diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index b07bf77ad..000000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,51 +0,0 @@ -cmake_minimum_required(VERSION 2.4) - -PROJECT(GAMEKIT) -SET(GAMEKIT 2.75) - -IF (NOT CMAKE_BUILD_TYPE) -# SET(CMAKE_BUILD_TYPE "Debug") - SET(CMAKE_BUILD_TYPE "Release") -ENDIF (NOT CMAKE_BUILD_TYPE) - - - -IF(COMMAND cmake_policy) - cmake_policy(SET CMP0003 NEW) -ENDIF(COMMAND cmake_policy) - -#SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -D_IRR_STATIC_LIB_ ) -ADD_DEFINITIONS( -D_IRR_STATIC_LIB_ ) -ADD_DEFINITIONS( -D_CRT_SECURE_NO_WARNINGS ) - - -#for now, just check for this X11 library on every platform, ignore on Mac and Win -#Linux and perhaps FreeBSD? -IF ( UNIX AND NOT APPLE ) -find_library( X11_VIDEO_LIBRARY Xxf86vm - /usr/lib64 - /usr/lib - /usr/local/lib64 - /usr/local/lib - /sw/lib - /opt/local/lib - DOC "Xxf86vm" - ) - - if( X11_VIDEO_LIBRARY ) - message( "--- Looking for Xxf86vm - found" ) - message( "--- Libs: " ${X11_VIDEO_LIBRARY} ) -# SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -D_IRR_LINUX_X11_VIDMODE_ ) - add_definitions( -D_IRR_LINUX_X11_VIDMODE_ ) - else( X11_VIDEO_LIBRARY ) - message( "--- Looking for Xxf86vm - not found" ) - endif( X11_VIDEO_LIBRARY ) - - set( X11_LIBRARIES ${X11_LIBRARIES} ${X11_VIDEO_LIBRARY} ) - -ENDIF (UNIX AND NOT APPLE) - - -SUBDIRS(bullet) -SUBDIRS(irrlicht-1.6) -SUBDIRS(gamekit) diff --git a/CharacterExporter.sln b/CharacterExporter.sln new file mode 100644 index 000000000..e8105d25f --- /dev/null +++ b/CharacterExporter.sln @@ -0,0 +1,51 @@ +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Exporter", "Exporter\Exporter.vcproj", "{F33CEE79-45EF-49A5-8A33-770D9A53FEE9}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "config-files", "config-files", "{4BAB174C-F023-41B0-8FA8-58B4367FE064}" + ProjectSection(SolutionItems) = preProject + data\anim.conf = data\anim.conf + data\boy3.conf = data\boy3.conf + data\character.conf = data\character.conf + data\middle.conf = data\middle.conf + data\multi-materials.conf = data\multi-materials.conf + data\simple-all.conf = data\simple-all.conf + data\simple-anims.conf = data\simple-anims.conf + data\simplest.conf = data\simplest.conf + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "batch-files", "batch-files", "{AEF5804C-E6C4-4DD5-A878-26A57E6A879F}" + ProjectSection(SolutionItems) = preProject + data\test.bat = data\test.bat + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "camera-files", "camera-files", "{AE99190D-5D6D-4407-9BEB-CE23ECB57B6E}" + ProjectSection(SolutionItems) = preProject + data\anim.camera = data\anim.camera + data\character.camera = data\character.camera + data\middle.camera = data\middle.camera + data\simple-all.camera = data\simple-all.camera + data\simple-anims.camera = data\simple-anims.camera + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F33CEE79-45EF-49A5-8A33-770D9A53FEE9}.Debug|Win32.ActiveCfg = Debug|Win32 + {F33CEE79-45EF-49A5-8A33-770D9A53FEE9}.Debug|Win32.Build.0 = Debug|Win32 + {F33CEE79-45EF-49A5-8A33-770D9A53FEE9}.Debug|x64.ActiveCfg = Debug|x64 + {F33CEE79-45EF-49A5-8A33-770D9A53FEE9}.Debug|x64.Build.0 = Debug|x64 + {F33CEE79-45EF-49A5-8A33-770D9A53FEE9}.Release|Win32.ActiveCfg = Release|Win32 + {F33CEE79-45EF-49A5-8A33-770D9A53FEE9}.Release|Win32.Build.0 = Release|Win32 + {F33CEE79-45EF-49A5-8A33-770D9A53FEE9}.Release|x64.ActiveCfg = Release|x64 + {F33CEE79-45EF-49A5-8A33-770D9A53FEE9}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/CharacterLoader.sln b/CharacterLoader.sln new file mode 100644 index 000000000..ac3e77391 --- /dev/null +++ b/CharacterLoader.sln @@ -0,0 +1,39 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Loader", "Loader\Loader.vcproj", "{C58DCF80-BE58-4080-A798-28F6DD577066}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Viewer", "Viewer\Viewer.vcproj", "{66B70A84-B92A-4AB4-9EF2-657AE42066CB}" + ProjectSection(ProjectDependencies) = postProject + {C58DCF80-BE58-4080-A798-28F6DD577066} = {C58DCF80-BE58-4080-A798-28F6DD577066} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C58DCF80-BE58-4080-A798-28F6DD577066}.Debug|Win32.ActiveCfg = Debug|Win32 + {C58DCF80-BE58-4080-A798-28F6DD577066}.Debug|Win32.Build.0 = Debug|Win32 + {C58DCF80-BE58-4080-A798-28F6DD577066}.Debug|x64.ActiveCfg = Debug|x64 + {C58DCF80-BE58-4080-A798-28F6DD577066}.Debug|x64.Build.0 = Debug|x64 + {C58DCF80-BE58-4080-A798-28F6DD577066}.Release|Win32.ActiveCfg = Release|Win32 + {C58DCF80-BE58-4080-A798-28F6DD577066}.Release|Win32.Build.0 = Release|Win32 + {C58DCF80-BE58-4080-A798-28F6DD577066}.Release|x64.ActiveCfg = Release|x64 + {C58DCF80-BE58-4080-A798-28F6DD577066}.Release|x64.Build.0 = Release|x64 + {66B70A84-B92A-4AB4-9EF2-657AE42066CB}.Debug|Win32.ActiveCfg = Debug|Win32 + {66B70A84-B92A-4AB4-9EF2-657AE42066CB}.Debug|Win32.Build.0 = Debug|Win32 + {66B70A84-B92A-4AB4-9EF2-657AE42066CB}.Debug|x64.ActiveCfg = Debug|x64 + {66B70A84-B92A-4AB4-9EF2-657AE42066CB}.Debug|x64.Build.0 = Debug|x64 + {66B70A84-B92A-4AB4-9EF2-657AE42066CB}.Release|Win32.ActiveCfg = Release|Win32 + {66B70A84-B92A-4AB4-9EF2-657AE42066CB}.Release|Win32.Build.0 = Release|Win32 + {66B70A84-B92A-4AB4-9EF2-657AE42066CB}.Release|x64.ActiveCfg = Release|x64 + {66B70A84-B92A-4AB4-9EF2-657AE42066CB}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Exporter/Animation.cpp b/Exporter/Animation.cpp new file mode 100644 index 000000000..0a2bc7b19 --- /dev/null +++ b/Exporter/Animation.cpp @@ -0,0 +1,67 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#include "Animation.h" + +#include + +#include +#include + +Animation::Animation(void) +{ +} + +Animation::~Animation(void) +{ +} + +void OutputAnimation(std::ostream &ofs, BlendShapeList &blendShapes, SAnimation* anim, SkeletonWriter& skel) +{ + // get file name + std::string filePath( MFileIO::currentFile().asChar() ); + std::string key("/"); + size_t found = filePath.rfind(key); + assert(found != std::string::npos); + std::string fileName = filePath.substr( found+1 ); + + ofs << "ANIMATION " + << fileName + << "\n"; + strcpy_s( anim->name, fileName.c_str() ); + + // get start and end times + int startFrame = static_cast(MAnimControl::minTime().as(MTime::kNTSCField)); + int endFrame = static_cast(MAnimControl::maxTime().as(MTime::kNTSCField)); + float startTime = static_cast(MAnimControl::minTime().as(MTime::kSeconds)); + float endTime = static_cast(MAnimControl::maxTime().as(MTime::kSeconds)); + + ofs << "\t" << "StartTime " << (float)startTime << std::endl; + ofs << "\t" << "EndTime " << (float)endTime << std::endl; + ofs << "\t" << "NumFrames " << (endFrame-startFrame+1) << std::endl; + ofs << "\t" << "NumBlendShapes " << blendShapes.m_NumBlendShapes << std::endl; + + anim->startTime = (float)startTime; + anim->endTime = (float)endTime; + anim->numFrames = (endFrame-startFrame+1); + anim->numBlendAnims = blendShapes.m_NumBlendShapes; + + if ( anim->numBlendAnims > 0 ) + blendShapes.outputBlendShapeAnims(ofs, startFrame, endFrame, anim); + + skel.writeJointAnimation( ofs, startFrame, endFrame ); + +} \ No newline at end of file diff --git a/Exporter/Animation.h b/Exporter/Animation.h new file mode 100644 index 000000000..750d4d15e --- /dev/null +++ b/Exporter/Animation.h @@ -0,0 +1,36 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#pragma once + +#include +#include +#include + +#include "BlendShapeList.h" +#include "SkeletonWriter.h" + +#include "../SharedStructures.h" + +class Animation +{ +public: + Animation(void); + ~Animation(void); + +}; + +void OutputAnimation(std::ostream &ofs, BlendShapeList &blendShapes, SAnimation* anim, SkeletonWriter& skel); diff --git a/Exporter/BlendShape.cpp b/Exporter/BlendShape.cpp new file mode 100644 index 000000000..495d414b6 --- /dev/null +++ b/Exporter/BlendShape.cpp @@ -0,0 +1,192 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#ifdef WIN32 + #ifndef NT_APP + #define NT_APP + #endif + #pragma warning(disable:4786) +#endif + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "BlendShape.h" +#include "Mesh.h" + +void DisableBlendShapes() +{ + MItDependencyNodes it(MFn::kBlendShape); + + while( !it.isDone() ) + { + MFnBlendShapeDeformer fn(it.item()); + + // get the envelope attribute plug + MPlug plug = fn.findPlug("en"); + + // set to 0 to disable FFD effect + plug.setValue(0.0f); + + it.next(); + } +} + +void EnableBlendShapes() +{ + MItDependencyNodes it(MFn::kBlendShape); + while( !it.isDone() ) + { + MFnBlendShapeDeformer fn(it.item()); + + // get the envelope attribute plug + MPlug plug = fn.findPlug("en"); + + // set to 1 to enable FFD effect + plug.setValue(1.0f); + + it.next(); + } +} + +BlendShape::BlendShape(void) +{ + m_WeightList = NULL; +} + +BlendShape::~BlendShape(void) +{ + if (m_WeightList) + delete [] m_WeightList; +} + +void BlendShape::extractBlendShape(MObject& DeformerObj) +{ + // attach the function set to the object + MFnBlendShapeDeformer fnBlendShape(DeformerObj); + m_Name = fnBlendShape.name().asChar(); + + // get a list of objects that this blend shape deforms + MObjectArray base_objects; + fnBlendShape.getBaseObjects(base_objects); + assert( base_objects.length() == 1 ); // Assume only one base object + + // get the base shape + MObject Base = base_objects[0]; + MFnDependencyNode fnDep(Base); + m_BaseName = fnDep.name().asChar(); + + // get the weight + m_NumWeights = fnBlendShape.numWeights(); + MIntArray indexList; + fnBlendShape.weightIndexList(indexList); + assert( m_NumWeights == indexList.length() ); + + if ( m_NumWeights > 0 ) + { + m_WeightList = new BlendShapeWeight[ m_NumWeights ]; + + // only want non-history items + for(unsigned int i = 0; i != m_NumWeights; ++i) + { + // get an array of target shapes + MObjectArray targets; + fnBlendShape.getTargets(Base, indexList[i], targets); + + m_WeightList[i].extractWeightAnimation( fnBlendShape, targets[0], indexList[i] ); + + unsigned int numTarget = targets.length(); + if ( numTarget == 1 ) + m_WeightList[i].extractTarget( fnBlendShape, targets[0], indexList[i] ); + else if ( numTarget == 0 ) + { + // oops, target is probably deleted + // reconstruct target shape from base mesh by setting only this weight to 1.0f + EnableBlendShapes(); + for ( int j = 0; j != m_NumWeights; ++j ) + fnBlendShape.setWeight( indexList[j], 0.0f ); + fnBlendShape.setWeight( indexList[i], 1.0f ); + m_WeightList[i].extractTarget( fnBlendShape, Base, indexList[i] ); + DisableBlendShapes(); + } + else + { + assert(0); // more than two targets are not supported yet. + } + } + } +} + +void BlendShape::outputBlendAnim(std::ostream& ofs, int startFrame, int endFrame, SBlendAnim* blendAnim) +{ + // print blend shape name + ofs << "\t\t" << "BLENDSHAPE " << m_Name << std::endl; + + // write base name and ID + ofs << "\t\t\t" << "Base " << m_BaseName << std::endl; + ofs << "\t\t\t" << "id= " << GetMeshID( m_BaseName ) << std::endl; + ofs << "\t\t\t" << "NumWeights " << m_NumWeights << std::endl; + + strcpy_s( blendAnim->name, m_Name.c_str() ); + strcpy_s( blendAnim->baseName, m_BaseName.c_str() ); + blendAnim->baseMeshID = GetMeshID( m_BaseName ); + blendAnim->numWeights = m_NumWeights; + + int numFrames = endFrame - startFrame + 1; + + // set float format + std::streamsize oldPrec = ofs.precision(5); + ofs.setf(std::ios::fixed,std::ios::floatfield); // floatfield set to fixed + ofs.setf(std::ios::showpos); // write + for positive + + uint numFloat = numFrames * blendAnim->numWeights; + if( numFloat > 0 ) + { + blendAnim->weights = (float*)calloc( numFloat, sizeof(float) ); //new float[ numFloat ]; + int count = 0; + for(int i = 0; i < numFrames; i++) + { + ofs << "\t\t\t\t" ; + for ( unsigned int j = 0; j < m_NumWeights; j++ ) + { + BlendShapeWeight *weight = &m_WeightList[j]; + ofs << weight->m_Weights[i] << " "; + blendAnim->weights[ count ] = weight->m_Weights[i]; + count++; + } + ofs << std::endl; + } + assert( count == numFloat ); + } + + // unset float format + ofs.precision(oldPrec); + ofs.unsetf(std::ios::floatfield); + ofs.unsetf(std::ios::showpos); +} diff --git a/Exporter/BlendShape.h b/Exporter/BlendShape.h new file mode 100644 index 000000000..b7b145929 --- /dev/null +++ b/Exporter/BlendShape.h @@ -0,0 +1,60 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#pragma once + +#ifdef WIN32 + #ifndef NT_APP + #define NT_APP + #endif + #pragma warning(disable:4786) +#endif + +#include +#include + +#include + +#include "BlendShapeWeight.h" + +#include "../SharedStructures.h" + +//using namespace std; + +void DisableBlendShapes(); + +void EnableBlendShapes(); + +class BlendShape +{ +public: + BlendShape(void); + ~BlendShape(void); + + void extractBlendShape(MObject& DeformerObj); + + void outputBlendAnim(std::ostream& ofs, int startFrame, int endFrame, SBlendAnim* blendAnim); + + // blend shape data + std::string m_Name; + std::string m_BaseName; // Assuming one base object for now + int m_BaseID; + unsigned int m_NumWeights; + BlendShapeWeight* m_WeightList; +}; + + + diff --git a/Exporter/BlendShapeList.cpp b/Exporter/BlendShapeList.cpp new file mode 100644 index 000000000..0addad338 --- /dev/null +++ b/Exporter/BlendShapeList.cpp @@ -0,0 +1,108 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#ifdef WIN32 + #ifndef NT_APP + #define NT_APP + #endif + #pragma warning(disable:4786) +#endif + +#include +#include + +#include + +#include "BlendShapeList.h" + +BlendShapeList::BlendShapeList(void) +{ + m_BlendShapes = NULL; +} + +BlendShapeList::~BlendShapeList(void) +{ + if( m_BlendShapes ) + delete [] m_BlendShapes; +} + + +void BlendShapeList::extractAllBlendShapes() +{ + // create an iterator to go through all blend shapes + MItDependencyNodes it(MFn::kBlendShape); + m_NumBlendShapes = 0; + while(!it.isDone()) + { + m_NumBlendShapes++; + it.next(); + } + + if ( m_NumBlendShapes > 0 ) + { + m_BlendShapes = new BlendShape[ m_NumBlendShapes ]; + + it.reset(MFn::kBlendShape); + int i = 0; + while(!it.isDone()) + { + m_BlendShapes[i++].extractBlendShape( it.thisNode() ); + it.next(); + } + } +} + +BlendShapeBinding BlendShapeList::getBlendShape(const std::string& meshName, BlendShape** blendShape) const +{ + // find BlendShape with a mesh named meshName + for( int i = 0; i < m_NumBlendShapes; i++ ) + { + BlendShape *bs = &m_BlendShapes[i]; + if ( bs->m_BaseName.compare( meshName ) == 0 ) + { + // found + *blendShape = bs; + return BASE; + } + // check if mesh is a target + for ( unsigned int j = 0; j < bs->m_NumWeights; j++) + { + BlendShapeWeight *bsw = &bs->m_WeightList[j]; + if ( bsw->m_TargetName.compare( meshName ) == 0 ) + { + *blendShape = bs; + return TARGET; + } + } + + } + + return NONE; +} + +void BlendShapeList::outputBlendShapeAnims(std::ostream& ofs, int startFrame, int endFrame, SAnimation* anim) +{ + anim->numBlendAnims = m_NumBlendShapes; + if ( anim->numBlendAnims > 0 ) + { + anim->blendAnims = (SBlendAnim*)calloc(anim->numBlendAnims, sizeof(SBlendAnim));//new SBlendAnim[ anim->numBlendAnims ]; + for( int i = 0; i < m_NumBlendShapes; i++ ) + { + BlendShape *bs = &m_BlendShapes[i]; + bs->outputBlendAnim(ofs, startFrame, endFrame, &anim->blendAnims[i]); + } + } +} diff --git a/Exporter/BlendShapeList.h b/Exporter/BlendShapeList.h new file mode 100644 index 000000000..51b4b0a6a --- /dev/null +++ b/Exporter/BlendShapeList.h @@ -0,0 +1,53 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#pragma once + +#ifdef WIN32 + #ifndef NT_APP + #define NT_APP + #endif + #pragma warning(disable:4786) +#endif + +#include +#include + +#include "BlendShape.h" + +enum BlendShapeBinding +{ + NONE, + BASE, + SKINED_BASE, + TARGET +}; + +class BlendShapeList +{ +public: + BlendShapeList(void); + ~BlendShapeList(void); + + void extractAllBlendShapes(); + + BlendShapeBinding getBlendShape(const std::string& meshName, BlendShape** blendShape) const; + + int m_NumBlendShapes; + BlendShape* m_BlendShapes; + + void outputBlendShapeAnims(std::ostream& ofs, int startFrame, int endFrame, SAnimation* anim); +}; diff --git a/Exporter/BlendShapeWeight.cpp b/Exporter/BlendShapeWeight.cpp new file mode 100644 index 000000000..17b98288f --- /dev/null +++ b/Exporter/BlendShapeWeight.cpp @@ -0,0 +1,132 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#ifdef WIN32 + #ifndef NT_APP + #define NT_APP + #endif + #pragma warning(disable:4786) +#endif + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include "BlendShapeWeight.h" + +BlendShapeWeight::BlendShapeWeight(void) +{ + m_Positions = NULL; + m_Normals = NULL; + m_Weights = NULL; +} + +BlendShapeWeight::~BlendShapeWeight(void) +{ + if (m_Positions) + delete [] m_Positions; + if (m_Normals) + delete [] m_Normals; + if (m_Weights) + delete [] m_Weights; +} + +void BlendShapeWeight::extractTarget(MFnBlendShapeDeformer& fnBlendShape, MObject& target, int weightIndex) +{ + MFnDependencyNode fnDep( target ); + m_TargetName = fnDep.name().asChar(); + + MPointArray vertexArray; + MFloatVectorArray normalArray; + + MStatus status = MStatus::kSuccess; + + MFnMesh m_Mesh( target ); + if (MStatus::kFailure == m_Mesh.getPoints(vertexArray, MSpace::kWorld)) { + MGlobal::displayError("MFnMesh::getPoints"); + status = MStatus::kFailure; + } + + if (MStatus::kFailure == m_Mesh.getNormals(normalArray, MSpace::kWorld)) { + MGlobal::displayError("MFnMesh::getNormals"); + status = MStatus::kFailure; + } + + // attach the function set to the object + MItGeometry it(target); + + // extract points + m_NumPositions = it.count(); + assert( vertexArray.length() == m_NumPositions ); + m_Positions = new float[ m_NumPositions * 3 ]; + + int i = 0; + // iterate through all geometry points + while(!it.isDone()) + { + MPoint P = it.position(); + + m_Positions[i++] = (float)P.x; + m_Positions[i++] = (float)P.y; + m_Positions[i++] = (float)P.z; + + it.next(); + } + assert( i == m_NumPositions*3 ); + + // extract normals + m_NumNormals = normalArray.length(); + m_Normals = new float[ m_NumNormals * 3 ]; + for ( unsigned int i = 0; i < m_NumNormals; i++ ) + { + m_Normals[i*3 + 0] = normalArray[i].x; + m_Normals[i*3 + 1] = normalArray[i].y; + m_Normals[i*3 + 2] = normalArray[i].z; + } +} + +void BlendShapeWeight::extractWeightAnimation(MFnBlendShapeDeformer& fnBlendShape, MObject& target, int weightIndex) +{ + // get start and end times + int startFrame = static_cast(MAnimControl::minTime().as(MTime::kNTSCField)); + int endFrame = static_cast(MAnimControl::maxTime().as(MTime::kNTSCField)); + m_StartTime = static_cast(MAnimControl::minTime().as(MTime::kSeconds)); + m_EndTime = static_cast(MAnimControl::maxTime().as(MTime::kSeconds)); + + m_NumFrames = endFrame - startFrame + 1; + + if( m_NumFrames > 0 ) + { + m_Weights = new float[ m_NumFrames ]; + + //for(int j = startFrame; j <= endFrame; ++j) + for( unsigned int i = 0; i < m_NumFrames; i++) + { + // set the current time + MAnimControl::setCurrentTime( MTime( i+startFrame, MTime::kNTSCField ) ); + m_Weights[i] = (float)fnBlendShape.weight( weightIndex ); + } + } +} diff --git a/Exporter/BlendShapeWeight.h b/Exporter/BlendShapeWeight.h new file mode 100644 index 000000000..decde8b95 --- /dev/null +++ b/Exporter/BlendShapeWeight.h @@ -0,0 +1,58 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#pragma once + +#ifdef WIN32 + #ifndef NT_APP + #define NT_APP + #endif + #pragma warning(disable:4786) +#endif + +#include +#include +#include +#include + +#include +#include + +class BlendShapeWeight +{ +public: + BlendShapeWeight(void); + ~BlendShapeWeight(void); + + void extractTarget(MFnBlendShapeDeformer& fnBlendShape, MObject& target, int weightIndex); + + void extractWeightAnimation(MFnBlendShapeDeformer& fnBlendShape, MObject& target, int weightIndex); + + // Target Mesh + std::string m_TargetName; + unsigned int m_TargetID; + unsigned int m_NumPositions; + float* m_Positions; + unsigned int m_NumNormals; + float* m_Normals; + + // animation data + float m_StartTime; + float m_EndTime; + unsigned int m_NumFrames; + float* m_Weights; + +}; diff --git a/Exporter/Exporter.vcproj b/Exporter/Exporter.vcproj new file mode 100644 index 000000000..e686c661a --- /dev/null +++ b/Exporter/Exporter.vcproj @@ -0,0 +1,460 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Exporter/JointWriter.cpp b/Exporter/JointWriter.cpp new file mode 100644 index 000000000..8c2f1b6a4 --- /dev/null +++ b/Exporter/JointWriter.cpp @@ -0,0 +1,154 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#include "JointWriter.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +//JointWriter::JointWriter() : m_Obj( NULL ) +//{ +//} + +//JointWriter::JointWriter( MObject& obj ) : m_Obj( obj ) +//{ +//} +JointWriter::JointWriter( MDagPath& path ) : m_DagPath( path ) +{ +} + +//JointWriter::JointWriter( JointWriter const& jw ) : m_Obj( jw.m_Obj ) +//{ +//} +// +//JointWriter & JointWriter::operator = ( const JointWriter & jw ) +//{ +// return *(new JointWriter( jw )); +//} + +JointWriter::~JointWriter(void) +{ +} + + +static bool isVisible(MFnDagNode& fnDag, MStatus& status) +{ + if(fnDag.isIntermediateObject()) + return false; + + MPlug visPlug = fnDag.findPlug("visibility", &status); + if (MStatus::kFailure == status) + { + MGlobal::displayError("MPlug::findPlug"); + return false; + } + else + { + bool visible; + status = visPlug.getValue(visible); + if (MStatus::kFailure == status) + { + MGlobal::displayError("MPlug::getValue"); + } + return visible; + } +} + +void JointWriter::extractJointTransformation() +{ + MFnTransform fnX( m_DagPath ); + + // extract visibility + //MDagPath p; + //fnX.getPath(p); + MFnDagNode fnDagNode( m_DagPath ); + MStatus status; + bool visibility = isVisible( fnDagNode, status ); + + // extract transformation + double Scale[3]; + fnX.getScale(Scale); + + MVector trans = fnX.translation(MSpace::kTransform); + + MQuaternion R(0,0,0,1); + fnX.getRotation(R); + + // combined rotation for joint + if ( fnX.object().hasFn( MFn::kJoint ) ) + { + MFnIkJoint fnJoint( m_DagPath ); + MQuaternion JO(0,0,0,1); + MQuaternion RO(0,0,0,1); + fnJoint.getOrientation(JO); + RO = fnJoint.rotateOrientation(MSpace::kObject); + R = RO * R * JO; + } + + // extract transformation values + m_visibility = visibility; + m_rotation[0] = (float)R.x; + m_rotation[1] = (float)R.y; + m_rotation[2] = (float)R.z; + m_rotation[3] = (float)R.w; + m_translation[0] = (float)trans.x; + m_translation[1] = (float)trans.y; + m_translation[2] = (float)trans.z; + m_scale[0] = (float)Scale[0]; + m_scale[1] = (float)Scale[1]; + m_scale[2] = (float)Scale[2]; +} + + +void JointWriter::writeJointTransformation(std::ostream& ofs) +{ + // set float format + std::streamsize oldPrec = ofs.precision(5); + ofs.setf(std::ios::fixed,std::ios::floatfield); // floatfield set to fixed + ofs.setf(std::ios::showpos); // write + for positive + + ofs << m_visibility << " " + << m_rotation[0] << " " << m_rotation[1] << " " << m_rotation[2] << " " << m_rotation[3] << " " + << m_translation[0] << " " << m_translation[1] << " " << m_translation[2] << " " + << m_scale[0] << " " << m_scale[1] << " " << m_scale[2] << std::endl; + + // unset float format + ofs.precision(oldPrec); + ofs.unsetf(std::ios::floatfield); + ofs.unsetf(std::ios::showpos); +} + +bool JointWriter::isEqual(const JointWriter* other) +{ + return + m_visibility == other->m_visibility && + m_rotation[0] == other->m_rotation[0] && + m_rotation[1] == other->m_rotation[1] && + m_rotation[2] == other->m_rotation[2] && + m_rotation[3] == other->m_rotation[3] && + m_translation[0] == other->m_translation[0] && + m_translation[1] == other->m_translation[1] && + m_translation[2] == other->m_translation[2] && + m_scale[0] == other->m_scale[0] && + m_scale[1] == other->m_scale[1] && + m_scale[2] == other->m_scale[2]; +} diff --git a/Exporter/JointWriter.h b/Exporter/JointWriter.h new file mode 100644 index 000000000..d966f1d90 --- /dev/null +++ b/Exporter/JointWriter.h @@ -0,0 +1,54 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#pragma once + +#ifdef WIN32 + #ifndef NT_APP + #define NT_APP + #endif + + #pragma warning(disable:4786) +#endif + +#include + +//#include +#include + +#include "../SharedStructures.h" + +class JointWriter : public Joint +{ +public: + //MObject& m_Obj; + MDagPath m_DagPath; + + //JointWriter(); + JointWriter( MDagPath& path ); + //JointWriter( JointWriter const& jw ); + //JointWriter & operator = ( const JointWriter & jw ); + ~JointWriter(void); + + // extract transformation of a joint + void extractJointTransformation(); + + // write joint transformation + void writeJointTransformation(std::ostream& ofs); + + // compare joint transformation with another joint + bool isEqual(const JointWriter* other); +}; diff --git a/Exporter/Material.cpp b/Exporter/Material.cpp new file mode 100644 index 000000000..90894fddb --- /dev/null +++ b/Exporter/Material.cpp @@ -0,0 +1,256 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#ifdef WIN32 + #ifndef NT_APP + #define NT_APP + #endif + + #pragma warning(disable:4786) +#endif + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "Material.h" +#include "Texture.h" + +std::map g_MaterialToID_Map; +unsigned int g_MatID_gen = 0; + +unsigned int GetMaterialID(const MString &material) +{ + std::map::iterator it = g_MaterialToID_Map.find(material.asChar()); + + if (it != g_MaterialToID_Map.end()) + { + return it->second; + } + return 0; +} + +void ClearMaterials(SModel* model) +{ + g_MaterialToID_Map.clear(); g_MatID_gen = 0; + + free( model->materials ); +} + +void ExtractAttribute(MFnDependencyNode& fn, std::string name, SMatAttrib& attrib) +{ + MPlug p; + + // extract attribute color + std::string r = name + "R"; + std::string g = name + "G"; + std::string b = name + "B"; + + p = fn.findPlug(r.c_str()); p.getValue(attrib.color[0]); + p = fn.findPlug(g.c_str()); p.getValue(attrib.color[1]); + p = fn.findPlug(b.c_str()); p.getValue(attrib.color[2]); + + // extract attribute texture + MString texname; + + p = fn.findPlug(name.c_str()); + + MPlugArray plugs; + p.connectedTo(plugs,true,true); + + for(int i = 0; i != plugs.length(); ++i) + { + if (plugs[i].node().apiType() == MFn::kFileTexture) + { + MFnDependencyNode fnDep(plugs[i].node()); + texname = fnDep.name(); + break; + } + } + + attrib.textureID = GetTextureID( texname ); +} + +void ExtractNormalMap(MFnDependencyNode& fn, unsigned int* tex = NULL) +{ + MString texname; + + MPlug p = fn.findPlug( "normalCamera" ); + MPlugArray plugs; + p.connectedTo(plugs,true,true); + + for(int i = 0; i != plugs.length(); ++i) + { + if (plugs[i].node().apiType() == MFn::kBump) + { + MFnDependencyNode fnDepBump( plugs[i].node() ); + MPlug pp = fnDepBump.findPlug( "bumpValue" ); + + MPlugArray pplugs; + pp.connectedTo(pplugs, true, true); + + for(int j = 0; j != pplugs.length(); ++j) + { + if (pplugs[j].node().apiType() == MFn::kFileTexture) + { + MFnDependencyNode fnDep(pplugs[j].node()); + texname = fnDep.name(); + break; + } + } + } + } + + *tex = GetTextureID( texname ); +} + +void ExtractMaterials(SModel* model) +{ + MItDependencyNodes itDep(MFn::kLambert); + + // count materials + model->numMaterials = 0; + while (!itDep.isDone()) + { + model->numMaterials++; + itDep.next(); + } + + // extract each material data + if ( model->numMaterials > 0 ) + { + model->materials = (SMaterial*)calloc(model->numMaterials, sizeof(SMaterial)); + unsigned int count = 0; + itDep.reset(MFn::kLambert); + while (!itDep.isDone()) + { + SMaterial* mat = &model->materials[ count ]; + mat->type = MATERIAL_LAMBERT; + MFnLambertShader fnLambert( itDep.item() ); + strcpy_s( mat->name, fnLambert.name().asChar() ); + g_MaterialToID_Map.insert( std::make_pair( mat->name, ++g_MatID_gen ) ); + mat->materialID = g_MatID_gen; + + ExtractAttribute(fnLambert, "ambientColor", mat->ambient); + ExtractAttribute(fnLambert, "color", mat->diffuse); + ExtractAttribute(fnLambert, "incandescence", mat->incandescence); + ExtractAttribute(fnLambert, "transparency", mat->transparency); + + ExtractNormalMap(fnLambert, &mat->normalmapTex); + + switch(itDep.item().apiType()) + { + case MFn::kPhong: + { + MFnPhongShader fnPhong( itDep.item() ); + mat->type = MATERIAL_PHONG; + ExtractAttribute(fnPhong, "specularColor", mat->specular); + mat->shininess = (float)(fnPhong.cosPower()); + } + break; + case MFn::kBlinn: + { + MFnBlinnShader fnBlinn( itDep.item() ); + mat->type = MATERIAL_BLINN; + ExtractAttribute(fnBlinn, "specularColor", mat->specular); + mat->eccentricity = (float)(fnBlinn.eccentricity()); + mat->specularRollOff = (float)(fnBlinn.specularRollOff()); + } + break; + } + + itDep.next(); + count++; + } + } +} + +void OutputAttribute(std::ostream& ofs, std::string name, const SMatAttrib& attrib) +{ + ofs << "\t\t" << name << " " << attrib.color[0] << " " << attrib.color[1] << " " << attrib.color[2] << " tex= " << attrib.textureID << "\n"; +} + +void OutputMaterials(std::ostream &ofs, SModel* model) +{ + ofs << "METERIALS" << std::endl; + ofs << "NumMaterials= " << model->numMaterials << std::endl; + + if ( model->numMaterials == 0 ) + { + model->materials = NULL; + return; + } + + for ( uint i = 0; i < model->numMaterials; i++ ) + { + SMaterial* mat = &model->materials[ i ]; + ofs << "\t" << "MaterialType= " << mat->type << std::endl; + ofs << "\t" << SMatNames[mat->type] << " " << mat->name << "\n"; + ofs << "\t\t" << "materialID= " << mat->materialID << std::endl; + + // set float format + std::streamsize oldPrec = ofs.precision(5); + ofs.setf(std::ios::fixed,std::ios::floatfield); // floatfield set to fixed + + OutputAttribute(ofs, "ambient ", mat->ambient); + OutputAttribute(ofs, "diffuse ", mat->diffuse); + OutputAttribute(ofs, "incandescence ", mat->incandescence); + OutputAttribute(ofs, "transparency ", mat->transparency); + + ofs << "\t\t" << "normalmap tex= " << mat->normalmapTex << "\n"; + + switch(mat->type) + { + case MATERIAL_PHONG: + { + OutputAttribute(ofs, "specular ", mat->specular); + ofs << "\t\t" << "shininess " << mat->shininess << std::endl; + } + break; + case MATERIAL_BLINN: + { + OutputAttribute(ofs, "specular ", mat->specular); + ofs << "\t\t" << "eccentricity " << mat->eccentricity << std::endl; + ofs << "\t\t" << "specularRollOff " << mat->specularRollOff << std::endl; + } + break; + case MATERIAL_LAMBERT: + { + // nothing + } + break; + default: + assert(0); exit(1); + } + + // unset float format + ofs.precision(oldPrec); + ofs.unsetf(std::ios::floatfield); + } +} + diff --git a/Exporter/Material.h b/Exporter/Material.h new file mode 100644 index 000000000..4269cd4b4 --- /dev/null +++ b/Exporter/Material.h @@ -0,0 +1,29 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#pragma once + +#include +#include + +#include "../SharedStructures.h" + +unsigned int GetMaterialID(const MString &material); + +void ClearMaterials(SModel* model); + +void ExtractMaterials(SModel* model); +void OutputMaterials(std::ostream &ofs, SModel* model); diff --git a/Exporter/Mesh.cpp b/Exporter/Mesh.cpp new file mode 100644 index 000000000..9c495b7f9 --- /dev/null +++ b/Exporter/Mesh.cpp @@ -0,0 +1,368 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#ifdef WIN32 + #ifndef NT_APP + #define NT_APP + #endif + + #pragma warning(disable:4786) +#endif + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "Mesh.h" +#include "Material.h" +#include "MeshWriter.h" + +#include "BlendShape.h" + +/// this is a global variable that is used to generate unique object id numbers. +unsigned int MeshRefID = 0; + +/// all of the object references are stored within a map +typedef std::map MeshMap; + +/// the iterator type +typedef MeshMap::iterator MeshIT; + +/// a map of all useful transforms +MeshMap g_Meshes; + + +unsigned int GetMeshID(const std::string name) +{ + // find the mesh + MeshIT it = g_Meshes.find(name); + + // if not found + if (it == g_Meshes.end()) + { + // insert entry into mesh map + std::pair pair_ = g_Meshes.insert( std::make_pair( name , ++MeshRefID ) ); + + return pair_.first->second; + } + return it->second; +} + +void ClearMeshes(SModel* model) +{ + g_Meshes.clear(); MeshRefID = 0; + + for ( uint i = 0; i < model->numMeshes; i++ ) + { + SMesh* mesh = &model->meshes[ i ]; + free( mesh->verts ); + for (uint i = 0; i < mesh->numMats; i++) + { + SMatGrp* matGrp = &mesh->matGrps[i]; + free( matGrp->triIndices ); + } + free( mesh->matGrps ); + } + + Skeleton* s = &model->skeleton; + free( s->m_parentIndices ); + free( s->m_basePose ); + free( s->m_jointNameHashes ); +} + +///////////////////////////////////////////////////////////////////////////////////////// +bool shouldBeExported(const MObject &obj, const BlendShapeList& blendShapeList) +{ + MFnMesh fnMesh( obj ); + std::string meshName( fnMesh.name().asChar() ); + + // determine blendshape binding + BlendShape* blendShape = NULL; + BlendShapeBinding binding = blendShapeList.getBlendShape( meshName, &blendShape ); + if ( binding == TARGET ) + return false; // no need to export target objects + + // ignore all 'intermediate objects' + if ( fnMesh.isIntermediateObject() ) + return false; + + return true; +} + +void ExtractMesh(const MObject &obj, const BlendShapeList& blendShapeList, SMesh* mesh, SkeletonWriter* skeleton ) +{ + MFnMesh fnMesh( obj ); + strcpy_s( mesh->name, fnMesh.name().asChar() ); + + // determine blendshape binding + BlendShape* blendShape = NULL; + BlendShapeBinding binding = blendShapeList.getBlendShape( mesh->name, &blendShape ); + + mesh->meshID = GetMeshID(mesh->name); + + std::cout << "extracting mesh " << mesh->name << std::endl; + + MeshWriter meshWriter( fnMesh ); + meshWriter.setSkeletonWriter( skeleton ); + meshWriter.extractPolyMesh(); + if ( binding == BASE ) + { + assert( blendShape ); + meshWriter.setBlendShape( blendShape ); + } + meshWriter.extractMeshData( mesh ); + + // extract parent hash + MObject& parentObj = fnMesh.parent(0); + assert(parentObj.hasFn(MFn::kTransform)); + MFnTransform fnX(parentObj); + const char* parentName = fnX.name().asChar(); + int parentIndex = skeleton->findJoint( parentName ); + if ( parentIndex != -1 ) + mesh->parentHash = skeleton->m_jointNameHashList[ parentIndex ]; + else + mesh->parentHash = 0; +} + +void ExtractAllMeshes( const BlendShapeList& blendShapeList, SModel* model, SkeletonWriter* skeleton ) +{ + MItDependencyNodes itDep(MFn::kMesh); + + // count meshes + model->numMeshes = 0; + while (!itDep.isDone()) + { + if ( shouldBeExported( itDep.thisNode(), blendShapeList ) ) + model->numMeshes++; + itDep.next(); + } + + if ( model->numMeshes > 0 ) + { + // allocate meshes + model->meshes = (SMesh*)calloc(model->numMeshes, sizeof(SMesh)); + unsigned int count = 0; + itDep.reset(MFn::kMesh); + while (!itDep.isDone()) + { + if ( shouldBeExported( itDep.thisNode(), blendShapeList ) ) + { + SMesh* mesh = &model->meshes[ count ]; + //OutputMesh(ofs, itDep.thisNode(), blendShapeList, mesh); + ExtractMesh(itDep.thisNode(), blendShapeList, mesh, skeleton); + count++; + } + itDep.next(); + } + } + + // copy skeleton writer data to skeleton in the model + Skeleton* s = &model->skeleton; + s->m_numJoints = skeleton->m_numJoints; + if ( s->m_numJoints > 0 ) + { + s->m_parentIndices = (int*)calloc(s->m_numJoints, sizeof(int)); + s->m_basePose = (Joint*)calloc(s->m_numJoints, sizeof(Joint)); + s->m_jointNameHashes = (uint*)calloc(s->m_numJoints, sizeof(uint)); + + for( unsigned int i = 0; i < s->m_numJoints; i++ ) + { + //strcpy_s( s->m_basePose[i].name, skeleton->m_jointNames[i].c_str() ); + s->m_parentIndices[i] = skeleton->m_parentIndexList[i]; + s->m_basePose[i] = skeleton->m_jointWriters[i]; + s->m_jointNameHashes[i] = skeleton->m_jointNameHashList[i]; + } + } + +} + +void OutputMesh(std::ostream& ofs, SMesh* mesh ) +{ + std::cout << "outputting mesh " << mesh->name << std::endl; + + ofs << "\t" << "MESH " << mesh->name << "\n"; + ofs << "\t\t" << "meshID= " << mesh->meshID << "\n"; + ofs << "\t\t" << "ParentHash= " << mesh->parentHash << std::endl; + + // output mesh info + ofs << "\t\t" << "NumBlendshapeWeights " << mesh->numBlends << endl; + ofs << "\t\t" << "IsSkinned " << mesh->isSkinned << endl; + if ( mesh->isSkinned ) + { + ofs << "\t\t\t" << "SKIN " << mesh->skinName << std::endl; + ofs << "\t\t\t" << "NumInfluences " << mesh->numSkinInfHashes << std::endl; + + // output skin inf hashes + if ( mesh->numSkinInfHashes > 0 ) + { + ofs << "\t\t\t\t"; + for ( uint infCount = 0; infCount < mesh->numSkinInfHashes; infCount++ ) + { + ofs << mesh->skinInfHashes[ infCount ] << " "; + } + } + ofs << std::endl; + } + ofs << "\t\t" << "Stride " << mesh->stride << endl; + ofs << "\t\t" << "// Vertices format: "; + ofs << "Position.xyz | Normal.xyz"; + for ( unsigned int i = 0; i < mesh->numBlends; i++ ) + ofs << " | BlendshapePos" << i << ".dxdydz | BlendShapeNormals" << i << ".dxdydz"; + ofs << " | UV"; + if ( mesh->isSkinned ) + ofs << " | JointIndices.0123 | JointWeights.0123"; + ofs << "\n"; + ofs << "\t\t" << "NumVerts " << mesh->numVerts << std::endl; + + unsigned int numFloat = mesh->numVerts * mesh->stride; + + // output verts + if ( numFloat > 0 ) + { + // set float format + streamsize oldPrec = ofs.precision(5); + ofs.setf(std::ios::fixed,std::ios::floatfield); // floatfield set to fixed + ofs.setf(std::ios::showpos); // write + for positive + + // output verts + uint count = 0; + for (uint i = 0; i < mesh->numVerts; i++) + { + ofs << "\t\t" << "\t"; + // position and normal + ofs << mesh->verts[ count++ ] << " "; + ofs << mesh->verts[ count++ ] << " "; + ofs << mesh->verts[ count++ ] << " "; + ofs << mesh->verts[ count++ ] << " "; + ofs << mesh->verts[ count++ ] << " "; + ofs << mesh->verts[ count++ ] << " "; + // blendshape target postions and normals + for ( unsigned int j = 0; j < mesh->numBlends; j++ ) + { + ofs << mesh->verts[ count++ ] << " "; + ofs << mesh->verts[ count++ ] << " "; + ofs << mesh->verts[ count++ ] << " "; + ofs << mesh->verts[ count++ ] << " "; + ofs << mesh->verts[ count++ ] << " "; + ofs << mesh->verts[ count++ ] << " "; + } + // uv + ofs << mesh->verts[ count++ ] << " "; + ofs << mesh->verts[ count++ ] << " "; + // skinning + if ( mesh->isSkinned ) + { + ofs << mesh->verts[ count++ ] << " "; + ofs << mesh->verts[ count++ ] << " "; + ofs << mesh->verts[ count++ ] << " "; + ofs << mesh->verts[ count++ ] << " "; + ofs << mesh->verts[ count++ ] << " "; + ofs << mesh->verts[ count++ ] << " "; + ofs << mesh->verts[ count++ ] << " "; + ofs << mesh->verts[ count++ ]; + } + ofs << endl; + } + assert( count == numFloat ); + + // unset float format + ofs.precision(oldPrec); + ofs.unsetf(std::ios::floatfield); + ofs.unsetf(std::ios::showpos); + } + + ofs << "\t\t" << "//" << endl; + + // output mesh groups and triangles + ofs << "\t\t" << "// Material Groups:\n"; + ofs << "\t\t" << "MaterialCount= " << mesh->numMats << std::endl; + for (uint i = 0; i < mesh->numMats; i++) + { + SMatGrp* matGrp = &mesh->matGrps[i]; + ofs << "\t\t" << "MaterialID= " << matGrp->materialID << endl; + // My triangles out + ofs << "\t\t" << "// Triangles:\n"; + ofs << "\t\t" << "TriCount " << matGrp->triCount << std::endl; + for (unsigned int i = 0; i < matGrp->triCount; i++) + { + ofs << "\t\t" << "\t"; + for (int j = 0; j < 3; j++) + { + int index = matGrp->triIndices[ i*3 + j ]; + ofs << index << " "; + } + ofs << std::endl; + } + } +} + +void OutputAllMeshes( std::ostream& ofs, SModel* model ) +{ + ofs << "MESHES" << std::endl; + ofs << "NumMeshes= " << model->numMeshes << std::endl; + + for ( uint i = 0; i < model->numMeshes; i++ ) + { + SMesh* mesh = &model->meshes[ i ]; + OutputMesh(ofs, mesh); + } + + // output skeleton + Skeleton* s = &model->skeleton; + ofs << "SKELETON" << std::endl; + ofs << "numJoints " << s->m_numJoints << std::endl; + for( unsigned int i = 0; i < s->m_numJoints; i++ ) + { + Joint* j = &s->m_basePose[i]; + + ofs << "\t" << "JOINT " << j->name << std::endl; + ofs << "\t\t" << "nameHash " << s->m_jointNameHashes[i] << std::endl; + ofs << "\t\t" << "parentIndex " << s->m_parentIndices[i] << std::endl; + ofs << "\t\t" << "Transformation "; + + //JointWriter joint = m_jointWriters[i]; + //joint.writeJointTransformation( ofs ); + + // set float format + std::streamsize oldPrec = ofs.precision(5); + ofs.setf(std::ios::fixed,std::ios::floatfield); // floatfield set to fixed + ofs.setf(std::ios::showpos); // write + for positive + + ofs << j->m_visibility << " " + << j->m_rotation[0] << " " << j->m_rotation[1] << " " << j->m_rotation[2] << " " << j->m_rotation[3] << " " + << j->m_translation[0] << " " << j->m_translation[1] << " " << j->m_translation[2] << " " + << j->m_scale[0] << " " << j->m_scale[1] << " " << j->m_scale[2] << std::endl; + + // unset float format + ofs.precision(oldPrec); + ofs.unsetf(std::ios::floatfield); + ofs.unsetf(std::ios::showpos); + } +} \ No newline at end of file diff --git a/Exporter/Mesh.h b/Exporter/Mesh.h new file mode 100644 index 000000000..fd6a6a95d --- /dev/null +++ b/Exporter/Mesh.h @@ -0,0 +1,44 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#pragma once + +#ifndef MESH_H_INCLUDED +#define MESH_H_INCLUDED + +#include +#include + +#include + +#include "BlendShapeList.h" +#include "SkeletonWriter.h" + +#include "../SharedStructures.h" + +unsigned int GetMeshID(std::string); + +void ClearMeshes(SModel* model); + +void ExtractMesh( const MObject &obj, const BlendShapeList& blendShapeList, SMesh* mesh, SkeletonWriter* skeleton ); +void ExtractAllMeshes( const BlendShapeList& blendShapeList, SModel* model, SkeletonWriter* skeleton ); + +void OutputMesh( std::ostream&, SMesh* mesh ); +void OutputAllMeshes( std::ostream& ofs, SModel* model ); + + +#endif + diff --git a/Exporter/MeshWriter.cpp b/Exporter/MeshWriter.cpp new file mode 100644 index 000000000..76a9a8872 --- /dev/null +++ b/Exporter/MeshWriter.cpp @@ -0,0 +1,588 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#include +#include +#include "MeshWriter.h" + +#define CheckError(status,msg) \ + if ( MS::kSuccess != status ) { \ + MGlobal::displayError(msg); \ + continue; \ + } + +MeshWriter::MeshWriter(MFnMesh& mesh) +: m_BlendShape(NULL), +m_Mesh( mesh ) +{ + MStatus status = MStatus::kSuccess; + + m_Mesh.getPath ( m_DagPath ); + + m_JointIndices = NULL; + m_JointWeights = NULL; + m_VertIndexList = NULL; + m_PolyList = NULL; + + m_BlendShape = NULL; +} + +MeshWriter::~MeshWriter(void) +{ + if (m_VertIndexList) + delete [] m_VertIndexList; + + if (m_PolyList) + delete m_PolyList; + +// delete m_Mesh; + + if (m_JointIndices) + delete [] m_JointIndices; + + if (m_JointWeights) + delete [] m_JointWeights; +} + +void MeshWriter::setSkeletonWriter(SkeletonWriter* skeleton) +{ + m_Skeleton = skeleton; +} + +MStatus MeshWriter::extractPolyMesh() +{ + MStatus status = MStatus::kSuccess; + + MString meshName = m_DagPath.partialPathName(&status); + m_MeshName = string(meshName.asChar()); + + status = extractUVSet(); + + status = extractMeshData(); + + unsigned int polyCount = m_Mesh.numPolygons(); + m_VertIndexList = new VertIndex[polyCount * Poly::MAX_POLY_VERTS]; // At most polyCount number of sets + m_PolyList = new PolyList(polyCount); + + status = buildIndexList(); + + status = extractSkinCluster(); + + return status; +} + +MStatus MeshWriter::extractUVSet() +{ + MStringArray uvSetNames; + if (MStatus::kFailure == m_Mesh.getUVSetNames(uvSetNames)) { + MGlobal::displayError("MFnMesh::getUVSetNames"); + return MStatus::kFailure; + } + + unsigned int uvSetCount = uvSetNames.length(); + unsigned int i; + + UVSet* currUVSet = NULL; + + for (i = 0; i < uvSetCount; i++ ) // for each uv set + { + if (0 == i) { + currUVSet = new UVSet; + m_HeadUVSet = currUVSet; + } else { + currUVSet->next = new UVSet; + currUVSet = currUVSet->next; + } + + currUVSet->name = uvSetNames[i]; + currUVSet->next = NULL; + + std::cout << " extracting UVSet: " << currUVSet->name.asChar() << std::endl; + // Retrieve the UV values + if (MStatus::kFailure == m_Mesh.getUVs(currUVSet->uArray, currUVSet->vArray, &currUVSet->name)) { + return MStatus::kFailure; + } + } + + if ( uvSetCount != 1 ) + std::cout << " Warning: Multiple UVSet found but the first UVSet: " << currUVSet->name.asChar() << " will be exported " << std::endl; + + return MStatus::kSuccess; +} + +MStatus MeshWriter::extractSkinCluster() +{ + // extract skin cluster + MItDependencyNodes itSkins( MFn::kSkinClusterFilter ); + for ( ; !itSkins.isDone(); itSkins.next() ) + { + MObject object = itSkins.thisNode(); + + // For each skinCluster node, get the list of influence objects + MFnSkinCluster skinCluster(object); + MStatus status = MStatus::kSuccess; + MDagPathArray infs; + unsigned int numInfs = skinCluster.influenceObjects(infs, &status); + CheckError(status,"Error getting influence objects."); + if (0 == numInfs) + { + status = MS::kFailure; + CheckError(status,"Error: No influence objects found."); + } + + // loop through the geometries affected by this cluster + unsigned int nGeoms = skinCluster.numOutputConnections(); + for (unsigned int ii = 0; ii < nGeoms; ++ii) + { + unsigned int index = skinCluster.indexForOutputConnection(ii,&status); + CheckError(status,"Error getting geometry index."); + + // get the dag path of the ii'th geometry + MDagPath skinPath; + status = skinCluster.getPathAtIndex(index,skinPath); + CheckError(status,"Error getting geometry path."); + + if (skinPath == m_DagPath) + { + if (NULL == m_JointIndices) + { + MGlobal::displayInfo("For mesh: " + m_DagPath.fullPathName() + + ", affecting skin cluster: " + skinCluster.name() + " is found."); + extractSkinClusterData(skinPath, skinCluster); + } + else + { + MGlobal::displayError("Multiple skin cluster found for a mesh"); + return MStatus::kFailure; + } + } + } + } + + return MStatus::kSuccess; +} + +struct JointWeightPair +{ + int index; + double weight; + bool operator< ( const JointWeightPair& rhs ) + { + return this->weight > rhs.weight; // Intensionally opposite for decending order + } +}; + +void MeshWriter::extractSkinClusterData(MDagPath skinPath, MFnSkinCluster skinCluster) +{ + MStatus status = MStatus::kSuccess; + + m_InfluenceCount = skinCluster.influenceObjects(m_InfluenceObjects, &status); + + m_SkinName = skinCluster.name().asChar(); + + // build joint ref + for (int i = 0; i < m_InfluenceCount; i++) + { + m_InfHashes.push_back( m_Skeleton->addJoint( m_InfluenceObjects[i].node() ) ); + } + + // initialize geometry iterator + MItGeometry gIter(skinPath); + + // initialize joint indices and bone weights to 0 + m_JointIndices = new int[gIter.count() * 4]; + m_JointWeights = new double[gIter.count() * 4]; + for ( int i = 0; i < gIter.count() * 4; i++ ) + { + m_JointIndices[i] = 0; + m_JointWeights[i] = 0; + } + + // iterate through the components of this geometry + for ( /* nothing */ ; !gIter.isDone(); gIter.next() ) + { + int index = gIter.index(); + MObject comp = gIter.component(&status); + CheckError(status,"Error getting component."); + + // Get the weights for this vertex (one per influence object) + MDoubleArray wts; + unsigned int infCount; + status = skinCluster.getWeights(skinPath,comp,wts,infCount); + CheckError(status,"Error getting weights."); + if (0 == infCount) { + status = MS::kFailure; + CheckError(status,"Error: 0 influence objects."); + } + + //// Store the weight data for this vertex + list weightList; + for (unsigned int i = 0; i < infCount ; ++i ) + { + if( 0.001 <= wts[i] ) + { + JointWeightPair pair; + pair.index = i; + pair.weight = wts[i]; + weightList.push_back( pair ); + } + } + + weightList.sort(); + + list::iterator pairIt = weightList.begin(); + unsigned int count = 0; + double sum = 0; + for ( ; pairIt != weightList.end(); pairIt++ ) + { + if ( count < 4 ) + { + m_JointIndices[index*4 + count] = (*pairIt).index; + m_JointWeights[index*4 + count] = (*pairIt).weight; + sum += (*pairIt).weight; + } + count++; + } + + if ( count > 4 ) + printf( "WARNING: %d weights are non-zero. 4 significant ones will be exported.\n", count ); + + if ( sum < 1.0 ) + { + m_JointWeights[index*4] += 1.0 - sum; + } + } +} + +MStatus MeshWriter::extractMeshData() +{ + MStatus status = MStatus::kSuccess; + + //if (MStatus::kFailure == m_Mesh.getPoints(m_VertexArray, MSpace::kWorld)) { + // MGlobal::displayError("MFnMesh::getPoints"); + // status = MStatus::kFailure; + //} + MItMeshVertex vtxIter( m_DagPath, MObject::kNullObj, &status ); + if ( MS::kSuccess != status ) + { + fprintf(stderr,"Failure in MItMeshVertex initialization.\n"); + return MS::kFailure; + } + + for ( ; !vtxIter.isDone(); vtxIter.next() ) + { + MPoint p = vtxIter.position( MSpace::kObject ); + //if (ptgroups && groups) { + // int compIdx = vtxIter.index(); + // outputSetsAndGroups( mdagPath, compIdx, true, objectIdx ); + //} + // convert from internal units to the current ui units + p.x = MDistance::internalToUI(p.x); + p.y = MDistance::internalToUI(p.y); + p.z = MDistance::internalToUI(p.z); + //printf("v %f %f %f\n",p.x,p.y,p.z); + m_VertexArray.append( p ); + } + + //if (MStatus::kFailure == m_Mesh.getFaceVertexColors(m_ColorArray)) { + // MGlobal::displayError("MFnMesh::getFaceVertexColors"); + // status = MStatus::kFailure; + //} + + if (MStatus::kFailure == m_Mesh.getNormals(m_NormalArray, MSpace::kWorld)) { + MGlobal::displayError("MFnMesh::getNormals"); + status = MStatus::kFailure; + } + if (MStatus::kFailure == m_Mesh.getCurrentUVSetName(m_CurrentUVSetName)) { + MGlobal::displayError("MFnMesh::getCurrentUVSetName"); + status = MStatus::kFailure; + } + + //if (MStatus::kFailure == m_Mesh.getTangents(m_TangentArray, MSpace::kWorld, &m_CurrentUVSetName)) { + // MGlobal::displayError("MFnMesh::getTangents"); + // status = MStatus::kFailure; + //} + + //if (MStatus::kFailure == m_Mesh.getBinormals(m_BinormalArray, MSpace::kWorld, &m_CurrentUVSetName)) { + // MGlobal::displayError("MFnMesh::getBinormals"); + // status = MStatus::kFailure; + //} + + return status; +} + +MStatus MeshWriter::buildIndexList() +{ + // Material ID + + // this will hold references to the shaders used on the meshes + MObjectArray Shaders; + + // this is used to hold indices to the materials returned in the object array + MIntArray FaceIndices; + + // this function builds a list of all surface shaders used on the mesh. Note + // that the nodes returned are the shading groups, not the material nodes! + m_Mesh.getConnectedShaders(0,Shaders,FaceIndices); + + // having recieved the shader information, we will try to process the returned + // shaders to find their name and ultimately find the relevant material ID that + // references the list we have built up. + std::vector< unsigned int > ShaderIDs; + + // start the first shader as a default zero value + ShaderIDs.push_back(0); + + // for each surface shader + for(int k=0;k!=Shaders.length();++k) + { + // attachy function set... + MFnDependencyNode fnShader(Shaders[k]); + + // get access to the surfaceShader attribute. This will be connected to + // lambert , phong nodes etc. + MPlug sshader = fnShader.findPlug("surfaceShader"); + + MPlugArray materials; + + // get the material connected to the surface shader + sshader.connectedTo(materials,true,true); + + // + for(unsigned int l=0;llist.size(); i++) // for each Poly + { + Poly *poly = &m_PolyList->list[i]; + + // Get vertex count, list of indices of vertices (positions), + // and list of indices of normals + + indexCount = m_Mesh.polygonVertexCount(i, &status); + if (MStatus::kFailure == status) { + MGlobal::displayError("MFnMesh::polygonVertexCount"); + return MStatus::kFailure; + } + + status = m_Mesh.getPolygonVertices (i, indexArray); + if (MStatus::kFailure == status) { + MGlobal::displayError("MFnMesh::getPolygonVertices"); + return MStatus::kFailure; + } + + status == m_Mesh.getFaceNormalIds (i, normalIndexArray); + if (MStatus::kFailure == status) { + MGlobal::displayError("MFnMesh::getFaceNormalIds"); + return MStatus::kFailure; + } + + // Fill out indices in my Poly list + poly->numVerts = indexCount; + + for (j = 0; j < indexCount; j++) + { + int uvID = -1; + status = m_Mesh.getPolygonUVid(i, j, uvID, &m_HeadUVSet->name); + if (MStatus::kFailure == status ) //|| uvID == -1) { + { + MGlobal::displayError("MFnMesh::getPolygonUVid"); + return MStatus::kFailure; + } + + VertIndex vertIndex; + vertIndex.pos = indexArray[j]; + vertIndex.normal = normalIndexArray[j]; + vertIndex.uv = uvID; + + // Search this vertIndex in the list so far + int index = -1; + for (int k = 0; k < counter; k++) + { + if(m_VertIndexList[k].isEqual(vertIndex)) + { + index = k; + break; + } + } + + // If vertIndex is new, add it to m_VertIndexList + if (index == -1) + { + m_VertIndexList[counter] = vertIndex; + index = counter; + counter++; + } + + // Add index to PolyList + poly->indices[j] = index; + } + + // set material index + int shaderIdx = FaceIndices[i]+1; + poly->matID = ShaderIDs[ shaderIdx ]; + } + + m_NumVertIndex = counter; // remember counted number of unique IndexSet + + m_PolyList->triangulate(); + + return status; +} + +void MeshWriter::extractMeshData( SMesh* smesh ) +{ + extractVertices(smesh); + extractTriangles( smesh ); +} + +void MeshWriter::extractSkin(SMesh* smesh) +{ + assert( m_InfluenceCount > 0 ); + strcpy_s( smesh->skinName, m_SkinName.c_str() ); + + smesh->numSkinInfHashes = m_InfluenceCount; + + // extract skin inf hashes + if ( smesh->numSkinInfHashes > 0 ) + { + smesh->skinInfHashes = (uint*)calloc( smesh->numSkinInfHashes, sizeof(uint) ); + uint infCount = 0; + vector::iterator itInfHashes = m_InfHashes.begin(); + for ( ; itInfHashes != m_InfHashes.end(); ++itInfHashes ) + { + smesh->skinInfHashes[ infCount ] = *itInfHashes; + infCount++; + } + assert( infCount == smesh->numSkinInfHashes ); + } +} + +void MeshWriter::extractVertices(SMesh* smesh) +{ + // get blendshape data + unsigned int numWeights = 0; + float **bsPos, **bsNml; + if ( m_BlendShape ) + { + numWeights = m_BlendShape->m_NumWeights; + // get target positions and normals + bsPos = new float*[numWeights]; + bsNml = new float*[numWeights]; + for ( unsigned int i = 0; i < numWeights; i++ ) + { + BlendShapeWeight *weight = &m_BlendShape->m_WeightList[i]; + bsPos[i] = weight->m_Positions; + bsNml[i] = weight->m_Normals; + } + } + + // determine stride + unsigned int stride = 8; // default, no skinning, no blendshape + stride += numWeights * 6; // blendshape, 3 for position, 3 for normal + if ( m_JointIndices ) + { + stride += 8; // skinning + } + + smesh->numBlends = numWeights; + smesh->isSkinned = m_JointIndices ? 1 : 0; + if ( smesh->isSkinned ) + { + extractSkin( smesh ); + } + smesh->stride = stride; + smesh->numVerts = m_NumVertIndex; + + unsigned int numFloat = smesh->numVerts * smesh->stride; + + // extract verts + if ( numFloat > 0 ) + { + smesh->verts = (float*)calloc( numFloat, sizeof(float) );//new float[ numFloat ]; + unsigned int count = 0; + + for (uint i = 0; i < smesh->numVerts; i++) + { + const VertIndex vertIndex = m_VertIndexList[i]; + + int vertexIndex = vertIndex.pos; + int normalIndex = vertIndex.normal; + int uvIndex = vertIndex.uv; + + float u = uvIndex == -1 ? -1.0f : m_HeadUVSet->uArray[uvIndex]; + float v = uvIndex == -1 ? -1.0f : m_HeadUVSet->vArray[uvIndex]; + + // position and normal + smesh->verts[ count++ ] = (float)m_VertexArray[vertexIndex].x; + smesh->verts[ count++ ] = (float)m_VertexArray[vertexIndex].y; + smesh->verts[ count++ ] = (float)m_VertexArray[vertexIndex].z; + smesh->verts[ count++ ] = (float)m_NormalArray[normalIndex].x; + smesh->verts[ count++ ] = (float)m_NormalArray[normalIndex].y; + smesh->verts[ count++ ] = (float)m_NormalArray[normalIndex].z; + // blendshape target postions and normals + for ( unsigned int j = 0; j < smesh->numBlends; j++ ) + { + smesh->verts[ count++ ] = (float)(bsPos[j][vertexIndex*3+0] - m_VertexArray[vertexIndex].x); + smesh->verts[ count++ ] = (float)(bsPos[j][vertexIndex*3+1] - m_VertexArray[vertexIndex].y); + smesh->verts[ count++ ] = (float)(bsPos[j][vertexIndex*3+2] - m_VertexArray[vertexIndex].z); + smesh->verts[ count++ ] = bsNml[j][normalIndex*3+0] - m_NormalArray[normalIndex].x; + smesh->verts[ count++ ] = bsNml[j][normalIndex*3+1] - m_NormalArray[normalIndex].y; + smesh->verts[ count++ ] = bsNml[j][normalIndex*3+2] - m_NormalArray[normalIndex].z; + } + // uv + smesh->verts[ count++ ] = u; + smesh->verts[ count++ ] = v; + // skinning + if ( m_JointIndices ) + { + smesh->verts[ count++ ] = (float)m_JointIndices[vertexIndex*4 + 0]; + smesh->verts[ count++ ] = (float)m_JointIndices[vertexIndex*4 + 1]; + smesh->verts[ count++ ] = (float)m_JointIndices[vertexIndex*4 + 2]; + smesh->verts[ count++ ] = (float)m_JointIndices[vertexIndex*4 + 3]; + smesh->verts[ count++ ] = (float)m_JointWeights[vertexIndex*4 + 0]; + smesh->verts[ count++ ] = (float)m_JointWeights[vertexIndex*4 + 1]; + smesh->verts[ count++ ] = (float)m_JointWeights[vertexIndex*4 + 2]; + smesh->verts[ count++ ] = (float)m_JointWeights[vertexIndex*4 + 3]; + } + } + assert( count == numFloat ); + } +} + +void MeshWriter::extractTriangles(SMesh* smesh) +{ + MaterialGroup mg( m_PolyList ); + mg.extract( smesh ); +} + +void MeshWriter::setBlendShape(const BlendShape* blendShape) +{ + m_BlendShape = blendShape; +} diff --git a/Exporter/MeshWriter.h b/Exporter/MeshWriter.h new file mode 100644 index 000000000..bcac5357b --- /dev/null +++ b/Exporter/MeshWriter.h @@ -0,0 +1,143 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#pragma once + +#ifdef WIN32 + #ifndef NT_APP + #define NT_APP + #endif + + #pragma warning(disable:4786) +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +using namespace std; + +#include "PolyList.h" +#include "Material.h" +#include "BlendShape.h" +#include "SkeletonWriter.h" + +#include "../SharedStructures.h" + + +//Used to store UV set information +struct UVSet { + MFloatArray uArray; + MFloatArray vArray; + MString name; + UVSet* next; +}; + + +class MeshWriter +{ +public: + MeshWriter(MFnMesh& mesh); + ~MeshWriter(void); + + // Process the poly mesh + MStatus extractPolyMesh(); + + void extractMeshData( SMesh* smesh ); + + void setBlendShape(const BlendShape* blendShape); + void setSkeletonWriter(SkeletonWriter* skeleton); + +private: + // Mesh data + MDagPath m_DagPath; + MFnMesh& m_Mesh; + + // Mesh name + string m_MeshName; + + //for storing UV information + UVSet* m_HeadUVSet; + + //the current UV set's name + MString m_CurrentUVSetName; + + //for storing general mesh information + MPointArray m_VertexArray; + //MColorArray m_ColorArray; + MFloatVectorArray m_NormalArray; + //MFloatVectorArray m_TangentArray; + //MFloatVectorArray m_BinormalArray; + + //for storing skin cluster + //MFnSkinCluster *m_SkinCluster; + string m_SkinName; + int m_InfluenceCount; + MDagPathArray m_InfluenceObjects; + vector m_InfHashes; + int* m_JointIndices; + double* m_JointWeights; + + // For Index list and Poly list + VertIndex* m_VertIndexList; + int m_NumVertIndex; + PolyList* m_PolyList; + + const BlendShape* m_BlendShape; + SkeletonWriter* m_Skeleton; + // Methods + + // Extract UVSet data + MStatus extractUVSet(); + + // Extract skin cluster connected to the mesh + MStatus extractSkinCluster(); + + // process a skin cluster and store joint indices and weights into arrays + void extractSkinClusterData(MDagPath skinPath, MFnSkinCluster skinCluster); + + // Extract mesh data + MStatus extractMeshData(); + + // Build index list and poly list + MStatus buildIndexList(); + + void extractSkin(SMesh* smesh); + void extractVertices(SMesh* smesh); + void extractTriangles(SMesh* smesh); +}; diff --git a/Exporter/PolyList.cpp b/Exporter/PolyList.cpp new file mode 100644 index 000000000..b1d86f8f7 --- /dev/null +++ b/Exporter/PolyList.cpp @@ -0,0 +1,137 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#include +#include "PolyList.h" + +bool VertIndex::isEqual(VertIndex &other) +{ + return pos == other.pos && normal == other.normal && uv == other.uv; +} + +PolyList::PolyList() +{ +} + +PolyList::PolyList(int polyCount) +{ + list.resize( polyCount ); +} + +PolyList::~PolyList(void) +{ +} + +void PolyList::triangulate() +{ + // Calculate number of trinangle + int triCount = 0; + for (unsigned int i = 0; i < list.size(); i++) + { + int numTris = list[i].numVerts - 2; + triCount += numTris; + } + + // Create new list of triangles by copying indices from old Poly list + vector newList(triCount); + triCount = 0; + for (unsigned int i = 0; i < list.size(); i++) + { + int numTris = list[i].numVerts - 2; + for (int j = 0; j < numTris; j++) // For each triangle in this Poly + { + newList[triCount].numVerts = 3; + newList[triCount].indices[0] = list[i].indices[0]; + newList[triCount].indices[1] = list[i].indices[j + 1]; + newList[triCount].indices[2] = list[i].indices[j + 2]; + newList[triCount].matID = list[i].matID; + triCount++; + } + } + list = newList; +} + +void PolyList::extract( SMatGrp* matGrp ) +{ + matGrp->triCount = (uint)list.size(); + if ( matGrp->triCount > 0 ) + { + matGrp->triIndices = (uint*)calloc(matGrp->triCount*3, sizeof(uint));//new unsigned int[ matGrp->triCount * 3 ]; + unsigned int count = 0; + for (unsigned int i = 0; i < list.size(); i++) + { + Poly *poly = &list[i]; + assert( poly->numVerts == 3 ); + for (int j = 0; j < 3; j++) + { + int index = poly->indices[j]; + matGrp->triIndices[ count++ ] = index; + } + } + assert( count == matGrp->triCount * 3 ); + } +} + +MaterialGroup::MaterialGroup(const PolyList *polyList) +{ + for ( unsigned int i = 0; i < polyList->list.size(); i++ ) + { + const Poly *poly = &polyList->list[i]; + int matID = poly->matID; + // is this material new? + vector::iterator it = find( MatIDs.begin(), MatIDs.end(), matID ); + if ( MatIDs.end() == it ) + { + // Yes, so create a new PolyList and add this poly there + MatIDs.push_back( matID ); + PolyList *newList = new PolyList(); + newList->list.push_back( *poly ); + PolyListList.push_back( newList ); + } + else + { + // No, add this poly to existing PolyList + unsigned int listID = (unsigned int)(it - MatIDs.begin()); + PolyList *list = PolyListList[listID]; + list->list.push_back( *poly ); + } + } +} + +MaterialGroup::~MaterialGroup() +{ + for ( vector< PolyList* >::iterator it = PolyListList.begin(); it < PolyListList.end(); it++ ) + { + PolyList *list = *it; + delete list; + } +} + +void MaterialGroup::extract( SMesh* mesh ) +{ + mesh->numMats = (uint)MatIDs.size(); + if ( mesh->numMats > 0 ) + { + mesh->matGrps = (SMatGrp*)calloc( mesh->numMats, sizeof(SMatGrp) );//new SMatGrp[ mesh->numMats ]; + for (size_t i = 0; i < mesh->numMats; i++) + { + SMatGrp* matGrp = &mesh->matGrps[i]; + matGrp->materialID = MatIDs[i]; + PolyList *list = PolyListList[i]; + list->extract( matGrp ); + } + } +} diff --git a/Exporter/PolyList.h b/Exporter/PolyList.h new file mode 100644 index 000000000..5bb339a79 --- /dev/null +++ b/Exporter/PolyList.h @@ -0,0 +1,85 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#pragma once + +#include +#include +#include +#include +#include +using namespace std; + +#include "../SharedStructures.h" + +////////////////////////////////////////////////////////////////////// + +// My index structures +struct VertIndex { + int pos; // Position Index + int normal; // Normal Index + int uv; // Texture coordinates Index + + // True if this index is equal to other one + bool isEqual(VertIndex &other); + +}; + +////////////////////////////////////////////////////////////////////// + +// My polygon structure +struct Poly { + static const int MAX_POLY_VERTS = 20; + int numVerts; + int indices[MAX_POLY_VERTS]; + int matID; // Material ID +}; + +////////////////////////////////////////////////////////////////////// + +// My polygon list class +class PolyList { + +public: + vector list; + + PolyList(); + PolyList(int polyCount); + + ~PolyList(); + + void triangulate(); + + void PolyList::extract( SMatGrp* matGrp ); +}; + +////////////////////////////////////////////////////////////////////// + +class MaterialGroup +{ +public: + vector< int > MatIDs; + vector< PolyList* > PolyListList; + + // create a material group from a poly list + MaterialGroup( const PolyList *polyList ); + ~MaterialGroup(); + + void extract( SMesh* smesh ); +}; + + + diff --git a/Exporter/SkeletonWriter.cpp b/Exporter/SkeletonWriter.cpp new file mode 100644 index 000000000..81ce8b6ad --- /dev/null +++ b/Exporter/SkeletonWriter.cpp @@ -0,0 +1,308 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#ifdef WIN32 + #ifndef NT_APP + #define NT_APP + #endif + + #pragma warning(disable:4786) +#endif + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "SkeletonWriter.h" + +// hash function +inline unsigned int GenerateNameHash(const char* name) +{ + unsigned int crcValue = ~0UL; + + if (name) + { + while(*name) + { + unsigned int tableTemp = (unsigned int)((crcValue & 0xff) ^ (unsigned char)*name); + + for (int bitLoop = 0; bitLoop < 8; bitLoop++) + { + if (tableTemp & 0x01) + tableTemp = (tableTemp >> 1) ^ 0xedb88320; + else + tableTemp = (tableTemp >> 1); + } + + crcValue = (crcValue >> 8) ^ tableTemp; + name++; + } + } + + return crcValue; +} + +SkeletonWriter::SkeletonWriter(void) +{ + m_numJoints = 0; +} + +SkeletonWriter::~SkeletonWriter(void) +{ +} + +void SkeletonWriter::buildSkeleton(MObject& obj, int parentID) +{ + + MFnTransform fnX( obj ); + MDagPath path; + fnX.getPath( path ); + + JointWriter joint( path ); + + // get the name + const char* name = fnX.name().asChar(); + strcpy_s( joint.name, name ); + + // check the name + size_t nameLen = strlen( name ); + if ( nameLen == 0 ) + { + std::cerr << "Error! Trying to add joint with no name.\n"; + assert(0); exit(1); + } + + // make sure this joint has not been added yet + if ( findJoint( name ) != -1 ) + return; + + // extract joint info + unsigned int nameHash = GenerateNameHash( name ); + std::string nameStr( name ); + + joint.extractJointTransformation(); + + // add joint to the list + m_jointNames.push_back( nameStr ); + m_jointWriters.push_back( joint ); + m_parentIndexList.push_back( parentID ); + m_basePoseList.push_back( joint ); + m_jointNameHashList.push_back( nameHash ); + m_numJoints++; + + parentID = (int)m_parentIndexList.size() - 1; + + // extract child joints + for(int i = 0; i != fnX.childCount(); ++i) + { + MObject child = fnX.child(i); + if ( child.hasFn( MFn::kTransform ) ) + buildSkeleton( child, parentID ); + } +} + +MObject SkeletonWriter::findRootJoint(MObject& obj) +{ + if ( !obj.hasFn( MFn::kJoint ) ) + { + std::cerr << "Error! Trying to add non-joint object to Skeltons\n"; + assert(0); exit(1); + } + + MFnTransform joint( obj ); + const char* name = joint.name().asChar(); + + size_t nameLen = strlen( name ); + if ( nameLen == 0 ) + { + std::cerr << "Error! Trying to add joint with no name.\n"; + assert(0); exit(1); + } + + if ( joint.parentCount() == 0 ) + return obj; + + MObject parentObj = joint.parent(0); + if ( !parentObj.hasFn( MFn::kTransform ) ) + return obj; + + MObject thisObj = parentObj; + while( MFnTransform( thisObj ).parentCount() != 0 ) + { + parentObj = MFnTransform( thisObj ).parent(0); + if ( !parentObj.hasFn( MFn::kTransform ) ) + return thisObj; + thisObj = parentObj; + } + return thisObj; +} + +// find joint with given name and return the id +int SkeletonWriter::findJoint(const char* name) +{ + unsigned int nameHash = GenerateNameHash( name ); + for ( unsigned int i = 0; i < m_jointNameHashList.size(); i++ ) + { + if ( m_jointNameHashList[i] == nameHash ) + return i; + } + return -1; +} + +unsigned int SkeletonWriter::addJoint(MObject& obj) +{ + if ( !obj.hasFn( MFn::kJoint ) ) + { + std::cerr << "Error! Trying to add non-joint object to Skeltons\n"; + assert(0); exit(1); + } + + // check if this joint is already in a skeleton + MFnIkJoint joint(obj); + const char* name = joint.name().asChar(); + + size_t nameLen = strlen( name ); + if ( nameLen == 0 ) + { + std::cerr << "Error! Trying to add joint with no name.\n"; + assert(0); exit(1); + } + + int jointID = findJoint(name); + if ( jointID == -1 ) + { + if ( m_jointNames.size() > 0 ) + { + std::cerr << "Error! Trying to export multiple skeltons for joint " << name << "\n"; + assert(0); exit(1); + } + MObject root = findRootJoint(obj); + buildSkeleton( root, -1 ); + } + + return GenerateNameHash( name ); +} + +void SkeletonWriter::OutputSkeleton(std::ofstream& ofs) +{ + ofs << "SKELETON" << std::endl; + ofs << "numJoints " << m_numJoints << std::endl; + for( unsigned int i = 0; i < m_numJoints; i++ ) + { + ofs << "\t" << "JOINT " << m_jointNames[i] << std::endl; + ofs << "\t\t" << "nameHash " << m_jointNameHashList[i] << std::endl; + ofs << "\t\t" << "parentIndex " << m_parentIndexList[i] << std::endl; + ofs << "\t\t" << "Transformation "; + + JointWriter joint = m_jointWriters[i]; + joint.writeJointTransformation( ofs ); + } +} + +void SkeletonWriter::writeJointAnimation(std::ostream& ofs, int startFrame, int endFrame) +{ + int numFrames = endFrame - startFrame + 1; + if ( numFrames > 0 ) + { + JointWriter** jointAnims = new JointWriter*[ m_numJoints * numFrames ]; + bool* isAnimated = new bool[ m_numJoints ]; + for ( uint j = 0; j < m_numJoints; j++ ) + isAnimated[j] = false; + + // extract joint trasformations for each frame + for( int i = 0; i < numFrames; i++ ) + { + MAnimControl::setCurrentTime(MTime(i+startFrame,MTime::kNTSCField)); + + for( uint j = 0; j < m_numJoints; j++ ) + { + JointWriter* jw = new JointWriter( m_jointWriters[j].m_DagPath ); + jw->extractJointTransformation(); + jointAnims[ i * m_numJoints + j ] = jw; + } + } + + // check if joint is animated or not + for ( int i = 1; i < numFrames; i++ ) + { + for ( uint j = 0; j < m_numJoints; j++ ) + { + JointWriter* prev = jointAnims[ (i-1) * m_numJoints + j ]; + JointWriter* curr = jointAnims[ i * m_numJoints + j ]; + isAnimated[j] |= !curr->isEqual( prev ); + } + } + + // count animated joint and find out max length of joint names + uint count = 0; + uint maxNameLen = 0; + for ( uint j = 0; j < m_numJoints; j++ ) + { + if ( isAnimated[j] ) + { + count++; + uint nameLen = (uint)m_jointNames[j].length(); + if ( nameLen > maxNameLen ) + maxNameLen = nameLen; + } + } + + // write animated joints to text file + ofs << "\t\t" << "JOINTANIM" << std::endl; + ofs << "\t\t" << "NumJointAnims " << count << std::endl; + for ( uint j = 0; j < m_numJoints; j++ ) + { + if ( isAnimated[j] ) + { + ofs << "\t\t\t"; + ofs.fill(' '); + ofs.width(maxNameLen + 1); + ofs << std::left << m_jointNames[j]; + ofs << m_jointNameHashList[j] << std::endl; + } + } + ofs << std::endl;; + + for( int i = 0; i < numFrames; i++ ) + { + for( uint j = 0; j < m_numJoints; j++ ) + { + if ( isAnimated[j] ) + { + JointWriter* jw = jointAnims[ i * m_numJoints + j ]; + ofs << "\t\t\t"; + jw->writeJointTransformation( ofs ); + } + } + ofs << std::endl; + } + + // clean joint animation data + for ( uint i = 0; i < m_numJoints * numFrames; i++ ) + delete jointAnims[i]; + + delete [] jointAnims; + delete [] isAnimated; + } +} diff --git a/Exporter/SkeletonWriter.h b/Exporter/SkeletonWriter.h new file mode 100644 index 000000000..09d244dc2 --- /dev/null +++ b/Exporter/SkeletonWriter.h @@ -0,0 +1,67 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#pragma once + +#ifdef WIN32 + #ifndef NT_APP + #define NT_APP + #endif + + #pragma warning(disable:4786) +#endif + +#include +#include +#include + +#include + +#include "JointWriter.h" +#include "../SharedStructures.h" + +class SkeletonWriter : public Skeleton +{ +public: + std::vector m_parentIndexList; + std::vector m_basePoseList; + std::vector m_jointNameHashList; + + std::vector m_jointWriters; + std::vector m_jointNames; + + SkeletonWriter(void); + ~SkeletonWriter(void); + + // try to add a new joint to the skeleton + // return joint hash if a joint is already in the skeleton + unsigned int addJoint(MObject& obj); + + // recursively extract skeleton for the given root joint + void buildSkeleton(MObject& obj, int parentID); + + // find a root joint for the given joint + MObject findRootJoint(MObject& obj); + + // find joint with given name and return the id + int findJoint(const char* name); + + // output skeleton text + void OutputSkeleton(std::ofstream& ofs); + + // write joint animations to text file + void writeJointAnimation(std::ostream& ofs, int startFrame, int endFrame); +}; diff --git a/Exporter/Texture.cpp b/Exporter/Texture.cpp new file mode 100644 index 000000000..9c0ed9aff --- /dev/null +++ b/Exporter/Texture.cpp @@ -0,0 +1,150 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#ifdef WIN32 + #ifndef NT_APP + #define NT_APP + #endif + #pragma warning(disable:4786) + #include +#endif + +#include "Texture.h" + +#include + +#include +#include + +#include +#include +#include +#include +#include + +std::map g_TextureToID_Map; +unsigned int g_TexID_gen = 0; + +unsigned int GetTextureID(MString &fnn) +{ + std::map::iterator it = g_TextureToID_Map.find(fnn.asChar()); + + if (it != g_TextureToID_Map.end()) + { + return it->second; + } + return 0; +} + +void ClearTextures(SModel* model) +{ + g_TextureToID_Map.clear(); g_TexID_gen = 0; + + for( uint i = 0; i < model->numTextures; i++ ) + { + free( model->texNames[i] ); + } + free(model->texNames); +} + +void ExtractTextures(SModel* model) +{ + MItDependencyNodes itDep(MFn::kFileTexture); + + uint texCount = 0; + // count textures + while (!itDep.isDone()) + { + //model->numTextures++; + texCount++; + itDep.next(); + } + + //if ( model->numTextures > 0 ) + if ( texCount > 0 ) + { + // string for current working directory + char cwdStr[256]; + _getcwd( cwdStr, 256 ); + for ( uint i = 0; i < strlen( cwdStr ); i++ ) + { + if ( cwdStr[i] == '\\' ) + cwdStr[i] = '/'; + } + size_t cwdStrLen = strlen( cwdStr ); + + //model->texNames = (char**)calloc( model->numTextures, sizeof(char*) );//256 ); + std::vector texNames; + itDep.reset(MFn::kFileTexture); + texCount = 0; + while (!itDep.isDone()) + { + MFnDependencyNode fnDep(itDep.item()); + MPlug filenamePlug = fnDep.findPlug("fileTextureName"); + MString textureName; + filenamePlug.getValue(textureName); + std::string nameString( textureName.asChar() ); + std::cout << "Found texture file " << nameString << std::endl; + + // find local path from current working directory + size_t dataPos = nameString.find( cwdStr ); + if ( dataPos == std::string::npos ) + { + std::cerr << "Warning: Texture is found at invalid directory " << nameString << std::endl; + //assert(0); exit(1); + itDep.next(); + continue; + } + std::string localPath = nameString.substr( cwdStrLen + 1 ); // + 1 for last '/' + + // extract local path name + //model->texNames[ count ] = (char*)calloc( 256, sizeof( char ) ); + //strcpy_s( model->texNames[ count ], 256, localPath.c_str() ); + + g_TextureToID_Map.insert( std::make_pair( fnDep.name().asChar(), ++g_TexID_gen) ); + + texNames.push_back( localPath ); + + itDep.next(); + texCount++; + } + //assert( count == model->numTextures ); + + // extract local path name + model->numTextures = texCount; + model->texNames = (char**)calloc( model->numTextures, sizeof(char*) );//256 ); + for ( uint i = 0; i < model->numTextures; i++ ) + { + model->texNames[i] = (char*)calloc( 256, sizeof( char ) ); + strcpy_s( model->texNames[i], 256, texNames[i].c_str() ); + + //g_TextureToID_Map.insert( std::make_pair( fnDep.name().asChar(), ++g_TexID_gen) ); + } + + + } +} + +void OutputTextures(std::ostream& ofs, SModel* model) +{ + ofs << "TEXTURES" << std::endl; + ofs << "NumTextures= " << model->numTextures << std::endl; + + for( uint i = 0; i < model->numTextures; i++ ) + { + ofs << "\t" << model->texNames[i] << std::endl; + } +} \ No newline at end of file diff --git a/Exporter/Texture.h b/Exporter/Texture.h new file mode 100644 index 000000000..9092d8875 --- /dev/null +++ b/Exporter/Texture.h @@ -0,0 +1,40 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#pragma once + +#ifndef TEXTURE_H_INCLUDED +#define TEXTURE_H_INCLUDED + +#include + +#include + +#include "../SharedStructures.h" + + +/// \brief This function returns the texture ID of the texture node specified. +/// If the name specified does not exist it will return 0. +/// \param fnn - the file node name. NOTE This is not the name of the texture +/// file, but the name of the fileTexture node in maya. +unsigned int GetTextureID(MString&); + +void ClearTextures(SModel* model); + +void ExtractTextures(SModel* model); +void OutputTextures(std::ostream& ofs, SModel* model); + +#endif diff --git a/Exporter/main.cpp b/Exporter/main.cpp new file mode 100644 index 000000000..de07cb642 --- /dev/null +++ b/Exporter/main.cpp @@ -0,0 +1,246 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + + +#ifdef WIN32 + #ifndef NT_APP + #define NT_APP + #endif + + #pragma warning(disable:4786) + #include + + #pragma comment(lib,"Foundation.lib") + #pragma comment(lib,"OpenMaya.lib") + #pragma comment(lib,"Image.lib") + #pragma comment(lib,"OpenMayaAnim.lib") +#endif + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include "../SharedStructures.h" +#include "Material.h" +#include "Mesh.h" +#include "Texture.h" +#include "SkeletonWriter.h" +#include "BlendShape.h" +#include "BlendShapeList.h" +#include "Animation.h" + +#define TYPE_MODEL 0 +#define TYPE_ANIM 1 +#define TYPE_CAMERA 2 + +struct InputFile +{ + uint type; + std::string inFileName; + std::string outFileName; +}; + +int main(int argc,char** argv) +{ + std::string configFileName; + + if (argc == 2 ) + { + configFileName = argv[1]; + } + else { + printf("Usage: Exporter CONFIG_FILE_NAME \n"); + return 0; + } + + // check file extension + std::string key (".conf"); + size_t found = configFileName.rfind(key); + if ( found == std::string::npos ) + { + std::cerr << "Error! Config file name has to have .conf as extension" << std::endl; + assert(0); exit(1); + } + + // open config file + std::ifstream ifs( configFileName.c_str() ); + if (!ifs) + { + std::cerr << "Error! Could not open config file" << std::endl; + assert(0); exit(1); + } + + + // read config file + char buffer[256]; + std::vector fileList; + while( !ifs.eof() ) + { + ifs >> buffer; + if ( strlen( buffer ) > 0 ) + { + //std::cout << buffer << std::endl; + InputFile file; + uint extLength = 2; // for .mb or .ma + if ( strcmp( buffer, "model" ) == 0 ) + file.type = TYPE_MODEL; + else if ( strcmp( buffer, "anim" ) == 0 ) + file.type = TYPE_ANIM; + else if ( strcmp( buffer, "camera" ) == 0 ) + { + file.type = TYPE_CAMERA; + extLength = 6; + } + else + { + std::cerr << "Error! Unrecognized file type " << buffer << " in config file." << std::endl; + assert(0); exit(1); + } + + // generate output file name + ifs >> file.inFileName; + size_t nameLength = file.inFileName.length(); + std::string name = file.inFileName.substr( 0, nameLength - extLength ); + file.outFileName = name + buffer; + + fileList.push_back( file ); + } + } + + // output scene file + std::string sceneFileName = configFileName.substr( 0, found ); + sceneFileName += ".scene"; + std::ofstream ofs( sceneFileName.c_str() ); + if (!ofs) + { + std::cerr << "Could not open scene file " << sceneFileName.c_str() << " for output." << std::endl; + assert(0); exit(1); + } + for ( size_t i = 0; i < fileList.size(); i++ ) + { + InputFile file = fileList[i]; + if ( file.type == TYPE_MODEL ) + { + ofs << "model "; + } + else if ( file.type == TYPE_ANIM ) + { + ofs << "anim "; + } + else // TYPE_CAMERA + { + ofs << "camera "; + } + ofs << file.outFileName; + ofs << "\n"; + } + ofs.close(); + + // initialise the maya library - This basically starts up Maya + std::cout << "Initializing Maya library" << std::endl; + MLibrary::initialize(argv[0]); + + // process maya files in config files + for ( size_t i = 0; i < fileList.size(); i++ ) + { + InputFile file = fileList[i]; + + if (file.type == TYPE_CAMERA ) + continue; + + char fileNameStr[256]; + + // replace \ to / + _getcwd( fileNameStr, 256 ); + strcat_s( fileNameStr, "/" ); + strcat_s( fileNameStr, file.inFileName.c_str() ); + for ( uint i = 0; i < strlen( fileNameStr ); i++ ) + { + if ( fileNameStr[i] == '\\' ) + fileNameStr[i] = '/'; + } + + std::cout << "Opening Maya file " << fileNameStr << std::endl; + MStatus status = MFileIO::open(fileNameStr,NULL,true); + if( MS::kSuccess != status ) + { + std::cerr << "Could not open Maya file " << fileNameStr << " " << status.errorString().asChar() << std::endl; + assert(0); exit(1); + } + + // create an output file stream + std::ofstream ofs(file.outFileName.c_str()); + if (!ofs) { + std::cerr << "Could not open output file " << file.outFileName.c_str() << std::endl; + MLibrary::cleanup(); + assert(0); exit(1); + } + + std::cout << "Extracting model data " << std::endl; + + DisableBlendShapes(); + + BlendShapeList blendShapes; + blendShapes.extractAllBlendShapes(); + + SModel sModel; + memset( &sModel, 0, sizeof( SModel ) ); + SkeletonWriter skeleton; + + ExtractTextures( &sModel ); + ExtractMaterials( &sModel ); + ExtractAllMeshes( blendShapes, &sModel, &skeleton); + + if ( file.type == TYPE_MODEL ) + { + std::cout << "Exporting model to " << file.outFileName << std::endl; + OutputTextures(ofs, &sModel ); + OutputMaterials(ofs, &sModel); + OutputAllMeshes(ofs, &sModel); + //skeleton.OutputSkeleton(ofs); + ofs << "\n"; + } + + std::cout << "Exporting anim to " << file.outFileName << std::endl; + SAnimation sAnim; + memset( &sAnim, 0, sizeof( SAnimation ) ); + OutputAnimation( ofs, blendShapes, &sAnim, skeleton ); + ofs << "\n"; + + EnableBlendShapes(); + + ClearTextures( &sModel ); + ClearMaterials( &sModel ); + ClearMeshes( &sModel ); + + // close the output file + ofs.close(); + } + + // cleanup maya data + MLibrary::cleanup(); + + return 0; +} + diff --git a/Loader-Info.plist b/Loader-Info.plist new file mode 100644 index 000000000..af9a1cadb --- /dev/null +++ b/Loader-Info.plist @@ -0,0 +1,20 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + com.yourcompany.${PRODUCT_NAME:identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + APPL + CFBundleSignature + ???? + CFBundleVersion + 1.0 + + diff --git a/Loader.xcodeproj/junmura.mode1v3 b/Loader.xcodeproj/junmura.mode1v3 new file mode 100644 index 000000000..7c92f32de --- /dev/null +++ b/Loader.xcodeproj/junmura.mode1v3 @@ -0,0 +1,1411 @@ + + + + + ActivePerspectiveName + Project + AllowedModules + + + BundleLoadPath + + MaxInstances + n + Module + PBXSmartGroupTreeModule + Name + Groups and Files Outline View + + + BundleLoadPath + + MaxInstances + n + Module + PBXNavigatorGroup + Name + Editor + + + BundleLoadPath + + MaxInstances + n + Module + XCTaskListModule + Name + Task List + + + BundleLoadPath + + MaxInstances + n + Module + XCDetailModule + Name + File and Smart Group Detail Viewer + + + BundleLoadPath + + MaxInstances + 1 + Module + PBXBuildResultsModule + Name + Detailed Build Results Viewer + + + BundleLoadPath + + MaxInstances + 1 + Module + PBXProjectFindModule + Name + Project Batch Find Tool + + + BundleLoadPath + + MaxInstances + n + Module + XCProjectFormatConflictsModule + Name + Project Format Conflicts List + + + BundleLoadPath + + MaxInstances + n + Module + PBXBookmarksModule + Name + Bookmarks Tool + + + BundleLoadPath + + MaxInstances + n + Module + PBXClassBrowserModule + Name + Class Browser + + + BundleLoadPath + + MaxInstances + n + Module + PBXCVSModule + Name + Source Code Control Tool + + + BundleLoadPath + + MaxInstances + n + Module + PBXDebugBreakpointsModule + Name + Debug Breakpoints Tool + + + BundleLoadPath + + MaxInstances + n + Module + XCDockableInspector + Name + Inspector + + + BundleLoadPath + + MaxInstances + n + Module + PBXOpenQuicklyModule + Name + Open Quickly Tool + + + BundleLoadPath + + MaxInstances + 1 + Module + PBXDebugSessionModule + Name + Debugger + + + BundleLoadPath + + MaxInstances + 1 + Module + PBXDebugCLIModule + Name + Debug Console + + + BundleLoadPath + + MaxInstances + n + Module + XCSnapshotModule + Name + Snapshots Tool + + + BundlePath + /Developer/Library/PrivateFrameworks/DevToolsInterface.framework/Resources + Description + DefaultDescriptionKey + DockingSystemVisible + + Extension + mode1v3 + FavBarConfig + + PBXProjectModuleGUID + DA888A740FFEE2A800F645F7 + XCBarModuleItemNames + + XCBarModuleItems + + + FirstTimeWindowDisplayed + + Identifier + com.apple.perspectives.project.mode1v3 + MajorVersion + 33 + MinorVersion + 0 + Name + Default + Notifications + + OpenEditors + + PerspectiveWidths + + -1 + -1 + + Perspectives + + + ChosenToolbarItems + + active-combo-popup + action + NSToolbarFlexibleSpaceItem + debugger-enable-breakpoints + buildOrClean + build-and-go + com.apple.ide.PBXToolbarStopButton + get-info + NSToolbarFlexibleSpaceItem + com.apple.pbx.toolbar.searchfield + + ControllerClassBaseName + + IconName + WindowOfProjectWithEditor + Identifier + perspective.project + IsVertical + + Layout + + + ContentConfiguration + + PBXBottomSmartGroupGIDs + + 1C37FBAC04509CD000000102 + 1C37FAAC04509CD000000102 + 1C37FABC05509CD000000102 + 1C37FABC05539CD112110102 + E2644B35053B69B200211256 + 1C37FABC04509CD000100104 + 1CC0EA4004350EF90044410B + 1CC0EA4004350EF90041110B + + PBXProjectModuleGUID + 1CE0B1FE06471DED0097A5F4 + PBXProjectModuleLabel + Files + PBXProjectStructureProvided + yes + PBXSmartGroupTreeModuleColumnData + + PBXSmartGroupTreeModuleColumnWidthsKey + + 22 + 173 + + PBXSmartGroupTreeModuleColumnsKey_v4 + + SCMStatusColumn + MainColumn + + + PBXSmartGroupTreeModuleOutlineStateKey_v7 + + PBXSmartGroupTreeModuleOutlineStateExpansionKey + + 5607DA2C07B19B9D00C2151B + 1C37FBAC04509CD000000102 + 1C37FABC05509CD000000102 + + PBXSmartGroupTreeModuleOutlineStateSelectionKey + + + 23 + 0 + + + PBXSmartGroupTreeModuleOutlineStateVisibleRectKey + {{0, 0}, {195, 1062}} + + PBXTopSmartGroupGIDs + + XCIncludePerspectivesSwitch + + XCSharingToken + com.apple.Xcode.GFSharingToken + + GeometryConfiguration + + Frame + {{0, 0}, {212, 1080}} + GroupTreeTableConfiguration + + SCMStatusColumn + 22 + MainColumn + 173 + + RubberWindowFrame + 70 57 922 1121 0 0 1920 1178 + + Module + PBXSmartGroupTreeModule + Proportion + 212pt + + + Dock + + + BecomeActive + + ContentConfiguration + + PBXProjectModuleGUID + 1CE0B20306471E060097A5F4 + PBXProjectModuleLabel + XTextureFile.h + PBXSplitModuleInNavigatorKey + + Split0 + + PBXProjectModuleGUID + 1CE0B20406471E060097A5F4 + PBXProjectModuleLabel + XTextureFile.h + _historyCapacity + 0 + bookmark + DA5599191094CB78001E7255 + history + + DA6D708E10096A7800A340F1 + DA6D70BC100A697200A340F1 + DA6D7118100A780C00A340F1 + DAE2B68B109152D6005ED940 + DA5598681094B742001E7255 + DA5598991094BFC7001E7255 + DA5598AF1094C1A2001E7255 + DA5598E21094C7C3001E7255 + DA5598E31094C7C3001E7255 + DA5598E41094C7C3001E7255 + DA5598E51094C7C3001E7255 + DA5598E61094C7C3001E7255 + + + SplitCount + 1 + + StatusBarVisibility + + + GeometryConfiguration + + Frame + {{0, 0}, {705, 890}} + RubberWindowFrame + 70 57 922 1121 0 0 1920 1178 + + Module + PBXNavigatorGroup + Proportion + 890pt + + + ContentConfiguration + + PBXProjectModuleGUID + 1CE0B20506471E060097A5F4 + PBXProjectModuleLabel + Detail + + GeometryConfiguration + + Frame + {{0, 895}, {705, 186}} + RubberWindowFrame + 70 57 922 1121 0 0 1920 1178 + + Module + XCDetailModule + Proportion + 186pt + + + Proportion + 705pt + + + Name + Project + ServiceClasses + + XCModuleDock + PBXSmartGroupTreeModule + XCModuleDock + PBXNavigatorGroup + XCDetailModule + + TableOfContents + + DA5596841094B25B001E7255 + 1CE0B1FE06471DED0097A5F4 + DA5596851094B25B001E7255 + 1CE0B20306471E060097A5F4 + 1CE0B20506471E060097A5F4 + + ToolbarConfigUserDefaultsMinorVersion + 2 + ToolbarConfiguration + xcode.toolbar.config.defaultV3 + + + ControllerClassBaseName + + IconName + WindowOfProject + Identifier + perspective.morph + IsVertical + 0 + Layout + + + BecomeActive + 1 + ContentConfiguration + + PBXBottomSmartGroupGIDs + + 1C37FBAC04509CD000000102 + 1C37FAAC04509CD000000102 + 1C08E77C0454961000C914BD + 1C37FABC05509CD000000102 + 1C37FABC05539CD112110102 + E2644B35053B69B200211256 + 1C37FABC04509CD000100104 + 1CC0EA4004350EF90044410B + 1CC0EA4004350EF90041110B + + PBXProjectModuleGUID + 11E0B1FE06471DED0097A5F4 + PBXProjectModuleLabel + Files + PBXProjectStructureProvided + yes + PBXSmartGroupTreeModuleColumnData + + PBXSmartGroupTreeModuleColumnWidthsKey + + 186 + + PBXSmartGroupTreeModuleColumnsKey_v4 + + MainColumn + + + PBXSmartGroupTreeModuleOutlineStateKey_v7 + + PBXSmartGroupTreeModuleOutlineStateExpansionKey + + 29B97314FDCFA39411CA2CEA + 1C37FABC05509CD000000102 + + PBXSmartGroupTreeModuleOutlineStateSelectionKey + + + 0 + + + PBXSmartGroupTreeModuleOutlineStateVisibleRectKey + {{0, 0}, {186, 337}} + + PBXTopSmartGroupGIDs + + XCIncludePerspectivesSwitch + 1 + XCSharingToken + com.apple.Xcode.GFSharingToken + + GeometryConfiguration + + Frame + {{0, 0}, {203, 355}} + GroupTreeTableConfiguration + + MainColumn + 186 + + RubberWindowFrame + 373 269 690 397 0 0 1440 878 + + Module + PBXSmartGroupTreeModule + Proportion + 100% + + + Name + Morph + PreferredWidth + 300 + ServiceClasses + + XCModuleDock + PBXSmartGroupTreeModule + + TableOfContents + + 11E0B1FE06471DED0097A5F4 + + ToolbarConfiguration + xcode.toolbar.config.default.shortV3 + + + PerspectivesBarVisible + + ShelfIsVisible + + SourceDescription + file at '/Developer/Library/PrivateFrameworks/DevToolsInterface.framework/Resources/XCPerspectivesSpecificationMode1.xcperspec' + StatusbarIsVisible + + TimeStamp + 0.0 + ToolbarDisplayMode + 1 + ToolbarIsVisible + + ToolbarSizeMode + 1 + Type + Perspectives + UpdateMessage + The Default Workspace in this version of Xcode now includes support to hide and show the detail view (what has been referred to as the "Metro-Morph" feature). You must discard your current Default Workspace settings and update to the latest Default Workspace in order to gain this feature. Do you wish to update to the latest Workspace defaults for project '%@'? + WindowJustification + 5 + WindowOrderList + + DA888A750FFEE2A800F645F7 + DA6D70AB10096BEA00A340F1 + /Users/junmura/character-loader/Loader.xcodeproj + + WindowString + 70 57 922 1121 0 0 1920 1178 + WindowToolsV3 + + + FirstTimeWindowDisplayed + + Identifier + windowTool.build + IsVertical + + Layout + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + 1CD0528F0623707200166675 + PBXProjectModuleLabel + XTextureFile.cpp + StatusBarVisibility + + + GeometryConfiguration + + Frame + {{0, 0}, {813, 236}} + RubberWindowFrame + 698 312 813 779 0 0 1920 1178 + + Module + PBXNavigatorGroup + Proportion + 236pt + + + BecomeActive + + ContentConfiguration + + PBXProjectModuleGUID + XCMainBuildResultsModuleGUID + PBXProjectModuleLabel + Build Results + XCBuildResultsTrigger_Collapse + 1021 + XCBuildResultsTrigger_Open + 1011 + + GeometryConfiguration + + Frame + {{0, 241}, {813, 497}} + RubberWindowFrame + 698 312 813 779 0 0 1920 1178 + + Module + PBXBuildResultsModule + Proportion + 497pt + + + Proportion + 738pt + + + Name + Build Results + ServiceClasses + + PBXBuildResultsModule + + StatusbarIsVisible + + TableOfContents + + DA888A750FFEE2A800F645F7 + DA5596861094B25B001E7255 + 1CD0528F0623707200166675 + XCMainBuildResultsModuleGUID + + ToolbarConfiguration + xcode.toolbar.config.buildV3 + WindowString + 698 312 813 779 0 0 1920 1178 + WindowToolGUID + DA888A750FFEE2A800F645F7 + WindowToolIsVisible + + + + FirstTimeWindowDisplayed + + Identifier + windowTool.debugger + IsVertical + + Layout + + + Dock + + + ContentConfiguration + + Debugger + + HorizontalSplitView + + _collapsingFrameDimension + 0.0 + _indexOfCollapsedView + 0 + _percentageOfCollapsedView + 0.0 + isCollapsed + yes + sizes + + {{0, 0}, {586, 495}} + {{586, 0}, {558, 495}} + + + VerticalSplitView + + _collapsingFrameDimension + 0.0 + _indexOfCollapsedView + 0 + _percentageOfCollapsedView + 0.0 + isCollapsed + yes + sizes + + {{0, 0}, {1144, 495}} + {{0, 495}, {1144, 440}} + + + + LauncherConfigVersion + 8 + PBXProjectModuleGUID + 1C162984064C10D400B95A72 + PBXProjectModuleLabel + Debug - GLUTExamples (Underwater) + + GeometryConfiguration + + DebugConsoleVisible + None + DebugConsoleWindowFrame + {{200, 200}, {500, 300}} + DebugSTDIOWindowFrame + {{200, 200}, {500, 300}} + Frame + {{0, 0}, {1144, 935}} + PBXDebugSessionStackFrameViewKey + + DebugVariablesTableConfiguration + + Name + 120 + Value + 109 + Summary + 304 + + Frame + {{586, 0}, {558, 495}} + RubberWindowFrame + 438 202 1144 976 0 0 1920 1178 + + RubberWindowFrame + 438 202 1144 976 0 0 1920 1178 + + Module + PBXDebugSessionModule + Proportion + 935pt + + + Proportion + 935pt + + + Name + Debugger + ServiceClasses + + PBXDebugSessionModule + + StatusbarIsVisible + + TableOfContents + + 1CD10A99069EF8BA00B06720 + DA1EC372108EE97500399BE5 + 1C162984064C10D400B95A72 + DA1EC373108EE97500399BE5 + DA1EC374108EE97500399BE5 + DA1EC375108EE97500399BE5 + DA1EC376108EE97500399BE5 + DA1EC377108EE97500399BE5 + + ToolbarConfiguration + xcode.toolbar.config.debugV3 + WindowString + 438 202 1144 976 0 0 1920 1178 + WindowToolGUID + 1CD10A99069EF8BA00B06720 + WindowToolIsVisible + + + + FirstTimeWindowDisplayed + + Identifier + windowTool.find + IsVertical + + Layout + + + Dock + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + 1CDD528C0622207200134675 + PBXProjectModuleLabel + main.cpp + StatusBarVisibility + + + GeometryConfiguration + + Frame + {{0, 0}, {731, 749}} + RubberWindowFrame + 1154 92 731 1007 0 0 1920 1178 + + Module + PBXNavigatorGroup + Proportion + 731pt + + + Proportion + 749pt + + + BecomeActive + + ContentConfiguration + + PBXProjectModuleGUID + 1CD0528E0623707200166675 + PBXProjectModuleLabel + Project Find + + GeometryConfiguration + + Frame + {{0, 754}, {731, 212}} + RubberWindowFrame + 1154 92 731 1007 0 0 1920 1178 + + Module + PBXProjectFindModule + Proportion + 212pt + + + Proportion + 966pt + + + Name + Project Find + ServiceClasses + + PBXProjectFindModule + + StatusbarIsVisible + + TableOfContents + + 1C530D57069F1CE1000CFCEE + DA6B26F7101B73FC00122FAE + DA6B26F8101B73FC00122FAE + 1CDD528C0622207200134675 + 1CD0528E0623707200166675 + + WindowString + 1154 92 731 1007 0 0 1920 1178 + WindowToolGUID + 1C530D57069F1CE1000CFCEE + WindowToolIsVisible + + + + Identifier + MENUSEPARATOR + + + FirstTimeWindowDisplayed + + Identifier + windowTool.debuggerConsole + IsVertical + + Layout + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + 1C78EAAC065D492600B07095 + PBXProjectModuleLabel + Debugger Console + + GeometryConfiguration + + Frame + {{0, 0}, {798, 572}} + RubberWindowFrame + 992 99 798 613 0 0 1920 1178 + + Module + PBXDebugCLIModule + Proportion + 572pt + + + Proportion + 572pt + + + Name + Debugger Console + ServiceClasses + + PBXDebugCLIModule + + StatusbarIsVisible + + TableOfContents + + 1C78EAAD065D492600B07095 + DAFAC0C7101CEC0000329128 + 1C78EAAC065D492600B07095 + + ToolbarConfiguration + xcode.toolbar.config.consoleV3 + WindowString + 992 99 798 613 0 0 1920 1178 + WindowToolGUID + 1C78EAAD065D492600B07095 + WindowToolIsVisible + + + + Identifier + windowTool.snapshots + Layout + + + Dock + + + Module + XCSnapshotModule + Proportion + 100% + + + Proportion + 100% + + + Name + Snapshots + ServiceClasses + + XCSnapshotModule + + StatusbarIsVisible + Yes + ToolbarConfiguration + xcode.toolbar.config.snapshots + WindowString + 315 824 300 550 0 0 1440 878 + WindowToolIsVisible + Yes + + + FirstTimeWindowDisplayed + + Identifier + windowTool.scm + IsVertical + + Layout + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + 1C78EAB2065D492600B07095 + PBXProjectModuleLabel + + StatusBarVisibility + + + GeometryConfiguration + + Frame + {{0, 0}, {1010, 234}} + RubberWindowFrame + 864 276 1010 761 0 0 1920 1178 + + Module + PBXNavigatorGroup + Proportion + 234pt + + + BecomeActive + + ContentConfiguration + + PBXCVSModuleFilterTypeKey + 1032 + PBXCVSModuleTreeModuleColumnData + + PBXCVSModuleTreeModuleColumnWidthsKey + + 594 + 56 + 63 + 60 + 63 + 139 + + PBXCVSModuleTreeModuleColumnsKey + + Name + Status + Update + Revision + Author + Date + + + PBXProjectModuleGUID + 1CD052920623707200166675 + PBXProjectModuleLabel + SCM Results + SCMActivityViewerShowingDefaultKey + {{0, 384}, {1010, 97}} + + GeometryConfiguration + + Frame + {{0, 239}, {1010, 481}} + RubberWindowFrame + 864 276 1010 761 0 0 1920 1178 + + Module + PBXCVSModule + Proportion + 481pt + + + Proportion + 720pt + + + Name + SCM + ServiceClasses + + PBXCVSModule + + StatusbarIsVisible + + TableOfContents + + DA6D70AB10096BEA00A340F1 + DA5596871094B25B001E7255 + 1C78EAB2065D492600B07095 + 1CD052920623707200166675 + + ToolbarConfiguration + xcode.toolbar.config.scm + WindowString + 864 276 1010 761 0 0 1920 1178 + WindowToolGUID + DA6D70AB10096BEA00A340F1 + WindowToolIsVisible + + + + FirstTimeWindowDisplayed + + Identifier + windowTool.breakpoints + IsVertical + + Layout + + + Dock + + + ContentConfiguration + + PBXBottomSmartGroupGIDs + + 1C77FABC04509CD000000102 + + PBXProjectModuleGUID + 1CE0B1FE06471DED0097A5F4 + PBXProjectModuleLabel + Files + PBXProjectStructureProvided + no + PBXSmartGroupTreeModuleColumnData + + PBXSmartGroupTreeModuleColumnWidthsKey + + 168 + + PBXSmartGroupTreeModuleColumnsKey_v4 + + MainColumn + + + PBXSmartGroupTreeModuleOutlineStateKey_v7 + + PBXSmartGroupTreeModuleOutlineStateExpansionKey + + 1C77FABC04509CD000000102 + 1C3E0DCA080725EA00A55177 + + PBXSmartGroupTreeModuleOutlineStateSelectionKey + + + 0 + + + PBXSmartGroupTreeModuleOutlineStateVisibleRectKey + {{0, 0}, {168, 350}} + + PBXTopSmartGroupGIDs + + XCIncludePerspectivesSwitch + + + GeometryConfiguration + + Frame + {{0, 0}, {185, 368}} + GroupTreeTableConfiguration + + MainColumn + 168 + + RubberWindowFrame + 991 769 744 409 0 0 1920 1178 + + Module + PBXSmartGroupTreeModule + Proportion + 185pt + + + BecomeActive + + ContentConfiguration + + PBXProjectModuleGUID + 1CA1AED706398EBD00589147 + PBXProjectModuleLabel + Detail + + GeometryConfiguration + + Frame + {{190, 0}, {554, 368}} + RubberWindowFrame + 991 769 744 409 0 0 1920 1178 + + Module + XCDetailModule + Proportion + 554pt + + + Proportion + 368pt + + + MajorVersion + 3 + MinorVersion + 0 + Name + Breakpoints + ServiceClasses + + PBXSmartGroupTreeModule + XCDetailModule + + StatusbarIsVisible + + TableOfContents + + DA6B265010124C5900122FAE + DA6B265110124C5900122FAE + 1CE0B1FE06471DED0097A5F4 + 1CA1AED706398EBD00589147 + + ToolbarConfiguration + xcode.toolbar.config.breakpointsV3 + WindowString + 991 769 744 409 0 0 1920 1178 + WindowToolGUID + DA6B265010124C5900122FAE + WindowToolIsVisible + + + + Identifier + windowTool.debugAnimator + Layout + + + Dock + + + Module + PBXNavigatorGroup + Proportion + 100% + + + Proportion + 100% + + + Name + Debug Visualizer + ServiceClasses + + PBXNavigatorGroup + + StatusbarIsVisible + 1 + ToolbarConfiguration + xcode.toolbar.config.debugAnimatorV3 + WindowString + 100 100 700 500 0 0 1280 1002 + + + Identifier + windowTool.bookmarks + Layout + + + Dock + + + Module + PBXBookmarksModule + Proportion + 100% + + + Proportion + 100% + + + Name + Bookmarks + ServiceClasses + + PBXBookmarksModule + + StatusbarIsVisible + 0 + WindowString + 538 42 401 187 0 0 1280 1002 + + + Identifier + windowTool.projectFormatConflicts + Layout + + + Dock + + + Module + XCProjectFormatConflictsModule + Proportion + 100% + + + Proportion + 100% + + + Name + Project Format Conflicts + ServiceClasses + + XCProjectFormatConflictsModule + + StatusbarIsVisible + 0 + WindowContentMinSize + 450 300 + WindowString + 50 850 472 307 0 0 1440 877 + + + Identifier + windowTool.classBrowser + Layout + + + Dock + + + BecomeActive + 1 + ContentConfiguration + + OptionsSetName + Hierarchy, all classes + PBXProjectModuleGUID + 1CA6456E063B45B4001379D8 + PBXProjectModuleLabel + Class Browser - NSObject + + GeometryConfiguration + + ClassesFrame + {{0, 0}, {374, 96}} + ClassesTreeTableConfiguration + + PBXClassNameColumnIdentifier + 208 + PBXClassBookColumnIdentifier + 22 + + Frame + {{0, 0}, {630, 331}} + MembersFrame + {{0, 105}, {374, 395}} + MembersTreeTableConfiguration + + PBXMemberTypeIconColumnIdentifier + 22 + PBXMemberNameColumnIdentifier + 216 + PBXMemberTypeColumnIdentifier + 97 + PBXMemberBookColumnIdentifier + 22 + + PBXModuleWindowStatusBarHidden2 + 1 + RubberWindowFrame + 385 179 630 352 0 0 1440 878 + + Module + PBXClassBrowserModule + Proportion + 332pt + + + Proportion + 332pt + + + Name + Class Browser + ServiceClasses + + PBXClassBrowserModule + + StatusbarIsVisible + 0 + TableOfContents + + 1C0AD2AF069F1E9B00FABCE6 + 1C0AD2B0069F1E9B00FABCE6 + 1CA6456E063B45B4001379D8 + + ToolbarConfiguration + xcode.toolbar.config.classbrowser + WindowString + 385 179 630 352 0 0 1440 878 + WindowToolGUID + 1C0AD2AF069F1E9B00FABCE6 + WindowToolIsVisible + 0 + + + Identifier + windowTool.refactoring + IncludeInToolsMenu + 0 + Layout + + + Dock + + + BecomeActive + 1 + GeometryConfiguration + + Frame + {0, 0}, {500, 335} + RubberWindowFrame + {0, 0}, {500, 335} + + Module + XCRefactoringModule + Proportion + 100% + + + Proportion + 100% + + + Name + Refactoring + ServiceClasses + + XCRefactoringModule + + WindowString + 200 200 500 356 0 0 1920 1200 + + + + diff --git a/Loader.xcodeproj/junmura.pbxuser b/Loader.xcodeproj/junmura.pbxuser new file mode 100644 index 000000000..182dd1713 --- /dev/null +++ b/Loader.xcodeproj/junmura.pbxuser @@ -0,0 +1,970 @@ +// !$*UTF8*$! +{ + 5607DA3007B19B9D00C2151B /* Project object */ = { + activeBuildConfigurationName = Release; + activeTarget = DA1EC36A108EE95500399BE5 /* Skin */; + addToTargets = ( + DA1EC36A108EE95500399BE5 /* Skin */, + ); + breakpoints = ( + DA6B26FA101B748A00122FAE /* XMesh.cpp:461 */, + DA6B271C101B789600122FAE /* main.cpp:390 */, + ); + codeSenseManager = DA888A7F0FFEE2A800F645F7 /* Code sense */; + perUserDictionary = { + "PBXConfiguration.PBXBreakpointsDataSource.v1:1CA1AED706398EBD00589147" = { + PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; + PBXFileTableDataSourceColumnSortingKey = PBXBreakpointsDataSource_BreakpointID; + PBXFileTableDataSourceColumnWidthsKey = ( + 20, + 20, + 198, + 20, + 99, + 99, + 29, + 20, + ); + PBXFileTableDataSourceColumnsKey = ( + PBXBreakpointsDataSource_ActionID, + PBXBreakpointsDataSource_TypeID, + PBXBreakpointsDataSource_BreakpointID, + PBXBreakpointsDataSource_UseID, + PBXBreakpointsDataSource_LocationID, + PBXBreakpointsDataSource_ConditionID, + PBXBreakpointsDataSource_IgnoreCountID, + PBXBreakpointsDataSource_ContinueID, + ); + }; + PBXConfiguration.PBXFileTableDataSource3.PBXErrorsWarningsDataSource = { + PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; + PBXFileTableDataSourceColumnSortingKey = PBXErrorsWarningsDataSource_LocationID; + PBXFileTableDataSourceColumnWidthsKey = ( + 20, + 468, + 320, + ); + PBXFileTableDataSourceColumnsKey = ( + PBXErrorsWarningsDataSource_TypeID, + PBXErrorsWarningsDataSource_MessageID, + PBXErrorsWarningsDataSource_LocationID, + ); + }; + PBXConfiguration.PBXFileTableDataSource3.PBXExecutablesDataSource = { + PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; + PBXFileTableDataSourceColumnSortingKey = PBXExecutablesDataSource_NameID; + PBXFileTableDataSourceColumnWidthsKey = ( + 22, + 300, + 486, + ); + PBXFileTableDataSourceColumnsKey = ( + PBXExecutablesDataSource_ActiveFlagID, + PBXExecutablesDataSource_NameID, + PBXExecutablesDataSource_CommentsID, + ); + }; + PBXConfiguration.PBXFileTableDataSource3.PBXFileTableDataSource = { + PBXFileTableDataSourceColumnSortingDirectionKey = 1; + PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; + PBXFileTableDataSourceColumnWidthsKey = ( + 20, + 466, + 20, + 48, + 43, + 43, + 20, + ); + PBXFileTableDataSourceColumnsKey = ( + PBXFileDataSource_FiletypeID, + PBXFileDataSource_Filename_ColumnID, + PBXFileDataSource_Built_ColumnID, + PBXFileDataSource_ObjectSize_ColumnID, + PBXFileDataSource_Errors_ColumnID, + PBXFileDataSource_Warnings_ColumnID, + PBXFileDataSource_Target_ColumnID, + ); + }; + PBXConfiguration.PBXFileTableDataSource3.PBXFindDataSource = { + PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; + PBXFileTableDataSourceColumnSortingKey = PBXFindDataSource_LocationID; + PBXFileTableDataSourceColumnWidthsKey = ( + 200, + 612, + ); + PBXFileTableDataSourceColumnsKey = ( + PBXFindDataSource_MessageID, + PBXFindDataSource_LocationID, + ); + }; + PBXConfiguration.PBXFileTableDataSource3.XCSCMDataSource = { + PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; + PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; + PBXFileTableDataSourceColumnWidthsKey = ( + 20, + 20, + 574, + 20, + 48, + 43, + 43, + 20, + ); + PBXFileTableDataSourceColumnsKey = ( + PBXFileDataSource_SCM_ColumnID, + PBXFileDataSource_FiletypeID, + PBXFileDataSource_Filename_ColumnID, + PBXFileDataSource_Built_ColumnID, + PBXFileDataSource_ObjectSize_ColumnID, + PBXFileDataSource_Errors_ColumnID, + PBXFileDataSource_Warnings_ColumnID, + PBXFileDataSource_Target_ColumnID, + ); + }; + PBXConfiguration.PBXTargetDataSource.PBXTargetDataSource = { + PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; + PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; + PBXFileTableDataSourceColumnWidthsKey = ( + 20, + 362, + 60, + 20, + 48, + 43, + 43, + ); + PBXFileTableDataSourceColumnsKey = ( + PBXFileDataSource_FiletypeID, + PBXFileDataSource_Filename_ColumnID, + PBXTargetDataSource_PrimaryAttribute, + PBXFileDataSource_Built_ColumnID, + PBXFileDataSource_ObjectSize_ColumnID, + PBXFileDataSource_Errors_ColumnID, + PBXFileDataSource_Warnings_ColumnID, + ); + }; + PBXPerProjectTemplateStateSaveDate = 278180431; + PBXWorkspaceStateSaveDate = 278180431; + }; + perUserProjectItems = { + DA5596831094B25B001E7255 /* PBXTextBookmark */ = DA5596831094B25B001E7255 /* PBXTextBookmark */; + DA5598391094B2BF001E7255 /* PBXTextBookmark */ = DA5598391094B2BF001E7255 /* PBXTextBookmark */; + DA55983E1094B302001E7255 /* PBXTextBookmark */ = DA55983E1094B302001E7255 /* PBXTextBookmark */; + DA5598681094B742001E7255 /* PBXTextBookmark */ = DA5598681094B742001E7255 /* PBXTextBookmark */; + DA5598691094B742001E7255 /* PBXBookmark */ = DA5598691094B742001E7255 /* PBXBookmark */; + DA55986A1094B742001E7255 /* PBXTextBookmark */ = DA55986A1094B742001E7255 /* PBXTextBookmark */; + DA55987A1094B813001E7255 /* PBXTextBookmark */ = DA55987A1094B813001E7255 /* PBXTextBookmark */; + DA5598831094B8F5001E7255 /* PBXTextBookmark */ = DA5598831094B8F5001E7255 /* PBXTextBookmark */; + DA5598841094B8F5001E7255 /* PBXTextBookmark */ = DA5598841094B8F5001E7255 /* PBXTextBookmark */; + DA5598851094B8F5001E7255 /* PBXTextBookmark */ = DA5598851094B8F5001E7255 /* PBXTextBookmark */; + DA55988C1094B963001E7255 /* PBXTextBookmark */ = DA55988C1094B963001E7255 /* PBXTextBookmark */; + DA5598931094BAAF001E7255 /* PBXTextBookmark */ = DA5598931094BAAF001E7255 /* PBXTextBookmark */; + DA5598981094BFC7001E7255 /* PBXTextBookmark */ = DA5598981094BFC7001E7255 /* PBXTextBookmark */; + DA5598991094BFC7001E7255 /* PBXTextBookmark */ = DA5598991094BFC7001E7255 /* PBXTextBookmark */; + DA55989A1094BFC7001E7255 /* PBXTextBookmark */ = DA55989A1094BFC7001E7255 /* PBXTextBookmark */; + DA5598A21094C188001E7255 /* XCBuildMessageTextBookmark */ = DA5598A21094C188001E7255 /* XCBuildMessageTextBookmark */; + DA5598A41094C188001E7255 /* PBXTextBookmark */ = DA5598A41094C188001E7255 /* PBXTextBookmark */; + DA5598AF1094C1A2001E7255 /* PBXTextBookmark */ = DA5598AF1094C1A2001E7255 /* PBXTextBookmark */; + DA5598B01094C1A2001E7255 /* PBXTextBookmark */ = DA5598B01094C1A2001E7255 /* PBXTextBookmark */; + DA5598B11094C1A2001E7255 /* PBXTextBookmark */ = DA5598B11094C1A2001E7255 /* PBXTextBookmark */; + DA5598B21094C1A2001E7255 /* PBXTextBookmark */ = DA5598B21094C1A2001E7255 /* PBXTextBookmark */; + DA5598B31094C1A2001E7255 /* PBXTextBookmark */ = DA5598B31094C1A2001E7255 /* PBXTextBookmark */; + DA5598B61094C239001E7255 /* PBXTextBookmark */ = DA5598B61094C239001E7255 /* PBXTextBookmark */; + DA5598BB1094C2EA001E7255 /* PBXTextBookmark */ = DA5598BB1094C2EA001E7255 /* PBXTextBookmark */; + DA5598C21094C2F6001E7255 /* PBXTextBookmark */ = DA5598C21094C2F6001E7255 /* PBXTextBookmark */; + DA5598C51094C50B001E7255 /* PBXTextBookmark */ = DA5598C51094C50B001E7255 /* PBXTextBookmark */; + DA5598C61094C50B001E7255 /* PBXTextBookmark */ = DA5598C61094C50B001E7255 /* PBXTextBookmark */; + DA5598C81094C50B001E7255 /* PBXTextBookmark */ = DA5598C81094C50B001E7255 /* PBXTextBookmark */; + DA5598CA1094C50C001E7255 /* PBXTextBookmark */ = DA5598CA1094C50C001E7255 /* PBXTextBookmark */; + DA5598CD1094C60F001E7255 /* PBXTextBookmark */ = DA5598CD1094C60F001E7255 /* PBXTextBookmark */; + DA5598CE1094C60F001E7255 /* PBXTextBookmark */ = DA5598CE1094C60F001E7255 /* PBXTextBookmark */; + DA5598CF1094C60F001E7255 /* PBXTextBookmark */ = DA5598CF1094C60F001E7255 /* PBXTextBookmark */; + DA5598D61094C61F001E7255 /* PBXTextBookmark */ = DA5598D61094C61F001E7255 /* PBXTextBookmark */; + DA5598D91094C789001E7255 /* PBXTextBookmark */ = DA5598D91094C789001E7255 /* PBXTextBookmark */; + DA5598DA1094C789001E7255 /* XCBuildMessageTextBookmark */ = DA5598DA1094C789001E7255 /* XCBuildMessageTextBookmark */; + DA5598DB1094C789001E7255 /* PBXTextBookmark */ = DA5598DB1094C789001E7255 /* PBXTextBookmark */; + DA5598E21094C7C3001E7255 /* PBXTextBookmark */ = DA5598E21094C7C3001E7255 /* PBXTextBookmark */; + DA5598E31094C7C3001E7255 /* PBXTextBookmark */ = DA5598E31094C7C3001E7255 /* PBXTextBookmark */; + DA5598E41094C7C3001E7255 /* PBXTextBookmark */ = DA5598E41094C7C3001E7255 /* PBXTextBookmark */; + DA5598E51094C7C3001E7255 /* PBXTextBookmark */ = DA5598E51094C7C3001E7255 /* PBXTextBookmark */; + DA5598E61094C7C3001E7255 /* PBXTextBookmark */ = DA5598E61094C7C3001E7255 /* PBXTextBookmark */; + DA5598E71094C7C3001E7255 /* PBXTextBookmark */ = DA5598E71094C7C3001E7255 /* PBXTextBookmark */; + DA5598EA1094C82B001E7255 /* PBXTextBookmark */ = DA5598EA1094C82B001E7255 /* PBXTextBookmark */; + DA5598F11094C835001E7255 /* PBXTextBookmark */ = DA5598F11094C835001E7255 /* PBXTextBookmark */; + DA5598F61094CA79001E7255 /* PBXTextBookmark */ = DA5598F61094CA79001E7255 /* PBXTextBookmark */; + DA5598FD1094CAA6001E7255 /* PBXTextBookmark */ = DA5598FD1094CAA6001E7255 /* PBXTextBookmark */; + DA5599051094CAD6001E7255 /* PBXTextBookmark */ = DA5599051094CAD6001E7255 /* PBXTextBookmark */; + DA5599081094CB18001E7255 /* PBXTextBookmark */ = DA5599081094CB18001E7255 /* PBXTextBookmark */; + DA55990D1094CB20001E7255 /* PBXTextBookmark */ = DA55990D1094CB20001E7255 /* PBXTextBookmark */; + DA5599121094CB5C001E7255 /* PBXTextBookmark */ = DA5599121094CB5C001E7255 /* PBXTextBookmark */; + DA5599191094CB78001E7255 /* PBXTextBookmark */ = DA5599191094CB78001E7255 /* PBXTextBookmark */; + DA6B26B510125A3700122FAE = DA6B26B510125A3700122FAE /* PBXTextBookmark */; + DA6D708E10096A7800A340F1 = DA6D708E10096A7800A340F1 /* PBXTextBookmark */; + DA6D70BC100A697200A340F1 = DA6D70BC100A697200A340F1 /* PlistBookmark */; + DA6D7118100A780C00A340F1 = DA6D7118100A780C00A340F1 /* PBXTextBookmark */; + DA80ECF310916FAC001A2D3B = DA80ECF310916FAC001A2D3B /* PBXTextBookmark */; + DAE2B68B109152D6005ED940 = DAE2B68B109152D6005ED940 /* PBXTextBookmark */; + DAE2B7B510916408005ED940 = DAE2B7B510916408005ED940 /* PBXTextBookmark */; + }; + sourceControlManager = DA888A7E0FFEE2A800F645F7 /* Source Control */; + userBuildSettings = { + }; + }; + DA1EC36A108EE95500399BE5 /* Skin */ = { + activeExec = 0; + }; + DA23B31210090B3C00B5CECE /* main.cpp */ = { + isa = PBXFileReference; + fileEncoding = 4; + lastKnownFileType = sourcecode.cpp.cpp; + name = main.cpp; + path = "/Users/junmura/character-loader/Loader/main.cpp"; + sourceTree = ""; + }; + DA23B31410090B3C00B5CECE /* XAnimation.cpp */ = { + isa = PBXFileReference; + fileEncoding = 4; + lastKnownFileType = sourcecode.cpp.cpp; + name = XAnimation.cpp; + path = "/Users/junmura/character-loader/Loader/XAnimation.cpp"; + sourceTree = ""; + }; + DA23B32C10090B3C00B5CECE /* XTransformation.cpp */ = { + isa = PBXFileReference; + fileEncoding = 4; + lastKnownFileType = sourcecode.cpp.cpp; + name = XTransformation.cpp; + path = "/Users/junmura/character-loader/Loader/XTransformation.cpp"; + sourceTree = ""; + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {922, 1105}}"; + sepNavSelRange = "{0, 0}"; + sepNavVisRange = "{235, 1729}"; + }; + }; + DA23B6E010094ADF00B5CECE /* mm_malloc.h */ = { + isa = PBXFileReference; + fileEncoding = 4; + lastKnownFileType = sourcecode.c.h; + name = mm_malloc.h; + path = "/Users/junmura/character-loader/Loader/mm_malloc.h"; + sourceTree = ""; + }; + DA5596831094B25B001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B64E10915168005ED940 /* XJointAnim.cpp */; + name = "XJointAnim.cpp: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1970; + vrLoc = 0; + }; + DA5598391094B2BF001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B64E10915168005ED940 /* XJointAnim.cpp */; + name = "XJointAnim.cpp: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1970; + vrLoc = 0; + }; + DA55983E1094B302001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B64E10915168005ED940 /* XJointAnim.cpp */; + name = "XJointAnim.cpp: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1970; + vrLoc = 0; + }; + DA5598681094B742001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B64E10915168005ED940 /* XJointAnim.cpp */; + name = "XJointAnim.cpp: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1970; + vrLoc = 0; + }; + DA5598691094B742001E7255 /* PBXBookmark */ = { + isa = PBXBookmark; + fRef = DAE2B65D10915168005ED940 /* XTextureFile.h */; + }; + DA55986A1094B742001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B65D10915168005ED940 /* XTextureFile.h */; + name = "XTextureFile.h: 24"; + rLen = 0; + rLoc = 907; + rType = 0; + vrLen = 2489; + vrLoc = 4799; + }; + DA55987A1094B813001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B65D10915168005ED940 /* XTextureFile.h */; + name = "XTextureFile.h: 24"; + rLen = 0; + rLoc = 907; + rType = 0; + vrLen = 2489; + vrLoc = 4799; + }; + DA5598831094B8F5001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B65D10915168005ED940 /* XTextureFile.h */; + name = "XTextureFile.h: 24"; + rLen = 0; + rLoc = 907; + rType = 0; + vrLen = 2489; + vrLoc = 4799; + }; + DA5598841094B8F5001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B65C10915168005ED940 /* XTextureFile.cpp */; + name = "XTextureFile.cpp: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 2303; + vrLoc = 0; + }; + DA5598851094B8F5001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B65C10915168005ED940 /* XTextureFile.cpp */; + name = "XTextureFile.cpp: 128"; + rLen = 0; + rLoc = 4072; + rType = 0; + vrLen = 1787; + vrLoc = 3179; + }; + DA55988C1094B963001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B65C10915168005ED940 /* XTextureFile.cpp */; + name = "XTextureFile.cpp: 157"; + rLen = 0; + rLoc = 4939; + rType = 0; + vrLen = 1783; + vrLoc = 3931; + }; + DA5598931094BAAF001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B65C10915168005ED940 /* XTextureFile.cpp */; + name = "XTextureFile.cpp: 157"; + rLen = 0; + rLoc = 4939; + rType = 0; + vrLen = 1783; + vrLoc = 3931; + }; + DA5598981094BFC7001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B65C10915168005ED940 /* XTextureFile.cpp */; + name = "XTextureFile.cpp: 157"; + rLen = 0; + rLoc = 4939; + rType = 0; + vrLen = 1626; + vrLoc = 2654; + }; + DA5598991094BFC7001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B65B10915168005ED940 /* XSkeleton.h */; + name = "XSkeleton.h: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1853; + vrLoc = 0; + }; + DA55989A1094BFC7001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B65D10915168005ED940 /* XTextureFile.h */; + name = "XTextureFile.h: 187"; + rLen = 0; + rLoc = 6746; + rType = 0; + vrLen = 2716; + vrLoc = 1781; + }; + DA5598A21094C188001E7255 /* XCBuildMessageTextBookmark */ = { + isa = PBXTextBookmark; + comments = "'SMatNames' defined but not used"; + fRef = DA5598A31094C188001E7255 /* SharedStructures.h */; + fallbackIsa = XCBuildMessageTextBookmark; + rLen = 1; + rLoc = 26; + rType = 1; + }; + DA5598A31094C188001E7255 /* SharedStructures.h */ = { + isa = PBXFileReference; + name = SharedStructures.h; + path = "/Users/junmura/character-loader/Loader/../SharedStructures.h"; + sourceTree = ""; + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {922, 1469}}"; + sepNavSelRange = "{1008, 0}"; + sepNavVisRange = "{0, 1673}"; + }; + }; + DA5598A41094C188001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DA5598A51094C188001E7255 /* SharedStructures.h */; + name = "SharedStructures.h: 27"; + rLen = 0; + rLoc = 1008; + rType = 0; + vrLen = 246; + vrLoc = 888; + }; + DA5598A51094C188001E7255 /* SharedStructures.h */ = { + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = SharedStructures.h; + path = "/Users/junmura/character-loader/Loader/../SharedStructures.h"; + sourceTree = ""; + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {922, 1469}}"; + sepNavSelRange = "{1008, 0}"; + sepNavVisRange = "{0, 1673}"; + }; + }; + DA5598AF1094C1A2001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B65010915168005ED940 /* XMaterial.cpp */; + name = "XMaterial.cpp: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1952; + vrLoc = 0; + }; + DA5598B01094C1A2001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DA5598A31094C188001E7255 /* SharedStructures.h */; + name = "SharedStructures.h: 27"; + rLen = 0; + rLoc = 1008; + rType = 0; + vrLen = 1673; + vrLoc = 0; + }; + DA5598B11094C1A2001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B65C10915168005ED940 /* XTextureFile.cpp */; + name = "XTextureFile.cpp: 157"; + rLen = 0; + rLoc = 4939; + rType = 0; + vrLen = 1625; + vrLoc = 2654; + }; + DA5598B21094C1A2001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B65D10915168005ED940 /* XTextureFile.h */; + name = "XTextureFile.h: 54"; + rLen = 0; + rLoc = 1657; + rType = 0; + vrLen = 2451; + vrLoc = 1052; + }; + DA5598B31094C1A2001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B65D10915168005ED940 /* XTextureFile.h */; + name = "XTextureFile.h: 54"; + rLen = 0; + rLoc = 1657; + rType = 0; + vrLen = 2397; + vrLoc = 1052; + }; + DA5598B61094C239001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B65D10915168005ED940 /* XTextureFile.h */; + name = "XTextureFile.h: 45"; + rLen = 0; + rLoc = 1342; + rType = 0; + vrLen = 2451; + vrLoc = 1052; + }; + DA5598BB1094C2EA001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B65D10915168005ED940 /* XTextureFile.h */; + name = "XTextureFile.h: 44"; + rLen = 4; + rLoc = 1312; + rType = 0; + vrLen = 2451; + vrLoc = 1052; + }; + DA5598C21094C2F6001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B65D10915168005ED940 /* XTextureFile.h */; + name = "XTextureFile.h: 44"; + rLen = 4; + rLoc = 1312; + rType = 0; + vrLen = 2451; + vrLoc = 1052; + }; + DA5598C51094C50B001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B65D10915168005ED940 /* XTextureFile.h */; + name = "XTextureFile.h: 44"; + rLen = 4; + rLoc = 1317; + rType = 0; + vrLen = 2451; + vrLoc = 1052; + }; + DA5598C61094C50B001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DA5598C71094C50B001E7255 /* types.h */; + name = "types.h: 98"; + rLen = 10; + rLoc = 3926; + rType = 0; + vrLen = 1628; + vrLoc = 3334; + }; + DA5598C71094C50B001E7255 /* types.h */ = { + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = types.h; + path = /usr/include/ppc/types.h; + sourceTree = ""; + }; + DA5598C81094C50B001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DA5598C91094C50B001E7255 /* types.h */; + name = "types.h: 98"; + rLen = 10; + rLoc = 3926; + rType = 0; + vrLen = 1628; + vrLoc = 3334; + }; + DA5598C91094C50B001E7255 /* types.h */ = { + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = types.h; + path = /usr/include/ppc/types.h; + sourceTree = ""; + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {644, 1768}}"; + sepNavSelRange = "{4394, 31}"; + sepNavVisRange = "{3358, 1604}"; + }; + }; + DA5598CA1094C50C001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DA5598C91094C50B001E7255 /* types.h */; + name = "types.h: 98"; + rLen = 10; + rLoc = 3926; + rType = 0; + vrLen = 647; + vrLoc = 3334; + }; + DA5598CD1094C60F001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DA5598C91094C50B001E7255 /* types.h */; + name = "types.h: 117"; + rLen = 31; + rLoc = 4394; + rType = 0; + vrLen = 1861; + vrLoc = 2597; + }; + DA5598CE1094C60F001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B65D10915168005ED940 /* XTextureFile.h */; + name = "XTextureFile.h: 44"; + rLen = 4; + rLoc = 1317; + rType = 0; + vrLen = 2451; + vrLoc = 1052; + }; + DA5598CF1094C60F001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B65D10915168005ED940 /* XTextureFile.h */; + name = "XTextureFile.h: 43"; + rLen = 0; + rLoc = 1302; + rType = 0; + vrLen = 2397; + vrLoc = 1052; + }; + DA5598D61094C61F001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B65D10915168005ED940 /* XTextureFile.h */; + name = "XTextureFile.h: 43"; + rLen = 0; + rLoc = 1302; + rType = 0; + vrLen = 2397; + vrLoc = 1052; + }; + DA5598D91094C789001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DA5598A51094C188001E7255 /* SharedStructures.h */; + name = "SharedStructures.h: 27"; + rLen = 0; + rLoc = 1008; + rType = 0; + vrLen = 246; + vrLoc = 888; + }; + DA5598DA1094C789001E7255 /* XCBuildMessageTextBookmark */ = { + isa = PBXTextBookmark; + comments = "Format '%d' expects type 'int', but argument 2 has type 'long unsigned int'"; + fRef = DAE2B65C10915168005ED940 /* XTextureFile.cpp */; + fallbackIsa = XCBuildMessageTextBookmark; + rLen = 1; + rLoc = 122; + rType = 1; + }; + DA5598DB1094C789001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B65C10915168005ED940 /* XTextureFile.cpp */; + name = "XTextureFile.cpp: 123"; + rLen = 0; + rLoc = 3726; + rType = 0; + vrLen = 426; + vrLoc = 3529; + }; + DA5598E21094C7C3001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DA5598C91094C50B001E7255 /* types.h */; + name = "types.h: 117"; + rLen = 31; + rLoc = 4394; + rType = 0; + vrLen = 1604; + vrLoc = 3358; + }; + DA5598E31094C7C3001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DA5598A51094C188001E7255 /* SharedStructures.h */; + name = "SharedStructures.h: 27"; + rLen = 0; + rLoc = 1008; + rType = 0; + vrLen = 1673; + vrLoc = 0; + }; + DA5598E41094C7C3001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DA23B32C10090B3C00B5CECE /* XTransformation.cpp */; + name = "XTransformation.cpp: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1729; + vrLoc = 235; + }; + DA5598E51094C7C3001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B65C10915168005ED940 /* XTextureFile.cpp */; + name = "XTextureFile.cpp: 163"; + rLen = 0; + rLoc = 4939; + rType = 0; + vrLen = 2303; + vrLoc = 0; + }; + DA5598E61094C7C3001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B65D10915168005ED940 /* XTextureFile.h */; + name = "XTextureFile.h: 149"; + rLen = 0; + rLoc = 5129; + rType = 0; + vrLen = 2497; + vrLoc = 4731; + }; + DA5598E71094C7C3001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B65D10915168005ED940 /* XTextureFile.h */; + name = "XTextureFile.h: 38"; + rLen = 0; + rLoc = 1286; + rType = 0; + vrLen = 2249; + vrLoc = 888; + }; + DA5598EA1094C82B001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B65D10915168005ED940 /* XTextureFile.h */; + name = "XTextureFile.h: 48"; + rLen = 0; + rLoc = 1650; + rType = 0; + vrLen = 2635; + vrLoc = 1106; + }; + DA5598F11094C835001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B65D10915168005ED940 /* XTextureFile.h */; + name = "XTextureFile.h: 48"; + rLen = 0; + rLoc = 1650; + rType = 0; + vrLen = 2635; + vrLoc = 1106; + }; + DA5598F61094CA79001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B65D10915168005ED940 /* XTextureFile.h */; + name = "XTextureFile.h: 196"; + rLen = 0; + rLoc = 7359; + rType = 0; + vrLen = 2740; + vrLoc = 1110; + }; + DA5598FD1094CAA6001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B65D10915168005ED940 /* XTextureFile.h */; + name = "XTextureFile.h: 196"; + rLen = 0; + rLoc = 7359; + rType = 0; + vrLen = 2740; + vrLoc = 1110; + }; + DA5599051094CAD6001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B65D10915168005ED940 /* XTextureFile.h */; + name = "XTextureFile.h: 196"; + rLen = 0; + rLoc = 7359; + rType = 0; + vrLen = 2740; + vrLoc = 1110; + }; + DA5599081094CB18001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B65D10915168005ED940 /* XTextureFile.h */; + name = "XTextureFile.h: 40"; + rLen = 0; + rLoc = 1363; + rType = 0; + vrLen = 2738; + vrLoc = 1110; + }; + DA55990D1094CB20001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B65D10915168005ED940 /* XTextureFile.h */; + name = "XTextureFile.h: 40"; + rLen = 0; + rLoc = 1363; + rType = 0; + vrLen = 2738; + vrLoc = 1110; + }; + DA5599121094CB5C001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B65D10915168005ED940 /* XTextureFile.h */; + name = "XTextureFile.h: 40"; + rLen = 0; + rLoc = 1363; + rType = 0; + vrLen = 2738; + vrLoc = 1110; + }; + DA5599191094CB78001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B65D10915168005ED940 /* XTextureFile.h */; + name = "XTextureFile.h: 40"; + rLen = 0; + rLoc = 1363; + rType = 0; + vrLen = 2738; + vrLoc = 1110; + }; + DA6B26B510125A3700122FAE /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DA23B32C10090B3C00B5CECE /* XTransformation.cpp */; + name = "XTransformation.cpp: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1657; + vrLoc = 306; + }; + DA6B26FA101B748A00122FAE /* XMesh.cpp:461 */ = { + isa = PBXFileBreakpoint; + actions = ( + ); + breakpointStyle = 0; + continueAfterActions = 0; + countType = 0; + delayBeforeContinue = 0; + fileReference = DAE2B65410915168005ED940 /* XMesh.cpp */; + functionName = "XMesh::gl(XMaterialList& mats)"; + hitCount = 0; + ignoreCount = 0; + lineNumber = 461; + location = Loader; + modificationTime = 278186870.977044; + originalNumberOfMultipleMatches = 0; + state = 2; + }; + DA6B271C101B789600122FAE /* main.cpp:390 */ = { + isa = PBXFileBreakpoint; + actions = ( + ); + breakpointStyle = 0; + continueAfterActions = 0; + countType = 0; + delayBeforeContinue = 0; + fileReference = DA23B31210090B3C00B5CECE /* main.cpp */; + functionName = "SpecialKey(int key,int x,int y)"; + hitCount = 0; + ignoreCount = 0; + lineNumber = 390; + location = Loader; + modificationTime = 278186870.977716; + originalNumberOfMultipleMatches = 0; + state = 1; + }; + DA6D708E10096A7800A340F1 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DA23B6E010094ADF00B5CECE /* mm_malloc.h */; + name = "mm_malloc.h: 10"; + rLen = 0; + rLoc = 140; + rType = 0; + vrLen = 1661; + vrLoc = 744; + }; + DA6D70BC100A697200A340F1 /* PlistBookmark */ = { + isa = PlistBookmark; + fRef = DA23B30410090AC900B5CECE /* Loader-Info.plist */; + fallbackIsa = PBXBookmark; + isK = 0; + kPath = ( + ); + name = "/Users/junmura/Documents/character-system/Loader-Info.plist"; + rLen = 0; + rLoc = 2147483647; + }; + DA6D7118100A780C00A340F1 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DA23B31410090B3C00B5CECE /* XAnimation.cpp */; + name = "XAnimation.cpp: 35"; + rLen = 20; + rLoc = 1218; + rType = 0; + vrLen = 1884; + vrLoc = 0; + }; + DA80ECF310916FAC001A2D3B /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B64E10915168005ED940 /* XJointAnim.cpp */; + name = "XJointAnim.cpp: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1975; + vrLoc = 0; + }; + DA888A7E0FFEE2A800F645F7 /* Source Control */ = { + isa = PBXSourceControlManager; + fallbackIsa = XCSourceControlManager; + isSCMEnabled = 0; + scmConfiguration = { + repositoryName = "Character System"; + repositoryNamesForRoots = { + "" = "Character System"; + }; + }; + }; + DA888A7F0FFEE2A800F645F7 /* Code sense */ = { + isa = PBXCodeSenseManager; + indexTemplatePath = ""; + }; + DAE2B64E10915168005ED940 /* XJointAnim.cpp */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {922, 1547}}"; + sepNavSelRange = "{0, 0}"; + sepNavVisRange = "{0, 1970}"; + }; + }; + DAE2B65010915168005ED940 /* XMaterial.cpp */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {922, 1170}}"; + sepNavSelRange = "{0, 0}"; + sepNavVisRange = "{0, 1952}"; + }; + }; + DAE2B65410915168005ED940 /* XMesh.cpp */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {922, 7293}}"; + sepNavSelRange = "{11710, 0}"; + sepNavVisRange = "{11150, 1667}"; + }; + }; + DAE2B65A10915168005ED940 /* XSkeleton.cpp */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {922, 2483}}"; + sepNavSelRange = "{59, 0}"; + sepNavVisRange = "{3061, 754}"; + }; + }; + DAE2B65B10915168005ED940 /* XSkeleton.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {922, 857}}"; + sepNavSelRange = "{0, 0}"; + sepNavVisRange = "{0, 1853}"; + }; + }; + DAE2B65C10915168005ED940 /* XTextureFile.cpp */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {922, 2626}}"; + sepNavSelRange = "{4931, 0}"; + sepNavVisRange = "{0, 2303}"; + }; + }; + DAE2B65D10915168005ED940 /* XTextureFile.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {971, 2548}}"; + sepNavSelRange = "{1363, 0}"; + sepNavVisRange = "{1110, 2738}"; + sepNavWindowFrame = "{{106, 81}, {734, 1071}}"; + }; + }; + DAE2B68B109152D6005ED940 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B65410915168005ED940 /* XMesh.cpp */; + name = "XMesh.cpp: 451"; + rLen = 0; + rLoc = 11710; + rType = 0; + vrLen = 1667; + vrLoc = 11150; + }; + DAE2B7B510916408005ED940 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B64E10915168005ED940 /* XJointAnim.cpp */; + name = "XJointAnim.cpp: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1975; + vrLoc = 0; + }; +} diff --git a/Loader.xcodeproj/project.pbxproj b/Loader.xcodeproj/project.pbxproj new file mode 100644 index 000000000..c1d3a8350 --- /dev/null +++ b/Loader.xcodeproj/project.pbxproj @@ -0,0 +1,278 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 42; + objects = { + +/* Begin PBXBuildFile section */ + DAE2B66310915168005ED940 /* mm_malloc.h in Headers */ = {isa = PBXBuildFile; fileRef = DAE2B64410915168005ED940 /* mm_malloc.h */; }; + DAE2B66510915168005ED940 /* XAnimation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DAE2B64610915168005ED940 /* XAnimation.cpp */; }; + DAE2B66610915168005ED940 /* XAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = DAE2B64710915168005ED940 /* XAnimation.h */; }; + DAE2B66710915168005ED940 /* XBlendShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DAE2B64810915168005ED940 /* XBlendShape.cpp */; }; + DAE2B66810915168005ED940 /* XBlendShape.h in Headers */ = {isa = PBXBuildFile; fileRef = DAE2B64910915168005ED940 /* XBlendShape.h */; }; + DAE2B66910915168005ED940 /* XBlendShapeWeight.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DAE2B64A10915168005ED940 /* XBlendShapeWeight.cpp */; }; + DAE2B66A10915168005ED940 /* XBlendShapeWeight.h in Headers */ = {isa = PBXBuildFile; fileRef = DAE2B64B10915168005ED940 /* XBlendShapeWeight.h */; }; + DAE2B66D10915168005ED940 /* XJointAnim.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DAE2B64E10915168005ED940 /* XJointAnim.cpp */; }; + DAE2B66E10915168005ED940 /* XJointAnim.h in Headers */ = {isa = PBXBuildFile; fileRef = DAE2B64F10915168005ED940 /* XJointAnim.h */; }; + DAE2B66F10915168005ED940 /* XMaterial.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DAE2B65010915168005ED940 /* XMaterial.cpp */; }; + DAE2B67010915168005ED940 /* XMaterial.h in Headers */ = {isa = PBXBuildFile; fileRef = DAE2B65110915168005ED940 /* XMaterial.h */; }; + DAE2B67110915168005ED940 /* XMaterialGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DAE2B65210915168005ED940 /* XMaterialGroup.cpp */; }; + DAE2B67210915168005ED940 /* XMaterialGroup.h in Headers */ = {isa = PBXBuildFile; fileRef = DAE2B65310915168005ED940 /* XMaterialGroup.h */; }; + DAE2B67310915168005ED940 /* XMesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DAE2B65410915168005ED940 /* XMesh.cpp */; }; + DAE2B67410915168005ED940 /* XMesh.h in Headers */ = {isa = PBXBuildFile; fileRef = DAE2B65510915168005ED940 /* XMesh.h */; }; + DAE2B67510915168005ED940 /* XModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DAE2B65610915168005ED940 /* XModel.cpp */; }; + DAE2B67610915168005ED940 /* XModel.h in Headers */ = {isa = PBXBuildFile; fileRef = DAE2B65710915168005ED940 /* XModel.h */; }; + DAE2B67710915168005ED940 /* XOptions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DAE2B65810915168005ED940 /* XOptions.cpp */; }; + DAE2B67810915168005ED940 /* XOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = DAE2B65910915168005ED940 /* XOptions.h */; }; + DAE2B67910915168005ED940 /* XSkeleton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DAE2B65A10915168005ED940 /* XSkeleton.cpp */; }; + DAE2B67A10915168005ED940 /* XSkeleton.h in Headers */ = {isa = PBXBuildFile; fileRef = DAE2B65B10915168005ED940 /* XSkeleton.h */; }; + DAE2B67B10915168005ED940 /* XTextureFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DAE2B65C10915168005ED940 /* XTextureFile.cpp */; }; + DAE2B67C10915168005ED940 /* XTextureFile.h in Headers */ = {isa = PBXBuildFile; fileRef = DAE2B65D10915168005ED940 /* XTextureFile.h */; }; + DAE2B67D10915168005ED940 /* XTransformation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DAE2B65E10915168005ED940 /* XTransformation.cpp */; }; + DAE2B67E10915168005ED940 /* XTransformation.h in Headers */ = {isa = PBXBuildFile; fileRef = DAE2B65F10915168005ED940 /* XTransformation.h */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + DA23B30410090AC900B5CECE /* Loader-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Loader-Info.plist"; sourceTree = ""; }; + DA23B6701009428200B5CECE /* GLUT.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GLUT.framework; path = System/Library/Frameworks/GLUT.framework; sourceTree = SDKROOT; }; + DA23B6741009428C00B5CECE /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = System/Library/Frameworks/OpenGL.framework; sourceTree = SDKROOT; }; + DAE2B64410915168005ED940 /* mm_malloc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mm_malloc.h; path = Loader/mm_malloc.h; sourceTree = ""; }; + DAE2B64610915168005ED940 /* XAnimation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = XAnimation.cpp; path = Loader/XAnimation.cpp; sourceTree = ""; }; + DAE2B64710915168005ED940 /* XAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XAnimation.h; path = Loader/XAnimation.h; sourceTree = ""; }; + DAE2B64810915168005ED940 /* XBlendShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = XBlendShape.cpp; path = Loader/XBlendShape.cpp; sourceTree = ""; }; + DAE2B64910915168005ED940 /* XBlendShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XBlendShape.h; path = Loader/XBlendShape.h; sourceTree = ""; }; + DAE2B64A10915168005ED940 /* XBlendShapeWeight.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = XBlendShapeWeight.cpp; path = Loader/XBlendShapeWeight.cpp; sourceTree = ""; }; + DAE2B64B10915168005ED940 /* XBlendShapeWeight.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XBlendShapeWeight.h; path = Loader/XBlendShapeWeight.h; sourceTree = ""; }; + DAE2B64E10915168005ED940 /* XJointAnim.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = XJointAnim.cpp; path = Loader/XJointAnim.cpp; sourceTree = ""; }; + DAE2B64F10915168005ED940 /* XJointAnim.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XJointAnim.h; path = Loader/XJointAnim.h; sourceTree = ""; }; + DAE2B65010915168005ED940 /* XMaterial.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = XMaterial.cpp; path = Loader/XMaterial.cpp; sourceTree = ""; }; + DAE2B65110915168005ED940 /* XMaterial.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XMaterial.h; path = Loader/XMaterial.h; sourceTree = ""; }; + DAE2B65210915168005ED940 /* XMaterialGroup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = XMaterialGroup.cpp; path = Loader/XMaterialGroup.cpp; sourceTree = ""; }; + DAE2B65310915168005ED940 /* XMaterialGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XMaterialGroup.h; path = Loader/XMaterialGroup.h; sourceTree = ""; }; + DAE2B65410915168005ED940 /* XMesh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = XMesh.cpp; path = Loader/XMesh.cpp; sourceTree = ""; }; + DAE2B65510915168005ED940 /* XMesh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XMesh.h; path = Loader/XMesh.h; sourceTree = ""; }; + DAE2B65610915168005ED940 /* XModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = XModel.cpp; path = Loader/XModel.cpp; sourceTree = ""; }; + DAE2B65710915168005ED940 /* XModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XModel.h; path = Loader/XModel.h; sourceTree = ""; }; + DAE2B65810915168005ED940 /* XOptions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = XOptions.cpp; path = Loader/XOptions.cpp; sourceTree = ""; }; + DAE2B65910915168005ED940 /* XOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XOptions.h; path = Loader/XOptions.h; sourceTree = ""; }; + DAE2B65A10915168005ED940 /* XSkeleton.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = XSkeleton.cpp; path = Loader/XSkeleton.cpp; sourceTree = ""; }; + DAE2B65B10915168005ED940 /* XSkeleton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XSkeleton.h; path = Loader/XSkeleton.h; sourceTree = ""; }; + DAE2B65C10915168005ED940 /* XTextureFile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = XTextureFile.cpp; path = Loader/XTextureFile.cpp; sourceTree = ""; }; + DAE2B65D10915168005ED940 /* XTextureFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XTextureFile.h; path = Loader/XTextureFile.h; sourceTree = ""; }; + DAE2B65E10915168005ED940 /* XTransformation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = XTransformation.cpp; path = Loader/XTransformation.cpp; sourceTree = ""; }; + DAE2B65F10915168005ED940 /* XTransformation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XTransformation.h; path = Loader/XTransformation.h; sourceTree = ""; }; + DAE2B687109152BA005ED940 /* libSkin.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libSkin.a; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + DA1EC369108EE95500399BE5 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 5607DA2C07B19B9D00C2151B = { + isa = PBXGroup; + children = ( + DAE2B64410915168005ED940 /* mm_malloc.h */, + DAE2B64610915168005ED940 /* XAnimation.cpp */, + DAE2B64710915168005ED940 /* XAnimation.h */, + DAE2B64810915168005ED940 /* XBlendShape.cpp */, + DAE2B64910915168005ED940 /* XBlendShape.h */, + DAE2B64A10915168005ED940 /* XBlendShapeWeight.cpp */, + DAE2B64B10915168005ED940 /* XBlendShapeWeight.h */, + DAE2B64E10915168005ED940 /* XJointAnim.cpp */, + DAE2B64F10915168005ED940 /* XJointAnim.h */, + DAE2B65010915168005ED940 /* XMaterial.cpp */, + DAE2B65110915168005ED940 /* XMaterial.h */, + DAE2B65210915168005ED940 /* XMaterialGroup.cpp */, + DAE2B65310915168005ED940 /* XMaterialGroup.h */, + DAE2B65410915168005ED940 /* XMesh.cpp */, + DAE2B65510915168005ED940 /* XMesh.h */, + DAE2B65610915168005ED940 /* XModel.cpp */, + DAE2B65710915168005ED940 /* XModel.h */, + DAE2B65810915168005ED940 /* XOptions.cpp */, + DAE2B65910915168005ED940 /* XOptions.h */, + DAE2B65A10915168005ED940 /* XSkeleton.cpp */, + DAE2B65B10915168005ED940 /* XSkeleton.h */, + DAE2B65C10915168005ED940 /* XTextureFile.cpp */, + DAE2B65D10915168005ED940 /* XTextureFile.h */, + DAE2B65E10915168005ED940 /* XTransformation.cpp */, + DAE2B65F10915168005ED940 /* XTransformation.h */, + DA23B30410090AC900B5CECE /* Loader-Info.plist */, + DA23B6701009428200B5CECE /* GLUT.framework */, + DA23B6741009428C00B5CECE /* OpenGL.framework */, + DAE2B687109152BA005ED940 /* libSkin.a */, + ); + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + DA1EC367108EE95500399BE5 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + DAE2B66310915168005ED940 /* mm_malloc.h in Headers */, + DAE2B66610915168005ED940 /* XAnimation.h in Headers */, + DAE2B66810915168005ED940 /* XBlendShape.h in Headers */, + DAE2B66A10915168005ED940 /* XBlendShapeWeight.h in Headers */, + DAE2B66E10915168005ED940 /* XJointAnim.h in Headers */, + DAE2B67010915168005ED940 /* XMaterial.h in Headers */, + DAE2B67210915168005ED940 /* XMaterialGroup.h in Headers */, + DAE2B67410915168005ED940 /* XMesh.h in Headers */, + DAE2B67610915168005ED940 /* XModel.h in Headers */, + DAE2B67810915168005ED940 /* XOptions.h in Headers */, + DAE2B67A10915168005ED940 /* XSkeleton.h in Headers */, + DAE2B67C10915168005ED940 /* XTextureFile.h in Headers */, + DAE2B67E10915168005ED940 /* XTransformation.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + DA1EC36A108EE95500399BE5 /* Skin */ = { + isa = PBXNativeTarget; + buildConfigurationList = DA1EC37C108EE98900399BE5 /* Build configuration list for PBXNativeTarget "Skin" */; + buildPhases = ( + DA1EC367108EE95500399BE5 /* Headers */, + DA1EC368108EE95500399BE5 /* Sources */, + DA1EC369108EE95500399BE5 /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Skin; + productName = libSkin; + productReference = DAE2B687109152BA005ED940 /* libSkin.a */; + productType = "com.apple.product-type.library.static"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 5607DA3007B19B9D00C2151B /* Project object */ = { + isa = PBXProject; + buildConfigurationList = F0EC25C708BBC88F006E9215 /* Build configuration list for PBXProject "Loader" */; + compatibilityVersion = "Xcode 2.4"; + hasScannedForEncodings = 0; + mainGroup = 5607DA2C07B19B9D00C2151B; + productRefGroup = 5607DA2C07B19B9D00C2151B; + projectDirPath = ""; + projectRoot = ""; + targets = ( + DA1EC36A108EE95500399BE5 /* Skin */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + DA1EC368108EE95500399BE5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + DAE2B66510915168005ED940 /* XAnimation.cpp in Sources */, + DAE2B66710915168005ED940 /* XBlendShape.cpp in Sources */, + DAE2B66910915168005ED940 /* XBlendShapeWeight.cpp in Sources */, + DAE2B66D10915168005ED940 /* XJointAnim.cpp in Sources */, + DAE2B66F10915168005ED940 /* XMaterial.cpp in Sources */, + DAE2B67110915168005ED940 /* XMaterialGroup.cpp in Sources */, + DAE2B67310915168005ED940 /* XMesh.cpp in Sources */, + DAE2B67510915168005ED940 /* XModel.cpp in Sources */, + DAE2B67710915168005ED940 /* XOptions.cpp in Sources */, + DAE2B67910915168005ED940 /* XSkeleton.cpp in Sources */, + DAE2B67B10915168005ED940 /* XTextureFile.cpp in Sources */, + DAE2B67D10915168005ED940 /* XTransformation.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + DA1EC36C108EE95500399BE5 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(NATIVE_ARCH_ACTUAL)"; + COPY_PHASE_STRIP = NO; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + PREBINDING = NO; + PRODUCT_NAME = Skin; + }; + name = Debug; + }; + DA1EC36D108EE95500399BE5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(NATIVE_ARCH_ACTUAL)"; + COPY_PHASE_STRIP = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_ENABLE_FIX_AND_CONTINUE = NO; + PREBINDING = NO; + PRODUCT_NAME = Skin; + ZERO_LINK = NO; + }; + name = Release; + }; + F0EC25C808BBC88F006E9215 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(NATIVE_ARCH)"; + CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)"; + GCC_ENABLE_FIX_AND_CONTINUE = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = "vectormathlibrary/include/**"; + PREBINDING = NO; + SYMROOT = data2009; + ZERO_LINK = YES; + }; + name = Debug; + }; + F0EC25C908BBC88F006E9215 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(NATIVE_ARCH)"; + CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)"; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = "vectormathlibrary/include/**"; + PREBINDING = NO; + SYMROOT = data2009; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + DA1EC37C108EE98900399BE5 /* Build configuration list for PBXNativeTarget "Skin" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + DA1EC36C108EE95500399BE5 /* Debug */, + DA1EC36D108EE95500399BE5 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + F0EC25C708BBC88F006E9215 /* Build configuration list for PBXProject "Loader" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + F0EC25C808BBC88F006E9215 /* Debug */, + F0EC25C908BBC88F006E9215 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 5607DA3007B19B9D00C2151B /* Project object */; +} diff --git a/Loader/GLExtensions.cpp b/Loader/GLExtensions.cpp new file mode 100644 index 000000000..fea36ab28 --- /dev/null +++ b/Loader/GLExtensions.cpp @@ -0,0 +1,203 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#include "GLExtensions.h" +#include + +// Multi-texture functions +PFNGLACTIVETEXTUREPROC glActiveTexture = NULL; +PFNGLCLIENTACTIVETEXTUREPROC glClientActiveTexture = NULL; + +// VBO Extension Function Pointers +PFNGLGENBUFFERSPROC glGenBuffers = NULL; // VBO Name Generation Procedure +PFNGLBINDBUFFERPROC glBindBuffer = NULL; // VBO Bind Procedure +PFNGLBUFFERDATAPROC glBufferData = NULL; // VBO Data Loading Procedure +PFNGLDELETEBUFFERSPROC glDeleteBuffers = NULL; // VBO Deletion Procedure +PFNGLMAPBUFFERPROC glMapBuffer = NULL; +PFNGLUNMAPBUFFERPROC glUnmapBuffer = NULL; +PFNGLBUFFERSUBDATAPROC glBufferSubData = NULL; + +// _texture_compression +PFNGLCOMPRESSEDTEXIMAGE2DPROC glCompressedTexImage2D = NULL; + +// EXT_framebuffer_object - http://oss.sgi.com/projects/ogl-sample/registry/EXT/framebuffer_object.txt +PFNGLISRENDERBUFFEREXTPROC glIsRenderbufferEXT = NULL; +PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT = NULL; +PFNGLDELETERENDERBUFFERSEXTPROC glDeleteRenderbuffersEXT = NULL; +PFNGLGENRENDERBUFFERSEXTPROC glGenRenderbuffersEXT = NULL; +PFNGLRENDERBUFFERSTORAGEEXTPROC glRenderbufferStorageEXT = NULL; +PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC glGetRenderbufferParameterivEXT = NULL; +PFNGLISFRAMEBUFFEREXTPROC glIsFramebufferEXT = NULL; +PFNGLBINDFRAMEBUFFEREXTPROC glBindFramebufferEXT = NULL; +PFNGLDELETEFRAMEBUFFERSEXTPROC glDeleteFramebuffersEXT = NULL; +PFNGLGENFRAMEBUFFERSEXTPROC glGenFramebuffersEXT = NULL; +PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glCheckFramebufferStatusEXT = NULL; +PFNGLFRAMEBUFFERTEXTURE1DEXTPROC glFramebufferTexture1DEXT = NULL; +PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glFramebufferTexture2DEXT = NULL; +PFNGLFRAMEBUFFERTEXTURE3DEXTPROC glFramebufferTexture3DEXT = NULL; +PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC glFramebufferRenderbufferEXT = NULL; +PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC glGetFramebufferAttachmentParameterivEXT = NULL; +PFNGLGENERATEMIPMAPEXTPROC glGenerateMipmapEXT = NULL; + +// wgl +PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT = NULL; +PFNWGLGETSWAPINTERVALEXTPROC wglGetSwapIntervalEXT = NULL; + +bool initGLExtensions(){ + // Initialize OpenGL extension function pointers + + // Multi-texture + glActiveTexture = (PFNGLACTIVETEXTUREPROC) wglGetProcAddress("glActiveTexture"); + glClientActiveTexture = (PFNGLACTIVETEXTUREPROC) wglGetProcAddress("glClientActiveTexture"); + + // VBO + glGenBuffers = (PFNGLGENBUFFERSPROC) wglGetProcAddress("glGenBuffers"); + glBindBuffer = (PFNGLBINDBUFFERPROC) wglGetProcAddress("glBindBuffer"); + glBufferData = (PFNGLBUFFERDATAPROC) wglGetProcAddress("glBufferData"); + glDeleteBuffers = (PFNGLDELETEBUFFERSPROC) wglGetProcAddress("glDeleteBuffers"); + glMapBuffer = (PFNGLMAPBUFFERPROC) wglGetProcAddress("glMapBuffer"); + glUnmapBuffer = (PFNGLUNMAPBUFFERPROC) wglGetProcAddress("glUnmapBuffer"); + glBufferSubData = (PFNGLBUFFERSUBDATAPROC) wglGetProcAddress("glBufferSubData"); + + // Texture compression + glCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC)wglGetProcAddress("glCompressedTexImage2D"); + + // Here we make sure that the functions were loaded properly + if ( + // Multi-texture + !glActiveTexture || + !glClientActiveTexture || + // VBO + !glGenBuffers || + !glBindBuffer || + !glBufferData || + !glDeleteBuffers || + !glBufferSubData || + // Texture Compression + !glCompressedTexImage2D + ) + { + return false; + } + + // + // EXT_framebuffer_object + // + + char *ext = (char*)glGetString( GL_EXTENSIONS ); + + if( strstr( ext, "EXT_framebuffer_object" ) == NULL ) + { + MessageBox(NULL,"EXT_framebuffer_object extension was not found", + "ERROR",MB_OK|MB_ICONEXCLAMATION); + exit(-1); + } + else + { + glIsRenderbufferEXT = (PFNGLISRENDERBUFFEREXTPROC)wglGetProcAddress("glIsRenderbufferEXT"); + glBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC)wglGetProcAddress("glBindRenderbufferEXT"); + glDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC)wglGetProcAddress("glDeleteRenderbuffersEXT"); + glGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC)wglGetProcAddress("glGenRenderbuffersEXT"); + glRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC)wglGetProcAddress("glRenderbufferStorageEXT"); + glGetRenderbufferParameterivEXT = (PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC)wglGetProcAddress("glGetRenderbufferParameterivEXT"); + glIsFramebufferEXT = (PFNGLISFRAMEBUFFEREXTPROC)wglGetProcAddress("glIsFramebufferEXT"); + glBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC)wglGetProcAddress("glBindFramebufferEXT"); + glDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC)wglGetProcAddress("glDeleteFramebuffersEXT"); + glGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC)wglGetProcAddress("glGenFramebuffersEXT"); + glCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)wglGetProcAddress("glCheckFramebufferStatusEXT"); + glFramebufferTexture1DEXT = (PFNGLFRAMEBUFFERTEXTURE1DEXTPROC)wglGetProcAddress("glFramebufferTexture1DEXT"); + glFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC)wglGetProcAddress("glFramebufferTexture2DEXT"); + glFramebufferTexture3DEXT = (PFNGLFRAMEBUFFERTEXTURE3DEXTPROC)wglGetProcAddress("glFramebufferTexture3DEXT"); + glFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC)wglGetProcAddress("glFramebufferRenderbufferEXT"); + glGetFramebufferAttachmentParameterivEXT = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC)wglGetProcAddress("glGetFramebufferAttachmentParameterivEXT"); + glGenerateMipmapEXT = (PFNGLGENERATEMIPMAPEXTPROC)wglGetProcAddress("glGenerateMipmapEXT"); + + if( !glIsRenderbufferEXT || !glBindRenderbufferEXT || !glDeleteRenderbuffersEXT || + !glGenRenderbuffersEXT || !glRenderbufferStorageEXT || !glGetRenderbufferParameterivEXT || + !glIsFramebufferEXT || !glBindFramebufferEXT || !glDeleteFramebuffersEXT || + !glGenFramebuffersEXT || !glCheckFramebufferStatusEXT || !glFramebufferTexture1DEXT || + !glFramebufferTexture2DEXT || !glFramebufferTexture3DEXT || !glFramebufferRenderbufferEXT|| + !glGetFramebufferAttachmentParameterivEXT || !glGenerateMipmapEXT ) + { + MessageBox(NULL,"One or more EXT_framebuffer_object functions were not found", + "ERROR",MB_OK|MB_ICONEXCLAMATION); + exit(-1); + } + } + + InitVSync(); + + return true; +} + +//from NeHe Lesson 45 +bool IsExtensionSupported( char* szTargetExtension ) +{ + const unsigned char *pszExtensions = NULL; + const unsigned char *pszStart; + unsigned char *pszWhere, *pszTerminator; + + // Extension names should not have spaces + pszWhere = (unsigned char *) strchr( szTargetExtension, ' ' ); + if( pszWhere || *szTargetExtension == '\0' ) + return false; + + // Get Extensions String + pszExtensions = glGetString( GL_EXTENSIONS ); + + // Search The Extensions String For An Exact Copy + pszStart = pszExtensions; + for(;;) + { + pszWhere = (unsigned char *) strstr( (const char *) pszStart, szTargetExtension ); + if( !pszWhere ) + break; + pszTerminator = pszWhere + strlen( szTargetExtension ); + if( pszWhere == pszStart || *( pszWhere - 1 ) == ' ' ) + if( *pszTerminator == ' ' || *pszTerminator == '\0' ) + return true; + pszStart = pszTerminator; + } + return false; +} + +bool InitVSync() +{ + if (IsExtensionSupported("WGL_EXT_swap_control")) + { + wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC) + wglGetProcAddress("wglSwapIntervalEXT"); + wglGetSwapIntervalEXT = (PFNWGLGETSWAPINTERVALEXTPROC) + wglGetProcAddress("wglGetSwapIntervalEXT"); + return true; + } + return false;// WGL_EXT_swap_control not supported +} + +bool SetVSync(bool VSync) +{ + if(!wglSwapIntervalEXT) return false; + wglSwapIntervalEXT(VSync); + return true; +} + +bool GetVSync(bool* VSync) +{ + if(!wglGetSwapIntervalEXT) return false;//VSynce value is not valid... + *VSync = wglGetSwapIntervalEXT() == 0 ? false : true; + return true; +} + diff --git a/Loader/GLExtensions.h b/Loader/GLExtensions.h new file mode 100644 index 000000000..65a905f81 --- /dev/null +++ b/Loader/GLExtensions.h @@ -0,0 +1,91 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef GLEXTENSIONS_H +#define GLEXTENSIONS_H + +#ifdef WIN32 + +#define _WINSOCKAPI_ + +#include +#include +#include +#include "GL/glext.h" +#include "wglext.h" + +// Multi-texture +typedef void (APIENTRY * PFNGLACTIVETEXTUREPROC) (GLenum target); +typedef void (APIENTRY * PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); + +// VBO Extension Definitions, From glext.h +typedef void (APIENTRY * PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRY * PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRY * PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); +//typedef void (APIENTRY * PFNGLBUFFERDATAPROC) (GLenum target, int size, const GLvoid *data, GLenum usage); + + +// Multi-texture +extern PFNGLACTIVETEXTUREPROC glActiveTexture; +extern PFNGLCLIENTACTIVETEXTUREPROC glClientActiveTexture; + +// VBO Extension Function Pointers +extern PFNGLGENBUFFERSPROC glGenBuffers; // VBO Name Generation Procedure +extern PFNGLBINDBUFFERPROC glBindBuffer; // VBO Bind Procedure +extern PFNGLBUFFERDATAPROC glBufferData; // VBO Data Loading Procedure +extern PFNGLDELETEBUFFERSPROC glDeleteBuffers; // VBO Deletion Procedure +extern PFNGLMAPBUFFERPROC glMapBuffer; +extern PFNGLUNMAPBUFFERPROC glUnmapBuffer; +extern PFNGLBUFFERSUBDATAPROC glBufferSubData; + +// ARB_texture_compression +extern PFNGLCOMPRESSEDTEXIMAGE2DPROC glCompressedTexImage2D; + +// EXT_framebuffer_object - http://oss.sgi.com/projects/ogl-sample/registry/EXT/framebuffer_object.txt +extern PFNGLISRENDERBUFFEREXTPROC glIsRenderbufferEXT; +extern PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT; +extern PFNGLDELETERENDERBUFFERSEXTPROC glDeleteRenderbuffersEXT; +extern PFNGLGENRENDERBUFFERSEXTPROC glGenRenderbuffersEXT; +extern PFNGLRENDERBUFFERSTORAGEEXTPROC glRenderbufferStorageEXT; +extern PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC glGetRenderbufferParameterivEXT; +extern PFNGLISFRAMEBUFFEREXTPROC glIsFramebufferEXT; +extern PFNGLBINDFRAMEBUFFEREXTPROC glBindFramebufferEXT; +extern PFNGLDELETEFRAMEBUFFERSEXTPROC glDeleteFramebuffersEXT; +extern PFNGLGENFRAMEBUFFERSEXTPROC glGenFramebuffersEXT; +extern PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glCheckFramebufferStatusEXT; +extern PFNGLFRAMEBUFFERTEXTURE1DEXTPROC glFramebufferTexture1DEXT; +extern PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glFramebufferTexture2DEXT; +extern PFNGLFRAMEBUFFERTEXTURE3DEXTPROC glFramebufferTexture3DEXT; +extern PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC glFramebufferRenderbufferEXT; +extern PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC glGetFramebufferAttachmentParameterivEXT; +extern PFNGLGENERATEMIPMAPEXTPROC glGenerateMipmapEXT; + +// wgl +extern PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT; +extern PFNWGLGETSWAPINTERVALEXTPROC wglGetSwapIntervalEXT; + +bool initGLExtensions(); + +// VSYNC +bool InitVSync(); +bool SetVSync(bool VSync); +bool GetVSync(bool* VSync); + +#else +#include +#endif + +#endif \ No newline at end of file diff --git a/Loader/I16Aligned.h b/Loader/I16Aligned.h new file mode 100644 index 000000000..59d9aa633 --- /dev/null +++ b/Loader/I16Aligned.h @@ -0,0 +1,80 @@ +#pragma once + +#ifdef WIN32 +#include +// http://www.gamedev.net/community/forums/topic.asp?topic_id=382642 +class CMemSpaceA16 +{ +public: + // new. dual with ReleaseMemSpaceA16(); + static BYTE* GetMemSpaceA16(size_t size) + { + BYTE *p = ::new BYTE[size + 16]; + if (p) + { + BYTE offset = (BYTE)(16 - ((unsigned long long)p & 15)); + p += offset; + p[-1] = offset; + } + return p; + }; + // delete. dual with GetMemSpaceA16(); + static void ReleaseMemSpaceA16( BYTE* p ) + { + if(p) { + p -= p[-1]; + ::delete [] p; + } + }; +}; + +//--------------------------------------------------------------------- +/////////////////////////////////////////////////////////////////////// +// I16Aligned - 16 byte aligned classes +// just public inherit from this and job done ;) +/////////////////////////////////////////////////////////////////////// +//--------------------------------------------------------------------- + +class I16Aligned +{ +public: + void* operator new(size_t size) + { + return static_cast( CMemSpaceA16::GetMemSpaceA16(size) ); + }; + void* operator new[](size_t size) + { + return static_cast( CMemSpaceA16::GetMemSpaceA16(size) ); + }; + + void operator delete(void* p) + { + BYTE* pb = static_cast(p); + CMemSpaceA16::ReleaseMemSpaceA16(pb); + }; + void operator delete[](void* p) + { + BYTE* pb = static_cast(p); + CMemSpaceA16::ReleaseMemSpaceA16(pb); + }; + + ///////////////////////////////////////////////////////// + // Placement version (fake). + ///////////////////////////////////////////////////////// + + void* operator new(size_t /*size*/, void* ptrPlacement) + { return ptrPlacement; }; + void operator delete(void* /*ptr*/, void* /*ptrPlacement*/) + { return; }; + + void* operator new[](size_t /*size*/, void* ptrPlacement) + { return ptrPlacement; }; + void operator delete[](void* /*ptr*/, void* /*ptrPlacement*/) + { return; }; +}; + +#else +class I16Aligned +{ +}; +#endif diff --git a/Loader/Loader.vcproj b/Loader/Loader.vcproj new file mode 100644 index 000000000..ec53f39ce --- /dev/null +++ b/Loader/Loader.vcproj @@ -0,0 +1,522 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Loader/XAnimation.cpp b/Loader/XAnimation.cpp new file mode 100644 index 000000000..fa7324275 --- /dev/null +++ b/Loader/XAnimation.cpp @@ -0,0 +1,87 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#include "XAnimation.h" + +XAnimation::XAnimation(void) +{ + m_NumBlendShapes = 0; +} + +XAnimation::~XAnimation(void) +{ + // delete all blendshapes + for(XItBlendShape it = m_BlendShapes.begin(); it < m_BlendShapes.end(); it++) + { + delete *it; + } +} + +std::istream& operator >> (std::istream& ifs, XAnimation &anim) +{ + char buffer[256]; + int num_frames=0; + float fStart,fEnd; + + ifs >> buffer; + anim.m_AnimName = buffer; + + // get start and end times + ifs >> buffer >> fStart; + ifs >> buffer >> fEnd; + ifs >> buffer >> num_frames; + + // set the timing info for the cycle + anim.m_Time.Initialise(fStart,fEnd,num_frames); + + ifs >> buffer >> anim.m_NumBlendShapes; + + // read in blendshapes + for ( int i = 0; i < anim.m_NumBlendShapes; i++ ) + { + XBlendShape* bs = new XBlendShape(&anim.m_Time); + ifs >> *bs; + anim.m_BlendShapes.push_back(bs); + } + + anim.m_JointAnim.m_NumFrames = num_frames; + ifs >> buffer; assert( strcmp( buffer, "JOINTANIM" ) == 0 ); + ifs >> anim.m_JointAnim; + + return ifs; +} + +void XAnimation::Update(float dt) +{ + m_Time.Update(dt); + updateBlendShapes(); +} + +void XAnimation::updateBlendShapes(void) +{ + // update blendshaped weights + //for( XItBlendShape it = m_BlendShapes.begin(); it != m_BlendShapes.end() ; ++it ) + for ( int j = 0; j < m_NumBlendShapes; j++ ) + { + XBlendShape *bs = m_BlendShapes[j];//*it; + bs->updateWeights(); + } +} + +void XAnimation::updateSkeleton(XSkeleton& skeleton) +{ + m_JointAnim.updateJointXforms( m_Time, skeleton ); +} diff --git a/Loader/XAnimation.h b/Loader/XAnimation.h new file mode 100644 index 000000000..9ab1b7a3a --- /dev/null +++ b/Loader/XAnimation.h @@ -0,0 +1,52 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#pragma once + +#include "../SharedStructures.h" + +#include "XBlendShape.h" +#include "XJointAnim.h" + +typedef std::vector< XBlendShape* > XBlendShapes; +typedef XBlendShapes::iterator XItBlendShape; + +class XAnimation : SAnimation +{ + friend std::istream& operator >> (std::istream& ifs, XAnimation &anim); + +public: + std::string m_AnimName; + XTimeInfo m_Time; + + int m_NumBlendShapes; + XBlendShapes m_BlendShapes; + XJointAnim m_JointAnim; + + + XAnimation(void); + ~XAnimation(void); + + // update time + void Update(float dt); + + // update blendshaped meshes + void updateBlendShapes(void); + + // update transformations of skeleton + void updateSkeleton(XSkeleton& skeleton); + +}; diff --git a/Loader/XBlendShape.cpp b/Loader/XBlendShape.cpp new file mode 100644 index 000000000..e8d10008b --- /dev/null +++ b/Loader/XBlendShape.cpp @@ -0,0 +1,55 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#include +#include "XBlendShape.h" + +XBlendShape::XBlendShape(XTimeInfo* timeInfo) + : m_Weight(timeInfo) +{ +} + +XBlendShape::~XBlendShape(void) +{ +} + +std::istream &operator>>(std::istream& ifs,XBlendShape& bs) +{ + char buffer[256]; + + ifs >> buffer; assert( strcmp(buffer, "BLENDSHAPE") == 0 ); + // read BLENDSHAPE name + ifs >> buffer; + bs.m_Name = buffer; + + // read base object + ifs >> buffer; assert( strcmp(buffer, "Base") == 0 ); + ifs >> buffer; + bs.m_BaseName = buffer; + ifs >> buffer; assert( strcmp(buffer, "id=") == 0 ); + //ifs >> bs.m_ID; + ifs >> bs.baseMeshID; + + // read weights + ifs >> bs.m_Weight; + + return ifs; +} + +void XBlendShape::updateWeights() +{ + m_Weight.getCurrentWeight( m_pTheMesh->m_BlendWeights ); +} diff --git a/Loader/XBlendShape.h b/Loader/XBlendShape.h new file mode 100644 index 000000000..0a8074f7b --- /dev/null +++ b/Loader/XBlendShape.h @@ -0,0 +1,49 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#pragma once + +#ifdef WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#endif + +#include +#include +#include +#include + +#include "XBlendShapeWeight.h" +#include "XMesh.h" + +class XBlendShape : public SBlendAnim +{ + friend std::istream &operator>>(std::istream&,XBlendShape&); + +public: + XBlendShape(XTimeInfo* timeInfo); + ~XBlendShape(void); + + void updateWeights(); // runtime + + std::string m_Name; + std::string m_BaseName; // Assuming one base object for now + XBlendShapeWeight m_Weight; + + // actual connection to the base mesh + XMesh *m_pTheMesh; + +}; diff --git a/Loader/XBlendShapeWeight.cpp b/Loader/XBlendShapeWeight.cpp new file mode 100644 index 000000000..9c5b3e22b --- /dev/null +++ b/Loader/XBlendShapeWeight.cpp @@ -0,0 +1,87 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#include + +#include "XBlendShapeWeight.h" + +#ifdef WIN32 +#else +#include "mm_malloc.h" +#endif + +XBlendShapeWeight::XBlendShapeWeight(XTimeInfo* timeInfo) +{ + m_TimeInfo = timeInfo; + m_Weights = NULL; +} + +XBlendShapeWeight::~XBlendShapeWeight(void) +{ + if (m_Weights) + //delete [] m_Weights; + _mm_free( m_Weights ); +} + +std::istream &operator>>(std::istream& ifs,XBlendShapeWeight& w) +{ + char buffer[256]; + + ifs >> buffer; assert( strcmp(buffer, "NumWeights") == 0 ); + ifs >> w.m_NumWeights; + + w.m_NumFrames = w.m_TimeInfo->m_iNumFrames; + w.m_Weights = (float*)_mm_malloc( sizeof(float)*w.m_NumWeights*w.m_NumFrames, 16 ); + for ( unsigned int i = 0; i < w.m_NumFrames; i++ ) + { + for ( unsigned int j = 0; j < w.m_NumWeights; j++ ) + { + ifs >> w.m_Weights[ i * w.m_NumWeights + j ]; + } + } + + return ifs; +} + +void XBlendShapeWeight::getCurrentWeight( float *weights ) +{ + unsigned int frame = m_TimeInfo->GetFrameNum(); + + assert( frame >= 0 ); + + if (frame < m_NumFrames - 1) + { + // linear interpolation of frame and frame+1 + float frameTime = m_TimeInfo->GetFrameT(); + assert( frameTime > 0 && frameTime < 1 ); + float oneMinusF = 1.0f - frameTime; + + for ( unsigned int i = 0; i < m_NumWeights; i++ ) + { + float w0 = m_Weights[ frame * m_NumWeights + i ]; + float w1 = m_Weights[ (frame+1) * m_NumWeights + i ]; + + weights[ i ] = w1 * frameTime + w0 * oneMinusF; + } + } + else + { + for ( unsigned int i = 0; i < m_NumWeights; i++ ) + { + weights[ i ] = m_Weights[ frame * m_NumWeights + i ]; + } + } +} diff --git a/Loader/XBlendShapeWeight.h b/Loader/XBlendShapeWeight.h new file mode 100644 index 000000000..547d2588a --- /dev/null +++ b/Loader/XBlendShapeWeight.h @@ -0,0 +1,46 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#pragma once + +#ifdef WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#endif + +#include +#include +#include + +#include "XMesh.h" + +class XBlendShapeWeight : public SBlendAnim +{ + friend std::istream &operator>>(std::istream&,XBlendShapeWeight&); + +public: + XBlendShapeWeight(XTimeInfo* timeInfo); + ~XBlendShapeWeight(void); + + // animation data + unsigned int m_NumFrames; + unsigned int m_NumWeights; + float* m_Weights; + + XTimeInfo* m_TimeInfo; // runtime + + void getCurrentWeight( float *weights ); +}; diff --git a/Loader/XCgFX.cpp b/Loader/XCgFX.cpp new file mode 100644 index 000000000..c1eff4fbc --- /dev/null +++ b/Loader/XCgFX.cpp @@ -0,0 +1,431 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#include + +#include "XCgFX.h" + +XCgFX::XCgFX(void) +{ + for ( int i = 0; i < m_ProgramNum; i++ ) + { + m_CgEffects[i] = NULL; + + for ( int j = 0; j < m_TechniqueNum; j++ ) + { + m_CgTechniques[i][j] = NULL; + } + + WorldInverseTranspose[i] = NULL; + WorldViewProjection[i] = NULL; + World[i] = NULL; + //ViewInverse[i] = NULL; + + Lamp0Pos[i] = NULL; + Lamp0Color[i] = NULL; + AmbiColor[i] = NULL; + + m_Ambient[i] = NULL; + m_Diffuse[i] = NULL; + m_Specular[i] = NULL; + m_Emission[i] = NULL; + m_Transparency[i] = NULL; + m_Shininess[i] = NULL; + + Ks[i] = NULL; + Eccentricity[i] = NULL; + + m_CurrentPasses[i] = NULL; + } +} + +XCgFX::~XCgFX(void) +{ +} + +int XCgFX::getProgramID( string name ) +{ + for ( int i = 0; i < m_ProgramNum; i++ ) + if ( m_ProgramNames[i].compare( name ) == 0 ) + return i; + assert(0); + return -1; +} + +int XCgFX::getTechniqueID(string techniqueName) +{ + for ( int i = 0; i < m_TechniqueNum; i++ ) + if ( m_TechniqueNames[i].compare( techniqueName ) == 0 ) + return i; + assert(0); + return -1; +} + + +void XCgFX::initCg(void) +{ + m_CgContext = cgCreateContext(); + checkForCgError("creating context"); + +#ifdef CG_DEFERRED_PARAMETER_SETTING + // this is not in older Cg + cgGLSetDebugMode( CG_FALSE ); + cgSetParameterSettingMode(m_CgContext, CG_DEFERRED_PARAMETER_SETTING); +#endif + + cgGLRegisterStates(m_CgContext); + checkForCgError("registering standard CgFX states"); + cgGLSetManageTextureParameters(m_CgContext, CG_TRUE); + checkForCgError("manage texture parameters"); + + for ( int i = 0; i < m_ProgramNum; i++ ) + { + string filePath( m_ProgramDir ); + filePath += m_ProgramNames[i]; + filePath += ".cgfx"; + + m_CgEffects[i] = cgCreateEffectFromFile(m_CgContext, filePath.c_str(), NULL); + checkForCgError("creating cgfx effect", m_ProgramNames[i].c_str()); + assert(m_CgEffects[i]); + + // initialize techniques + for ( int j = 0; j < m_TechniqueNum; j++ ) + { + m_CgTechniques[i][j] = cgGetNamedTechnique( m_CgEffects[i], m_TechniqueNames[j].c_str() ); + if (m_CgTechniques[i][j] && cgValidateTechnique(m_CgTechniques[i][j]) == CG_FALSE) + { + fprintf(stderr, "%s: Main Technique %s did not validate.\n", m_ProgramNames[i].c_str(), cgGetTechniqueName(m_CgTechniques[i][j])); + assert(0); exit(1); + } + //fprintf(stderr, "%s: Use Main technique %s.\n", m_ProgramNames[i].c_str(), cgGetTechniqueName(m_CgTechniques[i][j])); + } + + // initialize matrix parameters + WorldInverseTranspose[i] = + cgGetEffectParameterBySemantic(m_CgEffects[i], "WorldInverseTranspose");//"ModelViewProjection"); + WorldViewProjection[i] = + cgGetEffectParameterBySemantic(m_CgEffects[i], "WorldViewProjection");//"ModelViewProjection"); + World[i] = + cgGetEffectParameterBySemantic(m_CgEffects[i], "World");//"ModelViewProjection"); + //ViewInverse[i] = + // cgGetEffectParameterBySemantic(m_CgEffects[i], "ViewInverse");//"ModelViewProjection"); + + // initialize light parameters + Lamp0Pos[i] = + cgGetNamedEffectParameter(m_CgEffects[i], "Lamp0Pos"); + Lamp0Color[i] = + cgGetNamedEffectParameter(m_CgEffects[i], "Lamp0Color"); + AmbiColor[i] = + cgGetNamedEffectParameter(m_CgEffects[i], "AmbiColor"); + + // initialize material parameters + m_Ambient[i] = + cgGetNamedEffectParameter(m_CgEffects[i], "m_Ambient"); + m_Diffuse[i] = + cgGetNamedEffectParameter(m_CgEffects[i], "m_Diffuse"); + m_Specular[i] = + cgGetNamedEffectParameter(m_CgEffects[i], "m_Specular"); + m_Emission[i] = + cgGetNamedEffectParameter(m_CgEffects[i], "m_Emission"); + m_Transparency[i] = + cgGetNamedEffectParameter(m_CgEffects[i], "m_Transparency"); + m_Shininess[i] = + cgGetNamedEffectParameter(m_CgEffects[i], "m_Shininess"); + + // blinn specific materlials + Ks[i] = + cgGetNamedEffectParameter(m_CgEffects[i], "Ks"); + Eccentricity[i] = + cgGetNamedEffectParameter(m_CgEffects[i], "Eccentricity"); +#ifdef _DEBUG + // report unfound params + if (!WorldInverseTranspose[i]) { + fprintf(stderr, + "%s: must find parameter with WorldInverseTranspose semantic\n", + m_ProgramNames[i].c_str()); + //exit(1); + } + if (!WorldViewProjection[i]) { + fprintf(stderr, + "%s: must find parameter with WorldViewProjection semantic\n", + m_ProgramNames[i].c_str()); + //exit(1); + } + if (!World[i]) { + fprintf(stderr, + "%s: must find parameter with World semantic\n", + m_ProgramNames[i].c_str()); + //exit(1); + } + //if (!ViewInverse[i]) { + // fprintf(stderr, + // "%s: must find parameter with ViewInverse semantic\n", + // m_ProgramNames[i].c_str()); + // //exit(1); + //} + if (!Lamp0Pos[i]) { + fprintf(stderr, "%s: must find parameter named Lamp0Pos\n", + m_ProgramNames[i].c_str()); + //exit(1); + } + if (!Lamp0Color[i]) { + fprintf(stderr, "%s: must find parameter named Lamp0Color\n", + m_ProgramNames[i].c_str()); + //exit(1); + } + if (!AmbiColor[i]) { + fprintf(stderr, "%s: must find parameter named AmbiColor\n", + m_ProgramNames[i].c_str()); + //exit(1); + } + if (!m_Ambient[i]) { + fprintf(stderr, "%s: must find parameter named m_Ambient\n", + m_ProgramNames[i].c_str()); + //exit(1); + } + if (!m_Diffuse[i]) { + fprintf(stderr, "%s: must find parameter named m_Diffuse\n", + m_ProgramNames[i].c_str()); + //exit(1); + } + if (!m_Specular[i]) { + fprintf(stderr, "%s: must find parameter named m_Specular\n", + m_ProgramNames[i].c_str()); + //exit(1); + } + if (!m_Emission[i]) { + fprintf(stderr, "%s: must find parameter named m_Emission\n", + m_ProgramNames[i].c_str()); + //exit(1); + } + if (!m_Transparency[i]) { + fprintf(stderr, "%s: must find parameter named m_Transparency\n", + m_ProgramNames[i].c_str()); + //exit(1); + } + if (!m_Shininess[i]) { + fprintf(stderr, "%s: must find parameter named m_Shininess\n", + m_ProgramNames[i].c_str()); + //exit(1); + } + if (!Ks[i]) { + fprintf(stderr, "%s: must find parameter named Ks\n", + m_ProgramNames[i].c_str()); + //exit(1); + } + if (!Eccentricity[i]) { + fprintf(stderr, "%s: must find parameter named Eccentricity\n", + m_ProgramNames[i].c_str()); + //exit(1); + } +#endif + } + +} + +void XCgFX::checkForCgError(const char * situation, const char* m_ProgramName) +{ + CGerror error; + const char *string = cgGetLastErrorString(&error); + + if (error != CG_NO_ERROR) { + if (error == CG_COMPILER_ERROR) { + fprintf(stderr, + "Program: %s\n" + "Situation: %s\n" + "Error: %s\n\n" + "Cg compiler output...\n%s", + m_ProgramName, situation, string, + cgGetLastListing(m_CgContext)); + } else { + fprintf(stderr, + "Program: %s\n" + "Situation: %s\n" + "Error: %s", + m_ProgramName, situation, string); + } + exit(1); + } +} + + +void XCgFX::setCurrentPass(string programName, const CGtechnique &tech) +{ + int progID = getProgramID( programName ); + if ( !m_CurrentPasses[ progID ] ) + m_CurrentPasses[ progID ] = cgGetFirstPass( tech ); + cgSetPassState( m_CurrentPasses[ progID ] ); +} + +bool XCgFX::resetCurrentPass(string programName) +{ + int progID = getProgramID( programName ); + cgResetPassState(m_CurrentPasses[ progID ]); + m_CurrentPasses[ progID ] = cgGetNextPass(m_CurrentPasses[ progID ]); + return m_CurrentPasses[ progID ] ? true : false; +} + + +void XCgFX::updateGLstates(string programName) +{ + int progID = getProgramID( programName ); + /* Set Cg parameters for the technique's effect. */ + // Object -> World -> View -> Projection + cgGLSetStateMatrixParameter( + WorldInverseTranspose[progID], + CG_GL_MODELVIEW_MATRIX, + CG_GL_MATRIX_INVERSE_TRANSPOSE ); + cgGLSetStateMatrixParameter( + WorldViewProjection[progID], + CG_GL_MODELVIEW_PROJECTION_MATRIX, + CG_GL_MATRIX_IDENTITY ); + cgGLSetStateMatrixParameter( + World[progID], + CG_GL_MODELVIEW_MATRIX , + CG_GL_MATRIX_IDENTITY ); + //cgGLSetStateMatrixParameter( + // ViewInverse[progID], + // CG_GL_PROJECTION_MATRIX , + // CG_GL_MATRIX_INVERSE ); + +} + +void XCgFX::useSamplerParameter(string programName, const char *paramName, GLuint texobj) +{ + int progID = getProgramID( programName ); + CGparameter param = cgGetNamedEffectParameter(m_CgEffects[progID], paramName); + + if (!param) { + fprintf(stderr, "%s: expected effect parameter named %s\n", programName.c_str(), paramName); + assert(0); + exit(1); + } + cgGLSetTextureParameter(param, texobj); + //cgSetSamplerState(param); +} + +void XCgFX::bindMaterial(XMaterial* material) +{ + string programName; + switch( material->m_MaterialType ) + { + case MATERIAL_PHONG: + programName = "Phong"; + break; + case MATERIAL_LAMBERT: + programName = "Lambert"; + break; + case MATERIAL_BLINN: + programName = "Blinn"; + break; + default: + programName = "simple"; + break; + } + + updateGLstates( programName ); + + string techniqueName = "No_Texture"; + // set texture + unsigned int diffuseTex = material->m_Diffuse.m_TextureObject; + if ( diffuseTex != 0 ) { + useSamplerParameter( programName, "ColorSampler", material->m_Diffuse.m_TextureObject); + techniqueName = "Main"; + } + if ( material->m_Specular.m_TextureObject != 0 ) { + useSamplerParameter( programName, "SpecularSampler", material->m_Specular.m_TextureObject); + techniqueName += "_Specular"; + } + unsigned int transpTex = material->m_Transparency.m_TextureObject; + if ( transpTex != 0 && transpTex != diffuseTex ) { + useSamplerParameter( programName, "TranspSampler", material->m_Transparency.m_TextureObject); + techniqueName += "_Transp"; + } + //if (material->m_Ambient.m_TextureObject!=0) { + //useSamplerParameter( programName, "ColorSampler", material->m_Ambient.m_TextureObject); + //techniqueName = "Main"; + //} + //if (material->m_Emission.m_TextureObject!=0) { + //useSamplerParameter( programName, "ColorSampler", material->m_Emission.m_TextureObject); + //techniqueName = "Main"; + //} + //if ( techniqueName.compare( "No_Texture" ) == 0 ) + //{ + // useSamplerParameter( programName, "ColorSampler", 0); + // useSamplerParameter( programName, "SpecularSampler", 0); + //} + // should do this when unbind this material? + + // set material parameters + int progID = getProgramID( programName ); + if ( m_Ambient[progID] ) + cgSetParameter4fv(m_Ambient[progID], &material->m_Ambient.m_color[0]); + if ( m_Diffuse[progID] ) + cgSetParameter4fv(m_Diffuse[progID], &material->m_Diffuse.m_color[0]); + if ( m_Specular[progID] ) + cgSetParameter4fv(m_Specular[progID], &material->m_Specular.m_color[0]); + if ( m_Emission[progID] ) + cgSetParameter4fv(m_Emission[progID], &material->m_Emission.m_color[0]); + if ( m_Transparency[progID] ) + cgSetParameter4fv(m_Transparency[progID], &material->m_Transparency.m_color[0]); + if ( m_Shininess[progID] ) + cgSetParameter1f(m_Shininess[progID], material->m_Shininess); + + // set blinn specific material parameters + if ( programName.compare( "Blinn" ) == 0 ) + { + if ( Ks[progID] ) + cgSetParameter4fv(Ks[progID], &material->m_Specular.m_color[0]); + if ( Eccentricity[progID] ) + cgSetParameter1f(Eccentricity[progID], material->m_Shininess); + } + + size_t nameLength = material->m_MaterialName.size(); + if ( nameLength > 10 && material->m_MaterialName.compare( nameLength-10,10,"_Alphatest" ) == 0 ) + techniqueName += "_Alphatest"; // HACKY + else if ( material->m_IsTransparent ) + techniqueName += "_Blending"; + + int techniqueID = getTechniqueID( techniqueName ); + setCurrentPass( programName, m_CgTechniques[progID][techniqueID] ); +} + +void XCgFX::unbindMaterial(XMaterial* material) +{ + string programName; + switch( material->m_MaterialType ) + { + case MATERIAL_PHONG: + programName = "Phong"; + break; + case MATERIAL_LAMBERT: + programName = "Lambert"; + break; + case MATERIAL_BLINN: + programName = "Blinn"; + break; + default: + programName = "simple"; + break; + } + + resetCurrentPass( programName ); +} + +// light parameters + //if ( AmbiColor[progID] ) + // cgSetParameter4fv(AmbiColor[progID], &material->m_Ambient.m_color[0]); + diff --git a/Loader/XCgFX.h b/Loader/XCgFX.h new file mode 100644 index 000000000..001bcfd74 --- /dev/null +++ b/Loader/XCgFX.h @@ -0,0 +1,96 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#pragma once + +#include +#include +#include /* for exit */ +#include +using namespace std; + +#include /* Cg Core API: Can't include this? Is Cg Toolkit installed! */ +#include /* Cg OpenGL API (part of Cg Toolkit) */ + +#include "XMaterial.h" + +static const string m_ProgramDir = "CgFX/basic-lighting/"; + +static const int m_ProgramNum = 4; +static const string m_ProgramNames[ m_ProgramNum ] = +{"simple", "Phong", "Blinn", "Lambert"}; + +static const int m_TechniqueNum = 9; +static const string m_TechniqueNames[ m_TechniqueNum ] = +{"Main", "Main_Blending", "Main_Alphatest", +"No_Texture", "No_Texture_Blending", +"Main_Specular", "Main_Specular_Blending", +"Main_Transp_Blending","Main_Specular_Transp_Blending"}; + +class XCgFX +{ +public: + XCgFX(void); + ~XCgFX(void); + + CGcontext m_CgContext; + CGeffect m_CgEffects[m_ProgramNum]; + + CGtechnique m_CgTechniques[m_ProgramNum][ m_TechniqueNum ]; + + // matrix parameters + CGparameter WorldInverseTranspose[m_ProgramNum]; + CGparameter WorldViewProjection[m_ProgramNum]; + CGparameter World[m_ProgramNum]; + //CGparameter ViewInverse[m_ProgramNum]; + + // light parameters + CGparameter Lamp0Pos[m_ProgramNum]; + CGparameter Lamp0Color[m_ProgramNum]; + CGparameter AmbiColor[m_ProgramNum]; + + /// material parameters + CGparameter m_Ambient[m_ProgramNum]; + CGparameter m_Diffuse[m_ProgramNum]; + CGparameter m_Specular[m_ProgramNum]; + CGparameter m_Emission[m_ProgramNum]; + CGparameter m_Transparency[m_ProgramNum]; + CGparameter m_Shininess[m_ProgramNum]; + + // blinn specific material parameters + CGparameter Ks[m_ProgramNum]; + CGparameter Eccentricity[m_ProgramNum]; + + CGpass m_CurrentPasses[m_ProgramNum]; + + int getProgramID( string name ); + int getTechniqueID(string techniqueName); + + void initCg(void); + void checkForCgError(const char * situation, const char* m_ProgramName = NULL); + + void setCurrentPass(string programName, const CGtechnique &tech); + bool resetCurrentPass(string programName); + + void updateGLstates(string programName); + void useSamplerParameter(string programName, const char *paramName, GLuint texobj); + +public: + void bindMaterial(XMaterial* material); +public: + void unbindMaterial(XMaterial* material); + +}; diff --git a/Loader/XJointAnim.cpp b/Loader/XJointAnim.cpp new file mode 100644 index 000000000..52ec7c097 --- /dev/null +++ b/Loader/XJointAnim.cpp @@ -0,0 +1,117 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#include "XJointAnim.h" + +#ifdef WIN32 +#else +#include "mm_malloc.h" +#endif + +#include + +XJointAnim::XJointAnim(void) +{ + m_JointNameHashes = NULL; + + m_JointXforms = NULL; +} + +XJointAnim::~XJointAnim(void) +{ + if ( m_JointNameHashes ) + delete [] m_JointNameHashes; + + if ( m_JointXforms ) + _mm_free( m_JointXforms ); +} + +std::istream& operator >> (std::istream& ifs, XJointAnim &ja) +{ + char buffer[256]; + + ifs >> buffer; assert( strcmp(buffer, "NumJointAnims") == 0 ); + ifs >> ja.m_NumJointAnims; + + if ( ja.m_NumJointAnims > 0 ) + { + ja.m_JointNameHashes = new uint[ ja.m_NumJointAnims ]; + for ( uint j = 0; j < ja.m_NumJointAnims; j++ ) + { + ifs >> buffer; + ja.m_JointNames.push_back( string(buffer) ); + ifs >> ja.m_JointNameHashes[j]; + } + + assert( !ja.m_JointXforms ); + uint numKeys = ja.m_NumJointAnims * ja.m_NumFrames; + ja.m_JointXforms = (XTransformation*)_mm_malloc( sizeof(XTransformation)*numKeys, 16 ); + for ( uint i = 0; i < ja.m_NumFrames; i++ ) + { + for ( uint j = 0; j < ja.m_NumJointAnims; j++ ) + { + ifs >> ja.m_JointXforms[ ja.m_NumJointAnims * i + j ]; + } + } + } + + return ifs; +} + +void XJointAnim::updateJointXforms(const XTimeInfo& timeInfo, XSkeleton& skeleton) +{ + unsigned int frame = timeInfo.GetFrameNum(); + assert( frame >= 0 ); + assert( frame <= m_NumFrames ); + + if ( frame < m_NumFrames - 1) + { + // linear interpolation of frame and frame+1 + float frameTime = timeInfo.GetFrameT(); + assert( frameTime > 0 && frameTime < 1 ); + + XTransformation** xforms0 = new XTransformation*[m_NumJointAnims]; + XTransformation** xforms1 = new XTransformation*[m_NumJointAnims]; + for ( uint j = 0; j < m_NumJointAnims; j++ ) + { + xforms0[j] = &m_JointXforms[ m_NumJointAnims * frame + j ]; + } + for ( uint j = 0; j < m_NumJointAnims; j++ ) + { + xforms1[j] = &m_JointXforms[ m_NumJointAnims * (frame+1) + j ]; + } + + for ( uint j = 0; j < m_NumJointAnims; j++ ) + { + // update transform in skeleton + XTransformation xform = LERP( frameTime, *xforms0[j], *xforms1[j] ); + xform.m_Visibility = xforms0[j]->m_Visibility; + skeleton.updateXform( m_JointNameHashes[j], xform); + } + + delete [] xforms0; + delete [] xforms1; + } + else // frame == m_NumFrames - 1 + { + for ( uint j = 0; j < m_NumJointAnims; j++ ) + { + // update transform in skeleton + XTransformation xform = m_JointXforms[ m_NumJointAnims * frame + j ]; + skeleton.updateXform( m_JointNameHashes[j], xform ); + } + } +} diff --git a/Loader/XJointAnim.h b/Loader/XJointAnim.h new file mode 100644 index 000000000..20d60e2c1 --- /dev/null +++ b/Loader/XJointAnim.h @@ -0,0 +1,46 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#pragma once + +#include +#include + +#include "I16Aligned.h" +#include "XTransformation.h" +#include "XSkeleton.h" + +#include "../SharedStructures.h" + +using namespace std; + +class XJointAnim : public I16Aligned +{ + friend std::istream& operator >> (std::istream& ifs, XJointAnim &ja); + +public: + uint m_NumJointAnims; + uint m_NumFrames; + uint* m_JointNameHashes; + vector m_JointNames; + XTransformation* m_JointXforms; + + XJointAnim(void); + ~XJointAnim(void); + + // update skeleton's joint transformations using timeinfo + void updateJointXforms(const XTimeInfo& timeInfo, XSkeleton& skeleton); +}; diff --git a/Loader/XMaterial.cpp b/Loader/XMaterial.cpp new file mode 100644 index 000000000..6deb3d110 --- /dev/null +++ b/Loader/XMaterial.cpp @@ -0,0 +1,95 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#ifdef WIN32 + #define WIN32_LEAN_AND_MEAN + #include +#endif + +#include +#include +#include "XMaterial.h" + +XMaterial::XMaterial(void) +{ + m_IsTransparent = false; +} + +XMaterial::~XMaterial(void) +{ +} + +std::istream& operator >> (std::istream& ifs, XMaterial& mat) +{ + char buffer[256]; + + ifs >> buffer; assert( strcmp( buffer, "MaterialType=" ) == 0 ); + ifs >> mat.m_MaterialType; + ifs >> buffer; // "LAMBERT", "PHONG", "BLINN" + + if ( strcmp( buffer, SMatNames[ mat.m_MaterialType ] ) != 0 ) + { + std::cerr << "Error: Unrecognized material type " << mat.m_MaterialName.c_str() << std::endl; + } + + ifs >> buffer; // name + mat.m_MaterialName = buffer; + + ifs >> buffer; assert( strcmp(buffer, "materialID=") == 0 ); + ifs >> mat.m_MaterialID; + + ifs >> mat.m_Ambient + >> mat.m_Diffuse + >> mat.m_Emission // incadescence + >> mat.m_Transparency; + + ifs >> buffer; assert( strcmp(buffer, "normalmap") == 0 ); + ifs >> buffer; assert( strcmp(buffer, "tex=") == 0 ); + ifs >> mat.m_NormalMapObject; + + switch ( mat.m_MaterialType ) + { + case MATERIAL_LAMBERT: + { + // nothing + break; + } + case MATERIAL_PHONG: + { + ifs >> mat.m_Specular; + + ifs >> buffer; assert( strcmp( buffer, "shininess" ) == 0 ); + ifs >> mat.m_Shininess; + break; + } + case MATERIAL_BLINN: + { + ifs >> mat.m_Specular; + + ifs >> buffer; assert( strcmp( buffer, "eccentricity" ) == 0 ); + ifs >> mat.m_Shininess; // eccentricity + + float f; + ifs >> buffer >> f; // specularRollOff + break; + } + default: + std::cerr << "Error! Unrecognized material type " << mat.m_MaterialType; + assert(0); exit(1); + } + + return ifs; +} \ No newline at end of file diff --git a/Loader/XMaterial.h b/Loader/XMaterial.h new file mode 100644 index 000000000..30def4306 --- /dev/null +++ b/Loader/XMaterial.h @@ -0,0 +1,140 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#pragma once + +#include +#include +#include +#include "../SharedStructures.h" + +inline float CLAMP(const float &f) +{ + if ( f > 1.0f ) + return 1.0f; + if ( f < 0.0f ) + return 0.0f; + return f; +} + +class XMatAttrib +{ +public: + char m_name[256]; + float m_color[4]; + uint m_TextureObject; + + XMatAttrib() : m_TextureObject(0) + { + m_color[0] = 0.0f; + m_color[1] = 0.0f; + m_color[2] = 0.0f; + m_color[3] = 1.0f; + } + + friend std::istream& operator >> (std::istream& ifs, XMatAttrib& attrib) + { + char buffer[256]; + + ifs >> attrib.m_name; + ifs >> attrib.m_color[0] >> attrib.m_color[1] >> attrib.m_color[2]; + + ifs >> buffer; assert( strcmp( buffer, "tex=" ) == 0 ); + ifs >> attrib.m_TextureObject; + + return ifs; + } + + inline void SetAlpha(const float a) + { + m_color[3] = 1.0f - CLAMP(a); + } + +}; + +class XMaterial +{ +public: + uint m_MaterialType; + std::string m_MaterialName; + int m_MaterialID; + + XMatAttrib m_Ambient; + XMatAttrib m_Diffuse; + XMatAttrib m_Specular; + XMatAttrib m_Emission; + XMatAttrib m_Transparency; + + unsigned int m_NormalMapObject; + + float m_Shininess; + + bool m_IsTransparent; // runtime + + + XMaterial(void); + ~XMaterial(void); + + friend std::istream& operator >> (std::istream& ifs, XMaterial& mat); + + inline void SetTransparency() + { + // check if this material has transparency texture + unsigned int transpTexID = m_Transparency.m_TextureObject; + if ( transpTexID > 0 ) + { + m_IsTransparent = true; + } + // check if this material has transparency color + if ( + m_Transparency.m_color[0] > 0.1 || + m_Transparency.m_color[1] > 0.1 || + m_Transparency.m_color[2] > 0.1 ) + { + m_IsTransparent = true; + float r = m_Transparency.m_color[0]; + float g = m_Transparency.m_color[1]; + float b = m_Transparency.m_color[2]; + float transp = ( r + g + b ) / 3.0f; // just average for now + m_Ambient.SetAlpha( transp ); + m_Diffuse.SetAlpha( transp ); + } + + } + + /// a function to set the texture object for the material to use + inline void SetTextureObjects(unsigned int *texObjs) + { + if(m_Ambient.m_TextureObject != 0 ) + m_Ambient.m_TextureObject = texObjs[ m_Ambient.m_TextureObject-1 ]; + + if(m_Diffuse.m_TextureObject != 0 ) + m_Diffuse.m_TextureObject = texObjs[ m_Diffuse.m_TextureObject-1 ]; + + if(m_Specular.m_TextureObject != 0 ) + m_Specular.m_TextureObject = texObjs[ m_Specular.m_TextureObject-1 ]; + + if(m_Emission.m_TextureObject != 0 ) + m_Emission.m_TextureObject = texObjs[ m_Emission.m_TextureObject-1 ]; + + if(m_Transparency.m_TextureObject != 0 ) + m_Transparency.m_TextureObject = texObjs[ m_Transparency.m_TextureObject-1 ]; + + if (m_NormalMapObject != 0) + m_NormalMapObject = texObjs[ m_NormalMapObject-1 ]; + } + +}; diff --git a/Loader/XMaterialGroup.cpp b/Loader/XMaterialGroup.cpp new file mode 100644 index 000000000..adea64805 --- /dev/null +++ b/Loader/XMaterialGroup.cpp @@ -0,0 +1,63 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#include + +#include "XMaterialGroup.h" + +#include "GLExtensions.h" + +XMaterialGroup::XMaterialGroup(void) +{ + m_indices = NULL; +} + +XMaterialGroup::~XMaterialGroup(void) +{ + if( m_indices ) + delete [] m_indices; +} + +/// \brief stream insertion operator for the XMaterialGroup class +/// +std::istream &operator>>(std::istream& ifs,XMaterialGroup& m) +{ + string data; + + while( data != string("MaterialID=") ) + ifs >> data; + ifs >> m.m_MaterialID; + + while( data != string("TriCount") ) + ifs >> data; + ifs >> m.m_TriCount; + + m.m_numIndices = m.m_TriCount * 3; + + m.m_indices = new uint[ m.m_numIndices ]; + for( GLuint j = 0; j < m.m_numIndices; j++ ) + ifs >> m.m_indices[j]; + + // create index vbo + glGenBuffers( 1, (GLuint*)&m.m_indicesVBO ); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m.m_indicesVBO); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, m.m_numIndices * sizeof(uint), m.m_indices, GL_STATIC_DRAW); + + // unbind VBOs + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + + return ifs; +} diff --git a/Loader/XMaterialGroup.h b/Loader/XMaterialGroup.h new file mode 100644 index 000000000..0b22e7e8e --- /dev/null +++ b/Loader/XMaterialGroup.h @@ -0,0 +1,47 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#pragma once + +/// +#ifdef WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#endif + +#include +#include +#include +#include "../SharedStructures.h" + +using namespace std; + + +class XMaterialGroup +{ + friend std::istream &operator>>(std::istream&,XMaterialGroup&); + +public: + XMaterialGroup(void); + ~XMaterialGroup(void); + + int m_MaterialID; + uint m_TriCount; + uint m_numIndices; + uint* m_indices; + uint m_indicesVBO; + +}; diff --git a/Loader/XMesh.cpp b/Loader/XMesh.cpp new file mode 100644 index 000000000..5251b5c25 --- /dev/null +++ b/Loader/XMesh.cpp @@ -0,0 +1,555 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#include +#include + +#include "XMesh.h" +#include "GLExtensions.h" + +#ifdef WIN32 +#include "XCgFX.h" +extern XCgFX cgfx; +#else +#include "mm_malloc.h" +#endif + +using namespace std; + +extern XOptions options; + +XMesh::XMesh() +{ + m_verts = NULL; + m_FullOutVerts = NULL; + m_BlendShapeBinding = NONE; + m_Blendshaped = false; + + // blendshape + m_BlendWeights = NULL; + + // skinning + m_SkinInfHashes = NULL; + m_InvBindM4 = NULL; + m_CombinedMats = NULL; + m_CombinedRots = NULL; + + m_AnimatedM = Matrix4::identity(); + m_Visibility = true; +}; + +XMesh::~XMesh() +{ + if ( m_verts ) + _mm_free( m_verts ); + if( m_FullOutVerts ) + _mm_free( m_FullOutVerts ); + + // blendshape + if (m_BlendWeights) + _mm_free( m_BlendWeights ); + + // skinning + if (m_SkinInfHashes) + free(m_SkinInfHashes); + if (m_InvBindM4) + _mm_free( m_InvBindM4 ); + if (m_CombinedMats) + _mm_free( m_CombinedMats ); + if (m_CombinedRots) + _mm_free( m_CombinedRots ); + +}; + +void XMesh::allocateBlendWeights() +{ + m_BlendWeights = (float*)_mm_malloc( sizeof(float) * m_NumBlendWeights, 16 ); + memset( m_BlendWeights, 0, sizeof(float) * m_NumBlendWeights ); +} + +void XMesh::allocateFullOutVerts() +{ + if( !m_FullOutVerts ) + { + m_FullOutVerts = (float*)_mm_malloc( sizeof( float ) * m_NumFloats, 16 ); + memcpy( m_FullOutVerts, m_verts, sizeof(float)*m_NumFloats ); + } +} + +void XMesh::allocateSkinningMatrices() +{ + m_InvBindM4 = (Matrix4*)_mm_malloc( sizeof( Matrix4 ) * m_NumSkinInfs, 16 ); + m_CombinedMats = (Matrix4*)_mm_malloc( sizeof( Matrix4 ) * m_NumSkinInfs, 16 ); + m_CombinedRots = (Matrix3*)_mm_malloc( sizeof( Matrix3 ) * m_NumSkinInfs, 16 ); +} + +std::istream &operator>>(std::istream& ifs,XMesh& m) +{ + char buffer[256]; + + // read mesh name + ifs >> buffer; + m.m_MeshName = buffer; + + ifs >> buffer; assert( strcmp( buffer, "meshID=" ) == 0 ); + ifs >> m.m_ID; + + ifs >> buffer; assert( strcmp( buffer, "ParentHash=" ) == 0 ); + ifs >> m.m_ParentHash; + + string data; + + while( data != string("NumBlendshapeWeights") ) + ifs >> data; + ifs >> m.m_NumBlendWeights; + + while( data != string("IsSkinned") ) + ifs >> data; + ifs >> m.m_IsSkinned; + + if ( m.m_IsSkinned ) + { + ifs >> buffer; assert( strcmp( buffer, "SKIN" ) == 0 ); + ifs >> m.m_SkinName; + ifs >> buffer; assert( strcmp( buffer, "NumInfluences" ) == 0 ); + ifs >> m.m_NumSkinInfs; + + m.m_SkinInfHashes = (uint*)calloc( m.m_NumSkinInfs, sizeof(uint) ); + for ( uint i = 0; i < m.m_NumSkinInfs; i++ ) + ifs >> m.m_SkinInfHashes[i]; + } + + while( data != string("Stride") ) + ifs >> data; + ifs >> m.m_Stride; + + while( data != string("NumVerts") ) + ifs >> data; + ifs >> m.m_NumVerts; + + m.m_NumFloats = m.m_NumVerts * m.m_Stride; + m.m_UVoffset = 6 + m.m_NumBlendWeights * 6; + m.m_JointIndexOffset = m.m_UVoffset + 2; + m.m_JointWeightsOffset = m.m_JointIndexOffset + 4; + + m.m_verts = (float*)_mm_malloc( sizeof( float ) * m.m_NumFloats, 16 ); + for ( GLuint j = 0; j < m.m_NumFloats; j++ ) + ifs >> m.m_verts[j]; + + if ( m.m_IsSkinned ) + { + // convert joint indices to separate int array + m.m_JointIndices = new int[ m.m_NumVerts * 4 ]; + for (GLuint i = 0; i < m.m_NumVerts; i++) + for ( int j = 0; j < 4; j++) + m.m_JointIndices[i*4+j] = (int)m.m_verts[ i * m.m_Stride + m.m_JointIndexOffset + j ]; + } + + // read material groups + while( data != string("MaterialCount=") ) + ifs >> data; + ifs >> m.m_NumMaterials; + + m.m_MG_list.resize( m.m_NumMaterials ); + for ( GLuint j = 0; j < m.m_NumMaterials; j++ ) + ifs >> m.m_MG_list[j]; + + // create VBOs + glGenBuffers( 1, (GLuint*)&m.m_vertsVBO ); + glBindBuffer(GL_ARRAY_BUFFER, m.m_vertsVBO); + glBufferData(GL_ARRAY_BUFFER, m.m_NumFloats * sizeof(GLfloat), m.m_verts, GL_STATIC_DRAW); + + // unbind VBOs + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + + return ifs; +} + +void XMesh::init(XSkeleton* skeleton) +{ + m_Skeleton = skeleton; + + Matrix4 BindMat = Matrix4::identity(); + if ( m_ParentHash ) + BindMat = m_Skeleton->getJointWorldMatrix( m_ParentHash ); + + allocateBlendWeights(); + + allocateSkinningMatrices(); + + // allocate space for deformation + allocateFullOutVerts(); + + // update verts and position in vbo data to the bind pose + for (GLuint i = 0; i < m_NumVerts; i++) + { + Vector4 V( + m_verts[ i * m_Stride + 0 ], + m_verts[ i * m_Stride + 1 ], + m_verts[ i * m_Stride + 2 ], + 1.0f); + + // calculate the world space position of the vertex when it was actually bound. + Vector4 WSV = BindMat*V; + + m_verts[ i * m_Stride + 0 ] = WSV.getX(); + m_verts[ i * m_Stride + 1 ] = WSV.getY(); + m_verts[ i * m_Stride + 2 ] = WSV.getZ(); + + m_FullOutVerts[ i * m_Stride + 0 ] = WSV.getX(); + m_FullOutVerts[ i * m_Stride + 1 ] = WSV.getY(); + m_FullOutVerts[ i * m_Stride + 2 ] = WSV.getZ(); + } + glBindBuffer(GL_ARRAY_BUFFER, m_vertsVBO); + glBufferData(GL_ARRAY_BUFFER, m_NumFloats * sizeof(GLfloat), m_FullOutVerts, GL_STATIC_DRAW); + glBindBuffer(GL_ARRAY_BUFFER, 0); +} + +void XMesh::calculateInvBindMats() +{ + for (size_t i = 0; i < m_NumSkinInfs; i++ ) + { + uint infHash = m_SkinInfHashes[i]; + Matrix4 world = m_Skeleton->getJointWorldMatrix( infHash ); + float d = determinant( world ); + if ( fabs(d) < 0.01f ) + { + std::cerr << "COULD NOT INVERT MATRIX!!!" << std::endl; + assert(0); + exit(1); + } + Matrix4 Inv = inverse( world ); + m_InvBindM4[i] = Inv; + } +} + +bool XMesh::sortTransparentMaterials( XMaterialList *allMats ) +{ + for ( GLuint i = 0; i < m_NumMaterials; i++ ) + { + const XMaterialGroup &mg = m_MG_list[i]; + int matID = mg.m_MaterialID; + + if ( matID > 0 ) + { + XMaterial *mat = (*allMats)[ matID-1 ]; + + if ( mat->m_IsTransparent ) + return true; + } + } + return false; +} + +void XMesh::applyBlendshape() +{ + // update mesh using current weights + for (GLuint i = 0; i < m_NumVerts; i++) + { + // weighted sum of targets + + // position + Vector4 baseV( + m_verts[ i * m_Stride + 0 ], + m_verts[ i * m_Stride + 1 ], + m_verts[ i * m_Stride + 2 ], + 0); + //Matrix4 targetM(0.0f); + for ( unsigned int j = 0; j < m_NumBlendWeights; j++ ) + { + Vector4 targetV( + m_verts[ i * m_Stride + 6 + j*6 + 0 ], + m_verts[ i * m_Stride + 6 + j*6 + 1 ], + m_verts[ i * m_Stride + 6 + j*6 + 2 ], + 0); + //targetM.setCol( j, targetV ); + baseV += targetV * m_BlendWeights[j]; + } + //baseV += targetM * currentWeights; + m_FullOutVerts[ i * m_Stride + 0 ] = baseV.getX(); + m_FullOutVerts[ i * m_Stride + 1 ] = baseV.getY(); + m_FullOutVerts[ i * m_Stride + 2 ] = baseV.getZ(); + + // normal + baseV = Vector4( + m_verts[ i * m_Stride + 3 + 0 ], + m_verts[ i * m_Stride + 3 + 1 ], + m_verts[ i * m_Stride + 3 + 2 ], + 0); + //targetM = Matrix4(0.0f); + for ( unsigned int j = 0; j < m_NumBlendWeights; j++ ) + { + Vector4 targetV( + m_verts[ i * m_Stride + 6 + j*6 + 3 + 0 ], + m_verts[ i * m_Stride + 6 + j*6 + 3 + 1 ], + m_verts[ i * m_Stride + 6 + j*6 + 3 + 2 ], + 0); + //targetM.setCol( j, targetV ); + baseV += targetV * m_BlendWeights[j]; + } + //baseV += targetM * currentWeights; + m_FullOutVerts[ i * m_Stride + 3 + 0 ] = baseV.getX(); + m_FullOutVerts[ i * m_Stride + 3 + 1 ] = baseV.getY(); + m_FullOutVerts[ i * m_Stride + 3 + 2 ] = baseV.getZ(); + } + + if ( m_BlendShapeBinding == SKINED_BASE ) + { + m_Blendshaped = true; + } + else if ( m_BlendShapeBinding == BASE ) + { + glBindBuffer(GL_ARRAY_BUFFER, m_vertsVBO); + glBufferData(GL_ARRAY_BUFFER, m_NumFloats * sizeof(GLfloat), m_FullOutVerts, GL_STATIC_DRAW); + glBindBuffer(GL_ARRAY_BUFFER, 0); + } + else + { + assert(0); // no blenshape binding + } +} + +void XMesh::applySkinning() +{ + for (size_t i = 0; i < m_NumSkinInfs; i++ ) + { + Matrix4 W4 = m_Skeleton->getJointWorldMatrix( m_SkinInfHashes[i] ); + + Matrix4 Inv4 = m_InvBindM4[i]; + m_CombinedMats[i] = W4 * Inv4; + m_CombinedRots[i] = m_CombinedMats[i].getUpper3x3(); + } + + // update the position in vbo data + for (GLuint i = 0; i < m_NumVerts; i++) + { + Vector4 sum( 0.0f, 0.0f, 0.0f, 0.0f ); + // position + if (m_Blendshaped) + { + Vector4 V( + m_FullOutVerts[ i * m_Stride + 0 ], + m_FullOutVerts[ i * m_Stride + 1 ], + m_FullOutVerts[ i * m_Stride + 2 ], + 1.0f); + for ( int j = 0; j < 4; j++) + { + int idx = m_JointIndices[ i*4 + j ]; + float weight = m_verts[ i * m_Stride + m_JointWeightsOffset + j]; + sum += m_CombinedMats[idx] * V * weight; + } + } + else // no blendshape + { + Vector4 V( + m_verts[ i * m_Stride + 0 ], + m_verts[ i * m_Stride + 1 ], + m_verts[ i * m_Stride + 2 ], + 1.0f); + for ( int j = 0; j < 4; j++) + { + int idx = m_JointIndices[ i*4 + j ]; + float weight = m_verts[ i * m_Stride + m_JointWeightsOffset + j]; + sum += m_CombinedMats[idx] * V * weight; + } + } + // normal + Vector3 sumNormal( 0.0f ); + if (m_Blendshaped) + { + Vector3 V( + m_FullOutVerts[ i * m_Stride + 3 + 0 ], + m_FullOutVerts[ i * m_Stride + 3 + 1 ], + m_FullOutVerts[ i * m_Stride + 3 + 2 ]); + for ( int j = 0; j < 4; j++) + { + int idx = m_JointIndices[ i*4 + j ]; + float weight = m_verts[ i * m_Stride + m_JointWeightsOffset + j]; + sumNormal += m_CombinedRots[idx] * V * weight; + } + } + else // no blendshape + { + Vector3 V( + m_verts[ i * m_Stride + 3 + 0 ], + m_verts[ i * m_Stride + 3 + 1 ], + m_verts[ i * m_Stride + 3 + 2 ]); + for ( int j = 0; j < 4; j++) + { + //int idx = m_verts[ i * m_Stride + 8 + j]; + int idx = m_JointIndices[ i*4 + j ]; + float weight = m_verts[ i * m_Stride + m_JointWeightsOffset + j]; + sumNormal += m_CombinedRots[idx] * V * weight; + } + } + sumNormal = normalize( sumNormal ); + + m_FullOutVerts[ i * m_Stride + 0 ] = sum.getX(); + m_FullOutVerts[ i * m_Stride + 1 ] = sum.getY(); + m_FullOutVerts[ i * m_Stride + 2 ] = sum.getZ(); + m_FullOutVerts[ i * m_Stride + 3 + 0 ] = sumNormal.getX(); + m_FullOutVerts[ i * m_Stride + 3 + 1 ] = sumNormal.getY(); + m_FullOutVerts[ i * m_Stride + 3 + 2 ] = sumNormal.getZ(); + } + + glBindBuffer(GL_ARRAY_BUFFER, m_vertsVBO); + glBufferData(GL_ARRAY_BUFFER, m_NumFloats * sizeof(GLfloat), m_FullOutVerts, GL_STATIC_DRAW); + //glBufferSubData(GL_ARRAY_BUFFER, 0, m_NumFloats * sizeof(GLfloat), m_FullOutVerts); + glBindBuffer(GL_ARRAY_BUFFER, 0); + + m_Blendshaped = false; +} + +void XMesh::gl(XMaterialList& mats) +{ + + if( !options.m_bDrawMeshes ) + return; + + if ( m_NumBlendWeights > 0 ) + applyBlendshape(); + + if ( m_IsSkinned ) + applySkinning(); + else // not skinned + { + m_AnimatedM = Matrix4::identity(); + if ( m_ParentHash ) + { + m_AnimatedM = m_Skeleton->getJointWorldMatrix( m_ParentHash ); + bool visibility = m_Skeleton->getJointVisibility( m_ParentHash ); + if ( !visibility ) + return; + } + glMultMatrixf( (float*)&m_AnimatedM ); + } + + for ( GLuint i = 0; i < m_NumMaterials; i++ ) + { + const XMaterialGroup &mg = m_MG_list[i]; + int matID = mg.m_MaterialID; + + // check if this material group has material or not + //assert( matID > 0 ); + if ( matID == 0 ) + continue; + + XMaterial *mat = mats[ matID-1 ]; + + // set material +#ifdef WIN32 + cgfx.bindMaterial( mat ); +#else + // fixed function fallback + glEnable( GL_LIGHTING ); + glEnable( GL_LIGHT0 ); + glEnable( GL_COLOR_MATERIAL ); + glColor4fv( mat->m_Diffuse.m_color ); + uint diffuseTex = mat->m_Diffuse.m_TextureObject; + if ( diffuseTex ) + { + glEnable( GL_TEXTURE_2D ); + glBindTexture( GL_TEXTURE_2D, diffuseTex ); + //glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); + float white[4] = {1,1,1,1}; + glColor4fv( white ); + } + if ( mat->m_IsTransparent ) + { +// glEnable( GL_BLEND ); +// glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_COLOR ); + glEnable( GL_ALPHA_TEST ); + glAlphaFunc( GL_GREATER, 0.1f ); + } + else + { +// glDisable( GL_BLEND ); + glDisable( GL_ALPHA_TEST ); + } + // flip y for DXT texture + glMatrixMode( GL_TEXTURE ); + glLoadIdentity(); + glScalef( 1, -1, 1 ); + //glTranslatef( 0, 1, 0 ); + glMatrixMode(GL_MODELVIEW); +#endif + // Enable Pointers + glEnableClientState( GL_VERTEX_ARRAY ); + glEnableClientState( GL_NORMAL_ARRAY ); + glEnableClientState( GL_TEXTURE_COORD_ARRAY ); + + // Bind VBOs + glBindBuffer( GL_ARRAY_BUFFER_ARB, m_vertsVBO ); + glVertexPointer( 3, GL_FLOAT, m_Stride*sizeof(float), (GLvoid*)(0) ); + glNormalPointer( GL_FLOAT, m_Stride*sizeof(float), (GLvoid*)(3*sizeof(float)) ); + glTexCoordPointer(2, GL_FLOAT, m_Stride*sizeof(float), (GLvoid*)(m_UVoffset*sizeof(float)) ); + glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, mg.m_indicesVBO ); + + //glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); + glDrawElements( GL_TRIANGLES, mg.m_numIndices, GL_UNSIGNED_INT, 0 ); + + // Unbind VBOs + glBindBuffer( GL_ARRAY_BUFFER_ARB, 0 ); + glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 ); + + // Disable Pointers + glDisableClientState( GL_VERTEX_ARRAY ); + glDisableClientState( GL_NORMAL_ARRAY ); + glDisableClientState( GL_TEXTURE_COORD_ARRAY ); + +#ifdef WIN32 + cgfx.unbindMaterial( mat ); +#endif + + } + + if ( options.m_bNormals ) + { + float *normalLines = new float[ 3 * 2 * m_NumVerts ]; + for ( unsigned int i = 0; i < m_NumVerts; i++ ) + { + if (m_FullOutVerts) + memcpy( &normalLines[i*6], &m_FullOutVerts[i*m_Stride], sizeof(float)*3*2 ); + else + memcpy( &normalLines[i*6], &m_verts[i*m_Stride], sizeof(float)*3*2 ); + + for ( int j = 0; j < 3; j++ ) + { + normalLines[i*6 + 3 + j] += normalLines[i*6 + j]; + } + } + // Enable Pointers + glEnableClientState( GL_VERTEX_ARRAY ); + + // Bind VBOs + glVertexPointer( 3, GL_FLOAT, 0, (GLvoid*)normalLines ); + + glDisable(GL_LIGHTING); + glEnable(GL_DEPTH_TEST); + glColor3f(1,0,0); // red + glDrawArrays( GL_LINES, 0, m_NumVerts*2 ); + + // Unbind VBOs + glBindBuffer( GL_ARRAY_BUFFER_ARB, 0 ); + + // Disable Pointers + glDisableClientState( GL_VERTEX_ARRAY ); + + delete [] normalLines; + } +} + diff --git a/Loader/XMesh.h b/Loader/XMesh.h new file mode 100644 index 000000000..9b952ab70 --- /dev/null +++ b/Loader/XMesh.h @@ -0,0 +1,135 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#pragma once + +#ifndef XMESH__H_ +#define XMESH__H_ + +#ifdef WIN32 + #define WIN32_LEAN_AND_MEAN + #include +#endif + +#include +#include + +#include "I16Aligned.h" +#include "XMaterial.h" +#include "XMaterialGroup.h" +#include "XSkeleton.h" +#include "XOptions.h" +#include "XTransformation.h" + +#include "../SharedStructures.h" + +////////////////////////////////////////////////////////////////////////// +enum BlendShapeBinding +{ + NONE, + BASE, + SKINED_BASE/*, + TARGET*/ +}; + +class XMaterial; +// +/// a list of material types +typedef std::vector< XMaterial* > XMaterialList; + +/// an iterator type for the material list +typedef XMaterialList::iterator XItMaterial; + + +class XMesh : public I16Aligned +{ + friend std::istream &operator>>(std::istream&,XMesh&); + +public: + + XMesh(); + ~XMesh(); + + void gl(XMaterialList& mats); + + const char* Name() const { + return m_MeshName.c_str(); + } + + // blendshape + void allocateBlendWeights(); + + // skinning + void allocateSkinningMatrices(); + + void calculateInvBindMats(); + + //void init(const Matrix4 &MBind); + void init(XSkeleton* skeleton); + + void allocateFullOutVerts(); + + void applyBlendshape(); + void applySkinning(); + + // return true if any of material in this mesh is transparent + bool sortTransparentMaterials( XMaterialList *allMats ); + + // blend shape binding to this mesh + BlendShapeBinding m_BlendShapeBinding; + + std::string m_MeshName; + unsigned int m_ID; + unsigned int m_ParentHash; + uint m_NumBlendWeights; + uint m_IsSkinned; + + char m_SkinName[256]; + uint m_NumSkinInfs; + uint* m_SkinInfHashes; + + uint m_Stride; + uint m_NumVerts; + float* m_verts; // if skinned, position is in bind pose + uint m_vertsVBO; + + uint m_NumMaterials; + vector m_MG_list; + + float* m_BlendWeights; // runtime + + XSkeleton* m_Skeleton; // runtime + Matrix4* m_InvBindM4; // runtime + Matrix4* m_CombinedMats; // runtime + Matrix3* m_CombinedRots; // runtime + + uint m_NumFloats; // runtime + uint m_UVoffset; // runtime + uint m_JointIndexOffset; // runtime + uint m_JointWeightsOffset; // runtime + int* m_JointIndices; // runtime to avoid costly float -> int conversion + + + bool m_Blendshaped; // runtime + float* m_FullOutVerts; // runtime to store the final output vertices + + bool m_Visibility; // runtime + Matrix4 m_AnimatedM; // runtime +}; + + +#endif + diff --git a/Loader/XModel.cpp b/Loader/XModel.cpp new file mode 100644 index 000000000..fc00de011 --- /dev/null +++ b/Loader/XModel.cpp @@ -0,0 +1,371 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#include +#include + +#ifdef WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#include +#define STRCPY strcpy_s +#define STRCAT strcat_s +#else +#include +#define STRCPY strcpy +#define STRCAT strcat +#endif + + +#include "XModel.h" +#include "XMesh.h" +#include "XOptions.h" +#include "XTextureFile.h" + + + +extern XOptions options; + +XModel::XModel(void) : m_NumTextures(0) +{ + m_TextureObjects = NULL; + m_CurrentAnimID = 0; +} + +XModel::~XModel(void) +{ + if ( m_TextureObjects ) + { + // delete tesxtures + glDeleteTextures(m_NumTextures, (GLuint*)m_TextureObjects); + delete [] m_TextureObjects; + } + + // delete all meshes + { + XItMesh it = m_Meshes.begin(); + for( ; it != m_Meshes.end(); ++it ) + { + delete *it; + } + } +} + +bool XModel::LoadModel(const char* const filename) +{ + char buffer[512]; + std::ifstream ifs(filename);//, std::ifstream::binary); + + if (ifs) + { + ifs >> buffer; assert( strcmp( buffer, "TEXTURES" ) == 0 ); + ifs >> buffer; assert( strcmp( buffer, "NumTextures=" ) == 0 ); + ifs >> m_NumTextures; + if ( m_NumTextures > 0 ) + { + m_TexNames = (char**)calloc( m_NumTextures, sizeof(char*) ); + for ( uint i = 0; i < m_NumTextures; i++ ) + { + m_TexNames[ i ] = (char*)calloc( 256, sizeof( char ) ); + ifs >> m_TexNames[i]; + } + + // init textures + m_TextureObjects = new unsigned int[ m_NumTextures ]; + glGenTextures(m_NumTextures, (GLuint*)m_TextureObjects); + for ( uint i = 0; i < m_NumTextures; i++ ) + { + // check if texture is dds or not + if ( strstr( m_TexNames[i], ".dds" ) == NULL ) + { + // try a texture file name with .dds extension + char tmp[256]; + STRCPY( tmp, m_TexNames[i] ); + char* p = strrchr( tmp, '.' ); + //strcpy_s( p, 4, ".dds" ); + *p = '\0'; + STRCAT( tmp, ".dds" ); + loadCompressedTexture( m_TextureObjects[i], tmp ); + } + else + { + loadCompressedTexture( m_TextureObjects[i], m_TexNames[i] ); + } + } + } + + ifs >> buffer; assert( strcmp( buffer, "METERIALS" ) == 0 ); + ifs >> buffer; assert( strcmp( buffer, "NumMaterials=" ) == 0 ); + ifs >> m_NumMaterials; + for ( uint i = 0; i < m_NumMaterials; i++ ) + { + XMaterial* mat = new XMaterial; + assert(mat); + ifs >> *mat; + if (m_TextureObjects != NULL) + { + mat->SetTextureObjects( m_TextureObjects ); + } + m_Materials.push_back(mat); + } + + ifs >> buffer; assert( strcmp( buffer, "MESHES" ) == 0 ); + ifs >> buffer; assert( strcmp( buffer, "NumMeshes=" ) == 0 ); + ifs >> m_NumMeshes; + for ( uint i = 0; i < m_NumMeshes; i++ ) + { + ifs >> buffer; assert( strcmp( buffer, "MESH" ) == 0 ); + XMesh* pm = new XMesh; + assert (pm); + ifs >> *pm; + m_Meshes.push_back(pm); + } + + ifs >> buffer; assert( strcmp( buffer, "SKELETON" ) == 0 ); + ifs >> m_Skeleton; + + ifs >> buffer; + if ( strcmp( "ANIMATION", buffer ) == 0 ) + { + XAnimation* anim = new XAnimation; + assert (anim); + ifs >> *anim; + //m_CurrentAnim = anim; + m_Anims.push_back(anim); + ifs >> buffer; + } + + assert( ifs.eof() ); + ifs.close(); + } + else + { + std::cerr << "[ERROR] Could not open file " + << filename << std::endl; + return false; + } + return true; +} + +bool XModel::LoadAnim(const char* const filename) +{ + char buffer[512]; + std::ifstream ifs(filename);//, std::ifstream::binary); + + if (ifs) + { + ifs >> buffer; + if ( strcmp( "ANIMATION", buffer ) == 0 ) + { + XAnimation* anim = new XAnimation; + assert (anim); + ifs >> *anim; + //m_CurrentAnim = anim; + m_Anims.push_back(anim); + ifs >> buffer; + } + + assert( ifs.eof() ); + ifs.close(); + } + else + { + std::cerr << "[ERROR] Could not open file " + << filename << std::endl; + return false; + } + return true; +} + +XMesh* XModel::GetMesh( unsigned int id ) +{ + XItMesh it = m_Meshes.begin(); + for (; it != m_Meshes.end(); ++it ) + { + XMesh *mesh = (XMesh*)*it; + if ( mesh->m_ID == id ) + { + return mesh; + } + } + return NULL; +} + +void XModel::init() +{ + if ( m_Skeleton.m_numJoints > 0 ) + { + m_Skeleton.updateWorldMatrices( XTransformation(), true ); + + XItMesh itMesh = m_Meshes.begin(); + for( ; itMesh != m_Meshes.end(); ++itMesh ) + { + XMesh *mesh = (*itMesh); + if ( mesh->m_IsSkinned ) + { + mesh->init( &m_Skeleton ); + mesh->calculateInvBindMats(); + } + else + { + mesh->m_Skeleton = &m_Skeleton; + } + } + } + + bindMeshBlendShapes(); + + setMaterialTransparency(); + + sortTransparentObjects(); + + if ( m_Anims.size() > 0 ) + m_CurrentAnim = m_Anims[ 0 ]; +} + + +void XModel::bindSkins(void) +{ + // initialize skin's bind pose + XItMesh itMesh = m_Meshes.begin(); + for( ; itMesh != m_Meshes.end(); ++itMesh ) + { + XMesh *mesh = (*itMesh); + if ( mesh->m_IsSkinned ) + { + mesh->init( &m_Skeleton ); + mesh->calculateInvBindMats(); + } + } +} + +void XModel::bindMeshBlendShapes() +{ + for ( uint i = 0; i < m_Anims.size(); i++ ) + { + //for( XItBlendShape it = m_Anims[i]->m_BlendShapes.begin(); it != m_Anims[i]->m_BlendShapes.end() ; ++it ) + for ( int j = 0; j < m_Anims[i]->m_NumBlendShapes; j++ ) + { + // bind base mesh + XBlendShape *bs = m_Anims[i]->m_BlendShapes[j];//*it; + bs->m_pTheMesh = (XMesh*)GetMesh( bs->baseMeshID ); + //std::cout << "BlendShape base " << bs->m_BaseName << " mesh " << bs->m_pTheMesh->m_MeshName << std::endl; + bs->m_pTheMesh->allocateFullOutVerts(); + if ( bs->m_pTheMesh->m_IsSkinned ) + bs->m_pTheMesh->m_BlendShapeBinding = SKINED_BASE; + else + bs->m_pTheMesh->m_BlendShapeBinding = BASE; + + } + } +} + +void XModel::setMaterialTransparency(void) +{ + for ( XItMaterial it = m_Materials.begin(); it != m_Materials.end(); it++) + { + XMaterial* mat = *it; + mat->SetTransparency(); + } +} + +void XModel::sortTransparentObjects() +{ + // move transparent objects to m_TranspMeshes + std::vector< unsigned int > eraseList; + for ( unsigned int i = 0; i < m_Meshes.size(); i++) + { + XMesh *mesh = m_Meshes[i]; + + // ugh, a mesh could have both transparent and opaque material... + // Well, if mesh has any transparent material, treat it as + // a transparent object + if ( mesh->sortTransparentMaterials( &m_Materials ) ) + { + m_TranspMeshes.push_back( mesh ); + // want to delete from the end, so insert from front + eraseList.insert( eraseList.begin(), i ); + } + + } + + // move back transparent objects to the tail of m_Meshes + assert( m_TranspMeshes.size() == eraseList.size() ); + for ( unsigned int i = 0; i < eraseList.size(); i++ ) + { + m_Meshes.erase( m_Meshes.begin() + eraseList[i] ); + m_Meshes.push_back( m_TranspMeshes[i] ); + } +} + +void XModel::setCurrentAnimation(unsigned int id) +{ + assert(m_Anims.size() > id); + m_CurrentAnim = m_Anims[id]; +} + +void XModel::nextAnimation() +{ + m_CurrentAnimID++; + if ( m_Anims.size() <= m_CurrentAnimID ) + m_CurrentAnimID = 0; + + m_CurrentAnim = m_Anims[ m_CurrentAnimID ]; +} + +void XModel::Update(const float dt) +{ + if ( options.m_bAnimation ) + { + if(m_CurrentAnim) + { + m_CurrentAnim->Update( dt ); + if ( m_Skeleton.m_numJoints > 0 ) + { + m_CurrentAnim->updateSkeleton( m_Skeleton ); + m_Skeleton.updateWorldMatrices( XTransformation(), true); + } + } + } +} + +void XModel::gl() +{ + + glPushMatrix(); + + if( options.m_bDrawJoints ) + { + m_Skeleton.draw( Matrix4::identity() ); + } + + // draw meshes + XItMesh itMesh = m_Meshes.begin(); + for( ; itMesh != m_Meshes.end(); ++itMesh ) + { + XMesh *mesh = (*itMesh); + if ( mesh->m_Visibility ) + { + glPushMatrix(); + mesh->gl(m_Materials); + glPopMatrix(); + } + } + + glPopMatrix(); + +} + diff --git a/Loader/XModel.h b/Loader/XModel.h new file mode 100644 index 000000000..c39daa9c9 --- /dev/null +++ b/Loader/XModel.h @@ -0,0 +1,81 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#pragma once + +#include +#include +#include "XAnimation.h" +#include "XMaterial.h" +#include "XTextureFile.h" +#include "XBlendShape.h" +#include "XSkeleton.h" + +#include "../SharedStructures.h" + + +typedef std::vector< XMesh* > XMeshList; +typedef XMeshList::iterator XItMesh; + +typedef std::vector< XAnimation* > XAnimList; +typedef XAnimList::iterator XItAnim; + +class XModel +{ + +public: + + XModel(); + ~XModel(void); + + bool LoadModel(const char* const filename); + bool LoadAnim(const char* const filename); + + void init(); + void setCurrentAnimation(unsigned int id); + void nextAnimation(); + + void Update(const float dt); + void gl(); + +private: + + XMesh* GetMesh( unsigned int id ); + void bindSkins(void); + void bindMeshBlendShapes(); + void setMaterialTransparency(void); + void sortTransparentObjects(); + + unsigned int* m_TextureObjects; + unsigned int m_NumTextures; + char** m_TexNames; + + uint m_NumMaterials; + XMaterialList m_Materials; + + uint m_NumMeshes; + XMeshList m_Meshes; + XMeshList m_TranspMeshes; + + XSkeleton m_Skeleton; + + XAnimList m_Anims; + uint m_CurrentAnimID; + XAnimation* m_CurrentAnim; + +}; + + diff --git a/Loader/XOptions.cpp b/Loader/XOptions.cpp new file mode 100644 index 000000000..e639750ed --- /dev/null +++ b/Loader/XOptions.cpp @@ -0,0 +1,13 @@ +#include "XOptions.h" + +bool XOptions::m_bDrawMeshes=true; +bool XOptions::m_bDrawJoints=false; +bool XOptions::m_bWireFrame=false; +bool XOptions::m_bTextured=true; +bool XOptions::m_bCulling=false; +bool XOptions::m_bAxes = true; +bool XOptions::m_bGrid = true; +bool XOptions::m_bNormals = false; +bool XOptions::m_bAnimation = true; +bool XOptions::m_bSampleAlphaToCoverage = false; +bool XOptions::m_bAutoRotate = false; \ No newline at end of file diff --git a/Loader/XOptions.h b/Loader/XOptions.h new file mode 100644 index 000000000..4122418be --- /dev/null +++ b/Loader/XOptions.h @@ -0,0 +1,31 @@ +#ifndef __Options__H__ +#define __Options__H__ + +struct XOptions +{ + void ToggleMeshes() const { m_bDrawMeshes = !m_bDrawMeshes; } + void ToggleJoints() const { m_bDrawJoints = !m_bDrawJoints; } + void ToggleWireframe() const { m_bWireFrame = !m_bWireFrame; } + void ToggleTextured() const { m_bTextured = !m_bTextured; } + void ToggleCulling() const { m_bCulling = !m_bCulling; } + void ToggleGrid() const { m_bGrid = !m_bGrid; } + void ToggleAxes() const { m_bAxes = !m_bAxes; } + void ToggleNormals() const { m_bNormals = !m_bNormals; } + void ToggleAnimation() const { m_bAnimation = !m_bAnimation; } + void ToggleSampleAlphaToCoverage() const { m_bSampleAlphaToCoverage = !m_bSampleAlphaToCoverage; } + void ToggleAutoRotation() const { m_bAutoRotate = !m_bAutoRotate; } + + static bool m_bDrawMeshes; + static bool m_bDrawJoints; + static bool m_bWireFrame; + static bool m_bTextured; + static bool m_bCulling; + static bool m_bAxes; + static bool m_bGrid; + static bool m_bNormals; + static bool m_bAnimation; + static bool m_bSampleAlphaToCoverage; + static bool m_bAutoRotate; +}; + +#endif diff --git a/Loader/XSkeleton.cpp b/Loader/XSkeleton.cpp new file mode 100644 index 000000000..e192f0250 --- /dev/null +++ b/Loader/XSkeleton.cpp @@ -0,0 +1,201 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#include +#include + +#ifdef WIN32 + #define WIN32_LEAN_AND_MEAN + #include + #include +#else +#include +#include "mm_malloc.h" +#endif + +#include "XSkeleton.h" + +XSkeleton::XSkeleton(void) +{ + m_jointNameHashes = NULL; + m_parentIndices = NULL; + + m_bindXforms = NULL; + m_animXforms = NULL; + m_animVisibility = NULL; + + m_worldMatrices = NULL; +} + +XSkeleton::~XSkeleton(void) +{ + if ( m_jointNameHashes ) + free( m_jointNameHashes ); + if ( m_parentIndices ) + free( m_parentIndices ); + + if ( m_bindXforms ) + _mm_free( m_bindXforms ); + if ( m_animXforms ) + _mm_free( m_animXforms ); + if ( m_animVisibility ) + delete m_animVisibility; + + if ( m_worldMatrices ) + _mm_free( m_worldMatrices ); +} + +std::istream& operator >> (std::istream& ifs, XSkeleton &s) +{ + char buffer[256]; + unsigned int temp; + int iTemp; + + ifs >> buffer; assert( strcmp( buffer, "numJoints" ) == 0 ); + ifs >> s.m_numJoints; + + if ( s.m_numJoints > 0 ) + { + s.m_jointNameHashes = (uint*)calloc( s.m_numJoints, sizeof( uint ) ); + s.m_parentIndices = (int*)calloc( s.m_numJoints, sizeof( int ) ); + + s.m_bindXforms = (XTransformation*)_mm_malloc( sizeof(XTransformation)*s.m_numJoints, 16 ); + s.m_animXforms = (XTransformation*)_mm_malloc( sizeof(XTransformation)*s.m_numJoints, 16 ); + s.m_animVisibility = new bool[ s.m_numJoints ]; + + s.m_worldMatrices = (Matrix4*)_mm_malloc( sizeof(Matrix4)*s.m_numJoints, 16 ); + + for ( unsigned int i = 0; i < s.m_numJoints; i++ ) + { + ifs >> buffer; assert( strcmp( buffer, "JOINT" ) == 0 ); + ifs >> buffer; + s.m_jointNames.push_back( std::string( buffer ) ); + + ifs >> buffer; assert( strcmp( buffer, "nameHash" ) == 0 ); + ifs >> temp; + //s.m_jointNameHashes.push_back( temp ); + s.m_jointNameHashes[i] = temp; + + ifs >> buffer; assert( strcmp( buffer, "parentIndex" ) == 0 ); + ifs >> iTemp; + //s.m_parentIndices.push_back( iTemp ); + s.m_parentIndices[i] = iTemp; + + // read transformations + ifs >> buffer; assert( strcmp( buffer, "Transformation" ) == 0 ); + ifs >> s.m_bindXforms[i]; + + s.m_animXforms[i] = s.m_bindXforms[i]; + s.m_animVisibility[i] = s.m_bindXforms[i].m_Visibility; + } + } + + return ifs; +} + +void XSkeleton::updateWorldMatrices(const XTransformation& rootXform, bool rootVisibility) +{ + Matrix4 parentMatrix = rootXform.asMatrix(); + Matrix4 localMatrix = m_animXforms[0].asMatrix(); + m_worldMatrices[0] = parentMatrix * localMatrix; + m_animVisibility[0] = rootVisibility && m_animXforms[0].m_Visibility; + for ( uint i = 1; i < m_numJoints; i++ ) + { + int parentIndex = m_parentIndices[i]; + parentMatrix = m_worldMatrices[ parentIndex ]; + localMatrix = m_animXforms[i].asMatrix(); + m_worldMatrices[i] = parentMatrix * localMatrix; + + //printf("============================================\n"); + //std::cout << m_jointNames[i].c_str() << std::endl; + //printf("============================================\n"); + //printf("m_worldMatrices\n"); + //print( m_worldMatrices[i] ); + //printf("============================================\n"); + + m_animVisibility[i] = m_animVisibility[ parentIndex ] && m_animXforms[i].m_Visibility; + } +} + +Matrix4 XSkeleton::getJointWorldMatrix(uint jointNameHash) +{ + for ( uint i = 0; i < m_numJoints; i++ ) + { + if ( m_jointNameHashes[i] == jointNameHash ) + return m_worldMatrices[i]; + } + cerr << "Error! Joint with hash " << jointNameHash << " was not found." << endl; + assert(0); exit(1); + + return Matrix4(); +} + +bool XSkeleton::getJointVisibility(uint jointNameHash) +{ + for ( uint i = 0; i < m_numJoints; i++ ) + { + if ( m_jointNameHashes[i] == jointNameHash ) + return m_animVisibility[i]; + } + cerr << "Error! Joint with hash " << jointNameHash << " was not found." << endl; + assert(0); exit(1); + + return false; +} + +void XSkeleton::draw(const Matrix4& rootMatrix) +{ + glPushMatrix(); + glMultMatrixf( (float*)&rootMatrix ); + for ( uint i = 1; i < m_numJoints; i++ ) + { + int parentIndex = m_parentIndices[i]; + Matrix4 parentMatrix = m_worldMatrices[ parentIndex ]; + XTransformation* localXform = &m_animXforms[i]; + + glPushMatrix(); + glMultMatrixf( (float*)&parentMatrix ); + glDisable(GL_LIGHTING); + glDisable(GL_TEXTURE_2D); + + glColor3f(0.4f,0.8f,0.8f); + //glColor3fv( colors[ (m_ID-1) % 6 ] ); + + glBegin(GL_LINES); + glVertex3f(0.001f,0.001f,0.001f); + glVertex3fv( (float*)&localXform->m_Translation ); + glEnd(); + + //glutWireSphere(1,4,4); + + glPopMatrix(); + } + glPopMatrix(); +} + +void XSkeleton::updateXform(uint jointNameHash, const XTransformation& transformation) +{ + for ( uint i = 0; i < m_numJoints; i++ ) + { + if ( m_jointNameHashes[i] == jointNameHash ) + { + m_animXforms[i] = transformation; + return; + } + } + cerr << "Error! Joint with hash " << jointNameHash << " was not found." << endl; + assert(0); exit(1); +} diff --git a/Loader/XSkeleton.h b/Loader/XSkeleton.h new file mode 100644 index 000000000..053423b3c --- /dev/null +++ b/Loader/XSkeleton.h @@ -0,0 +1,59 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#pragma once + +#include +#include +#include + +#include "I16Aligned.h" +#include "XTransformation.h" +#include "../SharedStructures.h" + +using namespace std; + +class XSkeleton : public Skeleton, public I16Aligned +{ + friend std::istream& operator >> (std::istream& ifs, XSkeleton &s); + +public: + vector m_jointNames; + + XTransformation* m_bindXforms; + XTransformation* m_animXforms; + bool* m_animVisibility; + + Matrix4* m_worldMatrices; + + XSkeleton(void); + ~XSkeleton(void); + + // update world matricies for each joint + void updateWorldMatrices(const XTransformation& rootXform, bool rootVisibility); + + // return world metrix for a joint + Matrix4 getJointWorldMatrix(uint jointNameHash); + + // return visibility of a joint + bool getJointVisibility(uint jointNameHash); + + // draw skeleton for debug + void draw(const Matrix4& rootMatrix); + + // update joint transformation + void updateXform(uint jointNameHash, const XTransformation& transformation); +}; diff --git a/Loader/XTextureFile.cpp b/Loader/XTextureFile.cpp new file mode 100644 index 000000000..1372c2461 --- /dev/null +++ b/Loader/XTextureFile.cpp @@ -0,0 +1,199 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#include "XTextureFile.h" +#include "GLExtensions.h" + +#ifdef WIN32 +#define FOPEN fopen_s +#define SPRINTF sprintf_s +#else +#define FOPEN fopen +#define SPRINTF sprintf +#endif + +void loadCompressedTexture( unsigned int texObjID, const char *filename ) +{ + // NOTE: Unlike "lena.bmp", "lena.dds" actually contains its own mip-map + // levels, which are also compressed. + DDS_IMAGE_DATA *pDDSImageData = loadDDSTextureFile( filename ); + + if( pDDSImageData != NULL ) + { + int nHeight = pDDSImageData->height; + int nWidth = pDDSImageData->width; + int nNumMipMaps = pDDSImageData->numMipMaps; + + int nBlockSize; + + if( pDDSImageData->format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT ) + nBlockSize = 8; + else + nBlockSize = 16; + + //glGenTextures( 1, &texObjID ); + glBindTexture( GL_TEXTURE_2D, texObjID ); + + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + + int nSize; + int nOffset = 0; + + // Load the mip-map levels + + for( int i = 0; i < nNumMipMaps; ++i ) + { + if( nWidth == 0 ) nWidth = 1; + if( nHeight == 0 ) nHeight = 1; + + nSize = ((nWidth+3)/4) * ((nHeight+3)/4) * nBlockSize; + + glCompressedTexImage2D( GL_TEXTURE_2D, + i, + pDDSImageData->format, + nWidth, + nHeight, + 0, + nSize, + pDDSImageData->pixels + nOffset ); + + nOffset += nSize; + + // Half the image size for the next mip-map level... + nWidth = (nWidth / 2); + nHeight = (nHeight / 2); + } + } + + if( pDDSImageData != NULL ) + { + if( pDDSImageData->pixels != NULL ) + free( pDDSImageData->pixels ); + + free( pDDSImageData ); + } +} + +DDS_IMAGE_DATA* loadDDSTextureFile( const char *filename ) +{ + DDS_IMAGE_DATA *pDDSImageData; + DDSURFACEDESC2_32BIT ddsd; + char filecode[4]; + FILE *pFile; + int factor; + int bufferSize; + +#ifdef WIN32 + // Open the file + FOPEN( &pFile, filename, "rb" ); +#else + pFile = FOPEN( filename, "rb" ); +#endif + + if( pFile == NULL ) + { + printf( "loadDDSTextureFile couldn't find, or failed to load \"%s\" \n", filename ); + return NULL; + } + + // Verify the file is a true .dds file + fread( filecode, 1, 4, pFile ); + + if( strncmp( filecode, "DDS ", 4 ) != 0 ) + { + printf( "The file \"%s\" doesn't appear to be a valid .dds file! \n", filename ); + fclose( pFile ); + return NULL; + } + +// printf("LONG %d\n", sizeof(LONG)); +// printf("DWORD %d\n", sizeof(DWORD)); +// printf("WORD %d\n", sizeof(WORD)); +// printf("ddsd %d\n", sizeof(ddsd)); + + + // Get the surface descriptor + fread( &ddsd, sizeof(ddsd), 1, pFile ); + + pDDSImageData = (DDS_IMAGE_DATA*) malloc(sizeof(DDS_IMAGE_DATA)); + + memset( pDDSImageData, 0, sizeof(DDS_IMAGE_DATA) ); + + // + // This .dds loader supports the loading of compressed formats DXT1, DXT3 + // and DXT5. + // + + switch( ddsd.ddpfPixelFormat.dwFourCC ) + { + case FOURCC_DXT1: + // DXT1's compression ratio is 8:1 + pDDSImageData->format = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; + factor = 2; + break; + + case FOURCC_DXT3: + // DXT3's compression ratio is 4:1 + pDDSImageData->format = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; + factor = 4; + break; + + case FOURCC_DXT5: + // DXT5's compression ratio is 4:1 + pDDSImageData->format = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; + factor = 4; + break; + + default: + printf( "The file \"%s\" doesn't appear to be compressed " + "using DXT1, DXT3, or DXT5! \n", filename ); + return NULL; + } + + // + // How big will the buffer need to be to load all of the pixel data + // including mip-maps? + // + + if( ddsd.dwLinearSize == 0 ) + { + //MessageBox( NULL, "dwLinearSize is 0!","ERROR", MB_OK|MB_ICONEXCLAMATION); + } + + if( ddsd.dwMipMapCount > 1 ) + bufferSize = ddsd.dwLinearSize * factor; + else + bufferSize = ddsd.dwLinearSize; + + pDDSImageData->pixels = (unsigned char*)malloc(bufferSize * sizeof(unsigned char)); + + fread( pDDSImageData->pixels, 1, bufferSize, pFile ); + + // Close the file + fclose( pFile ); + + pDDSImageData->width = ddsd.dwWidth; + pDDSImageData->height = ddsd.dwHeight; + pDDSImageData->numMipMaps = ddsd.dwMipMapCount; + + if( ddsd.ddpfPixelFormat.dwFourCC == FOURCC_DXT1 ) + pDDSImageData->components = 3; + else + pDDSImageData->components = 4; + + return pDDSImageData; +} diff --git a/Loader/XTextureFile.h b/Loader/XTextureFile.h new file mode 100644 index 000000000..664870511 --- /dev/null +++ b/Loader/XTextureFile.h @@ -0,0 +1,195 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#pragma once + +#include +#include +#include + +struct DDS_IMAGE_DATA +{ + int width; + int height; + int components; + unsigned int format; + int numMipMaps; + unsigned char* pixels; +}; + +#ifdef WIN32 + #define WIN32_LEAN_AND_MEAN + #include + #include // Required for DirectX's DDSURFACEDESC2 structure definition +#else // Mac OS + // define types for DDSURFACEDESC2_32BIT + #define LONG int + #define DWORD unsigned int + #define WORD unsigned short + #define BYTE unsigned char + #define DUMMYUNIONNAMEN(n) //u##n + + #ifndef MAKEFOURCC + #define MAKEFOURCC(ch0, ch1, ch2, ch3) \ + ((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \ + ((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 )) + #endif + + /* + * FOURCC codes for DX compressed-texture pixel formats + */ + #define FOURCC_DXT1 (MAKEFOURCC('D','X','T','1')) + #define FOURCC_DXT2 (MAKEFOURCC('D','X','T','2')) + #define FOURCC_DXT3 (MAKEFOURCC('D','X','T','3')) + #define FOURCC_DXT4 (MAKEFOURCC('D','X','T','4')) + #define FOURCC_DXT5 (MAKEFOURCC('D','X','T','5')) + + /* + * DDPIXELFORMAT + */ + typedef struct _DDPIXELFORMAT + { + DWORD dwSize; // size of structure + DWORD dwFlags; // pixel format flags + DWORD dwFourCC; // (FOURCC code) + union + { + DWORD dwRGBBitCount; // how many bits per pixel + DWORD dwYUVBitCount; // how many bits per pixel + DWORD dwZBufferBitDepth; // how many total bits/pixel in z buffer (including any stencil bits) + DWORD dwAlphaBitDepth; // how many bits for alpha channels + DWORD dwLuminanceBitCount; // how many bits per pixel + DWORD dwBumpBitCount; // how many bits per "buxel", total + DWORD dwPrivateFormatBitCount;// Bits per pixel of private driver formats. Only valid in texture + // format list and if DDPF_D3DFORMAT is set + } DUMMYUNIONNAMEN(1); + union + { + DWORD dwRBitMask; // mask for red bit + DWORD dwYBitMask; // mask for Y bits + DWORD dwStencilBitDepth; // how many stencil bits (note: dwZBufferBitDepth-dwStencilBitDepth is total Z-only bits) + DWORD dwLuminanceBitMask; // mask for luminance bits + DWORD dwBumpDuBitMask; // mask for bump map U delta bits + DWORD dwOperations; // DDPF_D3DFORMAT Operations + } DUMMYUNIONNAMEN(2); + union + { + DWORD dwGBitMask; // mask for green bits + DWORD dwUBitMask; // mask for U bits + DWORD dwZBitMask; // mask for Z bits + DWORD dwBumpDvBitMask; // mask for bump map V delta bits + struct + { + WORD wFlipMSTypes; // Multisample methods supported via flip for this D3DFORMAT + WORD wBltMSTypes; // Multisample methods supported via blt for this D3DFORMAT + } MultiSampleCaps; + + } DUMMYUNIONNAMEN(3); + union + { + DWORD dwBBitMask; // mask for blue bits + DWORD dwVBitMask; // mask for V bits + DWORD dwStencilBitMask; // mask for stencil bits + DWORD dwBumpLuminanceBitMask; // mask for luminance in bump map + } DUMMYUNIONNAMEN(4); + union + { + DWORD dwRGBAlphaBitMask; // mask for alpha channel + DWORD dwYUVAlphaBitMask; // mask for alpha channel + DWORD dwLuminanceAlphaBitMask;// mask for alpha channel + DWORD dwRGBZBitMask; // mask for Z channel + DWORD dwYUVZBitMask; // mask for Z channel + } DUMMYUNIONNAMEN(5); + } DDPIXELFORMAT; + + /* + * DDCOLORKEY + */ + typedef struct _DDCOLORKEY + { + DWORD dwColorSpaceLowValue; // low boundary of color space that is to + // be treated as Color Key, inclusive + DWORD dwColorSpaceHighValue; // high boundary of color space that is + // to be treated as Color Key, inclusive + } DDCOLORKEY; + + /* + * DDSCAPS2 + */ + typedef struct _DDSCAPS2 + { + DWORD dwCaps; // capabilities of surface wanted + DWORD dwCaps2; + DWORD dwCaps3; + union + { + DWORD dwCaps4; + DWORD dwVolumeDepth; + } DUMMYUNIONNAMEN(1); + } DDSCAPS2; + +#endif + +// workaround for DDS load issue on 64 bit system +typedef struct _DDSURFACEDESC2_32BIT +{ + DWORD dwSize; // size of the DDSURFACEDESC structure + DWORD dwFlags; // determines what fields are valid + DWORD dwHeight; // height of surface to be created + DWORD dwWidth; // width of input surface +union +{ + LONG lPitch; // distance to start of next line (return value only) + DWORD dwLinearSize; // Formless late-allocated optimized surface size +} DUMMYUNIONNAMEN( 1 ); +union +{ + DWORD dwBackBufferCount; // number of back buffers requested + DWORD dwDepth; // the depth if this is a volume texture +} DUMMYUNIONNAMEN( 5 ); +union +{ + DWORD dwMipMapCount; // number of mip-map levels requestde + // dwZBufferBitDepth removed, use ddpfPixelFormat one instead + DWORD dwRefreshRate; // refresh rate (used when display mode is described) + DWORD dwSrcVBHandle; // The source used in VB::Optimize +} DUMMYUNIONNAMEN( 2 ); +DWORD dwAlphaBitDepth; // depth of alpha buffer requested +DWORD dwReserved; // reserved +DWORD lpSurface32; // this ptr isn't 64bit safe in the ddraw.h header +union +{ + DDCOLORKEY ddckCKDestOverlay; // color key for destination overlay use + DWORD dwEmptyFaceColor; // Physical color for empty cubemap faces +} DUMMYUNIONNAMEN( 3 ); +DDCOLORKEY ddckCKDestBlt; // color key for destination blt use +DDCOLORKEY ddckCKSrcOverlay; // color key for source overlay use +DDCOLORKEY ddckCKSrcBlt; // color key for source blt use +union +{ + DDPIXELFORMAT ddpfPixelFormat; // pixel format description of the surface + DWORD dwFVF; // vertex format description of vertex buffers +} DUMMYUNIONNAMEN( 4 ); +DDSCAPS2 ddsCaps; // direct draw surface capabilities +DWORD dwTextureStage; // stage in multitexture cascade +} DDSURFACEDESC2_32BIT; + +// functions +DDS_IMAGE_DATA* loadDDSTextureFile( const char *filename ); +void loadCompressedTexture( unsigned int texObjID, const char *filename ); + + + diff --git a/Loader/XTransformation.cpp b/Loader/XTransformation.cpp new file mode 100644 index 000000000..635123379 --- /dev/null +++ b/Loader/XTransformation.cpp @@ -0,0 +1,82 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#include + +#include "XTransformation.h" + +XTransformation::~XTransformation(void) +{ +} + +std::istream &operator >> (std::istream &ifs, Quat &v) +{ + float x,y,z,w; + ifs >> x >> y >> z >> w; + //v = Quat( x, y, z, w ); + v = Quat( x, y, z, w ); + return ifs; +} + +std::istream &operator >> (std::istream &ifs,Matrix4 &m) +{ + //ifs >> m.m_00 >> m.m_01 >> m.m_02 >> m.m_03; + //ifs >> m.m_10 >> m.m_11 >> m.m_12 >> m.m_13; + //ifs >> m.m_20 >> m.m_21 >> m.m_22 >> m.m_23; + //ifs >> m.m_30 >> m.m_31 >> m.m_32 >> m.m_33; + float f; + for ( int i = 0; i < 4; i++ ) + { + for ( int j = 0; j < 4; j++ ) + { + ifs >> f; + m.setElem(i, j, f); + } + } + return ifs; +} + +std::istream &operator >> (std::istream &ifs, Vector3 &v) +{ + float x,y,z; + ifs >> x >> y >> z; + v = Vector3( x, y, z ); + return ifs; +} + +/// stream extraction operator +std::istream& operator >> (std::istream& ifs, XTransformation &xf) +{ + unsigned int vis; + ifs >> vis; + xf.m_Visibility = vis ? true : false; + // read rotation translation and scale + ifs >> xf.m_Rotation; + ifs >> xf.m_Translation; + ifs >> xf.m_Scale; + return ifs; +} + + +XTransformation LERP(const float t, const XTransformation &t1, const XTransformation &t2) +{ + XTransformation out; + out.m_Rotation = slerp( t, t1.m_Rotation, t2.m_Rotation ); + out.m_Translation = lerp( t, t1.m_Translation, t2.m_Translation ); + out.m_Scale = lerp( t, t1.m_Scale, t2.m_Scale ); + return out; +} + diff --git a/Loader/XTransformation.h b/Loader/XTransformation.h new file mode 100644 index 000000000..c25bf55c9 --- /dev/null +++ b/Loader/XTransformation.h @@ -0,0 +1,197 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#pragma once + +#include +#include "I16Aligned.h" +#ifdef WIN32 +#include +#else +#include +#endif +using namespace Vectormath::Aos; + +class XTransformation + : public I16Aligned +{ +public: + + /// stream extraction operator + friend std::istream& operator>>(std::istream&,XTransformation &); + + /// \brief This function linearly interpolates the transform, however it + /// performs a Sphereical interpolation on the rotation components. + /// \param out - the output transform + /// \param t - the interpolation value + /// \param t1 - the first transform + /// \param t2 - the second transform + /// + friend XTransformation LERP(const float, const XTransformation&, const XTransformation&); + + const XTransformation& operator = (const XTransformation& T) + { + m_Rotation = T.m_Rotation; + m_Translation = T.m_Translation; + m_Scale = T.m_Scale; + m_Visibility = T.m_Visibility; + return *this; + } + + + ///------------------------------------------------------------------------- + /// \brief ctor + /// + XTransformation() + : m_Rotation( Quat::identity() ), + m_Translation( Vector3(0.0f) ), + m_Scale(1.0f,1.0f,1.0f), + m_Visibility(true) + { + } + + ///------------------------------------------------------------------------- + /// \brief A slightly more intersting ctor + /// \param r - the rotation quaternion for this transform + /// \param t - the translation for this transform + /// \param s - the scale for this transform + /// + XTransformation( const Quat& r, + const Vector3& t, + const Vector3& s ) + : m_Rotation(r), + m_Translation(t), + m_Scale(s), + m_Visibility(true) + { + } + + ///------------------------------------------------------------------------- + /// \brief The copy constructor for the transform types + /// \param rhs - the copied argument + /// + XTransformation( const XTransformation& rhs) + : m_Rotation(rhs.m_Rotation), + m_Translation(rhs.m_Translation), + m_Scale(rhs.m_Scale), + m_Visibility(rhs.m_Visibility) + { + } + + ~XTransformation(void); + + inline Matrix4 asMatrix() const + { + Matrix4 M = Matrix4( m_Rotation, m_Translation ); + return appendScale( M, m_Scale ); + } + + Quat m_Rotation; + Vector3 m_Translation; + Vector3 m_Scale; + + bool m_Visibility; + +}; + +class XTimeInfo +{ +public: + + /// the constructor + XTimeInfo() + { + memset(this,0,sizeof(XTimeInfo)); + } + + ///------------------------------------------------------------------------- + /// \brief this function is used to initialised the time control class. + /// \param start - the start time (in seconds) for the animation. + /// \param end - the end time (in seconds) for the animation + /// \param numframes - the number of frames in the cycle + /// + void Initialise(const float start,const float end,const unsigned int numframes) + { + m_iNumFrames = numframes; + m_fStart = start; + m_fEnd = end; + m_fLength = end-start; + m_fFrameTime = m_fLength/numframes; + m_fCurrTime = start; + } + + ///------------------------------------------------------------------------- + /// \brief This function updates the time by the specified delta + /// \param dt - difference in time + /// + void Update(const float dt) + { + m_fCurrTime += dt; + + while(m_fCurrTime > m_fEnd) + { + m_fCurrTime -= m_fLength; + } + } + + ///------------------------------------------------------------------------- + /// \brief this function returns the current frame number + /// \return the frame index + /// + inline unsigned int GetFrameNum() const + { + return (unsigned int)( (float)(m_fCurrTime - m_fStart)/m_fFrameTime ); + } + + ///------------------------------------------------------------------------- + /// \brief this function returns the interpolation t for the current frame. + /// ie, interpolate frame n and n+1 by frameT + /// + inline const float GetFrameT() const + { + return fmodf( m_fCurrTime - m_fStart, m_fFrameTime ) / m_fFrameTime; + } + + + ///------------------------------------------------------------------------- + /// \brief This function returns the t value over the whole animation length + /// + inline const float GetInterpolatingT() const + { + return (m_fCurrTime-m_fStart)/m_fLength; + } + + /// the number of frames in the cycle + unsigned int m_iNumFrames; + +protected: + + /// the time in seconds between each frame in the cycle. + float m_fFrameTime; + + /// the start time of the animation. + float m_fStart; + + /// the end time of the animation + float m_fEnd; + + /// the length (in seconds) of the animation + float m_fLength; + + /// the current time in seconds + float m_fCurrTime; + +}; diff --git a/Loader/ik2Bsolver/AwMath.h b/Loader/ik2Bsolver/AwMath.h new file mode 100644 index 000000000..6cfcefdd0 --- /dev/null +++ b/Loader/ik2Bsolver/AwMath.h @@ -0,0 +1,42 @@ +#ifndef _AwMath +#define _AwMath +//- +// ========================================================================== +// Copyright 1995,2006,2008 Autodesk, Inc. All rights reserved. +// +// Use of this software is subject to the terms of the Autodesk +// license agreement provided at the time of installation or download, +// or which otherwise accompanies this software in either electronic +// or hard copy form. +// ========================================================================== +//+ +// +// AwMath +// +// ***************************************************************************** +#include + +#define kFloatEpsilon 1.0e-5F +#define kDoubleEpsilon 1.0e-10 +#define kDoubleEpsilonSqr 1.0e-20 +#define kExtendedEpsilon kDoubleEpsilon +#define kPi 3.14159265358979323846264338327950 + +#if COMPILER_NEEDS_BOOL_TYPEDEF +typedef char bool; +#define true 1 +#define false 0 +#endif + +inline bool equivalent(double x, double y, double fudge = kDoubleEpsilon) +{ + return ((x > y) ? (x - y <= fudge) : (y - x <= fudge)); +} + +inline double clamp(double a, double l, double h) +{ + return ((a) < (l) ? (l) : (a) > (h) ? (h) : (a)); +} + +#endif /* _AwMath */ + diff --git a/Loader/ik2Bsolver/AwMatrix.cpp b/Loader/ik2Bsolver/AwMatrix.cpp new file mode 100644 index 000000000..ef7f60dc9 --- /dev/null +++ b/Loader/ik2Bsolver/AwMatrix.cpp @@ -0,0 +1,461 @@ +//- +// ========================================================================== +// Copyright 1995,2006,2008 Autodesk, Inc. All rights reserved. +// +// Use of this software is subject to the terms of the Autodesk +// license agreement provided at the time of installation or download, +// or which otherwise accompanies this software in either electronic +// or hard copy form. +// ========================================================================== +//+ +// +// CLASS: AwMatrix +// +// ***************************************************************************** +// +// CLASS DESCRIPTION (AwMatrix) +// +// This class is a standard 4x4 double matrix. Simple operations +// such as multiplication, inversion and transposition are supported. +// An indexing function is supplied, but if required, users can +// access the matrix elements directly. +// +// ***************************************************************************** + +#include +#include +#include + +#include +#include +#include +#include + +#define DET2X2(a,b,c,d) (a*d-b*c) + +#define DET3X3(a1,a2,a3,b1,b2,b3,c1,c2,c3) /* | a1 b1 c1 | */ \ + ( a1 * DET2X2( b2, b3, c2, c3 ) /* | a2 b2 c2 | */ \ + - b1 * DET2X2( a2, a3, c2, c3 ) /* | a3 b3 c3 | */ \ + + c1 * DET2X2( a2, a3, b2, b3 ) ) + +// Initialize constant +// +const AwMatrix AwMatrix::identity; + +AwMatrix &AwMatrix::setToIdentity() +// +// Description: +// Sets the matrix to the identity. +// +{ + matrix[0][0] = 1.0; + matrix[0][1] = 0.0; + matrix[0][2] = 0.0; + matrix[0][3] = 0.0; + matrix[1][0] = 0.0; + matrix[1][1] = 1.0; + matrix[1][2] = 0.0; + matrix[1][3] = 0.0; + matrix[2][0] = 0.0; + matrix[2][1] = 0.0; + matrix[2][2] = 1.0; + matrix[2][3] = 0.0; + matrix[3][0] = 0.0; + matrix[3][1] = 0.0; + matrix[3][2] = 0.0; + matrix[3][3] = 1.0; + + return *this; +} + +AwMatrix AwMatrix::operator*(const AwMatrix &right) const +// +// Description: +// Returns the matrix that is the inner product of the two argument matrices. +// +// Note: +// This routine has been hand scheduled for MIPS R4x00 CPU's +// Don't rearrange this code unless you know what your doing. +// +{ + AwMatrix result; + double *a = (double *) result.matrix; + double *b = (double *) this->matrix; + double *c = (double *) right.matrix; + + register double i0, i1, i2, i3, i4, i5, i6, i7; + + if (a == c) { + register double c0, c4, c8, c12; + + c0 = c[0]; c4 = c[4]; c8 = c[8]; c12 = c[12]; + i0 = b[0] * c0; i1 = b[1] * c4; i2 = b[2] * c8; i3 = b[3] * c12; + i4 = b[4] * c0; i5 = b[5] * c4; i6 = b[6] * c8; i7 = b[7] * c12; + a[0] = i0 + i1 + i2 + i3; + a[4] = i4 + i5 + i6 + i7; + + i0 = b[8] * c0; i1 = b[9] * c4; i2 = b[10] * c8; i3 = b[11] * c12; + i4 = b[12] * c0; i5 = b[13] * c4; i6 = b[14] * c8; i7 = b[15] * c12; + a[8] = i0 + i1 + i2 + i3; + a[12] = i4 + i5 + i6 + i7; + + c0 = c[1]; c4 = c[5]; c8 = c[9]; c12 = c[13]; + i0 = b[0] * c0; i1 = b[1] * c4; i2 = b[2] * c8; i3 = b[3] * c12; + i4 = b[4] * c0; i5 = b[5] * c4; i6 = b[6] * c8; i7 = b[7] * c12; + a[1] = i0 + i1 + i2 + i3; + a[5] = i4 + i5 + i6 + i7; + + i0 = b[8] * c0; i1 = b[9] * c4; i2 = b[10] * c8; i3 = b[11] * c12; + i4 = b[12] * c0; i5 = b[13] * c4; i6 = b[14] * c8; i7 = b[15] * c12; + a[9] = i0 + i1 + i2 + i3; + a[13] = i4 + i5 + i6 + i7; + + c0 = c[2]; c4 = c[6]; c8 = c[10]; c12 = c[14]; + i0 = b[0] * c0; i1 = b[1] * c4; i2 = b[2] * c8; i3 = b[3] * c12; + i4 = b[4] * c0; i5 = b[5] * c4; i6 = b[6] * c8; i7 = b[7] * c12; + a[2] = i0 + i1 + i2 + i3; + a[6] = i4 + i5 + i6 + i7; + + i0 = b[8] * c0; i1 = b[9] * c4; i2 = b[10] * c8; i3 = b[11] * c12; + i4 = b[12] * c0; i5 = b[13] * c4; i6 = b[14] * c8; i7 = b[15] * c12; + a[10] = i0 + i1 + i2 + i3; + a[14] = i4 + i5 + i6 + i7; + + c0 = c[3]; c4 = c[7]; c8 = c[11]; c12 = c[15]; + i0 = b[0] * c0; i1 = b[1] * c4; i2 = b[2] * c8; i3 = b[3] * c12; + i4 = b[4] * c0; i5 = b[5] * c4; i6 = b[6] * c8; i7 = b[7] * c12; + a[3] = i0 + i1 + i2 + i3; + a[7] = i4 + i5 + i6 + i7; + + i0 = b[8] * c0; i1 = b[9] * c4; i2 = b[10] * c8; i3 = b[11] * c12; + i4 = b[12] * c0; i5 = b[13] * c4; i6 = b[14] * c8; i7 = b[15] * c12; + a[11] = i0 + i1 + i2 + i3; + a[15] = i4 + i5 + i6 + i7; + + } else { + register double b0, b1, b2, b3; + + b0 = b[0]; b1 = b[1]; b2 = b[2]; b3 = b[3]; + i0 = b0 * c[0]; i1 = b1 * c[4]; i2 = b2 * c[8]; i3 = b3 * c[12]; + i4 = b0 * c[1]; i5 = b1 * c[5]; i6 = b2 * c[9]; i7 = b3 * c[13]; + a[0] = i0 + i1 + i2 + i3; + a[1] = i4 + i5 + i6 + i7; + + i0 = b0 * c[2]; i1 = b1 * c[6]; i2 = b2 * c[10]; i3 = b3 * c[14]; + i4 = b0 * c[3]; i5 = b1 * c[7]; i6 = b2 * c[11]; i7 = b3 * c[15]; + a[2] = i0 + i1 + i2 + i3; + a[3] = i4 + i5 + i6 + i7; + + b0 = b[4]; b1 = b[5]; b2 = b[6]; b3 = b[7]; + i0 = b0 * c[0]; i1 = b1 * c[4]; i2 = b2 * c[8]; i3 = b3 * c[12]; + i4 = b0 * c[1]; i5 = b1 * c[5]; i6 = b2 * c[9]; i7 = b3 * c[13]; + a[4] = i0 + i1 + i2 + i3; + a[5] = i4 + i5 + i6 + i7; + + i0 = b0 * c[2]; i1 = b1 * c[6]; i2 = b2 * c[10]; i3 = b3 * c[14]; + i4 = b0 * c[3]; i5 = b1 * c[7]; i6 = b2 * c[11]; i7 = b3 * c[15]; + a[6] = i0 + i1 + i2 + i3; + a[7] = i4 + i5 + i6 + i7; + + b0 = b[8]; b1 = b[9]; b2 = b[10]; b3 = b[11]; + i0 = b0 * c[0]; i1 = b1 * c[4]; i2 = b2 * c[8]; i3 = b3 * c[12]; + i4 = b0 * c[1]; i5 = b1 * c[5]; i6 = b2 * c[9]; i7 = b3 * c[13]; + a[8] = i0 + i1 + i2 + i3; + a[9] = i4 + i5 + i6 + i7; + + i0 = b0 * c[2]; i1 = b1 * c[6]; i2 = b2 * c[10]; i3 = b3 * c[14]; + i4 = b0 * c[3]; i5 = b1 * c[7]; i6 = b2 * c[11]; i7 = b3 * c[15]; + a[10] = i0 + i1 + i2 + i3; + a[11] = i4 + i5 + i6 + i7; + + b0 = b[12]; b1 = b[13]; b2 = b[14]; b3 = b[15]; + i0 = b0 * c[0]; i1 = b1 * c[4]; i2 = b2 * c[8]; i3 = b3 * c[12]; + i4 = b0 * c[1]; i5 = b1 * c[5]; i6 = b2 * c[9]; i7 = b3 * c[13]; + a[12] = i0 + i1 + i2 + i3; + a[13] = i4 + i5 + i6 + i7; + + i0 = b0 * c[2]; i1 = b1 * c[6]; i2 = b2 * c[10]; i3 = b3 * c[14]; + i4 = b0 * c[3]; i5 = b1 * c[7]; i6 = b2 * c[11]; i7 = b3 * c[15]; + a[14] = i0 + i1 + i2 + i3; + a[15] = i4 + i5 + i6 + i7; + } + + return result; +} + +AwMatrix &AwMatrix::invertIt() +// +// Description: +// Sets the matrix to be its own inverse. +// +// Notes: +// If the matrix is singular, return the identity matrix; +// +{ + // Create an identity matrix on which to mirror all of our operations. + // The identity matrix is it's own inverse. + // + AwMatrix inv; + + int i, j, k; + double factor, divisor, temp; + + // phase one: eliminate all the numbers under the diagonal. This is done + // in a loop, considering successively smaller matrices as the top-left + // corner of each is set to 1. (This does not need to be done for the + // last row, clearly) + // + for (i = 0; i < 3; i++) { + // step one: find the largest value in column i; + // swap that row to be row i + // + int bigOne = i; + for (j = i; j < 4; j++){ + if (matrix[j][i] * matrix[j][i] > + matrix[bigOne][i] * matrix[bigOne][i]) { + bigOne = j; + } + } + if (bigOne != i) { + for (j = 0; j < 4; j++) { + temp = matrix[bigOne][j]; + matrix[bigOne][j] = matrix[i][j]; + matrix[i][j] = temp; + temp = inv.matrix[bigOne][j]; + inv.matrix[bigOne][j] = inv.matrix[i][j]; + inv.matrix[i][j] = temp; + } + } + + // step two: by appropriate subtraction, eliminate all the numbers + // under the diagonal element i. Singular elements in the matrix + // are skipped. + // + if (matrix[i][i] > 1.0e-15 || matrix[i][i] < -1.0e-15) { + for (j = i + 1; j < 4; j++) { + factor = matrix[j][i] / matrix[i][i]; + for (k = 0; k < 4; k++) { + matrix[j][k] -= matrix[i][k] * factor; + inv.matrix[j][k] -= inv.matrix[i][k] * factor; + } + // set the column value to exactly zero in case + // numeric roundoff left it a very tiny number + matrix[j][i] = 0.0; + } + } + } + + // phase two: set all the diagonal values to 1 + // + for (i = 0; i < 4; i++) { + divisor = matrix[i][i]; + if (divisor > 1.0e-15 || divisor < -1.0e-15) { + for (j = 0; j < 4; j++) { + matrix[i][j] = matrix[i][j] / divisor; + inv.matrix[i][j] = inv.matrix[i][j] / divisor; + } + // set the diagonal to 1.0 exactly to avoid + // possible round-off error + matrix[i][i] = 1.0; + } + } + + // phase three: eliminate all the zeros above the diagonal + // + for (i = 0; i < 3; i++) { + for (j = i + 1; j < 4; j++) { + factor = matrix[i][j]; + for (k = 0; k < 4; k++) { + matrix[i][k] -= matrix[j][k] * factor; + inv.matrix[i][k] -= inv.matrix[j][k] * factor; + } + matrix[i][j] = 0.0; // in case of round-off error + } + } + + // At this point inv should contain the correct inverse matrix to the + // original matrix we started with. Copy it to this matrix. + // + *this = inv; + return *this; +} + +AwMatrix &AwMatrix::transposeIt() +// +// Description: +// Sets the matrix to be its own transpose. +// +{ + int i, j; + double temp; + for (i = 0; i < 3; i++){ + for (j = i + 1; j < 4; j++) { + temp = matrix[i][j]; + matrix[i][j] = matrix[j][i]; + matrix[j][i] = temp; + } + } + + return *this; +} + +bool AwMatrix::isEquivalent(const AwMatrix &otherM, double tolerance) const +// +// Description: +// This method returns true if this matrix is equal, within some +// given tolerance, to otherM. +// +// Notes: +// tolerance is asserted to be non-negative, and defaults to +// kMatrixEquivalentTolerance. +// +{ + assert(tolerance >= 0.0); + + return ( + fabs(matrix[0][0] - otherM.matrix[0][0]) <= tolerance + && fabs(matrix[0][1] - otherM.matrix[0][1]) <= tolerance + && fabs(matrix[0][2] - otherM.matrix[0][2]) <= tolerance + && fabs(matrix[0][3] - otherM.matrix[0][3]) <= tolerance + && fabs(matrix[1][0] - otherM.matrix[1][0]) <= tolerance + && fabs(matrix[1][1] - otherM.matrix[1][1]) <= tolerance + && fabs(matrix[1][2] - otherM.matrix[1][2]) <= tolerance + && fabs(matrix[1][3] - otherM.matrix[1][3]) <= tolerance + && fabs(matrix[2][0] - otherM.matrix[2][0]) <= tolerance + && fabs(matrix[2][1] - otherM.matrix[2][1]) <= tolerance + && fabs(matrix[2][2] - otherM.matrix[2][2]) <= tolerance + && fabs(matrix[2][3] - otherM.matrix[2][3]) <= tolerance + && fabs(matrix[3][0] - otherM.matrix[3][0]) <= tolerance + && fabs(matrix[3][1] - otherM.matrix[3][1]) <= tolerance + && fabs(matrix[3][2] - otherM.matrix[3][2]) <= tolerance + && fabs(matrix[3][3] - otherM.matrix[3][3]) <= tolerance ); +} + +AwMatrix AwMatrix::operator*(double mult) const +// +// Description: +// This method multiplies the matrix by a constant +// +{ + AwMatrix temp(*this); + temp[0][0] *= mult; temp[0][1] *= mult; + temp[0][2] *= mult; temp[0][3] *= mult; + temp[1][0] *= mult; temp[1][1] *= mult; + temp[1][2] *= mult; temp[1][3] *= mult; + temp[2][0] *= mult; temp[2][1] *= mult; + temp[2][2] *= mult; temp[2][3] *= mult; + temp[3][0] *= mult; temp[3][1] *= mult; + temp[3][2] *= mult; temp[3][3] *= mult; + return temp; +} + +bool AwMatrix::operator==(const AwMatrix &otherM) const +// +// Description: +// This method returns true if this matrix is identically equal to otherM. +// +{ + return ( + matrix[0][0] == otherM.matrix[0][0] + && matrix[0][1] == otherM.matrix[0][1] + && matrix[0][2] == otherM.matrix[0][2] + && matrix[0][3] == otherM.matrix[0][3] + && matrix[1][0] == otherM.matrix[1][0] + && matrix[1][1] == otherM.matrix[1][1] + && matrix[1][2] == otherM.matrix[1][2] + && matrix[1][3] == otherM.matrix[1][3] + && matrix[2][0] == otherM.matrix[2][0] + && matrix[2][1] == otherM.matrix[2][1] + && matrix[2][2] == otherM.matrix[2][2] + && matrix[2][3] == otherM.matrix[2][3] + && matrix[3][0] == otherM.matrix[3][0] + && matrix[3][1] == otherM.matrix[3][1] + && matrix[3][2] == otherM.matrix[3][2] + && matrix[3][3] == otherM.matrix[3][3] ); +} + +double AwMatrix::det3x3() const +// +// Description: +// Return the determinant of the upper-left 3 by 3 submatrix. +// +{ + return (matrix[0][0] * (matrix[1][1] * matrix[2][2] - + matrix[2][1] * matrix[1][2]) - + matrix[0][1] * (matrix[1][0] * matrix[2][2] - + matrix[2][0] * matrix[1][2]) + + matrix[0][2] * (matrix[1][0] * matrix[2][1] - + matrix[2][0] * matrix[1][1])); +} + +double AwMatrix::det4x4() const +// +// Description: +// Return the determinant of this matrix. +// +{ + double a1, a2, a3, a4; + double b1, b2, b3, b4; + double c1, c2, c3, c4; + double d1, d2, d3, d4; + + // assign to individual variable names to aid selecting correct elements + a1 = matrix[0][0]; b1 = matrix[0][1]; c1 = matrix[0][2]; d1 = matrix[0][3]; + a2 = matrix[1][0]; b2 = matrix[1][1]; c2 = matrix[1][2]; d2 = matrix[1][3]; + a3 = matrix[2][0]; b3 = matrix[2][1]; c3 = matrix[2][2]; d3 = matrix[2][3]; + a4 = matrix[3][0]; b4 = matrix[3][1]; c4 = matrix[3][2]; d4 = matrix[3][3]; + + return ( + a1 * DET3X3(b2, b3, b4, c2, c3, c4, d2, d3, d4) - + b1 * DET3X3(a2, a3, a4, c2, c3, c4, d2, d3, d4) + + c1 * DET3X3(a2, a3, a4, b2, b3, b4, d2, d3, d4) - + d1 * DET3X3(a2, a3, a4, b2, b3, b4, c2, c3, c4) + ); +} + +bool AwMatrix::isOrthogonal() const +// +// Description: +// Return true if the upper 3x3 sub-matrix does not +// contain non-proportional scaling or skewing. +// +{ + #define rowdot(i,j) (matrix[i][0]*matrix[j][0] + \ + matrix[i][1]*matrix[j][1] + \ + matrix[i][2]*matrix[j][2]) + #define rownorm(i) (rowdot(i,i)) + + // First, test for non-proportional scales since they will + // occur more frequently than skewing. + // + double norm0 = rownorm(0); + return ( + ::equivalent(rownorm(1), norm0) && // Non-prop scale tests + ::equivalent(rownorm(2), norm0) && + ::equivalent(rowdot(0,1), 0.0) && // Skewing tests + ::equivalent(rowdot(1,2), 0.0) && + ::equivalent(rowdot(0,2), 0.0) + ); + #undef rownorm + #undef rowdot +} + +/*friend*/ ostream &operator<<(ostream &os, const AwMatrix &m) +// +// Description: +// Stream output. +// +{ + os << "["; + for (int i = 0; i < 4; ++i) { + if (i) os << ", "; + os << "["; + for (int j = 0; j < 4; ++j) { + if (j) os << ", "; + os << m[i][j]; + } + os << "]"; + } + os << "]"; + return os; +} diff --git a/Loader/ik2Bsolver/AwMatrix.h b/Loader/ik2Bsolver/AwMatrix.h new file mode 100644 index 000000000..8b144d2cf --- /dev/null +++ b/Loader/ik2Bsolver/AwMatrix.h @@ -0,0 +1,141 @@ +#ifndef _AwMatrix +#define _AwMatrix +//- +// ========================================================================== +// Copyright 1995,2006,2008 Autodesk, Inc. All rights reserved. +// +// Use of this software is subject to the terms of the Autodesk +// license agreement provided at the time of installation or download, +// or which otherwise accompanies this software in either electronic +// or hard copy form. +// ========================================================================== +//+ +// +// CLASS: AwMatrix +// +// ***************************************************************************** +// +// CLASS DESCRIPTION (AwMatrix) +// +// This class is a standard 4x4 double matrix. Simple operations +// such as multiplication, inversion and transposition are supported. +// An indexing function is supplied, but if required, users can +// access the matrix elements directly. +// +// ***************************************************************************** + +#include + +#define kMatrixEquivalentTolerance kDoubleEpsilon + +class AwPoint; +class AwVector; + +class AwMatrix { +public: + AwMatrix(); + AwMatrix(const AwMatrix &src); +//#ifndef COMPILE_OUTSIDE_MAYA +// AwMatrix(const MMatrix &src); +//#endif + ~AwMatrix(); + + AwMatrix &operator=(const AwMatrix &rhs); + + double *operator[](unsigned i); + const double *operator[](unsigned i) const; + double &operator()(short i, short j); + const double &operator()(short i, short j) const; + + AwMatrix operator*(const AwMatrix &right) const; + AwMatrix operator*(double) const; + + bool operator==(const AwMatrix &otherM) const; + bool operator!=(const AwMatrix &otherM) const; + bool isEquivalent(const AwMatrix &otherM, + double tolerance = kMatrixEquivalentTolerance) const; + + AwMatrix &setToIdentity(); + AwMatrix inverse() const; + AwMatrix &invertIt(); + AwMatrix transpose() const; + AwMatrix &transposeIt(); + double det3x3() const; + double det4x4() const; + bool isOrthogonal() const; + + friend ostream &operator<<(ostream &os, const AwMatrix &); + + static const AwMatrix identity; // The multiplicative identity. + + double matrix[4][4]; // [row][column] +}; + +/////////////////////////////////////////////////////////////////////////// +// Inline methods +/////////////////////////////////////////////////////////////////////////// + +inline AwMatrix::AwMatrix() +{ + matrix[0][1] = matrix[0][2] = matrix[0][3] = + matrix[1][0] = matrix[1][2] = matrix[1][3] = + matrix[2][0] = matrix[2][1] = matrix[2][3] = + matrix[3][0] = matrix[3][1] = matrix[3][2] = 0.0; + matrix[0][0] = matrix[1][1] = matrix[2][2] = matrix[3][3] = 1.0; +} + +inline AwMatrix &AwMatrix::operator=(const AwMatrix &rhs) +{ + matrix[0][0] = rhs.matrix[0][0]; matrix[0][1] = rhs.matrix[0][1]; + matrix[0][2] = rhs.matrix[0][2]; matrix[0][3] = rhs.matrix[0][3]; + matrix[1][0] = rhs.matrix[1][0]; matrix[1][1] = rhs.matrix[1][1]; + matrix[1][2] = rhs.matrix[1][2]; matrix[1][3] = rhs.matrix[1][3]; + matrix[2][0] = rhs.matrix[2][0]; matrix[2][1] = rhs.matrix[2][1]; + matrix[2][2] = rhs.matrix[2][2]; matrix[2][3] = rhs.matrix[2][3]; + matrix[3][0] = rhs.matrix[3][0]; matrix[3][1] = rhs.matrix[3][1]; + matrix[3][2] = rhs.matrix[3][2]; matrix[3][3] = rhs.matrix[3][3]; + return *this; +} + +inline AwMatrix::AwMatrix(const AwMatrix &src) +{ *this = src; } + +//#ifndef COMPILE_OUTSIDE_MAYA +//inline AwMatrix::AwMatrix(const MMatrix &src) +//{ +// matrix[0][0] = src.matrix[0][0]; matrix[0][1] = src.matrix[0][1]; +// matrix[0][2] = src.matrix[0][2]; matrix[0][3] = src.matrix[0][3]; +// matrix[1][0] = src.matrix[1][0]; matrix[1][1] = src.matrix[1][1]; +// matrix[1][2] = src.matrix[1][2]; matrix[1][3] = src.matrix[1][3]; +// matrix[2][0] = src.matrix[2][0]; matrix[2][1] = src.matrix[2][1]; +// matrix[2][2] = src.matrix[2][2]; matrix[2][3] = src.matrix[2][3]; +// matrix[3][0] = src.matrix[3][0]; matrix[3][1] = src.matrix[3][1]; +// matrix[3][2] = src.matrix[3][2]; matrix[3][3] = src.matrix[3][3]; +//} +//#endif + +inline AwMatrix::~AwMatrix() +{} + +inline double *AwMatrix::operator[](unsigned i) +{ return &matrix[i][0]; } + +inline const double *AwMatrix::operator[](unsigned i) const +{ return &matrix[i][0]; } + +inline double & AwMatrix::operator()(short i, short j) +{ return matrix[i][j]; } + +inline const double& AwMatrix::operator()(short i, short j) const +{ return matrix[i][j]; } + +inline AwMatrix AwMatrix::inverse() const +{ AwMatrix temp(*this); temp.invertIt(); return temp; } + +inline AwMatrix AwMatrix::transpose() const +{ AwMatrix temp(*this); temp.transposeIt(); return temp; } + +inline bool AwMatrix::operator!=(const AwMatrix &otherM) const +{ return !( (*this) == otherM ); } + +#endif /* _AwMatrix */ diff --git a/Loader/ik2Bsolver/AwPoint.cpp b/Loader/ik2Bsolver/AwPoint.cpp new file mode 100644 index 000000000..042ade1e5 --- /dev/null +++ b/Loader/ik2Bsolver/AwPoint.cpp @@ -0,0 +1,107 @@ +//- +// ========================================================================== +// Copyright 1995,2006,2008 Autodesk, Inc. All rights reserved. +// +// Use of this software is subject to the terms of the Autodesk +// license agreement provided at the time of installation or download, +// or which otherwise accompanies this software in either electronic +// or hard copy form. +// ========================================================================== +//+ +// +// CLASS: AwPoint +// +// ***************************************************************************** +// +// CLASS DESCRIPTION (AwPoint) +// +// By expressing a point (a location in 3-space) in homogeneous +// coordinates we can express the three transformations (translate, +// rotate and scale) that can be applied to it as matrix +// multiplications. In homogeneous coordinates, the cartesian point +// P(x, y, z) is represented as P(W*x, W*y, W*z, W) for any scale +// factor W != 0. Therefor given a homogeneous-coordinate +// representation for a point P(X, Y, Z, W), we can find the 3D +// cartesian coordinate representation for the point as x = X/W, y = +// Y/W and z = Z/W. In general W == 1.0, so the division won't be +// required. However, some NURBS code sets W to be non-unit to +// acheive certain numerical effects! The methods cartesianize() +// and cartesian() make the division necessary to return a point that +// has w == 1.0. +// +// (Above paraphrased from Foley and Van Dam, Vol 1. p 250) +// +// ***************************************************************************** + +#include +#include +#include + +#include +#include + +// Initialize constant +// +const AwPoint AwPoint::origin; + +AwVector AwPoint::cartesianSub(const AwPoint &otherPt) const +{ + AwPoint ptA = cartesian(); + AwPoint ptB = otherPt.cartesian(); + return AwVector(ptA.x - ptB.x, ptA.y - ptB.y, ptA.z - ptB.z); +} + +AwPoint AwPoint::cartesianAdd(const AwVector &v) const +{ + AwPoint pt = cartesian(); + return AwPoint(pt.x + v.x, pt.y + v.y, pt.z + v.z); +} + +AwPoint AwPoint::cartesianSub(const AwVector &v) const +{ + AwPoint pt = cartesian(); + return AwPoint(pt.x - v.x, pt.y - v.y, pt.z - v.z); +} + +AwPoint& AwPoint::cartesianize() +// +// Description: +// If 'this' point is P(W*x, W*y, W*z, W), for some scale factor W != 0, +// then it is reset to be P(x, y, z, 1). +// +// Note: +// This will only work correctly if the point is in homogenous form or +// cartesian form. If the point is in rational form, the results are +// not defined. +// +{ + if (w != 1.0) { + assert(w != 0.0); + double wInv = 1.0/w; + x *= wInv; y *= wInv; z *= wInv; w = 1.0; + } + return *this; +} + +inline AwPoint AwPoint::operator*(const AwMatrix &right) const +{ + AwPoint tmp; + + const double *a = (const double *) (right.matrix); + tmp.x = x * a[0] + y * a[4] + z * a[8] + w * a[12]; + tmp.y = x * a[1] + y * a[5] + z * a[9] + w * a[13]; + tmp.z = x * a[2] + y * a[6] + z * a[10] + w * a[14]; + tmp.w = x * a[3] + y * a[7] + z * a[11] + w * a[15]; + + return tmp; +} + +/*friend*/ ostream &operator<<(ostream &os, const AwPoint &p) +// +// Description: +// Stream output. +// +{ + os << "[" << p.x << ", " << p.y << ", " << p.z << ", " << p.w << "]"; + return os; +} diff --git a/Loader/ik2Bsolver/AwPoint.h b/Loader/ik2Bsolver/AwPoint.h new file mode 100644 index 000000000..5cc0b08a4 --- /dev/null +++ b/Loader/ik2Bsolver/AwPoint.h @@ -0,0 +1,145 @@ +#ifndef _AwPoint +#define _AwPoint +//- +// ========================================================================== +// Copyright 1995,2006,2008 Autodesk, Inc. All rights reserved. +// +// Use of this software is subject to the terms of the Autodesk +// license agreement provided at the time of installation or download, +// or which otherwise accompanies this software in either electronic +// or hard copy form. +// ========================================================================== +//+ +// +// CLASS: AwPoint +// +// ***************************************************************************** +// +// CLASS DESCRIPTION (AwPoint) +// +// By expressing a point (a location in 3-space) in homogeneous +// coordinates we can express the three transformations (translate, +// rotate and scale) that can be applied to it as matrix +// multiplications. In homogeneous coordinates, the cartesian point +// P(x, y, z) is represented as P(W*x, W*y, W*z, W) for any scale +// factor W != 0. Therefor given a homogeneous-coordinate +// representation for a point P(X, Y, Z, W), we can find the 3D +// cartesian coordinate representation for the point as x = X/W, y = +// Y/W and z = Z/W. In general W == 1.0, so the division won't be +// required. However, some NURBS code sets W to be non-unit to +// acheive certain numerical effects! The methods cartesianizeIt() +// and cartesian() make the division necessary to return a point that +// has w == 1.0. +// +// (Above paraphrased from Foley and Van Dam, Vol 1. p 250) +// +// ***************************************************************************** + +#include +#include + +class AwPoint { +public: + AwPoint(); + AwPoint(const AwPoint &); + AwPoint(const AwVector &); + AwPoint(double xx, double yy, double zz = 0.0, double ww = 1.0); +//#ifndef COMPILE_OUTSIDE_MAYA +// AwPoint(const MPoint &); +//#endif + ~AwPoint(); + + AwPoint &operator=(const AwPoint &); + AwPoint &set(double xx, double yy, double zz = 0.0, double ww = 1.0); + + double &operator[](size_t i); + double operator[](size_t i) const; + + AwPoint operator+(const AwVector &) const; + AwPoint operator-(const AwVector &) const; + AwVector operator-(const AwPoint &) const; + AwPoint operator*(const AwMatrix &right) const; + + bool operator==(const AwPoint &) const; + bool operator!=(const AwPoint &) const; + + AwPoint cartesian() const; + AwPoint &cartesianize(); + + AwPoint &setToProduct(const AwPoint &left, const AwMatrix &right); + + friend ostream &operator<<(ostream &os, const AwPoint &); + + static const AwPoint origin; // The point (0, 0, 0). + + double x, y, z, w; + +private: + AwVector cartesianSub(const AwPoint &) const; + AwPoint cartesianAdd(const AwVector &) const; + AwPoint cartesianSub(const AwVector &) const; +}; + +/////////////////////////////////////////////////////////////////////////// +// Inline methods +/////////////////////////////////////////////////////////////////////////// + +inline AwPoint::AwPoint() +: x(0.0), y(0.0), z(0.0), w(1.0) +{} + +inline AwPoint::AwPoint(const AwPoint &pt) +: x(pt.x), y(pt.y), z(pt.z), w(pt.w) +{} + +inline AwPoint::AwPoint(const AwVector &v) +: x(v.x), y(v.y), z(v.z), w(1.0) +{} + +inline AwPoint::AwPoint(double xx, double yy, double zz, double ww) +: x(xx), y(yy), z(zz), w(ww) +{} + +//#ifndef COMPILE_OUTSIDE_MAYA +//inline AwPoint::AwPoint(const MPoint &pt) +//: x(pt.x), y(pt.y), z(pt.z), w(pt.w) +//{} +//#endif + +inline AwPoint::~AwPoint() +{} + +inline AwPoint &AwPoint::set(double xx, double yy, double zz, double ww) +{ x = xx; y = yy; z = zz; w = ww; return *this; } + +inline AwPoint &AwPoint::operator=(const AwPoint &src) +{ x = src.x; y = src.y; z = src.z; w = src.w; return *this; } + +inline double &AwPoint::operator[](size_t i) +{ return (&x)[i]; } + +inline double AwPoint::operator[](size_t i) const +{ return (&x)[i]; } + +inline AwPoint AwPoint::operator+(const AwVector &v) const +{ if (w == 1.0) return AwPoint(x+v.x, y+v.y, z+v.z); + else return cartesianAdd(v); } + +inline AwPoint AwPoint::operator-(const AwVector &v) const +{ if (w == 1.0) return AwPoint(x-v.x, y-v.y, z-v.z); + else return cartesianSub(v); } + +inline AwVector AwPoint::operator-(const AwPoint &o) const +{ if (w == 1.0 && o.w == 1.0) return AwVector(x-o.x, y-o.y, z-o.z); + else return cartesianSub(o); } + +inline bool AwPoint::operator==(const AwPoint &p) const +{ return( x == p.x && y == p.y && z == p.z && w == p.w); } + +inline bool AwPoint::operator!=(const AwPoint &otherPoint) const +{ return !(*this == otherPoint); } + +inline AwPoint AwPoint::cartesian() const +{ AwPoint temp(*this); return temp.cartesianize(); } + +#endif /* _AwPoint */ diff --git a/Loader/ik2Bsolver/AwQuaternion.cpp b/Loader/ik2Bsolver/AwQuaternion.cpp new file mode 100644 index 000000000..1fadd747a --- /dev/null +++ b/Loader/ik2Bsolver/AwQuaternion.cpp @@ -0,0 +1,289 @@ +//- +// ========================================================================== +// Copyright 1995,2006,2008 Autodesk, Inc. All rights reserved. +// +// Use of this software is subject to the terms of the Autodesk +// license agreement provided at the time of installation or download, +// or which otherwise accompanies this software in either electronic +// or hard copy form. +// ========================================================================== +//+ +// +// CLASS: AwQuaternion +// +// ***************************************************************************** +// +// CLASS DESCRIPTION (AwQuaternion) +// +// Quaternions can be used to specify orientations and rotations of 3-D +// objects relative to a starting reference, similar to the way that cartesian +// vectors can be used to specify positions and translations of 3-D objects +// relative to an origin. Quaternions represent orientations as a single +// rotation, just as rectangular co-ordinates represent position as a single +// vector. +// +// ***************************************************************************** + +#include +#include +#include +#include +#include +#include +#include + +// Initialize constants +// +const AwQuaternion AwQuaternion::identity; + +AwQuaternion::AwQuaternion(const AwVector &a, const AwVector &b) +// +// Description: +// This constructor creates a new quaternion that will rotate vector +// a into vector b about their mutually perpendicular axis. (if one +// exists) +// +: w(1.0), x(0.0), y(0.0), z(0.0) +{ + double factor = a.length() * b.length(); + + if (fabs(factor) > kFloatEpsilon) { + // Vectors have length > 0 + AwVector pivotVector; + double dot = a.dotProduct(b) / factor; + double theta = acos(clamp(dot, -1.0, 1.0)); + + pivotVector = a^b; + if (dot < 0.0 && pivotVector.length() < kFloatEpsilon) { + // Vectors parallel and opposite direction, therefore a rotation + // of 180 degrees about any vector perpendicular to this vector + // will rotate vector a onto vector b. + // + // The following guarantees the dot-product will be 0.0. + // + size_t dominantIndex = a.dominantAxis(); + pivotVector[dominantIndex] = -a[(dominantIndex+1)%3]; + pivotVector[(dominantIndex+1)%3] = a[dominantIndex]; + pivotVector[(dominantIndex+2)%3] = 0.0; + } + setAxisAngle(pivotVector, theta); + } +} + +AwQuaternion & AwQuaternion::operator=(const AwMatrix &tm) +// +// Description: +// Convert the given 4X4 homogeneous rotation matrix to a +// quaternion of unit length. +// +// Notes: +// This methods always returns a quaternion of unit length IF it +// is given a proper orthogonal matrix. A proper othogonal +// matrix is one such that the determinant of the matrix is one. +// (If the determinant were -1, this would imply that the +// orthogonal matrix is also producing a reflection, in addition +// to a rotation.) +// +{ + double trace, s; + int i, j, k; + + // vectors are multiplied on the left (pre-multipy). + // + + trace = tm.matrix[0][0] + tm.matrix[1][1] + tm.matrix[2][2]; + if (trace > 0.0) { + s = sqrt(trace + 1.0); + w = s * 0.5; + assert(s > kExtendedEpsilon); + s = 0.5/s; + x = (tm.matrix[1][2] - tm.matrix[2][1]) * s; + y = (tm.matrix[2][0] - tm.matrix[0][2]) * s; + z = (tm.matrix[0][1] - tm.matrix[1][0]) * s; + } else { + i = 0; + if (tm.matrix[1][1] > tm.matrix[0][0]) + i = 1; + if (tm.matrix[2][2] > tm.matrix[i][i]) + i = 2; + j = (i+1)%3; + k = (j+1)%3; + s = sqrt(tm.matrix[i][i] - (tm.matrix[j][j] + tm.matrix[k][k]) + 1.0); + (*this)[i] = s * 0.5; + assert(s > kExtendedEpsilon); + s = 0.5 / s; + w = (tm.matrix[j][k] - tm.matrix[k][j]) * s; + (*this)[j] = (tm.matrix[j][i] + tm.matrix[i][j]) * s; + (*this)[k] = (tm.matrix[k][i] + tm.matrix[i][k]) * s; + } + + return *this; +} + +AwQuaternion AwQuaternion::operator*(const AwQuaternion &rhs) const +// +// Description: +// This operator returns the product of two quaternions. +// "This" quaternion is the left quaternion in the product. +// +// Note: +// In general, if p and q are quaternions, pq != qp, i.e., +// multiplication does not commute! +// +// Quaternions in Maya multiply on the right (post-multiply) +// the same as matrices. Many popular quaternion papers (Shoemake) +// use pre-multiplication where quaternions pre-multiply on the left +// so you must be aware of this when using quaternions. +// +{ + AwQuaternion result; + result.w = rhs.w * w - (rhs.x * x + rhs.y * y + rhs.z * z); + result.x = rhs.w * x + rhs.x * w + rhs.y * z - rhs.z * y; + result.y = rhs.w * y + rhs.y * w + rhs.z * x - rhs.x * z; + result.z = rhs.w * z + rhs.z * w + rhs.x * y - rhs.y * x; + return result; +} + +AwQuaternion::operator AwMatrix() const +// +// Description: +// This casts a AwQuaternion to an AwMatrix by making use of the +// convertToMatrix method. +// +{ + AwMatrix m; + convertToMatrix(m); + return m; +} + +void AwQuaternion::convertToMatrix(AwMatrix &tm) const +// +// Description: +// Convert quaternion to a 4X4 homogeneous rotation matrix and pass +// result back in 'tm'. The construction of the matrix assumes that the +// vectors are going to be multiplied on the left side of the matrix. +// If the quaternion's length has degenerated, this method will still +// produce a well behaved matrix. +// +// Notes: +// For an explanation of the following implementation see +// Shoemake, K., "Quaternion Calculus and Fast Animation". +// +{ + // Common subexpressions + // + double ww = w*w, xx = x*x, yy = y*y, zz = z*z; + double s = 2.0/(ww + xx + yy + zz); + double xy = x*y, xz = x*z, yz = y*z, wx = w*x, wy = w*y, wz = w*z; + + // vectors are multiplied on the left (pre-multipy). + // + tm.matrix[0][0] = 1.0 - s * (yy + zz); + tm.matrix[1][0] = s * (xy - wz); + tm.matrix[2][0] = s * (xz + wy); + tm.matrix[3][0] = 0.0; + tm.matrix[0][1] = s * (xy + wz); + tm.matrix[1][1] = 1.0 - s * (xx + zz); + tm.matrix[2][1] = s * (yz - wx); + tm.matrix[3][1] = 0.0; + tm.matrix[0][2] = s * (xz - wy); + tm.matrix[1][2] = s * (yz + wx); + tm.matrix[2][2] = 1.0 - s * (xx + yy); + tm.matrix[3][2] = 0.0; + tm.matrix[0][3] = 0.0; + tm.matrix[1][3] = 0.0; + tm.matrix[2][3] = 0.0; + tm.matrix[3][3] = 1.0; +} + +AwQuaternion &AwQuaternion::setAxisAngle(const AwVector &axis, double theta) +// +// Description: +// This function sets this quaternion to be the rotation as expressed by a +// pivot axis and a rotation theta (in radians) about that axis. If the +// axis is too small the quaternion returned will be the identity +// quaternion. +// +{ + double sumOfSquares = + (double) axis.x * axis.x + + (double) axis.y * axis.y + + (double) axis.z * axis.z; + + if (sumOfSquares <= kDoubleEpsilon) { + // Axis too small. + *this = identity; + } else { + theta *= 0.5; + w = cos(theta); + double commonFactor = sin(theta); + if (!::equivalent(sumOfSquares, 1.0)) + commonFactor /= sqrt(sumOfSquares); + x = commonFactor * (double) axis.x; + y = commonFactor * (double) axis.y; + z = commonFactor * (double) axis.z; + } + return *this; +} + +bool AwQuaternion::getAxisAngle(AwVector &axis, double &theta) const +// +// Description: +// This function converts this quaternion into a user understandable +// representation. That is, the quaternion is represented as a pivot +// vector 'axis' and a rotation 'theta' (in radians) about that pivot +// vector. +// +// Returns: +// true - angle != 0 +// false - angle == 0 (uses arbitrary axis, if given axis not valid) +// +// Notes: +// If the identity unit quaternion is attempted to be converted to the +// pivot axis and angle representation it will be set to a zero degree +// rotation about the axis that was passed in. (Note that any axis will +// do, since an infinity of axis with rotation of zero satisfy the identity +// rotation.) If the axis is zero length, then an arbitrary axis will be +// chosen (z-axis). +// +{ + bool result; + double inverseOfSinThetaByTwo, thetaExtended; + + if (::equivalent(w, (double) 1.0)) { + theta = 0.0; + if (axis.length() < kDoubleEpsilon) { + // Passed in axis invalid, choose an arbitrary axis. + axis.set(0.0,0.0,1.0); + } + result = false; + } + else { + thetaExtended = acos(clamp(w,-1.0,1.0)); + theta = thetaExtended * 2.0; + + inverseOfSinThetaByTwo = 1.0 / sin(thetaExtended); + axis.x = x * inverseOfSinThetaByTwo; + axis.y = y * inverseOfSinThetaByTwo; + axis.z = z * inverseOfSinThetaByTwo; + + result = true; + } + + return result; +} + +/*friend*/ ostream &operator<<(ostream &os, const AwQuaternion &q) +// +// Description: +// Stream output. +// +{ + os << "[" + << "x: " << q.x << ", " + << "y: " << q.y << ", " + << "z: " << q.z << ", " + << "w: " << q.w << "]"; + + return os; +} diff --git a/Loader/ik2Bsolver/AwQuaternion.h b/Loader/ik2Bsolver/AwQuaternion.h new file mode 100644 index 000000000..31d947001 --- /dev/null +++ b/Loader/ik2Bsolver/AwQuaternion.h @@ -0,0 +1,124 @@ +#ifndef _AwQuaternion +#define _AwQuaternion +//- +// ========================================================================== +// Copyright 1995,2006,2008 Autodesk, Inc. All rights reserved. +// +// Use of this software is subject to the terms of the Autodesk +// license agreement provided at the time of installation or download, +// or which otherwise accompanies this software in either electronic +// or hard copy form. +// ========================================================================== +//+ +// +// CLASS: AwQuaternion +// +// ***************************************************************************** +// +// CLASS DESCRIPTION (AwQuaternion) +// +// Quaternions can be used to specify orientations and rotations of 3-D +// objects relative to a starting reference, similar to the way that cartesian +// vectors can be used to specify positions and translations of 3-D objects +// relative to an origin. Quaternions represent orientations as a single +// rotation, just as rectangular co-ordinates represent position as a single +// vector. +// +// ***************************************************************************** + +#include +//#include +#include + +class AwVector; +class AwMatrix; + +class AwQuaternion { +public: + // Constructors + // + AwQuaternion(); + AwQuaternion(const AwQuaternion &q); + AwQuaternion(double x, double y, double z, double w); + AwQuaternion(const AwVector &, const AwVector &); + AwQuaternion(double angle, const AwVector &axis); +//#ifndef COMPILE_OUTSIDE_MAYA +// AwQuaternion(const MQuaternion &q); +// operator MQuaternion() const; +//#endif + ~AwQuaternion(); + + AwQuaternion &operator=(const AwQuaternion &); + AwQuaternion &operator=(const AwMatrix &); + + double &operator[](unsigned i); + double operator[](unsigned i) const; + + AwQuaternion operator*(const AwQuaternion &) const; + + bool operator==(const AwQuaternion &) const; + bool operator!=(const AwQuaternion &) const; + + operator AwMatrix() const; + void convertToMatrix(AwMatrix &) const; + + AwQuaternion &setAxisAngle(const AwVector &axis, double theta); + bool getAxisAngle(AwVector &axis, double &theta) const; + + friend ostream &operator<<(ostream &os, const AwQuaternion &); + + static const AwQuaternion identity; // The multiplicative identity. + + double x, y, z, w; // imaginary (3) & real components +}; + +/////////////////////////////////////////////////////////////////////////// +// Inline methods +/////////////////////////////////////////////////////////////////////////// + +inline AwQuaternion::AwQuaternion() +: w(1.0), x(0.0), y(0.0), z(0.0) +{} + +inline AwQuaternion::AwQuaternion(const AwQuaternion &q) +: w(q.w), x(q.x), y(q.y), z(q.z) +{} + +inline AwQuaternion::AwQuaternion(double a, double b, double c, double d) +: x(a), y(b), z(c), w(d) +{} + +inline AwQuaternion::AwQuaternion(double angle, const AwVector &axis) +: w(1.0), x(0.0), y(0.0), z(0.0) +{ setAxisAngle(axis, angle); } + +//#ifndef COMPILE_OUTSIDE_MAYA +//inline AwQuaternion::AwQuaternion(const MQuaternion &q) +//: w(q.w), x(q.x), y(q.y), z(q.z) +//{} +// +//inline AwQuaternion::operator MQuaternion() const +//{ +// return MQuaternion(x, y, z, w); +//} +//#endif + +inline AwQuaternion::~AwQuaternion () +{} + +inline AwQuaternion &AwQuaternion::operator=(const AwQuaternion &src) +{ w = src.w; x = src.x; y = src.y; z = src.z; return *this; } + +inline double &AwQuaternion::operator[](unsigned i) +{ return (&x)[i]; } + +inline double AwQuaternion::operator[](unsigned i) const +{ return (&x)[i]; } + +inline bool AwQuaternion::operator==( const AwQuaternion &otherQ ) const +{ return w == otherQ.w && x == otherQ.x && y == otherQ.y && z == otherQ.z; } + +inline bool AwQuaternion::operator!=( const AwQuaternion &otherQ ) const +{ return !( (*this) == otherQ ); } + +#endif /* _AwQuaternion */ diff --git a/Loader/ik2Bsolver/AwVector.cpp b/Loader/ik2Bsolver/AwVector.cpp new file mode 100644 index 000000000..3f8524b0d --- /dev/null +++ b/Loader/ik2Bsolver/AwVector.cpp @@ -0,0 +1,180 @@ +//- +// ========================================================================== +// Copyright 1995,2006,2008 Autodesk, Inc. All rights reserved. +// +// Use of this software is subject to the terms of the Autodesk +// license agreement provided at the time of installation or download, +// or which otherwise accompanies this software in either electronic +// or hard copy form. +// ========================================================================== +//+ +// +// CLASS: AwVector +// +// ***************************************************************************** +// +// CLASS DESCRIPTION (AwVector) +// +// A vector is a mathematical entity used to express the notion of +// direction and magnitude (not to be confused with a point that expresses +// location). The direction is defined by the line from the origin +// to the vector's x, y, z coordinate. Vectors can be used to represent +// translations, in the way that quaternions are used to represent +// rotations. When vectors are used to represent a direction, multiplying +// it by a transformation matrix results in the vector being properly +// re-oriented by the transformation (eg. a pure translation doesn't affect +// the direction something is pointing, so a vector remains unchanged under +// a pure translation). +// +// ***************************************************************************** + +#include +#include +#include +#include +#include +#include +#include + +// Initialize constants +// +const AwVector AwVector::zero; +const AwVector AwVector::xAxis(1.0, 0.0, 0.0); +const AwVector AwVector::yAxis(0.0, 1.0, 0.0); +const AwVector AwVector::zAxis(0.0, 0.0, 1.0); + +AwVector::AwVector(const AwPoint &pt) +// +// Description: +// Convenience method to construct a vector from a point. +// +: x(pt.x), y(pt.y), z(pt.z) +{} + +AwVector AwVector::operator*(const AwMatrix &right) const +{ + AwVector tmp; + double *a = (double *) (right.matrix); + tmp.x = x * *a + y * *(a+4) + z * *(a+8); + tmp.y = x * *(a+1) + y * *(a+5) + z * *(a+9); + tmp.z = x * *(a+2) + y * *(a+6) + z * *(a+10); + + return tmp; +} + +AwVector& AwVector::operator=(const AwMatrix &tm) +// +// Description: +// Extract the translation components out of a 4X4 homogeneous +// transformation matrix into this vector. +// +{ + x = tm(3, 0); + y = tm(3, 1); + z = tm(3, 2); + return *this; +} + +AwVector &AwVector::normalize() +{ + double n = norm(); + if (n > kDoubleEpsilonSqr && !::equivalent(n, 1.0, 2.0*kDoubleEpsilon)) { + double factor = 1.0 / sqrt(n); + x *= factor; y *= factor; z *= factor; + } + return *this; +} + +AwVector AwVector::rotateBy(const AwQuaternion &q) const +// +// Description: +// Returns the vector that represents the rotation of this +// vector by the given quaternion. +// +// Simply carry out the quaternion multiplications: +// result = q.conjugate() * (*this) * q +// +{ + double rw = - q.x * x - q.y * y - q.z * z; + double rx = q.w * x + q.y * z - q.z * y; + double ry = q.w * y + q.z * x - q.x * z; + double rz = q.w * z + q.x * y - q.y * x; + return AwVector(- rw * q.x + rx * q.w - ry * q.z + rz * q.y, + - rw * q.y + ry * q.w - rz * q.x + rx * q.z, + - rw * q.z + rz * q.w - rx * q.y + ry * q.x); +} + +bool AwVector::isParallel(const AwVector &otherVector, double tolerance) const +// +// Description: +// Returns TRUE if the vectors are parallel, that is, pointing in +// the same or opposite directions, but not necessarily of the same +// magnitude. +// +{ + AwVector v1, v2; + v1 = this->normal(); + v2 = otherVector.normal(); + double dotPrd = v1.dotProduct(v2); + return (::equivalent(fabs(dotPrd), (double) 1.0, tolerance)); +} + +AwVector::Axis AwVector::dominantAxis() const +// +// Description: +// Returns the axis along which this vector is dominant +// +// +{ + double xx, yy; + + if ((xx = fabs(x)) > (yy = fabs(y))) { + if (xx > fabs(z)) { + return kXaxis; + } else { + return kZaxis; + } + } else { + if (yy > fabs(z)) { + return kYaxis; + } else { + return kZaxis; + } + } +} + +double AwVector::angle(const AwVector &vec) const +{ + double cosine = normal().dotProduct(vec.normal()); + double angle; + if (cosine >= 1.0) + angle = 0.0; + else if (cosine <= -1.0) + angle = kPi; + else + angle = acos(cosine); + return angle; +} + +AwVector::operator AwMatrix() const +// +// Description: +// This casts a AwVector to a translation Matrix. +// +{ + AwMatrix m; + m(3, 0) = x; + m(3, 1) = y; + m(3, 2) = z; + return m; +} + +/*friend*/ ostream &operator<<(ostream &os, const AwVector &v) +// +// Description: +// Stream output. +// +{ + os << "[" << v.x << ", " << v.y << ", " << v.z << "]"; + return os; +} diff --git a/Loader/ik2Bsolver/AwVector.h b/Loader/ik2Bsolver/AwVector.h new file mode 100644 index 000000000..5cbac930d --- /dev/null +++ b/Loader/ik2Bsolver/AwVector.h @@ -0,0 +1,184 @@ +#ifndef _AwVector +#define _AwVector +//- +// ========================================================================== +// Copyright 1995,2006,2008 Autodesk, Inc. All rights reserved. +// +// Use of this software is subject to the terms of the Autodesk +// license agreement provided at the time of installation or download, +// or which otherwise accompanies this software in either electronic +// or hard copy form. +// ========================================================================== +//+ +// +// CLASS: AwVector +// +// ***************************************************************************** +// +// CLASS DESCRIPTION (AwVector) +// +// A vector is a mathematical entity used to express the notion of +// direction and magnitude (not to be confused with a point that expresses +// location). The direction is defined by the line from the origin +// to the vector's x, y, z coordinate. Vectors can be used to represent +// translations, in the way that quaternions are used to represent +// rotations. When vectors are used to represent a direction, multiplying +// it by a transformation matrix results in the vector being properly +// re-oriented by the transformation (eg. a pure translation doesn't affect +// the direction something is pointing, so a vector remains unchanged under +// a pure translation). +// +// ***************************************************************************** + +#if defined(OSMac_) +#include +#endif +#include +#include +using namespace std; + +#define kVectorEquivalentTolerance kDoubleEpsilon + +class AwPoint; +class AwMatrix; +class AwQuaternion; + +class AwVector { +public: + enum Axis { + kXaxis, + kYaxis, + kZaxis + }; + + AwVector(); + AwVector(const AwVector &); + AwVector(const AwPoint &); + AwVector(double xx, double yy, double zz = 0.0); +//#ifndef COMPILE_OUTSIDE_MAYA +// AwVector(const MVector &); +//#endif + ~AwVector(); + + AwVector &operator=(const AwVector &); + AwVector &operator=(const AwMatrix &); + AwVector &set(double xx, double yy, double zz = 0.0); + + double &operator[](size_t i); + double operator[](size_t i) const; + + double operator*(const AwVector &right) const; + AwVector operator^(const AwVector &right) const; + + double dotProduct(const AwVector &) const; + AwVector crossProduct(const AwVector &) const; + + AwVector operator*(const AwMatrix &right) const; + AwVector &operator*=(const AwMatrix &right); + AwVector operator*(double) const; + AwVector operator+(const AwVector &) const; + AwVector operator-(const AwVector &) const; + AwVector operator-() const; + + bool operator==(const AwVector &) const; + bool operator!=(const AwVector &) const; + + double length() const; + double norm() const; + AwVector normal() const; + AwVector &normalize(); + + AwVector rotateBy(const AwQuaternion &) const; + bool isParallel(const AwVector &, + double = kVectorEquivalentTolerance) const; + Axis dominantAxis() const; + double angle(const AwVector &) const; + + operator AwMatrix() const; + + friend ostream &operator<<(ostream &os, const AwVector &); + + static const AwVector zero; // The identity transformation. + static const AwVector xAxis; // The x axis + static const AwVector yAxis; // The y axis + static const AwVector zAxis; // The z axis + + double x, y, z; +}; + +/////////////////////////////////////////////////////////////////////////// +// Inline methods +/////////////////////////////////////////////////////////////////////////// + +inline AwVector::AwVector () +: x(0.0), y(0.0), z(0.0) {} + +inline AwVector::AwVector(const AwVector &v) +: x(v.x), y(v.y), z(v.z) {} + +inline AwVector::AwVector(double xx, double yy, double zz) +: x(xx), y(yy), z(zz) {} + +//#ifndef COMPILE_OUTSIDE_MAYA +//inline AwVector::AwVector(const MVector &v) +//: x(v.x), y(v.y), z(v.z) {} +//#endif + +inline AwVector::~AwVector () +{} + +inline AwVector &AwVector::operator=(const AwVector &src) +{ x = src.x; y = src.y; z = src.z; return *this; } + +inline AwVector &AwVector::set(double xx, double yy, double zz) +{ x = xx; y = yy; z = zz; return *this; } + +inline double & AwVector::operator[](size_t i) +{ return (&x)[i]; } + +inline double AwVector::operator[](size_t i) const +{ return (&x)[i]; } + +inline double AwVector::dotProduct(const AwVector &v) const +{ return (x*v.x + y*v.y + z*v.z); } + +inline AwVector AwVector::crossProduct(const AwVector &r) const +{ return AwVector(y*r.z - z*r.y, z*r.x - x*r.z, x*r.y - y*r.x); } + +inline double AwVector::operator*(const AwVector &a) const +{ return dotProduct(a); } + +inline AwVector AwVector::operator^(const AwVector &a) const +{ return crossProduct(a); } + +inline AwVector AwVector::operator+(const AwVector &v) const +{ return AwVector(x + v.x, y + v.y, z + v.z); } + +inline AwVector AwVector::operator-(const AwVector &v) const +{ return AwVector(x - v.x, y - v.y, z - v.z); } + +inline AwVector &AwVector::operator*=(const AwMatrix &m) +{ *this = *this * m; return *this; } + +inline AwVector AwVector::operator*(double s) const +{ return AwVector(x * s, y * s, z * s); } + +inline AwVector AwVector::operator-() const +{ return AwVector(-x, -y, -z); } + +inline bool AwVector::operator==(const AwVector &v) const +{ return (x == v.x && y == v.y && z == v.z); } + +inline bool AwVector::operator!=(const AwVector &v) const +{ return !(*this == v); } + +inline double AwVector::norm() const +{ return (x*x + y*y + z*z); } + +inline double AwVector::length() const +{ return sqrt(norm()); } + +inline AwVector AwVector::normal() const +{ AwVector tmp(*this); return tmp.normalize(); } + +#endif // _AwVector diff --git a/Loader/ik2Bsolver/ik2Bsolver.cpp b/Loader/ik2Bsolver/ik2Bsolver.cpp new file mode 100644 index 000000000..57f8ca2aa --- /dev/null +++ b/Loader/ik2Bsolver/ik2Bsolver.cpp @@ -0,0 +1,482 @@ +//- +// ========================================================================== +// Copyright 1995,2006,2008 Autodesk, Inc. All rights reserved. +// +// Use of this software is subject to the terms of the Autodesk +// license agreement provided at the time of installation or download, +// or which otherwise accompanies this software in either electronic +// or hard copy form. +// ========================================================================== +//+ + +////////////////////////////////////////////////////////////////// +// +// ik2Bsolver: IK 2 Bone Solver +// +// This IK solver solves for 2 bones with +// rotate plane capability. +// +// To create the solver, load the plugin, and then type +// the following in the command window: +// +// createNode -n ik2Bsolver ik2Bsolver; +// +// To use the solver, create two bones using the Joint Tool. +// Then either use the IK Handle Tool, +// or type the following in the command window: +// +// ikHandle -sol ik2Bsolver -sj joint1 -ee joint3; +// +// Moving the handle will cause the IK solver to solve. +// +// For convenience, the command "addIK2BsolverCallbacks" +// will set up callbacks to recreate the ik2Bsolver after a +// File->New or File->Open, so that the solver will +// appear to be persistent. +// +////////////////////////////////////////////////////////////////// + + +#include +//#include +// +//#include +//#include +//#include +// +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +#include "ik2Bsolver.h" + +//#include +//#include +//#include +//#include +//#include +// +//#include +//#include +//#include +//#include +//#include + + +#define kSolverType "ik2Bsolver" +#define kPi 3.14159265358979323846264338327950 +#define kEpsilon 1.0e-5 +#define absoluteValue(x) ((x) < 0 ? (-(x)) : (x)) + + +////////////////////////////////////////////////////////////////// +// +// IK 2 Bone Solver Node +// +////////////////////////////////////////////////////////////////// +//class ik2Bsolver : public MPxIkSolverNode { +// +//public: +// ik2Bsolver(); +// virtual ~ik2Bsolver(); +// void postConstructor(); +// +// virtual MStatus doSolve(); +// virtual MString solverTypeName() const; +// +// static void* creator(); +// static MStatus initialize(); +// +// static MTypeId id; +// +//private: +// AwVector poleVectorFromHandle(const MDagPath &handlePath); +// double twistFromHandle(const MDagPath &handlePath); +//}; + +//void solveIK(const AwPoint &startJointPos, +// const AwPoint &midJointPos, +// const AwPoint &effectorPos, +// const AwPoint &handlePos, +// const AwVector &poleVector, +// double twistValue, +// AwQuaternion &qStart, +// AwQuaternion &qMid); + +//MTypeId ik2Bsolver::id(0x58000030); +// +//ik2Bsolver::ik2Bsolver() +// : MPxIkSolverNode() +//{ +//} +// +//ik2Bsolver::~ik2Bsolver() {} +// +//void ik2Bsolver::postConstructor() +//{ +// setRotatePlane(true); +//} +// +//void* ik2Bsolver::creator() +//{ +// return new ik2Bsolver; +//} +// +//MStatus ik2Bsolver::initialize() +//{ +// return MS::kSuccess; +//} +// +//MString ik2Bsolver::solverTypeName() const +//// +//// This method returns the type name used to identify this solver. +//// +//{ +// return MString(kSolverType); +//} +// +//MStatus ik2Bsolver::doSolve() +//// +//// This is the doSolve method which calls solveIK. +//// +//{ +// MStatus stat; +// +// // Handle Group +// // +// MIkHandleGroup * handle_group = handleGroup(); +// if (NULL == handle_group) { +// return MS::kFailure; +// } +// +// // Handle +// // +// // For single chain types of solvers, get the 0th handle. +// // Single chain solvers are solvers which act on one handle only, +// // i.e. the handle group for a single chain solver +// // has only one handle +// // +// MObject handle = handle_group->handle(0); +// MDagPath handlePath = MDagPath::getAPathTo(handle); +// MFnIkHandle handleFn(handlePath, &stat); +// +// // Effector +// // +// MDagPath effectorPath; +// handleFn.getEffector(effectorPath); +// MFnIkEffector effectorFn(effectorPath); +// +// // Mid Joint +// // +// effectorPath.pop(); +// MFnIkJoint midJointFn(effectorPath); +// +// // Start Joint +// // +// MDagPath startJointPath; +// handleFn.getStartJoint(startJointPath); +// MFnIkJoint startJointFn(startJointPath); +// +// // Preferred angles +// // +// double startJointPrefAngle[3]; +// double midJointPrefAngle[3]; +// startJointFn.getPreferedAngle(startJointPrefAngle); +// midJointFn.getPreferedAngle(midJointPrefAngle); +// +// // Set to preferred angles +// // +// startJointFn.setRotation(startJointPrefAngle, +// startJointFn.rotationOrder()); +// midJointFn.setRotation(midJointPrefAngle, +// midJointFn.rotationOrder()); +// +// AwPoint handlePos = handleFn.rotatePivot(MSpace::kWorld); +// AwPoint effectorPos = effectorFn.rotatePivot(MSpace::kWorld); +// AwPoint midJointPos = midJointFn.rotatePivot(MSpace::kWorld); +// AwPoint startJointPos = startJointFn.rotatePivot(MSpace::kWorld); +// AwVector poleVector = poleVectorFromHandle(handlePath); +// poleVector *= handlePath.exclusiveMatrix(); +// double twistValue = twistFromHandle(handlePath); +// +// AwQuaternion qStart, qMid; +// +// solveIK(startJointPos, +// midJointPos, +// effectorPos, +// handlePos, +// poleVector, +// twistValue, +// qStart, +// qMid); +// +// midJointFn.rotateBy(qMid, MSpace::kWorld); +// startJointFn.rotateBy(qStart, MSpace::kWorld); +// +// return MS::kSuccess; +//} + +void solveIK(const AwPoint &startJointPos, + const AwPoint &midJointPos, + const AwPoint &effectorPos, + const AwPoint &handlePos, + const AwVector &poleVector, + double twistValue, + AwQuaternion &qStart, + AwQuaternion &qMid) +// +// This is method that actually computes the IK solution. +// +{ + // vector from startJoint to midJoint + AwVector vector1 = midJointPos - startJointPos; + // vector from midJoint to effector + AwVector vector2 = effectorPos - midJointPos; + // vector from startJoint to handle + AwVector vectorH = handlePos - startJointPos; + // vector from startJoint to effector + AwVector vectorE = effectorPos - startJointPos; + // lengths of those vectors + double length1 = vector1.length(); + double length2 = vector2.length(); + double lengthH = vectorH.length(); + // component of the vector1 orthogonal to the vectorE + AwVector vectorO = + vector1 - vectorE*((vector1*vectorE)/(vectorE*vectorE)); + + ////////////////////////////////////////////////////////////////// + // calculate q12 which solves for the midJoint rotation + ////////////////////////////////////////////////////////////////// + // angle between vector1 and vector2 + double vectorAngle12 = vector1.angle(vector2); + // vector orthogonal to vector1 and 2 + AwVector vectorCross12 = vector1^vector2; + double lengthHsquared = lengthH*lengthH; + // angle for arm extension + double cos_theta = + (lengthHsquared - length1*length1 - length2*length2) + /(2*length1*length2); + if (cos_theta > 1) + cos_theta = 1; + else if (cos_theta < -1) + cos_theta = -1; + double theta = acos(cos_theta); + // quaternion for arm extension + AwQuaternion q12(theta - vectorAngle12, vectorCross12); + + ////////////////////////////////////////////////////////////////// + // calculate qEH which solves for effector rotating onto the handle + ////////////////////////////////////////////////////////////////// + // vector2 with quaternion q12 applied + vector2 = vector2.rotateBy(q12); + // vectorE with quaternion q12 applied + vectorE = vector1 + vector2; + // quaternion for rotating the effector onto the handle + AwQuaternion qEH(vectorE, vectorH); + + ////////////////////////////////////////////////////////////////// + // calculate qNP which solves for the rotate plane + ////////////////////////////////////////////////////////////////// + // vector1 with quaternion qEH applied + vector1 = vector1.rotateBy(qEH); + if (vector1.isParallel(vectorH)) + // singular case, use orthogonal component instead + vector1 = vectorO.rotateBy(qEH); + // quaternion for rotate plane + AwQuaternion qNP; + if (!poleVector.isParallel(vectorH) && (lengthHsquared != 0)) { + // component of vector1 orthogonal to vectorH + AwVector vectorN = + vector1 - vectorH*((vector1*vectorH)/lengthHsquared); + // component of pole vector orthogonal to vectorH + AwVector vectorP = + poleVector - vectorH*((poleVector*vectorH)/lengthHsquared); + double dotNP = (vectorN*vectorP)/(vectorN.length()*vectorP.length()); + if (absoluteValue(dotNP + 1.0) < kEpsilon) { + // singular case, rotate halfway around vectorH + AwQuaternion qNP1(kPi, vectorH); + qNP = qNP1; + } + else { + AwQuaternion qNP2(vectorN, vectorP); + qNP = qNP2; + } + } + + ////////////////////////////////////////////////////////////////// + // calculate qTwist which adds the twist + ////////////////////////////////////////////////////////////////// + AwQuaternion qTwist(twistValue, vectorH); + + // quaternion for the mid joint + qMid = q12; + // concatenate the quaternions for the start joint + qStart = qEH*qNP*qTwist; +} + +//AwVector ik2Bsolver::poleVectorFromHandle(const MDagPath &handlePath) +//// +//// This method returns the pole vector of the IK handle. +//// +//{ +// MStatus stat; +// MFnIkHandle handleFn(handlePath, &stat); +// MPlug pvxPlug = handleFn.findPlug("pvx"); +// MPlug pvyPlug = handleFn.findPlug("pvy"); +// MPlug pvzPlug = handleFn.findPlug("pvz"); +// double pvxValue, pvyValue, pvzValue; +// pvxPlug.getValue(pvxValue); +// pvyPlug.getValue(pvyValue); +// pvzPlug.getValue(pvzValue); +// AwVector poleVector(pvxValue, pvyValue, pvzValue); +// return poleVector; +//} +// +//double ik2Bsolver::twistFromHandle(const MDagPath &handlePath) +//// +//// This method returns the twist of the IK handle. +//// +//{ +// MStatus stat; +// MFnIkHandle handleFn(handlePath, &stat); +// MPlug twistPlug = handleFn.findPlug("twist"); +// double twistValue; +// twistPlug.getValue(twistValue); +// return twistValue; +//} +// +// +//////////////////////////////////////////////////////////////////// +//// +//// IK 2 Bone Solver Callbacks +//// +//////////////////////////////////////////////////////////////////// +// +//class addIK2BsolverCallbacks : public MPxCommand { +//public: +// addIK2BsolverCallbacks() {}; +// virtual MStatus doIt (const MArgList &); +// static void* creator(); +// +// // callback IDs for the solver callbacks +// static MCallbackId afterNewId; +// static MCallbackId afterOpenId; +//}; +// +//MCallbackId addIK2BsolverCallbacks::afterNewId; +//MCallbackId addIK2BsolverCallbacks::afterOpenId; +// +//void *addIK2BsolverCallbacks::creator() +//{ +// return new addIK2BsolverCallbacks; +//} +// +//void createIK2BsolverAfterNew(void *clientData) +//// +//// This method creates the ik2Bsolver after a File->New. +//// +//{ +// MSelectionList selList; +// MGlobal::getActiveSelectionList( selList ); +// MGlobal::executeCommand("createNode -n ik2Bsolver ik2Bsolver"); +// MGlobal::setActiveSelectionList( selList ); +//} +// +//void createIK2BsolverAfterOpen(void *clientData) +//// +//// This method creates the ik2Bsolver after a File->Open +//// if the ik2Bsolver does not exist in the loaded file. +//// +//{ +// MSelectionList selList; +// MGlobal::getSelectionListByName("ik2Bsolver", selList); +// if (selList.length() == 0) { +// MGlobal::getActiveSelectionList( selList ); +// MGlobal::executeCommand("createNode -n ik2Bsolver ik2Bsolver"); +// MGlobal::setActiveSelectionList( selList ); +// } +//} +// +//MStatus addIK2BsolverCallbacks::doIt(const MArgList &args) +//// +//// This method adds the File->New and File->Open callbacks +//// used to recreate the ik2Bsolver. +//// +//{ +// // Get the callback IDs so we can deregister them +// // when the plug-in is unloaded. +// afterNewId = MSceneMessage::addCallback(MSceneMessage::kAfterNew, +// createIK2BsolverAfterNew); +// afterOpenId = MSceneMessage::addCallback(MSceneMessage::kAfterOpen, +// createIK2BsolverAfterOpen); +// return MS::kSuccess; +//} +// +// +/////////////////////////////////////////////////////////// +//// +//// Register the IK 2 Bone Solver and Callback Command +//// +/////////////////////////////////////////////////////////// +//MStatus initializePlugin(MObject obj) +//{ +// MStatus status; +// MFnPlugin plugin(obj, "Autodesk", "2.5", "Any"); +// +// status = plugin.registerNode("ik2Bsolver", +// ik2Bsolver::id, +// &ik2Bsolver::creator, +// &ik2Bsolver::initialize, +// MPxNode::kIkSolverNode); +// if (!status) { +// status.perror("registerNode"); +// return status; +// } +// +// status = plugin.registerCommand("addIK2BsolverCallbacks", +// addIK2BsolverCallbacks::creator); +// if (!status) { +// status.perror("registerCommand"); +// return status; +// } +// +// // Register post-load MEL proc +// // +// // Note: We make use of the MFnPlugin::registerUI() method which executes +// // the given MEL procedures following the plugin load to execute our method. +// // This method will ensure that the solver node is created on plugin load. +// // +// //status = plugin.registerUI("ik2Bsolver", ""); +// +// return status; +//} +// +//MStatus uninitializePlugin(MObject obj) +//{ +// MStatus status; +// MFnPlugin plugin(obj); +// +// status = plugin.deregisterNode(ik2Bsolver::id); +// if (!status) { +// status.perror("deregisterNode"); +// return status; +// } +// +// status = plugin.deregisterCommand("addIK2BsolverCallbacks"); +// if (!status) { +// status.perror("deregisterCommand"); +// return status; +// } +// +// // Remove callbacks when plug-in is unloaded. +// MMessage::removeCallback(addIK2BsolverCallbacks::afterNewId); +// MMessage::removeCallback(addIK2BsolverCallbacks::afterOpenId); +// +// return status; +//} +// diff --git a/Loader/ik2Bsolver/ik2Bsolver.h b/Loader/ik2Bsolver/ik2Bsolver.h new file mode 100644 index 000000000..6882868de --- /dev/null +++ b/Loader/ik2Bsolver/ik2Bsolver.h @@ -0,0 +1,13 @@ +#include +#include +#include +#include + +void solveIK(const AwPoint &startJointPos, + const AwPoint &midJointPos, + const AwPoint &effectorPos, + const AwPoint &handlePos, + const AwVector &poleVector, + double twistValue, + AwQuaternion &qStart, + AwQuaternion &qMid); diff --git a/Loader/ik2Bsolver/ik2Bsolver.sln b/Loader/ik2Bsolver/ik2Bsolver.sln new file mode 100644 index 000000000..5692d14bb --- /dev/null +++ b/Loader/ik2Bsolver/ik2Bsolver.sln @@ -0,0 +1,45 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ik2Bsolver", "ik2Bsolver.vcproj", "{E94818A8-37B3-42C0-AA0E-64365C7CFCD4}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test\test.vcproj", "{41071E54-4119-47BC-A2FA-180E9E8DD2FE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + ReleaseDebug|Win32 = ReleaseDebug|Win32 + ReleaseDebug|x64 = ReleaseDebug|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E94818A8-37B3-42C0-AA0E-64365C7CFCD4}.Debug|Win32.ActiveCfg = Debug|Win32 + {E94818A8-37B3-42C0-AA0E-64365C7CFCD4}.Debug|Win32.Build.0 = Debug|Win32 + {E94818A8-37B3-42C0-AA0E-64365C7CFCD4}.Debug|x64.ActiveCfg = Debug|x64 + {E94818A8-37B3-42C0-AA0E-64365C7CFCD4}.Debug|x64.Build.0 = Debug|x64 + {E94818A8-37B3-42C0-AA0E-64365C7CFCD4}.Release|Win32.ActiveCfg = Release|Win32 + {E94818A8-37B3-42C0-AA0E-64365C7CFCD4}.Release|Win32.Build.0 = Release|Win32 + {E94818A8-37B3-42C0-AA0E-64365C7CFCD4}.Release|x64.ActiveCfg = Release|x64 + {E94818A8-37B3-42C0-AA0E-64365C7CFCD4}.Release|x64.Build.0 = Release|x64 + {E94818A8-37B3-42C0-AA0E-64365C7CFCD4}.ReleaseDebug|Win32.ActiveCfg = ReleaseDebug|Win32 + {E94818A8-37B3-42C0-AA0E-64365C7CFCD4}.ReleaseDebug|Win32.Build.0 = ReleaseDebug|Win32 + {E94818A8-37B3-42C0-AA0E-64365C7CFCD4}.ReleaseDebug|x64.ActiveCfg = ReleaseDebug|x64 + {E94818A8-37B3-42C0-AA0E-64365C7CFCD4}.ReleaseDebug|x64.Build.0 = ReleaseDebug|x64 + {41071E54-4119-47BC-A2FA-180E9E8DD2FE}.Debug|Win32.ActiveCfg = Debug|Win32 + {41071E54-4119-47BC-A2FA-180E9E8DD2FE}.Debug|Win32.Build.0 = Debug|Win32 + {41071E54-4119-47BC-A2FA-180E9E8DD2FE}.Debug|x64.ActiveCfg = Debug|x64 + {41071E54-4119-47BC-A2FA-180E9E8DD2FE}.Debug|x64.Build.0 = Debug|x64 + {41071E54-4119-47BC-A2FA-180E9E8DD2FE}.Release|Win32.ActiveCfg = Release|Win32 + {41071E54-4119-47BC-A2FA-180E9E8DD2FE}.Release|Win32.Build.0 = Release|Win32 + {41071E54-4119-47BC-A2FA-180E9E8DD2FE}.Release|x64.ActiveCfg = Release|x64 + {41071E54-4119-47BC-A2FA-180E9E8DD2FE}.Release|x64.Build.0 = Release|x64 + {41071E54-4119-47BC-A2FA-180E9E8DD2FE}.ReleaseDebug|Win32.ActiveCfg = Debug|Win32 + {41071E54-4119-47BC-A2FA-180E9E8DD2FE}.ReleaseDebug|Win32.Build.0 = Debug|Win32 + {41071E54-4119-47BC-A2FA-180E9E8DD2FE}.ReleaseDebug|x64.ActiveCfg = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Loader/ik2Bsolver/ik2Bsolver.vcproj b/Loader/ik2Bsolver/ik2Bsolver.vcproj new file mode 100644 index 000000000..029d8b375 --- /dev/null +++ b/Loader/ik2Bsolver/ik2Bsolver.vcproj @@ -0,0 +1,890 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Loader/ik2Bsolver/test/main.cpp b/Loader/ik2Bsolver/test/main.cpp new file mode 100644 index 000000000..b563eb5db --- /dev/null +++ b/Loader/ik2Bsolver/test/main.cpp @@ -0,0 +1,222 @@ +#include + +#include +#include +#include +#include +#include + +static const int KEY_SPACE = ' '; +static const int KEY_ESCAPE = '\033'; + +AwPoint startJointPos, midJointPos, effectorPos, handlePos; +AwVector poleVector; +double twistValue; +AwQuaternion qStart; +AwQuaternion qMid; +AwMatrix mStart, mMid; + +int currentButton = 0; + +template +inline T +Min( const T a, const T b ) +{ + return a <= b ? a : b; // use <= to maintain order +} + +void +Draw( void ) +{ + static bool firstTime = true; + if ( firstTime ) + { + // init bones + startJointPos.set(.0, .0); + midJointPos.set(.2, .4); + effectorPos.set(.5, .5); + handlePos.set(.5, .5); + twistValue = .0; + poleVector = AwVector(-1,1).normalize(); + firstTime = false; + } + + static GLfloat polygonColor1[] = { .25f, .8f, .8f }; + static GLfloat polygonColor2[] = { .8f, .25f, .8f }; + + // clear out buffer + glClearColor( 0.f, 0.f, 0.f, 0.f ); + glClear( GL_COLOR_BUFFER_BIT ); + + // draw primitives + glPushMatrix(); + glTranslated( startJointPos.x, startJointPos.y, 0 ); + glMultMatrixd( &mStart.matrix[0][0] ); + glBegin( GL_LINES ); + glColor3fv( polygonColor1 ); + glVertex2f(0,0); + glVertex2f(midJointPos.x-startJointPos.x, midJointPos.y-startJointPos.y); + glEnd(); + + glTranslated( midJointPos.x, midJointPos.y, 0 ); + glMultMatrixd( &mMid.matrix[0][0] ); + glBegin( GL_LINES ); + glColor3fv( polygonColor2 ); + glVertex2f(0,0); + glVertex2f(effectorPos.x-midJointPos.x, effectorPos.y-midJointPos.y); + glEnd(); + glPopMatrix(); + + // show result + glutSwapBuffers(); +} + +void +Reshape( int width, int height ) +{ + // the user just changed the window size + // Adjust projection parameters + glViewport( 0, 0, width, height ); + + // correct projection to avoid distortion + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + + // make it normalized + if( width > height ){ + GLdouble aspect = GLdouble( width ) / height; + gluOrtho2D( -aspect, aspect, -1., 1. ); + }else{ + GLdouble aspect = GLdouble( height ) / width; + gluOrtho2D( -1., 1., -aspect, aspect ); + } + + // and back to ModelView + glMatrixMode( GL_MODELVIEW ); +} + +void +Keyboard( unsigned char c, int x, int y ) +{ + switch( c ){ + case KEY_SPACE: + break; + case KEY_ESCAPE: + exit( 0 ); + break; + default: + ; + } +} + +void +Motion( int x, int y ) +{ + if ( currentButton == GLUT_LEFT_BUTTON ) + { + handlePos.set( (x - 500)/ 500.0, -(y - 500)/ 500.0 ); + } + else if ( currentButton == GLUT_RIGHT_BUTTON ) + { + startJointPos.set( (x - 500)/ 500.0, -(y - 500)/ 500.0 ); + } + + solveIK( startJointPos, midJointPos, effectorPos, handlePos, poleVector, twistValue, qStart, qMid ); + + qStart.convertToMatrix( mStart ); + qMid.convertToMatrix( mMid ); + + glutPostRedisplay(); +} + +// button click callback +void +Mouse( int button, int state, int x, int y ) +{ + switch( button ) + { + + case GLUT_LEFT_BUTTON: + // animation control + if( state == GLUT_DOWN ) + { + currentButton = button; + } + else if( state == GLUT_UP ) + { + currentButton = 0; + } + else + { + assert( 0 ); + } + break; + + case GLUT_MIDDLE_BUTTON: + break; + + case GLUT_RIGHT_BUTTON: + if( state == GLUT_DOWN ) + { + currentButton = button; + } + else if( state == GLUT_UP ) + { + currentButton = 0; + } + else + { + assert( 0 ); + } + break; + + default: + assert( 0 ); + + } +} + + +void +Init( void ) +{ + glutDisplayFunc( Draw ); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Keyboard ); + glutMouseFunc( Mouse ); + glutMotionFunc( Motion ); + glutPassiveMotionFunc( 0 ); + glutMenuStatusFunc( 0 ); + glutEntryFunc( 0 ); + + // setup orthographic projection + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + // make it normalized + gluOrtho2D( -1., 1., -1., 1. ); + + // back to the model matrix + glMatrixMode( GL_MODELVIEW ); +} + +int +main( int argc, char *argv[] ) +{ + // let glut eat any command line args that it owns + glutInit( &argc, argv ); + + glutInitWindowSize(1000, 1000); + glutInitWindowPosition(300, 80); + + // full color, double buffered + glutInitDisplayMode( GLUT_RGBA | GLUT_DOUBLE ); + glutCreateWindow( "IK Test" ); + + // setup remaining state + Init(); + + // start processing events + glutMainLoop(); + + return 0; +} diff --git a/Loader/ik2Bsolver/test/test.vcproj b/Loader/ik2Bsolver/test/test.vcproj new file mode 100644 index 000000000..9a5e12301 --- /dev/null +++ b/Loader/ik2Bsolver/test/test.vcproj @@ -0,0 +1,347 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Loader/mm_malloc.h b/Loader/mm_malloc.h new file mode 100644 index 000000000..5d68d55d7 --- /dev/null +++ b/Loader/mm_malloc.h @@ -0,0 +1,86 @@ +/* + * mm_malloc.h + * Loader + * + * Created by Jun Murakawa on 7/11/09. + * Copyright 2009 __MyCompanyName__. All rights reserved. + * + */ + +/* Copyright (C) 2004 Free Software Foundation, Inc. + + This file is part of GCC. + + GCC is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + GCC is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GCC; see the file COPYING. If not, write to + the Free Software Foundation, 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, if you include this header file into source + files compiled by GCC, this header file does not by itself cause + the resulting executable to be covered by the GNU General Public + License. This exception does not however invalidate any other + reasons why the executable file might be covered by the GNU General + Public License. */ + +#ifndef _MM_MALLOC_H_INCLUDED +#define _MM_MALLOC_H_INCLUDED + +#include +#include + +static __inline__ void* +_mm_malloc (size_t size, size_t align) +{ + void * malloc_ptr; + void * aligned_ptr; + + /* Error if align is not a power of two. */ + if (align & (align - 1)) + { + errno = EINVAL; + return ((void*) 0); + } + + if (size == 0) + return ((void *) 0); + + /* Assume malloc'd pointer is aligned at least to sizeof (void*). + If necessary, add another sizeof (void*) to store the value + returned by malloc. Effectively this enforces a minimum alignment + of sizeof double. */ + if (align < 2 * sizeof (void *)) + align = 2 * sizeof (void *); + + malloc_ptr = malloc (size + align); + if (!malloc_ptr) + return ((void *) 0); + + /* Align We have at least sizeof (void *) space below malloc'd ptr. */ + aligned_ptr = (void *) (((size_t) malloc_ptr + align) + & ~((size_t) (align) - 1)); + + /* Store the original pointer just before p. */ + ((void **) aligned_ptr) [-1] = malloc_ptr; + + return aligned_ptr; +} + +static __inline__ void +_mm_free (void * aligned_ptr) +{ + if (aligned_ptr) + free (((void **) aligned_ptr) [-1]); +} + +#endif /* _MM_MALLOC_H_INCLUDED */ \ No newline at end of file diff --git a/irrlicht-1.6/source/Irrlicht/wglext.h b/Loader/wglext.h similarity index 89% rename from irrlicht-1.6/source/Irrlicht/wglext.h rename to Loader/wglext.h index 4f7d1a1aa..0286a913c 100644 --- a/irrlicht-1.6/source/Irrlicht/wglext.h +++ b/Loader/wglext.h @@ -1,834 +1,776 @@ -#ifndef __wglext_h_ -#define __wglext_h_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* -** Copyright (c) 2007-2009 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -/* Function declaration macros - to move into glplatform.h */ - -#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) -#define WIN32_LEAN_AND_MEAN 1 -#include -#endif - -#ifndef APIENTRY -#define APIENTRY -#endif -#ifndef APIENTRYP -#define APIENTRYP APIENTRY * -#endif -#ifndef GLAPI -#define GLAPI extern -#endif - -/*************************************************************/ - -/* Header file version number */ -/* wglext.h last updated 2009/08/03 */ -/* Current version at http://www.opengl.org/registry/ */ -#define WGL_WGLEXT_VERSION 15 - -#ifndef WGL_ARB_buffer_region -#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001 -#define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002 -#define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004 -#define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008 -#endif - -#ifndef WGL_ARB_multisample -#define WGL_SAMPLE_BUFFERS_ARB 0x2041 -#define WGL_SAMPLES_ARB 0x2042 -#endif - -#ifndef WGL_ARB_extensions_string -#endif - -#ifndef WGL_ARB_pixel_format -#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 -#define WGL_DRAW_TO_WINDOW_ARB 0x2001 -#define WGL_DRAW_TO_BITMAP_ARB 0x2002 -#define WGL_ACCELERATION_ARB 0x2003 -#define WGL_NEED_PALETTE_ARB 0x2004 -#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 -#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 -#define WGL_SWAP_METHOD_ARB 0x2007 -#define WGL_NUMBER_OVERLAYS_ARB 0x2008 -#define WGL_NUMBER_UNDERLAYS_ARB 0x2009 -#define WGL_TRANSPARENT_ARB 0x200A -#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 -#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 -#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 -#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A -#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B -#define WGL_SHARE_DEPTH_ARB 0x200C -#define WGL_SHARE_STENCIL_ARB 0x200D -#define WGL_SHARE_ACCUM_ARB 0x200E -#define WGL_SUPPORT_GDI_ARB 0x200F -#define WGL_SUPPORT_OPENGL_ARB 0x2010 -#define WGL_DOUBLE_BUFFER_ARB 0x2011 -#define WGL_STEREO_ARB 0x2012 -#define WGL_PIXEL_TYPE_ARB 0x2013 -#define WGL_COLOR_BITS_ARB 0x2014 -#define WGL_RED_BITS_ARB 0x2015 -#define WGL_RED_SHIFT_ARB 0x2016 -#define WGL_GREEN_BITS_ARB 0x2017 -#define WGL_GREEN_SHIFT_ARB 0x2018 -#define WGL_BLUE_BITS_ARB 0x2019 -#define WGL_BLUE_SHIFT_ARB 0x201A -#define WGL_ALPHA_BITS_ARB 0x201B -#define WGL_ALPHA_SHIFT_ARB 0x201C -#define WGL_ACCUM_BITS_ARB 0x201D -#define WGL_ACCUM_RED_BITS_ARB 0x201E -#define WGL_ACCUM_GREEN_BITS_ARB 0x201F -#define WGL_ACCUM_BLUE_BITS_ARB 0x2020 -#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 -#define WGL_DEPTH_BITS_ARB 0x2022 -#define WGL_STENCIL_BITS_ARB 0x2023 -#define WGL_AUX_BUFFERS_ARB 0x2024 -#define WGL_NO_ACCELERATION_ARB 0x2025 -#define WGL_GENERIC_ACCELERATION_ARB 0x2026 -#define WGL_FULL_ACCELERATION_ARB 0x2027 -#define WGL_SWAP_EXCHANGE_ARB 0x2028 -#define WGL_SWAP_COPY_ARB 0x2029 -#define WGL_SWAP_UNDEFINED_ARB 0x202A -#define WGL_TYPE_RGBA_ARB 0x202B -#define WGL_TYPE_COLORINDEX_ARB 0x202C -#endif - -#ifndef WGL_ARB_make_current_read -#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043 -#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 -#endif - -#ifndef WGL_ARB_pbuffer -#define WGL_DRAW_TO_PBUFFER_ARB 0x202D -#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E -#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F -#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 -#define WGL_PBUFFER_LARGEST_ARB 0x2033 -#define WGL_PBUFFER_WIDTH_ARB 0x2034 -#define WGL_PBUFFER_HEIGHT_ARB 0x2035 -#define WGL_PBUFFER_LOST_ARB 0x2036 -#endif - -#ifndef WGL_ARB_render_texture -#define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070 -#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071 -#define WGL_TEXTURE_FORMAT_ARB 0x2072 -#define WGL_TEXTURE_TARGET_ARB 0x2073 -#define WGL_MIPMAP_TEXTURE_ARB 0x2074 -#define WGL_TEXTURE_RGB_ARB 0x2075 -#define WGL_TEXTURE_RGBA_ARB 0x2076 -#define WGL_NO_TEXTURE_ARB 0x2077 -#define WGL_TEXTURE_CUBE_MAP_ARB 0x2078 -#define WGL_TEXTURE_1D_ARB 0x2079 -#define WGL_TEXTURE_2D_ARB 0x207A -#define WGL_MIPMAP_LEVEL_ARB 0x207B -#define WGL_CUBE_MAP_FACE_ARB 0x207C -#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D -#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E -#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F -#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080 -#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081 -#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082 -#define WGL_FRONT_LEFT_ARB 0x2083 -#define WGL_FRONT_RIGHT_ARB 0x2084 -#define WGL_BACK_LEFT_ARB 0x2085 -#define WGL_BACK_RIGHT_ARB 0x2086 -#define WGL_AUX0_ARB 0x2087 -#define WGL_AUX1_ARB 0x2088 -#define WGL_AUX2_ARB 0x2089 -#define WGL_AUX3_ARB 0x208A -#define WGL_AUX4_ARB 0x208B -#define WGL_AUX5_ARB 0x208C -#define WGL_AUX6_ARB 0x208D -#define WGL_AUX7_ARB 0x208E -#define WGL_AUX8_ARB 0x208F -#define WGL_AUX9_ARB 0x2090 -#endif - -#ifndef WGL_ARB_pixel_format_float -#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 -#endif - -#ifndef WGL_ARB_create_context -#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001 -#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 -#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 -#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 -#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 -#define WGL_CONTEXT_FLAGS_ARB 0x2094 -#define ERROR_INVALID_VERSION_ARB 0x2095 -#endif - -#ifndef WGL_ARB_create_context_profile -#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 -#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 -#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 -#define ERROR_INVALID_PROFILE_ARB 0x2096 -#endif - -#ifndef WGL_EXT_make_current_read -#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043 -#endif - -#ifndef WGL_EXT_pixel_format -#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000 -#define WGL_DRAW_TO_WINDOW_EXT 0x2001 -#define WGL_DRAW_TO_BITMAP_EXT 0x2002 -#define WGL_ACCELERATION_EXT 0x2003 -#define WGL_NEED_PALETTE_EXT 0x2004 -#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005 -#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006 -#define WGL_SWAP_METHOD_EXT 0x2007 -#define WGL_NUMBER_OVERLAYS_EXT 0x2008 -#define WGL_NUMBER_UNDERLAYS_EXT 0x2009 -#define WGL_TRANSPARENT_EXT 0x200A -#define WGL_TRANSPARENT_VALUE_EXT 0x200B -#define WGL_SHARE_DEPTH_EXT 0x200C -#define WGL_SHARE_STENCIL_EXT 0x200D -#define WGL_SHARE_ACCUM_EXT 0x200E -#define WGL_SUPPORT_GDI_EXT 0x200F -#define WGL_SUPPORT_OPENGL_EXT 0x2010 -#define WGL_DOUBLE_BUFFER_EXT 0x2011 -#define WGL_STEREO_EXT 0x2012 -#define WGL_PIXEL_TYPE_EXT 0x2013 -#define WGL_COLOR_BITS_EXT 0x2014 -#define WGL_RED_BITS_EXT 0x2015 -#define WGL_RED_SHIFT_EXT 0x2016 -#define WGL_GREEN_BITS_EXT 0x2017 -#define WGL_GREEN_SHIFT_EXT 0x2018 -#define WGL_BLUE_BITS_EXT 0x2019 -#define WGL_BLUE_SHIFT_EXT 0x201A -#define WGL_ALPHA_BITS_EXT 0x201B -#define WGL_ALPHA_SHIFT_EXT 0x201C -#define WGL_ACCUM_BITS_EXT 0x201D -#define WGL_ACCUM_RED_BITS_EXT 0x201E -#define WGL_ACCUM_GREEN_BITS_EXT 0x201F -#define WGL_ACCUM_BLUE_BITS_EXT 0x2020 -#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021 -#define WGL_DEPTH_BITS_EXT 0x2022 -#define WGL_STENCIL_BITS_EXT 0x2023 -#define WGL_AUX_BUFFERS_EXT 0x2024 -#define WGL_NO_ACCELERATION_EXT 0x2025 -#define WGL_GENERIC_ACCELERATION_EXT 0x2026 -#define WGL_FULL_ACCELERATION_EXT 0x2027 -#define WGL_SWAP_EXCHANGE_EXT 0x2028 -#define WGL_SWAP_COPY_EXT 0x2029 -#define WGL_SWAP_UNDEFINED_EXT 0x202A -#define WGL_TYPE_RGBA_EXT 0x202B -#define WGL_TYPE_COLORINDEX_EXT 0x202C -#endif - -#ifndef WGL_EXT_pbuffer -#define WGL_DRAW_TO_PBUFFER_EXT 0x202D -#define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E -#define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F -#define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030 -#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031 -#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032 -#define WGL_PBUFFER_LARGEST_EXT 0x2033 -#define WGL_PBUFFER_WIDTH_EXT 0x2034 -#define WGL_PBUFFER_HEIGHT_EXT 0x2035 -#endif - -#ifndef WGL_EXT_depth_float -#define WGL_DEPTH_FLOAT_EXT 0x2040 -#endif - -#ifndef WGL_3DFX_multisample -#define WGL_SAMPLE_BUFFERS_3DFX 0x2060 -#define WGL_SAMPLES_3DFX 0x2061 -#endif - -#ifndef WGL_EXT_multisample -#define WGL_SAMPLE_BUFFERS_EXT 0x2041 -#define WGL_SAMPLES_EXT 0x2042 -#endif - -#ifndef WGL_I3D_digital_video_control -#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050 -#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051 -#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052 -#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053 -#endif - -#ifndef WGL_I3D_gamma -#define WGL_GAMMA_TABLE_SIZE_I3D 0x204E -#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F -#endif - -#ifndef WGL_I3D_genlock -#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044 -#define WGL_GENLOCK_SOURCE_EXTENAL_SYNC_I3D 0x2045 -#define WGL_GENLOCK_SOURCE_EXTENAL_FIELD_I3D 0x2046 -#define WGL_GENLOCK_SOURCE_EXTENAL_TTL_I3D 0x2047 -#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048 -#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049 -#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A -#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B -#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C -#endif - -#ifndef WGL_I3D_image_buffer -#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001 -#define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002 -#endif - -#ifndef WGL_I3D_swap_frame_lock -#endif - -#ifndef WGL_NV_render_depth_texture -#define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4 -#define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5 -#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6 -#define WGL_DEPTH_COMPONENT_NV 0x20A7 -#endif - -#ifndef WGL_NV_render_texture_rectangle -#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1 -#define WGL_TEXTURE_RECTANGLE_NV 0x20A2 -#endif - -#ifndef WGL_ATI_pixel_format_float -#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0 -#endif - -#ifndef WGL_NV_float_buffer -#define WGL_FLOAT_COMPONENTS_NV 0x20B0 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4 -#define WGL_TEXTURE_FLOAT_R_NV 0x20B5 -#define WGL_TEXTURE_FLOAT_RG_NV 0x20B6 -#define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7 -#define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8 -#endif - -#ifndef WGL_3DL_stereo_control -#define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055 -#define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056 -#define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057 -#define WGL_STEREO_POLARITY_INVERT_3DL 0x2058 -#endif - -#ifndef WGL_EXT_pixel_format_packed_float -#define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8 -#endif - -#ifndef WGL_EXT_framebuffer_sRGB -#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9 -#endif - -#ifndef WGL_NV_present_video -#define WGL_NUM_VIDEO_SLOTS_NV 0x20F0 -#endif - -#ifndef WGL_NV_video_out -#define WGL_BIND_TO_VIDEO_RGB_NV 0x20C0 -#define WGL_BIND_TO_VIDEO_RGBA_NV 0x20C1 -#define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2 -#define WGL_VIDEO_OUT_COLOR_NV 0x20C3 -#define WGL_VIDEO_OUT_ALPHA_NV 0x20C4 -#define WGL_VIDEO_OUT_DEPTH_NV 0x20C5 -#define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6 -#define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7 -#define WGL_VIDEO_OUT_FRAME 0x20C8 -#define WGL_VIDEO_OUT_FIELD_1 0x20C9 -#define WGL_VIDEO_OUT_FIELD_2 0x20CA -#define WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB -#define WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC -#endif - -#ifndef WGL_NV_swap_group -#endif - -#ifndef WGL_NV_gpu_affinity -#define WGL_ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0 -#define WGL_ERROR_MISSING_AFFINITY_MASK_NV 0x20D1 -#endif - -#ifndef WGL_AMD_gpu_association -#define WGL_GPU_VENDOR_AMD 0x1F00 -#define WGL_GPU_RENDERER_STRING_AMD 0x1F01 -#define WGL_GPU_OPENGL_VERSION_STRING_AMD 0x1F02 -#define WGL_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2 -#define WGL_GPU_RAM_AMD 0x21A3 -#define WGL_GPU_CLOCK_AMD 0x21A4 -#define WGL_GPU_NUM_PIPES_AMD 0x21A5 -#define WGL_GPU_NUM_SIMD_AMD 0x21A6 -#define WGL_GPU_NUM_RB_AMD 0x21A7 -#define WGL_GPU_NUM_SPI_AMD 0x21A8 -#endif - - -/*************************************************************/ - -#ifndef WGL_ARB_pbuffer -DECLARE_HANDLE(HPBUFFERARB); -#endif -#ifndef WGL_EXT_pbuffer -DECLARE_HANDLE(HPBUFFEREXT); -#endif -#ifndef WGL_NV_present_video -DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV); -#endif -#ifndef WGL_NV_video_out -DECLARE_HANDLE(HPVIDEODEV); -#endif -#ifndef WGL_NV_gpu_affinity -DECLARE_HANDLE(HPGPUNV); -DECLARE_HANDLE(HGPUNV); - -typedef struct _GPU_DEVICE { - DWORD cb; - CHAR DeviceName[32]; - CHAR DeviceString[128]; - DWORD Flags; - RECT rcVirtualScreen; -} GPU_DEVICE, *PGPU_DEVICE; -#endif - -#ifndef WGL_ARB_buffer_region -#define WGL_ARB_buffer_region 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern HANDLE WINAPI wglCreateBufferRegionARB (HDC, int, UINT); -extern VOID WINAPI wglDeleteBufferRegionARB (HANDLE); -extern BOOL WINAPI wglSaveBufferRegionARB (HANDLE, int, int, int, int); -extern BOOL WINAPI wglRestoreBufferRegionARB (HANDLE, int, int, int, int, int, int); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType); -typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion); -typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height); -typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); -#endif - -#ifndef WGL_ARB_multisample -#define WGL_ARB_multisample 1 -#endif - -#ifndef WGL_ARB_extensions_string -#define WGL_ARB_extensions_string 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern const char * WINAPI wglGetExtensionsStringARB (HDC); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc); -#endif - -#ifndef WGL_ARB_pixel_format -#define WGL_ARB_pixel_format 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetPixelFormatAttribivARB (HDC, int, int, UINT, const int *, int *); -extern BOOL WINAPI wglGetPixelFormatAttribfvARB (HDC, int, int, UINT, const int *, FLOAT *); -extern BOOL WINAPI wglChoosePixelFormatARB (HDC, const int *, const FLOAT *, UINT, int *, UINT *); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); -typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); -#endif - -#ifndef WGL_ARB_make_current_read -#define WGL_ARB_make_current_read 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglMakeContextCurrentARB (HDC, HDC, HGLRC); -extern HDC WINAPI wglGetCurrentReadDCARB (void); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); -typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (void); -#endif - -#ifndef WGL_ARB_pbuffer -#define WGL_ARB_pbuffer 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern HPBUFFERARB WINAPI wglCreatePbufferARB (HDC, int, int, int, const int *); -extern HDC WINAPI wglGetPbufferDCARB (HPBUFFERARB); -extern int WINAPI wglReleasePbufferDCARB (HPBUFFERARB, HDC); -extern BOOL WINAPI wglDestroyPbufferARB (HPBUFFERARB); -extern BOOL WINAPI wglQueryPbufferARB (HPBUFFERARB, int, int *); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); -typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer); -typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC); -typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer); -typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); -#endif - -#ifndef WGL_ARB_render_texture -#define WGL_ARB_render_texture 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglBindTexImageARB (HPBUFFERARB, int); -extern BOOL WINAPI wglReleaseTexImageARB (HPBUFFERARB, int); -extern BOOL WINAPI wglSetPbufferAttribARB (HPBUFFERARB, const int *); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); -typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); -typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList); -#endif - -#ifndef WGL_ARB_pixel_format_float -#define WGL_ARB_pixel_format_float 1 -#endif - -#ifndef WGL_ARB_create_context -#define WGL_ARB_create_context 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern HGLRC WINAPI wglCreateContextAttribsARB (HDC, HGLRC, const int *); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList); -#endif - -#ifndef WGL_ARB_create_context_profile -#define WGL_ARB_create_context_profile 1 -#endif - -#ifndef WGL_EXT_display_color_table -#define WGL_EXT_display_color_table 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern GLboolean WINAPI wglCreateDisplayColorTableEXT (GLushort); -extern GLboolean WINAPI wglLoadDisplayColorTableEXT (const GLushort *, GLuint); -extern GLboolean WINAPI wglBindDisplayColorTableEXT (GLushort); -extern VOID WINAPI wglDestroyDisplayColorTableEXT (GLushort); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id); -typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (const GLushort *table, GLuint length); -typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id); -typedef VOID (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id); -#endif - -#ifndef WGL_EXT_extensions_string -#define WGL_EXT_extensions_string 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern const char * WINAPI wglGetExtensionsStringEXT (void); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void); -#endif - -#ifndef WGL_EXT_make_current_read -#define WGL_EXT_make_current_read 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglMakeContextCurrentEXT (HDC, HDC, HGLRC); -extern HDC WINAPI wglGetCurrentReadDCEXT (void); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); -typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (void); -#endif - -#ifndef WGL_EXT_pbuffer -#define WGL_EXT_pbuffer 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern HPBUFFEREXT WINAPI wglCreatePbufferEXT (HDC, int, int, int, const int *); -extern HDC WINAPI wglGetPbufferDCEXT (HPBUFFEREXT); -extern int WINAPI wglReleasePbufferDCEXT (HPBUFFEREXT, HDC); -extern BOOL WINAPI wglDestroyPbufferEXT (HPBUFFEREXT); -extern BOOL WINAPI wglQueryPbufferEXT (HPBUFFEREXT, int, int *); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); -typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer); -typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC); -typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer); -typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue); -#endif - -#ifndef WGL_EXT_pixel_format -#define WGL_EXT_pixel_format 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetPixelFormatAttribivEXT (HDC, int, int, UINT, int *, int *); -extern BOOL WINAPI wglGetPixelFormatAttribfvEXT (HDC, int, int, UINT, int *, FLOAT *); -extern BOOL WINAPI wglChoosePixelFormatEXT (HDC, const int *, const FLOAT *, UINT, int *, UINT *); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues); -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues); -typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); -#endif - -#ifndef WGL_EXT_swap_control -#define WGL_EXT_swap_control 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglSwapIntervalEXT (int); -extern int WINAPI wglGetSwapIntervalEXT (void); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval); -typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void); -#endif - -#ifndef WGL_EXT_depth_float -#define WGL_EXT_depth_float 1 -#endif - -#ifndef WGL_NV_vertex_array_range -#define WGL_NV_vertex_array_range 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern void* WINAPI wglAllocateMemoryNV (GLsizei, GLfloat, GLfloat, GLfloat); -extern void WINAPI wglFreeMemoryNV (void *); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef void* (WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); -typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer); -#endif - -#ifndef WGL_3DFX_multisample -#define WGL_3DFX_multisample 1 -#endif - -#ifndef WGL_EXT_multisample -#define WGL_EXT_multisample 1 -#endif - -#ifndef WGL_OML_sync_control -#define WGL_OML_sync_control 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetSyncValuesOML (HDC, INT64 *, INT64 *, INT64 *); -extern BOOL WINAPI wglGetMscRateOML (HDC, INT32 *, INT32 *); -extern INT64 WINAPI wglSwapBuffersMscOML (HDC, INT64, INT64, INT64); -extern INT64 WINAPI wglSwapLayerBuffersMscOML (HDC, int, INT64, INT64, INT64); -extern BOOL WINAPI wglWaitForMscOML (HDC, INT64, INT64, INT64, INT64 *, INT64 *, INT64 *); -extern BOOL WINAPI wglWaitForSbcOML (HDC, INT64, INT64 *, INT64 *, INT64 *); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); -typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator); -typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); -typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); -typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); -typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); -#endif - -#ifndef WGL_I3D_digital_video_control -#define WGL_I3D_digital_video_control 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetDigitalVideoParametersI3D (HDC, int, int *); -extern BOOL WINAPI wglSetDigitalVideoParametersI3D (HDC, int, const int *); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); -typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); -#endif - -#ifndef WGL_I3D_gamma -#define WGL_I3D_gamma 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetGammaTableParametersI3D (HDC, int, int *); -extern BOOL WINAPI wglSetGammaTableParametersI3D (HDC, int, const int *); -extern BOOL WINAPI wglGetGammaTableI3D (HDC, int, USHORT *, USHORT *, USHORT *); -extern BOOL WINAPI wglSetGammaTableI3D (HDC, int, const USHORT *, const USHORT *, const USHORT *); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); -typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); -typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue); -typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue); -#endif - -#ifndef WGL_I3D_genlock -#define WGL_I3D_genlock 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglEnableGenlockI3D (HDC); -extern BOOL WINAPI wglDisableGenlockI3D (HDC); -extern BOOL WINAPI wglIsEnabledGenlockI3D (HDC, BOOL *); -extern BOOL WINAPI wglGenlockSourceI3D (HDC, UINT); -extern BOOL WINAPI wglGetGenlockSourceI3D (HDC, UINT *); -extern BOOL WINAPI wglGenlockSourceEdgeI3D (HDC, UINT); -extern BOOL WINAPI wglGetGenlockSourceEdgeI3D (HDC, UINT *); -extern BOOL WINAPI wglGenlockSampleRateI3D (HDC, UINT); -extern BOOL WINAPI wglGetGenlockSampleRateI3D (HDC, UINT *); -extern BOOL WINAPI wglGenlockSourceDelayI3D (HDC, UINT); -extern BOOL WINAPI wglGetGenlockSourceDelayI3D (HDC, UINT *); -extern BOOL WINAPI wglQueryGenlockMaxSourceDelayI3D (HDC, UINT *, UINT *); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC); -typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC); -typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL *pFlag); -typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource); -typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT *uSource); -typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge); -typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT *uEdge); -typedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate); -typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT *uRate); -typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay); -typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT *uDelay); -typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay); -#endif - -#ifndef WGL_I3D_image_buffer -#define WGL_I3D_image_buffer 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern LPVOID WINAPI wglCreateImageBufferI3D (HDC, DWORD, UINT); -extern BOOL WINAPI wglDestroyImageBufferI3D (HDC, LPVOID); -extern BOOL WINAPI wglAssociateImageBufferEventsI3D (HDC, const HANDLE *, const LPVOID *, const DWORD *, UINT); -extern BOOL WINAPI wglReleaseImageBufferEventsI3D (HDC, const LPVOID *, UINT); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags); -typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress); -typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count); -typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const LPVOID *pAddress, UINT count); -#endif - -#ifndef WGL_I3D_swap_frame_lock -#define WGL_I3D_swap_frame_lock 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglEnableFrameLockI3D (void); -extern BOOL WINAPI wglDisableFrameLockI3D (void); -extern BOOL WINAPI wglIsEnabledFrameLockI3D (BOOL *); -extern BOOL WINAPI wglQueryFrameLockMasterI3D (BOOL *); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (void); -typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (void); -typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL *pFlag); -typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL *pFlag); -#endif - -#ifndef WGL_I3D_swap_frame_usage -#define WGL_I3D_swap_frame_usage 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetFrameUsageI3D (float *); -extern BOOL WINAPI wglBeginFrameTrackingI3D (void); -extern BOOL WINAPI wglEndFrameTrackingI3D (void); -extern BOOL WINAPI wglQueryFrameTrackingI3D (DWORD *, DWORD *, float *); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float *pUsage); -typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void); -typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void); -typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); -#endif - -#ifndef WGL_ATI_pixel_format_float -#define WGL_ATI_pixel_format_float 1 -#endif - -#ifndef WGL_NV_float_buffer -#define WGL_NV_float_buffer 1 -#endif - -#ifndef WGL_3DL_stereo_control -#define WGL_3DL_stereo_control 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglSetStereoEmitterState3DL (HDC, UINT); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState); -#endif - -#ifndef WGL_EXT_pixel_format_packed_float -#define WGL_EXT_pixel_format_packed_float 1 -#endif - -#ifndef WGL_EXT_framebuffer_sRGB -#define WGL_EXT_framebuffer_sRGB 1 -#endif - -#ifndef WGL_NV_present_video -#define WGL_NV_present_video 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern int WINAPI wglEnumerateVideoDevicesNV (HDC, HVIDEOOUTPUTDEVICENV *); -extern BOOL WINAPI wglBindVideoDeviceNV (HDC, unsigned int, HVIDEOOUTPUTDEVICENV, const int *); -extern BOOL WINAPI wglQueryCurrentContextNV (int, int *); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList); -typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); -typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int *piValue); -#endif - -#ifndef WGL_NV_video_out -#define WGL_NV_video_out 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetVideoDeviceNV (HDC, int, HPVIDEODEV *); -extern BOOL WINAPI wglReleaseVideoDeviceNV (HPVIDEODEV); -extern BOOL WINAPI wglBindVideoImageNV (HPVIDEODEV, HPBUFFERARB, int); -extern BOOL WINAPI wglReleaseVideoImageNV (HPBUFFERARB, int); -extern BOOL WINAPI wglSendPbufferToVideoNV (HPBUFFERARB, int, unsigned long *, BOOL); -extern BOOL WINAPI wglGetVideoInfoNV (HPVIDEODEV, unsigned long *, unsigned long *); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice); -typedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice); -typedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); -typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer); -typedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock); -typedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); -#endif - -#ifndef WGL_NV_swap_group -#define WGL_NV_swap_group 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglJoinSwapGroupNV (HDC, GLuint); -extern BOOL WINAPI wglBindSwapBarrierNV (GLuint, GLuint); -extern BOOL WINAPI wglQuerySwapGroupNV (HDC, GLuint *, GLuint *); -extern BOOL WINAPI wglQueryMaxSwapGroupsNV (HDC, GLuint *, GLuint *); -extern BOOL WINAPI wglQueryFrameCountNV (HDC, GLuint *); -extern BOOL WINAPI wglResetFrameCountNV (HDC); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group); -typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier); -typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint *group, GLuint *barrier); -typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); -typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint *count); -typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC); -#endif - -#ifndef WGL_NV_gpu_affinity -#define WGL_NV_gpu_affinity 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglEnumGpusNV (UINT, HGPUNV *); -extern BOOL WINAPI wglEnumGpuDevicesNV (HGPUNV, UINT, PGPU_DEVICE); -extern HDC WINAPI wglCreateAffinityDCNV (const HGPUNV *); -extern BOOL WINAPI wglEnumGpusFromAffinityDCNV (HDC, UINT, HGPUNV *); -extern BOOL WINAPI wglDeleteDCNV (HDC); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu); -typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); -typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList); -typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); -typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc); -#endif - -#ifndef WGL_AMD_gpu_association -#define WGL_AMD_gpu_association 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern UINT WINAPI wglGetGPUIDsAMD (UINT, UINT *); -extern INT WINAPI wglGetGPUInfoAMD (UINT, int, GLenum, UINT, void *); -extern UINT WINAPI wglGetContextGPUIDAMD (HGLRC); -extern HGLRC WINAPI wglCreateAssociatedContextAMD (UINT); -extern HGLRC WINAPI wglCreateAssociatedContextAttribsAMD (UINT, HGLRC, const int *); -extern BOOL WINAPI wglDeleteAssociatedContextAMD (HGLRC); -extern BOOL WINAPI wglMakeAssociatedContextCurrentAMD (HGLRC); -extern HGLRC WINAPI wglGetCurrentAssociatedContextAMD (void); -extern VOID WINAPI wglBlitContextFramebufferAMD (HGLRC, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef UINT (WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT *ids); -typedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, int property, GLenum dataType, UINT size, void *data); -typedef UINT (WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc); -typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id); -typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int *attribList); -typedef BOOL (WINAPI * PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC) (HGLRC hglrc); -typedef BOOL (WINAPI * PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (HGLRC hglrc); -typedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void); -typedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -#endif - - -#ifdef __cplusplus -} -#endif - -#endif +#ifndef __wglext_h_ +#define __wglext_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright (c) 2007 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#define WIN32_LEAN_AND_MEAN 1 +#include +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif +#ifndef GLAPI +#define GLAPI extern +#endif + +/*************************************************************/ + +/* Header file version number */ +/* wglext.h last updated 2008/10/07 */ +/* Current version at http://www.opengl.org/registry/ */ +#define WGL_WGLEXT_VERSION 11 + +#ifndef WGL_ARB_buffer_region +#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001 +#define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002 +#define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004 +#define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008 +#endif + +#ifndef WGL_ARB_multisample +#define WGL_SAMPLE_BUFFERS_ARB 0x2041 +#define WGL_SAMPLES_ARB 0x2042 +#endif + +#ifndef WGL_ARB_extensions_string +#endif + +#ifndef WGL_ARB_pixel_format +#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 +#define WGL_DRAW_TO_WINDOW_ARB 0x2001 +#define WGL_DRAW_TO_BITMAP_ARB 0x2002 +#define WGL_ACCELERATION_ARB 0x2003 +#define WGL_NEED_PALETTE_ARB 0x2004 +#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 +#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 +#define WGL_SWAP_METHOD_ARB 0x2007 +#define WGL_NUMBER_OVERLAYS_ARB 0x2008 +#define WGL_NUMBER_UNDERLAYS_ARB 0x2009 +#define WGL_TRANSPARENT_ARB 0x200A +#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 +#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 +#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 +#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A +#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B +#define WGL_SHARE_DEPTH_ARB 0x200C +#define WGL_SHARE_STENCIL_ARB 0x200D +#define WGL_SHARE_ACCUM_ARB 0x200E +#define WGL_SUPPORT_GDI_ARB 0x200F +#define WGL_SUPPORT_OPENGL_ARB 0x2010 +#define WGL_DOUBLE_BUFFER_ARB 0x2011 +#define WGL_STEREO_ARB 0x2012 +#define WGL_PIXEL_TYPE_ARB 0x2013 +#define WGL_COLOR_BITS_ARB 0x2014 +#define WGL_RED_BITS_ARB 0x2015 +#define WGL_RED_SHIFT_ARB 0x2016 +#define WGL_GREEN_BITS_ARB 0x2017 +#define WGL_GREEN_SHIFT_ARB 0x2018 +#define WGL_BLUE_BITS_ARB 0x2019 +#define WGL_BLUE_SHIFT_ARB 0x201A +#define WGL_ALPHA_BITS_ARB 0x201B +#define WGL_ALPHA_SHIFT_ARB 0x201C +#define WGL_ACCUM_BITS_ARB 0x201D +#define WGL_ACCUM_RED_BITS_ARB 0x201E +#define WGL_ACCUM_GREEN_BITS_ARB 0x201F +#define WGL_ACCUM_BLUE_BITS_ARB 0x2020 +#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 +#define WGL_DEPTH_BITS_ARB 0x2022 +#define WGL_STENCIL_BITS_ARB 0x2023 +#define WGL_AUX_BUFFERS_ARB 0x2024 +#define WGL_NO_ACCELERATION_ARB 0x2025 +#define WGL_GENERIC_ACCELERATION_ARB 0x2026 +#define WGL_FULL_ACCELERATION_ARB 0x2027 +#define WGL_SWAP_EXCHANGE_ARB 0x2028 +#define WGL_SWAP_COPY_ARB 0x2029 +#define WGL_SWAP_UNDEFINED_ARB 0x202A +#define WGL_TYPE_RGBA_ARB 0x202B +#define WGL_TYPE_COLORINDEX_ARB 0x202C +#endif + +#ifndef WGL_ARB_make_current_read +#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043 +#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 +#endif + +#ifndef WGL_ARB_pbuffer +#define WGL_DRAW_TO_PBUFFER_ARB 0x202D +#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E +#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F +#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 +#define WGL_PBUFFER_LARGEST_ARB 0x2033 +#define WGL_PBUFFER_WIDTH_ARB 0x2034 +#define WGL_PBUFFER_HEIGHT_ARB 0x2035 +#define WGL_PBUFFER_LOST_ARB 0x2036 +#endif + +#ifndef WGL_ARB_render_texture +#define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070 +#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071 +#define WGL_TEXTURE_FORMAT_ARB 0x2072 +#define WGL_TEXTURE_TARGET_ARB 0x2073 +#define WGL_MIPMAP_TEXTURE_ARB 0x2074 +#define WGL_TEXTURE_RGB_ARB 0x2075 +#define WGL_TEXTURE_RGBA_ARB 0x2076 +#define WGL_NO_TEXTURE_ARB 0x2077 +#define WGL_TEXTURE_CUBE_MAP_ARB 0x2078 +#define WGL_TEXTURE_1D_ARB 0x2079 +#define WGL_TEXTURE_2D_ARB 0x207A +#define WGL_MIPMAP_LEVEL_ARB 0x207B +#define WGL_CUBE_MAP_FACE_ARB 0x207C +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080 +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081 +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082 +#define WGL_FRONT_LEFT_ARB 0x2083 +#define WGL_FRONT_RIGHT_ARB 0x2084 +#define WGL_BACK_LEFT_ARB 0x2085 +#define WGL_BACK_RIGHT_ARB 0x2086 +#define WGL_AUX0_ARB 0x2087 +#define WGL_AUX1_ARB 0x2088 +#define WGL_AUX2_ARB 0x2089 +#define WGL_AUX3_ARB 0x208A +#define WGL_AUX4_ARB 0x208B +#define WGL_AUX5_ARB 0x208C +#define WGL_AUX6_ARB 0x208D +#define WGL_AUX7_ARB 0x208E +#define WGL_AUX8_ARB 0x208F +#define WGL_AUX9_ARB 0x2090 +#endif + +#ifndef WGL_ARB_pixel_format_float +#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 +#endif + +#ifndef WGL_ARB_create_context +#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001 +#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 +#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 +#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 +#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 +#define WGL_CONTEXT_FLAGS_ARB 0x2094 +#define ERROR_INVALID_VERSION_ARB 0x2095 +#endif + +#ifndef WGL_EXT_make_current_read +#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043 +#endif + +#ifndef WGL_EXT_pixel_format +#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000 +#define WGL_DRAW_TO_WINDOW_EXT 0x2001 +#define WGL_DRAW_TO_BITMAP_EXT 0x2002 +#define WGL_ACCELERATION_EXT 0x2003 +#define WGL_NEED_PALETTE_EXT 0x2004 +#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005 +#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006 +#define WGL_SWAP_METHOD_EXT 0x2007 +#define WGL_NUMBER_OVERLAYS_EXT 0x2008 +#define WGL_NUMBER_UNDERLAYS_EXT 0x2009 +#define WGL_TRANSPARENT_EXT 0x200A +#define WGL_TRANSPARENT_VALUE_EXT 0x200B +#define WGL_SHARE_DEPTH_EXT 0x200C +#define WGL_SHARE_STENCIL_EXT 0x200D +#define WGL_SHARE_ACCUM_EXT 0x200E +#define WGL_SUPPORT_GDI_EXT 0x200F +#define WGL_SUPPORT_OPENGL_EXT 0x2010 +#define WGL_DOUBLE_BUFFER_EXT 0x2011 +#define WGL_STEREO_EXT 0x2012 +#define WGL_PIXEL_TYPE_EXT 0x2013 +#define WGL_COLOR_BITS_EXT 0x2014 +#define WGL_RED_BITS_EXT 0x2015 +#define WGL_RED_SHIFT_EXT 0x2016 +#define WGL_GREEN_BITS_EXT 0x2017 +#define WGL_GREEN_SHIFT_EXT 0x2018 +#define WGL_BLUE_BITS_EXT 0x2019 +#define WGL_BLUE_SHIFT_EXT 0x201A +#define WGL_ALPHA_BITS_EXT 0x201B +#define WGL_ALPHA_SHIFT_EXT 0x201C +#define WGL_ACCUM_BITS_EXT 0x201D +#define WGL_ACCUM_RED_BITS_EXT 0x201E +#define WGL_ACCUM_GREEN_BITS_EXT 0x201F +#define WGL_ACCUM_BLUE_BITS_EXT 0x2020 +#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021 +#define WGL_DEPTH_BITS_EXT 0x2022 +#define WGL_STENCIL_BITS_EXT 0x2023 +#define WGL_AUX_BUFFERS_EXT 0x2024 +#define WGL_NO_ACCELERATION_EXT 0x2025 +#define WGL_GENERIC_ACCELERATION_EXT 0x2026 +#define WGL_FULL_ACCELERATION_EXT 0x2027 +#define WGL_SWAP_EXCHANGE_EXT 0x2028 +#define WGL_SWAP_COPY_EXT 0x2029 +#define WGL_SWAP_UNDEFINED_EXT 0x202A +#define WGL_TYPE_RGBA_EXT 0x202B +#define WGL_TYPE_COLORINDEX_EXT 0x202C +#endif + +#ifndef WGL_EXT_pbuffer +#define WGL_DRAW_TO_PBUFFER_EXT 0x202D +#define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E +#define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F +#define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030 +#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031 +#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032 +#define WGL_PBUFFER_LARGEST_EXT 0x2033 +#define WGL_PBUFFER_WIDTH_EXT 0x2034 +#define WGL_PBUFFER_HEIGHT_EXT 0x2035 +#endif + +#ifndef WGL_EXT_depth_float +#define WGL_DEPTH_FLOAT_EXT 0x2040 +#endif + +#ifndef WGL_3DFX_multisample +#define WGL_SAMPLE_BUFFERS_3DFX 0x2060 +#define WGL_SAMPLES_3DFX 0x2061 +#endif + +#ifndef WGL_EXT_multisample +#define WGL_SAMPLE_BUFFERS_EXT 0x2041 +#define WGL_SAMPLES_EXT 0x2042 +#endif + +#ifndef WGL_I3D_digital_video_control +#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050 +#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051 +#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052 +#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053 +#endif + +#ifndef WGL_I3D_gamma +#define WGL_GAMMA_TABLE_SIZE_I3D 0x204E +#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F +#endif + +#ifndef WGL_I3D_genlock +#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044 +#define WGL_GENLOCK_SOURCE_EXTENAL_SYNC_I3D 0x2045 +#define WGL_GENLOCK_SOURCE_EXTENAL_FIELD_I3D 0x2046 +#define WGL_GENLOCK_SOURCE_EXTENAL_TTL_I3D 0x2047 +#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048 +#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049 +#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A +#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B +#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C +#endif + +#ifndef WGL_I3D_image_buffer +#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001 +#define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002 +#endif + +#ifndef WGL_I3D_swap_frame_lock +#endif + +#ifndef WGL_NV_render_depth_texture +#define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4 +#define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5 +#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6 +#define WGL_DEPTH_COMPONENT_NV 0x20A7 +#endif + +#ifndef WGL_NV_render_texture_rectangle +#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1 +#define WGL_TEXTURE_RECTANGLE_NV 0x20A2 +#endif + +#ifndef WGL_ATI_pixel_format_float +#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0 +#endif + +#ifndef WGL_NV_float_buffer +#define WGL_FLOAT_COMPONENTS_NV 0x20B0 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4 +#define WGL_TEXTURE_FLOAT_R_NV 0x20B5 +#define WGL_TEXTURE_FLOAT_RG_NV 0x20B6 +#define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7 +#define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8 +#endif + +#ifndef WGL_3DL_stereo_control +#define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055 +#define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056 +#define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057 +#define WGL_STEREO_POLARITY_INVERT_3DL 0x2058 +#endif + +#ifndef WGL_EXT_pixel_format_packed_float +#define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8 +#endif + +#ifndef WGL_EXT_framebuffer_sRGB +#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9 +#endif + +#ifndef WGL_NV_present_video +#define WGL_NUM_VIDEO_SLOTS_NV 0x20F0 +#endif + +#ifndef WGL_NV_video_out +#define WGL_BIND_TO_VIDEO_RGB_NV 0x20C0 +#define WGL_BIND_TO_VIDEO_RGBA_NV 0x20C1 +#define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2 +#define WGL_VIDEO_OUT_COLOR_NV 0x20C3 +#define WGL_VIDEO_OUT_ALPHA_NV 0x20C4 +#define WGL_VIDEO_OUT_DEPTH_NV 0x20C5 +#define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6 +#define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7 +#define WGL_VIDEO_OUT_FRAME 0x20C8 +#define WGL_VIDEO_OUT_FIELD_1 0x20C9 +#define WGL_VIDEO_OUT_FIELD_2 0x20CA +#define WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB +#define WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC +#endif + +#ifndef WGL_NV_swap_group +#endif + +#ifndef WGL_NV_gpu_affinity +#define WGL_ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0 +#define WGL_ERROR_MISSING_AFFINITY_MASK_NV 0x20D1 +#endif + + +/*************************************************************/ + +#ifndef WGL_ARB_pbuffer +DECLARE_HANDLE(HPBUFFERARB); +#endif +#ifndef WGL_EXT_pbuffer +DECLARE_HANDLE(HPBUFFEREXT); +#endif +#ifndef WGL_NV_present_video +DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV); +#endif +#ifndef WGL_NV_video_out +DECLARE_HANDLE(HPVIDEODEV); +#endif +#ifndef WGL_NV_gpu_affinity +DECLARE_HANDLE(HPGPUNV); +DECLARE_HANDLE(HGPUNV); + +typedef struct _GPU_DEVICE { + DWORD cb; + CHAR DeviceName[32]; + CHAR DeviceString[128]; + DWORD Flags; + RECT rcVirtualScreen; +} GPU_DEVICE, *PGPU_DEVICE; +#endif + +#ifndef WGL_ARB_buffer_region +#define WGL_ARB_buffer_region 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern HANDLE WINAPI wglCreateBufferRegionARB (HDC, int, UINT); +extern VOID WINAPI wglDeleteBufferRegionARB (HANDLE); +extern BOOL WINAPI wglSaveBufferRegionARB (HANDLE, int, int, int, int); +extern BOOL WINAPI wglRestoreBufferRegionARB (HANDLE, int, int, int, int, int, int); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType); +typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion); +typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height); +typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); +#endif + +#ifndef WGL_ARB_multisample +#define WGL_ARB_multisample 1 +#endif + +#ifndef WGL_ARB_extensions_string +#define WGL_ARB_extensions_string 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern const char * WINAPI wglGetExtensionsStringARB (HDC); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc); +#endif + +#ifndef WGL_ARB_pixel_format +#define WGL_ARB_pixel_format 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglGetPixelFormatAttribivARB (HDC, int, int, UINT, const int *, int *); +extern BOOL WINAPI wglGetPixelFormatAttribfvARB (HDC, int, int, UINT, const int *, FLOAT *); +extern BOOL WINAPI wglChoosePixelFormatARB (HDC, const int *, const FLOAT *, UINT, int *, UINT *); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); +typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +#endif + +#ifndef WGL_ARB_make_current_read +#define WGL_ARB_make_current_read 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglMakeContextCurrentARB (HDC, HDC, HGLRC); +extern HDC WINAPI wglGetCurrentReadDCARB (void); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); +typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (void); +#endif + +#ifndef WGL_ARB_pbuffer +#define WGL_ARB_pbuffer 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern HPBUFFERARB WINAPI wglCreatePbufferARB (HDC, int, int, int, const int *); +extern HDC WINAPI wglGetPbufferDCARB (HPBUFFERARB); +extern int WINAPI wglReleasePbufferDCARB (HPBUFFERARB, HDC); +extern BOOL WINAPI wglDestroyPbufferARB (HPBUFFERARB); +extern BOOL WINAPI wglQueryPbufferARB (HPBUFFERARB, int, int *); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); +typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer); +typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC); +typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer); +typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); +#endif + +#ifndef WGL_ARB_render_texture +#define WGL_ARB_render_texture 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglBindTexImageARB (HPBUFFERARB, int); +extern BOOL WINAPI wglReleaseTexImageARB (HPBUFFERARB, int); +extern BOOL WINAPI wglSetPbufferAttribARB (HPBUFFERARB, const int *); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); +typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); +typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList); +#endif + +#ifndef WGL_ARB_pixel_format_float +#define WGL_ARB_pixel_format_float 1 +#endif + +#ifndef WGL_ARB_create_context +#define WGL_ARB_create_context 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern HGLRC WINAPI wglCreateContextAttribsARB (HDC, HGLRC, const int *); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList); +#endif + +#ifndef WGL_EXT_display_color_table +#define WGL_EXT_display_color_table 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern GLboolean WINAPI wglCreateDisplayColorTableEXT (GLushort); +extern GLboolean WINAPI wglLoadDisplayColorTableEXT (const GLushort *, GLuint); +extern GLboolean WINAPI wglBindDisplayColorTableEXT (GLushort); +extern VOID WINAPI wglDestroyDisplayColorTableEXT (GLushort); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id); +typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (const GLushort *table, GLuint length); +typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id); +typedef VOID (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id); +#endif + +#ifndef WGL_EXT_extensions_string +#define WGL_EXT_extensions_string 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern const char * WINAPI wglGetExtensionsStringEXT (void); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void); +#endif + +#ifndef WGL_EXT_make_current_read +#define WGL_EXT_make_current_read 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglMakeContextCurrentEXT (HDC, HDC, HGLRC); +extern HDC WINAPI wglGetCurrentReadDCEXT (void); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); +typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (void); +#endif + +#ifndef WGL_EXT_pbuffer +#define WGL_EXT_pbuffer 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern HPBUFFEREXT WINAPI wglCreatePbufferEXT (HDC, int, int, int, const int *); +extern HDC WINAPI wglGetPbufferDCEXT (HPBUFFEREXT); +extern int WINAPI wglReleasePbufferDCEXT (HPBUFFEREXT, HDC); +extern BOOL WINAPI wglDestroyPbufferEXT (HPBUFFEREXT); +extern BOOL WINAPI wglQueryPbufferEXT (HPBUFFEREXT, int, int *); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); +typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer); +typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC); +typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer); +typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue); +#endif + +#ifndef WGL_EXT_pixel_format +#define WGL_EXT_pixel_format 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglGetPixelFormatAttribivEXT (HDC, int, int, UINT, int *, int *); +extern BOOL WINAPI wglGetPixelFormatAttribfvEXT (HDC, int, int, UINT, int *, FLOAT *); +extern BOOL WINAPI wglChoosePixelFormatEXT (HDC, const int *, const FLOAT *, UINT, int *, UINT *); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues); +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues); +typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +#endif + +#ifndef WGL_EXT_swap_control +#define WGL_EXT_swap_control 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglSwapIntervalEXT (int); +extern int WINAPI wglGetSwapIntervalEXT (void); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval); +typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void); +#endif + +#ifndef WGL_EXT_depth_float +#define WGL_EXT_depth_float 1 +#endif + +#ifndef WGL_NV_vertex_array_range +#define WGL_NV_vertex_array_range 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern void* WINAPI wglAllocateMemoryNV (GLsizei, GLfloat, GLfloat, GLfloat); +extern void WINAPI wglFreeMemoryNV (void *); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef void* (WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); +typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer); +#endif + +#ifndef WGL_3DFX_multisample +#define WGL_3DFX_multisample 1 +#endif + +#ifndef WGL_EXT_multisample +#define WGL_EXT_multisample 1 +#endif + +#ifndef WGL_OML_sync_control +#define WGL_OML_sync_control 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglGetSyncValuesOML (HDC, INT64 *, INT64 *, INT64 *); +extern BOOL WINAPI wglGetMscRateOML (HDC, INT32 *, INT32 *); +extern INT64 WINAPI wglSwapBuffersMscOML (HDC, INT64, INT64, INT64); +extern INT64 WINAPI wglSwapLayerBuffersMscOML (HDC, int, INT64, INT64, INT64); +extern BOOL WINAPI wglWaitForMscOML (HDC, INT64, INT64, INT64, INT64 *, INT64 *, INT64 *); +extern BOOL WINAPI wglWaitForSbcOML (HDC, INT64, INT64 *, INT64 *, INT64 *); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); +typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator); +typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); +typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); +typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); +typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); +#endif + +#ifndef WGL_I3D_digital_video_control +#define WGL_I3D_digital_video_control 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglGetDigitalVideoParametersI3D (HDC, int, int *); +extern BOOL WINAPI wglSetDigitalVideoParametersI3D (HDC, int, const int *); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); +typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); +#endif + +#ifndef WGL_I3D_gamma +#define WGL_I3D_gamma 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglGetGammaTableParametersI3D (HDC, int, int *); +extern BOOL WINAPI wglSetGammaTableParametersI3D (HDC, int, const int *); +extern BOOL WINAPI wglGetGammaTableI3D (HDC, int, USHORT *, USHORT *, USHORT *); +extern BOOL WINAPI wglSetGammaTableI3D (HDC, int, const USHORT *, const USHORT *, const USHORT *); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); +typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); +typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue); +typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue); +#endif + +#ifndef WGL_I3D_genlock +#define WGL_I3D_genlock 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglEnableGenlockI3D (HDC); +extern BOOL WINAPI wglDisableGenlockI3D (HDC); +extern BOOL WINAPI wglIsEnabledGenlockI3D (HDC, BOOL *); +extern BOOL WINAPI wglGenlockSourceI3D (HDC, UINT); +extern BOOL WINAPI wglGetGenlockSourceI3D (HDC, UINT *); +extern BOOL WINAPI wglGenlockSourceEdgeI3D (HDC, UINT); +extern BOOL WINAPI wglGetGenlockSourceEdgeI3D (HDC, UINT *); +extern BOOL WINAPI wglGenlockSampleRateI3D (HDC, UINT); +extern BOOL WINAPI wglGetGenlockSampleRateI3D (HDC, UINT *); +extern BOOL WINAPI wglGenlockSourceDelayI3D (HDC, UINT); +extern BOOL WINAPI wglGetGenlockSourceDelayI3D (HDC, UINT *); +extern BOOL WINAPI wglQueryGenlockMaxSourceDelayI3D (HDC, UINT *, UINT *); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC); +typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC); +typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL *pFlag); +typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource); +typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT *uSource); +typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge); +typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT *uEdge); +typedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate); +typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT *uRate); +typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay); +typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT *uDelay); +typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay); +#endif + +#ifndef WGL_I3D_image_buffer +#define WGL_I3D_image_buffer 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern LPVOID WINAPI wglCreateImageBufferI3D (HDC, DWORD, UINT); +extern BOOL WINAPI wglDestroyImageBufferI3D (HDC, LPVOID); +extern BOOL WINAPI wglAssociateImageBufferEventsI3D (HDC, const HANDLE *, const LPVOID *, const DWORD *, UINT); +extern BOOL WINAPI wglReleaseImageBufferEventsI3D (HDC, const LPVOID *, UINT); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags); +typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress); +typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count); +typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const LPVOID *pAddress, UINT count); +#endif + +#ifndef WGL_I3D_swap_frame_lock +#define WGL_I3D_swap_frame_lock 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglEnableFrameLockI3D (void); +extern BOOL WINAPI wglDisableFrameLockI3D (void); +extern BOOL WINAPI wglIsEnabledFrameLockI3D (BOOL *); +extern BOOL WINAPI wglQueryFrameLockMasterI3D (BOOL *); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (void); +typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (void); +typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL *pFlag); +typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL *pFlag); +#endif + +#ifndef WGL_I3D_swap_frame_usage +#define WGL_I3D_swap_frame_usage 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglGetFrameUsageI3D (float *); +extern BOOL WINAPI wglBeginFrameTrackingI3D (void); +extern BOOL WINAPI wglEndFrameTrackingI3D (void); +extern BOOL WINAPI wglQueryFrameTrackingI3D (DWORD *, DWORD *, float *); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float *pUsage); +typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void); +typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void); +typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); +#endif + +#ifndef WGL_ATI_pixel_format_float +#define WGL_ATI_pixel_format_float 1 +#endif + +#ifndef WGL_NV_float_buffer +#define WGL_NV_float_buffer 1 +#endif + +#ifndef WGL_EXT_pixel_format_packed_float +#define WGL_EXT_pixel_format_packed_float 1 +#endif + +#ifndef WGL_EXT_framebuffer_sRGB +#define WGL_EXT_framebuffer_sRGB 1 +#endif + +#ifndef WGL_NV_present_video +#define WGL_NV_present_video 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern int WINAPI wglEnumerateVideoDevicesNV (HDC, HVIDEOOUTPUTDEVICENV *); +extern BOOL WINAPI wglBindVideoDeviceNV (HDC, unsigned int, HVIDEOOUTPUTDEVICENV, const int *); +extern BOOL WINAPI wglQueryCurrentContextNV (int, int *); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList); +typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); +typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int *piValue); +#endif + +#ifndef WGL_NV_video_out +#define WGL_NV_video_out 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglGetVideoDeviceNV (HDC, int, HPVIDEODEV *); +extern BOOL WINAPI wglReleaseVideoDeviceNV (HPVIDEODEV); +extern BOOL WINAPI wglBindVideoImageNV (HPVIDEODEV, HPBUFFERARB, int); +extern BOOL WINAPI wglReleaseVideoImageNV (HPBUFFERARB, int); +extern BOOL WINAPI wglSendPbufferToVideoNV (HPBUFFERARB, int, unsigned long *, BOOL); +extern BOOL WINAPI wglGetVideoInfoNV (HPVIDEODEV, unsigned long *, unsigned long *); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice); +typedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice); +typedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); +typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer); +typedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock); +typedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); +#endif + +#ifndef WGL_NV_swap_group +#define WGL_NV_swap_group 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglJoinSwapGroupNV (HDC, GLuint); +extern BOOL WINAPI wglBindSwapBarrierNV (GLuint, GLuint); +extern BOOL WINAPI wglQuerySwapGroupNV (HDC, GLuint *, GLuint *); +extern BOOL WINAPI wglQueryMaxSwapGroupsNV (HDC, GLuint *, GLuint *); +extern BOOL WINAPI wglQueryFrameCountNV (HDC, GLuint *); +extern BOOL WINAPI wglResetFrameCountNV (HDC); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group); +typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier); +typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint *group, GLuint *barrier); +typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); +typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint *count); +typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC); +#endif + +#ifndef WGL_NV_gpu_affinity +#define WGL_NV_gpu_affinity 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglEnumGpusNV (UINT, HGPUNV *); +extern BOOL WINAPI wglEnumGpuDevicesNV (HGPUNV, UINT, PGPU_DEVICE); +extern HDC WINAPI wglCreateAffinityDCNV (const HGPUNV *); +extern BOOL WINAPI wglEnumGpusFromAffinityDCNV (HDC, UINT, HGPUNV *); +extern BOOL WINAPI wglDeleteDCNV (HDC); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu); +typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); +typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList); +typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); +typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc); +#endif + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/SharedStructures.h b/SharedStructures.h new file mode 100644 index 000000000..7b92c663f --- /dev/null +++ b/SharedStructures.h @@ -0,0 +1,123 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#pragma once + +typedef unsigned int uint; + +// Model + +#define MATERIAL_LAMBERT 0 +#define MATERIAL_PHONG 1 +#define MATERIAL_BLINN 2 + +static const char* SMatNames[3] = { "LAMBERT", "PHONG", "BLINN" }; + +struct SMatAttrib +{ + float color[3]; + uint textureID; +}; + +struct SMaterial +{ + uint type; + char name[256]; + uint materialID; + SMatAttrib ambient; + SMatAttrib diffuse; + SMatAttrib incandescence; + SMatAttrib transparency; + SMatAttrib specular; + float shininess; + float eccentricity; + float specularRollOff; + uint normalmapTex; +}; + +struct SMatGrp +{ + uint materialID; + uint triCount; uint* triIndices; +}; + +struct SMesh +{ + char name[256]; + uint meshID; + uint parentHash; + uint numBlends; + uint isSkinned; + char skinName[256]; + uint numSkinInfHashes; uint* skinInfHashes; + uint stride; + uint numVerts; float* verts; + uint numMats; SMatGrp* matGrps; +}; + +struct Joint +{ + char name[256]; + uint m_visibility; + float m_rotation[4]; // joint rotation (quaternion) + float m_translation[4]; // joint translation + float m_scale[4]; // joint scale +}; + +struct Skeleton +{ + uint m_numJoints; + int* m_parentIndices; + Joint* m_basePose; + uint* m_jointNameHashes; +}; + +struct SModel +{ + char name[256]; + uint numTextures; char** texNames; + uint numMaterials; SMaterial* materials; + uint numMeshes; SMesh* meshes; + Skeleton skeleton; +}; + +// Animation + +struct SBlendAnim +{ + char name[256]; + char baseName[256]; + uint baseMeshID; + uint numWeights; float* weights; +}; + +struct SJointAnim +{ + uint numJointAnims; + char** jointNames; + uint* jointNameHashes; + Joint* jointXforms; +}; + +struct SAnimation +{ + char name[256]; + uint numFrames; + float startTime; float endTime; + uint numBlendAnims; SBlendAnim* blendAnims; + SJointAnim jointAnim; +}; + diff --git a/Tests/SoftBody.cpp b/Tests/SoftBody.cpp deleted file mode 100644 index 71ef7e976..000000000 Binary files a/Tests/SoftBody.cpp and /dev/null differ diff --git a/Tests/earth.jpg b/Tests/earth.jpg deleted file mode 100644 index df0e9aaed..000000000 Binary files a/Tests/earth.jpg and /dev/null differ diff --git a/Tests/introduce/README-LIBINTRODUCE.txt b/Tests/introduce/README-LIBINTRODUCE.txt deleted file mode 100644 index 781016a30..000000000 --- a/Tests/introduce/README-LIBINTRODUCE.txt +++ /dev/null @@ -1,38 +0,0 @@ - -LIBINTRODUCE -Copyright 2004 Jon Watte -2004-11-11 version 0.2 - - -Libintroduce provides several gaming-related networking services: - -- simple UDP sockets Windows/UNIX portability layer -- C++ interface based API to UDP sockets and select() -- Binary data marshaling and demarshaling and message formatting -- Matchmaking/lobbying server library -- Peer-to-peer NAT punch-through capability - -For more information about the latter part, see my web page at -http://www.mindcontrol.org/~hplus/nat-punch.html -- it has links -to several other good references. - -There is currently no manual, although there are functional/unit -tests for most of the functionality. There are a few weak spots -at the top of the stack, with regards to the end-to-end matchmaking, -introduction, and game communication solution. This is work in -progress. - -LIBINTRODUCE is released under an MIT-style license. You don't have -to pay anyone to use it commercially, and it doesn't "taint" your -source with any further opensource requirements. However, you have -to accept all liability for your use of (or inability to use) the -source code -- Jon Watte must be held harmless against any claims -arising out of your such use. The source is provided free of charge -with no obligation, warrantee or guarantee. - - -The actual source is found in "lib". Add the .cpp files to your -project or make file, and point your include path to the headers -in that library. Start looking at "network.h" for the basic -networking abstraction. Look at the test runner "app" or at the -"getter," "putter" and "roster" applications for usage examples. diff --git a/Tests/introduce/app.sln b/Tests/introduce/app.sln deleted file mode 100644 index 0e9cf93a6..000000000 --- a/Tests/introduce/app.sln +++ /dev/null @@ -1,53 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "app", "app\app.vcproj", "{EA358755-392F-4687-8994-5B2107A0B11C}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lib", "lib\lib.vcproj", "{388B240A-DB24-4C57-88E7-1F96588DD5B0}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "roster", "roster\roster.vcproj", "{14786FAE-450A-4935-B714-2190FDA9BFFD}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "putter", "putter\putter.vcproj", "{58EAB682-E6A5-4AFE-96DF-CA9C30FC9206}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "getter", "getter\getter.vcproj", "{72EC699B-9335-4ACF-B090-67A0D21F0306}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfiguration) = preSolution - Debug = Debug - Release = Release - EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {EA358755-392F-4687-8994-5B2107A0B11C}.Debug.ActiveCfg = Debug|Win32 - {EA358755-392F-4687-8994-5B2107A0B11C}.Debug.Build.0 = Debug|Win32 - {EA358755-392F-4687-8994-5B2107A0B11C}.Release.ActiveCfg = Release|Win32 - {EA358755-392F-4687-8994-5B2107A0B11C}.Release.Build.0 = Release|Win32 - {388B240A-DB24-4C57-88E7-1F96588DD5B0}.Debug.ActiveCfg = Debug|Win32 - {388B240A-DB24-4C57-88E7-1F96588DD5B0}.Debug.Build.0 = Debug|Win32 - {388B240A-DB24-4C57-88E7-1F96588DD5B0}.Release.ActiveCfg = Release|Win32 - {388B240A-DB24-4C57-88E7-1F96588DD5B0}.Release.Build.0 = Release|Win32 - {14786FAE-450A-4935-B714-2190FDA9BFFD}.Debug.ActiveCfg = Debug|Win32 - {14786FAE-450A-4935-B714-2190FDA9BFFD}.Debug.Build.0 = Debug|Win32 - {14786FAE-450A-4935-B714-2190FDA9BFFD}.Release.ActiveCfg = Release|Win32 - {14786FAE-450A-4935-B714-2190FDA9BFFD}.Release.Build.0 = Release|Win32 - {58EAB682-E6A5-4AFE-96DF-CA9C30FC9206}.Debug.ActiveCfg = Debug|Win32 - {58EAB682-E6A5-4AFE-96DF-CA9C30FC9206}.Debug.Build.0 = Debug|Win32 - {58EAB682-E6A5-4AFE-96DF-CA9C30FC9206}.Release.ActiveCfg = Release|Win32 - {58EAB682-E6A5-4AFE-96DF-CA9C30FC9206}.Release.Build.0 = Release|Win32 - {72EC699B-9335-4ACF-B090-67A0D21F0306}.Debug.ActiveCfg = Debug|Win32 - {72EC699B-9335-4ACF-B090-67A0D21F0306}.Debug.Build.0 = Debug|Win32 - {72EC699B-9335-4ACF-B090-67A0D21F0306}.Release.ActiveCfg = Release|Win32 - {72EC699B-9335-4ACF-B090-67A0D21F0306}.Release.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution - EndGlobalSection -EndGlobal diff --git a/Tests/introduce/app/app.cpp b/Tests/introduce/app/app.cpp deleted file mode 100644 index 3643967b4..000000000 --- a/Tests/introduce/app/app.cpp +++ /dev/null @@ -1,25 +0,0 @@ - -#include "network.h" - -extern void Unittest_Network(); -extern void Unittest_Socket(); -extern void Unittest_SocketPeer(); -extern void Unittest_Message(); -extern void Unittest_MatchRecord(); -extern void Unittest_Roster(); -extern void Unittest_RosterQuery(); -extern void Unittest_Clock(); - -int -main() -{ - Unittest_Network(); - Unittest_Socket(); - Unittest_SocketPeer(); - Unittest_Message(); - Unittest_MatchRecord(); - Unittest_Roster(); - Unittest_RosterQuery(); - Unittest_Clock(); - return 0; -} diff --git a/Tests/introduce/app/app.suo b/Tests/introduce/app/app.suo deleted file mode 100644 index be4f53c70..000000000 Binary files a/Tests/introduce/app/app.suo and /dev/null differ diff --git a/Tests/introduce/app/app.vcproj b/Tests/introduce/app/app.vcproj deleted file mode 100644 index a9b455563..000000000 --- a/Tests/introduce/app/app.vcproj +++ /dev/null @@ -1,137 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Tests/introduce/getter/getter.cpp b/Tests/introduce/getter/getter.cpp deleted file mode 100644 index a53f75b12..000000000 --- a/Tests/introduce/getter/getter.cpp +++ /dev/null @@ -1,551 +0,0 @@ - - -#include "network.h" -#include "roster.h" -#include "../putter/xfer_proto.h" -#include "clock.h" -#include "sort_addr.h" - -#include -#include -#include -#include - -#include -#include -#include -#include - - -#if defined( WIN32 ) -#include -#include -#define SIGHUP 3 -#include -#include -#include -#define stat64func _stat64 -#define stat64struct struct __stat64 -#define LLFMT "%Ld" -typedef __int64 int64; -#else -#include -#include -#include -typedef long long int64; -#define LLFMT "%lld" -#endif - - -std::string gUserName = "luser"; -std::string gPassword = "secret"; -int gPort = 1599; -std::string gServer = "introduce.me:1599"; // .me is not actually a TLD as of June 2004 -bool gRunning = true; -bool gWaitForReturn; - -std::list< std::string > gFilesToGet; -bool gGetListOfFiles = true; - - -I_Network * gNetwork; -I_Clock * gClock; -I_RosterQuery * gRosterQuery; -I_Socket * gSocket; - - -// Print a helpful command-line usage message, and quit in disgust. -void usage() -{ - fprintf( stderr, "Usage: getter [options] [file ...]\n" ); - fprintf( stderr, "This program will retrieve the given files from some peer, as\n" ); - fprintf( stderr, "brokered by the given roster server.\n" ); - fprintf( stderr, "If no file given, will list all available files.\n" ); - fprintf( stderr, "This program can run behind a NAT firewall.\n" ); - fprintf( stderr, "long name short default\n" ); - fprintf( stderr, "--user -u %s\n", gUserName.c_str() ); - fprintf( stderr, "--password -w %s\n", gPassword.c_str() ); - fprintf( stderr, "--port -p %d (local port)\n", gPort ); - fprintf( stderr, "--server -s %s\n", gServer.c_str() ); - fprintf( stderr, "--wait -z wait for return before starting\n" ); - exit( 1 ); -} - -void addFileName( char const * str ) -{ - gFilesToGet.push_back( str ); - gGetListOfFiles = false; -} - -// Parse an option, if available. -int option( int num, char const ** & argv ) -{ - if( !strcmp( argv[0], "--user" ) || !strcmp( argv[0], "-u" ) ) { - if( num < 2 ) { - usage(); - } - gUserName = argv[1]; - return 2; - } - if( !strcmp( argv[0], "--password" ) || !strcmp( argv[0], "-w" ) ) { - if( num < 2 ) { - usage(); - } - gPassword = argv[1]; - return 2; - } - if( !strcmp( argv[0], "--port" ) || !strcmp( argv[0], "-p" ) ) { - if( num < 2 ) { - usage(); - } - gPort = atoi( argv[1] ); - if( gPort < 1 || gPort > 65535 ) { - fprintf( stderr, "ERROR: --port argument must be in range [1,65535]\n" ); - exit( 1 ); - } - return 2; - } - if( !strcmp( argv[0], "--server" ) || !strcmp( argv[0], "-s" ) ) { - if( num < 2 ) { - usage(); - } - gServer = argv[1]; - return 2; - } - if( !strcmp( argv[0], "--wait" ) || !strcmp( argv[0], "-z" ) ) { - gWaitForReturn = true; - return 1; - } - return 0; -} - -// Parse all available options in argv/argc -void readOptions( int argc, char const ** argv ) -{ - int cur = 1; - ++argv; - while( cur < argc ) { - if( !strcmp( *argv, "--" ) || ((*argv)[0] != '-') ) { - if( **argv == '-' ) { - ++cur; - ++argv; - } - break; - } - int used = option( argc-cur, argv ); - if( used == 0 ) { - usage(); - } - cur += used; - argv += used; - } - while( cur < argc ) { - addFileName( *argv ); - ++argv; - ++cur; - } -} - -namespace { - class RosterConnectionNotify : public I_RosterConnectionNotify { - public: - RosterConnectionNotify() { timeout_ = false; peer_ = 0; } - void disposing( I_RosterQuery * ) {} - void onPeerConnection( I_RosterQuery * query, - I_Socket * socket, I_SocketPeer * peer ) { - peer_ = peer; - } - void onRosterTimeout( I_RosterQuery * query, - I_Socket * socket ) { - timeout_ = true; - } - I_SocketPeer * peer_; - bool timeout_; - }; - RosterConnectionNotify gRosterConnectionNotify; -} - -void warnFunc( int level, char const * str, va_list vl ) -{ - vfprintf( stderr, str, vl ); - static FILE * f = fopen( "getter.log", "wb" ); - vfprintf( f, str, vl ); - fflush( f ); -} - -void initializeNetwork() -{ - char err[100]; - gNetwork = CreateNetwork( err, 100, warnFunc ); - if( !gNetwork ) { - fprintf( stderr, "Can't create network: %s\n", err ); - exit( 2 ); - } - gClock = CreateClock(); - if( !gClock ) { - fprintf( stderr, "Can't create clock.\n" ); - exit( 2 ); - } - gRosterQuery = CreateRosterQuery(); - if( !gRosterQuery ) { - fprintf( stderr, "Can't create roster query.\n" ); - exit( 2 ); - } - for( int portAdd = 0; portAdd < 11; ++portAdd ) { - gSocket = gNetwork->createSocket( gPort+portAdd, 0 ); - if( gSocket ) { - break; - } - } - if( !gSocket ) { - fprintf( stderr, "can't bind client on any ports %d - %d\n", gPort, gPort+10 ); - exit( 2 ); - } - gRosterQuery->notify( &gRosterConnectionNotify ); - gRosterQuery->connect( gSocket, gServer.c_str(), gUserName.c_str(), gPassword.c_str() ); -} - - -void stepNotConnected(); -void stepWaitingForReply(); -void stepWaitingForConnection(); -void stepTransferring(); -void stepDone(); - - -enum QueryState { - QueryStateNotConnected, - QueryStateWaitingForReply, - QueryStateWaitingForConnection, - QueryStateTransferring, - QueryStateDone, -}; - -struct { - char const * name; - void (*func)(); -} -gStateFuncs[] = { - { "Connecting to match-maker", stepNotConnected }, - { "Querying", stepWaitingForReply }, - { "Connecting to peer", stepWaitingForConnection }, - { "Transferring", stepTransferring }, - { "Done", stepDone }, -}; -int gState = QueryStateNotConnected; - -namespace { - class C_RosterQueryUser : public I_RosterQueryUser { - public: - void disposing( I_RosterQuery * query ) { - log( "C_RosterQueryUser::disposing()\n" ); - // do nothing - } - void onQueryResult( I_RosterQuery * query, - MatchedRecord const * matched, int numMatched ) { - // we're done! - log( "C_RosterQueryUser::onQueryResult()\n" ); - complete_ = true; - matches_.insert( matches_.begin(), matched, matched+numMatched ); - } - void onQueryTimeout( I_RosterQuery * query ) { - complete_ = true; - error_ = true; - log( "C_RosterQueryUser::onQueryTimeout()\n" ); - } - void clear() { - complete_ = false; - error_ = false; - matches_.swap( std::vector< MatchedRecord >() ); - } - bool complete() const { - return complete_; - } - bool error() const { - return error_; - } - int numRecords() const { - return (int)matches_.size(); - } - MatchedRecord const * records() const { - return &matches_[0]; - } - private: - std::vector< MatchedRecord > matches_; - bool error_; - bool complete_; - }; - C_RosterQueryUser gRosterQueryUser; -} - -void stepNotConnected() -{ - if( gRosterQuery->connected() ) { - log( "connected to roster\n" ); - gState = QueryStateWaitingForReply; - if( gGetListOfFiles ) { - gRosterQueryUser.clear(); - gRosterQuery->query( "name=%", &gRosterQueryUser, 100 ); - } - else { - std::list< std::string >::iterator f = gFilesToGet.begin(); - std::string q = "name="; - q += (*f); - gRosterQueryUser.clear(); - gRosterQuery->query( q.c_str(), &gRosterQueryUser, 10 ); - } - } -} - -void stepWaitingForReply() -{ - if( gRosterQueryUser.error() ) { - fprintf( stderr, "error querying roster (could we connect?)\n" ); - gRunning = false; - return; - } - if( gRosterQueryUser.complete() ) { - if( gGetListOfFiles ) { - MatchedRecord const * mr = gRosterQueryUser.records(); - int n = gRosterQueryUser.numRecords(); - for( int i = 0; i < n; ++i ) { - fprintf( stdout, "%s\t%s\n", mr[i].record, mr[i].score, - sort_sockaddr_in( mr[i].addr ).staticText() ); - } - gRunning = false; - } - else { - int n = gRosterQueryUser.numRecords(); - if( n == 0 ) { - fprintf( stderr, "no matching file was found\n" ); - gRunning = false; - return; - } - int ix = (rand() & 0x7fff) % n; - sort_sockaddr_in ssin = gRosterQueryUser.records()[ix].addr; - log( "connecting to %s\n", ssin.staticText() ); - gState = QueryStateWaitingForConnection; - gRosterQuery->introduce( ssin ); - } - } - if( gRosterConnectionNotify.timeout_ ) { - fprintf( stderr, "timeout from roster (after connection)\n" ); - gRunning = false; - return; - } -} - -namespace { - class Transfer : public I_SocketPeerUser { - public: - Transfer() { file_ = 0; name_ = ""; size_ = 0; complete_ = false; lastRequest_ = 0; } - ~Transfer() { - if( file_ ) { - fclose( file_ ); - _unlink( name_.c_str() ); - } - } - - void init( char const * file, long size ) { - char * ptr = strrchr( name_, '/' ); - if( ptr ) ptr++; else ptr = name_; - char * ptr2 = strrchr( ptr, '\\' ); - if( ptr2 ) ptr = ptr2+1; - if( strlen( ptr ) == 0 ) { - ptr = "received.dat"; - } - name_ = ptr; - file_ = fopen( ptr, "wb" ); - size_ = size; - togo_.push_back( std::pair< long, long >( 0, size_ ) ); - complete_ = false; - } - - void put( void const * buf, long pos, long size ) { - fseek( file_, pos, 0 ); - fwrite( buf, size, 1, file_ ); - removeSpan( pos, pos+size ); - } - - void done() { - fclose( file_ ); - file_ = 0; - peer_ = 0; - complete_ = true; - } - - void removeSpan( long a, long b ) { - std::list< std::pair< long, long > >::iterator ptr = togo_.begin(); - while( ptr != togo_.end() ) { - std::list< std::pair< long, long > >::iterator next = ptr; - ++next; - if( (*ptr).first <= b && (*ptr).second >= a ) { - // at least part of the span is covered here - if( (*ptr).first >= a ) { - // cutting from the front - if( (*ptr).second <= b ) { - // totally gone - togo_.erase( ptr ); - } - else { - (*ptr).first = b; - } - } - else if( (*ptr).second <= b ) { - // cutting from the back - assert( (*ptr).first < a ); // else previous case should have been hit - (*ptr).second = a; - } - else { - // cutting in the middle - std::pair< long, long > second; - second.first = (*ptr).first; - second.second = a; - (*ptr).first = b; - togo_.insert( ptr, second ); - } - } - assert( (*ptr).first < (*ptr).second ); - ptr = next; - } - } - - bool nextSpan( long * a, long * b ) { - if( todo_.size() == 0 ) { - return false; - } - *a = todo_.front().first; - *b = todo_.front().second; - return true; - } - - FILE * file_; - std::string name_; - long size_; - std::list< std::pair< long, long > > togo_; - I_SocketPeer * peer_; - bool complete_; - double lastRequest_; - - void setPeer( I_SocketPeer * peer ) { - peer_ = peer; - peer->setUser( this ); - } - - void step( double now ) { - if( !complete_ ) { - maybeSendRequest( now ); - maybeSendKeepalive( now ); - maybeRequestNextSpan( now ); - } - } - - void maybeSendRequest( double now ) { - if( !file_ && now > lastRequest_ + 0.9f ) { - lastRequest_ = now; - assert( peer_ ); - Message m; - m.put( gFilesToGet.front().c_str() ); - ProtoHeader::prepend( XferRequest, m ); - peer_->sendMessage( m.buf_, m.size_ ); - } - } - - void maybeSendKeepalive( double now ) { - // this likely never happens, as we keep sending requests faster than the timeout - if( now > lastRequest_ + 7 ) { - lastRequest_ = now; - ProtoHeader ph; - ph.type = Keepalive; - ph.size = 0; - peer_->sendMessage( &ph, sizeof( ph ) ); - } - } - - void maybeRequestNextSpan( double now ) { - if( !file_ ) { - return; - } - long a, b; - if( !nextSpan( &a, &b ) ) { - disconnect(); - } - else if( now > lastRequest_ + 2 ) { - lastRequest_ = now; - requestNextSpan( a, b ); - } - } - - void disconnect() { - XferDisconnect... - done(); - } - - void requestNextSpan( long a, long b ) { - XferPacketRequest... - } - - ... do the peer user, deal with packets ... - }; - Transfer gTransfer; -} - -void stepWaitingForConnection() -{ - I_SocketPeer * p = gRosterConnectionNotify.peer_; - if( p ) { - log( "got a peer: %s\n", sort_sockaddr_in( p->peerAddress() ).staticText() ); - gState = QueryStateTransferring; - } -} - -void stepTransferring() -{ - if( !gTransfer.peer_ ) { - gTransfer.setPeer( gRosterConnectionNotify.peer_ ); - } - gTransfer.step(); - if( gTransfer.complete_ ) { - gState = QueryStateDone; - } -} - -void stepDone() -{ - if( gFilesToGet.size() ) { - gFilesToGet.erase( gFilesToGet.begin() ); - gState = QueryStateNotConnected; - } - else { - gRunning = false; - log( "All files transferred; done.\n" ); - } -} - -void runMainLoop() -{ - while( gRunning ) { - gNetwork->step( 0.25 ); - gRosterQuery->step( gClock->realTime() ); - (*gStateFuncs[gState].func)(); - } -} - -void sleep10() { - ::Sleep( 5000 ); -} - -int main( int argc, char const ** argv ) -{ - atexit( sleep10 ); - readOptions( argc, argv ); - if( gWaitForReturn ) { - fprintf( stderr, "Press RETURN to continue:\n" ); - char line[ 10 ]; - fgets( line, 10, stdin ); - } - initializeNetwork(); - runMainLoop(); - return 0; -} - diff --git a/Tests/introduce/getter/getter.vcproj b/Tests/introduce/getter/getter.vcproj deleted file mode 100644 index 25f2ea65a..000000000 --- a/Tests/introduce/getter/getter.vcproj +++ /dev/null @@ -1,137 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Tests/introduce/lib/clock.cpp b/Tests/introduce/lib/clock.cpp deleted file mode 100644 index c2109939f..000000000 --- a/Tests/introduce/lib/clock.cpp +++ /dev/null @@ -1,64 +0,0 @@ - -#include "clock.h" -#include "sock_port.h" - -#include -#include - -using namespace libintroduce; - -namespace { - class C_Clock : public I_Clock { - public: - C_Clock() { - if( origin_ < 0 ) { - myOrigin_ = 0; - origin_ = realTime(); - assert( origin_ >= 0 ); - } - myOrigin_ = origin_ - 100; - } - void dispose() { delete this; } - double realTime(); - void adjust( double delta ) { - myOrigin_ -= delta; - } - static double origin_; - double myOrigin_; - }; - double C_Clock::origin_ = -100; -} - -I_Clock * libintroduce::CreateClock() -{ - return static_cast< I_Clock * >( new C_Clock() ); -} - -double C_Clock::realTime() -{ - struct timeval tv; - gettimeofday( &tv, 0 ); - double r = double( tv.tv_sec ) + 1e-6 * double( tv.tv_usec ) - myOrigin_; - return r; -} - -void Unittest_Clock() -{ - I_Clock * c1 = CreateClock(); - ::Sleep( 10 ); - I_Clock * c2 = CreateClock(); - double c1t, c2t; - c1t = c1->realTime(); - c2t = c2->realTime(); - assert( fabs( c1t - c2t ) < 1e-5 ); - c1->adjust( 100 ); - c1t = c1->realTime(); - c2t = c2->realTime(); - assert( c1t > 99 + c2t ); - c1->adjust( -200 ); - c1t = c1->realTime(); - c2t = c2->realTime(); - assert( c1t < c2t-99 ); - c1->dispose(); - c2->dispose(); -} diff --git a/Tests/introduce/lib/clock.h b/Tests/introduce/lib/clock.h deleted file mode 100644 index 2a7343885..000000000 --- a/Tests/introduce/lib/clock.h +++ /dev/null @@ -1,18 +0,0 @@ - -#if !defined( clock_h ) -#define clock_h - -namespace libintroduce { - -class I_Clock { - public: - virtual void dispose() = 0; - virtual double realTime() = 0; - virtual void adjust( double delta ) = 0; -}; - -I_Clock * CreateClock(); - -} - -#endif // clock_h diff --git a/Tests/introduce/lib/i_rosterconnectionnotify.h b/Tests/introduce/lib/i_rosterconnectionnotify.h deleted file mode 100644 index f18c60274..000000000 --- a/Tests/introduce/lib/i_rosterconnectionnotify.h +++ /dev/null @@ -1,33 +0,0 @@ - -#if !defined( i_rosterconnectionnotify_h ) -#define i_rosterconnectionnotify_h - -#include "roster.h" - -namespace libintroduce { - -class I_RosterQuery; - -class I_RosterConnectionNotify { - public: - // You will be called back when the roster query goes away. - virtual void disposing( I_RosterQuery * query ) = 0; - // I_RosterQuery calls this callback when a peer tries - // to connect to the socket specified on the roster, after - // the roster has actually connected to the roster server. - // It is up to you (the implementer of onPeerConnection()) - // to dispose the I_SocketPeer when you're done with it. - // You should typically configure a user on the peer, and - // start trying to communicate. - virtual void onPeerConnection( I_RosterQuery * query, - I_Socket * socket, I_SocketPeer * peer ) = 0; - // I_RosterQuery can also tell you about timeouts if there - // are no keepalives received from the registration server - // for a long while. - virtual void onRosterTimeout( I_RosterQuery * query, - I_Socket * socket ) = 0; -}; - -} - -#endif // i_rosterconnectionnotify_h diff --git a/Tests/introduce/lib/i_rosterquery.h b/Tests/introduce/lib/i_rosterquery.h deleted file mode 100644 index 3f40bb214..000000000 --- a/Tests/introduce/lib/i_rosterquery.h +++ /dev/null @@ -1,81 +0,0 @@ - -#if !defined( i_rosterquery_h ) -#define i_rosterquery_h - -#include "roster.h" - -namespace libintroduce { - -struct MatchedRecord; -class I_Network; -class I_Socket; -class I_Roster; -class I_RosterQueryUser; -class I_RosterConnectionNotify; - -// Time-outs aren't really that easy to detect or do something about -// through this interface. Not being able to log in can be detected -// by you by polling connected() over time, but once connected, if -// the roster crashes or shuts down, and doesn't get a Kick message -// through to you, there's now way of knowing. -// Perhaps your best defense is to create a new query and call connect() -// over again every so often (every 10 minutes?). -class I_RosterQuery { -public: - // Dispose me when you're done with me; I will disconnect if connected. - virtual void dispose() = 0; - // You can only connect() me to one roster at a time. The roster is - // identified using a server string, or a resolved sockaddr_in. - // You must not already have created a peer for the server address - // on the socket. - virtual void connect( I_Socket * socket, char const * server, - char const * name, char const * password ) = 0; - virtual void connect( I_Socket * socket, sockaddr_in const & server, - char const * name, char const * password ) = 0; - // You may specify a notify interface, into which peers trying - // to connect to your socket will be dispatched. - virtual void notify( I_RosterConnectionNotify * notify ) = 0; - // connected() returns true if I actually have connected to a server. - virtual bool connected() = 0; - // Once connect() is started, you must step() me until connected() returns - // true. You must also step() me after query() has been issued, until the - // query returns a result. It's also a good idea to step() while connected, - // to make sure keep-alives make it through. Make sure curTime increases - // linearly with time. - virtual void step( double curTime ) = 0; - // To issue a query, call query(). The result, if any, will be reported - // to the user. After some timeout, the user may be told the query was - // unsuccessful. You must step() me while a query is outstanding. - virtual void query( char const * key, I_RosterQueryUser * user, - int maxRecords ) = 0; - // To register a record when connected, call add(). - // You will need to step() me every so often so that I can send - // keep-alives to the server. - virtual void add( char const * key, int recId ) = 0; - // To connect to a peer that you found through the matchmaking service, - // call introduce(); if the introduction is successful, the - // I_RosterConnectionNotify you configured in notify() will be told about it. - virtual void introduce( sockaddr_in const & peer ) = 0; -}; - -I_RosterQuery * CreateRosterQuery(); - -// If you don't want to do anything else while querying, I provide a simple -// synchronous function for connecting to a server and running a query, -// returning the number of elements found. The network will be stepped until -// timeout happens (about 5 seconds) or a result is retrieved. Returns 0 when -// there are no results, and -1 if there's a connectivity error. -// Ownership for the MatchedRecord strings is kept statically by -// SimpleRosterQuery until the next call to SimpleRosterQuery. -// Note that this isn't really terribly useful, because there is no way to -// actually connect to the peers of the returned responses, because that needs -// the introducer to tell the other guy to cooperate. -int SimpleRosterQuery( I_Network * nw, - char const * server, - char const * user, char const * password, - char const * key, - MatchedRecord * outRecords, int maxRecords ); - -} - -#endif // i_rosterquery_h diff --git a/Tests/introduce/lib/i_rosterqueryuser.h b/Tests/introduce/lib/i_rosterqueryuser.h deleted file mode 100644 index 5ceed69c8..000000000 --- a/Tests/introduce/lib/i_rosterqueryuser.h +++ /dev/null @@ -1,28 +0,0 @@ - -#if !defined( i_rosterqueryuser_h ) -#define i_rosterqueryuser_h - -#include "roster.h" - -namespace libintroduce { - -struct MatchedRecord; -class I_RosterQuery; - -class I_RosterQueryUser { -public: - // When the query connection is going away, I'll be told, if - // I still have a query outstanding. - virtual void disposing( I_RosterQuery * query ) = 0; - // when the query completes or fails, I'm told about the - // results, or the failure. The query will then forget about - // me -- I will not get disposing() at that point. - virtual void onQueryResult( I_RosterQuery * query, - MatchedRecord const * matched, int numMatched ) = 0; - virtual void onQueryTimeout( I_RosterQuery * query ) = 0; -}; - -} - -#endif // i_rosterqueryuser_h - diff --git a/Tests/introduce/lib/i_rosteruser.h b/Tests/introduce/lib/i_rosteruser.h deleted file mode 100644 index 168e18f4e..000000000 --- a/Tests/introduce/lib/i_rosteruser.h +++ /dev/null @@ -1,44 +0,0 @@ - -#if !defined( i_rosteruser_h ) -#define i_rosteruser_h - -#include "roster.h" - -namespace libintroduce { - -struct MatchedRecord; -class I_Roster; - -class I_RosterUser { -public: - // disposing() is called back when the roster is going away - virtual void disposing( I_Roster * roster ) = 0; - // validatePeer() is called when a user attempts to connect; return TRUE if you - // want to allow the user to proceed. How you store user information and passwords - // is your problem. The user name and password fields can each be up to 64 chars. - virtual bool validatePeer( I_Roster * roster, sockaddr_in const & peer, - char const * name, char const * password ) = 0; - // userTimeout() is called when a user is timed out because of inactivity. - virtual void userTimeout( I_Roster * roster, sockaddr_in const & peer ) = 0; - // registerRecord() is called when a user attempts to register a record; call - // back into the roster to register the record if you agree. - // The token is supplied by the peer, and used by the peer to identify the - // registration (to avoid duplicates in case of network problems). - virtual void registerRecord( I_Roster * roster, sockaddr_in const & peer, - char const * record, int token ) = 0; - // matchRecords() is called when a user attempts to query records; you can - // call back into the roster to match records if you agree. Return the number - // of actual records matched. - virtual int matchRecords( I_Roster * roster, sockaddr_in const & peer, - char const * key, int id, MatchedRecord * outMatches, int maxMatches ) = 0; - // allocIntroduction() is called when a user attempts to get introduced to - // another peer. Typically, you will call back into the roster to make a - // introduce() call. - virtual void allowIntroduction( I_Roster * roster, sockaddr_in const & peer1, - sockaddr_in const & peer2 ) = 0; -}; - -} - -#endif // i_rosteruser_h - diff --git a/Tests/introduce/lib/i_socket.h b/Tests/introduce/lib/i_socket.h deleted file mode 100644 index f9ac8a73f..000000000 --- a/Tests/introduce/lib/i_socket.h +++ /dev/null @@ -1,45 +0,0 @@ -#if !defined( i_socket_h ) -#define i_socket_h - -#include "sock_port.h" - -namespace libintroduce { - -class I_Network; -class I_SocketUser; -class I_SocketPeer; -class I_SocketPeerUser; - -class I_Socket { -public: - // When you're done with me (the socket), dispose me. - virtual void dispose() = 0; - // I know which Network instance I belong to. - virtual I_Network * network() = 0; - // I can tell you the user that was configured on me on creation. - virtual I_SocketUser * socketUser() = 0; - // You can reconfigure my user. - virtual void setSocketUser( I_SocketUser * user ) = 0; - // I can create a peer for you. It is an error to create a peer - // for an address that already has a peer; such attempts will return NULL. - virtual I_SocketPeer * createPeer( sockaddr_in const & addr, I_SocketPeerUser * user ) = 0; - // I can create a peer using text-format addressing, too (this may - // not be instantaneous, because DNS is synchronous). If the address - // does not contain a :port part, I use the port of my socket. - virtual I_SocketPeer * createPeer( char const * addr, I_SocketPeerUser * user, - char * oError, int eSize ) = 0; - // return the peer for an address, if available - virtual I_SocketPeer * findPeer( sockaddr_in const & addr ) = 0; - // I can send a message to an arbitrary address, if you want. It may or - // may not make it to the other end; there's no way to tell. - virtual void sendMessage( sockaddr_in const & addr, void const * buf, int bSize ) = 0; - // I can tell you the local name of the socket. This may be of - // limited utility, because it's likely to be a private address, - // not visible on the global internet. That's why you should use - // the Roster interface for finding other peers to talk to. - virtual sockaddr_in address() = 0; -}; - -} - -#endif // i_socket_h diff --git a/Tests/introduce/lib/i_socketpeer.h b/Tests/introduce/lib/i_socketpeer.h deleted file mode 100644 index e94519e49..000000000 --- a/Tests/introduce/lib/i_socketpeer.h +++ /dev/null @@ -1,31 +0,0 @@ -#if !defined( i_socketpeer_h ) -#define i_socketpeer_h - -#include "sock_port.h" - -namespace libintroduce { - -class I_SocketPeerUser; - -class I_SocketPeer { -public: - // Dispose me when you're done with me. - virtual void dispose() = 0; - // I return the address of the peer. - virtual sockaddr_in const & peerAddress() = 0; - // I return the socket I was created on. - virtual I_Socket * socket() = 0; - // I return the peer user configured on me upon creation. - virtual I_SocketPeerUser * socketPeerUser() = 0; - // I can attempt to send data to the other end. - // There are no guarantees that the message will make it - // to the other side. The message will be copied (so you - // can delete the underlying buffer) and may not be sent until - // the next time you call step() on the I_Network. - virtual void sendMessage( void const * buf, int bSize ) = 0; -}; - -} - -#endif // i_socketpeer_h - diff --git a/Tests/introduce/lib/i_socketpeeruser.h b/Tests/introduce/lib/i_socketpeeruser.h deleted file mode 100644 index 1674be443..000000000 --- a/Tests/introduce/lib/i_socketpeeruser.h +++ /dev/null @@ -1,18 +0,0 @@ -#if !defined( i_socketpeeruser_h ) -#define i_socketpeeruser_h - -namespace libintroduce { - -// You implement I_SocketPeerUser to get notified -// about arriving data for a specific socket. -class I_SocketPeerUser { - public: - // When the peer is deleted, you will get notified. - virtual void disposing( I_SocketPeer * peer ) = 0; - // When data comes in, you are notified. - virtual void onMessage( I_SocketPeer * peer, char const * buf, int bSize ) = 0; -}; - -} - -#endif // i_socketpeeruser_h diff --git a/Tests/introduce/lib/i_socketuser.h b/Tests/introduce/lib/i_socketuser.h deleted file mode 100644 index 36fb8a824..000000000 --- a/Tests/introduce/lib/i_socketuser.h +++ /dev/null @@ -1,29 +0,0 @@ -#if !defined( i_socketuser_h ) -#define i_socketuser_h - -#include "sock_port.h" - -namespace libintroduce { - -class I_Socket; - -// You implement SocketUser, and had to I_Introduce when -// creating a socket. -class I_SocketUser { - public: - // When the bound socket goes away, you are called back - // to be notified about it (although you likely already - // initiated the socket death in the first place). - virtual void disposing( I_Socket * socket ) = 0; - - // When a message arrives from a socket that does not have - // a peer, this function is called on you. You can turn around - // and call I_Socket::createPeer(), for example. The buffer is - // the packet data. - virtual void onConnection( I_Socket * socket, sockaddr_in const & addr, - char const * buf, int bSize ) = 0; -}; - -} - -#endif // i_socketuser_h diff --git a/Tests/introduce/lib/lib.suo b/Tests/introduce/lib/lib.suo deleted file mode 100644 index b4d62e9e6..000000000 Binary files a/Tests/introduce/lib/lib.suo and /dev/null differ diff --git a/Tests/introduce/lib/lib.vcproj b/Tests/introduce/lib/lib.vcproj deleted file mode 100644 index 6cee19e7a..000000000 --- a/Tests/introduce/lib/lib.vcproj +++ /dev/null @@ -1,180 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Tests/introduce/lib/match.cpp b/Tests/introduce/lib/match.cpp deleted file mode 100644 index 77e39bdec..000000000 --- a/Tests/introduce/lib/match.cpp +++ /dev/null @@ -1,214 +0,0 @@ - -#include "roster.h" - -#include - -using namespace libintroduce; - - -static char const * Match( - char const * strBeg, - char const * strEnd, - char const * matchBeg, - char const * matchEnd, - bool anyStart ) -{ - assert( strEnd > strBeg ); - assert( matchEnd > matchBeg ); - while( matchEnd-matchBeg <= strEnd-strBeg ) { - if( *strBeg == *matchBeg && !strncmp( strBeg, matchBeg, matchEnd-matchBeg ) ) { - return strBeg + (matchEnd-matchBeg); - } - if( !anyStart ) { - break; - } - ++strBeg; - } - return false; -} - -static bool MatchPattern( - char const * patBeg, - char const * patEnd, - char const * strBeg, - char const * strEnd ) -{ - bool anyStart = false; - char const * matchBeg = patBeg; - while( patBeg < patEnd ) { - if( *patBeg == '%' ) { - if( matchBeg < patBeg ) { - strBeg = Match( strBeg, strEnd, matchBeg, patBeg, anyStart ); - if( !strBeg ) { - return false; - } - } - anyStart = true; - ++patBeg; - matchBeg = patBeg; - } - else { - ++patBeg; - } - } - if( matchBeg < patBeg ) { - strBeg = Match( strBeg, strEnd, matchBeg, patBeg, anyStart ); - if( !strBeg ) { - return false; - } - } - return true; -} - -static bool getnum( char const ** str, char const * end, long * out ) -{ - // strtol() needs zero termination, so we create a zero-terminated sub-string. - // I picked 48 chars because 47 characters is more than needed to represent - // even a long double in decimal. (128 bits / 3.1 bits per digit ~= 42 digits). - // This is overly paranoid, as I only support integers anyway. - char num[ 48 ]; - size_t l = end-*str; - if( l > 47 ) { - l = 47; - } - memcpy( num, *str, l ); - num[ l ] = 0; - char * o = 0; - *out = strtol( *str, &o, 10 ); - if( o == 0 || o == *str ) { - return false; - } - *str = o; - return true; -} - -static bool MatchChunk( - char const * recBeg, - char const * recEnd, - char op, - char const * valBeg, - char const * valEnd ) -{ - if( op == '<' || op == '>' ) { - // numeric comparision - long l1, l2; - if( !getnum( &recBeg, recEnd, &l1 ) ) { - return 0; - } - if( !getnum( &valBeg, valEnd, &l2 ) ) { - return 0; - } - if( op == '<' && l1 < l2 ) { - return true; - } - if( op == '>' && l1 > l2 ) { - return true; - } - } - else { - assert( op == '=' ); - return MatchPattern( valBeg, valEnd, recBeg, recEnd ); - } - return false; -} - -static int AttemptMatch( - char const * record, - char const * name, - char const * nameEnd, - char op, - char const * val, - char const * valEnd ) -{ - // pick apart the record to find key/value pairs to match against - char const * beg = record; - char const * eq; - while( true ) { - eq = strchr( beg, '=' ); - if( !eq ) { - if( *beg != 0 ) { - warning( "poorly formatted match record: %s", beg ); - } - break; - } - char const * semi = strchr( eq+1, ';' ); - if( !semi ) { - semi = eq + strlen( eq ); - } - if( eq-beg == nameEnd-name && !strncmp( beg, name, eq-beg ) ) { - if( MatchChunk( eq+1, semi, op, val, valEnd ) ) { - return 1; - } - } - if( !*semi ) { - break; - } - beg = semi+1; - } - - return 0; -} - -float libintroduce::MatchRecord( char const * record, char const * key ) -{ - int nFound = 0; // number of key clauses - int nMatch = 0; // number actually matched - // pick apart the values in the key - char const * cur = key; - char const * end = key; - while( cur ) { - end = strchr( cur, ';' ); - if( end == 0 ) { - end = cur + strlen( cur ); - } - if( cur == end ) { - break; - } - char const * op = cur; - while( op < end ) { - if( *op == '=' || *op == '<' || *op == '>' ) { - break; - } - ++op; - } - // let's assume we found an op - ++nFound; - if( op < end ) { - // actually attempt match - nMatch += AttemptMatch( record, cur, op, *op, op+1, end ); - } - else { - // warn on mal-formed key? - } - cur = *end ? end+1 : 0; - } - assert( nMatch <= nFound ); - if( nFound == 0 ) { - return 1; - } - if( nMatch == 0 ) { - return 0; - } - return float(nMatch)/float(nFound); -} - - -void Unittest_MatchRecord() -{ - assert( MatchRecord( "", "" ) == 1 ); - assert( MatchRecord( "foo=1", "" ) == 1 ); - assert( MatchRecord( "", "foo=1" ) == 0 ); - assert( MatchRecord( "foo=1", "foo>0" ) == 1 ); - assert( MatchRecord( "foo=1", "foo<0" ) == 0 ); - assert( MatchRecord( "foo=1;bar=1;baz=2", "baz<2" ) == 0 ); - assert( MatchRecord( "foo=1;bar=1;baz=2", "baz>1" ) == 1 ); - assert( MatchRecord( "foo=1;bar=1;baz=2", "baz>1;bar=0" ) == 0.5f ); - assert( MatchRecord( "foo=this is a string;bar=another string", "foo=%another%" ) == 0 ); - assert( MatchRecord( "foo=this is a string;bar=another string", "foo=%string%;bar=%this%" ) == 0.5f ); - assert( MatchRecord( "foo=this is a string;bar=another string", "foo=%string%;bar=%string%" ) == 1 ); - assert( MatchRecord( "foo=this is a string;bar=another string", "bar=another %" ) == 1 ); - assert( MatchRecord( "foo=this is a string;bar=another string", "bar=%another string" ) == 1 ); - assert( MatchRecord( "foo=this is a string;bar=another string", "bar=% string" ) == 1 ); - assert( MatchRecord( "foo=this is a string;bar=another string", "foo=%=%" ) == 0 ); -} - diff --git a/Tests/introduce/lib/message.cpp b/Tests/introduce/lib/message.cpp deleted file mode 100644 index 73aeda2bb..000000000 --- a/Tests/introduce/lib/message.cpp +++ /dev/null @@ -1,177 +0,0 @@ - -#include "message.h" - -#include -#include - -#define PREPEND_PAD 8 - -using namespace libintroduce; - -Message::Message() -{ - clear(); -} - -Message::Message( void const * src, int len ) -{ - if( len > sizeof( storage_ ) ) { - throw "Too large buffer for Message"; - } - buf_ = storage_; - size_ = len; - base_ = 0; - memcpy( buf_, src, len ); -} - -Message::Message( Message const & m ) -{ - copy( m ); -} - -Message & Message::operator=( Message const & m ) -{ - copy( m ); - return *this; -} - -void Message::copy( Message const & m ) -{ - buf_ = &storage_[m.buf_-m.storage_]; - size_ = m.size_; - base_ = m.base_; - memcpy( buf_, m.buf_, size_ ); -} - - -void Message::clear() -{ - // empty messages may later be pre-pended into - buf_ = &storage_[PREPEND_PAD]; - size_ = 0; - base_ = 0; -} - -bool Message::slurp( void const * src, int cnt ) -{ - if( cnt > int(sizeof(storage_)-size_) ) { - return false; - } - // shift down if we need to make room - if( buf_+size_+cnt > &storage_[MAX_MESSAGE_SIZE] ) { - assert( buf_ > storage_ ); - memmove( storage_, buf_, size_ ); - buf_ = storage_; - } - memcpy( &buf_[size_], src, cnt ); - size_ += cnt; - return true; -} - -bool Message::spew( void * buf, int len ) -{ - if( len > size_-base_ ) { - return false; - } - memcpy( buf, &buf_[base_], len ); - base_ += len; - return true; -} - -bool Message::spew_cstr( char * buf, int max ) -{ - assert( base_ <= size_ ); - if( base_ == size_ ) { - *buf = 0; - return false; - } - // find amount of space, excluding terminator - int l = max-1; - if( l + base_ >= size_ ) { - l = size_-base_-1; - } - // find length of string within these limits - int n = 0; - while( n < l ) { - if( buf_[base_+n] == 0 ) { - break; - } - ++n; - } - // if string is not terminated, complain - if( buf_[base_+n] ) { - *buf = 0; - return false; - } - memcpy( buf, &buf_[base_], n+1 ); - base_ += n+1; - return true; -} - -bool Message::prependn( int num, void const * src ) -{ - if( num > int(sizeof(storage_)-size_) ) { - return false; - } - // if there's size in the prepend area, then use that - if( buf_-storage_ >= num ) { - buf_ -= num; - memcpy( buf_, src, num ); - size_ += num; - if( base_ > 0 ) { - base_ += num; - } - return true; - } - // compact the message - memmove( &storage_[num], buf_, size_ ); - buf_ = storage_; - memcpy( buf_, src, num ); - size_ += num; - if( base_ > 0 ) { - base_ += num; - } - return true; -} - -void Unittest_Message() -{ - Message m; - - memset( &m.storage_, 0, sizeof( m.storage_ ) ); // to test string termination below - m.put( 1 ); - m.put( 2.25f ); - m.put( "hello, world" ); - assert( m.size_ == 4+4+13 ); - int i; m.get( &i ); assert( i == 1 ); - float f; m.get( &f ); assert( f == 2.25f ); - char buf[ 32 ]; m.get( buf, 32 ); assert( !strcmp( buf, "hello, world" ) ); - assert( !m.get( buf, 32 ) ); // out of data - m.prependn( 4, "1234" ); - m.base_ = 0; - buf[0] = 0; - m.getn( 4, buf ); - assert( !strncmp( buf, "1234", 4 ) ); - m.base_ = m.size_; - - Message m2 = m; - m.base_ = 0; - m.size_ = 0; - assert( m2.size_ == 4+4+4+13 ); - assert( m2.base_ == m2.size_ ); - - char temp[ MAX_MESSAGE_SIZE ]; - assert( m.putn( sizeof(temp)-4, temp ) ); - assert( !m.put( "hello" ) ); - assert( m.put( "hey" ) ); - assert( m.size_ == sizeof( temp ) ); - assert( !m.prependn( 1, "" ) ); - - Message m3( m.storage_, m.size_ ); - assert( m.getn( sizeof(temp)-4, temp ) ); - temp[4] = 0x45; - assert( m.get( temp, 100 ) ); - assert( !strcmp( temp, "hey" ) ); - assert( temp[4] == 0x45 ); -} - diff --git a/Tests/introduce/lib/message.h b/Tests/introduce/lib/message.h deleted file mode 100644 index 7765727ad..000000000 --- a/Tests/introduce/lib/message.h +++ /dev/null @@ -1,77 +0,0 @@ - -#if !defined( message_h ) -#define message_h - -#include "network.h" // for MAX_MESSAGE_SIZE -#include - -namespace libintroduce { - -// This is a simple utility class for generating network packets. -// -// Usage: -// -// Message m; -// m.put( 1 ); -// m.put( 2.3f ); -// m.put( "this is a string" ); -// sendMessage( m.buf_, m.size_ ); -// -// void Me::receive( void const * buf, int size ) { -// Message m2( buf, size ); -// int i; m2.get( &i ); -// float f; m2.get( &f ); -// char str[ 128 ]; m2.get( str, sizeof( str ) ); -// } -// -// Note that there is no error checking (except you can't overrun -// any buffers; all lengths are checked). Thus, you have to match -// up input and output fields/sizes yourself. - -class Message { - public: - Message(); - Message( void const * src, int len ); - Message( Message const & m ); - Message & operator=( Message const & m ); - ~Message() {} - void clear(); - - bool putn( int num, void const * buf ) { return slurp( buf, num ); } - // You never want to send pointers, so if you pass a pointer, you meant the pointed-at thing - template< typename T > bool put( T const & t ) { return putn( sizeof(T), &t ); } - template< typename T > bool put( T const * t ) { return putn( sizeof(T), t ); } - template<> bool put< char >( char const * str ) { return slurp( str, int(strlen( str )) + 1 ); } - - bool getn( int num, void * buf ) { return spew( buf, num ); } - template< typename T > bool get( T & t ) { return getn( sizeof(T), &t ); } - // just don't get() on a pointer to a single char (because that looks like a string, which needs buffer size) - template< typename T > bool get( T * t ) { assert(sizeof(T) != 1); return getn( sizeof(T), t ); } - bool get( char * buf, int max ) { return spew_cstr( buf, max ); } - - bool prependn( int num, void const * buf ); - template< typename T > bool prepend( T const & t ) { return prependn( sizeof(T), &t ); } - template< typename T > bool prepend( T const * t ) { return prependn( sizeof(T), t ); } - - // The semantics of buf_, size_ and base_ are fixed -- you can bang these - // values yourself if you want to, say, skip over bytes when reading. - // buf_+base_ is the next place to read from; buf_+size_ is the end of - // the buffer; buf_ is the first valid byte in the buffer, which may be - // somewhere into storage_, if I have space left for copy-less prepend(). - char * buf_; - int size_; - int base_; - // put storage at the end for cache locality of the other members - char storage_[ MAX_MESSAGE_SIZE ]; - - protected: - bool slurp( void const * src, int cnt ); - bool spew( void * buf, int len ); - bool spew_cstr( char * buf, int max ); - void copy( Message const & m ); -}; - -} - -#endif - diff --git a/Tests/introduce/lib/netfw.h b/Tests/introduce/lib/netfw.h deleted file mode 100644 index 3a1e4a759..000000000 --- a/Tests/introduce/lib/netfw.h +++ /dev/null @@ -1,3767 +0,0 @@ - -#pragma warning( disable: 4049 ) /* more than 64k source lines */ - -/* this ALWAYS GENERATED file contains the definitions for the interfaces */ - - - /* File created by MIDL compiler version 6.00.0347 */ -/* Compiler settings for netfw.idl: - Oicf, W1, Zp8, env=Win32 (32b run) - protocol : dce , ms_ext, c_ext, robust - error checks: allocation ref bounds_check enum stub_data - VC __declspec() decoration level: - __declspec(uuid()), __declspec(selectany), __declspec(novtable) - DECLSPEC_UUID(), MIDL_INTERFACE() -*/ -//@@MIDL_FILE_HEADING( ) - - -/* verify that the version is high enough to compile this file*/ -#ifndef __REQUIRED_RPCNDR_H_VERSION__ -#define __REQUIRED_RPCNDR_H_VERSION__ 475 -#endif - -#include "rpc.h" -#include "rpcndr.h" - -#ifndef __RPCNDR_H_VERSION__ -#error this stub requires an updated version of -#endif // __RPCNDR_H_VERSION__ - -#ifndef COM_NO_WINDOWS_H -#include "windows.h" -#include "ole2.h" -#endif /*COM_NO_WINDOWS_H*/ - -#ifndef __netfw_h__ -#define __netfw_h__ - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -#pragma once -#endif - -/* Forward Declarations */ - -#ifndef __INetFwRemoteAdminSettings_FWD_DEFINED__ -#define __INetFwRemoteAdminSettings_FWD_DEFINED__ -typedef interface INetFwRemoteAdminSettings INetFwRemoteAdminSettings; -#endif /* __INetFwRemoteAdminSettings_FWD_DEFINED__ */ - - -#ifndef __INetFwIcmpSettings_FWD_DEFINED__ -#define __INetFwIcmpSettings_FWD_DEFINED__ -typedef interface INetFwIcmpSettings INetFwIcmpSettings; -#endif /* __INetFwIcmpSettings_FWD_DEFINED__ */ - - -#ifndef __INetFwOpenPort_FWD_DEFINED__ -#define __INetFwOpenPort_FWD_DEFINED__ -typedef interface INetFwOpenPort INetFwOpenPort; -#endif /* __INetFwOpenPort_FWD_DEFINED__ */ - - -#ifndef __INetFwOpenPorts_FWD_DEFINED__ -#define __INetFwOpenPorts_FWD_DEFINED__ -typedef interface INetFwOpenPorts INetFwOpenPorts; -#endif /* __INetFwOpenPorts_FWD_DEFINED__ */ - - -#ifndef __INetFwService_FWD_DEFINED__ -#define __INetFwService_FWD_DEFINED__ -typedef interface INetFwService INetFwService; -#endif /* __INetFwService_FWD_DEFINED__ */ - - -#ifndef __INetFwServices_FWD_DEFINED__ -#define __INetFwServices_FWD_DEFINED__ -typedef interface INetFwServices INetFwServices; -#endif /* __INetFwServices_FWD_DEFINED__ */ - - -#ifndef __INetFwAuthorizedApplication_FWD_DEFINED__ -#define __INetFwAuthorizedApplication_FWD_DEFINED__ -typedef interface INetFwAuthorizedApplication INetFwAuthorizedApplication; -#endif /* __INetFwAuthorizedApplication_FWD_DEFINED__ */ - - -#ifndef __INetFwAuthorizedApplications_FWD_DEFINED__ -#define __INetFwAuthorizedApplications_FWD_DEFINED__ -typedef interface INetFwAuthorizedApplications INetFwAuthorizedApplications; -#endif /* __INetFwAuthorizedApplications_FWD_DEFINED__ */ - - -#ifndef __INetFwProfile_FWD_DEFINED__ -#define __INetFwProfile_FWD_DEFINED__ -typedef interface INetFwProfile INetFwProfile; -#endif /* __INetFwProfile_FWD_DEFINED__ */ - - -#ifndef __INetFwPolicy_FWD_DEFINED__ -#define __INetFwPolicy_FWD_DEFINED__ -typedef interface INetFwPolicy INetFwPolicy; -#endif /* __INetFwPolicy_FWD_DEFINED__ */ - - -#ifndef __INetFwMgr_FWD_DEFINED__ -#define __INetFwMgr_FWD_DEFINED__ -typedef interface INetFwMgr INetFwMgr; -#endif /* __INetFwMgr_FWD_DEFINED__ */ - - -#ifndef __INetFwRemoteAdminSettings_FWD_DEFINED__ -#define __INetFwRemoteAdminSettings_FWD_DEFINED__ -typedef interface INetFwRemoteAdminSettings INetFwRemoteAdminSettings; -#endif /* __INetFwRemoteAdminSettings_FWD_DEFINED__ */ - - -#ifndef __INetFwIcmpSettings_FWD_DEFINED__ -#define __INetFwIcmpSettings_FWD_DEFINED__ -typedef interface INetFwIcmpSettings INetFwIcmpSettings; -#endif /* __INetFwIcmpSettings_FWD_DEFINED__ */ - - -#ifndef __INetFwOpenPort_FWD_DEFINED__ -#define __INetFwOpenPort_FWD_DEFINED__ -typedef interface INetFwOpenPort INetFwOpenPort; -#endif /* __INetFwOpenPort_FWD_DEFINED__ */ - - -#ifndef __INetFwOpenPorts_FWD_DEFINED__ -#define __INetFwOpenPorts_FWD_DEFINED__ -typedef interface INetFwOpenPorts INetFwOpenPorts; -#endif /* __INetFwOpenPorts_FWD_DEFINED__ */ - - -#ifndef __INetFwService_FWD_DEFINED__ -#define __INetFwService_FWD_DEFINED__ -typedef interface INetFwService INetFwService; -#endif /* __INetFwService_FWD_DEFINED__ */ - - -#ifndef __INetFwServices_FWD_DEFINED__ -#define __INetFwServices_FWD_DEFINED__ -typedef interface INetFwServices INetFwServices; -#endif /* __INetFwServices_FWD_DEFINED__ */ - - -#ifndef __INetFwAuthorizedApplication_FWD_DEFINED__ -#define __INetFwAuthorizedApplication_FWD_DEFINED__ -typedef interface INetFwAuthorizedApplication INetFwAuthorizedApplication; -#endif /* __INetFwAuthorizedApplication_FWD_DEFINED__ */ - - -#ifndef __INetFwAuthorizedApplications_FWD_DEFINED__ -#define __INetFwAuthorizedApplications_FWD_DEFINED__ -typedef interface INetFwAuthorizedApplications INetFwAuthorizedApplications; -#endif /* __INetFwAuthorizedApplications_FWD_DEFINED__ */ - - -#ifndef __INetFwProfile_FWD_DEFINED__ -#define __INetFwProfile_FWD_DEFINED__ -typedef interface INetFwProfile INetFwProfile; -#endif /* __INetFwProfile_FWD_DEFINED__ */ - - -#ifndef __INetFwPolicy_FWD_DEFINED__ -#define __INetFwPolicy_FWD_DEFINED__ -typedef interface INetFwPolicy INetFwPolicy; -#endif /* __INetFwPolicy_FWD_DEFINED__ */ - - -#ifndef __INetFwMgr_FWD_DEFINED__ -#define __INetFwMgr_FWD_DEFINED__ -typedef interface INetFwMgr INetFwMgr; -#endif /* __INetFwMgr_FWD_DEFINED__ */ - - -#ifndef __NetFwOpenPort_FWD_DEFINED__ -#define __NetFwOpenPort_FWD_DEFINED__ - -#ifdef __cplusplus -typedef class NetFwOpenPort NetFwOpenPort; -#else -typedef struct NetFwOpenPort NetFwOpenPort; -#endif /* __cplusplus */ - -#endif /* __NetFwOpenPort_FWD_DEFINED__ */ - - -#ifndef __NetFwAuthorizedApplication_FWD_DEFINED__ -#define __NetFwAuthorizedApplication_FWD_DEFINED__ - -#ifdef __cplusplus -typedef class NetFwAuthorizedApplication NetFwAuthorizedApplication; -#else -typedef struct NetFwAuthorizedApplication NetFwAuthorizedApplication; -#endif /* __cplusplus */ - -#endif /* __NetFwAuthorizedApplication_FWD_DEFINED__ */ - - -#ifndef __NetFwMgr_FWD_DEFINED__ -#define __NetFwMgr_FWD_DEFINED__ - -#ifdef __cplusplus -typedef class NetFwMgr NetFwMgr; -#else -typedef struct NetFwMgr NetFwMgr; -#endif /* __cplusplus */ - -#endif /* __NetFwMgr_FWD_DEFINED__ */ - - -/* header files for imported files */ -#include "icftypes.h" -#include "oaidl.h" - -#ifdef __cplusplus -extern "C"{ -#endif - -void * __RPC_USER MIDL_user_allocate(size_t); -void __RPC_USER MIDL_user_free( void * ); - -#ifndef __INetFwRemoteAdminSettings_INTERFACE_DEFINED__ -#define __INetFwRemoteAdminSettings_INTERFACE_DEFINED__ - -/* interface INetFwRemoteAdminSettings */ -/* [dual][uuid][object] */ - - -EXTERN_C const IID IID_INetFwRemoteAdminSettings; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("D4BECDDF-6F73-4A83-B832-9C66874CD20E") - INetFwRemoteAdminSettings : public IDispatch - { - public: - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_IpVersion( - /* [retval][out] */ NET_FW_IP_VERSION *ipVersion) = 0; - - virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_IpVersion( - /* [in] */ NET_FW_IP_VERSION ipVersion) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_Scope( - /* [retval][out] */ NET_FW_SCOPE *scope) = 0; - - virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_Scope( - /* [in] */ NET_FW_SCOPE scope) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_RemoteAddresses( - /* [retval][out] */ BSTR *remoteAddrs) = 0; - - virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_RemoteAddresses( - /* [in] */ BSTR remoteAddrs) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_Enabled( - /* [retval][out] */ VARIANT_BOOL *enabled) = 0; - - virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_Enabled( - /* [in] */ VARIANT_BOOL enabled) = 0; - - }; - -#else /* C style interface */ - - typedef struct INetFwRemoteAdminSettingsVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - INetFwRemoteAdminSettings * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - INetFwRemoteAdminSettings * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - INetFwRemoteAdminSettings * This); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( - INetFwRemoteAdminSettings * This, - /* [out] */ UINT *pctinfo); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( - INetFwRemoteAdminSettings * This, - /* [in] */ UINT iTInfo, - /* [in] */ LCID lcid, - /* [out] */ ITypeInfo **ppTInfo); - - HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( - INetFwRemoteAdminSettings * This, - /* [in] */ REFIID riid, - /* [size_is][in] */ LPOLESTR *rgszNames, - /* [in] */ UINT cNames, - /* [in] */ LCID lcid, - /* [size_is][out] */ DISPID *rgDispId); - - /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( - INetFwRemoteAdminSettings * This, - /* [in] */ DISPID dispIdMember, - /* [in] */ REFIID riid, - /* [in] */ LCID lcid, - /* [in] */ WORD wFlags, - /* [out][in] */ DISPPARAMS *pDispParams, - /* [out] */ VARIANT *pVarResult, - /* [out] */ EXCEPINFO *pExcepInfo, - /* [out] */ UINT *puArgErr); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_IpVersion )( - INetFwRemoteAdminSettings * This, - /* [retval][out] */ NET_FW_IP_VERSION *ipVersion); - - /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE *put_IpVersion )( - INetFwRemoteAdminSettings * This, - /* [in] */ NET_FW_IP_VERSION ipVersion); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_Scope )( - INetFwRemoteAdminSettings * This, - /* [retval][out] */ NET_FW_SCOPE *scope); - - /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE *put_Scope )( - INetFwRemoteAdminSettings * This, - /* [in] */ NET_FW_SCOPE scope); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_RemoteAddresses )( - INetFwRemoteAdminSettings * This, - /* [retval][out] */ BSTR *remoteAddrs); - - /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE *put_RemoteAddresses )( - INetFwRemoteAdminSettings * This, - /* [in] */ BSTR remoteAddrs); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_Enabled )( - INetFwRemoteAdminSettings * This, - /* [retval][out] */ VARIANT_BOOL *enabled); - - /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE *put_Enabled )( - INetFwRemoteAdminSettings * This, - /* [in] */ VARIANT_BOOL enabled); - - END_INTERFACE - } INetFwRemoteAdminSettingsVtbl; - - interface INetFwRemoteAdminSettings - { - CONST_VTBL struct INetFwRemoteAdminSettingsVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define INetFwRemoteAdminSettings_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define INetFwRemoteAdminSettings_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define INetFwRemoteAdminSettings_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define INetFwRemoteAdminSettings_GetTypeInfoCount(This,pctinfo) \ - (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) - -#define INetFwRemoteAdminSettings_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ - (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) - -#define INetFwRemoteAdminSettings_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ - (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) - -#define INetFwRemoteAdminSettings_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ - (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) - - -#define INetFwRemoteAdminSettings_get_IpVersion(This,ipVersion) \ - (This)->lpVtbl -> get_IpVersion(This,ipVersion) - -#define INetFwRemoteAdminSettings_put_IpVersion(This,ipVersion) \ - (This)->lpVtbl -> put_IpVersion(This,ipVersion) - -#define INetFwRemoteAdminSettings_get_Scope(This,scope) \ - (This)->lpVtbl -> get_Scope(This,scope) - -#define INetFwRemoteAdminSettings_put_Scope(This,scope) \ - (This)->lpVtbl -> put_Scope(This,scope) - -#define INetFwRemoteAdminSettings_get_RemoteAddresses(This,remoteAddrs) \ - (This)->lpVtbl -> get_RemoteAddresses(This,remoteAddrs) - -#define INetFwRemoteAdminSettings_put_RemoteAddresses(This,remoteAddrs) \ - (This)->lpVtbl -> put_RemoteAddresses(This,remoteAddrs) - -#define INetFwRemoteAdminSettings_get_Enabled(This,enabled) \ - (This)->lpVtbl -> get_Enabled(This,enabled) - -#define INetFwRemoteAdminSettings_put_Enabled(This,enabled) \ - (This)->lpVtbl -> put_Enabled(This,enabled) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwRemoteAdminSettings_get_IpVersion_Proxy( - INetFwRemoteAdminSettings * This, - /* [retval][out] */ NET_FW_IP_VERSION *ipVersion); - - -void __RPC_STUB INetFwRemoteAdminSettings_get_IpVersion_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput][id] */ HRESULT STDMETHODCALLTYPE INetFwRemoteAdminSettings_put_IpVersion_Proxy( - INetFwRemoteAdminSettings * This, - /* [in] */ NET_FW_IP_VERSION ipVersion); - - -void __RPC_STUB INetFwRemoteAdminSettings_put_IpVersion_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwRemoteAdminSettings_get_Scope_Proxy( - INetFwRemoteAdminSettings * This, - /* [retval][out] */ NET_FW_SCOPE *scope); - - -void __RPC_STUB INetFwRemoteAdminSettings_get_Scope_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput][id] */ HRESULT STDMETHODCALLTYPE INetFwRemoteAdminSettings_put_Scope_Proxy( - INetFwRemoteAdminSettings * This, - /* [in] */ NET_FW_SCOPE scope); - - -void __RPC_STUB INetFwRemoteAdminSettings_put_Scope_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwRemoteAdminSettings_get_RemoteAddresses_Proxy( - INetFwRemoteAdminSettings * This, - /* [retval][out] */ BSTR *remoteAddrs); - - -void __RPC_STUB INetFwRemoteAdminSettings_get_RemoteAddresses_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput][id] */ HRESULT STDMETHODCALLTYPE INetFwRemoteAdminSettings_put_RemoteAddresses_Proxy( - INetFwRemoteAdminSettings * This, - /* [in] */ BSTR remoteAddrs); - - -void __RPC_STUB INetFwRemoteAdminSettings_put_RemoteAddresses_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwRemoteAdminSettings_get_Enabled_Proxy( - INetFwRemoteAdminSettings * This, - /* [retval][out] */ VARIANT_BOOL *enabled); - - -void __RPC_STUB INetFwRemoteAdminSettings_get_Enabled_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput][id] */ HRESULT STDMETHODCALLTYPE INetFwRemoteAdminSettings_put_Enabled_Proxy( - INetFwRemoteAdminSettings * This, - /* [in] */ VARIANT_BOOL enabled); - - -void __RPC_STUB INetFwRemoteAdminSettings_put_Enabled_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __INetFwRemoteAdminSettings_INTERFACE_DEFINED__ */ - - -#ifndef __INetFwIcmpSettings_INTERFACE_DEFINED__ -#define __INetFwIcmpSettings_INTERFACE_DEFINED__ - -/* interface INetFwIcmpSettings */ -/* [dual][uuid][object] */ - - -EXTERN_C const IID IID_INetFwIcmpSettings; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("A6207B2E-7CDD-426A-951E-5E1CBC5AFEAD") - INetFwIcmpSettings : public IDispatch - { - public: - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_AllowOutboundDestinationUnreachable( - /* [retval][out] */ VARIANT_BOOL *allow) = 0; - - virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_AllowOutboundDestinationUnreachable( - /* [in] */ VARIANT_BOOL allow) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_AllowRedirect( - /* [retval][out] */ VARIANT_BOOL *allow) = 0; - - virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_AllowRedirect( - /* [in] */ VARIANT_BOOL allow) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_AllowInboundEchoRequest( - /* [retval][out] */ VARIANT_BOOL *allow) = 0; - - virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_AllowInboundEchoRequest( - /* [in] */ VARIANT_BOOL allow) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_AllowOutboundTimeExceeded( - /* [retval][out] */ VARIANT_BOOL *allow) = 0; - - virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_AllowOutboundTimeExceeded( - /* [in] */ VARIANT_BOOL allow) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_AllowOutboundParameterProblem( - /* [retval][out] */ VARIANT_BOOL *allow) = 0; - - virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_AllowOutboundParameterProblem( - /* [in] */ VARIANT_BOOL allow) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_AllowOutboundSourceQuench( - /* [retval][out] */ VARIANT_BOOL *allow) = 0; - - virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_AllowOutboundSourceQuench( - /* [in] */ VARIANT_BOOL allow) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_AllowInboundRouterRequest( - /* [retval][out] */ VARIANT_BOOL *allow) = 0; - - virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_AllowInboundRouterRequest( - /* [in] */ VARIANT_BOOL allow) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_AllowInboundTimestampRequest( - /* [retval][out] */ VARIANT_BOOL *allow) = 0; - - virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_AllowInboundTimestampRequest( - /* [in] */ VARIANT_BOOL allow) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_AllowInboundMaskRequest( - /* [retval][out] */ VARIANT_BOOL *allow) = 0; - - virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_AllowInboundMaskRequest( - /* [in] */ VARIANT_BOOL allow) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_AllowOutboundPacketTooBig( - /* [retval][out] */ VARIANT_BOOL *allow) = 0; - - virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_AllowOutboundPacketTooBig( - /* [in] */ VARIANT_BOOL allow) = 0; - - }; - -#else /* C style interface */ - - typedef struct INetFwIcmpSettingsVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - INetFwIcmpSettings * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - INetFwIcmpSettings * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - INetFwIcmpSettings * This); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( - INetFwIcmpSettings * This, - /* [out] */ UINT *pctinfo); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( - INetFwIcmpSettings * This, - /* [in] */ UINT iTInfo, - /* [in] */ LCID lcid, - /* [out] */ ITypeInfo **ppTInfo); - - HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( - INetFwIcmpSettings * This, - /* [in] */ REFIID riid, - /* [size_is][in] */ LPOLESTR *rgszNames, - /* [in] */ UINT cNames, - /* [in] */ LCID lcid, - /* [size_is][out] */ DISPID *rgDispId); - - /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( - INetFwIcmpSettings * This, - /* [in] */ DISPID dispIdMember, - /* [in] */ REFIID riid, - /* [in] */ LCID lcid, - /* [in] */ WORD wFlags, - /* [out][in] */ DISPPARAMS *pDispParams, - /* [out] */ VARIANT *pVarResult, - /* [out] */ EXCEPINFO *pExcepInfo, - /* [out] */ UINT *puArgErr); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_AllowOutboundDestinationUnreachable )( - INetFwIcmpSettings * This, - /* [retval][out] */ VARIANT_BOOL *allow); - - /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE *put_AllowOutboundDestinationUnreachable )( - INetFwIcmpSettings * This, - /* [in] */ VARIANT_BOOL allow); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_AllowRedirect )( - INetFwIcmpSettings * This, - /* [retval][out] */ VARIANT_BOOL *allow); - - /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE *put_AllowRedirect )( - INetFwIcmpSettings * This, - /* [in] */ VARIANT_BOOL allow); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_AllowInboundEchoRequest )( - INetFwIcmpSettings * This, - /* [retval][out] */ VARIANT_BOOL *allow); - - /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE *put_AllowInboundEchoRequest )( - INetFwIcmpSettings * This, - /* [in] */ VARIANT_BOOL allow); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_AllowOutboundTimeExceeded )( - INetFwIcmpSettings * This, - /* [retval][out] */ VARIANT_BOOL *allow); - - /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE *put_AllowOutboundTimeExceeded )( - INetFwIcmpSettings * This, - /* [in] */ VARIANT_BOOL allow); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_AllowOutboundParameterProblem )( - INetFwIcmpSettings * This, - /* [retval][out] */ VARIANT_BOOL *allow); - - /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE *put_AllowOutboundParameterProblem )( - INetFwIcmpSettings * This, - /* [in] */ VARIANT_BOOL allow); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_AllowOutboundSourceQuench )( - INetFwIcmpSettings * This, - /* [retval][out] */ VARIANT_BOOL *allow); - - /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE *put_AllowOutboundSourceQuench )( - INetFwIcmpSettings * This, - /* [in] */ VARIANT_BOOL allow); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_AllowInboundRouterRequest )( - INetFwIcmpSettings * This, - /* [retval][out] */ VARIANT_BOOL *allow); - - /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE *put_AllowInboundRouterRequest )( - INetFwIcmpSettings * This, - /* [in] */ VARIANT_BOOL allow); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_AllowInboundTimestampRequest )( - INetFwIcmpSettings * This, - /* [retval][out] */ VARIANT_BOOL *allow); - - /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE *put_AllowInboundTimestampRequest )( - INetFwIcmpSettings * This, - /* [in] */ VARIANT_BOOL allow); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_AllowInboundMaskRequest )( - INetFwIcmpSettings * This, - /* [retval][out] */ VARIANT_BOOL *allow); - - /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE *put_AllowInboundMaskRequest )( - INetFwIcmpSettings * This, - /* [in] */ VARIANT_BOOL allow); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_AllowOutboundPacketTooBig )( - INetFwIcmpSettings * This, - /* [retval][out] */ VARIANT_BOOL *allow); - - /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE *put_AllowOutboundPacketTooBig )( - INetFwIcmpSettings * This, - /* [in] */ VARIANT_BOOL allow); - - END_INTERFACE - } INetFwIcmpSettingsVtbl; - - interface INetFwIcmpSettings - { - CONST_VTBL struct INetFwIcmpSettingsVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define INetFwIcmpSettings_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define INetFwIcmpSettings_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define INetFwIcmpSettings_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define INetFwIcmpSettings_GetTypeInfoCount(This,pctinfo) \ - (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) - -#define INetFwIcmpSettings_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ - (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) - -#define INetFwIcmpSettings_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ - (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) - -#define INetFwIcmpSettings_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ - (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) - - -#define INetFwIcmpSettings_get_AllowOutboundDestinationUnreachable(This,allow) \ - (This)->lpVtbl -> get_AllowOutboundDestinationUnreachable(This,allow) - -#define INetFwIcmpSettings_put_AllowOutboundDestinationUnreachable(This,allow) \ - (This)->lpVtbl -> put_AllowOutboundDestinationUnreachable(This,allow) - -#define INetFwIcmpSettings_get_AllowRedirect(This,allow) \ - (This)->lpVtbl -> get_AllowRedirect(This,allow) - -#define INetFwIcmpSettings_put_AllowRedirect(This,allow) \ - (This)->lpVtbl -> put_AllowRedirect(This,allow) - -#define INetFwIcmpSettings_get_AllowInboundEchoRequest(This,allow) \ - (This)->lpVtbl -> get_AllowInboundEchoRequest(This,allow) - -#define INetFwIcmpSettings_put_AllowInboundEchoRequest(This,allow) \ - (This)->lpVtbl -> put_AllowInboundEchoRequest(This,allow) - -#define INetFwIcmpSettings_get_AllowOutboundTimeExceeded(This,allow) \ - (This)->lpVtbl -> get_AllowOutboundTimeExceeded(This,allow) - -#define INetFwIcmpSettings_put_AllowOutboundTimeExceeded(This,allow) \ - (This)->lpVtbl -> put_AllowOutboundTimeExceeded(This,allow) - -#define INetFwIcmpSettings_get_AllowOutboundParameterProblem(This,allow) \ - (This)->lpVtbl -> get_AllowOutboundParameterProblem(This,allow) - -#define INetFwIcmpSettings_put_AllowOutboundParameterProblem(This,allow) \ - (This)->lpVtbl -> put_AllowOutboundParameterProblem(This,allow) - -#define INetFwIcmpSettings_get_AllowOutboundSourceQuench(This,allow) \ - (This)->lpVtbl -> get_AllowOutboundSourceQuench(This,allow) - -#define INetFwIcmpSettings_put_AllowOutboundSourceQuench(This,allow) \ - (This)->lpVtbl -> put_AllowOutboundSourceQuench(This,allow) - -#define INetFwIcmpSettings_get_AllowInboundRouterRequest(This,allow) \ - (This)->lpVtbl -> get_AllowInboundRouterRequest(This,allow) - -#define INetFwIcmpSettings_put_AllowInboundRouterRequest(This,allow) \ - (This)->lpVtbl -> put_AllowInboundRouterRequest(This,allow) - -#define INetFwIcmpSettings_get_AllowInboundTimestampRequest(This,allow) \ - (This)->lpVtbl -> get_AllowInboundTimestampRequest(This,allow) - -#define INetFwIcmpSettings_put_AllowInboundTimestampRequest(This,allow) \ - (This)->lpVtbl -> put_AllowInboundTimestampRequest(This,allow) - -#define INetFwIcmpSettings_get_AllowInboundMaskRequest(This,allow) \ - (This)->lpVtbl -> get_AllowInboundMaskRequest(This,allow) - -#define INetFwIcmpSettings_put_AllowInboundMaskRequest(This,allow) \ - (This)->lpVtbl -> put_AllowInboundMaskRequest(This,allow) - -#define INetFwIcmpSettings_get_AllowOutboundPacketTooBig(This,allow) \ - (This)->lpVtbl -> get_AllowOutboundPacketTooBig(This,allow) - -#define INetFwIcmpSettings_put_AllowOutboundPacketTooBig(This,allow) \ - (This)->lpVtbl -> put_AllowOutboundPacketTooBig(This,allow) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwIcmpSettings_get_AllowOutboundDestinationUnreachable_Proxy( - INetFwIcmpSettings * This, - /* [retval][out] */ VARIANT_BOOL *allow); - - -void __RPC_STUB INetFwIcmpSettings_get_AllowOutboundDestinationUnreachable_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput][id] */ HRESULT STDMETHODCALLTYPE INetFwIcmpSettings_put_AllowOutboundDestinationUnreachable_Proxy( - INetFwIcmpSettings * This, - /* [in] */ VARIANT_BOOL allow); - - -void __RPC_STUB INetFwIcmpSettings_put_AllowOutboundDestinationUnreachable_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwIcmpSettings_get_AllowRedirect_Proxy( - INetFwIcmpSettings * This, - /* [retval][out] */ VARIANT_BOOL *allow); - - -void __RPC_STUB INetFwIcmpSettings_get_AllowRedirect_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput][id] */ HRESULT STDMETHODCALLTYPE INetFwIcmpSettings_put_AllowRedirect_Proxy( - INetFwIcmpSettings * This, - /* [in] */ VARIANT_BOOL allow); - - -void __RPC_STUB INetFwIcmpSettings_put_AllowRedirect_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwIcmpSettings_get_AllowInboundEchoRequest_Proxy( - INetFwIcmpSettings * This, - /* [retval][out] */ VARIANT_BOOL *allow); - - -void __RPC_STUB INetFwIcmpSettings_get_AllowInboundEchoRequest_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput][id] */ HRESULT STDMETHODCALLTYPE INetFwIcmpSettings_put_AllowInboundEchoRequest_Proxy( - INetFwIcmpSettings * This, - /* [in] */ VARIANT_BOOL allow); - - -void __RPC_STUB INetFwIcmpSettings_put_AllowInboundEchoRequest_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwIcmpSettings_get_AllowOutboundTimeExceeded_Proxy( - INetFwIcmpSettings * This, - /* [retval][out] */ VARIANT_BOOL *allow); - - -void __RPC_STUB INetFwIcmpSettings_get_AllowOutboundTimeExceeded_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput][id] */ HRESULT STDMETHODCALLTYPE INetFwIcmpSettings_put_AllowOutboundTimeExceeded_Proxy( - INetFwIcmpSettings * This, - /* [in] */ VARIANT_BOOL allow); - - -void __RPC_STUB INetFwIcmpSettings_put_AllowOutboundTimeExceeded_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwIcmpSettings_get_AllowOutboundParameterProblem_Proxy( - INetFwIcmpSettings * This, - /* [retval][out] */ VARIANT_BOOL *allow); - - -void __RPC_STUB INetFwIcmpSettings_get_AllowOutboundParameterProblem_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput][id] */ HRESULT STDMETHODCALLTYPE INetFwIcmpSettings_put_AllowOutboundParameterProblem_Proxy( - INetFwIcmpSettings * This, - /* [in] */ VARIANT_BOOL allow); - - -void __RPC_STUB INetFwIcmpSettings_put_AllowOutboundParameterProblem_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwIcmpSettings_get_AllowOutboundSourceQuench_Proxy( - INetFwIcmpSettings * This, - /* [retval][out] */ VARIANT_BOOL *allow); - - -void __RPC_STUB INetFwIcmpSettings_get_AllowOutboundSourceQuench_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput][id] */ HRESULT STDMETHODCALLTYPE INetFwIcmpSettings_put_AllowOutboundSourceQuench_Proxy( - INetFwIcmpSettings * This, - /* [in] */ VARIANT_BOOL allow); - - -void __RPC_STUB INetFwIcmpSettings_put_AllowOutboundSourceQuench_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwIcmpSettings_get_AllowInboundRouterRequest_Proxy( - INetFwIcmpSettings * This, - /* [retval][out] */ VARIANT_BOOL *allow); - - -void __RPC_STUB INetFwIcmpSettings_get_AllowInboundRouterRequest_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput][id] */ HRESULT STDMETHODCALLTYPE INetFwIcmpSettings_put_AllowInboundRouterRequest_Proxy( - INetFwIcmpSettings * This, - /* [in] */ VARIANT_BOOL allow); - - -void __RPC_STUB INetFwIcmpSettings_put_AllowInboundRouterRequest_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwIcmpSettings_get_AllowInboundTimestampRequest_Proxy( - INetFwIcmpSettings * This, - /* [retval][out] */ VARIANT_BOOL *allow); - - -void __RPC_STUB INetFwIcmpSettings_get_AllowInboundTimestampRequest_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput][id] */ HRESULT STDMETHODCALLTYPE INetFwIcmpSettings_put_AllowInboundTimestampRequest_Proxy( - INetFwIcmpSettings * This, - /* [in] */ VARIANT_BOOL allow); - - -void __RPC_STUB INetFwIcmpSettings_put_AllowInboundTimestampRequest_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwIcmpSettings_get_AllowInboundMaskRequest_Proxy( - INetFwIcmpSettings * This, - /* [retval][out] */ VARIANT_BOOL *allow); - - -void __RPC_STUB INetFwIcmpSettings_get_AllowInboundMaskRequest_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput][id] */ HRESULT STDMETHODCALLTYPE INetFwIcmpSettings_put_AllowInboundMaskRequest_Proxy( - INetFwIcmpSettings * This, - /* [in] */ VARIANT_BOOL allow); - - -void __RPC_STUB INetFwIcmpSettings_put_AllowInboundMaskRequest_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwIcmpSettings_get_AllowOutboundPacketTooBig_Proxy( - INetFwIcmpSettings * This, - /* [retval][out] */ VARIANT_BOOL *allow); - - -void __RPC_STUB INetFwIcmpSettings_get_AllowOutboundPacketTooBig_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput][id] */ HRESULT STDMETHODCALLTYPE INetFwIcmpSettings_put_AllowOutboundPacketTooBig_Proxy( - INetFwIcmpSettings * This, - /* [in] */ VARIANT_BOOL allow); - - -void __RPC_STUB INetFwIcmpSettings_put_AllowOutboundPacketTooBig_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __INetFwIcmpSettings_INTERFACE_DEFINED__ */ - - -#ifndef __INetFwOpenPort_INTERFACE_DEFINED__ -#define __INetFwOpenPort_INTERFACE_DEFINED__ - -/* interface INetFwOpenPort */ -/* [dual][uuid][object] */ - - -EXTERN_C const IID IID_INetFwOpenPort; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("E0483BA0-47FF-4D9C-A6D6-7741D0B195F7") - INetFwOpenPort : public IDispatch - { - public: - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_Name( - /* [retval][out] */ BSTR *name) = 0; - - virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_Name( - /* [in] */ BSTR name) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_IpVersion( - /* [retval][out] */ NET_FW_IP_VERSION *ipVersion) = 0; - - virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_IpVersion( - /* [in] */ NET_FW_IP_VERSION ipVersion) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_Protocol( - /* [retval][out] */ NET_FW_IP_PROTOCOL *ipProtocol) = 0; - - virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_Protocol( - /* [in] */ NET_FW_IP_PROTOCOL ipProtocol) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_Port( - /* [retval][out] */ LONG *portNumber) = 0; - - virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_Port( - /* [in] */ LONG portNumber) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_Scope( - /* [retval][out] */ NET_FW_SCOPE *scope) = 0; - - virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_Scope( - /* [in] */ NET_FW_SCOPE scope) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_RemoteAddresses( - /* [retval][out] */ BSTR *remoteAddrs) = 0; - - virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_RemoteAddresses( - /* [in] */ BSTR remoteAddrs) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_Enabled( - /* [retval][out] */ VARIANT_BOOL *enabled) = 0; - - virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_Enabled( - /* [in] */ VARIANT_BOOL enabled) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_BuiltIn( - /* [retval][out] */ VARIANT_BOOL *builtIn) = 0; - - }; - -#else /* C style interface */ - - typedef struct INetFwOpenPortVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - INetFwOpenPort * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - INetFwOpenPort * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - INetFwOpenPort * This); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( - INetFwOpenPort * This, - /* [out] */ UINT *pctinfo); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( - INetFwOpenPort * This, - /* [in] */ UINT iTInfo, - /* [in] */ LCID lcid, - /* [out] */ ITypeInfo **ppTInfo); - - HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( - INetFwOpenPort * This, - /* [in] */ REFIID riid, - /* [size_is][in] */ LPOLESTR *rgszNames, - /* [in] */ UINT cNames, - /* [in] */ LCID lcid, - /* [size_is][out] */ DISPID *rgDispId); - - /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( - INetFwOpenPort * This, - /* [in] */ DISPID dispIdMember, - /* [in] */ REFIID riid, - /* [in] */ LCID lcid, - /* [in] */ WORD wFlags, - /* [out][in] */ DISPPARAMS *pDispParams, - /* [out] */ VARIANT *pVarResult, - /* [out] */ EXCEPINFO *pExcepInfo, - /* [out] */ UINT *puArgErr); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_Name )( - INetFwOpenPort * This, - /* [retval][out] */ BSTR *name); - - /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE *put_Name )( - INetFwOpenPort * This, - /* [in] */ BSTR name); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_IpVersion )( - INetFwOpenPort * This, - /* [retval][out] */ NET_FW_IP_VERSION *ipVersion); - - /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE *put_IpVersion )( - INetFwOpenPort * This, - /* [in] */ NET_FW_IP_VERSION ipVersion); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_Protocol )( - INetFwOpenPort * This, - /* [retval][out] */ NET_FW_IP_PROTOCOL *ipProtocol); - - /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE *put_Protocol )( - INetFwOpenPort * This, - /* [in] */ NET_FW_IP_PROTOCOL ipProtocol); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_Port )( - INetFwOpenPort * This, - /* [retval][out] */ LONG *portNumber); - - /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE *put_Port )( - INetFwOpenPort * This, - /* [in] */ LONG portNumber); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_Scope )( - INetFwOpenPort * This, - /* [retval][out] */ NET_FW_SCOPE *scope); - - /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE *put_Scope )( - INetFwOpenPort * This, - /* [in] */ NET_FW_SCOPE scope); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_RemoteAddresses )( - INetFwOpenPort * This, - /* [retval][out] */ BSTR *remoteAddrs); - - /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE *put_RemoteAddresses )( - INetFwOpenPort * This, - /* [in] */ BSTR remoteAddrs); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_Enabled )( - INetFwOpenPort * This, - /* [retval][out] */ VARIANT_BOOL *enabled); - - /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE *put_Enabled )( - INetFwOpenPort * This, - /* [in] */ VARIANT_BOOL enabled); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_BuiltIn )( - INetFwOpenPort * This, - /* [retval][out] */ VARIANT_BOOL *builtIn); - - END_INTERFACE - } INetFwOpenPortVtbl; - - interface INetFwOpenPort - { - CONST_VTBL struct INetFwOpenPortVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define INetFwOpenPort_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define INetFwOpenPort_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define INetFwOpenPort_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define INetFwOpenPort_GetTypeInfoCount(This,pctinfo) \ - (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) - -#define INetFwOpenPort_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ - (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) - -#define INetFwOpenPort_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ - (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) - -#define INetFwOpenPort_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ - (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) - - -#define INetFwOpenPort_get_Name(This,name) \ - (This)->lpVtbl -> get_Name(This,name) - -#define INetFwOpenPort_put_Name(This,name) \ - (This)->lpVtbl -> put_Name(This,name) - -#define INetFwOpenPort_get_IpVersion(This,ipVersion) \ - (This)->lpVtbl -> get_IpVersion(This,ipVersion) - -#define INetFwOpenPort_put_IpVersion(This,ipVersion) \ - (This)->lpVtbl -> put_IpVersion(This,ipVersion) - -#define INetFwOpenPort_get_Protocol(This,ipProtocol) \ - (This)->lpVtbl -> get_Protocol(This,ipProtocol) - -#define INetFwOpenPort_put_Protocol(This,ipProtocol) \ - (This)->lpVtbl -> put_Protocol(This,ipProtocol) - -#define INetFwOpenPort_get_Port(This,portNumber) \ - (This)->lpVtbl -> get_Port(This,portNumber) - -#define INetFwOpenPort_put_Port(This,portNumber) \ - (This)->lpVtbl -> put_Port(This,portNumber) - -#define INetFwOpenPort_get_Scope(This,scope) \ - (This)->lpVtbl -> get_Scope(This,scope) - -#define INetFwOpenPort_put_Scope(This,scope) \ - (This)->lpVtbl -> put_Scope(This,scope) - -#define INetFwOpenPort_get_RemoteAddresses(This,remoteAddrs) \ - (This)->lpVtbl -> get_RemoteAddresses(This,remoteAddrs) - -#define INetFwOpenPort_put_RemoteAddresses(This,remoteAddrs) \ - (This)->lpVtbl -> put_RemoteAddresses(This,remoteAddrs) - -#define INetFwOpenPort_get_Enabled(This,enabled) \ - (This)->lpVtbl -> get_Enabled(This,enabled) - -#define INetFwOpenPort_put_Enabled(This,enabled) \ - (This)->lpVtbl -> put_Enabled(This,enabled) - -#define INetFwOpenPort_get_BuiltIn(This,builtIn) \ - (This)->lpVtbl -> get_BuiltIn(This,builtIn) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwOpenPort_get_Name_Proxy( - INetFwOpenPort * This, - /* [retval][out] */ BSTR *name); - - -void __RPC_STUB INetFwOpenPort_get_Name_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput][id] */ HRESULT STDMETHODCALLTYPE INetFwOpenPort_put_Name_Proxy( - INetFwOpenPort * This, - /* [in] */ BSTR name); - - -void __RPC_STUB INetFwOpenPort_put_Name_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwOpenPort_get_IpVersion_Proxy( - INetFwOpenPort * This, - /* [retval][out] */ NET_FW_IP_VERSION *ipVersion); - - -void __RPC_STUB INetFwOpenPort_get_IpVersion_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput][id] */ HRESULT STDMETHODCALLTYPE INetFwOpenPort_put_IpVersion_Proxy( - INetFwOpenPort * This, - /* [in] */ NET_FW_IP_VERSION ipVersion); - - -void __RPC_STUB INetFwOpenPort_put_IpVersion_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwOpenPort_get_Protocol_Proxy( - INetFwOpenPort * This, - /* [retval][out] */ NET_FW_IP_PROTOCOL *ipProtocol); - - -void __RPC_STUB INetFwOpenPort_get_Protocol_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput][id] */ HRESULT STDMETHODCALLTYPE INetFwOpenPort_put_Protocol_Proxy( - INetFwOpenPort * This, - /* [in] */ NET_FW_IP_PROTOCOL ipProtocol); - - -void __RPC_STUB INetFwOpenPort_put_Protocol_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwOpenPort_get_Port_Proxy( - INetFwOpenPort * This, - /* [retval][out] */ LONG *portNumber); - - -void __RPC_STUB INetFwOpenPort_get_Port_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput][id] */ HRESULT STDMETHODCALLTYPE INetFwOpenPort_put_Port_Proxy( - INetFwOpenPort * This, - /* [in] */ LONG portNumber); - - -void __RPC_STUB INetFwOpenPort_put_Port_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwOpenPort_get_Scope_Proxy( - INetFwOpenPort * This, - /* [retval][out] */ NET_FW_SCOPE *scope); - - -void __RPC_STUB INetFwOpenPort_get_Scope_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput][id] */ HRESULT STDMETHODCALLTYPE INetFwOpenPort_put_Scope_Proxy( - INetFwOpenPort * This, - /* [in] */ NET_FW_SCOPE scope); - - -void __RPC_STUB INetFwOpenPort_put_Scope_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwOpenPort_get_RemoteAddresses_Proxy( - INetFwOpenPort * This, - /* [retval][out] */ BSTR *remoteAddrs); - - -void __RPC_STUB INetFwOpenPort_get_RemoteAddresses_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput][id] */ HRESULT STDMETHODCALLTYPE INetFwOpenPort_put_RemoteAddresses_Proxy( - INetFwOpenPort * This, - /* [in] */ BSTR remoteAddrs); - - -void __RPC_STUB INetFwOpenPort_put_RemoteAddresses_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwOpenPort_get_Enabled_Proxy( - INetFwOpenPort * This, - /* [retval][out] */ VARIANT_BOOL *enabled); - - -void __RPC_STUB INetFwOpenPort_get_Enabled_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput][id] */ HRESULT STDMETHODCALLTYPE INetFwOpenPort_put_Enabled_Proxy( - INetFwOpenPort * This, - /* [in] */ VARIANT_BOOL enabled); - - -void __RPC_STUB INetFwOpenPort_put_Enabled_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwOpenPort_get_BuiltIn_Proxy( - INetFwOpenPort * This, - /* [retval][out] */ VARIANT_BOOL *builtIn); - - -void __RPC_STUB INetFwOpenPort_get_BuiltIn_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __INetFwOpenPort_INTERFACE_DEFINED__ */ - - -#ifndef __INetFwOpenPorts_INTERFACE_DEFINED__ -#define __INetFwOpenPorts_INTERFACE_DEFINED__ - -/* interface INetFwOpenPorts */ -/* [dual][uuid][object] */ - - -EXTERN_C const IID IID_INetFwOpenPorts; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("C0E9D7FA-E07E-430A-B19A-090CE82D92E2") - INetFwOpenPorts : public IDispatch - { - public: - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_Count( - /* [retval][out] */ long *count) = 0; - - virtual /* [id] */ HRESULT STDMETHODCALLTYPE Add( - /* [in] */ INetFwOpenPort *port) = 0; - - virtual /* [id] */ HRESULT STDMETHODCALLTYPE Remove( - /* [in] */ LONG portNumber, - /* [in] */ NET_FW_IP_PROTOCOL ipProtocol) = 0; - - virtual /* [id] */ HRESULT STDMETHODCALLTYPE Item( - /* [in] */ LONG portNumber, - /* [in] */ NET_FW_IP_PROTOCOL ipProtocol, - /* [retval][out] */ INetFwOpenPort **openPort) = 0; - - virtual /* [restricted][propget][id] */ HRESULT STDMETHODCALLTYPE get__NewEnum( - /* [retval][out] */ IUnknown **newEnum) = 0; - - }; - -#else /* C style interface */ - - typedef struct INetFwOpenPortsVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - INetFwOpenPorts * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - INetFwOpenPorts * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - INetFwOpenPorts * This); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( - INetFwOpenPorts * This, - /* [out] */ UINT *pctinfo); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( - INetFwOpenPorts * This, - /* [in] */ UINT iTInfo, - /* [in] */ LCID lcid, - /* [out] */ ITypeInfo **ppTInfo); - - HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( - INetFwOpenPorts * This, - /* [in] */ REFIID riid, - /* [size_is][in] */ LPOLESTR *rgszNames, - /* [in] */ UINT cNames, - /* [in] */ LCID lcid, - /* [size_is][out] */ DISPID *rgDispId); - - /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( - INetFwOpenPorts * This, - /* [in] */ DISPID dispIdMember, - /* [in] */ REFIID riid, - /* [in] */ LCID lcid, - /* [in] */ WORD wFlags, - /* [out][in] */ DISPPARAMS *pDispParams, - /* [out] */ VARIANT *pVarResult, - /* [out] */ EXCEPINFO *pExcepInfo, - /* [out] */ UINT *puArgErr); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_Count )( - INetFwOpenPorts * This, - /* [retval][out] */ long *count); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *Add )( - INetFwOpenPorts * This, - /* [in] */ INetFwOpenPort *port); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *Remove )( - INetFwOpenPorts * This, - /* [in] */ LONG portNumber, - /* [in] */ NET_FW_IP_PROTOCOL ipProtocol); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *Item )( - INetFwOpenPorts * This, - /* [in] */ LONG portNumber, - /* [in] */ NET_FW_IP_PROTOCOL ipProtocol, - /* [retval][out] */ INetFwOpenPort **openPort); - - /* [restricted][propget][id] */ HRESULT ( STDMETHODCALLTYPE *get__NewEnum )( - INetFwOpenPorts * This, - /* [retval][out] */ IUnknown **newEnum); - - END_INTERFACE - } INetFwOpenPortsVtbl; - - interface INetFwOpenPorts - { - CONST_VTBL struct INetFwOpenPortsVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define INetFwOpenPorts_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define INetFwOpenPorts_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define INetFwOpenPorts_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define INetFwOpenPorts_GetTypeInfoCount(This,pctinfo) \ - (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) - -#define INetFwOpenPorts_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ - (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) - -#define INetFwOpenPorts_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ - (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) - -#define INetFwOpenPorts_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ - (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) - - -#define INetFwOpenPorts_get_Count(This,count) \ - (This)->lpVtbl -> get_Count(This,count) - -#define INetFwOpenPorts_Add(This,port) \ - (This)->lpVtbl -> Add(This,port) - -#define INetFwOpenPorts_Remove(This,portNumber,ipProtocol) \ - (This)->lpVtbl -> Remove(This,portNumber,ipProtocol) - -#define INetFwOpenPorts_Item(This,portNumber,ipProtocol,openPort) \ - (This)->lpVtbl -> Item(This,portNumber,ipProtocol,openPort) - -#define INetFwOpenPorts_get__NewEnum(This,newEnum) \ - (This)->lpVtbl -> get__NewEnum(This,newEnum) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwOpenPorts_get_Count_Proxy( - INetFwOpenPorts * This, - /* [retval][out] */ long *count); - - -void __RPC_STUB INetFwOpenPorts_get_Count_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id] */ HRESULT STDMETHODCALLTYPE INetFwOpenPorts_Add_Proxy( - INetFwOpenPorts * This, - /* [in] */ INetFwOpenPort *port); - - -void __RPC_STUB INetFwOpenPorts_Add_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id] */ HRESULT STDMETHODCALLTYPE INetFwOpenPorts_Remove_Proxy( - INetFwOpenPorts * This, - /* [in] */ LONG portNumber, - /* [in] */ NET_FW_IP_PROTOCOL ipProtocol); - - -void __RPC_STUB INetFwOpenPorts_Remove_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id] */ HRESULT STDMETHODCALLTYPE INetFwOpenPorts_Item_Proxy( - INetFwOpenPorts * This, - /* [in] */ LONG portNumber, - /* [in] */ NET_FW_IP_PROTOCOL ipProtocol, - /* [retval][out] */ INetFwOpenPort **openPort); - - -void __RPC_STUB INetFwOpenPorts_Item_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [restricted][propget][id] */ HRESULT STDMETHODCALLTYPE INetFwOpenPorts_get__NewEnum_Proxy( - INetFwOpenPorts * This, - /* [retval][out] */ IUnknown **newEnum); - - -void __RPC_STUB INetFwOpenPorts_get__NewEnum_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __INetFwOpenPorts_INTERFACE_DEFINED__ */ - - -#ifndef __INetFwService_INTERFACE_DEFINED__ -#define __INetFwService_INTERFACE_DEFINED__ - -/* interface INetFwService */ -/* [dual][uuid][object] */ - - -EXTERN_C const IID IID_INetFwService; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("79FD57C8-908E-4A36-9888-D5B3F0A444CF") - INetFwService : public IDispatch - { - public: - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_Name( - /* [retval][out] */ BSTR *name) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_Type( - /* [retval][out] */ NET_FW_SERVICE_TYPE *type) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_Customized( - /* [retval][out] */ VARIANT_BOOL *customized) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_IpVersion( - /* [retval][out] */ NET_FW_IP_VERSION *ipVersion) = 0; - - virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_IpVersion( - /* [in] */ NET_FW_IP_VERSION ipVersion) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_Scope( - /* [retval][out] */ NET_FW_SCOPE *scope) = 0; - - virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_Scope( - /* [in] */ NET_FW_SCOPE scope) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_RemoteAddresses( - /* [retval][out] */ BSTR *remoteAddrs) = 0; - - virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_RemoteAddresses( - /* [in] */ BSTR remoteAddrs) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_Enabled( - /* [retval][out] */ VARIANT_BOOL *enabled) = 0; - - virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_Enabled( - /* [in] */ VARIANT_BOOL enabled) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_GloballyOpenPorts( - /* [retval][out] */ INetFwOpenPorts **openPorts) = 0; - - }; - -#else /* C style interface */ - - typedef struct INetFwServiceVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - INetFwService * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - INetFwService * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - INetFwService * This); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( - INetFwService * This, - /* [out] */ UINT *pctinfo); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( - INetFwService * This, - /* [in] */ UINT iTInfo, - /* [in] */ LCID lcid, - /* [out] */ ITypeInfo **ppTInfo); - - HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( - INetFwService * This, - /* [in] */ REFIID riid, - /* [size_is][in] */ LPOLESTR *rgszNames, - /* [in] */ UINT cNames, - /* [in] */ LCID lcid, - /* [size_is][out] */ DISPID *rgDispId); - - /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( - INetFwService * This, - /* [in] */ DISPID dispIdMember, - /* [in] */ REFIID riid, - /* [in] */ LCID lcid, - /* [in] */ WORD wFlags, - /* [out][in] */ DISPPARAMS *pDispParams, - /* [out] */ VARIANT *pVarResult, - /* [out] */ EXCEPINFO *pExcepInfo, - /* [out] */ UINT *puArgErr); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_Name )( - INetFwService * This, - /* [retval][out] */ BSTR *name); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_Type )( - INetFwService * This, - /* [retval][out] */ NET_FW_SERVICE_TYPE *type); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_Customized )( - INetFwService * This, - /* [retval][out] */ VARIANT_BOOL *customized); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_IpVersion )( - INetFwService * This, - /* [retval][out] */ NET_FW_IP_VERSION *ipVersion); - - /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE *put_IpVersion )( - INetFwService * This, - /* [in] */ NET_FW_IP_VERSION ipVersion); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_Scope )( - INetFwService * This, - /* [retval][out] */ NET_FW_SCOPE *scope); - - /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE *put_Scope )( - INetFwService * This, - /* [in] */ NET_FW_SCOPE scope); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_RemoteAddresses )( - INetFwService * This, - /* [retval][out] */ BSTR *remoteAddrs); - - /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE *put_RemoteAddresses )( - INetFwService * This, - /* [in] */ BSTR remoteAddrs); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_Enabled )( - INetFwService * This, - /* [retval][out] */ VARIANT_BOOL *enabled); - - /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE *put_Enabled )( - INetFwService * This, - /* [in] */ VARIANT_BOOL enabled); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_GloballyOpenPorts )( - INetFwService * This, - /* [retval][out] */ INetFwOpenPorts **openPorts); - - END_INTERFACE - } INetFwServiceVtbl; - - interface INetFwService - { - CONST_VTBL struct INetFwServiceVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define INetFwService_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define INetFwService_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define INetFwService_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define INetFwService_GetTypeInfoCount(This,pctinfo) \ - (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) - -#define INetFwService_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ - (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) - -#define INetFwService_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ - (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) - -#define INetFwService_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ - (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) - - -#define INetFwService_get_Name(This,name) \ - (This)->lpVtbl -> get_Name(This,name) - -#define INetFwService_get_Type(This,type) \ - (This)->lpVtbl -> get_Type(This,type) - -#define INetFwService_get_Customized(This,customized) \ - (This)->lpVtbl -> get_Customized(This,customized) - -#define INetFwService_get_IpVersion(This,ipVersion) \ - (This)->lpVtbl -> get_IpVersion(This,ipVersion) - -#define INetFwService_put_IpVersion(This,ipVersion) \ - (This)->lpVtbl -> put_IpVersion(This,ipVersion) - -#define INetFwService_get_Scope(This,scope) \ - (This)->lpVtbl -> get_Scope(This,scope) - -#define INetFwService_put_Scope(This,scope) \ - (This)->lpVtbl -> put_Scope(This,scope) - -#define INetFwService_get_RemoteAddresses(This,remoteAddrs) \ - (This)->lpVtbl -> get_RemoteAddresses(This,remoteAddrs) - -#define INetFwService_put_RemoteAddresses(This,remoteAddrs) \ - (This)->lpVtbl -> put_RemoteAddresses(This,remoteAddrs) - -#define INetFwService_get_Enabled(This,enabled) \ - (This)->lpVtbl -> get_Enabled(This,enabled) - -#define INetFwService_put_Enabled(This,enabled) \ - (This)->lpVtbl -> put_Enabled(This,enabled) - -#define INetFwService_get_GloballyOpenPorts(This,openPorts) \ - (This)->lpVtbl -> get_GloballyOpenPorts(This,openPorts) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwService_get_Name_Proxy( - INetFwService * This, - /* [retval][out] */ BSTR *name); - - -void __RPC_STUB INetFwService_get_Name_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwService_get_Type_Proxy( - INetFwService * This, - /* [retval][out] */ NET_FW_SERVICE_TYPE *type); - - -void __RPC_STUB INetFwService_get_Type_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwService_get_Customized_Proxy( - INetFwService * This, - /* [retval][out] */ VARIANT_BOOL *customized); - - -void __RPC_STUB INetFwService_get_Customized_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwService_get_IpVersion_Proxy( - INetFwService * This, - /* [retval][out] */ NET_FW_IP_VERSION *ipVersion); - - -void __RPC_STUB INetFwService_get_IpVersion_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput][id] */ HRESULT STDMETHODCALLTYPE INetFwService_put_IpVersion_Proxy( - INetFwService * This, - /* [in] */ NET_FW_IP_VERSION ipVersion); - - -void __RPC_STUB INetFwService_put_IpVersion_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwService_get_Scope_Proxy( - INetFwService * This, - /* [retval][out] */ NET_FW_SCOPE *scope); - - -void __RPC_STUB INetFwService_get_Scope_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput][id] */ HRESULT STDMETHODCALLTYPE INetFwService_put_Scope_Proxy( - INetFwService * This, - /* [in] */ NET_FW_SCOPE scope); - - -void __RPC_STUB INetFwService_put_Scope_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwService_get_RemoteAddresses_Proxy( - INetFwService * This, - /* [retval][out] */ BSTR *remoteAddrs); - - -void __RPC_STUB INetFwService_get_RemoteAddresses_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput][id] */ HRESULT STDMETHODCALLTYPE INetFwService_put_RemoteAddresses_Proxy( - INetFwService * This, - /* [in] */ BSTR remoteAddrs); - - -void __RPC_STUB INetFwService_put_RemoteAddresses_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwService_get_Enabled_Proxy( - INetFwService * This, - /* [retval][out] */ VARIANT_BOOL *enabled); - - -void __RPC_STUB INetFwService_get_Enabled_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput][id] */ HRESULT STDMETHODCALLTYPE INetFwService_put_Enabled_Proxy( - INetFwService * This, - /* [in] */ VARIANT_BOOL enabled); - - -void __RPC_STUB INetFwService_put_Enabled_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwService_get_GloballyOpenPorts_Proxy( - INetFwService * This, - /* [retval][out] */ INetFwOpenPorts **openPorts); - - -void __RPC_STUB INetFwService_get_GloballyOpenPorts_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __INetFwService_INTERFACE_DEFINED__ */ - - -#ifndef __INetFwServices_INTERFACE_DEFINED__ -#define __INetFwServices_INTERFACE_DEFINED__ - -/* interface INetFwServices */ -/* [dual][uuid][object] */ - - -EXTERN_C const IID IID_INetFwServices; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("79649BB4-903E-421B-94C9-79848E79F6EE") - INetFwServices : public IDispatch - { - public: - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_Count( - /* [retval][out] */ long *count) = 0; - - virtual /* [id] */ HRESULT STDMETHODCALLTYPE Item( - /* [in] */ NET_FW_SERVICE_TYPE svcType, - /* [retval][out] */ INetFwService **service) = 0; - - virtual /* [restricted][propget][id] */ HRESULT STDMETHODCALLTYPE get__NewEnum( - /* [retval][out] */ IUnknown **newEnum) = 0; - - }; - -#else /* C style interface */ - - typedef struct INetFwServicesVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - INetFwServices * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - INetFwServices * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - INetFwServices * This); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( - INetFwServices * This, - /* [out] */ UINT *pctinfo); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( - INetFwServices * This, - /* [in] */ UINT iTInfo, - /* [in] */ LCID lcid, - /* [out] */ ITypeInfo **ppTInfo); - - HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( - INetFwServices * This, - /* [in] */ REFIID riid, - /* [size_is][in] */ LPOLESTR *rgszNames, - /* [in] */ UINT cNames, - /* [in] */ LCID lcid, - /* [size_is][out] */ DISPID *rgDispId); - - /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( - INetFwServices * This, - /* [in] */ DISPID dispIdMember, - /* [in] */ REFIID riid, - /* [in] */ LCID lcid, - /* [in] */ WORD wFlags, - /* [out][in] */ DISPPARAMS *pDispParams, - /* [out] */ VARIANT *pVarResult, - /* [out] */ EXCEPINFO *pExcepInfo, - /* [out] */ UINT *puArgErr); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_Count )( - INetFwServices * This, - /* [retval][out] */ long *count); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *Item )( - INetFwServices * This, - /* [in] */ NET_FW_SERVICE_TYPE svcType, - /* [retval][out] */ INetFwService **service); - - /* [restricted][propget][id] */ HRESULT ( STDMETHODCALLTYPE *get__NewEnum )( - INetFwServices * This, - /* [retval][out] */ IUnknown **newEnum); - - END_INTERFACE - } INetFwServicesVtbl; - - interface INetFwServices - { - CONST_VTBL struct INetFwServicesVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define INetFwServices_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define INetFwServices_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define INetFwServices_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define INetFwServices_GetTypeInfoCount(This,pctinfo) \ - (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) - -#define INetFwServices_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ - (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) - -#define INetFwServices_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ - (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) - -#define INetFwServices_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ - (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) - - -#define INetFwServices_get_Count(This,count) \ - (This)->lpVtbl -> get_Count(This,count) - -#define INetFwServices_Item(This,svcType,service) \ - (This)->lpVtbl -> Item(This,svcType,service) - -#define INetFwServices_get__NewEnum(This,newEnum) \ - (This)->lpVtbl -> get__NewEnum(This,newEnum) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwServices_get_Count_Proxy( - INetFwServices * This, - /* [retval][out] */ long *count); - - -void __RPC_STUB INetFwServices_get_Count_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id] */ HRESULT STDMETHODCALLTYPE INetFwServices_Item_Proxy( - INetFwServices * This, - /* [in] */ NET_FW_SERVICE_TYPE svcType, - /* [retval][out] */ INetFwService **service); - - -void __RPC_STUB INetFwServices_Item_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [restricted][propget][id] */ HRESULT STDMETHODCALLTYPE INetFwServices_get__NewEnum_Proxy( - INetFwServices * This, - /* [retval][out] */ IUnknown **newEnum); - - -void __RPC_STUB INetFwServices_get__NewEnum_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __INetFwServices_INTERFACE_DEFINED__ */ - - -#ifndef __INetFwAuthorizedApplication_INTERFACE_DEFINED__ -#define __INetFwAuthorizedApplication_INTERFACE_DEFINED__ - -/* interface INetFwAuthorizedApplication */ -/* [dual][uuid][object] */ - - -EXTERN_C const IID IID_INetFwAuthorizedApplication; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("B5E64FFA-C2C5-444E-A301-FB5E00018050") - INetFwAuthorizedApplication : public IDispatch - { - public: - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_Name( - /* [retval][out] */ BSTR *name) = 0; - - virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_Name( - /* [in] */ BSTR name) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_ProcessImageFileName( - /* [retval][out] */ BSTR *imageFileName) = 0; - - virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_ProcessImageFileName( - /* [in] */ BSTR imageFileName) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_IpVersion( - /* [retval][out] */ NET_FW_IP_VERSION *ipVersion) = 0; - - virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_IpVersion( - /* [in] */ NET_FW_IP_VERSION ipVersion) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_Scope( - /* [retval][out] */ NET_FW_SCOPE *scope) = 0; - - virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_Scope( - /* [in] */ NET_FW_SCOPE scope) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_RemoteAddresses( - /* [retval][out] */ BSTR *remoteAddrs) = 0; - - virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_RemoteAddresses( - /* [in] */ BSTR remoteAddrs) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_Enabled( - /* [retval][out] */ VARIANT_BOOL *enabled) = 0; - - virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_Enabled( - /* [in] */ VARIANT_BOOL enabled) = 0; - - }; - -#else /* C style interface */ - - typedef struct INetFwAuthorizedApplicationVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - INetFwAuthorizedApplication * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - INetFwAuthorizedApplication * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - INetFwAuthorizedApplication * This); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( - INetFwAuthorizedApplication * This, - /* [out] */ UINT *pctinfo); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( - INetFwAuthorizedApplication * This, - /* [in] */ UINT iTInfo, - /* [in] */ LCID lcid, - /* [out] */ ITypeInfo **ppTInfo); - - HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( - INetFwAuthorizedApplication * This, - /* [in] */ REFIID riid, - /* [size_is][in] */ LPOLESTR *rgszNames, - /* [in] */ UINT cNames, - /* [in] */ LCID lcid, - /* [size_is][out] */ DISPID *rgDispId); - - /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( - INetFwAuthorizedApplication * This, - /* [in] */ DISPID dispIdMember, - /* [in] */ REFIID riid, - /* [in] */ LCID lcid, - /* [in] */ WORD wFlags, - /* [out][in] */ DISPPARAMS *pDispParams, - /* [out] */ VARIANT *pVarResult, - /* [out] */ EXCEPINFO *pExcepInfo, - /* [out] */ UINT *puArgErr); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_Name )( - INetFwAuthorizedApplication * This, - /* [retval][out] */ BSTR *name); - - /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE *put_Name )( - INetFwAuthorizedApplication * This, - /* [in] */ BSTR name); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_ProcessImageFileName )( - INetFwAuthorizedApplication * This, - /* [retval][out] */ BSTR *imageFileName); - - /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE *put_ProcessImageFileName )( - INetFwAuthorizedApplication * This, - /* [in] */ BSTR imageFileName); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_IpVersion )( - INetFwAuthorizedApplication * This, - /* [retval][out] */ NET_FW_IP_VERSION *ipVersion); - - /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE *put_IpVersion )( - INetFwAuthorizedApplication * This, - /* [in] */ NET_FW_IP_VERSION ipVersion); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_Scope )( - INetFwAuthorizedApplication * This, - /* [retval][out] */ NET_FW_SCOPE *scope); - - /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE *put_Scope )( - INetFwAuthorizedApplication * This, - /* [in] */ NET_FW_SCOPE scope); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_RemoteAddresses )( - INetFwAuthorizedApplication * This, - /* [retval][out] */ BSTR *remoteAddrs); - - /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE *put_RemoteAddresses )( - INetFwAuthorizedApplication * This, - /* [in] */ BSTR remoteAddrs); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_Enabled )( - INetFwAuthorizedApplication * This, - /* [retval][out] */ VARIANT_BOOL *enabled); - - /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE *put_Enabled )( - INetFwAuthorizedApplication * This, - /* [in] */ VARIANT_BOOL enabled); - - END_INTERFACE - } INetFwAuthorizedApplicationVtbl; - - interface INetFwAuthorizedApplication - { - CONST_VTBL struct INetFwAuthorizedApplicationVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define INetFwAuthorizedApplication_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define INetFwAuthorizedApplication_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define INetFwAuthorizedApplication_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define INetFwAuthorizedApplication_GetTypeInfoCount(This,pctinfo) \ - (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) - -#define INetFwAuthorizedApplication_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ - (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) - -#define INetFwAuthorizedApplication_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ - (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) - -#define INetFwAuthorizedApplication_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ - (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) - - -#define INetFwAuthorizedApplication_get_Name(This,name) \ - (This)->lpVtbl -> get_Name(This,name) - -#define INetFwAuthorizedApplication_put_Name(This,name) \ - (This)->lpVtbl -> put_Name(This,name) - -#define INetFwAuthorizedApplication_get_ProcessImageFileName(This,imageFileName) \ - (This)->lpVtbl -> get_ProcessImageFileName(This,imageFileName) - -#define INetFwAuthorizedApplication_put_ProcessImageFileName(This,imageFileName) \ - (This)->lpVtbl -> put_ProcessImageFileName(This,imageFileName) - -#define INetFwAuthorizedApplication_get_IpVersion(This,ipVersion) \ - (This)->lpVtbl -> get_IpVersion(This,ipVersion) - -#define INetFwAuthorizedApplication_put_IpVersion(This,ipVersion) \ - (This)->lpVtbl -> put_IpVersion(This,ipVersion) - -#define INetFwAuthorizedApplication_get_Scope(This,scope) \ - (This)->lpVtbl -> get_Scope(This,scope) - -#define INetFwAuthorizedApplication_put_Scope(This,scope) \ - (This)->lpVtbl -> put_Scope(This,scope) - -#define INetFwAuthorizedApplication_get_RemoteAddresses(This,remoteAddrs) \ - (This)->lpVtbl -> get_RemoteAddresses(This,remoteAddrs) - -#define INetFwAuthorizedApplication_put_RemoteAddresses(This,remoteAddrs) \ - (This)->lpVtbl -> put_RemoteAddresses(This,remoteAddrs) - -#define INetFwAuthorizedApplication_get_Enabled(This,enabled) \ - (This)->lpVtbl -> get_Enabled(This,enabled) - -#define INetFwAuthorizedApplication_put_Enabled(This,enabled) \ - (This)->lpVtbl -> put_Enabled(This,enabled) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwAuthorizedApplication_get_Name_Proxy( - INetFwAuthorizedApplication * This, - /* [retval][out] */ BSTR *name); - - -void __RPC_STUB INetFwAuthorizedApplication_get_Name_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput][id] */ HRESULT STDMETHODCALLTYPE INetFwAuthorizedApplication_put_Name_Proxy( - INetFwAuthorizedApplication * This, - /* [in] */ BSTR name); - - -void __RPC_STUB INetFwAuthorizedApplication_put_Name_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwAuthorizedApplication_get_ProcessImageFileName_Proxy( - INetFwAuthorizedApplication * This, - /* [retval][out] */ BSTR *imageFileName); - - -void __RPC_STUB INetFwAuthorizedApplication_get_ProcessImageFileName_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput][id] */ HRESULT STDMETHODCALLTYPE INetFwAuthorizedApplication_put_ProcessImageFileName_Proxy( - INetFwAuthorizedApplication * This, - /* [in] */ BSTR imageFileName); - - -void __RPC_STUB INetFwAuthorizedApplication_put_ProcessImageFileName_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwAuthorizedApplication_get_IpVersion_Proxy( - INetFwAuthorizedApplication * This, - /* [retval][out] */ NET_FW_IP_VERSION *ipVersion); - - -void __RPC_STUB INetFwAuthorizedApplication_get_IpVersion_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput][id] */ HRESULT STDMETHODCALLTYPE INetFwAuthorizedApplication_put_IpVersion_Proxy( - INetFwAuthorizedApplication * This, - /* [in] */ NET_FW_IP_VERSION ipVersion); - - -void __RPC_STUB INetFwAuthorizedApplication_put_IpVersion_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwAuthorizedApplication_get_Scope_Proxy( - INetFwAuthorizedApplication * This, - /* [retval][out] */ NET_FW_SCOPE *scope); - - -void __RPC_STUB INetFwAuthorizedApplication_get_Scope_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput][id] */ HRESULT STDMETHODCALLTYPE INetFwAuthorizedApplication_put_Scope_Proxy( - INetFwAuthorizedApplication * This, - /* [in] */ NET_FW_SCOPE scope); - - -void __RPC_STUB INetFwAuthorizedApplication_put_Scope_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwAuthorizedApplication_get_RemoteAddresses_Proxy( - INetFwAuthorizedApplication * This, - /* [retval][out] */ BSTR *remoteAddrs); - - -void __RPC_STUB INetFwAuthorizedApplication_get_RemoteAddresses_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput][id] */ HRESULT STDMETHODCALLTYPE INetFwAuthorizedApplication_put_RemoteAddresses_Proxy( - INetFwAuthorizedApplication * This, - /* [in] */ BSTR remoteAddrs); - - -void __RPC_STUB INetFwAuthorizedApplication_put_RemoteAddresses_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwAuthorizedApplication_get_Enabled_Proxy( - INetFwAuthorizedApplication * This, - /* [retval][out] */ VARIANT_BOOL *enabled); - - -void __RPC_STUB INetFwAuthorizedApplication_get_Enabled_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput][id] */ HRESULT STDMETHODCALLTYPE INetFwAuthorizedApplication_put_Enabled_Proxy( - INetFwAuthorizedApplication * This, - /* [in] */ VARIANT_BOOL enabled); - - -void __RPC_STUB INetFwAuthorizedApplication_put_Enabled_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __INetFwAuthorizedApplication_INTERFACE_DEFINED__ */ - - -#ifndef __INetFwAuthorizedApplications_INTERFACE_DEFINED__ -#define __INetFwAuthorizedApplications_INTERFACE_DEFINED__ - -/* interface INetFwAuthorizedApplications */ -/* [dual][uuid][object] */ - - -EXTERN_C const IID IID_INetFwAuthorizedApplications; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("644EFD52-CCF9-486C-97A2-39F352570B30") - INetFwAuthorizedApplications : public IDispatch - { - public: - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_Count( - /* [retval][out] */ long *count) = 0; - - virtual /* [id] */ HRESULT STDMETHODCALLTYPE Add( - /* [in] */ INetFwAuthorizedApplication *app) = 0; - - virtual /* [id] */ HRESULT STDMETHODCALLTYPE Remove( - /* [in] */ BSTR imageFileName) = 0; - - virtual /* [id] */ HRESULT STDMETHODCALLTYPE Item( - /* [in] */ BSTR imageFileName, - /* [retval][out] */ INetFwAuthorizedApplication **app) = 0; - - virtual /* [restricted][propget][id] */ HRESULT STDMETHODCALLTYPE get__NewEnum( - /* [retval][out] */ IUnknown **newEnum) = 0; - - }; - -#else /* C style interface */ - - typedef struct INetFwAuthorizedApplicationsVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - INetFwAuthorizedApplications * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - INetFwAuthorizedApplications * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - INetFwAuthorizedApplications * This); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( - INetFwAuthorizedApplications * This, - /* [out] */ UINT *pctinfo); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( - INetFwAuthorizedApplications * This, - /* [in] */ UINT iTInfo, - /* [in] */ LCID lcid, - /* [out] */ ITypeInfo **ppTInfo); - - HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( - INetFwAuthorizedApplications * This, - /* [in] */ REFIID riid, - /* [size_is][in] */ LPOLESTR *rgszNames, - /* [in] */ UINT cNames, - /* [in] */ LCID lcid, - /* [size_is][out] */ DISPID *rgDispId); - - /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( - INetFwAuthorizedApplications * This, - /* [in] */ DISPID dispIdMember, - /* [in] */ REFIID riid, - /* [in] */ LCID lcid, - /* [in] */ WORD wFlags, - /* [out][in] */ DISPPARAMS *pDispParams, - /* [out] */ VARIANT *pVarResult, - /* [out] */ EXCEPINFO *pExcepInfo, - /* [out] */ UINT *puArgErr); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_Count )( - INetFwAuthorizedApplications * This, - /* [retval][out] */ long *count); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *Add )( - INetFwAuthorizedApplications * This, - /* [in] */ INetFwAuthorizedApplication *app); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *Remove )( - INetFwAuthorizedApplications * This, - /* [in] */ BSTR imageFileName); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *Item )( - INetFwAuthorizedApplications * This, - /* [in] */ BSTR imageFileName, - /* [retval][out] */ INetFwAuthorizedApplication **app); - - /* [restricted][propget][id] */ HRESULT ( STDMETHODCALLTYPE *get__NewEnum )( - INetFwAuthorizedApplications * This, - /* [retval][out] */ IUnknown **newEnum); - - END_INTERFACE - } INetFwAuthorizedApplicationsVtbl; - - interface INetFwAuthorizedApplications - { - CONST_VTBL struct INetFwAuthorizedApplicationsVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define INetFwAuthorizedApplications_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define INetFwAuthorizedApplications_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define INetFwAuthorizedApplications_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define INetFwAuthorizedApplications_GetTypeInfoCount(This,pctinfo) \ - (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) - -#define INetFwAuthorizedApplications_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ - (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) - -#define INetFwAuthorizedApplications_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ - (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) - -#define INetFwAuthorizedApplications_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ - (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) - - -#define INetFwAuthorizedApplications_get_Count(This,count) \ - (This)->lpVtbl -> get_Count(This,count) - -#define INetFwAuthorizedApplications_Add(This,app) \ - (This)->lpVtbl -> Add(This,app) - -#define INetFwAuthorizedApplications_Remove(This,imageFileName) \ - (This)->lpVtbl -> Remove(This,imageFileName) - -#define INetFwAuthorizedApplications_Item(This,imageFileName,app) \ - (This)->lpVtbl -> Item(This,imageFileName,app) - -#define INetFwAuthorizedApplications_get__NewEnum(This,newEnum) \ - (This)->lpVtbl -> get__NewEnum(This,newEnum) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwAuthorizedApplications_get_Count_Proxy( - INetFwAuthorizedApplications * This, - /* [retval][out] */ long *count); - - -void __RPC_STUB INetFwAuthorizedApplications_get_Count_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id] */ HRESULT STDMETHODCALLTYPE INetFwAuthorizedApplications_Add_Proxy( - INetFwAuthorizedApplications * This, - /* [in] */ INetFwAuthorizedApplication *app); - - -void __RPC_STUB INetFwAuthorizedApplications_Add_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id] */ HRESULT STDMETHODCALLTYPE INetFwAuthorizedApplications_Remove_Proxy( - INetFwAuthorizedApplications * This, - /* [in] */ BSTR imageFileName); - - -void __RPC_STUB INetFwAuthorizedApplications_Remove_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id] */ HRESULT STDMETHODCALLTYPE INetFwAuthorizedApplications_Item_Proxy( - INetFwAuthorizedApplications * This, - /* [in] */ BSTR imageFileName, - /* [retval][out] */ INetFwAuthorizedApplication **app); - - -void __RPC_STUB INetFwAuthorizedApplications_Item_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [restricted][propget][id] */ HRESULT STDMETHODCALLTYPE INetFwAuthorizedApplications_get__NewEnum_Proxy( - INetFwAuthorizedApplications * This, - /* [retval][out] */ IUnknown **newEnum); - - -void __RPC_STUB INetFwAuthorizedApplications_get__NewEnum_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __INetFwAuthorizedApplications_INTERFACE_DEFINED__ */ - - -#ifndef __INetFwProfile_INTERFACE_DEFINED__ -#define __INetFwProfile_INTERFACE_DEFINED__ - -/* interface INetFwProfile */ -/* [dual][uuid][object] */ - - -EXTERN_C const IID IID_INetFwProfile; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("174A0DDA-E9F9-449D-993B-21AB667CA456") - INetFwProfile : public IDispatch - { - public: - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_Type( - /* [retval][out] */ NET_FW_PROFILE_TYPE *type) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_FirewallEnabled( - /* [retval][out] */ VARIANT_BOOL *enabled) = 0; - - virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_FirewallEnabled( - /* [in] */ VARIANT_BOOL enabled) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_ExceptionsNotAllowed( - /* [retval][out] */ VARIANT_BOOL *notAllowed) = 0; - - virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_ExceptionsNotAllowed( - /* [in] */ VARIANT_BOOL notAllowed) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_NotificationsDisabled( - /* [retval][out] */ VARIANT_BOOL *disabled) = 0; - - virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_NotificationsDisabled( - /* [in] */ VARIANT_BOOL disabled) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_UnicastResponsesToMulticastBroadcastDisabled( - /* [retval][out] */ VARIANT_BOOL *disabled) = 0; - - virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE put_UnicastResponsesToMulticastBroadcastDisabled( - /* [in] */ VARIANT_BOOL disabled) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_RemoteAdminSettings( - /* [retval][out] */ INetFwRemoteAdminSettings **remoteAdminSettings) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_IcmpSettings( - /* [retval][out] */ INetFwIcmpSettings **icmpSettings) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_GloballyOpenPorts( - /* [retval][out] */ INetFwOpenPorts **openPorts) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_Services( - /* [retval][out] */ INetFwServices **services) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_AuthorizedApplications( - /* [retval][out] */ INetFwAuthorizedApplications **apps) = 0; - - }; - -#else /* C style interface */ - - typedef struct INetFwProfileVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - INetFwProfile * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - INetFwProfile * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - INetFwProfile * This); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( - INetFwProfile * This, - /* [out] */ UINT *pctinfo); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( - INetFwProfile * This, - /* [in] */ UINT iTInfo, - /* [in] */ LCID lcid, - /* [out] */ ITypeInfo **ppTInfo); - - HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( - INetFwProfile * This, - /* [in] */ REFIID riid, - /* [size_is][in] */ LPOLESTR *rgszNames, - /* [in] */ UINT cNames, - /* [in] */ LCID lcid, - /* [size_is][out] */ DISPID *rgDispId); - - /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( - INetFwProfile * This, - /* [in] */ DISPID dispIdMember, - /* [in] */ REFIID riid, - /* [in] */ LCID lcid, - /* [in] */ WORD wFlags, - /* [out][in] */ DISPPARAMS *pDispParams, - /* [out] */ VARIANT *pVarResult, - /* [out] */ EXCEPINFO *pExcepInfo, - /* [out] */ UINT *puArgErr); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_Type )( - INetFwProfile * This, - /* [retval][out] */ NET_FW_PROFILE_TYPE *type); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_FirewallEnabled )( - INetFwProfile * This, - /* [retval][out] */ VARIANT_BOOL *enabled); - - /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE *put_FirewallEnabled )( - INetFwProfile * This, - /* [in] */ VARIANT_BOOL enabled); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_ExceptionsNotAllowed )( - INetFwProfile * This, - /* [retval][out] */ VARIANT_BOOL *notAllowed); - - /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE *put_ExceptionsNotAllowed )( - INetFwProfile * This, - /* [in] */ VARIANT_BOOL notAllowed); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_NotificationsDisabled )( - INetFwProfile * This, - /* [retval][out] */ VARIANT_BOOL *disabled); - - /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE *put_NotificationsDisabled )( - INetFwProfile * This, - /* [in] */ VARIANT_BOOL disabled); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_UnicastResponsesToMulticastBroadcastDisabled )( - INetFwProfile * This, - /* [retval][out] */ VARIANT_BOOL *disabled); - - /* [propput][id] */ HRESULT ( STDMETHODCALLTYPE *put_UnicastResponsesToMulticastBroadcastDisabled )( - INetFwProfile * This, - /* [in] */ VARIANT_BOOL disabled); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_RemoteAdminSettings )( - INetFwProfile * This, - /* [retval][out] */ INetFwRemoteAdminSettings **remoteAdminSettings); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_IcmpSettings )( - INetFwProfile * This, - /* [retval][out] */ INetFwIcmpSettings **icmpSettings); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_GloballyOpenPorts )( - INetFwProfile * This, - /* [retval][out] */ INetFwOpenPorts **openPorts); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_Services )( - INetFwProfile * This, - /* [retval][out] */ INetFwServices **services); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_AuthorizedApplications )( - INetFwProfile * This, - /* [retval][out] */ INetFwAuthorizedApplications **apps); - - END_INTERFACE - } INetFwProfileVtbl; - - interface INetFwProfile - { - CONST_VTBL struct INetFwProfileVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define INetFwProfile_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define INetFwProfile_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define INetFwProfile_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define INetFwProfile_GetTypeInfoCount(This,pctinfo) \ - (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) - -#define INetFwProfile_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ - (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) - -#define INetFwProfile_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ - (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) - -#define INetFwProfile_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ - (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) - - -#define INetFwProfile_get_Type(This,type) \ - (This)->lpVtbl -> get_Type(This,type) - -#define INetFwProfile_get_FirewallEnabled(This,enabled) \ - (This)->lpVtbl -> get_FirewallEnabled(This,enabled) - -#define INetFwProfile_put_FirewallEnabled(This,enabled) \ - (This)->lpVtbl -> put_FirewallEnabled(This,enabled) - -#define INetFwProfile_get_ExceptionsNotAllowed(This,notAllowed) \ - (This)->lpVtbl -> get_ExceptionsNotAllowed(This,notAllowed) - -#define INetFwProfile_put_ExceptionsNotAllowed(This,notAllowed) \ - (This)->lpVtbl -> put_ExceptionsNotAllowed(This,notAllowed) - -#define INetFwProfile_get_NotificationsDisabled(This,disabled) \ - (This)->lpVtbl -> get_NotificationsDisabled(This,disabled) - -#define INetFwProfile_put_NotificationsDisabled(This,disabled) \ - (This)->lpVtbl -> put_NotificationsDisabled(This,disabled) - -#define INetFwProfile_get_UnicastResponsesToMulticastBroadcastDisabled(This,disabled) \ - (This)->lpVtbl -> get_UnicastResponsesToMulticastBroadcastDisabled(This,disabled) - -#define INetFwProfile_put_UnicastResponsesToMulticastBroadcastDisabled(This,disabled) \ - (This)->lpVtbl -> put_UnicastResponsesToMulticastBroadcastDisabled(This,disabled) - -#define INetFwProfile_get_RemoteAdminSettings(This,remoteAdminSettings) \ - (This)->lpVtbl -> get_RemoteAdminSettings(This,remoteAdminSettings) - -#define INetFwProfile_get_IcmpSettings(This,icmpSettings) \ - (This)->lpVtbl -> get_IcmpSettings(This,icmpSettings) - -#define INetFwProfile_get_GloballyOpenPorts(This,openPorts) \ - (This)->lpVtbl -> get_GloballyOpenPorts(This,openPorts) - -#define INetFwProfile_get_Services(This,services) \ - (This)->lpVtbl -> get_Services(This,services) - -#define INetFwProfile_get_AuthorizedApplications(This,apps) \ - (This)->lpVtbl -> get_AuthorizedApplications(This,apps) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwProfile_get_Type_Proxy( - INetFwProfile * This, - /* [retval][out] */ NET_FW_PROFILE_TYPE *type); - - -void __RPC_STUB INetFwProfile_get_Type_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwProfile_get_FirewallEnabled_Proxy( - INetFwProfile * This, - /* [retval][out] */ VARIANT_BOOL *enabled); - - -void __RPC_STUB INetFwProfile_get_FirewallEnabled_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput][id] */ HRESULT STDMETHODCALLTYPE INetFwProfile_put_FirewallEnabled_Proxy( - INetFwProfile * This, - /* [in] */ VARIANT_BOOL enabled); - - -void __RPC_STUB INetFwProfile_put_FirewallEnabled_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwProfile_get_ExceptionsNotAllowed_Proxy( - INetFwProfile * This, - /* [retval][out] */ VARIANT_BOOL *notAllowed); - - -void __RPC_STUB INetFwProfile_get_ExceptionsNotAllowed_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput][id] */ HRESULT STDMETHODCALLTYPE INetFwProfile_put_ExceptionsNotAllowed_Proxy( - INetFwProfile * This, - /* [in] */ VARIANT_BOOL notAllowed); - - -void __RPC_STUB INetFwProfile_put_ExceptionsNotAllowed_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwProfile_get_NotificationsDisabled_Proxy( - INetFwProfile * This, - /* [retval][out] */ VARIANT_BOOL *disabled); - - -void __RPC_STUB INetFwProfile_get_NotificationsDisabled_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput][id] */ HRESULT STDMETHODCALLTYPE INetFwProfile_put_NotificationsDisabled_Proxy( - INetFwProfile * This, - /* [in] */ VARIANT_BOOL disabled); - - -void __RPC_STUB INetFwProfile_put_NotificationsDisabled_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwProfile_get_UnicastResponsesToMulticastBroadcastDisabled_Proxy( - INetFwProfile * This, - /* [retval][out] */ VARIANT_BOOL *disabled); - - -void __RPC_STUB INetFwProfile_get_UnicastResponsesToMulticastBroadcastDisabled_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput][id] */ HRESULT STDMETHODCALLTYPE INetFwProfile_put_UnicastResponsesToMulticastBroadcastDisabled_Proxy( - INetFwProfile * This, - /* [in] */ VARIANT_BOOL disabled); - - -void __RPC_STUB INetFwProfile_put_UnicastResponsesToMulticastBroadcastDisabled_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwProfile_get_RemoteAdminSettings_Proxy( - INetFwProfile * This, - /* [retval][out] */ INetFwRemoteAdminSettings **remoteAdminSettings); - - -void __RPC_STUB INetFwProfile_get_RemoteAdminSettings_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwProfile_get_IcmpSettings_Proxy( - INetFwProfile * This, - /* [retval][out] */ INetFwIcmpSettings **icmpSettings); - - -void __RPC_STUB INetFwProfile_get_IcmpSettings_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwProfile_get_GloballyOpenPorts_Proxy( - INetFwProfile * This, - /* [retval][out] */ INetFwOpenPorts **openPorts); - - -void __RPC_STUB INetFwProfile_get_GloballyOpenPorts_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwProfile_get_Services_Proxy( - INetFwProfile * This, - /* [retval][out] */ INetFwServices **services); - - -void __RPC_STUB INetFwProfile_get_Services_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwProfile_get_AuthorizedApplications_Proxy( - INetFwProfile * This, - /* [retval][out] */ INetFwAuthorizedApplications **apps); - - -void __RPC_STUB INetFwProfile_get_AuthorizedApplications_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __INetFwProfile_INTERFACE_DEFINED__ */ - - -#ifndef __INetFwPolicy_INTERFACE_DEFINED__ -#define __INetFwPolicy_INTERFACE_DEFINED__ - -/* interface INetFwPolicy */ -/* [dual][uuid][object] */ - - -EXTERN_C const IID IID_INetFwPolicy; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("D46D2478-9AC9-4008-9DC7-5563CE5536CC") - INetFwPolicy : public IDispatch - { - public: - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_CurrentProfile( - /* [retval][out] */ INetFwProfile **profile) = 0; - - virtual /* [id] */ HRESULT STDMETHODCALLTYPE GetProfileByType( - /* [in] */ NET_FW_PROFILE_TYPE profileType, - /* [retval][out] */ INetFwProfile **profile) = 0; - - }; - -#else /* C style interface */ - - typedef struct INetFwPolicyVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - INetFwPolicy * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - INetFwPolicy * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - INetFwPolicy * This); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( - INetFwPolicy * This, - /* [out] */ UINT *pctinfo); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( - INetFwPolicy * This, - /* [in] */ UINT iTInfo, - /* [in] */ LCID lcid, - /* [out] */ ITypeInfo **ppTInfo); - - HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( - INetFwPolicy * This, - /* [in] */ REFIID riid, - /* [size_is][in] */ LPOLESTR *rgszNames, - /* [in] */ UINT cNames, - /* [in] */ LCID lcid, - /* [size_is][out] */ DISPID *rgDispId); - - /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( - INetFwPolicy * This, - /* [in] */ DISPID dispIdMember, - /* [in] */ REFIID riid, - /* [in] */ LCID lcid, - /* [in] */ WORD wFlags, - /* [out][in] */ DISPPARAMS *pDispParams, - /* [out] */ VARIANT *pVarResult, - /* [out] */ EXCEPINFO *pExcepInfo, - /* [out] */ UINT *puArgErr); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_CurrentProfile )( - INetFwPolicy * This, - /* [retval][out] */ INetFwProfile **profile); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *GetProfileByType )( - INetFwPolicy * This, - /* [in] */ NET_FW_PROFILE_TYPE profileType, - /* [retval][out] */ INetFwProfile **profile); - - END_INTERFACE - } INetFwPolicyVtbl; - - interface INetFwPolicy - { - CONST_VTBL struct INetFwPolicyVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define INetFwPolicy_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define INetFwPolicy_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define INetFwPolicy_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define INetFwPolicy_GetTypeInfoCount(This,pctinfo) \ - (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) - -#define INetFwPolicy_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ - (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) - -#define INetFwPolicy_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ - (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) - -#define INetFwPolicy_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ - (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) - - -#define INetFwPolicy_get_CurrentProfile(This,profile) \ - (This)->lpVtbl -> get_CurrentProfile(This,profile) - -#define INetFwPolicy_GetProfileByType(This,profileType,profile) \ - (This)->lpVtbl -> GetProfileByType(This,profileType,profile) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwPolicy_get_CurrentProfile_Proxy( - INetFwPolicy * This, - /* [retval][out] */ INetFwProfile **profile); - - -void __RPC_STUB INetFwPolicy_get_CurrentProfile_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id] */ HRESULT STDMETHODCALLTYPE INetFwPolicy_GetProfileByType_Proxy( - INetFwPolicy * This, - /* [in] */ NET_FW_PROFILE_TYPE profileType, - /* [retval][out] */ INetFwProfile **profile); - - -void __RPC_STUB INetFwPolicy_GetProfileByType_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __INetFwPolicy_INTERFACE_DEFINED__ */ - - -#ifndef __INetFwMgr_INTERFACE_DEFINED__ -#define __INetFwMgr_INTERFACE_DEFINED__ - -/* interface INetFwMgr */ -/* [dual][uuid][object] */ - - -EXTERN_C const IID IID_INetFwMgr; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("F7898AF5-CAC4-4632-A2EC-DA06E5111AF2") - INetFwMgr : public IDispatch - { - public: - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_LocalPolicy( - /* [retval][out] */ INetFwPolicy **localPolicy) = 0; - - virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE get_CurrentProfileType( - /* [retval][out] */ NET_FW_PROFILE_TYPE *profileType) = 0; - - virtual /* [id] */ HRESULT STDMETHODCALLTYPE RestoreDefaults( void) = 0; - - virtual /* [id] */ HRESULT STDMETHODCALLTYPE IsPortAllowed( - /* [in] */ BSTR imageFileName, - /* [in] */ NET_FW_IP_VERSION ipVersion, - /* [in] */ LONG portNumber, - /* [in] */ BSTR localAddress, - /* [in] */ NET_FW_IP_PROTOCOL ipProtocol, - /* [out] */ VARIANT *allowed, - /* [out] */ VARIANT *restricted) = 0; - - virtual /* [id] */ HRESULT STDMETHODCALLTYPE IsIcmpTypeAllowed( - /* [in] */ NET_FW_IP_VERSION ipVersion, - /* [in] */ BSTR localAddress, - /* [in] */ BYTE type, - /* [out] */ VARIANT *allowed, - /* [out] */ VARIANT *restricted) = 0; - - }; - -#else /* C style interface */ - - typedef struct INetFwMgrVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - INetFwMgr * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - INetFwMgr * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - INetFwMgr * This); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( - INetFwMgr * This, - /* [out] */ UINT *pctinfo); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( - INetFwMgr * This, - /* [in] */ UINT iTInfo, - /* [in] */ LCID lcid, - /* [out] */ ITypeInfo **ppTInfo); - - HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( - INetFwMgr * This, - /* [in] */ REFIID riid, - /* [size_is][in] */ LPOLESTR *rgszNames, - /* [in] */ UINT cNames, - /* [in] */ LCID lcid, - /* [size_is][out] */ DISPID *rgDispId); - - /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( - INetFwMgr * This, - /* [in] */ DISPID dispIdMember, - /* [in] */ REFIID riid, - /* [in] */ LCID lcid, - /* [in] */ WORD wFlags, - /* [out][in] */ DISPPARAMS *pDispParams, - /* [out] */ VARIANT *pVarResult, - /* [out] */ EXCEPINFO *pExcepInfo, - /* [out] */ UINT *puArgErr); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_LocalPolicy )( - INetFwMgr * This, - /* [retval][out] */ INetFwPolicy **localPolicy); - - /* [propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_CurrentProfileType )( - INetFwMgr * This, - /* [retval][out] */ NET_FW_PROFILE_TYPE *profileType); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *RestoreDefaults )( - INetFwMgr * This); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *IsPortAllowed )( - INetFwMgr * This, - /* [in] */ BSTR imageFileName, - /* [in] */ NET_FW_IP_VERSION ipVersion, - /* [in] */ LONG portNumber, - /* [in] */ BSTR localAddress, - /* [in] */ NET_FW_IP_PROTOCOL ipProtocol, - /* [out] */ VARIANT *allowed, - /* [out] */ VARIANT *restricted); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *IsIcmpTypeAllowed )( - INetFwMgr * This, - /* [in] */ NET_FW_IP_VERSION ipVersion, - /* [in] */ BSTR localAddress, - /* [in] */ BYTE type, - /* [out] */ VARIANT *allowed, - /* [out] */ VARIANT *restricted); - - END_INTERFACE - } INetFwMgrVtbl; - - interface INetFwMgr - { - CONST_VTBL struct INetFwMgrVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define INetFwMgr_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define INetFwMgr_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define INetFwMgr_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define INetFwMgr_GetTypeInfoCount(This,pctinfo) \ - (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) - -#define INetFwMgr_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ - (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) - -#define INetFwMgr_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ - (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) - -#define INetFwMgr_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ - (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) - - -#define INetFwMgr_get_LocalPolicy(This,localPolicy) \ - (This)->lpVtbl -> get_LocalPolicy(This,localPolicy) - -#define INetFwMgr_get_CurrentProfileType(This,profileType) \ - (This)->lpVtbl -> get_CurrentProfileType(This,profileType) - -#define INetFwMgr_RestoreDefaults(This) \ - (This)->lpVtbl -> RestoreDefaults(This) - -#define INetFwMgr_IsPortAllowed(This,imageFileName,ipVersion,portNumber,localAddress,ipProtocol,allowed,restricted) \ - (This)->lpVtbl -> IsPortAllowed(This,imageFileName,ipVersion,portNumber,localAddress,ipProtocol,allowed,restricted) - -#define INetFwMgr_IsIcmpTypeAllowed(This,ipVersion,localAddress,type,allowed,restricted) \ - (This)->lpVtbl -> IsIcmpTypeAllowed(This,ipVersion,localAddress,type,allowed,restricted) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwMgr_get_LocalPolicy_Proxy( - INetFwMgr * This, - /* [retval][out] */ INetFwPolicy **localPolicy); - - -void __RPC_STUB INetFwMgr_get_LocalPolicy_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget][id] */ HRESULT STDMETHODCALLTYPE INetFwMgr_get_CurrentProfileType_Proxy( - INetFwMgr * This, - /* [retval][out] */ NET_FW_PROFILE_TYPE *profileType); - - -void __RPC_STUB INetFwMgr_get_CurrentProfileType_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id] */ HRESULT STDMETHODCALLTYPE INetFwMgr_RestoreDefaults_Proxy( - INetFwMgr * This); - - -void __RPC_STUB INetFwMgr_RestoreDefaults_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id] */ HRESULT STDMETHODCALLTYPE INetFwMgr_IsPortAllowed_Proxy( - INetFwMgr * This, - /* [in] */ BSTR imageFileName, - /* [in] */ NET_FW_IP_VERSION ipVersion, - /* [in] */ LONG portNumber, - /* [in] */ BSTR localAddress, - /* [in] */ NET_FW_IP_PROTOCOL ipProtocol, - /* [out] */ VARIANT *allowed, - /* [out] */ VARIANT *restricted); - - -void __RPC_STUB INetFwMgr_IsPortAllowed_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id] */ HRESULT STDMETHODCALLTYPE INetFwMgr_IsIcmpTypeAllowed_Proxy( - INetFwMgr * This, - /* [in] */ NET_FW_IP_VERSION ipVersion, - /* [in] */ BSTR localAddress, - /* [in] */ BYTE type, - /* [out] */ VARIANT *allowed, - /* [out] */ VARIANT *restricted); - - -void __RPC_STUB INetFwMgr_IsIcmpTypeAllowed_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __INetFwMgr_INTERFACE_DEFINED__ */ - - - -#ifndef __NetFwPublicTypeLib_LIBRARY_DEFINED__ -#define __NetFwPublicTypeLib_LIBRARY_DEFINED__ - -/* library NetFwPublicTypeLib */ -/* [version][uuid] */ - - - - - - - - - - - - - -EXTERN_C const IID LIBID_NetFwPublicTypeLib; - -EXTERN_C const CLSID CLSID_NetFwOpenPort; - -#ifdef __cplusplus - -class DECLSPEC_UUID("0CA545C6-37AD-4A6C-BF92-9F7610067EF5") -NetFwOpenPort; -#endif - -EXTERN_C const CLSID CLSID_NetFwAuthorizedApplication; - -#ifdef __cplusplus - -class DECLSPEC_UUID("EC9846B3-2762-4A6B-A214-6ACB603462D2") -NetFwAuthorizedApplication; -#endif - -EXTERN_C const CLSID CLSID_NetFwMgr; - -#ifdef __cplusplus - -class DECLSPEC_UUID("304CE942-6E39-40D8-943A-B913C40C9CD4") -NetFwMgr; -#endif -#endif /* __NetFwPublicTypeLib_LIBRARY_DEFINED__ */ - -/* Additional Prototypes for ALL interfaces */ - -unsigned long __RPC_USER BSTR_UserSize( unsigned long *, unsigned long , BSTR * ); -unsigned char * __RPC_USER BSTR_UserMarshal( unsigned long *, unsigned char *, BSTR * ); -unsigned char * __RPC_USER BSTR_UserUnmarshal(unsigned long *, unsigned char *, BSTR * ); -void __RPC_USER BSTR_UserFree( unsigned long *, BSTR * ); - -unsigned long __RPC_USER VARIANT_UserSize( unsigned long *, unsigned long , VARIANT * ); -unsigned char * __RPC_USER VARIANT_UserMarshal( unsigned long *, unsigned char *, VARIANT * ); -unsigned char * __RPC_USER VARIANT_UserUnmarshal(unsigned long *, unsigned char *, VARIANT * ); -void __RPC_USER VARIANT_UserFree( unsigned long *, VARIANT * ); - -/* end of Additional Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif - - diff --git a/Tests/introduce/lib/network.cpp b/Tests/introduce/lib/network.cpp deleted file mode 100644 index 7fbb0b47c..000000000 --- a/Tests/introduce/lib/network.cpp +++ /dev/null @@ -1,755 +0,0 @@ - -#include "sock_port.h" -#include "network.h" -#include "sort_addr.h" - -#include -#include - -#include - - -using namespace libintroduce; - -namespace { - class C_Socket; - class C_SocketPeer; -} - -static void (*Warn_Func)( int level, char const *, va_list ); - -void libintroduce::warning( char const * fmt, ... ) -{ - va_list vl; - va_start( vl, fmt ); - (*Warn_Func)( WL_WARNING, fmt, vl ); - va_end( vl ); -} - -void libintroduce::log( char const * fmt, ... ) -{ - va_list vl; - va_start( vl, fmt ); - (*Warn_Func)( WL_LOG, fmt, vl ); - va_end( vl ); -} - -void libintroduce::debug( char const * fmt, ... ) -{ - va_list vl; - va_start( vl, fmt ); - (*Warn_Func)( WL_DEBUG, fmt, vl ); - va_end( vl ); -} - -namespace { - class C_Network : public I_Network { - public: - C_Network(); - ~C_Network(); - - // I_Network - void dispose(); - I_Socket * createSocket( unsigned short port, I_SocketUser * user ); - void step( double sleepSeconds ); - - void remove( C_Socket * socket ); - - void reallocate( size_t i ); - - std::vector< pollfd > pollFds_; - std::vector< C_Socket * > sockets_; - }; -} - -namespace { - class C_Socket : public I_Socket { - public: - C_Socket( C_Network * network ); - ~C_Socket(); - - C_Network * network_; - I_SocketUser * user_; - SOCKET fd_; - short port_; - - bool configure( short port, I_SocketUser * user ); - void remove( C_SocketPeer * peer ); - void receive( sockaddr_in const & addr, char const * buf, int size ); - - void dispose(); - I_Network * network(); - I_SocketUser * socketUser(); - void setSocketUser( I_SocketUser * user ); - I_SocketPeer * createPeer( sockaddr_in const & addr, I_SocketPeerUser * user ); - I_SocketPeer * createPeer( char const * addr, I_SocketPeerUser * user, - char * oError, int eSize ); - I_SocketPeer * findPeer( sockaddr_in const & addr ); - void sendMessage( sockaddr_in const & addr, void const * buf, int bSize ); - sockaddr_in address(); - void reallocate(); - - typedef std::map< sort_sockaddr_in, C_SocketPeer * > PeerMap; - PeerMap peers_; - }; -} - - -namespace { - class C_SocketPeer : public I_SocketPeer { - public: - C_SocketPeer( C_Socket * socket ); - ~C_SocketPeer(); - - C_Socket * socket_; - I_SocketPeerUser * user_; - sort_sockaddr_in sin_; - - void configure( sort_sockaddr_in const & sin, I_SocketPeerUser * user ); - - void dispose(); - sockaddr_in const & peerAddress(); - I_Socket * socket(); - I_SocketPeerUser * socketPeerUser(); - void sendMessage( void const * buf, int bSize ); - }; -} - - - -I_Network * libintroduce::CreateNetwork( char * buf, int size, void (*warnFunc)( int level, char const *, va_list ) ) -{ - static bool socketLibraryInited; - if( !socketLibraryInited ) { - INIT_SOCKET_LIBRARY(); - ENABLE_FIREWALL(); - } - Warn_Func = warnFunc; - C_Network * nw = new C_Network(); - return static_cast< I_Network * >( nw ); -} - - -C_Network::C_Network() -{ -} - -C_Network::~C_Network() -{ - assert( !sockets_.size() ); - assert( !pollFds_.size() ); -} - -void C_Network::dispose() -{ - size_t s; - while( (s = sockets_.size()) != 0 ) { - libintroduce::warning( "I_Socket(%d:%d) not destroyed before C_Network::dispose()", - sockets_[sockets_.size()-1]->port_, sockets_[sockets_.size()-1]->fd_ ); - sockets_[sockets_.size()-1]->dispose(); - assert( s > sockets_.size() ); - } - assert( sockets_.size() == pollFds_.size() ); - delete this; -} - -I_Socket * C_Network::createSocket( unsigned short port, I_SocketUser * user ) -{ - C_Socket * s = new C_Socket( this ); - if( !s->configure( port, user ) ) { - libintroduce::warning( "C_Network::configure(%d) failed", port ); - s->dispose(); - return 0; - } - sockets_.push_back( s ); - pollfd pfd; - pfd.revents = 0; - pfd.events = POLLIN /*| POLLOUT*/; - pfd.fd = s->fd_; - pollFds_.push_back( pfd ); - assert( sockets_.size() == pollFds_.size() ); - return static_cast< I_Socket * >( s ); -} - -void C_Network::step( double sleepSeconds ) -{ - char buffer[ MAX_MESSAGE_SIZE ]; - int size = sizeof( buffer ); - assert( sockets_.size() == pollFds_.size() ); - int r = ::poll( &pollFds_[0], pollFds_.size(), (int)(sleepSeconds*1000) ); - for( size_t i = 0; i < sockets_.size(); ++i ) { - pollfd & pfd = pollFds_[i]; - if( pfd.revents & POLLIN ) { - // receive pending messages - while( true ) { - sockaddr_in addr; - int len = sizeof( addr ); - size = ::recvfrom( pfd.fd, buffer, sizeof( buffer ), - NONBLOCK_MSG_SEND, (struct sockaddr *)&addr, &len ); - if( size < 1 ) { - if( size < 0 ) { - int e = SOCKET_ERRNO; - if( SOCKET_WOULDBLOCK_ERROR( e ) ) { - break; - } - else if( SOCKET_NEED_REOPEN( e ) ) { - libintroduce::debug( "C_Network::step() 0x%lx: socket %d needs reallocate()\n", this, e ); - reallocate( i ); - } - } - break; - } - sockets_[i]->receive( addr, buffer, size ); - } - } - if( pfd.revents & POLLOUT ) { - // send queued messages - } - pfd.events = POLLIN /*| POLLOUT*/; - } -} - -void C_Network::remove( C_Socket * socket ) -{ - size_t i = 0; - while( i < sockets_.size() ) { - if( sockets_[i] == socket ) { - break; - } - ++i; - } - assert( i < sockets_.size() ); - sockets_.erase( &sockets_[i] ); - pollFds_.erase( &pollFds_[i] ); -} - -void C_Network::reallocate( size_t i ) -{ - assert( i >= 0 && i < sockets_.size() ); - sockets_[i]->reallocate(); - pollFds_[i].fd = sockets_[i]->fd_; -} - - - - -C_Socket::C_Socket( C_Network * network ) -{ - network_ = network; - fd_ = BAD_SOCKET_FD; - port_ = 0; - user_ = 0; -} - -C_Socket::~C_Socket() -{ - assert( fd_ == BAD_SOCKET_FD ); -} - -bool C_Socket::configure( short port, I_SocketUser * user ) -{ - assert( port_ == 0 ); - assert( fd_ == BAD_SOCKET_FD ); - assert( port != 0 ); - - // if getprotoent() fails, we're screwed, and should core - int udpProto = getprotobyname( "udp" )->p_proto; - fd_ = ::socket( PF_INET, SOCK_DGRAM, udpProto ); - if( fd_ == BAD_SOCKET_FD ) { - libintroduce::warning( "could not create local UDP socket" ); - return false; - } - - int r = 0; - MAKE_SOCKET_NONBLOCKING( fd_, r ); - if( r < 0 ) { - libintroduce::warning( "could not make socket %d non-blocking", fd_ ); - ::closesocket( fd_ ); - fd_ = BAD_SOCKET_FD; - return false; - } - - int one = 1; - r = ::setsockopt( fd_, SOL_SOCKET, SO_BROADCAST, (char const *)&one, sizeof(one) ); - - sockaddr_in sin; - memset( &sin, 0, sizeof( sin ) ); - sin.sin_family = AF_INET; - sin.sin_port = htons( port ); - r = ::bind( fd_, (struct sockaddr *)&sin, sizeof( sin ) ); - if( r < 0 ) { - libintroduce::warning( "could not bind socket %d to local port %d", fd_, port ); - ::closesocket( fd_ ); - fd_ = BAD_SOCKET_FD; - return false; - } - port_ = port; - user_ = user; - - libintroduce::debug( "C_Socket::configure() 0x%lx: socket %d port %d\n", this, fd_, port_ ); - - return true; -} - -void C_Socket::remove( C_SocketPeer * peer ) -{ - sort_sockaddr_in sin = peer->peerAddress(); - PeerMap::iterator ptr = peers_.find( sin ); - assert( ptr != peers_.end() ); - if( ptr != peers_.end() ) { - peers_.erase( ptr ); - } -} - -void C_Socket::receive( sockaddr_in const & addr, char const * buf, int size ) -{ - PeerMap::iterator ptr = peers_.find( addr ); - if( ptr == peers_.end() ) { - user_->onConnection( this, addr, buf, size ); - } - else { - C_SocketPeer * peer = (*ptr).second; - if( !peer->user_ ) { - warning( "C_Socket::receive() 0x%lx for peer 0x%lx has NULL user; message size %d dropped\n", - this, peer, size ); - } - else { - peer->user_->onMessage( peer, buf, size ); - } - } -} - -void C_Socket::dispose() -{ - assert( peers_.size() == 0 ); - if( user_ ) { - user_->disposing( this ); - user_ = 0; - // user_ is only non-NULL if the configure was complete - network_->remove( this ); - } - network_ = 0; - ::closesocket( fd_ ); - fd_ = BAD_SOCKET_FD; - delete this; -} - -I_Network * C_Socket::network() -{ - return network_; -} - -I_SocketUser * C_Socket::socketUser() -{ - return user_; -} - -void C_Socket::setSocketUser( I_SocketUser * user ) -{ - user_ = user; -} - -I_SocketPeer * C_Socket::createPeer( sockaddr_in const & addr, I_SocketPeerUser * user ) -{ - // check for common mistakes and cull them out early - if( SIN_ADDR_UINT(addr.sin_addr) == 0 || addr.sin_port == 0 ) { - libintroduce::warning( "illegal arguments to C_Socket::createPeer(): 0x%x:%d 0x%lx\n", - htonl(SIN_ADDR_UINT(addr.sin_addr)), htons(addr.sin_port), user ); - return 0; - } - - sort_sockaddr_in sin = addr; // slicing assignment - - // find out whether there is already a peer for this address - PeerMap::iterator ptr = peers_.find( sin ); - if( ptr != peers_.end() ) { - // there already exists a peer for this address - return 0; - } - - // make a new peer and remember it - C_SocketPeer * sp = new C_SocketPeer( this ); - peers_[ sin ] = sp; - sp->configure( addr, user ); - return sp; -} - -I_SocketPeer * C_Socket::createPeer( char const * addr, I_SocketPeerUser * user, - char * oError, int eSize ) -{ - // check for common argument problems - if( !addr || !user || !oError || eSize < 10 ) { - libintroduce::warning( "bad arguments to C_Socket::createPeer()\n" ); - return 0; - } - - // parse the port part of the host name (colon not allowed in host name) - char const * colon = strchr( addr, ':' ); - // default to the configured port if we don't get another value - short port = port_; - if( colon ) { - char * end = 0; - long l = strtol( colon+1, &end, 10 ); - if( l == 0 || l < 0 || l > 65535 ) { - // only allow legal port ids - snprintf( oError, eSize, "createPeer() got bad port from address: '%s'", colon+1 ); - return 0; - } - if( !end || *end != 0 ) { - // don't allow sloppy port ids - snprintf( oError, eSize, "createPeer() got bad port id format: '%s'", end ? end : "" ); - return 0; - } - port = short( l & 0xffff ); - } - if( !colon ) { - // make sure we point at the end of the string for memcpy() - colon = addr + strlen( addr ); - } - // extract the host name portion - char hostname[ 256 ]; - if( colon-addr > 255 ) { - snprintf( oError, eSize, "createPeer() got too long host name: %d chars", colon-addr ); - return 0; - } - memcpy( hostname, addr, colon-addr ); - hostname[ colon-addr ] = 0; - if( !hostname[0] ) { - snprintf( oError, eSize, "createPeer() got an empty host name" ); - return 0; - } - // ask the deliciously blocking, non-thread-safe host resolver for the - // address of this host. - struct hostent * hent; - hent = gethostbyname( hostname ); - if( !hent ) { - snprintf( oError, eSize, "createPeer() could not find host: %s (%s)", hostname, hstrerror( h_errno ) ); - return 0; - } - - // formulate the actual address to use - sockaddr_in sin; - memset( &sin, 0, sizeof( sin ) ); - sin.sin_family = AF_INET; - sin.sin_addr = *(in_addr *)hent->h_addr_list[0]; - sin.sin_port = htons( port ); - - // attempt to create a peer using the given address - return createPeer( sin, user ); -} - -I_SocketPeer * C_Socket::findPeer( sockaddr_in const & addr ) -{ - PeerMap::iterator ptr = peers_.find( addr ); - if( ptr != peers_.end() ) { - // found it! - return (*ptr).second; - } - // not found - return 0; -} - -void C_Socket::sendMessage( sockaddr_in const & addr, void const * buf, int bSize ) -{ - int r = ::sendto( fd_, reinterpret_cast< char const * >( buf ), bSize, - NONBLOCK_MSG_SEND, (struct sockaddr *)&addr, sizeof( addr ) ); - if( r < 0 ) { - warning( "C_Socket::sendMessage() 0x%lx error sending to %s: %d\n", this, - sort_sockaddr_in( addr ).staticText(), SOCKET_ERRNO ); - } -} - -sockaddr_in C_Socket::address() -{ - sockaddr_in sin; - memset( &sin, 0, sizeof( sin ) ); - int sin_len = (int)sizeof( sin ); - ::getsockname( fd_, (struct sockaddr *)&sin, &sin_len ); - return sin; -} - - - -void C_Socket::reallocate() -{ - int udpProto = getprotobyname( "udp" )->p_proto; - SOCKET s2 = ::socket( PF_INET, SOCK_DGRAM, udpProto ); - if( s2 == BAD_SOCKET_FD ) { - libintroduce::warning( "could not allocate a new socket to reallocate socket %d: error %d\n", fd_, SOCKET_ERRNO ); - return; - } - int r = 0; - MAKE_SOCKET_NONBLOCKING( s2, r ); - if( r < 0 ) { - warning( "could not make socket %d non-blocking", s2 ); - ::closesocket( s2 ); - return; - } - - libintroduce::debug( "C_Socket::reallocate() 0x%lx: socket %d becomes %d for port %d\n", this, fd_, s2, port_ ); - - ::closesocket( fd_ ); - fd_ = s2; - - sockaddr_in sin; - memset( &sin, 0, sizeof( sin ) ); - sin.sin_family = AF_INET; - sin.sin_port = htons( port_ ); - r = ::bind( fd_, (struct sockaddr *)&sin, sizeof( sin ) ); - if( r < 0 ) { - libintroduce::warning( "could not re-bind new socket %d to local port %d", fd_, port_ ); - ::closesocket( fd_ ); - fd_ = BAD_SOCKET_FD; - } -} - - - -C_SocketPeer::C_SocketPeer( C_Socket * socket ) -{ - assert( socket ); - socket_ = socket; - user_ = 0; - memset( &sin_, 0, sizeof( sin_ ) ); -} - -C_SocketPeer::~C_SocketPeer() -{ - assert( !socket_ ); - assert( !user_ ); -} - -void C_SocketPeer::configure( sort_sockaddr_in const & sin, I_SocketPeerUser * user ) -{ - assert( socket_ ); - assert( sin.sin_port ); - assert( SIN_ADDR_UINT(sin.sin_addr) ); - assert( !user_ ); - user_ = user; - sin_ = sin; -} - -void C_SocketPeer::dispose() -{ - if( user_ ) { - user_->disposing( this ); - } - socket_->remove( this ); - user_ = 0; - socket_ = 0; - delete this; -} - -sockaddr_in const & C_SocketPeer::peerAddress() -{ - return sin_; -} - -I_Socket * C_SocketPeer::socket() -{ - return socket_; -} - -I_SocketPeerUser * C_SocketPeer::socketPeerUser() -{ - return user_; -} - -void C_SocketPeer::sendMessage( void const * buf, int bSize ) -{ - // Easiest is to just send here, and let the kernel sort out the - // buffering. If I flood the link, then this will block and/or fail - // at some point. - // An alternative is to copy the data into a queue per-socket, and - // use ::poll() to send only on sockets that are ready to accept - // more data. Possibly, in a non-blocking fashion. However, the - // queue still needs to be limited length, and in the end, it just - // translates to possibly dropping data anyway. - // Note that I don't guarantee success of the message (there can be - // no such guarantee) so you'll have to detect transmission failure - // somehow anyway. - int r = ::sendto( socket_->fd_, reinterpret_cast< char const * >( buf ), bSize, - NONBLOCK_MSG_SEND, (struct sockaddr *)&sin_, sizeof( sin_ ) ); - if( r < 0 ) { - warning( "C_Socket::sendMessage() 0x%lx error sending to %s: %d\n", this, - sin_.staticText(), SOCKET_ERRNO ); - } -} - - -#include - -namespace libintroduce { - -int swallowWarnings = 0; - -} - -void Unittest_Warn_Func( int level, char const * fmt, va_list vl ) -{ - if( level < WL_WARNING ) { - return; - } - if( !swallowWarnings ) { - fprintf( stderr, "WARNING: " ); - vfprintf( stderr, fmt, vl ); - fprintf( stderr, "\n" ); - assert( 0 ); - } - else { - --swallowWarnings; - } -} - -void Unittest_Network() -{ - char buf[ 100 ]; - I_Network * nw = libintroduce::CreateNetwork( buf, 100, Unittest_Warn_Func ); - assert( nw != 0 ); - nw->step(0.001); // sleeping - nw->step(0); // polling - nw->dispose(); -} - -namespace { - // This class is used as a convenient implementation of the - // "user" interfaces, so that we can test the general system. - class Unittest_SocketUser : public I_SocketUser, public I_SocketPeerUser { - public: - - bool disposingCalled_; - bool onConnectionCalled_; - bool disposingPeerCalled_; - bool onMessageCalled_; - char buf_[ 128 ]; - int size_; - sockaddr_in sin_; - I_SocketPeer * peer_; - - Unittest_SocketUser() { - disposingCalled_ = false; - onConnectionCalled_ = false; - disposingPeerCalled_ = false; - onMessageCalled_ = false; - size_ = 0; - peer_ = 0; - } - void disposing( I_Socket * socket ) { - disposingCalled_ = true; - } - void onConnection( I_Socket * socket, sockaddr_in const & addr, char const * buf, int bSize ) { - onConnectionCalled_ = true; - if( bSize > sizeof( buf_ ) ) { - bSize = sizeof( buf_ ); - } - memcpy( buf_, buf, bSize ); - size_ = bSize; - sin_ = addr; - } - void disposing( I_SocketPeer * peer ) { - disposingPeerCalled_ = true; - peer_ = peer; - } - void onMessage( I_SocketPeer * peer, char const * buf, int bSize ) { - onMessageCalled_ = true; - if( bSize > sizeof( buf_ ) ) { - bSize = sizeof( buf_ ); - } - memcpy( buf_, buf, bSize ); - size_ = bSize; - peer_ = peer; - } - }; -} - -void Unittest_Socket() -{ - char buf[ 100 ]; - I_Network * nw = libintroduce::CreateNetwork( buf, 100, Unittest_Warn_Func ); - assert( nw != 0 ); - - // verify that we can create and bind a socket on a port - Unittest_SocketUser user1; - I_Socket * sock1 = nw->createSocket( 60001, &user1 ); - assert( sock1->network() == nw ); - assert( sock1->socketUser() == &user1 ); - - // verify that we can't re-create a socket on the same port - swallowWarnings = 2; - assert( nw->createSocket( 60001, &user1 ) == 0 ); - - // verify that we don't have a peer (this just tests searching - // when there are no peers). - sockaddr_in sin; - sin.sin_family = AF_INET; - sin.sin_port = htons( 60001 ); - SIN_ADDR_UINT( sin.sin_addr ) = htonl( 0x7f0001 ); - assert( sock1->findPeer( sin ) == 0 ); - - // step for good measure - nw->step( 0 ); - - // verify that we get properly notified on dispose - assert( !user1.disposingCalled_ ); - sock1->dispose(); - assert( user1.disposingCalled_ ); - - // shut down the network - nw->dispose(); -} - -static void Watch_And_Wait( I_Network * nw, bool volatile & flag ) -{ - assert( flag == false ); - int watch = 50; - while( watch > 0 && !flag ) { - nw->step( 0.010 ); - --watch; - assert( watch > 0 ); // else it didn't happen - } - assert( flag ); -} - - -void Unittest_SocketPeer() -{ - char buf[ 100 ]; - I_Network * nw = libintroduce::CreateNetwork( buf, 100, Unittest_Warn_Func ); - assert( nw != 0 ); - - Unittest_SocketUser user1; - I_Socket * sock1 = nw->createSocket( 60001, &user1 ); - Unittest_SocketUser user2; - I_Socket * sock2 = nw->createSocket( 60002, &user2 ); - - // verify that we can create a peer - sockaddr_in sin; - sin.sin_family = AF_INET; - sin.sin_port = htons( 60002 ); - SIN_ADDR_UINT( sin.sin_addr ) = htonl( 0x7f000001 ); - I_SocketPeer * peer1 = sock1->createPeer( sin, &user1 ); - assert( peer1 != 0 ); - - // verify that a message ends up inside "connection" - peer1->sendMessage( "hello", 5 ); - Watch_And_Wait( nw, user2.onConnectionCalled_ ); - // assert it's from who we think it is - assert( user2.sin_.sin_port == htons( 60001 ) ); - - // verify that responding is reasonable - assert( user1.peer_ == 0 ); - I_SocketPeer * peer2 = sock2->createPeer( user2.sin_, &user2 ); - assert( peer2 != 0 ); - peer2->sendMessage( "hello2", 6 ); - Watch_And_Wait( nw, user1.onMessageCalled_ ); - assert( user1.peer_ == peer1 ); - - peer1->dispose(); - peer2->dispose(); - sock1->dispose(); - sock2->dispose(); - - // shut down the network - nw->dispose(); -} - diff --git a/Tests/introduce/lib/network.h b/Tests/introduce/lib/network.h deleted file mode 100644 index c4fed3f69..000000000 --- a/Tests/introduce/lib/network.h +++ /dev/null @@ -1,52 +0,0 @@ - -#if !defined( network_h ) -#define network_h - -#include - -#include "sock_port.h" -#include "i_socket.h" -#include "i_socketuser.h" -#include "i_socketpeer.h" -#include "i_socketpeeruser.h" - -namespace libintroduce { - -// I implement this interface; you get ahold of an instance by -// calling CreateNetwork. When you don't need any networking -// services anymore, call I_Network::dispose() on your interface. -// You only ever need one instance of this interface, as it can -// open multiple, independent sockets. -class I_Network { -public: - // When you're done, dispose me. This will delete all remaining - // instances created through me, but it will also print warnings - // because this likely means you have a leak in your program. - virtual void dispose() = 0; - // Open a socket on a port to start communicating. - virtual I_Socket * createSocket( unsigned short port, I_SocketUser * user ) = 0; - // Periodically (like, once a game step) you should call step() - // on me. I will check whether there are any incoming messages - // from socket peers, and dispatch them through the User callback - // interfaces. Pass 0 sleepSeconds to just do a poll. Pass something - // bigger to actually sleep if there is no data. - virtual void step( double sleepSeconds ) = 0; -}; - - -// warning levels passed to the warnFunc -#define WL_WARNING 3 -#define WL_LOG 2 -#define WL_DEBUG 0 -I_Network * CreateNetwork( char * o_error, int eSize, void (*warnFunc)( int level, char const *, va_list ) ); - -void warning( char const * str, ... ); -void log( char const * str, ... ); -void debug( char const * str, ... ); - -} - -// this is the maximum payload I'll let you send or receive -#define MAX_MESSAGE_SIZE (128*11) - -#endif // network_h diff --git a/Tests/introduce/lib/roster.cpp b/Tests/introduce/lib/roster.cpp deleted file mode 100644 index c8962ce5f..000000000 --- a/Tests/introduce/lib/roster.cpp +++ /dev/null @@ -1,1601 +0,0 @@ - -// Known problems: -// - there is very little user code configurability -// - some limitations in the protocol are arbitrary (name length, record length, etc) -// - the protocol allows you to make me send packets to a third party, if you can -// forge the source IP of your outgoing traffic -// - there is no encryption of login data (or any other data) -// - there is no authentication of traffic once logged in (except by source IP) - -#include "roster.h" -#include "message.h" -#include "sort_addr.h" - -#include -#include -#include -#include -#include -#include - -#define NAME_LEN 64 -#define PEER_TIMEOUT_SECONDS 30 -#define MAX_RECORD_SIZE 512 -#define MAX_RECORDS_PER_PEER 8 -#define MAX_PEERS 128 -#define MAX_MATCHED_RECORDS 32 -#define CONNECT_RETRY_SECONDS 3 -#define KEY_RESEND_SECONDS 3 -#define INTRODUCTION_RESEND_SECONDS 0.8 -#define PEER_ROSTER_TIMEOUT 30 -#define PEER_KEEPALIVE_INTERVAL 7 - -// Timeout in seconds to get a query operation through to the server -#define SIMPLE_TIMEOUT_SECONDS 5 -#define QUERY_RESEND_SECONDS 2 - - -using namespace libintroduce; - -// Record packet: -// ID -// string - -// Record ack packet: -// ID - -// Query packet: -// ID -// string - -// Each Answer packet: -// ID -// total num -// this index -// score -// string -// sockaddr_in - -namespace { - class C_Roster : public I_Roster, public I_SocketUser, public I_SocketPeerUser { - public: - C_Roster(); - ~C_Roster(); - - bool configure( I_Clock * clock, I_Socket * socket, I_RosterUser * user, bool ownSocket ); - - // I_Roster - void dispose(); - I_Clock * clock(); - I_Network * network(); - I_Socket * socket(); - I_RosterUser * rosterUser(); - void step(); - bool addRecord( sockaddr_in const & peer, char const * record, int token ); - void removeRecords( sockaddr_in const & peer ); - int matchRecords( char const * key, MatchedRecord * outMatches, - int maxMatches, float threshold ); - void introduce( sockaddr_in const & peer1, sockaddr_in const & peer2 ); - - // I_SocketUser - void disposing( I_Socket * socket ); - void onConnection( I_Socket * socket, sockaddr_in const & addr, - char const * buf, int bSize ); - - // I_SocketPeerUser - void disposing( I_SocketPeer * peer ); - void onMessage( I_SocketPeer * peer, char const * buf, int bSize ); - - I_Clock * clock_; - I_Socket * socket_; - bool ownSocket_; - I_RosterUser * user_; - - // The list of peers is sorted in timeout order, low to high. - // Any peer in the list has been validated with a valid user name and password. - struct Peer { - I_SocketPeer * peer; - double timeout; - double keepalive; - }; - std::list< Peer > peers_; - - // a Record is what peers ask me to store and match against - struct Record { - int token; - char data[ MAX_RECORD_SIZE ]; - }; - typedef std::map< sort_sockaddr_in, std::list< Record > > RecordMap; - RecordMap records_; - - void assertPeerListSorted() { - #if !defined( NDEBUG ) - std::list< Peer >::iterator i1, i2; - i1 = peers_.begin(); - i2 = peers_.begin(); - while( i1 != peers_.end() ) { - assert( (*i1).timeout >= (*i2).timeout ); - i2 = i1; - ++i1; - } - #endif - } - - //! \f validatePacket() will strip the \m bigEndian_ flag from \m ph.type if present - //! and correct. It will not validate the packet if it's not what I expect. This means - //! that I correctly reject, but cannot interoperate with, a host of another endian- - //! ness. This could obviously be betterized in the future. - bool validatePacket( char const * buf, int bSize, char const * func, ProtoHeader & ph ); - void sendConnectAckToPeer( I_SocketPeer * peer ); - void sendKickToAddress( sockaddr_in const & addr ); - void keepalive( I_SocketPeer * peer ); - void sendRecordAckToAddress( sockaddr_in const & addr, int token ); - void sendAnswerToPeer( int id, int n, MatchedRecord const * matches, I_SocketPeer * peer ); - void debugMessage( char const * ptr, size_t size, sort_sockaddr_in ssin ); - void sendKeepaliveToPeer( C_Roster::Peer * peer, double now ); - - static double peerTimeout_; - static unsigned char bigEndian_; - static int maxRecordsPerPeer_; - static int maxPeers_; - }; -} - -double C_Roster::peerTimeout_ = PEER_TIMEOUT_SECONDS; -unsigned char C_Roster::bigEndian_ = ((htons(1)==1) ? TypeBigEndian : 0); -int C_Roster::maxRecordsPerPeer_ = MAX_RECORDS_PER_PEER; -int C_Roster::maxPeers_ = MAX_PEERS; - -// If you create me with a network and port, I will create my own socket, -// and I will dispose it when I'm disposed. -I_Roster * libintroduce::CreateRoster( I_Clock * clock, I_Network * network, unsigned short port, I_RosterUser * user ) -{ - if( !network || !clock || !port || !user ) { - warning( "CreateRoster(network) was passed bad parameters" ); - return 0; - } - - C_Roster * r = new C_Roster(); - - I_Socket * sock = network->createSocket( port, r ); - if( !sock ) { - warning( "Could not create socket in CreateRoster(port %d)", port ); - r->dispose(); - return 0; - } - - if( !r->configure( clock, sock, user, true ) ) { - warning( "Could not configure roster after creation" ); - r->dispose(); - return 0; - } - - return static_cast< I_Roster * >( r ); -} - -// If you create me with a socket, I will not dispose that socket when disposed -I_Roster * libintroduce::CreateRoster( I_Clock * clock, I_Socket * socket, I_RosterUser * user ) -{ - if( !clock || !socket || !user ) { - warning( "CreateRoster(socket) was passed bad parameters" ); - return 0; - } - - C_Roster * r = new C_Roster(); - - if( !r->configure( clock, socket, user, false ) ) { - warning( "Could not configure roster with provided socket after creation" ); - r->dispose(); - return 0; - } - else { - socket->setSocketUser( r ); - } - - return static_cast< I_Roster * >( r ); -} - - - -C_Roster::C_Roster() -{ - socket_ = 0; - ownSocket_ = false; - user_ = 0; -} - -C_Roster::~C_Roster() -{ - assert( !ownSocket_ ); - assert( user_ == 0 ); - assert( peers_.size() == 0 ); -} - -bool C_Roster::configure( I_Clock * clock, I_Socket * socket, I_RosterUser * user, bool ownSocket ) -{ - if( socket_ || user_ ) { - return false; - } - clock_ = clock; - socket_ = socket; - user_ = user; - ownSocket_ = ownSocket; - return true; -} - -void C_Roster::dispose() -{ - debug( "C_Roster::dispose() 0x%lx ownSocket_ %s\n", this, ownSocket_ ? "true" : "false" ); - - if( user_ ) { - user_->disposing( this ); - user_ = 0; - } - - if( ownSocket_ ) { - socket_->dispose(); - } - assert( !ownSocket_ ); - - std::list< Peer >::iterator ptr = peers_.begin(); - while( ptr != peers_.end() ) { - (*ptr).peer->dispose(); - ++ptr; - } - peers_.clear(); - - delete this; -} - -I_Clock * C_Roster::clock() -{ - return clock_; -} - -I_Network * C_Roster::network() -{ - return socket_->network(); -} - -I_Socket * C_Roster::socket() -{ - return socket_; -} - -I_RosterUser * C_Roster::rosterUser() -{ - return user_; -} - -void C_Roster::step() -{ - assertPeerListSorted(); - - double now = clock_->realTime(); - - // expire peers that have been inactive too long - std::list< Peer >::iterator p = peers_.begin(); - while( p != peers_.end() ) { - if( (*p).timeout > now ) { - // there won't be any more peers to expire right now - break; - } - debug( "C_Roster::step() 0x%lx find peer 0x%lx timeout\n", this, (*p).peer ); - // time out this peer - std::list< Peer >::iterator del = p; - ++p; - I_SocketPeer * peer = (*del).peer; - peers_.erase( del ); - user_->userTimeout( this, peer->peerAddress() ); - sendKickToAddress( peer->peerAddress() ); - peer->dispose(); - } - while( p != peers_.end() ) { - if( (*p).keepalive < now ) { - sendKeepaliveToPeer( &(*p), now ); - } - ++p; - } - - assertPeerListSorted(); -} - -void C_Roster::sendKeepaliveToPeer( C_Roster::Peer * peer, double now ) -{ - peer->keepalive = now + PEER_KEEPALIVE_INTERVAL; - - debug( "C_Roster::sendKeepaliveToPeer() 0x%lx peer 0x%lx now %g\n", - this, peer->peer, now ); - - Message mm; - ProtoHeader::prepend( Keepalive | bigEndian_, mm ); - peer->peer->sendMessage( mm.buf_, mm.size_ ); -} - -bool C_Roster::addRecord( sockaddr_in const & peer, char const * record, int token ) -{ - sort_sockaddr_in ssin( peer ); - debug( "C_Roster::addRecord() 0x%lx peer %s token %d '%s'\n", this, ssin.staticText(), token, record ); - - Record r; - strncpy( r.data, record, sizeof( r.data ) ); - r.data[ sizeof( r.data )-1 ] = 0; - r.token = token; - std::list< Record > & recs = records_[ peer ]; - for( std::list< Record >::iterator ptr = recs.begin(); - ptr != recs.end(); - ++ptr ) { - if( (*ptr).token == token ) { - *ptr = r; - goto added; - } - } - if( int(records_[ peer ].size()) >= maxRecordsPerPeer_ ) { - return false; - } - records_[ peer ].push_back( r ); -added: - sendRecordAckToAddress( peer, token ); - return true; -} - -void C_Roster::removeRecords( sockaddr_in const & peer ) -{ - sort_sockaddr_in ssin( peer ); - debug( "C_Roster::removeRecords() 0x%lx peer %s\n", this, ssin.staticText() ); - - RecordMap::iterator ptr = records_.find( peer ); - if( ptr != records_.end() ) { - records_.erase( ptr ); - } -} - -int C_Roster::matchRecords( char const * key, MatchedRecord * outMatches, - int maxMatches, float threshold ) -{ - // I don't sort the matches; the N first that match over threshold are - // what I return. - RecordMap::iterator ptr = records_.begin(); - int matched = 0; - while( ptr != records_.end() && maxMatches > 0 ) { - for( std::list< Record >::iterator l = (*ptr).second.begin(); - l != (*ptr).second.end() && maxMatches > 0; - ++l ) { - float m = MatchRecord( (*l).data, key ); - if( m >= threshold ) { - outMatches->addr = (*ptr).first; - outMatches->record = (*l).data; - outMatches->score = m; - ++matched; - ++outMatches; - --maxMatches; - } - } - ++ptr; - } - return matched; -} - -void C_Roster::introduce( sockaddr_in const & peer1, sockaddr_in const & peer2 ) -{ - // maybe I should check that the two addresses really are peer addresses - Message m; - m.put( peer2 ); - ProtoHeader::prepend( IntroduceAck, m ); - debugMessage( m.buf_, m.size_, peer1 ); - socket_->sendMessage( peer1, m.buf_, m.size_ ); - m.clear(); - m.put( peer1 ); - ProtoHeader::prepend( IntroduceAck, m ); - debugMessage( m.buf_, m.size_, peer2 ); - socket_->sendMessage( peer2, m.buf_, m.size_ ); -} - -void C_Roster::disposing( I_Socket * socket ) -{ - assert( socket == socket_ ); - ownSocket_ = false; - socket_ = 0; -} - -void C_Roster::onConnection( I_Socket * socket, sockaddr_in const & addr, - char const * buf, int bSize ) -{ - ProtoHeader ph; - if( !validatePacket( buf, bSize, "C_Roster::onConnection()", ph ) ) { - return; - } - - debug( "C_Roster::onConnection() 0x%lx type %d\n", this, ph.type ); - - if( ph.type != Connect ) { - warning( "unexpected packet (type %d) in C_Roster::onConnection()", ph.type ); - // Maybe he didn't get the message the last time? - // Send a message without a peer. - sendKickToAddress( addr ); - return; - } - - char name[ NAME_LEN ]; - char password[ NAME_LEN ]; - Message m( buf+sizeof( ProtoHeader ), bSize-sizeof( ProtoHeader ) ); - if( !m.get( name, NAME_LEN ) ) { - warning( "could not get user name from packet in C_Roster::onConnection()" ); - return; - } - // The password is sent in clear text! - if( !m.get( password, NAME_LEN ) ) { - warning( "could not get password from packet in C_Roster::onConnection()" ); - return; - } - if( (int(peers_.size()) < maxPeers_) && user_->validatePeer( this, addr, name, password ) ) { - // make a note of this user - I_SocketPeer * peer = socket->createPeer( addr, this ); - Peer p; - p.peer = peer; - double now = clock_->realTime(); - p.timeout = now + peerTimeout_; - p.keepalive = now; - peers_.push_back( p ); - - // send back a connection ack - sendConnectAckToPeer( peer ); - } - // else say nothing - - assertPeerListSorted(); -} - -void C_Roster::disposing( I_SocketPeer * peer ) -{ - removeRecords( peer->peerAddress() ); -} - -void C_Roster::onMessage( I_SocketPeer * peer, char const * buf, int bSize ) -{ - // This chunk of packet validation code could be common with onConnection() - ProtoHeader ph; - if( !validatePacket( buf, bSize, "C_Roster::onMessage()", ph ) ) { - return; - } - - debug( "C_Roster::onMessage() 0x%lx type %d\n", this, ph.type ); - - Message m( buf+sizeof( ProtoHeader ), bSize-sizeof( ProtoHeader ) ); - - switch( ph.type ) { - case Connect: { - // Send back a connection ack. Because it's onMessage(), I know the peer - // has already been identified with user name and password, although I - // don't use any cryptography to assert that identity. - sendConnectAckToPeer( peer ); - keepalive( peer ); - } - break; - case Disconnect: { - } - break; - case Keepalive: { - keepalive( peer ); - } - break; - case ::Record: { - char record[ MAX_RECORD_SIZE ]; - int id; - if( m.get( &id ) && m.get( record, sizeof( record ) ) ) { - //todo: should this return a bool, and the ack be sent from this place - // instead of inside the registration? - user_->registerRecord( this, peer->peerAddress(), record, id ); - } - else { - warning( "bad packet format in Record request in C_Roster::onMessage()" ); - } - } - break; - case Query: { - char key[ MAX_RECORD_SIZE ]; - int id; - MatchedRecord matches[MAX_MATCHED_RECORDS]; - if( m.get( &id ) && m.get( key, sizeof( key ) ) ) { - int n = user_->matchRecords( this, peer->peerAddress(), key, id, - matches, sizeof(matches)/sizeof(matches[0]) ); - sendAnswerToPeer( id, n, matches, peer ); - } - else { - warning( "bad packet format in Query request in C_Roster::onMessage()" ); - } - } - break; - case IntroducePeer: { - // I know that I'm already connected here - sockaddr_in sin; - if( m.get( &sin ) ) { - user_->allowIntroduction( this, peer->peerAddress(), sin ); - } - else { - warning( "bad packet format in IntroducePeer request in C_Roster::onMessage()" ); - } - } - break; - default: - warning( "unexpected packet (type %d) in C_Roster::onMessage()", ph.type ); - return; - } -} - -bool C_Roster::validatePacket( char const * buf, int bSize, char const * func, ProtoHeader & ph ) -{ - if( bSize < sizeof( ProtoHeader ) ) { - warning( "short packet (%d bytes) in %s", bSize, func ); - return false; - } - memcpy( &ph, buf, sizeof( ph ) ); - if( (ph.type & TypeBigEndian) != bigEndian_ ) { - warning( "wrong endian order or mal-formed packet (type %d) in %s", ph.type, func ); - return false; - } - ph.type &= ~TypeBigEndian; - if( bSize != sizeof( ProtoHeader ) + ph.size ) { - warning( "packet length calculated wrong (is %d should be %d) in %s", - ph.size, bSize - sizeof( ProtoHeader ), func ); - return false; - } - return true; -} - -void C_Roster::sendConnectAckToPeer( I_SocketPeer * peer ) -{ - log( "C_Roster::sendConnectAckToPeer() 0x%lx peer 0x%lx addr %s\n", - this, peer, sort_sockaddr_in( peer->peerAddress() ).staticText() ); - - ProtoHeader ack; - ack.type = ConnectAck | bigEndian_; - ack.size = 0; - // can't get status back, because it's unreliable - peer->sendMessage( &ack, sizeof( ack ) ); -} - -void C_Roster::sendKickToAddress( sockaddr_in const & addr ) -{ - log( "C_Roster::sendKickToAddress() 0x%lx addr %s\n", - this, sort_sockaddr_in( addr ).staticText() ); - - // The message contains a reason for kicking, as a string. - Message m; - m.put( "You are not logged in." ); - ProtoHeader::prepend( Kick | bigEndian_, m ); - socket_->sendMessage( addr, m.buf_, m.size_ ); -} - -void C_Roster::keepalive( I_SocketPeer * peer ) -{ - // Find the record for the peer, update the timeout, - // and put it back in the list in the appropriate spot. - // This spot is likely at the end of the list, but if - // there are different time-outs for different clients, - // that's not necessarily true. - for( std::list< Peer >::iterator ptr = peers_.begin(); - ptr != peers_.end(); - ++ptr ) { - if( (*ptr).peer == peer ) { - Peer p = *ptr; - ptr = peers_.erase( ptr ); - double nuTime = clock_->realTime() + peerTimeout_; - debug( "C_Roster::keepalive() 0x%lx peer 0x%lx updating time from %g to %g\n", - this, p.peer, p.timeout, nuTime ); - p.timeout = nuTime; - while( ptr != peers_.end() && ((*ptr).timeout <= p.timeout) ) { - ++ptr; - } - peers_.insert( ptr, p ); - break; - } - } -} - -void C_Roster::sendRecordAckToAddress( sockaddr_in const & addr, int token ) -{ - debug( "C_Roster::sendRecordAckToAddress() 0x%lx token %d to %s\n", - this, token, sort_sockaddr_in( addr ).staticText() ); - - Message mm; - mm.put( token ); - ProtoHeader::prepend( RecordAck | bigEndian_, mm ); - socket_->sendMessage( addr, mm.buf_, mm.size_ ); -} - -void C_Roster::sendAnswerToPeer( int id, int n, MatchedRecord const * matches, I_SocketPeer * peer ) -{ - debug( "C_Roster::sendAnswerToPeer() 0x%lx id %d with %d records (peer 0x%lx = %s)\n", - this, id, n, peer, sort_sockaddr_in( peer->peerAddress() ).staticText() ); - - // Because each packet can't be bigger than 255 bytes (ProtoHeader) - // I have to send a number of packets. - // There's also a limit to the answer size. - // If we have no answers at all, we should say so. - for( int ix = 0; ix < n || ix == 0; ++ix ) { - Message mm; - mm.put( id ); - mm.put( n ); - mm.put( ix ); - if( n == 0 ) { - mm.put( (float)0 ); - mm.put( "" ); - sockaddr_in junk; - memset( &junk, 0, sizeof( junk ) ); - mm.putn( sizeof( junk ), &junk ); - } - else { - mm.put( matches[ix].score ); - mm.put( matches[ix].record ); - mm.putn( sizeof( matches[ix].addr ), &matches[ix].addr ); - } - ProtoHeader::prepend( Answer, mm ); - peer->sendMessage( mm.buf_, mm.size_ ); - } -} - -void C_Roster::debugMessage( char const * buf, size_t size, sort_sockaddr_in ssin ) -{ -#if !defined( NDEBUG ) - // create a hex dump of the message and log, in addition to destination - char msg[1024]; - char * ptr = msg; - size_t done = 0; - while( done < size ) { - // we can add about 3+3+16+1 characters in one iteration - if( ptr - msg > 950 ) { - sprintf( ptr, " ..." ); - break; - } - if( !(done & 0xf) ) { - sprintf( ptr, "%04x ", done ); - ptr += strlen( ptr ); - } - sprintf( ptr, "%02x ", buf[done] ); - ptr += 3; - if( (done & 0xf) == 0xf ) { - sprintf( ptr, " " ); - ptr += 3; - for( int i = -15; i <= 0; ++i ) { - if( buf[done+i] < 32 || buf[done+i] > 127 ) { - *ptr++ = '.'; - } - else { - *ptr++ = buf[done+i]; - } - } - sprintf( ptr, "\n" ); - ptr++; - } - ++done; - } - *ptr = 0; - if( ptr > msg && ptr[-1] != '\n' ) { - sprintf( ptr, "\n" ); - } - - debug( "C_Roster::debugMessage() 0x%lx addr %s\n%s", this, ssin.staticText(), msg ); -#endif -} - - -namespace { - class C_RosterQuery : public I_RosterQuery, public I_SocketUser, public I_SocketPeerUser { - public: - struct SQuery; - C_RosterQuery(); - ~C_RosterQuery(); - void disconnectSync(); - void connectPeer( I_Socket * socket, I_SocketPeer * peer, - char const * name, char const * password ); - void maybeSendConnect( double time ); - void onAnswer( I_SocketPeer * peer, Message & m ); - void maybeNotifyUser( int id, SQuery & a ); - void maybeSendQueries( double time ); - void maybeSendKeys( double time ); - void onRecordAck( I_SocketPeer * peer, Message & m ); - void maybeSendIntroductions( double curTime ); - void onIntroduceAck( I_SocketPeer * peer, Message & m ); - void maybeTimeoutRoster( double curTime ); - - // I_RosterQuery - void dispose(); - void connect( I_Socket * socket, char const * server, - char const * name, char const * password ); - void connect( I_Socket * socket, sockaddr_in const & server, - char const * name, char const * password ); - void notify( I_RosterConnectionNotify * notify ); - bool connected(); - void step( double now ); - void query( char const * key, I_RosterQueryUser * user, - int maxRecords ); - void add( char const * key, int recId ); - void introduce( sockaddr_in const & sin ); - - // I_SocketUser - void disposing( I_Socket * socket ); - void onConnection( I_Socket * socket, sockaddr_in const & addr, - char const * buf, int bSize ); - - // I_SocketPeerUser - void disposing( I_SocketPeer * peer ); - void onMessage( I_SocketPeer * peer, char const * buf, int bSize ); - - I_Socket * socket_; - I_SocketPeer * serverPeer_; - sort_sockaddr_in server_; - std::string userName_; - std::string userPassword_; - I_RosterConnectionNotify * notify_; - bool connected_; - double lastConnectTime_; - double lastRosterMessage_; - double lastTime_; - - struct SAnswer { - SAnswer() : ok_( false ) {} - bool ok_; - std::string data_; - sockaddr_in addr_; - float score_; - }; - - struct SQuery { - SQuery() {} - SQuery( int i, char const * k, I_RosterQueryUser * u ) : - id( i ), key( k ), user( u ), lastSend_( -1e15 ) {} - int id; - std::string key; - I_RosterQueryUser * user; - std::vector< SAnswer > answers_; - double lastSend_; - }; - std::map< int, SQuery > queries_; - int nextQuery_; - - struct Key { - Key() {} - Key( int i, char const * k ) : id( i ), key( k ), ack( false ) {} - int id; - std::string key; - double lastSend; - bool ack; - }; - std::map< int, Key > keys_; - std::map< double, Key * > keyQueue_; - - struct Peer { - Peer() {} - Peer( sockaddr_in const & s ) : sin_( s ), gotPeer_( false ), peer_( 0 ) {} - sort_sockaddr_in sin_; - bool gotPeer_; - I_SocketPeer * peer_; - }; - std::map< sort_sockaddr_in, Peer > peers_; - std::map< double, Peer * > peerQueue_; - }; -} - -I_RosterQuery * libintroduce::CreateRosterQuery() -{ - return static_cast< I_RosterQuery * >( new C_RosterQuery() ); -} - - - -C_RosterQuery::C_RosterQuery() -{ - socket_ = 0; - serverPeer_ = 0; - notify_ = 0; - connected_ = false; - lastConnectTime_ = 0; - nextQuery_ = 0; - lastRosterMessage_ = 0; - lastTime_ = 0; -} - -C_RosterQuery::~C_RosterQuery() -{ - assert( !serverPeer_ ); - assert( !notify_ ); -} - -namespace { - class StopQuery { - public: - I_RosterQuery * query_; - StopQuery( I_RosterQuery * q ) : query_( q ) {} - void operator()( std::pair< int const, C_RosterQuery::SQuery > & q ) { - q.second.user->onQueryTimeout( query_ ); - } - }; -} - -void C_RosterQuery::disconnectSync() -{ - debug( "C_RosterQuery::disconnectSync() 0x%lx for %s\n", this, server_.staticText() ); - - // be kind and say good-bye - ProtoHeader ph; - ph.type = Disconnect; - ph.size = 0; - socket_->sendMessage( server_, &ph, sizeof( ph ) ); - std::for_each( queries_.begin(), queries_.end(), StopQuery( this ) ); - queries_.clear(); - keys_.clear(); - socket_ = 0; - connected_ = false; - lastRosterMessage_ = 0; -} - -void C_RosterQuery::dispose() -{ - if( connected_ ) { - disconnectSync(); - } - if( notify_ ) { - notify_->disposing( this ); - notify_ = 0; - } - if( serverPeer_ ) { - serverPeer_->dispose(); - serverPeer_ = 0; - } - delete this; -} - -void C_RosterQuery::connect( I_Socket * socket, char const * server, - char const * name, char const * password ) -{ - char err[ 100 ]; - I_SocketPeer * peer = socket->createPeer( server, this, err, 100 ); - connectPeer( socket, peer, name, password ); -} - -void C_RosterQuery::connect( I_Socket * socket, sockaddr_in const & server, - char const * name, char const * password ) -{ - I_SocketPeer * peer = socket->createPeer( server, this ); - connectPeer( socket, peer, name, password ); -} - -void C_RosterQuery::connectPeer( I_Socket * socket, I_SocketPeer * peer, - char const * name, char const * password ) -{ - // You really shouldn't re-use the same query for a different - // server. - assert( !connected_ ); - if( connected_ ) { - disconnectSync(); - } - assert( socket_ == 0 ); - socket_ = socket; - serverPeer_ = peer; - server_ = peer->peerAddress(); - userName_ = name; - userPassword_ = password; -} - -void C_RosterQuery::notify( I_RosterConnectionNotify * notify ) -{ - notify_ = notify; -} - -bool C_RosterQuery::connected() -{ - return connected_; -} - -void C_RosterQuery::step( double curTime ) -{ - assert( notify_ != NULL ); - maybeTimeoutRoster( curTime ); - maybeSendConnect( curTime ); - maybeSendQueries( curTime ); - maybeSendKeys( curTime ); - maybeSendIntroductions( curTime ); -} - -void C_RosterQuery::maybeTimeoutRoster( double curTime ) -{ - lastTime_ = curTime; - if( lastRosterMessage_ == 0 ) { - lastRosterMessage_ = curTime; - } - if( lastTime_ > PEER_ROSTER_TIMEOUT + lastRosterMessage_ ) { - debug( "C_RosterQuery::maybeTimeoutRoster() 0x%lx lastTime_ %g lastRosterMessage_ %g PEER_ROSTER_TIMEOUT %g\n", - this, lastTime_, lastRosterMessage_, (double)PEER_ROSTER_TIMEOUT ); - notify_->onRosterTimeout( this, socket_ ); - lastRosterMessage_ = lastTime_; - } -} - -void C_RosterQuery::maybeSendQueries( double time ) -{ - for( std::map< int, SQuery >::iterator ptr = queries_.begin(); - ptr != queries_.end(); - ++ptr ) { - if( (*ptr).second.lastSend_ + QUERY_RESEND_SECONDS < time ) { - - debug( "C_RosterQuery::maybeSendQueries() 0x%lx time %g id %d\n", - this, time, (*ptr).second.id ); - - (*ptr).second.lastSend_ = time; - Message m; - m.put( (*ptr).second.id ); - m.put( (*ptr).second.key.c_str() ); - ProtoHeader::prepend( Query, m ); - serverPeer_->sendMessage( m.buf_, m.size_ ); - } - } -} - -void C_RosterQuery::query( char const * key, I_RosterQueryUser * user, - int maxRecords ) -{ - if( !serverPeer_ || !connected_ ) { - debug( "C_RosterQuery::query() 0x%lx serverPeer_ 0x%lx connected_ %s\n", - this, serverPeer_, connected_ ? "true" : "false" ); - user->onQueryTimeout( this ); - return; - } - int id = ++nextQuery_; - SQuery q( id, key, user ); - queries_[id] = q; -} - -void C_RosterQuery::maybeSendKeys( double curTime ) -{ - if( !connected_ ) { - return; - } - for( std::map::iterator ptr = keyQueue_.begin(); - ptr != keyQueue_.end(); ) { - std::map::iterator i = ptr++; - if( (*i).second->ack ) { - keyQueue_.erase( i ); - } - else if( curTime > (*i).first + KEY_RESEND_SECONDS ) { - - debug( "C_RosterQuery::maybeSendKeys() 0x%lx time %g sending key %d\n", this, curTime, (*i).second->id ); - - Message m; - m.put( (*i).second->id ); - m.put( (*i).second->key.c_str() ); - ProtoHeader::prepend( Record, m ); - serverPeer_->sendMessage( m.buf_, m.size_ ); - keyQueue_[curTime] = (*i).second; - keyQueue_.erase( i ); - } - } -} - -void C_RosterQuery::add( char const * key, int recId ) -{ - keys_[recId] = C_RosterQuery::Key( recId, key ); - keyQueue_[-1e15] = &keys_[recId]; -} - -void C_RosterQuery::maybeSendIntroductions( double curTime ) -{ - if( !connected_ ) { - return; - } - for( std::map::iterator ptr = peerQueue_.begin(); - ptr != peerQueue_.end(); ) { - std::map< double, Peer * >::iterator i = ptr++; - if( (*i).second->gotPeer_ ) { - peerQueue_.erase( i ); - } - else if( curTime > (*i).first + INTRODUCTION_RESEND_SECONDS ) { - - debug( "C_RosterQuery::maybeSendIntroductions() 0x%lx time %g sending to %s\n", - this, curTime, (*i).second->sin_.staticText() ); - - Message m; - m.put( (*i).second->sin_ ); - ProtoHeader::prepend( IntroducePeer, m ); - serverPeer_->sendMessage( m.buf_, m.size_ ); - peerQueue_[curTime] = (*i).second; - peerQueue_.erase( i ); - } - } -} - -// The "peer" here is still the server. -void C_RosterQuery::onIntroduceAck( I_SocketPeer * peer, Message & m ) -{ - debug( "C_RosterQuery::onIntroduceAck() 0x%lx peer 0x%lx %d bytes\n", this, peer, m.size_ ); - - sort_sockaddr_in sin; - if( !m.get( sin ) ) { - // fixme: don't use assert to report errors - assert( !"bad data in onIntroduceAck" ); - return; - } - // fixme: perhaps the login name, as seen by roster, should go with this - // inet address, so that we can know the roster validated the name. - std::map< sort_sockaddr_in, Peer >::iterator ptr = peers_.find( sin ); - Peer * p; - if( ptr == peers_.end() ) { - peers_[sin] = Peer( sin ); - p = &peers_[sin]; - } - else { - p = &(*ptr).second; - bool found = false; - for( std::map< double, Peer * >::iterator i = peerQueue_.begin(); - i != peerQueue_.end(); ++i ) { - if( (*i).second == p ) { - peerQueue_.erase( i ); - found = true; - break; - } - } - assert( found ); - } - p->gotPeer_ = true; - p->peer_ = socket_->createPeer( sin, 0 ); - notify_->onPeerConnection( this, socket_, p->peer_ ); -} - -void C_RosterQuery::introduce( sockaddr_in const & s ) -{ - sort_sockaddr_in ssin( s ); - debug( "C_RosterQuery::introduce() 0x%lx addr %s\n", this, ssin.staticText() ); - - // you must configure a notify_ before calling introduce() - assert( notify_ ); - if( !notify_ ) { - warning( "you must configure a notify() before calling C_RosterQuery::introduce()" ); - } - sort_sockaddr_in sin = s; - std::map< sort_sockaddr_in, Peer >::iterator ptr = peers_.find( sin ); - if( ptr != peers_.end() ) { - return; // already working on it - } - peers_[sin] = Peer( s ); - peerQueue_[1e-15] = &peers_[sin]; -} - -void C_RosterQuery::disposing( I_Socket * socket ) -{ - assert( !"not implemented" ); - connected_ = false; -} - -void C_RosterQuery::onConnection( I_Socket * socket, sockaddr_in const & addr, - char const * buf, int bSize ) -{ - assert( !"not implemented" ); -} - -void C_RosterQuery::disposing( I_SocketPeer * peer ) -{ - connected_ = false; -} - -void C_RosterQuery::onMessage( I_SocketPeer * peer, char const * buf, int bSize ) -{ - if( peer == serverPeer_ ) { - debug( "C_RosterQuery::onMessage() 0x%lx lastTime_ %g size %d type %d\n", - this, lastTime_, bSize, buf[0] ); - lastRosterMessage_ = lastTime_; - - Message m( buf, bSize ); - ProtoHeader ph; - if( !m.getn( sizeof( ph ), &ph ) ) { - return; - } - switch( ph.type ) { - case ConnectAck: - connected_ = true; - break; - case Answer: - onAnswer( peer, m ); - break; - case Kick: - assert( !"implement me" ); - break; - case RecordAck: - onRecordAck( peer, m ); - break; - case IntroduceAck: - onIntroduceAck( peer, m ); - break; - case Keepalive: - // nothing - debug( "C_RosterQuery::onMessage() 0x%lx keepalive\n", this ); - break; - default: - warning( "C_RosterQuery::onMessage() 0x%lx: unknown reply type '%d' received\n", - this, ph.type ); - //fixme: don't use assert for error reporting - assert( !"unknown reply type" ); - break; - } - } - else { - warning( "C_RosterQuery::onMessage() 0x%lx: unexpected message from unknown, existing peer (%s)\n", - this, sort_sockaddr_in( peer->peerAddress() ).staticText() ); - //fixme: do I need to vector through to the user here? - assert( !"unexpected message from unknown, but existing, peer" ); - } -} - -void C_RosterQuery::onRecordAck( I_SocketPeer * peer, Message & m ) -{ - debug( "C_RosterQuery::onRecordAck() 0x%lx peer 0x%lx %d bytes\n", this, peer, m.size_ ); - - int id; - m.get( &id ); - std::map< int, Key >::iterator ptr = keys_.find( id ); - if( ptr == keys_.end() ) { - // this was an ID that's not actually ever defined - assert( !"bad ID received" ); - return; - } - (*ptr).second.ack = true; -} - -void C_RosterQuery::onAnswer( I_SocketPeer * peer, Message & m ) -{ - int id; - int num; - int ix; - float score; - char buf[ 1024 ]; - sockaddr_in addr; - std::map< int, SQuery >::iterator ptr; - - debug( "C_RosterQuery::onAnswer() 0x%lx peer 0x%lx %d bytes\n", this, peer, m.size_ ); - - if( !m.get( &id ) ) { assert( 0 ); goto error; } - if( !m.get( &num ) ) { assert( 0 ); goto error; } - if( !m.get( &ix ) ) { assert( 0 ); goto error; } - if( !m.get( &score ) ) { assert( 0 ); goto error; } - if( !m.get( buf, sizeof( buf ) ) ) { assert( 0 ); goto error; } - if( !m.getn( sizeof( addr ), &addr ) ) { assert( 0 ); goto error; } - - // sanity check - if( num == 0 ) { - assert( ix == 0 ); - debug( "C_RosterQuery::onAnswer() 0x%lx received empty answer\n", this ); - num = 1; - } - if( ix < 0 || ix >= num ) { assert( 0 ); goto error; } - if( num < 0 || num > MAX_MATCHED_RECORDS ) { assert( 0 ); goto error; } - - // find the corresponding query - ptr = queries_.find( id ); - if( ptr == queries_.end() ) { assert( 0 ); goto error; } - if( (*ptr).second.answers_.size() != size_t(num) ) { - (*ptr).second.answers_.resize( size_t(num) ); - } - { - SAnswer & a = (*ptr).second.answers_[ ix ]; - a.ok_ = true; - a.data_ = buf; - a.addr_ = addr; - a.score_ = score; - } - maybeNotifyUser( id, (*ptr).second ); - - return; - -error: - ; // do nothing -} - -void C_RosterQuery::maybeNotifyUser( int id, SQuery & q ) -{ - debug( "C_RosterQuery::maybeNotifyUser() 0x%lx id %d\n", this, id ); - - for( std::vector< SAnswer >::iterator ptr = q.answers_.begin(); - ptr != q.answers_.end(); - ++ptr ) { - if( !(*ptr).ok_ ) { - return; // not done -- don't notify user - } - } - // I guess we're done! Create the MatchedRecord array - std::vector< MatchedRecord > mrv; - for( std::vector< SAnswer >::iterator ptr = q.answers_.begin(); - ptr != q.answers_.end(); - ++ptr ) { - MatchedRecord mr; - mr.addr = (*ptr).addr_; - mr.record = (*ptr).data_.c_str(); - mr.score = (*ptr).score_; - mrv.push_back( mr ); - } - q.user->onQueryResult( this, &mrv[0], int( mrv.size() ) ); -} - -void C_RosterQuery::maybeSendConnect( double time ) -{ - if( serverPeer_ && (time >= CONNECT_RETRY_SECONDS + lastConnectTime_) ) { - if( !connected_ ) { - debug( "C_RosterQuery::maybeSendConnect() 0x%lx time %g lastConnectTime_ %g sending connect message\n", this, time, lastConnectTime_ ); - lastConnectTime_ = time; - Message m; - m.put( userName_.c_str() ); - m.put( userPassword_.c_str() ); - ProtoHeader::prepend( Connect, m ); - serverPeer_->sendMessage( m.buf_, m.size_ ); - } - else if( time > (PEER_TIMEOUT_SECONDS / 5 + lastConnectTime_) ) { - debug( "C_RosterQuery::maybeSendConnect() 0x%lx time %g lastConnectTime_ %g sending keepalive\n", this, time, lastConnectTime_ ); - lastConnectTime_ = time; - ProtoHeader ph; - ph.type = Keepalive; - ph.size = 0; - serverPeer_->sendMessage( &ph, sizeof( ph ) ); - } - } -} - - -namespace { - class C_RosterSocketUser : public I_SocketUser { - public: - C_RosterSocketUser() {} - void disposing( I_Socket * socket ); - void onConnection( I_Socket * socket, sockaddr_in const & addr, - char const * buf, int bSize ); - }; -} - -void C_RosterSocketUser::disposing( I_Socket * socket ) -{ - warning( "C_RosterSocketUser::disposing() 0x%lx shouldn't be here\n", this ); - assert( !"not implemented" ); -} - -void C_RosterSocketUser::onConnection( I_Socket * socket, sockaddr_in const & addr, - char const * buf, int bSize ) -{ - warning( "C_RosterSocketUser::onConnection() 0x%lx shouldn't be here\n", this ); - assert( !"not implemented" ); -} - -namespace { - class C_RosterQueryUser : public I_RosterQueryUser { - public: - C_RosterQueryUser( std::list< std::string > & strings ) : - strings_( strings ), done_( false ), numMatches_( -1 ) {} - void disposing( I_RosterQuery * query ) {} - void onQueryResult( I_RosterQuery * query, - MatchedRecord const * matched, int numMatched ); - void onQueryTimeout( I_RosterQuery * query ); - - std::vector< MatchedRecord > matches_; - std::list< std::string > & strings_; - bool done_; - int numMatches_; - }; -} - -void C_RosterQueryUser::onQueryResult( I_RosterQuery * query, - MatchedRecord const * matched, int numMatched ) -{ - debug( "C_RosterQueryUser::onQueryResult() 0x%lx with %d matches\n", this, numMatched ); - - matches_.resize( numMatched ); - memcpy( &matches_[0], matched, sizeof(MatchedRecord)*numMatched ); - strings_.clear(); - for( size_t ix = 0; ix < size_t( numMatched ); ++ix ) { - strings_.push_back( matched[ix].record ); - matches_[ix].record = strings_.back().c_str(); - } - done_ = true; - numMatches_ = numMatched; -} - -void C_RosterQueryUser::onQueryTimeout( I_RosterQuery * query ) -{ - debug( "C_RosterQueryUser::onQueryTimeout() 0x%lx\n", this ); - - done_ = true; -} - -int libintroduce::SimpleRosterQuery( I_Network * nw, - char const * server, - char const * user, char const * password, - char const * key, - MatchedRecord * outRecords, int maxRecords ) -{ - // space for returned strings - static std::list< std::string > strings; - strings.swap( std::list< std::string >() ); - - // create local socket - C_RosterSocketUser rsu; - I_Socket * s = 0; - for( int i = 0; i < 10; ++i ) { - s = nw->createSocket( 45234+i, &rsu ); - if( s ) { - break; - } - } - if( !s ) { - warning( "could not bind to any port 45234 through 45243" ); - return -1; - } - - // create our query object - I_RosterQuery * q = CreateRosterQuery(); - - // connect - q->connect( s, server, user, password ); - - C_RosterQueryUser rqu( strings ); - I_Clock * c = CreateClock(); - double now = c->realTime(); - int result = -1; - - while( !q->connected() ) { - double then = c->realTime(); - if( then > now + SIMPLE_TIMEOUT_SECONDS ) { - warning( "timeout waiting to connect to server" ); - goto error; - } - q->step( then ); - nw->step( 0 ); - } - - q->query( key, &rqu, 10 ); - now = c->realTime(); - double cur; - while( !rqu.done_ && ((cur = c->realTime()) < (now + SIMPLE_TIMEOUT_SECONDS)) ) { - q->step( cur ); - nw->step( 0.25f ); - } - result = rqu.numMatches_; - if( result > maxRecords ) { - result = maxRecords; - } - if( result > 0 ) { - for( int ix = 0; ix < result; ++ix ) { - outRecords[ix] = rqu.matches_[ix]; - } - } - -error: - c->dispose(); - q->dispose(); - s->dispose(); - - return result; -} - - -#include "test_fakes.h" - -namespace libintroduce { -extern int swallowWarnings; -} - - -void Unittest_Roster() -{ - TestFakeSock fakeSock; - TestRosterUser tru; - TestFakeClock clock; - char str[ 512 ]; - - // verify lifetime with provided socket - I_Roster * r = CreateRoster( (I_Clock *)&clock, (I_Socket *)&fakeSock, &tru ); - assert( r->network() == (I_Network *)&fakeSock ); - assert( r->socket() == (I_Socket *)&fakeSock ); - assert( r->rosterUser() == (I_RosterUser *)&tru ); - Message msg; - msg.put( "root" ); - msg.put( "password" ); - ProtoHeader::prepend( Connect, msg ); - fakeSock.sockUser_->onConnection( &fakeSock, fakeSock.peer_.peerAddress_, msg.buf_, msg.size_ ); - r->step(); - assert( fakeSock.gotCreatePeer_ ); fakeSock.gotCreatePeer_ = false; - r->addRecord( fakeSock.peer_.peerAddress_, "name=blah;size=3;time=now", 1 ); - r->addRecord( fakeSock.peer_.peerAddress_, "blarg=0", 2 ); - // make sure we replace correctly - r->addRecord( fakeSock.peer_.peerAddress_, "name=booh;size=2;time=then", 2 ); - r->step(); - MatchedRecord matches[ 10 ]; - int m = r->matchRecords( "name=blah", matches, 10, 1.0f ); - assert( m == 1 ); - m = r->matchRecords( "name=b%;size<3", matches, 10, 0.5f ); - assert( m == 2 ); - m = r->matchRecords( "name=b%;size<3", matches, 1, 0.5f ); - assert( m == 1 ); - m = r->matchRecords( "name=b%;size<3", matches, 10, 1.0f ); - assert( m == 1 ); - m = r->matchRecords( "name=c%;size>3", matches, 10, 0.1f ); - assert( m == 0 ); - - r->removeRecords( fakeSock.peer_.peerAddress_ ); - r->dispose(); - assert( tru.gotDisposing_ ); tru.gotDisposing_ = false; - assert( !fakeSock.gotDispose_ ); - - // verify lifetime with network-created socket - r = CreateRoster( (I_Clock *)&clock, (I_Network *)&fakeSock, 12345, &tru ); - assert( fakeSock.gotPort_ == 12345 ); - C_Roster * cr = static_cast< C_Roster * >( r ); - - // getting a message from someone who's not logged in should kick them - Message mm; - ProtoHeader::prepend( Keepalive, mm ); - ++swallowWarnings; - fakeSock.sockUser_->onConnection( &fakeSock, fakeSock.peer_.peerAddress_, mm.buf_, mm.size_ ); - assert( ((ProtoHeader *)fakeSock.peer_.message_)->type == Kick ); - - // connection with invalid name/password should not work - mm.clear(); - mm.put( "bad" ); - mm.put( "bad" ); - ProtoHeader::prepend( Connect, mm ); - ((ProtoHeader *)fakeSock.peer_.message_)->type = 0x7f; - fakeSock.sockUser_->onConnection( &fakeSock, fakeSock.peer_.peerAddress_, mm.buf_, mm.size_ ); - assert( ((ProtoHeader *)fakeSock.peer_.message_)->type == 0x7f ); - - // connection with valid name/password should work - mm.clear(); - mm.put( "root" ); - mm.put( "password" ); - ProtoHeader::prepend( Connect, mm ); - fakeSock.sockUser_->onConnection( &fakeSock, fakeSock.peer_.peerAddress_, mm.buf_, mm.size_ ); - assert( ((ProtoHeader *)fakeSock.peer_.message_)->type == ConnectAck ); - - // if we get a second connect request, it should be re-acked - ((ProtoHeader *)fakeSock.peer_.message_)->type = 0x7f; - fakeSock.peer_.user_->onMessage( &fakeSock.peer_, mm.buf_, mm.size_ ); - assert( ((ProtoHeader *)fakeSock.peer_.message_)->type == ConnectAck ); - - r->step(); - - // keepalives should not generate response traffic - mm.clear(); - ProtoHeader::prepend( Keepalive, mm ); - ((ProtoHeader *)fakeSock.peer_.message_)->type = 0x7f; - fakeSock.peer_.user_->onMessage( &fakeSock.peer_, mm.buf_, mm.size_ ); - assert( ((ProtoHeader *)fakeSock.peer_.message_)->type == 0x7f); - - // register a record - mm.clear(); - mm.put( 1 ); - mm.put( "record=1;option=true" ); - ProtoHeader::prepend( Record, mm ); - fakeSock.peer_.user_->onMessage( &fakeSock.peer_, mm.buf_, mm.size_ ); - mm = Message( fakeSock.peer_.message_, fakeSock.peer_.messageSize_ ); - ProtoHeader ph; - assert( mm.getn( sizeof( ph ), &ph ) ); - assert( ph.type == RecordAck ); - assert( ph.size == sizeof( int ) ); - int i; - float f; - assert( mm.get( &i ) ); - assert( i == 1 ); - - // run a query - mm.clear(); - mm.put( 10 ); // query identifier - mm.put( "option=true" ); // query string - ProtoHeader::prepend( Query, mm ); - fakeSock.peer_.user_->onMessage( &fakeSock.peer_, mm.buf_, mm.size_ ); - mm = Message( fakeSock.peer_.message_, fakeSock.peer_.messageSize_ ); - assert( mm.getn( sizeof( ph ), &ph ) ); - assert( ph.type == Answer ); - assert( mm.get( &i ) ); - assert( i == 10 ); - assert( mm.get( &i ) ); - assert( i == 1 ); - assert( mm.get( &i ) ); - assert( i == 0 ); - assert( mm.get( &f ) ); - assert( f == 1.0 ); - assert( mm.get( str, sizeof( str ) ) ); - assert( !strcmp( str, "record=1;option=true" ) ); - sort_sockaddr_in sin; - assert( mm.getn( sizeof( sin ), &sin ) ); - assert( sin == fakeSock.peer_.peerAddress_ ); - assert( mm.size_ == mm.base_ ); - - // shouldn't be kicked the first time (still within timeout) - clock.time_ += C_Roster::peerTimeout_/2 + 0.125f; - ((ProtoHeader *)fakeSock.peer_.message_)->type = 0x7f; - r->step(); - assert( ((ProtoHeader *)fakeSock.peer_.message_)->type == 0x7f); - - // should be kicked the second time (now outside timeout) - clock.time_ += C_Roster::peerTimeout_/2 + 0.125f; - r->step(); - assert( ((ProtoHeader *)fakeSock.peer_.message_)->type == Kick); - assert( cr->peers_.size() == 0 ); - assert( cr->records_.size() == 0 ); - - r->dispose(); - assert( tru.gotDisposing_ ); tru.gotDisposing_ = false; - assert( fakeSock.gotDispose_ ); fakeSock.gotDispose_ = false; -} - - -void Unittest_RosterQuery() -{ - // test querying - TestNetwork tnw; - MatchedRecord matches[ 10 ]; - Message m; - // add a reply for a possible Connect packet - ProtoHeader ph; - ph.type = ConnectAck; - ph.size = 0; - m.putn( sizeof( ph ), &ph ); - tnw.addReply( Connect, tnw.tfs_.peer_.peerAddress_, m ); - // add an Answer reply for a possible Query packet - m.clear(); - m.put( 1 ); - m.put( 1 ); - m.put( 0 ); - m.put( 1.0f ); - m.put( "value=1" ); - sort_sockaddr_in sin; - memset( &sin, 1, sizeof( sin ) ); - m.putn( sizeof( sin ), &sin ); - ProtoHeader::prepend( Answer, m ); - tnw.addReply( Query, tnw.tfs_.peer_.peerAddress_, m ); - int i = SimpleRosterQuery( &tnw, "host1:45234", "root", "password", "value=1", matches, 10 ); - assert( i == 1 ); - assert( sin == matches[0].addr ); - - // test adding records - TestFakeClock tfc; - I_Clock * c = &tfc; - I_RosterQuery * rq = CreateRosterQuery(); - I_Socket * sock = tnw.createSocket( 12345, 0 ); - rq->connect( sock, "server:44444", "root", "password" ); - int cnt = 0; - while( !rq->connected() ) { - assert( ++cnt < 3 ); // I should connect immediately - rq->step( c->realTime() ); - tnw.step( 0.01 ); - } - // set up fake response for Record query - m.clear(); - m.put( 42 ); - ProtoHeader::prepend( RecordAck, m ); - tnw.addReply( Record, tnw.tfs_.peer_.peerAddress_, m ); - - rq->add( "me=this;value=5", 42 ); - // Send, and ack, are the two events we expect. Give - // then a step each (although stepping network after rq - // will mean it's probably done in the first step). - for( int ix = 0; ix < 2; ++ix ) { - rq->step( c->realTime() ); - tnw.step( 0.01 ); - } - C_RosterQuery * crq = static_cast< C_RosterQuery * >( rq ); - assert( (crq->keys_.size() == 1) && (*crq->keys_.begin()).second.ack ); - - // test connecting to other peers - SIN_ADDR_UINT(sin.sin_addr) = 0x03030303; - sin.sin_port = htons( 44444 ); - m.clear(); - m.put( sin ); - ProtoHeader::prepend( IntroduceAck, m ); - tnw.addReply( IntroducePeer, tnw.tfs_.peer_.peerAddress_, m ); - TestRosterConnectionNotify trcn; - rq->notify( &trcn ); - rq->introduce( sin ); - for( int ix = 0; ix < 2; ++ix ) { - rq->step( c->realTime() ); - tnw.step( 0.01 ); - } - assert( trcn.peer_ ); - - rq->dispose(); - c->dispose(); -} - diff --git a/Tests/introduce/lib/roster.h b/Tests/introduce/lib/roster.h deleted file mode 100644 index c73860357..000000000 --- a/Tests/introduce/lib/roster.h +++ /dev/null @@ -1,104 +0,0 @@ - -#if !defined( roster_h ) -#define roster_h - -#include "network.h" -#include "clock.h" -#include "i_rosteruser.h" -#include "i_rosterquery.h" -#include "i_rosterqueryuser.h" -#include "i_rosterconnectionnotify.h" - -namespace libintroduce { - -// The Roster allows a host to export a network introduction service, -// and allows a client to find matching peers. The way this works is -// that the roster keeps a list of : -// tuples. A client can connect, giving a name and password, which the -// roster user can reject. Once accepted, the client can issue -// queries that can be matched up to the information record. The -// roster user is in control over exactly how the matching is done, -// although the Roster has a default implementation that most users -// will take advantage of. - -// For the client side interface, look at I_RosterQuery. - -class I_Socket; -class I_RosterUser; -class I_Roster; - -// Anyone wanting to host a roster can create a I_Roster, either having the -// Roster create the socket, or by borrowing an existing socket. -// If you create me with a network and port, I will create my own socket, -// and I will dispose it when I'm disposed. -I_Roster * CreateRoster( I_Clock * clock, I_Network * network, unsigned short port, I_RosterUser * user ); -// If you create me with a socket, I will not dispose that socket when disposed. -I_Roster * CreateRoster( I_Clock * clock, I_Socket * socket, I_RosterUser * user ); - - -//! The lifetime for \m record is only until you next call back into -//! the roster, or into a system that may deliver messages to the -//! roster. -struct MatchedRecord { - sockaddr_in addr; - char const * record; //!< copy this as soon as the value is returned - float score; //!< between 0 and 1 -}; - -class I_Roster { -public: - //! \f dispose() me when you're done - virtual void dispose() = 0; - // accessors for configured properties - virtual I_Clock * clock() = 0; - virtual I_Network * network() = 0; - virtual I_Socket * socket() = 0; - virtual I_RosterUser * rosterUser() = 0; - - //! \f step() me every so often, so that I can expire old peers. - virtual void step() = 0; - //! When you hear about a client that wants to register a record, call me back to - //! manage that record. A peer can have multiple records. \returns false if the - //! implementation-defined limit to record storage would be exceeded. - //! The token is passed in by the peer, and used by him/her to identify this - //! particular record (to avoid duplication). - virtual bool addRecord( sockaddr_in const & peer, char const * record, int token ) = 0; - //! \f removeRecords() removes all records associated with a peer address. - virtual void removeRecords( sockaddr_in const & peer ) = 0; - //! Match and return multiple records. Returns how many records were actually returned. - //! All returned records will have a score >= threshold. At most maxMatches records - //! will be returned. - virtual int matchRecords( char const * key, MatchedRecord * outMatches, - int maxMatches, float threshold ) = 0; - //! Send out introduction packets to both peers, to let them talk to each other. - virtual void introduce( sockaddr_in const & peer1, sockaddr_in const & peer2 ) = 0; -}; - -//! The format of a record is a list of semicolon separated variable=value values. -//! The format if a key is a list of semicolon separated variablevalue relations. -//! MatchRecord will return 1.0 if the key matches perfectly, and 0.0 if the key -//! matches not at all, compared to the values in the record. "%" matches any string. -//! It is impossible to register or match a semicolon for any value. -//! Example: -//! record: "score=1300;location=us.ca;length=20" -//! key: "score>1000;score<1200;location=us.%;length=20;importance=high" -//! return value from MatchRecord(record,key) is 0.6f; "score<1200" is not true, -//! and "importance=high" is not true (query attributes missing in the record are -//! always assumed not matching). -//! For strings, '=' and '=' with wildcard (%) are the only allowed operations. -//! For integers, '<', '=' and '>' are the allowed operations. -//! String values cannot start with a digit. -//! There is a 63-character limit on each individual variable name length, and a -//! 255-character limit on each variable value length. There is a ~1300 byte limit -//! on the total length of a record. Note that the underlying protocol restricts -//! these numbers further; down to about 230 characters per record at the most. -//! UTF-8 strings will work with this function. -//! The record MUST BE tightly spaced; whitespace is significant! -//! "var=value;var2=value2" is very different from "var = value; var2=value2". -float MatchRecord( char const * record, char const * key ); - -} - -#include "roster_protocol.h" - -#endif // roster_h diff --git a/Tests/introduce/lib/roster_protocol.h b/Tests/introduce/lib/roster_protocol.h deleted file mode 100644 index b26c1e5f4..000000000 --- a/Tests/introduce/lib/roster_protocol.h +++ /dev/null @@ -1,58 +0,0 @@ - -#if !defined( roster_protocol_h ) -#define roster_protocol_h - -#include "message.h" - -namespace libintroduce { - -//! All packets in my protocol start with \c ProtoHeader. -//! \note I haven't taken the trouble to make this protocol endian -//! safe. Use it only on machines all of the same kind. -//! To make determining this a little better (and make it possible -//! to wire them up in the future), the "type" field should be -//! or-ed with \e TypeBigEndian if sent from a big-endian machine. -//! The \c C_Roster class has a static named \m bigEndian_ which -//! I can bit-or in for this particular purpose. -//! Note that making "size" be an unsigned byte restricts the maximum -//! message size, compared to what the underlying transport can deal -//! with. On a modem, 256 bytes takes 100 milliseconds to send, so -//! it's probably a good idea to keep this restriction. - -struct ProtoHeader { - unsigned char type; - unsigned char size; - //! When creating a message for sending, you can first create the - //! entire message (minus header) and then prepend a protoheader - //! using ProtoHeader::prepend( Type, theMessage ); this is very - //! convenient. - static bool prepend( unsigned char t, Message & m ) { - ProtoHeader ph; - ph.type = t; - ph.size = m.size_; - return m.prepend( ph ); - } -}; - -//! The "type" field of \c ProtoHeader can take the following values. -enum ProtoHeader_Type { - Keepalive = 0, //!< client->server - Connect = 1, //!< client->server - ConnectAck = 2, //!< server->client - Disconnect = 3, //!< client->server (not acked) - Record = 4, //!< client->server - RecordAck = 5, //!< server->client - Query = 6, //!< client->server (answer is ack) - Answer = 7, //!< server->client - Kick = 8, //!< server->client - IntroducePeer = 9, //!< client->server - IntroduceAck = 10, //!< server->client - - User = 32, //!< user types can start numbering here - - TypeBigEndian = 0x80, //!< OR this in on a big-endian host -}; - -} - -#endif // roster_protocol_h diff --git a/Tests/introduce/lib/sock_port.cpp b/Tests/introduce/lib/sock_port.cpp deleted file mode 100644 index 312ececc1..000000000 --- a/Tests/introduce/lib/sock_port.cpp +++ /dev/null @@ -1,580 +0,0 @@ - -#include "sock_port.h" - -#if NEED_GETTIMEOFDAY - #if defined( WIN32 ) - -#include -#include -#include -#include - -#pragma comment( lib, "winmm.lib" ) -#pragma comment( lib, "ws2_32.lib" ) - - -namespace { - -// This class could be made cheaper using RDTSC for short-term -// measurement. But, whatever. -class init_gettimeofday -{ - public: - init_gettimeofday() - { - timeBeginPeriod( 2 ); - __int64 rr; - QueryPerformanceFrequency( (LARGE_INTEGER *)&rr ); - ticksPerSecInv_ = 1.0 / (double)((DWORD)rr & 0xffffffff); - int watchdog = 0; - again: - lastTicks_ = timeGetTime(); - QueryPerformanceCounter( (LARGE_INTEGER *)&lastRead_ ); - timeb tb; - ftime( &tb ); - timeOffset_ = tb.time + tb.millitm * 0.001 - lastRead_ * ticksPerSecInv_; - lastTime_ = timeOffset_; - // make sure it didn't take too long - if( watchdog++ < 10 && (timeGetTime() != lastTicks_) ) { - goto again; - } - } - ~init_gettimeofday() - { - timeEndPeriod( 2 ); - } - - void get( timeval * tv ) - { - __int64 nu; - int watchdog = 0; - again: - DWORD m = timeGetTime(); - QueryPerformanceCounter( (LARGE_INTEGER *)&nu ); - DWORD n = timeGetTime(); - // guard against pre-emption - if( (watchdog++ < 10) && (n != m) ) { - goto again; - } - double nuTime = nu * ticksPerSecInv_ + timeOffset_; - if( (nu - lastRead_) & 0x7fffffff80000000ULL ) { - // there's a chance that we're seeing a jump-ahead - double adjust = (nuTime - lastTime_ - (n - lastTicks_) * 0.001); - if( adjust > 0.1f ) { - timeOffset_ -= adjust; - nuTime -= adjust; - assert( nuTime >= lastTime_ ); - } - } - lastRead_ = nu; - lastTicks_ = n; - lastTime_ = nuTime; - tv->tv_sec = (ulong)floor( nuTime ); - tv->tv_usec = (ulong)(1000000 * (nuTime - tv->tv_sec)); - } - - double ticksPerSecInv_; - double timeOffset_; - double lastTime_; - __int64 lastRead_; - DWORD lastTicks_; -}; - -} - -void gettimeofday( timeval * tv, int ) -{ - static init_gettimeofday data; - data.get( tv ); -} - - #else - #error "don't know how to do this" - #endif -#endif - -#if TIME_MAIN - -int main() -{ - struct timeval ta, tb; - gettimeofday( &ta, 0 ); - while( 1 ) { - fprintf( stderr, "0x%08lx:0x%08lx\n", ta.tv_sec, ta.tv_usec ); - do { - gettimeofday( &tb, 0 ); - } - while( ta.tv_sec == tb.tv_sec ); - ta = tb; - } - return 0; -} - -#endif - - -#if NEED_WINDOWS_POLL - #if defined( WIN32 ) - -#include -#include -#include - -// This is somewhat less than ideal -- better would be if we could -// abstract pollfd enough that it's non-copying on Windows. -int poll( pollfd * iofds, size_t count, int ms ) -{ - FD_SET rd, wr, ex; - FD_ZERO( &rd ); - FD_ZERO( &wr ); - FD_ZERO( &ex ); - SOCKET m = 0; - for( size_t ix = 0; ix < count; ++ix ) { - iofds[ix].revents = 0; - if( iofds[ix].fd >= m ) { - m = iofds[ix].fd + 1; - } - if( iofds[ix].events & (POLLIN | POLLPRI) ) { - assert( rd.fd_count < FD_SETSIZE ); - rd.fd_array[ rd.fd_count++ ] = iofds[ix].fd; - } - if( iofds[ix].events & (POLLOUT) ) { - assert( wr.fd_count < FD_SETSIZE ); - wr.fd_array[ wr.fd_count++ ] = iofds[ix].fd; - } - assert( ex.fd_count < FD_SETSIZE ); - ex.fd_array[ ex.fd_count++ ] = iofds[ix].fd; - } - timeval tv; - tv.tv_sec = ms/1000; - tv.tv_usec = (ms - (tv.tv_sec * 1000)) * 1000; - int r = 0; - if( m == 0 ) { - ::Sleep( ms ); - } - else { - r = ::select( (int)m, (rd.fd_count ? &rd : 0), (wr.fd_count ? &wr : 0), (ex.fd_count ? &ex : 0), &tv ); - } - if( r < 0 ) { - int err = WSAGetLastError(); - errno = err; - return r; - } - r = 0; - for( size_t ix = 0; ix < count; ++ix ) { - for( size_t iy = 0; iy < rd.fd_count; ++iy ) { - if( rd.fd_array[ iy ] == iofds[ix].fd ) { - iofds[ix].revents |= POLLIN; - ++r; - break; - } - } - for( size_t iy = 0; iy < wr.fd_count; ++iy ) { - if( wr.fd_array[ iy ] == iofds[ix].fd ) { - iofds[ix].revents |= POLLOUT; - ++r; - break; - } - } - for( size_t iy = 0; iy < ex.fd_count; ++iy ) { - if( ex.fd_array[ iy ] == iofds[ix].fd ) { - iofds[ix].revents |= POLLERR; - ++r; - break; - } - } - } - return r; -} - - #else - #error "don't know how to do this" - #endif -#endif - - -#if NEED_FIREWALL_ENABLE - #if defined( WIN32 ) - - #undef _WIN32_WINNT - #define _WIN32_WINNT 0x500 - -#include -#include - -// If you get "file not found" for , then you have two options: -// -// 1) Download and install the Windows XP SP2 Platform SDK from the MSDN -// site (msdn.microsoft.com/downloads), and point Visual Studio at -// this newly installed Platform SDK. -// -// 2) Change NEED_FIREWALL_ENABLE to 0 in the include file "sock_port.h". -// -// The firewall enable feature makes the application request that it be -// added to the list of applications allowed to use networking in the -// Windows Firewall, new in XP SP2. Without this, networking applications -// may not work without disabling the Windows Firewall. (Note that the -// Windows Server 2003 version of the Platform SDK doesn't contain the -// right headers -- it's too old). -// -// The Platform SDK is the official set of headers, libraries, and -// documentation for development for Windows. More info at msdn.microsoft.com -// -#include - -#define _ASSERT assert - -namespace { - -HRESULT WindowsFirewallInitialize(OUT INetFwProfile** fwProfile) -{ - HRESULT hr = S_OK; - INetFwMgr* fwMgr = NULL; - INetFwPolicy* fwPolicy = NULL; - - _ASSERT(fwProfile != NULL); - - *fwProfile = NULL; - - // Create an instance of the firewall settings manager. - hr = CoCreateInstance( - __uuidof(NetFwMgr), - NULL, - CLSCTX_INPROC_SERVER, - __uuidof(INetFwMgr), - (void**)&fwMgr - ); - if (FAILED(hr)) - { - printf("CoCreateInstance failed: 0x%08lx\n", hr); - goto error; - } - - // Retrieve the local firewall policy. - hr = fwMgr->get_LocalPolicy(&fwPolicy); - if (FAILED(hr)) - { - printf("get_LocalPolicy failed: 0x%08lx\n", hr); - goto error; - } - - // Retrieve the firewall profile currently in effect. - hr = fwPolicy->get_CurrentProfile(fwProfile); - if (FAILED(hr)) - { - printf("get_CurrentProfile failed: 0x%08lx\n", hr); - goto error; - } - -error: - - // Release the local firewall policy. - if (fwPolicy != NULL) - { - fwPolicy->Release(); - } - - // Release the firewall settings manager. - if (fwMgr != NULL) - { - fwMgr->Release(); - } - - return hr; -} - -void WindowsFirewallCleanup(IN INetFwProfile* fwProfile) -{ - // Release the firewall profile. - if (fwProfile != NULL) - { - fwProfile->Release(); - } -} - -HRESULT WindowsFirewallAppIsEnabled( - IN INetFwProfile* fwProfile, - IN const wchar_t* fwProcessImageFileName, - OUT BOOL* fwAppEnabled - ) -{ - HRESULT hr = S_OK; - BSTR fwBstrProcessImageFileName = NULL; - VARIANT_BOOL fwEnabled; - INetFwAuthorizedApplication* fwApp = NULL; - INetFwAuthorizedApplications* fwApps = NULL; - - _ASSERT(fwProfile != NULL); - _ASSERT(fwProcessImageFileName != NULL); - _ASSERT(fwAppEnabled != NULL); - - *fwAppEnabled = FALSE; - - // Retrieve the authorized application collection. - hr = fwProfile->get_AuthorizedApplications(&fwApps); - if (FAILED(hr)) - { - printf("get_AuthorizedApplications failed: 0x%08lx\n", hr); - goto error; - } - - // Allocate a BSTR for the process image file name. - fwBstrProcessImageFileName = SysAllocString(fwProcessImageFileName); - if (SysStringLen(fwBstrProcessImageFileName) == 0) - { - hr = E_OUTOFMEMORY; - printf("SysAllocString failed: 0x%08lx\n", hr); - goto error; - } - - // Attempt to retrieve the authorized application. - hr = fwApps->Item(fwBstrProcessImageFileName, &fwApp); - if (SUCCEEDED(hr)) - { - // Find out if the authorized application is enabled. - hr = fwApp->get_Enabled(&fwEnabled); - if (FAILED(hr)) - { - printf("get_Enabled failed: 0x%08lx\n", hr); - goto error; - } - - if (fwEnabled != VARIANT_FALSE) - { - // The authorized application is enabled. - *fwAppEnabled = TRUE; - - printf( - "Authorized application %lS is enabled in the firewall.\n", - fwProcessImageFileName - ); - } - else - { - printf( - "Authorized application %lS is disabled in the firewall.\n", - fwProcessImageFileName - ); - } - } - else - { - // The authorized application was not in the collection. - hr = S_OK; - - printf( - "Authorized application %lS is disabled in the firewall.\n", - fwProcessImageFileName - ); - } - -error: - - // Free the BSTR. - SysFreeString(fwBstrProcessImageFileName); - - // Release the authorized application instance. - if (fwApp != NULL) - { - fwApp->Release(); - } - - // Release the authorized application collection. - if (fwApps != NULL) - { - fwApps->Release(); - } - - return hr; -} - - -HRESULT WindowsFirewallAddApp( - IN INetFwProfile* fwProfile, - IN const wchar_t* fwProcessImageFileName, - IN const wchar_t* fwName - ) -{ - HRESULT hr = S_OK; - BOOL fwAppEnabled; - BSTR fwBstrName = NULL; - BSTR fwBstrProcessImageFileName = NULL; - INetFwAuthorizedApplication* fwApp = NULL; - INetFwAuthorizedApplications* fwApps = NULL; - - _ASSERT(fwProfile != NULL); - _ASSERT(fwProcessImageFileName != NULL); - _ASSERT(fwName != NULL); - - // First check to see if the application is already authorized. - hr = WindowsFirewallAppIsEnabled( - fwProfile, - fwProcessImageFileName, - &fwAppEnabled - ); - if (FAILED(hr)) - { - printf("WindowsFirewallAppIsEnabled failed: 0x%08lx\n", hr); - goto error; - } - - // Only add the application if it isn't already authorized. - if (!fwAppEnabled) - { - // Retrieve the authorized application collection. - hr = fwProfile->get_AuthorizedApplications(&fwApps); - if (FAILED(hr)) - { - printf("get_AuthorizedApplications failed: 0x%08lx\n", hr); - goto error; - } - - // Create an instance of an authorized application. - hr = CoCreateInstance( - __uuidof(NetFwAuthorizedApplication), - NULL, - CLSCTX_INPROC_SERVER, - __uuidof(INetFwAuthorizedApplication), - (void**)&fwApp - ); - if (FAILED(hr)) - { - printf("CoCreateInstance failed: 0x%08lx\n", hr); - goto error; - } - - // Allocate a BSTR for the process image file name. - fwBstrProcessImageFileName = SysAllocString(fwProcessImageFileName); - if (SysStringLen(fwBstrProcessImageFileName) == 0) - { - hr = E_OUTOFMEMORY; - printf("SysAllocString failed: 0x%08lx\n", hr); - goto error; - } - - // Set the process image file name. - hr = fwApp->put_ProcessImageFileName(fwBstrProcessImageFileName); - if (FAILED(hr)) - { - printf("put_ProcessImageFileName failed: 0x%08lx\n", hr); - goto error; - } - - // Allocate a BSTR for the application friendly name. - fwBstrName = SysAllocString(fwName); - if (SysStringLen(fwBstrName) == 0) - { - hr = E_OUTOFMEMORY; - printf("SysAllocString failed: 0x%08lx\n", hr); - goto error; - } - - // Set the application friendly name. - hr = fwApp->put_Name(fwBstrName); - if (FAILED(hr)) - { - printf("put_Name failed: 0x%08lx\n", hr); - goto error; - } - - // Add the application to the collection. - hr = fwApps->Add(fwApp); - if (FAILED(hr)) - { - printf("Add failed: 0x%08lx\n", hr); - goto error; - } - - printf( - "Authorized application %lS is now enabled in the firewall.\n", - fwProcessImageFileName - ); - } - -error: - - // Free the BSTRs. - SysFreeString(fwBstrName); - SysFreeString(fwBstrProcessImageFileName); - - // Release the authorized application instance. - if (fwApp != NULL) - { - fwApp->Release(); - } - - // Release the authorized application collection. - if (fwApps != NULL) - { - fwApps->Release(); - } - - return hr; -} - -} - -bool ENABLE_FIREWALL() -{ - BOOL couldEnable = false; - HRESULT hr = S_OK; - HRESULT comInit = E_FAIL; - INetFwProfile* fwProfile = NULL; - - // Initialize COM. - comInit = CoInitializeEx( - 0, - COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE - ); - - // Ignore RPC_E_CHANGED_MODE; this just means that COM has already been - // initialized with a different mode. Since we don't care what the mode is, - // we'll just use the existing mode. - if (comInit != RPC_E_CHANGED_MODE) { - hr = comInit; - if (FAILED(hr)) { - fprintf( stderr, "CoInitializeEx failed: 0x%08lx\n", hr ); - goto error; - } - } - - // Retrieve the firewall profile currently in effect. - hr = WindowsFirewallInitialize(&fwProfile); - if (FAILED(hr)) { - fprintf( stderr, "WindowsFirewallInitialize failed: 0x%08lx\n", hr ); - goto error; - } - - HMODULE hm = GetModuleHandle( 0 ); - wchar_t path[512]; - if( !GetModuleFileNameW( hm, path, sizeof(path)/sizeof(wchar_t) ) ) { - fprintf( stderr, "GetModuleFileName() failed: 0x%lx\n", GetLastError() ); - goto error; - } - - // Add the application to the authorized application collection. - hr = WindowsFirewallAddApp( - fwProfile, - path, - L"Introduction Library User" - ); - if (FAILED(hr)) { - fprintf( stderr, "WindowsFirewallAddApp failed: 0x%08lx\n", hr ); - goto error; - } - -error: - - WindowsFirewallCleanup(fwProfile); - - if (SUCCEEDED(comInit)) { - CoUninitialize(); - } - - return couldEnable != FALSE; -} - - #else - #error "don't know how to do this" - #endif -#endif diff --git a/Tests/introduce/lib/sock_port.h b/Tests/introduce/lib/sock_port.h deleted file mode 100644 index 8c9ef5579..000000000 --- a/Tests/introduce/lib/sock_port.h +++ /dev/null @@ -1,191 +0,0 @@ - -#if !defined( sock_port_h ) -#define sock_port_h - -// There are differences between Linux/Berkeley sockets and WinSock2 -// This file wraps some of the more common ones (as used by this library). - -#include - -#if defined( WIN32 ) - - #define _WIN32_WINNT 0x500 - #define _WIN32_DCOM 1 - - // Windows features go here - #include - #include - - #if !defined( NEED_SHORT_TYPES ) - #define NEED_SHORT_TYPES 1 - #endif - #if !defined( NEED_WINDOWS_POLL ) - #define NEED_WINDOWS_POLL 1 - #endif - #if !defined( NEED_GETTIMEOFDAY ) - #define NEED_GETTIMEOFDAY 1 - #endif - #if !defined( NEED_SNPRINTF ) - #define NEED_SNPRINTF 1 - #endif - #if !defined( NEED_HSTRERROR ) - #define NEED_HSTRERROR 1 - #endif - #if !defined( NEED_GETLASTERROR ) - #define NEED_GETLASTERROR 1 - #endif - #if !defined( NEED_FIREWALL_ENABLE ) - #define NEED_FIREWALL_ENABLE 1 - #endif - - typedef int socklen_t; - #define MSG_NOSIGNAL 0 - #define MAKE_SOCKET_NONBLOCKING(x,r) \ - do { u_long _x = 1; (r) = ioctlsocket( (x), FIONBIO, &_x ); } while(0) - #define NONBLOCK_MSG_SEND 0 - #define INIT_SOCKET_LIBRARY() \ - do { WSADATA wsaData; WSAStartup( MAKEWORD(2,2), &wsaData ); } while(0) - - #pragma warning( disable: 4250 ) - - #define SIN_ADDR_UINT(x) \ - ((uint&)(x).S_un.S_addr) - #define BAD_SOCKET_FD 0xffffffffU - -#else - - // Linux features go here - #include - #include - #include - #include - #include - - #if !defined( NEED_CLOSESOCKET ) - #define NEED_CLOSESOCKET 1 - #endif - #if !defined( NEED_IOCTLSOCKET ) - #define NEED_IOCTLSOCKET 1 - #endif - #if !defined( NEED_SHORT_TYPES ) - #define NEED_SHORT_TYPES 1 - #endif - #if !defined( NEED_ERRNO ) - #define NEED_ERRNO 1 - #endif - - extern int h_errno; - // hack -- I don't make it non-blocking; instead, I pass - // NONBLOCK_MSG_SEND for each call to sendto() - #define MAKE_SOCKET_NONBLOCKING(x,r) do { (r) = 0; } while(0) - #define NONBLOCK_MSG_SEND MSG_DONTWAIT - #define INIT_SOCKET_LIBRARY() do {} while(0) - - #if !defined( SOCKET ) - #define SOCKET int - #endif - #define SIN_ADDR_UINT(x) \ - ((uint&)(x).s_addr) - #define BAD_SOCKET_FD -1 - -#endif - -#if NEED_CLOSESOCKET - #define closesocket close -#endif - -#if NEED_PROTOENT - struct protoent { - int p_proto; - }; -#endif -#if NEED_GETPROTOBYNAME - inline protoent * getprotobyname( char const * s ) { - static protoent p; - if( !strcmp( s, "udp" ) ) { - p.p_proto = IPPROTO_UDP; - return &p; - } - if( !strcmp( s, "tcp" ) ) { - p.p_proto = IPPROTO_TCP; - return &p; - } - return 0; - } -#endif - -#if NEED_SHORT_TYPES - typedef unsigned long ulong; - typedef unsigned int uint; - typedef unsigned short ushort; - typedef unsigned char uchar; -#endif - -#if NEED_WINDOWS_POLL - struct pollfd { - SOCKET fd; - unsigned short events; - unsigned short revents; - }; - #define POLLIN 0x1 - #define POLLPRI 0x2 - #define POLLOUT 0x4 - #define POLLERR 0x100 - #define POLLHUP 0x200 - #define POLLNVAL 0x8000 - int poll( pollfd * iofds, size_t count, int ms ); -#endif - -#if NEED_GETTIMEOFDAY - // this is not thread safe! - void gettimeofday( timeval * otv, int ); -#endif - -#if NEED_SNPRINTF - inline int vsnprintf( char * buf, int size, char const * fmt, va_list vl ) { - int r = _vsnprintf( buf, size, fmt, vl ); - if( r < 0 ) { - buf[size-1] = 0; - r = size-1; - } - return r; - } - inline int snprintf( char * buf, int size, char const * fmt, ... ) { - va_list vl; - va_start( vl, fmt ); - int r = vsnprintf( buf, size, fmt, vl ); - va_end( vl ); - return r; - } -#endif - -#if NEED_HSTRERROR - // NOT thread safe! - inline char const * hstrerror( ulong ec ) { - static char err[ 128 ]; - snprintf( err, 128, "host error 0x%lx", ec ); - return err; - } -#endif - -#if NEED_GETLASTERROR - #define SOCKET_ERRNO WSAGetLastError() - inline bool SOCKET_WOULDBLOCK_ERROR( int e ) { return e == WSAEWOULDBLOCK; } - inline bool SOCKET_NEED_REOPEN( int e ) { return e == WSAECONNRESET; } -#endif - -#if NEED_ERRNO - #include - #define SOCKET_ERRNO errno - inline bool SOCKET_WOULDBLOCK_ERROR( int e ) { return e == EWOULDBLOCK; } - inline bool SOCKET_NEED_REOPEN( int e ) { return false; } -#endif - -#if NEED_FIREWALL_ENABLE - extern bool ENABLE_FIREWALL(); -#else - #define ENABLE_FIREWALL() true -#endif - -#endif // sock_port_h - diff --git a/Tests/introduce/lib/sort_addr.h b/Tests/introduce/lib/sort_addr.h deleted file mode 100644 index 7320d8ca0..000000000 --- a/Tests/introduce/lib/sort_addr.h +++ /dev/null @@ -1,40 +0,0 @@ - -#if !defined( sort_addr_h ) -#define sort_addr_h - -#include "sock_port.h" - -namespace libintroduce { - -// sort_sockaddr_in is a convenient wrapper around sockaddr_in, that will -// allow you to use it as a key for a std::map<>. The ordering is defined -// to be stable, but not necessarily otherwise useful in any specific way -// (because of the network byte order of data). - -struct sort_sockaddr_in : public sockaddr_in { - sort_sockaddr_in() { memset( this, 0, sizeof( *this ) ); } - sort_sockaddr_in( sockaddr_in const & o ) : sockaddr_in( o ) {} - // I don't need to care about network/host byte order here - // because all sort_sockaddr_in structs are in the same format. - bool operator==( sockaddr_in const & o ) const { - return SIN_ADDR_UINT( sin_addr ) == SIN_ADDR_UINT( o.sin_addr ) && - sin_port == o.sin_port; - } - bool operator<( sockaddr_in const & o ) const { - return SIN_ADDR_UINT( sin_addr ) < SIN_ADDR_UINT( o.sin_addr ) || - (SIN_ADDR_UINT( sin_addr ) == SIN_ADDR_UINT( o.sin_addr ) && - sin_port < o.sin_port); - } - char const * staticText() const { - static char buf[ 64 ]; - unsigned long ul = htonl( SIN_ADDR_UINT(sin_addr) ); - unsigned short us = htons( sin_port ); - sprintf( buf, "%d.%d.%d.%d:%d", ul>>24, (ul>>16)&0xff, (ul>>8)&0xff, ul&0xff, us ); - return buf; - } -}; - -} - -#endif // sort_addr_h - diff --git a/Tests/introduce/lib/test_fakes.h b/Tests/introduce/lib/test_fakes.h deleted file mode 100644 index db3c8c498..000000000 --- a/Tests/introduce/lib/test_fakes.h +++ /dev/null @@ -1,172 +0,0 @@ - -#if !defined( test_fakes_h ) -#define test_fakes_h - -#include "network.h" -#include "message.h" - -namespace libintroduce { - -class TestFakeClock : public I_Clock { - public: - TestFakeClock() : time_( 1000 ) {} - void dispose() {} - void adjust( double delta ) { time_ += delta; } - double realTime() { time_ += 0.01; return time_; } - double time_; -}; - -class TestNetworkBase { - public: - TestNetworkBase() {} - virtual void onMessageSent( char const * buf, size_t size ) = 0; -}; - -class TestFakeSockPeer : public I_SocketPeer { - public: - sockaddr_in peerAddress_; - TestNetworkBase * nbase_; - I_Socket * socket_; - I_SocketPeerUser * user_; - char message_[ 2048 ]; - int messageSize_; - TestFakeSockPeer() : messageSize_( 0 ), nbase_( 0 ) {} - virtual void dispose() { if( user_ ) user_->disposing( this ); } - virtual sockaddr_in const & peerAddress() { return peerAddress_; } - virtual I_Socket * socket() { return socket_; } - virtual I_SocketPeerUser * socketPeerUser() { return user_; } - virtual void sendMessage( void const * buf, int bSize ) { - assert( bSize < 2048 ); memcpy( message_, buf, bSize ); messageSize_ = bSize; - if( nbase_ ) nbase_->onMessageSent( message_, messageSize_ ); } -}; - -class TestFakeSock : public I_Socket, public I_Network { - public: - TestFakeSock() : gotDispose_( false ), sockUser_( 0 ), gotCreatePeer_( false ) { peer_.socket_ = this; } - - // class I_Socket - virtual void dispose() { gotDispose_ = true; if( sockUser_ ) sockUser_->disposing( this ); sockUser_ = 0; } - virtual I_Network * network() { return this; } - virtual I_SocketUser * socketUser() { return sockUser_; } - virtual void setSocketUser( I_SocketUser * user ) { sockUser_ = user; } - virtual I_SocketPeer * createPeer( sockaddr_in const & addr, I_SocketPeerUser * user ) { - gotCreatePeer_ = true; peer_.peerAddress_ = addr; peer_.user_ = user; return &peer_; } - virtual I_SocketPeer * createPeer( char const * addr, I_SocketPeerUser * user, - char * oError, int eSize ) { gotCreatePeer_ = true; memset( &peer_.peerAddress_, 2, sizeof( peer_.peerAddress_ ) ); - peer_.peerAddress_.sin_family = AF_INET; peer_.user_ = user; return &peer_; } - virtual I_SocketPeer * findPeer( sockaddr_in const & addr ) { return &peer_; } - virtual void sendMessage( sockaddr_in const & addr, void const * buf, int bSize ) { - peer_.sendMessage( buf, bSize ); } - virtual sockaddr_in address() { - sockaddr_in sin; memset( &sin, 0, sizeof( sin ) ); sin.sin_family = AF_INET; sin.sin_port = htons(gotPort_); - SIN_ADDR_UINT(sin.sin_addr) = 0x7f000001; return sin; } - // class I_Network - virtual I_Socket * createSocket( unsigned short port, I_SocketUser * user ) { gotPort_ = port; sockUser_ = user; return this; } - virtual void step( double sleepSeconds ) {} - - bool gotDispose_; - bool gotCreatePeer_; - short gotPort_; - I_SocketUser * sockUser_; - TestFakeSockPeer peer_; -}; - -class TestRosterUser : public I_RosterUser { - public: - TestRosterUser() : gotDisposing_( false ) {} - virtual void disposing( I_Roster * roster ) { gotDisposing_ = true; } - virtual bool validatePeer( I_Roster * roster, sockaddr_in const & peer, - char const * name, char const * password ) { - return (!strcmp( name, "root" ) || !strcmp( name, "guest" )) && !strcmp( password, "password" ); - } - virtual void userTimeout( I_Roster * roster, sockaddr_in const & peer ) { - } - virtual void registerRecord( I_Roster * roster, sockaddr_in const & peer, - char const * record, int token ) { - roster->addRecord( peer, record, token ); - } - virtual int matchRecords( I_Roster * roster, sockaddr_in const & peer, - char const * key, int id, MatchedRecord * outMatches, int maxMatches ) { - return roster->matchRecords( key, outMatches, maxMatches, 0.75f ); - } - - virtual void allowIntroduction( I_Roster * roster, sockaddr_in const & peer1, - sockaddr_in const & peer2 ) { - roster->introduce( peer1, peer2 ); - } - - bool gotDisposing_; -}; - -class TestRosterConnectionNotify : public I_RosterConnectionNotify { - public: - TestRosterConnectionNotify() : peer_( 0 ) {} - void disposing( I_RosterQuery * query ) { - if( peer_ ) peer_->dispose(); - peer_ = 0; - } - ~TestRosterConnectionNotify() { - if( peer_ ) peer_->dispose(); - peer_ = 0; - } - void onPeerConnection( I_RosterQuery * query, - I_Socket * socket, I_SocketPeer * peer ) { - peer_ = peer; - } - void onRosterTimeout( I_RosterQuery * query, - I_Socket * socket ) { - assert( !"not implemented" ); - } - I_SocketPeer * peer_; -}; - -class TestNetwork : public I_Network, public TestNetworkBase { - public: - TestNetwork() { tfs_.peer_.nbase_ = this; } - void addReply( int code, sockaddr_in const & addr, Message const & m ) { - Reply r; - r.code = code; r.addr = addr; r.m = m; - possibleReplies_.push_back( r ); - Reply * rp = &*possibleReplies_.rbegin(); - assert( rp->m.buf_[0] == m.buf_[0] ); - } - virtual void dispose() {} - virtual I_Socket * createSocket( unsigned short port, I_SocketUser * user ) { - return &tfs_; - } - virtual void step( double sleepSeconds ) { - if( replies_.size() ) { - std::list< Reply >::iterator i = replies_.begin(); - Reply & r = *i; - if( tfs_.gotCreatePeer_ ) { - tfs_.peer_.user_->onMessage( &tfs_.peer_, r.m.buf_, r.m.size_ ); - } - else { - tfs_.sockUser_->onConnection( &tfs_, r.addr, r.m.buf_, r.m.size_ ); - } - replies_.erase( i ); - } - } - virtual void onMessageSent( char const * buf, size_t size ) { - unsigned char ch = *(unsigned char *)buf; - for( std::list< Reply >::iterator ptr = possibleReplies_.begin(); - ptr != possibleReplies_.end(); - ++ptr ) { - if( ch == (*ptr).code ) { - replies_.push_back( *ptr ); - } - } - } - struct Reply { - int code; - sockaddr_in addr; - Message m; - }; - TestFakeSock tfs_; - std::list< Reply > replies_; - std::list< Reply > possibleReplies_; -}; - -} - -#endif // test_fakes_h diff --git a/Tests/introduce/putter/file.txt b/Tests/introduce/putter/file.txt deleted file mode 100644 index da647374a..000000000 --- a/Tests/introduce/putter/file.txt +++ /dev/null @@ -1,2 +0,0 @@ -This is a sample file. -It's just a very short text file. diff --git a/Tests/introduce/putter/putter.cpp b/Tests/introduce/putter/putter.cpp deleted file mode 100644 index 11a30ea3d..000000000 --- a/Tests/introduce/putter/putter.cpp +++ /dev/null @@ -1,381 +0,0 @@ - -#include "network.h" -#include "roster.h" -#include "clock.h" -#include "sort_addr.h" -#include "xfer_proto.h" - -#include -#include -#include -#include - -#include -#include -#include - - -#if defined( WIN32 ) -#include -#include -#define SIGHUP 3 -#include -#include -#include -#define stat64func _stat64 -#define stat64struct struct __stat64 -#define LLFMT "%Ld" -typedef __int64 int64; -#else -#include -#include -#include -typedef long long int64; -#define LLFMT "%lld" -#endif - - -#define PEER_CONNECT_RETRY 1.0 - -struct FileInfo { - std::string path; - std::string name; - fpos_t size; - bool registered; - int id; - int fd; - int fdRefCount; -}; - -std::string gUserName = "luser"; -std::string gPassword = "secret"; -int gPort = 1599; -std::string gServer = "introduce.me:1599"; // .me is not actually a TLD as of June 2004 -std::list< FileInfo > gSharedFiles; -volatile bool gDumpInfo = false; -bool gWaitForReturn; - -I_Network * gNetwork; -I_Clock * gClock; -I_RosterQuery * gRosterQuery; -I_Socket * gSocket; - -// Print a helpful command-line usage message, and quit in disgust. -void usage() -{ - fprintf( stderr, "Usage: putter [options] file ...\n" ); - fprintf( stderr, "This program will make given files available for peer-to-peer\n" ); - fprintf( stderr, "sharing, assuming a roster server is available at the roster\n" ); - fprintf( stderr, "address given. This program can be run behind a NAT firewall.\n" ); - fprintf( stderr, "Long name Short Default\n" ); - fprintf( stderr, "--user -u %s\n", gUserName.c_str() ); - fprintf( stderr, "--password -w %s\n", gPassword.c_str() ); - fprintf( stderr, "--port -p %d (local port)\n", gPort ); - fprintf( stderr, "--server -s %s\n", gServer.c_str() ); - fprintf( stderr, "--wait -z wait for return before starting\n" ); - exit( 1 ); -} - -void addFileName( char const * name ) -{ - FileInfo fi; - fi.path = name; - char const * s = strrchr( name, '/' ); - if( s ) ++s; else s = name; - fi.name = s; - stat64struct st; - if( stat64func( name, &st ) < 0 ) { - fprintf( stderr, "Cannot find file: %s\n", name ); - exit( 2 ); - } - fi.size = st.st_size; - fi.registered = false; - fi.id = int(1 + gSharedFiles.size()); - fi.fd = -1; - fi.fdRefCount = 0; - gSharedFiles.push_back( fi ); -} - -// Parse an option, if available. -int option( int num, char const ** & argv ) -{ - if( !strcmp( argv[0], "--user" ) || !strcmp( argv[0], "-u" ) ) { - if( num < 2 ) { - usage(); - } - gUserName = argv[1]; - return 2; - } - if( !strcmp( argv[0], "--password" ) || !strcmp( argv[0], "-w" ) ) { - if( num < 2 ) { - usage(); - } - gPassword = argv[1]; - return 2; - } - if( !strcmp( argv[0], "--port" ) || !strcmp( argv[0], "-p" ) ) { - if( num < 2 ) { - usage(); - } - gPort = atoi( argv[1] ); - if( gPort < 1 || gPort > 65535 ) { - fprintf( stderr, "ERROR: --port argument must be in range [1,65535]\n" ); - exit( 1 ); - } - return 2; - } - if( !strcmp( argv[0], "--server" ) || !strcmp( argv[0], "-s" ) ) { - if( num < 2 ) { - usage(); - } - gServer = argv[1]; - return 2; - } - if( !strcmp( argv[0], "--wait" ) || !strcmp( argv[0], "-z" ) ) { - gWaitForReturn = true; - return 1; - } - - return 0; -} - -// Parse all available options in argv/argc -void readOptions( int argc, char const ** argv ) -{ - int cur = 1; - ++argv; - while( cur < argc ) { - if( !strcmp( *argv, "--" ) || ((*argv)[0] != '-') ) { - if( **argv == '-' ) { - ++cur; - ++argv; - } - break; - } - int used = option( argc-cur, argv ); - if( used == 0 ) { - usage(); - } - cur += used; - argv += used; - } - while( cur < argc ) { - addFileName( *argv ); - ++argv; - ++cur; - } - if( gSharedFiles.size() == 0 ) { - fprintf( stderr, "ERROR: you must share at least one file!\n" ); - usage(); - } -} - -void setDumpInfo( int sig ) -{ - gDumpInfo = true; -} - -void installSignalHandlers() -{ - signal( SIGHUP, setDumpInfo ); -} - -void warnFunc( int level, char const * str, va_list vl ) -{ - vfprintf( stderr, str, vl ); - static FILE * f = fopen( "putter.log", "wb" ); - vfprintf( f, str, vl ); - fflush( f ); -} - -namespace { - class RosterConnectionNotify : public I_RosterConnectionNotify { - public: - RosterConnectionNotify() { - timeout_ = false; - } - virtual void disposing( I_RosterQuery * query ) { - } - virtual void onPeerConnection( I_RosterQuery * query, - I_Socket * socket, I_SocketPeer * peer ) { - log( "RosterConnectionNotify::onPeerConnection() 0x%lx peer %s\n", this, - sort_sockaddr_in( peer->peerAddress() ).staticText() ); - assert( query == gRosterQuery ); - assert( socket == gSocket ); - Peer p( peer ); - peers_[p.addr_] = p; - } - void onRosterTimeout( I_RosterQuery * query, - I_Socket * socket ) { - log( "RosterConnectionNotify::onRosterTimeout() 0x%lx\n", this ); - assert( query == gRosterQuery ); - assert( socket == gSocket ); - timeout_ = true; - } - void step( double now ) { - std::map< sort_sockaddr_in, Peer >::iterator ptr = peers_.begin(); - while( ptr != peers_.end() ) { - Peer & p = (*ptr).second; - if( !p.connected_ && p.lastSentTime_ < now ) { - // try to send again - assert( !"not implemented" ); - p.lastSentTime_ = now + PEER_CONNECT_RETRY; - } - ++ptr; - } - } - - struct Peer { - Peer() {} - Peer( I_SocketPeer * peer ) : peer_( peer ), addr_( peer->peerAddress() ), - connected_( false ), connectCount_( 0 ), lastReceivedTime_( 1e-15 ), - lastSentTime_( 1e-15 ) {} - I_SocketPeer * peer_; - sort_sockaddr_in addr_; - bool connected_; - int connectCount_; - double lastReceivedTime_; - double lastSentTime_; - }; - std::map< sort_sockaddr_in, Peer > peers_; - bool timeout_; - }; - - RosterConnectionNotify gRosterConnectionNotify; - - char const * itoa( int i ) { - static char buf[ 40 ]; - sprintf( buf, "%d", i ); - return buf; - } - - char const * lltoa( int64 ll ) { - static char buf[ 60 ]; - sprintf( buf, LLFMT, ll ); - return buf; - } -} - -void initializeNetwork() -{ - char err[100]; - gNetwork = CreateNetwork( err, 100, warnFunc ); - if( !gNetwork ) { - fprintf( stderr, "Can't create network: %s\n", err ); - exit( 2 ); - } - gClock = CreateClock(); - if( !gClock ) { - fprintf( stderr, "Can't create clock.\n" ); - exit( 2 ); - } - gRosterQuery = CreateRosterQuery(); - if( !gRosterQuery ) { - fprintf( stderr, "Can't create roster query.\n" ); - exit( 2 ); - } - for( int portAdd = 0; portAdd < 11; ++portAdd ) { - gSocket = gNetwork->createSocket( gPort+portAdd, 0 ); - if( gSocket ) { - break; - } - } - if( !gSocket ) { - fprintf( stderr, "can't bind client on any ports %d - %d\n", gPort, gPort+10 ); - exit( 2 ); - } - gRosterQuery->notify( &gRosterConnectionNotify ); - gRosterQuery->connect( gSocket, gServer.c_str(), gUserName.c_str(), gPassword.c_str() ); -} - -void addAllFiles() -{ - // Add all files to the roster. Note that it's OK to do this before - // the roster is actually connected; the roster will remember the fact - // that we want to register these keys, and register them once it - // connects to the introducer/matchmaker. - std::list< FileInfo >::iterator curFile = gSharedFiles.begin(); - while( curFile != gSharedFiles.end() ) { - std::string s = "name="; - s += (*curFile).name; - s += ";size="; - s += lltoa( (*curFile).size ); - // Adding the Id is convenient for debugging; not really necessary for - // the application. - s += ";id="; - s += itoa( (*curFile).id ); - gRosterQuery->add( s.c_str(), (*curFile).id ); - ++curFile; - } -} - -void dumpInfo() -{ - gDumpInfo = false; - fprintf( stderr, "---- PUTTER DUMP INFO ----\n" ); - fprintf( stderr, "Current time: %.2f\n", gClock->realTime() ); - fprintf( stderr, "Num files: %d\n", gSharedFiles.size() ); - fprintf( stderr, "Num peers: %d\n", gRosterConnectionNotify.peers_.size() ); - for( std::list< FileInfo >::iterator ptr = gSharedFiles.begin(); - ptr != gSharedFiles.end(); ++ptr ) { - fprintf( stderr, "File id %d: name=%s; size=%ld; fd=%d; refCount=%d; path=%s\n", - (*ptr).id, (*ptr).name.c_str(), long((*ptr).size), (*ptr).fd, (*ptr).fdRefCount, - (*ptr).path.c_str() ); - } - for( std::map< sort_sockaddr_in, RosterConnectionNotify::Peer >::iterator ptr = - gRosterConnectionNotify.peers_.begin(); ptr != gRosterConnectionNotify.peers_.end(); - ++ptr ) { - RosterConnectionNotify::Peer & p = (*ptr).second; - fprintf( stderr, "Peer %s; %s; conn count %d; last send %.2f; last recv %.2f\n", - p.addr_.staticText(), p.connected_ ? "connected" : "pending", - p.connectCount_, p.lastReceivedTime_, p.lastSentTime_ ); - } -} - -void runMainLoop() -{ - int timeoutCnt = 0; - double then = gClock->realTime(); - while( true ) { - gNetwork->step( 1 ); - gRosterQuery->step( gClock->realTime() ); - double now = gClock->realTime(); - gRosterConnectionNotify.step( now ); - if( gDumpInfo ) { - dumpInfo(); - } - if( now-then > 9.3 ) { - then = now; - log( "time %g: %s\n", now, gRosterQuery->connected() ? "connected" : "not connected" ); - if( !gRosterQuery->connected() && (++timeoutCnt > 3) ) { - warning( "timeout trying to connect\n" ); - break; - } - if( gRosterConnectionNotify.timeout_ ) { - warning( "timeout on roster connection\n" ); - break; - } - } - } -} - -void sleep10() { - ::Sleep( 5000 ); -} - -int main( int argc, char const ** argv ) -{ - atexit( sleep10 ); - readOptions( argc, argv ); - if( gWaitForReturn ) { - fprintf( stderr, "Press RETURN to continue:\n" ); - char line[ 10 ]; - fgets( line, 10, stdin ); - } - installSignalHandlers(); - initializeNetwork(); - addAllFiles(); - runMainLoop(); - - return 0; -} diff --git a/Tests/introduce/putter/putter.vcproj b/Tests/introduce/putter/putter.vcproj deleted file mode 100644 index ab0624e34..000000000 --- a/Tests/introduce/putter/putter.vcproj +++ /dev/null @@ -1,140 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Tests/introduce/putter/xfer_proto.h b/Tests/introduce/putter/xfer_proto.h deleted file mode 100644 index f1f14f1bf..000000000 --- a/Tests/introduce/putter/xfer_proto.h +++ /dev/null @@ -1,41 +0,0 @@ - -#if !defined( xfer_proto_h ) -#define xfer_proto_h - -#include "roster_protocol.h" - -// extends ProtoHeader_Type -enum Xfer_Type { - XferReqeust = User, - XferRequestAck, - XferPacketRequest, - XferPacket, - XferDisconnect, -}; - -// XferRequest -// id (client's id, int) -// name (cstring) -// bytesPerSecond (int) -- client's request - -// XferRequestAck -// id (client's id, int) (<=0 for error) -// name/error (cstring) -// numPackets (int) (if not error) -// sizeofLastPacket (int) (all packets except last contain 1024 bytes) - -// XferPacketRequest -// id (client's id, int) -// packet (int) -// numPackets (int) - -// XferPacket -// id (client's id, int) (<= 0 for error) -// packet (int) -// - -// XferDisconnect -- advisory -// - -#endif // xfer_proto_h - diff --git a/Tests/introduce/roster/roster.cpp b/Tests/introduce/roster/roster.cpp deleted file mode 100644 index e26f7823b..000000000 --- a/Tests/introduce/roster/roster.cpp +++ /dev/null @@ -1,379 +0,0 @@ - -#include "network.h" -#include "roster.h" -#include "sort_addr.h" - -#include -#include -#include -#include - -#if defined( WIN32 ) -#include -#include -#define SIGHUP 3 -#else -#include -#include -#include -#endif - -#include -#include - - -// Global variables are your friend in small programs like these. -// Note that in a high-secure environment (which this is NOT), you -// don't want to be storing plain-text passwords, you don't want -// your protocol to send plain-text passwords, and you don't even -// want to store user information in memory for long, because it -// may get paged out to disk. This app isn't all that, and doesn't -// pretend to be. -char const * gUserFile = "users.csv"; // where to read user data -int gPort = 1599; // what port to listen on -volatile bool gRescanUsers = true; // set when we receive SIGHUP, to re-read user file -I_Network * gNetwork; // the network object (socket factory) -I_Clock * gClock; // the passage of time -I_Roster * gRoster; // the main work-horse of this program -std::map< std::string, std::string > gUsers; // the list of passwords keyed by user from user file -#if !defined( NDEBUG ) -bool gSpawnDebug; // start getter and putter processes -#endif -bool gWaitForReturn; // wait for return before starting program - -// Use an anonymous namespace to avoid clashing with any other classes -// of the same name. This probably isn't necessary for this application, -// but good form in general. -namespace { - // The Roster does most of the work, but calls through this interface - // to allow us to customize operation (limit what certain users can - // do, limit number of connections from the same IP, or whatever). I - // don't particularly want to modify anything, so I just turn around - // and let the roster do as much as it can. - class RosterUser : public I_RosterUser { - public: - RosterUser() {} - void disposing( I_Roster * roster ) - { - } - bool validatePeer( I_Roster * roster, sockaddr_in const & peer, - char const * name, char const * password ) - { - // Look up the give user and password in the map we built from the user file - std::string uname( name ); - std::string upass( password ); - std::map< std::string, std::string >::iterator ptr = gUsers.find( uname ); - if( ptr == gUsers.end() ) { - warning( "user '%s' not found in user file %s\n", name, gUserFile ); - return false; - } - sort_sockaddr_in ssin( peer ); - warning( "user '%s' logged in at %s\n", name, ssin.staticText() ); - return true; - } - void userTimeout( I_Roster * roster, sockaddr_in const & peer ) - { - // I don't care about userTimeout events from the roster object - sort_sockaddr_in ssin( peer ); - log( "user timeout for %s\n", ssin.staticText() ); - } - void registerRecord( I_Roster * roster, sockaddr_in const & peer, - char const * record, int token ) - { - sort_sockaddr_in ssin( peer ); - log( "register record for %s; token %d; record '%s'\n", ssin.staticText(), token, record ); - // turn around and let the roster store this record - roster->addRecord( peer, record, token ); - } - int matchRecords( I_Roster * roster, sockaddr_in const & peer, - char const * key, int id, MatchedRecord * outMatches, int maxMatches ) - { - sort_sockaddr_in ssin( peer ); - log( "match records for %s; id %d\n", ssin.staticText(), id ); - // turn around and let the roster match this record - return roster->matchRecords( key, outMatches, maxMatches, 0.6f ); - } - void allowIntroduction( I_Roster * roster, sockaddr_in const & peer1, - sockaddr_in const & peer2 ) - { - sort_sockaddr_in ssin1( peer1 ); - sort_sockaddr_in ssin2( peer2 ); - char buf[ 64 ]; strncpy( buf, ssin1.staticText(), 64 ); buf[63] = 0; - log( "allow introduction for %s and %s\n", buf, ssin2.staticText() ); - // turn around and let the roster introduce these peers to each other - roster->introduce( peer1, peer2 ); - } - }; - // The single gRosterUser instance is what we need to create the Roster. - RosterUser gRosterUser; -} - - -// Print a usage message and exit. -void usage() -{ - fprintf( stderr, "ROSTER -- a NAT punch-through introduction server.\n" ); - fprintf( stderr, "This server must be run on a machine not behind a firewall,\n" ); - fprintf( stderr, "or you must make sure it's properly port-forwarded.\n" ); - fprintf( stderr, "Available options:\n" ); - fprintf( stderr, "Long name Short Default\n" ); - fprintf( stderr, " --users -u %s (user,password file)\n", gUserFile ); - fprintf( stderr, " --port -p %d (service port)\n", gPort ); - fprintf( stderr, " --wait -z wait for return from user before starting\n" ); -#if !defined( NDEBUG ) - fprintf( stderr, " --yo -y (debug only) spawn a getter and a putter, too\n" ); -#endif - exit( 1 ); -} - -// Parse an option, if available. -int option( int num, char const ** & argv ) -{ - if( !strcmp( argv[0], "--users" ) || !strcmp( argv[0], "-u" ) ) { - if( num < 2 ) { - usage(); - } - gUserFile = argv[1]; - return 2; - } - if( !strcmp( argv[0], "--port" ) || !strcmp( argv[0], "-p" ) ) { - if( num < 2 ) { - usage(); - } - gPort = atoi( argv[1] ); - if( gPort < 1 || gPort > 65535 ) { - fprintf( stderr, "ERROR: --port argument must be in range [1,65535]\n" ); - exit( 1 ); - } - return 2; - } -#if !defined( NDEBUG ) - if( !strcmp( argv[0], "--yo" ) || !strcmp( argv[0], "-y" ) ) { - gSpawnDebug = true; - return 1; - } -#endif - if( !strcmp( argv[0], "--wait" ) || !strcmp( argv[0], "-w" ) ) { - gWaitForReturn = true; - return 1; - } - return 0; -} - -// Parse all available options in argv/argc -void readOptions( int argc, char const ** argv ) -{ - int cur = 1; - ++argv; - while( cur < argc ) { - // how many items were used? - int used = option( argc-cur, argv ); - // if none, syntax was wrong; kvetch and bail - if( used == 0 ) { - usage(); - } - // move past to next option - cur += used; - argv += used; - } -} - -// setRescanUsers is the signal handler for SIGHUP; it arranges for -// the user file to get re-scanned as soon as the network un-blocks -// (which happens because of the signal delivery). -void setRescanUsers(int) -{ - gRescanUsers = true; -} - -// on start-up, install the necessary signal handlers -void installSignals() -{ - signal( SIGHUP, setRescanUsers ); -} - -// When creating the network, it needs a function to vector warning -// messages to. I just print to stderr. -void warnFunc( int level, char const * str, va_list vl ) -{ - vfprintf( stderr, str, vl ); - static FILE * f = fopen( "roster.log", "wb" ); - vfprintf( f, str, vl ); - fflush( f ); -} - -// Set up the network objects we need. -void initializeNetwork() -{ - char err[100]; - gNetwork = CreateNetwork( err, sizeof(err), warnFunc ); - if( !gNetwork ) { - fprintf( stderr, "ERROR: cannot create network: %s\n", err ); - exit( 2 ); - } - gClock = CreateClock(); - if( !gClock ) { - // I doubt this case actually ever happens - fprintf( stderr, "ERROR: cannot create clock\n" ); - exit( 2 ); - } - gRoster = CreateRoster( gClock, gNetwork, gPort, &gRosterUser ); - if( !gRoster ) { - fprintf( stderr, "ERROR: cannot create roster\n" ); - exit( 2 ); - } -} - -// The user file has lines of the form: -// username,password -// A line that's empty, or starts with a hash mark (#) is ignored. -// Comma (,) is not a valid character in a user name. -void rescanUsers() -{ - // don't scan again, unless we get a signal while reading - gRescanUsers = false; - char line[256]; - // nuke old users, if any (on SIGHUP) - gUsers.clear(); - // open up the user list - FILE * f = fopen( gUserFile, "rb" ); - if( f == 0 ) { - char cwd[256]; -#if defined( WIN32 ) - _getcwd( cwd, 256 ); cwd[255] = 0; -#else - getcwd( cwd, 256 ); -#endif - fprintf( stderr, "ERROR: user file '%s' not found (cwd: %s). Roster server exiting.\n", - gUserFile, cwd ); - exit( 2 ); - } - // parse out users, skipping comments and empty lines - int lineNo = 0; - while( true ) { - char * user, * password; - line[0] = 0; - fgets( line, sizeof(line), f ); - if( !line[0] ) { - break; // end of file - } - ++lineNo; - // remove newlines - char * nl = strchr( line, '\n' ); - if( nl ) *nl = 0; - nl = strchr( line, '\r' ); - if( nl ) *nl = 0; - // empty lines, and lines STARTING with a hash mark, are ignored - if( *line == '#' || !*line ) { - continue; // comment - } - user = line; - password = strchr( line, ',' ); - if( !password ) { - fprintf( stderr, "%s:%d: WARNING: bad line '%s'\n", gUserFile, lineNo, line ); - continue; - } - *password = 0; ++password; - // remember this user as legit - gUsers[user] = password; - } - fprintf( stderr, "Roster server read %d users from '%s'.\n", gUsers.size(), gUserFile ); -} - -// If we got a signal in the previous loop, then re-scan the user list. -// Make the roster do what it needs, then block waiting for network traffic. -void runMainLoop() -{ - while( true ) { - if( gRescanUsers ) { - rescanUsers(); - } - gRoster->step(); - // Why wake up every 5 seconds? Well, we want to time out inactive users, for one. - gNetwork->step( 5 ); - } -} - -#if !defined( NDEBUG ) -// Make the program come to a debuggable halt -void breakpoint() -{ - *(volatile char *)0; -} - -char const * SEError( int e ) -{ - switch( e ) { - case ERROR_FILE_NOT_FOUND: return "The specified file was not found. "; - case ERROR_PATH_NOT_FOUND: return "The specified path was not found. "; - case ERROR_BAD_FORMAT: return "The .exe file is invalid (non-Microsoft Win32 .exe or error in .exe image). "; - case SE_ERR_ACCESSDENIED: return "The operating system denied access to the specified file. "; - case SE_ERR_ASSOCINCOMPLETE: return "The file name association is incomplete or invalid. "; - case SE_ERR_DDEBUSY: return "The Dynamic Data Exchange (DDE) transaction could not be completed because other DDE transactions were being processed. "; - case SE_ERR_DDEFAIL: return "The DDE transaction failed. "; - case SE_ERR_DDETIMEOUT: return "The DDE transaction could not be completed because the request timed out. "; - case SE_ERR_DLLNOTFOUND: return "The specified dynamic-link library (DLL) was not found. "; - case SE_ERR_NOASSOC: return "There is no application associated with the given file name extension. This error will also be returned if you attempt to print a file that is not printable. "; - case SE_ERR_OOM: return "There was not enough memory to complete the operation. "; - case SE_ERR_SHARE: return "A sharing violation occurred. "; - } - return "No error"; -} - -// Spawn a getter and putter that we can use to debug the roster -void spawnDebug() -{ - char cwd[300]; - _getcwd( cwd, 256 ); - cwd[255] = 0; - fprintf( stderr, "cwd = %s\n", cwd ); - char dir[256]; - strcpy( dir, cwd ); - char * e = strrchr( cwd, '\\' ); - char * de = &dir[e-cwd]; - int r; - -#pragma warning( push ) -#pragma warning( disable: 4311 ) - - strcpy( de, "\\getter" ); - strcpy( e, "\\getter\\debug\\getter.exe" ); - fprintf( stderr, "starting %s in %s...\n", cwd, dir ); - r = (int)::ShellExecute( 0, 0, cwd, "-s localhost:1599 -p 1600 -u luser -w secret -z file.txt", dir, SW_SHOW ); - fprintf( stderr, "getter returned %d (%s)\n", r, SEError( r ) ); - - strcpy( de, "\\putter" ); - strcpy( e, "\\putter\\debug\\putter.exe" ); - fprintf( stderr, "starting %s in %s...\n", cwd, dir ); - r = (int)::ShellExecute( 0, 0, cwd, "-s localhost:1599 -p 1611 -u luser -w secret -z file.txt", dir, SW_SHOW ); - fprintf( stderr, "putter returned %d (%s)\n", r, SEError( r ) ); - -#pragma warning( pop ) - - fprintf( stderr, "starting roster...\n" ); -} -#endif - -int main( int argc, char const ** argv ) -{ -#if !defined( NDEBUG ) - // In debug mode, I want to know why the program exits. - atexit( breakpoint ); -#endif - readOptions( argc, argv ); - if( gWaitForReturn ) { - fprintf( stderr, "Press RETURN to continue:\n" ); - char line[ 10 ]; - fgets( line, 10, stdin ); - } -#if !defined( NDEBUG ) - // In debug mode, we might want to start a troika of processes - if( gSpawnDebug ) { - spawnDebug(); - } -#endif - installSignals(); // SIGHUP means rescan users - initializeNetwork(); // create the socket, etc - runMainLoop(); // read and process packets - return 0; -} diff --git a/Tests/introduce/roster/roster.vcproj b/Tests/introduce/roster/roster.vcproj deleted file mode 100644 index e0bacfe64..000000000 --- a/Tests/introduce/roster/roster.vcproj +++ /dev/null @@ -1,137 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Tests/introduce/roster/users.csv b/Tests/introduce/roster/users.csv deleted file mode 100644 index c7b7fa9fe..000000000 --- a/Tests/introduce/roster/users.csv +++ /dev/null @@ -1,2 +0,0 @@ -# This sample file has only one user -luser,secret diff --git a/Tests/test.3ds b/Tests/test.3ds deleted file mode 100644 index 995f0d4ff..000000000 Binary files a/Tests/test.3ds and /dev/null differ diff --git a/Tests/wall.jpg b/Tests/wall.jpg deleted file mode 100644 index b63c22607..000000000 Binary files a/Tests/wall.jpg and /dev/null differ diff --git a/Viewer/English.lproj/InfoPlist.strings b/Viewer/English.lproj/InfoPlist.strings new file mode 100644 index 000000000..477b28ff8 --- /dev/null +++ b/Viewer/English.lproj/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ + diff --git a/Viewer/FrameTimer.cpp b/Viewer/FrameTimer.cpp new file mode 100644 index 000000000..9e3c3a503 --- /dev/null +++ b/Viewer/FrameTimer.cpp @@ -0,0 +1,98 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +float g_frametime=0.0001f; + +float g_fStartOfFrame, g_fEndOfFrame, g_fRateInv; + +#ifdef WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#include + +__int64 StartClk; + +void InitFrameTimer() +{ + __int64 Rate; + g_fRateInv = 1.0f/(float)CLOCKS_PER_SEC; + + if( !QueryPerformanceFrequency( ( LARGE_INTEGER* )&Rate) ) + return; + + if(!Rate) + return; + + g_fRateInv=1.0f/(float)Rate; + if(!QueryPerformanceCounter( ( LARGE_INTEGER* )&StartClk) ) + return; + +} + +float CurrentTime_() +{ + __int64 EndClk; + QueryPerformanceCounter(( LARGE_INTEGER* )&EndClk); + return ( EndClk - StartClk )*g_fRateInv; +} + +#else +#include + +timeval StartTime; + +/* + * Initialise the frame counter + */ +void InitFrameTimer() +{ + gettimeofday(&StartTime, NULL); +} + +/* + * Get the current time + */ +float CurrentTime_() +{ + timeval currentTime; + gettimeofday(¤tTime, NULL); + + timeval elapsedtp; + timersub(¤tTime, &StartTime, &elapsedtp); + + float elapsedSec = (double)elapsedtp.tv_sec + (double)elapsedtp.tv_usec/1000000.0; + return elapsedSec; +} + +#endif + +void SortFrameTimer() +{ + do + { + g_fEndOfFrame= CurrentTime_(); + } + while(g_fEndOfFrame==g_fStartOfFrame); + + g_frametime = g_fEndOfFrame - g_fStartOfFrame ; + g_fStartOfFrame = g_fEndOfFrame ; +} + +float FrameTime() +{ + return g_frametime; +} + diff --git a/Viewer/FrameTimer.h b/Viewer/FrameTimer.h new file mode 100644 index 000000000..7a6c09308 --- /dev/null +++ b/Viewer/FrameTimer.h @@ -0,0 +1,28 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef __FRAMETIMER_H___ +#define __FRAMETIMER_H___ + +void InitFrameTimer(); + +void SortFrameTimer(); + +float FrameTime(); + +#endif + + diff --git a/Viewer/Viewer-Info.plist b/Viewer/Viewer-Info.plist new file mode 100644 index 000000000..f5e01d9a9 --- /dev/null +++ b/Viewer/Viewer-Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIconFile + + CFBundleIdentifier + com.yourcompany.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleSignature + ???? + CFBundleShortVersionString + 1.0 + LSMinimumSystemVersion + ${MACOSX_DEPLOYMENT_TARGET} + CFBundleVersion + 1 + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/Viewer/Viewer.vcproj b/Viewer/Viewer.vcproj new file mode 100644 index 000000000..df03891d9 --- /dev/null +++ b/Viewer/Viewer.vcproj @@ -0,0 +1,358 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Viewer/Viewer.xcodeproj/junmura.mode1v3 b/Viewer/Viewer.xcodeproj/junmura.mode1v3 new file mode 100644 index 000000000..5681d047c --- /dev/null +++ b/Viewer/Viewer.xcodeproj/junmura.mode1v3 @@ -0,0 +1,1409 @@ + + + + + ActivePerspectiveName + Project + AllowedModules + + + BundleLoadPath + + MaxInstances + n + Module + PBXSmartGroupTreeModule + Name + Groups and Files Outline View + + + BundleLoadPath + + MaxInstances + n + Module + PBXNavigatorGroup + Name + Editor + + + BundleLoadPath + + MaxInstances + n + Module + XCTaskListModule + Name + Task List + + + BundleLoadPath + + MaxInstances + n + Module + XCDetailModule + Name + File and Smart Group Detail Viewer + + + BundleLoadPath + + MaxInstances + 1 + Module + PBXBuildResultsModule + Name + Detailed Build Results Viewer + + + BundleLoadPath + + MaxInstances + 1 + Module + PBXProjectFindModule + Name + Project Batch Find Tool + + + BundleLoadPath + + MaxInstances + n + Module + XCProjectFormatConflictsModule + Name + Project Format Conflicts List + + + BundleLoadPath + + MaxInstances + n + Module + PBXBookmarksModule + Name + Bookmarks Tool + + + BundleLoadPath + + MaxInstances + n + Module + PBXClassBrowserModule + Name + Class Browser + + + BundleLoadPath + + MaxInstances + n + Module + PBXCVSModule + Name + Source Code Control Tool + + + BundleLoadPath + + MaxInstances + n + Module + PBXDebugBreakpointsModule + Name + Debug Breakpoints Tool + + + BundleLoadPath + + MaxInstances + n + Module + XCDockableInspector + Name + Inspector + + + BundleLoadPath + + MaxInstances + n + Module + PBXOpenQuicklyModule + Name + Open Quickly Tool + + + BundleLoadPath + + MaxInstances + 1 + Module + PBXDebugSessionModule + Name + Debugger + + + BundleLoadPath + + MaxInstances + 1 + Module + PBXDebugCLIModule + Name + Debug Console + + + BundleLoadPath + + MaxInstances + n + Module + XCSnapshotModule + Name + Snapshots Tool + + + BundlePath + /Developer/Library/PrivateFrameworks/DevToolsInterface.framework/Resources + Description + DefaultDescriptionKey + DockingSystemVisible + + Extension + mode1v3 + FavBarConfig + + PBXProjectModuleGUID + DA80EBEB10916569001A2D3B + XCBarModuleItemNames + + XCBarModuleItems + + + FirstTimeWindowDisplayed + + Identifier + com.apple.perspectives.project.mode1v3 + MajorVersion + 33 + MinorVersion + 0 + Name + Default + Notifications + + OpenEditors + + PerspectiveWidths + + -1 + -1 + + Perspectives + + + ChosenToolbarItems + + active-combo-popup + action + NSToolbarFlexibleSpaceItem + debugger-enable-breakpoints + buildOrClean + build-and-go + com.apple.ide.PBXToolbarStopButton + get-info + NSToolbarFlexibleSpaceItem + com.apple.pbx.toolbar.searchfield + + ControllerClassBaseName + + IconName + WindowOfProjectWithEditor + Identifier + perspective.project + IsVertical + + Layout + + + BecomeActive + + ContentConfiguration + + PBXBottomSmartGroupGIDs + + 1C37FBAC04509CD000000102 + 1C37FAAC04509CD000000102 + 1C37FABC05509CD000000102 + 1C37FABC05539CD112110102 + E2644B35053B69B200211256 + 1C37FABC04509CD000100104 + 1CC0EA4004350EF90044410B + 1CC0EA4004350EF90041110B + + PBXProjectModuleGUID + 1CE0B1FE06471DED0097A5F4 + PBXProjectModuleLabel + Files + PBXProjectStructureProvided + yes + PBXSmartGroupTreeModuleColumnData + + PBXSmartGroupTreeModuleColumnWidthsKey + + 288 + + PBXSmartGroupTreeModuleColumnsKey_v4 + + MainColumn + + + PBXSmartGroupTreeModuleOutlineStateKey_v7 + + PBXSmartGroupTreeModuleOutlineStateExpansionKey + + 29B97314FDCFA39411CA2CEA + 1C37FBAC04509CD000000102 + DA55992B1094CC55001E7255 + DA55992C1094CC55001E7255 + 1C37FAAC04509CD000000102 + 1C37FABC05509CD000000102 + + PBXSmartGroupTreeModuleOutlineStateSelectionKey + + + 14 + 13 + + + PBXSmartGroupTreeModuleOutlineStateVisibleRectKey + {{0, 0}, {288, 886}} + + PBXTopSmartGroupGIDs + + XCIncludePerspectivesSwitch + + XCSharingToken + com.apple.Xcode.GFSharingToken + + GeometryConfiguration + + Frame + {{0, 0}, {305, 904}} + GroupTreeTableConfiguration + + MainColumn + 288 + + RubberWindowFrame + 710 58 1209 945 0 0 1920 1178 + + Module + PBXSmartGroupTreeModule + Proportion + 305pt + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + 1CE0B20306471E060097A5F4 + PBXProjectModuleLabel + main.cpp + PBXSplitModuleInNavigatorKey + + Split0 + + PBXProjectModuleGUID + 1CE0B20406471E060097A5F4 + PBXProjectModuleLabel + main.cpp + _historyCapacity + 0 + bookmark + DA55992F1094CC55001E7255 + history + + DA55984B1094B6B6001E7255 + DA55992D1094CC55001E7255 + DA55992E1094CC55001E7255 + + + SplitCount + 1 + + StatusBarVisibility + + + GeometryConfiguration + + Frame + {{0, 0}, {899, 710}} + RubberWindowFrame + 710 58 1209 945 0 0 1920 1178 + + Module + PBXNavigatorGroup + Proportion + 710pt + + + ContentConfiguration + + PBXProjectModuleGUID + 1CE0B20506471E060097A5F4 + PBXProjectModuleLabel + Detail + + GeometryConfiguration + + Frame + {{0, 715}, {899, 189}} + RubberWindowFrame + 710 58 1209 945 0 0 1920 1178 + + Module + XCDetailModule + Proportion + 189pt + + + Proportion + 899pt + + + Name + Project + ServiceClasses + + XCModuleDock + PBXSmartGroupTreeModule + XCModuleDock + PBXNavigatorGroup + XCDetailModule + + TableOfContents + + DA55986C1094B742001E7255 + 1CE0B1FE06471DED0097A5F4 + DA55986D1094B742001E7255 + 1CE0B20306471E060097A5F4 + 1CE0B20506471E060097A5F4 + + ToolbarConfigUserDefaultsMinorVersion + 2 + ToolbarConfiguration + xcode.toolbar.config.defaultV3 + + + ControllerClassBaseName + + IconName + WindowOfProject + Identifier + perspective.morph + IsVertical + 0 + Layout + + + BecomeActive + 1 + ContentConfiguration + + PBXBottomSmartGroupGIDs + + 1C37FBAC04509CD000000102 + 1C37FAAC04509CD000000102 + 1C08E77C0454961000C914BD + 1C37FABC05509CD000000102 + 1C37FABC05539CD112110102 + E2644B35053B69B200211256 + 1C37FABC04509CD000100104 + 1CC0EA4004350EF90044410B + 1CC0EA4004350EF90041110B + + PBXProjectModuleGUID + 11E0B1FE06471DED0097A5F4 + PBXProjectModuleLabel + Files + PBXProjectStructureProvided + yes + PBXSmartGroupTreeModuleColumnData + + PBXSmartGroupTreeModuleColumnWidthsKey + + 186 + + PBXSmartGroupTreeModuleColumnsKey_v4 + + MainColumn + + + PBXSmartGroupTreeModuleOutlineStateKey_v7 + + PBXSmartGroupTreeModuleOutlineStateExpansionKey + + 29B97314FDCFA39411CA2CEA + 1C37FABC05509CD000000102 + + PBXSmartGroupTreeModuleOutlineStateSelectionKey + + + 0 + + + PBXSmartGroupTreeModuleOutlineStateVisibleRectKey + {{0, 0}, {186, 337}} + + PBXTopSmartGroupGIDs + + XCIncludePerspectivesSwitch + 1 + XCSharingToken + com.apple.Xcode.GFSharingToken + + GeometryConfiguration + + Frame + {{0, 0}, {203, 355}} + GroupTreeTableConfiguration + + MainColumn + 186 + + RubberWindowFrame + 373 269 690 397 0 0 1440 878 + + Module + PBXSmartGroupTreeModule + Proportion + 100% + + + Name + Morph + PreferredWidth + 300 + ServiceClasses + + XCModuleDock + PBXSmartGroupTreeModule + + TableOfContents + + 11E0B1FE06471DED0097A5F4 + + ToolbarConfiguration + xcode.toolbar.config.default.shortV3 + + + PerspectivesBarVisible + + ShelfIsVisible + + SourceDescription + file at '/Developer/Library/PrivateFrameworks/DevToolsInterface.framework/Resources/XCPerspectivesSpecificationMode1.xcperspec' + StatusbarIsVisible + + TimeStamp + 0.0 + ToolbarConfigUserDefaultsMinorVersion + 2 + ToolbarDisplayMode + 1 + ToolbarIsVisible + + ToolbarSizeMode + 1 + Type + Perspectives + UpdateMessage + The Default Workspace in this version of Xcode now includes support to hide and show the detail view (what has been referred to as the "Metro-Morph" feature). You must discard your current Default Workspace settings and update to the latest Default Workspace in order to gain this feature. Do you wish to update to the latest Workspace defaults for project '%@'? + WindowJustification + 5 + WindowOrderList + + DA5599301094CC55001E7255 + DA5598701094B742001E7255 + DA5598711094B742001E7255 + DA5598641094B725001E7255 + DA80EBEC10916569001A2D3B + 1CD10A99069EF8BA00B06720 + 1C78EAAD065D492600B07095 + /Users/junmura/character-loader/Viewer/Viewer.xcodeproj + + WindowString + 710 58 1209 945 0 0 1920 1178 + WindowToolsV3 + + + FirstTimeWindowDisplayed + + Identifier + windowTool.build + IsVertical + + Layout + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + 1CD0528F0623707200166675 + PBXProjectModuleLabel + main.cpp + StatusBarVisibility + + + GeometryConfiguration + + Frame + {{0, 0}, {876, 791}} + RubberWindowFrame + 915 78 876 1073 0 0 1920 1178 + + Module + PBXNavigatorGroup + Proportion + 791pt + + + BecomeActive + + ContentConfiguration + + PBXProjectModuleGUID + XCMainBuildResultsModuleGUID + PBXProjectModuleLabel + Build Results + XCBuildResultsTrigger_Collapse + 1021 + XCBuildResultsTrigger_Open + 1011 + + GeometryConfiguration + + Frame + {{0, 796}, {876, 236}} + RubberWindowFrame + 915 78 876 1073 0 0 1920 1178 + + Module + PBXBuildResultsModule + Proportion + 236pt + + + Proportion + 1032pt + + + Name + Build Results + ServiceClasses + + PBXBuildResultsModule + + StatusbarIsVisible + + TableOfContents + + DA80EBEC10916569001A2D3B + DA55985D1094B725001E7255 + 1CD0528F0623707200166675 + XCMainBuildResultsModuleGUID + + ToolbarConfiguration + xcode.toolbar.config.buildV3 + WindowContentMinSize + 486 300 + WindowString + 915 78 876 1073 0 0 1920 1178 + WindowToolGUID + DA80EBEC10916569001A2D3B + WindowToolIsVisible + + + + FirstTimeWindowDisplayed + + Identifier + windowTool.debugger + IsVertical + + Layout + + + Dock + + + ContentConfiguration + + Debugger + + HorizontalSplitView + + _collapsingFrameDimension + 0.0 + _indexOfCollapsedView + 0 + _percentageOfCollapsedView + 0.0 + isCollapsed + yes + sizes + + {{0, 0}, {425, 547}} + {{425, 0}, {507, 547}} + + + VerticalSplitView + + _collapsingFrameDimension + 0.0 + _indexOfCollapsedView + 0 + _percentageOfCollapsedView + 0.0 + isCollapsed + yes + sizes + + {{0, 0}, {932, 547}} + {{0, 547}, {932, 505}} + + + + LauncherConfigVersion + 8 + PBXProjectModuleGUID + 1C162984064C10D400B95A72 + PBXProjectModuleLabel + Debug - GLUTExamples (Underwater) + + GeometryConfiguration + + DebugConsoleVisible + None + DebugConsoleWindowFrame + {{200, 200}, {500, 300}} + DebugSTDIOWindowFrame + {{200, 200}, {500, 300}} + Frame + {{0, 0}, {932, 1052}} + PBXDebugSessionStackFrameViewKey + + DebugVariablesTableConfiguration + + Name + 174 + Value + 85 + Summary + 223 + + Frame + {{425, 0}, {507, 547}} + RubberWindowFrame + 982 77 932 1093 0 0 1920 1178 + + RubberWindowFrame + 982 77 932 1093 0 0 1920 1178 + + Module + PBXDebugSessionModule + Proportion + 1052pt + + + Proportion + 1052pt + + + Name + Debugger + ServiceClasses + + PBXDebugSessionModule + + StatusbarIsVisible + + TableOfContents + + 1CD10A99069EF8BA00B06720 + DA55985E1094B725001E7255 + 1C162984064C10D400B95A72 + DA55985F1094B725001E7255 + DA5598601094B725001E7255 + DA5598611094B725001E7255 + DA5598621094B725001E7255 + DA5598631094B725001E7255 + + ToolbarConfiguration + xcode.toolbar.config.debugV3 + WindowString + 982 77 932 1093 0 0 1920 1178 + WindowToolGUID + 1CD10A99069EF8BA00B06720 + WindowToolIsVisible + + + + Identifier + windowTool.find + Layout + + + Dock + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + 1CDD528C0622207200134675 + PBXProjectModuleLabel + <No Editor> + PBXSplitModuleInNavigatorKey + + Split0 + + PBXProjectModuleGUID + 1CD0528D0623707200166675 + + SplitCount + 1 + + StatusBarVisibility + 1 + + GeometryConfiguration + + Frame + {{0, 0}, {781, 167}} + RubberWindowFrame + 62 385 781 470 0 0 1440 878 + + Module + PBXNavigatorGroup + Proportion + 781pt + + + Proportion + 50% + + + BecomeActive + 1 + ContentConfiguration + + PBXProjectModuleGUID + 1CD0528E0623707200166675 + PBXProjectModuleLabel + Project Find + + GeometryConfiguration + + Frame + {{8, 0}, {773, 254}} + RubberWindowFrame + 62 385 781 470 0 0 1440 878 + + Module + PBXProjectFindModule + Proportion + 50% + + + Proportion + 428pt + + + Name + Project Find + ServiceClasses + + PBXProjectFindModule + + StatusbarIsVisible + 1 + TableOfContents + + 1C530D57069F1CE1000CFCEE + 1C530D58069F1CE1000CFCEE + 1C530D59069F1CE1000CFCEE + 1CDD528C0622207200134675 + 1C530D5A069F1CE1000CFCEE + 1CE0B1FE06471DED0097A5F4 + 1CD0528E0623707200166675 + + WindowString + 62 385 781 470 0 0 1440 878 + WindowToolGUID + 1C530D57069F1CE1000CFCEE + WindowToolIsVisible + 0 + + + Identifier + MENUSEPARATOR + + + FirstTimeWindowDisplayed + + Identifier + windowTool.debuggerConsole + IsVertical + + Layout + + + Dock + + + BecomeActive + + ContentConfiguration + + PBXProjectModuleGUID + 1C78EAAC065D492600B07095 + PBXProjectModuleLabel + Debugger Console + + GeometryConfiguration + + Frame + {{0, 0}, {1147, 812}} + RubberWindowFrame + 112 279 1147 853 0 0 1920 1178 + + Module + PBXDebugCLIModule + Proportion + 812pt + + + Proportion + 812pt + + + Name + Debugger Console + ServiceClasses + + PBXDebugCLIModule + + StatusbarIsVisible + + TableOfContents + + 1C78EAAD065D492600B07095 + DA55986E1094B742001E7255 + 1C78EAAC065D492600B07095 + + ToolbarConfiguration + xcode.toolbar.config.consoleV3 + WindowString + 112 279 1147 853 0 0 1920 1178 + WindowToolGUID + 1C78EAAD065D492600B07095 + WindowToolIsVisible + + + + Identifier + windowTool.snapshots + Layout + + + Dock + + + Module + XCSnapshotModule + Proportion + 100% + + + Proportion + 100% + + + Name + Snapshots + ServiceClasses + + XCSnapshotModule + + StatusbarIsVisible + Yes + ToolbarConfiguration + xcode.toolbar.config.snapshots + WindowString + 315 824 300 550 0 0 1440 878 + WindowToolIsVisible + Yes + + + Identifier + windowTool.scm + Layout + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + 1C78EAB2065D492600B07095 + PBXProjectModuleLabel + <No Editor> + PBXSplitModuleInNavigatorKey + + Split0 + + PBXProjectModuleGUID + 1C78EAB3065D492600B07095 + + SplitCount + 1 + + StatusBarVisibility + 1 + + GeometryConfiguration + + Frame + {{0, 0}, {452, 0}} + RubberWindowFrame + 743 379 452 308 0 0 1280 1002 + + Module + PBXNavigatorGroup + Proportion + 0pt + + + BecomeActive + 1 + ContentConfiguration + + PBXProjectModuleGUID + 1CD052920623707200166675 + PBXProjectModuleLabel + SCM + + GeometryConfiguration + + ConsoleFrame + {{0, 259}, {452, 0}} + Frame + {{0, 7}, {452, 259}} + RubberWindowFrame + 743 379 452 308 0 0 1280 1002 + TableConfiguration + + Status + 30 + FileName + 199 + Path + 197.0950012207031 + + TableFrame + {{0, 0}, {452, 250}} + + Module + PBXCVSModule + Proportion + 262pt + + + Proportion + 266pt + + + Name + SCM + ServiceClasses + + PBXCVSModule + + StatusbarIsVisible + 1 + TableOfContents + + 1C78EAB4065D492600B07095 + 1C78EAB5065D492600B07095 + 1C78EAB2065D492600B07095 + 1CD052920623707200166675 + + ToolbarConfiguration + xcode.toolbar.config.scm + WindowString + 743 379 452 308 0 0 1280 1002 + + + FirstTimeWindowDisplayed + + Identifier + windowTool.breakpoints + IsVertical + + Layout + + + Dock + + + ContentConfiguration + + PBXBottomSmartGroupGIDs + + 1C77FABC04509CD000000102 + + PBXProjectModuleGUID + 1CE0B1FE06471DED0097A5F4 + PBXProjectModuleLabel + Files + PBXProjectStructureProvided + no + PBXSmartGroupTreeModuleColumnData + + PBXSmartGroupTreeModuleColumnWidthsKey + + 168 + + PBXSmartGroupTreeModuleColumnsKey_v4 + + MainColumn + + + PBXSmartGroupTreeModuleOutlineStateKey_v7 + + PBXSmartGroupTreeModuleOutlineStateExpansionKey + + 1C77FABC04509CD000000102 + + PBXSmartGroupTreeModuleOutlineStateSelectionKey + + + 0 + + + PBXSmartGroupTreeModuleOutlineStateVisibleRectKey + {{0, 0}, {168, 350}} + + PBXTopSmartGroupGIDs + + XCIncludePerspectivesSwitch + + + GeometryConfiguration + + Frame + {{0, 0}, {185, 368}} + GroupTreeTableConfiguration + + MainColumn + 168 + + RubberWindowFrame + 669 571 744 409 0 0 1920 1178 + + Module + PBXSmartGroupTreeModule + Proportion + 185pt + + + BecomeActive + + ContentConfiguration + + PBXProjectModuleGUID + 1CA1AED706398EBD00589147 + PBXProjectModuleLabel + Detail + + GeometryConfiguration + + Frame + {{190, 0}, {554, 368}} + RubberWindowFrame + 669 571 744 409 0 0 1920 1178 + + Module + XCDetailModule + Proportion + 554pt + + + Proportion + 368pt + + + MajorVersion + 3 + MinorVersion + 0 + Name + Breakpoints + ServiceClasses + + PBXSmartGroupTreeModule + XCDetailModule + + StatusbarIsVisible + + TableOfContents + + DA5598641094B725001E7255 + DA5598651094B725001E7255 + 1CE0B1FE06471DED0097A5F4 + 1CA1AED706398EBD00589147 + + ToolbarConfiguration + xcode.toolbar.config.breakpointsV3 + WindowString + 669 571 744 409 0 0 1920 1178 + WindowToolGUID + DA5598641094B725001E7255 + WindowToolIsVisible + + + + Identifier + windowTool.debugAnimator + Layout + + + Dock + + + Module + PBXNavigatorGroup + Proportion + 100% + + + Proportion + 100% + + + Name + Debug Visualizer + ServiceClasses + + PBXNavigatorGroup + + StatusbarIsVisible + 1 + ToolbarConfiguration + xcode.toolbar.config.debugAnimatorV3 + WindowString + 100 100 700 500 0 0 1280 1002 + + + Identifier + windowTool.bookmarks + Layout + + + Dock + + + Module + PBXBookmarksModule + Proportion + 100% + + + Proportion + 100% + + + Name + Bookmarks + ServiceClasses + + PBXBookmarksModule + + StatusbarIsVisible + 0 + WindowString + 538 42 401 187 0 0 1280 1002 + + + Identifier + windowTool.projectFormatConflicts + Layout + + + Dock + + + Module + XCProjectFormatConflictsModule + Proportion + 100% + + + Proportion + 100% + + + Name + Project Format Conflicts + ServiceClasses + + XCProjectFormatConflictsModule + + StatusbarIsVisible + 0 + WindowContentMinSize + 450 300 + WindowString + 50 850 472 307 0 0 1440 877 + + + Identifier + windowTool.classBrowser + Layout + + + Dock + + + BecomeActive + 1 + ContentConfiguration + + OptionsSetName + Hierarchy, all classes + PBXProjectModuleGUID + 1CA6456E063B45B4001379D8 + PBXProjectModuleLabel + Class Browser - NSObject + + GeometryConfiguration + + ClassesFrame + {{0, 0}, {374, 96}} + ClassesTreeTableConfiguration + + PBXClassNameColumnIdentifier + 208 + PBXClassBookColumnIdentifier + 22 + + Frame + {{0, 0}, {630, 331}} + MembersFrame + {{0, 105}, {374, 395}} + MembersTreeTableConfiguration + + PBXMemberTypeIconColumnIdentifier + 22 + PBXMemberNameColumnIdentifier + 216 + PBXMemberTypeColumnIdentifier + 97 + PBXMemberBookColumnIdentifier + 22 + + PBXModuleWindowStatusBarHidden2 + 1 + RubberWindowFrame + 385 179 630 352 0 0 1440 878 + + Module + PBXClassBrowserModule + Proportion + 332pt + + + Proportion + 332pt + + + Name + Class Browser + ServiceClasses + + PBXClassBrowserModule + + StatusbarIsVisible + 0 + TableOfContents + + 1C0AD2AF069F1E9B00FABCE6 + 1C0AD2B0069F1E9B00FABCE6 + 1CA6456E063B45B4001379D8 + + ToolbarConfiguration + xcode.toolbar.config.classbrowser + WindowString + 385 179 630 352 0 0 1440 878 + WindowToolGUID + 1C0AD2AF069F1E9B00FABCE6 + WindowToolIsVisible + 0 + + + Identifier + windowTool.refactoring + IncludeInToolsMenu + 0 + Layout + + + Dock + + + BecomeActive + 1 + GeometryConfiguration + + Frame + {0, 0}, {500, 335} + RubberWindowFrame + {0, 0}, {500, 335} + + Module + XCRefactoringModule + Proportion + 100% + + + Proportion + 100% + + + Name + Refactoring + ServiceClasses + + XCRefactoringModule + + WindowString + 200 200 500 356 0 0 1920 1200 + + + + diff --git a/Viewer/Viewer.xcodeproj/junmura.pbxuser b/Viewer/Viewer.xcodeproj/junmura.pbxuser new file mode 100644 index 000000000..d09746913 --- /dev/null +++ b/Viewer/Viewer.xcodeproj/junmura.pbxuser @@ -0,0 +1,459 @@ +// !$*UTF8*$! +{ + 29B97313FDCFA39411CA2CEA /* Project object */ = { + activeBuildConfigurationName = Release; + activeExecutable = DA80EBDD10916566001A2D3B /* Viewer */; + activeTarget = 8D1107260486CEB800E47090 /* Viewer */; + addToTargets = ( + 8D1107260486CEB800E47090 /* Viewer */, + ); + breakpoints = ( + ); + codeSenseManager = DA80EBEF10916569001A2D3B /* Code sense */; + executables = ( + DA80EBDD10916566001A2D3B /* Viewer */, + ); + perUserDictionary = { + "PBXConfiguration.PBXBreakpointsDataSource.v1:1CA1AED706398EBD00589147" = { + PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; + PBXFileTableDataSourceColumnSortingKey = PBXBreakpointsDataSource_BreakpointID; + PBXFileTableDataSourceColumnWidthsKey = ( + 20, + 20, + 198, + 20, + 99, + 99, + 29, + 20, + ); + PBXFileTableDataSourceColumnsKey = ( + PBXBreakpointsDataSource_ActionID, + PBXBreakpointsDataSource_TypeID, + PBXBreakpointsDataSource_BreakpointID, + PBXBreakpointsDataSource_UseID, + PBXBreakpointsDataSource_LocationID, + PBXBreakpointsDataSource_ConditionID, + PBXBreakpointsDataSource_IgnoreCountID, + PBXBreakpointsDataSource_ContinueID, + ); + }; + PBXConfiguration.PBXFileTableDataSource3.PBXExecutablesDataSource = { + PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; + PBXFileTableDataSourceColumnSortingKey = PBXExecutablesDataSource_NameID; + PBXFileTableDataSourceColumnWidthsKey = ( + 22, + 300, + 548, + ); + PBXFileTableDataSourceColumnsKey = ( + PBXExecutablesDataSource_ActiveFlagID, + PBXExecutablesDataSource_NameID, + PBXExecutablesDataSource_CommentsID, + ); + }; + PBXConfiguration.PBXFileTableDataSource3.PBXFileTableDataSource = { + PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; + PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; + PBXFileTableDataSourceColumnWidthsKey = ( + 20, + 660, + 20, + 48, + 43, + 43, + 20, + ); + PBXFileTableDataSourceColumnsKey = ( + PBXFileDataSource_FiletypeID, + PBXFileDataSource_Filename_ColumnID, + PBXFileDataSource_Built_ColumnID, + PBXFileDataSource_ObjectSize_ColumnID, + PBXFileDataSource_Errors_ColumnID, + PBXFileDataSource_Warnings_ColumnID, + PBXFileDataSource_Target_ColumnID, + ); + }; + PBXConfiguration.PBXTargetDataSource.PBXTargetDataSource = { + PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; + PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; + PBXFileTableDataSourceColumnWidthsKey = ( + 20, + 620, + 60, + 20, + 48, + 43, + 43, + ); + PBXFileTableDataSourceColumnsKey = ( + PBXFileDataSource_FiletypeID, + PBXFileDataSource_Filename_ColumnID, + PBXTargetDataSource_PrimaryAttribute, + PBXFileDataSource_Built_ColumnID, + PBXFileDataSource_ObjectSize_ColumnID, + PBXFileDataSource_Errors_ColumnID, + PBXFileDataSource_Warnings_ColumnID, + ); + }; + PBXPerProjectTemplateStateSaveDate = 278181562; + PBXWorkspaceStateSaveDate = 278181562; + }; + perUserProjectItems = { + DA5598491094B641001E7255 /* PBXTextBookmark */ = DA5598491094B641001E7255 /* PBXTextBookmark */; + DA55984A1094B6B6001E7255 = DA55984A1094B6B6001E7255 /* PBXTextBookmark */; + DA55984B1094B6B6001E7255 = DA55984B1094B6B6001E7255 /* PBXTextBookmark */; + DA55984D1094B6B6001E7255 = DA55984D1094B6B6001E7255 /* PBXTextBookmark */; + DA55984F1094B6B6001E7255 = DA55984F1094B6B6001E7255 /* PBXTextBookmark */; + DA55986B1094B742001E7255 /* PBXTextBookmark */ = DA55986B1094B742001E7255 /* PBXTextBookmark */; + DA55988D1094B963001E7255 /* PBXTextBookmark */ = DA55988D1094B963001E7255 /* PBXTextBookmark */; + DA55988E1094B963001E7255 /* PBXTextBookmark */ = DA55988E1094B963001E7255 /* PBXTextBookmark */; + DA55988F1094B963001E7255 /* PBXTextBookmark */ = DA55988F1094B963001E7255 /* PBXTextBookmark */; + DA5598B71094C239001E7255 /* PBXTextBookmark */ = DA5598B71094C239001E7255 /* PBXTextBookmark */; + DA5598BC1094C2EA001E7255 /* PBXTextBookmark */ = DA5598BC1094C2EA001E7255 /* PBXTextBookmark */; + DA5598D01094C60F001E7255 /* PBXTextBookmark */ = DA5598D01094C60F001E7255 /* PBXTextBookmark */; + DA5598EB1094C82B001E7255 /* PBXTextBookmark */ = DA5598EB1094C82B001E7255 /* PBXTextBookmark */; + DA5598FE1094CAA6001E7255 /* PBXTextBookmark */ = DA5598FE1094CAA6001E7255 /* PBXTextBookmark */; + DA5598FF1094CAA6001E7255 /* PBXTextBookmark */ = DA5598FF1094CAA6001E7255 /* PBXTextBookmark */; + DA5599131094CB5C001E7255 /* PBXTextBookmark */ = DA5599131094CB5C001E7255 /* PBXTextBookmark */; + DA55991E1094CB82001E7255 /* PBXTextBookmark */ = DA55991E1094CB82001E7255 /* PBXTextBookmark */; + DA5599271094CC52001E7255 /* XCBuildMessageTextBookmark */ = DA5599271094CC52001E7255 /* XCBuildMessageTextBookmark */; + DA5599281094CC52001E7255 /* PBXTextBookmark */ = DA5599281094CC52001E7255 /* PBXTextBookmark */; + DA55992D1094CC55001E7255 /* PBXTextBookmark */ = DA55992D1094CC55001E7255 /* PBXTextBookmark */; + DA55992E1094CC55001E7255 /* XCBuildMessageTextBookmark */ = DA55992E1094CC55001E7255 /* XCBuildMessageTextBookmark */; + DA55992F1094CC55001E7255 /* PBXTextBookmark */ = DA55992F1094CC55001E7255 /* PBXTextBookmark */; + }; + sourceControlManager = DA80EBEE10916569001A2D3B /* Source Control */; + userBuildSettings = { + }; + }; + 8D1107260486CEB800E47090 /* Viewer */ = { + activeExec = 0; + executables = ( + DA80EBDD10916566001A2D3B /* Viewer */, + ); + }; + DA5598491094B641001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DAE2B65C10915168005ED940 /* XTextureFile.cpp */; + rLen = 1; + rLoc = 140; + rType = 1; + }; + DA55984A1094B6B6001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DA80ECA110916694001A2D3B /* main.cpp */; + name = "main.cpp: 525"; + rLen = 0; + rLoc = 10791; + rType = 0; + vrLen = 932; + vrLoc = 10346; + }; + DA55984B1094B6B6001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DA55984C1094B6B6001E7255 /* XModel.cpp */; + name = "XModel.cpp: 67"; + rLen = 0; + rLoc = 1631; + rType = 0; + vrLen = 1376; + vrLoc = 1606; + }; + DA55984C1094B6B6001E7255 /* XModel.cpp */ = { + isa = PBXFileReference; + lastKnownFileType = sourcecode.cpp.cpp; + name = XModel.cpp; + path = "/Users/junmura/character-loader/Loader/XModel.cpp"; + sourceTree = ""; + }; + DA55984D1094B6B6001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DA55984E1094B6B6001E7255 /* XTextureFile.cpp */; + name = "XTextureFile.cpp: 118"; + rLen = 0; + rLoc = 3483; + rType = 0; + vrLen = 1357; + vrLoc = 3103; + }; + DA55984E1094B6B6001E7255 /* XTextureFile.cpp */ = { + isa = PBXFileReference; + lastKnownFileType = sourcecode.cpp.cpp; + name = XTextureFile.cpp; + path = "/Users/junmura/character-loader/Loader/XTextureFile.cpp"; + sourceTree = ""; + }; + DA55984F1094B6B6001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DA5598501094B6B6001E7255 /* XTextureFile.cpp */; + name = "XTextureFile.cpp: 14"; + rLen = 0; + rLoc = 840; + rType = 0; + vrLen = 1934; + vrLoc = 0; + }; + DA5598501094B6B6001E7255 /* XTextureFile.cpp */ = { + isa = PBXFileReference; + lastKnownFileType = sourcecode.cpp.cpp; + name = XTextureFile.cpp; + path = "/Users/junmura/character-loader/Loader/XTextureFile.cpp"; + sourceTree = ""; + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {838, 2691}}"; + sepNavSelRange = "{3726, 153}"; + sepNavVisRange = "{3672, 1429}"; + }; + }; + DA55986B1094B742001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DA5598501094B6B6001E7255 /* XTextureFile.cpp */; + name = "XTextureFile.cpp: 124"; + rLen = 0; + rLoc = 3954; + rType = 0; + vrLen = 1486; + vrLoc = 3419; + }; + DA55988D1094B963001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DA80ECA110916694001A2D3B /* main.cpp */; + name = "main.cpp: 530"; + rLen = 8; + rLoc = 10924; + rType = 0; + vrLen = 756; + vrLoc = 10530; + }; + DA55988E1094B963001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DA5598501094B6B6001E7255 /* XTextureFile.cpp */; + rLen = 0; + rLoc = 129; + rType = 1; + }; + DA55988F1094B963001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DA5598501094B6B6001E7255 /* XTextureFile.cpp */; + name = "XTextureFile.cpp: 156"; + rLen = 0; + rLoc = 4876; + rType = 0; + vrLen = 1315; + vrLoc = 3178; + }; + DA5598B71094C239001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DA5598501094B6B6001E7255 /* XTextureFile.cpp */; + name = "XTextureFile.cpp: 124"; + rLen = 0; + rLoc = 3943; + rType = 0; + vrLen = 1392; + vrLoc = 3443; + }; + DA5598BC1094C2EA001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DA5598501094B6B6001E7255 /* XTextureFile.cpp */; + name = "XTextureFile.cpp: 129"; + rLen = 0; + rLoc = 3943; + rType = 0; + vrLen = 1414; + vrLoc = 3443; + }; + DA5598D01094C60F001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DA5598501094B6B6001E7255 /* XTextureFile.cpp */; + name = "XTextureFile.cpp: 125"; + rLen = 0; + rLoc = 3726; + rType = 0; + vrLen = 1379; + vrLoc = 3443; + }; + DA5598EB1094C82B001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DA5598501094B6B6001E7255 /* XTextureFile.cpp */; + name = "XTextureFile.cpp: 123"; + rLen = 153; + rLoc = 3726; + rType = 0; + vrLen = 1387; + vrLoc = 3443; + }; + DA5598FE1094CAA6001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DA5598501094B6B6001E7255 /* XTextureFile.cpp */; + name = "XTextureFile.cpp: 123"; + rLen = 153; + rLoc = 3726; + rType = 0; + vrLen = 1511; + vrLoc = 3443; + }; + DA5598FF1094CAA6001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DA5598501094B6B6001E7255 /* XTextureFile.cpp */; + name = "XTextureFile.cpp: 126"; + rLen = 0; + rLoc = 3879; + rType = 0; + vrLen = 1379; + vrLoc = 3443; + }; + DA5599131094CB5C001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DA5598501094B6B6001E7255 /* XTextureFile.cpp */; + name = "XTextureFile.cpp: 123"; + rLen = 153; + rLoc = 3726; + rType = 0; + vrLen = 1421; + vrLoc = 3672; + }; + DA55991E1094CB82001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DA5598501094B6B6001E7255 /* XTextureFile.cpp */; + name = "XTextureFile.cpp: 123"; + rLen = 153; + rLoc = 3726; + rType = 0; + vrLen = 1421; + vrLoc = 3672; + }; + DA5599271094CC52001E7255 /* XCBuildMessageTextBookmark */ = { + isa = PBXTextBookmark; + comments = "Deprecated conversion from string constant to 'char*'"; + fRef = DA80ECA110916694001A2D3B /* main.cpp */; + fallbackIsa = XCBuildMessageTextBookmark; + rLen = 1; + rLoc = 77; + rType = 1; + }; + DA5599281094CC52001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DA80ECA110916694001A2D3B /* main.cpp */; + name = "main.cpp: 78"; + rLen = 0; + rLoc = 1832; + rType = 0; + vrLen = 1532; + vrLoc = 1303; + }; + DA55992D1094CC55001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DA5598501094B6B6001E7255 /* XTextureFile.cpp */; + name = "XTextureFile.cpp: 123"; + rLen = 153; + rLoc = 3726; + rType = 0; + vrLen = 1429; + vrLoc = 3672; + }; + DA55992E1094CC55001E7255 /* XCBuildMessageTextBookmark */ = { + isa = PBXTextBookmark; + comments = "Deprecated conversion from string constant to 'char*'"; + fRef = DA80ECA110916694001A2D3B /* main.cpp */; + fallbackIsa = XCBuildMessageTextBookmark; + rLen = 1; + rLoc = 77; + rType = 1; + }; + DA55992F1094CC55001E7255 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = DA80ECA110916694001A2D3B /* main.cpp */; + name = "main.cpp: 78"; + rLen = 0; + rLoc = 1832; + rType = 0; + vrLen = 1225; + vrLoc = 1323; + }; + DA80EBDD10916566001A2D3B /* Viewer */ = { + isa = PBXExecutable; + activeArgIndices = ( + YES, + ); + argumentStrings = ( + "masha-simple-bind-all.scene", + ); + autoAttachOnCrash = 1; + breakpointsEnabled = 1; + configStateDict = { + "PBXLSLaunchAction-0" = { + PBXLSLaunchAction = 0; + PBXLSLaunchStartAction = 1; + PBXLSLaunchStdioStyle = 2; + PBXLSLaunchStyle = 0; + class = PBXLSRunLaunchConfig; + commandLineArgs = ( + ); + displayName = "Executable Runner"; + environment = { + }; + identifier = com.apple.Xcode.launch.runConfig; + remoteHostInfo = ""; + startActionInfo = ""; + }; + }; + customDataFormattersEnabled = 1; + dataTipCustomDataFormattersEnabled = 1; + dataTipShowTypeColumn = 1; + dataTipSortType = 0; + debuggerPlugin = GDBDebugging; + disassemblyDisplayState = 0; + dylibVariantSuffix = ""; + enableDebugStr = 1; + environmentEntries = ( + ); + executableSystemSymbolLevel = 0; + executableUserSymbolLevel = 0; + libgmallocEnabled = 0; + name = Viewer; + savedGlobals = { + }; + showTypeColumn = 0; + sourceDirectories = ( + ); + startupPath = "/Users/junmura/character-loader/data2009"; + variableFormatDictionary = { + }; + }; + DA80EBEE10916569001A2D3B /* Source Control */ = { + isa = PBXSourceControlManager; + fallbackIsa = XCSourceControlManager; + isSCMEnabled = 0; + scmConfiguration = { + repositoryNamesForRoots = { + "" = ""; + }; + }; + }; + DA80EBEF10916569001A2D3B /* Code sense */ = { + isa = PBXCodeSenseManager; + indexTemplatePath = ""; + }; + DA80ECA110916694001A2D3B /* main.cpp */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {922, 7293}}"; + sepNavSelRange = "{1832, 0}"; + sepNavVisRange = "{1323, 1225}"; + sepNavWindowFrame = "{{78, 102}, {734, 1071}}"; + }; + }; + DAE2B65C10915168005ED940 /* XTextureFile.cpp */ = { + isa = PBXFileReference; + fileEncoding = 4; + lastKnownFileType = sourcecode.cpp.cpp; + name = XTextureFile.cpp; + path = Loader/XTextureFile.cpp; + sourceTree = ""; + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {922, 2626}}"; + sepNavSelRange = "{4931, 0}"; + sepNavVisRange = "{0, 2303}"; + }; + }; +} diff --git a/Viewer/Viewer.xcodeproj/project.pbxproj b/Viewer/Viewer.xcodeproj/project.pbxproj new file mode 100644 index 000000000..cb58b3a96 --- /dev/null +++ b/Viewer/Viewer.xcodeproj/project.pbxproj @@ -0,0 +1,300 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 45; + objects = { + +/* Begin PBXBuildFile section */ + 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; }; + 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; }; + DA80EBF4109165EF001A2D3B /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA80EBF3109165EF001A2D3B /* OpenGL.framework */; }; + DA80EBF8109165F8001A2D3B /* GLUT.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA80EBF7109165F8001A2D3B /* GLUT.framework */; }; + DA80EC981091661E001A2D3B /* libSkin.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DA80EC971091661E001A2D3B /* libSkin.a */; }; + DA80ECA210916694001A2D3B /* FrameTimer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DA80EC9F10916694001A2D3B /* FrameTimer.cpp */; }; + DA80ECA310916694001A2D3B /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DA80ECA110916694001A2D3B /* main.cpp */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 089C165DFE840E0CC02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = ""; }; + 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; + 13E42FB307B3F0F600E4EEF1 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = ""; }; + 29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; + 29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; + 8D1107310486CEB800E47090 /* Viewer-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Viewer-Info.plist"; sourceTree = ""; }; + 8D1107320486CEB800E47090 /* Viewer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Viewer.app; sourceTree = BUILT_PRODUCTS_DIR; }; + DA80EBF3109165EF001A2D3B /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = System/Library/Frameworks/OpenGL.framework; sourceTree = SDKROOT; }; + DA80EBF7109165F8001A2D3B /* GLUT.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GLUT.framework; path = System/Library/Frameworks/GLUT.framework; sourceTree = SDKROOT; }; + DA80EBFB1091660A001A2D3B /* data2009 */ = {isa = PBXFileReference; lastKnownFileType = folder; name = data2009; path = "/Users/junmura/character-loader/data2009"; sourceTree = ""; }; + DA80EC971091661E001A2D3B /* libSkin.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libSkin.a; path = "/Users/junmura/character-loader/data2009/Debug/libSkin.a"; sourceTree = ""; }; + DA80EC9F10916694001A2D3B /* FrameTimer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FrameTimer.cpp; sourceTree = ""; }; + DA80ECA010916694001A2D3B /* FrameTimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FrameTimer.h; sourceTree = ""; }; + DA80ECA110916694001A2D3B /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 8D11072E0486CEB800E47090 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */, + DA80EBF4109165EF001A2D3B /* OpenGL.framework in Frameworks */, + DA80EBF8109165F8001A2D3B /* GLUT.framework in Frameworks */, + DA80EC981091661E001A2D3B /* libSkin.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 080E96DDFE201D6D7F000001 /* Classes */ = { + isa = PBXGroup; + children = ( + ); + name = Classes; + sourceTree = ""; + }; + 1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */ = { + isa = PBXGroup; + children = ( + 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */, + ); + name = "Linked Frameworks"; + sourceTree = ""; + }; + 1058C7A2FEA54F0111CA2CBB /* Other Frameworks */ = { + isa = PBXGroup; + children = ( + 29B97324FDCFA39411CA2CEA /* AppKit.framework */, + 13E42FB307B3F0F600E4EEF1 /* CoreData.framework */, + 29B97325FDCFA39411CA2CEA /* Foundation.framework */, + ); + name = "Other Frameworks"; + sourceTree = ""; + }; + 19C28FACFE9D520D11CA2CBB /* Products */ = { + isa = PBXGroup; + children = ( + 8D1107320486CEB800E47090 /* Viewer.app */, + ); + name = Products; + sourceTree = ""; + }; + 29B97314FDCFA39411CA2CEA /* Viewer */ = { + isa = PBXGroup; + children = ( + DA80EC9F10916694001A2D3B /* FrameTimer.cpp */, + DA80ECA010916694001A2D3B /* FrameTimer.h */, + DA80ECA110916694001A2D3B /* main.cpp */, + 080E96DDFE201D6D7F000001 /* Classes */, + 29B97315FDCFA39411CA2CEA /* Other Sources */, + 29B97317FDCFA39411CA2CEA /* Resources */, + 29B97323FDCFA39411CA2CEA /* Frameworks */, + 19C28FACFE9D520D11CA2CBB /* Products */, + DA80EBF3109165EF001A2D3B /* OpenGL.framework */, + DA80EBF7109165F8001A2D3B /* GLUT.framework */, + DA80EBFB1091660A001A2D3B /* data2009 */, + DA80EC971091661E001A2D3B /* libSkin.a */, + ); + name = Viewer; + sourceTree = ""; + }; + 29B97315FDCFA39411CA2CEA /* Other Sources */ = { + isa = PBXGroup; + children = ( + ); + name = "Other Sources"; + sourceTree = ""; + }; + 29B97317FDCFA39411CA2CEA /* Resources */ = { + isa = PBXGroup; + children = ( + 8D1107310486CEB800E47090 /* Viewer-Info.plist */, + 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */, + ); + name = Resources; + sourceTree = ""; + }; + 29B97323FDCFA39411CA2CEA /* Frameworks */ = { + isa = PBXGroup; + children = ( + 1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */, + 1058C7A2FEA54F0111CA2CBB /* Other Frameworks */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 8D1107260486CEB800E47090 /* Viewer */ = { + isa = PBXNativeTarget; + buildConfigurationList = C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "Viewer" */; + buildPhases = ( + 8D1107290486CEB800E47090 /* Resources */, + 8D11072C0486CEB800E47090 /* Sources */, + 8D11072E0486CEB800E47090 /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Viewer; + productInstallPath = "$(HOME)/Applications"; + productName = Viewer; + productReference = 8D1107320486CEB800E47090 /* Viewer.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 29B97313FDCFA39411CA2CEA /* Project object */ = { + isa = PBXProject; + buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "Viewer" */; + compatibilityVersion = "Xcode 3.1"; + hasScannedForEncodings = 1; + mainGroup = 29B97314FDCFA39411CA2CEA /* Viewer */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 8D1107260486CEB800E47090 /* Viewer */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 8D1107290486CEB800E47090 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 8D11072C0486CEB800E47090 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + DA80ECA210916694001A2D3B /* FrameTimer.cpp in Sources */, + DA80ECA310916694001A2D3B /* main.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + 089C165DFE840E0CC02AAC07 /* English */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + C01FCF4B08A954540054247B /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(NATIVE_ARCH_ACTUAL)"; + COPY_PHASE_STRIP = NO; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_FIX_AND_CONTINUE = YES; + GCC_MODEL_TUNING = G5; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + INFOPLIST_FILE = "Viewer-Info.plist"; + INSTALL_PATH = "$(HOME)/Applications"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SRCROOT)/../data2009/Debug\"", + ); + PRODUCT_NAME = Viewer; + }; + name = Debug; + }; + C01FCF4C08A954540054247B /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(NATIVE_ARCH_ACTUAL)"; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_MODEL_TUNING = G5; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + INFOPLIST_FILE = "Viewer-Info.plist"; + INSTALL_PATH = "$(HOME)/Applications"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SRCROOT)/../data2009/Release\"", + ); + PRODUCT_NAME = Viewer; + }; + name = Release; + }; + C01FCF4F08A954540054247B /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + "../Loader/**", + "../vectormathlibrary/include/**", + ); + ONLY_ACTIVE_ARCH = YES; + PREBINDING = NO; + SDKROOT = macosx10.6; + USER_HEADER_SEARCH_PATHS = "../Loader/** ../vectormathlibrary/include/**"; + }; + name = Debug; + }; + C01FCF5008A954540054247B /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + "../Loader/**", + "../vectormathlibrary/include/**", + ); + PREBINDING = NO; + SDKROOT = macosx10.6; + USER_HEADER_SEARCH_PATHS = "../Loader/** ../vectormathlibrary/include/**"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "Viewer" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C01FCF4B08A954540054247B /* Debug */, + C01FCF4C08A954540054247B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + C01FCF4E08A954540054247B /* Build configuration list for PBXProject "Viewer" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C01FCF4F08A954540054247B /* Debug */, + C01FCF5008A954540054247B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 29B97313FDCFA39411CA2CEA /* Project object */; +} diff --git a/Viewer/main.cpp b/Viewer/main.cpp new file mode 100644 index 000000000..dc15de2c9 --- /dev/null +++ b/Viewer/main.cpp @@ -0,0 +1,665 @@ +/* +Maya Character Exporter +Copyright (c) 2009 Jun Murakawa + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#ifdef WIN32 + #include + #include +#else + #include +#endif + +#include +#include +#include + +#include "GLExtensions.h" +#include "FrameTimer.h" + +#include "XModel.h" + +#ifdef WIN32 + #include "XCgFX.h" + /// The global cgfx instance + XCgFX cgfx; +#endif + +using namespace std; + +/// The global model list +vector modelList; + +float offset = -1.0f; + +float windowWidth; +float windowHeight; + +XOptions options; + +// camera variables [default] +float zoom = 12.800001; +float rotx = 21.500000; +float roty = -51.000000; +float tx = 0.050000; +float ty = -0.800000; +float lastx = 0.000000; +float lasty = 0.000000; +float zoomStep = 0.050000; +float panStep = 0.050000; +float ROTATION = 0.000000; + +bool g_MultiSample = false; + +#define NUM_CAMERA_ATTRIBS 10 +char* cameraAttribs[NUM_CAMERA_ATTRIBS] = +{ + "zoom=", + "rotx=", + "roty=", + "tx=", + "ty=", + "lastx=", + "lasty=", + "zoomStep=", + "panStep=", + "ROTATION=", +}; + +void InitCamera( const string &fileName ) +{ + char buffer[256]; + std::ifstream ifs( fileName.c_str() ); + + int count = 0; + ifs >> buffer; assert( strcmp( buffer, cameraAttribs[count++] ) == 0 ); + ifs >> zoom; + ifs >> buffer; assert( strcmp( buffer, cameraAttribs[count++] ) == 0 ); + ifs >> rotx; + ifs >> buffer; assert( strcmp( buffer, cameraAttribs[count++] ) == 0 ); + ifs >> roty; + ifs >> buffer; assert( strcmp( buffer, cameraAttribs[count++] ) == 0 ); + ifs >> tx; + ifs >> buffer; assert( strcmp( buffer, cameraAttribs[count++] ) == 0 ); + ifs >> ty; + ifs >> buffer; assert( strcmp( buffer, cameraAttribs[count++] ) == 0 ); + ifs >> lastx; + ifs >> buffer; assert( strcmp( buffer, cameraAttribs[count++] ) == 0 ); + ifs >> lasty; + ifs >> buffer; assert( strcmp( buffer, cameraAttribs[count++] ) == 0 ); + ifs >> zoomStep; + ifs >> buffer; assert( strcmp( buffer, cameraAttribs[count++] ) == 0 ); + ifs >> panStep; + ifs >> buffer; assert( strcmp( buffer, cameraAttribs[count++] ) == 0 ); + ifs >> ROTATION; + + ifs.close(); + return; +} + +// mouse button states +unsigned char Buttons[3] = {0}; + +// mouse handler +void Mouse(int button,int state,int x,int y) +{ + lastx=x; + lasty=y; + switch(button) + { + case GLUT_LEFT_BUTTON: + Buttons[0] = ((GLUT_DOWN==state)?1:0); + break; + case GLUT_MIDDLE_BUTTON: + Buttons[1] = ((GLUT_DOWN==state)?1:0); + break; + case GLUT_RIGHT_BUTTON: + Buttons[2] = ((GLUT_DOWN==state)?1:0); + break; + default: + break; + } + +} + +// motion handler +void Motion(int x,int y) +{ + int diffx=x-lastx; + int diffy=y-lasty; + lastx=x; + lasty=y; + + if( Buttons[2] ) + { + zoom -= (float) zoomStep * diffx; + } + else + if( Buttons[0] ) + { + rotx += (float) 0.5f * diffy; + roty += (float) 0.5f * diffx; + } + else + if( Buttons[1] ) + { + tx += (float) panStep * diffx; + ty -= (float) panStep * diffy; + } +} + +void InitGL() +{ +#ifdef WIN32 + initGLExtensions(); + + SetVSync(false); + + cgfx.initCg(); +#endif + + // check multisample + GLint buffers, samples; + glGetIntegerv(GL_SAMPLE_BUFFERS, &buffers); + glGetIntegerv(GL_SAMPLES, &samples); + //printf("buffers = %d, samples = %d\n", buffers, samples); + if ( buffers > 0 && samples > 1 ) + { + g_MultiSample = true; + glEnable(GL_MULTISAMPLE); + } +} + + +/* + * drawText + * + */ +void drawText(const char * message) +{ + /* + * set viewing window in world coordinates + */ + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); /* init projection matrix */ + + //if (windowWidth <= windowHeight) + // glOrtho(-2.0, 2.0, -2.0 * (GLfloat) windowHeight / (GLfloat) windowWidth, + // 2.0 * (GLfloat) windowHeight / (GLfloat) windowWidth, -1.0, 1.0); + //else + // glOrtho(-2.0 * (GLfloat) windowWidth / (GLfloat) windowHeight, + // 2.0 * (GLfloat) windowWidth / (GLfloat) windowHeight, -2.0, 2.0, -1.0, 1.0); + + /* set matrix mode to modelview */ + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + /* transformations to scale the stroke text - + * notice how these only change stroke and raster text + * differently... + */ + glScalef(0.001f, 0.001f, 0.001f); + //glRotatef(g_rotate, 0, 0, 1.0); + /* glTranslatef(-180, -180, 0.0); */ + + glClear( GL_COLOR_BUFFER_BIT ); + + /* raster pos sets the current raster position + * mapped via the modelview and projection matrices + */ + glRasterPos2f((GLfloat)-900, (GLfloat)900);//-400); + + /* + * write using bitmap and stroke chars + */ + while (*message) + { + glutBitmapCharacter( GLUT_BITMAP_HELVETICA_18, *message++ ); + //glutStrokeCharacter(GLUT_STROKE_ROMAN,*message++); + } +} + + + +// display +void display() +{ + // set viewport and clear it + glViewport(0,0,windowWidth,windowHeight); + + glClearColor(0.65f,0.65f,0.65f,1.0f); + glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); + + // report FPS + static float frameTime = 0.0f; + static int numFrames = 0; + static char buffer[128]; + + frameTime += FrameTime(); + ++numFrames; + if(frameTime > 1.0f) + { + sprintf_s( buffer, "FPS %.1f", numFrames/frameTime ); + frameTime -= 1.0f; + numFrames = 0; + } + drawText( buffer ); + + // set gl states + glEnable(GL_DEPTH_TEST); + + if( g_MultiSample && options.m_bSampleAlphaToCoverage ) + { + // enable multisample and alpha to coverage + // http://marina.sys.wakayama-u.ac.jp/~tokoi/?date=20081122 + glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE); + } + else + { + glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE); + } + + if( options.m_bWireFrame ) + glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); + else + glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); + + if( options.m_bCulling ) + glEnable(GL_CULL_FACE); + else + glDisable(GL_CULL_FACE); + + // set gl matrices + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(10, (float)windowWidth/windowHeight, zoom/2.0f, zoom*2.0f); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + // camera transformation + glTranslatef(0,0,-zoom); + glTranslatef(tx,ty,0); + glRotatef(rotx,1,0,0); + glRotatef(roty,0,1,0); + + if (options.m_bAutoRotate) + roty += ROTATION; + + // draw grid + if(options.m_bGrid) + { + glColor3f(0.45f,0.45f,0.45f); + glBegin(GL_LINES); + for (int i=-10;i<=10;++i) + { + glVertex3i(i,0,-10); + glVertex3i(i,0,10); + + glVertex3i(-10,0,i); + glVertex3i(10,0,i); + } + glEnd(); + } + + // draw axes + if(options.m_bAxes) + { + glBegin(GL_LINES); + glColor3f(1,0,0); + glVertex3f(1,0,0); + glVertex3f(0,0,0); + + glColor3f(0,1,0); + glVertex3f(0,1,0); + glVertex3f(0,0,0); + + glColor3f(0,0,1); + glVertex3f(0,0,1); + glVertex3f(0,0,0); + glEnd(); + } + + // draw models + glTranslatef( -7.5*offset, 0, 5.0*offset ); + for ( size_t i = 0; i < modelList.size(); i++ ) + { + XModel* model = modelList[i]; + model->gl(); + glTranslatef( 15, 0, -10 ); + } + + glutSwapBuffers(); +} + +// reshape func +void reshape(int x, int y) +{ + if(y==0) y = 1; + windowWidth = x; + windowHeight = y; + +} + + +// anim speed scalar +float scalar=1.0f; + +// idle func +void idle() +{ + SortFrameTimer(); + + // update the models animation + for ( size_t i = 0; i < modelList.size(); i++ ) + { + XModel* model = modelList[i]; + model->Update(scalar*FrameTime()); + } + + //roty += scalar*FrameTime()*ROTATION; + + glutPostRedisplay(); +} + +// key func - just used for changing anim speed +void NormalKey(unsigned char key,int x,int y) +{ + switch( key ) + { + case 'h': + std::cout << "Help" << std::endl; + std::cout << std::endl; + std::cout << "F1: "; + std::cout << "Toggle AutoRotation " << std::endl; + std::cout << "F2: "; + std::cout << "Toggle SampleAlphaToCoverage " << std::endl; + std::cout << "F3: "; + std::cout << "Toggle DrawMeshes " << std::endl; + std::cout << "F4: "; + std::cout << "Toggle DrawJoints " << std::endl; + std::cout << "F5: "; + std::cout << "Toggle UpdateAnimation " << std::endl; + std::cout << "F6: "; + std::cout << "Cycle animations " << std::endl; + std::cout << "F7: "; + std::cout << "Toggle Wireframe " << std::endl; + std::cout << "F8: "; + std::cout << "Toggle Culling " << std::endl; + std::cout << "F9: "; + std::cout << "Toggle ViewAxes " << std::endl; + std::cout << "F10: "; + std::cout << "Toggle ViewGrid " << std::endl; + std::cout << "F11: "; + std::cout << "Toggle Texture " << std::endl; + std::cout << "F12: "; + std::cout << "Toggle DrawNormals " << std::endl; + std::cout << std::endl; + std::cout << "+: "; + std::cout << "Increase animation speed twice" << std::endl; + std::cout << "-: "; + std::cout << "Reduce animation speed by half" << std::endl; + std::cout << std::endl; + std::cout << "Esc: "; + std::cout << "Quit" << std::endl; + break; + case '-': + scalar *= 0.5f; + break; + case '+': + scalar *= 2.0f; + break; + case ']': + zoom += (float) zoomStep; + break; + case '[': + zoom -= (float) zoomStep; + break; + case 'c': + // print camera attrib values + printf("zoom= %f\n",zoom); + printf("rotx= %f\n",rotx); + printf("roty= %f\n",roty); + printf("tx= %f\n",tx); + printf("ty= %f\n",ty); + printf("lastx= %f\n",lastx); + printf("lasty= %f\n",lasty); + printf("zoomStep= %f\n",zoomStep); + printf("panStep= %f\n",panStep); + printf("ROTATION= %f\n",ROTATION); + break; + case 27: + glutIdleFunc(0); + exit(0); + break; + } +} + +// options +void SpecialKey(int key,int x,int y) +{ + switch(key) + { + case GLUT_KEY_F1: + options.ToggleAutoRotation(); + std::cout << "AutoRotation " << options.m_bAutoRotate << std::endl; + break; + case GLUT_KEY_F2: + options.ToggleSampleAlphaToCoverage(); + std::cout << "EnableSampleAlphaToCoverage " << options.m_bSampleAlphaToCoverage << std::endl; + break; + case GLUT_KEY_F3: + options.ToggleMeshes(); + std::cout << "DrawMeshes " << options.m_bDrawMeshes << std::endl; + break; + case GLUT_KEY_F4: + options.ToggleJoints(); + std::cout << "DrawJoints " << options.m_bDrawJoints << std::endl; + break; + case GLUT_KEY_F5: + options.ToggleAnimation(); + std::cout << "UpdateAnimation " << options.m_bAnimation << std::endl; + break; + case GLUT_KEY_F6: + // cycle animations + for ( size_t i = 0; i < modelList.size(); i++ ) + { + XModel* model = modelList[i]; + model->nextAnimation(); + } + break; + case GLUT_KEY_F7: + options.ToggleWireframe(); + std::cout << "IsWireframe " << options.m_bWireFrame << std::endl; + break; + case GLUT_KEY_F8: + options.ToggleCulling(); + std::cout << "IsCulled " << options.m_bCulling << std::endl; + break; + case GLUT_KEY_F9: + options.ToggleAxes(); + std::cout << "ViewAxes " << options.m_bAxes << std::endl; + break; + case GLUT_KEY_F10: + options.ToggleGrid(); + std::cout << "ViewGrid " << options.m_bGrid << std::endl; + break; + case GLUT_KEY_F11: + options.ToggleTextured(); + std::cout << "ToggleTextured " << options.m_bTextured << std::endl; + break; + case GLUT_KEY_F12: + options.ToggleNormals(); + std::cout << "DrawNormals " << options.m_bNormals << std::endl; + break; + default: + break; + } +} + +#define TYPE_MODEL 0 +#define TYPE_ANIM 1 +#define TYPE_CAMERA 2 + +struct InputFile +{ + uint type; + std::string inFileName; +}; + +int main(int argc,char** argv) +{ + // parse input + std::string sceneFileName; + + if( argc == 2 ) + { + sceneFileName = argv[1]; + } + else + { + printf("Usage: Loader SCENE_FILE_NAME\n "); + assert(0); + exit(0); + } + + // check file extension + std::string key (".scene"); + size_t found = sceneFileName.rfind(key); + if ( found == std::string::npos ) + { + std::cerr << "Error! Config file name has to have .scene as extension" << std::endl; + assert(0); exit(1); + } + + // open scene file + std::ifstream ifs( sceneFileName.c_str() ); + if (!ifs) + { + std::cerr << "Error! Could not open scene file" << std::endl; + assert(0); exit(1); + } + + // read scene file + char buffer[256]; + std::vector fileList; + while( !ifs.eof() ) + { + ifs >> buffer; + if ( strlen( buffer ) > 0 ) + { + //std::cout << buffer << std::endl; + InputFile file; + if ( strcmp( buffer, "model" ) == 0 ) + file.type = TYPE_MODEL; + else if ( strcmp( buffer, "anim" ) == 0 ) + file.type = TYPE_ANIM; + else if ( strcmp( buffer, "camera" ) == 0 ) + file.type = TYPE_CAMERA; + else + { + std::cerr << "Error! Unrecognized file type " << buffer << " in config file." << std::endl; + assert(0); exit(1); + } + + ifs >> file.inFileName; + fileList.push_back( file ); + } + buffer[0] = '\0'; + } + ifs.close(); + + // init glut + glutInit(&argc,argv); + + glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA|GLUT_DEPTH | GLUT_MULTISAMPLE); + + glutInitWindowSize(1000, 1000); + glutInitWindowPosition(300, 80); + + glutCreateWindow( sceneFileName.c_str() ); + + glutDisplayFunc(display); + glutReshapeFunc(reshape); + glutMouseFunc(Mouse); + glutMotionFunc(Motion); + glutIdleFunc(idle); + glutSpecialFunc(SpecialKey); + glutKeyboardFunc(NormalKey); + + InitFrameTimer(); + InitGL(); + + // Load the scene + bool status = true; + XModel* model = NULL; + for ( size_t i = 0; i < fileList.size(); i++ ) + { + InputFile file = fileList[i]; + if ( file.type == TYPE_MODEL ) + { + model = new XModel; + status &= model->LoadModel( file.inFileName.c_str() ); + modelList.push_back( model ); + } + else if ( file.type == TYPE_ANIM ) + { + status &= model->LoadAnim( file.inFileName.c_str() ); + } + else // camera + { + InitCamera( file.inFileName ); + } + } + + // init models + if ( status ) + { + for ( size_t i = 0; i < modelList.size(); i++ ) + { + XModel* model = modelList[i]; + model->init(); + offset += 1.0f; + } + //int zSize = glutGet(GLUT_WINDOW_DEPTH_SIZE); + glutMainLoop(); + } + + return 1; +} + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bullet/CMakeLists.txt b/bullet/CMakeLists.txt deleted file mode 100644 index bfcb5fef4..000000000 --- a/bullet/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -cmake_minimum_required(VERSION 2.4) - -PROJECT(BULLET_PHYSICS) -SET(BULLET_VERSION 2.75) - -IF (NOT CMAKE_BUILD_TYPE) -# SET(CMAKE_BUILD_TYPE "Debug") - SET(CMAKE_BUILD_TYPE "Release") -ENDIF (NOT CMAKE_BUILD_TYPE) - - -IF(COMMAND cmake_policy) - cmake_policy(SET CMP0003 NEW) -ENDIF(COMMAND cmake_policy) - - - -SUBDIRS(src) diff --git a/bullet/src/Bullet-C-Api.h b/bullet/src/Bullet-C-Api.h deleted file mode 100644 index 5b8f6c1ca..000000000 --- a/bullet/src/Bullet-C-Api.h +++ /dev/null @@ -1,176 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -/* - Draft high-level generic physics C-API. For low-level access, use the physics SDK native API's. - Work in progress, functionality will be added on demand. - - If possible, use the richer Bullet C++ API, by including "btBulletDynamicsCommon.h" -*/ - -#ifndef BULLET_C_API_H -#define BULLET_C_API_H - -#define PL_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name - -#ifdef BT_USE_DOUBLE_PRECISION -typedef double plReal; -#else -typedef float plReal; -#endif - -typedef plReal plVector3[3]; -typedef plReal plQuaternion[4]; - -#ifdef __cplusplus -extern "C" { -#endif - -/** Particular physics SDK (C-API) */ - PL_DECLARE_HANDLE(plPhysicsSdkHandle); - -/** Dynamics world, belonging to some physics SDK (C-API)*/ - PL_DECLARE_HANDLE(plDynamicsWorldHandle); - -/** Rigid Body that can be part of a Dynamics World (C-API)*/ - PL_DECLARE_HANDLE(plRigidBodyHandle); - -/** Collision Shape/Geometry, property of a Rigid Body (C-API)*/ - PL_DECLARE_HANDLE(plCollisionShapeHandle); - -/** Constraint for Rigid Bodies (C-API)*/ - PL_DECLARE_HANDLE(plConstraintHandle); - -/** Triangle Mesh interface (C-API)*/ - PL_DECLARE_HANDLE(plMeshInterfaceHandle); - -/** Broadphase Scene/Proxy Handles (C-API)*/ - PL_DECLARE_HANDLE(plCollisionBroadphaseHandle); - PL_DECLARE_HANDLE(plBroadphaseProxyHandle); - PL_DECLARE_HANDLE(plCollisionWorldHandle); - -/** - Create and Delete a Physics SDK -*/ - - extern plPhysicsSdkHandle plNewBulletSdk(); //this could be also another sdk, like ODE, PhysX etc. - extern void plDeletePhysicsSdk(plPhysicsSdkHandle physicsSdk); - -/** Collision World, not strictly necessary, you can also just create a Dynamics World with Rigid Bodies which internally manages the Collision World with Collision Objects */ - - typedef void(*btBroadphaseCallback)(void* clientData, void* object1,void* object2); - - extern plCollisionBroadphaseHandle plCreateSapBroadphase(btBroadphaseCallback beginCallback,btBroadphaseCallback endCallback); - - extern void plDestroyBroadphase(plCollisionBroadphaseHandle bp); - - extern plBroadphaseProxyHandle plCreateProxy(plCollisionBroadphaseHandle bp, void* clientData, plReal minX,plReal minY,plReal minZ, plReal maxX,plReal maxY, plReal maxZ); - - extern void plDestroyProxy(plCollisionBroadphaseHandle bp, plBroadphaseProxyHandle proxyHandle); - - extern void plSetBoundingBox(plBroadphaseProxyHandle proxyHandle, plReal minX,plReal minY,plReal minZ, plReal maxX,plReal maxY, plReal maxZ); - -/* todo: add pair cache support with queries like add/remove/find pair */ - - extern plCollisionWorldHandle plCreateCollisionWorld(plPhysicsSdkHandle physicsSdk); - -/* todo: add/remove objects */ - - -/* Dynamics World */ - - extern plDynamicsWorldHandle plCreateDynamicsWorld(plPhysicsSdkHandle physicsSdk); - - extern void plDeleteDynamicsWorld(plDynamicsWorldHandle world); - - extern void plStepSimulation(plDynamicsWorldHandle, plReal timeStep); - - extern void plAddRigidBody(plDynamicsWorldHandle world, plRigidBodyHandle object); - - extern void plRemoveRigidBody(plDynamicsWorldHandle world, plRigidBodyHandle object); - - -/* Rigid Body */ - - extern plRigidBodyHandle plCreateRigidBody( void* user_data, float mass, plCollisionShapeHandle cshape ); - - extern void plDeleteRigidBody(plRigidBodyHandle body); - - -/* Collision Shape definition */ - - extern plCollisionShapeHandle plNewSphereShape(plReal radius); - extern plCollisionShapeHandle plNewBoxShape(plReal x, plReal y, plReal z); - extern plCollisionShapeHandle plNewCapsuleShape(plReal radius, plReal height); - extern plCollisionShapeHandle plNewConeShape(plReal radius, plReal height); - extern plCollisionShapeHandle plNewCylinderShape(plReal radius, plReal height); - extern plCollisionShapeHandle plNewCompoundShape(); - extern void plAddChildShape(plCollisionShapeHandle compoundShape,plCollisionShapeHandle childShape, plVector3 childPos,plQuaternion childOrn); - - extern void plDeleteShape(plCollisionShapeHandle shape); - - /* Convex Meshes */ - extern plCollisionShapeHandle plNewConvexHullShape(); - extern void plAddVertex(plCollisionShapeHandle convexHull, plReal x,plReal y,plReal z); -/* Concave static triangle meshes */ - extern plMeshInterfaceHandle plNewMeshInterface(); - extern void plAddTriangle(plMeshInterfaceHandle meshHandle, plVector3 v0,plVector3 v1,plVector3 v2); - extern plCollisionShapeHandle plNewStaticTriangleMeshShape(plMeshInterfaceHandle); - - extern void plSetScaling(plCollisionShapeHandle shape, plVector3 scaling); - -/* SOLID has Response Callback/Table/Management */ -/* PhysX has Triggers, User Callbacks and filtering */ -/* ODE has the typedef void dNearCallback (void *data, dGeomID o1, dGeomID o2); */ - -/* typedef void plUpdatedPositionCallback(void* userData, plRigidBodyHandle rbHandle, plVector3 pos); */ -/* typedef void plUpdatedOrientationCallback(void* userData, plRigidBodyHandle rbHandle, plQuaternion orientation); */ - - /* get world transform */ - extern void plGetOpenGLMatrix(plRigidBodyHandle object, plReal* matrix); - extern void plGetPosition(plRigidBodyHandle object,plVector3 position); - extern void plGetOrientation(plRigidBodyHandle object,plQuaternion orientation); - - /* set world transform (position/orientation) */ - extern void plSetPosition(plRigidBodyHandle object, const plVector3 position); - extern void plSetOrientation(plRigidBodyHandle object, const plQuaternion orientation); - extern void plSetEuler(plReal yaw,plReal pitch,plReal roll, plQuaternion orient); - extern void plSetOpenGLMatrix(plRigidBodyHandle object, plReal* matrix); - - typedef struct plRayCastResult { - plRigidBodyHandle m_body; - plCollisionShapeHandle m_shape; - plVector3 m_positionWorld; - plVector3 m_normalWorld; - } plRayCastResult; - - extern int plRayCast(plDynamicsWorldHandle world, const plVector3 rayStart, const plVector3 rayEnd, plRayCastResult res); - - /* Sweep API */ - - /* extern plRigidBodyHandle plObjectCast(plDynamicsWorldHandle world, const plVector3 rayStart, const plVector3 rayEnd, plVector3 hitpoint, plVector3 normal); */ - - /* Continuous Collision Detection API */ - - // needed for source/blender/blenkernel/intern/collision.c - double plNearestPoints(float p1[3], float p2[3], float p3[3], float q1[3], float q2[3], float q3[3], float *pa, float *pb, float normal[3]); - -#ifdef __cplusplus -} -#endif - - -#endif //BULLET_C_API_H - diff --git a/bullet/src/BulletCollision/BroadphaseCollision/btAxisSweep3.cpp b/bullet/src/BulletCollision/BroadphaseCollision/btAxisSweep3.cpp deleted file mode 100644 index d4eefff58..000000000 --- a/bullet/src/BulletCollision/BroadphaseCollision/btAxisSweep3.cpp +++ /dev/null @@ -1,37 +0,0 @@ - -//Bullet Continuous Collision Detection and Physics Library -//Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - - -// -// btAxisSweep3 -// -// Copyright (c) 2006 Simon Hobbs -// -// This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -#include "btAxisSweep3.h" - - -btAxisSweep3::btAxisSweep3(const btVector3& worldAabbMin,const btVector3& worldAabbMax, unsigned short int maxHandles, btOverlappingPairCache* pairCache, bool disableRaycastAccelerator) -:btAxisSweep3Internal(worldAabbMin,worldAabbMax,0xfffe,0xffff,maxHandles,pairCache,disableRaycastAccelerator) -{ - // 1 handle is reserved as sentinel - btAssert(maxHandles > 1 && maxHandles < 32767); - -} - - -bt32BitAxisSweep3::bt32BitAxisSweep3(const btVector3& worldAabbMin,const btVector3& worldAabbMax, unsigned int maxHandles , btOverlappingPairCache* pairCache , bool disableRaycastAccelerator) -:btAxisSweep3Internal(worldAabbMin,worldAabbMax,0xfffffffe,0x7fffffff,maxHandles,pairCache,disableRaycastAccelerator) -{ - // 1 handle is reserved as sentinel - btAssert(maxHandles > 1 && maxHandles < 2147483647); -} diff --git a/bullet/src/BulletCollision/BroadphaseCollision/btAxisSweep3.h b/bullet/src/BulletCollision/BroadphaseCollision/btAxisSweep3.h deleted file mode 100644 index c879eba80..000000000 --- a/bullet/src/BulletCollision/BroadphaseCollision/btAxisSweep3.h +++ /dev/null @@ -1,1024 +0,0 @@ -//Bullet Continuous Collision Detection and Physics Library -//Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -// -// btAxisSweep3.h -// -// Copyright (c) 2006 Simon Hobbs -// -// This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. - -#ifndef AXIS_SWEEP_3_H -#define AXIS_SWEEP_3_H - -#include "LinearMath/btVector3.h" -#include "btOverlappingPairCache.h" -#include "btBroadphaseInterface.h" -#include "btBroadphaseProxy.h" -#include "btOverlappingPairCallback.h" -#include "btDbvtBroadphase.h" - -//#define DEBUG_BROADPHASE 1 -#define USE_OVERLAP_TEST_ON_REMOVES 1 - -/// The internal templace class btAxisSweep3Internal implements the sweep and prune broadphase. -/// It uses quantized integers to represent the begin and end points for each of the 3 axis. -/// Dont use this class directly, use btAxisSweep3 or bt32BitAxisSweep3 instead. -template -class btAxisSweep3Internal : public btBroadphaseInterface -{ -protected: - - BP_FP_INT_TYPE m_bpHandleMask; - BP_FP_INT_TYPE m_handleSentinel; - -public: - - BT_DECLARE_ALIGNED_ALLOCATOR(); - - class Edge - { - public: - BP_FP_INT_TYPE m_pos; // low bit is min/max - BP_FP_INT_TYPE m_handle; - - BP_FP_INT_TYPE IsMax() const {return static_cast(m_pos & 1);} - }; - -public: - class Handle : public btBroadphaseProxy - { - public: - BT_DECLARE_ALIGNED_ALLOCATOR(); - - // indexes into the edge arrays - BP_FP_INT_TYPE m_minEdges[3], m_maxEdges[3]; // 6 * 2 = 12 -// BP_FP_INT_TYPE m_uniqueId; - btBroadphaseProxy* m_dbvtProxy;//for faster raycast - //void* m_pOwner; this is now in btBroadphaseProxy.m_clientObject - - SIMD_FORCE_INLINE void SetNextFree(BP_FP_INT_TYPE next) {m_minEdges[0] = next;} - SIMD_FORCE_INLINE BP_FP_INT_TYPE GetNextFree() const {return m_minEdges[0];} - }; // 24 bytes + 24 for Edge structures = 44 bytes total per entry - - -protected: - btVector3 m_worldAabbMin; // overall system bounds - btVector3 m_worldAabbMax; // overall system bounds - - btVector3 m_quantize; // scaling factor for quantization - - BP_FP_INT_TYPE m_numHandles; // number of active handles - BP_FP_INT_TYPE m_maxHandles; // max number of handles - Handle* m_pHandles; // handles pool - - BP_FP_INT_TYPE m_firstFreeHandle; // free handles list - - Edge* m_pEdges[3]; // edge arrays for the 3 axes (each array has m_maxHandles * 2 + 2 sentinel entries) - void* m_pEdgesRawPtr[3]; - - btOverlappingPairCache* m_pairCache; - - ///btOverlappingPairCallback is an additional optional user callback for adding/removing overlapping pairs, similar interface to btOverlappingPairCache. - btOverlappingPairCallback* m_userPairCallback; - - bool m_ownsPairCache; - - int m_invalidPair; - - ///additional dynamic aabb structure, used to accelerate ray cast queries. - ///can be disabled using a optional argument in the constructor - btDbvtBroadphase* m_raycastAccelerator; - btOverlappingPairCache* m_nullPairCache; - - - // allocation/deallocation - BP_FP_INT_TYPE allocHandle(); - void freeHandle(BP_FP_INT_TYPE handle); - - - bool testOverlap2D(const Handle* pHandleA, const Handle* pHandleB,int axis0,int axis1); - -#ifdef DEBUG_BROADPHASE - void debugPrintAxis(int axis,bool checkCardinality=true); -#endif //DEBUG_BROADPHASE - - //Overlap* AddOverlap(BP_FP_INT_TYPE handleA, BP_FP_INT_TYPE handleB); - //void RemoveOverlap(BP_FP_INT_TYPE handleA, BP_FP_INT_TYPE handleB); - - - - void sortMinDown(int axis, BP_FP_INT_TYPE edge, btDispatcher* dispatcher, bool updateOverlaps ); - void sortMinUp(int axis, BP_FP_INT_TYPE edge, btDispatcher* dispatcher, bool updateOverlaps ); - void sortMaxDown(int axis, BP_FP_INT_TYPE edge, btDispatcher* dispatcher, bool updateOverlaps ); - void sortMaxUp(int axis, BP_FP_INT_TYPE edge, btDispatcher* dispatcher, bool updateOverlaps ); - -public: - - btAxisSweep3Internal(const btVector3& worldAabbMin,const btVector3& worldAabbMax, BP_FP_INT_TYPE handleMask, BP_FP_INT_TYPE handleSentinel, BP_FP_INT_TYPE maxHandles = 16384, btOverlappingPairCache* pairCache=0,bool disableRaycastAccelerator = false); - - virtual ~btAxisSweep3Internal(); - - BP_FP_INT_TYPE getNumHandles() const - { - return m_numHandles; - } - - virtual void calculateOverlappingPairs(btDispatcher* dispatcher); - - BP_FP_INT_TYPE addHandle(const btVector3& aabbMin,const btVector3& aabbMax, void* pOwner,short int collisionFilterGroup,short int collisionFilterMask,btDispatcher* dispatcher,void* multiSapProxy); - void removeHandle(BP_FP_INT_TYPE handle,btDispatcher* dispatcher); - void updateHandle(BP_FP_INT_TYPE handle, const btVector3& aabbMin,const btVector3& aabbMax,btDispatcher* dispatcher); - SIMD_FORCE_INLINE Handle* getHandle(BP_FP_INT_TYPE index) const {return m_pHandles + index;} - - virtual void resetPool(btDispatcher* dispatcher); - - void processAllOverlappingPairs(btOverlapCallback* callback); - - //Broadphase Interface - virtual btBroadphaseProxy* createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr ,short int collisionFilterGroup,short int collisionFilterMask,btDispatcher* dispatcher,void* multiSapProxy); - virtual void destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher); - virtual void setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax,btDispatcher* dispatcher); - virtual void getAabb(btBroadphaseProxy* proxy,btVector3& aabbMin, btVector3& aabbMax ) const; - - virtual void rayTest(const btVector3& rayFrom,const btVector3& rayTo, btBroadphaseRayCallback& rayCallback, const btVector3& aabbMin=btVector3(0,0,0), const btVector3& aabbMax = btVector3(0,0,0)); - - void quantize(BP_FP_INT_TYPE* out, const btVector3& point, int isMax) const; - ///unQuantize should be conservative: aabbMin/aabbMax should be larger then 'getAabb' result - void unQuantize(btBroadphaseProxy* proxy,btVector3& aabbMin, btVector3& aabbMax ) const; - - bool testAabbOverlap(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1); - - btOverlappingPairCache* getOverlappingPairCache() - { - return m_pairCache; - } - const btOverlappingPairCache* getOverlappingPairCache() const - { - return m_pairCache; - } - - void setOverlappingPairUserCallback(btOverlappingPairCallback* pairCallback) - { - m_userPairCallback = pairCallback; - } - const btOverlappingPairCallback* getOverlappingPairUserCallback() const - { - return m_userPairCallback; - } - - ///getAabb returns the axis aligned bounding box in the 'global' coordinate frame - ///will add some transform later - virtual void getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const - { - aabbMin = m_worldAabbMin; - aabbMax = m_worldAabbMax; - } - - virtual void printStats() - { -/* printf("btAxisSweep3.h\n"); - printf("numHandles = %d, maxHandles = %d\n",m_numHandles,m_maxHandles); - printf("aabbMin=%f,%f,%f,aabbMax=%f,%f,%f\n",m_worldAabbMin.getX(),m_worldAabbMin.getY(),m_worldAabbMin.getZ(), - m_worldAabbMax.getX(),m_worldAabbMax.getY(),m_worldAabbMax.getZ()); - */ - - } - -}; - -//////////////////////////////////////////////////////////////////// - - - - -#ifdef DEBUG_BROADPHASE -#include - -template -void btAxisSweep3::debugPrintAxis(int axis, bool checkCardinality) -{ - int numEdges = m_pHandles[0].m_maxEdges[axis]; - printf("SAP Axis %d, numEdges=%d\n",axis,numEdges); - - int i; - for (i=0;im_handle); - int handleIndex = pEdge->IsMax()? pHandlePrev->m_maxEdges[axis] : pHandlePrev->m_minEdges[axis]; - char beginOrEnd; - beginOrEnd=pEdge->IsMax()?'E':'B'; - printf(" [%c,h=%d,p=%x,i=%d]\n",beginOrEnd,pEdge->m_handle,pEdge->m_pos,handleIndex); - } - - if (checkCardinality) - btAssert(numEdges == m_numHandles*2+1); -} -#endif //DEBUG_BROADPHASE - -template -btBroadphaseProxy* btAxisSweep3Internal::createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr,short int collisionFilterGroup,short int collisionFilterMask,btDispatcher* dispatcher,void* multiSapProxy) -{ - (void)shapeType; - BP_FP_INT_TYPE handleId = addHandle(aabbMin,aabbMax, userPtr,collisionFilterGroup,collisionFilterMask,dispatcher,multiSapProxy); - - Handle* handle = getHandle(handleId); - - if (m_raycastAccelerator) - { - btBroadphaseProxy* rayProxy = m_raycastAccelerator->createProxy(aabbMin,aabbMax,shapeType,userPtr,collisionFilterGroup,collisionFilterMask,dispatcher,0); - handle->m_dbvtProxy = rayProxy; - } - return handle; -} - - - -template -void btAxisSweep3Internal::destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher) -{ - Handle* handle = static_cast(proxy); - if (m_raycastAccelerator) - m_raycastAccelerator->destroyProxy(handle->m_dbvtProxy,dispatcher); - removeHandle(static_cast(handle->m_uniqueId), dispatcher); -} - -template -void btAxisSweep3Internal::setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax,btDispatcher* dispatcher) -{ - Handle* handle = static_cast(proxy); - handle->m_aabbMin = aabbMin; - handle->m_aabbMax = aabbMax; - updateHandle(static_cast(handle->m_uniqueId), aabbMin, aabbMax,dispatcher); - if (m_raycastAccelerator) - m_raycastAccelerator->setAabb(handle->m_dbvtProxy,aabbMin,aabbMax,dispatcher); - -} - -template -void btAxisSweep3Internal::rayTest(const btVector3& rayFrom,const btVector3& rayTo, btBroadphaseRayCallback& rayCallback,const btVector3& aabbMin,const btVector3& aabbMax) -{ - if (m_raycastAccelerator) - { - m_raycastAccelerator->rayTest(rayFrom,rayTo,rayCallback,aabbMin,aabbMax); - } else - { - //choose axis? - BP_FP_INT_TYPE axis = 0; - //for each proxy - for (BP_FP_INT_TYPE i=1;i -void btAxisSweep3Internal::getAabb(btBroadphaseProxy* proxy,btVector3& aabbMin, btVector3& aabbMax ) const -{ - Handle* pHandle = static_cast(proxy); - aabbMin = pHandle->m_aabbMin; - aabbMax = pHandle->m_aabbMax; -} - - -template -void btAxisSweep3Internal::unQuantize(btBroadphaseProxy* proxy,btVector3& aabbMin, btVector3& aabbMax ) const -{ - Handle* pHandle = static_cast(proxy); - - unsigned short vecInMin[3]; - unsigned short vecInMax[3]; - - vecInMin[0] = m_pEdges[0][pHandle->m_minEdges[0]].m_pos ; - vecInMax[0] = m_pEdges[0][pHandle->m_maxEdges[0]].m_pos +1 ; - vecInMin[1] = m_pEdges[1][pHandle->m_minEdges[1]].m_pos ; - vecInMax[1] = m_pEdges[1][pHandle->m_maxEdges[1]].m_pos +1 ; - vecInMin[2] = m_pEdges[2][pHandle->m_minEdges[2]].m_pos ; - vecInMax[2] = m_pEdges[2][pHandle->m_maxEdges[2]].m_pos +1 ; - - aabbMin.setValue((btScalar)(vecInMin[0]) / (m_quantize.getX()),(btScalar)(vecInMin[1]) / (m_quantize.getY()),(btScalar)(vecInMin[2]) / (m_quantize.getZ())); - aabbMin += m_worldAabbMin; - - aabbMax.setValue((btScalar)(vecInMax[0]) / (m_quantize.getX()),(btScalar)(vecInMax[1]) / (m_quantize.getY()),(btScalar)(vecInMax[2]) / (m_quantize.getZ())); - aabbMax += m_worldAabbMin; -} - - - - -template -btAxisSweep3Internal::btAxisSweep3Internal(const btVector3& worldAabbMin,const btVector3& worldAabbMax, BP_FP_INT_TYPE handleMask, BP_FP_INT_TYPE handleSentinel,BP_FP_INT_TYPE userMaxHandles, btOverlappingPairCache* pairCache , bool disableRaycastAccelerator) -:m_bpHandleMask(handleMask), -m_handleSentinel(handleSentinel), -m_pairCache(pairCache), -m_userPairCallback(0), -m_ownsPairCache(false), -m_invalidPair(0), -m_raycastAccelerator(0) -{ - BP_FP_INT_TYPE maxHandles = static_cast(userMaxHandles+1);//need to add one sentinel handle - - if (!m_pairCache) - { - void* ptr = btAlignedAlloc(sizeof(btHashedOverlappingPairCache),16); - m_pairCache = new(ptr) btHashedOverlappingPairCache(); - m_ownsPairCache = true; - } - - if (!disableRaycastAccelerator) - { - m_nullPairCache = new (btAlignedAlloc(sizeof(btNullPairCache),16)) btNullPairCache(); - m_raycastAccelerator = new (btAlignedAlloc(sizeof(btDbvtBroadphase),16)) btDbvtBroadphase(m_nullPairCache);//m_pairCache); - m_raycastAccelerator->m_deferedcollide = true;//don't add/remove pairs - } - - //btAssert(bounds.HasVolume()); - - // init bounds - m_worldAabbMin = worldAabbMin; - m_worldAabbMax = worldAabbMax; - - btVector3 aabbSize = m_worldAabbMax - m_worldAabbMin; - - BP_FP_INT_TYPE maxInt = m_handleSentinel; - - m_quantize = btVector3(btScalar(maxInt),btScalar(maxInt),btScalar(maxInt)) / aabbSize; - - // allocate handles buffer, using btAlignedAlloc, and put all handles on free list - m_pHandles = new Handle[maxHandles]; - - m_maxHandles = maxHandles; - m_numHandles = 0; - - // handle 0 is reserved as the null index, and is also used as the sentinel - m_firstFreeHandle = 1; - { - for (BP_FP_INT_TYPE i = m_firstFreeHandle; i < maxHandles; i++) - m_pHandles[i].SetNextFree(static_cast(i + 1)); - m_pHandles[maxHandles - 1].SetNextFree(0); - } - - { - // allocate edge buffers - for (int i = 0; i < 3; i++) - { - m_pEdgesRawPtr[i] = btAlignedAlloc(sizeof(Edge)*maxHandles*2,16); - m_pEdges[i] = new(m_pEdgesRawPtr[i]) Edge[maxHandles * 2]; - } - } - //removed overlap management - - // make boundary sentinels - - m_pHandles[0].m_clientObject = 0; - - for (int axis = 0; axis < 3; axis++) - { - m_pHandles[0].m_minEdges[axis] = 0; - m_pHandles[0].m_maxEdges[axis] = 1; - - m_pEdges[axis][0].m_pos = 0; - m_pEdges[axis][0].m_handle = 0; - m_pEdges[axis][1].m_pos = m_handleSentinel; - m_pEdges[axis][1].m_handle = 0; -#ifdef DEBUG_BROADPHASE - debugPrintAxis(axis); -#endif //DEBUG_BROADPHASE - - } - -} - -template -btAxisSweep3Internal::~btAxisSweep3Internal() -{ - if (m_raycastAccelerator) - { - m_nullPairCache->~btOverlappingPairCache(); - btAlignedFree(m_nullPairCache); - m_raycastAccelerator->~btDbvtBroadphase(); - btAlignedFree (m_raycastAccelerator); - } - - for (int i = 2; i >= 0; i--) - { - btAlignedFree(m_pEdgesRawPtr[i]); - } - delete [] m_pHandles; - - if (m_ownsPairCache) - { - m_pairCache->~btOverlappingPairCache(); - btAlignedFree(m_pairCache); - } -} - -template -void btAxisSweep3Internal::quantize(BP_FP_INT_TYPE* out, const btVector3& point, int isMax) const -{ -#ifdef OLD_CLAMPING_METHOD - ///problem with this clamping method is that the floating point during quantization might still go outside the range [(0|isMax) .. (m_handleSentinel&m_bpHandleMask]|isMax] - ///see http://code.google.com/p/bullet/issues/detail?id=87 - btVector3 clampedPoint(point); - clampedPoint.setMax(m_worldAabbMin); - clampedPoint.setMin(m_worldAabbMax); - btVector3 v = (clampedPoint - m_worldAabbMin) * m_quantize; - out[0] = (BP_FP_INT_TYPE)(((BP_FP_INT_TYPE)v.getX() & m_bpHandleMask) | isMax); - out[1] = (BP_FP_INT_TYPE)(((BP_FP_INT_TYPE)v.getY() & m_bpHandleMask) | isMax); - out[2] = (BP_FP_INT_TYPE)(((BP_FP_INT_TYPE)v.getZ() & m_bpHandleMask) | isMax); -#else - btVector3 v = (point - m_worldAabbMin) * m_quantize; - out[0]=(v[0]<=0)?(BP_FP_INT_TYPE)isMax:(v[0]>=m_handleSentinel)?(BP_FP_INT_TYPE)((m_handleSentinel&m_bpHandleMask)|isMax):(BP_FP_INT_TYPE)(((BP_FP_INT_TYPE)v[0]&m_bpHandleMask)|isMax); - out[1]=(v[1]<=0)?(BP_FP_INT_TYPE)isMax:(v[1]>=m_handleSentinel)?(BP_FP_INT_TYPE)((m_handleSentinel&m_bpHandleMask)|isMax):(BP_FP_INT_TYPE)(((BP_FP_INT_TYPE)v[1]&m_bpHandleMask)|isMax); - out[2]=(v[2]<=0)?(BP_FP_INT_TYPE)isMax:(v[2]>=m_handleSentinel)?(BP_FP_INT_TYPE)((m_handleSentinel&m_bpHandleMask)|isMax):(BP_FP_INT_TYPE)(((BP_FP_INT_TYPE)v[2]&m_bpHandleMask)|isMax); -#endif //OLD_CLAMPING_METHOD -} - - -template -BP_FP_INT_TYPE btAxisSweep3Internal::allocHandle() -{ - btAssert(m_firstFreeHandle); - - BP_FP_INT_TYPE handle = m_firstFreeHandle; - m_firstFreeHandle = getHandle(handle)->GetNextFree(); - m_numHandles++; - - return handle; -} - -template -void btAxisSweep3Internal::freeHandle(BP_FP_INT_TYPE handle) -{ - btAssert(handle > 0 && handle < m_maxHandles); - - getHandle(handle)->SetNextFree(m_firstFreeHandle); - m_firstFreeHandle = handle; - - m_numHandles--; -} - - -template -BP_FP_INT_TYPE btAxisSweep3Internal::addHandle(const btVector3& aabbMin,const btVector3& aabbMax, void* pOwner,short int collisionFilterGroup,short int collisionFilterMask,btDispatcher* dispatcher,void* multiSapProxy) -{ - // quantize the bounds - BP_FP_INT_TYPE min[3], max[3]; - quantize(min, aabbMin, 0); - quantize(max, aabbMax, 1); - - // allocate a handle - BP_FP_INT_TYPE handle = allocHandle(); - - - Handle* pHandle = getHandle(handle); - - pHandle->m_uniqueId = static_cast(handle); - //pHandle->m_pOverlaps = 0; - pHandle->m_clientObject = pOwner; - pHandle->m_collisionFilterGroup = collisionFilterGroup; - pHandle->m_collisionFilterMask = collisionFilterMask; - pHandle->m_multiSapParentProxy = multiSapProxy; - - // compute current limit of edge arrays - BP_FP_INT_TYPE limit = static_cast(m_numHandles * 2); - - - // insert new edges just inside the max boundary edge - for (BP_FP_INT_TYPE axis = 0; axis < 3; axis++) - { - - m_pHandles[0].m_maxEdges[axis] += 2; - - m_pEdges[axis][limit + 1] = m_pEdges[axis][limit - 1]; - - m_pEdges[axis][limit - 1].m_pos = min[axis]; - m_pEdges[axis][limit - 1].m_handle = handle; - - m_pEdges[axis][limit].m_pos = max[axis]; - m_pEdges[axis][limit].m_handle = handle; - - pHandle->m_minEdges[axis] = static_cast(limit - 1); - pHandle->m_maxEdges[axis] = limit; - } - - // now sort the new edges to their correct position - sortMinDown(0, pHandle->m_minEdges[0], dispatcher,false); - sortMaxDown(0, pHandle->m_maxEdges[0], dispatcher,false); - sortMinDown(1, pHandle->m_minEdges[1], dispatcher,false); - sortMaxDown(1, pHandle->m_maxEdges[1], dispatcher,false); - sortMinDown(2, pHandle->m_minEdges[2], dispatcher,true); - sortMaxDown(2, pHandle->m_maxEdges[2], dispatcher,true); - - - return handle; -} - - -template -void btAxisSweep3Internal::removeHandle(BP_FP_INT_TYPE handle,btDispatcher* dispatcher) -{ - - Handle* pHandle = getHandle(handle); - - //explicitly remove the pairs containing the proxy - //we could do it also in the sortMinUp (passing true) - ///@todo: compare performance - if (!m_pairCache->hasDeferredRemoval()) - { - m_pairCache->removeOverlappingPairsContainingProxy(pHandle,dispatcher); - } - - // compute current limit of edge arrays - int limit = static_cast(m_numHandles * 2); - - int axis; - - for (axis = 0;axis<3;axis++) - { - m_pHandles[0].m_maxEdges[axis] -= 2; - } - - // remove the edges by sorting them up to the end of the list - for ( axis = 0; axis < 3; axis++) - { - Edge* pEdges = m_pEdges[axis]; - BP_FP_INT_TYPE max = pHandle->m_maxEdges[axis]; - pEdges[max].m_pos = m_handleSentinel; - - sortMaxUp(axis,max,dispatcher,false); - - - BP_FP_INT_TYPE i = pHandle->m_minEdges[axis]; - pEdges[i].m_pos = m_handleSentinel; - - - sortMinUp(axis,i,dispatcher,false); - - pEdges[limit-1].m_handle = 0; - pEdges[limit-1].m_pos = m_handleSentinel; - -#ifdef DEBUG_BROADPHASE - debugPrintAxis(axis,false); -#endif //DEBUG_BROADPHASE - - - } - - - // free the handle - freeHandle(handle); - - -} - -template -void btAxisSweep3Internal::resetPool(btDispatcher* dispatcher) -{ - if (m_numHandles == 0) - { - m_firstFreeHandle = 1; - { - for (BP_FP_INT_TYPE i = m_firstFreeHandle; i < m_maxHandles; i++) - m_pHandles[i].SetNextFree(static_cast(i + 1)); - m_pHandles[m_maxHandles - 1].SetNextFree(0); - } - } -} - - -extern int gOverlappingPairs; -//#include - -template -void btAxisSweep3Internal::calculateOverlappingPairs(btDispatcher* dispatcher) -{ - - if (m_pairCache->hasDeferredRemoval()) - { - - btBroadphasePairArray& overlappingPairArray = m_pairCache->getOverlappingPairArray(); - - //perform a sort, to find duplicates and to sort 'invalid' pairs to the end - overlappingPairArray.quickSort(btBroadphasePairSortPredicate()); - - overlappingPairArray.resize(overlappingPairArray.size() - m_invalidPair); - m_invalidPair = 0; - - - int i; - - btBroadphasePair previousPair; - previousPair.m_pProxy0 = 0; - previousPair.m_pProxy1 = 0; - previousPair.m_algorithm = 0; - - - for (i=0;iprocessOverlap(pair); - } else - { - needsRemoval = true; - } - } else - { - //remove duplicate - needsRemoval = true; - //should have no algorithm - btAssert(!pair.m_algorithm); - } - - if (needsRemoval) - { - m_pairCache->cleanOverlappingPair(pair,dispatcher); - - // m_overlappingPairArray.swap(i,m_overlappingPairArray.size()-1); - // m_overlappingPairArray.pop_back(); - pair.m_pProxy0 = 0; - pair.m_pProxy1 = 0; - m_invalidPair++; - gOverlappingPairs--; - } - - } - - ///if you don't like to skip the invalid pairs in the array, execute following code: - #define CLEAN_INVALID_PAIRS 1 - #ifdef CLEAN_INVALID_PAIRS - - //perform a sort, to sort 'invalid' pairs to the end - overlappingPairArray.quickSort(btBroadphasePairSortPredicate()); - - overlappingPairArray.resize(overlappingPairArray.size() - m_invalidPair); - m_invalidPair = 0; - #endif//CLEAN_INVALID_PAIRS - - //printf("overlappingPairArray.size()=%d\n",overlappingPairArray.size()); - } - -} - - -template -bool btAxisSweep3Internal::testAabbOverlap(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) -{ - const Handle* pHandleA = static_cast(proxy0); - const Handle* pHandleB = static_cast(proxy1); - - //optimization 1: check the array index (memory address), instead of the m_pos - - for (int axis = 0; axis < 3; axis++) - { - if (pHandleA->m_maxEdges[axis] < pHandleB->m_minEdges[axis] || - pHandleB->m_maxEdges[axis] < pHandleA->m_minEdges[axis]) - { - return false; - } - } - return true; -} - -template -bool btAxisSweep3Internal::testOverlap2D(const Handle* pHandleA, const Handle* pHandleB,int axis0,int axis1) -{ - //optimization 1: check the array index (memory address), instead of the m_pos - - if (pHandleA->m_maxEdges[axis0] < pHandleB->m_minEdges[axis0] || - pHandleB->m_maxEdges[axis0] < pHandleA->m_minEdges[axis0] || - pHandleA->m_maxEdges[axis1] < pHandleB->m_minEdges[axis1] || - pHandleB->m_maxEdges[axis1] < pHandleA->m_minEdges[axis1]) - { - return false; - } - return true; -} - -template -void btAxisSweep3Internal::updateHandle(BP_FP_INT_TYPE handle, const btVector3& aabbMin,const btVector3& aabbMax,btDispatcher* dispatcher) -{ -// btAssert(bounds.IsFinite()); - //btAssert(bounds.HasVolume()); - - Handle* pHandle = getHandle(handle); - - // quantize the new bounds - BP_FP_INT_TYPE min[3], max[3]; - quantize(min, aabbMin, 0); - quantize(max, aabbMax, 1); - - // update changed edges - for (int axis = 0; axis < 3; axis++) - { - BP_FP_INT_TYPE emin = pHandle->m_minEdges[axis]; - BP_FP_INT_TYPE emax = pHandle->m_maxEdges[axis]; - - int dmin = (int)min[axis] - (int)m_pEdges[axis][emin].m_pos; - int dmax = (int)max[axis] - (int)m_pEdges[axis][emax].m_pos; - - m_pEdges[axis][emin].m_pos = min[axis]; - m_pEdges[axis][emax].m_pos = max[axis]; - - // expand (only adds overlaps) - if (dmin < 0) - sortMinDown(axis, emin,dispatcher,true); - - if (dmax > 0) - sortMaxUp(axis, emax,dispatcher,true); - - // shrink (only removes overlaps) - if (dmin > 0) - sortMinUp(axis, emin,dispatcher,true); - - if (dmax < 0) - sortMaxDown(axis, emax,dispatcher,true); - -#ifdef DEBUG_BROADPHASE - debugPrintAxis(axis); -#endif //DEBUG_BROADPHASE - } - - -} - - - - -// sorting a min edge downwards can only ever *add* overlaps -template -void btAxisSweep3Internal::sortMinDown(int axis, BP_FP_INT_TYPE edge, btDispatcher* /* dispatcher */, bool updateOverlaps) -{ - - Edge* pEdge = m_pEdges[axis] + edge; - Edge* pPrev = pEdge - 1; - Handle* pHandleEdge = getHandle(pEdge->m_handle); - - while (pEdge->m_pos < pPrev->m_pos) - { - Handle* pHandlePrev = getHandle(pPrev->m_handle); - - if (pPrev->IsMax()) - { - // if previous edge is a maximum check the bounds and add an overlap if necessary - const int axis1 = (1 << axis) & 3; - const int axis2 = (1 << axis1) & 3; - if (updateOverlaps && testOverlap2D(pHandleEdge, pHandlePrev,axis1,axis2)) - { - m_pairCache->addOverlappingPair(pHandleEdge,pHandlePrev); - if (m_userPairCallback) - m_userPairCallback->addOverlappingPair(pHandleEdge,pHandlePrev); - - //AddOverlap(pEdge->m_handle, pPrev->m_handle); - - } - - // update edge reference in other handle - pHandlePrev->m_maxEdges[axis]++; - } - else - pHandlePrev->m_minEdges[axis]++; - - pHandleEdge->m_minEdges[axis]--; - - // swap the edges - Edge swap = *pEdge; - *pEdge = *pPrev; - *pPrev = swap; - - // decrement - pEdge--; - pPrev--; - } - -#ifdef DEBUG_BROADPHASE - debugPrintAxis(axis); -#endif //DEBUG_BROADPHASE - -} - -// sorting a min edge upwards can only ever *remove* overlaps -template -void btAxisSweep3Internal::sortMinUp(int axis, BP_FP_INT_TYPE edge, btDispatcher* dispatcher, bool updateOverlaps) -{ - Edge* pEdge = m_pEdges[axis] + edge; - Edge* pNext = pEdge + 1; - Handle* pHandleEdge = getHandle(pEdge->m_handle); - - while (pNext->m_handle && (pEdge->m_pos >= pNext->m_pos)) - { - Handle* pHandleNext = getHandle(pNext->m_handle); - - if (pNext->IsMax()) - { - Handle* handle0 = getHandle(pEdge->m_handle); - Handle* handle1 = getHandle(pNext->m_handle); - const int axis1 = (1 << axis) & 3; - const int axis2 = (1 << axis1) & 3; - - // if next edge is maximum remove any overlap between the two handles - if (updateOverlaps -#ifdef USE_OVERLAP_TEST_ON_REMOVES - && testOverlap2D(handle0,handle1,axis1,axis2) -#endif //USE_OVERLAP_TEST_ON_REMOVES - ) - { - - - m_pairCache->removeOverlappingPair(handle0,handle1,dispatcher); - if (m_userPairCallback) - m_userPairCallback->removeOverlappingPair(handle0,handle1,dispatcher); - - } - - - // update edge reference in other handle - pHandleNext->m_maxEdges[axis]--; - } - else - pHandleNext->m_minEdges[axis]--; - - pHandleEdge->m_minEdges[axis]++; - - // swap the edges - Edge swap = *pEdge; - *pEdge = *pNext; - *pNext = swap; - - // increment - pEdge++; - pNext++; - } - - -} - -// sorting a max edge downwards can only ever *remove* overlaps -template -void btAxisSweep3Internal::sortMaxDown(int axis, BP_FP_INT_TYPE edge, btDispatcher* dispatcher, bool updateOverlaps) -{ - - Edge* pEdge = m_pEdges[axis] + edge; - Edge* pPrev = pEdge - 1; - Handle* pHandleEdge = getHandle(pEdge->m_handle); - - while (pEdge->m_pos < pPrev->m_pos) - { - Handle* pHandlePrev = getHandle(pPrev->m_handle); - - if (!pPrev->IsMax()) - { - // if previous edge was a minimum remove any overlap between the two handles - Handle* handle0 = getHandle(pEdge->m_handle); - Handle* handle1 = getHandle(pPrev->m_handle); - const int axis1 = (1 << axis) & 3; - const int axis2 = (1 << axis1) & 3; - - if (updateOverlaps -#ifdef USE_OVERLAP_TEST_ON_REMOVES - && testOverlap2D(handle0,handle1,axis1,axis2) -#endif //USE_OVERLAP_TEST_ON_REMOVES - ) - { - //this is done during the overlappingpairarray iteration/narrowphase collision - - - m_pairCache->removeOverlappingPair(handle0,handle1,dispatcher); - if (m_userPairCallback) - m_userPairCallback->removeOverlappingPair(handle0,handle1,dispatcher); - - - - } - - // update edge reference in other handle - pHandlePrev->m_minEdges[axis]++;; - } - else - pHandlePrev->m_maxEdges[axis]++; - - pHandleEdge->m_maxEdges[axis]--; - - // swap the edges - Edge swap = *pEdge; - *pEdge = *pPrev; - *pPrev = swap; - - // decrement - pEdge--; - pPrev--; - } - - -#ifdef DEBUG_BROADPHASE - debugPrintAxis(axis); -#endif //DEBUG_BROADPHASE - -} - -// sorting a max edge upwards can only ever *add* overlaps -template -void btAxisSweep3Internal::sortMaxUp(int axis, BP_FP_INT_TYPE edge, btDispatcher* /* dispatcher */, bool updateOverlaps) -{ - Edge* pEdge = m_pEdges[axis] + edge; - Edge* pNext = pEdge + 1; - Handle* pHandleEdge = getHandle(pEdge->m_handle); - - while (pNext->m_handle && (pEdge->m_pos >= pNext->m_pos)) - { - Handle* pHandleNext = getHandle(pNext->m_handle); - - const int axis1 = (1 << axis) & 3; - const int axis2 = (1 << axis1) & 3; - - if (!pNext->IsMax()) - { - // if next edge is a minimum check the bounds and add an overlap if necessary - if (updateOverlaps && testOverlap2D(pHandleEdge, pHandleNext,axis1,axis2)) - { - Handle* handle0 = getHandle(pEdge->m_handle); - Handle* handle1 = getHandle(pNext->m_handle); - m_pairCache->addOverlappingPair(handle0,handle1); - if (m_userPairCallback) - m_userPairCallback->addOverlappingPair(handle0,handle1); - } - - // update edge reference in other handle - pHandleNext->m_minEdges[axis]--; - } - else - pHandleNext->m_maxEdges[axis]--; - - pHandleEdge->m_maxEdges[axis]++; - - // swap the edges - Edge swap = *pEdge; - *pEdge = *pNext; - *pNext = swap; - - // increment - pEdge++; - pNext++; - } - -} - - - -//////////////////////////////////////////////////////////////////// - - -/// The btAxisSweep3 is an efficient implementation of the 3d axis sweep and prune broadphase. -/// It uses arrays rather then lists for storage of the 3 axis. Also it operates using 16 bit integer coordinates instead of floats. -/// For large worlds and many objects, use bt32BitAxisSweep3 or btDbvtBroadphase instead. bt32BitAxisSweep3 has higher precision and allows more then 16384 objects at the cost of more memory and bit of performance. -class btAxisSweep3 : public btAxisSweep3Internal -{ -public: - - btAxisSweep3(const btVector3& worldAabbMin,const btVector3& worldAabbMax, unsigned short int maxHandles = 16384, btOverlappingPairCache* pairCache = 0, bool disableRaycastAccelerator = false); - -}; - -/// The bt32BitAxisSweep3 allows higher precision quantization and more objects compared to the btAxisSweep3 sweep and prune. -/// This comes at the cost of more memory per handle, and a bit slower performance. -/// It uses arrays rather then lists for storage of the 3 axis. -class bt32BitAxisSweep3 : public btAxisSweep3Internal -{ -public: - - bt32BitAxisSweep3(const btVector3& worldAabbMin,const btVector3& worldAabbMax, unsigned int maxHandles = 1500000, btOverlappingPairCache* pairCache = 0, bool disableRaycastAccelerator = false); - -}; - -#endif - diff --git a/bullet/src/BulletCollision/BroadphaseCollision/btBroadphaseInterface.h b/bullet/src/BulletCollision/BroadphaseCollision/btBroadphaseInterface.h deleted file mode 100644 index c650bcc76..000000000 --- a/bullet/src/BulletCollision/BroadphaseCollision/btBroadphaseInterface.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef BROADPHASE_INTERFACE_H -#define BROADPHASE_INTERFACE_H - - - -struct btDispatcherInfo; -class btDispatcher; -#include "btBroadphaseProxy.h" - -class btOverlappingPairCache; - - - -struct btBroadphaseRayCallback -{ - ///added some cached data to accelerate ray-AABB tests - btVector3 m_rayDirectionInverse; - unsigned int m_signs[3]; - btScalar m_lambda_max; - - virtual ~btBroadphaseRayCallback() {} - virtual bool process(const btBroadphaseProxy* proxy) = 0; -}; - -#include "LinearMath/btVector3.h" - -///The btBroadphaseInterface class provides an interface to detect aabb-overlapping object pairs. -///Some implementations for this broadphase interface include btAxisSweep3, bt32BitAxisSweep3 and btDbvtBroadphase. -///The actual overlapping pair management, storage, adding and removing of pairs is dealt by the btOverlappingPairCache class. -class btBroadphaseInterface -{ -public: - virtual ~btBroadphaseInterface() {} - - virtual btBroadphaseProxy* createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr, short int collisionFilterGroup,short int collisionFilterMask, btDispatcher* dispatcher,void* multiSapProxy) =0; - virtual void destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher)=0; - virtual void setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax, btDispatcher* dispatcher)=0; - virtual void getAabb(btBroadphaseProxy* proxy,btVector3& aabbMin, btVector3& aabbMax ) const =0; - - virtual void rayTest(const btVector3& rayFrom,const btVector3& rayTo, btBroadphaseRayCallback& rayCallback, const btVector3& aabbMin=btVector3(0,0,0), const btVector3& aabbMax = btVector3(0,0,0)) = 0; - - ///calculateOverlappingPairs is optional: incremental algorithms (sweep and prune) might do it during the set aabb - virtual void calculateOverlappingPairs(btDispatcher* dispatcher)=0; - - virtual btOverlappingPairCache* getOverlappingPairCache()=0; - virtual const btOverlappingPairCache* getOverlappingPairCache() const =0; - - ///getAabb returns the axis aligned bounding box in the 'global' coordinate frame - ///will add some transform later - virtual void getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const =0; - - ///reset broadphase internal structures, to ensure determinism/reproducability - virtual void resetPool(btDispatcher* dispatcher) {}; - - virtual void printStats() = 0; - -}; - -#endif //BROADPHASE_INTERFACE_H diff --git a/bullet/src/BulletCollision/BroadphaseCollision/btBroadphaseProxy.cpp b/bullet/src/BulletCollision/BroadphaseCollision/btBroadphaseProxy.cpp deleted file mode 100644 index 63e97f2ac..000000000 --- a/bullet/src/BulletCollision/BroadphaseCollision/btBroadphaseProxy.cpp +++ /dev/null @@ -1,17 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btBroadphaseProxy.h" - diff --git a/bullet/src/BulletCollision/BroadphaseCollision/btBroadphaseProxy.h b/bullet/src/BulletCollision/BroadphaseCollision/btBroadphaseProxy.h deleted file mode 100644 index e08e5aa92..000000000 --- a/bullet/src/BulletCollision/BroadphaseCollision/btBroadphaseProxy.h +++ /dev/null @@ -1,259 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef BROADPHASE_PROXY_H -#define BROADPHASE_PROXY_H - -#include "LinearMath/btScalar.h" //for SIMD_FORCE_INLINE -#include "LinearMath/btVector3.h" -#include "LinearMath/btAlignedAllocator.h" - - -/// btDispatcher uses these types -/// IMPORTANT NOTE:The types are ordered polyhedral, implicit convex and concave -/// to facilitate type checking -/// CUSTOM_POLYHEDRAL_SHAPE_TYPE,CUSTOM_CONVEX_SHAPE_TYPE and CUSTOM_CONCAVE_SHAPE_TYPE can be used to extend Bullet without modifying source code -enum BroadphaseNativeTypes -{ - // polyhedral convex shapes - BOX_SHAPE_PROXYTYPE, - TRIANGLE_SHAPE_PROXYTYPE, - TETRAHEDRAL_SHAPE_PROXYTYPE, - CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE, - CONVEX_HULL_SHAPE_PROXYTYPE, - CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE, - CUSTOM_POLYHEDRAL_SHAPE_TYPE, -//implicit convex shapes -IMPLICIT_CONVEX_SHAPES_START_HERE, - SPHERE_SHAPE_PROXYTYPE, - MULTI_SPHERE_SHAPE_PROXYTYPE, - CAPSULE_SHAPE_PROXYTYPE, - CONE_SHAPE_PROXYTYPE, - CONVEX_SHAPE_PROXYTYPE, - CYLINDER_SHAPE_PROXYTYPE, - UNIFORM_SCALING_SHAPE_PROXYTYPE, - MINKOWSKI_SUM_SHAPE_PROXYTYPE, - MINKOWSKI_DIFFERENCE_SHAPE_PROXYTYPE, - BOX_2D_SHAPE_PROXYTYPE, - CONVEX_2D_SHAPE_PROXYTYPE, - CUSTOM_CONVEX_SHAPE_TYPE, -//concave shapes -CONCAVE_SHAPES_START_HERE, - //keep all the convex shapetype below here, for the check IsConvexShape in broadphase proxy! - TRIANGLE_MESH_SHAPE_PROXYTYPE, - SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE, - ///used for demo integration FAST/Swift collision library and Bullet - FAST_CONCAVE_MESH_PROXYTYPE, - //terrain - TERRAIN_SHAPE_PROXYTYPE, -///Used for GIMPACT Trimesh integration - GIMPACT_SHAPE_PROXYTYPE, -///Multimaterial mesh - MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE, - - EMPTY_SHAPE_PROXYTYPE, - STATIC_PLANE_PROXYTYPE, - CUSTOM_CONCAVE_SHAPE_TYPE, -CONCAVE_SHAPES_END_HERE, - - COMPOUND_SHAPE_PROXYTYPE, - - SOFTBODY_SHAPE_PROXYTYPE, - HFFLUID_SHAPE_PROXYTYPE, - HFFLUID_BUOYANT_CONVEX_SHAPE_PROXYTYPE, - INVALID_SHAPE_PROXYTYPE, - - MAX_BROADPHASE_COLLISION_TYPES - -}; - - -///The btBroadphaseProxy is the main class that can be used with the Bullet broadphases. -///It stores collision shape type information, collision filter information and a client object, typically a btCollisionObject or btRigidBody. -ATTRIBUTE_ALIGNED16(struct) btBroadphaseProxy -{ - -BT_DECLARE_ALIGNED_ALLOCATOR(); - - ///optional filtering to cull potential collisions - enum CollisionFilterGroups - { - DefaultFilter = 1, - StaticFilter = 2, - KinematicFilter = 4, - DebrisFilter = 8, - SensorTrigger = 16, - CharacterFilter = 32, - AllFilter = -1 //all bits sets: DefaultFilter | StaticFilter | KinematicFilter | DebrisFilter | SensorTrigger - }; - - //Usually the client btCollisionObject or Rigidbody class - void* m_clientObject; - short int m_collisionFilterGroup; - short int m_collisionFilterMask; - void* m_multiSapParentProxy; - int m_uniqueId;//m_uniqueId is introduced for paircache. could get rid of this, by calculating the address offset etc. - - btVector3 m_aabbMin; - btVector3 m_aabbMax; - - SIMD_FORCE_INLINE int getUid() const - { - return m_uniqueId; - } - - //used for memory pools - btBroadphaseProxy() :m_clientObject(0),m_multiSapParentProxy(0) - { - } - - btBroadphaseProxy(const btVector3& aabbMin,const btVector3& aabbMax,void* userPtr,short int collisionFilterGroup, short int collisionFilterMask,void* multiSapParentProxy=0) - :m_clientObject(userPtr), - m_collisionFilterGroup(collisionFilterGroup), - m_collisionFilterMask(collisionFilterMask), - m_aabbMin(aabbMin), - m_aabbMax(aabbMax) - { - m_multiSapParentProxy = multiSapParentProxy; - } - - - - static SIMD_FORCE_INLINE bool isPolyhedral(int proxyType) - { - return (proxyType < IMPLICIT_CONVEX_SHAPES_START_HERE); - } - - static SIMD_FORCE_INLINE bool isConvex(int proxyType) - { - return (proxyType < CONCAVE_SHAPES_START_HERE); - } - - static SIMD_FORCE_INLINE bool isConcave(int proxyType) - { - return ((proxyType > CONCAVE_SHAPES_START_HERE) && - (proxyType < CONCAVE_SHAPES_END_HERE)); - } - static SIMD_FORCE_INLINE bool isCompound(int proxyType) - { - return (proxyType == COMPOUND_SHAPE_PROXYTYPE); - } - static SIMD_FORCE_INLINE bool isInfinite(int proxyType) - { - return (proxyType == STATIC_PLANE_PROXYTYPE); - } - - static SIMD_FORCE_INLINE bool isConvex2d(int proxyType) - { - return (proxyType == BOX_2D_SHAPE_PROXYTYPE) || (proxyType == CONVEX_2D_SHAPE_PROXYTYPE); - } - - -} -; - -class btCollisionAlgorithm; - -struct btBroadphaseProxy; - - - -///The btBroadphasePair class contains a pair of aabb-overlapping objects. -///A btDispatcher can search a btCollisionAlgorithm that performs exact/narrowphase collision detection on the actual collision shapes. -ATTRIBUTE_ALIGNED16(struct) btBroadphasePair -{ - btBroadphasePair () - : - m_pProxy0(0), - m_pProxy1(0), - m_algorithm(0), - m_internalInfo1(0) - { - } - -BT_DECLARE_ALIGNED_ALLOCATOR(); - - btBroadphasePair(const btBroadphasePair& other) - : m_pProxy0(other.m_pProxy0), - m_pProxy1(other.m_pProxy1), - m_algorithm(other.m_algorithm), - m_internalInfo1(other.m_internalInfo1) - { - } - btBroadphasePair(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1) - { - - //keep them sorted, so the std::set operations work - if (proxy0.m_uniqueId < proxy1.m_uniqueId) - { - m_pProxy0 = &proxy0; - m_pProxy1 = &proxy1; - } - else - { - m_pProxy0 = &proxy1; - m_pProxy1 = &proxy0; - } - - m_algorithm = 0; - m_internalInfo1 = 0; - - } - - btBroadphaseProxy* m_pProxy0; - btBroadphaseProxy* m_pProxy1; - - mutable btCollisionAlgorithm* m_algorithm; - union { void* m_internalInfo1; int m_internalTmpValue;};//don't use this data, it will be removed in future version. - -}; - -/* -//comparison for set operation, see Solid DT_Encounter -SIMD_FORCE_INLINE bool operator<(const btBroadphasePair& a, const btBroadphasePair& b) -{ - return a.m_pProxy0 < b.m_pProxy0 || - (a.m_pProxy0 == b.m_pProxy0 && a.m_pProxy1 < b.m_pProxy1); -} -*/ - - - -class btBroadphasePairSortPredicate -{ - public: - - bool operator() ( const btBroadphasePair& a, const btBroadphasePair& b ) - { - const int uidA0 = a.m_pProxy0 ? a.m_pProxy0->m_uniqueId : -1; - const int uidB0 = b.m_pProxy0 ? b.m_pProxy0->m_uniqueId : -1; - const int uidA1 = a.m_pProxy1 ? a.m_pProxy1->m_uniqueId : -1; - const int uidB1 = b.m_pProxy1 ? b.m_pProxy1->m_uniqueId : -1; - - return uidA0 > uidB0 || - (a.m_pProxy0 == b.m_pProxy0 && uidA1 > uidB1) || - (a.m_pProxy0 == b.m_pProxy0 && a.m_pProxy1 == b.m_pProxy1 && a.m_algorithm > b.m_algorithm); - } -}; - - -SIMD_FORCE_INLINE bool operator==(const btBroadphasePair& a, const btBroadphasePair& b) -{ - return (a.m_pProxy0 == b.m_pProxy0) && (a.m_pProxy1 == b.m_pProxy1); -} - - -#endif //BROADPHASE_PROXY_H - diff --git a/bullet/src/BulletCollision/BroadphaseCollision/btCollisionAlgorithm.cpp b/bullet/src/BulletCollision/BroadphaseCollision/btCollisionAlgorithm.cpp deleted file mode 100644 index de8b77166..000000000 --- a/bullet/src/BulletCollision/BroadphaseCollision/btCollisionAlgorithm.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btCollisionAlgorithm.h" -#include "btDispatcher.h" - -btCollisionAlgorithm::btCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci) -{ - m_dispatcher = ci.m_dispatcher1; -} - diff --git a/bullet/src/BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h b/bullet/src/BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h deleted file mode 100644 index 381f055a3..000000000 --- a/bullet/src/BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef COLLISION_ALGORITHM_H -#define COLLISION_ALGORITHM_H - -#include "LinearMath/btScalar.h" -#include "LinearMath/btAlignedObjectArray.h" - -struct btBroadphaseProxy; -class btDispatcher; -class btManifoldResult; -class btCollisionObject; -struct btDispatcherInfo; -class btPersistentManifold; - -typedef btAlignedObjectArray btManifoldArray; - -struct btCollisionAlgorithmConstructionInfo -{ - btCollisionAlgorithmConstructionInfo() - :m_dispatcher1(0), - m_manifold(0) - { - } - btCollisionAlgorithmConstructionInfo(btDispatcher* dispatcher,int temp) - :m_dispatcher1(dispatcher) - { - (void)temp; - } - - btDispatcher* m_dispatcher1; - btPersistentManifold* m_manifold; - - int getDispatcherId(); - -}; - - -///btCollisionAlgorithm is an collision interface that is compatible with the Broadphase and btDispatcher. -///It is persistent over frames -class btCollisionAlgorithm -{ - -protected: - - btDispatcher* m_dispatcher; - -protected: - int getDispatcherId(); - -public: - - btCollisionAlgorithm() {}; - - btCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci); - - virtual ~btCollisionAlgorithm() {}; - - virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) = 0; - - virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) = 0; - - virtual void getAllContactManifolds(btManifoldArray& manifoldArray) = 0; -}; - - -#endif //COLLISION_ALGORITHM_H diff --git a/bullet/src/BulletCollision/BroadphaseCollision/btDbvt.cpp b/bullet/src/BulletCollision/BroadphaseCollision/btDbvt.cpp deleted file mode 100644 index b5603dae0..000000000 --- a/bullet/src/BulletCollision/BroadphaseCollision/btDbvt.cpp +++ /dev/null @@ -1,1295 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ -///btDbvt implementation by Nathanael Presson - -#include "btDbvt.h" - -// -typedef btAlignedObjectArray tNodeArray; -typedef btAlignedObjectArray tConstNodeArray; - -// -struct btDbvtNodeEnumerator : btDbvt::ICollide -{ - tConstNodeArray nodes; - void Process(const btDbvtNode* n) { nodes.push_back(n); } -}; - -// -static DBVT_INLINE int indexof(const btDbvtNode* node) -{ - return(node->parent->childs[1]==node); -} - -// -static DBVT_INLINE btDbvtVolume merge( const btDbvtVolume& a, - const btDbvtVolume& b) -{ -#if (DBVT_MERGE_IMPL==DBVT_IMPL_SSE) - ATTRIBUTE_ALIGNED16(char locals[sizeof(btDbvtAabbMm)]); - btDbvtVolume& res=*(btDbvtVolume*)locals; -#else - btDbvtVolume res; -#endif - Merge(a,b,res); - return(res); -} - -// volume+edge lengths -static DBVT_INLINE btScalar size(const btDbvtVolume& a) -{ - const btVector3 edges=a.Lengths(); - return( edges.x()*edges.y()*edges.z()+ - edges.x()+edges.y()+edges.z()); -} - -// -static void getmaxdepth(const btDbvtNode* node,int depth,int& maxdepth) -{ - if(node->isinternal()) - { - getmaxdepth(node->childs[0],depth+1,maxdepth); - getmaxdepth(node->childs[0],depth+1,maxdepth); - } else maxdepth=btMax(maxdepth,depth); -} - -// -static DBVT_INLINE void deletenode( btDbvt* pdbvt, - btDbvtNode* node) -{ - btAlignedFree(pdbvt->m_free); - pdbvt->m_free=node; -} - -// -static void recursedeletenode( btDbvt* pdbvt, - btDbvtNode* node) -{ - if(!node->isleaf()) - { - recursedeletenode(pdbvt,node->childs[0]); - recursedeletenode(pdbvt,node->childs[1]); - } - if(node==pdbvt->m_root) pdbvt->m_root=0; - deletenode(pdbvt,node); -} - -// -static DBVT_INLINE btDbvtNode* createnode( btDbvt* pdbvt, - btDbvtNode* parent, - void* data) -{ - btDbvtNode* node; - if(pdbvt->m_free) - { node=pdbvt->m_free;pdbvt->m_free=0; } - else - { node=new(btAlignedAlloc(sizeof(btDbvtNode),16)) btDbvtNode(); } - node->parent = parent; - node->data = data; - node->childs[1] = 0; - return(node); -} - -// -static DBVT_INLINE btDbvtNode* createnode( btDbvt* pdbvt, - btDbvtNode* parent, - const btDbvtVolume& volume, - void* data) -{ - btDbvtNode* node=createnode(pdbvt,parent,data); - node->volume=volume; - return(node); -} - -// -static DBVT_INLINE btDbvtNode* createnode( btDbvt* pdbvt, - btDbvtNode* parent, - const btDbvtVolume& volume0, - const btDbvtVolume& volume1, - void* data) -{ - btDbvtNode* node=createnode(pdbvt,parent,data); - Merge(volume0,volume1,node->volume); - return(node); -} - -// -static void insertleaf( btDbvt* pdbvt, - btDbvtNode* root, - btDbvtNode* leaf) -{ - if(!pdbvt->m_root) - { - pdbvt->m_root = leaf; - leaf->parent = 0; - } - else - { - if(!root->isleaf()) - { - do { - root=root->childs[Select( leaf->volume, - root->childs[0]->volume, - root->childs[1]->volume)]; - } while(!root->isleaf()); - } - btDbvtNode* prev=root->parent; - btDbvtNode* node=createnode(pdbvt,prev,leaf->volume,root->volume,0); - if(prev) - { - prev->childs[indexof(root)] = node; - node->childs[0] = root;root->parent=node; - node->childs[1] = leaf;leaf->parent=node; - do { - if(!prev->volume.Contain(node->volume)) - Merge(prev->childs[0]->volume,prev->childs[1]->volume,prev->volume); - else - break; - node=prev; - } while(0!=(prev=node->parent)); - } - else - { - node->childs[0] = root;root->parent=node; - node->childs[1] = leaf;leaf->parent=node; - pdbvt->m_root = node; - } - } -} - -// -static btDbvtNode* removeleaf( btDbvt* pdbvt, - btDbvtNode* leaf) -{ - if(leaf==pdbvt->m_root) - { - pdbvt->m_root=0; - return(0); - } - else - { - btDbvtNode* parent=leaf->parent; - btDbvtNode* prev=parent->parent; - btDbvtNode* sibling=parent->childs[1-indexof(leaf)]; - if(prev) - { - prev->childs[indexof(parent)]=sibling; - sibling->parent=prev; - deletenode(pdbvt,parent); - while(prev) - { - const btDbvtVolume pb=prev->volume; - Merge(prev->childs[0]->volume,prev->childs[1]->volume,prev->volume); - if(NotEqual(pb,prev->volume)) - { - prev=prev->parent; - } else break; - } - return(prev?prev:pdbvt->m_root); - } - else - { - pdbvt->m_root=sibling; - sibling->parent=0; - deletenode(pdbvt,parent); - return(pdbvt->m_root); - } - } -} - -// -static void fetchleaves(btDbvt* pdbvt, - btDbvtNode* root, - tNodeArray& leaves, - int depth=-1) -{ - if(root->isinternal()&&depth) - { - fetchleaves(pdbvt,root->childs[0],leaves,depth-1); - fetchleaves(pdbvt,root->childs[1],leaves,depth-1); - deletenode(pdbvt,root); - } - else - { - leaves.push_back(root); - } -} - -// -static void split( const tNodeArray& leaves, - tNodeArray& left, - tNodeArray& right, - const btVector3& org, - const btVector3& axis) -{ - left.resize(0); - right.resize(0); - for(int i=0,ni=leaves.size();ivolume.Center()-org)<0) - left.push_back(leaves[i]); - else - right.push_back(leaves[i]); - } -} - -// -static btDbvtVolume bounds( const tNodeArray& leaves) -{ -#if DBVT_MERGE_IMPL==DBVT_IMPL_SSE - ATTRIBUTE_ALIGNED16(char locals[sizeof(btDbvtVolume)]); - btDbvtVolume& volume=*(btDbvtVolume*)locals; - volume=leaves[0]->volume; -#else - btDbvtVolume volume=leaves[0]->volume; -#endif - for(int i=1,ni=leaves.size();ivolume,volume); - } - return(volume); -} - -// -static void bottomup( btDbvt* pdbvt, - tNodeArray& leaves) -{ - while(leaves.size()>1) - { - btScalar minsize=SIMD_INFINITY; - int minidx[2]={-1,-1}; - for(int i=0;ivolume,leaves[j]->volume)); - if(szvolume,n[1]->volume,0); - p->childs[0] = n[0]; - p->childs[1] = n[1]; - n[0]->parent = p; - n[1]->parent = p; - leaves[minidx[0]] = p; - leaves.swap(minidx[1],leaves.size()-1); - leaves.pop_back(); - } -} - -// -static btDbvtNode* topdown(btDbvt* pdbvt, - tNodeArray& leaves, - int bu_treshold) -{ - static const btVector3 axis[]={btVector3(1,0,0), - btVector3(0,1,0), - btVector3(0,0,1)}; - if(leaves.size()>1) - { - if(leaves.size()>bu_treshold) - { - const btDbvtVolume vol=bounds(leaves); - const btVector3 org=vol.Center(); - tNodeArray sets[2]; - int bestaxis=-1; - int bestmidp=leaves.size(); - int splitcount[3][2]={{0,0},{0,0},{0,0}}; - int i; - for( i=0;ivolume.Center()-org; - for(int j=0;j<3;++j) - { - ++splitcount[j][btDot(x,axis[j])>0?1:0]; - } - } - for( i=0;i<3;++i) - { - if((splitcount[i][0]>0)&&(splitcount[i][1]>0)) - { - const int midp=(int)btFabs(btScalar(splitcount[i][0]-splitcount[i][1])); - if(midp=0) - { - sets[0].reserve(splitcount[bestaxis][0]); - sets[1].reserve(splitcount[bestaxis][1]); - split(leaves,sets[0],sets[1],org,axis[bestaxis]); - } - else - { - sets[0].reserve(leaves.size()/2+1); - sets[1].reserve(leaves.size()/2); - for(int i=0,ni=leaves.size();ichilds[0]=topdown(pdbvt,sets[0],bu_treshold); - node->childs[1]=topdown(pdbvt,sets[1],bu_treshold); - node->childs[0]->parent=node; - node->childs[1]->parent=node; - return(node); - } - else - { - bottomup(pdbvt,leaves); - return(leaves[0]); - } - } - return(leaves[0]); -} - -// -static DBVT_INLINE btDbvtNode* sort(btDbvtNode* n,btDbvtNode*& r) -{ - btDbvtNode* p=n->parent; - btAssert(n->isinternal()); - if(p>n) - { - const int i=indexof(n); - const int j=1-i; - btDbvtNode* s=p->childs[j]; - btDbvtNode* q=p->parent; - btAssert(n==p->childs[i]); - if(q) q->childs[indexof(p)]=n; else r=n; - s->parent=n; - p->parent=n; - n->parent=q; - p->childs[0]=n->childs[0]; - p->childs[1]=n->childs[1]; - n->childs[0]->parent=p; - n->childs[1]->parent=p; - n->childs[i]=p; - n->childs[j]=s; - btSwap(p->volume,n->volume); - return(p); - } - return(n); -} - -#if 0 -static DBVT_INLINE btDbvtNode* walkup(btDbvtNode* n,int count) -{ - while(n&&(count--)) n=n->parent; - return(n); -} -#endif - -// -// Api -// - -// -btDbvt::btDbvt() -{ - m_root = 0; - m_free = 0; - m_lkhd = -1; - m_leaves = 0; - m_opath = 0; -} - -// -btDbvt::~btDbvt() -{ - clear(); -} - -// -void btDbvt::clear() -{ - if(m_root) - recursedeletenode(this,m_root); - btAlignedFree(m_free); - m_free=0; - m_lkhd = -1; - m_stkStack.clear(); - m_opath = 0; - -} - -// -void btDbvt::optimizeBottomUp() -{ - if(m_root) - { - tNodeArray leaves; - leaves.reserve(m_leaves); - fetchleaves(this,m_root,leaves); - bottomup(this,leaves); - m_root=leaves[0]; - } -} - -// -void btDbvt::optimizeTopDown(int bu_treshold) -{ - if(m_root) - { - tNodeArray leaves; - leaves.reserve(m_leaves); - fetchleaves(this,m_root,leaves); - m_root=topdown(this,leaves,bu_treshold); - } -} - -// -void btDbvt::optimizeIncremental(int passes) -{ - if(passes<0) passes=m_leaves; - if(m_root&&(passes>0)) - { - do { - btDbvtNode* node=m_root; - unsigned bit=0; - while(node->isinternal()) - { - node=sort(node,m_root)->childs[(m_opath>>bit)&1]; - bit=(bit+1)&(sizeof(unsigned)*8-1); - } - update(node); - ++m_opath; - } while(--passes); - } -} - -// -btDbvtNode* btDbvt::insert(const btDbvtVolume& volume,void* data) -{ - btDbvtNode* leaf=createnode(this,0,volume,data); - insertleaf(this,m_root,leaf); - ++m_leaves; - return(leaf); -} - -// -void btDbvt::update(btDbvtNode* leaf,int lookahead) -{ - btDbvtNode* root=removeleaf(this,leaf); - if(root) - { - if(lookahead>=0) - { - for(int i=0;(iparent;++i) - { - root=root->parent; - } - } else root=m_root; - } - insertleaf(this,root,leaf); -} - -// -void btDbvt::update(btDbvtNode* leaf,btDbvtVolume& volume) -{ - btDbvtNode* root=removeleaf(this,leaf); - if(root) - { - if(m_lkhd>=0) - { - for(int i=0;(iparent;++i) - { - root=root->parent; - } - } else root=m_root; - } - leaf->volume=volume; - insertleaf(this,root,leaf); -} - -// -bool btDbvt::update(btDbvtNode* leaf,btDbvtVolume& volume,const btVector3& velocity,btScalar margin) -{ - if(leaf->volume.Contain(volume)) return(false); - volume.Expand(btVector3(margin,margin,margin)); - volume.SignedExpand(velocity); - update(leaf,volume); - return(true); -} - -// -bool btDbvt::update(btDbvtNode* leaf,btDbvtVolume& volume,const btVector3& velocity) -{ - if(leaf->volume.Contain(volume)) return(false); - volume.SignedExpand(velocity); - update(leaf,volume); - return(true); -} - -// -bool btDbvt::update(btDbvtNode* leaf,btDbvtVolume& volume,btScalar margin) -{ - if(leaf->volume.Contain(volume)) return(false); - volume.Expand(btVector3(margin,margin,margin)); - update(leaf,volume); - return(true); -} - -// -void btDbvt::remove(btDbvtNode* leaf) -{ - removeleaf(this,leaf); - deletenode(this,leaf); - --m_leaves; -} - -// -void btDbvt::write(IWriter* iwriter) const -{ - btDbvtNodeEnumerator nodes; - nodes.nodes.reserve(m_leaves*2); - enumNodes(m_root,nodes); - iwriter->Prepare(m_root,nodes.nodes.size()); - for(int i=0;iparent) p=nodes.nodes.findLinearSearch(n->parent); - if(n->isinternal()) - { - const int c0=nodes.nodes.findLinearSearch(n->childs[0]); - const int c1=nodes.nodes.findLinearSearch(n->childs[1]); - iwriter->WriteNode(n,i,p,c0,c1); - } - else - { - iwriter->WriteLeaf(n,i,p); - } - } -} - -// -void btDbvt::clone(btDbvt& dest,IClone* iclone) const -{ - dest.clear(); - if(m_root!=0) - { - btAlignedObjectArray stack; - stack.reserve(m_leaves); - stack.push_back(sStkCLN(m_root,0)); - do { - const int i=stack.size()-1; - const sStkCLN e=stack[i]; - btDbvtNode* n=createnode(&dest,e.parent,e.node->volume,e.node->data); - stack.pop_back(); - if(e.parent!=0) - e.parent->childs[i&1]=n; - else - dest.m_root=n; - if(e.node->isinternal()) - { - stack.push_back(sStkCLN(e.node->childs[0],n)); - stack.push_back(sStkCLN(e.node->childs[1],n)); - } - else - { - iclone->CloneLeaf(n); - } - } while(stack.size()>0); - } -} - -// -int btDbvt::maxdepth(const btDbvtNode* node) -{ - int depth=0; - if(node) getmaxdepth(node,1,depth); - return(depth); -} - -// -int btDbvt::countLeaves(const btDbvtNode* node) -{ - if(node->isinternal()) - return(countLeaves(node->childs[0])+countLeaves(node->childs[1])); - else - return(1); -} - -// -void btDbvt::extractLeaves(const btDbvtNode* node,btAlignedObjectArray& leaves) -{ - if(node->isinternal()) - { - extractLeaves(node->childs[0],leaves); - extractLeaves(node->childs[1],leaves); - } - else - { - leaves.push_back(node); - } -} - -// -#if DBVT_ENABLE_BENCHMARK - -#include -#include -#include "LinearMath/btQuickProf.h" - -/* -q6600,2.4ghz - -/Ox /Ob2 /Oi /Ot /I "." /I "..\.." /I "..\..\src" /D "NDEBUG" /D "_LIB" /D "_WINDOWS" /D "_CRT_SECURE_NO_DEPRECATE" /D "_CRT_NONSTDC_NO_DEPRECATE" /D "WIN32" -/GF /FD /MT /GS- /Gy /arch:SSE2 /Zc:wchar_t- /Fp"..\..\out\release8\build\libbulletcollision\libbulletcollision.pch" -/Fo"..\..\out\release8\build\libbulletcollision\\" -/Fd"..\..\out\release8\build\libbulletcollision\bulletcollision.pdb" -/W3 /nologo /c /Wp64 /Zi /errorReport:prompt - -Benchmarking dbvt... -World scale: 100.000000 -Extents base: 1.000000 -Extents range: 4.000000 -Leaves: 8192 -sizeof(btDbvtVolume): 32 bytes -sizeof(btDbvtNode): 44 bytes -[1] btDbvtVolume intersections: 3499 ms (-1%) -[2] btDbvtVolume merges: 1934 ms (0%) -[3] btDbvt::collideTT: 5485 ms (-21%) -[4] btDbvt::collideTT self: 2814 ms (-20%) -[5] btDbvt::collideTT xform: 7379 ms (-1%) -[6] btDbvt::collideTT xform,self: 7270 ms (-2%) -[7] btDbvt::rayTest: 6314 ms (0%),(332143 r/s) -[8] insert/remove: 2093 ms (0%),(1001983 ir/s) -[9] updates (teleport): 1879 ms (-3%),(1116100 u/s) -[10] updates (jitter): 1244 ms (-4%),(1685813 u/s) -[11] optimize (incremental): 2514 ms (0%),(1668000 o/s) -[12] btDbvtVolume notequal: 3659 ms (0%) -[13] culling(OCL+fullsort): 2218 ms (0%),(461 t/s) -[14] culling(OCL+qsort): 3688 ms (5%),(2221 t/s) -[15] culling(KDOP+qsort): 1139 ms (-1%),(7192 t/s) -[16] insert/remove batch(256): 5092 ms (0%),(823704 bir/s) -[17] btDbvtVolume select: 3419 ms (0%) -*/ - -struct btDbvtBenchmark -{ - struct NilPolicy : btDbvt::ICollide - { - NilPolicy() : m_pcount(0),m_depth(-SIMD_INFINITY),m_checksort(true) {} - void Process(const btDbvtNode*,const btDbvtNode*) { ++m_pcount; } - void Process(const btDbvtNode*) { ++m_pcount; } - void Process(const btDbvtNode*,btScalar depth) - { - ++m_pcount; - if(m_checksort) - { if(depth>=m_depth) m_depth=depth; else printf("wrong depth: %f (should be >= %f)\r\n",depth,m_depth); } - } - int m_pcount; - btScalar m_depth; - bool m_checksort; - }; - struct P14 : btDbvt::ICollide - { - struct Node - { - const btDbvtNode* leaf; - btScalar depth; - }; - void Process(const btDbvtNode* leaf,btScalar depth) - { - Node n; - n.leaf = leaf; - n.depth = depth; - } - static int sortfnc(const Node& a,const Node& b) - { - if(a.depthb.depth) return(-1); - return(0); - } - btAlignedObjectArray m_nodes; - }; - struct P15 : btDbvt::ICollide - { - struct Node - { - const btDbvtNode* leaf; - btScalar depth; - }; - void Process(const btDbvtNode* leaf) - { - Node n; - n.leaf = leaf; - n.depth = dot(leaf->volume.Center(),m_axis); - } - static int sortfnc(const Node& a,const Node& b) - { - if(a.depthb.depth) return(-1); - return(0); - } - btAlignedObjectArray m_nodes; - btVector3 m_axis; - }; - static btScalar RandUnit() - { - return(rand()/(btScalar)RAND_MAX); - } - static btVector3 RandVector3() - { - return(btVector3(RandUnit(),RandUnit(),RandUnit())); - } - static btVector3 RandVector3(btScalar cs) - { - return(RandVector3()*cs-btVector3(cs,cs,cs)/2); - } - static btDbvtVolume RandVolume(btScalar cs,btScalar eb,btScalar es) - { - return(btDbvtVolume::FromCE(RandVector3(cs),btVector3(eb,eb,eb)+RandVector3()*es)); - } - static btTransform RandTransform(btScalar cs) - { - btTransform t; - t.setOrigin(RandVector3(cs)); - t.setRotation(btQuaternion(RandUnit()*SIMD_PI*2,RandUnit()*SIMD_PI*2,RandUnit()*SIMD_PI*2).normalized()); - return(t); - } - static void RandTree(btScalar cs,btScalar eb,btScalar es,int leaves,btDbvt& dbvt) - { - dbvt.clear(); - for(int i=0;i volumes; - btAlignedObjectArray results; - volumes.resize(cfgLeaves); - results.resize(cfgLeaves); - for(int i=0;i volumes; - btAlignedObjectArray results; - volumes.resize(cfgLeaves); - results.resize(cfgLeaves); - for(int i=0;i transforms; - btDbvtBenchmark::NilPolicy policy; - transforms.resize(cfgBenchmark5_Iterations); - for(int i=0;i transforms; - btDbvtBenchmark::NilPolicy policy; - transforms.resize(cfgBenchmark6_Iterations); - for(int i=0;i rayorg; - btAlignedObjectArray raydir; - btDbvtBenchmark::NilPolicy policy; - rayorg.resize(cfgBenchmark7_Iterations); - raydir.resize(cfgBenchmark7_Iterations); - for(int i=0;i leaves; - btDbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt); - dbvt.optimizeTopDown(); - dbvt.extractLeaves(dbvt.m_root,leaves); - printf("[9] updates (teleport): "); - wallclock.reset(); - for(int i=0;i(leaves[rand()%cfgLeaves]), - btDbvtBenchmark::RandVolume(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale)); - } - } - const int time=(int)wallclock.getTimeMilliseconds(); - const int up=cfgBenchmark9_Passes*cfgBenchmark9_Iterations; - printf("%u ms (%i%%),(%u u/s)\r\n",time,(time-cfgBenchmark9_Reference)*100/time,up*1000/time); - } - if(cfgBenchmark10_Enable) - {// Benchmark 10 - srand(380843); - btDbvt dbvt; - btAlignedObjectArray leaves; - btAlignedObjectArray vectors; - vectors.resize(cfgBenchmark10_Iterations); - for(int i=0;i(leaves[rand()%cfgLeaves]); - btDbvtVolume v=btDbvtVolume::FromMM(l->volume.Mins()+d,l->volume.Maxs()+d); - dbvt.update(l,v); - } - } - const int time=(int)wallclock.getTimeMilliseconds(); - const int up=cfgBenchmark10_Passes*cfgBenchmark10_Iterations; - printf("%u ms (%i%%),(%u u/s)\r\n",time,(time-cfgBenchmark10_Reference)*100/time,up*1000/time); - } - if(cfgBenchmark11_Enable) - {// Benchmark 11 - srand(380843); - btDbvt dbvt; - btDbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt); - dbvt.optimizeTopDown(); - printf("[11] optimize (incremental): "); - wallclock.reset(); - for(int i=0;i volumes; - btAlignedObjectArray results; - volumes.resize(cfgLeaves); - results.resize(cfgLeaves); - for(int i=0;i vectors; - btDbvtBenchmark::NilPolicy policy; - vectors.resize(cfgBenchmark13_Iterations); - for(int i=0;i vectors; - btDbvtBenchmark::P14 policy; - vectors.resize(cfgBenchmark14_Iterations); - for(int i=0;i vectors; - btDbvtBenchmark::P15 policy; - vectors.resize(cfgBenchmark15_Iterations); - for(int i=0;i batch; - btDbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt); - dbvt.optimizeTopDown(); - batch.reserve(cfgBenchmark16_BatchCount); - printf("[16] insert/remove batch(%u): ",cfgBenchmark16_BatchCount); - wallclock.reset(); - for(int i=0;i volumes; - btAlignedObjectArray results; - btAlignedObjectArray indices; - volumes.resize(cfgLeaves); - results.resize(cfgLeaves); - indices.resize(cfgLeaves); - for(int i=0;i= 1400) -#define DBVT_USE_TEMPLATE 1 -#else -#define DBVT_USE_TEMPLATE 0 -#endif -#else -#define DBVT_USE_TEMPLATE 0 -#endif - -// Use only intrinsics instead of inline asm -#define DBVT_USE_INTRINSIC_SSE 1 - -// Using memmov for collideOCL -#define DBVT_USE_MEMMOVE 1 - -// Enable benchmarking code -#define DBVT_ENABLE_BENCHMARK 0 - -// Inlining -#define DBVT_INLINE SIMD_FORCE_INLINE - -// Specific methods implementation - -//SSE gives errors on a MSVC 7.1 -#if defined (BT_USE_SSE) && defined (WIN32) -#define DBVT_SELECT_IMPL DBVT_IMPL_SSE -#define DBVT_MERGE_IMPL DBVT_IMPL_SSE -#define DBVT_INT0_IMPL DBVT_IMPL_SSE -#else -#define DBVT_SELECT_IMPL DBVT_IMPL_GENERIC -#define DBVT_MERGE_IMPL DBVT_IMPL_GENERIC -#define DBVT_INT0_IMPL DBVT_IMPL_GENERIC -#endif - -#if (DBVT_SELECT_IMPL==DBVT_IMPL_SSE)|| \ - (DBVT_MERGE_IMPL==DBVT_IMPL_SSE)|| \ - (DBVT_INT0_IMPL==DBVT_IMPL_SSE) -#include -#endif - -// -// Auto config and checks -// - -#if DBVT_USE_TEMPLATE -#define DBVT_VIRTUAL -#define DBVT_VIRTUAL_DTOR(a) -#define DBVT_PREFIX template -#define DBVT_IPOLICY T& policy -#define DBVT_CHECKTYPE static const ICollide& typechecker=*(T*)1;(void)typechecker; -#else -#define DBVT_VIRTUAL_DTOR(a) virtual ~a() {} -#define DBVT_VIRTUAL virtual -#define DBVT_PREFIX -#define DBVT_IPOLICY ICollide& policy -#define DBVT_CHECKTYPE -#endif - -#if DBVT_USE_MEMMOVE -#ifndef __CELLOS_LV2__ -#include -#endif -#include -#endif - -#ifndef DBVT_USE_TEMPLATE -#error "DBVT_USE_TEMPLATE undefined" -#endif - -#ifndef DBVT_USE_MEMMOVE -#error "DBVT_USE_MEMMOVE undefined" -#endif - -#ifndef DBVT_ENABLE_BENCHMARK -#error "DBVT_ENABLE_BENCHMARK undefined" -#endif - -#ifndef DBVT_SELECT_IMPL -#error "DBVT_SELECT_IMPL undefined" -#endif - -#ifndef DBVT_MERGE_IMPL -#error "DBVT_MERGE_IMPL undefined" -#endif - -#ifndef DBVT_INT0_IMPL -#error "DBVT_INT0_IMPL undefined" -#endif - -// -// Defaults volumes -// - -/* btDbvtAabbMm */ -struct btDbvtAabbMm -{ - DBVT_INLINE btVector3 Center() const { return((mi+mx)/2); } - DBVT_INLINE btVector3 Lengths() const { return(mx-mi); } - DBVT_INLINE btVector3 Extents() const { return((mx-mi)/2); } - DBVT_INLINE const btVector3& Mins() const { return(mi); } - DBVT_INLINE const btVector3& Maxs() const { return(mx); } - static inline btDbvtAabbMm FromCE(const btVector3& c,const btVector3& e); - static inline btDbvtAabbMm FromCR(const btVector3& c,btScalar r); - static inline btDbvtAabbMm FromMM(const btVector3& mi,const btVector3& mx); - static inline btDbvtAabbMm FromPoints(const btVector3* pts,int n); - static inline btDbvtAabbMm FromPoints(const btVector3** ppts,int n); - DBVT_INLINE void Expand(const btVector3& e); - DBVT_INLINE void SignedExpand(const btVector3& e); - DBVT_INLINE bool Contain(const btDbvtAabbMm& a) const; - DBVT_INLINE int Classify(const btVector3& n,btScalar o,int s) const; - DBVT_INLINE btScalar ProjectMinimum(const btVector3& v,unsigned signs) const; - DBVT_INLINE friend bool Intersect( const btDbvtAabbMm& a, - const btDbvtAabbMm& b); - - DBVT_INLINE friend bool Intersect( const btDbvtAabbMm& a, - const btVector3& b); - - DBVT_INLINE friend btScalar Proximity( const btDbvtAabbMm& a, - const btDbvtAabbMm& b); - DBVT_INLINE friend int Select( const btDbvtAabbMm& o, - const btDbvtAabbMm& a, - const btDbvtAabbMm& b); - DBVT_INLINE friend void Merge( const btDbvtAabbMm& a, - const btDbvtAabbMm& b, - btDbvtAabbMm& r); - DBVT_INLINE friend bool NotEqual( const btDbvtAabbMm& a, - const btDbvtAabbMm& b); -private: - DBVT_INLINE void AddSpan(const btVector3& d,btScalar& smi,btScalar& smx) const; -private: - btVector3 mi,mx; -}; - -// Types -typedef btDbvtAabbMm btDbvtVolume; - -/* btDbvtNode */ -struct btDbvtNode -{ - btDbvtVolume volume; - btDbvtNode* parent; - DBVT_INLINE bool isleaf() const { return(childs[1]==0); } - DBVT_INLINE bool isinternal() const { return(!isleaf()); } - union - { - btDbvtNode* childs[2]; - void* data; - int dataAsInt; - }; -}; - -///The btDbvt class implements a fast dynamic bounding volume tree based on axis aligned bounding boxes (aabb tree). -///This btDbvt is used for soft body collision detection and for the btDbvtBroadphase. It has a fast insert, remove and update of nodes. -///Unlike the btQuantizedBvh, nodes can be dynamically moved around, which allows for change in topology of the underlying data structure. -struct btDbvt -{ - /* Stack element */ - struct sStkNN - { - const btDbvtNode* a; - const btDbvtNode* b; - sStkNN() {} - sStkNN(const btDbvtNode* na,const btDbvtNode* nb) : a(na),b(nb) {} - }; - struct sStkNP - { - const btDbvtNode* node; - int mask; - sStkNP(const btDbvtNode* n,unsigned m) : node(n),mask(m) {} - }; - struct sStkNPS - { - const btDbvtNode* node; - int mask; - btScalar value; - sStkNPS() {} - sStkNPS(const btDbvtNode* n,unsigned m,btScalar v) : node(n),mask(m),value(v) {} - }; - struct sStkCLN - { - const btDbvtNode* node; - btDbvtNode* parent; - sStkCLN(const btDbvtNode* n,btDbvtNode* p) : node(n),parent(p) {} - }; - // Policies/Interfaces - - /* ICollide */ - struct ICollide - { - DBVT_VIRTUAL_DTOR(ICollide) - DBVT_VIRTUAL void Process(const btDbvtNode*,const btDbvtNode*) {} - DBVT_VIRTUAL void Process(const btDbvtNode*) {} - DBVT_VIRTUAL void Process(const btDbvtNode* n,btScalar) { Process(n); } - DBVT_VIRTUAL bool Descent(const btDbvtNode*) { return(true); } - DBVT_VIRTUAL bool AllLeaves(const btDbvtNode*) { return(true); } - }; - /* IWriter */ - struct IWriter - { - virtual ~IWriter() {} - virtual void Prepare(const btDbvtNode* root,int numnodes)=0; - virtual void WriteNode(const btDbvtNode*,int index,int parent,int child0,int child1)=0; - virtual void WriteLeaf(const btDbvtNode*,int index,int parent)=0; - }; - /* IClone */ - struct IClone - { - virtual ~IClone() {} - virtual void CloneLeaf(btDbvtNode*) {} - }; - - // Constants - enum { - SIMPLE_STACKSIZE = 64, - DOUBLE_STACKSIZE = SIMPLE_STACKSIZE*2 - }; - - // Fields - btDbvtNode* m_root; - btDbvtNode* m_free; - int m_lkhd; - int m_leaves; - unsigned m_opath; - - - btAlignedObjectArray m_stkStack; - - - // Methods - btDbvt(); - ~btDbvt(); - void clear(); - bool empty() const { return(0==m_root); } - void optimizeBottomUp(); - void optimizeTopDown(int bu_treshold=128); - void optimizeIncremental(int passes); - btDbvtNode* insert(const btDbvtVolume& box,void* data); - void update(btDbvtNode* leaf,int lookahead=-1); - void update(btDbvtNode* leaf,btDbvtVolume& volume); - bool update(btDbvtNode* leaf,btDbvtVolume& volume,const btVector3& velocity,btScalar margin); - bool update(btDbvtNode* leaf,btDbvtVolume& volume,const btVector3& velocity); - bool update(btDbvtNode* leaf,btDbvtVolume& volume,btScalar margin); - void remove(btDbvtNode* leaf); - void write(IWriter* iwriter) const; - void clone(btDbvt& dest,IClone* iclone=0) const; - static int maxdepth(const btDbvtNode* node); - static int countLeaves(const btDbvtNode* node); - static void extractLeaves(const btDbvtNode* node,btAlignedObjectArray& leaves); -#if DBVT_ENABLE_BENCHMARK - static void benchmark(); -#else - static void benchmark(){} -#endif - // DBVT_IPOLICY must support ICollide policy/interface - DBVT_PREFIX - static void enumNodes( const btDbvtNode* root, - DBVT_IPOLICY); - DBVT_PREFIX - static void enumLeaves( const btDbvtNode* root, - DBVT_IPOLICY); - DBVT_PREFIX - void collideTT( const btDbvtNode* root0, - const btDbvtNode* root1, - DBVT_IPOLICY); - - DBVT_PREFIX - void collideTTpersistentStack( const btDbvtNode* root0, - const btDbvtNode* root1, - DBVT_IPOLICY); -#if 0 - DBVT_PREFIX - void collideTT( const btDbvtNode* root0, - const btDbvtNode* root1, - const btTransform& xform, - DBVT_IPOLICY); - DBVT_PREFIX - void collideTT( const btDbvtNode* root0, - const btTransform& xform0, - const btDbvtNode* root1, - const btTransform& xform1, - DBVT_IPOLICY); -#endif - - DBVT_PREFIX - void collideTV( const btDbvtNode* root, - const btDbvtVolume& volume, - DBVT_IPOLICY); - ///rayTest is a re-entrant ray test, and can be called in parallel as long as the btAlignedAlloc is thread-safe (uses locking etc) - ///rayTest is slower than rayTestInternal, because it builds a local stack, using memory allocations, and it recomputes signs/rayDirectionInverses each time - DBVT_PREFIX - static void rayTest( const btDbvtNode* root, - const btVector3& rayFrom, - const btVector3& rayTo, - DBVT_IPOLICY); - ///rayTestInternal is faster than rayTest, because it uses a persistent stack (to reduce dynamic memory allocations to a minimum) and it uses precomputed signs/rayInverseDirections - ///rayTestInternal is used by btDbvtBroadphase to accelerate world ray casts - DBVT_PREFIX - void rayTestInternal( const btDbvtNode* root, - const btVector3& rayFrom, - const btVector3& rayTo, - const btVector3& rayDirectionInverse, - unsigned int signs[3], - btScalar lambda_max, - const btVector3& aabbMin, - const btVector3& aabbMax, - DBVT_IPOLICY) const; - - DBVT_PREFIX - static void collideKDOP(const btDbvtNode* root, - const btVector3* normals, - const btScalar* offsets, - int count, - DBVT_IPOLICY); - DBVT_PREFIX - static void collideOCL( const btDbvtNode* root, - const btVector3* normals, - const btScalar* offsets, - const btVector3& sortaxis, - int count, - DBVT_IPOLICY, - bool fullsort=true); - DBVT_PREFIX - static void collideTU( const btDbvtNode* root, - DBVT_IPOLICY); - // Helpers - static DBVT_INLINE int nearest(const int* i,const btDbvt::sStkNPS* a,btScalar v,int l,int h) - { - int m=0; - while(l>1; - if(a[i[m]].value>=v) l=m+1; else h=m; - } - return(h); - } - static DBVT_INLINE int allocate( btAlignedObjectArray& ifree, - btAlignedObjectArray& stock, - const sStkNPS& value) - { - int i; - if(ifree.size()>0) - { i=ifree[ifree.size()-1];ifree.pop_back();stock[i]=value; } - else - { i=stock.size();stock.push_back(value); } - return(i); - } - // -private: - btDbvt(const btDbvt&) {} -}; - -// -// Inline's -// - -// -inline btDbvtAabbMm btDbvtAabbMm::FromCE(const btVector3& c,const btVector3& e) -{ - btDbvtAabbMm box; - box.mi=c-e;box.mx=c+e; - return(box); -} - -// -inline btDbvtAabbMm btDbvtAabbMm::FromCR(const btVector3& c,btScalar r) -{ - return(FromCE(c,btVector3(r,r,r))); -} - -// -inline btDbvtAabbMm btDbvtAabbMm::FromMM(const btVector3& mi,const btVector3& mx) -{ - btDbvtAabbMm box; - box.mi=mi;box.mx=mx; - return(box); -} - -// -inline btDbvtAabbMm btDbvtAabbMm::FromPoints(const btVector3* pts,int n) -{ - btDbvtAabbMm box; - box.mi=box.mx=pts[0]; - for(int i=1;i0) mx.setX(mx.x()+e[0]); else mi.setX(mi.x()+e[0]); - if(e.y()>0) mx.setY(mx.y()+e[1]); else mi.setY(mi.y()+e[1]); - if(e.z()>0) mx.setZ(mx.z()+e[2]); else mi.setZ(mi.z()+e[2]); -} - -// -DBVT_INLINE bool btDbvtAabbMm::Contain(const btDbvtAabbMm& a) const -{ - return( (mi.x()<=a.mi.x())&& - (mi.y()<=a.mi.y())&& - (mi.z()<=a.mi.z())&& - (mx.x()>=a.mx.x())&& - (mx.y()>=a.mx.y())&& - (mx.z()>=a.mx.z())); -} - -// -DBVT_INLINE int btDbvtAabbMm::Classify(const btVector3& n,btScalar o,int s) const -{ - btVector3 pi,px; - switch(s) - { - case (0+0+0): px=btVector3(mi.x(),mi.y(),mi.z()); - pi=btVector3(mx.x(),mx.y(),mx.z());break; - case (1+0+0): px=btVector3(mx.x(),mi.y(),mi.z()); - pi=btVector3(mi.x(),mx.y(),mx.z());break; - case (0+2+0): px=btVector3(mi.x(),mx.y(),mi.z()); - pi=btVector3(mx.x(),mi.y(),mx.z());break; - case (1+2+0): px=btVector3(mx.x(),mx.y(),mi.z()); - pi=btVector3(mi.x(),mi.y(),mx.z());break; - case (0+0+4): px=btVector3(mi.x(),mi.y(),mx.z()); - pi=btVector3(mx.x(),mx.y(),mi.z());break; - case (1+0+4): px=btVector3(mx.x(),mi.y(),mx.z()); - pi=btVector3(mi.x(),mx.y(),mi.z());break; - case (0+2+4): px=btVector3(mi.x(),mx.y(),mx.z()); - pi=btVector3(mx.x(),mi.y(),mi.z());break; - case (1+2+4): px=btVector3(mx.x(),mx.y(),mx.z()); - pi=btVector3(mi.x(),mi.y(),mi.z());break; - } - if((btDot(n,px)+o)<0) return(-1); - if((btDot(n,pi)+o)>=0) return(+1); - return(0); -} - -// -DBVT_INLINE btScalar btDbvtAabbMm::ProjectMinimum(const btVector3& v,unsigned signs) const -{ - const btVector3* b[]={&mx,&mi}; - const btVector3 p( b[(signs>>0)&1]->x(), - b[(signs>>1)&1]->y(), - b[(signs>>2)&1]->z()); - return(btDot(p,v)); -} - -// -DBVT_INLINE void btDbvtAabbMm::AddSpan(const btVector3& d,btScalar& smi,btScalar& smx) const -{ - for(int i=0;i<3;++i) - { - if(d[i]<0) - { smi+=mx[i]*d[i];smx+=mi[i]*d[i]; } - else - { smi+=mi[i]*d[i];smx+=mx[i]*d[i]; } - } -} - -// -DBVT_INLINE bool Intersect( const btDbvtAabbMm& a, - const btDbvtAabbMm& b) -{ -#if DBVT_INT0_IMPL == DBVT_IMPL_SSE - const __m128 rt(_mm_or_ps( _mm_cmplt_ps(_mm_load_ps(b.mx),_mm_load_ps(a.mi)), - _mm_cmplt_ps(_mm_load_ps(a.mx),_mm_load_ps(b.mi)))); - const __int32* pu((const __int32*)&rt); - return((pu[0]|pu[1]|pu[2])==0); -#else - return( (a.mi.x()<=b.mx.x())&& - (a.mx.x()>=b.mi.x())&& - (a.mi.y()<=b.mx.y())&& - (a.mx.y()>=b.mi.y())&& - (a.mi.z()<=b.mx.z())&& - (a.mx.z()>=b.mi.z())); -#endif -} - - - -// -DBVT_INLINE bool Intersect( const btDbvtAabbMm& a, - const btVector3& b) -{ - return( (b.x()>=a.mi.x())&& - (b.y()>=a.mi.y())&& - (b.z()>=a.mi.z())&& - (b.x()<=a.mx.x())&& - (b.y()<=a.mx.y())&& - (b.z()<=a.mx.z())); -} - - - - - -////////////////////////////////////// - - -// -DBVT_INLINE btScalar Proximity( const btDbvtAabbMm& a, - const btDbvtAabbMm& b) -{ - const btVector3 d=(a.mi+a.mx)-(b.mi+b.mx); - return(btFabs(d.x())+btFabs(d.y())+btFabs(d.z())); -} - - - -// -DBVT_INLINE int Select( const btDbvtAabbMm& o, - const btDbvtAabbMm& a, - const btDbvtAabbMm& b) -{ -#if DBVT_SELECT_IMPL == DBVT_IMPL_SSE - static ATTRIBUTE_ALIGNED16(const unsigned __int32) mask[]={0x7fffffff,0x7fffffff,0x7fffffff,0x7fffffff}; - ///@todo: the intrinsic version is 11% slower -#if DBVT_USE_INTRINSIC_SSE - - union btSSEUnion ///NOTE: if we use more intrinsics, move btSSEUnion into the LinearMath directory - { - __m128 ssereg; - float floats[4]; - int ints[4]; - }; - - __m128 omi(_mm_load_ps(o.mi)); - omi=_mm_add_ps(omi,_mm_load_ps(o.mx)); - __m128 ami(_mm_load_ps(a.mi)); - ami=_mm_add_ps(ami,_mm_load_ps(a.mx)); - ami=_mm_sub_ps(ami,omi); - ami=_mm_and_ps(ami,_mm_load_ps((const float*)mask)); - __m128 bmi(_mm_load_ps(b.mi)); - bmi=_mm_add_ps(bmi,_mm_load_ps(b.mx)); - bmi=_mm_sub_ps(bmi,omi); - bmi=_mm_and_ps(bmi,_mm_load_ps((const float*)mask)); - __m128 t0(_mm_movehl_ps(ami,ami)); - ami=_mm_add_ps(ami,t0); - ami=_mm_add_ss(ami,_mm_shuffle_ps(ami,ami,1)); - __m128 t1(_mm_movehl_ps(bmi,bmi)); - bmi=_mm_add_ps(bmi,t1); - bmi=_mm_add_ss(bmi,_mm_shuffle_ps(bmi,bmi,1)); - - btSSEUnion tmp; - tmp.ssereg = _mm_cmple_ss(bmi,ami); - return tmp.ints[0]&1; - -#else - ATTRIBUTE_ALIGNED16(__int32 r[1]); - __asm - { - mov eax,o - mov ecx,a - mov edx,b - movaps xmm0,[eax] - movaps xmm5,mask - addps xmm0,[eax+16] - movaps xmm1,[ecx] - movaps xmm2,[edx] - addps xmm1,[ecx+16] - addps xmm2,[edx+16] - subps xmm1,xmm0 - subps xmm2,xmm0 - andps xmm1,xmm5 - andps xmm2,xmm5 - movhlps xmm3,xmm1 - movhlps xmm4,xmm2 - addps xmm1,xmm3 - addps xmm2,xmm4 - pshufd xmm3,xmm1,1 - pshufd xmm4,xmm2,1 - addss xmm1,xmm3 - addss xmm2,xmm4 - cmpless xmm2,xmm1 - movss r,xmm2 - } - return(r[0]&1); -#endif -#else - return(Proximity(o,a)b.mx[i]) r.mx[i]=a.mx[i]; else r.mx[i]=b.mx[i]; - } -#endif -} - -// -DBVT_INLINE bool NotEqual( const btDbvtAabbMm& a, - const btDbvtAabbMm& b) -{ - return( (a.mi.x()!=b.mi.x())|| - (a.mi.y()!=b.mi.y())|| - (a.mi.z()!=b.mi.z())|| - (a.mx.x()!=b.mx.x())|| - (a.mx.y()!=b.mx.y())|| - (a.mx.z()!=b.mx.z())); -} - -// -// Inline's -// - -// -DBVT_PREFIX -inline void btDbvt::enumNodes( const btDbvtNode* root, - DBVT_IPOLICY) -{ - DBVT_CHECKTYPE - policy.Process(root); - if(root->isinternal()) - { - enumNodes(root->childs[0],policy); - enumNodes(root->childs[1],policy); - } -} - -// -DBVT_PREFIX -inline void btDbvt::enumLeaves( const btDbvtNode* root, - DBVT_IPOLICY) -{ - DBVT_CHECKTYPE - if(root->isinternal()) - { - enumLeaves(root->childs[0],policy); - enumLeaves(root->childs[1],policy); - } - else - { - policy.Process(root); - } -} - -// -DBVT_PREFIX -inline void btDbvt::collideTT( const btDbvtNode* root0, - const btDbvtNode* root1, - DBVT_IPOLICY) -{ - DBVT_CHECKTYPE - if(root0&&root1) - { - int depth=1; - int treshold=DOUBLE_STACKSIZE-4; - btAlignedObjectArray stkStack; - stkStack.resize(DOUBLE_STACKSIZE); - stkStack[0]=sStkNN(root0,root1); - do { - sStkNN p=stkStack[--depth]; - if(depth>treshold) - { - stkStack.resize(stkStack.size()*2); - treshold=stkStack.size()-4; - } - if(p.a==p.b) - { - if(p.a->isinternal()) - { - stkStack[depth++]=sStkNN(p.a->childs[0],p.a->childs[0]); - stkStack[depth++]=sStkNN(p.a->childs[1],p.a->childs[1]); - stkStack[depth++]=sStkNN(p.a->childs[0],p.a->childs[1]); - } - } - else if(Intersect(p.a->volume,p.b->volume)) - { - if(p.a->isinternal()) - { - if(p.b->isinternal()) - { - stkStack[depth++]=sStkNN(p.a->childs[0],p.b->childs[0]); - stkStack[depth++]=sStkNN(p.a->childs[1],p.b->childs[0]); - stkStack[depth++]=sStkNN(p.a->childs[0],p.b->childs[1]); - stkStack[depth++]=sStkNN(p.a->childs[1],p.b->childs[1]); - } - else - { - stkStack[depth++]=sStkNN(p.a->childs[0],p.b); - stkStack[depth++]=sStkNN(p.a->childs[1],p.b); - } - } - else - { - if(p.b->isinternal()) - { - stkStack[depth++]=sStkNN(p.a,p.b->childs[0]); - stkStack[depth++]=sStkNN(p.a,p.b->childs[1]); - } - else - { - policy.Process(p.a,p.b); - } - } - } - } while(depth); - } -} - - - -DBVT_PREFIX -inline void btDbvt::collideTTpersistentStack( const btDbvtNode* root0, - const btDbvtNode* root1, - DBVT_IPOLICY) -{ - DBVT_CHECKTYPE - if(root0&&root1) - { - int depth=1; - int treshold=DOUBLE_STACKSIZE-4; - - m_stkStack.resize(DOUBLE_STACKSIZE); - m_stkStack[0]=sStkNN(root0,root1); - do { - sStkNN p=m_stkStack[--depth]; - if(depth>treshold) - { - m_stkStack.resize(m_stkStack.size()*2); - treshold=m_stkStack.size()-4; - } - if(p.a==p.b) - { - if(p.a->isinternal()) - { - m_stkStack[depth++]=sStkNN(p.a->childs[0],p.a->childs[0]); - m_stkStack[depth++]=sStkNN(p.a->childs[1],p.a->childs[1]); - m_stkStack[depth++]=sStkNN(p.a->childs[0],p.a->childs[1]); - } - } - else if(Intersect(p.a->volume,p.b->volume)) - { - if(p.a->isinternal()) - { - if(p.b->isinternal()) - { - m_stkStack[depth++]=sStkNN(p.a->childs[0],p.b->childs[0]); - m_stkStack[depth++]=sStkNN(p.a->childs[1],p.b->childs[0]); - m_stkStack[depth++]=sStkNN(p.a->childs[0],p.b->childs[1]); - m_stkStack[depth++]=sStkNN(p.a->childs[1],p.b->childs[1]); - } - else - { - m_stkStack[depth++]=sStkNN(p.a->childs[0],p.b); - m_stkStack[depth++]=sStkNN(p.a->childs[1],p.b); - } - } - else - { - if(p.b->isinternal()) - { - m_stkStack[depth++]=sStkNN(p.a,p.b->childs[0]); - m_stkStack[depth++]=sStkNN(p.a,p.b->childs[1]); - } - else - { - policy.Process(p.a,p.b); - } - } - } - } while(depth); - } -} - -#if 0 -// -DBVT_PREFIX -inline void btDbvt::collideTT( const btDbvtNode* root0, - const btDbvtNode* root1, - const btTransform& xform, - DBVT_IPOLICY) -{ - DBVT_CHECKTYPE - if(root0&&root1) - { - int depth=1; - int treshold=DOUBLE_STACKSIZE-4; - btAlignedObjectArray stkStack; - stkStack.resize(DOUBLE_STACKSIZE); - stkStack[0]=sStkNN(root0,root1); - do { - sStkNN p=stkStack[--depth]; - if(Intersect(p.a->volume,p.b->volume,xform)) - { - if(depth>treshold) - { - stkStack.resize(stkStack.size()*2); - treshold=stkStack.size()-4; - } - if(p.a->isinternal()) - { - if(p.b->isinternal()) - { - stkStack[depth++]=sStkNN(p.a->childs[0],p.b->childs[0]); - stkStack[depth++]=sStkNN(p.a->childs[1],p.b->childs[0]); - stkStack[depth++]=sStkNN(p.a->childs[0],p.b->childs[1]); - stkStack[depth++]=sStkNN(p.a->childs[1],p.b->childs[1]); - } - else - { - stkStack[depth++]=sStkNN(p.a->childs[0],p.b); - stkStack[depth++]=sStkNN(p.a->childs[1],p.b); - } - } - else - { - if(p.b->isinternal()) - { - stkStack[depth++]=sStkNN(p.a,p.b->childs[0]); - stkStack[depth++]=sStkNN(p.a,p.b->childs[1]); - } - else - { - policy.Process(p.a,p.b); - } - } - } - } while(depth); - } -} -// -DBVT_PREFIX -inline void btDbvt::collideTT( const btDbvtNode* root0, - const btTransform& xform0, - const btDbvtNode* root1, - const btTransform& xform1, - DBVT_IPOLICY) -{ - const btTransform xform=xform0.inverse()*xform1; - collideTT(root0,root1,xform,policy); -} -#endif - -// -DBVT_PREFIX -inline void btDbvt::collideTV( const btDbvtNode* root, - const btDbvtVolume& vol, - DBVT_IPOLICY) -{ - DBVT_CHECKTYPE - if(root) - { - ATTRIBUTE_ALIGNED16(btDbvtVolume) volume(vol); - btAlignedObjectArray stack; - stack.resize(0); - stack.reserve(SIMPLE_STACKSIZE); - stack.push_back(root); - do { - const btDbvtNode* n=stack[stack.size()-1]; - stack.pop_back(); - if(Intersect(n->volume,volume)) - { - if(n->isinternal()) - { - stack.push_back(n->childs[0]); - stack.push_back(n->childs[1]); - } - else - { - policy.Process(n); - } - } - } while(stack.size()>0); - } -} - -DBVT_PREFIX -inline void btDbvt::rayTestInternal( const btDbvtNode* root, - const btVector3& rayFrom, - const btVector3& rayTo, - const btVector3& rayDirectionInverse, - unsigned int signs[3], - btScalar lambda_max, - const btVector3& aabbMin, - const btVector3& aabbMax, - DBVT_IPOLICY) const -{ - DBVT_CHECKTYPE - if(root) - { - btVector3 resultNormal; - - int depth=1; - int treshold=DOUBLE_STACKSIZE-2; - btAlignedObjectArray stack; - stack.resize(DOUBLE_STACKSIZE); - stack[0]=root; - btVector3 bounds[2]; - do - { - const btDbvtNode* node=stack[--depth]; - bounds[0] = node->volume.Mins()+aabbMin; - bounds[1] = node->volume.Maxs()+aabbMax; - btScalar tmin=1.f,lambda_min=0.f; - unsigned int result1=false; - result1 = btRayAabb2(rayFrom,rayDirectionInverse,signs,bounds,tmin,lambda_min,lambda_max); - if(result1) - { - if(node->isinternal()) - { - if(depth>treshold) - { - stack.resize(stack.size()*2); - treshold=stack.size()-2; - } - stack[depth++]=node->childs[0]; - stack[depth++]=node->childs[1]; - } - else - { - policy.Process(node); - } - } - } while(depth); - } -} - -// -DBVT_PREFIX -inline void btDbvt::rayTest( const btDbvtNode* root, - const btVector3& rayFrom, - const btVector3& rayTo, - DBVT_IPOLICY) -{ - DBVT_CHECKTYPE - if(root) - { - btVector3 rayDir = (rayTo-rayFrom); - rayDir.normalize (); - - ///what about division by zero? --> just set rayDirection[i] to INF/BT_LARGE_FLOAT - btVector3 rayDirectionInverse; - rayDirectionInverse[0] = rayDir[0] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDir[0]; - rayDirectionInverse[1] = rayDir[1] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDir[1]; - rayDirectionInverse[2] = rayDir[2] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDir[2]; - unsigned int signs[3] = { rayDirectionInverse[0] < 0.0, rayDirectionInverse[1] < 0.0, rayDirectionInverse[2] < 0.0}; - - btScalar lambda_max = rayDir.dot(rayTo-rayFrom); - - btVector3 resultNormal; - - btAlignedObjectArray stack; - - int depth=1; - int treshold=DOUBLE_STACKSIZE-2; - - stack.resize(DOUBLE_STACKSIZE); - stack[0]=root; - btVector3 bounds[2]; - do { - const btDbvtNode* node=stack[--depth]; - - bounds[0] = node->volume.Mins(); - bounds[1] = node->volume.Maxs(); - - btScalar tmin=1.f,lambda_min=0.f; - unsigned int result1 = btRayAabb2(rayFrom,rayDirectionInverse,signs,bounds,tmin,lambda_min,lambda_max); - -#ifdef COMPARE_BTRAY_AABB2 - btScalar param=1.f; - bool result2 = btRayAabb(rayFrom,rayTo,node->volume.Mins(),node->volume.Maxs(),param,resultNormal); - btAssert(result1 == result2); -#endif //TEST_BTRAY_AABB2 - - if(result1) - { - if(node->isinternal()) - { - if(depth>treshold) - { - stack.resize(stack.size()*2); - treshold=stack.size()-2; - } - stack[depth++]=node->childs[0]; - stack[depth++]=node->childs[1]; - } - else - { - policy.Process(node); - } - } - } while(depth); - - } -} - -// -DBVT_PREFIX -inline void btDbvt::collideKDOP(const btDbvtNode* root, - const btVector3* normals, - const btScalar* offsets, - int count, - DBVT_IPOLICY) -{ - DBVT_CHECKTYPE - if(root) - { - const int inside=(1< stack; - int signs[sizeof(unsigned)*8]; - btAssert(count=0)?1:0)+ - ((normals[i].y()>=0)?2:0)+ - ((normals[i].z()>=0)?4:0); - } - stack.reserve(SIMPLE_STACKSIZE); - stack.push_back(sStkNP(root,0)); - do { - sStkNP se=stack[stack.size()-1]; - bool out=false; - stack.pop_back(); - for(int i=0,j=1;(!out)&&(ivolume.Classify(normals[i],offsets[i],signs[i]); - switch(side) - { - case -1: out=true;break; - case +1: se.mask|=j;break; - } - } - } - if(!out) - { - if((se.mask!=inside)&&(se.node->isinternal())) - { - stack.push_back(sStkNP(se.node->childs[0],se.mask)); - stack.push_back(sStkNP(se.node->childs[1],se.mask)); - } - else - { - if(policy.AllLeaves(se.node)) enumLeaves(se.node,policy); - } - } - } while(stack.size()); - } -} - -// -DBVT_PREFIX -inline void btDbvt::collideOCL( const btDbvtNode* root, - const btVector3* normals, - const btScalar* offsets, - const btVector3& sortaxis, - int count, - DBVT_IPOLICY, - bool fsort) -{ - DBVT_CHECKTYPE - if(root) - { - const unsigned srtsgns=(sortaxis[0]>=0?1:0)+ - (sortaxis[1]>=0?2:0)+ - (sortaxis[2]>=0?4:0); - const int inside=(1< stock; - btAlignedObjectArray ifree; - btAlignedObjectArray stack; - int signs[sizeof(unsigned)*8]; - btAssert(count=0)?1:0)+ - ((normals[i].y()>=0)?2:0)+ - ((normals[i].z()>=0)?4:0); - } - stock.reserve(SIMPLE_STACKSIZE); - stack.reserve(SIMPLE_STACKSIZE); - ifree.reserve(SIMPLE_STACKSIZE); - stack.push_back(allocate(ifree,stock,sStkNPS(root,0,root->volume.ProjectMinimum(sortaxis,srtsgns)))); - do { - const int id=stack[stack.size()-1]; - sStkNPS se=stock[id]; - stack.pop_back();ifree.push_back(id); - if(se.mask!=inside) - { - bool out=false; - for(int i=0,j=1;(!out)&&(ivolume.Classify(normals[i],offsets[i],signs[i]); - switch(side) - { - case -1: out=true;break; - case +1: se.mask|=j;break; - } - } - } - if(out) continue; - } - if(policy.Descent(se.node)) - { - if(se.node->isinternal()) - { - const btDbvtNode* pns[]={ se.node->childs[0],se.node->childs[1]}; - sStkNPS nes[]={ sStkNPS(pns[0],se.mask,pns[0]->volume.ProjectMinimum(sortaxis,srtsgns)), - sStkNPS(pns[1],se.mask,pns[1]->volume.ProjectMinimum(sortaxis,srtsgns))}; - const int q=nes[0].value0)) - { - /* Insert 0 */ - j=nearest(&stack[0],&stock[0],nes[q].value,0,stack.size()); - stack.push_back(0); -#if DBVT_USE_MEMMOVE - memmove(&stack[j+1],&stack[j],sizeof(int)*(stack.size()-j-1)); -#else - for(int k=stack.size()-1;k>j;--k) stack[k]=stack[k-1]; -#endif - stack[j]=allocate(ifree,stock,nes[q]); - /* Insert 1 */ - j=nearest(&stack[0],&stock[0],nes[1-q].value,j,stack.size()); - stack.push_back(0); -#if DBVT_USE_MEMMOVE - memmove(&stack[j+1],&stack[j],sizeof(int)*(stack.size()-j-1)); -#else - for(int k=stack.size()-1;k>j;--k) stack[k]=stack[k-1]; -#endif - stack[j]=allocate(ifree,stock,nes[1-q]); - } - else - { - stack.push_back(allocate(ifree,stock,nes[q])); - stack.push_back(allocate(ifree,stock,nes[1-q])); - } - } - else - { - policy.Process(se.node,se.value); - } - } - } while(stack.size()); - } -} - -// -DBVT_PREFIX -inline void btDbvt::collideTU( const btDbvtNode* root, - DBVT_IPOLICY) -{ - DBVT_CHECKTYPE - if(root) - { - btAlignedObjectArray stack; - stack.reserve(SIMPLE_STACKSIZE); - stack.push_back(root); - do { - const btDbvtNode* n=stack[stack.size()-1]; - stack.pop_back(); - if(policy.Descent(n)) - { - if(n->isinternal()) - { stack.push_back(n->childs[0]);stack.push_back(n->childs[1]); } - else - { policy.Process(n); } - } - } while(stack.size()>0); - } -} - -// -// PP Cleanup -// - -#undef DBVT_USE_MEMMOVE -#undef DBVT_USE_TEMPLATE -#undef DBVT_VIRTUAL_DTOR -#undef DBVT_VIRTUAL -#undef DBVT_PREFIX -#undef DBVT_IPOLICY -#undef DBVT_CHECKTYPE -#undef DBVT_IMPL_GENERIC -#undef DBVT_IMPL_SSE -#undef DBVT_USE_INTRINSIC_SSE -#undef DBVT_SELECT_IMPL -#undef DBVT_MERGE_IMPL -#undef DBVT_INT0_IMPL - -#endif diff --git a/bullet/src/BulletCollision/BroadphaseCollision/btDbvtBroadphase.cpp b/bullet/src/BulletCollision/BroadphaseCollision/btDbvtBroadphase.cpp deleted file mode 100644 index 220b61f1d..000000000 --- a/bullet/src/BulletCollision/BroadphaseCollision/btDbvtBroadphase.cpp +++ /dev/null @@ -1,728 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -///btDbvtBroadphase implementation by Nathanael Presson - -#include "btDbvtBroadphase.h" - -// -// Profiling -// - -#if DBVT_BP_PROFILE||DBVT_BP_ENABLE_BENCHMARK -#include -#endif - -#if DBVT_BP_PROFILE -struct ProfileScope -{ - __forceinline ProfileScope(btClock& clock,unsigned long& value) : - m_clock(&clock),m_value(&value),m_base(clock.getTimeMicroseconds()) - { - } - __forceinline ~ProfileScope() - { - (*m_value)+=m_clock->getTimeMicroseconds()-m_base; - } - btClock* m_clock; - unsigned long* m_value; - unsigned long m_base; -}; -#define SPC(_value_) ProfileScope spc_scope(m_clock,_value_) -#else -#define SPC(_value_) -#endif - -// -// Helpers -// - -// -template -static inline void listappend(T* item,T*& list) -{ - item->links[0]=0; - item->links[1]=list; - if(list) list->links[0]=item; - list=item; -} - -// -template -static inline void listremove(T* item,T*& list) -{ - if(item->links[0]) item->links[0]->links[1]=item->links[1]; else list=item->links[1]; - if(item->links[1]) item->links[1]->links[0]=item->links[0]; -} - -// -template -static inline int listcount(T* root) -{ - int n=0; - while(root) { ++n;root=root->links[1]; } - return(n); -} - -// -template -static inline void clear(T& value) -{ - static const struct ZeroDummy : T {} zerodummy; - value=zerodummy; -} - -// -// Colliders -// - -/* Tree collider */ -struct btDbvtTreeCollider : btDbvt::ICollide -{ - btDbvtBroadphase* pbp; - btDbvtProxy* proxy; - btDbvtTreeCollider(btDbvtBroadphase* p) : pbp(p) {} - void Process(const btDbvtNode* na,const btDbvtNode* nb) - { - if(na!=nb) - { - btDbvtProxy* pa=(btDbvtProxy*)na->data; - btDbvtProxy* pb=(btDbvtProxy*)nb->data; -#if DBVT_BP_SORTPAIRS - if(pa->m_uniqueId>pb->m_uniqueId) - btSwap(pa,pb); -#endif - pbp->m_paircache->addOverlappingPair(pa,pb); - ++pbp->m_newpairs; - } - } - void Process(const btDbvtNode* n) - { - Process(n,proxy->leaf); - } -}; - -// -// btDbvtBroadphase -// - -// -btDbvtBroadphase::btDbvtBroadphase(btOverlappingPairCache* paircache) -{ - m_deferedcollide = false; - m_needcleanup = true; - m_releasepaircache = (paircache!=0)?false:true; - m_prediction = 0; - m_stageCurrent = 0; - m_fixedleft = 0; - m_fupdates = 1; - m_dupdates = 0; - m_cupdates = 10; - m_newpairs = 1; - m_updates_call = 0; - m_updates_done = 0; - m_updates_ratio = 0; - m_paircache = paircache? paircache : new(btAlignedAlloc(sizeof(btHashedOverlappingPairCache),16)) btHashedOverlappingPairCache(); - m_gid = 0; - m_pid = 0; - m_cid = 0; - for(int i=0;i<=STAGECOUNT;++i) - { - m_stageRoots[i]=0; - } -#if DBVT_BP_PROFILE - clear(m_profiling); -#endif -} - -// -btDbvtBroadphase::~btDbvtBroadphase() -{ - if(m_releasepaircache) - { - m_paircache->~btOverlappingPairCache(); - btAlignedFree(m_paircache); - } -} - -// -btBroadphaseProxy* btDbvtBroadphase::createProxy( const btVector3& aabbMin, - const btVector3& aabbMax, - int /*shapeType*/, - void* userPtr, - short int collisionFilterGroup, - short int collisionFilterMask, - btDispatcher* /*dispatcher*/, - void* /*multiSapProxy*/) -{ - btDbvtProxy* proxy=new(btAlignedAlloc(sizeof(btDbvtProxy),16)) btDbvtProxy( aabbMin,aabbMax,userPtr, - collisionFilterGroup, - collisionFilterMask); - - btDbvtAabbMm aabb = btDbvtVolume::FromMM(aabbMin,aabbMax); - - //bproxy->aabb = btDbvtVolume::FromMM(aabbMin,aabbMax); - proxy->stage = m_stageCurrent; - proxy->m_uniqueId = ++m_gid; - proxy->leaf = m_sets[0].insert(aabb,proxy); - listappend(proxy,m_stageRoots[m_stageCurrent]); - if(!m_deferedcollide) - { - btDbvtTreeCollider collider(this); - collider.proxy=proxy; - m_sets[0].collideTV(m_sets[0].m_root,aabb,collider); - m_sets[1].collideTV(m_sets[1].m_root,aabb,collider); - } - return(proxy); -} - -// -void btDbvtBroadphase::destroyProxy( btBroadphaseProxy* absproxy, - btDispatcher* dispatcher) -{ - btDbvtProxy* proxy=(btDbvtProxy*)absproxy; - if(proxy->stage==STAGECOUNT) - m_sets[1].remove(proxy->leaf); - else - m_sets[0].remove(proxy->leaf); - listremove(proxy,m_stageRoots[proxy->stage]); - m_paircache->removeOverlappingPairsContainingProxy(proxy,dispatcher); - btAlignedFree(proxy); - m_needcleanup=true; -} - -void btDbvtBroadphase::getAabb(btBroadphaseProxy* absproxy,btVector3& aabbMin, btVector3& aabbMax ) const -{ - btDbvtProxy* proxy=(btDbvtProxy*)absproxy; - aabbMin = proxy->m_aabbMin; - aabbMax = proxy->m_aabbMax; -} - -struct BroadphaseRayTester : btDbvt::ICollide -{ - btBroadphaseRayCallback& m_rayCallback; - BroadphaseRayTester(btBroadphaseRayCallback& orgCallback) - :m_rayCallback(orgCallback) - { - } - void Process(const btDbvtNode* leaf) - { - btDbvtProxy* proxy=(btDbvtProxy*)leaf->data; - m_rayCallback.process(proxy); - } -}; - -void btDbvtBroadphase::rayTest(const btVector3& rayFrom,const btVector3& rayTo, btBroadphaseRayCallback& rayCallback,const btVector3& aabbMin,const btVector3& aabbMax) -{ - BroadphaseRayTester callback(rayCallback); - - m_sets[0].rayTestInternal( m_sets[0].m_root, - rayFrom, - rayTo, - rayCallback.m_rayDirectionInverse, - rayCallback.m_signs, - rayCallback.m_lambda_max, - aabbMin, - aabbMax, - callback); - - m_sets[1].rayTestInternal( m_sets[1].m_root, - rayFrom, - rayTo, - rayCallback.m_rayDirectionInverse, - rayCallback.m_signs, - rayCallback.m_lambda_max, - aabbMin, - aabbMax, - callback); - -} - - -// -void btDbvtBroadphase::setAabb( btBroadphaseProxy* absproxy, - const btVector3& aabbMin, - const btVector3& aabbMax, - btDispatcher* /*dispatcher*/) -{ - btDbvtProxy* proxy=(btDbvtProxy*)absproxy; - ATTRIBUTE_ALIGNED16(btDbvtVolume) aabb=btDbvtVolume::FromMM(aabbMin,aabbMax); -#if DBVT_BP_PREVENTFALSEUPDATE - if(NotEqual(aabb,proxy->leaf->volume)) -#endif - { - bool docollide=false; - if(proxy->stage==STAGECOUNT) - {/* fixed -> dynamic set */ - m_sets[1].remove(proxy->leaf); - proxy->leaf=m_sets[0].insert(aabb,proxy); - docollide=true; - } - else - {/* dynamic set */ - ++m_updates_call; - if(Intersect(proxy->leaf->volume,aabb)) - {/* Moving */ - - const btVector3 delta=aabbMin-proxy->m_aabbMin; - btVector3 velocity(((proxy->m_aabbMax-proxy->m_aabbMin)/2)*m_prediction); - if(delta[0]<0) velocity[0]=-velocity[0]; - if(delta[1]<0) velocity[1]=-velocity[1]; - if(delta[2]<0) velocity[2]=-velocity[2]; - if ( -#ifdef DBVT_BP_MARGIN - m_sets[0].update(proxy->leaf,aabb,velocity,DBVT_BP_MARGIN) -#else - m_sets[0].update(proxy->leaf,aabb,velocity) -#endif - ) - { - ++m_updates_done; - docollide=true; - } - } - else - {/* Teleporting */ - m_sets[0].update(proxy->leaf,aabb); - ++m_updates_done; - docollide=true; - } - } - listremove(proxy,m_stageRoots[proxy->stage]); - proxy->m_aabbMin = aabbMin; - proxy->m_aabbMax = aabbMax; - proxy->stage = m_stageCurrent; - listappend(proxy,m_stageRoots[m_stageCurrent]); - if(docollide) - { - m_needcleanup=true; - if(!m_deferedcollide) - { - btDbvtTreeCollider collider(this); - m_sets[1].collideTTpersistentStack(m_sets[1].m_root,proxy->leaf,collider); - m_sets[0].collideTTpersistentStack(m_sets[0].m_root,proxy->leaf,collider); - } - } - } -} - -// -void btDbvtBroadphase::calculateOverlappingPairs(btDispatcher* dispatcher) -{ - collide(dispatcher); -#if DBVT_BP_PROFILE - if(0==(m_pid%DBVT_BP_PROFILING_RATE)) - { - printf("fixed(%u) dynamics(%u) pairs(%u)\r\n",m_sets[1].m_leaves,m_sets[0].m_leaves,m_paircache->getNumOverlappingPairs()); - unsigned int total=m_profiling.m_total; - if(total<=0) total=1; - printf("ddcollide: %u%% (%uus)\r\n",(50+m_profiling.m_ddcollide*100)/total,m_profiling.m_ddcollide/DBVT_BP_PROFILING_RATE); - printf("fdcollide: %u%% (%uus)\r\n",(50+m_profiling.m_fdcollide*100)/total,m_profiling.m_fdcollide/DBVT_BP_PROFILING_RATE); - printf("cleanup: %u%% (%uus)\r\n",(50+m_profiling.m_cleanup*100)/total,m_profiling.m_cleanup/DBVT_BP_PROFILING_RATE); - printf("total: %uus\r\n",total/DBVT_BP_PROFILING_RATE); - const unsigned long sum=m_profiling.m_ddcollide+ - m_profiling.m_fdcollide+ - m_profiling.m_cleanup; - printf("leaked: %u%% (%uus)\r\n",100-((50+sum*100)/total),(total-sum)/DBVT_BP_PROFILING_RATE); - printf("job counts: %u%%\r\n",(m_profiling.m_jobcount*100)/((m_sets[0].m_leaves+m_sets[1].m_leaves)*DBVT_BP_PROFILING_RATE)); - clear(m_profiling); - m_clock.reset(); - } -#endif - - performDeferredRemoval(dispatcher); - -} - -void btDbvtBroadphase::performDeferredRemoval(btDispatcher* dispatcher) -{ - - if (m_paircache->hasDeferredRemoval()) - { - - btBroadphasePairArray& overlappingPairArray = m_paircache->getOverlappingPairArray(); - - //perform a sort, to find duplicates and to sort 'invalid' pairs to the end - overlappingPairArray.quickSort(btBroadphasePairSortPredicate()); - - int invalidPair = 0; - - - int i; - - btBroadphasePair previousPair; - previousPair.m_pProxy0 = 0; - previousPair.m_pProxy1 = 0; - previousPair.m_algorithm = 0; - - - for (i=0;ileaf->volume,pb->leaf->volume); - - if (hasOverlap) - { - needsRemoval = false; - } else - { - needsRemoval = true; - } - } else - { - //remove duplicate - needsRemoval = true; - //should have no algorithm - btAssert(!pair.m_algorithm); - } - - if (needsRemoval) - { - m_paircache->cleanOverlappingPair(pair,dispatcher); - - pair.m_pProxy0 = 0; - pair.m_pProxy1 = 0; - invalidPair++; - } - - } - - //perform a sort, to sort 'invalid' pairs to the end - overlappingPairArray.quickSort(btBroadphasePairSortPredicate()); - overlappingPairArray.resize(overlappingPairArray.size() - invalidPair); - } -} - -// -void btDbvtBroadphase::collide(btDispatcher* dispatcher) -{ - /*printf("---------------------------------------------------------\n"); - printf("m_sets[0].m_leaves=%d\n",m_sets[0].m_leaves); - printf("m_sets[1].m_leaves=%d\n",m_sets[1].m_leaves); - printf("numPairs = %d\n",getOverlappingPairCache()->getNumOverlappingPairs()); - { - int i; - for (i=0;igetNumOverlappingPairs();i++) - { - printf("pair[%d]=(%d,%d),",i,getOverlappingPairCache()->getOverlappingPairArray()[i].m_pProxy0->getUid(), - getOverlappingPairCache()->getOverlappingPairArray()[i].m_pProxy1->getUid()); - } - printf("\n"); - } -*/ - - - - SPC(m_profiling.m_total); - /* optimize */ - m_sets[0].optimizeIncremental(1+(m_sets[0].m_leaves*m_dupdates)/100); - if(m_fixedleft) - { - const int count=1+(m_sets[1].m_leaves*m_fupdates)/100; - m_sets[1].optimizeIncremental(1+(m_sets[1].m_leaves*m_fupdates)/100); - m_fixedleft=btMax(0,m_fixedleft-count); - } - /* dynamic -> fixed set */ - m_stageCurrent=(m_stageCurrent+1)%STAGECOUNT; - btDbvtProxy* current=m_stageRoots[m_stageCurrent]; - if(current) - { - btDbvtTreeCollider collider(this); - do { - btDbvtProxy* next=current->links[1]; - listremove(current,m_stageRoots[current->stage]); - listappend(current,m_stageRoots[STAGECOUNT]); -#if DBVT_BP_ACCURATESLEEPING - m_paircache->removeOverlappingPairsContainingProxy(current,dispatcher); - collider.proxy=current; - btDbvt::collideTV(m_sets[0].m_root,current->aabb,collider); - btDbvt::collideTV(m_sets[1].m_root,current->aabb,collider); -#endif - m_sets[0].remove(current->leaf); - ATTRIBUTE_ALIGNED16(btDbvtVolume) curAabb=btDbvtVolume::FromMM(current->m_aabbMin,current->m_aabbMax); - current->leaf = m_sets[1].insert(curAabb,current); - current->stage = STAGECOUNT; - current = next; - } while(current); - m_fixedleft=m_sets[1].m_leaves; - m_needcleanup=true; - } - /* collide dynamics */ - { - btDbvtTreeCollider collider(this); - if(m_deferedcollide) - { - SPC(m_profiling.m_fdcollide); - m_sets[0].collideTTpersistentStack(m_sets[0].m_root,m_sets[1].m_root,collider); - } - if(m_deferedcollide) - { - SPC(m_profiling.m_ddcollide); - m_sets[0].collideTTpersistentStack(m_sets[0].m_root,m_sets[0].m_root,collider); - } - } - /* clean up */ - if(m_needcleanup) - { - SPC(m_profiling.m_cleanup); - btBroadphasePairArray& pairs=m_paircache->getOverlappingPairArray(); - if(pairs.size()>0) - { - - int ni=btMin(pairs.size(),btMax(m_newpairs,(pairs.size()*m_cupdates)/100)); - for(int i=0;ileaf->volume,pb->leaf->volume)) - { -#if DBVT_BP_SORTPAIRS - if(pa->m_uniqueId>pb->m_uniqueId) - btSwap(pa,pb); -#endif - m_paircache->removeOverlappingPair(pa,pb,dispatcher); - --ni;--i; - } - } - if(pairs.size()>0) m_cid=(m_cid+ni)%pairs.size(); else m_cid=0; - } - } - ++m_pid; - m_newpairs=1; - m_needcleanup=false; - if(m_updates_call>0) - { m_updates_ratio=m_updates_done/(btScalar)m_updates_call; } - else - { m_updates_ratio=0; } - m_updates_done/=2; - m_updates_call/=2; -} - -// -void btDbvtBroadphase::optimize() -{ - m_sets[0].optimizeTopDown(); - m_sets[1].optimizeTopDown(); -} - -// -btOverlappingPairCache* btDbvtBroadphase::getOverlappingPairCache() -{ - return(m_paircache); -} - -// -const btOverlappingPairCache* btDbvtBroadphase::getOverlappingPairCache() const -{ - return(m_paircache); -} - -// -void btDbvtBroadphase::getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const -{ - - ATTRIBUTE_ALIGNED16(btDbvtVolume) bounds; - - if(!m_sets[0].empty()) - if(!m_sets[1].empty()) Merge( m_sets[0].m_root->volume, - m_sets[1].m_root->volume,bounds); - else - bounds=m_sets[0].m_root->volume; - else if(!m_sets[1].empty()) bounds=m_sets[1].m_root->volume; - else - bounds=btDbvtVolume::FromCR(btVector3(0,0,0),0); - aabbMin=bounds.Mins(); - aabbMax=bounds.Maxs(); -} - -void btDbvtBroadphase::resetPool(btDispatcher* dispatcher) -{ - - int totalObjects = m_sets[0].m_leaves + m_sets[1].m_leaves; - if (!totalObjects) - { - //reset internal dynamic tree data structures - m_sets[0].clear(); - m_sets[1].clear(); - - m_deferedcollide = false; - m_needcleanup = true; - m_stageCurrent = 0; - m_fixedleft = 0; - m_fupdates = 1; - m_dupdates = 0; - m_cupdates = 10; - m_newpairs = 1; - m_updates_call = 0; - m_updates_done = 0; - m_updates_ratio = 0; - - m_gid = 0; - m_pid = 0; - m_cid = 0; - for(int i=0;i<=STAGECOUNT;++i) - { - m_stageRoots[i]=0; - } - } -} - -// -void btDbvtBroadphase::printStats() -{} - -// -#if DBVT_BP_ENABLE_BENCHMARK - -struct btBroadphaseBenchmark -{ - struct Experiment - { - const char* name; - int object_count; - int update_count; - int spawn_count; - int iterations; - btScalar speed; - btScalar amplitude; - }; - struct Object - { - btVector3 center; - btVector3 extents; - btBroadphaseProxy* proxy; - btScalar time; - void update(btScalar speed,btScalar amplitude,btBroadphaseInterface* pbi) - { - time += speed; - center[0] = btCos(time*(btScalar)2.17)*amplitude+ - btSin(time)*amplitude/2; - center[1] = btCos(time*(btScalar)1.38)*amplitude+ - btSin(time)*amplitude; - center[2] = btSin(time*(btScalar)0.777)*amplitude; - pbi->setAabb(proxy,center-extents,center+extents,0); - } - }; - static int UnsignedRand(int range=RAND_MAX-1) { return(rand()%(range+1)); } - static btScalar UnitRand() { return(UnsignedRand(16384)/(btScalar)16384); } - static void OutputTime(const char* name,btClock& c,unsigned count=0) - { - const unsigned long us=c.getTimeMicroseconds(); - const unsigned long ms=(us+500)/1000; - const btScalar sec=us/(btScalar)(1000*1000); - if(count>0) - printf("%s : %u us (%u ms), %.2f/s\r\n",name,us,ms,count/sec); - else - printf("%s : %u us (%u ms)\r\n",name,us,ms); - } -}; - -void btDbvtBroadphase::benchmark(btBroadphaseInterface* pbi) -{ - static const btBroadphaseBenchmark::Experiment experiments[]= - { - {"1024o.10%",1024,10,0,8192,(btScalar)0.005,(btScalar)100}, - /*{"4096o.10%",4096,10,0,8192,(btScalar)0.005,(btScalar)100}, - {"8192o.10%",8192,10,0,8192,(btScalar)0.005,(btScalar)100},*/ - }; - static const int nexperiments=sizeof(experiments)/sizeof(experiments[0]); - btAlignedObjectArray objects; - btClock wallclock; - /* Begin */ - for(int iexp=0;iexpcenter[0]=btBroadphaseBenchmark::UnitRand()*50; - po->center[1]=btBroadphaseBenchmark::UnitRand()*50; - po->center[2]=btBroadphaseBenchmark::UnitRand()*50; - po->extents[0]=btBroadphaseBenchmark::UnitRand()*2+2; - po->extents[1]=btBroadphaseBenchmark::UnitRand()*2+2; - po->extents[2]=btBroadphaseBenchmark::UnitRand()*2+2; - po->time=btBroadphaseBenchmark::UnitRand()*2000; - po->proxy=pbi->createProxy(po->center-po->extents,po->center+po->extents,0,po,1,1,0,0); - objects.push_back(po); - } - btBroadphaseBenchmark::OutputTime("\tInitialization",wallclock); - /* First update */ - wallclock.reset(); - for(int i=0;iupdate(speed,amplitude,pbi); - } - btBroadphaseBenchmark::OutputTime("\tFirst update",wallclock); - /* Updates */ - wallclock.reset(); - for(int i=0;iupdate(speed,amplitude,pbi); - } - pbi->calculateOverlappingPairs(0); - } - btBroadphaseBenchmark::OutputTime("\tUpdate",wallclock,experiment.iterations); - /* Clean up */ - wallclock.reset(); - for(int i=0;idestroyProxy(objects[i]->proxy,0); - delete objects[i]; - } - objects.resize(0); - btBroadphaseBenchmark::OutputTime("\tRelease",wallclock); - } - -} -#else -void btDbvtBroadphase::benchmark(btBroadphaseInterface*) -{} -#endif - -#if DBVT_BP_PROFILE -#undef SPC -#endif - diff --git a/bullet/src/BulletCollision/BroadphaseCollision/btDbvtBroadphase.h b/bullet/src/BulletCollision/BroadphaseCollision/btDbvtBroadphase.h deleted file mode 100644 index 0e571d67a..000000000 --- a/bullet/src/BulletCollision/BroadphaseCollision/btDbvtBroadphase.h +++ /dev/null @@ -1,135 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -///btDbvtBroadphase implementation by Nathanael Presson -#ifndef BT_DBVT_BROADPHASE_H -#define BT_DBVT_BROADPHASE_H - -#include "BulletCollision/BroadphaseCollision/btDbvt.h" -#include "BulletCollision/BroadphaseCollision/btOverlappingPairCache.h" - -// -// Compile time config -// - -#define DBVT_BP_PROFILE 0 -//#define DBVT_BP_SORTPAIRS 1 -#define DBVT_BP_PREVENTFALSEUPDATE 0 -#define DBVT_BP_ACCURATESLEEPING 0 -#define DBVT_BP_ENABLE_BENCHMARK 0 -#define DBVT_BP_MARGIN (btScalar)0.05 - -#if DBVT_BP_PROFILE -#define DBVT_BP_PROFILING_RATE 256 -#include "LinearMath/btQuickprof.h" -#endif - -// -// btDbvtProxy -// -struct btDbvtProxy : btBroadphaseProxy -{ - /* Fields */ - //btDbvtAabbMm aabb; - btDbvtNode* leaf; - btDbvtProxy* links[2]; - int stage; - /* ctor */ - btDbvtProxy(const btVector3& aabbMin,const btVector3& aabbMax,void* userPtr,short int collisionFilterGroup, short int collisionFilterMask) : - btBroadphaseProxy(aabbMin,aabbMax,userPtr,collisionFilterGroup,collisionFilterMask) - { - links[0]=links[1]=0; - } -}; - -typedef btAlignedObjectArray btDbvtProxyArray; - -///The btDbvtBroadphase implements a broadphase using two dynamic AABB bounding volume hierarchies/trees (see btDbvt). -///One tree is used for static/non-moving objects, and another tree is used for dynamic objects. Objects can move from one tree to the other. -///This is a very fast broadphase, especially for very dynamic worlds where many objects are moving. Its insert/add and remove of objects is generally faster than the sweep and prune broadphases btAxisSweep3 and bt32BitAxisSweep3. -struct btDbvtBroadphase : btBroadphaseInterface -{ - /* Config */ - enum { - DYNAMIC_SET = 0, /* Dynamic set index */ - FIXED_SET = 1, /* Fixed set index */ - STAGECOUNT = 2 /* Number of stages */ - }; - /* Fields */ - btDbvt m_sets[2]; // Dbvt sets - btDbvtProxy* m_stageRoots[STAGECOUNT+1]; // Stages list - btOverlappingPairCache* m_paircache; // Pair cache - btScalar m_prediction; // Velocity prediction - int m_stageCurrent; // Current stage - int m_fupdates; // % of fixed updates per frame - int m_dupdates; // % of dynamic updates per frame - int m_cupdates; // % of cleanup updates per frame - int m_newpairs; // Number of pairs created - int m_fixedleft; // Fixed optimization left - unsigned m_updates_call; // Number of updates call - unsigned m_updates_done; // Number of updates done - btScalar m_updates_ratio; // m_updates_done/m_updates_call - int m_pid; // Parse id - int m_cid; // Cleanup index - int m_gid; // Gen id - bool m_releasepaircache; // Release pair cache on delete - bool m_deferedcollide; // Defere dynamic/static collision to collide call - bool m_needcleanup; // Need to run cleanup? -#if DBVT_BP_PROFILE - btClock m_clock; - struct { - unsigned long m_total; - unsigned long m_ddcollide; - unsigned long m_fdcollide; - unsigned long m_cleanup; - unsigned long m_jobcount; - } m_profiling; -#endif - /* Methods */ - btDbvtBroadphase(btOverlappingPairCache* paircache=0); - ~btDbvtBroadphase(); - void collide(btDispatcher* dispatcher); - void optimize(); - /* btBroadphaseInterface Implementation */ - btBroadphaseProxy* createProxy(const btVector3& aabbMin,const btVector3& aabbMax,int shapeType,void* userPtr,short int collisionFilterGroup,short int collisionFilterMask,btDispatcher* dispatcher,void* multiSapProxy); - void destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher); - void setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax,btDispatcher* dispatcher); - virtual void rayTest(const btVector3& rayFrom,const btVector3& rayTo, btBroadphaseRayCallback& rayCallback, const btVector3& aabbMin=btVector3(0,0,0), const btVector3& aabbMax = btVector3(0,0,0)); - - virtual void getAabb(btBroadphaseProxy* proxy,btVector3& aabbMin, btVector3& aabbMax ) const; - void calculateOverlappingPairs(btDispatcher* dispatcher); - btOverlappingPairCache* getOverlappingPairCache(); - const btOverlappingPairCache* getOverlappingPairCache() const; - void getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const; - void printStats(); - static void benchmark(btBroadphaseInterface*); - - void setVelocityPrediction(btScalar prediction) - { - m_prediction = prediction; - } - btScalar getVelocityPrediction() const - { - return m_prediction; - } - - void performDeferredRemoval(btDispatcher* dispatcher); - - ///reset broadphase internal structures, to ensure determinism/reproducability - virtual void resetPool(btDispatcher* dispatcher); - -}; - -#endif diff --git a/bullet/src/BulletCollision/BroadphaseCollision/btDispatcher.cpp b/bullet/src/BulletCollision/BroadphaseCollision/btDispatcher.cpp deleted file mode 100644 index e70223279..000000000 --- a/bullet/src/BulletCollision/BroadphaseCollision/btDispatcher.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btDispatcher.h" - -btDispatcher::~btDispatcher() -{ - -} - diff --git a/bullet/src/BulletCollision/BroadphaseCollision/btDispatcher.h b/bullet/src/BulletCollision/BroadphaseCollision/btDispatcher.h deleted file mode 100644 index 25c369681..000000000 --- a/bullet/src/BulletCollision/BroadphaseCollision/btDispatcher.h +++ /dev/null @@ -1,106 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef _DISPATCHER_H -#define _DISPATCHER_H - -#include "LinearMath/btScalar.h" - -class btCollisionAlgorithm; -struct btBroadphaseProxy; -class btRigidBody; -class btCollisionObject; -class btOverlappingPairCache; - - -class btPersistentManifold; -class btStackAlloc; - -struct btDispatcherInfo -{ - enum DispatchFunc - { - DISPATCH_DISCRETE = 1, - DISPATCH_CONTINUOUS - }; - btDispatcherInfo() - :m_timeStep(btScalar(0.)), - m_stepCount(0), - m_dispatchFunc(DISPATCH_DISCRETE), - m_timeOfImpact(btScalar(1.)), - m_useContinuous(false), - m_debugDraw(0), - m_enableSatConvex(false), - m_enableSPU(true), - m_useEpa(true), - m_allowedCcdPenetration(btScalar(0.04)), - m_useConvexConservativeDistanceUtil(false), - m_convexConservativeDistanceThreshold(0.0f), - m_stackAllocator(0) - { - - } - btScalar m_timeStep; - int m_stepCount; - int m_dispatchFunc; - mutable btScalar m_timeOfImpact; - bool m_useContinuous; - class btIDebugDraw* m_debugDraw; - bool m_enableSatConvex; - bool m_enableSPU; - bool m_useEpa; - btScalar m_allowedCcdPenetration; - bool m_useConvexConservativeDistanceUtil; - btScalar m_convexConservativeDistanceThreshold; - btStackAlloc* m_stackAllocator; -}; - -///The btDispatcher interface class can be used in combination with broadphase to dispatch calculations for overlapping pairs. -///For example for pairwise collision detection, calculating contact points stored in btPersistentManifold or user callbacks (game logic). -class btDispatcher -{ - - -public: - virtual ~btDispatcher() ; - - virtual btCollisionAlgorithm* findAlgorithm(btCollisionObject* body0,btCollisionObject* body1,btPersistentManifold* sharedManifold=0) = 0; - - virtual btPersistentManifold* getNewManifold(void* body0,void* body1)=0; - - virtual void releaseManifold(btPersistentManifold* manifold)=0; - - virtual void clearManifold(btPersistentManifold* manifold)=0; - - virtual bool needsCollision(btCollisionObject* body0,btCollisionObject* body1) = 0; - - virtual bool needsResponse(btCollisionObject* body0,btCollisionObject* body1)=0; - - virtual void dispatchAllCollisionPairs(btOverlappingPairCache* pairCache,const btDispatcherInfo& dispatchInfo,btDispatcher* dispatcher) =0; - - virtual int getNumManifolds() const = 0; - - virtual btPersistentManifold* getManifoldByIndexInternal(int index) = 0; - - virtual btPersistentManifold** getInternalManifoldPointer() = 0; - - virtual void* allocateCollisionAlgorithm(int size) = 0; - - virtual void freeCollisionAlgorithm(void* ptr) = 0; - -}; - - -#endif //_DISPATCHER_H diff --git a/bullet/src/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.cpp b/bullet/src/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.cpp deleted file mode 100644 index ef6779240..000000000 --- a/bullet/src/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.cpp +++ /dev/null @@ -1,489 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btMultiSapBroadphase.h" - -#include "btSimpleBroadphase.h" -#include "LinearMath/btAabbUtil2.h" -#include "btQuantizedBvh.h" - -/// btSapBroadphaseArray m_sapBroadphases; - -/// btOverlappingPairCache* m_overlappingPairs; -extern int gOverlappingPairs; - -/* -class btMultiSapSortedOverlappingPairCache : public btSortedOverlappingPairCache -{ -public: - - virtual btBroadphasePair* addOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) - { - return btSortedOverlappingPairCache::addOverlappingPair((btBroadphaseProxy*)proxy0->m_multiSapParentProxy,(btBroadphaseProxy*)proxy1->m_multiSapParentProxy); - } -}; - -*/ - -btMultiSapBroadphase::btMultiSapBroadphase(int /*maxProxies*/,btOverlappingPairCache* pairCache) -:m_overlappingPairs(pairCache), -m_optimizedAabbTree(0), -m_ownsPairCache(false), -m_invalidPair(0) -{ - if (!m_overlappingPairs) - { - m_ownsPairCache = true; - void* mem = btAlignedAlloc(sizeof(btSortedOverlappingPairCache),16); - m_overlappingPairs = new (mem)btSortedOverlappingPairCache(); - } - - struct btMultiSapOverlapFilterCallback : public btOverlapFilterCallback - { - virtual ~btMultiSapOverlapFilterCallback() - {} - // return true when pairs need collision - virtual bool needBroadphaseCollision(btBroadphaseProxy* childProxy0,btBroadphaseProxy* childProxy1) const - { - btBroadphaseProxy* multiProxy0 = (btBroadphaseProxy*)childProxy0->m_multiSapParentProxy; - btBroadphaseProxy* multiProxy1 = (btBroadphaseProxy*)childProxy1->m_multiSapParentProxy; - - bool collides = (multiProxy0->m_collisionFilterGroup & multiProxy1->m_collisionFilterMask) != 0; - collides = collides && (multiProxy1->m_collisionFilterGroup & multiProxy0->m_collisionFilterMask); - - return collides; - } - }; - - void* mem = btAlignedAlloc(sizeof(btMultiSapOverlapFilterCallback),16); - m_filterCallback = new (mem)btMultiSapOverlapFilterCallback(); - - m_overlappingPairs->setOverlapFilterCallback(m_filterCallback); -// mem = btAlignedAlloc(sizeof(btSimpleBroadphase),16); -// m_simpleBroadphase = new (mem) btSimpleBroadphase(maxProxies,m_overlappingPairs); -} - -btMultiSapBroadphase::~btMultiSapBroadphase() -{ - if (m_ownsPairCache) - { - m_overlappingPairs->~btOverlappingPairCache(); - btAlignedFree(m_overlappingPairs); - } -} - - -void btMultiSapBroadphase::buildTree(const btVector3& bvhAabbMin,const btVector3& bvhAabbMax) -{ - m_optimizedAabbTree = new btQuantizedBvh(); - m_optimizedAabbTree->setQuantizationValues(bvhAabbMin,bvhAabbMax); - QuantizedNodeArray& nodes = m_optimizedAabbTree->getLeafNodeArray(); - for (int i=0;igetBroadphaseAabb(aabbMin,aabbMax); - m_optimizedAabbTree->quantize(&node.m_quantizedAabbMin[0],aabbMin,0); - m_optimizedAabbTree->quantize(&node.m_quantizedAabbMax[0],aabbMax,1); - int partId = 0; - node.m_escapeIndexOrTriangleIndex = (partId<<(31-MAX_NUM_PARTS_IN_BITS)) | i; - nodes.push_back(node); - } - m_optimizedAabbTree->buildInternal(); -} - -btBroadphaseProxy* btMultiSapBroadphase::createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr, short int collisionFilterGroup,short int collisionFilterMask, btDispatcher* dispatcher,void* /*ignoreMe*/) -{ - //void* ignoreMe -> we could think of recursive multi-sap, if someone is interested - - void* mem = btAlignedAlloc(sizeof(btMultiSapProxy),16); - btMultiSapProxy* proxy = new (mem)btMultiSapProxy(aabbMin, aabbMax,shapeType,userPtr, collisionFilterGroup,collisionFilterMask); - m_multiSapProxies.push_back(proxy); - - ///this should deal with inserting/removal into child broadphases - setAabb(proxy,aabbMin,aabbMax,dispatcher); - return proxy; -} - -void btMultiSapBroadphase::destroyProxy(btBroadphaseProxy* /*proxy*/,btDispatcher* /*dispatcher*/) -{ - ///not yet - btAssert(0); - -} - - -void btMultiSapBroadphase::addToChildBroadphase(btMultiSapProxy* parentMultiSapProxy, btBroadphaseProxy* childProxy, btBroadphaseInterface* childBroadphase) -{ - void* mem = btAlignedAlloc(sizeof(btBridgeProxy),16); - btBridgeProxy* bridgeProxyRef = new(mem) btBridgeProxy; - bridgeProxyRef->m_childProxy = childProxy; - bridgeProxyRef->m_childBroadphase = childBroadphase; - parentMultiSapProxy->m_bridgeProxies.push_back(bridgeProxyRef); -} - - -bool boxIsContainedWithinBox(const btVector3& amin,const btVector3& amax,const btVector3& bmin,const btVector3& bmax); -bool boxIsContainedWithinBox(const btVector3& amin,const btVector3& amax,const btVector3& bmin,const btVector3& bmax) -{ -return -amin.getX() >= bmin.getX() && amax.getX() <= bmax.getX() && -amin.getY() >= bmin.getY() && amax.getY() <= bmax.getY() && -amin.getZ() >= bmin.getZ() && amax.getZ() <= bmax.getZ(); -} - - - - - - -void btMultiSapBroadphase::getAabb(btBroadphaseProxy* proxy,btVector3& aabbMin, btVector3& aabbMax ) const -{ - btMultiSapProxy* multiProxy = static_cast(proxy); - aabbMin = multiProxy->m_aabbMin; - aabbMax = multiProxy->m_aabbMax; -} - -void btMultiSapBroadphase::rayTest(const btVector3& rayFrom,const btVector3& rayTo, btBroadphaseRayCallback& rayCallback, const btVector3& aabbMin,const btVector3& aabbMax) -{ - for (int i=0;i - -void btMultiSapBroadphase::setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax, btDispatcher* dispatcher) -{ - btMultiSapProxy* multiProxy = static_cast(proxy); - multiProxy->m_aabbMin = aabbMin; - multiProxy->m_aabbMax = aabbMax; - - -// bool fullyContained = false; -// bool alreadyInSimple = false; - - - - - struct MyNodeOverlapCallback : public btNodeOverlapCallback - { - btMultiSapBroadphase* m_multiSap; - btMultiSapProxy* m_multiProxy; - btDispatcher* m_dispatcher; - - MyNodeOverlapCallback(btMultiSapBroadphase* multiSap,btMultiSapProxy* multiProxy,btDispatcher* dispatcher) - :m_multiSap(multiSap), - m_multiProxy(multiProxy), - m_dispatcher(dispatcher) - { - - } - - virtual void processNode(int /*nodeSubPart*/, int broadphaseIndex) - { - btBroadphaseInterface* childBroadphase = m_multiSap->getBroadphaseArray()[broadphaseIndex]; - - int containingBroadphaseIndex = -1; - //already found? - for (int i=0;im_bridgeProxies.size();i++) - { - - if (m_multiProxy->m_bridgeProxies[i]->m_childBroadphase == childBroadphase) - { - containingBroadphaseIndex = i; - break; - } - } - if (containingBroadphaseIndex<0) - { - //add it - btBroadphaseProxy* childProxy = childBroadphase->createProxy(m_multiProxy->m_aabbMin,m_multiProxy->m_aabbMax,m_multiProxy->m_shapeType,m_multiProxy->m_clientObject,m_multiProxy->m_collisionFilterGroup,m_multiProxy->m_collisionFilterMask, m_dispatcher,m_multiProxy); - m_multiSap->addToChildBroadphase(m_multiProxy,childProxy,childBroadphase); - - } - } - }; - - MyNodeOverlapCallback myNodeCallback(this,multiProxy,dispatcher); - - - - - if (m_optimizedAabbTree) - m_optimizedAabbTree->reportAabbOverlappingNodex(&myNodeCallback,aabbMin,aabbMax); - - int i; - - for ( i=0;im_bridgeProxies.size();i++) - { - btVector3 worldAabbMin,worldAabbMax; - multiProxy->m_bridgeProxies[i]->m_childBroadphase->getBroadphaseAabb(worldAabbMin,worldAabbMax); - bool overlapsBroadphase = TestAabbAgainstAabb2(worldAabbMin,worldAabbMax,multiProxy->m_aabbMin,multiProxy->m_aabbMax); - if (!overlapsBroadphase) - { - //remove it now - btBridgeProxy* bridgeProxy = multiProxy->m_bridgeProxies[i]; - - btBroadphaseProxy* childProxy = bridgeProxy->m_childProxy; - bridgeProxy->m_childBroadphase->destroyProxy(childProxy,dispatcher); - - multiProxy->m_bridgeProxies.swap( i,multiProxy->m_bridgeProxies.size()-1); - multiProxy->m_bridgeProxies.pop_back(); - - } - } - - - /* - - if (1) - { - - //find broadphase that contain this multiProxy - int numChildBroadphases = getBroadphaseArray().size(); - for (int i=0;igetBroadphaseAabb(worldAabbMin,worldAabbMax); - bool overlapsBroadphase = TestAabbAgainstAabb2(worldAabbMin,worldAabbMax,multiProxy->m_aabbMin,multiProxy->m_aabbMax); - - // fullyContained = fullyContained || boxIsContainedWithinBox(worldAabbMin,worldAabbMax,multiProxy->m_aabbMin,multiProxy->m_aabbMax); - int containingBroadphaseIndex = -1; - - //if already contains this - - for (int i=0;im_bridgeProxies.size();i++) - { - if (multiProxy->m_bridgeProxies[i]->m_childBroadphase == childBroadphase) - { - containingBroadphaseIndex = i; - } - alreadyInSimple = alreadyInSimple || (multiProxy->m_bridgeProxies[i]->m_childBroadphase == m_simpleBroadphase); - } - - if (overlapsBroadphase) - { - if (containingBroadphaseIndex<0) - { - btBroadphaseProxy* childProxy = childBroadphase->createProxy(aabbMin,aabbMax,multiProxy->m_shapeType,multiProxy->m_clientObject,multiProxy->m_collisionFilterGroup,multiProxy->m_collisionFilterMask, dispatcher); - childProxy->m_multiSapParentProxy = multiProxy; - addToChildBroadphase(multiProxy,childProxy,childBroadphase); - } - } else - { - if (containingBroadphaseIndex>=0) - { - //remove - btBridgeProxy* bridgeProxy = multiProxy->m_bridgeProxies[containingBroadphaseIndex]; - - btBroadphaseProxy* childProxy = bridgeProxy->m_childProxy; - bridgeProxy->m_childBroadphase->destroyProxy(childProxy,dispatcher); - - multiProxy->m_bridgeProxies.swap( containingBroadphaseIndex,multiProxy->m_bridgeProxies.size()-1); - multiProxy->m_bridgeProxies.pop_back(); - } - } - } - - - ///If we are in no other child broadphase, stick the proxy in the global 'simple' broadphase (brute force) - ///hopefully we don't end up with many entries here (can assert/provide feedback on stats) - if (0)//!multiProxy->m_bridgeProxies.size()) - { - ///we don't pass the userPtr but our multisap proxy. We need to patch this, before processing an actual collision - ///this is needed to be able to calculate the aabb overlap - btBroadphaseProxy* childProxy = m_simpleBroadphase->createProxy(aabbMin,aabbMax,multiProxy->m_shapeType,multiProxy->m_clientObject,multiProxy->m_collisionFilterGroup,multiProxy->m_collisionFilterMask, dispatcher); - childProxy->m_multiSapParentProxy = multiProxy; - addToChildBroadphase(multiProxy,childProxy,m_simpleBroadphase); - } - } - - if (!multiProxy->m_bridgeProxies.size()) - { - ///we don't pass the userPtr but our multisap proxy. We need to patch this, before processing an actual collision - ///this is needed to be able to calculate the aabb overlap - btBroadphaseProxy* childProxy = m_simpleBroadphase->createProxy(aabbMin,aabbMax,multiProxy->m_shapeType,multiProxy->m_clientObject,multiProxy->m_collisionFilterGroup,multiProxy->m_collisionFilterMask, dispatcher); - childProxy->m_multiSapParentProxy = multiProxy; - addToChildBroadphase(multiProxy,childProxy,m_simpleBroadphase); - } -*/ - - - //update - for ( i=0;im_bridgeProxies.size();i++) - { - btBridgeProxy* bridgeProxyRef = multiProxy->m_bridgeProxies[i]; - bridgeProxyRef->m_childBroadphase->setAabb(bridgeProxyRef->m_childProxy,aabbMin,aabbMax,dispatcher); - } - -} -bool stopUpdating=false; - - - -class btMultiSapBroadphasePairSortPredicate -{ - public: - - bool operator() ( const btBroadphasePair& a1, const btBroadphasePair& b1 ) - { - btMultiSapBroadphase::btMultiSapProxy* aProxy0 = a1.m_pProxy0 ? (btMultiSapBroadphase::btMultiSapProxy*)a1.m_pProxy0->m_multiSapParentProxy : 0; - btMultiSapBroadphase::btMultiSapProxy* aProxy1 = a1.m_pProxy1 ? (btMultiSapBroadphase::btMultiSapProxy*)a1.m_pProxy1->m_multiSapParentProxy : 0; - btMultiSapBroadphase::btMultiSapProxy* bProxy0 = b1.m_pProxy0 ? (btMultiSapBroadphase::btMultiSapProxy*)b1.m_pProxy0->m_multiSapParentProxy : 0; - btMultiSapBroadphase::btMultiSapProxy* bProxy1 = b1.m_pProxy1 ? (btMultiSapBroadphase::btMultiSapProxy*)b1.m_pProxy1->m_multiSapParentProxy : 0; - - return aProxy0 > bProxy0 || - (aProxy0 == bProxy0 && aProxy1 > bProxy1) || - (aProxy0 == bProxy0 && aProxy1 == bProxy1 && a1.m_algorithm > b1.m_algorithm); - } -}; - - - ///calculateOverlappingPairs is optional: incremental algorithms (sweep and prune) might do it during the set aabb -void btMultiSapBroadphase::calculateOverlappingPairs(btDispatcher* dispatcher) -{ - -// m_simpleBroadphase->calculateOverlappingPairs(dispatcher); - - if (!stopUpdating && getOverlappingPairCache()->hasDeferredRemoval()) - { - - btBroadphasePairArray& overlappingPairArray = getOverlappingPairCache()->getOverlappingPairArray(); - - // quicksort(overlappingPairArray,0,overlappingPairArray.size()); - - overlappingPairArray.quickSort(btMultiSapBroadphasePairSortPredicate()); - - //perform a sort, to find duplicates and to sort 'invalid' pairs to the end - // overlappingPairArray.heapSort(btMultiSapBroadphasePairSortPredicate()); - - overlappingPairArray.resize(overlappingPairArray.size() - m_invalidPair); - m_invalidPair = 0; - - - int i; - - btBroadphasePair previousPair; - previousPair.m_pProxy0 = 0; - previousPair.m_pProxy1 = 0; - previousPair.m_algorithm = 0; - - - for (i=0;im_multiSapParentProxy : 0; - btMultiSapProxy* aProxy1 = pair.m_pProxy1 ? (btMultiSapProxy*)pair.m_pProxy1->m_multiSapParentProxy : 0; - btMultiSapProxy* bProxy0 = previousPair.m_pProxy0 ? (btMultiSapProxy*)previousPair.m_pProxy0->m_multiSapParentProxy : 0; - btMultiSapProxy* bProxy1 = previousPair.m_pProxy1 ? (btMultiSapProxy*)previousPair.m_pProxy1->m_multiSapParentProxy : 0; - - bool isDuplicate = (aProxy0 == bProxy0) && (aProxy1 == bProxy1); - - previousPair = pair; - - bool needsRemoval = false; - - if (!isDuplicate) - { - bool hasOverlap = testAabbOverlap(pair.m_pProxy0,pair.m_pProxy1); - - if (hasOverlap) - { - needsRemoval = false;//callback->processOverlap(pair); - } else - { - needsRemoval = true; - } - } else - { - //remove duplicate - needsRemoval = true; - //should have no algorithm - btAssert(!pair.m_algorithm); - } - - if (needsRemoval) - { - getOverlappingPairCache()->cleanOverlappingPair(pair,dispatcher); - - // m_overlappingPairArray.swap(i,m_overlappingPairArray.size()-1); - // m_overlappingPairArray.pop_back(); - pair.m_pProxy0 = 0; - pair.m_pProxy1 = 0; - m_invalidPair++; - gOverlappingPairs--; - } - - } - - ///if you don't like to skip the invalid pairs in the array, execute following code: - #define CLEAN_INVALID_PAIRS 1 - #ifdef CLEAN_INVALID_PAIRS - - //perform a sort, to sort 'invalid' pairs to the end - //overlappingPairArray.heapSort(btMultiSapBroadphasePairSortPredicate()); - overlappingPairArray.quickSort(btMultiSapBroadphasePairSortPredicate()); - - overlappingPairArray.resize(overlappingPairArray.size() - m_invalidPair); - m_invalidPair = 0; - #endif//CLEAN_INVALID_PAIRS - - //printf("overlappingPairArray.size()=%d\n",overlappingPairArray.size()); - } - - -} - - -bool btMultiSapBroadphase::testAabbOverlap(btBroadphaseProxy* childProxy0,btBroadphaseProxy* childProxy1) -{ - btMultiSapProxy* multiSapProxy0 = (btMultiSapProxy*)childProxy0->m_multiSapParentProxy; - btMultiSapProxy* multiSapProxy1 = (btMultiSapProxy*)childProxy1->m_multiSapParentProxy; - - return TestAabbAgainstAabb2(multiSapProxy0->m_aabbMin,multiSapProxy0->m_aabbMax, - multiSapProxy1->m_aabbMin,multiSapProxy1->m_aabbMax); - -} - - -void btMultiSapBroadphase::printStats() -{ -/* printf("---------------------------------\n"); - - printf("btMultiSapBroadphase.h\n"); - printf("numHandles = %d\n",m_multiSapProxies.size()); - //find broadphase that contain this multiProxy - int numChildBroadphases = getBroadphaseArray().size(); - for (int i=0;iprintStats(); - - } - */ - -} - -void btMultiSapBroadphase::resetPool(btDispatcher* dispatcher) -{ - // not yet -} diff --git a/bullet/src/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.h b/bullet/src/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.h deleted file mode 100644 index df1637a86..000000000 --- a/bullet/src/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.h +++ /dev/null @@ -1,151 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ -#ifndef BT_MULTI_SAP_BROADPHASE -#define BT_MULTI_SAP_BROADPHASE - -#include "btBroadphaseInterface.h" -#include "LinearMath/btAlignedObjectArray.h" -#include "btOverlappingPairCache.h" - - -class btBroadphaseInterface; -class btSimpleBroadphase; - - -typedef btAlignedObjectArray btSapBroadphaseArray; - -///The btMultiSapBroadphase is a research project, not recommended to use in production. Use btAxisSweep3 or btDbvtBroadphase instead. -///The btMultiSapBroadphase is a broadphase that contains multiple SAP broadphases. -///The user can add SAP broadphases that cover the world. A btBroadphaseProxy can be in multiple child broadphases at the same time. -///A btQuantizedBvh acceleration structures finds overlapping SAPs for each btBroadphaseProxy. -///See http://www.continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=328 -///and http://www.continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=1329 -class btMultiSapBroadphase :public btBroadphaseInterface -{ - btSapBroadphaseArray m_sapBroadphases; - - btSimpleBroadphase* m_simpleBroadphase; - - btOverlappingPairCache* m_overlappingPairs; - - class btQuantizedBvh* m_optimizedAabbTree; - - - bool m_ownsPairCache; - - btOverlapFilterCallback* m_filterCallback; - - int m_invalidPair; - - struct btBridgeProxy - { - btBroadphaseProxy* m_childProxy; - btBroadphaseInterface* m_childBroadphase; - }; - - -public: - - struct btMultiSapProxy : public btBroadphaseProxy - { - - ///array with all the entries that this proxy belongs to - btAlignedObjectArray m_bridgeProxies; - btVector3 m_aabbMin; - btVector3 m_aabbMax; - - int m_shapeType; - -/* void* m_userPtr; - short int m_collisionFilterGroup; - short int m_collisionFilterMask; -*/ - btMultiSapProxy(const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr, short int collisionFilterGroup,short int collisionFilterMask) - :btBroadphaseProxy(aabbMin,aabbMax,userPtr,collisionFilterGroup,collisionFilterMask), - m_aabbMin(aabbMin), - m_aabbMax(aabbMax), - m_shapeType(shapeType) - { - m_multiSapParentProxy =this; - } - - - }; - -protected: - - - btAlignedObjectArray m_multiSapProxies; - -public: - - btMultiSapBroadphase(int maxProxies = 16384,btOverlappingPairCache* pairCache=0); - - - btSapBroadphaseArray& getBroadphaseArray() - { - return m_sapBroadphases; - } - - const btSapBroadphaseArray& getBroadphaseArray() const - { - return m_sapBroadphases; - } - - virtual ~btMultiSapBroadphase(); - - virtual btBroadphaseProxy* createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr, short int collisionFilterGroup,short int collisionFilterMask, btDispatcher* dispatcher,void* multiSapProxy); - virtual void destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher); - virtual void setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax, btDispatcher* dispatcher); - virtual void getAabb(btBroadphaseProxy* proxy,btVector3& aabbMin, btVector3& aabbMax ) const; - - virtual void rayTest(const btVector3& rayFrom,const btVector3& rayTo, btBroadphaseRayCallback& rayCallback,const btVector3& aabbMin=btVector3(0,0,0),const btVector3& aabbMax=btVector3(0,0,0)); - - void addToChildBroadphase(btMultiSapProxy* parentMultiSapProxy, btBroadphaseProxy* childProxy, btBroadphaseInterface* childBroadphase); - - ///calculateOverlappingPairs is optional: incremental algorithms (sweep and prune) might do it during the set aabb - virtual void calculateOverlappingPairs(btDispatcher* dispatcher); - - bool testAabbOverlap(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1); - - virtual btOverlappingPairCache* getOverlappingPairCache() - { - return m_overlappingPairs; - } - virtual const btOverlappingPairCache* getOverlappingPairCache() const - { - return m_overlappingPairs; - } - - ///getAabb returns the axis aligned bounding box in the 'global' coordinate frame - ///will add some transform later - virtual void getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const - { - aabbMin.setValue(-BT_LARGE_FLOAT,-BT_LARGE_FLOAT,-BT_LARGE_FLOAT); - aabbMax.setValue(BT_LARGE_FLOAT,BT_LARGE_FLOAT,BT_LARGE_FLOAT); - } - - void buildTree(const btVector3& bvhAabbMin,const btVector3& bvhAabbMax); - - virtual void printStats(); - - void quicksort (btBroadphasePairArray& a, int lo, int hi); - - ///reset broadphase internal structures, to ensure determinism/reproducability - virtual void resetPool(btDispatcher* dispatcher); - -}; - -#endif //BT_MULTI_SAP_BROADPHASE diff --git a/bullet/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp b/bullet/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp deleted file mode 100644 index 9cf98dbae..000000000 --- a/bullet/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp +++ /dev/null @@ -1,633 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - - -#include "btOverlappingPairCache.h" - -#include "btDispatcher.h" -#include "btCollisionAlgorithm.h" -#include "LinearMath/btAabbUtil2.h" - -#include - -int gOverlappingPairs = 0; - -int gRemovePairs =0; -int gAddedPairs =0; -int gFindPairs =0; - - - - -btHashedOverlappingPairCache::btHashedOverlappingPairCache(): - m_overlapFilterCallback(0), - m_blockedForChanges(false), - m_ghostPairCallback(0) -{ - int initialAllocatedSize= 2; - m_overlappingPairArray.reserve(initialAllocatedSize); - growTables(); -} - - - - -btHashedOverlappingPairCache::~btHashedOverlappingPairCache() -{ -} - - - -void btHashedOverlappingPairCache::cleanOverlappingPair(btBroadphasePair& pair,btDispatcher* dispatcher) -{ - if (pair.m_algorithm) - { - { - pair.m_algorithm->~btCollisionAlgorithm(); - dispatcher->freeCollisionAlgorithm(pair.m_algorithm); - pair.m_algorithm=0; - } - } -} - - - - -void btHashedOverlappingPairCache::cleanProxyFromPairs(btBroadphaseProxy* proxy,btDispatcher* dispatcher) -{ - - class CleanPairCallback : public btOverlapCallback - { - btBroadphaseProxy* m_cleanProxy; - btOverlappingPairCache* m_pairCache; - btDispatcher* m_dispatcher; - - public: - CleanPairCallback(btBroadphaseProxy* cleanProxy,btOverlappingPairCache* pairCache,btDispatcher* dispatcher) - :m_cleanProxy(cleanProxy), - m_pairCache(pairCache), - m_dispatcher(dispatcher) - { - } - virtual bool processOverlap(btBroadphasePair& pair) - { - if ((pair.m_pProxy0 == m_cleanProxy) || - (pair.m_pProxy1 == m_cleanProxy)) - { - m_pairCache->cleanOverlappingPair(pair,m_dispatcher); - } - return false; - } - - }; - - CleanPairCallback cleanPairs(proxy,this,dispatcher); - - processAllOverlappingPairs(&cleanPairs,dispatcher); - -} - - - - -void btHashedOverlappingPairCache::removeOverlappingPairsContainingProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher) -{ - - class RemovePairCallback : public btOverlapCallback - { - btBroadphaseProxy* m_obsoleteProxy; - - public: - RemovePairCallback(btBroadphaseProxy* obsoleteProxy) - :m_obsoleteProxy(obsoleteProxy) - { - } - virtual bool processOverlap(btBroadphasePair& pair) - { - return ((pair.m_pProxy0 == m_obsoleteProxy) || - (pair.m_pProxy1 == m_obsoleteProxy)); - } - - }; - - - RemovePairCallback removeCallback(proxy); - - processAllOverlappingPairs(&removeCallback,dispatcher); -} - - - - - -btBroadphasePair* btHashedOverlappingPairCache::findPair(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1) -{ - gFindPairs++; - if(proxy0->m_uniqueId>proxy1->m_uniqueId) - btSwap(proxy0,proxy1); - int proxyId1 = proxy0->getUid(); - int proxyId2 = proxy1->getUid(); - - /*if (proxyId1 > proxyId2) - btSwap(proxyId1, proxyId2);*/ - - int hash = static_cast(getHash(static_cast(proxyId1), static_cast(proxyId2)) & (m_overlappingPairArray.capacity()-1)); - - if (hash >= m_hashTable.size()) - { - return NULL; - } - - int index = m_hashTable[hash]; - while (index != BT_NULL_PAIR && equalsPair(m_overlappingPairArray[index], proxyId1, proxyId2) == false) - { - index = m_next[index]; - } - - if (index == BT_NULL_PAIR) - { - return NULL; - } - - btAssert(index < m_overlappingPairArray.size()); - - return &m_overlappingPairArray[index]; -} - -//#include - -void btHashedOverlappingPairCache::growTables() -{ - - int newCapacity = m_overlappingPairArray.capacity(); - - if (m_hashTable.size() < newCapacity) - { - //grow hashtable and next table - int curHashtableSize = m_hashTable.size(); - - m_hashTable.resize(newCapacity); - m_next.resize(newCapacity); - - - int i; - - for (i= 0; i < newCapacity; ++i) - { - m_hashTable[i] = BT_NULL_PAIR; - } - for (i = 0; i < newCapacity; ++i) - { - m_next[i] = BT_NULL_PAIR; - } - - for(i=0;igetUid(); - int proxyId2 = pair.m_pProxy1->getUid(); - /*if (proxyId1 > proxyId2) - btSwap(proxyId1, proxyId2);*/ - int hashValue = static_cast(getHash(static_cast(proxyId1),static_cast(proxyId2)) & (m_overlappingPairArray.capacity()-1)); // New hash value with new mask - m_next[i] = m_hashTable[hashValue]; - m_hashTable[hashValue] = i; - } - - - } -} - -btBroadphasePair* btHashedOverlappingPairCache::internalAddPair(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1) -{ - if(proxy0->m_uniqueId>proxy1->m_uniqueId) - btSwap(proxy0,proxy1); - int proxyId1 = proxy0->getUid(); - int proxyId2 = proxy1->getUid(); - - /*if (proxyId1 > proxyId2) - btSwap(proxyId1, proxyId2);*/ - - int hash = static_cast(getHash(static_cast(proxyId1),static_cast(proxyId2)) & (m_overlappingPairArray.capacity()-1)); // New hash value with new mask - - - btBroadphasePair* pair = internalFindPair(proxy0, proxy1, hash); - if (pair != NULL) - { - return pair; - } - /*for(int i=0;i%u\r\n",proxyId1,proxyId2); - internalFindPair(proxy0, proxy1, hash); - } - }*/ - int count = m_overlappingPairArray.size(); - int oldCapacity = m_overlappingPairArray.capacity(); - void* mem = &m_overlappingPairArray.expand(); - - //this is where we add an actual pair, so also call the 'ghost' - if (m_ghostPairCallback) - m_ghostPairCallback->addOverlappingPair(proxy0,proxy1); - - int newCapacity = m_overlappingPairArray.capacity(); - - if (oldCapacity < newCapacity) - { - growTables(); - //hash with new capacity - hash = static_cast(getHash(static_cast(proxyId1),static_cast(proxyId2)) & (m_overlappingPairArray.capacity()-1)); - } - - pair = new (mem) btBroadphasePair(*proxy0,*proxy1); -// pair->m_pProxy0 = proxy0; -// pair->m_pProxy1 = proxy1; - pair->m_algorithm = 0; - pair->m_internalTmpValue = 0; - - - m_next[count] = m_hashTable[hash]; - m_hashTable[hash] = count; - - return pair; -} - - - -void* btHashedOverlappingPairCache::removeOverlappingPair(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1,btDispatcher* dispatcher) -{ - gRemovePairs++; - if(proxy0->m_uniqueId>proxy1->m_uniqueId) - btSwap(proxy0,proxy1); - int proxyId1 = proxy0->getUid(); - int proxyId2 = proxy1->getUid(); - - /*if (proxyId1 > proxyId2) - btSwap(proxyId1, proxyId2);*/ - - int hash = static_cast(getHash(static_cast(proxyId1),static_cast(proxyId2)) & (m_overlappingPairArray.capacity()-1)); - - btBroadphasePair* pair = internalFindPair(proxy0, proxy1, hash); - if (pair == NULL) - { - return 0; - } - - cleanOverlappingPair(*pair,dispatcher); - - void* userData = pair->m_internalInfo1; - - btAssert(pair->m_pProxy0->getUid() == proxyId1); - btAssert(pair->m_pProxy1->getUid() == proxyId2); - - int pairIndex = int(pair - &m_overlappingPairArray[0]); - btAssert(pairIndex < m_overlappingPairArray.size()); - - // Remove the pair from the hash table. - int index = m_hashTable[hash]; - btAssert(index != BT_NULL_PAIR); - - int previous = BT_NULL_PAIR; - while (index != pairIndex) - { - previous = index; - index = m_next[index]; - } - - if (previous != BT_NULL_PAIR) - { - btAssert(m_next[previous] == pairIndex); - m_next[previous] = m_next[pairIndex]; - } - else - { - m_hashTable[hash] = m_next[pairIndex]; - } - - // We now move the last pair into spot of the - // pair being removed. We need to fix the hash - // table indices to support the move. - - int lastPairIndex = m_overlappingPairArray.size() - 1; - - if (m_ghostPairCallback) - m_ghostPairCallback->removeOverlappingPair(proxy0, proxy1,dispatcher); - - // If the removed pair is the last pair, we are done. - if (lastPairIndex == pairIndex) - { - m_overlappingPairArray.pop_back(); - return userData; - } - - // Remove the last pair from the hash table. - const btBroadphasePair* last = &m_overlappingPairArray[lastPairIndex]; - /* missing swap here too, Nat. */ - int lastHash = static_cast(getHash(static_cast(last->m_pProxy0->getUid()), static_cast(last->m_pProxy1->getUid())) & (m_overlappingPairArray.capacity()-1)); - - index = m_hashTable[lastHash]; - btAssert(index != BT_NULL_PAIR); - - previous = BT_NULL_PAIR; - while (index != lastPairIndex) - { - previous = index; - index = m_next[index]; - } - - if (previous != BT_NULL_PAIR) - { - btAssert(m_next[previous] == lastPairIndex); - m_next[previous] = m_next[lastPairIndex]; - } - else - { - m_hashTable[lastHash] = m_next[lastPairIndex]; - } - - // Copy the last pair into the remove pair's spot. - m_overlappingPairArray[pairIndex] = m_overlappingPairArray[lastPairIndex]; - - // Insert the last pair into the hash table - m_next[pairIndex] = m_hashTable[lastHash]; - m_hashTable[lastHash] = pairIndex; - - m_overlappingPairArray.pop_back(); - - return userData; -} -//#include - -void btHashedOverlappingPairCache::processAllOverlappingPairs(btOverlapCallback* callback,btDispatcher* dispatcher) -{ - - int i; - -// printf("m_overlappingPairArray.size()=%d\n",m_overlappingPairArray.size()); - for (i=0;iprocessOverlap(*pair)) - { - removeOverlappingPair(pair->m_pProxy0,pair->m_pProxy1,dispatcher); - - gOverlappingPairs--; - } else - { - i++; - } - } -} - -void btHashedOverlappingPairCache::sortOverlappingPairs(btDispatcher* dispatcher) -{ - ///need to keep hashmap in sync with pair address, so rebuild all - btBroadphasePairArray tmpPairs; - int i; - for (i=0;iremoveOverlappingPair(proxy0, proxy1,dispatcher); - - m_overlappingPairArray.swap(findIndex,m_overlappingPairArray.capacity()-1); - m_overlappingPairArray.pop_back(); - return userData; - } - } - - return 0; -} - - - - - - - - -btBroadphasePair* btSortedOverlappingPairCache::addOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) -{ - //don't add overlap with own - btAssert(proxy0 != proxy1); - - if (!needsBroadphaseCollision(proxy0,proxy1)) - return 0; - - void* mem = &m_overlappingPairArray.expand(); - btBroadphasePair* pair = new (mem) btBroadphasePair(*proxy0,*proxy1); - - gOverlappingPairs++; - gAddedPairs++; - - if (m_ghostPairCallback) - m_ghostPairCallback->addOverlappingPair(proxy0, proxy1); - return pair; - -} - -///this findPair becomes really slow. Either sort the list to speedup the query, or -///use a different solution. It is mainly used for Removing overlapping pairs. Removal could be delayed. -///we could keep a linked list in each proxy, and store pair in one of the proxies (with lowest memory address) -///Also we can use a 2D bitmap, which can be useful for a future GPU implementation - btBroadphasePair* btSortedOverlappingPairCache::findPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) -{ - if (!needsBroadphaseCollision(proxy0,proxy1)) - return 0; - - btBroadphasePair tmpPair(*proxy0,*proxy1); - int findIndex = m_overlappingPairArray.findLinearSearch(tmpPair); - - if (findIndex < m_overlappingPairArray.size()) - { - //btAssert(it != m_overlappingPairSet.end()); - btBroadphasePair* pair = &m_overlappingPairArray[findIndex]; - return pair; - } - return 0; -} - - - - - - - - - - -//#include - -void btSortedOverlappingPairCache::processAllOverlappingPairs(btOverlapCallback* callback,btDispatcher* dispatcher) -{ - - int i; - - for (i=0;iprocessOverlap(*pair)) - { - cleanOverlappingPair(*pair,dispatcher); - pair->m_pProxy0 = 0; - pair->m_pProxy1 = 0; - m_overlappingPairArray.swap(i,m_overlappingPairArray.size()-1); - m_overlappingPairArray.pop_back(); - gOverlappingPairs--; - } else - { - i++; - } - } -} - - - - -btSortedOverlappingPairCache::btSortedOverlappingPairCache(): - m_blockedForChanges(false), - m_hasDeferredRemoval(true), - m_overlapFilterCallback(0), - m_ghostPairCallback(0) -{ - int initialAllocatedSize= 2; - m_overlappingPairArray.reserve(initialAllocatedSize); -} - -btSortedOverlappingPairCache::~btSortedOverlappingPairCache() -{ -} - -void btSortedOverlappingPairCache::cleanOverlappingPair(btBroadphasePair& pair,btDispatcher* dispatcher) -{ - if (pair.m_algorithm) - { - { - pair.m_algorithm->~btCollisionAlgorithm(); - dispatcher->freeCollisionAlgorithm(pair.m_algorithm); - pair.m_algorithm=0; - gRemovePairs--; - } - } -} - - -void btSortedOverlappingPairCache::cleanProxyFromPairs(btBroadphaseProxy* proxy,btDispatcher* dispatcher) -{ - - class CleanPairCallback : public btOverlapCallback - { - btBroadphaseProxy* m_cleanProxy; - btOverlappingPairCache* m_pairCache; - btDispatcher* m_dispatcher; - - public: - CleanPairCallback(btBroadphaseProxy* cleanProxy,btOverlappingPairCache* pairCache,btDispatcher* dispatcher) - :m_cleanProxy(cleanProxy), - m_pairCache(pairCache), - m_dispatcher(dispatcher) - { - } - virtual bool processOverlap(btBroadphasePair& pair) - { - if ((pair.m_pProxy0 == m_cleanProxy) || - (pair.m_pProxy1 == m_cleanProxy)) - { - m_pairCache->cleanOverlappingPair(pair,m_dispatcher); - } - return false; - } - - }; - - CleanPairCallback cleanPairs(proxy,this,dispatcher); - - processAllOverlappingPairs(&cleanPairs,dispatcher); - -} - - -void btSortedOverlappingPairCache::removeOverlappingPairsContainingProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher) -{ - - class RemovePairCallback : public btOverlapCallback - { - btBroadphaseProxy* m_obsoleteProxy; - - public: - RemovePairCallback(btBroadphaseProxy* obsoleteProxy) - :m_obsoleteProxy(obsoleteProxy) - { - } - virtual bool processOverlap(btBroadphasePair& pair) - { - return ((pair.m_pProxy0 == m_obsoleteProxy) || - (pair.m_pProxy1 == m_obsoleteProxy)); - } - - }; - - RemovePairCallback removeCallback(proxy); - - processAllOverlappingPairs(&removeCallback,dispatcher); -} - -void btSortedOverlappingPairCache::sortOverlappingPairs(btDispatcher* dispatcher) -{ - //should already be sorted -} - diff --git a/bullet/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.h b/bullet/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.h deleted file mode 100644 index 7bed273b2..000000000 --- a/bullet/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.h +++ /dev/null @@ -1,468 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef OVERLAPPING_PAIR_CACHE_H -#define OVERLAPPING_PAIR_CACHE_H - - -#include "btBroadphaseInterface.h" -#include "btBroadphaseProxy.h" -#include "btOverlappingPairCallback.h" - -#include "LinearMath/btAlignedObjectArray.h" -class btDispatcher; - -typedef btAlignedObjectArray btBroadphasePairArray; - -struct btOverlapCallback -{ - virtual ~btOverlapCallback() - {} - //return true for deletion of the pair - virtual bool processOverlap(btBroadphasePair& pair) = 0; - -}; - -struct btOverlapFilterCallback -{ - virtual ~btOverlapFilterCallback() - {} - // return true when pairs need collision - virtual bool needBroadphaseCollision(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) const = 0; -}; - - - - - - - -extern int gRemovePairs; -extern int gAddedPairs; -extern int gFindPairs; - -const int BT_NULL_PAIR=0xffffffff; - -///The btOverlappingPairCache provides an interface for overlapping pair management (add, remove, storage), used by the btBroadphaseInterface broadphases. -///The btHashedOverlappingPairCache and btSortedOverlappingPairCache classes are two implementations. -class btOverlappingPairCache : public btOverlappingPairCallback -{ -public: - virtual ~btOverlappingPairCache() {} // this is needed so we can get to the derived class destructor - - virtual btBroadphasePair* getOverlappingPairArrayPtr() = 0; - - virtual const btBroadphasePair* getOverlappingPairArrayPtr() const = 0; - - virtual btBroadphasePairArray& getOverlappingPairArray() = 0; - - virtual void cleanOverlappingPair(btBroadphasePair& pair,btDispatcher* dispatcher) = 0; - - virtual int getNumOverlappingPairs() const = 0; - - virtual void cleanProxyFromPairs(btBroadphaseProxy* proxy,btDispatcher* dispatcher) = 0; - - virtual void setOverlapFilterCallback(btOverlapFilterCallback* callback) = 0; - - virtual void processAllOverlappingPairs(btOverlapCallback*,btDispatcher* dispatcher) = 0; - - virtual btBroadphasePair* findPair(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1) = 0; - - virtual bool hasDeferredRemoval() = 0; - - virtual void setInternalGhostPairCallback(btOverlappingPairCallback* ghostPairCallback)=0; - - virtual void sortOverlappingPairs(btDispatcher* dispatcher) = 0; - - -}; - -/// Hash-space based Pair Cache, thanks to Erin Catto, Box2D, http://www.box2d.org, and Pierre Terdiman, Codercorner, http://codercorner.com -class btHashedOverlappingPairCache : public btOverlappingPairCache -{ - btBroadphasePairArray m_overlappingPairArray; - btOverlapFilterCallback* m_overlapFilterCallback; - bool m_blockedForChanges; - - -public: - btHashedOverlappingPairCache(); - virtual ~btHashedOverlappingPairCache(); - - - void removeOverlappingPairsContainingProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher); - - virtual void* removeOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,btDispatcher* dispatcher); - - SIMD_FORCE_INLINE bool needsBroadphaseCollision(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) const - { - if (m_overlapFilterCallback) - return m_overlapFilterCallback->needBroadphaseCollision(proxy0,proxy1); - - bool collides = (proxy0->m_collisionFilterGroup & proxy1->m_collisionFilterMask) != 0; - collides = collides && (proxy1->m_collisionFilterGroup & proxy0->m_collisionFilterMask); - - return collides; - } - - // Add a pair and return the new pair. If the pair already exists, - // no new pair is created and the old one is returned. - virtual btBroadphasePair* addOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) - { - gAddedPairs++; - - if (!needsBroadphaseCollision(proxy0,proxy1)) - return 0; - - return internalAddPair(proxy0,proxy1); - } - - - - void cleanProxyFromPairs(btBroadphaseProxy* proxy,btDispatcher* dispatcher); - - - virtual void processAllOverlappingPairs(btOverlapCallback*,btDispatcher* dispatcher); - - virtual btBroadphasePair* getOverlappingPairArrayPtr() - { - return &m_overlappingPairArray[0]; - } - - const btBroadphasePair* getOverlappingPairArrayPtr() const - { - return &m_overlappingPairArray[0]; - } - - btBroadphasePairArray& getOverlappingPairArray() - { - return m_overlappingPairArray; - } - - const btBroadphasePairArray& getOverlappingPairArray() const - { - return m_overlappingPairArray; - } - - void cleanOverlappingPair(btBroadphasePair& pair,btDispatcher* dispatcher); - - - - btBroadphasePair* findPair(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1); - - int GetCount() const { return m_overlappingPairArray.size(); } -// btBroadphasePair* GetPairs() { return m_pairs; } - - btOverlapFilterCallback* getOverlapFilterCallback() - { - return m_overlapFilterCallback; - } - - void setOverlapFilterCallback(btOverlapFilterCallback* callback) - { - m_overlapFilterCallback = callback; - } - - int getNumOverlappingPairs() const - { - return m_overlappingPairArray.size(); - } -private: - - btBroadphasePair* internalAddPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1); - - void growTables(); - - SIMD_FORCE_INLINE bool equalsPair(const btBroadphasePair& pair, int proxyId1, int proxyId2) - { - return pair.m_pProxy0->getUid() == proxyId1 && pair.m_pProxy1->getUid() == proxyId2; - } - - /* - // Thomas Wang's hash, see: http://www.concentric.net/~Ttwang/tech/inthash.htm - // This assumes proxyId1 and proxyId2 are 16-bit. - SIMD_FORCE_INLINE int getHash(int proxyId1, int proxyId2) - { - int key = (proxyId2 << 16) | proxyId1; - key = ~key + (key << 15); - key = key ^ (key >> 12); - key = key + (key << 2); - key = key ^ (key >> 4); - key = key * 2057; - key = key ^ (key >> 16); - return key; - } - */ - - - - SIMD_FORCE_INLINE unsigned int getHash(unsigned int proxyId1, unsigned int proxyId2) - { - int key = static_cast(((unsigned int)proxyId1) | (((unsigned int)proxyId2) <<16)); - // Thomas Wang's hash - - key += ~(key << 15); - key ^= (key >> 10); - key += (key << 3); - key ^= (key >> 6); - key += ~(key << 11); - key ^= (key >> 16); - return static_cast(key); - } - - - - - - SIMD_FORCE_INLINE btBroadphasePair* internalFindPair(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1, int hash) - { - int proxyId1 = proxy0->getUid(); - int proxyId2 = proxy1->getUid(); - #if 0 // wrong, 'equalsPair' use unsorted uids, copy-past devil striked again. Nat. - if (proxyId1 > proxyId2) - btSwap(proxyId1, proxyId2); - #endif - - int index = m_hashTable[hash]; - - while( index != BT_NULL_PAIR && equalsPair(m_overlappingPairArray[index], proxyId1, proxyId2) == false) - { - index = m_next[index]; - } - - if ( index == BT_NULL_PAIR ) - { - return NULL; - } - - btAssert(index < m_overlappingPairArray.size()); - - return &m_overlappingPairArray[index]; - } - - virtual bool hasDeferredRemoval() - { - return false; - } - - virtual void setInternalGhostPairCallback(btOverlappingPairCallback* ghostPairCallback) - { - m_ghostPairCallback = ghostPairCallback; - } - - virtual void sortOverlappingPairs(btDispatcher* dispatcher); - - -protected: - - btAlignedObjectArray m_hashTable; - btAlignedObjectArray m_next; - btOverlappingPairCallback* m_ghostPairCallback; - -}; - - - - -///btSortedOverlappingPairCache maintains the objects with overlapping AABB -///Typically managed by the Broadphase, Axis3Sweep or btSimpleBroadphase -class btSortedOverlappingPairCache : public btOverlappingPairCache -{ - protected: - //avoid brute-force finding all the time - btBroadphasePairArray m_overlappingPairArray; - - //during the dispatch, check that user doesn't destroy/create proxy - bool m_blockedForChanges; - - ///by default, do the removal during the pair traversal - bool m_hasDeferredRemoval; - - //if set, use the callback instead of the built in filter in needBroadphaseCollision - btOverlapFilterCallback* m_overlapFilterCallback; - - btOverlappingPairCallback* m_ghostPairCallback; - - public: - - btSortedOverlappingPairCache(); - virtual ~btSortedOverlappingPairCache(); - - virtual void processAllOverlappingPairs(btOverlapCallback*,btDispatcher* dispatcher); - - void* removeOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,btDispatcher* dispatcher); - - void cleanOverlappingPair(btBroadphasePair& pair,btDispatcher* dispatcher); - - btBroadphasePair* addOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1); - - btBroadphasePair* findPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1); - - - void cleanProxyFromPairs(btBroadphaseProxy* proxy,btDispatcher* dispatcher); - - void removeOverlappingPairsContainingProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher); - - - inline bool needsBroadphaseCollision(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) const - { - if (m_overlapFilterCallback) - return m_overlapFilterCallback->needBroadphaseCollision(proxy0,proxy1); - - bool collides = (proxy0->m_collisionFilterGroup & proxy1->m_collisionFilterMask) != 0; - collides = collides && (proxy1->m_collisionFilterGroup & proxy0->m_collisionFilterMask); - - return collides; - } - - btBroadphasePairArray& getOverlappingPairArray() - { - return m_overlappingPairArray; - } - - const btBroadphasePairArray& getOverlappingPairArray() const - { - return m_overlappingPairArray; - } - - - - - btBroadphasePair* getOverlappingPairArrayPtr() - { - return &m_overlappingPairArray[0]; - } - - const btBroadphasePair* getOverlappingPairArrayPtr() const - { - return &m_overlappingPairArray[0]; - } - - int getNumOverlappingPairs() const - { - return m_overlappingPairArray.size(); - } - - btOverlapFilterCallback* getOverlapFilterCallback() - { - return m_overlapFilterCallback; - } - - void setOverlapFilterCallback(btOverlapFilterCallback* callback) - { - m_overlapFilterCallback = callback; - } - - virtual bool hasDeferredRemoval() - { - return m_hasDeferredRemoval; - } - - virtual void setInternalGhostPairCallback(btOverlappingPairCallback* ghostPairCallback) - { - m_ghostPairCallback = ghostPairCallback; - } - - virtual void sortOverlappingPairs(btDispatcher* dispatcher); - - -}; - - - -///btNullPairCache skips add/removal of overlapping pairs. Userful for benchmarking and unit testing. -class btNullPairCache : public btOverlappingPairCache -{ - - btBroadphasePairArray m_overlappingPairArray; - -public: - - virtual btBroadphasePair* getOverlappingPairArrayPtr() - { - return &m_overlappingPairArray[0]; - } - const btBroadphasePair* getOverlappingPairArrayPtr() const - { - return &m_overlappingPairArray[0]; - } - btBroadphasePairArray& getOverlappingPairArray() - { - return m_overlappingPairArray; - } - - virtual void cleanOverlappingPair(btBroadphasePair& /*pair*/,btDispatcher* /*dispatcher*/) - { - - } - - virtual int getNumOverlappingPairs() const - { - return 0; - } - - virtual void cleanProxyFromPairs(btBroadphaseProxy* /*proxy*/,btDispatcher* /*dispatcher*/) - { - - } - - virtual void setOverlapFilterCallback(btOverlapFilterCallback* /*callback*/) - { - } - - virtual void processAllOverlappingPairs(btOverlapCallback*,btDispatcher* /*dispatcher*/) - { - } - - virtual btBroadphasePair* findPair(btBroadphaseProxy* /*proxy0*/, btBroadphaseProxy* /*proxy1*/) - { - return 0; - } - - virtual bool hasDeferredRemoval() - { - return true; - } - - virtual void setInternalGhostPairCallback(btOverlappingPairCallback* /* ghostPairCallback */) - { - - } - - virtual btBroadphasePair* addOverlappingPair(btBroadphaseProxy* /*proxy0*/,btBroadphaseProxy* /*proxy1*/) - { - return 0; - } - - virtual void* removeOverlappingPair(btBroadphaseProxy* /*proxy0*/,btBroadphaseProxy* /*proxy1*/,btDispatcher* /*dispatcher*/) - { - return 0; - } - - virtual void removeOverlappingPairsContainingProxy(btBroadphaseProxy* /*proxy0*/,btDispatcher* /*dispatcher*/) - { - } - - virtual void sortOverlappingPairs(btDispatcher* dispatcher) - { - } - - -}; - - -#endif //OVERLAPPING_PAIR_CACHE_H - - diff --git a/bullet/src/BulletCollision/BroadphaseCollision/btOverlappingPairCallback.h b/bullet/src/BulletCollision/BroadphaseCollision/btOverlappingPairCallback.h deleted file mode 100644 index ca11c52d2..000000000 --- a/bullet/src/BulletCollision/BroadphaseCollision/btOverlappingPairCallback.h +++ /dev/null @@ -1,40 +0,0 @@ - -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef OVERLAPPING_PAIR_CALLBACK_H -#define OVERLAPPING_PAIR_CALLBACK_H - -class btDispatcher; -struct btBroadphasePair; - -///The btOverlappingPairCallback class is an additional optional broadphase user callback for adding/removing overlapping pairs, similar interface to btOverlappingPairCache. -class btOverlappingPairCallback -{ -public: - virtual ~btOverlappingPairCallback() - { - - } - - virtual btBroadphasePair* addOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) = 0; - - virtual void* removeOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,btDispatcher* dispatcher) = 0; - - virtual void removeOverlappingPairsContainingProxy(btBroadphaseProxy* proxy0,btDispatcher* dispatcher) = 0; - -}; - -#endif //OVERLAPPING_PAIR_CALLBACK_H diff --git a/bullet/src/BulletCollision/BroadphaseCollision/btQuantizedBvh.cpp b/bullet/src/BulletCollision/BroadphaseCollision/btQuantizedBvh.cpp deleted file mode 100644 index 856aba92d..000000000 --- a/bullet/src/BulletCollision/BroadphaseCollision/btQuantizedBvh.cpp +++ /dev/null @@ -1,1148 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btQuantizedBvh.h" - -#include "LinearMath/btAabbUtil2.h" -#include "LinearMath/btIDebugDraw.h" - -#define RAYAABB2 - -btQuantizedBvh::btQuantizedBvh() : - m_bulletVersion(BT_BULLET_VERSION), - m_useQuantization(false), - //m_traversalMode(TRAVERSAL_STACKLESS_CACHE_FRIENDLY) - m_traversalMode(TRAVERSAL_STACKLESS) - //m_traversalMode(TRAVERSAL_RECURSIVE) - ,m_subtreeHeaderCount(0) //PCK: add this line -{ - m_bvhAabbMin.setValue(-SIMD_INFINITY,-SIMD_INFINITY,-SIMD_INFINITY); - m_bvhAabbMax.setValue(SIMD_INFINITY,SIMD_INFINITY,SIMD_INFINITY); -} - - - - - -void btQuantizedBvh::buildInternal() -{ - ///assumes that caller filled in the m_quantizedLeafNodes - m_useQuantization = true; - int numLeafNodes = 0; - - if (m_useQuantization) - { - //now we have an array of leafnodes in m_leafNodes - numLeafNodes = m_quantizedLeafNodes.size(); - - m_quantizedContiguousNodes.resize(2*numLeafNodes); - - } - - m_curNodeIndex = 0; - - buildTree(0,numLeafNodes); - - ///if the entire tree is small then subtree size, we need to create a header info for the tree - if(m_useQuantization && !m_SubtreeHeaders.size()) - { - btBvhSubtreeInfo& subtree = m_SubtreeHeaders.expand(); - subtree.setAabbFromQuantizeNode(m_quantizedContiguousNodes[0]); - subtree.m_rootNodeIndex = 0; - subtree.m_subtreeSize = m_quantizedContiguousNodes[0].isLeafNode() ? 1 : m_quantizedContiguousNodes[0].getEscapeIndex(); - } - - //PCK: update the copy of the size - m_subtreeHeaderCount = m_SubtreeHeaders.size(); - - //PCK: clear m_quantizedLeafNodes and m_leafNodes, they are temporary - m_quantizedLeafNodes.clear(); - m_leafNodes.clear(); -} - - - -///just for debugging, to visualize the individual patches/subtrees -#ifdef DEBUG_PATCH_COLORS -btVector3 color[4]= -{ - btVector3(255,0,0), - btVector3(0,255,0), - btVector3(0,0,255), - btVector3(0,255,255) -}; -#endif //DEBUG_PATCH_COLORS - - - -void btQuantizedBvh::setQuantizationValues(const btVector3& bvhAabbMin,const btVector3& bvhAabbMax,btScalar quantizationMargin) -{ - //enlarge the AABB to avoid division by zero when initializing the quantization values - btVector3 clampValue(quantizationMargin,quantizationMargin,quantizationMargin); - m_bvhAabbMin = bvhAabbMin - clampValue; - m_bvhAabbMax = bvhAabbMax + clampValue; - btVector3 aabbSize = m_bvhAabbMax - m_bvhAabbMin; - m_bvhQuantization = btVector3(btScalar(65533.0),btScalar(65533.0),btScalar(65533.0)) / aabbSize; - m_useQuantization = true; -} - - - - -btQuantizedBvh::~btQuantizedBvh() -{ -} - -#ifdef DEBUG_TREE_BUILDING -int gStackDepth = 0; -int gMaxStackDepth = 0; -#endif //DEBUG_TREE_BUILDING - -void btQuantizedBvh::buildTree (int startIndex,int endIndex) -{ -#ifdef DEBUG_TREE_BUILDING - gStackDepth++; - if (gStackDepth > gMaxStackDepth) - gMaxStackDepth = gStackDepth; -#endif //DEBUG_TREE_BUILDING - - - int splitAxis, splitIndex, i; - int numIndices =endIndex-startIndex; - int curIndex = m_curNodeIndex; - - btAssert(numIndices>0); - - if (numIndices==1) - { -#ifdef DEBUG_TREE_BUILDING - gStackDepth--; -#endif //DEBUG_TREE_BUILDING - - assignInternalNodeFromLeafNode(m_curNodeIndex,startIndex); - - m_curNodeIndex++; - return; - } - //calculate Best Splitting Axis and where to split it. Sort the incoming 'leafNodes' array within range 'startIndex/endIndex'. - - splitAxis = calcSplittingAxis(startIndex,endIndex); - - splitIndex = sortAndCalcSplittingIndex(startIndex,endIndex,splitAxis); - - int internalNodeIndex = m_curNodeIndex; - - //set the min aabb to 'inf' or a max value, and set the max aabb to a -inf/minimum value. - //the aabb will be expanded during buildTree/mergeInternalNodeAabb with actual node values - setInternalNodeAabbMin(m_curNodeIndex,m_bvhAabbMax);//can't use btVector3(SIMD_INFINITY,SIMD_INFINITY,SIMD_INFINITY)) because of quantization - setInternalNodeAabbMax(m_curNodeIndex,m_bvhAabbMin);//can't use btVector3(-SIMD_INFINITY,-SIMD_INFINITY,-SIMD_INFINITY)) because of quantization - - - for (i=startIndex;im_escapeIndex; - - int leftChildNodexIndex = m_curNodeIndex; - - //build left child tree - buildTree(startIndex,splitIndex); - - int rightChildNodexIndex = m_curNodeIndex; - //build right child tree - buildTree(splitIndex,endIndex); - -#ifdef DEBUG_TREE_BUILDING - gStackDepth--; -#endif //DEBUG_TREE_BUILDING - - int escapeIndex = m_curNodeIndex - curIndex; - - if (m_useQuantization) - { - //escapeIndex is the number of nodes of this subtree - const int sizeQuantizedNode =sizeof(btQuantizedBvhNode); - const int treeSizeInBytes = escapeIndex * sizeQuantizedNode; - if (treeSizeInBytes > MAX_SUBTREE_SIZE_IN_BYTES) - { - updateSubtreeHeaders(leftChildNodexIndex,rightChildNodexIndex); - } - } else - { - - } - - setInternalNodeEscapeIndex(internalNodeIndex,escapeIndex); - -} - -void btQuantizedBvh::updateSubtreeHeaders(int leftChildNodexIndex,int rightChildNodexIndex) -{ - btAssert(m_useQuantization); - - btQuantizedBvhNode& leftChildNode = m_quantizedContiguousNodes[leftChildNodexIndex]; - int leftSubTreeSize = leftChildNode.isLeafNode() ? 1 : leftChildNode.getEscapeIndex(); - int leftSubTreeSizeInBytes = leftSubTreeSize * static_cast(sizeof(btQuantizedBvhNode)); - - btQuantizedBvhNode& rightChildNode = m_quantizedContiguousNodes[rightChildNodexIndex]; - int rightSubTreeSize = rightChildNode.isLeafNode() ? 1 : rightChildNode.getEscapeIndex(); - int rightSubTreeSizeInBytes = rightSubTreeSize * static_cast(sizeof(btQuantizedBvhNode)); - - if(leftSubTreeSizeInBytes <= MAX_SUBTREE_SIZE_IN_BYTES) - { - btBvhSubtreeInfo& subtree = m_SubtreeHeaders.expand(); - subtree.setAabbFromQuantizeNode(leftChildNode); - subtree.m_rootNodeIndex = leftChildNodexIndex; - subtree.m_subtreeSize = leftSubTreeSize; - } - - if(rightSubTreeSizeInBytes <= MAX_SUBTREE_SIZE_IN_BYTES) - { - btBvhSubtreeInfo& subtree = m_SubtreeHeaders.expand(); - subtree.setAabbFromQuantizeNode(rightChildNode); - subtree.m_rootNodeIndex = rightChildNodexIndex; - subtree.m_subtreeSize = rightSubTreeSize; - } - - //PCK: update the copy of the size - m_subtreeHeaderCount = m_SubtreeHeaders.size(); -} - - -int btQuantizedBvh::sortAndCalcSplittingIndex(int startIndex,int endIndex,int splitAxis) -{ - int i; - int splitIndex =startIndex; - int numIndices = endIndex - startIndex; - btScalar splitValue; - - btVector3 means(btScalar(0.),btScalar(0.),btScalar(0.)); - for (i=startIndex;i splitValue) - { - //swap - swapLeafNodes(i,splitIndex); - splitIndex++; - } - } - - //if the splitIndex causes unbalanced trees, fix this by using the center in between startIndex and endIndex - //otherwise the tree-building might fail due to stack-overflows in certain cases. - //unbalanced1 is unsafe: it can cause stack overflows - //bool unbalanced1 = ((splitIndex==startIndex) || (splitIndex == (endIndex-1))); - - //unbalanced2 should work too: always use center (perfect balanced trees) - //bool unbalanced2 = true; - - //this should be safe too: - int rangeBalancedIndices = numIndices/3; - bool unbalanced = ((splitIndex<=(startIndex+rangeBalancedIndices)) || (splitIndex >=(endIndex-1-rangeBalancedIndices))); - - if (unbalanced) - { - splitIndex = startIndex+ (numIndices>>1); - } - - bool unbal = (splitIndex==startIndex) || (splitIndex == (endIndex)); - (void)unbal; - btAssert(!unbal); - - return splitIndex; -} - - -int btQuantizedBvh::calcSplittingAxis(int startIndex,int endIndex) -{ - int i; - - btVector3 means(btScalar(0.),btScalar(0.),btScalar(0.)); - btVector3 variance(btScalar(0.),btScalar(0.),btScalar(0.)); - int numIndices = endIndex-startIndex; - - for (i=startIndex;im_aabbMinOrg,rootNode->m_aabbMaxOrg); - isLeafNode = rootNode->m_escapeIndex == -1; - - //PCK: unsigned instead of bool - if (isLeafNode && (aabbOverlap != 0)) - { - nodeCallback->processNode(rootNode->m_subPart,rootNode->m_triangleIndex); - } - - //PCK: unsigned instead of bool - if ((aabbOverlap != 0) || isLeafNode) - { - rootNode++; - curIndex++; - } else - { - escapeIndex = rootNode->m_escapeIndex; - rootNode += escapeIndex; - curIndex += escapeIndex; - } - } - if (maxIterations < walkIterations) - maxIterations = walkIterations; - -} - -/* -///this was the original recursive traversal, before we optimized towards stackless traversal -void btQuantizedBvh::walkTree(btOptimizedBvhNode* rootNode,btNodeOverlapCallback* nodeCallback,const btVector3& aabbMin,const btVector3& aabbMax) const -{ - bool isLeafNode, aabbOverlap = TestAabbAgainstAabb2(aabbMin,aabbMax,rootNode->m_aabbMin,rootNode->m_aabbMax); - if (aabbOverlap) - { - isLeafNode = (!rootNode->m_leftChild && !rootNode->m_rightChild); - if (isLeafNode) - { - nodeCallback->processNode(rootNode); - } else - { - walkTree(rootNode->m_leftChild,nodeCallback,aabbMin,aabbMax); - walkTree(rootNode->m_rightChild,nodeCallback,aabbMin,aabbMax); - } - } - -} -*/ - -void btQuantizedBvh::walkRecursiveQuantizedTreeAgainstQueryAabb(const btQuantizedBvhNode* currentNode,btNodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax) const -{ - btAssert(m_useQuantization); - - bool isLeafNode; - //PCK: unsigned instead of bool - unsigned aabbOverlap; - - //PCK: unsigned instead of bool - aabbOverlap = testQuantizedAabbAgainstQuantizedAabb(quantizedQueryAabbMin,quantizedQueryAabbMax,currentNode->m_quantizedAabbMin,currentNode->m_quantizedAabbMax); - isLeafNode = currentNode->isLeafNode(); - - //PCK: unsigned instead of bool - if (aabbOverlap != 0) - { - if (isLeafNode) - { - nodeCallback->processNode(currentNode->getPartId(),currentNode->getTriangleIndex()); - } else - { - //process left and right children - const btQuantizedBvhNode* leftChildNode = currentNode+1; - walkRecursiveQuantizedTreeAgainstQueryAabb(leftChildNode,nodeCallback,quantizedQueryAabbMin,quantizedQueryAabbMax); - - const btQuantizedBvhNode* rightChildNode = leftChildNode->isLeafNode() ? leftChildNode+1:leftChildNode+leftChildNode->getEscapeIndex(); - walkRecursiveQuantizedTreeAgainstQueryAabb(rightChildNode,nodeCallback,quantizedQueryAabbMin,quantizedQueryAabbMax); - } - } -} - - - -void btQuantizedBvh::walkStacklessTreeAgainstRay(btNodeOverlapCallback* nodeCallback, const btVector3& raySource, const btVector3& rayTarget, const btVector3& aabbMin, const btVector3& aabbMax, int startNodeIndex,int endNodeIndex) const -{ - btAssert(!m_useQuantization); - - const btOptimizedBvhNode* rootNode = &m_contiguousNodes[0]; - int escapeIndex, curIndex = 0; - int walkIterations = 0; - bool isLeafNode; - //PCK: unsigned instead of bool - unsigned aabbOverlap=0; - unsigned rayBoxOverlap=0; - btScalar lambda_max = 1.0; - - /* Quick pruning by quantized box */ - btVector3 rayAabbMin = raySource; - btVector3 rayAabbMax = raySource; - rayAabbMin.setMin(rayTarget); - rayAabbMax.setMax(rayTarget); - - /* Add box cast extents to bounding box */ - rayAabbMin += aabbMin; - rayAabbMax += aabbMax; - -#ifdef RAYAABB2 - btVector3 rayDir = (rayTarget-raySource); - rayDir.normalize (); - lambda_max = rayDir.dot(rayTarget-raySource); - ///what about division by zero? --> just set rayDirection[i] to 1.0 - btVector3 rayDirectionInverse; - rayDirectionInverse[0] = rayDir[0] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDir[0]; - rayDirectionInverse[1] = rayDir[1] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDir[1]; - rayDirectionInverse[2] = rayDir[2] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDir[2]; - unsigned int sign[3] = { rayDirectionInverse[0] < 0.0, rayDirectionInverse[1] < 0.0, rayDirectionInverse[2] < 0.0}; -#endif - - btVector3 bounds[2]; - - while (curIndex < m_curNodeIndex) - { - btScalar param = 1.0; - //catch bugs in tree data - btAssert (walkIterations < m_curNodeIndex); - - walkIterations++; - - bounds[0] = rootNode->m_aabbMinOrg; - bounds[1] = rootNode->m_aabbMaxOrg; - /* Add box cast extents */ - bounds[0] += aabbMin; - bounds[1] += aabbMax; - - aabbOverlap = TestAabbAgainstAabb2(rayAabbMin,rayAabbMax,rootNode->m_aabbMinOrg,rootNode->m_aabbMaxOrg); - //perhaps profile if it is worth doing the aabbOverlap test first - -#ifdef RAYAABB2 - ///careful with this check: need to check division by zero (above) and fix the unQuantize method - ///thanks Joerg/hiker for the reproduction case! - ///http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=1858 - rayBoxOverlap = aabbOverlap ? btRayAabb2 (raySource, rayDirectionInverse, sign, bounds, param, 0.0f, lambda_max) : false; - -#else - btVector3 normal; - rayBoxOverlap = btRayAabb(raySource, rayTarget,bounds[0],bounds[1],param, normal); -#endif - - isLeafNode = rootNode->m_escapeIndex == -1; - - //PCK: unsigned instead of bool - if (isLeafNode && (rayBoxOverlap != 0)) - { - nodeCallback->processNode(rootNode->m_subPart,rootNode->m_triangleIndex); - } - - //PCK: unsigned instead of bool - if ((rayBoxOverlap != 0) || isLeafNode) - { - rootNode++; - curIndex++; - } else - { - escapeIndex = rootNode->m_escapeIndex; - rootNode += escapeIndex; - curIndex += escapeIndex; - } - } - if (maxIterations < walkIterations) - maxIterations = walkIterations; - -} - - - -void btQuantizedBvh::walkStacklessQuantizedTreeAgainstRay(btNodeOverlapCallback* nodeCallback, const btVector3& raySource, const btVector3& rayTarget, const btVector3& aabbMin, const btVector3& aabbMax, int startNodeIndex,int endNodeIndex) const -{ - btAssert(m_useQuantization); - - int curIndex = startNodeIndex; - int walkIterations = 0; - int subTreeSize = endNodeIndex - startNodeIndex; - (void)subTreeSize; - - const btQuantizedBvhNode* rootNode = &m_quantizedContiguousNodes[startNodeIndex]; - int escapeIndex; - - bool isLeafNode; - //PCK: unsigned instead of bool - unsigned boxBoxOverlap = 0; - unsigned rayBoxOverlap = 0; - - btScalar lambda_max = 1.0; - -#ifdef RAYAABB2 - btVector3 rayDirection = (rayTarget-raySource); - rayDirection.normalize (); - lambda_max = rayDirection.dot(rayTarget-raySource); - ///what about division by zero? --> just set rayDirection[i] to 1.0 - rayDirection[0] = rayDirection[0] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDirection[0]; - rayDirection[1] = rayDirection[1] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDirection[1]; - rayDirection[2] = rayDirection[2] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDirection[2]; - unsigned int sign[3] = { rayDirection[0] < 0.0, rayDirection[1] < 0.0, rayDirection[2] < 0.0}; -#endif - - /* Quick pruning by quantized box */ - btVector3 rayAabbMin = raySource; - btVector3 rayAabbMax = raySource; - rayAabbMin.setMin(rayTarget); - rayAabbMax.setMax(rayTarget); - - /* Add box cast extents to bounding box */ - rayAabbMin += aabbMin; - rayAabbMax += aabbMax; - - unsigned short int quantizedQueryAabbMin[3]; - unsigned short int quantizedQueryAabbMax[3]; - quantizeWithClamp(quantizedQueryAabbMin,rayAabbMin,0); - quantizeWithClamp(quantizedQueryAabbMax,rayAabbMax,1); - - while (curIndex < endNodeIndex) - { - -//#define VISUALLY_ANALYZE_BVH 1 -#ifdef VISUALLY_ANALYZE_BVH - //some code snippet to debugDraw aabb, to visually analyze bvh structure - static int drawPatch = 0; - //need some global access to a debugDrawer - extern btIDebugDraw* debugDrawerPtr; - if (curIndex==drawPatch) - { - btVector3 aabbMin,aabbMax; - aabbMin = unQuantize(rootNode->m_quantizedAabbMin); - aabbMax = unQuantize(rootNode->m_quantizedAabbMax); - btVector3 color(1,0,0); - debugDrawerPtr->drawAabb(aabbMin,aabbMax,color); - } -#endif//VISUALLY_ANALYZE_BVH - - //catch bugs in tree data - btAssert (walkIterations < subTreeSize); - - walkIterations++; - //PCK: unsigned instead of bool - // only interested if this is closer than any previous hit - btScalar param = 1.0; - rayBoxOverlap = 0; - boxBoxOverlap = testQuantizedAabbAgainstQuantizedAabb(quantizedQueryAabbMin,quantizedQueryAabbMax,rootNode->m_quantizedAabbMin,rootNode->m_quantizedAabbMax); - isLeafNode = rootNode->isLeafNode(); - if (boxBoxOverlap) - { - btVector3 bounds[2]; - bounds[0] = unQuantize(rootNode->m_quantizedAabbMin); - bounds[1] = unQuantize(rootNode->m_quantizedAabbMax); - /* Add box cast extents */ - bounds[0] += aabbMin; - bounds[1] += aabbMax; - btVector3 normal; -#if 0 - bool ra2 = btRayAabb2 (raySource, rayDirection, sign, bounds, param, 0.0, lambda_max); - bool ra = btRayAabb (raySource, rayTarget, bounds[0], bounds[1], param, normal); - if (ra2 != ra) - { - printf("functions don't match\n"); - } -#endif -#ifdef RAYAABB2 - ///careful with this check: need to check division by zero (above) and fix the unQuantize method - ///thanks Joerg/hiker for the reproduction case! - ///http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=1858 - - //BT_PROFILE("btRayAabb2"); - rayBoxOverlap = btRayAabb2 (raySource, rayDirection, sign, bounds, param, 0.0f, lambda_max); - -#else - rayBoxOverlap = true;//btRayAabb(raySource, rayTarget, bounds[0], bounds[1], param, normal); -#endif - } - - if (isLeafNode && rayBoxOverlap) - { - nodeCallback->processNode(rootNode->getPartId(),rootNode->getTriangleIndex()); - } - - //PCK: unsigned instead of bool - if ((rayBoxOverlap != 0) || isLeafNode) - { - rootNode++; - curIndex++; - } else - { - escapeIndex = rootNode->getEscapeIndex(); - rootNode += escapeIndex; - curIndex += escapeIndex; - } - } - if (maxIterations < walkIterations) - maxIterations = walkIterations; - -} - -void btQuantizedBvh::walkStacklessQuantizedTree(btNodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax,int startNodeIndex,int endNodeIndex) const -{ - btAssert(m_useQuantization); - - int curIndex = startNodeIndex; - int walkIterations = 0; - int subTreeSize = endNodeIndex - startNodeIndex; - (void)subTreeSize; - - const btQuantizedBvhNode* rootNode = &m_quantizedContiguousNodes[startNodeIndex]; - int escapeIndex; - - bool isLeafNode; - //PCK: unsigned instead of bool - unsigned aabbOverlap; - - while (curIndex < endNodeIndex) - { - -//#define VISUALLY_ANALYZE_BVH 1 -#ifdef VISUALLY_ANALYZE_BVH - //some code snippet to debugDraw aabb, to visually analyze bvh structure - static int drawPatch = 0; - //need some global access to a debugDrawer - extern btIDebugDraw* debugDrawerPtr; - if (curIndex==drawPatch) - { - btVector3 aabbMin,aabbMax; - aabbMin = unQuantize(rootNode->m_quantizedAabbMin); - aabbMax = unQuantize(rootNode->m_quantizedAabbMax); - btVector3 color(1,0,0); - debugDrawerPtr->drawAabb(aabbMin,aabbMax,color); - } -#endif//VISUALLY_ANALYZE_BVH - - //catch bugs in tree data - btAssert (walkIterations < subTreeSize); - - walkIterations++; - //PCK: unsigned instead of bool - aabbOverlap = testQuantizedAabbAgainstQuantizedAabb(quantizedQueryAabbMin,quantizedQueryAabbMax,rootNode->m_quantizedAabbMin,rootNode->m_quantizedAabbMax); - isLeafNode = rootNode->isLeafNode(); - - if (isLeafNode && aabbOverlap) - { - nodeCallback->processNode(rootNode->getPartId(),rootNode->getTriangleIndex()); - } - - //PCK: unsigned instead of bool - if ((aabbOverlap != 0) || isLeafNode) - { - rootNode++; - curIndex++; - } else - { - escapeIndex = rootNode->getEscapeIndex(); - rootNode += escapeIndex; - curIndex += escapeIndex; - } - } - if (maxIterations < walkIterations) - maxIterations = walkIterations; - -} - -//This traversal can be called from Playstation 3 SPU -void btQuantizedBvh::walkStacklessQuantizedTreeCacheFriendly(btNodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax) const -{ - btAssert(m_useQuantization); - - int i; - - - for (i=0;im_SubtreeHeaders.size();i++) - { - const btBvhSubtreeInfo& subtree = m_SubtreeHeaders[i]; - - //PCK: unsigned instead of bool - unsigned overlap = testQuantizedAabbAgainstQuantizedAabb(quantizedQueryAabbMin,quantizedQueryAabbMax,subtree.m_quantizedAabbMin,subtree.m_quantizedAabbMax); - if (overlap != 0) - { - walkStacklessQuantizedTree(nodeCallback,quantizedQueryAabbMin,quantizedQueryAabbMax, - subtree.m_rootNodeIndex, - subtree.m_rootNodeIndex+subtree.m_subtreeSize); - } - } -} - - -void btQuantizedBvh::reportRayOverlappingNodex (btNodeOverlapCallback* nodeCallback, const btVector3& raySource, const btVector3& rayTarget) const -{ - reportBoxCastOverlappingNodex(nodeCallback,raySource,rayTarget,btVector3(0,0,0),btVector3(0,0,0)); -} - - -void btQuantizedBvh::reportBoxCastOverlappingNodex(btNodeOverlapCallback* nodeCallback, const btVector3& raySource, const btVector3& rayTarget, const btVector3& aabbMin,const btVector3& aabbMax) const -{ - //always use stackless - - if (m_useQuantization) - { - walkStacklessQuantizedTreeAgainstRay(nodeCallback, raySource, rayTarget, aabbMin, aabbMax, 0, m_curNodeIndex); - } - else - { - walkStacklessTreeAgainstRay(nodeCallback, raySource, rayTarget, aabbMin, aabbMax, 0, m_curNodeIndex); - } - /* - { - //recursive traversal - btVector3 qaabbMin = raySource; - btVector3 qaabbMax = raySource; - qaabbMin.setMin(rayTarget); - qaabbMax.setMax(rayTarget); - qaabbMin += aabbMin; - qaabbMax += aabbMax; - reportAabbOverlappingNodex(nodeCallback,qaabbMin,qaabbMax); - } - */ - -} - - -void btQuantizedBvh::swapLeafNodes(int i,int splitIndex) -{ - if (m_useQuantization) - { - btQuantizedBvhNode tmp = m_quantizedLeafNodes[i]; - m_quantizedLeafNodes[i] = m_quantizedLeafNodes[splitIndex]; - m_quantizedLeafNodes[splitIndex] = tmp; - } else - { - btOptimizedBvhNode tmp = m_leafNodes[i]; - m_leafNodes[i] = m_leafNodes[splitIndex]; - m_leafNodes[splitIndex] = tmp; - } -} - -void btQuantizedBvh::assignInternalNodeFromLeafNode(int internalNode,int leafNodeIndex) -{ - if (m_useQuantization) - { - m_quantizedContiguousNodes[internalNode] = m_quantizedLeafNodes[leafNodeIndex]; - } else - { - m_contiguousNodes[internalNode] = m_leafNodes[leafNodeIndex]; - } -} - -//PCK: include -#include - -#if 0 -//PCK: consts -static const unsigned BVH_ALIGNMENT = 16; -static const unsigned BVH_ALIGNMENT_MASK = BVH_ALIGNMENT-1; - -static const unsigned BVH_ALIGNMENT_BLOCKS = 2; -#endif - - -unsigned int btQuantizedBvh::getAlignmentSerializationPadding() -{ - // I changed this to 0 since the extra padding is not needed or used. - return 0;//BVH_ALIGNMENT_BLOCKS * BVH_ALIGNMENT; -} - -unsigned btQuantizedBvh::calculateSerializeBufferSize() const -{ - unsigned baseSize = sizeof(btQuantizedBvh) + getAlignmentSerializationPadding(); - baseSize += sizeof(btBvhSubtreeInfo) * m_subtreeHeaderCount; - if (m_useQuantization) - { - return baseSize + m_curNodeIndex * sizeof(btQuantizedBvhNode); - } - return baseSize + m_curNodeIndex * sizeof(btOptimizedBvhNode); -} - -bool btQuantizedBvh::serialize(void *o_alignedDataBuffer, unsigned /*i_dataBufferSize */, bool i_swapEndian) const -{ - btAssert(m_subtreeHeaderCount == m_SubtreeHeaders.size()); - m_subtreeHeaderCount = m_SubtreeHeaders.size(); - -/* if (i_dataBufferSize < calculateSerializeBufferSize() || o_alignedDataBuffer == NULL || (((unsigned)o_alignedDataBuffer & BVH_ALIGNMENT_MASK) != 0)) - { - ///check alignedment for buffer? - btAssert(0); - return false; - } -*/ - - btQuantizedBvh *targetBvh = (btQuantizedBvh *)o_alignedDataBuffer; - - // construct the class so the virtual function table, etc will be set up - // Also, m_leafNodes and m_quantizedLeafNodes will be initialized to default values by the constructor - new (targetBvh) btQuantizedBvh; - - if (i_swapEndian) - { - targetBvh->m_curNodeIndex = static_cast(btSwapEndian(m_curNodeIndex)); - - - btSwapVector3Endian(m_bvhAabbMin,targetBvh->m_bvhAabbMin); - btSwapVector3Endian(m_bvhAabbMax,targetBvh->m_bvhAabbMax); - btSwapVector3Endian(m_bvhQuantization,targetBvh->m_bvhQuantization); - - targetBvh->m_traversalMode = (btTraversalMode)btSwapEndian(m_traversalMode); - targetBvh->m_subtreeHeaderCount = static_cast(btSwapEndian(m_subtreeHeaderCount)); - } - else - { - targetBvh->m_curNodeIndex = m_curNodeIndex; - targetBvh->m_bvhAabbMin = m_bvhAabbMin; - targetBvh->m_bvhAabbMax = m_bvhAabbMax; - targetBvh->m_bvhQuantization = m_bvhQuantization; - targetBvh->m_traversalMode = m_traversalMode; - targetBvh->m_subtreeHeaderCount = m_subtreeHeaderCount; - } - - targetBvh->m_useQuantization = m_useQuantization; - - unsigned char *nodeData = (unsigned char *)targetBvh; - nodeData += sizeof(btQuantizedBvh); - - unsigned sizeToAdd = 0;//(BVH_ALIGNMENT-((unsigned)nodeData & BVH_ALIGNMENT_MASK))&BVH_ALIGNMENT_MASK; - nodeData += sizeToAdd; - - int nodeCount = m_curNodeIndex; - - if (m_useQuantization) - { - targetBvh->m_quantizedContiguousNodes.initializeFromBuffer(nodeData, nodeCount, nodeCount); - - if (i_swapEndian) - { - for (int nodeIndex = 0; nodeIndex < nodeCount; nodeIndex++) - { - targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[0] = btSwapEndian(m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[0]); - targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[1] = btSwapEndian(m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[1]); - targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[2] = btSwapEndian(m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[2]); - - targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[0] = btSwapEndian(m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[0]); - targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[1] = btSwapEndian(m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[1]); - targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[2] = btSwapEndian(m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[2]); - - targetBvh->m_quantizedContiguousNodes[nodeIndex].m_escapeIndexOrTriangleIndex = static_cast(btSwapEndian(m_quantizedContiguousNodes[nodeIndex].m_escapeIndexOrTriangleIndex)); - } - } - else - { - for (int nodeIndex = 0; nodeIndex < nodeCount; nodeIndex++) - { - - targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[0] = m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[0]; - targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[1] = m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[1]; - targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[2] = m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[2]; - - targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[0] = m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[0]; - targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[1] = m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[1]; - targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[2] = m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[2]; - - targetBvh->m_quantizedContiguousNodes[nodeIndex].m_escapeIndexOrTriangleIndex = m_quantizedContiguousNodes[nodeIndex].m_escapeIndexOrTriangleIndex; - - - } - } - nodeData += sizeof(btQuantizedBvhNode) * nodeCount; - - // this clears the pointer in the member variable it doesn't really do anything to the data - // it does call the destructor on the contained objects, but they are all classes with no destructor defined - // so the memory (which is not freed) is left alone - targetBvh->m_quantizedContiguousNodes.initializeFromBuffer(NULL, 0, 0); - } - else - { - targetBvh->m_contiguousNodes.initializeFromBuffer(nodeData, nodeCount, nodeCount); - - if (i_swapEndian) - { - for (int nodeIndex = 0; nodeIndex < nodeCount; nodeIndex++) - { - btSwapVector3Endian(m_contiguousNodes[nodeIndex].m_aabbMinOrg, targetBvh->m_contiguousNodes[nodeIndex].m_aabbMinOrg); - btSwapVector3Endian(m_contiguousNodes[nodeIndex].m_aabbMaxOrg, targetBvh->m_contiguousNodes[nodeIndex].m_aabbMaxOrg); - - targetBvh->m_contiguousNodes[nodeIndex].m_escapeIndex = static_cast(btSwapEndian(m_contiguousNodes[nodeIndex].m_escapeIndex)); - targetBvh->m_contiguousNodes[nodeIndex].m_subPart = static_cast(btSwapEndian(m_contiguousNodes[nodeIndex].m_subPart)); - targetBvh->m_contiguousNodes[nodeIndex].m_triangleIndex = static_cast(btSwapEndian(m_contiguousNodes[nodeIndex].m_triangleIndex)); - } - } - else - { - for (int nodeIndex = 0; nodeIndex < nodeCount; nodeIndex++) - { - targetBvh->m_contiguousNodes[nodeIndex].m_aabbMinOrg = m_contiguousNodes[nodeIndex].m_aabbMinOrg; - targetBvh->m_contiguousNodes[nodeIndex].m_aabbMaxOrg = m_contiguousNodes[nodeIndex].m_aabbMaxOrg; - - targetBvh->m_contiguousNodes[nodeIndex].m_escapeIndex = m_contiguousNodes[nodeIndex].m_escapeIndex; - targetBvh->m_contiguousNodes[nodeIndex].m_subPart = m_contiguousNodes[nodeIndex].m_subPart; - targetBvh->m_contiguousNodes[nodeIndex].m_triangleIndex = m_contiguousNodes[nodeIndex].m_triangleIndex; - } - } - nodeData += sizeof(btOptimizedBvhNode) * nodeCount; - - // this clears the pointer in the member variable it doesn't really do anything to the data - // it does call the destructor on the contained objects, but they are all classes with no destructor defined - // so the memory (which is not freed) is left alone - targetBvh->m_contiguousNodes.initializeFromBuffer(NULL, 0, 0); - } - - sizeToAdd = 0;//(BVH_ALIGNMENT-((unsigned)nodeData & BVH_ALIGNMENT_MASK))&BVH_ALIGNMENT_MASK; - nodeData += sizeToAdd; - - // Now serialize the subtree headers - targetBvh->m_SubtreeHeaders.initializeFromBuffer(nodeData, m_subtreeHeaderCount, m_subtreeHeaderCount); - if (i_swapEndian) - { - for (int i = 0; i < m_subtreeHeaderCount; i++) - { - targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMin[0] = btSwapEndian(m_SubtreeHeaders[i].m_quantizedAabbMin[0]); - targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMin[1] = btSwapEndian(m_SubtreeHeaders[i].m_quantizedAabbMin[1]); - targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMin[2] = btSwapEndian(m_SubtreeHeaders[i].m_quantizedAabbMin[2]); - - targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMax[0] = btSwapEndian(m_SubtreeHeaders[i].m_quantizedAabbMax[0]); - targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMax[1] = btSwapEndian(m_SubtreeHeaders[i].m_quantizedAabbMax[1]); - targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMax[2] = btSwapEndian(m_SubtreeHeaders[i].m_quantizedAabbMax[2]); - - targetBvh->m_SubtreeHeaders[i].m_rootNodeIndex = static_cast(btSwapEndian(m_SubtreeHeaders[i].m_rootNodeIndex)); - targetBvh->m_SubtreeHeaders[i].m_subtreeSize = static_cast(btSwapEndian(m_SubtreeHeaders[i].m_subtreeSize)); - } - } - else - { - for (int i = 0; i < m_subtreeHeaderCount; i++) - { - targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMin[0] = (m_SubtreeHeaders[i].m_quantizedAabbMin[0]); - targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMin[1] = (m_SubtreeHeaders[i].m_quantizedAabbMin[1]); - targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMin[2] = (m_SubtreeHeaders[i].m_quantizedAabbMin[2]); - - targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMax[0] = (m_SubtreeHeaders[i].m_quantizedAabbMax[0]); - targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMax[1] = (m_SubtreeHeaders[i].m_quantizedAabbMax[1]); - targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMax[2] = (m_SubtreeHeaders[i].m_quantizedAabbMax[2]); - - targetBvh->m_SubtreeHeaders[i].m_rootNodeIndex = (m_SubtreeHeaders[i].m_rootNodeIndex); - targetBvh->m_SubtreeHeaders[i].m_subtreeSize = (m_SubtreeHeaders[i].m_subtreeSize); - - // need to clear padding in destination buffer - targetBvh->m_SubtreeHeaders[i].m_padding[0] = 0; - targetBvh->m_SubtreeHeaders[i].m_padding[1] = 0; - targetBvh->m_SubtreeHeaders[i].m_padding[2] = 0; - } - } - nodeData += sizeof(btBvhSubtreeInfo) * m_subtreeHeaderCount; - - // this clears the pointer in the member variable it doesn't really do anything to the data - // it does call the destructor on the contained objects, but they are all classes with no destructor defined - // so the memory (which is not freed) is left alone - targetBvh->m_SubtreeHeaders.initializeFromBuffer(NULL, 0, 0); - - // this wipes the virtual function table pointer at the start of the buffer for the class - *((void**)o_alignedDataBuffer) = NULL; - - return true; -} - -btQuantizedBvh *btQuantizedBvh::deSerializeInPlace(void *i_alignedDataBuffer, unsigned int i_dataBufferSize, bool i_swapEndian) -{ - - if (i_alignedDataBuffer == NULL)// || (((unsigned)i_alignedDataBuffer & BVH_ALIGNMENT_MASK) != 0)) - { - return NULL; - } - btQuantizedBvh *bvh = (btQuantizedBvh *)i_alignedDataBuffer; - - if (i_swapEndian) - { - bvh->m_curNodeIndex = static_cast(btSwapEndian(bvh->m_curNodeIndex)); - - btUnSwapVector3Endian(bvh->m_bvhAabbMin); - btUnSwapVector3Endian(bvh->m_bvhAabbMax); - btUnSwapVector3Endian(bvh->m_bvhQuantization); - - bvh->m_traversalMode = (btTraversalMode)btSwapEndian(bvh->m_traversalMode); - bvh->m_subtreeHeaderCount = static_cast(btSwapEndian(bvh->m_subtreeHeaderCount)); - } - - unsigned int calculatedBufSize = bvh->calculateSerializeBufferSize(); - btAssert(calculatedBufSize <= i_dataBufferSize); - - if (calculatedBufSize > i_dataBufferSize) - { - return NULL; - } - - unsigned char *nodeData = (unsigned char *)bvh; - nodeData += sizeof(btQuantizedBvh); - - unsigned sizeToAdd = 0;//(BVH_ALIGNMENT-((unsigned)nodeData & BVH_ALIGNMENT_MASK))&BVH_ALIGNMENT_MASK; - nodeData += sizeToAdd; - - int nodeCount = bvh->m_curNodeIndex; - - // Must call placement new to fill in virtual function table, etc, but we don't want to overwrite most data, so call a special version of the constructor - // Also, m_leafNodes and m_quantizedLeafNodes will be initialized to default values by the constructor - new (bvh) btQuantizedBvh(*bvh, false); - - if (bvh->m_useQuantization) - { - bvh->m_quantizedContiguousNodes.initializeFromBuffer(nodeData, nodeCount, nodeCount); - - if (i_swapEndian) - { - for (int nodeIndex = 0; nodeIndex < nodeCount; nodeIndex++) - { - bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[0] = btSwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[0]); - bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[1] = btSwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[1]); - bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[2] = btSwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[2]); - - bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[0] = btSwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[0]); - bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[1] = btSwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[1]); - bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[2] = btSwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[2]); - - bvh->m_quantizedContiguousNodes[nodeIndex].m_escapeIndexOrTriangleIndex = static_cast(btSwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_escapeIndexOrTriangleIndex)); - } - } - nodeData += sizeof(btQuantizedBvhNode) * nodeCount; - } - else - { - bvh->m_contiguousNodes.initializeFromBuffer(nodeData, nodeCount, nodeCount); - - if (i_swapEndian) - { - for (int nodeIndex = 0; nodeIndex < nodeCount; nodeIndex++) - { - btUnSwapVector3Endian(bvh->m_contiguousNodes[nodeIndex].m_aabbMinOrg); - btUnSwapVector3Endian(bvh->m_contiguousNodes[nodeIndex].m_aabbMaxOrg); - - bvh->m_contiguousNodes[nodeIndex].m_escapeIndex = static_cast(btSwapEndian(bvh->m_contiguousNodes[nodeIndex].m_escapeIndex)); - bvh->m_contiguousNodes[nodeIndex].m_subPart = static_cast(btSwapEndian(bvh->m_contiguousNodes[nodeIndex].m_subPart)); - bvh->m_contiguousNodes[nodeIndex].m_triangleIndex = static_cast(btSwapEndian(bvh->m_contiguousNodes[nodeIndex].m_triangleIndex)); - } - } - nodeData += sizeof(btOptimizedBvhNode) * nodeCount; - } - - sizeToAdd = 0;//(BVH_ALIGNMENT-((unsigned)nodeData & BVH_ALIGNMENT_MASK))&BVH_ALIGNMENT_MASK; - nodeData += sizeToAdd; - - // Now serialize the subtree headers - bvh->m_SubtreeHeaders.initializeFromBuffer(nodeData, bvh->m_subtreeHeaderCount, bvh->m_subtreeHeaderCount); - if (i_swapEndian) - { - for (int i = 0; i < bvh->m_subtreeHeaderCount; i++) - { - bvh->m_SubtreeHeaders[i].m_quantizedAabbMin[0] = btSwapEndian(bvh->m_SubtreeHeaders[i].m_quantizedAabbMin[0]); - bvh->m_SubtreeHeaders[i].m_quantizedAabbMin[1] = btSwapEndian(bvh->m_SubtreeHeaders[i].m_quantizedAabbMin[1]); - bvh->m_SubtreeHeaders[i].m_quantizedAabbMin[2] = btSwapEndian(bvh->m_SubtreeHeaders[i].m_quantizedAabbMin[2]); - - bvh->m_SubtreeHeaders[i].m_quantizedAabbMax[0] = btSwapEndian(bvh->m_SubtreeHeaders[i].m_quantizedAabbMax[0]); - bvh->m_SubtreeHeaders[i].m_quantizedAabbMax[1] = btSwapEndian(bvh->m_SubtreeHeaders[i].m_quantizedAabbMax[1]); - bvh->m_SubtreeHeaders[i].m_quantizedAabbMax[2] = btSwapEndian(bvh->m_SubtreeHeaders[i].m_quantizedAabbMax[2]); - - bvh->m_SubtreeHeaders[i].m_rootNodeIndex = static_cast(btSwapEndian(bvh->m_SubtreeHeaders[i].m_rootNodeIndex)); - bvh->m_SubtreeHeaders[i].m_subtreeSize = static_cast(btSwapEndian(bvh->m_SubtreeHeaders[i].m_subtreeSize)); - } - } - - return bvh; -} - -// Constructor that prevents btVector3's default constructor from being called -btQuantizedBvh::btQuantizedBvh(btQuantizedBvh &self, bool /* ownsMemory */) : -m_bvhAabbMin(self.m_bvhAabbMin), -m_bvhAabbMax(self.m_bvhAabbMax), -m_bvhQuantization(self.m_bvhQuantization), -m_bulletVersion(BT_BULLET_VERSION) -{ - -} - - - - diff --git a/bullet/src/BulletCollision/BroadphaseCollision/btQuantizedBvh.h b/bullet/src/BulletCollision/BroadphaseCollision/btQuantizedBvh.h deleted file mode 100644 index d045d1092..000000000 --- a/bullet/src/BulletCollision/BroadphaseCollision/btQuantizedBvh.h +++ /dev/null @@ -1,473 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef QUANTIZED_BVH_H -#define QUANTIZED_BVH_H - -//#define DEBUG_CHECK_DEQUANTIZATION 1 -#ifdef DEBUG_CHECK_DEQUANTIZATION -#ifdef __SPU__ -#define printf spu_printf -#endif //__SPU__ - -#include -#include -#endif //DEBUG_CHECK_DEQUANTIZATION - -#include "LinearMath/btVector3.h" -#include "LinearMath/btAlignedAllocator.h" - - -//http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/vclrf__m128.asp - - -//Note: currently we have 16 bytes per quantized node -#define MAX_SUBTREE_SIZE_IN_BYTES 2048 - -// 10 gives the potential for 1024 parts, with at most 2^21 (2097152) (minus one -// actually) triangles each (since the sign bit is reserved -#define MAX_NUM_PARTS_IN_BITS 10 - -///btQuantizedBvhNode is a compressed aabb node, 16 bytes. -///Node can be used for leafnode or internal node. Leafnodes can point to 32-bit triangle index (non-negative range). -ATTRIBUTE_ALIGNED16 (struct) btQuantizedBvhNode -{ - BT_DECLARE_ALIGNED_ALLOCATOR(); - - //12 bytes - unsigned short int m_quantizedAabbMin[3]; - unsigned short int m_quantizedAabbMax[3]; - //4 bytes - int m_escapeIndexOrTriangleIndex; - - bool isLeafNode() const - { - //skipindex is negative (internal node), triangleindex >=0 (leafnode) - return (m_escapeIndexOrTriangleIndex >= 0); - } - int getEscapeIndex() const - { - btAssert(!isLeafNode()); - return -m_escapeIndexOrTriangleIndex; - } - int getTriangleIndex() const - { - btAssert(isLeafNode()); - // Get only the lower bits where the triangle index is stored - return (m_escapeIndexOrTriangleIndex&~((~0)<<(31-MAX_NUM_PARTS_IN_BITS))); - } - int getPartId() const - { - btAssert(isLeafNode()); - // Get only the highest bits where the part index is stored - return (m_escapeIndexOrTriangleIndex>>(31-MAX_NUM_PARTS_IN_BITS)); - } -} -; - -/// btOptimizedBvhNode contains both internal and leaf node information. -/// Total node size is 44 bytes / node. You can use the compressed version of 16 bytes. -ATTRIBUTE_ALIGNED16 (struct) btOptimizedBvhNode -{ - BT_DECLARE_ALIGNED_ALLOCATOR(); - - //32 bytes - btVector3 m_aabbMinOrg; - btVector3 m_aabbMaxOrg; - - //4 - int m_escapeIndex; - - //8 - //for child nodes - int m_subPart; - int m_triangleIndex; - int m_padding[5];//bad, due to alignment - - -}; - - -///btBvhSubtreeInfo provides info to gather a subtree of limited size -ATTRIBUTE_ALIGNED16(class) btBvhSubtreeInfo -{ -public: - BT_DECLARE_ALIGNED_ALLOCATOR(); - - //12 bytes - unsigned short int m_quantizedAabbMin[3]; - unsigned short int m_quantizedAabbMax[3]; - //4 bytes, points to the root of the subtree - int m_rootNodeIndex; - //4 bytes - int m_subtreeSize; - int m_padding[3]; - - btBvhSubtreeInfo() - { - //memset(&m_padding[0], 0, sizeof(m_padding)); - } - - - void setAabbFromQuantizeNode(const btQuantizedBvhNode& quantizedNode) - { - m_quantizedAabbMin[0] = quantizedNode.m_quantizedAabbMin[0]; - m_quantizedAabbMin[1] = quantizedNode.m_quantizedAabbMin[1]; - m_quantizedAabbMin[2] = quantizedNode.m_quantizedAabbMin[2]; - m_quantizedAabbMax[0] = quantizedNode.m_quantizedAabbMax[0]; - m_quantizedAabbMax[1] = quantizedNode.m_quantizedAabbMax[1]; - m_quantizedAabbMax[2] = quantizedNode.m_quantizedAabbMax[2]; - } -} -; - - -class btNodeOverlapCallback -{ -public: - virtual ~btNodeOverlapCallback() {}; - - virtual void processNode(int subPart, int triangleIndex) = 0; -}; - -#include "LinearMath/btAlignedAllocator.h" -#include "LinearMath/btAlignedObjectArray.h" - - - -///for code readability: -typedef btAlignedObjectArray NodeArray; -typedef btAlignedObjectArray QuantizedNodeArray; -typedef btAlignedObjectArray BvhSubtreeInfoArray; - - -///The btQuantizedBvh class stores an AABB tree that can be quickly traversed on CPU and Cell SPU. -///It is used by the btBvhTriangleMeshShape as midphase, and by the btMultiSapBroadphase. -///It is recommended to use quantization for better performance and lower memory requirements. -ATTRIBUTE_ALIGNED16(class) btQuantizedBvh -{ -public: - enum btTraversalMode - { - TRAVERSAL_STACKLESS = 0, - TRAVERSAL_STACKLESS_CACHE_FRIENDLY, - TRAVERSAL_RECURSIVE - }; - -protected: - - - btVector3 m_bvhAabbMin; - btVector3 m_bvhAabbMax; - btVector3 m_bvhQuantization; - - int m_bulletVersion; //for serialization versioning. It could also be used to detect endianess. - - int m_curNodeIndex; - //quantization data - bool m_useQuantization; - - - - NodeArray m_leafNodes; - NodeArray m_contiguousNodes; - QuantizedNodeArray m_quantizedLeafNodes; - QuantizedNodeArray m_quantizedContiguousNodes; - - btTraversalMode m_traversalMode; - BvhSubtreeInfoArray m_SubtreeHeaders; - - //This is only used for serialization so we don't have to add serialization directly to btAlignedObjectArray - mutable int m_subtreeHeaderCount; - - - - - - ///two versions, one for quantized and normal nodes. This allows code-reuse while maintaining readability (no template/macro!) - ///this might be refactored into a virtual, it is usually not calculated at run-time - void setInternalNodeAabbMin(int nodeIndex, const btVector3& aabbMin) - { - if (m_useQuantization) - { - quantize(&m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[0] ,aabbMin,0); - } else - { - m_contiguousNodes[nodeIndex].m_aabbMinOrg = aabbMin; - - } - } - void setInternalNodeAabbMax(int nodeIndex,const btVector3& aabbMax) - { - if (m_useQuantization) - { - quantize(&m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[0],aabbMax,1); - } else - { - m_contiguousNodes[nodeIndex].m_aabbMaxOrg = aabbMax; - } - } - - btVector3 getAabbMin(int nodeIndex) const - { - if (m_useQuantization) - { - return unQuantize(&m_quantizedLeafNodes[nodeIndex].m_quantizedAabbMin[0]); - } - //non-quantized - return m_leafNodes[nodeIndex].m_aabbMinOrg; - - } - btVector3 getAabbMax(int nodeIndex) const - { - if (m_useQuantization) - { - return unQuantize(&m_quantizedLeafNodes[nodeIndex].m_quantizedAabbMax[0]); - } - //non-quantized - return m_leafNodes[nodeIndex].m_aabbMaxOrg; - - } - - - void setInternalNodeEscapeIndex(int nodeIndex, int escapeIndex) - { - if (m_useQuantization) - { - m_quantizedContiguousNodes[nodeIndex].m_escapeIndexOrTriangleIndex = -escapeIndex; - } - else - { - m_contiguousNodes[nodeIndex].m_escapeIndex = escapeIndex; - } - - } - - void mergeInternalNodeAabb(int nodeIndex,const btVector3& newAabbMin,const btVector3& newAabbMax) - { - if (m_useQuantization) - { - unsigned short int quantizedAabbMin[3]; - unsigned short int quantizedAabbMax[3]; - quantize(quantizedAabbMin,newAabbMin,0); - quantize(quantizedAabbMax,newAabbMax,1); - for (int i=0;i<3;i++) - { - if (m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[i] > quantizedAabbMin[i]) - m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[i] = quantizedAabbMin[i]; - - if (m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[i] < quantizedAabbMax[i]) - m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[i] = quantizedAabbMax[i]; - - } - } else - { - //non-quantized - m_contiguousNodes[nodeIndex].m_aabbMinOrg.setMin(newAabbMin); - m_contiguousNodes[nodeIndex].m_aabbMaxOrg.setMax(newAabbMax); - } - } - - void swapLeafNodes(int firstIndex,int secondIndex); - - void assignInternalNodeFromLeafNode(int internalNode,int leafNodeIndex); - -protected: - - - - void buildTree (int startIndex,int endIndex); - - int calcSplittingAxis(int startIndex,int endIndex); - - int sortAndCalcSplittingIndex(int startIndex,int endIndex,int splitAxis); - - void walkStacklessTree(btNodeOverlapCallback* nodeCallback,const btVector3& aabbMin,const btVector3& aabbMax) const; - - void walkStacklessQuantizedTreeAgainstRay(btNodeOverlapCallback* nodeCallback, const btVector3& raySource, const btVector3& rayTarget, const btVector3& aabbMin, const btVector3& aabbMax, int startNodeIndex,int endNodeIndex) const; - void walkStacklessQuantizedTree(btNodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax,int startNodeIndex,int endNodeIndex) const; - void walkStacklessTreeAgainstRay(btNodeOverlapCallback* nodeCallback, const btVector3& raySource, const btVector3& rayTarget, const btVector3& aabbMin, const btVector3& aabbMax, int startNodeIndex,int endNodeIndex) const; - - ///tree traversal designed for small-memory processors like PS3 SPU - void walkStacklessQuantizedTreeCacheFriendly(btNodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax) const; - - ///use the 16-byte stackless 'skipindex' node tree to do a recursive traversal - void walkRecursiveQuantizedTreeAgainstQueryAabb(const btQuantizedBvhNode* currentNode,btNodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax) const; - - ///use the 16-byte stackless 'skipindex' node tree to do a recursive traversal - void walkRecursiveQuantizedTreeAgainstQuantizedTree(const btQuantizedBvhNode* treeNodeA,const btQuantizedBvhNode* treeNodeB,btNodeOverlapCallback* nodeCallback) const; - - - - - void updateSubtreeHeaders(int leftChildNodexIndex,int rightChildNodexIndex); - -public: - - BT_DECLARE_ALIGNED_ALLOCATOR(); - - btQuantizedBvh(); - - virtual ~btQuantizedBvh(); - - - ///***************************************** expert/internal use only ************************* - void setQuantizationValues(const btVector3& bvhAabbMin,const btVector3& bvhAabbMax,btScalar quantizationMargin=btScalar(1.0)); - QuantizedNodeArray& getLeafNodeArray() { return m_quantizedLeafNodes; } - ///buildInternal is expert use only: assumes that setQuantizationValues and LeafNodeArray are initialized - void buildInternal(); - ///***************************************** expert/internal use only ************************* - - void reportAabbOverlappingNodex(btNodeOverlapCallback* nodeCallback,const btVector3& aabbMin,const btVector3& aabbMax) const; - void reportRayOverlappingNodex (btNodeOverlapCallback* nodeCallback, const btVector3& raySource, const btVector3& rayTarget) const; - void reportBoxCastOverlappingNodex(btNodeOverlapCallback* nodeCallback, const btVector3& raySource, const btVector3& rayTarget, const btVector3& aabbMin,const btVector3& aabbMax) const; - - SIMD_FORCE_INLINE void quantize(unsigned short* out, const btVector3& point,int isMax) const - { - - btAssert(m_useQuantization); - - btAssert(point.getX() <= m_bvhAabbMax.getX()); - btAssert(point.getY() <= m_bvhAabbMax.getY()); - btAssert(point.getZ() <= m_bvhAabbMax.getZ()); - - btAssert(point.getX() >= m_bvhAabbMin.getX()); - btAssert(point.getY() >= m_bvhAabbMin.getY()); - btAssert(point.getZ() >= m_bvhAabbMin.getZ()); - - btVector3 v = (point - m_bvhAabbMin) * m_bvhQuantization; - ///Make sure rounding is done in a way that unQuantize(quantizeWithClamp(...)) is conservative - ///end-points always set the first bit, so that they are sorted properly (so that neighbouring AABBs overlap properly) - ///@todo: double-check this - if (isMax) - { - out[0] = (unsigned short) (((unsigned short)(v.getX()+btScalar(1.)) | 1)); - out[1] = (unsigned short) (((unsigned short)(v.getY()+btScalar(1.)) | 1)); - out[2] = (unsigned short) (((unsigned short)(v.getZ()+btScalar(1.)) | 1)); - } else - { - out[0] = (unsigned short) (((unsigned short)(v.getX()) & 0xfffe)); - out[1] = (unsigned short) (((unsigned short)(v.getY()) & 0xfffe)); - out[2] = (unsigned short) (((unsigned short)(v.getZ()) & 0xfffe)); - } - - -#ifdef DEBUG_CHECK_DEQUANTIZATION - btVector3 newPoint = unQuantize(out); - if (isMax) - { - if (newPoint.getX() < point.getX()) - { - printf("unconservative X, diffX = %f, oldX=%f,newX=%f\n",newPoint.getX()-point.getX(), newPoint.getX(),point.getX()); - } - if (newPoint.getY() < point.getY()) - { - printf("unconservative Y, diffY = %f, oldY=%f,newY=%f\n",newPoint.getY()-point.getY(), newPoint.getY(),point.getY()); - } - if (newPoint.getZ() < point.getZ()) - { - - printf("unconservative Z, diffZ = %f, oldZ=%f,newZ=%f\n",newPoint.getZ()-point.getZ(), newPoint.getZ(),point.getZ()); - } - } else - { - if (newPoint.getX() > point.getX()) - { - printf("unconservative X, diffX = %f, oldX=%f,newX=%f\n",newPoint.getX()-point.getX(), newPoint.getX(),point.getX()); - } - if (newPoint.getY() > point.getY()) - { - printf("unconservative Y, diffY = %f, oldY=%f,newY=%f\n",newPoint.getY()-point.getY(), newPoint.getY(),point.getY()); - } - if (newPoint.getZ() > point.getZ()) - { - printf("unconservative Z, diffZ = %f, oldZ=%f,newZ=%f\n",newPoint.getZ()-point.getZ(), newPoint.getZ(),point.getZ()); - } - } -#endif //DEBUG_CHECK_DEQUANTIZATION - - } - - - SIMD_FORCE_INLINE void quantizeWithClamp(unsigned short* out, const btVector3& point2,int isMax) const - { - - btAssert(m_useQuantization); - - btVector3 clampedPoint(point2); - clampedPoint.setMax(m_bvhAabbMin); - clampedPoint.setMin(m_bvhAabbMax); - - quantize(out,clampedPoint,isMax); - - } - - SIMD_FORCE_INLINE btVector3 unQuantize(const unsigned short* vecIn) const - { - btVector3 vecOut; - vecOut.setValue( - (btScalar)(vecIn[0]) / (m_bvhQuantization.getX()), - (btScalar)(vecIn[1]) / (m_bvhQuantization.getY()), - (btScalar)(vecIn[2]) / (m_bvhQuantization.getZ())); - vecOut += m_bvhAabbMin; - return vecOut; - } - - ///setTraversalMode let's you choose between stackless, recursive or stackless cache friendly tree traversal. Note this is only implemented for quantized trees. - void setTraversalMode(btTraversalMode traversalMode) - { - m_traversalMode = traversalMode; - } - - - SIMD_FORCE_INLINE QuantizedNodeArray& getQuantizedNodeArray() - { - return m_quantizedContiguousNodes; - } - - - SIMD_FORCE_INLINE BvhSubtreeInfoArray& getSubtreeInfoArray() - { - return m_SubtreeHeaders; - } - - - /////Calculate space needed to store BVH for serialization - unsigned calculateSerializeBufferSize() const; - - /// Data buffer MUST be 16 byte aligned - virtual bool serialize(void *o_alignedDataBuffer, unsigned i_dataBufferSize, bool i_swapEndian) const; - - ///deSerializeInPlace loads and initializes a BVH from a buffer in memory 'in place' - static btQuantizedBvh *deSerializeInPlace(void *i_alignedDataBuffer, unsigned int i_dataBufferSize, bool i_swapEndian); - - static unsigned int getAlignmentSerializationPadding(); - - SIMD_FORCE_INLINE bool isQuantized() - { - return m_useQuantization; - } - -private: - // Special "copy" constructor that allows for in-place deserialization - // Prevents btVector3's default constructor from being called, but doesn't inialize much else - // ownsMemory should most likely be false if deserializing, and if you are not, don't call this (it also changes the function signature, which we need) - btQuantizedBvh(btQuantizedBvh &other, bool ownsMemory); - -} -; - - -#endif //QUANTIZED_BVH_H diff --git a/bullet/src/BulletCollision/BroadphaseCollision/btSimpleBroadphase.cpp b/bullet/src/BulletCollision/BroadphaseCollision/btSimpleBroadphase.cpp deleted file mode 100644 index 9125ed7dc..000000000 --- a/bullet/src/BulletCollision/BroadphaseCollision/btSimpleBroadphase.cpp +++ /dev/null @@ -1,330 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btSimpleBroadphase.h" -#include "BulletCollision/BroadphaseCollision/btDispatcher.h" -#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h" - -#include "LinearMath/btVector3.h" -#include "LinearMath/btTransform.h" -#include "LinearMath/btMatrix3x3.h" -#include - -extern int gOverlappingPairs; - -void btSimpleBroadphase::validate() -{ - for (int i=0;i~btOverlappingPairCache(); - btAlignedFree(m_pairCache); - } -} - - -btBroadphaseProxy* btSimpleBroadphase::createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr ,short int collisionFilterGroup,short int collisionFilterMask, btDispatcher* /*dispatcher*/,void* multiSapProxy) -{ - if (m_numHandles >= m_maxHandles) - { - btAssert(0); - return 0; //should never happen, but don't let the game crash ;-) - } - btAssert(aabbMin[0]<= aabbMax[0] && aabbMin[1]<= aabbMax[1] && aabbMin[2]<= aabbMax[2]); - - int newHandleIndex = allocHandle(); - btSimpleBroadphaseProxy* proxy = new (&m_pHandles[newHandleIndex])btSimpleBroadphaseProxy(aabbMin,aabbMax,shapeType,userPtr,collisionFilterGroup,collisionFilterMask,multiSapProxy); - - return proxy; -} - -class RemovingOverlapCallback : public btOverlapCallback -{ -protected: - virtual bool processOverlap(btBroadphasePair& pair) - { - (void)pair; - btAssert(0); - return false; - } -}; - -class RemovePairContainingProxy -{ - - btBroadphaseProxy* m_targetProxy; - public: - virtual ~RemovePairContainingProxy() - { - } -protected: - virtual bool processOverlap(btBroadphasePair& pair) - { - btSimpleBroadphaseProxy* proxy0 = static_cast(pair.m_pProxy0); - btSimpleBroadphaseProxy* proxy1 = static_cast(pair.m_pProxy1); - - return ((m_targetProxy == proxy0 || m_targetProxy == proxy1)); - }; -}; - -void btSimpleBroadphase::destroyProxy(btBroadphaseProxy* proxyOrg,btDispatcher* dispatcher) -{ - - btSimpleBroadphaseProxy* proxy0 = static_cast(proxyOrg); - freeHandle(proxy0); - - m_pairCache->removeOverlappingPairsContainingProxy(proxyOrg,dispatcher); - - //validate(); - -} - -void btSimpleBroadphase::getAabb(btBroadphaseProxy* proxy,btVector3& aabbMin, btVector3& aabbMax ) const -{ - const btSimpleBroadphaseProxy* sbp = getSimpleProxyFromProxy(proxy); - aabbMin = sbp->m_aabbMin; - aabbMax = sbp->m_aabbMax; -} - -void btSimpleBroadphase::setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax, btDispatcher* /*dispatcher*/) -{ - btSimpleBroadphaseProxy* sbp = getSimpleProxyFromProxy(proxy); - sbp->m_aabbMin = aabbMin; - sbp->m_aabbMax = aabbMax; -} - -void btSimpleBroadphase::rayTest(const btVector3& rayFrom,const btVector3& rayTo, btBroadphaseRayCallback& rayCallback, const btVector3& aabbMin,const btVector3& aabbMax) -{ - for (int i=0; i <= m_LastHandleIndex; i++) - { - btSimpleBroadphaseProxy* proxy = &m_pHandles[i]; - if(!proxy->m_clientObject) - { - continue; - } - rayCallback.process(proxy); - } -} - - - - - - - -bool btSimpleBroadphase::aabbOverlap(btSimpleBroadphaseProxy* proxy0,btSimpleBroadphaseProxy* proxy1) -{ - return proxy0->m_aabbMin[0] <= proxy1->m_aabbMax[0] && proxy1->m_aabbMin[0] <= proxy0->m_aabbMax[0] && - proxy0->m_aabbMin[1] <= proxy1->m_aabbMax[1] && proxy1->m_aabbMin[1] <= proxy0->m_aabbMax[1] && - proxy0->m_aabbMin[2] <= proxy1->m_aabbMax[2] && proxy1->m_aabbMin[2] <= proxy0->m_aabbMax[2]; - -} - - - -//then remove non-overlapping ones -class CheckOverlapCallback : public btOverlapCallback -{ -public: - virtual bool processOverlap(btBroadphasePair& pair) - { - return (!btSimpleBroadphase::aabbOverlap(static_cast(pair.m_pProxy0),static_cast(pair.m_pProxy1))); - } -}; - -void btSimpleBroadphase::calculateOverlappingPairs(btDispatcher* dispatcher) -{ - //first check for new overlapping pairs - int i,j; - if (m_numHandles >= 0) - { - int new_largest_index = -1; - for (i=0; i <= m_LastHandleIndex; i++) - { - btSimpleBroadphaseProxy* proxy0 = &m_pHandles[i]; - if(!proxy0->m_clientObject) - { - continue; - } - new_largest_index = i; - for (j=i+1; j <= m_LastHandleIndex; j++) - { - btSimpleBroadphaseProxy* proxy1 = &m_pHandles[j]; - btAssert(proxy0 != proxy1); - if(!proxy1->m_clientObject) - { - continue; - } - - btSimpleBroadphaseProxy* p0 = getSimpleProxyFromProxy(proxy0); - btSimpleBroadphaseProxy* p1 = getSimpleProxyFromProxy(proxy1); - - if (aabbOverlap(p0,p1)) - { - if ( !m_pairCache->findPair(proxy0,proxy1)) - { - m_pairCache->addOverlappingPair(proxy0,proxy1); - } - } else - { - if (!m_pairCache->hasDeferredRemoval()) - { - if ( m_pairCache->findPair(proxy0,proxy1)) - { - m_pairCache->removeOverlappingPair(proxy0,proxy1,dispatcher); - } - } - } - } - } - - m_LastHandleIndex = new_largest_index; - - if (m_ownsPairCache && m_pairCache->hasDeferredRemoval()) - { - - btBroadphasePairArray& overlappingPairArray = m_pairCache->getOverlappingPairArray(); - - //perform a sort, to find duplicates and to sort 'invalid' pairs to the end - overlappingPairArray.quickSort(btBroadphasePairSortPredicate()); - - overlappingPairArray.resize(overlappingPairArray.size() - m_invalidPair); - m_invalidPair = 0; - - - btBroadphasePair previousPair; - previousPair.m_pProxy0 = 0; - previousPair.m_pProxy1 = 0; - previousPair.m_algorithm = 0; - - - for (i=0;iprocessOverlap(pair); - } else - { - needsRemoval = true; - } - } else - { - //remove duplicate - needsRemoval = true; - //should have no algorithm - btAssert(!pair.m_algorithm); - } - - if (needsRemoval) - { - m_pairCache->cleanOverlappingPair(pair,dispatcher); - - // m_overlappingPairArray.swap(i,m_overlappingPairArray.size()-1); - // m_overlappingPairArray.pop_back(); - pair.m_pProxy0 = 0; - pair.m_pProxy1 = 0; - m_invalidPair++; - gOverlappingPairs--; - } - - } - - ///if you don't like to skip the invalid pairs in the array, execute following code: -#define CLEAN_INVALID_PAIRS 1 -#ifdef CLEAN_INVALID_PAIRS - - //perform a sort, to sort 'invalid' pairs to the end - overlappingPairArray.quickSort(btBroadphasePairSortPredicate()); - - overlappingPairArray.resize(overlappingPairArray.size() - m_invalidPair); - m_invalidPair = 0; -#endif//CLEAN_INVALID_PAIRS - - } - } -} - - -bool btSimpleBroadphase::testAabbOverlap(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) -{ - btSimpleBroadphaseProxy* p0 = getSimpleProxyFromProxy(proxy0); - btSimpleBroadphaseProxy* p1 = getSimpleProxyFromProxy(proxy1); - return aabbOverlap(p0,p1); -} - -void btSimpleBroadphase::resetPool(btDispatcher* dispatcher) -{ - //not yet -} diff --git a/bullet/src/BulletCollision/BroadphaseCollision/btSimpleBroadphase.h b/bullet/src/BulletCollision/BroadphaseCollision/btSimpleBroadphase.h deleted file mode 100644 index 3be8cc038..000000000 --- a/bullet/src/BulletCollision/BroadphaseCollision/btSimpleBroadphase.h +++ /dev/null @@ -1,170 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef SIMPLE_BROADPHASE_H -#define SIMPLE_BROADPHASE_H - - -#include "btOverlappingPairCache.h" - - -struct btSimpleBroadphaseProxy : public btBroadphaseProxy -{ - int m_nextFree; - -// int m_handleId; - - - btSimpleBroadphaseProxy() {}; - - btSimpleBroadphaseProxy(const btVector3& minpt,const btVector3& maxpt,int shapeType,void* userPtr,short int collisionFilterGroup,short int collisionFilterMask,void* multiSapProxy) - :btBroadphaseProxy(minpt,maxpt,userPtr,collisionFilterGroup,collisionFilterMask,multiSapProxy) - { - (void)shapeType; - } - - - SIMD_FORCE_INLINE void SetNextFree(int next) {m_nextFree = next;} - SIMD_FORCE_INLINE int GetNextFree() const {return m_nextFree;} - - - - -}; - -///The SimpleBroadphase is just a unit-test for btAxisSweep3, bt32BitAxisSweep3, or btDbvtBroadphase, so use those classes instead. -///It is a brute force aabb culling broadphase based on O(n^2) aabb checks -class btSimpleBroadphase : public btBroadphaseInterface -{ - -protected: - - int m_numHandles; // number of active handles - int m_maxHandles; // max number of handles - int m_LastHandleIndex; - - btSimpleBroadphaseProxy* m_pHandles; // handles pool - - void* m_pHandlesRawPtr; - int m_firstFreeHandle; // free handles list - - int allocHandle() - { - btAssert(m_numHandles < m_maxHandles); - int freeHandle = m_firstFreeHandle; - m_firstFreeHandle = m_pHandles[freeHandle].GetNextFree(); - m_numHandles++; - if(freeHandle > m_LastHandleIndex) - { - m_LastHandleIndex = freeHandle; - } - return freeHandle; - } - - void freeHandle(btSimpleBroadphaseProxy* proxy) - { - int handle = int(proxy-m_pHandles); - btAssert(handle >= 0 && handle < m_maxHandles); - if(handle == m_LastHandleIndex) - { - m_LastHandleIndex--; - } - proxy->SetNextFree(m_firstFreeHandle); - m_firstFreeHandle = handle; - - proxy->m_clientObject = 0; - - m_numHandles--; - } - - btOverlappingPairCache* m_pairCache; - bool m_ownsPairCache; - - int m_invalidPair; - - - - inline btSimpleBroadphaseProxy* getSimpleProxyFromProxy(btBroadphaseProxy* proxy) - { - btSimpleBroadphaseProxy* proxy0 = static_cast(proxy); - return proxy0; - } - - inline const btSimpleBroadphaseProxy* getSimpleProxyFromProxy(btBroadphaseProxy* proxy) const - { - const btSimpleBroadphaseProxy* proxy0 = static_cast(proxy); - return proxy0; - } - - ///reset broadphase internal structures, to ensure determinism/reproducability - virtual void resetPool(btDispatcher* dispatcher); - - - void validate(); - -protected: - - - - -public: - btSimpleBroadphase(int maxProxies=16384,btOverlappingPairCache* overlappingPairCache=0); - virtual ~btSimpleBroadphase(); - - - static bool aabbOverlap(btSimpleBroadphaseProxy* proxy0,btSimpleBroadphaseProxy* proxy1); - - - virtual btBroadphaseProxy* createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr ,short int collisionFilterGroup,short int collisionFilterMask, btDispatcher* dispatcher,void* multiSapProxy); - - virtual void calculateOverlappingPairs(btDispatcher* dispatcher); - - virtual void destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher); - virtual void setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax, btDispatcher* dispatcher); - virtual void getAabb(btBroadphaseProxy* proxy,btVector3& aabbMin, btVector3& aabbMax ) const; - - virtual void rayTest(const btVector3& rayFrom,const btVector3& rayTo, btBroadphaseRayCallback& rayCallback, const btVector3& aabbMin=btVector3(0,0,0),const btVector3& aabbMax=btVector3(0,0,0)); - - btOverlappingPairCache* getOverlappingPairCache() - { - return m_pairCache; - } - const btOverlappingPairCache* getOverlappingPairCache() const - { - return m_pairCache; - } - - bool testAabbOverlap(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1); - - - ///getAabb returns the axis aligned bounding box in the 'global' coordinate frame - ///will add some transform later - virtual void getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const - { - aabbMin.setValue(-BT_LARGE_FLOAT,-BT_LARGE_FLOAT,-BT_LARGE_FLOAT); - aabbMax.setValue(BT_LARGE_FLOAT,BT_LARGE_FLOAT,BT_LARGE_FLOAT); - } - - virtual void printStats() - { -// printf("btSimpleBroadphase.h\n"); -// printf("numHandles = %d, maxHandles = %d\n",m_numHandles,m_maxHandles); - } -}; - - - -#endif //SIMPLE_BROADPHASE_H - diff --git a/bullet/src/BulletCollision/CMakeLists.txt b/bullet/src/BulletCollision/CMakeLists.txt deleted file mode 100644 index 1ae802246..000000000 --- a/bullet/src/BulletCollision/CMakeLists.txt +++ /dev/null @@ -1,268 +0,0 @@ -INCLUDE_DIRECTORIES( ${BULLET_PHYSICS_SOURCE_DIR}/src ) - -SET(BulletCollision_SRCS - BroadphaseCollision/btAxisSweep3.cpp - BroadphaseCollision/btBroadphaseProxy.cpp - BroadphaseCollision/btCollisionAlgorithm.cpp - BroadphaseCollision/btDbvt.cpp - BroadphaseCollision/btDbvtBroadphase.cpp - BroadphaseCollision/btDispatcher.cpp - BroadphaseCollision/btMultiSapBroadphase.cpp - BroadphaseCollision/btOverlappingPairCache.cpp - BroadphaseCollision/btQuantizedBvh.cpp - BroadphaseCollision/btSimpleBroadphase.cpp - CollisionDispatch/btActivatingCollisionAlgorithm.cpp - CollisionDispatch/btBoxBoxCollisionAlgorithm.cpp - CollisionDispatch/btBox2dBox2dCollisionAlgorithm.cpp - CollisionDispatch/btBoxBoxDetector.cpp - CollisionDispatch/btCollisionDispatcher.cpp - CollisionDispatch/btCollisionObject.cpp - CollisionDispatch/btCollisionWorld.cpp - CollisionDispatch/btCompoundCollisionAlgorithm.cpp - CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp - CollisionDispatch/btConvexConvexAlgorithm.cpp - CollisionDispatch/btConvexPlaneCollisionAlgorithm.cpp - CollisionDispatch/btConvex2dConvex2dAlgorithm.cpp - CollisionDispatch/btDefaultCollisionConfiguration.cpp - CollisionDispatch/btEmptyCollisionAlgorithm.cpp - CollisionDispatch/btGhostObject.cpp - CollisionDispatch/btManifoldResult.cpp - CollisionDispatch/btSimulationIslandManager.cpp - CollisionDispatch/btSphereBoxCollisionAlgorithm.cpp - CollisionDispatch/btSphereSphereCollisionAlgorithm.cpp - CollisionDispatch/btSphereTriangleCollisionAlgorithm.cpp - CollisionDispatch/btUnionFind.cpp - CollisionDispatch/SphereTriangleDetector.cpp - CollisionShapes/btBoxShape.cpp - CollisionShapes/btBox2dShape.cpp - CollisionShapes/btBvhTriangleMeshShape.cpp - CollisionShapes/btCapsuleShape.cpp - CollisionShapes/btCollisionShape.cpp - CollisionShapes/btCompoundShape.cpp - CollisionShapes/btConcaveShape.cpp - CollisionShapes/btConeShape.cpp - CollisionShapes/btConvexHullShape.cpp - CollisionShapes/btConvexInternalShape.cpp - CollisionShapes/btConvexPointCloudShape.cpp - CollisionShapes/btConvexShape.cpp - CollisionShapes/btConvex2dShape.cpp - CollisionShapes/btConvexTriangleMeshShape.cpp - CollisionShapes/btCylinderShape.cpp - CollisionShapes/btEmptyShape.cpp - CollisionShapes/btHeightfieldTerrainShape.cpp - CollisionShapes/btMinkowskiSumShape.cpp - CollisionShapes/btMultimaterialTriangleMeshShape.cpp - CollisionShapes/btMultiSphereShape.cpp - CollisionShapes/btOptimizedBvh.cpp - CollisionShapes/btPolyhedralConvexShape.cpp - CollisionShapes/btScaledBvhTriangleMeshShape.cpp - CollisionShapes/btShapeHull.cpp - CollisionShapes/btSphereShape.cpp - CollisionShapes/btStaticPlaneShape.cpp - CollisionShapes/btStridingMeshInterface.cpp - CollisionShapes/btTetrahedronShape.cpp - CollisionShapes/btTriangleBuffer.cpp - CollisionShapes/btTriangleCallback.cpp - CollisionShapes/btTriangleIndexVertexArray.cpp - CollisionShapes/btTriangleIndexVertexMaterialArray.cpp - CollisionShapes/btTriangleMesh.cpp - CollisionShapes/btTriangleMeshShape.cpp - CollisionShapes/btUniformScalingShape.cpp - Gimpact/btContactProcessing.cpp - Gimpact/btGenericPoolAllocator.cpp - Gimpact/btGImpactBvh.cpp - Gimpact/btGImpactCollisionAlgorithm.cpp - Gimpact/btGImpactQuantizedBvh.cpp - Gimpact/btGImpactShape.cpp - Gimpact/btTriangleShapeEx.cpp - Gimpact/gim_box_set.cpp - Gimpact/gim_contact.cpp - Gimpact/gim_memory.cpp - Gimpact/gim_tri_collision.cpp - NarrowPhaseCollision/btContinuousConvexCollision.cpp - NarrowPhaseCollision/btConvexCast.cpp - NarrowPhaseCollision/btGjkConvexCast.cpp - NarrowPhaseCollision/btGjkEpa2.cpp - NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp - NarrowPhaseCollision/btGjkPairDetector.cpp - NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp - NarrowPhaseCollision/btPersistentManifold.cpp - NarrowPhaseCollision/btRaycastCallback.cpp - NarrowPhaseCollision/btSubSimplexConvexCast.cpp - NarrowPhaseCollision/btVoronoiSimplexSolver.cpp -) - -SET(Root_HDRS - ../btBulletCollisionCommon.h -) -SET(BroadphaseCollision_HDRS - BroadphaseCollision/btAxisSweep3.h - BroadphaseCollision/btBroadphaseInterface.h - BroadphaseCollision/btBroadphaseProxy.h - BroadphaseCollision/btCollisionAlgorithm.h - BroadphaseCollision/btDbvt.h - BroadphaseCollision/btDbvtBroadphase.h - BroadphaseCollision/btDispatcher.h - BroadphaseCollision/btMultiSapBroadphase.h - BroadphaseCollision/btOverlappingPairCache.h - BroadphaseCollision/btOverlappingPairCallback.h - BroadphaseCollision/btQuantizedBvh.h - BroadphaseCollision/btSimpleBroadphase.h -) -SET(CollisionDispatch_HDRS - CollisionDispatch/btActivatingCollisionAlgorithm.h - CollisionDispatch/btBoxBoxCollisionAlgorithm.h - CollisionDispatch/btBox2dBox2dCollisionAlgorithm.h - CollisionDispatch/btBoxBoxDetector.h - CollisionDispatch/btCollisionConfiguration.h - CollisionDispatch/btCollisionCreateFunc.h - CollisionDispatch/btCollisionDispatcher.h - CollisionDispatch/btCollisionObject.h - CollisionDispatch/btCollisionWorld.h - CollisionDispatch/btCompoundCollisionAlgorithm.h - CollisionDispatch/btConvexConcaveCollisionAlgorithm.h - CollisionDispatch/btConvexConvexAlgorithm.h - CollisionDispatch/btConvex2dConvex2dAlgorithm.h - CollisionDispatch/btConvexPlaneCollisionAlgorithm.h - CollisionDispatch/btDefaultCollisionConfiguration.h - CollisionDispatch/btEmptyCollisionAlgorithm.h - CollisionDispatch/btGhostObject.h - CollisionDispatch/btManifoldResult.h - CollisionDispatch/btSimulationIslandManager.h - CollisionDispatch/btSphereBoxCollisionAlgorithm.h - CollisionDispatch/btSphereSphereCollisionAlgorithm.h - CollisionDispatch/btSphereTriangleCollisionAlgorithm.h - CollisionDispatch/btUnionFind.h - CollisionDispatch/SphereTriangleDetector.h -) -SET(CollisionShapes_HDRS - CollisionShapes/btBoxShape.h - CollisionShapes/btBox2dShape.h - CollisionShapes/btBvhTriangleMeshShape.h - CollisionShapes/btCapsuleShape.h - CollisionShapes/btCollisionMargin.h - CollisionShapes/btCollisionShape.h - CollisionShapes/btCompoundShape.h - CollisionShapes/btConcaveShape.h - CollisionShapes/btConeShape.h - CollisionShapes/btConvexHullShape.h - CollisionShapes/btConvexInternalShape.h - CollisionShapes/btConvexPointCloudShape.h - CollisionShapes/btConvexShape.h - CollisionShapes/btConvex2dShape.h - CollisionShapes/btConvexTriangleMeshShape.h - CollisionShapes/btCylinderShape.h - CollisionShapes/btEmptyShape.h - CollisionShapes/btHeightfieldTerrainShape.h - CollisionShapes/btMaterial.h - CollisionShapes/btMinkowskiSumShape.h - CollisionShapes/btMultimaterialTriangleMeshShape.h - CollisionShapes/btMultiSphereShape.h - CollisionShapes/btOptimizedBvh.h - CollisionShapes/btPolyhedralConvexShape.h - CollisionShapes/btScaledBvhTriangleMeshShape.h - CollisionShapes/btShapeHull.h - CollisionShapes/btSphereShape.h - CollisionShapes/btStaticPlaneShape.h - CollisionShapes/btStridingMeshInterface.h - CollisionShapes/btTetrahedronShape.h - CollisionShapes/btTriangleBuffer.h - CollisionShapes/btTriangleCallback.h - CollisionShapes/btTriangleIndexVertexArray.h - CollisionShapes/btTriangleIndexVertexMaterialArray.h - CollisionShapes/btTriangleMesh.h - CollisionShapes/btTriangleMeshShape.h - CollisionShapes/btTriangleShape.h - CollisionShapes/btUniformScalingShape.h -) -SET(Gimpact_HDRS - Gimpact/btBoxCollision.h - Gimpact/btClipPolygon.h - Gimpact/btContactProcessing.h - Gimpact/btGenericPoolAllocator.h - Gimpact/btGeometryOperations.h - Gimpact/btGImpactBvh.h - Gimpact/btGImpactCollisionAlgorithm.h - Gimpact/btGImpactMassUtil.h - Gimpact/btGImpactQuantizedBvh.h - Gimpact/btGImpactShape.h - Gimpact/btQuantization.h - Gimpact/btTriangleShapeEx.h - Gimpact/gim_array.h - Gimpact/gim_basic_geometry_operations.h - Gimpact/gim_bitset.h - Gimpact/gim_box_collision.h - Gimpact/gim_box_set.h - Gimpact/gim_clip_polygon.h - Gimpact/gim_contact.h - Gimpact/gim_geom_types.h - Gimpact/gim_geometry.h - Gimpact/gim_hash_table.h - Gimpact/gim_linear_math.h - Gimpact/gim_math.h - Gimpact/gim_memory.h - Gimpact/gim_radixsort.h - Gimpact/gim_tri_collision.h -) -SET(NarrowPhaseCollision_HDRS - NarrowPhaseCollision/btContinuousConvexCollision.h - NarrowPhaseCollision/btConvexCast.h - NarrowPhaseCollision/btConvexPenetrationDepthSolver.h - NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h - NarrowPhaseCollision/btGjkConvexCast.h - NarrowPhaseCollision/btGjkEpa2.h - NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h - NarrowPhaseCollision/btGjkPairDetector.h - NarrowPhaseCollision/btManifoldPoint.h - NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h - NarrowPhaseCollision/btPersistentManifold.h - NarrowPhaseCollision/btPointCollector.h - NarrowPhaseCollision/btRaycastCallback.h - NarrowPhaseCollision/btSimplexSolverInterface.h - NarrowPhaseCollision/btSubSimplexConvexCast.h - NarrowPhaseCollision/btVoronoiSimplexSolver.h -) - -SET(BulletCollision_HDRS - ${Root_HDRS} - ${BroadphaseCollision_HDRS} - ${CollisionDispatch_HDRS} - ${CollisionShapes_HDRS} - ${Gimpact_HDRS} - ${NarrowPhaseCollision_HDRS} -) - - -ADD_LIBRARY(BulletCollision ${BulletCollision_SRCS} ${BulletCollision_HDRS}) -SET_TARGET_PROPERTIES(BulletCollision PROPERTIES VERSION ${BULLET_VERSION}) -SET_TARGET_PROPERTIES(BulletCollision PROPERTIES SOVERSION ${BULLET_VERSION}) -IF (BUILD_SHARED_LIBS) - TARGET_LINK_LIBRARIES(BulletCollision LinearMath) -ENDIF (BUILD_SHARED_LIBS) - - - - -#INSTALL of other files requires CMake 2.6 -IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) - IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) - INSTALL(TARGETS BulletCollision DESTINATION .) - ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) - INSTALL(TARGETS BulletCollision DESTINATION lib${LIB_SUFFIX}) - INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION include FILES_MATCHING PATTERN "*.h") - INSTALL(FILES ../btBulletCollisionCommon.h DESTINATION include/BulletCollision) - ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) -ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) - -IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) - SET_TARGET_PROPERTIES(BulletCollision PROPERTIES FRAMEWORK true) - - SET_TARGET_PROPERTIES(BulletCollision PROPERTIES PUBLIC_HEADER ${Root_HDRS}) - # Have to list out sub-directories manually: - SET_PROPERTY(SOURCE ${BroadphaseCollision_HDRS} PROPERTY MACOSX_PACKAGE_LOCATION Headers/BroadphaseCollision) - SET_PROPERTY(SOURCE ${CollisionDispatch_HDRS} PROPERTY MACOSX_PACKAGE_LOCATION Headers/CollisionDispatch) - SET_PROPERTY(SOURCE ${CollisionShapes_HDRS} PROPERTY MACOSX_PACKAGE_LOCATION Headers/CollisionShapes) - SET_PROPERTY(SOURCE ${Gimpact_HDRS} PROPERTY MACOSX_PACKAGE_LOCATION Headers/Gimpact) - SET_PROPERTY(SOURCE ${NarrowPhaseCollision_HDRS} PROPERTY MACOSX_PACKAGE_LOCATION Headers/NarrowPhaseCollision) - -ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) diff --git a/bullet/src/BulletCollision/CollisionDispatch/SphereTriangleDetector.cpp b/bullet/src/BulletCollision/CollisionDispatch/SphereTriangleDetector.cpp deleted file mode 100644 index 983df3fcf..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/SphereTriangleDetector.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "LinearMath/btScalar.h" -#include "SphereTriangleDetector.h" -#include "BulletCollision/CollisionShapes/btTriangleShape.h" -#include "BulletCollision/CollisionShapes/btSphereShape.h" - - -SphereTriangleDetector::SphereTriangleDetector(btSphereShape* sphere,btTriangleShape* triangle,btScalar contactBreakingThreshold) -:m_sphere(sphere), -m_triangle(triangle), -m_contactBreakingThreshold(contactBreakingThreshold) -{ - -} - -void SphereTriangleDetector::getClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw,bool swapResults) -{ - - (void)debugDraw; - const btTransform& transformA = input.m_transformA; - const btTransform& transformB = input.m_transformB; - - btVector3 point,normal; - btScalar timeOfImpact = btScalar(1.); - btScalar depth = btScalar(0.); -// output.m_distance = btScalar(BT_LARGE_FLOAT); - //move sphere into triangle space - btTransform sphereInTr = transformB.inverseTimes(transformA); - - if (collide(sphereInTr.getOrigin(),point,normal,depth,timeOfImpact,m_contactBreakingThreshold)) - { - if (swapResults) - { - btVector3 normalOnB = transformB.getBasis()*normal; - btVector3 normalOnA = -normalOnB; - btVector3 pointOnA = transformB*point+normalOnB*depth; - output.addContactPoint(normalOnA,pointOnA,depth); - } else - { - output.addContactPoint(transformB.getBasis()*normal,transformB*point,depth); - } - } - -} - -#define MAX_OVERLAP btScalar(0.) - - - -// See also geometrictools.com -// Basic idea: D = |p - (lo + t0*lv)| where t0 = lv . (p - lo) / lv . lv -btScalar SegmentSqrDistance(const btVector3& from, const btVector3& to,const btVector3 &p, btVector3 &nearest); - -btScalar SegmentSqrDistance(const btVector3& from, const btVector3& to,const btVector3 &p, btVector3 &nearest) { - btVector3 diff = p - from; - btVector3 v = to - from; - btScalar t = v.dot(diff); - - if (t > 0) { - btScalar dotVV = v.dot(v); - if (t < dotVV) { - t /= dotVV; - diff -= t*v; - } else { - t = 1; - diff -= v; - } - } else - t = 0; - - nearest = from + t*v; - return diff.dot(diff); -} - -bool SphereTriangleDetector::facecontains(const btVector3 &p,const btVector3* vertices,btVector3& normal) { - btVector3 lp(p); - btVector3 lnormal(normal); - - return pointInTriangle(vertices, lnormal, &lp); -} - -///combined discrete/continuous sphere-triangle -bool SphereTriangleDetector::collide(const btVector3& sphereCenter,btVector3 &point, btVector3& resultNormal, btScalar& depth, btScalar &timeOfImpact, btScalar contactBreakingThreshold) -{ - - const btVector3* vertices = &m_triangle->getVertexPtr(0); - const btVector3& c = sphereCenter; - btScalar r = m_sphere->getRadius(); - - btVector3 delta (0,0,0); - - btVector3 normal = (vertices[1]-vertices[0]).cross(vertices[2]-vertices[0]); - normal.normalize(); - btVector3 p1ToCentre = c - vertices[0]; - btScalar distanceFromPlane = p1ToCentre.dot(normal); - - if (distanceFromPlane < btScalar(0.)) - { - //triangle facing the other way - - distanceFromPlane *= btScalar(-1.); - normal *= btScalar(-1.); - } - - btScalar contactMargin = contactBreakingThreshold; - bool isInsideContactPlane = distanceFromPlane < r + contactMargin; - bool isInsideShellPlane = distanceFromPlane < r; - - btScalar deltaDotNormal = delta.dot(normal); - if (!isInsideShellPlane && deltaDotNormal >= btScalar(0.0)) - return false; - - // Check for contact / intersection - bool hasContact = false; - btVector3 contactPoint; - if (isInsideContactPlane) { - if (facecontains(c,vertices,normal)) { - // Inside the contact wedge - touches a point on the shell plane - hasContact = true; - contactPoint = c - normal*distanceFromPlane; - } else { - // Could be inside one of the contact capsules - btScalar contactCapsuleRadiusSqr = (r + contactMargin) * (r + contactMargin); - btVector3 nearestOnEdge; - for (int i = 0; i < m_triangle->getNumEdges(); i++) { - - btVector3 pa; - btVector3 pb; - - m_triangle->getEdge(i,pa,pb); - - btScalar distanceSqr = SegmentSqrDistance(pa,pb,c, nearestOnEdge); - if (distanceSqr < contactCapsuleRadiusSqr) { - // Yep, we're inside a capsule - hasContact = true; - contactPoint = nearestOnEdge; - } - - } - } - } - - if (hasContact) { - btVector3 contactToCentre = c - contactPoint; - btScalar distanceSqr = contactToCentre.length2(); - if (distanceSqr < (r - MAX_OVERLAP)*(r - MAX_OVERLAP)) { - btScalar distance = btSqrt(distanceSqr); - resultNormal = contactToCentre; - resultNormal.normalize(); - point = contactPoint; - depth = -(r-distance); - return true; - } - - if (delta.dot(contactToCentre) >= btScalar(0.0)) - return false; - - // Moving towards the contact point -> collision - point = contactPoint; - timeOfImpact = btScalar(0.0); - return true; - } - - return false; -} - - -bool SphereTriangleDetector::pointInTriangle(const btVector3 vertices[], const btVector3 &normal, btVector3 *p ) -{ - const btVector3* p1 = &vertices[0]; - const btVector3* p2 = &vertices[1]; - const btVector3* p3 = &vertices[2]; - - btVector3 edge1( *p2 - *p1 ); - btVector3 edge2( *p3 - *p2 ); - btVector3 edge3( *p1 - *p3 ); - - btVector3 p1_to_p( *p - *p1 ); - btVector3 p2_to_p( *p - *p2 ); - btVector3 p3_to_p( *p - *p3 ); - - btVector3 edge1_normal( edge1.cross(normal)); - btVector3 edge2_normal( edge2.cross(normal)); - btVector3 edge3_normal( edge3.cross(normal)); - - btScalar r1, r2, r3; - r1 = edge1_normal.dot( p1_to_p ); - r2 = edge2_normal.dot( p2_to_p ); - r3 = edge3_normal.dot( p3_to_p ); - if ( ( r1 > 0 && r2 > 0 && r3 > 0 ) || - ( r1 <= 0 && r2 <= 0 && r3 <= 0 ) ) - return true; - return false; - -} diff --git a/bullet/src/BulletCollision/CollisionDispatch/SphereTriangleDetector.h b/bullet/src/BulletCollision/CollisionDispatch/SphereTriangleDetector.h deleted file mode 100644 index 2f30b6cdb..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/SphereTriangleDetector.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef SPHERE_TRIANGLE_DETECTOR_H -#define SPHERE_TRIANGLE_DETECTOR_H - -#include "BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h" - - - -class btSphereShape; -class btTriangleShape; - - - -/// sphere-triangle to match the btDiscreteCollisionDetectorInterface -struct SphereTriangleDetector : public btDiscreteCollisionDetectorInterface -{ - virtual void getClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw,bool swapResults=false); - - SphereTriangleDetector(btSphereShape* sphere,btTriangleShape* triangle, btScalar contactBreakingThreshold); - - virtual ~SphereTriangleDetector() {}; - -private: - - bool collide(const btVector3& sphereCenter,btVector3 &point, btVector3& resultNormal, btScalar& depth, btScalar &timeOfImpact, btScalar contactBreakingThreshold); - bool pointInTriangle(const btVector3 vertices[], const btVector3 &normal, btVector3 *p ); - bool facecontains(const btVector3 &p,const btVector3* vertices,btVector3& normal); - - btSphereShape* m_sphere; - btTriangleShape* m_triangle; - btScalar m_contactBreakingThreshold; - -}; -#endif //SPHERE_TRIANGLE_DETECTOR_H - diff --git a/bullet/src/BulletCollision/CollisionDispatch/btActivatingCollisionAlgorithm.cpp b/bullet/src/BulletCollision/CollisionDispatch/btActivatingCollisionAlgorithm.cpp deleted file mode 100644 index 8fef85ef6..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btActivatingCollisionAlgorithm.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2008 Erwin Coumans http://bulletphysics.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btActivatingCollisionAlgorithm.h" -#include "btCollisionDispatcher.h" -#include "btCollisionObject.h" - -btActivatingCollisionAlgorithm::btActivatingCollisionAlgorithm (const btCollisionAlgorithmConstructionInfo& ci) -:btCollisionAlgorithm(ci) -//, -//m_colObj0(0), -//m_colObj1(0) -{ -} -btActivatingCollisionAlgorithm::btActivatingCollisionAlgorithm (const btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* colObj0,btCollisionObject* colObj1) -:btCollisionAlgorithm(ci) -//, -//m_colObj0(0), -//m_colObj1(0) -{ -// if (ci.m_dispatcher1->needsCollision(colObj0,colObj1)) -// { -// m_colObj0 = colObj0; -// m_colObj1 = colObj1; -// -// m_colObj0->activate(); -// m_colObj1->activate(); -// } -} - -btActivatingCollisionAlgorithm::~btActivatingCollisionAlgorithm() -{ -// m_colObj0->activate(); -// m_colObj1->activate(); -} diff --git a/bullet/src/BulletCollision/CollisionDispatch/btActivatingCollisionAlgorithm.h b/bullet/src/BulletCollision/CollisionDispatch/btActivatingCollisionAlgorithm.h deleted file mode 100644 index a1f8746c1..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btActivatingCollisionAlgorithm.h +++ /dev/null @@ -1,36 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2008 Erwin Coumans http://bulletphysics.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef __BT_ACTIVATING_COLLISION_ALGORITHM_H -#define __BT_ACTIVATING_COLLISION_ALGORITHM_H - -#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h" - -///This class is not enabled yet (work-in-progress) to more aggressively activate objects. -class btActivatingCollisionAlgorithm : public btCollisionAlgorithm -{ -// btCollisionObject* m_colObj0; -// btCollisionObject* m_colObj1; - -public: - - btActivatingCollisionAlgorithm (const btCollisionAlgorithmConstructionInfo& ci); - - btActivatingCollisionAlgorithm (const btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* colObj0,btCollisionObject* colObj1); - - virtual ~btActivatingCollisionAlgorithm(); - -}; -#endif //__BT_ACTIVATING_COLLISION_ALGORITHM_H diff --git a/bullet/src/BulletCollision/CollisionDispatch/btBox2dBox2dCollisionAlgorithm.cpp b/bullet/src/BulletCollision/CollisionDispatch/btBox2dBox2dCollisionAlgorithm.cpp deleted file mode 100644 index 757a35973..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btBox2dBox2dCollisionAlgorithm.cpp +++ /dev/null @@ -1,437 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -* The b2CollidePolygons routines are Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -///btBox2dBox2dCollisionAlgorithm, with modified b2CollidePolygons routines from the Box2D library. -///The modifications include: switching from b2Vec to btVector3, redefinition of b2Dot, b2Cross - -#include "btBox2dBox2dCollisionAlgorithm.h" -#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h" -#include "BulletCollision/CollisionShapes/btBoxShape.h" -#include "BulletCollision/CollisionDispatch/btCollisionObject.h" -#include "BulletCollision/CollisionDispatch/btBoxBoxDetector.h" -#include "BulletCollision/CollisionShapes/btBox2dShape.h" - -#define USE_PERSISTENT_CONTACTS 1 - -btBox2dBox2dCollisionAlgorithm::btBox2dBox2dCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* obj0,btCollisionObject* obj1) -: btActivatingCollisionAlgorithm(ci,obj0,obj1), -m_ownManifold(false), -m_manifoldPtr(mf) -{ - if (!m_manifoldPtr && m_dispatcher->needsCollision(obj0,obj1)) - { - m_manifoldPtr = m_dispatcher->getNewManifold(obj0,obj1); - m_ownManifold = true; - } -} - -btBox2dBox2dCollisionAlgorithm::~btBox2dBox2dCollisionAlgorithm() -{ - - if (m_ownManifold) - { - if (m_manifoldPtr) - m_dispatcher->releaseManifold(m_manifoldPtr); - } - -} - - -void b2CollidePolygons(btManifoldResult* manifold, const btBox2dShape* polyA, const btTransform& xfA, const btBox2dShape* polyB, const btTransform& xfB); - -//#include -void btBox2dBox2dCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) -{ - if (!m_manifoldPtr) - return; - - btCollisionObject* col0 = body0; - btCollisionObject* col1 = body1; - btBox2dShape* box0 = (btBox2dShape*)col0->getCollisionShape(); - btBox2dShape* box1 = (btBox2dShape*)col1->getCollisionShape(); - - resultOut->setPersistentManifold(m_manifoldPtr); - - b2CollidePolygons(resultOut,box0,col0->getWorldTransform(),box1,col1->getWorldTransform()); - - // refreshContactPoints is only necessary when using persistent contact points. otherwise all points are newly added - if (m_ownManifold) - { - resultOut->refreshContactPoints(); - } - -} - -btScalar btBox2dBox2dCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* /*body0*/,btCollisionObject* /*body1*/,const btDispatcherInfo& /*dispatchInfo*/,btManifoldResult* /*resultOut*/) -{ - //not yet - return 1.f; -} - - -struct ClipVertex -{ - btVector3 v; - int id; - //b2ContactID id; - //b2ContactID id; -}; - -#define b2Dot(a,b) (a).dot(b) -#define b2Mul(a,b) (a)*(b) -#define b2MulT(a,b) (a).transpose()*(b) -#define b2Cross(a,b) (a).cross(b) -#define btCrossS(a,s) btVector3(s * a.getY(), -s * a.getX(),0.f) - -int b2_maxManifoldPoints =2; - -static int ClipSegmentToLine(ClipVertex vOut[2], ClipVertex vIn[2], - const btVector3& normal, btScalar offset) -{ - // Start with no output points - int numOut = 0; - - // Calculate the distance of end points to the line - btScalar distance0 = b2Dot(normal, vIn[0].v) - offset; - btScalar distance1 = b2Dot(normal, vIn[1].v) - offset; - - // If the points are behind the plane - if (distance0 <= 0.0f) vOut[numOut++] = vIn[0]; - if (distance1 <= 0.0f) vOut[numOut++] = vIn[1]; - - // If the points are on different sides of the plane - if (distance0 * distance1 < 0.0f) - { - // Find intersection point of edge and plane - btScalar interp = distance0 / (distance0 - distance1); - vOut[numOut].v = vIn[0].v + interp * (vIn[1].v - vIn[0].v); - if (distance0 > 0.0f) - { - vOut[numOut].id = vIn[0].id; - } - else - { - vOut[numOut].id = vIn[1].id; - } - ++numOut; - } - - return numOut; -} - -// Find the separation between poly1 and poly2 for a give edge normal on poly1. -static btScalar EdgeSeparation(const btBox2dShape* poly1, const btTransform& xf1, int edge1, - const btBox2dShape* poly2, const btTransform& xf2) -{ - int count1 = poly1->getVertexCount(); - const btVector3* vertices1 = poly1->getVertices(); - const btVector3* normals1 = poly1->getNormals(); - - int count2 = poly2->getVertexCount(); - const btVector3* vertices2 = poly2->getVertices(); - - btAssert(0 <= edge1 && edge1 < count1); - - // Convert normal from poly1's frame into poly2's frame. - btVector3 normal1World = b2Mul(xf1.getBasis(), normals1[edge1]); - btVector3 normal1 = b2MulT(xf2.getBasis(), normal1World); - - // Find support vertex on poly2 for -normal. - int index = 0; - btScalar minDot = BT_LARGE_FLOAT; - - for (int i = 0; i < count2; ++i) - { - btScalar dot = b2Dot(vertices2[i], normal1); - if (dot < minDot) - { - minDot = dot; - index = i; - } - } - - btVector3 v1 = b2Mul(xf1, vertices1[edge1]); - btVector3 v2 = b2Mul(xf2, vertices2[index]); - btScalar separation = b2Dot(v2 - v1, normal1World); - return separation; -} - -// Find the max separation between poly1 and poly2 using edge normals from poly1. -static btScalar FindMaxSeparation(int* edgeIndex, - const btBox2dShape* poly1, const btTransform& xf1, - const btBox2dShape* poly2, const btTransform& xf2) -{ - int count1 = poly1->getVertexCount(); - const btVector3* normals1 = poly1->getNormals(); - - // Vector pointing from the centroid of poly1 to the centroid of poly2. - btVector3 d = b2Mul(xf2, poly2->getCentroid()) - b2Mul(xf1, poly1->getCentroid()); - btVector3 dLocal1 = b2MulT(xf1.getBasis(), d); - - // Find edge normal on poly1 that has the largest projection onto d. - int edge = 0; - btScalar maxDot = -BT_LARGE_FLOAT; - for (int i = 0; i < count1; ++i) - { - btScalar dot = b2Dot(normals1[i], dLocal1); - if (dot > maxDot) - { - maxDot = dot; - edge = i; - } - } - - // Get the separation for the edge normal. - btScalar s = EdgeSeparation(poly1, xf1, edge, poly2, xf2); - if (s > 0.0f) - { - return s; - } - - // Check the separation for the previous edge normal. - int prevEdge = edge - 1 >= 0 ? edge - 1 : count1 - 1; - btScalar sPrev = EdgeSeparation(poly1, xf1, prevEdge, poly2, xf2); - if (sPrev > 0.0f) - { - return sPrev; - } - - // Check the separation for the next edge normal. - int nextEdge = edge + 1 < count1 ? edge + 1 : 0; - btScalar sNext = EdgeSeparation(poly1, xf1, nextEdge, poly2, xf2); - if (sNext > 0.0f) - { - return sNext; - } - - // Find the best edge and the search direction. - int bestEdge; - btScalar bestSeparation; - int increment; - if (sPrev > s && sPrev > sNext) - { - increment = -1; - bestEdge = prevEdge; - bestSeparation = sPrev; - } - else if (sNext > s) - { - increment = 1; - bestEdge = nextEdge; - bestSeparation = sNext; - } - else - { - *edgeIndex = edge; - return s; - } - - // Perform a local search for the best edge normal. - for ( ; ; ) - { - if (increment == -1) - edge = bestEdge - 1 >= 0 ? bestEdge - 1 : count1 - 1; - else - edge = bestEdge + 1 < count1 ? bestEdge + 1 : 0; - - s = EdgeSeparation(poly1, xf1, edge, poly2, xf2); - if (s > 0.0f) - { - return s; - } - - if (s > bestSeparation) - { - bestEdge = edge; - bestSeparation = s; - } - else - { - break; - } - } - - *edgeIndex = bestEdge; - return bestSeparation; -} - -static void FindIncidentEdge(ClipVertex c[2], - const btBox2dShape* poly1, const btTransform& xf1, int edge1, - const btBox2dShape* poly2, const btTransform& xf2) -{ - int count1 = poly1->getVertexCount(); - const btVector3* normals1 = poly1->getNormals(); - - int count2 = poly2->getVertexCount(); - const btVector3* vertices2 = poly2->getVertices(); - const btVector3* normals2 = poly2->getNormals(); - - btAssert(0 <= edge1 && edge1 < count1); - - // Get the normal of the reference edge in poly2's frame. - btVector3 normal1 = b2MulT(xf2.getBasis(), b2Mul(xf1.getBasis(), normals1[edge1])); - - // Find the incident edge on poly2. - int index = 0; - btScalar minDot = BT_LARGE_FLOAT; - for (int i = 0; i < count2; ++i) - { - btScalar dot = b2Dot(normal1, normals2[i]); - if (dot < minDot) - { - minDot = dot; - index = i; - } - } - - // Build the clip vertices for the incident edge. - int i1 = index; - int i2 = i1 + 1 < count2 ? i1 + 1 : 0; - - c[0].v = b2Mul(xf2, vertices2[i1]); -// c[0].id.features.referenceEdge = (unsigned char)edge1; -// c[0].id.features.incidentEdge = (unsigned char)i1; -// c[0].id.features.incidentVertex = 0; - - c[1].v = b2Mul(xf2, vertices2[i2]); -// c[1].id.features.referenceEdge = (unsigned char)edge1; -// c[1].id.features.incidentEdge = (unsigned char)i2; -// c[1].id.features.incidentVertex = 1; -} - -// Find edge normal of max separation on A - return if separating axis is found -// Find edge normal of max separation on B - return if separation axis is found -// Choose reference edge as min(minA, minB) -// Find incident edge -// Clip - -// The normal points from 1 to 2 -void b2CollidePolygons(btManifoldResult* manifold, - const btBox2dShape* polyA, const btTransform& xfA, - const btBox2dShape* polyB, const btTransform& xfB) -{ - - int edgeA = 0; - btScalar separationA = FindMaxSeparation(&edgeA, polyA, xfA, polyB, xfB); - if (separationA > 0.0f) - return; - - int edgeB = 0; - btScalar separationB = FindMaxSeparation(&edgeB, polyB, xfB, polyA, xfA); - if (separationB > 0.0f) - return; - - const btBox2dShape* poly1; // reference poly - const btBox2dShape* poly2; // incident poly - btTransform xf1, xf2; - int edge1; // reference edge - unsigned char flip; - const btScalar k_relativeTol = 0.98f; - const btScalar k_absoluteTol = 0.001f; - - // TODO_ERIN use "radius" of poly for absolute tolerance. - if (separationB > k_relativeTol * separationA + k_absoluteTol) - { - poly1 = polyB; - poly2 = polyA; - xf1 = xfB; - xf2 = xfA; - edge1 = edgeB; - flip = 1; - } - else - { - poly1 = polyA; - poly2 = polyB; - xf1 = xfA; - xf2 = xfB; - edge1 = edgeA; - flip = 0; - } - - ClipVertex incidentEdge[2]; - FindIncidentEdge(incidentEdge, poly1, xf1, edge1, poly2, xf2); - - int count1 = poly1->getVertexCount(); - const btVector3* vertices1 = poly1->getVertices(); - - btVector3 v11 = vertices1[edge1]; - btVector3 v12 = edge1 + 1 < count1 ? vertices1[edge1+1] : vertices1[0]; - - btVector3 dv = v12 - v11; - btVector3 sideNormal = b2Mul(xf1.getBasis(), v12 - v11); - sideNormal.normalize(); - btVector3 frontNormal = btCrossS(sideNormal, 1.0f); - - - v11 = b2Mul(xf1, v11); - v12 = b2Mul(xf1, v12); - - btScalar frontOffset = b2Dot(frontNormal, v11); - btScalar sideOffset1 = -b2Dot(sideNormal, v11); - btScalar sideOffset2 = b2Dot(sideNormal, v12); - - // Clip incident edge against extruded edge1 side edges. - ClipVertex clipPoints1[2]; - clipPoints1[0].v.setValue(0,0,0); - clipPoints1[1].v.setValue(0,0,0); - - ClipVertex clipPoints2[2]; - clipPoints2[0].v.setValue(0,0,0); - clipPoints2[1].v.setValue(0,0,0); - - - int np; - - // Clip to box side 1 - np = ClipSegmentToLine(clipPoints1, incidentEdge, -sideNormal, sideOffset1); - - if (np < 2) - return; - - // Clip to negative box side 1 - np = ClipSegmentToLine(clipPoints2, clipPoints1, sideNormal, sideOffset2); - - if (np < 2) - { - return; - } - - // Now clipPoints2 contains the clipped points. - btVector3 manifoldNormal = flip ? -frontNormal : frontNormal; - - int pointCount = 0; - for (int i = 0; i < b2_maxManifoldPoints; ++i) - { - btScalar separation = b2Dot(frontNormal, clipPoints2[i].v) - frontOffset; - - if (separation <= 0.0f) - { - - //b2ManifoldPoint* cp = manifold->points + pointCount; - //btScalar separation = separation; - //cp->localPoint1 = b2MulT(xfA, clipPoints2[i].v); - //cp->localPoint2 = b2MulT(xfB, clipPoints2[i].v); - - manifold->addContactPoint(-manifoldNormal,clipPoints2[i].v,separation); - -// cp->id = clipPoints2[i].id; -// cp->id.features.flip = flip; - ++pointCount; - } - } - -// manifold->pointCount = pointCount;} -} diff --git a/bullet/src/BulletCollision/CollisionDispatch/btBox2dBox2dCollisionAlgorithm.h b/bullet/src/BulletCollision/CollisionDispatch/btBox2dBox2dCollisionAlgorithm.h deleted file mode 100644 index 2766c3fc2..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btBox2dBox2dCollisionAlgorithm.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef BOX_2D_BOX_2D__COLLISION_ALGORITHM_H -#define BOX_2D_BOX_2D__COLLISION_ALGORITHM_H - -#include "BulletCollision/CollisionDispatch/btActivatingCollisionAlgorithm.h" -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" -#include "BulletCollision/BroadphaseCollision/btDispatcher.h" -#include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h" - -class btPersistentManifold; - -///box-box collision detection -class btBox2dBox2dCollisionAlgorithm : public btActivatingCollisionAlgorithm -{ - bool m_ownManifold; - btPersistentManifold* m_manifoldPtr; - -public: - btBox2dBox2dCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci) - : btActivatingCollisionAlgorithm(ci) {} - - virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); - - virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); - - btBox2dBox2dCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1); - - virtual ~btBox2dBox2dCollisionAlgorithm(); - - virtual void getAllContactManifolds(btManifoldArray& manifoldArray) - { - if (m_manifoldPtr && m_ownManifold) - { - manifoldArray.push_back(m_manifoldPtr); - } - } - - - struct CreateFunc :public btCollisionAlgorithmCreateFunc - { - virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1) - { - int bbsize = sizeof(btBox2dBox2dCollisionAlgorithm); - void* ptr = ci.m_dispatcher1->allocateCollisionAlgorithm(bbsize); - return new(ptr) btBox2dBox2dCollisionAlgorithm(0,ci,body0,body1); - } - }; - -}; - -#endif //BOX_2D_BOX_2D__COLLISION_ALGORITHM_H - diff --git a/bullet/src/BulletCollision/CollisionDispatch/btBoxBoxCollisionAlgorithm.cpp b/bullet/src/BulletCollision/CollisionDispatch/btBoxBoxCollisionAlgorithm.cpp deleted file mode 100644 index 765a4fad4..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btBoxBoxCollisionAlgorithm.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btBoxBoxCollisionAlgorithm.h" -#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h" -#include "BulletCollision/CollisionShapes/btBoxShape.h" -#include "BulletCollision/CollisionDispatch/btCollisionObject.h" -#include "btBoxBoxDetector.h" - -#define USE_PERSISTENT_CONTACTS 1 - -btBoxBoxCollisionAlgorithm::btBoxBoxCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* obj0,btCollisionObject* obj1) -: btActivatingCollisionAlgorithm(ci,obj0,obj1), -m_ownManifold(false), -m_manifoldPtr(mf) -{ - if (!m_manifoldPtr && m_dispatcher->needsCollision(obj0,obj1)) - { - m_manifoldPtr = m_dispatcher->getNewManifold(obj0,obj1); - m_ownManifold = true; - } -} - -btBoxBoxCollisionAlgorithm::~btBoxBoxCollisionAlgorithm() -{ - if (m_ownManifold) - { - if (m_manifoldPtr) - m_dispatcher->releaseManifold(m_manifoldPtr); - } -} - -void btBoxBoxCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) -{ - if (!m_manifoldPtr) - return; - - btCollisionObject* col0 = body0; - btCollisionObject* col1 = body1; - btBoxShape* box0 = (btBoxShape*)col0->getCollisionShape(); - btBoxShape* box1 = (btBoxShape*)col1->getCollisionShape(); - - - - /// report a contact. internally this will be kept persistent, and contact reduction is done - resultOut->setPersistentManifold(m_manifoldPtr); -#ifndef USE_PERSISTENT_CONTACTS - m_manifoldPtr->clearManifold(); -#endif //USE_PERSISTENT_CONTACTS - - btDiscreteCollisionDetectorInterface::ClosestPointInput input; - input.m_maximumDistanceSquared = BT_LARGE_FLOAT; - input.m_transformA = body0->getWorldTransform(); - input.m_transformB = body1->getWorldTransform(); - - btBoxBoxDetector detector(box0,box1); - detector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw); - -#ifdef USE_PERSISTENT_CONTACTS - // refreshContactPoints is only necessary when using persistent contact points. otherwise all points are newly added - if (m_ownManifold) - { - resultOut->refreshContactPoints(); - } -#endif //USE_PERSISTENT_CONTACTS - -} - -btScalar btBoxBoxCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* /*body0*/,btCollisionObject* /*body1*/,const btDispatcherInfo& /*dispatchInfo*/,btManifoldResult* /*resultOut*/) -{ - //not yet - return 1.f; -} diff --git a/bullet/src/BulletCollision/CollisionDispatch/btBoxBoxCollisionAlgorithm.h b/bullet/src/BulletCollision/CollisionDispatch/btBoxBoxCollisionAlgorithm.h deleted file mode 100644 index 1247c6544..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btBoxBoxCollisionAlgorithm.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef BOX_BOX__COLLISION_ALGORITHM_H -#define BOX_BOX__COLLISION_ALGORITHM_H - -#include "btActivatingCollisionAlgorithm.h" -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" -#include "BulletCollision/BroadphaseCollision/btDispatcher.h" -#include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h" - -class btPersistentManifold; - -///box-box collision detection -class btBoxBoxCollisionAlgorithm : public btActivatingCollisionAlgorithm -{ - bool m_ownManifold; - btPersistentManifold* m_manifoldPtr; - -public: - btBoxBoxCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci) - : btActivatingCollisionAlgorithm(ci) {} - - virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); - - virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); - - btBoxBoxCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1); - - virtual ~btBoxBoxCollisionAlgorithm(); - - virtual void getAllContactManifolds(btManifoldArray& manifoldArray) - { - if (m_manifoldPtr && m_ownManifold) - { - manifoldArray.push_back(m_manifoldPtr); - } - } - - - struct CreateFunc :public btCollisionAlgorithmCreateFunc - { - virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1) - { - int bbsize = sizeof(btBoxBoxCollisionAlgorithm); - void* ptr = ci.m_dispatcher1->allocateCollisionAlgorithm(bbsize); - return new(ptr) btBoxBoxCollisionAlgorithm(0,ci,body0,body1); - } - }; - -}; - -#endif //BOX_BOX__COLLISION_ALGORITHM_H - diff --git a/bullet/src/BulletCollision/CollisionDispatch/btBoxBoxDetector.cpp b/bullet/src/BulletCollision/CollisionDispatch/btBoxBoxDetector.cpp deleted file mode 100644 index 6f91cade8..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btBoxBoxDetector.cpp +++ /dev/null @@ -1,689 +0,0 @@ - -/* - * Box-Box collision detection re-distributed under the ZLib license with permission from Russell L. Smith - * Original version is from Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. - * All rights reserved. Email: russ@q12.org Web: www.q12.org - Bullet Continuous Collision Detection and Physics Library - Bullet is Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -///ODE box-box collision detection is adapted to work with Bullet - -#include "btBoxBoxDetector.h" -#include "BulletCollision/CollisionShapes/btBoxShape.h" - -#include -#include - -btBoxBoxDetector::btBoxBoxDetector(btBoxShape* box1,btBoxShape* box2) -: m_box1(box1), -m_box2(box2) -{ - -} - - -// given two boxes (p1,R1,side1) and (p2,R2,side2), collide them together and -// generate contact points. this returns 0 if there is no contact otherwise -// it returns the number of contacts generated. -// `normal' returns the contact normal. -// `depth' returns the maximum penetration depth along that normal. -// `return_code' returns a number indicating the type of contact that was -// detected: -// 1,2,3 = box 2 intersects with a face of box 1 -// 4,5,6 = box 1 intersects with a face of box 2 -// 7..15 = edge-edge contact -// `maxc' is the maximum number of contacts allowed to be generated, i.e. -// the size of the `contact' array. -// `contact' and `skip' are the contact array information provided to the -// collision functions. this function only fills in the position and depth -// fields. -struct dContactGeom; -#define dDOTpq(a,b,p,q) ((a)[0]*(b)[0] + (a)[p]*(b)[q] + (a)[2*(p)]*(b)[2*(q)]) -#define dInfinity FLT_MAX - - -/*PURE_INLINE btScalar dDOT (const btScalar *a, const btScalar *b) { return dDOTpq(a,b,1,1); } -PURE_INLINE btScalar dDOT13 (const btScalar *a, const btScalar *b) { return dDOTpq(a,b,1,3); } -PURE_INLINE btScalar dDOT31 (const btScalar *a, const btScalar *b) { return dDOTpq(a,b,3,1); } -PURE_INLINE btScalar dDOT33 (const btScalar *a, const btScalar *b) { return dDOTpq(a,b,3,3); } -*/ -static btScalar dDOT (const btScalar *a, const btScalar *b) { return dDOTpq(a,b,1,1); } -static btScalar dDOT44 (const btScalar *a, const btScalar *b) { return dDOTpq(a,b,4,4); } -static btScalar dDOT41 (const btScalar *a, const btScalar *b) { return dDOTpq(a,b,4,1); } -static btScalar dDOT14 (const btScalar *a, const btScalar *b) { return dDOTpq(a,b,1,4); } -#define dMULTIPLYOP1_331(A,op,B,C) \ -{\ - (A)[0] op dDOT41((B),(C)); \ - (A)[1] op dDOT41((B+1),(C)); \ - (A)[2] op dDOT41((B+2),(C)); \ -} - -#define dMULTIPLYOP0_331(A,op,B,C) \ -{ \ - (A)[0] op dDOT((B),(C)); \ - (A)[1] op dDOT((B+4),(C)); \ - (A)[2] op dDOT((B+8),(C)); \ -} - -#define dMULTIPLY1_331(A,B,C) dMULTIPLYOP1_331(A,=,B,C) -#define dMULTIPLY0_331(A,B,C) dMULTIPLYOP0_331(A,=,B,C) - -typedef btScalar dMatrix3[4*3]; - -void dLineClosestApproach (const btVector3& pa, const btVector3& ua, - const btVector3& pb, const btVector3& ub, - btScalar *alpha, btScalar *beta); -void dLineClosestApproach (const btVector3& pa, const btVector3& ua, - const btVector3& pb, const btVector3& ub, - btScalar *alpha, btScalar *beta) -{ - btVector3 p; - p[0] = pb[0] - pa[0]; - p[1] = pb[1] - pa[1]; - p[2] = pb[2] - pa[2]; - btScalar uaub = dDOT(ua,ub); - btScalar q1 = dDOT(ua,p); - btScalar q2 = -dDOT(ub,p); - btScalar d = 1-uaub*uaub; - if (d <= btScalar(0.0001f)) { - // @@@ this needs to be made more robust - *alpha = 0; - *beta = 0; - } - else { - d = 1.f/d; - *alpha = (q1 + uaub*q2)*d; - *beta = (uaub*q1 + q2)*d; - } -} - - - -// find all the intersection points between the 2D rectangle with vertices -// at (+/-h[0],+/-h[1]) and the 2D quadrilateral with vertices (p[0],p[1]), -// (p[2],p[3]),(p[4],p[5]),(p[6],p[7]). -// -// the intersection points are returned as x,y pairs in the 'ret' array. -// the number of intersection points is returned by the function (this will -// be in the range 0 to 8). - -static int intersectRectQuad2 (btScalar h[2], btScalar p[8], btScalar ret[16]) -{ - // q (and r) contain nq (and nr) coordinate points for the current (and - // chopped) polygons - int nq=4,nr=0; - btScalar buffer[16]; - btScalar *q = p; - btScalar *r = ret; - for (int dir=0; dir <= 1; dir++) { - // direction notation: xy[0] = x axis, xy[1] = y axis - for (int sign=-1; sign <= 1; sign += 2) { - // chop q along the line xy[dir] = sign*h[dir] - btScalar *pq = q; - btScalar *pr = r; - nr = 0; - for (int i=nq; i > 0; i--) { - // go through all points in q and all lines between adjacent points - if (sign*pq[dir] < h[dir]) { - // this point is inside the chopping line - pr[0] = pq[0]; - pr[1] = pq[1]; - pr += 2; - nr++; - if (nr & 8) { - q = r; - goto done; - } - } - btScalar *nextq = (i > 1) ? pq+2 : q; - if ((sign*pq[dir] < h[dir]) ^ (sign*nextq[dir] < h[dir])) { - // this line crosses the chopping line - pr[1-dir] = pq[1-dir] + (nextq[1-dir]-pq[1-dir]) / - (nextq[dir]-pq[dir]) * (sign*h[dir]-pq[dir]); - pr[dir] = sign*h[dir]; - pr += 2; - nr++; - if (nr & 8) { - q = r; - goto done; - } - } - pq += 2; - } - q = r; - r = (q==ret) ? buffer : ret; - nq = nr; - } - } - done: - if (q != ret) memcpy (ret,q,nr*2*sizeof(btScalar)); - return nr; -} - - -#define M__PI 3.14159265f - -// given n points in the plane (array p, of size 2*n), generate m points that -// best represent the whole set. the definition of 'best' here is not -// predetermined - the idea is to select points that give good box-box -// collision detection behavior. the chosen point indexes are returned in the -// array iret (of size m). 'i0' is always the first entry in the array. -// n must be in the range [1..8]. m must be in the range [1..n]. i0 must be -// in the range [0..n-1]. - -void cullPoints2 (int n, btScalar p[], int m, int i0, int iret[]); -void cullPoints2 (int n, btScalar p[], int m, int i0, int iret[]) -{ - // compute the centroid of the polygon in cx,cy - int i,j; - btScalar a,cx,cy,q; - if (n==1) { - cx = p[0]; - cy = p[1]; - } - else if (n==2) { - cx = btScalar(0.5)*(p[0] + p[2]); - cy = btScalar(0.5)*(p[1] + p[3]); - } - else { - a = 0; - cx = 0; - cy = 0; - for (i=0; i<(n-1); i++) { - q = p[i*2]*p[i*2+3] - p[i*2+2]*p[i*2+1]; - a += q; - cx += q*(p[i*2]+p[i*2+2]); - cy += q*(p[i*2+1]+p[i*2+3]); - } - q = p[n*2-2]*p[1] - p[0]*p[n*2-1]; - if (btFabs(a+q) > SIMD_EPSILON) - { - a = 1.f/(btScalar(3.0)*(a+q)); - } else - { - a=BT_LARGE_FLOAT; - } - cx = a*(cx + q*(p[n*2-2]+p[0])); - cy = a*(cy + q*(p[n*2-1]+p[1])); - } - - // compute the angle of each point w.r.t. the centroid - btScalar A[8]; - for (i=0; i M__PI) a -= 2*M__PI; - btScalar maxdiff=1e9,diff; - - *iret = i0; // iret is not allowed to keep this value, but it sometimes does, when diff=#QNAN0 - - for (i=0; i M__PI) diff = 2*M__PI - diff; - if (diff < maxdiff) { - maxdiff = diff; - *iret = i; - } - } - } -#if defined(DEBUG) || defined (_DEBUG) - btAssert (*iret != i0); // ensure iret got set -#endif - avail[*iret] = 0; - iret++; - } -} - - - -int dBoxBox2 (const btVector3& p1, const dMatrix3 R1, - const btVector3& side1, const btVector3& p2, - const dMatrix3 R2, const btVector3& side2, - btVector3& normal, btScalar *depth, int *return_code, - int maxc, dContactGeom * /*contact*/, int /*skip*/,btDiscreteCollisionDetectorInterface::Result& output); -int dBoxBox2 (const btVector3& p1, const dMatrix3 R1, - const btVector3& side1, const btVector3& p2, - const dMatrix3 R2, const btVector3& side2, - btVector3& normal, btScalar *depth, int *return_code, - int maxc, dContactGeom * /*contact*/, int /*skip*/,btDiscreteCollisionDetectorInterface::Result& output) -{ - const btScalar fudge_factor = btScalar(1.05); - btVector3 p,pp,normalC(0.f,0.f,0.f); - const btScalar *normalR = 0; - btScalar A[3],B[3],R11,R12,R13,R21,R22,R23,R31,R32,R33, - Q11,Q12,Q13,Q21,Q22,Q23,Q31,Q32,Q33,s,s2,l; - int i,j,invert_normal,code; - - // get vector from centers of box 1 to box 2, relative to box 1 - p = p2 - p1; - dMULTIPLY1_331 (pp,R1,p); // get pp = p relative to body 1 - - // get side lengths / 2 - A[0] = side1[0]*btScalar(0.5); - A[1] = side1[1]*btScalar(0.5); - A[2] = side1[2]*btScalar(0.5); - B[0] = side2[0]*btScalar(0.5); - B[1] = side2[1]*btScalar(0.5); - B[2] = side2[2]*btScalar(0.5); - - // Rij is R1'*R2, i.e. the relative rotation between R1 and R2 - R11 = dDOT44(R1+0,R2+0); R12 = dDOT44(R1+0,R2+1); R13 = dDOT44(R1+0,R2+2); - R21 = dDOT44(R1+1,R2+0); R22 = dDOT44(R1+1,R2+1); R23 = dDOT44(R1+1,R2+2); - R31 = dDOT44(R1+2,R2+0); R32 = dDOT44(R1+2,R2+1); R33 = dDOT44(R1+2,R2+2); - - Q11 = btFabs(R11); Q12 = btFabs(R12); Q13 = btFabs(R13); - Q21 = btFabs(R21); Q22 = btFabs(R22); Q23 = btFabs(R23); - Q31 = btFabs(R31); Q32 = btFabs(R32); Q33 = btFabs(R33); - - // for all 15 possible separating axes: - // * see if the axis separates the boxes. if so, return 0. - // * find the depth of the penetration along the separating axis (s2) - // * if this is the largest depth so far, record it. - // the normal vector will be set to the separating axis with the smallest - // depth. note: normalR is set to point to a column of R1 or R2 if that is - // the smallest depth normal so far. otherwise normalR is 0 and normalC is - // set to a vector relative to body 1. invert_normal is 1 if the sign of - // the normal should be flipped. - -#define TST(expr1,expr2,norm,cc) \ - s2 = btFabs(expr1) - (expr2); \ - if (s2 > 0) return 0; \ - if (s2 > s) { \ - s = s2; \ - normalR = norm; \ - invert_normal = ((expr1) < 0); \ - code = (cc); \ - } - - s = -dInfinity; - invert_normal = 0; - code = 0; - - // separating axis = u1,u2,u3 - TST (pp[0],(A[0] + B[0]*Q11 + B[1]*Q12 + B[2]*Q13),R1+0,1); - TST (pp[1],(A[1] + B[0]*Q21 + B[1]*Q22 + B[2]*Q23),R1+1,2); - TST (pp[2],(A[2] + B[0]*Q31 + B[1]*Q32 + B[2]*Q33),R1+2,3); - - // separating axis = v1,v2,v3 - TST (dDOT41(R2+0,p),(A[0]*Q11 + A[1]*Q21 + A[2]*Q31 + B[0]),R2+0,4); - TST (dDOT41(R2+1,p),(A[0]*Q12 + A[1]*Q22 + A[2]*Q32 + B[1]),R2+1,5); - TST (dDOT41(R2+2,p),(A[0]*Q13 + A[1]*Q23 + A[2]*Q33 + B[2]),R2+2,6); - - // note: cross product axes need to be scaled when s is computed. - // normal (n1,n2,n3) is relative to box 1. -#undef TST -#define TST(expr1,expr2,n1,n2,n3,cc) \ - s2 = btFabs(expr1) - (expr2); \ - if (s2 > SIMD_EPSILON) return 0; \ - l = btSqrt((n1)*(n1) + (n2)*(n2) + (n3)*(n3)); \ - if (l > SIMD_EPSILON) { \ - s2 /= l; \ - if (s2*fudge_factor > s) { \ - s = s2; \ - normalR = 0; \ - normalC[0] = (n1)/l; normalC[1] = (n2)/l; normalC[2] = (n3)/l; \ - invert_normal = ((expr1) < 0); \ - code = (cc); \ - } \ - } - - // separating axis = u1 x (v1,v2,v3) - TST(pp[2]*R21-pp[1]*R31,(A[1]*Q31+A[2]*Q21+B[1]*Q13+B[2]*Q12),0,-R31,R21,7); - TST(pp[2]*R22-pp[1]*R32,(A[1]*Q32+A[2]*Q22+B[0]*Q13+B[2]*Q11),0,-R32,R22,8); - TST(pp[2]*R23-pp[1]*R33,(A[1]*Q33+A[2]*Q23+B[0]*Q12+B[1]*Q11),0,-R33,R23,9); - - // separating axis = u2 x (v1,v2,v3) - TST(pp[0]*R31-pp[2]*R11,(A[0]*Q31+A[2]*Q11+B[1]*Q23+B[2]*Q22),R31,0,-R11,10); - TST(pp[0]*R32-pp[2]*R12,(A[0]*Q32+A[2]*Q12+B[0]*Q23+B[2]*Q21),R32,0,-R12,11); - TST(pp[0]*R33-pp[2]*R13,(A[0]*Q33+A[2]*Q13+B[0]*Q22+B[1]*Q21),R33,0,-R13,12); - - // separating axis = u3 x (v1,v2,v3) - TST(pp[1]*R11-pp[0]*R21,(A[0]*Q21+A[1]*Q11+B[1]*Q33+B[2]*Q32),-R21,R11,0,13); - TST(pp[1]*R12-pp[0]*R22,(A[0]*Q22+A[1]*Q12+B[0]*Q33+B[2]*Q31),-R22,R12,0,14); - TST(pp[1]*R13-pp[0]*R23,(A[0]*Q23+A[1]*Q13+B[0]*Q32+B[1]*Q31),-R23,R13,0,15); - -#undef TST - - if (!code) return 0; - - // if we get to this point, the boxes interpenetrate. compute the normal - // in global coordinates. - if (normalR) { - normal[0] = normalR[0]; - normal[1] = normalR[4]; - normal[2] = normalR[8]; - } - else { - dMULTIPLY0_331 (normal,R1,normalC); - } - if (invert_normal) { - normal[0] = -normal[0]; - normal[1] = -normal[1]; - normal[2] = -normal[2]; - } - *depth = -s; - - // compute contact point(s) - - if (code > 6) { - // an edge from box 1 touches an edge from box 2. - // find a point pa on the intersecting edge of box 1 - btVector3 pa; - btScalar sign; - for (i=0; i<3; i++) pa[i] = p1[i]; - for (j=0; j<3; j++) { - sign = (dDOT14(normal,R1+j) > 0) ? btScalar(1.0) : btScalar(-1.0); - for (i=0; i<3; i++) pa[i] += sign * A[j] * R1[i*4+j]; - } - - // find a point pb on the intersecting edge of box 2 - btVector3 pb; - for (i=0; i<3; i++) pb[i] = p2[i]; - for (j=0; j<3; j++) { - sign = (dDOT14(normal,R2+j) > 0) ? btScalar(-1.0) : btScalar(1.0); - for (i=0; i<3; i++) pb[i] += sign * B[j] * R2[i*4+j]; - } - - btScalar alpha,beta; - btVector3 ua,ub; - for (i=0; i<3; i++) ua[i] = R1[((code)-7)/3 + i*4]; - for (i=0; i<3; i++) ub[i] = R2[((code)-7)%3 + i*4]; - - dLineClosestApproach (pa,ua,pb,ub,&alpha,&beta); - for (i=0; i<3; i++) pa[i] += ua[i]*alpha; - for (i=0; i<3; i++) pb[i] += ub[i]*beta; - - { - - //contact[0].pos[i] = btScalar(0.5)*(pa[i]+pb[i]); - //contact[0].depth = *depth; - btVector3 pointInWorld; - -#ifdef USE_CENTER_POINT - for (i=0; i<3; i++) - pointInWorld[i] = (pa[i]+pb[i])*btScalar(0.5); - output.addContactPoint(-normal,pointInWorld,-*depth); -#else - output.addContactPoint(-normal,pb,-*depth); -#endif // - *return_code = code; - } - return 1; - } - - // okay, we have a face-something intersection (because the separating - // axis is perpendicular to a face). define face 'a' to be the reference - // face (i.e. the normal vector is perpendicular to this) and face 'b' to be - // the incident face (the closest face of the other box). - - const btScalar *Ra,*Rb,*pa,*pb,*Sa,*Sb; - if (code <= 3) { - Ra = R1; - Rb = R2; - pa = p1; - pb = p2; - Sa = A; - Sb = B; - } - else { - Ra = R2; - Rb = R1; - pa = p2; - pb = p1; - Sa = B; - Sb = A; - } - - // nr = normal vector of reference face dotted with axes of incident box. - // anr = absolute values of nr. - btVector3 normal2,nr,anr; - if (code <= 3) { - normal2[0] = normal[0]; - normal2[1] = normal[1]; - normal2[2] = normal[2]; - } - else { - normal2[0] = -normal[0]; - normal2[1] = -normal[1]; - normal2[2] = -normal[2]; - } - dMULTIPLY1_331 (nr,Rb,normal2); - anr[0] = btFabs (nr[0]); - anr[1] = btFabs (nr[1]); - anr[2] = btFabs (nr[2]); - - // find the largest compontent of anr: this corresponds to the normal - // for the indident face. the other axis numbers of the indicent face - // are stored in a1,a2. - int lanr,a1,a2; - if (anr[1] > anr[0]) { - if (anr[1] > anr[2]) { - a1 = 0; - lanr = 1; - a2 = 2; - } - else { - a1 = 0; - a2 = 1; - lanr = 2; - } - } - else { - if (anr[0] > anr[2]) { - lanr = 0; - a1 = 1; - a2 = 2; - } - else { - a1 = 0; - a2 = 1; - lanr = 2; - } - } - - // compute center point of incident face, in reference-face coordinates - btVector3 center; - if (nr[lanr] < 0) { - for (i=0; i<3; i++) center[i] = pb[i] - pa[i] + Sb[lanr] * Rb[i*4+lanr]; - } - else { - for (i=0; i<3; i++) center[i] = pb[i] - pa[i] - Sb[lanr] * Rb[i*4+lanr]; - } - - // find the normal and non-normal axis numbers of the reference box - int codeN,code1,code2; - if (code <= 3) codeN = code-1; else codeN = code-4; - if (codeN==0) { - code1 = 1; - code2 = 2; - } - else if (codeN==1) { - code1 = 0; - code2 = 2; - } - else { - code1 = 0; - code2 = 1; - } - - // find the four corners of the incident face, in reference-face coordinates - btScalar quad[8]; // 2D coordinate of incident face (x,y pairs) - btScalar c1,c2,m11,m12,m21,m22; - c1 = dDOT14 (center,Ra+code1); - c2 = dDOT14 (center,Ra+code2); - // optimize this? - we have already computed this data above, but it is not - // stored in an easy-to-index format. for now it's quicker just to recompute - // the four dot products. - m11 = dDOT44 (Ra+code1,Rb+a1); - m12 = dDOT44 (Ra+code1,Rb+a2); - m21 = dDOT44 (Ra+code2,Rb+a1); - m22 = dDOT44 (Ra+code2,Rb+a2); - { - btScalar k1 = m11*Sb[a1]; - btScalar k2 = m21*Sb[a1]; - btScalar k3 = m12*Sb[a2]; - btScalar k4 = m22*Sb[a2]; - quad[0] = c1 - k1 - k3; - quad[1] = c2 - k2 - k4; - quad[2] = c1 - k1 + k3; - quad[3] = c2 - k2 + k4; - quad[4] = c1 + k1 + k3; - quad[5] = c2 + k2 + k4; - quad[6] = c1 + k1 - k3; - quad[7] = c2 + k2 - k4; - } - - // find the size of the reference face - btScalar rect[2]; - rect[0] = Sa[code1]; - rect[1] = Sa[code2]; - - // intersect the incident and reference faces - btScalar ret[16]; - int n = intersectRectQuad2 (rect,quad,ret); - if (n < 1) return 0; // this should never happen - - // convert the intersection points into reference-face coordinates, - // and compute the contact position and depth for each point. only keep - // those points that have a positive (penetrating) depth. delete points in - // the 'ret' array as necessary so that 'point' and 'ret' correspond. - btScalar point[3*8]; // penetrating contact points - btScalar dep[8]; // depths for those points - btScalar det1 = 1.f/(m11*m22 - m12*m21); - m11 *= det1; - m12 *= det1; - m21 *= det1; - m22 *= det1; - int cnum = 0; // number of penetrating contact points found - for (j=0; j < n; j++) { - btScalar k1 = m22*(ret[j*2]-c1) - m12*(ret[j*2+1]-c2); - btScalar k2 = -m21*(ret[j*2]-c1) + m11*(ret[j*2+1]-c2); - for (i=0; i<3; i++) point[cnum*3+i] = - center[i] + k1*Rb[i*4+a1] + k2*Rb[i*4+a2]; - dep[cnum] = Sa[codeN] - dDOT(normal2,point+cnum*3); - if (dep[cnum] >= 0) { - ret[cnum*2] = ret[j*2]; - ret[cnum*2+1] = ret[j*2+1]; - cnum++; - } - } - if (cnum < 1) return 0; // this should never happen - - // we can't generate more contacts than we actually have - if (maxc > cnum) maxc = cnum; - if (maxc < 1) maxc = 1; - - if (cnum <= maxc) { - // we have less contacts than we need, so we use them all - for (j=0; j < cnum; j++) { - - //AddContactPoint... - - //dContactGeom *con = CONTACT(contact,skip*j); - //for (i=0; i<3; i++) con->pos[i] = point[j*3+i] + pa[i]; - //con->depth = dep[j]; - - btVector3 pointInWorld; - for (i=0; i<3; i++) - pointInWorld[i] = point[j*3+i] + pa[i]; - output.addContactPoint(-normal,pointInWorld,-dep[j]); - - } - } - else { - // we have more contacts than are wanted, some of them must be culled. - // find the deepest point, it is always the first contact. - int i1 = 0; - btScalar maxdepth = dep[0]; - for (i=1; i maxdepth) { - maxdepth = dep[i]; - i1 = i; - } - } - - int iret[8]; - cullPoints2 (cnum,ret,maxc,i1,iret); - - for (j=0; j < maxc; j++) { -// dContactGeom *con = CONTACT(contact,skip*j); - // for (i=0; i<3; i++) con->pos[i] = point[iret[j]*3+i] + pa[i]; - // con->depth = dep[iret[j]]; - - btVector3 posInWorld; - for (i=0; i<3; i++) - posInWorld[i] = point[iret[j]*3+i] + pa[i]; - output.addContactPoint(-normal,posInWorld,-dep[iret[j]]); - } - cnum = maxc; - } - - *return_code = code; - return cnum; -} - -void btBoxBoxDetector::getClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* /*debugDraw*/,bool /*swapResults*/) -{ - - const btTransform& transformA = input.m_transformA; - const btTransform& transformB = input.m_transformB; - - int skip = 0; - dContactGeom *contact = 0; - - dMatrix3 R1; - dMatrix3 R2; - - for (int j=0;j<3;j++) - { - R1[0+4*j] = transformA.getBasis()[j].x(); - R2[0+4*j] = transformB.getBasis()[j].x(); - - R1[1+4*j] = transformA.getBasis()[j].y(); - R2[1+4*j] = transformB.getBasis()[j].y(); - - - R1[2+4*j] = transformA.getBasis()[j].z(); - R2[2+4*j] = transformB.getBasis()[j].z(); - - } - - - - btVector3 normal; - btScalar depth; - int return_code; - int maxc = 4; - - - dBoxBox2 (transformA.getOrigin(), - R1, - 2.f*m_box1->getHalfExtentsWithMargin(), - transformB.getOrigin(), - R2, - 2.f*m_box2->getHalfExtentsWithMargin(), - normal, &depth, &return_code, - maxc, contact, skip, - output - ); - -} diff --git a/bullet/src/BulletCollision/CollisionDispatch/btBoxBoxDetector.h b/bullet/src/BulletCollision/CollisionDispatch/btBoxBoxDetector.h deleted file mode 100644 index eacc90e85..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btBoxBoxDetector.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Box-Box collision detection re-distributed under the ZLib license with permission from Russell L. Smith - * Original version is from Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. - * All rights reserved. Email: russ@q12.org Web: www.q12.org - -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ -#ifndef BOX_BOX_DETECTOR_H -#define BOX_BOX_DETECTOR_H - - -class btBoxShape; -#include "BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h" - - -/// btBoxBoxDetector wraps the ODE box-box collision detector -/// re-distributed under the Zlib license with permission from Russell L. Smith -struct btBoxBoxDetector : public btDiscreteCollisionDetectorInterface -{ - btBoxShape* m_box1; - btBoxShape* m_box2; - -public: - - btBoxBoxDetector(btBoxShape* box1,btBoxShape* box2); - - virtual ~btBoxBoxDetector() {}; - - virtual void getClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw,bool swapResults=false); - -}; - -#endif //BT_BOX_BOX_DETECTOR_H diff --git a/bullet/src/BulletCollision/CollisionDispatch/btCollisionConfiguration.h b/bullet/src/BulletCollision/CollisionDispatch/btCollisionConfiguration.h deleted file mode 100644 index 76d3a6e52..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btCollisionConfiguration.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef BT_COLLISION_CONFIGURATION -#define BT_COLLISION_CONFIGURATION -struct btCollisionAlgorithmCreateFunc; - -class btStackAlloc; -class btPoolAllocator; - -///btCollisionConfiguration allows to configure Bullet collision detection -///stack allocator size, default collision algorithms and persistent manifold pool size -///@todo: describe the meaning -class btCollisionConfiguration -{ - -public: - - virtual ~btCollisionConfiguration() - { - } - - ///memory pools - virtual btPoolAllocator* getPersistentManifoldPool() = 0; - - virtual btPoolAllocator* getCollisionAlgorithmPool() = 0; - - virtual btStackAlloc* getStackAllocator() = 0; - - virtual btCollisionAlgorithmCreateFunc* getCollisionAlgorithmCreateFunc(int proxyType0,int proxyType1) =0; - -}; - -#endif //BT_COLLISION_CONFIGURATION - diff --git a/bullet/src/BulletCollision/CollisionDispatch/btCollisionCreateFunc.h b/bullet/src/BulletCollision/CollisionDispatch/btCollisionCreateFunc.h deleted file mode 100644 index 3ee299277..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btCollisionCreateFunc.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef COLLISION_CREATE_FUNC -#define COLLISION_CREATE_FUNC - -#include "LinearMath/btAlignedObjectArray.h" -class btCollisionAlgorithm; -class btCollisionObject; - -struct btCollisionAlgorithmConstructionInfo; - -///Used by the btCollisionDispatcher to register and create instances for btCollisionAlgorithm -struct btCollisionAlgorithmCreateFunc -{ - bool m_swapped; - - btCollisionAlgorithmCreateFunc() - :m_swapped(false) - { - } - virtual ~btCollisionAlgorithmCreateFunc(){}; - - virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& , btCollisionObject* body0,btCollisionObject* body1) - { - - (void)body0; - (void)body1; - return 0; - } -}; -#endif //COLLISION_CREATE_FUNC - diff --git a/bullet/src/BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp b/bullet/src/BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp deleted file mode 100644 index 6452098d3..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp +++ /dev/null @@ -1,303 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - - -#include "btCollisionDispatcher.h" - - -#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h" - -#include "BulletCollision/CollisionShapes/btCollisionShape.h" -#include "BulletCollision/CollisionDispatch/btCollisionObject.h" -#include "BulletCollision/BroadphaseCollision/btOverlappingPairCache.h" -#include "LinearMath/btPoolAllocator.h" -#include "BulletCollision/CollisionDispatch/btCollisionConfiguration.h" - -int gNumManifold = 0; - -#ifdef BT_DEBUG -#include -#endif - - -btCollisionDispatcher::btCollisionDispatcher (btCollisionConfiguration* collisionConfiguration): - m_count(0), - m_useIslands(true), - m_staticWarningReported(false), - m_collisionConfiguration(collisionConfiguration) -{ - int i; - - setNearCallback(defaultNearCallback); - - m_collisionAlgorithmPoolAllocator = collisionConfiguration->getCollisionAlgorithmPool(); - - m_persistentManifoldPoolAllocator = collisionConfiguration->getPersistentManifoldPool(); - - for (i=0;igetCollisionAlgorithmCreateFunc(i,j); - btAssert(m_doubleDispatch[i][j]); - } - } - - -} - - -void btCollisionDispatcher::registerCollisionCreateFunc(int proxyType0, int proxyType1, btCollisionAlgorithmCreateFunc *createFunc) -{ - m_doubleDispatch[proxyType0][proxyType1] = createFunc; -} - -btCollisionDispatcher::~btCollisionDispatcher() -{ -} - -btPersistentManifold* btCollisionDispatcher::getNewManifold(void* b0,void* b1) -{ - gNumManifold++; - - //btAssert(gNumManifold < 65535); - - - btCollisionObject* body0 = (btCollisionObject*)b0; - btCollisionObject* body1 = (btCollisionObject*)b1; - - //test for Bullet 2.74: use a relative contact breaking threshold without clamping against 'gContactBreakingThreshold' - //btScalar contactBreakingThreshold = btMin(gContactBreakingThreshold,btMin(body0->getCollisionShape()->getContactBreakingThreshold(),body1->getCollisionShape()->getContactBreakingThreshold())); - btScalar contactBreakingThreshold = btMin(body0->getCollisionShape()->getContactBreakingThreshold(),body1->getCollisionShape()->getContactBreakingThreshold()); - - btScalar contactProcessingThreshold = btMin(body0->getContactProcessingThreshold(),body1->getContactProcessingThreshold()); - - void* mem = 0; - - if (m_persistentManifoldPoolAllocator->getFreeCount()) - { - mem = m_persistentManifoldPoolAllocator->allocate(sizeof(btPersistentManifold)); - } else - { - mem = btAlignedAlloc(sizeof(btPersistentManifold),16); - - } - btPersistentManifold* manifold = new(mem) btPersistentManifold (body0,body1,0,contactBreakingThreshold,contactProcessingThreshold); - manifold->m_index1a = m_manifoldsPtr.size(); - m_manifoldsPtr.push_back(manifold); - - return manifold; -} - -void btCollisionDispatcher::clearManifold(btPersistentManifold* manifold) -{ - manifold->clearManifold(); -} - - -void btCollisionDispatcher::releaseManifold(btPersistentManifold* manifold) -{ - - gNumManifold--; - - //printf("releaseManifold: gNumManifold %d\n",gNumManifold); - clearManifold(manifold); - - int findIndex = manifold->m_index1a; - btAssert(findIndex < m_manifoldsPtr.size()); - m_manifoldsPtr.swap(findIndex,m_manifoldsPtr.size()-1); - m_manifoldsPtr[findIndex]->m_index1a = findIndex; - m_manifoldsPtr.pop_back(); - - manifold->~btPersistentManifold(); - if (m_persistentManifoldPoolAllocator->validPtr(manifold)) - { - m_persistentManifoldPoolAllocator->freeMemory(manifold); - } else - { - btAlignedFree(manifold); - } - -} - - - -btCollisionAlgorithm* btCollisionDispatcher::findAlgorithm(btCollisionObject* body0,btCollisionObject* body1,btPersistentManifold* sharedManifold) -{ - - btCollisionAlgorithmConstructionInfo ci; - - ci.m_dispatcher1 = this; - ci.m_manifold = sharedManifold; - btCollisionAlgorithm* algo = m_doubleDispatch[body0->getCollisionShape()->getShapeType()][body1->getCollisionShape()->getShapeType()]->CreateCollisionAlgorithm(ci,body0,body1); - - return algo; -} - - - - -bool btCollisionDispatcher::needsResponse(btCollisionObject* body0,btCollisionObject* body1) -{ - //here you can do filtering - bool hasResponse = - (body0->hasContactResponse() && body1->hasContactResponse()); - //no response between two static/kinematic bodies: - hasResponse = hasResponse && - ((!body0->isStaticOrKinematicObject()) ||(! body1->isStaticOrKinematicObject())); - return hasResponse; -} - -bool btCollisionDispatcher::needsCollision(btCollisionObject* body0,btCollisionObject* body1) -{ - btAssert(body0); - btAssert(body1); - - bool needsCollision = true; - -#ifdef BT_DEBUG - if (!m_staticWarningReported) - { - //broadphase filtering already deals with this - if ((body0->isStaticObject() || body0->isKinematicObject()) && - (body1->isStaticObject() || body1->isKinematicObject())) - { - m_staticWarningReported = true; - printf("warning btCollisionDispatcher::needsCollision: static-static collision!\n"); - } - } -#endif //BT_DEBUG - - if ((!body0->isActive()) && (!body1->isActive())) - needsCollision = false; - else if (!body0->checkCollideWith(body1)) - needsCollision = false; - - return needsCollision ; - -} - - - -///interface for iterating all overlapping collision pairs, no matter how those pairs are stored (array, set, map etc) -///this is useful for the collision dispatcher. -class btCollisionPairCallback : public btOverlapCallback -{ - const btDispatcherInfo& m_dispatchInfo; - btCollisionDispatcher* m_dispatcher; - -public: - - btCollisionPairCallback(const btDispatcherInfo& dispatchInfo,btCollisionDispatcher* dispatcher) - :m_dispatchInfo(dispatchInfo), - m_dispatcher(dispatcher) - { - } - - /*btCollisionPairCallback& operator=(btCollisionPairCallback& other) - { - m_dispatchInfo = other.m_dispatchInfo; - m_dispatcher = other.m_dispatcher; - return *this; - } - */ - - - virtual ~btCollisionPairCallback() {} - - - virtual bool processOverlap(btBroadphasePair& pair) - { - (*m_dispatcher->getNearCallback())(pair,*m_dispatcher,m_dispatchInfo); - - return false; - } -}; - - - -void btCollisionDispatcher::dispatchAllCollisionPairs(btOverlappingPairCache* pairCache,const btDispatcherInfo& dispatchInfo,btDispatcher* dispatcher) -{ - //m_blockedForChanges = true; - - btCollisionPairCallback collisionCallback(dispatchInfo,this); - - pairCache->processAllOverlappingPairs(&collisionCallback,dispatcher); - - //m_blockedForChanges = false; - -} - - - - -//by default, Bullet will use this near callback -void btCollisionDispatcher::defaultNearCallback(btBroadphasePair& collisionPair, btCollisionDispatcher& dispatcher, const btDispatcherInfo& dispatchInfo) -{ - btCollisionObject* colObj0 = (btCollisionObject*)collisionPair.m_pProxy0->m_clientObject; - btCollisionObject* colObj1 = (btCollisionObject*)collisionPair.m_pProxy1->m_clientObject; - - if (dispatcher.needsCollision(colObj0,colObj1)) - { - //dispatcher will keep algorithms persistent in the collision pair - if (!collisionPair.m_algorithm) - { - collisionPair.m_algorithm = dispatcher.findAlgorithm(colObj0,colObj1); - } - - if (collisionPair.m_algorithm) - { - btManifoldResult contactPointResult(colObj0,colObj1); - - if (dispatchInfo.m_dispatchFunc == btDispatcherInfo::DISPATCH_DISCRETE) - { - //discrete collision detection query - collisionPair.m_algorithm->processCollision(colObj0,colObj1,dispatchInfo,&contactPointResult); - } else - { - //continuous collision detection query, time of impact (toi) - btScalar toi = collisionPair.m_algorithm->calculateTimeOfImpact(colObj0,colObj1,dispatchInfo,&contactPointResult); - if (dispatchInfo.m_timeOfImpact > toi) - dispatchInfo.m_timeOfImpact = toi; - - } - } - } - -} - - -void* btCollisionDispatcher::allocateCollisionAlgorithm(int size) -{ - if (m_collisionAlgorithmPoolAllocator->getFreeCount()) - { - return m_collisionAlgorithmPoolAllocator->allocate(size); - } - - //warn user for overflow? - return btAlignedAlloc(static_cast(size), 16); -} - -void btCollisionDispatcher::freeCollisionAlgorithm(void* ptr) -{ - if (m_collisionAlgorithmPoolAllocator->validPtr(ptr)) - { - m_collisionAlgorithmPoolAllocator->freeMemory(ptr); - } else - { - btAlignedFree(ptr); - } -} diff --git a/bullet/src/BulletCollision/CollisionDispatch/btCollisionDispatcher.h b/bullet/src/BulletCollision/CollisionDispatch/btCollisionDispatcher.h deleted file mode 100644 index 7ef9466c0..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btCollisionDispatcher.h +++ /dev/null @@ -1,147 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef COLLISION__DISPATCHER_H -#define COLLISION__DISPATCHER_H - -#include "BulletCollision/BroadphaseCollision/btDispatcher.h" -#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h" - -#include "BulletCollision/CollisionDispatch/btManifoldResult.h" - -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" -#include "LinearMath/btAlignedObjectArray.h" - -class btIDebugDraw; -class btOverlappingPairCache; -class btPoolAllocator; -class btCollisionConfiguration; - -#include "btCollisionCreateFunc.h" - -#define USE_DISPATCH_REGISTRY_ARRAY 1 - -class btCollisionDispatcher; -///user can override this nearcallback for collision filtering and more finegrained control over collision detection -typedef void (*btNearCallback)(btBroadphasePair& collisionPair, btCollisionDispatcher& dispatcher, const btDispatcherInfo& dispatchInfo); - - -///btCollisionDispatcher supports algorithms that handle ConvexConvex and ConvexConcave collision pairs. -///Time of Impact, Closest Points and Penetration Depth. -class btCollisionDispatcher : public btDispatcher -{ - int m_count; - - btAlignedObjectArray m_manifoldsPtr; - - bool m_useIslands; - - bool m_staticWarningReported; - - btManifoldResult m_defaultManifoldResult; - - btNearCallback m_nearCallback; - - btPoolAllocator* m_collisionAlgorithmPoolAllocator; - - btPoolAllocator* m_persistentManifoldPoolAllocator; - - btCollisionAlgorithmCreateFunc* m_doubleDispatch[MAX_BROADPHASE_COLLISION_TYPES][MAX_BROADPHASE_COLLISION_TYPES]; - - - btCollisionConfiguration* m_collisionConfiguration; - - -public: - - ///registerCollisionCreateFunc allows registration of custom/alternative collision create functions - void registerCollisionCreateFunc(int proxyType0,int proxyType1, btCollisionAlgorithmCreateFunc* createFunc); - - int getNumManifolds() const - { - return int( m_manifoldsPtr.size()); - } - - btPersistentManifold** getInternalManifoldPointer() - { - return &m_manifoldsPtr[0]; - } - - btPersistentManifold* getManifoldByIndexInternal(int index) - { - return m_manifoldsPtr[index]; - } - - const btPersistentManifold* getManifoldByIndexInternal(int index) const - { - return m_manifoldsPtr[index]; - } - - btCollisionDispatcher (btCollisionConfiguration* collisionConfiguration); - - virtual ~btCollisionDispatcher(); - - virtual btPersistentManifold* getNewManifold(void* b0,void* b1); - - virtual void releaseManifold(btPersistentManifold* manifold); - - - virtual void clearManifold(btPersistentManifold* manifold); - - - btCollisionAlgorithm* findAlgorithm(btCollisionObject* body0,btCollisionObject* body1,btPersistentManifold* sharedManifold = 0); - - virtual bool needsCollision(btCollisionObject* body0,btCollisionObject* body1); - - virtual bool needsResponse(btCollisionObject* body0,btCollisionObject* body1); - - virtual void dispatchAllCollisionPairs(btOverlappingPairCache* pairCache,const btDispatcherInfo& dispatchInfo,btDispatcher* dispatcher) ; - - void setNearCallback(btNearCallback nearCallback) - { - m_nearCallback = nearCallback; - } - - btNearCallback getNearCallback() const - { - return m_nearCallback; - } - - //by default, Bullet will use this near callback - static void defaultNearCallback(btBroadphasePair& collisionPair, btCollisionDispatcher& dispatcher, const btDispatcherInfo& dispatchInfo); - - virtual void* allocateCollisionAlgorithm(int size); - - virtual void freeCollisionAlgorithm(void* ptr); - - btCollisionConfiguration* getCollisionConfiguration() - { - return m_collisionConfiguration; - } - - const btCollisionConfiguration* getCollisionConfiguration() const - { - return m_collisionConfiguration; - } - - void setCollisionConfiguration(btCollisionConfiguration* config) - { - m_collisionConfiguration = config; - } - -}; - -#endif //COLLISION__DISPATCHER_H - diff --git a/bullet/src/BulletCollision/CollisionDispatch/btCollisionObject.cpp b/bullet/src/BulletCollision/CollisionDispatch/btCollisionObject.cpp deleted file mode 100644 index 17b31459a..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btCollisionObject.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#include "btCollisionObject.h" - -btCollisionObject::btCollisionObject() - : m_anisotropicFriction(1.f,1.f,1.f), - m_hasAnisotropicFriction(false), - m_contactProcessingThreshold(BT_LARGE_FLOAT), - m_broadphaseHandle(0), - m_collisionShape(0), - m_rootCollisionShape(0), - m_collisionFlags(btCollisionObject::CF_STATIC_OBJECT), - m_islandTag1(-1), - m_companionId(-1), - m_activationState1(1), - m_deactivationTime(btScalar(0.)), - m_friction(btScalar(0.5)), - m_restitution(btScalar(0.)), - m_userObjectPointer(0), - m_internalType(CO_COLLISION_OBJECT), - m_hitFraction(btScalar(1.)), - m_ccdSweptSphereRadius(btScalar(0.)), - m_ccdMotionThreshold(btScalar(0.)), - m_checkCollideWith(false) -{ - m_worldTransform.setIdentity(); -} - -btCollisionObject::~btCollisionObject() -{ -} - -void btCollisionObject::setActivationState(int newState) -{ - if ( (m_activationState1 != DISABLE_DEACTIVATION) && (m_activationState1 != DISABLE_SIMULATION)) - m_activationState1 = newState; -} - -void btCollisionObject::forceActivationState(int newState) -{ - m_activationState1 = newState; -} - -void btCollisionObject::activate(bool forceActivation) -{ - if (forceActivation || !(m_collisionFlags & (CF_STATIC_OBJECT|CF_KINEMATIC_OBJECT))) - { - setActivationState(ACTIVE_TAG); - m_deactivationTime = btScalar(0.); - } -} - - - diff --git a/bullet/src/BulletCollision/CollisionDispatch/btCollisionObject.h b/bullet/src/BulletCollision/CollisionDispatch/btCollisionObject.h deleted file mode 100644 index 76fbd603e..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btCollisionObject.h +++ /dev/null @@ -1,498 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef COLLISION_OBJECT_H -#define COLLISION_OBJECT_H - -#include "LinearMath/btTransform.h" - -//island management, m_activationState1 -#define ACTIVE_TAG 1 -#define ISLAND_SLEEPING 2 -#define WANTS_DEACTIVATION 3 -#define DISABLE_DEACTIVATION 4 -#define DISABLE_SIMULATION 5 - -struct btBroadphaseProxy; -class btCollisionShape; -struct btCollisionShapeData; -#include "LinearMath/btMotionState.h" -#include "LinearMath/btAlignedAllocator.h" -#include "LinearMath/btAlignedObjectArray.h" - -typedef btAlignedObjectArray btCollisionObjectArray; - - -/// btCollisionObject can be used to manage collision detection objects. -/// btCollisionObject maintains all information that is needed for a collision detection: Shape, Transform and AABB proxy. -/// They can be added to the btCollisionWorld. -ATTRIBUTE_ALIGNED16(class) btCollisionObject -{ - -protected: - - btTransform m_worldTransform; - - ///m_interpolationWorldTransform is used for CCD and interpolation - ///it can be either previous or future (predicted) transform - btTransform m_interpolationWorldTransform; - //those two are experimental: just added for bullet time effect, so you can still apply impulses (directly modifying velocities) - //without destroying the continuous interpolated motion (which uses this interpolation velocities) - btVector3 m_interpolationLinearVelocity; - btVector3 m_interpolationAngularVelocity; - - btVector3 m_anisotropicFriction; - int m_hasAnisotropicFriction; - btScalar m_contactProcessingThreshold; - - btBroadphaseProxy* m_broadphaseHandle; - btCollisionShape* m_collisionShape; - - ///m_rootCollisionShape is temporarily used to store the original collision shape - ///The m_collisionShape might be temporarily replaced by a child collision shape during collision detection purposes - ///If it is NULL, the m_collisionShape is not temporarily replaced. - btCollisionShape* m_rootCollisionShape; - - int m_collisionFlags; - - int m_islandTag1; - int m_companionId; - - int m_activationState1; - btScalar m_deactivationTime; - - btScalar m_friction; - btScalar m_restitution; - - ///m_internalType is reserved to distinguish Bullet's btCollisionObject, btRigidBody, btSoftBody, btGhostObject etc. - ///do not assign your own m_internalType unless you write a new dynamics object class. - int m_internalType; - - ///users can point to their objects, m_userPointer is not used by Bullet, see setUserPointer/getUserPointer - void* m_userObjectPointer; - - ///time of impact calculation - btScalar m_hitFraction; - - ///Swept sphere radius (0.0 by default), see btConvexConvexAlgorithm:: - btScalar m_ccdSweptSphereRadius; - - /// Don't do continuous collision detection if the motion (in one step) is less then m_ccdMotionThreshold - btScalar m_ccdMotionThreshold; - - /// If some object should have elaborate collision filtering by sub-classes - int m_checkCollideWith; - - virtual bool checkCollideWithOverride(btCollisionObject* /* co */) - { - return true; - } - -public: - - BT_DECLARE_ALIGNED_ALLOCATOR(); - - enum CollisionFlags - { - CF_STATIC_OBJECT= 1, - CF_KINEMATIC_OBJECT= 2, - CF_NO_CONTACT_RESPONSE = 4, - CF_CUSTOM_MATERIAL_CALLBACK = 8,//this allows per-triangle material (friction/restitution) - CF_CHARACTER_OBJECT = 16 - }; - - enum CollisionObjectTypes - { - CO_COLLISION_OBJECT =1, - CO_RIGID_BODY, - ///CO_GHOST_OBJECT keeps track of all objects overlapping its AABB and that pass its collision filter - ///It is useful for collision sensors, explosion objects, character controller etc. - CO_GHOST_OBJECT, - CO_SOFT_BODY, - CO_HF_FLUID - }; - - SIMD_FORCE_INLINE bool mergesSimulationIslands() const - { - ///static objects, kinematic and object without contact response don't merge islands - return ((m_collisionFlags & (CF_STATIC_OBJECT | CF_KINEMATIC_OBJECT | CF_NO_CONTACT_RESPONSE) )==0); - } - - const btVector3& getAnisotropicFriction() const - { - return m_anisotropicFriction; - } - void setAnisotropicFriction(const btVector3& anisotropicFriction) - { - m_anisotropicFriction = anisotropicFriction; - m_hasAnisotropicFriction = (anisotropicFriction[0]!=1.f) || (anisotropicFriction[1]!=1.f) || (anisotropicFriction[2]!=1.f); - } - bool hasAnisotropicFriction() const - { - return m_hasAnisotropicFriction!=0; - } - - ///the constraint solver can discard solving contacts, if the distance is above this threshold. 0 by default. - ///Note that using contacts with positive distance can improve stability. It increases, however, the chance of colliding with degerate contacts, such as 'interior' triangle edges - void setContactProcessingThreshold( btScalar contactProcessingThreshold) - { - m_contactProcessingThreshold = contactProcessingThreshold; - } - btScalar getContactProcessingThreshold() const - { - return m_contactProcessingThreshold; - } - - SIMD_FORCE_INLINE bool isStaticObject() const { - return (m_collisionFlags & CF_STATIC_OBJECT) != 0; - } - - SIMD_FORCE_INLINE bool isKinematicObject() const - { - return (m_collisionFlags & CF_KINEMATIC_OBJECT) != 0; - } - - SIMD_FORCE_INLINE bool isStaticOrKinematicObject() const - { - return (m_collisionFlags & (CF_KINEMATIC_OBJECT | CF_STATIC_OBJECT)) != 0 ; - } - - SIMD_FORCE_INLINE bool hasContactResponse() const { - return (m_collisionFlags & CF_NO_CONTACT_RESPONSE)==0; - } - - - btCollisionObject(); - - virtual ~btCollisionObject(); - - virtual void setCollisionShape(btCollisionShape* collisionShape) - { - m_collisionShape = collisionShape; - m_rootCollisionShape = collisionShape; - } - - SIMD_FORCE_INLINE const btCollisionShape* getCollisionShape() const - { - return m_collisionShape; - } - - SIMD_FORCE_INLINE btCollisionShape* getCollisionShape() - { - return m_collisionShape; - } - - SIMD_FORCE_INLINE const btCollisionShape* getRootCollisionShape() const - { - return m_rootCollisionShape; - } - - SIMD_FORCE_INLINE btCollisionShape* getRootCollisionShape() - { - return m_rootCollisionShape; - } - - ///Avoid using this internal API call - ///internalSetTemporaryCollisionShape is used to temporary replace the actual collision shape by a child collision shape. - void internalSetTemporaryCollisionShape(btCollisionShape* collisionShape) - { - m_collisionShape = collisionShape; - } - - SIMD_FORCE_INLINE int getActivationState() const { return m_activationState1;} - - void setActivationState(int newState); - - void setDeactivationTime(btScalar time) - { - m_deactivationTime = time; - } - btScalar getDeactivationTime() const - { - return m_deactivationTime; - } - - void forceActivationState(int newState); - - void activate(bool forceActivation = false); - - SIMD_FORCE_INLINE bool isActive() const - { - return ((getActivationState() != ISLAND_SLEEPING) && (getActivationState() != DISABLE_SIMULATION)); - } - - void setRestitution(btScalar rest) - { - m_restitution = rest; - } - btScalar getRestitution() const - { - return m_restitution; - } - void setFriction(btScalar frict) - { - m_friction = frict; - } - btScalar getFriction() const - { - return m_friction; - } - - ///reserved for Bullet internal usage - int getInternalType() const - { - return m_internalType; - } - - btTransform& getWorldTransform() - { - return m_worldTransform; - } - - const btTransform& getWorldTransform() const - { - return m_worldTransform; - } - - void setWorldTransform(const btTransform& worldTrans) - { - m_worldTransform = worldTrans; - } - - - SIMD_FORCE_INLINE btBroadphaseProxy* getBroadphaseHandle() - { - return m_broadphaseHandle; - } - - SIMD_FORCE_INLINE const btBroadphaseProxy* getBroadphaseHandle() const - { - return m_broadphaseHandle; - } - - void setBroadphaseHandle(btBroadphaseProxy* handle) - { - m_broadphaseHandle = handle; - } - - - const btTransform& getInterpolationWorldTransform() const - { - return m_interpolationWorldTransform; - } - - btTransform& getInterpolationWorldTransform() - { - return m_interpolationWorldTransform; - } - - void setInterpolationWorldTransform(const btTransform& trans) - { - m_interpolationWorldTransform = trans; - } - - void setInterpolationLinearVelocity(const btVector3& linvel) - { - m_interpolationLinearVelocity = linvel; - } - - void setInterpolationAngularVelocity(const btVector3& angvel) - { - m_interpolationAngularVelocity = angvel; - } - - const btVector3& getInterpolationLinearVelocity() const - { - return m_interpolationLinearVelocity; - } - - const btVector3& getInterpolationAngularVelocity() const - { - return m_interpolationAngularVelocity; - } - - SIMD_FORCE_INLINE int getIslandTag() const - { - return m_islandTag1; - } - - void setIslandTag(int tag) - { - m_islandTag1 = tag; - } - - SIMD_FORCE_INLINE int getCompanionId() const - { - return m_companionId; - } - - void setCompanionId(int id) - { - m_companionId = id; - } - - SIMD_FORCE_INLINE btScalar getHitFraction() const - { - return m_hitFraction; - } - - void setHitFraction(btScalar hitFraction) - { - m_hitFraction = hitFraction; - } - - - SIMD_FORCE_INLINE int getCollisionFlags() const - { - return m_collisionFlags; - } - - void setCollisionFlags(int flags) - { - m_collisionFlags = flags; - } - - ///Swept sphere radius (0.0 by default), see btConvexConvexAlgorithm:: - btScalar getCcdSweptSphereRadius() const - { - return m_ccdSweptSphereRadius; - } - - ///Swept sphere radius (0.0 by default), see btConvexConvexAlgorithm:: - void setCcdSweptSphereRadius(btScalar radius) - { - m_ccdSweptSphereRadius = radius; - } - - btScalar getCcdMotionThreshold() const - { - return m_ccdMotionThreshold; - } - - btScalar getCcdSquareMotionThreshold() const - { - return m_ccdMotionThreshold*m_ccdMotionThreshold; - } - - - - /// Don't do continuous collision detection if the motion (in one step) is less then m_ccdMotionThreshold - void setCcdMotionThreshold(btScalar ccdMotionThreshold) - { - m_ccdMotionThreshold = ccdMotionThreshold; - } - - ///users can point to their objects, userPointer is not used by Bullet - void* getUserPointer() const - { - return m_userObjectPointer; - } - - ///users can point to their objects, userPointer is not used by Bullet - void setUserPointer(void* userPointer) - { - m_userObjectPointer = userPointer; - } - - - inline bool checkCollideWith(btCollisionObject* co) - { - if (m_checkCollideWith) - return checkCollideWithOverride(co); - - return true; - } - - virtual int calculateSerializeBufferSize() const; - - ///fills the dataBuffer and returns the struct name (and 0 on failure) - virtual const char* serialize(void* dataBuffer) const; - - -}; - -///using offsetof for m_vtablePadding might break some compilers, in that case define m_vtablePadding manually - -///for serialization -struct btCollisionObjectData -{ - btTransformData m_worldTransform; - btTransformData m_interpolationWorldTransform; - btVector3Data m_interpolationLinearVelocity; - btVector3Data m_interpolationAngularVelocity; - btVector3Data m_anisotropicFriction; - int m_hasAnisotropicFriction; - btScalar m_contactProcessingThreshold; - void *m_broadphaseHandle; - void *m_collisionShape; - btCollisionShapeData *m_rootCollisionShape; - int m_collisionFlags; - int m_islandTag1; - int m_companionId; - int m_activationState1; - btScalar m_deactivationTime; - btScalar m_friction; - btScalar m_restitution; - int m_internalType; - void *m_userObjectPointer; - btScalar m_hitFraction; - btScalar m_ccdSweptSphereRadius; - btScalar m_ccdMotionThreshold; - int m_checkCollideWith; -}; - - -SIMD_FORCE_INLINE int btCollisionObject::calculateSerializeBufferSize() const -{ - return sizeof(btCollisionObjectData); -} - -SIMD_FORCE_INLINE const char* btCollisionObject::serialize(void* dataBuffer) const -{ - - btCollisionObjectData* dataOut = (btCollisionObjectData*)dataBuffer; - - m_worldTransform.serialize(dataOut->m_worldTransform); - m_interpolationWorldTransform.serialize(dataOut->m_interpolationWorldTransform); - m_interpolationLinearVelocity.serialize(dataOut->m_interpolationLinearVelocity); - m_interpolationAngularVelocity.serialize(dataOut->m_interpolationAngularVelocity); - m_anisotropicFriction.serialize(dataOut->m_anisotropicFriction); - dataOut->m_hasAnisotropicFriction = m_hasAnisotropicFriction; - dataOut->m_contactProcessingThreshold = m_contactProcessingThreshold; - dataOut->m_broadphaseHandle = 0; - dataOut->m_collisionShape = m_collisionShape; //@todo - dataOut->m_rootCollisionShape = 0;//@todo - dataOut->m_collisionFlags = m_collisionFlags; - dataOut->m_islandTag1 = m_islandTag1; - dataOut->m_companionId = m_companionId; - dataOut->m_activationState1 = m_activationState1; - dataOut->m_activationState1 = m_activationState1; - dataOut->m_deactivationTime = m_deactivationTime; - dataOut->m_friction = m_friction; - dataOut->m_restitution = m_restitution; - dataOut->m_internalType = m_internalType; - dataOut->m_userObjectPointer = m_userObjectPointer; - dataOut->m_hitFraction = m_hitFraction; - dataOut->m_ccdSweptSphereRadius = m_ccdSweptSphereRadius; - dataOut->m_ccdMotionThreshold = m_ccdMotionThreshold; - dataOut->m_ccdMotionThreshold = m_ccdMotionThreshold; - dataOut->m_checkCollideWith = m_checkCollideWith; - - return "btCollisionObjectData"; -} - - - -#endif //COLLISION_OBJECT_H diff --git a/bullet/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp b/bullet/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp deleted file mode 100644 index 739bd62a3..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp +++ /dev/null @@ -1,846 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btCollisionWorld.h" -#include "btCollisionDispatcher.h" -#include "BulletCollision/CollisionDispatch/btCollisionObject.h" -#include "BulletCollision/CollisionShapes/btCollisionShape.h" -#include "BulletCollision/CollisionShapes/btConvexShape.h" -#include "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h" -#include "BulletCollision/CollisionShapes/btSphereShape.h" //for raycasting -#include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h" //for raycasting -#include "BulletCollision/NarrowPhaseCollision/btRaycastCallback.h" -#include "BulletCollision/CollisionShapes/btCompoundShape.h" -#include "BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h" -#include "BulletCollision/NarrowPhaseCollision/btGjkConvexCast.h" -#include "BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.h" - -#include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h" -#include "LinearMath/btAabbUtil2.h" -#include "LinearMath/btQuickprof.h" -#include "LinearMath/btStackAlloc.h" - -//#define USE_BRUTEFORCE_RAYBROADPHASE 1 -//RECALCULATE_AABB is slower, but benefit is that you don't need to call 'stepSimulation' or 'updateAabbs' before using a rayTest -//#define RECALCULATE_AABB_RAYCAST 1 - -//When the user doesn't provide dispatcher or broadphase, create basic versions (and delete them in destructor) -#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h" -#include "BulletCollision/BroadphaseCollision/btSimpleBroadphase.h" -#include "BulletCollision/CollisionDispatch/btCollisionConfiguration.h" - - -btCollisionWorld::btCollisionWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache, btCollisionConfiguration* collisionConfiguration) -:m_dispatcher1(dispatcher), -m_broadphasePairCache(pairCache), -m_debugDrawer(0), -m_forceUpdateAllAabbs(true) -{ - m_stackAlloc = collisionConfiguration->getStackAllocator(); - m_dispatchInfo.m_stackAllocator = m_stackAlloc; -} - - -btCollisionWorld::~btCollisionWorld() -{ - - //clean up remaining objects - int i; - for (i=0;igetBroadphaseHandle(); - if (bp) - { - // - // only clear the cached algorithms - // - getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(bp,m_dispatcher1); - getBroadphase()->destroyProxy(bp,m_dispatcher1); - collisionObject->setBroadphaseHandle(0); - } - } - - -} - - - - - - - - - - -void btCollisionWorld::addCollisionObject(btCollisionObject* collisionObject,short int collisionFilterGroup,short int collisionFilterMask) -{ - - btAssert(collisionObject); - - //check that the object isn't already added - btAssert( m_collisionObjects.findLinearSearch(collisionObject) == m_collisionObjects.size()); - - m_collisionObjects.push_back(collisionObject); - - //calculate new AABB - btTransform trans = collisionObject->getWorldTransform(); - - btVector3 minAabb; - btVector3 maxAabb; - collisionObject->getCollisionShape()->getAabb(trans,minAabb,maxAabb); - - int type = collisionObject->getCollisionShape()->getShapeType(); - collisionObject->setBroadphaseHandle( getBroadphase()->createProxy( - minAabb, - maxAabb, - type, - collisionObject, - collisionFilterGroup, - collisionFilterMask, - m_dispatcher1,0 - )) ; - - - - - -} - - - -void btCollisionWorld::updateSingleAabb(btCollisionObject* colObj) -{ - btVector3 minAabb,maxAabb; - colObj->getCollisionShape()->getAabb(colObj->getWorldTransform(), minAabb,maxAabb); - //need to increase the aabb for contact thresholds - btVector3 contactThreshold(gContactBreakingThreshold,gContactBreakingThreshold,gContactBreakingThreshold); - minAabb -= contactThreshold; - maxAabb += contactThreshold; - - btBroadphaseInterface* bp = (btBroadphaseInterface*)m_broadphasePairCache; - - //moving objects should be moderately sized, probably something wrong if not - if ( colObj->isStaticObject() || ((maxAabb-minAabb).length2() < btScalar(1e12))) - { - bp->setAabb(colObj->getBroadphaseHandle(),minAabb,maxAabb, m_dispatcher1); - } else - { - //something went wrong, investigate - //this assert is unwanted in 3D modelers (danger of loosing work) - colObj->setActivationState(DISABLE_SIMULATION); - - static bool reportMe = true; - if (reportMe && m_debugDrawer) - { - reportMe = false; - m_debugDrawer->reportErrorWarning("Overflow in AABB, object removed from simulation"); - m_debugDrawer->reportErrorWarning("If you can reproduce this, please email bugs@continuousphysics.com\n"); - m_debugDrawer->reportErrorWarning("Please include above information, your Platform, version of OS.\n"); - m_debugDrawer->reportErrorWarning("Thanks.\n"); - } - } -} - -void btCollisionWorld::updateAabbs() -{ - BT_PROFILE("updateAabbs"); - - btTransform predictedTrans; - for ( int i=0;iisActive()) - { - updateSingleAabb(colObj); - } - } -} - - - -void btCollisionWorld::performDiscreteCollisionDetection() -{ - BT_PROFILE("performDiscreteCollisionDetection"); - - btDispatcherInfo& dispatchInfo = getDispatchInfo(); - - updateAabbs(); - - { - BT_PROFILE("calculateOverlappingPairs"); - m_broadphasePairCache->calculateOverlappingPairs(m_dispatcher1); - } - - - btDispatcher* dispatcher = getDispatcher(); - { - BT_PROFILE("dispatchAllCollisionPairs"); - if (dispatcher) - dispatcher->dispatchAllCollisionPairs(m_broadphasePairCache->getOverlappingPairCache(),dispatchInfo,m_dispatcher1); - } - -} - - - -void btCollisionWorld::removeCollisionObject(btCollisionObject* collisionObject) -{ - - - //bool removeFromBroadphase = false; - - { - - btBroadphaseProxy* bp = collisionObject->getBroadphaseHandle(); - if (bp) - { - // - // only clear the cached algorithms - // - getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(bp,m_dispatcher1); - getBroadphase()->destroyProxy(bp,m_dispatcher1); - collisionObject->setBroadphaseHandle(0); - } - } - - - //swapremove - m_collisionObjects.remove(collisionObject); - -} - - - -void btCollisionWorld::rayTestSingle(const btTransform& rayFromTrans,const btTransform& rayToTrans, - btCollisionObject* collisionObject, - const btCollisionShape* collisionShape, - const btTransform& colObjWorldTransform, - RayResultCallback& resultCallback) -{ - btSphereShape pointShape(btScalar(0.0)); - pointShape.setMargin(0.f); - const btConvexShape* castShape = &pointShape; - - if (collisionShape->isConvex()) - { -// BT_PROFILE("rayTestConvex"); - btConvexCast::CastResult castResult; - castResult.m_fraction = resultCallback.m_closestHitFraction; - - btConvexShape* convexShape = (btConvexShape*) collisionShape; - btVoronoiSimplexSolver simplexSolver; -#define USE_SUBSIMPLEX_CONVEX_CAST 1 -#ifdef USE_SUBSIMPLEX_CONVEX_CAST - btSubsimplexConvexCast convexCaster(castShape,convexShape,&simplexSolver); -#else - //btGjkConvexCast convexCaster(castShape,convexShape,&simplexSolver); - //btContinuousConvexCollision convexCaster(castShape,convexShape,&simplexSolver,0); -#endif //#USE_SUBSIMPLEX_CONVEX_CAST - - if (convexCaster.calcTimeOfImpact(rayFromTrans,rayToTrans,colObjWorldTransform,colObjWorldTransform,castResult)) - { - //add hit - if (castResult.m_normal.length2() > btScalar(0.0001)) - { - if (castResult.m_fraction < resultCallback.m_closestHitFraction) - { -#ifdef USE_SUBSIMPLEX_CONVEX_CAST - //rotate normal into worldspace - castResult.m_normal = rayFromTrans.getBasis() * castResult.m_normal; -#endif //USE_SUBSIMPLEX_CONVEX_CAST - - castResult.m_normal.normalize(); - btCollisionWorld::LocalRayResult localRayResult - ( - collisionObject, - 0, - castResult.m_normal, - castResult.m_fraction - ); - - bool normalInWorldSpace = true; - resultCallback.addSingleResult(localRayResult, normalInWorldSpace); - - } - } - } - } else { - if (collisionShape->isConcave()) - { -// BT_PROFILE("rayTestConcave"); - if (collisionShape->getShapeType()==TRIANGLE_MESH_SHAPE_PROXYTYPE) - { - ///optimized version for btBvhTriangleMeshShape - btBvhTriangleMeshShape* triangleMesh = (btBvhTriangleMeshShape*)collisionShape; - btTransform worldTocollisionObject = colObjWorldTransform.inverse(); - btVector3 rayFromLocal = worldTocollisionObject * rayFromTrans.getOrigin(); - btVector3 rayToLocal = worldTocollisionObject * rayToTrans.getOrigin(); - - //ConvexCast::CastResult - struct BridgeTriangleRaycastCallback : public btTriangleRaycastCallback - { - btCollisionWorld::RayResultCallback* m_resultCallback; - btCollisionObject* m_collisionObject; - btTriangleMeshShape* m_triangleMesh; - - btTransform m_colObjWorldTransform; - - BridgeTriangleRaycastCallback( const btVector3& from,const btVector3& to, - btCollisionWorld::RayResultCallback* resultCallback, btCollisionObject* collisionObject,btTriangleMeshShape* triangleMesh,const btTransform& colObjWorldTransform): - //@BP Mod - btTriangleRaycastCallback(from,to, resultCallback->m_flags), - m_resultCallback(resultCallback), - m_collisionObject(collisionObject), - m_triangleMesh(triangleMesh), - m_colObjWorldTransform(colObjWorldTransform) - { - } - - - virtual btScalar reportHit(const btVector3& hitNormalLocal, btScalar hitFraction, int partId, int triangleIndex ) - { - btCollisionWorld::LocalShapeInfo shapeInfo; - shapeInfo.m_shapePart = partId; - shapeInfo.m_triangleIndex = triangleIndex; - - btVector3 hitNormalWorld = m_colObjWorldTransform.getBasis() * hitNormalLocal; - - btCollisionWorld::LocalRayResult rayResult - (m_collisionObject, - &shapeInfo, - hitNormalWorld, - hitFraction); - - bool normalInWorldSpace = true; - return m_resultCallback->addSingleResult(rayResult,normalInWorldSpace); - } - - }; - - BridgeTriangleRaycastCallback rcb(rayFromLocal,rayToLocal,&resultCallback,collisionObject,triangleMesh,colObjWorldTransform); - rcb.m_hitFraction = resultCallback.m_closestHitFraction; - triangleMesh->performRaycast(&rcb,rayFromLocal,rayToLocal); - } else - { - //generic (slower) case - btConcaveShape* concaveShape = (btConcaveShape*)collisionShape; - - btTransform worldTocollisionObject = colObjWorldTransform.inverse(); - - btVector3 rayFromLocal = worldTocollisionObject * rayFromTrans.getOrigin(); - btVector3 rayToLocal = worldTocollisionObject * rayToTrans.getOrigin(); - - //ConvexCast::CastResult - - struct BridgeTriangleRaycastCallback : public btTriangleRaycastCallback - { - btCollisionWorld::RayResultCallback* m_resultCallback; - btCollisionObject* m_collisionObject; - btConcaveShape* m_triangleMesh; - - btTransform m_colObjWorldTransform; - - BridgeTriangleRaycastCallback( const btVector3& from,const btVector3& to, - btCollisionWorld::RayResultCallback* resultCallback, btCollisionObject* collisionObject,btConcaveShape* triangleMesh, const btTransform& colObjWorldTransform): - //@BP Mod - btTriangleRaycastCallback(from,to, resultCallback->m_flags), - m_resultCallback(resultCallback), - m_collisionObject(collisionObject), - m_triangleMesh(triangleMesh), - m_colObjWorldTransform(colObjWorldTransform) - { - } - - - virtual btScalar reportHit(const btVector3& hitNormalLocal, btScalar hitFraction, int partId, int triangleIndex ) - { - btCollisionWorld::LocalShapeInfo shapeInfo; - shapeInfo.m_shapePart = partId; - shapeInfo.m_triangleIndex = triangleIndex; - - btVector3 hitNormalWorld = m_colObjWorldTransform.getBasis() * hitNormalLocal; - - btCollisionWorld::LocalRayResult rayResult - (m_collisionObject, - &shapeInfo, - hitNormalWorld, - hitFraction); - - bool normalInWorldSpace = true; - return m_resultCallback->addSingleResult(rayResult,normalInWorldSpace); - } - - }; - - - BridgeTriangleRaycastCallback rcb(rayFromLocal,rayToLocal,&resultCallback,collisionObject,concaveShape, colObjWorldTransform); - rcb.m_hitFraction = resultCallback.m_closestHitFraction; - - btVector3 rayAabbMinLocal = rayFromLocal; - rayAabbMinLocal.setMin(rayToLocal); - btVector3 rayAabbMaxLocal = rayFromLocal; - rayAabbMaxLocal.setMax(rayToLocal); - - concaveShape->processAllTriangles(&rcb,rayAabbMinLocal,rayAabbMaxLocal); - } - } else { -// BT_PROFILE("rayTestCompound"); - ///@todo: use AABB tree or other BVH acceleration structure, see btDbvt - if (collisionShape->isCompound()) - { - const btCompoundShape* compoundShape = static_cast(collisionShape); - int i=0; - for (i=0;igetNumChildShapes();i++) - { - btTransform childTrans = compoundShape->getChildTransform(i); - const btCollisionShape* childCollisionShape = compoundShape->getChildShape(i); - btTransform childWorldTrans = colObjWorldTransform * childTrans; - // replace collision shape so that callback can determine the triangle - btCollisionShape* saveCollisionShape = collisionObject->getCollisionShape(); - collisionObject->internalSetTemporaryCollisionShape((btCollisionShape*)childCollisionShape); - rayTestSingle(rayFromTrans,rayToTrans, - collisionObject, - childCollisionShape, - childWorldTrans, - resultCallback); - // restore - collisionObject->internalSetTemporaryCollisionShape(saveCollisionShape); - } - } - } - } -} - -void btCollisionWorld::objectQuerySingle(const btConvexShape* castShape,const btTransform& convexFromTrans,const btTransform& convexToTrans, - btCollisionObject* collisionObject, - const btCollisionShape* collisionShape, - const btTransform& colObjWorldTransform, - ConvexResultCallback& resultCallback, btScalar allowedPenetration) -{ - if (collisionShape->isConvex()) - { - //BT_PROFILE("convexSweepConvex"); - btConvexCast::CastResult castResult; - castResult.m_allowedPenetration = allowedPenetration; - castResult.m_fraction = resultCallback.m_closestHitFraction;//btScalar(1.);//?? - - btConvexShape* convexShape = (btConvexShape*) collisionShape; - btVoronoiSimplexSolver simplexSolver; - btGjkEpaPenetrationDepthSolver gjkEpaPenetrationSolver; - - btContinuousConvexCollision convexCaster1(castShape,convexShape,&simplexSolver,&gjkEpaPenetrationSolver); - //btGjkConvexCast convexCaster2(castShape,convexShape,&simplexSolver); - //btSubsimplexConvexCast convexCaster3(castShape,convexShape,&simplexSolver); - - btConvexCast* castPtr = &convexCaster1; - - - - if (castPtr->calcTimeOfImpact(convexFromTrans,convexToTrans,colObjWorldTransform,colObjWorldTransform,castResult)) - { - //add hit - if (castResult.m_normal.length2() > btScalar(0.0001)) - { - if (castResult.m_fraction < resultCallback.m_closestHitFraction) - { - castResult.m_normal.normalize(); - btCollisionWorld::LocalConvexResult localConvexResult - ( - collisionObject, - 0, - castResult.m_normal, - castResult.m_hitPoint, - castResult.m_fraction - ); - - bool normalInWorldSpace = true; - resultCallback.addSingleResult(localConvexResult, normalInWorldSpace); - - } - } - } - } else { - if (collisionShape->isConcave()) - { - if (collisionShape->getShapeType()==TRIANGLE_MESH_SHAPE_PROXYTYPE) - { - //BT_PROFILE("convexSweepbtBvhTriangleMesh"); - btBvhTriangleMeshShape* triangleMesh = (btBvhTriangleMeshShape*)collisionShape; - btTransform worldTocollisionObject = colObjWorldTransform.inverse(); - btVector3 convexFromLocal = worldTocollisionObject * convexFromTrans.getOrigin(); - btVector3 convexToLocal = worldTocollisionObject * convexToTrans.getOrigin(); - // rotation of box in local mesh space = MeshRotation^-1 * ConvexToRotation - btTransform rotationXform = btTransform(worldTocollisionObject.getBasis() * convexToTrans.getBasis()); - - //ConvexCast::CastResult - struct BridgeTriangleConvexcastCallback : public btTriangleConvexcastCallback - { - btCollisionWorld::ConvexResultCallback* m_resultCallback; - btCollisionObject* m_collisionObject; - btTriangleMeshShape* m_triangleMesh; - - BridgeTriangleConvexcastCallback(const btConvexShape* castShape, const btTransform& from,const btTransform& to, - btCollisionWorld::ConvexResultCallback* resultCallback, btCollisionObject* collisionObject,btTriangleMeshShape* triangleMesh, const btTransform& triangleToWorld): - btTriangleConvexcastCallback(castShape, from,to, triangleToWorld, triangleMesh->getMargin()), - m_resultCallback(resultCallback), - m_collisionObject(collisionObject), - m_triangleMesh(triangleMesh) - { - } - - - virtual btScalar reportHit(const btVector3& hitNormalLocal, const btVector3& hitPointLocal, btScalar hitFraction, int partId, int triangleIndex ) - { - btCollisionWorld::LocalShapeInfo shapeInfo; - shapeInfo.m_shapePart = partId; - shapeInfo.m_triangleIndex = triangleIndex; - if (hitFraction <= m_resultCallback->m_closestHitFraction) - { - - btCollisionWorld::LocalConvexResult convexResult - (m_collisionObject, - &shapeInfo, - hitNormalLocal, - hitPointLocal, - hitFraction); - - bool normalInWorldSpace = true; - - - return m_resultCallback->addSingleResult(convexResult,normalInWorldSpace); - } - return hitFraction; - } - - }; - - BridgeTriangleConvexcastCallback tccb(castShape, convexFromTrans,convexToTrans,&resultCallback,collisionObject,triangleMesh, colObjWorldTransform); - tccb.m_hitFraction = resultCallback.m_closestHitFraction; - btVector3 boxMinLocal, boxMaxLocal; - castShape->getAabb(rotationXform, boxMinLocal, boxMaxLocal); - triangleMesh->performConvexcast(&tccb,convexFromLocal,convexToLocal,boxMinLocal, boxMaxLocal); - } else - { - //BT_PROFILE("convexSweepConcave"); - btConcaveShape* concaveShape = (btConcaveShape*)collisionShape; - btTransform worldTocollisionObject = colObjWorldTransform.inverse(); - btVector3 convexFromLocal = worldTocollisionObject * convexFromTrans.getOrigin(); - btVector3 convexToLocal = worldTocollisionObject * convexToTrans.getOrigin(); - // rotation of box in local mesh space = MeshRotation^-1 * ConvexToRotation - btTransform rotationXform = btTransform(worldTocollisionObject.getBasis() * convexToTrans.getBasis()); - - //ConvexCast::CastResult - struct BridgeTriangleConvexcastCallback : public btTriangleConvexcastCallback - { - btCollisionWorld::ConvexResultCallback* m_resultCallback; - btCollisionObject* m_collisionObject; - btConcaveShape* m_triangleMesh; - - BridgeTriangleConvexcastCallback(const btConvexShape* castShape, const btTransform& from,const btTransform& to, - btCollisionWorld::ConvexResultCallback* resultCallback, btCollisionObject* collisionObject,btConcaveShape* triangleMesh, const btTransform& triangleToWorld): - btTriangleConvexcastCallback(castShape, from,to, triangleToWorld, triangleMesh->getMargin()), - m_resultCallback(resultCallback), - m_collisionObject(collisionObject), - m_triangleMesh(triangleMesh) - { - } - - - virtual btScalar reportHit(const btVector3& hitNormalLocal, const btVector3& hitPointLocal, btScalar hitFraction, int partId, int triangleIndex ) - { - btCollisionWorld::LocalShapeInfo shapeInfo; - shapeInfo.m_shapePart = partId; - shapeInfo.m_triangleIndex = triangleIndex; - if (hitFraction <= m_resultCallback->m_closestHitFraction) - { - - btCollisionWorld::LocalConvexResult convexResult - (m_collisionObject, - &shapeInfo, - hitNormalLocal, - hitPointLocal, - hitFraction); - - bool normalInWorldSpace = false; - - return m_resultCallback->addSingleResult(convexResult,normalInWorldSpace); - } - return hitFraction; - } - - }; - - BridgeTriangleConvexcastCallback tccb(castShape, convexFromTrans,convexToTrans,&resultCallback,collisionObject,concaveShape, colObjWorldTransform); - tccb.m_hitFraction = resultCallback.m_closestHitFraction; - btVector3 boxMinLocal, boxMaxLocal; - castShape->getAabb(rotationXform, boxMinLocal, boxMaxLocal); - - btVector3 rayAabbMinLocal = convexFromLocal; - rayAabbMinLocal.setMin(convexToLocal); - btVector3 rayAabbMaxLocal = convexFromLocal; - rayAabbMaxLocal.setMax(convexToLocal); - rayAabbMinLocal += boxMinLocal; - rayAabbMaxLocal += boxMaxLocal; - concaveShape->processAllTriangles(&tccb,rayAabbMinLocal,rayAabbMaxLocal); - } - } else { - ///@todo : use AABB tree or other BVH acceleration structure! - if (collisionShape->isCompound()) - { - BT_PROFILE("convexSweepCompound"); - const btCompoundShape* compoundShape = static_cast(collisionShape); - int i=0; - for (i=0;igetNumChildShapes();i++) - { - btTransform childTrans = compoundShape->getChildTransform(i); - const btCollisionShape* childCollisionShape = compoundShape->getChildShape(i); - btTransform childWorldTrans = colObjWorldTransform * childTrans; - // replace collision shape so that callback can determine the triangle - btCollisionShape* saveCollisionShape = collisionObject->getCollisionShape(); - collisionObject->internalSetTemporaryCollisionShape((btCollisionShape*)childCollisionShape); - objectQuerySingle(castShape, convexFromTrans,convexToTrans, - collisionObject, - childCollisionShape, - childWorldTrans, - resultCallback, allowedPenetration); - // restore - collisionObject->internalSetTemporaryCollisionShape(saveCollisionShape); - } - } - } - } -} - - -struct btSingleRayCallback : public btBroadphaseRayCallback -{ - - btVector3 m_rayFromWorld; - btVector3 m_rayToWorld; - btTransform m_rayFromTrans; - btTransform m_rayToTrans; - btVector3 m_hitNormal; - - const btCollisionWorld* m_world; - btCollisionWorld::RayResultCallback& m_resultCallback; - - btSingleRayCallback(const btVector3& rayFromWorld,const btVector3& rayToWorld,const btCollisionWorld* world,btCollisionWorld::RayResultCallback& resultCallback) - :m_rayFromWorld(rayFromWorld), - m_rayToWorld(rayToWorld), - m_world(world), - m_resultCallback(resultCallback) - { - m_rayFromTrans.setIdentity(); - m_rayFromTrans.setOrigin(m_rayFromWorld); - m_rayToTrans.setIdentity(); - m_rayToTrans.setOrigin(m_rayToWorld); - - btVector3 rayDir = (rayToWorld-rayFromWorld); - - rayDir.normalize (); - ///what about division by zero? --> just set rayDirection[i] to INF/BT_LARGE_FLOAT - m_rayDirectionInverse[0] = rayDir[0] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDir[0]; - m_rayDirectionInverse[1] = rayDir[1] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDir[1]; - m_rayDirectionInverse[2] = rayDir[2] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDir[2]; - m_signs[0] = m_rayDirectionInverse[0] < 0.0; - m_signs[1] = m_rayDirectionInverse[1] < 0.0; - m_signs[2] = m_rayDirectionInverse[2] < 0.0; - - m_lambda_max = rayDir.dot(m_rayToWorld-m_rayFromWorld); - - } - - - - virtual bool process(const btBroadphaseProxy* proxy) - { - ///terminate further ray tests, once the closestHitFraction reached zero - if (m_resultCallback.m_closestHitFraction == btScalar(0.f)) - return false; - - btCollisionObject* collisionObject = (btCollisionObject*)proxy->m_clientObject; - - //only perform raycast if filterMask matches - if(m_resultCallback.needsCollision(collisionObject->getBroadphaseHandle())) - { - //RigidcollisionObject* collisionObject = ctrl->GetRigidcollisionObject(); - //btVector3 collisionObjectAabbMin,collisionObjectAabbMax; -#if 0 -#ifdef RECALCULATE_AABB - btVector3 collisionObjectAabbMin,collisionObjectAabbMax; - collisionObject->getCollisionShape()->getAabb(collisionObject->getWorldTransform(),collisionObjectAabbMin,collisionObjectAabbMax); -#else - //getBroadphase()->getAabb(collisionObject->getBroadphaseHandle(),collisionObjectAabbMin,collisionObjectAabbMax); - const btVector3& collisionObjectAabbMin = collisionObject->getBroadphaseHandle()->m_aabbMin; - const btVector3& collisionObjectAabbMax = collisionObject->getBroadphaseHandle()->m_aabbMax; -#endif -#endif - //btScalar hitLambda = m_resultCallback.m_closestHitFraction; - //culling already done by broadphase - //if (btRayAabb(m_rayFromWorld,m_rayToWorld,collisionObjectAabbMin,collisionObjectAabbMax,hitLambda,m_hitNormal)) - { - m_world->rayTestSingle(m_rayFromTrans,m_rayToTrans, - collisionObject, - collisionObject->getCollisionShape(), - collisionObject->getWorldTransform(), - m_resultCallback); - } - } - return true; - } -}; - -void btCollisionWorld::rayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, RayResultCallback& resultCallback) const -{ - //BT_PROFILE("rayTest"); - /// use the broadphase to accelerate the search for objects, based on their aabb - /// and for each object with ray-aabb overlap, perform an exact ray test - btSingleRayCallback rayCB(rayFromWorld,rayToWorld,this,resultCallback); - -#ifndef USE_BRUTEFORCE_RAYBROADPHASE - m_broadphasePairCache->rayTest(rayFromWorld,rayToWorld,rayCB); -#else - for (int i=0;igetNumCollisionObjects();i++) - { - rayCB.process(m_collisionObjects[i]->getBroadphaseHandle()); - } -#endif //USE_BRUTEFORCE_RAYBROADPHASE - -} - - -struct btSingleSweepCallback : public btBroadphaseRayCallback -{ - - btTransform m_convexFromTrans; - btTransform m_convexToTrans; - btVector3 m_hitNormal; - const btCollisionWorld* m_world; - btCollisionWorld::ConvexResultCallback& m_resultCallback; - btScalar m_allowedCcdPenetration; - const btConvexShape* m_castShape; - - - btSingleSweepCallback(const btConvexShape* castShape, const btTransform& convexFromTrans,const btTransform& convexToTrans,const btCollisionWorld* world,btCollisionWorld::ConvexResultCallback& resultCallback,btScalar allowedPenetration) - :m_convexFromTrans(convexFromTrans), - m_convexToTrans(convexToTrans), - m_world(world), - m_resultCallback(resultCallback), - m_allowedCcdPenetration(allowedPenetration), - m_castShape(castShape) - { - btVector3 unnormalizedRayDir = (m_convexToTrans.getOrigin()-m_convexFromTrans.getOrigin()); - btVector3 rayDir = unnormalizedRayDir.normalized(); - ///what about division by zero? --> just set rayDirection[i] to INF/BT_LARGE_FLOAT - m_rayDirectionInverse[0] = rayDir[0] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDir[0]; - m_rayDirectionInverse[1] = rayDir[1] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDir[1]; - m_rayDirectionInverse[2] = rayDir[2] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDir[2]; - m_signs[0] = m_rayDirectionInverse[0] < 0.0; - m_signs[1] = m_rayDirectionInverse[1] < 0.0; - m_signs[2] = m_rayDirectionInverse[2] < 0.0; - - m_lambda_max = rayDir.dot(unnormalizedRayDir); - - } - - virtual bool process(const btBroadphaseProxy* proxy) - { - ///terminate further convex sweep tests, once the closestHitFraction reached zero - if (m_resultCallback.m_closestHitFraction == btScalar(0.f)) - return false; - - btCollisionObject* collisionObject = (btCollisionObject*)proxy->m_clientObject; - - //only perform raycast if filterMask matches - if(m_resultCallback.needsCollision(collisionObject->getBroadphaseHandle())) { - //RigidcollisionObject* collisionObject = ctrl->GetRigidcollisionObject(); - m_world->objectQuerySingle(m_castShape, m_convexFromTrans,m_convexToTrans, - collisionObject, - collisionObject->getCollisionShape(), - collisionObject->getWorldTransform(), - m_resultCallback, - m_allowedCcdPenetration); - } - - return true; - } -}; - - - -void btCollisionWorld::convexSweepTest(const btConvexShape* castShape, const btTransform& convexFromWorld, const btTransform& convexToWorld, ConvexResultCallback& resultCallback, btScalar allowedCcdPenetration) const -{ - - BT_PROFILE("convexSweepTest"); - /// use the broadphase to accelerate the search for objects, based on their aabb - /// and for each object with ray-aabb overlap, perform an exact ray test - /// unfortunately the implementation for rayTest and convexSweepTest duplicated, albeit practically identical - - - - btTransform convexFromTrans,convexToTrans; - convexFromTrans = convexFromWorld; - convexToTrans = convexToWorld; - btVector3 castShapeAabbMin, castShapeAabbMax; - /* Compute AABB that encompasses angular movement */ - { - btVector3 linVel, angVel; - btTransformUtil::calculateVelocity (convexFromTrans, convexToTrans, 1.0, linVel, angVel); - btVector3 zeroLinVel; - zeroLinVel.setValue(0,0,0); - btTransform R; - R.setIdentity (); - R.setRotation (convexFromTrans.getRotation()); - castShape->calculateTemporalAabb (R, zeroLinVel, angVel, 1.0, castShapeAabbMin, castShapeAabbMax); - } - -#ifndef USE_BRUTEFORCE_RAYBROADPHASE - - btSingleSweepCallback convexCB(castShape,convexFromWorld,convexToWorld,this,resultCallback,allowedCcdPenetration); - - m_broadphasePairCache->rayTest(convexFromTrans.getOrigin(),convexToTrans.getOrigin(),convexCB,castShapeAabbMin,castShapeAabbMax); - -#else - /// go over all objects, and if the ray intersects their aabb + cast shape aabb, - // do a ray-shape query using convexCaster (CCD) - int i; - for (i=0;igetBroadphaseHandle())) { - //RigidcollisionObject* collisionObject = ctrl->GetRigidcollisionObject(); - btVector3 collisionObjectAabbMin,collisionObjectAabbMax; - collisionObject->getCollisionShape()->getAabb(collisionObject->getWorldTransform(),collisionObjectAabbMin,collisionObjectAabbMax); - AabbExpand (collisionObjectAabbMin, collisionObjectAabbMax, castShapeAabbMin, castShapeAabbMax); - btScalar hitLambda = btScalar(1.); //could use resultCallback.m_closestHitFraction, but needs testing - btVector3 hitNormal; - if (btRayAabb(convexFromWorld.getOrigin(),convexToWorld.getOrigin(),collisionObjectAabbMin,collisionObjectAabbMax,hitLambda,hitNormal)) - { - objectQuerySingle(castShape, convexFromTrans,convexToTrans, - collisionObject, - collisionObject->getCollisionShape(), - collisionObject->getWorldTransform(), - resultCallback, - allowedCcdPenetration); - } - } - } -#endif //USE_BRUTEFORCE_RAYBROADPHASE -} diff --git a/bullet/src/BulletCollision/CollisionDispatch/btCollisionWorld.h b/bullet/src/BulletCollision/CollisionDispatch/btCollisionWorld.h deleted file mode 100644 index 96afaf12d..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btCollisionWorld.h +++ /dev/null @@ -1,422 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://bulletphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -/** - * @mainpage Bullet Documentation - * - * @section intro_sec Introduction - * Bullet Collision Detection & Physics SDK - * - * Bullet is a Collision Detection and Rigid Body Dynamics Library. The Library is Open Source and free for commercial use, under the ZLib license ( http://opensource.org/licenses/zlib-license.php ). - * - * There is the Physics Forum for feedback and general Collision Detection and Physics discussions. - * Please visit http://www.bulletphysics.com - * - * @section install_sec Installation - * - * @subsection step1 Step 1: Download - * You can download the Bullet Physics Library from the Google Code repository: http://code.google.com/p/bullet/downloads/list - * @subsection step2 Step 2: Building - * Bullet comes with autogenerated Project Files for Microsoft Visual Studio 6, 7, 7.1 and 8. - * The main Workspace/Solution is located in Bullet/msvc/8/wksbullet.sln (replace 8 with your version). - * - * Under other platforms, like Linux or Mac OS-X, Bullet can be build using either using make, cmake, http://www.cmake.org , or jam, http://www.perforce.com/jam/jam.html . cmake can autogenerate Xcode, KDevelop, MSVC and other build systems. just run cmake . in the root of Bullet. - * So if you are not using MSVC or cmake, you can run ./autogen.sh ./configure to create both Makefile and Jamfile and then run make or jam. - * Jam is a build system that can build the library, demos and also autogenerate the MSVC Project Files. - * If you don't have jam installed, you can make jam from the included jam-2.5 sources, or download jam from ftp://ftp.perforce.com/jam - * - * @subsection step3 Step 3: Testing demos - * Try to run and experiment with BasicDemo executable as a starting point. - * Bullet can be used in several ways, as Full Rigid Body simulation, as Collision Detector Library or Low Level / Snippets like the GJK Closest Point calculation. - * The Dependencies can be seen in this documentation under Directories - * - * @subsection step4 Step 4: Integrating in your application, full Rigid Body and Soft Body simulation - * Check out BasicDemo how to create a btDynamicsWorld, btRigidBody and btCollisionShape, Stepping the simulation and synchronizing your graphics object transform. - * Check out SoftDemo how to use soft body dynamics, using btSoftRigidDynamicsWorld. - * @subsection step5 Step 5 : Integrate the Collision Detection Library (without Dynamics and other Extras) - * Bullet Collision Detection can also be used without the Dynamics/Extras. - * Check out btCollisionWorld and btCollisionObject, and the CollisionInterfaceDemo. - * @subsection step6 Step 6 : Use Snippets like the GJK Closest Point calculation. - * Bullet has been designed in a modular way keeping dependencies to a minimum. The ConvexHullDistance demo demonstrates direct use of btGjkPairDetector. - * - * @section copyright Copyright - * Copyright (C) 2005-2008 Erwin Coumans, some contributions Copyright Gino van den Bergen, Christer Ericson, Simon Hobbs, Ricardo Padrela, F Richter(res), Stephane Redon - * Special thanks to all visitors of the Bullet Physics forum, and in particular above contributors, John McCutchan, Nathanael Presson, Dave Eberle, Dirk Gregorius, Erin Catto, Dave Eberle, Adam Moravanszky, - * Pierre Terdiman, Kenny Erleben, Russell Smith, Oliver Strunk, Jan Paul van Waveren, Marten Svanfeldt. - * - */ - - - -#ifndef COLLISION_WORLD_H -#define COLLISION_WORLD_H - -class btStackAlloc; -class btCollisionShape; -class btConvexShape; -class btBroadphaseInterface; -#include "LinearMath/btVector3.h" -#include "LinearMath/btTransform.h" -#include "btCollisionObject.h" -#include "btCollisionDispatcher.h" -#include "BulletCollision/BroadphaseCollision/btOverlappingPairCache.h" -#include "LinearMath/btAlignedObjectArray.h" - -///CollisionWorld is interface and container for the collision detection -class btCollisionWorld -{ - - -protected: - - btAlignedObjectArray m_collisionObjects; - - btDispatcher* m_dispatcher1; - - btDispatcherInfo m_dispatchInfo; - - btStackAlloc* m_stackAlloc; - - btBroadphaseInterface* m_broadphasePairCache; - - btIDebugDraw* m_debugDrawer; - - ///m_forceUpdateAllAabbs can be set to false as an optimization to only update active object AABBs - ///it is true by default, because it is error-prone (setting the position of static objects wouldn't update their AABB) - bool m_forceUpdateAllAabbs; - -public: - - //this constructor doesn't own the dispatcher and paircache/broadphase - btCollisionWorld(btDispatcher* dispatcher,btBroadphaseInterface* broadphasePairCache, btCollisionConfiguration* collisionConfiguration); - - virtual ~btCollisionWorld(); - - void setBroadphase(btBroadphaseInterface* pairCache) - { - m_broadphasePairCache = pairCache; - } - - const btBroadphaseInterface* getBroadphase() const - { - return m_broadphasePairCache; - } - - btBroadphaseInterface* getBroadphase() - { - return m_broadphasePairCache; - } - - btOverlappingPairCache* getPairCache() - { - return m_broadphasePairCache->getOverlappingPairCache(); - } - - - btDispatcher* getDispatcher() - { - return m_dispatcher1; - } - - const btDispatcher* getDispatcher() const - { - return m_dispatcher1; - } - - void updateSingleAabb(btCollisionObject* colObj); - - virtual void updateAabbs(); - - virtual void setDebugDrawer(btIDebugDraw* debugDrawer) - { - m_debugDrawer = debugDrawer; - } - - virtual btIDebugDraw* getDebugDrawer() - { - return m_debugDrawer; - } - - - ///LocalShapeInfo gives extra information for complex shapes - ///Currently, only btTriangleMeshShape is available, so it just contains triangleIndex and subpart - struct LocalShapeInfo - { - int m_shapePart; - int m_triangleIndex; - - //const btCollisionShape* m_shapeTemp; - //const btTransform* m_shapeLocalTransform; - }; - - struct LocalRayResult - { - LocalRayResult(btCollisionObject* collisionObject, - LocalShapeInfo* localShapeInfo, - const btVector3& hitNormalLocal, - btScalar hitFraction) - :m_collisionObject(collisionObject), - m_localShapeInfo(localShapeInfo), - m_hitNormalLocal(hitNormalLocal), - m_hitFraction(hitFraction) - { - } - - btCollisionObject* m_collisionObject; - LocalShapeInfo* m_localShapeInfo; - btVector3 m_hitNormalLocal; - btScalar m_hitFraction; - - }; - - ///RayResultCallback is used to report new raycast results - struct RayResultCallback - { - btScalar m_closestHitFraction; - btCollisionObject* m_collisionObject; - short int m_collisionFilterGroup; - short int m_collisionFilterMask; - //@BP Mod - Custom flags, currently used to enable backface culling on tri-meshes, see btRaycastCallback - unsigned int m_flags; - - virtual ~RayResultCallback() - { - } - bool hasHit() const - { - return (m_collisionObject != 0); - } - - RayResultCallback() - :m_closestHitFraction(btScalar(1.)), - m_collisionObject(0), - m_collisionFilterGroup(btBroadphaseProxy::DefaultFilter), - m_collisionFilterMask(btBroadphaseProxy::AllFilter), - //@BP Mod - m_flags(0) - { - } - - virtual bool needsCollision(btBroadphaseProxy* proxy0) const - { - bool collides = (proxy0->m_collisionFilterGroup & m_collisionFilterMask) != 0; - collides = collides && (m_collisionFilterGroup & proxy0->m_collisionFilterMask); - return collides; - } - - - virtual btScalar addSingleResult(LocalRayResult& rayResult,bool normalInWorldSpace) = 0; - }; - - struct ClosestRayResultCallback : public RayResultCallback - { - ClosestRayResultCallback(const btVector3& rayFromWorld,const btVector3& rayToWorld) - :m_rayFromWorld(rayFromWorld), - m_rayToWorld(rayToWorld) - { - } - - btVector3 m_rayFromWorld;//used to calculate hitPointWorld from hitFraction - btVector3 m_rayToWorld; - - btVector3 m_hitNormalWorld; - btVector3 m_hitPointWorld; - - virtual btScalar addSingleResult(LocalRayResult& rayResult,bool normalInWorldSpace) - { - //caller already does the filter on the m_closestHitFraction - btAssert(rayResult.m_hitFraction <= m_closestHitFraction); - - m_closestHitFraction = rayResult.m_hitFraction; - m_collisionObject = rayResult.m_collisionObject; - if (normalInWorldSpace) - { - m_hitNormalWorld = rayResult.m_hitNormalLocal; - } else - { - ///need to transform normal into worldspace - m_hitNormalWorld = m_collisionObject->getWorldTransform().getBasis()*rayResult.m_hitNormalLocal; - } - m_hitPointWorld.setInterpolate3(m_rayFromWorld,m_rayToWorld,rayResult.m_hitFraction); - return rayResult.m_hitFraction; - } - }; - - - struct LocalConvexResult - { - LocalConvexResult(btCollisionObject* hitCollisionObject, - LocalShapeInfo* localShapeInfo, - const btVector3& hitNormalLocal, - const btVector3& hitPointLocal, - btScalar hitFraction - ) - :m_hitCollisionObject(hitCollisionObject), - m_localShapeInfo(localShapeInfo), - m_hitNormalLocal(hitNormalLocal), - m_hitPointLocal(hitPointLocal), - m_hitFraction(hitFraction) - { - } - - btCollisionObject* m_hitCollisionObject; - LocalShapeInfo* m_localShapeInfo; - btVector3 m_hitNormalLocal; - btVector3 m_hitPointLocal; - btScalar m_hitFraction; - }; - - ///RayResultCallback is used to report new raycast results - struct ConvexResultCallback - { - btScalar m_closestHitFraction; - short int m_collisionFilterGroup; - short int m_collisionFilterMask; - - ConvexResultCallback() - :m_closestHitFraction(btScalar(1.)), - m_collisionFilterGroup(btBroadphaseProxy::DefaultFilter), - m_collisionFilterMask(btBroadphaseProxy::AllFilter) - { - } - - virtual ~ConvexResultCallback() - { - } - - bool hasHit() const - { - return (m_closestHitFraction < btScalar(1.)); - } - - - - virtual bool needsCollision(btBroadphaseProxy* proxy0) const - { - bool collides = (proxy0->m_collisionFilterGroup & m_collisionFilterMask) != 0; - collides = collides && (m_collisionFilterGroup & proxy0->m_collisionFilterMask); - return collides; - } - - virtual btScalar addSingleResult(LocalConvexResult& convexResult,bool normalInWorldSpace) = 0; - }; - - struct ClosestConvexResultCallback : public ConvexResultCallback - { - ClosestConvexResultCallback(const btVector3& convexFromWorld,const btVector3& convexToWorld) - :m_convexFromWorld(convexFromWorld), - m_convexToWorld(convexToWorld), - m_hitCollisionObject(0) - { - } - - btVector3 m_convexFromWorld;//used to calculate hitPointWorld from hitFraction - btVector3 m_convexToWorld; - - btVector3 m_hitNormalWorld; - btVector3 m_hitPointWorld; - btCollisionObject* m_hitCollisionObject; - - virtual btScalar addSingleResult(LocalConvexResult& convexResult,bool normalInWorldSpace) - { -//caller already does the filter on the m_closestHitFraction - btAssert(convexResult.m_hitFraction <= m_closestHitFraction); - - m_closestHitFraction = convexResult.m_hitFraction; - m_hitCollisionObject = convexResult.m_hitCollisionObject; - if (normalInWorldSpace) - { - m_hitNormalWorld = convexResult.m_hitNormalLocal; - } else - { - ///need to transform normal into worldspace - m_hitNormalWorld = m_hitCollisionObject->getWorldTransform().getBasis()*convexResult.m_hitNormalLocal; - } - m_hitPointWorld = convexResult.m_hitPointLocal; - return convexResult.m_hitFraction; - } - }; - - int getNumCollisionObjects() const - { - return int(m_collisionObjects.size()); - } - - /// rayTest performs a raycast on all objects in the btCollisionWorld, and calls the resultCallback - /// This allows for several queries: first hit, all hits, any hit, dependent on the value returned by the callback. - void rayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, RayResultCallback& resultCallback) const; - - // convexTest performs a swept convex cast on all objects in the btCollisionWorld, and calls the resultCallback - // This allows for several queries: first hit, all hits, any hit, dependent on the value return by the callback. - void convexSweepTest (const btConvexShape* castShape, const btTransform& from, const btTransform& to, ConvexResultCallback& resultCallback, btScalar allowedCcdPenetration = btScalar(0.)) const; - - - /// rayTestSingle performs a raycast call and calls the resultCallback. It is used internally by rayTest. - /// In a future implementation, we consider moving the ray test as a virtual method in btCollisionShape. - /// This allows more customization. - static void rayTestSingle(const btTransform& rayFromTrans,const btTransform& rayToTrans, - btCollisionObject* collisionObject, - const btCollisionShape* collisionShape, - const btTransform& colObjWorldTransform, - RayResultCallback& resultCallback); - - /// objectQuerySingle performs a collision detection query and calls the resultCallback. It is used internally by rayTest. - static void objectQuerySingle(const btConvexShape* castShape, const btTransform& rayFromTrans,const btTransform& rayToTrans, - btCollisionObject* collisionObject, - const btCollisionShape* collisionShape, - const btTransform& colObjWorldTransform, - ConvexResultCallback& resultCallback, btScalar allowedPenetration); - - virtual void addCollisionObject(btCollisionObject* collisionObject,short int collisionFilterGroup=btBroadphaseProxy::DefaultFilter,short int collisionFilterMask=btBroadphaseProxy::AllFilter); - - btCollisionObjectArray& getCollisionObjectArray() - { - return m_collisionObjects; - } - - const btCollisionObjectArray& getCollisionObjectArray() const - { - return m_collisionObjects; - } - - - virtual void removeCollisionObject(btCollisionObject* collisionObject); - - virtual void performDiscreteCollisionDetection(); - - btDispatcherInfo& getDispatchInfo() - { - return m_dispatchInfo; - } - - const btDispatcherInfo& getDispatchInfo() const - { - return m_dispatchInfo; - } - - bool getForceUpdateAllAabbs() const - { - return m_forceUpdateAllAabbs; - } - void setForceUpdateAllAabbs( bool forceUpdateAllAabbs) - { - m_forceUpdateAllAabbs = forceUpdateAllAabbs; - } - -}; - - -#endif //COLLISION_WORLD_H diff --git a/bullet/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp b/bullet/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp deleted file mode 100644 index 3c3a971f2..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp +++ /dev/null @@ -1,351 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h" -#include "BulletCollision/CollisionDispatch/btCollisionObject.h" -#include "BulletCollision/CollisionShapes/btCompoundShape.h" -#include "BulletCollision/BroadphaseCollision/btDbvt.h" -#include "LinearMath/btIDebugDraw.h" -#include "LinearMath/btAabbUtil2.h" -#include "btManifoldResult.h" - -btCompoundCollisionAlgorithm::btCompoundCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped) -:btActivatingCollisionAlgorithm(ci,body0,body1), -m_isSwapped(isSwapped), -m_sharedManifold(ci.m_manifold) -{ - m_ownsManifold = false; - - btCollisionObject* colObj = m_isSwapped? body1 : body0; - btAssert (colObj->getCollisionShape()->isCompound()); - - btCompoundShape* compoundShape = static_cast(colObj->getCollisionShape()); - m_compoundShapeRevision = compoundShape->getUpdateRevision(); - - preallocateChildAlgorithms(body0,body1); -} - -void btCompoundCollisionAlgorithm::preallocateChildAlgorithms(btCollisionObject* body0,btCollisionObject* body1) -{ - btCollisionObject* colObj = m_isSwapped? body1 : body0; - btCollisionObject* otherObj = m_isSwapped? body0 : body1; - btAssert (colObj->getCollisionShape()->isCompound()); - - btCompoundShape* compoundShape = static_cast(colObj->getCollisionShape()); - - int numChildren = compoundShape->getNumChildShapes(); - int i; - - m_childCollisionAlgorithms.resize(numChildren); - for (i=0;igetDynamicAabbTree()) - { - m_childCollisionAlgorithms[i] = 0; - } else - { - btCollisionShape* tmpShape = colObj->getCollisionShape(); - btCollisionShape* childShape = compoundShape->getChildShape(i); - colObj->internalSetTemporaryCollisionShape( childShape ); - m_childCollisionAlgorithms[i] = m_dispatcher->findAlgorithm(colObj,otherObj,m_sharedManifold); - colObj->internalSetTemporaryCollisionShape( tmpShape ); - } - } -} - -void btCompoundCollisionAlgorithm::removeChildAlgorithms() -{ - int numChildren = m_childCollisionAlgorithms.size(); - int i; - for (i=0;i~btCollisionAlgorithm(); - m_dispatcher->freeCollisionAlgorithm(m_childCollisionAlgorithms[i]); - } - } -} - -btCompoundCollisionAlgorithm::~btCompoundCollisionAlgorithm() -{ - removeChildAlgorithms(); -} - - - - -struct btCompoundLeafCallback : btDbvt::ICollide -{ - -public: - - btCollisionObject* m_compoundColObj; - btCollisionObject* m_otherObj; - btDispatcher* m_dispatcher; - const btDispatcherInfo& m_dispatchInfo; - btManifoldResult* m_resultOut; - btCollisionAlgorithm** m_childCollisionAlgorithms; - btPersistentManifold* m_sharedManifold; - - - - - btCompoundLeafCallback (btCollisionObject* compoundObj,btCollisionObject* otherObj,btDispatcher* dispatcher,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut,btCollisionAlgorithm** childCollisionAlgorithms,btPersistentManifold* sharedManifold) - :m_compoundColObj(compoundObj),m_otherObj(otherObj),m_dispatcher(dispatcher),m_dispatchInfo(dispatchInfo),m_resultOut(resultOut), - m_childCollisionAlgorithms(childCollisionAlgorithms), - m_sharedManifold(sharedManifold) - { - - } - - - void ProcessChildShape(btCollisionShape* childShape,int index) - { - - btCompoundShape* compoundShape = static_cast(m_compoundColObj->getCollisionShape()); - - - //backup - btTransform orgTrans = m_compoundColObj->getWorldTransform(); - btTransform orgInterpolationTrans = m_compoundColObj->getInterpolationWorldTransform(); - const btTransform& childTrans = compoundShape->getChildTransform(index); - btTransform newChildWorldTrans = orgTrans*childTrans ; - - //perform an AABB check first - btVector3 aabbMin0,aabbMax0,aabbMin1,aabbMax1; - childShape->getAabb(newChildWorldTrans,aabbMin0,aabbMax0); - m_otherObj->getCollisionShape()->getAabb(m_otherObj->getWorldTransform(),aabbMin1,aabbMax1); - - if (TestAabbAgainstAabb2(aabbMin0,aabbMax0,aabbMin1,aabbMax1)) - { - - m_compoundColObj->setWorldTransform( newChildWorldTrans); - m_compoundColObj->setInterpolationWorldTransform(newChildWorldTrans); - - //the contactpoint is still projected back using the original inverted worldtrans - btCollisionShape* tmpShape = m_compoundColObj->getCollisionShape(); - m_compoundColObj->internalSetTemporaryCollisionShape( childShape ); - - if (!m_childCollisionAlgorithms[index]) - m_childCollisionAlgorithms[index] = m_dispatcher->findAlgorithm(m_compoundColObj,m_otherObj,m_sharedManifold); - - ///detect swapping case - if (m_resultOut->getBody0Internal() == m_compoundColObj) - { - m_resultOut->setShapeIdentifiersA(-1,index); - } else - { - m_resultOut->setShapeIdentifiersB(-1,index); - } - - m_childCollisionAlgorithms[index]->processCollision(m_compoundColObj,m_otherObj,m_dispatchInfo,m_resultOut); - if (m_dispatchInfo.m_debugDraw && (m_dispatchInfo.m_debugDraw->getDebugMode() & btIDebugDraw::DBG_DrawAabb)) - { - btVector3 worldAabbMin,worldAabbMax; - m_dispatchInfo.m_debugDraw->drawAabb(aabbMin0,aabbMax0,btVector3(1,1,1)); - m_dispatchInfo.m_debugDraw->drawAabb(aabbMin1,aabbMax1,btVector3(1,1,1)); - } - - //revert back transform - m_compoundColObj->internalSetTemporaryCollisionShape( tmpShape); - m_compoundColObj->setWorldTransform( orgTrans ); - m_compoundColObj->setInterpolationWorldTransform(orgInterpolationTrans); - } - } - void Process(const btDbvtNode* leaf) - { - int index = leaf->dataAsInt; - - btCompoundShape* compoundShape = static_cast(m_compoundColObj->getCollisionShape()); - btCollisionShape* childShape = compoundShape->getChildShape(index); - if (m_dispatchInfo.m_debugDraw && (m_dispatchInfo.m_debugDraw->getDebugMode() & btIDebugDraw::DBG_DrawAabb)) - { - btVector3 worldAabbMin,worldAabbMax; - btTransform orgTrans = m_compoundColObj->getWorldTransform(); - btTransformAabb(leaf->volume.Mins(),leaf->volume.Maxs(),0.,orgTrans,worldAabbMin,worldAabbMax); - m_dispatchInfo.m_debugDraw->drawAabb(worldAabbMin,worldAabbMax,btVector3(1,0,0)); - } - ProcessChildShape(childShape,index); - - } -}; - - - - - - -void btCompoundCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) -{ - btCollisionObject* colObj = m_isSwapped? body1 : body0; - btCollisionObject* otherObj = m_isSwapped? body0 : body1; - - - - btAssert (colObj->getCollisionShape()->isCompound()); - btCompoundShape* compoundShape = static_cast(colObj->getCollisionShape()); - - ///btCompoundShape might have changed: - ////make sure the internal child collision algorithm caches are still valid - if (compoundShape->getUpdateRevision() != m_compoundShapeRevision) - { - ///clear and update all - removeChildAlgorithms(); - - preallocateChildAlgorithms(body0,body1); - } - - - btDbvt* tree = compoundShape->getDynamicAabbTree(); - //use a dynamic aabb tree to cull potential child-overlaps - btCompoundLeafCallback callback(colObj,otherObj,m_dispatcher,dispatchInfo,resultOut,&m_childCollisionAlgorithms[0],m_sharedManifold); - - ///we need to refresh all contact manifolds - ///note that we should actually recursively traverse all children, btCompoundShape can nested more then 1 level deep - ///so we should add a 'refreshManifolds' in the btCollisionAlgorithm - { - int i; - btManifoldArray manifoldArray; - for (i=0;igetAllContactManifolds(manifoldArray); - for (int m=0;mgetNumContacts()) - { - resultOut->setPersistentManifold(manifoldArray[m]); - resultOut->refreshContactPoints(); - resultOut->setPersistentManifold(0);//??necessary? - } - } - manifoldArray.clear(); - } - } - } - - if (tree) - { - - btVector3 localAabbMin,localAabbMax; - btTransform otherInCompoundSpace; - otherInCompoundSpace = colObj->getWorldTransform().inverse() * otherObj->getWorldTransform(); - otherObj->getCollisionShape()->getAabb(otherInCompoundSpace,localAabbMin,localAabbMax); - - const ATTRIBUTE_ALIGNED16(btDbvtVolume) bounds=btDbvtVolume::FromMM(localAabbMin,localAabbMax); - //process all children, that overlap with the given AABB bounds - tree->collideTV(tree->m_root,bounds,callback); - - } else - { - //iterate over all children, perform an AABB check inside ProcessChildShape - int numChildren = m_childCollisionAlgorithms.size(); - int i; - for (i=0;igetChildShape(i),i); - } - } - - { - //iterate over all children, perform an AABB check inside ProcessChildShape - int numChildren = m_childCollisionAlgorithms.size(); - int i; - btManifoldArray manifoldArray; - - for (i=0;igetChildShape(i); - //if not longer overlapping, remove the algorithm - btTransform orgTrans = colObj->getWorldTransform(); - btTransform orgInterpolationTrans = colObj->getInterpolationWorldTransform(); - const btTransform& childTrans = compoundShape->getChildTransform(i); - btTransform newChildWorldTrans = orgTrans*childTrans ; - - //perform an AABB check first - btVector3 aabbMin0,aabbMax0,aabbMin1,aabbMax1; - childShape->getAabb(newChildWorldTrans,aabbMin0,aabbMax0); - otherObj->getCollisionShape()->getAabb(otherObj->getWorldTransform(),aabbMin1,aabbMax1); - - if (!TestAabbAgainstAabb2(aabbMin0,aabbMax0,aabbMin1,aabbMax1)) - { - m_childCollisionAlgorithms[i]->~btCollisionAlgorithm(); - m_dispatcher->freeCollisionAlgorithm(m_childCollisionAlgorithms[i]); - m_childCollisionAlgorithms[i] = 0; - } - - } - - } - - - - } -} - -btScalar btCompoundCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) -{ - - btCollisionObject* colObj = m_isSwapped? body1 : body0; - btCollisionObject* otherObj = m_isSwapped? body0 : body1; - - btAssert (colObj->getCollisionShape()->isCompound()); - - btCompoundShape* compoundShape = static_cast(colObj->getCollisionShape()); - - //We will use the OptimizedBVH, AABB tree to cull potential child-overlaps - //If both proxies are Compound, we will deal with that directly, by performing sequential/parallel tree traversals - //given Proxy0 and Proxy1, if both have a tree, Tree0 and Tree1, this means: - //determine overlapping nodes of Proxy1 using Proxy0 AABB against Tree1 - //then use each overlapping node AABB against Tree0 - //and vise versa. - - btScalar hitFraction = btScalar(1.); - - int numChildren = m_childCollisionAlgorithms.size(); - int i; - for (i=0;igetChildShape(i); - - //backup - btTransform orgTrans = colObj->getWorldTransform(); - - const btTransform& childTrans = compoundShape->getChildTransform(i); - //btTransform newChildWorldTrans = orgTrans*childTrans ; - colObj->setWorldTransform( orgTrans*childTrans ); - - btCollisionShape* tmpShape = colObj->getCollisionShape(); - colObj->internalSetTemporaryCollisionShape( childShape ); - btScalar frac = m_childCollisionAlgorithms[i]->calculateTimeOfImpact(colObj,otherObj,dispatchInfo,resultOut); - if (fracinternalSetTemporaryCollisionShape( tmpShape); - colObj->setWorldTransform( orgTrans); - } - return hitFraction; - -} - - - diff --git a/bullet/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h b/bullet/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h deleted file mode 100644 index 6ed30c92d..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h +++ /dev/null @@ -1,86 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef COMPOUND_COLLISION_ALGORITHM_H -#define COMPOUND_COLLISION_ALGORITHM_H - -#include "btActivatingCollisionAlgorithm.h" -#include "BulletCollision/BroadphaseCollision/btDispatcher.h" -#include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h" - -#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h" -class btDispatcher; -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" -#include "btCollisionCreateFunc.h" -#include "LinearMath/btAlignedObjectArray.h" -class btDispatcher; -class btCollisionObject; - -/// btCompoundCollisionAlgorithm supports collision between CompoundCollisionShapes and other collision shapes -class btCompoundCollisionAlgorithm : public btActivatingCollisionAlgorithm -{ - btAlignedObjectArray m_childCollisionAlgorithms; - bool m_isSwapped; - - class btPersistentManifold* m_sharedManifold; - bool m_ownsManifold; - - int m_compoundShapeRevision;//to keep track of changes, so that childAlgorithm array can be updated - - void removeChildAlgorithms(); - - void preallocateChildAlgorithms(btCollisionObject* body0,btCollisionObject* body1); - -public: - - btCompoundCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped); - - virtual ~btCompoundCollisionAlgorithm(); - - virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); - - btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); - - virtual void getAllContactManifolds(btManifoldArray& manifoldArray) - { - int i; - for (i=0;igetAllContactManifolds(manifoldArray); - } - } - - struct CreateFunc :public btCollisionAlgorithmCreateFunc - { - virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1) - { - void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btCompoundCollisionAlgorithm)); - return new(mem) btCompoundCollisionAlgorithm(ci,body0,body1,false); - } - }; - - struct SwappedCreateFunc :public btCollisionAlgorithmCreateFunc - { - virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1) - { - void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btCompoundCollisionAlgorithm)); - return new(mem) btCompoundCollisionAlgorithm(ci,body0,body1,true); - } - }; - -}; - -#endif //COMPOUND_COLLISION_ALGORITHM_H diff --git a/bullet/src/BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.cpp b/bullet/src/BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.cpp deleted file mode 100644 index 9d5d530c7..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.cpp +++ /dev/null @@ -1,247 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btConvex2dConvex2dAlgorithm.h" - -//#include -#include "BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h" -#include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h" -#include "BulletCollision/CollisionDispatch/btCollisionObject.h" -#include "BulletCollision/CollisionShapes/btConvexShape.h" -#include "BulletCollision/CollisionShapes/btCapsuleShape.h" - - -#include "BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h" -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" -#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h" -#include "BulletCollision/CollisionShapes/btBoxShape.h" -#include "BulletCollision/CollisionDispatch/btManifoldResult.h" - -#include "BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h" -#include "BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.h" -#include "BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h" -#include "BulletCollision/NarrowPhaseCollision/btGjkConvexCast.h" - - - -#include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h" -#include "BulletCollision/CollisionShapes/btSphereShape.h" - -#include "BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h" - -#include "BulletCollision/NarrowPhaseCollision/btGjkEpa2.h" -#include "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h" - - -btConvex2dConvex2dAlgorithm::CreateFunc::CreateFunc(btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver) -{ - m_numPerturbationIterations = 0; - m_minimumPointsPerturbationThreshold = 3; - m_simplexSolver = simplexSolver; - m_pdSolver = pdSolver; -} - -btConvex2dConvex2dAlgorithm::CreateFunc::~CreateFunc() -{ -} - -btConvex2dConvex2dAlgorithm::btConvex2dConvex2dAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver,int numPerturbationIterations, int minimumPointsPerturbationThreshold) -: btActivatingCollisionAlgorithm(ci,body0,body1), -m_simplexSolver(simplexSolver), -m_pdSolver(pdSolver), -m_ownManifold (false), -m_manifoldPtr(mf), -m_lowLevelOfDetail(false), - m_numPerturbationIterations(numPerturbationIterations), -m_minimumPointsPerturbationThreshold(minimumPointsPerturbationThreshold) -{ - (void)body0; - (void)body1; -} - - - - -btConvex2dConvex2dAlgorithm::~btConvex2dConvex2dAlgorithm() -{ - if (m_ownManifold) - { - if (m_manifoldPtr) - m_dispatcher->releaseManifold(m_manifoldPtr); - } -} - -void btConvex2dConvex2dAlgorithm ::setLowLevelOfDetail(bool useLowLevel) -{ - m_lowLevelOfDetail = useLowLevel; -} - - - -extern btScalar gContactBreakingThreshold; - - -// -// Convex-Convex collision algorithm -// -void btConvex2dConvex2dAlgorithm ::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) -{ - - if (!m_manifoldPtr) - { - //swapped? - m_manifoldPtr = m_dispatcher->getNewManifold(body0,body1); - m_ownManifold = true; - } - resultOut->setPersistentManifold(m_manifoldPtr); - - //comment-out next line to test multi-contact generation - //resultOut->getPersistentManifold()->clearManifold(); - - - btConvexShape* min0 = static_cast(body0->getCollisionShape()); - btConvexShape* min1 = static_cast(body1->getCollisionShape()); - - btVector3 normalOnB; - btVector3 pointOnBWorld; - - { - - - btGjkPairDetector::ClosestPointInput input; - - btGjkPairDetector gjkPairDetector(min0,min1,m_simplexSolver,m_pdSolver); - //TODO: if (dispatchInfo.m_useContinuous) - gjkPairDetector.setMinkowskiA(min0); - gjkPairDetector.setMinkowskiB(min1); - - { - input.m_maximumDistanceSquared = min0->getMargin() + min1->getMargin() + m_manifoldPtr->getContactBreakingThreshold(); - input.m_maximumDistanceSquared*= input.m_maximumDistanceSquared; - } - - input.m_stackAlloc = dispatchInfo.m_stackAllocator; - input.m_transformA = body0->getWorldTransform(); - input.m_transformB = body1->getWorldTransform(); - - gjkPairDetector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw); - - btVector3 v0,v1; - btVector3 sepNormalWorldSpace; - - } - - if (m_ownManifold) - { - resultOut->refreshContactPoints(); - } - -} - - - - -btScalar btConvex2dConvex2dAlgorithm::calculateTimeOfImpact(btCollisionObject* col0,btCollisionObject* col1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) -{ - (void)resultOut; - (void)dispatchInfo; - ///Rather then checking ALL pairs, only calculate TOI when motion exceeds threshold - - ///Linear motion for one of objects needs to exceed m_ccdSquareMotionThreshold - ///col0->m_worldTransform, - btScalar resultFraction = btScalar(1.); - - - btScalar squareMot0 = (col0->getInterpolationWorldTransform().getOrigin() - col0->getWorldTransform().getOrigin()).length2(); - btScalar squareMot1 = (col1->getInterpolationWorldTransform().getOrigin() - col1->getWorldTransform().getOrigin()).length2(); - - if (squareMot0 < col0->getCcdSquareMotionThreshold() && - squareMot1 < col1->getCcdSquareMotionThreshold()) - return resultFraction; - - - //An adhoc way of testing the Continuous Collision Detection algorithms - //One object is approximated as a sphere, to simplify things - //Starting in penetration should report no time of impact - //For proper CCD, better accuracy and handling of 'allowed' penetration should be added - //also the mainloop of the physics should have a kind of toi queue (something like Brian Mirtich's application of Timewarp for Rigidbodies) - - - /// Convex0 against sphere for Convex1 - { - btConvexShape* convex0 = static_cast(col0->getCollisionShape()); - - btSphereShape sphere1(col1->getCcdSweptSphereRadius()); //todo: allow non-zero sphere sizes, for better approximation - btConvexCast::CastResult result; - btVoronoiSimplexSolver voronoiSimplex; - //SubsimplexConvexCast ccd0(&sphere,min0,&voronoiSimplex); - ///Simplification, one object is simplified as a sphere - btGjkConvexCast ccd1( convex0 ,&sphere1,&voronoiSimplex); - //ContinuousConvexCollision ccd(min0,min1,&voronoiSimplex,0); - if (ccd1.calcTimeOfImpact(col0->getWorldTransform(),col0->getInterpolationWorldTransform(), - col1->getWorldTransform(),col1->getInterpolationWorldTransform(),result)) - { - - //store result.m_fraction in both bodies - - if (col0->getHitFraction()> result.m_fraction) - col0->setHitFraction( result.m_fraction ); - - if (col1->getHitFraction() > result.m_fraction) - col1->setHitFraction( result.m_fraction); - - if (resultFraction > result.m_fraction) - resultFraction = result.m_fraction; - - } - - - - - } - - /// Sphere (for convex0) against Convex1 - { - btConvexShape* convex1 = static_cast(col1->getCollisionShape()); - - btSphereShape sphere0(col0->getCcdSweptSphereRadius()); //todo: allow non-zero sphere sizes, for better approximation - btConvexCast::CastResult result; - btVoronoiSimplexSolver voronoiSimplex; - //SubsimplexConvexCast ccd0(&sphere,min0,&voronoiSimplex); - ///Simplification, one object is simplified as a sphere - btGjkConvexCast ccd1(&sphere0,convex1,&voronoiSimplex); - //ContinuousConvexCollision ccd(min0,min1,&voronoiSimplex,0); - if (ccd1.calcTimeOfImpact(col0->getWorldTransform(),col0->getInterpolationWorldTransform(), - col1->getWorldTransform(),col1->getInterpolationWorldTransform(),result)) - { - - //store result.m_fraction in both bodies - - if (col0->getHitFraction() > result.m_fraction) - col0->setHitFraction( result.m_fraction); - - if (col1->getHitFraction() > result.m_fraction) - col1->setHitFraction( result.m_fraction); - - if (resultFraction > result.m_fraction) - resultFraction = result.m_fraction; - - } - } - - return resultFraction; - -} - diff --git a/bullet/src/BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.h b/bullet/src/BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.h deleted file mode 100644 index f3916bcc5..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.h +++ /dev/null @@ -1,95 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef CONVEX_2D_CONVEX_2D_ALGORITHM_H -#define CONVEX_2D_CONVEX_2D_ALGORITHM_H - -#include "BulletCollision/CollisionDispatch/btActivatingCollisionAlgorithm.h" -#include "BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h" -#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h" -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" -#include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h" -#include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h" -#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h" -#include "LinearMath/btTransformUtil.h" //for btConvexSeparatingDistanceUtil - -class btConvexPenetrationDepthSolver; - - -///The convex2dConvex2dAlgorithm collision algorithm support 2d collision detection for btConvex2dShape -///Currently it requires the btMinkowskiPenetrationDepthSolver, it has support for 2d penetration depth computation -class btConvex2dConvex2dAlgorithm : public btActivatingCollisionAlgorithm -{ - btSimplexSolverInterface* m_simplexSolver; - btConvexPenetrationDepthSolver* m_pdSolver; - - - bool m_ownManifold; - btPersistentManifold* m_manifoldPtr; - bool m_lowLevelOfDetail; - - int m_numPerturbationIterations; - int m_minimumPointsPerturbationThreshold; - -public: - - btConvex2dConvex2dAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1, btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver, int numPerturbationIterations, int minimumPointsPerturbationThreshold); - - - virtual ~btConvex2dConvex2dAlgorithm(); - - virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); - - virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); - - virtual void getAllContactManifolds(btManifoldArray& manifoldArray) - { - ///should we use m_ownManifold to avoid adding duplicates? - if (m_manifoldPtr && m_ownManifold) - manifoldArray.push_back(m_manifoldPtr); - } - - - void setLowLevelOfDetail(bool useLowLevel); - - - const btPersistentManifold* getManifold() - { - return m_manifoldPtr; - } - - struct CreateFunc :public btCollisionAlgorithmCreateFunc - { - - btConvexPenetrationDepthSolver* m_pdSolver; - btSimplexSolverInterface* m_simplexSolver; - int m_numPerturbationIterations; - int m_minimumPointsPerturbationThreshold; - - CreateFunc(btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver); - - virtual ~CreateFunc(); - - virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1) - { - void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btConvex2dConvex2dAlgorithm)); - return new(mem) btConvex2dConvex2dAlgorithm(ci.m_manifold,ci,body0,body1,m_simplexSolver,m_pdSolver,m_numPerturbationIterations,m_minimumPointsPerturbationThreshold); - } - }; - - -}; - -#endif //CONVEX_2D_CONVEX_2D_ALGORITHM_H diff --git a/bullet/src/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp b/bullet/src/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp deleted file mode 100644 index d5f5c3a80..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp +++ /dev/null @@ -1,317 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#include "btConvexConcaveCollisionAlgorithm.h" -#include "BulletCollision/CollisionDispatch/btCollisionObject.h" -#include "BulletCollision/CollisionShapes/btMultiSphereShape.h" -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" -#include "BulletCollision/CollisionShapes/btConcaveShape.h" -#include "BulletCollision/CollisionDispatch/btManifoldResult.h" -#include "BulletCollision/NarrowPhaseCollision/btRaycastCallback.h" -#include "BulletCollision/CollisionShapes/btTriangleShape.h" -#include "BulletCollision/CollisionShapes/btSphereShape.h" -#include "LinearMath/btIDebugDraw.h" -#include "BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h" - -btConvexConcaveCollisionAlgorithm::btConvexConcaveCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1,bool isSwapped) -: btActivatingCollisionAlgorithm(ci,body0,body1), -m_isSwapped(isSwapped), -m_btConvexTriangleCallback(ci.m_dispatcher1,body0,body1,isSwapped) -{ -} - -btConvexConcaveCollisionAlgorithm::~btConvexConcaveCollisionAlgorithm() -{ -} - -void btConvexConcaveCollisionAlgorithm::getAllContactManifolds(btManifoldArray& manifoldArray) -{ - if (m_btConvexTriangleCallback.m_manifoldPtr) - { - manifoldArray.push_back(m_btConvexTriangleCallback.m_manifoldPtr); - } -} - - -btConvexTriangleCallback::btConvexTriangleCallback(btDispatcher* dispatcher,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped): - m_dispatcher(dispatcher), - m_dispatchInfoPtr(0) -{ - m_convexBody = isSwapped? body1:body0; - m_triBody = isSwapped? body0:body1; - - // - // create the manifold from the dispatcher 'manifold pool' - // - m_manifoldPtr = m_dispatcher->getNewManifold(m_convexBody,m_triBody); - - clearCache(); -} - -btConvexTriangleCallback::~btConvexTriangleCallback() -{ - clearCache(); - m_dispatcher->releaseManifold( m_manifoldPtr ); - -} - - -void btConvexTriangleCallback::clearCache() -{ - m_dispatcher->clearManifold(m_manifoldPtr); -} - - - -void btConvexTriangleCallback::processTriangle(btVector3* triangle,int partId, int triangleIndex) -{ - - //just for debugging purposes - //printf("triangle %d",m_triangleCount++); - - - //aabb filter is already applied! - - btCollisionAlgorithmConstructionInfo ci; - ci.m_dispatcher1 = m_dispatcher; - - btCollisionObject* ob = static_cast(m_triBody); - - - - ///debug drawing of the overlapping triangles - if (m_dispatchInfoPtr && m_dispatchInfoPtr->m_debugDraw && (m_dispatchInfoPtr->m_debugDraw->getDebugMode() &btIDebugDraw::DBG_DrawWireframe )) - { - btVector3 color(255,255,0); - btTransform& tr = ob->getWorldTransform(); - m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[0]),tr(triangle[1]),color); - m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[1]),tr(triangle[2]),color); - m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[2]),tr(triangle[0]),color); - - //btVector3 center = triangle[0] + triangle[1]+triangle[2]; - //center *= btScalar(0.333333); - //m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[0]),tr(center),color); - //m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[1]),tr(center),color); - //m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[2]),tr(center),color); - - } - - - //btCollisionObject* colObj = static_cast(m_convexProxy->m_clientObject); - - if (m_convexBody->getCollisionShape()->isConvex()) - { - btTriangleShape tm(triangle[0],triangle[1],triangle[2]); - tm.setMargin(m_collisionMarginTriangle); - - btCollisionShape* tmpShape = ob->getCollisionShape(); - ob->internalSetTemporaryCollisionShape( &tm ); - - btCollisionAlgorithm* colAlgo = ci.m_dispatcher1->findAlgorithm(m_convexBody,m_triBody,m_manifoldPtr); - ///this should use the btDispatcher, so the actual registered algorithm is used - // btConvexConvexAlgorithm cvxcvxalgo(m_manifoldPtr,ci,m_convexBody,m_triBody); - - m_resultOut->setShapeIdentifiersB(partId,triangleIndex); - -// cvxcvxalgo.processCollision(m_convexBody,m_triBody,*m_dispatchInfoPtr,m_resultOut); - colAlgo->processCollision(m_convexBody,m_triBody,*m_dispatchInfoPtr,m_resultOut); - colAlgo->~btCollisionAlgorithm(); - ci.m_dispatcher1->freeCollisionAlgorithm(colAlgo); - ob->internalSetTemporaryCollisionShape( tmpShape); - } - - -} - - - -void btConvexTriangleCallback::setTimeStepAndCounters(btScalar collisionMarginTriangle,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) -{ - m_dispatchInfoPtr = &dispatchInfo; - m_collisionMarginTriangle = collisionMarginTriangle; - m_resultOut = resultOut; - - //recalc aabbs - btTransform convexInTriangleSpace; - convexInTriangleSpace = m_triBody->getWorldTransform().inverse() * m_convexBody->getWorldTransform(); - btCollisionShape* convexShape = static_cast(m_convexBody->getCollisionShape()); - //CollisionShape* triangleShape = static_cast(triBody->m_collisionShape); - convexShape->getAabb(convexInTriangleSpace,m_aabbMin,m_aabbMax); - btScalar extraMargin = collisionMarginTriangle; - btVector3 extra(extraMargin,extraMargin,extraMargin); - - m_aabbMax += extra; - m_aabbMin -= extra; - -} - -void btConvexConcaveCollisionAlgorithm::clearCache() -{ - m_btConvexTriangleCallback.clearCache(); - -} - -void btConvexConcaveCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) -{ - - - btCollisionObject* convexBody = m_isSwapped ? body1 : body0; - btCollisionObject* triBody = m_isSwapped ? body0 : body1; - - if (triBody->getCollisionShape()->isConcave()) - { - - - btCollisionObject* triOb = triBody; - btConcaveShape* concaveShape = static_cast( triOb->getCollisionShape()); - - if (convexBody->getCollisionShape()->isConvex()) - { - btScalar collisionMarginTriangle = concaveShape->getMargin(); - - resultOut->setPersistentManifold(m_btConvexTriangleCallback.m_manifoldPtr); - m_btConvexTriangleCallback.setTimeStepAndCounters(collisionMarginTriangle,dispatchInfo,resultOut); - - //Disable persistency. previously, some older algorithm calculated all contacts in one go, so you can clear it here. - //m_dispatcher->clearManifold(m_btConvexTriangleCallback.m_manifoldPtr); - - m_btConvexTriangleCallback.m_manifoldPtr->setBodies(convexBody,triBody); - - concaveShape->processAllTriangles( &m_btConvexTriangleCallback,m_btConvexTriangleCallback.getAabbMin(),m_btConvexTriangleCallback.getAabbMax()); - - resultOut->refreshContactPoints(); - - } - - } - -} - - -btScalar btConvexConcaveCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) -{ - (void)resultOut; - (void)dispatchInfo; - btCollisionObject* convexbody = m_isSwapped ? body1 : body0; - btCollisionObject* triBody = m_isSwapped ? body0 : body1; - - - //quick approximation using raycast, todo: hook up to the continuous collision detection (one of the btConvexCast) - - //only perform CCD above a certain threshold, this prevents blocking on the long run - //because object in a blocked ccd state (hitfraction<1) get their linear velocity halved each frame... - btScalar squareMot0 = (convexbody->getInterpolationWorldTransform().getOrigin() - convexbody->getWorldTransform().getOrigin()).length2(); - if (squareMot0 < convexbody->getCcdSquareMotionThreshold()) - { - return btScalar(1.); - } - - //const btVector3& from = convexbody->m_worldTransform.getOrigin(); - //btVector3 to = convexbody->m_interpolationWorldTransform.getOrigin(); - //todo: only do if the motion exceeds the 'radius' - - btTransform triInv = triBody->getWorldTransform().inverse(); - btTransform convexFromLocal = triInv * convexbody->getWorldTransform(); - btTransform convexToLocal = triInv * convexbody->getInterpolationWorldTransform(); - - struct LocalTriangleSphereCastCallback : public btTriangleCallback - { - btTransform m_ccdSphereFromTrans; - btTransform m_ccdSphereToTrans; - btTransform m_meshTransform; - - btScalar m_ccdSphereRadius; - btScalar m_hitFraction; - - - LocalTriangleSphereCastCallback(const btTransform& from,const btTransform& to,btScalar ccdSphereRadius,btScalar hitFraction) - :m_ccdSphereFromTrans(from), - m_ccdSphereToTrans(to), - m_ccdSphereRadius(ccdSphereRadius), - m_hitFraction(hitFraction) - { - } - - - virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex) - { - (void)partId; - (void)triangleIndex; - //do a swept sphere for now - btTransform ident; - ident.setIdentity(); - btConvexCast::CastResult castResult; - castResult.m_fraction = m_hitFraction; - btSphereShape pointShape(m_ccdSphereRadius); - btTriangleShape triShape(triangle[0],triangle[1],triangle[2]); - btVoronoiSimplexSolver simplexSolver; - btSubsimplexConvexCast convexCaster(&pointShape,&triShape,&simplexSolver); - //GjkConvexCast convexCaster(&pointShape,convexShape,&simplexSolver); - //ContinuousConvexCollision convexCaster(&pointShape,convexShape,&simplexSolver,0); - //local space? - - if (convexCaster.calcTimeOfImpact(m_ccdSphereFromTrans,m_ccdSphereToTrans, - ident,ident,castResult)) - { - if (m_hitFraction > castResult.m_fraction) - m_hitFraction = castResult.m_fraction; - } - - } - - }; - - - - - - if (triBody->getCollisionShape()->isConcave()) - { - btVector3 rayAabbMin = convexFromLocal.getOrigin(); - rayAabbMin.setMin(convexToLocal.getOrigin()); - btVector3 rayAabbMax = convexFromLocal.getOrigin(); - rayAabbMax.setMax(convexToLocal.getOrigin()); - btScalar ccdRadius0 = convexbody->getCcdSweptSphereRadius(); - rayAabbMin -= btVector3(ccdRadius0,ccdRadius0,ccdRadius0); - rayAabbMax += btVector3(ccdRadius0,ccdRadius0,ccdRadius0); - - btScalar curHitFraction = btScalar(1.); //is this available? - LocalTriangleSphereCastCallback raycastCallback(convexFromLocal,convexToLocal, - convexbody->getCcdSweptSphereRadius(),curHitFraction); - - raycastCallback.m_hitFraction = convexbody->getHitFraction(); - - btCollisionObject* concavebody = triBody; - - btConcaveShape* triangleMesh = (btConcaveShape*) concavebody->getCollisionShape(); - - if (triangleMesh) - { - triangleMesh->processAllTriangles(&raycastCallback,rayAabbMin,rayAabbMax); - } - - - - if (raycastCallback.m_hitFraction < convexbody->getHitFraction()) - { - convexbody->setHitFraction( raycastCallback.m_hitFraction); - return raycastCallback.m_hitFraction; - } - } - - return btScalar(1.); - -} diff --git a/bullet/src/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.h b/bullet/src/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.h deleted file mode 100644 index 48bc4e916..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.h +++ /dev/null @@ -1,116 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef CONVEX_CONCAVE_COLLISION_ALGORITHM_H -#define CONVEX_CONCAVE_COLLISION_ALGORITHM_H - -#include "btActivatingCollisionAlgorithm.h" -#include "BulletCollision/BroadphaseCollision/btDispatcher.h" -#include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h" -#include "BulletCollision/CollisionShapes/btTriangleCallback.h" -#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h" -class btDispatcher; -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" -#include "btCollisionCreateFunc.h" - -///For each triangle in the concave mesh that overlaps with the AABB of a convex (m_convexProxy), processTriangle is called. -class btConvexTriangleCallback : public btTriangleCallback -{ - btCollisionObject* m_convexBody; - btCollisionObject* m_triBody; - - btVector3 m_aabbMin; - btVector3 m_aabbMax ; - - - btManifoldResult* m_resultOut; - btDispatcher* m_dispatcher; - const btDispatcherInfo* m_dispatchInfoPtr; - btScalar m_collisionMarginTriangle; - -public: -int m_triangleCount; - - btPersistentManifold* m_manifoldPtr; - - btConvexTriangleCallback(btDispatcher* dispatcher,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped); - - void setTimeStepAndCounters(btScalar collisionMarginTriangle,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); - - virtual ~btConvexTriangleCallback(); - - virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex); - - void clearCache(); - - SIMD_FORCE_INLINE const btVector3& getAabbMin() const - { - return m_aabbMin; - } - SIMD_FORCE_INLINE const btVector3& getAabbMax() const - { - return m_aabbMax; - } - -}; - - - - -/// btConvexConcaveCollisionAlgorithm supports collision between convex shapes and (concave) trianges meshes. -class btConvexConcaveCollisionAlgorithm : public btActivatingCollisionAlgorithm -{ - - bool m_isSwapped; - - btConvexTriangleCallback m_btConvexTriangleCallback; - - - -public: - - btConvexConcaveCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped); - - virtual ~btConvexConcaveCollisionAlgorithm(); - - virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); - - btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); - - virtual void getAllContactManifolds(btManifoldArray& manifoldArray); - - void clearCache(); - - struct CreateFunc :public btCollisionAlgorithmCreateFunc - { - virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1) - { - void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btConvexConcaveCollisionAlgorithm)); - return new(mem) btConvexConcaveCollisionAlgorithm(ci,body0,body1,false); - } - }; - - struct SwappedCreateFunc :public btCollisionAlgorithmCreateFunc - { - virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1) - { - void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btConvexConcaveCollisionAlgorithm)); - return new(mem) btConvexConcaveCollisionAlgorithm(ci,body0,body1,true); - } - }; - -}; - -#endif //CONVEX_CONCAVE_COLLISION_ALGORITHM_H diff --git a/bullet/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp b/bullet/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp deleted file mode 100644 index 5bf0f335b..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp +++ /dev/null @@ -1,565 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -///Specialized capsule-capsule collision algorithm has been added for Bullet 2.75 release to increase ragdoll performance -///If you experience problems with capsule-capsule collision, try to define BT_DISABLE_CAPSULE_CAPSULE_COLLIDER and report it in the Bullet forums -///with reproduction case -//define BT_DISABLE_CAPSULE_CAPSULE_COLLIDER 1 - -#include "btConvexConvexAlgorithm.h" - -//#include -#include "BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h" -#include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h" -#include "BulletCollision/CollisionDispatch/btCollisionObject.h" -#include "BulletCollision/CollisionShapes/btConvexShape.h" -#include "BulletCollision/CollisionShapes/btCapsuleShape.h" - - -#include "BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h" -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" -#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h" -#include "BulletCollision/CollisionShapes/btBoxShape.h" -#include "BulletCollision/CollisionDispatch/btManifoldResult.h" - -#include "BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h" -#include "BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.h" -#include "BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h" -#include "BulletCollision/NarrowPhaseCollision/btGjkConvexCast.h" - - - -#include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h" -#include "BulletCollision/CollisionShapes/btSphereShape.h" - -#include "BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h" - -#include "BulletCollision/NarrowPhaseCollision/btGjkEpa2.h" -#include "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h" - - - -/////////// - - - -static SIMD_FORCE_INLINE void segmentsClosestPoints( - btVector3& ptsVector, - btVector3& offsetA, - btVector3& offsetB, - btScalar& tA, btScalar& tB, - const btVector3& translation, - const btVector3& dirA, btScalar hlenA, - const btVector3& dirB, btScalar hlenB ) -{ - // compute the parameters of the closest points on each line segment - - btScalar dirA_dot_dirB = btDot(dirA,dirB); - btScalar dirA_dot_trans = btDot(dirA,translation); - btScalar dirB_dot_trans = btDot(dirB,translation); - - btScalar denom = 1.0f - dirA_dot_dirB * dirA_dot_dirB; - - if ( denom == 0.0f ) { - tA = 0.0f; - } else { - tA = ( dirA_dot_trans - dirB_dot_trans * dirA_dot_dirB ) / denom; - if ( tA < -hlenA ) - tA = -hlenA; - else if ( tA > hlenA ) - tA = hlenA; - } - - tB = tA * dirA_dot_dirB - dirB_dot_trans; - - if ( tB < -hlenB ) { - tB = -hlenB; - tA = tB * dirA_dot_dirB + dirA_dot_trans; - - if ( tA < -hlenA ) - tA = -hlenA; - else if ( tA > hlenA ) - tA = hlenA; - } else if ( tB > hlenB ) { - tB = hlenB; - tA = tB * dirA_dot_dirB + dirA_dot_trans; - - if ( tA < -hlenA ) - tA = -hlenA; - else if ( tA > hlenA ) - tA = hlenA; - } - - // compute the closest points relative to segment centers. - - offsetA = dirA * tA; - offsetB = dirB * tB; - - ptsVector = translation - offsetA + offsetB; -} - - -static SIMD_FORCE_INLINE btScalar capsuleCapsuleDistance( - btVector3& normalOnB, - btVector3& pointOnB, - btScalar capsuleLengthA, - btScalar capsuleRadiusA, - btScalar capsuleLengthB, - btScalar capsuleRadiusB, - int capsuleAxisA, - int capsuleAxisB, - const btTransform& transformA, - const btTransform& transformB, - btScalar distanceThreshold ) -{ - btVector3 directionA = transformA.getBasis().getColumn(capsuleAxisA); - btVector3 translationA = transformA.getOrigin(); - btVector3 directionB = transformB.getBasis().getColumn(capsuleAxisB); - btVector3 translationB = transformB.getOrigin(); - - // translation between centers - - btVector3 translation = translationB - translationA; - - // compute the closest points of the capsule line segments - - btVector3 ptsVector; // the vector between the closest points - - btVector3 offsetA, offsetB; // offsets from segment centers to their closest points - btScalar tA, tB; // parameters on line segment - - segmentsClosestPoints( ptsVector, offsetA, offsetB, tA, tB, translation, - directionA, capsuleLengthA, directionB, capsuleLengthB ); - - btScalar distance = ptsVector.length() - capsuleRadiusA - capsuleRadiusB; - - if ( distance > distanceThreshold ) - return distance; - - btScalar lenSqr = ptsVector.length2(); - if (lenSqr<= (SIMD_EPSILON*SIMD_EPSILON)) - { - //degenerate case where 2 capsules are likely at the same location: take a vector tangential to 'directionA' - btVector3 q; - btPlaneSpace1(directionA,normalOnB,q); - } else - { - // compute the contact normal - normalOnB = ptsVector*-btRecipSqrt(lenSqr); - } - pointOnB = transformB.getOrigin()+offsetB + normalOnB * capsuleRadiusB; - - return distance; -} - - - - - - - -////////// - - - - - -btConvexConvexAlgorithm::CreateFunc::CreateFunc(btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver) -{ - m_numPerturbationIterations = 0; - m_minimumPointsPerturbationThreshold = 3; - m_simplexSolver = simplexSolver; - m_pdSolver = pdSolver; -} - -btConvexConvexAlgorithm::CreateFunc::~CreateFunc() -{ -} - -btConvexConvexAlgorithm::btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver,int numPerturbationIterations, int minimumPointsPerturbationThreshold) -: btActivatingCollisionAlgorithm(ci,body0,body1), -m_simplexSolver(simplexSolver), -m_pdSolver(pdSolver), -m_ownManifold (false), -m_manifoldPtr(mf), -m_lowLevelOfDetail(false), -#ifdef USE_SEPDISTANCE_UTIL2 -m_sepDistance((static_cast(body0->getCollisionShape()))->getAngularMotionDisc(), - (static_cast(body1->getCollisionShape()))->getAngularMotionDisc()), -#endif -m_numPerturbationIterations(numPerturbationIterations), -m_minimumPointsPerturbationThreshold(minimumPointsPerturbationThreshold) -{ - (void)body0; - (void)body1; -} - - - - -btConvexConvexAlgorithm::~btConvexConvexAlgorithm() -{ - if (m_ownManifold) - { - if (m_manifoldPtr) - m_dispatcher->releaseManifold(m_manifoldPtr); - } -} - -void btConvexConvexAlgorithm ::setLowLevelOfDetail(bool useLowLevel) -{ - m_lowLevelOfDetail = useLowLevel; -} - - -struct btPerturbedContactResult : public btManifoldResult -{ - btManifoldResult* m_originalManifoldResult; - btTransform m_transformA; - btTransform m_transformB; - btTransform m_unPerturbedTransform; - bool m_perturbA; - btIDebugDraw* m_debugDrawer; - - - btPerturbedContactResult(btManifoldResult* originalResult,const btTransform& transformA,const btTransform& transformB,const btTransform& unPerturbedTransform,bool perturbA,btIDebugDraw* debugDrawer) - :m_originalManifoldResult(originalResult), - m_transformA(transformA), - m_transformB(transformB), - m_perturbA(perturbA), - m_unPerturbedTransform(unPerturbedTransform), - m_debugDrawer(debugDrawer) - { - } - virtual ~ btPerturbedContactResult() - { - } - - virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar orgDepth) - { - btVector3 endPt,startPt; - btScalar newDepth; - btVector3 newNormal; - - if (m_perturbA) - { - btVector3 endPtOrg = pointInWorld + normalOnBInWorld*orgDepth; - endPt = (m_unPerturbedTransform*m_transformA.inverse())(endPtOrg); - newDepth = (endPt - pointInWorld).dot(normalOnBInWorld); - startPt = endPt+normalOnBInWorld*newDepth; - } else - { - endPt = pointInWorld + normalOnBInWorld*orgDepth; - startPt = (m_unPerturbedTransform*m_transformB.inverse())(pointInWorld); - newDepth = (endPt - startPt).dot(normalOnBInWorld); - - } - -//#define DEBUG_CONTACTS 1 -#ifdef DEBUG_CONTACTS - m_debugDrawer->drawLine(startPt,endPt,btVector3(1,0,0)); - m_debugDrawer->drawSphere(startPt,0.05,btVector3(0,1,0)); - m_debugDrawer->drawSphere(endPt,0.05,btVector3(0,0,1)); -#endif //DEBUG_CONTACTS - - - m_originalManifoldResult->addContactPoint(normalOnBInWorld,startPt,newDepth); - } - -}; - -extern btScalar gContactBreakingThreshold; - - -// -// Convex-Convex collision algorithm -// -void btConvexConvexAlgorithm ::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) -{ - - if (!m_manifoldPtr) - { - //swapped? - m_manifoldPtr = m_dispatcher->getNewManifold(body0,body1); - m_ownManifold = true; - } - resultOut->setPersistentManifold(m_manifoldPtr); - - //comment-out next line to test multi-contact generation - //resultOut->getPersistentManifold()->clearManifold(); - - - btConvexShape* min0 = static_cast(body0->getCollisionShape()); - btConvexShape* min1 = static_cast(body1->getCollisionShape()); - - btVector3 normalOnB; - btVector3 pointOnBWorld; -#ifndef BT_DISABLE_CAPSULE_CAPSULE_COLLIDER - if ((min0->getShapeType() == CAPSULE_SHAPE_PROXYTYPE) && (min1->getShapeType() == CAPSULE_SHAPE_PROXYTYPE)) - { - btCapsuleShape* capsuleA = (btCapsuleShape*) min0; - btCapsuleShape* capsuleB = (btCapsuleShape*) min1; - btVector3 localScalingA = capsuleA->getLocalScaling(); - btVector3 localScalingB = capsuleB->getLocalScaling(); - - btScalar threshold = m_manifoldPtr->getContactBreakingThreshold(); - - btScalar dist = capsuleCapsuleDistance(normalOnB, pointOnBWorld,capsuleA->getHalfHeight(),capsuleA->getRadius(), - capsuleB->getHalfHeight(),capsuleB->getRadius(),capsuleA->getUpAxis(),capsuleB->getUpAxis(), - body0->getWorldTransform(),body1->getWorldTransform(),threshold); - - if (dist=(SIMD_EPSILON*SIMD_EPSILON)); - resultOut->addContactPoint(normalOnB,pointOnBWorld,dist); - } - resultOut->refreshContactPoints(); - return; - } -#endif //BT_DISABLE_CAPSULE_CAPSULE_COLLIDER - - -#ifdef USE_SEPDISTANCE_UTIL2 - m_sepDistance.updateSeparatingDistance(body0->getWorldTransform(),body1->getWorldTransform()); - if (!dispatchInfo.m_useConvexConservativeDistanceUtil || m_sepDistance.getConservativeSeparatingDistance()<=0.f) -#endif //USE_SEPDISTANCE_UTIL2 - - { - - - btGjkPairDetector::ClosestPointInput input; - - btGjkPairDetector gjkPairDetector(min0,min1,m_simplexSolver,m_pdSolver); - //TODO: if (dispatchInfo.m_useContinuous) - gjkPairDetector.setMinkowskiA(min0); - gjkPairDetector.setMinkowskiB(min1); - -#ifdef USE_SEPDISTANCE_UTIL2 - if (dispatchInfo.m_useConvexConservativeDistanceUtil) - { - input.m_maximumDistanceSquared = BT_LARGE_FLOAT; - } else -#endif //USE_SEPDISTANCE_UTIL2 - { - input.m_maximumDistanceSquared = min0->getMargin() + min1->getMargin() + m_manifoldPtr->getContactBreakingThreshold(); - input.m_maximumDistanceSquared*= input.m_maximumDistanceSquared; - } - - input.m_stackAlloc = dispatchInfo.m_stackAllocator; - input.m_transformA = body0->getWorldTransform(); - input.m_transformB = body1->getWorldTransform(); - - gjkPairDetector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw); - - btVector3 v0,v1; - btVector3 sepNormalWorldSpace; - - -#ifdef USE_SEPDISTANCE_UTIL2 - btScalar sepDist = 0.f; - if (dispatchInfo.m_useConvexConservativeDistanceUtil) - { - sepDist = gjkPairDetector.getCachedSeparatingDistance(); - if (sepDist>SIMD_EPSILON) - { - sepDist += dispatchInfo.m_convexConservativeDistanceThreshold; - //now perturbe directions to get multiple contact points - sepNormalWorldSpace = gjkPairDetector.getCachedSeparatingAxis().normalized(); - btPlaneSpace1(sepNormalWorldSpace,v0,v1); - } - } -#endif //USE_SEPDISTANCE_UTIL2 - - //now perform 'm_numPerturbationIterations' collision queries with the perturbated collision objects - - //perform perturbation when more then 'm_minimumPointsPerturbationThreshold' points - if (resultOut->getPersistentManifold()->getNumContacts() < m_minimumPointsPerturbationThreshold) - { - - int i; - - bool perturbeA = true; - const btScalar angleLimit = 0.125f * SIMD_PI; - btScalar perturbeAngle; - btScalar radiusA = min0->getAngularMotionDisc(); - btScalar radiusB = min1->getAngularMotionDisc(); - if (radiusA < radiusB) - { - perturbeAngle = gContactBreakingThreshold /radiusA; - perturbeA = true; - } else - { - perturbeAngle = gContactBreakingThreshold / radiusB; - perturbeA = false; - } - if ( perturbeAngle > angleLimit ) - perturbeAngle = angleLimit; - - btTransform unPerturbedTransform; - if (perturbeA) - { - unPerturbedTransform = input.m_transformA; - } else - { - unPerturbedTransform = input.m_transformB; - } - - for ( i=0;igetWorldTransform().getBasis()); - input.m_transformB = body1->getWorldTransform(); -#ifdef DEBUG_CONTACTS - dispatchInfo.m_debugDraw->drawTransform(input.m_transformA,10.0); -#endif //DEBUG_CONTACTS - } else - { - input.m_transformA = body0->getWorldTransform(); - input.m_transformB.setBasis( btMatrix3x3(rotq.inverse()*perturbeRot*rotq)*body1->getWorldTransform().getBasis()); -#ifdef DEBUG_CONTACTS - dispatchInfo.m_debugDraw->drawTransform(input.m_transformB,10.0); -#endif - } - - btPerturbedContactResult perturbedResultOut(resultOut,input.m_transformA,input.m_transformB,unPerturbedTransform,perturbeA,dispatchInfo.m_debugDraw); - gjkPairDetector.getClosestPoints(input,perturbedResultOut,dispatchInfo.m_debugDraw); - - - } - } - - - -#ifdef USE_SEPDISTANCE_UTIL2 - if (dispatchInfo.m_useConvexConservativeDistanceUtil && (sepDist>SIMD_EPSILON)) - { - m_sepDistance.initSeparatingDistance(gjkPairDetector.getCachedSeparatingAxis(),sepDist,body0->getWorldTransform(),body1->getWorldTransform()); - } -#endif //USE_SEPDISTANCE_UTIL2 - - - } - - if (m_ownManifold) - { - resultOut->refreshContactPoints(); - } - -} - - - -bool disableCcd = false; -btScalar btConvexConvexAlgorithm::calculateTimeOfImpact(btCollisionObject* col0,btCollisionObject* col1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) -{ - (void)resultOut; - (void)dispatchInfo; - ///Rather then checking ALL pairs, only calculate TOI when motion exceeds threshold - - ///Linear motion for one of objects needs to exceed m_ccdSquareMotionThreshold - ///col0->m_worldTransform, - btScalar resultFraction = btScalar(1.); - - - btScalar squareMot0 = (col0->getInterpolationWorldTransform().getOrigin() - col0->getWorldTransform().getOrigin()).length2(); - btScalar squareMot1 = (col1->getInterpolationWorldTransform().getOrigin() - col1->getWorldTransform().getOrigin()).length2(); - - if (squareMot0 < col0->getCcdSquareMotionThreshold() && - squareMot1 < col1->getCcdSquareMotionThreshold()) - return resultFraction; - - if (disableCcd) - return btScalar(1.); - - - //An adhoc way of testing the Continuous Collision Detection algorithms - //One object is approximated as a sphere, to simplify things - //Starting in penetration should report no time of impact - //For proper CCD, better accuracy and handling of 'allowed' penetration should be added - //also the mainloop of the physics should have a kind of toi queue (something like Brian Mirtich's application of Timewarp for Rigidbodies) - - - /// Convex0 against sphere for Convex1 - { - btConvexShape* convex0 = static_cast(col0->getCollisionShape()); - - btSphereShape sphere1(col1->getCcdSweptSphereRadius()); //todo: allow non-zero sphere sizes, for better approximation - btConvexCast::CastResult result; - btVoronoiSimplexSolver voronoiSimplex; - //SubsimplexConvexCast ccd0(&sphere,min0,&voronoiSimplex); - ///Simplification, one object is simplified as a sphere - btGjkConvexCast ccd1( convex0 ,&sphere1,&voronoiSimplex); - //ContinuousConvexCollision ccd(min0,min1,&voronoiSimplex,0); - if (ccd1.calcTimeOfImpact(col0->getWorldTransform(),col0->getInterpolationWorldTransform(), - col1->getWorldTransform(),col1->getInterpolationWorldTransform(),result)) - { - - //store result.m_fraction in both bodies - - if (col0->getHitFraction()> result.m_fraction) - col0->setHitFraction( result.m_fraction ); - - if (col1->getHitFraction() > result.m_fraction) - col1->setHitFraction( result.m_fraction); - - if (resultFraction > result.m_fraction) - resultFraction = result.m_fraction; - - } - - - - - } - - /// Sphere (for convex0) against Convex1 - { - btConvexShape* convex1 = static_cast(col1->getCollisionShape()); - - btSphereShape sphere0(col0->getCcdSweptSphereRadius()); //todo: allow non-zero sphere sizes, for better approximation - btConvexCast::CastResult result; - btVoronoiSimplexSolver voronoiSimplex; - //SubsimplexConvexCast ccd0(&sphere,min0,&voronoiSimplex); - ///Simplification, one object is simplified as a sphere - btGjkConvexCast ccd1(&sphere0,convex1,&voronoiSimplex); - //ContinuousConvexCollision ccd(min0,min1,&voronoiSimplex,0); - if (ccd1.calcTimeOfImpact(col0->getWorldTransform(),col0->getInterpolationWorldTransform(), - col1->getWorldTransform(),col1->getInterpolationWorldTransform(),result)) - { - - //store result.m_fraction in both bodies - - if (col0->getHitFraction() > result.m_fraction) - col0->setHitFraction( result.m_fraction); - - if (col1->getHitFraction() > result.m_fraction) - col1->setHitFraction( result.m_fraction); - - if (resultFraction > result.m_fraction) - resultFraction = result.m_fraction; - - } - } - - return resultFraction; - -} - diff --git a/bullet/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.h b/bullet/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.h deleted file mode 100644 index dea16d069..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.h +++ /dev/null @@ -1,109 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef CONVEX_CONVEX_ALGORITHM_H -#define CONVEX_CONVEX_ALGORITHM_H - -#include "btActivatingCollisionAlgorithm.h" -#include "BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h" -#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h" -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" -#include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h" -#include "btCollisionCreateFunc.h" -#include "btCollisionDispatcher.h" -#include "LinearMath/btTransformUtil.h" //for btConvexSeparatingDistanceUtil - -class btConvexPenetrationDepthSolver; - -///Enabling USE_SEPDISTANCE_UTIL2 requires 100% reliable distance computation. However, when using large size ratios GJK can be imprecise -///so the distance is not conservative. In that case, enabling this USE_SEPDISTANCE_UTIL2 would result in failing/missing collisions. -///Either improve GJK for large size ratios (testing a 100 units versus a 0.1 unit object) or only enable the util -///for certain pairs that have a small size ratio - -#define USE_SEPDISTANCE_UTIL2 1 - -///The convexConvexAlgorithm collision algorithm implements time of impact, convex closest points and penetration depth calculations between two convex objects. -///Multiple contact points are calculated by perturbing the orientation of the smallest object orthogonal to the separating normal. -///This idea was described by Gino van den Bergen in this forum topic http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=4&t=288&p=888#p888 -class btConvexConvexAlgorithm : public btActivatingCollisionAlgorithm -{ -#ifdef USE_SEPDISTANCE_UTIL2 - btConvexSeparatingDistanceUtil m_sepDistance; -#endif - btSimplexSolverInterface* m_simplexSolver; - btConvexPenetrationDepthSolver* m_pdSolver; - - - bool m_ownManifold; - btPersistentManifold* m_manifoldPtr; - bool m_lowLevelOfDetail; - - int m_numPerturbationIterations; - int m_minimumPointsPerturbationThreshold; - - - ///cache separating vector to speedup collision detection - - -public: - - btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1, btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver, int numPerturbationIterations, int minimumPointsPerturbationThreshold); - - - virtual ~btConvexConvexAlgorithm(); - - virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); - - virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); - - virtual void getAllContactManifolds(btManifoldArray& manifoldArray) - { - ///should we use m_ownManifold to avoid adding duplicates? - if (m_manifoldPtr && m_ownManifold) - manifoldArray.push_back(m_manifoldPtr); - } - - - void setLowLevelOfDetail(bool useLowLevel); - - - const btPersistentManifold* getManifold() - { - return m_manifoldPtr; - } - - struct CreateFunc :public btCollisionAlgorithmCreateFunc - { - - btConvexPenetrationDepthSolver* m_pdSolver; - btSimplexSolverInterface* m_simplexSolver; - int m_numPerturbationIterations; - int m_minimumPointsPerturbationThreshold; - - CreateFunc(btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver); - - virtual ~CreateFunc(); - - virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1) - { - void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btConvexConvexAlgorithm)); - return new(mem) btConvexConvexAlgorithm(ci.m_manifold,ci,body0,body1,m_simplexSolver,m_pdSolver,m_numPerturbationIterations,m_minimumPointsPerturbationThreshold); - } - }; - - -}; - -#endif //CONVEX_CONVEX_ALGORITHM_H diff --git a/bullet/src/BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.cpp b/bullet/src/BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.cpp deleted file mode 100644 index 9aa8fc646..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btConvexPlaneCollisionAlgorithm.h" - -#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h" -#include "BulletCollision/CollisionDispatch/btCollisionObject.h" -#include "BulletCollision/CollisionShapes/btConvexShape.h" -#include "BulletCollision/CollisionShapes/btStaticPlaneShape.h" - -//#include - -btConvexPlaneCollisionAlgorithm::btConvexPlaneCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1, bool isSwapped, int numPerturbationIterations,int minimumPointsPerturbationThreshold) -: btCollisionAlgorithm(ci), -m_ownManifold(false), -m_manifoldPtr(mf), -m_isSwapped(isSwapped), -m_numPerturbationIterations(numPerturbationIterations), -m_minimumPointsPerturbationThreshold(minimumPointsPerturbationThreshold) -{ - btCollisionObject* convexObj = m_isSwapped? col1 : col0; - btCollisionObject* planeObj = m_isSwapped? col0 : col1; - - if (!m_manifoldPtr && m_dispatcher->needsCollision(convexObj,planeObj)) - { - m_manifoldPtr = m_dispatcher->getNewManifold(convexObj,planeObj); - m_ownManifold = true; - } -} - - -btConvexPlaneCollisionAlgorithm::~btConvexPlaneCollisionAlgorithm() -{ - if (m_ownManifold) - { - if (m_manifoldPtr) - m_dispatcher->releaseManifold(m_manifoldPtr); - } -} - -void btConvexPlaneCollisionAlgorithm::collideSingleContact (const btQuaternion& perturbeRot, btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) -{ - btCollisionObject* convexObj = m_isSwapped? body1 : body0; - btCollisionObject* planeObj = m_isSwapped? body0: body1; - - btConvexShape* convexShape = (btConvexShape*) convexObj->getCollisionShape(); - btStaticPlaneShape* planeShape = (btStaticPlaneShape*) planeObj->getCollisionShape(); - - bool hasCollision = false; - const btVector3& planeNormal = planeShape->getPlaneNormal(); - const btScalar& planeConstant = planeShape->getPlaneConstant(); - - btTransform convexWorldTransform = convexObj->getWorldTransform(); - btTransform convexInPlaneTrans; - convexInPlaneTrans= planeObj->getWorldTransform().inverse() * convexWorldTransform; - //now perturbe the convex-world transform - convexWorldTransform.getBasis()*=btMatrix3x3(perturbeRot); - btTransform planeInConvex; - planeInConvex= convexWorldTransform.inverse() * planeObj->getWorldTransform(); - - btVector3 vtx = convexShape->localGetSupportingVertex(planeInConvex.getBasis()*-planeNormal); - - btVector3 vtxInPlane = convexInPlaneTrans(vtx); - btScalar distance = (planeNormal.dot(vtxInPlane) - planeConstant); - - btVector3 vtxInPlaneProjected = vtxInPlane - distance*planeNormal; - btVector3 vtxInPlaneWorld = planeObj->getWorldTransform() * vtxInPlaneProjected; - - hasCollision = distance < m_manifoldPtr->getContactBreakingThreshold(); - resultOut->setPersistentManifold(m_manifoldPtr); - if (hasCollision) - { - /// report a contact. internally this will be kept persistent, and contact reduction is done - btVector3 normalOnSurfaceB = planeObj->getWorldTransform().getBasis() * planeNormal; - btVector3 pOnB = vtxInPlaneWorld; - resultOut->addContactPoint(normalOnSurfaceB,pOnB,distance); - } -} - - -void btConvexPlaneCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) -{ - (void)dispatchInfo; - if (!m_manifoldPtr) - return; - - btCollisionObject* convexObj = m_isSwapped? body1 : body0; - btCollisionObject* planeObj = m_isSwapped? body0: body1; - - btConvexShape* convexShape = (btConvexShape*) convexObj->getCollisionShape(); - btStaticPlaneShape* planeShape = (btStaticPlaneShape*) planeObj->getCollisionShape(); - - - const btVector3& planeNormal = planeShape->getPlaneNormal(); - //const btScalar& planeConstant = planeShape->getPlaneConstant(); - - //first perform a collision query with the non-perturbated collision objects - { - btQuaternion rotq(0,0,0,1); - collideSingleContact(rotq,body0,body1,dispatchInfo,resultOut); - } - - if (resultOut->getPersistentManifold()->getNumContacts()getAngularMotionDisc(); - perturbeAngle = gContactBreakingThreshold / radius; - if ( perturbeAngle > angleLimit ) - perturbeAngle = angleLimit; - - btQuaternion perturbeRot(v0,perturbeAngle); - for (int i=0;igetNumContacts()) - { - resultOut->refreshContactPoints(); - } - } -} - -btScalar btConvexPlaneCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* col0,btCollisionObject* col1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) -{ - (void)resultOut; - (void)dispatchInfo; - (void)col0; - (void)col1; - - //not yet - return btScalar(1.); -} diff --git a/bullet/src/BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.h b/bullet/src/BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.h deleted file mode 100644 index 3aed141b1..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.h +++ /dev/null @@ -1,84 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef CONVEX_PLANE_COLLISION_ALGORITHM_H -#define CONVEX_PLANE_COLLISION_ALGORITHM_H - -#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h" -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" -#include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h" -class btPersistentManifold; -#include "btCollisionDispatcher.h" - -#include "LinearMath/btVector3.h" - -/// btSphereBoxCollisionAlgorithm provides sphere-box collision detection. -/// Other features are frame-coherency (persistent data) and collision response. -class btConvexPlaneCollisionAlgorithm : public btCollisionAlgorithm -{ - bool m_ownManifold; - btPersistentManifold* m_manifoldPtr; - bool m_isSwapped; - int m_numPerturbationIterations; - int m_minimumPointsPerturbationThreshold; - -public: - - btConvexPlaneCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1, bool isSwapped, int numPerturbationIterations,int minimumPointsPerturbationThreshold); - - virtual ~btConvexPlaneCollisionAlgorithm(); - - virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); - - void collideSingleContact (const btQuaternion& perturbeRot, btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); - - virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); - - virtual void getAllContactManifolds(btManifoldArray& manifoldArray) - { - if (m_manifoldPtr && m_ownManifold) - { - manifoldArray.push_back(m_manifoldPtr); - } - } - - struct CreateFunc :public btCollisionAlgorithmCreateFunc - { - int m_numPerturbationIterations; - int m_minimumPointsPerturbationThreshold; - - CreateFunc() - : m_numPerturbationIterations(1), - m_minimumPointsPerturbationThreshold(1) - { - } - - virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1) - { - void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btConvexPlaneCollisionAlgorithm)); - if (!m_swapped) - { - return new(mem) btConvexPlaneCollisionAlgorithm(0,ci,body0,body1,false,m_numPerturbationIterations,m_minimumPointsPerturbationThreshold); - } else - { - return new(mem) btConvexPlaneCollisionAlgorithm(0,ci,body0,body1,true,m_numPerturbationIterations,m_minimumPointsPerturbationThreshold); - } - } - }; - -}; - -#endif //CONVEX_PLANE_COLLISION_ALGORITHM_H - diff --git a/bullet/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp b/bullet/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp deleted file mode 100644 index 3a08bfcc3..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp +++ /dev/null @@ -1,298 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btDefaultCollisionConfiguration.h" - -#include "BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.h" -#include "BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.h" -#include "BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.h" -#include "BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h" -#include "BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.h" -#include "BulletCollision/CollisionDispatch/btBoxBoxCollisionAlgorithm.h" -#include "BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.h" -#ifdef USE_BUGGY_SPHERE_BOX_ALGORITHM -#include "BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.h" -#endif //USE_BUGGY_SPHERE_BOX_ALGORITHM -#include "BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.h" -#include "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h" -#include "BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h" -#include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h" - - - -#include "LinearMath/btStackAlloc.h" -#include "LinearMath/btPoolAllocator.h" - - - - - -btDefaultCollisionConfiguration::btDefaultCollisionConfiguration(const btDefaultCollisionConstructionInfo& constructionInfo) -//btDefaultCollisionConfiguration::btDefaultCollisionConfiguration(btStackAlloc* stackAlloc,btPoolAllocator* persistentManifoldPool,btPoolAllocator* collisionAlgorithmPool) -{ - - void* mem = btAlignedAlloc(sizeof(btVoronoiSimplexSolver),16); - m_simplexSolver = new (mem)btVoronoiSimplexSolver(); - - if (constructionInfo.m_useEpaPenetrationAlgorithm) - { - mem = btAlignedAlloc(sizeof(btGjkEpaPenetrationDepthSolver),16); - m_pdSolver = new (mem)btGjkEpaPenetrationDepthSolver; - }else - { - mem = btAlignedAlloc(sizeof(btMinkowskiPenetrationDepthSolver),16); - m_pdSolver = new (mem)btMinkowskiPenetrationDepthSolver; - } - - //default CreationFunctions, filling the m_doubleDispatch table - mem = btAlignedAlloc(sizeof(btConvexConvexAlgorithm::CreateFunc),16); - m_convexConvexCreateFunc = new(mem) btConvexConvexAlgorithm::CreateFunc(m_simplexSolver,m_pdSolver); - mem = btAlignedAlloc(sizeof(btConvexConcaveCollisionAlgorithm::CreateFunc),16); - m_convexConcaveCreateFunc = new (mem)btConvexConcaveCollisionAlgorithm::CreateFunc; - mem = btAlignedAlloc(sizeof(btConvexConcaveCollisionAlgorithm::CreateFunc),16); - m_swappedConvexConcaveCreateFunc = new (mem)btConvexConcaveCollisionAlgorithm::SwappedCreateFunc; - mem = btAlignedAlloc(sizeof(btCompoundCollisionAlgorithm::CreateFunc),16); - m_compoundCreateFunc = new (mem)btCompoundCollisionAlgorithm::CreateFunc; - mem = btAlignedAlloc(sizeof(btCompoundCollisionAlgorithm::SwappedCreateFunc),16); - m_swappedCompoundCreateFunc = new (mem)btCompoundCollisionAlgorithm::SwappedCreateFunc; - mem = btAlignedAlloc(sizeof(btEmptyAlgorithm::CreateFunc),16); - m_emptyCreateFunc = new(mem) btEmptyAlgorithm::CreateFunc; - - mem = btAlignedAlloc(sizeof(btSphereSphereCollisionAlgorithm::CreateFunc),16); - m_sphereSphereCF = new(mem) btSphereSphereCollisionAlgorithm::CreateFunc; -#ifdef USE_BUGGY_SPHERE_BOX_ALGORITHM - mem = btAlignedAlloc(sizeof(btSphereBoxCollisionAlgorithm::CreateFunc),16); - m_sphereBoxCF = new(mem) btSphereBoxCollisionAlgorithm::CreateFunc; - mem = btAlignedAlloc(sizeof(btSphereBoxCollisionAlgorithm::CreateFunc),16); - m_boxSphereCF = new (mem)btSphereBoxCollisionAlgorithm::CreateFunc; - m_boxSphereCF->m_swapped = true; -#endif //USE_BUGGY_SPHERE_BOX_ALGORITHM - - mem = btAlignedAlloc(sizeof(btSphereTriangleCollisionAlgorithm::CreateFunc),16); - m_sphereTriangleCF = new (mem)btSphereTriangleCollisionAlgorithm::CreateFunc; - mem = btAlignedAlloc(sizeof(btSphereTriangleCollisionAlgorithm::CreateFunc),16); - m_triangleSphereCF = new (mem)btSphereTriangleCollisionAlgorithm::CreateFunc; - m_triangleSphereCF->m_swapped = true; - - mem = btAlignedAlloc(sizeof(btBoxBoxCollisionAlgorithm::CreateFunc),16); - m_boxBoxCF = new(mem)btBoxBoxCollisionAlgorithm::CreateFunc; - - //convex versus plane - mem = btAlignedAlloc (sizeof(btConvexPlaneCollisionAlgorithm::CreateFunc),16); - m_convexPlaneCF = new (mem) btConvexPlaneCollisionAlgorithm::CreateFunc; - mem = btAlignedAlloc (sizeof(btConvexPlaneCollisionAlgorithm::CreateFunc),16); - m_planeConvexCF = new (mem) btConvexPlaneCollisionAlgorithm::CreateFunc; - m_planeConvexCF->m_swapped = true; - - ///calculate maximum element size, big enough to fit any collision algorithm in the memory pool - int maxSize = sizeof(btConvexConvexAlgorithm); - int maxSize2 = sizeof(btConvexConcaveCollisionAlgorithm); - int maxSize3 = sizeof(btCompoundCollisionAlgorithm); - int sl = sizeof(btConvexSeparatingDistanceUtil); - sl = sizeof(btGjkPairDetector); - int collisionAlgorithmMaxElementSize = btMax(maxSize,constructionInfo.m_customCollisionAlgorithmMaxElementSize); - collisionAlgorithmMaxElementSize = btMax(collisionAlgorithmMaxElementSize,maxSize2); - collisionAlgorithmMaxElementSize = btMax(collisionAlgorithmMaxElementSize,maxSize3); - - if (constructionInfo.m_stackAlloc) - { - m_ownsStackAllocator = false; - this->m_stackAlloc = constructionInfo.m_stackAlloc; - } else - { - m_ownsStackAllocator = true; - void* mem = btAlignedAlloc(sizeof(btStackAlloc),16); - m_stackAlloc = new(mem)btStackAlloc(constructionInfo.m_defaultStackAllocatorSize); - } - - if (constructionInfo.m_persistentManifoldPool) - { - m_ownsPersistentManifoldPool = false; - m_persistentManifoldPool = constructionInfo.m_persistentManifoldPool; - } else - { - m_ownsPersistentManifoldPool = true; - void* mem = btAlignedAlloc(sizeof(btPoolAllocator),16); - m_persistentManifoldPool = new (mem) btPoolAllocator(sizeof(btPersistentManifold),constructionInfo.m_defaultMaxPersistentManifoldPoolSize); - } - - if (constructionInfo.m_collisionAlgorithmPool) - { - m_ownsCollisionAlgorithmPool = false; - m_collisionAlgorithmPool = constructionInfo.m_collisionAlgorithmPool; - } else - { - m_ownsCollisionAlgorithmPool = true; - void* mem = btAlignedAlloc(sizeof(btPoolAllocator),16); - m_collisionAlgorithmPool = new(mem) btPoolAllocator(collisionAlgorithmMaxElementSize,constructionInfo.m_defaultMaxCollisionAlgorithmPoolSize); - } - - -} - -btDefaultCollisionConfiguration::~btDefaultCollisionConfiguration() -{ - if (m_ownsStackAllocator) - { - m_stackAlloc->destroy(); - m_stackAlloc->~btStackAlloc(); - btAlignedFree(m_stackAlloc); - } - if (m_ownsCollisionAlgorithmPool) - { - m_collisionAlgorithmPool->~btPoolAllocator(); - btAlignedFree(m_collisionAlgorithmPool); - } - if (m_ownsPersistentManifoldPool) - { - m_persistentManifoldPool->~btPoolAllocator(); - btAlignedFree(m_persistentManifoldPool); - } - - m_convexConvexCreateFunc->~btCollisionAlgorithmCreateFunc(); - btAlignedFree( m_convexConvexCreateFunc); - - m_convexConcaveCreateFunc->~btCollisionAlgorithmCreateFunc(); - btAlignedFree( m_convexConcaveCreateFunc); - m_swappedConvexConcaveCreateFunc->~btCollisionAlgorithmCreateFunc(); - btAlignedFree( m_swappedConvexConcaveCreateFunc); - - m_compoundCreateFunc->~btCollisionAlgorithmCreateFunc(); - btAlignedFree( m_compoundCreateFunc); - - m_swappedCompoundCreateFunc->~btCollisionAlgorithmCreateFunc(); - btAlignedFree( m_swappedCompoundCreateFunc); - - m_emptyCreateFunc->~btCollisionAlgorithmCreateFunc(); - btAlignedFree( m_emptyCreateFunc); - - m_sphereSphereCF->~btCollisionAlgorithmCreateFunc(); - btAlignedFree( m_sphereSphereCF); - -#ifdef USE_BUGGY_SPHERE_BOX_ALGORITHM - m_sphereBoxCF->~btCollisionAlgorithmCreateFunc(); - btAlignedFree( m_sphereBoxCF); - m_boxSphereCF->~btCollisionAlgorithmCreateFunc(); - btAlignedFree( m_boxSphereCF); -#endif //USE_BUGGY_SPHERE_BOX_ALGORITHM - - m_sphereTriangleCF->~btCollisionAlgorithmCreateFunc(); - btAlignedFree( m_sphereTriangleCF); - m_triangleSphereCF->~btCollisionAlgorithmCreateFunc(); - btAlignedFree( m_triangleSphereCF); - m_boxBoxCF->~btCollisionAlgorithmCreateFunc(); - btAlignedFree( m_boxBoxCF); - - m_convexPlaneCF->~btCollisionAlgorithmCreateFunc(); - btAlignedFree( m_convexPlaneCF); - m_planeConvexCF->~btCollisionAlgorithmCreateFunc(); - btAlignedFree( m_planeConvexCF); - - m_simplexSolver->~btVoronoiSimplexSolver(); - btAlignedFree(m_simplexSolver); - - m_pdSolver->~btConvexPenetrationDepthSolver(); - - btAlignedFree(m_pdSolver); - - -} - - -btCollisionAlgorithmCreateFunc* btDefaultCollisionConfiguration::getCollisionAlgorithmCreateFunc(int proxyType0,int proxyType1) -{ - - - - if ((proxyType0 == SPHERE_SHAPE_PROXYTYPE) && (proxyType1==SPHERE_SHAPE_PROXYTYPE)) - { - return m_sphereSphereCF; - } -#ifdef USE_BUGGY_SPHERE_BOX_ALGORITHM - if ((proxyType0 == SPHERE_SHAPE_PROXYTYPE) && (proxyType1==BOX_SHAPE_PROXYTYPE)) - { - return m_sphereBoxCF; - } - - if ((proxyType0 == BOX_SHAPE_PROXYTYPE ) && (proxyType1==SPHERE_SHAPE_PROXYTYPE)) - { - return m_boxSphereCF; - } -#endif //USE_BUGGY_SPHERE_BOX_ALGORITHM - - - if ((proxyType0 == SPHERE_SHAPE_PROXYTYPE ) && (proxyType1==TRIANGLE_SHAPE_PROXYTYPE)) - { - return m_sphereTriangleCF; - } - - if ((proxyType0 == TRIANGLE_SHAPE_PROXYTYPE ) && (proxyType1==SPHERE_SHAPE_PROXYTYPE)) - { - return m_triangleSphereCF; - } - - if ((proxyType0 == BOX_SHAPE_PROXYTYPE) && (proxyType1 == BOX_SHAPE_PROXYTYPE)) - { - return m_boxBoxCF; - } - - if (btBroadphaseProxy::isConvex(proxyType0) && (proxyType1 == STATIC_PLANE_PROXYTYPE)) - { - return m_convexPlaneCF; - } - - if (btBroadphaseProxy::isConvex(proxyType1) && (proxyType0 == STATIC_PLANE_PROXYTYPE)) - { - return m_planeConvexCF; - } - - - - if (btBroadphaseProxy::isConvex(proxyType0) && btBroadphaseProxy::isConvex(proxyType1)) - { - return m_convexConvexCreateFunc; - } - - if (btBroadphaseProxy::isConvex(proxyType0) && btBroadphaseProxy::isConcave(proxyType1)) - { - return m_convexConcaveCreateFunc; - } - - if (btBroadphaseProxy::isConvex(proxyType1) && btBroadphaseProxy::isConcave(proxyType0)) - { - return m_swappedConvexConcaveCreateFunc; - } - - if (btBroadphaseProxy::isCompound(proxyType0)) - { - return m_compoundCreateFunc; - } else - { - if (btBroadphaseProxy::isCompound(proxyType1)) - { - return m_swappedCompoundCreateFunc; - } - } - - //failed to find an algorithm - return m_emptyCreateFunc; -} - -void btDefaultCollisionConfiguration::setConvexConvexMultipointIterations(int numPerturbationIterations, int minimumPointsPerturbationThreshold) -{ - btConvexConvexAlgorithm::CreateFunc* convexConvex = (btConvexConvexAlgorithm::CreateFunc*) m_convexConvexCreateFunc; - convexConvex->m_numPerturbationIterations = numPerturbationIterations; - convexConvex->m_minimumPointsPerturbationThreshold = minimumPointsPerturbationThreshold; -} diff --git a/bullet/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h b/bullet/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h deleted file mode 100644 index 408cce1fb..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h +++ /dev/null @@ -1,130 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef BT_DEFAULT_COLLISION_CONFIGURATION -#define BT_DEFAULT_COLLISION_CONFIGURATION - -#include "btCollisionConfiguration.h" -class btVoronoiSimplexSolver; -class btConvexPenetrationDepthSolver; - -struct btDefaultCollisionConstructionInfo -{ - btStackAlloc* m_stackAlloc; - btPoolAllocator* m_persistentManifoldPool; - btPoolAllocator* m_collisionAlgorithmPool; - int m_defaultMaxPersistentManifoldPoolSize; - int m_defaultMaxCollisionAlgorithmPoolSize; - int m_customCollisionAlgorithmMaxElementSize; - int m_defaultStackAllocatorSize; - int m_useEpaPenetrationAlgorithm; - - btDefaultCollisionConstructionInfo() - :m_stackAlloc(0), - m_persistentManifoldPool(0), - m_collisionAlgorithmPool(0), - m_defaultMaxPersistentManifoldPoolSize(4096), - m_defaultMaxCollisionAlgorithmPoolSize(4096), - m_customCollisionAlgorithmMaxElementSize(0), - m_defaultStackAllocatorSize(0), - m_useEpaPenetrationAlgorithm(true) - { - } -}; - - - -///btCollisionConfiguration allows to configure Bullet collision detection -///stack allocator, pool memory allocators -///@todo: describe the meaning -class btDefaultCollisionConfiguration : public btCollisionConfiguration -{ - -protected: - - int m_persistentManifoldPoolSize; - - btStackAlloc* m_stackAlloc; - bool m_ownsStackAllocator; - - btPoolAllocator* m_persistentManifoldPool; - bool m_ownsPersistentManifoldPool; - - - btPoolAllocator* m_collisionAlgorithmPool; - bool m_ownsCollisionAlgorithmPool; - - //default simplex/penetration depth solvers - btVoronoiSimplexSolver* m_simplexSolver; - btConvexPenetrationDepthSolver* m_pdSolver; - - //default CreationFunctions, filling the m_doubleDispatch table - btCollisionAlgorithmCreateFunc* m_convexConvexCreateFunc; - btCollisionAlgorithmCreateFunc* m_convexConcaveCreateFunc; - btCollisionAlgorithmCreateFunc* m_swappedConvexConcaveCreateFunc; - btCollisionAlgorithmCreateFunc* m_compoundCreateFunc; - btCollisionAlgorithmCreateFunc* m_swappedCompoundCreateFunc; - btCollisionAlgorithmCreateFunc* m_emptyCreateFunc; - btCollisionAlgorithmCreateFunc* m_sphereSphereCF; -#ifdef USE_BUGGY_SPHERE_BOX_ALGORITHM - btCollisionAlgorithmCreateFunc* m_sphereBoxCF; - btCollisionAlgorithmCreateFunc* m_boxSphereCF; -#endif //USE_BUGGY_SPHERE_BOX_ALGORITHM - - btCollisionAlgorithmCreateFunc* m_boxBoxCF; - btCollisionAlgorithmCreateFunc* m_sphereTriangleCF; - btCollisionAlgorithmCreateFunc* m_triangleSphereCF; - btCollisionAlgorithmCreateFunc* m_planeConvexCF; - btCollisionAlgorithmCreateFunc* m_convexPlaneCF; - -public: - - - btDefaultCollisionConfiguration(const btDefaultCollisionConstructionInfo& constructionInfo = btDefaultCollisionConstructionInfo()); - - virtual ~btDefaultCollisionConfiguration(); - - ///memory pools - virtual btPoolAllocator* getPersistentManifoldPool() - { - return m_persistentManifoldPool; - } - - virtual btPoolAllocator* getCollisionAlgorithmPool() - { - return m_collisionAlgorithmPool; - } - - virtual btStackAlloc* getStackAllocator() - { - return m_stackAlloc; - } - - - virtual btCollisionAlgorithmCreateFunc* getCollisionAlgorithmCreateFunc(int proxyType0,int proxyType1); - - ///Use this method to allow to generate multiple contact points between at once, between two objects using the generic convex-convex algorithm. - ///By default, this feature is disabled for best performance. - ///@param numPerturbationIterations controls the number of collision queries. Set it to zero to disable the feature. - ///@param minimumPointsPerturbationThreshold is the minimum number of points in the contact cache, above which the feature is disabled - ///3 is a good value for both params, if you want to enable the feature. This is because the default contact cache contains a maximum of 4 points, and one collision query at the unperturbed orientation is performed first. - ///See Bullet/Demos/CollisionDemo for an example how this feature gathers multiple points. - ///@todo we could add a per-object setting of those parameters, for level-of-detail collision detection. - void setConvexConvexMultipointIterations(int numPerturbationIterations=3, int minimumPointsPerturbationThreshold = 3); - -}; - -#endif //BT_DEFAULT_COLLISION_CONFIGURATION - diff --git a/bullet/src/BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.cpp b/bullet/src/BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.cpp deleted file mode 100644 index 605c4fff0..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btEmptyCollisionAlgorithm.h" - - - -btEmptyAlgorithm::btEmptyAlgorithm(const btCollisionAlgorithmConstructionInfo& ci) - : btCollisionAlgorithm(ci) -{ -} - -void btEmptyAlgorithm::processCollision (btCollisionObject* ,btCollisionObject* ,const btDispatcherInfo& ,btManifoldResult* ) -{ -} - -btScalar btEmptyAlgorithm::calculateTimeOfImpact(btCollisionObject* ,btCollisionObject* ,const btDispatcherInfo& ,btManifoldResult* ) -{ - return btScalar(1.); -} - - diff --git a/bullet/src/BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.h b/bullet/src/BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.h deleted file mode 100644 index 8583386ad..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef EMPTY_ALGORITH -#define EMPTY_ALGORITH -#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h" -#include "btCollisionCreateFunc.h" -#include "btCollisionDispatcher.h" - -#define ATTRIBUTE_ALIGNED(a) - -///EmptyAlgorithm is a stub for unsupported collision pairs. -///The dispatcher can dispatch a persistent btEmptyAlgorithm to avoid a search every frame. -class btEmptyAlgorithm : public btCollisionAlgorithm -{ - -public: - - btEmptyAlgorithm(const btCollisionAlgorithmConstructionInfo& ci); - - virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); - - virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); - - virtual void getAllContactManifolds(btManifoldArray& manifoldArray) - { - } - - struct CreateFunc :public btCollisionAlgorithmCreateFunc - { - virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1) - { - (void)body0; - (void)body1; - void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btEmptyAlgorithm)); - return new(mem) btEmptyAlgorithm(ci); - } - }; - -} ATTRIBUTE_ALIGNED(16); - -#endif //EMPTY_ALGORITH diff --git a/bullet/src/BulletCollision/CollisionDispatch/btGhostObject.cpp b/bullet/src/BulletCollision/CollisionDispatch/btGhostObject.cpp deleted file mode 100644 index 467e7bebd..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btGhostObject.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2008 Erwin Coumans http://bulletphysics.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btGhostObject.h" -#include "btCollisionWorld.h" -#include "BulletCollision/CollisionShapes/btConvexShape.h" -#include "LinearMath/btAabbUtil2.h" - -btGhostObject::btGhostObject() -{ - m_internalType = CO_GHOST_OBJECT; -} - -btGhostObject::~btGhostObject() -{ - ///btGhostObject should have been removed from the world, so no overlapping objects - btAssert(!m_overlappingObjects.size()); -} - - -void btGhostObject::addOverlappingObjectInternal(btBroadphaseProxy* otherProxy,btBroadphaseProxy* thisProxy) -{ - btCollisionObject* otherObject = (btCollisionObject*)otherProxy->m_clientObject; - btAssert(otherObject); - ///if this linearSearch becomes too slow (too many overlapping objects) we should add a more appropriate data structure - int index = m_overlappingObjects.findLinearSearch(otherObject); - if (index==m_overlappingObjects.size()) - { - //not found - m_overlappingObjects.push_back(otherObject); - } -} - -void btGhostObject::removeOverlappingObjectInternal(btBroadphaseProxy* otherProxy,btDispatcher* dispatcher,btBroadphaseProxy* thisProxy) -{ - btCollisionObject* otherObject = (btCollisionObject*)otherProxy->m_clientObject; - btAssert(otherObject); - int index = m_overlappingObjects.findLinearSearch(otherObject); - if (index~btHashedOverlappingPairCache(); - btAlignedFree( m_hashPairCache ); -} - -void btPairCachingGhostObject::addOverlappingObjectInternal(btBroadphaseProxy* otherProxy,btBroadphaseProxy* thisProxy) -{ - btBroadphaseProxy*actualThisProxy = thisProxy ? thisProxy : getBroadphaseHandle(); - btAssert(actualThisProxy); - - btCollisionObject* otherObject = (btCollisionObject*)otherProxy->m_clientObject; - btAssert(otherObject); - int index = m_overlappingObjects.findLinearSearch(otherObject); - if (index==m_overlappingObjects.size()) - { - m_overlappingObjects.push_back(otherObject); - m_hashPairCache->addOverlappingPair(actualThisProxy,otherProxy); - } -} - -void btPairCachingGhostObject::removeOverlappingObjectInternal(btBroadphaseProxy* otherProxy,btDispatcher* dispatcher,btBroadphaseProxy* thisProxy1) -{ - btCollisionObject* otherObject = (btCollisionObject*)otherProxy->m_clientObject; - btBroadphaseProxy* actualThisProxy = thisProxy1 ? thisProxy1 : getBroadphaseHandle(); - btAssert(actualThisProxy); - - btAssert(otherObject); - int index = m_overlappingObjects.findLinearSearch(otherObject); - if (indexremoveOverlappingPair(actualThisProxy,otherProxy,dispatcher); - } -} - - -void btGhostObject::convexSweepTest(const btConvexShape* castShape, const btTransform& convexFromWorld, const btTransform& convexToWorld, btCollisionWorld::ConvexResultCallback& resultCallback, btScalar allowedCcdPenetration) const -{ - btTransform convexFromTrans,convexToTrans; - convexFromTrans = convexFromWorld; - convexToTrans = convexToWorld; - btVector3 castShapeAabbMin, castShapeAabbMax; - /* Compute AABB that encompasses angular movement */ - { - btVector3 linVel, angVel; - btTransformUtil::calculateVelocity (convexFromTrans, convexToTrans, 1.0, linVel, angVel); - btTransform R; - R.setIdentity (); - R.setRotation (convexFromTrans.getRotation()); - castShape->calculateTemporalAabb (R, linVel, angVel, 1.0, castShapeAabbMin, castShapeAabbMax); - } - - /// go over all objects, and if the ray intersects their aabb + cast shape aabb, - // do a ray-shape query using convexCaster (CCD) - int i; - for (i=0;igetBroadphaseHandle())) { - //RigidcollisionObject* collisionObject = ctrl->GetRigidcollisionObject(); - btVector3 collisionObjectAabbMin,collisionObjectAabbMax; - collisionObject->getCollisionShape()->getAabb(collisionObject->getWorldTransform(),collisionObjectAabbMin,collisionObjectAabbMax); - AabbExpand (collisionObjectAabbMin, collisionObjectAabbMax, castShapeAabbMin, castShapeAabbMax); - btScalar hitLambda = btScalar(1.); //could use resultCallback.m_closestHitFraction, but needs testing - btVector3 hitNormal; - if (btRayAabb(convexFromWorld.getOrigin(),convexToWorld.getOrigin(),collisionObjectAabbMin,collisionObjectAabbMax,hitLambda,hitNormal)) - { - btCollisionWorld::objectQuerySingle(castShape, convexFromTrans,convexToTrans, - collisionObject, - collisionObject->getCollisionShape(), - collisionObject->getWorldTransform(), - resultCallback, - allowedCcdPenetration); - } - } - } - -} - -void btGhostObject::rayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, btCollisionWorld::RayResultCallback& resultCallback) const -{ - btTransform rayFromTrans; - rayFromTrans.setIdentity(); - rayFromTrans.setOrigin(rayFromWorld); - btTransform rayToTrans; - rayToTrans.setIdentity(); - rayToTrans.setOrigin(rayToWorld); - - - int i; - for (i=0;igetBroadphaseHandle())) - { - btCollisionWorld::rayTestSingle(rayFromTrans,rayToTrans, - collisionObject, - collisionObject->getCollisionShape(), - collisionObject->getWorldTransform(), - resultCallback); - } - } -} - diff --git a/bullet/src/BulletCollision/CollisionDispatch/btGhostObject.h b/bullet/src/BulletCollision/CollisionDispatch/btGhostObject.h deleted file mode 100644 index d1e4d5cc8..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btGhostObject.h +++ /dev/null @@ -1,174 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2008 Erwin Coumans http://bulletphysics.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef BT_GHOST_OBJECT_H -#define BT_GHOST_OBJECT_H - - -#include "btCollisionObject.h" -#include "BulletCollision/BroadphaseCollision/btOverlappingPairCallback.h" -#include "LinearMath/btAlignedAllocator.h" -#include "BulletCollision/BroadphaseCollision/btOverlappingPairCache.h" -#include "btCollisionWorld.h" - -class btConvexShape; - -class btDispatcher; - -///The btGhostObject can keep track of all objects that are overlapping -///By default, this overlap is based on the AABB -///This is useful for creating a character controller, collision sensors/triggers, explosions etc. -///We plan on adding rayTest and other queries for the btGhostObject -ATTRIBUTE_ALIGNED16(class) btGhostObject : public btCollisionObject -{ -protected: - - btAlignedObjectArray m_overlappingObjects; - -public: - - btGhostObject(); - - virtual ~btGhostObject(); - - void convexSweepTest(const class btConvexShape* castShape, const btTransform& convexFromWorld, const btTransform& convexToWorld, btCollisionWorld::ConvexResultCallback& resultCallback, btScalar allowedCcdPenetration = 0.f) const; - - void rayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, btCollisionWorld::RayResultCallback& resultCallback) const; - - ///this method is mainly for expert/internal use only. - virtual void addOverlappingObjectInternal(btBroadphaseProxy* otherProxy, btBroadphaseProxy* thisProxy=0); - ///this method is mainly for expert/internal use only. - virtual void removeOverlappingObjectInternal(btBroadphaseProxy* otherProxy,btDispatcher* dispatcher,btBroadphaseProxy* thisProxy=0); - - int getNumOverlappingObjects() const - { - return m_overlappingObjects.size(); - } - - btCollisionObject* getOverlappingObject(int index) - { - return m_overlappingObjects[index]; - } - - const btCollisionObject* getOverlappingObject(int index) const - { - return m_overlappingObjects[index]; - } - - btAlignedObjectArray& getOverlappingPairs() - { - return m_overlappingObjects; - } - - const btAlignedObjectArray getOverlappingPairs() const - { - return m_overlappingObjects; - } - - // - // internal cast - // - - static const btGhostObject* upcast(const btCollisionObject* colObj) - { - if (colObj->getInternalType()==CO_GHOST_OBJECT) - return (const btGhostObject*)colObj; - return 0; - } - static btGhostObject* upcast(btCollisionObject* colObj) - { - if (colObj->getInternalType()==CO_GHOST_OBJECT) - return (btGhostObject*)colObj; - return 0; - } - -}; - -class btPairCachingGhostObject : public btGhostObject -{ - btHashedOverlappingPairCache* m_hashPairCache; - -public: - - btPairCachingGhostObject(); - - virtual ~btPairCachingGhostObject(); - - ///this method is mainly for expert/internal use only. - virtual void addOverlappingObjectInternal(btBroadphaseProxy* otherProxy, btBroadphaseProxy* thisProxy=0); - - virtual void removeOverlappingObjectInternal(btBroadphaseProxy* otherProxy,btDispatcher* dispatcher,btBroadphaseProxy* thisProxy=0); - - btHashedOverlappingPairCache* getOverlappingPairCache() - { - return m_hashPairCache; - } - -}; - - - -///The btGhostPairCallback interfaces and forwards adding and removal of overlapping pairs from the btBroadphaseInterface to btGhostObject. -class btGhostPairCallback : public btOverlappingPairCallback -{ - -public: - btGhostPairCallback() - { - } - - virtual ~btGhostPairCallback() - { - - } - - virtual btBroadphasePair* addOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) - { - btCollisionObject* colObj0 = (btCollisionObject*) proxy0->m_clientObject; - btCollisionObject* colObj1 = (btCollisionObject*) proxy1->m_clientObject; - btGhostObject* ghost0 = btGhostObject::upcast(colObj0); - btGhostObject* ghost1 = btGhostObject::upcast(colObj1); - if (ghost0) - ghost0->addOverlappingObjectInternal(proxy1, proxy0); - if (ghost1) - ghost1->addOverlappingObjectInternal(proxy0, proxy1); - return 0; - } - - virtual void* removeOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,btDispatcher* dispatcher) - { - btCollisionObject* colObj0 = (btCollisionObject*) proxy0->m_clientObject; - btCollisionObject* colObj1 = (btCollisionObject*) proxy1->m_clientObject; - btGhostObject* ghost0 = btGhostObject::upcast(colObj0); - btGhostObject* ghost1 = btGhostObject::upcast(colObj1); - if (ghost0) - ghost0->removeOverlappingObjectInternal(proxy1,dispatcher,proxy0); - if (ghost1) - ghost1->removeOverlappingObjectInternal(proxy0,dispatcher,proxy1); - return 0; - } - - virtual void removeOverlappingPairsContainingProxy(btBroadphaseProxy* proxy0,btDispatcher* dispatcher) - { - btAssert(0); - //need to keep track of all ghost objects and call them here - //m_hashPairCache->removeOverlappingPairsContainingProxy(proxy0,dispatcher); - } - - - -}; - -#endif \ No newline at end of file diff --git a/bullet/src/BulletCollision/CollisionDispatch/btManifoldResult.cpp b/bullet/src/BulletCollision/CollisionDispatch/btManifoldResult.cpp deleted file mode 100644 index 20eb3e35b..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btManifoldResult.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#include "btManifoldResult.h" -#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h" -#include "BulletCollision/CollisionDispatch/btCollisionObject.h" - - -///This is to allow MaterialCombiner/Custom Friction/Restitution values -ContactAddedCallback gContactAddedCallback=0; - -///User can override this material combiner by implementing gContactAddedCallback and setting body0->m_collisionFlags |= btCollisionObject::customMaterialCallback; -inline btScalar calculateCombinedFriction(const btCollisionObject* body0,const btCollisionObject* body1) -{ - btScalar friction = body0->getFriction() * body1->getFriction(); - - const btScalar MAX_FRICTION = btScalar(10.); - if (friction < -MAX_FRICTION) - friction = -MAX_FRICTION; - if (friction > MAX_FRICTION) - friction = MAX_FRICTION; - return friction; - -} - -inline btScalar calculateCombinedRestitution(const btCollisionObject* body0,const btCollisionObject* body1) -{ - return body0->getRestitution() * body1->getRestitution(); -} - - - -btManifoldResult::btManifoldResult(btCollisionObject* body0,btCollisionObject* body1) - :m_manifoldPtr(0), - m_body0(body0), - m_body1(body1) -#ifdef DEBUG_PART_INDEX - ,m_partId0(-1), - m_partId1(-1), - m_index0(-1), - m_index1(-1) -#endif //DEBUG_PART_INDEX -{ - m_rootTransA = body0->getWorldTransform(); - m_rootTransB = body1->getWorldTransform(); -} - - -void btManifoldResult::addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth) -{ - btAssert(m_manifoldPtr); - //order in manifold needs to match - - if (depth > m_manifoldPtr->getContactBreakingThreshold()) - return; - - bool isSwapped = m_manifoldPtr->getBody0() != m_body0; - - btVector3 pointA = pointInWorld + normalOnBInWorld * depth; - - btVector3 localA; - btVector3 localB; - - if (isSwapped) - { - localA = m_rootTransB.invXform(pointA ); - localB = m_rootTransA.invXform(pointInWorld); - } else - { - localA = m_rootTransA.invXform(pointA ); - localB = m_rootTransB.invXform(pointInWorld); - } - - btManifoldPoint newPt(localA,localB,normalOnBInWorld,depth); - newPt.m_positionWorldOnA = pointA; - newPt.m_positionWorldOnB = pointInWorld; - - int insertIndex = m_manifoldPtr->getCacheEntry(newPt); - - newPt.m_combinedFriction = calculateCombinedFriction(m_body0,m_body1); - newPt.m_combinedRestitution = calculateCombinedRestitution(m_body0,m_body1); - - //BP mod, store contact triangles. - if (isSwapped) - { - newPt.m_partId0 = m_partId1; - newPt.m_partId1 = m_partId0; - newPt.m_index0 = m_index1; - newPt.m_index1 = m_index0; - } else - { - newPt.m_partId0 = m_partId0; - newPt.m_partId1 = m_partId1; - newPt.m_index0 = m_index0; - newPt.m_index1 = m_index1; - } - //printf("depth=%f\n",depth); - ///@todo, check this for any side effects - if (insertIndex >= 0) - { - //const btManifoldPoint& oldPoint = m_manifoldPtr->getContactPoint(insertIndex); - m_manifoldPtr->replaceContactPoint(newPt,insertIndex); - } else - { - insertIndex = m_manifoldPtr->addManifoldPoint(newPt); - } - - //User can override friction and/or restitution - if (gContactAddedCallback && - //and if either of the two bodies requires custom material - ((m_body0->getCollisionFlags() & btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK) || - (m_body1->getCollisionFlags() & btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK))) - { - //experimental feature info, for per-triangle material etc. - btCollisionObject* obj0 = isSwapped? m_body1 : m_body0; - btCollisionObject* obj1 = isSwapped? m_body0 : m_body1; - (*gContactAddedCallback)(m_manifoldPtr->getContactPoint(insertIndex),obj0,newPt.m_partId0,newPt.m_index0,obj1,newPt.m_partId1,newPt.m_index1); - } - -} - diff --git a/bullet/src/BulletCollision/CollisionDispatch/btManifoldResult.h b/bullet/src/BulletCollision/CollisionDispatch/btManifoldResult.h deleted file mode 100644 index 0891de7ae..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btManifoldResult.h +++ /dev/null @@ -1,126 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#ifndef MANIFOLD_RESULT_H -#define MANIFOLD_RESULT_H - -class btCollisionObject; -#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h" -class btManifoldPoint; - -#include "BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h" - -#include "LinearMath/btTransform.h" - -typedef bool (*ContactAddedCallback)(btManifoldPoint& cp, const btCollisionObject* colObj0,int partId0,int index0,const btCollisionObject* colObj1,int partId1,int index1); -extern ContactAddedCallback gContactAddedCallback; - -//#define DEBUG_PART_INDEX 1 - - -///btManifoldResult is a helper class to manage contact results. -class btManifoldResult : public btDiscreteCollisionDetectorInterface::Result -{ - btPersistentManifold* m_manifoldPtr; - - //we need this for compounds - btTransform m_rootTransA; - btTransform m_rootTransB; - - btCollisionObject* m_body0; - btCollisionObject* m_body1; - int m_partId0; - int m_partId1; - int m_index0; - int m_index1; - - -public: - - btManifoldResult() -#ifdef DEBUG_PART_INDEX - : - m_partId0(-1), - m_partId1(-1), - m_index0(-1), - m_index1(-1) -#endif //DEBUG_PART_INDEX - { - } - - btManifoldResult(btCollisionObject* body0,btCollisionObject* body1); - - virtual ~btManifoldResult() {}; - - void setPersistentManifold(btPersistentManifold* manifoldPtr) - { - m_manifoldPtr = manifoldPtr; - } - - const btPersistentManifold* getPersistentManifold() const - { - return m_manifoldPtr; - } - btPersistentManifold* getPersistentManifold() - { - return m_manifoldPtr; - } - - virtual void setShapeIdentifiersA(int partId0,int index0) - { - m_partId0=partId0; - m_index0=index0; - } - - virtual void setShapeIdentifiersB( int partId1,int index1) - { - m_partId1=partId1; - m_index1=index1; - } - - - virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth); - - SIMD_FORCE_INLINE void refreshContactPoints() - { - btAssert(m_manifoldPtr); - if (!m_manifoldPtr->getNumContacts()) - return; - - bool isSwapped = m_manifoldPtr->getBody0() != m_body0; - - if (isSwapped) - { - m_manifoldPtr->refreshContactPoints(m_rootTransB,m_rootTransA); - } else - { - m_manifoldPtr->refreshContactPoints(m_rootTransA,m_rootTransB); - } - } - - const btCollisionObject* getBody0Internal() const - { - return m_body0; - } - - const btCollisionObject* getBody1Internal() const - { - return m_body1; - } - -}; - -#endif //MANIFOLD_RESULT_H diff --git a/bullet/src/BulletCollision/CollisionDispatch/btSimulationIslandManager.cpp b/bullet/src/BulletCollision/CollisionDispatch/btSimulationIslandManager.cpp deleted file mode 100644 index b0f466878..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btSimulationIslandManager.cpp +++ /dev/null @@ -1,392 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#include "LinearMath/btScalar.h" -#include "btSimulationIslandManager.h" -#include "BulletCollision/BroadphaseCollision/btDispatcher.h" -#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h" -#include "BulletCollision/CollisionDispatch/btCollisionObject.h" -#include "BulletCollision/CollisionDispatch/btCollisionWorld.h" - -//#include -#include "LinearMath/btQuickprof.h" - -btSimulationIslandManager::btSimulationIslandManager(): -m_splitIslands(true) -{ -} - -btSimulationIslandManager::~btSimulationIslandManager() -{ -} - - -void btSimulationIslandManager::initUnionFind(int n) -{ - m_unionFind.reset(n); -} - - -void btSimulationIslandManager::findUnions(btDispatcher* /* dispatcher */,btCollisionWorld* colWorld) -{ - - { - btOverlappingPairCache* pairCachePtr = colWorld->getPairCache(); - const int numOverlappingPairs = pairCachePtr->getNumOverlappingPairs(); - btBroadphasePair* pairPtr = pairCachePtr->getOverlappingPairArrayPtr(); - - for (int i=0;im_clientObject; - btCollisionObject* colObj1 = (btCollisionObject*)collisionPair.m_pProxy1->m_clientObject; - - if (((colObj0) && ((colObj0)->mergesSimulationIslands())) && - ((colObj1) && ((colObj1)->mergesSimulationIslands()))) - { - - m_unionFind.unite((colObj0)->getIslandTag(), - (colObj1)->getIslandTag()); - } - } - } -} - - -void btSimulationIslandManager::updateActivationState(btCollisionWorld* colWorld,btDispatcher* dispatcher) -{ - - initUnionFind( int (colWorld->getCollisionObjectArray().size())); - - // put the index into m_controllers into m_tag - { - - int index = 0; - int i; - for (i=0;igetCollisionObjectArray().size(); i++) - { - btCollisionObject* collisionObject= colWorld->getCollisionObjectArray()[i]; - collisionObject->setIslandTag(index); - collisionObject->setCompanionId(-1); - collisionObject->setHitFraction(btScalar(1.)); - index++; - - } - } - // do the union find - - findUnions(dispatcher,colWorld); - - - -} - - - - -void btSimulationIslandManager::storeIslandActivationState(btCollisionWorld* colWorld) -{ - // put the islandId ('find' value) into m_tag - { - - - int index = 0; - int i; - for (i=0;igetCollisionObjectArray().size();i++) - { - btCollisionObject* collisionObject= colWorld->getCollisionObjectArray()[i]; - if (!collisionObject->isStaticOrKinematicObject()) - { - collisionObject->setIslandTag( m_unionFind.find(index) ); - collisionObject->setCompanionId(-1); - } else - { - collisionObject->setIslandTag(-1); - collisionObject->setCompanionId(-2); - } - index++; - } - } -} - -inline int getIslandId(const btPersistentManifold* lhs) -{ - int islandId; - const btCollisionObject* rcolObj0 = static_cast(lhs->getBody0()); - const btCollisionObject* rcolObj1 = static_cast(lhs->getBody1()); - islandId= rcolObj0->getIslandTag()>=0?rcolObj0->getIslandTag():rcolObj1->getIslandTag(); - return islandId; - -} - - - -/// function object that routes calls to operator< -class btPersistentManifoldSortPredicate -{ - public: - - SIMD_FORCE_INLINE bool operator() ( const btPersistentManifold* lhs, const btPersistentManifold* rhs ) - { - return getIslandId(lhs) < getIslandId(rhs); - } -}; - - -void btSimulationIslandManager::buildIslands(btDispatcher* dispatcher,btCollisionWorld* collisionWorld) -{ - - BT_PROFILE("islandUnionFindAndQuickSort"); - - btCollisionObjectArray& collisionObjects = collisionWorld->getCollisionObjectArray(); - - m_islandmanifold.resize(0); - - //we are going to sort the unionfind array, and store the element id in the size - //afterwards, we clean unionfind, to make sure no-one uses it anymore - - getUnionFind().sortIslands(); - int numElem = getUnionFind().getNumElements(); - - int endIslandIndex=1; - int startIslandIndex; - - - //update the sleeping state for bodies, if all are sleeping - for ( startIslandIndex=0;startIslandIndexgetIslandTag() != islandId) && (colObj0->getIslandTag() != -1)) - { -// printf("error in island management\n"); - } - - btAssert((colObj0->getIslandTag() == islandId) || (colObj0->getIslandTag() == -1)); - if (colObj0->getIslandTag() == islandId) - { - if (colObj0->getActivationState()== ACTIVE_TAG) - { - allSleeping = false; - } - if (colObj0->getActivationState()== DISABLE_DEACTIVATION) - { - allSleeping = false; - } - } - } - - - if (allSleeping) - { - int idx; - for (idx=startIslandIndex;idxgetIslandTag() != islandId) && (colObj0->getIslandTag() != -1)) - { -// printf("error in island management\n"); - } - - btAssert((colObj0->getIslandTag() == islandId) || (colObj0->getIslandTag() == -1)); - - if (colObj0->getIslandTag() == islandId) - { - colObj0->setActivationState( ISLAND_SLEEPING ); - } - } - } else - { - - int idx; - for (idx=startIslandIndex;idxgetIslandTag() != islandId) && (colObj0->getIslandTag() != -1)) - { -// printf("error in island management\n"); - } - - btAssert((colObj0->getIslandTag() == islandId) || (colObj0->getIslandTag() == -1)); - - if (colObj0->getIslandTag() == islandId) - { - if ( colObj0->getActivationState() == ISLAND_SLEEPING) - { - colObj0->setActivationState( WANTS_DEACTIVATION); - colObj0->setDeactivationTime(0.f); - } - } - } - } - } - - - int i; - int maxNumManifolds = dispatcher->getNumManifolds(); - -//#define SPLIT_ISLANDS 1 -//#ifdef SPLIT_ISLANDS - - -//#endif //SPLIT_ISLANDS - - - for (i=0;igetManifoldByIndexInternal(i); - - btCollisionObject* colObj0 = static_cast(manifold->getBody0()); - btCollisionObject* colObj1 = static_cast(manifold->getBody1()); - - ///@todo: check sleeping conditions! - if (((colObj0) && colObj0->getActivationState() != ISLAND_SLEEPING) || - ((colObj1) && colObj1->getActivationState() != ISLAND_SLEEPING)) - { - - //kinematic objects don't merge islands, but wake up all connected objects - if (colObj0->isKinematicObject() && colObj0->getActivationState() != ISLAND_SLEEPING) - { - colObj1->activate(); - } - if (colObj1->isKinematicObject() && colObj1->getActivationState() != ISLAND_SLEEPING) - { - colObj0->activate(); - } - if(m_splitIslands) - { - //filtering for response - if (dispatcher->needsResponse(colObj0,colObj1)) - m_islandmanifold.push_back(manifold); - } - } - } -} - - - -///@todo: this is random access, it can be walked 'cache friendly'! -void btSimulationIslandManager::buildAndProcessIslands(btDispatcher* dispatcher,btCollisionWorld* collisionWorld, IslandCallback* callback) -{ - btCollisionObjectArray& collisionObjects = collisionWorld->getCollisionObjectArray(); - - buildIslands(dispatcher,collisionWorld); - - int endIslandIndex=1; - int startIslandIndex; - int numElem = getUnionFind().getNumElements(); - - BT_PROFILE("processIslands"); - - if(!m_splitIslands) - { - btPersistentManifold** manifold = dispatcher->getInternalManifoldPointer(); - int maxNumManifolds = dispatcher->getNumManifolds(); - callback->ProcessIsland(&collisionObjects[0],collisionObjects.size(),manifold,maxNumManifolds, -1); - } - else - { - // Sort manifolds, based on islands - // Sort the vector using predicate and std::sort - //std::sort(islandmanifold.begin(), islandmanifold.end(), btPersistentManifoldSortPredicate); - - int numManifolds = int (m_islandmanifold.size()); - - //we should do radix sort, it it much faster (O(n) instead of O (n log2(n)) - m_islandmanifold.quickSort(btPersistentManifoldSortPredicate()); - - //now process all active islands (sets of manifolds for now) - - int startManifoldIndex = 0; - int endManifoldIndex = 1; - - //int islandId; - - - - // printf("Start Islands\n"); - - //traverse the simulation islands, and call the solver, unless all objects are sleeping/deactivated - for ( startIslandIndex=0;startIslandIndexisActive()) - islandSleeping = true; - } - - - //find the accompanying contact manifold for this islandId - int numIslandManifolds = 0; - btPersistentManifold** startManifold = 0; - - if (startManifoldIndexProcessIsland(&m_islandBodies[0],m_islandBodies.size(),startManifold,numIslandManifolds, islandId); - // printf("Island callback of size:%d bodies, %d manifolds\n",islandBodies.size(),numIslandManifolds); - } - - if (numIslandManifolds) - { - startManifoldIndex = endManifoldIndex; - } - - m_islandBodies.resize(0); - } - } // else if(!splitIslands) - -} diff --git a/bullet/src/BulletCollision/CollisionDispatch/btSimulationIslandManager.h b/bullet/src/BulletCollision/CollisionDispatch/btSimulationIslandManager.h deleted file mode 100644 index dccd2a72c..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btSimulationIslandManager.h +++ /dev/null @@ -1,81 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef SIMULATION_ISLAND_MANAGER_H -#define SIMULATION_ISLAND_MANAGER_H - -#include "BulletCollision/CollisionDispatch/btUnionFind.h" -#include "btCollisionCreateFunc.h" -#include "LinearMath/btAlignedObjectArray.h" -#include "btCollisionObject.h" - -class btCollisionObject; -class btCollisionWorld; -class btDispatcher; -class btPersistentManifold; - - -///SimulationIslandManager creates and handles simulation islands, using btUnionFind -class btSimulationIslandManager -{ - btUnionFind m_unionFind; - - btAlignedObjectArray m_islandmanifold; - btAlignedObjectArray m_islandBodies; - - bool m_splitIslands; - -public: - btSimulationIslandManager(); - virtual ~btSimulationIslandManager(); - - - void initUnionFind(int n); - - - btUnionFind& getUnionFind() { return m_unionFind;} - - virtual void updateActivationState(btCollisionWorld* colWorld,btDispatcher* dispatcher); - virtual void storeIslandActivationState(btCollisionWorld* world); - - - void findUnions(btDispatcher* dispatcher,btCollisionWorld* colWorld); - - - - struct IslandCallback - { - virtual ~IslandCallback() {}; - - virtual void ProcessIsland(btCollisionObject** bodies,int numBodies,class btPersistentManifold** manifolds,int numManifolds, int islandId) = 0; - }; - - void buildAndProcessIslands(btDispatcher* dispatcher,btCollisionWorld* collisionWorld, IslandCallback* callback); - - void buildIslands(btDispatcher* dispatcher,btCollisionWorld* colWorld); - - bool getSplitIslands() - { - return m_splitIslands; - } - void setSplitIslands(bool doSplitIslands) - { - m_splitIslands = doSplitIslands; - } - -}; - -#endif //SIMULATION_ISLAND_MANAGER_H - diff --git a/bullet/src/BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.cpp b/bullet/src/BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.cpp deleted file mode 100644 index 9342919bf..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.cpp +++ /dev/null @@ -1,260 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btSphereBoxCollisionAlgorithm.h" -#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h" -#include "BulletCollision/CollisionShapes/btSphereShape.h" -#include "BulletCollision/CollisionShapes/btBoxShape.h" -#include "BulletCollision/CollisionDispatch/btCollisionObject.h" -//#include - -btSphereBoxCollisionAlgorithm::btSphereBoxCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1, bool isSwapped) -: btActivatingCollisionAlgorithm(ci,col0,col1), -m_ownManifold(false), -m_manifoldPtr(mf), -m_isSwapped(isSwapped) -{ - btCollisionObject* sphereObj = m_isSwapped? col1 : col0; - btCollisionObject* boxObj = m_isSwapped? col0 : col1; - - if (!m_manifoldPtr && m_dispatcher->needsCollision(sphereObj,boxObj)) - { - m_manifoldPtr = m_dispatcher->getNewManifold(sphereObj,boxObj); - m_ownManifold = true; - } -} - - -btSphereBoxCollisionAlgorithm::~btSphereBoxCollisionAlgorithm() -{ - if (m_ownManifold) - { - if (m_manifoldPtr) - m_dispatcher->releaseManifold(m_manifoldPtr); - } -} - - - -void btSphereBoxCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) -{ - (void)dispatchInfo; - (void)resultOut; - if (!m_manifoldPtr) - return; - - btCollisionObject* sphereObj = m_isSwapped? body1 : body0; - btCollisionObject* boxObj = m_isSwapped? body0 : body1; - - - btSphereShape* sphere0 = (btSphereShape*)sphereObj->getCollisionShape(); - - btVector3 normalOnSurfaceB; - btVector3 pOnBox,pOnSphere; - btVector3 sphereCenter = sphereObj->getWorldTransform().getOrigin(); - btScalar radius = sphere0->getRadius(); - - btScalar dist = getSphereDistance(boxObj,pOnBox,pOnSphere,sphereCenter,radius); - - resultOut->setPersistentManifold(m_manifoldPtr); - - if (dist < SIMD_EPSILON) - { - btVector3 normalOnSurfaceB = (pOnBox- pOnSphere).normalize(); - - /// report a contact. internally this will be kept persistent, and contact reduction is done - - resultOut->addContactPoint(normalOnSurfaceB,pOnBox,dist); - - } - - if (m_ownManifold) - { - if (m_manifoldPtr->getNumContacts()) - { - resultOut->refreshContactPoints(); - } - } - -} - -btScalar btSphereBoxCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* col0,btCollisionObject* col1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) -{ - (void)resultOut; - (void)dispatchInfo; - (void)col0; - (void)col1; - - //not yet - return btScalar(1.); -} - - -btScalar btSphereBoxCollisionAlgorithm::getSphereDistance(btCollisionObject* boxObj, btVector3& pointOnBox, btVector3& v3PointOnSphere, const btVector3& sphereCenter, btScalar fRadius ) -{ - - btScalar margins; - btVector3 bounds[2]; - btBoxShape* boxShape= (btBoxShape*)boxObj->getCollisionShape(); - - bounds[0] = -boxShape->getHalfExtentsWithoutMargin(); - bounds[1] = boxShape->getHalfExtentsWithoutMargin(); - - margins = boxShape->getMargin();//also add sphereShape margin? - - const btTransform& m44T = boxObj->getWorldTransform(); - - btVector3 boundsVec[2]; - btScalar fPenetration; - - boundsVec[0] = bounds[0]; - boundsVec[1] = bounds[1]; - - btVector3 marginsVec( margins, margins, margins ); - - // add margins - bounds[0] += marginsVec; - bounds[1] -= marginsVec; - - ///////////////////////////////////////////////// - - btVector3 tmp, prel, n[6], normal, v3P; - btScalar fSep = btScalar(10000000.0), fSepThis; - - n[0].setValue( btScalar(-1.0), btScalar(0.0), btScalar(0.0) ); - n[1].setValue( btScalar(0.0), btScalar(-1.0), btScalar(0.0) ); - n[2].setValue( btScalar(0.0), btScalar(0.0), btScalar(-1.0) ); - n[3].setValue( btScalar(1.0), btScalar(0.0), btScalar(0.0) ); - n[4].setValue( btScalar(0.0), btScalar(1.0), btScalar(0.0) ); - n[5].setValue( btScalar(0.0), btScalar(0.0), btScalar(1.0) ); - - // convert point in local space - prel = m44T.invXform( sphereCenter); - - bool bFound = false; - - v3P = prel; - - for (int i=0;i<6;i++) - { - int j = i<3? 0:1; - if ( (fSepThis = ((v3P-bounds[j]) .dot(n[i]))) > btScalar(0.0) ) - { - v3P = v3P - n[i]*fSepThis; - bFound = true; - } - } - - // - - if ( bFound ) - { - bounds[0] = boundsVec[0]; - bounds[1] = boundsVec[1]; - - normal = (prel - v3P).normalize(); - pointOnBox = v3P + normal*margins; - v3PointOnSphere = prel - normal*fRadius; - - if ( ((v3PointOnSphere - pointOnBox) .dot (normal)) > btScalar(0.0) ) - { - return btScalar(1.0); - } - - // transform back in world space - tmp = m44T( pointOnBox); - pointOnBox = tmp; - tmp = m44T( v3PointOnSphere); - v3PointOnSphere = tmp; - btScalar fSeps2 = (pointOnBox-v3PointOnSphere).length2(); - - //if this fails, fallback into deeper penetration case, below - if (fSeps2 > SIMD_EPSILON) - { - fSep = - btSqrt(fSeps2); - normal = (pointOnBox-v3PointOnSphere); - normal *= btScalar(1.)/fSep; - } - - return fSep; - } - - ////////////////////////////////////////////////// - // Deep penetration case - - fPenetration = getSpherePenetration( boxObj,pointOnBox, v3PointOnSphere, sphereCenter, fRadius,bounds[0],bounds[1] ); - - bounds[0] = boundsVec[0]; - bounds[1] = boundsVec[1]; - - if ( fPenetration <= btScalar(0.0) ) - return (fPenetration-margins); - else - return btScalar(1.0); -} - -btScalar btSphereBoxCollisionAlgorithm::getSpherePenetration( btCollisionObject* boxObj,btVector3& pointOnBox, btVector3& v3PointOnSphere, const btVector3& sphereCenter, btScalar fRadius, const btVector3& aabbMin, const btVector3& aabbMax) -{ - - btVector3 bounds[2]; - - bounds[0] = aabbMin; - bounds[1] = aabbMax; - - btVector3 p0, tmp, prel, n[6], normal; - btScalar fSep = btScalar(-10000000.0), fSepThis; - - // set p0 and normal to a default value to shup up GCC - p0.setValue(btScalar(0.), btScalar(0.), btScalar(0.)); - normal.setValue(btScalar(0.), btScalar(0.), btScalar(0.)); - - n[0].setValue( btScalar(-1.0), btScalar(0.0), btScalar(0.0) ); - n[1].setValue( btScalar(0.0), btScalar(-1.0), btScalar(0.0) ); - n[2].setValue( btScalar(0.0), btScalar(0.0), btScalar(-1.0) ); - n[3].setValue( btScalar(1.0), btScalar(0.0), btScalar(0.0) ); - n[4].setValue( btScalar(0.0), btScalar(1.0), btScalar(0.0) ); - n[5].setValue( btScalar(0.0), btScalar(0.0), btScalar(1.0) ); - - const btTransform& m44T = boxObj->getWorldTransform(); - - // convert point in local space - prel = m44T.invXform( sphereCenter); - - /////////// - - for (int i=0;i<6;i++) - { - int j = i<3 ? 0:1; - if ( (fSepThis = ((prel-bounds[j]) .dot( n[i]))-fRadius) > btScalar(0.0) ) return btScalar(1.0); - if ( fSepThis > fSep ) - { - p0 = bounds[j]; normal = (btVector3&)n[i]; - fSep = fSepThis; - } - } - - pointOnBox = prel - normal*(normal.dot((prel-p0))); - v3PointOnSphere = pointOnBox + normal*fSep; - - // transform back in world space - tmp = m44T( pointOnBox); - pointOnBox = tmp; - tmp = m44T( v3PointOnSphere); v3PointOnSphere = tmp; - normal = (pointOnBox-v3PointOnSphere).normalize(); - - return fSep; - -} - diff --git a/bullet/src/BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.h b/bullet/src/BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.h deleted file mode 100644 index 6bded59b6..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef SPHERE_BOX_COLLISION_ALGORITHM_H -#define SPHERE_BOX_COLLISION_ALGORITHM_H - -#include "btActivatingCollisionAlgorithm.h" -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" -#include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h" -class btPersistentManifold; -#include "btCollisionDispatcher.h" - -#include "LinearMath/btVector3.h" - -/// btSphereBoxCollisionAlgorithm provides sphere-box collision detection. -/// Other features are frame-coherency (persistent data) and collision response. -class btSphereBoxCollisionAlgorithm : public btActivatingCollisionAlgorithm -{ - bool m_ownManifold; - btPersistentManifold* m_manifoldPtr; - bool m_isSwapped; - -public: - - btSphereBoxCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1, bool isSwapped); - - virtual ~btSphereBoxCollisionAlgorithm(); - - virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); - - virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); - - virtual void getAllContactManifolds(btManifoldArray& manifoldArray) - { - if (m_manifoldPtr && m_ownManifold) - { - manifoldArray.push_back(m_manifoldPtr); - } - } - - btScalar getSphereDistance( btCollisionObject* boxObj,btVector3& v3PointOnBox, btVector3& v3PointOnSphere, const btVector3& v3SphereCenter, btScalar fRadius ); - - btScalar getSpherePenetration( btCollisionObject* boxObj, btVector3& v3PointOnBox, btVector3& v3PointOnSphere, const btVector3& v3SphereCenter, btScalar fRadius, const btVector3& aabbMin, const btVector3& aabbMax); - - struct CreateFunc :public btCollisionAlgorithmCreateFunc - { - virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1) - { - void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btSphereBoxCollisionAlgorithm)); - if (!m_swapped) - { - return new(mem) btSphereBoxCollisionAlgorithm(0,ci,body0,body1,false); - } else - { - return new(mem) btSphereBoxCollisionAlgorithm(0,ci,body0,body1,true); - } - } - }; - -}; - -#endif //SPHERE_BOX_COLLISION_ALGORITHM_H - diff --git a/bullet/src/BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.cpp b/bullet/src/BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.cpp deleted file mode 100644 index d08742bed..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btSphereSphereCollisionAlgorithm.h" -#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h" -#include "BulletCollision/CollisionShapes/btSphereShape.h" -#include "BulletCollision/CollisionDispatch/btCollisionObject.h" - -btSphereSphereCollisionAlgorithm::btSphereSphereCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1) -: btActivatingCollisionAlgorithm(ci,col0,col1), -m_ownManifold(false), -m_manifoldPtr(mf) -{ - if (!m_manifoldPtr) - { - m_manifoldPtr = m_dispatcher->getNewManifold(col0,col1); - m_ownManifold = true; - } -} - -btSphereSphereCollisionAlgorithm::~btSphereSphereCollisionAlgorithm() -{ - if (m_ownManifold) - { - if (m_manifoldPtr) - m_dispatcher->releaseManifold(m_manifoldPtr); - } -} - -void btSphereSphereCollisionAlgorithm::processCollision (btCollisionObject* col0,btCollisionObject* col1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) -{ - (void)dispatchInfo; - - if (!m_manifoldPtr) - return; - - resultOut->setPersistentManifold(m_manifoldPtr); - - btSphereShape* sphere0 = (btSphereShape*)col0->getCollisionShape(); - btSphereShape* sphere1 = (btSphereShape*)col1->getCollisionShape(); - - btVector3 diff = col0->getWorldTransform().getOrigin()- col1->getWorldTransform().getOrigin(); - btScalar len = diff.length(); - btScalar radius0 = sphere0->getRadius(); - btScalar radius1 = sphere1->getRadius(); - -#ifdef CLEAR_MANIFOLD - m_manifoldPtr->clearManifold(); //don't do this, it disables warmstarting -#endif - - ///iff distance positive, don't generate a new contact - if ( len > (radius0+radius1)) - { -#ifndef CLEAR_MANIFOLD - resultOut->refreshContactPoints(); -#endif //CLEAR_MANIFOLD - return; - } - ///distance (negative means penetration) - btScalar dist = len - (radius0+radius1); - - btVector3 normalOnSurfaceB(1,0,0); - if (len > SIMD_EPSILON) - { - normalOnSurfaceB = diff / len; - } - - ///point on A (worldspace) - ///btVector3 pos0 = col0->getWorldTransform().getOrigin() - radius0 * normalOnSurfaceB; - ///point on B (worldspace) - btVector3 pos1 = col1->getWorldTransform().getOrigin() + radius1* normalOnSurfaceB; - - /// report a contact. internally this will be kept persistent, and contact reduction is done - - - resultOut->addContactPoint(normalOnSurfaceB,pos1,dist); - -#ifndef CLEAR_MANIFOLD - resultOut->refreshContactPoints(); -#endif //CLEAR_MANIFOLD - -} - -btScalar btSphereSphereCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* col0,btCollisionObject* col1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) -{ - (void)col0; - (void)col1; - (void)dispatchInfo; - (void)resultOut; - - //not yet - return btScalar(1.); -} diff --git a/bullet/src/BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.h b/bullet/src/BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.h deleted file mode 100644 index e6b322376..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef SPHERE_SPHERE_COLLISION_ALGORITHM_H -#define SPHERE_SPHERE_COLLISION_ALGORITHM_H - -#include "btActivatingCollisionAlgorithm.h" -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" -#include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h" -#include "btCollisionDispatcher.h" - -class btPersistentManifold; - -/// btSphereSphereCollisionAlgorithm provides sphere-sphere collision detection. -/// Other features are frame-coherency (persistent data) and collision response. -/// Also provides the most basic sample for custom/user btCollisionAlgorithm -class btSphereSphereCollisionAlgorithm : public btActivatingCollisionAlgorithm -{ - bool m_ownManifold; - btPersistentManifold* m_manifoldPtr; - -public: - btSphereSphereCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1); - - btSphereSphereCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci) - : btActivatingCollisionAlgorithm(ci) {} - - virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); - - virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); - - virtual void getAllContactManifolds(btManifoldArray& manifoldArray) - { - if (m_manifoldPtr && m_ownManifold) - { - manifoldArray.push_back(m_manifoldPtr); - } - } - - virtual ~btSphereSphereCollisionAlgorithm(); - - struct CreateFunc :public btCollisionAlgorithmCreateFunc - { - virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1) - { - void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btSphereSphereCollisionAlgorithm)); - return new(mem) btSphereSphereCollisionAlgorithm(0,ci,body0,body1); - } - }; - -}; - -#endif //SPHERE_SPHERE_COLLISION_ALGORITHM_H - diff --git a/bullet/src/BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.cpp b/bullet/src/BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.cpp deleted file mode 100644 index 3a2656729..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#include "btSphereTriangleCollisionAlgorithm.h" -#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h" -#include "BulletCollision/CollisionShapes/btSphereShape.h" -#include "BulletCollision/CollisionDispatch/btCollisionObject.h" -#include "SphereTriangleDetector.h" - - -btSphereTriangleCollisionAlgorithm::btSphereTriangleCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1,bool swapped) -: btActivatingCollisionAlgorithm(ci,col0,col1), -m_ownManifold(false), -m_manifoldPtr(mf), -m_swapped(swapped) -{ - if (!m_manifoldPtr) - { - m_manifoldPtr = m_dispatcher->getNewManifold(col0,col1); - m_ownManifold = true; - } -} - -btSphereTriangleCollisionAlgorithm::~btSphereTriangleCollisionAlgorithm() -{ - if (m_ownManifold) - { - if (m_manifoldPtr) - m_dispatcher->releaseManifold(m_manifoldPtr); - } -} - -void btSphereTriangleCollisionAlgorithm::processCollision (btCollisionObject* col0,btCollisionObject* col1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) -{ - if (!m_manifoldPtr) - return; - - btCollisionObject* sphereObj = m_swapped? col1 : col0; - btCollisionObject* triObj = m_swapped? col0 : col1; - - btSphereShape* sphere = (btSphereShape*)sphereObj->getCollisionShape(); - btTriangleShape* triangle = (btTriangleShape*)triObj->getCollisionShape(); - - /// report a contact. internally this will be kept persistent, and contact reduction is done - resultOut->setPersistentManifold(m_manifoldPtr); - SphereTriangleDetector detector(sphere,triangle, m_manifoldPtr->getContactBreakingThreshold()); - - btDiscreteCollisionDetectorInterface::ClosestPointInput input; - input.m_maximumDistanceSquared = btScalar(BT_LARGE_FLOAT);///@todo: tighter bounds - input.m_transformA = sphereObj->getWorldTransform(); - input.m_transformB = triObj->getWorldTransform(); - - bool swapResults = m_swapped; - - detector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw,swapResults); - - if (m_ownManifold) - resultOut->refreshContactPoints(); - -} - -btScalar btSphereTriangleCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* col0,btCollisionObject* col1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) -{ - (void)resultOut; - (void)dispatchInfo; - (void)col0; - (void)col1; - - //not yet - return btScalar(1.); -} diff --git a/bullet/src/BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.h b/bullet/src/BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.h deleted file mode 100644 index f184c700f..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef SPHERE_TRIANGLE_COLLISION_ALGORITHM_H -#define SPHERE_TRIANGLE_COLLISION_ALGORITHM_H - -#include "btActivatingCollisionAlgorithm.h" -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" -#include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h" -class btPersistentManifold; -#include "btCollisionDispatcher.h" - -/// btSphereSphereCollisionAlgorithm provides sphere-sphere collision detection. -/// Other features are frame-coherency (persistent data) and collision response. -/// Also provides the most basic sample for custom/user btCollisionAlgorithm -class btSphereTriangleCollisionAlgorithm : public btActivatingCollisionAlgorithm -{ - bool m_ownManifold; - btPersistentManifold* m_manifoldPtr; - bool m_swapped; - -public: - btSphereTriangleCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,bool swapped); - - btSphereTriangleCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci) - : btActivatingCollisionAlgorithm(ci) {} - - virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); - - virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); - - virtual void getAllContactManifolds(btManifoldArray& manifoldArray) - { - if (m_manifoldPtr && m_ownManifold) - { - manifoldArray.push_back(m_manifoldPtr); - } - } - - virtual ~btSphereTriangleCollisionAlgorithm(); - - struct CreateFunc :public btCollisionAlgorithmCreateFunc - { - - virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1) - { - - void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btSphereTriangleCollisionAlgorithm)); - - return new(mem) btSphereTriangleCollisionAlgorithm(ci.m_manifold,ci,body0,body1,m_swapped); - } - }; - -}; - -#endif //SPHERE_TRIANGLE_COLLISION_ALGORITHM_H - diff --git a/bullet/src/BulletCollision/CollisionDispatch/btUnionFind.cpp b/bullet/src/BulletCollision/CollisionDispatch/btUnionFind.cpp deleted file mode 100644 index 06ea3e6f9..000000000 --- a/bullet/src/BulletCollision/CollisionDispatch/btUnionFind.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btUnionFind.h" - - - -btUnionFind::~btUnionFind() -{ - Free(); - -} - -btUnionFind::btUnionFind() -{ - -} - -void btUnionFind::allocate(int N) -{ - m_elements.resize(N); -} -void btUnionFind::Free() -{ - m_elements.clear(); -} - - -void btUnionFind::reset(int N) -{ - allocate(N); - - for (int i = 0; i < N; i++) - { - m_elements[i].m_id = i; m_elements[i].m_sz = 1; - } -} - - -class btUnionFindElementSortPredicate -{ - public: - - bool operator() ( const btElement& lhs, const btElement& rhs ) - { - return lhs.m_id < rhs.m_id; - } -}; - -///this is a special operation, destroying the content of btUnionFind. -///it sorts the elements, based on island id, in order to make it easy to iterate over islands -void btUnionFind::sortIslands() -{ - - //first store the original body index, and islandId - int numElements = m_elements.size(); - - for (int i=0;i m_elements; - - public: - - btUnionFind(); - ~btUnionFind(); - - - //this is a special operation, destroying the content of btUnionFind. - //it sorts the elements, based on island id, in order to make it easy to iterate over islands - void sortIslands(); - - void reset(int N); - - SIMD_FORCE_INLINE int getNumElements() const - { - return int(m_elements.size()); - } - SIMD_FORCE_INLINE bool isRoot(int x) const - { - return (x == m_elements[x].m_id); - } - - btElement& getElement(int index) - { - return m_elements[index]; - } - const btElement& getElement(int index) const - { - return m_elements[index]; - } - - void allocate(int N); - void Free(); - - - - - int find(int p, int q) - { - return (find(p) == find(q)); - } - - void unite(int p, int q) - { - int i = find(p), j = find(q); - if (i == j) - return; - -#ifndef USE_PATH_COMPRESSION - //weighted quick union, this keeps the 'trees' balanced, and keeps performance of unite O( log(n) ) - if (m_elements[i].m_sz < m_elements[j].m_sz) - { - m_elements[i].m_id = j; m_elements[j].m_sz += m_elements[i].m_sz; - } - else - { - m_elements[j].m_id = i; m_elements[i].m_sz += m_elements[j].m_sz; - } -#else - m_elements[i].m_id = j; m_elements[j].m_sz += m_elements[i].m_sz; -#endif //USE_PATH_COMPRESSION - } - - int find(int x) - { - //btAssert(x < m_N); - //btAssert(x >= 0); - - while (x != m_elements[x].m_id) - { - //not really a reason not to use path compression, and it flattens the trees/improves find performance dramatically - - #ifdef USE_PATH_COMPRESSION - // - m_elements[x].m_id = m_elements[m_elements[x].m_id].m_id; - #endif // - x = m_elements[x].m_id; - //btAssert(x < m_N); - //btAssert(x >= 0); - - } - return x; - } - - - }; - - -#endif //UNION_FIND_H diff --git a/bullet/src/BulletCollision/CollisionShapes/btBox2dShape.cpp b/bullet/src/BulletCollision/CollisionShapes/btBox2dShape.cpp deleted file mode 100644 index cfc54fc4f..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btBox2dShape.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btBox2dShape.h" - - -//{ - - -void btBox2dShape::getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const -{ - btTransformAabb(getHalfExtentsWithoutMargin(),getMargin(),t,aabbMin,aabbMax); -} - - -void btBox2dShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const -{ - //btScalar margin = btScalar(0.); - btVector3 halfExtents = getHalfExtentsWithMargin(); - - btScalar lx=btScalar(2.)*(halfExtents.x()); - btScalar ly=btScalar(2.)*(halfExtents.y()); - btScalar lz=btScalar(2.)*(halfExtents.z()); - - inertia.setValue(mass/(btScalar(12.0)) * (ly*ly + lz*lz), - mass/(btScalar(12.0)) * (lx*lx + lz*lz), - mass/(btScalar(12.0)) * (lx*lx + ly*ly)); - -} - diff --git a/bullet/src/BulletCollision/CollisionShapes/btBox2dShape.h b/bullet/src/BulletCollision/CollisionShapes/btBox2dShape.h deleted file mode 100644 index a282e2302..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btBox2dShape.h +++ /dev/null @@ -1,363 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef OBB_BOX_2D_SHAPE_H -#define OBB_BOX_2D_SHAPE_H - -#include "BulletCollision/CollisionShapes/btPolyhedralConvexShape.h" -#include "BulletCollision/CollisionShapes/btCollisionMargin.h" -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" -#include "LinearMath/btVector3.h" -#include "LinearMath/btMinMax.h" - -///The btBox2dShape is a box primitive around the origin, its sides axis aligned with length specified by half extents, in local shape coordinates. When used as part of a btCollisionObject or btRigidBody it will be an oriented box in world space. -class btBox2dShape: public btPolyhedralConvexShape -{ - - //btVector3 m_boxHalfExtents1; //use m_implicitShapeDimensions instead - - btVector3 m_centroid; - btVector3 m_vertices[4]; - btVector3 m_normals[4]; - -public: - - btVector3 getHalfExtentsWithMargin() const - { - btVector3 halfExtents = getHalfExtentsWithoutMargin(); - btVector3 margin(getMargin(),getMargin(),getMargin()); - halfExtents += margin; - return halfExtents; - } - - const btVector3& getHalfExtentsWithoutMargin() const - { - return m_implicitShapeDimensions;//changed in Bullet 2.63: assume the scaling and margin are included - } - - - virtual btVector3 localGetSupportingVertex(const btVector3& vec) const - { - btVector3 halfExtents = getHalfExtentsWithoutMargin(); - btVector3 margin(getMargin(),getMargin(),getMargin()); - halfExtents += margin; - - return btVector3(btFsels(vec.x(), halfExtents.x(), -halfExtents.x()), - btFsels(vec.y(), halfExtents.y(), -halfExtents.y()), - btFsels(vec.z(), halfExtents.z(), -halfExtents.z())); - } - - SIMD_FORCE_INLINE btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const - { - const btVector3& halfExtents = getHalfExtentsWithoutMargin(); - - return btVector3(btFsels(vec.x(), halfExtents.x(), -halfExtents.x()), - btFsels(vec.y(), halfExtents.y(), -halfExtents.y()), - btFsels(vec.z(), halfExtents.z(), -halfExtents.z())); - } - - virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const - { - const btVector3& halfExtents = getHalfExtentsWithoutMargin(); - - for (int i=0;i>1)) - halfExtents.y() * ((i&2)>>1), - halfExtents.z() * (1-((i&4)>>2)) - halfExtents.z() * ((i&4)>>2)); - } - - - virtual void getPlaneEquation(btVector4& plane,int i) const - { - btVector3 halfExtents = getHalfExtentsWithoutMargin(); - - switch (i) - { - case 0: - plane.setValue(btScalar(1.),btScalar(0.),btScalar(0.),-halfExtents.x()); - break; - case 1: - plane.setValue(btScalar(-1.),btScalar(0.),btScalar(0.),-halfExtents.x()); - break; - case 2: - plane.setValue(btScalar(0.),btScalar(1.),btScalar(0.),-halfExtents.y()); - break; - case 3: - plane.setValue(btScalar(0.),btScalar(-1.),btScalar(0.),-halfExtents.y()); - break; - case 4: - plane.setValue(btScalar(0.),btScalar(0.),btScalar(1.),-halfExtents.z()); - break; - case 5: - plane.setValue(btScalar(0.),btScalar(0.),btScalar(-1.),-halfExtents.z()); - break; - default: - btAssert(0); - } - } - - - virtual void getEdge(int i,btVector3& pa,btVector3& pb) const - //virtual void getEdge(int i,Edge& edge) const - { - int edgeVert0 = 0; - int edgeVert1 = 0; - - switch (i) - { - case 0: - edgeVert0 = 0; - edgeVert1 = 1; - break; - case 1: - edgeVert0 = 0; - edgeVert1 = 2; - break; - case 2: - edgeVert0 = 1; - edgeVert1 = 3; - - break; - case 3: - edgeVert0 = 2; - edgeVert1 = 3; - break; - case 4: - edgeVert0 = 0; - edgeVert1 = 4; - break; - case 5: - edgeVert0 = 1; - edgeVert1 = 5; - - break; - case 6: - edgeVert0 = 2; - edgeVert1 = 6; - break; - case 7: - edgeVert0 = 3; - edgeVert1 = 7; - break; - case 8: - edgeVert0 = 4; - edgeVert1 = 5; - break; - case 9: - edgeVert0 = 4; - edgeVert1 = 6; - break; - case 10: - edgeVert0 = 5; - edgeVert1 = 7; - break; - case 11: - edgeVert0 = 6; - edgeVert1 = 7; - break; - default: - btAssert(0); - - } - - getVertex(edgeVert0,pa ); - getVertex(edgeVert1,pb ); - } - - - - - - virtual bool isInside(const btVector3& pt,btScalar tolerance) const - { - btVector3 halfExtents = getHalfExtentsWithoutMargin(); - - //btScalar minDist = 2*tolerance; - - bool result = (pt.x() <= (halfExtents.x()+tolerance)) && - (pt.x() >= (-halfExtents.x()-tolerance)) && - (pt.y() <= (halfExtents.y()+tolerance)) && - (pt.y() >= (-halfExtents.y()-tolerance)) && - (pt.z() <= (halfExtents.z()+tolerance)) && - (pt.z() >= (-halfExtents.z()-tolerance)); - - return result; - } - - - //debugging - virtual const char* getName()const - { - return "Box2d"; - } - - virtual int getNumPreferredPenetrationDirections() const - { - return 6; - } - - virtual void getPreferredPenetrationDirection(int index, btVector3& penetrationVector) const - { - switch (index) - { - case 0: - penetrationVector.setValue(btScalar(1.),btScalar(0.),btScalar(0.)); - break; - case 1: - penetrationVector.setValue(btScalar(-1.),btScalar(0.),btScalar(0.)); - break; - case 2: - penetrationVector.setValue(btScalar(0.),btScalar(1.),btScalar(0.)); - break; - case 3: - penetrationVector.setValue(btScalar(0.),btScalar(-1.),btScalar(0.)); - break; - case 4: - penetrationVector.setValue(btScalar(0.),btScalar(0.),btScalar(1.)); - break; - case 5: - penetrationVector.setValue(btScalar(0.),btScalar(0.),btScalar(-1.)); - break; - default: - btAssert(0); - } - } - -}; - -#endif //OBB_BOX_2D_SHAPE_H - - diff --git a/bullet/src/BulletCollision/CollisionShapes/btBoxShape.cpp b/bullet/src/BulletCollision/CollisionShapes/btBoxShape.cpp deleted file mode 100644 index acd6afe21..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btBoxShape.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ -#include "btBoxShape.h" - - -//{ - - -void btBoxShape::getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const -{ - btTransformAabb(getHalfExtentsWithoutMargin(),getMargin(),t,aabbMin,aabbMax); -} - - -void btBoxShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const -{ - //btScalar margin = btScalar(0.); - btVector3 halfExtents = getHalfExtentsWithMargin(); - - btScalar lx=btScalar(2.)*(halfExtents.x()); - btScalar ly=btScalar(2.)*(halfExtents.y()); - btScalar lz=btScalar(2.)*(halfExtents.z()); - - inertia.setValue(mass/(btScalar(12.0)) * (ly*ly + lz*lz), - mass/(btScalar(12.0)) * (lx*lx + lz*lz), - mass/(btScalar(12.0)) * (lx*lx + ly*ly)); - -} - diff --git a/bullet/src/BulletCollision/CollisionShapes/btBoxShape.h b/bullet/src/BulletCollision/CollisionShapes/btBoxShape.h deleted file mode 100644 index ae159552c..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btBoxShape.h +++ /dev/null @@ -1,350 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef OBB_BOX_MINKOWSKI_H -#define OBB_BOX_MINKOWSKI_H - -#include "btPolyhedralConvexShape.h" -#include "btCollisionMargin.h" -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" -#include "LinearMath/btVector3.h" -#include "LinearMath/btMinMax.h" - -///The btBoxShape is a box primitive around the origin, its sides axis aligned with length specified by half extents, in local shape coordinates. When used as part of a btCollisionObject or btRigidBody it will be an oriented box in world space. -class btBoxShape: public btPolyhedralConvexShape -{ - - //btVector3 m_boxHalfExtents1; //use m_implicitShapeDimensions instead - - -public: - - btVector3 getHalfExtentsWithMargin() const - { - btVector3 halfExtents = getHalfExtentsWithoutMargin(); - btVector3 margin(getMargin(),getMargin(),getMargin()); - halfExtents += margin; - return halfExtents; - } - - const btVector3& getHalfExtentsWithoutMargin() const - { - return m_implicitShapeDimensions;//changed in Bullet 2.63: assume the scaling and margin are included - } - - - virtual btVector3 localGetSupportingVertex(const btVector3& vec) const - { - btVector3 halfExtents = getHalfExtentsWithoutMargin(); - btVector3 margin(getMargin(),getMargin(),getMargin()); - halfExtents += margin; - - return btVector3(btFsels(vec.x(), halfExtents.x(), -halfExtents.x()), - btFsels(vec.y(), halfExtents.y(), -halfExtents.y()), - btFsels(vec.z(), halfExtents.z(), -halfExtents.z())); - } - - SIMD_FORCE_INLINE btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const - { - const btVector3& halfExtents = getHalfExtentsWithoutMargin(); - - return btVector3(btFsels(vec.x(), halfExtents.x(), -halfExtents.x()), - btFsels(vec.y(), halfExtents.y(), -halfExtents.y()), - btFsels(vec.z(), halfExtents.z(), -halfExtents.z())); - } - - virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const - { - const btVector3& halfExtents = getHalfExtentsWithoutMargin(); - - for (int i=0;i>1)) - halfExtents.y() * ((i&2)>>1), - halfExtents.z() * (1-((i&4)>>2)) - halfExtents.z() * ((i&4)>>2)); - } - - - virtual void getPlaneEquation(btVector4& plane,int i) const - { - btVector3 halfExtents = getHalfExtentsWithoutMargin(); - - switch (i) - { - case 0: - plane.setValue(btScalar(1.),btScalar(0.),btScalar(0.),-halfExtents.x()); - break; - case 1: - plane.setValue(btScalar(-1.),btScalar(0.),btScalar(0.),-halfExtents.x()); - break; - case 2: - plane.setValue(btScalar(0.),btScalar(1.),btScalar(0.),-halfExtents.y()); - break; - case 3: - plane.setValue(btScalar(0.),btScalar(-1.),btScalar(0.),-halfExtents.y()); - break; - case 4: - plane.setValue(btScalar(0.),btScalar(0.),btScalar(1.),-halfExtents.z()); - break; - case 5: - plane.setValue(btScalar(0.),btScalar(0.),btScalar(-1.),-halfExtents.z()); - break; - default: - btAssert(0); - } - } - - - virtual void getEdge(int i,btVector3& pa,btVector3& pb) const - //virtual void getEdge(int i,Edge& edge) const - { - int edgeVert0 = 0; - int edgeVert1 = 0; - - switch (i) - { - case 0: - edgeVert0 = 0; - edgeVert1 = 1; - break; - case 1: - edgeVert0 = 0; - edgeVert1 = 2; - break; - case 2: - edgeVert0 = 1; - edgeVert1 = 3; - - break; - case 3: - edgeVert0 = 2; - edgeVert1 = 3; - break; - case 4: - edgeVert0 = 0; - edgeVert1 = 4; - break; - case 5: - edgeVert0 = 1; - edgeVert1 = 5; - - break; - case 6: - edgeVert0 = 2; - edgeVert1 = 6; - break; - case 7: - edgeVert0 = 3; - edgeVert1 = 7; - break; - case 8: - edgeVert0 = 4; - edgeVert1 = 5; - break; - case 9: - edgeVert0 = 4; - edgeVert1 = 6; - break; - case 10: - edgeVert0 = 5; - edgeVert1 = 7; - break; - case 11: - edgeVert0 = 6; - edgeVert1 = 7; - break; - default: - btAssert(0); - - } - - getVertex(edgeVert0,pa ); - getVertex(edgeVert1,pb ); - } - - - - - - virtual bool isInside(const btVector3& pt,btScalar tolerance) const - { - btVector3 halfExtents = getHalfExtentsWithoutMargin(); - - //btScalar minDist = 2*tolerance; - - bool result = (pt.x() <= (halfExtents.x()+tolerance)) && - (pt.x() >= (-halfExtents.x()-tolerance)) && - (pt.y() <= (halfExtents.y()+tolerance)) && - (pt.y() >= (-halfExtents.y()-tolerance)) && - (pt.z() <= (halfExtents.z()+tolerance)) && - (pt.z() >= (-halfExtents.z()-tolerance)); - - return result; - } - - - //debugging - virtual const char* getName()const - { - return "Box"; - } - - virtual int getNumPreferredPenetrationDirections() const - { - return 6; - } - - virtual void getPreferredPenetrationDirection(int index, btVector3& penetrationVector) const - { - switch (index) - { - case 0: - penetrationVector.setValue(btScalar(1.),btScalar(0.),btScalar(0.)); - break; - case 1: - penetrationVector.setValue(btScalar(-1.),btScalar(0.),btScalar(0.)); - break; - case 2: - penetrationVector.setValue(btScalar(0.),btScalar(1.),btScalar(0.)); - break; - case 3: - penetrationVector.setValue(btScalar(0.),btScalar(-1.),btScalar(0.)); - break; - case 4: - penetrationVector.setValue(btScalar(0.),btScalar(0.),btScalar(1.)); - break; - case 5: - penetrationVector.setValue(btScalar(0.),btScalar(0.),btScalar(-1.)); - break; - default: - btAssert(0); - } - } - - virtual int calculateSerializeBufferSize(); - - ///fills the dataBuffer and returns the struct name (and 0 on failure) - virtual const char* serialize(void* dataBuffer) const; - - - - -}; - - -struct btBoxShapeData -{ - btVector3Data m_halfExtents; - btVector3Data m_localScaling; -}; - - - -SIMD_FORCE_INLINE int btBoxShape::calculateSerializeBufferSize() -{ - return sizeof(btBoxShapeData); -} - -///fills the dataBuffer and returns the struct name (and 0 on failure) -SIMD_FORCE_INLINE const char* btBoxShape::serialize(void* dataBuffer) const -{ - btBoxShapeData* boxData = (btBoxShapeData*) dataBuffer; - - m_implicitShapeDimensions.serialize(boxData->m_halfExtents); - m_localScaling.serialize(boxData->m_localScaling); - return "btBoxShapeData"; -} - - -#endif //OBB_BOX_MINKOWSKI_H - - diff --git a/bullet/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp b/bullet/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp deleted file mode 100644 index fe1a78c25..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp +++ /dev/null @@ -1,374 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -//#define DISABLE_BVH - -#include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h" -#include "BulletCollision/CollisionShapes/btOptimizedBvh.h" - -///Bvh Concave triangle mesh is a static-triangle mesh shape with Bounding Volume Hierarchy optimization. -///Uses an interface to access the triangles to allow for sharing graphics/physics triangles. -btBvhTriangleMeshShape::btBvhTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression, bool buildBvh) -:btTriangleMeshShape(meshInterface), -m_bvh(0), -m_useQuantizedAabbCompression(useQuantizedAabbCompression), -m_ownsBvh(false) -{ - m_shapeType = TRIANGLE_MESH_SHAPE_PROXYTYPE; - //construct bvh from meshInterface -#ifndef DISABLE_BVH - - btVector3 bvhAabbMin,bvhAabbMax; - if(meshInterface->hasPremadeAabb()) - { - meshInterface->getPremadeAabb(&bvhAabbMin, &bvhAabbMax); - } - else - { - meshInterface->calculateAabbBruteForce(bvhAabbMin,bvhAabbMax); - } - - if (buildBvh) - { - void* mem = btAlignedAlloc(sizeof(btOptimizedBvh),16); - m_bvh = new (mem) btOptimizedBvh(); - m_bvh->build(meshInterface,m_useQuantizedAabbCompression,bvhAabbMin,bvhAabbMax); - m_ownsBvh = true; - } - -#endif //DISABLE_BVH - -} - -btBvhTriangleMeshShape::btBvhTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression,const btVector3& bvhAabbMin,const btVector3& bvhAabbMax,bool buildBvh) -:btTriangleMeshShape(meshInterface), -m_bvh(0), -m_useQuantizedAabbCompression(useQuantizedAabbCompression), -m_ownsBvh(false) -{ - m_shapeType = TRIANGLE_MESH_SHAPE_PROXYTYPE; - //construct bvh from meshInterface -#ifndef DISABLE_BVH - - if (buildBvh) - { - void* mem = btAlignedAlloc(sizeof(btOptimizedBvh),16); - m_bvh = new (mem) btOptimizedBvh(); - - m_bvh->build(meshInterface,m_useQuantizedAabbCompression,bvhAabbMin,bvhAabbMax); - m_ownsBvh = true; - } - -#endif //DISABLE_BVH - -} - -void btBvhTriangleMeshShape::partialRefitTree(const btVector3& aabbMin,const btVector3& aabbMax) -{ - m_bvh->refitPartial( m_meshInterface,aabbMin,aabbMax ); - - m_localAabbMin.setMin(aabbMin); - m_localAabbMax.setMax(aabbMax); -} - - -void btBvhTriangleMeshShape::refitTree(const btVector3& aabbMin,const btVector3& aabbMax) -{ - m_bvh->refit( m_meshInterface, aabbMin,aabbMax ); - - recalcLocalAabb(); -} - -btBvhTriangleMeshShape::~btBvhTriangleMeshShape() -{ - if (m_ownsBvh) - { - m_bvh->~btOptimizedBvh(); - btAlignedFree(m_bvh); - } -} - -void btBvhTriangleMeshShape::performRaycast (btTriangleCallback* callback, const btVector3& raySource, const btVector3& rayTarget) -{ - struct MyNodeOverlapCallback : public btNodeOverlapCallback - { - btStridingMeshInterface* m_meshInterface; - btTriangleCallback* m_callback; - - MyNodeOverlapCallback(btTriangleCallback* callback,btStridingMeshInterface* meshInterface) - :m_meshInterface(meshInterface), - m_callback(callback) - { - } - - virtual void processNode(int nodeSubPart, int nodeTriangleIndex) - { - btVector3 m_triangle[3]; - const unsigned char *vertexbase; - int numverts; - PHY_ScalarType type; - int stride; - const unsigned char *indexbase; - int indexstride; - int numfaces; - PHY_ScalarType indicestype; - - m_meshInterface->getLockedReadOnlyVertexIndexBase( - &vertexbase, - numverts, - type, - stride, - &indexbase, - indexstride, - numfaces, - indicestype, - nodeSubPart); - - unsigned int* gfxbase = (unsigned int*)(indexbase+nodeTriangleIndex*indexstride); - btAssert(indicestype==PHY_INTEGER||indicestype==PHY_SHORT); - - const btVector3& meshScaling = m_meshInterface->getScaling(); - for (int j=2;j>=0;j--) - { - int graphicsindex = indicestype==PHY_SHORT?((unsigned short*)gfxbase)[j]:gfxbase[j]; - - if (type == PHY_FLOAT) - { - float* graphicsbase = (float*)(vertexbase+graphicsindex*stride); - - m_triangle[j] = btVector3(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ()); - } - else - { - double* graphicsbase = (double*)(vertexbase+graphicsindex*stride); - - m_triangle[j] = btVector3(btScalar(graphicsbase[0])*meshScaling.getX(),btScalar(graphicsbase[1])*meshScaling.getY(),btScalar(graphicsbase[2])*meshScaling.getZ()); - } - } - - /* Perform ray vs. triangle collision here */ - m_callback->processTriangle(m_triangle,nodeSubPart,nodeTriangleIndex); - m_meshInterface->unLockReadOnlyVertexBase(nodeSubPart); - } - }; - - MyNodeOverlapCallback myNodeCallback(callback,m_meshInterface); - - m_bvh->reportRayOverlappingNodex(&myNodeCallback,raySource,rayTarget); -} - -void btBvhTriangleMeshShape::performConvexcast (btTriangleCallback* callback, const btVector3& raySource, const btVector3& rayTarget, const btVector3& aabbMin, const btVector3& aabbMax) -{ - struct MyNodeOverlapCallback : public btNodeOverlapCallback - { - btStridingMeshInterface* m_meshInterface; - btTriangleCallback* m_callback; - - MyNodeOverlapCallback(btTriangleCallback* callback,btStridingMeshInterface* meshInterface) - :m_meshInterface(meshInterface), - m_callback(callback) - { - } - - virtual void processNode(int nodeSubPart, int nodeTriangleIndex) - { - btVector3 m_triangle[3]; - const unsigned char *vertexbase; - int numverts; - PHY_ScalarType type; - int stride; - const unsigned char *indexbase; - int indexstride; - int numfaces; - PHY_ScalarType indicestype; - - m_meshInterface->getLockedReadOnlyVertexIndexBase( - &vertexbase, - numverts, - type, - stride, - &indexbase, - indexstride, - numfaces, - indicestype, - nodeSubPart); - - unsigned int* gfxbase = (unsigned int*)(indexbase+nodeTriangleIndex*indexstride); - btAssert(indicestype==PHY_INTEGER||indicestype==PHY_SHORT); - - const btVector3& meshScaling = m_meshInterface->getScaling(); - for (int j=2;j>=0;j--) - { - int graphicsindex = indicestype==PHY_SHORT?((unsigned short*)gfxbase)[j]:gfxbase[j]; - - if (type == PHY_FLOAT) - { - float* graphicsbase = (float*)(vertexbase+graphicsindex*stride); - - m_triangle[j] = btVector3(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ()); - } - else - { - double* graphicsbase = (double*)(vertexbase+graphicsindex*stride); - - m_triangle[j] = btVector3(btScalar(graphicsbase[0])*meshScaling.getX(),btScalar(graphicsbase[1])*meshScaling.getY(),btScalar(graphicsbase[2])*meshScaling.getZ()); - } - } - - /* Perform ray vs. triangle collision here */ - m_callback->processTriangle(m_triangle,nodeSubPart,nodeTriangleIndex); - m_meshInterface->unLockReadOnlyVertexBase(nodeSubPart); - } - }; - - MyNodeOverlapCallback myNodeCallback(callback,m_meshInterface); - - m_bvh->reportBoxCastOverlappingNodex (&myNodeCallback, raySource, rayTarget, aabbMin, aabbMax); -} - -//perform bvh tree traversal and report overlapping triangles to 'callback' -void btBvhTriangleMeshShape::processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const -{ - -#ifdef DISABLE_BVH - //brute force traverse all triangles - btTriangleMeshShape::processAllTriangles(callback,aabbMin,aabbMax); -#else - - //first get all the nodes - - - struct MyNodeOverlapCallback : public btNodeOverlapCallback - { - btStridingMeshInterface* m_meshInterface; - btTriangleCallback* m_callback; - btVector3 m_triangle[3]; - - - MyNodeOverlapCallback(btTriangleCallback* callback,btStridingMeshInterface* meshInterface) - :m_meshInterface(meshInterface), - m_callback(callback) - { - } - - virtual void processNode(int nodeSubPart, int nodeTriangleIndex) - { - const unsigned char *vertexbase; - int numverts; - PHY_ScalarType type; - int stride; - const unsigned char *indexbase; - int indexstride; - int numfaces; - PHY_ScalarType indicestype; - - - m_meshInterface->getLockedReadOnlyVertexIndexBase( - &vertexbase, - numverts, - type, - stride, - &indexbase, - indexstride, - numfaces, - indicestype, - nodeSubPart); - - unsigned int* gfxbase = (unsigned int*)(indexbase+nodeTriangleIndex*indexstride); - btAssert(indicestype==PHY_INTEGER||indicestype==PHY_SHORT); - - const btVector3& meshScaling = m_meshInterface->getScaling(); - for (int j=2;j>=0;j--) - { - - int graphicsindex = indicestype==PHY_SHORT?((unsigned short*)gfxbase)[j]:gfxbase[j]; - - -#ifdef DEBUG_TRIANGLE_MESH - printf("%d ,",graphicsindex); -#endif //DEBUG_TRIANGLE_MESH - if (type == PHY_FLOAT) - { - float* graphicsbase = (float*)(vertexbase+graphicsindex*stride); - - m_triangle[j] = btVector3( - graphicsbase[0]*meshScaling.getX(), - graphicsbase[1]*meshScaling.getY(), - graphicsbase[2]*meshScaling.getZ()); - } - else - { - double* graphicsbase = (double*)(vertexbase+graphicsindex*stride); - - m_triangle[j] = btVector3( - btScalar(graphicsbase[0])*meshScaling.getX(), - btScalar(graphicsbase[1])*meshScaling.getY(), - btScalar(graphicsbase[2])*meshScaling.getZ()); - } -#ifdef DEBUG_TRIANGLE_MESH - printf("triangle vertices:%f,%f,%f\n",triangle[j].x(),triangle[j].y(),triangle[j].z()); -#endif //DEBUG_TRIANGLE_MESH - } - - m_callback->processTriangle(m_triangle,nodeSubPart,nodeTriangleIndex); - m_meshInterface->unLockReadOnlyVertexBase(nodeSubPart); - } - - }; - - MyNodeOverlapCallback myNodeCallback(callback,m_meshInterface); - - m_bvh->reportAabbOverlappingNodex(&myNodeCallback,aabbMin,aabbMax); - - -#endif//DISABLE_BVH - - -} - -void btBvhTriangleMeshShape::setLocalScaling(const btVector3& scaling) -{ - if ((getLocalScaling() -scaling).length2() > SIMD_EPSILON) - { - btTriangleMeshShape::setLocalScaling(scaling); - if (m_ownsBvh) - { - m_bvh->~btOptimizedBvh(); - btAlignedFree(m_bvh); - } - ///m_localAabbMin/m_localAabbMax is already re-calculated in btTriangleMeshShape. We could just scale aabb, but this needs some more work - void* mem = btAlignedAlloc(sizeof(btOptimizedBvh),16); - m_bvh = new(mem) btOptimizedBvh(); - //rebuild the bvh... - m_bvh->build(m_meshInterface,m_useQuantizedAabbCompression,m_localAabbMin,m_localAabbMax); - m_ownsBvh = true; - } -} - -void btBvhTriangleMeshShape::setOptimizedBvh(btOptimizedBvh* bvh, const btVector3& scaling) -{ - btAssert(!m_bvh); - btAssert(!m_ownsBvh); - - m_bvh = bvh; - m_ownsBvh = false; - // update the scaling without rebuilding the bvh - if ((getLocalScaling() -scaling).length2() > SIMD_EPSILON) - { - btTriangleMeshShape::setLocalScaling(scaling); - } -} - - diff --git a/bullet/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h b/bullet/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h deleted file mode 100644 index e7bce6b9b..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h +++ /dev/null @@ -1,86 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef BVH_TRIANGLE_MESH_SHAPE_H -#define BVH_TRIANGLE_MESH_SHAPE_H - -#include "btTriangleMeshShape.h" -#include "btOptimizedBvh.h" -#include "LinearMath/btAlignedAllocator.h" - - -///The btBvhTriangleMeshShape is a static-triangle mesh shape with several optimizations, such as bounding volume hierarchy and cache friendly traversal for PlayStation 3 Cell SPU. It is recommended to enable useQuantizedAabbCompression for better memory usage. -///It takes a triangle mesh as input, for example a btTriangleMesh or btTriangleIndexVertexArray. The btBvhTriangleMeshShape class allows for triangle mesh deformations by a refit or partialRefit method. -///Instead of building the bounding volume hierarchy acceleration structure, it is also possible to serialize (save) and deserialize (load) the structure from disk. -///See Demos\ConcaveDemo\ConcavePhysicsDemo.cpp for an example. -ATTRIBUTE_ALIGNED16(class) btBvhTriangleMeshShape : public btTriangleMeshShape -{ - - btOptimizedBvh* m_bvh; - bool m_useQuantizedAabbCompression; - bool m_ownsBvh; - bool m_pad[11];////need padding due to alignment - -public: - - BT_DECLARE_ALIGNED_ALLOCATOR(); - - btBvhTriangleMeshShape() : btTriangleMeshShape(0),m_bvh(0),m_ownsBvh(false) {m_shapeType = TRIANGLE_MESH_SHAPE_PROXYTYPE;}; - btBvhTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression, bool buildBvh = true); - - ///optionally pass in a larger bvh aabb, used for quantization. This allows for deformations within this aabb - btBvhTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression,const btVector3& bvhAabbMin,const btVector3& bvhAabbMax, bool buildBvh = true); - - virtual ~btBvhTriangleMeshShape(); - - bool getOwnsBvh () const - { - return m_ownsBvh; - } - - - - void performRaycast (btTriangleCallback* callback, const btVector3& raySource, const btVector3& rayTarget); - void performConvexcast (btTriangleCallback* callback, const btVector3& boxSource, const btVector3& boxTarget, const btVector3& boxMin, const btVector3& boxMax); - - virtual void processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const; - - void refitTree(const btVector3& aabbMin,const btVector3& aabbMax); - - ///for a fast incremental refit of parts of the tree. Note: the entire AABB of the tree will become more conservative, it never shrinks - void partialRefitTree(const btVector3& aabbMin,const btVector3& aabbMax); - - //debugging - virtual const char* getName()const {return "BVHTRIANGLEMESH";} - - - virtual void setLocalScaling(const btVector3& scaling); - - btOptimizedBvh* getOptimizedBvh() - { - return m_bvh; - } - - - void setOptimizedBvh(btOptimizedBvh* bvh, const btVector3& localScaling=btVector3(1,1,1)); - - bool usesQuantizedAabbCompression() const - { - return m_useQuantizedAabbCompression; - } -} -; - -#endif //BVH_TRIANGLE_MESH_SHAPE_H diff --git a/bullet/src/BulletCollision/CollisionShapes/btCapsuleShape.cpp b/bullet/src/BulletCollision/CollisionShapes/btCapsuleShape.cpp deleted file mode 100644 index 2a5a593e0..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btCapsuleShape.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#include "btCapsuleShape.h" - -#include "BulletCollision/CollisionShapes/btCollisionMargin.h" -#include "LinearMath/btQuaternion.h" - -btCapsuleShape::btCapsuleShape(btScalar radius, btScalar height) : btConvexInternalShape () -{ - m_shapeType = CAPSULE_SHAPE_PROXYTYPE; - m_upAxis = 1; - m_implicitShapeDimensions.setValue(radius,0.5f*height,radius); -} - - - btVector3 btCapsuleShape::localGetSupportingVertexWithoutMargin(const btVector3& vec0)const -{ - - btVector3 supVec(0,0,0); - - btScalar maxDot(btScalar(-BT_LARGE_FLOAT)); - - btVector3 vec = vec0; - btScalar lenSqr = vec.length2(); - if (lenSqr < btScalar(0.0001)) - { - vec.setValue(1,0,0); - } else - { - btScalar rlen = btScalar(1.) / btSqrt(lenSqr ); - vec *= rlen; - } - - btVector3 vtx; - btScalar newDot; - - btScalar radius = getRadius(); - - - { - btVector3 pos(0,0,0); - pos[getUpAxis()] = getHalfHeight(); - - vtx = pos +vec*m_localScaling*(radius) - vec * getMargin(); - newDot = vec.dot(vtx); - if (newDot > maxDot) - { - maxDot = newDot; - supVec = vtx; - } - } - { - btVector3 pos(0,0,0); - pos[getUpAxis()] = -getHalfHeight(); - - vtx = pos +vec*m_localScaling*(radius) - vec * getMargin(); - newDot = vec.dot(vtx); - if (newDot > maxDot) - { - maxDot = newDot; - supVec = vtx; - } - } - - return supVec; - -} - - void btCapsuleShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const -{ - - - btScalar radius = getRadius(); - - for (int j=0;j maxDot) - { - maxDot = newDot; - supportVerticesOut[j] = vtx; - } - } - { - btVector3 pos(0,0,0); - pos[getUpAxis()] = -getHalfHeight(); - vtx = pos +vec*m_localScaling*(radius) - vec * getMargin(); - newDot = vec.dot(vtx); - if (newDot > maxDot) - { - maxDot = newDot; - supportVerticesOut[j] = vtx; - } - } - - } -} - - -void btCapsuleShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const -{ - //as an approximation, take the inertia of the box that bounds the spheres - - btTransform ident; - ident.setIdentity(); - - - btScalar radius = getRadius(); - - btVector3 halfExtents(radius,radius,radius); - halfExtents[getUpAxis()]+=getHalfHeight(); - - btScalar margin = CONVEX_DISTANCE_MARGIN; - - btScalar lx=btScalar(2.)*(halfExtents[0]+margin); - btScalar ly=btScalar(2.)*(halfExtents[1]+margin); - btScalar lz=btScalar(2.)*(halfExtents[2]+margin); - const btScalar x2 = lx*lx; - const btScalar y2 = ly*ly; - const btScalar z2 = lz*lz; - const btScalar scaledmass = mass * btScalar(.08333333); - - inertia[0] = scaledmass * (y2+z2); - inertia[1] = scaledmass * (x2+z2); - inertia[2] = scaledmass * (x2+y2); - -} - -btCapsuleShapeX::btCapsuleShapeX(btScalar radius,btScalar height) -{ - m_upAxis = 0; - m_implicitShapeDimensions.setValue(0.5f*height, radius,radius); -} - - - - - - -btCapsuleShapeZ::btCapsuleShapeZ(btScalar radius,btScalar height) -{ - m_upAxis = 2; - m_implicitShapeDimensions.setValue(radius,radius,0.5f*height); -} - - - - diff --git a/bullet/src/BulletCollision/CollisionShapes/btCapsuleShape.h b/bullet/src/BulletCollision/CollisionShapes/btCapsuleShape.h deleted file mode 100644 index 5f2358e02..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btCapsuleShape.h +++ /dev/null @@ -1,129 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef BT_CAPSULE_SHAPE_H -#define BT_CAPSULE_SHAPE_H - -#include "btConvexInternalShape.h" -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types - - -///The btCapsuleShape represents a capsule around the Y axis, there is also the btCapsuleShapeX aligned around the X axis and btCapsuleShapeZ around the Z axis. -///The total height is height+2*radius, so the height is just the height between the center of each 'sphere' of the capsule caps. -///The btCapsuleShape is a convex hull of two spheres. The btMultiSphereShape is a more general collision shape that takes the convex hull of multiple sphere, so it can also represent a capsule when just using two spheres. -class btCapsuleShape : public btConvexInternalShape -{ -protected: - int m_upAxis; - -protected: - ///only used for btCapsuleShapeZ and btCapsuleShapeX subclasses. - btCapsuleShape() : btConvexInternalShape() {m_shapeType = CAPSULE_SHAPE_PROXYTYPE;}; - -public: - btCapsuleShape(btScalar radius,btScalar height); - - ///CollisionShape Interface - virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const; - - /// btConvexShape Interface - virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const; - - virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const; - - virtual void getAabb (const btTransform& t, btVector3& aabbMin, btVector3& aabbMax) const - { - btVector3 halfExtents(getRadius(),getRadius(),getRadius()); - halfExtents[m_upAxis] = getRadius() + getHalfHeight(); - halfExtents += btVector3(getMargin(),getMargin(),getMargin()); - btMatrix3x3 abs_b = t.getBasis().absolute(); - btVector3 center = t.getOrigin(); - btVector3 extent = btVector3(abs_b[0].dot(halfExtents),abs_b[1].dot(halfExtents),abs_b[2].dot(halfExtents)); - - aabbMin = center - extent; - aabbMax = center + extent; - } - - virtual const char* getName()const - { - return "CapsuleShape"; - } - - int getUpAxis() const - { - return m_upAxis; - } - - btScalar getRadius() const - { - int radiusAxis = (m_upAxis+2)%3; - return m_implicitShapeDimensions[radiusAxis]; - } - - btScalar getHalfHeight() const - { - return m_implicitShapeDimensions[m_upAxis]; - } - - virtual void setLocalScaling(const btVector3& scaling) - { - btVector3 oldMargin(getMargin(),getMargin(),getMargin()); - btVector3 implicitShapeDimensionsWithMargin = m_implicitShapeDimensions+oldMargin; - btVector3 unScaledImplicitShapeDimensionsWithMargin = implicitShapeDimensionsWithMargin / m_localScaling; - - btConvexInternalShape::setLocalScaling(scaling); - - m_implicitShapeDimensions = (unScaledImplicitShapeDimensionsWithMargin * m_localScaling) - oldMargin; - - } -}; - -///btCapsuleShapeX represents a capsule around the Z axis -///the total height is height+2*radius, so the height is just the height between the center of each 'sphere' of the capsule caps. -class btCapsuleShapeX : public btCapsuleShape -{ -public: - - btCapsuleShapeX(btScalar radius,btScalar height); - - //debugging - virtual const char* getName()const - { - return "CapsuleX"; - } - - - -}; - -///btCapsuleShapeZ represents a capsule around the Z axis -///the total height is height+2*radius, so the height is just the height between the center of each 'sphere' of the capsule caps. -class btCapsuleShapeZ : public btCapsuleShape -{ -public: - btCapsuleShapeZ(btScalar radius,btScalar height); - - //debugging - virtual const char* getName()const - { - return "CapsuleZ"; - } - - -}; - - - -#endif //BT_CAPSULE_SHAPE_H diff --git a/bullet/src/BulletCollision/CollisionShapes/btCollisionMargin.h b/bullet/src/BulletCollision/CollisionShapes/btCollisionMargin.h deleted file mode 100644 index a34e4aac1..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btCollisionMargin.h +++ /dev/null @@ -1,26 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef COLLISION_MARGIN_H -#define COLLISION_MARGIN_H - -//used by Gjk and some other algorithms - -#define CONVEX_DISTANCE_MARGIN btScalar(0.04)// btScalar(0.1)//;//btScalar(0.01) - - - -#endif //COLLISION_MARGIN_H - diff --git a/bullet/src/BulletCollision/CollisionShapes/btCollisionShape.cpp b/bullet/src/BulletCollision/CollisionShapes/btCollisionShape.cpp deleted file mode 100644 index da6baa2b6..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btCollisionShape.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ -#include "BulletCollision/CollisionShapes/btCollisionShape.h" - - -btScalar gContactThresholdFactor=btScalar(0.02); - - -/* - Make sure this dummy function never changes so that it - can be used by probes that are checking whether the - library is actually installed. -*/ -extern "C" -{ -void btBulletCollisionProbe (); - -void btBulletCollisionProbe () {} -} - - - -void btCollisionShape::getBoundingSphere(btVector3& center,btScalar& radius) const -{ - btTransform tr; - tr.setIdentity(); - btVector3 aabbMin,aabbMax; - - getAabb(tr,aabbMin,aabbMax); - - radius = (aabbMax-aabbMin).length()*btScalar(0.5); - center = (aabbMin+aabbMax)*btScalar(0.5); -} - - -btScalar btCollisionShape::getContactBreakingThreshold() const -{ - return getAngularMotionDisc() * gContactThresholdFactor; -} -btScalar btCollisionShape::getAngularMotionDisc() const -{ - ///@todo cache this value, to improve performance - btVector3 center; - btScalar disc; - getBoundingSphere(center,disc); - disc += (center).length(); - return disc; -} - -void btCollisionShape::calculateTemporalAabb(const btTransform& curTrans,const btVector3& linvel,const btVector3& angvel,btScalar timeStep, btVector3& temporalAabbMin,btVector3& temporalAabbMax) const -{ - //start with static aabb - getAabb(curTrans,temporalAabbMin,temporalAabbMax); - - btScalar temporalAabbMaxx = temporalAabbMax.getX(); - btScalar temporalAabbMaxy = temporalAabbMax.getY(); - btScalar temporalAabbMaxz = temporalAabbMax.getZ(); - btScalar temporalAabbMinx = temporalAabbMin.getX(); - btScalar temporalAabbMiny = temporalAabbMin.getY(); - btScalar temporalAabbMinz = temporalAabbMin.getZ(); - - // add linear motion - btVector3 linMotion = linvel*timeStep; - ///@todo: simd would have a vector max/min operation, instead of per-element access - if (linMotion.x() > btScalar(0.)) - temporalAabbMaxx += linMotion.x(); - else - temporalAabbMinx += linMotion.x(); - if (linMotion.y() > btScalar(0.)) - temporalAabbMaxy += linMotion.y(); - else - temporalAabbMiny += linMotion.y(); - if (linMotion.z() > btScalar(0.)) - temporalAabbMaxz += linMotion.z(); - else - temporalAabbMinz += linMotion.z(); - - //add conservative angular motion - btScalar angularMotion = angvel.length() * getAngularMotionDisc() * timeStep; - btVector3 angularMotion3d(angularMotion,angularMotion,angularMotion); - temporalAabbMin = btVector3(temporalAabbMinx,temporalAabbMiny,temporalAabbMinz); - temporalAabbMax = btVector3(temporalAabbMaxx,temporalAabbMaxy,temporalAabbMaxz); - - temporalAabbMin -= angularMotion3d; - temporalAabbMax += angularMotion3d; -} diff --git a/bullet/src/BulletCollision/CollisionShapes/btCollisionShape.h b/bullet/src/BulletCollision/CollisionShapes/btCollisionShape.h deleted file mode 100644 index af74002b5..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btCollisionShape.h +++ /dev/null @@ -1,128 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef COLLISION_SHAPE_H -#define COLLISION_SHAPE_H - -#include "LinearMath/btTransform.h" -#include "LinearMath/btVector3.h" -#include "LinearMath/btMatrix3x3.h" -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" //for the shape types - - - -///The btCollisionShape class provides an interface for collision shapes that can be shared among btCollisionObjects. -class btCollisionShape -{ -protected: - int m_shapeType; - void* m_userPointer; - -public: - - btCollisionShape() : m_shapeType (INVALID_SHAPE_PROXYTYPE), m_userPointer(0) - { - } - - virtual ~btCollisionShape() - { - } - - ///getAabb returns the axis aligned bounding box in the coordinate frame of the given transform t. - virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const =0; - - virtual void getBoundingSphere(btVector3& center,btScalar& radius) const; - - ///getAngularMotionDisc returns the maximus radius needed for Conservative Advancement to handle time-of-impact with rotations. - virtual btScalar getAngularMotionDisc() const; - - virtual btScalar getContactBreakingThreshold() const; - - - ///calculateTemporalAabb calculates the enclosing aabb for the moving object over interval [0..timeStep) - ///result is conservative - void calculateTemporalAabb(const btTransform& curTrans,const btVector3& linvel,const btVector3& angvel,btScalar timeStep, btVector3& temporalAabbMin,btVector3& temporalAabbMax) const; - - - - SIMD_FORCE_INLINE bool isPolyhedral() const - { - return btBroadphaseProxy::isPolyhedral(getShapeType()); - } - - SIMD_FORCE_INLINE bool isConvex2d() const - { - return btBroadphaseProxy::isConvex2d(getShapeType()); - } - - SIMD_FORCE_INLINE bool isConvex() const - { - return btBroadphaseProxy::isConvex(getShapeType()); - } - SIMD_FORCE_INLINE bool isConcave() const - { - return btBroadphaseProxy::isConcave(getShapeType()); - } - SIMD_FORCE_INLINE bool isCompound() const - { - return btBroadphaseProxy::isCompound(getShapeType()); - } - - ///isInfinite is used to catch simulation error (aabb check) - SIMD_FORCE_INLINE bool isInfinite() const - { - return btBroadphaseProxy::isInfinite(getShapeType()); - } - -#ifndef __SPU__ - virtual void setLocalScaling(const btVector3& scaling) =0; - virtual const btVector3& getLocalScaling() const =0; - virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const = 0; - - -//debugging support - virtual const char* getName()const =0 ; -#endif //__SPU__ - - - int getShapeType() const { return m_shapeType; } - virtual void setMargin(btScalar margin) = 0; - virtual btScalar getMargin() const = 0; - - - ///optional user data pointer - void setUserPointer(void* userPtr) - { - m_userPointer = userPtr; - } - - void* getUserPointer() const - { - return m_userPointer; - } - -}; - -///for serialization -struct btCollisionShapeData -{ - void *m_userPointer; - int m_shapeType; - char m_padding[4]; -}; - - -#endif //COLLISION_SHAPE_H - diff --git a/bullet/src/BulletCollision/CollisionShapes/btCompoundShape.cpp b/bullet/src/BulletCollision/CollisionShapes/btCompoundShape.cpp deleted file mode 100644 index 265d58e48..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btCompoundShape.cpp +++ /dev/null @@ -1,266 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btCompoundShape.h" -#include "btCollisionShape.h" -#include "BulletCollision/BroadphaseCollision/btDbvt.h" - -btCompoundShape::btCompoundShape(bool enableDynamicAabbTree) -: m_localAabbMin(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT)), -m_localAabbMax(btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT)), -m_dynamicAabbTree(0), -m_updateRevision(1), -m_collisionMargin(btScalar(0.)), -m_localScaling(btScalar(1.),btScalar(1.),btScalar(1.)) -{ - m_shapeType = COMPOUND_SHAPE_PROXYTYPE; - - if (enableDynamicAabbTree) - { - void* mem = btAlignedAlloc(sizeof(btDbvt),16); - m_dynamicAabbTree = new(mem) btDbvt(); - btAssert(mem==m_dynamicAabbTree); - } -} - - -btCompoundShape::~btCompoundShape() -{ - if (m_dynamicAabbTree) - { - m_dynamicAabbTree->~btDbvt(); - btAlignedFree(m_dynamicAabbTree); - } -} - -void btCompoundShape::addChildShape(const btTransform& localTransform,btCollisionShape* shape) -{ - m_updateRevision++; - //m_childTransforms.push_back(localTransform); - //m_childShapes.push_back(shape); - btCompoundShapeChild child; - child.m_transform = localTransform; - child.m_childShape = shape; - child.m_childShapeType = shape->getShapeType(); - child.m_childMargin = shape->getMargin(); - - - //extend the local aabbMin/aabbMax - btVector3 localAabbMin,localAabbMax; - shape->getAabb(localTransform,localAabbMin,localAabbMax); - for (int i=0;i<3;i++) - { - if (m_localAabbMin[i] > localAabbMin[i]) - { - m_localAabbMin[i] = localAabbMin[i]; - } - if (m_localAabbMax[i] < localAabbMax[i]) - { - m_localAabbMax[i] = localAabbMax[i]; - } - - } - if (m_dynamicAabbTree) - { - const btDbvtVolume bounds=btDbvtVolume::FromMM(localAabbMin,localAabbMax); - int index = m_children.size(); - child.m_node = m_dynamicAabbTree->insert(bounds,(void*)index); - } - - m_children.push_back(child); - -} - -void btCompoundShape::updateChildTransform(int childIndex, const btTransform& newChildTransform) -{ - m_children[childIndex].m_transform = newChildTransform; - - if (m_dynamicAabbTree) - { - ///update the dynamic aabb tree - btVector3 localAabbMin,localAabbMax; - m_children[childIndex].m_childShape->getAabb(newChildTransform,localAabbMin,localAabbMax); - ATTRIBUTE_ALIGNED16(btDbvtVolume) bounds=btDbvtVolume::FromMM(localAabbMin,localAabbMax); - //int index = m_children.size()-1; - m_dynamicAabbTree->update(m_children[childIndex].m_node,bounds); - } - - recalculateLocalAabb(); -} - -void btCompoundShape::removeChildShapeByIndex(int childShapeIndex) -{ - m_updateRevision++; - btAssert(childShapeIndex >=0 && childShapeIndex < m_children.size()); - if (m_dynamicAabbTree) - { - m_dynamicAabbTree->remove(m_children[childShapeIndex].m_node); - } - m_children.swap(childShapeIndex,m_children.size()-1); - m_children.pop_back(); - -} - - - -void btCompoundShape::removeChildShape(btCollisionShape* shape) -{ - m_updateRevision++; - // Find the children containing the shape specified, and remove those children. - //note: there might be multiple children using the same shape! - for(int i = m_children.size()-1; i >= 0 ; i--) - { - if(m_children[i].m_childShape == shape) - { - removeChildShapeByIndex(i); - } - } - - - - recalculateLocalAabb(); -} - -void btCompoundShape::recalculateLocalAabb() -{ - // Recalculate the local aabb - // Brute force, it iterates over all the shapes left. - - m_localAabbMin = btVector3(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT)); - m_localAabbMax = btVector3(btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT)); - - //extend the local aabbMin/aabbMax - for (int j = 0; j < m_children.size(); j++) - { - btVector3 localAabbMin,localAabbMax; - m_children[j].m_childShape->getAabb(m_children[j].m_transform, localAabbMin, localAabbMax); - for (int i=0;i<3;i++) - { - if (m_localAabbMin[i] > localAabbMin[i]) - m_localAabbMin[i] = localAabbMin[i]; - if (m_localAabbMax[i] < localAabbMax[i]) - m_localAabbMax[i] = localAabbMax[i]; - } - } -} - -///getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version -void btCompoundShape::getAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax) const -{ - btVector3 localHalfExtents = btScalar(0.5)*(m_localAabbMax-m_localAabbMin); - btVector3 localCenter = btScalar(0.5)*(m_localAabbMax+m_localAabbMin); - - //avoid an illegal AABB when there are no children - if (!m_children.size()) - { - localHalfExtents.setValue(0,0,0); - localCenter.setValue(0,0,0); - } - localHalfExtents += btVector3(getMargin(),getMargin(),getMargin()); - - - btMatrix3x3 abs_b = trans.getBasis().absolute(); - - btVector3 center = trans(localCenter); - - btVector3 extent = btVector3(abs_b[0].dot(localHalfExtents), - abs_b[1].dot(localHalfExtents), - abs_b[2].dot(localHalfExtents)); - aabbMin = center-extent; - aabbMax = center+extent; - -} - -void btCompoundShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const -{ - //approximation: take the inertia from the aabb for now - btTransform ident; - ident.setIdentity(); - btVector3 aabbMin,aabbMax; - getAabb(ident,aabbMin,aabbMax); - - btVector3 halfExtents = (aabbMax-aabbMin)*btScalar(0.5); - - btScalar lx=btScalar(2.)*(halfExtents.x()); - btScalar ly=btScalar(2.)*(halfExtents.y()); - btScalar lz=btScalar(2.)*(halfExtents.z()); - - inertia[0] = mass/(btScalar(12.0)) * (ly*ly + lz*lz); - inertia[1] = mass/(btScalar(12.0)) * (lx*lx + lz*lz); - inertia[2] = mass/(btScalar(12.0)) * (lx*lx + ly*ly); - -} - - - - -void btCompoundShape::calculatePrincipalAxisTransform(btScalar* masses, btTransform& principal, btVector3& inertia) const -{ - int n = m_children.size(); - - btScalar totalMass = 0; - btVector3 center(0, 0, 0); - int k; - - for (k = 0; k < n; k++) - { - center += m_children[k].m_transform.getOrigin() * masses[k]; - totalMass += masses[k]; - } - center /= totalMass; - principal.setOrigin(center); - - btMatrix3x3 tensor(0, 0, 0, 0, 0, 0, 0, 0, 0); - for ( k = 0; k < n; k++) - { - btVector3 i; - m_children[k].m_childShape->calculateLocalInertia(masses[k], i); - - const btTransform& t = m_children[k].m_transform; - btVector3 o = t.getOrigin() - center; - - //compute inertia tensor in coordinate system of compound shape - btMatrix3x3 j = t.getBasis().transpose(); - j[0] *= i[0]; - j[1] *= i[1]; - j[2] *= i[2]; - j = t.getBasis() * j; - - //add inertia tensor - tensor[0] += j[0]; - tensor[1] += j[1]; - tensor[2] += j[2]; - - //compute inertia tensor of pointmass at o - btScalar o2 = o.length2(); - j[0].setValue(o2, 0, 0); - j[1].setValue(0, o2, 0); - j[2].setValue(0, 0, o2); - j[0] += o * -o.x(); - j[1] += o * -o.y(); - j[2] += o * -o.z(); - - //add inertia tensor of pointmass - tensor[0] += masses[k] * j[0]; - tensor[1] += masses[k] * j[1]; - tensor[2] += masses[k] * j[2]; - } - - tensor.diagonalize(principal.getBasis(), btScalar(0.00001), 20); - inertia.setValue(tensor[0][0], tensor[1][1], tensor[2][2]); -} - - - diff --git a/bullet/src/BulletCollision/CollisionShapes/btCompoundShape.h b/bullet/src/BulletCollision/CollisionShapes/btCompoundShape.h deleted file mode 100644 index f1bca6fd4..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btCompoundShape.h +++ /dev/null @@ -1,172 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef COMPOUND_SHAPE_H -#define COMPOUND_SHAPE_H - -#include "btCollisionShape.h" - -#include "LinearMath/btVector3.h" -#include "LinearMath/btTransform.h" -#include "LinearMath/btMatrix3x3.h" -#include "btCollisionMargin.h" -#include "LinearMath/btAlignedObjectArray.h" - -//class btOptimizedBvh; -struct btDbvt; - -ATTRIBUTE_ALIGNED16(struct) btCompoundShapeChild -{ - BT_DECLARE_ALIGNED_ALLOCATOR(); - - btTransform m_transform; - btCollisionShape* m_childShape; - int m_childShapeType; - btScalar m_childMargin; - struct btDbvtNode* m_node; -}; - -SIMD_FORCE_INLINE bool operator==(const btCompoundShapeChild& c1, const btCompoundShapeChild& c2) -{ - return ( c1.m_transform == c2.m_transform && - c1.m_childShape == c2.m_childShape && - c1.m_childShapeType == c2.m_childShapeType && - c1.m_childMargin == c2.m_childMargin ); -} - -/// The btCompoundShape allows to store multiple other btCollisionShapes -/// This allows for moving concave collision objects. This is more general then the static concave btBvhTriangleMeshShape. -/// It has an (optional) dynamic aabb tree to accelerate early rejection tests. -/// @todo: This aabb tree can also be use to speed up ray tests on btCompoundShape, see http://code.google.com/p/bullet/issues/detail?id=25 -/// Currently, removal of child shapes is only supported when disabling the aabb tree (pass 'false' in the constructor of btCompoundShape) -ATTRIBUTE_ALIGNED16(class) btCompoundShape : public btCollisionShape -{ - btAlignedObjectArray m_children; - btVector3 m_localAabbMin; - btVector3 m_localAabbMax; - - btDbvt* m_dynamicAabbTree; - - ///increment m_updateRevision when adding/removing/replacing child shapes, so that some caches can be updated - int m_updateRevision; - -public: - BT_DECLARE_ALIGNED_ALLOCATOR(); - - btCompoundShape(bool enableDynamicAabbTree = true); - - virtual ~btCompoundShape(); - - void addChildShape(const btTransform& localTransform,btCollisionShape* shape); - - /// Remove all children shapes that contain the specified shape - virtual void removeChildShape(btCollisionShape* shape); - - void removeChildShapeByIndex(int childShapeindex); - - - int getNumChildShapes() const - { - return int (m_children.size()); - } - - btCollisionShape* getChildShape(int index) - { - return m_children[index].m_childShape; - } - const btCollisionShape* getChildShape(int index) const - { - return m_children[index].m_childShape; - } - - btTransform& getChildTransform(int index) - { - return m_children[index].m_transform; - } - const btTransform& getChildTransform(int index) const - { - return m_children[index].m_transform; - } - - ///set a new transform for a child, and update internal data structures (local aabb and dynamic tree) - void updateChildTransform(int childIndex, const btTransform& newChildTransform); - - - btCompoundShapeChild* getChildList() - { - return &m_children[0]; - } - - ///getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version - virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const; - - /** Re-calculate the local Aabb. Is called at the end of removeChildShapes. - Use this yourself if you modify the children or their transforms. */ - virtual void recalculateLocalAabb(); - - virtual void setLocalScaling(const btVector3& scaling) - { - m_localScaling = scaling; - } - virtual const btVector3& getLocalScaling() const - { - return m_localScaling; - } - - virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const; - - virtual void setMargin(btScalar margin) - { - m_collisionMargin = margin; - } - virtual btScalar getMargin() const - { - return m_collisionMargin; - } - virtual const char* getName()const - { - return "Compound"; - } - - //this is optional, but should make collision queries faster, by culling non-overlapping nodes - void createAabbTreeFromChildren(); - - btDbvt* getDynamicAabbTree() - { - return m_dynamicAabbTree; - } - - ///computes the exact moment of inertia and the transform from the coordinate system defined by the principal axes of the moment of inertia - ///and the center of mass to the current coordinate system. "masses" points to an array of masses of the children. The resulting transform - ///"principal" has to be applied inversely to all children transforms in order for the local coordinate system of the compound - ///shape to be centered at the center of mass and to coincide with the principal axes. This also necessitates a correction of the world transform - ///of the collision object by the principal transform. - void calculatePrincipalAxisTransform(btScalar* masses, btTransform& principal, btVector3& inertia) const; - - int getUpdateRevision() const - { - return m_updateRevision; - } - -private: - btScalar m_collisionMargin; -protected: - btVector3 m_localScaling; - -}; - - - -#endif //COMPOUND_SHAPE_H diff --git a/bullet/src/BulletCollision/CollisionShapes/btConcaveShape.cpp b/bullet/src/BulletCollision/CollisionShapes/btConcaveShape.cpp deleted file mode 100644 index d6c24942d..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btConcaveShape.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#include "btConcaveShape.h" - -btConcaveShape::btConcaveShape() : m_collisionMargin(btScalar(0.)) -{ - -} - -btConcaveShape::~btConcaveShape() -{ - -} diff --git a/bullet/src/BulletCollision/CollisionShapes/btConcaveShape.h b/bullet/src/BulletCollision/CollisionShapes/btConcaveShape.h deleted file mode 100644 index 4953664ba..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btConcaveShape.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef CONCAVE_SHAPE_H -#define CONCAVE_SHAPE_H - -#include "btCollisionShape.h" -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types -#include "btTriangleCallback.h" - -/// PHY_ScalarType enumerates possible scalar types. -/// See the btStridingMeshInterface or btHeightfieldTerrainShape for its use -typedef enum PHY_ScalarType { - PHY_FLOAT, - PHY_DOUBLE, - PHY_INTEGER, - PHY_SHORT, - PHY_FIXEDPOINT88, - PHY_UCHAR -} PHY_ScalarType; - -///The btConcaveShape class provides an interface for non-moving (static) concave shapes. -///It has been implemented by the btStaticPlaneShape, btBvhTriangleMeshShape and btHeightfieldTerrainShape. -class btConcaveShape : public btCollisionShape -{ -protected: - btScalar m_collisionMargin; - -public: - btConcaveShape(); - - virtual ~btConcaveShape(); - - virtual void processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const = 0; - - virtual btScalar getMargin() const { - return m_collisionMargin; - } - virtual void setMargin(btScalar collisionMargin) - { - m_collisionMargin = collisionMargin; - } - - - -}; - -#endif //CONCAVE_SHAPE_H diff --git a/bullet/src/BulletCollision/CollisionShapes/btConeShape.cpp b/bullet/src/BulletCollision/CollisionShapes/btConeShape.cpp deleted file mode 100644 index d0fe01cf4..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btConeShape.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btConeShape.h" - - - -btConeShape::btConeShape (btScalar radius,btScalar height): btConvexInternalShape (), -m_radius (radius), -m_height(height) -{ - m_shapeType = CONE_SHAPE_PROXYTYPE; - setConeUpIndex(1); - btVector3 halfExtents; - m_sinAngle = (m_radius / btSqrt(m_radius * m_radius + m_height * m_height)); -} - -btConeShapeZ::btConeShapeZ (btScalar radius,btScalar height): -btConeShape(radius,height) -{ - setConeUpIndex(2); -} - -btConeShapeX::btConeShapeX (btScalar radius,btScalar height): -btConeShape(radius,height) -{ - setConeUpIndex(0); -} - -///choose upAxis index -void btConeShape::setConeUpIndex(int upIndex) -{ - switch (upIndex) - { - case 0: - m_coneIndices[0] = 1; - m_coneIndices[1] = 0; - m_coneIndices[2] = 2; - break; - case 1: - m_coneIndices[0] = 0; - m_coneIndices[1] = 1; - m_coneIndices[2] = 2; - break; - case 2: - m_coneIndices[0] = 0; - m_coneIndices[1] = 2; - m_coneIndices[2] = 1; - break; - default: - btAssert(0); - }; -} - -btVector3 btConeShape::coneLocalSupport(const btVector3& v) const -{ - - btScalar halfHeight = m_height * btScalar(0.5); - - if (v[m_coneIndices[1]] > v.length() * m_sinAngle) - { - btVector3 tmp; - - tmp[m_coneIndices[0]] = btScalar(0.); - tmp[m_coneIndices[1]] = halfHeight; - tmp[m_coneIndices[2]] = btScalar(0.); - return tmp; - } - else { - btScalar s = btSqrt(v[m_coneIndices[0]] * v[m_coneIndices[0]] + v[m_coneIndices[2]] * v[m_coneIndices[2]]); - if (s > SIMD_EPSILON) { - btScalar d = m_radius / s; - btVector3 tmp; - tmp[m_coneIndices[0]] = v[m_coneIndices[0]] * d; - tmp[m_coneIndices[1]] = -halfHeight; - tmp[m_coneIndices[2]] = v[m_coneIndices[2]] * d; - return tmp; - } - else { - btVector3 tmp; - tmp[m_coneIndices[0]] = btScalar(0.); - tmp[m_coneIndices[1]] = -halfHeight; - tmp[m_coneIndices[2]] = btScalar(0.); - return tmp; - } - } - -} - -btVector3 btConeShape::localGetSupportingVertexWithoutMargin(const btVector3& vec) const -{ - return coneLocalSupport(vec); -} - -void btConeShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const -{ - for (int i=0;ilocalGetSupportingVertexWithoutMargin(vec); -} - -void btConvex2dShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const -{ - m_childConvexShape->batchedUnitVectorGetSupportingVertexWithoutMargin(vectors,supportVerticesOut,numVectors); -} - - -btVector3 btConvex2dShape::localGetSupportingVertex(const btVector3& vec)const -{ - return m_childConvexShape->localGetSupportingVertex(vec); -} - - -void btConvex2dShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const -{ - ///this linear upscaling is not realistic, but we don't deal with large mass ratios... - m_childConvexShape->calculateLocalInertia(mass,inertia); -} - - - ///getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version -void btConvex2dShape::getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const -{ - m_childConvexShape->getAabb(t,aabbMin,aabbMax); -} - -void btConvex2dShape::getAabbSlow(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const -{ - m_childConvexShape->getAabbSlow(t,aabbMin,aabbMax); -} - -void btConvex2dShape::setLocalScaling(const btVector3& scaling) -{ - m_childConvexShape->setLocalScaling(scaling); -} - -const btVector3& btConvex2dShape::getLocalScaling() const -{ - return m_childConvexShape->getLocalScaling(); -} - -void btConvex2dShape::setMargin(btScalar margin) -{ - m_childConvexShape->setMargin(margin); -} -btScalar btConvex2dShape::getMargin() const -{ - return m_childConvexShape->getMargin(); -} - -int btConvex2dShape::getNumPreferredPenetrationDirections() const -{ - return m_childConvexShape->getNumPreferredPenetrationDirections(); -} - -void btConvex2dShape::getPreferredPenetrationDirection(int index, btVector3& penetrationVector) const -{ - m_childConvexShape->getPreferredPenetrationDirection(index,penetrationVector); -} diff --git a/bullet/src/BulletCollision/CollisionShapes/btConvex2dShape.h b/bullet/src/BulletCollision/CollisionShapes/btConvex2dShape.h deleted file mode 100644 index eb8fa8c46..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btConvex2dShape.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef BT_CONVEX_2D_SHAPE_H -#define BT_CONVEX_2D_SHAPE_H - -#include "BulletCollision/CollisionShapes/btConvexShape.h" -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types - -///The btConvex2dShape allows to use arbitrary convex shapes are 2d convex shapes, with the Z component assumed to be 0. -///For 2d boxes, the btBox2dShape is recommended. -class btConvex2dShape : public btConvexShape -{ - btConvexShape* m_childConvexShape; - - public: - - btConvex2dShape( btConvexShape* convexChildShape); - - virtual ~btConvex2dShape(); - - virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const; - - virtual btVector3 localGetSupportingVertex(const btVector3& vec)const; - - virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const; - - virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const; - - btConvexShape* getChildShape() - { - return m_childConvexShape; - } - - const btConvexShape* getChildShape() const - { - return m_childConvexShape; - } - - virtual const char* getName()const - { - return "Convex2dShape"; - } - - - - /////////////////////////// - - - ///getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version - void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const; - - virtual void getAabbSlow(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const; - - virtual void setLocalScaling(const btVector3& scaling) ; - virtual const btVector3& getLocalScaling() const ; - - virtual void setMargin(btScalar margin); - virtual btScalar getMargin() const; - - virtual int getNumPreferredPenetrationDirections() const; - - virtual void getPreferredPenetrationDirection(int index, btVector3& penetrationVector) const; - - -}; - -#endif //BT_CONVEX_2D_SHAPE_H diff --git a/bullet/src/BulletCollision/CollisionShapes/btConvexHullShape.cpp b/bullet/src/BulletCollision/CollisionShapes/btConvexHullShape.cpp deleted file mode 100644 index fea2d31ec..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btConvexHullShape.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btConvexHullShape.h" -#include "BulletCollision/CollisionShapes/btCollisionMargin.h" - -#include "LinearMath/btQuaternion.h" - - -btConvexHullShape ::btConvexHullShape (const btScalar* points,int numPoints,int stride) : btPolyhedralConvexAabbCachingShape () -{ - m_shapeType = CONVEX_HULL_SHAPE_PROXYTYPE; - m_unscaledPoints.resize(numPoints); - - unsigned char* pointsAddress = (unsigned char*)points; - - for (int i=0;i maxDot) - { - maxDot = newDot; - supVec = vtx; - } - } - return supVec; -} - -void btConvexHullShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const -{ - btScalar newDot; - //use 'w' component of supportVerticesOut? - { - for (int i=0;i supportVerticesOut[j][3]) - { - //WARNING: don't swap next lines, the w component would get overwritten! - supportVerticesOut[j] = vtx; - supportVerticesOut[j][3] = newDot; - } - } - } - - - -} - - - -btVector3 btConvexHullShape::localGetSupportingVertex(const btVector3& vec)const -{ - btVector3 supVertex = localGetSupportingVertexWithoutMargin(vec); - - if ( getMargin()!=btScalar(0.) ) - { - btVector3 vecnorm = vec; - if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON)) - { - vecnorm.setValue(btScalar(-1.),btScalar(-1.),btScalar(-1.)); - } - vecnorm.normalize(); - supVertex+= getMargin() * vecnorm; - } - return supVertex; -} - - - - - - - - - -//currently just for debugging (drawing), perhaps future support for algebraic continuous collision detection -//Please note that you can debug-draw btConvexHullShape with the Raytracer Demo -int btConvexHullShape::getNumVertices() const -{ - return m_unscaledPoints.size(); -} - -int btConvexHullShape::getNumEdges() const -{ - return m_unscaledPoints.size(); -} - -void btConvexHullShape::getEdge(int i,btVector3& pa,btVector3& pb) const -{ - - int index0 = i%m_unscaledPoints.size(); - int index1 = (i+1)%m_unscaledPoints.size(); - pa = getScaledPoint(index0); - pb = getScaledPoint(index1); -} - -void btConvexHullShape::getVertex(int i,btVector3& vtx) const -{ - vtx = getScaledPoint(i); -} - -int btConvexHullShape::getNumPlanes() const -{ - return 0; -} - -void btConvexHullShape::getPlane(btVector3& ,btVector3& ,int ) const -{ - - btAssert(0); -} - -//not yet -bool btConvexHullShape::isInside(const btVector3& ,btScalar ) const -{ - btAssert(0); - return false; -} - diff --git a/bullet/src/BulletCollision/CollisionShapes/btConvexHullShape.h b/bullet/src/BulletCollision/CollisionShapes/btConvexHullShape.h deleted file mode 100644 index 89f56375d..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btConvexHullShape.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef CONVEX_HULL_SHAPE_H -#define CONVEX_HULL_SHAPE_H - -#include "btPolyhedralConvexShape.h" -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types -#include "LinearMath/btAlignedObjectArray.h" - - -///The btConvexHullShape implements an implicit convex hull of an array of vertices. -///Bullet provides a general and fast collision detector for convex shapes based on GJK and EPA using localGetSupportingVertex. -ATTRIBUTE_ALIGNED16(class) btConvexHullShape : public btPolyhedralConvexAabbCachingShape -{ - btAlignedObjectArray m_unscaledPoints; - -public: - BT_DECLARE_ALIGNED_ALLOCATOR(); - - - ///this constructor optionally takes in a pointer to points. Each point is assumed to be 3 consecutive btScalar (x,y,z), the striding defines the number of bytes between each point, in memory. - ///It is easier to not pass any points in the constructor, and just add one point at a time, using addPoint. - ///btConvexHullShape make an internal copy of the points. - btConvexHullShape(const btScalar* points=0,int numPoints=0, int stride=sizeof(btVector3)); - - void addPoint(const btVector3& point); - - - btVector3* getUnscaledPoints() - { - return &m_unscaledPoints[0]; - } - - const btVector3* getUnscaledPoints() const - { - return &m_unscaledPoints[0]; - } - - ///getPoints is obsolete, please use getUnscaledPoints - const btVector3* getPoints() const - { - return getUnscaledPoints(); - } - - - - - SIMD_FORCE_INLINE btVector3 getScaledPoint(int i) const - { - return m_unscaledPoints[i] * m_localScaling; - } - - SIMD_FORCE_INLINE int getNumPoints() const - { - return m_unscaledPoints.size(); - } - - virtual btVector3 localGetSupportingVertex(const btVector3& vec)const; - virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const; - virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const; - - - - //debugging - virtual const char* getName()const {return "Convex";} - - - virtual int getNumVertices() const; - virtual int getNumEdges() const; - virtual void getEdge(int i,btVector3& pa,btVector3& pb) const; - virtual void getVertex(int i,btVector3& vtx) const; - virtual int getNumPlanes() const; - virtual void getPlane(btVector3& planeNormal,btVector3& planeSupport,int i ) const; - virtual bool isInside(const btVector3& pt,btScalar tolerance) const; - - ///in case we receive negative scaling - virtual void setLocalScaling(const btVector3& scaling); - -}; - - -#endif //CONVEX_HULL_SHAPE_H - diff --git a/bullet/src/BulletCollision/CollisionShapes/btConvexInternalShape.cpp b/bullet/src/BulletCollision/CollisionShapes/btConvexInternalShape.cpp deleted file mode 100644 index 51def69d8..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btConvexInternalShape.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#include "btConvexInternalShape.h" - - - -btConvexInternalShape::btConvexInternalShape() -: m_localScaling(btScalar(1.),btScalar(1.),btScalar(1.)), -m_collisionMargin(CONVEX_DISTANCE_MARGIN) -{ -} - - -void btConvexInternalShape::setLocalScaling(const btVector3& scaling) -{ - m_localScaling = scaling.absolute(); -} - - - -void btConvexInternalShape::getAabbSlow(const btTransform& trans,btVector3&minAabb,btVector3&maxAabb) const -{ -#ifndef __SPU__ - //use localGetSupportingVertexWithoutMargin? - btScalar margin = getMargin(); - for (int i=0;i<3;i++) - { - btVector3 vec(btScalar(0.),btScalar(0.),btScalar(0.)); - vec[i] = btScalar(1.); - - btVector3 sv = localGetSupportingVertex(vec*trans.getBasis()); - - btVector3 tmp = trans(sv); - maxAabb[i] = tmp[i]+margin; - vec[i] = btScalar(-1.); - tmp = trans(localGetSupportingVertex(vec*trans.getBasis())); - minAabb[i] = tmp[i]-margin; - } -#endif -} - - - -btVector3 btConvexInternalShape::localGetSupportingVertex(const btVector3& vec)const -{ -#ifndef __SPU__ - - btVector3 supVertex = localGetSupportingVertexWithoutMargin(vec); - - if ( getMargin()!=btScalar(0.) ) - { - btVector3 vecnorm = vec; - if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON)) - { - vecnorm.setValue(btScalar(-1.),btScalar(-1.),btScalar(-1.)); - } - vecnorm.normalize(); - supVertex+= getMargin() * vecnorm; - } - return supVertex; - -#else - btAssert(0); - return btVector3(0,0,0); -#endif //__SPU__ - - } - - -btConvexInternalAabbCachingShape::btConvexInternalAabbCachingShape() - : btConvexInternalShape(), -m_localAabbMin(1,1,1), -m_localAabbMax(-1,-1,-1), -m_isLocalAabbValid(false) -{ -} - - -void btConvexInternalAabbCachingShape::getAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax) const -{ - getNonvirtualAabb(trans,aabbMin,aabbMax,getMargin()); -} - -void btConvexInternalAabbCachingShape::setLocalScaling(const btVector3& scaling) -{ - btConvexInternalShape::setLocalScaling(scaling); - recalcLocalAabb(); -} - - -void btConvexInternalAabbCachingShape::recalcLocalAabb() -{ - m_isLocalAabbValid = true; - - #if 1 - static const btVector3 _directions[] = - { - btVector3( 1., 0., 0.), - btVector3( 0., 1., 0.), - btVector3( 0., 0., 1.), - btVector3( -1., 0., 0.), - btVector3( 0., -1., 0.), - btVector3( 0., 0., -1.) - }; - - btVector3 _supporting[] = - { - btVector3( 0., 0., 0.), - btVector3( 0., 0., 0.), - btVector3( 0., 0., 0.), - btVector3( 0., 0., 0.), - btVector3( 0., 0., 0.), - btVector3( 0., 0., 0.) - }; - - batchedUnitVectorGetSupportingVertexWithoutMargin(_directions, _supporting, 6); - - for ( int i = 0; i < 3; ++i ) - { - m_localAabbMax[i] = _supporting[i][i] + m_collisionMargin; - m_localAabbMin[i] = _supporting[i + 3][i] - m_collisionMargin; - } - - #else - - for (int i=0;i<3;i++) - { - btVector3 vec(btScalar(0.),btScalar(0.),btScalar(0.)); - vec[i] = btScalar(1.); - btVector3 tmp = localGetSupportingVertex(vec); - m_localAabbMax[i] = tmp[i]+m_collisionMargin; - vec[i] = btScalar(-1.); - tmp = localGetSupportingVertex(vec); - m_localAabbMin[i] = tmp[i]-m_collisionMargin; - } - #endif -} diff --git a/bullet/src/BulletCollision/CollisionShapes/btConvexInternalShape.h b/bullet/src/BulletCollision/CollisionShapes/btConvexInternalShape.h deleted file mode 100644 index 74f754772..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btConvexInternalShape.h +++ /dev/null @@ -1,151 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef BT_CONVEX_INTERNAL_SHAPE_H -#define BT_CONVEX_INTERNAL_SHAPE_H - -#include "btConvexShape.h" -#include "LinearMath/btAabbUtil2.h" - -///The btConvexInternalShape is an internal base class, shared by most convex shape implementations. -class btConvexInternalShape : public btConvexShape -{ - - protected: - - //local scaling. collisionMargin is not scaled ! - btVector3 m_localScaling; - - btVector3 m_implicitShapeDimensions; - - btScalar m_collisionMargin; - - btScalar m_padding; - - btConvexInternalShape(); - -public: - - - - virtual ~btConvexInternalShape() - { - - } - - virtual btVector3 localGetSupportingVertex(const btVector3& vec)const; - - const btVector3& getImplicitShapeDimensions() const - { - return m_implicitShapeDimensions; - } - - ///getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version - void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const - { - getAabbSlow(t,aabbMin,aabbMax); - } - - - - virtual void getAabbSlow(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const; - - - virtual void setLocalScaling(const btVector3& scaling); - virtual const btVector3& getLocalScaling() const - { - return m_localScaling; - } - - const btVector3& getLocalScalingNV() const - { - return m_localScaling; - } - - virtual void setMargin(btScalar margin) - { - m_collisionMargin = margin; - } - virtual btScalar getMargin() const - { - return m_collisionMargin; - } - - btScalar getMarginNV() const - { - return m_collisionMargin; - } - - virtual int getNumPreferredPenetrationDirections() const - { - return 0; - } - - virtual void getPreferredPenetrationDirection(int index, btVector3& penetrationVector) const - { - (void)penetrationVector; - (void)index; - btAssert(0); - } - - - -}; - - -///btConvexInternalAabbCachingShape adds local aabb caching for convex shapes, to avoid expensive bounding box calculations -class btConvexInternalAabbCachingShape : public btConvexInternalShape -{ - btVector3 m_localAabbMin; - btVector3 m_localAabbMax; - bool m_isLocalAabbValid; - -protected: - - btConvexInternalAabbCachingShape(); - - void setCachedLocalAabb (const btVector3& aabbMin, const btVector3& aabbMax) - { - m_isLocalAabbValid = true; - m_localAabbMin = aabbMin; - m_localAabbMax = aabbMax; - } - - inline void getCachedLocalAabb (btVector3& aabbMin, btVector3& aabbMax) const - { - btAssert(m_isLocalAabbValid); - aabbMin = m_localAabbMin; - aabbMax = m_localAabbMax; - } - - inline void getNonvirtualAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax, btScalar margin) const - { - - //lazy evaluation of local aabb - btAssert(m_isLocalAabbValid); - btTransformAabb(m_localAabbMin,m_localAabbMax,margin,trans,aabbMin,aabbMax); - } - -public: - - virtual void setLocalScaling(const btVector3& scaling); - - virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const; - - void recalcLocalAabb(); - -}; - -#endif //BT_CONVEX_INTERNAL_SHAPE_H diff --git a/bullet/src/BulletCollision/CollisionShapes/btConvexPointCloudShape.cpp b/bullet/src/BulletCollision/CollisionShapes/btConvexPointCloudShape.cpp deleted file mode 100644 index ef003ce6f..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btConvexPointCloudShape.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btConvexPointCloudShape.h" -#include "BulletCollision/CollisionShapes/btCollisionMargin.h" - -#include "LinearMath/btQuaternion.h" - -void btConvexPointCloudShape::setLocalScaling(const btVector3& scaling) -{ - m_localScaling = scaling; - recalcLocalAabb(); -} - -#ifndef __SPU__ -btVector3 btConvexPointCloudShape::localGetSupportingVertexWithoutMargin(const btVector3& vec0)const -{ - btVector3 supVec(btScalar(0.),btScalar(0.),btScalar(0.)); - btScalar newDot,maxDot = btScalar(-BT_LARGE_FLOAT); - - btVector3 vec = vec0; - btScalar lenSqr = vec.length2(); - if (lenSqr < btScalar(0.0001)) - { - vec.setValue(1,0,0); - } else - { - btScalar rlen = btScalar(1.) / btSqrt(lenSqr ); - vec *= rlen; - } - - - for (int i=0;i maxDot) - { - maxDot = newDot; - supVec = vtx; - } - } - return supVec; -} - -void btConvexPointCloudShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const -{ - btScalar newDot; - //use 'w' component of supportVerticesOut? - { - for (int i=0;i supportVerticesOut[j][3]) - { - //WARNING: don't swap next lines, the w component would get overwritten! - supportVerticesOut[j] = vtx; - supportVerticesOut[j][3] = newDot; - } - } - } - - - -} - - - -btVector3 btConvexPointCloudShape::localGetSupportingVertex(const btVector3& vec)const -{ - btVector3 supVertex = localGetSupportingVertexWithoutMargin(vec); - - if ( getMargin()!=btScalar(0.) ) - { - btVector3 vecnorm = vec; - if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON)) - { - vecnorm.setValue(btScalar(-1.),btScalar(-1.),btScalar(-1.)); - } - vecnorm.normalize(); - supVertex+= getMargin() * vecnorm; - } - return supVertex; -} - - -#endif - - - - - - -//currently just for debugging (drawing), perhaps future support for algebraic continuous collision detection -//Please note that you can debug-draw btConvexHullShape with the Raytracer Demo -int btConvexPointCloudShape::getNumVertices() const -{ - return m_numPoints; -} - -int btConvexPointCloudShape::getNumEdges() const -{ - return 0; -} - -void btConvexPointCloudShape::getEdge(int i,btVector3& pa,btVector3& pb) const -{ - btAssert (0); -} - -void btConvexPointCloudShape::getVertex(int i,btVector3& vtx) const -{ - vtx = m_unscaledPoints[i]*m_localScaling; -} - -int btConvexPointCloudShape::getNumPlanes() const -{ - return 0; -} - -void btConvexPointCloudShape::getPlane(btVector3& ,btVector3& ,int ) const -{ - - btAssert(0); -} - -//not yet -bool btConvexPointCloudShape::isInside(const btVector3& ,btScalar ) const -{ - btAssert(0); - return false; -} - diff --git a/bullet/src/BulletCollision/CollisionShapes/btConvexPointCloudShape.h b/bullet/src/BulletCollision/CollisionShapes/btConvexPointCloudShape.h deleted file mode 100644 index fbc4f090f..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btConvexPointCloudShape.h +++ /dev/null @@ -1,105 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef BT_CONVEX_POINT_CLOUD_SHAPE_H -#define BT_CONVEX_POINT_CLOUD_SHAPE_H - -#include "btPolyhedralConvexShape.h" -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types -#include "LinearMath/btAlignedObjectArray.h" - -///The btConvexPointCloudShape implements an implicit convex hull of an array of vertices. -ATTRIBUTE_ALIGNED16(class) btConvexPointCloudShape : public btPolyhedralConvexAabbCachingShape -{ - btVector3* m_unscaledPoints; - int m_numPoints; - -public: - BT_DECLARE_ALIGNED_ALLOCATOR(); - - btConvexPointCloudShape() - { - m_localScaling.setValue(1.f,1.f,1.f); - m_shapeType = CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE; - m_unscaledPoints = 0; - m_numPoints = 0; - } - - btConvexPointCloudShape(btVector3* points,int numPoints, const btVector3& localScaling,bool computeAabb = true) - { - m_localScaling = localScaling; - m_shapeType = CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE; - m_unscaledPoints = points; - m_numPoints = numPoints; - - if (computeAabb) - recalcLocalAabb(); - } - - void setPoints (btVector3* points, int numPoints, bool computeAabb = true,const btVector3& localScaling=btVector3(1.f,1.f,1.f)) - { - m_unscaledPoints = points; - m_numPoints = numPoints; - m_localScaling = localScaling; - - if (computeAabb) - recalcLocalAabb(); - } - - SIMD_FORCE_INLINE btVector3* getUnscaledPoints() - { - return m_unscaledPoints; - } - - SIMD_FORCE_INLINE const btVector3* getUnscaledPoints() const - { - return m_unscaledPoints; - } - - SIMD_FORCE_INLINE int getNumPoints() const - { - return m_numPoints; - } - - SIMD_FORCE_INLINE btVector3 getScaledPoint( int index) const - { - return m_unscaledPoints[index] * m_localScaling; - } - -#ifndef __SPU__ - virtual btVector3 localGetSupportingVertex(const btVector3& vec)const; - virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const; - virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const; -#endif - - - //debugging - virtual const char* getName()const {return "ConvexPointCloud";} - - virtual int getNumVertices() const; - virtual int getNumEdges() const; - virtual void getEdge(int i,btVector3& pa,btVector3& pb) const; - virtual void getVertex(int i,btVector3& vtx) const; - virtual int getNumPlanes() const; - virtual void getPlane(btVector3& planeNormal,btVector3& planeSupport,int i ) const; - virtual bool isInside(const btVector3& pt,btScalar tolerance) const; - - ///in case we receive negative scaling - virtual void setLocalScaling(const btVector3& scaling); -}; - - -#endif //BT_CONVEX_POINT_CLOUD_SHAPE_H - diff --git a/bullet/src/BulletCollision/CollisionShapes/btConvexShape.cpp b/bullet/src/BulletCollision/CollisionShapes/btConvexShape.cpp deleted file mode 100644 index c27343003..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btConvexShape.cpp +++ /dev/null @@ -1,429 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btConvexShape.h" -#include "btTriangleShape.h" -#include "btSphereShape.h" -#include "btCylinderShape.h" -#include "btCapsuleShape.h" -#include "btConvexHullShape.h" -#include "btConvexPointCloudShape.h" - -///not supported on IBM SDK, until we fix the alignment of btVector3 -#if defined (__CELLOS_LV2__) && defined (__SPU__) -#include -static inline vec_float4 vec_dot3( vec_float4 vec0, vec_float4 vec1 ) -{ - vec_float4 result; - result = spu_mul( vec0, vec1 ); - result = spu_madd( spu_rlqwbyte( vec0, 4 ), spu_rlqwbyte( vec1, 4 ), result ); - return spu_madd( spu_rlqwbyte( vec0, 8 ), spu_rlqwbyte( vec1, 8 ), result ); -} -#endif //__SPU__ - -btConvexShape::btConvexShape () -{ -} - -btConvexShape::~btConvexShape() -{ - -} - - - -static btVector3 convexHullSupport (const btVector3& localDirOrg, const btVector3* points, int numPoints, const btVector3& localScaling) -{ - - btVector3 vec = localDirOrg * localScaling; - -#if defined (__CELLOS_LV2__) && defined (__SPU__) - - btVector3 localDir = vec; - - vec_float4 v_distMax = {-FLT_MAX,0,0,0}; - vec_int4 v_idxMax = {-999,0,0,0}; - int v=0; - int numverts = numPoints; - - for(;v<(int)numverts-4;v+=4) { - vec_float4 p0 = vec_dot3(points[v ].get128(),localDir.get128()); - vec_float4 p1 = vec_dot3(points[v+1].get128(),localDir.get128()); - vec_float4 p2 = vec_dot3(points[v+2].get128(),localDir.get128()); - vec_float4 p3 = vec_dot3(points[v+3].get128(),localDir.get128()); - const vec_int4 i0 = {v ,0,0,0}; - const vec_int4 i1 = {v+1,0,0,0}; - const vec_int4 i2 = {v+2,0,0,0}; - const vec_int4 i3 = {v+3,0,0,0}; - vec_uint4 retGt01 = spu_cmpgt(p0,p1); - vec_float4 pmax01 = spu_sel(p1,p0,retGt01); - vec_int4 imax01 = spu_sel(i1,i0,retGt01); - vec_uint4 retGt23 = spu_cmpgt(p2,p3); - vec_float4 pmax23 = spu_sel(p3,p2,retGt23); - vec_int4 imax23 = spu_sel(i3,i2,retGt23); - vec_uint4 retGt0123 = spu_cmpgt(pmax01,pmax23); - vec_float4 pmax0123 = spu_sel(pmax23,pmax01,retGt0123); - vec_int4 imax0123 = spu_sel(imax23,imax01,retGt0123); - vec_uint4 retGtMax = spu_cmpgt(v_distMax,pmax0123); - v_distMax = spu_sel(pmax0123,v_distMax,retGtMax); - v_idxMax = spu_sel(imax0123,v_idxMax,retGtMax); - } - for(;v<(int)numverts;v++) { - vec_float4 p = vec_dot3(points[v].get128(),localDir.get128()); - const vec_int4 i = {v,0,0,0}; - vec_uint4 retGtMax = spu_cmpgt(v_distMax,p); - v_distMax = spu_sel(p,v_distMax,retGtMax); - v_idxMax = spu_sel(i,v_idxMax,retGtMax); - } - int ptIndex = spu_extract(v_idxMax,0); - const btVector3& supVec= points[ptIndex] * localScaling; - return supVec; -#else - - btScalar newDot,maxDot = btScalar(-BT_LARGE_FLOAT); - int ptIndex = -1; - - for (int i=0;i maxDot) - { - maxDot = newDot; - ptIndex = i; - } - } - btAssert(ptIndex >= 0); - btVector3 supVec = points[ptIndex] * localScaling; - return supVec; -#endif //__SPU__ -} - -btVector3 btConvexShape::localGetSupportVertexWithoutMarginNonVirtual (const btVector3& localDir) const -{ - switch (m_shapeType) - { - case SPHERE_SHAPE_PROXYTYPE: - { - return btVector3(0,0,0); - } - case BOX_SHAPE_PROXYTYPE: - { - btBoxShape* convexShape = (btBoxShape*)this; - const btVector3& halfExtents = convexShape->getImplicitShapeDimensions(); - - return btVector3(btFsels(localDir.x(), halfExtents.x(), -halfExtents.x()), - btFsels(localDir.y(), halfExtents.y(), -halfExtents.y()), - btFsels(localDir.z(), halfExtents.z(), -halfExtents.z())); - } - case TRIANGLE_SHAPE_PROXYTYPE: - { - btTriangleShape* triangleShape = (btTriangleShape*)this; - btVector3 dir(localDir.getX(),localDir.getY(),localDir.getZ()); - btVector3* vertices = &triangleShape->m_vertices1[0]; - btVector3 dots(dir.dot(vertices[0]), dir.dot(vertices[1]), dir.dot(vertices[2])); - btVector3 sup = vertices[dots.maxAxis()]; - return btVector3(sup.getX(),sup.getY(),sup.getZ()); - } - case CYLINDER_SHAPE_PROXYTYPE: - { - btCylinderShape* cylShape = (btCylinderShape*)this; - //mapping of halfextents/dimension onto radius/height depends on how cylinder local orientation is (upAxis) - - btVector3 halfExtents = cylShape->getImplicitShapeDimensions(); - btVector3 v(localDir.getX(),localDir.getY(),localDir.getZ()); - int cylinderUpAxis = cylShape->getUpAxis(); - int XX(1),YY(0),ZZ(2); - - switch (cylinderUpAxis) - { - case 0: - { - XX = 1; - YY = 0; - ZZ = 2; - } - break; - case 1: - { - XX = 0; - YY = 1; - ZZ = 2; - } - break; - case 2: - { - XX = 0; - YY = 2; - ZZ = 1; - - } - break; - default: - btAssert(0); - break; - }; - - btScalar radius = halfExtents[XX]; - btScalar halfHeight = halfExtents[cylinderUpAxis]; - - btVector3 tmp; - btScalar d ; - - btScalar s = btSqrt(v[XX] * v[XX] + v[ZZ] * v[ZZ]); - if (s != btScalar(0.0)) - { - d = radius / s; - tmp[XX] = v[XX] * d; - tmp[YY] = v[YY] < 0.0 ? -halfHeight : halfHeight; - tmp[ZZ] = v[ZZ] * d; - return btVector3(tmp.getX(),tmp.getY(),tmp.getZ()); - } else { - tmp[XX] = radius; - tmp[YY] = v[YY] < 0.0 ? -halfHeight : halfHeight; - tmp[ZZ] = btScalar(0.0); - return btVector3(tmp.getX(),tmp.getY(),tmp.getZ()); - } - } - case CAPSULE_SHAPE_PROXYTYPE: - { - btVector3 vec0(localDir.getX(),localDir.getY(),localDir.getZ()); - - btCapsuleShape* capsuleShape = (btCapsuleShape*)this; - btScalar halfHeight = capsuleShape->getHalfHeight(); - int capsuleUpAxis = capsuleShape->getUpAxis(); - - btScalar radius = capsuleShape->getRadius(); - btVector3 supVec(0,0,0); - - btScalar maxDot(btScalar(-BT_LARGE_FLOAT)); - - btVector3 vec = vec0; - btScalar lenSqr = vec.length2(); - if (lenSqr < btScalar(0.0001)) - { - vec.setValue(1,0,0); - } else - { - btScalar rlen = btScalar(1.) / btSqrt(lenSqr ); - vec *= rlen; - } - btVector3 vtx; - btScalar newDot; - { - btVector3 pos(0,0,0); - pos[capsuleUpAxis] = halfHeight; - - //vtx = pos +vec*(radius); - vtx = pos +vec*capsuleShape->getLocalScalingNV()*(radius) - vec * capsuleShape->getMarginNV(); - newDot = vec.dot(vtx); - - - if (newDot > maxDot) - { - maxDot = newDot; - supVec = vtx; - } - } - { - btVector3 pos(0,0,0); - pos[capsuleUpAxis] = -halfHeight; - - //vtx = pos +vec*(radius); - vtx = pos +vec*capsuleShape->getLocalScalingNV()*(radius) - vec * capsuleShape->getMarginNV(); - newDot = vec.dot(vtx); - if (newDot > maxDot) - { - maxDot = newDot; - supVec = vtx; - } - } - return btVector3(supVec.getX(),supVec.getY(),supVec.getZ()); - } - case CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE: - { - btConvexPointCloudShape* convexPointCloudShape = (btConvexPointCloudShape*)this; - btVector3* points = convexPointCloudShape->getUnscaledPoints (); - int numPoints = convexPointCloudShape->getNumPoints (); - return convexHullSupport (localDir, points, numPoints,convexPointCloudShape->getLocalScalingNV()); - } - case CONVEX_HULL_SHAPE_PROXYTYPE: - { - btConvexHullShape* convexHullShape = (btConvexHullShape*)this; - btVector3* points = convexHullShape->getUnscaledPoints(); - int numPoints = convexHullShape->getNumPoints (); - return convexHullSupport (localDir, points, numPoints,convexHullShape->getLocalScalingNV()); - } - default: -#ifndef __SPU__ - return this->localGetSupportingVertexWithoutMargin (localDir); -#else - btAssert (0); -#endif - } - - // should never reach here - btAssert (0); - return btVector3 (btScalar(0.0f), btScalar(0.0f), btScalar(0.0f)); -} - -btVector3 btConvexShape::localGetSupportVertexNonVirtual (const btVector3& localDir) const -{ - btVector3 localDirNorm = localDir; - if (localDirNorm .length2() < (SIMD_EPSILON*SIMD_EPSILON)) - { - localDirNorm.setValue(btScalar(-1.),btScalar(-1.),btScalar(-1.)); - } - localDirNorm.normalize (); - - return localGetSupportVertexWithoutMarginNonVirtual(localDirNorm)+ getMarginNonVirtual() * localDirNorm; -} - -/* TODO: This should be bumped up to btCollisionShape () */ -btScalar btConvexShape::getMarginNonVirtual () const -{ - switch (m_shapeType) - { - case SPHERE_SHAPE_PROXYTYPE: - { - btSphereShape* sphereShape = (btSphereShape*)this; - return sphereShape->getRadius (); - } - case BOX_SHAPE_PROXYTYPE: - { - btBoxShape* convexShape = (btBoxShape*)this; - return convexShape->getMarginNV (); - } - case TRIANGLE_SHAPE_PROXYTYPE: - { - btTriangleShape* triangleShape = (btTriangleShape*)this; - return triangleShape->getMarginNV (); - } - case CYLINDER_SHAPE_PROXYTYPE: - { - btCylinderShape* cylShape = (btCylinderShape*)this; - return cylShape->getMarginNV(); - } - case CAPSULE_SHAPE_PROXYTYPE: - { - btCapsuleShape* capsuleShape = (btCapsuleShape*)this; - return capsuleShape->getMarginNV(); - } - case CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE: - /* fall through */ - case CONVEX_HULL_SHAPE_PROXYTYPE: - { - btPolyhedralConvexShape* convexHullShape = (btPolyhedralConvexShape*)this; - return convexHullShape->getMarginNV(); - } - default: -#ifndef __SPU__ - return this->getMargin (); -#else - btAssert (0); -#endif - } - - // should never reach here - btAssert (0); - return btScalar(0.0f); -} -#ifndef __SPU__ -void btConvexShape::getAabbNonVirtual (const btTransform& t, btVector3& aabbMin, btVector3& aabbMax) const -{ - switch (m_shapeType) - { - case SPHERE_SHAPE_PROXYTYPE: - { - btSphereShape* sphereShape = (btSphereShape*)this; - btScalar radius = sphereShape->getImplicitShapeDimensions().getX();// * convexShape->getLocalScaling().getX(); - btScalar margin = radius + sphereShape->getMarginNonVirtual(); - const btVector3& center = t.getOrigin(); - btVector3 extent(margin,margin,margin); - aabbMin = center - extent; - aabbMax = center + extent; - } - break; - case CYLINDER_SHAPE_PROXYTYPE: - /* fall through */ - case BOX_SHAPE_PROXYTYPE: - { - btBoxShape* convexShape = (btBoxShape*)this; - btScalar margin=convexShape->getMarginNonVirtual(); - btVector3 halfExtents = convexShape->getImplicitShapeDimensions(); - halfExtents += btVector3(margin,margin,margin); - btMatrix3x3 abs_b = t.getBasis().absolute(); - btVector3 center = t.getOrigin(); - btVector3 extent = btVector3(abs_b[0].dot(halfExtents),abs_b[1].dot(halfExtents),abs_b[2].dot(halfExtents)); - - aabbMin = center - extent; - aabbMax = center + extent; - break; - } - case TRIANGLE_SHAPE_PROXYTYPE: - { - btTriangleShape* triangleShape = (btTriangleShape*)this; - btScalar margin = triangleShape->getMarginNonVirtual(); - for (int i=0;i<3;i++) - { - btVector3 vec(btScalar(0.),btScalar(0.),btScalar(0.)); - vec[i] = btScalar(1.); - - btVector3 sv = localGetSupportVertexWithoutMarginNonVirtual(vec*t.getBasis()); - - btVector3 tmp = t(sv); - aabbMax[i] = tmp[i]+margin; - vec[i] = btScalar(-1.); - tmp = t(localGetSupportVertexWithoutMarginNonVirtual(vec*t.getBasis())); - aabbMin[i] = tmp[i]-margin; - } - } - break; - case CAPSULE_SHAPE_PROXYTYPE: - { - btCapsuleShape* capsuleShape = (btCapsuleShape*)this; - btVector3 halfExtents(capsuleShape->getRadius(),capsuleShape->getRadius(),capsuleShape->getRadius()); - int m_upAxis = capsuleShape->getUpAxis(); - halfExtents[m_upAxis] = capsuleShape->getRadius() + capsuleShape->getHalfHeight(); - halfExtents += btVector3(capsuleShape->getMarginNonVirtual(),capsuleShape->getMarginNonVirtual(),capsuleShape->getMarginNonVirtual()); - btMatrix3x3 abs_b = t.getBasis().absolute(); - btVector3 center = t.getOrigin(); - btVector3 extent = btVector3(abs_b[0].dot(halfExtents),abs_b[1].dot(halfExtents),abs_b[2].dot(halfExtents)); - aabbMin = center - extent; - aabbMax = center + extent; - } - break; - case CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE: - case CONVEX_HULL_SHAPE_PROXYTYPE: - { - btPolyhedralConvexAabbCachingShape* convexHullShape = (btPolyhedralConvexAabbCachingShape*)this; - btScalar margin = convexHullShape->getMarginNonVirtual(); - convexHullShape->getNonvirtualAabb (t, aabbMin, aabbMax, margin); - } - break; - default: -#ifndef __SPU__ - this->getAabb (t, aabbMin, aabbMax); -#else - btAssert (0); -#endif - break; - } - - // should never reach here - btAssert (0); -} - -#endif //__SPU__ diff --git a/bullet/src/BulletCollision/CollisionShapes/btConvexShape.h b/bullet/src/BulletCollision/CollisionShapes/btConvexShape.h deleted file mode 100644 index 5d4eb9003..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btConvexShape.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef CONVEX_SHAPE_INTERFACE1 -#define CONVEX_SHAPE_INTERFACE1 - -#include "btCollisionShape.h" - -#include "LinearMath/btVector3.h" -#include "LinearMath/btTransform.h" -#include "LinearMath/btMatrix3x3.h" -#include "btCollisionMargin.h" -#include "LinearMath/btAlignedAllocator.h" - -#define MAX_PREFERRED_PENETRATION_DIRECTIONS 10 - -/// The btConvexShape is an abstract shape interface, implemented by all convex shapes such as btBoxShape, btConvexHullShape etc. -/// It describes general convex shapes using the localGetSupportingVertex interface, used by collision detectors such as btGjkPairDetector. -ATTRIBUTE_ALIGNED16(class) btConvexShape : public btCollisionShape -{ - - -public: - - BT_DECLARE_ALIGNED_ALLOCATOR(); - - btConvexShape (); - - virtual ~btConvexShape(); - - virtual btVector3 localGetSupportingVertex(const btVector3& vec)const = 0; - - //////// - #ifndef __SPU__ - virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec) const=0; - #endif //#ifndef __SPU__ - - btVector3 localGetSupportVertexWithoutMarginNonVirtual (const btVector3& vec) const; - btVector3 localGetSupportVertexNonVirtual (const btVector3& vec) const; - btScalar getMarginNonVirtual () const; - void getAabbNonVirtual (const btTransform& t, btVector3& aabbMin, btVector3& aabbMax) const; - - - //notice that the vectors should be unit length - virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const= 0; - - ///getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version - void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const =0; - - virtual void getAabbSlow(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const =0; - - virtual void setLocalScaling(const btVector3& scaling) =0; - virtual const btVector3& getLocalScaling() const =0; - - virtual void setMargin(btScalar margin)=0; - - virtual btScalar getMargin() const=0; - - virtual int getNumPreferredPenetrationDirections() const=0; - - virtual void getPreferredPenetrationDirection(int index, btVector3& penetrationVector) const=0; - - - - -}; - - - -#endif //CONVEX_SHAPE_INTERFACE1 diff --git a/bullet/src/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.cpp b/bullet/src/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.cpp deleted file mode 100644 index f84516621..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.cpp +++ /dev/null @@ -1,315 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btConvexTriangleMeshShape.h" -#include "BulletCollision/CollisionShapes/btCollisionMargin.h" - -#include "LinearMath/btQuaternion.h" -#include "BulletCollision/CollisionShapes/btStridingMeshInterface.h" - - -btConvexTriangleMeshShape ::btConvexTriangleMeshShape (btStridingMeshInterface* meshInterface, bool calcAabb) -: btPolyhedralConvexAabbCachingShape(), m_stridingMesh(meshInterface) -{ - m_shapeType = CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE; - if ( calcAabb ) - recalcLocalAabb(); -} - - - - -///It's not nice to have all this virtual function overhead, so perhaps we can also gather the points once -///but then we are duplicating -class LocalSupportVertexCallback: public btInternalTriangleIndexCallback -{ - - btVector3 m_supportVertexLocal; -public: - - btScalar m_maxDot; - btVector3 m_supportVecLocal; - - LocalSupportVertexCallback(const btVector3& supportVecLocal) - : m_supportVertexLocal(btScalar(0.),btScalar(0.),btScalar(0.)), - m_maxDot(btScalar(-BT_LARGE_FLOAT)), - m_supportVecLocal(supportVecLocal) - { - } - - virtual void internalProcessTriangleIndex(btVector3* triangle,int partId,int triangleIndex) - { - (void)triangleIndex; - (void)partId; - - for (int i=0;i<3;i++) - { - btScalar dot = m_supportVecLocal.dot(triangle[i]); - if (dot > m_maxDot) - { - m_maxDot = dot; - m_supportVertexLocal = triangle[i]; - } - } - } - - btVector3 GetSupportVertexLocal() - { - return m_supportVertexLocal; - } - -}; - - - - - -btVector3 btConvexTriangleMeshShape::localGetSupportingVertexWithoutMargin(const btVector3& vec0)const -{ - btVector3 supVec(btScalar(0.),btScalar(0.),btScalar(0.)); - - btVector3 vec = vec0; - btScalar lenSqr = vec.length2(); - if (lenSqr < btScalar(0.0001)) - { - vec.setValue(1,0,0); - } else - { - btScalar rlen = btScalar(1.) / btSqrt(lenSqr ); - vec *= rlen; - } - - LocalSupportVertexCallback supportCallback(vec); - btVector3 aabbMax(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT)); - m_stridingMesh->InternalProcessAllTriangles(&supportCallback,-aabbMax,aabbMax); - supVec = supportCallback.GetSupportVertexLocal(); - - return supVec; -} - -void btConvexTriangleMeshShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const -{ - //use 'w' component of supportVerticesOut? - { - for (int i=0;iInternalProcessAllTriangles(&supportCallback,-aabbMax,aabbMax); - supportVerticesOut[j] = supportCallback.GetSupportVertexLocal(); - } - -} - - - -btVector3 btConvexTriangleMeshShape::localGetSupportingVertex(const btVector3& vec)const -{ - btVector3 supVertex = localGetSupportingVertexWithoutMargin(vec); - - if ( getMargin()!=btScalar(0.) ) - { - btVector3 vecnorm = vec; - if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON)) - { - vecnorm.setValue(btScalar(-1.),btScalar(-1.),btScalar(-1.)); - } - vecnorm.normalize(); - supVertex+= getMargin() * vecnorm; - } - return supVertex; -} - - - - - - - - - -//currently just for debugging (drawing), perhaps future support for algebraic continuous collision detection -//Please note that you can debug-draw btConvexTriangleMeshShape with the Raytracer Demo -int btConvexTriangleMeshShape::getNumVertices() const -{ - //cache this? - return 0; - -} - -int btConvexTriangleMeshShape::getNumEdges() const -{ - return 0; -} - -void btConvexTriangleMeshShape::getEdge(int ,btVector3& ,btVector3& ) const -{ - btAssert(0); -} - -void btConvexTriangleMeshShape::getVertex(int ,btVector3& ) const -{ - btAssert(0); -} - -int btConvexTriangleMeshShape::getNumPlanes() const -{ - return 0; -} - -void btConvexTriangleMeshShape::getPlane(btVector3& ,btVector3& ,int ) const -{ - btAssert(0); -} - -//not yet -bool btConvexTriangleMeshShape::isInside(const btVector3& ,btScalar ) const -{ - btAssert(0); - return false; -} - - - -void btConvexTriangleMeshShape::setLocalScaling(const btVector3& scaling) -{ - m_stridingMesh->setScaling(scaling); - - recalcLocalAabb(); - -} - - -const btVector3& btConvexTriangleMeshShape::getLocalScaling() const -{ - return m_stridingMesh->getScaling(); -} - -void btConvexTriangleMeshShape::calculatePrincipalAxisTransform(btTransform& principal, btVector3& inertia, btScalar& volume) const -{ - class CenterCallback: public btInternalTriangleIndexCallback - { - bool first; - btVector3 ref; - btVector3 sum; - btScalar volume; - - public: - - CenterCallback() : first(true), ref(0, 0, 0), sum(0, 0, 0), volume(0) - { - } - - virtual void internalProcessTriangleIndex(btVector3* triangle, int partId, int triangleIndex) - { - (void) triangleIndex; - (void) partId; - if (first) - { - ref = triangle[0]; - first = false; - } - else - { - btScalar vol = btFabs((triangle[0] - ref).triple(triangle[1] - ref, triangle[2] - ref)); - sum += (btScalar(0.25) * vol) * ((triangle[0] + triangle[1] + triangle[2] + ref)); - volume += vol; - } - } - - btVector3 getCenter() - { - return (volume > 0) ? sum / volume : ref; - } - - btScalar getVolume() - { - return volume * btScalar(1. / 6); - } - - }; - - class InertiaCallback: public btInternalTriangleIndexCallback - { - btMatrix3x3 sum; - btVector3 center; - - public: - - InertiaCallback(btVector3& center) : sum(0, 0, 0, 0, 0, 0, 0, 0, 0), center(center) - { - } - - virtual void internalProcessTriangleIndex(btVector3* triangle, int partId, int triangleIndex) - { - (void) triangleIndex; - (void) partId; - btMatrix3x3 i; - btVector3 a = triangle[0] - center; - btVector3 b = triangle[1] - center; - btVector3 c = triangle[2] - center; - btScalar volNeg = -btFabs(a.triple(b, c)) * btScalar(1. / 6); - for (int j = 0; j < 3; j++) - { - for (int k = 0; k <= j; k++) - { - i[j][k] = i[k][j] = volNeg * (btScalar(0.1) * (a[j] * a[k] + b[j] * b[k] + c[j] * c[k]) - + btScalar(0.05) * (a[j] * b[k] + a[k] * b[j] + a[j] * c[k] + a[k] * c[j] + b[j] * c[k] + b[k] * c[j])); - } - } - btScalar i00 = -i[0][0]; - btScalar i11 = -i[1][1]; - btScalar i22 = -i[2][2]; - i[0][0] = i11 + i22; - i[1][1] = i22 + i00; - i[2][2] = i00 + i11; - sum[0] += i[0]; - sum[1] += i[1]; - sum[2] += i[2]; - } - - btMatrix3x3& getInertia() - { - return sum; - } - - }; - - CenterCallback centerCallback; - btVector3 aabbMax(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT)); - m_stridingMesh->InternalProcessAllTriangles(¢erCallback, -aabbMax, aabbMax); - btVector3 center = centerCallback.getCenter(); - principal.setOrigin(center); - volume = centerCallback.getVolume(); - - InertiaCallback inertiaCallback(center); - m_stridingMesh->InternalProcessAllTriangles(&inertiaCallback, -aabbMax, aabbMax); - - btMatrix3x3& i = inertiaCallback.getInertia(); - i.diagonalize(principal.getBasis(), btScalar(0.00001), 20); - inertia.setValue(i[0][0], i[1][1], i[2][2]); - inertia /= volume; -} - diff --git a/bullet/src/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.h b/bullet/src/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.h deleted file mode 100644 index a583424a5..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ -#ifndef CONVEX_TRIANGLEMESH_SHAPE_H -#define CONVEX_TRIANGLEMESH_SHAPE_H - - -#include "btPolyhedralConvexShape.h" -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types - - -/// The btConvexTriangleMeshShape is a convex hull of a triangle mesh, but the performance is not as good as btConvexHullShape. -/// A small benefit of this class is that it uses the btStridingMeshInterface, so you can avoid the duplication of the triangle mesh data. Nevertheless, most users should use the much better performing btConvexHullShape instead. -class btConvexTriangleMeshShape : public btPolyhedralConvexAabbCachingShape -{ - - class btStridingMeshInterface* m_stridingMesh; - -public: - btConvexTriangleMeshShape(btStridingMeshInterface* meshInterface, bool calcAabb = true); - - class btStridingMeshInterface* getMeshInterface() - { - return m_stridingMesh; - } - const class btStridingMeshInterface* getMeshInterface() const - { - return m_stridingMesh; - } - - virtual btVector3 localGetSupportingVertex(const btVector3& vec)const; - virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const; - virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const; - - //debugging - virtual const char* getName()const {return "ConvexTrimesh";} - - virtual int getNumVertices() const; - virtual int getNumEdges() const; - virtual void getEdge(int i,btVector3& pa,btVector3& pb) const; - virtual void getVertex(int i,btVector3& vtx) const; - virtual int getNumPlanes() const; - virtual void getPlane(btVector3& planeNormal,btVector3& planeSupport,int i ) const; - virtual bool isInside(const btVector3& pt,btScalar tolerance) const; - - - virtual void setLocalScaling(const btVector3& scaling); - virtual const btVector3& getLocalScaling() const; - - ///computes the exact moment of inertia and the transform from the coordinate system defined by the principal axes of the moment of inertia - ///and the center of mass to the current coordinate system. A mass of 1 is assumed, for other masses just multiply the computed "inertia" - ///by the mass. The resulting transform "principal" has to be applied inversely to the mesh in order for the local coordinate system of the - ///shape to be centered at the center of mass and to coincide with the principal axes. This also necessitates a correction of the world transform - ///of the collision object by the principal transform. This method also computes the volume of the convex mesh. - void calculatePrincipalAxisTransform(btTransform& principal, btVector3& inertia, btScalar& volume) const; - -}; - - - -#endif //CONVEX_TRIANGLEMESH_SHAPE_H - - - diff --git a/bullet/src/BulletCollision/CollisionShapes/btCylinderShape.cpp b/bullet/src/BulletCollision/CollisionShapes/btCylinderShape.cpp deleted file mode 100644 index 4ce45ca23..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btCylinderShape.cpp +++ /dev/null @@ -1,222 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btCylinderShape.h" - -btCylinderShape::btCylinderShape (const btVector3& halfExtents) -:btConvexInternalShape(), -m_upAxis(1) -{ - btVector3 margin(getMargin(),getMargin(),getMargin()); - m_implicitShapeDimensions = (halfExtents * m_localScaling) - margin; - m_shapeType = CYLINDER_SHAPE_PROXYTYPE; -} - - -btCylinderShapeX::btCylinderShapeX (const btVector3& halfExtents) -:btCylinderShape(halfExtents) -{ - m_upAxis = 0; - -} - - -btCylinderShapeZ::btCylinderShapeZ (const btVector3& halfExtents) -:btCylinderShape(halfExtents) -{ - m_upAxis = 2; - -} - -void btCylinderShape::getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const -{ - btTransformAabb(getHalfExtentsWithoutMargin(),getMargin(),t,aabbMin,aabbMax); -} - -void btCylinderShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const -{ - //approximation of box shape, todo: implement cylinder shape inertia before people notice ;-) - btVector3 halfExtents = getHalfExtentsWithMargin(); - - btScalar lx=btScalar(2.)*(halfExtents.x()); - btScalar ly=btScalar(2.)*(halfExtents.y()); - btScalar lz=btScalar(2.)*(halfExtents.z()); - - inertia.setValue(mass/(btScalar(12.0)) * (ly*ly + lz*lz), - mass/(btScalar(12.0)) * (lx*lx + lz*lz), - mass/(btScalar(12.0)) * (lx*lx + ly*ly)); - -} - - -SIMD_FORCE_INLINE btVector3 CylinderLocalSupportX(const btVector3& halfExtents,const btVector3& v) -{ -const int cylinderUpAxis = 0; -const int XX = 1; -const int YY = 0; -const int ZZ = 2; - - //mapping depends on how cylinder local orientation is - // extents of the cylinder is: X,Y is for radius, and Z for height - - - btScalar radius = halfExtents[XX]; - btScalar halfHeight = halfExtents[cylinderUpAxis]; - - - btVector3 tmp; - btScalar d ; - - btScalar s = btSqrt(v[XX] * v[XX] + v[ZZ] * v[ZZ]); - if (s != btScalar(0.0)) - { - d = radius / s; - tmp[XX] = v[XX] * d; - tmp[YY] = v[YY] < 0.0 ? -halfHeight : halfHeight; - tmp[ZZ] = v[ZZ] * d; - return tmp; - } - else - { - tmp[XX] = radius; - tmp[YY] = v[YY] < 0.0 ? -halfHeight : halfHeight; - tmp[ZZ] = btScalar(0.0); - return tmp; - } - - -} - - - - - - -inline btVector3 CylinderLocalSupportY(const btVector3& halfExtents,const btVector3& v) -{ - -const int cylinderUpAxis = 1; -const int XX = 0; -const int YY = 1; -const int ZZ = 2; - - - btScalar radius = halfExtents[XX]; - btScalar halfHeight = halfExtents[cylinderUpAxis]; - - - btVector3 tmp; - btScalar d ; - - btScalar s = btSqrt(v[XX] * v[XX] + v[ZZ] * v[ZZ]); - if (s != btScalar(0.0)) - { - d = radius / s; - tmp[XX] = v[XX] * d; - tmp[YY] = v[YY] < 0.0 ? -halfHeight : halfHeight; - tmp[ZZ] = v[ZZ] * d; - return tmp; - } - else - { - tmp[XX] = radius; - tmp[YY] = v[YY] < 0.0 ? -halfHeight : halfHeight; - tmp[ZZ] = btScalar(0.0); - return tmp; - } - -} - -inline btVector3 CylinderLocalSupportZ(const btVector3& halfExtents,const btVector3& v) -{ -const int cylinderUpAxis = 2; -const int XX = 0; -const int YY = 2; -const int ZZ = 1; - - //mapping depends on how cylinder local orientation is - // extents of the cylinder is: X,Y is for radius, and Z for height - - - btScalar radius = halfExtents[XX]; - btScalar halfHeight = halfExtents[cylinderUpAxis]; - - - btVector3 tmp; - btScalar d ; - - btScalar s = btSqrt(v[XX] * v[XX] + v[ZZ] * v[ZZ]); - if (s != btScalar(0.0)) - { - d = radius / s; - tmp[XX] = v[XX] * d; - tmp[YY] = v[YY] < 0.0 ? -halfHeight : halfHeight; - tmp[ZZ] = v[ZZ] * d; - return tmp; - } - else - { - tmp[XX] = radius; - tmp[YY] = v[YY] < 0.0 ? -halfHeight : halfHeight; - tmp[ZZ] = btScalar(0.0); - return tmp; - } - - -} - -btVector3 btCylinderShapeX::localGetSupportingVertexWithoutMargin(const btVector3& vec)const -{ - return CylinderLocalSupportX(getHalfExtentsWithoutMargin(),vec); -} - - -btVector3 btCylinderShapeZ::localGetSupportingVertexWithoutMargin(const btVector3& vec)const -{ - return CylinderLocalSupportZ(getHalfExtentsWithoutMargin(),vec); -} -btVector3 btCylinderShape::localGetSupportingVertexWithoutMargin(const btVector3& vec)const -{ - return CylinderLocalSupportY(getHalfExtentsWithoutMargin(),vec); -} - -void btCylinderShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const -{ - for (int i=0;i 1 && "bad width"); - btAssert(heightStickLength > 1 && "bad length"); - btAssert(heightfieldData && "null heightfield data"); - // btAssert(heightScale) -- do we care? Trust caller here - btAssert(minHeight <= maxHeight && "bad min/max height"); - btAssert(upAxis >= 0 && upAxis < 3 && - "bad upAxis--should be in range [0,2]"); - btAssert(hdt != PHY_UCHAR || hdt != PHY_FLOAT || hdt != PHY_SHORT && - "Bad height data type enum"); - - // initialize member variables - m_shapeType = TERRAIN_SHAPE_PROXYTYPE; - m_heightStickWidth = heightStickWidth; - m_heightStickLength = heightStickLength; - m_minHeight = minHeight; - m_maxHeight = maxHeight; - m_width = (btScalar) (heightStickWidth - 1); - m_length = (btScalar) (heightStickLength - 1); - m_heightScale = heightScale; - m_heightfieldDataUnknown = heightfieldData; - m_heightDataType = hdt; - m_flipQuadEdges = flipQuadEdges; - m_useDiamondSubdivision = false; - m_upAxis = upAxis; - m_localScaling.setValue(btScalar(1.), btScalar(1.), btScalar(1.)); - - // determine min/max axis-aligned bounding box (aabb) values - switch (m_upAxis) - { - case 0: - { - m_localAabbMin.setValue(m_minHeight, 0, 0); - m_localAabbMax.setValue(m_maxHeight, m_width, m_length); - break; - } - case 1: - { - m_localAabbMin.setValue(0, m_minHeight, 0); - m_localAabbMax.setValue(m_width, m_maxHeight, m_length); - break; - }; - case 2: - { - m_localAabbMin.setValue(0, 0, m_minHeight); - m_localAabbMax.setValue(m_width, m_length, m_maxHeight); - break; - } - default: - { - //need to get valid m_upAxis - btAssert(0 && "Bad m_upAxis"); - } - } - - // remember origin (defined as exact middle of aabb) - m_localOrigin = btScalar(0.5) * (m_localAabbMin + m_localAabbMax); -} - - - -btHeightfieldTerrainShape::~btHeightfieldTerrainShape() -{ -} - - - -void btHeightfieldTerrainShape::getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const -{ - btVector3 halfExtents = (m_localAabbMax-m_localAabbMin)* m_localScaling * btScalar(0.5); - - btVector3 localOrigin(0, 0, 0); - localOrigin[m_upAxis] = (m_minHeight + m_maxHeight) * btScalar(0.5); - localOrigin *= m_localScaling; - - btMatrix3x3 abs_b = t.getBasis().absolute(); - btVector3 center = t.getOrigin(); - btVector3 extent = btVector3(abs_b[0].dot(halfExtents), - abs_b[1].dot(halfExtents), - abs_b[2].dot(halfExtents)); - extent += btVector3(getMargin(),getMargin(),getMargin()); - - aabbMin = center - extent; - aabbMax = center + extent; -} - - -/// This returns the "raw" (user's initial) height, not the actual height. -/// The actual height needs to be adjusted to be relative to the center -/// of the heightfield's AABB. -btScalar -btHeightfieldTerrainShape::getRawHeightFieldValue(int x,int y) const -{ - btScalar val = 0.f; - switch (m_heightDataType) - { - case PHY_FLOAT: - { - val = m_heightfieldDataFloat[(y*m_heightStickWidth)+x]; - break; - } - - case PHY_UCHAR: - { - unsigned char heightFieldValue = m_heightfieldDataUnsignedChar[(y*m_heightStickWidth)+x]; - val = heightFieldValue * m_heightScale; - break; - } - - case PHY_SHORT: - { - short hfValue = m_heightfieldDataShort[(y * m_heightStickWidth) + x]; - val = hfValue * m_heightScale; - break; - } - - default: - { - btAssert(!"Bad m_heightDataType"); - } - } - - return val; -} - - - - -/// this returns the vertex in bullet-local coordinates -void btHeightfieldTerrainShape::getVertex(int x,int y,btVector3& vertex) const -{ - btAssert(x>=0); - btAssert(y>=0); - btAssert(xstartX) - startX = quantizedAabbMin[1]; - if (quantizedAabbMax[1]startJ) - startJ = quantizedAabbMin[2]; - if (quantizedAabbMax[2]startX) - startX = quantizedAabbMin[0]; - if (quantizedAabbMax[0]startJ) - startJ = quantizedAabbMin[2]; - if (quantizedAabbMax[2]startX) - startX = quantizedAabbMin[0]; - if (quantizedAabbMax[0]startJ) - startJ = quantizedAabbMin[1]; - if (quantizedAabbMax[1]processTriangle(vertices,x,j); - //second triangle - getVertex(x,j,vertices[0]); - getVertex(x+1,j+1,vertices[1]); - getVertex(x,j+1,vertices[2]); - callback->processTriangle(vertices,x,j); - } else - { - //first triangle - getVertex(x,j,vertices[0]); - getVertex(x,j+1,vertices[1]); - getVertex(x+1,j,vertices[2]); - callback->processTriangle(vertices,x,j); - //second triangle - getVertex(x+1,j,vertices[0]); - getVertex(x,j+1,vertices[1]); - getVertex(x+1,j+1,vertices[2]); - callback->processTriangle(vertices,x,j); - } - } - } - - - -} - -void btHeightfieldTerrainShape::calculateLocalInertia(btScalar ,btVector3& inertia) const -{ - //moving concave objects not supported - - inertia.setValue(btScalar(0.),btScalar(0.),btScalar(0.)); -} - -void btHeightfieldTerrainShape::setLocalScaling(const btVector3& scaling) -{ - m_localScaling = scaling; -} -const btVector3& btHeightfieldTerrainShape::getLocalScaling() const -{ - return m_localScaling; -} diff --git a/bullet/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h b/bullet/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h deleted file mode 100644 index 487e77e74..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h +++ /dev/null @@ -1,161 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef HEIGHTFIELD_TERRAIN_SHAPE_H -#define HEIGHTFIELD_TERRAIN_SHAPE_H - -#include "btConcaveShape.h" - -///btHeightfieldTerrainShape simulates a 2D heightfield terrain -/** - The caller is responsible for maintaining the heightfield array; this - class does not make a copy. - - The heightfield can be dynamic so long as the min/max height values - capture the extremes (heights must always be in that range). - - The local origin of the heightfield is assumed to be the exact - center (as determined by width and length and height, with each - axis multiplied by the localScaling). - - \b NOTE: be careful with coordinates. If you have a heightfield with a local - min height of -100m, and a max height of +500m, you may be tempted to place it - at the origin (0,0) and expect the heights in world coordinates to be - -100 to +500 meters. - Actually, the heights will be -300 to +300m, because bullet will re-center - the heightfield based on its AABB (which is determined by the min/max - heights). So keep in mind that once you create a btHeightfieldTerrainShape - object, the heights will be adjusted relative to the center of the AABB. This - is different to the behavior of many rendering engines, but is useful for - physics engines. - - Most (but not all) rendering and heightfield libraries assume upAxis = 1 - (that is, the y-axis is "up"). This class allows any of the 3 coordinates - to be "up". Make sure your choice of axis is consistent with your rendering - system. - - The heightfield heights are determined from the data type used for the - heightfieldData array. - - - PHY_UCHAR: height at a point is the uchar value at the - grid point, multipled by heightScale. uchar isn't recommended - because of its inability to deal with negative values, and - low resolution (8-bit). - - - PHY_SHORT: height at a point is the short int value at that grid - point, multipled by heightScale. - - - PHY_FLOAT: height at a point is the float value at that grid - point. heightScale is ignored when using the float heightfield - data type. - - Whatever the caller specifies as minHeight and maxHeight will be honored. - The class will not inspect the heightfield to discover the actual minimum - or maximum heights. These values are used to determine the heightfield's - axis-aligned bounding box, multiplied by localScaling. - - For usage and testing see the TerrainDemo. - */ -class btHeightfieldTerrainShape : public btConcaveShape -{ -protected: - btVector3 m_localAabbMin; - btVector3 m_localAabbMax; - btVector3 m_localOrigin; - - ///terrain data - int m_heightStickWidth; - int m_heightStickLength; - btScalar m_minHeight; - btScalar m_maxHeight; - btScalar m_width; - btScalar m_length; - btScalar m_heightScale; - union - { - unsigned char* m_heightfieldDataUnsignedChar; - short* m_heightfieldDataShort; - btScalar* m_heightfieldDataFloat; - void* m_heightfieldDataUnknown; - }; - - PHY_ScalarType m_heightDataType; - bool m_flipQuadEdges; - bool m_useDiamondSubdivision; - - int m_upAxis; - - btVector3 m_localScaling; - - virtual btScalar getRawHeightFieldValue(int x,int y) const; - void quantizeWithClamp(int* out, const btVector3& point,int isMax) const; - void getVertex(int x,int y,btVector3& vertex) const; - - - - /// protected initialization - /** - Handles the work of constructors so that public constructors can be - backwards-compatible without a lot of copy/paste. - */ - void initialize(int heightStickWidth, int heightStickLength, - void* heightfieldData, btScalar heightScale, - btScalar minHeight, btScalar maxHeight, int upAxis, - PHY_ScalarType heightDataType, bool flipQuadEdges); - -public: - /// preferred constructor - /** - This constructor supports a range of heightfield - data types, and allows for a non-zero minimum height value. - heightScale is needed for any integer-based heightfield data types. - */ - btHeightfieldTerrainShape(int heightStickWidth,int heightStickLength, - void* heightfieldData, btScalar heightScale, - btScalar minHeight, btScalar maxHeight, - int upAxis, PHY_ScalarType heightDataType, - bool flipQuadEdges); - - /// legacy constructor - /** - The legacy constructor assumes the heightfield has a minimum height - of zero. Only unsigned char or floats are supported. For legacy - compatibility reasons, heightScale is calculated as maxHeight / 65535 - (and is only used when useFloatData = false). - */ - btHeightfieldTerrainShape(int heightStickWidth,int heightStickLength,void* heightfieldData, btScalar maxHeight,int upAxis,bool useFloatData,bool flipQuadEdges); - - virtual ~btHeightfieldTerrainShape(); - - - void setUseDiamondSubdivision(bool useDiamondSubdivision=true) { m_useDiamondSubdivision = useDiamondSubdivision;} - - - virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const; - - virtual void processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const; - - virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const; - - virtual void setLocalScaling(const btVector3& scaling); - - virtual const btVector3& getLocalScaling() const; - - //debugging - virtual const char* getName()const {return "HEIGHTFIELD";} - -}; - -#endif //HEIGHTFIELD_TERRAIN_SHAPE_H diff --git a/bullet/src/BulletCollision/CollisionShapes/btMaterial.h b/bullet/src/BulletCollision/CollisionShapes/btMaterial.h deleted file mode 100644 index 4626040f9..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btMaterial.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -/// This file was created by Alex Silverman - -#ifndef MATERIAL_H -#define MATERIAL_H - -// Material class to be used by btMultimaterialTriangleMeshShape to store triangle properties -class btMaterial -{ - // public members so that materials can change due to world events -public: - btScalar m_friction; - btScalar m_restitution; - int pad[2]; - - btMaterial(){} - btMaterial(btScalar fric, btScalar rest) { m_friction = fric; m_restitution = rest; } -}; - -#endif // MATERIAL_H \ No newline at end of file diff --git a/bullet/src/BulletCollision/CollisionShapes/btMinkowskiSumShape.cpp b/bullet/src/BulletCollision/CollisionShapes/btMinkowskiSumShape.cpp deleted file mode 100644 index 05e4d6537..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btMinkowskiSumShape.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#include "btMinkowskiSumShape.h" - - -btMinkowskiSumShape::btMinkowskiSumShape(const btConvexShape* shapeA,const btConvexShape* shapeB) -: btConvexInternalShape (), -m_shapeA(shapeA), -m_shapeB(shapeB) -{ - m_shapeType = MINKOWSKI_DIFFERENCE_SHAPE_PROXYTYPE; - m_transA.setIdentity(); - m_transB.setIdentity(); -} - -btVector3 btMinkowskiSumShape::localGetSupportingVertexWithoutMargin(const btVector3& vec)const -{ - btVector3 supVertexA = m_transA(m_shapeA->localGetSupportingVertexWithoutMargin(vec*m_transA.getBasis())); - btVector3 supVertexB = m_transB(m_shapeB->localGetSupportingVertexWithoutMargin(-vec*m_transB.getBasis())); - return supVertexA - supVertexB; -} - -void btMinkowskiSumShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const -{ - ///@todo: could make recursive use of batching. probably this shape is not used frequently. - for (int i=0;igetMargin() + m_shapeB->getMargin(); -} - - -void btMinkowskiSumShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const -{ - (void)mass; - btAssert(0); - inertia.setValue(0,0,0); -} diff --git a/bullet/src/BulletCollision/CollisionShapes/btMinkowskiSumShape.h b/bullet/src/BulletCollision/CollisionShapes/btMinkowskiSumShape.h deleted file mode 100644 index dc2433cb5..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btMinkowskiSumShape.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef MINKOWSKI_SUM_SHAPE_H -#define MINKOWSKI_SUM_SHAPE_H - -#include "btConvexInternalShape.h" -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types - -/// The btMinkowskiSumShape is only for advanced users. This shape represents implicit based minkowski sum of two convex implicit shapes. -class btMinkowskiSumShape : public btConvexInternalShape -{ - - btTransform m_transA; - btTransform m_transB; - const btConvexShape* m_shapeA; - const btConvexShape* m_shapeB; - -public: - - btMinkowskiSumShape(const btConvexShape* shapeA,const btConvexShape* shapeB); - - virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const; - - virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const; - - - virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const; - - void setTransformA(const btTransform& transA) { m_transA = transA;} - void setTransformB(const btTransform& transB) { m_transB = transB;} - - const btTransform& getTransformA()const { return m_transA;} - const btTransform& GetTransformB()const { return m_transB;} - - - virtual btScalar getMargin() const; - - const btConvexShape* getShapeA() const { return m_shapeA;} - const btConvexShape* getShapeB() const { return m_shapeB;} - - virtual const char* getName()const - { - return "MinkowskiSum"; - } -}; - -#endif //MINKOWSKI_SUM_SHAPE_H diff --git a/bullet/src/BulletCollision/CollisionShapes/btMultiSphereShape.cpp b/bullet/src/BulletCollision/CollisionShapes/btMultiSphereShape.cpp deleted file mode 100644 index 2d870b652..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btMultiSphereShape.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - - -#include "btMultiSphereShape.h" -#include "BulletCollision/CollisionShapes/btCollisionMargin.h" -#include "LinearMath/btQuaternion.h" - -btMultiSphereShape::btMultiSphereShape (const btVector3* positions,const btScalar* radi,int numSpheres) -:btConvexInternalAabbCachingShape () -{ - m_shapeType = MULTI_SPHERE_SHAPE_PROXYTYPE; - //btScalar startMargin = btScalar(BT_LARGE_FLOAT); - - m_localPositionArray.resize(numSpheres); - m_radiArray.resize(numSpheres); - for (int i=0;i maxDot) - { - maxDot = newDot; - supVec = vtx; - } - } - - return supVec; - -} - - void btMultiSphereShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const -{ - - for (int j=0;j maxDot) - { - maxDot = newDot; - supportVerticesOut[j] = vtx; - } - } - } -} - - - - - - - - -void btMultiSphereShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const -{ - //as an approximation, take the inertia of the box that bounds the spheres - - btVector3 localAabbMin,localAabbMax; - getCachedLocalAabb(localAabbMin,localAabbMax); - btVector3 halfExtents = (localAabbMax-localAabbMin)*btScalar(0.5); - - btScalar lx=btScalar(2.)*(halfExtents.x()); - btScalar ly=btScalar(2.)*(halfExtents.y()); - btScalar lz=btScalar(2.)*(halfExtents.z()); - - inertia.setValue(mass/(btScalar(12.0)) * (ly*ly + lz*lz), - mass/(btScalar(12.0)) * (lx*lx + lz*lz), - mass/(btScalar(12.0)) * (lx*lx + ly*ly)); - -} - - diff --git a/bullet/src/BulletCollision/CollisionShapes/btMultiSphereShape.h b/bullet/src/BulletCollision/CollisionShapes/btMultiSphereShape.h deleted file mode 100644 index 9cb08ba02..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btMultiSphereShape.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef MULTI_SPHERE_MINKOWSKI_H -#define MULTI_SPHERE_MINKOWSKI_H - -#include "btConvexInternalShape.h" -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types -#include "LinearMath/btAlignedObjectArray.h" -#include "LinearMath/btAabbUtil2.h" - -///The btMultiSphereShape represents the convex hull of a collection of spheres. You can create special capsules or other smooth volumes. -///It is possible to animate the spheres for deformation, but call 'recalcLocalAabb' after changing any sphere position/radius -class btMultiSphereShape : public btConvexInternalAabbCachingShape -{ - - btAlignedObjectArray m_localPositionArray; - btAlignedObjectArray m_radiArray; - -public: - btMultiSphereShape (const btVector3* positions,const btScalar* radi,int numSpheres); - - ///CollisionShape Interface - virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const; - - /// btConvexShape Interface - virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const; - - virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const; - - int getSphereCount() const - { - return m_localPositionArray.size(); - } - - const btVector3& getSpherePosition(int index) const - { - return m_localPositionArray[index]; - } - - btScalar getSphereRadius(int index) const - { - return m_radiArray[index]; - } - - - virtual const char* getName()const - { - return "MultiSphere"; - } - - -}; - - -#endif //MULTI_SPHERE_MINKOWSKI_H diff --git a/bullet/src/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.cpp b/bullet/src/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.cpp deleted file mode 100644 index 353f42699..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -/// This file was created by Alex Silverman - -#include "BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.h" -#include "BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.h" -//#include "BulletCollision/CollisionShapes/btOptimizedBvh.h" - - -///Obtains the material for a specific triangle -const btMaterial * btMultimaterialTriangleMeshShape::getMaterialProperties(int partID, int triIndex) -{ - const unsigned char * materialBase = 0; - int numMaterials; - PHY_ScalarType materialType; - int materialStride; - const unsigned char * triangleMaterialBase = 0; - int numTriangles; - int triangleMaterialStride; - PHY_ScalarType triangleType; - - ((btTriangleIndexVertexMaterialArray*)m_meshInterface)->getLockedReadOnlyMaterialBase(&materialBase, numMaterials, materialType, materialStride, - &triangleMaterialBase, numTriangles, triangleMaterialStride, triangleType, partID); - - // return the pointer to the place with the friction for the triangle - // TODO: This depends on whether it's a moving mesh or not - // BUG IN GIMPACT - //return (btScalar*)(&materialBase[triangleMaterialBase[(triIndex-1) * triangleMaterialStride] * materialStride]); - int * matInd = (int *)(&(triangleMaterialBase[(triIndex * triangleMaterialStride)])); - btMaterial *matVal = (btMaterial *)(&(materialBase[*matInd * materialStride])); - return (matVal); -} diff --git a/bullet/src/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.h b/bullet/src/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.h deleted file mode 100644 index bb6e77281..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.h +++ /dev/null @@ -1,123 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -/// This file was created by Alex Silverman - -#ifndef BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H -#define BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H - -#include "btBvhTriangleMeshShape.h" -#include "btMaterial.h" - -///The BvhTriangleMaterialMeshShape extends the btBvhTriangleMeshShape. Its main contribution is the interface into a material array, which allows per-triangle friction and restitution. -ATTRIBUTE_ALIGNED16(class) btMultimaterialTriangleMeshShape : public btBvhTriangleMeshShape -{ - btAlignedObjectArray m_materialList; - int ** m_triangleMaterials; - -public: - - BT_DECLARE_ALIGNED_ALLOCATOR(); - - btMultimaterialTriangleMeshShape(): btBvhTriangleMeshShape() {m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;} - btMultimaterialTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression, bool buildBvh = true): - btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression, buildBvh) - { - m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE; - - btVector3 m_triangle[3]; - const unsigned char *vertexbase; - int numverts; - PHY_ScalarType type; - int stride; - const unsigned char *indexbase; - int indexstride; - int numfaces; - PHY_ScalarType indicestype; - - //m_materialLookup = (int**)(btAlignedAlloc(sizeof(int*) * meshInterface->getNumSubParts(), 16)); - - for(int i = 0; i < meshInterface->getNumSubParts(); i++) - { - m_meshInterface->getLockedReadOnlyVertexIndexBase( - &vertexbase, - numverts, - type, - stride, - &indexbase, - indexstride, - numfaces, - indicestype, - i); - //m_materialLookup[i] = (int*)(btAlignedAlloc(sizeof(int) * numfaces, 16)); - } - } - - ///optionally pass in a larger bvh aabb, used for quantization. This allows for deformations within this aabb - btMultimaterialTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression,const btVector3& bvhAabbMin,const btVector3& bvhAabbMax, bool buildBvh = true): - btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression, bvhAabbMin, bvhAabbMax, buildBvh) - { - m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE; - - btVector3 m_triangle[3]; - const unsigned char *vertexbase; - int numverts; - PHY_ScalarType type; - int stride; - const unsigned char *indexbase; - int indexstride; - int numfaces; - PHY_ScalarType indicestype; - - //m_materialLookup = (int**)(btAlignedAlloc(sizeof(int*) * meshInterface->getNumSubParts(), 16)); - - for(int i = 0; i < meshInterface->getNumSubParts(); i++) - { - m_meshInterface->getLockedReadOnlyVertexIndexBase( - &vertexbase, - numverts, - type, - stride, - &indexbase, - indexstride, - numfaces, - indicestype, - i); - //m_materialLookup[i] = (int*)(btAlignedAlloc(sizeof(int) * numfaces * 2, 16)); - } - } - - virtual ~btMultimaterialTriangleMeshShape() - { -/* - for(int i = 0; i < m_meshInterface->getNumSubParts(); i++) - { - btAlignedFree(m_materialValues[i]); - m_materialLookup[i] = NULL; - } - btAlignedFree(m_materialValues); - m_materialLookup = NULL; -*/ - } - //debugging - virtual const char* getName()const {return "MULTIMATERIALTRIANGLEMESH";} - - ///Obtains the material for a specific triangle - const btMaterial * getMaterialProperties(int partID, int triIndex); - -} -; - -#endif //BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H diff --git a/bullet/src/BulletCollision/CollisionShapes/btOptimizedBvh.cpp b/bullet/src/BulletCollision/CollisionShapes/btOptimizedBvh.cpp deleted file mode 100644 index 27ce286a5..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btOptimizedBvh.cpp +++ /dev/null @@ -1,391 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#include "btOptimizedBvh.h" -#include "btStridingMeshInterface.h" -#include "LinearMath/btAabbUtil2.h" -#include "LinearMath/btIDebugDraw.h" - - -btOptimizedBvh::btOptimizedBvh() -{ -} - -btOptimizedBvh::~btOptimizedBvh() -{ -} - - -void btOptimizedBvh::build(btStridingMeshInterface* triangles, bool useQuantizedAabbCompression, const btVector3& bvhAabbMin, const btVector3& bvhAabbMax) -{ - m_useQuantization = useQuantizedAabbCompression; - - - // NodeArray triangleNodes; - - struct NodeTriangleCallback : public btInternalTriangleIndexCallback - { - - NodeArray& m_triangleNodes; - - NodeTriangleCallback& operator=(NodeTriangleCallback& other) - { - m_triangleNodes = other.m_triangleNodes; - return *this; - } - - NodeTriangleCallback(NodeArray& triangleNodes) - :m_triangleNodes(triangleNodes) - { - } - - virtual void internalProcessTriangleIndex(btVector3* triangle,int partId,int triangleIndex) - { - btOptimizedBvhNode node; - btVector3 aabbMin,aabbMax; - aabbMin.setValue(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT)); - aabbMax.setValue(btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT)); - aabbMin.setMin(triangle[0]); - aabbMax.setMax(triangle[0]); - aabbMin.setMin(triangle[1]); - aabbMax.setMax(triangle[1]); - aabbMin.setMin(triangle[2]); - aabbMax.setMax(triangle[2]); - - //with quantization? - node.m_aabbMinOrg = aabbMin; - node.m_aabbMaxOrg = aabbMax; - - node.m_escapeIndex = -1; - - //for child nodes - node.m_subPart = partId; - node.m_triangleIndex = triangleIndex; - m_triangleNodes.push_back(node); - } - }; - struct QuantizedNodeTriangleCallback : public btInternalTriangleIndexCallback - { - QuantizedNodeArray& m_triangleNodes; - const btQuantizedBvh* m_optimizedTree; // for quantization - - QuantizedNodeTriangleCallback& operator=(QuantizedNodeTriangleCallback& other) - { - m_triangleNodes = other.m_triangleNodes; - m_optimizedTree = other.m_optimizedTree; - return *this; - } - - QuantizedNodeTriangleCallback(QuantizedNodeArray& triangleNodes,const btQuantizedBvh* tree) - :m_triangleNodes(triangleNodes),m_optimizedTree(tree) - { - } - - virtual void internalProcessTriangleIndex(btVector3* triangle,int partId,int triangleIndex) - { - // The partId and triangle index must fit in the same (positive) integer - btAssert(partId < (1<=0); - - btQuantizedBvhNode node; - btVector3 aabbMin,aabbMax; - aabbMin.setValue(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT)); - aabbMax.setValue(btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT)); - aabbMin.setMin(triangle[0]); - aabbMax.setMax(triangle[0]); - aabbMin.setMin(triangle[1]); - aabbMax.setMax(triangle[1]); - aabbMin.setMin(triangle[2]); - aabbMax.setMax(triangle[2]); - - //PCK: add these checks for zero dimensions of aabb - const btScalar MIN_AABB_DIMENSION = btScalar(0.002); - const btScalar MIN_AABB_HALF_DIMENSION = btScalar(0.001); - if (aabbMax.x() - aabbMin.x() < MIN_AABB_DIMENSION) - { - aabbMax.setX(aabbMax.x() + MIN_AABB_HALF_DIMENSION); - aabbMin.setX(aabbMin.x() - MIN_AABB_HALF_DIMENSION); - } - if (aabbMax.y() - aabbMin.y() < MIN_AABB_DIMENSION) - { - aabbMax.setY(aabbMax.y() + MIN_AABB_HALF_DIMENSION); - aabbMin.setY(aabbMin.y() - MIN_AABB_HALF_DIMENSION); - } - if (aabbMax.z() - aabbMin.z() < MIN_AABB_DIMENSION) - { - aabbMax.setZ(aabbMax.z() + MIN_AABB_HALF_DIMENSION); - aabbMin.setZ(aabbMin.z() - MIN_AABB_HALF_DIMENSION); - } - - m_optimizedTree->quantize(&node.m_quantizedAabbMin[0],aabbMin,0); - m_optimizedTree->quantize(&node.m_quantizedAabbMax[0],aabbMax,1); - - node.m_escapeIndexOrTriangleIndex = (partId<<(31-MAX_NUM_PARTS_IN_BITS)) | triangleIndex; - - m_triangleNodes.push_back(node); - } - }; - - - - int numLeafNodes = 0; - - - if (m_useQuantization) - { - - //initialize quantization values - setQuantizationValues(bvhAabbMin,bvhAabbMax); - - QuantizedNodeTriangleCallback callback(m_quantizedLeafNodes,this); - - - triangles->InternalProcessAllTriangles(&callback,m_bvhAabbMin,m_bvhAabbMax); - - //now we have an array of leafnodes in m_leafNodes - numLeafNodes = m_quantizedLeafNodes.size(); - - - m_quantizedContiguousNodes.resize(2*numLeafNodes); - - - } else - { - NodeTriangleCallback callback(m_leafNodes); - - btVector3 aabbMin(btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT)); - btVector3 aabbMax(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT)); - - triangles->InternalProcessAllTriangles(&callback,aabbMin,aabbMax); - - //now we have an array of leafnodes in m_leafNodes - numLeafNodes = m_leafNodes.size(); - - m_contiguousNodes.resize(2*numLeafNodes); - } - - m_curNodeIndex = 0; - - buildTree(0,numLeafNodes); - - ///if the entire tree is small then subtree size, we need to create a header info for the tree - if(m_useQuantization && !m_SubtreeHeaders.size()) - { - btBvhSubtreeInfo& subtree = m_SubtreeHeaders.expand(); - subtree.setAabbFromQuantizeNode(m_quantizedContiguousNodes[0]); - subtree.m_rootNodeIndex = 0; - subtree.m_subtreeSize = m_quantizedContiguousNodes[0].isLeafNode() ? 1 : m_quantizedContiguousNodes[0].getEscapeIndex(); - } - - //PCK: update the copy of the size - m_subtreeHeaderCount = m_SubtreeHeaders.size(); - - //PCK: clear m_quantizedLeafNodes and m_leafNodes, they are temporary - m_quantizedLeafNodes.clear(); - m_leafNodes.clear(); -} - - - - -void btOptimizedBvh::refit(btStridingMeshInterface* meshInterface,const btVector3& aabbMin,const btVector3& aabbMax) -{ - if (m_useQuantization) - { - - setQuantizationValues(aabbMin,aabbMax); - - updateBvhNodes(meshInterface,0,m_curNodeIndex,0); - - ///now update all subtree headers - - int i; - for (i=0;i m_bvhAabbMin.getX()); - btAssert(aabbMin.getY() > m_bvhAabbMin.getY()); - btAssert(aabbMin.getZ() > m_bvhAabbMin.getZ()); - - btAssert(aabbMax.getX() < m_bvhAabbMax.getX()); - btAssert(aabbMax.getY() < m_bvhAabbMax.getY()); - btAssert(aabbMax.getZ() < m_bvhAabbMax.getZ()); - - ///we should update all quantization values, using updateBvhNodes(meshInterface); - ///but we only update chunks that overlap the given aabb - - unsigned short quantizedQueryAabbMin[3]; - unsigned short quantizedQueryAabbMax[3]; - - quantize(&quantizedQueryAabbMin[0],aabbMin,0); - quantize(&quantizedQueryAabbMax[0],aabbMax,1); - - int i; - for (i=0;im_SubtreeHeaders.size();i++) - { - btBvhSubtreeInfo& subtree = m_SubtreeHeaders[i]; - - //PCK: unsigned instead of bool - unsigned overlap = testQuantizedAabbAgainstQuantizedAabb(quantizedQueryAabbMin,quantizedQueryAabbMax,subtree.m_quantizedAabbMin,subtree.m_quantizedAabbMax); - if (overlap != 0) - { - updateBvhNodes(meshInterface,subtree.m_rootNodeIndex,subtree.m_rootNodeIndex+subtree.m_subtreeSize,i); - - subtree.setAabbFromQuantizeNode(m_quantizedContiguousNodes[subtree.m_rootNodeIndex]); - } - } - -} - -void btOptimizedBvh::updateBvhNodes(btStridingMeshInterface* meshInterface,int firstNode,int endNode,int index) -{ - (void)index; - - btAssert(m_useQuantization); - - int curNodeSubPart=-1; - - //get access info to trianglemesh data - const unsigned char *vertexbase = 0; - int numverts = 0; - PHY_ScalarType type = PHY_INTEGER; - int stride = 0; - const unsigned char *indexbase = 0; - int indexstride = 0; - int numfaces = 0; - PHY_ScalarType indicestype = PHY_INTEGER; - - btVector3 triangleVerts[3]; - btVector3 aabbMin,aabbMax; - const btVector3& meshScaling = meshInterface->getScaling(); - - int i; - for (i=endNode-1;i>=firstNode;i--) - { - - - btQuantizedBvhNode& curNode = m_quantizedContiguousNodes[i]; - if (curNode.isLeafNode()) - { - //recalc aabb from triangle data - int nodeSubPart = curNode.getPartId(); - int nodeTriangleIndex = curNode.getTriangleIndex(); - if (nodeSubPart != curNodeSubPart) - { - if (curNodeSubPart >= 0) - meshInterface->unLockReadOnlyVertexBase(curNodeSubPart); - meshInterface->getLockedReadOnlyVertexIndexBase(&vertexbase,numverts, type,stride,&indexbase,indexstride,numfaces,indicestype,nodeSubPart); - - curNodeSubPart = nodeSubPart; - btAssert(indicestype==PHY_INTEGER||indicestype==PHY_SHORT); - } - //triangles->getLockedReadOnlyVertexIndexBase(vertexBase,numVerts, - - unsigned int* gfxbase = (unsigned int*)(indexbase+nodeTriangleIndex*indexstride); - - - for (int j=2;j>=0;j--) - { - - int graphicsindex = indicestype==PHY_SHORT?((unsigned short*)gfxbase)[j]:gfxbase[j]; - if (type == PHY_FLOAT) - { - float* graphicsbase = (float*)(vertexbase+graphicsindex*stride); - triangleVerts[j] = btVector3( - graphicsbase[0]*meshScaling.getX(), - graphicsbase[1]*meshScaling.getY(), - graphicsbase[2]*meshScaling.getZ()); - } - else - { - double* graphicsbase = (double*)(vertexbase+graphicsindex*stride); - triangleVerts[j] = btVector3( btScalar(graphicsbase[0]*meshScaling.getX()), btScalar(graphicsbase[1]*meshScaling.getY()), btScalar(graphicsbase[2]*meshScaling.getZ())); - } - } - - - - aabbMin.setValue(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT)); - aabbMax.setValue(btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT)); - aabbMin.setMin(triangleVerts[0]); - aabbMax.setMax(triangleVerts[0]); - aabbMin.setMin(triangleVerts[1]); - aabbMax.setMax(triangleVerts[1]); - aabbMin.setMin(triangleVerts[2]); - aabbMax.setMax(triangleVerts[2]); - - quantize(&curNode.m_quantizedAabbMin[0],aabbMin,0); - quantize(&curNode.m_quantizedAabbMax[0],aabbMax,1); - - } else - { - //combine aabb from both children - - btQuantizedBvhNode* leftChildNode = &m_quantizedContiguousNodes[i+1]; - - btQuantizedBvhNode* rightChildNode = leftChildNode->isLeafNode() ? &m_quantizedContiguousNodes[i+2] : - &m_quantizedContiguousNodes[i+1+leftChildNode->getEscapeIndex()]; - - - { - for (int i=0;i<3;i++) - { - curNode.m_quantizedAabbMin[i] = leftChildNode->m_quantizedAabbMin[i]; - if (curNode.m_quantizedAabbMin[i]>rightChildNode->m_quantizedAabbMin[i]) - curNode.m_quantizedAabbMin[i]=rightChildNode->m_quantizedAabbMin[i]; - - curNode.m_quantizedAabbMax[i] = leftChildNode->m_quantizedAabbMax[i]; - if (curNode.m_quantizedAabbMax[i] < rightChildNode->m_quantizedAabbMax[i]) - curNode.m_quantizedAabbMax[i] = rightChildNode->m_quantizedAabbMax[i]; - } - } - } - - } - - if (curNodeSubPart >= 0) - meshInterface->unLockReadOnlyVertexBase(curNodeSubPart); - - -} - -///deSerializeInPlace loads and initializes a BVH from a buffer in memory 'in place' -btOptimizedBvh* btOptimizedBvh::deSerializeInPlace(void *i_alignedDataBuffer, unsigned int i_dataBufferSize, bool i_swapEndian) -{ - btQuantizedBvh* bvh = btQuantizedBvh::deSerializeInPlace(i_alignedDataBuffer,i_dataBufferSize,i_swapEndian); - - //we don't add additional data so just do a static upcast - return static_cast(bvh); -} diff --git a/bullet/src/BulletCollision/CollisionShapes/btOptimizedBvh.h b/bullet/src/BulletCollision/CollisionShapes/btOptimizedBvh.h deleted file mode 100644 index d8f9968e0..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btOptimizedBvh.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -///Contains contributions from Disney Studio's - -#ifndef OPTIMIZED_BVH_H -#define OPTIMIZED_BVH_H - -#include "BulletCollision/BroadphaseCollision/btQuantizedBvh.h" - -class btStridingMeshInterface; - - -///The btOptimizedBvh extends the btQuantizedBvh to create AABB tree for triangle meshes, through the btStridingMeshInterface. -ATTRIBUTE_ALIGNED16(class) btOptimizedBvh : public btQuantizedBvh -{ - -public: - BT_DECLARE_ALIGNED_ALLOCATOR(); - -protected: - -public: - - btOptimizedBvh(); - - virtual ~btOptimizedBvh(); - - void build(btStridingMeshInterface* triangles,bool useQuantizedAabbCompression, const btVector3& bvhAabbMin, const btVector3& bvhAabbMax); - - void refit(btStridingMeshInterface* triangles,const btVector3& aabbMin,const btVector3& aabbMax); - - void refitPartial(btStridingMeshInterface* triangles,const btVector3& aabbMin, const btVector3& aabbMax); - - void updateBvhNodes(btStridingMeshInterface* meshInterface,int firstNode,int endNode,int index); - - /// Data buffer MUST be 16 byte aligned - virtual bool serialize(void *o_alignedDataBuffer, unsigned i_dataBufferSize, bool i_swapEndian) const - { - return btQuantizedBvh::serialize(o_alignedDataBuffer,i_dataBufferSize,i_swapEndian); - - } - - ///deSerializeInPlace loads and initializes a BVH from a buffer in memory 'in place' - static btOptimizedBvh *deSerializeInPlace(void *i_alignedDataBuffer, unsigned int i_dataBufferSize, bool i_swapEndian); - - -}; - - -#endif //OPTIMIZED_BVH_H - - diff --git a/bullet/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp b/bullet/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp deleted file mode 100644 index 836210240..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp +++ /dev/null @@ -1,193 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "BulletCollision/CollisionShapes/btPolyhedralConvexShape.h" - -btPolyhedralConvexShape::btPolyhedralConvexShape() :btConvexInternalShape() -{ - -} - - -btVector3 btPolyhedralConvexShape::localGetSupportingVertexWithoutMargin(const btVector3& vec0)const -{ - - - btVector3 supVec(0,0,0); -#ifndef __SPU__ - int i; - btScalar maxDot(btScalar(-BT_LARGE_FLOAT)); - - btVector3 vec = vec0; - btScalar lenSqr = vec.length2(); - if (lenSqr < btScalar(0.0001)) - { - vec.setValue(1,0,0); - } else - { - btScalar rlen = btScalar(1.) / btSqrt(lenSqr ); - vec *= rlen; - } - - btVector3 vtx; - btScalar newDot; - - for (i=0;i maxDot) - { - maxDot = newDot; - supVec = vtx; - } - } - - -#endif //__SPU__ - return supVec; -} - - - -void btPolyhedralConvexShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const -{ -#ifndef __SPU__ - int i; - - btVector3 vtx; - btScalar newDot; - - for (i=0;i supportVerticesOut[j][3]) - { - //WARNING: don't swap next lines, the w component would get overwritten! - supportVerticesOut[j] = vtx; - supportVerticesOut[j][3] = newDot; - } - } - } -#endif //__SPU__ -} - - - -void btPolyhedralConvexShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const -{ -#ifndef __SPU__ - //not yet, return box inertia - - btScalar margin = getMargin(); - - btTransform ident; - ident.setIdentity(); - btVector3 aabbMin,aabbMax; - getAabb(ident,aabbMin,aabbMax); - btVector3 halfExtents = (aabbMax-aabbMin)*btScalar(0.5); - - btScalar lx=btScalar(2.)*(halfExtents.x()+margin); - btScalar ly=btScalar(2.)*(halfExtents.y()+margin); - btScalar lz=btScalar(2.)*(halfExtents.z()+margin); - const btScalar x2 = lx*lx; - const btScalar y2 = ly*ly; - const btScalar z2 = lz*lz; - const btScalar scaledmass = mass * btScalar(0.08333333); - - inertia = scaledmass * (btVector3(y2+z2,x2+z2,x2+y2)); -#endif //__SPU__ -} - - - -void btPolyhedralConvexAabbCachingShape::setLocalScaling(const btVector3& scaling) -{ - btConvexInternalShape::setLocalScaling(scaling); - recalcLocalAabb(); -} - -btPolyhedralConvexAabbCachingShape::btPolyhedralConvexAabbCachingShape() -:btPolyhedralConvexShape(), -m_localAabbMin(1,1,1), -m_localAabbMax(-1,-1,-1), -m_isLocalAabbValid(false) -{ -} - -void btPolyhedralConvexAabbCachingShape::getAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax) const -{ - getNonvirtualAabb(trans,aabbMin,aabbMax,getMargin()); -} - -void btPolyhedralConvexAabbCachingShape::recalcLocalAabb() -{ - m_isLocalAabbValid = true; - - #if 1 - static const btVector3 _directions[] = - { - btVector3( 1., 0., 0.), - btVector3( 0., 1., 0.), - btVector3( 0., 0., 1.), - btVector3( -1., 0., 0.), - btVector3( 0., -1., 0.), - btVector3( 0., 0., -1.) - }; - - btVector3 _supporting[] = - { - btVector3( 0., 0., 0.), - btVector3( 0., 0., 0.), - btVector3( 0., 0., 0.), - btVector3( 0., 0., 0.), - btVector3( 0., 0., 0.), - btVector3( 0., 0., 0.) - }; - - batchedUnitVectorGetSupportingVertexWithoutMargin(_directions, _supporting, 6); - - for ( int i = 0; i < 3; ++i ) - { - m_localAabbMax[i] = _supporting[i][i] + m_collisionMargin; - m_localAabbMin[i] = _supporting[i + 3][i] - m_collisionMargin; - } - - #else - - for (int i=0;i<3;i++) - { - btVector3 vec(btScalar(0.),btScalar(0.),btScalar(0.)); - vec[i] = btScalar(1.); - btVector3 tmp = localGetSupportingVertex(vec); - m_localAabbMax[i] = tmp[i]+m_collisionMargin; - vec[i] = btScalar(-1.); - tmp = localGetSupportingVertex(vec); - m_localAabbMin[i] = tmp[i]-m_collisionMargin; - } - #endif -} - diff --git a/bullet/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.h b/bullet/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.h deleted file mode 100644 index 9507f10f4..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.h +++ /dev/null @@ -1,98 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef BU_SHAPE -#define BU_SHAPE - -#include "LinearMath/btMatrix3x3.h" -#include "btConvexInternalShape.h" - - -///The btPolyhedralConvexShape is an internal interface class for polyhedral convex shapes. -class btPolyhedralConvexShape : public btConvexInternalShape -{ - -protected: - -public: - - btPolyhedralConvexShape(); - - //brute force implementations - - virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const; - virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const; - - virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const; - - - virtual int getNumVertices() const = 0 ; - virtual int getNumEdges() const = 0; - virtual void getEdge(int i,btVector3& pa,btVector3& pb) const = 0; - virtual void getVertex(int i,btVector3& vtx) const = 0; - virtual int getNumPlanes() const = 0; - virtual void getPlane(btVector3& planeNormal,btVector3& planeSupport,int i ) const = 0; -// virtual int getIndex(int i) const = 0 ; - - virtual bool isInside(const btVector3& pt,btScalar tolerance) const = 0; - -}; - - -///The btPolyhedralConvexAabbCachingShape adds aabb caching to the btPolyhedralConvexShape -class btPolyhedralConvexAabbCachingShape : public btPolyhedralConvexShape -{ - - btVector3 m_localAabbMin; - btVector3 m_localAabbMax; - bool m_isLocalAabbValid; - -protected: - - void setCachedLocalAabb (const btVector3& aabbMin, const btVector3& aabbMax) - { - m_isLocalAabbValid = true; - m_localAabbMin = aabbMin; - m_localAabbMax = aabbMax; - } - - inline void getCachedLocalAabb (btVector3& aabbMin, btVector3& aabbMax) const - { - btAssert(m_isLocalAabbValid); - aabbMin = m_localAabbMin; - aabbMax = m_localAabbMax; - } - -public: - - btPolyhedralConvexAabbCachingShape(); - - inline void getNonvirtualAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax, btScalar margin) const - { - - //lazy evaluation of local aabb - btAssert(m_isLocalAabbValid); - btTransformAabb(m_localAabbMin,m_localAabbMax,margin,trans,aabbMin,aabbMax); - } - - virtual void setLocalScaling(const btVector3& scaling); - - virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const; - - void recalcLocalAabb(); - -}; - -#endif //BU_SHAPE diff --git a/bullet/src/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.cpp b/bullet/src/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.cpp deleted file mode 100644 index 93f7b92e0..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#include "btScaledBvhTriangleMeshShape.h" - -btScaledBvhTriangleMeshShape::btScaledBvhTriangleMeshShape(btBvhTriangleMeshShape* childShape,const btVector3& localScaling) -:m_localScaling(localScaling),m_bvhTriMeshShape(childShape) -{ - m_shapeType = SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE; -} - -btScaledBvhTriangleMeshShape::~btScaledBvhTriangleMeshShape() -{ -} - - -class btScaledTriangleCallback : public btTriangleCallback -{ - btTriangleCallback* m_originalCallback; - - btVector3 m_localScaling; - -public: - - btScaledTriangleCallback(btTriangleCallback* originalCallback,const btVector3& localScaling) - :m_originalCallback(originalCallback), - m_localScaling(localScaling) - { - } - - virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex) - { - btVector3 newTriangle[3]; - newTriangle[0] = triangle[0]*m_localScaling; - newTriangle[1] = triangle[1]*m_localScaling; - newTriangle[2] = triangle[2]*m_localScaling; - m_originalCallback->processTriangle(&newTriangle[0],partId,triangleIndex); - } -}; - -void btScaledBvhTriangleMeshShape::processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const -{ - btScaledTriangleCallback scaledCallback(callback,m_localScaling); - - btVector3 invLocalScaling(1.f/m_localScaling.getX(),1.f/m_localScaling.getY(),1.f/m_localScaling.getZ()); - btVector3 scaledAabbMin,scaledAabbMax; - - ///support negative scaling - scaledAabbMin[0] = m_localScaling.getX() >= 0. ? aabbMin[0] * invLocalScaling[0] : aabbMax[0] * invLocalScaling[0]; - scaledAabbMin[1] = m_localScaling.getY() >= 0. ? aabbMin[1] * invLocalScaling[1] : aabbMax[1] * invLocalScaling[1]; - scaledAabbMin[2] = m_localScaling.getZ() >= 0. ? aabbMin[2] * invLocalScaling[2] : aabbMax[2] * invLocalScaling[2]; - - scaledAabbMax[0] = m_localScaling.getX() <= 0. ? aabbMin[0] * invLocalScaling[0] : aabbMax[0] * invLocalScaling[0]; - scaledAabbMax[1] = m_localScaling.getY() <= 0. ? aabbMin[1] * invLocalScaling[1] : aabbMax[1] * invLocalScaling[1]; - scaledAabbMax[2] = m_localScaling.getZ() <= 0. ? aabbMin[2] * invLocalScaling[2] : aabbMax[2] * invLocalScaling[2]; - - - m_bvhTriMeshShape->processAllTriangles(&scaledCallback,scaledAabbMin,scaledAabbMax); -} - - -void btScaledBvhTriangleMeshShape::getAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax) const -{ - btVector3 localAabbMin = m_bvhTriMeshShape->getLocalAabbMin(); - btVector3 localAabbMax = m_bvhTriMeshShape->getLocalAabbMax(); - - btVector3 tmpLocalAabbMin = localAabbMin * m_localScaling; - btVector3 tmpLocalAabbMax = localAabbMax * m_localScaling; - - localAabbMin[0] = (m_localScaling.getX() >= 0.) ? tmpLocalAabbMin[0] : tmpLocalAabbMax[0]; - localAabbMin[1] = (m_localScaling.getY() >= 0.) ? tmpLocalAabbMin[1] : tmpLocalAabbMax[1]; - localAabbMin[2] = (m_localScaling.getZ() >= 0.) ? tmpLocalAabbMin[2] : tmpLocalAabbMax[2]; - localAabbMax[0] = (m_localScaling.getX() <= 0.) ? tmpLocalAabbMin[0] : tmpLocalAabbMax[0]; - localAabbMax[1] = (m_localScaling.getY() <= 0.) ? tmpLocalAabbMin[1] : tmpLocalAabbMax[1]; - localAabbMax[2] = (m_localScaling.getZ() <= 0.) ? tmpLocalAabbMin[2] : tmpLocalAabbMax[2]; - - btVector3 localHalfExtents = btScalar(0.5)*(localAabbMax-localAabbMin); - btScalar margin = m_bvhTriMeshShape->getMargin(); - localHalfExtents += btVector3(margin,margin,margin); - btVector3 localCenter = btScalar(0.5)*(localAabbMax+localAabbMin); - - btMatrix3x3 abs_b = trans.getBasis().absolute(); - - btVector3 center = trans(localCenter); - - btVector3 extent = btVector3(abs_b[0].dot(localHalfExtents), - abs_b[1].dot(localHalfExtents), - abs_b[2].dot(localHalfExtents)); - aabbMin = center - extent; - aabbMax = center + extent; - -} - -void btScaledBvhTriangleMeshShape::setLocalScaling(const btVector3& scaling) -{ - m_localScaling = scaling; -} - -const btVector3& btScaledBvhTriangleMeshShape::getLocalScaling() const -{ - return m_localScaling; -} - -void btScaledBvhTriangleMeshShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const -{ - ///don't make this a movable object! -// btAssert(0); -} diff --git a/bullet/src/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h b/bullet/src/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h deleted file mode 100644 index 63b591fae..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef SCALED_BVH_TRIANGLE_MESH_SHAPE_H -#define SCALED_BVH_TRIANGLE_MESH_SHAPE_H - -#include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h" - - -///The btScaledBvhTriangleMeshShape allows to instance a scaled version of an existing btBvhTriangleMeshShape. -///Note that each btBvhTriangleMeshShape still can have its own local scaling, independent from this btScaledBvhTriangleMeshShape 'localScaling' -ATTRIBUTE_ALIGNED16(class) btScaledBvhTriangleMeshShape : public btConcaveShape -{ - - - btVector3 m_localScaling; - - btBvhTriangleMeshShape* m_bvhTriMeshShape; - -public: - - - btScaledBvhTriangleMeshShape(btBvhTriangleMeshShape* childShape,const btVector3& localScaling); - - virtual ~btScaledBvhTriangleMeshShape(); - - - virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const; - virtual void setLocalScaling(const btVector3& scaling); - virtual const btVector3& getLocalScaling() const; - virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const; - - virtual void processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const; - - btBvhTriangleMeshShape* getChildShape() - { - return m_bvhTriMeshShape; - } - - const btBvhTriangleMeshShape* getChildShape() const - { - return m_bvhTriMeshShape; - } - - //debugging - virtual const char* getName()const {return "SCALEDBVHTRIANGLEMESH";} - -}; - -#endif //BVH_TRIANGLE_MESH_SHAPE_H diff --git a/bullet/src/BulletCollision/CollisionShapes/btShapeHull.cpp b/bullet/src/BulletCollision/CollisionShapes/btShapeHull.cpp deleted file mode 100644 index 126543dc5..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btShapeHull.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -//btShapeHull was implemented by John McCutchan. - - -#include "btShapeHull.h" -#include "LinearMath/btConvexHull.h" - -#define NUM_UNITSPHERE_POINTS 42 - -static btVector3 btUnitSpherePoints[NUM_UNITSPHERE_POINTS+MAX_PREFERRED_PENETRATION_DIRECTIONS*2] = -{ - btVector3(btScalar(0.000000) , btScalar(-0.000000),btScalar(-1.000000)), - btVector3(btScalar(0.723608) , btScalar(-0.525725),btScalar(-0.447219)), - btVector3(btScalar(-0.276388) , btScalar(-0.850649),btScalar(-0.447219)), - btVector3(btScalar(-0.894426) , btScalar(-0.000000),btScalar(-0.447216)), - btVector3(btScalar(-0.276388) , btScalar(0.850649),btScalar(-0.447220)), - btVector3(btScalar(0.723608) , btScalar(0.525725),btScalar(-0.447219)), - btVector3(btScalar(0.276388) , btScalar(-0.850649),btScalar(0.447220)), - btVector3(btScalar(-0.723608) , btScalar(-0.525725),btScalar(0.447219)), - btVector3(btScalar(-0.723608) , btScalar(0.525725),btScalar(0.447219)), - btVector3(btScalar(0.276388) , btScalar(0.850649),btScalar(0.447219)), - btVector3(btScalar(0.894426) , btScalar(0.000000),btScalar(0.447216)), - btVector3(btScalar(-0.000000) , btScalar(0.000000),btScalar(1.000000)), - btVector3(btScalar(0.425323) , btScalar(-0.309011),btScalar(-0.850654)), - btVector3(btScalar(-0.162456) , btScalar(-0.499995),btScalar(-0.850654)), - btVector3(btScalar(0.262869) , btScalar(-0.809012),btScalar(-0.525738)), - btVector3(btScalar(0.425323) , btScalar(0.309011),btScalar(-0.850654)), - btVector3(btScalar(0.850648) , btScalar(-0.000000),btScalar(-0.525736)), - btVector3(btScalar(-0.525730) , btScalar(-0.000000),btScalar(-0.850652)), - btVector3(btScalar(-0.688190) , btScalar(-0.499997),btScalar(-0.525736)), - btVector3(btScalar(-0.162456) , btScalar(0.499995),btScalar(-0.850654)), - btVector3(btScalar(-0.688190) , btScalar(0.499997),btScalar(-0.525736)), - btVector3(btScalar(0.262869) , btScalar(0.809012),btScalar(-0.525738)), - btVector3(btScalar(0.951058) , btScalar(0.309013),btScalar(0.000000)), - btVector3(btScalar(0.951058) , btScalar(-0.309013),btScalar(0.000000)), - btVector3(btScalar(0.587786) , btScalar(-0.809017),btScalar(0.000000)), - btVector3(btScalar(0.000000) , btScalar(-1.000000),btScalar(0.000000)), - btVector3(btScalar(-0.587786) , btScalar(-0.809017),btScalar(0.000000)), - btVector3(btScalar(-0.951058) , btScalar(-0.309013),btScalar(-0.000000)), - btVector3(btScalar(-0.951058) , btScalar(0.309013),btScalar(-0.000000)), - btVector3(btScalar(-0.587786) , btScalar(0.809017),btScalar(-0.000000)), - btVector3(btScalar(-0.000000) , btScalar(1.000000),btScalar(-0.000000)), - btVector3(btScalar(0.587786) , btScalar(0.809017),btScalar(-0.000000)), - btVector3(btScalar(0.688190) , btScalar(-0.499997),btScalar(0.525736)), - btVector3(btScalar(-0.262869) , btScalar(-0.809012),btScalar(0.525738)), - btVector3(btScalar(-0.850648) , btScalar(0.000000),btScalar(0.525736)), - btVector3(btScalar(-0.262869) , btScalar(0.809012),btScalar(0.525738)), - btVector3(btScalar(0.688190) , btScalar(0.499997),btScalar(0.525736)), - btVector3(btScalar(0.525730) , btScalar(0.000000),btScalar(0.850652)), - btVector3(btScalar(0.162456) , btScalar(-0.499995),btScalar(0.850654)), - btVector3(btScalar(-0.425323) , btScalar(-0.309011),btScalar(0.850654)), - btVector3(btScalar(-0.425323) , btScalar(0.309011),btScalar(0.850654)), - btVector3(btScalar(0.162456) , btScalar(0.499995),btScalar(0.850654)) -}; - -btShapeHull::btShapeHull (const btConvexShape* shape) -{ - m_shape = shape; - m_vertices.clear (); - m_indices.clear(); - m_numIndices = 0; -} - -btShapeHull::~btShapeHull () -{ - m_indices.clear(); - m_vertices.clear (); -} - -bool -btShapeHull::buildHull (btScalar /*margin*/) -{ - int numSampleDirections = NUM_UNITSPHERE_POINTS; - { - int numPDA = m_shape->getNumPreferredPenetrationDirections(); - if (numPDA) - { - for (int i=0;igetPreferredPenetrationDirection(i,norm); - btUnitSpherePoints[numSampleDirections] = norm; - numSampleDirections++; - } - } - } - - btVector3 supportPoints[NUM_UNITSPHERE_POINTS+MAX_PREFERRED_PENETRATION_DIRECTIONS*2]; - int i; - for (i = 0; i < numSampleDirections; i++) - { - supportPoints[i] = m_shape->localGetSupportingVertex(btUnitSpherePoints[i]); - } - - HullDesc hd; - hd.mFlags = QF_TRIANGLES; - hd.mVcount = static_cast(numSampleDirections); - -#ifdef BT_USE_DOUBLE_PRECISION - hd.mVertices = &supportPoints[0]; - hd.mVertexStride = sizeof(btVector3); -#else - hd.mVertices = &supportPoints[0]; - hd.mVertexStride = sizeof (btVector3); -#endif - - HullLibrary hl; - HullResult hr; - if (hl.CreateConvexHull (hd, hr) == QE_FAIL) - { - return false; - } - - m_vertices.resize (static_cast(hr.mNumOutputVertices)); - - - for (i = 0; i < static_cast(hr.mNumOutputVertices); i++) - { - m_vertices[i] = hr.m_OutputVertices[i]; - } - m_numIndices = hr.mNumIndices; - m_indices.resize(static_cast(m_numIndices)); - for (i = 0; i < static_cast(m_numIndices); i++) - { - m_indices[i] = hr.m_Indices[i]; - } - - // free temporary hull result that we just copied - hl.ReleaseResult (hr); - - return true; -} - -int -btShapeHull::numTriangles () const -{ - return static_cast(m_numIndices / 3); -} - -int -btShapeHull::numVertices () const -{ - return m_vertices.size (); -} - -int -btShapeHull::numIndices () const -{ - return static_cast(m_numIndices); -} - diff --git a/bullet/src/BulletCollision/CollisionShapes/btShapeHull.h b/bullet/src/BulletCollision/CollisionShapes/btShapeHull.h deleted file mode 100644 index cc9412389..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btShapeHull.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -///btShapeHull implemented by John McCutchan. - -#ifndef _SHAPE_HULL_H -#define _SHAPE_HULL_H - -#include "LinearMath/btAlignedObjectArray.h" -#include "BulletCollision/CollisionShapes/btConvexShape.h" - - -///The btShapeHull class takes a btConvexShape, builds a simplified convex hull using btConvexHull and provides triangle indices and vertices. -///It can be useful for to simplify a complex convex object and for visualization of a non-polyhedral convex object. -///It approximates the convex hull using the supporting vertex of 42 directions. -class btShapeHull -{ -public: - btShapeHull (const btConvexShape* shape); - ~btShapeHull (); - - bool buildHull (btScalar margin); - - int numTriangles () const; - int numVertices () const; - int numIndices () const; - - const btVector3* getVertexPointer() const - { - return &m_vertices[0]; - } - const unsigned int* getIndexPointer() const - { - return &m_indices[0]; - } - -protected: - btAlignedObjectArray m_vertices; - btAlignedObjectArray m_indices; - unsigned int m_numIndices; - const btConvexShape* m_shape; -}; - -#endif //_SHAPE_HULL_H diff --git a/bullet/src/BulletCollision/CollisionShapes/btSphereShape.cpp b/bullet/src/BulletCollision/CollisionShapes/btSphereShape.cpp deleted file mode 100644 index 8da9c5143..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btSphereShape.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btSphereShape.h" -#include "BulletCollision/CollisionShapes/btCollisionMargin.h" - -#include "LinearMath/btQuaternion.h" - -btVector3 btSphereShape::localGetSupportingVertexWithoutMargin(const btVector3& vec)const -{ - (void)vec; - return btVector3(btScalar(0.),btScalar(0.),btScalar(0.)); -} - -void btSphereShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const -{ - (void)vectors; - - for (int i=0;iprocessTriangle(triangle,0,0); - - triangle[0] = projectedCenter - tangentDir0*radius - tangentDir1*radius; - triangle[1] = projectedCenter - tangentDir0*radius + tangentDir1*radius; - triangle[2] = projectedCenter + tangentDir0*radius + tangentDir1*radius; - - callback->processTriangle(triangle,0,1); - -} - -void btStaticPlaneShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const -{ - (void)mass; - - //moving concave objects not supported - - inertia.setValue(btScalar(0.),btScalar(0.),btScalar(0.)); -} - -void btStaticPlaneShape::setLocalScaling(const btVector3& scaling) -{ - m_localScaling = scaling; -} -const btVector3& btStaticPlaneShape::getLocalScaling() const -{ - return m_localScaling; -} diff --git a/bullet/src/BulletCollision/CollisionShapes/btStaticPlaneShape.h b/bullet/src/BulletCollision/CollisionShapes/btStaticPlaneShape.h deleted file mode 100644 index a4b6eaa52..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btStaticPlaneShape.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef STATIC_PLANE_SHAPE_H -#define STATIC_PLANE_SHAPE_H - -#include "btConcaveShape.h" - - -///The btStaticPlaneShape simulates an infinite non-moving (static) collision plane. -class btStaticPlaneShape : public btConcaveShape -{ -protected: - btVector3 m_localAabbMin; - btVector3 m_localAabbMax; - - btVector3 m_planeNormal; - btScalar m_planeConstant; - btVector3 m_localScaling; - -public: - btStaticPlaneShape(const btVector3& planeNormal,btScalar planeConstant); - - virtual ~btStaticPlaneShape(); - - - virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const; - - virtual void processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const; - - virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const; - - virtual void setLocalScaling(const btVector3& scaling); - virtual const btVector3& getLocalScaling() const; - - const btVector3& getPlaneNormal() const - { - return m_planeNormal; - } - - const btScalar& getPlaneConstant() const - { - return m_planeConstant; - } - - //debugging - virtual const char* getName()const {return "STATICPLANE";} - - -}; - -#endif //STATIC_PLANE_SHAPE_H diff --git a/bullet/src/BulletCollision/CollisionShapes/btStridingMeshInterface.cpp b/bullet/src/BulletCollision/CollisionShapes/btStridingMeshInterface.cpp deleted file mode 100644 index 1cd0762b0..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btStridingMeshInterface.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btStridingMeshInterface.h" - -btStridingMeshInterface::~btStridingMeshInterface() -{ - -} - - -void btStridingMeshInterface::InternalProcessAllTriangles(btInternalTriangleIndexCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const -{ - (void)aabbMin; - (void)aabbMax; - int numtotalphysicsverts = 0; - int part,graphicssubparts = getNumSubParts(); - const unsigned char * vertexbase; - const unsigned char * indexbase; - int indexstride; - PHY_ScalarType type; - PHY_ScalarType gfxindextype; - int stride,numverts,numtriangles; - int gfxindex; - btVector3 triangle[3]; - - btVector3 meshScaling = getScaling(); - - ///if the number of parts is big, the performance might drop due to the innerloop switch on indextype - for (part=0;partinternalProcessTriangleIndex(triangle,part,gfxindex); - } - break; - } - case PHY_SHORT: - { - for (gfxindex=0;gfxindexinternalProcessTriangleIndex(triangle,part,gfxindex); - } - break; - } - default: - btAssert((gfxindextype == PHY_INTEGER) || (gfxindextype == PHY_SHORT)); - } - break; - } - - case PHY_DOUBLE: - { - double* graphicsbase; - - switch (gfxindextype) - { - case PHY_INTEGER: - { - for (gfxindex=0;gfxindexinternalProcessTriangleIndex(triangle,part,gfxindex); - } - break; - } - case PHY_SHORT: - { - for (gfxindex=0;gfxindexinternalProcessTriangleIndex(triangle,part,gfxindex); - } - break; - } - default: - btAssert((gfxindextype == PHY_INTEGER) || (gfxindextype == PHY_SHORT)); - } - break; - } - default: - btAssert((type == PHY_FLOAT) || (type == PHY_DOUBLE)); - } - - unLockReadOnlyVertexBase(part); - } -} - -void btStridingMeshInterface::calculateAabbBruteForce(btVector3& aabbMin,btVector3& aabbMax) -{ - - struct AabbCalculationCallback : public btInternalTriangleIndexCallback - { - btVector3 m_aabbMin; - btVector3 m_aabbMax; - - AabbCalculationCallback() - { - m_aabbMin.setValue(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT)); - m_aabbMax.setValue(btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT)); - } - - virtual void internalProcessTriangleIndex(btVector3* triangle,int partId,int triangleIndex) - { - (void)partId; - (void)triangleIndex; - - m_aabbMin.setMin(triangle[0]); - m_aabbMax.setMax(triangle[0]); - m_aabbMin.setMin(triangle[1]); - m_aabbMax.setMax(triangle[1]); - m_aabbMin.setMin(triangle[2]); - m_aabbMax.setMax(triangle[2]); - } - }; - - //first calculate the total aabb for all triangles - AabbCalculationCallback aabbCallback; - aabbMin.setValue(btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT)); - aabbMax.setValue(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT)); - InternalProcessAllTriangles(&aabbCallback,aabbMin,aabbMax); - - aabbMin = aabbCallback.m_aabbMin; - aabbMax = aabbCallback.m_aabbMax; -} diff --git a/bullet/src/BulletCollision/CollisionShapes/btStridingMeshInterface.h b/bullet/src/BulletCollision/CollisionShapes/btStridingMeshInterface.h deleted file mode 100644 index 331d9ee18..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btStridingMeshInterface.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef STRIDING_MESHINTERFACE_H -#define STRIDING_MESHINTERFACE_H - -#include "LinearMath/btVector3.h" -#include "btTriangleCallback.h" -#include "btConcaveShape.h" - - - -/// The btStridingMeshInterface is the interface class for high performance generic access to triangle meshes, used in combination with btBvhTriangleMeshShape and some other collision shapes. -/// Using index striding of 3*sizeof(integer) it can use triangle arrays, using index striding of 1*sizeof(integer) it can handle triangle strips. -/// It allows for sharing graphics and collision meshes. Also it provides locking/unlocking of graphics meshes that are in gpu memory. -class btStridingMeshInterface -{ - protected: - - btVector3 m_scaling; - - public: - btStridingMeshInterface() :m_scaling(btScalar(1.),btScalar(1.),btScalar(1.)) - { - - } - - virtual ~btStridingMeshInterface(); - - - - virtual void InternalProcessAllTriangles(btInternalTriangleIndexCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const; - - ///brute force method to calculate aabb - void calculateAabbBruteForce(btVector3& aabbMin,btVector3& aabbMax); - - /// get read and write access to a subpart of a triangle mesh - /// this subpart has a continuous array of vertices and indices - /// in this way the mesh can be handled as chunks of memory with striding - /// very similar to OpenGL vertexarray support - /// make a call to unLockVertexBase when the read and write access is finished - virtual void getLockedVertexIndexBase(unsigned char **vertexbase, int& numverts,PHY_ScalarType& type, int& stride,unsigned char **indexbase,int & indexstride,int& numfaces,PHY_ScalarType& indicestype,int subpart=0)=0; - - virtual void getLockedReadOnlyVertexIndexBase(const unsigned char **vertexbase, int& numverts,PHY_ScalarType& type, int& stride,const unsigned char **indexbase,int & indexstride,int& numfaces,PHY_ScalarType& indicestype,int subpart=0) const=0; - - /// unLockVertexBase finishes the access to a subpart of the triangle mesh - /// make a call to unLockVertexBase when the read and write access (using getLockedVertexIndexBase) is finished - virtual void unLockVertexBase(int subpart)=0; - - virtual void unLockReadOnlyVertexBase(int subpart) const=0; - - - /// getNumSubParts returns the number of seperate subparts - /// each subpart has a continuous array of vertices and indices - virtual int getNumSubParts() const=0; - - virtual void preallocateVertices(int numverts)=0; - virtual void preallocateIndices(int numindices)=0; - - virtual bool hasPremadeAabb() const { return false; } - virtual void setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax ) const - { - (void) aabbMin; - (void) aabbMax; - } - virtual void getPremadeAabb(btVector3* aabbMin, btVector3* aabbMax ) const - { - (void) aabbMin; - (void) aabbMax; - } - - const btVector3& getScaling() const { - return m_scaling; - } - void setScaling(const btVector3& scaling) - { - m_scaling = scaling; - } - - - -}; - -#endif //STRIDING_MESHINTERFACE_H diff --git a/bullet/src/BulletCollision/CollisionShapes/btTetrahedronShape.cpp b/bullet/src/BulletCollision/CollisionShapes/btTetrahedronShape.cpp deleted file mode 100644 index 0837124aa..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btTetrahedronShape.cpp +++ /dev/null @@ -1,218 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btTetrahedronShape.h" -#include "LinearMath/btMatrix3x3.h" - -btBU_Simplex1to4::btBU_Simplex1to4() : btPolyhedralConvexAabbCachingShape (), -m_numVertices(0) -{ - m_shapeType = TETRAHEDRAL_SHAPE_PROXYTYPE; -} - -btBU_Simplex1to4::btBU_Simplex1to4(const btVector3& pt0) : btPolyhedralConvexAabbCachingShape (), -m_numVertices(0) -{ - m_shapeType = TETRAHEDRAL_SHAPE_PROXYTYPE; - addVertex(pt0); -} - -btBU_Simplex1to4::btBU_Simplex1to4(const btVector3& pt0,const btVector3& pt1) : btPolyhedralConvexAabbCachingShape (), -m_numVertices(0) -{ - m_shapeType = TETRAHEDRAL_SHAPE_PROXYTYPE; - addVertex(pt0); - addVertex(pt1); -} - -btBU_Simplex1to4::btBU_Simplex1to4(const btVector3& pt0,const btVector3& pt1,const btVector3& pt2) : btPolyhedralConvexAabbCachingShape (), -m_numVertices(0) -{ - m_shapeType = TETRAHEDRAL_SHAPE_PROXYTYPE; - addVertex(pt0); - addVertex(pt1); - addVertex(pt2); -} - -btBU_Simplex1to4::btBU_Simplex1to4(const btVector3& pt0,const btVector3& pt1,const btVector3& pt2,const btVector3& pt3) : btPolyhedralConvexAabbCachingShape (), -m_numVertices(0) -{ - m_shapeType = TETRAHEDRAL_SHAPE_PROXYTYPE; - addVertex(pt0); - addVertex(pt1); - addVertex(pt2); - addVertex(pt3); -} - - -void btBU_Simplex1to4::getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const -{ -#if 1 - btPolyhedralConvexAabbCachingShape::getAabb(t,aabbMin,aabbMax); -#else - aabbMin.setValue(BT_LARGE_FLOAT,BT_LARGE_FLOAT,BT_LARGE_FLOAT); - aabbMax.setValue(-BT_LARGE_FLOAT,-BT_LARGE_FLOAT,-BT_LARGE_FLOAT); - - //just transform the vertices in worldspace, and take their AABB - for (int i=0;iprocessAllTriangles(&triBuf,aabbMin, aabbMax); -/// for (int i=0;i m_triangleBuffer; - -public: - - - virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex); - - int getNumTriangles() const - { - return int(m_triangleBuffer.size()); - } - - const btTriangle& getTriangle(int index) const - { - return m_triangleBuffer[index]; - } - - void clearBuffer() - { - m_triangleBuffer.clear(); - } - -}; - - -#endif //BT_TRIANGLE_BUFFER_H - diff --git a/bullet/src/BulletCollision/CollisionShapes/btTriangleCallback.cpp b/bullet/src/BulletCollision/CollisionShapes/btTriangleCallback.cpp deleted file mode 100644 index 2426599aa..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btTriangleCallback.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btTriangleCallback.h" - -btTriangleCallback::~btTriangleCallback() -{ - -} - - -btInternalTriangleIndexCallback::~btInternalTriangleIndexCallback() -{ - -} - diff --git a/bullet/src/BulletCollision/CollisionShapes/btTriangleCallback.h b/bullet/src/BulletCollision/CollisionShapes/btTriangleCallback.h deleted file mode 100644 index b99adbd63..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btTriangleCallback.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef TRIANGLE_CALLBACK_H -#define TRIANGLE_CALLBACK_H - -#include "LinearMath/btVector3.h" - - -///The btTriangleCallback provides a callback for each overlapping triangle when calling processAllTriangles. -///This callback is called by processAllTriangles for all btConcaveShape derived class, such as btBvhTriangleMeshShape, btStaticPlaneShape and btHeightfieldTerrainShape. -class btTriangleCallback -{ -public: - - virtual ~btTriangleCallback(); - virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex) = 0; -}; - -class btInternalTriangleIndexCallback -{ -public: - - virtual ~btInternalTriangleIndexCallback(); - virtual void internalProcessTriangleIndex(btVector3* triangle,int partId,int triangleIndex) = 0; -}; - - - -#endif //TRIANGLE_CALLBACK_H diff --git a/bullet/src/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.cpp b/bullet/src/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.cpp deleted file mode 100644 index 770615e44..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btTriangleIndexVertexArray.h" - -btTriangleIndexVertexArray::btTriangleIndexVertexArray(int numTriangles,int* triangleIndexBase,int triangleIndexStride,int numVertices,btScalar* vertexBase,int vertexStride) -: m_hasAabb(0) -{ - btIndexedMesh mesh; - - mesh.m_numTriangles = numTriangles; - mesh.m_triangleIndexBase = (const unsigned char *)triangleIndexBase; - mesh.m_triangleIndexStride = triangleIndexStride; - mesh.m_numVertices = numVertices; - mesh.m_vertexBase = (const unsigned char *)vertexBase; - mesh.m_vertexStride = vertexStride; - - addIndexedMesh(mesh); - -} - -btTriangleIndexVertexArray::~btTriangleIndexVertexArray() -{ - -} - -void btTriangleIndexVertexArray::getLockedVertexIndexBase(unsigned char **vertexbase, int& numverts,PHY_ScalarType& type, int& vertexStride,unsigned char **indexbase,int & indexstride,int& numfaces,PHY_ScalarType& indicestype,int subpart) -{ - btAssert(subpart< getNumSubParts() ); - - btIndexedMesh& mesh = m_indexedMeshes[subpart]; - - numverts = mesh.m_numVertices; - (*vertexbase) = (unsigned char *) mesh.m_vertexBase; - - type = mesh.m_vertexType; - - vertexStride = mesh.m_vertexStride; - - numfaces = mesh.m_numTriangles; - - (*indexbase) = (unsigned char *)mesh.m_triangleIndexBase; - indexstride = mesh.m_triangleIndexStride; - indicestype = mesh.m_indexType; -} - -void btTriangleIndexVertexArray::getLockedReadOnlyVertexIndexBase(const unsigned char **vertexbase, int& numverts,PHY_ScalarType& type, int& vertexStride,const unsigned char **indexbase,int & indexstride,int& numfaces,PHY_ScalarType& indicestype,int subpart) const -{ - const btIndexedMesh& mesh = m_indexedMeshes[subpart]; - - numverts = mesh.m_numVertices; - (*vertexbase) = (const unsigned char *)mesh.m_vertexBase; - - type = mesh.m_vertexType; - - vertexStride = mesh.m_vertexStride; - - numfaces = mesh.m_numTriangles; - (*indexbase) = (const unsigned char *)mesh.m_triangleIndexBase; - indexstride = mesh.m_triangleIndexStride; - indicestype = mesh.m_indexType; -} - -bool btTriangleIndexVertexArray::hasPremadeAabb() const -{ - return (m_hasAabb == 1); -} - - -void btTriangleIndexVertexArray::setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax ) const -{ - m_aabbMin = aabbMin; - m_aabbMax = aabbMax; - m_hasAabb = 1; // this is intentionally an int see notes in header -} - -void btTriangleIndexVertexArray::getPremadeAabb(btVector3* aabbMin, btVector3* aabbMax ) const -{ - *aabbMin = m_aabbMin; - *aabbMax = m_aabbMax; -} - - diff --git a/bullet/src/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.h b/bullet/src/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.h deleted file mode 100644 index bf007cbf2..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.h +++ /dev/null @@ -1,131 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef BT_TRIANGLE_INDEX_VERTEX_ARRAY_H -#define BT_TRIANGLE_INDEX_VERTEX_ARRAY_H - -#include "btStridingMeshInterface.h" -#include "LinearMath/btAlignedObjectArray.h" -#include "LinearMath/btScalar.h" - - -///The btIndexedMesh indexes a single vertex and index array. Multiple btIndexedMesh objects can be passed into a btTriangleIndexVertexArray using addIndexedMesh. -///Instead of the number of indices, we pass the number of triangles. -ATTRIBUTE_ALIGNED16( struct) btIndexedMesh -{ - BT_DECLARE_ALIGNED_ALLOCATOR(); - - int m_numTriangles; - const unsigned char * m_triangleIndexBase; - int m_triangleIndexStride; - int m_numVertices; - const unsigned char * m_vertexBase; - int m_vertexStride; - - // The index type is set when adding an indexed mesh to the - // btTriangleIndexVertexArray, do not set it manually - PHY_ScalarType m_indexType; - - // The vertex type has a default type similar to Bullet's precision mode (float or double) - // but can be set manually if you for example run Bullet with double precision but have - // mesh data in single precision.. - PHY_ScalarType m_vertexType; - - - btIndexedMesh() - :m_indexType(PHY_INTEGER), -#ifdef BT_USE_DOUBLE_PRECISION - m_vertexType(PHY_DOUBLE) -#else // BT_USE_DOUBLE_PRECISION - m_vertexType(PHY_FLOAT) -#endif // BT_USE_DOUBLE_PRECISION - { - } -} -; - - -typedef btAlignedObjectArray IndexedMeshArray; - -///The btTriangleIndexVertexArray allows to access multiple triangle meshes, by indexing into existing triangle/index arrays. -///Additional meshes can be added using addIndexedMesh -///No duplcate is made of the vertex/index data, it only indexes into external vertex/index arrays. -///So keep those arrays around during the lifetime of this btTriangleIndexVertexArray. -ATTRIBUTE_ALIGNED16( class) btTriangleIndexVertexArray : public btStridingMeshInterface -{ -protected: - IndexedMeshArray m_indexedMeshes; - int m_pad[2]; - mutable int m_hasAabb; // using int instead of bool to maintain alignment - mutable btVector3 m_aabbMin; - mutable btVector3 m_aabbMax; - -public: - - BT_DECLARE_ALIGNED_ALLOCATOR(); - - btTriangleIndexVertexArray() : m_hasAabb(0) - { - } - - virtual ~btTriangleIndexVertexArray(); - - //just to be backwards compatible - btTriangleIndexVertexArray(int numTriangles,int* triangleIndexBase,int triangleIndexStride,int numVertices,btScalar* vertexBase,int vertexStride); - - void addIndexedMesh(const btIndexedMesh& mesh, PHY_ScalarType indexType = PHY_INTEGER) - { - m_indexedMeshes.push_back(mesh); - m_indexedMeshes[m_indexedMeshes.size()-1].m_indexType = indexType; - } - - - virtual void getLockedVertexIndexBase(unsigned char **vertexbase, int& numverts,PHY_ScalarType& type, int& vertexStride,unsigned char **indexbase,int & indexstride,int& numfaces,PHY_ScalarType& indicestype,int subpart=0); - - virtual void getLockedReadOnlyVertexIndexBase(const unsigned char **vertexbase, int& numverts,PHY_ScalarType& type, int& vertexStride,const unsigned char **indexbase,int & indexstride,int& numfaces,PHY_ScalarType& indicestype,int subpart=0) const; - - /// unLockVertexBase finishes the access to a subpart of the triangle mesh - /// make a call to unLockVertexBase when the read and write access (using getLockedVertexIndexBase) is finished - virtual void unLockVertexBase(int subpart) {(void)subpart;} - - virtual void unLockReadOnlyVertexBase(int subpart) const {(void)subpart;} - - /// getNumSubParts returns the number of seperate subparts - /// each subpart has a continuous array of vertices and indices - virtual int getNumSubParts() const { - return (int)m_indexedMeshes.size(); - } - - IndexedMeshArray& getIndexedMeshArray() - { - return m_indexedMeshes; - } - - const IndexedMeshArray& getIndexedMeshArray() const - { - return m_indexedMeshes; - } - - virtual void preallocateVertices(int numverts){(void) numverts;} - virtual void preallocateIndices(int numindices){(void) numindices;} - - virtual bool hasPremadeAabb() const; - virtual void setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax ) const; - virtual void getPremadeAabb(btVector3* aabbMin, btVector3* aabbMax ) const; - -} -; - -#endif //BT_TRIANGLE_INDEX_VERTEX_ARRAY_H diff --git a/bullet/src/BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.cpp b/bullet/src/BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.cpp deleted file mode 100644 index 933bf3470..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -///This file was created by Alex Silverman - -#include "btTriangleIndexVertexMaterialArray.h" - -btTriangleIndexVertexMaterialArray::btTriangleIndexVertexMaterialArray(int numTriangles,int* triangleIndexBase,int triangleIndexStride, - int numVertices,btScalar* vertexBase,int vertexStride, - int numMaterials, unsigned char* materialBase, int materialStride, - int* triangleMaterialsBase, int materialIndexStride) : -btTriangleIndexVertexArray(numTriangles, triangleIndexBase, triangleIndexStride, numVertices, vertexBase, vertexStride) -{ - btMaterialProperties mat; - - mat.m_numMaterials = numMaterials; - mat.m_materialBase = materialBase; - mat.m_materialStride = materialStride; -#ifdef BT_USE_DOUBLE_PRECISION - mat.m_materialType = PHY_DOUBLE; -#else - mat.m_materialType = PHY_FLOAT; -#endif - - mat.m_numTriangles = numTriangles; - mat.m_triangleMaterialsBase = (unsigned char *)triangleMaterialsBase; - mat.m_triangleMaterialStride = materialIndexStride; - mat.m_triangleType = PHY_INTEGER; - - addMaterialProperties(mat); -} - - -void btTriangleIndexVertexMaterialArray::getLockedMaterialBase(unsigned char **materialBase, int& numMaterials, PHY_ScalarType& materialType, int& materialStride, - unsigned char ** triangleMaterialBase, int& numTriangles, int& triangleMaterialStride, PHY_ScalarType& triangleType, int subpart) -{ - btAssert(subpart< getNumSubParts() ); - - btMaterialProperties& mats = m_materials[subpart]; - - numMaterials = mats.m_numMaterials; - (*materialBase) = (unsigned char *) mats.m_materialBase; -#ifdef BT_USE_DOUBLE_PRECISION - materialType = PHY_DOUBLE; -#else - materialType = PHY_FLOAT; -#endif - materialStride = mats.m_materialStride; - - numTriangles = mats.m_numTriangles; - (*triangleMaterialBase) = (unsigned char *)mats.m_triangleMaterialsBase; - triangleMaterialStride = mats.m_triangleMaterialStride; - triangleType = mats.m_triangleType; -} - -void btTriangleIndexVertexMaterialArray::getLockedReadOnlyMaterialBase(const unsigned char **materialBase, int& numMaterials, PHY_ScalarType& materialType, int& materialStride, - const unsigned char ** triangleMaterialBase, int& numTriangles, int& triangleMaterialStride, PHY_ScalarType& triangleType, int subpart) -{ - btMaterialProperties& mats = m_materials[subpart]; - - numMaterials = mats.m_numMaterials; - (*materialBase) = (const unsigned char *) mats.m_materialBase; -#ifdef BT_USE_DOUBLE_PRECISION - materialType = PHY_DOUBLE; -#else - materialType = PHY_FLOAT; -#endif - materialStride = mats.m_materialStride; - - numTriangles = mats.m_numTriangles; - (*triangleMaterialBase) = (const unsigned char *)mats.m_triangleMaterialsBase; - triangleMaterialStride = mats.m_triangleMaterialStride; - triangleType = mats.m_triangleType; -} diff --git a/bullet/src/BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.h b/bullet/src/BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.h deleted file mode 100644 index d7920d7a6..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.h +++ /dev/null @@ -1,84 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -///This file was created by Alex Silverman - -#ifndef BT_MULTIMATERIAL_TRIANGLE_INDEX_VERTEX_ARRAY_H -#define BT_MULTIMATERIAL_TRIANGLE_INDEX_VERTEX_ARRAY_H - -#include "btTriangleIndexVertexArray.h" - - -ATTRIBUTE_ALIGNED16( struct) btMaterialProperties -{ - ///m_materialBase ==========> 2 btScalar values make up one material, friction then restitution - int m_numMaterials; - const unsigned char * m_materialBase; - int m_materialStride; - PHY_ScalarType m_materialType; - ///m_numTriangles <=========== This exists in the btIndexedMesh object for the same subpart, but since we're - /// padding the structure, it can be reproduced at no real cost - ///m_triangleMaterials =====> 1 integer value makes up one entry - /// eg: m_triangleMaterials[1] = 5; // This will set triangle 2 to use material 5 - int m_numTriangles; - const unsigned char * m_triangleMaterialsBase; - int m_triangleMaterialStride; - ///m_triangleType <========== Automatically set in addMaterialProperties - PHY_ScalarType m_triangleType; -}; - -typedef btAlignedObjectArray MaterialArray; - -///Teh btTriangleIndexVertexMaterialArray is built on TriangleIndexVertexArray -///The addition of a material array allows for the utilization of the partID and -///triangleIndex that are returned in the ContactAddedCallback. As with -///TriangleIndexVertexArray, no duplicate is made of the material data, so it -///is the users responsibility to maintain the array during the lifetime of the -///TriangleIndexVertexMaterialArray. -ATTRIBUTE_ALIGNED16(class) btTriangleIndexVertexMaterialArray : public btTriangleIndexVertexArray -{ -protected: - MaterialArray m_materials; - -public: - BT_DECLARE_ALIGNED_ALLOCATOR(); - - btTriangleIndexVertexMaterialArray() - { - } - - btTriangleIndexVertexMaterialArray(int numTriangles,int* triangleIndexBase,int triangleIndexStride, - int numVertices,btScalar* vertexBase,int vertexStride, - int numMaterials, unsigned char* materialBase, int materialStride, - int* triangleMaterialsBase, int materialIndexStride); - - virtual ~btTriangleIndexVertexMaterialArray() {} - - void addMaterialProperties(const btMaterialProperties& mat, PHY_ScalarType triangleType = PHY_INTEGER) - { - m_materials.push_back(mat); - m_materials[m_materials.size()-1].m_triangleType = triangleType; - } - - virtual void getLockedMaterialBase(unsigned char **materialBase, int& numMaterials, PHY_ScalarType& materialType, int& materialStride, - unsigned char ** triangleMaterialBase, int& numTriangles, int& triangleMaterialStride, PHY_ScalarType& triangleType ,int subpart = 0); - - virtual void getLockedReadOnlyMaterialBase(const unsigned char **materialBase, int& numMaterials, PHY_ScalarType& materialType, int& materialStride, - const unsigned char ** triangleMaterialBase, int& numTriangles, int& triangleMaterialStride, PHY_ScalarType& triangleType, int subpart = 0); - -} -; - -#endif //BT_MULTIMATERIAL_TRIANGLE_INDEX_VERTEX_ARRAY_H diff --git a/bullet/src/BulletCollision/CollisionShapes/btTriangleMesh.cpp b/bullet/src/BulletCollision/CollisionShapes/btTriangleMesh.cpp deleted file mode 100644 index 87f32fa0e..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btTriangleMesh.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#include "btTriangleMesh.h" - - - -btTriangleMesh::btTriangleMesh (bool use32bitIndices,bool use4componentVertices) -:m_use32bitIndices(use32bitIndices), -m_use4componentVertices(use4componentVertices), -m_weldingThreshold(0.0) -{ - btIndexedMesh meshIndex; - meshIndex.m_numTriangles = 0; - meshIndex.m_numVertices = 0; - meshIndex.m_indexType = PHY_INTEGER; - meshIndex.m_triangleIndexBase = 0; - meshIndex.m_triangleIndexStride = 3*sizeof(int); - meshIndex.m_vertexBase = 0; - meshIndex.m_vertexStride = sizeof(btVector3); - m_indexedMeshes.push_back(meshIndex); - - if (m_use32bitIndices) - { - m_indexedMeshes[0].m_numTriangles = m_32bitIndices.size()/3; - m_indexedMeshes[0].m_triangleIndexBase = 0; - m_indexedMeshes[0].m_indexType = PHY_INTEGER; - m_indexedMeshes[0].m_triangleIndexStride = 3*sizeof(int); - } else - { - m_indexedMeshes[0].m_numTriangles = m_16bitIndices.size()/3; - m_indexedMeshes[0].m_triangleIndexBase = 0; - m_indexedMeshes[0].m_indexType = PHY_SHORT; - m_indexedMeshes[0].m_triangleIndexStride = 3*sizeof(short int); - } - - if (m_use4componentVertices) - { - m_indexedMeshes[0].m_numVertices = m_4componentVertices.size(); - m_indexedMeshes[0].m_vertexBase = 0; - m_indexedMeshes[0].m_vertexStride = sizeof(btVector3); - } else - { - m_indexedMeshes[0].m_numVertices = m_3componentVertices.size()/3; - m_indexedMeshes[0].m_vertexBase = 0; - m_indexedMeshes[0].m_vertexStride = 3*sizeof(btScalar); - } - - -} - -void btTriangleMesh::addIndex(int index) -{ - if (m_use32bitIndices) - { - m_32bitIndices.push_back(index); - m_indexedMeshes[0].m_triangleIndexBase = (unsigned char*) &m_32bitIndices[0]; - } else - { - m_16bitIndices.push_back(index); - m_indexedMeshes[0].m_triangleIndexBase = (unsigned char*) &m_16bitIndices[0]; - } -} - - -int btTriangleMesh::findOrAddVertex(const btVector3& vertex, bool removeDuplicateVertices) -{ - //return index of new/existing vertex - ///@todo: could use acceleration structure for this - if (m_use4componentVertices) - { - if (removeDuplicateVertices) - { - for (int i=0;i< m_4componentVertices.size();i++) - { - if ((m_4componentVertices[i]-vertex).length2() <= m_weldingThreshold) - { - return i; - } - } - } - m_indexedMeshes[0].m_numVertices++; - m_4componentVertices.push_back(vertex); - m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_4componentVertices[0]; - - return m_4componentVertices.size()-1; - - } else - { - - if (removeDuplicateVertices) - { - for (int i=0;i< m_3componentVertices.size();i+=3) - { - btVector3 vtx(m_3componentVertices[i],m_3componentVertices[i+1],m_3componentVertices[i+2]); - if ((vtx-vertex).length2() <= m_weldingThreshold) - { - return i/3; - } - } - } - m_3componentVertices.push_back((float)vertex.getX()); - m_3componentVertices.push_back((float)vertex.getY()); - m_3componentVertices.push_back((float)vertex.getZ()); - m_indexedMeshes[0].m_numVertices++; - m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_3componentVertices[0]; - return (m_3componentVertices.size()/3)-1; - } - -} - -void btTriangleMesh::addTriangle(const btVector3& vertex0,const btVector3& vertex1,const btVector3& vertex2,bool removeDuplicateVertices) -{ - m_indexedMeshes[0].m_numTriangles++; - addIndex(findOrAddVertex(vertex0,removeDuplicateVertices)); - addIndex(findOrAddVertex(vertex1,removeDuplicateVertices)); - addIndex(findOrAddVertex(vertex2,removeDuplicateVertices)); -} - -int btTriangleMesh::getNumTriangles() const -{ - if (m_use32bitIndices) - { - return m_32bitIndices.size() / 3; - } - return m_16bitIndices.size() / 3; -} diff --git a/bullet/src/BulletCollision/CollisionShapes/btTriangleMesh.h b/bullet/src/BulletCollision/CollisionShapes/btTriangleMesh.h deleted file mode 100644 index e9c41d799..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btTriangleMesh.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef TRIANGLE_MESH_H -#define TRIANGLE_MESH_H - -#include "btTriangleIndexVertexArray.h" -#include "LinearMath/btVector3.h" -#include "LinearMath/btAlignedObjectArray.h" - -///The btTriangleMesh class is a convenience class derived from btTriangleIndexVertexArray, that provides storage for a concave triangle mesh. It can be used as data for the btBvhTriangleMeshShape. -///It allows either 32bit or 16bit indices, and 4 (x-y-z-w) or 3 (x-y-z) component vertices. -///If you want to share triangle/index data between graphics mesh and collision mesh (btBvhTriangleMeshShape), you can directly use btTriangleIndexVertexArray or derive your own class from btStridingMeshInterface. -///Performance of btTriangleMesh and btTriangleIndexVertexArray used in a btBvhTriangleMeshShape is the same. -class btTriangleMesh : public btTriangleIndexVertexArray -{ - btAlignedObjectArray m_4componentVertices; - btAlignedObjectArray m_3componentVertices; - - btAlignedObjectArray m_32bitIndices; - btAlignedObjectArray m_16bitIndices; - bool m_use32bitIndices; - bool m_use4componentVertices; - - - public: - btScalar m_weldingThreshold; - - btTriangleMesh (bool use32bitIndices=true,bool use4componentVertices=true); - - bool getUse32bitIndices() const - { - return m_use32bitIndices; - } - - bool getUse4componentVertices() const - { - return m_use4componentVertices; - } - ///By default addTriangle won't search for duplicate vertices, because the search is very slow for large triangle meshes. - ///In general it is better to directly use btTriangleIndexVertexArray instead. - void addTriangle(const btVector3& vertex0,const btVector3& vertex1,const btVector3& vertex2, bool removeDuplicateVertices=false); - - int getNumTriangles() const; - - virtual void preallocateVertices(int numverts){(void) numverts;} - virtual void preallocateIndices(int numindices){(void) numindices;} - - ///findOrAddVertex is an internal method, use addTriangle instead - int findOrAddVertex(const btVector3& vertex, bool removeDuplicateVertices); - ///addIndex is an internal method, use addTriangle instead - void addIndex(int index); - -}; - -#endif //TRIANGLE_MESH_H - diff --git a/bullet/src/BulletCollision/CollisionShapes/btTriangleMeshShape.cpp b/bullet/src/BulletCollision/CollisionShapes/btTriangleMeshShape.cpp deleted file mode 100644 index abf5697d9..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btTriangleMeshShape.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btTriangleMeshShape.h" -#include "LinearMath/btVector3.h" -#include "LinearMath/btQuaternion.h" -#include "btStridingMeshInterface.h" -#include "LinearMath/btAabbUtil2.h" -#include "BulletCollision/CollisionShapes/btCollisionMargin.h" - - -btTriangleMeshShape::btTriangleMeshShape(btStridingMeshInterface* meshInterface) -: btConcaveShape (), m_meshInterface(meshInterface) -{ - m_shapeType = TRIANGLE_MESH_SHAPE_PROXYTYPE; - if(meshInterface->hasPremadeAabb()) - { - meshInterface->getPremadeAabb(&m_localAabbMin, &m_localAabbMax); - } - else - { - recalcLocalAabb(); - } -} - - -btTriangleMeshShape::~btTriangleMeshShape() -{ - -} - - - - -void btTriangleMeshShape::getAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax) const -{ - - btVector3 localHalfExtents = btScalar(0.5)*(m_localAabbMax-m_localAabbMin); - localHalfExtents += btVector3(getMargin(),getMargin(),getMargin()); - btVector3 localCenter = btScalar(0.5)*(m_localAabbMax+m_localAabbMin); - - btMatrix3x3 abs_b = trans.getBasis().absolute(); - - btVector3 center = trans(localCenter); - - btVector3 extent = btVector3(abs_b[0].dot(localHalfExtents), - abs_b[1].dot(localHalfExtents), - abs_b[2].dot(localHalfExtents)); - aabbMin = center - extent; - aabbMax = center + extent; - - -} - -void btTriangleMeshShape::recalcLocalAabb() -{ - for (int i=0;i<3;i++) - { - btVector3 vec(btScalar(0.),btScalar(0.),btScalar(0.)); - vec[i] = btScalar(1.); - btVector3 tmp = localGetSupportingVertex(vec); - m_localAabbMax[i] = tmp[i]+m_collisionMargin; - vec[i] = btScalar(-1.); - tmp = localGetSupportingVertex(vec); - m_localAabbMin[i] = tmp[i]-m_collisionMargin; - } -} - - - -class SupportVertexCallback : public btTriangleCallback -{ - - btVector3 m_supportVertexLocal; -public: - - btTransform m_worldTrans; - btScalar m_maxDot; - btVector3 m_supportVecLocal; - - SupportVertexCallback(const btVector3& supportVecWorld,const btTransform& trans) - : m_supportVertexLocal(btScalar(0.),btScalar(0.),btScalar(0.)), m_worldTrans(trans) ,m_maxDot(btScalar(-BT_LARGE_FLOAT)) - - { - m_supportVecLocal = supportVecWorld * m_worldTrans.getBasis(); - } - - virtual void processTriangle( btVector3* triangle,int partId, int triangleIndex) - { - (void)partId; - (void)triangleIndex; - for (int i=0;i<3;i++) - { - btScalar dot = m_supportVecLocal.dot(triangle[i]); - if (dot > m_maxDot) - { - m_maxDot = dot; - m_supportVertexLocal = triangle[i]; - } - } - } - - btVector3 GetSupportVertexWorldSpace() - { - return m_worldTrans(m_supportVertexLocal); - } - - btVector3 GetSupportVertexLocal() - { - return m_supportVertexLocal; - } - -}; - - -void btTriangleMeshShape::setLocalScaling(const btVector3& scaling) -{ - m_meshInterface->setScaling(scaling); - recalcLocalAabb(); -} - -const btVector3& btTriangleMeshShape::getLocalScaling() const -{ - return m_meshInterface->getScaling(); -} - - - - - - -//#define DEBUG_TRIANGLE_MESH - - - -void btTriangleMeshShape::processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const -{ - struct FilteredCallback : public btInternalTriangleIndexCallback - { - btTriangleCallback* m_callback; - btVector3 m_aabbMin; - btVector3 m_aabbMax; - - FilteredCallback(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) - :m_callback(callback), - m_aabbMin(aabbMin), - m_aabbMax(aabbMax) - { - } - - virtual void internalProcessTriangleIndex(btVector3* triangle,int partId,int triangleIndex) - { - if (TestTriangleAgainstAabb2(&triangle[0],m_aabbMin,m_aabbMax)) - { - //check aabb in triangle-space, before doing this - m_callback->processTriangle(triangle,partId,triangleIndex); - } - - } - - }; - - FilteredCallback filterCallback(callback,aabbMin,aabbMax); - - m_meshInterface->InternalProcessAllTriangles(&filterCallback,aabbMin,aabbMax); -} - - - - - -void btTriangleMeshShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const -{ - (void)mass; - //moving concave objects not supported - btAssert(0); - inertia.setValue(btScalar(0.),btScalar(0.),btScalar(0.)); -} - - -btVector3 btTriangleMeshShape::localGetSupportingVertex(const btVector3& vec) const -{ - btVector3 supportVertex; - - btTransform ident; - ident.setIdentity(); - - SupportVertexCallback supportCallback(vec,ident); - - btVector3 aabbMax(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT)); - - processAllTriangles(&supportCallback,-aabbMax,aabbMax); - - supportVertex = supportCallback.GetSupportVertexLocal(); - - return supportVertex; -} diff --git a/bullet/src/BulletCollision/CollisionShapes/btTriangleMeshShape.h b/bullet/src/BulletCollision/CollisionShapes/btTriangleMeshShape.h deleted file mode 100644 index aef96411f..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btTriangleMeshShape.h +++ /dev/null @@ -1,85 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef TRIANGLE_MESH_SHAPE_H -#define TRIANGLE_MESH_SHAPE_H - -#include "btConcaveShape.h" -#include "btStridingMeshInterface.h" - - -///The btTriangleMeshShape is an internal concave triangle mesh interface. Don't use this class directly, use btBvhTriangleMeshShape instead. -class btTriangleMeshShape : public btConcaveShape -{ -protected: - btVector3 m_localAabbMin; - btVector3 m_localAabbMax; - btStridingMeshInterface* m_meshInterface; - - ///btTriangleMeshShape constructor has been disabled/protected, so that users will not mistakenly use this class. - ///Don't use btTriangleMeshShape but use btBvhTriangleMeshShape instead! - btTriangleMeshShape(btStridingMeshInterface* meshInterface); - -public: - - virtual ~btTriangleMeshShape(); - - virtual btVector3 localGetSupportingVertex(const btVector3& vec) const; - - virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const - { - btAssert(0); - return localGetSupportingVertex(vec); - } - - void recalcLocalAabb(); - - virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const; - - virtual void processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const; - - virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const; - - virtual void setLocalScaling(const btVector3& scaling); - virtual const btVector3& getLocalScaling() const; - - btStridingMeshInterface* getMeshInterface() - { - return m_meshInterface; - } - - const btStridingMeshInterface* getMeshInterface() const - { - return m_meshInterface; - } - - const btVector3& getLocalAabbMin() const - { - return m_localAabbMin; - } - const btVector3& getLocalAabbMax() const - { - return m_localAabbMax; - } - - - - //debugging - virtual const char* getName()const {return "TRIANGLEMESH";} - - -}; - -#endif //TRIANGLE_MESH_SHAPE_H diff --git a/bullet/src/BulletCollision/CollisionShapes/btTriangleShape.h b/bullet/src/BulletCollision/CollisionShapes/btTriangleShape.h deleted file mode 100644 index 1fe9b6367..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btTriangleShape.h +++ /dev/null @@ -1,182 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef OBB_TRIANGLE_MINKOWSKI_H -#define OBB_TRIANGLE_MINKOWSKI_H - -#include "btConvexShape.h" -#include "btBoxShape.h" - -ATTRIBUTE_ALIGNED16(class) btTriangleShape : public btPolyhedralConvexShape -{ - - -public: - - btVector3 m_vertices1[3]; - - virtual int getNumVertices() const - { - return 3; - } - - btVector3& getVertexPtr(int index) - { - return m_vertices1[index]; - } - - const btVector3& getVertexPtr(int index) const - { - return m_vertices1[index]; - } - virtual void getVertex(int index,btVector3& vert) const - { - vert = m_vertices1[index]; - } - - virtual int getNumEdges() const - { - return 3; - } - - virtual void getEdge(int i,btVector3& pa,btVector3& pb) const - { - getVertex(i,pa); - getVertex((i+1)%3,pb); - } - - - virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax)const - { -// btAssert(0); - getAabbSlow(t,aabbMin,aabbMax); - } - - btVector3 localGetSupportingVertexWithoutMargin(const btVector3& dir)const - { - btVector3 dots(dir.dot(m_vertices1[0]), dir.dot(m_vertices1[1]), dir.dot(m_vertices1[2])); - return m_vertices1[dots.maxAxis()]; - - } - - virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const - { - for (int i=0;i= -tolerance && dist <= tolerance) - { - //inside check on edge-planes - int i; - for (i=0;i<3;i++) - { - btVector3 pa,pb; - getEdge(i,pa,pb); - btVector3 edge = pb-pa; - btVector3 edgeNormal = edge.cross(normal); - edgeNormal.normalize(); - btScalar dist = pt.dot( edgeNormal); - btScalar edgeConst = pa.dot(edgeNormal); - dist -= edgeConst; - if (dist < -tolerance) - return false; - } - - return true; - } - - return false; - } - //debugging - virtual const char* getName()const - { - return "Triangle"; - } - - virtual int getNumPreferredPenetrationDirections() const - { - return 2; - } - - virtual void getPreferredPenetrationDirection(int index, btVector3& penetrationVector) const - { - calcNormal(penetrationVector); - if (index) - penetrationVector *= btScalar(-1.); - } - - -}; - -#endif //OBB_TRIANGLE_MINKOWSKI_H - diff --git a/bullet/src/BulletCollision/CollisionShapes/btUniformScalingShape.cpp b/bullet/src/BulletCollision/CollisionShapes/btUniformScalingShape.cpp deleted file mode 100644 index 12399ece8..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btUniformScalingShape.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btUniformScalingShape.h" - -btUniformScalingShape::btUniformScalingShape( btConvexShape* convexChildShape,btScalar uniformScalingFactor): -btConvexShape (), m_childConvexShape(convexChildShape), -m_uniformScalingFactor(uniformScalingFactor) -{ - m_shapeType = UNIFORM_SCALING_SHAPE_PROXYTYPE; -} - -btUniformScalingShape::~btUniformScalingShape() -{ -} - - -btVector3 btUniformScalingShape::localGetSupportingVertexWithoutMargin(const btVector3& vec)const -{ - btVector3 tmpVertex; - tmpVertex = m_childConvexShape->localGetSupportingVertexWithoutMargin(vec); - return tmpVertex*m_uniformScalingFactor; -} - -void btUniformScalingShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const -{ - m_childConvexShape->batchedUnitVectorGetSupportingVertexWithoutMargin(vectors,supportVerticesOut,numVectors); - int i; - for (i=0;ilocalGetSupportingVertex(vec); - return tmpVertex*m_uniformScalingFactor; -} - - -void btUniformScalingShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const -{ - - ///this linear upscaling is not realistic, but we don't deal with large mass ratios... - btVector3 tmpInertia; - m_childConvexShape->calculateLocalInertia(mass,tmpInertia); - inertia = tmpInertia * m_uniformScalingFactor; -} - - - ///getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version -void btUniformScalingShape::getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const -{ - m_childConvexShape->getAabb(t,aabbMin,aabbMax); - btVector3 aabbCenter = (aabbMax+aabbMin)*btScalar(0.5); - btVector3 scaledAabbHalfExtends = (aabbMax-aabbMin)*btScalar(0.5)*m_uniformScalingFactor; - - aabbMin = aabbCenter - scaledAabbHalfExtends; - aabbMax = aabbCenter + scaledAabbHalfExtends; - -} - -void btUniformScalingShape::getAabbSlow(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const -{ - m_childConvexShape->getAabbSlow(t,aabbMin,aabbMax); - btVector3 aabbCenter = (aabbMax+aabbMin)*btScalar(0.5); - btVector3 scaledAabbHalfExtends = (aabbMax-aabbMin)*btScalar(0.5)*m_uniformScalingFactor; - - aabbMin = aabbCenter - scaledAabbHalfExtends; - aabbMax = aabbCenter + scaledAabbHalfExtends; -} - -void btUniformScalingShape::setLocalScaling(const btVector3& scaling) -{ - m_childConvexShape->setLocalScaling(scaling); -} - -const btVector3& btUniformScalingShape::getLocalScaling() const -{ - return m_childConvexShape->getLocalScaling(); -} - -void btUniformScalingShape::setMargin(btScalar margin) -{ - m_childConvexShape->setMargin(margin); -} -btScalar btUniformScalingShape::getMargin() const -{ - return m_childConvexShape->getMargin() * m_uniformScalingFactor; -} - -int btUniformScalingShape::getNumPreferredPenetrationDirections() const -{ - return m_childConvexShape->getNumPreferredPenetrationDirections(); -} - -void btUniformScalingShape::getPreferredPenetrationDirection(int index, btVector3& penetrationVector) const -{ - m_childConvexShape->getPreferredPenetrationDirection(index,penetrationVector); -} diff --git a/bullet/src/BulletCollision/CollisionShapes/btUniformScalingShape.h b/bullet/src/BulletCollision/CollisionShapes/btUniformScalingShape.h deleted file mode 100644 index 5d0a69b89..000000000 --- a/bullet/src/BulletCollision/CollisionShapes/btUniformScalingShape.h +++ /dev/null @@ -1,87 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef BT_UNIFORM_SCALING_SHAPE_H -#define BT_UNIFORM_SCALING_SHAPE_H - -#include "btConvexShape.h" -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types - -///The btUniformScalingShape allows to re-use uniform scaled instances of btConvexShape in a memory efficient way. -///Istead of using btUniformScalingShape, it is better to use the non-uniform setLocalScaling method on convex shapes that implement it. -class btUniformScalingShape : public btConvexShape -{ - btConvexShape* m_childConvexShape; - - btScalar m_uniformScalingFactor; - - public: - - btUniformScalingShape( btConvexShape* convexChildShape, btScalar uniformScalingFactor); - - virtual ~btUniformScalingShape(); - - virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const; - - virtual btVector3 localGetSupportingVertex(const btVector3& vec)const; - - virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const; - - virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const; - - btScalar getUniformScalingFactor() const - { - return m_uniformScalingFactor; - } - - btConvexShape* getChildShape() - { - return m_childConvexShape; - } - - const btConvexShape* getChildShape() const - { - return m_childConvexShape; - } - - virtual const char* getName()const - { - return "UniformScalingShape"; - } - - - - /////////////////////////// - - - ///getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version - void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const; - - virtual void getAabbSlow(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const; - - virtual void setLocalScaling(const btVector3& scaling) ; - virtual const btVector3& getLocalScaling() const ; - - virtual void setMargin(btScalar margin); - virtual btScalar getMargin() const; - - virtual int getNumPreferredPenetrationDirections() const; - - virtual void getPreferredPenetrationDirection(int index, btVector3& penetrationVector) const; - - -}; - -#endif //BT_UNIFORM_SCALING_SHAPE_H diff --git a/bullet/src/BulletCollision/Doxyfile b/bullet/src/BulletCollision/Doxyfile deleted file mode 100644 index 4ecb6acb6..000000000 --- a/bullet/src/BulletCollision/Doxyfile +++ /dev/null @@ -1,746 +0,0 @@ -# Doxyfile 1.2.4 - -# This file describes the settings to be used by doxygen for a project -# -# All text after a hash (#) is considered a comment and will be ignored -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") - -#--------------------------------------------------------------------------- -# General configuration options -#--------------------------------------------------------------------------- - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. -PROJECT_NAME = "Bullet Continuous Collision Detection Library" - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Dutch, French, Italian, Czech, Swedish, German, Finnish, Japanese, -# Korean, Hungarian, Norwegian, Spanish, Romanian, Russian, Croatian, -# Polish, Portuguese and Slovene. - -OUTPUT_LANGUAGE = English - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = YES - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = YES - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = YES - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these class will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = NO - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. It is allowed to use relative paths in the argument list. - -STRIP_FROM_PATH = - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a class diagram (in Html and LaTeX) for classes with base or -# super classes. Setting the tag to NO turns the diagrams off. - -CLASS_DIAGRAMS = YES - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. - -SOURCE_BROWSER = YES - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower case letters. If set to YES upper case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# users are adviced to set this option to NO. - -CASE_SENSE_NAMES = YES - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like the Qt-style comments (thus requiring an -# explict @brief command for a brief description. - -JAVADOC_AUTOBRIEF = YES - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# reimplements. - -INHERIT_DOCS = YES - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 8 - -# The ENABLE_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = . - - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -FILE_PATTERNS = *.h *.cpp *.c - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = YES - -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. - -EXCLUDE = - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. - -EXCLUDE_PATTERNS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. - -INPUT_FILTER = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse. - -FILTER_SOURCE_FILES = NO - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = NO - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet - -HTML_STYLESHEET = - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. - -DISABLE_INDEX = NO - -# This tag can be used to set the number of enum values (range [1..20]) -# that doxygen will group on one line in the generated HTML documentation. - -ENUM_VALUES_PER_LINE = 4 - -# If the GENERATE_TREEVIEW tag is set to YES, a side pannel will be -# generated containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript and frames is required (for instance Netscape 4.0+ -# or Internet explorer 4.0+). - -GENERATE_TREEVIEW = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = NO - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4wide - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = NO - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = NO - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimised for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using a WORD or other. -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assigments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. Warning: This feature -# is still experimental and very incomplete. - -GENERATE_XML = NO - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = NO - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_PREDEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = ../../generic/extern - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. - -PREDEFINED = - -# If the MACRO_EXPANSION and EXPAND_PREDEF_ONLY tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition. - -EXPAND_AS_DEFINED = - -#--------------------------------------------------------------------------- -# Configuration::addtions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES tag can be used to specify one or more tagfiles. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = YES - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the ENABLE_PREPROCESSING, INCLUDE_GRAPH, and HAVE_DOT tags are set to -# YES then doxygen will generate a graph for each documented file showing -# the direct and indirect include dependencies of the file with other -# documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, INCLUDED_BY_GRAPH, and HAVE_DOT tags are set to -# YES then doxygen will generate a graph for each documented header file showing -# the documented files that directly or indirectly include this file - -INCLUDED_BY_GRAPH = YES - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found on the path. - -DOT_PATH = - -# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width -# (in pixels) of the graphs generated by dot. If a graph becomes larger than -# this value, doxygen will try to truncate the graph, so that it fits within -# the specified constraint. Beware that most browsers cannot cope with very -# large images. - -MAX_DOT_GRAPH_WIDTH = 1024 - -# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height -# (in pixels) of the graphs generated by dot. If a graph becomes larger than -# this value, doxygen will try to truncate the graph, so that it fits within -# the specified constraint. Beware that most browsers cannot cope with very -# large images. - -MAX_DOT_GRAPH_HEIGHT = 1024 - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -#--------------------------------------------------------------------------- -# Configuration::addtions related to the search engine -#--------------------------------------------------------------------------- - -# The SEARCHENGINE tag specifies whether or not a search engine should be -# used. If set to NO the values of all tags below this one will be ignored. - -SEARCHENGINE = NO - -# The CGI_NAME tag should be the name of the CGI script that -# starts the search engine (doxysearch) with the correct parameters. -# A script with this name will be generated by doxygen. - -CGI_NAME = search.cgi - -# The CGI_URL tag should be the absolute URL to the directory where the -# cgi binaries are located. See the documentation of your http daemon for -# details. - -CGI_URL = - -# The DOC_URL tag should be the absolute URL to the directory where the -# documentation is located. If left blank the absolute path to the -# documentation, with file:// prepended to it, will be used. - -DOC_URL = - -# The DOC_ABSPATH tag should be the absolute path to the directory where the -# documentation is located. If left blank the directory on the local machine -# will be used. - -DOC_ABSPATH = - -# The BIN_ABSPATH tag must point to the directory where the doxysearch binary -# is installed. - -BIN_ABSPATH = c:\program files\doxygen\bin - -# The EXT_DOC_PATHS tag can be used to specify one or more paths to -# documentation generated for other projects. This allows doxysearch to search -# the documentation for these projects as well. - -EXT_DOC_PATHS = diff --git a/bullet/src/BulletCollision/Gimpact/btBoxCollision.h b/bullet/src/BulletCollision/Gimpact/btBoxCollision.h deleted file mode 100644 index e2a430081..000000000 --- a/bullet/src/BulletCollision/Gimpact/btBoxCollision.h +++ /dev/null @@ -1,647 +0,0 @@ -#ifndef BT_BOX_COLLISION_H_INCLUDED -#define BT_BOX_COLLISION_H_INCLUDED - -/*! \file gim_box_collision.h -\author Francisco Len Njera -*/ -/* -This source file is part of GIMPACT Library. - -For the latest info, see http://gimpact.sourceforge.net/ - -Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371. -email: projectileman@yahoo.com - - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "LinearMath/btTransform.h" - - -///Swap numbers -#define BT_SWAP_NUMBERS(a,b){ \ - a = a+b; \ - b = a-b; \ - a = a-b; \ -}\ - - -#define BT_MAX(a,b) (ab?b:a) - -#define BT_GREATER(x, y) btFabs(x) > (y) - -#define BT_MAX3(a,b,c) BT_MAX(a,BT_MAX(b,c)) -#define BT_MIN3(a,b,c) BT_MIN(a,BT_MIN(b,c)) - - - - - - -enum eBT_PLANE_INTERSECTION_TYPE -{ - BT_CONST_BACK_PLANE = 0, - BT_CONST_COLLIDE_PLANE, - BT_CONST_FRONT_PLANE -}; - -//SIMD_FORCE_INLINE bool test_cross_edge_box( -// const btVector3 & edge, -// const btVector3 & absolute_edge, -// const btVector3 & pointa, -// const btVector3 & pointb, const btVector3 & extend, -// int dir_index0, -// int dir_index1 -// int component_index0, -// int component_index1) -//{ -// // dir coords are -z and y -// -// const btScalar dir0 = -edge[dir_index0]; -// const btScalar dir1 = edge[dir_index1]; -// btScalar pmin = pointa[component_index0]*dir0 + pointa[component_index1]*dir1; -// btScalar pmax = pointb[component_index0]*dir0 + pointb[component_index1]*dir1; -// //find minmax -// if(pmin>pmax) -// { -// BT_SWAP_NUMBERS(pmin,pmax); -// } -// //find extends -// const btScalar rad = extend[component_index0] * absolute_edge[dir_index0] + -// extend[component_index1] * absolute_edge[dir_index1]; -// -// if(pmin>rad || -rad>pmax) return false; -// return true; -//} -// -//SIMD_FORCE_INLINE bool test_cross_edge_box_X_axis( -// const btVector3 & edge, -// const btVector3 & absolute_edge, -// const btVector3 & pointa, -// const btVector3 & pointb, btVector3 & extend) -//{ -// -// return test_cross_edge_box(edge,absolute_edge,pointa,pointb,extend,2,1,1,2); -//} -// -// -//SIMD_FORCE_INLINE bool test_cross_edge_box_Y_axis( -// const btVector3 & edge, -// const btVector3 & absolute_edge, -// const btVector3 & pointa, -// const btVector3 & pointb, btVector3 & extend) -//{ -// -// return test_cross_edge_box(edge,absolute_edge,pointa,pointb,extend,0,2,2,0); -//} -// -//SIMD_FORCE_INLINE bool test_cross_edge_box_Z_axis( -// const btVector3 & edge, -// const btVector3 & absolute_edge, -// const btVector3 & pointa, -// const btVector3 & pointb, btVector3 & extend) -//{ -// -// return test_cross_edge_box(edge,absolute_edge,pointa,pointb,extend,1,0,0,1); -//} - - -#define TEST_CROSS_EDGE_BOX_MCR(edge,absolute_edge,pointa,pointb,_extend,i_dir_0,i_dir_1,i_comp_0,i_comp_1)\ -{\ - const btScalar dir0 = -edge[i_dir_0];\ - const btScalar dir1 = edge[i_dir_1];\ - btScalar pmin = pointa[i_comp_0]*dir0 + pointa[i_comp_1]*dir1;\ - btScalar pmax = pointb[i_comp_0]*dir0 + pointb[i_comp_1]*dir1;\ - if(pmin>pmax)\ - {\ - BT_SWAP_NUMBERS(pmin,pmax); \ - }\ - const btScalar abs_dir0 = absolute_edge[i_dir_0];\ - const btScalar abs_dir1 = absolute_edge[i_dir_1];\ - const btScalar rad = _extend[i_comp_0] * abs_dir0 + _extend[i_comp_1] * abs_dir1;\ - if(pmin>rad || -rad>pmax) return false;\ -}\ - - -#define TEST_CROSS_EDGE_BOX_X_AXIS_MCR(edge,absolute_edge,pointa,pointb,_extend)\ -{\ - TEST_CROSS_EDGE_BOX_MCR(edge,absolute_edge,pointa,pointb,_extend,2,1,1,2);\ -}\ - -#define TEST_CROSS_EDGE_BOX_Y_AXIS_MCR(edge,absolute_edge,pointa,pointb,_extend)\ -{\ - TEST_CROSS_EDGE_BOX_MCR(edge,absolute_edge,pointa,pointb,_extend,0,2,2,0);\ -}\ - -#define TEST_CROSS_EDGE_BOX_Z_AXIS_MCR(edge,absolute_edge,pointa,pointb,_extend)\ -{\ - TEST_CROSS_EDGE_BOX_MCR(edge,absolute_edge,pointa,pointb,_extend,1,0,0,1);\ -}\ - - -//! Returns the dot product between a vec3f and the col of a matrix -SIMD_FORCE_INLINE btScalar bt_mat3_dot_col( -const btMatrix3x3 & mat, const btVector3 & vec3, int colindex) -{ - return vec3[0]*mat[0][colindex] + vec3[1]*mat[1][colindex] + vec3[2]*mat[2][colindex]; -} - - -//! Class for transforming a model1 to the space of model0 -ATTRIBUTE_ALIGNED16 (class) BT_BOX_BOX_TRANSFORM_CACHE -{ -public: - btVector3 m_T1to0;//!< Transforms translation of model1 to model 0 - btMatrix3x3 m_R1to0;//!< Transforms Rotation of model1 to model 0, equal to R0' * R1 - btMatrix3x3 m_AR;//!< Absolute value of m_R1to0 - - SIMD_FORCE_INLINE void calc_absolute_matrix() - { -// static const btVector3 vepsi(1e-6f,1e-6f,1e-6f); -// m_AR[0] = vepsi + m_R1to0[0].absolute(); -// m_AR[1] = vepsi + m_R1to0[1].absolute(); -// m_AR[2] = vepsi + m_R1to0[2].absolute(); - - int i,j; - - for(i=0;i<3;i++) - { - for(j=0;j<3;j++ ) - { - m_AR[i][j] = 1e-6f + btFabs(m_R1to0[i][j]); - } - } - - } - - BT_BOX_BOX_TRANSFORM_CACHE() - { - } - - - - //! Calc the transformation relative 1 to 0. Inverts matrics by transposing - SIMD_FORCE_INLINE void calc_from_homogenic(const btTransform & trans0,const btTransform & trans1) - { - - btTransform temp_trans = trans0.inverse(); - temp_trans = temp_trans * trans1; - - m_T1to0 = temp_trans.getOrigin(); - m_R1to0 = temp_trans.getBasis(); - - - calc_absolute_matrix(); - } - - //! Calcs the full invertion of the matrices. Useful for scaling matrices - SIMD_FORCE_INLINE void calc_from_full_invert(const btTransform & trans0,const btTransform & trans1) - { - m_R1to0 = trans0.getBasis().inverse(); - m_T1to0 = m_R1to0 * (-trans0.getOrigin()); - - m_T1to0 += m_R1to0*trans1.getOrigin(); - m_R1to0 *= trans1.getBasis(); - - calc_absolute_matrix(); - } - - SIMD_FORCE_INLINE btVector3 transform(const btVector3 & point) const - { - return btVector3(m_R1to0[0].dot(point) + m_T1to0.x(), - m_R1to0[1].dot(point) + m_T1to0.y(), - m_R1to0[2].dot(point) + m_T1to0.z()); - } -}; - - -#define BOX_PLANE_EPSILON 0.000001f - -//! Axis aligned box -ATTRIBUTE_ALIGNED16 (class) btAABB -{ -public: - btVector3 m_min; - btVector3 m_max; - - btAABB() - {} - - - btAABB(const btVector3 & V1, - const btVector3 & V2, - const btVector3 & V3) - { - m_min[0] = BT_MIN3(V1[0],V2[0],V3[0]); - m_min[1] = BT_MIN3(V1[1],V2[1],V3[1]); - m_min[2] = BT_MIN3(V1[2],V2[2],V3[2]); - - m_max[0] = BT_MAX3(V1[0],V2[0],V3[0]); - m_max[1] = BT_MAX3(V1[1],V2[1],V3[1]); - m_max[2] = BT_MAX3(V1[2],V2[2],V3[2]); - } - - btAABB(const btVector3 & V1, - const btVector3 & V2, - const btVector3 & V3, - btScalar margin) - { - m_min[0] = BT_MIN3(V1[0],V2[0],V3[0]); - m_min[1] = BT_MIN3(V1[1],V2[1],V3[1]); - m_min[2] = BT_MIN3(V1[2],V2[2],V3[2]); - - m_max[0] = BT_MAX3(V1[0],V2[0],V3[0]); - m_max[1] = BT_MAX3(V1[1],V2[1],V3[1]); - m_max[2] = BT_MAX3(V1[2],V2[2],V3[2]); - - m_min[0] -= margin; - m_min[1] -= margin; - m_min[2] -= margin; - m_max[0] += margin; - m_max[1] += margin; - m_max[2] += margin; - } - - btAABB(const btAABB &other): - m_min(other.m_min),m_max(other.m_max) - { - } - - btAABB(const btAABB &other,btScalar margin ): - m_min(other.m_min),m_max(other.m_max) - { - m_min[0] -= margin; - m_min[1] -= margin; - m_min[2] -= margin; - m_max[0] += margin; - m_max[1] += margin; - m_max[2] += margin; - } - - SIMD_FORCE_INLINE void invalidate() - { - m_min[0] = SIMD_INFINITY; - m_min[1] = SIMD_INFINITY; - m_min[2] = SIMD_INFINITY; - m_max[0] = -SIMD_INFINITY; - m_max[1] = -SIMD_INFINITY; - m_max[2] = -SIMD_INFINITY; - } - - SIMD_FORCE_INLINE void increment_margin(btScalar margin) - { - m_min[0] -= margin; - m_min[1] -= margin; - m_min[2] -= margin; - m_max[0] += margin; - m_max[1] += margin; - m_max[2] += margin; - } - - SIMD_FORCE_INLINE void copy_with_margin(const btAABB &other, btScalar margin) - { - m_min[0] = other.m_min[0] - margin; - m_min[1] = other.m_min[1] - margin; - m_min[2] = other.m_min[2] - margin; - - m_max[0] = other.m_max[0] + margin; - m_max[1] = other.m_max[1] + margin; - m_max[2] = other.m_max[2] + margin; - } - - template - SIMD_FORCE_INLINE void calc_from_triangle( - const CLASS_POINT & V1, - const CLASS_POINT & V2, - const CLASS_POINT & V3) - { - m_min[0] = BT_MIN3(V1[0],V2[0],V3[0]); - m_min[1] = BT_MIN3(V1[1],V2[1],V3[1]); - m_min[2] = BT_MIN3(V1[2],V2[2],V3[2]); - - m_max[0] = BT_MAX3(V1[0],V2[0],V3[0]); - m_max[1] = BT_MAX3(V1[1],V2[1],V3[1]); - m_max[2] = BT_MAX3(V1[2],V2[2],V3[2]); - } - - template - SIMD_FORCE_INLINE void calc_from_triangle_margin( - const CLASS_POINT & V1, - const CLASS_POINT & V2, - const CLASS_POINT & V3, btScalar margin) - { - m_min[0] = BT_MIN3(V1[0],V2[0],V3[0]); - m_min[1] = BT_MIN3(V1[1],V2[1],V3[1]); - m_min[2] = BT_MIN3(V1[2],V2[2],V3[2]); - - m_max[0] = BT_MAX3(V1[0],V2[0],V3[0]); - m_max[1] = BT_MAX3(V1[1],V2[1],V3[1]); - m_max[2] = BT_MAX3(V1[2],V2[2],V3[2]); - - m_min[0] -= margin; - m_min[1] -= margin; - m_min[2] -= margin; - m_max[0] += margin; - m_max[1] += margin; - m_max[2] += margin; - } - - //! Apply a transform to an AABB - SIMD_FORCE_INLINE void appy_transform(const btTransform & trans) - { - btVector3 center = (m_max+m_min)*0.5f; - btVector3 extends = m_max - center; - // Compute new center - center = trans(center); - - btVector3 textends(extends.dot(trans.getBasis().getRow(0).absolute()), - extends.dot(trans.getBasis().getRow(1).absolute()), - extends.dot(trans.getBasis().getRow(2).absolute())); - - m_min = center - textends; - m_max = center + textends; - } - - - //! Apply a transform to an AABB - SIMD_FORCE_INLINE void appy_transform_trans_cache(const BT_BOX_BOX_TRANSFORM_CACHE & trans) - { - btVector3 center = (m_max+m_min)*0.5f; - btVector3 extends = m_max - center; - // Compute new center - center = trans.transform(center); - - btVector3 textends(extends.dot(trans.m_R1to0.getRow(0).absolute()), - extends.dot(trans.m_R1to0.getRow(1).absolute()), - extends.dot(trans.m_R1to0.getRow(2).absolute())); - - m_min = center - textends; - m_max = center + textends; - } - - //! Merges a Box - SIMD_FORCE_INLINE void merge(const btAABB & box) - { - m_min[0] = BT_MIN(m_min[0],box.m_min[0]); - m_min[1] = BT_MIN(m_min[1],box.m_min[1]); - m_min[2] = BT_MIN(m_min[2],box.m_min[2]); - - m_max[0] = BT_MAX(m_max[0],box.m_max[0]); - m_max[1] = BT_MAX(m_max[1],box.m_max[1]); - m_max[2] = BT_MAX(m_max[2],box.m_max[2]); - } - - //! Merges a point - template - SIMD_FORCE_INLINE void merge_point(const CLASS_POINT & point) - { - m_min[0] = BT_MIN(m_min[0],point[0]); - m_min[1] = BT_MIN(m_min[1],point[1]); - m_min[2] = BT_MIN(m_min[2],point[2]); - - m_max[0] = BT_MAX(m_max[0],point[0]); - m_max[1] = BT_MAX(m_max[1],point[1]); - m_max[2] = BT_MAX(m_max[2],point[2]); - } - - //! Gets the extend and center - SIMD_FORCE_INLINE void get_center_extend(btVector3 & center,btVector3 & extend) const - { - center = (m_max+m_min)*0.5f; - extend = m_max - center; - } - - //! Finds the intersecting box between this box and the other. - SIMD_FORCE_INLINE void find_intersection(const btAABB & other, btAABB & intersection) const - { - intersection.m_min[0] = BT_MAX(other.m_min[0],m_min[0]); - intersection.m_min[1] = BT_MAX(other.m_min[1],m_min[1]); - intersection.m_min[2] = BT_MAX(other.m_min[2],m_min[2]); - - intersection.m_max[0] = BT_MIN(other.m_max[0],m_max[0]); - intersection.m_max[1] = BT_MIN(other.m_max[1],m_max[1]); - intersection.m_max[2] = BT_MIN(other.m_max[2],m_max[2]); - } - - - SIMD_FORCE_INLINE bool has_collision(const btAABB & other) const - { - if(m_min[0] > other.m_max[0] || - m_max[0] < other.m_min[0] || - m_min[1] > other.m_max[1] || - m_max[1] < other.m_min[1] || - m_min[2] > other.m_max[2] || - m_max[2] < other.m_min[2]) - { - return false; - } - return true; - } - - /*! \brief Finds the Ray intersection parameter. - \param aabb Aligned box - \param vorigin A vec3f with the origin of the ray - \param vdir A vec3f with the direction of the ray - */ - SIMD_FORCE_INLINE bool collide_ray(const btVector3 & vorigin,const btVector3 & vdir) const - { - btVector3 extents,center; - this->get_center_extend(center,extents);; - - btScalar Dx = vorigin[0] - center[0]; - if(BT_GREATER(Dx, extents[0]) && Dx*vdir[0]>=0.0f) return false; - btScalar Dy = vorigin[1] - center[1]; - if(BT_GREATER(Dy, extents[1]) && Dy*vdir[1]>=0.0f) return false; - btScalar Dz = vorigin[2] - center[2]; - if(BT_GREATER(Dz, extents[2]) && Dz*vdir[2]>=0.0f) return false; - - - btScalar f = vdir[1] * Dz - vdir[2] * Dy; - if(btFabs(f) > extents[1]*btFabs(vdir[2]) + extents[2]*btFabs(vdir[1])) return false; - f = vdir[2] * Dx - vdir[0] * Dz; - if(btFabs(f) > extents[0]*btFabs(vdir[2]) + extents[2]*btFabs(vdir[0]))return false; - f = vdir[0] * Dy - vdir[1] * Dx; - if(btFabs(f) > extents[0]*btFabs(vdir[1]) + extents[1]*btFabs(vdir[0]))return false; - return true; - } - - - SIMD_FORCE_INLINE void projection_interval(const btVector3 & direction, btScalar &vmin, btScalar &vmax) const - { - btVector3 center = (m_max+m_min)*0.5f; - btVector3 extend = m_max-center; - - btScalar _fOrigin = direction.dot(center); - btScalar _fMaximumExtent = extend.dot(direction.absolute()); - vmin = _fOrigin - _fMaximumExtent; - vmax = _fOrigin + _fMaximumExtent; - } - - SIMD_FORCE_INLINE eBT_PLANE_INTERSECTION_TYPE plane_classify(const btVector4 &plane) const - { - btScalar _fmin,_fmax; - this->projection_interval(plane,_fmin,_fmax); - - if(plane[3] > _fmax + BOX_PLANE_EPSILON) - { - return BT_CONST_BACK_PLANE; // 0 - } - - if(plane[3]+BOX_PLANE_EPSILON >=_fmin) - { - return BT_CONST_COLLIDE_PLANE; //1 - } - return BT_CONST_FRONT_PLANE;//2 - } - - SIMD_FORCE_INLINE bool overlapping_trans_conservative(const btAABB & box, btTransform & trans1_to_0) const - { - btAABB tbox = box; - tbox.appy_transform(trans1_to_0); - return has_collision(tbox); - } - - SIMD_FORCE_INLINE bool overlapping_trans_conservative2(const btAABB & box, - const BT_BOX_BOX_TRANSFORM_CACHE & trans1_to_0) const - { - btAABB tbox = box; - tbox.appy_transform_trans_cache(trans1_to_0); - return has_collision(tbox); - } - - //! transcache is the transformation cache from box to this AABB - SIMD_FORCE_INLINE bool overlapping_trans_cache( - const btAABB & box,const BT_BOX_BOX_TRANSFORM_CACHE & transcache, bool fulltest) const - { - - //Taken from OPCODE - btVector3 ea,eb;//extends - btVector3 ca,cb;//extends - get_center_extend(ca,ea); - box.get_center_extend(cb,eb); - - - btVector3 T; - btScalar t,t2; - int i; - - // Class I : A's basis vectors - for(i=0;i<3;i++) - { - T[i] = transcache.m_R1to0[i].dot(cb) + transcache.m_T1to0[i] - ca[i]; - t = transcache.m_AR[i].dot(eb) + ea[i]; - if(BT_GREATER(T[i], t)) return false; - } - // Class II : B's basis vectors - for(i=0;i<3;i++) - { - t = bt_mat3_dot_col(transcache.m_R1to0,T,i); - t2 = bt_mat3_dot_col(transcache.m_AR,ea,i) + eb[i]; - if(BT_GREATER(t,t2)) return false; - } - // Class III : 9 cross products - if(fulltest) - { - int j,m,n,o,p,q,r; - for(i=0;i<3;i++) - { - m = (i+1)%3; - n = (i+2)%3; - o = i==0?1:0; - p = i==2?1:2; - for(j=0;j<3;j++) - { - q = j==2?1:2; - r = j==0?1:0; - t = T[n]*transcache.m_R1to0[m][j] - T[m]*transcache.m_R1to0[n][j]; - t2 = ea[o]*transcache.m_AR[p][j] + ea[p]*transcache.m_AR[o][j] + - eb[r]*transcache.m_AR[i][q] + eb[q]*transcache.m_AR[i][r]; - if(BT_GREATER(t,t2)) return false; - } - } - } - return true; - } - - //! Simple test for planes. - SIMD_FORCE_INLINE bool collide_plane( - const btVector4 & plane) const - { - eBT_PLANE_INTERSECTION_TYPE classify = plane_classify(plane); - return (classify == BT_CONST_COLLIDE_PLANE); - } - - //! test for a triangle, with edges - SIMD_FORCE_INLINE bool collide_triangle_exact( - const btVector3 & p1, - const btVector3 & p2, - const btVector3 & p3, - const btVector4 & triangle_plane) const - { - if(!collide_plane(triangle_plane)) return false; - - btVector3 center,extends; - this->get_center_extend(center,extends); - - const btVector3 v1(p1 - center); - const btVector3 v2(p2 - center); - const btVector3 v3(p3 - center); - - //First axis - btVector3 diff(v2 - v1); - btVector3 abs_diff = diff.absolute(); - //Test With X axis - TEST_CROSS_EDGE_BOX_X_AXIS_MCR(diff,abs_diff,v1,v3,extends); - //Test With Y axis - TEST_CROSS_EDGE_BOX_Y_AXIS_MCR(diff,abs_diff,v1,v3,extends); - //Test With Z axis - TEST_CROSS_EDGE_BOX_Z_AXIS_MCR(diff,abs_diff,v1,v3,extends); - - - diff = v3 - v2; - abs_diff = diff.absolute(); - //Test With X axis - TEST_CROSS_EDGE_BOX_X_AXIS_MCR(diff,abs_diff,v2,v1,extends); - //Test With Y axis - TEST_CROSS_EDGE_BOX_Y_AXIS_MCR(diff,abs_diff,v2,v1,extends); - //Test With Z axis - TEST_CROSS_EDGE_BOX_Z_AXIS_MCR(diff,abs_diff,v2,v1,extends); - - diff = v1 - v3; - abs_diff = diff.absolute(); - //Test With X axis - TEST_CROSS_EDGE_BOX_X_AXIS_MCR(diff,abs_diff,v3,v2,extends); - //Test With Y axis - TEST_CROSS_EDGE_BOX_Y_AXIS_MCR(diff,abs_diff,v3,v2,extends); - //Test With Z axis - TEST_CROSS_EDGE_BOX_Z_AXIS_MCR(diff,abs_diff,v3,v2,extends); - - return true; - } -}; - - -//! Compairison of transformation objects -SIMD_FORCE_INLINE bool btCompareTransformsEqual(const btTransform & t1,const btTransform & t2) -{ - if(!(t1.getOrigin() == t2.getOrigin()) ) return false; - - if(!(t1.getBasis().getRow(0) == t2.getBasis().getRow(0)) ) return false; - if(!(t1.getBasis().getRow(1) == t2.getBasis().getRow(1)) ) return false; - if(!(t1.getBasis().getRow(2) == t2.getBasis().getRow(2)) ) return false; - return true; -} - - - -#endif // GIM_BOX_COLLISION_H_INCLUDED diff --git a/bullet/src/BulletCollision/Gimpact/btClipPolygon.h b/bullet/src/BulletCollision/Gimpact/btClipPolygon.h deleted file mode 100644 index 501c21514..000000000 --- a/bullet/src/BulletCollision/Gimpact/btClipPolygon.h +++ /dev/null @@ -1,182 +0,0 @@ -#ifndef BT_CLIP_POLYGON_H_INCLUDED -#define BT_CLIP_POLYGON_H_INCLUDED - -/*! \file btClipPolygon.h -\author Francisco Len Njera -*/ -/* -This source file is part of GIMPACT Library. - -For the latest info, see http://gimpact.sourceforge.net/ - -Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371. -email: projectileman@yahoo.com - - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "LinearMath/btTransform.h" -#include "LinearMath/btGeometryUtil.h" - - -SIMD_FORCE_INLINE btScalar bt_distance_point_plane(const btVector4 & plane,const btVector3 &point) -{ - return point.dot(plane) - plane[3]; -} - -/*! Vector blending -Takes two vectors a, b, blends them together*/ -SIMD_FORCE_INLINE void bt_vec_blend(btVector3 &vr, const btVector3 &va,const btVector3 &vb, btScalar blend_factor) -{ - vr = (1-blend_factor)*va + blend_factor*vb; -} - -//! This function calcs the distance from a 3D plane -SIMD_FORCE_INLINE void bt_plane_clip_polygon_collect( - const btVector3 & point0, - const btVector3 & point1, - btScalar dist0, - btScalar dist1, - btVector3 * clipped, - int & clipped_count) -{ - bool _prevclassif = (dist0>SIMD_EPSILON); - bool _classif = (dist1>SIMD_EPSILON); - if(_classif!=_prevclassif) - { - btScalar blendfactor = -dist0/(dist1-dist0); - bt_vec_blend(clipped[clipped_count],point0,point1,blendfactor); - clipped_count++; - } - if(!_classif) - { - clipped[clipped_count] = point1; - clipped_count++; - } -} - - -//! Clips a polygon by a plane -/*! -*\return The count of the clipped counts -*/ -SIMD_FORCE_INLINE int bt_plane_clip_polygon( - const btVector4 & plane, - const btVector3 * polygon_points, - int polygon_point_count, - btVector3 * clipped) -{ - int clipped_count = 0; - - - //clip first point - btScalar firstdist = bt_distance_point_plane(plane,polygon_points[0]);; - if(!(firstdist>SIMD_EPSILON)) - { - clipped[clipped_count] = polygon_points[0]; - clipped_count++; - } - - btScalar olddist = firstdist; - for(int i=1;iSIMD_EPSILON)) - { - clipped[clipped_count] = point0; - clipped_count++; - } - - // point 1 - btScalar olddist = firstdist; - btScalar dist = bt_distance_point_plane(plane,point1); - - bt_plane_clip_polygon_collect( - point0,point1, - olddist, - dist, - clipped, - clipped_count); - - olddist = dist; - - - // point 2 - dist = bt_distance_point_plane(plane,point2); - - bt_plane_clip_polygon_collect( - point1,point2, - olddist, - dist, - clipped, - clipped_count); - olddist = dist; - - - - //RETURN TO FIRST point0 - bt_plane_clip_polygon_collect( - point2,point0, - olddist, - firstdist, - clipped, - clipped_count); - - return clipped_count; -} - - - - - -#endif // GIM_TRI_COLLISION_H_INCLUDED diff --git a/bullet/src/BulletCollision/Gimpact/btContactProcessing.cpp b/bullet/src/BulletCollision/Gimpact/btContactProcessing.cpp deleted file mode 100644 index d5a3f0694..000000000 --- a/bullet/src/BulletCollision/Gimpact/btContactProcessing.cpp +++ /dev/null @@ -1,181 +0,0 @@ - -/* -This source file is part of GIMPACT Library. - -For the latest info, see http://gimpact.sourceforge.net/ - -Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371. -email: projectileman@yahoo.com - - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ -#include "btContactProcessing.h" - -#define MAX_COINCIDENT 8 - -struct CONTACT_KEY_TOKEN -{ - unsigned int m_key; - int m_value; - CONTACT_KEY_TOKEN() - { - } - - CONTACT_KEY_TOKEN(unsigned int key,int token) - { - m_key = key; - m_value = token; - } - - CONTACT_KEY_TOKEN(const CONTACT_KEY_TOKEN& rtoken) - { - m_key = rtoken.m_key; - m_value = rtoken.m_value; - } - - inline bool operator <(const CONTACT_KEY_TOKEN& other) const - { - return (m_key < other.m_key); - } - - inline bool operator >(const CONTACT_KEY_TOKEN& other) const - { - return (m_key > other.m_key); - } - -}; - -class CONTACT_KEY_TOKEN_COMP -{ - public: - - bool operator() ( const CONTACT_KEY_TOKEN& a, const CONTACT_KEY_TOKEN& b ) - { - return ( a < b ); - } -}; - - -void btContactArray::merge_contacts( - const btContactArray & contacts, bool normal_contact_average) -{ - clear(); - - int i; - if(contacts.size()==0) return; - - - if(contacts.size()==1) - { - push_back(contacts[0]); - return; - } - - btAlignedObjectArray keycontacts; - - keycontacts.reserve(contacts.size()); - - //fill key contacts - - for ( i = 0;im_depth - CONTACT_DIFF_EPSILON > scontact->m_depth)//) - { - *pcontact = *scontact; - coincident_count = 0; - } - else if(normal_contact_average) - { - if(btFabs(pcontact->m_depth - scontact->m_depth)m_normal; - coincident_count++; - } - } - } - } - else - {//add new contact - - if(normal_contact_average && coincident_count>0) - { - pcontact->interpolate_normals(coincident_normals,coincident_count); - coincident_count = 0; - } - - push_back(*scontact); - pcontact = &(*this)[this->size()-1]; - } - last_key = key; - } -} - -void btContactArray::merge_contacts_unique(const btContactArray & contacts) -{ - clear(); - - if(contacts.size()==0) return; - - if(contacts.size()==1) - { - push_back(contacts[0]); - return; - } - - GIM_CONTACT average_contact = contacts[0]; - - for (int i=1;i -{ -public: - btContactArray() - { - reserve(64); - } - - SIMD_FORCE_INLINE void push_contact( - const btVector3 &point,const btVector3 & normal, - btScalar depth, int feature1, int feature2) - { - push_back( GIM_CONTACT(point,normal,depth,feature1,feature2) ); - } - - SIMD_FORCE_INLINE void push_triangle_contacts( - const GIM_TRIANGLE_CONTACT & tricontact, - int feature1,int feature2) - { - for(int i = 0;i splitValue) - { - //swap - primitive_boxes.swap(i,splitIndex); - //swapLeafNodes(i,splitIndex); - splitIndex++; - } - } - - //if the splitIndex causes unbalanced trees, fix this by using the center in between startIndex and endIndex - //otherwise the tree-building might fail due to stack-overflows in certain cases. - //unbalanced1 is unsafe: it can cause stack overflows - //bool unbalanced1 = ((splitIndex==startIndex) || (splitIndex == (endIndex-1))); - - //unbalanced2 should work too: always use center (perfect balanced trees) - //bool unbalanced2 = true; - - //this should be safe too: - int rangeBalancedIndices = numIndices/3; - bool unbalanced = ((splitIndex<=(startIndex+rangeBalancedIndices)) || (splitIndex >=(endIndex-1-rangeBalancedIndices))); - - if (unbalanced) - { - splitIndex = startIndex+ (numIndices>>1); - } - - btAssert(!((splitIndex==startIndex) || (splitIndex == (endIndex)))); - - return splitIndex; - -} - - -void btBvhTree::_build_sub_tree(GIM_BVH_DATA_ARRAY & primitive_boxes, int startIndex, int endIndex) -{ - int curIndex = m_num_nodes; - m_num_nodes++; - - btAssert((endIndex-startIndex)>0); - - if ((endIndex-startIndex)==1) - { - //We have a leaf node - setNodeBound(curIndex,primitive_boxes[startIndex].m_bound); - m_node_array[curIndex].setDataIndex(primitive_boxes[startIndex].m_data); - - return; - } - //calculate Best Splitting Axis and where to split it. Sort the incoming 'leafNodes' array within range 'startIndex/endIndex'. - - //split axis - int splitIndex = _calc_splitting_axis(primitive_boxes,startIndex,endIndex); - - splitIndex = _sort_and_calc_splitting_index( - primitive_boxes,startIndex,endIndex, - splitIndex//split axis - ); - - - //calc this node bounding box - - btAABB node_bound; - node_bound.invalidate(); - - for (int i=startIndex;iget_primitive_box(getNodeData(nodecount),leafbox); - setNodeBound(nodecount,leafbox); - } - else - { - //const GIM_BVH_TREE_NODE * nodepointer = get_node_pointer(nodecount); - //get left bound - btAABB bound; - bound.invalidate(); - - btAABB temp_box; - - int child_node = getLeftNode(nodecount); - if(child_node) - { - getNodeBound(child_node,temp_box); - bound.merge(temp_box); - } - - child_node = getRightNode(nodecount); - if(child_node) - { - getNodeBound(child_node,temp_box); - bound.merge(temp_box); - } - - setNodeBound(nodecount,bound); - } - } -} - -//! this rebuild the entire set -void btGImpactBvh::buildSet() -{ - //obtain primitive boxes - GIM_BVH_DATA_ARRAY primitive_boxes; - primitive_boxes.resize(m_primitive_manager->get_primitive_count()); - - for (int i = 0;iget_primitive_box(i,primitive_boxes[i].m_bound); - primitive_boxes[i].m_data = i; - } - - m_box_tree.build_tree(primitive_boxes); -} - -//! returns the indices of the primitives in the m_primitive_manager -bool btGImpactBvh::boxQuery(const btAABB & box, btAlignedObjectArray & collided_results) const -{ - int curIndex = 0; - int numNodes = getNodeCount(); - - while (curIndex < numNodes) - { - btAABB bound; - getNodeBound(curIndex,bound); - - //catch bugs in tree data - - bool aabbOverlap = bound.has_collision(box); - bool isleafnode = isLeafNode(curIndex); - - if (isleafnode && aabbOverlap) - { - collided_results.push_back(getNodeData(curIndex)); - } - - if (aabbOverlap || isleafnode) - { - //next subnode - curIndex++; - } - else - { - //skip node - curIndex+= getEscapeNodeIndex(curIndex); - } - } - if(collided_results.size()>0) return true; - return false; -} - - - -//! returns the indices of the primitives in the m_primitive_manager -bool btGImpactBvh::rayQuery( - const btVector3 & ray_dir,const btVector3 & ray_origin , - btAlignedObjectArray & collided_results) const -{ - int curIndex = 0; - int numNodes = getNodeCount(); - - while (curIndex < numNodes) - { - btAABB bound; - getNodeBound(curIndex,bound); - - //catch bugs in tree data - - bool aabbOverlap = bound.collide_ray(ray_origin,ray_dir); - bool isleafnode = isLeafNode(curIndex); - - if (isleafnode && aabbOverlap) - { - collided_results.push_back(getNodeData( curIndex)); - } - - if (aabbOverlap || isleafnode) - { - //next subnode - curIndex++; - } - else - { - //skip node - curIndex+= getEscapeNodeIndex(curIndex); - } - } - if(collided_results.size()>0) return true; - return false; -} - - -SIMD_FORCE_INLINE bool _node_collision( - btGImpactBvh * boxset0, btGImpactBvh * boxset1, - const BT_BOX_BOX_TRANSFORM_CACHE & trans_cache_1to0, - int node0 ,int node1, bool complete_primitive_tests) -{ - btAABB box0; - boxset0->getNodeBound(node0,box0); - btAABB box1; - boxset1->getNodeBound(node1,box1); - - return box0.overlapping_trans_cache(box1,trans_cache_1to0,complete_primitive_tests ); -// box1.appy_transform_trans_cache(trans_cache_1to0); -// return box0.has_collision(box1); - -} - - -//stackless recursive collision routine -static void _find_collision_pairs_recursive( - btGImpactBvh * boxset0, btGImpactBvh * boxset1, - btPairSet * collision_pairs, - const BT_BOX_BOX_TRANSFORM_CACHE & trans_cache_1to0, - int node0, int node1, bool complete_primitive_tests) -{ - - - - if( _node_collision( - boxset0,boxset1,trans_cache_1to0, - node0,node1,complete_primitive_tests) ==false) return;//avoid colliding internal nodes - - if(boxset0->isLeafNode(node0)) - { - if(boxset1->isLeafNode(node1)) - { - // collision result - collision_pairs->push_pair( - boxset0->getNodeData(node0),boxset1->getNodeData(node1)); - return; - } - else - { - - //collide left recursive - - _find_collision_pairs_recursive( - boxset0,boxset1, - collision_pairs,trans_cache_1to0, - node0,boxset1->getLeftNode(node1),false); - - //collide right recursive - _find_collision_pairs_recursive( - boxset0,boxset1, - collision_pairs,trans_cache_1to0, - node0,boxset1->getRightNode(node1),false); - - - } - } - else - { - if(boxset1->isLeafNode(node1)) - { - - //collide left recursive - _find_collision_pairs_recursive( - boxset0,boxset1, - collision_pairs,trans_cache_1to0, - boxset0->getLeftNode(node0),node1,false); - - - //collide right recursive - - _find_collision_pairs_recursive( - boxset0,boxset1, - collision_pairs,trans_cache_1to0, - boxset0->getRightNode(node0),node1,false); - - - } - else - { - //collide left0 left1 - - - - _find_collision_pairs_recursive( - boxset0,boxset1, - collision_pairs,trans_cache_1to0, - boxset0->getLeftNode(node0),boxset1->getLeftNode(node1),false); - - //collide left0 right1 - - _find_collision_pairs_recursive( - boxset0,boxset1, - collision_pairs,trans_cache_1to0, - boxset0->getLeftNode(node0),boxset1->getRightNode(node1),false); - - - //collide right0 left1 - - _find_collision_pairs_recursive( - boxset0,boxset1, - collision_pairs,trans_cache_1to0, - boxset0->getRightNode(node0),boxset1->getLeftNode(node1),false); - - //collide right0 right1 - - _find_collision_pairs_recursive( - boxset0,boxset1, - collision_pairs,trans_cache_1to0, - boxset0->getRightNode(node0),boxset1->getRightNode(node1),false); - - }// else if node1 is not a leaf - }// else if node0 is not a leaf -} - - -void btGImpactBvh::find_collision(btGImpactBvh * boxset0, const btTransform & trans0, - btGImpactBvh * boxset1, const btTransform & trans1, - btPairSet & collision_pairs) -{ - - if(boxset0->getNodeCount()==0 || boxset1->getNodeCount()==0 ) return; - - BT_BOX_BOX_TRANSFORM_CACHE trans_cache_1to0; - - trans_cache_1to0.calc_from_homogenic(trans0,trans1); - -#ifdef TRI_COLLISION_PROFILING - bt_begin_gim02_tree_time(); -#endif //TRI_COLLISION_PROFILING - - _find_collision_pairs_recursive( - boxset0,boxset1, - &collision_pairs,trans_cache_1to0,0,0,true); -#ifdef TRI_COLLISION_PROFILING - bt_end_gim02_tree_time(); -#endif //TRI_COLLISION_PROFILING - -} - diff --git a/bullet/src/BulletCollision/Gimpact/btGImpactBvh.h b/bullet/src/BulletCollision/Gimpact/btGImpactBvh.h deleted file mode 100644 index f76fa73c5..000000000 --- a/bullet/src/BulletCollision/Gimpact/btGImpactBvh.h +++ /dev/null @@ -1,396 +0,0 @@ -#ifndef GIM_BOX_SET_H_INCLUDED -#define GIM_BOX_SET_H_INCLUDED - -/*! \file gim_box_set.h -\author Francisco Len Njera -*/ -/* -This source file is part of GIMPACT Library. - -For the latest info, see http://gimpact.sourceforge.net/ - -Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371. -email: projectileman@yahoo.com - - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#include "LinearMath/btAlignedObjectArray.h" - -#include "btBoxCollision.h" -#include "btTriangleShapeEx.h" - - - - - -//! Overlapping pair -struct GIM_PAIR -{ - int m_index1; - int m_index2; - GIM_PAIR() - {} - - GIM_PAIR(const GIM_PAIR & p) - { - m_index1 = p.m_index1; - m_index2 = p.m_index2; - } - - GIM_PAIR(int index1, int index2) - { - m_index1 = index1; - m_index2 = index2; - } -}; - -//! A pairset array -class btPairSet: public btAlignedObjectArray -{ -public: - btPairSet() - { - reserve(32); - } - inline void push_pair(int index1,int index2) - { - push_back(GIM_PAIR(index1,index2)); - } - - inline void push_pair_inv(int index1,int index2) - { - push_back(GIM_PAIR(index2,index1)); - } -}; - - -///GIM_BVH_DATA is an internal GIMPACT collision structure to contain axis aligned bounding box -struct GIM_BVH_DATA -{ - btAABB m_bound; - int m_data; -}; - -//! Node Structure for trees -class GIM_BVH_TREE_NODE -{ -public: - btAABB m_bound; -protected: - int m_escapeIndexOrDataIndex; -public: - GIM_BVH_TREE_NODE() - { - m_escapeIndexOrDataIndex = 0; - } - - SIMD_FORCE_INLINE bool isLeafNode() const - { - //skipindex is negative (internal node), triangleindex >=0 (leafnode) - return (m_escapeIndexOrDataIndex>=0); - } - - SIMD_FORCE_INLINE int getEscapeIndex() const - { - //btAssert(m_escapeIndexOrDataIndex < 0); - return -m_escapeIndexOrDataIndex; - } - - SIMD_FORCE_INLINE void setEscapeIndex(int index) - { - m_escapeIndexOrDataIndex = -index; - } - - SIMD_FORCE_INLINE int getDataIndex() const - { - //btAssert(m_escapeIndexOrDataIndex >= 0); - - return m_escapeIndexOrDataIndex; - } - - SIMD_FORCE_INLINE void setDataIndex(int index) - { - m_escapeIndexOrDataIndex = index; - } - -}; - - -class GIM_BVH_DATA_ARRAY:public btAlignedObjectArray -{ -}; - - -class GIM_BVH_TREE_NODE_ARRAY:public btAlignedObjectArray -{ -}; - - - - -//! Basic Box tree structure -class btBvhTree -{ -protected: - int m_num_nodes; - GIM_BVH_TREE_NODE_ARRAY m_node_array; -protected: - int _sort_and_calc_splitting_index( - GIM_BVH_DATA_ARRAY & primitive_boxes, - int startIndex, int endIndex, int splitAxis); - - int _calc_splitting_axis(GIM_BVH_DATA_ARRAY & primitive_boxes, int startIndex, int endIndex); - - void _build_sub_tree(GIM_BVH_DATA_ARRAY & primitive_boxes, int startIndex, int endIndex); -public: - btBvhTree() - { - m_num_nodes = 0; - } - - //! prototype functions for box tree management - //!@{ - void build_tree(GIM_BVH_DATA_ARRAY & primitive_boxes); - - SIMD_FORCE_INLINE void clearNodes() - { - m_node_array.clear(); - m_num_nodes = 0; - } - - //! node count - SIMD_FORCE_INLINE int getNodeCount() const - { - return m_num_nodes; - } - - //! tells if the node is a leaf - SIMD_FORCE_INLINE bool isLeafNode(int nodeindex) const - { - return m_node_array[nodeindex].isLeafNode(); - } - - SIMD_FORCE_INLINE int getNodeData(int nodeindex) const - { - return m_node_array[nodeindex].getDataIndex(); - } - - SIMD_FORCE_INLINE void getNodeBound(int nodeindex, btAABB & bound) const - { - bound = m_node_array[nodeindex].m_bound; - } - - SIMD_FORCE_INLINE void setNodeBound(int nodeindex, const btAABB & bound) - { - m_node_array[nodeindex].m_bound = bound; - } - - SIMD_FORCE_INLINE int getLeftNode(int nodeindex) const - { - return nodeindex+1; - } - - SIMD_FORCE_INLINE int getRightNode(int nodeindex) const - { - if(m_node_array[nodeindex+1].isLeafNode()) return nodeindex+2; - return nodeindex+1 + m_node_array[nodeindex+1].getEscapeIndex(); - } - - SIMD_FORCE_INLINE int getEscapeNodeIndex(int nodeindex) const - { - return m_node_array[nodeindex].getEscapeIndex(); - } - - SIMD_FORCE_INLINE const GIM_BVH_TREE_NODE * get_node_pointer(int index = 0) const - { - return &m_node_array[index]; - } - - //!@} -}; - - -//! Prototype Base class for primitive classification -/*! -This class is a wrapper for primitive collections. -This tells relevant info for the Bounding Box set classes, which take care of space classification. -This class can manage Compound shapes and trimeshes, and if it is managing trimesh then the Hierarchy Bounding Box classes will take advantage of primitive Vs Box overlapping tests for getting optimal results and less Per Box compairisons. -*/ -class btPrimitiveManagerBase -{ -public: - - virtual ~btPrimitiveManagerBase() {} - - //! determines if this manager consist on only triangles, which special case will be optimized - virtual bool is_trimesh() const = 0; - virtual int get_primitive_count() const = 0; - virtual void get_primitive_box(int prim_index ,btAABB & primbox) const = 0; - //! retrieves only the points of the triangle, and the collision margin - virtual void get_primitive_triangle(int prim_index,btPrimitiveTriangle & triangle) const= 0; -}; - - -//! Structure for containing Boxes -/*! -This class offers an structure for managing a box tree of primitives. -Requires a Primitive prototype (like btPrimitiveManagerBase ) -*/ -class btGImpactBvh -{ -protected: - btBvhTree m_box_tree; - btPrimitiveManagerBase * m_primitive_manager; - -protected: - //stackless refit - void refit(); -public: - - //! this constructor doesn't build the tree. you must call buildSet - btGImpactBvh() - { - m_primitive_manager = NULL; - } - - //! this constructor doesn't build the tree. you must call buildSet - btGImpactBvh(btPrimitiveManagerBase * primitive_manager) - { - m_primitive_manager = primitive_manager; - } - - SIMD_FORCE_INLINE btAABB getGlobalBox() const - { - btAABB totalbox; - getNodeBound(0, totalbox); - return totalbox; - } - - SIMD_FORCE_INLINE void setPrimitiveManager(btPrimitiveManagerBase * primitive_manager) - { - m_primitive_manager = primitive_manager; - } - - SIMD_FORCE_INLINE btPrimitiveManagerBase * getPrimitiveManager() const - { - return m_primitive_manager; - } - - -//! node manager prototype functions -///@{ - - //! this attemps to refit the box set. - SIMD_FORCE_INLINE void update() - { - refit(); - } - - //! this rebuild the entire set - void buildSet(); - - //! returns the indices of the primitives in the m_primitive_manager - bool boxQuery(const btAABB & box, btAlignedObjectArray & collided_results) const; - - //! returns the indices of the primitives in the m_primitive_manager - SIMD_FORCE_INLINE bool boxQueryTrans(const btAABB & box, - const btTransform & transform, btAlignedObjectArray & collided_results) const - { - btAABB transbox=box; - transbox.appy_transform(transform); - return boxQuery(transbox,collided_results); - } - - //! returns the indices of the primitives in the m_primitive_manager - bool rayQuery( - const btVector3 & ray_dir,const btVector3 & ray_origin , - btAlignedObjectArray & collided_results) const; - - //! tells if this set has hierarcht - SIMD_FORCE_INLINE bool hasHierarchy() const - { - return true; - } - - //! tells if this set is a trimesh - SIMD_FORCE_INLINE bool isTrimesh() const - { - return m_primitive_manager->is_trimesh(); - } - - //! node count - SIMD_FORCE_INLINE int getNodeCount() const - { - return m_box_tree.getNodeCount(); - } - - //! tells if the node is a leaf - SIMD_FORCE_INLINE bool isLeafNode(int nodeindex) const - { - return m_box_tree.isLeafNode(nodeindex); - } - - SIMD_FORCE_INLINE int getNodeData(int nodeindex) const - { - return m_box_tree.getNodeData(nodeindex); - } - - SIMD_FORCE_INLINE void getNodeBound(int nodeindex, btAABB & bound) const - { - m_box_tree.getNodeBound(nodeindex, bound); - } - - SIMD_FORCE_INLINE void setNodeBound(int nodeindex, const btAABB & bound) - { - m_box_tree.setNodeBound(nodeindex, bound); - } - - - SIMD_FORCE_INLINE int getLeftNode(int nodeindex) const - { - return m_box_tree.getLeftNode(nodeindex); - } - - SIMD_FORCE_INLINE int getRightNode(int nodeindex) const - { - return m_box_tree.getRightNode(nodeindex); - } - - SIMD_FORCE_INLINE int getEscapeNodeIndex(int nodeindex) const - { - return m_box_tree.getEscapeNodeIndex(nodeindex); - } - - SIMD_FORCE_INLINE void getNodeTriangle(int nodeindex,btPrimitiveTriangle & triangle) const - { - m_primitive_manager->get_primitive_triangle(getNodeData(nodeindex),triangle); - } - - - SIMD_FORCE_INLINE const GIM_BVH_TREE_NODE * get_node_pointer(int index = 0) const - { - return m_box_tree.get_node_pointer(index); - } - - - static float getAverageTreeCollisionTime(); - - - static void find_collision(btGImpactBvh * boxset1, const btTransform & trans1, - btGImpactBvh * boxset2, const btTransform & trans2, - btPairSet & collision_pairs); -}; - - -#endif // GIM_BOXPRUNING_H_INCLUDED diff --git a/bullet/src/BulletCollision/Gimpact/btGImpactCollisionAlgorithm.cpp b/bullet/src/BulletCollision/Gimpact/btGImpactCollisionAlgorithm.cpp deleted file mode 100644 index 7ed4c4005..000000000 --- a/bullet/src/BulletCollision/Gimpact/btGImpactCollisionAlgorithm.cpp +++ /dev/null @@ -1,902 +0,0 @@ -/* -This source file is part of GIMPACT Library. - -For the latest info, see http://gimpact.sourceforge.net/ - -Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371. -email: projectileman@yahoo.com - - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ -/* -Author: Francisco Len Njera -Concave-Concave Collision - -*/ - -#include "BulletCollision/CollisionDispatch/btManifoldResult.h" -#include "LinearMath/btIDebugDraw.h" -#include "BulletCollision/CollisionDispatch/btCollisionObject.h" -#include "BulletCollision/CollisionShapes/btBoxShape.h" -#include "btGImpactCollisionAlgorithm.h" -#include "btContactProcessing.h" -#include "LinearMath/btQuickprof.h" - - -//! Class for accessing the plane equation -class btPlaneShape : public btStaticPlaneShape -{ -public: - - btPlaneShape(const btVector3& v, float f) - :btStaticPlaneShape(v,f) - { - } - - void get_plane_equation(btVector4 &equation) - { - equation[0] = m_planeNormal[0]; - equation[1] = m_planeNormal[1]; - equation[2] = m_planeNormal[2]; - equation[3] = m_planeConstant; - } - - - void get_plane_equation_transformed(const btTransform & trans,btVector4 &equation) - { - equation[0] = trans.getBasis().getRow(0).dot(m_planeNormal); - equation[1] = trans.getBasis().getRow(1).dot(m_planeNormal); - equation[2] = trans.getBasis().getRow(2).dot(m_planeNormal); - equation[3] = trans.getOrigin().dot(m_planeNormal) + m_planeConstant; - } -}; - - - -////////////////////////////////////////////////////////////////////////////////////////////// -#ifdef TRI_COLLISION_PROFILING - -btClock g_triangle_clock; - -float g_accum_triangle_collision_time = 0; -int g_count_triangle_collision = 0; - -void bt_begin_gim02_tri_time() -{ - g_triangle_clock.reset(); -} - -void bt_end_gim02_tri_time() -{ - g_accum_triangle_collision_time += g_triangle_clock.getTimeMicroseconds(); - g_count_triangle_collision++; -} -#endif //TRI_COLLISION_PROFILING -//! Retrieving shapes shapes -/*! -Declared here due of insuficent space on Pool allocators -*/ -//!@{ -class GIM_ShapeRetriever -{ -public: - btGImpactShapeInterface * m_gim_shape; - btTriangleShapeEx m_trishape; - btTetrahedronShapeEx m_tetrashape; - -public: - class ChildShapeRetriever - { - public: - GIM_ShapeRetriever * m_parent; - virtual btCollisionShape * getChildShape(int index) - { - return m_parent->m_gim_shape->getChildShape(index); - } - virtual ~ChildShapeRetriever() {} - }; - - class TriangleShapeRetriever:public ChildShapeRetriever - { - public: - - virtual btCollisionShape * getChildShape(int index) - { - m_parent->m_gim_shape->getBulletTriangle(index,m_parent->m_trishape); - return &m_parent->m_trishape; - } - virtual ~TriangleShapeRetriever() {} - }; - - class TetraShapeRetriever:public ChildShapeRetriever - { - public: - - virtual btCollisionShape * getChildShape(int index) - { - m_parent->m_gim_shape->getBulletTetrahedron(index,m_parent->m_tetrashape); - return &m_parent->m_tetrashape; - } - }; -public: - ChildShapeRetriever m_child_retriever; - TriangleShapeRetriever m_tri_retriever; - TetraShapeRetriever m_tetra_retriever; - ChildShapeRetriever * m_current_retriever; - - GIM_ShapeRetriever(btGImpactShapeInterface * gim_shape) - { - m_gim_shape = gim_shape; - //select retriever - if(m_gim_shape->needsRetrieveTriangles()) - { - m_current_retriever = &m_tri_retriever; - } - else if(m_gim_shape->needsRetrieveTetrahedrons()) - { - m_current_retriever = &m_tetra_retriever; - } - else - { - m_current_retriever = &m_child_retriever; - } - - m_current_retriever->m_parent = this; - } - - btCollisionShape * getChildShape(int index) - { - return m_current_retriever->getChildShape(index); - } - - -}; - - - -//!@} - - -#ifdef TRI_COLLISION_PROFILING - -//! Gets the average time in miliseconds of tree collisions -float btGImpactCollisionAlgorithm::getAverageTreeCollisionTime() -{ - return btGImpactBoxSet::getAverageTreeCollisionTime(); - -} - -//! Gets the average time in miliseconds of triangle collisions -float btGImpactCollisionAlgorithm::getAverageTriangleCollisionTime() -{ - if(g_count_triangle_collision == 0) return 0; - - float avgtime = g_accum_triangle_collision_time; - avgtime /= (float)g_count_triangle_collision; - - g_accum_triangle_collision_time = 0; - g_count_triangle_collision = 0; - - return avgtime; -} - -#endif //TRI_COLLISION_PROFILING - - - -btGImpactCollisionAlgorithm::btGImpactCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1) -: btActivatingCollisionAlgorithm(ci,body0,body1) -{ - m_manifoldPtr = NULL; - m_convex_algorithm = NULL; -} - -btGImpactCollisionAlgorithm::~btGImpactCollisionAlgorithm() -{ - clearCache(); -} - - - - - -void btGImpactCollisionAlgorithm::addContactPoint(btCollisionObject * body0, - btCollisionObject * body1, - const btVector3 & point, - const btVector3 & normal, - btScalar distance) -{ - m_resultOut->setShapeIdentifiersA(m_part0,m_triface0); - m_resultOut->setShapeIdentifiersB(m_part1,m_triface1); - checkManifold(body0,body1); - m_resultOut->addContactPoint(normal,point,distance); -} - - -void btGImpactCollisionAlgorithm::shape_vs_shape_collision( - btCollisionObject * body0, - btCollisionObject * body1, - btCollisionShape * shape0, - btCollisionShape * shape1) -{ - - btCollisionShape* tmpShape0 = body0->getCollisionShape(); - btCollisionShape* tmpShape1 = body1->getCollisionShape(); - - body0->internalSetTemporaryCollisionShape(shape0); - body1->internalSetTemporaryCollisionShape(shape1); - - { - btCollisionAlgorithm* algor = newAlgorithm(body0,body1); - // post : checkManifold is called - - m_resultOut->setShapeIdentifiersA(m_part0,m_triface0); - m_resultOut->setShapeIdentifiersB(m_part1,m_triface1); - - algor->processCollision(body0,body1,*m_dispatchInfo,m_resultOut); - - algor->~btCollisionAlgorithm(); - m_dispatcher->freeCollisionAlgorithm(algor); - } - - body0->internalSetTemporaryCollisionShape(tmpShape0); - body1->internalSetTemporaryCollisionShape(tmpShape1); -} - -void btGImpactCollisionAlgorithm::convex_vs_convex_collision( - btCollisionObject * body0, - btCollisionObject * body1, - btCollisionShape * shape0, - btCollisionShape * shape1) -{ - - btCollisionShape* tmpShape0 = body0->getCollisionShape(); - btCollisionShape* tmpShape1 = body1->getCollisionShape(); - - body0->internalSetTemporaryCollisionShape(shape0); - body1->internalSetTemporaryCollisionShape(shape1); - - - m_resultOut->setShapeIdentifiersA(m_part0,m_triface0); - m_resultOut->setShapeIdentifiersB(m_part1,m_triface1); - - checkConvexAlgorithm(body0,body1); - m_convex_algorithm->processCollision(body0,body1,*m_dispatchInfo,m_resultOut); - - body0->internalSetTemporaryCollisionShape(tmpShape0); - body1->internalSetTemporaryCollisionShape(tmpShape1); - -} - - - - -void btGImpactCollisionAlgorithm::gimpact_vs_gimpact_find_pairs( - const btTransform & trans0, - const btTransform & trans1, - btGImpactShapeInterface * shape0, - btGImpactShapeInterface * shape1,btPairSet & pairset) -{ - if(shape0->hasBoxSet() && shape1->hasBoxSet()) - { - btGImpactBoxSet::find_collision(shape0->getBoxSet(),trans0,shape1->getBoxSet(),trans1,pairset); - } - else - { - btAABB boxshape0; - btAABB boxshape1; - int i = shape0->getNumChildShapes(); - - while(i--) - { - shape0->getChildAabb(i,trans0,boxshape0.m_min,boxshape0.m_max); - - int j = shape1->getNumChildShapes(); - while(j--) - { - shape1->getChildAabb(i,trans1,boxshape1.m_min,boxshape1.m_max); - - if(boxshape1.has_collision(boxshape0)) - { - pairset.push_pair(i,j); - } - } - } - } - - -} - - -void btGImpactCollisionAlgorithm::gimpact_vs_shape_find_pairs( - const btTransform & trans0, - const btTransform & trans1, - btGImpactShapeInterface * shape0, - btCollisionShape * shape1, - btAlignedObjectArray & collided_primitives) -{ - - btAABB boxshape; - - - if(shape0->hasBoxSet()) - { - btTransform trans1to0 = trans0.inverse(); - trans1to0 *= trans1; - - shape1->getAabb(trans1to0,boxshape.m_min,boxshape.m_max); - - shape0->getBoxSet()->boxQuery(boxshape, collided_primitives); - } - else - { - shape1->getAabb(trans1,boxshape.m_min,boxshape.m_max); - - btAABB boxshape0; - int i = shape0->getNumChildShapes(); - - while(i--) - { - shape0->getChildAabb(i,trans0,boxshape0.m_min,boxshape0.m_max); - - if(boxshape.has_collision(boxshape0)) - { - collided_primitives.push_back(i); - } - } - - } - -} - - -void btGImpactCollisionAlgorithm::collide_gjk_triangles(btCollisionObject * body0, - btCollisionObject * body1, - btGImpactMeshShapePart * shape0, - btGImpactMeshShapePart * shape1, - const int * pairs, int pair_count) -{ - btTriangleShapeEx tri0; - btTriangleShapeEx tri1; - - shape0->lockChildShapes(); - shape1->lockChildShapes(); - - const int * pair_pointer = pairs; - - while(pair_count--) - { - - m_triface0 = *(pair_pointer); - m_triface1 = *(pair_pointer+1); - pair_pointer+=2; - - - - shape0->getBulletTriangle(m_triface0,tri0); - shape1->getBulletTriangle(m_triface1,tri1); - - - //collide two convex shapes - if(tri0.overlap_test_conservative(tri1)) - { - convex_vs_convex_collision(body0,body1,&tri0,&tri1); - } - - } - - shape0->unlockChildShapes(); - shape1->unlockChildShapes(); -} - -void btGImpactCollisionAlgorithm::collide_sat_triangles(btCollisionObject * body0, - btCollisionObject * body1, - btGImpactMeshShapePart * shape0, - btGImpactMeshShapePart * shape1, - const int * pairs, int pair_count) -{ - btTransform orgtrans0 = body0->getWorldTransform(); - btTransform orgtrans1 = body1->getWorldTransform(); - - btPrimitiveTriangle ptri0; - btPrimitiveTriangle ptri1; - GIM_TRIANGLE_CONTACT contact_data; - - shape0->lockChildShapes(); - shape1->lockChildShapes(); - - const int * pair_pointer = pairs; - - while(pair_count--) - { - - m_triface0 = *(pair_pointer); - m_triface1 = *(pair_pointer+1); - pair_pointer+=2; - - - shape0->getPrimitiveTriangle(m_triface0,ptri0); - shape1->getPrimitiveTriangle(m_triface1,ptri1); - - #ifdef TRI_COLLISION_PROFILING - bt_begin_gim02_tri_time(); - #endif - - ptri0.applyTransform(orgtrans0); - ptri1.applyTransform(orgtrans1); - - - //build planes - ptri0.buildTriPlane(); - ptri1.buildTriPlane(); - // test conservative - - - - if(ptri0.overlap_test_conservative(ptri1)) - { - if(ptri0.find_triangle_collision_clip_method(ptri1,contact_data)) - { - - int j = contact_data.m_point_count; - while(j--) - { - - addContactPoint(body0, body1, - contact_data.m_points[j], - contact_data.m_separating_normal, - -contact_data.m_penetration_depth); - } - } - } - - #ifdef TRI_COLLISION_PROFILING - bt_end_gim02_tri_time(); - #endif - - } - - shape0->unlockChildShapes(); - shape1->unlockChildShapes(); - -} - - -void btGImpactCollisionAlgorithm::gimpact_vs_gimpact( - btCollisionObject * body0, - btCollisionObject * body1, - btGImpactShapeInterface * shape0, - btGImpactShapeInterface * shape1) -{ - - if(shape0->getGImpactShapeType()==CONST_GIMPACT_TRIMESH_SHAPE) - { - btGImpactMeshShape * meshshape0 = static_cast(shape0); - m_part0 = meshshape0->getMeshPartCount(); - - while(m_part0--) - { - gimpact_vs_gimpact(body0,body1,meshshape0->getMeshPart(m_part0),shape1); - } - - return; - } - - if(shape1->getGImpactShapeType()==CONST_GIMPACT_TRIMESH_SHAPE) - { - btGImpactMeshShape * meshshape1 = static_cast(shape1); - m_part1 = meshshape1->getMeshPartCount(); - - while(m_part1--) - { - - gimpact_vs_gimpact(body0,body1,shape0,meshshape1->getMeshPart(m_part1)); - - } - - return; - } - - - btTransform orgtrans0 = body0->getWorldTransform(); - btTransform orgtrans1 = body1->getWorldTransform(); - - btPairSet pairset; - - gimpact_vs_gimpact_find_pairs(orgtrans0,orgtrans1,shape0,shape1,pairset); - - if(pairset.size()== 0) return; - - if(shape0->getGImpactShapeType() == CONST_GIMPACT_TRIMESH_SHAPE_PART && - shape1->getGImpactShapeType() == CONST_GIMPACT_TRIMESH_SHAPE_PART) - { - btGImpactMeshShapePart * shapepart0 = static_cast(shape0); - btGImpactMeshShapePart * shapepart1 = static_cast(shape1); - //specialized function - #ifdef BULLET_TRIANGLE_COLLISION - collide_gjk_triangles(body0,body1,shapepart0,shapepart1,&pairset[0].m_index1,pairset.size()); - #else - collide_sat_triangles(body0,body1,shapepart0,shapepart1,&pairset[0].m_index1,pairset.size()); - #endif - - return; - } - - //general function - - shape0->lockChildShapes(); - shape1->lockChildShapes(); - - GIM_ShapeRetriever retriever0(shape0); - GIM_ShapeRetriever retriever1(shape1); - - bool child_has_transform0 = shape0->childrenHasTransform(); - bool child_has_transform1 = shape1->childrenHasTransform(); - - int i = pairset.size(); - while(i--) - { - GIM_PAIR * pair = &pairset[i]; - m_triface0 = pair->m_index1; - m_triface1 = pair->m_index2; - btCollisionShape * colshape0 = retriever0.getChildShape(m_triface0); - btCollisionShape * colshape1 = retriever1.getChildShape(m_triface1); - - if(child_has_transform0) - { - body0->setWorldTransform(orgtrans0*shape0->getChildTransform(m_triface0)); - } - - if(child_has_transform1) - { - body1->setWorldTransform(orgtrans1*shape1->getChildTransform(m_triface1)); - } - - //collide two convex shapes - convex_vs_convex_collision(body0,body1,colshape0,colshape1); - - - if(child_has_transform0) - { - body0->setWorldTransform(orgtrans0); - } - - if(child_has_transform1) - { - body1->setWorldTransform(orgtrans1); - } - - } - - shape0->unlockChildShapes(); - shape1->unlockChildShapes(); -} - -void btGImpactCollisionAlgorithm::gimpact_vs_shape(btCollisionObject * body0, - btCollisionObject * body1, - btGImpactShapeInterface * shape0, - btCollisionShape * shape1,bool swapped) -{ - if(shape0->getGImpactShapeType()==CONST_GIMPACT_TRIMESH_SHAPE) - { - btGImpactMeshShape * meshshape0 = static_cast(shape0); - int& part = swapped ? m_part1 : m_part0; - part = meshshape0->getMeshPartCount(); - - while(part--) - { - - gimpact_vs_shape(body0, - body1, - meshshape0->getMeshPart(part), - shape1,swapped); - - } - - return; - } - - #ifdef GIMPACT_VS_PLANE_COLLISION - if(shape0->getGImpactShapeType() == CONST_GIMPACT_TRIMESH_SHAPE_PART && - shape1->getShapeType() == STATIC_PLANE_PROXYTYPE) - { - btGImpactMeshShapePart * shapepart = static_cast(shape0); - btStaticPlaneShape * planeshape = static_cast(shape1); - gimpacttrimeshpart_vs_plane_collision(body0,body1,shapepart,planeshape,swapped); - return; - } - - #endif - - - - if(shape1->isCompound()) - { - btCompoundShape * compoundshape = static_cast(shape1); - gimpact_vs_compoundshape(body0,body1,shape0,compoundshape,swapped); - return; - } - else if(shape1->isConcave()) - { - btConcaveShape * concaveshape = static_cast(shape1); - gimpact_vs_concave(body0,body1,shape0,concaveshape,swapped); - return; - } - - - btTransform orgtrans0 = body0->getWorldTransform(); - - btTransform orgtrans1 = body1->getWorldTransform(); - - btAlignedObjectArray collided_results; - - gimpact_vs_shape_find_pairs(orgtrans0,orgtrans1,shape0,shape1,collided_results); - - if(collided_results.size() == 0) return; - - - shape0->lockChildShapes(); - - GIM_ShapeRetriever retriever0(shape0); - - - bool child_has_transform0 = shape0->childrenHasTransform(); - - - int i = collided_results.size(); - - while(i--) - { - int child_index = collided_results[i]; - if(swapped) - m_triface1 = child_index; - else - m_triface0 = child_index; - - btCollisionShape * colshape0 = retriever0.getChildShape(child_index); - - if(child_has_transform0) - { - body0->setWorldTransform(orgtrans0*shape0->getChildTransform(child_index)); - } - - //collide two shapes - if(swapped) - { - shape_vs_shape_collision(body1,body0,shape1,colshape0); - } - else - { - shape_vs_shape_collision(body0,body1,colshape0,shape1); - } - - //restore transforms - if(child_has_transform0) - { - body0->setWorldTransform(orgtrans0); - } - - } - - shape0->unlockChildShapes(); - -} - -void btGImpactCollisionAlgorithm::gimpact_vs_compoundshape(btCollisionObject * body0, - btCollisionObject * body1, - btGImpactShapeInterface * shape0, - btCompoundShape * shape1,bool swapped) -{ - btTransform orgtrans1 = body1->getWorldTransform(); - - int i = shape1->getNumChildShapes(); - while(i--) - { - - btCollisionShape * colshape1 = shape1->getChildShape(i); - btTransform childtrans1 = orgtrans1*shape1->getChildTransform(i); - - body1->setWorldTransform(childtrans1); - - //collide child shape - gimpact_vs_shape(body0, body1, - shape0,colshape1,swapped); - - - //restore transforms - body1->setWorldTransform(orgtrans1); - } -} - -void btGImpactCollisionAlgorithm::gimpacttrimeshpart_vs_plane_collision( - btCollisionObject * body0, - btCollisionObject * body1, - btGImpactMeshShapePart * shape0, - btStaticPlaneShape * shape1,bool swapped) -{ - - - btTransform orgtrans0 = body0->getWorldTransform(); - btTransform orgtrans1 = body1->getWorldTransform(); - - btPlaneShape * planeshape = static_cast(shape1); - btVector4 plane; - planeshape->get_plane_equation_transformed(orgtrans1,plane); - - //test box against plane - - btAABB tribox; - shape0->getAabb(orgtrans0,tribox.m_min,tribox.m_max); - tribox.increment_margin(planeshape->getMargin()); - - if( tribox.plane_classify(plane)!= BT_CONST_COLLIDE_PLANE) return; - - shape0->lockChildShapes(); - - btScalar margin = shape0->getMargin() + planeshape->getMargin(); - - btVector3 vertex; - int vi = shape0->getVertexCount(); - while(vi--) - { - shape0->getVertex(vi,vertex); - vertex = orgtrans0(vertex); - - btScalar distance = vertex.dot(plane) - plane[3] - margin; - - if(distance<0.0)//add contact - { - if(swapped) - { - addContactPoint(body1, body0, - vertex, - -plane, - distance); - } - else - { - addContactPoint(body0, body1, - vertex, - plane, - distance); - } - } - } - - shape0->unlockChildShapes(); -} - - - - -class btGImpactTriangleCallback: public btTriangleCallback -{ -public: - btGImpactCollisionAlgorithm * algorithm; - btCollisionObject * body0; - btCollisionObject * body1; - btGImpactShapeInterface * gimpactshape0; - bool swapped; - btScalar margin; - - virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex) - { - btTriangleShapeEx tri1(triangle[0],triangle[1],triangle[2]); - tri1.setMargin(margin); - if(swapped) - { - algorithm->setPart0(partId); - algorithm->setFace0(triangleIndex); - } - else - { - algorithm->setPart1(partId); - algorithm->setFace1(triangleIndex); - } - algorithm->gimpact_vs_shape( - body0,body1,gimpactshape0,&tri1,swapped); - } -}; - - - - -void btGImpactCollisionAlgorithm::gimpact_vs_concave( - btCollisionObject * body0, - btCollisionObject * body1, - btGImpactShapeInterface * shape0, - btConcaveShape * shape1,bool swapped) -{ - //create the callback - btGImpactTriangleCallback tricallback; - tricallback.algorithm = this; - tricallback.body0 = body0; - tricallback.body1 = body1; - tricallback.gimpactshape0 = shape0; - tricallback.swapped = swapped; - tricallback.margin = shape1->getMargin(); - - //getting the trimesh AABB - btTransform gimpactInConcaveSpace; - - gimpactInConcaveSpace = body1->getWorldTransform().inverse() * body0->getWorldTransform(); - - btVector3 minAABB,maxAABB; - shape0->getAabb(gimpactInConcaveSpace,minAABB,maxAABB); - - shape1->processAllTriangles(&tricallback,minAABB,maxAABB); - -} - - - -void btGImpactCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) -{ - clearCache(); - - m_resultOut = resultOut; - m_dispatchInfo = &dispatchInfo; - btGImpactShapeInterface * gimpactshape0; - btGImpactShapeInterface * gimpactshape1; - - if (body0->getCollisionShape()->getShapeType()==GIMPACT_SHAPE_PROXYTYPE) - { - gimpactshape0 = static_cast(body0->getCollisionShape()); - - if( body1->getCollisionShape()->getShapeType()==GIMPACT_SHAPE_PROXYTYPE ) - { - gimpactshape1 = static_cast(body1->getCollisionShape()); - - gimpact_vs_gimpact(body0,body1,gimpactshape0,gimpactshape1); - } - else - { - gimpact_vs_shape(body0,body1,gimpactshape0,body1->getCollisionShape(),false); - } - - } - else if (body1->getCollisionShape()->getShapeType()==GIMPACT_SHAPE_PROXYTYPE ) - { - gimpactshape1 = static_cast(body1->getCollisionShape()); - - gimpact_vs_shape(body1,body0,gimpactshape1,body0->getCollisionShape(),true); - } -} - - -btScalar btGImpactCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) -{ - return 1.f; - -} - -///////////////////////////////////// REGISTERING ALGORITHM ////////////////////////////////////////////// - -btGImpactCollisionAlgorithm::CreateFunc g_gimpact_cf; - -//! Use this function for register the algorithm externally -void btGImpactCollisionAlgorithm::registerAlgorithm(btCollisionDispatcher * dispatcher) -{ - - int i; - - for ( i = 0;i < MAX_BROADPHASE_COLLISION_TYPES ;i++ ) - { - dispatcher->registerCollisionCreateFunc(GIMPACT_SHAPE_PROXYTYPE,i ,&g_gimpact_cf); - } - - for ( i = 0;i < MAX_BROADPHASE_COLLISION_TYPES ;i++ ) - { - dispatcher->registerCollisionCreateFunc(i,GIMPACT_SHAPE_PROXYTYPE ,&g_gimpact_cf); - } - -} diff --git a/bullet/src/BulletCollision/Gimpact/btGImpactCollisionAlgorithm.h b/bullet/src/BulletCollision/Gimpact/btGImpactCollisionAlgorithm.h deleted file mode 100644 index c57ad58b0..000000000 --- a/bullet/src/BulletCollision/Gimpact/btGImpactCollisionAlgorithm.h +++ /dev/null @@ -1,306 +0,0 @@ -/*! \file btGImpactShape.h -\author Francisco Len Njera -*/ -/* -This source file is part of GIMPACT Library. - -For the latest info, see http://gimpact.sourceforge.net/ - -Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371. -email: projectileman@yahoo.com - - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef BVH_CONCAVE_COLLISION_ALGORITHM_H -#define BVH_CONCAVE_COLLISION_ALGORITHM_H - -#include "BulletCollision/CollisionDispatch/btActivatingCollisionAlgorithm.h" -#include "BulletCollision/BroadphaseCollision/btDispatcher.h" -#include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h" -#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h" -class btDispatcher; -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" -#include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h" -#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h" - -#include "LinearMath/btAlignedObjectArray.h" - -#include "btGImpactShape.h" -#include "BulletCollision/CollisionShapes/btStaticPlaneShape.h" -#include "BulletCollision/CollisionShapes/btCompoundShape.h" -#include "BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.h" -#include "LinearMath/btIDebugDraw.h" - - - -//! Collision Algorithm for GImpact Shapes -/*! -For register this algorithm in Bullet, proceed as following: - \code -btCollisionDispatcher * dispatcher = static_cast(m_dynamicsWorld ->getDispatcher()); -btGImpactCollisionAlgorithm::registerAlgorithm(dispatcher); - \endcode -*/ -class btGImpactCollisionAlgorithm : public btActivatingCollisionAlgorithm -{ -protected: - btCollisionAlgorithm * m_convex_algorithm; - btPersistentManifold * m_manifoldPtr; - btManifoldResult* m_resultOut; - const btDispatcherInfo * m_dispatchInfo; - int m_triface0; - int m_part0; - int m_triface1; - int m_part1; - - - //! Creates a new contact point - SIMD_FORCE_INLINE btPersistentManifold* newContactManifold(btCollisionObject* body0,btCollisionObject* body1) - { - m_manifoldPtr = m_dispatcher->getNewManifold(body0,body1); - return m_manifoldPtr; - } - - SIMD_FORCE_INLINE void destroyConvexAlgorithm() - { - if(m_convex_algorithm) - { - m_convex_algorithm->~btCollisionAlgorithm(); - m_dispatcher->freeCollisionAlgorithm( m_convex_algorithm); - m_convex_algorithm = NULL; - } - } - - SIMD_FORCE_INLINE void destroyContactManifolds() - { - if(m_manifoldPtr == NULL) return; - m_dispatcher->releaseManifold(m_manifoldPtr); - m_manifoldPtr = NULL; - } - - SIMD_FORCE_INLINE void clearCache() - { - destroyContactManifolds(); - destroyConvexAlgorithm(); - - m_triface0 = -1; - m_part0 = -1; - m_triface1 = -1; - m_part1 = -1; - } - - SIMD_FORCE_INLINE btPersistentManifold* getLastManifold() - { - return m_manifoldPtr; - } - - - // Call before process collision - SIMD_FORCE_INLINE void checkManifold(btCollisionObject* body0,btCollisionObject* body1) - { - if(getLastManifold() == 0) - { - newContactManifold(body0,body1); - } - - m_resultOut->setPersistentManifold(getLastManifold()); - } - - // Call before process collision - SIMD_FORCE_INLINE btCollisionAlgorithm * newAlgorithm(btCollisionObject* body0,btCollisionObject* body1) - { - checkManifold(body0,body1); - - btCollisionAlgorithm * convex_algorithm = m_dispatcher->findAlgorithm( - body0,body1,getLastManifold()); - return convex_algorithm ; - } - - // Call before process collision - SIMD_FORCE_INLINE void checkConvexAlgorithm(btCollisionObject* body0,btCollisionObject* body1) - { - if(m_convex_algorithm) return; - m_convex_algorithm = newAlgorithm(body0,body1); - } - - - - - void addContactPoint(btCollisionObject * body0, - btCollisionObject * body1, - const btVector3 & point, - const btVector3 & normal, - btScalar distance); - -//! Collision routines -//!@{ - - void collide_gjk_triangles(btCollisionObject * body0, - btCollisionObject * body1, - btGImpactMeshShapePart * shape0, - btGImpactMeshShapePart * shape1, - const int * pairs, int pair_count); - - void collide_sat_triangles(btCollisionObject * body0, - btCollisionObject * body1, - btGImpactMeshShapePart * shape0, - btGImpactMeshShapePart * shape1, - const int * pairs, int pair_count); - - - - - void shape_vs_shape_collision( - btCollisionObject * body0, - btCollisionObject * body1, - btCollisionShape * shape0, - btCollisionShape * shape1); - - void convex_vs_convex_collision(btCollisionObject * body0, - btCollisionObject * body1, - btCollisionShape * shape0, - btCollisionShape * shape1); - - - - void gimpact_vs_gimpact_find_pairs( - const btTransform & trans0, - const btTransform & trans1, - btGImpactShapeInterface * shape0, - btGImpactShapeInterface * shape1,btPairSet & pairset); - - void gimpact_vs_shape_find_pairs( - const btTransform & trans0, - const btTransform & trans1, - btGImpactShapeInterface * shape0, - btCollisionShape * shape1, - btAlignedObjectArray & collided_primitives); - - - void gimpacttrimeshpart_vs_plane_collision( - btCollisionObject * body0, - btCollisionObject * body1, - btGImpactMeshShapePart * shape0, - btStaticPlaneShape * shape1,bool swapped); - - -public: - - btGImpactCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1); - - virtual ~btGImpactCollisionAlgorithm(); - - virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); - - btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); - - virtual void getAllContactManifolds(btManifoldArray& manifoldArray) - { - if (m_manifoldPtr) - manifoldArray.push_back(m_manifoldPtr); - } - - - struct CreateFunc :public btCollisionAlgorithmCreateFunc - { - virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1) - { - void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btGImpactCollisionAlgorithm)); - return new(mem) btGImpactCollisionAlgorithm(ci,body0,body1); - } - }; - - //! Use this function for register the algorithm externally - static void registerAlgorithm(btCollisionDispatcher * dispatcher); - - //! Gets the average time in miliseconds of tree collisions - static float getAverageTreeCollisionTime(); - - //! Gets the average time in miliseconds of triangle collisions - static float getAverageTriangleCollisionTime(); - - - //! Collides two gimpact shapes - /*! - \pre shape0 and shape1 couldn't be btGImpactMeshShape objects - */ - - - void gimpact_vs_gimpact(btCollisionObject * body0, - btCollisionObject * body1, - btGImpactShapeInterface * shape0, - btGImpactShapeInterface * shape1); - - void gimpact_vs_shape(btCollisionObject * body0, - btCollisionObject * body1, - btGImpactShapeInterface * shape0, - btCollisionShape * shape1,bool swapped); - - void gimpact_vs_compoundshape(btCollisionObject * body0, - btCollisionObject * body1, - btGImpactShapeInterface * shape0, - btCompoundShape * shape1,bool swapped); - - void gimpact_vs_concave( - btCollisionObject * body0, - btCollisionObject * body1, - btGImpactShapeInterface * shape0, - btConcaveShape * shape1,bool swapped); - - - - - /// Accessor/Mutator pairs for Part and triangleID - void setFace0(int value) - { - m_triface0 = value; - } - int getFace0() - { - return m_triface0; - } - void setFace1(int value) - { - m_triface1 = value; - } - int getFace1() - { - return m_triface1; - } - void setPart0(int value) - { - m_part0 = value; - } - int getPart0() - { - return m_part0; - } - void setPart1(int value) - { - m_part1 = value; - } - int getPart1() - { - return m_part1; - } - -}; - - -//algorithm details -//#define BULLET_TRIANGLE_COLLISION 1 -#define GIMPACT_VS_PLANE_COLLISION 1 - - - -#endif //BVH_CONCAVE_COLLISION_ALGORITHM_H diff --git a/bullet/src/BulletCollision/Gimpact/btGImpactMassUtil.h b/bullet/src/BulletCollision/Gimpact/btGImpactMassUtil.h deleted file mode 100644 index cf9e03a62..000000000 --- a/bullet/src/BulletCollision/Gimpact/btGImpactMassUtil.h +++ /dev/null @@ -1,60 +0,0 @@ -/*! \file btGImpactMassUtil.h -\author Francisco Len Njera -*/ -/* -This source file is part of GIMPACT Library. - -For the latest info, see http://gimpact.sourceforge.net/ - -Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371. -email: projectileman@yahoo.com - - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#ifndef GIMPACT_MASS_UTIL_H -#define GIMPACT_MASS_UTIL_H - -#include "LinearMath/btTransform.h" - - - -SIMD_FORCE_INLINE btVector3 gim_inertia_add_transformed( - const btVector3 & source_inertia, const btVector3 & added_inertia, const btTransform & transform) -{ - btMatrix3x3 rotatedTensor = transform.getBasis().scaled(added_inertia) * transform.getBasis().transpose(); - - btScalar x2 = transform.getOrigin()[0]; - x2*= x2; - btScalar y2 = transform.getOrigin()[1]; - y2*= y2; - btScalar z2 = transform.getOrigin()[2]; - z2*= z2; - - btScalar ix = rotatedTensor[0][0]*(y2+z2); - btScalar iy = rotatedTensor[1][1]*(x2+z2); - btScalar iz = rotatedTensor[2][2]*(x2+y2); - - return btVector3(source_inertia[0]+ix,source_inertia[1]+iy,source_inertia[2] + iz); -} - -SIMD_FORCE_INLINE btVector3 gim_get_point_inertia(const btVector3 & point, btScalar mass) -{ - btScalar x2 = point[0]*point[0]; - btScalar y2 = point[1]*point[1]; - btScalar z2 = point[2]*point[2]; - return btVector3(mass*(y2+z2),mass*(x2+z2),mass*(x2+y2)); -} - - -#endif //GIMPACT_MESH_SHAPE_H diff --git a/bullet/src/BulletCollision/Gimpact/btGImpactQuantizedBvh.cpp b/bullet/src/BulletCollision/Gimpact/btGImpactQuantizedBvh.cpp deleted file mode 100644 index 0ac94a861..000000000 --- a/bullet/src/BulletCollision/Gimpact/btGImpactQuantizedBvh.cpp +++ /dev/null @@ -1,528 +0,0 @@ -/*! \file gim_box_set.h -\author Francisco Len Njera -*/ -/* -This source file is part of GIMPACT Library. - -For the latest info, see http://gimpact.sourceforge.net/ - -Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371. -email: projectileman@yahoo.com - - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btGImpactQuantizedBvh.h" -#include "LinearMath/btQuickprof.h" - -#ifdef TRI_COLLISION_PROFILING -btClock g_q_tree_clock; - - -float g_q_accum_tree_collision_time = 0; -int g_q_count_traversing = 0; - - -void bt_begin_gim02_q_tree_time() -{ - g_q_tree_clock.reset(); -} - -void bt_end_gim02_q_tree_time() -{ - g_q_accum_tree_collision_time += g_q_tree_clock.getTimeMicroseconds(); - g_q_count_traversing++; -} - - -//! Gets the average time in miliseconds of tree collisions -float btGImpactQuantizedBvh::getAverageTreeCollisionTime() -{ - if(g_q_count_traversing == 0) return 0; - - float avgtime = g_q_accum_tree_collision_time; - avgtime /= (float)g_q_count_traversing; - - g_q_accum_tree_collision_time = 0; - g_q_count_traversing = 0; - return avgtime; - -// float avgtime = g_q_count_traversing; -// g_q_count_traversing = 0; -// return avgtime; - -} - -#endif //TRI_COLLISION_PROFILING - -/////////////////////// btQuantizedBvhTree ///////////////////////////////// - -void btQuantizedBvhTree::calc_quantization( - GIM_BVH_DATA_ARRAY & primitive_boxes, btScalar boundMargin) -{ - //calc globa box - btAABB global_bound; - global_bound.invalidate(); - - for (int i=0;i splitValue) - { - //swap - primitive_boxes.swap(i,splitIndex); - //swapLeafNodes(i,splitIndex); - splitIndex++; - } - } - - //if the splitIndex causes unbalanced trees, fix this by using the center in between startIndex and endIndex - //otherwise the tree-building might fail due to stack-overflows in certain cases. - //unbalanced1 is unsafe: it can cause stack overflows - //bool unbalanced1 = ((splitIndex==startIndex) || (splitIndex == (endIndex-1))); - - //unbalanced2 should work too: always use center (perfect balanced trees) - //bool unbalanced2 = true; - - //this should be safe too: - int rangeBalancedIndices = numIndices/3; - bool unbalanced = ((splitIndex<=(startIndex+rangeBalancedIndices)) || (splitIndex >=(endIndex-1-rangeBalancedIndices))); - - if (unbalanced) - { - splitIndex = startIndex+ (numIndices>>1); - } - - btAssert(!((splitIndex==startIndex) || (splitIndex == (endIndex)))); - - return splitIndex; - -} - - -void btQuantizedBvhTree::_build_sub_tree(GIM_BVH_DATA_ARRAY & primitive_boxes, int startIndex, int endIndex) -{ - int curIndex = m_num_nodes; - m_num_nodes++; - - btAssert((endIndex-startIndex)>0); - - if ((endIndex-startIndex)==1) - { - //We have a leaf node - setNodeBound(curIndex,primitive_boxes[startIndex].m_bound); - m_node_array[curIndex].setDataIndex(primitive_boxes[startIndex].m_data); - - return; - } - //calculate Best Splitting Axis and where to split it. Sort the incoming 'leafNodes' array within range 'startIndex/endIndex'. - - //split axis - int splitIndex = _calc_splitting_axis(primitive_boxes,startIndex,endIndex); - - splitIndex = _sort_and_calc_splitting_index( - primitive_boxes,startIndex,endIndex, - splitIndex//split axis - ); - - - //calc this node bounding box - - btAABB node_bound; - node_bound.invalidate(); - - for (int i=startIndex;iget_primitive_box(getNodeData(nodecount),leafbox); - setNodeBound(nodecount,leafbox); - } - else - { - //const GIM_BVH_TREE_NODE * nodepointer = get_node_pointer(nodecount); - //get left bound - btAABB bound; - bound.invalidate(); - - btAABB temp_box; - - int child_node = getLeftNode(nodecount); - if(child_node) - { - getNodeBound(child_node,temp_box); - bound.merge(temp_box); - } - - child_node = getRightNode(nodecount); - if(child_node) - { - getNodeBound(child_node,temp_box); - bound.merge(temp_box); - } - - setNodeBound(nodecount,bound); - } - } -} - -//! this rebuild the entire set -void btGImpactQuantizedBvh::buildSet() -{ - //obtain primitive boxes - GIM_BVH_DATA_ARRAY primitive_boxes; - primitive_boxes.resize(m_primitive_manager->get_primitive_count()); - - for (int i = 0;iget_primitive_box(i,primitive_boxes[i].m_bound); - primitive_boxes[i].m_data = i; - } - - m_box_tree.build_tree(primitive_boxes); -} - -//! returns the indices of the primitives in the m_primitive_manager -bool btGImpactQuantizedBvh::boxQuery(const btAABB & box, btAlignedObjectArray & collided_results) const -{ - int curIndex = 0; - int numNodes = getNodeCount(); - - //quantize box - - unsigned short quantizedMin[3]; - unsigned short quantizedMax[3]; - - m_box_tree.quantizePoint(quantizedMin,box.m_min); - m_box_tree.quantizePoint(quantizedMax,box.m_max); - - - while (curIndex < numNodes) - { - - //catch bugs in tree data - - bool aabbOverlap = m_box_tree.testQuantizedBoxOverlapp(curIndex, quantizedMin,quantizedMax); - bool isleafnode = isLeafNode(curIndex); - - if (isleafnode && aabbOverlap) - { - collided_results.push_back(getNodeData(curIndex)); - } - - if (aabbOverlap || isleafnode) - { - //next subnode - curIndex++; - } - else - { - //skip node - curIndex+= getEscapeNodeIndex(curIndex); - } - } - if(collided_results.size()>0) return true; - return false; -} - - - -//! returns the indices of the primitives in the m_primitive_manager -bool btGImpactQuantizedBvh::rayQuery( - const btVector3 & ray_dir,const btVector3 & ray_origin , - btAlignedObjectArray & collided_results) const -{ - int curIndex = 0; - int numNodes = getNodeCount(); - - while (curIndex < numNodes) - { - btAABB bound; - getNodeBound(curIndex,bound); - - //catch bugs in tree data - - bool aabbOverlap = bound.collide_ray(ray_origin,ray_dir); - bool isleafnode = isLeafNode(curIndex); - - if (isleafnode && aabbOverlap) - { - collided_results.push_back(getNodeData( curIndex)); - } - - if (aabbOverlap || isleafnode) - { - //next subnode - curIndex++; - } - else - { - //skip node - curIndex+= getEscapeNodeIndex(curIndex); - } - } - if(collided_results.size()>0) return true; - return false; -} - - -SIMD_FORCE_INLINE bool _quantized_node_collision( - btGImpactQuantizedBvh * boxset0, btGImpactQuantizedBvh * boxset1, - const BT_BOX_BOX_TRANSFORM_CACHE & trans_cache_1to0, - int node0 ,int node1, bool complete_primitive_tests) -{ - btAABB box0; - boxset0->getNodeBound(node0,box0); - btAABB box1; - boxset1->getNodeBound(node1,box1); - - return box0.overlapping_trans_cache(box1,trans_cache_1to0,complete_primitive_tests ); -// box1.appy_transform_trans_cache(trans_cache_1to0); -// return box0.has_collision(box1); - -} - - -//stackless recursive collision routine -static void _find_quantized_collision_pairs_recursive( - btGImpactQuantizedBvh * boxset0, btGImpactQuantizedBvh * boxset1, - btPairSet * collision_pairs, - const BT_BOX_BOX_TRANSFORM_CACHE & trans_cache_1to0, - int node0, int node1, bool complete_primitive_tests) -{ - - - - if( _quantized_node_collision( - boxset0,boxset1,trans_cache_1to0, - node0,node1,complete_primitive_tests) ==false) return;//avoid colliding internal nodes - - if(boxset0->isLeafNode(node0)) - { - if(boxset1->isLeafNode(node1)) - { - // collision result - collision_pairs->push_pair( - boxset0->getNodeData(node0),boxset1->getNodeData(node1)); - return; - } - else - { - - //collide left recursive - - _find_quantized_collision_pairs_recursive( - boxset0,boxset1, - collision_pairs,trans_cache_1to0, - node0,boxset1->getLeftNode(node1),false); - - //collide right recursive - _find_quantized_collision_pairs_recursive( - boxset0,boxset1, - collision_pairs,trans_cache_1to0, - node0,boxset1->getRightNode(node1),false); - - - } - } - else - { - if(boxset1->isLeafNode(node1)) - { - - //collide left recursive - _find_quantized_collision_pairs_recursive( - boxset0,boxset1, - collision_pairs,trans_cache_1to0, - boxset0->getLeftNode(node0),node1,false); - - - //collide right recursive - - _find_quantized_collision_pairs_recursive( - boxset0,boxset1, - collision_pairs,trans_cache_1to0, - boxset0->getRightNode(node0),node1,false); - - - } - else - { - //collide left0 left1 - - - - _find_quantized_collision_pairs_recursive( - boxset0,boxset1, - collision_pairs,trans_cache_1to0, - boxset0->getLeftNode(node0),boxset1->getLeftNode(node1),false); - - //collide left0 right1 - - _find_quantized_collision_pairs_recursive( - boxset0,boxset1, - collision_pairs,trans_cache_1to0, - boxset0->getLeftNode(node0),boxset1->getRightNode(node1),false); - - - //collide right0 left1 - - _find_quantized_collision_pairs_recursive( - boxset0,boxset1, - collision_pairs,trans_cache_1to0, - boxset0->getRightNode(node0),boxset1->getLeftNode(node1),false); - - //collide right0 right1 - - _find_quantized_collision_pairs_recursive( - boxset0,boxset1, - collision_pairs,trans_cache_1to0, - boxset0->getRightNode(node0),boxset1->getRightNode(node1),false); - - }// else if node1 is not a leaf - }// else if node0 is not a leaf -} - - -void btGImpactQuantizedBvh::find_collision(btGImpactQuantizedBvh * boxset0, const btTransform & trans0, - btGImpactQuantizedBvh * boxset1, const btTransform & trans1, - btPairSet & collision_pairs) -{ - - if(boxset0->getNodeCount()==0 || boxset1->getNodeCount()==0 ) return; - - BT_BOX_BOX_TRANSFORM_CACHE trans_cache_1to0; - - trans_cache_1to0.calc_from_homogenic(trans0,trans1); - -#ifdef TRI_COLLISION_PROFILING - bt_begin_gim02_q_tree_time(); -#endif //TRI_COLLISION_PROFILING - - _find_quantized_collision_pairs_recursive( - boxset0,boxset1, - &collision_pairs,trans_cache_1to0,0,0,true); -#ifdef TRI_COLLISION_PROFILING - bt_end_gim02_q_tree_time(); -#endif //TRI_COLLISION_PROFILING - -} - - diff --git a/bullet/src/BulletCollision/Gimpact/btGImpactQuantizedBvh.h b/bullet/src/BulletCollision/Gimpact/btGImpactQuantizedBvh.h deleted file mode 100644 index aac7f47ef..000000000 --- a/bullet/src/BulletCollision/Gimpact/btGImpactQuantizedBvh.h +++ /dev/null @@ -1,372 +0,0 @@ -#ifndef GIM_QUANTIZED_SET_H_INCLUDED -#define GIM_QUANTIZED_SET_H_INCLUDED - -/*! \file btGImpactQuantizedBvh.h -\author Francisco Len Njera -*/ -/* -This source file is part of GIMPACT Library. - -For the latest info, see http://gimpact.sourceforge.net/ - -Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371. -email: projectileman@yahoo.com - - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btGImpactBvh.h" -#include "btQuantization.h" - - - - - -///btQuantizedBvhNode is a compressed aabb node, 16 bytes. -///Node can be used for leafnode or internal node. Leafnodes can point to 32-bit triangle index (non-negative range). -ATTRIBUTE_ALIGNED16 (struct) BT_QUANTIZED_BVH_NODE -{ - //12 bytes - unsigned short int m_quantizedAabbMin[3]; - unsigned short int m_quantizedAabbMax[3]; - //4 bytes - int m_escapeIndexOrDataIndex; - - BT_QUANTIZED_BVH_NODE() - { - m_escapeIndexOrDataIndex = 0; - } - - SIMD_FORCE_INLINE bool isLeafNode() const - { - //skipindex is negative (internal node), triangleindex >=0 (leafnode) - return (m_escapeIndexOrDataIndex>=0); - } - - SIMD_FORCE_INLINE int getEscapeIndex() const - { - //btAssert(m_escapeIndexOrDataIndex < 0); - return -m_escapeIndexOrDataIndex; - } - - SIMD_FORCE_INLINE void setEscapeIndex(int index) - { - m_escapeIndexOrDataIndex = -index; - } - - SIMD_FORCE_INLINE int getDataIndex() const - { - //btAssert(m_escapeIndexOrDataIndex >= 0); - - return m_escapeIndexOrDataIndex; - } - - SIMD_FORCE_INLINE void setDataIndex(int index) - { - m_escapeIndexOrDataIndex = index; - } - - SIMD_FORCE_INLINE bool testQuantizedBoxOverlapp( - unsigned short * quantizedMin,unsigned short * quantizedMax) const - { - if(m_quantizedAabbMin[0] > quantizedMax[0] || - m_quantizedAabbMax[0] < quantizedMin[0] || - m_quantizedAabbMin[1] > quantizedMax[1] || - m_quantizedAabbMax[1] < quantizedMin[1] || - m_quantizedAabbMin[2] > quantizedMax[2] || - m_quantizedAabbMax[2] < quantizedMin[2]) - { - return false; - } - return true; - } - -}; - - - -class GIM_QUANTIZED_BVH_NODE_ARRAY:public btAlignedObjectArray -{ -}; - - - - -//! Basic Box tree structure -class btQuantizedBvhTree -{ -protected: - int m_num_nodes; - GIM_QUANTIZED_BVH_NODE_ARRAY m_node_array; - btAABB m_global_bound; - btVector3 m_bvhQuantization; -protected: - void calc_quantization(GIM_BVH_DATA_ARRAY & primitive_boxes, btScalar boundMargin = btScalar(1.0) ); - - int _sort_and_calc_splitting_index( - GIM_BVH_DATA_ARRAY & primitive_boxes, - int startIndex, int endIndex, int splitAxis); - - int _calc_splitting_axis(GIM_BVH_DATA_ARRAY & primitive_boxes, int startIndex, int endIndex); - - void _build_sub_tree(GIM_BVH_DATA_ARRAY & primitive_boxes, int startIndex, int endIndex); -public: - btQuantizedBvhTree() - { - m_num_nodes = 0; - } - - //! prototype functions for box tree management - //!@{ - void build_tree(GIM_BVH_DATA_ARRAY & primitive_boxes); - - SIMD_FORCE_INLINE void quantizePoint( - unsigned short * quantizedpoint, const btVector3 & point) const - { - bt_quantize_clamp(quantizedpoint,point,m_global_bound.m_min,m_global_bound.m_max,m_bvhQuantization); - } - - - SIMD_FORCE_INLINE bool testQuantizedBoxOverlapp( - int node_index, - unsigned short * quantizedMin,unsigned short * quantizedMax) const - { - return m_node_array[node_index].testQuantizedBoxOverlapp(quantizedMin,quantizedMax); - } - - SIMD_FORCE_INLINE void clearNodes() - { - m_node_array.clear(); - m_num_nodes = 0; - } - - //! node count - SIMD_FORCE_INLINE int getNodeCount() const - { - return m_num_nodes; - } - - //! tells if the node is a leaf - SIMD_FORCE_INLINE bool isLeafNode(int nodeindex) const - { - return m_node_array[nodeindex].isLeafNode(); - } - - SIMD_FORCE_INLINE int getNodeData(int nodeindex) const - { - return m_node_array[nodeindex].getDataIndex(); - } - - SIMD_FORCE_INLINE void getNodeBound(int nodeindex, btAABB & bound) const - { - bound.m_min = bt_unquantize( - m_node_array[nodeindex].m_quantizedAabbMin, - m_global_bound.m_min,m_bvhQuantization); - - bound.m_max = bt_unquantize( - m_node_array[nodeindex].m_quantizedAabbMax, - m_global_bound.m_min,m_bvhQuantization); - } - - SIMD_FORCE_INLINE void setNodeBound(int nodeindex, const btAABB & bound) - { - bt_quantize_clamp( m_node_array[nodeindex].m_quantizedAabbMin, - bound.m_min, - m_global_bound.m_min, - m_global_bound.m_max, - m_bvhQuantization); - - bt_quantize_clamp( m_node_array[nodeindex].m_quantizedAabbMax, - bound.m_max, - m_global_bound.m_min, - m_global_bound.m_max, - m_bvhQuantization); - } - - SIMD_FORCE_INLINE int getLeftNode(int nodeindex) const - { - return nodeindex+1; - } - - SIMD_FORCE_INLINE int getRightNode(int nodeindex) const - { - if(m_node_array[nodeindex+1].isLeafNode()) return nodeindex+2; - return nodeindex+1 + m_node_array[nodeindex+1].getEscapeIndex(); - } - - SIMD_FORCE_INLINE int getEscapeNodeIndex(int nodeindex) const - { - return m_node_array[nodeindex].getEscapeIndex(); - } - - SIMD_FORCE_INLINE const BT_QUANTIZED_BVH_NODE * get_node_pointer(int index = 0) const - { - return &m_node_array[index]; - } - - //!@} -}; - - - -//! Structure for containing Boxes -/*! -This class offers an structure for managing a box tree of primitives. -Requires a Primitive prototype (like btPrimitiveManagerBase ) -*/ -class btGImpactQuantizedBvh -{ -protected: - btQuantizedBvhTree m_box_tree; - btPrimitiveManagerBase * m_primitive_manager; - -protected: - //stackless refit - void refit(); -public: - - //! this constructor doesn't build the tree. you must call buildSet - btGImpactQuantizedBvh() - { - m_primitive_manager = NULL; - } - - //! this constructor doesn't build the tree. you must call buildSet - btGImpactQuantizedBvh(btPrimitiveManagerBase * primitive_manager) - { - m_primitive_manager = primitive_manager; - } - - SIMD_FORCE_INLINE btAABB getGlobalBox() const - { - btAABB totalbox; - getNodeBound(0, totalbox); - return totalbox; - } - - SIMD_FORCE_INLINE void setPrimitiveManager(btPrimitiveManagerBase * primitive_manager) - { - m_primitive_manager = primitive_manager; - } - - SIMD_FORCE_INLINE btPrimitiveManagerBase * getPrimitiveManager() const - { - return m_primitive_manager; - } - - -//! node manager prototype functions -///@{ - - //! this attemps to refit the box set. - SIMD_FORCE_INLINE void update() - { - refit(); - } - - //! this rebuild the entire set - void buildSet(); - - //! returns the indices of the primitives in the m_primitive_manager - bool boxQuery(const btAABB & box, btAlignedObjectArray & collided_results) const; - - //! returns the indices of the primitives in the m_primitive_manager - SIMD_FORCE_INLINE bool boxQueryTrans(const btAABB & box, - const btTransform & transform, btAlignedObjectArray & collided_results) const - { - btAABB transbox=box; - transbox.appy_transform(transform); - return boxQuery(transbox,collided_results); - } - - //! returns the indices of the primitives in the m_primitive_manager - bool rayQuery( - const btVector3 & ray_dir,const btVector3 & ray_origin , - btAlignedObjectArray & collided_results) const; - - //! tells if this set has hierarcht - SIMD_FORCE_INLINE bool hasHierarchy() const - { - return true; - } - - //! tells if this set is a trimesh - SIMD_FORCE_INLINE bool isTrimesh() const - { - return m_primitive_manager->is_trimesh(); - } - - //! node count - SIMD_FORCE_INLINE int getNodeCount() const - { - return m_box_tree.getNodeCount(); - } - - //! tells if the node is a leaf - SIMD_FORCE_INLINE bool isLeafNode(int nodeindex) const - { - return m_box_tree.isLeafNode(nodeindex); - } - - SIMD_FORCE_INLINE int getNodeData(int nodeindex) const - { - return m_box_tree.getNodeData(nodeindex); - } - - SIMD_FORCE_INLINE void getNodeBound(int nodeindex, btAABB & bound) const - { - m_box_tree.getNodeBound(nodeindex, bound); - } - - SIMD_FORCE_INLINE void setNodeBound(int nodeindex, const btAABB & bound) - { - m_box_tree.setNodeBound(nodeindex, bound); - } - - - SIMD_FORCE_INLINE int getLeftNode(int nodeindex) const - { - return m_box_tree.getLeftNode(nodeindex); - } - - SIMD_FORCE_INLINE int getRightNode(int nodeindex) const - { - return m_box_tree.getRightNode(nodeindex); - } - - SIMD_FORCE_INLINE int getEscapeNodeIndex(int nodeindex) const - { - return m_box_tree.getEscapeNodeIndex(nodeindex); - } - - SIMD_FORCE_INLINE void getNodeTriangle(int nodeindex,btPrimitiveTriangle & triangle) const - { - m_primitive_manager->get_primitive_triangle(getNodeData(nodeindex),triangle); - } - - - SIMD_FORCE_INLINE const BT_QUANTIZED_BVH_NODE * get_node_pointer(int index = 0) const - { - return m_box_tree.get_node_pointer(index); - } - - - static float getAverageTreeCollisionTime(); - - - static void find_collision(btGImpactQuantizedBvh * boxset1, const btTransform & trans1, - btGImpactQuantizedBvh * boxset2, const btTransform & trans2, - btPairSet & collision_pairs); -}; - - -#endif // GIM_BOXPRUNING_H_INCLUDED diff --git a/bullet/src/BulletCollision/Gimpact/btGImpactShape.cpp b/bullet/src/BulletCollision/Gimpact/btGImpactShape.cpp deleted file mode 100644 index 5e27d086a..000000000 --- a/bullet/src/BulletCollision/Gimpact/btGImpactShape.cpp +++ /dev/null @@ -1,183 +0,0 @@ -/* -This source file is part of GIMPACT Library. - -For the latest info, see http://gimpact.sourceforge.net/ - -Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371. -email: projectileman@yahoo.com - - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#include "btGImpactShape.h" -#include "btGImpactMassUtil.h" - - -#define CALC_EXACT_INERTIA 1 - -void btGImpactCompoundShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const -{ - lockChildShapes(); -#ifdef CALC_EXACT_INERTIA - inertia.setValue(0.f,0.f,0.f); - - int i = this->getNumChildShapes(); - btScalar shapemass = mass/btScalar(i); - - while(i--) - { - btVector3 temp_inertia; - m_childShapes[i]->calculateLocalInertia(shapemass,temp_inertia); - if(childrenHasTransform()) - { - inertia = gim_inertia_add_transformed( inertia,temp_inertia,m_childTransforms[i]); - } - else - { - inertia = gim_inertia_add_transformed( inertia,temp_inertia,btTransform::getIdentity()); - } - - } - -#else - - // Calc box inertia - - btScalar lx= m_localAABB.m_max[0] - m_localAABB.m_min[0]; - btScalar ly= m_localAABB.m_max[1] - m_localAABB.m_min[1]; - btScalar lz= m_localAABB.m_max[2] - m_localAABB.m_min[2]; - const btScalar x2 = lx*lx; - const btScalar y2 = ly*ly; - const btScalar z2 = lz*lz; - const btScalar scaledmass = mass * btScalar(0.08333333); - - inertia = scaledmass * (btVector3(y2+z2,x2+z2,x2+y2)); - -#endif - unlockChildShapes(); -} - - - -void btGImpactMeshShapePart::calculateLocalInertia(btScalar mass,btVector3& inertia) const -{ - lockChildShapes(); - - -#ifdef CALC_EXACT_INERTIA - inertia.setValue(0.f,0.f,0.f); - - int i = this->getVertexCount(); - btScalar pointmass = mass/btScalar(i); - - while(i--) - { - btVector3 pointintertia; - this->getVertex(i,pointintertia); - pointintertia = gim_get_point_inertia(pointintertia,pointmass); - inertia+=pointintertia; - } - -#else - - // Calc box inertia - - btScalar lx= m_localAABB.m_max[0] - m_localAABB.m_min[0]; - btScalar ly= m_localAABB.m_max[1] - m_localAABB.m_min[1]; - btScalar lz= m_localAABB.m_max[2] - m_localAABB.m_min[2]; - const btScalar x2 = lx*lx; - const btScalar y2 = ly*ly; - const btScalar z2 = lz*lz; - const btScalar scaledmass = mass * btScalar(0.08333333); - - inertia = scaledmass * (btVector3(y2+z2,x2+z2,x2+y2)); - -#endif - - unlockChildShapes(); -} - -void btGImpactMeshShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const -{ - -#ifdef CALC_EXACT_INERTIA - inertia.setValue(0.f,0.f,0.f); - - int i = this->getMeshPartCount(); - btScalar partmass = mass/btScalar(i); - - while(i--) - { - btVector3 partinertia; - getMeshPart(i)->calculateLocalInertia(partmass,partinertia); - inertia+=partinertia; - } - -#else - - // Calc box inertia - - btScalar lx= m_localAABB.m_max[0] - m_localAABB.m_min[0]; - btScalar ly= m_localAABB.m_max[1] - m_localAABB.m_min[1]; - btScalar lz= m_localAABB.m_max[2] - m_localAABB.m_min[2]; - const btScalar x2 = lx*lx; - const btScalar y2 = ly*ly; - const btScalar z2 = lz*lz; - const btScalar scaledmass = mass * btScalar(0.08333333); - - inertia = scaledmass * (btVector3(y2+z2,x2+z2,x2+y2)); - -#endif -} - -void btGImpactMeshShape::rayTest(const btVector3& rayFrom, const btVector3& rayTo, btCollisionWorld::RayResultCallback& resultCallback) const -{ -} - - -void btGImpactMeshShapePart::processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const -{ - lockChildShapes(); - btAABB box; - box.m_min = aabbMin; - box.m_max = aabbMax; - - btAlignedObjectArray collided; - m_box_set.boxQuery(box,collided); - - if(collided.size()==0) - { - unlockChildShapes(); - return; - } - - int part = (int)getPart(); - btPrimitiveTriangle triangle; - int i = collided.size(); - while(i--) - { - this->getPrimitiveTriangle(collided[i],triangle); - callback->processTriangle(triangle.m_vertices,part,collided[i]); - } - unlockChildShapes(); - -} - -void btGImpactMeshShape::processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const -{ - int i = m_mesh_parts.size(); - while(i--) - { - m_mesh_parts[i]->processAllTriangles(callback,aabbMin,aabbMax); - } -} diff --git a/bullet/src/BulletCollision/Gimpact/btGImpactShape.h b/bullet/src/BulletCollision/Gimpact/btGImpactShape.h deleted file mode 100644 index c3d9aa2f0..000000000 --- a/bullet/src/BulletCollision/Gimpact/btGImpactShape.h +++ /dev/null @@ -1,1124 +0,0 @@ -/*! \file btGImpactShape.h -\author Francisco Len Njera -*/ -/* -This source file is part of GIMPACT Library. - -For the latest info, see http://gimpact.sourceforge.net/ - -Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371. -email: projectileman@yahoo.com - - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#ifndef GIMPACT_SHAPE_H -#define GIMPACT_SHAPE_H - -#include "BulletCollision/CollisionShapes/btCollisionShape.h" -#include "BulletCollision/CollisionShapes/btTriangleShape.h" -#include "BulletCollision/CollisionShapes/btStridingMeshInterface.h" -#include "BulletCollision/CollisionShapes/btCollisionMargin.h" -#include "BulletCollision/CollisionDispatch/btCollisionWorld.h" -#include "BulletCollision/CollisionShapes/btConcaveShape.h" -#include "BulletCollision/CollisionShapes/btTetrahedronShape.h" -#include "LinearMath/btVector3.h" -#include "LinearMath/btTransform.h" -#include "LinearMath/btMatrix3x3.h" -#include "LinearMath/btAlignedObjectArray.h" - -#include "btGImpactQuantizedBvh.h" // box tree class - - -//! declare Quantized trees, (you can change to float based trees) -typedef btGImpactQuantizedBvh btGImpactBoxSet; - -enum eGIMPACT_SHAPE_TYPE -{ - CONST_GIMPACT_COMPOUND_SHAPE = 0, - CONST_GIMPACT_TRIMESH_SHAPE_PART, - CONST_GIMPACT_TRIMESH_SHAPE -}; - - -//! Helper class for tetrahedrons -class btTetrahedronShapeEx:public btBU_Simplex1to4 -{ -public: - btTetrahedronShapeEx() - { - m_numVertices = 4; - } - - - SIMD_FORCE_INLINE void setVertices( - const btVector3 & v0,const btVector3 & v1, - const btVector3 & v2,const btVector3 & v3) - { - m_vertices[0] = v0; - m_vertices[1] = v1; - m_vertices[2] = v2; - m_vertices[3] = v3; - recalcLocalAabb(); - } -}; - - -//! Base class for gimpact shapes -class btGImpactShapeInterface : public btConcaveShape -{ -protected: - btAABB m_localAABB; - bool m_needs_update; - btVector3 localScaling; - btGImpactBoxSet m_box_set;// optionally boxset - - //! use this function for perfofm refit in bounding boxes - //! use this function for perfofm refit in bounding boxes - virtual void calcLocalAABB() - { - lockChildShapes(); - if(m_box_set.getNodeCount() == 0) - { - m_box_set.buildSet(); - } - else - { - m_box_set.update(); - } - unlockChildShapes(); - - m_localAABB = m_box_set.getGlobalBox(); - } - - -public: - btGImpactShapeInterface() - { - m_shapeType=GIMPACT_SHAPE_PROXYTYPE; - m_localAABB.invalidate(); - m_needs_update = true; - localScaling.setValue(1.f,1.f,1.f); - } - - - //! performs refit operation - /*! - Updates the entire Box set of this shape. - \pre postUpdate() must be called for attemps to calculating the box set, else this function - will does nothing. - \post if m_needs_update == true, then it calls calcLocalAABB(); - */ - SIMD_FORCE_INLINE void updateBound() - { - if(!m_needs_update) return; - calcLocalAABB(); - m_needs_update = false; - } - - //! If the Bounding box is not updated, then this class attemps to calculate it. - /*! - \post Calls updateBound() for update the box set. - */ - void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const - { - btAABB transformedbox = m_localAABB; - transformedbox.appy_transform(t); - aabbMin = transformedbox.m_min; - aabbMax = transformedbox.m_max; - } - - //! Tells to this object that is needed to refit the box set - virtual void postUpdate() - { - m_needs_update = true; - } - - //! Obtains the local box, which is the global calculated box of the total of subshapes - SIMD_FORCE_INLINE const btAABB & getLocalBox() - { - return m_localAABB; - } - - - virtual int getShapeType() const - { - return GIMPACT_SHAPE_PROXYTYPE; - } - - /*! - \post You must call updateBound() for update the box set. - */ - virtual void setLocalScaling(const btVector3& scaling) - { - localScaling = scaling; - postUpdate(); - } - - virtual const btVector3& getLocalScaling() const - { - return localScaling; - } - - - virtual void setMargin(btScalar margin) - { - m_collisionMargin = margin; - int i = getNumChildShapes(); - while(i--) - { - btCollisionShape* child = getChildShape(i); - child->setMargin(margin); - } - - m_needs_update = true; - } - - - //! Subshape member functions - //!@{ - - //! Base method for determinig which kind of GIMPACT shape we get - virtual eGIMPACT_SHAPE_TYPE getGImpactShapeType() = 0; - - //! gets boxset - SIMD_FORCE_INLINE btGImpactBoxSet * getBoxSet() - { - return &m_box_set; - } - - //! Determines if this class has a hierarchy structure for sorting its primitives - SIMD_FORCE_INLINE bool hasBoxSet() const - { - if(m_box_set.getNodeCount() == 0) return false; - return true; - } - - //! Obtains the primitive manager - virtual const btPrimitiveManagerBase * getPrimitiveManager() const = 0; - - - //! Gets the number of children - virtual int getNumChildShapes() const = 0; - - //! if true, then its children must get transforms. - virtual bool childrenHasTransform() const = 0; - - //! Determines if this shape has triangles - virtual bool needsRetrieveTriangles() const = 0; - - //! Determines if this shape has tetrahedrons - virtual bool needsRetrieveTetrahedrons() const = 0; - - virtual void getBulletTriangle(int prim_index,btTriangleShapeEx & triangle) const = 0; - - virtual void getBulletTetrahedron(int prim_index,btTetrahedronShapeEx & tetrahedron) const = 0; - - - - //! call when reading child shapes - virtual void lockChildShapes() const - { - } - - virtual void unlockChildShapes() const - { - } - - //! if this trimesh - SIMD_FORCE_INLINE void getPrimitiveTriangle(int index,btPrimitiveTriangle & triangle) const - { - getPrimitiveManager()->get_primitive_triangle(index,triangle); - } - - - //! Retrieves the bound from a child - /*! - */ - virtual void getChildAabb(int child_index,const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const - { - btAABB child_aabb; - getPrimitiveManager()->get_primitive_box(child_index,child_aabb); - child_aabb.appy_transform(t); - aabbMin = child_aabb.m_min; - aabbMax = child_aabb.m_max; - } - - //! Gets the children - virtual btCollisionShape* getChildShape(int index) = 0; - - - //! Gets the child - virtual const btCollisionShape* getChildShape(int index) const = 0; - - //! Gets the children transform - virtual btTransform getChildTransform(int index) const = 0; - - //! Sets the children transform - /*! - \post You must call updateBound() for update the box set. - */ - virtual void setChildTransform(int index, const btTransform & transform) = 0; - - //!@} - - - //! virtual method for ray collision - virtual void rayTest(const btVector3& rayFrom, const btVector3& rayTo, btCollisionWorld::RayResultCallback& resultCallback) const - { - } - - //! Function for retrieve triangles. - /*! - It gives the triangles in local space - */ - virtual void processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const - { - } - - //!@} - -}; - - -//! btGImpactCompoundShape allows to handle multiple btCollisionShape objects at once -/*! -This class only can manage Convex subshapes -*/ -class btGImpactCompoundShape : public btGImpactShapeInterface -{ -public: - //! compound primitive manager - class CompoundPrimitiveManager:public btPrimitiveManagerBase - { - public: - virtual ~CompoundPrimitiveManager() {} - btGImpactCompoundShape * m_compoundShape; - - - CompoundPrimitiveManager(const CompoundPrimitiveManager& compound) - { - m_compoundShape = compound.m_compoundShape; - } - - CompoundPrimitiveManager(btGImpactCompoundShape * compoundShape) - { - m_compoundShape = compoundShape; - } - - CompoundPrimitiveManager() - { - m_compoundShape = NULL; - } - - virtual bool is_trimesh() const - { - return false; - } - - virtual int get_primitive_count() const - { - return (int )m_compoundShape->getNumChildShapes(); - } - - virtual void get_primitive_box(int prim_index ,btAABB & primbox) const - { - btTransform prim_trans; - if(m_compoundShape->childrenHasTransform()) - { - prim_trans = m_compoundShape->getChildTransform(prim_index); - } - else - { - prim_trans.setIdentity(); - } - const btCollisionShape* shape = m_compoundShape->getChildShape(prim_index); - shape->getAabb(prim_trans,primbox.m_min,primbox.m_max); - } - - virtual void get_primitive_triangle(int prim_index,btPrimitiveTriangle & triangle) const - { - btAssert(0); - } - - }; - - - -protected: - CompoundPrimitiveManager m_primitive_manager; - btAlignedObjectArray m_childTransforms; - btAlignedObjectArray m_childShapes; - - -public: - - btGImpactCompoundShape(bool children_has_transform = true) - { - m_primitive_manager.m_compoundShape = this; - m_box_set.setPrimitiveManager(&m_primitive_manager); - } - - virtual ~btGImpactCompoundShape() - { - } - - - //! if true, then its children must get transforms. - virtual bool childrenHasTransform() const - { - if(m_childTransforms.size()==0) return false; - return true; - } - - - //! Obtains the primitive manager - virtual const btPrimitiveManagerBase * getPrimitiveManager() const - { - return &m_primitive_manager; - } - - //! Obtains the compopund primitive manager - SIMD_FORCE_INLINE CompoundPrimitiveManager * getCompoundPrimitiveManager() - { - return &m_primitive_manager; - } - - //! Gets the number of children - virtual int getNumChildShapes() const - { - return m_childShapes.size(); - } - - - //! Use this method for adding children. Only Convex shapes are allowed. - void addChildShape(const btTransform& localTransform,btCollisionShape* shape) - { - btAssert(shape->isConvex()); - m_childTransforms.push_back(localTransform); - m_childShapes.push_back(shape); - } - - //! Use this method for adding children. Only Convex shapes are allowed. - void addChildShape(btCollisionShape* shape) - { - btAssert(shape->isConvex()); - m_childShapes.push_back(shape); - } - - //! Gets the children - virtual btCollisionShape* getChildShape(int index) - { - return m_childShapes[index]; - } - - //! Gets the children - virtual const btCollisionShape* getChildShape(int index) const - { - return m_childShapes[index]; - } - - //! Retrieves the bound from a child - /*! - */ - virtual void getChildAabb(int child_index,const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const - { - - if(childrenHasTransform()) - { - m_childShapes[child_index]->getAabb(t*m_childTransforms[child_index],aabbMin,aabbMax); - } - else - { - m_childShapes[child_index]->getAabb(t,aabbMin,aabbMax); - } - } - - - //! Gets the children transform - virtual btTransform getChildTransform(int index) const - { - btAssert(m_childTransforms.size() == m_childShapes.size()); - return m_childTransforms[index]; - } - - //! Sets the children transform - /*! - \post You must call updateBound() for update the box set. - */ - virtual void setChildTransform(int index, const btTransform & transform) - { - btAssert(m_childTransforms.size() == m_childShapes.size()); - m_childTransforms[index] = transform; - postUpdate(); - } - - //! Determines if this shape has triangles - virtual bool needsRetrieveTriangles() const - { - return false; - } - - //! Determines if this shape has tetrahedrons - virtual bool needsRetrieveTetrahedrons() const - { - return false; - } - - - virtual void getBulletTriangle(int prim_index,btTriangleShapeEx & triangle) const - { - btAssert(0); - } - - virtual void getBulletTetrahedron(int prim_index,btTetrahedronShapeEx & tetrahedron) const - { - btAssert(0); - } - - - //! Calculates the exact inertia tensor for this shape - virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const; - - virtual const char* getName()const - { - return "GImpactCompound"; - } - - virtual eGIMPACT_SHAPE_TYPE getGImpactShapeType() - { - return CONST_GIMPACT_COMPOUND_SHAPE; - } - -}; - - - -//! This class manages a sub part of a mesh supplied by the btStridingMeshInterface interface. -/*! -- Simply create this shape by passing the btStridingMeshInterface to the constructor btGImpactMeshShapePart, then you must call updateBound() after creating the mesh -- When making operations with this shape, you must call lock before accessing to the trimesh primitives, and then call unlock -- You can handle deformable meshes with this shape, by calling postUpdate() every time when changing the mesh vertices. - -*/ -class btGImpactMeshShapePart : public btGImpactShapeInterface -{ -public: - //! Trimesh primitive manager - /*! - Manages the info from btStridingMeshInterface object and controls the Lock/Unlock mechanism - */ - class TrimeshPrimitiveManager:public btPrimitiveManagerBase - { - public: - btScalar m_margin; - btStridingMeshInterface * m_meshInterface; - btVector3 m_scale; - int m_part; - int m_lock_count; - const unsigned char *vertexbase; - int numverts; - PHY_ScalarType type; - int stride; - const unsigned char *indexbase; - int indexstride; - int numfaces; - PHY_ScalarType indicestype; - - TrimeshPrimitiveManager() - { - m_meshInterface = NULL; - m_part = 0; - m_margin = 0.01f; - m_scale = btVector3(1.f,1.f,1.f); - m_lock_count = 0; - vertexbase = 0; - numverts = 0; - stride = 0; - indexbase = 0; - indexstride = 0; - numfaces = 0; - } - - TrimeshPrimitiveManager(const TrimeshPrimitiveManager & manager) - { - m_meshInterface = manager.m_meshInterface; - m_part = manager.m_part; - m_margin = manager.m_margin; - m_scale = manager.m_scale; - m_lock_count = 0; - vertexbase = 0; - numverts = 0; - stride = 0; - indexbase = 0; - indexstride = 0; - numfaces = 0; - - } - - TrimeshPrimitiveManager( - btStridingMeshInterface * meshInterface, int part) - { - m_meshInterface = meshInterface; - m_part = part; - m_scale = m_meshInterface->getScaling(); - m_margin = 0.1f; - m_lock_count = 0; - vertexbase = 0; - numverts = 0; - stride = 0; - indexbase = 0; - indexstride = 0; - numfaces = 0; - - } - - virtual ~TrimeshPrimitiveManager() {} - - void lock() - { - if(m_lock_count>0) - { - m_lock_count++; - return; - } - m_meshInterface->getLockedReadOnlyVertexIndexBase( - &vertexbase,numverts, - type, stride,&indexbase, indexstride, numfaces,indicestype,m_part); - - m_lock_count = 1; - } - - void unlock() - { - if(m_lock_count == 0) return; - if(m_lock_count>1) - { - --m_lock_count; - return; - } - m_meshInterface->unLockReadOnlyVertexBase(m_part); - vertexbase = NULL; - m_lock_count = 0; - } - - virtual bool is_trimesh() const - { - return true; - } - - virtual int get_primitive_count() const - { - return (int )numfaces; - } - - SIMD_FORCE_INLINE int get_vertex_count() const - { - return (int )numverts; - } - - SIMD_FORCE_INLINE void get_indices(int face_index,int &i0,int &i1,int &i2) const - { - if(indicestype == PHY_SHORT) - { - short * s_indices = (short *)(indexbase + face_index*indexstride); - i0 = s_indices[0]; - i1 = s_indices[1]; - i2 = s_indices[2]; - } - else - { - int * i_indices = (int *)(indexbase + face_index*indexstride); - i0 = i_indices[0]; - i1 = i_indices[1]; - i2 = i_indices[2]; - } - } - - SIMD_FORCE_INLINE void get_vertex(int vertex_index, btVector3 & vertex) const - { - if(type == PHY_DOUBLE) - { - double * dvertices = (double *)(vertexbase + vertex_index*stride); - vertex[0] = btScalar(dvertices[0]*m_scale[0]); - vertex[1] = btScalar(dvertices[1]*m_scale[1]); - vertex[2] = btScalar(dvertices[2]*m_scale[2]); - } - else - { - float * svertices = (float *)(vertexbase + vertex_index*stride); - vertex[0] = svertices[0]*m_scale[0]; - vertex[1] = svertices[1]*m_scale[1]; - vertex[2] = svertices[2]*m_scale[2]; - } - } - - virtual void get_primitive_box(int prim_index ,btAABB & primbox) const - { - btPrimitiveTriangle triangle; - get_primitive_triangle(prim_index,triangle); - primbox.calc_from_triangle_margin( - triangle.m_vertices[0], - triangle.m_vertices[1],triangle.m_vertices[2],triangle.m_margin); - } - - virtual void get_primitive_triangle(int prim_index,btPrimitiveTriangle & triangle) const - { - int indices[3]; - get_indices(prim_index,indices[0],indices[1],indices[2]); - get_vertex(indices[0],triangle.m_vertices[0]); - get_vertex(indices[1],triangle.m_vertices[1]); - get_vertex(indices[2],triangle.m_vertices[2]); - triangle.m_margin = m_margin; - } - - SIMD_FORCE_INLINE void get_bullet_triangle(int prim_index,btTriangleShapeEx & triangle) const - { - int indices[3]; - get_indices(prim_index,indices[0],indices[1],indices[2]); - get_vertex(indices[0],triangle.m_vertices1[0]); - get_vertex(indices[1],triangle.m_vertices1[1]); - get_vertex(indices[2],triangle.m_vertices1[2]); - triangle.setMargin(m_margin); - } - - }; - - -protected: - TrimeshPrimitiveManager m_primitive_manager; -public: - - btGImpactMeshShapePart() - { - m_box_set.setPrimitiveManager(&m_primitive_manager); - } - - - btGImpactMeshShapePart(btStridingMeshInterface * meshInterface, int part) - { - m_primitive_manager.m_meshInterface = meshInterface; - m_primitive_manager.m_part = part; - m_box_set.setPrimitiveManager(&m_primitive_manager); - } - - virtual ~btGImpactMeshShapePart() - { - } - - //! if true, then its children must get transforms. - virtual bool childrenHasTransform() const - { - return false; - } - - - //! call when reading child shapes - virtual void lockChildShapes() const - { - void * dummy = (void*)(m_box_set.getPrimitiveManager()); - TrimeshPrimitiveManager * dummymanager = static_cast(dummy); - dummymanager->lock(); - } - - virtual void unlockChildShapes() const - { - void * dummy = (void*)(m_box_set.getPrimitiveManager()); - TrimeshPrimitiveManager * dummymanager = static_cast(dummy); - dummymanager->unlock(); - } - - //! Gets the number of children - virtual int getNumChildShapes() const - { - return m_primitive_manager.get_primitive_count(); - } - - - //! Gets the children - virtual btCollisionShape* getChildShape(int index) - { - btAssert(0); - return NULL; - } - - - - //! Gets the child - virtual const btCollisionShape* getChildShape(int index) const - { - btAssert(0); - return NULL; - } - - //! Gets the children transform - virtual btTransform getChildTransform(int index) const - { - btAssert(0); - return btTransform(); - } - - //! Sets the children transform - /*! - \post You must call updateBound() for update the box set. - */ - virtual void setChildTransform(int index, const btTransform & transform) - { - btAssert(0); - } - - - //! Obtains the primitive manager - virtual const btPrimitiveManagerBase * getPrimitiveManager() const - { - return &m_primitive_manager; - } - - SIMD_FORCE_INLINE TrimeshPrimitiveManager * getTrimeshPrimitiveManager() - { - return &m_primitive_manager; - } - - - - - - virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const; - - - - - virtual const char* getName()const - { - return "GImpactMeshShapePart"; - } - - virtual eGIMPACT_SHAPE_TYPE getGImpactShapeType() - { - return CONST_GIMPACT_TRIMESH_SHAPE_PART; - } - - //! Determines if this shape has triangles - virtual bool needsRetrieveTriangles() const - { - return true; - } - - //! Determines if this shape has tetrahedrons - virtual bool needsRetrieveTetrahedrons() const - { - return false; - } - - virtual void getBulletTriangle(int prim_index,btTriangleShapeEx & triangle) const - { - m_primitive_manager.get_bullet_triangle(prim_index,triangle); - } - - virtual void getBulletTetrahedron(int prim_index,btTetrahedronShapeEx & tetrahedron) const - { - btAssert(0); - } - - - - SIMD_FORCE_INLINE int getVertexCount() const - { - return m_primitive_manager.get_vertex_count(); - } - - SIMD_FORCE_INLINE void getVertex(int vertex_index, btVector3 & vertex) const - { - m_primitive_manager.get_vertex(vertex_index,vertex); - } - - SIMD_FORCE_INLINE void setMargin(btScalar margin) - { - m_primitive_manager.m_margin = margin; - postUpdate(); - } - - SIMD_FORCE_INLINE btScalar getMargin() const - { - return m_primitive_manager.m_margin; - } - - virtual void setLocalScaling(const btVector3& scaling) - { - m_primitive_manager.m_scale = scaling; - postUpdate(); - } - - virtual const btVector3& getLocalScaling() const - { - return m_primitive_manager.m_scale; - } - - SIMD_FORCE_INLINE int getPart() const - { - return (int)m_primitive_manager.m_part; - } - - virtual void processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const; -}; - - -//! This class manages a mesh supplied by the btStridingMeshInterface interface. -/*! -Set of btGImpactMeshShapePart parts -- Simply create this shape by passing the btStridingMeshInterface to the constructor btGImpactMeshShape, then you must call updateBound() after creating the mesh - -- You can handle deformable meshes with this shape, by calling postUpdate() every time when changing the mesh vertices. - -*/ -class btGImpactMeshShape : public btGImpactShapeInterface -{ - btStridingMeshInterface* m_meshInterface; - -protected: - btAlignedObjectArray m_mesh_parts; - void buildMeshParts(btStridingMeshInterface * meshInterface) - { - for (int i=0;igetNumSubParts() ;++i ) - { - btGImpactMeshShapePart * newpart = new btGImpactMeshShapePart(meshInterface,i); - m_mesh_parts.push_back(newpart); - } - } - - //! use this function for perfofm refit in bounding boxes - virtual void calcLocalAABB() - { - m_localAABB.invalidate(); - int i = m_mesh_parts.size(); - while(i--) - { - m_mesh_parts[i]->updateBound(); - m_localAABB.merge(m_mesh_parts[i]->getLocalBox()); - } - } - -public: - btGImpactMeshShape(btStridingMeshInterface * meshInterface) - { - m_meshInterface = meshInterface; - buildMeshParts(meshInterface); - } - - virtual ~btGImpactMeshShape() - { - int i = m_mesh_parts.size(); - while(i--) - { - btGImpactMeshShapePart * part = m_mesh_parts[i]; - delete part; - } - m_mesh_parts.clear(); - } - - - btStridingMeshInterface* getMeshInterface() - { - return m_meshInterface; - } - - const btStridingMeshInterface* getMeshInterface() const - { - return m_meshInterface; - } - - int getMeshPartCount() const - { - return m_mesh_parts.size(); - } - - btGImpactMeshShapePart * getMeshPart(int index) - { - return m_mesh_parts[index]; - } - - - - const btGImpactMeshShapePart * getMeshPart(int index) const - { - return m_mesh_parts[index]; - } - - - virtual void setLocalScaling(const btVector3& scaling) - { - localScaling = scaling; - - int i = m_mesh_parts.size(); - while(i--) - { - btGImpactMeshShapePart * part = m_mesh_parts[i]; - part->setLocalScaling(scaling); - } - - m_needs_update = true; - } - - virtual void setMargin(btScalar margin) - { - m_collisionMargin = margin; - - int i = m_mesh_parts.size(); - while(i--) - { - btGImpactMeshShapePart * part = m_mesh_parts[i]; - part->setMargin(margin); - } - - m_needs_update = true; - } - - //! Tells to this object that is needed to refit all the meshes - virtual void postUpdate() - { - int i = m_mesh_parts.size(); - while(i--) - { - btGImpactMeshShapePart * part = m_mesh_parts[i]; - part->postUpdate(); - } - - m_needs_update = true; - } - - virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const; - - - //! Obtains the primitive manager - virtual const btPrimitiveManagerBase * getPrimitiveManager() const - { - btAssert(0); - return NULL; - } - - - //! Gets the number of children - virtual int getNumChildShapes() const - { - btAssert(0); - return 0; - } - - - //! if true, then its children must get transforms. - virtual bool childrenHasTransform() const - { - btAssert(0); - return false; - } - - //! Determines if this shape has triangles - virtual bool needsRetrieveTriangles() const - { - btAssert(0); - return false; - } - - //! Determines if this shape has tetrahedrons - virtual bool needsRetrieveTetrahedrons() const - { - btAssert(0); - return false; - } - - virtual void getBulletTriangle(int prim_index,btTriangleShapeEx & triangle) const - { - btAssert(0); - } - - virtual void getBulletTetrahedron(int prim_index,btTetrahedronShapeEx & tetrahedron) const - { - btAssert(0); - } - - //! call when reading child shapes - virtual void lockChildShapes() const - { - btAssert(0); - } - - virtual void unlockChildShapes() const - { - btAssert(0); - } - - - - - //! Retrieves the bound from a child - /*! - */ - virtual void getChildAabb(int child_index,const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const - { - btAssert(0); - } - - //! Gets the children - virtual btCollisionShape* getChildShape(int index) - { - btAssert(0); - return NULL; - } - - - //! Gets the child - virtual const btCollisionShape* getChildShape(int index) const - { - btAssert(0); - return NULL; - } - - //! Gets the children transform - virtual btTransform getChildTransform(int index) const - { - btAssert(0); - return btTransform(); - } - - //! Sets the children transform - /*! - \post You must call updateBound() for update the box set. - */ - virtual void setChildTransform(int index, const btTransform & transform) - { - btAssert(0); - } - - - virtual eGIMPACT_SHAPE_TYPE getGImpactShapeType() - { - return CONST_GIMPACT_TRIMESH_SHAPE; - } - - - virtual const char* getName()const - { - return "GImpactMesh"; - } - - virtual void rayTest(const btVector3& rayFrom, const btVector3& rayTo, btCollisionWorld::RayResultCallback& resultCallback) const; - - //! Function for retrieve triangles. - /*! - It gives the triangles in local space - */ - virtual void processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const; -}; - - -#endif //GIMPACT_MESH_SHAPE_H diff --git a/bullet/src/BulletCollision/Gimpact/btGenericPoolAllocator.cpp b/bullet/src/BulletCollision/Gimpact/btGenericPoolAllocator.cpp deleted file mode 100644 index 4247ec152..000000000 --- a/bullet/src/BulletCollision/Gimpact/btGenericPoolAllocator.cpp +++ /dev/null @@ -1,283 +0,0 @@ -/*! \file btGenericPoolAllocator.cpp -\author Francisco Len Njera. email projectileman@yahoo.com - -General purpose allocator class -*/ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btGenericPoolAllocator.h" - - - -/// *************** btGenericMemoryPool ******************/////////// - -size_t btGenericMemoryPool::allocate_from_free_nodes(size_t num_elements) -{ - size_t ptr = BT_UINT_MAX; - - if(m_free_nodes_count == 0) return BT_UINT_MAX; - // find an avaliable free node with the correct size - size_t revindex = m_free_nodes_count; - - while(revindex-- && ptr == BT_UINT_MAX) - { - if(m_allocated_sizes[m_free_nodes[revindex]]>=num_elements) - { - ptr = revindex; - } - } - if(ptr == BT_UINT_MAX) return BT_UINT_MAX; // not found - - - revindex = ptr; - ptr = m_free_nodes[revindex]; - // post: ptr contains the node index, and revindex the index in m_free_nodes - - size_t finalsize = m_allocated_sizes[ptr]; - finalsize -= num_elements; - - m_allocated_sizes[ptr] = num_elements; - - // post: finalsize>=0, m_allocated_sizes[ptr] has the requested size - - if(finalsize>0) // preserve free node, there are some free memory - { - m_free_nodes[revindex] = ptr + num_elements; - m_allocated_sizes[ptr + num_elements] = finalsize; - } - else // delete free node - { - // swap with end - m_free_nodes[revindex] = m_free_nodes[m_free_nodes_count-1]; - m_free_nodes_count--; - } - - return ptr; -} - -size_t btGenericMemoryPool::allocate_from_pool(size_t num_elements) -{ - if(m_allocated_count+num_elements>m_max_element_count) return BT_UINT_MAX; - - size_t ptr = m_allocated_count; - - m_allocated_sizes[m_allocated_count] = num_elements; - m_allocated_count+=num_elements; - - return ptr; -} - - -void btGenericMemoryPool::init_pool(size_t element_size, size_t element_count) -{ - m_allocated_count = 0; - m_free_nodes_count = 0; - - m_element_size = element_size; - m_max_element_count = element_count; - - - - - m_pool = (unsigned char *) btAlignedAlloc(m_element_size*m_max_element_count,16); - m_free_nodes = (size_t *) btAlignedAlloc(sizeof(size_t)*m_max_element_count,16); - m_allocated_sizes = (size_t *) btAlignedAlloc(sizeof(size_t)*m_max_element_count,16); - - for (size_t i = 0;i< m_max_element_count;i++ ) - { - m_allocated_sizes[i] = 0; - } -} - -void btGenericMemoryPool::end_pool() -{ - btAlignedFree(m_pool); - btAlignedFree(m_free_nodes); - btAlignedFree(m_allocated_sizes); - m_allocated_count = 0; - m_free_nodes_count = 0; -} - - -//! Allocates memory in pool -/*! -\param size_bytes size in bytes of the buffer -*/ -void * btGenericMemoryPool::allocate(size_t size_bytes) -{ - - size_t module = size_bytes%m_element_size; - size_t element_count = size_bytes/m_element_size; - if(module>0) element_count++; - - size_t alloc_pos = allocate_from_free_nodes(element_count); - // a free node is found - if(alloc_pos != BT_UINT_MAX) - { - return get_element_data(alloc_pos); - } - // allocate directly on pool - alloc_pos = allocate_from_pool(element_count); - - if(alloc_pos == BT_UINT_MAX) return NULL; // not space - return get_element_data(alloc_pos); -} - -bool btGenericMemoryPool::freeMemory(void * pointer) -{ - unsigned char * pointer_pos = (unsigned char *)pointer; - unsigned char * pool_pos = (unsigned char *)m_pool; - // calc offset - if(pointer_pos=get_pool_capacity()) return false;// far away - - // find free position - m_free_nodes[m_free_nodes_count] = offset/m_element_size; - m_free_nodes_count++; - return true; -} - - -/// *******************! btGenericPoolAllocator *******************!/// - - -btGenericPoolAllocator::~btGenericPoolAllocator() -{ - // destroy pools - size_t i; - for (i=0;iend_pool(); - btAlignedFree(m_pools[i]); - } -} - - -// creates a pool -btGenericMemoryPool * btGenericPoolAllocator::push_new_pool() -{ - if(m_pool_count >= BT_DEFAULT_MAX_POOLS) return NULL; - - btGenericMemoryPool * newptr = (btGenericMemoryPool *)btAlignedAlloc(sizeof(btGenericMemoryPool),16); - - m_pools[m_pool_count] = newptr; - - m_pools[m_pool_count]->init_pool(m_pool_element_size,m_pool_element_count); - - m_pool_count++; - return newptr; -} - -void * btGenericPoolAllocator::failback_alloc(size_t size_bytes) -{ - - btGenericMemoryPool * pool = NULL; - - - if(size_bytes<=get_pool_capacity()) - { - pool = push_new_pool(); - } - - if(pool==NULL) // failback - { - return btAlignedAlloc(size_bytes,16); - } - - return pool->allocate(size_bytes); -} - -bool btGenericPoolAllocator::failback_free(void * pointer) -{ - btAlignedFree(pointer); - return true; -} - - -//! Allocates memory in pool -/*! -\param size_bytes size in bytes of the buffer -*/ -void * btGenericPoolAllocator::allocate(size_t size_bytes) -{ - void * ptr = NULL; - - size_t i = 0; - while(iallocate(size_bytes); - ++i; - } - - if(ptr) return ptr; - - return failback_alloc(size_bytes); -} - -bool btGenericPoolAllocator::freeMemory(void * pointer) -{ - bool result = false; - - size_t i = 0; - while(ifreeMemory(pointer); - ++i; - } - - if(result) return true; - - return failback_free(pointer); -} - -/// ************** STANDARD ALLOCATOR ***************************/// - - -#define BT_DEFAULT_POOL_SIZE 32768 -#define BT_DEFAULT_POOL_ELEMENT_SIZE 8 - -// main allocator -class GIM_STANDARD_ALLOCATOR: public btGenericPoolAllocator -{ -public: - GIM_STANDARD_ALLOCATOR():btGenericPoolAllocator(BT_DEFAULT_POOL_ELEMENT_SIZE,BT_DEFAULT_POOL_SIZE) - { - } -}; - -// global allocator -GIM_STANDARD_ALLOCATOR g_main_allocator; - - -void * btPoolAlloc(size_t size) -{ - return g_main_allocator.allocate(size); -} - -void * btPoolRealloc(void *ptr, size_t oldsize, size_t newsize) -{ - void * newptr = btPoolAlloc(newsize); - size_t copysize = oldsize -#include -#include -#include "LinearMath/btAlignedAllocator.h" - -#define BT_UINT_MAX UINT_MAX -#define BT_DEFAULT_MAX_POOLS 16 - - -//! Generic Pool class -class btGenericMemoryPool -{ -public: - unsigned char * m_pool; //[m_element_size*m_max_element_count]; - size_t * m_free_nodes; //[m_max_element_count];//! free nodes - size_t * m_allocated_sizes;//[m_max_element_count];//! Number of elements allocated per node - size_t m_allocated_count; - size_t m_free_nodes_count; -protected: - size_t m_element_size; - size_t m_max_element_count; - - size_t allocate_from_free_nodes(size_t num_elements); - size_t allocate_from_pool(size_t num_elements); - -public: - - void init_pool(size_t element_size, size_t element_count); - - void end_pool(); - - - btGenericMemoryPool(size_t element_size, size_t element_count) - { - init_pool(element_size, element_count); - } - - ~btGenericMemoryPool() - { - end_pool(); - } - - - inline size_t get_pool_capacity() - { - return m_element_size*m_max_element_count; - } - - inline size_t gem_element_size() - { - return m_element_size; - } - - inline size_t get_max_element_count() - { - return m_max_element_count; - } - - inline size_t get_allocated_count() - { - return m_allocated_count; - } - - inline size_t get_free_positions_count() - { - return m_free_nodes_count; - } - - inline void * get_element_data(size_t element_index) - { - return &m_pool[element_index*m_element_size]; - } - - //! Allocates memory in pool - /*! - \param size_bytes size in bytes of the buffer - */ - void * allocate(size_t size_bytes); - - bool freeMemory(void * pointer); -}; - - - - -//! Generic Allocator with pools -/*! -General purpose Allocator which can create Memory Pools dynamiacally as needed. -*/ -class btGenericPoolAllocator -{ -protected: - size_t m_pool_element_size; - size_t m_pool_element_count; -public: - btGenericMemoryPool * m_pools[BT_DEFAULT_MAX_POOLS]; - size_t m_pool_count; - - - inline size_t get_pool_capacity() - { - return m_pool_element_size*m_pool_element_count; - } - - -protected: - // creates a pool - btGenericMemoryPool * push_new_pool(); - - void * failback_alloc(size_t size_bytes); - - bool failback_free(void * pointer); -public: - - btGenericPoolAllocator(size_t pool_element_size, size_t pool_element_count) - { - m_pool_count = 0; - m_pool_element_size = pool_element_size; - m_pool_element_count = pool_element_count; - } - - virtual ~btGenericPoolAllocator(); - - //! Allocates memory in pool - /*! - \param size_bytes size in bytes of the buffer - */ - void * allocate(size_t size_bytes); - - bool freeMemory(void * pointer); -}; - - - -void * btPoolAlloc(size_t size); -void * btPoolRealloc(void *ptr, size_t oldsize, size_t newsize); -void btPoolFree(void *ptr); - - -#endif diff --git a/bullet/src/BulletCollision/Gimpact/btGeometryOperations.h b/bullet/src/BulletCollision/Gimpact/btGeometryOperations.h deleted file mode 100644 index 86c4bb209..000000000 --- a/bullet/src/BulletCollision/Gimpact/btGeometryOperations.h +++ /dev/null @@ -1,212 +0,0 @@ -#ifndef BT_BASIC_GEOMETRY_OPERATIONS_H_INCLUDED -#define BT_BASIC_GEOMETRY_OPERATIONS_H_INCLUDED - -/*! \file btGeometryOperations.h -*\author Francisco Len Njera - -*/ -/* -This source file is part of GIMPACT Library. - -For the latest info, see http://gimpact.sourceforge.net/ - -Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371. -email: projectileman@yahoo.com - - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btBoxCollision.h" - - - - - -#define PLANEDIREPSILON 0.0000001f -#define PARALELENORMALS 0.000001f - - -#define BT_CLAMP(number,minval,maxval) (numbermaxval?maxval:number)) - -/// Calc a plane from a triangle edge an a normal. plane is a vec4f -SIMD_FORCE_INLINE void bt_edge_plane(const btVector3 & e1,const btVector3 & e2, const btVector3 & normal,btVector4 & plane) -{ - btVector3 planenormal = (e2-e1).cross(normal); - planenormal.normalize(); - plane.setValue(planenormal[0],planenormal[1],planenormal[2],e2.dot(planenormal)); -} - - - -//***************** SEGMENT and LINE FUNCTIONS **********************************/// - -/*! Finds the closest point(cp) to (v) on a segment (e1,e2) - */ -SIMD_FORCE_INLINE void bt_closest_point_on_segment( - btVector3 & cp, const btVector3 & v, - const btVector3 &e1,const btVector3 &e2) -{ - btVector3 n = e2-e1; - cp = v - e1; - btScalar _scalar = cp.dot(n)/n.dot(n); - if(_scalar <0.0f) - { - cp = e1; - } - else if(_scalar >1.0f) - { - cp = e2; - } - else - { - cp = _scalar*n + e1; - } -} - - -//! line plane collision -/*! -*\return - -0 if the ray never intersects - -1 if the ray collides in front - -2 if the ray collides in back -*/ - -SIMD_FORCE_INLINE int bt_line_plane_collision( - const btVector4 & plane, - const btVector3 & vDir, - const btVector3 & vPoint, - btVector3 & pout, - btScalar &tparam, - btScalar tmin, btScalar tmax) -{ - - btScalar _dotdir = vDir.dot(plane); - - if(btFabs(_dotdir)tmax) - { - returnvalue = 0; - tparam = tmax; - } - pout = tparam*vDir + vPoint; - return returnvalue; -} - - -//! Find closest points on segments -SIMD_FORCE_INLINE void bt_segment_collision( - const btVector3 & vA1, - const btVector3 & vA2, - const btVector3 & vB1, - const btVector3 & vB2, - btVector3 & vPointA, - btVector3 & vPointB) -{ - btVector3 AD = vA2 - vA1; - btVector3 BD = vB2 - vB1; - btVector3 N = AD.cross(BD); - btScalar tp = N.length2(); - - btVector4 _M;//plane - - if(tp_M[1]) - { - invert_b_order = true; - BT_SWAP_NUMBERS(_M[0],_M[1]); - } - _M[2] = vA1.dot(AD); - _M[3] = vA2.dot(AD); - //mid points - N[0] = (_M[0]+_M[1])*0.5f; - N[1] = (_M[2]+_M[3])*0.5f; - - if(N[0]=0.0f) - { - if (_dist>m_penetration_depth) - { - m_penetration_depth = _dist; - point_indices[0] = _k; - m_point_count=1; - } - else if ((_dist+SIMD_EPSILON)>=m_penetration_depth) - { - point_indices[m_point_count] = _k; - m_point_count++; - } - } - } - - for ( _k=0;_k0.0f&&dis1>0.0f&&dis2>0.0f) return false; - - // classify points on this triangle - dis0 = bt_distance_point_plane(other.m_plane,m_vertices[0]) - total_margin; - - dis1 = bt_distance_point_plane(other.m_plane,m_vertices[1]) - total_margin; - - dis2 = bt_distance_point_plane(other.m_plane,m_vertices[2]) - total_margin; - - if (dis0>0.0f&&dis1>0.0f&&dis2>0.0f) return false; - - return true; -} - -int btPrimitiveTriangle::clip_triangle(btPrimitiveTriangle & other, btVector3 * clipped_points ) -{ - // edge 0 - - btVector3 temp_points[MAX_TRI_CLIPPING]; - - - btVector4 edgeplane; - - get_edge_plane(0,edgeplane); - - - int clipped_count = bt_plane_clip_triangle( - edgeplane,other.m_vertices[0],other.m_vertices[1],other.m_vertices[2],temp_points); - - if (clipped_count == 0) return 0; - - btVector3 temp_points1[MAX_TRI_CLIPPING]; - - - // edge 1 - get_edge_plane(1,edgeplane); - - - clipped_count = bt_plane_clip_polygon(edgeplane,temp_points,clipped_count,temp_points1); - - if (clipped_count == 0) return 0; - - // edge 2 - get_edge_plane(2,edgeplane); - - clipped_count = bt_plane_clip_polygon( - edgeplane,temp_points1,clipped_count,clipped_points); - - return clipped_count; -} - -bool btPrimitiveTriangle::find_triangle_collision_clip_method(btPrimitiveTriangle & other, GIM_TRIANGLE_CONTACT & contacts) -{ - btScalar margin = m_margin + other.m_margin; - - btVector3 clipped_points[MAX_TRI_CLIPPING]; - int clipped_count; - //create planes - // plane v vs U points - - GIM_TRIANGLE_CONTACT contacts1; - - contacts1.m_separating_normal = m_plane; - - - clipped_count = clip_triangle(other,clipped_points); - - if (clipped_count == 0 ) - { - return false;//Reject - } - - //find most deep interval face1 - contacts1.merge_points(contacts1.m_separating_normal,margin,clipped_points,clipped_count); - if (contacts1.m_point_count == 0) return false; // too far - //Normal pointing to this triangle - contacts1.m_separating_normal *= -1.f; - - - //Clip tri1 by tri2 edges - GIM_TRIANGLE_CONTACT contacts2; - contacts2.m_separating_normal = other.m_plane; - - clipped_count = other.clip_triangle(*this,clipped_points); - - if (clipped_count == 0 ) - { - return false;//Reject - } - - //find most deep interval face1 - contacts2.merge_points(contacts2.m_separating_normal,margin,clipped_points,clipped_count); - if (contacts2.m_point_count == 0) return false; // too far - - - - - ////check most dir for contacts - if (contacts2.m_penetration_depth0.0f&&dis1>0.0f&&dis2>0.0f) return false; - - // classify points on this triangle - dis0 = bt_distance_point_plane(plane1,m_vertices1[0]) - total_margin; - - dis1 = bt_distance_point_plane(plane1,m_vertices1[1]) - total_margin; - - dis2 = bt_distance_point_plane(plane1,m_vertices1[2]) - total_margin; - - if (dis0>0.0f&&dis1>0.0f&&dis2>0.0f) return false; - - return true; -} - - diff --git a/bullet/src/BulletCollision/Gimpact/btTriangleShapeEx.h b/bullet/src/BulletCollision/Gimpact/btTriangleShapeEx.h deleted file mode 100644 index d0d7793a9..000000000 --- a/bullet/src/BulletCollision/Gimpact/btTriangleShapeEx.h +++ /dev/null @@ -1,180 +0,0 @@ -/*! \file btGImpactShape.h -\author Francisco Len Njera -*/ -/* -This source file is part of GIMPACT Library. - -For the latest info, see http://gimpact.sourceforge.net/ - -Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371. -email: projectileman@yahoo.com - - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#ifndef TRIANGLE_SHAPE_EX_H -#define TRIANGLE_SHAPE_EX_H - -#include "BulletCollision/CollisionShapes/btCollisionShape.h" -#include "BulletCollision/CollisionShapes/btTriangleShape.h" -#include "btBoxCollision.h" -#include "btClipPolygon.h" -#include "btGeometryOperations.h" - - -#define MAX_TRI_CLIPPING 16 - -//! Structure for collision -struct GIM_TRIANGLE_CONTACT -{ - btScalar m_penetration_depth; - int m_point_count; - btVector4 m_separating_normal; - btVector3 m_points[MAX_TRI_CLIPPING]; - - SIMD_FORCE_INLINE void copy_from(const GIM_TRIANGLE_CONTACT& other) - { - m_penetration_depth = other.m_penetration_depth; - m_separating_normal = other.m_separating_normal; - m_point_count = other.m_point_count; - int i = m_point_count; - while(i--) - { - m_points[i] = other.m_points[i]; - } - } - - GIM_TRIANGLE_CONTACT() - { - } - - GIM_TRIANGLE_CONTACT(const GIM_TRIANGLE_CONTACT& other) - { - copy_from(other); - } - - //! classify points that are closer - void merge_points(const btVector4 & plane, - btScalar margin, const btVector3 * points, int point_count); - -}; - - - -class btPrimitiveTriangle -{ -public: - btVector3 m_vertices[3]; - btVector4 m_plane; - btScalar m_margin; - btScalar m_dummy; - btPrimitiveTriangle():m_margin(0.01f) - { - - } - - - SIMD_FORCE_INLINE void buildTriPlane() - { - btVector3 normal = (m_vertices[1]-m_vertices[0]).cross(m_vertices[2]-m_vertices[0]); - normal.normalize(); - m_plane.setValue(normal[0],normal[1],normal[2],m_vertices[0].dot(normal)); - } - - //! Test if triangles could collide - bool overlap_test_conservative(const btPrimitiveTriangle& other); - - //! Calcs the plane which is paralele to the edge and perpendicular to the triangle plane - /*! - \pre this triangle must have its plane calculated. - */ - SIMD_FORCE_INLINE void get_edge_plane(int edge_index, btVector4 &plane) const - { - const btVector3 & e0 = m_vertices[edge_index]; - const btVector3 & e1 = m_vertices[(edge_index+1)%3]; - bt_edge_plane(e0,e1,m_plane,plane); - } - - void applyTransform(const btTransform& t) - { - m_vertices[0] = t(m_vertices[0]); - m_vertices[1] = t(m_vertices[1]); - m_vertices[2] = t(m_vertices[2]); - } - - //! Clips the triangle against this - /*! - \pre clipped_points must have MAX_TRI_CLIPPING size, and this triangle must have its plane calculated. - \return the number of clipped points - */ - int clip_triangle(btPrimitiveTriangle & other, btVector3 * clipped_points ); - - //! Find collision using the clipping method - /*! - \pre this triangle and other must have their triangles calculated - */ - bool find_triangle_collision_clip_method(btPrimitiveTriangle & other, GIM_TRIANGLE_CONTACT & contacts); -}; - - - -//! Helper class for colliding Bullet Triangle Shapes -/*! -This class implements a better getAabb method than the previous btTriangleShape class -*/ -class btTriangleShapeEx: public btTriangleShape -{ -public: - - btTriangleShapeEx():btTriangleShape(btVector3(0,0,0),btVector3(0,0,0),btVector3(0,0,0)) - { - } - - btTriangleShapeEx(const btVector3& p0,const btVector3& p1,const btVector3& p2): btTriangleShape(p0,p1,p2) - { - } - - btTriangleShapeEx(const btTriangleShapeEx & other): btTriangleShape(other.m_vertices1[0],other.m_vertices1[1],other.m_vertices1[2]) - { - } - - virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax)const - { - btVector3 tv0 = t(m_vertices1[0]); - btVector3 tv1 = t(m_vertices1[1]); - btVector3 tv2 = t(m_vertices1[2]); - - btAABB trianglebox(tv0,tv1,tv2,m_collisionMargin); - aabbMin = trianglebox.m_min; - aabbMax = trianglebox.m_max; - } - - void applyTransform(const btTransform& t) - { - m_vertices1[0] = t(m_vertices1[0]); - m_vertices1[1] = t(m_vertices1[1]); - m_vertices1[2] = t(m_vertices1[2]); - } - - SIMD_FORCE_INLINE void buildTriPlane(btVector4 & plane) const - { - btVector3 normal = (m_vertices1[1]-m_vertices1[0]).cross(m_vertices1[2]-m_vertices1[0]); - normal.normalize(); - plane.setValue(normal[0],normal[1],normal[2],m_vertices1[0].dot(normal)); - } - - bool overlap_test_conservative(const btTriangleShapeEx& other); -}; - - -#endif //TRIANGLE_MESH_SHAPE_H diff --git a/bullet/src/BulletCollision/Gimpact/gim_array.h b/bullet/src/BulletCollision/Gimpact/gim_array.h deleted file mode 100644 index 0b61eab41..000000000 --- a/bullet/src/BulletCollision/Gimpact/gim_array.h +++ /dev/null @@ -1,326 +0,0 @@ -#ifndef GIM_ARRAY_H_INCLUDED -#define GIM_ARRAY_H_INCLUDED -/*! \file gim_array.h -\author Francisco Len Njera -*/ -/* ------------------------------------------------------------------------------ -This source file is part of GIMPACT Library. - -For the latest info, see http://gimpact.sourceforge.net/ - -Copyright (c) 2006 Francisco Leon Najera. C.C. 80087371. -email: projectileman@yahoo.com - - This library is free software; you can redistribute it and/or - modify it under the terms of EITHER: - (1) The GNU Lesser General Public License as published by the Free - Software Foundation; either version 2.1 of the License, or (at - your option) any later version. The text of the GNU Lesser - General Public License is included with this library in the - file GIMPACT-LICENSE-LGPL.TXT. - (2) The BSD-style license that is included with this library in - the file GIMPACT-LICENSE-BSD.TXT. - (3) The zlib/libpng license that is included with this library in - the file GIMPACT-LICENSE-ZLIB.TXT. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files - GIMPACT-LICENSE-LGPL.TXT, GIMPACT-LICENSE-ZLIB.TXT and GIMPACT-LICENSE-BSD.TXT for more details. - ------------------------------------------------------------------------------ -*/ - -#include "gim_memory.h" - - -#define GIM_ARRAY_GROW_INCREMENT 2 -#define GIM_ARRAY_GROW_FACTOR 2 - -//! Very simple array container with fast access and simd memory -template -class gim_array -{ -public: -//! properties -//!@{ - T *m_data; - GUINT m_size; - GUINT m_allocated_size; -//!@} -//! protected operations -//!@{ - - inline void destroyData() - { - m_allocated_size = 0; - if(m_data==NULL) return; - gim_free(m_data); - m_data = NULL; - } - - inline bool resizeData(GUINT newsize) - { - if(newsize==0) - { - destroyData(); - return true; - } - - if(m_size>0) - { - m_data = (T*)gim_realloc(m_data,m_size*sizeof(T),newsize*sizeof(T)); - } - else - { - m_data = (T*)gim_alloc(newsize*sizeof(T)); - } - m_allocated_size = newsize; - return true; - } - - inline bool growingCheck() - { - if(m_allocated_size<=m_size) - { - GUINT requestsize = m_size; - m_size = m_allocated_size; - if(resizeData((requestsize+GIM_ARRAY_GROW_INCREMENT)*GIM_ARRAY_GROW_FACTOR)==false) return false; - } - return true; - } - -//!@} -//! public operations -//!@{ - inline bool reserve(GUINT size) - { - if(m_allocated_size>=size) return false; - return resizeData(size); - } - - inline void clear_range(GUINT start_range) - { - while(m_size>start_range) - { - m_data[--m_size].~T(); - } - } - - inline void clear() - { - if(m_size==0)return; - clear_range(0); - } - - inline void clear_memory() - { - clear(); - destroyData(); - } - - gim_array() - { - m_data = 0; - m_size = 0; - m_allocated_size = 0; - } - - gim_array(GUINT reservesize) - { - m_data = 0; - m_size = 0; - - m_allocated_size = 0; - reserve(reservesize); - } - - ~gim_array() - { - clear_memory(); - } - - inline GUINT size() const - { - return m_size; - } - - inline GUINT max_size() const - { - return m_allocated_size; - } - - inline T & operator[](size_t i) - { - return m_data[i]; - } - inline const T & operator[](size_t i) const - { - return m_data[i]; - } - - inline T * pointer(){ return m_data;} - inline const T * pointer() const - { return m_data;} - - - inline T * get_pointer_at(GUINT i) - { - return m_data + i; - } - - inline const T * get_pointer_at(GUINT i) const - { - return m_data + i; - } - - inline T & at(GUINT i) - { - return m_data[i]; - } - - inline const T & at(GUINT i) const - { - return m_data[i]; - } - - inline T & front() - { - return *m_data; - } - - inline const T & front() const - { - return *m_data; - } - - inline T & back() - { - return m_data[m_size-1]; - } - - inline const T & back() const - { - return m_data[m_size-1]; - } - - - inline void swap(GUINT i, GUINT j) - { - gim_swap_elements(m_data,i,j); - } - - inline void push_back(const T & obj) - { - this->growingCheck(); - m_data[m_size] = obj; - m_size++; - } - - //!Simply increase the m_size, doesn't call the new element constructor - inline void push_back_mem() - { - this->growingCheck(); - m_size++; - } - - inline void push_back_memcpy(const T & obj) - { - this->growingCheck(); - irr_simd_memcpy(&m_data[m_size],&obj,sizeof(T)); - m_size++; - } - - inline void pop_back() - { - m_size--; - m_data[m_size].~T(); - } - - //!Simply decrease the m_size, doesn't call the deleted element destructor - inline void pop_back_mem() - { - m_size--; - } - - //! fast erase - inline void erase(GUINT index) - { - if(indexgrowingCheck(); - for(GUINT i = m_size;i>index;i--) - { - gim_simd_memcpy(m_data+i,m_data+i-1,sizeof(T)); - } - m_size++; - } - - inline void insert(const T & obj,GUINT index) - { - insert_mem(index); - m_data[index] = obj; - } - - inline void resize(GUINT size, bool call_constructor = true) - { - - if(size>m_size) - { - reserve(size); - if(call_constructor) - { - T obj; - while(m_size -SIMD_FORCE_INLINE bool POINT_IN_HULL( - const CLASS_POINT& point,const CLASS_PLANE * planes,GUINT plane_count) -{ - GREAL _dis; - for (GUINT _i = 0;_i< plane_count;++_i) - { - _dis = DISTANCE_PLANE_POINT(planes[_i],point); - if(_dis>0.0f) return false; - } - return true; -} - -template -SIMD_FORCE_INLINE void PLANE_CLIP_SEGMENT( - const CLASS_POINT& s1, - const CLASS_POINT &s2,const CLASS_PLANE &plane,CLASS_POINT &clipped) -{ - GREAL _dis1,_dis2; - _dis1 = DISTANCE_PLANE_POINT(plane,s1); - VEC_DIFF(clipped,s2,s1); - _dis2 = VEC_DOT(clipped,plane); - VEC_SCALE(clipped,-_dis1/_dis2,clipped); - VEC_SUM(clipped,clipped,s1); -} - -enum ePLANE_INTERSECTION_TYPE -{ - G_BACK_PLANE = 0, - G_COLLIDE_PLANE, - G_FRONT_PLANE -}; - -enum eLINE_PLANE_INTERSECTION_TYPE -{ - G_FRONT_PLANE_S1 = 0, - G_FRONT_PLANE_S2, - G_BACK_PLANE_S1, - G_BACK_PLANE_S2, - G_COLLIDE_PLANE_S1, - G_COLLIDE_PLANE_S2 -}; - -//! Confirms if the plane intersect the edge or nor -/*! -intersection type must have the following values -
    -
  • 0 : Segment in front of plane, s1 closest -
  • 1 : Segment in front of plane, s2 closest -
  • 2 : Segment in back of plane, s1 closest -
  • 3 : Segment in back of plane, s2 closest -
  • 4 : Segment collides plane, s1 in back -
  • 5 : Segment collides plane, s2 in back -
-*/ - -template -SIMD_FORCE_INLINE eLINE_PLANE_INTERSECTION_TYPE PLANE_CLIP_SEGMENT2( - const CLASS_POINT& s1, - const CLASS_POINT &s2, - const CLASS_PLANE &plane,CLASS_POINT &clipped) -{ - GREAL _dis1 = DISTANCE_PLANE_POINT(plane,s1); - GREAL _dis2 = DISTANCE_PLANE_POINT(plane,s2); - if(_dis1 >-G_EPSILON && _dis2 >-G_EPSILON) - { - if(_dis1<_dis2) return G_FRONT_PLANE_S1; - return G_FRONT_PLANE_S2; - } - else if(_dis1 _dis2) return G_BACK_PLANE_S1; - return G_BACK_PLANE_S2; - } - - VEC_DIFF(clipped,s2,s1); - _dis2 = VEC_DOT(clipped,plane); - VEC_SCALE(clipped,-_dis1/_dis2,clipped); - VEC_SUM(clipped,clipped,s1); - if(_dis1<_dis2) return G_COLLIDE_PLANE_S1; - return G_COLLIDE_PLANE_S2; -} - -//! Confirms if the plane intersect the edge or not -/*! -clipped1 and clipped2 are the vertices behind the plane. -clipped1 is the closest - -intersection_type must have the following values -
    -
  • 0 : Segment in front of plane, s1 closest -
  • 1 : Segment in front of plane, s2 closest -
  • 2 : Segment in back of plane, s1 closest -
  • 3 : Segment in back of plane, s2 closest -
  • 4 : Segment collides plane, s1 in back -
  • 5 : Segment collides plane, s2 in back -
-*/ -template -SIMD_FORCE_INLINE eLINE_PLANE_INTERSECTION_TYPE PLANE_CLIP_SEGMENT_CLOSEST( - const CLASS_POINT& s1, - const CLASS_POINT &s2, - const CLASS_PLANE &plane, - CLASS_POINT &clipped1,CLASS_POINT &clipped2) -{ - eLINE_PLANE_INTERSECTION_TYPE intersection_type = PLANE_CLIP_SEGMENT2(s1,s2,plane,clipped1); - switch(intersection_type) - { - case G_FRONT_PLANE_S1: - VEC_COPY(clipped1,s1); - VEC_COPY(clipped2,s2); - break; - case G_FRONT_PLANE_S2: - VEC_COPY(clipped1,s2); - VEC_COPY(clipped2,s1); - break; - case G_BACK_PLANE_S1: - VEC_COPY(clipped1,s1); - VEC_COPY(clipped2,s2); - break; - case G_BACK_PLANE_S2: - VEC_COPY(clipped1,s2); - VEC_COPY(clipped2,s1); - break; - case G_COLLIDE_PLANE_S1: - VEC_COPY(clipped2,s1); - break; - case G_COLLIDE_PLANE_S2: - VEC_COPY(clipped2,s2); - break; - } - return intersection_type; -} - - -//! Finds the 2 smallest cartesian coordinates of a plane normal -#define PLANE_MINOR_AXES(plane, i0, i1) VEC_MINOR_AXES(plane, i0, i1) - -//! Ray plane collision in one way -/*! -Intersects plane in one way only. The ray must face the plane (normals must be in opossite directions).
-It uses the PLANEDIREPSILON constant. -*/ -template -SIMD_FORCE_INLINE bool RAY_PLANE_COLLISION( - const CLASS_PLANE & plane, - const CLASS_POINT & vDir, - const CLASS_POINT & vPoint, - CLASS_POINT & pout,T &tparam) -{ - GREAL _dis,_dotdir; - _dotdir = VEC_DOT(plane,vDir); - if(_dotdir -SIMD_FORCE_INLINE GUINT LINE_PLANE_COLLISION( - const CLASS_PLANE & plane, - const CLASS_POINT & vDir, - const CLASS_POINT & vPoint, - CLASS_POINT & pout, - T &tparam, - T tmin, T tmax) -{ - GREAL _dis,_dotdir; - _dotdir = VEC_DOT(plane,vDir); - if(btFabs(_dotdir)tmax) - { - returnvalue = 0; - tparam = tmax; - } - - VEC_SCALE(pout,tparam,vDir); - VEC_SUM(pout,vPoint,pout); - return returnvalue; -} - -/*! \brief Returns the Ray on which 2 planes intersect if they do. - Written by Rodrigo Hernandez on ODE convex collision - - \param p1 Plane 1 - \param p2 Plane 2 - \param p Contains the origin of the ray upon returning if planes intersect - \param d Contains the direction of the ray upon returning if planes intersect - \return true if the planes intersect, 0 if paralell. - -*/ -template -SIMD_FORCE_INLINE bool INTERSECT_PLANES( - const CLASS_PLANE &p1, - const CLASS_PLANE &p2, - CLASS_POINT &p, - CLASS_POINT &d) -{ - VEC_CROSS(d,p1,p2); - GREAL denom = VEC_DOT(d, d); - if(GIM_IS_ZERO(denom)) return false; - vec3f _n; - _n[0]=p1[3]*p2[0] - p2[3]*p1[0]; - _n[1]=p1[3]*p2[1] - p2[3]*p1[1]; - _n[2]=p1[3]*p2[2] - p2[3]*p1[2]; - VEC_CROSS(p,_n,d); - p[0]/=denom; - p[1]/=denom; - p[2]/=denom; - return true; -} - -//***************** SEGMENT and LINE FUNCTIONS **********************************/// - -/*! Finds the closest point(cp) to (v) on a segment (e1,e2) - */ -template -SIMD_FORCE_INLINE void CLOSEST_POINT_ON_SEGMENT( - CLASS_POINT & cp, const CLASS_POINT & v, - const CLASS_POINT &e1,const CLASS_POINT &e2) -{ - vec3f _n; - VEC_DIFF(_n,e2,e1); - VEC_DIFF(cp,v,e1); - GREAL _scalar = VEC_DOT(cp, _n); - _scalar/= VEC_DOT(_n, _n); - if(_scalar <0.0f) - { - VEC_COPY(cp,e1); - } - else if(_scalar >1.0f) - { - VEC_COPY(cp,e2); - } - else - { - VEC_SCALE(cp,_scalar,_n); - VEC_SUM(cp,cp,e1); - } -} - - -/*! \brief Finds the line params where these lines intersect. - -\param dir1 Direction of line 1 -\param point1 Point of line 1 -\param dir2 Direction of line 2 -\param point2 Point of line 2 -\param t1 Result Parameter for line 1 -\param t2 Result Parameter for line 2 -\param dointersect 0 if the lines won't intersect, else 1 - -*/ -template -SIMD_FORCE_INLINE bool LINE_INTERSECTION_PARAMS( - const CLASS_POINT & dir1, - CLASS_POINT & point1, - const CLASS_POINT & dir2, - CLASS_POINT & point2, - T& t1,T& t2) -{ - GREAL det; - GREAL e1e1 = VEC_DOT(dir1,dir1); - GREAL e1e2 = VEC_DOT(dir1,dir2); - GREAL e2e2 = VEC_DOT(dir2,dir2); - vec3f p1p2; - VEC_DIFF(p1p2,point1,point2); - GREAL p1p2e1 = VEC_DOT(p1p2,dir1); - GREAL p1p2e2 = VEC_DOT(p1p2,dir2); - det = e1e2*e1e2 - e1e1*e2e2; - if(GIM_IS_ZERO(det)) return false; - t1 = (e1e2*p1p2e2 - e2e2*p1p2e1)/det; - t2 = (e1e1*p1p2e2 - e1e2*p1p2e1)/det; - return true; -} - -//! Find closest points on segments -template -SIMD_FORCE_INLINE void SEGMENT_COLLISION( - const CLASS_POINT & vA1, - const CLASS_POINT & vA2, - const CLASS_POINT & vB1, - const CLASS_POINT & vB2, - CLASS_POINT & vPointA, - CLASS_POINT & vPointB) -{ - CLASS_POINT _AD,_BD,_N; - vec4f _M;//plane - VEC_DIFF(_AD,vA2,vA1); - VEC_DIFF(_BD,vB2,vB1); - VEC_CROSS(_N,_AD,_BD); - GREAL _tp = VEC_DOT(_N,_N); - if(_tp_M[1]) - { - invert_b_order = true; - GIM_SWAP_NUMBERS(_M[0],_M[1]); - } - _M[2] = VEC_DOT(vA1,_AD); - _M[3] = VEC_DOT(vA2,_AD); - //mid points - _N[0] = (_M[0]+_M[1])*0.5f; - _N[1] = (_M[2]+_M[3])*0.5f; - - if(_N[0]<_N[1]) - { - if(_M[1]<_M[2]) - { - vPointB = invert_b_order?vB1:vB2; - vPointA = vA1; - } - else if(_M[1]<_M[3]) - { - vPointB = invert_b_order?vB1:vB2; - CLOSEST_POINT_ON_SEGMENT(vPointA,vPointB,vA1,vA2); - } - else - { - vPointA = vA2; - CLOSEST_POINT_ON_SEGMENT(vPointB,vPointA,vB1,vB2); - } - } - else - { - if(_M[3]<_M[0]) - { - vPointB = invert_b_order?vB2:vB1; - vPointA = vA2; - } - else if(_M[3]<_M[1]) - { - vPointA = vA2; - CLOSEST_POINT_ON_SEGMENT(vPointB,vPointA,vB1,vB2); - } - else - { - vPointB = invert_b_order?vB1:vB2; - CLOSEST_POINT_ON_SEGMENT(vPointA,vPointB,vA1,vA2); - } - } - return; - } - - - VEC_CROSS(_M,_N,_BD); - _M[3] = VEC_DOT(_M,vB1); - - LINE_PLANE_COLLISION(_M,_AD,vA1,vPointA,_tp,btScalar(0), btScalar(1)); - /*Closest point on segment*/ - VEC_DIFF(vPointB,vPointA,vB1); - _tp = VEC_DOT(vPointB, _BD); - _tp/= VEC_DOT(_BD, _BD); - _tp = GIM_CLAMP(_tp,0.0f,1.0f); - VEC_SCALE(vPointB,_tp,_BD); - VEC_SUM(vPointB,vPointB,vB1); -} - - - - -//! Line box intersection in one dimension -/*! - -*\param pos Position of the ray -*\param dir Projection of the Direction of the ray -*\param bmin Minimum bound of the box -*\param bmax Maximum bound of the box -*\param tfirst the minimum projection. Assign to 0 at first. -*\param tlast the maximum projection. Assign to INFINITY at first. -*\return true if there is an intersection. -*/ -template -SIMD_FORCE_INLINE bool BOX_AXIS_INTERSECT(T pos, T dir,T bmin, T bmax, T & tfirst, T & tlast) -{ - if(GIM_IS_ZERO(dir)) - { - return !(pos < bmin || pos > bmax); - } - GREAL a0 = (bmin - pos) / dir; - GREAL a1 = (bmax - pos) / dir; - if(a0 > a1) GIM_SWAP_NUMBERS(a0, a1); - tfirst = GIM_MAX(a0, tfirst); - tlast = GIM_MIN(a1, tlast); - if (tlast < tfirst) return false; - return true; -} - - -//! Sorts 3 componets -template -SIMD_FORCE_INLINE void SORT_3_INDICES( - const T * values, - GUINT * order_indices) -{ - //get minimum - order_indices[0] = values[0] < values[1] ? (values[0] < values[2] ? 0 : 2) : (values[1] < values[2] ? 1 : 2); - - //get second and third - GUINT i0 = (order_indices[0] + 1)%3; - GUINT i1 = (i0 + 1)%3; - - if(values[i0] < values[i1]) - { - order_indices[1] = i0; - order_indices[2] = i1; - } - else - { - order_indices[1] = i1; - order_indices[2] = i0; - } -} - - - - - -#endif // GIM_VECTOR_H_INCLUDED diff --git a/bullet/src/BulletCollision/Gimpact/gim_bitset.h b/bullet/src/BulletCollision/Gimpact/gim_bitset.h deleted file mode 100644 index d2cac514b..000000000 --- a/bullet/src/BulletCollision/Gimpact/gim_bitset.h +++ /dev/null @@ -1,123 +0,0 @@ -#ifndef GIM_BITSET_H_INCLUDED -#define GIM_BITSET_H_INCLUDED -/*! \file gim_bitset.h -\author Francisco Len Njera -*/ -/* ------------------------------------------------------------------------------ -This source file is part of GIMPACT Library. - -For the latest info, see http://gimpact.sourceforge.net/ - -Copyright (c) 2006 Francisco Leon Najera. C.C. 80087371. -email: projectileman@yahoo.com - - This library is free software; you can redistribute it and/or - modify it under the terms of EITHER: - (1) The GNU Lesser General Public License as published by the Free - Software Foundation; either version 2.1 of the License, or (at - your option) any later version. The text of the GNU Lesser - General Public License is included with this library in the - file GIMPACT-LICENSE-LGPL.TXT. - (2) The BSD-style license that is included with this library in - the file GIMPACT-LICENSE-BSD.TXT. - (3) The zlib/libpng license that is included with this library in - the file GIMPACT-LICENSE-ZLIB.TXT. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files - GIMPACT-LICENSE-LGPL.TXT, GIMPACT-LICENSE-ZLIB.TXT and GIMPACT-LICENSE-BSD.TXT for more details. - ------------------------------------------------------------------------------ -*/ - -#include "gim_array.h" - - -#define GUINT_BIT_COUNT 32 -#define GUINT_EXPONENT 5 - -class gim_bitset -{ -public: - gim_array m_container; - - gim_bitset() - { - - } - - gim_bitset(GUINT bits_count) - { - resize(bits_count); - } - - ~gim_bitset() - { - } - - inline bool resize(GUINT newsize) - { - GUINT oldsize = m_container.size(); - m_container.resize(newsize/GUINT_BIT_COUNT + 1,false); - while(oldsize=size()) - { - resize(bit_index); - } - m_container[bit_index >> GUINT_EXPONENT] |= (1 << (bit_index & (GUINT_BIT_COUNT-1))); - } - - ///Return 0 or 1 - inline char get(GUINT bit_index) - { - if(bit_index>=size()) - { - return 0; - } - char value = m_container[bit_index >> GUINT_EXPONENT] & - (1 << (bit_index & (GUINT_BIT_COUNT-1))); - return value; - } - - inline void clear(GUINT bit_index) - { - m_container[bit_index >> GUINT_EXPONENT] &= ~(1 << (bit_index & (GUINT_BIT_COUNT-1))); - } -}; - - - - - -#endif // GIM_CONTAINERS_H_INCLUDED diff --git a/bullet/src/BulletCollision/Gimpact/gim_box_collision.h b/bullet/src/BulletCollision/Gimpact/gim_box_collision.h deleted file mode 100644 index 906b641e2..000000000 --- a/bullet/src/BulletCollision/Gimpact/gim_box_collision.h +++ /dev/null @@ -1,590 +0,0 @@ -#ifndef GIM_BOX_COLLISION_H_INCLUDED -#define GIM_BOX_COLLISION_H_INCLUDED - -/*! \file gim_box_collision.h -\author Francisco Len Njera -*/ -/* ------------------------------------------------------------------------------ -This source file is part of GIMPACT Library. - -For the latest info, see http://gimpact.sourceforge.net/ - -Copyright (c) 2006 Francisco Leon Najera. C.C. 80087371. -email: projectileman@yahoo.com - - This library is free software; you can redistribute it and/or - modify it under the terms of EITHER: - (1) The GNU Lesser General Public License as published by the Free - Software Foundation; either version 2.1 of the License, or (at - your option) any later version. The text of the GNU Lesser - General Public License is included with this library in the - file GIMPACT-LICENSE-LGPL.TXT. - (2) The BSD-style license that is included with this library in - the file GIMPACT-LICENSE-BSD.TXT. - (3) The zlib/libpng license that is included with this library in - the file GIMPACT-LICENSE-ZLIB.TXT. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files - GIMPACT-LICENSE-LGPL.TXT, GIMPACT-LICENSE-ZLIB.TXT and GIMPACT-LICENSE-BSD.TXT for more details. - ------------------------------------------------------------------------------ -*/ -#include "gim_basic_geometry_operations.h" -#include "LinearMath/btTransform.h" - - - -//SIMD_FORCE_INLINE bool test_cross_edge_box( -// const btVector3 & edge, -// const btVector3 & absolute_edge, -// const btVector3 & pointa, -// const btVector3 & pointb, const btVector3 & extend, -// int dir_index0, -// int dir_index1 -// int component_index0, -// int component_index1) -//{ -// // dir coords are -z and y -// -// const btScalar dir0 = -edge[dir_index0]; -// const btScalar dir1 = edge[dir_index1]; -// btScalar pmin = pointa[component_index0]*dir0 + pointa[component_index1]*dir1; -// btScalar pmax = pointb[component_index0]*dir0 + pointb[component_index1]*dir1; -// //find minmax -// if(pmin>pmax) -// { -// GIM_SWAP_NUMBERS(pmin,pmax); -// } -// //find extends -// const btScalar rad = extend[component_index0] * absolute_edge[dir_index0] + -// extend[component_index1] * absolute_edge[dir_index1]; -// -// if(pmin>rad || -rad>pmax) return false; -// return true; -//} -// -//SIMD_FORCE_INLINE bool test_cross_edge_box_X_axis( -// const btVector3 & edge, -// const btVector3 & absolute_edge, -// const btVector3 & pointa, -// const btVector3 & pointb, btVector3 & extend) -//{ -// -// return test_cross_edge_box(edge,absolute_edge,pointa,pointb,extend,2,1,1,2); -//} -// -// -//SIMD_FORCE_INLINE bool test_cross_edge_box_Y_axis( -// const btVector3 & edge, -// const btVector3 & absolute_edge, -// const btVector3 & pointa, -// const btVector3 & pointb, btVector3 & extend) -//{ -// -// return test_cross_edge_box(edge,absolute_edge,pointa,pointb,extend,0,2,2,0); -//} -// -//SIMD_FORCE_INLINE bool test_cross_edge_box_Z_axis( -// const btVector3 & edge, -// const btVector3 & absolute_edge, -// const btVector3 & pointa, -// const btVector3 & pointb, btVector3 & extend) -//{ -// -// return test_cross_edge_box(edge,absolute_edge,pointa,pointb,extend,1,0,0,1); -//} - -#define TEST_CROSS_EDGE_BOX_MCR(edge,absolute_edge,pointa,pointb,_extend,i_dir_0,i_dir_1,i_comp_0,i_comp_1)\ -{\ - const btScalar dir0 = -edge[i_dir_0];\ - const btScalar dir1 = edge[i_dir_1];\ - btScalar pmin = pointa[i_comp_0]*dir0 + pointa[i_comp_1]*dir1;\ - btScalar pmax = pointb[i_comp_0]*dir0 + pointb[i_comp_1]*dir1;\ - if(pmin>pmax)\ - {\ - GIM_SWAP_NUMBERS(pmin,pmax); \ - }\ - const btScalar abs_dir0 = absolute_edge[i_dir_0];\ - const btScalar abs_dir1 = absolute_edge[i_dir_1];\ - const btScalar rad = _extend[i_comp_0] * abs_dir0 + _extend[i_comp_1] * abs_dir1;\ - if(pmin>rad || -rad>pmax) return false;\ -}\ - - -#define TEST_CROSS_EDGE_BOX_X_AXIS_MCR(edge,absolute_edge,pointa,pointb,_extend)\ -{\ - TEST_CROSS_EDGE_BOX_MCR(edge,absolute_edge,pointa,pointb,_extend,2,1,1,2);\ -}\ - -#define TEST_CROSS_EDGE_BOX_Y_AXIS_MCR(edge,absolute_edge,pointa,pointb,_extend)\ -{\ - TEST_CROSS_EDGE_BOX_MCR(edge,absolute_edge,pointa,pointb,_extend,0,2,2,0);\ -}\ - -#define TEST_CROSS_EDGE_BOX_Z_AXIS_MCR(edge,absolute_edge,pointa,pointb,_extend)\ -{\ - TEST_CROSS_EDGE_BOX_MCR(edge,absolute_edge,pointa,pointb,_extend,1,0,0,1);\ -}\ - - - -//! Class for transforming a model1 to the space of model0 -class GIM_BOX_BOX_TRANSFORM_CACHE -{ -public: - btVector3 m_T1to0;//!< Transforms translation of model1 to model 0 - btMatrix3x3 m_R1to0;//!< Transforms Rotation of model1 to model 0, equal to R0' * R1 - btMatrix3x3 m_AR;//!< Absolute value of m_R1to0 - - SIMD_FORCE_INLINE void calc_absolute_matrix() - { - static const btVector3 vepsi(1e-6f,1e-6f,1e-6f); - m_AR[0] = vepsi + m_R1to0[0].absolute(); - m_AR[1] = vepsi + m_R1to0[1].absolute(); - m_AR[2] = vepsi + m_R1to0[2].absolute(); - } - - GIM_BOX_BOX_TRANSFORM_CACHE() - { - } - - - GIM_BOX_BOX_TRANSFORM_CACHE(mat4f trans1_to_0) - { - COPY_MATRIX_3X3(m_R1to0,trans1_to_0) - MAT_GET_TRANSLATION(trans1_to_0,m_T1to0) - calc_absolute_matrix(); - } - - //! Calc the transformation relative 1 to 0. Inverts matrics by transposing - SIMD_FORCE_INLINE void calc_from_homogenic(const btTransform & trans0,const btTransform & trans1) - { - - m_R1to0 = trans0.getBasis().transpose(); - m_T1to0 = m_R1to0 * (-trans0.getOrigin()); - - m_T1to0 += m_R1to0*trans1.getOrigin(); - m_R1to0 *= trans1.getBasis(); - - calc_absolute_matrix(); - } - - //! Calcs the full invertion of the matrices. Useful for scaling matrices - SIMD_FORCE_INLINE void calc_from_full_invert(const btTransform & trans0,const btTransform & trans1) - { - m_R1to0 = trans0.getBasis().inverse(); - m_T1to0 = m_R1to0 * (-trans0.getOrigin()); - - m_T1to0 += m_R1to0*trans1.getOrigin(); - m_R1to0 *= trans1.getBasis(); - - calc_absolute_matrix(); - } - - SIMD_FORCE_INLINE btVector3 transform(const btVector3 & point) - { - return btVector3(m_R1to0[0].dot(point) + m_T1to0.x(), - m_R1to0[1].dot(point) + m_T1to0.y(), - m_R1to0[2].dot(point) + m_T1to0.z()); - } -}; - - -#define BOX_PLANE_EPSILON 0.000001f - -//! Axis aligned box -class GIM_AABB -{ -public: - btVector3 m_min; - btVector3 m_max; - - GIM_AABB() - {} - - - GIM_AABB(const btVector3 & V1, - const btVector3 & V2, - const btVector3 & V3) - { - m_min[0] = GIM_MIN3(V1[0],V2[0],V3[0]); - m_min[1] = GIM_MIN3(V1[1],V2[1],V3[1]); - m_min[2] = GIM_MIN3(V1[2],V2[2],V3[2]); - - m_max[0] = GIM_MAX3(V1[0],V2[0],V3[0]); - m_max[1] = GIM_MAX3(V1[1],V2[1],V3[1]); - m_max[2] = GIM_MAX3(V1[2],V2[2],V3[2]); - } - - GIM_AABB(const btVector3 & V1, - const btVector3 & V2, - const btVector3 & V3, - GREAL margin) - { - m_min[0] = GIM_MIN3(V1[0],V2[0],V3[0]); - m_min[1] = GIM_MIN3(V1[1],V2[1],V3[1]); - m_min[2] = GIM_MIN3(V1[2],V2[2],V3[2]); - - m_max[0] = GIM_MAX3(V1[0],V2[0],V3[0]); - m_max[1] = GIM_MAX3(V1[1],V2[1],V3[1]); - m_max[2] = GIM_MAX3(V1[2],V2[2],V3[2]); - - m_min[0] -= margin; - m_min[1] -= margin; - m_min[2] -= margin; - m_max[0] += margin; - m_max[1] += margin; - m_max[2] += margin; - } - - GIM_AABB(const GIM_AABB &other): - m_min(other.m_min),m_max(other.m_max) - { - } - - GIM_AABB(const GIM_AABB &other,btScalar margin ): - m_min(other.m_min),m_max(other.m_max) - { - m_min[0] -= margin; - m_min[1] -= margin; - m_min[2] -= margin; - m_max[0] += margin; - m_max[1] += margin; - m_max[2] += margin; - } - - SIMD_FORCE_INLINE void invalidate() - { - m_min[0] = G_REAL_INFINITY; - m_min[1] = G_REAL_INFINITY; - m_min[2] = G_REAL_INFINITY; - m_max[0] = -G_REAL_INFINITY; - m_max[1] = -G_REAL_INFINITY; - m_max[2] = -G_REAL_INFINITY; - } - - SIMD_FORCE_INLINE void increment_margin(btScalar margin) - { - m_min[0] -= margin; - m_min[1] -= margin; - m_min[2] -= margin; - m_max[0] += margin; - m_max[1] += margin; - m_max[2] += margin; - } - - SIMD_FORCE_INLINE void copy_with_margin(const GIM_AABB &other, btScalar margin) - { - m_min[0] = other.m_min[0] - margin; - m_min[1] = other.m_min[1] - margin; - m_min[2] = other.m_min[2] - margin; - - m_max[0] = other.m_max[0] + margin; - m_max[1] = other.m_max[1] + margin; - m_max[2] = other.m_max[2] + margin; - } - - template - SIMD_FORCE_INLINE void calc_from_triangle( - const CLASS_POINT & V1, - const CLASS_POINT & V2, - const CLASS_POINT & V3) - { - m_min[0] = GIM_MIN3(V1[0],V2[0],V3[0]); - m_min[1] = GIM_MIN3(V1[1],V2[1],V3[1]); - m_min[2] = GIM_MIN3(V1[2],V2[2],V3[2]); - - m_max[0] = GIM_MAX3(V1[0],V2[0],V3[0]); - m_max[1] = GIM_MAX3(V1[1],V2[1],V3[1]); - m_max[2] = GIM_MAX3(V1[2],V2[2],V3[2]); - } - - template - SIMD_FORCE_INLINE void calc_from_triangle_margin( - const CLASS_POINT & V1, - const CLASS_POINT & V2, - const CLASS_POINT & V3, btScalar margin) - { - m_min[0] = GIM_MIN3(V1[0],V2[0],V3[0]); - m_min[1] = GIM_MIN3(V1[1],V2[1],V3[1]); - m_min[2] = GIM_MIN3(V1[2],V2[2],V3[2]); - - m_max[0] = GIM_MAX3(V1[0],V2[0],V3[0]); - m_max[1] = GIM_MAX3(V1[1],V2[1],V3[1]); - m_max[2] = GIM_MAX3(V1[2],V2[2],V3[2]); - - m_min[0] -= margin; - m_min[1] -= margin; - m_min[2] -= margin; - m_max[0] += margin; - m_max[1] += margin; - m_max[2] += margin; - } - - //! Apply a transform to an AABB - SIMD_FORCE_INLINE void appy_transform(const btTransform & trans) - { - btVector3 center = (m_max+m_min)*0.5f; - btVector3 extends = m_max - center; - // Compute new center - center = trans(center); - - btVector3 textends(extends.dot(trans.getBasis().getRow(0).absolute()), - extends.dot(trans.getBasis().getRow(1).absolute()), - extends.dot(trans.getBasis().getRow(2).absolute())); - - m_min = center - textends; - m_max = center + textends; - } - - //! Merges a Box - SIMD_FORCE_INLINE void merge(const GIM_AABB & box) - { - m_min[0] = GIM_MIN(m_min[0],box.m_min[0]); - m_min[1] = GIM_MIN(m_min[1],box.m_min[1]); - m_min[2] = GIM_MIN(m_min[2],box.m_min[2]); - - m_max[0] = GIM_MAX(m_max[0],box.m_max[0]); - m_max[1] = GIM_MAX(m_max[1],box.m_max[1]); - m_max[2] = GIM_MAX(m_max[2],box.m_max[2]); - } - - //! Merges a point - template - SIMD_FORCE_INLINE void merge_point(const CLASS_POINT & point) - { - m_min[0] = GIM_MIN(m_min[0],point[0]); - m_min[1] = GIM_MIN(m_min[1],point[1]); - m_min[2] = GIM_MIN(m_min[2],point[2]); - - m_max[0] = GIM_MAX(m_max[0],point[0]); - m_max[1] = GIM_MAX(m_max[1],point[1]); - m_max[2] = GIM_MAX(m_max[2],point[2]); - } - - //! Gets the extend and center - SIMD_FORCE_INLINE void get_center_extend(btVector3 & center,btVector3 & extend) const - { - center = (m_max+m_min)*0.5f; - extend = m_max - center; - } - - //! Finds the intersecting box between this box and the other. - SIMD_FORCE_INLINE void find_intersection(const GIM_AABB & other, GIM_AABB & intersection) const - { - intersection.m_min[0] = GIM_MAX(other.m_min[0],m_min[0]); - intersection.m_min[1] = GIM_MAX(other.m_min[1],m_min[1]); - intersection.m_min[2] = GIM_MAX(other.m_min[2],m_min[2]); - - intersection.m_max[0] = GIM_MIN(other.m_max[0],m_max[0]); - intersection.m_max[1] = GIM_MIN(other.m_max[1],m_max[1]); - intersection.m_max[2] = GIM_MIN(other.m_max[2],m_max[2]); - } - - - SIMD_FORCE_INLINE bool has_collision(const GIM_AABB & other) const - { - if(m_min[0] > other.m_max[0] || - m_max[0] < other.m_min[0] || - m_min[1] > other.m_max[1] || - m_max[1] < other.m_min[1] || - m_min[2] > other.m_max[2] || - m_max[2] < other.m_min[2]) - { - return false; - } - return true; - } - - /*! \brief Finds the Ray intersection parameter. - \param aabb Aligned box - \param vorigin A vec3f with the origin of the ray - \param vdir A vec3f with the direction of the ray - */ - SIMD_FORCE_INLINE bool collide_ray(const btVector3 & vorigin,const btVector3 & vdir) - { - btVector3 extents,center; - this->get_center_extend(center,extents);; - - btScalar Dx = vorigin[0] - center[0]; - if(GIM_GREATER(Dx, extents[0]) && Dx*vdir[0]>=0.0f) return false; - btScalar Dy = vorigin[1] - center[1]; - if(GIM_GREATER(Dy, extents[1]) && Dy*vdir[1]>=0.0f) return false; - btScalar Dz = vorigin[2] - center[2]; - if(GIM_GREATER(Dz, extents[2]) && Dz*vdir[2]>=0.0f) return false; - - - btScalar f = vdir[1] * Dz - vdir[2] * Dy; - if(btFabs(f) > extents[1]*btFabs(vdir[2]) + extents[2]*btFabs(vdir[1])) return false; - f = vdir[2] * Dx - vdir[0] * Dz; - if(btFabs(f) > extents[0]*btFabs(vdir[2]) + extents[2]*btFabs(vdir[0]))return false; - f = vdir[0] * Dy - vdir[1] * Dx; - if(btFabs(f) > extents[0]*btFabs(vdir[1]) + extents[1]*btFabs(vdir[0]))return false; - return true; - } - - - SIMD_FORCE_INLINE void projection_interval(const btVector3 & direction, btScalar &vmin, btScalar &vmax) const - { - btVector3 center = (m_max+m_min)*0.5f; - btVector3 extend = m_max-center; - - btScalar _fOrigin = direction.dot(center); - btScalar _fMaximumExtent = extend.dot(direction.absolute()); - vmin = _fOrigin - _fMaximumExtent; - vmax = _fOrigin + _fMaximumExtent; - } - - SIMD_FORCE_INLINE ePLANE_INTERSECTION_TYPE plane_classify(const btVector4 &plane) const - { - btScalar _fmin,_fmax; - this->projection_interval(plane,_fmin,_fmax); - - if(plane[3] > _fmax + BOX_PLANE_EPSILON) - { - return G_BACK_PLANE; // 0 - } - - if(plane[3]+BOX_PLANE_EPSILON >=_fmin) - { - return G_COLLIDE_PLANE; //1 - } - return G_FRONT_PLANE;//2 - } - - SIMD_FORCE_INLINE bool overlapping_trans_conservative(const GIM_AABB & box, btTransform & trans1_to_0) - { - GIM_AABB tbox = box; - tbox.appy_transform(trans1_to_0); - return has_collision(tbox); - } - - //! transcache is the transformation cache from box to this AABB - SIMD_FORCE_INLINE bool overlapping_trans_cache( - const GIM_AABB & box,const GIM_BOX_BOX_TRANSFORM_CACHE & transcache, bool fulltest) - { - - //Taken from OPCODE - btVector3 ea,eb;//extends - btVector3 ca,cb;//extends - get_center_extend(ca,ea); - box.get_center_extend(cb,eb); - - - btVector3 T; - btScalar t,t2; - int i; - - // Class I : A's basis vectors - for(i=0;i<3;i++) - { - T[i] = transcache.m_R1to0[i].dot(cb) + transcache.m_T1to0[i] - ca[i]; - t = transcache.m_AR[i].dot(eb) + ea[i]; - if(GIM_GREATER(T[i], t)) return false; - } - // Class II : B's basis vectors - for(i=0;i<3;i++) - { - t = MAT_DOT_COL(transcache.m_R1to0,T,i); - t2 = MAT_DOT_COL(transcache.m_AR,ea,i) + eb[i]; - if(GIM_GREATER(t,t2)) return false; - } - // Class III : 9 cross products - if(fulltest) - { - int j,m,n,o,p,q,r; - for(i=0;i<3;i++) - { - m = (i+1)%3; - n = (i+2)%3; - o = i==0?1:0; - p = i==2?1:2; - for(j=0;j<3;j++) - { - q = j==2?1:2; - r = j==0?1:0; - t = T[n]*transcache.m_R1to0[m][j] - T[m]*transcache.m_R1to0[n][j]; - t2 = ea[o]*transcache.m_AR[p][j] + ea[p]*transcache.m_AR[o][j] + - eb[r]*transcache.m_AR[i][q] + eb[q]*transcache.m_AR[i][r]; - if(GIM_GREATER(t,t2)) return false; - } - } - } - return true; - } - - //! Simple test for planes. - SIMD_FORCE_INLINE bool collide_plane( - const btVector4 & plane) - { - ePLANE_INTERSECTION_TYPE classify = plane_classify(plane); - return (classify == G_COLLIDE_PLANE); - } - - //! test for a triangle, with edges - SIMD_FORCE_INLINE bool collide_triangle_exact( - const btVector3 & p1, - const btVector3 & p2, - const btVector3 & p3, - const btVector4 & triangle_plane) - { - if(!collide_plane(triangle_plane)) return false; - - btVector3 center,extends; - this->get_center_extend(center,extends); - - const btVector3 v1(p1 - center); - const btVector3 v2(p2 - center); - const btVector3 v3(p3 - center); - - //First axis - btVector3 diff(v2 - v1); - btVector3 abs_diff = diff.absolute(); - //Test With X axis - TEST_CROSS_EDGE_BOX_X_AXIS_MCR(diff,abs_diff,v1,v3,extends); - //Test With Y axis - TEST_CROSS_EDGE_BOX_Y_AXIS_MCR(diff,abs_diff,v1,v3,extends); - //Test With Z axis - TEST_CROSS_EDGE_BOX_Z_AXIS_MCR(diff,abs_diff,v1,v3,extends); - - - diff = v3 - v2; - abs_diff = diff.absolute(); - //Test With X axis - TEST_CROSS_EDGE_BOX_X_AXIS_MCR(diff,abs_diff,v2,v1,extends); - //Test With Y axis - TEST_CROSS_EDGE_BOX_Y_AXIS_MCR(diff,abs_diff,v2,v1,extends); - //Test With Z axis - TEST_CROSS_EDGE_BOX_Z_AXIS_MCR(diff,abs_diff,v2,v1,extends); - - diff = v1 - v3; - abs_diff = diff.absolute(); - //Test With X axis - TEST_CROSS_EDGE_BOX_X_AXIS_MCR(diff,abs_diff,v3,v2,extends); - //Test With Y axis - TEST_CROSS_EDGE_BOX_Y_AXIS_MCR(diff,abs_diff,v3,v2,extends); - //Test With Z axis - TEST_CROSS_EDGE_BOX_Z_AXIS_MCR(diff,abs_diff,v3,v2,extends); - - return true; - } -}; - - -//! Compairison of transformation objects -SIMD_FORCE_INLINE bool btCompareTransformsEqual(const btTransform & t1,const btTransform & t2) -{ - if(!(t1.getOrigin() == t2.getOrigin()) ) return false; - - if(!(t1.getBasis().getRow(0) == t2.getBasis().getRow(0)) ) return false; - if(!(t1.getBasis().getRow(1) == t2.getBasis().getRow(1)) ) return false; - if(!(t1.getBasis().getRow(2) == t2.getBasis().getRow(2)) ) return false; - return true; -} - - - -#endif // GIM_BOX_COLLISION_H_INCLUDED diff --git a/bullet/src/BulletCollision/Gimpact/gim_box_set.cpp b/bullet/src/BulletCollision/Gimpact/gim_box_set.cpp deleted file mode 100644 index b91dddaac..000000000 --- a/bullet/src/BulletCollision/Gimpact/gim_box_set.cpp +++ /dev/null @@ -1,182 +0,0 @@ - -/* ------------------------------------------------------------------------------ -This source file is part of GIMPACT Library. - -For the latest info, see http://gimpact.sourceforge.net/ - -Copyright (c) 2006 Francisco Leon Najera. C.C. 80087371. -email: projectileman@yahoo.com - - This library is free software; you can redistribute it and/or - modify it under the terms of EITHER: - (1) The GNU Lesser General Public License as published by the Free - Software Foundation; either version 2.1 of the License, or (at - your option) any later version. The text of the GNU Lesser - General Public License is included with this library in the - file GIMPACT-LICENSE-LGPL.TXT. - (2) The BSD-style license that is included with this library in - the file GIMPACT-LICENSE-BSD.TXT. - (3) The zlib/libpng license that is included with this library in - the file GIMPACT-LICENSE-ZLIB.TXT. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files - GIMPACT-LICENSE-LGPL.TXT, GIMPACT-LICENSE-ZLIB.TXT and GIMPACT-LICENSE-BSD.TXT for more details. - ------------------------------------------------------------------------------ -*/ - - -#include "gim_box_set.h" - - -GUINT GIM_BOX_TREE::_calc_splitting_axis( - gim_array & primitive_boxes, GUINT startIndex, GUINT endIndex) -{ - GUINT i; - - btVector3 means(btScalar(0.),btScalar(0.),btScalar(0.)); - btVector3 variance(btScalar(0.),btScalar(0.),btScalar(0.)); - GUINT numIndices = endIndex-startIndex; - - for (i=startIndex;i & primitive_boxes, GUINT startIndex, - GUINT endIndex, GUINT splitAxis) -{ - GUINT i; - GUINT splitIndex =startIndex; - GUINT numIndices = endIndex - startIndex; - - // average of centers - btScalar splitValue = 0.0f; - for (i=startIndex;i splitValue) - { - //swap - primitive_boxes.swap(i,splitIndex); - splitIndex++; - } - } - - //if the splitIndex causes unbalanced trees, fix this by using the center in between startIndex and endIndex - //otherwise the tree-building might fail due to stack-overflows in certain cases. - //unbalanced1 is unsafe: it can cause stack overflows - //bool unbalanced1 = ((splitIndex==startIndex) || (splitIndex == (endIndex-1))); - - //unbalanced2 should work too: always use center (perfect balanced trees) - //bool unbalanced2 = true; - - //this should be safe too: - GUINT rangeBalancedIndices = numIndices/3; - bool unbalanced = ((splitIndex<=(startIndex+rangeBalancedIndices)) || (splitIndex >=(endIndex-1-rangeBalancedIndices))); - - if (unbalanced) - { - splitIndex = startIndex+ (numIndices>>1); - } - - btAssert(!((splitIndex==startIndex) || (splitIndex == (endIndex)))); - - return splitIndex; -} - - -void GIM_BOX_TREE::_build_sub_tree(gim_array & primitive_boxes, GUINT startIndex, GUINT endIndex) -{ - GUINT current_index = m_num_nodes++; - - btAssert((endIndex-startIndex)>0); - - if((endIndex-startIndex) == 1) //we got a leaf - { - m_node_array[current_index].m_left = 0; - m_node_array[current_index].m_right = 0; - m_node_array[current_index].m_escapeIndex = 0; - - m_node_array[current_index].m_bound = primitive_boxes[startIndex].m_bound; - m_node_array[current_index].m_data = primitive_boxes[startIndex].m_data; - return; - } - - //configure inner node - - GUINT splitIndex; - - //calc this node bounding box - m_node_array[current_index].m_bound.invalidate(); - for (splitIndex=startIndex;splitIndex & primitive_boxes) -{ - // initialize node count to 0 - m_num_nodes = 0; - // allocate nodes - m_node_array.resize(primitive_boxes.size()*2); - - _build_sub_tree(primitive_boxes, 0, primitive_boxes.size()); -} - - diff --git a/bullet/src/BulletCollision/Gimpact/gim_box_set.h b/bullet/src/BulletCollision/Gimpact/gim_box_set.h deleted file mode 100644 index fabdbb4da..000000000 --- a/bullet/src/BulletCollision/Gimpact/gim_box_set.h +++ /dev/null @@ -1,671 +0,0 @@ -#ifndef GIM_BOX_SET_H_INCLUDED -#define GIM_BOX_SET_H_INCLUDED - -/*! \file gim_box_set.h -\author Francisco Len Njera -*/ -/* ------------------------------------------------------------------------------ -This source file is part of GIMPACT Library. - -For the latest info, see http://gimpact.sourceforge.net/ - -Copyright (c) 2006 Francisco Leon Najera. C.C. 80087371. -email: projectileman@yahoo.com - - This library is free software; you can redistribute it and/or - modify it under the terms of EITHER: - (1) The GNU Lesser General Public License as published by the Free - Software Foundation; either version 2.1 of the License, or (at - your option) any later version. The text of the GNU Lesser - General Public License is included with this library in the - file GIMPACT-LICENSE-LGPL.TXT. - (2) The BSD-style license that is included with this library in - the file GIMPACT-LICENSE-BSD.TXT. - (3) The zlib/libpng license that is included with this library in - the file GIMPACT-LICENSE-ZLIB.TXT. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files - GIMPACT-LICENSE-LGPL.TXT, GIMPACT-LICENSE-ZLIB.TXT and GIMPACT-LICENSE-BSD.TXT for more details. - ------------------------------------------------------------------------------ -*/ - - -#include "gim_array.h" -#include "gim_radixsort.h" -#include "gim_box_collision.h" -#include "gim_tri_collision.h" - - - -//! Overlapping pair -struct GIM_PAIR -{ - GUINT m_index1; - GUINT m_index2; - GIM_PAIR() - {} - - GIM_PAIR(const GIM_PAIR & p) - { - m_index1 = p.m_index1; - m_index2 = p.m_index2; - } - - GIM_PAIR(GUINT index1, GUINT index2) - { - m_index1 = index1; - m_index2 = index2; - } -}; - -//! A pairset array -class gim_pair_set: public gim_array -{ -public: - gim_pair_set():gim_array(32) - { - } - inline void push_pair(GUINT index1,GUINT index2) - { - push_back(GIM_PAIR(index1,index2)); - } - - inline void push_pair_inv(GUINT index1,GUINT index2) - { - push_back(GIM_PAIR(index2,index1)); - } -}; - - -//! Prototype Base class for primitive classification -/*! -This class is a wrapper for primitive collections. -This tells relevant info for the Bounding Box set classes, which take care of space classification. -This class can manage Compound shapes and trimeshes, and if it is managing trimesh then the Hierarchy Bounding Box classes will take advantage of primitive Vs Box overlapping tests for getting optimal results and less Per Box compairisons. -*/ -class GIM_PRIMITIVE_MANAGER_PROTOTYPE -{ -public: - - //! determines if this manager consist on only triangles, which special case will be optimized - virtual bool is_trimesh() = 0; - virtual GUINT get_primitive_count() = 0; - virtual void get_primitive_box(GUINT prim_index ,GIM_AABB & primbox) = 0; - virtual void get_primitive_triangle(GUINT prim_index,GIM_TRIANGLE & triangle) = 0; -}; - - -struct GIM_AABB_DATA -{ - GIM_AABB m_bound; - GUINT m_data; -}; - -//! Node Structure for trees -struct GIM_BOX_TREE_NODE -{ - GIM_AABB m_bound; - GUINT m_left;//!< Left subtree - GUINT m_right;//!< Right subtree - GUINT m_escapeIndex;//!< Scape index for traversing - GUINT m_data;//!< primitive index if apply - - GIM_BOX_TREE_NODE() - { - m_left = 0; - m_right = 0; - m_escapeIndex = 0; - m_data = 0; - } - - SIMD_FORCE_INLINE bool is_leaf_node() const - { - return (!m_left && !m_right); - } -}; - -//! Basic Box tree structure -class GIM_BOX_TREE -{ -protected: - GUINT m_num_nodes; - gim_array m_node_array; -protected: - GUINT _sort_and_calc_splitting_index( - gim_array & primitive_boxes, - GUINT startIndex, GUINT endIndex, GUINT splitAxis); - - GUINT _calc_splitting_axis(gim_array & primitive_boxes, GUINT startIndex, GUINT endIndex); - - void _build_sub_tree(gim_array & primitive_boxes, GUINT startIndex, GUINT endIndex); -public: - GIM_BOX_TREE() - { - m_num_nodes = 0; - } - - //! prototype functions for box tree management - //!@{ - void build_tree(gim_array & primitive_boxes); - - SIMD_FORCE_INLINE void clearNodes() - { - m_node_array.clear(); - m_num_nodes = 0; - } - - //! node count - SIMD_FORCE_INLINE GUINT getNodeCount() const - { - return m_num_nodes; - } - - //! tells if the node is a leaf - SIMD_FORCE_INLINE bool isLeafNode(GUINT nodeindex) const - { - return m_node_array[nodeindex].is_leaf_node(); - } - - SIMD_FORCE_INLINE GUINT getNodeData(GUINT nodeindex) const - { - return m_node_array[nodeindex].m_data; - } - - SIMD_FORCE_INLINE void getNodeBound(GUINT nodeindex, GIM_AABB & bound) const - { - bound = m_node_array[nodeindex].m_bound; - } - - SIMD_FORCE_INLINE void setNodeBound(GUINT nodeindex, const GIM_AABB & bound) - { - m_node_array[nodeindex].m_bound = bound; - } - - SIMD_FORCE_INLINE GUINT getLeftNodeIndex(GUINT nodeindex) const - { - return m_node_array[nodeindex].m_left; - } - - SIMD_FORCE_INLINE GUINT getRightNodeIndex(GUINT nodeindex) const - { - return m_node_array[nodeindex].m_right; - } - - SIMD_FORCE_INLINE GUINT getScapeNodeIndex(GUINT nodeindex) const - { - return m_node_array[nodeindex].m_escapeIndex; - } - - //!@} -}; - - -//! Generic Box Tree Template -/*! -This class offers an structure for managing a box tree of primitives. -Requires a Primitive prototype (like GIM_PRIMITIVE_MANAGER_PROTOTYPE ) and -a Box tree structure ( like GIM_BOX_TREE). -*/ -template -class GIM_BOX_TREE_TEMPLATE_SET -{ -protected: - _GIM_PRIMITIVE_MANAGER_PROTOTYPE m_primitive_manager; - _GIM_BOX_TREE_PROTOTYPE m_box_tree; -protected: - //stackless refit - SIMD_FORCE_INLINE void refit() - { - GUINT nodecount = getNodeCount(); - while(nodecount--) - { - if(isLeafNode(nodecount)) - { - GIM_AABB leafbox; - m_primitive_manager.get_primitive_box(getNodeData(nodecount),leafbox); - setNodeBound(nodecount,leafbox); - } - else - { - //get left bound - GUINT childindex = getLeftNodeIndex(nodecount); - GIM_AABB bound; - getNodeBound(childindex,bound); - //get right bound - childindex = getRightNodeIndex(nodecount); - GIM_AABB bound2; - getNodeBound(childindex,bound2); - bound.merge(bound2); - - setNodeBound(nodecount,bound); - } - } - } -public: - - GIM_BOX_TREE_TEMPLATE_SET() - { - } - - SIMD_FORCE_INLINE GIM_AABB getGlobalBox() const - { - GIM_AABB totalbox; - getNodeBound(0, totalbox); - return totalbox; - } - - SIMD_FORCE_INLINE void setPrimitiveManager(const _GIM_PRIMITIVE_MANAGER_PROTOTYPE & primitive_manager) - { - m_primitive_manager = primitive_manager; - } - - const _GIM_PRIMITIVE_MANAGER_PROTOTYPE & getPrimitiveManager() const - { - return m_primitive_manager; - } - - _GIM_PRIMITIVE_MANAGER_PROTOTYPE & getPrimitiveManager() - { - return m_primitive_manager; - } - -//! node manager prototype functions -///@{ - - //! this attemps to refit the box set. - SIMD_FORCE_INLINE void update() - { - refit(); - } - - //! this rebuild the entire set - SIMD_FORCE_INLINE void buildSet() - { - //obtain primitive boxes - gim_array primitive_boxes; - primitive_boxes.resize(m_primitive_manager.get_primitive_count(),false); - - for (GUINT i = 0;i & collided_results) const - { - GUINT curIndex = 0; - GUINT numNodes = getNodeCount(); - - while (curIndex < numNodes) - { - GIM_AABB bound; - getNodeBound(curIndex,bound); - - //catch bugs in tree data - - bool aabbOverlap = bound.has_collision(box); - bool isleafnode = isLeafNode(curIndex); - - if (isleafnode && aabbOverlap) - { - collided_results.push_back(getNodeData(curIndex)); - } - - if (aabbOverlap || isleafnode) - { - //next subnode - curIndex++; - } - else - { - //skip node - curIndex+= getScapeNodeIndex(curIndex); - } - } - if(collided_results.size()>0) return true; - return false; - } - - //! returns the indices of the primitives in the m_primitive_manager - SIMD_FORCE_INLINE bool boxQueryTrans(const GIM_AABB & box, - const btTransform & transform, gim_array & collided_results) const - { - GIM_AABB transbox=box; - transbox.appy_transform(transform); - return boxQuery(transbox,collided_results); - } - - //! returns the indices of the primitives in the m_primitive_manager - SIMD_FORCE_INLINE bool rayQuery( - const btVector3 & ray_dir,const btVector3 & ray_origin , - gim_array & collided_results) const - { - GUINT curIndex = 0; - GUINT numNodes = getNodeCount(); - - while (curIndex < numNodes) - { - GIM_AABB bound; - getNodeBound(curIndex,bound); - - //catch bugs in tree data - - bool aabbOverlap = bound.collide_ray(ray_origin,ray_dir); - bool isleafnode = isLeafNode(curIndex); - - if (isleafnode && aabbOverlap) - { - collided_results.push_back(getNodeData( curIndex)); - } - - if (aabbOverlap || isleafnode) - { - //next subnode - curIndex++; - } - else - { - //skip node - curIndex+= getScapeNodeIndex(curIndex); - } - } - if(collided_results.size()>0) return true; - return false; - } - - //! tells if this set has hierarcht - SIMD_FORCE_INLINE bool hasHierarchy() const - { - return true; - } - - //! tells if this set is a trimesh - SIMD_FORCE_INLINE bool isTrimesh() const - { - return m_primitive_manager.is_trimesh(); - } - - //! node count - SIMD_FORCE_INLINE GUINT getNodeCount() const - { - return m_box_tree.getNodeCount(); - } - - //! tells if the node is a leaf - SIMD_FORCE_INLINE bool isLeafNode(GUINT nodeindex) const - { - return m_box_tree.isLeafNode(nodeindex); - } - - SIMD_FORCE_INLINE GUINT getNodeData(GUINT nodeindex) const - { - return m_box_tree.getNodeData(nodeindex); - } - - SIMD_FORCE_INLINE void getNodeBound(GUINT nodeindex, GIM_AABB & bound) const - { - m_box_tree.getNodeBound(nodeindex, bound); - } - - SIMD_FORCE_INLINE void setNodeBound(GUINT nodeindex, const GIM_AABB & bound) - { - m_box_tree.setNodeBound(nodeindex, bound); - } - - SIMD_FORCE_INLINE GUINT getLeftNodeIndex(GUINT nodeindex) const - { - return m_box_tree.getLeftNodeIndex(nodeindex); - } - - SIMD_FORCE_INLINE GUINT getRightNodeIndex(GUINT nodeindex) const - { - return m_box_tree.getRightNodeIndex(nodeindex); - } - - SIMD_FORCE_INLINE GUINT getScapeNodeIndex(GUINT nodeindex) const - { - return m_box_tree.getScapeNodeIndex(nodeindex); - } - - SIMD_FORCE_INLINE void getNodeTriangle(GUINT nodeindex,GIM_TRIANGLE & triangle) const - { - m_primitive_manager.get_primitive_triangle(getNodeData(nodeindex),triangle); - } - -}; - -//! Class for Box Tree Sets -/*! -this has the GIM_BOX_TREE implementation for bounding boxes. -*/ -template -class GIM_BOX_TREE_SET: public GIM_BOX_TREE_TEMPLATE_SET< _GIM_PRIMITIVE_MANAGER_PROTOTYPE, GIM_BOX_TREE> -{ -public: - -}; - - - - - -/// GIM_BOX_SET collision methods -template -class GIM_TREE_TREE_COLLIDER -{ -public: - gim_pair_set * m_collision_pairs; - BOX_SET_CLASS0 * m_boxset0; - BOX_SET_CLASS1 * m_boxset1; - GUINT current_node0; - GUINT current_node1; - bool node0_is_leaf; - bool node1_is_leaf; - bool t0_is_trimesh; - bool t1_is_trimesh; - bool node0_has_triangle; - bool node1_has_triangle; - GIM_AABB m_box0; - GIM_AABB m_box1; - GIM_BOX_BOX_TRANSFORM_CACHE trans_cache_1to0; - btTransform trans_cache_0to1; - GIM_TRIANGLE m_tri0; - btVector4 m_tri0_plane; - GIM_TRIANGLE m_tri1; - btVector4 m_tri1_plane; - - -public: - GIM_TREE_TREE_COLLIDER() - { - current_node0 = G_UINT_INFINITY; - current_node1 = G_UINT_INFINITY; - } -protected: - SIMD_FORCE_INLINE void retrieve_node0_triangle(GUINT node0) - { - if(node0_has_triangle) return; - m_boxset0->getNodeTriangle(node0,m_tri0); - //transform triangle - m_tri0.m_vertices[0] = trans_cache_0to1(m_tri0.m_vertices[0]); - m_tri0.m_vertices[1] = trans_cache_0to1(m_tri0.m_vertices[1]); - m_tri0.m_vertices[2] = trans_cache_0to1(m_tri0.m_vertices[2]); - m_tri0.get_plane(m_tri0_plane); - - node0_has_triangle = true; - } - - SIMD_FORCE_INLINE void retrieve_node1_triangle(GUINT node1) - { - if(node1_has_triangle) return; - m_boxset1->getNodeTriangle(node1,m_tri1); - //transform triangle - m_tri1.m_vertices[0] = trans_cache_1to0.transform(m_tri1.m_vertices[0]); - m_tri1.m_vertices[1] = trans_cache_1to0.transform(m_tri1.m_vertices[1]); - m_tri1.m_vertices[2] = trans_cache_1to0.transform(m_tri1.m_vertices[2]); - m_tri1.get_plane(m_tri1_plane); - - node1_has_triangle = true; - } - - SIMD_FORCE_INLINE void retrieve_node0_info(GUINT node0) - { - if(node0 == current_node0) return; - m_boxset0->getNodeBound(node0,m_box0); - node0_is_leaf = m_boxset0->isLeafNode(node0); - node0_has_triangle = false; - current_node0 = node0; - } - - SIMD_FORCE_INLINE void retrieve_node1_info(GUINT node1) - { - if(node1 == current_node1) return; - m_boxset1->getNodeBound(node1,m_box1); - node1_is_leaf = m_boxset1->isLeafNode(node1); - node1_has_triangle = false; - current_node1 = node1; - } - - SIMD_FORCE_INLINE bool node_collision(GUINT node0 ,GUINT node1) - { - retrieve_node0_info(node0); - retrieve_node1_info(node1); - bool result = m_box0.overlapping_trans_cache(m_box1,trans_cache_1to0,true); - if(!result) return false; - - if(t0_is_trimesh && node0_is_leaf) - { - //perform primitive vs box collision - retrieve_node0_triangle(node0); - //do triangle vs box collision - m_box1.increment_margin(m_tri0.m_margin); - - result = m_box1.collide_triangle_exact( - m_tri0.m_vertices[0],m_tri0.m_vertices[1],m_tri0.m_vertices[2],m_tri0_plane); - - m_box1.increment_margin(-m_tri0.m_margin); - - if(!result) return false; - return true; - } - else if(t1_is_trimesh && node1_is_leaf) - { - //perform primitive vs box collision - retrieve_node1_triangle(node1); - //do triangle vs box collision - m_box0.increment_margin(m_tri1.m_margin); - - result = m_box0.collide_triangle_exact( - m_tri1.m_vertices[0],m_tri1.m_vertices[1],m_tri1.m_vertices[2],m_tri1_plane); - - m_box0.increment_margin(-m_tri1.m_margin); - - if(!result) return false; - return true; - } - return true; - } - - //stackless collision routine - void find_collision_pairs() - { - gim_pair_set stack_collisions; - stack_collisions.reserve(32); - - //add the first pair - stack_collisions.push_pair(0,0); - - - while(stack_collisions.size()) - { - //retrieve the last pair and pop - GUINT node0 = stack_collisions.back().m_index1; - GUINT node1 = stack_collisions.back().m_index2; - stack_collisions.pop_back(); - if(node_collision(node0,node1)) // a collision is found - { - if(node0_is_leaf) - { - if(node1_is_leaf) - { - m_collision_pairs->push_pair(m_boxset0->getNodeData(node0),m_boxset1->getNodeData(node1)); - } - else - { - //collide left - stack_collisions.push_pair(node0,m_boxset1->getLeftNodeIndex(node1)); - - //collide right - stack_collisions.push_pair(node0,m_boxset1->getRightNodeIndex(node1)); - } - } - else - { - if(node1_is_leaf) - { - //collide left - stack_collisions.push_pair(m_boxset0->getLeftNodeIndex(node0),node1); - //collide right - stack_collisions.push_pair(m_boxset0->getRightNodeIndex(node0),node1); - } - else - { - GUINT left0 = m_boxset0->getLeftNodeIndex(node0); - GUINT right0 = m_boxset0->getRightNodeIndex(node0); - GUINT left1 = m_boxset1->getLeftNodeIndex(node1); - GUINT right1 = m_boxset1->getRightNodeIndex(node1); - //collide left - stack_collisions.push_pair(left0,left1); - //collide right - stack_collisions.push_pair(left0,right1); - //collide left - stack_collisions.push_pair(right0,left1); - //collide right - stack_collisions.push_pair(right0,right1); - - }// else if node1 is not a leaf - }// else if node0 is not a leaf - - }// if(node_collision(node0,node1)) - }//while(stack_collisions.size()) - } -public: - void find_collision(BOX_SET_CLASS0 * boxset1, const btTransform & trans1, - BOX_SET_CLASS1 * boxset2, const btTransform & trans2, - gim_pair_set & collision_pairs, bool complete_primitive_tests = true) - { - m_collision_pairs = &collision_pairs; - m_boxset0 = boxset1; - m_boxset1 = boxset2; - - trans_cache_1to0.calc_from_homogenic(trans1,trans2); - - trans_cache_0to1 = trans2.inverse(); - trans_cache_0to1 *= trans1; - - - if(complete_primitive_tests) - { - t0_is_trimesh = boxset1->getPrimitiveManager().is_trimesh(); - t1_is_trimesh = boxset2->getPrimitiveManager().is_trimesh(); - } - else - { - t0_is_trimesh = false; - t1_is_trimesh = false; - } - - find_collision_pairs(); - } -}; - - -#endif // GIM_BOXPRUNING_H_INCLUDED diff --git a/bullet/src/BulletCollision/Gimpact/gim_clip_polygon.h b/bullet/src/BulletCollision/Gimpact/gim_clip_polygon.h deleted file mode 100644 index 649aa41b8..000000000 --- a/bullet/src/BulletCollision/Gimpact/gim_clip_polygon.h +++ /dev/null @@ -1,210 +0,0 @@ -#ifndef GIM_CLIP_POLYGON_H_INCLUDED -#define GIM_CLIP_POLYGON_H_INCLUDED - -/*! \file gim_tri_collision.h -\author Francisco Len Njera -*/ -/* ------------------------------------------------------------------------------ -This source file is part of GIMPACT Library. - -For the latest info, see http://gimpact.sourceforge.net/ - -Copyright (c) 2006 Francisco Leon Najera. C.C. 80087371. -email: projectileman@yahoo.com - - This library is free software; you can redistribute it and/or - modify it under the terms of EITHER: - (1) The GNU Lesser General Public License as published by the Free - Software Foundation; either version 2.1 of the License, or (at - your option) any later version. The text of the GNU Lesser - General Public License is included with this library in the - file GIMPACT-LICENSE-LGPL.TXT. - (2) The BSD-style license that is included with this library in - the file GIMPACT-LICENSE-BSD.TXT. - (3) The zlib/libpng license that is included with this library in - the file GIMPACT-LICENSE-ZLIB.TXT. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files - GIMPACT-LICENSE-LGPL.TXT, GIMPACT-LICENSE-ZLIB.TXT and GIMPACT-LICENSE-BSD.TXT for more details. - ------------------------------------------------------------------------------ -*/ - - -//! This function calcs the distance from a 3D plane -class DISTANCE_PLANE_3D_FUNC -{ -public: - template - inline GREAL operator()(const CLASS_PLANE & plane, const CLASS_POINT & point) - { - return DISTANCE_PLANE_POINT(plane, point); - } -}; - - - -template -SIMD_FORCE_INLINE void PLANE_CLIP_POLYGON_COLLECT( - const CLASS_POINT & point0, - const CLASS_POINT & point1, - GREAL dist0, - GREAL dist1, - CLASS_POINT * clipped, - GUINT & clipped_count) -{ - GUINT _prevclassif = (dist0>G_EPSILON); - GUINT _classif = (dist1>G_EPSILON); - if(_classif!=_prevclassif) - { - GREAL blendfactor = -dist0/(dist1-dist0); - VEC_BLEND(clipped[clipped_count],point0,point1,blendfactor); - clipped_count++; - } - if(!_classif) - { - VEC_COPY(clipped[clipped_count],point1); - clipped_count++; - } -} - - -//! Clips a polygon by a plane -/*! -*\return The count of the clipped counts -*/ -template -SIMD_FORCE_INLINE GUINT PLANE_CLIP_POLYGON_GENERIC( - const CLASS_PLANE & plane, - const CLASS_POINT * polygon_points, - GUINT polygon_point_count, - CLASS_POINT * clipped,DISTANCE_PLANE_FUNC distance_func) -{ - GUINT clipped_count = 0; - - - //clip first point - GREAL firstdist = distance_func(plane,polygon_points[0]);; - if(!(firstdist>G_EPSILON)) - { - VEC_COPY(clipped[clipped_count],polygon_points[0]); - clipped_count++; - } - - GREAL olddist = firstdist; - for(GUINT _i=1;_i -SIMD_FORCE_INLINE GUINT PLANE_CLIP_TRIANGLE_GENERIC( - const CLASS_PLANE & plane, - const CLASS_POINT & point0, - const CLASS_POINT & point1, - const CLASS_POINT & point2, - CLASS_POINT * clipped,DISTANCE_PLANE_FUNC distance_func) -{ - GUINT clipped_count = 0; - - //clip first point - GREAL firstdist = distance_func(plane,point0);; - if(!(firstdist>G_EPSILON)) - { - VEC_COPY(clipped[clipped_count],point0); - clipped_count++; - } - - // point 1 - GREAL olddist = firstdist; - GREAL dist = distance_func(plane,point1); - - PLANE_CLIP_POLYGON_COLLECT( - point0,point1, - olddist, - dist, - clipped, - clipped_count); - - olddist = dist; - - - // point 2 - dist = distance_func(plane,point2); - - PLANE_CLIP_POLYGON_COLLECT( - point1,point2, - olddist, - dist, - clipped, - clipped_count); - olddist = dist; - - - - //RETURN TO FIRST point - PLANE_CLIP_POLYGON_COLLECT( - point2,point0, - olddist, - firstdist, - clipped, - clipped_count); - - return clipped_count; -} - - -template -SIMD_FORCE_INLINE GUINT PLANE_CLIP_POLYGON3D( - const CLASS_PLANE & plane, - const CLASS_POINT * polygon_points, - GUINT polygon_point_count, - CLASS_POINT * clipped) -{ - return PLANE_CLIP_POLYGON_GENERIC(plane,polygon_points,polygon_point_count,clipped,DISTANCE_PLANE_3D_FUNC()); -} - - -template -SIMD_FORCE_INLINE GUINT PLANE_CLIP_TRIANGLE3D( - const CLASS_PLANE & plane, - const CLASS_POINT & point0, - const CLASS_POINT & point1, - const CLASS_POINT & point2, - CLASS_POINT * clipped) -{ - return PLANE_CLIP_TRIANGLE_GENERIC(plane,point0,point1,point2,clipped,DISTANCE_PLANE_3D_FUNC()); -} - - - -#endif // GIM_TRI_COLLISION_H_INCLUDED diff --git a/bullet/src/BulletCollision/Gimpact/gim_contact.cpp b/bullet/src/BulletCollision/Gimpact/gim_contact.cpp deleted file mode 100644 index 8beec8893..000000000 --- a/bullet/src/BulletCollision/Gimpact/gim_contact.cpp +++ /dev/null @@ -1,146 +0,0 @@ - -/* ------------------------------------------------------------------------------ -This source file is part of GIMPACT Library. - -For the latest info, see http://gimpact.sourceforge.net/ - -Copyright (c) 2006 Francisco Leon Najera. C.C. 80087371. -email: projectileman@yahoo.com - - This library is free software; you can redistribute it and/or - modify it under the terms of EITHER: - (1) The GNU Lesser General Public License as published by the Free - Software Foundation; either version 2.1 of the License, or (at - your option) any later version. The text of the GNU Lesser - General Public License is included with this library in the - file GIMPACT-LICENSE-LGPL.TXT. - (2) The BSD-style license that is included with this library in - the file GIMPACT-LICENSE-BSD.TXT. - (3) The zlib/libpng license that is included with this library in - the file GIMPACT-LICENSE-ZLIB.TXT. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files - GIMPACT-LICENSE-LGPL.TXT, GIMPACT-LICENSE-ZLIB.TXT and GIMPACT-LICENSE-BSD.TXT for more details. - ------------------------------------------------------------------------------ -*/ - -#include "gim_contact.h" - -#define MAX_COINCIDENT 8 - -void gim_contact_array::merge_contacts( - const gim_contact_array & contacts, bool normal_contact_average) -{ - clear(); - - if(contacts.size()==1) - { - push_back(contacts.back()); - return; - } - - gim_array keycontacts(contacts.size()); - keycontacts.resize(contacts.size(),false); - - //fill key contacts - - GUINT i; - - for (i = 0;im_depth - CONTACT_DIFF_EPSILON > scontact->m_depth)//) - { - *pcontact = *scontact; - coincident_count = 0; - } - else if(normal_contact_average) - { - if(btFabs(pcontact->m_depth - scontact->m_depth)m_normal; - coincident_count++; - } - } - } - } - else - {//add new contact - - if(normal_contact_average && coincident_count>0) - { - pcontact->interpolate_normals(coincident_normals,coincident_count); - coincident_count = 0; - } - - push_back(*scontact); - pcontact = &back(); - } - last_key = key; - } -} - -void gim_contact_array::merge_contacts_unique(const gim_contact_array & contacts) -{ - clear(); - - if(contacts.size()==1) - { - push_back(contacts.back()); - return; - } - - GIM_CONTACT average_contact = contacts.back(); - - for (GUINT i=1;i -{ -public: - gim_contact_array():gim_array(64) - { - } - - SIMD_FORCE_INLINE void push_contact(const btVector3 &point,const btVector3 & normal, - GREAL depth, GUINT feature1, GUINT feature2) - { - push_back_mem(); - GIM_CONTACT & newele = back(); - newele.m_point = point; - newele.m_normal = normal; - newele.m_depth = depth; - newele.m_feature1 = feature1; - newele.m_feature2 = feature2; - } - - SIMD_FORCE_INLINE void push_triangle_contacts( - const GIM_TRIANGLE_CONTACT_DATA & tricontact, - GUINT feature1,GUINT feature2) - { - for(GUINT i = 0;i -struct GIM_HASH_TABLE_NODE -{ - GUINT m_key; - T m_data; - GIM_HASH_TABLE_NODE() - { - } - - GIM_HASH_TABLE_NODE(const GIM_HASH_TABLE_NODE & value) - { - m_key = value.m_key; - m_data = value.m_data; - } - - GIM_HASH_TABLE_NODE(GUINT key, const T & data) - { - m_key = key; - m_data = data; - } - - bool operator <(const GIM_HASH_TABLE_NODE & other) const - { - ///inverse order, further objects are first - if(m_key < other.m_key) return true; - return false; - } - - bool operator >(const GIM_HASH_TABLE_NODE & other) const - { - ///inverse order, further objects are first - if(m_key > other.m_key) return true; - return false; - } - - bool operator ==(const GIM_HASH_TABLE_NODE & other) const - { - ///inverse order, further objects are first - if(m_key == other.m_key) return true; - return false; - } -}; - -///Macro for getting the key -class GIM_HASH_NODE_GET_KEY -{ -public: - template - inline GUINT operator()( const T& a) - { - return a.m_key; - } -}; - - - -///Macro for comparing the key and the element -class GIM_HASH_NODE_CMP_KEY_MACRO -{ -public: - template - inline int operator() ( const T& a, GUINT key) - { - return ((int)(a.m_key - key)); - } -}; - -///Macro for comparing Hash nodes -class GIM_HASH_NODE_CMP_MACRO -{ -public: - template - inline int operator() ( const T& a, const T& b ) - { - return ((int)(a.m_key - b.m_key)); - } -}; - - - - - -//! Sorting for hash table -/*! -switch automatically between quicksort and radixsort -*/ -template -void gim_sort_hash_node_array(T * array, GUINT array_count) -{ - if(array_count - -
    -
  • if node_size = 0, then this container becomes a simple sorted array allocator. reserve_size is used for reserve memory in m_nodes. -When the array size reaches the size equivalent to 'min_hash_table_size', then it becomes a hash table by calling check_for_switching_to_hashtable. -
  • If node_size != 0, then this container becomes a hash table for ever -
- -*/ -template -class gim_hash_table -{ -protected: - typedef GIM_HASH_TABLE_NODE _node_type; - - //!The nodes - //array< _node_type, SuperAllocator<_node_type> > m_nodes; - gim_array< _node_type > m_nodes; - //SuperBufferedArray< _node_type > m_nodes; - bool m_sorted; - - ///Hash table data management. The hash table has the indices to the corresponding m_nodes array - GUINT * m_hash_table;//!< - GUINT m_table_size;//!< - GUINT m_node_size;//!< - GUINT m_min_hash_table_size; - - - - //! Returns the cell index - inline GUINT _find_cell(GUINT hashkey) - { - _node_type * nodesptr = m_nodes.pointer(); - GUINT start_index = (hashkey%m_table_size)*m_node_size; - GUINT end_index = start_index + m_node_size; - - while(start_index= m_nodes.size()) return false; - if(m_nodes[index].m_key != GIM_INVALID_HASH) - { - //Search for the avaliable cell in buffer - GUINT cell_index = _find_cell(m_nodes[index].m_key); - - btAssert(cell_index!=GIM_INVALID_HASH); - btAssert(m_hash_table[cell_index]==index); - - m_hash_table[cell_index] = GIM_INVALID_HASH; - } - - return this->_erase_unsorted(index); - } - - //! erase by key in hash table - inline bool _erase_hash_table(GUINT hashkey) - { - if(hashkey == GIM_INVALID_HASH) return false; - - //Search for the avaliable cell in buffer - GUINT cell_index = _find_cell(hashkey); - if(cell_index ==GIM_INVALID_HASH) return false; - - GUINT index = m_hash_table[cell_index]; - m_hash_table[cell_index] = GIM_INVALID_HASH; - - return this->_erase_unsorted(index); - } - - - - //! insert an element in hash table - /*! - If the element exists, this won't insert the element - \return the index in the array of the existing element,or GIM_INVALID_HASH if the element has been inserted - If so, the element has been inserted at the last position of the array. - */ - inline GUINT _insert_hash_table(GUINT hashkey, const T & value) - { - if(hashkey==GIM_INVALID_HASH) - { - //Insert anyway - _insert_unsorted(hashkey,value); - return GIM_INVALID_HASH; - } - - GUINT cell_index = _assign_hash_table_cell(hashkey); - - GUINT value_key = m_hash_table[cell_index]; - - if(value_key!= GIM_INVALID_HASH) return value_key;// Not overrited - - m_hash_table[cell_index] = m_nodes.size(); - - _insert_unsorted(hashkey,value); - return GIM_INVALID_HASH; - } - - //! insert an element in hash table. - /*! - If the element exists, this replaces the element. - \return the index in the array of the existing element,or GIM_INVALID_HASH if the element has been inserted - If so, the element has been inserted at the last position of the array. - */ - inline GUINT _insert_hash_table_replace(GUINT hashkey, const T & value) - { - if(hashkey==GIM_INVALID_HASH) - { - //Insert anyway - _insert_unsorted(hashkey,value); - return GIM_INVALID_HASH; - } - - GUINT cell_index = _assign_hash_table_cell(hashkey); - - GUINT value_key = m_hash_table[cell_index]; - - if(value_key!= GIM_INVALID_HASH) - {//replaces the existing - m_nodes[value_key] = _node_type(hashkey,value); - return value_key;// index of the replaced element - } - - m_hash_table[cell_index] = m_nodes.size(); - - _insert_unsorted(hashkey,value); - return GIM_INVALID_HASH; - - } - - - ///Sorted array data management. The hash table has the indices to the corresponding m_nodes array - inline bool _erase_sorted(GUINT index) - { - if(index>=(GUINT)m_nodes.size()) return false; - m_nodes.erase_sorted(index); - if(m_nodes.size()<2) m_sorted = false; - return true; - } - - //! faster, but unsorted - inline bool _erase_unsorted(GUINT index) - { - if(index>=m_nodes.size()) return false; - - GUINT lastindex = m_nodes.size()-1; - if(indexcheck_for_switching_to_hashtable(); - } - - //! Insert an element in an ordered array - inline GUINT _insert_sorted(GUINT hashkey, const T & value) - { - if(hashkey==GIM_INVALID_HASH || size()==0) - { - m_nodes.push_back(_node_type(hashkey,value)); - return GIM_INVALID_HASH; - } - //Insert at last position - //Sort element - - - GUINT result_ind=0; - GUINT last_index = m_nodes.size()-1; - _node_type * ptr = m_nodes.pointer(); - - bool found = gim_binary_search_ex( - ptr,0,last_index,result_ind,hashkey,GIM_HASH_NODE_CMP_KEY_MACRO()); - - - //Insert before found index - if(found) - { - return result_ind; - } - else - { - _insert_in_pos(hashkey, value, result_ind); - } - return GIM_INVALID_HASH; - } - - inline GUINT _insert_sorted_replace(GUINT hashkey, const T & value) - { - if(hashkey==GIM_INVALID_HASH || size()==0) - { - m_nodes.push_back(_node_type(hashkey,value)); - return GIM_INVALID_HASH; - } - //Insert at last position - //Sort element - GUINT result_ind; - GUINT last_index = m_nodes.size()-1; - _node_type * ptr = m_nodes.pointer(); - - bool found = gim_binary_search_ex( - ptr,0,last_index,result_ind,hashkey,GIM_HASH_NODE_CMP_KEY_MACRO()); - - //Insert before found index - if(found) - { - m_nodes[result_ind] = _node_type(hashkey,value); - } - else - { - _insert_in_pos(hashkey, value, result_ind); - } - return result_ind; - } - - //! Fast insertion in m_nodes array - inline GUINT _insert_unsorted(GUINT hashkey, const T & value) - { - m_nodes.push_back(_node_type(hashkey,value)); - m_sorted = false; - return GIM_INVALID_HASH; - } - - - -public: - - /*! -
  • if node_size = 0, then this container becomes a simple sorted array allocator. reserve_size is used for reserve memory in m_nodes. - When the array size reaches the size equivalent to 'min_hash_table_size', then it becomes a hash table by calling check_for_switching_to_hashtable. -
  • If node_size != 0, then this container becomes a hash table for ever - - */ - gim_hash_table(GUINT reserve_size = GIM_DEFAULT_HASH_TABLE_SIZE, - GUINT node_size = GIM_DEFAULT_HASH_TABLE_NODE_SIZE, - GUINT min_hash_table_size = GIM_INVALID_HASH) - { - m_hash_table = NULL; - m_table_size = 0; - m_sorted = false; - m_node_size = node_size; - m_min_hash_table_size = min_hash_table_size; - - if(m_node_size!=0) - { - if(reserve_size!=0) - { - m_nodes.reserve(reserve_size); - _reserve_table_memory(reserve_size); - _invalidate_keys(); - } - else - { - m_nodes.reserve(GIM_DEFAULT_HASH_TABLE_SIZE); - _reserve_table_memory(GIM_DEFAULT_HASH_TABLE_SIZE); - _invalidate_keys(); - } - } - else if(reserve_size!=0) - { - m_nodes.reserve(reserve_size); - } - - } - - ~gim_hash_table() - { - _destroy(); - } - - inline bool is_hash_table() - { - if(m_hash_table) return true; - return false; - } - - inline bool is_sorted() - { - if(size()<2) return true; - return m_sorted; - } - - bool sort() - { - if(is_sorted()) return true; - if(m_nodes.size()<2) return false; - - - _node_type * ptr = m_nodes.pointer(); - GUINT siz = m_nodes.size(); - gim_sort_hash_node_array(ptr,siz); - m_sorted=true; - - - - if(m_hash_table) - { - _rehash(); - } - return true; - } - - bool switch_to_hashtable() - { - if(m_hash_table) return false; - if(m_node_size==0) m_node_size = GIM_DEFAULT_HASH_TABLE_NODE_SIZE; - if(m_nodes.size()m_hash_table) return true; - - if(!(m_nodes.size()< m_min_hash_table_size)) - { - if(m_node_size == 0) - { - m_node_size = GIM_DEFAULT_HASH_TABLE_NODE_SIZE; - } - - _resize_table(m_nodes.size()+1); - return true; - } - return false; - } - - inline void set_sorted(bool value) - { - m_sorted = value; - } - - //! Retrieves the amount of keys. - inline GUINT size() const - { - return m_nodes.size(); - } - - //! Retrieves the hash key. - inline GUINT get_key(GUINT index) const - { - return m_nodes[index].m_key; - } - - //! Retrieves the value by index - /*! - */ - inline T * get_value_by_index(GUINT index) - { - return &m_nodes[index].m_data; - } - - inline const T& operator[](GUINT index) const - { - return m_nodes[index].m_data; - } - - inline T& operator[](GUINT index) - { - return m_nodes[index].m_data; - } - - //! Finds the index of the element with the key - /*! - \return the index in the array of the existing element,or GIM_INVALID_HASH if the element has been inserted - If so, the element has been inserted at the last position of the array. - */ - inline GUINT find(GUINT hashkey) - { - if(m_hash_table) - { - GUINT cell_index = _find_cell(hashkey); - if(cell_index==GIM_INVALID_HASH) return GIM_INVALID_HASH; - return m_hash_table[cell_index]; - } - GUINT last_index = m_nodes.size(); - if(last_index<2) - { - if(last_index==0) return GIM_INVALID_HASH; - if(m_nodes[0].m_key == hashkey) return 0; - return GIM_INVALID_HASH; - } - else if(m_sorted) - { - //Binary search - GUINT result_ind = 0; - last_index--; - _node_type * ptr = m_nodes.pointer(); - - bool found = gim_binary_search_ex(ptr,0,last_index,result_ind,hashkey,GIM_HASH_NODE_CMP_KEY_MACRO()); - - - if(found) return result_ind; - } - return GIM_INVALID_HASH; - } - - //! Retrieves the value associated with the index - /*! - \return the found element, or null - */ - inline T * get_value(GUINT hashkey) - { - GUINT index = find(hashkey); - if(index == GIM_INVALID_HASH) return NULL; - return &m_nodes[index].m_data; - } - - - /*! - */ - inline bool erase_by_index(GUINT index) - { - if(index > m_nodes.size()) return false; - - if(m_hash_table == NULL) - { - if(is_sorted()) - { - return this->_erase_sorted(index); - } - else - { - return this->_erase_unsorted(index); - } - } - else - { - return this->_erase_by_index_hash_table(index); - } - return false; - } - - - - inline bool erase_by_index_unsorted(GUINT index) - { - if(index > m_nodes.size()) return false; - - if(m_hash_table == NULL) - { - return this->_erase_unsorted(index); - } - else - { - return this->_erase_by_index_hash_table(index); - } - return false; - } - - - - /*! - - */ - inline bool erase_by_key(GUINT hashkey) - { - if(size()==0) return false; - - if(m_hash_table) - { - return this->_erase_hash_table(hashkey); - } - //Binary search - - if(is_sorted()==false) return false; - - GUINT result_ind = find(hashkey); - if(result_ind!= GIM_INVALID_HASH) - { - return this->_erase_sorted(result_ind); - } - return false; - } - - void clear() - { - m_nodes.clear(); - - if(m_hash_table==NULL) return; - GUINT datasize = m_table_size*m_node_size; - //Initialize the hashkeys. - GUINT i; - for(i=0;i_insert_hash_table(hashkey,element); - } - if(this->is_sorted()) - { - return this->_insert_sorted(hashkey,element); - } - return this->_insert_unsorted(hashkey,element); - } - - //! Insert an element into the hash, and could overrite an existing object with the same hash. - /*! - \return If GIM_INVALID_HASH, the object has been inserted succesfully. Else it returns the position - of the replaced element. - */ - inline GUINT insert_override(GUINT hashkey, const T & element) - { - if(m_hash_table) - { - return this->_insert_hash_table_replace(hashkey,element); - } - if(this->is_sorted()) - { - return this->_insert_sorted_replace(hashkey,element); - } - this->_insert_unsorted(hashkey,element); - return m_nodes.size(); - } - - - - //! Insert an element into the hash,But if this container is a sorted array, this inserts it unsorted - /*! - */ - inline GUINT insert_unsorted(GUINT hashkey,const T & element) - { - if(m_hash_table) - { - return this->_insert_hash_table(hashkey,element); - } - return this->_insert_unsorted(hashkey,element); - } - - -}; - - - -#endif // GIM_CONTAINERS_H_INCLUDED diff --git a/bullet/src/BulletCollision/Gimpact/gim_linear_math.h b/bullet/src/BulletCollision/Gimpact/gim_linear_math.h deleted file mode 100644 index 96ba93d19..000000000 --- a/bullet/src/BulletCollision/Gimpact/gim_linear_math.h +++ /dev/null @@ -1,1573 +0,0 @@ -#ifndef GIM_LINEAR_H_INCLUDED -#define GIM_LINEAR_H_INCLUDED - -/*! \file gim_linear_math.h -*\author Francisco Len Njera -Type Independant Vector and matrix operations. -*/ -/* ------------------------------------------------------------------------------ -This source file is part of GIMPACT Library. - -For the latest info, see http://gimpact.sourceforge.net/ - -Copyright (c) 2006 Francisco Leon Najera. C.C. 80087371. -email: projectileman@yahoo.com - - This library is free software; you can redistribute it and/or - modify it under the terms of EITHER: - (1) The GNU Lesser General Public License as published by the Free - Software Foundation; either version 2.1 of the License, or (at - your option) any later version. The text of the GNU Lesser - General Public License is included with this library in the - file GIMPACT-LICENSE-LGPL.TXT. - (2) The BSD-style license that is included with this library in - the file GIMPACT-LICENSE-BSD.TXT. - (3) The zlib/libpng license that is included with this library in - the file GIMPACT-LICENSE-ZLIB.TXT. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files - GIMPACT-LICENSE-LGPL.TXT, GIMPACT-LICENSE-ZLIB.TXT and GIMPACT-LICENSE-BSD.TXT for more details. - ------------------------------------------------------------------------------ -*/ - - -#include "gim_math.h" -#include "gim_geom_types.h" - - - - -//! Zero out a 2D vector -#define VEC_ZERO_2(a) \ -{ \ - (a)[0] = (a)[1] = 0.0f; \ -}\ - - -//! Zero out a 3D vector -#define VEC_ZERO(a) \ -{ \ - (a)[0] = (a)[1] = (a)[2] = 0.0f; \ -}\ - - -/// Zero out a 4D vector -#define VEC_ZERO_4(a) \ -{ \ - (a)[0] = (a)[1] = (a)[2] = (a)[3] = 0.0f; \ -}\ - - -/// Vector copy -#define VEC_COPY_2(b,a) \ -{ \ - (b)[0] = (a)[0]; \ - (b)[1] = (a)[1]; \ -}\ - - -/// Copy 3D vector -#define VEC_COPY(b,a) \ -{ \ - (b)[0] = (a)[0]; \ - (b)[1] = (a)[1]; \ - (b)[2] = (a)[2]; \ -}\ - - -/// Copy 4D vector -#define VEC_COPY_4(b,a) \ -{ \ - (b)[0] = (a)[0]; \ - (b)[1] = (a)[1]; \ - (b)[2] = (a)[2]; \ - (b)[3] = (a)[3]; \ -}\ - -/// VECTOR SWAP -#define VEC_SWAP(b,a) \ -{ \ - GIM_SWAP_NUMBERS((b)[0],(a)[0]);\ - GIM_SWAP_NUMBERS((b)[1],(a)[1]);\ - GIM_SWAP_NUMBERS((b)[2],(a)[2]);\ -}\ - -/// Vector difference -#define VEC_DIFF_2(v21,v2,v1) \ -{ \ - (v21)[0] = (v2)[0] - (v1)[0]; \ - (v21)[1] = (v2)[1] - (v1)[1]; \ -}\ - - -/// Vector difference -#define VEC_DIFF(v21,v2,v1) \ -{ \ - (v21)[0] = (v2)[0] - (v1)[0]; \ - (v21)[1] = (v2)[1] - (v1)[1]; \ - (v21)[2] = (v2)[2] - (v1)[2]; \ -}\ - - -/// Vector difference -#define VEC_DIFF_4(v21,v2,v1) \ -{ \ - (v21)[0] = (v2)[0] - (v1)[0]; \ - (v21)[1] = (v2)[1] - (v1)[1]; \ - (v21)[2] = (v2)[2] - (v1)[2]; \ - (v21)[3] = (v2)[3] - (v1)[3]; \ -}\ - - -/// Vector sum -#define VEC_SUM_2(v21,v2,v1) \ -{ \ - (v21)[0] = (v2)[0] + (v1)[0]; \ - (v21)[1] = (v2)[1] + (v1)[1]; \ -}\ - - -/// Vector sum -#define VEC_SUM(v21,v2,v1) \ -{ \ - (v21)[0] = (v2)[0] + (v1)[0]; \ - (v21)[1] = (v2)[1] + (v1)[1]; \ - (v21)[2] = (v2)[2] + (v1)[2]; \ -}\ - - -/// Vector sum -#define VEC_SUM_4(v21,v2,v1) \ -{ \ - (v21)[0] = (v2)[0] + (v1)[0]; \ - (v21)[1] = (v2)[1] + (v1)[1]; \ - (v21)[2] = (v2)[2] + (v1)[2]; \ - (v21)[3] = (v2)[3] + (v1)[3]; \ -}\ - - -/// scalar times vector -#define VEC_SCALE_2(c,a,b) \ -{ \ - (c)[0] = (a)*(b)[0]; \ - (c)[1] = (a)*(b)[1]; \ -}\ - - -/// scalar times vector -#define VEC_SCALE(c,a,b) \ -{ \ - (c)[0] = (a)*(b)[0]; \ - (c)[1] = (a)*(b)[1]; \ - (c)[2] = (a)*(b)[2]; \ -}\ - - -/// scalar times vector -#define VEC_SCALE_4(c,a,b) \ -{ \ - (c)[0] = (a)*(b)[0]; \ - (c)[1] = (a)*(b)[1]; \ - (c)[2] = (a)*(b)[2]; \ - (c)[3] = (a)*(b)[3]; \ -}\ - - -/// accumulate scaled vector -#define VEC_ACCUM_2(c,a,b) \ -{ \ - (c)[0] += (a)*(b)[0]; \ - (c)[1] += (a)*(b)[1]; \ -}\ - - -/// accumulate scaled vector -#define VEC_ACCUM(c,a,b) \ -{ \ - (c)[0] += (a)*(b)[0]; \ - (c)[1] += (a)*(b)[1]; \ - (c)[2] += (a)*(b)[2]; \ -}\ - - -/// accumulate scaled vector -#define VEC_ACCUM_4(c,a,b) \ -{ \ - (c)[0] += (a)*(b)[0]; \ - (c)[1] += (a)*(b)[1]; \ - (c)[2] += (a)*(b)[2]; \ - (c)[3] += (a)*(b)[3]; \ -}\ - - -/// Vector dot product -#define VEC_DOT_2(a,b) ((a)[0]*(b)[0] + (a)[1]*(b)[1]) - - -/// Vector dot product -#define VEC_DOT(a,b) ((a)[0]*(b)[0] + (a)[1]*(b)[1] + (a)[2]*(b)[2]) - -/// Vector dot product -#define VEC_DOT_4(a,b) ((a)[0]*(b)[0] + (a)[1]*(b)[1] + (a)[2]*(b)[2] + (a)[3]*(b)[3]) - -/// vector impact parameter (squared) -#define VEC_IMPACT_SQ(bsq,direction,position) {\ - GREAL _llel_ = VEC_DOT(direction, position);\ - bsq = VEC_DOT(position, position) - _llel_*_llel_;\ -}\ - - -/// vector impact parameter -#define VEC_IMPACT(bsq,direction,position) {\ - VEC_IMPACT_SQ(bsq,direction,position); \ - GIM_SQRT(bsq,bsq); \ -}\ - -/// Vector length -#define VEC_LENGTH_2(a,l)\ -{\ - GREAL _pp = VEC_DOT_2(a,a);\ - GIM_SQRT(_pp,l);\ -}\ - - -/// Vector length -#define VEC_LENGTH(a,l)\ -{\ - GREAL _pp = VEC_DOT(a,a);\ - GIM_SQRT(_pp,l);\ -}\ - - -/// Vector length -#define VEC_LENGTH_4(a,l)\ -{\ - GREAL _pp = VEC_DOT_4(a,a);\ - GIM_SQRT(_pp,l);\ -}\ - -/// Vector inv length -#define VEC_INV_LENGTH_2(a,l)\ -{\ - GREAL _pp = VEC_DOT_2(a,a);\ - GIM_INV_SQRT(_pp,l);\ -}\ - - -/// Vector inv length -#define VEC_INV_LENGTH(a,l)\ -{\ - GREAL _pp = VEC_DOT(a,a);\ - GIM_INV_SQRT(_pp,l);\ -}\ - - -/// Vector inv length -#define VEC_INV_LENGTH_4(a,l)\ -{\ - GREAL _pp = VEC_DOT_4(a,a);\ - GIM_INV_SQRT(_pp,l);\ -}\ - - - -/// distance between two points -#define VEC_DISTANCE(_len,_va,_vb) {\ - vec3f _tmp_; \ - VEC_DIFF(_tmp_, _vb, _va); \ - VEC_LENGTH(_tmp_,_len); \ -}\ - - -/// Vector length -#define VEC_CONJUGATE_LENGTH(a,l)\ -{\ - GREAL _pp = 1.0 - a[0]*a[0] - a[1]*a[1] - a[2]*a[2];\ - GIM_SQRT(_pp,l);\ -}\ - - -/// Vector length -#define VEC_NORMALIZE(a) { \ - GREAL len;\ - VEC_INV_LENGTH(a,len); \ - if(lenA[1]?(A[0]>A[2]?0:2):(A[1]>A[2]?1:2);\ -}\ - -//! Finds the 2 smallest cartesian coordinates from a vector -#define VEC_MINOR_AXES(vec, i0, i1)\ -{\ - VEC_MAYOR_COORD(vec,i0);\ - i0 = (i0+1)%3;\ - i1 = (i0+1)%3;\ -}\ - - - - -#define VEC_EQUAL(v1,v2) (v1[0]==v2[0]&&v1[1]==v2[1]&&v1[2]==v2[2]) - -#define VEC_NEAR_EQUAL(v1,v2) (GIM_NEAR_EQUAL(v1[0],v2[0])&&GIM_NEAR_EQUAL(v1[1],v2[1])&&GIM_NEAR_EQUAL(v1[2],v2[2])) - - -/// Vector cross -#define X_AXIS_CROSS_VEC(dst,src)\ -{ \ - dst[0] = 0.0f; \ - dst[1] = -src[2]; \ - dst[2] = src[1]; \ -}\ - -#define Y_AXIS_CROSS_VEC(dst,src)\ -{ \ - dst[0] = src[2]; \ - dst[1] = 0.0f; \ - dst[2] = -src[0]; \ -}\ - -#define Z_AXIS_CROSS_VEC(dst,src)\ -{ \ - dst[0] = -src[1]; \ - dst[1] = src[0]; \ - dst[2] = 0.0f; \ -}\ - - - - - - -/// initialize matrix -#define IDENTIFY_MATRIX_3X3(m) \ -{ \ - m[0][0] = 1.0; \ - m[0][1] = 0.0; \ - m[0][2] = 0.0; \ - \ - m[1][0] = 0.0; \ - m[1][1] = 1.0; \ - m[1][2] = 0.0; \ - \ - m[2][0] = 0.0; \ - m[2][1] = 0.0; \ - m[2][2] = 1.0; \ -}\ - -/*! initialize matrix */ -#define IDENTIFY_MATRIX_4X4(m) \ -{ \ - m[0][0] = 1.0; \ - m[0][1] = 0.0; \ - m[0][2] = 0.0; \ - m[0][3] = 0.0; \ - \ - m[1][0] = 0.0; \ - m[1][1] = 1.0; \ - m[1][2] = 0.0; \ - m[1][3] = 0.0; \ - \ - m[2][0] = 0.0; \ - m[2][1] = 0.0; \ - m[2][2] = 1.0; \ - m[2][3] = 0.0; \ - \ - m[3][0] = 0.0; \ - m[3][1] = 0.0; \ - m[3][2] = 0.0; \ - m[3][3] = 1.0; \ -}\ - -/*! initialize matrix */ -#define ZERO_MATRIX_4X4(m) \ -{ \ - m[0][0] = 0.0; \ - m[0][1] = 0.0; \ - m[0][2] = 0.0; \ - m[0][3] = 0.0; \ - \ - m[1][0] = 0.0; \ - m[1][1] = 0.0; \ - m[1][2] = 0.0; \ - m[1][3] = 0.0; \ - \ - m[2][0] = 0.0; \ - m[2][1] = 0.0; \ - m[2][2] = 0.0; \ - m[2][3] = 0.0; \ - \ - m[3][0] = 0.0; \ - m[3][1] = 0.0; \ - m[3][2] = 0.0; \ - m[3][3] = 0.0; \ -}\ - -/*! matrix rotation X */ -#define ROTX_CS(m,cosine,sine) \ -{ \ - /* rotation about the x-axis */ \ - \ - m[0][0] = 1.0; \ - m[0][1] = 0.0; \ - m[0][2] = 0.0; \ - m[0][3] = 0.0; \ - \ - m[1][0] = 0.0; \ - m[1][1] = (cosine); \ - m[1][2] = (sine); \ - m[1][3] = 0.0; \ - \ - m[2][0] = 0.0; \ - m[2][1] = -(sine); \ - m[2][2] = (cosine); \ - m[2][3] = 0.0; \ - \ - m[3][0] = 0.0; \ - m[3][1] = 0.0; \ - m[3][2] = 0.0; \ - m[3][3] = 1.0; \ -}\ - -/*! matrix rotation Y */ -#define ROTY_CS(m,cosine,sine) \ -{ \ - /* rotation about the y-axis */ \ - \ - m[0][0] = (cosine); \ - m[0][1] = 0.0; \ - m[0][2] = -(sine); \ - m[0][3] = 0.0; \ - \ - m[1][0] = 0.0; \ - m[1][1] = 1.0; \ - m[1][2] = 0.0; \ - m[1][3] = 0.0; \ - \ - m[2][0] = (sine); \ - m[2][1] = 0.0; \ - m[2][2] = (cosine); \ - m[2][3] = 0.0; \ - \ - m[3][0] = 0.0; \ - m[3][1] = 0.0; \ - m[3][2] = 0.0; \ - m[3][3] = 1.0; \ -}\ - -/*! matrix rotation Z */ -#define ROTZ_CS(m,cosine,sine) \ -{ \ - /* rotation about the z-axis */ \ - \ - m[0][0] = (cosine); \ - m[0][1] = (sine); \ - m[0][2] = 0.0; \ - m[0][3] = 0.0; \ - \ - m[1][0] = -(sine); \ - m[1][1] = (cosine); \ - m[1][2] = 0.0; \ - m[1][3] = 0.0; \ - \ - m[2][0] = 0.0; \ - m[2][1] = 0.0; \ - m[2][2] = 1.0; \ - m[2][3] = 0.0; \ - \ - m[3][0] = 0.0; \ - m[3][1] = 0.0; \ - m[3][2] = 0.0; \ - m[3][3] = 1.0; \ -}\ - -/*! matrix copy */ -#define COPY_MATRIX_2X2(b,a) \ -{ \ - b[0][0] = a[0][0]; \ - b[0][1] = a[0][1]; \ - \ - b[1][0] = a[1][0]; \ - b[1][1] = a[1][1]; \ - \ -}\ - - -/*! matrix copy */ -#define COPY_MATRIX_2X3(b,a) \ -{ \ - b[0][0] = a[0][0]; \ - b[0][1] = a[0][1]; \ - b[0][2] = a[0][2]; \ - \ - b[1][0] = a[1][0]; \ - b[1][1] = a[1][1]; \ - b[1][2] = a[1][2]; \ -}\ - - -/*! matrix copy */ -#define COPY_MATRIX_3X3(b,a) \ -{ \ - b[0][0] = a[0][0]; \ - b[0][1] = a[0][1]; \ - b[0][2] = a[0][2]; \ - \ - b[1][0] = a[1][0]; \ - b[1][1] = a[1][1]; \ - b[1][2] = a[1][2]; \ - \ - b[2][0] = a[2][0]; \ - b[2][1] = a[2][1]; \ - b[2][2] = a[2][2]; \ -}\ - - -/*! matrix copy */ -#define COPY_MATRIX_4X4(b,a) \ -{ \ - b[0][0] = a[0][0]; \ - b[0][1] = a[0][1]; \ - b[0][2] = a[0][2]; \ - b[0][3] = a[0][3]; \ - \ - b[1][0] = a[1][0]; \ - b[1][1] = a[1][1]; \ - b[1][2] = a[1][2]; \ - b[1][3] = a[1][3]; \ - \ - b[2][0] = a[2][0]; \ - b[2][1] = a[2][1]; \ - b[2][2] = a[2][2]; \ - b[2][3] = a[2][3]; \ - \ - b[3][0] = a[3][0]; \ - b[3][1] = a[3][1]; \ - b[3][2] = a[3][2]; \ - b[3][3] = a[3][3]; \ -}\ - - -/*! matrix transpose */ -#define TRANSPOSE_MATRIX_2X2(b,a) \ -{ \ - b[0][0] = a[0][0]; \ - b[0][1] = a[1][0]; \ - \ - b[1][0] = a[0][1]; \ - b[1][1] = a[1][1]; \ -}\ - - -/*! matrix transpose */ -#define TRANSPOSE_MATRIX_3X3(b,a) \ -{ \ - b[0][0] = a[0][0]; \ - b[0][1] = a[1][0]; \ - b[0][2] = a[2][0]; \ - \ - b[1][0] = a[0][1]; \ - b[1][1] = a[1][1]; \ - b[1][2] = a[2][1]; \ - \ - b[2][0] = a[0][2]; \ - b[2][1] = a[1][2]; \ - b[2][2] = a[2][2]; \ -}\ - - -/*! matrix transpose */ -#define TRANSPOSE_MATRIX_4X4(b,a) \ -{ \ - b[0][0] = a[0][0]; \ - b[0][1] = a[1][0]; \ - b[0][2] = a[2][0]; \ - b[0][3] = a[3][0]; \ - \ - b[1][0] = a[0][1]; \ - b[1][1] = a[1][1]; \ - b[1][2] = a[2][1]; \ - b[1][3] = a[3][1]; \ - \ - b[2][0] = a[0][2]; \ - b[2][1] = a[1][2]; \ - b[2][2] = a[2][2]; \ - b[2][3] = a[3][2]; \ - \ - b[3][0] = a[0][3]; \ - b[3][1] = a[1][3]; \ - b[3][2] = a[2][3]; \ - b[3][3] = a[3][3]; \ -}\ - - -/*! multiply matrix by scalar */ -#define SCALE_MATRIX_2X2(b,s,a) \ -{ \ - b[0][0] = (s) * a[0][0]; \ - b[0][1] = (s) * a[0][1]; \ - \ - b[1][0] = (s) * a[1][0]; \ - b[1][1] = (s) * a[1][1]; \ -}\ - - -/*! multiply matrix by scalar */ -#define SCALE_MATRIX_3X3(b,s,a) \ -{ \ - b[0][0] = (s) * a[0][0]; \ - b[0][1] = (s) * a[0][1]; \ - b[0][2] = (s) * a[0][2]; \ - \ - b[1][0] = (s) * a[1][0]; \ - b[1][1] = (s) * a[1][1]; \ - b[1][2] = (s) * a[1][2]; \ - \ - b[2][0] = (s) * a[2][0]; \ - b[2][1] = (s) * a[2][1]; \ - b[2][2] = (s) * a[2][2]; \ -}\ - - -/*! multiply matrix by scalar */ -#define SCALE_MATRIX_4X4(b,s,a) \ -{ \ - b[0][0] = (s) * a[0][0]; \ - b[0][1] = (s) * a[0][1]; \ - b[0][2] = (s) * a[0][2]; \ - b[0][3] = (s) * a[0][3]; \ - \ - b[1][0] = (s) * a[1][0]; \ - b[1][1] = (s) * a[1][1]; \ - b[1][2] = (s) * a[1][2]; \ - b[1][3] = (s) * a[1][3]; \ - \ - b[2][0] = (s) * a[2][0]; \ - b[2][1] = (s) * a[2][1]; \ - b[2][2] = (s) * a[2][2]; \ - b[2][3] = (s) * a[2][3]; \ - \ - b[3][0] = s * a[3][0]; \ - b[3][1] = s * a[3][1]; \ - b[3][2] = s * a[3][2]; \ - b[3][3] = s * a[3][3]; \ -}\ - - -/*! multiply matrix by scalar */ -#define SCALE_VEC_MATRIX_2X2(b,svec,a) \ -{ \ - b[0][0] = svec[0] * a[0][0]; \ - b[1][0] = svec[0] * a[1][0]; \ - \ - b[0][1] = svec[1] * a[0][1]; \ - b[1][1] = svec[1] * a[1][1]; \ -}\ - - -/*! multiply matrix by scalar. Each columns is scaled by each scalar vector component */ -#define SCALE_VEC_MATRIX_3X3(b,svec,a) \ -{ \ - b[0][0] = svec[0] * a[0][0]; \ - b[1][0] = svec[0] * a[1][0]; \ - b[2][0] = svec[0] * a[2][0]; \ - \ - b[0][1] = svec[1] * a[0][1]; \ - b[1][1] = svec[1] * a[1][1]; \ - b[2][1] = svec[1] * a[2][1]; \ - \ - b[0][2] = svec[2] * a[0][2]; \ - b[1][2] = svec[2] * a[1][2]; \ - b[2][2] = svec[2] * a[2][2]; \ -}\ - - -/*! multiply matrix by scalar */ -#define SCALE_VEC_MATRIX_4X4(b,svec,a) \ -{ \ - b[0][0] = svec[0] * a[0][0]; \ - b[1][0] = svec[0] * a[1][0]; \ - b[2][0] = svec[0] * a[2][0]; \ - b[3][0] = svec[0] * a[3][0]; \ - \ - b[0][1] = svec[1] * a[0][1]; \ - b[1][1] = svec[1] * a[1][1]; \ - b[2][1] = svec[1] * a[2][1]; \ - b[3][1] = svec[1] * a[3][1]; \ - \ - b[0][2] = svec[2] * a[0][2]; \ - b[1][2] = svec[2] * a[1][2]; \ - b[2][2] = svec[2] * a[2][2]; \ - b[3][2] = svec[2] * a[3][2]; \ - \ - b[0][3] = svec[3] * a[0][3]; \ - b[1][3] = svec[3] * a[1][3]; \ - b[2][3] = svec[3] * a[2][3]; \ - b[3][3] = svec[3] * a[3][3]; \ -}\ - - -/*! multiply matrix by scalar */ -#define ACCUM_SCALE_MATRIX_2X2(b,s,a) \ -{ \ - b[0][0] += (s) * a[0][0]; \ - b[0][1] += (s) * a[0][1]; \ - \ - b[1][0] += (s) * a[1][0]; \ - b[1][1] += (s) * a[1][1]; \ -}\ - - -/*! multiply matrix by scalar */ -#define ACCUM_SCALE_MATRIX_3X3(b,s,a) \ -{ \ - b[0][0] += (s) * a[0][0]; \ - b[0][1] += (s) * a[0][1]; \ - b[0][2] += (s) * a[0][2]; \ - \ - b[1][0] += (s) * a[1][0]; \ - b[1][1] += (s) * a[1][1]; \ - b[1][2] += (s) * a[1][2]; \ - \ - b[2][0] += (s) * a[2][0]; \ - b[2][1] += (s) * a[2][1]; \ - b[2][2] += (s) * a[2][2]; \ -}\ - - -/*! multiply matrix by scalar */ -#define ACCUM_SCALE_MATRIX_4X4(b,s,a) \ -{ \ - b[0][0] += (s) * a[0][0]; \ - b[0][1] += (s) * a[0][1]; \ - b[0][2] += (s) * a[0][2]; \ - b[0][3] += (s) * a[0][3]; \ - \ - b[1][0] += (s) * a[1][0]; \ - b[1][1] += (s) * a[1][1]; \ - b[1][2] += (s) * a[1][2]; \ - b[1][3] += (s) * a[1][3]; \ - \ - b[2][0] += (s) * a[2][0]; \ - b[2][1] += (s) * a[2][1]; \ - b[2][2] += (s) * a[2][2]; \ - b[2][3] += (s) * a[2][3]; \ - \ - b[3][0] += (s) * a[3][0]; \ - b[3][1] += (s) * a[3][1]; \ - b[3][2] += (s) * a[3][2]; \ - b[3][3] += (s) * a[3][3]; \ -}\ - -/*! matrix product */ -/*! c[x][y] = a[x][0]*b[0][y]+a[x][1]*b[1][y]+a[x][2]*b[2][y]+a[x][3]*b[3][y];*/ -#define MATRIX_PRODUCT_2X2(c,a,b) \ -{ \ - c[0][0] = a[0][0]*b[0][0]+a[0][1]*b[1][0]; \ - c[0][1] = a[0][0]*b[0][1]+a[0][1]*b[1][1]; \ - \ - c[1][0] = a[1][0]*b[0][0]+a[1][1]*b[1][0]; \ - c[1][1] = a[1][0]*b[0][1]+a[1][1]*b[1][1]; \ - \ -}\ - -/*! matrix product */ -/*! c[x][y] = a[x][0]*b[0][y]+a[x][1]*b[1][y]+a[x][2]*b[2][y]+a[x][3]*b[3][y];*/ -#define MATRIX_PRODUCT_3X3(c,a,b) \ -{ \ - c[0][0] = a[0][0]*b[0][0]+a[0][1]*b[1][0]+a[0][2]*b[2][0]; \ - c[0][1] = a[0][0]*b[0][1]+a[0][1]*b[1][1]+a[0][2]*b[2][1]; \ - c[0][2] = a[0][0]*b[0][2]+a[0][1]*b[1][2]+a[0][2]*b[2][2]; \ - \ - c[1][0] = a[1][0]*b[0][0]+a[1][1]*b[1][0]+a[1][2]*b[2][0]; \ - c[1][1] = a[1][0]*b[0][1]+a[1][1]*b[1][1]+a[1][2]*b[2][1]; \ - c[1][2] = a[1][0]*b[0][2]+a[1][1]*b[1][2]+a[1][2]*b[2][2]; \ - \ - c[2][0] = a[2][0]*b[0][0]+a[2][1]*b[1][0]+a[2][2]*b[2][0]; \ - c[2][1] = a[2][0]*b[0][1]+a[2][1]*b[1][1]+a[2][2]*b[2][1]; \ - c[2][2] = a[2][0]*b[0][2]+a[2][1]*b[1][2]+a[2][2]*b[2][2]; \ -}\ - - -/*! matrix product */ -/*! c[x][y] = a[x][0]*b[0][y]+a[x][1]*b[1][y]+a[x][2]*b[2][y]+a[x][3]*b[3][y];*/ -#define MATRIX_PRODUCT_4X4(c,a,b) \ -{ \ - c[0][0] = a[0][0]*b[0][0]+a[0][1]*b[1][0]+a[0][2]*b[2][0]+a[0][3]*b[3][0];\ - c[0][1] = a[0][0]*b[0][1]+a[0][1]*b[1][1]+a[0][2]*b[2][1]+a[0][3]*b[3][1];\ - c[0][2] = a[0][0]*b[0][2]+a[0][1]*b[1][2]+a[0][2]*b[2][2]+a[0][3]*b[3][2];\ - c[0][3] = a[0][0]*b[0][3]+a[0][1]*b[1][3]+a[0][2]*b[2][3]+a[0][3]*b[3][3];\ - \ - c[1][0] = a[1][0]*b[0][0]+a[1][1]*b[1][0]+a[1][2]*b[2][0]+a[1][3]*b[3][0];\ - c[1][1] = a[1][0]*b[0][1]+a[1][1]*b[1][1]+a[1][2]*b[2][1]+a[1][3]*b[3][1];\ - c[1][2] = a[1][0]*b[0][2]+a[1][1]*b[1][2]+a[1][2]*b[2][2]+a[1][3]*b[3][2];\ - c[1][3] = a[1][0]*b[0][3]+a[1][1]*b[1][3]+a[1][2]*b[2][3]+a[1][3]*b[3][3];\ - \ - c[2][0] = a[2][0]*b[0][0]+a[2][1]*b[1][0]+a[2][2]*b[2][0]+a[2][3]*b[3][0];\ - c[2][1] = a[2][0]*b[0][1]+a[2][1]*b[1][1]+a[2][2]*b[2][1]+a[2][3]*b[3][1];\ - c[2][2] = a[2][0]*b[0][2]+a[2][1]*b[1][2]+a[2][2]*b[2][2]+a[2][3]*b[3][2];\ - c[2][3] = a[2][0]*b[0][3]+a[2][1]*b[1][3]+a[2][2]*b[2][3]+a[2][3]*b[3][3];\ - \ - c[3][0] = a[3][0]*b[0][0]+a[3][1]*b[1][0]+a[3][2]*b[2][0]+a[3][3]*b[3][0];\ - c[3][1] = a[3][0]*b[0][1]+a[3][1]*b[1][1]+a[3][2]*b[2][1]+a[3][3]*b[3][1];\ - c[3][2] = a[3][0]*b[0][2]+a[3][1]*b[1][2]+a[3][2]*b[2][2]+a[3][3]*b[3][2];\ - c[3][3] = a[3][0]*b[0][3]+a[3][1]*b[1][3]+a[3][2]*b[2][3]+a[3][3]*b[3][3];\ -}\ - - -/*! matrix times vector */ -#define MAT_DOT_VEC_2X2(p,m,v) \ -{ \ - p[0] = m[0][0]*v[0] + m[0][1]*v[1]; \ - p[1] = m[1][0]*v[0] + m[1][1]*v[1]; \ -}\ - - -/*! matrix times vector */ -#define MAT_DOT_VEC_3X3(p,m,v) \ -{ \ - p[0] = m[0][0]*v[0] + m[0][1]*v[1] + m[0][2]*v[2]; \ - p[1] = m[1][0]*v[0] + m[1][1]*v[1] + m[1][2]*v[2]; \ - p[2] = m[2][0]*v[0] + m[2][1]*v[1] + m[2][2]*v[2]; \ -}\ - - -/*! matrix times vector -v is a vec4f -*/ -#define MAT_DOT_VEC_4X4(p,m,v) \ -{ \ - p[0] = m[0][0]*v[0] + m[0][1]*v[1] + m[0][2]*v[2] + m[0][3]*v[3]; \ - p[1] = m[1][0]*v[0] + m[1][1]*v[1] + m[1][2]*v[2] + m[1][3]*v[3]; \ - p[2] = m[2][0]*v[0] + m[2][1]*v[1] + m[2][2]*v[2] + m[2][3]*v[3]; \ - p[3] = m[3][0]*v[0] + m[3][1]*v[1] + m[3][2]*v[2] + m[3][3]*v[3]; \ -}\ - -/*! matrix times vector -v is a vec3f -and m is a mat4f
    -Last column is added as the position -*/ -#define MAT_DOT_VEC_3X4(p,m,v) \ -{ \ - p[0] = m[0][0]*v[0] + m[0][1]*v[1] + m[0][2]*v[2] + m[0][3]; \ - p[1] = m[1][0]*v[0] + m[1][1]*v[1] + m[1][2]*v[2] + m[1][3]; \ - p[2] = m[2][0]*v[0] + m[2][1]*v[1] + m[2][2]*v[2] + m[2][3]; \ -}\ - - -/*! vector transpose times matrix */ -/*! p[j] = v[0]*m[0][j] + v[1]*m[1][j] + v[2]*m[2][j]; */ -#define VEC_DOT_MAT_3X3(p,v,m) \ -{ \ - p[0] = v[0]*m[0][0] + v[1]*m[1][0] + v[2]*m[2][0]; \ - p[1] = v[0]*m[0][1] + v[1]*m[1][1] + v[2]*m[2][1]; \ - p[2] = v[0]*m[0][2] + v[1]*m[1][2] + v[2]*m[2][2]; \ -}\ - - -/*! affine matrix times vector */ -/** The matrix is assumed to be an affine matrix, with last two - * entries representing a translation */ -#define MAT_DOT_VEC_2X3(p,m,v) \ -{ \ - p[0] = m[0][0]*v[0] + m[0][1]*v[1] + m[0][2]; \ - p[1] = m[1][0]*v[0] + m[1][1]*v[1] + m[1][2]; \ -}\ - -//! Transform a plane -#define MAT_TRANSFORM_PLANE_4X4(pout,m,plane)\ -{ \ - pout[0] = m[0][0]*plane[0] + m[0][1]*plane[1] + m[0][2]*plane[2];\ - pout[1] = m[1][0]*plane[0] + m[1][1]*plane[1] + m[1][2]*plane[2];\ - pout[2] = m[2][0]*plane[0] + m[2][1]*plane[1] + m[2][2]*plane[2];\ - pout[3] = m[0][3]*pout[0] + m[1][3]*pout[1] + m[2][3]*pout[2] + plane[3];\ -}\ - - - -/** inverse transpose of matrix times vector - * - * This macro computes inverse transpose of matrix m, - * and multiplies vector v into it, to yeild vector p - * - * DANGER !!! Do Not use this on normal vectors!!! - * It will leave normals the wrong length !!! - * See macro below for use on normals. - */ -#define INV_TRANSP_MAT_DOT_VEC_2X2(p,m,v) \ -{ \ - GREAL det; \ - \ - det = m[0][0]*m[1][1] - m[0][1]*m[1][0]; \ - p[0] = m[1][1]*v[0] - m[1][0]*v[1]; \ - p[1] = - m[0][1]*v[0] + m[0][0]*v[1]; \ - \ - /* if matrix not singular, and not orthonormal, then renormalize */ \ - if ((det!=1.0f) && (det != 0.0f)) { \ - det = 1.0f / det; \ - p[0] *= det; \ - p[1] *= det; \ - } \ -}\ - - -/** transform normal vector by inverse transpose of matrix - * and then renormalize the vector - * - * This macro computes inverse transpose of matrix m, - * and multiplies vector v into it, to yeild vector p - * Vector p is then normalized. - */ -#define NORM_XFORM_2X2(p,m,v) \ -{ \ - GREAL len; \ - \ - /* do nothing if off-diagonals are zero and diagonals are \ - * equal */ \ - if ((m[0][1] != 0.0) || (m[1][0] != 0.0) || (m[0][0] != m[1][1])) { \ - p[0] = m[1][1]*v[0] - m[1][0]*v[1]; \ - p[1] = - m[0][1]*v[0] + m[0][0]*v[1]; \ - \ - len = p[0]*p[0] + p[1]*p[1]; \ - GIM_INV_SQRT(len,len); \ - p[0] *= len; \ - p[1] *= len; \ - } else { \ - VEC_COPY_2 (p, v); \ - } \ -}\ - - -/** outer product of vector times vector transpose - * - * The outer product of vector v and vector transpose t yeilds - * dyadic matrix m. - */ -#define OUTER_PRODUCT_2X2(m,v,t) \ -{ \ - m[0][0] = v[0] * t[0]; \ - m[0][1] = v[0] * t[1]; \ - \ - m[1][0] = v[1] * t[0]; \ - m[1][1] = v[1] * t[1]; \ -}\ - - -/** outer product of vector times vector transpose - * - * The outer product of vector v and vector transpose t yeilds - * dyadic matrix m. - */ -#define OUTER_PRODUCT_3X3(m,v,t) \ -{ \ - m[0][0] = v[0] * t[0]; \ - m[0][1] = v[0] * t[1]; \ - m[0][2] = v[0] * t[2]; \ - \ - m[1][0] = v[1] * t[0]; \ - m[1][1] = v[1] * t[1]; \ - m[1][2] = v[1] * t[2]; \ - \ - m[2][0] = v[2] * t[0]; \ - m[2][1] = v[2] * t[1]; \ - m[2][2] = v[2] * t[2]; \ -}\ - - -/** outer product of vector times vector transpose - * - * The outer product of vector v and vector transpose t yeilds - * dyadic matrix m. - */ -#define OUTER_PRODUCT_4X4(m,v,t) \ -{ \ - m[0][0] = v[0] * t[0]; \ - m[0][1] = v[0] * t[1]; \ - m[0][2] = v[0] * t[2]; \ - m[0][3] = v[0] * t[3]; \ - \ - m[1][0] = v[1] * t[0]; \ - m[1][1] = v[1] * t[1]; \ - m[1][2] = v[1] * t[2]; \ - m[1][3] = v[1] * t[3]; \ - \ - m[2][0] = v[2] * t[0]; \ - m[2][1] = v[2] * t[1]; \ - m[2][2] = v[2] * t[2]; \ - m[2][3] = v[2] * t[3]; \ - \ - m[3][0] = v[3] * t[0]; \ - m[3][1] = v[3] * t[1]; \ - m[3][2] = v[3] * t[2]; \ - m[3][3] = v[3] * t[3]; \ -}\ - - -/** outer product of vector times vector transpose - * - * The outer product of vector v and vector transpose t yeilds - * dyadic matrix m. - */ -#define ACCUM_OUTER_PRODUCT_2X2(m,v,t) \ -{ \ - m[0][0] += v[0] * t[0]; \ - m[0][1] += v[0] * t[1]; \ - \ - m[1][0] += v[1] * t[0]; \ - m[1][1] += v[1] * t[1]; \ -}\ - - -/** outer product of vector times vector transpose - * - * The outer product of vector v and vector transpose t yeilds - * dyadic matrix m. - */ -#define ACCUM_OUTER_PRODUCT_3X3(m,v,t) \ -{ \ - m[0][0] += v[0] * t[0]; \ - m[0][1] += v[0] * t[1]; \ - m[0][2] += v[0] * t[2]; \ - \ - m[1][0] += v[1] * t[0]; \ - m[1][1] += v[1] * t[1]; \ - m[1][2] += v[1] * t[2]; \ - \ - m[2][0] += v[2] * t[0]; \ - m[2][1] += v[2] * t[1]; \ - m[2][2] += v[2] * t[2]; \ -}\ - - -/** outer product of vector times vector transpose - * - * The outer product of vector v and vector transpose t yeilds - * dyadic matrix m. - */ -#define ACCUM_OUTER_PRODUCT_4X4(m,v,t) \ -{ \ - m[0][0] += v[0] * t[0]; \ - m[0][1] += v[0] * t[1]; \ - m[0][2] += v[0] * t[2]; \ - m[0][3] += v[0] * t[3]; \ - \ - m[1][0] += v[1] * t[0]; \ - m[1][1] += v[1] * t[1]; \ - m[1][2] += v[1] * t[2]; \ - m[1][3] += v[1] * t[3]; \ - \ - m[2][0] += v[2] * t[0]; \ - m[2][1] += v[2] * t[1]; \ - m[2][2] += v[2] * t[2]; \ - m[2][3] += v[2] * t[3]; \ - \ - m[3][0] += v[3] * t[0]; \ - m[3][1] += v[3] * t[1]; \ - m[3][2] += v[3] * t[2]; \ - m[3][3] += v[3] * t[3]; \ -}\ - - -/** determinant of matrix - * - * Computes determinant of matrix m, returning d - */ -#define DETERMINANT_2X2(d,m) \ -{ \ - d = m[0][0] * m[1][1] - m[0][1] * m[1][0]; \ -}\ - - -/** determinant of matrix - * - * Computes determinant of matrix m, returning d - */ -#define DETERMINANT_3X3(d,m) \ -{ \ - d = m[0][0] * (m[1][1]*m[2][2] - m[1][2] * m[2][1]); \ - d -= m[0][1] * (m[1][0]*m[2][2] - m[1][2] * m[2][0]); \ - d += m[0][2] * (m[1][0]*m[2][1] - m[1][1] * m[2][0]); \ -}\ - - -/** i,j,th cofactor of a 4x4 matrix - * - */ -#define COFACTOR_4X4_IJ(fac,m,i,j) \ -{ \ - GUINT __ii[4], __jj[4], __k; \ - \ - for (__k=0; __k -*/ -#define INV_MAT_DOT_VEC_3X3(p,m,v) \ -{ \ - p[0] = MAT_DOT_COL(m,v,0); \ - p[1] = MAT_DOT_COL(m,v,1); \ - p[2] = MAT_DOT_COL(m,v,2); \ -}\ - - - -#endif // GIM_VECTOR_H_INCLUDED diff --git a/bullet/src/BulletCollision/Gimpact/gim_math.h b/bullet/src/BulletCollision/Gimpact/gim_math.h deleted file mode 100644 index 9949c635f..000000000 --- a/bullet/src/BulletCollision/Gimpact/gim_math.h +++ /dev/null @@ -1,157 +0,0 @@ -#ifndef GIM_MATH_H_INCLUDED -#define GIM_MATH_H_INCLUDED -/*! \file gim_math.h -\author Francisco Len Njera -*/ -/* ------------------------------------------------------------------------------ -This source file is part of GIMPACT Library. - -For the latest info, see http://gimpact.sourceforge.net/ - -Copyright (c) 2006 Francisco Leon Najera. C.C. 80087371. -email: projectileman@yahoo.com - - This library is free software; you can redistribute it and/or - modify it under the terms of EITHER: - (1) The GNU Lesser General Public License as published by the Free - Software Foundation; either version 2.1 of the License, or (at - your option) any later version. The text of the GNU Lesser - General Public License is included with this library in the - file GIMPACT-LICENSE-LGPL.TXT. - (2) The BSD-style license that is included with this library in - the file GIMPACT-LICENSE-BSD.TXT. - (3) The zlib/libpng license that is included with this library in - the file GIMPACT-LICENSE-ZLIB.TXT. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files - GIMPACT-LICENSE-LGPL.TXT, GIMPACT-LICENSE-ZLIB.TXT and GIMPACT-LICENSE-BSD.TXT for more details. - ------------------------------------------------------------------------------ -*/ - -#include "LinearMath/btScalar.h" - - - -#define GREAL btScalar -#define GREAL2 double -#define GINT int -#define GUINT unsigned int -#define GSHORT short -#define GUSHORT unsigned short -#define GINT64 long long -#define GUINT64 unsigned long long - - - -#define G_PI 3.14159265358979f -#define G_HALF_PI 1.5707963f -//267948966 -#define G_TWO_PI 6.28318530f -//71795864 -#define G_ROOT3 1.73205f -#define G_ROOT2 1.41421f -#define G_UINT_INFINITY 0xffffffff //!< A very very high value -#define G_REAL_INFINITY FLT_MAX -#define G_SIGN_BITMASK 0x80000000 -#define G_EPSILON SIMD_EPSILON - - - -enum GIM_SCALAR_TYPES -{ - G_STYPE_REAL =0, - G_STYPE_REAL2, - G_STYPE_SHORT, - G_STYPE_USHORT, - G_STYPE_INT, - G_STYPE_UINT, - G_STYPE_INT64, - G_STYPE_UINT64 -}; - - - -#define G_DEGTORAD(X) ((X)*3.1415926f/180.0f) -#define G_RADTODEG(X) ((X)*180.0f/3.1415926f) - -//! Integer representation of a floating-point value. -#define GIM_IR(x) ((GUINT&)(x)) - -//! Signed integer representation of a floating-point value. -#define GIM_SIR(x) ((GINT&)(x)) - -//! Absolute integer representation of a floating-point value -#define GIM_AIR(x) (GIM_IR(x)&0x7fffffff) - -//! Floating-point representation of an integer value. -#define GIM_FR(x) ((GREAL&)(x)) - -#define GIM_MAX(a,b) (ab?b:a) - -#define GIM_MAX3(a,b,c) GIM_MAX(a,GIM_MAX(b,c)) -#define GIM_MIN3(a,b,c) GIM_MIN(a,GIM_MIN(b,c)) - -#define GIM_IS_ZERO(value) (value < G_EPSILON && value > -G_EPSILON) - -#define GIM_IS_NEGATIVE(value) (value <= -G_EPSILON) - -#define GIM_IS_POSISITVE(value) (value >= G_EPSILON) - -#define GIM_NEAR_EQUAL(v1,v2) GIM_IS_ZERO((v1-v2)) - -///returns a clamped number -#define GIM_CLAMP(number,minval,maxval) (numbermaxval?maxval:number)) - -#define GIM_GREATER(x, y) btFabs(x) > (y) - -///Swap numbers -#define GIM_SWAP_NUMBERS(a,b){ \ - a = a+b; \ - b = a-b; \ - a = a-b; \ -}\ - -#define GIM_INV_SQRT(va,isva)\ -{\ - if(va<=0.0000001f)\ - {\ - isva = G_REAL_INFINITY;\ - }\ - else\ - {\ - GREAL _x = va * 0.5f;\ - GUINT _y = 0x5f3759df - ( GIM_IR(va) >> 1);\ - isva = GIM_FR(_y);\ - isva = isva * ( 1.5f - ( _x * isva * isva ) );\ - }\ -}\ - -#define GIM_SQRT(va,sva)\ -{\ - GIM_INV_SQRT(va,sva);\ - sva = 1.0f/sva;\ -}\ - -//! Computes 1.0f / sqrtf(x). Comes from Quake3. See http://www.magic-software.com/3DGEDInvSqrt.html -inline GREAL gim_inv_sqrt(GREAL f) -{ - GREAL r; - GIM_INV_SQRT(f,r); - return r; -} - -inline GREAL gim_sqrt(GREAL f) -{ - GREAL r; - GIM_SQRT(f,r); - return r; -} - - - -#endif // GIM_MATH_H_INCLUDED diff --git a/bullet/src/BulletCollision/Gimpact/gim_memory.cpp b/bullet/src/BulletCollision/Gimpact/gim_memory.cpp deleted file mode 100644 index b1d471e69..000000000 --- a/bullet/src/BulletCollision/Gimpact/gim_memory.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* ------------------------------------------------------------------------------ -This source file is part of GIMPACT Library. - -For the latest info, see http://gimpact.sourceforge.net/ - -Copyright (c) 2006 Francisco Leon Najera. C.C. 80087371. -email: projectileman@yahoo.com - - This library is free software; you can redistribute it and/or - modify it under the terms of EITHER: - (1) The GNU Lesser General Public License as published by the Free - Software Foundation; either version 2.1 of the License, or (at - your option) any later version. The text of the GNU Lesser - General Public License is included with this library in the - file GIMPACT-LICENSE-LGPL.TXT. - (2) The BSD-style license that is included with this library in - the file GIMPACT-LICENSE-BSD.TXT. - (3) The zlib/libpng license that is included with this library in - the file GIMPACT-LICENSE-ZLIB.TXT. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files - GIMPACT-LICENSE-LGPL.TXT, GIMPACT-LICENSE-ZLIB.TXT and GIMPACT-LICENSE-BSD.TXT for more details. - ------------------------------------------------------------------------------ -*/ - - -#include "gim_memory.h" -#include "stdlib.h" - -#ifdef GIM_SIMD_MEMORY -#include "LinearMath/btAlignedAllocator.h" -#endif - -static gim_alloc_function *g_allocfn = 0; -static gim_alloca_function *g_allocafn = 0; -static gim_realloc_function *g_reallocfn = 0; -static gim_free_function *g_freefn = 0; - -void gim_set_alloc_handler (gim_alloc_function *fn) -{ - g_allocfn = fn; -} - -void gim_set_alloca_handler (gim_alloca_function *fn) -{ - g_allocafn = fn; -} - -void gim_set_realloc_handler (gim_realloc_function *fn) -{ - g_reallocfn = fn; -} - -void gim_set_free_handler (gim_free_function *fn) -{ - g_freefn = fn; -} - -gim_alloc_function *gim_get_alloc_handler() -{ - return g_allocfn; -} - -gim_alloca_function *gim_get_alloca_handler() -{ - return g_allocafn; -} - - -gim_realloc_function *gim_get_realloc_handler () -{ - return g_reallocfn; -} - - -gim_free_function *gim_get_free_handler () -{ - return g_freefn; -} - - -void * gim_alloc(size_t size) -{ - void * ptr; - if (g_allocfn) - { - ptr = g_allocfn(size); - } - else - { -#ifdef GIM_SIMD_MEMORY - ptr = btAlignedAlloc(size,16); -#else - ptr = malloc(size); -#endif - } - return ptr; -} - -void * gim_alloca(size_t size) -{ - if (g_allocafn) return g_allocafn(size); else return gim_alloc(size); -} - - -void * gim_realloc(void *ptr, size_t oldsize, size_t newsize) -{ - void * newptr = gim_alloc(newsize); - size_t copysize = oldsize - -#ifdef PREFETCH -#include // for prefetch -#define pfval 64 -#define pfval2 128 -//! Prefetch 64 -#define pf(_x,_i) _mm_prefetch((void *)(_x + _i + pfval), 0) -//! Prefetch 128 -#define pf2(_x,_i) _mm_prefetch((void *)(_x + _i + pfval2), 0) -#else -//! Prefetch 64 -#define pf(_x,_i) -//! Prefetch 128 -#define pf2(_x,_i) -#endif - - -///Functions for manip packed arrays of numbers -#define GIM_COPY_ARRAYS(dest_array,source_array,element_count)\ -{\ - for (GUINT _i_=0;_i_=SIMD_T_SIZE) - { - *(ui_dst_ptr++) = *(ui_src_ptr++); - copysize-=SIMD_T_SIZE; - } - if(copysize==0) return; -*/ - - char * c_src_ptr = (char *)src; - char * c_dst_ptr = (char *)dst; - while(copysize>0) - { - *(c_dst_ptr++) = *(c_src_ptr++); - copysize--; - } - return; -#else - memcpy(dst,src,copysize); -#endif -} - - - -template -inline void gim_swap_elements(T* _array,size_t _i,size_t _j) -{ - T _e_tmp_ = _array[_i]; - _array[_i] = _array[_j]; - _array[_j] = _e_tmp_; -} - - -template -inline void gim_swap_elements_memcpy(T* _array,size_t _i,size_t _j) -{ - char _e_tmp_[sizeof(T)]; - gim_simd_memcpy(_e_tmp_,&_array[_i],sizeof(T)); - gim_simd_memcpy(&_array[_i],&_array[_j],sizeof(T)); - gim_simd_memcpy(&_array[_j],_e_tmp_,sizeof(T)); -} - -template -inline void gim_swap_elements_ptr(char * _array,size_t _i,size_t _j) -{ - char _e_tmp_[SIZE]; - _i*=SIZE; - _j*=SIZE; - gim_simd_memcpy(_e_tmp_,_array+_i,SIZE); - gim_simd_memcpy(_array+_i,_array+_j,SIZE); - gim_simd_memcpy(_array+_j,_e_tmp_,SIZE); -} - -#endif // GIM_MEMORY_H_INCLUDED diff --git a/bullet/src/BulletCollision/Gimpact/gim_radixsort.h b/bullet/src/BulletCollision/Gimpact/gim_radixsort.h deleted file mode 100644 index 0a0518a4f..000000000 --- a/bullet/src/BulletCollision/Gimpact/gim_radixsort.h +++ /dev/null @@ -1,406 +0,0 @@ -#ifndef GIM_RADIXSORT_H_INCLUDED -#define GIM_RADIXSORT_H_INCLUDED -/*! \file gim_radixsort.h -\author Francisco Len Njera. -Based on the work of Michael Herf : "fast floating-point radix sort" -Avaliable on http://www.stereopsis.com/radix.html -*/ -/* ------------------------------------------------------------------------------ -This source file is part of GIMPACT Library. - -For the latest info, see http://gimpact.sourceforge.net/ - -Copyright (c) 2006 Francisco Leon Najera. C.C. 80087371. -email: projectileman@yahoo.com - - This library is free software; you can redistribute it and/or - modify it under the terms of EITHER: - (1) The GNU Lesser General Public License as published by the Free - Software Foundation; either version 2.1 of the License, or (at - your option) any later version. The text of the GNU Lesser - General Public License is included with this library in the - file GIMPACT-LICENSE-LGPL.TXT. - (2) The BSD-style license that is included with this library in - the file GIMPACT-LICENSE-BSD.TXT. - (3) The zlib/libpng license that is included with this library in - the file GIMPACT-LICENSE-ZLIB.TXT. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files - GIMPACT-LICENSE-LGPL.TXT, GIMPACT-LICENSE-ZLIB.TXT and GIMPACT-LICENSE-BSD.TXT for more details. - ------------------------------------------------------------------------------ -*/ - -#include "gim_memory.h" - -///Macros for sorting. -//! Prototype for comparators -class less_comparator -{ - public: - - template - inline int operator() ( const T& a, const Z& b ) - { - return ( ab?1:0)); - } -}; - -//! Prototype for comparators -class integer_comparator -{ - public: - - template - inline int operator() ( const T& a, const T& b ) - { - return (int)(a-b); - } -}; - -//!Prototype for getting the integer representation of an object -class uint_key_func -{ -public: - template - inline GUINT operator()( const T& a) - { - return (GUINT)a; - } -}; - - -//!Prototype for copying elements -class copy_elements_func -{ -public: - template - inline void operator()(T& a,T& b) - { - a = b; - } -}; - -//!Prototype for copying elements -class memcopy_elements_func -{ -public: - template - inline void operator()(T& a,T& b) - { - gim_simd_memcpy(&a,&b,sizeof(T)); - } -}; - - -//! @{ -struct GIM_RSORT_TOKEN -{ - GUINT m_key; - GUINT m_value; - GIM_RSORT_TOKEN() - { - } - GIM_RSORT_TOKEN(const GIM_RSORT_TOKEN& rtoken) - { - m_key = rtoken.m_key; - m_value = rtoken.m_value; - } - - inline bool operator <(const GIM_RSORT_TOKEN& other) const - { - return (m_key < other.m_key); - } - - inline bool operator >(const GIM_RSORT_TOKEN& other) const - { - return (m_key > other.m_key); - } -}; - -//! Prototype for comparators -class GIM_RSORT_TOKEN_COMPARATOR -{ - public: - - inline int operator()( const GIM_RSORT_TOKEN& a, const GIM_RSORT_TOKEN& b ) - { - return (int)((a.m_key) - (b.m_key)); - } -}; - - - -#define kHist 2048 -// ---- utils for accessing 11-bit quantities -#define D11_0(x) (x & 0x7FF) -#define D11_1(x) (x >> 11 & 0x7FF) -#define D11_2(x) (x >> 22 ) - - - -///Radix sort for unsigned integer keys -inline void gim_radix_sort_rtokens( - GIM_RSORT_TOKEN * array, - GIM_RSORT_TOKEN * sorted, GUINT element_count) -{ - GUINT i; - GUINT b0[kHist * 3]; - GUINT *b1 = b0 + kHist; - GUINT *b2 = b1 + kHist; - for (i = 0; i < kHist * 3; ++i) - { - b0[i] = 0; - } - GUINT fi; - GUINT pos; - for (i = 0; i < element_count; ++i) - { - fi = array[i].m_key; - b0[D11_0(fi)] ++; - b1[D11_1(fi)] ++; - b2[D11_2(fi)] ++; - } - { - GUINT sum0 = 0, sum1 = 0, sum2 = 0; - GUINT tsum; - for (i = 0; i < kHist; ++i) - { - tsum = b0[i] + sum0; - b0[i] = sum0 - 1; - sum0 = tsum; - tsum = b1[i] + sum1; - b1[i] = sum1 - 1; - sum1 = tsum; - tsum = b2[i] + sum2; - b2[i] = sum2 - 1; - sum2 = tsum; - } - } - for (i = 0; i < element_count; ++i) - { - fi = array[i].m_key; - pos = D11_0(fi); - pos = ++b0[pos]; - sorted[pos].m_key = array[i].m_key; - sorted[pos].m_value = array[i].m_value; - } - for (i = 0; i < element_count; ++i) - { - fi = sorted[i].m_key; - pos = D11_1(fi); - pos = ++b1[pos]; - array[pos].m_key = sorted[i].m_key; - array[pos].m_value = sorted[i].m_value; - } - for (i = 0; i < element_count; ++i) - { - fi = array[i].m_key; - pos = D11_2(fi); - pos = ++b2[pos]; - sorted[pos].m_key = array[i].m_key; - sorted[pos].m_value = array[i].m_value; - } -} - - - - -/// Get the sorted tokens from an array. For generic use. Tokens are IRR_RSORT_TOKEN -/*! -*\param array Array of elements to sort -*\param sorted_tokens Tokens of sorted elements -*\param element_count element count -*\param uintkey_macro Functor which retrieves the integer representation of an array element -*/ -template -void gim_radix_sort_array_tokens( - T* array , - GIM_RSORT_TOKEN * sorted_tokens, - GUINT element_count,GETKEY_CLASS uintkey_macro) -{ - GIM_RSORT_TOKEN * _unsorted = (GIM_RSORT_TOKEN *) gim_alloc(sizeof(GIM_RSORT_TOKEN)*element_count); - for (GUINT _i=0;_i -void gim_radix_sort( - T * array, GUINT element_count, - GETKEY_CLASS get_uintkey_macro, COPY_CLASS copy_elements_macro) -{ - GIM_RSORT_TOKEN * _sorted = (GIM_RSORT_TOKEN *) gim_alloc(sizeof(GIM_RSORT_TOKEN)*element_count); - gim_radix_sort_array_tokens(array,_sorted,element_count,get_uintkey_macro); - T * _original_array = (T *) gim_alloc(sizeof(T)*element_count); - gim_simd_memcpy(_original_array,array,sizeof(T)*element_count); - for (GUINT _i=0;_i -bool gim_binary_search_ex( - const T* _array, GUINT _start_i, - GUINT _end_i,GUINT & _result_index, - const KEYCLASS & _search_key, - COMP_CLASS _comp_macro) -{ - GUINT _k; - int _comp_result; - GUINT _i = _start_i; - GUINT _j = _end_i+1; - while (_i < _j) - { - _k = (_j+_i-1)/2; - _comp_result = _comp_macro(_array[_k], _search_key); - if (_comp_result == 0) - { - _result_index = _k; - return true; - } - else if (_comp_result < 0) - { - _i = _k+1; - } - else - { - _j = _k; - } - } - _result_index = _i; - return false; -} - - - -//! Failsafe Iterative binary search,Template version -/*! -If the element is not found, it returns the nearest upper element position, may be the further position after the last element. -\param _array -\param _start_i the beginning of the array -\param _end_i the ending index of the array -\param _search_key Value to find -\param _result_index the index of the found element, or if not found then it will get the index of the closest bigger value -\return true if found, else false -*/ -template -bool gim_binary_search( - const T*_array,GUINT _start_i, - GUINT _end_i,const T & _search_key, - GUINT & _result_index) -{ - GUINT _i = _start_i; - GUINT _j = _end_i+1; - GUINT _k; - while(_i < _j) - { - _k = (_j+_i-1)/2; - if(_array[_k]==_search_key) - { - _result_index = _k; - return true; - } - else if (_array[_k]<_search_key) - { - _i = _k+1; - } - else - { - _j = _k; - } - } - _result_index = _i; - return false; -} - - - -///heap sort from http://www.csse.monash.edu.au/~lloyd/tildeAlgDS/Sort/Heap/ -template -void gim_down_heap(T *pArr, GUINT k, GUINT n,COMP_CLASS CompareFunc) -{ - /* PRE: a[k+1..N] is a heap */ - /* POST: a[k..N] is a heap */ - - T temp = pArr[k - 1]; - /* k has child(s) */ - while (k <= n/2) - { - int child = 2*k; - - if ((child < (int)n) && CompareFunc(pArr[child - 1] , pArr[child])<0) - { - child++; - } - /* pick larger child */ - if (CompareFunc(temp , pArr[child - 1])<0) - { - /* move child up */ - pArr[k - 1] = pArr[child - 1]; - k = child; - } - else - { - break; - } - } - pArr[k - 1] = temp; -} /*downHeap*/ - - -template -void gim_heap_sort(T *pArr, GUINT element_count, COMP_CLASS CompareFunc) -{ - /* sort a[0..N-1], N.B. 0 to N-1 */ - GUINT k; - GUINT n = element_count; - for (k = n/2; k > 0; k--) - { - gim_down_heap(pArr, k, n, CompareFunc); - } - - /* a[1..N] is now a heap */ - while ( n>=2 ) - { - gim_swap_elements(pArr,0,n-1); /* largest of a[0..n-1] */ - --n; - /* restore a[1..i-1] heap */ - gim_down_heap(pArr, 1, n, CompareFunc); - } -} - - - - -#endif // GIM_RADIXSORT_H_INCLUDED diff --git a/bullet/src/BulletCollision/Gimpact/gim_tri_collision.cpp b/bullet/src/BulletCollision/Gimpact/gim_tri_collision.cpp deleted file mode 100644 index 1cc2ac623..000000000 --- a/bullet/src/BulletCollision/Gimpact/gim_tri_collision.cpp +++ /dev/null @@ -1,640 +0,0 @@ - -/*! \file gim_tri_collision.h -\author Francisco Len Njera -*/ -/* ------------------------------------------------------------------------------ -This source file is part of GIMPACT Library. - -For the latest info, see http://gimpact.sourceforge.net/ - -Copyright (c) 2006 Francisco Leon Najera. C.C. 80087371. -email: projectileman@yahoo.com - - This library is free software; you can redistribute it and/or - modify it under the terms of EITHER: - (1) The GNU Lesser General Public License as published by the Free - Software Foundation; either version 2.1 of the License, or (at - your option) any later version. The text of the GNU Lesser - General Public License is included with this library in the - file GIMPACT-LICENSE-LGPL.TXT. - (2) The BSD-style license that is included with this library in - the file GIMPACT-LICENSE-BSD.TXT. - (3) The zlib/libpng license that is included with this library in - the file GIMPACT-LICENSE-ZLIB.TXT. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files - GIMPACT-LICENSE-LGPL.TXT, GIMPACT-LICENSE-ZLIB.TXT and GIMPACT-LICENSE-BSD.TXT for more details. - ------------------------------------------------------------------------------ -*/ - -#include "gim_tri_collision.h" - - -#define TRI_LOCAL_EPSILON 0.000001f -#define MIN_EDGE_EDGE_DIS 0.00001f - - -class GIM_TRIANGLE_CALCULATION_CACHE -{ -public: - GREAL margin; - btVector3 tu_vertices[3]; - btVector3 tv_vertices[3]; - btVector4 tu_plane; - btVector4 tv_plane; - btVector3 closest_point_u; - btVector3 closest_point_v; - btVector3 edge_edge_dir; - btVector3 distances; - GREAL du[4]; - GREAL du0du1; - GREAL du0du2; - GREAL dv[4]; - GREAL dv0dv1; - GREAL dv0dv2; - btVector3 temp_points[MAX_TRI_CLIPPING]; - btVector3 temp_points1[MAX_TRI_CLIPPING]; - btVector3 contact_points[MAX_TRI_CLIPPING]; - - - - //! if returns false, the faces are paralele - SIMD_FORCE_INLINE bool compute_intervals( - const GREAL &D0, - const GREAL &D1, - const GREAL &D2, - const GREAL &D0D1, - const GREAL &D0D2, - GREAL & scale_edge0, - GREAL & scale_edge1, - GUINT &edge_index0, - GUINT &edge_index1) - { - if(D0D1>0.0f) - { - /* here we know that D0D2<=0.0 */ - /* that is D0, D1 are on the same side, D2 on the other or on the plane */ - scale_edge0 = -D2/(D0-D2); - scale_edge1 = -D1/(D2-D1); - edge_index0 = 2;edge_index1 = 1; - } - else if(D0D2>0.0f) - { - /* here we know that d0d1<=0.0 */ - scale_edge0 = -D0/(D1-D0); - scale_edge1 = -D1/(D2-D1); - edge_index0 = 0;edge_index1 = 1; - } - else if(D1*D2>0.0f || D0!=0.0f) - { - /* here we know that d0d1<=0.0 or that D0!=0.0 */ - scale_edge0 = -D0/(D1-D0); - scale_edge1 = -D2/(D0-D2); - edge_index0 = 0 ;edge_index1 = 2; - } - else - { - return false; - } - return true; - } - - - //! clip triangle - /*! - */ - SIMD_FORCE_INLINE GUINT clip_triangle( - const btVector4 & tri_plane, - const btVector3 * tripoints, - const btVector3 * srcpoints, - btVector3 * clip_points) - { - // edge 0 - - btVector4 edgeplane; - - EDGE_PLANE(tripoints[0],tripoints[1],tri_plane,edgeplane); - - GUINT clipped_count = PLANE_CLIP_TRIANGLE3D( - edgeplane,srcpoints[0],srcpoints[1],srcpoints[2],temp_points); - - if(clipped_count == 0) return 0; - - // edge 1 - - EDGE_PLANE(tripoints[1],tripoints[2],tri_plane,edgeplane); - - clipped_count = PLANE_CLIP_POLYGON3D( - edgeplane,temp_points,clipped_count,temp_points1); - - if(clipped_count == 0) return 0; - - // edge 2 - - EDGE_PLANE(tripoints[2],tripoints[0],tri_plane,edgeplane); - - clipped_count = PLANE_CLIP_POLYGON3D( - edgeplane,temp_points1,clipped_count,clip_points); - - return clipped_count; - - - /*GUINT i0 = (tri_plane.closestAxis()+1)%3; - GUINT i1 = (i0+1)%3; - // edge 0 - btVector3 temp_points[MAX_TRI_CLIPPING]; - btVector3 temp_points1[MAX_TRI_CLIPPING]; - - GUINT clipped_count= PLANE_CLIP_TRIANGLE_GENERIC( - 0,srcpoints[0],srcpoints[1],srcpoints[2],temp_points, - DISTANCE_EDGE(tripoints[0],tripoints[1],i0,i1)); - - - if(clipped_count == 0) return 0; - - // edge 1 - clipped_count = PLANE_CLIP_POLYGON_GENERIC( - 0,temp_points,clipped_count,temp_points1, - DISTANCE_EDGE(tripoints[1],tripoints[2],i0,i1)); - - if(clipped_count == 0) return 0; - - // edge 2 - clipped_count = PLANE_CLIP_POLYGON_GENERIC( - 0,temp_points1,clipped_count,clipped_points, - DISTANCE_EDGE(tripoints[2],tripoints[0],i0,i1)); - - return clipped_count;*/ - } - - SIMD_FORCE_INLINE void sort_isect( - GREAL & isect0,GREAL & isect1,GUINT &e0,GUINT &e1,btVector3 & vec0,btVector3 & vec1) - { - if(isect1=isect_v[1]) // face U casts face V - { - return 1; - } - else if(isect_v[0]<=isect_u[0]) // face V casts face U - { - return 2; - } - // closest points - closest_point_u = up_e1; - closest_point_v = vp_e0; - // calc edges and separation - - if(isect_u[1]+ MIN_EDGE_EDGE_DIS=isect_u[1]) // face V casts face U - { - return 2; - } - else if(isect_u[0]<=isect_v[0]) // face U casts face V - { - return 1; - } - // closest points - closest_point_u = up_e0; - closest_point_v = vp_e1; - // calc edges and separation - - if(isect_v[1]+MIN_EDGE_EDGE_DIS0.0f && du0du2>0.0f) // same sign on all of them + not equal 0 ? - { - if(du[0]<0) //we need test behind the triangle plane - { - distances[0] = GIM_MAX3(du[0],du[1],du[2]); - distances[0] = -distances[0]; - if(distances[0]>margin) return false; //never intersect - - //reorder triangle v - VEC_SWAP(tv_vertices[0],tv_vertices[1]); - VEC_SCALE_4(tv_plane,-1.0f,tv_plane); - } - else - { - distances[0] = GIM_MIN3(du[0],du[1],du[2]); - if(distances[0]>margin) return false; //never intersect - } - } - else - { - //Look if we need to invert the triangle - distances[0] = (du[0]+du[1]+du[2])/3.0f; //centroid - - if(distances[0]<0.0f) - { - //reorder triangle v - VEC_SWAP(tv_vertices[0],tv_vertices[1]); - VEC_SCALE_4(tv_plane,-1.0f,tv_plane); - - distances[0] = GIM_MAX3(du[0],du[1],du[2]); - distances[0] = -distances[0]; - } - else - { - distances[0] = GIM_MIN3(du[0],du[1],du[2]); - } - } - - - // plane U vs V points - - TRIANGLE_PLANE(tu_vertices[0],tu_vertices[1],tu_vertices[2],tu_plane); - - dv[0] = DISTANCE_PLANE_POINT(tu_plane,tv_vertices[0]); - dv[1] = DISTANCE_PLANE_POINT(tu_plane,tv_vertices[1]); - dv[2] = DISTANCE_PLANE_POINT(tu_plane,tv_vertices[2]); - - dv0dv1 = dv[0] * dv[1]; - dv0dv2 = dv[0] * dv[2]; - - - if(dv0dv1>0.0f && dv0dv2>0.0f) // same sign on all of them + not equal 0 ? - { - if(dv[0]<0) //we need test behind the triangle plane - { - distances[1] = GIM_MAX3(dv[0],dv[1],dv[2]); - distances[1] = -distances[1]; - if(distances[1]>margin) return false; //never intersect - - //reorder triangle u - VEC_SWAP(tu_vertices[0],tu_vertices[1]); - VEC_SCALE_4(tu_plane,-1.0f,tu_plane); - } - else - { - distances[1] = GIM_MIN3(dv[0],dv[1],dv[2]); - if(distances[1]>margin) return false; //never intersect - } - } - else - { - //Look if we need to invert the triangle - distances[1] = (dv[0]+dv[1]+dv[2])/3.0f; //centroid - - if(distances[1]<0.0f) - { - //reorder triangle v - VEC_SWAP(tu_vertices[0],tu_vertices[1]); - VEC_SCALE_4(tu_plane,-1.0f,tu_plane); - - distances[1] = GIM_MAX3(dv[0],dv[1],dv[2]); - distances[1] = -distances[1]; - } - else - { - distances[1] = GIM_MIN3(dv[0],dv[1],dv[2]); - } - } - - GUINT bl; - /* bl = cross_line_intersection_test(); - if(bl==3) - { - //take edge direction too - bl = distances.maxAxis(); - } - else - {*/ - bl = 0; - if(distances[0]margin) return false; - - contacts.m_penetration_depth = -distances[2] + margin; - contacts.m_points[0] = closest_point_v; - contacts.m_point_count = 1; - VEC_COPY(contacts.m_separating_normal,edge_edge_dir); - - return true; - } - - //clip face against other - - - GUINT point_count; - //TODO - if(bl == 0) //clip U points against V - { - point_count = clip_triangle(tv_plane,tv_vertices,tu_vertices,contact_points); - if(point_count == 0) return false; - contacts.merge_points(tv_plane,margin,contact_points,point_count); - } - else //clip V points against U - { - point_count = clip_triangle(tu_plane,tu_vertices,tv_vertices,contact_points); - if(point_count == 0) return false; - contacts.merge_points(tu_plane,margin,contact_points,point_count); - contacts.m_separating_normal *= -1.f; - } - if(contacts.m_point_count == 0) return false; - return true; - } - -}; - - -/*class GIM_TRIANGLE_CALCULATION_CACHE -{ -public: - GREAL margin; - GUINT clipped_count; - btVector3 tu_vertices[3]; - btVector3 tv_vertices[3]; - btVector3 temp_points[MAX_TRI_CLIPPING]; - btVector3 temp_points1[MAX_TRI_CLIPPING]; - btVector3 clipped_points[MAX_TRI_CLIPPING]; - GIM_TRIANGLE_CONTACT_DATA contacts1; - GIM_TRIANGLE_CONTACT_DATA contacts2; - - - //! clip triangle - GUINT clip_triangle( - const btVector4 & tri_plane, - const btVector3 * tripoints, - const btVector3 * srcpoints, - btVector3 * clipped_points) - { - // edge 0 - - btVector4 edgeplane; - - EDGE_PLANE(tripoints[0],tripoints[1],tri_plane,edgeplane); - - GUINT clipped_count = PLANE_CLIP_TRIANGLE3D( - edgeplane,srcpoints[0],srcpoints[1],srcpoints[2],temp_points); - - if(clipped_count == 0) return 0; - - // edge 1 - - EDGE_PLANE(tripoints[1],tripoints[2],tri_plane,edgeplane); - - clipped_count = PLANE_CLIP_POLYGON3D( - edgeplane,temp_points,clipped_count,temp_points1); - - if(clipped_count == 0) return 0; - - // edge 2 - - EDGE_PLANE(tripoints[2],tripoints[0],tri_plane,edgeplane); - - clipped_count = PLANE_CLIP_POLYGON3D( - edgeplane,temp_points1,clipped_count,clipped_points); - - return clipped_count; - } - - - - - //! collides only on one side - bool triangle_collision( - const btVector3 & u0, - const btVector3 & u1, - const btVector3 & u2, - GREAL margin_u, - const btVector3 & v0, - const btVector3 & v1, - const btVector3 & v2, - GREAL margin_v, - GIM_TRIANGLE_CONTACT_DATA & contacts) - { - - margin = margin_u + margin_v; - - - tu_vertices[0] = u0; - tu_vertices[1] = u1; - tu_vertices[2] = u2; - - tv_vertices[0] = v0; - tv_vertices[1] = v1; - tv_vertices[2] = v2; - - //create planes - // plane v vs U points - - - TRIANGLE_PLANE(tv_vertices[0],tv_vertices[1],tv_vertices[2],contacts1.m_separating_normal); - - clipped_count = clip_triangle( - contacts1.m_separating_normal,tv_vertices,tu_vertices,clipped_points); - - if(clipped_count == 0 ) - { - return false;//Reject - } - - //find most deep interval face1 - contacts1.merge_points(contacts1.m_separating_normal,margin,clipped_points,clipped_count); - if(contacts1.m_point_count == 0) return false; // too far - - //Normal pointing to triangle1 - //contacts1.m_separating_normal *= -1.f; - - //Clip tri1 by tri2 edges - - TRIANGLE_PLANE(tu_vertices[0],tu_vertices[1],tu_vertices[2],contacts2.m_separating_normal); - - clipped_count = clip_triangle( - contacts2.m_separating_normal,tu_vertices,tv_vertices,clipped_points); - - if(clipped_count == 0 ) - { - return false;//Reject - } - - //find most deep interval face1 - contacts2.merge_points(contacts2.m_separating_normal,margin,clipped_points,clipped_count); - if(contacts2.m_point_count == 0) return false; // too far - - contacts2.m_separating_normal *= -1.f; - - ////check most dir for contacts - if(contacts2.m_penetration_depth - SIMD_FORCE_INLINE void mergepoints_generic(const CLASS_PLANE & plane, - GREAL margin, const btVector3 * points, GUINT point_count, DISTANCE_FUNC distance_func) - { - m_point_count = 0; - m_penetration_depth= -1000.0f; - - GUINT point_indices[MAX_TRI_CLIPPING]; - - GUINT _k; - - for(_k=0;_k=0.0f) - { - if(_dist>m_penetration_depth) - { - m_penetration_depth = _dist; - point_indices[0] = _k; - m_point_count=1; - } - else if((_dist+G_EPSILON)>=m_penetration_depth) - { - point_indices[m_point_count] = _k; - m_point_count++; - } - } - } - - for( _k=0;_k u*axe1[i1] + ((vecproj[i2] - u*axe1[i2])/axe2[i2])*axe2[i1] = vecproj[i1] - - --> u*axe1[i1] + vecproj[i2]*axe2[i1]/axe2[i2] - u*axe1[i2]*axe2[i1]/axe2[i2] = vecproj[i1] - - --> u*(axe1[i1] - axe1[i2]*axe2[i1]/axe2[i2]) = vecproj[i1] - vecproj[i2]*axe2[i1]/axe2[i2] - - --> u*((axe1[i1]*axe2[i2] - axe1[i2]*axe2[i1])/axe2[i2]) = (vecproj[i1]*axe2[i2] - vecproj[i2]*axe2[i1])/axe2[i2] - - --> u*(axe1[i1]*axe2[i2] - axe1[i2]*axe2[i1]) = vecproj[i1]*axe2[i2] - vecproj[i2]*axe2[i1] - - --> u = (vecproj[i1]*axe2[i2] - vecproj[i2]*axe2[i1]) /(axe1[i1]*axe2[i2] - axe1[i2]*axe2[i1]) - -if 0.0<= u+v <=1.0 then they are inside of triangle - - \return false if the point is outside of triangle.This function doesn't take the margin - */ - SIMD_FORCE_INLINE bool get_uv_parameters( - const btVector3 & point, - const btVector3 & tri_plane, - GREAL & u, GREAL & v) const - { - btVector3 _axe1 = m_vertices[1]-m_vertices[0]; - btVector3 _axe2 = m_vertices[2]-m_vertices[0]; - btVector3 _vecproj = point - m_vertices[0]; - GUINT _i1 = (tri_plane.closestAxis()+1)%3; - GUINT _i2 = (_i1+1)%3; - if(btFabs(_axe2[_i2])G_EPSILON) - { - return false; - } - } - return true; - } - - //! is point in triangle beam? - /*! - Test if point is in triangle, with m_margin tolerance - */ - SIMD_FORCE_INLINE bool is_point_inside(const btVector3 & point, const btVector3 & tri_normal) const - { - //Test with edge 0 - btVector4 edge_plane; - this->get_edge_plane(0,tri_normal,edge_plane); - GREAL dist = DISTANCE_PLANE_POINT(edge_plane,point); - if(dist-m_margin>0.0f) return false; // outside plane - - this->get_edge_plane(1,tri_normal,edge_plane); - dist = DISTANCE_PLANE_POINT(edge_plane,point); - if(dist-m_margin>0.0f) return false; // outside plane - - this->get_edge_plane(2,tri_normal,edge_plane); - dist = DISTANCE_PLANE_POINT(edge_plane,point); - if(dist-m_margin>0.0f) return false; // outside plane - return true; - } - - - //! Bidireccional ray collision - SIMD_FORCE_INLINE bool ray_collision( - const btVector3 & vPoint, - const btVector3 & vDir, btVector3 & pout, btVector3 & triangle_normal, - GREAL & tparam, GREAL tmax = G_REAL_INFINITY) - { - btVector4 faceplane; - { - btVector3 dif1 = m_vertices[1] - m_vertices[0]; - btVector3 dif2 = m_vertices[2] - m_vertices[0]; - VEC_CROSS(faceplane,dif1,dif2); - faceplane[3] = m_vertices[0].dot(faceplane); - } - - GUINT res = LINE_PLANE_COLLISION(faceplane,vDir,vPoint,pout,tparam, btScalar(0), tmax); - if(res == 0) return false; - if(! is_point_inside(pout,faceplane)) return false; - - if(res==2) //invert normal - { - triangle_normal.setValue(-faceplane[0],-faceplane[1],-faceplane[2]); - } - else - { - triangle_normal.setValue(faceplane[0],faceplane[1],faceplane[2]); - } - - VEC_NORMALIZE(triangle_normal); - - return true; - } - - - //! one direccion ray collision - SIMD_FORCE_INLINE bool ray_collision_front_side( - const btVector3 & vPoint, - const btVector3 & vDir, btVector3 & pout, btVector3 & triangle_normal, - GREAL & tparam, GREAL tmax = G_REAL_INFINITY) - { - btVector4 faceplane; - { - btVector3 dif1 = m_vertices[1] - m_vertices[0]; - btVector3 dif2 = m_vertices[2] - m_vertices[0]; - VEC_CROSS(faceplane,dif1,dif2); - faceplane[3] = m_vertices[0].dot(faceplane); - } - - GUINT res = LINE_PLANE_COLLISION(faceplane,vDir,vPoint,pout,tparam, btScalar(0), tmax); - if(res != 1) return false; - - if(!is_point_inside(pout,faceplane)) return false; - - triangle_normal.setValue(faceplane[0],faceplane[1],faceplane[2]); - - VEC_NORMALIZE(triangle_normal); - - return true; - } - -}; - - - - -#endif // GIM_TRI_COLLISION_H_INCLUDED diff --git a/bullet/src/BulletCollision/Jamfile b/bullet/src/BulletCollision/Jamfile deleted file mode 100644 index 879118357..000000000 --- a/bullet/src/BulletCollision/Jamfile +++ /dev/null @@ -1,14 +0,0 @@ - -SubDir TOP src BulletCollision ; - - -Description bulletcollision : "Bullet Collision Detection" ; -Library bulletcollision : - [ Wildcard Gimpact : *.h *.cpp ] - [ Wildcard BroadphaseCollision : *.h *.cpp ] - [ Wildcard CollisionDispatch : *.h *.cpp ] - [ Wildcard CollisionShapes : *.h *.cpp ] - [ Wildcard NarrowPhaseCollision : *.h *.cpp ] -; -LibDepends bulletcollision : bulletmath ; - diff --git a/bullet/src/BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.cpp b/bullet/src/BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.cpp deleted file mode 100644 index 8a69ba278..000000000 --- a/bullet/src/BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.cpp +++ /dev/null @@ -1,236 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#include "btContinuousConvexCollision.h" -#include "BulletCollision/CollisionShapes/btConvexShape.h" -#include "BulletCollision/NarrowPhaseCollision/btSimplexSolverInterface.h" -#include "LinearMath/btTransformUtil.h" -#include "BulletCollision/CollisionShapes/btSphereShape.h" - -#include "btGjkPairDetector.h" -#include "btPointCollector.h" - - - -btContinuousConvexCollision::btContinuousConvexCollision ( const btConvexShape* convexA,const btConvexShape* convexB,btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* penetrationDepthSolver) -:m_simplexSolver(simplexSolver), -m_penetrationDepthSolver(penetrationDepthSolver), -m_convexA(convexA),m_convexB(convexB) -{ -} - -/// This maximum should not be necessary. It allows for untested/degenerate cases in production code. -/// You don't want your game ever to lock-up. -#define MAX_ITERATIONS 64 - -bool btContinuousConvexCollision::calcTimeOfImpact( - const btTransform& fromA, - const btTransform& toA, - const btTransform& fromB, - const btTransform& toB, - CastResult& result) -{ - - m_simplexSolver->reset(); - - /// compute linear and angular velocity for this interval, to interpolate - btVector3 linVelA,angVelA,linVelB,angVelB; - btTransformUtil::calculateVelocity(fromA,toA,btScalar(1.),linVelA,angVelA); - btTransformUtil::calculateVelocity(fromB,toB,btScalar(1.),linVelB,angVelB); - - - btScalar boundingRadiusA = m_convexA->getAngularMotionDisc(); - btScalar boundingRadiusB = m_convexB->getAngularMotionDisc(); - - btScalar maxAngularProjectedVelocity = angVelA.length() * boundingRadiusA + angVelB.length() * boundingRadiusB; - btVector3 relLinVel = (linVelB-linVelA); - - btScalar relLinVelocLength = (linVelB-linVelA).length(); - - if ((relLinVelocLength+maxAngularProjectedVelocity) == 0.f) - return false; - - - btScalar radius = btScalar(0.001); - - btScalar lambda = btScalar(0.); - btVector3 v(1,0,0); - - int maxIter = MAX_ITERATIONS; - - btVector3 n; - n.setValue(btScalar(0.),btScalar(0.),btScalar(0.)); - bool hasResult = false; - btVector3 c; - - btScalar lastLambda = lambda; - //btScalar epsilon = btScalar(0.001); - - int numIter = 0; - //first solution, using GJK - - - btTransform identityTrans; - identityTrans.setIdentity(); - - btSphereShape raySphere(btScalar(0.0)); - raySphere.setMargin(btScalar(0.)); - - -// result.drawCoordSystem(sphereTr); - - btPointCollector pointCollector1; - - { - - btGjkPairDetector gjk(m_convexA,m_convexB,m_convexA->getShapeType(),m_convexB->getShapeType(),m_convexA->getMargin(),m_convexB->getMargin(),m_simplexSolver,m_penetrationDepthSolver); - btGjkPairDetector::ClosestPointInput input; - - //we don't use margins during CCD - // gjk.setIgnoreMargin(true); - - input.m_transformA = fromA; - input.m_transformB = fromB; - gjk.getClosestPoints(input,pointCollector1,0); - - hasResult = pointCollector1.m_hasResult; - c = pointCollector1.m_pointInWorld; - } - - if (hasResult) - { - btScalar dist; - dist = pointCollector1.m_distance; - n = pointCollector1.m_normalOnBInWorld; - - btScalar projectedLinearVelocity = relLinVel.dot(n); - - //not close enough - while (dist > radius) - { - if (result.m_debugDrawer) - { - result.m_debugDrawer->drawSphere(c,0.2f,btVector3(1,1,1)); - } - numIter++; - if (numIter > maxIter) - { - return false; //todo: report a failure - } - btScalar dLambda = btScalar(0.); - - projectedLinearVelocity = relLinVel.dot(n); - - //calculate safe moving fraction from distance / (linear+rotational velocity) - - //btScalar clippedDist = GEN_min(angularConservativeRadius,dist); - //btScalar clippedDist = dist; - - //don't report time of impact for motion away from the contact normal (or causes minor penetration) - if ((projectedLinearVelocity+ maxAngularProjectedVelocity)<=SIMD_EPSILON) - return false; - - dLambda = dist / (projectedLinearVelocity+ maxAngularProjectedVelocity); - - - - lambda = lambda + dLambda; - - if (lambda > btScalar(1.)) - return false; - - if (lambda < btScalar(0.)) - return false; - - - //todo: next check with relative epsilon - if (lambda <= lastLambda) - { - return false; - //n.setValue(0,0,0); - break; - } - lastLambda = lambda; - - - - //interpolate to next lambda - btTransform interpolatedTransA,interpolatedTransB,relativeTrans; - - btTransformUtil::integrateTransform(fromA,linVelA,angVelA,lambda,interpolatedTransA); - btTransformUtil::integrateTransform(fromB,linVelB,angVelB,lambda,interpolatedTransB); - relativeTrans = interpolatedTransB.inverseTimes(interpolatedTransA); - - if (result.m_debugDrawer) - { - result.m_debugDrawer->drawSphere(interpolatedTransA.getOrigin(),0.2f,btVector3(1,0,0)); - } - - result.DebugDraw( lambda ); - - btPointCollector pointCollector; - btGjkPairDetector gjk(m_convexA,m_convexB,m_simplexSolver,m_penetrationDepthSolver); - btGjkPairDetector::ClosestPointInput input; - input.m_transformA = interpolatedTransA; - input.m_transformB = interpolatedTransB; - gjk.getClosestPoints(input,pointCollector,0); - if (pointCollector.m_hasResult) - { - if (pointCollector.m_distance < btScalar(0.)) - { - //degenerate ?! - result.m_fraction = lastLambda; - n = pointCollector.m_normalOnBInWorld; - result.m_normal=n;//.setValue(1,1,1);// = n; - result.m_hitPoint = pointCollector.m_pointInWorld; - return true; - } - c = pointCollector.m_pointInWorld; - n = pointCollector.m_normalOnBInWorld; - dist = pointCollector.m_distance; - } else - { - //?? - return false; - } - - - } - - if ((projectedLinearVelocity+ maxAngularProjectedVelocity)<=result.m_allowedPenetration)//SIMD_EPSILON) - return false; - - result.m_fraction = lambda; - result.m_normal = n; - result.m_hitPoint = c; - return true; - } - - return false; - -/* -//todo: - //if movement away from normal, discard result - btVector3 move = transBLocalTo.getOrigin() - transBLocalFrom.getOrigin(); - if (result.m_fraction < btScalar(1.)) - { - if (move.dot(result.m_normal) <= btScalar(0.)) - { - } - } -*/ - -} diff --git a/bullet/src/BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.h b/bullet/src/BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.h deleted file mode 100644 index 4121df3be..000000000 --- a/bullet/src/BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#ifndef CONTINUOUS_COLLISION_CONVEX_CAST_H -#define CONTINUOUS_COLLISION_CONVEX_CAST_H - -#include "btConvexCast.h" -#include "btSimplexSolverInterface.h" -class btConvexPenetrationDepthSolver; -class btConvexShape; - -/// btContinuousConvexCollision implements angular and linear time of impact for convex objects. -/// Based on Brian Mirtich's Conservative Advancement idea (PhD thesis). -/// Algorithm operates in worldspace, in order to keep inbetween motion globally consistent. -/// It uses GJK at the moment. Future improvement would use minkowski sum / supporting vertex, merging innerloops -class btContinuousConvexCollision : public btConvexCast -{ - btSimplexSolverInterface* m_simplexSolver; - btConvexPenetrationDepthSolver* m_penetrationDepthSolver; - const btConvexShape* m_convexA; - const btConvexShape* m_convexB; - - -public: - - btContinuousConvexCollision (const btConvexShape* shapeA,const btConvexShape* shapeB ,btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver); - - virtual bool calcTimeOfImpact( - const btTransform& fromA, - const btTransform& toA, - const btTransform& fromB, - const btTransform& toB, - CastResult& result); - - -}; - -#endif //CONTINUOUS_COLLISION_CONVEX_CAST_H - diff --git a/bullet/src/BulletCollision/NarrowPhaseCollision/btConvexCast.cpp b/bullet/src/BulletCollision/NarrowPhaseCollision/btConvexCast.cpp deleted file mode 100644 index dfa1f0a9d..000000000 --- a/bullet/src/BulletCollision/NarrowPhaseCollision/btConvexCast.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btConvexCast.h" - -btConvexCast::~btConvexCast() -{ -} diff --git a/bullet/src/BulletCollision/NarrowPhaseCollision/btConvexCast.h b/bullet/src/BulletCollision/NarrowPhaseCollision/btConvexCast.h deleted file mode 100644 index 35312b356..000000000 --- a/bullet/src/BulletCollision/NarrowPhaseCollision/btConvexCast.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#ifndef CONVEX_CAST_H -#define CONVEX_CAST_H - -#include "LinearMath/btTransform.h" -#include "LinearMath/btVector3.h" -#include "LinearMath/btScalar.h" -class btMinkowskiSumShape; -#include "LinearMath/btIDebugDraw.h" - -/// btConvexCast is an interface for Casting -class btConvexCast -{ -public: - - - virtual ~btConvexCast(); - - ///RayResult stores the closest result - /// alternatively, add a callback method to decide about closest/all results - struct CastResult - { - //virtual bool addRayResult(const btVector3& normal,btScalar fraction) = 0; - - virtual void DebugDraw(btScalar fraction) {(void)fraction;} - virtual void drawCoordSystem(const btTransform& trans) {(void)trans;} - - CastResult() - :m_fraction(btScalar(BT_LARGE_FLOAT)), - m_debugDrawer(0), - m_allowedPenetration(btScalar(0)) - { - } - - - virtual ~CastResult() {}; - - btTransform m_hitTransformA; - btTransform m_hitTransformB; - btVector3 m_normal; - btVector3 m_hitPoint; - btScalar m_fraction; //input and output - btIDebugDraw* m_debugDrawer; - btScalar m_allowedPenetration; - - }; - - - /// cast a convex against another convex object - virtual bool calcTimeOfImpact( - const btTransform& fromA, - const btTransform& toA, - const btTransform& fromB, - const btTransform& toB, - CastResult& result) = 0; -}; - -#endif //CONVEX_CAST_H diff --git a/bullet/src/BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h b/bullet/src/BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h deleted file mode 100644 index 9bd951ca6..000000000 --- a/bullet/src/BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#ifndef __CONVEX_PENETRATION_DEPTH_H -#define __CONVEX_PENETRATION_DEPTH_H - -class btStackAlloc; -class btVector3; -#include "btSimplexSolverInterface.h" -class btConvexShape; -class btTransform; - -///ConvexPenetrationDepthSolver provides an interface for penetration depth calculation. -class btConvexPenetrationDepthSolver -{ -public: - - virtual ~btConvexPenetrationDepthSolver() {}; - virtual bool calcPenDepth( btSimplexSolverInterface& simplexSolver, - const btConvexShape* convexA,const btConvexShape* convexB, - const btTransform& transA,const btTransform& transB, - btVector3& v, btVector3& pa, btVector3& pb, - class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc - ) = 0; - - -}; -#endif //CONVEX_PENETRATION_DEPTH_H - diff --git a/bullet/src/BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h b/bullet/src/BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h deleted file mode 100644 index bfedca52d..000000000 --- a/bullet/src/BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h +++ /dev/null @@ -1,89 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#ifndef DISCRETE_COLLISION_DETECTOR1_INTERFACE_H -#define DISCRETE_COLLISION_DETECTOR1_INTERFACE_H -#include "LinearMath/btTransform.h" -#include "LinearMath/btVector3.h" -class btStackAlloc; - -/// This interface is made to be used by an iterative approach to do TimeOfImpact calculations -/// This interface allows to query for closest points and penetration depth between two (convex) objects -/// the closest point is on the second object (B), and the normal points from the surface on B towards A. -/// distance is between closest points on B and closest point on A. So you can calculate closest point on A -/// by taking closestPointInA = closestPointInB + m_distance * m_normalOnSurfaceB -struct btDiscreteCollisionDetectorInterface -{ - - struct Result - { - - virtual ~Result(){} - - ///setShapeIdentifiersA/B provides experimental support for per-triangle material / custom material combiner - virtual void setShapeIdentifiersA(int partId0,int index0)=0; - virtual void setShapeIdentifiersB(int partId1,int index1)=0; - virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth)=0; - }; - - struct ClosestPointInput - { - ClosestPointInput() - :m_maximumDistanceSquared(btScalar(BT_LARGE_FLOAT)), - m_stackAlloc(0) - { - } - - btTransform m_transformA; - btTransform m_transformB; - btScalar m_maximumDistanceSquared; - btStackAlloc* m_stackAlloc; - }; - - virtual ~btDiscreteCollisionDetectorInterface() {}; - - // - // give either closest points (distance > 0) or penetration (distance) - // the normal always points from B towards A - // - virtual void getClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw,bool swapResults=false) = 0; - -}; - -struct btStorageResult : public btDiscreteCollisionDetectorInterface::Result -{ - btVector3 m_normalOnSurfaceB; - btVector3 m_closestPointInB; - btScalar m_distance; //negative means penetration ! - - btStorageResult() : m_distance(btScalar(BT_LARGE_FLOAT)) - { - - } - virtual ~btStorageResult() {}; - - virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth) - { - if (depth < m_distance) - { - m_normalOnSurfaceB = normalOnBInWorld; - m_closestPointInB = pointInWorld; - m_distance = depth; - } - } -}; - -#endif //DISCRETE_COLLISION_DETECTOR_INTERFACE1_H diff --git a/bullet/src/BulletCollision/NarrowPhaseCollision/btGjkConvexCast.cpp b/bullet/src/BulletCollision/NarrowPhaseCollision/btGjkConvexCast.cpp deleted file mode 100644 index ce72266f4..000000000 --- a/bullet/src/BulletCollision/NarrowPhaseCollision/btGjkConvexCast.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - - -#include "btGjkConvexCast.h" -#include "BulletCollision/CollisionShapes/btSphereShape.h" -#include "btGjkPairDetector.h" -#include "btPointCollector.h" -#include "LinearMath/btTransformUtil.h" - -#ifdef BT_USE_DOUBLE_PRECISION -#define MAX_ITERATIONS 64 -#else -#define MAX_ITERATIONS 32 -#endif - -btGjkConvexCast::btGjkConvexCast(const btConvexShape* convexA,const btConvexShape* convexB,btSimplexSolverInterface* simplexSolver) -:m_simplexSolver(simplexSolver), -m_convexA(convexA), -m_convexB(convexB) -{ -} - -bool btGjkConvexCast::calcTimeOfImpact( - const btTransform& fromA, - const btTransform& toA, - const btTransform& fromB, - const btTransform& toB, - CastResult& result) -{ - - - m_simplexSolver->reset(); - - /// compute linear velocity for this interval, to interpolate - //assume no rotation/angular velocity, assert here? - btVector3 linVelA,linVelB; - linVelA = toA.getOrigin()-fromA.getOrigin(); - linVelB = toB.getOrigin()-fromB.getOrigin(); - - btScalar radius = btScalar(0.001); - btScalar lambda = btScalar(0.); - btVector3 v(1,0,0); - - int maxIter = MAX_ITERATIONS; - - btVector3 n; - n.setValue(btScalar(0.),btScalar(0.),btScalar(0.)); - bool hasResult = false; - btVector3 c; - btVector3 r = (linVelA-linVelB); - - btScalar lastLambda = lambda; - //btScalar epsilon = btScalar(0.001); - - int numIter = 0; - //first solution, using GJK - - - btTransform identityTrans; - identityTrans.setIdentity(); - - -// result.drawCoordSystem(sphereTr); - - btPointCollector pointCollector; - - - btGjkPairDetector gjk(m_convexA,m_convexB,m_simplexSolver,0);//m_penetrationDepthSolver); - btGjkPairDetector::ClosestPointInput input; - - //we don't use margins during CCD - // gjk.setIgnoreMargin(true); - - input.m_transformA = fromA; - input.m_transformB = fromB; - gjk.getClosestPoints(input,pointCollector,0); - - hasResult = pointCollector.m_hasResult; - c = pointCollector.m_pointInWorld; - - if (hasResult) - { - btScalar dist; - dist = pointCollector.m_distance; - n = pointCollector.m_normalOnBInWorld; - - - - //not close enough - while (dist > radius) - { - numIter++; - if (numIter > maxIter) - { - return false; //todo: report a failure - } - btScalar dLambda = btScalar(0.); - - btScalar projectedLinearVelocity = r.dot(n); - - dLambda = dist / (projectedLinearVelocity); - - lambda = lambda - dLambda; - - if (lambda > btScalar(1.)) - return false; - - if (lambda < btScalar(0.)) - return false; - - //todo: next check with relative epsilon - if (lambda <= lastLambda) - { - return false; - //n.setValue(0,0,0); - break; - } - lastLambda = lambda; - - //interpolate to next lambda - result.DebugDraw( lambda ); - input.m_transformA.getOrigin().setInterpolate3(fromA.getOrigin(),toA.getOrigin(),lambda); - input.m_transformB.getOrigin().setInterpolate3(fromB.getOrigin(),toB.getOrigin(),lambda); - - gjk.getClosestPoints(input,pointCollector,0); - if (pointCollector.m_hasResult) - { - if (pointCollector.m_distance < btScalar(0.)) - { - result.m_fraction = lastLambda; - n = pointCollector.m_normalOnBInWorld; - result.m_normal=n; - result.m_hitPoint = pointCollector.m_pointInWorld; - return true; - } - c = pointCollector.m_pointInWorld; - n = pointCollector.m_normalOnBInWorld; - dist = pointCollector.m_distance; - } else - { - //?? - return false; - } - - } - - //is n normalized? - //don't report time of impact for motion away from the contact normal (or causes minor penetration) - if (n.dot(r)>=-result.m_allowedPenetration) - return false; - - result.m_fraction = lambda; - result.m_normal = n; - result.m_hitPoint = c; - return true; - } - - return false; - - -} - diff --git a/bullet/src/BulletCollision/NarrowPhaseCollision/btGjkConvexCast.h b/bullet/src/BulletCollision/NarrowPhaseCollision/btGjkConvexCast.h deleted file mode 100644 index 2fd2ed34c..000000000 --- a/bullet/src/BulletCollision/NarrowPhaseCollision/btGjkConvexCast.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - - -#ifndef GJK_CONVEX_CAST_H -#define GJK_CONVEX_CAST_H - -#include "BulletCollision/CollisionShapes/btCollisionMargin.h" - -#include "LinearMath/btVector3.h" -#include "btConvexCast.h" -class btConvexShape; -class btMinkowskiSumShape; -#include "btSimplexSolverInterface.h" - -///GjkConvexCast performs a raycast on a convex object using support mapping. -class btGjkConvexCast : public btConvexCast -{ - btSimplexSolverInterface* m_simplexSolver; - const btConvexShape* m_convexA; - const btConvexShape* m_convexB; - -public: - - btGjkConvexCast(const btConvexShape* convexA,const btConvexShape* convexB,btSimplexSolverInterface* simplexSolver); - - /// cast a convex against another convex object - virtual bool calcTimeOfImpact( - const btTransform& fromA, - const btTransform& toA, - const btTransform& fromB, - const btTransform& toB, - CastResult& result); - -}; - -#endif //GJK_CONVEX_CAST_H diff --git a/bullet/src/BulletCollision/NarrowPhaseCollision/btGjkEpa2.cpp b/bullet/src/BulletCollision/NarrowPhaseCollision/btGjkEpa2.cpp deleted file mode 100644 index ed9d7279a..000000000 --- a/bullet/src/BulletCollision/NarrowPhaseCollision/btGjkEpa2.cpp +++ /dev/null @@ -1,989 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2008 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the -use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not -claim that you wrote the original software. If you use this software in a -product, an acknowledgment in the product documentation would be appreciated -but is not required. -2. Altered source versions must be plainly marked as such, and must not be -misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -/* -GJK-EPA collision solver by Nathanael Presson, 2008 -*/ -#include "BulletCollision/CollisionShapes/btConvexInternalShape.h" -#include "BulletCollision/CollisionShapes/btSphereShape.h" -#include "btGjkEpa2.h" - -#if defined(DEBUG) || defined (_DEBUG) -#include //for debug printf -#ifdef __SPU__ -#include -#define printf spu_printf -#endif //__SPU__ -#endif - -namespace gjkepa2_impl -{ - - // Config - - /* GJK */ -#define GJK_MAX_ITERATIONS 128 -#define GJK_ACCURARY ((btScalar)0.0001) -#define GJK_MIN_DISTANCE ((btScalar)0.0001) -#define GJK_DUPLICATED_EPS ((btScalar)0.0001) -#define GJK_SIMPLEX2_EPS ((btScalar)0.0) -#define GJK_SIMPLEX3_EPS ((btScalar)0.0) -#define GJK_SIMPLEX4_EPS ((btScalar)0.0) - - /* EPA */ -#define EPA_MAX_VERTICES 64 -#define EPA_MAX_FACES (EPA_MAX_VERTICES*2) -#define EPA_MAX_ITERATIONS 255 -#define EPA_ACCURACY ((btScalar)0.0001) -#define EPA_FALLBACK (10*EPA_ACCURACY) -#define EPA_PLANE_EPS ((btScalar)0.00001) -#define EPA_INSIDE_EPS ((btScalar)0.01) - - - // Shorthands - typedef unsigned int U; - typedef unsigned char U1; - - // MinkowskiDiff - struct MinkowskiDiff - { - const btConvexShape* m_shapes[2]; - btMatrix3x3 m_toshape1; - btTransform m_toshape0; -#ifdef __SPU__ - bool m_enableMargin; -#else - btVector3 (btConvexShape::*Ls)(const btVector3&) const; -#endif//__SPU__ - - - MinkowskiDiff() - { - - } -#ifdef __SPU__ - void EnableMargin(bool enable) - { - m_enableMargin = enable; - } - inline btVector3 Support0(const btVector3& d) const - { - if (m_enableMargin) - { - return m_shapes[0]->localGetSupportVertexNonVirtual(d); - } else - { - return m_shapes[0]->localGetSupportVertexWithoutMarginNonVirtual(d); - } - } - inline btVector3 Support1(const btVector3& d) const - { - if (m_enableMargin) - { - return m_toshape0*(m_shapes[1]->localGetSupportVertexNonVirtual(m_toshape1*d)); - } else - { - return m_toshape0*(m_shapes[1]->localGetSupportVertexWithoutMarginNonVirtual(m_toshape1*d)); - } - } -#else - void EnableMargin(bool enable) - { - if(enable) - Ls=&btConvexShape::localGetSupportVertexNonVirtual; - else - Ls=&btConvexShape::localGetSupportVertexWithoutMarginNonVirtual; - } - inline btVector3 Support0(const btVector3& d) const - { - return(((m_shapes[0])->*(Ls))(d)); - } - inline btVector3 Support1(const btVector3& d) const - { - return(m_toshape0*((m_shapes[1])->*(Ls))(m_toshape1*d)); - } -#endif //__SPU__ - - inline btVector3 Support(const btVector3& d) const - { - return(Support0(d)-Support1(-d)); - } - btVector3 Support(const btVector3& d,U index) const - { - if(index) - return(Support1(d)); - else - return(Support0(d)); - } - }; - - typedef MinkowskiDiff tShape; - - - // GJK - struct GJK - { - /* Types */ - struct sSV - { - btVector3 d,w; - }; - struct sSimplex - { - sSV* c[4]; - btScalar p[4]; - U rank; - }; - struct eStatus { enum _ { - Valid, - Inside, - Failed };}; - /* Fields */ - tShape m_shape; - btVector3 m_ray; - btScalar m_distance; - sSimplex m_simplices[2]; - sSV m_store[4]; - sSV* m_free[4]; - U m_nfree; - U m_current; - sSimplex* m_simplex; - eStatus::_ m_status; - /* Methods */ - GJK() - { - Initialize(); - } - void Initialize() - { - m_ray = btVector3(0,0,0); - m_nfree = 0; - m_status = eStatus::Failed; - m_current = 0; - m_distance = 0; - } - eStatus::_ Evaluate(const tShape& shapearg,const btVector3& guess) - { - U iterations=0; - btScalar sqdist=0; - btScalar alpha=0; - btVector3 lastw[4]; - U clastw=0; - /* Initialize solver */ - m_free[0] = &m_store[0]; - m_free[1] = &m_store[1]; - m_free[2] = &m_store[2]; - m_free[3] = &m_store[3]; - m_nfree = 4; - m_current = 0; - m_status = eStatus::Valid; - m_shape = shapearg; - m_distance = 0; - /* Initialize simplex */ - m_simplices[0].rank = 0; - m_ray = guess; - const btScalar sqrl= m_ray.length2(); - appendvertice(m_simplices[0],sqrl>0?-m_ray:btVector3(1,0,0)); - m_simplices[0].p[0] = 1; - m_ray = m_simplices[0].c[0]->w; - sqdist = sqrl; - lastw[0] = - lastw[1] = - lastw[2] = - lastw[3] = m_ray; - /* Loop */ - do { - const U next=1-m_current; - sSimplex& cs=m_simplices[m_current]; - sSimplex& ns=m_simplices[next]; - /* Check zero */ - const btScalar rl=m_ray.length(); - if(rlw; - bool found=false; - for(U i=0;i<4;++i) - { - if((w-lastw[i]).length2()w, - cs.c[1]->w, - weights,mask);break; - case 3: sqdist=projectorigin( cs.c[0]->w, - cs.c[1]->w, - cs.c[2]->w, - weights,mask);break; - case 4: sqdist=projectorigin( cs.c[0]->w, - cs.c[1]->w, - cs.c[2]->w, - cs.c[3]->w, - weights,mask);break; - } - if(sqdist>=0) - {/* Valid */ - ns.rank = 0; - m_ray = btVector3(0,0,0); - m_current = next; - for(U i=0,ni=cs.rank;iw*weights[i]; - } - else - { - m_free[m_nfree++] = cs.c[i]; - } - } - if(mask==15) m_status=eStatus::Inside; - } - else - {/* Return old simplex */ - removevertice(m_simplices[m_current]); - break; - } - m_status=((++iterations)rank) - { - case 1: - { - for(U i=0;i<3;++i) - { - btVector3 axis=btVector3(0,0,0); - axis[i]=1; - appendvertice(*m_simplex, axis); - if(EncloseOrigin()) return(true); - removevertice(*m_simplex); - appendvertice(*m_simplex,-axis); - if(EncloseOrigin()) return(true); - removevertice(*m_simplex); - } - } - break; - case 2: - { - const btVector3 d=m_simplex->c[1]->w-m_simplex->c[0]->w; - for(U i=0;i<3;++i) - { - btVector3 axis=btVector3(0,0,0); - axis[i]=1; - const btVector3 p=btCross(d,axis); - if(p.length2()>0) - { - appendvertice(*m_simplex, p); - if(EncloseOrigin()) return(true); - removevertice(*m_simplex); - appendvertice(*m_simplex,-p); - if(EncloseOrigin()) return(true); - removevertice(*m_simplex); - } - } - } - break; - case 3: - { - const btVector3 n=btCross(m_simplex->c[1]->w-m_simplex->c[0]->w, - m_simplex->c[2]->w-m_simplex->c[0]->w); - if(n.length2()>0) - { - appendvertice(*m_simplex,n); - if(EncloseOrigin()) return(true); - removevertice(*m_simplex); - appendvertice(*m_simplex,-n); - if(EncloseOrigin()) return(true); - removevertice(*m_simplex); - } - } - break; - case 4: - { - if(btFabs(det( m_simplex->c[0]->w-m_simplex->c[3]->w, - m_simplex->c[1]->w-m_simplex->c[3]->w, - m_simplex->c[2]->w-m_simplex->c[3]->w))>0) - return(true); - } - break; - } - return(false); - } - /* Internals */ - void getsupport(const btVector3& d,sSV& sv) const - { - sv.d = d/d.length(); - sv.w = m_shape.Support(sv.d); - } - void removevertice(sSimplex& simplex) - { - m_free[m_nfree++]=simplex.c[--simplex.rank]; - } - void appendvertice(sSimplex& simplex,const btVector3& v) - { - simplex.p[simplex.rank]=0; - simplex.c[simplex.rank]=m_free[--m_nfree]; - getsupport(v,*simplex.c[simplex.rank++]); - } - static btScalar det(const btVector3& a,const btVector3& b,const btVector3& c) - { - return( a.y()*b.z()*c.x()+a.z()*b.x()*c.y()- - a.x()*b.z()*c.y()-a.y()*b.x()*c.z()+ - a.x()*b.y()*c.z()-a.z()*b.y()*c.x()); - } - static btScalar projectorigin( const btVector3& a, - const btVector3& b, - btScalar* w,U& m) - { - const btVector3 d=b-a; - const btScalar l=d.length2(); - if(l>GJK_SIMPLEX2_EPS) - { - const btScalar t(l>0?-btDot(a,d)/l:0); - if(t>=1) { w[0]=0;w[1]=1;m=2;return(b.length2()); } - else if(t<=0) { w[0]=1;w[1]=0;m=1;return(a.length2()); } - else { w[0]=1-(w[1]=t);m=3;return((a+d*t).length2()); } - } - return(-1); - } - static btScalar projectorigin( const btVector3& a, - const btVector3& b, - const btVector3& c, - btScalar* w,U& m) - { - static const U imd3[]={1,2,0}; - const btVector3* vt[]={&a,&b,&c}; - const btVector3 dl[]={a-b,b-c,c-a}; - const btVector3 n=btCross(dl[0],dl[1]); - const btScalar l=n.length2(); - if(l>GJK_SIMPLEX3_EPS) - { - btScalar mindist=-1; - btScalar subw[2]={0.f,0.f}; - U subm(0); - for(U i=0;i<3;++i) - { - if(btDot(*vt[i],btCross(dl[i],n))>0) - { - const U j=imd3[i]; - const btScalar subd(projectorigin(*vt[i],*vt[j],subw,subm)); - if((mindist<0)||(subd(((subm&1)?1<GJK_SIMPLEX4_EPS)) - { - btScalar mindist=-1; - btScalar subw[3]={0.f,0.f,0.f}; - U subm(0); - for(U i=0;i<3;++i) - { - const U j=imd3[i]; - const btScalar s=vl*btDot(d,btCross(dl[i],dl[j])); - if(s>0) - { - const btScalar subd=projectorigin(*vt[i],*vt[j],d,subw,subm); - if((mindist<0)||(subd((subm&1?1<e[ea]=(U1)eb;fa->f[ea]=fb; - fb->e[eb]=(U1)ea;fb->f[eb]=fa; - } - static inline void append(sList& list,sFace* face) - { - face->l[0] = 0; - face->l[1] = list.root; - if(list.root) list.root->l[0]=face; - list.root = face; - ++list.count; - } - static inline void remove(sList& list,sFace* face) - { - if(face->l[1]) face->l[1]->l[0]=face->l[0]; - if(face->l[0]) face->l[0]->l[1]=face->l[1]; - if(face==list.root) list.root=face->l[1]; - --list.count; - } - - - void Initialize() - { - m_status = eStatus::Failed; - m_normal = btVector3(0,0,0); - m_depth = 0; - m_nextsv = 0; - for(U i=0;i1)&&gjk.EncloseOrigin()) - { - - /* Clean up */ - while(m_hull.root) - { - sFace* f = m_hull.root; - remove(m_hull,f); - append(m_stock,f); - } - m_status = eStatus::Valid; - m_nextsv = 0; - /* Orient simplex */ - if(gjk.det( simplex.c[0]->w-simplex.c[3]->w, - simplex.c[1]->w-simplex.c[3]->w, - simplex.c[2]->w-simplex.c[3]->w)<0) - { - btSwap(simplex.c[0],simplex.c[1]); - btSwap(simplex.p[0],simplex.p[1]); - } - /* Build initial hull */ - sFace* tetra[]={newface(simplex.c[0],simplex.c[1],simplex.c[2],true), - newface(simplex.c[1],simplex.c[0],simplex.c[3],true), - newface(simplex.c[2],simplex.c[1],simplex.c[3],true), - newface(simplex.c[0],simplex.c[2],simplex.c[3],true)}; - if(m_hull.count==4) - { - sFace* best=findbest(); - sFace outer=*best; - U pass=0; - U iterations=0; - bind(tetra[0],0,tetra[1],0); - bind(tetra[0],1,tetra[2],0); - bind(tetra[0],2,tetra[3],0); - bind(tetra[1],1,tetra[3],2); - bind(tetra[1],2,tetra[2],1); - bind(tetra[2],2,tetra[3],1); - m_status=eStatus::Valid; - for(;iterationspass = (U1)(++pass); - gjk.getsupport(best->n,*w); - const btScalar wdist=btDot(best->n,w->w)-best->d; - if(wdist>EPA_ACCURACY) - { - for(U j=0;(j<3)&&valid;++j) - { - valid&=expand( pass,w, - best->f[j],best->e[j], - horizon); - } - if(valid&&(horizon.nf>=3)) - { - bind(horizon.cf,1,horizon.ff,2); - remove(m_hull,best); - append(m_stock,best); - best=findbest(); - if(best->p>=outer.p) outer=*best; - } else { m_status=eStatus::InvalidHull;break; } - } else { m_status=eStatus::AccuraryReached;break; } - } else { m_status=eStatus::OutOfVertices;break; } - } - const btVector3 projection=outer.n*outer.d; - m_normal = outer.n; - m_depth = outer.d; - m_result.rank = 3; - m_result.c[0] = outer.c[0]; - m_result.c[1] = outer.c[1]; - m_result.c[2] = outer.c[2]; - m_result.p[0] = btCross( outer.c[1]->w-projection, - outer.c[2]->w-projection).length(); - m_result.p[1] = btCross( outer.c[2]->w-projection, - outer.c[0]->w-projection).length(); - m_result.p[2] = btCross( outer.c[0]->w-projection, - outer.c[1]->w-projection).length(); - const btScalar sum=m_result.p[0]+m_result.p[1]+m_result.p[2]; - m_result.p[0] /= sum; - m_result.p[1] /= sum; - m_result.p[2] /= sum; - return(m_status); - } - } - /* Fallback */ - m_status = eStatus::FallBack; - m_normal = -guess; - const btScalar nl=m_normal.length(); - if(nl>0) - m_normal = m_normal/nl; - else - m_normal = btVector3(1,0,0); - m_depth = 0; - m_result.rank=1; - m_result.c[0]=simplex.c[0]; - m_result.p[0]=1; - return(m_status); - } - sFace* newface(sSV* a,sSV* b,sSV* c,bool forced) - { - if(m_stock.root) - { - sFace* face=m_stock.root; - remove(m_stock,face); - append(m_hull,face); - face->pass = 0; - face->c[0] = a; - face->c[1] = b; - face->c[2] = c; - face->n = btCross(b->w-a->w,c->w-a->w); - const btScalar l=face->n.length(); - const bool v=l>EPA_ACCURACY; - face->p = btMin(btMin( - btDot(a->w,btCross(face->n,a->w-b->w)), - btDot(b->w,btCross(face->n,b->w-c->w))), - btDot(c->w,btCross(face->n,c->w-a->w))) / - (v?l:1); - face->p = face->p>=-EPA_INSIDE_EPS?0:face->p; - if(v) - { - face->d = btDot(a->w,face->n)/l; - face->n /= l; - if(forced||(face->d>=-EPA_PLANE_EPS)) - { - return(face); - } else m_status=eStatus::NonConvex; - } else m_status=eStatus::Degenerated; - remove(m_hull,face); - append(m_stock,face); - return(0); - } - m_status=m_stock.root?eStatus::OutOfVertices:eStatus::OutOfFaces; - return(0); - } - sFace* findbest() - { - sFace* minf=m_hull.root; - btScalar mind=minf->d*minf->d; - btScalar maxp=minf->p; - for(sFace* f=minf->l[1];f;f=f->l[1]) - { - const btScalar sqd=f->d*f->d; - if((f->p>=maxp)&&(sqdp; - } - } - return(minf); - } - bool expand(U pass,sSV* w,sFace* f,U e,sHorizon& horizon) - { - static const U i1m3[]={1,2,0}; - static const U i2m3[]={2,0,1}; - if(f->pass!=pass) - { - const U e1=i1m3[e]; - if((btDot(f->n,w->w)-f->d)<-EPA_PLANE_EPS) - { - sFace* nf=newface(f->c[e1],f->c[e],w,false); - if(nf) - { - bind(nf,0,f,e); - if(horizon.cf) bind(horizon.cf,1,nf,2); else horizon.ff=nf; - horizon.cf=nf; - ++horizon.nf; - return(true); - } - } - else - { - const U e2=i2m3[e]; - f->pass = (U1)pass; - if( expand(pass,w,f->f[e1],f->e[e1],horizon)&& - expand(pass,w,f->f[e2],f->e[e2],horizon)) - { - remove(m_hull,f); - append(m_stock,f); - return(true); - } - } - } - return(false); - } - - }; - - // - static void Initialize( const btConvexShape* shape0,const btTransform& wtrs0, - const btConvexShape* shape1,const btTransform& wtrs1, - btGjkEpaSolver2::sResults& results, - tShape& shape, - bool withmargins) - { - /* Results */ - results.witnesses[0] = - results.witnesses[1] = btVector3(0,0,0); - results.status = btGjkEpaSolver2::sResults::Separated; - /* Shape */ - shape.m_shapes[0] = shape0; - shape.m_shapes[1] = shape1; - shape.m_toshape1 = wtrs1.getBasis().transposeTimes(wtrs0.getBasis()); - shape.m_toshape0 = wtrs0.inverseTimes(wtrs1); - shape.EnableMargin(withmargins); - } - -} - -// -// Api -// - -using namespace gjkepa2_impl; - -// -int btGjkEpaSolver2::StackSizeRequirement() -{ - return(sizeof(GJK)+sizeof(EPA)); -} - -// -bool btGjkEpaSolver2::Distance( const btConvexShape* shape0, - const btTransform& wtrs0, - const btConvexShape* shape1, - const btTransform& wtrs1, - const btVector3& guess, - sResults& results) -{ - tShape shape; - Initialize(shape0,wtrs0,shape1,wtrs1,results,shape,false); - GJK gjk; - GJK::eStatus::_ gjk_status=gjk.Evaluate(shape,guess); - if(gjk_status==GJK::eStatus::Valid) - { - btVector3 w0=btVector3(0,0,0); - btVector3 w1=btVector3(0,0,0); - for(U i=0;irank;++i) - { - const btScalar p=gjk.m_simplex->p[i]; - w0+=shape.Support( gjk.m_simplex->c[i]->d,0)*p; - w1+=shape.Support(-gjk.m_simplex->c[i]->d,1)*p; - } - results.witnesses[0] = wtrs0*w0; - results.witnesses[1] = wtrs0*w1; - results.normal = w0-w1; - results.distance = results.normal.length(); - results.normal /= results.distance>GJK_MIN_DISTANCE?results.distance:1; - return(true); - } - else - { - results.status = gjk_status==GJK::eStatus::Inside? - sResults::Penetrating : - sResults::GJK_Failed ; - return(false); - } -} - -// -bool btGjkEpaSolver2::Penetration( const btConvexShape* shape0, - const btTransform& wtrs0, - const btConvexShape* shape1, - const btTransform& wtrs1, - const btVector3& guess, - sResults& results, - bool usemargins) -{ - tShape shape; - Initialize(shape0,wtrs0,shape1,wtrs1,results,shape,usemargins); - GJK gjk; - GJK::eStatus::_ gjk_status=gjk.Evaluate(shape,-guess); - switch(gjk_status) - { - case GJK::eStatus::Inside: - { - EPA epa; - EPA::eStatus::_ epa_status=epa.Evaluate(gjk,-guess); - if(epa_status!=EPA::eStatus::Failed) - { - btVector3 w0=btVector3(0,0,0); - for(U i=0;id,0)*epa.m_result.p[i]; - } - results.status = sResults::Penetrating; - results.witnesses[0] = wtrs0*w0; - results.witnesses[1] = wtrs0*(w0-epa.m_normal*epa.m_depth); - results.normal = -epa.m_normal; - results.distance = -epa.m_depth; - return(true); - } else results.status=sResults::EPA_Failed; - } - break; - case GJK::eStatus::Failed: - results.status=sResults::GJK_Failed; - break; - default: - { - } - } - return(false); -} - -#ifndef __SPU__ -// -btScalar btGjkEpaSolver2::SignedDistance(const btVector3& position, - btScalar margin, - const btConvexShape* shape0, - const btTransform& wtrs0, - sResults& results) -{ - tShape shape; - btSphereShape shape1(margin); - btTransform wtrs1(btQuaternion(0,0,0,1),position); - Initialize(shape0,wtrs0,&shape1,wtrs1,results,shape,false); - GJK gjk; - GJK::eStatus::_ gjk_status=gjk.Evaluate(shape,btVector3(1,1,1)); - if(gjk_status==GJK::eStatus::Valid) - { - btVector3 w0=btVector3(0,0,0); - btVector3 w1=btVector3(0,0,0); - for(U i=0;irank;++i) - { - const btScalar p=gjk.m_simplex->p[i]; - w0+=shape.Support( gjk.m_simplex->c[i]->d,0)*p; - w1+=shape.Support(-gjk.m_simplex->c[i]->d,1)*p; - } - results.witnesses[0] = wtrs0*w0; - results.witnesses[1] = wtrs0*w1; - const btVector3 delta= results.witnesses[1]- - results.witnesses[0]; - const btScalar margin= shape0->getMarginNonVirtual()+ - shape1.getMarginNonVirtual(); - const btScalar length= delta.length(); - results.normal = delta/length; - results.witnesses[0] += results.normal*margin; - return(length-margin); - } - else - { - if(gjk_status==GJK::eStatus::Inside) - { - if(Penetration(shape0,wtrs0,&shape1,wtrs1,gjk.m_ray,results)) - { - const btVector3 delta= results.witnesses[0]- - results.witnesses[1]; - const btScalar length= delta.length(); - if (length >= SIMD_EPSILON) - results.normal = delta/length; - return(-length); - } - } - } - return(SIMD_INFINITY); -} - -// -bool btGjkEpaSolver2::SignedDistance(const btConvexShape* shape0, - const btTransform& wtrs0, - const btConvexShape* shape1, - const btTransform& wtrs1, - const btVector3& guess, - sResults& results) -{ - if(!Distance(shape0,wtrs0,shape1,wtrs1,guess,results)) - return(Penetration(shape0,wtrs0,shape1,wtrs1,guess,results,false)); - else - return(true); -} -#endif //__SPU__ - -/* Symbols cleanup */ - -#undef GJK_MAX_ITERATIONS -#undef GJK_ACCURARY -#undef GJK_MIN_DISTANCE -#undef GJK_DUPLICATED_EPS -#undef GJK_SIMPLEX2_EPS -#undef GJK_SIMPLEX3_EPS -#undef GJK_SIMPLEX4_EPS - -#undef EPA_MAX_VERTICES -#undef EPA_MAX_FACES -#undef EPA_MAX_ITERATIONS -#undef EPA_ACCURACY -#undef EPA_FALLBACK -#undef EPA_PLANE_EPS -#undef EPA_INSIDE_EPS diff --git a/bullet/src/BulletCollision/NarrowPhaseCollision/btGjkEpa2.h b/bullet/src/BulletCollision/NarrowPhaseCollision/btGjkEpa2.h deleted file mode 100644 index cda1c18ed..000000000 --- a/bullet/src/BulletCollision/NarrowPhaseCollision/btGjkEpa2.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2008 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the -use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not -claim that you wrote the original software. If you use this software in a -product, an acknowledgment in the product documentation would be appreciated -but is not required. -2. Altered source versions must be plainly marked as such, and must not be -misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -/* -GJK-EPA collision solver by Nathanael Presson, 2008 -*/ -#ifndef _68DA1F85_90B7_4bb0_A705_83B4040A75C6_ -#define _68DA1F85_90B7_4bb0_A705_83B4040A75C6_ -#include "BulletCollision/CollisionShapes/btConvexShape.h" - -///btGjkEpaSolver contributed under zlib by Nathanael Presson -struct btGjkEpaSolver2 -{ -struct sResults - { - enum eStatus - { - Separated, /* Shapes doesnt penetrate */ - Penetrating, /* Shapes are penetrating */ - GJK_Failed, /* GJK phase fail, no big issue, shapes are probably just 'touching' */ - EPA_Failed /* EPA phase fail, bigger problem, need to save parameters, and debug */ - } status; - btVector3 witnesses[2]; - btVector3 normal; - btScalar distance; - }; - -static int StackSizeRequirement(); - -static bool Distance( const btConvexShape* shape0,const btTransform& wtrs0, - const btConvexShape* shape1,const btTransform& wtrs1, - const btVector3& guess, - sResults& results); - -static bool Penetration(const btConvexShape* shape0,const btTransform& wtrs0, - const btConvexShape* shape1,const btTransform& wtrs1, - const btVector3& guess, - sResults& results, - bool usemargins=true); -#ifndef __SPU__ -static btScalar SignedDistance( const btVector3& position, - btScalar margin, - const btConvexShape* shape, - const btTransform& wtrs, - sResults& results); - -static bool SignedDistance( const btConvexShape* shape0,const btTransform& wtrs0, - const btConvexShape* shape1,const btTransform& wtrs1, - const btVector3& guess, - sResults& results); -#endif //__SPU__ - -}; - -#endif diff --git a/bullet/src/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp b/bullet/src/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp deleted file mode 100644 index 9c26fe465..000000000 --- a/bullet/src/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -EPA Copyright (c) Ricardo Padrela 2006 - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "BulletCollision/CollisionShapes/btConvexShape.h" -#include "btGjkEpaPenetrationDepthSolver.h" - - -#include "BulletCollision/NarrowPhaseCollision/btGjkEpa2.h" - -bool btGjkEpaPenetrationDepthSolver::calcPenDepth( btSimplexSolverInterface& simplexSolver, - const btConvexShape* pConvexA, const btConvexShape* pConvexB, - const btTransform& transformA, const btTransform& transformB, - btVector3& v, btVector3& wWitnessOnA, btVector3& wWitnessOnB, - class btIDebugDraw* debugDraw, btStackAlloc* stackAlloc ) -{ - - (void)debugDraw; - (void)v; - (void)simplexSolver; - -// const btScalar radialmargin(btScalar(0.)); - - btVector3 guessVector(transformA.getOrigin()-transformB.getOrigin()); - btGjkEpaSolver2::sResults results; - - - if(btGjkEpaSolver2::Penetration(pConvexA,transformA, - pConvexB,transformB, - guessVector,results)) - - { - // debugDraw->drawLine(results.witnesses[1],results.witnesses[1]+results.normal,btVector3(255,0,0)); - //resultOut->addContactPoint(results.normal,results.witnesses[1],-results.depth); - wWitnessOnA = results.witnesses[0]; - wWitnessOnB = results.witnesses[1]; - v = results.normal; - return true; - } else - { - if(btGjkEpaSolver2::Distance(pConvexA,transformA,pConvexB,transformB,guessVector,results)) - { - wWitnessOnA = results.witnesses[0]; - wWitnessOnB = results.witnesses[1]; - v = results.normal; - return false; - } - } - - return false; -} - - diff --git a/bullet/src/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h b/bullet/src/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h deleted file mode 100644 index 417b95245..000000000 --- a/bullet/src/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -EPA Copyright (c) Ricardo Padrela 2006 - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ -#ifndef BT_GJP_EPA_PENETRATION_DEPTH_H -#define BT_GJP_EPA_PENETRATION_DEPTH_H - -#include "btConvexPenetrationDepthSolver.h" - -///EpaPenetrationDepthSolver uses the Expanding Polytope Algorithm to -///calculate the penetration depth between two convex shapes. -class btGjkEpaPenetrationDepthSolver : public btConvexPenetrationDepthSolver -{ - public : - - btGjkEpaPenetrationDepthSolver() - { - } - - bool calcPenDepth( btSimplexSolverInterface& simplexSolver, - const btConvexShape* pConvexA, const btConvexShape* pConvexB, - const btTransform& transformA, const btTransform& transformB, - btVector3& v, btVector3& wWitnessOnA, btVector3& wWitnessOnB, - class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc ); - - private : - -}; - -#endif // BT_GJP_EPA_PENETRATION_DEPTH_H - diff --git a/bullet/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp b/bullet/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp deleted file mode 100644 index 7b145c4a2..000000000 --- a/bullet/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp +++ /dev/null @@ -1,456 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btGjkPairDetector.h" -#include "BulletCollision/CollisionShapes/btConvexShape.h" -#include "BulletCollision/NarrowPhaseCollision/btSimplexSolverInterface.h" -#include "BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h" - - - -#if defined(DEBUG) || defined (_DEBUG) -//#define TEST_NON_VIRTUAL 1 -#include //for debug printf -#ifdef __SPU__ -#include -#define printf spu_printf -//#define DEBUG_SPU_COLLISION_DETECTION 1 -#endif //__SPU__ -#endif - -//must be above the machine epsilon -#define REL_ERROR2 btScalar(1.0e-6) - -//temp globals, to improve GJK/EPA/penetration calculations -int gNumDeepPenetrationChecks = 0; -int gNumGjkChecks = 0; - - -btGjkPairDetector::btGjkPairDetector(const btConvexShape* objectA,const btConvexShape* objectB,btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver) -:m_cachedSeparatingAxis(btScalar(0.),btScalar(1.),btScalar(0.)), -m_penetrationDepthSolver(penetrationDepthSolver), -m_simplexSolver(simplexSolver), -m_minkowskiA(objectA), -m_minkowskiB(objectB), -m_shapeTypeA(objectA->getShapeType()), -m_shapeTypeB(objectB->getShapeType()), -m_marginA(objectA->getMargin()), -m_marginB(objectB->getMargin()), -m_ignoreMargin(false), -m_lastUsedMethod(-1), -m_catchDegeneracies(1) -{ -} -btGjkPairDetector::btGjkPairDetector(const btConvexShape* objectA,const btConvexShape* objectB,int shapeTypeA,int shapeTypeB,btScalar marginA, btScalar marginB, btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver) -:m_cachedSeparatingAxis(btScalar(0.),btScalar(1.),btScalar(0.)), -m_penetrationDepthSolver(penetrationDepthSolver), -m_simplexSolver(simplexSolver), -m_minkowskiA(objectA), -m_minkowskiB(objectB), -m_shapeTypeA(shapeTypeA), -m_shapeTypeB(shapeTypeB), -m_marginA(marginA), -m_marginB(marginB), -m_ignoreMargin(false), -m_lastUsedMethod(-1), -m_catchDegeneracies(1) -{ -} - -void btGjkPairDetector::getClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw,bool swapResults) -{ - (void)swapResults; - - getClosestPointsNonVirtual(input,output,debugDraw); -} - -#ifdef __SPU__ -void btGjkPairDetector::getClosestPointsNonVirtual(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw) -#else -void btGjkPairDetector::getClosestPointsNonVirtual(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw) -#endif -{ - m_cachedSeparatingDistance = 0.f; - - btScalar distance=btScalar(0.); - btVector3 normalInB(btScalar(0.),btScalar(0.),btScalar(0.)); - btVector3 pointOnA,pointOnB; - btTransform localTransA = input.m_transformA; - btTransform localTransB = input.m_transformB; - btVector3 positionOffset = (localTransA.getOrigin() + localTransB.getOrigin()) * btScalar(0.5); - localTransA.getOrigin() -= positionOffset; - localTransB.getOrigin() -= positionOffset; - - bool check2d = m_minkowskiA->isConvex2d() && m_minkowskiB->isConvex2d(); - - btScalar marginA = m_marginA; - btScalar marginB = m_marginB; - - gNumGjkChecks++; - -#ifdef DEBUG_SPU_COLLISION_DETECTION - spu_printf("inside gjk\n"); -#endif - //for CCD we don't use margins - if (m_ignoreMargin) - { - marginA = btScalar(0.); - marginB = btScalar(0.); -#ifdef DEBUG_SPU_COLLISION_DETECTION - spu_printf("ignoring margin\n"); -#endif - } - - m_curIter = 0; - int gGjkMaxIter = 1000;//this is to catch invalid input, perhaps check for #NaN? - m_cachedSeparatingAxis.setValue(0,1,0); - - bool isValid = false; - bool checkSimplex = false; - bool checkPenetration = true; - m_degenerateSimplex = 0; - - m_lastUsedMethod = -1; - - { - btScalar squaredDistance = BT_LARGE_FLOAT; - btScalar delta = btScalar(0.); - - btScalar margin = marginA + marginB; - - - - m_simplexSolver->reset(); - - for ( ; ; ) - //while (true) - { - - btVector3 seperatingAxisInA = (-m_cachedSeparatingAxis)* input.m_transformA.getBasis(); - btVector3 seperatingAxisInB = m_cachedSeparatingAxis* input.m_transformB.getBasis(); - -#if 1 - - btVector3 pInA = m_minkowskiA->localGetSupportVertexWithoutMarginNonVirtual(seperatingAxisInA); - btVector3 qInB = m_minkowskiB->localGetSupportVertexWithoutMarginNonVirtual(seperatingAxisInB); - -// btVector3 pInA = localGetSupportingVertexWithoutMargin(m_shapeTypeA, m_minkowskiA, seperatingAxisInA,input.m_convexVertexData[0]);//, &featureIndexA); -// btVector3 qInB = localGetSupportingVertexWithoutMargin(m_shapeTypeB, m_minkowskiB, seperatingAxisInB,input.m_convexVertexData[1]);//, &featureIndexB); - -#else -#ifdef __SPU__ - btVector3 pInA = m_minkowskiA->localGetSupportVertexWithoutMarginNonVirtual(seperatingAxisInA); - btVector3 qInB = m_minkowskiB->localGetSupportVertexWithoutMarginNonVirtual(seperatingAxisInB); -#else - btVector3 pInA = m_minkowskiA->localGetSupportingVertexWithoutMargin(seperatingAxisInA); - btVector3 qInB = m_minkowskiB->localGetSupportingVertexWithoutMargin(seperatingAxisInB); -#ifdef TEST_NON_VIRTUAL - btVector3 pInAv = m_minkowskiA->localGetSupportingVertexWithoutMargin(seperatingAxisInA); - btVector3 qInBv = m_minkowskiB->localGetSupportingVertexWithoutMargin(seperatingAxisInB); - btAssert((pInAv-pInA).length() < 0.0001); - btAssert((qInBv-qInB).length() < 0.0001); -#endif // -#endif //__SPU__ -#endif - - - btVector3 pWorld = localTransA(pInA); - btVector3 qWorld = localTransB(qInB); - -#ifdef DEBUG_SPU_COLLISION_DETECTION - spu_printf("got local supporting vertices\n"); -#endif - - if (check2d) - { - pWorld[2] = 0.f; - qWorld[2] = 0.f; - } - - btVector3 w = pWorld - qWorld; - delta = m_cachedSeparatingAxis.dot(w); - - // potential exit, they don't overlap - if ((delta > btScalar(0.0)) && (delta * delta > squaredDistance * input.m_maximumDistanceSquared)) - { - m_degenerateSimplex = 10; - checkSimplex=true; - //checkPenetration = false; - break; - } - - //exit 0: the new point is already in the simplex, or we didn't come any closer - if (m_simplexSolver->inSimplex(w)) - { - m_degenerateSimplex = 1; - checkSimplex = true; - break; - } - // are we getting any closer ? - btScalar f0 = squaredDistance - delta; - btScalar f1 = squaredDistance * REL_ERROR2; - - if (f0 <= f1) - { - if (f0 <= btScalar(0.)) - { - m_degenerateSimplex = 2; - } else - { - m_degenerateSimplex = 11; - } - checkSimplex = true; - break; - } - -#ifdef DEBUG_SPU_COLLISION_DETECTION - spu_printf("addVertex 1\n"); -#endif - //add current vertex to simplex - m_simplexSolver->addVertex(w, pWorld, qWorld); -#ifdef DEBUG_SPU_COLLISION_DETECTION - spu_printf("addVertex 2\n"); -#endif - btVector3 newCachedSeparatingAxis; - - //calculate the closest point to the origin (update vector v) - if (!m_simplexSolver->closest(newCachedSeparatingAxis)) - { - m_degenerateSimplex = 3; - checkSimplex = true; - break; - } - - if(newCachedSeparatingAxis.length2()previousSquaredDistance) - { - m_degenerateSimplex = 7; - squaredDistance = previousSquaredDistance; - checkSimplex = false; - break; - } -#endif // - - m_cachedSeparatingAxis = newCachedSeparatingAxis; - - //redundant m_simplexSolver->compute_points(pointOnA, pointOnB); - - //are we getting any closer ? - if (previousSquaredDistance - squaredDistance <= SIMD_EPSILON * previousSquaredDistance) - { - m_simplexSolver->backup_closest(m_cachedSeparatingAxis); - checkSimplex = true; - m_degenerateSimplex = 12; - - break; - } - - //degeneracy, this is typically due to invalid/uninitialized worldtransforms for a btCollisionObject - if (m_curIter++ > gGjkMaxIter) - { - #if defined(DEBUG) || defined (_DEBUG) || defined (DEBUG_SPU_COLLISION_DETECTION) - - printf("btGjkPairDetector maxIter exceeded:%i\n",m_curIter); - printf("sepAxis=(%f,%f,%f), squaredDistance = %f, shapeTypeA=%i,shapeTypeB=%i\n", - m_cachedSeparatingAxis.getX(), - m_cachedSeparatingAxis.getY(), - m_cachedSeparatingAxis.getZ(), - squaredDistance, - m_minkowskiA->getShapeType(), - m_minkowskiB->getShapeType()); - - #endif - break; - - } - - - bool check = (!m_simplexSolver->fullSimplex()); - //bool check = (!m_simplexSolver->fullSimplex() && squaredDistance > SIMD_EPSILON * m_simplexSolver->maxVertex()); - - if (!check) - { - //do we need this backup_closest here ? - m_simplexSolver->backup_closest(m_cachedSeparatingAxis); - m_degenerateSimplex = 13; - break; - } - } - - if (checkSimplex) - { - m_simplexSolver->compute_points(pointOnA, pointOnB); - normalInB = pointOnA-pointOnB; - btScalar lenSqr =m_cachedSeparatingAxis.length2(); - - //valid normal - if (lenSqr < 0.0001) - { - m_degenerateSimplex = 5; - } - if (lenSqr > SIMD_EPSILON*SIMD_EPSILON) - { - btScalar rlen = btScalar(1.) / btSqrt(lenSqr ); - normalInB *= rlen; //normalize - btScalar s = btSqrt(squaredDistance); - - btAssert(s > btScalar(0.0)); - pointOnA -= m_cachedSeparatingAxis * (marginA / s); - pointOnB += m_cachedSeparatingAxis * (marginB / s); - distance = ((btScalar(1.)/rlen) - margin); - isValid = true; - - m_lastUsedMethod = 1; - } else - { - m_lastUsedMethod = 2; - } - } - - bool catchDegeneratePenetrationCase = - (m_catchDegeneracies && m_penetrationDepthSolver && m_degenerateSimplex && ((distance+margin) < 0.01)); - - //if (checkPenetration && !isValid) - if (checkPenetration && (!isValid || catchDegeneratePenetrationCase )) - { - //penetration case - - //if there is no way to handle penetrations, bail out - if (m_penetrationDepthSolver) - { - // Penetration depth case. - btVector3 tmpPointOnA,tmpPointOnB; - - gNumDeepPenetrationChecks++; - m_cachedSeparatingAxis.setZero(); - - bool isValid2 = m_penetrationDepthSolver->calcPenDepth( - *m_simplexSolver, - m_minkowskiA,m_minkowskiB, - localTransA,localTransB, - m_cachedSeparatingAxis, tmpPointOnA, tmpPointOnB, - debugDraw,input.m_stackAlloc - ); - - - if (isValid2) - { - btVector3 tmpNormalInB = tmpPointOnB-tmpPointOnA; - btScalar lenSqr = tmpNormalInB.length2(); - if (lenSqr <= (SIMD_EPSILON*SIMD_EPSILON)) - { - tmpNormalInB = m_cachedSeparatingAxis; - lenSqr = m_cachedSeparatingAxis.length2(); - } - - if (lenSqr > (SIMD_EPSILON*SIMD_EPSILON)) - { - tmpNormalInB /= btSqrt(lenSqr); - btScalar distance2 = -(tmpPointOnA-tmpPointOnB).length(); - //only replace valid penetrations when the result is deeper (check) - if (!isValid || (distance2 < distance)) - { - distance = distance2; - pointOnA = tmpPointOnA; - pointOnB = tmpPointOnB; - normalInB = tmpNormalInB; - isValid = true; - m_lastUsedMethod = 3; - } else - { - m_lastUsedMethod = 8; - } - } else - { - m_lastUsedMethod = 9; - } - } else - - { - ///this is another degenerate case, where the initial GJK calculation reports a degenerate case - ///EPA reports no penetration, and the second GJK (using the supporting vector without margin) - ///reports a valid positive distance. Use the results of the second GJK instead of failing. - ///thanks to Jacob.Langford for the reproduction case - ///http://code.google.com/p/bullet/issues/detail?id=250 - - - if (m_cachedSeparatingAxis.length2() > btScalar(0.)) - { - btScalar distance2 = (tmpPointOnA-tmpPointOnB).length()-margin; - //only replace valid distances when the distance is less - if (!isValid || (distance2 < distance)) - { - distance = distance2; - pointOnA = tmpPointOnA; - pointOnB = tmpPointOnB; - pointOnA -= m_cachedSeparatingAxis * marginA ; - pointOnB += m_cachedSeparatingAxis * marginB ; - normalInB = m_cachedSeparatingAxis; - normalInB.normalize(); - isValid = true; - m_lastUsedMethod = 6; - } else - { - m_lastUsedMethod = 5; - } - } - } - - } - - } - } - - - - if (isValid && ((distance < 0) || (distance*distance < input.m_maximumDistanceSquared))) - { -#if 0 -///some debugging -// if (check2d) - { - printf("n = %2.3f,%2.3f,%2.3f. ",normalInB[0],normalInB[1],normalInB[2]); - printf("distance = %2.3f exit=%d deg=%d\n",distance,m_lastUsedMethod,m_degenerateSimplex); - } -#endif - - m_cachedSeparatingAxis = normalInB; - m_cachedSeparatingDistance = distance; - - output.addContactPoint( - normalInB, - pointOnB+positionOffset, - distance); - - } - - -} - - - - - diff --git a/bullet/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h b/bullet/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h deleted file mode 100644 index 3acf69ba4..000000000 --- a/bullet/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h +++ /dev/null @@ -1,103 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - - - -#ifndef GJK_PAIR_DETECTOR_H -#define GJK_PAIR_DETECTOR_H - -#include "btDiscreteCollisionDetectorInterface.h" -#include "BulletCollision/CollisionShapes/btCollisionMargin.h" - -class btConvexShape; -#include "btSimplexSolverInterface.h" -class btConvexPenetrationDepthSolver; - -/// btGjkPairDetector uses GJK to implement the btDiscreteCollisionDetectorInterface -class btGjkPairDetector : public btDiscreteCollisionDetectorInterface -{ - - - btVector3 m_cachedSeparatingAxis; - btConvexPenetrationDepthSolver* m_penetrationDepthSolver; - btSimplexSolverInterface* m_simplexSolver; - const btConvexShape* m_minkowskiA; - const btConvexShape* m_minkowskiB; - int m_shapeTypeA; - int m_shapeTypeB; - btScalar m_marginA; - btScalar m_marginB; - - bool m_ignoreMargin; - btScalar m_cachedSeparatingDistance; - - -public: - - //some debugging to fix degeneracy problems - int m_lastUsedMethod; - int m_curIter; - int m_degenerateSimplex; - int m_catchDegeneracies; - - - btGjkPairDetector(const btConvexShape* objectA,const btConvexShape* objectB,btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver); - btGjkPairDetector(const btConvexShape* objectA,const btConvexShape* objectB,int shapeTypeA,int shapeTypeB,btScalar marginA, btScalar marginB, btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver); - virtual ~btGjkPairDetector() {}; - - virtual void getClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw,bool swapResults=false); - - void getClosestPointsNonVirtual(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw); - - - void setMinkowskiA(btConvexShape* minkA) - { - m_minkowskiA = minkA; - } - - void setMinkowskiB(btConvexShape* minkB) - { - m_minkowskiB = minkB; - } - void setCachedSeperatingAxis(const btVector3& seperatingAxis) - { - m_cachedSeparatingAxis = seperatingAxis; - } - - const btVector3& getCachedSeparatingAxis() const - { - return m_cachedSeparatingAxis; - } - btScalar getCachedSeparatingDistance() const - { - return m_cachedSeparatingDistance; - } - - void setPenetrationDepthSolver(btConvexPenetrationDepthSolver* penetrationDepthSolver) - { - m_penetrationDepthSolver = penetrationDepthSolver; - } - - ///don't use setIgnoreMargin, it's for Bullet's internal use - void setIgnoreMargin(bool ignoreMargin) - { - m_ignoreMargin = ignoreMargin; - } - - -}; - -#endif //GJK_PAIR_DETECTOR_H diff --git a/bullet/src/BulletCollision/NarrowPhaseCollision/btManifoldPoint.h b/bullet/src/BulletCollision/NarrowPhaseCollision/btManifoldPoint.h deleted file mode 100644 index 2f7a3155e..000000000 --- a/bullet/src/BulletCollision/NarrowPhaseCollision/btManifoldPoint.h +++ /dev/null @@ -1,138 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef MANIFOLD_CONTACT_POINT_H -#define MANIFOLD_CONTACT_POINT_H - -#include "LinearMath/btVector3.h" -#include "LinearMath/btTransformUtil.h" - - - - - -/// ManifoldContactPoint collects and maintains persistent contactpoints. -/// used to improve stability and performance of rigidbody dynamics response. -class btManifoldPoint - { - public: - btManifoldPoint() - :m_userPersistentData(0), - m_appliedImpulse(0.f), - m_lateralFrictionInitialized(false), - m_appliedImpulseLateral1(0.f), - m_appliedImpulseLateral2(0.f), - m_contactMotion1(0.f), - m_contactMotion2(0.f), - m_contactCFM1(0.f), - m_contactCFM2(0.f), - m_lifeTime(0) - { - } - - btManifoldPoint( const btVector3 &pointA, const btVector3 &pointB, - const btVector3 &normal, - btScalar distance ) : - m_localPointA( pointA ), - m_localPointB( pointB ), - m_normalWorldOnB( normal ), - m_distance1( distance ), - m_combinedFriction(btScalar(0.)), - m_combinedRestitution(btScalar(0.)), - m_userPersistentData(0), - m_appliedImpulse(0.f), - m_lateralFrictionInitialized(false), - m_appliedImpulseLateral1(0.f), - m_appliedImpulseLateral2(0.f), - m_contactMotion1(0.f), - m_contactMotion2(0.f), - m_contactCFM1(0.f), - m_contactCFM2(0.f), - m_lifeTime(0) - { - - - } - - - - btVector3 m_localPointA; - btVector3 m_localPointB; - btVector3 m_positionWorldOnB; - ///m_positionWorldOnA is redundant information, see getPositionWorldOnA(), but for clarity - btVector3 m_positionWorldOnA; - btVector3 m_normalWorldOnB; - - btScalar m_distance1; - btScalar m_combinedFriction; - btScalar m_combinedRestitution; - - //BP mod, store contact triangles. - int m_partId0; - int m_partId1; - int m_index0; - int m_index1; - - mutable void* m_userPersistentData; - btScalar m_appliedImpulse; - - bool m_lateralFrictionInitialized; - btScalar m_appliedImpulseLateral1; - btScalar m_appliedImpulseLateral2; - btScalar m_contactMotion1; - btScalar m_contactMotion2; - btScalar m_contactCFM1; - btScalar m_contactCFM2; - - int m_lifeTime;//lifetime of the contactpoint in frames - - btVector3 m_lateralFrictionDir1; - btVector3 m_lateralFrictionDir2; - - btScalar getDistance() const - { - return m_distance1; - } - int getLifeTime() const - { - return m_lifeTime; - } - - const btVector3& getPositionWorldOnA() const { - return m_positionWorldOnA; -// return m_positionWorldOnB + m_normalWorldOnB * m_distance1; - } - - const btVector3& getPositionWorldOnB() const - { - return m_positionWorldOnB; - } - - void setDistance(btScalar dist) - { - m_distance1 = dist; - } - - ///this returns the most recent applied impulse, to satisfy contact constraints by the constraint solver - btScalar getAppliedImpulse() const - { - return m_appliedImpulse; - } - - - - }; - -#endif //MANIFOLD_CONTACT_POINT_H diff --git a/bullet/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp b/bullet/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp deleted file mode 100644 index 35db30297..000000000 --- a/bullet/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp +++ /dev/null @@ -1,357 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btMinkowskiPenetrationDepthSolver.h" -#include "BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h" -#include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h" -#include "BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h" -#include "BulletCollision/CollisionShapes/btConvexShape.h" - -#define NUM_UNITSPHERE_POINTS 42 -static btVector3 sPenetrationDirections[NUM_UNITSPHERE_POINTS+MAX_PREFERRED_PENETRATION_DIRECTIONS*2] = -{ -btVector3(btScalar(0.000000) , btScalar(-0.000000),btScalar(-1.000000)), -btVector3(btScalar(0.723608) , btScalar(-0.525725),btScalar(-0.447219)), -btVector3(btScalar(-0.276388) , btScalar(-0.850649),btScalar(-0.447219)), -btVector3(btScalar(-0.894426) , btScalar(-0.000000),btScalar(-0.447216)), -btVector3(btScalar(-0.276388) , btScalar(0.850649),btScalar(-0.447220)), -btVector3(btScalar(0.723608) , btScalar(0.525725),btScalar(-0.447219)), -btVector3(btScalar(0.276388) , btScalar(-0.850649),btScalar(0.447220)), -btVector3(btScalar(-0.723608) , btScalar(-0.525725),btScalar(0.447219)), -btVector3(btScalar(-0.723608) , btScalar(0.525725),btScalar(0.447219)), -btVector3(btScalar(0.276388) , btScalar(0.850649),btScalar(0.447219)), -btVector3(btScalar(0.894426) , btScalar(0.000000),btScalar(0.447216)), -btVector3(btScalar(-0.000000) , btScalar(0.000000),btScalar(1.000000)), -btVector3(btScalar(0.425323) , btScalar(-0.309011),btScalar(-0.850654)), -btVector3(btScalar(-0.162456) , btScalar(-0.499995),btScalar(-0.850654)), -btVector3(btScalar(0.262869) , btScalar(-0.809012),btScalar(-0.525738)), -btVector3(btScalar(0.425323) , btScalar(0.309011),btScalar(-0.850654)), -btVector3(btScalar(0.850648) , btScalar(-0.000000),btScalar(-0.525736)), -btVector3(btScalar(-0.525730) , btScalar(-0.000000),btScalar(-0.850652)), -btVector3(btScalar(-0.688190) , btScalar(-0.499997),btScalar(-0.525736)), -btVector3(btScalar(-0.162456) , btScalar(0.499995),btScalar(-0.850654)), -btVector3(btScalar(-0.688190) , btScalar(0.499997),btScalar(-0.525736)), -btVector3(btScalar(0.262869) , btScalar(0.809012),btScalar(-0.525738)), -btVector3(btScalar(0.951058) , btScalar(0.309013),btScalar(0.000000)), -btVector3(btScalar(0.951058) , btScalar(-0.309013),btScalar(0.000000)), -btVector3(btScalar(0.587786) , btScalar(-0.809017),btScalar(0.000000)), -btVector3(btScalar(0.000000) , btScalar(-1.000000),btScalar(0.000000)), -btVector3(btScalar(-0.587786) , btScalar(-0.809017),btScalar(0.000000)), -btVector3(btScalar(-0.951058) , btScalar(-0.309013),btScalar(-0.000000)), -btVector3(btScalar(-0.951058) , btScalar(0.309013),btScalar(-0.000000)), -btVector3(btScalar(-0.587786) , btScalar(0.809017),btScalar(-0.000000)), -btVector3(btScalar(-0.000000) , btScalar(1.000000),btScalar(-0.000000)), -btVector3(btScalar(0.587786) , btScalar(0.809017),btScalar(-0.000000)), -btVector3(btScalar(0.688190) , btScalar(-0.499997),btScalar(0.525736)), -btVector3(btScalar(-0.262869) , btScalar(-0.809012),btScalar(0.525738)), -btVector3(btScalar(-0.850648) , btScalar(0.000000),btScalar(0.525736)), -btVector3(btScalar(-0.262869) , btScalar(0.809012),btScalar(0.525738)), -btVector3(btScalar(0.688190) , btScalar(0.499997),btScalar(0.525736)), -btVector3(btScalar(0.525730) , btScalar(0.000000),btScalar(0.850652)), -btVector3(btScalar(0.162456) , btScalar(-0.499995),btScalar(0.850654)), -btVector3(btScalar(-0.425323) , btScalar(-0.309011),btScalar(0.850654)), -btVector3(btScalar(-0.425323) , btScalar(0.309011),btScalar(0.850654)), -btVector3(btScalar(0.162456) , btScalar(0.499995),btScalar(0.850654)) -}; - - -bool btMinkowskiPenetrationDepthSolver::calcPenDepth(btSimplexSolverInterface& simplexSolver, - const btConvexShape* convexA,const btConvexShape* convexB, - const btTransform& transA,const btTransform& transB, - btVector3& v, btVector3& pa, btVector3& pb, - class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc - ) -{ - - (void)stackAlloc; - (void)v; - - bool check2d= convexA->isConvex2d() && convexB->isConvex2d(); - - struct btIntermediateResult : public btDiscreteCollisionDetectorInterface::Result - { - - btIntermediateResult():m_hasResult(false) - { - } - - btVector3 m_normalOnBInWorld; - btVector3 m_pointInWorld; - btScalar m_depth; - bool m_hasResult; - - virtual void setShapeIdentifiersA(int partId0,int index0) - { - (void)partId0; - (void)index0; - } - virtual void setShapeIdentifiersB(int partId1,int index1) - { - (void)partId1; - (void)index1; - } - void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth) - { - m_normalOnBInWorld = normalOnBInWorld; - m_pointInWorld = pointInWorld; - m_depth = depth; - m_hasResult = true; - } - }; - - //just take fixed number of orientation, and sample the penetration depth in that direction - btScalar minProj = btScalar(BT_LARGE_FLOAT); - btVector3 minNorm(btScalar(0.), btScalar(0.), btScalar(0.)); - btVector3 minA,minB; - btVector3 seperatingAxisInA,seperatingAxisInB; - btVector3 pInA,qInB,pWorld,qWorld,w; - -#ifndef __SPU__ -#define USE_BATCHED_SUPPORT 1 -#endif -#ifdef USE_BATCHED_SUPPORT - - btVector3 supportVerticesABatch[NUM_UNITSPHERE_POINTS+MAX_PREFERRED_PENETRATION_DIRECTIONS*2]; - btVector3 supportVerticesBBatch[NUM_UNITSPHERE_POINTS+MAX_PREFERRED_PENETRATION_DIRECTIONS*2]; - btVector3 seperatingAxisInABatch[NUM_UNITSPHERE_POINTS+MAX_PREFERRED_PENETRATION_DIRECTIONS*2]; - btVector3 seperatingAxisInBBatch[NUM_UNITSPHERE_POINTS+MAX_PREFERRED_PENETRATION_DIRECTIONS*2]; - int i; - - int numSampleDirections = NUM_UNITSPHERE_POINTS; - - for (i=0;igetNumPreferredPenetrationDirections(); - if (numPDA) - { - for (int i=0;igetPreferredPenetrationDirection(i,norm); - norm = transA.getBasis() * norm; - sPenetrationDirections[numSampleDirections] = norm; - seperatingAxisInABatch[numSampleDirections] = (-norm) * transA.getBasis(); - seperatingAxisInBBatch[numSampleDirections] = norm * transB.getBasis(); - numSampleDirections++; - } - } - } - - { - int numPDB = convexB->getNumPreferredPenetrationDirections(); - if (numPDB) - { - for (int i=0;igetPreferredPenetrationDirection(i,norm); - norm = transB.getBasis() * norm; - sPenetrationDirections[numSampleDirections] = norm; - seperatingAxisInABatch[numSampleDirections] = (-norm) * transA.getBasis(); - seperatingAxisInBBatch[numSampleDirections] = norm * transB.getBasis(); - numSampleDirections++; - } - } - } - - - - - convexA->batchedUnitVectorGetSupportingVertexWithoutMargin(seperatingAxisInABatch,supportVerticesABatch,numSampleDirections); - convexB->batchedUnitVectorGetSupportingVertexWithoutMargin(seperatingAxisInBBatch,supportVerticesBBatch,numSampleDirections); - - for (i=0;i0.01) - { - - seperatingAxisInA = seperatingAxisInABatch[i]; - seperatingAxisInB = seperatingAxisInBBatch[i]; - - pInA = supportVerticesABatch[i]; - qInB = supportVerticesBBatch[i]; - - pWorld = transA(pInA); - qWorld = transB(qInB); - if (check2d) - { - pWorld[2] = 0.f; - qWorld[2] = 0.f; - } - - w = qWorld - pWorld; - btScalar delta = norm.dot(w); - //find smallest delta - if (delta < minProj) - { - minProj = delta; - minNorm = norm; - minA = pWorld; - minB = qWorld; - } - } - } -#else - - int numSampleDirections = NUM_UNITSPHERE_POINTS; - -#ifndef __SPU__ - { - int numPDA = convexA->getNumPreferredPenetrationDirections(); - if (numPDA) - { - for (int i=0;igetPreferredPenetrationDirection(i,norm); - norm = transA.getBasis() * norm; - sPenetrationDirections[numSampleDirections] = norm; - numSampleDirections++; - } - } - } - - { - int numPDB = convexB->getNumPreferredPenetrationDirections(); - if (numPDB) - { - for (int i=0;igetPreferredPenetrationDirection(i,norm); - norm = transB.getBasis() * norm; - sPenetrationDirections[numSampleDirections] = norm; - numSampleDirections++; - } - } - } -#endif // __SPU__ - - for (int i=0;ilocalGetSupportVertexWithoutMarginNonVirtual(seperatingAxisInA); - qInB = convexB->localGetSupportVertexWithoutMarginNonVirtual(seperatingAxisInB); - pWorld = transA(pInA); - qWorld = transB(qInB); - w = qWorld - pWorld; - btScalar delta = norm.dot(w); - //find smallest delta - if (delta < minProj) - { - minProj = delta; - minNorm = norm; - minA = pWorld; - minB = qWorld; - } - } -#endif //USE_BATCHED_SUPPORT - - //add the margins - - minA += minNorm*convexA->getMarginNonVirtual(); - minB -= minNorm*convexB->getMarginNonVirtual(); - //no penetration - if (minProj < btScalar(0.)) - return false; - - btScalar extraSeparation = 0.5f;///scale dependent - minProj += extraSeparation+(convexA->getMarginNonVirtual() + convexB->getMarginNonVirtual()); - - - - - -//#define DEBUG_DRAW 1 -#ifdef DEBUG_DRAW - if (debugDraw) - { - btVector3 color(0,1,0); - debugDraw->drawLine(minA,minB,color); - color = btVector3 (1,1,1); - btVector3 vec = minB-minA; - btScalar prj2 = minNorm.dot(vec); - debugDraw->drawLine(minA,minA+(minNorm*minProj),color); - - } -#endif //DEBUG_DRAW - - - - btGjkPairDetector gjkdet(convexA,convexB,&simplexSolver,0); - - btScalar offsetDist = minProj; - btVector3 offset = minNorm * offsetDist; - - - - btGjkPairDetector::ClosestPointInput input; - - btVector3 newOrg = transA.getOrigin() + offset; - - btTransform displacedTrans = transA; - displacedTrans.setOrigin(newOrg); - - input.m_transformA = displacedTrans; - input.m_transformB = transB; - input.m_maximumDistanceSquared = btScalar(BT_LARGE_FLOAT);//minProj; - - btIntermediateResult res; - gjkdet.setCachedSeperatingAxis(-minNorm); - gjkdet.getClosestPoints(input,res,debugDraw); - - btScalar correctedMinNorm = minProj - res.m_depth; - - - //the penetration depth is over-estimated, relax it - btScalar penetration_relaxation= btScalar(1.); - minNorm*=penetration_relaxation; - - - if (res.m_hasResult) - { - - pa = res.m_pointInWorld - minNorm * correctedMinNorm; - pb = res.m_pointInWorld; - v = minNorm; - -#ifdef DEBUG_DRAW - if (debugDraw) - { - btVector3 color(1,0,0); - debugDraw->drawLine(pa,pb,color); - } -#endif//DEBUG_DRAW - - - } - return res.m_hasResult; -} - - - diff --git a/bullet/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h b/bullet/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h deleted file mode 100644 index 4f306e761..000000000 --- a/bullet/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h +++ /dev/null @@ -1,36 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef MINKOWSKI_PENETRATION_DEPTH_SOLVER_H -#define MINKOWSKI_PENETRATION_DEPTH_SOLVER_H - -#include "btConvexPenetrationDepthSolver.h" - -///MinkowskiPenetrationDepthSolver implements bruteforce penetration depth estimation. -///Implementation is based on sampling the depth using support mapping, and using GJK step to get the witness points. -class btMinkowskiPenetrationDepthSolver : public btConvexPenetrationDepthSolver -{ -public: - - virtual bool calcPenDepth( btSimplexSolverInterface& simplexSolver, - const btConvexShape* convexA,const btConvexShape* convexB, - const btTransform& transA,const btTransform& transB, - btVector3& v, btVector3& pa, btVector3& pb, - class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc - ); -}; - -#endif //MINKOWSKI_PENETRATION_DEPTH_SOLVER_H - diff --git a/bullet/src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.cpp b/bullet/src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.cpp deleted file mode 100644 index ca5761b0d..000000000 --- a/bullet/src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.cpp +++ /dev/null @@ -1,260 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#include "btPersistentManifold.h" -#include "LinearMath/btTransform.h" - - -btScalar gContactBreakingThreshold = btScalar(0.02); -ContactDestroyedCallback gContactDestroyedCallback = 0; -ContactProcessedCallback gContactProcessedCallback = 0; - - - -btPersistentManifold::btPersistentManifold() -:btTypedObject(BT_PERSISTENT_MANIFOLD_TYPE), -m_body0(0), -m_body1(0), -m_cachedPoints (0), -m_index1a(0) -{ -} - - - - -#ifdef DEBUG_PERSISTENCY -#include -void btPersistentManifold::DebugPersistency() -{ - int i; - printf("DebugPersistency : numPoints %d\n",m_cachedPoints); - for (i=0;i1) - printf("error in clearUserCache\n"); - } - } - btAssert(occurance<=0); -#endif //DEBUG_PERSISTENCY - - if (pt.m_userPersistentData && gContactDestroyedCallback) - { - (*gContactDestroyedCallback)(pt.m_userPersistentData); - pt.m_userPersistentData = 0; - } - -#ifdef DEBUG_PERSISTENCY - DebugPersistency(); -#endif - } - - -} - - -int btPersistentManifold::sortCachedPoints(const btManifoldPoint& pt) -{ - - //calculate 4 possible cases areas, and take biggest area - //also need to keep 'deepest' - - int maxPenetrationIndex = -1; -#define KEEP_DEEPEST_POINT 1 -#ifdef KEEP_DEEPEST_POINT - btScalar maxPenetration = pt.getDistance(); - for (int i=0;i<4;i++) - { - if (m_pointCache[i].getDistance() < maxPenetration) - { - maxPenetrationIndex = i; - maxPenetration = m_pointCache[i].getDistance(); - } - } -#endif //KEEP_DEEPEST_POINT - - btScalar res0(btScalar(0.)),res1(btScalar(0.)),res2(btScalar(0.)),res3(btScalar(0.)); - if (maxPenetrationIndex != 0) - { - btVector3 a0 = pt.m_localPointA-m_pointCache[1].m_localPointA; - btVector3 b0 = m_pointCache[3].m_localPointA-m_pointCache[2].m_localPointA; - btVector3 cross = a0.cross(b0); - res0 = cross.length2(); - } - if (maxPenetrationIndex != 1) - { - btVector3 a1 = pt.m_localPointA-m_pointCache[0].m_localPointA; - btVector3 b1 = m_pointCache[3].m_localPointA-m_pointCache[2].m_localPointA; - btVector3 cross = a1.cross(b1); - res1 = cross.length2(); - } - - if (maxPenetrationIndex != 2) - { - btVector3 a2 = pt.m_localPointA-m_pointCache[0].m_localPointA; - btVector3 b2 = m_pointCache[3].m_localPointA-m_pointCache[1].m_localPointA; - btVector3 cross = a2.cross(b2); - res2 = cross.length2(); - } - - if (maxPenetrationIndex != 3) - { - btVector3 a3 = pt.m_localPointA-m_pointCache[0].m_localPointA; - btVector3 b3 = m_pointCache[2].m_localPointA-m_pointCache[1].m_localPointA; - btVector3 cross = a3.cross(b3); - res3 = cross.length2(); - } - - btVector4 maxvec(res0,res1,res2,res3); - int biggestarea = maxvec.closestAxis4(); - return biggestarea; -} - - -int btPersistentManifold::getCacheEntry(const btManifoldPoint& newPoint) const -{ - btScalar shortestDist = getContactBreakingThreshold() * getContactBreakingThreshold(); - int size = getNumContacts(); - int nearestPoint = -1; - for( int i = 0; i < size; i++ ) - { - const btManifoldPoint &mp = m_pointCache[i]; - - btVector3 diffA = mp.m_localPointA- newPoint.m_localPointA; - const btScalar distToManiPoint = diffA.dot(diffA); - if( distToManiPoint < shortestDist ) - { - shortestDist = distToManiPoint; - nearestPoint = i; - } - } - return nearestPoint; -} - -int btPersistentManifold::addManifoldPoint(const btManifoldPoint& newPoint) -{ - btAssert(validContactDistance(newPoint)); - - int insertIndex = getNumContacts(); - if (insertIndex == MANIFOLD_CACHE_SIZE) - { -#if MANIFOLD_CACHE_SIZE >= 4 - //sort cache so best points come first, based on area - insertIndex = sortCachedPoints(newPoint); -#else - insertIndex = 0; -#endif - clearUserCache(m_pointCache[insertIndex]); - - } else - { - m_cachedPoints++; - - - } - if (insertIndex<0) - insertIndex=0; - - btAssert(m_pointCache[insertIndex].m_userPersistentData==0); - m_pointCache[insertIndex] = newPoint; - return insertIndex; -} - -btScalar btPersistentManifold::getContactBreakingThreshold() const -{ - return m_contactBreakingThreshold; -} - - - -void btPersistentManifold::refreshContactPoints(const btTransform& trA,const btTransform& trB) -{ - int i; -#ifdef DEBUG_PERSISTENCY - printf("refreshContactPoints posA = (%f,%f,%f) posB = (%f,%f,%f)\n", - trA.getOrigin().getX(), - trA.getOrigin().getY(), - trA.getOrigin().getZ(), - trB.getOrigin().getX(), - trB.getOrigin().getY(), - trB.getOrigin().getZ()); -#endif //DEBUG_PERSISTENCY - /// first refresh worldspace positions and distance - for (i=getNumContacts()-1;i>=0;i--) - { - btManifoldPoint &manifoldPoint = m_pointCache[i]; - manifoldPoint.m_positionWorldOnA = trA( manifoldPoint.m_localPointA ); - manifoldPoint.m_positionWorldOnB = trB( manifoldPoint.m_localPointB ); - manifoldPoint.m_distance1 = (manifoldPoint.m_positionWorldOnA - manifoldPoint.m_positionWorldOnB).dot(manifoldPoint.m_normalWorldOnB); - manifoldPoint.m_lifeTime++; - } - - /// then - btScalar distance2d; - btVector3 projectedDifference,projectedPoint; - for (i=getNumContacts()-1;i>=0;i--) - { - - btManifoldPoint &manifoldPoint = m_pointCache[i]; - //contact becomes invalid when signed distance exceeds margin (projected on contactnormal direction) - if (!validContactDistance(manifoldPoint)) - { - removeContactPoint(i); - } else - { - //contact also becomes invalid when relative movement orthogonal to normal exceeds margin - projectedPoint = manifoldPoint.m_positionWorldOnA - manifoldPoint.m_normalWorldOnB * manifoldPoint.m_distance1; - projectedDifference = manifoldPoint.m_positionWorldOnB - projectedPoint; - distance2d = projectedDifference.dot(projectedDifference); - if (distance2d > getContactBreakingThreshold()*getContactBreakingThreshold() ) - { - removeContactPoint(i); - } else - { - //contact point processed callback - if (gContactProcessedCallback) - (*gContactProcessedCallback)(manifoldPoint,m_body0,m_body1); - } - } - } -#ifdef DEBUG_PERSISTENCY - DebugPersistency(); -#endif // -} - - - - - diff --git a/bullet/src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.h b/bullet/src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.h deleted file mode 100644 index 1c3d0bdb5..000000000 --- a/bullet/src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.h +++ /dev/null @@ -1,208 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef PERSISTENT_MANIFOLD_H -#define PERSISTENT_MANIFOLD_H - - -#include "LinearMath/btVector3.h" -#include "LinearMath/btTransform.h" -#include "btManifoldPoint.h" -#include "LinearMath/btAlignedAllocator.h" - -struct btCollisionResult; - -///maximum contact breaking and merging threshold -extern btScalar gContactBreakingThreshold; - -typedef bool (*ContactDestroyedCallback)(void* userPersistentData); -typedef bool (*ContactProcessedCallback)(btManifoldPoint& cp,void* body0,void* body1); -extern ContactDestroyedCallback gContactDestroyedCallback; -extern ContactProcessedCallback gContactProcessedCallback; - - -enum btContactManifoldTypes -{ - BT_PERSISTENT_MANIFOLD_TYPE = 1, - MAX_CONTACT_MANIFOLD_TYPE -}; - -#define MANIFOLD_CACHE_SIZE 4 - -///btPersistentManifold is a contact point cache, it stays persistent as long as objects are overlapping in the broadphase. -///Those contact points are created by the collision narrow phase. -///The cache can be empty, or hold 1,2,3 or 4 points. Some collision algorithms (GJK) might only add one point at a time. -///updates/refreshes old contact points, and throw them away if necessary (distance becomes too large) -///reduces the cache to 4 points, when more then 4 points are added, using following rules: -///the contact point with deepest penetration is always kept, and it tries to maximuze the area covered by the points -///note that some pairs of objects might have more then one contact manifold. -ATTRIBUTE_ALIGNED16( class) btPersistentManifold : public btTypedObject -{ - - btManifoldPoint m_pointCache[MANIFOLD_CACHE_SIZE]; - - /// this two body pointers can point to the physics rigidbody class. - /// void* will allow any rigidbody class - void* m_body0; - void* m_body1; - int m_cachedPoints; - - btScalar m_contactBreakingThreshold; - btScalar m_contactProcessingThreshold; - - - /// sort cached points so most isolated points come first - int sortCachedPoints(const btManifoldPoint& pt); - - int findContactPoint(const btManifoldPoint* unUsed, int numUnused,const btManifoldPoint& pt); - -public: - - BT_DECLARE_ALIGNED_ALLOCATOR(); - - int m_index1a; - - btPersistentManifold(); - - btPersistentManifold(void* body0,void* body1,int , btScalar contactBreakingThreshold,btScalar contactProcessingThreshold) - : btTypedObject(BT_PERSISTENT_MANIFOLD_TYPE), - m_body0(body0),m_body1(body1),m_cachedPoints(0), - m_contactBreakingThreshold(contactBreakingThreshold), - m_contactProcessingThreshold(contactProcessingThreshold) - { - } - - SIMD_FORCE_INLINE void* getBody0() { return m_body0;} - SIMD_FORCE_INLINE void* getBody1() { return m_body1;} - - SIMD_FORCE_INLINE const void* getBody0() const { return m_body0;} - SIMD_FORCE_INLINE const void* getBody1() const { return m_body1;} - - void setBodies(void* body0,void* body1) - { - m_body0 = body0; - m_body1 = body1; - } - - void clearUserCache(btManifoldPoint& pt); - -#ifdef DEBUG_PERSISTENCY - void DebugPersistency(); -#endif // - - SIMD_FORCE_INLINE int getNumContacts() const { return m_cachedPoints;} - - SIMD_FORCE_INLINE const btManifoldPoint& getContactPoint(int index) const - { - btAssert(index < m_cachedPoints); - return m_pointCache[index]; - } - - SIMD_FORCE_INLINE btManifoldPoint& getContactPoint(int index) - { - btAssert(index < m_cachedPoints); - return m_pointCache[index]; - } - - ///@todo: get this margin from the current physics / collision environment - btScalar getContactBreakingThreshold() const; - - btScalar getContactProcessingThreshold() const - { - return m_contactProcessingThreshold; - } - - int getCacheEntry(const btManifoldPoint& newPoint) const; - - int addManifoldPoint( const btManifoldPoint& newPoint); - - void removeContactPoint (int index) - { - clearUserCache(m_pointCache[index]); - - int lastUsedIndex = getNumContacts() - 1; -// m_pointCache[index] = m_pointCache[lastUsedIndex]; - if(index != lastUsedIndex) - { - m_pointCache[index] = m_pointCache[lastUsedIndex]; - //get rid of duplicated userPersistentData pointer - m_pointCache[lastUsedIndex].m_userPersistentData = 0; - m_pointCache[lastUsedIndex].m_appliedImpulse = 0.f; - m_pointCache[lastUsedIndex].m_lateralFrictionInitialized = false; - m_pointCache[lastUsedIndex].m_appliedImpulseLateral1 = 0.f; - m_pointCache[lastUsedIndex].m_appliedImpulseLateral2 = 0.f; - m_pointCache[lastUsedIndex].m_lifeTime = 0; - } - - btAssert(m_pointCache[lastUsedIndex].m_userPersistentData==0); - m_cachedPoints--; - } - void replaceContactPoint(const btManifoldPoint& newPoint,int insertIndex) - { - btAssert(validContactDistance(newPoint)); - -#define MAINTAIN_PERSISTENCY 1 -#ifdef MAINTAIN_PERSISTENCY - int lifeTime = m_pointCache[insertIndex].getLifeTime(); - btScalar appliedImpulse = m_pointCache[insertIndex].m_appliedImpulse; - btScalar appliedLateralImpulse1 = m_pointCache[insertIndex].m_appliedImpulseLateral1; - btScalar appliedLateralImpulse2 = m_pointCache[insertIndex].m_appliedImpulseLateral2; - - btAssert(lifeTime>=0); - void* cache = m_pointCache[insertIndex].m_userPersistentData; - - m_pointCache[insertIndex] = newPoint; - - m_pointCache[insertIndex].m_userPersistentData = cache; - m_pointCache[insertIndex].m_appliedImpulse = appliedImpulse; - m_pointCache[insertIndex].m_appliedImpulseLateral1 = appliedLateralImpulse1; - m_pointCache[insertIndex].m_appliedImpulseLateral2 = appliedLateralImpulse2; - - m_pointCache[insertIndex].m_lifeTime = lifeTime; -#else - clearUserCache(m_pointCache[insertIndex]); - m_pointCache[insertIndex] = newPoint; - -#endif - } - - bool validContactDistance(const btManifoldPoint& pt) const - { - return pt.m_distance1 <= getContactBreakingThreshold(); - } - /// calculated new worldspace coordinates and depth, and reject points that exceed the collision margin - void refreshContactPoints( const btTransform& trA,const btTransform& trB); - - - SIMD_FORCE_INLINE void clearManifold() - { - int i; - for (i=0;i - -#include "BulletCollision/CollisionShapes/btConvexShape.h" -#include "BulletCollision/CollisionShapes/btTriangleShape.h" -#include "BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h" -#include "BulletCollision/NarrowPhaseCollision/btGjkConvexCast.h" -#include "BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.h" -#include "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h" -#include "btRaycastCallback.h" - -btTriangleRaycastCallback::btTriangleRaycastCallback(const btVector3& from,const btVector3& to, unsigned int flags) - : - m_from(from), - m_to(to), - //@BP Mod - m_flags(flags), - m_hitFraction(btScalar(1.)) -{ - -} - - - -void btTriangleRaycastCallback::processTriangle(btVector3* triangle,int partId, int triangleIndex) -{ - const btVector3 &vert0=triangle[0]; - const btVector3 &vert1=triangle[1]; - const btVector3 &vert2=triangle[2]; - - btVector3 v10; v10 = vert1 - vert0 ; - btVector3 v20; v20 = vert2 - vert0 ; - - btVector3 triangleNormal; triangleNormal = v10.cross( v20 ); - - const btScalar dist = vert0.dot(triangleNormal); - btScalar dist_a = triangleNormal.dot(m_from) ; - dist_a-= dist; - btScalar dist_b = triangleNormal.dot(m_to); - dist_b -= dist; - - if ( dist_a * dist_b >= btScalar(0.0) ) - { - return ; // same sign - } - //@BP Mod - Backface filtering - if (((m_flags & kF_FilterBackfaces) != 0) && (dist_a > btScalar(0.0))) - { - // Backface, skip check - return; - } - - const btScalar proj_length=dist_a-dist_b; - const btScalar distance = (dist_a)/(proj_length); - // Now we have the intersection point on the plane, we'll see if it's inside the triangle - // Add an epsilon as a tolerance for the raycast, - // in case the ray hits exacly on the edge of the triangle. - // It must be scaled for the triangle size. - - if(distance < m_hitFraction) - { - - - btScalar edge_tolerance =triangleNormal.length2(); - edge_tolerance *= btScalar(-0.0001); - btVector3 point; point.setInterpolate3( m_from, m_to, distance); - { - btVector3 v0p; v0p = vert0 - point; - btVector3 v1p; v1p = vert1 - point; - btVector3 cp0; cp0 = v0p.cross( v1p ); - - if ( (btScalar)(cp0.dot(triangleNormal)) >=edge_tolerance) - { - - - btVector3 v2p; v2p = vert2 - point; - btVector3 cp1; - cp1 = v1p.cross( v2p); - if ( (btScalar)(cp1.dot(triangleNormal)) >=edge_tolerance) - { - btVector3 cp2; - cp2 = v2p.cross(v0p); - - if ( (btScalar)(cp2.dot(triangleNormal)) >=edge_tolerance) - { - //@BP Mod - // Triangle normal isn't normalized - triangleNormal.normalize(); - - //@BP Mod - Allow for unflipped normal when raycasting against backfaces - if (((m_flags & kF_KeepUnflippedNormal) != 0) || (dist_a <= btScalar(0.0))) - { - m_hitFraction = reportHit(-triangleNormal,distance,partId,triangleIndex); - } - else - { - m_hitFraction = reportHit(triangleNormal,distance,partId,triangleIndex); - } - } - } - } - } - } -} - - -btTriangleConvexcastCallback::btTriangleConvexcastCallback (const btConvexShape* convexShape, const btTransform& convexShapeFrom, const btTransform& convexShapeTo, const btTransform& triangleToWorld, const btScalar triangleCollisionMargin) -{ - m_convexShape = convexShape; - m_convexShapeFrom = convexShapeFrom; - m_convexShapeTo = convexShapeTo; - m_triangleToWorld = triangleToWorld; - m_hitFraction = 1.0; - m_triangleCollisionMargin = triangleCollisionMargin; -} - -void -btTriangleConvexcastCallback::processTriangle (btVector3* triangle, int partId, int triangleIndex) -{ - btTriangleShape triangleShape (triangle[0], triangle[1], triangle[2]); - triangleShape.setMargin(m_triangleCollisionMargin); - - btVoronoiSimplexSolver simplexSolver; - btGjkEpaPenetrationDepthSolver gjkEpaPenetrationSolver; - -//#define USE_SUBSIMPLEX_CONVEX_CAST 1 -//if you reenable USE_SUBSIMPLEX_CONVEX_CAST see commented out code below -#ifdef USE_SUBSIMPLEX_CONVEX_CAST - btSubsimplexConvexCast convexCaster(m_convexShape, &triangleShape, &simplexSolver); -#else - //btGjkConvexCast convexCaster(m_convexShape,&triangleShape,&simplexSolver); - btContinuousConvexCollision convexCaster(m_convexShape,&triangleShape,&simplexSolver,&gjkEpaPenetrationSolver); -#endif //#USE_SUBSIMPLEX_CONVEX_CAST - - btConvexCast::CastResult castResult; - castResult.m_fraction = btScalar(1.); - if (convexCaster.calcTimeOfImpact(m_convexShapeFrom,m_convexShapeTo,m_triangleToWorld, m_triangleToWorld, castResult)) - { - //add hit - if (castResult.m_normal.length2() > btScalar(0.0001)) - { - if (castResult.m_fraction < m_hitFraction) - { -/* btContinuousConvexCast's normal is already in world space */ -/* -#ifdef USE_SUBSIMPLEX_CONVEX_CAST - //rotate normal into worldspace - castResult.m_normal = m_convexShapeFrom.getBasis() * castResult.m_normal; -#endif //USE_SUBSIMPLEX_CONVEX_CAST -*/ - castResult.m_normal.normalize(); - - reportHit (castResult.m_normal, - castResult.m_hitPoint, - castResult.m_fraction, - partId, - triangleIndex); - } - } - } -} diff --git a/bullet/src/BulletCollision/NarrowPhaseCollision/btRaycastCallback.h b/bullet/src/BulletCollision/NarrowPhaseCollision/btRaycastCallback.h deleted file mode 100644 index ea8104daf..000000000 --- a/bullet/src/BulletCollision/NarrowPhaseCollision/btRaycastCallback.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef RAYCAST_TRI_CALLBACK_H -#define RAYCAST_TRI_CALLBACK_H - -#include "BulletCollision/CollisionShapes/btTriangleCallback.h" -#include "LinearMath/btTransform.h" -struct btBroadphaseProxy; -class btConvexShape; - -class btTriangleRaycastCallback: public btTriangleCallback -{ -public: - - //input - btVector3 m_from; - btVector3 m_to; - - //@BP Mod - allow backface filtering and unflipped normals - enum EFlags - { - kF_None = 0, - kF_FilterBackfaces = 1 << 0, - kF_KeepUnflippedNormal = 1 << 1, // Prevents returned face normal getting flipped when a ray hits a back-facing triangle - - kF_Terminator = 0xFFFFFFFF - }; - unsigned int m_flags; - - btScalar m_hitFraction; - - btTriangleRaycastCallback(const btVector3& from,const btVector3& to, unsigned int flags=0); - - virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex); - - virtual btScalar reportHit(const btVector3& hitNormalLocal, btScalar hitFraction, int partId, int triangleIndex ) = 0; - -}; - -class btTriangleConvexcastCallback : public btTriangleCallback -{ -public: - const btConvexShape* m_convexShape; - btTransform m_convexShapeFrom; - btTransform m_convexShapeTo; - btTransform m_triangleToWorld; - btScalar m_hitFraction; - btScalar m_triangleCollisionMargin; - - btTriangleConvexcastCallback (const btConvexShape* convexShape, const btTransform& convexShapeFrom, const btTransform& convexShapeTo, const btTransform& triangleToWorld, const btScalar triangleCollisionMargin); - - virtual void processTriangle (btVector3* triangle, int partId, int triangleIndex); - - virtual btScalar reportHit (const btVector3& hitNormalLocal, const btVector3& hitPointLocal, btScalar hitFraction, int partId, int triangleIndex) = 0; -}; - -#endif //RAYCAST_TRI_CALLBACK_H - diff --git a/bullet/src/BulletCollision/NarrowPhaseCollision/btSimplexSolverInterface.h b/bullet/src/BulletCollision/NarrowPhaseCollision/btSimplexSolverInterface.h deleted file mode 100644 index b2708c161..000000000 --- a/bullet/src/BulletCollision/NarrowPhaseCollision/btSimplexSolverInterface.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - - -#ifndef SIMPLEX_SOLVER_INTERFACE_H -#define SIMPLEX_SOLVER_INTERFACE_H - -#include "LinearMath/btVector3.h" - -#define NO_VIRTUAL_INTERFACE 1 -#ifdef NO_VIRTUAL_INTERFACE -#include "btVoronoiSimplexSolver.h" -#define btSimplexSolverInterface btVoronoiSimplexSolver -#else - -/// btSimplexSolverInterface can incrementally calculate distance between origin and up to 4 vertices -/// Used by GJK or Linear Casting. Can be implemented by the Johnson-algorithm or alternative approaches based on -/// voronoi regions or barycentric coordinates -class btSimplexSolverInterface -{ - public: - virtual ~btSimplexSolverInterface() {}; - - virtual void reset() = 0; - - virtual void addVertex(const btVector3& w, const btVector3& p, const btVector3& q) = 0; - - virtual bool closest(btVector3& v) = 0; - - virtual btScalar maxVertex() = 0; - - virtual bool fullSimplex() const = 0; - - virtual int getSimplex(btVector3 *pBuf, btVector3 *qBuf, btVector3 *yBuf) const = 0; - - virtual bool inSimplex(const btVector3& w) = 0; - - virtual void backup_closest(btVector3& v) = 0; - - virtual bool emptySimplex() const = 0; - - virtual void compute_points(btVector3& p1, btVector3& p2) = 0; - - virtual int numVertices() const =0; - - -}; -#endif -#endif //SIMPLEX_SOLVER_INTERFACE_H - diff --git a/bullet/src/BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.cpp b/bullet/src/BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.cpp deleted file mode 100644 index 55405965b..000000000 --- a/bullet/src/BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#include "btSubSimplexConvexCast.h" -#include "BulletCollision/CollisionShapes/btConvexShape.h" - -#include "BulletCollision/CollisionShapes/btMinkowskiSumShape.h" -#include "BulletCollision/NarrowPhaseCollision/btSimplexSolverInterface.h" -#include "btPointCollector.h" -#include "LinearMath/btTransformUtil.h" - -btSubsimplexConvexCast::btSubsimplexConvexCast (const btConvexShape* convexA,const btConvexShape* convexB,btSimplexSolverInterface* simplexSolver) -:m_simplexSolver(simplexSolver), -m_convexA(convexA),m_convexB(convexB) -{ -} - -///Typically the conservative advancement reaches solution in a few iterations, clip it to 32 for degenerate cases. -///See discussion about this here http://continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=565 -#ifdef BT_USE_DOUBLE_PRECISION -#define MAX_ITERATIONS 64 -#else -#define MAX_ITERATIONS 32 -#endif -bool btSubsimplexConvexCast::calcTimeOfImpact( - const btTransform& fromA, - const btTransform& toA, - const btTransform& fromB, - const btTransform& toB, - CastResult& result) -{ - - m_simplexSolver->reset(); - - btVector3 linVelA,linVelB; - linVelA = toA.getOrigin()-fromA.getOrigin(); - linVelB = toB.getOrigin()-fromB.getOrigin(); - - btScalar lambda = btScalar(0.); - - btTransform interpolatedTransA = fromA; - btTransform interpolatedTransB = fromB; - - ///take relative motion - btVector3 r = (linVelA-linVelB); - btVector3 v; - - btVector3 supVertexA = fromA(m_convexA->localGetSupportingVertex(-r*fromA.getBasis())); - btVector3 supVertexB = fromB(m_convexB->localGetSupportingVertex(r*fromB.getBasis())); - v = supVertexA-supVertexB; - int maxIter = MAX_ITERATIONS; - - btVector3 n; - n.setValue(btScalar(0.),btScalar(0.),btScalar(0.)); - bool hasResult = false; - btVector3 c; - - btScalar lastLambda = lambda; - - - btScalar dist2 = v.length2(); -#ifdef BT_USE_DOUBLE_PRECISION - btScalar epsilon = btScalar(0.0001); -#else - btScalar epsilon = btScalar(0.0001); -#endif //BT_USE_DOUBLE_PRECISION - btVector3 w,p; - btScalar VdotR; - - while ( (dist2 > epsilon) && maxIter--) - { - supVertexA = interpolatedTransA(m_convexA->localGetSupportingVertex(-v*interpolatedTransA.getBasis())); - supVertexB = interpolatedTransB(m_convexB->localGetSupportingVertex(v*interpolatedTransB.getBasis())); - w = supVertexA-supVertexB; - - btScalar VdotW = v.dot(w); - - if (lambda > btScalar(1.0)) - { - return false; - } - - if ( VdotW > btScalar(0.)) - { - VdotR = v.dot(r); - - if (VdotR >= -(SIMD_EPSILON*SIMD_EPSILON)) - return false; - else - { - lambda = lambda - VdotW / VdotR; - //interpolate to next lambda - // x = s + lambda * r; - interpolatedTransA.getOrigin().setInterpolate3(fromA.getOrigin(),toA.getOrigin(),lambda); - interpolatedTransB.getOrigin().setInterpolate3(fromB.getOrigin(),toB.getOrigin(),lambda); - //m_simplexSolver->reset(); - //check next line - w = supVertexA-supVertexB; - lastLambda = lambda; - n = v; - hasResult = true; - } - } - m_simplexSolver->addVertex( w, supVertexA , supVertexB); - if (m_simplexSolver->closest(v)) - { - dist2 = v.length2(); - hasResult = true; - //todo: check this normal for validity - //n=v; - //printf("V=%f , %f, %f\n",v[0],v[1],v[2]); - //printf("DIST2=%f\n",dist2); - //printf("numverts = %i\n",m_simplexSolver->numVertices()); - } else - { - dist2 = btScalar(0.); - } - } - - //int numiter = MAX_ITERATIONS - maxIter; -// printf("number of iterations: %d", numiter); - - //don't report a time of impact when moving 'away' from the hitnormal - - - result.m_fraction = lambda; - if (n.length2() >= (SIMD_EPSILON*SIMD_EPSILON)) - result.m_normal = n.normalized(); - else - result.m_normal = btVector3(btScalar(0.0), btScalar(0.0), btScalar(0.0)); - - //don't report time of impact for motion away from the contact normal (or causes minor penetration) - if (result.m_normal.dot(r)>=-result.m_allowedPenetration) - return false; - - btVector3 hitA,hitB; - m_simplexSolver->compute_points(hitA,hitB); - result.m_hitPoint=hitB; - return true; -} - - - - diff --git a/bullet/src/BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h b/bullet/src/BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h deleted file mode 100644 index eaa472520..000000000 --- a/bullet/src/BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#ifndef SUBSIMPLEX_CONVEX_CAST_H -#define SUBSIMPLEX_CONVEX_CAST_H - -#include "btConvexCast.h" -#include "btSimplexSolverInterface.h" -class btConvexShape; - -/// btSubsimplexConvexCast implements Gino van den Bergens' paper -///"Ray Casting against bteral Convex Objects with Application to Continuous Collision Detection" -/// GJK based Ray Cast, optimized version -/// Objects should not start in overlap, otherwise results are not defined. -class btSubsimplexConvexCast : public btConvexCast -{ - btSimplexSolverInterface* m_simplexSolver; - const btConvexShape* m_convexA; - const btConvexShape* m_convexB; - -public: - - btSubsimplexConvexCast (const btConvexShape* shapeA,const btConvexShape* shapeB,btSimplexSolverInterface* simplexSolver); - - //virtual ~btSubsimplexConvexCast(); - ///SimsimplexConvexCast calculateTimeOfImpact calculates the time of impact+normal for the linear cast (sweep) between two moving objects. - ///Precondition is that objects should not penetration/overlap at the start from the interval. Overlap can be tested using btGjkPairDetector. - virtual bool calcTimeOfImpact( - const btTransform& fromA, - const btTransform& toA, - const btTransform& fromB, - const btTransform& toB, - CastResult& result); - -}; - -#endif //SUBSIMPLEX_CONVEX_CAST_H diff --git a/bullet/src/BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.cpp b/bullet/src/BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.cpp deleted file mode 100644 index 2ecf3c6ad..000000000 --- a/bullet/src/BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.cpp +++ /dev/null @@ -1,605 +0,0 @@ - -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. - - Elsevier CDROM license agreements grants nonexclusive license to use the software - for any purpose, commercial or non-commercial as long as the following credit is included - identifying the original source of the software: - - Parts of the source are "from the book Real-Time Collision Detection by - Christer Ericson, published by Morgan Kaufmann Publishers, - (c) 2005 Elsevier Inc." - -*/ - - -#include "btVoronoiSimplexSolver.h" - -#define VERTA 0 -#define VERTB 1 -#define VERTC 2 -#define VERTD 3 - -#define CATCH_DEGENERATE_TETRAHEDRON 1 -void btVoronoiSimplexSolver::removeVertex(int index) -{ - - btAssert(m_numVertices>0); - m_numVertices--; - m_simplexVectorW[index] = m_simplexVectorW[m_numVertices]; - m_simplexPointsP[index] = m_simplexPointsP[m_numVertices]; - m_simplexPointsQ[index] = m_simplexPointsQ[m_numVertices]; -} - -void btVoronoiSimplexSolver::reduceVertices (const btUsageBitfield& usedVerts) -{ - if ((numVertices() >= 4) && (!usedVerts.usedVertexD)) - removeVertex(3); - - if ((numVertices() >= 3) && (!usedVerts.usedVertexC)) - removeVertex(2); - - if ((numVertices() >= 2) && (!usedVerts.usedVertexB)) - removeVertex(1); - - if ((numVertices() >= 1) && (!usedVerts.usedVertexA)) - removeVertex(0); - -} - - - - - -//clear the simplex, remove all the vertices -void btVoronoiSimplexSolver::reset() -{ - m_cachedValidClosest = false; - m_numVertices = 0; - m_needsUpdate = true; - m_lastW = btVector3(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT)); - m_cachedBC.reset(); -} - - - - //add a vertex -void btVoronoiSimplexSolver::addVertex(const btVector3& w, const btVector3& p, const btVector3& q) -{ - m_lastW = w; - m_needsUpdate = true; - - m_simplexVectorW[m_numVertices] = w; - m_simplexPointsP[m_numVertices] = p; - m_simplexPointsQ[m_numVertices] = q; - - m_numVertices++; -} - -bool btVoronoiSimplexSolver::updateClosestVectorAndPoints() -{ - - if (m_needsUpdate) - { - m_cachedBC.reset(); - - m_needsUpdate = false; - - switch (numVertices()) - { - case 0: - m_cachedValidClosest = false; - break; - case 1: - { - m_cachedP1 = m_simplexPointsP[0]; - m_cachedP2 = m_simplexPointsQ[0]; - m_cachedV = m_cachedP1-m_cachedP2; //== m_simplexVectorW[0] - m_cachedBC.reset(); - m_cachedBC.setBarycentricCoordinates(btScalar(1.),btScalar(0.),btScalar(0.),btScalar(0.)); - m_cachedValidClosest = m_cachedBC.isValid(); - break; - }; - case 2: - { - //closest point origin from line segment - const btVector3& from = m_simplexVectorW[0]; - const btVector3& to = m_simplexVectorW[1]; - btVector3 nearest; - - btVector3 p (btScalar(0.),btScalar(0.),btScalar(0.)); - btVector3 diff = p - from; - btVector3 v = to - from; - btScalar t = v.dot(diff); - - if (t > 0) { - btScalar dotVV = v.dot(v); - if (t < dotVV) { - t /= dotVV; - diff -= t*v; - m_cachedBC.m_usedVertices.usedVertexA = true; - m_cachedBC.m_usedVertices.usedVertexB = true; - } else { - t = 1; - diff -= v; - //reduce to 1 point - m_cachedBC.m_usedVertices.usedVertexB = true; - } - } else - { - t = 0; - //reduce to 1 point - m_cachedBC.m_usedVertices.usedVertexA = true; - } - m_cachedBC.setBarycentricCoordinates(1-t,t); - nearest = from + t*v; - - m_cachedP1 = m_simplexPointsP[0] + t * (m_simplexPointsP[1] - m_simplexPointsP[0]); - m_cachedP2 = m_simplexPointsQ[0] + t * (m_simplexPointsQ[1] - m_simplexPointsQ[0]); - m_cachedV = m_cachedP1 - m_cachedP2; - - reduceVertices(m_cachedBC.m_usedVertices); - - m_cachedValidClosest = m_cachedBC.isValid(); - break; - } - case 3: - { - //closest point origin from triangle - btVector3 p (btScalar(0.),btScalar(0.),btScalar(0.)); - - const btVector3& a = m_simplexVectorW[0]; - const btVector3& b = m_simplexVectorW[1]; - const btVector3& c = m_simplexVectorW[2]; - - closestPtPointTriangle(p,a,b,c,m_cachedBC); - m_cachedP1 = m_simplexPointsP[0] * m_cachedBC.m_barycentricCoords[0] + - m_simplexPointsP[1] * m_cachedBC.m_barycentricCoords[1] + - m_simplexPointsP[2] * m_cachedBC.m_barycentricCoords[2]; - - m_cachedP2 = m_simplexPointsQ[0] * m_cachedBC.m_barycentricCoords[0] + - m_simplexPointsQ[1] * m_cachedBC.m_barycentricCoords[1] + - m_simplexPointsQ[2] * m_cachedBC.m_barycentricCoords[2]; - - m_cachedV = m_cachedP1-m_cachedP2; - - reduceVertices (m_cachedBC.m_usedVertices); - m_cachedValidClosest = m_cachedBC.isValid(); - - break; - } - case 4: - { - - - btVector3 p (btScalar(0.),btScalar(0.),btScalar(0.)); - - const btVector3& a = m_simplexVectorW[0]; - const btVector3& b = m_simplexVectorW[1]; - const btVector3& c = m_simplexVectorW[2]; - const btVector3& d = m_simplexVectorW[3]; - - bool hasSeperation = closestPtPointTetrahedron(p,a,b,c,d,m_cachedBC); - - if (hasSeperation) - { - - m_cachedP1 = m_simplexPointsP[0] * m_cachedBC.m_barycentricCoords[0] + - m_simplexPointsP[1] * m_cachedBC.m_barycentricCoords[1] + - m_simplexPointsP[2] * m_cachedBC.m_barycentricCoords[2] + - m_simplexPointsP[3] * m_cachedBC.m_barycentricCoords[3]; - - m_cachedP2 = m_simplexPointsQ[0] * m_cachedBC.m_barycentricCoords[0] + - m_simplexPointsQ[1] * m_cachedBC.m_barycentricCoords[1] + - m_simplexPointsQ[2] * m_cachedBC.m_barycentricCoords[2] + - m_simplexPointsQ[3] * m_cachedBC.m_barycentricCoords[3]; - - m_cachedV = m_cachedP1-m_cachedP2; - reduceVertices (m_cachedBC.m_usedVertices); - } else - { -// printf("sub distance got penetration\n"); - - if (m_cachedBC.m_degenerate) - { - m_cachedValidClosest = false; - } else - { - m_cachedValidClosest = true; - //degenerate case == false, penetration = true + zero - m_cachedV.setValue(btScalar(0.),btScalar(0.),btScalar(0.)); - } - break; - } - - m_cachedValidClosest = m_cachedBC.isValid(); - - //closest point origin from tetrahedron - break; - } - default: - { - m_cachedValidClosest = false; - } - }; - } - - return m_cachedValidClosest; - -} - -//return/calculate the closest vertex -bool btVoronoiSimplexSolver::closest(btVector3& v) -{ - bool succes = updateClosestVectorAndPoints(); - v = m_cachedV; - return succes; -} - - - -btScalar btVoronoiSimplexSolver::maxVertex() -{ - int i, numverts = numVertices(); - btScalar maxV = btScalar(0.); - for (i=0;i= btScalar(0.0) && d4 <= d3) - { - result.m_closestPointOnSimplex = b; - result.m_usedVertices.usedVertexB = true; - result.setBarycentricCoordinates(0,1,0); - - return true; // b; // barycentric coordinates (0,1,0) - } - // Check if P in edge region of AB, if so return projection of P onto AB - btScalar vc = d1*d4 - d3*d2; - if (vc <= btScalar(0.0) && d1 >= btScalar(0.0) && d3 <= btScalar(0.0)) { - btScalar v = d1 / (d1 - d3); - result.m_closestPointOnSimplex = a + v * ab; - result.m_usedVertices.usedVertexA = true; - result.m_usedVertices.usedVertexB = true; - result.setBarycentricCoordinates(1-v,v,0); - return true; - //return a + v * ab; // barycentric coordinates (1-v,v,0) - } - - // Check if P in vertex region outside C - btVector3 cp = p - c; - btScalar d5 = ab.dot(cp); - btScalar d6 = ac.dot(cp); - if (d6 >= btScalar(0.0) && d5 <= d6) - { - result.m_closestPointOnSimplex = c; - result.m_usedVertices.usedVertexC = true; - result.setBarycentricCoordinates(0,0,1); - return true;//c; // barycentric coordinates (0,0,1) - } - - // Check if P in edge region of AC, if so return projection of P onto AC - btScalar vb = d5*d2 - d1*d6; - if (vb <= btScalar(0.0) && d2 >= btScalar(0.0) && d6 <= btScalar(0.0)) { - btScalar w = d2 / (d2 - d6); - result.m_closestPointOnSimplex = a + w * ac; - result.m_usedVertices.usedVertexA = true; - result.m_usedVertices.usedVertexC = true; - result.setBarycentricCoordinates(1-w,0,w); - return true; - //return a + w * ac; // barycentric coordinates (1-w,0,w) - } - - // Check if P in edge region of BC, if so return projection of P onto BC - btScalar va = d3*d6 - d5*d4; - if (va <= btScalar(0.0) && (d4 - d3) >= btScalar(0.0) && (d5 - d6) >= btScalar(0.0)) { - btScalar w = (d4 - d3) / ((d4 - d3) + (d5 - d6)); - - result.m_closestPointOnSimplex = b + w * (c - b); - result.m_usedVertices.usedVertexB = true; - result.m_usedVertices.usedVertexC = true; - result.setBarycentricCoordinates(0,1-w,w); - return true; - // return b + w * (c - b); // barycentric coordinates (0,1-w,w) - } - - // P inside face region. Compute Q through its barycentric coordinates (u,v,w) - btScalar denom = btScalar(1.0) / (va + vb + vc); - btScalar v = vb * denom; - btScalar w = vc * denom; - - result.m_closestPointOnSimplex = a + ab * v + ac * w; - result.m_usedVertices.usedVertexA = true; - result.m_usedVertices.usedVertexB = true; - result.m_usedVertices.usedVertexC = true; - result.setBarycentricCoordinates(1-v-w,v,w); - - return true; -// return a + ab * v + ac * w; // = u*a + v*b + w*c, u = va * denom = btScalar(1.0) - v - w - -} - - - - - -/// Test if point p and d lie on opposite sides of plane through abc -int btVoronoiSimplexSolver::pointOutsideOfPlane(const btVector3& p, const btVector3& a, const btVector3& b, const btVector3& c, const btVector3& d) -{ - btVector3 normal = (b-a).cross(c-a); - - btScalar signp = (p - a).dot(normal); // [AP AB AC] - btScalar signd = (d - a).dot( normal); // [AD AB AC] - -#ifdef CATCH_DEGENERATE_TETRAHEDRON -#ifdef BT_USE_DOUBLE_PRECISION -if (signd * signd < (btScalar(1e-8) * btScalar(1e-8))) - { - return -1; - } -#else - if (signd * signd < (btScalar(1e-4) * btScalar(1e-4))) - { -// printf("affine dependent/degenerate\n");// - return -1; - } -#endif - -#endif - // Points on opposite sides if expression signs are opposite - return signp * signd < btScalar(0.); -} - - -bool btVoronoiSimplexSolver::closestPtPointTetrahedron(const btVector3& p, const btVector3& a, const btVector3& b, const btVector3& c, const btVector3& d, btSubSimplexClosestResult& finalResult) -{ - btSubSimplexClosestResult tempResult; - - // Start out assuming point inside all halfspaces, so closest to itself - finalResult.m_closestPointOnSimplex = p; - finalResult.m_usedVertices.reset(); - finalResult.m_usedVertices.usedVertexA = true; - finalResult.m_usedVertices.usedVertexB = true; - finalResult.m_usedVertices.usedVertexC = true; - finalResult.m_usedVertices.usedVertexD = true; - - int pointOutsideABC = pointOutsideOfPlane(p, a, b, c, d); - int pointOutsideACD = pointOutsideOfPlane(p, a, c, d, b); - int pointOutsideADB = pointOutsideOfPlane(p, a, d, b, c); - int pointOutsideBDC = pointOutsideOfPlane(p, b, d, c, a); - - if (pointOutsideABC < 0 || pointOutsideACD < 0 || pointOutsideADB < 0 || pointOutsideBDC < 0) - { - finalResult.m_degenerate = true; - return false; - } - - if (!pointOutsideABC && !pointOutsideACD && !pointOutsideADB && !pointOutsideBDC) - { - return false; - } - - - btScalar bestSqDist = FLT_MAX; - // If point outside face abc then compute closest point on abc - if (pointOutsideABC) - { - closestPtPointTriangle(p, a, b, c,tempResult); - btVector3 q = tempResult.m_closestPointOnSimplex; - - btScalar sqDist = (q - p).dot( q - p); - // Update best closest point if (squared) distance is less than current best - if (sqDist < bestSqDist) { - bestSqDist = sqDist; - finalResult.m_closestPointOnSimplex = q; - //convert result bitmask! - finalResult.m_usedVertices.reset(); - finalResult.m_usedVertices.usedVertexA = tempResult.m_usedVertices.usedVertexA; - finalResult.m_usedVertices.usedVertexB = tempResult.m_usedVertices.usedVertexB; - finalResult.m_usedVertices.usedVertexC = tempResult.m_usedVertices.usedVertexC; - finalResult.setBarycentricCoordinates( - tempResult.m_barycentricCoords[VERTA], - tempResult.m_barycentricCoords[VERTB], - tempResult.m_barycentricCoords[VERTC], - 0 - ); - - } - } - - - // Repeat test for face acd - if (pointOutsideACD) - { - closestPtPointTriangle(p, a, c, d,tempResult); - btVector3 q = tempResult.m_closestPointOnSimplex; - //convert result bitmask! - - btScalar sqDist = (q - p).dot( q - p); - if (sqDist < bestSqDist) - { - bestSqDist = sqDist; - finalResult.m_closestPointOnSimplex = q; - finalResult.m_usedVertices.reset(); - finalResult.m_usedVertices.usedVertexA = tempResult.m_usedVertices.usedVertexA; - - finalResult.m_usedVertices.usedVertexC = tempResult.m_usedVertices.usedVertexB; - finalResult.m_usedVertices.usedVertexD = tempResult.m_usedVertices.usedVertexC; - finalResult.setBarycentricCoordinates( - tempResult.m_barycentricCoords[VERTA], - 0, - tempResult.m_barycentricCoords[VERTB], - tempResult.m_barycentricCoords[VERTC] - ); - - } - } - // Repeat test for face adb - - - if (pointOutsideADB) - { - closestPtPointTriangle(p, a, d, b,tempResult); - btVector3 q = tempResult.m_closestPointOnSimplex; - //convert result bitmask! - - btScalar sqDist = (q - p).dot( q - p); - if (sqDist < bestSqDist) - { - bestSqDist = sqDist; - finalResult.m_closestPointOnSimplex = q; - finalResult.m_usedVertices.reset(); - finalResult.m_usedVertices.usedVertexA = tempResult.m_usedVertices.usedVertexA; - finalResult.m_usedVertices.usedVertexB = tempResult.m_usedVertices.usedVertexC; - - finalResult.m_usedVertices.usedVertexD = tempResult.m_usedVertices.usedVertexB; - finalResult.setBarycentricCoordinates( - tempResult.m_barycentricCoords[VERTA], - tempResult.m_barycentricCoords[VERTC], - 0, - tempResult.m_barycentricCoords[VERTB] - ); - - } - } - // Repeat test for face bdc - - - if (pointOutsideBDC) - { - closestPtPointTriangle(p, b, d, c,tempResult); - btVector3 q = tempResult.m_closestPointOnSimplex; - //convert result bitmask! - btScalar sqDist = (q - p).dot( q - p); - if (sqDist < bestSqDist) - { - bestSqDist = sqDist; - finalResult.m_closestPointOnSimplex = q; - finalResult.m_usedVertices.reset(); - // - finalResult.m_usedVertices.usedVertexB = tempResult.m_usedVertices.usedVertexA; - finalResult.m_usedVertices.usedVertexC = tempResult.m_usedVertices.usedVertexC; - finalResult.m_usedVertices.usedVertexD = tempResult.m_usedVertices.usedVertexB; - - finalResult.setBarycentricCoordinates( - 0, - tempResult.m_barycentricCoords[VERTA], - tempResult.m_barycentricCoords[VERTC], - tempResult.m_barycentricCoords[VERTB] - ); - - } - } - - //help! we ended up full ! - - if (finalResult.m_usedVertices.usedVertexA && - finalResult.m_usedVertices.usedVertexB && - finalResult.m_usedVertices.usedVertexC && - finalResult.m_usedVertices.usedVertexD) - { - return true; - } - - return true; -} - diff --git a/bullet/src/BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h b/bullet/src/BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h deleted file mode 100644 index ee61ecbfb..000000000 --- a/bullet/src/BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h +++ /dev/null @@ -1,157 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - - -#ifndef btVoronoiSimplexSolver_H -#define btVoronoiSimplexSolver_H - -#include "btSimplexSolverInterface.h" - - - -#define VORONOI_SIMPLEX_MAX_VERTS 5 - -struct btUsageBitfield{ - btUsageBitfield() - { - reset(); - } - - void reset() - { - usedVertexA = false; - usedVertexB = false; - usedVertexC = false; - usedVertexD = false; - } - unsigned short usedVertexA : 1; - unsigned short usedVertexB : 1; - unsigned short usedVertexC : 1; - unsigned short usedVertexD : 1; - unsigned short unused1 : 1; - unsigned short unused2 : 1; - unsigned short unused3 : 1; - unsigned short unused4 : 1; -}; - - -struct btSubSimplexClosestResult -{ - btVector3 m_closestPointOnSimplex; - //MASK for m_usedVertices - //stores the simplex vertex-usage, using the MASK, - // if m_usedVertices & MASK then the related vertex is used - btUsageBitfield m_usedVertices; - btScalar m_barycentricCoords[4]; - bool m_degenerate; - - void reset() - { - m_degenerate = false; - setBarycentricCoordinates(); - m_usedVertices.reset(); - } - bool isValid() - { - bool valid = (m_barycentricCoords[0] >= btScalar(0.)) && - (m_barycentricCoords[1] >= btScalar(0.)) && - (m_barycentricCoords[2] >= btScalar(0.)) && - (m_barycentricCoords[3] >= btScalar(0.)); - - - return valid; - } - void setBarycentricCoordinates(btScalar a=btScalar(0.),btScalar b=btScalar(0.),btScalar c=btScalar(0.),btScalar d=btScalar(0.)) - { - m_barycentricCoords[0] = a; - m_barycentricCoords[1] = b; - m_barycentricCoords[2] = c; - m_barycentricCoords[3] = d; - } - -}; - -/// btVoronoiSimplexSolver is an implementation of the closest point distance algorithm from a 1-4 points simplex to the origin. -/// Can be used with GJK, as an alternative to Johnson distance algorithm. -#ifdef NO_VIRTUAL_INTERFACE -class btVoronoiSimplexSolver -#else -class btVoronoiSimplexSolver : public btSimplexSolverInterface -#endif -{ -public: - - int m_numVertices; - - btVector3 m_simplexVectorW[VORONOI_SIMPLEX_MAX_VERTS]; - btVector3 m_simplexPointsP[VORONOI_SIMPLEX_MAX_VERTS]; - btVector3 m_simplexPointsQ[VORONOI_SIMPLEX_MAX_VERTS]; - - - - btVector3 m_cachedP1; - btVector3 m_cachedP2; - btVector3 m_cachedV; - btVector3 m_lastW; - bool m_cachedValidClosest; - - btSubSimplexClosestResult m_cachedBC; - - bool m_needsUpdate; - - void removeVertex(int index); - void reduceVertices (const btUsageBitfield& usedVerts); - bool updateClosestVectorAndPoints(); - - bool closestPtPointTetrahedron(const btVector3& p, const btVector3& a, const btVector3& b, const btVector3& c, const btVector3& d, btSubSimplexClosestResult& finalResult); - int pointOutsideOfPlane(const btVector3& p, const btVector3& a, const btVector3& b, const btVector3& c, const btVector3& d); - bool closestPtPointTriangle(const btVector3& p, const btVector3& a, const btVector3& b, const btVector3& c,btSubSimplexClosestResult& result); - -public: - - void reset(); - - void addVertex(const btVector3& w, const btVector3& p, const btVector3& q); - - - bool closest(btVector3& v); - - btScalar maxVertex(); - - bool fullSimplex() const - { - return (m_numVertices == 4); - } - - int getSimplex(btVector3 *pBuf, btVector3 *qBuf, btVector3 *yBuf) const; - - bool inSimplex(const btVector3& w); - - void backup_closest(btVector3& v) ; - - bool emptySimplex() const ; - - void compute_points(btVector3& p1, btVector3& p2) ; - - int numVertices() const - { - return m_numVertices; - } - - -}; - -#endif //VoronoiSimplexSolver diff --git a/bullet/src/BulletCollision/ibmsdk/Makefile b/bullet/src/BulletCollision/ibmsdk/Makefile deleted file mode 100644 index 82d5fd646..000000000 --- a/bullet/src/BulletCollision/ibmsdk/Makefile +++ /dev/null @@ -1,112 +0,0 @@ -#### Source code Dirs -VPATH = \ -../BroadphaseCollision \ -../CollisionDispatch \ -../NarrowPhaseCollision \ -../CollisionShapes - -ROOT = ../../.. - -#### Library -LIBRARY_ppu = bulletcollision.a - -#### Compiler flags -CPPFLAGS = \ --DUSE_LIBSPE2 \ --I../BroadphaseCollision \ --I../CollisionDispath \ --I../NarrowPhaseCollision \ --I../CollisionShapes \ --I$(ROOT)/src/ \ --I$(SDKINC) - -#### Optimization level flags -#CC_OPT_LEVEL = $(CC_OPT_LEVEL_DEBUG) -CC_OPT_LEVEL = -O3 - -##### Objects to be archived in lib - -OBJS = \ -btAxisSweep3.o \ -btQuantizedBvh.o \ -btBroadphaseProxy.o \ -btCollisionAlgorithm.o \ -btDispatcher.o \ -btDbvtBroadphase.o \ -btDbvt.o \ -btOverlappingPairCache.o \ -btSimpleBroadphase.o \ -btContinuousConvexCollision.o \ -btConvexCast.o \ -btGjkConvexCast.o \ -btGjkEpa2.o \ -btGjkEpaPenetrationDepthSolver.o \ -btGjkPairDetector.o \ -btDefaultCollisionConfiguration.o \ -btMinkowskiPenetrationDepthSolver.o \ -btPersistentManifold.o \ -btRaycastCallback.o \ -btSubSimplexConvexCast.o \ -btVoronoiSimplexSolver.o \ -btCollisionDispatcher.o \ -btCollisionObject.o \ -btCollisionWorld.o \ -btCompoundCollisionAlgorithm.o \ -btBoxBoxCollisionAlgorithm.o \ -btBoxBoxDetector.o \ -btConvexPlaneCollisionAlgorithm.o \ -btConvexConcaveCollisionAlgorithm.o \ -btConvexConvexAlgorithm.o \ -btDefaultCollisionConfiguration.o \ -btEmptyCollisionAlgorithm.o \ -btManifoldResult.o \ -btSimulationIslandManager.o \ -btSphereBoxCollisionAlgorithm.o \ -btSphereSphereCollisionAlgorithm.o \ -btSphereTriangleCollisionAlgorithm.o \ -btActivatingCollisionAlgorithm.o \ -btUnionFind.o \ -SphereTriangleDetector.o \ -btBoxShape.o \ -btBvhTriangleMeshShape.o \ -btCapsuleShape.o \ -btCollisionShape.o \ -btCompoundShape.o \ -btConcaveShape.o \ -btConeShape.o \ -btConvexHullShape.o \ -btConvexShape.o \ -btConvexInternalShape.o \ -btConvexTriangleMeshShape.o \ -btCylinderShape.o \ -btEmptyShape.o \ -btHeightfieldTerrainShape.o \ -btMinkowskiSumShape.o \ -btMultiSphereShape.o \ -btOptimizedBvh.o \ -btPolyhedralConvexShape.o \ -btSphereShape.o \ -btStaticPlaneShape.o \ -btStridingMeshInterface.o \ -btTetrahedronShape.o \ -btTriangleBuffer.o \ -btTriangleCallback.o \ -btTriangleIndexVertexArray.o \ -btTriangleMesh.o \ -btTriangleMeshShape.o \ -btUniformScalingShape.o - -#### Install directories -INSTALL_DIR = $(ROOT)/lib/ibmsdk -INSTALL_FILES = $(LIBRARY_ppu) - -IBM_CELLSDK_VERSION := $(shell if [ -d /opt/cell ]; then echo "3.0"; fi) - -ifeq ("$(IBM_CELLSDK_VERSION)","3.0") - CELL_TOP ?= /opt/cell/sdk - include $(CELL_TOP)/buildutils/make.footer -else - CELL_TOP ?= /opt/ibm/cell-sdk/prototype - include $(CELL_TOP)/make.footer -endif - diff --git a/bullet/src/BulletDynamics/CMakeLists.txt b/bullet/src/BulletDynamics/CMakeLists.txt deleted file mode 100644 index fa2d21cb4..000000000 --- a/bullet/src/BulletDynamics/CMakeLists.txt +++ /dev/null @@ -1,108 +0,0 @@ -INCLUDE_DIRECTORIES( ${BULLET_PHYSICS_SOURCE_DIR}/src ) - - - -SET(BulletDynamics_SRCS - Character/btKinematicCharacterController.cpp - ConstraintSolver/btConeTwistConstraint.cpp - ConstraintSolver/btContactConstraint.cpp - ConstraintSolver/btGeneric6DofConstraint.cpp - ConstraintSolver/btGeneric6DofSpringConstraint.cpp - ConstraintSolver/btHinge2Constraint.cpp - ConstraintSolver/btHingeConstraint.cpp - ConstraintSolver/btPoint2PointConstraint.cpp - ConstraintSolver/btSequentialImpulseConstraintSolver.cpp - ConstraintSolver/btSliderConstraint.cpp - ConstraintSolver/btSolve2LinearConstraint.cpp - ConstraintSolver/btTypedConstraint.cpp - ConstraintSolver/btUniversalConstraint.cpp - Dynamics/btContinuousDynamicsWorld.cpp - Dynamics/btDiscreteDynamicsWorld.cpp - Dynamics/btRigidBody.cpp - Dynamics/btSimpleDynamicsWorld.cpp - Dynamics/Bullet-C-API.cpp - Vehicle/btRaycastVehicle.cpp - Vehicle/btWheelInfo.cpp -) - -SET(Root_HDRS - ../btBulletDynamicsCommon.h - ../btBulletCollisionCommon.h -) -SET(ConstraintSolver_HDRS - ConstraintSolver/btConeTwistConstraint.h - ConstraintSolver/btConstraintSolver.h - ConstraintSolver/btContactConstraint.h - ConstraintSolver/btContactSolverInfo.h - ConstraintSolver/btGeneric6DofConstraint.h - ConstraintSolver/btGeneric6DofSpringConstraint.h - ConstraintSolver/btHinge2Constraint.h - ConstraintSolver/btHingeConstraint.h - ConstraintSolver/btJacobianEntry.h - ConstraintSolver/btPoint2PointConstraint.h - ConstraintSolver/btSequentialImpulseConstraintSolver.h - ConstraintSolver/btSliderConstraint.h - ConstraintSolver/btSolve2LinearConstraint.h - ConstraintSolver/btSolverBody.h - ConstraintSolver/btSolverConstraint.h - ConstraintSolver/btTypedConstraint.h - ConstraintSolver/btUniversalConstraint.h -) -SET(Dynamics_HDRS - Dynamics/btActionInterface.h - Dynamics/btContinuousDynamicsWorld.h - Dynamics/btDiscreteDynamicsWorld.h - Dynamics/btDynamicsWorld.h - Dynamics/btSimpleDynamicsWorld.h - Dynamics/btRigidBody.h -) -SET(Vehicle_HDRS - Vehicle/btRaycastVehicle.h - Vehicle/btVehicleRaycaster.h - Vehicle/btWheelInfo.h -) - -SET(Character_HDRS - Character/btCharacterControllerInterface.h - Character/btKinematicCharacterController.h -) - - - -SET(BulletDynamics_HDRS - ${Root_HDRS} - ${ConstraintSolver_HDRS} - ${Dynamics_HDRS} - ${Vehicle_HDRS} - ${Character_HDRS} -) - - -ADD_LIBRARY(BulletDynamics ${BulletDynamics_SRCS} ${BulletDynamics_HDRS}) -SET_TARGET_PROPERTIES(BulletDynamics PROPERTIES VERSION ${BULLET_VERSION}) -SET_TARGET_PROPERTIES(BulletDynamics PROPERTIES SOVERSION ${BULLET_VERSION}) -IF (BUILD_SHARED_LIBS) - TARGET_LINK_LIBRARIES(BulletDynamics BulletCollision LinearMath) -ENDIF (BUILD_SHARED_LIBS) - -IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) - IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) - INSTALL(TARGETS BulletDynamics DESTINATION .) - ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) - INSTALL(TARGETS BulletDynamics DESTINATION lib${LIB_SUFFIX}) - INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION include FILES_MATCHING PATTERN "*.h") - INSTALL(FILES ../btBulletDynamicsCommon.h DESTINATION include/BulletDynamics) - ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) -ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) - -IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) - SET_TARGET_PROPERTIES(BulletDynamics PROPERTIES FRAMEWORK true) - - SET_TARGET_PROPERTIES(BulletDynamics PROPERTIES PUBLIC_HEADER ${Root_HDRS}) - # Have to list out sub-directories manually: - SET_PROPERTY(SOURCE ${ConstraintSolver_HDRS} PROPERTY MACOSX_PACKAGE_LOCATION Headers/ConstraintSolver) - SET_PROPERTY(SOURCE ${Dynamics_HDRS} PROPERTY MACOSX_PACKAGE_LOCATION Headers/Dynamics) - SET_PROPERTY(SOURCE ${Vehicle_HDRS} PROPERTY MACOSX_PACKAGE_LOCATION Headers/Vehicle) - SET_PROPERTY(SOURCE ${Character_HDRS} PROPERTY MACOSX_PACKAGE_LOCATION Headers/Character) - -ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) diff --git a/bullet/src/BulletDynamics/Character/btCharacterControllerInterface.h b/bullet/src/BulletDynamics/Character/btCharacterControllerInterface.h deleted file mode 100644 index 8d4f6a9f0..000000000 --- a/bullet/src/BulletDynamics/Character/btCharacterControllerInterface.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2008 Erwin Coumans http://bulletphysics.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef CHARACTER_CONTROLLER_INTERFACE_H -#define CHARACTER_CONTROLLER_INTERFACE_H - -#include "LinearMath/btVector3.h" -#include "BulletDynamics/Dynamics/btActionInterface.h" - -class btCollisionShape; -class btRigidBody; -class btCollisionWorld; - -class btCharacterControllerInterface : public btActionInterface -{ -public: - btCharacterControllerInterface () {}; - virtual ~btCharacterControllerInterface () {}; - - virtual void setWalkDirection(const btVector3& walkDirection) = 0; - virtual void setVelocityForTimeInterval(const btVector3& velocity, btScalar timeInterval) = 0; - virtual void reset () = 0; - virtual void warp (const btVector3& origin) = 0; - - virtual void preStep ( btCollisionWorld* collisionWorld) = 0; - virtual void playerStep (btCollisionWorld* collisionWorld, btScalar dt) = 0; - virtual bool canJump () const = 0; - virtual void jump () = 0; - - virtual bool onGround () const = 0; -}; - -#endif diff --git a/bullet/src/BulletDynamics/Character/btKinematicCharacterController.cpp b/bullet/src/BulletDynamics/Character/btKinematicCharacterController.cpp deleted file mode 100644 index 1f9670fdd..000000000 --- a/bullet/src/BulletDynamics/Character/btKinematicCharacterController.cpp +++ /dev/null @@ -1,547 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2008 Erwin Coumans http://bulletphysics.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#include "LinearMath/btIDebugDraw.h" -#include "BulletCollision/CollisionDispatch/btGhostObject.h" -#include "BulletCollision/CollisionShapes/btMultiSphereShape.h" -#include "BulletCollision/BroadphaseCollision/btOverlappingPairCache.h" -#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h" -#include "BulletCollision/CollisionDispatch/btCollisionWorld.h" -#include "LinearMath/btDefaultMotionState.h" -#include "btKinematicCharacterController.h" - -static btVector3 upAxisDirection[3] = { btVector3(1.0f, 0.0f, 0.0f), btVector3(0.0f, 1.0f, 0.0f), btVector3(0.0f, 0.0f, 1.0f) }; - - -// static helper method -static btVector3 -getNormalizedVector(const btVector3& v) -{ - btVector3 n = v.normalized(); - if (n.length() < SIMD_EPSILON) { - n.setValue(0, 0, 0); - } - return n; -} - - -///@todo Interact with dynamic objects, -///Ride kinematicly animated platforms properly -///More realistic (or maybe just a config option) falling -/// -> Should integrate falling velocity manually and use that in stepDown() -///Support jumping -///Support ducking -class btKinematicClosestNotMeRayResultCallback : public btCollisionWorld::ClosestRayResultCallback -{ -public: - btKinematicClosestNotMeRayResultCallback (btCollisionObject* me) : btCollisionWorld::ClosestRayResultCallback(btVector3(0.0, 0.0, 0.0), btVector3(0.0, 0.0, 0.0)) - { - m_me = me; - } - - virtual btScalar addSingleResult(btCollisionWorld::LocalRayResult& rayResult,bool normalInWorldSpace) - { - if (rayResult.m_collisionObject == m_me) - return 1.0; - - return ClosestRayResultCallback::addSingleResult (rayResult, normalInWorldSpace); - } -protected: - btCollisionObject* m_me; -}; - -class btKinematicClosestNotMeConvexResultCallback : public btCollisionWorld::ClosestConvexResultCallback -{ -public: - btKinematicClosestNotMeConvexResultCallback (btCollisionObject* me) : btCollisionWorld::ClosestConvexResultCallback(btVector3(0.0, 0.0, 0.0), btVector3(0.0, 0.0, 0.0)) - { - m_me = me; - } - - virtual btScalar addSingleResult(btCollisionWorld::LocalConvexResult& convexResult,bool normalInWorldSpace) - { - if (convexResult.m_hitCollisionObject == m_me) - return 1.0; - - return ClosestConvexResultCallback::addSingleResult (convexResult, normalInWorldSpace); - } -protected: - btCollisionObject* m_me; -}; - -/* - * Returns the reflection direction of a ray going 'direction' hitting a surface with normal 'normal' - * - * from: http://www-cs-students.stanford.edu/~adityagp/final/node3.html - */ -btVector3 btKinematicCharacterController::computeReflectionDirection (const btVector3& direction, const btVector3& normal) -{ - return direction - (btScalar(2.0) * direction.dot(normal)) * normal; -} - -/* - * Returns the portion of 'direction' that is parallel to 'normal' - */ -btVector3 btKinematicCharacterController::parallelComponent (const btVector3& direction, const btVector3& normal) -{ - btScalar magnitude = direction.dot(normal); - return normal * magnitude; -} - -/* - * Returns the portion of 'direction' that is perpindicular to 'normal' - */ -btVector3 btKinematicCharacterController::perpindicularComponent (const btVector3& direction, const btVector3& normal) -{ - return direction - parallelComponent(direction, normal); -} - -btKinematicCharacterController::btKinematicCharacterController (btPairCachingGhostObject* ghostObject,btConvexShape* convexShape,btScalar stepHeight, int upAxis) -{ - m_upAxis = upAxis; - m_addedMargin = 0.02f; - m_walkDirection.setValue(0,0,0); - m_useGhostObjectSweepTest = true; - m_ghostObject = ghostObject; - m_stepHeight = stepHeight; - m_turnAngle = btScalar(0.0); - m_convexShape=convexShape; - m_useWalkDirection = true; // use walk direction by default, legacy behavior - m_velocityTimeInterval = 0.0; -} - -btKinematicCharacterController::~btKinematicCharacterController () -{ -} - -btPairCachingGhostObject* btKinematicCharacterController::getGhostObject() -{ - return m_ghostObject; -} - -bool btKinematicCharacterController::recoverFromPenetration ( btCollisionWorld* collisionWorld) -{ - - bool penetration = false; - - collisionWorld->getDispatcher()->dispatchAllCollisionPairs(m_ghostObject->getOverlappingPairCache(), collisionWorld->getDispatchInfo(), collisionWorld->getDispatcher()); - - m_currentPosition = m_ghostObject->getWorldTransform().getOrigin(); - - btScalar maxPen = btScalar(0.0); - for (int i = 0; i < m_ghostObject->getOverlappingPairCache()->getNumOverlappingPairs(); i++) - { - m_manifoldArray.resize(0); - - btBroadphasePair* collisionPair = &m_ghostObject->getOverlappingPairCache()->getOverlappingPairArray()[i]; - - if (collisionPair->m_algorithm) - collisionPair->m_algorithm->getAllContactManifolds(m_manifoldArray); - - - for (int j=0;jgetBody0() == m_ghostObject ? btScalar(-1.0) : btScalar(1.0); - for (int p=0;pgetNumContacts();p++) - { - const btManifoldPoint&pt = manifold->getContactPoint(p); - - if (pt.getDistance() < 0.0) - { - if (pt.getDistance() < maxPen) - { - maxPen = pt.getDistance(); - m_touchingNormal = pt.m_normalWorldOnB * directionSign;//?? - - } - m_currentPosition += pt.m_normalWorldOnB * directionSign * pt.getDistance() * btScalar(0.2); - penetration = true; - } else { - //printf("touching %f\n", pt.getDistance()); - } - } - - //manifold->clearManifold(); - } - } - btTransform newTrans = m_ghostObject->getWorldTransform(); - newTrans.setOrigin(m_currentPosition); - m_ghostObject->setWorldTransform(newTrans); -// printf("m_touchingNormal = %f,%f,%f\n",m_touchingNormal[0],m_touchingNormal[1],m_touchingNormal[2]); - return penetration; -} - -void btKinematicCharacterController::stepUp ( btCollisionWorld* world) -{ - // phase 1: up - btTransform start, end; - m_targetPosition = m_currentPosition + upAxisDirection[m_upAxis] * m_stepHeight; - - start.setIdentity (); - end.setIdentity (); - - /* FIXME: Handle penetration properly */ - start.setOrigin (m_currentPosition + upAxisDirection[m_upAxis] * btScalar(0.1f)); - end.setOrigin (m_targetPosition); - - btKinematicClosestNotMeConvexResultCallback callback (m_ghostObject); - callback.m_collisionFilterGroup = getGhostObject()->getBroadphaseHandle()->m_collisionFilterGroup; - callback.m_collisionFilterMask = getGhostObject()->getBroadphaseHandle()->m_collisionFilterMask; - - if (m_useGhostObjectSweepTest) - { - m_ghostObject->convexSweepTest (m_convexShape, start, end, callback, world->getDispatchInfo().m_allowedCcdPenetration); - } - else - { - world->convexSweepTest (m_convexShape, start, end, callback); - } - - if (callback.hasHit()) - { - // we moved up only a fraction of the step height - m_currentStepOffset = m_stepHeight * callback.m_closestHitFraction; - m_currentPosition.setInterpolate3 (m_currentPosition, m_targetPosition, callback.m_closestHitFraction); - } else { - m_currentStepOffset = m_stepHeight; - m_currentPosition = m_targetPosition; - } -} - -void btKinematicCharacterController::updateTargetPositionBasedOnCollision (const btVector3& hitNormal, btScalar tangentMag, btScalar normalMag) -{ - btVector3 movementDirection = m_targetPosition - m_currentPosition; - btScalar movementLength = movementDirection.length(); - if (movementLength>SIMD_EPSILON) - { - movementDirection.normalize(); - - btVector3 reflectDir = computeReflectionDirection (movementDirection, hitNormal); - reflectDir.normalize(); - - btVector3 parallelDir, perpindicularDir; - - parallelDir = parallelComponent (reflectDir, hitNormal); - perpindicularDir = perpindicularComponent (reflectDir, hitNormal); - - m_targetPosition = m_currentPosition; - if (0)//tangentMag != 0.0) - { - btVector3 parComponent = parallelDir * btScalar (tangentMag*movementLength); -// printf("parComponent=%f,%f,%f\n",parComponent[0],parComponent[1],parComponent[2]); - m_targetPosition += parComponent; - } - - if (normalMag != 0.0) - { - btVector3 perpComponent = perpindicularDir * btScalar (normalMag*movementLength); -// printf("perpComponent=%f,%f,%f\n",perpComponent[0],perpComponent[1],perpComponent[2]); - m_targetPosition += perpComponent; - } - } else - { -// printf("movementLength don't normalize a zero vector\n"); - } -} - -void btKinematicCharacterController::stepForwardAndStrafe ( btCollisionWorld* collisionWorld, const btVector3& walkMove) -{ - // printf("m_normalizedDirection=%f,%f,%f\n", - // m_normalizedDirection[0],m_normalizedDirection[1],m_normalizedDirection[2]); - // phase 2: forward and strafe - btTransform start, end; - m_targetPosition = m_currentPosition + walkMove; - start.setIdentity (); - end.setIdentity (); - - btScalar fraction = 1.0; - btScalar distance2 = (m_currentPosition-m_targetPosition).length2(); -// printf("distance2=%f\n",distance2); - - if (m_touchingContact) - { - if (m_normalizedDirection.dot(m_touchingNormal) > btScalar(0.0)) - updateTargetPositionBasedOnCollision (m_touchingNormal); - } - - int maxIter = 10; - - while (fraction > btScalar(0.01) && maxIter-- > 0) - { - start.setOrigin (m_currentPosition); - end.setOrigin (m_targetPosition); - - btKinematicClosestNotMeConvexResultCallback callback (m_ghostObject); - callback.m_collisionFilterGroup = getGhostObject()->getBroadphaseHandle()->m_collisionFilterGroup; - callback.m_collisionFilterMask = getGhostObject()->getBroadphaseHandle()->m_collisionFilterMask; - - - btScalar margin = m_convexShape->getMargin(); - m_convexShape->setMargin(margin + m_addedMargin); - - - if (m_useGhostObjectSweepTest) - { - m_ghostObject->convexSweepTest (m_convexShape, start, end, callback, collisionWorld->getDispatchInfo().m_allowedCcdPenetration); - } else - { - collisionWorld->convexSweepTest (m_convexShape, start, end, callback, collisionWorld->getDispatchInfo().m_allowedCcdPenetration); - } - - m_convexShape->setMargin(margin); - - - fraction -= callback.m_closestHitFraction; - - if (callback.hasHit()) - { - // we moved only a fraction - btScalar hitDistance = (callback.m_hitPointWorld - m_currentPosition).length(); - if (hitDistance<0.f) - { -// printf("neg dist?\n"); - } - - /* If the distance is farther than the collision margin, move */ - if (hitDistance > m_addedMargin) - { -// printf("callback.m_closestHitFraction=%f\n",callback.m_closestHitFraction); - m_currentPosition.setInterpolate3 (m_currentPosition, m_targetPosition, callback.m_closestHitFraction); - } - - updateTargetPositionBasedOnCollision (callback.m_hitNormalWorld); - btVector3 currentDir = m_targetPosition - m_currentPosition; - distance2 = currentDir.length2(); - if (distance2 > SIMD_EPSILON) - { - currentDir.normalize(); - /* See Quake2: "If velocity is against original velocity, stop ead to avoid tiny oscilations in sloping corners." */ - if (currentDir.dot(m_normalizedDirection) <= btScalar(0.0)) - { - break; - } - } else - { -// printf("currentDir: don't normalize a zero vector\n"); - break; - } - } else { - // we moved whole way - m_currentPosition = m_targetPosition; - } - - // if (callback.m_closestHitFraction == 0.f) - // break; - - } -} - -void btKinematicCharacterController::stepDown ( btCollisionWorld* collisionWorld, btScalar dt) -{ - btTransform start, end; - - // phase 3: down - btVector3 step_drop = upAxisDirection[m_upAxis] * m_currentStepOffset; - btVector3 gravity_drop = upAxisDirection[m_upAxis] * m_stepHeight; - m_targetPosition -= (step_drop + gravity_drop); - - start.setIdentity (); - end.setIdentity (); - - start.setOrigin (m_currentPosition); - end.setOrigin (m_targetPosition); - - btKinematicClosestNotMeConvexResultCallback callback (m_ghostObject); - callback.m_collisionFilterGroup = getGhostObject()->getBroadphaseHandle()->m_collisionFilterGroup; - callback.m_collisionFilterMask = getGhostObject()->getBroadphaseHandle()->m_collisionFilterMask; - - if (m_useGhostObjectSweepTest) - { - m_ghostObject->convexSweepTest (m_convexShape, start, end, callback, collisionWorld->getDispatchInfo().m_allowedCcdPenetration); - } else - { - collisionWorld->convexSweepTest (m_convexShape, start, end, callback, collisionWorld->getDispatchInfo().m_allowedCcdPenetration); - } - - if (callback.hasHit()) - { - // we dropped a fraction of the height -> hit floor - m_currentPosition.setInterpolate3 (m_currentPosition, m_targetPosition, callback.m_closestHitFraction); - } else { - // we dropped the full height - - m_currentPosition = m_targetPosition; - } -} - - - -void btKinematicCharacterController::setWalkDirection -( -const btVector3& walkDirection -) -{ - m_useWalkDirection = true; - m_walkDirection = walkDirection; - m_normalizedDirection = getNormalizedVector(m_walkDirection); -} - - - -void btKinematicCharacterController::setVelocityForTimeInterval -( -const btVector3& velocity, -btScalar timeInterval -) -{ -// printf("setVelocity!\n"); -// printf(" interval: %f\n", timeInterval); -// printf(" velocity: (%f, %f, %f)\n", -// velocity.x(), velocity.y(), velocity.z()); - - m_useWalkDirection = false; - m_walkDirection = velocity; - m_normalizedDirection = getNormalizedVector(m_walkDirection); - m_velocityTimeInterval = timeInterval; -} - - - -void btKinematicCharacterController::reset () -{ -} - -void btKinematicCharacterController::warp (const btVector3& origin) -{ - btTransform xform; - xform.setIdentity(); - xform.setOrigin (origin); - m_ghostObject->setWorldTransform (xform); -} - - -void btKinematicCharacterController::preStep ( btCollisionWorld* collisionWorld) -{ - - int numPenetrationLoops = 0; - m_touchingContact = false; - while (recoverFromPenetration (collisionWorld)) - { - numPenetrationLoops++; - m_touchingContact = true; - if (numPenetrationLoops > 4) - { -// printf("character could not recover from penetration = %d\n", numPenetrationLoops); - break; - } - } - - m_currentPosition = m_ghostObject->getWorldTransform().getOrigin(); - m_targetPosition = m_currentPosition; -// printf("m_targetPosition=%f,%f,%f\n",m_targetPosition[0],m_targetPosition[1],m_targetPosition[2]); - - -} - -void btKinematicCharacterController::playerStep ( btCollisionWorld* collisionWorld, btScalar dt) -{ -// printf("playerStep(): "); -// printf(" dt = %f", dt); - - // quick check... - if (!m_useWalkDirection && m_velocityTimeInterval <= 0.0) { -// printf("\n"); - return; // no motion - } - - btTransform xform; - xform = m_ghostObject->getWorldTransform (); - -// printf("walkDirection(%f,%f,%f)\n",walkDirection[0],walkDirection[1],walkDirection[2]); -// printf("walkSpeed=%f\n",walkSpeed); - - stepUp (collisionWorld); - if (m_useWalkDirection) { - stepForwardAndStrafe (collisionWorld, m_walkDirection); - } else { - //printf(" time: %f", m_velocityTimeInterval); - // still have some time left for moving! - btScalar dtMoving = - (dt < m_velocityTimeInterval) ? dt : m_velocityTimeInterval; - m_velocityTimeInterval -= dt; - - // how far will we move while we are moving? - btVector3 move = m_walkDirection * dtMoving; - - // printf(" dtMoving: %f", dtMoving); - - // okay, step - stepForwardAndStrafe(collisionWorld, move); - } - stepDown (collisionWorld, dt); - - // printf("\n"); - - xform.setOrigin (m_currentPosition); - m_ghostObject->setWorldTransform (xform); -} - -void btKinematicCharacterController::setFallSpeed (btScalar fallSpeed) -{ - m_fallSpeed = fallSpeed; -} - -void btKinematicCharacterController::setJumpSpeed (btScalar jumpSpeed) -{ - m_jumpSpeed = jumpSpeed; -} - -void btKinematicCharacterController::setMaxJumpHeight (btScalar maxJumpHeight) -{ - m_maxJumpHeight = maxJumpHeight; -} - -bool btKinematicCharacterController::canJump () const -{ - return onGround(); -} - -void btKinematicCharacterController::jump () -{ - if (!canJump()) - return; - -#if 0 - currently no jumping. - btTransform xform; - m_rigidBody->getMotionState()->getWorldTransform (xform); - btVector3 up = xform.getBasis()[1]; - up.normalize (); - btScalar magnitude = (btScalar(1.0)/m_rigidBody->getInvMass()) * btScalar(8.0); - m_rigidBody->applyCentralImpulse (up * magnitude); -#endif -} - -bool btKinematicCharacterController::onGround () const -{ - return true; -} - - -void btKinematicCharacterController::debugDraw(btIDebugDraw* debugDrawer) -{ -} diff --git a/bullet/src/BulletDynamics/Character/btKinematicCharacterController.h b/bullet/src/BulletDynamics/Character/btKinematicCharacterController.h deleted file mode 100644 index 4162b94f5..000000000 --- a/bullet/src/BulletDynamics/Character/btKinematicCharacterController.h +++ /dev/null @@ -1,142 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2008 Erwin Coumans http://bulletphysics.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef KINEMATIC_CHARACTER_CONTROLLER_H -#define KINEMATIC_CHARACTER_CONTROLLER_H - -#include "LinearMath/btVector3.h" - -#include "btCharacterControllerInterface.h" - -#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h" - - -class btCollisionShape; -class btRigidBody; -class btCollisionWorld; -class btCollisionDispatcher; -class btPairCachingGhostObject; - -///btKinematicCharacterController is an object that supports a sliding motion in a world. -///It uses a ghost object and convex sweep test to test for upcoming collisions. This is combined with discrete collision detection to recover from penetrations. -///Interaction between btKinematicCharacterController and dynamic rigid bodies needs to be explicity implemented by the user. -class btKinematicCharacterController : public btCharacterControllerInterface -{ -protected: - btScalar m_halfHeight; - - btPairCachingGhostObject* m_ghostObject; - btConvexShape* m_convexShape;//is also in m_ghostObject, but it needs to be convex, so we store it here to avoid upcast - - btScalar m_fallSpeed; - btScalar m_jumpSpeed; - btScalar m_maxJumpHeight; - - btScalar m_turnAngle; - - btScalar m_stepHeight; - - btScalar m_addedMargin;//@todo: remove this and fix the code - - ///this is the desired walk direction, set by the user - btVector3 m_walkDirection; - btVector3 m_normalizedDirection; - - //some internal variables - btVector3 m_currentPosition; - btScalar m_currentStepOffset; - btVector3 m_targetPosition; - - ///keep track of the contact manifolds - btManifoldArray m_manifoldArray; - - bool m_touchingContact; - btVector3 m_touchingNormal; - - bool m_useGhostObjectSweepTest; - bool m_useWalkDirection; - float m_velocityTimeInterval; - int m_upAxis; - - btVector3 computeReflectionDirection (const btVector3& direction, const btVector3& normal); - btVector3 parallelComponent (const btVector3& direction, const btVector3& normal); - btVector3 perpindicularComponent (const btVector3& direction, const btVector3& normal); - - bool recoverFromPenetration ( btCollisionWorld* collisionWorld); - void stepUp (btCollisionWorld* collisionWorld); - void updateTargetPositionBasedOnCollision (const btVector3& hit_normal, btScalar tangentMag = btScalar(0.0), btScalar normalMag = btScalar(1.0)); - void stepForwardAndStrafe (btCollisionWorld* collisionWorld, const btVector3& walkMove); - void stepDown (btCollisionWorld* collisionWorld, btScalar dt); -public: - btKinematicCharacterController (btPairCachingGhostObject* ghostObject,btConvexShape* convexShape,btScalar stepHeight, int upAxis = 1); - ~btKinematicCharacterController (); - - - ///btActionInterface interface - virtual void updateAction( btCollisionWorld* collisionWorld,btScalar deltaTime) - { - preStep ( collisionWorld); - playerStep (collisionWorld, deltaTime); - } - - ///btActionInterface interface - void debugDraw(btIDebugDraw* debugDrawer); - - void setUpAxis (int axis) - { - if (axis < 0) - axis = 0; - if (axis > 2) - axis = 2; - m_upAxis = axis; - } - - /// This should probably be called setPositionIncrementPerSimulatorStep. - /// This is neither a direction nor a velocity, but the amount to - /// increment the position each simulation iteration, regardless - /// of dt. - /// This call will reset any velocity set by setVelocityForTimeInterval(). - virtual void setWalkDirection(const btVector3& walkDirection); - - /// Caller provides a velocity with which the character should move for - /// the given time period. After the time period, velocity is reset - /// to zero. - /// This call will reset any walk direction set by setWalkDirection(). - /// Negative time intervals will result in no motion. - virtual void setVelocityForTimeInterval(const btVector3& velocity, - btScalar timeInterval); - - void reset (); - void warp (const btVector3& origin); - - void preStep ( btCollisionWorld* collisionWorld); - void playerStep ( btCollisionWorld* collisionWorld, btScalar dt); - - void setFallSpeed (btScalar fallSpeed); - void setJumpSpeed (btScalar jumpSpeed); - void setMaxJumpHeight (btScalar maxJumpHeight); - bool canJump () const; - void jump (); - - btPairCachingGhostObject* getGhostObject(); - void setUseGhostSweepTest(bool useGhostObjectSweepTest) - { - m_useGhostObjectSweepTest = useGhostObjectSweepTest; - } - - bool onGround () const; -}; - -#endif // KINEMATIC_CHARACTER_CONTROLLER_H diff --git a/bullet/src/BulletDynamics/ConstraintSolver/btConeTwistConstraint.cpp b/bullet/src/BulletDynamics/ConstraintSolver/btConeTwistConstraint.cpp deleted file mode 100644 index f29088532..000000000 --- a/bullet/src/BulletDynamics/ConstraintSolver/btConeTwistConstraint.cpp +++ /dev/null @@ -1,1026 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -btConeTwistConstraint is Copyright (c) 2007 Starbreeze Studios - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. - -Written by: Marcus Hennix -*/ - - -#include "btConeTwistConstraint.h" -#include "BulletDynamics/Dynamics/btRigidBody.h" -#include "LinearMath/btTransformUtil.h" -#include "LinearMath/btMinMax.h" -#include - - - -//#define CONETWIST_USE_OBSOLETE_SOLVER true -#define CONETWIST_USE_OBSOLETE_SOLVER false -#define CONETWIST_DEF_FIX_THRESH btScalar(.05f) - - -SIMD_FORCE_INLINE btScalar computeAngularImpulseDenominator(const btVector3& axis, const btMatrix3x3& invInertiaWorld) -{ - btVector3 vec = axis * invInertiaWorld; - return axis.dot(vec); -} - - -btConeTwistConstraint::btConeTwistConstraint() -:btTypedConstraint(CONETWIST_CONSTRAINT_TYPE), -m_useSolveConstraintObsolete(CONETWIST_USE_OBSOLETE_SOLVER) -{ -} - - -btConeTwistConstraint::btConeTwistConstraint(btRigidBody& rbA,btRigidBody& rbB, - const btTransform& rbAFrame,const btTransform& rbBFrame) - :btTypedConstraint(CONETWIST_CONSTRAINT_TYPE, rbA,rbB),m_rbAFrame(rbAFrame),m_rbBFrame(rbBFrame), - m_angularOnly(false), - m_useSolveConstraintObsolete(CONETWIST_USE_OBSOLETE_SOLVER) -{ - init(); -} - -btConeTwistConstraint::btConeTwistConstraint(btRigidBody& rbA,const btTransform& rbAFrame) - :btTypedConstraint(CONETWIST_CONSTRAINT_TYPE,rbA),m_rbAFrame(rbAFrame), - m_angularOnly(false), - m_useSolveConstraintObsolete(CONETWIST_USE_OBSOLETE_SOLVER) -{ - m_rbBFrame = m_rbAFrame; - init(); -} - - -void btConeTwistConstraint::init() -{ - m_angularOnly = false; - m_solveTwistLimit = false; - m_solveSwingLimit = false; - m_bMotorEnabled = false; - m_maxMotorImpulse = btScalar(-1); - - setLimit(btScalar(BT_LARGE_FLOAT), btScalar(BT_LARGE_FLOAT), btScalar(BT_LARGE_FLOAT)); - m_damping = btScalar(0.01); - m_fixThresh = CONETWIST_DEF_FIX_THRESH; -} - - -void btConeTwistConstraint::getInfo1 (btConstraintInfo1* info) -{ - if (m_useSolveConstraintObsolete) - { - info->m_numConstraintRows = 0; - info->nub = 0; - } - else - { - info->m_numConstraintRows = 3; - info->nub = 3; - calcAngleInfo2(m_rbA.getCenterOfMassTransform(),m_rbB.getCenterOfMassTransform(),m_rbA.getInvInertiaTensorWorld(),m_rbB.getInvInertiaTensorWorld()); - if(m_solveSwingLimit) - { - info->m_numConstraintRows++; - info->nub--; - if((m_swingSpan1 < m_fixThresh) && (m_swingSpan2 < m_fixThresh)) - { - info->m_numConstraintRows++; - info->nub--; - } - } - if(m_solveTwistLimit) - { - info->m_numConstraintRows++; - info->nub--; - } - } -} - -void btConeTwistConstraint::getInfo1NonVirtual (btConstraintInfo1* info) -{ - //always reserve 6 rows: object transform is not available on SPU - info->m_numConstraintRows = 6; - info->nub = 0; - -} - - -void btConeTwistConstraint::getInfo2 (btConstraintInfo2* info) -{ - getInfo2NonVirtual(info,m_rbA.getCenterOfMassTransform(),m_rbB.getCenterOfMassTransform(),m_rbA.getInvInertiaTensorWorld(),m_rbB.getInvInertiaTensorWorld()); -} - -void btConeTwistConstraint::getInfo2NonVirtual (btConstraintInfo2* info,const btTransform& transA,const btTransform& transB,const btMatrix3x3& invInertiaWorldA,const btMatrix3x3& invInertiaWorldB) -{ - calcAngleInfo2(transA,transB,invInertiaWorldA,invInertiaWorldB); - - btAssert(!m_useSolveConstraintObsolete); - // set jacobian - info->m_J1linearAxis[0] = 1; - info->m_J1linearAxis[info->rowskip+1] = 1; - info->m_J1linearAxis[2*info->rowskip+2] = 1; - btVector3 a1 = transA.getBasis() * m_rbAFrame.getOrigin(); - { - btVector3* angular0 = (btVector3*)(info->m_J1angularAxis); - btVector3* angular1 = (btVector3*)(info->m_J1angularAxis+info->rowskip); - btVector3* angular2 = (btVector3*)(info->m_J1angularAxis+2*info->rowskip); - btVector3 a1neg = -a1; - a1neg.getSkewSymmetricMatrix(angular0,angular1,angular2); - } - btVector3 a2 = transB.getBasis() * m_rbBFrame.getOrigin(); - { - btVector3* angular0 = (btVector3*)(info->m_J2angularAxis); - btVector3* angular1 = (btVector3*)(info->m_J2angularAxis+info->rowskip); - btVector3* angular2 = (btVector3*)(info->m_J2angularAxis+2*info->rowskip); - a2.getSkewSymmetricMatrix(angular0,angular1,angular2); - } - // set right hand side - btScalar k = info->fps * info->erp; - int j; - for (j=0; j<3; j++) - { - info->m_constraintError[j*info->rowskip] = k * (a2[j] + transB.getOrigin()[j] - a1[j] - transA.getOrigin()[j]); - info->m_lowerLimit[j*info->rowskip] = -SIMD_INFINITY; - info->m_upperLimit[j*info->rowskip] = SIMD_INFINITY; - } - int row = 3; - int srow = row * info->rowskip; - btVector3 ax1; - // angular limits - if(m_solveSwingLimit) - { - btScalar *J1 = info->m_J1angularAxis; - btScalar *J2 = info->m_J2angularAxis; - if((m_swingSpan1 < m_fixThresh) && (m_swingSpan2 < m_fixThresh)) - { - btTransform trA = transA*m_rbAFrame; - btVector3 p = trA.getBasis().getColumn(1); - btVector3 q = trA.getBasis().getColumn(2); - int srow1 = srow + info->rowskip; - J1[srow+0] = p[0]; - J1[srow+1] = p[1]; - J1[srow+2] = p[2]; - J1[srow1+0] = q[0]; - J1[srow1+1] = q[1]; - J1[srow1+2] = q[2]; - J2[srow+0] = -p[0]; - J2[srow+1] = -p[1]; - J2[srow+2] = -p[2]; - J2[srow1+0] = -q[0]; - J2[srow1+1] = -q[1]; - J2[srow1+2] = -q[2]; - btScalar fact = info->fps * m_relaxationFactor; - info->m_constraintError[srow] = fact * m_swingAxis.dot(p); - info->m_constraintError[srow1] = fact * m_swingAxis.dot(q); - info->m_lowerLimit[srow] = -SIMD_INFINITY; - info->m_upperLimit[srow] = SIMD_INFINITY; - info->m_lowerLimit[srow1] = -SIMD_INFINITY; - info->m_upperLimit[srow1] = SIMD_INFINITY; - srow = srow1 + info->rowskip; - } - else - { - ax1 = m_swingAxis * m_relaxationFactor * m_relaxationFactor; - J1[srow+0] = ax1[0]; - J1[srow+1] = ax1[1]; - J1[srow+2] = ax1[2]; - J2[srow+0] = -ax1[0]; - J2[srow+1] = -ax1[1]; - J2[srow+2] = -ax1[2]; - btScalar k = info->fps * m_biasFactor; - - info->m_constraintError[srow] = k * m_swingCorrection; - info->cfm[srow] = 0.0f; - // m_swingCorrection is always positive or 0 - info->m_lowerLimit[srow] = 0; - info->m_upperLimit[srow] = SIMD_INFINITY; - srow += info->rowskip; - } - } - if(m_solveTwistLimit) - { - ax1 = m_twistAxis * m_relaxationFactor * m_relaxationFactor; - btScalar *J1 = info->m_J1angularAxis; - btScalar *J2 = info->m_J2angularAxis; - J1[srow+0] = ax1[0]; - J1[srow+1] = ax1[1]; - J1[srow+2] = ax1[2]; - J2[srow+0] = -ax1[0]; - J2[srow+1] = -ax1[1]; - J2[srow+2] = -ax1[2]; - btScalar k = info->fps * m_biasFactor; - info->m_constraintError[srow] = k * m_twistCorrection; - info->cfm[srow] = 0.0f; - if(m_twistSpan > 0.0f) - { - - if(m_twistCorrection > 0.0f) - { - info->m_lowerLimit[srow] = 0; - info->m_upperLimit[srow] = SIMD_INFINITY; - } - else - { - info->m_lowerLimit[srow] = -SIMD_INFINITY; - info->m_upperLimit[srow] = 0; - } - } - else - { - info->m_lowerLimit[srow] = -SIMD_INFINITY; - info->m_upperLimit[srow] = SIMD_INFINITY; - } - srow += info->rowskip; - } -} - - - -void btConeTwistConstraint::buildJacobian() -{ - if (m_useSolveConstraintObsolete) - { - m_appliedImpulse = btScalar(0.); - m_accTwistLimitImpulse = btScalar(0.); - m_accSwingLimitImpulse = btScalar(0.); - m_accMotorImpulse = btVector3(0.,0.,0.); - - if (!m_angularOnly) - { - btVector3 pivotAInW = m_rbA.getCenterOfMassTransform()*m_rbAFrame.getOrigin(); - btVector3 pivotBInW = m_rbB.getCenterOfMassTransform()*m_rbBFrame.getOrigin(); - btVector3 relPos = pivotBInW - pivotAInW; - - btVector3 normal[3]; - if (relPos.length2() > SIMD_EPSILON) - { - normal[0] = relPos.normalized(); - } - else - { - normal[0].setValue(btScalar(1.0),0,0); - } - - btPlaneSpace1(normal[0], normal[1], normal[2]); - - for (int i=0;i<3;i++) - { - new (&m_jac[i]) btJacobianEntry( - m_rbA.getCenterOfMassTransform().getBasis().transpose(), - m_rbB.getCenterOfMassTransform().getBasis().transpose(), - pivotAInW - m_rbA.getCenterOfMassPosition(), - pivotBInW - m_rbB.getCenterOfMassPosition(), - normal[i], - m_rbA.getInvInertiaDiagLocal(), - m_rbA.getInvMass(), - m_rbB.getInvInertiaDiagLocal(), - m_rbB.getInvMass()); - } - } - - calcAngleInfo2(m_rbA.getCenterOfMassTransform(),m_rbB.getCenterOfMassTransform(),m_rbA.getInvInertiaTensorWorld(),m_rbB.getInvInertiaTensorWorld()); - } -} - - - -void btConeTwistConstraint::solveConstraintObsolete(btSolverBody& bodyA,btSolverBody& bodyB,btScalar timeStep) -{ - #ifndef __SPU__ - if (m_useSolveConstraintObsolete) - { - btVector3 pivotAInW = m_rbA.getCenterOfMassTransform()*m_rbAFrame.getOrigin(); - btVector3 pivotBInW = m_rbB.getCenterOfMassTransform()*m_rbBFrame.getOrigin(); - - btScalar tau = btScalar(0.3); - - //linear part - if (!m_angularOnly) - { - btVector3 rel_pos1 = pivotAInW - m_rbA.getCenterOfMassPosition(); - btVector3 rel_pos2 = pivotBInW - m_rbB.getCenterOfMassPosition(); - - btVector3 vel1; - bodyA.getVelocityInLocalPointObsolete(rel_pos1,vel1); - btVector3 vel2; - bodyB.getVelocityInLocalPointObsolete(rel_pos2,vel2); - btVector3 vel = vel1 - vel2; - - for (int i=0;i<3;i++) - { - const btVector3& normal = m_jac[i].m_linearJointAxis; - btScalar jacDiagABInv = btScalar(1.) / m_jac[i].getDiagonal(); - - btScalar rel_vel; - rel_vel = normal.dot(vel); - //positional error (zeroth order error) - btScalar depth = -(pivotAInW - pivotBInW).dot(normal); //this is the error projected on the normal - btScalar impulse = depth*tau/timeStep * jacDiagABInv - rel_vel * jacDiagABInv; - m_appliedImpulse += impulse; - - btVector3 ftorqueAxis1 = rel_pos1.cross(normal); - btVector3 ftorqueAxis2 = rel_pos2.cross(normal); - bodyA.applyImpulse(normal*m_rbA.getInvMass(), m_rbA.getInvInertiaTensorWorld()*ftorqueAxis1,impulse); - bodyB.applyImpulse(normal*m_rbB.getInvMass(), m_rbB.getInvInertiaTensorWorld()*ftorqueAxis2,-impulse); - - } - } - - // apply motor - if (m_bMotorEnabled) - { - // compute current and predicted transforms - btTransform trACur = m_rbA.getCenterOfMassTransform(); - btTransform trBCur = m_rbB.getCenterOfMassTransform(); - btVector3 omegaA; bodyA.getAngularVelocity(omegaA); - btVector3 omegaB; bodyB.getAngularVelocity(omegaB); - btTransform trAPred; trAPred.setIdentity(); - btVector3 zerovec(0,0,0); - btTransformUtil::integrateTransform( - trACur, zerovec, omegaA, timeStep, trAPred); - btTransform trBPred; trBPred.setIdentity(); - btTransformUtil::integrateTransform( - trBCur, zerovec, omegaB, timeStep, trBPred); - - // compute desired transforms in world - btTransform trPose(m_qTarget); - btTransform trABDes = m_rbBFrame * trPose * m_rbAFrame.inverse(); - btTransform trADes = trBPred * trABDes; - btTransform trBDes = trAPred * trABDes.inverse(); - - // compute desired omegas in world - btVector3 omegaADes, omegaBDes; - - btTransformUtil::calculateVelocity(trACur, trADes, timeStep, zerovec, omegaADes); - btTransformUtil::calculateVelocity(trBCur, trBDes, timeStep, zerovec, omegaBDes); - - // compute delta omegas - btVector3 dOmegaA = omegaADes - omegaA; - btVector3 dOmegaB = omegaBDes - omegaB; - - // compute weighted avg axis of dOmega (weighting based on inertias) - btVector3 axisA, axisB; - btScalar kAxisAInv = 0, kAxisBInv = 0; - - if (dOmegaA.length2() > SIMD_EPSILON) - { - axisA = dOmegaA.normalized(); - kAxisAInv = getRigidBodyA().computeAngularImpulseDenominator(axisA); - } - - if (dOmegaB.length2() > SIMD_EPSILON) - { - axisB = dOmegaB.normalized(); - kAxisBInv = getRigidBodyB().computeAngularImpulseDenominator(axisB); - } - - btVector3 avgAxis = kAxisAInv * axisA + kAxisBInv * axisB; - - static bool bDoTorque = true; - if (bDoTorque && avgAxis.length2() > SIMD_EPSILON) - { - avgAxis.normalize(); - kAxisAInv = getRigidBodyA().computeAngularImpulseDenominator(avgAxis); - kAxisBInv = getRigidBodyB().computeAngularImpulseDenominator(avgAxis); - btScalar kInvCombined = kAxisAInv + kAxisBInv; - - btVector3 impulse = (kAxisAInv * dOmegaA - kAxisBInv * dOmegaB) / - (kInvCombined * kInvCombined); - - if (m_maxMotorImpulse >= 0) - { - btScalar fMaxImpulse = m_maxMotorImpulse; - if (m_bNormalizedMotorStrength) - fMaxImpulse = fMaxImpulse/kAxisAInv; - - btVector3 newUnclampedAccImpulse = m_accMotorImpulse + impulse; - btScalar newUnclampedMag = newUnclampedAccImpulse.length(); - if (newUnclampedMag > fMaxImpulse) - { - newUnclampedAccImpulse.normalize(); - newUnclampedAccImpulse *= fMaxImpulse; - impulse = newUnclampedAccImpulse - m_accMotorImpulse; - } - m_accMotorImpulse += impulse; - } - - btScalar impulseMag = impulse.length(); - btVector3 impulseAxis = impulse / impulseMag; - - bodyA.applyImpulse(btVector3(0,0,0), m_rbA.getInvInertiaTensorWorld()*impulseAxis, impulseMag); - bodyB.applyImpulse(btVector3(0,0,0), m_rbB.getInvInertiaTensorWorld()*impulseAxis, -impulseMag); - - } - } - else if (m_damping > SIMD_EPSILON) // no motor: do a little damping - { - btVector3 angVelA; bodyA.getAngularVelocity(angVelA); - btVector3 angVelB; bodyB.getAngularVelocity(angVelB); - btVector3 relVel = angVelB - angVelA; - if (relVel.length2() > SIMD_EPSILON) - { - btVector3 relVelAxis = relVel.normalized(); - btScalar m_kDamping = btScalar(1.) / - (getRigidBodyA().computeAngularImpulseDenominator(relVelAxis) + - getRigidBodyB().computeAngularImpulseDenominator(relVelAxis)); - btVector3 impulse = m_damping * m_kDamping * relVel; - - btScalar impulseMag = impulse.length(); - btVector3 impulseAxis = impulse / impulseMag; - bodyA.applyImpulse(btVector3(0,0,0), m_rbA.getInvInertiaTensorWorld()*impulseAxis, impulseMag); - bodyB.applyImpulse(btVector3(0,0,0), m_rbB.getInvInertiaTensorWorld()*impulseAxis, -impulseMag); - } - } - - // joint limits - { - ///solve angular part - btVector3 angVelA; - bodyA.getAngularVelocity(angVelA); - btVector3 angVelB; - bodyB.getAngularVelocity(angVelB); - - // solve swing limit - if (m_solveSwingLimit) - { - btScalar amplitude = m_swingLimitRatio * m_swingCorrection*m_biasFactor/timeStep; - btScalar relSwingVel = (angVelB - angVelA).dot(m_swingAxis); - if (relSwingVel > 0) - amplitude += m_swingLimitRatio * relSwingVel * m_relaxationFactor; - btScalar impulseMag = amplitude * m_kSwing; - - // Clamp the accumulated impulse - btScalar temp = m_accSwingLimitImpulse; - m_accSwingLimitImpulse = btMax(m_accSwingLimitImpulse + impulseMag, btScalar(0.0) ); - impulseMag = m_accSwingLimitImpulse - temp; - - btVector3 impulse = m_swingAxis * impulseMag; - - // don't let cone response affect twist - // (this can happen since body A's twist doesn't match body B's AND we use an elliptical cone limit) - { - btVector3 impulseTwistCouple = impulse.dot(m_twistAxisA) * m_twistAxisA; - btVector3 impulseNoTwistCouple = impulse - impulseTwistCouple; - impulse = impulseNoTwistCouple; - } - - impulseMag = impulse.length(); - btVector3 noTwistSwingAxis = impulse / impulseMag; - - bodyA.applyImpulse(btVector3(0,0,0), m_rbA.getInvInertiaTensorWorld()*noTwistSwingAxis, impulseMag); - bodyB.applyImpulse(btVector3(0,0,0), m_rbB.getInvInertiaTensorWorld()*noTwistSwingAxis, -impulseMag); - } - - - // solve twist limit - if (m_solveTwistLimit) - { - btScalar amplitude = m_twistLimitRatio * m_twistCorrection*m_biasFactor/timeStep; - btScalar relTwistVel = (angVelB - angVelA).dot( m_twistAxis ); - if (relTwistVel > 0) // only damp when moving towards limit (m_twistAxis flipping is important) - amplitude += m_twistLimitRatio * relTwistVel * m_relaxationFactor; - btScalar impulseMag = amplitude * m_kTwist; - - // Clamp the accumulated impulse - btScalar temp = m_accTwistLimitImpulse; - m_accTwistLimitImpulse = btMax(m_accTwistLimitImpulse + impulseMag, btScalar(0.0) ); - impulseMag = m_accTwistLimitImpulse - temp; - - btVector3 impulse = m_twistAxis * impulseMag; - - bodyA.applyImpulse(btVector3(0,0,0), m_rbA.getInvInertiaTensorWorld()*m_twistAxis,impulseMag); - bodyB.applyImpulse(btVector3(0,0,0), m_rbB.getInvInertiaTensorWorld()*m_twistAxis,-impulseMag); - } - } - } -#else -btAssert(0); -#endif //__SPU__ -} - - - - -void btConeTwistConstraint::updateRHS(btScalar timeStep) -{ - (void)timeStep; - -} - - -#ifndef __SPU__ -void btConeTwistConstraint::calcAngleInfo() -{ - m_swingCorrection = btScalar(0.); - m_twistLimitSign = btScalar(0.); - m_solveTwistLimit = false; - m_solveSwingLimit = false; - - btVector3 b1Axis1,b1Axis2,b1Axis3; - btVector3 b2Axis1,b2Axis2; - - b1Axis1 = getRigidBodyA().getCenterOfMassTransform().getBasis() * this->m_rbAFrame.getBasis().getColumn(0); - b2Axis1 = getRigidBodyB().getCenterOfMassTransform().getBasis() * this->m_rbBFrame.getBasis().getColumn(0); - - btScalar swing1=btScalar(0.),swing2 = btScalar(0.); - - btScalar swx=btScalar(0.),swy = btScalar(0.); - btScalar thresh = btScalar(10.); - btScalar fact; - - // Get Frame into world space - if (m_swingSpan1 >= btScalar(0.05f)) - { - b1Axis2 = getRigidBodyA().getCenterOfMassTransform().getBasis() * this->m_rbAFrame.getBasis().getColumn(1); - swx = b2Axis1.dot(b1Axis1); - swy = b2Axis1.dot(b1Axis2); - swing1 = btAtan2Fast(swy, swx); - fact = (swy*swy + swx*swx) * thresh * thresh; - fact = fact / (fact + btScalar(1.0)); - swing1 *= fact; - } - - if (m_swingSpan2 >= btScalar(0.05f)) - { - b1Axis3 = getRigidBodyA().getCenterOfMassTransform().getBasis() * this->m_rbAFrame.getBasis().getColumn(2); - swx = b2Axis1.dot(b1Axis1); - swy = b2Axis1.dot(b1Axis3); - swing2 = btAtan2Fast(swy, swx); - fact = (swy*swy + swx*swx) * thresh * thresh; - fact = fact / (fact + btScalar(1.0)); - swing2 *= fact; - } - - btScalar RMaxAngle1Sq = 1.0f / (m_swingSpan1*m_swingSpan1); - btScalar RMaxAngle2Sq = 1.0f / (m_swingSpan2*m_swingSpan2); - btScalar EllipseAngle = btFabs(swing1*swing1)* RMaxAngle1Sq + btFabs(swing2*swing2) * RMaxAngle2Sq; - - if (EllipseAngle > 1.0f) - { - m_swingCorrection = EllipseAngle-1.0f; - m_solveSwingLimit = true; - // Calculate necessary axis & factors - m_swingAxis = b2Axis1.cross(b1Axis2* b2Axis1.dot(b1Axis2) + b1Axis3* b2Axis1.dot(b1Axis3)); - m_swingAxis.normalize(); - btScalar swingAxisSign = (b2Axis1.dot(b1Axis1) >= 0.0f) ? 1.0f : -1.0f; - m_swingAxis *= swingAxisSign; - } - - // Twist limits - if (m_twistSpan >= btScalar(0.)) - { - btVector3 b2Axis2 = getRigidBodyB().getCenterOfMassTransform().getBasis() * this->m_rbBFrame.getBasis().getColumn(1); - btQuaternion rotationArc = shortestArcQuat(b2Axis1,b1Axis1); - btVector3 TwistRef = quatRotate(rotationArc,b2Axis2); - btScalar twist = btAtan2Fast( TwistRef.dot(b1Axis3), TwistRef.dot(b1Axis2) ); - m_twistAngle = twist; - -// btScalar lockedFreeFactor = (m_twistSpan > btScalar(0.05f)) ? m_limitSoftness : btScalar(0.); - btScalar lockedFreeFactor = (m_twistSpan > btScalar(0.05f)) ? btScalar(1.0f) : btScalar(0.); - if (twist <= -m_twistSpan*lockedFreeFactor) - { - m_twistCorrection = -(twist + m_twistSpan); - m_solveTwistLimit = true; - m_twistAxis = (b2Axis1 + b1Axis1) * 0.5f; - m_twistAxis.normalize(); - m_twistAxis *= -1.0f; - } - else if (twist > m_twistSpan*lockedFreeFactor) - { - m_twistCorrection = (twist - m_twistSpan); - m_solveTwistLimit = true; - m_twistAxis = (b2Axis1 + b1Axis1) * 0.5f; - m_twistAxis.normalize(); - } - } -} -#endif //__SPU__ - -static btVector3 vTwist(1,0,0); // twist axis in constraint's space - - - -void btConeTwistConstraint::calcAngleInfo2(const btTransform& transA, const btTransform& transB, const btMatrix3x3& invInertiaWorldA,const btMatrix3x3& invInertiaWorldB) -{ - m_swingCorrection = btScalar(0.); - m_twistLimitSign = btScalar(0.); - m_solveTwistLimit = false; - m_solveSwingLimit = false; - // compute rotation of A wrt B (in constraint space) - if (m_bMotorEnabled && (!m_useSolveConstraintObsolete)) - { // it is assumed that setMotorTarget() was alredy called - // and motor target m_qTarget is within constraint limits - // TODO : split rotation to pure swing and pure twist - // compute desired transforms in world - btTransform trPose(m_qTarget); - btTransform trA = transA * m_rbAFrame; - btTransform trB = transB * m_rbBFrame; - btTransform trDeltaAB = trB * trPose * trA.inverse(); - btQuaternion qDeltaAB = trDeltaAB.getRotation(); - btVector3 swingAxis = btVector3(qDeltaAB.x(), qDeltaAB.y(), qDeltaAB.z()); - m_swingAxis = swingAxis; - m_swingAxis.normalize(); - m_swingCorrection = qDeltaAB.getAngle(); - if(!btFuzzyZero(m_swingCorrection)) - { - m_solveSwingLimit = true; - } - return; - } - - - { - // compute rotation of A wrt B (in constraint space) - btQuaternion qA = transA.getRotation() * m_rbAFrame.getRotation(); - btQuaternion qB = transB.getRotation() * m_rbBFrame.getRotation(); - btQuaternion qAB = qB.inverse() * qA; - // split rotation into cone and twist - // (all this is done from B's perspective. Maybe I should be averaging axes...) - btVector3 vConeNoTwist = quatRotate(qAB, vTwist); vConeNoTwist.normalize(); - btQuaternion qABCone = shortestArcQuat(vTwist, vConeNoTwist); qABCone.normalize(); - btQuaternion qABTwist = qABCone.inverse() * qAB; qABTwist.normalize(); - - if (m_swingSpan1 >= m_fixThresh && m_swingSpan2 >= m_fixThresh) - { - btScalar swingAngle, swingLimit = 0; btVector3 swingAxis; - computeConeLimitInfo(qABCone, swingAngle, swingAxis, swingLimit); - - if (swingAngle > swingLimit * m_limitSoftness) - { - m_solveSwingLimit = true; - - // compute limit ratio: 0->1, where - // 0 == beginning of soft limit - // 1 == hard/real limit - m_swingLimitRatio = 1.f; - if (swingAngle < swingLimit && m_limitSoftness < 1.f - SIMD_EPSILON) - { - m_swingLimitRatio = (swingAngle - swingLimit * m_limitSoftness)/ - (swingLimit - swingLimit * m_limitSoftness); - } - - // swing correction tries to get back to soft limit - m_swingCorrection = swingAngle - (swingLimit * m_limitSoftness); - - // adjustment of swing axis (based on ellipse normal) - adjustSwingAxisToUseEllipseNormal(swingAxis); - - // Calculate necessary axis & factors - m_swingAxis = quatRotate(qB, -swingAxis); - - m_twistAxisA.setValue(0,0,0); - - m_kSwing = btScalar(1.) / - (computeAngularImpulseDenominator(m_swingAxis,invInertiaWorldA) + - computeAngularImpulseDenominator(m_swingAxis,invInertiaWorldB)); - } - } - else - { - // you haven't set any limits; - // or you're trying to set at least one of the swing limits too small. (if so, do you really want a conetwist constraint?) - // anyway, we have either hinge or fixed joint - btVector3 ivA = transA.getBasis() * m_rbAFrame.getBasis().getColumn(0); - btVector3 jvA = transA.getBasis() * m_rbAFrame.getBasis().getColumn(1); - btVector3 kvA = transA.getBasis() * m_rbAFrame.getBasis().getColumn(2); - btVector3 ivB = transB.getBasis() * m_rbBFrame.getBasis().getColumn(0); - btVector3 target; - btScalar x = ivB.dot(ivA); - btScalar y = ivB.dot(jvA); - btScalar z = ivB.dot(kvA); - if((m_swingSpan1 < m_fixThresh) && (m_swingSpan2 < m_fixThresh)) - { // fixed. We'll need to add one more row to constraint - if((!btFuzzyZero(y)) || (!(btFuzzyZero(z)))) - { - m_solveSwingLimit = true; - m_swingAxis = -ivB.cross(ivA); - } - } - else - { - if(m_swingSpan1 < m_fixThresh) - { // hinge around Y axis - if(!(btFuzzyZero(y))) - { - m_solveSwingLimit = true; - if(m_swingSpan2 >= m_fixThresh) - { - y = btScalar(0.f); - btScalar span2 = btAtan2(z, x); - if(span2 > m_swingSpan2) - { - x = btCos(m_swingSpan2); - z = btSin(m_swingSpan2); - } - else if(span2 < -m_swingSpan2) - { - x = btCos(m_swingSpan2); - z = -btSin(m_swingSpan2); - } - } - } - } - else - { // hinge around Z axis - if(!btFuzzyZero(z)) - { - m_solveSwingLimit = true; - if(m_swingSpan1 >= m_fixThresh) - { - z = btScalar(0.f); - btScalar span1 = btAtan2(y, x); - if(span1 > m_swingSpan1) - { - x = btCos(m_swingSpan1); - y = btSin(m_swingSpan1); - } - else if(span1 < -m_swingSpan1) - { - x = btCos(m_swingSpan1); - y = -btSin(m_swingSpan1); - } - } - } - } - target[0] = x * ivA[0] + y * jvA[0] + z * kvA[0]; - target[1] = x * ivA[1] + y * jvA[1] + z * kvA[1]; - target[2] = x * ivA[2] + y * jvA[2] + z * kvA[2]; - target.normalize(); - m_swingAxis = -ivB.cross(target); - m_swingCorrection = m_swingAxis.length(); - m_swingAxis.normalize(); - } - } - - if (m_twistSpan >= btScalar(0.f)) - { - btVector3 twistAxis; - computeTwistLimitInfo(qABTwist, m_twistAngle, twistAxis); - - if (m_twistAngle > m_twistSpan*m_limitSoftness) - { - m_solveTwistLimit = true; - - m_twistLimitRatio = 1.f; - if (m_twistAngle < m_twistSpan && m_limitSoftness < 1.f - SIMD_EPSILON) - { - m_twistLimitRatio = (m_twistAngle - m_twistSpan * m_limitSoftness)/ - (m_twistSpan - m_twistSpan * m_limitSoftness); - } - - // twist correction tries to get back to soft limit - m_twistCorrection = m_twistAngle - (m_twistSpan * m_limitSoftness); - - m_twistAxis = quatRotate(qB, -twistAxis); - - m_kTwist = btScalar(1.) / - (computeAngularImpulseDenominator(m_twistAxis,invInertiaWorldA) + - computeAngularImpulseDenominator(m_twistAxis,invInertiaWorldB)); - } - - if (m_solveSwingLimit) - m_twistAxisA = quatRotate(qA, -twistAxis); - } - else - { - m_twistAngle = btScalar(0.f); - } - } -} - - - -// given a cone rotation in constraint space, (pre: twist must already be removed) -// this method computes its corresponding swing angle and axis. -// more interestingly, it computes the cone/swing limit (angle) for this cone "pose". -void btConeTwistConstraint::computeConeLimitInfo(const btQuaternion& qCone, - btScalar& swingAngle, // out - btVector3& vSwingAxis, // out - btScalar& swingLimit) // out -{ - swingAngle = qCone.getAngle(); - if (swingAngle > SIMD_EPSILON) - { - vSwingAxis = btVector3(qCone.x(), qCone.y(), qCone.z()); - vSwingAxis.normalize(); - if (fabs(vSwingAxis.x()) > SIMD_EPSILON) - { - // non-zero twist?! this should never happen. - int wtf = 0; wtf = wtf; - } - - // Compute limit for given swing. tricky: - // Given a swing axis, we're looking for the intersection with the bounding cone ellipse. - // (Since we're dealing with angles, this ellipse is embedded on the surface of a sphere.) - - // For starters, compute the direction from center to surface of ellipse. - // This is just the perpendicular (ie. rotate 2D vector by PI/2) of the swing axis. - // (vSwingAxis is the cone rotation (in z,y); change vars and rotate to (x,y) coords.) - btScalar xEllipse = vSwingAxis.y(); - btScalar yEllipse = -vSwingAxis.z(); - - // Now, we use the slope of the vector (using x/yEllipse) and find the length - // of the line that intersects the ellipse: - // x^2 y^2 - // --- + --- = 1, where a and b are semi-major axes 2 and 1 respectively (ie. the limits) - // a^2 b^2 - // Do the math and it should be clear. - - swingLimit = m_swingSpan1; // if xEllipse == 0, we have a pure vSwingAxis.z rotation: just use swingspan1 - if (fabs(xEllipse) > SIMD_EPSILON) - { - btScalar surfaceSlope2 = (yEllipse*yEllipse)/(xEllipse*xEllipse); - btScalar norm = 1 / (m_swingSpan2 * m_swingSpan2); - norm += surfaceSlope2 / (m_swingSpan1 * m_swingSpan1); - btScalar swingLimit2 = (1 + surfaceSlope2) / norm; - swingLimit = sqrt(swingLimit2); - } - - // test! - /*swingLimit = m_swingSpan2; - if (fabs(vSwingAxis.z()) > SIMD_EPSILON) - { - btScalar mag_2 = m_swingSpan1*m_swingSpan1 + m_swingSpan2*m_swingSpan2; - btScalar sinphi = m_swingSpan2 / sqrt(mag_2); - btScalar phi = asin(sinphi); - btScalar theta = atan2(fabs(vSwingAxis.y()),fabs(vSwingAxis.z())); - btScalar alpha = 3.14159f - theta - phi; - btScalar sinalpha = sin(alpha); - swingLimit = m_swingSpan1 * sinphi/sinalpha; - }*/ - } - else if (swingAngle < 0) - { - // this should never happen! - int wtf = 0; wtf = wtf; - } -} - -btVector3 btConeTwistConstraint::GetPointForAngle(btScalar fAngleInRadians, btScalar fLength) const -{ - // compute x/y in ellipse using cone angle (0 -> 2*PI along surface of cone) - btScalar xEllipse = btCos(fAngleInRadians); - btScalar yEllipse = btSin(fAngleInRadians); - - // Use the slope of the vector (using x/yEllipse) and find the length - // of the line that intersects the ellipse: - // x^2 y^2 - // --- + --- = 1, where a and b are semi-major axes 2 and 1 respectively (ie. the limits) - // a^2 b^2 - // Do the math and it should be clear. - - float swingLimit = m_swingSpan1; // if xEllipse == 0, just use axis b (1) - if (fabs(xEllipse) > SIMD_EPSILON) - { - btScalar surfaceSlope2 = (yEllipse*yEllipse)/(xEllipse*xEllipse); - btScalar norm = 1 / (m_swingSpan2 * m_swingSpan2); - norm += surfaceSlope2 / (m_swingSpan1 * m_swingSpan1); - btScalar swingLimit2 = (1 + surfaceSlope2) / norm; - swingLimit = sqrt(swingLimit2); - } - - // convert into point in constraint space: - // note: twist is x-axis, swing 1 and 2 are along the z and y axes respectively - btVector3 vSwingAxis(0, xEllipse, -yEllipse); - btQuaternion qSwing(vSwingAxis, swingLimit); - btVector3 vPointInConstraintSpace(fLength,0,0); - return quatRotate(qSwing, vPointInConstraintSpace); -} - -// given a twist rotation in constraint space, (pre: cone must already be removed) -// this method computes its corresponding angle and axis. -void btConeTwistConstraint::computeTwistLimitInfo(const btQuaternion& qTwist, - btScalar& twistAngle, // out - btVector3& vTwistAxis) // out -{ - btQuaternion qMinTwist = qTwist; - twistAngle = qTwist.getAngle(); - - if (twistAngle > SIMD_PI) // long way around. flip quat and recalculate. - { - qMinTwist = operator-(qTwist); - twistAngle = qMinTwist.getAngle(); - } - if (twistAngle < 0) - { - // this should never happen - int wtf = 0; wtf = wtf; - } - - vTwistAxis = btVector3(qMinTwist.x(), qMinTwist.y(), qMinTwist.z()); - if (twistAngle > SIMD_EPSILON) - vTwistAxis.normalize(); -} - - -void btConeTwistConstraint::adjustSwingAxisToUseEllipseNormal(btVector3& vSwingAxis) const -{ - // the swing axis is computed as the "twist-free" cone rotation, - // but the cone limit is not circular, but elliptical (if swingspan1 != swingspan2). - // so, if we're outside the limits, the closest way back inside the cone isn't - // along the vector back to the center. better (and more stable) to use the ellipse normal. - - // convert swing axis to direction from center to surface of ellipse - // (ie. rotate 2D vector by PI/2) - btScalar y = -vSwingAxis.z(); - btScalar z = vSwingAxis.y(); - - // do the math... - if (fabs(z) > SIMD_EPSILON) // avoid division by 0. and we don't need an update if z == 0. - { - // compute gradient/normal of ellipse surface at current "point" - btScalar grad = y/z; - grad *= m_swingSpan2 / m_swingSpan1; - - // adjust y/z to represent normal at point (instead of vector to point) - if (y > 0) - y = fabs(grad * z); - else - y = -fabs(grad * z); - - // convert ellipse direction back to swing axis - vSwingAxis.setZ(-y); - vSwingAxis.setY( z); - vSwingAxis.normalize(); - } -} - - - -void btConeTwistConstraint::setMotorTarget(const btQuaternion &q) -{ - btTransform trACur = m_rbA.getCenterOfMassTransform(); - btTransform trBCur = m_rbB.getCenterOfMassTransform(); - btTransform trABCur = trBCur.inverse() * trACur; - btQuaternion qABCur = trABCur.getRotation(); - btTransform trConstraintCur = (trBCur * m_rbBFrame).inverse() * (trACur * m_rbAFrame); - btQuaternion qConstraintCur = trConstraintCur.getRotation(); - - btQuaternion qConstraint = m_rbBFrame.getRotation().inverse() * q * m_rbAFrame.getRotation(); - setMotorTargetInConstraintSpace(qConstraint); -} - - -void btConeTwistConstraint::setMotorTargetInConstraintSpace(const btQuaternion &q) -{ - m_qTarget = q; - - // clamp motor target to within limits - { - btScalar softness = 1.f;//m_limitSoftness; - - // split into twist and cone - btVector3 vTwisted = quatRotate(m_qTarget, vTwist); - btQuaternion qTargetCone = shortestArcQuat(vTwist, vTwisted); qTargetCone.normalize(); - btQuaternion qTargetTwist = qTargetCone.inverse() * m_qTarget; qTargetTwist.normalize(); - - // clamp cone - if (m_swingSpan1 >= btScalar(0.05f) && m_swingSpan2 >= btScalar(0.05f)) - { - btScalar swingAngle, swingLimit; btVector3 swingAxis; - computeConeLimitInfo(qTargetCone, swingAngle, swingAxis, swingLimit); - - if (fabs(swingAngle) > SIMD_EPSILON) - { - if (swingAngle > swingLimit*softness) - swingAngle = swingLimit*softness; - else if (swingAngle < -swingLimit*softness) - swingAngle = -swingLimit*softness; - qTargetCone = btQuaternion(swingAxis, swingAngle); - } - } - - // clamp twist - if (m_twistSpan >= btScalar(0.05f)) - { - btScalar twistAngle; btVector3 twistAxis; - computeTwistLimitInfo(qTargetTwist, twistAngle, twistAxis); - - if (fabs(twistAngle) > SIMD_EPSILON) - { - // eddy todo: limitSoftness used here??? - if (twistAngle > m_twistSpan*softness) - twistAngle = m_twistSpan*softness; - else if (twistAngle < -m_twistSpan*softness) - twistAngle = -m_twistSpan*softness; - qTargetTwist = btQuaternion(twistAxis, twistAngle); - } - } - - m_qTarget = qTargetCone * qTargetTwist; - } -} - - - - diff --git a/bullet/src/BulletDynamics/ConstraintSolver/btConeTwistConstraint.h b/bullet/src/BulletDynamics/ConstraintSolver/btConeTwistConstraint.h deleted file mode 100644 index 74b284675..000000000 --- a/bullet/src/BulletDynamics/ConstraintSolver/btConeTwistConstraint.h +++ /dev/null @@ -1,259 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -btConeTwistConstraint is Copyright (c) 2007 Starbreeze Studios - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. - -Written by: Marcus Hennix -*/ - - - -/* -Overview: - -btConeTwistConstraint can be used to simulate ragdoll joints (upper arm, leg etc). -It is a fixed translation, 3 degree-of-freedom (DOF) rotational "joint". -It divides the 3 rotational DOFs into swing (movement within a cone) and twist. -Swing is divided into swing1 and swing2 which can have different limits, giving an elliptical shape. -(Note: the cone's base isn't flat, so this ellipse is "embedded" on the surface of a sphere.) - -In the contraint's frame of reference: -twist is along the x-axis, -and swing 1 and 2 are along the z and y axes respectively. -*/ - - - -#ifndef CONETWISTCONSTRAINT_H -#define CONETWISTCONSTRAINT_H - -#include "LinearMath/btVector3.h" -#include "btJacobianEntry.h" -#include "btTypedConstraint.h" - -class btRigidBody; - - -///btConeTwistConstraint can be used to simulate ragdoll joints (upper arm, leg etc) -class btConeTwistConstraint : public btTypedConstraint -{ -#ifdef IN_PARALLELL_SOLVER -public: -#endif - btJacobianEntry m_jac[3]; //3 orthogonal linear constraints - - btTransform m_rbAFrame; - btTransform m_rbBFrame; - - btScalar m_limitSoftness; - btScalar m_biasFactor; - btScalar m_relaxationFactor; - - btScalar m_damping; - - btScalar m_swingSpan1; - btScalar m_swingSpan2; - btScalar m_twistSpan; - - btScalar m_fixThresh; - - btVector3 m_swingAxis; - btVector3 m_twistAxis; - - btScalar m_kSwing; - btScalar m_kTwist; - - btScalar m_twistLimitSign; - btScalar m_swingCorrection; - btScalar m_twistCorrection; - - btScalar m_twistAngle; - - btScalar m_accSwingLimitImpulse; - btScalar m_accTwistLimitImpulse; - - bool m_angularOnly; - bool m_solveTwistLimit; - bool m_solveSwingLimit; - - bool m_useSolveConstraintObsolete; - - // not yet used... - btScalar m_swingLimitRatio; - btScalar m_twistLimitRatio; - btVector3 m_twistAxisA; - - // motor - bool m_bMotorEnabled; - bool m_bNormalizedMotorStrength; - btQuaternion m_qTarget; - btScalar m_maxMotorImpulse; - btVector3 m_accMotorImpulse; - -public: - - btConeTwistConstraint(btRigidBody& rbA,btRigidBody& rbB,const btTransform& rbAFrame, const btTransform& rbBFrame); - - btConeTwistConstraint(btRigidBody& rbA,const btTransform& rbAFrame); - - btConeTwistConstraint(); - - virtual void buildJacobian(); - - virtual void getInfo1 (btConstraintInfo1* info); - - void getInfo1NonVirtual(btConstraintInfo1* info); - - virtual void getInfo2 (btConstraintInfo2* info); - - void getInfo2NonVirtual(btConstraintInfo2* info,const btTransform& transA,const btTransform& transB,const btMatrix3x3& invInertiaWorldA,const btMatrix3x3& invInertiaWorldB); - - virtual void solveConstraintObsolete(btSolverBody& bodyA,btSolverBody& bodyB,btScalar timeStep); - - void updateRHS(btScalar timeStep); - - const btRigidBody& getRigidBodyA() const - { - return m_rbA; - } - const btRigidBody& getRigidBodyB() const - { - return m_rbB; - } - - void setAngularOnly(bool angularOnly) - { - m_angularOnly = angularOnly; - } - - void setLimit(int limitIndex,btScalar limitValue) - { - switch (limitIndex) - { - case 3: - { - m_twistSpan = limitValue; - break; - } - case 4: - { - m_swingSpan2 = limitValue; - break; - } - case 5: - { - m_swingSpan1 = limitValue; - break; - } - default: - { - } - }; - } - - // setLimit(), a few notes: - // _softness: - // 0->1, recommend ~0.8->1. - // describes % of limits where movement is free. - // beyond this softness %, the limit is gradually enforced until the "hard" (1.0) limit is reached. - // _biasFactor: - // 0->1?, recommend 0.3 +/-0.3 or so. - // strength with which constraint resists zeroth order (angular, not angular velocity) limit violation. - // __relaxationFactor: - // 0->1, recommend to stay near 1. - // the lower the value, the less the constraint will fight velocities which violate the angular limits. - void setLimit(btScalar _swingSpan1,btScalar _swingSpan2,btScalar _twistSpan, btScalar _softness = 1.f, btScalar _biasFactor = 0.3f, btScalar _relaxationFactor = 1.0f) - { - m_swingSpan1 = _swingSpan1; - m_swingSpan2 = _swingSpan2; - m_twistSpan = _twistSpan; - - m_limitSoftness = _softness; - m_biasFactor = _biasFactor; - m_relaxationFactor = _relaxationFactor; - } - - const btTransform& getAFrame() { return m_rbAFrame; }; - const btTransform& getBFrame() { return m_rbBFrame; }; - - inline int getSolveTwistLimit() - { - return m_solveTwistLimit; - } - - inline int getSolveSwingLimit() - { - return m_solveTwistLimit; - } - - inline btScalar getTwistLimitSign() - { - return m_twistLimitSign; - } - - void calcAngleInfo(); - void calcAngleInfo2(const btTransform& transA, const btTransform& transB,const btMatrix3x3& invInertiaWorldA,const btMatrix3x3& invInertiaWorldB); - - inline btScalar getSwingSpan1() - { - return m_swingSpan1; - } - inline btScalar getSwingSpan2() - { - return m_swingSpan2; - } - inline btScalar getTwistSpan() - { - return m_twistSpan; - } - inline btScalar getTwistAngle() - { - return m_twistAngle; - } - bool isPastSwingLimit() { return m_solveSwingLimit; } - - - void setDamping(btScalar damping) { m_damping = damping; } - - void enableMotor(bool b) { m_bMotorEnabled = b; } - void setMaxMotorImpulse(btScalar maxMotorImpulse) { m_maxMotorImpulse = maxMotorImpulse; m_bNormalizedMotorStrength = false; } - void setMaxMotorImpulseNormalized(btScalar maxMotorImpulse) { m_maxMotorImpulse = maxMotorImpulse; m_bNormalizedMotorStrength = true; } - - btScalar getFixThresh() { return m_fixThresh; } - void setFixThresh(btScalar fixThresh) { m_fixThresh = fixThresh; } - - // setMotorTarget: - // q: the desired rotation of bodyA wrt bodyB. - // note: if q violates the joint limits, the internal target is clamped to avoid conflicting impulses (very bad for stability) - // note: don't forget to enableMotor() - void setMotorTarget(const btQuaternion &q); - - // same as above, but q is the desired rotation of frameA wrt frameB in constraint space - void setMotorTargetInConstraintSpace(const btQuaternion &q); - - btVector3 GetPointForAngle(btScalar fAngleInRadians, btScalar fLength) const; - - - -protected: - void init(); - - void computeConeLimitInfo(const btQuaternion& qCone, // in - btScalar& swingAngle, btVector3& vSwingAxis, btScalar& swingLimit); // all outs - - void computeTwistLimitInfo(const btQuaternion& qTwist, // in - btScalar& twistAngle, btVector3& vTwistAxis); // all outs - - void adjustSwingAxisToUseEllipseNormal(btVector3& vSwingAxis) const; -}; - -#endif //CONETWISTCONSTRAINT_H diff --git a/bullet/src/BulletDynamics/ConstraintSolver/btConstraintSolver.h b/bullet/src/BulletDynamics/ConstraintSolver/btConstraintSolver.h deleted file mode 100644 index 7975de35f..000000000 --- a/bullet/src/BulletDynamics/ConstraintSolver/btConstraintSolver.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef CONSTRAINT_SOLVER_H -#define CONSTRAINT_SOLVER_H - -#include "LinearMath/btScalar.h" - -class btPersistentManifold; -class btRigidBody; -class btCollisionObject; -class btTypedConstraint; -struct btContactSolverInfo; -struct btBroadphaseProxy; -class btIDebugDraw; -class btStackAlloc; -class btDispatcher; -/// btConstraintSolver provides solver interface -class btConstraintSolver -{ - -public: - - virtual ~btConstraintSolver() {} - - virtual void prepareSolve (int /* numBodies */, int /* numManifolds */) {;} - - ///solve a group of constraints - virtual btScalar solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifold,int numManifolds,btTypedConstraint** constraints,int numConstraints, const btContactSolverInfo& info,class btIDebugDraw* debugDrawer, btStackAlloc* stackAlloc,btDispatcher* dispatcher) = 0; - - virtual void allSolved (const btContactSolverInfo& /* info */,class btIDebugDraw* /* debugDrawer */, btStackAlloc* /* stackAlloc */) {;} - - ///clear internal cached data and reset random seed - virtual void reset() = 0; -}; - - - - -#endif //CONSTRAINT_SOLVER_H diff --git a/bullet/src/BulletDynamics/ConstraintSolver/btContactConstraint.cpp b/bullet/src/BulletDynamics/ConstraintSolver/btContactConstraint.cpp deleted file mode 100644 index c8fcf13f1..000000000 --- a/bullet/src/BulletDynamics/ConstraintSolver/btContactConstraint.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#include "btContactConstraint.h" -#include "BulletDynamics/Dynamics/btRigidBody.h" -#include "LinearMath/btVector3.h" -#include "btJacobianEntry.h" -#include "btContactSolverInfo.h" -#include "LinearMath/btMinMax.h" -#include "BulletCollision/NarrowPhaseCollision/btManifoldPoint.h" - -btContactConstraint::btContactConstraint() -:btTypedConstraint(CONTACT_CONSTRAINT_TYPE) -{ -} - -btContactConstraint::btContactConstraint(btPersistentManifold* contactManifold,btRigidBody& rbA,btRigidBody& rbB) -:btTypedConstraint(CONTACT_CONSTRAINT_TYPE,rbA,rbB), - m_contactManifold(*contactManifold) -{ - -} - -btContactConstraint::~btContactConstraint() -{ - -} - -void btContactConstraint::setContactManifold(btPersistentManifold* contactManifold) -{ - m_contactManifold = *contactManifold; -} - -void btContactConstraint::getInfo1 (btConstraintInfo1* info) -{ - -} - -void btContactConstraint::getInfo2 (btConstraintInfo2* info) -{ - -} - -void btContactConstraint::buildJacobian() -{ - -} - -void btContactConstraint::solveConstraintObsolete(btSolverBody& bodyA,btSolverBody& bodyB,btScalar timeStep) -{ - -} - - - - -#include "btContactConstraint.h" -#include "BulletDynamics/Dynamics/btRigidBody.h" -#include "LinearMath/btVector3.h" -#include "btJacobianEntry.h" -#include "btContactSolverInfo.h" -#include "LinearMath/btMinMax.h" -#include "BulletCollision/NarrowPhaseCollision/btManifoldPoint.h" - -#define ASSERT2 btAssert - -#define USE_INTERNAL_APPLY_IMPULSE 1 - - -//bilateral constraint between two dynamic objects -void resolveSingleBilateral(btRigidBody& body1, const btVector3& pos1, - btRigidBody& body2, const btVector3& pos2, - btScalar distance, const btVector3& normal,btScalar& impulse ,btScalar timeStep) -{ - (void)timeStep; - (void)distance; - - - btScalar normalLenSqr = normal.length2(); - ASSERT2(btFabs(normalLenSqr) < btScalar(1.1)); - if (normalLenSqr > btScalar(1.1)) - { - impulse = btScalar(0.); - return; - } - btVector3 rel_pos1 = pos1 - body1.getCenterOfMassPosition(); - btVector3 rel_pos2 = pos2 - body2.getCenterOfMassPosition(); - //this jacobian entry could be re-used for all iterations - - btVector3 vel1 = body1.getVelocityInLocalPoint(rel_pos1); - btVector3 vel2 = body2.getVelocityInLocalPoint(rel_pos2); - btVector3 vel = vel1 - vel2; - - - btJacobianEntry jac(body1.getCenterOfMassTransform().getBasis().transpose(), - body2.getCenterOfMassTransform().getBasis().transpose(), - rel_pos1,rel_pos2,normal,body1.getInvInertiaDiagLocal(),body1.getInvMass(), - body2.getInvInertiaDiagLocal(),body2.getInvMass()); - - btScalar jacDiagAB = jac.getDiagonal(); - btScalar jacDiagABInv = btScalar(1.) / jacDiagAB; - - btScalar rel_vel = jac.getRelativeVelocity( - body1.getLinearVelocity(), - body1.getCenterOfMassTransform().getBasis().transpose() * body1.getAngularVelocity(), - body2.getLinearVelocity(), - body2.getCenterOfMassTransform().getBasis().transpose() * body2.getAngularVelocity()); - btScalar a; - a=jacDiagABInv; - - - rel_vel = normal.dot(vel); - - //todo: move this into proper structure - btScalar contactDamping = btScalar(0.2); - -#ifdef ONLY_USE_LINEAR_MASS - btScalar massTerm = btScalar(1.) / (body1.getInvMass() + body2.getInvMass()); - impulse = - contactDamping * rel_vel * massTerm; -#else - btScalar velocityImpulse = -contactDamping * rel_vel * jacDiagABInv; - impulse = velocityImpulse; -#endif -} - - - - diff --git a/bullet/src/BulletDynamics/ConstraintSolver/btContactConstraint.h b/bullet/src/BulletDynamics/ConstraintSolver/btContactConstraint.h deleted file mode 100644 index 36cf8b5ef..000000000 --- a/bullet/src/BulletDynamics/ConstraintSolver/btContactConstraint.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef CONTACT_CONSTRAINT_H -#define CONTACT_CONSTRAINT_H - -#include "LinearMath/btVector3.h" -#include "btJacobianEntry.h" -#include "btTypedConstraint.h" -#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h" - -///btContactConstraint can be automatically created to solve contact constraints using the unified btTypedConstraint interface -ATTRIBUTE_ALIGNED16(class) btContactConstraint : public btTypedConstraint -{ -protected: - - btPersistentManifold m_contactManifold; - -public: - - btContactConstraint(); - - btContactConstraint(btPersistentManifold* contactManifold,btRigidBody& rbA,btRigidBody& rbB); - - void setContactManifold(btPersistentManifold* contactManifold); - - btPersistentManifold* getContactManifold() - { - return &m_contactManifold; - } - - const btPersistentManifold* getContactManifold() const - { - return &m_contactManifold; - } - - virtual ~btContactConstraint(); - - virtual void getInfo1 (btConstraintInfo1* info); - - virtual void getInfo2 (btConstraintInfo2* info); - - ///obsolete methods - virtual void buildJacobian(); - - ///obsolete methods - virtual void solveConstraintObsolete(btSolverBody& bodyA,btSolverBody& bodyB,btScalar timeStep); - -}; - - -///resolveSingleBilateral is an obsolete methods used for vehicle friction between two dynamic objects -void resolveSingleBilateral(btRigidBody& body1, const btVector3& pos1, - btRigidBody& body2, const btVector3& pos2, - btScalar distance, const btVector3& normal,btScalar& impulse ,btScalar timeStep); - - - -#endif //CONTACT_CONSTRAINT_H diff --git a/bullet/src/BulletDynamics/ConstraintSolver/btContactSolverInfo.h b/bullet/src/BulletDynamics/ConstraintSolver/btContactSolverInfo.h deleted file mode 100644 index 71bc3a907..000000000 --- a/bullet/src/BulletDynamics/ConstraintSolver/btContactSolverInfo.h +++ /dev/null @@ -1,85 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef CONTACT_SOLVER_INFO -#define CONTACT_SOLVER_INFO - -enum btSolverMode -{ - SOLVER_RANDMIZE_ORDER = 1, - SOLVER_FRICTION_SEPARATE = 2, - SOLVER_USE_WARMSTARTING = 4, - SOLVER_USE_FRICTION_WARMSTARTING = 8, - SOLVER_USE_2_FRICTION_DIRECTIONS = 16, - SOLVER_ENABLE_FRICTION_DIRECTION_CACHING = 32, - SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION = 64, - SOLVER_CACHE_FRIENDLY = 128, - SOLVER_SIMD = 256, //enabled for Windows, the solver innerloop is branchless SIMD, 40% faster than FPU/scalar version - SOLVER_CUDA = 512 //will be open sourced during Game Developers Conference 2009. Much faster. -}; - -struct btContactSolverInfoData -{ - - - btScalar m_tau; - btScalar m_damping; - btScalar m_friction; - btScalar m_timeStep; - btScalar m_restitution; - int m_numIterations; - btScalar m_maxErrorReduction; - btScalar m_sor; - btScalar m_erp;//used as Baumgarte factor - btScalar m_erp2;//used in Split Impulse - btScalar m_globalCfm;//constraint force mixing - int m_splitImpulse; - btScalar m_splitImpulsePenetrationThreshold; - btScalar m_linearSlop; - btScalar m_warmstartingFactor; - - int m_solverMode; - int m_restingContactRestitutionThreshold; - - -}; - -struct btContactSolverInfo : public btContactSolverInfoData -{ - - - - inline btContactSolverInfo() - { - m_tau = btScalar(0.6); - m_damping = btScalar(1.0); - m_friction = btScalar(0.3); - m_restitution = btScalar(0.); - m_maxErrorReduction = btScalar(20.); - m_numIterations = 10; - m_erp = btScalar(0.2); - m_erp2 = btScalar(0.1); - m_globalCfm = btScalar(0.); - m_sor = btScalar(1.); - m_splitImpulse = false; - m_splitImpulsePenetrationThreshold = -0.02f; - m_linearSlop = btScalar(0.0); - m_warmstartingFactor=btScalar(0.85); - m_solverMode = SOLVER_USE_WARMSTARTING | SOLVER_SIMD;// | SOLVER_RANDMIZE_ORDER; - m_restingContactRestitutionThreshold = 2;//resting contact lifetime threshold to disable restitution - } -}; - -#endif //CONTACT_SOLVER_INFO diff --git a/bullet/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.cpp b/bullet/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.cpp deleted file mode 100644 index 92068d418..000000000 --- a/bullet/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.cpp +++ /dev/null @@ -1,1057 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ -/* -2007-09-09 -Refactored by Francisco Le?n -email: projectileman@yahoo.com -http://gimpact.sf.net -*/ - -#include "btGeneric6DofConstraint.h" -#include "BulletDynamics/Dynamics/btRigidBody.h" -#include "LinearMath/btTransformUtil.h" -#include "LinearMath/btTransformUtil.h" -#include - - - -#define D6_USE_OBSOLETE_METHOD false -#define D6_USE_FRAME_OFFSET true - - -btGeneric6DofConstraint::btGeneric6DofConstraint() -:btTypedConstraint(D6_CONSTRAINT_TYPE), -m_useLinearReferenceFrameA(true), -m_useOffsetForConstraintFrame(D6_USE_FRAME_OFFSET), -m_useSolveConstraintObsolete(D6_USE_OBSOLETE_METHOD) -{ -} - - - -btGeneric6DofConstraint::btGeneric6DofConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB, bool useLinearReferenceFrameA) -: btTypedConstraint(D6_CONSTRAINT_TYPE, rbA, rbB) -, m_frameInA(frameInA) -, m_frameInB(frameInB), -m_useLinearReferenceFrameA(useLinearReferenceFrameA), -m_useOffsetForConstraintFrame(D6_USE_FRAME_OFFSET), -m_useSolveConstraintObsolete(D6_USE_OBSOLETE_METHOD) -{ - -} - - - -#define GENERIC_D6_DISABLE_WARMSTARTING 1 - - - -btScalar btGetMatrixElem(const btMatrix3x3& mat, int index); -btScalar btGetMatrixElem(const btMatrix3x3& mat, int index) -{ - int i = index%3; - int j = index/3; - return mat[i][j]; -} - - - -///MatrixToEulerXYZ from http://www.geometrictools.com/LibFoundation/Mathematics/Wm4Matrix3.inl.html -bool matrixToEulerXYZ(const btMatrix3x3& mat,btVector3& xyz); -bool matrixToEulerXYZ(const btMatrix3x3& mat,btVector3& xyz) -{ - // // rot = cy*cz -cy*sz sy - // // cz*sx*sy+cx*sz cx*cz-sx*sy*sz -cy*sx - // // -cx*cz*sy+sx*sz cz*sx+cx*sy*sz cx*cy - // - - btScalar fi = btGetMatrixElem(mat,2); - if (fi < btScalar(1.0f)) - { - if (fi > btScalar(-1.0f)) - { - xyz[0] = btAtan2(-btGetMatrixElem(mat,5),btGetMatrixElem(mat,8)); - xyz[1] = btAsin(btGetMatrixElem(mat,2)); - xyz[2] = btAtan2(-btGetMatrixElem(mat,1),btGetMatrixElem(mat,0)); - return true; - } - else - { - // WARNING. Not unique. XA - ZA = -atan2(r10,r11) - xyz[0] = -btAtan2(btGetMatrixElem(mat,3),btGetMatrixElem(mat,4)); - xyz[1] = -SIMD_HALF_PI; - xyz[2] = btScalar(0.0); - return false; - } - } - else - { - // WARNING. Not unique. XAngle + ZAngle = atan2(r10,r11) - xyz[0] = btAtan2(btGetMatrixElem(mat,3),btGetMatrixElem(mat,4)); - xyz[1] = SIMD_HALF_PI; - xyz[2] = 0.0; - } - return false; -} - -//////////////////////////// btRotationalLimitMotor //////////////////////////////////// - -int btRotationalLimitMotor::testLimitValue(btScalar test_value) -{ - if(m_loLimit>m_hiLimit) - { - m_currentLimit = 0;//Free from violation - return 0; - } - if (test_value < m_loLimit) - { - m_currentLimit = 1;//low limit violation - m_currentLimitError = test_value - m_loLimit; - return 1; - } - else if (test_value> m_hiLimit) - { - m_currentLimit = 2;//High limit violation - m_currentLimitError = test_value - m_hiLimit; - return 2; - }; - - m_currentLimit = 0;//Free from violation - return 0; - -} - - - -btScalar btRotationalLimitMotor::solveAngularLimits( - btScalar timeStep,btVector3& axis,btScalar jacDiagABInv, - btRigidBody * body0, btSolverBody& bodyA, btRigidBody * body1, btSolverBody& bodyB) -{ - if (needApplyTorques()==false) return 0.0f; - - btScalar target_velocity = m_targetVelocity; - btScalar maxMotorForce = m_maxMotorForce; - - //current error correction - if (m_currentLimit!=0) - { - target_velocity = -m_ERP*m_currentLimitError/(timeStep); - maxMotorForce = m_maxLimitForce; - } - - maxMotorForce *= timeStep; - - // current velocity difference - - btVector3 angVelA; - bodyA.getAngularVelocity(angVelA); - btVector3 angVelB; - bodyB.getAngularVelocity(angVelB); - - btVector3 vel_diff; - vel_diff = angVelA-angVelB; - - - - btScalar rel_vel = axis.dot(vel_diff); - - // correction velocity - btScalar motor_relvel = m_limitSoftness*(target_velocity - m_damping*rel_vel); - - - if ( motor_relvel < SIMD_EPSILON && motor_relvel > -SIMD_EPSILON ) - { - return 0.0f;//no need for applying force - } - - - // correction impulse - btScalar unclippedMotorImpulse = (1+m_bounce)*motor_relvel*jacDiagABInv; - - // clip correction impulse - btScalar clippedMotorImpulse; - - ///@todo: should clip against accumulated impulse - if (unclippedMotorImpulse>0.0f) - { - clippedMotorImpulse = unclippedMotorImpulse > maxMotorForce? maxMotorForce: unclippedMotorImpulse; - } - else - { - clippedMotorImpulse = unclippedMotorImpulse < -maxMotorForce ? -maxMotorForce: unclippedMotorImpulse; - } - - - // sort with accumulated impulses - btScalar lo = btScalar(-BT_LARGE_FLOAT); - btScalar hi = btScalar(BT_LARGE_FLOAT); - - btScalar oldaccumImpulse = m_accumulatedImpulse; - btScalar sum = oldaccumImpulse + clippedMotorImpulse; - m_accumulatedImpulse = sum > hi ? btScalar(0.) : sum < lo ? btScalar(0.) : sum; - - clippedMotorImpulse = m_accumulatedImpulse - oldaccumImpulse; - - btVector3 motorImp = clippedMotorImpulse * axis; - - //body0->applyTorqueImpulse(motorImp); - //body1->applyTorqueImpulse(-motorImp); - - bodyA.applyImpulse(btVector3(0,0,0), body0->getInvInertiaTensorWorld()*axis,clippedMotorImpulse); - bodyB.applyImpulse(btVector3(0,0,0), body1->getInvInertiaTensorWorld()*axis,-clippedMotorImpulse); - - - return clippedMotorImpulse; - - -} - -//////////////////////////// End btRotationalLimitMotor //////////////////////////////////// - - - - -//////////////////////////// btTranslationalLimitMotor //////////////////////////////////// - - -int btTranslationalLimitMotor::testLimitValue(int limitIndex, btScalar test_value) -{ - btScalar loLimit = m_lowerLimit[limitIndex]; - btScalar hiLimit = m_upperLimit[limitIndex]; - if(loLimit > hiLimit) - { - m_currentLimit[limitIndex] = 0;//Free from violation - m_currentLimitError[limitIndex] = btScalar(0.f); - return 0; - } - - if (test_value < loLimit) - { - m_currentLimit[limitIndex] = 2;//low limit violation - m_currentLimitError[limitIndex] = test_value - loLimit; - return 2; - } - else if (test_value> hiLimit) - { - m_currentLimit[limitIndex] = 1;//High limit violation - m_currentLimitError[limitIndex] = test_value - hiLimit; - return 1; - }; - - m_currentLimit[limitIndex] = 0;//Free from violation - m_currentLimitError[limitIndex] = btScalar(0.f); - return 0; -} - - - -btScalar btTranslationalLimitMotor::solveLinearAxis( - btScalar timeStep, - btScalar jacDiagABInv, - btRigidBody& body1,btSolverBody& bodyA,const btVector3 &pointInA, - btRigidBody& body2,btSolverBody& bodyB,const btVector3 &pointInB, - int limit_index, - const btVector3 & axis_normal_on_a, - const btVector3 & anchorPos) -{ - - ///find relative velocity - // btVector3 rel_pos1 = pointInA - body1.getCenterOfMassPosition(); - // btVector3 rel_pos2 = pointInB - body2.getCenterOfMassPosition(); - btVector3 rel_pos1 = anchorPos - body1.getCenterOfMassPosition(); - btVector3 rel_pos2 = anchorPos - body2.getCenterOfMassPosition(); - - btVector3 vel1; - bodyA.getVelocityInLocalPointObsolete(rel_pos1,vel1); - btVector3 vel2; - bodyB.getVelocityInLocalPointObsolete(rel_pos2,vel2); - btVector3 vel = vel1 - vel2; - - btScalar rel_vel = axis_normal_on_a.dot(vel); - - - - /// apply displacement correction - - //positional error (zeroth order error) - btScalar depth = -(pointInA - pointInB).dot(axis_normal_on_a); - btScalar lo = btScalar(-BT_LARGE_FLOAT); - btScalar hi = btScalar(BT_LARGE_FLOAT); - - btScalar minLimit = m_lowerLimit[limit_index]; - btScalar maxLimit = m_upperLimit[limit_index]; - - //handle the limits - if (minLimit < maxLimit) - { - { - if (depth > maxLimit) - { - depth -= maxLimit; - lo = btScalar(0.); - - } - else - { - if (depth < minLimit) - { - depth -= minLimit; - hi = btScalar(0.); - } - else - { - return 0.0f; - } - } - } - } - - btScalar normalImpulse= m_limitSoftness*(m_restitution*depth/timeStep - m_damping*rel_vel) * jacDiagABInv; - - - - - btScalar oldNormalImpulse = m_accumulatedImpulse[limit_index]; - btScalar sum = oldNormalImpulse + normalImpulse; - m_accumulatedImpulse[limit_index] = sum > hi ? btScalar(0.) : sum < lo ? btScalar(0.) : sum; - normalImpulse = m_accumulatedImpulse[limit_index] - oldNormalImpulse; - - btVector3 impulse_vector = axis_normal_on_a * normalImpulse; - //body1.applyImpulse( impulse_vector, rel_pos1); - //body2.applyImpulse(-impulse_vector, rel_pos2); - - btVector3 ftorqueAxis1 = rel_pos1.cross(axis_normal_on_a); - btVector3 ftorqueAxis2 = rel_pos2.cross(axis_normal_on_a); - bodyA.applyImpulse(axis_normal_on_a*body1.getInvMass(), body1.getInvInertiaTensorWorld()*ftorqueAxis1,normalImpulse); - bodyB.applyImpulse(axis_normal_on_a*body2.getInvMass(), body2.getInvInertiaTensorWorld()*ftorqueAxis2,-normalImpulse); - - - - - return normalImpulse; -} - -//////////////////////////// btTranslationalLimitMotor //////////////////////////////////// - -void btGeneric6DofConstraint::calculateAngleInfo() -{ - btMatrix3x3 relative_frame = m_calculatedTransformA.getBasis().inverse()*m_calculatedTransformB.getBasis(); - matrixToEulerXYZ(relative_frame,m_calculatedAxisAngleDiff); - // in euler angle mode we do not actually constrain the angular velocity - // along the axes axis[0] and axis[2] (although we do use axis[1]) : - // - // to get constrain w2-w1 along ...not - // ------ --------------------- ------ - // d(angle[0])/dt = 0 ax[1] x ax[2] ax[0] - // d(angle[1])/dt = 0 ax[1] - // d(angle[2])/dt = 0 ax[0] x ax[1] ax[2] - // - // constraining w2-w1 along an axis 'a' means that a'*(w2-w1)=0. - // to prove the result for angle[0], write the expression for angle[0] from - // GetInfo1 then take the derivative. to prove this for angle[2] it is - // easier to take the euler rate expression for d(angle[2])/dt with respect - // to the components of w and set that to 0. - btVector3 axis0 = m_calculatedTransformB.getBasis().getColumn(0); - btVector3 axis2 = m_calculatedTransformA.getBasis().getColumn(2); - - m_calculatedAxis[1] = axis2.cross(axis0); - m_calculatedAxis[0] = m_calculatedAxis[1].cross(axis2); - m_calculatedAxis[2] = axis0.cross(m_calculatedAxis[1]); - - m_calculatedAxis[0].normalize(); - m_calculatedAxis[1].normalize(); - m_calculatedAxis[2].normalize(); - -} - -void btGeneric6DofConstraint::calculateTransforms() -{ - calculateTransforms(m_rbA.getCenterOfMassTransform(),m_rbB.getCenterOfMassTransform()); -} - -void btGeneric6DofConstraint::calculateTransforms(const btTransform& transA,const btTransform& transB) -{ - m_calculatedTransformA = transA * m_frameInA; - m_calculatedTransformB = transB * m_frameInB; - calculateLinearInfo(); - calculateAngleInfo(); - if(m_useOffsetForConstraintFrame) - { // get weight factors depending on masses - btScalar miA = getRigidBodyA().getInvMass(); - btScalar miB = getRigidBodyB().getInvMass(); - m_hasStaticBody = (miA < SIMD_EPSILON) || (miB < SIMD_EPSILON); - btScalar miS = miA + miB; - if(miS > btScalar(0.f)) - { - m_factA = miB / miS; - } - else - { - m_factA = btScalar(0.5f); - } - m_factB = btScalar(1.0f) - m_factA; - } -} - - - -void btGeneric6DofConstraint::buildLinearJacobian( - btJacobianEntry & jacLinear,const btVector3 & normalWorld, - const btVector3 & pivotAInW,const btVector3 & pivotBInW) -{ - new (&jacLinear) btJacobianEntry( - m_rbA.getCenterOfMassTransform().getBasis().transpose(), - m_rbB.getCenterOfMassTransform().getBasis().transpose(), - pivotAInW - m_rbA.getCenterOfMassPosition(), - pivotBInW - m_rbB.getCenterOfMassPosition(), - normalWorld, - m_rbA.getInvInertiaDiagLocal(), - m_rbA.getInvMass(), - m_rbB.getInvInertiaDiagLocal(), - m_rbB.getInvMass()); -} - - - -void btGeneric6DofConstraint::buildAngularJacobian( - btJacobianEntry & jacAngular,const btVector3 & jointAxisW) -{ - new (&jacAngular) btJacobianEntry(jointAxisW, - m_rbA.getCenterOfMassTransform().getBasis().transpose(), - m_rbB.getCenterOfMassTransform().getBasis().transpose(), - m_rbA.getInvInertiaDiagLocal(), - m_rbB.getInvInertiaDiagLocal()); - -} - - - -bool btGeneric6DofConstraint::testAngularLimitMotor(int axis_index) -{ - btScalar angle = m_calculatedAxisAngleDiff[axis_index]; - angle = btAdjustAngleToLimits(angle, m_angularLimits[axis_index].m_loLimit, m_angularLimits[axis_index].m_hiLimit); - m_angularLimits[axis_index].m_currentPosition = angle; - //test limits - m_angularLimits[axis_index].testLimitValue(angle); - return m_angularLimits[axis_index].needApplyTorques(); -} - - - -void btGeneric6DofConstraint::buildJacobian() -{ -#ifndef __SPU__ - if (m_useSolveConstraintObsolete) - { - - // Clear accumulated impulses for the next simulation step - m_linearLimits.m_accumulatedImpulse.setValue(btScalar(0.), btScalar(0.), btScalar(0.)); - int i; - for(i = 0; i < 3; i++) - { - m_angularLimits[i].m_accumulatedImpulse = btScalar(0.); - } - //calculates transform - calculateTransforms(m_rbA.getCenterOfMassTransform(),m_rbB.getCenterOfMassTransform()); - - // const btVector3& pivotAInW = m_calculatedTransformA.getOrigin(); - // const btVector3& pivotBInW = m_calculatedTransformB.getOrigin(); - calcAnchorPos(); - btVector3 pivotAInW = m_AnchorPos; - btVector3 pivotBInW = m_AnchorPos; - - // not used here - // btVector3 rel_pos1 = pivotAInW - m_rbA.getCenterOfMassPosition(); - // btVector3 rel_pos2 = pivotBInW - m_rbB.getCenterOfMassPosition(); - - btVector3 normalWorld; - //linear part - for (i=0;i<3;i++) - { - if (m_linearLimits.isLimited(i)) - { - if (m_useLinearReferenceFrameA) - normalWorld = m_calculatedTransformA.getBasis().getColumn(i); - else - normalWorld = m_calculatedTransformB.getBasis().getColumn(i); - - buildLinearJacobian( - m_jacLinear[i],normalWorld , - pivotAInW,pivotBInW); - - } - } - - // angular part - for (i=0;i<3;i++) - { - //calculates error angle - if (testAngularLimitMotor(i)) - { - normalWorld = this->getAxis(i); - // Create angular atom - buildAngularJacobian(m_jacAng[i],normalWorld); - } - } - - } -#endif //__SPU__ - -} - - -void btGeneric6DofConstraint::getInfo1 (btConstraintInfo1* info) -{ - if (m_useSolveConstraintObsolete) - { - info->m_numConstraintRows = 0; - info->nub = 0; - } else - { - //prepare constraint - calculateTransforms(m_rbA.getCenterOfMassTransform(),m_rbB.getCenterOfMassTransform()); - info->m_numConstraintRows = 0; - info->nub = 6; - int i; - //test linear limits - for(i = 0; i < 3; i++) - { - if(m_linearLimits.needApplyForce(i)) - { - info->m_numConstraintRows++; - info->nub--; - } - } - //test angular limits - for (i=0;i<3 ;i++ ) - { - if(testAngularLimitMotor(i)) - { - info->m_numConstraintRows++; - info->nub--; - } - } - } -} - -void btGeneric6DofConstraint::getInfo1NonVirtual (btConstraintInfo1* info) -{ - if (m_useSolveConstraintObsolete) - { - info->m_numConstraintRows = 0; - info->nub = 0; - } else - { - //pre-allocate all 6 - info->m_numConstraintRows = 6; - info->nub = 0; - } -} - - -void btGeneric6DofConstraint::getInfo2 (btConstraintInfo2* info) -{ - getInfo2NonVirtual(info,m_rbA.getCenterOfMassTransform(),m_rbB.getCenterOfMassTransform(), m_rbA.getLinearVelocity(),m_rbB.getLinearVelocity(),m_rbA.getAngularVelocity(), m_rbB.getAngularVelocity()); -} - -void btGeneric6DofConstraint::getInfo2NonVirtual (btConstraintInfo2* info, const btTransform& transA,const btTransform& transB,const btVector3& linVelA,const btVector3& linVelB,const btVector3& angVelA,const btVector3& angVelB) -{ - btAssert(!m_useSolveConstraintObsolete); - //prepare constraint - calculateTransforms(transA,transB); - if(m_useOffsetForConstraintFrame) - { // for stability better to solve angular limits first - int row = setAngularLimits(info, 0,transA,transB,linVelA,linVelB,angVelA,angVelB); - setLinearLimits(info, row, transA,transB,linVelA,linVelB,angVelA,angVelB); - } - else - { // leave old version for compatibility - int row = setLinearLimits(info, 0, transA,transB,linVelA,linVelB,angVelA,angVelB); - setAngularLimits(info, row,transA,transB,linVelA,linVelB,angVelA,angVelB); - } -} - - - -int btGeneric6DofConstraint::setLinearLimits(btConstraintInfo2* info, int row, const btTransform& transA,const btTransform& transB,const btVector3& linVelA,const btVector3& linVelB,const btVector3& angVelA,const btVector3& angVelB) -{ -// int row = 0; - //solve linear limits - btRotationalLimitMotor limot; - for (int i=0;i<3 ;i++ ) - { - if(m_linearLimits.needApplyForce(i)) - { // re-use rotational motor code - limot.m_bounce = btScalar(0.f); - limot.m_currentLimit = m_linearLimits.m_currentLimit[i]; - limot.m_currentPosition = m_linearLimits.m_currentLinearDiff[i]; - limot.m_currentLimitError = m_linearLimits.m_currentLimitError[i]; - limot.m_damping = m_linearLimits.m_damping; - limot.m_enableMotor = m_linearLimits.m_enableMotor[i]; - limot.m_ERP = m_linearLimits.m_restitution; - limot.m_hiLimit = m_linearLimits.m_upperLimit[i]; - limot.m_limitSoftness = m_linearLimits.m_limitSoftness; - limot.m_loLimit = m_linearLimits.m_lowerLimit[i]; - limot.m_maxLimitForce = btScalar(0.f); - limot.m_maxMotorForce = m_linearLimits.m_maxMotorForce[i]; - limot.m_targetVelocity = m_linearLimits.m_targetVelocity[i]; - btVector3 axis = m_calculatedTransformA.getBasis().getColumn(i); - if(m_useOffsetForConstraintFrame) - { - int indx1 = (i + 1) % 3; - int indx2 = (i + 2) % 3; - int rotAllowed = 1; // rotations around orthos to current axis - if(m_angularLimits[indx1].m_currentLimit && m_angularLimits[indx2].m_currentLimit) - { - rotAllowed = 0; - } - row += get_limit_motor_info2UsingFrameOffset(&limot, transA,transB,linVelA,linVelB,angVelA,angVelB, info, row, axis, 0, rotAllowed); - } - else - { - row += get_limit_motor_info2(&limot, transA,transB,linVelA,linVelB,angVelA,angVelB, info, row, axis, 0); - } - } - } - return row; -} - - - -int btGeneric6DofConstraint::setAngularLimits(btConstraintInfo2 *info, int row_offset, const btTransform& transA,const btTransform& transB,const btVector3& linVelA,const btVector3& linVelB,const btVector3& angVelA,const btVector3& angVelB) -{ - btGeneric6DofConstraint * d6constraint = this; - int row = row_offset; - //solve angular limits - for (int i=0;i<3 ;i++ ) - { - if(d6constraint->getRotationalLimitMotor(i)->needApplyTorques()) - { - btVector3 axis = d6constraint->getAxis(i); - row += get_limit_motor_info2(d6constraint->getRotationalLimitMotor(i), - transA,transB,linVelA,linVelB,angVelA,angVelB, info,row,axis,1); - } - } - - return row; -} - - - -void btGeneric6DofConstraint::solveConstraintObsolete(btSolverBody& bodyA,btSolverBody& bodyB,btScalar timeStep) -{ - if (m_useSolveConstraintObsolete) - { - - - m_timeStep = timeStep; - - //calculateTransforms(); - - int i; - - // linear - - btVector3 pointInA = m_calculatedTransformA.getOrigin(); - btVector3 pointInB = m_calculatedTransformB.getOrigin(); - - btScalar jacDiagABInv; - btVector3 linear_axis; - for (i=0;i<3;i++) - { - if (m_linearLimits.isLimited(i)) - { - jacDiagABInv = btScalar(1.) / m_jacLinear[i].getDiagonal(); - - if (m_useLinearReferenceFrameA) - linear_axis = m_calculatedTransformA.getBasis().getColumn(i); - else - linear_axis = m_calculatedTransformB.getBasis().getColumn(i); - - m_linearLimits.solveLinearAxis( - m_timeStep, - jacDiagABInv, - m_rbA,bodyA,pointInA, - m_rbB,bodyB,pointInB, - i,linear_axis, m_AnchorPos); - - } - } - - // angular - btVector3 angular_axis; - btScalar angularJacDiagABInv; - for (i=0;i<3;i++) - { - if (m_angularLimits[i].needApplyTorques()) - { - - // get axis - angular_axis = getAxis(i); - - angularJacDiagABInv = btScalar(1.) / m_jacAng[i].getDiagonal(); - - m_angularLimits[i].solveAngularLimits(m_timeStep,angular_axis,angularJacDiagABInv, &m_rbA,bodyA,&m_rbB,bodyB); - } - } - } -} - - - -void btGeneric6DofConstraint::updateRHS(btScalar timeStep) -{ - (void)timeStep; - -} - - - -btVector3 btGeneric6DofConstraint::getAxis(int axis_index) const -{ - return m_calculatedAxis[axis_index]; -} - - -btScalar btGeneric6DofConstraint::getRelativePivotPosition(int axisIndex) const -{ - return m_calculatedLinearDiff[axisIndex]; -} - - -btScalar btGeneric6DofConstraint::getAngle(int axisIndex) const -{ - return m_calculatedAxisAngleDiff[axisIndex]; -} - - - -void btGeneric6DofConstraint::calcAnchorPos(void) -{ - btScalar imA = m_rbA.getInvMass(); - btScalar imB = m_rbB.getInvMass(); - btScalar weight; - if(imB == btScalar(0.0)) - { - weight = btScalar(1.0); - } - else - { - weight = imA / (imA + imB); - } - const btVector3& pA = m_calculatedTransformA.getOrigin(); - const btVector3& pB = m_calculatedTransformB.getOrigin(); - m_AnchorPos = pA * weight + pB * (btScalar(1.0) - weight); - return; -} - - - -void btGeneric6DofConstraint::calculateLinearInfo() -{ - m_calculatedLinearDiff = m_calculatedTransformB.getOrigin() - m_calculatedTransformA.getOrigin(); - m_calculatedLinearDiff = m_calculatedTransformA.getBasis().inverse() * m_calculatedLinearDiff; - for(int i = 0; i < 3; i++) - { - m_linearLimits.m_currentLinearDiff[i] = m_calculatedLinearDiff[i]; - m_linearLimits.testLimitValue(i, m_calculatedLinearDiff[i]); - } -} - - - -int btGeneric6DofConstraint::get_limit_motor_info2( - btRotationalLimitMotor * limot, - const btTransform& transA,const btTransform& transB,const btVector3& linVelA,const btVector3& linVelB,const btVector3& angVelA,const btVector3& angVelB, - btConstraintInfo2 *info, int row, btVector3& ax1, int rotational) -{ - int srow = row * info->rowskip; - int powered = limot->m_enableMotor; - int limit = limot->m_currentLimit; - if (powered || limit) - { // if the joint is powered, or has joint limits, add in the extra row - btScalar *J1 = rotational ? info->m_J1angularAxis : info->m_J1linearAxis; - btScalar *J2 = rotational ? info->m_J2angularAxis : 0; - J1[srow+0] = ax1[0]; - J1[srow+1] = ax1[1]; - J1[srow+2] = ax1[2]; - if(rotational) - { - J2[srow+0] = -ax1[0]; - J2[srow+1] = -ax1[1]; - J2[srow+2] = -ax1[2]; - } - if((!rotational)) - { - btVector3 ltd; // Linear Torque Decoupling vector - btVector3 c = m_calculatedTransformB.getOrigin() - transA.getOrigin(); - ltd = c.cross(ax1); - info->m_J1angularAxis[srow+0] = ltd[0]; - info->m_J1angularAxis[srow+1] = ltd[1]; - info->m_J1angularAxis[srow+2] = ltd[2]; - - c = m_calculatedTransformB.getOrigin() - transB.getOrigin(); - ltd = -c.cross(ax1); - info->m_J2angularAxis[srow+0] = ltd[0]; - info->m_J2angularAxis[srow+1] = ltd[1]; - info->m_J2angularAxis[srow+2] = ltd[2]; - } - // if we're limited low and high simultaneously, the joint motor is - // ineffective - if (limit && (limot->m_loLimit == limot->m_hiLimit)) powered = 0; - info->m_constraintError[srow] = btScalar(0.f); - if (powered) - { - info->cfm[srow] = 0.0f; - if(!limit) - { - btScalar tag_vel = rotational ? limot->m_targetVelocity : -limot->m_targetVelocity; - - btScalar mot_fact = getMotorFactor( limot->m_currentPosition, - limot->m_loLimit, - limot->m_hiLimit, - tag_vel, - info->fps * info->erp); - info->m_constraintError[srow] += mot_fact * limot->m_targetVelocity; - info->m_lowerLimit[srow] = -limot->m_maxMotorForce; - info->m_upperLimit[srow] = limot->m_maxMotorForce; - } - } - if(limit) - { - btScalar k = info->fps * limot->m_ERP; - if(!rotational) - { - info->m_constraintError[srow] += k * limot->m_currentLimitError; - } - else - { - info->m_constraintError[srow] += -k * limot->m_currentLimitError; - } - info->cfm[srow] = 0.0f; - if (limot->m_loLimit == limot->m_hiLimit) - { // limited low and high simultaneously - info->m_lowerLimit[srow] = -SIMD_INFINITY; - info->m_upperLimit[srow] = SIMD_INFINITY; - } - else - { - if (limit == 1) - { - info->m_lowerLimit[srow] = 0; - info->m_upperLimit[srow] = SIMD_INFINITY; - } - else - { - info->m_lowerLimit[srow] = -SIMD_INFINITY; - info->m_upperLimit[srow] = 0; - } - // deal with bounce - if (limot->m_bounce > 0) - { - // calculate joint velocity - btScalar vel; - if (rotational) - { - vel = angVelA.dot(ax1); -//make sure that if no body -> angVelB == zero vec -// if (body1) - vel -= angVelB.dot(ax1); - } - else - { - vel = linVelA.dot(ax1); -//make sure that if no body -> angVelB == zero vec -// if (body1) - vel -= linVelB.dot(ax1); - } - // only apply bounce if the velocity is incoming, and if the - // resulting c[] exceeds what we already have. - if (limit == 1) - { - if (vel < 0) - { - btScalar newc = -limot->m_bounce* vel; - if (newc > info->m_constraintError[srow]) - info->m_constraintError[srow] = newc; - } - } - else - { - if (vel > 0) - { - btScalar newc = -limot->m_bounce * vel; - if (newc < info->m_constraintError[srow]) - info->m_constraintError[srow] = newc; - } - } - } - } - } - return 1; - } - else return 0; -} - - - -int btGeneric6DofConstraint::get_limit_motor_info2UsingFrameOffset( btRotationalLimitMotor * limot, - const btTransform& transA,const btTransform& transB,const btVector3& linVelA,const btVector3& linVelB,const btVector3& angVelA,const btVector3& angVelB, - btConstraintInfo2 *info, int row, btVector3& ax1, int rotational, int rotAllowed) -{ - int srow = row * info->rowskip; - int powered = limot->m_enableMotor; - int limit = limot->m_currentLimit; - if (powered || limit) - { // if the joint is powered, or has joint limits, add in the extra row - btScalar *J1 = rotational ? info->m_J1angularAxis : info->m_J1linearAxis; - btScalar *J2 = rotational ? info->m_J2angularAxis : 0; - J1[srow+0] = ax1[0]; - J1[srow+1] = ax1[1]; - J1[srow+2] = ax1[2]; - if(rotational) - { - J2[srow+0] = -ax1[0]; - J2[srow+1] = -ax1[1]; - J2[srow+2] = -ax1[2]; - } - if((!rotational)) - { - btVector3 tmpA, tmpB, relA, relB; - // get vector from bodyB to frameB in WCS - relB = m_calculatedTransformB.getOrigin() - transB.getOrigin(); - // get its projection to constraint axis - btVector3 projB = ax1 * relB.dot(ax1); - // get vector directed from bodyB to constraint axis (and orthogonal to it) - btVector3 orthoB = relB - projB; - // same for bodyA - relA = m_calculatedTransformA.getOrigin() - transA.getOrigin(); - btVector3 projA = ax1 * relA.dot(ax1); - btVector3 orthoA = relA - projA; - // get desired offset between frames A and B along constraint axis - btScalar desiredOffs = limot->m_currentPosition - limot->m_currentLimitError; - // desired vector from projection of center of bodyA to projection of center of bodyB to constraint axis - btVector3 totalDist = projA + ax1 * desiredOffs - projB; - // get offset vectors relA and relB - relA = orthoA + totalDist * m_factA; - relB = orthoB - totalDist * m_factB; - tmpA = relA.cross(ax1); - tmpB = relB.cross(ax1); - if(m_hasStaticBody && (!rotAllowed)) - { - tmpA *= m_factA; - tmpB *= m_factB; - } - int i; - for (i=0; i<3; i++) info->m_J1angularAxis[srow+i] = tmpA[i]; - for (i=0; i<3; i++) info->m_J2angularAxis[srow+i] = -tmpB[i]; - } - // if we're limited low and high simultaneously, the joint motor is - // ineffective - if (limit && (limot->m_loLimit == limot->m_hiLimit)) powered = 0; - info->m_constraintError[srow] = btScalar(0.f); - if (powered) - { - info->cfm[srow] = 0.0f; - if(!limit) - { - btScalar tag_vel = rotational ? limot->m_targetVelocity : -limot->m_targetVelocity; - - btScalar mot_fact = getMotorFactor( limot->m_currentPosition, - limot->m_loLimit, - limot->m_hiLimit, - tag_vel, - info->fps * info->erp); - info->m_constraintError[srow] += mot_fact * limot->m_targetVelocity; - info->m_lowerLimit[srow] = -limot->m_maxMotorForce; - info->m_upperLimit[srow] = limot->m_maxMotorForce; - } - } - if(limit) - { - btScalar k = info->fps * limot->m_ERP; - if(!rotational) - { - info->m_constraintError[srow] += k * limot->m_currentLimitError; - } - else - { - info->m_constraintError[srow] += -k * limot->m_currentLimitError; - } - info->cfm[srow] = 0.0f; - if (limot->m_loLimit == limot->m_hiLimit) - { // limited low and high simultaneously - info->m_lowerLimit[srow] = -SIMD_INFINITY; - info->m_upperLimit[srow] = SIMD_INFINITY; - } - else - { - if (limit == 1) - { - info->m_lowerLimit[srow] = 0; - info->m_upperLimit[srow] = SIMD_INFINITY; - } - else - { - info->m_lowerLimit[srow] = -SIMD_INFINITY; - info->m_upperLimit[srow] = 0; - } - // deal with bounce - if (limot->m_bounce > 0) - { - // calculate joint velocity - btScalar vel; - if (rotational) - { - vel = angVelA.dot(ax1); -//make sure that if no body -> angVelB == zero vec -// if (body1) - vel -= angVelB.dot(ax1); - } - else - { - vel = linVelA.dot(ax1); -//make sure that if no body -> angVelB == zero vec -// if (body1) - vel -= linVelB.dot(ax1); - } - // only apply bounce if the velocity is incoming, and if the - // resulting c[] exceeds what we already have. - if (limit == 1) - { - if (vel < 0) - { - btScalar newc = -limot->m_bounce* vel; - if (newc > info->m_constraintError[srow]) - info->m_constraintError[srow] = newc; - } - } - else - { - if (vel > 0) - { - btScalar newc = -limot->m_bounce * vel; - if (newc < info->m_constraintError[srow]) - info->m_constraintError[srow] = newc; - } - } - } - } - } - return 1; - } - else return 0; -} - diff --git a/bullet/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h b/bullet/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h deleted file mode 100644 index 7c4e6e378..000000000 --- a/bullet/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h +++ /dev/null @@ -1,504 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -/// 2009 March: btGeneric6DofConstraint refactored by Roman Ponomarev -/// Added support for generic constraint solver through getInfo1/getInfo2 methods - -/* -2007-09-09 -btGeneric6DofConstraint Refactored by Francisco Le?n -email: projectileman@yahoo.com -http://gimpact.sf.net -*/ - - -#ifndef GENERIC_6DOF_CONSTRAINT_H -#define GENERIC_6DOF_CONSTRAINT_H - -#include "LinearMath/btVector3.h" -#include "btJacobianEntry.h" -#include "btTypedConstraint.h" - -class btRigidBody; - - - - -//! Rotation Limit structure for generic joints -class btRotationalLimitMotor -{ -public: - //! limit_parameters - //!@{ - btScalar m_loLimit;//!< joint limit - btScalar m_hiLimit;//!< joint limit - btScalar m_targetVelocity;//!< target motor velocity - btScalar m_maxMotorForce;//!< max force on motor - btScalar m_maxLimitForce;//!< max force on limit - btScalar m_damping;//!< Damping. - btScalar m_limitSoftness;//! Relaxation factor - btScalar m_ERP;//!< Error tolerance factor when joint is at limit - btScalar m_bounce;//!< restitution factor - bool m_enableMotor; - - //!@} - - //! temp_variables - //!@{ - btScalar m_currentLimitError;//! How much is violated this limit - btScalar m_currentPosition; //! current value of angle - int m_currentLimit;//!< 0=free, 1=at lo limit, 2=at hi limit - btScalar m_accumulatedImpulse; - //!@} - - btRotationalLimitMotor() - { - m_accumulatedImpulse = 0.f; - m_targetVelocity = 0; - m_maxMotorForce = 0.1f; - m_maxLimitForce = 300.0f; - m_loLimit = 1.0f; - m_hiLimit = -1.0f; - m_ERP = 0.5f; - m_bounce = 0.0f; - m_damping = 1.0f; - m_limitSoftness = 0.5f; - m_currentLimit = 0; - m_currentLimitError = 0; - m_enableMotor = false; - } - - btRotationalLimitMotor(const btRotationalLimitMotor & limot) - { - m_targetVelocity = limot.m_targetVelocity; - m_maxMotorForce = limot.m_maxMotorForce; - m_limitSoftness = limot.m_limitSoftness; - m_loLimit = limot.m_loLimit; - m_hiLimit = limot.m_hiLimit; - m_ERP = limot.m_ERP; - m_bounce = limot.m_bounce; - m_currentLimit = limot.m_currentLimit; - m_currentLimitError = limot.m_currentLimitError; - m_enableMotor = limot.m_enableMotor; - } - - - - //! Is limited - bool isLimited() - { - if(m_loLimit > m_hiLimit) return false; - return true; - } - - //! Need apply correction - bool needApplyTorques() - { - if(m_currentLimit == 0 && m_enableMotor == false) return false; - return true; - } - - //! calculates error - /*! - calculates m_currentLimit and m_currentLimitError. - */ - int testLimitValue(btScalar test_value); - - //! apply the correction impulses for two bodies - btScalar solveAngularLimits(btScalar timeStep,btVector3& axis, btScalar jacDiagABInv,btRigidBody * body0, btSolverBody& bodyA,btRigidBody * body1,btSolverBody& bodyB); - -}; - - - -class btTranslationalLimitMotor -{ -public: - btVector3 m_lowerLimit;//!< the constraint lower limits - btVector3 m_upperLimit;//!< the constraint upper limits - btVector3 m_accumulatedImpulse; - //! Linear_Limit_parameters - //!@{ - btScalar m_limitSoftness;//!< Softness for linear limit - btScalar m_damping;//!< Damping for linear limit - btScalar m_restitution;//! Bounce parameter for linear limit - //!@} - bool m_enableMotor[3]; - btVector3 m_targetVelocity;//!< target motor velocity - btVector3 m_maxMotorForce;//!< max force on motor - btVector3 m_currentLimitError;//! How much is violated this limit - btVector3 m_currentLinearDiff;//! Current relative offset of constraint frames - int m_currentLimit[3];//!< 0=free, 1=at lower limit, 2=at upper limit - - btTranslationalLimitMotor() - { - m_lowerLimit.setValue(0.f,0.f,0.f); - m_upperLimit.setValue(0.f,0.f,0.f); - m_accumulatedImpulse.setValue(0.f,0.f,0.f); - - m_limitSoftness = 0.7f; - m_damping = btScalar(1.0f); - m_restitution = btScalar(0.5f); - for(int i=0; i < 3; i++) - { - m_enableMotor[i] = false; - m_targetVelocity[i] = btScalar(0.f); - m_maxMotorForce[i] = btScalar(0.f); - } - } - - btTranslationalLimitMotor(const btTranslationalLimitMotor & other ) - { - m_lowerLimit = other.m_lowerLimit; - m_upperLimit = other.m_upperLimit; - m_accumulatedImpulse = other.m_accumulatedImpulse; - - m_limitSoftness = other.m_limitSoftness ; - m_damping = other.m_damping; - m_restitution = other.m_restitution; - for(int i=0; i < 3; i++) - { - m_enableMotor[i] = other.m_enableMotor[i]; - m_targetVelocity[i] = other.m_targetVelocity[i]; - m_maxMotorForce[i] = other.m_maxMotorForce[i]; - } - } - - //! Test limit - /*! - - free means upper < lower, - - locked means upper == lower - - limited means upper > lower - - limitIndex: first 3 are linear, next 3 are angular - */ - inline bool isLimited(int limitIndex) - { - return (m_upperLimit[limitIndex] >= m_lowerLimit[limitIndex]); - } - inline bool needApplyForce(int limitIndex) - { - if(m_currentLimit[limitIndex] == 0 && m_enableMotor[limitIndex] == false) return false; - return true; - } - int testLimitValue(int limitIndex, btScalar test_value); - - - btScalar solveLinearAxis( - btScalar timeStep, - btScalar jacDiagABInv, - btRigidBody& body1,btSolverBody& bodyA,const btVector3 &pointInA, - btRigidBody& body2,btSolverBody& bodyB,const btVector3 &pointInB, - int limit_index, - const btVector3 & axis_normal_on_a, - const btVector3 & anchorPos); - - -}; - -/// btGeneric6DofConstraint between two rigidbodies each with a pivotpoint that descibes the axis location in local space -/*! -btGeneric6DofConstraint can leave any of the 6 degree of freedom 'free' or 'locked'. -currently this limit supports rotational motors
    -
      -
    • For Linear limits, use btGeneric6DofConstraint.setLinearUpperLimit, btGeneric6DofConstraint.setLinearLowerLimit. You can set the parameters with the btTranslationalLimitMotor structure accsesible through the btGeneric6DofConstraint.getTranslationalLimitMotor method. -At this moment translational motors are not supported. May be in the future.
    • - -
    • For Angular limits, use the btRotationalLimitMotor structure for configuring the limit. -This is accessible through btGeneric6DofConstraint.getLimitMotor method, -This brings support for limit parameters and motors.
    • - -
    • Angulars limits have these possible ranges: - - - - - - - - - - - - - - - - - - -
      AXISMIN ANGLEMAX ANGLE
      X-PIPI
      Y-PI/2PI/2
      Z-PIPI
      -
    • -
    - -*/ -class btGeneric6DofConstraint : public btTypedConstraint -{ -protected: - - //! relative_frames - //!@{ - btTransform m_frameInA;//!< the constraint space w.r.t body A - btTransform m_frameInB;//!< the constraint space w.r.t body B - //!@} - - //! Jacobians - //!@{ - btJacobianEntry m_jacLinear[3];//!< 3 orthogonal linear constraints - btJacobianEntry m_jacAng[3];//!< 3 orthogonal angular constraints - //!@} - - //! Linear_Limit_parameters - //!@{ - btTranslationalLimitMotor m_linearLimits; - //!@} - - - //! hinge_parameters - //!@{ - btRotationalLimitMotor m_angularLimits[3]; - //!@} - - -protected: - //! temporal variables - //!@{ - btScalar m_timeStep; - btTransform m_calculatedTransformA; - btTransform m_calculatedTransformB; - btVector3 m_calculatedAxisAngleDiff; - btVector3 m_calculatedAxis[3]; - btVector3 m_calculatedLinearDiff; - btScalar m_factA; - btScalar m_factB; - bool m_hasStaticBody; - - btVector3 m_AnchorPos; // point betwen pivots of bodies A and B to solve linear axes - - bool m_useLinearReferenceFrameA; - bool m_useOffsetForConstraintFrame; - - //!@} - - btGeneric6DofConstraint& operator=(btGeneric6DofConstraint& other) - { - btAssert(0); - (void) other; - return *this; - } - - - int setAngularLimits(btConstraintInfo2 *info, int row_offset,const btTransform& transA,const btTransform& transB,const btVector3& linVelA,const btVector3& linVelB,const btVector3& angVelA,const btVector3& angVelB); - - int setLinearLimits(btConstraintInfo2 *info, int row, const btTransform& transA,const btTransform& transB,const btVector3& linVelA,const btVector3& linVelB,const btVector3& angVelA,const btVector3& angVelB); - - void buildLinearJacobian( - btJacobianEntry & jacLinear,const btVector3 & normalWorld, - const btVector3 & pivotAInW,const btVector3 & pivotBInW); - - void buildAngularJacobian(btJacobianEntry & jacAngular,const btVector3 & jointAxisW); - - // tests linear limits - void calculateLinearInfo(); - - //! calcs the euler angles between the two bodies. - void calculateAngleInfo(); - - - -public: - - ///for backwards compatibility during the transition to 'getInfo/getInfo2' - bool m_useSolveConstraintObsolete; - - btGeneric6DofConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB ,bool useLinearReferenceFrameA); - - btGeneric6DofConstraint(); - - //! Calcs global transform of the offsets - /*! - Calcs the global transform for the joint offset for body A an B, and also calcs the agle differences between the bodies. - \sa btGeneric6DofConstraint.getCalculatedTransformA , btGeneric6DofConstraint.getCalculatedTransformB, btGeneric6DofConstraint.calculateAngleInfo - */ - void calculateTransforms(const btTransform& transA,const btTransform& transB); - - void calculateTransforms(); - - //! Gets the global transform of the offset for body A - /*! - \sa btGeneric6DofConstraint.getFrameOffsetA, btGeneric6DofConstraint.getFrameOffsetB, btGeneric6DofConstraint.calculateAngleInfo. - */ - const btTransform & getCalculatedTransformA() const - { - return m_calculatedTransformA; - } - - //! Gets the global transform of the offset for body B - /*! - \sa btGeneric6DofConstraint.getFrameOffsetA, btGeneric6DofConstraint.getFrameOffsetB, btGeneric6DofConstraint.calculateAngleInfo. - */ - const btTransform & getCalculatedTransformB() const - { - return m_calculatedTransformB; - } - - const btTransform & getFrameOffsetA() const - { - return m_frameInA; - } - - const btTransform & getFrameOffsetB() const - { - return m_frameInB; - } - - - btTransform & getFrameOffsetA() - { - return m_frameInA; - } - - btTransform & getFrameOffsetB() - { - return m_frameInB; - } - - - //! performs Jacobian calculation, and also calculates angle differences and axis - virtual void buildJacobian(); - - virtual void getInfo1 (btConstraintInfo1* info); - - void getInfo1NonVirtual (btConstraintInfo1* info); - - virtual void getInfo2 (btConstraintInfo2* info); - - void getInfo2NonVirtual (btConstraintInfo2* info,const btTransform& transA,const btTransform& transB,const btVector3& linVelA,const btVector3& linVelB,const btVector3& angVelA,const btVector3& angVelB); - - - virtual void solveConstraintObsolete(btSolverBody& bodyA,btSolverBody& bodyB,btScalar timeStep); - - void updateRHS(btScalar timeStep); - - //! Get the rotation axis in global coordinates - /*! - \pre btGeneric6DofConstraint.buildJacobian must be called previously. - */ - btVector3 getAxis(int axis_index) const; - - //! Get the relative Euler angle - /*! - \pre btGeneric6DofConstraint::calculateTransforms() must be called previously. - */ - btScalar getAngle(int axis_index) const; - - //! Get the relative position of the constraint pivot - /*! - \pre btGeneric6DofConstraint::calculateTransforms() must be called previously. - */ - btScalar getRelativePivotPosition(int axis_index) const; - - - //! Test angular limit. - /*! - Calculates angular correction and returns true if limit needs to be corrected. - \pre btGeneric6DofConstraint::calculateTransforms() must be called previously. - */ - bool testAngularLimitMotor(int axis_index); - - void setLinearLowerLimit(const btVector3& linearLower) - { - m_linearLimits.m_lowerLimit = linearLower; - } - - void setLinearUpperLimit(const btVector3& linearUpper) - { - m_linearLimits.m_upperLimit = linearUpper; - } - - void setAngularLowerLimit(const btVector3& angularLower) - { - for(int i = 0; i < 3; i++) - m_angularLimits[i].m_loLimit = btNormalizeAngle(angularLower[i]); - } - - void setAngularUpperLimit(const btVector3& angularUpper) - { - for(int i = 0; i < 3; i++) - m_angularLimits[i].m_hiLimit = btNormalizeAngle(angularUpper[i]); - } - - //! Retrieves the angular limit informacion - btRotationalLimitMotor * getRotationalLimitMotor(int index) - { - return &m_angularLimits[index]; - } - - //! Retrieves the limit informacion - btTranslationalLimitMotor * getTranslationalLimitMotor() - { - return &m_linearLimits; - } - - //first 3 are linear, next 3 are angular - void setLimit(int axis, btScalar lo, btScalar hi) - { - if(axis<3) - { - m_linearLimits.m_lowerLimit[axis] = lo; - m_linearLimits.m_upperLimit[axis] = hi; - } - else - { - lo = btNormalizeAngle(lo); - hi = btNormalizeAngle(hi); - m_angularLimits[axis-3].m_loLimit = lo; - m_angularLimits[axis-3].m_hiLimit = hi; - } - } - - //! Test limit - /*! - - free means upper < lower, - - locked means upper == lower - - limited means upper > lower - - limitIndex: first 3 are linear, next 3 are angular - */ - bool isLimited(int limitIndex) - { - if(limitIndex<3) - { - return m_linearLimits.isLimited(limitIndex); - - } - return m_angularLimits[limitIndex-3].isLimited(); - } - - virtual void calcAnchorPos(void); // overridable - - int get_limit_motor_info2( btRotationalLimitMotor * limot, - const btTransform& transA,const btTransform& transB,const btVector3& linVelA,const btVector3& linVelB,const btVector3& angVelA,const btVector3& angVelB, - btConstraintInfo2 *info, int row, btVector3& ax1, int rotational); - - int get_limit_motor_info2UsingFrameOffset( btRotationalLimitMotor * limot, - const btTransform& transA,const btTransform& transB,const btVector3& linVelA,const btVector3& linVelB,const btVector3& angVelA,const btVector3& angVelB, - btConstraintInfo2 *info, int row, btVector3& ax1, int rotational, int rotAllowed); - - // access for UseFrameOffset - bool getUseFrameOffset() { return m_useOffsetForConstraintFrame; } - void setUseFrameOffset(bool frameOffsetOnOff) { m_useOffsetForConstraintFrame = frameOffsetOnOff; } -}; - - -#endif //GENERIC_6DOF_CONSTRAINT_H diff --git a/bullet/src/BulletDynamics/ConstraintSolver/btGeneric6DofSpringConstraint.cpp b/bullet/src/BulletDynamics/ConstraintSolver/btGeneric6DofSpringConstraint.cpp deleted file mode 100644 index 3dad5c2ec..000000000 --- a/bullet/src/BulletDynamics/ConstraintSolver/btGeneric6DofSpringConstraint.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library, http://bulletphysics.org -Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btGeneric6DofSpringConstraint.h" -#include "BulletDynamics/Dynamics/btRigidBody.h" -#include "LinearMath/btTransformUtil.h" - - -btGeneric6DofSpringConstraint::btGeneric6DofSpringConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB ,bool useLinearReferenceFrameA) - : btGeneric6DofConstraint(rbA, rbB, frameInA, frameInB, useLinearReferenceFrameA) -{ - for(int i = 0; i < 6; i++) - { - m_springEnabled[i] = false; - m_equilibriumPoint[i] = btScalar(0.f); - m_springStiffness[i] = btScalar(0.f); - m_springDamping[i] = btScalar(1.f); - } -} - - -void btGeneric6DofSpringConstraint::enableSpring(int index, bool onOff) -{ - btAssert((index >= 0) && (index < 6)); - m_springEnabled[index] = onOff; - if(index < 3) - { - m_linearLimits.m_enableMotor[index] = onOff; - } - else - { - m_angularLimits[index - 3].m_enableMotor = onOff; - } -} - - - -void btGeneric6DofSpringConstraint::setStiffness(int index, btScalar stiffness) -{ - btAssert((index >= 0) && (index < 6)); - m_springStiffness[index] = stiffness; -} - - -void btGeneric6DofSpringConstraint::setDamping(int index, btScalar damping) -{ - btAssert((index >= 0) && (index < 6)); - m_springDamping[index] = damping; -} - - -void btGeneric6DofSpringConstraint::setEquilibriumPoint() -{ - calculateTransforms(); - for(int i = 0; i < 3; i++) - { - m_equilibriumPoint[i] = m_calculatedLinearDiff[i]; - } - for(int i = 0; i < 3; i++) - { - m_equilibriumPoint[i + 3] = m_calculatedAxisAngleDiff[i]; - } -} - - - -void btGeneric6DofSpringConstraint::setEquilibriumPoint(int index) -{ - btAssert((index >= 0) && (index < 6)); - calculateTransforms(); - if(index < 3) - { - m_equilibriumPoint[index] = m_calculatedLinearDiff[index]; - } - else - { - m_equilibriumPoint[index] = m_calculatedAxisAngleDiff[index - 3]; - } -} - - - -void btGeneric6DofSpringConstraint::internalUpdateSprings(btConstraintInfo2* info) -{ - // it is assumed that calculateTransforms() have been called before this call - int i; - btVector3 relVel = m_rbB.getLinearVelocity() - m_rbA.getLinearVelocity(); - for(i = 0; i < 3; i++) - { - if(m_springEnabled[i]) - { - // get current position of constraint - btScalar currPos = m_calculatedLinearDiff[i]; - // calculate difference - btScalar delta = currPos - m_equilibriumPoint[i]; - // spring force is (delta * m_stiffness) according to Hooke's Law - btScalar force = delta * m_springStiffness[i]; - btScalar velFactor = info->fps * m_springDamping[i] / btScalar(info->m_numIterations); - m_linearLimits.m_targetVelocity[i] = velFactor * force; - m_linearLimits.m_maxMotorForce[i] = btFabs(force) / info->fps; - } - } - for(i = 0; i < 3; i++) - { - if(m_springEnabled[i + 3]) - { - // get current position of constraint - btScalar currPos = m_calculatedAxisAngleDiff[i]; - // calculate difference - btScalar delta = currPos - m_equilibriumPoint[i+3]; - // spring force is (-delta * m_stiffness) according to Hooke's Law - btScalar force = -delta * m_springStiffness[i+3]; - btScalar velFactor = info->fps * m_springDamping[i+3] / btScalar(info->m_numIterations); - m_angularLimits[i].m_targetVelocity = velFactor * force; - m_angularLimits[i].m_maxMotorForce = btFabs(force) / info->fps; - } - } -} - - -void btGeneric6DofSpringConstraint::getInfo2(btConstraintInfo2* info) -{ - // this will be called by constraint solver at the constraint setup stage - // set current motor parameters - internalUpdateSprings(info); - // do the rest of job for constraint setup - btGeneric6DofConstraint::getInfo2(info); -} - - - - diff --git a/bullet/src/BulletDynamics/ConstraintSolver/btGeneric6DofSpringConstraint.h b/bullet/src/BulletDynamics/ConstraintSolver/btGeneric6DofSpringConstraint.h deleted file mode 100644 index b084c7e8d..000000000 --- a/bullet/src/BulletDynamics/ConstraintSolver/btGeneric6DofSpringConstraint.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library, http://bulletphysics.org -Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef GENERIC_6DOF_SPRING_CONSTRAINT_H -#define GENERIC_6DOF_SPRING_CONSTRAINT_H - - -#include "LinearMath/btVector3.h" -#include "btTypedConstraint.h" -#include "btGeneric6DofConstraint.h" - - -/// Generic 6 DOF constraint that allows to set spring motors to any translational and rotational DOF - -/// DOF index used in enableSpring() and setStiffness() means: -/// 0 : translation X -/// 1 : translation Y -/// 2 : translation Z -/// 3 : rotation X (3rd Euler rotational around new position of X axis, range [-PI+epsilon, PI-epsilon] ) -/// 4 : rotation Y (2nd Euler rotational around new position of Y axis, range [-PI/2+epsilon, PI/2-epsilon] ) -/// 5 : rotation Z (1st Euler rotational around Z axis, range [-PI+epsilon, PI-epsilon] ) - -class btGeneric6DofSpringConstraint : public btGeneric6DofConstraint -{ -protected: - bool m_springEnabled[6]; - btScalar m_equilibriumPoint[6]; - btScalar m_springStiffness[6]; - btScalar m_springDamping[6]; // between 0 and 1 (1 == no damping) - void internalUpdateSprings(btConstraintInfo2* info); -public: - btGeneric6DofSpringConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB ,bool useLinearReferenceFrameA); - void enableSpring(int index, bool onOff); - void setStiffness(int index, btScalar stiffness); - void setDamping(int index, btScalar damping); - void setEquilibriumPoint(); // set the current constraint position/orientation as an equilibrium point for all DOF - void setEquilibriumPoint(int index); // set the current constraint position/orientation as an equilibrium point for given DOF - virtual void getInfo2 (btConstraintInfo2* info); -}; - -#endif // GENERIC_6DOF_SPRING_CONSTRAINT_H - diff --git a/bullet/src/BulletDynamics/ConstraintSolver/btHinge2Constraint.cpp b/bullet/src/BulletDynamics/ConstraintSolver/btHinge2Constraint.cpp deleted file mode 100644 index 4d9244134..000000000 --- a/bullet/src/BulletDynamics/ConstraintSolver/btHinge2Constraint.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library, http://bulletphysics.org -Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - - -#include "btHinge2Constraint.h" -#include "BulletDynamics/Dynamics/btRigidBody.h" -#include "LinearMath/btTransformUtil.h" - - - -// constructor -// anchor, axis1 and axis2 are in world coordinate system -// axis1 must be orthogonal to axis2 -btHinge2Constraint::btHinge2Constraint(btRigidBody& rbA, btRigidBody& rbB, btVector3& anchor, btVector3& axis1, btVector3& axis2) -: btGeneric6DofSpringConstraint(rbA, rbB, btTransform::getIdentity(), btTransform::getIdentity(), true), - m_anchor(anchor), - m_axis1(axis1), - m_axis2(axis2) -{ - // build frame basis - // 6DOF constraint uses Euler angles and to define limits - // it is assumed that rotational order is : - // Z - first, allowed limits are (-PI,PI); - // new position of Y - second (allowed limits are (-PI/2 + epsilon, PI/2 - epsilon), where epsilon is a small positive number - // used to prevent constraint from instability on poles; - // new position of X, allowed limits are (-PI,PI); - // So to simulate ODE Universal joint we should use parent axis as Z, child axis as Y and limit all other DOFs - // Build the frame in world coordinate system first - btVector3 zAxis = axis1.normalize(); - btVector3 xAxis = axis2.normalize(); - btVector3 yAxis = zAxis.cross(xAxis); // we want right coordinate system - btTransform frameInW; - frameInW.setIdentity(); - frameInW.getBasis().setValue( xAxis[0], yAxis[0], zAxis[0], - xAxis[1], yAxis[1], zAxis[1], - xAxis[2], yAxis[2], zAxis[2]); - frameInW.setOrigin(anchor); - // now get constraint frame in local coordinate systems - m_frameInA = rbA.getCenterOfMassTransform().inverse() * frameInW; - m_frameInB = rbB.getCenterOfMassTransform().inverse() * frameInW; - // sei limits - setLinearLowerLimit(btVector3(0.f, 0.f, -1.f)); - setLinearUpperLimit(btVector3(0.f, 0.f, 1.f)); - // like front wheels of a car - setAngularLowerLimit(btVector3(1.f, 0.f, -SIMD_HALF_PI * 0.5f)); - setAngularUpperLimit(btVector3(-1.f, 0.f, SIMD_HALF_PI * 0.5f)); - // enable suspension - enableSpring(2, true); - setStiffness(2, SIMD_PI * SIMD_PI * 4.f); // period 1 sec for 1 kilogramm weel :-) - setDamping(2, 0.01f); - setEquilibriumPoint(); -} - diff --git a/bullet/src/BulletDynamics/ConstraintSolver/btHinge2Constraint.h b/bullet/src/BulletDynamics/ConstraintSolver/btHinge2Constraint.h deleted file mode 100644 index b589687d7..000000000 --- a/bullet/src/BulletDynamics/ConstraintSolver/btHinge2Constraint.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library, http://bulletphysics.org -Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef HINGE2_CONSTRAINT_H -#define HINGE2_CONSTRAINT_H - - - -#include "LinearMath/btVector3.h" -#include "btTypedConstraint.h" -#include "btGeneric6DofSpringConstraint.h" - - - -// Constraint similar to ODE Hinge2 Joint -// has 3 degrees of frredom: -// 2 rotational degrees of freedom, similar to Euler rotations around Z (axis 1) and X (axis 2) -// 1 translational (along axis Z) with suspension spring - -class btHinge2Constraint : public btGeneric6DofSpringConstraint -{ -protected: - btVector3 m_anchor; - btVector3 m_axis1; - btVector3 m_axis2; -public: - // constructor - // anchor, axis1 and axis2 are in world coordinate system - // axis1 must be orthogonal to axis2 - btHinge2Constraint(btRigidBody& rbA, btRigidBody& rbB, btVector3& anchor, btVector3& axis1, btVector3& axis2); - // access - const btVector3& getAnchor() { return m_calculatedTransformA.getOrigin(); } - const btVector3& getAnchor2() { return m_calculatedTransformB.getOrigin(); } - const btVector3& getAxis1() { return m_axis1; } - const btVector3& getAxis2() { return m_axis2; } - btScalar getAngle1() { return getAngle(2); } - btScalar getAngle2() { return getAngle(0); } - // limits - void setUpperLimit(btScalar ang1max) { setAngularUpperLimit(btVector3(-1.f, 0.f, ang1max)); } - void setLowerLimit(btScalar ang1min) { setAngularLowerLimit(btVector3( 1.f, 0.f, ang1min)); } -}; - - - -#endif // HINGE2_CONSTRAINT_H - diff --git a/bullet/src/BulletDynamics/ConstraintSolver/btHingeConstraint.cpp b/bullet/src/BulletDynamics/ConstraintSolver/btHingeConstraint.cpp deleted file mode 100644 index 643fea35b..000000000 --- a/bullet/src/BulletDynamics/ConstraintSolver/btHingeConstraint.cpp +++ /dev/null @@ -1,1077 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#include "btHingeConstraint.h" -#include "BulletDynamics/Dynamics/btRigidBody.h" -#include "LinearMath/btTransformUtil.h" -#include "LinearMath/btMinMax.h" -#include -#include "btSolverBody.h" - - - -//#define HINGE_USE_OBSOLETE_SOLVER false -#define HINGE_USE_OBSOLETE_SOLVER false - -#define HINGE_USE_FRAME_OFFSET true - -#ifndef __SPU__ - -btHingeConstraint::btHingeConstraint() -: btTypedConstraint (HINGE_CONSTRAINT_TYPE), -m_enableAngularMotor(false), -m_useSolveConstraintObsolete(HINGE_USE_OBSOLETE_SOLVER), -m_useOffsetForConstraintFrame(HINGE_USE_FRAME_OFFSET), -m_useReferenceFrameA(false) -{ - m_referenceSign = m_useReferenceFrameA ? btScalar(-1.f) : btScalar(1.f); -} - - - -btHingeConstraint::btHingeConstraint(btRigidBody& rbA,btRigidBody& rbB, const btVector3& pivotInA,const btVector3& pivotInB, - btVector3& axisInA,btVector3& axisInB, bool useReferenceFrameA) - :btTypedConstraint(HINGE_CONSTRAINT_TYPE, rbA,rbB), - m_angularOnly(false), - m_enableAngularMotor(false), - m_useSolveConstraintObsolete(HINGE_USE_OBSOLETE_SOLVER), - m_useOffsetForConstraintFrame(HINGE_USE_FRAME_OFFSET), - m_useReferenceFrameA(useReferenceFrameA) -{ - m_rbAFrame.getOrigin() = pivotInA; - - // since no frame is given, assume this to be zero angle and just pick rb transform axis - btVector3 rbAxisA1 = rbA.getCenterOfMassTransform().getBasis().getColumn(0); - - btVector3 rbAxisA2; - btScalar projection = axisInA.dot(rbAxisA1); - if (projection >= 1.0f - SIMD_EPSILON) { - rbAxisA1 = -rbA.getCenterOfMassTransform().getBasis().getColumn(2); - rbAxisA2 = rbA.getCenterOfMassTransform().getBasis().getColumn(1); - } else if (projection <= -1.0f + SIMD_EPSILON) { - rbAxisA1 = rbA.getCenterOfMassTransform().getBasis().getColumn(2); - rbAxisA2 = rbA.getCenterOfMassTransform().getBasis().getColumn(1); - } else { - rbAxisA2 = axisInA.cross(rbAxisA1); - rbAxisA1 = rbAxisA2.cross(axisInA); - } - - m_rbAFrame.getBasis().setValue( rbAxisA1.getX(),rbAxisA2.getX(),axisInA.getX(), - rbAxisA1.getY(),rbAxisA2.getY(),axisInA.getY(), - rbAxisA1.getZ(),rbAxisA2.getZ(),axisInA.getZ() ); - - btQuaternion rotationArc = shortestArcQuat(axisInA,axisInB); - btVector3 rbAxisB1 = quatRotate(rotationArc,rbAxisA1); - btVector3 rbAxisB2 = axisInB.cross(rbAxisB1); - - m_rbBFrame.getOrigin() = pivotInB; - m_rbBFrame.getBasis().setValue( rbAxisB1.getX(),rbAxisB2.getX(),axisInB.getX(), - rbAxisB1.getY(),rbAxisB2.getY(),axisInB.getY(), - rbAxisB1.getZ(),rbAxisB2.getZ(),axisInB.getZ() ); - - //start with free - m_lowerLimit = btScalar(1.0f); - m_upperLimit = btScalar(-1.0f); - m_biasFactor = 0.3f; - m_relaxationFactor = 1.0f; - m_limitSoftness = 0.9f; - m_solveLimit = false; - m_referenceSign = m_useReferenceFrameA ? btScalar(-1.f) : btScalar(1.f); -} - - - -btHingeConstraint::btHingeConstraint(btRigidBody& rbA,const btVector3& pivotInA,btVector3& axisInA, bool useReferenceFrameA) -:btTypedConstraint(HINGE_CONSTRAINT_TYPE, rbA), m_angularOnly(false), m_enableAngularMotor(false), -m_useSolveConstraintObsolete(HINGE_USE_OBSOLETE_SOLVER), -m_useOffsetForConstraintFrame(HINGE_USE_FRAME_OFFSET), -m_useReferenceFrameA(useReferenceFrameA) -{ - - // since no frame is given, assume this to be zero angle and just pick rb transform axis - // fixed axis in worldspace - btVector3 rbAxisA1, rbAxisA2; - btPlaneSpace1(axisInA, rbAxisA1, rbAxisA2); - - m_rbAFrame.getOrigin() = pivotInA; - m_rbAFrame.getBasis().setValue( rbAxisA1.getX(),rbAxisA2.getX(),axisInA.getX(), - rbAxisA1.getY(),rbAxisA2.getY(),axisInA.getY(), - rbAxisA1.getZ(),rbAxisA2.getZ(),axisInA.getZ() ); - - btVector3 axisInB = rbA.getCenterOfMassTransform().getBasis() * axisInA; - - btQuaternion rotationArc = shortestArcQuat(axisInA,axisInB); - btVector3 rbAxisB1 = quatRotate(rotationArc,rbAxisA1); - btVector3 rbAxisB2 = axisInB.cross(rbAxisB1); - - - m_rbBFrame.getOrigin() = rbA.getCenterOfMassTransform()(pivotInA); - m_rbBFrame.getBasis().setValue( rbAxisB1.getX(),rbAxisB2.getX(),axisInB.getX(), - rbAxisB1.getY(),rbAxisB2.getY(),axisInB.getY(), - rbAxisB1.getZ(),rbAxisB2.getZ(),axisInB.getZ() ); - - //start with free - m_lowerLimit = btScalar(1.0f); - m_upperLimit = btScalar(-1.0f); - m_biasFactor = 0.3f; - m_relaxationFactor = 1.0f; - m_limitSoftness = 0.9f; - m_solveLimit = false; - m_referenceSign = m_useReferenceFrameA ? btScalar(-1.f) : btScalar(1.f); -} - - - -btHingeConstraint::btHingeConstraint(btRigidBody& rbA,btRigidBody& rbB, - const btTransform& rbAFrame, const btTransform& rbBFrame, bool useReferenceFrameA) -:btTypedConstraint(HINGE_CONSTRAINT_TYPE, rbA,rbB),m_rbAFrame(rbAFrame),m_rbBFrame(rbBFrame), -m_angularOnly(false), -m_enableAngularMotor(false), -m_useSolveConstraintObsolete(HINGE_USE_OBSOLETE_SOLVER), -m_useOffsetForConstraintFrame(HINGE_USE_FRAME_OFFSET), -m_useReferenceFrameA(useReferenceFrameA) -{ - //start with free - m_lowerLimit = btScalar(1.0f); - m_upperLimit = btScalar(-1.0f); - m_biasFactor = 0.3f; - m_relaxationFactor = 1.0f; - m_limitSoftness = 0.9f; - m_solveLimit = false; - m_referenceSign = m_useReferenceFrameA ? btScalar(-1.f) : btScalar(1.f); -} - - - -btHingeConstraint::btHingeConstraint(btRigidBody& rbA, const btTransform& rbAFrame, bool useReferenceFrameA) -:btTypedConstraint(HINGE_CONSTRAINT_TYPE, rbA),m_rbAFrame(rbAFrame),m_rbBFrame(rbAFrame), -m_angularOnly(false), -m_enableAngularMotor(false), -m_useSolveConstraintObsolete(HINGE_USE_OBSOLETE_SOLVER), -m_useOffsetForConstraintFrame(HINGE_USE_FRAME_OFFSET), -m_useReferenceFrameA(useReferenceFrameA) -{ - ///not providing rigidbody B means implicitly using worldspace for body B - - m_rbBFrame.getOrigin() = m_rbA.getCenterOfMassTransform()(m_rbAFrame.getOrigin()); - - //start with free - m_lowerLimit = btScalar(1.0f); - m_upperLimit = btScalar(-1.0f); - m_biasFactor = 0.3f; - m_relaxationFactor = 1.0f; - m_limitSoftness = 0.9f; - m_solveLimit = false; - m_referenceSign = m_useReferenceFrameA ? btScalar(-1.f) : btScalar(1.f); -} - - - -void btHingeConstraint::buildJacobian() -{ - if (m_useSolveConstraintObsolete) - { - m_appliedImpulse = btScalar(0.); - m_accMotorImpulse = btScalar(0.); - - if (!m_angularOnly) - { - btVector3 pivotAInW = m_rbA.getCenterOfMassTransform()*m_rbAFrame.getOrigin(); - btVector3 pivotBInW = m_rbB.getCenterOfMassTransform()*m_rbBFrame.getOrigin(); - btVector3 relPos = pivotBInW - pivotAInW; - - btVector3 normal[3]; - if (relPos.length2() > SIMD_EPSILON) - { - normal[0] = relPos.normalized(); - } - else - { - normal[0].setValue(btScalar(1.0),0,0); - } - - btPlaneSpace1(normal[0], normal[1], normal[2]); - - for (int i=0;i<3;i++) - { - new (&m_jac[i]) btJacobianEntry( - m_rbA.getCenterOfMassTransform().getBasis().transpose(), - m_rbB.getCenterOfMassTransform().getBasis().transpose(), - pivotAInW - m_rbA.getCenterOfMassPosition(), - pivotBInW - m_rbB.getCenterOfMassPosition(), - normal[i], - m_rbA.getInvInertiaDiagLocal(), - m_rbA.getInvMass(), - m_rbB.getInvInertiaDiagLocal(), - m_rbB.getInvMass()); - } - } - - //calculate two perpendicular jointAxis, orthogonal to hingeAxis - //these two jointAxis require equal angular velocities for both bodies - - //this is unused for now, it's a todo - btVector3 jointAxis0local; - btVector3 jointAxis1local; - - btPlaneSpace1(m_rbAFrame.getBasis().getColumn(2),jointAxis0local,jointAxis1local); - - btVector3 jointAxis0 = getRigidBodyA().getCenterOfMassTransform().getBasis() * jointAxis0local; - btVector3 jointAxis1 = getRigidBodyA().getCenterOfMassTransform().getBasis() * jointAxis1local; - btVector3 hingeAxisWorld = getRigidBodyA().getCenterOfMassTransform().getBasis() * m_rbAFrame.getBasis().getColumn(2); - - new (&m_jacAng[0]) btJacobianEntry(jointAxis0, - m_rbA.getCenterOfMassTransform().getBasis().transpose(), - m_rbB.getCenterOfMassTransform().getBasis().transpose(), - m_rbA.getInvInertiaDiagLocal(), - m_rbB.getInvInertiaDiagLocal()); - - new (&m_jacAng[1]) btJacobianEntry(jointAxis1, - m_rbA.getCenterOfMassTransform().getBasis().transpose(), - m_rbB.getCenterOfMassTransform().getBasis().transpose(), - m_rbA.getInvInertiaDiagLocal(), - m_rbB.getInvInertiaDiagLocal()); - - new (&m_jacAng[2]) btJacobianEntry(hingeAxisWorld, - m_rbA.getCenterOfMassTransform().getBasis().transpose(), - m_rbB.getCenterOfMassTransform().getBasis().transpose(), - m_rbA.getInvInertiaDiagLocal(), - m_rbB.getInvInertiaDiagLocal()); - - // clear accumulator - m_accLimitImpulse = btScalar(0.); - - // test angular limit - testLimit(m_rbA.getCenterOfMassTransform(),m_rbB.getCenterOfMassTransform()); - - //Compute K = J*W*J' for hinge axis - btVector3 axisA = getRigidBodyA().getCenterOfMassTransform().getBasis() * m_rbAFrame.getBasis().getColumn(2); - m_kHinge = 1.0f / (getRigidBodyA().computeAngularImpulseDenominator(axisA) + - getRigidBodyB().computeAngularImpulseDenominator(axisA)); - - } -} - -void btHingeConstraint::solveConstraintObsolete(btSolverBody& bodyA,btSolverBody& bodyB,btScalar timeStep) -{ - - ///for backwards compatibility during the transition to 'getInfo/getInfo2' - if (m_useSolveConstraintObsolete) - { - - btVector3 pivotAInW = m_rbA.getCenterOfMassTransform()*m_rbAFrame.getOrigin(); - btVector3 pivotBInW = m_rbB.getCenterOfMassTransform()*m_rbBFrame.getOrigin(); - - btScalar tau = btScalar(0.3); - - //linear part - if (!m_angularOnly) - { - btVector3 rel_pos1 = pivotAInW - m_rbA.getCenterOfMassPosition(); - btVector3 rel_pos2 = pivotBInW - m_rbB.getCenterOfMassPosition(); - - btVector3 vel1,vel2; - bodyA.getVelocityInLocalPointObsolete(rel_pos1,vel1); - bodyB.getVelocityInLocalPointObsolete(rel_pos2,vel2); - btVector3 vel = vel1 - vel2; - - for (int i=0;i<3;i++) - { - const btVector3& normal = m_jac[i].m_linearJointAxis; - btScalar jacDiagABInv = btScalar(1.) / m_jac[i].getDiagonal(); - - btScalar rel_vel; - rel_vel = normal.dot(vel); - //positional error (zeroth order error) - btScalar depth = -(pivotAInW - pivotBInW).dot(normal); //this is the error projected on the normal - btScalar impulse = depth*tau/timeStep * jacDiagABInv - rel_vel * jacDiagABInv; - m_appliedImpulse += impulse; - btVector3 impulse_vector = normal * impulse; - btVector3 ftorqueAxis1 = rel_pos1.cross(normal); - btVector3 ftorqueAxis2 = rel_pos2.cross(normal); - bodyA.applyImpulse(normal*m_rbA.getInvMass(), m_rbA.getInvInertiaTensorWorld()*ftorqueAxis1,impulse); - bodyB.applyImpulse(normal*m_rbB.getInvMass(), m_rbB.getInvInertiaTensorWorld()*ftorqueAxis2,-impulse); - } - } - - - { - ///solve angular part - - // get axes in world space - btVector3 axisA = getRigidBodyA().getCenterOfMassTransform().getBasis() * m_rbAFrame.getBasis().getColumn(2); - btVector3 axisB = getRigidBodyB().getCenterOfMassTransform().getBasis() * m_rbBFrame.getBasis().getColumn(2); - - btVector3 angVelA; - bodyA.getAngularVelocity(angVelA); - btVector3 angVelB; - bodyB.getAngularVelocity(angVelB); - - btVector3 angVelAroundHingeAxisA = axisA * axisA.dot(angVelA); - btVector3 angVelAroundHingeAxisB = axisB * axisB.dot(angVelB); - - btVector3 angAorthog = angVelA - angVelAroundHingeAxisA; - btVector3 angBorthog = angVelB - angVelAroundHingeAxisB; - btVector3 velrelOrthog = angAorthog-angBorthog; - { - - - //solve orthogonal angular velocity correction - //btScalar relaxation = btScalar(1.); - btScalar len = velrelOrthog.length(); - if (len > btScalar(0.00001)) - { - btVector3 normal = velrelOrthog.normalized(); - btScalar denom = getRigidBodyA().computeAngularImpulseDenominator(normal) + - getRigidBodyB().computeAngularImpulseDenominator(normal); - // scale for mass and relaxation - //velrelOrthog *= (btScalar(1.)/denom) * m_relaxationFactor; - - bodyA.applyImpulse(btVector3(0,0,0), m_rbA.getInvInertiaTensorWorld()*velrelOrthog,-(btScalar(1.)/denom)); - bodyB.applyImpulse(btVector3(0,0,0), m_rbB.getInvInertiaTensorWorld()*velrelOrthog,(btScalar(1.)/denom)); - - } - - //solve angular positional correction - btVector3 angularError = axisA.cross(axisB) *(btScalar(1.)/timeStep); - btScalar len2 = angularError.length(); - if (len2>btScalar(0.00001)) - { - btVector3 normal2 = angularError.normalized(); - btScalar denom2 = getRigidBodyA().computeAngularImpulseDenominator(normal2) + - getRigidBodyB().computeAngularImpulseDenominator(normal2); - //angularError *= (btScalar(1.)/denom2) * relaxation; - - bodyA.applyImpulse(btVector3(0,0,0), m_rbA.getInvInertiaTensorWorld()*angularError,(btScalar(1.)/denom2)); - bodyB.applyImpulse(btVector3(0,0,0), m_rbB.getInvInertiaTensorWorld()*angularError,-(btScalar(1.)/denom2)); - - } - - - - - - // solve limit - if (m_solveLimit) - { - btScalar amplitude = ( (angVelB - angVelA).dot( axisA )*m_relaxationFactor + m_correction* (btScalar(1.)/timeStep)*m_biasFactor ) * m_limitSign; - - btScalar impulseMag = amplitude * m_kHinge; - - // Clamp the accumulated impulse - btScalar temp = m_accLimitImpulse; - m_accLimitImpulse = btMax(m_accLimitImpulse + impulseMag, btScalar(0) ); - impulseMag = m_accLimitImpulse - temp; - - - - bodyA.applyImpulse(btVector3(0,0,0), m_rbA.getInvInertiaTensorWorld()*axisA,impulseMag * m_limitSign); - bodyB.applyImpulse(btVector3(0,0,0), m_rbB.getInvInertiaTensorWorld()*axisA,-(impulseMag * m_limitSign)); - - } - } - - //apply motor - if (m_enableAngularMotor) - { - //todo: add limits too - btVector3 angularLimit(0,0,0); - - btVector3 velrel = angVelAroundHingeAxisA - angVelAroundHingeAxisB; - btScalar projRelVel = velrel.dot(axisA); - - btScalar desiredMotorVel = m_motorTargetVelocity; - btScalar motor_relvel = desiredMotorVel - projRelVel; - - btScalar unclippedMotorImpulse = m_kHinge * motor_relvel;; - - // accumulated impulse clipping: - btScalar fMaxImpulse = m_maxMotorImpulse; - btScalar newAccImpulse = m_accMotorImpulse + unclippedMotorImpulse; - btScalar clippedMotorImpulse = unclippedMotorImpulse; - if (newAccImpulse > fMaxImpulse) - { - newAccImpulse = fMaxImpulse; - clippedMotorImpulse = newAccImpulse - m_accMotorImpulse; - } - else if (newAccImpulse < -fMaxImpulse) - { - newAccImpulse = -fMaxImpulse; - clippedMotorImpulse = newAccImpulse - m_accMotorImpulse; - } - m_accMotorImpulse += clippedMotorImpulse; - - bodyA.applyImpulse(btVector3(0,0,0), m_rbA.getInvInertiaTensorWorld()*axisA,clippedMotorImpulse); - bodyB.applyImpulse(btVector3(0,0,0), m_rbB.getInvInertiaTensorWorld()*axisA,-clippedMotorImpulse); - - } - } - } - -} - - -#endif //__SPU__ - - -void btHingeConstraint::getInfo1(btConstraintInfo1* info) -{ - if (m_useSolveConstraintObsolete) - { - info->m_numConstraintRows = 0; - info->nub = 0; - } - else - { - info->m_numConstraintRows = 5; // Fixed 3 linear + 2 angular - info->nub = 1; - //always add the row, to avoid computation (data is not available yet) - //prepare constraint - testLimit(m_rbA.getCenterOfMassTransform(),m_rbB.getCenterOfMassTransform()); - if(getSolveLimit() || getEnableAngularMotor()) - { - info->m_numConstraintRows++; // limit 3rd anguar as well - info->nub--; - } - - } -} - -void btHingeConstraint::getInfo1NonVirtual(btConstraintInfo1* info) -{ - if (m_useSolveConstraintObsolete) - { - info->m_numConstraintRows = 0; - info->nub = 0; - } - else - { - //always add the 'limit' row, to avoid computation (data is not available yet) - info->m_numConstraintRows = 6; // Fixed 3 linear + 2 angular - info->nub = 0; - } -} - -void btHingeConstraint::getInfo2 (btConstraintInfo2* info) -{ - if(m_useOffsetForConstraintFrame) - { - getInfo2InternalUsingFrameOffset(info, m_rbA.getCenterOfMassTransform(),m_rbB.getCenterOfMassTransform(),m_rbA.getAngularVelocity(),m_rbB.getAngularVelocity()); - } - else - { - getInfo2Internal(info, m_rbA.getCenterOfMassTransform(),m_rbB.getCenterOfMassTransform(),m_rbA.getAngularVelocity(),m_rbB.getAngularVelocity()); - } -} - - -void btHingeConstraint::getInfo2NonVirtual (btConstraintInfo2* info,const btTransform& transA,const btTransform& transB,const btVector3& angVelA,const btVector3& angVelB) -{ - ///the regular (virtual) implementation getInfo2 already performs 'testLimit' during getInfo1, so we need to do it now - testLimit(transA,transB); - - getInfo2Internal(info,transA,transB,angVelA,angVelB); -} - - -void btHingeConstraint::getInfo2Internal(btConstraintInfo2* info, const btTransform& transA,const btTransform& transB,const btVector3& angVelA,const btVector3& angVelB) -{ - - btAssert(!m_useSolveConstraintObsolete); - int i, skip = info->rowskip; - // transforms in world space - btTransform trA = transA*m_rbAFrame; - btTransform trB = transB*m_rbBFrame; - // pivot point - btVector3 pivotAInW = trA.getOrigin(); - btVector3 pivotBInW = trB.getOrigin(); -#if 0 - if (0) - { - for (i=0;i<6;i++) - { - info->m_J1linearAxis[i*skip]=0; - info->m_J1linearAxis[i*skip+1]=0; - info->m_J1linearAxis[i*skip+2]=0; - - info->m_J1angularAxis[i*skip]=0; - info->m_J1angularAxis[i*skip+1]=0; - info->m_J1angularAxis[i*skip+2]=0; - - info->m_J2angularAxis[i*skip]=0; - info->m_J2angularAxis[i*skip+1]=0; - info->m_J2angularAxis[i*skip+2]=0; - - info->m_constraintError[i*skip]=0.f; - } - } -#endif //#if 0 - // linear (all fixed) - info->m_J1linearAxis[0] = 1; - info->m_J1linearAxis[skip + 1] = 1; - info->m_J1linearAxis[2 * skip + 2] = 1; - - - - - - btVector3 a1 = pivotAInW - transA.getOrigin(); - { - btVector3* angular0 = (btVector3*)(info->m_J1angularAxis); - btVector3* angular1 = (btVector3*)(info->m_J1angularAxis + skip); - btVector3* angular2 = (btVector3*)(info->m_J1angularAxis + 2 * skip); - btVector3 a1neg = -a1; - a1neg.getSkewSymmetricMatrix(angular0,angular1,angular2); - } - btVector3 a2 = pivotBInW - transB.getOrigin(); - { - btVector3* angular0 = (btVector3*)(info->m_J2angularAxis); - btVector3* angular1 = (btVector3*)(info->m_J2angularAxis + skip); - btVector3* angular2 = (btVector3*)(info->m_J2angularAxis + 2 * skip); - a2.getSkewSymmetricMatrix(angular0,angular1,angular2); - } - // linear RHS - btScalar k = info->fps * info->erp; - for(i = 0; i < 3; i++) - { - info->m_constraintError[i * skip] = k * (pivotBInW[i] - pivotAInW[i]); - } - // make rotations around X and Y equal - // the hinge axis should be the only unconstrained - // rotational axis, the angular velocity of the two bodies perpendicular to - // the hinge axis should be equal. thus the constraint equations are - // p*w1 - p*w2 = 0 - // q*w1 - q*w2 = 0 - // where p and q are unit vectors normal to the hinge axis, and w1 and w2 - // are the angular velocity vectors of the two bodies. - // get hinge axis (Z) - btVector3 ax1 = trA.getBasis().getColumn(2); - // get 2 orthos to hinge axis (X, Y) - btVector3 p = trA.getBasis().getColumn(0); - btVector3 q = trA.getBasis().getColumn(1); - // set the two hinge angular rows - int s3 = 3 * info->rowskip; - int s4 = 4 * info->rowskip; - - info->m_J1angularAxis[s3 + 0] = p[0]; - info->m_J1angularAxis[s3 + 1] = p[1]; - info->m_J1angularAxis[s3 + 2] = p[2]; - info->m_J1angularAxis[s4 + 0] = q[0]; - info->m_J1angularAxis[s4 + 1] = q[1]; - info->m_J1angularAxis[s4 + 2] = q[2]; - - info->m_J2angularAxis[s3 + 0] = -p[0]; - info->m_J2angularAxis[s3 + 1] = -p[1]; - info->m_J2angularAxis[s3 + 2] = -p[2]; - info->m_J2angularAxis[s4 + 0] = -q[0]; - info->m_J2angularAxis[s4 + 1] = -q[1]; - info->m_J2angularAxis[s4 + 2] = -q[2]; - // compute the right hand side of the constraint equation. set relative - // body velocities along p and q to bring the hinge back into alignment. - // if ax1,ax2 are the unit length hinge axes as computed from body1 and - // body2, we need to rotate both bodies along the axis u = (ax1 x ax2). - // if `theta' is the angle between ax1 and ax2, we need an angular velocity - // along u to cover angle erp*theta in one step : - // |angular_velocity| = angle/time = erp*theta / stepsize - // = (erp*fps) * theta - // angular_velocity = |angular_velocity| * (ax1 x ax2) / |ax1 x ax2| - // = (erp*fps) * theta * (ax1 x ax2) / sin(theta) - // ...as ax1 and ax2 are unit length. if theta is smallish, - // theta ~= sin(theta), so - // angular_velocity = (erp*fps) * (ax1 x ax2) - // ax1 x ax2 is in the plane space of ax1, so we project the angular - // velocity to p and q to find the right hand side. - btVector3 ax2 = trB.getBasis().getColumn(2); - btVector3 u = ax1.cross(ax2); - info->m_constraintError[s3] = k * u.dot(p); - info->m_constraintError[s4] = k * u.dot(q); - // check angular limits - int nrow = 4; // last filled row - int srow; - btScalar limit_err = btScalar(0.0); - int limit = 0; - if(getSolveLimit()) - { - limit_err = m_correction * m_referenceSign; - limit = (limit_err > btScalar(0.0)) ? 1 : 2; - } - // if the hinge has joint limits or motor, add in the extra row - int powered = 0; - if(getEnableAngularMotor()) - { - powered = 1; - } - if(limit || powered) - { - nrow++; - srow = nrow * info->rowskip; - info->m_J1angularAxis[srow+0] = ax1[0]; - info->m_J1angularAxis[srow+1] = ax1[1]; - info->m_J1angularAxis[srow+2] = ax1[2]; - - info->m_J2angularAxis[srow+0] = -ax1[0]; - info->m_J2angularAxis[srow+1] = -ax1[1]; - info->m_J2angularAxis[srow+2] = -ax1[2]; - - btScalar lostop = getLowerLimit(); - btScalar histop = getUpperLimit(); - if(limit && (lostop == histop)) - { // the joint motor is ineffective - powered = 0; - } - info->m_constraintError[srow] = btScalar(0.0f); - if(powered) - { - info->cfm[srow] = btScalar(0.0); - btScalar mot_fact = getMotorFactor(m_hingeAngle, lostop, histop, m_motorTargetVelocity, info->fps * info->erp); - info->m_constraintError[srow] += mot_fact * m_motorTargetVelocity * m_referenceSign; - info->m_lowerLimit[srow] = - m_maxMotorImpulse; - info->m_upperLimit[srow] = m_maxMotorImpulse; - } - if(limit) - { - k = info->fps * info->erp; - info->m_constraintError[srow] += k * limit_err; - info->cfm[srow] = btScalar(0.0); - if(lostop == histop) - { - // limited low and high simultaneously - info->m_lowerLimit[srow] = -SIMD_INFINITY; - info->m_upperLimit[srow] = SIMD_INFINITY; - } - else if(limit == 1) - { // low limit - info->m_lowerLimit[srow] = 0; - info->m_upperLimit[srow] = SIMD_INFINITY; - } - else - { // high limit - info->m_lowerLimit[srow] = -SIMD_INFINITY; - info->m_upperLimit[srow] = 0; - } - // bounce (we'll use slider parameter abs(1.0 - m_dampingLimAng) for that) - btScalar bounce = m_relaxationFactor; - if(bounce > btScalar(0.0)) - { - btScalar vel = angVelA.dot(ax1); - vel -= angVelB.dot(ax1); - // only apply bounce if the velocity is incoming, and if the - // resulting c[] exceeds what we already have. - if(limit == 1) - { // low limit - if(vel < 0) - { - btScalar newc = -bounce * vel; - if(newc > info->m_constraintError[srow]) - { - info->m_constraintError[srow] = newc; - } - } - } - else - { // high limit - all those computations are reversed - if(vel > 0) - { - btScalar newc = -bounce * vel; - if(newc < info->m_constraintError[srow]) - { - info->m_constraintError[srow] = newc; - } - } - } - } - info->m_constraintError[srow] *= m_biasFactor; - } // if(limit) - } // if angular limit or powered -} - - - - - - -void btHingeConstraint::updateRHS(btScalar timeStep) -{ - (void)timeStep; - -} - - -btScalar btHingeConstraint::getHingeAngle() -{ - return getHingeAngle(m_rbA.getCenterOfMassTransform(),m_rbB.getCenterOfMassTransform()); -} - -btScalar btHingeConstraint::getHingeAngle(const btTransform& transA,const btTransform& transB) -{ - const btVector3 refAxis0 = transA.getBasis() * m_rbAFrame.getBasis().getColumn(0); - const btVector3 refAxis1 = transA.getBasis() * m_rbAFrame.getBasis().getColumn(1); - const btVector3 swingAxis = transB.getBasis() * m_rbBFrame.getBasis().getColumn(1); -// btScalar angle = btAtan2Fast(swingAxis.dot(refAxis0), swingAxis.dot(refAxis1)); - btScalar angle = btAtan2(swingAxis.dot(refAxis0), swingAxis.dot(refAxis1)); - return m_referenceSign * angle; -} - - -#if 0 -void btHingeConstraint::testLimit() -{ - // Compute limit information - m_hingeAngle = getHingeAngle(); - m_correction = btScalar(0.); - m_limitSign = btScalar(0.); - m_solveLimit = false; - if (m_lowerLimit <= m_upperLimit) - { - if (m_hingeAngle <= m_lowerLimit) - { - m_correction = (m_lowerLimit - m_hingeAngle); - m_limitSign = 1.0f; - m_solveLimit = true; - } - else if (m_hingeAngle >= m_upperLimit) - { - m_correction = m_upperLimit - m_hingeAngle; - m_limitSign = -1.0f; - m_solveLimit = true; - } - } - return; -} -#else - - -void btHingeConstraint::testLimit(const btTransform& transA,const btTransform& transB) -{ - // Compute limit information - m_hingeAngle = getHingeAngle(transA,transB); - m_correction = btScalar(0.); - m_limitSign = btScalar(0.); - m_solveLimit = false; - if (m_lowerLimit <= m_upperLimit) - { - m_hingeAngle = btAdjustAngleToLimits(m_hingeAngle, m_lowerLimit, m_upperLimit); - if (m_hingeAngle <= m_lowerLimit) - { - m_correction = (m_lowerLimit - m_hingeAngle); - m_limitSign = 1.0f; - m_solveLimit = true; - } - else if (m_hingeAngle >= m_upperLimit) - { - m_correction = m_upperLimit - m_hingeAngle; - m_limitSign = -1.0f; - m_solveLimit = true; - } - } - return; -} -#endif - -static btVector3 vHinge(0, 0, btScalar(1)); - -void btHingeConstraint::setMotorTarget(const btQuaternion& qAinB, btScalar dt) -{ - // convert target from body to constraint space - btQuaternion qConstraint = m_rbBFrame.getRotation().inverse() * qAinB * m_rbAFrame.getRotation(); - qConstraint.normalize(); - - // extract "pure" hinge component - btVector3 vNoHinge = quatRotate(qConstraint, vHinge); vNoHinge.normalize(); - btQuaternion qNoHinge = shortestArcQuat(vHinge, vNoHinge); - btQuaternion qHinge = qNoHinge.inverse() * qConstraint; - qHinge.normalize(); - - // compute angular target, clamped to limits - btScalar targetAngle = qHinge.getAngle(); - if (targetAngle > SIMD_PI) // long way around. flip quat and recalculate. - { - qHinge = operator-(qHinge); - targetAngle = qHinge.getAngle(); - } - if (qHinge.getZ() < 0) - targetAngle = -targetAngle; - - setMotorTarget(targetAngle, dt); -} - -void btHingeConstraint::setMotorTarget(btScalar targetAngle, btScalar dt) -{ - if (m_lowerLimit < m_upperLimit) - { - if (targetAngle < m_lowerLimit) - targetAngle = m_lowerLimit; - else if (targetAngle > m_upperLimit) - targetAngle = m_upperLimit; - } - - // compute angular velocity - btScalar curAngle = getHingeAngle(m_rbA.getCenterOfMassTransform(),m_rbB.getCenterOfMassTransform()); - btScalar dAngle = targetAngle - curAngle; - m_motorTargetVelocity = dAngle / dt; -} - - - -void btHingeConstraint::getInfo2InternalUsingFrameOffset(btConstraintInfo2* info, const btTransform& transA,const btTransform& transB,const btVector3& angVelA,const btVector3& angVelB) -{ - btAssert(!m_useSolveConstraintObsolete); - int i, s = info->rowskip; - // transforms in world space - btTransform trA = transA*m_rbAFrame; - btTransform trB = transB*m_rbBFrame; - // pivot point - btVector3 pivotAInW = trA.getOrigin(); - btVector3 pivotBInW = trB.getOrigin(); -#if 1 - // difference between frames in WCS - btVector3 ofs = trB.getOrigin() - trA.getOrigin(); - // now get weight factors depending on masses - btScalar miA = getRigidBodyA().getInvMass(); - btScalar miB = getRigidBodyB().getInvMass(); - bool hasStaticBody = (miA < SIMD_EPSILON) || (miB < SIMD_EPSILON); - btScalar miS = miA + miB; - btScalar factA, factB; - if(miS > btScalar(0.f)) - { - factA = miB / miS; - } - else - { - factA = btScalar(0.5f); - } - factB = btScalar(1.0f) - factA; - // get the desired direction of hinge axis - // as weighted sum of Z-orthos of frameA and frameB in WCS - btVector3 ax1A = trA.getBasis().getColumn(2); - btVector3 ax1B = trB.getBasis().getColumn(2); - btVector3 ax1 = ax1A * factA + ax1B * factB; - ax1.normalize(); - // fill first 3 rows - // we want: velA + wA x relA == velB + wB x relB - btTransform bodyA_trans = transA; - btTransform bodyB_trans = transB; - int s0 = 0; - int s1 = s; - int s2 = s * 2; - int nrow = 2; // last filled row - btVector3 tmpA, tmpB, relA, relB, p, q; - // get vector from bodyB to frameB in WCS - relB = trB.getOrigin() - bodyB_trans.getOrigin(); - // get its projection to hinge axis - btVector3 projB = ax1 * relB.dot(ax1); - // get vector directed from bodyB to hinge axis (and orthogonal to it) - btVector3 orthoB = relB - projB; - // same for bodyA - relA = trA.getOrigin() - bodyA_trans.getOrigin(); - btVector3 projA = ax1 * relA.dot(ax1); - btVector3 orthoA = relA - projA; - btVector3 totalDist = projA - projB; - // get offset vectors relA and relB - relA = orthoA + totalDist * factA; - relB = orthoB - totalDist * factB; - // now choose average ortho to hinge axis - p = orthoB * factA + orthoA * factB; - btScalar len2 = p.length2(); - if(len2 > SIMD_EPSILON) - { - p /= btSqrt(len2); - } - else - { - p = trA.getBasis().getColumn(1); - } - // make one more ortho - q = ax1.cross(p); - // fill three rows - tmpA = relA.cross(p); - tmpB = relB.cross(p); - for (i=0; i<3; i++) info->m_J1angularAxis[s0+i] = tmpA[i]; - for (i=0; i<3; i++) info->m_J2angularAxis[s0+i] = -tmpB[i]; - tmpA = relA.cross(q); - tmpB = relB.cross(q); - if(hasStaticBody && getSolveLimit()) - { // to make constraint between static and dynamic objects more rigid - // remove wA (or wB) from equation if angular limit is hit - tmpB *= factB; - tmpA *= factA; - } - for (i=0; i<3; i++) info->m_J1angularAxis[s1+i] = tmpA[i]; - for (i=0; i<3; i++) info->m_J2angularAxis[s1+i] = -tmpB[i]; - tmpA = relA.cross(ax1); - tmpB = relB.cross(ax1); - if(hasStaticBody) - { // to make constraint between static and dynamic objects more rigid - // remove wA (or wB) from equation - tmpB *= factB; - tmpA *= factA; - } - for (i=0; i<3; i++) info->m_J1angularAxis[s2+i] = tmpA[i]; - for (i=0; i<3; i++) info->m_J2angularAxis[s2+i] = -tmpB[i]; - - for (i=0; i<3; i++) info->m_J1linearAxis[s0+i] = p[i]; - for (i=0; i<3; i++) info->m_J1linearAxis[s1+i] = q[i]; - for (i=0; i<3; i++) info->m_J1linearAxis[s2+i] = ax1[i]; - // compute three elements of right hand side - btScalar k = info->fps * info->erp; - btScalar rhs = k * p.dot(ofs); - info->m_constraintError[s0] = rhs; - rhs = k * q.dot(ofs); - info->m_constraintError[s1] = rhs; - rhs = k * ax1.dot(ofs); - info->m_constraintError[s2] = rhs; - // the hinge axis should be the only unconstrained - // rotational axis, the angular velocity of the two bodies perpendicular to - // the hinge axis should be equal. thus the constraint equations are - // p*w1 - p*w2 = 0 - // q*w1 - q*w2 = 0 - // where p and q are unit vectors normal to the hinge axis, and w1 and w2 - // are the angular velocity vectors of the two bodies. - int s3 = 3 * s; - int s4 = 4 * s; - info->m_J1angularAxis[s3 + 0] = p[0]; - info->m_J1angularAxis[s3 + 1] = p[1]; - info->m_J1angularAxis[s3 + 2] = p[2]; - info->m_J1angularAxis[s4 + 0] = q[0]; - info->m_J1angularAxis[s4 + 1] = q[1]; - info->m_J1angularAxis[s4 + 2] = q[2]; - - info->m_J2angularAxis[s3 + 0] = -p[0]; - info->m_J2angularAxis[s3 + 1] = -p[1]; - info->m_J2angularAxis[s3 + 2] = -p[2]; - info->m_J2angularAxis[s4 + 0] = -q[0]; - info->m_J2angularAxis[s4 + 1] = -q[1]; - info->m_J2angularAxis[s4 + 2] = -q[2]; - // compute the right hand side of the constraint equation. set relative - // body velocities along p and q to bring the hinge back into alignment. - // if ax1A,ax1B are the unit length hinge axes as computed from bodyA and - // bodyB, we need to rotate both bodies along the axis u = (ax1 x ax2). - // if "theta" is the angle between ax1 and ax2, we need an angular velocity - // along u to cover angle erp*theta in one step : - // |angular_velocity| = angle/time = erp*theta / stepsize - // = (erp*fps) * theta - // angular_velocity = |angular_velocity| * (ax1 x ax2) / |ax1 x ax2| - // = (erp*fps) * theta * (ax1 x ax2) / sin(theta) - // ...as ax1 and ax2 are unit length. if theta is smallish, - // theta ~= sin(theta), so - // angular_velocity = (erp*fps) * (ax1 x ax2) - // ax1 x ax2 is in the plane space of ax1, so we project the angular - // velocity to p and q to find the right hand side. - k = info->fps * info->erp; - btVector3 u = ax1A.cross(ax1B); - info->m_constraintError[s3] = k * u.dot(p); - info->m_constraintError[s4] = k * u.dot(q); -#endif - // check angular limits - nrow = 4; // last filled row - int srow; - btScalar limit_err = btScalar(0.0); - int limit = 0; - if(getSolveLimit()) - { - limit_err = m_correction * m_referenceSign; - limit = (limit_err > btScalar(0.0)) ? 1 : 2; - } - // if the hinge has joint limits or motor, add in the extra row - int powered = 0; - if(getEnableAngularMotor()) - { - powered = 1; - } - if(limit || powered) - { - nrow++; - srow = nrow * info->rowskip; - info->m_J1angularAxis[srow+0] = ax1[0]; - info->m_J1angularAxis[srow+1] = ax1[1]; - info->m_J1angularAxis[srow+2] = ax1[2]; - - info->m_J2angularAxis[srow+0] = -ax1[0]; - info->m_J2angularAxis[srow+1] = -ax1[1]; - info->m_J2angularAxis[srow+2] = -ax1[2]; - - btScalar lostop = getLowerLimit(); - btScalar histop = getUpperLimit(); - if(limit && (lostop == histop)) - { // the joint motor is ineffective - powered = 0; - } - info->m_constraintError[srow] = btScalar(0.0f); - if(powered) - { - info->cfm[srow] = btScalar(0.0); - btScalar mot_fact = getMotorFactor(m_hingeAngle, lostop, histop, m_motorTargetVelocity, info->fps * info->erp); - info->m_constraintError[srow] += mot_fact * m_motorTargetVelocity * m_referenceSign; - info->m_lowerLimit[srow] = - m_maxMotorImpulse; - info->m_upperLimit[srow] = m_maxMotorImpulse; - } - if(limit) - { - k = info->fps * info->erp; - info->m_constraintError[srow] += k * limit_err; - info->cfm[srow] = btScalar(0.0); - if(lostop == histop) - { - // limited low and high simultaneously - info->m_lowerLimit[srow] = -SIMD_INFINITY; - info->m_upperLimit[srow] = SIMD_INFINITY; - } - else if(limit == 1) - { // low limit - info->m_lowerLimit[srow] = 0; - info->m_upperLimit[srow] = SIMD_INFINITY; - } - else - { // high limit - info->m_lowerLimit[srow] = -SIMD_INFINITY; - info->m_upperLimit[srow] = 0; - } - // bounce (we'll use slider parameter abs(1.0 - m_dampingLimAng) for that) - btScalar bounce = m_relaxationFactor; - if(bounce > btScalar(0.0)) - { - btScalar vel = angVelA.dot(ax1); - vel -= angVelB.dot(ax1); - // only apply bounce if the velocity is incoming, and if the - // resulting c[] exceeds what we already have. - if(limit == 1) - { // low limit - if(vel < 0) - { - btScalar newc = -bounce * vel; - if(newc > info->m_constraintError[srow]) - { - info->m_constraintError[srow] = newc; - } - } - } - else - { // high limit - all those computations are reversed - if(vel > 0) - { - btScalar newc = -bounce * vel; - if(newc < info->m_constraintError[srow]) - { - info->m_constraintError[srow] = newc; - } - } - } - } - info->m_constraintError[srow] *= m_biasFactor; - } // if(limit) - } // if angular limit or powered -} - diff --git a/bullet/src/BulletDynamics/ConstraintSolver/btHingeConstraint.h b/bullet/src/BulletDynamics/ConstraintSolver/btHingeConstraint.h deleted file mode 100644 index 2dfe8bdf1..000000000 --- a/bullet/src/BulletDynamics/ConstraintSolver/btHingeConstraint.h +++ /dev/null @@ -1,227 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -/* Hinge Constraint by Dirk Gregorius. Limits added by Marcus Hennix at Starbreeze Studios */ - -#ifndef HINGECONSTRAINT_H -#define HINGECONSTRAINT_H - -#include "LinearMath/btVector3.h" -#include "btJacobianEntry.h" -#include "btTypedConstraint.h" - -class btRigidBody; - -/// hinge constraint between two rigidbodies each with a pivotpoint that descibes the axis location in local space -/// axis defines the orientation of the hinge axis -ATTRIBUTE_ALIGNED16(class) btHingeConstraint : public btTypedConstraint -{ -#ifdef IN_PARALLELL_SOLVER -public: -#endif - btJacobianEntry m_jac[3]; //3 orthogonal linear constraints - btJacobianEntry m_jacAng[3]; //2 orthogonal angular constraints+ 1 for limit/motor - - btTransform m_rbAFrame; // constraint axii. Assumes z is hinge axis. - btTransform m_rbBFrame; - - btScalar m_motorTargetVelocity; - btScalar m_maxMotorImpulse; - - btScalar m_limitSoftness; - btScalar m_biasFactor; - btScalar m_relaxationFactor; - - btScalar m_lowerLimit; - btScalar m_upperLimit; - - btScalar m_kHinge; - - btScalar m_limitSign; - btScalar m_correction; - - btScalar m_accLimitImpulse; - btScalar m_hingeAngle; - btScalar m_referenceSign; - - bool m_angularOnly; - bool m_enableAngularMotor; - bool m_solveLimit; - bool m_useSolveConstraintObsolete; - bool m_useOffsetForConstraintFrame; - bool m_useReferenceFrameA; - - btScalar m_accMotorImpulse; - - -public: - - btHingeConstraint(btRigidBody& rbA,btRigidBody& rbB, const btVector3& pivotInA,const btVector3& pivotInB, btVector3& axisInA,btVector3& axisInB, bool useReferenceFrameA = false); - - btHingeConstraint(btRigidBody& rbA,const btVector3& pivotInA,btVector3& axisInA, bool useReferenceFrameA = false); - - btHingeConstraint(btRigidBody& rbA,btRigidBody& rbB, const btTransform& rbAFrame, const btTransform& rbBFrame, bool useReferenceFrameA = false); - - btHingeConstraint(btRigidBody& rbA,const btTransform& rbAFrame, bool useReferenceFrameA = false); - - btHingeConstraint(); - - virtual void buildJacobian(); - - virtual void getInfo1 (btConstraintInfo1* info); - - void getInfo1NonVirtual(btConstraintInfo1* info); - - virtual void getInfo2 (btConstraintInfo2* info); - - void getInfo2NonVirtual(btConstraintInfo2* info,const btTransform& transA,const btTransform& transB,const btVector3& angVelA,const btVector3& angVelB); - - void getInfo2Internal(btConstraintInfo2* info,const btTransform& transA,const btTransform& transB,const btVector3& angVelA,const btVector3& angVelB); - void getInfo2InternalUsingFrameOffset(btConstraintInfo2* info,const btTransform& transA,const btTransform& transB,const btVector3& angVelA,const btVector3& angVelB); - - virtual void solveConstraintObsolete(btSolverBody& bodyA,btSolverBody& bodyB,btScalar timeStep); - - void updateRHS(btScalar timeStep); - - const btRigidBody& getRigidBodyA() const - { - return m_rbA; - } - const btRigidBody& getRigidBodyB() const - { - return m_rbB; - } - - btRigidBody& getRigidBodyA() - { - return m_rbA; - } - - btRigidBody& getRigidBodyB() - { - return m_rbB; - } - - void setAngularOnly(bool angularOnly) - { - m_angularOnly = angularOnly; - } - - void enableAngularMotor(bool enableMotor,btScalar targetVelocity,btScalar maxMotorImpulse) - { - m_enableAngularMotor = enableMotor; - m_motorTargetVelocity = targetVelocity; - m_maxMotorImpulse = maxMotorImpulse; - } - - // extra motor API, including ability to set a target rotation (as opposed to angular velocity) - // note: setMotorTarget sets angular velocity under the hood, so you must call it every tick to - // maintain a given angular target. - void enableMotor(bool enableMotor) { m_enableAngularMotor = enableMotor; } - void setMaxMotorImpulse(btScalar maxMotorImpulse) { m_maxMotorImpulse = maxMotorImpulse; } - void setMotorTarget(const btQuaternion& qAinB, btScalar dt); // qAinB is rotation of body A wrt body B. - void setMotorTarget(btScalar targetAngle, btScalar dt); - - - void setLimit(btScalar low,btScalar high,btScalar _softness = 0.9f, btScalar _biasFactor = 0.3f, btScalar _relaxationFactor = 1.0f) - { - m_lowerLimit = btNormalizeAngle(low); - m_upperLimit = btNormalizeAngle(high); - - m_limitSoftness = _softness; - m_biasFactor = _biasFactor; - m_relaxationFactor = _relaxationFactor; - - } - - void setAxis(btVector3& axisInA) - { - btVector3 rbAxisA1, rbAxisA2; - btPlaneSpace1(axisInA, rbAxisA1, rbAxisA2); - btVector3 pivotInA = m_rbAFrame.getOrigin(); -// m_rbAFrame.getOrigin() = pivotInA; - m_rbAFrame.getBasis().setValue( rbAxisA1.getX(),rbAxisA2.getX(),axisInA.getX(), - rbAxisA1.getY(),rbAxisA2.getY(),axisInA.getY(), - rbAxisA1.getZ(),rbAxisA2.getZ(),axisInA.getZ() ); - - btVector3 axisInB = m_rbA.getCenterOfMassTransform().getBasis() * axisInA; - - btQuaternion rotationArc = shortestArcQuat(axisInA,axisInB); - btVector3 rbAxisB1 = quatRotate(rotationArc,rbAxisA1); - btVector3 rbAxisB2 = axisInB.cross(rbAxisB1); - - - m_rbBFrame.getOrigin() = m_rbA.getCenterOfMassTransform()(pivotInA); - m_rbBFrame.getBasis().setValue( rbAxisB1.getX(),rbAxisB2.getX(),axisInB.getX(), - rbAxisB1.getY(),rbAxisB2.getY(),axisInB.getY(), - rbAxisB1.getZ(),rbAxisB2.getZ(),axisInB.getZ() ); - } - - btScalar getLowerLimit() const - { - return m_lowerLimit; - } - - btScalar getUpperLimit() const - { - return m_upperLimit; - } - - - btScalar getHingeAngle(); - - btScalar getHingeAngle(const btTransform& transA,const btTransform& transB); - - void testLimit(const btTransform& transA,const btTransform& transB); - - - const btTransform& getAFrame() const { return m_rbAFrame; }; - const btTransform& getBFrame() const { return m_rbBFrame; }; - - btTransform& getAFrame() { return m_rbAFrame; }; - btTransform& getBFrame() { return m_rbBFrame; }; - - inline int getSolveLimit() - { - return m_solveLimit; - } - - inline btScalar getLimitSign() - { - return m_limitSign; - } - - inline bool getAngularOnly() - { - return m_angularOnly; - } - inline bool getEnableAngularMotor() - { - return m_enableAngularMotor; - } - inline btScalar getMotorTargetVelosity() - { - return m_motorTargetVelocity; - } - inline btScalar getMaxMotorImpulse() - { - return m_maxMotorImpulse; - } - // access for UseFrameOffset - bool getUseFrameOffset() { return m_useOffsetForConstraintFrame; } - void setUseFrameOffset(bool frameOffsetOnOff) { m_useOffsetForConstraintFrame = frameOffsetOnOff; } -}; - -#endif //HINGECONSTRAINT_H diff --git a/bullet/src/BulletDynamics/ConstraintSolver/btJacobianEntry.h b/bullet/src/BulletDynamics/ConstraintSolver/btJacobianEntry.h deleted file mode 100644 index 13ff68c85..000000000 --- a/bullet/src/BulletDynamics/ConstraintSolver/btJacobianEntry.h +++ /dev/null @@ -1,156 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef JACOBIAN_ENTRY_H -#define JACOBIAN_ENTRY_H - -#include "LinearMath/btVector3.h" -#include "BulletDynamics/Dynamics/btRigidBody.h" - - -//notes: -// Another memory optimization would be to store m_1MinvJt in the remaining 3 w components -// which makes the btJacobianEntry memory layout 16 bytes -// if you only are interested in angular part, just feed massInvA and massInvB zero - -/// Jacobian entry is an abstraction that allows to describe constraints -/// it can be used in combination with a constraint solver -/// Can be used to relate the effect of an impulse to the constraint error -ATTRIBUTE_ALIGNED16(class) btJacobianEntry -{ -public: - btJacobianEntry() {}; - //constraint between two different rigidbodies - btJacobianEntry( - const btMatrix3x3& world2A, - const btMatrix3x3& world2B, - const btVector3& rel_pos1,const btVector3& rel_pos2, - const btVector3& jointAxis, - const btVector3& inertiaInvA, - const btScalar massInvA, - const btVector3& inertiaInvB, - const btScalar massInvB) - :m_linearJointAxis(jointAxis) - { - m_aJ = world2A*(rel_pos1.cross(m_linearJointAxis)); - m_bJ = world2B*(rel_pos2.cross(-m_linearJointAxis)); - m_0MinvJt = inertiaInvA * m_aJ; - m_1MinvJt = inertiaInvB * m_bJ; - m_Adiag = massInvA + m_0MinvJt.dot(m_aJ) + massInvB + m_1MinvJt.dot(m_bJ); - - btAssert(m_Adiag > btScalar(0.0)); - } - - //angular constraint between two different rigidbodies - btJacobianEntry(const btVector3& jointAxis, - const btMatrix3x3& world2A, - const btMatrix3x3& world2B, - const btVector3& inertiaInvA, - const btVector3& inertiaInvB) - :m_linearJointAxis(btVector3(btScalar(0.),btScalar(0.),btScalar(0.))) - { - m_aJ= world2A*jointAxis; - m_bJ = world2B*-jointAxis; - m_0MinvJt = inertiaInvA * m_aJ; - m_1MinvJt = inertiaInvB * m_bJ; - m_Adiag = m_0MinvJt.dot(m_aJ) + m_1MinvJt.dot(m_bJ); - - btAssert(m_Adiag > btScalar(0.0)); - } - - //angular constraint between two different rigidbodies - btJacobianEntry(const btVector3& axisInA, - const btVector3& axisInB, - const btVector3& inertiaInvA, - const btVector3& inertiaInvB) - : m_linearJointAxis(btVector3(btScalar(0.),btScalar(0.),btScalar(0.))) - , m_aJ(axisInA) - , m_bJ(-axisInB) - { - m_0MinvJt = inertiaInvA * m_aJ; - m_1MinvJt = inertiaInvB * m_bJ; - m_Adiag = m_0MinvJt.dot(m_aJ) + m_1MinvJt.dot(m_bJ); - - btAssert(m_Adiag > btScalar(0.0)); - } - - //constraint on one rigidbody - btJacobianEntry( - const btMatrix3x3& world2A, - const btVector3& rel_pos1,const btVector3& rel_pos2, - const btVector3& jointAxis, - const btVector3& inertiaInvA, - const btScalar massInvA) - :m_linearJointAxis(jointAxis) - { - m_aJ= world2A*(rel_pos1.cross(jointAxis)); - m_bJ = world2A*(rel_pos2.cross(-jointAxis)); - m_0MinvJt = inertiaInvA * m_aJ; - m_1MinvJt = btVector3(btScalar(0.),btScalar(0.),btScalar(0.)); - m_Adiag = massInvA + m_0MinvJt.dot(m_aJ); - - btAssert(m_Adiag > btScalar(0.0)); - } - - btScalar getDiagonal() const { return m_Adiag; } - - // for two constraints on the same rigidbody (for example vehicle friction) - btScalar getNonDiagonal(const btJacobianEntry& jacB, const btScalar massInvA) const - { - const btJacobianEntry& jacA = *this; - btScalar lin = massInvA * jacA.m_linearJointAxis.dot(jacB.m_linearJointAxis); - btScalar ang = jacA.m_0MinvJt.dot(jacB.m_aJ); - return lin + ang; - } - - - - // for two constraints on sharing two same rigidbodies (for example two contact points between two rigidbodies) - btScalar getNonDiagonal(const btJacobianEntry& jacB,const btScalar massInvA,const btScalar massInvB) const - { - const btJacobianEntry& jacA = *this; - btVector3 lin = jacA.m_linearJointAxis * jacB.m_linearJointAxis; - btVector3 ang0 = jacA.m_0MinvJt * jacB.m_aJ; - btVector3 ang1 = jacA.m_1MinvJt * jacB.m_bJ; - btVector3 lin0 = massInvA * lin ; - btVector3 lin1 = massInvB * lin; - btVector3 sum = ang0+ang1+lin0+lin1; - return sum[0]+sum[1]+sum[2]; - } - - btScalar getRelativeVelocity(const btVector3& linvelA,const btVector3& angvelA,const btVector3& linvelB,const btVector3& angvelB) - { - btVector3 linrel = linvelA - linvelB; - btVector3 angvela = angvelA * m_aJ; - btVector3 angvelb = angvelB * m_bJ; - linrel *= m_linearJointAxis; - angvela += angvelb; - angvela += linrel; - btScalar rel_vel2 = angvela[0]+angvela[1]+angvela[2]; - return rel_vel2 + SIMD_EPSILON; - } -//private: - - btVector3 m_linearJointAxis; - btVector3 m_aJ; - btVector3 m_bJ; - btVector3 m_0MinvJt; - btVector3 m_1MinvJt; - //Optimization: can be stored in the w/last component of one of the vectors - btScalar m_Adiag; - -}; - -#endif //JACOBIAN_ENTRY_H diff --git a/bullet/src/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.cpp b/bullet/src/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.cpp deleted file mode 100644 index f857757fb..000000000 --- a/bullet/src/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.cpp +++ /dev/null @@ -1,242 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#include "btPoint2PointConstraint.h" -#include "BulletDynamics/Dynamics/btRigidBody.h" -#include - - - -btPoint2PointConstraint::btPoint2PointConstraint() -:btTypedConstraint(POINT2POINT_CONSTRAINT_TYPE), -m_useSolveConstraintObsolete(false) -{ -} - -btPoint2PointConstraint::btPoint2PointConstraint(btRigidBody& rbA,btRigidBody& rbB, const btVector3& pivotInA,const btVector3& pivotInB) -:btTypedConstraint(POINT2POINT_CONSTRAINT_TYPE,rbA,rbB),m_pivotInA(pivotInA),m_pivotInB(pivotInB), -m_useSolveConstraintObsolete(false) -{ - -} - - -btPoint2PointConstraint::btPoint2PointConstraint(btRigidBody& rbA,const btVector3& pivotInA) -:btTypedConstraint(POINT2POINT_CONSTRAINT_TYPE,rbA),m_pivotInA(pivotInA),m_pivotInB(rbA.getCenterOfMassTransform()(pivotInA)), -m_useSolveConstraintObsolete(false) -{ - -} - -void btPoint2PointConstraint::buildJacobian() -{ - - ///we need it for both methods - { - m_appliedImpulse = btScalar(0.); - - btVector3 normal(0,0,0); - - for (int i=0;i<3;i++) - { - normal[i] = 1; - new (&m_jac[i]) btJacobianEntry( - m_rbA.getCenterOfMassTransform().getBasis().transpose(), - m_rbB.getCenterOfMassTransform().getBasis().transpose(), - m_rbA.getCenterOfMassTransform()*m_pivotInA - m_rbA.getCenterOfMassPosition(), - m_rbB.getCenterOfMassTransform()*m_pivotInB - m_rbB.getCenterOfMassPosition(), - normal, - m_rbA.getInvInertiaDiagLocal(), - m_rbA.getInvMass(), - m_rbB.getInvInertiaDiagLocal(), - m_rbB.getInvMass()); - normal[i] = 0; - } - } - - -} - -void btPoint2PointConstraint::getInfo1 (btConstraintInfo1* info) -{ - getInfo1NonVirtual(info); -} - -void btPoint2PointConstraint::getInfo1NonVirtual (btConstraintInfo1* info) -{ - if (m_useSolveConstraintObsolete) - { - info->m_numConstraintRows = 0; - info->nub = 0; - } else - { - info->m_numConstraintRows = 3; - info->nub = 3; - } -} - - - - -void btPoint2PointConstraint::getInfo2 (btConstraintInfo2* info) -{ - getInfo2NonVirtual(info, m_rbA.getCenterOfMassTransform(),m_rbB.getCenterOfMassTransform()); -} - -void btPoint2PointConstraint::getInfo2NonVirtual (btConstraintInfo2* info, const btTransform& body0_trans, const btTransform& body1_trans) -{ - btAssert(!m_useSolveConstraintObsolete); - - //retrieve matrices - - // anchor points in global coordinates with respect to body PORs. - - // set jacobian - info->m_J1linearAxis[0] = 1; - info->m_J1linearAxis[info->rowskip+1] = 1; - info->m_J1linearAxis[2*info->rowskip+2] = 1; - - btVector3 a1 = body0_trans.getBasis()*getPivotInA(); - { - btVector3* angular0 = (btVector3*)(info->m_J1angularAxis); - btVector3* angular1 = (btVector3*)(info->m_J1angularAxis+info->rowskip); - btVector3* angular2 = (btVector3*)(info->m_J1angularAxis+2*info->rowskip); - btVector3 a1neg = -a1; - a1neg.getSkewSymmetricMatrix(angular0,angular1,angular2); - } - - /*info->m_J2linearAxis[0] = -1; - info->m_J2linearAxis[s+1] = -1; - info->m_J2linearAxis[2*s+2] = -1; - */ - - btVector3 a2 = body1_trans.getBasis()*getPivotInB(); - - { - btVector3 a2n = -a2; - btVector3* angular0 = (btVector3*)(info->m_J2angularAxis); - btVector3* angular1 = (btVector3*)(info->m_J2angularAxis+info->rowskip); - btVector3* angular2 = (btVector3*)(info->m_J2angularAxis+2*info->rowskip); - a2.getSkewSymmetricMatrix(angular0,angular1,angular2); - } - - - - // set right hand side - btScalar k = info->fps * info->erp; - int j; - - for (j=0; j<3; j++) - { - info->m_constraintError[j*info->rowskip] = k * (a2[j] + body1_trans.getOrigin()[j] - a1[j] - body0_trans.getOrigin()[j]); - //printf("info->m_constraintError[%d]=%f\n",j,info->m_constraintError[j]); - } - - btScalar impulseClamp = m_setting.m_impulseClamp;// - for (j=0; j<3; j++) - { - if (m_setting.m_impulseClamp > 0) - { - info->m_lowerLimit[j*info->rowskip] = -impulseClamp; - info->m_upperLimit[j*info->rowskip] = impulseClamp; - } - } - -} - - -void btPoint2PointConstraint::solveConstraintObsolete(btSolverBody& bodyA,btSolverBody& bodyB,btScalar timeStep) -{ - - if (m_useSolveConstraintObsolete) - { - btVector3 pivotAInW = m_rbA.getCenterOfMassTransform()*m_pivotInA; - btVector3 pivotBInW = m_rbB.getCenterOfMassTransform()*m_pivotInB; - - - btVector3 normal(0,0,0); - - - // btVector3 angvelA = m_rbA.getCenterOfMassTransform().getBasis().transpose() * m_rbA.getAngularVelocity(); - // btVector3 angvelB = m_rbB.getCenterOfMassTransform().getBasis().transpose() * m_rbB.getAngularVelocity(); - - for (int i=0;i<3;i++) - { - normal[i] = 1; - btScalar jacDiagABInv = btScalar(1.) / m_jac[i].getDiagonal(); - - btVector3 rel_pos1 = pivotAInW - m_rbA.getCenterOfMassPosition(); - btVector3 rel_pos2 = pivotBInW - m_rbB.getCenterOfMassPosition(); - //this jacobian entry could be re-used for all iterations - - btVector3 vel1,vel2; - bodyA.getVelocityInLocalPointObsolete(rel_pos1,vel1); - bodyB.getVelocityInLocalPointObsolete(rel_pos2,vel2); - btVector3 vel = vel1 - vel2; - - btScalar rel_vel; - rel_vel = normal.dot(vel); - - /* - //velocity error (first order error) - btScalar rel_vel = m_jac[i].getRelativeVelocity(m_rbA.getLinearVelocity(),angvelA, - m_rbB.getLinearVelocity(),angvelB); - */ - - //positional error (zeroth order error) - btScalar depth = -(pivotAInW - pivotBInW).dot(normal); //this is the error projected on the normal - - btScalar deltaImpulse = depth*m_setting.m_tau/timeStep * jacDiagABInv - m_setting.m_damping * rel_vel * jacDiagABInv; - - btScalar impulseClamp = m_setting.m_impulseClamp; - - const btScalar sum = btScalar(m_appliedImpulse) + deltaImpulse; - if (sum < -impulseClamp) - { - deltaImpulse = -impulseClamp-m_appliedImpulse; - m_appliedImpulse = -impulseClamp; - } - else if (sum > impulseClamp) - { - deltaImpulse = impulseClamp-m_appliedImpulse; - m_appliedImpulse = impulseClamp; - } - else - { - m_appliedImpulse = sum; - } - - - btVector3 impulse_vector = normal * deltaImpulse; - - btVector3 ftorqueAxis1 = rel_pos1.cross(normal); - btVector3 ftorqueAxis2 = rel_pos2.cross(normal); - bodyA.applyImpulse(normal*m_rbA.getInvMass(), m_rbA.getInvInertiaTensorWorld()*ftorqueAxis1,deltaImpulse); - bodyB.applyImpulse(normal*m_rbB.getInvMass(), m_rbB.getInvInertiaTensorWorld()*ftorqueAxis2,-deltaImpulse); - - - normal[i] = 0; - } - } - -} - -void btPoint2PointConstraint::updateRHS(btScalar timeStep) -{ - (void)timeStep; - -} - diff --git a/bullet/src/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h b/bullet/src/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h deleted file mode 100644 index e9598b832..000000000 --- a/bullet/src/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h +++ /dev/null @@ -1,101 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef POINT2POINTCONSTRAINT_H -#define POINT2POINTCONSTRAINT_H - -#include "LinearMath/btVector3.h" -#include "btJacobianEntry.h" -#include "btTypedConstraint.h" - -class btRigidBody; - -struct btConstraintSetting -{ - btConstraintSetting() : - m_tau(btScalar(0.3)), - m_damping(btScalar(1.)), - m_impulseClamp(btScalar(0.)) - { - } - btScalar m_tau; - btScalar m_damping; - btScalar m_impulseClamp; -}; - -/// point to point constraint between two rigidbodies each with a pivotpoint that descibes the 'ballsocket' location in local space -ATTRIBUTE_ALIGNED16(class) btPoint2PointConstraint : public btTypedConstraint -{ -#ifdef IN_PARALLELL_SOLVER -public: -#endif - btJacobianEntry m_jac[3]; //3 orthogonal linear constraints - - btVector3 m_pivotInA; - btVector3 m_pivotInB; - - - -public: - - ///for backwards compatibility during the transition to 'getInfo/getInfo2' - bool m_useSolveConstraintObsolete; - - btConstraintSetting m_setting; - - btPoint2PointConstraint(btRigidBody& rbA,btRigidBody& rbB, const btVector3& pivotInA,const btVector3& pivotInB); - - btPoint2PointConstraint(btRigidBody& rbA,const btVector3& pivotInA); - - btPoint2PointConstraint(); - - virtual void buildJacobian(); - - virtual void getInfo1 (btConstraintInfo1* info); - - void getInfo1NonVirtual (btConstraintInfo1* info); - - virtual void getInfo2 (btConstraintInfo2* info); - - void getInfo2NonVirtual (btConstraintInfo2* info, const btTransform& body0_trans, const btTransform& body1_trans); - - virtual void solveConstraintObsolete(btSolverBody& bodyA,btSolverBody& bodyB,btScalar timeStep); - - void updateRHS(btScalar timeStep); - - void setPivotA(const btVector3& pivotA) - { - m_pivotInA = pivotA; - } - - void setPivotB(const btVector3& pivotB) - { - m_pivotInB = pivotB; - } - - const btVector3& getPivotInA() const - { - return m_pivotInA; - } - - const btVector3& getPivotInB() const - { - return m_pivotInB; - } - - -}; - -#endif //POINT2POINTCONSTRAINT_H diff --git a/bullet/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp b/bullet/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp deleted file mode 100644 index 75f6f513f..000000000 --- a/bullet/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp +++ /dev/null @@ -1,1159 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -//#define COMPUTE_IMPULSE_DENOM 1 -//It is not necessary (redundant) to refresh contact manifolds, this refresh has been moved to the collision algorithms. - -#include "btSequentialImpulseConstraintSolver.h" -#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h" -#include "BulletDynamics/Dynamics/btRigidBody.h" -#include "btContactConstraint.h" -#include "btSolve2LinearConstraint.h" -#include "btContactSolverInfo.h" -#include "LinearMath/btIDebugDraw.h" -#include "btJacobianEntry.h" -#include "LinearMath/btMinMax.h" -#include "BulletDynamics/ConstraintSolver/btTypedConstraint.h" -#include -#include "LinearMath/btStackAlloc.h" -#include "LinearMath/btQuickprof.h" -#include "btSolverBody.h" -#include "btSolverConstraint.h" -#include "LinearMath/btAlignedObjectArray.h" -#include //for memset - -int gNumSplitImpulseRecoveries = 0; - -btSequentialImpulseConstraintSolver::btSequentialImpulseConstraintSolver() -:m_btSeed2(0) -{ - -} - -btSequentialImpulseConstraintSolver::~btSequentialImpulseConstraintSolver() -{ -} - -#ifdef USE_SIMD -#include -#define vec_splat(x, e) _mm_shuffle_ps(x, x, _MM_SHUFFLE(e,e,e,e)) -static inline __m128 _vmathVfDot3( __m128 vec0, __m128 vec1 ) -{ - __m128 result = _mm_mul_ps( vec0, vec1); - return _mm_add_ps( vec_splat( result, 0 ), _mm_add_ps( vec_splat( result, 1 ), vec_splat( result, 2 ) ) ); -} -#endif//USE_SIMD - -// Project Gauss Seidel or the equivalent Sequential Impulse -void btSequentialImpulseConstraintSolver::resolveSingleConstraintRowGenericSIMD(btSolverBody& body1,btSolverBody& body2,const btSolverConstraint& c) -{ -#ifdef USE_SIMD - __m128 cpAppliedImp = _mm_set1_ps(c.m_appliedImpulse); - __m128 lowerLimit1 = _mm_set1_ps(c.m_lowerLimit); - __m128 upperLimit1 = _mm_set1_ps(c.m_upperLimit); - __m128 deltaImpulse = _mm_sub_ps(_mm_set1_ps(c.m_rhs), _mm_mul_ps(_mm_set1_ps(c.m_appliedImpulse),_mm_set1_ps(c.m_cfm))); - __m128 deltaVel1Dotn = _mm_add_ps(_vmathVfDot3(c.m_contactNormal.mVec128,body1.m_deltaLinearVelocity.mVec128), _vmathVfDot3(c.m_relpos1CrossNormal.mVec128,body1.m_deltaAngularVelocity.mVec128)); - __m128 deltaVel2Dotn = _mm_sub_ps(_vmathVfDot3(c.m_relpos2CrossNormal.mVec128,body2.m_deltaAngularVelocity.mVec128),_vmathVfDot3((c.m_contactNormal).mVec128,body2.m_deltaLinearVelocity.mVec128)); - deltaImpulse = _mm_sub_ps(deltaImpulse,_mm_mul_ps(deltaVel1Dotn,_mm_set1_ps(c.m_jacDiagABInv))); - deltaImpulse = _mm_sub_ps(deltaImpulse,_mm_mul_ps(deltaVel2Dotn,_mm_set1_ps(c.m_jacDiagABInv))); - btSimdScalar sum = _mm_add_ps(cpAppliedImp,deltaImpulse); - btSimdScalar resultLowerLess,resultUpperLess; - resultLowerLess = _mm_cmplt_ps(sum,lowerLimit1); - resultUpperLess = _mm_cmplt_ps(sum,upperLimit1); - __m128 lowMinApplied = _mm_sub_ps(lowerLimit1,cpAppliedImp); - deltaImpulse = _mm_or_ps( _mm_and_ps(resultLowerLess, lowMinApplied), _mm_andnot_ps(resultLowerLess, deltaImpulse) ); - c.m_appliedImpulse = _mm_or_ps( _mm_and_ps(resultLowerLess, lowerLimit1), _mm_andnot_ps(resultLowerLess, sum) ); - __m128 upperMinApplied = _mm_sub_ps(upperLimit1,cpAppliedImp); - deltaImpulse = _mm_or_ps( _mm_and_ps(resultUpperLess, deltaImpulse), _mm_andnot_ps(resultUpperLess, upperMinApplied) ); - c.m_appliedImpulse = _mm_or_ps( _mm_and_ps(resultUpperLess, c.m_appliedImpulse), _mm_andnot_ps(resultUpperLess, upperLimit1) ); - __m128 linearComponentA = _mm_mul_ps(c.m_contactNormal.mVec128,body1.m_invMass.mVec128); - __m128 linearComponentB = _mm_mul_ps((c.m_contactNormal).mVec128,body2.m_invMass.mVec128); - __m128 impulseMagnitude = deltaImpulse; - body1.m_deltaLinearVelocity.mVec128 = _mm_add_ps(body1.m_deltaLinearVelocity.mVec128,_mm_mul_ps(linearComponentA,impulseMagnitude)); - body1.m_deltaAngularVelocity.mVec128 = _mm_add_ps(body1.m_deltaAngularVelocity.mVec128 ,_mm_mul_ps(c.m_angularComponentA.mVec128,impulseMagnitude)); - body2.m_deltaLinearVelocity.mVec128 = _mm_sub_ps(body2.m_deltaLinearVelocity.mVec128,_mm_mul_ps(linearComponentB,impulseMagnitude)); - body2.m_deltaAngularVelocity.mVec128 = _mm_add_ps(body2.m_deltaAngularVelocity.mVec128 ,_mm_mul_ps(c.m_angularComponentB.mVec128,impulseMagnitude)); -#else - resolveSingleConstraintRowGeneric(body1,body2,c); -#endif -} - -// Project Gauss Seidel or the equivalent Sequential Impulse - void btSequentialImpulseConstraintSolver::resolveSingleConstraintRowGeneric(btSolverBody& body1,btSolverBody& body2,const btSolverConstraint& c) -{ - btScalar deltaImpulse = c.m_rhs-btScalar(c.m_appliedImpulse)*c.m_cfm; - const btScalar deltaVel1Dotn = c.m_contactNormal.dot(body1.m_deltaLinearVelocity) + c.m_relpos1CrossNormal.dot(body1.m_deltaAngularVelocity); - const btScalar deltaVel2Dotn = -c.m_contactNormal.dot(body2.m_deltaLinearVelocity) + c.m_relpos2CrossNormal.dot(body2.m_deltaAngularVelocity); - -// const btScalar delta_rel_vel = deltaVel1Dotn-deltaVel2Dotn; - deltaImpulse -= deltaVel1Dotn*c.m_jacDiagABInv; - deltaImpulse -= deltaVel2Dotn*c.m_jacDiagABInv; - - const btScalar sum = btScalar(c.m_appliedImpulse) + deltaImpulse; - if (sum < c.m_lowerLimit) - { - deltaImpulse = c.m_lowerLimit-c.m_appliedImpulse; - c.m_appliedImpulse = c.m_lowerLimit; - } - else if (sum > c.m_upperLimit) - { - deltaImpulse = c.m_upperLimit-c.m_appliedImpulse; - c.m_appliedImpulse = c.m_upperLimit; - } - else - { - c.m_appliedImpulse = sum; - } - body1.applyImpulse(c.m_contactNormal*body1.m_invMass,c.m_angularComponentA,deltaImpulse); - body2.applyImpulse(-c.m_contactNormal*body2.m_invMass,c.m_angularComponentB,deltaImpulse); -} - - void btSequentialImpulseConstraintSolver::resolveSingleConstraintRowLowerLimitSIMD(btSolverBody& body1,btSolverBody& body2,const btSolverConstraint& c) -{ -#ifdef USE_SIMD - __m128 cpAppliedImp = _mm_set1_ps(c.m_appliedImpulse); - __m128 lowerLimit1 = _mm_set1_ps(c.m_lowerLimit); - __m128 upperLimit1 = _mm_set1_ps(c.m_upperLimit); - __m128 deltaImpulse = _mm_sub_ps(_mm_set1_ps(c.m_rhs), _mm_mul_ps(_mm_set1_ps(c.m_appliedImpulse),_mm_set1_ps(c.m_cfm))); - __m128 deltaVel1Dotn = _mm_add_ps(_vmathVfDot3(c.m_contactNormal.mVec128,body1.m_deltaLinearVelocity.mVec128), _vmathVfDot3(c.m_relpos1CrossNormal.mVec128,body1.m_deltaAngularVelocity.mVec128)); - __m128 deltaVel2Dotn = _mm_sub_ps(_vmathVfDot3(c.m_relpos2CrossNormal.mVec128,body2.m_deltaAngularVelocity.mVec128),_vmathVfDot3((c.m_contactNormal).mVec128,body2.m_deltaLinearVelocity.mVec128)); - deltaImpulse = _mm_sub_ps(deltaImpulse,_mm_mul_ps(deltaVel1Dotn,_mm_set1_ps(c.m_jacDiagABInv))); - deltaImpulse = _mm_sub_ps(deltaImpulse,_mm_mul_ps(deltaVel2Dotn,_mm_set1_ps(c.m_jacDiagABInv))); - btSimdScalar sum = _mm_add_ps(cpAppliedImp,deltaImpulse); - btSimdScalar resultLowerLess,resultUpperLess; - resultLowerLess = _mm_cmplt_ps(sum,lowerLimit1); - resultUpperLess = _mm_cmplt_ps(sum,upperLimit1); - __m128 lowMinApplied = _mm_sub_ps(lowerLimit1,cpAppliedImp); - deltaImpulse = _mm_or_ps( _mm_and_ps(resultLowerLess, lowMinApplied), _mm_andnot_ps(resultLowerLess, deltaImpulse) ); - c.m_appliedImpulse = _mm_or_ps( _mm_and_ps(resultLowerLess, lowerLimit1), _mm_andnot_ps(resultLowerLess, sum) ); - __m128 linearComponentA = _mm_mul_ps(c.m_contactNormal.mVec128,body1.m_invMass.mVec128); - __m128 linearComponentB = _mm_mul_ps((c.m_contactNormal).mVec128,body2.m_invMass.mVec128); - __m128 impulseMagnitude = deltaImpulse; - body1.m_deltaLinearVelocity.mVec128 = _mm_add_ps(body1.m_deltaLinearVelocity.mVec128,_mm_mul_ps(linearComponentA,impulseMagnitude)); - body1.m_deltaAngularVelocity.mVec128 = _mm_add_ps(body1.m_deltaAngularVelocity.mVec128 ,_mm_mul_ps(c.m_angularComponentA.mVec128,impulseMagnitude)); - body2.m_deltaLinearVelocity.mVec128 = _mm_sub_ps(body2.m_deltaLinearVelocity.mVec128,_mm_mul_ps(linearComponentB,impulseMagnitude)); - body2.m_deltaAngularVelocity.mVec128 = _mm_add_ps(body2.m_deltaAngularVelocity.mVec128 ,_mm_mul_ps(c.m_angularComponentB.mVec128,impulseMagnitude)); -#else - resolveSingleConstraintRowLowerLimit(body1,body2,c); -#endif -} - -// Project Gauss Seidel or the equivalent Sequential Impulse - void btSequentialImpulseConstraintSolver::resolveSingleConstraintRowLowerLimit(btSolverBody& body1,btSolverBody& body2,const btSolverConstraint& c) -{ - btScalar deltaImpulse = c.m_rhs-btScalar(c.m_appliedImpulse)*c.m_cfm; - const btScalar deltaVel1Dotn = c.m_contactNormal.dot(body1.m_deltaLinearVelocity) + c.m_relpos1CrossNormal.dot(body1.m_deltaAngularVelocity); - const btScalar deltaVel2Dotn = -c.m_contactNormal.dot(body2.m_deltaLinearVelocity) + c.m_relpos2CrossNormal.dot(body2.m_deltaAngularVelocity); - - deltaImpulse -= deltaVel1Dotn*c.m_jacDiagABInv; - deltaImpulse -= deltaVel2Dotn*c.m_jacDiagABInv; - const btScalar sum = btScalar(c.m_appliedImpulse) + deltaImpulse; - if (sum < c.m_lowerLimit) - { - deltaImpulse = c.m_lowerLimit-c.m_appliedImpulse; - c.m_appliedImpulse = c.m_lowerLimit; - } - else - { - c.m_appliedImpulse = sum; - } - body1.applyImpulse(c.m_contactNormal*body1.m_invMass,c.m_angularComponentA,deltaImpulse); - body2.applyImpulse(-c.m_contactNormal*body2.m_invMass,c.m_angularComponentB,deltaImpulse); -} - - -void btSequentialImpulseConstraintSolver::resolveSplitPenetrationImpulseCacheFriendly( - btSolverBody& body1, - btSolverBody& body2, - const btSolverConstraint& c) -{ - if (c.m_rhsPenetration) - { - gNumSplitImpulseRecoveries++; - btScalar deltaImpulse = c.m_rhsPenetration-btScalar(c.m_appliedPushImpulse)*c.m_cfm; - const btScalar deltaVel1Dotn = c.m_contactNormal.dot(body1.m_pushVelocity) + c.m_relpos1CrossNormal.dot(body1.m_turnVelocity); - const btScalar deltaVel2Dotn = -c.m_contactNormal.dot(body2.m_pushVelocity) + c.m_relpos2CrossNormal.dot(body2.m_turnVelocity); - - deltaImpulse -= deltaVel1Dotn*c.m_jacDiagABInv; - deltaImpulse -= deltaVel2Dotn*c.m_jacDiagABInv; - const btScalar sum = btScalar(c.m_appliedPushImpulse) + deltaImpulse; - if (sum < c.m_lowerLimit) - { - deltaImpulse = c.m_lowerLimit-c.m_appliedPushImpulse; - c.m_appliedPushImpulse = c.m_lowerLimit; - } - else - { - c.m_appliedPushImpulse = sum; - } - body1.internalApplyPushImpulse(c.m_contactNormal*body1.m_invMass,c.m_angularComponentA,deltaImpulse); - body2.internalApplyPushImpulse(-c.m_contactNormal*body2.m_invMass,c.m_angularComponentB,deltaImpulse); - } -} - - void btSequentialImpulseConstraintSolver::resolveSplitPenetrationSIMD(btSolverBody& body1,btSolverBody& body2,const btSolverConstraint& c) -{ -#ifdef USE_SIMD - if (!c.m_rhsPenetration) - return; - - gNumSplitImpulseRecoveries++; - - __m128 cpAppliedImp = _mm_set1_ps(c.m_appliedPushImpulse); - __m128 lowerLimit1 = _mm_set1_ps(c.m_lowerLimit); - __m128 upperLimit1 = _mm_set1_ps(c.m_upperLimit); - __m128 deltaImpulse = _mm_sub_ps(_mm_set1_ps(c.m_rhsPenetration), _mm_mul_ps(_mm_set1_ps(c.m_appliedPushImpulse),_mm_set1_ps(c.m_cfm))); - __m128 deltaVel1Dotn = _mm_add_ps(_vmathVfDot3(c.m_contactNormal.mVec128,body1.m_pushVelocity.mVec128), _vmathVfDot3(c.m_relpos1CrossNormal.mVec128,body1.m_turnVelocity.mVec128)); - __m128 deltaVel2Dotn = _mm_sub_ps(_vmathVfDot3(c.m_relpos2CrossNormal.mVec128,body2.m_turnVelocity.mVec128),_vmathVfDot3((c.m_contactNormal).mVec128,body2.m_pushVelocity.mVec128)); - deltaImpulse = _mm_sub_ps(deltaImpulse,_mm_mul_ps(deltaVel1Dotn,_mm_set1_ps(c.m_jacDiagABInv))); - deltaImpulse = _mm_sub_ps(deltaImpulse,_mm_mul_ps(deltaVel2Dotn,_mm_set1_ps(c.m_jacDiagABInv))); - btSimdScalar sum = _mm_add_ps(cpAppliedImp,deltaImpulse); - btSimdScalar resultLowerLess,resultUpperLess; - resultLowerLess = _mm_cmplt_ps(sum,lowerLimit1); - resultUpperLess = _mm_cmplt_ps(sum,upperLimit1); - __m128 lowMinApplied = _mm_sub_ps(lowerLimit1,cpAppliedImp); - deltaImpulse = _mm_or_ps( _mm_and_ps(resultLowerLess, lowMinApplied), _mm_andnot_ps(resultLowerLess, deltaImpulse) ); - c.m_appliedImpulse = _mm_or_ps( _mm_and_ps(resultLowerLess, lowerLimit1), _mm_andnot_ps(resultLowerLess, sum) ); - __m128 linearComponentA = _mm_mul_ps(c.m_contactNormal.mVec128,body1.m_invMass.mVec128); - __m128 linearComponentB = _mm_mul_ps((c.m_contactNormal).mVec128,body2.m_invMass.mVec128); - __m128 impulseMagnitude = deltaImpulse; - body1.m_pushVelocity.mVec128 = _mm_add_ps(body1.m_pushVelocity.mVec128,_mm_mul_ps(linearComponentA,impulseMagnitude)); - body1.m_turnVelocity.mVec128 = _mm_add_ps(body1.m_turnVelocity.mVec128 ,_mm_mul_ps(c.m_angularComponentA.mVec128,impulseMagnitude)); - body2.m_pushVelocity.mVec128 = _mm_sub_ps(body2.m_pushVelocity.mVec128,_mm_mul_ps(linearComponentB,impulseMagnitude)); - body2.m_turnVelocity.mVec128 = _mm_add_ps(body2.m_turnVelocity.mVec128 ,_mm_mul_ps(c.m_angularComponentB.mVec128,impulseMagnitude)); -#else - resolveSplitPenetrationImpulseCacheFriendly(body1,body2,c); -#endif -} - - - -unsigned long btSequentialImpulseConstraintSolver::btRand2() -{ - m_btSeed2 = (1664525L*m_btSeed2 + 1013904223L) & 0xffffffff; - return m_btSeed2; -} - - - -//See ODE: adam's all-int straightforward(?) dRandInt (0..n-1) -int btSequentialImpulseConstraintSolver::btRandInt2 (int n) -{ - // seems good; xor-fold and modulus - const unsigned long un = static_cast(n); - unsigned long r = btRand2(); - - // note: probably more aggressive than it needs to be -- might be - // able to get away without one or two of the innermost branches. - if (un <= 0x00010000UL) { - r ^= (r >> 16); - if (un <= 0x00000100UL) { - r ^= (r >> 8); - if (un <= 0x00000010UL) { - r ^= (r >> 4); - if (un <= 0x00000004UL) { - r ^= (r >> 2); - if (un <= 0x00000002UL) { - r ^= (r >> 1); - } - } - } - } - } - - return (int) (r % un); -} - - - -void btSequentialImpulseConstraintSolver::initSolverBody(btSolverBody* solverBody, btCollisionObject* collisionObject) -{ - btRigidBody* rb = collisionObject? btRigidBody::upcast(collisionObject) : 0; - - solverBody->m_deltaLinearVelocity.setValue(0.f,0.f,0.f); - solverBody->m_deltaAngularVelocity.setValue(0.f,0.f,0.f); - solverBody->m_pushVelocity.setValue(0.f,0.f,0.f); - solverBody->m_turnVelocity.setValue(0.f,0.f,0.f); - - if (rb) - { - solverBody->m_invMass = btVector3(rb->getInvMass(),rb->getInvMass(),rb->getInvMass())*rb->getLinearFactor(); - solverBody->m_originalBody = rb; - solverBody->m_angularFactor = rb->getAngularFactor(); - } else - { - solverBody->m_invMass.setValue(0,0,0); - solverBody->m_originalBody = 0; - solverBody->m_angularFactor.setValue(1,1,1); - } -} - - - - - -btScalar btSequentialImpulseConstraintSolver::restitutionCurve(btScalar rel_vel, btScalar restitution) -{ - btScalar rest = restitution * -rel_vel; - return rest; -} - - - -void applyAnisotropicFriction(btCollisionObject* colObj,btVector3& frictionDirection); -void applyAnisotropicFriction(btCollisionObject* colObj,btVector3& frictionDirection) -{ - if (colObj && colObj->hasAnisotropicFriction()) - { - // transform to local coordinates - btVector3 loc_lateral = frictionDirection * colObj->getWorldTransform().getBasis(); - const btVector3& friction_scaling = colObj->getAnisotropicFriction(); - //apply anisotropic friction - loc_lateral *= friction_scaling; - // ... and transform it back to global coordinates - frictionDirection = colObj->getWorldTransform().getBasis() * loc_lateral; - } -} - - - -btSolverConstraint& btSequentialImpulseConstraintSolver::addFrictionConstraint(const btVector3& normalAxis,int solverBodyIdA,int solverBodyIdB,int frictionIndex,btManifoldPoint& cp,const btVector3& rel_pos1,const btVector3& rel_pos2,btCollisionObject* colObj0,btCollisionObject* colObj1, btScalar relaxation, btScalar desiredVelocity, btScalar cfmSlip) -{ - - - btRigidBody* body0=btRigidBody::upcast(colObj0); - btRigidBody* body1=btRigidBody::upcast(colObj1); - - btSolverConstraint& solverConstraint = m_tmpSolverContactFrictionConstraintPool.expand(); - memset(&solverConstraint,0xff,sizeof(btSolverConstraint)); - solverConstraint.m_contactNormal = normalAxis; - - solverConstraint.m_solverBodyIdA = solverBodyIdA; - solverConstraint.m_solverBodyIdB = solverBodyIdB; - solverConstraint.m_frictionIndex = frictionIndex; - - solverConstraint.m_friction = cp.m_combinedFriction; - solverConstraint.m_originalContactPoint = 0; - - solverConstraint.m_appliedImpulse = 0.f; - solverConstraint.m_appliedPushImpulse = 0.f; - - { - btVector3 ftorqueAxis1 = rel_pos1.cross(solverConstraint.m_contactNormal); - solverConstraint.m_relpos1CrossNormal = ftorqueAxis1; - solverConstraint.m_angularComponentA = body0 ? body0->getInvInertiaTensorWorld()*ftorqueAxis1*body0->getAngularFactor() : btVector3(0,0,0); - } - { - btVector3 ftorqueAxis1 = rel_pos2.cross(-solverConstraint.m_contactNormal); - solverConstraint.m_relpos2CrossNormal = ftorqueAxis1; - solverConstraint.m_angularComponentB = body1 ? body1->getInvInertiaTensorWorld()*ftorqueAxis1*body1->getAngularFactor() : btVector3(0,0,0); - } - -#ifdef COMPUTE_IMPULSE_DENOM - btScalar denom0 = rb0->computeImpulseDenominator(pos1,solverConstraint.m_contactNormal); - btScalar denom1 = rb1->computeImpulseDenominator(pos2,solverConstraint.m_contactNormal); -#else - btVector3 vec; - btScalar denom0 = 0.f; - btScalar denom1 = 0.f; - if (body0) - { - vec = ( solverConstraint.m_angularComponentA).cross(rel_pos1); - denom0 = body0->getInvMass() + normalAxis.dot(vec); - } - if (body1) - { - vec = ( -solverConstraint.m_angularComponentB).cross(rel_pos2); - denom1 = body1->getInvMass() + normalAxis.dot(vec); - } - - -#endif //COMPUTE_IMPULSE_DENOM - btScalar denom = relaxation/(denom0+denom1); - solverConstraint.m_jacDiagABInv = denom; - -#ifdef _USE_JACOBIAN - solverConstraint.m_jac = btJacobianEntry ( - rel_pos1,rel_pos2,solverConstraint.m_contactNormal, - body0->getInvInertiaDiagLocal(), - body0->getInvMass(), - body1->getInvInertiaDiagLocal(), - body1->getInvMass()); -#endif //_USE_JACOBIAN - - - { - btScalar rel_vel; - btScalar vel1Dotn = solverConstraint.m_contactNormal.dot(body0?body0->getLinearVelocity():btVector3(0,0,0)) - + solverConstraint.m_relpos1CrossNormal.dot(body0?body0->getAngularVelocity():btVector3(0,0,0)); - btScalar vel2Dotn = -solverConstraint.m_contactNormal.dot(body1?body1->getLinearVelocity():btVector3(0,0,0)) - + solverConstraint.m_relpos2CrossNormal.dot(body1?body1->getAngularVelocity():btVector3(0,0,0)); - - rel_vel = vel1Dotn+vel2Dotn; - -// btScalar positionalError = 0.f; - - btSimdScalar velocityError = desiredVelocity - rel_vel; - btSimdScalar velocityImpulse = velocityError * btSimdScalar(solverConstraint.m_jacDiagABInv); - solverConstraint.m_rhs = velocityImpulse; - solverConstraint.m_cfm = cfmSlip; - solverConstraint.m_lowerLimit = 0; - solverConstraint.m_upperLimit = 1e10f; - } - - return solverConstraint; -} - -int btSequentialImpulseConstraintSolver::getOrInitSolverBody(btCollisionObject& body) -{ - int solverBodyIdA = -1; - - if (body.getCompanionId() >= 0) - { - //body has already been converted - solverBodyIdA = body.getCompanionId(); - } else - { - btRigidBody* rb = btRigidBody::upcast(&body); - if (rb && rb->getInvMass()) - { - solverBodyIdA = m_tmpSolverBodyPool.size(); - btSolverBody& solverBody = m_tmpSolverBodyPool.expand(); - initSolverBody(&solverBody,&body); - body.setCompanionId(solverBodyIdA); - } else - { - return 0;//assume first one is a fixed solver body - } - } - return solverBodyIdA; -} -#include - - - -void btSequentialImpulseConstraintSolver::convertContact(btPersistentManifold* manifold,const btContactSolverInfo& infoGlobal) -{ - btCollisionObject* colObj0=0,*colObj1=0; - - colObj0 = (btCollisionObject*)manifold->getBody0(); - colObj1 = (btCollisionObject*)manifold->getBody1(); - - int solverBodyIdA=-1; - int solverBodyIdB=-1; - - if (manifold->getNumContacts()) - { - solverBodyIdA = getOrInitSolverBody(*colObj0); - solverBodyIdB = getOrInitSolverBody(*colObj1); - } - - ///avoid collision response between two static objects - if (!solverBodyIdA && !solverBodyIdB) - return; - - btVector3 rel_pos1; - btVector3 rel_pos2; - btScalar relaxation; - - for (int j=0;jgetNumContacts();j++) - { - - btManifoldPoint& cp = manifold->getContactPoint(j); - - if (cp.getDistance() <= manifold->getContactProcessingThreshold()) - { - - const btVector3& pos1 = cp.getPositionWorldOnA(); - const btVector3& pos2 = cp.getPositionWorldOnB(); - - rel_pos1 = pos1 - colObj0->getWorldTransform().getOrigin(); - rel_pos2 = pos2 - colObj1->getWorldTransform().getOrigin(); - - - relaxation = 1.f; - btScalar rel_vel; - btVector3 vel; - - int frictionIndex = m_tmpSolverContactConstraintPool.size(); - - { - btSolverConstraint& solverConstraint = m_tmpSolverContactConstraintPool.expand(); - btRigidBody* rb0 = btRigidBody::upcast(colObj0); - btRigidBody* rb1 = btRigidBody::upcast(colObj1); - - solverConstraint.m_solverBodyIdA = solverBodyIdA; - solverConstraint.m_solverBodyIdB = solverBodyIdB; - - solverConstraint.m_originalContactPoint = &cp; - - btVector3 torqueAxis0 = rel_pos1.cross(cp.m_normalWorldOnB); - solverConstraint.m_angularComponentA = rb0 ? rb0->getInvInertiaTensorWorld()*torqueAxis0*rb0->getAngularFactor() : btVector3(0,0,0); - btVector3 torqueAxis1 = rel_pos2.cross(cp.m_normalWorldOnB); - solverConstraint.m_angularComponentB = rb1 ? rb1->getInvInertiaTensorWorld()*-torqueAxis1*rb1->getAngularFactor() : btVector3(0,0,0); - { -#ifdef COMPUTE_IMPULSE_DENOM - btScalar denom0 = rb0->computeImpulseDenominator(pos1,cp.m_normalWorldOnB); - btScalar denom1 = rb1->computeImpulseDenominator(pos2,cp.m_normalWorldOnB); -#else - btVector3 vec; - btScalar denom0 = 0.f; - btScalar denom1 = 0.f; - if (rb0) - { - vec = ( solverConstraint.m_angularComponentA).cross(rel_pos1); - denom0 = rb0->getInvMass() + cp.m_normalWorldOnB.dot(vec); - } - if (rb1) - { - vec = ( -solverConstraint.m_angularComponentB).cross(rel_pos2); - denom1 = rb1->getInvMass() + cp.m_normalWorldOnB.dot(vec); - } -#endif //COMPUTE_IMPULSE_DENOM - - btScalar denom = relaxation/(denom0+denom1); - solverConstraint.m_jacDiagABInv = denom; - } - - solverConstraint.m_contactNormal = cp.m_normalWorldOnB; - solverConstraint.m_relpos1CrossNormal = rel_pos1.cross(cp.m_normalWorldOnB); - solverConstraint.m_relpos2CrossNormal = rel_pos2.cross(-cp.m_normalWorldOnB); - - - btVector3 vel1 = rb0 ? rb0->getVelocityInLocalPoint(rel_pos1) : btVector3(0,0,0); - btVector3 vel2 = rb1 ? rb1->getVelocityInLocalPoint(rel_pos2) : btVector3(0,0,0); - - vel = vel1 - vel2; - - rel_vel = cp.m_normalWorldOnB.dot(vel); - - btScalar penetration = cp.getDistance()+infoGlobal.m_linearSlop; - - - solverConstraint.m_friction = cp.m_combinedFriction; - - btScalar restitution = 0.f; - - if (cp.m_lifeTime>infoGlobal.m_restingContactRestitutionThreshold) - { - restitution = 0.f; - } else - { - restitution = restitutionCurve(rel_vel, cp.m_combinedRestitution); - if (restitution <= btScalar(0.)) - { - restitution = 0.f; - }; - } - - - ///warm starting (or zero if disabled) - if (infoGlobal.m_solverMode & SOLVER_USE_WARMSTARTING) - { - solverConstraint.m_appliedImpulse = cp.m_appliedImpulse * infoGlobal.m_warmstartingFactor; - if (rb0) - m_tmpSolverBodyPool[solverConstraint.m_solverBodyIdA].applyImpulse(solverConstraint.m_contactNormal*rb0->getInvMass()*rb0->getLinearFactor(),solverConstraint.m_angularComponentA,solverConstraint.m_appliedImpulse); - if (rb1) - m_tmpSolverBodyPool[solverConstraint.m_solverBodyIdB].applyImpulse(solverConstraint.m_contactNormal*rb1->getInvMass()*rb1->getLinearFactor(),-solverConstraint.m_angularComponentB,-solverConstraint.m_appliedImpulse); - } else - { - solverConstraint.m_appliedImpulse = 0.f; - } - - solverConstraint.m_appliedPushImpulse = 0.f; - - { - btScalar rel_vel; - btScalar vel1Dotn = solverConstraint.m_contactNormal.dot(rb0?rb0->getLinearVelocity():btVector3(0,0,0)) - + solverConstraint.m_relpos1CrossNormal.dot(rb0?rb0->getAngularVelocity():btVector3(0,0,0)); - btScalar vel2Dotn = -solverConstraint.m_contactNormal.dot(rb1?rb1->getLinearVelocity():btVector3(0,0,0)) - + solverConstraint.m_relpos2CrossNormal.dot(rb1?rb1->getAngularVelocity():btVector3(0,0,0)); - - rel_vel = vel1Dotn+vel2Dotn; - - btScalar positionalError = 0.f; - positionalError = -penetration * infoGlobal.m_erp/infoGlobal.m_timeStep; - btScalar velocityError = restitution - rel_vel;// * damping; - btScalar penetrationImpulse = positionalError*solverConstraint.m_jacDiagABInv; - btScalar velocityImpulse = velocityError *solverConstraint.m_jacDiagABInv; - if (!infoGlobal.m_splitImpulse || (penetration > infoGlobal.m_splitImpulsePenetrationThreshold)) - { - //combine position and velocity into rhs - solverConstraint.m_rhs = penetrationImpulse+velocityImpulse; - solverConstraint.m_rhsPenetration = 0.f; - } else - { - //split position and velocity into rhs and m_rhsPenetration - solverConstraint.m_rhs = velocityImpulse; - solverConstraint.m_rhsPenetration = penetrationImpulse; - } - solverConstraint.m_cfm = 0.f; - solverConstraint.m_lowerLimit = 0; - solverConstraint.m_upperLimit = 1e10f; - } - - - /////setup the friction constraints - - - - if (1) - { - solverConstraint.m_frictionIndex = m_tmpSolverContactFrictionConstraintPool.size(); - if (!(infoGlobal.m_solverMode & SOLVER_ENABLE_FRICTION_DIRECTION_CACHING) || !cp.m_lateralFrictionInitialized) - { - cp.m_lateralFrictionDir1 = vel - cp.m_normalWorldOnB * rel_vel; - btScalar lat_rel_vel = cp.m_lateralFrictionDir1.length2(); - if (!(infoGlobal.m_solverMode & SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION) && lat_rel_vel > SIMD_EPSILON) - { - cp.m_lateralFrictionDir1 /= btSqrt(lat_rel_vel); - if((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)) - { - cp.m_lateralFrictionDir2 = cp.m_lateralFrictionDir1.cross(cp.m_normalWorldOnB); - cp.m_lateralFrictionDir2.normalize();//?? - applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir2); - applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir2); - addFrictionConstraint(cp.m_lateralFrictionDir2,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); - } - - applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir1); - applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir1); - addFrictionConstraint(cp.m_lateralFrictionDir1,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); - cp.m_lateralFrictionInitialized = true; - } else - { - //re-calculate friction direction every frame, todo: check if this is really needed - btPlaneSpace1(cp.m_normalWorldOnB,cp.m_lateralFrictionDir1,cp.m_lateralFrictionDir2); - if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)) - { - applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir2); - applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir2); - addFrictionConstraint(cp.m_lateralFrictionDir2,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); - } - - applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir1); - applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir1); - addFrictionConstraint(cp.m_lateralFrictionDir1,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); - - cp.m_lateralFrictionInitialized = true; - } - - } else - { - addFrictionConstraint(cp.m_lateralFrictionDir1,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation,cp.m_contactMotion1, cp.m_contactCFM1); - if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)) - addFrictionConstraint(cp.m_lateralFrictionDir2,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation, cp.m_contactMotion2, cp.m_contactCFM2); - } - - if (infoGlobal.m_solverMode & SOLVER_USE_FRICTION_WARMSTARTING) - { - { - btSolverConstraint& frictionConstraint1 = m_tmpSolverContactFrictionConstraintPool[solverConstraint.m_frictionIndex]; - if (infoGlobal.m_solverMode & SOLVER_USE_WARMSTARTING) - { - frictionConstraint1.m_appliedImpulse = cp.m_appliedImpulseLateral1 * infoGlobal.m_warmstartingFactor; - if (rb0) - m_tmpSolverBodyPool[solverConstraint.m_solverBodyIdA].applyImpulse(frictionConstraint1.m_contactNormal*rb0->getInvMass()*rb0->getLinearFactor(),frictionConstraint1.m_angularComponentA,frictionConstraint1.m_appliedImpulse); - if (rb1) - m_tmpSolverBodyPool[solverConstraint.m_solverBodyIdB].applyImpulse(frictionConstraint1.m_contactNormal*rb1->getInvMass()*rb1->getLinearFactor(),-frictionConstraint1.m_angularComponentB,-frictionConstraint1.m_appliedImpulse); - } else - { - frictionConstraint1.m_appliedImpulse = 0.f; - } - } - - if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)) - { - btSolverConstraint& frictionConstraint2 = m_tmpSolverContactFrictionConstraintPool[solverConstraint.m_frictionIndex+1]; - if (infoGlobal.m_solverMode & SOLVER_USE_WARMSTARTING) - { - frictionConstraint2.m_appliedImpulse = cp.m_appliedImpulseLateral2 * infoGlobal.m_warmstartingFactor; - if (rb0) - m_tmpSolverBodyPool[solverConstraint.m_solverBodyIdA].applyImpulse(frictionConstraint2.m_contactNormal*rb0->getInvMass(),frictionConstraint2.m_angularComponentA,frictionConstraint2.m_appliedImpulse); - if (rb1) - m_tmpSolverBodyPool[solverConstraint.m_solverBodyIdB].applyImpulse(frictionConstraint2.m_contactNormal*rb1->getInvMass(),-frictionConstraint2.m_angularComponentB,-frictionConstraint2.m_appliedImpulse); - } else - { - frictionConstraint2.m_appliedImpulse = 0.f; - } - } - } else - { - btSolverConstraint& frictionConstraint1 = m_tmpSolverContactFrictionConstraintPool[solverConstraint.m_frictionIndex]; - frictionConstraint1.m_appliedImpulse = 0.f; - if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)) - { - btSolverConstraint& frictionConstraint2 = m_tmpSolverContactFrictionConstraintPool[solverConstraint.m_frictionIndex+1]; - frictionConstraint2.m_appliedImpulse = 0.f; - } - } - } - } - - - } - } -} - - -btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCollisionObject** /*bodies */,int /*numBodies */,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc) -{ - BT_PROFILE("solveGroupCacheFriendlySetup"); - (void)stackAlloc; - (void)debugDrawer; - - - if (!(numConstraints + numManifolds)) - { - // printf("empty\n"); - return 0.f; - } - - if (1) - { - int j; - for (j=0;jbuildJacobian(); - } - } - - btSolverBody& fixedBody = m_tmpSolverBodyPool.expand(); - initSolverBody(&fixedBody,0); - - //btRigidBody* rb0=0,*rb1=0; - - //if (1) - { - { - - int totalNumRows = 0; - int i; - - m_tmpConstraintSizesPool.resize(numConstraints); - //calculate the total number of contraint rows - for (i=0;igetInfo1(&info1); - totalNumRows += info1.m_numConstraintRows; - } - m_tmpSolverNonContactConstraintPool.resize(totalNumRows); - - - ///setup the btSolverConstraints - int currentRow = 0; - - for (i=0;igetRigidBodyA(); - btRigidBody& rbB = constraint->getRigidBodyB(); - - int solverBodyIdA = getOrInitSolverBody(rbA); - int solverBodyIdB = getOrInitSolverBody(rbB); - - btSolverBody* bodyAPtr = &m_tmpSolverBodyPool[solverBodyIdA]; - btSolverBody* bodyBPtr = &m_tmpSolverBodyPool[solverBodyIdB]; - - int j; - for ( j=0;jm_deltaLinearVelocity.setValue(0.f,0.f,0.f); - bodyAPtr->m_deltaAngularVelocity.setValue(0.f,0.f,0.f); - bodyBPtr->m_deltaLinearVelocity.setValue(0.f,0.f,0.f); - bodyBPtr->m_deltaAngularVelocity.setValue(0.f,0.f,0.f); - - - - btTypedConstraint::btConstraintInfo2 info2; - info2.fps = 1.f/infoGlobal.m_timeStep; - info2.erp = infoGlobal.m_erp; - info2.m_J1linearAxis = currentConstraintRow->m_contactNormal; - info2.m_J1angularAxis = currentConstraintRow->m_relpos1CrossNormal; - info2.m_J2linearAxis = 0; - info2.m_J2angularAxis = currentConstraintRow->m_relpos2CrossNormal; - info2.rowskip = sizeof(btSolverConstraint)/sizeof(btScalar);//check this - ///the size of btSolverConstraint needs be a multiple of btScalar - btAssert(info2.rowskip*sizeof(btScalar)== sizeof(btSolverConstraint)); - info2.m_constraintError = ¤tConstraintRow->m_rhs; - info2.cfm = ¤tConstraintRow->m_cfm; - info2.m_lowerLimit = ¤tConstraintRow->m_lowerLimit; - info2.m_upperLimit = ¤tConstraintRow->m_upperLimit; - info2.m_numIterations = infoGlobal.m_numIterations; - constraints[i]->getInfo2(&info2); - - ///finalize the constraint setup - for ( j=0;jgetRigidBodyA().getInvInertiaTensorWorld()*ftorqueAxis1*constraint->getRigidBodyA().getAngularFactor(); - } - { - const btVector3& ftorqueAxis2 = solverConstraint.m_relpos2CrossNormal; - solverConstraint.m_angularComponentB = constraint->getRigidBodyB().getInvInertiaTensorWorld()*ftorqueAxis2*constraint->getRigidBodyB().getAngularFactor(); - } - - { - btVector3 iMJlA = solverConstraint.m_contactNormal*rbA.getInvMass(); - btVector3 iMJaA = rbA.getInvInertiaTensorWorld()*solverConstraint.m_relpos1CrossNormal; - btVector3 iMJlB = solverConstraint.m_contactNormal*rbB.getInvMass();//sign of normal? - btVector3 iMJaB = rbB.getInvInertiaTensorWorld()*solverConstraint.m_relpos2CrossNormal; - - btScalar sum = iMJlA.dot(solverConstraint.m_contactNormal); - sum += iMJaA.dot(solverConstraint.m_relpos1CrossNormal); - sum += iMJlB.dot(solverConstraint.m_contactNormal); - sum += iMJaB.dot(solverConstraint.m_relpos2CrossNormal); - - solverConstraint.m_jacDiagABInv = btScalar(1.)/sum; - } - - - ///fix rhs - ///todo: add force/torque accelerators - { - btScalar rel_vel; - btScalar vel1Dotn = solverConstraint.m_contactNormal.dot(rbA.getLinearVelocity()) + solverConstraint.m_relpos1CrossNormal.dot(rbA.getAngularVelocity()); - btScalar vel2Dotn = -solverConstraint.m_contactNormal.dot(rbB.getLinearVelocity()) + solverConstraint.m_relpos2CrossNormal.dot(rbB.getAngularVelocity()); - - rel_vel = vel1Dotn+vel2Dotn; - - btScalar restitution = 0.f; - btScalar positionalError = solverConstraint.m_rhs;//already filled in by getConstraintInfo2 - btScalar velocityError = restitution - rel_vel;// * damping; - btScalar penetrationImpulse = positionalError*solverConstraint.m_jacDiagABInv; - btScalar velocityImpulse = velocityError *solverConstraint.m_jacDiagABInv; - solverConstraint.m_rhs = penetrationImpulse+velocityImpulse; - solverConstraint.m_appliedImpulse = 0.f; - - } - } - } - currentRow+=m_tmpConstraintSizesPool[i].m_numConstraintRows; - } - } - - { - int i; - btPersistentManifold* manifold = 0; -// btCollisionObject* colObj0=0,*colObj1=0; - - - for (i=0;igetRigidBodyA()); - int bodyBid = getOrInitSolverBody(constraints[j]->getRigidBodyB()); - btSolverBody& bodyA = m_tmpSolverBodyPool[bodyAid]; - btSolverBody& bodyB = m_tmpSolverBodyPool[bodyBid]; - constraints[j]->solveConstraintObsolete(bodyA,bodyB,infoGlobal.m_timeStep); - } - - ///solve all contact constraints using SIMD, if available - int numPoolConstraints = m_tmpSolverContactConstraintPool.size(); - for (j=0;jbtScalar(0)) - { - solveManifold.m_lowerLimit = -(solveManifold.m_friction*totalImpulse); - solveManifold.m_upperLimit = solveManifold.m_friction*totalImpulse; - - resolveSingleConstraintRowGenericSIMD(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA], m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold); - } - } - } else - { - - ///solve all joint constraints - for (j=0;jgetRigidBodyA()); - int bodyBid = getOrInitSolverBody(constraints[j]->getRigidBodyB()); - btSolverBody& bodyA = m_tmpSolverBodyPool[bodyAid]; - btSolverBody& bodyB = m_tmpSolverBodyPool[bodyBid]; - - constraints[j]->solveConstraintObsolete(bodyA,bodyB,infoGlobal.m_timeStep); - } - - ///solve all contact constraints - int numPoolConstraints = m_tmpSolverContactConstraintPool.size(); - for (j=0;jbtScalar(0)) - { - solveManifold.m_lowerLimit = -(solveManifold.m_friction*totalImpulse); - solveManifold.m_upperLimit = solveManifold.m_friction*totalImpulse; - - resolveSingleConstraintRowGeneric(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA], m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold); - } - } - } - - } - - if (infoGlobal.m_splitImpulse) - { - if (infoGlobal.m_solverMode & SOLVER_SIMD) - { - for ( iteration = 0;iterationm_appliedImpulse = solveManifold.m_appliedImpulse; - if (infoGlobal.m_solverMode & SOLVER_USE_FRICTION_WARMSTARTING) - { - pt->m_appliedImpulseLateral1 = m_tmpSolverContactFrictionConstraintPool[solveManifold.m_frictionIndex].m_appliedImpulse; - pt->m_appliedImpulseLateral2 = m_tmpSolverContactFrictionConstraintPool[solveManifold.m_frictionIndex+1].m_appliedImpulse; - } - - //do a callback here? - } - - numPoolConstraints = m_tmpSolverNonContactConstraintPool.size(); - for (j=0;jinternalGetAppliedImpulse(); - sum += solverConstr.m_appliedImpulse; - constr->internalSetAppliedImpulse(sum); - } - - - if (infoGlobal.m_splitImpulse) - { - for ( i=0;i m_tmpSolverBodyPool; - btConstraintArray m_tmpSolverContactConstraintPool; - btConstraintArray m_tmpSolverNonContactConstraintPool; - btConstraintArray m_tmpSolverContactFrictionConstraintPool; - btAlignedObjectArray m_orderTmpConstraintPool; - btAlignedObjectArray m_orderFrictionConstraintPool; - btAlignedObjectArray m_tmpConstraintSizesPool; - - btSolverConstraint& addFrictionConstraint(const btVector3& normalAxis,int solverBodyIdA,int solverBodyIdB,int frictionIndex,btManifoldPoint& cp,const btVector3& rel_pos1,const btVector3& rel_pos2,btCollisionObject* colObj0,btCollisionObject* colObj1, btScalar relaxation, btScalar desiredVelocity=0., btScalar cfmSlip=0.); - - ///m_btSeed2 is used for re-arranging the constraint rows. improves convergence/quality of friction - unsigned long m_btSeed2; - - void initSolverBody(btSolverBody* solverBody, btCollisionObject* collisionObject); - btScalar restitutionCurve(btScalar rel_vel, btScalar restitution); - - void convertContact(btPersistentManifold* manifold,const btContactSolverInfo& infoGlobal); - - - void resolveSplitPenetrationSIMD( - btSolverBody& body1, - btSolverBody& body2, - const btSolverConstraint& contactConstraint); - - void resolveSplitPenetrationImpulseCacheFriendly( - btSolverBody& body1, - btSolverBody& body2, - const btSolverConstraint& contactConstraint); - - //internal method - int getOrInitSolverBody(btCollisionObject& body); - - void resolveSingleConstraintRowGeneric(btSolverBody& body1,btSolverBody& body2,const btSolverConstraint& contactConstraint); - - void resolveSingleConstraintRowGenericSIMD(btSolverBody& body1,btSolverBody& body2,const btSolverConstraint& contactConstraint); - - void resolveSingleConstraintRowLowerLimit(btSolverBody& body1,btSolverBody& body2,const btSolverConstraint& contactConstraint); - - void resolveSingleConstraintRowLowerLimitSIMD(btSolverBody& body1,btSolverBody& body2,const btSolverConstraint& contactConstraint); - -public: - - - btSequentialImpulseConstraintSolver(); - virtual ~btSequentialImpulseConstraintSolver(); - - virtual btScalar solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifold,int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& info, btIDebugDraw* debugDrawer, btStackAlloc* stackAlloc,btDispatcher* dispatcher); - - btScalar solveGroupCacheFriendlySetup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc); - btScalar solveGroupCacheFriendlyIterations(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc); - - ///clear internal cached data and reset random seed - virtual void reset(); - - unsigned long btRand2(); - - int btRandInt2 (int n); - - void setRandSeed(unsigned long seed) - { - m_btSeed2 = seed; - } - unsigned long getRandSeed() const - { - return m_btSeed2; - } - -}; - -#ifndef BT_PREFER_SIMD -typedef btSequentialImpulseConstraintSolver btSequentialImpulseConstraintSolverPrefered; -#endif - - -#endif //SEQUENTIAL_IMPULSE_CONSTRAINT_SOLVER_H - diff --git a/bullet/src/BulletDynamics/ConstraintSolver/btSliderConstraint.cpp b/bullet/src/BulletDynamics/ConstraintSolver/btSliderConstraint.cpp deleted file mode 100644 index 848a09082..000000000 --- a/bullet/src/BulletDynamics/ConstraintSolver/btSliderConstraint.cpp +++ /dev/null @@ -1,1216 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -/* -Added by Roman Ponomarev (rponom@gmail.com) -April 04, 2008 -*/ - - - -#include "btSliderConstraint.h" -#include "BulletDynamics/Dynamics/btRigidBody.h" -#include "LinearMath/btTransformUtil.h" -#include - -#define USE_OFFSET_FOR_CONSTANT_FRAME true - -void btSliderConstraint::initParams() -{ - m_lowerLinLimit = btScalar(1.0); - m_upperLinLimit = btScalar(-1.0); - m_lowerAngLimit = btScalar(0.); - m_upperAngLimit = btScalar(0.); - m_softnessDirLin = SLIDER_CONSTRAINT_DEF_SOFTNESS; - m_restitutionDirLin = SLIDER_CONSTRAINT_DEF_RESTITUTION; - m_dampingDirLin = btScalar(0.); - m_softnessDirAng = SLIDER_CONSTRAINT_DEF_SOFTNESS; - m_restitutionDirAng = SLIDER_CONSTRAINT_DEF_RESTITUTION; - m_dampingDirAng = btScalar(0.); - m_softnessOrthoLin = SLIDER_CONSTRAINT_DEF_SOFTNESS; - m_restitutionOrthoLin = SLIDER_CONSTRAINT_DEF_RESTITUTION; - m_dampingOrthoLin = SLIDER_CONSTRAINT_DEF_DAMPING; - m_softnessOrthoAng = SLIDER_CONSTRAINT_DEF_SOFTNESS; - m_restitutionOrthoAng = SLIDER_CONSTRAINT_DEF_RESTITUTION; - m_dampingOrthoAng = SLIDER_CONSTRAINT_DEF_DAMPING; - m_softnessLimLin = SLIDER_CONSTRAINT_DEF_SOFTNESS; - m_restitutionLimLin = SLIDER_CONSTRAINT_DEF_RESTITUTION; - m_dampingLimLin = SLIDER_CONSTRAINT_DEF_DAMPING; - m_softnessLimAng = SLIDER_CONSTRAINT_DEF_SOFTNESS; - m_restitutionLimAng = SLIDER_CONSTRAINT_DEF_RESTITUTION; - m_dampingLimAng = SLIDER_CONSTRAINT_DEF_DAMPING; - - m_poweredLinMotor = false; - m_targetLinMotorVelocity = btScalar(0.); - m_maxLinMotorForce = btScalar(0.); - m_accumulatedLinMotorImpulse = btScalar(0.0); - - m_poweredAngMotor = false; - m_targetAngMotorVelocity = btScalar(0.); - m_maxAngMotorForce = btScalar(0.); - m_accumulatedAngMotorImpulse = btScalar(0.0); - - m_useLinearReferenceFrameA = USE_OFFSET_FOR_CONSTANT_FRAME; - - -} - - - -btSliderConstraint::btSliderConstraint() - :btTypedConstraint(SLIDER_CONSTRAINT_TYPE), - m_useSolveConstraintObsolete(false), - m_useLinearReferenceFrameA(true) -{ - initParams(); -} - - - -btSliderConstraint::btSliderConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB, bool useLinearReferenceFrameA) - : btTypedConstraint(SLIDER_CONSTRAINT_TYPE, rbA, rbB), - m_useSolveConstraintObsolete(false), - m_frameInA(frameInA), - m_frameInB(frameInB) -{ - initParams(); -} - - -static btRigidBody s_fixed(0, 0, 0); -btSliderConstraint::btSliderConstraint(btRigidBody& rbB, const btTransform& frameInB, bool useLinearReferenceFrameB) - : btTypedConstraint(SLIDER_CONSTRAINT_TYPE, s_fixed, rbB), - m_useSolveConstraintObsolete(false), - m_frameInB(frameInB), - m_useLinearReferenceFrameA(useLinearReferenceFrameB) -{ - ///not providing rigidbody B means implicitly using worldspace for body B -// m_frameInA.getOrigin() = m_rbA.getCenterOfMassTransform()(m_frameInA.getOrigin()); - - initParams(); -} - - - -void btSliderConstraint::buildJacobian() -{ - if (!m_useSolveConstraintObsolete) - { - return; - } - if(m_useLinearReferenceFrameA) - { - buildJacobianInt(m_rbA, m_rbB, m_frameInA, m_frameInB); - } - else - { - buildJacobianInt(m_rbB, m_rbA, m_frameInB, m_frameInA); - } -} - - - -void btSliderConstraint::buildJacobianInt(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB) -{ -#ifndef __SPU__ - //calculate transforms - m_calculatedTransformA = rbA.getCenterOfMassTransform() * frameInA; - m_calculatedTransformB = rbB.getCenterOfMassTransform() * frameInB; - m_realPivotAInW = m_calculatedTransformA.getOrigin(); - m_realPivotBInW = m_calculatedTransformB.getOrigin(); - m_sliderAxis = m_calculatedTransformA.getBasis().getColumn(0); // along X - m_delta = m_realPivotBInW - m_realPivotAInW; - m_projPivotInW = m_realPivotAInW + m_sliderAxis.dot(m_delta) * m_sliderAxis; - m_relPosA = m_projPivotInW - rbA.getCenterOfMassPosition(); - m_relPosB = m_realPivotBInW - rbB.getCenterOfMassPosition(); - btVector3 normalWorld; - int i; - //linear part - for(i = 0; i < 3; i++) - { - normalWorld = m_calculatedTransformA.getBasis().getColumn(i); - new (&m_jacLin[i]) btJacobianEntry( - rbA.getCenterOfMassTransform().getBasis().transpose(), - rbB.getCenterOfMassTransform().getBasis().transpose(), - m_relPosA, - m_relPosB, - normalWorld, - rbA.getInvInertiaDiagLocal(), - rbA.getInvMass(), - rbB.getInvInertiaDiagLocal(), - rbB.getInvMass() - ); - m_jacLinDiagABInv[i] = btScalar(1.) / m_jacLin[i].getDiagonal(); - m_depth[i] = m_delta.dot(normalWorld); - } - testLinLimits(); - // angular part - for(i = 0; i < 3; i++) - { - normalWorld = m_calculatedTransformA.getBasis().getColumn(i); - new (&m_jacAng[i]) btJacobianEntry( - normalWorld, - rbA.getCenterOfMassTransform().getBasis().transpose(), - rbB.getCenterOfMassTransform().getBasis().transpose(), - rbA.getInvInertiaDiagLocal(), - rbB.getInvInertiaDiagLocal() - ); - } - testAngLimits(); - btVector3 axisA = m_calculatedTransformA.getBasis().getColumn(0); - m_kAngle = btScalar(1.0 )/ (rbA.computeAngularImpulseDenominator(axisA) + rbB.computeAngularImpulseDenominator(axisA)); - // clear accumulator for motors - m_accumulatedLinMotorImpulse = btScalar(0.0); - m_accumulatedAngMotorImpulse = btScalar(0.0); -#endif //__SPU__ -} - -void btSliderConstraint::getInfo1(btConstraintInfo1* info) -{ - if (m_useSolveConstraintObsolete) - { - info->m_numConstraintRows = 0; - info->nub = 0; - } - else - { - info->m_numConstraintRows = 4; // Fixed 2 linear + 2 angular - info->nub = 2; - //prepare constraint - calculateTransforms(m_rbA.getCenterOfMassTransform(),m_rbB.getCenterOfMassTransform()); - testAngLimits(); - testLinLimits(); - if(getSolveLinLimit() || getPoweredLinMotor()) - { - info->m_numConstraintRows++; // limit 3rd linear as well - info->nub--; - } - if(getSolveAngLimit() || getPoweredAngMotor()) - { - info->m_numConstraintRows++; // limit 3rd angular as well - info->nub--; - } - } -} - -void btSliderConstraint::getInfo1NonVirtual(btConstraintInfo1* info) -{ - - info->m_numConstraintRows = 6; // Fixed 2 linear + 2 angular + 1 limit (even if not used) - info->nub = 0; -} - -void btSliderConstraint::getInfo2(btConstraintInfo2* info) -{ - if(m_useOffsetForConstraintFrame) - { - getInfo2NonVirtualUsingFrameOffset(info,m_rbA.getCenterOfMassTransform(),m_rbB.getCenterOfMassTransform(), m_rbA.getLinearVelocity(),m_rbB.getLinearVelocity(), m_rbA.getInvMass(),m_rbB.getInvMass()); - } - else - { - getInfo2NonVirtual(info,m_rbA.getCenterOfMassTransform(),m_rbB.getCenterOfMassTransform(), m_rbA.getLinearVelocity(),m_rbB.getLinearVelocity(), m_rbA.getInvMass(),m_rbB.getInvMass()); - } -} - -void btSliderConstraint::getInfo2NonVirtual(btConstraintInfo2* info, const btTransform& transA,const btTransform& transB, const btVector3& linVelA,const btVector3& linVelB, btScalar rbAinvMass,btScalar rbBinvMass ) -{ - //prepare constraint - calculateTransforms(transA,transB); - testLinLimits(); - testAngLimits(); - - const btTransform& trA = getCalculatedTransformA(); - const btTransform& trB = getCalculatedTransformB(); - - btAssert(!m_useSolveConstraintObsolete); - int i, s = info->rowskip; - - btScalar signFact = m_useLinearReferenceFrameA ? btScalar(1.0f) : btScalar(-1.0f); - // make rotations around Y and Z equal - // the slider axis should be the only unconstrained - // rotational axis, the angular velocity of the two bodies perpendicular to - // the slider axis should be equal. thus the constraint equations are - // p*w1 - p*w2 = 0 - // q*w1 - q*w2 = 0 - // where p and q are unit vectors normal to the slider axis, and w1 and w2 - // are the angular velocity vectors of the two bodies. - // get slider axis (X) - btVector3 ax1 = trA.getBasis().getColumn(0); - // get 2 orthos to slider axis (Y, Z) - btVector3 p = trA.getBasis().getColumn(1); - btVector3 q = trA.getBasis().getColumn(2); - // set the two slider rows - info->m_J1angularAxis[0] = p[0]; - info->m_J1angularAxis[1] = p[1]; - info->m_J1angularAxis[2] = p[2]; - info->m_J1angularAxis[s+0] = q[0]; - info->m_J1angularAxis[s+1] = q[1]; - info->m_J1angularAxis[s+2] = q[2]; - - info->m_J2angularAxis[0] = -p[0]; - info->m_J2angularAxis[1] = -p[1]; - info->m_J2angularAxis[2] = -p[2]; - info->m_J2angularAxis[s+0] = -q[0]; - info->m_J2angularAxis[s+1] = -q[1]; - info->m_J2angularAxis[s+2] = -q[2]; - // compute the right hand side of the constraint equation. set relative - // body velocities along p and q to bring the slider back into alignment. - // if ax1,ax2 are the unit length slider axes as computed from body1 and - // body2, we need to rotate both bodies along the axis u = (ax1 x ax2). - // if "theta" is the angle between ax1 and ax2, we need an angular velocity - // along u to cover angle erp*theta in one step : - // |angular_velocity| = angle/time = erp*theta / stepsize - // = (erp*fps) * theta - // angular_velocity = |angular_velocity| * (ax1 x ax2) / |ax1 x ax2| - // = (erp*fps) * theta * (ax1 x ax2) / sin(theta) - // ...as ax1 and ax2 are unit length. if theta is smallish, - // theta ~= sin(theta), so - // angular_velocity = (erp*fps) * (ax1 x ax2) - // ax1 x ax2 is in the plane space of ax1, so we project the angular - // velocity to p and q to find the right hand side. - btScalar k = info->fps * info->erp * getSoftnessOrthoAng(); - btVector3 ax2 = trB.getBasis().getColumn(0); - btVector3 u = ax1.cross(ax2); - info->m_constraintError[0] = k * u.dot(p); - info->m_constraintError[s] = k * u.dot(q); - // pull out pos and R for both bodies. also get the connection - // vector c = pos2-pos1. - // next two rows. we want: vel2 = vel1 + w1 x c ... but this would - // result in three equations, so we project along the planespace vectors - // so that sliding along the slider axis is disregarded. for symmetry we - // also consider rotation around center of mass of two bodies (factA and factB). - btTransform bodyA_trans = transA; - btTransform bodyB_trans = transB; - int s2 = 2 * s, s3 = 3 * s; - btVector3 c; - btScalar miA = rbAinvMass; - btScalar miB = rbBinvMass; - btScalar miS = miA + miB; - btScalar factA, factB; - if(miS > btScalar(0.f)) - { - factA = miB / miS; - } - else - { - factA = btScalar(0.5f); - } - if(factA > 0.99f) factA = 0.99f; - if(factA < 0.01f) factA = 0.01f; - factB = btScalar(1.0f) - factA; - c = bodyB_trans.getOrigin() - bodyA_trans.getOrigin(); - btVector3 tmp = c.cross(p); - for (i=0; i<3; i++) info->m_J1angularAxis[s2+i] = factA*tmp[i]; - for (i=0; i<3; i++) info->m_J2angularAxis[s2+i] = factB*tmp[i]; - tmp = c.cross(q); - for (i=0; i<3; i++) info->m_J1angularAxis[s3+i] = factA*tmp[i]; - for (i=0; i<3; i++) info->m_J2angularAxis[s3+i] = factB*tmp[i]; - - for (i=0; i<3; i++) info->m_J1linearAxis[s2+i] = p[i]; - for (i=0; i<3; i++) info->m_J1linearAxis[s3+i] = q[i]; - // compute two elements of right hand side. we want to align the offset - // point (in body 2's frame) with the center of body 1. - btVector3 ofs; // offset point in global coordinates - ofs = trB.getOrigin() - trA.getOrigin(); - k = info->fps * info->erp * getSoftnessOrthoLin(); - info->m_constraintError[s2] = k * p.dot(ofs); - info->m_constraintError[s3] = k * q.dot(ofs); - int nrow = 3; // last filled row - int srow; - // check linear limits linear - btScalar limit_err = btScalar(0.0); - int limit = 0; - if(getSolveLinLimit()) - { - limit_err = getLinDepth() * signFact; - limit = (limit_err > btScalar(0.0)) ? 2 : 1; - } - int powered = 0; - if(getPoweredLinMotor()) - { - powered = 1; - } - // if the slider has joint limits or motor, add in the extra row - if (limit || powered) - { - nrow++; - srow = nrow * info->rowskip; - info->m_J1linearAxis[srow+0] = ax1[0]; - info->m_J1linearAxis[srow+1] = ax1[1]; - info->m_J1linearAxis[srow+2] = ax1[2]; - // linear torque decoupling step: - // - // we have to be careful that the linear constraint forces (+/- ax1) applied to the two bodies - // do not create a torque couple. in other words, the points that the - // constraint force is applied at must lie along the same ax1 axis. - // a torque couple will result in limited slider-jointed free - // bodies from gaining angular momentum. - // the solution used here is to apply the constraint forces at the center of mass of the two bodies - btVector3 ltd; // Linear Torque Decoupling vector (a torque) -// c = btScalar(0.5) * c; - ltd = c.cross(ax1); - info->m_J1angularAxis[srow+0] = factA*ltd[0]; - info->m_J1angularAxis[srow+1] = factA*ltd[1]; - info->m_J1angularAxis[srow+2] = factA*ltd[2]; - info->m_J2angularAxis[srow+0] = factB*ltd[0]; - info->m_J2angularAxis[srow+1] = factB*ltd[1]; - info->m_J2angularAxis[srow+2] = factB*ltd[2]; - // right-hand part - btScalar lostop = getLowerLinLimit(); - btScalar histop = getUpperLinLimit(); - if(limit && (lostop == histop)) - { // the joint motor is ineffective - powered = 0; - } - info->m_constraintError[srow] = 0.; - info->m_lowerLimit[srow] = 0.; - info->m_upperLimit[srow] = 0.; - if(powered) - { - info->cfm[nrow] = btScalar(0.0); - btScalar tag_vel = getTargetLinMotorVelocity(); - btScalar mot_fact = getMotorFactor(m_linPos, m_lowerLinLimit, m_upperLinLimit, tag_vel, info->fps * info->erp); -// info->m_constraintError[srow] += mot_fact * getTargetLinMotorVelocity(); - info->m_constraintError[srow] -= signFact * mot_fact * getTargetLinMotorVelocity(); - info->m_lowerLimit[srow] += -getMaxLinMotorForce() * info->fps; - info->m_upperLimit[srow] += getMaxLinMotorForce() * info->fps; - } - if(limit) - { - k = info->fps * info->erp; - info->m_constraintError[srow] += k * limit_err; - info->cfm[srow] = btScalar(0.0); // stop_cfm; - if(lostop == histop) - { // limited low and high simultaneously - info->m_lowerLimit[srow] = -SIMD_INFINITY; - info->m_upperLimit[srow] = SIMD_INFINITY; - } - else if(limit == 1) - { // low limit - info->m_lowerLimit[srow] = -SIMD_INFINITY; - info->m_upperLimit[srow] = 0; - } - else - { // high limit - info->m_lowerLimit[srow] = 0; - info->m_upperLimit[srow] = SIMD_INFINITY; - } - // bounce (we'll use slider parameter abs(1.0 - m_dampingLimLin) for that) - btScalar bounce = btFabs(btScalar(1.0) - getDampingLimLin()); - if(bounce > btScalar(0.0)) - { - btScalar vel = linVelA.dot(ax1); - vel -= linVelB.dot(ax1); - vel *= signFact; - // only apply bounce if the velocity is incoming, and if the - // resulting c[] exceeds what we already have. - if(limit == 1) - { // low limit - if(vel < 0) - { - btScalar newc = -bounce * vel; - if (newc > info->m_constraintError[srow]) - { - info->m_constraintError[srow] = newc; - } - } - } - else - { // high limit - all those computations are reversed - if(vel > 0) - { - btScalar newc = -bounce * vel; - if(newc < info->m_constraintError[srow]) - { - info->m_constraintError[srow] = newc; - } - } - } - } - info->m_constraintError[srow] *= getSoftnessLimLin(); - } // if(limit) - } // if linear limit - // check angular limits - limit_err = btScalar(0.0); - limit = 0; - if(getSolveAngLimit()) - { - limit_err = getAngDepth(); - limit = (limit_err > btScalar(0.0)) ? 1 : 2; - } - // if the slider has joint limits, add in the extra row - powered = 0; - if(getPoweredAngMotor()) - { - powered = 1; - } - if(limit || powered) - { - nrow++; - srow = nrow * info->rowskip; - info->m_J1angularAxis[srow+0] = ax1[0]; - info->m_J1angularAxis[srow+1] = ax1[1]; - info->m_J1angularAxis[srow+2] = ax1[2]; - - info->m_J2angularAxis[srow+0] = -ax1[0]; - info->m_J2angularAxis[srow+1] = -ax1[1]; - info->m_J2angularAxis[srow+2] = -ax1[2]; - - btScalar lostop = getLowerAngLimit(); - btScalar histop = getUpperAngLimit(); - if(limit && (lostop == histop)) - { // the joint motor is ineffective - powered = 0; - } - if(powered) - { - info->cfm[srow] = btScalar(0.0); - btScalar mot_fact = getMotorFactor(m_angPos, m_lowerAngLimit, m_upperAngLimit, getTargetAngMotorVelocity(), info->fps * info->erp); - info->m_constraintError[srow] = mot_fact * getTargetAngMotorVelocity(); - info->m_lowerLimit[srow] = -getMaxAngMotorForce() * info->fps; - info->m_upperLimit[srow] = getMaxAngMotorForce() * info->fps; - } - if(limit) - { - k = info->fps * info->erp; - info->m_constraintError[srow] += k * limit_err; - info->cfm[srow] = btScalar(0.0); // stop_cfm; - if(lostop == histop) - { - // limited low and high simultaneously - info->m_lowerLimit[srow] = -SIMD_INFINITY; - info->m_upperLimit[srow] = SIMD_INFINITY; - } - else if(limit == 1) - { // low limit - info->m_lowerLimit[srow] = 0; - info->m_upperLimit[srow] = SIMD_INFINITY; - } - else - { // high limit - info->m_lowerLimit[srow] = -SIMD_INFINITY; - info->m_upperLimit[srow] = 0; - } - // bounce (we'll use slider parameter abs(1.0 - m_dampingLimAng) for that) - btScalar bounce = btFabs(btScalar(1.0) - getDampingLimAng()); - if(bounce > btScalar(0.0)) - { - btScalar vel = m_rbA.getAngularVelocity().dot(ax1); - vel -= m_rbB.getAngularVelocity().dot(ax1); - // only apply bounce if the velocity is incoming, and if the - // resulting c[] exceeds what we already have. - if(limit == 1) - { // low limit - if(vel < 0) - { - btScalar newc = -bounce * vel; - if(newc > info->m_constraintError[srow]) - { - info->m_constraintError[srow] = newc; - } - } - } - else - { // high limit - all those computations are reversed - if(vel > 0) - { - btScalar newc = -bounce * vel; - if(newc < info->m_constraintError[srow]) - { - info->m_constraintError[srow] = newc; - } - } - } - } - info->m_constraintError[srow] *= getSoftnessLimAng(); - } // if(limit) - } // if angular limit or powered -} - - -void btSliderConstraint::solveConstraintObsolete(btSolverBody& bodyA,btSolverBody& bodyB,btScalar timeStep) -{ - if (m_useSolveConstraintObsolete) - { - m_timeStep = timeStep; - if(m_useLinearReferenceFrameA) - { - solveConstraintInt(m_rbA,bodyA, m_rbB,bodyB); - } - else - { - solveConstraintInt(m_rbB,bodyB, m_rbA,bodyA); - } - } -} - - - -void btSliderConstraint::solveConstraintInt(btRigidBody& rbA, btSolverBody& bodyA,btRigidBody& rbB, btSolverBody& bodyB) -{ -#ifndef __SPU__ - int i; - // linear - btVector3 velA; - bodyA.getVelocityInLocalPointObsolete(m_relPosA,velA); - btVector3 velB; - bodyB.getVelocityInLocalPointObsolete(m_relPosB,velB); - btVector3 vel = velA - velB; - for(i = 0; i < 3; i++) - { - const btVector3& normal = m_jacLin[i].m_linearJointAxis; - btScalar rel_vel = normal.dot(vel); - // calculate positional error - btScalar depth = m_depth[i]; - // get parameters - btScalar softness = (i) ? m_softnessOrthoLin : (m_solveLinLim ? m_softnessLimLin : m_softnessDirLin); - btScalar restitution = (i) ? m_restitutionOrthoLin : (m_solveLinLim ? m_restitutionLimLin : m_restitutionDirLin); - btScalar damping = (i) ? m_dampingOrthoLin : (m_solveLinLim ? m_dampingLimLin : m_dampingDirLin); - // calcutate and apply impulse - btScalar normalImpulse = softness * (restitution * depth / m_timeStep - damping * rel_vel) * m_jacLinDiagABInv[i]; - btVector3 impulse_vector = normal * normalImpulse; - - //rbA.applyImpulse( impulse_vector, m_relPosA); - //rbB.applyImpulse(-impulse_vector, m_relPosB); - { - btVector3 ftorqueAxis1 = m_relPosA.cross(normal); - btVector3 ftorqueAxis2 = m_relPosB.cross(normal); - bodyA.applyImpulse(normal*rbA.getInvMass(), rbA.getInvInertiaTensorWorld()*ftorqueAxis1,normalImpulse); - bodyB.applyImpulse(normal*rbB.getInvMass(), rbB.getInvInertiaTensorWorld()*ftorqueAxis2,-normalImpulse); - } - - - - if(m_poweredLinMotor && (!i)) - { // apply linear motor - if(m_accumulatedLinMotorImpulse < m_maxLinMotorForce) - { - btScalar desiredMotorVel = m_targetLinMotorVelocity; - btScalar motor_relvel = desiredMotorVel + rel_vel; - normalImpulse = -motor_relvel * m_jacLinDiagABInv[i]; - // clamp accumulated impulse - btScalar new_acc = m_accumulatedLinMotorImpulse + btFabs(normalImpulse); - if(new_acc > m_maxLinMotorForce) - { - new_acc = m_maxLinMotorForce; - } - btScalar del = new_acc - m_accumulatedLinMotorImpulse; - if(normalImpulse < btScalar(0.0)) - { - normalImpulse = -del; - } - else - { - normalImpulse = del; - } - m_accumulatedLinMotorImpulse = new_acc; - // apply clamped impulse - impulse_vector = normal * normalImpulse; - //rbA.applyImpulse( impulse_vector, m_relPosA); - //rbB.applyImpulse(-impulse_vector, m_relPosB); - - { - btVector3 ftorqueAxis1 = m_relPosA.cross(normal); - btVector3 ftorqueAxis2 = m_relPosB.cross(normal); - bodyA.applyImpulse(normal*rbA.getInvMass(), rbA.getInvInertiaTensorWorld()*ftorqueAxis1,normalImpulse); - bodyB.applyImpulse(normal*rbB.getInvMass(), rbB.getInvInertiaTensorWorld()*ftorqueAxis2,-normalImpulse); - } - - - - } - } - } - // angular - // get axes in world space - btVector3 axisA = m_calculatedTransformA.getBasis().getColumn(0); - btVector3 axisB = m_calculatedTransformB.getBasis().getColumn(0); - - btVector3 angVelA; - bodyA.getAngularVelocity(angVelA); - btVector3 angVelB; - bodyB.getAngularVelocity(angVelB); - - btVector3 angVelAroundAxisA = axisA * axisA.dot(angVelA); - btVector3 angVelAroundAxisB = axisB * axisB.dot(angVelB); - - btVector3 angAorthog = angVelA - angVelAroundAxisA; - btVector3 angBorthog = angVelB - angVelAroundAxisB; - btVector3 velrelOrthog = angAorthog-angBorthog; - //solve orthogonal angular velocity correction - btScalar len = velrelOrthog.length(); - btScalar orthorImpulseMag = 0.f; - - if (len > btScalar(0.00001)) - { - btVector3 normal = velrelOrthog.normalized(); - btScalar denom = rbA.computeAngularImpulseDenominator(normal) + rbB.computeAngularImpulseDenominator(normal); - //velrelOrthog *= (btScalar(1.)/denom) * m_dampingOrthoAng * m_softnessOrthoAng; - orthorImpulseMag = (btScalar(1.)/denom) * m_dampingOrthoAng * m_softnessOrthoAng; - } - //solve angular positional correction - btVector3 angularError = axisA.cross(axisB) *(btScalar(1.)/m_timeStep); - btVector3 angularAxis = angularError; - btScalar angularImpulseMag = 0; - - btScalar len2 = angularError.length(); - if (len2>btScalar(0.00001)) - { - btVector3 normal2 = angularError.normalized(); - btScalar denom2 = rbA.computeAngularImpulseDenominator(normal2) + rbB.computeAngularImpulseDenominator(normal2); - angularImpulseMag = (btScalar(1.)/denom2) * m_restitutionOrthoAng * m_softnessOrthoAng; - angularError *= angularImpulseMag; - } - // apply impulse - //rbA.applyTorqueImpulse(-velrelOrthog+angularError); - //rbB.applyTorqueImpulse(velrelOrthog-angularError); - - bodyA.applyImpulse(btVector3(0,0,0), rbA.getInvInertiaTensorWorld()*velrelOrthog,-orthorImpulseMag); - bodyB.applyImpulse(btVector3(0,0,0), rbB.getInvInertiaTensorWorld()*velrelOrthog,orthorImpulseMag); - bodyA.applyImpulse(btVector3(0,0,0), rbA.getInvInertiaTensorWorld()*angularAxis,angularImpulseMag); - bodyB.applyImpulse(btVector3(0,0,0), rbB.getInvInertiaTensorWorld()*angularAxis,-angularImpulseMag); - - - btScalar impulseMag; - //solve angular limits - if(m_solveAngLim) - { - impulseMag = (angVelB - angVelA).dot(axisA) * m_dampingLimAng + m_angDepth * m_restitutionLimAng / m_timeStep; - impulseMag *= m_kAngle * m_softnessLimAng; - } - else - { - impulseMag = (angVelB - angVelA).dot(axisA) * m_dampingDirAng + m_angDepth * m_restitutionDirAng / m_timeStep; - impulseMag *= m_kAngle * m_softnessDirAng; - } - btVector3 impulse = axisA * impulseMag; - //rbA.applyTorqueImpulse(impulse); - //rbB.applyTorqueImpulse(-impulse); - - bodyA.applyImpulse(btVector3(0,0,0), rbA.getInvInertiaTensorWorld()*axisA,impulseMag); - bodyB.applyImpulse(btVector3(0,0,0), rbB.getInvInertiaTensorWorld()*axisA,-impulseMag); - - - - //apply angular motor - if(m_poweredAngMotor) - { - if(m_accumulatedAngMotorImpulse < m_maxAngMotorForce) - { - btVector3 velrel = angVelAroundAxisA - angVelAroundAxisB; - btScalar projRelVel = velrel.dot(axisA); - - btScalar desiredMotorVel = m_targetAngMotorVelocity; - btScalar motor_relvel = desiredMotorVel - projRelVel; - - btScalar angImpulse = m_kAngle * motor_relvel; - // clamp accumulated impulse - btScalar new_acc = m_accumulatedAngMotorImpulse + btFabs(angImpulse); - if(new_acc > m_maxAngMotorForce) - { - new_acc = m_maxAngMotorForce; - } - btScalar del = new_acc - m_accumulatedAngMotorImpulse; - if(angImpulse < btScalar(0.0)) - { - angImpulse = -del; - } - else - { - angImpulse = del; - } - m_accumulatedAngMotorImpulse = new_acc; - // apply clamped impulse - btVector3 motorImp = angImpulse * axisA; - //rbA.applyTorqueImpulse(motorImp); - //rbB.applyTorqueImpulse(-motorImp); - - bodyA.applyImpulse(btVector3(0,0,0), rbA.getInvInertiaTensorWorld()*axisA,angImpulse); - bodyB.applyImpulse(btVector3(0,0,0), rbB.getInvInertiaTensorWorld()*axisA,-angImpulse); - } - } -#endif //__SPU__ -} - - - - - -void btSliderConstraint::calculateTransforms(const btTransform& transA,const btTransform& transB) -{ - if(m_useLinearReferenceFrameA || (!m_useSolveConstraintObsolete)) - { - m_calculatedTransformA = transA * m_frameInA; - m_calculatedTransformB = transB * m_frameInB; - } - else - { - m_calculatedTransformA = transB * m_frameInB; - m_calculatedTransformB = transA * m_frameInA; - } - m_realPivotAInW = m_calculatedTransformA.getOrigin(); - m_realPivotBInW = m_calculatedTransformB.getOrigin(); - m_sliderAxis = m_calculatedTransformA.getBasis().getColumn(0); // along X - if(m_useLinearReferenceFrameA || m_useSolveConstraintObsolete) - { - m_delta = m_realPivotBInW - m_realPivotAInW; - } - else - { - m_delta = m_realPivotAInW - m_realPivotBInW; - } - m_projPivotInW = m_realPivotAInW + m_sliderAxis.dot(m_delta) * m_sliderAxis; - btVector3 normalWorld; - int i; - //linear part - for(i = 0; i < 3; i++) - { - normalWorld = m_calculatedTransformA.getBasis().getColumn(i); - m_depth[i] = m_delta.dot(normalWorld); - } -} - - - -void btSliderConstraint::testLinLimits(void) -{ - m_solveLinLim = false; - m_linPos = m_depth[0]; - if(m_lowerLinLimit <= m_upperLinLimit) - { - if(m_depth[0] > m_upperLinLimit) - { - m_depth[0] -= m_upperLinLimit; - m_solveLinLim = true; - } - else if(m_depth[0] < m_lowerLinLimit) - { - m_depth[0] -= m_lowerLinLimit; - m_solveLinLim = true; - } - else - { - m_depth[0] = btScalar(0.); - } - } - else - { - m_depth[0] = btScalar(0.); - } -} - - - -void btSliderConstraint::testAngLimits(void) -{ - m_angDepth = btScalar(0.); - m_solveAngLim = false; - if(m_lowerAngLimit <= m_upperAngLimit) - { - const btVector3 axisA0 = m_calculatedTransformA.getBasis().getColumn(1); - const btVector3 axisA1 = m_calculatedTransformA.getBasis().getColumn(2); - const btVector3 axisB0 = m_calculatedTransformB.getBasis().getColumn(1); -// btScalar rot = btAtan2Fast(axisB0.dot(axisA1), axisB0.dot(axisA0)); - btScalar rot = btAtan2(axisB0.dot(axisA1), axisB0.dot(axisA0)); - rot = btAdjustAngleToLimits(rot, m_lowerAngLimit, m_upperAngLimit); - m_angPos = rot; - if(rot < m_lowerAngLimit) - { - m_angDepth = rot - m_lowerAngLimit; - m_solveAngLim = true; - } - else if(rot > m_upperAngLimit) - { - m_angDepth = rot - m_upperAngLimit; - m_solveAngLim = true; - } - } -} - -btVector3 btSliderConstraint::getAncorInA(void) -{ - btVector3 ancorInA; - ancorInA = m_realPivotAInW + (m_lowerLinLimit + m_upperLinLimit) * btScalar(0.5) * m_sliderAxis; - ancorInA = m_rbA.getCenterOfMassTransform().inverse() * ancorInA; - return ancorInA; -} - - - -btVector3 btSliderConstraint::getAncorInB(void) -{ - btVector3 ancorInB; - ancorInB = m_frameInB.getOrigin(); - return ancorInB; -} - - -void btSliderConstraint::getInfo2NonVirtualUsingFrameOffset(btConstraintInfo2* info, const btTransform& transA,const btTransform& transB, const btVector3& linVelA,const btVector3& linVelB, btScalar rbAinvMass,btScalar rbBinvMass ) -{ - const btTransform& trA = getCalculatedTransformA(); - const btTransform& trB = getCalculatedTransformB(); - - btAssert(!m_useSolveConstraintObsolete); - int i, s = info->rowskip; - - btScalar signFact = m_useLinearReferenceFrameA ? btScalar(1.0f) : btScalar(-1.0f); - - // difference between frames in WCS - btVector3 ofs = trB.getOrigin() - trA.getOrigin(); - // now get weight factors depending on masses - btScalar miA = rbAinvMass; - btScalar miB = rbBinvMass; - bool hasStaticBody = (miA < SIMD_EPSILON) || (miB < SIMD_EPSILON); - btScalar miS = miA + miB; - btScalar factA, factB; - if(miS > btScalar(0.f)) - { - factA = miB / miS; - } - else - { - factA = btScalar(0.5f); - } - factB = btScalar(1.0f) - factA; - // get the desired direction of slider axis - // as weighted sum of X-orthos of frameA and frameB in WCS - btVector3 ax1A = trA.getBasis().getColumn(0); - btVector3 ax1B = trB.getBasis().getColumn(0); - btVector3 ax1 = ax1A * factA + ax1B * factB; - ax1.normalize(); - // construct two orthos to slider axis - btVector3 p, q; - btPlaneSpace1 (ax1, p, q); - // make rotations around these orthos equal - // the slider axis should be the only unconstrained - // rotational axis, the angular velocity of the two bodies perpendicular to - // the slider axis should be equal. thus the constraint equations are - // p*w1 - p*w2 = 0 - // q*w1 - q*w2 = 0 - // where p and q are unit vectors normal to the slider axis, and w1 and w2 - // are the angular velocity vectors of the two bodies. - info->m_J1angularAxis[0] = p[0]; - info->m_J1angularAxis[1] = p[1]; - info->m_J1angularAxis[2] = p[2]; - info->m_J1angularAxis[s+0] = q[0]; - info->m_J1angularAxis[s+1] = q[1]; - info->m_J1angularAxis[s+2] = q[2]; - - info->m_J2angularAxis[0] = -p[0]; - info->m_J2angularAxis[1] = -p[1]; - info->m_J2angularAxis[2] = -p[2]; - info->m_J2angularAxis[s+0] = -q[0]; - info->m_J2angularAxis[s+1] = -q[1]; - info->m_J2angularAxis[s+2] = -q[2]; - // compute the right hand side of the constraint equation. set relative - // body velocities along p and q to bring the slider back into alignment. - // if ax1A,ax1B are the unit length slider axes as computed from bodyA and - // bodyB, we need to rotate both bodies along the axis u = (ax1 x ax2). - // if "theta" is the angle between ax1 and ax2, we need an angular velocity - // along u to cover angle erp*theta in one step : - // |angular_velocity| = angle/time = erp*theta / stepsize - // = (erp*fps) * theta - // angular_velocity = |angular_velocity| * (ax1 x ax2) / |ax1 x ax2| - // = (erp*fps) * theta * (ax1 x ax2) / sin(theta) - // ...as ax1 and ax2 are unit length. if theta is smallish, - // theta ~= sin(theta), so - // angular_velocity = (erp*fps) * (ax1 x ax2) - // ax1 x ax2 is in the plane space of ax1, so we project the angular - // velocity to p and q to find the right hand side. - btScalar k = info->fps * info->erp * getSoftnessOrthoAng(); - btVector3 u = ax1A.cross(ax1B); - info->m_constraintError[0] = k * u.dot(p); - info->m_constraintError[s] = k * u.dot(q); - - int nrow = 1; // last filled row - int srow; - btScalar limit_err; - int limit; - int powered; - - // next two rows. - // we want: velA + wA x relA == velB + wB x relB ... but this would - // result in three equations, so we project along two orthos to the slider axis - - btTransform bodyA_trans = transA; - btTransform bodyB_trans = transB; - nrow++; - int s2 = nrow * s; - nrow++; - int s3 = nrow * s; - btVector3 tmpA, tmpB, relA, relB; - // get vector from bodyB to frameB in WCS - relB = trB.getOrigin() - bodyB_trans.getOrigin(); - // get its projection to slider axis - btVector3 projB = ax1 * relB.dot(ax1); - // get vector directed from bodyB to slider axis (and orthogonal to it) - btVector3 orthoB = relB - projB; - // same for bodyA - relA = trA.getOrigin() - bodyA_trans.getOrigin(); - btVector3 projA = ax1 * relA.dot(ax1); - btVector3 orthoA = relA - projA; - // get desired offset between frames A and B along slider axis - btScalar sliderOffs = m_linPos - m_depth[0]; - // desired vector from projection of center of bodyA to projection of center of bodyB to slider axis - btVector3 totalDist = projA + ax1 * sliderOffs - projB; - // get offset vectors relA and relB - relA = orthoA + totalDist * factA; - relB = orthoB - totalDist * factB; - // now choose average ortho to slider axis - p = orthoB * factA + orthoA * factB; - btScalar len2 = p.length2(); - if(len2 > SIMD_EPSILON) - { - p /= btSqrt(len2); - } - else - { - p = trA.getBasis().getColumn(1); - } - // make one more ortho - q = ax1.cross(p); - // fill two rows - tmpA = relA.cross(p); - tmpB = relB.cross(p); - for (i=0; i<3; i++) info->m_J1angularAxis[s2+i] = tmpA[i]; - for (i=0; i<3; i++) info->m_J2angularAxis[s2+i] = -tmpB[i]; - tmpA = relA.cross(q); - tmpB = relB.cross(q); - if(hasStaticBody && getSolveAngLimit()) - { // to make constraint between static and dynamic objects more rigid - // remove wA (or wB) from equation if angular limit is hit - tmpB *= factB; - tmpA *= factA; - } - for (i=0; i<3; i++) info->m_J1angularAxis[s3+i] = tmpA[i]; - for (i=0; i<3; i++) info->m_J2angularAxis[s3+i] = -tmpB[i]; - for (i=0; i<3; i++) info->m_J1linearAxis[s2+i] = p[i]; - for (i=0; i<3; i++) info->m_J1linearAxis[s3+i] = q[i]; - // compute two elements of right hand side - k = info->fps * info->erp * getSoftnessOrthoLin(); - btScalar rhs = k * p.dot(ofs); - info->m_constraintError[s2] = rhs; - rhs = k * q.dot(ofs); - info->m_constraintError[s3] = rhs; - // check linear limits - limit_err = btScalar(0.0); - limit = 0; - if(getSolveLinLimit()) - { - limit_err = getLinDepth() * signFact; - limit = (limit_err > btScalar(0.0)) ? 2 : 1; - } - powered = 0; - if(getPoweredLinMotor()) - { - powered = 1; - } - // if the slider has joint limits or motor, add in the extra row - if (limit || powered) - { - nrow++; - srow = nrow * info->rowskip; - info->m_J1linearAxis[srow+0] = ax1[0]; - info->m_J1linearAxis[srow+1] = ax1[1]; - info->m_J1linearAxis[srow+2] = ax1[2]; - // linear torque decoupling step: - // - // we have to be careful that the linear constraint forces (+/- ax1) applied to the two bodies - // do not create a torque couple. in other words, the points that the - // constraint force is applied at must lie along the same ax1 axis. - // a torque couple will result in limited slider-jointed free - // bodies from gaining angular momentum. - // this is needed only when bodyA and bodyB are both dynamic. - if(!hasStaticBody) - { - tmpA = relA.cross(ax1); - tmpB = relB.cross(ax1); - info->m_J1angularAxis[srow+0] = tmpA[0]; - info->m_J1angularAxis[srow+1] = tmpA[1]; - info->m_J1angularAxis[srow+2] = tmpA[2]; - info->m_J2angularAxis[srow+0] = -tmpB[0]; - info->m_J2angularAxis[srow+1] = -tmpB[1]; - info->m_J2angularAxis[srow+2] = -tmpB[2]; - } - // right-hand part - btScalar lostop = getLowerLinLimit(); - btScalar histop = getUpperLinLimit(); - if(limit && (lostop == histop)) - { // the joint motor is ineffective - powered = 0; - } - info->m_constraintError[srow] = 0.; - info->m_lowerLimit[srow] = 0.; - info->m_upperLimit[srow] = 0.; - if(powered) - { - info->cfm[nrow] = btScalar(0.0); - btScalar tag_vel = getTargetLinMotorVelocity(); - btScalar mot_fact = getMotorFactor(m_linPos, m_lowerLinLimit, m_upperLinLimit, tag_vel, info->fps * info->erp); - info->m_constraintError[srow] -= signFact * mot_fact * getTargetLinMotorVelocity(); - info->m_lowerLimit[srow] += -getMaxLinMotorForce() * info->fps; - info->m_upperLimit[srow] += getMaxLinMotorForce() * info->fps; - } - if(limit) - { - k = info->fps * info->erp; - info->m_constraintError[srow] += k * limit_err; - info->cfm[srow] = btScalar(0.0); // stop_cfm; - if(lostop == histop) - { // limited low and high simultaneously - info->m_lowerLimit[srow] = -SIMD_INFINITY; - info->m_upperLimit[srow] = SIMD_INFINITY; - } - else if(limit == 1) - { // low limit - info->m_lowerLimit[srow] = -SIMD_INFINITY; - info->m_upperLimit[srow] = 0; - } - else - { // high limit - info->m_lowerLimit[srow] = 0; - info->m_upperLimit[srow] = SIMD_INFINITY; - } - // bounce (we'll use slider parameter abs(1.0 - m_dampingLimLin) for that) - btScalar bounce = btFabs(btScalar(1.0) - getDampingLimLin()); - if(bounce > btScalar(0.0)) - { - btScalar vel = linVelA.dot(ax1); - vel -= linVelB.dot(ax1); - vel *= signFact; - // only apply bounce if the velocity is incoming, and if the - // resulting c[] exceeds what we already have. - if(limit == 1) - { // low limit - if(vel < 0) - { - btScalar newc = -bounce * vel; - if (newc > info->m_constraintError[srow]) - { - info->m_constraintError[srow] = newc; - } - } - } - else - { // high limit - all those computations are reversed - if(vel > 0) - { - btScalar newc = -bounce * vel; - if(newc < info->m_constraintError[srow]) - { - info->m_constraintError[srow] = newc; - } - } - } - } - info->m_constraintError[srow] *= getSoftnessLimLin(); - } // if(limit) - } // if linear limit - // check angular limits - limit_err = btScalar(0.0); - limit = 0; - if(getSolveAngLimit()) - { - limit_err = getAngDepth(); - limit = (limit_err > btScalar(0.0)) ? 1 : 2; - } - // if the slider has joint limits, add in the extra row - powered = 0; - if(getPoweredAngMotor()) - { - powered = 1; - } - if(limit || powered) - { - nrow++; - srow = nrow * info->rowskip; - info->m_J1angularAxis[srow+0] = ax1[0]; - info->m_J1angularAxis[srow+1] = ax1[1]; - info->m_J1angularAxis[srow+2] = ax1[2]; - - info->m_J2angularAxis[srow+0] = -ax1[0]; - info->m_J2angularAxis[srow+1] = -ax1[1]; - info->m_J2angularAxis[srow+2] = -ax1[2]; - - btScalar lostop = getLowerAngLimit(); - btScalar histop = getUpperAngLimit(); - if(limit && (lostop == histop)) - { // the joint motor is ineffective - powered = 0; - } - if(powered) - { - info->cfm[srow] = btScalar(0.0); - btScalar mot_fact = getMotorFactor(m_angPos, m_lowerAngLimit, m_upperAngLimit, getTargetAngMotorVelocity(), info->fps * info->erp); - info->m_constraintError[srow] = mot_fact * getTargetAngMotorVelocity(); - info->m_lowerLimit[srow] = -getMaxAngMotorForce() * info->fps; - info->m_upperLimit[srow] = getMaxAngMotorForce() * info->fps; - } - if(limit) - { - k = info->fps * info->erp; - info->m_constraintError[srow] += k * limit_err; - info->cfm[srow] = btScalar(0.0); // stop_cfm; - if(lostop == histop) - { - // limited low and high simultaneously - info->m_lowerLimit[srow] = -SIMD_INFINITY; - info->m_upperLimit[srow] = SIMD_INFINITY; - } - else if(limit == 1) - { // low limit - info->m_lowerLimit[srow] = 0; - info->m_upperLimit[srow] = SIMD_INFINITY; - } - else - { // high limit - info->m_lowerLimit[srow] = -SIMD_INFINITY; - info->m_upperLimit[srow] = 0; - } - // bounce (we'll use slider parameter abs(1.0 - m_dampingLimAng) for that) - btScalar bounce = btFabs(btScalar(1.0) - getDampingLimAng()); - if(bounce > btScalar(0.0)) - { - btScalar vel = m_rbA.getAngularVelocity().dot(ax1); - vel -= m_rbB.getAngularVelocity().dot(ax1); - // only apply bounce if the velocity is incoming, and if the - // resulting c[] exceeds what we already have. - if(limit == 1) - { // low limit - if(vel < 0) - { - btScalar newc = -bounce * vel; - if(newc > info->m_constraintError[srow]) - { - info->m_constraintError[srow] = newc; - } - } - } - else - { // high limit - all those computations are reversed - if(vel > 0) - { - btScalar newc = -bounce * vel; - if(newc < info->m_constraintError[srow]) - { - info->m_constraintError[srow] = newc; - } - } - } - } - info->m_constraintError[srow] *= getSoftnessLimAng(); - } // if(limit) - } // if angular limit or powered -} diff --git a/bullet/src/BulletDynamics/ConstraintSolver/btSliderConstraint.h b/bullet/src/BulletDynamics/ConstraintSolver/btSliderConstraint.h deleted file mode 100644 index 80256e493..000000000 --- a/bullet/src/BulletDynamics/ConstraintSolver/btSliderConstraint.h +++ /dev/null @@ -1,238 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -/* -Added by Roman Ponomarev (rponom@gmail.com) -April 04, 2008 - -TODO: - - add clamping od accumulated impulse to improve stability - - add conversion for ODE constraint solver -*/ - -#ifndef SLIDER_CONSTRAINT_H -#define SLIDER_CONSTRAINT_H - - - -#include "LinearMath/btVector3.h" -#include "btJacobianEntry.h" -#include "btTypedConstraint.h" - - - -class btRigidBody; - - - -#define SLIDER_CONSTRAINT_DEF_SOFTNESS (btScalar(1.0)) -#define SLIDER_CONSTRAINT_DEF_DAMPING (btScalar(1.0)) -#define SLIDER_CONSTRAINT_DEF_RESTITUTION (btScalar(0.7)) - - - -class btSliderConstraint : public btTypedConstraint -{ -protected: - ///for backwards compatibility during the transition to 'getInfo/getInfo2' - bool m_useSolveConstraintObsolete; - bool m_useOffsetForConstraintFrame; - btTransform m_frameInA; - btTransform m_frameInB; - // use frameA fo define limits, if true - bool m_useLinearReferenceFrameA; - // linear limits - btScalar m_lowerLinLimit; - btScalar m_upperLinLimit; - // angular limits - btScalar m_lowerAngLimit; - btScalar m_upperAngLimit; - // softness, restitution and damping for different cases - // DirLin - moving inside linear limits - // LimLin - hitting linear limit - // DirAng - moving inside angular limits - // LimAng - hitting angular limit - // OrthoLin, OrthoAng - against constraint axis - btScalar m_softnessDirLin; - btScalar m_restitutionDirLin; - btScalar m_dampingDirLin; - btScalar m_softnessDirAng; - btScalar m_restitutionDirAng; - btScalar m_dampingDirAng; - btScalar m_softnessLimLin; - btScalar m_restitutionLimLin; - btScalar m_dampingLimLin; - btScalar m_softnessLimAng; - btScalar m_restitutionLimAng; - btScalar m_dampingLimAng; - btScalar m_softnessOrthoLin; - btScalar m_restitutionOrthoLin; - btScalar m_dampingOrthoLin; - btScalar m_softnessOrthoAng; - btScalar m_restitutionOrthoAng; - btScalar m_dampingOrthoAng; - - // for interlal use - bool m_solveLinLim; - bool m_solveAngLim; - - btJacobianEntry m_jacLin[3]; - btScalar m_jacLinDiagABInv[3]; - - btJacobianEntry m_jacAng[3]; - - btScalar m_timeStep; - btTransform m_calculatedTransformA; - btTransform m_calculatedTransformB; - - btVector3 m_sliderAxis; - btVector3 m_realPivotAInW; - btVector3 m_realPivotBInW; - btVector3 m_projPivotInW; - btVector3 m_delta; - btVector3 m_depth; - btVector3 m_relPosA; - btVector3 m_relPosB; - - btScalar m_linPos; - btScalar m_angPos; - - btScalar m_angDepth; - btScalar m_kAngle; - - bool m_poweredLinMotor; - btScalar m_targetLinMotorVelocity; - btScalar m_maxLinMotorForce; - btScalar m_accumulatedLinMotorImpulse; - - bool m_poweredAngMotor; - btScalar m_targetAngMotorVelocity; - btScalar m_maxAngMotorForce; - btScalar m_accumulatedAngMotorImpulse; - - //------------------------ - void initParams(); -public: - // constructors - btSliderConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB ,bool useLinearReferenceFrameA); - btSliderConstraint(btRigidBody& rbB, const btTransform& frameInB, bool useLinearReferenceFrameB); - btSliderConstraint(); - // overrides - virtual void buildJacobian(); - virtual void getInfo1 (btConstraintInfo1* info); - - void getInfo1NonVirtual(btConstraintInfo1* info); - - virtual void getInfo2 (btConstraintInfo2* info); - - void getInfo2NonVirtual(btConstraintInfo2* info, const btTransform& transA, const btTransform& transB,const btVector3& linVelA,const btVector3& linVelB, btScalar rbAinvMass,btScalar rbBinvMass); - void getInfo2NonVirtualUsingFrameOffset(btConstraintInfo2* info, const btTransform& transA, const btTransform& transB,const btVector3& linVelA,const btVector3& linVelB, btScalar rbAinvMass,btScalar rbBinvMass); - - virtual void solveConstraintObsolete(btSolverBody& bodyA,btSolverBody& bodyB,btScalar timeStep); - - - // access - const btRigidBody& getRigidBodyA() const { return m_rbA; } - const btRigidBody& getRigidBodyB() const { return m_rbB; } - const btTransform & getCalculatedTransformA() const { return m_calculatedTransformA; } - const btTransform & getCalculatedTransformB() const { return m_calculatedTransformB; } - const btTransform & getFrameOffsetA() const { return m_frameInA; } - const btTransform & getFrameOffsetB() const { return m_frameInB; } - btTransform & getFrameOffsetA() { return m_frameInA; } - btTransform & getFrameOffsetB() { return m_frameInB; } - btScalar getLowerLinLimit() { return m_lowerLinLimit; } - void setLowerLinLimit(btScalar lowerLimit) { m_lowerLinLimit = lowerLimit; } - btScalar getUpperLinLimit() { return m_upperLinLimit; } - void setUpperLinLimit(btScalar upperLimit) { m_upperLinLimit = upperLimit; } - btScalar getLowerAngLimit() { return m_lowerAngLimit; } - void setLowerAngLimit(btScalar lowerLimit) { m_lowerAngLimit = btNormalizeAngle(lowerLimit); } - btScalar getUpperAngLimit() { return m_upperAngLimit; } - void setUpperAngLimit(btScalar upperLimit) { m_upperAngLimit = btNormalizeAngle(upperLimit); } - bool getUseLinearReferenceFrameA() { return m_useLinearReferenceFrameA; } - btScalar getSoftnessDirLin() { return m_softnessDirLin; } - btScalar getRestitutionDirLin() { return m_restitutionDirLin; } - btScalar getDampingDirLin() { return m_dampingDirLin ; } - btScalar getSoftnessDirAng() { return m_softnessDirAng; } - btScalar getRestitutionDirAng() { return m_restitutionDirAng; } - btScalar getDampingDirAng() { return m_dampingDirAng; } - btScalar getSoftnessLimLin() { return m_softnessLimLin; } - btScalar getRestitutionLimLin() { return m_restitutionLimLin; } - btScalar getDampingLimLin() { return m_dampingLimLin; } - btScalar getSoftnessLimAng() { return m_softnessLimAng; } - btScalar getRestitutionLimAng() { return m_restitutionLimAng; } - btScalar getDampingLimAng() { return m_dampingLimAng; } - btScalar getSoftnessOrthoLin() { return m_softnessOrthoLin; } - btScalar getRestitutionOrthoLin() { return m_restitutionOrthoLin; } - btScalar getDampingOrthoLin() { return m_dampingOrthoLin; } - btScalar getSoftnessOrthoAng() { return m_softnessOrthoAng; } - btScalar getRestitutionOrthoAng() { return m_restitutionOrthoAng; } - btScalar getDampingOrthoAng() { return m_dampingOrthoAng; } - void setSoftnessDirLin(btScalar softnessDirLin) { m_softnessDirLin = softnessDirLin; } - void setRestitutionDirLin(btScalar restitutionDirLin) { m_restitutionDirLin = restitutionDirLin; } - void setDampingDirLin(btScalar dampingDirLin) { m_dampingDirLin = dampingDirLin; } - void setSoftnessDirAng(btScalar softnessDirAng) { m_softnessDirAng = softnessDirAng; } - void setRestitutionDirAng(btScalar restitutionDirAng) { m_restitutionDirAng = restitutionDirAng; } - void setDampingDirAng(btScalar dampingDirAng) { m_dampingDirAng = dampingDirAng; } - void setSoftnessLimLin(btScalar softnessLimLin) { m_softnessLimLin = softnessLimLin; } - void setRestitutionLimLin(btScalar restitutionLimLin) { m_restitutionLimLin = restitutionLimLin; } - void setDampingLimLin(btScalar dampingLimLin) { m_dampingLimLin = dampingLimLin; } - void setSoftnessLimAng(btScalar softnessLimAng) { m_softnessLimAng = softnessLimAng; } - void setRestitutionLimAng(btScalar restitutionLimAng) { m_restitutionLimAng = restitutionLimAng; } - void setDampingLimAng(btScalar dampingLimAng) { m_dampingLimAng = dampingLimAng; } - void setSoftnessOrthoLin(btScalar softnessOrthoLin) { m_softnessOrthoLin = softnessOrthoLin; } - void setRestitutionOrthoLin(btScalar restitutionOrthoLin) { m_restitutionOrthoLin = restitutionOrthoLin; } - void setDampingOrthoLin(btScalar dampingOrthoLin) { m_dampingOrthoLin = dampingOrthoLin; } - void setSoftnessOrthoAng(btScalar softnessOrthoAng) { m_softnessOrthoAng = softnessOrthoAng; } - void setRestitutionOrthoAng(btScalar restitutionOrthoAng) { m_restitutionOrthoAng = restitutionOrthoAng; } - void setDampingOrthoAng(btScalar dampingOrthoAng) { m_dampingOrthoAng = dampingOrthoAng; } - void setPoweredLinMotor(bool onOff) { m_poweredLinMotor = onOff; } - bool getPoweredLinMotor() { return m_poweredLinMotor; } - void setTargetLinMotorVelocity(btScalar targetLinMotorVelocity) { m_targetLinMotorVelocity = targetLinMotorVelocity; } - btScalar getTargetLinMotorVelocity() { return m_targetLinMotorVelocity; } - void setMaxLinMotorForce(btScalar maxLinMotorForce) { m_maxLinMotorForce = maxLinMotorForce; } - btScalar getMaxLinMotorForce() { return m_maxLinMotorForce; } - void setPoweredAngMotor(bool onOff) { m_poweredAngMotor = onOff; } - bool getPoweredAngMotor() { return m_poweredAngMotor; } - void setTargetAngMotorVelocity(btScalar targetAngMotorVelocity) { m_targetAngMotorVelocity = targetAngMotorVelocity; } - btScalar getTargetAngMotorVelocity() { return m_targetAngMotorVelocity; } - void setMaxAngMotorForce(btScalar maxAngMotorForce) { m_maxAngMotorForce = maxAngMotorForce; } - btScalar getMaxAngMotorForce() { return m_maxAngMotorForce; } - btScalar getLinearPos() { return m_linPos; } - - - // access for ODE solver - bool getSolveLinLimit() { return m_solveLinLim; } - btScalar getLinDepth() { return m_depth[0]; } - bool getSolveAngLimit() { return m_solveAngLim; } - btScalar getAngDepth() { return m_angDepth; } - // internal - void buildJacobianInt(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB); - void solveConstraintInt(btRigidBody& rbA, btSolverBody& bodyA,btRigidBody& rbB, btSolverBody& bodyB); - // shared code used by ODE solver - void calculateTransforms(const btTransform& transA,const btTransform& transB); - void testLinLimits(); - void testAngLimits(); - // access for PE Solver - btVector3 getAncorInA(); - btVector3 getAncorInB(); - // access for UseFrameOffset - bool getUseFrameOffset() { return m_useOffsetForConstraintFrame; } - void setUseFrameOffset(bool frameOffsetOnOff) { m_useOffsetForConstraintFrame = frameOffsetOnOff; } -}; - - - -#endif //SLIDER_CONSTRAINT_H - diff --git a/bullet/src/BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.cpp b/bullet/src/BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.cpp deleted file mode 100644 index 0279064eb..000000000 --- a/bullet/src/BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.cpp +++ /dev/null @@ -1,255 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - - -#include "btSolve2LinearConstraint.h" - -#include "BulletDynamics/Dynamics/btRigidBody.h" -#include "LinearMath/btVector3.h" -#include "btJacobianEntry.h" - - -void btSolve2LinearConstraint::resolveUnilateralPairConstraint( - btRigidBody* body1, - btRigidBody* body2, - - const btMatrix3x3& world2A, - const btMatrix3x3& world2B, - - const btVector3& invInertiaADiag, - const btScalar invMassA, - const btVector3& linvelA,const btVector3& angvelA, - const btVector3& rel_posA1, - const btVector3& invInertiaBDiag, - const btScalar invMassB, - const btVector3& linvelB,const btVector3& angvelB, - const btVector3& rel_posA2, - - btScalar depthA, const btVector3& normalA, - const btVector3& rel_posB1,const btVector3& rel_posB2, - btScalar depthB, const btVector3& normalB, - btScalar& imp0,btScalar& imp1) -{ - (void)linvelA; - (void)linvelB; - (void)angvelB; - (void)angvelA; - - - - imp0 = btScalar(0.); - imp1 = btScalar(0.); - - btScalar len = btFabs(normalA.length()) - btScalar(1.); - if (btFabs(len) >= SIMD_EPSILON) - return; - - btAssert(len < SIMD_EPSILON); - - - //this jacobian entry could be re-used for all iterations - btJacobianEntry jacA(world2A,world2B,rel_posA1,rel_posA2,normalA,invInertiaADiag,invMassA, - invInertiaBDiag,invMassB); - btJacobianEntry jacB(world2A,world2B,rel_posB1,rel_posB2,normalB,invInertiaADiag,invMassA, - invInertiaBDiag,invMassB); - - //const btScalar vel0 = jacA.getRelativeVelocity(linvelA,angvelA,linvelB,angvelB); - //const btScalar vel1 = jacB.getRelativeVelocity(linvelA,angvelA,linvelB,angvelB); - - const btScalar vel0 = normalA.dot(body1->getVelocityInLocalPoint(rel_posA1)-body2->getVelocityInLocalPoint(rel_posA1)); - const btScalar vel1 = normalB.dot(body1->getVelocityInLocalPoint(rel_posB1)-body2->getVelocityInLocalPoint(rel_posB1)); - -// btScalar penetrationImpulse = (depth*contactTau*timeCorrection) * massTerm;//jacDiagABInv - btScalar massTerm = btScalar(1.) / (invMassA + invMassB); - - - // calculate rhs (or error) terms - const btScalar dv0 = depthA * m_tau * massTerm - vel0 * m_damping; - const btScalar dv1 = depthB * m_tau * massTerm - vel1 * m_damping; - - - // dC/dv * dv = -C - - // jacobian * impulse = -error - // - - //impulse = jacobianInverse * -error - - // inverting 2x2 symmetric system (offdiagonal are equal!) - // - - - btScalar nonDiag = jacA.getNonDiagonal(jacB,invMassA,invMassB); - btScalar invDet = btScalar(1.0) / (jacA.getDiagonal() * jacB.getDiagonal() - nonDiag * nonDiag ); - - //imp0 = dv0 * jacA.getDiagonal() * invDet + dv1 * -nonDiag * invDet; - //imp1 = dv1 * jacB.getDiagonal() * invDet + dv0 * - nonDiag * invDet; - - imp0 = dv0 * jacA.getDiagonal() * invDet + dv1 * -nonDiag * invDet; - imp1 = dv1 * jacB.getDiagonal() * invDet + dv0 * - nonDiag * invDet; - - //[a b] [d -c] - //[c d] inverse = (1 / determinant) * [-b a] where determinant is (ad - bc) - - //[jA nD] * [imp0] = [dv0] - //[nD jB] [imp1] [dv1] - -} - - - -void btSolve2LinearConstraint::resolveBilateralPairConstraint( - btRigidBody* body1, - btRigidBody* body2, - const btMatrix3x3& world2A, - const btMatrix3x3& world2B, - - const btVector3& invInertiaADiag, - const btScalar invMassA, - const btVector3& linvelA,const btVector3& angvelA, - const btVector3& rel_posA1, - const btVector3& invInertiaBDiag, - const btScalar invMassB, - const btVector3& linvelB,const btVector3& angvelB, - const btVector3& rel_posA2, - - btScalar depthA, const btVector3& normalA, - const btVector3& rel_posB1,const btVector3& rel_posB2, - btScalar depthB, const btVector3& normalB, - btScalar& imp0,btScalar& imp1) -{ - - (void)linvelA; - (void)linvelB; - (void)angvelA; - (void)angvelB; - - - - imp0 = btScalar(0.); - imp1 = btScalar(0.); - - btScalar len = btFabs(normalA.length()) - btScalar(1.); - if (btFabs(len) >= SIMD_EPSILON) - return; - - btAssert(len < SIMD_EPSILON); - - - //this jacobian entry could be re-used for all iterations - btJacobianEntry jacA(world2A,world2B,rel_posA1,rel_posA2,normalA,invInertiaADiag,invMassA, - invInertiaBDiag,invMassB); - btJacobianEntry jacB(world2A,world2B,rel_posB1,rel_posB2,normalB,invInertiaADiag,invMassA, - invInertiaBDiag,invMassB); - - //const btScalar vel0 = jacA.getRelativeVelocity(linvelA,angvelA,linvelB,angvelB); - //const btScalar vel1 = jacB.getRelativeVelocity(linvelA,angvelA,linvelB,angvelB); - - const btScalar vel0 = normalA.dot(body1->getVelocityInLocalPoint(rel_posA1)-body2->getVelocityInLocalPoint(rel_posA1)); - const btScalar vel1 = normalB.dot(body1->getVelocityInLocalPoint(rel_posB1)-body2->getVelocityInLocalPoint(rel_posB1)); - - // calculate rhs (or error) terms - const btScalar dv0 = depthA * m_tau - vel0 * m_damping; - const btScalar dv1 = depthB * m_tau - vel1 * m_damping; - - // dC/dv * dv = -C - - // jacobian * impulse = -error - // - - //impulse = jacobianInverse * -error - - // inverting 2x2 symmetric system (offdiagonal are equal!) - // - - - btScalar nonDiag = jacA.getNonDiagonal(jacB,invMassA,invMassB); - btScalar invDet = btScalar(1.0) / (jacA.getDiagonal() * jacB.getDiagonal() - nonDiag * nonDiag ); - - //imp0 = dv0 * jacA.getDiagonal() * invDet + dv1 * -nonDiag * invDet; - //imp1 = dv1 * jacB.getDiagonal() * invDet + dv0 * - nonDiag * invDet; - - imp0 = dv0 * jacA.getDiagonal() * invDet + dv1 * -nonDiag * invDet; - imp1 = dv1 * jacB.getDiagonal() * invDet + dv0 * - nonDiag * invDet; - - //[a b] [d -c] - //[c d] inverse = (1 / determinant) * [-b a] where determinant is (ad - bc) - - //[jA nD] * [imp0] = [dv0] - //[nD jB] [imp1] [dv1] - - if ( imp0 > btScalar(0.0)) - { - if ( imp1 > btScalar(0.0) ) - { - //both positive - } - else - { - imp1 = btScalar(0.); - - // now imp0>0 imp1<0 - imp0 = dv0 / jacA.getDiagonal(); - if ( imp0 > btScalar(0.0) ) - { - } else - { - imp0 = btScalar(0.); - } - } - } - else - { - imp0 = btScalar(0.); - - imp1 = dv1 / jacB.getDiagonal(); - if ( imp1 <= btScalar(0.0) ) - { - imp1 = btScalar(0.); - // now imp0>0 imp1<0 - imp0 = dv0 / jacA.getDiagonal(); - if ( imp0 > btScalar(0.0) ) - { - } else - { - imp0 = btScalar(0.); - } - } else - { - } - } -} - - -/* -void btSolve2LinearConstraint::resolveAngularConstraint( const btMatrix3x3& invInertiaAWS, - const btScalar invMassA, - const btVector3& linvelA,const btVector3& angvelA, - const btVector3& rel_posA1, - const btMatrix3x3& invInertiaBWS, - const btScalar invMassB, - const btVector3& linvelB,const btVector3& angvelB, - const btVector3& rel_posA2, - - btScalar depthA, const btVector3& normalA, - const btVector3& rel_posB1,const btVector3& rel_posB2, - btScalar depthB, const btVector3& normalB, - btScalar& imp0,btScalar& imp1) -{ - -} -*/ - diff --git a/bullet/src/BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.h b/bullet/src/BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.h deleted file mode 100644 index 7e33c624d..000000000 --- a/bullet/src/BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.h +++ /dev/null @@ -1,107 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef SOLVE_2LINEAR_CONSTRAINT_H -#define SOLVE_2LINEAR_CONSTRAINT_H - -#include "LinearMath/btMatrix3x3.h" -#include "LinearMath/btVector3.h" - - -class btRigidBody; - - - -/// constraint class used for lateral tyre friction. -class btSolve2LinearConstraint -{ - btScalar m_tau; - btScalar m_damping; - -public: - - btSolve2LinearConstraint(btScalar tau,btScalar damping) - { - m_tau = tau; - m_damping = damping; - } - // - // solve unilateral constraint (equality, direct method) - // - void resolveUnilateralPairConstraint( - btRigidBody* body0, - btRigidBody* body1, - - const btMatrix3x3& world2A, - const btMatrix3x3& world2B, - - const btVector3& invInertiaADiag, - const btScalar invMassA, - const btVector3& linvelA,const btVector3& angvelA, - const btVector3& rel_posA1, - const btVector3& invInertiaBDiag, - const btScalar invMassB, - const btVector3& linvelB,const btVector3& angvelB, - const btVector3& rel_posA2, - - btScalar depthA, const btVector3& normalA, - const btVector3& rel_posB1,const btVector3& rel_posB2, - btScalar depthB, const btVector3& normalB, - btScalar& imp0,btScalar& imp1); - - - // - // solving 2x2 lcp problem (inequality, direct solution ) - // - void resolveBilateralPairConstraint( - btRigidBody* body0, - btRigidBody* body1, - const btMatrix3x3& world2A, - const btMatrix3x3& world2B, - - const btVector3& invInertiaADiag, - const btScalar invMassA, - const btVector3& linvelA,const btVector3& angvelA, - const btVector3& rel_posA1, - const btVector3& invInertiaBDiag, - const btScalar invMassB, - const btVector3& linvelB,const btVector3& angvelB, - const btVector3& rel_posA2, - - btScalar depthA, const btVector3& normalA, - const btVector3& rel_posB1,const btVector3& rel_posB2, - btScalar depthB, const btVector3& normalB, - btScalar& imp0,btScalar& imp1); - -/* - void resolveAngularConstraint( const btMatrix3x3& invInertiaAWS, - const btScalar invMassA, - const btVector3& linvelA,const btVector3& angvelA, - const btVector3& rel_posA1, - const btMatrix3x3& invInertiaBWS, - const btScalar invMassB, - const btVector3& linvelB,const btVector3& angvelB, - const btVector3& rel_posA2, - - btScalar depthA, const btVector3& normalA, - const btVector3& rel_posB1,const btVector3& rel_posB2, - btScalar depthB, const btVector3& normalB, - btScalar& imp0,btScalar& imp1); - -*/ - -}; - -#endif //SOLVE_2LINEAR_CONSTRAINT_H diff --git a/bullet/src/BulletDynamics/ConstraintSolver/btSolverBody.h b/bullet/src/BulletDynamics/ConstraintSolver/btSolverBody.h deleted file mode 100644 index 7187ae1ff..000000000 --- a/bullet/src/BulletDynamics/ConstraintSolver/btSolverBody.h +++ /dev/null @@ -1,191 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef BT_SOLVER_BODY_H -#define BT_SOLVER_BODY_H - -class btRigidBody; -#include "LinearMath/btVector3.h" -#include "LinearMath/btMatrix3x3.h" -#include "BulletDynamics/Dynamics/btRigidBody.h" -#include "LinearMath/btAlignedAllocator.h" -#include "LinearMath/btTransformUtil.h" - -///Until we get other contributions, only use SIMD on Windows, when using Visual Studio 2008 or later, and not double precision -#ifdef BT_USE_SSE -#define USE_SIMD 1 -#endif // - - -#ifdef USE_SIMD - -struct btSimdScalar -{ - SIMD_FORCE_INLINE btSimdScalar() - { - - } - - SIMD_FORCE_INLINE btSimdScalar(float fl) - :m_vec128 (_mm_set1_ps(fl)) - { - } - - SIMD_FORCE_INLINE btSimdScalar(__m128 v128) - :m_vec128(v128) - { - } - union - { - __m128 m_vec128; - float m_floats[4]; - int m_ints[4]; - btScalar m_unusedPadding; - }; - SIMD_FORCE_INLINE __m128 get128() - { - return m_vec128; - } - - SIMD_FORCE_INLINE const __m128 get128() const - { - return m_vec128; - } - - SIMD_FORCE_INLINE void set128(__m128 v128) - { - m_vec128 = v128; - } - - SIMD_FORCE_INLINE operator __m128() - { - return m_vec128; - } - SIMD_FORCE_INLINE operator const __m128() const - { - return m_vec128; - } - - SIMD_FORCE_INLINE operator float() const - { - return m_floats[0]; - } - -}; - -///@brief Return the elementwise product of two btSimdScalar -SIMD_FORCE_INLINE btSimdScalar -operator*(const btSimdScalar& v1, const btSimdScalar& v2) -{ - return btSimdScalar(_mm_mul_ps(v1.get128(),v2.get128())); -} - -///@brief Return the elementwise product of two btSimdScalar -SIMD_FORCE_INLINE btSimdScalar -operator+(const btSimdScalar& v1, const btSimdScalar& v2) -{ - return btSimdScalar(_mm_add_ps(v1.get128(),v2.get128())); -} - - -#else -#define btSimdScalar btScalar -#endif - -///The btSolverBody is an internal datastructure for the constraint solver. Only necessary data is packed to increase cache coherence/performance. -ATTRIBUTE_ALIGNED16 (struct) btSolverBody -{ - BT_DECLARE_ALIGNED_ALLOCATOR(); - btVector3 m_deltaLinearVelocity; - btVector3 m_deltaAngularVelocity; - btVector3 m_angularFactor; - btVector3 m_invMass; - btScalar m_friction; - btRigidBody* m_originalBody; - btVector3 m_pushVelocity; - btVector3 m_turnVelocity; - - - SIMD_FORCE_INLINE void getVelocityInLocalPointObsolete(const btVector3& rel_pos, btVector3& velocity ) const - { - if (m_originalBody) - velocity = m_originalBody->getLinearVelocity()+m_deltaLinearVelocity + (m_originalBody->getAngularVelocity()+m_deltaAngularVelocity).cross(rel_pos); - else - velocity.setValue(0,0,0); - } - - SIMD_FORCE_INLINE void getAngularVelocity(btVector3& angVel) const - { - if (m_originalBody) - angVel = m_originalBody->getAngularVelocity()+m_deltaAngularVelocity; - else - angVel.setValue(0,0,0); - } - - - //Optimization for the iterative solver: avoid calculating constant terms involving inertia, normal, relative position - SIMD_FORCE_INLINE void applyImpulse(const btVector3& linearComponent, const btVector3& angularComponent,const btScalar impulseMagnitude) - { - //if (m_invMass) - { - m_deltaLinearVelocity += linearComponent*impulseMagnitude; - m_deltaAngularVelocity += angularComponent*(impulseMagnitude*m_angularFactor); - } - } - - SIMD_FORCE_INLINE void internalApplyPushImpulse(const btVector3& linearComponent, const btVector3& angularComponent,btScalar impulseMagnitude) - { - if (m_originalBody) - { - m_pushVelocity += linearComponent*impulseMagnitude; - m_turnVelocity += angularComponent*(impulseMagnitude*m_angularFactor); - } - } - - void writebackVelocity() - { - if (m_originalBody) - { - m_originalBody->setLinearVelocity(m_originalBody->getLinearVelocity()+ m_deltaLinearVelocity); - m_originalBody->setAngularVelocity(m_originalBody->getAngularVelocity()+m_deltaAngularVelocity); - - //m_originalBody->setCompanionId(-1); - } - } - - - void writebackVelocity(btScalar timeStep) - { - if (m_originalBody) - { - m_originalBody->setLinearVelocity(m_originalBody->getLinearVelocity()+ m_deltaLinearVelocity); - m_originalBody->setAngularVelocity(m_originalBody->getAngularVelocity()+m_deltaAngularVelocity); - - //correct the position/orientation based on push/turn recovery - btTransform newTransform; - btTransformUtil::integrateTransform(m_originalBody->getWorldTransform(),m_pushVelocity,m_turnVelocity,timeStep,newTransform); - m_originalBody->setWorldTransform(newTransform); - - //m_originalBody->setCompanionId(-1); - } - } - - - -}; - -#endif //BT_SOLVER_BODY_H - - diff --git a/bullet/src/BulletDynamics/ConstraintSolver/btSolverConstraint.h b/bullet/src/BulletDynamics/ConstraintSolver/btSolverConstraint.h deleted file mode 100644 index 2fef846cd..000000000 --- a/bullet/src/BulletDynamics/ConstraintSolver/btSolverConstraint.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef BT_SOLVER_CONSTRAINT_H -#define BT_SOLVER_CONSTRAINT_H - -class btRigidBody; -#include "LinearMath/btVector3.h" -#include "LinearMath/btMatrix3x3.h" -#include "btJacobianEntry.h" - -//#define NO_FRICTION_TANGENTIALS 1 -#include "btSolverBody.h" - - -///1D constraint along a normal axis between bodyA and bodyB. It can be combined to solve contact and friction constraints. -ATTRIBUTE_ALIGNED16 (struct) btSolverConstraint -{ - BT_DECLARE_ALIGNED_ALLOCATOR(); - - btVector3 m_relpos1CrossNormal; - btVector3 m_contactNormal; - - btVector3 m_relpos2CrossNormal; - //btVector3 m_contactNormal2;//usually m_contactNormal2 == -m_contactNormal - - btVector3 m_angularComponentA; - btVector3 m_angularComponentB; - - mutable btSimdScalar m_appliedPushImpulse; - mutable btSimdScalar m_appliedImpulse; - - - btScalar m_friction; - btScalar m_jacDiagABInv; - union - { - int m_numConsecutiveRowsPerKernel; - btScalar m_unusedPadding0; - }; - - union - { - int m_frictionIndex; - btScalar m_unusedPadding1; - }; - union - { - int m_solverBodyIdA; - btScalar m_unusedPadding2; - }; - union - { - int m_solverBodyIdB; - btScalar m_unusedPadding3; - }; - - union - { - void* m_originalContactPoint; - btScalar m_unusedPadding4; - }; - - btScalar m_rhs; - btScalar m_cfm; - btScalar m_lowerLimit; - btScalar m_upperLimit; - - btScalar m_rhsPenetration; - - enum btSolverConstraintType - { - BT_SOLVER_CONTACT_1D = 0, - BT_SOLVER_FRICTION_1D - }; -}; - -typedef btAlignedObjectArray btConstraintArray; - - -#endif //BT_SOLVER_CONSTRAINT_H - - - diff --git a/bullet/src/BulletDynamics/ConstraintSolver/btTypedConstraint.cpp b/bullet/src/BulletDynamics/ConstraintSolver/btTypedConstraint.cpp deleted file mode 100644 index 62f11062b..000000000 --- a/bullet/src/BulletDynamics/ConstraintSolver/btTypedConstraint.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#include "btTypedConstraint.h" -#include "BulletDynamics/Dynamics/btRigidBody.h" - -static btRigidBody s_fixed(0, 0,0); - -#define DEFAULT_DEBUGDRAW_SIZE btScalar(0.3f) - -btTypedConstraint::btTypedConstraint(btTypedConstraintType type) -:btTypedObject(type), -m_userConstraintType(-1), -m_userConstraintId(-1), -m_needsFeedback(false), -m_rbA(s_fixed), -m_rbB(s_fixed), -m_appliedImpulse(btScalar(0.)), -m_dbgDrawSize(DEFAULT_DEBUGDRAW_SIZE) -{ - s_fixed.setMassProps(btScalar(0.),btVector3(btScalar(0.),btScalar(0.),btScalar(0.))); -} -btTypedConstraint::btTypedConstraint(btTypedConstraintType type, btRigidBody& rbA) -:btTypedObject(type), -m_userConstraintType(-1), -m_userConstraintId(-1), -m_needsFeedback(false), -m_rbA(rbA), -m_rbB(s_fixed), -m_appliedImpulse(btScalar(0.)), -m_dbgDrawSize(DEFAULT_DEBUGDRAW_SIZE) -{ - s_fixed.setMassProps(btScalar(0.),btVector3(btScalar(0.),btScalar(0.),btScalar(0.))); -} - - -btTypedConstraint::btTypedConstraint(btTypedConstraintType type, btRigidBody& rbA,btRigidBody& rbB) -:btTypedObject(type), -m_userConstraintType(-1), -m_userConstraintId(-1), -m_needsFeedback(false), -m_rbA(rbA), -m_rbB(rbB), -m_appliedImpulse(btScalar(0.)), -m_dbgDrawSize(DEFAULT_DEBUGDRAW_SIZE) -{ - s_fixed.setMassProps(btScalar(0.),btVector3(btScalar(0.),btScalar(0.),btScalar(0.))); - -} - - - - -btScalar btTypedConstraint::getMotorFactor(btScalar pos, btScalar lowLim, btScalar uppLim, btScalar vel, btScalar timeFact) -{ - if(lowLim > uppLim) - { - return btScalar(1.0f); - } - else if(lowLim == uppLim) - { - return btScalar(0.0f); - } - btScalar lim_fact = btScalar(1.0f); - btScalar delta_max = vel / timeFact; - if(delta_max < btScalar(0.0f)) - { - if((pos >= lowLim) && (pos < (lowLim - delta_max))) - { - lim_fact = (lowLim - pos) / delta_max; - } - else if(pos < lowLim) - { - lim_fact = btScalar(0.0f); - } - else - { - lim_fact = btScalar(1.0f); - } - } - else if(delta_max > btScalar(0.0f)) - { - if((pos <= uppLim) && (pos > (uppLim - delta_max))) - { - lim_fact = (uppLim - pos) / delta_max; - } - else if(pos > uppLim) - { - lim_fact = btScalar(0.0f); - } - else - { - lim_fact = btScalar(1.0f); - } - } - else - { - lim_fact = btScalar(0.0f); - } - return lim_fact; -} - - diff --git a/bullet/src/BulletDynamics/ConstraintSolver/btTypedConstraint.h b/bullet/src/BulletDynamics/ConstraintSolver/btTypedConstraint.h deleted file mode 100644 index 645f0336d..000000000 --- a/bullet/src/BulletDynamics/ConstraintSolver/btTypedConstraint.h +++ /dev/null @@ -1,276 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef TYPED_CONSTRAINT_H -#define TYPED_CONSTRAINT_H - -class btRigidBody; -#include "LinearMath/btScalar.h" -#include "btSolverConstraint.h" -#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h" -struct btSolverBody; - -enum btTypedConstraintType -{ - POINT2POINT_CONSTRAINT_TYPE=MAX_CONTACT_MANIFOLD_TYPE+1, - HINGE_CONSTRAINT_TYPE, - CONETWIST_CONSTRAINT_TYPE, - D6_CONSTRAINT_TYPE, - SLIDER_CONSTRAINT_TYPE, - CONTACT_CONSTRAINT_TYPE -}; - -///TypedConstraint is the baseclass for Bullet constraints and vehicles -class btTypedConstraint : public btTypedObject -{ - int m_userConstraintType; - int m_userConstraintId; - bool m_needsFeedback; - - btTypedConstraint& operator=(btTypedConstraint& other) - { - btAssert(0); - (void) other; - return *this; - } - -protected: - btRigidBody& m_rbA; - btRigidBody& m_rbB; - btScalar m_appliedImpulse; - btScalar m_dbgDrawSize; - - btVector3 m_appliedLinearImpulse; - btVector3 m_appliedAngularImpulseA; - btVector3 m_appliedAngularImpulseB; - -public: - - btTypedConstraint(btTypedConstraintType type); - virtual ~btTypedConstraint() {}; - btTypedConstraint(btTypedConstraintType type, btRigidBody& rbA); - btTypedConstraint(btTypedConstraintType type, btRigidBody& rbA,btRigidBody& rbB); - - struct btConstraintInfo1 { - int m_numConstraintRows,nub; - }; - - struct btConstraintInfo2 { - // integrator parameters: frames per second (1/stepsize), default error - // reduction parameter (0..1). - btScalar fps,erp; - - // for the first and second body, pointers to two (linear and angular) - // n*3 jacobian sub matrices, stored by rows. these matrices will have - // been initialized to 0 on entry. if the second body is zero then the - // J2xx pointers may be 0. - btScalar *m_J1linearAxis,*m_J1angularAxis,*m_J2linearAxis,*m_J2angularAxis; - - // elements to jump from one row to the next in J's - int rowskip; - - // right hand sides of the equation J*v = c + cfm * lambda. cfm is the - // "constraint force mixing" vector. c is set to zero on entry, cfm is - // set to a constant value (typically very small or zero) value on entry. - btScalar *m_constraintError,*cfm; - - // lo and hi limits for variables (set to -/+ infinity on entry). - btScalar *m_lowerLimit,*m_upperLimit; - - // findex vector for variables. see the LCP solver interface for a - // description of what this does. this is set to -1 on entry. - // note that the returned indexes are relative to the first index of - // the constraint. - int *findex; - // number of solver iterations - int m_numIterations; - }; - - ///internal method used by the constraint solver, don't use them directly - virtual void buildJacobian() = 0; - - ///internal method used by the constraint solver, don't use them directly - virtual void setupSolverConstraint(btConstraintArray& ca, int solverBodyA,int solverBodyB, btScalar timeStep) - { - } - - ///internal method used by the constraint solver, don't use them directly - virtual void getInfo1 (btConstraintInfo1* info)=0; - - ///internal method used by the constraint solver, don't use them directly - virtual void getInfo2 (btConstraintInfo2* info)=0; - - ///internal method used by the constraint solver, don't use them directly - void internalSetAppliedImpulse(btScalar appliedImpulse) - { - m_appliedImpulse = appliedImpulse; - } - ///internal method used by the constraint solver, don't use them directly - btScalar internalGetAppliedImpulse() - { - return m_appliedImpulse; - } - - ///internal method used by the constraint solver, don't use them directly - virtual void solveConstraintObsolete(btSolverBody& bodyA,btSolverBody& bodyB,btScalar timeStep) = 0; - - ///internal method used by the constraint solver, don't use them directly - btScalar getMotorFactor(btScalar pos, btScalar lowLim, btScalar uppLim, btScalar vel, btScalar timeFact); - - const btRigidBody& getRigidBodyA() const - { - return m_rbA; - } - const btRigidBody& getRigidBodyB() const - { - return m_rbB; - } - - btRigidBody& getRigidBodyA() - { - return m_rbA; - } - btRigidBody& getRigidBodyB() - { - return m_rbB; - } - - int getUserConstraintType() const - { - return m_userConstraintType ; - } - - void setUserConstraintType(int userConstraintType) - { - m_userConstraintType = userConstraintType; - }; - - void setUserConstraintId(int uid) - { - m_userConstraintId = uid; - } - - int getUserConstraintId() const - { - return m_userConstraintId; - } - - int getUid() const - { - return m_userConstraintId; - } - - bool needsFeedback() const - { - return m_needsFeedback; - } - - ///enableFeedback will allow to read the applied linear and angular impulse - ///use getAppliedImpulse, getAppliedLinearImpulse and getAppliedAngularImpulse to read feedback information - void enableFeedback(bool needsFeedback) - { - m_needsFeedback = needsFeedback; - } - - ///getAppliedImpulse is an estimated total applied impulse. - ///This feedback could be used to determine breaking constraints or playing sounds. - btScalar getAppliedImpulse() const - { - btAssert(m_needsFeedback); - return m_appliedImpulse; - } - - const btVector3& getAppliedLinearImpulse() const - { - btAssert(m_needsFeedback); - return m_appliedLinearImpulse; - } - - btVector3& getAppliedLinearImpulse() - { - btAssert(m_needsFeedback); - return m_appliedLinearImpulse; - } - - const btVector3& getAppliedAngularImpulseA() const - { - btAssert(m_needsFeedback); - return m_appliedAngularImpulseA; - } - - btVector3& getAppliedAngularImpulseA() - { - btAssert(m_needsFeedback); - return m_appliedAngularImpulseA; - } - - const btVector3& getAppliedAngularImpulseB() const - { - btAssert(m_needsFeedback); - return m_appliedAngularImpulseB; - } - - btVector3& getAppliedAngularImpulseB() - { - btAssert(m_needsFeedback); - return m_appliedAngularImpulseB; - } - - - - btTypedConstraintType getConstraintType () const - { - return btTypedConstraintType(m_objectType); - } - - void setDbgDrawSize(btScalar dbgDrawSize) - { - m_dbgDrawSize = dbgDrawSize; - } - btScalar getDbgDrawSize() - { - return m_dbgDrawSize; - } - -}; - -// returns angle in range [-SIMD_2_PI, SIMD_2_PI], closest to one of the limits -// all arguments should be normalized angles (i.e. in range [-SIMD_PI, SIMD_PI]) -SIMD_FORCE_INLINE btScalar btAdjustAngleToLimits(btScalar angleInRadians, btScalar angleLowerLimitInRadians, btScalar angleUpperLimitInRadians) -{ - if(angleLowerLimitInRadians >= angleUpperLimitInRadians) - { - return angleInRadians; - } - else if(angleInRadians < angleLowerLimitInRadians) - { - btScalar diffLo = btNormalizeAngle(angleLowerLimitInRadians - angleInRadians); // this is positive - btScalar diffHi = btFabs(btNormalizeAngle(angleUpperLimitInRadians - angleInRadians)); - return (diffLo < diffHi) ? angleInRadians : (angleInRadians + SIMD_2_PI); - } - else if(angleInRadians > angleUpperLimitInRadians) - { - btScalar diffHi = btNormalizeAngle(angleInRadians - angleUpperLimitInRadians); // this is positive - btScalar diffLo = btFabs(btNormalizeAngle(angleInRadians - angleLowerLimitInRadians)); - return (diffLo < diffHi) ? (angleInRadians - SIMD_2_PI) : angleInRadians; - } - else - { - return angleInRadians; - } -} - - -#endif //TYPED_CONSTRAINT_H diff --git a/bullet/src/BulletDynamics/ConstraintSolver/btUniversalConstraint.cpp b/bullet/src/BulletDynamics/ConstraintSolver/btUniversalConstraint.cpp deleted file mode 100644 index 564e5cbfb..000000000 --- a/bullet/src/BulletDynamics/ConstraintSolver/btUniversalConstraint.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library, http://bulletphysics.org -Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - - -#include "btUniversalConstraint.h" -#include "BulletDynamics/Dynamics/btRigidBody.h" -#include "LinearMath/btTransformUtil.h" - - - -#define UNIV_EPS btScalar(0.01f) - - -// constructor -// anchor, axis1 and axis2 are in world coordinate system -// axis1 must be orthogonal to axis2 -btUniversalConstraint::btUniversalConstraint(btRigidBody& rbA, btRigidBody& rbB, btVector3& anchor, btVector3& axis1, btVector3& axis2) -: btGeneric6DofConstraint(rbA, rbB, btTransform::getIdentity(), btTransform::getIdentity(), true), - m_anchor(anchor), - m_axis1(axis1), - m_axis2(axis2) -{ - // build frame basis - // 6DOF constraint uses Euler angles and to define limits - // it is assumed that rotational order is : - // Z - first, allowed limits are (-PI,PI); - // new position of Y - second (allowed limits are (-PI/2 + epsilon, PI/2 - epsilon), where epsilon is a small positive number - // used to prevent constraint from instability on poles; - // new position of X, allowed limits are (-PI,PI); - // So to simulate ODE Universal joint we should use parent axis as Z, child axis as Y and limit all other DOFs - // Build the frame in world coordinate system first - btVector3 zAxis = axis1.normalize(); - btVector3 yAxis = axis2.normalize(); - btVector3 xAxis = yAxis.cross(zAxis); // we want right coordinate system - btTransform frameInW; - frameInW.setIdentity(); - frameInW.getBasis().setValue( xAxis[0], yAxis[0], zAxis[0], - xAxis[1], yAxis[1], zAxis[1], - xAxis[2], yAxis[2], zAxis[2]); - frameInW.setOrigin(anchor); - // now get constraint frame in local coordinate systems - m_frameInA = rbA.getCenterOfMassTransform().inverse() * frameInW; - m_frameInB = rbB.getCenterOfMassTransform().inverse() * frameInW; - // sei limits - setLinearLowerLimit(btVector3(0., 0., 0.)); - setLinearUpperLimit(btVector3(0., 0., 0.)); - setAngularLowerLimit(btVector3(0.f, -SIMD_HALF_PI + UNIV_EPS, -SIMD_PI + UNIV_EPS)); - setAngularUpperLimit(btVector3(0.f, SIMD_HALF_PI - UNIV_EPS, SIMD_PI - UNIV_EPS)); -} - diff --git a/bullet/src/BulletDynamics/ConstraintSolver/btUniversalConstraint.h b/bullet/src/BulletDynamics/ConstraintSolver/btUniversalConstraint.h deleted file mode 100644 index fdde703f7..000000000 --- a/bullet/src/BulletDynamics/ConstraintSolver/btUniversalConstraint.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library, http://bulletphysics.org -Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef UNIVERSAL_CONSTRAINT_H -#define UNIVERSAL_CONSTRAINT_H - - - -#include "LinearMath/btVector3.h" -#include "btTypedConstraint.h" -#include "btGeneric6DofConstraint.h" - - - -/// Constraint similar to ODE Universal Joint -/// has 2 rotatioonal degrees of freedom, similar to Euler rotations around Z (axis 1) -/// and Y (axis 2) -/// Description from ODE manual : -/// "Given axis 1 on body 1, and axis 2 on body 2 that is perpendicular to axis 1, it keeps them perpendicular. -/// In other words, rotation of the two bodies about the direction perpendicular to the two axes will be equal." - -class btUniversalConstraint : public btGeneric6DofConstraint -{ -protected: - btVector3 m_anchor; - btVector3 m_axis1; - btVector3 m_axis2; -public: - // constructor - // anchor, axis1 and axis2 are in world coordinate system - // axis1 must be orthogonal to axis2 - btUniversalConstraint(btRigidBody& rbA, btRigidBody& rbB, btVector3& anchor, btVector3& axis1, btVector3& axis2); - // access - const btVector3& getAnchor() { return m_calculatedTransformA.getOrigin(); } - const btVector3& getAnchor2() { return m_calculatedTransformB.getOrigin(); } - const btVector3& getAxis1() { return m_axis1; } - const btVector3& getAxis2() { return m_axis2; } - btScalar getAngle1() { return getAngle(2); } - btScalar getAngle2() { return getAngle(1); } - // limits - void setUpperLimit(btScalar ang1max, btScalar ang2max) { setAngularUpperLimit(btVector3(0.f, ang1max, ang2max)); } - void setLowerLimit(btScalar ang1min, btScalar ang2min) { setAngularLowerLimit(btVector3(0.f, ang1min, ang2min)); } -}; - - - -#endif // UNIVERSAL_CONSTRAINT_H - diff --git a/bullet/src/BulletDynamics/Dynamics/Bullet-C-API.cpp b/bullet/src/BulletDynamics/Dynamics/Bullet-C-API.cpp deleted file mode 100644 index 873946d71..000000000 --- a/bullet/src/BulletDynamics/Dynamics/Bullet-C-API.cpp +++ /dev/null @@ -1,408 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -/* - Draft high-level generic physics C-API. For low-level access, use the physics SDK native API's. - Work in progress, functionality will be added on demand. - - If possible, use the richer Bullet C++ API, by including -*/ - -#include "Bullet-C-Api.h" -#include "btBulletDynamicsCommon.h" -#include "LinearMath/btAlignedAllocator.h" - - - -#include "LinearMath/btVector3.h" -#include "LinearMath/btScalar.h" -#include "LinearMath/btMatrix3x3.h" -#include "LinearMath/btTransform.h" -#include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h" -#include "BulletCollision/CollisionShapes/btTriangleShape.h" - -#include "BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h" -#include "BulletCollision/NarrowPhaseCollision/btPointCollector.h" -#include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h" -#include "BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h" -#include "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h" -#include "BulletCollision/NarrowPhaseCollision/btGjkEpa2.h" -#include "BulletCollision/CollisionShapes/btMinkowskiSumShape.h" -#include "BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h" -#include "BulletCollision/NarrowPhaseCollision/btSimplexSolverInterface.h" -#include "BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h" -#include "LinearMath/btStackAlloc.h" - -/* - Create and Delete a Physics SDK -*/ - -struct btPhysicsSdk -{ - -// btDispatcher* m_dispatcher; -// btOverlappingPairCache* m_pairCache; -// btConstraintSolver* m_constraintSolver - - btVector3 m_worldAabbMin; - btVector3 m_worldAabbMax; - - - //todo: version, hardware/optimization settings etc? - btPhysicsSdk() - :m_worldAabbMin(-1000,-1000,-1000), - m_worldAabbMax(1000,1000,1000) - { - - } - - -}; - -plPhysicsSdkHandle plNewBulletSdk() -{ - void* mem = btAlignedAlloc(sizeof(btPhysicsSdk),16); - return (plPhysicsSdkHandle)new (mem)btPhysicsSdk; -} - -void plDeletePhysicsSdk(plPhysicsSdkHandle physicsSdk) -{ - btPhysicsSdk* phys = reinterpret_cast(physicsSdk); - btAlignedFree(phys); -} - - -/* Dynamics World */ -plDynamicsWorldHandle plCreateDynamicsWorld(plPhysicsSdkHandle physicsSdkHandle) -{ - btPhysicsSdk* physicsSdk = reinterpret_cast(physicsSdkHandle); - void* mem = btAlignedAlloc(sizeof(btDefaultCollisionConfiguration),16); - btDefaultCollisionConfiguration* collisionConfiguration = new (mem)btDefaultCollisionConfiguration(); - mem = btAlignedAlloc(sizeof(btCollisionDispatcher),16); - btDispatcher* dispatcher = new (mem)btCollisionDispatcher(collisionConfiguration); - mem = btAlignedAlloc(sizeof(btAxisSweep3),16); - btBroadphaseInterface* pairCache = new (mem)btAxisSweep3(physicsSdk->m_worldAabbMin,physicsSdk->m_worldAabbMax); - mem = btAlignedAlloc(sizeof(btSequentialImpulseConstraintSolver),16); - btConstraintSolver* constraintSolver = new(mem) btSequentialImpulseConstraintSolver(); - - mem = btAlignedAlloc(sizeof(btDiscreteDynamicsWorld),16); - return (plDynamicsWorldHandle) new (mem)btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver,collisionConfiguration); -} -void plDeleteDynamicsWorld(plDynamicsWorldHandle world) -{ - //todo: also clean up the other allocations, axisSweep, pairCache,dispatcher,constraintSolver,collisionConfiguration - btDynamicsWorld* dynamicsWorld = reinterpret_cast< btDynamicsWorld* >(world); - btAlignedFree(dynamicsWorld); -} - -void plStepSimulation(plDynamicsWorldHandle world, plReal timeStep) -{ - btDynamicsWorld* dynamicsWorld = reinterpret_cast< btDynamicsWorld* >(world); - btAssert(dynamicsWorld); - dynamicsWorld->stepSimulation(timeStep); -} - -void plAddRigidBody(plDynamicsWorldHandle world, plRigidBodyHandle object) -{ - btDynamicsWorld* dynamicsWorld = reinterpret_cast< btDynamicsWorld* >(world); - btAssert(dynamicsWorld); - btRigidBody* body = reinterpret_cast< btRigidBody* >(object); - btAssert(body); - - dynamicsWorld->addRigidBody(body); -} - -void plRemoveRigidBody(plDynamicsWorldHandle world, plRigidBodyHandle object) -{ - btDynamicsWorld* dynamicsWorld = reinterpret_cast< btDynamicsWorld* >(world); - btAssert(dynamicsWorld); - btRigidBody* body = reinterpret_cast< btRigidBody* >(object); - btAssert(body); - - dynamicsWorld->removeRigidBody(body); -} - -/* Rigid Body */ - -plRigidBodyHandle plCreateRigidBody( void* user_data, float mass, plCollisionShapeHandle cshape ) -{ - btTransform trans; - trans.setIdentity(); - btVector3 localInertia(0,0,0); - btCollisionShape* shape = reinterpret_cast( cshape); - btAssert(shape); - if (mass) - { - shape->calculateLocalInertia(mass,localInertia); - } - void* mem = btAlignedAlloc(sizeof(btRigidBody),16); - btRigidBody::btRigidBodyConstructionInfo rbci(mass, 0,shape,localInertia); - btRigidBody* body = new (mem)btRigidBody(rbci); - body->setWorldTransform(trans); - body->setUserPointer(user_data); - return (plRigidBodyHandle) body; -} - -void plDeleteRigidBody(plRigidBodyHandle cbody) -{ - btRigidBody* body = reinterpret_cast< btRigidBody* >(cbody); - btAssert(body); - btAlignedFree( body); -} - - -/* Collision Shape definition */ - -plCollisionShapeHandle plNewSphereShape(plReal radius) -{ - void* mem = btAlignedAlloc(sizeof(btSphereShape),16); - return (plCollisionShapeHandle) new (mem)btSphereShape(radius); - -} - -plCollisionShapeHandle plNewBoxShape(plReal x, plReal y, plReal z) -{ - void* mem = btAlignedAlloc(sizeof(btBoxShape),16); - return (plCollisionShapeHandle) new (mem)btBoxShape(btVector3(x,y,z)); -} - -plCollisionShapeHandle plNewCapsuleShape(plReal radius, plReal height) -{ - //capsule is convex hull of 2 spheres, so use btMultiSphereShape - - const int numSpheres = 2; - btVector3 positions[numSpheres] = {btVector3(0,height,0),btVector3(0,-height,0)}; - btScalar radi[numSpheres] = {radius,radius}; - void* mem = btAlignedAlloc(sizeof(btMultiSphereShape),16); - return (plCollisionShapeHandle) new (mem)btMultiSphereShape(positions,radi,numSpheres); -} -plCollisionShapeHandle plNewConeShape(plReal radius, plReal height) -{ - void* mem = btAlignedAlloc(sizeof(btConeShape),16); - return (plCollisionShapeHandle) new (mem)btConeShape(radius,height); -} - -plCollisionShapeHandle plNewCylinderShape(plReal radius, plReal height) -{ - void* mem = btAlignedAlloc(sizeof(btCylinderShape),16); - return (plCollisionShapeHandle) new (mem)btCylinderShape(btVector3(radius,height,radius)); -} - -/* Convex Meshes */ -plCollisionShapeHandle plNewConvexHullShape() -{ - void* mem = btAlignedAlloc(sizeof(btConvexHullShape),16); - return (plCollisionShapeHandle) new (mem)btConvexHullShape(); -} - - -/* Concave static triangle meshes */ -plMeshInterfaceHandle plNewMeshInterface() -{ - return 0; -} - -plCollisionShapeHandle plNewCompoundShape() -{ - void* mem = btAlignedAlloc(sizeof(btCompoundShape),16); - return (plCollisionShapeHandle) new (mem)btCompoundShape(); -} - -void plAddChildShape(plCollisionShapeHandle compoundShapeHandle,plCollisionShapeHandle childShapeHandle, plVector3 childPos,plQuaternion childOrn) -{ - btCollisionShape* colShape = reinterpret_cast(compoundShapeHandle); - btAssert(colShape->getShapeType() == COMPOUND_SHAPE_PROXYTYPE); - btCompoundShape* compoundShape = reinterpret_cast(colShape); - btCollisionShape* childShape = reinterpret_cast(childShapeHandle); - btTransform localTrans; - localTrans.setIdentity(); - localTrans.setOrigin(btVector3(childPos[0],childPos[1],childPos[2])); - localTrans.setRotation(btQuaternion(childOrn[0],childOrn[1],childOrn[2],childOrn[3])); - compoundShape->addChildShape(localTrans,childShape); -} - -void plSetEuler(plReal yaw,plReal pitch,plReal roll, plQuaternion orient) -{ - btQuaternion orn; - orn.setEuler(yaw,pitch,roll); - orient[0] = orn.getX(); - orient[1] = orn.getY(); - orient[2] = orn.getZ(); - orient[3] = orn.getW(); - -} - - -// extern void plAddTriangle(plMeshInterfaceHandle meshHandle, plVector3 v0,plVector3 v1,plVector3 v2); -// extern plCollisionShapeHandle plNewStaticTriangleMeshShape(plMeshInterfaceHandle); - - -void plAddVertex(plCollisionShapeHandle cshape, plReal x,plReal y,plReal z) -{ - btCollisionShape* colShape = reinterpret_cast( cshape); - (void)colShape; - btAssert(colShape->getShapeType()==CONVEX_HULL_SHAPE_PROXYTYPE); - btConvexHullShape* convexHullShape = reinterpret_cast( cshape); - convexHullShape->addPoint(btVector3(x,y,z)); - -} - -void plDeleteShape(plCollisionShapeHandle cshape) -{ - btCollisionShape* shape = reinterpret_cast( cshape); - btAssert(shape); - btAlignedFree(shape); -} -void plSetScaling(plCollisionShapeHandle cshape, plVector3 cscaling) -{ - btCollisionShape* shape = reinterpret_cast( cshape); - btAssert(shape); - btVector3 scaling(cscaling[0],cscaling[1],cscaling[2]); - shape->setLocalScaling(scaling); -} - - - -void plSetPosition(plRigidBodyHandle object, const plVector3 position) -{ - btRigidBody* body = reinterpret_cast< btRigidBody* >(object); - btAssert(body); - btVector3 pos(position[0],position[1],position[2]); - btTransform worldTrans = body->getWorldTransform(); - worldTrans.setOrigin(pos); - body->setWorldTransform(worldTrans); -} - -void plSetOrientation(plRigidBodyHandle object, const plQuaternion orientation) -{ - btRigidBody* body = reinterpret_cast< btRigidBody* >(object); - btAssert(body); - btQuaternion orn(orientation[0],orientation[1],orientation[2],orientation[3]); - btTransform worldTrans = body->getWorldTransform(); - worldTrans.setRotation(orn); - body->setWorldTransform(worldTrans); -} - -void plSetOpenGLMatrix(plRigidBodyHandle object, plReal* matrix) -{ - btRigidBody* body = reinterpret_cast< btRigidBody* >(object); - btAssert(body); - btTransform& worldTrans = body->getWorldTransform(); - worldTrans.setFromOpenGLMatrix(matrix); -} - -void plGetOpenGLMatrix(plRigidBodyHandle object, plReal* matrix) -{ - btRigidBody* body = reinterpret_cast< btRigidBody* >(object); - btAssert(body); - body->getWorldTransform().getOpenGLMatrix(matrix); - -} - -void plGetPosition(plRigidBodyHandle object,plVector3 position) -{ - btRigidBody* body = reinterpret_cast< btRigidBody* >(object); - btAssert(body); - const btVector3& pos = body->getWorldTransform().getOrigin(); - position[0] = pos.getX(); - position[1] = pos.getY(); - position[2] = pos.getZ(); -} - -void plGetOrientation(plRigidBodyHandle object,plQuaternion orientation) -{ - btRigidBody* body = reinterpret_cast< btRigidBody* >(object); - btAssert(body); - const btQuaternion& orn = body->getWorldTransform().getRotation(); - orientation[0] = orn.getX(); - orientation[1] = orn.getY(); - orientation[2] = orn.getZ(); - orientation[3] = orn.getW(); -} - - - -//plRigidBodyHandle plRayCast(plDynamicsWorldHandle world, const plVector3 rayStart, const plVector3 rayEnd, plVector3 hitpoint, plVector3 normal); - -// extern plRigidBodyHandle plObjectCast(plDynamicsWorldHandle world, const plVector3 rayStart, const plVector3 rayEnd, plVector3 hitpoint, plVector3 normal); - -double plNearestPoints(float p1[3], float p2[3], float p3[3], float q1[3], float q2[3], float q3[3], float *pa, float *pb, float normal[3]) -{ - btVector3 vp(p1[0], p1[1], p1[2]); - btTriangleShape trishapeA(vp, - btVector3(p2[0], p2[1], p2[2]), - btVector3(p3[0], p3[1], p3[2])); - trishapeA.setMargin(0.000001f); - btVector3 vq(q1[0], q1[1], q1[2]); - btTriangleShape trishapeB(vq, - btVector3(q2[0], q2[1], q2[2]), - btVector3(q3[0], q3[1], q3[2])); - trishapeB.setMargin(0.000001f); - - // btVoronoiSimplexSolver sGjkSimplexSolver; - // btGjkEpaPenetrationDepthSolver penSolverPtr; - - static btSimplexSolverInterface sGjkSimplexSolver; - sGjkSimplexSolver.reset(); - - static btGjkEpaPenetrationDepthSolver Solver0; - static btMinkowskiPenetrationDepthSolver Solver1; - - btConvexPenetrationDepthSolver* Solver = NULL; - - Solver = &Solver1; - - btGjkPairDetector convexConvex(&trishapeA ,&trishapeB,&sGjkSimplexSolver,Solver); - - convexConvex.m_catchDegeneracies = 1; - - // btGjkPairDetector convexConvex(&trishapeA ,&trishapeB,&sGjkSimplexSolver,0); - - btPointCollector gjkOutput; - btGjkPairDetector::ClosestPointInput input; - - btStackAlloc gStackAlloc(1024*1024*2); - - input.m_stackAlloc = &gStackAlloc; - - btTransform tr; - tr.setIdentity(); - - input.m_transformA = tr; - input.m_transformB = tr; - - convexConvex.getClosestPoints(input, gjkOutput, 0); - - - if (gjkOutput.m_hasResult) - { - - pb[0] = pa[0] = gjkOutput.m_pointInWorld[0]; - pb[1] = pa[1] = gjkOutput.m_pointInWorld[1]; - pb[2] = pa[2] = gjkOutput.m_pointInWorld[2]; - - pb[0]+= gjkOutput.m_normalOnBInWorld[0] * gjkOutput.m_distance; - pb[1]+= gjkOutput.m_normalOnBInWorld[1] * gjkOutput.m_distance; - pb[2]+= gjkOutput.m_normalOnBInWorld[2] * gjkOutput.m_distance; - - normal[0] = gjkOutput.m_normalOnBInWorld[0]; - normal[1] = gjkOutput.m_normalOnBInWorld[1]; - normal[2] = gjkOutput.m_normalOnBInWorld[2]; - - return gjkOutput.m_distance; - } - return -1.0f; -} - diff --git a/bullet/src/BulletDynamics/Dynamics/btActionInterface.h b/bullet/src/BulletDynamics/Dynamics/btActionInterface.h deleted file mode 100644 index 1a986ce9b..000000000 --- a/bullet/src/BulletDynamics/Dynamics/btActionInterface.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef _BT_ACTION_INTERFACE_H -#define _BT_ACTION_INTERFACE_H - -class btIDebugDraw; -class btCollisionWorld; - -#include "LinearMath/btScalar.h" - -///Basic interface to allow actions such as vehicles and characters to be updated inside a btDynamicsWorld -class btActionInterface -{ - public: - - virtual ~btActionInterface() - { - } - - virtual void updateAction( btCollisionWorld* collisionWorld, btScalar deltaTimeStep)=0; - - virtual void debugDraw(btIDebugDraw* debugDrawer) = 0; - -}; - -#endif //_BT_ACTION_INTERFACE_H - diff --git a/bullet/src/BulletDynamics/Dynamics/btContinuousDynamicsWorld.cpp b/bullet/src/BulletDynamics/Dynamics/btContinuousDynamicsWorld.cpp deleted file mode 100644 index b3433f69f..000000000 --- a/bullet/src/BulletDynamics/Dynamics/btContinuousDynamicsWorld.cpp +++ /dev/null @@ -1,196 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2007 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#include "btContinuousDynamicsWorld.h" -#include "LinearMath/btQuickprof.h" - -//collision detection -#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h" -#include "BulletCollision/BroadphaseCollision/btSimpleBroadphase.h" -#include "BulletCollision/CollisionShapes/btCollisionShape.h" -#include "BulletCollision/CollisionDispatch/btSimulationIslandManager.h" - -//rigidbody & constraints -#include "BulletDynamics/Dynamics/btRigidBody.h" -#include "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h" -#include "BulletDynamics/ConstraintSolver/btContactSolverInfo.h" -#include "BulletDynamics/ConstraintSolver/btTypedConstraint.h" - - - -#include - -btContinuousDynamicsWorld::btContinuousDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration) -:btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver,collisionConfiguration) -{ -} - -btContinuousDynamicsWorld::~btContinuousDynamicsWorld() -{ -} - - -void btContinuousDynamicsWorld::internalSingleStepSimulation( btScalar timeStep) -{ - - startProfiling(timeStep); - - if(0 != m_internalPreTickCallback) { - (*m_internalPreTickCallback)(this, timeStep); - } - - - ///update aabbs information - updateAabbs(); - //static int frame=0; -// printf("frame %d\n",frame++); - - ///apply gravity, predict motion - predictUnconstraintMotion(timeStep); - - btDispatcherInfo& dispatchInfo = getDispatchInfo(); - - dispatchInfo.m_timeStep = timeStep; - dispatchInfo.m_stepCount = 0; - dispatchInfo.m_debugDraw = getDebugDrawer(); - - ///perform collision detection - performDiscreteCollisionDetection(); - - calculateSimulationIslands(); - - - getSolverInfo().m_timeStep = timeStep; - - - - ///solve contact and other joint constraints - solveConstraints(getSolverInfo()); - - ///CallbackTriggers(); - calculateTimeOfImpacts(timeStep); - - btScalar toi = dispatchInfo.m_timeOfImpact; -// if (toi < 1.f) -// printf("toi = %f\n",toi); - if (toi < 0.f) - printf("toi = %f\n",toi); - - - ///integrate transforms - integrateTransforms(timeStep * toi); - - ///update vehicle simulation - updateActions(timeStep); - - updateActivationState( timeStep ); - - if(0 != m_internalTickCallback) { - (*m_internalTickCallback)(this, timeStep); - } -} - -void btContinuousDynamicsWorld::calculateTimeOfImpacts(btScalar timeStep) -{ - ///these should be 'temporal' aabbs! - updateTemporalAabbs(timeStep); - - ///'toi' is the global smallest time of impact. However, we just calculate the time of impact for each object individually. - ///so we handle the case moving versus static properly, and we cheat for moving versus moving - btScalar toi = 1.f; - - - btDispatcherInfo& dispatchInfo = getDispatchInfo(); - dispatchInfo.m_timeStep = timeStep; - dispatchInfo.m_timeOfImpact = 1.f; - dispatchInfo.m_stepCount = 0; - dispatchInfo.m_dispatchFunc = btDispatcherInfo::DISPATCH_CONTINUOUS; - - ///calculate time of impact for overlapping pairs - - - btDispatcher* dispatcher = getDispatcher(); - if (dispatcher) - dispatcher->dispatchAllCollisionPairs(m_broadphasePairCache->getOverlappingPairCache(),dispatchInfo,m_dispatcher1); - - toi = dispatchInfo.m_timeOfImpact; - - dispatchInfo.m_dispatchFunc = btDispatcherInfo::DISPATCH_DISCRETE; - -} - -void btContinuousDynamicsWorld::updateTemporalAabbs(btScalar timeStep) -{ - - btVector3 temporalAabbMin,temporalAabbMax; - - for ( int i=0;igetCollisionShape()->getAabb(m_collisionObjects[i]->getWorldTransform(),temporalAabbMin,temporalAabbMax); - const btVector3& linvel = body->getLinearVelocity(); - - //make the AABB temporal - btScalar temporalAabbMaxx = temporalAabbMax.getX(); - btScalar temporalAabbMaxy = temporalAabbMax.getY(); - btScalar temporalAabbMaxz = temporalAabbMax.getZ(); - btScalar temporalAabbMinx = temporalAabbMin.getX(); - btScalar temporalAabbMiny = temporalAabbMin.getY(); - btScalar temporalAabbMinz = temporalAabbMin.getZ(); - - // add linear motion - btVector3 linMotion = linvel*timeStep; - - if (linMotion.x() > 0.f) - temporalAabbMaxx += linMotion.x(); - else - temporalAabbMinx += linMotion.x(); - if (linMotion.y() > 0.f) - temporalAabbMaxy += linMotion.y(); - else - temporalAabbMiny += linMotion.y(); - if (linMotion.z() > 0.f) - temporalAabbMaxz += linMotion.z(); - else - temporalAabbMinz += linMotion.z(); - - //add conservative angular motion - btScalar angularMotion(0);// = angvel.length() * GetAngularMotionDisc() * timeStep; - btVector3 angularMotion3d(angularMotion,angularMotion,angularMotion); - temporalAabbMin = btVector3(temporalAabbMinx,temporalAabbMiny,temporalAabbMinz); - temporalAabbMax = btVector3(temporalAabbMaxx,temporalAabbMaxy,temporalAabbMaxz); - - temporalAabbMin -= angularMotion3d; - temporalAabbMax += angularMotion3d; - - m_broadphasePairCache->setAabb(body->getBroadphaseHandle(),temporalAabbMin,temporalAabbMax,m_dispatcher1); - } - } - - //update aabb (of all moved objects) - - m_broadphasePairCache->calculateOverlappingPairs(m_dispatcher1); - - - -} - - - diff --git a/bullet/src/BulletDynamics/Dynamics/btContinuousDynamicsWorld.h b/bullet/src/BulletDynamics/Dynamics/btContinuousDynamicsWorld.h deleted file mode 100644 index 6c991a8e3..000000000 --- a/bullet/src/BulletDynamics/Dynamics/btContinuousDynamicsWorld.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2007 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef BT_CONTINUOUS_DYNAMICS_WORLD_H -#define BT_CONTINUOUS_DYNAMICS_WORLD_H - -#include "btDiscreteDynamicsWorld.h" - -///btContinuousDynamicsWorld adds optional (per object) continuous collision detection for fast moving objects to the btDiscreteDynamicsWorld. -///This copes with fast moving objects that otherwise would tunnel/miss collisions. -///Under construction, don't use yet! Please use btDiscreteDynamicsWorld instead. -class btContinuousDynamicsWorld : public btDiscreteDynamicsWorld -{ - - void updateTemporalAabbs(btScalar timeStep); - - public: - - btContinuousDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration); - virtual ~btContinuousDynamicsWorld(); - - ///time stepping with calculation of time of impact for selected fast moving objects - virtual void internalSingleStepSimulation( btScalar timeStep); - - virtual void calculateTimeOfImpacts(btScalar timeStep); - - virtual btDynamicsWorldType getWorldType() const - { - return BT_CONTINUOUS_DYNAMICS_WORLD; - } - -}; - -#endif //BT_CONTINUOUS_DYNAMICS_WORLD_H diff --git a/bullet/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp b/bullet/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp deleted file mode 100644 index 401b53052..000000000 --- a/bullet/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp +++ /dev/null @@ -1,1421 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#include "btDiscreteDynamicsWorld.h" - -//collision detection -#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h" -#include "BulletCollision/BroadphaseCollision/btSimpleBroadphase.h" -#include "BulletCollision/CollisionShapes/btCollisionShape.h" -#include "BulletCollision/CollisionDispatch/btSimulationIslandManager.h" -#include "LinearMath/btTransformUtil.h" -#include "LinearMath/btQuickprof.h" - -//rigidbody & constraints -#include "BulletDynamics/Dynamics/btRigidBody.h" -#include "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h" -#include "BulletDynamics/ConstraintSolver/btContactSolverInfo.h" -#include "BulletDynamics/ConstraintSolver/btTypedConstraint.h" -#include "BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h" -#include "BulletDynamics/ConstraintSolver/btHingeConstraint.h" -#include "BulletDynamics/ConstraintSolver/btConeTwistConstraint.h" -#include "BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h" -#include "BulletDynamics/ConstraintSolver/btSliderConstraint.h" - -//for debug rendering -#include "BulletCollision/CollisionShapes/btBoxShape.h" -#include "BulletCollision/CollisionShapes/btCapsuleShape.h" -#include "BulletCollision/CollisionShapes/btCompoundShape.h" -#include "BulletCollision/CollisionShapes/btConeShape.h" -#include "BulletCollision/CollisionShapes/btConvexTriangleMeshShape.h" -#include "BulletCollision/CollisionShapes/btCylinderShape.h" -#include "BulletCollision/CollisionShapes/btMultiSphereShape.h" -#include "BulletCollision/CollisionShapes/btPolyhedralConvexShape.h" -#include "BulletCollision/CollisionShapes/btSphereShape.h" -#include "BulletCollision/CollisionShapes/btTriangleCallback.h" -#include "BulletCollision/CollisionShapes/btTriangleMeshShape.h" -#include "BulletCollision/CollisionShapes/btStaticPlaneShape.h" -#include "LinearMath/btIDebugDraw.h" - - -#include "BulletDynamics/Dynamics/btActionInterface.h" -#include "LinearMath/btQuickprof.h" -#include "LinearMath/btMotionState.h" - - - - - -btDiscreteDynamicsWorld::btDiscreteDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver, btCollisionConfiguration* collisionConfiguration) -:btDynamicsWorld(dispatcher,pairCache,collisionConfiguration), -m_constraintSolver(constraintSolver), -m_gravity(0,-10,0), -m_localTime(btScalar(1.)/btScalar(60.)), -m_synchronizeAllMotionStates(false), -m_profileTimings(0) -{ - if (!m_constraintSolver) - { - void* mem = btAlignedAlloc(sizeof(btSequentialImpulseConstraintSolver),16); - m_constraintSolver = new (mem) btSequentialImpulseConstraintSolver; - m_ownsConstraintSolver = true; - } else - { - m_ownsConstraintSolver = false; - } - - { - void* mem = btAlignedAlloc(sizeof(btSimulationIslandManager),16); - m_islandManager = new (mem) btSimulationIslandManager(); - } - - m_ownsIslandManager = true; -} - - -btDiscreteDynamicsWorld::~btDiscreteDynamicsWorld() -{ - //only delete it when we created it - if (m_ownsIslandManager) - { - m_islandManager->~btSimulationIslandManager(); - btAlignedFree( m_islandManager); - } - if (m_ownsConstraintSolver) - { - - m_constraintSolver->~btConstraintSolver(); - btAlignedFree(m_constraintSolver); - } -} - -void btDiscreteDynamicsWorld::saveKinematicState(btScalar timeStep) -{ -///would like to iterate over m_nonStaticRigidBodies, but unfortunately old API allows -///to switch status _after_ adding kinematic objects to the world -///fix it for Bullet 3.x release - for (int i=0;igetActivationState() != ISLAND_SLEEPING) - { - if (body->isKinematicObject()) - { - //to calculate velocities next frame - body->saveKinematicState(timeStep); - } - } - } - -} - -void btDiscreteDynamicsWorld::debugDrawWorld() -{ - BT_PROFILE("debugDrawWorld"); - - if (getDebugDrawer() && getDebugDrawer()->getDebugMode() & btIDebugDraw::DBG_DrawContactPoints) - { - int numManifolds = getDispatcher()->getNumManifolds(); - btVector3 color(0,0,0); - for (int i=0;igetManifoldByIndexInternal(i); - //btCollisionObject* obA = static_cast(contactManifold->getBody0()); - //btCollisionObject* obB = static_cast(contactManifold->getBody1()); - - int numContacts = contactManifold->getNumContacts(); - for (int j=0;jgetContactPoint(j); - getDebugDrawer()->drawContactPoint(cp.m_positionWorldOnB,cp.m_normalWorldOnB,cp.getDistance(),cp.getLifeTime(),color); - } - } - } - bool drawConstraints = false; - if (getDebugDrawer()) - { - int mode = getDebugDrawer()->getDebugMode(); - if(mode & (btIDebugDraw::DBG_DrawConstraints | btIDebugDraw::DBG_DrawConstraintLimits)) - { - drawConstraints = true; - } - } - if(drawConstraints) - { - for(int i = getNumConstraints()-1; i>=0 ;i--) - { - btTypedConstraint* constraint = getConstraint(i); - debugDrawConstraint(constraint); - } - } - - - - if (getDebugDrawer() && getDebugDrawer()->getDebugMode() & (btIDebugDraw::DBG_DrawWireframe | btIDebugDraw::DBG_DrawAabb)) - { - int i; - - for ( i=0;igetDebugMode() & btIDebugDraw::DBG_DrawWireframe) - { - btVector3 color(btScalar(255.),btScalar(255.),btScalar(255.)); - switch(colObj->getActivationState()) - { - case ACTIVE_TAG: - color = btVector3(btScalar(255.),btScalar(255.),btScalar(255.)); break; - case ISLAND_SLEEPING: - color = btVector3(btScalar(0.),btScalar(255.),btScalar(0.));break; - case WANTS_DEACTIVATION: - color = btVector3(btScalar(0.),btScalar(255.),btScalar(255.));break; - case DISABLE_DEACTIVATION: - color = btVector3(btScalar(255.),btScalar(0.),btScalar(0.));break; - case DISABLE_SIMULATION: - color = btVector3(btScalar(255.),btScalar(255.),btScalar(0.));break; - default: - { - color = btVector3(btScalar(255.),btScalar(0.),btScalar(0.)); - } - }; - - debugDrawObject(colObj->getWorldTransform(),colObj->getCollisionShape(),color); - } - if (m_debugDrawer && (m_debugDrawer->getDebugMode() & btIDebugDraw::DBG_DrawAabb)) - { - btVector3 minAabb,maxAabb; - btVector3 colorvec(1,0,0); - colObj->getCollisionShape()->getAabb(colObj->getWorldTransform(), minAabb,maxAabb); - m_debugDrawer->drawAabb(minAabb,maxAabb,colorvec); - } - - } - - if (getDebugDrawer() && getDebugDrawer()->getDebugMode()) - { - for (i=0;idebugDraw(m_debugDrawer); - } - } - } -} - -void btDiscreteDynamicsWorld::clearForces() -{ - ///@todo: iterate over awake simulation islands! - for ( int i=0;iclearForces(); - } -} - -///apply gravity, call this once per timestep -void btDiscreteDynamicsWorld::applyGravity() -{ - ///@todo: iterate over awake simulation islands! - for ( int i=0;iisActive()) - { - body->applyGravity(); - } - } -} - - -void btDiscreteDynamicsWorld::synchronizeSingleMotionState(btRigidBody* body) -{ - btAssert(body); - - if (body->getMotionState() && !body->isStaticOrKinematicObject()) - { - //we need to call the update at least once, even for sleeping objects - //otherwise the 'graphics' transform never updates properly - ///@todo: add 'dirty' flag - //if (body->getActivationState() != ISLAND_SLEEPING) - { - btTransform interpolatedTransform; - btTransformUtil::integrateTransform(body->getInterpolationWorldTransform(), - body->getInterpolationLinearVelocity(),body->getInterpolationAngularVelocity(),m_localTime*body->getHitFraction(),interpolatedTransform); - body->getMotionState()->setWorldTransform(interpolatedTransform); - } - } -} - - -void btDiscreteDynamicsWorld::synchronizeMotionStates() -{ - BT_PROFILE("synchronizeMotionStates"); - if (m_synchronizeAllMotionStates) - { - //iterate over all collision objects - for ( int i=0;iisActive()) - synchronizeSingleMotionState(body); - } - } -} - - -int btDiscreteDynamicsWorld::stepSimulation( btScalar timeStep,int maxSubSteps, btScalar fixedTimeStep) -{ - startProfiling(timeStep); - - BT_PROFILE("stepSimulation"); - - int numSimulationSubSteps = 0; - - if (maxSubSteps) - { - //fixed timestep with interpolation - m_localTime += timeStep; - if (m_localTime >= fixedTimeStep) - { - numSimulationSubSteps = int( m_localTime / fixedTimeStep); - m_localTime -= numSimulationSubSteps * fixedTimeStep; - } - } else - { - //variable timestep - fixedTimeStep = timeStep; - m_localTime = timeStep; - if (btFuzzyZero(timeStep)) - { - numSimulationSubSteps = 0; - maxSubSteps = 0; - } else - { - numSimulationSubSteps = 1; - maxSubSteps = 1; - } - } - - //process some debugging flags - if (getDebugDrawer()) - { - btIDebugDraw* debugDrawer = getDebugDrawer (); - gDisableDeactivation = (debugDrawer->getDebugMode() & btIDebugDraw::DBG_NoDeactivation) != 0; - } - if (numSimulationSubSteps) - { - - saveKinematicState(fixedTimeStep); - - applyGravity(); - - //clamp the number of substeps, to prevent simulation grinding spiralling down to a halt - int clampedSimulationSteps = (numSimulationSubSteps > maxSubSteps)? maxSubSteps : numSimulationSubSteps; - - for (int i=0;iisActive()) - { - body->setGravity(gravity); - } - } -} - -btVector3 btDiscreteDynamicsWorld::getGravity () const -{ - return m_gravity; -} - -void btDiscreteDynamicsWorld::addCollisionObject(btCollisionObject* collisionObject,short int collisionFilterGroup,short int collisionFilterMask) -{ - btCollisionWorld::addCollisionObject(collisionObject,collisionFilterGroup,collisionFilterMask); -} - -void btDiscreteDynamicsWorld::removeCollisionObject(btCollisionObject* collisionObject) -{ - btRigidBody* body = btRigidBody::upcast(collisionObject); - if (body) - removeRigidBody(body); - else - btCollisionWorld::removeCollisionObject(collisionObject); -} - -void btDiscreteDynamicsWorld::removeRigidBody(btRigidBody* body) -{ - m_nonStaticRigidBodies.remove(body); - btCollisionWorld::removeCollisionObject(body); -} - - -void btDiscreteDynamicsWorld::addRigidBody(btRigidBody* body) -{ - if (!body->isStaticOrKinematicObject()) - { - body->setGravity(m_gravity); - } - - if (body->getCollisionShape()) - { - if (!body->isStaticObject()) - { - m_nonStaticRigidBodies.push_back(body); - } else - { - body->setActivationState(ISLAND_SLEEPING); - } - - bool isDynamic = !(body->isStaticObject() || body->isKinematicObject()); - short collisionFilterGroup = isDynamic? short(btBroadphaseProxy::DefaultFilter) : short(btBroadphaseProxy::StaticFilter); - short collisionFilterMask = isDynamic? short(btBroadphaseProxy::AllFilter) : short(btBroadphaseProxy::AllFilter ^ btBroadphaseProxy::StaticFilter); - - addCollisionObject(body,collisionFilterGroup,collisionFilterMask); - } -} - -void btDiscreteDynamicsWorld::addRigidBody(btRigidBody* body, short group, short mask) -{ - if (!body->isStaticOrKinematicObject()) - { - body->setGravity(m_gravity); - } - - if (body->getCollisionShape()) - { - if (!body->isStaticObject()) - { - m_nonStaticRigidBodies.push_back(body); - } - else - { - body->setActivationState(ISLAND_SLEEPING); - } - addCollisionObject(body,group,mask); - } -} - - -void btDiscreteDynamicsWorld::updateActions(btScalar timeStep) -{ - BT_PROFILE("updateActions"); - - for ( int i=0;iupdateAction( this, timeStep); - } -} - - -void btDiscreteDynamicsWorld::updateActivationState(btScalar timeStep) -{ - BT_PROFILE("updateActivationState"); - - for ( int i=0;iupdateDeactivation(timeStep); - - if (body->wantsSleeping()) - { - if (body->isStaticOrKinematicObject()) - { - body->setActivationState(ISLAND_SLEEPING); - } else - { - if (body->getActivationState() == ACTIVE_TAG) - body->setActivationState( WANTS_DEACTIVATION ); - if (body->getActivationState() == ISLAND_SLEEPING) - { - body->setAngularVelocity(btVector3(0,0,0)); - body->setLinearVelocity(btVector3(0,0,0)); - } - - } - } else - { - if (body->getActivationState() != DISABLE_DEACTIVATION) - body->setActivationState( ACTIVE_TAG ); - } - } - } -} - -void btDiscreteDynamicsWorld::addConstraint(btTypedConstraint* constraint,bool disableCollisionsBetweenLinkedBodies) -{ - m_constraints.push_back(constraint); - if (disableCollisionsBetweenLinkedBodies) - { - constraint->getRigidBodyA().addConstraintRef(constraint); - constraint->getRigidBodyB().addConstraintRef(constraint); - } -} - -void btDiscreteDynamicsWorld::removeConstraint(btTypedConstraint* constraint) -{ - m_constraints.remove(constraint); - constraint->getRigidBodyA().removeConstraintRef(constraint); - constraint->getRigidBodyB().removeConstraintRef(constraint); -} - -void btDiscreteDynamicsWorld::addAction(btActionInterface* action) -{ - m_actions.push_back(action); -} - -void btDiscreteDynamicsWorld::removeAction(btActionInterface* action) -{ - m_actions.remove(action); -} - - -void btDiscreteDynamicsWorld::addVehicle(btActionInterface* vehicle) -{ - addAction(vehicle); -} - -void btDiscreteDynamicsWorld::removeVehicle(btActionInterface* vehicle) -{ - removeAction(vehicle); -} - -void btDiscreteDynamicsWorld::addCharacter(btActionInterface* character) -{ - addAction(character); -} - -void btDiscreteDynamicsWorld::removeCharacter(btActionInterface* character) -{ - removeAction(character); -} - - -SIMD_FORCE_INLINE int btGetConstraintIslandId(const btTypedConstraint* lhs) -{ - int islandId; - - const btCollisionObject& rcolObj0 = lhs->getRigidBodyA(); - const btCollisionObject& rcolObj1 = lhs->getRigidBodyB(); - islandId= rcolObj0.getIslandTag()>=0?rcolObj0.getIslandTag():rcolObj1.getIslandTag(); - return islandId; - -} - - -class btSortConstraintOnIslandPredicate -{ - public: - - bool operator() ( const btTypedConstraint* lhs, const btTypedConstraint* rhs ) - { - int rIslandId0,lIslandId0; - rIslandId0 = btGetConstraintIslandId(rhs); - lIslandId0 = btGetConstraintIslandId(lhs); - return lIslandId0 < rIslandId0; - } -}; - - - - -void btDiscreteDynamicsWorld::solveConstraints(btContactSolverInfo& solverInfo) -{ - BT_PROFILE("solveConstraints"); - - struct InplaceSolverIslandCallback : public btSimulationIslandManager::IslandCallback - { - - btContactSolverInfo& m_solverInfo; - btConstraintSolver* m_solver; - btTypedConstraint** m_sortedConstraints; - int m_numConstraints; - btIDebugDraw* m_debugDrawer; - btStackAlloc* m_stackAlloc; - btDispatcher* m_dispatcher; - - InplaceSolverIslandCallback( - btContactSolverInfo& solverInfo, - btConstraintSolver* solver, - btTypedConstraint** sortedConstraints, - int numConstraints, - btIDebugDraw* debugDrawer, - btStackAlloc* stackAlloc, - btDispatcher* dispatcher) - :m_solverInfo(solverInfo), - m_solver(solver), - m_sortedConstraints(sortedConstraints), - m_numConstraints(numConstraints), - m_debugDrawer(debugDrawer), - m_stackAlloc(stackAlloc), - m_dispatcher(dispatcher) - { - - } - - InplaceSolverIslandCallback& operator=(InplaceSolverIslandCallback& other) - { - btAssert(0); - (void)other; - return *this; - } - virtual void ProcessIsland(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifolds,int numManifolds, int islandId) - { - if (islandId<0) - { - if (numManifolds + m_numConstraints) - { - ///we don't split islands, so all constraints/contact manifolds/bodies are passed into the solver regardless the island id - m_solver->solveGroup( bodies,numBodies,manifolds, numManifolds,&m_sortedConstraints[0],m_numConstraints,m_solverInfo,m_debugDrawer,m_stackAlloc,m_dispatcher); - } - } else - { - //also add all non-contact constraints/joints for this island - btTypedConstraint** startConstraint = 0; - int numCurConstraints = 0; - int i; - - //find the first constraint for this island - for (i=0;isolveGroup( bodies,numBodies,manifolds, numManifolds,startConstraint,numCurConstraints,m_solverInfo,m_debugDrawer,m_stackAlloc,m_dispatcher); - } - - } - } - - }; - - //sorted version of all btTypedConstraint, based on islandId - btAlignedObjectArray sortedConstraints; - sortedConstraints.resize( m_constraints.size()); - int i; - for (i=0;iprepareSolve(getCollisionWorld()->getNumCollisionObjects(), getCollisionWorld()->getDispatcher()->getNumManifolds()); - - /// solve all the constraints for this island - m_islandManager->buildAndProcessIslands(getCollisionWorld()->getDispatcher(),getCollisionWorld(),&solverCallback); - - m_constraintSolver->allSolved(solverInfo, m_debugDrawer, m_stackAlloc); -} - - - - -void btDiscreteDynamicsWorld::calculateSimulationIslands() -{ - BT_PROFILE("calculateSimulationIslands"); - - getSimulationIslandManager()->updateActivationState(getCollisionWorld(),getCollisionWorld()->getDispatcher()); - - { - int i; - int numConstraints = int(m_constraints.size()); - for (i=0;i< numConstraints ; i++ ) - { - btTypedConstraint* constraint = m_constraints[i]; - - const btRigidBody* colObj0 = &constraint->getRigidBodyA(); - const btRigidBody* colObj1 = &constraint->getRigidBodyB(); - - if (((colObj0) && (!(colObj0)->isStaticOrKinematicObject())) && - ((colObj1) && (!(colObj1)->isStaticOrKinematicObject()))) - { - if (colObj0->isActive() || colObj1->isActive()) - { - - getSimulationIslandManager()->getUnionFind().unite((colObj0)->getIslandTag(), - (colObj1)->getIslandTag()); - } - } - } - } - - //Store the island id in each body - getSimulationIslandManager()->storeIslandActivationState(getCollisionWorld()); - - -} - - -#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h" - -class btClosestNotMeConvexResultCallback : public btCollisionWorld::ClosestConvexResultCallback -{ - btCollisionObject* m_me; - btScalar m_allowedPenetration; - btOverlappingPairCache* m_pairCache; - btDispatcher* m_dispatcher; - - -public: - btClosestNotMeConvexResultCallback (btCollisionObject* me,const btVector3& fromA,const btVector3& toA,btOverlappingPairCache* pairCache,btDispatcher* dispatcher) : - btCollisionWorld::ClosestConvexResultCallback(fromA,toA), - m_allowedPenetration(0.0f), - m_me(me), - m_pairCache(pairCache), - m_dispatcher(dispatcher) - { - } - - virtual btScalar addSingleResult(btCollisionWorld::LocalConvexResult& convexResult,bool normalInWorldSpace) - { - if (convexResult.m_hitCollisionObject == m_me) - return 1.0f; - - //ignore result if there is no contact response - if(!convexResult.m_hitCollisionObject->hasContactResponse()) - return 1.0f; - - btVector3 linVelA,linVelB; - linVelA = m_convexToWorld-m_convexFromWorld; - linVelB = btVector3(0,0,0);//toB.getOrigin()-fromB.getOrigin(); - - btVector3 relativeVelocity = (linVelA-linVelB); - //don't report time of impact for motion away from the contact normal (or causes minor penetration) - if (convexResult.m_hitNormalLocal.dot(relativeVelocity)>=-m_allowedPenetration) - return 1.f; - - return ClosestConvexResultCallback::addSingleResult (convexResult, normalInWorldSpace); - } - - virtual bool needsCollision(btBroadphaseProxy* proxy0) const - { - //don't collide with itself - if (proxy0->m_clientObject == m_me) - return false; - - ///don't do CCD when the collision filters are not matching - if (!ClosestConvexResultCallback::needsCollision(proxy0)) - return false; - - btCollisionObject* otherObj = (btCollisionObject*) proxy0->m_clientObject; - - //call needsResponse, see http://code.google.com/p/bullet/issues/detail?id=179 - if (m_dispatcher->needsResponse(m_me,otherObj)) - { - ///don't do CCD when there are already contact points (touching contact/penetration) - btAlignedObjectArray manifoldArray; - btBroadphasePair* collisionPair = m_pairCache->findPair(m_me->getBroadphaseHandle(),proxy0); - if (collisionPair) - { - if (collisionPair->m_algorithm) - { - manifoldArray.resize(0); - collisionPair->m_algorithm->getAllContactManifolds(manifoldArray); - for (int j=0;jgetNumContacts()>0) - return false; - } - } - } - } - return true; - } - - -}; - -///internal debugging variable. this value shouldn't be too high -int gNumClampedCcdMotions=0; - -//#include "stdio.h" -void btDiscreteDynamicsWorld::integrateTransforms(btScalar timeStep) -{ - BT_PROFILE("integrateTransforms"); - btTransform predictedTrans; - for ( int i=0;isetHitFraction(1.f); - - if (body->isActive() && (!body->isStaticOrKinematicObject())) - { - body->predictIntegratedTransform(timeStep, predictedTrans); - btScalar squareMotion = (predictedTrans.getOrigin()-body->getWorldTransform().getOrigin()).length2(); - - if (body->getCcdSquareMotionThreshold() && body->getCcdSquareMotionThreshold() < squareMotion) - { - BT_PROFILE("CCD motion clamping"); - if (body->getCollisionShape()->isConvex()) - { - gNumClampedCcdMotions++; - - btClosestNotMeConvexResultCallback sweepResults(body,body->getWorldTransform().getOrigin(),predictedTrans.getOrigin(),getBroadphase()->getOverlappingPairCache(),getDispatcher()); - //btConvexShape* convexShape = static_cast(body->getCollisionShape()); - btSphereShape tmpSphere(body->getCcdSweptSphereRadius());//btConvexShape* convexShape = static_cast(body->getCollisionShape()); - - sweepResults.m_collisionFilterGroup = body->getBroadphaseProxy()->m_collisionFilterGroup; - sweepResults.m_collisionFilterMask = body->getBroadphaseProxy()->m_collisionFilterMask; - - convexSweepTest(&tmpSphere,body->getWorldTransform(),predictedTrans,sweepResults); - if (sweepResults.hasHit() && (sweepResults.m_closestHitFraction < 1.f)) - { - body->setHitFraction(sweepResults.m_closestHitFraction); - body->predictIntegratedTransform(timeStep*body->getHitFraction(), predictedTrans); - body->setHitFraction(0.f); -// printf("clamped integration to hit fraction = %f\n",fraction); - } - } - } - - body->proceedToTransform( predictedTrans); - } - } -} - - - - - -void btDiscreteDynamicsWorld::predictUnconstraintMotion(btScalar timeStep) -{ - BT_PROFILE("predictUnconstraintMotion"); - for ( int i=0;iisStaticOrKinematicObject()) - { - body->integrateVelocities( timeStep); - //damping - body->applyDamping(timeStep); - - body->predictIntegratedTransform(timeStep,body->getInterpolationWorldTransform()); - } - } -} - - -void btDiscreteDynamicsWorld::startProfiling(btScalar timeStep) -{ - (void)timeStep; - -#ifndef BT_NO_PROFILE - CProfileManager::Reset(); -#endif //BT_NO_PROFILE - -} - - - - - - -class DebugDrawcallback : public btTriangleCallback, public btInternalTriangleIndexCallback -{ - btIDebugDraw* m_debugDrawer; - btVector3 m_color; - btTransform m_worldTrans; - -public: - - DebugDrawcallback(btIDebugDraw* debugDrawer,const btTransform& worldTrans,const btVector3& color) : - m_debugDrawer(debugDrawer), - m_color(color), - m_worldTrans(worldTrans) - { - } - - virtual void internalProcessTriangleIndex(btVector3* triangle,int partId,int triangleIndex) - { - processTriangle(triangle,partId,triangleIndex); - } - - virtual void processTriangle(btVector3* triangle,int partId, int triangleIndex) - { - (void)partId; - (void)triangleIndex; - - btVector3 wv0,wv1,wv2; - wv0 = m_worldTrans*triangle[0]; - wv1 = m_worldTrans*triangle[1]; - wv2 = m_worldTrans*triangle[2]; - m_debugDrawer->drawLine(wv0,wv1,m_color); - m_debugDrawer->drawLine(wv1,wv2,m_color); - m_debugDrawer->drawLine(wv2,wv0,m_color); - } -}; - -void btDiscreteDynamicsWorld::debugDrawSphere(btScalar radius, const btTransform& transform, const btVector3& color) -{ - btVector3 start = transform.getOrigin(); - - const btVector3 xoffs = transform.getBasis() * btVector3(radius,0,0); - const btVector3 yoffs = transform.getBasis() * btVector3(0,radius,0); - const btVector3 zoffs = transform.getBasis() * btVector3(0,0,radius); - - // XY - getDebugDrawer()->drawLine(start-xoffs, start+yoffs, color); - getDebugDrawer()->drawLine(start+yoffs, start+xoffs, color); - getDebugDrawer()->drawLine(start+xoffs, start-yoffs, color); - getDebugDrawer()->drawLine(start-yoffs, start-xoffs, color); - - // XZ - getDebugDrawer()->drawLine(start-xoffs, start+zoffs, color); - getDebugDrawer()->drawLine(start+zoffs, start+xoffs, color); - getDebugDrawer()->drawLine(start+xoffs, start-zoffs, color); - getDebugDrawer()->drawLine(start-zoffs, start-xoffs, color); - - // YZ - getDebugDrawer()->drawLine(start-yoffs, start+zoffs, color); - getDebugDrawer()->drawLine(start+zoffs, start+yoffs, color); - getDebugDrawer()->drawLine(start+yoffs, start-zoffs, color); - getDebugDrawer()->drawLine(start-zoffs, start-yoffs, color); -} - -void btDiscreteDynamicsWorld::debugDrawObject(const btTransform& worldTransform, const btCollisionShape* shape, const btVector3& color) -{ - // Draw a small simplex at the center of the object - { - btVector3 start = worldTransform.getOrigin(); - getDebugDrawer()->drawLine(start, start+worldTransform.getBasis() * btVector3(1,0,0), btVector3(1,0,0)); - getDebugDrawer()->drawLine(start, start+worldTransform.getBasis() * btVector3(0,1,0), btVector3(0,1,0)); - getDebugDrawer()->drawLine(start, start+worldTransform.getBasis() * btVector3(0,0,1), btVector3(0,0,1)); - } - - if (shape->getShapeType() == COMPOUND_SHAPE_PROXYTYPE) - { - const btCompoundShape* compoundShape = static_cast(shape); - for (int i=compoundShape->getNumChildShapes()-1;i>=0;i--) - { - btTransform childTrans = compoundShape->getChildTransform(i); - const btCollisionShape* colShape = compoundShape->getChildShape(i); - debugDrawObject(worldTransform*childTrans,colShape,color); - } - - } else - { - switch (shape->getShapeType()) - { - - case SPHERE_SHAPE_PROXYTYPE: - { - const btSphereShape* sphereShape = static_cast(shape); - btScalar radius = sphereShape->getMargin();//radius doesn't include the margin, so draw with margin - - debugDrawSphere(radius, worldTransform, color); - break; - } - case MULTI_SPHERE_SHAPE_PROXYTYPE: - { - const btMultiSphereShape* multiSphereShape = static_cast(shape); - - btTransform childTransform; - childTransform.setIdentity(); - - for (int i = multiSphereShape->getSphereCount()-1; i>=0;i--) - { - childTransform.setOrigin(multiSphereShape->getSpherePosition(i)); - debugDrawSphere(multiSphereShape->getSphereRadius(i), worldTransform*childTransform, color); - } - - break; - } - case CAPSULE_SHAPE_PROXYTYPE: - { - const btCapsuleShape* capsuleShape = static_cast(shape); - - btScalar radius = capsuleShape->getRadius(); - btScalar halfHeight = capsuleShape->getHalfHeight(); - - int upAxis = capsuleShape->getUpAxis(); - - - btVector3 capStart(0.f,0.f,0.f); - capStart[upAxis] = -halfHeight; - - btVector3 capEnd(0.f,0.f,0.f); - capEnd[upAxis] = halfHeight; - - // Draw the ends - { - - btTransform childTransform = worldTransform; - childTransform.getOrigin() = worldTransform * capStart; - debugDrawSphere(radius, childTransform, color); - } - - { - btTransform childTransform = worldTransform; - childTransform.getOrigin() = worldTransform * capEnd; - debugDrawSphere(radius, childTransform, color); - } - - // Draw some additional lines - btVector3 start = worldTransform.getOrigin(); - - - capStart[(upAxis+1)%3] = radius; - capEnd[(upAxis+1)%3] = radius; - getDebugDrawer()->drawLine(start+worldTransform.getBasis() * capStart,start+worldTransform.getBasis() * capEnd, color); - capStart[(upAxis+1)%3] = -radius; - capEnd[(upAxis+1)%3] = -radius; - getDebugDrawer()->drawLine(start+worldTransform.getBasis() * capStart,start+worldTransform.getBasis() * capEnd, color); - - capStart[(upAxis+1)%3] = 0.f; - capEnd[(upAxis+1)%3] = 0.f; - - capStart[(upAxis+2)%3] = radius; - capEnd[(upAxis+2)%3] = radius; - getDebugDrawer()->drawLine(start+worldTransform.getBasis() * capStart,start+worldTransform.getBasis() * capEnd, color); - capStart[(upAxis+2)%3] = -radius; - capEnd[(upAxis+2)%3] = -radius; - getDebugDrawer()->drawLine(start+worldTransform.getBasis() * capStart,start+worldTransform.getBasis() * capEnd, color); - - - break; - } - case CONE_SHAPE_PROXYTYPE: - { - const btConeShape* coneShape = static_cast(shape); - btScalar radius = coneShape->getRadius();//+coneShape->getMargin(); - btScalar height = coneShape->getHeight();//+coneShape->getMargin(); - btVector3 start = worldTransform.getOrigin(); - - int upAxis= coneShape->getConeUpIndex(); - - - btVector3 offsetHeight(0,0,0); - offsetHeight[upAxis] = height * btScalar(0.5); - btVector3 offsetRadius(0,0,0); - offsetRadius[(upAxis+1)%3] = radius; - btVector3 offset2Radius(0,0,0); - offset2Radius[(upAxis+2)%3] = radius; - - getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight),start+worldTransform.getBasis() * (-offsetHeight+offsetRadius),color); - getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight),start+worldTransform.getBasis() * (-offsetHeight-offsetRadius),color); - getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight),start+worldTransform.getBasis() * (-offsetHeight+offset2Radius),color); - getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight),start+worldTransform.getBasis() * (-offsetHeight-offset2Radius),color); - - - - break; - - } - case CYLINDER_SHAPE_PROXYTYPE: - { - const btCylinderShape* cylinder = static_cast(shape); - int upAxis = cylinder->getUpAxis(); - btScalar radius = cylinder->getRadius(); - btScalar halfHeight = cylinder->getHalfExtentsWithMargin()[upAxis]; - btVector3 start = worldTransform.getOrigin(); - btVector3 offsetHeight(0,0,0); - offsetHeight[upAxis] = halfHeight; - btVector3 offsetRadius(0,0,0); - offsetRadius[(upAxis+1)%3] = radius; - getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight+offsetRadius),start+worldTransform.getBasis() * (-offsetHeight+offsetRadius),color); - getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight-offsetRadius),start+worldTransform.getBasis() * (-offsetHeight-offsetRadius),color); - break; - } - - case STATIC_PLANE_PROXYTYPE: - { - const btStaticPlaneShape* staticPlaneShape = static_cast(shape); - btScalar planeConst = staticPlaneShape->getPlaneConstant(); - const btVector3& planeNormal = staticPlaneShape->getPlaneNormal(); - btVector3 planeOrigin = planeNormal * planeConst; - btVector3 vec0,vec1; - btPlaneSpace1(planeNormal,vec0,vec1); - btScalar vecLen = 100.f; - btVector3 pt0 = planeOrigin + vec0*vecLen; - btVector3 pt1 = planeOrigin - vec0*vecLen; - btVector3 pt2 = planeOrigin + vec1*vecLen; - btVector3 pt3 = planeOrigin - vec1*vecLen; - getDebugDrawer()->drawLine(worldTransform*pt0,worldTransform*pt1,color); - getDebugDrawer()->drawLine(worldTransform*pt2,worldTransform*pt3,color); - break; - - } - default: - { - - if (shape->isConcave()) - { - btConcaveShape* concaveMesh = (btConcaveShape*) shape; - - ///@todo pass camera, for some culling? no -> we are not a graphics lib - btVector3 aabbMax(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT)); - btVector3 aabbMin(btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT)); - - DebugDrawcallback drawCallback(getDebugDrawer(),worldTransform,color); - concaveMesh->processAllTriangles(&drawCallback,aabbMin,aabbMax); - - } - - if (shape->getShapeType() == CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE) - { - btConvexTriangleMeshShape* convexMesh = (btConvexTriangleMeshShape*) shape; - //todo: pass camera for some culling - btVector3 aabbMax(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT)); - btVector3 aabbMin(btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT)); - //DebugDrawcallback drawCallback; - DebugDrawcallback drawCallback(getDebugDrawer(),worldTransform,color); - convexMesh->getMeshInterface()->InternalProcessAllTriangles(&drawCallback,aabbMin,aabbMax); - } - - - /// for polyhedral shapes - if (shape->isPolyhedral()) - { - btPolyhedralConvexShape* polyshape = (btPolyhedralConvexShape*) shape; - - int i; - for (i=0;igetNumEdges();i++) - { - btVector3 a,b; - polyshape->getEdge(i,a,b); - btVector3 wa = worldTransform * a; - btVector3 wb = worldTransform * b; - getDebugDrawer()->drawLine(wa,wb,color); - - } - - - } - } - } - } -} - - -void btDiscreteDynamicsWorld::debugDrawConstraint(btTypedConstraint* constraint) -{ - bool drawFrames = (getDebugDrawer()->getDebugMode() & btIDebugDraw::DBG_DrawConstraints) != 0; - bool drawLimits = (getDebugDrawer()->getDebugMode() & btIDebugDraw::DBG_DrawConstraintLimits) != 0; - btScalar dbgDrawSize = constraint->getDbgDrawSize(); - if(dbgDrawSize <= btScalar(0.f)) - { - return; - } - - switch(constraint->getConstraintType()) - { - case POINT2POINT_CONSTRAINT_TYPE: - { - btPoint2PointConstraint* p2pC = (btPoint2PointConstraint*)constraint; - btTransform tr; - tr.setIdentity(); - btVector3 pivot = p2pC->getPivotInA(); - pivot = p2pC->getRigidBodyA().getCenterOfMassTransform() * pivot; - tr.setOrigin(pivot); - getDebugDrawer()->drawTransform(tr, dbgDrawSize); - // that ideally should draw the same frame - pivot = p2pC->getPivotInB(); - pivot = p2pC->getRigidBodyB().getCenterOfMassTransform() * pivot; - tr.setOrigin(pivot); - if(drawFrames) getDebugDrawer()->drawTransform(tr, dbgDrawSize); - } - break; - case HINGE_CONSTRAINT_TYPE: - { - btHingeConstraint* pHinge = (btHingeConstraint*)constraint; - btTransform tr = pHinge->getRigidBodyA().getCenterOfMassTransform() * pHinge->getAFrame(); - if(drawFrames) getDebugDrawer()->drawTransform(tr, dbgDrawSize); - tr = pHinge->getRigidBodyB().getCenterOfMassTransform() * pHinge->getBFrame(); - if(drawFrames) getDebugDrawer()->drawTransform(tr, dbgDrawSize); - btScalar minAng = pHinge->getLowerLimit(); - btScalar maxAng = pHinge->getUpperLimit(); - if(minAng == maxAng) - { - break; - } - bool drawSect = true; - if(minAng > maxAng) - { - minAng = btScalar(0.f); - maxAng = SIMD_2_PI; - drawSect = false; - } - if(drawLimits) - { - btVector3& center = tr.getOrigin(); - btVector3 normal = tr.getBasis().getColumn(2); - btVector3 axis = tr.getBasis().getColumn(0); - getDebugDrawer()->drawArc(center, normal, axis, dbgDrawSize, dbgDrawSize, minAng, maxAng, btVector3(0,0,0), drawSect); - } - } - break; - case CONETWIST_CONSTRAINT_TYPE: - { - btConeTwistConstraint* pCT = (btConeTwistConstraint*)constraint; - btTransform tr = pCT->getRigidBodyA().getCenterOfMassTransform() * pCT->getAFrame(); - if(drawFrames) getDebugDrawer()->drawTransform(tr, dbgDrawSize); - tr = pCT->getRigidBodyB().getCenterOfMassTransform() * pCT->getBFrame(); - if(drawFrames) getDebugDrawer()->drawTransform(tr, dbgDrawSize); - if(drawLimits) - { - //const btScalar length = btScalar(5); - const btScalar length = dbgDrawSize; - static int nSegments = 8*4; - btScalar fAngleInRadians = btScalar(2.*3.1415926) * (btScalar)(nSegments-1)/btScalar(nSegments); - btVector3 pPrev = pCT->GetPointForAngle(fAngleInRadians, length); - pPrev = tr * pPrev; - for (int i=0; iGetPointForAngle(fAngleInRadians, length); - pCur = tr * pCur; - getDebugDrawer()->drawLine(pPrev, pCur, btVector3(0,0,0)); - - if (i%(nSegments/8) == 0) - getDebugDrawer()->drawLine(tr.getOrigin(), pCur, btVector3(0,0,0)); - - pPrev = pCur; - } - btScalar tws = pCT->getTwistSpan(); - btScalar twa = pCT->getTwistAngle(); - bool useFrameB = (pCT->getRigidBodyB().getInvMass() > btScalar(0.f)); - if(useFrameB) - { - tr = pCT->getRigidBodyB().getCenterOfMassTransform() * pCT->getBFrame(); - } - else - { - tr = pCT->getRigidBodyA().getCenterOfMassTransform() * pCT->getAFrame(); - } - btVector3 pivot = tr.getOrigin(); - btVector3 normal = tr.getBasis().getColumn(0); - btVector3 axis1 = tr.getBasis().getColumn(1); - getDebugDrawer()->drawArc(pivot, normal, axis1, dbgDrawSize, dbgDrawSize, -twa-tws, -twa+tws, btVector3(0,0,0), true); - - } - } - break; - case D6_CONSTRAINT_TYPE: - { - btGeneric6DofConstraint* p6DOF = (btGeneric6DofConstraint*)constraint; - btTransform tr = p6DOF->getCalculatedTransformA(); - if(drawFrames) getDebugDrawer()->drawTransform(tr, dbgDrawSize); - tr = p6DOF->getCalculatedTransformB(); - if(drawFrames) getDebugDrawer()->drawTransform(tr, dbgDrawSize); - if(drawLimits) - { - tr = p6DOF->getCalculatedTransformA(); - const btVector3& center = p6DOF->getCalculatedTransformB().getOrigin(); - btVector3 up = tr.getBasis().getColumn(2); - btVector3 axis = tr.getBasis().getColumn(0); - btScalar minTh = p6DOF->getRotationalLimitMotor(1)->m_loLimit; - btScalar maxTh = p6DOF->getRotationalLimitMotor(1)->m_hiLimit; - btScalar minPs = p6DOF->getRotationalLimitMotor(2)->m_loLimit; - btScalar maxPs = p6DOF->getRotationalLimitMotor(2)->m_hiLimit; - getDebugDrawer()->drawSpherePatch(center, up, axis, dbgDrawSize * btScalar(.9f), minTh, maxTh, minPs, maxPs, btVector3(0,0,0)); - axis = tr.getBasis().getColumn(1); - btScalar ay = p6DOF->getAngle(1); - btScalar az = p6DOF->getAngle(2); - btScalar cy = btCos(ay); - btScalar sy = btSin(ay); - btScalar cz = btCos(az); - btScalar sz = btSin(az); - btVector3 ref; - ref[0] = cy*cz*axis[0] + cy*sz*axis[1] - sy*axis[2]; - ref[1] = -sz*axis[0] + cz*axis[1]; - ref[2] = cz*sy*axis[0] + sz*sy*axis[1] + cy*axis[2]; - tr = p6DOF->getCalculatedTransformB(); - btVector3 normal = -tr.getBasis().getColumn(0); - btScalar minFi = p6DOF->getRotationalLimitMotor(0)->m_loLimit; - btScalar maxFi = p6DOF->getRotationalLimitMotor(0)->m_hiLimit; - if(minFi > maxFi) - { - getDebugDrawer()->drawArc(center, normal, ref, dbgDrawSize, dbgDrawSize, -SIMD_PI, SIMD_PI, btVector3(0,0,0), false); - } - else if(minFi < maxFi) - { - getDebugDrawer()->drawArc(center, normal, ref, dbgDrawSize, dbgDrawSize, minFi, maxFi, btVector3(0,0,0), true); - } - tr = p6DOF->getCalculatedTransformA(); - btVector3 bbMin = p6DOF->getTranslationalLimitMotor()->m_lowerLimit; - btVector3 bbMax = p6DOF->getTranslationalLimitMotor()->m_upperLimit; - getDebugDrawer()->drawBox(bbMin, bbMax, tr, btVector3(0,0,0)); - } - } - break; - case SLIDER_CONSTRAINT_TYPE: - { - btSliderConstraint* pSlider = (btSliderConstraint*)constraint; - btTransform tr = pSlider->getCalculatedTransformA(); - if(drawFrames) getDebugDrawer()->drawTransform(tr, dbgDrawSize); - tr = pSlider->getCalculatedTransformB(); - if(drawFrames) getDebugDrawer()->drawTransform(tr, dbgDrawSize); - if(drawLimits) - { - btTransform tr = pSlider->getCalculatedTransformA(); - btVector3 li_min = tr * btVector3(pSlider->getLowerLinLimit(), 0.f, 0.f); - btVector3 li_max = tr * btVector3(pSlider->getUpperLinLimit(), 0.f, 0.f); - getDebugDrawer()->drawLine(li_min, li_max, btVector3(0, 0, 0)); - btVector3 normal = tr.getBasis().getColumn(0); - btVector3 axis = tr.getBasis().getColumn(1); - btScalar a_min = pSlider->getLowerAngLimit(); - btScalar a_max = pSlider->getUpperAngLimit(); - const btVector3& center = pSlider->getCalculatedTransformB().getOrigin(); - getDebugDrawer()->drawArc(center, normal, axis, dbgDrawSize, dbgDrawSize, a_min, a_max, btVector3(0,0,0), true); - } - } - break; - default : - break; - } - return; -} - - - - - -void btDiscreteDynamicsWorld::setConstraintSolver(btConstraintSolver* solver) -{ - if (m_ownsConstraintSolver) - { - btAlignedFree( m_constraintSolver); - } - m_ownsConstraintSolver = false; - m_constraintSolver = solver; -} - -btConstraintSolver* btDiscreteDynamicsWorld::getConstraintSolver() -{ - return m_constraintSolver; -} - - -int btDiscreteDynamicsWorld::getNumConstraints() const -{ - return int(m_constraints.size()); -} -btTypedConstraint* btDiscreteDynamicsWorld::getConstraint(int index) -{ - return m_constraints[index]; -} -const btTypedConstraint* btDiscreteDynamicsWorld::getConstraint(int index) const -{ - return m_constraints[index]; -} - - diff --git a/bullet/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h b/bullet/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h deleted file mode 100644 index 8c7b44e11..000000000 --- a/bullet/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h +++ /dev/null @@ -1,197 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#ifndef BT_DISCRETE_DYNAMICS_WORLD_H -#define BT_DISCRETE_DYNAMICS_WORLD_H - -#include "btDynamicsWorld.h" - -class btDispatcher; -class btOverlappingPairCache; -class btConstraintSolver; -class btSimulationIslandManager; -class btTypedConstraint; -class btActionInterface; - -class btIDebugDraw; -#include "LinearMath/btAlignedObjectArray.h" - - -///btDiscreteDynamicsWorld provides discrete rigid body simulation -///those classes replace the obsolete CcdPhysicsEnvironment/CcdPhysicsController -class btDiscreteDynamicsWorld : public btDynamicsWorld -{ -protected: - - btConstraintSolver* m_constraintSolver; - - btSimulationIslandManager* m_islandManager; - - btAlignedObjectArray m_constraints; - - btAlignedObjectArray m_nonStaticRigidBodies; - - btVector3 m_gravity; - - //for variable timesteps - btScalar m_localTime; - //for variable timesteps - - bool m_ownsIslandManager; - bool m_ownsConstraintSolver; - bool m_synchronizeAllMotionStates; - - btAlignedObjectArray m_actions; - - int m_profileTimings; - - virtual void predictUnconstraintMotion(btScalar timeStep); - - virtual void integrateTransforms(btScalar timeStep); - - virtual void calculateSimulationIslands(); - - virtual void solveConstraints(btContactSolverInfo& solverInfo); - - void updateActivationState(btScalar timeStep); - - void updateActions(btScalar timeStep); - - void startProfiling(btScalar timeStep); - - virtual void internalSingleStepSimulation( btScalar timeStep); - - - virtual void saveKinematicState(btScalar timeStep); - - void debugDrawSphere(btScalar radius, const btTransform& transform, const btVector3& color); - - -public: - - - ///this btDiscreteDynamicsWorld constructor gets created objects from the user, and will not delete those - btDiscreteDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration); - - virtual ~btDiscreteDynamicsWorld(); - - ///if maxSubSteps > 0, it will interpolate motion between fixedTimeStep's - virtual int stepSimulation( btScalar timeStep,int maxSubSteps=1, btScalar fixedTimeStep=btScalar(1.)/btScalar(60.)); - - - virtual void synchronizeMotionStates(); - - ///this can be useful to synchronize a single rigid body -> graphics object - void synchronizeSingleMotionState(btRigidBody* body); - - virtual void addConstraint(btTypedConstraint* constraint, bool disableCollisionsBetweenLinkedBodies=false); - - virtual void removeConstraint(btTypedConstraint* constraint); - - virtual void addAction(btActionInterface*); - - virtual void removeAction(btActionInterface*); - - btSimulationIslandManager* getSimulationIslandManager() - { - return m_islandManager; - } - - const btSimulationIslandManager* getSimulationIslandManager() const - { - return m_islandManager; - } - - btCollisionWorld* getCollisionWorld() - { - return this; - } - - virtual void setGravity(const btVector3& gravity); - - virtual btVector3 getGravity () const; - - virtual void addCollisionObject(btCollisionObject* collisionObject,short int collisionFilterGroup=btBroadphaseProxy::StaticFilter,short int collisionFilterMask=btBroadphaseProxy::AllFilter ^ btBroadphaseProxy::StaticFilter); - - virtual void addRigidBody(btRigidBody* body); - - virtual void addRigidBody(btRigidBody* body, short group, short mask); - - virtual void removeRigidBody(btRigidBody* body); - - ///removeCollisionObject will first check if it is a rigid body, if so call removeRigidBody otherwise call btCollisionWorld::removeCollisionObject - virtual void removeCollisionObject(btCollisionObject* collisionObject); - - void debugDrawObject(const btTransform& worldTransform, const btCollisionShape* shape, const btVector3& color); - - void debugDrawConstraint(btTypedConstraint* constraint); - - virtual void debugDrawWorld(); - - virtual void setConstraintSolver(btConstraintSolver* solver); - - virtual btConstraintSolver* getConstraintSolver(); - - virtual int getNumConstraints() const; - - virtual btTypedConstraint* getConstraint(int index) ; - - virtual const btTypedConstraint* getConstraint(int index) const; - - - virtual btDynamicsWorldType getWorldType() const - { - return BT_DISCRETE_DYNAMICS_WORLD; - } - - ///the forces on each rigidbody is accumulating together with gravity. clear this after each timestep. - virtual void clearForces(); - - ///apply gravity, call this once per timestep - virtual void applyGravity(); - - virtual void setNumTasks(int numTasks) - { - (void) numTasks; - } - - ///obsolete, use updateActions instead - virtual void updateVehicles(btScalar timeStep) - { - updateActions(timeStep); - } - - ///obsolete, use addAction instead - virtual void addVehicle(btActionInterface* vehicle); - ///obsolete, use removeAction instead - virtual void removeVehicle(btActionInterface* vehicle); - ///obsolete, use addAction instead - virtual void addCharacter(btActionInterface* character); - ///obsolete, use removeAction instead - virtual void removeCharacter(btActionInterface* character); - - void setSynchronizeAllMotionStates(bool synchronizeAll) - { - m_synchronizeAllMotionStates = synchronizeAll; - } - bool getSynchronizeAllMotionStates() const - { - return m_synchronizeAllMotionStates; - } - -}; - -#endif //BT_DISCRETE_DYNAMICS_WORLD_H diff --git a/bullet/src/BulletDynamics/Dynamics/btDynamicsWorld.h b/bullet/src/BulletDynamics/Dynamics/btDynamicsWorld.h deleted file mode 100644 index ff3da5c1a..000000000 --- a/bullet/src/BulletDynamics/Dynamics/btDynamicsWorld.h +++ /dev/null @@ -1,148 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef BT_DYNAMICS_WORLD_H -#define BT_DYNAMICS_WORLD_H - -#include "BulletCollision/CollisionDispatch/btCollisionWorld.h" -#include "BulletDynamics/ConstraintSolver/btContactSolverInfo.h" - -class btTypedConstraint; -class btActionInterface; -class btConstraintSolver; -class btDynamicsWorld; - - -/// Type for the callback for each tick -typedef void (*btInternalTickCallback)(btDynamicsWorld *world, btScalar timeStep); - -enum btDynamicsWorldType -{ - BT_SIMPLE_DYNAMICS_WORLD=1, - BT_DISCRETE_DYNAMICS_WORLD=2, - BT_CONTINUOUS_DYNAMICS_WORLD=3 -}; - -///The btDynamicsWorld is the interface class for several dynamics implementation, basic, discrete, parallel, and continuous etc. -class btDynamicsWorld : public btCollisionWorld -{ - -protected: - btInternalTickCallback m_internalTickCallback; - btInternalTickCallback m_internalPreTickCallback; - void* m_worldUserInfo; - - btContactSolverInfo m_solverInfo; - -public: - - - btDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* broadphase,btCollisionConfiguration* collisionConfiguration) - :btCollisionWorld(dispatcher,broadphase,collisionConfiguration), m_internalTickCallback(0),m_internalPreTickCallback(0), m_worldUserInfo(0) - { - } - - virtual ~btDynamicsWorld() - { - } - - ///stepSimulation proceeds the simulation over 'timeStep', units in preferably in seconds. - ///By default, Bullet will subdivide the timestep in constant substeps of each 'fixedTimeStep'. - ///in order to keep the simulation real-time, the maximum number of substeps can be clamped to 'maxSubSteps'. - ///You can disable subdividing the timestep/substepping by passing maxSubSteps=0 as second argument to stepSimulation, but in that case you have to keep the timeStep constant. - virtual int stepSimulation( btScalar timeStep,int maxSubSteps=1, btScalar fixedTimeStep=btScalar(1.)/btScalar(60.))=0; - - virtual void debugDrawWorld() = 0; - - virtual void addConstraint(btTypedConstraint* constraint, bool disableCollisionsBetweenLinkedBodies=false) - { - (void)constraint; (void)disableCollisionsBetweenLinkedBodies; - } - - virtual void removeConstraint(btTypedConstraint* constraint) {(void)constraint;} - - virtual void addAction(btActionInterface* action) = 0; - - virtual void removeAction(btActionInterface* action) = 0; - - //once a rigidbody is added to the dynamics world, it will get this gravity assigned - //existing rigidbodies in the world get gravity assigned too, during this method - virtual void setGravity(const btVector3& gravity) = 0; - virtual btVector3 getGravity () const = 0; - - virtual void synchronizeMotionStates() = 0; - - virtual void addRigidBody(btRigidBody* body) = 0; - - virtual void removeRigidBody(btRigidBody* body) = 0; - - virtual void setConstraintSolver(btConstraintSolver* solver) = 0; - - virtual btConstraintSolver* getConstraintSolver() = 0; - - virtual int getNumConstraints() const { return 0; } - - virtual btTypedConstraint* getConstraint(int index) { (void)index; return 0; } - - virtual const btTypedConstraint* getConstraint(int index) const { (void)index; return 0; } - - virtual btDynamicsWorldType getWorldType() const=0; - - virtual void clearForces() = 0; - - /// Set the callback for when an internal tick (simulation substep) happens, optional user info - void setInternalTickCallback(btInternalTickCallback cb, void* worldUserInfo=0,bool isPreTick=false) - { - if (isPreTick) - { - m_internalPreTickCallback = cb; - } else - { - m_internalTickCallback = cb; - } - m_worldUserInfo = worldUserInfo; - } - - void setWorldUserInfo(void* worldUserInfo) - { - m_worldUserInfo = worldUserInfo; - } - - void* getWorldUserInfo() const - { - return m_worldUserInfo; - } - - btContactSolverInfo& getSolverInfo() - { - return m_solverInfo; - } - - - ///obsolete, use addAction instead. - virtual void addVehicle(btActionInterface* vehicle) {(void)vehicle;} - ///obsolete, use removeAction instead - virtual void removeVehicle(btActionInterface* vehicle) {(void)vehicle;} - ///obsolete, use addAction instead. - virtual void addCharacter(btActionInterface* character) {(void)character;} - ///obsolete, use removeAction instead - virtual void removeCharacter(btActionInterface* character) {(void)character;} - - -}; - -#endif //BT_DYNAMICS_WORLD_H - - diff --git a/bullet/src/BulletDynamics/Dynamics/btRigidBody.cpp b/bullet/src/BulletDynamics/Dynamics/btRigidBody.cpp deleted file mode 100644 index ec5e3ccee..000000000 --- a/bullet/src/BulletDynamics/Dynamics/btRigidBody.cpp +++ /dev/null @@ -1,317 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btRigidBody.h" -#include "BulletCollision/CollisionShapes/btConvexShape.h" -#include "LinearMath/btMinMax.h" -#include "LinearMath/btTransformUtil.h" -#include "LinearMath/btMotionState.h" -#include "BulletDynamics/ConstraintSolver/btTypedConstraint.h" - -//'temporarily' global variables -btScalar gDeactivationTime = btScalar(2.); -bool gDisableDeactivation = false; -static int uniqueId = 0; - - -btRigidBody::btRigidBody(const btRigidBody::btRigidBodyConstructionInfo& constructionInfo) -{ - setupRigidBody(constructionInfo); -} - -btRigidBody::btRigidBody(btScalar mass, btMotionState *motionState, btCollisionShape *collisionShape, const btVector3 &localInertia) -{ - btRigidBodyConstructionInfo cinfo(mass,motionState,collisionShape,localInertia); - setupRigidBody(cinfo); -} - -void btRigidBody::setupRigidBody(const btRigidBody::btRigidBodyConstructionInfo& constructionInfo) -{ - - m_internalType=CO_RIGID_BODY; - - m_linearVelocity.setValue(btScalar(0.0), btScalar(0.0), btScalar(0.0)); - m_angularVelocity.setValue(btScalar(0.),btScalar(0.),btScalar(0.)); - m_angularFactor.setValue(1,1,1); - m_linearFactor.setValue(1,1,1); - m_gravity.setValue(btScalar(0.0), btScalar(0.0), btScalar(0.0)); - m_gravity_acceleration.setValue(btScalar(0.0), btScalar(0.0), btScalar(0.0)); - m_totalForce.setValue(btScalar(0.0), btScalar(0.0), btScalar(0.0)); - m_totalTorque.setValue(btScalar(0.0), btScalar(0.0), btScalar(0.0)), - m_linearDamping = btScalar(0.); - m_angularDamping = btScalar(0.5); - m_linearSleepingThreshold = constructionInfo.m_linearSleepingThreshold; - m_angularSleepingThreshold = constructionInfo.m_angularSleepingThreshold; - m_optionalMotionState = constructionInfo.m_motionState; - m_contactSolverType = 0; - m_frictionSolverType = 0; - m_additionalDamping = constructionInfo.m_additionalDamping; - m_additionalDampingFactor = constructionInfo.m_additionalDampingFactor; - m_additionalLinearDampingThresholdSqr = constructionInfo.m_additionalLinearDampingThresholdSqr; - m_additionalAngularDampingThresholdSqr = constructionInfo.m_additionalAngularDampingThresholdSqr; - m_additionalAngularDampingFactor = constructionInfo.m_additionalAngularDampingFactor; - - if (m_optionalMotionState) - { - m_optionalMotionState->getWorldTransform(m_worldTransform); - } else - { - m_worldTransform = constructionInfo.m_startWorldTransform; - } - - m_interpolationWorldTransform = m_worldTransform; - m_interpolationLinearVelocity.setValue(0,0,0); - m_interpolationAngularVelocity.setValue(0,0,0); - - //moved to btCollisionObject - m_friction = constructionInfo.m_friction; - m_restitution = constructionInfo.m_restitution; - - setCollisionShape( constructionInfo.m_collisionShape ); - m_debugBodyId = uniqueId++; - - setMassProps(constructionInfo.m_mass, constructionInfo.m_localInertia); - setDamping(constructionInfo.m_linearDamping, constructionInfo.m_angularDamping); - updateInertiaTensor(); - -} - - -void btRigidBody::predictIntegratedTransform(btScalar timeStep,btTransform& predictedTransform) -{ - btTransformUtil::integrateTransform(m_worldTransform,m_linearVelocity,m_angularVelocity,timeStep,predictedTransform); -} - -void btRigidBody::saveKinematicState(btScalar timeStep) -{ - //todo: clamp to some (user definable) safe minimum timestep, to limit maximum angular/linear velocities - if (timeStep != btScalar(0.)) - { - //if we use motionstate to synchronize world transforms, get the new kinematic/animated world transform - if (getMotionState()) - getMotionState()->getWorldTransform(m_worldTransform); - btVector3 linVel,angVel; - - btTransformUtil::calculateVelocity(m_interpolationWorldTransform,m_worldTransform,timeStep,m_linearVelocity,m_angularVelocity); - m_interpolationLinearVelocity = m_linearVelocity; - m_interpolationAngularVelocity = m_angularVelocity; - m_interpolationWorldTransform = m_worldTransform; - //printf("angular = %f %f %f\n",m_angularVelocity.getX(),m_angularVelocity.getY(),m_angularVelocity.getZ()); - } -} - -void btRigidBody::getAabb(btVector3& aabbMin,btVector3& aabbMax) const -{ - getCollisionShape()->getAabb(m_worldTransform,aabbMin,aabbMax); -} - - - - -void btRigidBody::setGravity(const btVector3& acceleration) -{ - if (m_inverseMass != btScalar(0.0)) - { - m_gravity = acceleration * (btScalar(1.0) / m_inverseMass); - } - m_gravity_acceleration = acceleration; -} - - - - - - -void btRigidBody::setDamping(btScalar lin_damping, btScalar ang_damping) -{ - m_linearDamping = GEN_clamped(lin_damping, (btScalar)btScalar(0.0), (btScalar)btScalar(1.0)); - m_angularDamping = GEN_clamped(ang_damping, (btScalar)btScalar(0.0), (btScalar)btScalar(1.0)); -} - - - - -///applyDamping damps the velocity, using the given m_linearDamping and m_angularDamping -void btRigidBody::applyDamping(btScalar timeStep) -{ - //On new damping: see discussion/issue report here: http://code.google.com/p/bullet/issues/detail?id=74 - //todo: do some performance comparisons (but other parts of the engine are probably bottleneck anyway - -//#define USE_OLD_DAMPING_METHOD 1 -#ifdef USE_OLD_DAMPING_METHOD - m_linearVelocity *= GEN_clamped((btScalar(1.) - timeStep * m_linearDamping), (btScalar)btScalar(0.0), (btScalar)btScalar(1.0)); - m_angularVelocity *= GEN_clamped((btScalar(1.) - timeStep * m_angularDamping), (btScalar)btScalar(0.0), (btScalar)btScalar(1.0)); -#else - m_linearVelocity *= btPow(btScalar(1)-m_linearDamping, timeStep); - m_angularVelocity *= btPow(btScalar(1)-m_angularDamping, timeStep); -#endif - - if (m_additionalDamping) - { - //Additional damping can help avoiding lowpass jitter motion, help stability for ragdolls etc. - //Such damping is undesirable, so once the overall simulation quality of the rigid body dynamics system has improved, this should become obsolete - if ((m_angularVelocity.length2() < m_additionalAngularDampingThresholdSqr) && - (m_linearVelocity.length2() < m_additionalLinearDampingThresholdSqr)) - { - m_angularVelocity *= m_additionalDampingFactor; - m_linearVelocity *= m_additionalDampingFactor; - } - - - btScalar speed = m_linearVelocity.length(); - if (speed < m_linearDamping) - { - btScalar dampVel = btScalar(0.005); - if (speed > dampVel) - { - btVector3 dir = m_linearVelocity.normalized(); - m_linearVelocity -= dir * dampVel; - } else - { - m_linearVelocity.setValue(btScalar(0.),btScalar(0.),btScalar(0.)); - } - } - - btScalar angSpeed = m_angularVelocity.length(); - if (angSpeed < m_angularDamping) - { - btScalar angDampVel = btScalar(0.005); - if (angSpeed > angDampVel) - { - btVector3 dir = m_angularVelocity.normalized(); - m_angularVelocity -= dir * angDampVel; - } else - { - m_angularVelocity.setValue(btScalar(0.),btScalar(0.),btScalar(0.)); - } - } - } -} - - -void btRigidBody::applyGravity() -{ - if (isStaticOrKinematicObject()) - return; - - applyCentralForce(m_gravity); - -} - -void btRigidBody::proceedToTransform(const btTransform& newTrans) -{ - setCenterOfMassTransform( newTrans ); -} - - -void btRigidBody::setMassProps(btScalar mass, const btVector3& inertia) -{ - if (mass == btScalar(0.)) - { - m_collisionFlags |= btCollisionObject::CF_STATIC_OBJECT; - m_inverseMass = btScalar(0.); - } else - { - m_collisionFlags &= (~btCollisionObject::CF_STATIC_OBJECT); - m_inverseMass = btScalar(1.0) / mass; - } - - m_invInertiaLocal.setValue(inertia.x() != btScalar(0.0) ? btScalar(1.0) / inertia.x(): btScalar(0.0), - inertia.y() != btScalar(0.0) ? btScalar(1.0) / inertia.y(): btScalar(0.0), - inertia.z() != btScalar(0.0) ? btScalar(1.0) / inertia.z(): btScalar(0.0)); - -} - - - -void btRigidBody::updateInertiaTensor() -{ - m_invInertiaTensorWorld = m_worldTransform.getBasis().scaled(m_invInertiaLocal) * m_worldTransform.getBasis().transpose(); -} - - -void btRigidBody::integrateVelocities(btScalar step) -{ - if (isStaticOrKinematicObject()) - return; - - m_linearVelocity += m_totalForce * (m_inverseMass * step); - m_angularVelocity += m_invInertiaTensorWorld * m_totalTorque * step; - -#define MAX_ANGVEL SIMD_HALF_PI - /// clamp angular velocity. collision calculations will fail on higher angular velocities - btScalar angvel = m_angularVelocity.length(); - if (angvel*step > MAX_ANGVEL) - { - m_angularVelocity *= (MAX_ANGVEL/step) /angvel; - } - -} - -btQuaternion btRigidBody::getOrientation() const -{ - btQuaternion orn; - m_worldTransform.getBasis().getRotation(orn); - return orn; -} - - -void btRigidBody::setCenterOfMassTransform(const btTransform& xform) -{ - - if (isStaticOrKinematicObject()) - { - m_interpolationWorldTransform = m_worldTransform; - } else - { - m_interpolationWorldTransform = xform; - } - m_interpolationLinearVelocity = getLinearVelocity(); - m_interpolationAngularVelocity = getAngularVelocity(); - m_worldTransform = xform; - updateInertiaTensor(); -} - - -bool btRigidBody::checkCollideWithOverride(btCollisionObject* co) -{ - btRigidBody* otherRb = btRigidBody::upcast(co); - if (!otherRb) - return true; - - for (int i = 0; i < m_constraintRefs.size(); ++i) - { - btTypedConstraint* c = m_constraintRefs[i]; - if (&c->getRigidBodyA() == otherRb || &c->getRigidBodyB() == otherRb) - return false; - } - - return true; -} - -void btRigidBody::addConstraintRef(btTypedConstraint* c) -{ - int index = m_constraintRefs.findLinearSearch(c); - if (index == m_constraintRefs.size()) - m_constraintRefs.push_back(c); - - m_checkCollideWith = true; -} - -void btRigidBody::removeConstraintRef(btTypedConstraint* c) -{ - m_constraintRefs.remove(c); - m_checkCollideWith = m_constraintRefs.size() > 0; -} diff --git a/bullet/src/BulletDynamics/Dynamics/btRigidBody.h b/bullet/src/BulletDynamics/Dynamics/btRigidBody.h deleted file mode 100644 index adb892f99..000000000 --- a/bullet/src/BulletDynamics/Dynamics/btRigidBody.h +++ /dev/null @@ -1,503 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef RIGIDBODY_H -#define RIGIDBODY_H - -#include "LinearMath/btAlignedObjectArray.h" -#include "LinearMath/btTransform.h" -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" -#include "BulletCollision/CollisionDispatch/btCollisionObject.h" - -class btCollisionShape; -class btMotionState; -class btTypedConstraint; - - -extern btScalar gDeactivationTime; -extern bool gDisableDeactivation; - - -///The btRigidBody is the main class for rigid body objects. It is derived from btCollisionObject, so it keeps a pointer to a btCollisionShape. -///It is recommended for performance and memory use to share btCollisionShape objects whenever possible. -///There are 3 types of rigid bodies: -///- A) Dynamic rigid bodies, with positive mass. Motion is controlled by rigid body dynamics. -///- B) Fixed objects with zero mass. They are not moving (basically collision objects) -///- C) Kinematic objects, which are objects without mass, but the user can move them. There is on-way interaction, and Bullet calculates a velocity based on the timestep and previous and current world transform. -///Bullet automatically deactivates dynamic rigid bodies, when the velocity is below a threshold for a given time. -///Deactivated (sleeping) rigid bodies don't take any processing time, except a minor broadphase collision detection impact (to allow active objects to activate/wake up sleeping objects) -class btRigidBody : public btCollisionObject -{ - - btMatrix3x3 m_invInertiaTensorWorld; - btVector3 m_linearVelocity; - btVector3 m_angularVelocity; - btScalar m_inverseMass; - btVector3 m_angularFactor; - btVector3 m_linearFactor; - - btVector3 m_gravity; - btVector3 m_gravity_acceleration; - btVector3 m_invInertiaLocal; - btVector3 m_totalForce; - btVector3 m_totalTorque; - - btScalar m_linearDamping; - btScalar m_angularDamping; - - bool m_additionalDamping; - btScalar m_additionalDampingFactor; - btScalar m_additionalLinearDampingThresholdSqr; - btScalar m_additionalAngularDampingThresholdSqr; - btScalar m_additionalAngularDampingFactor; - - - btScalar m_linearSleepingThreshold; - btScalar m_angularSleepingThreshold; - - //m_optionalMotionState allows to automatic synchronize the world transform for active objects - btMotionState* m_optionalMotionState; - - //keep track of typed constraints referencing this rigid body - btAlignedObjectArray m_constraintRefs; - -public: - - - ///The btRigidBodyConstructionInfo structure provides information to create a rigid body. Setting mass to zero creates a fixed (non-dynamic) rigid body. - ///For dynamic objects, you can use the collision shape to approximate the local inertia tensor, otherwise use the zero vector (default argument) - ///You can use the motion state to synchronize the world transform between physics and graphics objects. - ///And if the motion state is provided, the rigid body will initialize its initial world transform from the motion state, - ///m_startWorldTransform is only used when you don't provide a motion state. - struct btRigidBodyConstructionInfo - { - btScalar m_mass; - - ///When a motionState is provided, the rigid body will initialize its world transform from the motion state - ///In this case, m_startWorldTransform is ignored. - btMotionState* m_motionState; - btTransform m_startWorldTransform; - - btCollisionShape* m_collisionShape; - btVector3 m_localInertia; - btScalar m_linearDamping; - btScalar m_angularDamping; - - ///best simulation results when friction is non-zero - btScalar m_friction; - ///best simulation results using zero restitution. - btScalar m_restitution; - - btScalar m_linearSleepingThreshold; - btScalar m_angularSleepingThreshold; - - //Additional damping can help avoiding lowpass jitter motion, help stability for ragdolls etc. - //Such damping is undesirable, so once the overall simulation quality of the rigid body dynamics system has improved, this should become obsolete - bool m_additionalDamping; - btScalar m_additionalDampingFactor; - btScalar m_additionalLinearDampingThresholdSqr; - btScalar m_additionalAngularDampingThresholdSqr; - btScalar m_additionalAngularDampingFactor; - - - btRigidBodyConstructionInfo( btScalar mass, btMotionState* motionState, btCollisionShape* collisionShape, const btVector3& localInertia=btVector3(0,0,0)): - m_mass(mass), - m_motionState(motionState), - m_collisionShape(collisionShape), - m_localInertia(localInertia), - m_linearDamping(btScalar(0.)), - m_angularDamping(btScalar(0.)), - m_friction(btScalar(0.5)), - m_restitution(btScalar(0.)), - m_linearSleepingThreshold(btScalar(0.8)), - m_angularSleepingThreshold(btScalar(1.f)), - m_additionalDamping(false), - m_additionalDampingFactor(btScalar(0.005)), - m_additionalLinearDampingThresholdSqr(btScalar(0.01)), - m_additionalAngularDampingThresholdSqr(btScalar(0.01)), - m_additionalAngularDampingFactor(btScalar(0.01)) - { - m_startWorldTransform.setIdentity(); - } - }; - - ///btRigidBody constructor using construction info - btRigidBody( const btRigidBodyConstructionInfo& constructionInfo); - - ///btRigidBody constructor for backwards compatibility. - ///To specify friction (etc) during rigid body construction, please use the other constructor (using btRigidBodyConstructionInfo) - btRigidBody( btScalar mass, btMotionState* motionState, btCollisionShape* collisionShape, const btVector3& localInertia=btVector3(0,0,0)); - - - virtual ~btRigidBody() - { - //No constraints should point to this rigidbody - //Remove constraints from the dynamics world before you delete the related rigidbodies. - btAssert(m_constraintRefs.size()==0); - } - -protected: - - ///setupRigidBody is only used internally by the constructor - void setupRigidBody(const btRigidBodyConstructionInfo& constructionInfo); - -public: - - void proceedToTransform(const btTransform& newTrans); - - ///to keep collision detection and dynamics separate we don't store a rigidbody pointer - ///but a rigidbody is derived from btCollisionObject, so we can safely perform an upcast - static const btRigidBody* upcast(const btCollisionObject* colObj) - { - if (colObj->getInternalType()==btCollisionObject::CO_RIGID_BODY) - return (const btRigidBody*)colObj; - return 0; - } - static btRigidBody* upcast(btCollisionObject* colObj) - { - if (colObj->getInternalType()==btCollisionObject::CO_RIGID_BODY) - return (btRigidBody*)colObj; - return 0; - } - - /// continuous collision detection needs prediction - void predictIntegratedTransform(btScalar step, btTransform& predictedTransform) ; - - void saveKinematicState(btScalar step); - - void applyGravity(); - - void setGravity(const btVector3& acceleration); - - const btVector3& getGravity() const - { - return m_gravity_acceleration; - } - - void setDamping(btScalar lin_damping, btScalar ang_damping); - - btScalar getLinearDamping() const - { - return m_linearDamping; - } - - btScalar getAngularDamping() const - { - return m_angularDamping; - } - - btScalar getLinearSleepingThreshold() const - { - return m_linearSleepingThreshold; - } - - btScalar getAngularSleepingThreshold() const - { - return m_angularSleepingThreshold; - } - - void applyDamping(btScalar timeStep); - - SIMD_FORCE_INLINE const btCollisionShape* getCollisionShape() const { - return m_collisionShape; - } - - SIMD_FORCE_INLINE btCollisionShape* getCollisionShape() { - return m_collisionShape; - } - - void setMassProps(btScalar mass, const btVector3& inertia); - - const btVector3& getLinearFactor() const - { - return m_linearFactor; - } - void setLinearFactor(const btVector3& linearFactor) - { - m_linearFactor = linearFactor; - } - btScalar getInvMass() const { return m_inverseMass; } - const btMatrix3x3& getInvInertiaTensorWorld() const { - return m_invInertiaTensorWorld; - } - - void integrateVelocities(btScalar step); - - void setCenterOfMassTransform(const btTransform& xform); - - void applyCentralForce(const btVector3& force) - { - m_totalForce += force*m_linearFactor; - } - - const btVector3& getTotalForce() - { - return m_totalForce; - }; - - const btVector3& getTotalTorque() - { - return m_totalTorque; - }; - - const btVector3& getInvInertiaDiagLocal() const - { - return m_invInertiaLocal; - }; - - void setInvInertiaDiagLocal(const btVector3& diagInvInertia) - { - m_invInertiaLocal = diagInvInertia; - } - - void setSleepingThresholds(btScalar linear,btScalar angular) - { - m_linearSleepingThreshold = linear; - m_angularSleepingThreshold = angular; - } - - void applyTorque(const btVector3& torque) - { - m_totalTorque += torque*m_angularFactor; - } - - void applyForce(const btVector3& force, const btVector3& rel_pos) - { - applyCentralForce(force); - applyTorque(rel_pos.cross(force*m_linearFactor)); - } - - void applyCentralImpulse(const btVector3& impulse) - { - m_linearVelocity += impulse *m_linearFactor * m_inverseMass; - } - - void applyTorqueImpulse(const btVector3& torque) - { - m_angularVelocity += m_invInertiaTensorWorld * torque * m_angularFactor; - } - - void applyImpulse(const btVector3& impulse, const btVector3& rel_pos) - { - if (m_inverseMass != btScalar(0.)) - { - applyCentralImpulse(impulse); - if (m_angularFactor) - { - applyTorqueImpulse(rel_pos.cross(impulse*m_linearFactor)); - } - } - } - - //Optimization for the iterative solver: avoid calculating constant terms involving inertia, normal, relative position - SIMD_FORCE_INLINE void internalApplyImpulse(const btVector3& linearComponent, const btVector3& angularComponent,btScalar impulseMagnitude) - { - if (m_inverseMass != btScalar(0.)) - { - m_linearVelocity += linearComponent*m_linearFactor*impulseMagnitude; - if (m_angularFactor) - { - m_angularVelocity += angularComponent*m_angularFactor*impulseMagnitude; - } - } - } - - void clearForces() - { - m_totalForce.setValue(btScalar(0.0), btScalar(0.0), btScalar(0.0)); - m_totalTorque.setValue(btScalar(0.0), btScalar(0.0), btScalar(0.0)); - } - - void updateInertiaTensor(); - - const btVector3& getCenterOfMassPosition() const { - return m_worldTransform.getOrigin(); - } - btQuaternion getOrientation() const; - - const btTransform& getCenterOfMassTransform() const { - return m_worldTransform; - } - const btVector3& getLinearVelocity() const { - return m_linearVelocity; - } - const btVector3& getAngularVelocity() const { - return m_angularVelocity; - } - - - inline void setLinearVelocity(const btVector3& lin_vel) - { - m_linearVelocity = lin_vel; - } - - inline void setAngularVelocity(const btVector3& ang_vel) - { - m_angularVelocity = ang_vel; - } - - btVector3 getVelocityInLocalPoint(const btVector3& rel_pos) const - { - //we also calculate lin/ang velocity for kinematic objects - return m_linearVelocity + m_angularVelocity.cross(rel_pos); - - //for kinematic objects, we could also use use: - // return (m_worldTransform(rel_pos) - m_interpolationWorldTransform(rel_pos)) / m_kinematicTimeStep; - } - - void translate(const btVector3& v) - { - m_worldTransform.getOrigin() += v; - } - - - void getAabb(btVector3& aabbMin,btVector3& aabbMax) const; - - - - - - SIMD_FORCE_INLINE btScalar computeImpulseDenominator(const btVector3& pos, const btVector3& normal) const - { - btVector3 r0 = pos - getCenterOfMassPosition(); - - btVector3 c0 = (r0).cross(normal); - - btVector3 vec = (c0 * getInvInertiaTensorWorld()).cross(r0); - - return m_inverseMass + normal.dot(vec); - - } - - SIMD_FORCE_INLINE btScalar computeAngularImpulseDenominator(const btVector3& axis) const - { - btVector3 vec = axis * getInvInertiaTensorWorld(); - return axis.dot(vec); - } - - SIMD_FORCE_INLINE void updateDeactivation(btScalar timeStep) - { - if ( (getActivationState() == ISLAND_SLEEPING) || (getActivationState() == DISABLE_DEACTIVATION)) - return; - - if ((getLinearVelocity().length2() < m_linearSleepingThreshold*m_linearSleepingThreshold) && - (getAngularVelocity().length2() < m_angularSleepingThreshold*m_angularSleepingThreshold)) - { - m_deactivationTime += timeStep; - } else - { - m_deactivationTime=btScalar(0.); - setActivationState(0); - } - - } - - SIMD_FORCE_INLINE bool wantsSleeping() - { - - if (getActivationState() == DISABLE_DEACTIVATION) - return false; - - //disable deactivation - if (gDisableDeactivation || (gDeactivationTime == btScalar(0.))) - return false; - - if ( (getActivationState() == ISLAND_SLEEPING) || (getActivationState() == WANTS_DEACTIVATION)) - return true; - - if (m_deactivationTime> gDeactivationTime) - { - return true; - } - return false; - } - - - - const btBroadphaseProxy* getBroadphaseProxy() const - { - return m_broadphaseHandle; - } - btBroadphaseProxy* getBroadphaseProxy() - { - return m_broadphaseHandle; - } - void setNewBroadphaseProxy(btBroadphaseProxy* broadphaseProxy) - { - m_broadphaseHandle = broadphaseProxy; - } - - //btMotionState allows to automatic synchronize the world transform for active objects - btMotionState* getMotionState() - { - return m_optionalMotionState; - } - const btMotionState* getMotionState() const - { - return m_optionalMotionState; - } - void setMotionState(btMotionState* motionState) - { - m_optionalMotionState = motionState; - if (m_optionalMotionState) - motionState->getWorldTransform(m_worldTransform); - } - - //for experimental overriding of friction/contact solver func - int m_contactSolverType; - int m_frictionSolverType; - - void setAngularFactor(const btVector3& angFac) - { - m_angularFactor = angFac; - } - - void setAngularFactor(btScalar angFac) - { - m_angularFactor.setValue(angFac,angFac,angFac); - } - const btVector3& getAngularFactor() const - { - return m_angularFactor; - } - - //is this rigidbody added to a btCollisionWorld/btDynamicsWorld/btBroadphase? - bool isInWorld() const - { - return (getBroadphaseProxy() != 0); - } - - virtual bool checkCollideWithOverride(btCollisionObject* co); - - void addConstraintRef(btTypedConstraint* c); - void removeConstraintRef(btTypedConstraint* c); - - btTypedConstraint* getConstraintRef(int index) - { - return m_constraintRefs[index]; - } - - int getNumConstraintRefs() - { - return m_constraintRefs.size(); - } - - int m_debugBodyId; -}; - - - -#endif - diff --git a/bullet/src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp b/bullet/src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp deleted file mode 100644 index 70be136bc..000000000 --- a/bullet/src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp +++ /dev/null @@ -1,253 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btSimpleDynamicsWorld.h" -#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h" -#include "BulletCollision/BroadphaseCollision/btSimpleBroadphase.h" -#include "BulletCollision/CollisionShapes/btCollisionShape.h" -#include "BulletDynamics/Dynamics/btRigidBody.h" -#include "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h" -#include "BulletDynamics/ConstraintSolver/btContactSolverInfo.h" - - -/* - Make sure this dummy function never changes so that it - can be used by probes that are checking whether the - library is actually installed. -*/ -extern "C" -{ - void btBulletDynamicsProbe (); - void btBulletDynamicsProbe () {} -} - - - - -btSimpleDynamicsWorld::btSimpleDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration) -:btDynamicsWorld(dispatcher,pairCache,collisionConfiguration), -m_constraintSolver(constraintSolver), -m_ownsConstraintSolver(false), -m_gravity(0,0,-10) -{ - -} - - -btSimpleDynamicsWorld::~btSimpleDynamicsWorld() -{ - if (m_ownsConstraintSolver) - btAlignedFree( m_constraintSolver); -} - -int btSimpleDynamicsWorld::stepSimulation( btScalar timeStep,int maxSubSteps, btScalar fixedTimeStep) -{ - (void)fixedTimeStep; - (void)maxSubSteps; - - - ///apply gravity, predict motion - predictUnconstraintMotion(timeStep); - - btDispatcherInfo& dispatchInfo = getDispatchInfo(); - dispatchInfo.m_timeStep = timeStep; - dispatchInfo.m_stepCount = 0; - dispatchInfo.m_debugDraw = getDebugDrawer(); - - ///perform collision detection - performDiscreteCollisionDetection(); - - ///solve contact constraints - int numManifolds = m_dispatcher1->getNumManifolds(); - if (numManifolds) - { - btPersistentManifold** manifoldPtr = ((btCollisionDispatcher*)m_dispatcher1)->getInternalManifoldPointer(); - - btContactSolverInfo infoGlobal; - infoGlobal.m_timeStep = timeStep; - m_constraintSolver->prepareSolve(0,numManifolds); - m_constraintSolver->solveGroup(0,0,manifoldPtr, numManifolds,0,0,infoGlobal,m_debugDrawer, m_stackAlloc,m_dispatcher1); - m_constraintSolver->allSolved(infoGlobal,m_debugDrawer, m_stackAlloc); - } - - ///integrate transforms - integrateTransforms(timeStep); - - updateAabbs(); - - synchronizeMotionStates(); - - clearForces(); - - return 1; - -} - -void btSimpleDynamicsWorld::clearForces() -{ - ///@todo: iterate over awake simulation islands! - for ( int i=0;iclearForces(); - } - } -} - - -void btSimpleDynamicsWorld::setGravity(const btVector3& gravity) -{ - m_gravity = gravity; - for ( int i=0;isetGravity(gravity); - } - } -} - -btVector3 btSimpleDynamicsWorld::getGravity () const -{ - return m_gravity; -} - -void btSimpleDynamicsWorld::removeRigidBody(btRigidBody* body) -{ - btCollisionWorld::removeCollisionObject(body); -} - -void btSimpleDynamicsWorld::removeCollisionObject(btCollisionObject* collisionObject) -{ - btRigidBody* body = btRigidBody::upcast(collisionObject); - if (body) - removeRigidBody(body); - else - btCollisionWorld::removeCollisionObject(collisionObject); -} - - -void btSimpleDynamicsWorld::addRigidBody(btRigidBody* body) -{ - body->setGravity(m_gravity); - - if (body->getCollisionShape()) - { - addCollisionObject(body); - } -} - -void btSimpleDynamicsWorld::updateAabbs() -{ - btTransform predictedTrans; - for ( int i=0;iisActive() && (!body->isStaticObject())) - { - btVector3 minAabb,maxAabb; - colObj->getCollisionShape()->getAabb(colObj->getWorldTransform(), minAabb,maxAabb); - btBroadphaseInterface* bp = getBroadphase(); - bp->setAabb(body->getBroadphaseHandle(),minAabb,maxAabb, m_dispatcher1); - } - } - } -} - -void btSimpleDynamicsWorld::integrateTransforms(btScalar timeStep) -{ - btTransform predictedTrans; - for ( int i=0;iisActive() && (!body->isStaticObject())) - { - body->predictIntegratedTransform(timeStep, predictedTrans); - body->proceedToTransform( predictedTrans); - } - } - } -} - - - -void btSimpleDynamicsWorld::predictUnconstraintMotion(btScalar timeStep) -{ - for ( int i=0;iisStaticObject()) - { - if (body->isActive()) - { - body->applyGravity(); - body->integrateVelocities( timeStep); - body->applyDamping(timeStep); - body->predictIntegratedTransform(timeStep,body->getInterpolationWorldTransform()); - } - } - } - } -} - - -void btSimpleDynamicsWorld::synchronizeMotionStates() -{ - ///@todo: iterate over awake simulation islands! - for ( int i=0;igetMotionState()) - { - if (body->getActivationState() != ISLAND_SLEEPING) - { - body->getMotionState()->setWorldTransform(body->getWorldTransform()); - } - } - } - -} - - -void btSimpleDynamicsWorld::setConstraintSolver(btConstraintSolver* solver) -{ - if (m_ownsConstraintSolver) - { - btAlignedFree(m_constraintSolver); - } - m_ownsConstraintSolver = false; - m_constraintSolver = solver; -} - -btConstraintSolver* btSimpleDynamicsWorld::getConstraintSolver() -{ - return m_constraintSolver; -} diff --git a/bullet/src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.h b/bullet/src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.h deleted file mode 100644 index 8d8d35d7b..000000000 --- a/bullet/src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.h +++ /dev/null @@ -1,81 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef BT_SIMPLE_DYNAMICS_WORLD_H -#define BT_SIMPLE_DYNAMICS_WORLD_H - -#include "btDynamicsWorld.h" - -class btDispatcher; -class btOverlappingPairCache; -class btConstraintSolver; - -///The btSimpleDynamicsWorld serves as unit-test and to verify more complicated and optimized dynamics worlds. -///Please use btDiscreteDynamicsWorld instead (or btContinuousDynamicsWorld once it is finished). -class btSimpleDynamicsWorld : public btDynamicsWorld -{ -protected: - - btConstraintSolver* m_constraintSolver; - - bool m_ownsConstraintSolver; - - void predictUnconstraintMotion(btScalar timeStep); - - void integrateTransforms(btScalar timeStep); - - btVector3 m_gravity; - -public: - - - - ///this btSimpleDynamicsWorld constructor creates dispatcher, broadphase pairCache and constraintSolver - btSimpleDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration); - - virtual ~btSimpleDynamicsWorld(); - - ///maxSubSteps/fixedTimeStep for interpolation is currently ignored for btSimpleDynamicsWorld, use btDiscreteDynamicsWorld instead - virtual int stepSimulation( btScalar timeStep,int maxSubSteps=1, btScalar fixedTimeStep=btScalar(1.)/btScalar(60.)); - - virtual void setGravity(const btVector3& gravity); - - virtual btVector3 getGravity () const; - - virtual void addRigidBody(btRigidBody* body); - - virtual void removeRigidBody(btRigidBody* body); - - ///removeCollisionObject will first check if it is a rigid body, if so call removeRigidBody otherwise call btCollisionWorld::removeCollisionObject - virtual void removeCollisionObject(btCollisionObject* collisionObject); - - virtual void updateAabbs(); - - virtual void synchronizeMotionStates(); - - virtual void setConstraintSolver(btConstraintSolver* solver); - - virtual btConstraintSolver* getConstraintSolver(); - - virtual btDynamicsWorldType getWorldType() const - { - return BT_SIMPLE_DYNAMICS_WORLD; - } - - virtual void clearForces(); - -}; - -#endif //BT_SIMPLE_DYNAMICS_WORLD_H diff --git a/bullet/src/BulletDynamics/Jamfile b/bullet/src/BulletDynamics/Jamfile deleted file mode 100644 index 9992e8a4c..000000000 --- a/bullet/src/BulletDynamics/Jamfile +++ /dev/null @@ -1,13 +0,0 @@ - -SubDir TOP src BulletDynamics ; - -Description bulletdynamics : "Bullet Rigidbody Dynamics" ; -Library bulletdynamics : - [ Wildcard ConstraintSolver : *.h *.cpp ] - [ Wildcard Dynamics : *.h *.cpp ] - [ Wildcard Vehicle : *.h *.cpp ] - [ Wildcard Character : *.h *.cpp ] -; - -LibDepends bulletdynamics : bulletcollision ; - diff --git a/bullet/src/BulletDynamics/Vehicle/btRaycastVehicle.cpp b/bullet/src/BulletDynamics/Vehicle/btRaycastVehicle.cpp deleted file mode 100644 index e1a4bac41..000000000 --- a/bullet/src/BulletDynamics/Vehicle/btRaycastVehicle.cpp +++ /dev/null @@ -1,758 +0,0 @@ -/* - * Copyright (c) 2005 Erwin Coumans http://continuousphysics.com/Bullet/ - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies. - * Erwin Coumans makes no representations about the suitability - * of this software for any purpose. - * It is provided "as is" without express or implied warranty. -*/ - -#include "LinearMath/btVector3.h" -#include "btRaycastVehicle.h" - -#include "BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.h" -#include "BulletDynamics/ConstraintSolver/btJacobianEntry.h" -#include "LinearMath/btQuaternion.h" -#include "BulletDynamics/Dynamics/btDynamicsWorld.h" -#include "btVehicleRaycaster.h" -#include "btWheelInfo.h" -#include "LinearMath/btMinMax.h" -#include "LinearMath/btIDebugDraw.h" -#include "BulletDynamics/ConstraintSolver/btContactConstraint.h" - -static btRigidBody s_fixedObject( 0,0,0); - -btRaycastVehicle::btRaycastVehicle(const btVehicleTuning& tuning,btRigidBody* chassis, btVehicleRaycaster* raycaster ) -:m_vehicleRaycaster(raycaster), -m_pitchControl(btScalar(0.)) -{ - m_chassisBody = chassis; - m_indexRightAxis = 0; - m_indexUpAxis = 2; - m_indexForwardAxis = 1; - defaultInit(tuning); -} - - -void btRaycastVehicle::defaultInit(const btVehicleTuning& tuning) -{ - (void)tuning; - m_currentVehicleSpeedKmHour = btScalar(0.); - m_steeringValue = btScalar(0.); - -} - - - -btRaycastVehicle::~btRaycastVehicle() -{ -} - - -// -// basically most of the code is general for 2 or 4 wheel vehicles, but some of it needs to be reviewed -// -btWheelInfo& btRaycastVehicle::addWheel( const btVector3& connectionPointCS, const btVector3& wheelDirectionCS0,const btVector3& wheelAxleCS, btScalar suspensionRestLength, btScalar wheelRadius,const btVehicleTuning& tuning, bool isFrontWheel) -{ - - btWheelInfoConstructionInfo ci; - - ci.m_chassisConnectionCS = connectionPointCS; - ci.m_wheelDirectionCS = wheelDirectionCS0; - ci.m_wheelAxleCS = wheelAxleCS; - ci.m_suspensionRestLength = suspensionRestLength; - ci.m_wheelRadius = wheelRadius; - ci.m_suspensionStiffness = tuning.m_suspensionStiffness; - ci.m_wheelsDampingCompression = tuning.m_suspensionCompression; - ci.m_wheelsDampingRelaxation = tuning.m_suspensionDamping; - ci.m_frictionSlip = tuning.m_frictionSlip; - ci.m_bIsFrontWheel = isFrontWheel; - ci.m_maxSuspensionTravelCm = tuning.m_maxSuspensionTravelCm; - - m_wheelInfo.push_back( btWheelInfo(ci)); - - btWheelInfo& wheel = m_wheelInfo[getNumWheels()-1]; - - updateWheelTransformsWS( wheel , false ); - updateWheelTransform(getNumWheels()-1,false); - return wheel; -} - - - - -const btTransform& btRaycastVehicle::getWheelTransformWS( int wheelIndex ) const -{ - btAssert(wheelIndex < getNumWheels()); - const btWheelInfo& wheel = m_wheelInfo[wheelIndex]; - return wheel.m_worldTransform; - -} - -void btRaycastVehicle::updateWheelTransform( int wheelIndex , bool interpolatedTransform) -{ - - btWheelInfo& wheel = m_wheelInfo[ wheelIndex ]; - updateWheelTransformsWS(wheel,interpolatedTransform); - btVector3 up = -wheel.m_raycastInfo.m_wheelDirectionWS; - const btVector3& right = wheel.m_raycastInfo.m_wheelAxleWS; - btVector3 fwd = up.cross(right); - fwd = fwd.normalize(); -// up = right.cross(fwd); -// up.normalize(); - - //rotate around steering over de wheelAxleWS - btScalar steering = wheel.m_steering; - - btQuaternion steeringOrn(up,steering);//wheel.m_steering); - btMatrix3x3 steeringMat(steeringOrn); - - btQuaternion rotatingOrn(right,-wheel.m_rotation); - btMatrix3x3 rotatingMat(rotatingOrn); - - btMatrix3x3 basis2( - right[0],fwd[0],up[0], - right[1],fwd[1],up[1], - right[2],fwd[2],up[2] - ); - - wheel.m_worldTransform.setBasis(steeringMat * rotatingMat * basis2); - wheel.m_worldTransform.setOrigin( - wheel.m_raycastInfo.m_hardPointWS + wheel.m_raycastInfo.m_wheelDirectionWS * wheel.m_raycastInfo.m_suspensionLength - ); -} - -void btRaycastVehicle::resetSuspension() -{ - - int i; - for (i=0;igetMotionState())) - { - getRigidBody()->getMotionState()->getWorldTransform(chassisTrans); - } - - wheel.m_raycastInfo.m_hardPointWS = chassisTrans( wheel.m_chassisConnectionPointCS ); - wheel.m_raycastInfo.m_wheelDirectionWS = chassisTrans.getBasis() * wheel.m_wheelDirectionCS ; - wheel.m_raycastInfo.m_wheelAxleWS = chassisTrans.getBasis() * wheel.m_wheelAxleCS; -} - -btScalar btRaycastVehicle::rayCast(btWheelInfo& wheel) -{ - updateWheelTransformsWS( wheel,false); - - - btScalar depth = -1; - - btScalar raylen = wheel.getSuspensionRestLength()+wheel.m_wheelsRadius; - - btVector3 rayvector = wheel.m_raycastInfo.m_wheelDirectionWS * (raylen); - const btVector3& source = wheel.m_raycastInfo.m_hardPointWS; - wheel.m_raycastInfo.m_contactPointWS = source + rayvector; - const btVector3& target = wheel.m_raycastInfo.m_contactPointWS; - - btScalar param = btScalar(0.); - - btVehicleRaycaster::btVehicleRaycasterResult rayResults; - - btAssert(m_vehicleRaycaster); - - void* object = m_vehicleRaycaster->castRay(source,target,rayResults); - - wheel.m_raycastInfo.m_groundObject = 0; - - if (object) - { - param = rayResults.m_distFraction; - depth = raylen * rayResults.m_distFraction; - wheel.m_raycastInfo.m_contactNormalWS = rayResults.m_hitNormalInWorld; - wheel.m_raycastInfo.m_isInContact = true; - - wheel.m_raycastInfo.m_groundObject = &s_fixedObject;///@todo for driving on dynamic/movable objects!; - //wheel.m_raycastInfo.m_groundObject = object; - - - btScalar hitDistance = param*raylen; - wheel.m_raycastInfo.m_suspensionLength = hitDistance - wheel.m_wheelsRadius; - //clamp on max suspension travel - - btScalar minSuspensionLength = wheel.getSuspensionRestLength() - wheel.m_maxSuspensionTravelCm*btScalar(0.01); - btScalar maxSuspensionLength = wheel.getSuspensionRestLength()+ wheel.m_maxSuspensionTravelCm*btScalar(0.01); - if (wheel.m_raycastInfo.m_suspensionLength < minSuspensionLength) - { - wheel.m_raycastInfo.m_suspensionLength = minSuspensionLength; - } - if (wheel.m_raycastInfo.m_suspensionLength > maxSuspensionLength) - { - wheel.m_raycastInfo.m_suspensionLength = maxSuspensionLength; - } - - wheel.m_raycastInfo.m_contactPointWS = rayResults.m_hitPointInWorld; - - btScalar denominator= wheel.m_raycastInfo.m_contactNormalWS.dot( wheel.m_raycastInfo.m_wheelDirectionWS ); - - btVector3 chassis_velocity_at_contactPoint; - btVector3 relpos = wheel.m_raycastInfo.m_contactPointWS-getRigidBody()->getCenterOfMassPosition(); - - chassis_velocity_at_contactPoint = getRigidBody()->getVelocityInLocalPoint(relpos); - - btScalar projVel = wheel.m_raycastInfo.m_contactNormalWS.dot( chassis_velocity_at_contactPoint ); - - if ( denominator >= btScalar(-0.1)) - { - wheel.m_suspensionRelativeVelocity = btScalar(0.0); - wheel.m_clippedInvContactDotSuspension = btScalar(1.0) / btScalar(0.1); - } - else - { - btScalar inv = btScalar(-1.) / denominator; - wheel.m_suspensionRelativeVelocity = projVel * inv; - wheel.m_clippedInvContactDotSuspension = inv; - } - - } else - { - //put wheel info as in rest position - wheel.m_raycastInfo.m_suspensionLength = wheel.getSuspensionRestLength(); - wheel.m_suspensionRelativeVelocity = btScalar(0.0); - wheel.m_raycastInfo.m_contactNormalWS = - wheel.m_raycastInfo.m_wheelDirectionWS; - wheel.m_clippedInvContactDotSuspension = btScalar(1.0); - } - - return depth; -} - - -const btTransform& btRaycastVehicle::getChassisWorldTransform() const -{ - /*if (getRigidBody()->getMotionState()) - { - btTransform chassisWorldTrans; - getRigidBody()->getMotionState()->getWorldTransform(chassisWorldTrans); - return chassisWorldTrans; - } - */ - - - return getRigidBody()->getCenterOfMassTransform(); -} - - -void btRaycastVehicle::updateVehicle( btScalar step ) -{ - { - for (int i=0;igetLinearVelocity().length(); - - const btTransform& chassisTrans = getChassisWorldTransform(); - - btVector3 forwardW ( - chassisTrans.getBasis()[0][m_indexForwardAxis], - chassisTrans.getBasis()[1][m_indexForwardAxis], - chassisTrans.getBasis()[2][m_indexForwardAxis]); - - if (forwardW.dot(getRigidBody()->getLinearVelocity()) < btScalar(0.)) - { - m_currentVehicleSpeedKmHour *= btScalar(-1.); - } - - // - // simulate suspension - // - - int i=0; - for (i=0;i gMaxSuspensionForce) - { - suspensionForce = gMaxSuspensionForce; - } - btVector3 impulse = wheel.m_raycastInfo.m_contactNormalWS * suspensionForce * step; - btVector3 relpos = wheel.m_raycastInfo.m_contactPointWS - getRigidBody()->getCenterOfMassPosition(); - - getRigidBody()->applyImpulse(impulse, relpos); - - } - - - - updateFriction( step); - - - for (i=0;igetCenterOfMassPosition(); - btVector3 vel = getRigidBody()->getVelocityInLocalPoint( relpos ); - - if (wheel.m_raycastInfo.m_isInContact) - { - const btTransform& chassisWorldTransform = getChassisWorldTransform(); - - btVector3 fwd ( - chassisWorldTransform.getBasis()[0][m_indexForwardAxis], - chassisWorldTransform.getBasis()[1][m_indexForwardAxis], - chassisWorldTransform.getBasis()[2][m_indexForwardAxis]); - - btScalar proj = fwd.dot(wheel.m_raycastInfo.m_contactNormalWS); - fwd -= wheel.m_raycastInfo.m_contactNormalWS * proj; - - btScalar proj2 = fwd.dot(vel); - - wheel.m_deltaRotation = (proj2 * step) / (wheel.m_wheelsRadius); - wheel.m_rotation += wheel.m_deltaRotation; - - } else - { - wheel.m_rotation += wheel.m_deltaRotation; - } - - wheel.m_deltaRotation *= btScalar(0.99);//damping of rotation when not in contact - - } - - - -} - - -void btRaycastVehicle::setSteeringValue(btScalar steering,int wheel) -{ - btAssert(wheel>=0 && wheel < getNumWheels()); - - btWheelInfo& wheelInfo = getWheelInfo(wheel); - wheelInfo.m_steering = steering; -} - - - -btScalar btRaycastVehicle::getSteeringValue(int wheel) const -{ - return getWheelInfo(wheel).m_steering; -} - - -void btRaycastVehicle::applyEngineForce(btScalar force, int wheel) -{ - btAssert(wheel>=0 && wheel < getNumWheels()); - btWheelInfo& wheelInfo = getWheelInfo(wheel); - wheelInfo.m_engineForce = force; -} - - -const btWheelInfo& btRaycastVehicle::getWheelInfo(int index) const -{ - btAssert((index >= 0) && (index < getNumWheels())); - - return m_wheelInfo[index]; -} - -btWheelInfo& btRaycastVehicle::getWheelInfo(int index) -{ - btAssert((index >= 0) && (index < getNumWheels())); - - return m_wheelInfo[index]; -} - -void btRaycastVehicle::setBrake(btScalar brake,int wheelIndex) -{ - btAssert((wheelIndex >= 0) && (wheelIndex < getNumWheels())); - getWheelInfo(wheelIndex).m_brake = brake; -} - - -void btRaycastVehicle::updateSuspension(btScalar deltaTime) -{ - (void)deltaTime; - - btScalar chassisMass = btScalar(1.) / m_chassisBody->getInvMass(); - - for (int w_it=0; w_itcomputeImpulseDenominator(frictionPosWorld,frictionDirectionWorld); - btScalar denom1 = body1->computeImpulseDenominator(frictionPosWorld,frictionDirectionWorld); - btScalar relaxation = 1.f; - m_jacDiagABInv = relaxation/(denom0+denom1); - } - - - -}; - -btScalar calcRollingFriction(btWheelContactPoint& contactPoint); -btScalar calcRollingFriction(btWheelContactPoint& contactPoint) -{ - - btScalar j1=0.f; - - const btVector3& contactPosWorld = contactPoint.m_frictionPositionWorld; - - btVector3 rel_pos1 = contactPosWorld - contactPoint.m_body0->getCenterOfMassPosition(); - btVector3 rel_pos2 = contactPosWorld - contactPoint.m_body1->getCenterOfMassPosition(); - - btScalar maxImpulse = contactPoint.m_maxImpulse; - - btVector3 vel1 = contactPoint.m_body0->getVelocityInLocalPoint(rel_pos1); - btVector3 vel2 = contactPoint.m_body1->getVelocityInLocalPoint(rel_pos2); - btVector3 vel = vel1 - vel2; - - btScalar vrel = contactPoint.m_frictionDirectionWorld.dot(vel); - - // calculate j that moves us to zero relative velocity - j1 = -vrel * contactPoint.m_jacDiagABInv; - btSetMin(j1, maxImpulse); - btSetMax(j1, -maxImpulse); - - return j1; -} - - - - -btScalar sideFrictionStiffness2 = btScalar(1.0); -void btRaycastVehicle::updateFriction(btScalar timeStep) -{ - - //calculate the impulse, so that the wheels don't move sidewards - int numWheel = getNumWheels(); - if (!numWheel) - return; - - m_forwardWS.resize(numWheel); - m_axle.resize(numWheel); - m_forwardImpulse.resize(numWheel); - m_sideImpulse.resize(numWheel); - - int numWheelsOnGround = 0; - - - //collapse all those loops into one! - for (int i=0;i maximpSquared) - { - sliding = true; - - btScalar factor = maximp / btSqrt(impulseSquared); - - m_wheelInfo[wheel].m_skidInfo *= factor; - } - } - - } - } - - - - - if (sliding) - { - for (int wheel = 0;wheel < getNumWheels(); wheel++) - { - if (m_sideImpulse[wheel] != btScalar(0.)) - { - if (m_wheelInfo[wheel].m_skidInfo< btScalar(1.)) - { - m_forwardImpulse[wheel] *= m_wheelInfo[wheel].m_skidInfo; - m_sideImpulse[wheel] *= m_wheelInfo[wheel].m_skidInfo; - } - } - } - } - - // apply the impulses - { - for (int wheel = 0;wheelgetCenterOfMassPosition(); - - if (m_forwardImpulse[wheel] != btScalar(0.)) - { - m_chassisBody->applyImpulse(m_forwardWS[wheel]*(m_forwardImpulse[wheel]),rel_pos); - } - if (m_sideImpulse[wheel] != btScalar(0.)) - { - class btRigidBody* groundObject = (class btRigidBody*) m_wheelInfo[wheel].m_raycastInfo.m_groundObject; - - btVector3 rel_pos2 = wheelInfo.m_raycastInfo.m_contactPointWS - - groundObject->getCenterOfMassPosition(); - - - btVector3 sideImp = m_axle[wheel] * m_sideImpulse[wheel]; - - rel_pos[m_indexUpAxis] *= wheelInfo.m_rollInfluence; - m_chassisBody->applyImpulse(sideImp,rel_pos); - - //apply friction impulse on the ground - groundObject->applyImpulse(-sideImp,rel_pos2); - } - } - } - - -} - - - -void btRaycastVehicle::debugDraw(btIDebugDraw* debugDrawer) -{ - - for (int v=0;vgetNumWheels();v++) - { - btVector3 wheelColor(0,255,255); - if (getWheelInfo(v).m_raycastInfo.m_isInContact) - { - wheelColor.setValue(0,0,255); - } else - { - wheelColor.setValue(255,0,255); - } - - btVector3 wheelPosWS = getWheelInfo(v).m_worldTransform.getOrigin(); - - btVector3 axle = btVector3( - getWheelInfo(v).m_worldTransform.getBasis()[0][getRightAxis()], - getWheelInfo(v).m_worldTransform.getBasis()[1][getRightAxis()], - getWheelInfo(v).m_worldTransform.getBasis()[2][getRightAxis()]); - - //debug wheels (cylinders) - debugDrawer->drawLine(wheelPosWS,wheelPosWS+axle,wheelColor); - debugDrawer->drawLine(wheelPosWS,getWheelInfo(v).m_raycastInfo.m_contactPointWS,wheelColor); - - } -} - - -void* btDefaultVehicleRaycaster::castRay(const btVector3& from,const btVector3& to, btVehicleRaycasterResult& result) -{ -// RayResultCallback& resultCallback; - - btCollisionWorld::ClosestRayResultCallback rayCallback(from,to); - - m_dynamicsWorld->rayTest(from, to, rayCallback); - - if (rayCallback.hasHit()) - { - - btRigidBody* body = btRigidBody::upcast(rayCallback.m_collisionObject); - if (body && body->hasContactResponse()) - { - result.m_hitPointInWorld = rayCallback.m_hitPointWorld; - result.m_hitNormalInWorld = rayCallback.m_hitNormalWorld; - result.m_hitNormalInWorld.normalize(); - result.m_distFraction = rayCallback.m_closestHitFraction; - return body; - } - } - return 0; -} - diff --git a/bullet/src/BulletDynamics/Vehicle/btRaycastVehicle.h b/bullet/src/BulletDynamics/Vehicle/btRaycastVehicle.h deleted file mode 100644 index 4d17f5482..000000000 --- a/bullet/src/BulletDynamics/Vehicle/btRaycastVehicle.h +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright (c) 2005 Erwin Coumans http://continuousphysics.com/Bullet/ - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies. - * Erwin Coumans makes no representations about the suitability - * of this software for any purpose. - * It is provided "as is" without express or implied warranty. -*/ -#ifndef RAYCASTVEHICLE_H -#define RAYCASTVEHICLE_H - -#include "BulletDynamics/Dynamics/btRigidBody.h" -#include "BulletDynamics/ConstraintSolver/btTypedConstraint.h" -#include "btVehicleRaycaster.h" -class btDynamicsWorld; -#include "LinearMath/btAlignedObjectArray.h" -#include "btWheelInfo.h" -#include "BulletDynamics/Dynamics/btActionInterface.h" - -class btVehicleTuning; - -///rayCast vehicle, very special constraint that turn a rigidbody into a vehicle. -class btRaycastVehicle : public btActionInterface -{ - - btAlignedObjectArray m_forwardWS; - btAlignedObjectArray m_axle; - btAlignedObjectArray m_forwardImpulse; - btAlignedObjectArray m_sideImpulse; - -public: - class btVehicleTuning - { - public: - - btVehicleTuning() - :m_suspensionStiffness(btScalar(5.88)), - m_suspensionCompression(btScalar(0.83)), - m_suspensionDamping(btScalar(0.88)), - m_maxSuspensionTravelCm(btScalar(500.)), - m_frictionSlip(btScalar(10.5)) - { - } - btScalar m_suspensionStiffness; - btScalar m_suspensionCompression; - btScalar m_suspensionDamping; - btScalar m_maxSuspensionTravelCm; - btScalar m_frictionSlip; - - }; -private: - - btScalar m_tau; - btScalar m_damping; - btVehicleRaycaster* m_vehicleRaycaster; - btScalar m_pitchControl; - btScalar m_steeringValue; - btScalar m_currentVehicleSpeedKmHour; - - btRigidBody* m_chassisBody; - - int m_indexRightAxis; - int m_indexUpAxis; - int m_indexForwardAxis; - - void defaultInit(const btVehicleTuning& tuning); - -public: - - //constructor to create a car from an existing rigidbody - btRaycastVehicle(const btVehicleTuning& tuning,btRigidBody* chassis, btVehicleRaycaster* raycaster ); - - virtual ~btRaycastVehicle() ; - - - ///btActionInterface interface - virtual void updateAction( btCollisionWorld* collisionWorld, btScalar step) - { - updateVehicle(step); - } - - - ///btActionInterface interface - void debugDraw(btIDebugDraw* debugDrawer); - - const btTransform& getChassisWorldTransform() const; - - btScalar rayCast(btWheelInfo& wheel); - - virtual void updateVehicle(btScalar step); - - - void resetSuspension(); - - btScalar getSteeringValue(int wheel) const; - - void setSteeringValue(btScalar steering,int wheel); - - - void applyEngineForce(btScalar force, int wheel); - - const btTransform& getWheelTransformWS( int wheelIndex ) const; - - void updateWheelTransform( int wheelIndex, bool interpolatedTransform = true ); - - void setRaycastWheelInfo( int wheelIndex , bool isInContact, const btVector3& hitPoint, const btVector3& hitNormal,btScalar depth); - - btWheelInfo& addWheel( const btVector3& connectionPointCS0, const btVector3& wheelDirectionCS0,const btVector3& wheelAxleCS,btScalar suspensionRestLength,btScalar wheelRadius,const btVehicleTuning& tuning, bool isFrontWheel); - - inline int getNumWheels() const { - return int (m_wheelInfo.size()); - } - - btAlignedObjectArray m_wheelInfo; - - - const btWheelInfo& getWheelInfo(int index) const; - - btWheelInfo& getWheelInfo(int index); - - void updateWheelTransformsWS(btWheelInfo& wheel , bool interpolatedTransform = true); - - - void setBrake(btScalar brake,int wheelIndex); - - void setPitchControl(btScalar pitch) - { - m_pitchControl = pitch; - } - - void updateSuspension(btScalar deltaTime); - - virtual void updateFriction(btScalar timeStep); - - - - inline btRigidBody* getRigidBody() - { - return m_chassisBody; - } - - const btRigidBody* getRigidBody() const - { - return m_chassisBody; - } - - inline int getRightAxis() const - { - return m_indexRightAxis; - } - inline int getUpAxis() const - { - return m_indexUpAxis; - } - - inline int getForwardAxis() const - { - return m_indexForwardAxis; - } - - - ///Worldspace forward vector - btVector3 getForwardVector() const - { - const btTransform& chassisTrans = getChassisWorldTransform(); - - btVector3 forwardW ( - chassisTrans.getBasis()[0][m_indexForwardAxis], - chassisTrans.getBasis()[1][m_indexForwardAxis], - chassisTrans.getBasis()[2][m_indexForwardAxis]); - - return forwardW; - } - - ///Velocity of vehicle (positive if velocity vector has same direction as foward vector) - btScalar getCurrentSpeedKmHour() const - { - return m_currentVehicleSpeedKmHour; - } - - virtual void setCoordinateSystem(int rightIndex,int upIndex,int forwardIndex) - { - m_indexRightAxis = rightIndex; - m_indexUpAxis = upIndex; - m_indexForwardAxis = forwardIndex; - } - - - -}; - -class btDefaultVehicleRaycaster : public btVehicleRaycaster -{ - btDynamicsWorld* m_dynamicsWorld; -public: - btDefaultVehicleRaycaster(btDynamicsWorld* world) - :m_dynamicsWorld(world) - { - } - - virtual void* castRay(const btVector3& from,const btVector3& to, btVehicleRaycasterResult& result); - -}; - - -#endif //RAYCASTVEHICLE_H - diff --git a/bullet/src/BulletDynamics/Vehicle/btVehicleRaycaster.h b/bullet/src/BulletDynamics/Vehicle/btVehicleRaycaster.h deleted file mode 100644 index 7c830bd86..000000000 --- a/bullet/src/BulletDynamics/Vehicle/btVehicleRaycaster.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2005 Erwin Coumans http://continuousphysics.com/Bullet/ - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies. - * Erwin Coumans makes no representations about the suitability - * of this software for any purpose. - * It is provided "as is" without express or implied warranty. -*/ -#ifndef VEHICLE_RAYCASTER_H -#define VEHICLE_RAYCASTER_H - -#include "LinearMath/btVector3.h" - -/// btVehicleRaycaster is provides interface for between vehicle simulation and raycasting -struct btVehicleRaycaster -{ -virtual ~btVehicleRaycaster() -{ -} - struct btVehicleRaycasterResult - { - btVehicleRaycasterResult() :m_distFraction(btScalar(-1.)){}; - btVector3 m_hitPointInWorld; - btVector3 m_hitNormalInWorld; - btScalar m_distFraction; - }; - - virtual void* castRay(const btVector3& from,const btVector3& to, btVehicleRaycasterResult& result) = 0; - -}; - -#endif //VEHICLE_RAYCASTER_H - diff --git a/bullet/src/BulletDynamics/Vehicle/btWheelInfo.cpp b/bullet/src/BulletDynamics/Vehicle/btWheelInfo.cpp deleted file mode 100644 index e51c0a5f1..000000000 --- a/bullet/src/BulletDynamics/Vehicle/btWheelInfo.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2005 Erwin Coumans http://continuousphysics.com/Bullet/ - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies. - * Erwin Coumans makes no representations about the suitability - * of this software for any purpose. - * It is provided "as is" without express or implied warranty. -*/ -#include "btWheelInfo.h" -#include "BulletDynamics/Dynamics/btRigidBody.h" // for pointvelocity - - -btScalar btWheelInfo::getSuspensionRestLength() const -{ - - return m_suspensionRestLength1; - -} - -void btWheelInfo::updateWheel(const btRigidBody& chassis,RaycastInfo& raycastInfo) -{ - (void)raycastInfo; - - - if (m_raycastInfo.m_isInContact) - - { - btScalar project= m_raycastInfo.m_contactNormalWS.dot( m_raycastInfo.m_wheelDirectionWS ); - btVector3 chassis_velocity_at_contactPoint; - btVector3 relpos = m_raycastInfo.m_contactPointWS - chassis.getCenterOfMassPosition(); - chassis_velocity_at_contactPoint = chassis.getVelocityInLocalPoint( relpos ); - btScalar projVel = m_raycastInfo.m_contactNormalWS.dot( chassis_velocity_at_contactPoint ); - if ( project >= btScalar(-0.1)) - { - m_suspensionRelativeVelocity = btScalar(0.0); - m_clippedInvContactDotSuspension = btScalar(1.0) / btScalar(0.1); - } - else - { - btScalar inv = btScalar(-1.) / project; - m_suspensionRelativeVelocity = projVel * inv; - m_clippedInvContactDotSuspension = inv; - } - - } - - else // Not in contact : position wheel in a nice (rest length) position - { - m_raycastInfo.m_suspensionLength = this->getSuspensionRestLength(); - m_suspensionRelativeVelocity = btScalar(0.0); - m_raycastInfo.m_contactNormalWS = -m_raycastInfo.m_wheelDirectionWS; - m_clippedInvContactDotSuspension = btScalar(1.0); - } -} diff --git a/bullet/src/BulletDynamics/Vehicle/btWheelInfo.h b/bullet/src/BulletDynamics/Vehicle/btWheelInfo.h deleted file mode 100644 index a785fd0bd..000000000 --- a/bullet/src/BulletDynamics/Vehicle/btWheelInfo.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2005 Erwin Coumans http://continuousphysics.com/Bullet/ - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies. - * Erwin Coumans makes no representations about the suitability - * of this software for any purpose. - * It is provided "as is" without express or implied warranty. -*/ -#ifndef WHEEL_INFO_H -#define WHEEL_INFO_H - -#include "LinearMath/btVector3.h" -#include "LinearMath/btTransform.h" - -class btRigidBody; - -struct btWheelInfoConstructionInfo -{ - btVector3 m_chassisConnectionCS; - btVector3 m_wheelDirectionCS; - btVector3 m_wheelAxleCS; - btScalar m_suspensionRestLength; - btScalar m_maxSuspensionTravelCm; - btScalar m_wheelRadius; - - btScalar m_suspensionStiffness; - btScalar m_wheelsDampingCompression; - btScalar m_wheelsDampingRelaxation; - btScalar m_frictionSlip; - bool m_bIsFrontWheel; - -}; - -/// btWheelInfo contains information per wheel about friction and suspension. -struct btWheelInfo -{ - struct RaycastInfo - { - //set by raycaster - btVector3 m_contactNormalWS;//contactnormal - btVector3 m_contactPointWS;//raycast hitpoint - btScalar m_suspensionLength; - btVector3 m_hardPointWS;//raycast starting point - btVector3 m_wheelDirectionWS; //direction in worldspace - btVector3 m_wheelAxleWS; // axle in worldspace - bool m_isInContact; - void* m_groundObject; //could be general void* ptr - }; - - RaycastInfo m_raycastInfo; - - btTransform m_worldTransform; - - btVector3 m_chassisConnectionPointCS; //const - btVector3 m_wheelDirectionCS;//const - btVector3 m_wheelAxleCS; // const or modified by steering - btScalar m_suspensionRestLength1;//const - btScalar m_maxSuspensionTravelCm; - btScalar getSuspensionRestLength() const; - btScalar m_wheelsRadius;//const - btScalar m_suspensionStiffness;//const - btScalar m_wheelsDampingCompression;//const - btScalar m_wheelsDampingRelaxation;//const - btScalar m_frictionSlip; - btScalar m_steering; - btScalar m_rotation; - btScalar m_deltaRotation; - btScalar m_rollInfluence; - - btScalar m_engineForce; - - btScalar m_brake; - - bool m_bIsFrontWheel; - - void* m_clientInfo;//can be used to store pointer to sync transforms... - - btWheelInfo(btWheelInfoConstructionInfo& ci) - - { - - m_suspensionRestLength1 = ci.m_suspensionRestLength; - m_maxSuspensionTravelCm = ci.m_maxSuspensionTravelCm; - - m_wheelsRadius = ci.m_wheelRadius; - m_suspensionStiffness = ci.m_suspensionStiffness; - m_wheelsDampingCompression = ci.m_wheelsDampingCompression; - m_wheelsDampingRelaxation = ci.m_wheelsDampingRelaxation; - m_chassisConnectionPointCS = ci.m_chassisConnectionCS; - m_wheelDirectionCS = ci.m_wheelDirectionCS; - m_wheelAxleCS = ci.m_wheelAxleCS; - m_frictionSlip = ci.m_frictionSlip; - m_steering = btScalar(0.); - m_engineForce = btScalar(0.); - m_rotation = btScalar(0.); - m_deltaRotation = btScalar(0.); - m_brake = btScalar(0.); - m_rollInfluence = btScalar(0.1); - m_bIsFrontWheel = ci.m_bIsFrontWheel; - - } - - void updateWheel(const btRigidBody& chassis,RaycastInfo& raycastInfo); - - btScalar m_clippedInvContactDotSuspension; - btScalar m_suspensionRelativeVelocity; - //calculated by suspension - btScalar m_wheelsSuspensionForce; - btScalar m_skidInfo; - -}; - -#endif //WHEEL_INFO_H - diff --git a/bullet/src/BulletDynamics/ibmsdk/Makefile b/bullet/src/BulletDynamics/ibmsdk/Makefile deleted file mode 100644 index 988526fd0..000000000 --- a/bullet/src/BulletDynamics/ibmsdk/Makefile +++ /dev/null @@ -1,53 +0,0 @@ -#### Source code Dirs -VPATH = \ -../ConstraintSolver \ -../Dynamics \ -../Vehicle - -ROOT = ../../.. - -#### Library -LIBRARY_ppu = bulletdynamics.a - -#### Compiler flags -CPPFLAGS = \ --DUSE_LIBSPE2 \ --I../ConstraintSolver \ --I../Dynamics \ --I../Vehicle \ --I$(ROOT)/src \ --I$(SDKINC) - -#### Optimization level flags -#CC_OPT_LEVEL = $(CC_OPT_LEVEL_DEBUG) -CC_OPT_LEVEL = -O3 - -##### Objects to be archived in lib - -OBJS = \ -btContactConstraint.o \ -btGeneric6DofConstraint.o \ -btHingeConstraint.o \ -btPoint2PointConstraint.o \ -btSequentialImpulseConstraintSolver.o \ -btSolve2LinearConstraint.o \ -btTypedConstraint.o \ -btDiscreteDynamicsWorld.o \ -btRigidBody.o \ -btSimpleDynamicsWorld.o \ -btRaycastVehicle.o \ -btWheelInfo.o -#### Install directories -INSTALL_DIR = $(ROOT)/lib/ibmsdk -INSTALL_FILES = $(LIBRARY_ppu) - -IBM_CELLSDK_VERSION := $(shell if [ -d /opt/cell ]; then echo "3.0"; fi) - -ifeq ("$(IBM_CELLSDK_VERSION)","3.0") - CELL_TOP ?= /opt/cell/sdk - include $(CELL_TOP)/buildutils/make.footer -else - CELL_TOP ?= /opt/ibm/cell-sdk/prototype - include $(CELL_TOP)/make.footer -endif - diff --git a/bullet/src/BulletMultiThreaded/CMakeLists.txt b/bullet/src/BulletMultiThreaded/CMakeLists.txt deleted file mode 100644 index 372437c31..000000000 --- a/bullet/src/BulletMultiThreaded/CMakeLists.txt +++ /dev/null @@ -1,71 +0,0 @@ -INCLUDE_DIRECTORIES( - ${BULLET_PHYSICS_SOURCE_DIR}/src - ${BULLET_PHYSICS_SOURCE_DIR}/src/BulletMultiThreaded/vectormath/scalar/cpp -) - -ADD_LIBRARY(BulletMultiThreaded - PlatformDefinitions.h - SpuFakeDma.cpp - SpuFakeDma.h - SpuSync.h - SpuDoubleBuffer.h - SpuLibspe2Support.cpp - SpuLibspe2Support.h - btThreadSupportInterface.cpp - btThreadSupportInterface.h - - Win32ThreadSupport.cpp - Win32ThreadSupport.h - PosixThreadSupport.cpp - PosixThreadSupport.h - SequentialThreadSupport.cpp - SequentialThreadSupport.h - SpuSampleTaskProcess.h - SpuSampleTaskProcess.cpp - - SpuCollisionObjectWrapper.cpp - SpuCollisionObjectWrapper.h - SpuCollisionTaskProcess.h - SpuCollisionTaskProcess.cpp - SpuGatheringCollisionDispatcher.h - SpuGatheringCollisionDispatcher.cpp - SpuContactManifoldCollisionAlgorithm.cpp - SpuContactManifoldCollisionAlgorithm.h - SpuNarrowPhaseCollisionTask/Box.h - SpuNarrowPhaseCollisionTask/boxBoxDistance.cpp - SpuNarrowPhaseCollisionTask/boxBoxDistance.h - SpuNarrowPhaseCollisionTask/SpuContactResult.cpp - SpuNarrowPhaseCollisionTask/SpuContactResult.h - SpuNarrowPhaseCollisionTask/SpuMinkowskiPenetrationDepthSolver.cpp - SpuNarrowPhaseCollisionTask/SpuMinkowskiPenetrationDepthSolver.h - SpuNarrowPhaseCollisionTask/SpuConvexPenetrationDepthSolver.h - SpuNarrowPhaseCollisionTask/SpuPreferredPenetrationDirections.h - SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.cpp - SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.h - SpuNarrowPhaseCollisionTask/SpuCollisionShapes.cpp - SpuNarrowPhaseCollisionTask/SpuCollisionShapes.h - - -#Some GPU related stuff, mainly CUDA and perhaps OpenCL - btGpu3DGridBroadphase.cpp - btGpu3DGridBroadphase.h - btGpu3DGridBroadphaseSharedCode.h - btGpu3DGridBroadphaseSharedDefs.h - btGpu3DGridBroadphaseSharedTypes.h - btGpuDefines.h - btGpuUtilsSharedCode.h - btGpuUtilsSharedDefs.h - -#MiniCL provides a small subset of OpenCL - MiniCLTaskScheduler.cpp - MiniCLTaskScheduler.h - MiniCLTask/MiniCLTask.cpp - MiniCLTask/MiniCLTask.h - ../MiniCL/cl.h - ../MiniCL/cl_gl.h - ../MiniCL/cl_platform.h -) - -IF (BUILD_SHARED_LIBS) - TARGET_LINK_LIBRARIES(BulletMultiThreaded BulletCollision) -ENDIF (BUILD_SHARED_LIBS) diff --git a/bullet/src/BulletMultiThreaded/Jamfile b/bullet/src/BulletMultiThreaded/Jamfile deleted file mode 100644 index 43e878175..000000000 --- a/bullet/src/BulletMultiThreaded/Jamfile +++ /dev/null @@ -1,14 +0,0 @@ -SubDir TOP src BulletMultiThreaded ; - -#IncludeDir src/BulletMultiThreaded ; - -Library bulletmultithreaded : [ Wildcard . : *.h *.cpp ] [ Wildcard MiniCLTask : *.h *.cpp ] [ Wildcard SpuNarrowPhaseCollisionTask : *.h *.cpp ] : noinstall ; -CFlags bulletmultithreaded : [ FIncludes $(TOP)/src/BulletMultiThreaded ] [ FIncludes $(TOP)/src/BulletMultiThreaded/vectormath/scalar/cpp ] ; -LibDepends bulletmultithreaded : ; - - MsvcIncDirs bulletmultithreaded : - "../../src/BulletMultiThreaded" - "../../src/BulletMultiThreaded/vectormath/scalar/cpp" - ; - -InstallHeader [ Wildcard *.h ] : bulletmultithreaded ; diff --git a/bullet/src/BulletMultiThreaded/Makefile.original b/bullet/src/BulletMultiThreaded/Makefile.original deleted file mode 100644 index 1edc9811f..000000000 --- a/bullet/src/BulletMultiThreaded/Makefile.original +++ /dev/null @@ -1,187 +0,0 @@ -__ARCH_BITS__ := 32 - -# define macros -NARROWPHASEDIR=./SpuNarrowPhaseCollisionTask -SPU_TASKFILE=$(NARROWPHASEDIR)/SpuGatheringCollisionTask - -IBM_CELLSDK_VERSION := $(shell if [ -d /opt/cell ]; then echo "3.0"; fi) - -ifeq ("$(IBM_CELLSDK_VERSION)","3.0") - CELL_TOP ?= /opt/cell/sdk - CELL_SYSROOT := /opt/cell/sysroot -else - CELL_TOP ?= /opt/ibm/cell-sdk/prototype - CELL_SYSROOT := $(CELL_TOP)/sysroot -endif - - -USE_CCACHE=ccache -RM=rm -f -OUTDIR=./out -DEBUGFLAG=-DNDEBUG -LIBOUTDIR=../../lib/ibmsdk -COLLISIONDIR=../../src/BulletCollision -MATHDIR=../../src/LinearMath -ARCHITECTUREFLAG=-m$(__ARCH_BITS__) -ifeq "$(__ARCH_BITS__)" "64" - SPU_DEFFLAGS= -DUSE_LIBSPE2 -D__SPU__ -DUSE_ADDR64 -else - SPU_DEFFLAGS= -DUSE_LIBSPE2 -D__SPU__ -endif - -SPU_DEFFLAGS+=-DUSE_PE_BOX_BOX - -SPU_GCC=$(USE_CCACHE) /usr/bin/spu-gcc -SPU_INCLUDEDIR= -Ivectormath/scalar/cpp -I. -I$(CELL_SYSROOT)/usr/spu/include -I../../src -I$(NARROWPHASEDIR) -#SPU_CFLAGS= $(DEBUGFLAG) -W -Wall -Winline -Os -c -include spu_intrinsics.h -include stdbool.h -SPU_CFLAGS= $(DEBUGFLAG) -W -Wall -Winline -O3 -mbranch-hints -fomit-frame-pointer -ftree-vectorize -finline-functions -ftree-vect-loop-version -ftree-loop-optimize -ffast-math -fno-rtti -fno-exceptions -c -include spu_intrinsics.h -include stdbool.h - -SPU_LFLAGS= -Wl,-N -SPU_LIBRARIES=-lstdc++ -SPU_EMBED=/usr/bin/ppu-embedspu -SPU_AR=/usr/bin/ar -SYMBOLNAME=spu_program - -ifeq "$(__ARCH_BITS__)" "64" - PPU_DEFFLAGS= -DUSE_LIBSPE2 -DUSE_ADDR64 - PPU_GCC=$(USE_CCACHE) /usr/bin/ppu-gcc -else - PPU_DEFFLAGS= -DUSE_LIBSPE2 - PPU_GCC=$(USE_CCACHE) /usr/bin/ppu32-gcc -endif - -PPU_CFLAGS= $(ARCHITECTUREFLAG) $(DEBUGFLAG) -W -Wall -Winline -O3 -c -mabi=altivec -maltivec -include altivec.h -include stdbool.h -PPU_INCLUDEDIR= -I. -I$(CELL_SYSROOT)/usr/include -I../../src -I$(NARROWPHASEDIR) -PPU_LFLAGS= $(ARCHITECTUREFLAG) -Wl,-m,elf$(__ARCH_BITS__)ppc -PPU_LIBRARIES= -lstdc++ -lsupc++ -lgcc -lgcov -lspe2 -lpthread -L../../lib/ibmsdk -lbulletcollision -lbulletdynamics -lbulletmath -L$(CELL_SYSROOT)/usr/lib$(__ARCH_BITS__) -R$(CELL_SYSROOT)/usr/lib -PPU_AR=/usr/bin/ar - -MakeOut : -# rm -f -R $(OUTDIR) ; mkdir $(OUTDIR) - @echo "usage: make spu, make ppu, make all, or make clean" -# SPU -SpuTaskFile : MakeOut - $(SPU_GCC) $(SPU_DEFFLAGS) $(SPU_CFLAGS) $(SPU_INCLUDEDIR) -o $(OUTDIR)/SpuTaskFile.o $(SPU_TASKFILE).cpp - -boxBoxDistance : MakeOut - $(SPU_GCC) $(SPU_DEFFLAGS) $(SPU_CFLAGS) $(SPU_INCLUDEDIR) -o $(OUTDIR)/$@.o $(NARROWPHASEDIR)/$@.cpp - -SpuFakeDma : MakeOut - $(SPU_GCC) $(SPU_DEFFLAGS) $(SPU_CFLAGS) $(SPU_INCLUDEDIR) -o $(OUTDIR)/$@.o $@.cpp - -SpuContactManifoldCollisionAlgorithm_spu : MakeOut - $(SPU_GCC) $(SPU_DEFFLAGS) $(SPU_CFLAGS) $(SPU_INCLUDEDIR) -o $(OUTDIR)/$@.o SpuContactManifoldCollisionAlgorithm.cpp - -SpuCollisionShapes : MakeOut - $(SPU_GCC) $(SPU_DEFFLAGS) $(SPU_CFLAGS) $(SPU_INCLUDEDIR) -o $(OUTDIR)/$@.o $(NARROWPHASEDIR)/$@.cpp - -SpuContactResult : MakeOut - $(SPU_GCC) $(SPU_DEFFLAGS) $(SPU_CFLAGS) $(SPU_INCLUDEDIR) -o $(OUTDIR)/$@.o $(NARROWPHASEDIR)/$@.cpp - -#SpuGatheringCollisionTask : MakeOut -# $(SPU_GCC) $(SPU_DEFFLAGS) $(SPU_CFLAGS) $(SPU_INCLUDEDIR) -o $(OUTDIR)/$@.o $(NARROWPHASEDIR)/$@.cpp - -SpuGjkPairDetector: MakeOut - $(SPU_GCC) $(SPU_DEFFLAGS) $(SPU_CFLAGS) $(SPU_INCLUDEDIR) -o $(OUTDIR)/$@.o $(NARROWPHASEDIR)/$@.cpp - -SpuMinkowskiPenetrationDepthSolver : MakeOut - $(SPU_GCC) $(SPU_DEFFLAGS) $(SPU_CFLAGS) $(SPU_INCLUDEDIR) -o $(OUTDIR)/$@.o $(NARROWPHASEDIR)/$@.cpp - -SpuVoronoiSimplexSolver : MakeOut - $(SPU_GCC) $(SPU_DEFFLAGS) $(SPU_CFLAGS) $(SPU_INCLUDEDIR) -o $(OUTDIR)/$@.o $(NARROWPHASEDIR)/$@.cpp - -#SpuLibspe2Support_spu : MakeOut -# $(SPU_GCC) $(SPU_DEFFLAGS) $(SPU_CFLAGS) $(SPU_INCLUDEDIR) -o $(OUTDIR)/$@.o SpuLibspe2Support.cpp - -## SPU-Bullet -btPersistentManifold : MakeOut - $(SPU_GCC) $(SPU_DEFFLAGS) $(SPU_CFLAGS) $(SPU_INCLUDEDIR) -o $(OUTDIR)/$@.o $(COLLISIONDIR)/NarrowPhaseCollision/$@.cpp - -btOptimizedBvh : MakeOut - $(SPU_GCC) $(SPU_DEFFLAGS) $(SPU_CFLAGS) $(SPU_INCLUDEDIR) -o $(OUTDIR)/$@.o $(COLLISIONDIR)/CollisionShapes/$@.cpp - -btCollisionObject : MakeOut - $(SPU_GCC) $(SPU_DEFFLAGS) $(SPU_CFLAGS) $(SPU_INCLUDEDIR) -o $(OUTDIR)/$@.o $(COLLISIONDIR)/CollisionDispatch/$@.cpp - -btTriangleCallback : MakeOut - $(SPU_GCC) $(SPU_DEFFLAGS) $(SPU_CFLAGS) $(SPU_INCLUDEDIR) -o $(OUTDIR)/$@.o $(COLLISIONDIR)/CollisionShapes/$@.cpp - -btTriangleIndexVertexArray : MakeOut - $(SPU_GCC) $(SPU_DEFFLAGS) $(SPU_CFLAGS) $(SPU_INCLUDEDIR) -o $(OUTDIR)/$@.o $(COLLISIONDIR)/CollisionShapes/$@.cpp - -btStridingMeshInterface : MakeOut - $(SPU_GCC) $(SPU_DEFFLAGS) $(SPU_CFLAGS) $(SPU_INCLUDEDIR) -o $(OUTDIR)/$@.o $(COLLISIONDIR)/CollisionShapes/$@.cpp - -btAlignedAllocator : MakeOut - $(SPU_GCC) $(SPU_DEFFLAGS) $(SPU_CFLAGS) $(SPU_INCLUDEDIR) -o $(OUTDIR)/$@.o $(MATHDIR)/$@.cpp - - -# PPU -SpuGatheringCollisionDispatcher : MakeOut - $(PPU_GCC) $(PPU_DEFFLAGS) $(PPU_CFLAGS) $(PPU_INCLUDEDIR) -o $(OUTDIR)/$@.o $@.cpp - -SequentialThreadSupport: MakeOut - $(PPU_GCC) $(PPU_DEFFLAGS) $(PPU_CFLAGS) $(PPU_INCLUDEDIR) -o $(OUTDIR)/$@.o $@.cpp - -SpuLibspe2Support: MakeOut - $(PPU_GCC) $(PPU_DEFFLAGS) $(PPU_CFLAGS) $(PPU_INCLUDEDIR) -o $(OUTDIR)/$@.o $@.cpp - -btThreadSupportInterface: MakeOut - $(PPU_GCC) $(PPU_DEFFLAGS) $(PPU_CFLAGS) $(PPU_INCLUDEDIR) -o $(OUTDIR)/$@.o $@.cpp - -SpuCollisionTaskProcess : MakeOut - $(PPU_GCC) $(PPU_DEFFLAGS) $(PPU_CFLAGS) $(PPU_INCLUDEDIR) -o $(OUTDIR)/$@.o $@.cpp - -SpuContactManifoldCollisionAlgorithm : MakeOut - $(PPU_GCC) $(PPU_DEFFLAGS) $(PPU_CFLAGS) $(PPU_INCLUDEDIR) -o $(OUTDIR)/$@.o $@.cpp - -SpuSampleTaskProcess : MakeOut - $(PPU_GCC) $(PPU_DEFFLAGS) $(PPU_CFLAGS) $(PPU_INCLUDEDIR) -o $(OUTDIR)/$@.o $@.cpp - - - -spu : boxBoxDistance SpuFakeDma SpuContactManifoldCollisionAlgorithm_spu SpuContactResult SpuTaskFile \ - SpuGjkPairDetector SpuMinkowskiPenetrationDepthSolver SpuVoronoiSimplexSolver SpuCollisionShapes \ - btPersistentManifold btOptimizedBvh btCollisionObject btTriangleCallback btTriangleIndexVertexArray \ - btStridingMeshInterface btAlignedAllocator - $(SPU_GCC) -o $(OUTDIR)/spuCollision.elf \ - $(OUTDIR)/SpuTaskFile.o \ - $(OUTDIR)/SpuFakeDma.o \ - $(OUTDIR)/boxBoxDistance.o \ - $(OUTDIR)/SpuContactManifoldCollisionAlgorithm_spu.o \ - $(OUTDIR)/SpuContactResult.o \ - $(OUTDIR)/SpuCollisionShapes.o \ - $(OUTDIR)/SpuGjkPairDetector.o \ - $(OUTDIR)/SpuMinkowskiPenetrationDepthSolver.o \ - $(OUTDIR)/SpuVoronoiSimplexSolver.o \ - $(OUTDIR)/btPersistentManifold.o \ - $(OUTDIR)/btTriangleCallback.o \ - $(OUTDIR)/btTriangleIndexVertexArray.o \ - $(OUTDIR)/btStridingMeshInterface.o \ - $(OUTDIR)/btAlignedAllocator.o \ - $(SPU_LFLAGS) $(SPU_LIBRARIES) - -spu-embed : spu - $(SPU_EMBED) $(ARCHITECTUREFLAG) $(SYMBOLNAME) $(OUTDIR)/spuCollision.elf $(OUTDIR)/$@.o - $(SPU_AR) -qcs $(LIBOUTDIR)/libspu.a $(OUTDIR)/$@.o - - - -ppu : SpuGatheringCollisionDispatcher SpuCollisionTaskProcess btThreadSupportInterface \ - SpuLibspe2Support SpuContactManifoldCollisionAlgorithm SpuSampleTaskProcess - $(PPU_AR) -qcs $(LIBOUTDIR)/bulletmultithreaded.a \ - $(OUTDIR)/SpuCollisionTaskProcess.o \ - $(OUTDIR)/SpuSampleTaskProcess.o \ - $(OUTDIR)/SpuGatheringCollisionDispatcher.o \ - $(OUTDIR)/SpuLibspe2Support.o \ - $(OUTDIR)/btThreadSupportInterface.o \ - $(OUTDIR)/SpuContactManifoldCollisionAlgorithm.o - -all : spu-embed ppu - -clean: - $(RM) $(OUTDIR)/* ; $(RM) $(LIBOUTDIR)/libspu.a ; $(RM) $(LIBOUTDIR)/bulletmultithreaded.a - - - - diff --git a/bullet/src/BulletMultiThreaded/MiniCLTask/MiniCLTask.cpp b/bullet/src/BulletMultiThreaded/MiniCLTask/MiniCLTask.cpp deleted file mode 100644 index 40aec14b9..000000000 --- a/bullet/src/BulletMultiThreaded/MiniCLTask/MiniCLTask.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library, Copyright (c) 2007 Erwin Coumans - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. - -*/ - - -#include "MiniCLTask.h" -#include "../PlatformDefinitions.h" -#include "../SpuFakeDma.h" -#include "LinearMath/btMinMax.h" -#include "BulletMultiThreaded/MiniCLTask/MiniCLTask.h" - -#ifdef __SPU__ -#include -#else -#include -#define spu_printf printf -#endif - -#define __kernel -#define __global -#define get_global_id(a) guid - -struct MiniCLTask_LocalStoreMemory -{ - -}; - - -/////////////////////////////////////////////////// -// OpenCL Kernel Function for element by element vector addition -__kernel void VectorAdd(__global const float8* a, __global const float8* b, __global float8* c, int guid) -{ - // get oct-float index into global data array - int iGID = get_global_id(0); - - // read inputs into registers - float8 f8InA = a[iGID]; - float8 f8InB = b[iGID]; - float8 f8Out = (float8)0.0f; - - // add the vector elements - f8Out.s0 = f8InA.s0 + f8InB.s0; - f8Out.s1 = f8InA.s1 + f8InB.s1; - f8Out.s2 = f8InA.s2 + f8InB.s2; - f8Out.s3 = f8InA.s3 + f8InB.s3; - f8Out.s4 = f8InA.s4 + f8InB.s4; - f8Out.s5 = f8InA.s5 + f8InB.s5; - f8Out.s6 = f8InA.s6 + f8InB.s6; - f8Out.s7 = f8InA.s7 + f8InB.s7; - - // write back out to GMEM - c[get_global_id(0)] = f8Out; -} -/////////////////////////////////////////////////// - - -//-- MAIN METHOD -void processMiniCLTask(void* userPtr, void* lsMemory) -{ - // BT_PROFILE("processSampleTask"); - - MiniCLTask_LocalStoreMemory* localMemory = (MiniCLTask_LocalStoreMemory*)lsMemory; - - MiniCLTaskDesc* taskDescPtr = (MiniCLTaskDesc*)userPtr; - MiniCLTaskDesc& taskDesc = *taskDescPtr; - - printf("Compute Unit[%d] executed kernel %d work items [%d..%d)\n",taskDesc.m_taskId,taskDesc.m_kernelProgramId,taskDesc.m_firstWorkUnit,taskDesc.m_lastWorkUnit); - - - switch (taskDesc.m_kernelProgramId) - { - case CMD_MINICL_ADDVECTOR: - { - for (unsigned int i=taskDesc.m_firstWorkUnit;i - -#ifdef __SPU__ - - - -void SampleThreadFunc(void* userPtr,void* lsMemory) -{ - //do nothing - printf("hello world\n"); -} - - -void* SamplelsMemoryFunc() -{ - //don't create local store memory, just return 0 - return 0; -} - - -#else - - -#include "btThreadSupportInterface.h" - -//# include "SPUAssert.h" -#include - - - -extern "C" { - extern char SPU_SAMPLE_ELF_SYMBOL[]; -} - - - - - -MiniCLTaskScheduler::MiniCLTaskScheduler(btThreadSupportInterface* threadInterface, int maxNumOutstandingTasks) -:m_threadInterface(threadInterface), -m_maxNumOutstandingTasks(maxNumOutstandingTasks) -{ - - m_taskBusy.resize(m_maxNumOutstandingTasks); - m_spuSampleTaskDesc.resize(m_maxNumOutstandingTasks); - - for (int i = 0; i < m_maxNumOutstandingTasks; i++) - { - m_taskBusy[i] = false; - } - m_numBusyTasks = 0; - m_currentTask = 0; - - m_initialized = false; - - m_threadInterface->startSPU(); - - -} - -MiniCLTaskScheduler::~MiniCLTaskScheduler() -{ - m_threadInterface->stopSPU(); - -} - - - -void MiniCLTaskScheduler::initialize() -{ -#ifdef DEBUG_SPU_TASK_SCHEDULING - printf("MiniCLTaskScheduler::initialize()\n"); -#endif //DEBUG_SPU_TASK_SCHEDULING - - for (int i = 0; i < m_maxNumOutstandingTasks; i++) - { - m_taskBusy[i] = false; - } - m_numBusyTasks = 0; - m_currentTask = 0; - m_initialized = true; - -} - - -void MiniCLTaskScheduler::issueTask(int firstWorkUnit, int lastWorkUnit,int kernelProgramId,char* argData,int* argSizes) -{ - -#ifdef DEBUG_SPU_TASK_SCHEDULING - printf("MiniCLTaskScheduler::issueTask (m_currentTask= %d\)n", m_currentTask); -#endif //DEBUG_SPU_TASK_SCHEDULING - - m_taskBusy[m_currentTask] = true; - m_numBusyTasks++; - - MiniCLTaskDesc& taskDesc = m_spuSampleTaskDesc[m_currentTask]; - { - // send task description in event message - taskDesc.m_firstWorkUnit = firstWorkUnit; - taskDesc.m_lastWorkUnit = lastWorkUnit; - taskDesc.m_kernelProgramId = kernelProgramId; - //some bookkeeping to recognize finished tasks - taskDesc.m_taskId = m_currentTask; - - for (int i=0;isendRequest(1, (ppu_address_t) &taskDesc, m_currentTask); - - // if all tasks busy, wait for spu event to clear the task. - - if (m_numBusyTasks >= m_maxNumOutstandingTasks) - { - unsigned int taskId; - unsigned int outputSize; - - for (int i=0;iwaitForResponse(&taskId, &outputSize); - - //printf("PPU: after issue, received event: %u %d\n", taskId, outputSize); - - postProcess(taskId, outputSize); - - m_taskBusy[taskId] = false; - - m_numBusyTasks--; - } - - // find new task buffer - for (int i = 0; i < m_maxNumOutstandingTasks; i++) - { - if (!m_taskBusy[i]) - { - m_currentTask = i; - break; - } - } -} - - -///Optional PPU-size post processing for each task -void MiniCLTaskScheduler::postProcess(int taskId, int outputSize) -{ - -} - - -void MiniCLTaskScheduler::flush() -{ -#ifdef DEBUG_SPU_TASK_SCHEDULING - printf("\nSpuCollisionTaskProcess::flush()\n"); -#endif //DEBUG_SPU_TASK_SCHEDULING - - - // all tasks are issued, wait for all tasks to be complete - while(m_numBusyTasks > 0) - { -// Consolidating SPU code - unsigned int taskId; - unsigned int outputSize; - - for (int i=0;iwaitForResponse(&taskId, &outputSize); - } - - //printf("PPU: flushing, received event: %u %d\n", taskId, outputSize); - - postProcess(taskId, outputSize); - - m_taskBusy[taskId] = false; - - m_numBusyTasks--; - } - - -} - -#endif - - -#endif //USE_SAMPLE_PROCESS diff --git a/bullet/src/BulletMultiThreaded/MiniCLTaskScheduler.h b/bullet/src/BulletMultiThreaded/MiniCLTaskScheduler.h deleted file mode 100644 index 580b509b8..000000000 --- a/bullet/src/BulletMultiThreaded/MiniCLTaskScheduler.h +++ /dev/null @@ -1,181 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2007 Erwin Coumans http://bulletphysics.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - - -#ifndef MINICL_TASK_SCHEDULER_H -#define MINICL_TASK_SCHEDULER_H - -#include - - -#include "PlatformDefinitions.h" - -#include - -#include "LinearMath/btAlignedObjectArray.h" - - -#include "MiniCLTask/MiniCLTask.h" - - -//just add your commands here, try to keep them globally unique for debugging purposes -#define CMD_SAMPLE_TASK_COMMAND 10 - - - -/// MiniCLTaskScheduler handles SPU processing of collision pairs. -/// When PPU issues a task, it will look for completed task buffers -/// PPU will do postprocessing, dependent on workunit output (not likely) -class MiniCLTaskScheduler -{ - // track task buffers that are being used, and total busy tasks - btAlignedObjectArray m_taskBusy; - btAlignedObjectArray m_spuSampleTaskDesc; - - int m_numBusyTasks; - - // the current task and the current entry to insert a new work unit - int m_currentTask; - - bool m_initialized; - - void postProcess(int taskId, int outputSize); - - class btThreadSupportInterface* m_threadInterface; - - int m_maxNumOutstandingTasks; - - - -public: - MiniCLTaskScheduler(btThreadSupportInterface* threadInterface, int maxNumOutstandingTasks); - - ~MiniCLTaskScheduler(); - - ///call initialize in the beginning of the frame, before addCollisionPairToTask - void initialize(); - - void issueTask(int firstWorkUnit, int lastWorkUnit,int kernelProgramId,char* argData,int* argSizes); - - ///call flush to submit potential outstanding work to SPUs and wait for all involved SPUs to be finished - void flush(); - - class btThreadSupportInterface* getThreadSupportInterface() - { - return m_threadInterface; - } - - int findProgramCommandIdByName(const char* programName) const - { - return CMD_MINICL_ADDVECTOR;//hardcoded temp value, todo: implement multi-program support - } - - int getMaxNumOutstandingTasks() const - { - return m_maxNumOutstandingTasks; - } -}; - - -struct MiniCLKernel -{ - MiniCLTaskScheduler* m_scheduler; - - int m_kernelProgramCommandId; - - char m_argData[MINI_CL_MAX_ARG][MINICL_MAX_ARGLENGTH]; - int m_argSizes[MINI_CL_MAX_ARG]; -}; - - -#if defined(USE_LIBSPE2) && defined(__SPU__) -////////////////////MAIN///////////////////////////// -#include "../SpuLibspe2Support.h" -#include -#include -#include - -void * SamplelsMemoryFunc(); -void SampleThreadFunc(void* userPtr,void* lsMemory); - -//#define DEBUG_LIBSPE2_MAINLOOP - -int main(unsigned long long speid, addr64 argp, addr64 envp) -{ - printf("SPU is up \n"); - - ATTRIBUTE_ALIGNED128(btSpuStatus status); - ATTRIBUTE_ALIGNED16( SpuSampleTaskDesc taskDesc ) ; - unsigned int received_message = Spu_Mailbox_Event_Nothing; - bool shutdown = false; - - cellDmaGet(&status, argp.ull, sizeof(btSpuStatus), DMA_TAG(3), 0, 0); - cellDmaWaitTagStatusAll(DMA_MASK(3)); - - status.m_status = Spu_Status_Free; - status.m_lsMemory.p = SamplelsMemoryFunc(); - - cellDmaLargePut(&status, argp.ull, sizeof(btSpuStatus), DMA_TAG(3), 0, 0); - cellDmaWaitTagStatusAll(DMA_MASK(3)); - - - while (!shutdown) - { - received_message = spu_read_in_mbox(); - - - - switch(received_message) - { - case Spu_Mailbox_Event_Shutdown: - shutdown = true; - break; - case Spu_Mailbox_Event_Task: - // refresh the status -#ifdef DEBUG_LIBSPE2_MAINLOOP - printf("SPU recieved Task \n"); -#endif //DEBUG_LIBSPE2_MAINLOOP - cellDmaGet(&status, argp.ull, sizeof(btSpuStatus), DMA_TAG(3), 0, 0); - cellDmaWaitTagStatusAll(DMA_MASK(3)); - - btAssert(status.m_status==Spu_Status_Occupied); - - cellDmaGet(&taskDesc, status.m_taskDesc.p, sizeof(SpuSampleTaskDesc), DMA_TAG(3), 0, 0); - cellDmaWaitTagStatusAll(DMA_MASK(3)); - - SampleThreadFunc((void*)&taskDesc, reinterpret_cast (taskDesc.m_mainMemoryPtr) ); - break; - case Spu_Mailbox_Event_Nothing: - default: - break; - } - - // set to status free and wait for next task - status.m_status = Spu_Status_Free; - cellDmaLargePut(&status, argp.ull, sizeof(btSpuStatus), DMA_TAG(3), 0, 0); - cellDmaWaitTagStatusAll(DMA_MASK(3)); - - - } - return 0; -} -////////////////////////////////////////////////////// -#endif - - - -#endif // MINICL_TASK_SCHEDULER_H - diff --git a/bullet/src/BulletMultiThreaded/PlatformDefinitions.h b/bullet/src/BulletMultiThreaded/PlatformDefinitions.h deleted file mode 100644 index 5b5cc2165..000000000 --- a/bullet/src/BulletMultiThreaded/PlatformDefinitions.h +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef TYPE_DEFINITIONS_H -#define TYPE_DEFINITIONS_H - -///This file provides some platform/compiler checks for common definitions - -#ifdef WIN32 - -typedef union -{ - unsigned int u; - void *p; -} addr64; - -#define USE_WIN32_THREADING 1 - - #if defined(__MINGW32__) || defined(__CYGWIN__) || (defined (_MSC_VER) && _MSC_VER < 1300) - #else - #endif //__MINGW32__ - - typedef unsigned char uint8_t; -#ifndef __PHYSICS_COMMON_H__ - typedef unsigned long int uint64_t; - typedef unsigned int uint32_t; -#endif //__PHYSICS_COMMON_H__ - typedef unsigned short uint16_t; - - #include - #define memalign(alignment, size) malloc(size); - -#include //memcpy - - - - #include - #define spu_printf printf - -#else - #include - #include - #include //for memcpy - -#if defined (__CELLOS_LV2__) - // Playstation 3 Cell SDK -#include - -#else - // posix system - -#define USE_PTHREADS (1) - -#ifdef USE_LIBSPE2 -#include -#define spu_printf printf -#define DWORD unsigned int - - typedef union - { - unsigned long long ull; - unsigned int ui[2]; - void *p; - } addr64; - - -#else - -#include -#define spu_printf printf - -#endif // USE_LIBSPE2 - -#endif //__CELLOS_LV2__ - -#endif - - -/* Included here because we need uint*_t typedefs */ -#include "PpuAddressSpace.h" - -#endif //TYPE_DEFINITIONS_H - - - diff --git a/bullet/src/BulletMultiThreaded/PosixThreadSupport.cpp b/bullet/src/BulletMultiThreaded/PosixThreadSupport.cpp deleted file mode 100644 index 247064207..000000000 --- a/bullet/src/BulletMultiThreaded/PosixThreadSupport.cpp +++ /dev/null @@ -1,249 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2007 Erwin Coumans http://bulletphysics.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include -#include "PosixThreadSupport.h" -#ifdef USE_PTHREADS -#include -#include - -#include "SpuCollisionTaskProcess.h" -#include "SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.h" - -#define checkPThreadFunction(returnValue) \ - if(0 != returnValue) { \ - printf("PThread problem at line %i in file %s: %i %d\n", __LINE__, __FILE__, returnValue, errno); \ - } - -// The number of threads should be equal to the number of available cores -// Todo: each worker should be linked to a single core, using SetThreadIdealProcessor. - -// PosixThreadSupport helps to initialize/shutdown libspe2, start/stop SPU tasks and communication -// Setup and initialize SPU/CELL/Libspe2 -PosixThreadSupport::PosixThreadSupport(ThreadConstructionInfo& threadConstructionInfo) -{ - startThreads(threadConstructionInfo); -} - -// cleanup/shutdown Libspe2 -PosixThreadSupport::~PosixThreadSupport() -{ - stopSPU(); -} - -#if (defined (__APPLE__)) -#define NAMED_SEMAPHORES -#endif - -// this semaphore will signal, if and how many threads are finished with their work -static sem_t* mainSemaphore; - -static sem_t* createSem(const char* baseName) -{ - static int semCount = 0; -#ifdef NAMED_SEMAPHORES - /// Named semaphore begin - char name[32]; - snprintf(name, 32, "/%s-%d-%4.4d", baseName, getpid(), semCount++); - sem_t* tempSem = sem_open(name, O_CREAT, 0600, 0); - if (tempSem != reinterpret_cast(SEM_FAILED)) - { - //printf("Created \"%s\" Semaphore %x\n", name, tempSem); - } - else - { - //printf("Error creating Semaphore %d\n", errno); - exit(-1); - } - /// Named semaphore end -#else - sem_t* tempSem = new sem_t; - checkPThreadFunction(sem_init(tempSem, 0, 0)); -#endif - return tempSem; -} - -static void destroySem(sem_t* semaphore) -{ -#ifdef NAMED_SEMAPHORES - checkPThreadFunction(sem_close(semaphore)); -#else - checkPThreadFunction(sem_destroy(semaphore)); - delete semaphore; -#endif -} - -static void *threadFunction(void *argument) -{ - - PosixThreadSupport::btSpuStatus* status = (PosixThreadSupport::btSpuStatus*)argument; - - - while (1) - { - checkPThreadFunction(sem_wait(status->startSemaphore)); - - void* userPtr = status->m_userPtr; - - if (userPtr) - { - btAssert(status->m_status); - status->m_userThreadFunc(userPtr,status->m_lsMemory); - status->m_status = 2; - checkPThreadFunction(sem_post(mainSemaphore)); - status->threadUsed++; - } else { - //exit Thread - status->m_status = 3; - checkPThreadFunction(sem_post(mainSemaphore)); - printf("Thread with taskId %i exiting\n",status->m_taskId); - break; - } - - } - - printf("Thread TERMINATED\n"); - return 0; - -} - -///send messages to SPUs -void PosixThreadSupport::sendRequest(uint32_t uiCommand, ppu_address_t uiArgument0, uint32_t taskId) -{ - /// gMidphaseSPU.sendRequest(CMD_GATHER_AND_PROCESS_PAIRLIST, (uint32_t) &taskDesc); - - ///we should spawn an SPU task here, and in 'waitForResponse' it should wait for response of the (one of) the first tasks that finished - - - - switch (uiCommand) - { - case CMD_GATHER_AND_PROCESS_PAIRLIST: - { - btSpuStatus& spuStatus = m_activeSpuStatus[taskId]; - btAssert(taskId >= 0); - btAssert(taskId < m_activeSpuStatus.size()); - - spuStatus.m_commandId = uiCommand; - spuStatus.m_status = 1; - spuStatus.m_userPtr = (void*)uiArgument0; - - // fire event to start new task - checkPThreadFunction(sem_post(spuStatus.startSemaphore)); - break; - } - default: - { - ///not implemented - btAssert(0); - } - - }; - - -} - - -///check for messages from SPUs -void PosixThreadSupport::waitForResponse(unsigned int *puiArgument0, unsigned int *puiArgument1) -{ - ///We should wait for (one of) the first tasks to finish (or other SPU messages), and report its response - - ///A possible response can be 'yes, SPU handled it', or 'no, please do a PPU fallback' - - - btAssert(m_activeSpuStatus.size()); - - // wait for any of the threads to finish - checkPThreadFunction(sem_wait(mainSemaphore)); - - // get at least one thread which has finished - size_t last = -1; - - for(size_t t=0; t < m_activeSpuStatus.size(); ++t) { - if(2 == m_activeSpuStatus[t].m_status) { - last = t; - break; - } - } - - btSpuStatus& spuStatus = m_activeSpuStatus[last]; - - btAssert(spuStatus.m_status > 1); - spuStatus.m_status = 0; - - // need to find an active spu - btAssert(last >= 0); - - *puiArgument0 = spuStatus.m_taskId; - *puiArgument1 = spuStatus.m_status; -} - - - -void PosixThreadSupport::startThreads(ThreadConstructionInfo& threadConstructionInfo) -{ - printf("%s creating %i threads.\n", __FUNCTION__, threadConstructionInfo.m_numThreads); - m_activeSpuStatus.resize(threadConstructionInfo.m_numThreads); - - mainSemaphore = createSem("main"); - - for (int i=0;i < threadConstructionInfo.m_numThreads;i++) - { - printf("starting thread %d\n",i); - - btSpuStatus& spuStatus = m_activeSpuStatus[i]; - - spuStatus.startSemaphore = createSem("threadLocal"); - - checkPThreadFunction(pthread_create(&spuStatus.thread, NULL, &threadFunction, (void*)&spuStatus)); - - spuStatus.m_userPtr=0; - - spuStatus.m_taskId = i; - spuStatus.m_commandId = 0; - spuStatus.m_status = 0; - spuStatus.m_lsMemory = threadConstructionInfo.m_lsMemoryFunc(); - spuStatus.m_userThreadFunc = threadConstructionInfo.m_userThreadFunc; - spuStatus.threadUsed = 0; - - printf("started thread %d \n",i); - - } - -} - -void PosixThreadSupport::startSPU() -{ -} - - -///tell the task scheduler we are done with the SPU tasks -void PosixThreadSupport::stopSPU() -{ - for(size_t t=0; t < m_activeSpuStatus.size(); ++t) { - btSpuStatus& spuStatus = m_activeSpuStatus[t]; - printf("%s: Thread %i used: %ld\n", __FUNCTION__, t, spuStatus.threadUsed); - - destroySem(spuStatus.startSemaphore); - checkPThreadFunction(pthread_cancel(spuStatus.thread)); - } - destroySem(mainSemaphore); - - m_activeSpuStatus.clear(); -} - -#endif // USE_PTHREADS - diff --git a/bullet/src/BulletMultiThreaded/PosixThreadSupport.h b/bullet/src/BulletMultiThreaded/PosixThreadSupport.h deleted file mode 100644 index a6733179b..000000000 --- a/bullet/src/BulletMultiThreaded/PosixThreadSupport.h +++ /dev/null @@ -1,124 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2007 Erwin Coumans http://bulletphysics.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#include "LinearMath/btScalar.h" -#include "PlatformDefinitions.h" - -#ifdef USE_PTHREADS //platform specific defines are defined in PlatformDefinitions.h -#include -#include - -#ifndef POSIX_THREAD_SUPPORT_H -#define POSIX_THREAD_SUPPORT_H - -#include "LinearMath/btAlignedObjectArray.h" - -#include "btThreadSupportInterface.h" - - -typedef void (*PosixThreadFunc)(void* userPtr,void* lsMemory); -typedef void* (*PosixlsMemorySetupFunc)(); - -// PosixThreadSupport helps to initialize/shutdown libspe2, start/stop SPU tasks and communication -class PosixThreadSupport : public btThreadSupportInterface -{ -public: - typedef enum sStatus { - STATUS_BUSY, - STATUS_READY, - STATUS_FINISHED - } Status; - - // placeholder, until libspe2 support is there - struct btSpuStatus - { - uint32_t m_taskId; - uint32_t m_commandId; - uint32_t m_status; - - PosixThreadFunc m_userThreadFunc; - void* m_userPtr; //for taskDesc etc - void* m_lsMemory; //initialized using PosixLocalStoreMemorySetupFunc - - pthread_t thread; - sem_t* startSemaphore; - - unsigned long threadUsed; - }; -private: - - btAlignedObjectArray m_activeSpuStatus; -public: - ///Setup and initialize SPU/CELL/Libspe2 - - - - struct ThreadConstructionInfo - { - ThreadConstructionInfo(char* uniqueName, - PosixThreadFunc userThreadFunc, - PosixlsMemorySetupFunc lsMemoryFunc, - int numThreads=1, - int threadStackSize=65535 - ) - :m_uniqueName(uniqueName), - m_userThreadFunc(userThreadFunc), - m_lsMemoryFunc(lsMemoryFunc), - m_numThreads(numThreads), - m_threadStackSize(threadStackSize) - { - - } - - char* m_uniqueName; - PosixThreadFunc m_userThreadFunc; - PosixlsMemorySetupFunc m_lsMemoryFunc; - int m_numThreads; - int m_threadStackSize; - - }; - - PosixThreadSupport(ThreadConstructionInfo& threadConstructionInfo); - -///cleanup/shutdown Libspe2 - virtual ~PosixThreadSupport(); - - void startThreads(ThreadConstructionInfo& threadInfo); - - -///send messages to SPUs - virtual void sendRequest(uint32_t uiCommand, ppu_address_t uiArgument0, uint32_t uiArgument1); - -///check for messages from SPUs - virtual void waitForResponse(unsigned int *puiArgument0, unsigned int *puiArgument1); - -///start the spus (can be called at the beginning of each frame, to make sure that the right SPU program is loaded) - virtual void startSPU(); - -///tell the task scheduler we are done with the SPU tasks - virtual void stopSPU(); - - virtual void setNumTasks(int numTasks) {} - - virtual int getNumTasks() const - { - return m_activeSpuStatus.size(); - } -}; - -#endif // POSIX_THREAD_SUPPORT_H - -#endif // USE_PTHREADS diff --git a/bullet/src/BulletMultiThreaded/PpuAddressSpace.h b/bullet/src/BulletMultiThreaded/PpuAddressSpace.h deleted file mode 100644 index 948aea620..000000000 --- a/bullet/src/BulletMultiThreaded/PpuAddressSpace.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef __PPU_ADDRESS_SPACE_H -#define __PPU_ADDRESS_SPACE_H - - -#ifdef WIN32 -//stop those casting warnings until we have a better solution for ppu_address_t / void* / uint64 conversions -#pragma warning (disable: 4311) -#pragma warning (disable: 4312) -#endif //WIN32 - -#if defined(_WIN64) || defined(__LP64__) || defined(__x86_64__) || defined(USE_ADDR64) -typedef uint64_t ppu_address_t; -#else - -typedef uint32_t ppu_address_t; - -#endif - -#endif - diff --git a/bullet/src/BulletMultiThreaded/SequentialThreadSupport.cpp b/bullet/src/BulletMultiThreaded/SequentialThreadSupport.cpp deleted file mode 100644 index a1a473aeb..000000000 --- a/bullet/src/BulletMultiThreaded/SequentialThreadSupport.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2007 Erwin Coumans http://bulletphysics.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "SequentialThreadSupport.h" - - -#include "SpuCollisionTaskProcess.h" -#include "SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.h" - -SequentialThreadSupport::SequentialThreadSupport(SequentialThreadConstructionInfo& threadConstructionInfo) -{ - startThreads(threadConstructionInfo); -} - -///cleanup/shutdown Libspe2 -SequentialThreadSupport::~SequentialThreadSupport() -{ - stopSPU(); -} - -#include - -///send messages to SPUs -void SequentialThreadSupport::sendRequest(uint32_t uiCommand, ppu_address_t uiArgument0, uint32_t taskId) -{ - switch (uiCommand) - { - case CMD_GATHER_AND_PROCESS_PAIRLIST: - { - btSpuStatus& spuStatus = m_activeSpuStatus[0]; - spuStatus.m_userPtr=(void*)uiArgument0; - spuStatus.m_userThreadFunc(spuStatus.m_userPtr,spuStatus.m_lsMemory); - } - break; - default: - { - ///not implemented - btAssert(0 && "Not implemented"); - } - - }; - - -} - -///check for messages from SPUs -void SequentialThreadSupport::waitForResponse(unsigned int *puiArgument0, unsigned int *puiArgument1) -{ - btAssert(m_activeSpuStatus.size()); - btSpuStatus& spuStatus = m_activeSpuStatus[0]; - *puiArgument0 = spuStatus.m_taskId; - *puiArgument1 = spuStatus.m_status; -} - -void SequentialThreadSupport::startThreads(SequentialThreadConstructionInfo& threadConstructionInfo) -{ - m_activeSpuStatus.resize(1); - printf("STS: Not starting any threads\n"); - btSpuStatus& spuStatus = m_activeSpuStatus[0]; - spuStatus.m_userPtr = 0; - spuStatus.m_taskId = 0; - spuStatus.m_commandId = 0; - spuStatus.m_status = 0; - spuStatus.m_lsMemory = threadConstructionInfo.m_lsMemoryFunc(); - spuStatus.m_userThreadFunc = threadConstructionInfo.m_userThreadFunc; - printf("STS: Created local store at %p for task %s\n", spuStatus.m_lsMemory, threadConstructionInfo.m_uniqueName); -} - -void SequentialThreadSupport::startSPU() -{ -} - -void SequentialThreadSupport::stopSPU() -{ - m_activeSpuStatus.clear(); -} - -void SequentialThreadSupport::setNumTasks(int numTasks) -{ - printf("SequentialThreadSupport::setNumTasks(%d) is not implemented and has no effect\n",numTasks); -} diff --git a/bullet/src/BulletMultiThreaded/SequentialThreadSupport.h b/bullet/src/BulletMultiThreaded/SequentialThreadSupport.h deleted file mode 100644 index 57b7be434..000000000 --- a/bullet/src/BulletMultiThreaded/SequentialThreadSupport.h +++ /dev/null @@ -1,92 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2007 Erwin Coumans http://bulletphysics.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "LinearMath/btScalar.h" -#include "PlatformDefinitions.h" - - -#ifndef SEQUENTIAL_THREAD_SUPPORT_H -#define SEQUENTIAL_THREAD_SUPPORT_H - -#include "LinearMath/btAlignedObjectArray.h" - -#include "btThreadSupportInterface.h" - -typedef void (*SequentialThreadFunc)(void* userPtr,void* lsMemory); -typedef void* (*SequentiallsMemorySetupFunc)(); - - - -///The SequentialThreadSupport is a portable non-parallel implementation of the btThreadSupportInterface -///This is useful for debugging and porting SPU Tasks to other platforms. -class SequentialThreadSupport : public btThreadSupportInterface -{ -public: - struct btSpuStatus - { - uint32_t m_taskId; - uint32_t m_commandId; - uint32_t m_status; - - SequentialThreadFunc m_userThreadFunc; - - void* m_userPtr; //for taskDesc etc - void* m_lsMemory; //initialized using SequentiallsMemorySetupFunc - }; -private: - btAlignedObjectArray m_activeSpuStatus; - btAlignedObjectArray m_completeHandles; -public: - struct SequentialThreadConstructionInfo - { - SequentialThreadConstructionInfo (char* uniqueName, - SequentialThreadFunc userThreadFunc, - SequentiallsMemorySetupFunc lsMemoryFunc - ) - :m_uniqueName(uniqueName), - m_userThreadFunc(userThreadFunc), - m_lsMemoryFunc(lsMemoryFunc) - { - - } - - char* m_uniqueName; - SequentialThreadFunc m_userThreadFunc; - SequentiallsMemorySetupFunc m_lsMemoryFunc; - }; - - SequentialThreadSupport(SequentialThreadConstructionInfo& threadConstructionInfo); - virtual ~SequentialThreadSupport(); - void startThreads(SequentialThreadConstructionInfo& threadInfo); -///send messages to SPUs - virtual void sendRequest(uint32_t uiCommand, ppu_address_t uiArgument0, uint32_t uiArgument1); -///check for messages from SPUs - virtual void waitForResponse(unsigned int *puiArgument0, unsigned int *puiArgument1); -///start the spus (can be called at the beginning of each frame, to make sure that the right SPU program is loaded) - virtual void startSPU(); -///tell the task scheduler we are done with the SPU tasks - virtual void stopSPU(); - - virtual void setNumTasks(int numTasks); - - virtual int getNumTasks() const - { - return 1; - } - -}; - -#endif //SEQUENTIAL_THREAD_SUPPORT_H - diff --git a/bullet/src/BulletMultiThreaded/SpuCollisionObjectWrapper.cpp b/bullet/src/BulletMultiThreaded/SpuCollisionObjectWrapper.cpp deleted file mode 100644 index d1de6f95b..000000000 --- a/bullet/src/BulletMultiThreaded/SpuCollisionObjectWrapper.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2007 Erwin Coumans http://bulletphysics.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "SpuCollisionObjectWrapper.h" -#include "BulletCollision/CollisionShapes/btCollisionShape.h" - -SpuCollisionObjectWrapper::SpuCollisionObjectWrapper () -{ -} - -#ifndef __SPU__ -SpuCollisionObjectWrapper::SpuCollisionObjectWrapper (const btCollisionObject* collisionObject) -{ - m_shapeType = collisionObject->getCollisionShape()->getShapeType (); - m_collisionObjectPtr = (ppu_address_t)collisionObject; - m_margin = collisionObject->getCollisionShape()->getMargin (); -} -#endif - -int -SpuCollisionObjectWrapper::getShapeType () const -{ - return m_shapeType; -} - -float -SpuCollisionObjectWrapper::getCollisionMargin () const -{ - return m_margin; -} - -ppu_address_t -SpuCollisionObjectWrapper::getCollisionObjectPtr () const -{ - return m_collisionObjectPtr; -} diff --git a/bullet/src/BulletMultiThreaded/SpuCollisionObjectWrapper.h b/bullet/src/BulletMultiThreaded/SpuCollisionObjectWrapper.h deleted file mode 100644 index 2a3a11e4f..000000000 --- a/bullet/src/BulletMultiThreaded/SpuCollisionObjectWrapper.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2007 Erwin Coumans http://bulletphysics.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef SPU_COLLISION_OBJECT_WRAPPER_H -#define SPU_COLLISION_OBJECT_WRAPPER_H - -#include "PlatformDefinitions.h" -#include "BulletCollision/CollisionDispatch/btCollisionObject.h" - -ATTRIBUTE_ALIGNED16(class) SpuCollisionObjectWrapper -{ -protected: - int m_shapeType; - float m_margin; - ppu_address_t m_collisionObjectPtr; - -public: - SpuCollisionObjectWrapper (); - - SpuCollisionObjectWrapper (const btCollisionObject* collisionObject); - - int getShapeType () const; - float getCollisionMargin () const; - ppu_address_t getCollisionObjectPtr () const; -}; - - -#endif //SPU_COLLISION_OBJECT_WRAPPER_H diff --git a/bullet/src/BulletMultiThreaded/SpuCollisionTaskProcess.cpp b/bullet/src/BulletMultiThreaded/SpuCollisionTaskProcess.cpp deleted file mode 100644 index 80885c5dd..000000000 --- a/bullet/src/BulletMultiThreaded/SpuCollisionTaskProcess.cpp +++ /dev/null @@ -1,318 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2007 Erwin Coumans http://bulletphysics.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -//#define DEBUG_SPU_TASK_SCHEDULING 1 - - -//class OptimizedBvhNode; - -#include "SpuCollisionTaskProcess.h" - - - - -void SpuCollisionTaskProcess::setNumTasks(int maxNumTasks) -{ - if (m_maxNumOutstandingTasks != maxNumTasks) - { - m_maxNumOutstandingTasks = maxNumTasks; - m_taskBusy.resize(m_maxNumOutstandingTasks); - m_spuGatherTaskDesc.resize(m_maxNumOutstandingTasks); - - for (int i = 0; i < m_taskBusy.size(); i++) - { - m_taskBusy[i] = false; - } - - ///re-allocate task memory buffers - if (m_workUnitTaskBuffers != 0) - { - btAlignedFree(m_workUnitTaskBuffers); - } - - m_workUnitTaskBuffers = (unsigned char *)btAlignedAlloc(MIDPHASE_WORKUNIT_TASK_SIZE*m_maxNumOutstandingTasks, 128); - m_workUnitTaskBuffers = (unsigned char *)btAlignedAlloc(MIDPHASE_WORKUNIT_TASK_SIZE*6, 128); - } - -} - - - -SpuCollisionTaskProcess::SpuCollisionTaskProcess(class btThreadSupportInterface* threadInterface, unsigned int maxNumOutstandingTasks) -:m_threadInterface(threadInterface), -m_maxNumOutstandingTasks(0) -{ - m_workUnitTaskBuffers = (unsigned char *)0; - setNumTasks(maxNumOutstandingTasks); - m_numBusyTasks = 0; - m_currentTask = 0; - m_currentPage = 0; - m_currentPageEntry = 0; - -#ifdef DEBUG_SpuCollisionTaskProcess - m_initialized = false; -#endif - - m_threadInterface->startSPU(); - - //printf("sizeof vec_float4: %d\n", sizeof(vec_float4)); - printf("sizeof SpuGatherAndProcessWorkUnitInput: %d\n", sizeof(SpuGatherAndProcessWorkUnitInput)); - -} - -SpuCollisionTaskProcess::~SpuCollisionTaskProcess() -{ - - if (m_workUnitTaskBuffers != 0) - { - btAlignedFree(m_workUnitTaskBuffers); - m_workUnitTaskBuffers = 0; - } - - - - m_threadInterface->stopSPU(); - -} - - - -void SpuCollisionTaskProcess::initialize2(bool useEpa) -{ - -#ifdef DEBUG_SPU_TASK_SCHEDULING - printf("SpuCollisionTaskProcess::initialize()\n"); -#endif //DEBUG_SPU_TASK_SCHEDULING - - for (int i = 0; i < int (m_maxNumOutstandingTasks); i++) - { - m_taskBusy[i] = false; - } - m_numBusyTasks = 0; - m_currentTask = 0; - m_currentPage = 0; - m_currentPageEntry = 0; - m_useEpa = useEpa; - -#ifdef DEBUG_SpuCollisionTaskProcess - m_initialized = true; - btAssert(MIDPHASE_NUM_WORKUNITS_PER_TASK*sizeof(SpuGatherAndProcessWorkUnitInput) <= MIDPHASE_WORKUNIT_TASK_SIZE); -#endif -} - - -void SpuCollisionTaskProcess::issueTask2() -{ - -#ifdef DEBUG_SPU_TASK_SCHEDULING - printf("SpuCollisionTaskProcess::issueTask (m_currentTask= %d\n)", m_currentTask); -#endif //DEBUG_SPU_TASK_SCHEDULING - - m_taskBusy[m_currentTask] = true; - m_numBusyTasks++; - - - SpuGatherAndProcessPairsTaskDesc& taskDesc = m_spuGatherTaskDesc[m_currentTask]; - taskDesc.m_useEpa = m_useEpa; - - { - // send task description in event message - // no error checking here... - // but, currently, event queue can be no larger than NUM_WORKUNIT_TASKS. - - taskDesc.m_inPairPtr = reinterpret_cast(MIDPHASE_TASK_PTR(m_currentTask)); - - taskDesc.taskId = m_currentTask; - taskDesc.numPages = m_currentPage+1; - taskDesc.numOnLastPage = m_currentPageEntry; - } - - - - m_threadInterface->sendRequest(CMD_GATHER_AND_PROCESS_PAIRLIST, (ppu_address_t) &taskDesc,m_currentTask); - - // if all tasks busy, wait for spu event to clear the task. - - - if (m_numBusyTasks >= m_maxNumOutstandingTasks) - { - unsigned int taskId; - unsigned int outputSize; - - - for (int i=0;i=0); - - - m_threadInterface->waitForResponse(&taskId, &outputSize); - -// printf("issueTask taskId %d completed, numBusy=%d\n",taskId,m_numBusyTasks); - - //printf("PPU: after issue, received event: %u %d\n", taskId, outputSize); - - //postProcess(taskId, outputSize); - - m_taskBusy[taskId] = false; - - m_numBusyTasks--; - } - -} - -void SpuCollisionTaskProcess::addWorkToTask(void* pairArrayPtr,int startIndex,int endIndex) -{ -#ifdef DEBUG_SPU_TASK_SCHEDULING - printf("#"); -#endif //DEBUG_SPU_TASK_SCHEDULING - -#ifdef DEBUG_SpuCollisionTaskProcess - btAssert(m_initialized); - btAssert(m_workUnitTaskBuffers); - -#endif - - bool batch = true; - - if (batch) - { - if (m_currentPageEntry == MIDPHASE_NUM_WORKUNITS_PER_PAGE) - { - if (m_currentPage == MIDPHASE_NUM_WORKUNIT_PAGES-1) - { - // task buffer is full, issue current task. - // if all task buffers busy, this waits until SPU is done. - issueTask2(); - - // find new task buffer - for (unsigned int i = 0; i < m_maxNumOutstandingTasks; i++) - { - if (!m_taskBusy[i]) - { - m_currentTask = i; - //init the task data - - break; - } - } - - m_currentPage = 0; - } - else - { - m_currentPage++; - } - - m_currentPageEntry = 0; - } - } - - { - - - - SpuGatherAndProcessWorkUnitInput &wuInput = - *(reinterpret_cast - (MIDPHASE_ENTRY_PTR(m_currentTask, m_currentPage, m_currentPageEntry))); - - wuInput.m_pairArrayPtr = reinterpret_cast(pairArrayPtr); - wuInput.m_startIndex = startIndex; - wuInput.m_endIndex = endIndex; - - - - m_currentPageEntry++; - - if (!batch) - { - issueTask2(); - - // find new task buffer - for (unsigned int i = 0; i < m_maxNumOutstandingTasks; i++) - { - if (!m_taskBusy[i]) - { - m_currentTask = i; - //init the task data - - break; - } - } - - m_currentPage = 0; - m_currentPageEntry =0; - } - } -} - - -void -SpuCollisionTaskProcess::flush2() -{ -#ifdef DEBUG_SPU_TASK_SCHEDULING - printf("\nSpuCollisionTaskProcess::flush()\n"); -#endif //DEBUG_SPU_TASK_SCHEDULING - - // if there's a partially filled task buffer, submit that task - if (m_currentPage > 0 || m_currentPageEntry > 0) - { - issueTask2(); - } - - - // all tasks are issued, wait for all tasks to be complete - while(m_numBusyTasks > 0) - { - // Consolidating SPU code - unsigned int taskId=-1; - unsigned int outputSize; - - for (int i=0;i=0); - - - { - - // SPURS support. - m_threadInterface->waitForResponse(&taskId, &outputSize); - } -// printf("flush2 taskId %d completed, numBusy =%d \n",taskId,m_numBusyTasks); - //printf("PPU: flushing, received event: %u %d\n", taskId, outputSize); - - //postProcess(taskId, outputSize); - - m_taskBusy[taskId] = false; - - m_numBusyTasks--; - } - - -} diff --git a/bullet/src/BulletMultiThreaded/SpuCollisionTaskProcess.h b/bullet/src/BulletMultiThreaded/SpuCollisionTaskProcess.h deleted file mode 100644 index 4985a44dd..000000000 --- a/bullet/src/BulletMultiThreaded/SpuCollisionTaskProcess.h +++ /dev/null @@ -1,163 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2007 Erwin Coumans http://bulletphysics.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef SPU_COLLISION_TASK_PROCESS_H -#define SPU_COLLISION_TASK_PROCESS_H - -#include - -#include - -#include "PlatformDefinitions.h" -#include "LinearMath/btAlignedObjectArray.h" -#include "SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.h" // for definitions processCollisionTask and createCollisionLocalStoreMemory - -#include "btThreadSupportInterface.h" - - -//#include "SPUAssert.h" -#include - - -#include "BulletCollision/CollisionDispatch/btCollisionObject.h" -#include "BulletCollision/CollisionShapes/btCollisionShape.h" -#include "BulletCollision/CollisionShapes/btConvexShape.h" - -#include - -#include - - -#define DEBUG_SpuCollisionTaskProcess 1 - - -#define CMD_GATHER_AND_PROCESS_PAIRLIST 1 - -class btCollisionObject; -class btPersistentManifold; -class btDispatcher; - - -/////Task Description for SPU collision detection -//struct SpuGatherAndProcessPairsTaskDesc -//{ -// uint64_t inPtr;//m_pairArrayPtr; -// //mutex variable -// uint32_t m_someMutexVariableInMainMemory; -// -// uint64_t m_dispatcher; -// -// uint32_t numOnLastPage; -// -// uint16_t numPages; -// uint16_t taskId; -// -// struct CollisionTask_LocalStoreMemory* m_lsMemory; -//} -// -//#if defined(__CELLOS_LV2__) || defined(USE_LIBSPE2) -//__attribute__ ((aligned (16))) -//#endif -//; - - -///MidphaseWorkUnitInput stores individual primitive versus mesh collision detection input, to be processed by the SPU. -ATTRIBUTE_ALIGNED16(struct) SpuGatherAndProcessWorkUnitInput -{ - uint64_t m_pairArrayPtr; - int m_startIndex; - int m_endIndex; -}; - - - - -/// SpuCollisionTaskProcess handles SPU processing of collision pairs. -/// Maintains a set of task buffers. -/// When the task is full, the task is issued for SPUs to process. Contact output goes into btPersistentManifold -/// associated with each task. -/// When PPU issues a task, it will look for completed task buffers -/// PPU will do postprocessing, dependent on workunit output (not likely) -class SpuCollisionTaskProcess -{ - - unsigned char *m_workUnitTaskBuffers; - - - // track task buffers that are being used, and total busy tasks - btAlignedObjectArray m_taskBusy; - btAlignedObjectArray m_spuGatherTaskDesc; - - class btThreadSupportInterface* m_threadInterface; - - unsigned int m_maxNumOutstandingTasks; - - unsigned int m_numBusyTasks; - - // the current task and the current entry to insert a new work unit - unsigned int m_currentTask; - unsigned int m_currentPage; - unsigned int m_currentPageEntry; - - bool m_useEpa; - -#ifdef DEBUG_SpuCollisionTaskProcess - bool m_initialized; -#endif - void issueTask2(); - //void postProcess(unsigned int taskId, int outputSize); - -public: - SpuCollisionTaskProcess(btThreadSupportInterface* threadInterface, unsigned int maxNumOutstandingTasks); - - ~SpuCollisionTaskProcess(); - - ///call initialize in the beginning of the frame, before addCollisionPairToTask - void initialize2(bool useEpa = false); - - ///batch up additional work to a current task for SPU processing. When batch is full, it issues the task. - void addWorkToTask(void* pairArrayPtr,int startIndex,int endIndex); - - ///call flush to submit potential outstanding work to SPUs and wait for all involved SPUs to be finished - void flush2(); - - /// set the maximum number of SPU tasks allocated - void setNumTasks(int maxNumTasks); - - int getNumTasks() const - { - return m_maxNumOutstandingTasks; - } -}; - - - -#define MIDPHASE_TASK_PTR(task) (&m_workUnitTaskBuffers[0] + MIDPHASE_WORKUNIT_TASK_SIZE*task) -#define MIDPHASE_ENTRY_PTR(task,page,entry) (MIDPHASE_TASK_PTR(task) + MIDPHASE_WORKUNIT_PAGE_SIZE*page + sizeof(SpuGatherAndProcessWorkUnitInput)*entry) -#define MIDPHASE_OUTPUT_PTR(task) (&m_contactOutputBuffers[0] + MIDPHASE_MAX_CONTACT_BUFFER_SIZE*task) -#define MIDPHASE_TREENODES_PTR(task) (&m_complexShapeBuffers[0] + MIDPHASE_COMPLEX_SHAPE_BUFFER_SIZE*task) - - -#define MIDPHASE_WORKUNIT_PAGE_SIZE (16) -//#define MIDPHASE_WORKUNIT_PAGE_SIZE (128) - -#define MIDPHASE_NUM_WORKUNIT_PAGES 1 -#define MIDPHASE_WORKUNIT_TASK_SIZE (MIDPHASE_WORKUNIT_PAGE_SIZE*MIDPHASE_NUM_WORKUNIT_PAGES) -#define MIDPHASE_NUM_WORKUNITS_PER_PAGE (MIDPHASE_WORKUNIT_PAGE_SIZE / sizeof(SpuGatherAndProcessWorkUnitInput)) -#define MIDPHASE_NUM_WORKUNITS_PER_TASK (MIDPHASE_NUM_WORKUNITS_PER_PAGE*MIDPHASE_NUM_WORKUNIT_PAGES) - - -#endif // SPU_COLLISION_TASK_PROCESS_H - diff --git a/bullet/src/BulletMultiThreaded/SpuContactManifoldCollisionAlgorithm.cpp b/bullet/src/BulletMultiThreaded/SpuContactManifoldCollisionAlgorithm.cpp deleted file mode 100644 index b2d93b38c..000000000 --- a/bullet/src/BulletMultiThreaded/SpuContactManifoldCollisionAlgorithm.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2007 Erwin Coumans http://bulletphysics.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "SpuContactManifoldCollisionAlgorithm.h" -#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h" -#include "BulletCollision/CollisionDispatch/btCollisionObject.h" -#include "BulletCollision/CollisionShapes/btCollisionShape.h" -#include "BulletCollision/CollisionShapes/btPolyhedralConvexShape.h" - - - - -void SpuContactManifoldCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) -{ - btAssert(0); -} - -btScalar SpuContactManifoldCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) -{ - btAssert(0); - return 1.f; -} - -#ifndef __SPU__ -SpuContactManifoldCollisionAlgorithm::SpuContactManifoldCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1) -:btCollisionAlgorithm(ci) -#ifdef USE_SEPDISTANCE_UTIL -,m_sepDistance(body0->getCollisionShape()->getAngularMotionDisc(),body1->getCollisionShape()->getAngularMotionDisc()) -#endif //USE_SEPDISTANCE_UTIL -{ - m_manifoldPtr = m_dispatcher->getNewManifold(body0,body1); - m_shapeType0 = body0->getCollisionShape()->getShapeType(); - m_shapeType1 = body1->getCollisionShape()->getShapeType(); - m_collisionMargin0 = body0->getCollisionShape()->getMargin(); - m_collisionMargin1 = body1->getCollisionShape()->getMargin(); - m_collisionObject0 = body0; - m_collisionObject1 = body1; - - if (body0->getCollisionShape()->isPolyhedral()) - { - btPolyhedralConvexShape* convex0 = (btPolyhedralConvexShape*)body0->getCollisionShape(); - m_shapeDimensions0 = convex0->getImplicitShapeDimensions(); - } - if (body1->getCollisionShape()->isPolyhedral()) - { - btPolyhedralConvexShape* convex1 = (btPolyhedralConvexShape*)body1->getCollisionShape(); - m_shapeDimensions1 = convex1->getImplicitShapeDimensions(); - } -} -#endif //__SPU__ - - -SpuContactManifoldCollisionAlgorithm::~SpuContactManifoldCollisionAlgorithm() -{ - if (m_manifoldPtr) - m_dispatcher->releaseManifold(m_manifoldPtr); -} diff --git a/bullet/src/BulletMultiThreaded/SpuContactManifoldCollisionAlgorithm.h b/bullet/src/BulletMultiThreaded/SpuContactManifoldCollisionAlgorithm.h deleted file mode 100644 index 486a49742..000000000 --- a/bullet/src/BulletMultiThreaded/SpuContactManifoldCollisionAlgorithm.h +++ /dev/null @@ -1,120 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2007 Erwin Coumans http://bulletphysics.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef SPU_CONTACTMANIFOLD_COLLISION_ALGORITHM_H -#define SPU_CONTACTMANIFOLD_COLLISION_ALGORITHM_H - -#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h" -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" -#include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h" -#include "BulletCollision/BroadphaseCollision/btDispatcher.h" -#include "LinearMath/btTransformUtil.h" - -class btPersistentManifold; - -//#define USE_SEPDISTANCE_UTIL 1 - -/// SpuContactManifoldCollisionAlgorithm provides contact manifold and should be processed on SPU. -ATTRIBUTE_ALIGNED16(class) SpuContactManifoldCollisionAlgorithm : public btCollisionAlgorithm -{ - btVector3 m_shapeDimensions0; - btVector3 m_shapeDimensions1; - btPersistentManifold* m_manifoldPtr; - int m_shapeType0; - int m_shapeType1; - float m_collisionMargin0; - float m_collisionMargin1; - - btCollisionObject* m_collisionObject0; - btCollisionObject* m_collisionObject1; - - - - -public: - - virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); - - virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); - - - SpuContactManifoldCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1); -#ifdef USE_SEPDISTANCE_UTIL - btConvexSeparatingDistanceUtil m_sepDistance; -#endif //USE_SEPDISTANCE_UTIL - - virtual ~SpuContactManifoldCollisionAlgorithm(); - - virtual void getAllContactManifolds(btManifoldArray& manifoldArray) - { - if (m_manifoldPtr) - manifoldArray.push_back(m_manifoldPtr); - } - - btPersistentManifold* getContactManifoldPtr() - { - return m_manifoldPtr; - } - - btCollisionObject* getCollisionObject0() - { - return m_collisionObject0; - } - - btCollisionObject* getCollisionObject1() - { - return m_collisionObject1; - } - - int getShapeType0() const - { - return m_shapeType0; - } - - int getShapeType1() const - { - return m_shapeType1; - } - float getCollisionMargin0() const - { - return m_collisionMargin0; - } - float getCollisionMargin1() const - { - return m_collisionMargin1; - } - - const btVector3& getShapeDimensions0() const - { - return m_shapeDimensions0; - } - - const btVector3& getShapeDimensions1() const - { - return m_shapeDimensions1; - } - - struct CreateFunc :public btCollisionAlgorithmCreateFunc - { - virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1) - { - void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(SpuContactManifoldCollisionAlgorithm)); - return new(mem) SpuContactManifoldCollisionAlgorithm(ci,body0,body1); - } - }; - -}; - -#endif //SPU_CONTACTMANIFOLD_COLLISION_ALGORITHM_H diff --git a/bullet/src/BulletMultiThreaded/SpuDoubleBuffer.h b/bullet/src/BulletMultiThreaded/SpuDoubleBuffer.h deleted file mode 100644 index 064d87465..000000000 --- a/bullet/src/BulletMultiThreaded/SpuDoubleBuffer.h +++ /dev/null @@ -1,110 +0,0 @@ -#ifndef DOUBLE_BUFFER_H -#define DOUBLE_BUFFER_H - -#include "SpuFakeDma.h" -#include - - -///DoubleBuffer -template -class DoubleBuffer -{ -#if defined(__SPU__) || defined(USE_LIBSPE2) - ATTRIBUTE_ALIGNED128( T m_buffer0[size] ) ; - ATTRIBUTE_ALIGNED128( T m_buffer1[size] ) ; -#else - T m_buffer0[size]; - T m_buffer1[size]; -#endif - - T *m_frontBuffer; - T *m_backBuffer; - - unsigned int m_dmaTag; - bool m_dmaPending; -public: - bool isPending() const { return m_dmaPending;} - DoubleBuffer(); - - void init (); - - // dma get and put commands - void backBufferDmaGet(uint64_t ea, unsigned int numBytes, unsigned int tag); - void backBufferDmaPut(uint64_t ea, unsigned int numBytes, unsigned int tag); - - // gets pointer to a buffer - T *getFront(); - T *getBack(); - - // if back buffer dma was started, wait for it to complete - // then move back to front and vice versa - T *swapBuffers(); -}; - -template -DoubleBuffer::DoubleBuffer() -{ - init (); -} - -template -void DoubleBuffer::init() -{ - this->m_dmaPending = false; - this->m_frontBuffer = &this->m_buffer0[0]; - this->m_backBuffer = &this->m_buffer1[0]; -} - -template -void -DoubleBuffer::backBufferDmaGet(uint64_t ea, unsigned int numBytes, unsigned int tag) -{ - m_dmaPending = true; - m_dmaTag = tag; - if (numBytes) - { - m_backBuffer = (T*)cellDmaLargeGetReadOnly(m_backBuffer, ea, numBytes, tag, 0, 0); - } -} - -template -void -DoubleBuffer::backBufferDmaPut(uint64_t ea, unsigned int numBytes, unsigned int tag) -{ - m_dmaPending = true; - m_dmaTag = tag; - cellDmaLargePut(m_backBuffer, ea, numBytes, tag, 0, 0); -} - -template -T * -DoubleBuffer::getFront() -{ - return m_frontBuffer; -} - -template -T * -DoubleBuffer::getBack() -{ - return m_backBuffer; -} - -template -T * -DoubleBuffer::swapBuffers() -{ - if (m_dmaPending) - { - cellDmaWaitTagStatusAll(1< //for btAssert -//Disabling memcpy sometimes helps debugging DMA - -#define USE_MEMCPY 1 -#ifdef USE_MEMCPY - -#endif - - -void* cellDmaLargeGetReadOnly(void *ls, uint64_t ea, uint32_t size, uint32_t tag, uint32_t tid, uint32_t rid) -{ - -#if defined (__SPU__) || defined (USE_LIBSPE2) - cellDmaLargeGet(ls,ea,size,tag,tid,rid); - return ls; -#else - return (void*)(uint32_t)ea; -#endif -} - -void* cellDmaSmallGetReadOnly(void *ls, uint64_t ea, uint32_t size, uint32_t tag, uint32_t tid, uint32_t rid) -{ -#if defined (__SPU__) || defined (USE_LIBSPE2) - mfc_get(ls,ea,size,tag,0,0); - return ls; -#else - return (void*)(uint32_t)ea; -#endif -} - - - - -void* cellDmaGetReadOnly(void *ls, uint64_t ea, uint32_t size, uint32_t tag, uint32_t tid, uint32_t rid) -{ -#if defined (__SPU__) || defined (USE_LIBSPE2) - cellDmaGet(ls,ea,size,tag,tid,rid); - return ls; -#else - return (void*)(uint32_t)ea; -#endif -} - - -///this unalignedDma should not be frequently used, only for small data. It handles alignment and performs check on size (<16 bytes) -int stallingUnalignedDmaSmallGet(void *ls, uint64_t ea, uint32_t size) -{ - - btAssert(size<32); - - ATTRIBUTE_ALIGNED16(char tmpBuffer[32]); - - - char* localStore = (char*)ls; - uint32_t i; - - - ///make sure last 4 bits are the same, for cellDmaSmallGet - uint32_t last4BitsOffset = ea & 0x0f; - char* tmpTarget = tmpBuffer + last4BitsOffset; - -#if defined (__SPU__) || defined (USE_LIBSPE2) - - int remainingSize = size; - -//#define FORCE_cellDmaUnalignedGet 1 -#ifdef FORCE_cellDmaUnalignedGet - cellDmaUnalignedGet(tmpTarget,ea,size,DMA_TAG(1),0,0); -#else - char* remainingTmpTarget = tmpTarget; - uint64_t remainingEa = ea; - - while (remainingSize) - { - switch (remainingSize) - { - case 1: - case 2: - case 4: - case 8: - case 16: - { - mfc_get(remainingTmpTarget,remainingEa,remainingSize,DMA_TAG(1),0,0); - remainingSize=0; - break; - } - default: - { - //spu_printf("unaligned DMA with non-natural size:%d\n",remainingSize); - int actualSize = 0; - - if (remainingSize > 16) - actualSize = 16; - else - if (remainingSize >8) - actualSize=8; - else - if (remainingSize >4) - actualSize=4; - else - if (remainingSize >2) - actualSize=2; - mfc_get(remainingTmpTarget,remainingEa,actualSize,DMA_TAG(1),0,0); - remainingSize-=actualSize; - remainingTmpTarget+=actualSize; - remainingEa += actualSize; - } - } - } -#endif//FORCE_cellDmaUnalignedGet - -#else - char* mainMem = (char*)ea; - //copy into final destination -#ifdef USE_MEMCPY - - memcpy(tmpTarget,mainMem,size); -#else - for ( i=0;i -#include - -#define DMA_TAG(xfer) (xfer + 1) -#define DMA_MASK(xfer) (1 << DMA_TAG(xfer)) - -#else // !USE_LIBSPE2 - -#define DMA_TAG(xfer) (xfer + 1) -#define DMA_MASK(xfer) (1 << DMA_TAG(xfer)) - -#include - -#define DEBUG_DMA -#ifdef DEBUG_DMA -#define dUASSERT(a,b) if (!(a)) { printf(b);} -#define uintsize ppu_address_t - -#define cellDmaLargeGet(ls, ea, size, tag, tid, rid) if ( (((uintsize)ls%16) != ((uintsize)ea%16)) || ((((uintsize)ea%16) || ((uintsize)ls%16)) && (( ((uintsize)ls%16) != ((uintsize)size%16) ) || ( ((uintsize)ea%16) != ((uintsize)size%16) ) ) ) || ( ((uintsize)size%16) && ((uintsize)size!=1) && ((uintsize)size!=2) && ((uintsize)size!=4) && ((uintsize)size!=8) ) || (size >= 16384) || !(uintsize)ls || !(uintsize)ea) { \ - dUASSERT( (((uintsize)ea % 16) == 0) || (size < 16), "XDR Address not aligned: "); \ - dUASSERT( (((uintsize)ls % 16) == 0) || (size < 16), "LS Address not aligned: "); \ - dUASSERT( ((((uintsize)ls % size) == 0) && (((uintsize)ea % size) == 0)) || (size > 16), "Not naturally aligned: "); \ - dUASSERT((size == 1) || (size == 2) || (size == 4) || (size == 8) || ((size % 16) == 0), "size not a multiple of 16byte: "); \ - dUASSERT(size < 16384, "size too big: "); \ - dUASSERT( ((uintsize)ea%16)==((uintsize)ls%16), "wrong Quadword alignment of LS and EA: "); \ - dUASSERT(ea != 0, "Nullpointer EA: "); dUASSERT(ls != 0, "Nullpointer LS: ");\ - printf("GET %s:%d from: 0x%x, to: 0x%x - %d bytes\n", __FILE__, __LINE__, (unsigned int)ea,(unsigned int)ls,(unsigned int)size);\ - } \ - mfc_get(ls, ea, size, tag, tid, rid) -#define cellDmaGet(ls, ea, size, tag, tid, rid) if ( (((uintsize)ls%16) != ((uintsize)ea%16)) || ((((uintsize)ea%16) || ((uintsize)ls%16)) && (( ((uintsize)ls%16) != ((uintsize)size%16) ) || ( ((uintsize)ea%16) != ((uintsize)size%16) ) ) ) || ( ((uintsize)size%16) && ((uintsize)size!=1) && ((uintsize)size!=2) && ((uintsize)size!=4) && ((uintsize)size!=8) ) || (size >= 16384) || !(uintsize)ls || !(uintsize)ea) { \ - dUASSERT( (((uintsize)ea % 16) == 0) || (size < 16), "XDR Address not aligned: "); \ - dUASSERT( (((uintsize)ls % 16) == 0) || (size < 16), "LS Address not aligned: "); \ - dUASSERT( ((((uintsize)ls % size) == 0) && (((uintsize)ea % size) == 0)) || (size > 16), "Not naturally aligned: "); \ - dUASSERT((size == 1) || (size == 2) || (size == 4) || (size == 8) || ((size % 16) == 0), "size not a multiple of 16byte: "); \ - dUASSERT(size < 16384, "size too big: "); \ - dUASSERT( ((uintsize)ea%16)==((uintsize)ls%16), "wrong Quadword alignment of LS and EA: "); \ - dUASSERT(ea != 0, "Nullpointer EA: "); dUASSERT(ls != 0, "Nullpointer LS: ");\ - printf("GET %s:%d from: 0x%x, to: 0x%x - %d bytes\n", __FILE__, __LINE__, (unsigned int)ea,(unsigned int)ls,(unsigned int)size);\ - } \ - mfc_get(ls, ea, size, tag, tid, rid) -#define cellDmaLargePut(ls, ea, size, tag, tid, rid) if ( (((uintsize)ls%16) != ((uintsize)ea%16)) || ((((uintsize)ea%16) || ((uintsize)ls%16)) && (( ((uintsize)ls%16) != ((uintsize)size%16) ) || ( ((uintsize)ea%16) != ((uintsize)size%16) ) ) ) || ( ((uintsize)size%16) && ((uintsize)size!=1) && ((uintsize)size!=2) && ((uintsize)size!=4) && ((uintsize)size!=8) ) || (size >= 16384) || !(uintsize)ls || !(uintsize)ea) { \ - dUASSERT( (((uintsize)ea % 16) == 0) || (size < 16), "XDR Address not aligned: "); \ - dUASSERT( (((uintsize)ls % 16) == 0) || (size < 16), "LS Address not aligned: "); \ - dUASSERT( ((((uintsize)ls % size) == 0) && (((uintsize)ea % size) == 0)) || (size > 16), "Not naturally aligned: "); \ - dUASSERT((size == 1) || (size == 2) || (size == 4) || (size == 8) || ((size % 16) == 0), "size not a multiple of 16byte: "); \ - dUASSERT(size < 16384, "size too big: "); \ - dUASSERT( ((uintsize)ea%16)==((uintsize)ls%16), "wrong Quadword alignment of LS and EA: "); \ - dUASSERT(ea != 0, "Nullpointer EA: "); dUASSERT(ls != 0, "Nullpointer LS: ");\ - printf("PUT %s:%d from: 0x%x, to: 0x%x - %d bytes\n", __FILE__, __LINE__, (unsigned int)ls,(unsigned int)ea,(unsigned int)size); \ - } \ - mfc_put(ls, ea, size, tag, tid, rid) -#define cellDmaSmallGet(ls, ea, size, tag, tid, rid) if ( (((uintsize)ls%16) != ((uintsize)ea%16)) || ((((uintsize)ea%16) || ((uintsize)ls%16)) && (( ((uintsize)ls%16) != ((uintsize)size%16) ) || ( ((uintsize)ea%16) != ((uintsize)size%16) ) ) ) || ( ((uintsize)size%16) && ((uintsize)size!=1) && ((uintsize)size!=2) && ((uintsize)size!=4) && ((uintsize)size!=8) ) || (size >= 16384) || !(uintsize)ls || !(uintsize)ea) { \ - dUASSERT( (((uintsize)ea % 16) == 0) || (size < 16), "XDR Address not aligned: "); \ - dUASSERT( (((uintsize)ls % 16) == 0) || (size < 16), "LS Address not aligned: "); \ - dUASSERT( ((((uintsize)ls % size) == 0) && (((uintsize)ea % size) == 0)) || (size > 16), "Not naturally aligned: "); \ - dUASSERT((size == 1) || (size == 2) || (size == 4) || (size == 8) || ((size % 16) == 0), "size not a multiple of 16byte: "); \ - dUASSERT(size < 16384, "size too big: "); \ - dUASSERT( ((uintsize)ea%16)==((uintsize)ls%16), "wrong Quadword alignment of LS and EA: "); \ - dUASSERT(ea != 0, "Nullpointer EA: "); dUASSERT(ls != 0, "Nullpointer LS: ");\ - printf("GET %s:%d from: 0x%x, to: 0x%x - %d bytes\n", __FILE__, __LINE__, (unsigned int)ea,(unsigned int)ls,(unsigned int)size);\ - } \ - mfc_get(ls, ea, size, tag, tid, rid) -#define cellDmaWaitTagStatusAll(ignore) mfc_write_tag_mask(ignore) ; mfc_read_tag_status_all() - -#else -#define cellDmaLargeGet(ls, ea, size, tag, tid, rid) mfc_get(ls, ea, size, tag, tid, rid) -#define cellDmaGet(ls, ea, size, tag, tid, rid) mfc_get(ls, ea, size, tag, tid, rid) -#define cellDmaLargePut(ls, ea, size, tag, tid, rid) mfc_put(ls, ea, size, tag, tid, rid) -#define cellDmaSmallGet(ls, ea, size, tag, tid, rid) mfc_get(ls, ea, size, tag, tid, rid) -#define cellDmaWaitTagStatusAll(ignore) mfc_write_tag_mask(ignore) ; mfc_read_tag_status_all() -#endif // DEBUG_DMA - - - - - - - - -#endif // USE_LIBSPE2 -#else // !__SPU__ -//Simulate DMA using memcpy or direct access on non-CELL platforms that don't have DMAs and SPUs (Win32, Mac, Linux etc) -//Potential to add networked simulation using this interface - -#define DMA_TAG(a) (a) -#define DMA_MASK(a) (a) - - /// cellDmaLargeGet Win32 replacements for Cell DMA to allow simulating most of the SPU code (just memcpy) - int cellDmaLargeGet(void *ls, uint64_t ea, uint32_t size, uint32_t tag, uint32_t tid, uint32_t rid); - int cellDmaGet(void *ls, uint64_t ea, uint32_t size, uint32_t tag, uint32_t tid, uint32_t rid); - /// cellDmaLargePut Win32 replacements for Cell DMA to allow simulating most of the SPU code (just memcpy) - int cellDmaLargePut(const void *ls, uint64_t ea, uint32_t size, uint32_t tag, uint32_t tid, uint32_t rid); - /// cellDmaWaitTagStatusAll Win32 replacements for Cell DMA to allow simulating most of the SPU code (just memcpy) - void cellDmaWaitTagStatusAll(int ignore); - - -#endif //__CELLOS_LV2__ - -///stallingUnalignedDmaSmallGet internally uses DMA_TAG(1) -int stallingUnalignedDmaSmallGet(void *ls, uint64_t ea, uint32_t size); - - -void* cellDmaLargeGetReadOnly(void *ls, uint64_t ea, uint32_t size, uint32_t tag, uint32_t tid, uint32_t rid); -void* cellDmaGetReadOnly(void *ls, uint64_t ea, uint32_t size, uint32_t tag, uint32_t tid, uint32_t rid); -void* cellDmaSmallGetReadOnly(void *ls, uint64_t ea, uint32_t size, uint32_t tag, uint32_t tid, uint32_t rid); - - -#endif //FAKE_DMA_H diff --git a/bullet/src/BulletMultiThreaded/SpuGatheringCollisionDispatcher.cpp b/bullet/src/BulletMultiThreaded/SpuGatheringCollisionDispatcher.cpp deleted file mode 100644 index 4dfd2326c..000000000 --- a/bullet/src/BulletMultiThreaded/SpuGatheringCollisionDispatcher.cpp +++ /dev/null @@ -1,238 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2007 Erwin Coumans http://bulletphysics.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "SpuGatheringCollisionDispatcher.h" -#include "SpuCollisionTaskProcess.h" - - -#include "BulletCollision/BroadphaseCollision/btOverlappingPairCache.h" -#include "BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.h" -#include "SpuContactManifoldCollisionAlgorithm.h" -#include "BulletCollision/CollisionDispatch/btCollisionObject.h" -#include "BulletCollision/CollisionShapes/btCollisionShape.h" -#include "LinearMath/btQuickprof.h" - - - - -SpuGatheringCollisionDispatcher::SpuGatheringCollisionDispatcher(class btThreadSupportInterface* threadInterface, unsigned int maxNumOutstandingTasks,btCollisionConfiguration* collisionConfiguration) -:btCollisionDispatcher(collisionConfiguration), -m_spuCollisionTaskProcess(0), -m_threadInterface(threadInterface), -m_maxNumOutstandingTasks(maxNumOutstandingTasks) -{ - -} - - -bool SpuGatheringCollisionDispatcher::supportsDispatchPairOnSpu(int proxyType0,int proxyType1) -{ - bool supported0 = ( - (proxyType0 == BOX_SHAPE_PROXYTYPE) || - (proxyType0 == TRIANGLE_SHAPE_PROXYTYPE) || - (proxyType0 == SPHERE_SHAPE_PROXYTYPE) || - (proxyType0 == CAPSULE_SHAPE_PROXYTYPE) || - (proxyType0 == CYLINDER_SHAPE_PROXYTYPE) || -// (proxyType0 == CONE_SHAPE_PROXYTYPE) || - (proxyType0 == TRIANGLE_MESH_SHAPE_PROXYTYPE) || - (proxyType0 == CONVEX_HULL_SHAPE_PROXYTYPE)|| - (proxyType0 == COMPOUND_SHAPE_PROXYTYPE) - ); - - bool supported1 = ( - (proxyType1 == BOX_SHAPE_PROXYTYPE) || - (proxyType1 == TRIANGLE_SHAPE_PROXYTYPE) || - (proxyType1 == SPHERE_SHAPE_PROXYTYPE) || - (proxyType1 == CAPSULE_SHAPE_PROXYTYPE) || - (proxyType1 == CYLINDER_SHAPE_PROXYTYPE) || -// (proxyType1 == CONE_SHAPE_PROXYTYPE) || - (proxyType1 == TRIANGLE_MESH_SHAPE_PROXYTYPE) || - (proxyType1 == CONVEX_HULL_SHAPE_PROXYTYPE) || - (proxyType1 == COMPOUND_SHAPE_PROXYTYPE) - ); - - return supported0 && supported1; -} - - - -SpuGatheringCollisionDispatcher::~SpuGatheringCollisionDispatcher() -{ - if (m_spuCollisionTaskProcess) - delete m_spuCollisionTaskProcess; - -} - -#include "stdio.h" - - - -///interface for iterating all overlapping collision pairs, no matter how those pairs are stored (array, set, map etc) -///this is useful for the collision dispatcher. -class btSpuCollisionPairCallback : public btOverlapCallback -{ - const btDispatcherInfo& m_dispatchInfo; - SpuGatheringCollisionDispatcher* m_dispatcher; - -public: - - btSpuCollisionPairCallback(const btDispatcherInfo& dispatchInfo, SpuGatheringCollisionDispatcher* dispatcher) - :m_dispatchInfo(dispatchInfo), - m_dispatcher(dispatcher) - { - } - - virtual bool processOverlap(btBroadphasePair& collisionPair) - { - - - //PPU version - //(*m_dispatcher->getNearCallback())(collisionPair,*m_dispatcher,m_dispatchInfo); - - //only support discrete collision detection for now, we could fallback on PPU/unoptimized version for TOI/CCD - btAssert(m_dispatchInfo.m_dispatchFunc == btDispatcherInfo::DISPATCH_DISCRETE); - - //by default, Bullet will use this near callback - { - ///userInfo is used to determine if the SPU has to handle this case or not (skip PPU tasks) - if (!collisionPair.m_internalTmpValue) - { - collisionPair.m_internalTmpValue = 1; - } - if (!collisionPair.m_algorithm) - { - btCollisionObject* colObj0 = (btCollisionObject*)collisionPair.m_pProxy0->m_clientObject; - btCollisionObject* colObj1 = (btCollisionObject*)collisionPair.m_pProxy1->m_clientObject; - - btCollisionAlgorithmConstructionInfo ci; - ci.m_dispatcher1 = m_dispatcher; - ci.m_manifold = 0; - - if (m_dispatcher->needsCollision(colObj0,colObj1)) - { - int proxyType0 = colObj0->getCollisionShape()->getShapeType(); - int proxyType1 = colObj1->getCollisionShape()->getShapeType(); - if (m_dispatcher->supportsDispatchPairOnSpu(proxyType0,proxyType1)) - { - int so = sizeof(SpuContactManifoldCollisionAlgorithm); -#ifdef ALLOCATE_SEPARATELY - void* mem = btAlignedAlloc(so,16);//m_dispatcher->allocateCollisionAlgorithm(so); -#else - void* mem = m_dispatcher->allocateCollisionAlgorithm(so); -#endif - collisionPair.m_algorithm = new(mem) SpuContactManifoldCollisionAlgorithm(ci,colObj0,colObj1); - collisionPair.m_internalTmpValue = 2; - } else - { - collisionPair.m_algorithm = m_dispatcher->findAlgorithm(colObj0,colObj1); - collisionPair.m_internalTmpValue = 3; - } - } - } - } - return false; - } -}; - -void SpuGatheringCollisionDispatcher::dispatchAllCollisionPairs(btOverlappingPairCache* pairCache,const btDispatcherInfo& dispatchInfo, btDispatcher* dispatcher) -{ - - if (dispatchInfo.m_enableSPU) - { - m_maxNumOutstandingTasks = m_threadInterface->getNumTasks(); - - { - BT_PROFILE("processAllOverlappingPairs"); - - if (!m_spuCollisionTaskProcess) - m_spuCollisionTaskProcess = new SpuCollisionTaskProcess(m_threadInterface,m_maxNumOutstandingTasks); - - m_spuCollisionTaskProcess->setNumTasks(m_maxNumOutstandingTasks); - // printf("m_maxNumOutstandingTasks =%d\n",m_maxNumOutstandingTasks); - - m_spuCollisionTaskProcess->initialize2(dispatchInfo.m_useEpa); - - - ///modified version of btCollisionDispatcher::dispatchAllCollisionPairs: - { - btSpuCollisionPairCallback collisionCallback(dispatchInfo,this); - - pairCache->processAllOverlappingPairs(&collisionCallback,dispatcher); - } - } - - //send one big batch - int numTotalPairs = pairCache->getNumOverlappingPairs(); - btBroadphasePair* pairPtr = pairCache->getOverlappingPairArrayPtr(); - int i; - { - BT_PROFILE("addWorkToTask"); - for (i=0;iaddWorkToTask(pairPtr,i,endIndex); - i = endIndex; - } - } - - { - BT_PROFILE("PPU fallback"); - //handle PPU fallback pairs - for (i=0;im_clientObject; - btCollisionObject* colObj1 = (btCollisionObject*)collisionPair.m_pProxy1->m_clientObject; - - if (dispatcher->needsCollision(colObj0,colObj1)) - { - btManifoldResult contactPointResult(colObj0,colObj1); - - if (dispatchInfo.m_dispatchFunc == btDispatcherInfo::DISPATCH_DISCRETE) - { - //discrete collision detection query - collisionPair.m_algorithm->processCollision(colObj0,colObj1,dispatchInfo,&contactPointResult); - } else - { - //continuous collision detection query, time of impact (toi) - btScalar toi = collisionPair.m_algorithm->calculateTimeOfImpact(colObj0,colObj1,dispatchInfo,&contactPointResult); - if (dispatchInfo.m_timeOfImpact > toi) - dispatchInfo.m_timeOfImpact = toi; - - } - } - } - } - } - } - { - BT_PROFILE("flush2"); - //make sure all SPU work is done - m_spuCollisionTaskProcess->flush2(); - } - - } else - { - ///PPU fallback - ///!Need to make sure to clear all 'algorithms' when switching between SPU and PPU - btCollisionDispatcher::dispatchAllCollisionPairs(pairCache,dispatchInfo,dispatcher); - } -} diff --git a/bullet/src/BulletMultiThreaded/SpuGatheringCollisionDispatcher.h b/bullet/src/BulletMultiThreaded/SpuGatheringCollisionDispatcher.h deleted file mode 100644 index f99e00381..000000000 --- a/bullet/src/BulletMultiThreaded/SpuGatheringCollisionDispatcher.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2007 Erwin Coumans http://bulletphysics.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ -#ifndef SPU_GATHERING_COLLISION__DISPATCHER_H -#define SPU_GATHERING_COLLISION__DISPATCHER_H - -#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h" - - -///Tuning value to optimized SPU utilization -///Too small value means Task overhead is large compared to computation (too fine granularity) -///Too big value might render some SPUs are idle, while a few other SPUs are doing all work. -//#define SPU_BATCHSIZE_BROADPHASE_PAIRS 8 -//#define SPU_BATCHSIZE_BROADPHASE_PAIRS 16 -#define SPU_BATCHSIZE_BROADPHASE_PAIRS 64 -//#define SPU_BATCHSIZE_BROADPHASE_PAIRS 128 -//#define SPU_BATCHSIZE_BROADPHASE_PAIRS 256 -//#define SPU_BATCHSIZE_BROADPHASE_PAIRS 1024 - - - -class SpuCollisionTaskProcess; - -///SpuGatheringCollisionDispatcher can use SPU to gather and calculate collision detection -///Time of Impact, Closest Points and Penetration Depth. -class SpuGatheringCollisionDispatcher : public btCollisionDispatcher -{ - - SpuCollisionTaskProcess* m_spuCollisionTaskProcess; - -protected: - - class btThreadSupportInterface* m_threadInterface; - - unsigned int m_maxNumOutstandingTasks; - - -public: - - //can be used by SPU collision algorithms - SpuCollisionTaskProcess* getSpuCollisionTaskProcess() - { - return m_spuCollisionTaskProcess; - } - - SpuGatheringCollisionDispatcher (class btThreadSupportInterface* threadInterface, unsigned int maxNumOutstandingTasks,btCollisionConfiguration* collisionConfiguration); - - virtual ~SpuGatheringCollisionDispatcher(); - - bool supportsDispatchPairOnSpu(int proxyType0,int proxyType1); - - virtual void dispatchAllCollisionPairs(btOverlappingPairCache* pairCache,const btDispatcherInfo& dispatchInfo,btDispatcher* dispatcher) ; - -}; - - - -#endif //SPU_GATHERING_COLLISION__DISPATCHER_H diff --git a/bullet/src/BulletMultiThreaded/SpuLibspe2Support.cpp b/bullet/src/BulletMultiThreaded/SpuLibspe2Support.cpp deleted file mode 100644 index 37604b664..000000000 --- a/bullet/src/BulletMultiThreaded/SpuLibspe2Support.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2007 Erwin Coumans http://bulletphysics.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifdef USE_LIBSPE2 - -#include "SpuLibspe2Support.h" - - - - -//SpuLibspe2Support helps to initialize/shutdown libspe2, start/stop SPU tasks and communication -///Setup and initialize SPU/CELL/Libspe2 -SpuLibspe2Support::SpuLibspe2Support(spe_program_handle_t *speprog, int numThreads) -{ - this->program = speprog; - this->numThreads = ((numThreads <= spe_cpu_info_get(SPE_COUNT_PHYSICAL_SPES, -1)) ? numThreads : spe_cpu_info_get(SPE_COUNT_PHYSICAL_SPES, -1)); -} - -///cleanup/shutdown Libspe2 -SpuLibspe2Support::~SpuLibspe2Support() -{ - - stopSPU(); -} - - - -///send messages to SPUs -void SpuLibspe2Support::sendRequest(uint32_t uiCommand, uint32_t uiArgument0, uint32_t uiArgument1) -{ - spe_context_ptr_t context; - - switch (uiCommand) - { - case CMD_SAMPLE_TASK_COMMAND: - { - //get taskdescription - SpuSampleTaskDesc* taskDesc = (SpuSampleTaskDesc*) uiArgument0; - - btAssert(taskDesc->m_taskIdm_taskId]; - - //set data for spuStatus - spuStatus.m_commandId = uiCommand; - spuStatus.m_status = Spu_Status_Occupied; //set SPU as "occupied" - spuStatus.m_taskDesc.p = taskDesc; - - //get context - context = data[taskDesc->m_taskId].context; - - - taskDesc->m_mainMemoryPtr = reinterpret_cast (spuStatus.m_lsMemory.p); - - - break; - } - case CMD_GATHER_AND_PROCESS_PAIRLIST: - { - //get taskdescription - SpuGatherAndProcessPairsTaskDesc* taskDesc = (SpuGatherAndProcessPairsTaskDesc*) uiArgument0; - - btAssert(taskDesc->taskIdtaskId]; - - //set data for spuStatus - spuStatus.m_commandId = uiCommand; - spuStatus.m_status = Spu_Status_Occupied; //set SPU as "occupied" - spuStatus.m_taskDesc.p = taskDesc; - - //get context - context = data[taskDesc->taskId].context; - - - taskDesc->m_lsMemory = (CollisionTask_LocalStoreMemory*)spuStatus.m_lsMemory.p; - - break; - } - default: - { - ///not implemented - btAssert(0); - } - - }; - - - //write taskdescription in mailbox - unsigned int event = Spu_Mailbox_Event_Task; - spe_in_mbox_write(context, &event, 1, SPE_MBOX_ANY_NONBLOCKING); - -} - -///check for messages from SPUs -void SpuLibspe2Support::waitForResponse(unsigned int *puiArgument0, unsigned int *puiArgument1) -{ - ///We should wait for (one of) the first tasks to finish (or other SPU messages), and report its response - - ///A possible response can be 'yes, SPU handled it', or 'no, please do a PPU fallback' - - btAssert(m_activeSpuStatus.size()); - - - int last = -1; - - //find an active spu/thread - while(last < 0) - { - for (int i=0;i=0); - - - - *puiArgument0 = spuStatus.m_taskId; - *puiArgument1 = spuStatus.m_status; - - -} - - -void SpuLibspe2Support::startSPU() -{ - this->internal_startSPU(); -} - - - -///start the spus group (can be called at the beginning of each frame, to make sure that the right SPU program is loaded) -void SpuLibspe2Support::internal_startSPU() -{ - m_activeSpuStatus.resize(numThreads); - - - for (int i=0; i < numThreads; i++) - { - - if(data[i].context == NULL) - { - - /* Create context */ - if ((data[i].context = spe_context_create(0, NULL)) == NULL) - { - perror ("Failed creating context"); - exit(1); - } - - /* Load program into context */ - if(spe_program_load(data[i].context, this->program)) - { - perror ("Failed loading program"); - exit(1); - } - - m_activeSpuStatus[i].m_status = Spu_Status_Startup; - m_activeSpuStatus[i].m_taskId = i; - m_activeSpuStatus[i].m_commandId = 0; - m_activeSpuStatus[i].m_lsMemory.p = NULL; - - - data[i].entry = SPE_DEFAULT_ENTRY; - data[i].flags = 0; - data[i].argp.p = &m_activeSpuStatus[i]; - data[i].envp.p = NULL; - - /* Create thread for each SPE context */ - if (pthread_create(&data[i].pthread, NULL, &ppu_pthread_function, &(data[i]) )) - { - perror ("Failed creating thread"); - exit(1); - } - /* - else - { - printf("started thread %d\n",i); - }*/ - } - } - - - for (int i=0; i < numThreads; i++) - { - if(data[i].context != NULL) - { - while( m_activeSpuStatus[i].m_status == Spu_Status_Startup) - { - // wait for spu to set up - sched_yield(); - } - printf("Spu %d is ready\n", i); - } - } -} - -///tell the task scheduler we are done with the SPU tasks -void SpuLibspe2Support::stopSPU() -{ - // wait for all threads to finish - int i; - for ( i = 0; i < this->numThreads; i++ ) - { - - unsigned int event = Spu_Mailbox_Event_Shutdown; - spe_context_ptr_t context = data[i].context; - spe_in_mbox_write(context, &event, 1, SPE_MBOX_ALL_BLOCKING); - pthread_join (data[i].pthread, NULL); - - } - // close SPE program - spe_image_close(program); - // destroy SPE contexts - for ( i = 0; i < this->numThreads; i++ ) - { - if(data[i].context != NULL) - { - spe_context_destroy (data[i].context); - } - } - - m_activeSpuStatus.clear(); - -} - - - -#endif //USE_LIBSPE2 - diff --git a/bullet/src/BulletMultiThreaded/SpuLibspe2Support.h b/bullet/src/BulletMultiThreaded/SpuLibspe2Support.h deleted file mode 100644 index 3fb8f2b9a..000000000 --- a/bullet/src/BulletMultiThreaded/SpuLibspe2Support.h +++ /dev/null @@ -1,180 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2007 Erwin Coumans http://bulletphysics.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#ifndef SPU_LIBSPE2_SUPPORT_H -#define SPU_LIBSPE2_SUPPORT_H - -#include //for uint32_t etc. - -#ifdef USE_LIBSPE2 - -#include -#include -//#include "SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.h" -#include "PlatformDefinitions.h" - - -//extern struct SpuGatherAndProcessPairsTaskDesc; - -enum -{ - Spu_Mailbox_Event_Nothing = 0, - Spu_Mailbox_Event_Task = 1, - Spu_Mailbox_Event_Shutdown = 2, - - Spu_Mailbox_Event_ForceDword = 0xFFFFFFFF - -}; - -enum -{ - Spu_Status_Free = 0, - Spu_Status_Occupied = 1, - Spu_Status_Startup = 2, - - Spu_Status_ForceDword = 0xFFFFFFFF - -}; - - -struct btSpuStatus -{ - uint32_t m_taskId; - uint32_t m_commandId; - uint32_t m_status; - - addr64 m_taskDesc; - addr64 m_lsMemory; - -} -__attribute__ ((aligned (128))) -; - - - -#ifndef __SPU__ - -#include "LinearMath/btAlignedObjectArray.h" -#include "SpuCollisionTaskProcess.h" -#include "SpuSampleTaskProcess.h" -#include "btThreadSupportInterface.h" -#include -#include -#include - -#define MAX_SPUS 4 - -typedef struct ppu_pthread_data -{ - spe_context_ptr_t context; - pthread_t pthread; - unsigned int entry; - unsigned int flags; - addr64 argp; - addr64 envp; - spe_stop_info_t stopinfo; -} ppu_pthread_data_t; - - -static void *ppu_pthread_function(void *arg) -{ - ppu_pthread_data_t * datap = (ppu_pthread_data_t *)arg; - /* - int rc; - do - {*/ - spe_context_run(datap->context, &datap->entry, datap->flags, datap->argp.p, datap->envp.p, &datap->stopinfo); - if (datap->stopinfo.stop_reason == SPE_EXIT) - { - if (datap->stopinfo.result.spe_exit_code != 0) - { - perror("FAILED: SPE returned a non-zero exit status: \n"); - exit(1); - } - } - else - { - perror("FAILED: SPE abnormally terminated\n"); - exit(1); - } - - - //} while (rc > 0); // loop until exit or error, and while any stop & signal - pthread_exit(NULL); -} - - - - - - -///SpuLibspe2Support helps to initialize/shutdown libspe2, start/stop SPU tasks and communication -class SpuLibspe2Support : public btThreadSupportInterface -{ - - btAlignedObjectArray m_activeSpuStatus; - -public: - //Setup and initialize SPU/CELL/Libspe2 - SpuLibspe2Support(spe_program_handle_t *speprog,int numThreads); - - // SPE program handle ptr. - spe_program_handle_t *program; - - // SPE program data - ppu_pthread_data_t data[MAX_SPUS]; - - //cleanup/shutdown Libspe2 - ~SpuLibspe2Support(); - - ///send messages to SPUs - void sendRequest(uint32_t uiCommand, uint32_t uiArgument0, uint32_t uiArgument1=0); - - //check for messages from SPUs - void waitForResponse(unsigned int *puiArgument0, unsigned int *puiArgument1); - - //start the spus (can be called at the beginning of each frame, to make sure that the right SPU program is loaded) - virtual void startSPU(); - - //tell the task scheduler we are done with the SPU tasks - virtual void stopSPU(); - - virtual void setNumTasks(int numTasks) - { - //changing the number of tasks after initialization is not implemented (yet) - } - -private: - - ///start the spus (can be called at the beginning of each frame, to make sure that the right SPU program is loaded) - void internal_startSPU(); - - - - - int numThreads; - -}; - -#endif // NOT __SPU__ - -#endif //USE_LIBSPE2 - -#endif //SPU_LIBSPE2_SUPPORT_H - - - - diff --git a/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/Box.h b/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/Box.h deleted file mode 100644 index 18bb7df23..000000000 --- a/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/Box.h +++ /dev/null @@ -1,167 +0,0 @@ -/* - Copyright (C) 2006, 2008 Sony Computer Entertainment Inc. - All rights reserved. - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. - -*/ - -#ifndef __BOX_H__ -#define __BOX_H__ - - -#ifndef PE_REF -#define PE_REF(a) a& -#endif - -#include - -//#include "BulletMultiThreaded/vectormath/scalar/cpp/vectormath_aos.h" -#include - - -using namespace Vectormath::Aos; - -enum FeatureType { F, E, V }; - -//---------------------------------------------------------------------------- -// Box -//---------------------------------------------------------------------------- -///The Box is an internal class used by the boxBoxDistance calculation. -class Box -{ -public: - Vector3 half; - - inline Box() - {} - inline Box(PE_REF(Vector3) half_); - inline Box(float hx, float hy, float hz); - - inline void Set(PE_REF(Vector3) half_); - inline void Set(float hx, float hy, float hz); - - inline Vector3 GetAABB(const Matrix3& rotation) const; -}; - -inline -Box::Box(PE_REF(Vector3) half_) -{ - Set(half_); -} - -inline -Box::Box(float hx, float hy, float hz) -{ - Set(hx, hy, hz); -} - -inline -void -Box::Set(PE_REF(Vector3) half_) -{ - half = half_; -} - -inline -void -Box::Set(float hx, float hy, float hz) -{ - half = Vector3(hx, hy, hz); -} - -inline -Vector3 -Box::GetAABB(const Matrix3& rotation) const -{ - return absPerElem(rotation) * half; -} - -//------------------------------------------------------------------------------------------------- -// BoxPoint -//------------------------------------------------------------------------------------------------- - -///The BoxPoint class is an internally used class to contain feature information for boxBoxDistance calculation. -class BoxPoint -{ -public: - BoxPoint() : localPoint(0.0f) {} - - Point3 localPoint; - FeatureType featureType; - int featureIdx; - - inline void setVertexFeature(int plusX, int plusY, int plusZ); - inline void setEdgeFeature(int dim0, int plus0, int dim1, int plus1); - inline void setFaceFeature(int dim, int plus); - - inline void getVertexFeature(int & plusX, int & plusY, int & plusZ) const; - inline void getEdgeFeature(int & dim0, int & plus0, int & dim1, int & plus1) const; - inline void getFaceFeature(int & dim, int & plus) const; -}; - -inline -void -BoxPoint::setVertexFeature(int plusX, int plusY, int plusZ) -{ - featureType = V; - featureIdx = plusX << 2 | plusY << 1 | plusZ; -} - -inline -void -BoxPoint::setEdgeFeature(int dim0, int plus0, int dim1, int plus1) -{ - featureType = E; - - if (dim0 > dim1) { - featureIdx = plus1 << 5 | dim1 << 3 | plus0 << 2 | dim0; - } else { - featureIdx = plus0 << 5 | dim0 << 3 | plus1 << 2 | dim1; - } -} - -inline -void -BoxPoint::setFaceFeature(int dim, int plus) -{ - featureType = F; - featureIdx = plus << 2 | dim; -} - -inline -void -BoxPoint::getVertexFeature(int & plusX, int & plusY, int & plusZ) const -{ - plusX = featureIdx >> 2; - plusY = featureIdx >> 1 & 1; - plusZ = featureIdx & 1; -} - -inline -void -BoxPoint::getEdgeFeature(int & dim0, int & plus0, int & dim1, int & plus1) const -{ - plus0 = featureIdx >> 5; - dim0 = featureIdx >> 3 & 3; - plus1 = featureIdx >> 2 & 1; - dim1 = featureIdx & 3; -} - -inline -void -BoxPoint::getFaceFeature(int & dim, int & plus) const -{ - plus = featureIdx >> 2; - dim = featureIdx & 3; -} - -#endif /* __BOX_H__ */ diff --git a/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuCollisionShapes.cpp b/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuCollisionShapes.cpp deleted file mode 100644 index 96f7cb9e7..000000000 --- a/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuCollisionShapes.cpp +++ /dev/null @@ -1,295 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#include "SpuCollisionShapes.h" - -///not supported on IBM SDK, until we fix the alignment of btVector3 -#if defined (__CELLOS_LV2__) && defined (__SPU__) -#include -static inline vec_float4 vec_dot3( vec_float4 vec0, vec_float4 vec1 ) -{ - vec_float4 result; - result = spu_mul( vec0, vec1 ); - result = spu_madd( spu_rlqwbyte( vec0, 4 ), spu_rlqwbyte( vec1, 4 ), result ); - return spu_madd( spu_rlqwbyte( vec0, 8 ), spu_rlqwbyte( vec1, 8 ), result ); -} -#endif //__SPU__ - - -void computeAabb (btVector3& aabbMin, btVector3& aabbMax, btConvexInternalShape* convexShape, ppu_address_t convexShapePtr, int shapeType, const btTransform& xform) -{ - //calculate the aabb, given the types... - switch (shapeType) - { - case CYLINDER_SHAPE_PROXYTYPE: - /* fall through */ - case BOX_SHAPE_PROXYTYPE: - { - btScalar margin=convexShape->getMarginNV(); - btVector3 halfExtents = convexShape->getImplicitShapeDimensions(); - halfExtents += btVector3(margin,margin,margin); - const btTransform& t = xform; - btMatrix3x3 abs_b = t.getBasis().absolute(); - btVector3 center = t.getOrigin(); - btVector3 extent = btVector3(abs_b[0].dot(halfExtents),abs_b[1].dot(halfExtents),abs_b[2].dot(halfExtents)); - - aabbMin = center - extent; - aabbMax = center + extent; - break; - } - case CAPSULE_SHAPE_PROXYTYPE: - { - btScalar margin=convexShape->getMarginNV(); - btVector3 halfExtents = convexShape->getImplicitShapeDimensions(); - //add the radius to y-axis to get full height - btScalar radius = halfExtents[0]; - halfExtents[1] += radius; - halfExtents += btVector3(margin,margin,margin); -#if 0 - int capsuleUpAxis = convexShape->getUpAxis(); - btScalar halfHeight = convexShape->getHalfHeight(); - btScalar radius = convexShape->getRadius(); - halfExtents[capsuleUpAxis] = radius + halfHeight; -#endif - const btTransform& t = xform; - btMatrix3x3 abs_b = t.getBasis().absolute(); - btVector3 center = t.getOrigin(); - btVector3 extent = btVector3(abs_b[0].dot(halfExtents),abs_b[1].dot(halfExtents),abs_b[2].dot(halfExtents)); - - aabbMin = center - extent; - aabbMax = center + extent; - break; - } - case SPHERE_SHAPE_PROXYTYPE: - { - btScalar radius = convexShape->getImplicitShapeDimensions().getX();// * convexShape->getLocalScaling().getX(); - btScalar margin = radius + convexShape->getMarginNV(); - const btTransform& t = xform; - const btVector3& center = t.getOrigin(); - btVector3 extent(margin,margin,margin); - aabbMin = center - extent; - aabbMax = center + extent; - break; - } - case CONVEX_HULL_SHAPE_PROXYTYPE: - { - ATTRIBUTE_ALIGNED16(char convexHullShape0[sizeof(btConvexHullShape)]); - cellDmaGet(&convexHullShape0, convexShapePtr , sizeof(btConvexHullShape), DMA_TAG(1), 0, 0); - cellDmaWaitTagStatusAll(DMA_MASK(1)); - btConvexHullShape* localPtr = (btConvexHullShape*)&convexHullShape0; - const btTransform& t = xform; - btScalar margin = convexShape->getMarginNV(); - localPtr->getNonvirtualAabb(t,aabbMin,aabbMax,margin); - //spu_printf("SPU convex aabbMin=%f,%f,%f=\n",aabbMin.getX(),aabbMin.getY(),aabbMin.getZ()); - //spu_printf("SPU convex aabbMax=%f,%f,%f=\n",aabbMax.getX(),aabbMax.getY(),aabbMax.getZ()); - break; - } - default: - { - // spu_printf("SPU: unsupported shapetype %d in AABB calculation\n"); - } - }; -} - -void dmaBvhShapeData (bvhMeshShape_LocalStoreMemory* bvhMeshShape, btBvhTriangleMeshShape* triMeshShape) -{ - register int dmaSize; - register ppu_address_t dmaPpuAddress2; - - dmaSize = sizeof(btTriangleIndexVertexArray); - dmaPpuAddress2 = reinterpret_cast(triMeshShape->getMeshInterface()); - // spu_printf("trimeshShape->getMeshInterface() == %llx\n",dmaPpuAddress2); -#ifdef __SPU__ - cellDmaGet(&bvhMeshShape->gTriangleMeshInterfaceStorage, dmaPpuAddress2 , dmaSize, DMA_TAG(1), 0, 0); - bvhMeshShape->gTriangleMeshInterfacePtr = &bvhMeshShape->gTriangleMeshInterfaceStorage; -#else - bvhMeshShape->gTriangleMeshInterfacePtr = (btTriangleIndexVertexArray*)cellDmaGetReadOnly(&bvhMeshShape->gTriangleMeshInterfaceStorage, dmaPpuAddress2 , dmaSize, DMA_TAG(1), 0, 0); -#endif - - //cellDmaWaitTagStatusAll(DMA_MASK(1)); - - ///now DMA over the BVH - - dmaSize = sizeof(btOptimizedBvh); - dmaPpuAddress2 = reinterpret_cast(triMeshShape->getOptimizedBvh()); - //spu_printf("trimeshShape->getOptimizedBvh() == %llx\n",dmaPpuAddress2); - cellDmaGet(&bvhMeshShape->gOptimizedBvh, dmaPpuAddress2 , dmaSize, DMA_TAG(2), 0, 0); - //cellDmaWaitTagStatusAll(DMA_MASK(2)); - cellDmaWaitTagStatusAll(DMA_MASK(1) | DMA_MASK(2)); -} - -void dmaBvhIndexedMesh (btIndexedMesh* IndexMesh, IndexedMeshArray& indexArray, int index, uint32_t dmaTag) -{ - cellDmaGet(IndexMesh, (ppu_address_t)&indexArray[index] , sizeof(btIndexedMesh), DMA_TAG(dmaTag), 0, 0); - -} - -void dmaBvhSubTreeHeaders (btBvhSubtreeInfo* subTreeHeaders, ppu_address_t subTreePtr, int batchSize, uint32_t dmaTag) -{ - cellDmaGet(subTreeHeaders, subTreePtr, batchSize * sizeof(btBvhSubtreeInfo), DMA_TAG(dmaTag), 0, 0); -} - -void dmaBvhSubTreeNodes (btQuantizedBvhNode* nodes, const btBvhSubtreeInfo& subtree, QuantizedNodeArray& nodeArray, int dmaTag) -{ - cellDmaGet(nodes, reinterpret_cast(&nodeArray[subtree.m_rootNodeIndex]) , subtree.m_subtreeSize* sizeof(btQuantizedBvhNode), DMA_TAG(2), 0, 0); -} - -///getShapeTypeSize could easily be optimized, but it is not likely a bottleneck -int getShapeTypeSize(int shapeType) -{ - - - switch (shapeType) - { - case CYLINDER_SHAPE_PROXYTYPE: - { - int shapeSize = sizeof(btCylinderShape); - btAssert(shapeSize < MAX_SHAPE_SIZE); - return shapeSize; - } - case BOX_SHAPE_PROXYTYPE: - { - int shapeSize = sizeof(btBoxShape); - btAssert(shapeSize < MAX_SHAPE_SIZE); - return shapeSize; - } - case SPHERE_SHAPE_PROXYTYPE: - { - int shapeSize = sizeof(btSphereShape); - btAssert(shapeSize < MAX_SHAPE_SIZE); - return shapeSize; - } - case TRIANGLE_MESH_SHAPE_PROXYTYPE: - { - int shapeSize = sizeof(btBvhTriangleMeshShape); - btAssert(shapeSize < MAX_SHAPE_SIZE); - return shapeSize; - } - case CAPSULE_SHAPE_PROXYTYPE: - { - int shapeSize = sizeof(btCapsuleShape); - btAssert(shapeSize < MAX_SHAPE_SIZE); - return shapeSize; - } - - case CONVEX_HULL_SHAPE_PROXYTYPE: - { - int shapeSize = sizeof(btConvexHullShape); - btAssert(shapeSize < MAX_SHAPE_SIZE); - return shapeSize; - } - - case COMPOUND_SHAPE_PROXYTYPE: - { - int shapeSize = sizeof(btCompoundShape); - btAssert(shapeSize < MAX_SHAPE_SIZE); - return shapeSize; - } - - default: - btAssert(0); - //unsupported shapetype, please add here - return 0; - } -} - -void dmaConvexVertexData (SpuConvexPolyhedronVertexData* convexVertexData, btConvexHullShape* convexShapeSPU) -{ - convexVertexData->gNumConvexPoints = convexShapeSPU->getNumPoints(); - if (convexVertexData->gNumConvexPoints>MAX_NUM_SPU_CONVEX_POINTS) - { - btAssert(0); - // spu_printf("SPU: Error: MAX_NUM_SPU_CONVEX_POINTS(%d) exceeded: %d\n",MAX_NUM_SPU_CONVEX_POINTS,convexVertexData->gNumConvexPoints); - return; - } - - register int dmaSize = convexVertexData->gNumConvexPoints*sizeof(btVector3); - ppu_address_t pointsPPU = (ppu_address_t) convexShapeSPU->getUnscaledPoints(); - cellDmaGet(&convexVertexData->g_convexPointBuffer[0], pointsPPU , dmaSize, DMA_TAG(2), 0, 0); -} - -void dmaCollisionShape (void* collisionShapeLocation, ppu_address_t collisionShapePtr, uint32_t dmaTag, int shapeType) -{ - register int dmaSize = getShapeTypeSize(shapeType); - cellDmaGet(collisionShapeLocation, collisionShapePtr , dmaSize, DMA_TAG(dmaTag), 0, 0); - //cellDmaWaitTagStatusAll(DMA_MASK(dmaTag)); -} - -void dmaCompoundShapeInfo (CompoundShape_LocalStoreMemory* compoundShapeLocation, btCompoundShape* spuCompoundShape, uint32_t dmaTag) -{ - register int dmaSize; - register ppu_address_t dmaPpuAddress2; - int childShapeCount = spuCompoundShape->getNumChildShapes(); - dmaSize = childShapeCount * sizeof(btCompoundShapeChild); - dmaPpuAddress2 = (ppu_address_t)spuCompoundShape->getChildList(); - cellDmaGet(&compoundShapeLocation->gSubshapes[0], dmaPpuAddress2, dmaSize, DMA_TAG(dmaTag), 0, 0); -} - -void dmaCompoundSubShapes (CompoundShape_LocalStoreMemory* compoundShapeLocation, btCompoundShape* spuCompoundShape, uint32_t dmaTag) -{ - int childShapeCount = spuCompoundShape->getNumChildShapes(); - int i; - // DMA all the subshapes - for ( i = 0; i < childShapeCount; ++i) - { - btCompoundShapeChild& childShape = compoundShapeLocation->gSubshapes[i]; - dmaCollisionShape (&compoundShapeLocation->gSubshapeShape[i],(ppu_address_t)childShape.m_childShape, dmaTag, childShape.m_childShapeType); - } -} - - -void spuWalkStacklessQuantizedTree(btNodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax,const btQuantizedBvhNode* rootNode,int startNodeIndex,int endNodeIndex) -{ - - int curIndex = startNodeIndex; - int walkIterations = 0; -#ifdef BT_DEBUG - int subTreeSize = endNodeIndex - startNodeIndex; -#endif - - int escapeIndex; - - unsigned int aabbOverlap, isLeafNode; - - while (curIndex < endNodeIndex) - { - //catch bugs in tree data - btAssert (walkIterations < subTreeSize); - - walkIterations++; - aabbOverlap = spuTestQuantizedAabbAgainstQuantizedAabb(quantizedQueryAabbMin,quantizedQueryAabbMax,rootNode->m_quantizedAabbMin,rootNode->m_quantizedAabbMax); - isLeafNode = rootNode->isLeafNode(); - - if (isLeafNode && aabbOverlap) - { - //printf("overlap with node %d\n",rootNode->getTriangleIndex()); - nodeCallback->processNode(0,rootNode->getTriangleIndex()); - // spu_printf("SPU: overlap detected with triangleIndex:%d\n",rootNode->getTriangleIndex()); - } - - if (aabbOverlap || isLeafNode) - { - rootNode++; - curIndex++; - } else - { - escapeIndex = rootNode->getEscapeIndex(); - rootNode += escapeIndex; - curIndex += escapeIndex; - } - } - -} diff --git a/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuCollisionShapes.h b/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuCollisionShapes.h deleted file mode 100644 index 8d9179ba2..000000000 --- a/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuCollisionShapes.h +++ /dev/null @@ -1,125 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ -#ifndef __SPU_COLLISION_SHAPES_H -#define __SPU_COLLISION_SHAPES_H - -#include "../SpuDoubleBuffer.h" - -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" -#include "BulletCollision/CollisionShapes/btConvexInternalShape.h" -#include "BulletCollision/CollisionShapes/btCylinderShape.h" - -#include "BulletCollision/CollisionShapes/btOptimizedBvh.h" -#include "BulletCollision/CollisionShapes/btTriangleIndexVertexArray.h" -#include "BulletCollision/CollisionShapes/btSphereShape.h" - -#include "BulletCollision/CollisionShapes/btCapsuleShape.h" - -#include "BulletCollision/CollisionShapes/btConvexShape.h" -#include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h" -#include "BulletCollision/CollisionShapes/btConvexHullShape.h" -#include "BulletCollision/CollisionShapes/btCompoundShape.h" - -#define MAX_NUM_SPU_CONVEX_POINTS 128 - -ATTRIBUTE_ALIGNED16(struct) SpuConvexPolyhedronVertexData -{ - void* gSpuConvexShapePtr; - btVector3* gConvexPoints; - int gNumConvexPoints; - int unused; - ATTRIBUTE_ALIGNED16(btVector3 g_convexPointBuffer[MAX_NUM_SPU_CONVEX_POINTS]); -}; - -#define MAX_SHAPE_SIZE 256 - -ATTRIBUTE_ALIGNED16(struct) CollisionShape_LocalStoreMemory -{ - ATTRIBUTE_ALIGNED16(char collisionShape[MAX_SHAPE_SIZE]); -}; - -ATTRIBUTE_ALIGNED16(struct) CompoundShape_LocalStoreMemory -{ - // Compound data -#define MAX_SPU_COMPOUND_SUBSHAPES 16 - ATTRIBUTE_ALIGNED16(btCompoundShapeChild gSubshapes[MAX_SPU_COMPOUND_SUBSHAPES]); - ATTRIBUTE_ALIGNED16(char gSubshapeShape[MAX_SPU_COMPOUND_SUBSHAPES][MAX_SHAPE_SIZE]); -}; - -ATTRIBUTE_ALIGNED16(struct) bvhMeshShape_LocalStoreMemory -{ - //ATTRIBUTE_ALIGNED16(btOptimizedBvh gOptimizedBvh); - ATTRIBUTE_ALIGNED16(char gOptimizedBvh[sizeof(btOptimizedBvh)+16]); - btOptimizedBvh* getOptimizedBvh() - { - return (btOptimizedBvh*) gOptimizedBvh; - } - - ATTRIBUTE_ALIGNED16(btTriangleIndexVertexArray gTriangleMeshInterfaceStorage); - btTriangleIndexVertexArray* gTriangleMeshInterfacePtr; - ///only a single mesh part for now, we can add support for multiple parts, but quantized trees don't support this at the moment - ATTRIBUTE_ALIGNED16(btIndexedMesh gIndexMesh); - #define MAX_SPU_SUBTREE_HEADERS 32 - //1024 - ATTRIBUTE_ALIGNED16(btBvhSubtreeInfo gSubtreeHeaders[MAX_SPU_SUBTREE_HEADERS]); - ATTRIBUTE_ALIGNED16(btQuantizedBvhNode gSubtreeNodes[MAX_SUBTREE_SIZE_IN_BYTES/sizeof(btQuantizedBvhNode)]); -}; - - -void computeAabb (btVector3& aabbMin, btVector3& aabbMax, btConvexInternalShape* convexShape, ppu_address_t convexShapePtr, int shapeType, const btTransform& xform); -void dmaBvhShapeData (bvhMeshShape_LocalStoreMemory* bvhMeshShape, btBvhTriangleMeshShape* triMeshShape); -void dmaBvhIndexedMesh (btIndexedMesh* IndexMesh, IndexedMeshArray& indexArray, int index, uint32_t dmaTag); -void dmaBvhSubTreeHeaders (btBvhSubtreeInfo* subTreeHeaders, ppu_address_t subTreePtr, int batchSize, uint32_t dmaTag); -void dmaBvhSubTreeNodes (btQuantizedBvhNode* nodes, const btBvhSubtreeInfo& subtree, QuantizedNodeArray& nodeArray, int dmaTag); - -int getShapeTypeSize(int shapeType); -void dmaConvexVertexData (SpuConvexPolyhedronVertexData* convexVertexData, btConvexHullShape* convexShapeSPU); -void dmaCollisionShape (void* collisionShapeLocation, ppu_address_t collisionShapePtr, uint32_t dmaTag, int shapeType); -void dmaCompoundShapeInfo (CompoundShape_LocalStoreMemory* compoundShapeLocation, btCompoundShape* spuCompoundShape, uint32_t dmaTag); -void dmaCompoundSubShapes (CompoundShape_LocalStoreMemory* compoundShapeLocation, btCompoundShape* spuCompoundShape, uint32_t dmaTag); - - -#define USE_BRANCHFREE_TEST 1 -#ifdef USE_BRANCHFREE_TEST -SIMD_FORCE_INLINE unsigned int spuTestQuantizedAabbAgainstQuantizedAabb(unsigned short int* aabbMin1,unsigned short int* aabbMax1,const unsigned short int* aabbMin2,const unsigned short int* aabbMax2) -{ -#if defined(__CELLOS_LV2__) && defined (__SPU__) - vec_ushort8 vecMin = {aabbMin1[0],aabbMin2[0],aabbMin1[2],aabbMin2[2],aabbMin1[1],aabbMin2[1],0,0}; - vec_ushort8 vecMax = {aabbMax2[0],aabbMax1[0],aabbMax2[2],aabbMax1[2],aabbMax2[1],aabbMax1[1],0,0}; - vec_ushort8 isGt = spu_cmpgt(vecMin,vecMax); - return spu_extract(spu_gather(isGt),0)==0; - -#else - return btSelect((unsigned)((aabbMin1[0] <= aabbMax2[0]) & (aabbMax1[0] >= aabbMin2[0]) - & (aabbMin1[2] <= aabbMax2[2]) & (aabbMax1[2] >= aabbMin2[2]) - & (aabbMin1[1] <= aabbMax2[1]) & (aabbMax1[1] >= aabbMin2[1])), - 1, 0); -#endif -} -#else - -SIMD_FORCE_INLINE unsigned int spuTestQuantizedAabbAgainstQuantizedAabb(const unsigned short int* aabbMin1,const unsigned short int* aabbMax1,const unsigned short int* aabbMin2,const unsigned short int* aabbMax2) -{ - unsigned int overlap = 1; - overlap = (aabbMin1[0] > aabbMax2[0] || aabbMax1[0] < aabbMin2[0]) ? 0 : overlap; - overlap = (aabbMin1[2] > aabbMax2[2] || aabbMax1[2] < aabbMin2[2]) ? 0 : overlap; - overlap = (aabbMin1[1] > aabbMax2[1] || aabbMax1[1] < aabbMin2[1]) ? 0 : overlap; - return overlap; -} -#endif - -void spuWalkStacklessQuantizedTree(btNodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax,const btQuantizedBvhNode* rootNode,int startNodeIndex,int endNodeIndex); - -#endif diff --git a/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuContactResult.cpp b/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuContactResult.cpp deleted file mode 100644 index 7346951dc..000000000 --- a/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuContactResult.cpp +++ /dev/null @@ -1,236 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "SpuContactResult.h" - -//#define DEBUG_SPU_COLLISION_DETECTION 1 - - -SpuContactResult::SpuContactResult() -{ - m_manifoldAddress = 0; - m_spuManifold = NULL; - m_RequiresWriteBack = false; -} - - SpuContactResult::~SpuContactResult() -{ - g_manifoldDmaExport.swapBuffers(); -} - - ///User can override this material combiner by implementing gContactAddedCallback and setting body0->m_collisionFlags |= btCollisionObject::customMaterialCallback; -inline btScalar calculateCombinedFriction(btScalar friction0,btScalar friction1) -{ - btScalar friction = friction0*friction1; - - const btScalar MAX_FRICTION = btScalar(10.); - - if (friction < -MAX_FRICTION) - friction = -MAX_FRICTION; - if (friction > MAX_FRICTION) - friction = MAX_FRICTION; - return friction; - -} - -inline btScalar calculateCombinedRestitution(btScalar restitution0,btScalar restitution1) -{ - return restitution0*restitution1; -} - - - - void SpuContactResult::setContactInfo(btPersistentManifold* spuManifold, ppu_address_t manifoldAddress,const btTransform& worldTrans0,const btTransform& worldTrans1, btScalar restitution0,btScalar restitution1, btScalar friction0,btScalar friction1, bool isSwapped) - { - //spu_printf("SpuContactResult::setContactInfo ManifoldAddress: %lu\n", manifoldAddress); - m_rootWorldTransform0 = worldTrans0; - m_rootWorldTransform1 = worldTrans1; - m_manifoldAddress = manifoldAddress; - m_spuManifold = spuManifold; - - m_combinedFriction = calculateCombinedFriction(friction0,friction1); - m_combinedRestitution = calculateCombinedRestitution(restitution0,restitution1); - m_isSwapped = isSwapped; - } - - void SpuContactResult::setShapeIdentifiersA(int partId0,int index0) - { - - } - - void SpuContactResult::setShapeIdentifiersB(int partId1,int index1) - { - - } - - - - ///return true if it requires a dma transfer back -bool ManifoldResultAddContactPoint(const btVector3& normalOnBInWorld, - const btVector3& pointInWorld, - float depth, - btPersistentManifold* manifoldPtr, - btTransform& transA, - btTransform& transB, - btScalar combinedFriction, - btScalar combinedRestitution, - bool isSwapped) -{ - -// float contactTreshold = manifoldPtr->getContactBreakingThreshold(); - - //spu_printf("SPU: add contactpoint, depth:%f, contactTreshold %f, manifoldPtr %llx\n",depth,contactTreshold,manifoldPtr); - -#ifdef DEBUG_SPU_COLLISION_DETECTION - spu_printf("SPU: contactTreshold %f\n",contactTreshold); -#endif //DEBUG_SPU_COLLISION_DETECTION - if (depth > manifoldPtr->getContactBreakingThreshold()) - return false; - - //provide inverses or just calculate? - btTransform transAInv = transA.inverse();//m_body0->m_cachedInvertedWorldTransform; - btTransform transBInv= transB.inverse();//m_body1->m_cachedInvertedWorldTransform; - - btVector3 pointA; - btVector3 localA; - btVector3 localB; - btVector3 normal; - - if (isSwapped) - { - normal = normalOnBInWorld * -1; - pointA = pointInWorld + normal * depth; - localA = transAInv(pointA ); - localB = transBInv(pointInWorld); - /*localA = transBInv(pointA ); - localB = transAInv(pointInWorld);*/ - } - else - { - normal = normalOnBInWorld; - pointA = pointInWorld + normal * depth; - localA = transAInv(pointA ); - localB = transBInv(pointInWorld); - } - - btManifoldPoint newPt(localA,localB,normal,depth); - - int insertIndex = manifoldPtr->getCacheEntry(newPt); - if (insertIndex >= 0) - { -// manifoldPtr->replaceContactPoint(newPt,insertIndex); -// return true; - -#ifdef DEBUG_SPU_COLLISION_DETECTION - spu_printf("SPU: same contact detected, nothing done\n"); -#endif //DEBUG_SPU_COLLISION_DETECTION - // This is not needed, just use the old info! saves a DMA transfer as well - } else - { - - newPt.m_combinedFriction = combinedFriction; - newPt.m_combinedRestitution = combinedRestitution; - - /* - ///@todo: SPU callbacks, either immediate (local on the SPU), or deferred - //User can override friction and/or restitution - if (gContactAddedCallback && - //and if either of the two bodies requires custom material - ((m_body0->m_collisionFlags & btCollisionObject::customMaterialCallback) || - (m_body1->m_collisionFlags & btCollisionObject::customMaterialCallback))) - { - //experimental feature info, for per-triangle material etc. - (*gContactAddedCallback)(newPt,m_body0,m_partId0,m_index0,m_body1,m_partId1,m_index1); - } - */ - manifoldPtr->addManifoldPoint(newPt); - return true; - - } - return false; - -} - - -void SpuContactResult::writeDoubleBufferedManifold(btPersistentManifold* lsManifold, btPersistentManifold* mmManifold) -{ - ///only write back the contact information on SPU. Other platforms avoid copying, and use the data in-place - ///see SpuFakeDma.cpp 'cellDmaLargeGetReadOnly' -#if defined (__SPU__) || defined (USE_LIBSPE2) - memcpy(g_manifoldDmaExport.getFront(),lsManifold,sizeof(btPersistentManifold)); - - g_manifoldDmaExport.swapBuffers(); - ppu_address_t mmAddr = (ppu_address_t)mmManifold; - g_manifoldDmaExport.backBufferDmaPut(mmAddr, sizeof(btPersistentManifold), DMA_TAG(9)); - // Should there be any kind of wait here? What if somebody tries to use this tag again? What if we call this function again really soon? - //no, the swapBuffers does the wait -#endif -} - -void SpuContactResult::addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth) -{ - //spu_printf("*** SpuContactResult::addContactPoint: depth = %f\n",depth); - -#ifdef DEBUG_SPU_COLLISION_DETECTION - // int sman = sizeof(rage::phManifold); -// spu_printf("sizeof_manifold = %i\n",sman); -#endif //DEBUG_SPU_COLLISION_DETECTION - - btPersistentManifold* localManifold = m_spuManifold; - - btVector3 normalB(normalOnBInWorld.getX(),normalOnBInWorld.getY(),normalOnBInWorld.getZ()); - btVector3 pointWrld(pointInWorld.getX(),pointInWorld.getY(),pointInWorld.getZ()); - - //process the contact point - const bool retVal = ManifoldResultAddContactPoint(normalB, - pointWrld, - depth, - localManifold, - m_rootWorldTransform0, - m_rootWorldTransform1, - m_combinedFriction, - m_combinedRestitution, - m_isSwapped); - m_RequiresWriteBack = m_RequiresWriteBack || retVal; -} - -void SpuContactResult::flush() -{ - - if (m_spuManifold && m_spuManifold->getNumContacts()) - { - m_spuManifold->refreshContactPoints(m_rootWorldTransform0,m_rootWorldTransform1); - m_RequiresWriteBack = true; - } - - - if (m_RequiresWriteBack) - { -#ifdef DEBUG_SPU_COLLISION_DETECTION - spu_printf("SPU: Start SpuContactResult::flush (Put) DMA\n"); - spu_printf("Num contacts:%d\n", m_spuManifold->getNumContacts()); - spu_printf("Manifold address: %llu\n", m_manifoldAddress); -#endif //DEBUG_SPU_COLLISION_DETECTION - // spu_printf("writeDoubleBufferedManifold\n"); - writeDoubleBufferedManifold(m_spuManifold, (btPersistentManifold*)m_manifoldAddress); -#ifdef DEBUG_SPU_COLLISION_DETECTION - spu_printf("SPU: Finished (Put) DMA\n"); -#endif //DEBUG_SPU_COLLISION_DETECTION - } - m_spuManifold = NULL; - m_RequiresWriteBack = false; -} - - diff --git a/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuContactResult.h b/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuContactResult.h deleted file mode 100644 index 8df161cfe..000000000 --- a/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuContactResult.h +++ /dev/null @@ -1,106 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef SPU_CONTACT_RESULT2_H -#define SPU_CONTACT_RESULT2_H - - -#ifndef WIN32 -#include -#endif - - - -#include "../SpuDoubleBuffer.h" - - -#include "LinearMath/btTransform.h" - - -#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h" -#include "BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h" - -class btCollisionShape; - - -struct SpuCollisionPairInput -{ - ppu_address_t m_collisionShapes[2]; - btCollisionShape* m_spuCollisionShapes[2]; - - ppu_address_t m_persistentManifoldPtr; - btVector3 m_primitiveDimensions0; - btVector3 m_primitiveDimensions1; - int m_shapeType0; - int m_shapeType1; - float m_collisionMargin0; - float m_collisionMargin1; - - btTransform m_worldTransform0; - btTransform m_worldTransform1; - - bool m_isSwapped; - bool m_useEpa; -}; - - -struct SpuClosestPointInput : public btDiscreteCollisionDetectorInterface::ClosestPointInput -{ - struct SpuConvexPolyhedronVertexData* m_convexVertexData[2]; -}; - -///SpuContactResult exports the contact points using double-buffered DMA transfers, only when needed -///So when an existing contact point is duplicated, no transfer/refresh is performed. -class SpuContactResult : public btDiscreteCollisionDetectorInterface::Result -{ - btTransform m_rootWorldTransform0; - btTransform m_rootWorldTransform1; - ppu_address_t m_manifoldAddress; - - btPersistentManifold* m_spuManifold; - bool m_RequiresWriteBack; - btScalar m_combinedFriction; - btScalar m_combinedRestitution; - - bool m_isSwapped; - - DoubleBuffer g_manifoldDmaExport; - - public: - SpuContactResult(); - virtual ~SpuContactResult(); - - btPersistentManifold* GetSpuManifold() const - { - return m_spuManifold; - } - - virtual void setShapeIdentifiersA(int partId0,int index0); - virtual void setShapeIdentifiersB(int partId1,int index1); - - void setContactInfo(btPersistentManifold* spuManifold, ppu_address_t manifoldAddress,const btTransform& worldTrans0,const btTransform& worldTrans1, btScalar restitution0,btScalar restitution1, btScalar friction0,btScalar friction01, bool isSwapped); - - - void writeDoubleBufferedManifold(btPersistentManifold* lsManifold, btPersistentManifold* mmManifold); - - virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth); - - void flush(); -}; - - - -#endif //SPU_CONTACT_RESULT2_H - diff --git a/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuConvexPenetrationDepthSolver.h b/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuConvexPenetrationDepthSolver.h deleted file mode 100644 index 4930ced35..000000000 --- a/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuConvexPenetrationDepthSolver.h +++ /dev/null @@ -1,51 +0,0 @@ - -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#ifndef SPU_CONVEX_PENETRATION_DEPTH_H -#define SPU_CONVEX_PENETRATION_DEPTH_H - - - -class btStackAlloc; -class btIDebugDraw; -#include "BulletCollision/NarrowphaseCollision/btConvexPenetrationDepthSolver.h" - -#include - - -///ConvexPenetrationDepthSolver provides an interface for penetration depth calculation. -class SpuConvexPenetrationDepthSolver : public btConvexPenetrationDepthSolver -{ -public: - - virtual ~SpuConvexPenetrationDepthSolver() {}; - virtual bool calcPenDepth( SpuVoronoiSimplexSolver& simplexSolver, - void* convexA,void* convexB,int shapeTypeA, int shapeTypeB, float marginA, float marginB, - btTransform& transA,const btTransform& transB, - btVector3& v, btVector3& pa, btVector3& pb, - class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc, - struct SpuConvexPolyhedronVertexData* convexVertexDataA, - struct SpuConvexPolyhedronVertexData* convexVertexDataB - ) const = 0; - - -}; - - - -#endif //SPU_CONVEX_PENETRATION_DEPTH_H - diff --git a/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.cpp b/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.cpp deleted file mode 100644 index 1474e160c..000000000 --- a/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.cpp +++ /dev/null @@ -1,1211 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "SpuGatheringCollisionTask.h" - -//#define DEBUG_SPU_COLLISION_DETECTION 1 -#include "../SpuDoubleBuffer.h" - -#include "../SpuCollisionTaskProcess.h" -#include "../SpuGatheringCollisionDispatcher.h" //for SPU_BATCHSIZE_BROADPHASE_PAIRS - -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" -#include "../SpuContactManifoldCollisionAlgorithm.h" -#include "BulletCollision/CollisionDispatch/btCollisionObject.h" -#include "SpuContactResult.h" -#include "BulletCollision/CollisionShapes/btOptimizedBvh.h" -#include "BulletCollision/CollisionShapes/btTriangleIndexVertexArray.h" -#include "BulletCollision/CollisionShapes/btSphereShape.h" -#include "BulletCollision/CollisionShapes/btConvexPointCloudShape.h" - -#include "BulletCollision/CollisionShapes/btCapsuleShape.h" - -#include "BulletCollision/CollisionShapes/btConvexShape.h" -#include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h" -#include "BulletCollision/CollisionShapes/btConvexHullShape.h" -#include "BulletCollision/CollisionShapes/btCompoundShape.h" - -#include "SpuMinkowskiPenetrationDepthSolver.h" -//#include "SpuEpaPenetrationDepthSolver.h" -#include "BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h" - - -#include "boxBoxDistance.h" -#include "BulletMultiThreaded/vectormath2bullet.h" -#include "SpuCollisionShapes.h" //definition of SpuConvexPolyhedronVertexData -#include "BulletCollision/CollisionDispatch/btBoxBoxDetector.h" -#include "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h" -#include "BulletCollision/CollisionShapes/btTriangleShape.h" - -#ifdef __SPU__ -///Software caching from the IBM Cell SDK, it reduces 25% SPU time for our test cases -#ifndef USE_LIBSPE2 -#define USE_SOFTWARE_CACHE 1 -#endif -#endif //__SPU__ - -int gSkippedCol = 0; -int gProcessedCol = 0; - -//////////////////////////////////////////////// -/// software caching -#if USE_SOFTWARE_CACHE -#include -#include -#include -#include -#define SPE_CACHE_NWAY 4 -//#define SPE_CACHE_NSETS 32, 16 -#define SPE_CACHE_NSETS 8 -//#define SPE_CACHELINE_SIZE 512 -#define SPE_CACHELINE_SIZE 128 -#define SPE_CACHE_SET_TAGID(set) 15 -///make sure that spe_cache.h is below those defines! -#include "../Extras/software_cache/cache/include/spe_cache.h" - - -int g_CacheMisses=0; -int g_CacheHits=0; - -#if 0 // Added to allow cache misses and hits to be tracked, change this to 1 to restore unmodified version -#define spe_cache_read(ea) _spe_cache_lookup_xfer_wait_(ea, 0, 1) -#else -#define spe_cache_read(ea) \ -({ \ - int set, idx, line, byte; \ - _spe_cache_nway_lookup_(ea, set, idx); \ - \ - if (btUnlikely(idx < 0)) { \ - ++g_CacheMisses; \ - idx = _spe_cache_miss_(ea, set, -1); \ - spu_writech(22, SPE_CACHE_SET_TAGMASK(set)); \ - spu_mfcstat(MFC_TAG_UPDATE_ALL); \ - } \ - else \ - { \ - ++g_CacheHits; \ - } \ - line = _spe_cacheline_num_(set, idx); \ - byte = _spe_cacheline_byte_offset_(ea); \ - (void *) &spe_cache_mem[line + byte]; \ -}) - -#endif - -#endif // USE_SOFTWARE_CACHE - -bool gUseEpa = false; - -#ifdef USE_SN_TUNER -#include -#endif //USE_SN_TUNER - -#if defined (__SPU__) && !defined (USE_LIBSPE2) -#include -#elif defined (USE_LIBSPE2) -#define spu_printf(a) -#else -#define IGNORE_ALIGNMENT 1 -#include -#include -#define spu_printf printf - -#endif - -//int gNumConvexPoints0=0; - -///Make sure no destructors are called on this memory -struct CollisionTask_LocalStoreMemory -{ - ///This CollisionTask_LocalStoreMemory is mainly used for the SPU version, using explicit DMA - ///Other platforms can use other memory programming models. - - ATTRIBUTE_ALIGNED16(btBroadphasePair gBroadphasePairsBuffer[SPU_BATCHSIZE_BROADPHASE_PAIRS]); - DoubleBuffer g_workUnitTaskBuffers; - ATTRIBUTE_ALIGNED16(char gSpuContactManifoldAlgoBuffer [sizeof(SpuContactManifoldCollisionAlgorithm)+16]); - ATTRIBUTE_ALIGNED16(char gColObj0Buffer [sizeof(btCollisionObject)+16]); - ATTRIBUTE_ALIGNED16(char gColObj1Buffer [sizeof(btCollisionObject)+16]); - ///we reserve 32bit integer indices, even though they might be 16bit - ATTRIBUTE_ALIGNED16(int spuIndices[16]); - btPersistentManifold gPersistentManifoldBuffer; - CollisionShape_LocalStoreMemory gCollisionShapes[2]; - bvhMeshShape_LocalStoreMemory bvhShapeData; - SpuConvexPolyhedronVertexData convexVertexData[2]; - CompoundShape_LocalStoreMemory compoundShapeData[2]; - - ///The following pointers might either point into this local store memory, or to the original/other memory locations. - ///See SpuFakeDma for implementation of cellDmaSmallGetReadOnly. - btCollisionObject* m_lsColObj0Ptr; - btCollisionObject* m_lsColObj1Ptr; - btBroadphasePair* m_pairsPointer; - btPersistentManifold* m_lsManifoldPtr; - SpuContactManifoldCollisionAlgorithm* m_lsCollisionAlgorithmPtr; - - bool needsDmaPutContactManifoldAlgo; - - btCollisionObject* getColObj0() - { - return m_lsColObj0Ptr; - } - btCollisionObject* getColObj1() - { - return m_lsColObj1Ptr; - } - - - btBroadphasePair* getBroadphasePairPtr() - { - return m_pairsPointer; - } - - SpuContactManifoldCollisionAlgorithm* getlocalCollisionAlgorithm() - { - return m_lsCollisionAlgorithmPtr; - } - - btPersistentManifold* getContactManifoldPtr() - { - return m_lsManifoldPtr; - } -}; - - -#if defined(__CELLOS_LV2__) || defined(USE_LIBSPE2) - -ATTRIBUTE_ALIGNED16(CollisionTask_LocalStoreMemory gLocalStoreMemory); - -void* createCollisionLocalStoreMemory() -{ - return &gLocalStoreMemory; -} -#else -void* createCollisionLocalStoreMemory() -{ - return new CollisionTask_LocalStoreMemory; -} - -#endif - -void ProcessSpuConvexConvexCollision(SpuCollisionPairInput* wuInput, CollisionTask_LocalStoreMemory* lsMemPtr, SpuContactResult& spuContacts); - - -SIMD_FORCE_INLINE void small_cache_read(void* buffer, ppu_address_t ea, size_t size) -{ -#if USE_SOFTWARE_CACHE - // Check for alignment requirements. We need to make sure the entire request fits within one cache line, - // so the first and last bytes should fall on the same cache line - btAssert((ea & ~SPE_CACHELINE_MASK) == ((ea + size - 1) & ~SPE_CACHELINE_MASK)); - - void* ls = spe_cache_read(ea); - memcpy(buffer, ls, size); -#else - stallingUnalignedDmaSmallGet(buffer,ea,size); -#endif -} - -SIMD_FORCE_INLINE void small_cache_read_triple( void* ls0, ppu_address_t ea0, - void* ls1, ppu_address_t ea1, - void* ls2, ppu_address_t ea2, - size_t size) -{ - btAssert(size<16); - ATTRIBUTE_ALIGNED16(char tmpBuffer0[32]); - ATTRIBUTE_ALIGNED16(char tmpBuffer1[32]); - ATTRIBUTE_ALIGNED16(char tmpBuffer2[32]); - - uint32_t i; - - - ///make sure last 4 bits are the same, for cellDmaSmallGet - char* localStore0 = (char*)ls0; - uint32_t last4BitsOffset = ea0 & 0x0f; - char* tmpTarget0 = tmpBuffer0 + last4BitsOffset; -#ifdef __SPU__ - cellDmaSmallGet(tmpTarget0,ea0,size,DMA_TAG(1),0,0); -#else - tmpTarget0 = (char*)cellDmaSmallGetReadOnly(tmpTarget0,ea0,size,DMA_TAG(1),0,0); -#endif - - - char* localStore1 = (char*)ls1; - last4BitsOffset = ea1 & 0x0f; - char* tmpTarget1 = tmpBuffer1 + last4BitsOffset; -#ifdef __SPU__ - cellDmaSmallGet(tmpTarget1,ea1,size,DMA_TAG(1),0,0); -#else - tmpTarget1 = (char*)cellDmaSmallGetReadOnly(tmpTarget1,ea1,size,DMA_TAG(1),0,0); -#endif - - char* localStore2 = (char*)ls2; - last4BitsOffset = ea2 & 0x0f; - char* tmpTarget2 = tmpBuffer2 + last4BitsOffset; -#ifdef __SPU__ - cellDmaSmallGet(tmpTarget2,ea2,size,DMA_TAG(1),0,0); -#else - tmpTarget2 = (char*)cellDmaSmallGetReadOnly(tmpTarget2,ea2,size,DMA_TAG(1),0,0); -#endif - - - cellDmaWaitTagStatusAll( DMA_MASK(1) ); - - //this is slowish, perhaps memcpy on SPU is smarter? - for (i=0; btLikely( ibvhShapeData.gIndexMesh.m_indexType == PHY_SHORT) - { - unsigned short int* indexBasePtr = (unsigned short int*)(m_lsMemPtr->bvhShapeData.gIndexMesh.m_triangleIndexBase+triangleIndex*m_lsMemPtr->bvhShapeData.gIndexMesh.m_triangleIndexStride); - ATTRIBUTE_ALIGNED16(unsigned short int tmpIndices[3]); - - small_cache_read_triple(&tmpIndices[0],(ppu_address_t)&indexBasePtr[0], - &tmpIndices[1],(ppu_address_t)&indexBasePtr[1], - &tmpIndices[2],(ppu_address_t)&indexBasePtr[2], - sizeof(unsigned short int)); - - m_lsMemPtr->spuIndices[0] = int(tmpIndices[0]); - m_lsMemPtr->spuIndices[1] = int(tmpIndices[1]); - m_lsMemPtr->spuIndices[2] = int(tmpIndices[2]); - } else - { - unsigned int* indexBasePtr = (unsigned int*)(m_lsMemPtr->bvhShapeData.gIndexMesh.m_triangleIndexBase+triangleIndex*m_lsMemPtr->bvhShapeData.gIndexMesh.m_triangleIndexStride); - - small_cache_read_triple(&m_lsMemPtr->spuIndices[0],(ppu_address_t)&indexBasePtr[0], - &m_lsMemPtr->spuIndices[1],(ppu_address_t)&indexBasePtr[1], - &m_lsMemPtr->spuIndices[2],(ppu_address_t)&indexBasePtr[2], - sizeof(int)); - } - - // spu_printf("SPU index0=%d ,",spuIndices[0]); - // spu_printf("SPU index1=%d ,",spuIndices[1]); - // spu_printf("SPU index2=%d ,",spuIndices[2]); - // spu_printf("SPU: indexBasePtr=%llx\n",indexBasePtr); - - const btVector3& meshScaling = m_lsMemPtr->bvhShapeData.gTriangleMeshInterfacePtr->getScaling(); - for (int j=2;btLikely( j>=0 );j--) - { - int graphicsindex = m_lsMemPtr->spuIndices[j]; - - // spu_printf("SPU index=%d ,",graphicsindex); - btScalar* graphicsbasePtr = (btScalar*)(m_lsMemPtr->bvhShapeData.gIndexMesh.m_vertexBase+graphicsindex*m_lsMemPtr->bvhShapeData.gIndexMesh.m_vertexStride); - // spu_printf("SPU graphicsbasePtr=%llx\n",graphicsbasePtr); - - - ///handle un-aligned vertices... - - //another DMA for each vertex - small_cache_read_triple(&spuUnscaledVertex[0],(ppu_address_t)&graphicsbasePtr[0], - &spuUnscaledVertex[1],(ppu_address_t)&graphicsbasePtr[1], - &spuUnscaledVertex[2],(ppu_address_t)&graphicsbasePtr[2], - sizeof(btScalar)); - - m_tmpTriangleShape.getVertexPtr(j).setValue(spuUnscaledVertex[0]*meshScaling.getX(), - spuUnscaledVertex[1]*meshScaling.getY(), - spuUnscaledVertex[2]*meshScaling.getZ()); - - // spu_printf("SPU:triangle vertices:%f,%f,%f\n",spuTriangleVertices[j].x(),spuTriangleVertices[j].y(),spuTriangleVertices[j].z()); - } - - - SpuCollisionPairInput triangleConcaveInput(*m_wuInput); -// triangleConcaveInput.m_spuCollisionShapes[1] = &spuTriangleVertices[0]; - triangleConcaveInput.m_spuCollisionShapes[1] = &m_tmpTriangleShape; - triangleConcaveInput.m_shapeType1 = TRIANGLE_SHAPE_PROXYTYPE; - - m_spuContacts.setShapeIdentifiersB(subPart,triangleIndex); - - // m_spuContacts.flush(); - - ProcessSpuConvexConvexCollision(&triangleConcaveInput, m_lsMemPtr,m_spuContacts); - ///this flush should be automatic - // m_spuContacts.flush(); - } - -}; - - -//////////////////////// -/// Convex versus Concave triangle mesh collision detection (handles concave triangle mesh versus sphere, box, cylinder, triangle, cone, convex polyhedron etc) -/////////////////// -void ProcessConvexConcaveSpuCollision(SpuCollisionPairInput* wuInput, CollisionTask_LocalStoreMemory* lsMemPtr, SpuContactResult& spuContacts) -{ - //order: first collision shape is convex, second concave. m_isSwapped is true, if the original order was opposite - - btBvhTriangleMeshShape* trimeshShape = (btBvhTriangleMeshShape*)wuInput->m_spuCollisionShapes[1]; - //need the mesh interface, for access to triangle vertices - dmaBvhShapeData (&lsMemPtr->bvhShapeData, trimeshShape); - - btVector3 aabbMin(-1,-400,-1); - btVector3 aabbMax(1,400,1); - - - //recalc aabbs - btTransform convexInTriangleSpace; - convexInTriangleSpace = wuInput->m_worldTransform1.inverse() * wuInput->m_worldTransform0; - btConvexInternalShape* convexShape = (btConvexInternalShape*)wuInput->m_spuCollisionShapes[0]; - - computeAabb (aabbMin, aabbMax, convexShape, wuInput->m_collisionShapes[0], wuInput->m_shapeType0, convexInTriangleSpace); - - - //CollisionShape* triangleShape = static_cast(triBody->m_collisionShape); - //convexShape->getAabb(convexInTriangleSpace,m_aabbMin,m_aabbMax); - - // btScalar extraMargin = collisionMarginTriangle; - // btVector3 extra(extraMargin,extraMargin,extraMargin); - // aabbMax += extra; - // aabbMin -= extra; - - ///quantize query AABB - unsigned short int quantizedQueryAabbMin[3]; - unsigned short int quantizedQueryAabbMax[3]; - lsMemPtr->bvhShapeData.getOptimizedBvh()->quantizeWithClamp(quantizedQueryAabbMin,aabbMin,0); - lsMemPtr->bvhShapeData.getOptimizedBvh()->quantizeWithClamp(quantizedQueryAabbMax,aabbMax,1); - - QuantizedNodeArray& nodeArray = lsMemPtr->bvhShapeData.getOptimizedBvh()->getQuantizedNodeArray(); - //spu_printf("SPU: numNodes = %d\n",nodeArray.size()); - - BvhSubtreeInfoArray& subTrees = lsMemPtr->bvhShapeData.getOptimizedBvh()->getSubtreeInfoArray(); - - - spuNodeCallback nodeCallback(wuInput,lsMemPtr,spuContacts); - IndexedMeshArray& indexArray = lsMemPtr->bvhShapeData.gTriangleMeshInterfacePtr->getIndexedMeshArray(); - //spu_printf("SPU:indexArray.size() = %d\n",indexArray.size()); - - // spu_printf("SPU: numSubTrees = %d\n",subTrees.size()); - //not likely to happen - if (subTrees.size() && indexArray.size() == 1) - { - ///DMA in the index info - dmaBvhIndexedMesh (&lsMemPtr->bvhShapeData.gIndexMesh, indexArray, 0 /* index into indexArray */, 1 /* dmaTag */); - cellDmaWaitTagStatusAll(DMA_MASK(1)); - - //display the headers - int numBatch = subTrees.size(); - for (int i=0;ibvhShapeData.gSubtreeHeaders[0], (ppu_address_t)(&subTrees[i]), nextBatch, 1); - cellDmaWaitTagStatusAll(DMA_MASK(1)); - - - // spu_printf("nextBatch = %d\n",nextBatch); - - for (int j=0;jbvhShapeData.gSubtreeHeaders[j]; - - unsigned int overlap = spuTestQuantizedAabbAgainstQuantizedAabb(quantizedQueryAabbMin,quantizedQueryAabbMax,subtree.m_quantizedAabbMin,subtree.m_quantizedAabbMax); - if (overlap) - { - btAssert(subtree.m_subtreeSize); - - //dma the actual nodes of this subtree - dmaBvhSubTreeNodes (&lsMemPtr->bvhShapeData.gSubtreeNodes[0], subtree, nodeArray, 2); - cellDmaWaitTagStatusAll(DMA_MASK(2)); - - /* Walk this subtree */ - spuWalkStacklessQuantizedTree(&nodeCallback,quantizedQueryAabbMin,quantizedQueryAabbMax, - &lsMemPtr->bvhShapeData.gSubtreeNodes[0], - 0, - subtree.m_subtreeSize); - } - // spu_printf("subtreeSize = %d\n",gSubtreeHeaders[j].m_subtreeSize); - } - - // unsigned short int m_quantizedAabbMin[3]; - // unsigned short int m_quantizedAabbMax[3]; - // int m_rootNodeIndex; - // int m_subtreeSize; - i+=nextBatch; - } - - //pre-fetch first tree, then loop and double buffer - } - -} - - -int stats[11]={0,0,0,0,0,0,0,0,0,0,0}; -int degenerateStats[11]={0,0,0,0,0,0,0,0,0,0,0}; - - -//////////////////////// -/// Convex versus Convex collision detection (handles collision between sphere, box, cylinder, triangle, cone, convex polyhedron etc) -/////////////////// -void ProcessSpuConvexConvexCollision(SpuCollisionPairInput* wuInput, CollisionTask_LocalStoreMemory* lsMemPtr, SpuContactResult& spuContacts) -{ - register int dmaSize; - register ppu_address_t dmaPpuAddress2; - -#ifdef DEBUG_SPU_COLLISION_DETECTION - //spu_printf("SPU: ProcessSpuConvexConvexCollision\n"); -#endif //DEBUG_SPU_COLLISION_DETECTION - //CollisionShape* shape0 = (CollisionShape*)wuInput->m_collisionShapes[0]; - //CollisionShape* shape1 = (CollisionShape*)wuInput->m_collisionShapes[1]; - btPersistentManifold* manifold = (btPersistentManifold*)wuInput->m_persistentManifoldPtr; - - bool genericGjk = true; - - if (genericGjk) - { - //try generic GJK - - - - //SpuConvexPenetrationDepthSolver* penetrationSolver=0; - btVoronoiSimplexSolver simplexSolver; - btGjkEpaPenetrationDepthSolver epaPenetrationSolver2; - - btConvexPenetrationDepthSolver* penetrationSolver = &epaPenetrationSolver2; - - //SpuMinkowskiPenetrationDepthSolver minkowskiPenetrationSolver; -#ifdef ENABLE_EPA - if (gUseEpa) - { - penetrationSolver = &epaPenetrationSolver2; - } else -#endif - { - //penetrationSolver = &minkowskiPenetrationSolver; - } - - - ///DMA in the vertices for convex shapes - ATTRIBUTE_ALIGNED16(char convexHullShape0[sizeof(btConvexHullShape)]); - ATTRIBUTE_ALIGNED16(char convexHullShape1[sizeof(btConvexHullShape)]); - - if ( btLikely( wuInput->m_shapeType0== CONVEX_HULL_SHAPE_PROXYTYPE ) ) - { - // spu_printf("SPU: DMA btConvexHullShape\n"); - - dmaSize = sizeof(btConvexHullShape); - dmaPpuAddress2 = wuInput->m_collisionShapes[0]; - - cellDmaGet(&convexHullShape0, dmaPpuAddress2 , dmaSize, DMA_TAG(1), 0, 0); - //cellDmaWaitTagStatusAll(DMA_MASK(1)); - } - - if ( btLikely( wuInput->m_shapeType1 == CONVEX_HULL_SHAPE_PROXYTYPE ) ) - { - // spu_printf("SPU: DMA btConvexHullShape\n"); - dmaSize = sizeof(btConvexHullShape); - dmaPpuAddress2 = wuInput->m_collisionShapes[1]; - cellDmaGet(&convexHullShape1, dmaPpuAddress2 , dmaSize, DMA_TAG(1), 0, 0); - //cellDmaWaitTagStatusAll(DMA_MASK(1)); - } - - if ( btLikely( wuInput->m_shapeType0 == CONVEX_HULL_SHAPE_PROXYTYPE ) ) - { - cellDmaWaitTagStatusAll(DMA_MASK(1)); - dmaConvexVertexData (&lsMemPtr->convexVertexData[0], (btConvexHullShape*)&convexHullShape0); - lsMemPtr->convexVertexData[0].gSpuConvexShapePtr = wuInput->m_spuCollisionShapes[0]; - } - - - if ( btLikely( wuInput->m_shapeType1 == CONVEX_HULL_SHAPE_PROXYTYPE ) ) - { - cellDmaWaitTagStatusAll(DMA_MASK(1)); - dmaConvexVertexData (&lsMemPtr->convexVertexData[1], (btConvexHullShape*)&convexHullShape1); - lsMemPtr->convexVertexData[1].gSpuConvexShapePtr = wuInput->m_spuCollisionShapes[1]; - } - - - btConvexPointCloudShape cpc0,cpc1; - - if ( btLikely( wuInput->m_shapeType0 == CONVEX_HULL_SHAPE_PROXYTYPE ) ) - { - cellDmaWaitTagStatusAll(DMA_MASK(2)); - lsMemPtr->convexVertexData[0].gConvexPoints = &lsMemPtr->convexVertexData[0].g_convexPointBuffer[0]; - btConvexHullShape* ch = (btConvexHullShape*)wuInput->m_spuCollisionShapes[0]; - const btVector3& localScaling = ch->getLocalScalingNV(); - cpc0.setPoints(lsMemPtr->convexVertexData[0].gConvexPoints,lsMemPtr->convexVertexData[0].gNumConvexPoints,false,localScaling); - wuInput->m_spuCollisionShapes[0] = &cpc0; - } - - if ( btLikely( wuInput->m_shapeType1 == CONVEX_HULL_SHAPE_PROXYTYPE ) ) - { - cellDmaWaitTagStatusAll(DMA_MASK(2)); - lsMemPtr->convexVertexData[1].gConvexPoints = &lsMemPtr->convexVertexData[1].g_convexPointBuffer[0]; - btConvexHullShape* ch = (btConvexHullShape*)wuInput->m_spuCollisionShapes[1]; - const btVector3& localScaling = ch->getLocalScalingNV(); - cpc1.setPoints(lsMemPtr->convexVertexData[1].gConvexPoints,lsMemPtr->convexVertexData[1].gNumConvexPoints,false,localScaling); - wuInput->m_spuCollisionShapes[1] = &cpc1; - - } - - - const btConvexShape* shape0Ptr = (const btConvexShape*)wuInput->m_spuCollisionShapes[0]; - const btConvexShape* shape1Ptr = (const btConvexShape*)wuInput->m_spuCollisionShapes[1]; - int shapeType0 = wuInput->m_shapeType0; - int shapeType1 = wuInput->m_shapeType1; - float marginA = wuInput->m_collisionMargin0; - float marginB = wuInput->m_collisionMargin1; - - SpuClosestPointInput cpInput; - cpInput.m_convexVertexData[0] = &lsMemPtr->convexVertexData[0]; - cpInput.m_convexVertexData[1] = &lsMemPtr->convexVertexData[1]; - cpInput.m_transformA = wuInput->m_worldTransform0; - cpInput.m_transformB = wuInput->m_worldTransform1; - float sumMargin = (marginA+marginB+lsMemPtr->getContactManifoldPtr()->getContactBreakingThreshold()); - cpInput.m_maximumDistanceSquared = sumMargin * sumMargin; - - ppu_address_t manifoldAddress = (ppu_address_t)manifold; - - btPersistentManifold* spuManifold=lsMemPtr->getContactManifoldPtr(); - //spuContacts.setContactInfo(spuManifold,manifoldAddress,wuInput->m_worldTransform0,wuInput->m_worldTransform1,wuInput->m_isSwapped); - spuContacts.setContactInfo(spuManifold,manifoldAddress,lsMemPtr->getColObj0()->getWorldTransform(), - lsMemPtr->getColObj1()->getWorldTransform(), - lsMemPtr->getColObj0()->getRestitution(),lsMemPtr->getColObj1()->getRestitution(), - lsMemPtr->getColObj0()->getFriction(),lsMemPtr->getColObj1()->getFriction(), - wuInput->m_isSwapped); - - { - btGjkPairDetector gjk(shape0Ptr,shape1Ptr,shapeType0,shapeType1,marginA,marginB,&simplexSolver,penetrationSolver);//&vsSolver,penetrationSolver); - gjk.getClosestPoints(cpInput,spuContacts,0);//,debugDraw); - - stats[gjk.m_lastUsedMethod]++; - degenerateStats[gjk.m_degenerateSimplex]++; - -#ifdef USE_SEPDISTANCE_UTIL - btScalar sepDist = gjk.getCachedSeparatingDistance()+spuManifold->getContactBreakingThreshold(); - lsMemPtr->getlocalCollisionAlgorithm()->m_sepDistance.initSeparatingDistance(gjk.getCachedSeparatingAxis(),sepDist,wuInput->m_worldTransform0,wuInput->m_worldTransform1); - lsMemPtr->needsDmaPutContactManifoldAlgo = true; -#endif //USE_SEPDISTANCE_UTIL - - } - - } - - -} - - -template void DoSwap(T& a, T& b) -{ - char tmp[sizeof(T)]; - memcpy(tmp, &a, sizeof(T)); - memcpy(&a, &b, sizeof(T)); - memcpy(&b, tmp, sizeof(T)); -} - -SIMD_FORCE_INLINE void dmaAndSetupCollisionObjects(SpuCollisionPairInput& collisionPairInput, CollisionTask_LocalStoreMemory& lsMem) -{ - register int dmaSize; - register ppu_address_t dmaPpuAddress2; - - dmaSize = sizeof(btCollisionObject);//btTransform); - dmaPpuAddress2 = /*collisionPairInput.m_isSwapped ? (ppu_address_t)lsMem.gProxyPtr1->m_clientObject :*/ (ppu_address_t)lsMem.getlocalCollisionAlgorithm()->getCollisionObject0(); - lsMem.m_lsColObj0Ptr = (btCollisionObject*)cellDmaGetReadOnly(&lsMem.gColObj0Buffer, dmaPpuAddress2 , dmaSize, DMA_TAG(1), 0, 0); - - dmaSize = sizeof(btCollisionObject);//btTransform); - dmaPpuAddress2 = /*collisionPairInput.m_isSwapped ? (ppu_address_t)lsMem.gProxyPtr0->m_clientObject :*/ (ppu_address_t)lsMem.getlocalCollisionAlgorithm()->getCollisionObject1(); - lsMem.m_lsColObj1Ptr = (btCollisionObject*)cellDmaGetReadOnly(&lsMem.gColObj1Buffer, dmaPpuAddress2 , dmaSize, DMA_TAG(2), 0, 0); - - cellDmaWaitTagStatusAll(DMA_MASK(1) | DMA_MASK(2)); - - btCollisionObject* ob0 = lsMem.getColObj0(); - btCollisionObject* ob1 = lsMem.getColObj1(); - - collisionPairInput.m_worldTransform0 = ob0->getWorldTransform(); - collisionPairInput.m_worldTransform1 = ob1->getWorldTransform(); -} - - - -void handleCollisionPair(SpuCollisionPairInput& collisionPairInput, CollisionTask_LocalStoreMemory& lsMem, - SpuContactResult &spuContacts, - ppu_address_t collisionShape0Ptr, void* collisionShape0Loc, - ppu_address_t collisionShape1Ptr, void* collisionShape1Loc, bool dmaShapes = true) -{ - - if (btBroadphaseProxy::isConvex(collisionPairInput.m_shapeType0) - && btBroadphaseProxy::isConvex(collisionPairInput.m_shapeType1)) - { - if (dmaShapes) - { - dmaCollisionShape (collisionShape0Loc, collisionShape0Ptr, 1, collisionPairInput.m_shapeType0); - dmaCollisionShape (collisionShape1Loc, collisionShape1Ptr, 2, collisionPairInput.m_shapeType1); - cellDmaWaitTagStatusAll(DMA_MASK(1) | DMA_MASK(2)); - } - - btConvexInternalShape* spuConvexShape0 = (btConvexInternalShape*)collisionShape0Loc; - btConvexInternalShape* spuConvexShape1 = (btConvexInternalShape*)collisionShape1Loc; - - btVector3 dim0 = spuConvexShape0->getImplicitShapeDimensions(); - btVector3 dim1 = spuConvexShape1->getImplicitShapeDimensions(); - - collisionPairInput.m_primitiveDimensions0 = dim0; - collisionPairInput.m_primitiveDimensions1 = dim1; - collisionPairInput.m_collisionShapes[0] = collisionShape0Ptr; - collisionPairInput.m_collisionShapes[1] = collisionShape1Ptr; - collisionPairInput.m_spuCollisionShapes[0] = spuConvexShape0; - collisionPairInput.m_spuCollisionShapes[1] = spuConvexShape1; - ProcessSpuConvexConvexCollision(&collisionPairInput,&lsMem,spuContacts); - } - else if (btBroadphaseProxy::isCompound(collisionPairInput.m_shapeType0) && - btBroadphaseProxy::isCompound(collisionPairInput.m_shapeType1)) - { - //snPause(); - - dmaCollisionShape (collisionShape0Loc, collisionShape0Ptr, 1, collisionPairInput.m_shapeType0); - dmaCollisionShape (collisionShape1Loc, collisionShape1Ptr, 2, collisionPairInput.m_shapeType1); - cellDmaWaitTagStatusAll(DMA_MASK(1) | DMA_MASK(2)); - - // Both are compounds, do N^2 CD for now - ///@todo: add some AABB-based pruning (probably not -> slower) - - btCompoundShape* spuCompoundShape0 = (btCompoundShape*)collisionShape0Loc; - btCompoundShape* spuCompoundShape1 = (btCompoundShape*)collisionShape1Loc; - - dmaCompoundShapeInfo (&lsMem.compoundShapeData[0], spuCompoundShape0, 1); - dmaCompoundShapeInfo (&lsMem.compoundShapeData[1], spuCompoundShape1, 2); - cellDmaWaitTagStatusAll(DMA_MASK(1) | DMA_MASK(2)); - - - dmaCompoundSubShapes (&lsMem.compoundShapeData[0], spuCompoundShape0, 1); - cellDmaWaitTagStatusAll(DMA_MASK(1)); - dmaCompoundSubShapes (&lsMem.compoundShapeData[1], spuCompoundShape1, 1); - cellDmaWaitTagStatusAll(DMA_MASK(1)); - - int childShapeCount0 = spuCompoundShape0->getNumChildShapes(); - int childShapeCount1 = spuCompoundShape1->getNumChildShapes(); - - // Start the N^2 - for (int i = 0; i < childShapeCount0; ++i) - { - btCompoundShapeChild& childShape0 = lsMem.compoundShapeData[0].gSubshapes[i]; - - for (int j = 0; j < childShapeCount1; ++j) - { - btCompoundShapeChild& childShape1 = lsMem.compoundShapeData[1].gSubshapes[j]; - - /* Create a new collision pair input struct using the two child shapes */ - SpuCollisionPairInput cinput (collisionPairInput); - - cinput.m_worldTransform0 = collisionPairInput.m_worldTransform0 * childShape0.m_transform; - cinput.m_shapeType0 = childShape0.m_childShapeType; - cinput.m_collisionMargin0 = childShape0.m_childMargin; - - cinput.m_worldTransform1 = collisionPairInput.m_worldTransform1 * childShape1.m_transform; - cinput.m_shapeType1 = childShape1.m_childShapeType; - cinput.m_collisionMargin1 = childShape1.m_childMargin; - /* Recursively call handleCollisionPair () with new collision pair input */ - handleCollisionPair(cinput, lsMem, spuContacts, - (ppu_address_t)childShape0.m_childShape, lsMem.compoundShapeData[0].gSubshapeShape[i], - (ppu_address_t)childShape1.m_childShape, lsMem.compoundShapeData[1].gSubshapeShape[j], false); // bug fix: changed index to j. - } - } - } - else if (btBroadphaseProxy::isCompound(collisionPairInput.m_shapeType0) ) - { - //snPause(); - - dmaCollisionShape (collisionShape0Loc, collisionShape0Ptr, 1, collisionPairInput.m_shapeType0); - dmaCollisionShape (collisionShape1Loc, collisionShape1Ptr, 2, collisionPairInput.m_shapeType1); - cellDmaWaitTagStatusAll(DMA_MASK(1) | DMA_MASK(2)); - - // object 0 compound, object 1 non-compound - btCompoundShape* spuCompoundShape = (btCompoundShape*)collisionShape0Loc; - dmaCompoundShapeInfo (&lsMem.compoundShapeData[0], spuCompoundShape, 1); - cellDmaWaitTagStatusAll(DMA_MASK(1)); - - int childShapeCount = spuCompoundShape->getNumChildShapes(); - - for (int i = 0; i < childShapeCount; ++i) - { - btCompoundShapeChild& childShape = lsMem.compoundShapeData[0].gSubshapes[i]; - - // Dma the child shape - dmaCollisionShape (&lsMem.compoundShapeData[0].gSubshapeShape[i], (ppu_address_t)childShape.m_childShape, 1, childShape.m_childShapeType); - cellDmaWaitTagStatusAll(DMA_MASK(1)); - - SpuCollisionPairInput cinput (collisionPairInput); - cinput.m_worldTransform0 = collisionPairInput.m_worldTransform0 * childShape.m_transform; - cinput.m_shapeType0 = childShape.m_childShapeType; - cinput.m_collisionMargin0 = childShape.m_childMargin; - - handleCollisionPair(cinput, lsMem, spuContacts, - (ppu_address_t)childShape.m_childShape, lsMem.compoundShapeData[0].gSubshapeShape[i], - collisionShape1Ptr, collisionShape1Loc, false); - } - } - else if (btBroadphaseProxy::isCompound(collisionPairInput.m_shapeType1) ) - { - //snPause(); - - dmaCollisionShape (collisionShape0Loc, collisionShape0Ptr, 1, collisionPairInput.m_shapeType0); - dmaCollisionShape (collisionShape1Loc, collisionShape1Ptr, 2, collisionPairInput.m_shapeType1); - cellDmaWaitTagStatusAll(DMA_MASK(1) | DMA_MASK(2)); - // object 0 non-compound, object 1 compound - btCompoundShape* spuCompoundShape = (btCompoundShape*)collisionShape1Loc; - dmaCompoundShapeInfo (&lsMem.compoundShapeData[0], spuCompoundShape, 1); - cellDmaWaitTagStatusAll(DMA_MASK(1)); - - int childShapeCount = spuCompoundShape->getNumChildShapes(); - - for (int i = 0; i < childShapeCount; ++i) - { - btCompoundShapeChild& childShape = lsMem.compoundShapeData[0].gSubshapes[i]; - // Dma the child shape - dmaCollisionShape (&lsMem.compoundShapeData[0].gSubshapeShape[i], (ppu_address_t)childShape.m_childShape, 1, childShape.m_childShapeType); - cellDmaWaitTagStatusAll(DMA_MASK(1)); - - SpuCollisionPairInput cinput (collisionPairInput); - cinput.m_worldTransform1 = collisionPairInput.m_worldTransform1 * childShape.m_transform; - cinput.m_shapeType1 = childShape.m_childShapeType; - cinput.m_collisionMargin1 = childShape.m_childMargin; - handleCollisionPair(cinput, lsMem, spuContacts, - collisionShape0Ptr, collisionShape0Loc, - (ppu_address_t)childShape.m_childShape, lsMem.compoundShapeData[0].gSubshapeShape[i], false); - } - - } - else - { - //a non-convex shape is involved - bool handleConvexConcave = false; - - //snPause(); - - if (btBroadphaseProxy::isConcave(collisionPairInput.m_shapeType0) && - btBroadphaseProxy::isConvex(collisionPairInput.m_shapeType1)) - { - // Swap stuff - DoSwap(collisionShape0Ptr, collisionShape1Ptr); - DoSwap(collisionShape0Loc, collisionShape1Loc); - DoSwap(collisionPairInput.m_shapeType0, collisionPairInput.m_shapeType1); - DoSwap(collisionPairInput.m_worldTransform0, collisionPairInput.m_worldTransform1); - DoSwap(collisionPairInput.m_collisionMargin0, collisionPairInput.m_collisionMargin1); - - collisionPairInput.m_isSwapped = true; - } - - if (btBroadphaseProxy::isConvex(collisionPairInput.m_shapeType0)&& - btBroadphaseProxy::isConcave(collisionPairInput.m_shapeType1)) - { - handleConvexConcave = true; - } - if (handleConvexConcave) - { - if (dmaShapes) - { - dmaCollisionShape (collisionShape0Loc, collisionShape0Ptr, 1, collisionPairInput.m_shapeType0); - dmaCollisionShape (collisionShape1Loc, collisionShape1Ptr, 2, collisionPairInput.m_shapeType1); - cellDmaWaitTagStatusAll(DMA_MASK(1) | DMA_MASK(2)); - } - - btConvexInternalShape* spuConvexShape0 = (btConvexInternalShape*)collisionShape0Loc; - btBvhTriangleMeshShape* trimeshShape = (btBvhTriangleMeshShape*)collisionShape1Loc; - - btVector3 dim0 = spuConvexShape0->getImplicitShapeDimensions(); - collisionPairInput.m_primitiveDimensions0 = dim0; - collisionPairInput.m_collisionShapes[0] = collisionShape0Ptr; - collisionPairInput.m_collisionShapes[1] = collisionShape1Ptr; - collisionPairInput.m_spuCollisionShapes[0] = spuConvexShape0; - collisionPairInput.m_spuCollisionShapes[1] = trimeshShape; - - ProcessConvexConcaveSpuCollision(&collisionPairInput,&lsMem,spuContacts); - } - - } - - spuContacts.flush(); - -} - - -void processCollisionTask(void* userPtr, void* lsMemPtr) -{ - - SpuGatherAndProcessPairsTaskDesc* taskDescPtr = (SpuGatherAndProcessPairsTaskDesc*)userPtr; - SpuGatherAndProcessPairsTaskDesc& taskDesc = *taskDescPtr; - CollisionTask_LocalStoreMemory* colMemPtr = (CollisionTask_LocalStoreMemory*)lsMemPtr; - CollisionTask_LocalStoreMemory& lsMem = *(colMemPtr); - - gUseEpa = taskDesc.m_useEpa; - - // spu_printf("taskDescPtr=%llx\n",taskDescPtr); - - SpuContactResult spuContacts; - - //////////////////// - - ppu_address_t dmaInPtr = taskDesc.m_inPairPtr; - unsigned int numPages = taskDesc.numPages; - unsigned int numOnLastPage = taskDesc.numOnLastPage; - - // prefetch first set of inputs and wait - lsMem.g_workUnitTaskBuffers.init(); - - unsigned int nextNumOnPage = (numPages > 1)? MIDPHASE_NUM_WORKUNITS_PER_PAGE : numOnLastPage; - lsMem.g_workUnitTaskBuffers.backBufferDmaGet(dmaInPtr, nextNumOnPage*sizeof(SpuGatherAndProcessWorkUnitInput), DMA_TAG(3)); - dmaInPtr += MIDPHASE_WORKUNIT_PAGE_SIZE; - - - register unsigned char *inputPtr; - register unsigned int numOnPage; - register unsigned int j; - SpuGatherAndProcessWorkUnitInput* wuInputs; - register int dmaSize; - register ppu_address_t dmaPpuAddress; - register ppu_address_t dmaPpuAddress2; - - int numPairs; - register int p; - SpuCollisionPairInput collisionPairInput; - - for (unsigned int i = 0; btLikely(i < numPages); i++) - { - - // wait for back buffer dma and swap buffers - inputPtr = lsMem.g_workUnitTaskBuffers.swapBuffers(); - - // number on current page is number prefetched last iteration - numOnPage = nextNumOnPage; - - - // prefetch next set of inputs -#if MIDPHASE_NUM_WORKUNIT_PAGES > 2 - if ( btLikely( i < numPages-1 ) ) -#else - if ( btUnlikely( i < numPages-1 ) ) -#endif - { - nextNumOnPage = (i == numPages-2)? numOnLastPage : MIDPHASE_NUM_WORKUNITS_PER_PAGE; - lsMem.g_workUnitTaskBuffers.backBufferDmaGet(dmaInPtr, nextNumOnPage*sizeof(SpuGatherAndProcessWorkUnitInput), DMA_TAG(3)); - dmaInPtr += MIDPHASE_WORKUNIT_PAGE_SIZE; - } - - wuInputs = reinterpret_cast(inputPtr); - - - for (j = 0; btLikely( j < numOnPage ); j++) - { -#ifdef DEBUG_SPU_COLLISION_DETECTION - // printMidphaseInput(&wuInputs[j]); -#endif //DEBUG_SPU_COLLISION_DETECTION - - - numPairs = wuInputs[j].m_endIndex - wuInputs[j].m_startIndex; - - if ( btLikely( numPairs ) ) - { - dmaSize = numPairs*sizeof(btBroadphasePair); - dmaPpuAddress = wuInputs[j].m_pairArrayPtr+wuInputs[j].m_startIndex * sizeof(btBroadphasePair); - lsMem.m_pairsPointer = (btBroadphasePair*)cellDmaGetReadOnly(&lsMem.gBroadphasePairsBuffer, dmaPpuAddress , dmaSize, DMA_TAG(1), 0, 0); - cellDmaWaitTagStatusAll(DMA_MASK(1)); - - - for (p=0;pm_userInfo = %d\n",pair.m_userInfo); - spu_printf("pair->m_algorithm = %d\n",pair.m_algorithm); - spu_printf("pair->m_pProxy0 = %d\n",pair.m_pProxy0); - spu_printf("pair->m_pProxy1 = %d\n",pair.m_pProxy1); -#endif //DEBUG_SPU_COLLISION_DETECTION - - if (pair.m_internalTmpValue == 2 && pair.m_algorithm && pair.m_pProxy0 && pair.m_pProxy1) - { - dmaSize = sizeof(SpuContactManifoldCollisionAlgorithm); - dmaPpuAddress2 = (ppu_address_t)pair.m_algorithm; - lsMem.m_lsCollisionAlgorithmPtr = (SpuContactManifoldCollisionAlgorithm*)cellDmaGetReadOnly(&lsMem.gSpuContactManifoldAlgoBuffer, dmaPpuAddress2 , dmaSize, DMA_TAG(1), 0, 0); - - cellDmaWaitTagStatusAll(DMA_MASK(1)); - - lsMem.needsDmaPutContactManifoldAlgo = false; - - collisionPairInput.m_persistentManifoldPtr = (ppu_address_t) lsMem.getlocalCollisionAlgorithm()->getContactManifoldPtr(); - collisionPairInput.m_isSwapped = false; - - if (1) - { - - ///can wait on the combined DMA_MASK, or dma on the same tag - - -#ifdef DEBUG_SPU_COLLISION_DETECTION - // spu_printf("SPU collisionPairInput->m_shapeType0 = %d\n",collisionPairInput->m_shapeType0); - // spu_printf("SPU collisionPairInput->m_shapeType1 = %d\n",collisionPairInput->m_shapeType1); -#endif //DEBUG_SPU_COLLISION_DETECTION - - - dmaSize = sizeof(btPersistentManifold); - - dmaPpuAddress2 = collisionPairInput.m_persistentManifoldPtr; - lsMem.m_lsManifoldPtr = (btPersistentManifold*)cellDmaGetReadOnly(&lsMem.gPersistentManifoldBuffer, dmaPpuAddress2 , dmaSize, DMA_TAG(1), 0, 0); - - collisionPairInput.m_shapeType0 = lsMem.getlocalCollisionAlgorithm()->getShapeType0(); - collisionPairInput.m_shapeType1 = lsMem.getlocalCollisionAlgorithm()->getShapeType1(); - collisionPairInput.m_collisionMargin0 = lsMem.getlocalCollisionAlgorithm()->getCollisionMargin0(); - collisionPairInput.m_collisionMargin1 = lsMem.getlocalCollisionAlgorithm()->getCollisionMargin1(); - - - - //??cellDmaWaitTagStatusAll(DMA_MASK(1)); - - - if (1) - { - //snPause(); - - // Get the collision objects - dmaAndSetupCollisionObjects(collisionPairInput, lsMem); - - if (lsMem.getColObj0()->isActive() || lsMem.getColObj1()->isActive()) - { - - lsMem.needsDmaPutContactManifoldAlgo = true; -#ifdef USE_SEPDISTANCE_UTIL - lsMem.getlocalCollisionAlgorithm()->m_sepDistance.updateSeparatingDistance(collisionPairInput.m_worldTransform0,collisionPairInput.m_worldTransform1); -#endif //USE_SEPDISTANCE_UTIL - -#define USE_DEDICATED_BOX_BOX 1 -#ifdef USE_DEDICATED_BOX_BOX - bool boxbox = ((lsMem.getlocalCollisionAlgorithm()->getShapeType0()==BOX_SHAPE_PROXYTYPE)&& - (lsMem.getlocalCollisionAlgorithm()->getShapeType1()==BOX_SHAPE_PROXYTYPE)); - if (boxbox) - { - //spu_printf("boxbox dist = %f\n",distance); - btPersistentManifold* spuManifold=lsMem.getContactManifoldPtr(); - btPersistentManifold* manifold = (btPersistentManifold*)collisionPairInput.m_persistentManifoldPtr; - ppu_address_t manifoldAddress = (ppu_address_t)manifold; - - spuContacts.setContactInfo(spuManifold,manifoldAddress,lsMem.getColObj0()->getWorldTransform(), - lsMem.getColObj1()->getWorldTransform(), - lsMem.getColObj0()->getRestitution(),lsMem.getColObj1()->getRestitution(), - lsMem.getColObj0()->getFriction(),lsMem.getColObj1()->getFriction(), - collisionPairInput.m_isSwapped); - - - float distance=0.f; - btVector3 normalInB; - - - if (//!gUseEpa && -#ifdef USE_SEPDISTANCE_UTIL - lsMem.getlocalCollisionAlgorithm()->m_sepDistance.getConservativeSeparatingDistance()<=0.f -#else - 1 -#endif - ) - { -//#define USE_PE_BOX_BOX 1 -#ifdef USE_PE_BOX_BOX - { - - //getCollisionMargin0 - btScalar margin0 = lsMem.getlocalCollisionAlgorithm()->getCollisionMargin0(); - btScalar margin1 = lsMem.getlocalCollisionAlgorithm()->getCollisionMargin1(); - btVector3 shapeDim0 = lsMem.getlocalCollisionAlgorithm()->getShapeDimensions0()+btVector3(margin0,margin0,margin0); - btVector3 shapeDim1 = lsMem.getlocalCollisionAlgorithm()->getShapeDimensions1()+btVector3(margin1,margin1,margin1); - - Box boxA(shapeDim0.getX(),shapeDim0.getY(),shapeDim0.getZ()); - Vector3 vmPos0 = getVmVector3(collisionPairInput.m_worldTransform0.getOrigin()); - Vector3 vmPos1 = getVmVector3(collisionPairInput.m_worldTransform1.getOrigin()); - Matrix3 vmMatrix0 = getVmMatrix3(collisionPairInput.m_worldTransform0.getBasis()); - Matrix3 vmMatrix1 = getVmMatrix3(collisionPairInput.m_worldTransform1.getBasis()); - - Transform3 transformA(vmMatrix0,vmPos0); - Box boxB(shapeDim1.getX(),shapeDim1.getY(),shapeDim1.getZ()); - Transform3 transformB(vmMatrix1,vmPos1); - BoxPoint resultClosestBoxPointA; - BoxPoint resultClosestBoxPointB; - Vector3 resultNormal; -#ifdef USE_SEPDISTANCE_UTIL - float distanceThreshold = FLT_MAX -#else - float distanceThreshold = 0.f; -#endif - - - distance = boxBoxDistance(resultNormal,resultClosestBoxPointA,resultClosestBoxPointB, boxA, transformA, boxB,transformB,distanceThreshold); - - normalInB = -getBtVector3(resultNormal); - - if(distance < spuManifold->getContactBreakingThreshold()) - { - btVector3 pointOnB = collisionPairInput.m_worldTransform1(getBtVector3(resultClosestBoxPointB.localPoint)); - - spuContacts.addContactPoint( - normalInB, - pointOnB, - distance); - } - } -#else - { - - btScalar margin0 = lsMem.getlocalCollisionAlgorithm()->getCollisionMargin0(); - btScalar margin1 = lsMem.getlocalCollisionAlgorithm()->getCollisionMargin1(); - btVector3 shapeDim0 = lsMem.getlocalCollisionAlgorithm()->getShapeDimensions0()+btVector3(margin0,margin0,margin0); - btVector3 shapeDim1 = lsMem.getlocalCollisionAlgorithm()->getShapeDimensions1()+btVector3(margin1,margin1,margin1); - - - btBoxShape box0(shapeDim0); - btBoxShape box1(shapeDim1); - - struct SpuBridgeContactCollector : public btDiscreteCollisionDetectorInterface::Result - { - SpuContactResult& m_spuContacts; - - virtual void setShapeIdentifiersA(int partId0,int index0) - { - m_spuContacts.setShapeIdentifiersA(partId0,index0); - } - virtual void setShapeIdentifiersB(int partId1,int index1) - { - m_spuContacts.setShapeIdentifiersB(partId1,index1); - } - virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth) - { - m_spuContacts.addContactPoint(normalOnBInWorld,pointInWorld,depth); - } - - SpuBridgeContactCollector(SpuContactResult& spuContacts) - :m_spuContacts(spuContacts) - { - - } - }; - - SpuBridgeContactCollector bridgeOutput(spuContacts); - - btDiscreteCollisionDetectorInterface::ClosestPointInput input; - input.m_maximumDistanceSquared = BT_LARGE_FLOAT; - input.m_transformA = collisionPairInput.m_worldTransform0; - input.m_transformB = collisionPairInput.m_worldTransform1; - - btBoxBoxDetector detector(&box0,&box1); - - detector.getClosestPoints(input,bridgeOutput,0); - - } -#endif //USE_PE_BOX_BOX - - lsMem.needsDmaPutContactManifoldAlgo = true; -#ifdef USE_SEPDISTANCE_UTIL - btScalar sepDist2 = distance+spuManifold->getContactBreakingThreshold(); - lsMem.getlocalCollisionAlgorithm()->m_sepDistance.initSeparatingDistance(normalInB,sepDist2,collisionPairInput.m_worldTransform0,collisionPairInput.m_worldTransform1); -#endif //USE_SEPDISTANCE_UTIL - gProcessedCol++; - } else - { - gSkippedCol++; - } - - spuContacts.flush(); - - - } else -#endif //USE_DEDICATED_BOX_BOX - { - if ( -#ifdef USE_SEPDISTANCE_UTIL - lsMem.getlocalCollisionAlgorithm()->m_sepDistance.getConservativeSeparatingDistance()<=0.f -#else - 1 -#endif //USE_SEPDISTANCE_UTIL - ) - { - handleCollisionPair(collisionPairInput, lsMem, spuContacts, (ppu_address_t)lsMem.getColObj0()->getCollisionShape(), &lsMem.gCollisionShapes[0].collisionShape, (ppu_address_t)lsMem.getColObj1()->getCollisionShape(), &lsMem.gCollisionShapes[1].collisionShape); - } else - { - //spu_printf("boxbox dist = %f\n",distance); - btPersistentManifold* spuManifold=lsMem.getContactManifoldPtr(); - btPersistentManifold* manifold = (btPersistentManifold*)collisionPairInput.m_persistentManifoldPtr; - ppu_address_t manifoldAddress = (ppu_address_t)manifold; - - spuContacts.setContactInfo(spuManifold,manifoldAddress,lsMem.getColObj0()->getWorldTransform(), - lsMem.getColObj1()->getWorldTransform(), - lsMem.getColObj0()->getRestitution(),lsMem.getColObj1()->getRestitution(), - lsMem.getColObj0()->getFriction(),lsMem.getColObj1()->getFriction(), - collisionPairInput.m_isSwapped); - - spuContacts.flush(); - } - } - - } - - } - } - -#ifdef USE_SEPDISTANCE_UTIL -#if defined (__SPU__) || defined (USE_LIBSPE2) - if (lsMem.needsDmaPutContactManifoldAlgo) - { - dmaSize = sizeof(SpuContactManifoldCollisionAlgorithm); - dmaPpuAddress2 = (ppu_address_t)pair.m_algorithm; - cellDmaLargePut(&lsMem.gSpuContactManifoldAlgoBuffer, dmaPpuAddress2 , dmaSize, DMA_TAG(1), 0, 0); - cellDmaWaitTagStatusAll(DMA_MASK(1)); - } -#endif -#endif //#ifdef USE_SEPDISTANCE_UTIL - - } - } - } - } //end for (j = 0; j < numOnPage; j++) - - }// for - - - - return; -} diff --git a/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.h b/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.h deleted file mode 100644 index 100432339..000000000 --- a/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.h +++ /dev/null @@ -1,140 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef SPU_GATHERING_COLLISION_TASK_H -#define SPU_GATHERING_COLLISION_TASK_H - -#include "../PlatformDefinitions.h" -//#define DEBUG_SPU_COLLISION_DETECTION 1 - - -///Task Description for SPU collision detection -struct SpuGatherAndProcessPairsTaskDesc -{ - ppu_address_t m_inPairPtr;//m_pairArrayPtr; - //mutex variable - uint32_t m_someMutexVariableInMainMemory; - - ppu_address_t m_dispatcher; - - uint32_t numOnLastPage; - - uint16_t numPages; - uint16_t taskId; - bool m_useEpa; - - struct CollisionTask_LocalStoreMemory* m_lsMemory; -} - -#if defined(__CELLOS_LV2__) || defined(USE_LIBSPE2) -__attribute__ ((aligned (128))) -#endif -; - - -void processCollisionTask(void* userPtr, void* lsMemory); - -void* createCollisionLocalStoreMemory(); - - -#if defined(USE_LIBSPE2) && defined(__SPU__) -#include "../SpuLibspe2Support.h" -#include -#include -#include - -//#define DEBUG_LIBSPE2_SPU_TASK - - - -int main(unsigned long long speid, addr64 argp, addr64 envp) -{ - printf("SPU: hello \n"); - - ATTRIBUTE_ALIGNED128(btSpuStatus status); - ATTRIBUTE_ALIGNED16( SpuGatherAndProcessPairsTaskDesc taskDesc ) ; - unsigned int received_message = Spu_Mailbox_Event_Nothing; - bool shutdown = false; - - cellDmaGet(&status, argp.ull, sizeof(btSpuStatus), DMA_TAG(3), 0, 0); - cellDmaWaitTagStatusAll(DMA_MASK(3)); - - status.m_status = Spu_Status_Free; - status.m_lsMemory.p = createCollisionLocalStoreMemory(); - - cellDmaLargePut(&status, argp.ull, sizeof(btSpuStatus), DMA_TAG(3), 0, 0); - cellDmaWaitTagStatusAll(DMA_MASK(3)); - - - while ( btLikely( !shutdown ) ) - { - - received_message = spu_read_in_mbox(); - - if( btLikely( received_message == Spu_Mailbox_Event_Task )) - { -#ifdef DEBUG_LIBSPE2_SPU_TASK - printf("SPU: received Spu_Mailbox_Event_Task\n"); -#endif //DEBUG_LIBSPE2_SPU_TASK - - // refresh the status - cellDmaGet(&status, argp.ull, sizeof(btSpuStatus), DMA_TAG(3), 0, 0); - cellDmaWaitTagStatusAll(DMA_MASK(3)); - - btAssert(status.m_status==Spu_Status_Occupied); - - cellDmaGet(&taskDesc, status.m_taskDesc.p, sizeof(SpuGatherAndProcessPairsTaskDesc), DMA_TAG(3), 0, 0); - cellDmaWaitTagStatusAll(DMA_MASK(3)); -#ifdef DEBUG_LIBSPE2_SPU_TASK - printf("SPU:processCollisionTask\n"); -#endif //DEBUG_LIBSPE2_SPU_TASK - processCollisionTask((void*)&taskDesc, taskDesc.m_lsMemory); - -#ifdef DEBUG_LIBSPE2_SPU_TASK - printf("SPU:finished processCollisionTask\n"); -#endif //DEBUG_LIBSPE2_SPU_TASK - } - else - { -#ifdef DEBUG_LIBSPE2_SPU_TASK - printf("SPU: received ShutDown\n"); -#endif //DEBUG_LIBSPE2_SPU_TASK - if( btLikely( received_message == Spu_Mailbox_Event_Shutdown ) ) - { - shutdown = true; - } - else - { - //printf("SPU - Sth. recieved\n"); - } - } - - // set to status free and wait for next task - status.m_status = Spu_Status_Free; - cellDmaLargePut(&status, argp.ull, sizeof(btSpuStatus), DMA_TAG(3), 0, 0); - cellDmaWaitTagStatusAll(DMA_MASK(3)); - - - } - - printf("SPU: shutdown\n"); - return 0; -} -#endif // USE_LIBSPE2 - - -#endif //SPU_GATHERING_COLLISION_TASK_H - - diff --git a/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuLocalSupport.h b/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuLocalSupport.h deleted file mode 100644 index af45ed974..000000000 --- a/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuLocalSupport.h +++ /dev/null @@ -1,19 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - - - - diff --git a/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuMinkowskiPenetrationDepthSolver.cpp b/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuMinkowskiPenetrationDepthSolver.cpp deleted file mode 100644 index cc42501e5..000000000 --- a/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuMinkowskiPenetrationDepthSolver.cpp +++ /dev/null @@ -1,348 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "SpuMinkowskiPenetrationDepthSolver.h" -#include "SpuContactResult.h" -#include "SpuPreferredPenetrationDirections.h" -#include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h" -#include "BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h" -#include "SpuCollisionShapes.h" - -#define NUM_UNITSPHERE_POINTS 42 -static btVector3 sPenetrationDirections[NUM_UNITSPHERE_POINTS+MAX_PREFERRED_PENETRATION_DIRECTIONS*2] = -{ -btVector3(btScalar(0.000000) , btScalar(-0.000000),btScalar(-1.000000)), -btVector3(btScalar(0.723608) , btScalar(-0.525725),btScalar(-0.447219)), -btVector3(btScalar(-0.276388) , btScalar(-0.850649),btScalar(-0.447219)), -btVector3(btScalar(-0.894426) , btScalar(-0.000000),btScalar(-0.447216)), -btVector3(btScalar(-0.276388) , btScalar(0.850649),btScalar(-0.447220)), -btVector3(btScalar(0.723608) , btScalar(0.525725),btScalar(-0.447219)), -btVector3(btScalar(0.276388) , btScalar(-0.850649),btScalar(0.447220)), -btVector3(btScalar(-0.723608) , btScalar(-0.525725),btScalar(0.447219)), -btVector3(btScalar(-0.723608) , btScalar(0.525725),btScalar(0.447219)), -btVector3(btScalar(0.276388) , btScalar(0.850649),btScalar(0.447219)), -btVector3(btScalar(0.894426) , btScalar(0.000000),btScalar(0.447216)), -btVector3(btScalar(-0.000000) , btScalar(0.000000),btScalar(1.000000)), -btVector3(btScalar(0.425323) , btScalar(-0.309011),btScalar(-0.850654)), -btVector3(btScalar(-0.162456) , btScalar(-0.499995),btScalar(-0.850654)), -btVector3(btScalar(0.262869) , btScalar(-0.809012),btScalar(-0.525738)), -btVector3(btScalar(0.425323) , btScalar(0.309011),btScalar(-0.850654)), -btVector3(btScalar(0.850648) , btScalar(-0.000000),btScalar(-0.525736)), -btVector3(btScalar(-0.525730) , btScalar(-0.000000),btScalar(-0.850652)), -btVector3(btScalar(-0.688190) , btScalar(-0.499997),btScalar(-0.525736)), -btVector3(btScalar(-0.162456) , btScalar(0.499995),btScalar(-0.850654)), -btVector3(btScalar(-0.688190) , btScalar(0.499997),btScalar(-0.525736)), -btVector3(btScalar(0.262869) , btScalar(0.809012),btScalar(-0.525738)), -btVector3(btScalar(0.951058) , btScalar(0.309013),btScalar(0.000000)), -btVector3(btScalar(0.951058) , btScalar(-0.309013),btScalar(0.000000)), -btVector3(btScalar(0.587786) , btScalar(-0.809017),btScalar(0.000000)), -btVector3(btScalar(0.000000) , btScalar(-1.000000),btScalar(0.000000)), -btVector3(btScalar(-0.587786) , btScalar(-0.809017),btScalar(0.000000)), -btVector3(btScalar(-0.951058) , btScalar(-0.309013),btScalar(-0.000000)), -btVector3(btScalar(-0.951058) , btScalar(0.309013),btScalar(-0.000000)), -btVector3(btScalar(-0.587786) , btScalar(0.809017),btScalar(-0.000000)), -btVector3(btScalar(-0.000000) , btScalar(1.000000),btScalar(-0.000000)), -btVector3(btScalar(0.587786) , btScalar(0.809017),btScalar(-0.000000)), -btVector3(btScalar(0.688190) , btScalar(-0.499997),btScalar(0.525736)), -btVector3(btScalar(-0.262869) , btScalar(-0.809012),btScalar(0.525738)), -btVector3(btScalar(-0.850648) , btScalar(0.000000),btScalar(0.525736)), -btVector3(btScalar(-0.262869) , btScalar(0.809012),btScalar(0.525738)), -btVector3(btScalar(0.688190) , btScalar(0.499997),btScalar(0.525736)), -btVector3(btScalar(0.525730) , btScalar(0.000000),btScalar(0.850652)), -btVector3(btScalar(0.162456) , btScalar(-0.499995),btScalar(0.850654)), -btVector3(btScalar(-0.425323) , btScalar(-0.309011),btScalar(0.850654)), -btVector3(btScalar(-0.425323) , btScalar(0.309011),btScalar(0.850654)), -btVector3(btScalar(0.162456) , btScalar(0.499995),btScalar(0.850654)) -}; - - -bool SpuMinkowskiPenetrationDepthSolver::calcPenDepth( btSimplexSolverInterface& simplexSolver, - const btConvexShape* convexA,const btConvexShape* convexB, - const btTransform& transA,const btTransform& transB, - btVector3& v, btVector3& pa, btVector3& pb, - class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc) -{ -#if 0 - (void)stackAlloc; - (void)v; - - - struct btIntermediateResult : public SpuContactResult - { - - btIntermediateResult():m_hasResult(false) - { - } - - btVector3 m_normalOnBInWorld; - btVector3 m_pointInWorld; - btScalar m_depth; - bool m_hasResult; - - virtual void setShapeIdentifiersA(int partId0,int index0) - { - (void)partId0; - (void)index0; - } - - virtual void setShapeIdentifiersB(int partId1,int index1) - { - (void)partId1; - (void)index1; - } - void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth) - { - m_normalOnBInWorld = normalOnBInWorld; - m_pointInWorld = pointInWorld; - m_depth = depth; - m_hasResult = true; - } - }; - - //just take fixed number of orientation, and sample the penetration depth in that direction - btScalar minProj = btScalar(BT_LARGE_FLOAT); - btVector3 minNorm(0.f,0.f,0.f); - btVector3 minVertex; - btVector3 minA,minB; - btVector3 seperatingAxisInA,seperatingAxisInB; - btVector3 pInA,qInB,pWorld,qWorld,w; - -//#define USE_BATCHED_SUPPORT 1 -#ifdef USE_BATCHED_SUPPORT - - btVector3 supportVerticesABatch[NUM_UNITSPHERE_POINTS+MAX_PREFERRED_PENETRATION_DIRECTIONS*2]; - btVector3 supportVerticesBBatch[NUM_UNITSPHERE_POINTS+MAX_PREFERRED_PENETRATION_DIRECTIONS*2]; - btVector3 seperatingAxisInABatch[NUM_UNITSPHERE_POINTS+MAX_PREFERRED_PENETRATION_DIRECTIONS*2]; - btVector3 seperatingAxisInBBatch[NUM_UNITSPHERE_POINTS+MAX_PREFERRED_PENETRATION_DIRECTIONS*2]; - int i; - - int numSampleDirections = NUM_UNITSPHERE_POINTS; - - for (i=0;igetNumPreferredPenetrationDirections(); - if (numPDA) - { - for (int i=0;igetPreferredPenetrationDirection(i,norm); - norm = transA.getBasis() * norm; - sPenetrationDirections[numSampleDirections] = norm; - seperatingAxisInABatch[numSampleDirections] = (-norm) * transA.getBasis(); - seperatingAxisInBBatch[numSampleDirections] = norm * transB.getBasis(); - numSampleDirections++; - } - } - } - - { - int numPDB = convexB->getNumPreferredPenetrationDirections(); - if (numPDB) - { - for (int i=0;igetPreferredPenetrationDirection(i,norm); - norm = transB.getBasis() * norm; - sPenetrationDirections[numSampleDirections] = norm; - seperatingAxisInABatch[numSampleDirections] = (-norm) * transA.getBasis(); - seperatingAxisInBBatch[numSampleDirections] = norm * transB.getBasis(); - numSampleDirections++; - } - } - } - - - - convexA->batchedUnitVectorGetSupportingVertexWithoutMargin(seperatingAxisInABatch,supportVerticesABatch,numSampleDirections); - convexB->batchedUnitVectorGetSupportingVertexWithoutMargin(seperatingAxisInBBatch,supportVerticesBBatch,numSampleDirections); - - for (i=0;ilocalGetSupportVertexWithoutMarginNonVirtual( seperatingAxisInA);//, NULL); - qInB = convexB->localGetSupportVertexWithoutMarginNonVirtual(seperatingAxisInB);//, NULL); - - // pInA = convexA->localGetSupportingVertexWithoutMargin(seperatingAxisInA); - // qInB = convexB->localGetSupportingVertexWithoutMargin(seperatingAxisInB); - - pWorld = transA(pInA); - qWorld = transB(qInB); - w = qWorld - pWorld; - btScalar delta = norm.dot(w); - //find smallest delta - if (delta < minProj) - { - minProj = delta; - minNorm = norm; - minA = pWorld; - minB = qWorld; - } - } -#endif //USE_BATCHED_SUPPORT - - //add the margins - - minA += minNorm*marginA; - minB -= minNorm*marginB; - //no penetration - if (minProj < btScalar(0.)) - return false; - - minProj += (marginA + marginB) + btScalar(1.00); - - - - - -//#define DEBUG_DRAW 1 -#ifdef DEBUG_DRAW - if (debugDraw) - { - btVector3 color(0,1,0); - debugDraw->drawLine(minA,minB,color); - color = btVector3 (1,1,1); - btVector3 vec = minB-minA; - btScalar prj2 = minNorm.dot(vec); - debugDraw->drawLine(minA,minA+(minNorm*minProj),color); - - } -#endif //DEBUG_DRAW - - - btGjkPairDetector gjkdet(convexA,convexB,&simplexSolver,0); - - btScalar offsetDist = minProj; - btVector3 offset = minNorm * offsetDist; - - - SpuClosestPointInput input; - input.m_convexVertexData[0] = convexVertexDataA; - input.m_convexVertexData[1] = convexVertexDataB; - btVector3 newOrg = transA.getOrigin() + offset; - - btTransform displacedTrans = transA; - displacedTrans.setOrigin(newOrg); - - input.m_transformA = displacedTrans; - input.m_transformB = transB; - input.m_maximumDistanceSquared = btScalar(BT_LARGE_FLOAT);//minProj; - - btIntermediateResult res; - gjkdet.getClosestPoints(input,res,0); - - btScalar correctedMinNorm = minProj - res.m_depth; - - - //the penetration depth is over-estimated, relax it - btScalar penetration_relaxation= btScalar(1.); - minNorm*=penetration_relaxation; - - if (res.m_hasResult) - { - - pa = res.m_pointInWorld - minNorm * correctedMinNorm; - pb = res.m_pointInWorld; - -#ifdef DEBUG_DRAW - if (debugDraw) - { - btVector3 color(1,0,0); - debugDraw->drawLine(pa,pb,color); - } -#endif//DEBUG_DRAW - - - } else { - // could not seperate shapes - //btAssert (false); - } - return res.m_hasResult; -#endif - return false; -} - - - diff --git a/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuMinkowskiPenetrationDepthSolver.h b/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuMinkowskiPenetrationDepthSolver.h deleted file mode 100644 index ce568d1de..000000000 --- a/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuMinkowskiPenetrationDepthSolver.h +++ /dev/null @@ -1,48 +0,0 @@ - -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef MINKOWSKI_PENETRATION_DEPTH_SOLVER_H -#define MINKOWSKI_PENETRATION_DEPTH_SOLVER_H - - -#include "BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h" - -class btStackAlloc; -class btIDebugDraw; -class btVoronoiSimplexSolver; -class btConvexShape; - -///MinkowskiPenetrationDepthSolver implements bruteforce penetration depth estimation. -///Implementation is based on sampling the depth using support mapping, and using GJK step to get the witness points. -class SpuMinkowskiPenetrationDepthSolver : public btConvexPenetrationDepthSolver -{ -public: - SpuMinkowskiPenetrationDepthSolver() {} - virtual ~SpuMinkowskiPenetrationDepthSolver() {}; - - virtual bool calcPenDepth( btSimplexSolverInterface& simplexSolver, - const btConvexShape* convexA,const btConvexShape* convexB, - const btTransform& transA,const btTransform& transB, - btVector3& v, btVector3& pa, btVector3& pb, - class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc - ); - - -}; - - -#endif //MINKOWSKI_PENETRATION_DEPTH_SOLVER_H - diff --git a/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuPreferredPenetrationDirections.h b/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuPreferredPenetrationDirections.h deleted file mode 100644 index 044e2be88..000000000 --- a/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuPreferredPenetrationDirections.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2007 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef _SPU_PREFERRED_PENETRATION_DIRECTIONS_H -#define _SPU_PREFERRED_PENETRATION_DIRECTIONS_H - - -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" - -int spuGetNumPreferredPenetrationDirections(int shapeType, void* shape) -{ - switch (shapeType) - { - case TRIANGLE_SHAPE_PROXYTYPE: - { - return 2; - //spu_printf("2\n"); - break; - } - default: - { -#if __ASSERT - spu_printf("spuGetNumPreferredPenetrationDirections() - Unsupported bound type: %d.\n", shapeType); -#endif // __ASSERT - } - } - - return 0; -} - -void spuGetPreferredPenetrationDirection(int shapeType, void* shape, int index, btVector3& penetrationVector) -{ - - - switch (shapeType) - { - case TRIANGLE_SHAPE_PROXYTYPE: - { - btVector3* vertices = (btVector3*)shape; - ///calcNormal - penetrationVector = (vertices[1]-vertices[0]).cross(vertices[2]-vertices[0]); - penetrationVector.normalize(); - if (index) - penetrationVector *= btScalar(-1.); - break; - } - default: - { - -#if __ASSERT - spu_printf("spuGetNumPreferredPenetrationDirections() - Unsupported bound type: %d.\n", shapeType); -#endif // __ASSERT - } - } - -} - -#endif //_SPU_PREFERRED_PENETRATION_DIRECTIONS_H diff --git a/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/boxBoxDistance.cpp b/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/boxBoxDistance.cpp deleted file mode 100644 index ad7fc2633..000000000 --- a/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/boxBoxDistance.cpp +++ /dev/null @@ -1,1155 +0,0 @@ -/* - Copyright (C) 2006, 2008 Sony Computer Entertainment Inc. - All rights reserved. - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. - -*/ - - -#include "Box.h" - -static inline float sqr( float a ) -{ - return (a * a); -} - -enum BoxSepAxisType -{ - A_AXIS, B_AXIS, CROSS_AXIS -}; - -//------------------------------------------------------------------------------------------------- -// voronoiTol: bevels Voronoi planes slightly which helps when features are parallel. -//------------------------------------------------------------------------------------------------- - -static const float voronoiTol = -1.0e-5f; - -//------------------------------------------------------------------------------------------------- -// separating axis tests: gaps along each axis are computed, and the axis with the maximum -// gap is stored. cross product axes are normalized. -//------------------------------------------------------------------------------------------------- - -#define AaxisTest( dim, letter, first ) \ -{ \ - if ( first ) \ - { \ - maxGap = gap = gapsA.get##letter(); \ - if ( gap > distanceThreshold ) return gap; \ - axisType = A_AXIS; \ - faceDimA = dim; \ - axisA = identity.getCol##dim(); \ - } \ - else \ - { \ - gap = gapsA.get##letter(); \ - if ( gap > distanceThreshold ) return gap; \ - else if ( gap > maxGap ) \ - { \ - maxGap = gap; \ - axisType = A_AXIS; \ - faceDimA = dim; \ - axisA = identity.getCol##dim(); \ - } \ - } \ -} - - -#define BaxisTest( dim, letter ) \ -{ \ - gap = gapsB.get##letter(); \ - if ( gap > distanceThreshold ) return gap; \ - else if ( gap > maxGap ) \ - { \ - maxGap = gap; \ - axisType = B_AXIS; \ - faceDimB = dim; \ - axisB = identity.getCol##dim(); \ - } \ -} - -#define CrossAxisTest( dima, dimb, letterb ) \ -{ \ - const float lsqr_tolerance = 1.0e-30f; \ - float lsqr; \ - \ - lsqr = lsqrs.getCol##dima().get##letterb(); \ - \ - if ( lsqr > lsqr_tolerance ) \ - { \ - float l_recip = 1.0f / sqrtf( lsqr ); \ - gap = float(gapsAxB.getCol##dima().get##letterb()) * l_recip; \ - \ - if ( gap > distanceThreshold ) \ - { \ - return gap; \ - } \ - \ - if ( gap > maxGap ) \ - { \ - maxGap = gap; \ - axisType = CROSS_AXIS; \ - edgeDimA = dima; \ - edgeDimB = dimb; \ - axisA = cross(identity.getCol##dima(),matrixAB.getCol##dimb()) * l_recip; \ - } \ - } \ -} - -//------------------------------------------------------------------------------------------------- -// tests whether a vertex of box B and a face of box A are the closest features -//------------------------------------------------------------------------------------------------- - -inline -float -VertexBFaceATest( - bool & inVoronoi, - float & t0, - float & t1, - const Vector3 & hA, - PE_REF(Vector3) faceOffsetAB, - PE_REF(Vector3) faceOffsetBA, - const Matrix3 & matrixAB, - const Matrix3 & matrixBA, - PE_REF(Vector3) signsB, - PE_REF(Vector3) scalesB ) -{ - // compute a corner of box B in A's coordinate system - - Vector3 corner = - Vector3( faceOffsetAB + matrixAB.getCol0() * scalesB.getX() + matrixAB.getCol1() * scalesB.getY() ); - - // compute the parameters of the point on A, closest to this corner - - t0 = corner[0]; - t1 = corner[1]; - - if ( t0 > hA[0] ) - t0 = hA[0]; - else if ( t0 < -hA[0] ) - t0 = -hA[0]; - if ( t1 > hA[1] ) - t1 = hA[1]; - else if ( t1 < -hA[1] ) - t1 = -hA[1]; - - // do the Voronoi test: already know the point on B is in the Voronoi region of the - // point on A, check the reverse. - - Vector3 facePointB = - Vector3( mulPerElem( faceOffsetBA + matrixBA.getCol0() * t0 + matrixBA.getCol1() * t1 - scalesB, signsB ) ); - - inVoronoi = ( ( facePointB[0] >= voronoiTol * facePointB[2] ) && - ( facePointB[1] >= voronoiTol * facePointB[0] ) && - ( facePointB[2] >= voronoiTol * facePointB[1] ) ); - - return (sqr( corner[0] - t0 ) + sqr( corner[1] - t1 ) + sqr( corner[2] )); -} - -#define VertexBFaceA_SetNewMin() \ -{ \ - minDistSqr = distSqr; \ - localPointA.setX(t0); \ - localPointA.setY(t1); \ - localPointB.setX( scalesB.getX() ); \ - localPointB.setY( scalesB.getY() ); \ - featureA = F; \ - featureB = V; \ -} - -void -VertexBFaceATests( - bool & done, - float & minDistSqr, - Point3 & localPointA, - Point3 & localPointB, - FeatureType & featureA, - FeatureType & featureB, - const Vector3 & hA, - PE_REF(Vector3) faceOffsetAB, - PE_REF(Vector3) faceOffsetBA, - const Matrix3 & matrixAB, - const Matrix3 & matrixBA, - PE_REF(Vector3) signsB, - PE_REF(Vector3) scalesB, - bool first ) -{ - - float t0, t1; - float distSqr; - - distSqr = VertexBFaceATest( done, t0, t1, hA, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsB, scalesB ); - - if ( first ) { - VertexBFaceA_SetNewMin(); - } else { - if ( distSqr < minDistSqr ) { - VertexBFaceA_SetNewMin(); - } - } - - if ( done ) - return; - - signsB.setX( -signsB.getX() ); - scalesB.setX( -scalesB.getX() ); - - distSqr = VertexBFaceATest( done, t0, t1, hA, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsB, scalesB ); - - if ( distSqr < minDistSqr ) { - VertexBFaceA_SetNewMin(); - } - - if ( done ) - return; - - signsB.setY( -signsB.getY() ); - scalesB.setY( -scalesB.getY() ); - - distSqr = VertexBFaceATest( done, t0, t1, hA, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsB, scalesB ); - - if ( distSqr < minDistSqr ) { - VertexBFaceA_SetNewMin(); - } - - if ( done ) - return; - - signsB.setX( -signsB.getX() ); - scalesB.setX( -scalesB.getX() ); - - distSqr = VertexBFaceATest( done, t0, t1, hA, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsB, scalesB ); - - if ( distSqr < minDistSqr ) { - VertexBFaceA_SetNewMin(); - } -} - -//------------------------------------------------------------------------------------------------- -// VertexAFaceBTest: tests whether a vertex of box A and a face of box B are the closest features -//------------------------------------------------------------------------------------------------- - -inline -float -VertexAFaceBTest( - bool & inVoronoi, - float & t0, - float & t1, - const Vector3 & hB, - PE_REF(Vector3) faceOffsetAB, - PE_REF(Vector3) faceOffsetBA, - const Matrix3 & matrixAB, - const Matrix3 & matrixBA, - PE_REF(Vector3) signsA, - PE_REF(Vector3) scalesA ) -{ - Vector3 corner = - Vector3( faceOffsetBA + matrixBA.getCol0() * scalesA.getX() + matrixBA.getCol1() * scalesA.getY() ); - - t0 = corner[0]; - t1 = corner[1]; - - if ( t0 > hB[0] ) - t0 = hB[0]; - else if ( t0 < -hB[0] ) - t0 = -hB[0]; - if ( t1 > hB[1] ) - t1 = hB[1]; - else if ( t1 < -hB[1] ) - t1 = -hB[1]; - - Vector3 facePointA = - Vector3( mulPerElem( faceOffsetAB + matrixAB.getCol0() * t0 + matrixAB.getCol1() * t1 - scalesA, signsA ) ); - - inVoronoi = ( ( facePointA[0] >= voronoiTol * facePointA[2] ) && - ( facePointA[1] >= voronoiTol * facePointA[0] ) && - ( facePointA[2] >= voronoiTol * facePointA[1] ) ); - - return (sqr( corner[0] - t0 ) + sqr( corner[1] - t1 ) + sqr( corner[2] )); -} - -#define VertexAFaceB_SetNewMin() \ -{ \ - minDistSqr = distSqr; \ - localPointB.setX(t0); \ - localPointB.setY(t1); \ - localPointA.setX( scalesA.getX() ); \ - localPointA.setY( scalesA.getY() ); \ - featureA = V; \ - featureB = F; \ -} - -void -VertexAFaceBTests( - bool & done, - float & minDistSqr, - Point3 & localPointA, - Point3 & localPointB, - FeatureType & featureA, - FeatureType & featureB, - const Vector3 & hB, - PE_REF(Vector3) faceOffsetAB, - PE_REF(Vector3) faceOffsetBA, - const Matrix3 & matrixAB, - const Matrix3 & matrixBA, - PE_REF(Vector3) signsA, - PE_REF(Vector3) scalesA, - bool first ) -{ - float t0, t1; - float distSqr; - - distSqr = VertexAFaceBTest( done, t0, t1, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, scalesA ); - - if ( first ) { - VertexAFaceB_SetNewMin(); - } else { - if ( distSqr < minDistSqr ) { - VertexAFaceB_SetNewMin(); - } - } - - if ( done ) - return; - - signsA.setX( -signsA.getX() ); - scalesA.setX( -scalesA.getX() ); - - distSqr = VertexAFaceBTest( done, t0, t1, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, scalesA ); - - if ( distSqr < minDistSqr ) { - VertexAFaceB_SetNewMin(); - } - - if ( done ) - return; - - signsA.setY( -signsA.getY() ); - scalesA.setY( -scalesA.getY() ); - - distSqr = VertexAFaceBTest( done, t0, t1, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, scalesA ); - - if ( distSqr < minDistSqr ) { - VertexAFaceB_SetNewMin(); - } - - if ( done ) - return; - - signsA.setX( -signsA.getX() ); - scalesA.setX( -scalesA.getX() ); - - distSqr = VertexAFaceBTest( done, t0, t1, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, scalesA ); - - if ( distSqr < minDistSqr ) { - VertexAFaceB_SetNewMin(); - } -} - -//------------------------------------------------------------------------------------------------- -// EdgeEdgeTest: -// -// tests whether a pair of edges are the closest features -// -// note on the shorthand: -// 'a' & 'b' refer to the edges. -// 'c' is the dimension of the axis that points from the face center to the edge Center -// 'd' is the dimension of the edge Direction -// the dimension of the face normal is 2 -//------------------------------------------------------------------------------------------------- - -#define EdgeEdgeTest( ac, ac_letter, ad, ad_letter, bc, bc_letter, bd, bd_letter ) \ -{ \ - Vector3 edgeOffsetAB; \ - Vector3 edgeOffsetBA; \ - \ - edgeOffsetAB = faceOffsetAB + matrixAB.getCol##bc() * scalesB.get##bc_letter(); \ - edgeOffsetAB.set##ac_letter( edgeOffsetAB.get##ac_letter() - scalesA.get##ac_letter() ); \ - \ - edgeOffsetBA = faceOffsetBA + matrixBA.getCol##ac() * scalesA.get##ac_letter(); \ - edgeOffsetBA.set##bc_letter( edgeOffsetBA.get##bc_letter() - scalesB.get##bc_letter() ); \ - \ - float dirDot = matrixAB.getCol##bd().get##ad_letter(); \ - float denom = 1.0f - dirDot*dirDot; \ - float edgeOffsetAB_ad = edgeOffsetAB.get##ad_letter(); \ - float edgeOffsetBA_bd = edgeOffsetBA.get##bd_letter(); \ - \ - if ( denom == 0.0f ) \ - { \ - tA = 0.0f; \ - } \ - else \ - { \ - tA = ( edgeOffsetAB_ad + edgeOffsetBA_bd * dirDot ) / denom; \ - } \ - \ - if ( tA < -hA[ad] ) tA = -hA[ad]; \ - else if ( tA > hA[ad] ) tA = hA[ad]; \ - \ - tB = tA * dirDot + edgeOffsetBA_bd; \ - \ - if ( tB < -hB[bd] ) \ - { \ - tB = -hB[bd]; \ - tA = tB * dirDot + edgeOffsetAB_ad; \ - \ - if ( tA < -hA[ad] ) tA = -hA[ad]; \ - else if ( tA > hA[ad] ) tA = hA[ad]; \ - } \ - else if ( tB > hB[bd] ) \ - { \ - tB = hB[bd]; \ - tA = tB * dirDot + edgeOffsetAB_ad; \ - \ - if ( tA < -hA[ad] ) tA = -hA[ad]; \ - else if ( tA > hA[ad] ) tA = hA[ad]; \ - } \ - \ - Vector3 edgeOffAB = Vector3( mulPerElem( edgeOffsetAB + matrixAB.getCol##bd() * tB, signsA ) );\ - Vector3 edgeOffBA = Vector3( mulPerElem( edgeOffsetBA + matrixBA.getCol##ad() * tA, signsB ) );\ - \ - inVoronoi = ( edgeOffAB[ac] >= voronoiTol * edgeOffAB[2] ) && \ - ( edgeOffAB[2] >= voronoiTol * edgeOffAB[ac] ) && \ - ( edgeOffBA[bc] >= voronoiTol * edgeOffBA[2] ) && \ - ( edgeOffBA[2] >= voronoiTol * edgeOffBA[bc] ); \ - \ - edgeOffAB[ad] -= tA; \ - edgeOffBA[bd] -= tB; \ - \ - return dot(edgeOffAB,edgeOffAB); \ -} - -float -EdgeEdgeTest_0101( - bool & inVoronoi, - float & tA, - float & tB, - const Vector3 & hA, - const Vector3 & hB, - PE_REF(Vector3) faceOffsetAB, - PE_REF(Vector3) faceOffsetBA, - const Matrix3 & matrixAB, - const Matrix3 & matrixBA, - PE_REF(Vector3) signsA, - PE_REF(Vector3) signsB, - PE_REF(Vector3) scalesA, - PE_REF(Vector3) scalesB ) -{ - EdgeEdgeTest( 0, X, 1, Y, 0, X, 1, Y ); -} - -float -EdgeEdgeTest_0110( - bool & inVoronoi, - float & tA, - float & tB, - const Vector3 & hA, - const Vector3 & hB, - PE_REF(Vector3) faceOffsetAB, - PE_REF(Vector3) faceOffsetBA, - const Matrix3 & matrixAB, - const Matrix3 & matrixBA, - PE_REF(Vector3) signsA, - PE_REF(Vector3) signsB, - PE_REF(Vector3) scalesA, - PE_REF(Vector3) scalesB ) -{ - EdgeEdgeTest( 0, X, 1, Y, 1, Y, 0, X ); -} - -float -EdgeEdgeTest_1001( - bool & inVoronoi, - float & tA, - float & tB, - const Vector3 & hA, - const Vector3 & hB, - PE_REF(Vector3) faceOffsetAB, - PE_REF(Vector3) faceOffsetBA, - const Matrix3 & matrixAB, - const Matrix3 & matrixBA, - PE_REF(Vector3) signsA, - PE_REF(Vector3) signsB, - PE_REF(Vector3) scalesA, - PE_REF(Vector3) scalesB ) -{ - EdgeEdgeTest( 1, Y, 0, X, 0, X, 1, Y ); -} - -float -EdgeEdgeTest_1010( - bool & inVoronoi, - float & tA, - float & tB, - const Vector3 & hA, - const Vector3 & hB, - PE_REF(Vector3) faceOffsetAB, - PE_REF(Vector3) faceOffsetBA, - const Matrix3 & matrixAB, - const Matrix3 & matrixBA, - PE_REF(Vector3) signsA, - PE_REF(Vector3) signsB, - PE_REF(Vector3) scalesA, - PE_REF(Vector3) scalesB ) -{ - EdgeEdgeTest( 1, Y, 0, X, 1, Y, 0, X ); -} - -#define EdgeEdge_SetNewMin( ac_letter, ad_letter, bc_letter, bd_letter ) \ -{ \ - minDistSqr = distSqr; \ - localPointA.set##ac_letter(scalesA.get##ac_letter()); \ - localPointA.set##ad_letter(tA); \ - localPointB.set##bc_letter(scalesB.get##bc_letter()); \ - localPointB.set##bd_letter(tB); \ - otherFaceDimA = testOtherFaceDimA; \ - otherFaceDimB = testOtherFaceDimB; \ - featureA = E; \ - featureB = E; \ -} - -void -EdgeEdgeTests( - bool & done, - float & minDistSqr, - Point3 & localPointA, - Point3 & localPointB, - int & otherFaceDimA, - int & otherFaceDimB, - FeatureType & featureA, - FeatureType & featureB, - const Vector3 & hA, - const Vector3 & hB, - PE_REF(Vector3) faceOffsetAB, - PE_REF(Vector3) faceOffsetBA, - const Matrix3 & matrixAB, - const Matrix3 & matrixBA, - PE_REF(Vector3) signsA, - PE_REF(Vector3) signsB, - PE_REF(Vector3) scalesA, - PE_REF(Vector3) scalesB, - bool first ) -{ - - float distSqr; - float tA, tB; - - int testOtherFaceDimA, testOtherFaceDimB; - - testOtherFaceDimA = 0; - testOtherFaceDimB = 0; - - distSqr = EdgeEdgeTest_0101( done, tA, tB, hA, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, signsB, scalesA, scalesB ); - - if ( first ) { - EdgeEdge_SetNewMin( X, Y, X, Y ); - } else { - if ( distSqr < minDistSqr ) { - EdgeEdge_SetNewMin( X, Y, X, Y ); - } - } - - if ( done ) - return; - - signsA.setX( -signsA.getX() ); - scalesA.setX( -scalesA.getX() ); - - distSqr = EdgeEdgeTest_0101( done, tA, tB, hA, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, signsB, scalesA, scalesB ); - - if ( distSqr < minDistSqr ) { - EdgeEdge_SetNewMin( X, Y, X, Y ); - } - - if ( done ) - return; - - signsB.setX( -signsB.getX() ); - scalesB.setX( -scalesB.getX() ); - - distSqr = EdgeEdgeTest_0101( done, tA, tB, hA, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, signsB, scalesA, scalesB ); - - if ( distSqr < minDistSqr ) { - EdgeEdge_SetNewMin( X, Y, X, Y ); - } - - if ( done ) - return; - - signsA.setX( -signsA.getX() ); - scalesA.setX( -scalesA.getX() ); - - distSqr = EdgeEdgeTest_0101( done, tA, tB, hA, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, signsB, scalesA, scalesB ); - - if ( distSqr < minDistSqr ) { - EdgeEdge_SetNewMin( X, Y, X, Y ); - } - - if ( done ) - return; - - testOtherFaceDimA = 1; - testOtherFaceDimB = 0; - signsB.setX( -signsB.getX() ); - scalesB.setX( -scalesB.getX() ); - - distSqr = EdgeEdgeTest_1001( done, tA, tB, hA, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, signsB, scalesA, scalesB ); - - if ( distSqr < minDistSqr ) { - EdgeEdge_SetNewMin( Y, X, X, Y ); - } - - if ( done ) - return; - - signsA.setY( -signsA.getY() ); - scalesA.setY( -scalesA.getY() ); - - distSqr = EdgeEdgeTest_1001( done, tA, tB, hA, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, signsB, scalesA, scalesB ); - - if ( distSqr < minDistSqr ) { - EdgeEdge_SetNewMin( Y, X, X, Y ); - } - - if ( done ) - return; - - signsB.setX( -signsB.getX() ); - scalesB.setX( -scalesB.getX() ); - - distSqr = EdgeEdgeTest_1001( done, tA, tB, hA, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, signsB, scalesA, scalesB ); - - if ( distSqr < minDistSqr ) { - EdgeEdge_SetNewMin( Y, X, X, Y ); - } - - if ( done ) - return; - - signsA.setY( -signsA.getY() ); - scalesA.setY( -scalesA.getY() ); - - distSqr = EdgeEdgeTest_1001( done, tA, tB, hA, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, signsB, scalesA, scalesB ); - - if ( distSqr < minDistSqr ) { - EdgeEdge_SetNewMin( Y, X, X, Y ); - } - - if ( done ) - return; - - testOtherFaceDimA = 0; - testOtherFaceDimB = 1; - signsB.setX( -signsB.getX() ); - scalesB.setX( -scalesB.getX() ); - - distSqr = EdgeEdgeTest_0110( done, tA, tB, hA, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, signsB, scalesA, scalesB ); - - if ( distSqr < minDistSqr ) { - EdgeEdge_SetNewMin( X, Y, Y, X ); - } - - if ( done ) - return; - - signsA.setX( -signsA.getX() ); - scalesA.setX( -scalesA.getX() ); - - distSqr = EdgeEdgeTest_0110( done, tA, tB, hA, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, signsB, scalesA, scalesB ); - - if ( distSqr < minDistSqr ) { - EdgeEdge_SetNewMin( X, Y, Y, X ); - } - - if ( done ) - return; - - signsB.setY( -signsB.getY() ); - scalesB.setY( -scalesB.getY() ); - - distSqr = EdgeEdgeTest_0110( done, tA, tB, hA, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, signsB, scalesA, scalesB ); - - if ( distSqr < minDistSqr ) { - EdgeEdge_SetNewMin( X, Y, Y, X ); - } - - if ( done ) - return; - - signsA.setX( -signsA.getX() ); - scalesA.setX( -scalesA.getX() ); - - distSqr = EdgeEdgeTest_0110( done, tA, tB, hA, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, signsB, scalesA, scalesB ); - - if ( distSqr < minDistSqr ) { - EdgeEdge_SetNewMin( X, Y, Y, X ); - } - - if ( done ) - return; - - testOtherFaceDimA = 1; - testOtherFaceDimB = 1; - signsB.setY( -signsB.getY() ); - scalesB.setY( -scalesB.getY() ); - - distSqr = EdgeEdgeTest_1010( done, tA, tB, hA, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, signsB, scalesA, scalesB ); - - if ( distSqr < minDistSqr ) { - EdgeEdge_SetNewMin( Y, X, Y, X ); - } - - if ( done ) - return; - - signsA.setY( -signsA.getY() ); - scalesA.setY( -scalesA.getY() ); - - distSqr = EdgeEdgeTest_1010( done, tA, tB, hA, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, signsB, scalesA, scalesB ); - - if ( distSqr < minDistSqr ) { - EdgeEdge_SetNewMin( Y, X, Y, X ); - } - - if ( done ) - return; - - signsB.setY( -signsB.getY() ); - scalesB.setY( -scalesB.getY() ); - - distSqr = EdgeEdgeTest_1010( done, tA, tB, hA, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, signsB, scalesA, scalesB ); - - if ( distSqr < minDistSqr ) { - EdgeEdge_SetNewMin( Y, X, Y, X ); - } - - if ( done ) - return; - - signsA.setY( -signsA.getY() ); - scalesA.setY( -scalesA.getY() ); - - distSqr = EdgeEdgeTest_1010( done, tA, tB, hA, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, signsB, scalesA, scalesB ); - - if ( distSqr < minDistSqr ) { - EdgeEdge_SetNewMin( Y, X, Y, X ); - } -} - -float -boxBoxDistance( - Vector3& normal, - BoxPoint& boxPointA, - BoxPoint& boxPointB, - PE_REF(Box) boxA, const Transform3& transformA, - PE_REF(Box) boxB, const Transform3& transformB, - float distanceThreshold ) -{ - Matrix3 identity; - identity = Matrix3::identity(); - Vector3 ident[3]; - ident[0] = identity.getCol0(); - ident[1] = identity.getCol1(); - ident[2] = identity.getCol2(); - - // get relative transformations - - Transform3 transformAB, transformBA; - Matrix3 matrixAB, matrixBA; - Vector3 offsetAB, offsetBA; - - transformAB = orthoInverse(transformA) * transformB; - transformBA = orthoInverse(transformAB); - - matrixAB = transformAB.getUpper3x3(); - offsetAB = transformAB.getTranslation(); - matrixBA = transformBA.getUpper3x3(); - offsetBA = transformBA.getTranslation(); - - Matrix3 absMatrixAB = absPerElem(matrixAB); - Matrix3 absMatrixBA = absPerElem(matrixBA); - - // find separating axis with largest gap between projections - - BoxSepAxisType axisType; - Vector3 axisA(0.0f), axisB(0.0f); - float gap, maxGap; - int faceDimA = 0, faceDimB = 0, edgeDimA = 0, edgeDimB = 0; - - // face axes - - Vector3 gapsA = absPerElem(offsetAB) - boxA.half - absMatrixAB * boxB.half; - - AaxisTest(0,X,true); - AaxisTest(1,Y,false); - AaxisTest(2,Z,false); - - Vector3 gapsB = absPerElem(offsetBA) - boxB.half - absMatrixBA * boxA.half; - - BaxisTest(0,X); - BaxisTest(1,Y); - BaxisTest(2,Z); - - // cross product axes - - // OςÔƂ̑΍ - absMatrixAB += Matrix3(1.0e-5f); - absMatrixBA += Matrix3(1.0e-5f); - - Matrix3 lsqrs, projOffset, projAhalf, projBhalf; - - lsqrs.setCol0( mulPerElem( matrixBA.getCol2(), matrixBA.getCol2() ) + - mulPerElem( matrixBA.getCol1(), matrixBA.getCol1() ) ); - lsqrs.setCol1( mulPerElem( matrixBA.getCol2(), matrixBA.getCol2() ) + - mulPerElem( matrixBA.getCol0(), matrixBA.getCol0() ) ); - lsqrs.setCol2( mulPerElem( matrixBA.getCol1(), matrixBA.getCol1() ) + - mulPerElem( matrixBA.getCol0(), matrixBA.getCol0() ) ); - - projOffset.setCol0(matrixBA.getCol1() * offsetAB.getZ() - matrixBA.getCol2() * offsetAB.getY()); - projOffset.setCol1(matrixBA.getCol2() * offsetAB.getX() - matrixBA.getCol0() * offsetAB.getZ()); - projOffset.setCol2(matrixBA.getCol0() * offsetAB.getY() - matrixBA.getCol1() * offsetAB.getX()); - - projAhalf.setCol0(absMatrixBA.getCol1() * boxA.half.getZ() + absMatrixBA.getCol2() * boxA.half.getY()); - projAhalf.setCol1(absMatrixBA.getCol2() * boxA.half.getX() + absMatrixBA.getCol0() * boxA.half.getZ()); - projAhalf.setCol2(absMatrixBA.getCol0() * boxA.half.getY() + absMatrixBA.getCol1() * boxA.half.getX()); - - projBhalf.setCol0(absMatrixAB.getCol1() * boxB.half.getZ() + absMatrixAB.getCol2() * boxB.half.getY()); - projBhalf.setCol1(absMatrixAB.getCol2() * boxB.half.getX() + absMatrixAB.getCol0() * boxB.half.getZ()); - projBhalf.setCol2(absMatrixAB.getCol0() * boxB.half.getY() + absMatrixAB.getCol1() * boxB.half.getX()); - - Matrix3 gapsAxB = absPerElem(projOffset) - projAhalf - transpose(projBhalf); - - CrossAxisTest(0,0,X); - CrossAxisTest(0,1,Y); - CrossAxisTest(0,2,Z); - CrossAxisTest(1,0,X); - CrossAxisTest(1,1,Y); - CrossAxisTest(1,2,Z); - CrossAxisTest(2,0,X); - CrossAxisTest(2,1,Y); - CrossAxisTest(2,2,Z); - - // need to pick the face on each box whose normal best matches the separating axis. - // will transform vectors to be in the coordinate system of this face to simplify things later. - // for this, a permutation matrix can be used, which the next section computes. - - int dimA[3], dimB[3]; - - if ( axisType == A_AXIS ) { - if ( dot(axisA,offsetAB) < 0.0f ) - axisA = -axisA; - axisB = matrixBA * -axisA; - - Vector3 absAxisB = Vector3(absPerElem(axisB)); - - if ( ( absAxisB[0] > absAxisB[1] ) && ( absAxisB[0] > absAxisB[2] ) ) - faceDimB = 0; - else if ( absAxisB[1] > absAxisB[2] ) - faceDimB = 1; - else - faceDimB = 2; - } else if ( axisType == B_AXIS ) { - if ( dot(axisB,offsetBA) < 0.0f ) - axisB = -axisB; - axisA = matrixAB * -axisB; - - Vector3 absAxisA = Vector3(absPerElem(axisA)); - - if ( ( absAxisA[0] > absAxisA[1] ) && ( absAxisA[0] > absAxisA[2] ) ) - faceDimA = 0; - else if ( absAxisA[1] > absAxisA[2] ) - faceDimA = 1; - else - faceDimA = 2; - } - - if ( axisType == CROSS_AXIS ) { - if ( dot(axisA,offsetAB) < 0.0f ) - axisA = -axisA; - axisB = matrixBA * -axisA; - - Vector3 absAxisA = Vector3(absPerElem(axisA)); - Vector3 absAxisB = Vector3(absPerElem(axisB)); - - dimA[1] = edgeDimA; - dimB[1] = edgeDimB; - - if ( edgeDimA == 0 ) { - if ( absAxisA[1] > absAxisA[2] ) { - dimA[0] = 2; - dimA[2] = 1; - } else { - dimA[0] = 1; - dimA[2] = 2; - } - } else if ( edgeDimA == 1 ) { - if ( absAxisA[2] > absAxisA[0] ) { - dimA[0] = 0; - dimA[2] = 2; - } else { - dimA[0] = 2; - dimA[2] = 0; - } - } else { - if ( absAxisA[0] > absAxisA[1] ) { - dimA[0] = 1; - dimA[2] = 0; - } else { - dimA[0] = 0; - dimA[2] = 1; - } - } - - if ( edgeDimB == 0 ) { - if ( absAxisB[1] > absAxisB[2] ) { - dimB[0] = 2; - dimB[2] = 1; - } else { - dimB[0] = 1; - dimB[2] = 2; - } - } else if ( edgeDimB == 1 ) { - if ( absAxisB[2] > absAxisB[0] ) { - dimB[0] = 0; - dimB[2] = 2; - } else { - dimB[0] = 2; - dimB[2] = 0; - } - } else { - if ( absAxisB[0] > absAxisB[1] ) { - dimB[0] = 1; - dimB[2] = 0; - } else { - dimB[0] = 0; - dimB[2] = 1; - } - } - } else { - dimA[2] = faceDimA; - dimA[0] = (faceDimA+1)%3; - dimA[1] = (faceDimA+2)%3; - dimB[2] = faceDimB; - dimB[0] = (faceDimB+1)%3; - dimB[1] = (faceDimB+2)%3; - } - - Matrix3 aperm_col, bperm_col; - - aperm_col.setCol0(ident[dimA[0]]); - aperm_col.setCol1(ident[dimA[1]]); - aperm_col.setCol2(ident[dimA[2]]); - - bperm_col.setCol0(ident[dimB[0]]); - bperm_col.setCol1(ident[dimB[1]]); - bperm_col.setCol2(ident[dimB[2]]); - - Matrix3 aperm_row, bperm_row; - - aperm_row = transpose(aperm_col); - bperm_row = transpose(bperm_col); - - // permute all box parameters to be in the face coordinate systems - - Matrix3 matrixAB_perm = aperm_row * matrixAB * bperm_col; - Matrix3 matrixBA_perm = transpose(matrixAB_perm); - - Vector3 offsetAB_perm, offsetBA_perm; - - offsetAB_perm = aperm_row * offsetAB; - offsetBA_perm = bperm_row * offsetBA; - - Vector3 halfA_perm, halfB_perm; - - halfA_perm = aperm_row * boxA.half; - halfB_perm = bperm_row * boxB.half; - - // compute the vector between the centers of each face, in each face's coordinate frame - - Vector3 signsA_perm, signsB_perm, scalesA_perm, scalesB_perm, faceOffsetAB_perm, faceOffsetBA_perm; - - signsA_perm = copySignPerElem(Vector3(1.0f),aperm_row * axisA); - signsB_perm = copySignPerElem(Vector3(1.0f),bperm_row * axisB); - scalesA_perm = mulPerElem( signsA_perm, halfA_perm ); - scalesB_perm = mulPerElem( signsB_perm, halfB_perm ); - - faceOffsetAB_perm = offsetAB_perm + matrixAB_perm.getCol2() * scalesB_perm.getZ(); - faceOffsetAB_perm.setZ( faceOffsetAB_perm.getZ() - scalesA_perm.getZ() ); - - faceOffsetBA_perm = offsetBA_perm + matrixBA_perm.getCol2() * scalesA_perm.getZ(); - faceOffsetBA_perm.setZ( faceOffsetBA_perm.getZ() - scalesB_perm.getZ() ); - - if ( maxGap < 0.0f ) { - // if boxes overlap, this will separate the faces for finding points of penetration. - - faceOffsetAB_perm -= aperm_row * axisA * maxGap * 1.01f; - faceOffsetBA_perm -= bperm_row * axisB * maxGap * 1.01f; - } - - // for each vertex/face or edge/edge pair of the two faces, find the closest points. - // - // these points each have an associated box feature (vertex, edge, or face). if each - // point is in the external Voronoi region of the other's feature, they are the - // closest points of the boxes, and the algorithm can exit. - // - // the feature pairs are arranged so that in the general case, the first test will - // succeed. degenerate cases (parallel faces) may require up to all tests in the - // worst case. - // - // if for some reason no case passes the Voronoi test, the features with the minimum - // distance are returned. - - Point3 localPointA_perm, localPointB_perm; - float minDistSqr; - bool done; - - Vector3 hA_perm( halfA_perm ), hB_perm( halfB_perm ); - - localPointA_perm.setZ( scalesA_perm.getZ() ); - localPointB_perm.setZ( scalesB_perm.getZ() ); - scalesA_perm.setZ(0.0f); - scalesB_perm.setZ(0.0f); - - int otherFaceDimA, otherFaceDimB; - FeatureType featureA, featureB; - - if ( axisType == CROSS_AXIS ) { - EdgeEdgeTests( done, minDistSqr, localPointA_perm, localPointB_perm, - otherFaceDimA, otherFaceDimB, featureA, featureB, - hA_perm, hB_perm, faceOffsetAB_perm, faceOffsetBA_perm, - matrixAB_perm, matrixBA_perm, signsA_perm, signsB_perm, - scalesA_perm, scalesB_perm, true ); - - if ( !done ) { - VertexBFaceATests( done, minDistSqr, localPointA_perm, localPointB_perm, - featureA, featureB, - hA_perm, faceOffsetAB_perm, faceOffsetBA_perm, - matrixAB_perm, matrixBA_perm, signsB_perm, scalesB_perm, false ); - - if ( !done ) { - VertexAFaceBTests( done, minDistSqr, localPointA_perm, localPointB_perm, - featureA, featureB, - hB_perm, faceOffsetAB_perm, faceOffsetBA_perm, - matrixAB_perm, matrixBA_perm, signsA_perm, scalesA_perm, false ); - } - } - } else if ( axisType == B_AXIS ) { - VertexAFaceBTests( done, minDistSqr, localPointA_perm, localPointB_perm, - featureA, featureB, - hB_perm, faceOffsetAB_perm, faceOffsetBA_perm, - matrixAB_perm, matrixBA_perm, signsA_perm, scalesA_perm, true ); - - if ( !done ) { - VertexBFaceATests( done, minDistSqr, localPointA_perm, localPointB_perm, - featureA, featureB, - hA_perm, faceOffsetAB_perm, faceOffsetBA_perm, - matrixAB_perm, matrixBA_perm, signsB_perm, scalesB_perm, false ); - - if ( !done ) { - EdgeEdgeTests( done, minDistSqr, localPointA_perm, localPointB_perm, - otherFaceDimA, otherFaceDimB, featureA, featureB, - hA_perm, hB_perm, faceOffsetAB_perm, faceOffsetBA_perm, - matrixAB_perm, matrixBA_perm, signsA_perm, signsB_perm, - scalesA_perm, scalesB_perm, false ); - } - } - } else { - VertexBFaceATests( done, minDistSqr, localPointA_perm, localPointB_perm, - featureA, featureB, - hA_perm, faceOffsetAB_perm, faceOffsetBA_perm, - matrixAB_perm, matrixBA_perm, signsB_perm, scalesB_perm, true ); - - if ( !done ) { - VertexAFaceBTests( done, minDistSqr, localPointA_perm, localPointB_perm, - featureA, featureB, - hB_perm, faceOffsetAB_perm, faceOffsetBA_perm, - matrixAB_perm, matrixBA_perm, signsA_perm, scalesA_perm, false ); - - if ( !done ) { - EdgeEdgeTests( done, minDistSqr, localPointA_perm, localPointB_perm, - otherFaceDimA, otherFaceDimB, featureA, featureB, - hA_perm, hB_perm, faceOffsetAB_perm, faceOffsetBA_perm, - matrixAB_perm, matrixBA_perm, signsA_perm, signsB_perm, - scalesA_perm, scalesB_perm, false ); - } - } - } - - // convert local points from face-local to box-local coordinate system - - boxPointA.localPoint = Point3( aperm_col * Vector3( localPointA_perm ) ); - boxPointB.localPoint = Point3( bperm_col * Vector3( localPointB_perm ) ); - - // find which features of the boxes are involved. - // the only feature pairs which occur in this function are VF, FV, and EE, even though the - // closest points might actually lie on sub-features, as in a VF contact might be used for - // what's actually a VV contact. this means some feature pairs could possibly seem distinct - // from others, although their contact positions are the same. don't know yet whether this - // matters. - - int sA[3], sB[3]; - - sA[0] = boxPointA.localPoint.getX() > 0.0f; - sA[1] = boxPointA.localPoint.getY() > 0.0f; - sA[2] = boxPointA.localPoint.getZ() > 0.0f; - - sB[0] = boxPointB.localPoint.getX() > 0.0f; - sB[1] = boxPointB.localPoint.getY() > 0.0f; - sB[2] = boxPointB.localPoint.getZ() > 0.0f; - - if ( featureA == F ) { - boxPointA.setFaceFeature( dimA[2], sA[dimA[2]] ); - } else if ( featureA == E ) { - boxPointA.setEdgeFeature( dimA[2], sA[dimA[2]], dimA[otherFaceDimA], sA[dimA[otherFaceDimA]] ); - } else { - boxPointA.setVertexFeature( sA[0], sA[1], sA[2] ); - } - - if ( featureB == F ) { - boxPointB.setFaceFeature( dimB[2], sB[dimB[2]] ); - } else if ( featureB == E ) { - boxPointB.setEdgeFeature( dimB[2], sB[dimB[2]], dimB[otherFaceDimB], sB[dimB[otherFaceDimB]] ); - } else { - boxPointB.setVertexFeature( sB[0], sB[1], sB[2] ); - } - - normal = transformA * axisA; - - if ( maxGap < 0.0f ) { - return (maxGap); - } else { - return (sqrtf( minDistSqr )); - } -} diff --git a/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/boxBoxDistance.h b/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/boxBoxDistance.h deleted file mode 100644 index 7e8b40f75..000000000 --- a/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/boxBoxDistance.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - Copyright (C) 2006, 2008 Sony Computer Entertainment Inc. - All rights reserved. - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. - -*/ - - -#ifndef __BOXBOXDISTANCE_H__ -#define __BOXBOXDISTANCE_H__ - - -#include "Box.h" - -using namespace Vectormath::Aos; - -//--------------------------------------------------------------------------- -// boxBoxDistance: -// -// description: -// this computes info that can be used for the collision response of two boxes. when the boxes -// do not overlap, the points are set to the closest points of the boxes, and a positive -// distance between them is returned. if the boxes do overlap, a negative distance is returned -// and the points are set to two points that would touch after the boxes are translated apart. -// the contact normal gives the direction to repel or separate the boxes when they touch or -// overlap (it's being approximated here as one of the 15 "separating axis" directions). -// -// returns: -// positive or negative distance between two boxes. -// -// args: -// Vector3& normal: set to a unit contact normal pointing from box A to box B. -// -// BoxPoint& boxPointA, BoxPoint& boxPointB: -// set to a closest point or point of penetration on each box. -// -// Box boxA, Box boxB: -// boxes, represented as 3 half-widths -// -// const Transform3& transformA, const Transform3& transformB: -// box transformations, in world coordinates -// -// float distanceThreshold: -// the algorithm will exit early if it finds that the boxes are more distant than this -// threshold, and not compute a contact normal or points. if this distance returned -// exceeds the threshold, all the other output data may not have been computed. by -// default, this is set to MAX_FLOAT so it will have no effect. -// -//--------------------------------------------------------------------------- - -float -boxBoxDistance(Vector3& normal, BoxPoint& boxPointA, BoxPoint& boxPointB, - PE_REF(Box) boxA, const Transform3 & transformA, PE_REF(Box) boxB, - const Transform3 & transformB, - float distanceThreshold = FLT_MAX ); - -#endif /* __BOXBOXDISTANCE_H__ */ diff --git a/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/readme.txt b/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/readme.txt deleted file mode 100644 index f3e907347..000000000 --- a/bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/readme.txt +++ /dev/null @@ -1 +0,0 @@ -Empty placeholder for future Libspe2 SPU task diff --git a/bullet/src/BulletMultiThreaded/SpuSampleTask/SpuSampleTask.cpp b/bullet/src/BulletMultiThreaded/SpuSampleTask/SpuSampleTask.cpp deleted file mode 100644 index 17b81965e..000000000 --- a/bullet/src/BulletMultiThreaded/SpuSampleTask/SpuSampleTask.cpp +++ /dev/null @@ -1,214 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library, Copyright (c) 2007 Erwin Coumans - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. - -*/ - - -#include "SpuSampleTask.h" -#include "BulletDynamics/Dynamics/btRigidBody.h" -#include "../PlatformDefinitions.h" -#include "../SpuFakeDma.h" -#include "LinearMath/btMinMax.h" - -#ifdef __SPU__ -#include -#else -#include -#define spu_printf printf -#endif - -#define MAX_NUM_BODIES 8192 - -struct SampleTask_LocalStoreMemory -{ - ATTRIBUTE_ALIGNED16(char gLocalRigidBody [sizeof(btRigidBody)+16]); - ATTRIBUTE_ALIGNED16(void* gPointerArray[MAX_NUM_BODIES]); - -}; - - - - -//-- MAIN METHOD -void processSampleTask(void* userPtr, void* lsMemory) -{ - // BT_PROFILE("processSampleTask"); - - SampleTask_LocalStoreMemory* localMemory = (SampleTask_LocalStoreMemory*)lsMemory; - - SpuSampleTaskDesc* taskDescPtr = (SpuSampleTaskDesc*)userPtr; - SpuSampleTaskDesc& taskDesc = *taskDescPtr; - - switch (taskDesc.m_sampleCommand) - { - case CMD_SAMPLE_INTEGRATE_BODIES: - { - btTransform predictedTrans; - btCollisionObject** eaPtr = (btCollisionObject**)taskDesc.m_mainMemoryPtr; - - int batchSize = taskDesc.m_sampleValue; - if (batchSize>MAX_NUM_BODIES) - { - spu_printf("SPU Error: exceed number of bodies, see MAX_NUM_BODIES in SpuSampleTask.cpp\n"); - break; - } - int dmaArraySize = batchSize*sizeof(void*); - - uint64_t ppuArrayAddress = reinterpret_cast(eaPtr); - - // spu_printf("array location is at %llx, batchSize = %d, DMA size = %d\n",ppuArrayAddress,batchSize,dmaArraySize); - - if (dmaArraySize>=16) - { - cellDmaLargeGet((void*)&localMemory->gPointerArray[0], ppuArrayAddress , dmaArraySize, DMA_TAG(1), 0, 0); - cellDmaWaitTagStatusAll(DMA_MASK(1)); - } else - { - stallingUnalignedDmaSmallGet((void*)&localMemory->gPointerArray[0], ppuArrayAddress , dmaArraySize); - } - - - for ( int i=0;igLocalRigidBody[0]; - void* shortAdd = localMemory->gPointerArray[i]; - uint64_t ppuRigidBodyAddress = reinterpret_cast(shortAdd); - - // spu_printf("cellDmaGet at CMD_SAMPLE_INTEGRATE_BODIES from %llx to %llx\n",ppuRigidBodyAddress,localPtr); - - int dmaBodySize = sizeof(btRigidBody); - - cellDmaGet((void*)localPtr, ppuRigidBodyAddress , dmaBodySize, DMA_TAG(1), 0, 0); - cellDmaWaitTagStatusAll(DMA_MASK(1)); - - - float timeStep = 1.f/60.f; - - btRigidBody* body = (btRigidBody*) localPtr;//btRigidBody::upcast(colObj); - if (body) - { - if (body->isActive() && (!body->isStaticOrKinematicObject())) - { - body->predictIntegratedTransform(timeStep, predictedTrans); - body->proceedToTransform( predictedTrans); - void* ptr = (void*)localPtr; - // spu_printf("cellDmaLargePut from %llx to LS %llx\n",ptr,ppuRigidBodyAddress); - - cellDmaLargePut(ptr, ppuRigidBodyAddress , dmaBodySize, DMA_TAG(1), 0, 0); - cellDmaWaitTagStatusAll(DMA_MASK(1)); - - } - } - - } - break; - } - - - case CMD_SAMPLE_PREDICT_MOTION_BODIES: - { - btTransform predictedTrans; - btCollisionObject** eaPtr = (btCollisionObject**)taskDesc.m_mainMemoryPtr; - - int batchSize = taskDesc.m_sampleValue; - int dmaArraySize = batchSize*sizeof(void*); - - if (batchSize>MAX_NUM_BODIES) - { - spu_printf("SPU Error: exceed number of bodies, see MAX_NUM_BODIES in SpuSampleTask.cpp\n"); - break; - } - - uint64_t ppuArrayAddress = reinterpret_cast(eaPtr); - - // spu_printf("array location is at %llx, batchSize = %d, DMA size = %d\n",ppuArrayAddress,batchSize,dmaArraySize); - - if (dmaArraySize>=16) - { - cellDmaLargeGet((void*)&localMemory->gPointerArray[0], ppuArrayAddress , dmaArraySize, DMA_TAG(1), 0, 0); - cellDmaWaitTagStatusAll(DMA_MASK(1)); - } else - { - stallingUnalignedDmaSmallGet((void*)&localMemory->gPointerArray[0], ppuArrayAddress , dmaArraySize); - } - - - for ( int i=0;igLocalRigidBody[0]; - void* shortAdd = localMemory->gPointerArray[i]; - uint64_t ppuRigidBodyAddress = reinterpret_cast(shortAdd); - - // spu_printf("cellDmaGet at CMD_SAMPLE_INTEGRATE_BODIES from %llx to %llx\n",ppuRigidBodyAddress,localPtr); - - int dmaBodySize = sizeof(btRigidBody); - - cellDmaGet((void*)localPtr, ppuRigidBodyAddress , dmaBodySize, DMA_TAG(1), 0, 0); - cellDmaWaitTagStatusAll(DMA_MASK(1)); - - - float timeStep = 1.f/60.f; - - btRigidBody* body = (btRigidBody*) localPtr;//btRigidBody::upcast(colObj); - if (body) - { - if (!body->isStaticOrKinematicObject()) - { - if (body->isActive()) - { - body->integrateVelocities( timeStep); - //damping - body->applyDamping(timeStep); - - body->predictIntegratedTransform(timeStep,body->getInterpolationWorldTransform()); - - void* ptr = (void*)localPtr; - cellDmaLargePut(ptr, ppuRigidBodyAddress , dmaBodySize, DMA_TAG(1), 0, 0); - cellDmaWaitTagStatusAll(DMA_MASK(1)); - } - } - } - - } - break; - } - - - - default: - { - - } - }; -} - - -#if defined(__CELLOS_LV2__) || defined (LIBSPE2) - -ATTRIBUTE_ALIGNED16(SampleTask_LocalStoreMemory gLocalStoreMemory); - -void* createSampleLocalStoreMemory() -{ - return &gLocalStoreMemory; -} -#else -void* createSampleLocalStoreMemory() -{ - return new SampleTask_LocalStoreMemory; -}; - -#endif diff --git a/bullet/src/BulletMultiThreaded/SpuSampleTask/SpuSampleTask.h b/bullet/src/BulletMultiThreaded/SpuSampleTask/SpuSampleTask.h deleted file mode 100644 index 900be99c4..000000000 --- a/bullet/src/BulletMultiThreaded/SpuSampleTask/SpuSampleTask.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library, Copyright (c) 2007 Erwin Coumans - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. - -*/ - -#ifndef SPU_SAMPLE_TASK_H -#define SPU_SAMPLE_TASK_H - -#include "../PlatformDefinitions.h" -#include "LinearMath/btScalar.h" -#include "LinearMath/btVector3.h" -#include "LinearMath/btMatrix3x3.h" - -#include "LinearMath/btAlignedAllocator.h" - - -enum -{ - CMD_SAMPLE_INTEGRATE_BODIES = 1, - CMD_SAMPLE_PREDICT_MOTION_BODIES -}; - - - -ATTRIBUTE_ALIGNED16(struct) SpuSampleTaskDesc -{ - BT_DECLARE_ALIGNED_ALLOCATOR(); - - uint32_t m_sampleCommand; - uint32_t m_taskId; - - uint64_t m_mainMemoryPtr; - int m_sampleValue; - - -}; - - -void processSampleTask(void* userPtr, void* lsMemory); -void* createSampleLocalStoreMemory(); - - -#endif //SPU_SAMPLE_TASK_H - diff --git a/bullet/src/BulletMultiThreaded/SpuSampleTask/readme.txt b/bullet/src/BulletMultiThreaded/SpuSampleTask/readme.txt deleted file mode 100644 index f3e907347..000000000 --- a/bullet/src/BulletMultiThreaded/SpuSampleTask/readme.txt +++ /dev/null @@ -1 +0,0 @@ -Empty placeholder for future Libspe2 SPU task diff --git a/bullet/src/BulletMultiThreaded/SpuSampleTaskProcess.cpp b/bullet/src/BulletMultiThreaded/SpuSampleTaskProcess.cpp deleted file mode 100644 index 0a582aff1..000000000 --- a/bullet/src/BulletMultiThreaded/SpuSampleTaskProcess.cpp +++ /dev/null @@ -1,222 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2007 Erwin Coumans http://bulletphysics.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -//#define __CELLOS_LV2__ 1 - -#define USE_SAMPLE_PROCESS 1 -#ifdef USE_SAMPLE_PROCESS - - -#include "SpuSampleTaskProcess.h" -#include - -#ifdef __SPU__ - - - -void SampleThreadFunc(void* userPtr,void* lsMemory) -{ - //do nothing - printf("hello world\n"); -} - - -void* SamplelsMemoryFunc() -{ - //don't create local store memory, just return 0 - return 0; -} - - -#else - - -#include "btThreadSupportInterface.h" - -//# include "SPUAssert.h" -#include - - - -extern "C" { - extern char SPU_SAMPLE_ELF_SYMBOL[]; -} - - - - - -SpuSampleTaskProcess::SpuSampleTaskProcess(btThreadSupportInterface* threadInterface, int maxNumOutstandingTasks) -:m_threadInterface(threadInterface), -m_maxNumOutstandingTasks(maxNumOutstandingTasks) -{ - - m_taskBusy.resize(m_maxNumOutstandingTasks); - m_spuSampleTaskDesc.resize(m_maxNumOutstandingTasks); - - for (int i = 0; i < m_maxNumOutstandingTasks; i++) - { - m_taskBusy[i] = false; - } - m_numBusyTasks = 0; - m_currentTask = 0; - - m_initialized = false; - - m_threadInterface->startSPU(); - - -} - -SpuSampleTaskProcess::~SpuSampleTaskProcess() -{ - m_threadInterface->stopSPU(); - -} - - - -void SpuSampleTaskProcess::initialize() -{ -#ifdef DEBUG_SPU_TASK_SCHEDULING - printf("SpuSampleTaskProcess::initialize()\n"); -#endif //DEBUG_SPU_TASK_SCHEDULING - - for (int i = 0; i < m_maxNumOutstandingTasks; i++) - { - m_taskBusy[i] = false; - } - m_numBusyTasks = 0; - m_currentTask = 0; - m_initialized = true; - -} - - -void SpuSampleTaskProcess::issueTask(void* sampleMainMemPtr,int sampleValue,int sampleCommand) -{ - -#ifdef DEBUG_SPU_TASK_SCHEDULING - printf("SpuSampleTaskProcess::issueTask (m_currentTask= %d\)n", m_currentTask); -#endif //DEBUG_SPU_TASK_SCHEDULING - - m_taskBusy[m_currentTask] = true; - m_numBusyTasks++; - - SpuSampleTaskDesc& taskDesc = m_spuSampleTaskDesc[m_currentTask]; - { - // send task description in event message - // no error checking here... - // but, currently, event queue can be no larger than NUM_WORKUNIT_TASKS. - - taskDesc.m_mainMemoryPtr = reinterpret_cast(sampleMainMemPtr); - taskDesc.m_sampleValue = sampleValue; - taskDesc.m_sampleCommand = sampleCommand; - - //some bookkeeping to recognize finished tasks - taskDesc.m_taskId = m_currentTask; - } - - - m_threadInterface->sendRequest(1, (ppu_address_t) &taskDesc, m_currentTask); - - // if all tasks busy, wait for spu event to clear the task. - - if (m_numBusyTasks >= m_maxNumOutstandingTasks) - { - unsigned int taskId; - unsigned int outputSize; - - for (int i=0;iwaitForResponse(&taskId, &outputSize); - - //printf("PPU: after issue, received event: %u %d\n", taskId, outputSize); - - postProcess(taskId, outputSize); - - m_taskBusy[taskId] = false; - - m_numBusyTasks--; - } - - // find new task buffer - for (int i = 0; i < m_maxNumOutstandingTasks; i++) - { - if (!m_taskBusy[i]) - { - m_currentTask = i; - break; - } - } -} - - -///Optional PPU-size post processing for each task -void SpuSampleTaskProcess::postProcess(int taskId, int outputSize) -{ - -} - - -void SpuSampleTaskProcess::flush() -{ -#ifdef DEBUG_SPU_TASK_SCHEDULING - printf("\nSpuCollisionTaskProcess::flush()\n"); -#endif //DEBUG_SPU_TASK_SCHEDULING - - - // all tasks are issued, wait for all tasks to be complete - while(m_numBusyTasks > 0) - { -// Consolidating SPU code - unsigned int taskId; - unsigned int outputSize; - - for (int i=0;iwaitForResponse(&taskId, &outputSize); - } - - //printf("PPU: flushing, received event: %u %d\n", taskId, outputSize); - - postProcess(taskId, outputSize); - - m_taskBusy[taskId] = false; - - m_numBusyTasks--; - } - - -} - -#endif - - -#endif //USE_SAMPLE_PROCESS diff --git a/bullet/src/BulletMultiThreaded/SpuSampleTaskProcess.h b/bullet/src/BulletMultiThreaded/SpuSampleTaskProcess.h deleted file mode 100644 index fe605d238..000000000 --- a/bullet/src/BulletMultiThreaded/SpuSampleTaskProcess.h +++ /dev/null @@ -1,153 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2007 Erwin Coumans http://bulletphysics.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef SPU_SAMPLE_TASK_PROCESS_H -#define SPU_SAMPLE_TASK_PROCESS_H - -#include - - -#include "PlatformDefinitions.h" - -#include - -#include "LinearMath/btAlignedObjectArray.h" - - -#include "SpuSampleTask/SpuSampleTask.h" - - -//just add your commands here, try to keep them globally unique for debugging purposes -#define CMD_SAMPLE_TASK_COMMAND 10 - - - -/// SpuSampleTaskProcess handles SPU processing of collision pairs. -/// When PPU issues a task, it will look for completed task buffers -/// PPU will do postprocessing, dependent on workunit output (not likely) -class SpuSampleTaskProcess -{ - // track task buffers that are being used, and total busy tasks - btAlignedObjectArray m_taskBusy; - btAlignedObjectArraym_spuSampleTaskDesc; - - int m_numBusyTasks; - - // the current task and the current entry to insert a new work unit - int m_currentTask; - - bool m_initialized; - - void postProcess(int taskId, int outputSize); - - class btThreadSupportInterface* m_threadInterface; - - int m_maxNumOutstandingTasks; - - - -public: - SpuSampleTaskProcess(btThreadSupportInterface* threadInterface, int maxNumOutstandingTasks); - - ~SpuSampleTaskProcess(); - - ///call initialize in the beginning of the frame, before addCollisionPairToTask - void initialize(); - - void issueTask(void* sampleMainMemPtr,int sampleValue,int sampleCommand); - - ///call flush to submit potential outstanding work to SPUs and wait for all involved SPUs to be finished - void flush(); -}; - - -#if defined(USE_LIBSPE2) && defined(__SPU__) -////////////////////MAIN///////////////////////////// -#include "../SpuLibspe2Support.h" -#include -#include -#include - -void * SamplelsMemoryFunc(); -void SampleThreadFunc(void* userPtr,void* lsMemory); - -//#define DEBUG_LIBSPE2_MAINLOOP - -int main(unsigned long long speid, addr64 argp, addr64 envp) -{ - printf("SPU is up \n"); - - ATTRIBUTE_ALIGNED128(btSpuStatus status); - ATTRIBUTE_ALIGNED16( SpuSampleTaskDesc taskDesc ) ; - unsigned int received_message = Spu_Mailbox_Event_Nothing; - bool shutdown = false; - - cellDmaGet(&status, argp.ull, sizeof(btSpuStatus), DMA_TAG(3), 0, 0); - cellDmaWaitTagStatusAll(DMA_MASK(3)); - - status.m_status = Spu_Status_Free; - status.m_lsMemory.p = SamplelsMemoryFunc(); - - cellDmaLargePut(&status, argp.ull, sizeof(btSpuStatus), DMA_TAG(3), 0, 0); - cellDmaWaitTagStatusAll(DMA_MASK(3)); - - - while (!shutdown) - { - received_message = spu_read_in_mbox(); - - - - switch(received_message) - { - case Spu_Mailbox_Event_Shutdown: - shutdown = true; - break; - case Spu_Mailbox_Event_Task: - // refresh the status -#ifdef DEBUG_LIBSPE2_MAINLOOP - printf("SPU recieved Task \n"); -#endif //DEBUG_LIBSPE2_MAINLOOP - cellDmaGet(&status, argp.ull, sizeof(btSpuStatus), DMA_TAG(3), 0, 0); - cellDmaWaitTagStatusAll(DMA_MASK(3)); - - btAssert(status.m_status==Spu_Status_Occupied); - - cellDmaGet(&taskDesc, status.m_taskDesc.p, sizeof(SpuSampleTaskDesc), DMA_TAG(3), 0, 0); - cellDmaWaitTagStatusAll(DMA_MASK(3)); - - SampleThreadFunc((void*)&taskDesc, reinterpret_cast (taskDesc.m_mainMemoryPtr) ); - break; - case Spu_Mailbox_Event_Nothing: - default: - break; - } - - // set to status free and wait for next task - status.m_status = Spu_Status_Free; - cellDmaLargePut(&status, argp.ull, sizeof(btSpuStatus), DMA_TAG(3), 0, 0); - cellDmaWaitTagStatusAll(DMA_MASK(3)); - - - } - return 0; -} -////////////////////////////////////////////////////// -#endif - - - -#endif // SPU_SAMPLE_TASK_PROCESS_H - diff --git a/bullet/src/BulletMultiThreaded/SpuSync.h b/bullet/src/BulletMultiThreaded/SpuSync.h deleted file mode 100644 index 1862935e6..000000000 --- a/bullet/src/BulletMultiThreaded/SpuSync.h +++ /dev/null @@ -1,148 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2007 Starbreeze Studios - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. - -Written by: Marten Svanfeldt -*/ - -#ifndef SPU_SYNC_H -#define SPU_SYNC_H - - -#include "PlatformDefinitions.h" - - -#if defined(WIN32) - -#define WIN32_LEAN_AND_MEAN -#ifdef _XBOX -#include -#else -#include -#endif - -///The btSpinlock is a structure to allow multi-platform synchronization. This allows to port the SPU tasks to other platforms. -class btSpinlock -{ -public: - //typedef volatile LONG SpinVariable; - typedef CRITICAL_SECTION SpinVariable; - - btSpinlock (SpinVariable* var) - : spinVariable (var) - {} - - void Init () - { - //*spinVariable = 0; - InitializeCriticalSection(spinVariable); - } - - void Lock () - { - EnterCriticalSection(spinVariable); - } - - void Unlock () - { - LeaveCriticalSection(spinVariable); - } - -private: - SpinVariable* spinVariable; -}; - - -#elif defined (__CELLOS_LV2__) - -//#include -#include - -///The btSpinlock is a structure to allow multi-platform synchronization. This allows to port the SPU tasks to other platforms. -class btSpinlock -{ -public: - typedef CellSyncMutex SpinVariable; - - btSpinlock (SpinVariable* var) - : spinVariable (var) - {} - - void Init () - { -#ifndef __SPU__ - //*spinVariable = 1; - cellSyncMutexInitialize(spinVariable); -#endif - } - - - - void Lock () - { -#ifdef __SPU__ - // lock semaphore - /*while (cellAtomicTestAndDecr32(atomic_buf, (uint64_t)spinVariable) == 0) - { - - };*/ - cellSyncMutexLock((uint64_t)spinVariable); -#endif - } - - void Unlock () - { -#ifdef __SPU__ - //cellAtomicIncr32(atomic_buf, (uint64_t)spinVariable); - cellSyncMutexUnlock((uint64_t)spinVariable); -#endif - } - - -private: - SpinVariable* spinVariable; - ATTRIBUTE_ALIGNED128(uint32_t atomic_buf[32]); -}; - -#else -//create a dummy implementation (without any locking) useful for serial processing -class btSpinlock -{ -public: - typedef int SpinVariable; - - btSpinlock (SpinVariable* var) - : spinVariable (var) - {} - - void Init () - { - } - - void Lock () - { - } - - void Unlock () - { - } - -private: - SpinVariable* spinVariable; -}; - - -#endif - - -#endif diff --git a/bullet/src/BulletMultiThreaded/Win32ThreadSupport.cpp b/bullet/src/BulletMultiThreaded/Win32ThreadSupport.cpp deleted file mode 100644 index f05d80a79..000000000 --- a/bullet/src/BulletMultiThreaded/Win32ThreadSupport.cpp +++ /dev/null @@ -1,262 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2007 Erwin Coumans http://bulletphysics.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "Win32ThreadSupport.h" - -#ifdef USE_WIN32_THREADING - -#include - -#include "SpuCollisionTaskProcess.h" - -#include "SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.h" - - - -///The number of threads should be equal to the number of available cores -///@todo: each worker should be linked to a single core, using SetThreadIdealProcessor. - -///Win32ThreadSupport helps to initialize/shutdown libspe2, start/stop SPU tasks and communication -///Setup and initialize SPU/CELL/Libspe2 -Win32ThreadSupport::Win32ThreadSupport(const Win32ThreadConstructionInfo & threadConstructionInfo) -{ - m_maxNumTasks = threadConstructionInfo.m_numThreads; - startThreads(threadConstructionInfo); -} - -///cleanup/shutdown Libspe2 -Win32ThreadSupport::~Win32ThreadSupport() -{ - stopSPU(); -} - - - - -#include - -DWORD WINAPI Thread_no_1( LPVOID lpParam ) -{ - - Win32ThreadSupport::btSpuStatus* status = (Win32ThreadSupport::btSpuStatus*)lpParam; - - - while (1) - { - WaitForSingleObject(status->m_eventStartHandle,INFINITE); - - void* userPtr = status->m_userPtr; - - if (userPtr) - { - btAssert(status->m_status); - status->m_userThreadFunc(userPtr,status->m_lsMemory); - status->m_status = 2; - SetEvent(status->m_eventCompletetHandle); - } else - { - //exit Thread - status->m_status = 3; - SetEvent(status->m_eventCompletetHandle); - printf("Thread with taskId %i with handle %p exiting\n",status->m_taskId, status->m_threadHandle); - break; - } - - } - - printf("Thread TERMINATED\n"); - return 0; - -} - -///send messages to SPUs -void Win32ThreadSupport::sendRequest(uint32_t uiCommand, ppu_address_t uiArgument0, uint32_t taskId) -{ - /// gMidphaseSPU.sendRequest(CMD_GATHER_AND_PROCESS_PAIRLIST, (ppu_address_t) &taskDesc); - - ///we should spawn an SPU task here, and in 'waitForResponse' it should wait for response of the (one of) the first tasks that finished - - - - switch (uiCommand) - { - case CMD_GATHER_AND_PROCESS_PAIRLIST: - { - - -//#define SINGLE_THREADED 1 -#ifdef SINGLE_THREADED - - btSpuStatus& spuStatus = m_activeSpuStatus[0]; - spuStatus.m_userPtr=(void*)uiArgument0; - spuStatus.m_userThreadFunc(spuStatus.m_userPtr,spuStatus.m_lsMemory); - HANDLE handle =0; -#else - - - btSpuStatus& spuStatus = m_activeSpuStatus[taskId]; - btAssert(taskId>=0); - btAssert(int(taskId) 1); - spuStatus.m_status = 0; - - ///need to find an active spu - btAssert(last>=0); - -#else - last=0; - btSpuStatus& spuStatus = m_activeSpuStatus[last]; -#endif //SINGLE_THREADED - - - - *puiArgument0 = spuStatus.m_taskId; - *puiArgument1 = spuStatus.m_status; - - -} - - - -void Win32ThreadSupport::startThreads(const Win32ThreadConstructionInfo& threadConstructionInfo) -{ - - m_activeSpuStatus.resize(threadConstructionInfo.m_numThreads); - m_completeHandles.resize(threadConstructionInfo.m_numThreads); - - m_maxNumTasks = threadConstructionInfo.m_numThreads; - - for (int i=0;i0) - { - WaitForSingleObject(spuStatus.m_eventCompletetHandle, INFINITE); - } - - - spuStatus.m_userPtr = 0; - SetEvent(spuStatus.m_eventStartHandle); - WaitForSingleObject(spuStatus.m_eventCompletetHandle, INFINITE); - - CloseHandle(spuStatus.m_eventCompletetHandle); - CloseHandle(spuStatus.m_eventStartHandle); - CloseHandle(spuStatus.m_threadHandle); - } - - m_activeSpuStatus.clear(); - m_completeHandles.clear(); - -} - -#endif //USE_WIN32_THREADING diff --git a/bullet/src/BulletMultiThreaded/Win32ThreadSupport.h b/bullet/src/BulletMultiThreaded/Win32ThreadSupport.h deleted file mode 100644 index 3b4412f25..000000000 --- a/bullet/src/BulletMultiThreaded/Win32ThreadSupport.h +++ /dev/null @@ -1,132 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2007 Erwin Coumans http://bulletphysics.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "LinearMath/btScalar.h" -#include "PlatformDefinitions.h" - -#ifdef USE_WIN32_THREADING //platform specific defines are defined in PlatformDefinitions.h - -#ifndef WIN32_THREAD_SUPPORT_H -#define WIN32_THREAD_SUPPORT_H - -#include "LinearMath/btAlignedObjectArray.h" - -#include "btThreadSupportInterface.h" - - -typedef void (*Win32ThreadFunc)(void* userPtr,void* lsMemory); -typedef void* (*Win32lsMemorySetupFunc)(); - - - - - - -///Win32ThreadSupport helps to initialize/shutdown libspe2, start/stop SPU tasks and communication -class Win32ThreadSupport : public btThreadSupportInterface -{ -public: - ///placeholder, until libspe2 support is there - struct btSpuStatus - { - uint32_t m_taskId; - uint32_t m_commandId; - uint32_t m_status; - - Win32ThreadFunc m_userThreadFunc; - void* m_userPtr; //for taskDesc etc - void* m_lsMemory; //initialized using Win32LocalStoreMemorySetupFunc - - void* m_threadHandle; //this one is calling 'Win32ThreadFunc' - - void* m_eventStartHandle; - char m_eventStartHandleName[32]; - - void* m_eventCompletetHandle; - char m_eventCompletetHandleName[32]; - - - }; -private: - - btAlignedObjectArray m_activeSpuStatus; - btAlignedObjectArray m_completeHandles; - - int m_maxNumTasks; -public: - ///Setup and initialize SPU/CELL/Libspe2 - - struct Win32ThreadConstructionInfo - { - Win32ThreadConstructionInfo(char* uniqueName, - Win32ThreadFunc userThreadFunc, - Win32lsMemorySetupFunc lsMemoryFunc, - int numThreads=1, - int threadStackSize=65535 - ) - :m_uniqueName(uniqueName), - m_userThreadFunc(userThreadFunc), - m_lsMemoryFunc(lsMemoryFunc), - m_numThreads(numThreads), - m_threadStackSize(threadStackSize) - { - - } - - char* m_uniqueName; - Win32ThreadFunc m_userThreadFunc; - Win32lsMemorySetupFunc m_lsMemoryFunc; - int m_numThreads; - int m_threadStackSize; - - }; - - - - Win32ThreadSupport(const Win32ThreadConstructionInfo& threadConstructionInfo); - -///cleanup/shutdown Libspe2 - virtual ~Win32ThreadSupport(); - - void startThreads(const Win32ThreadConstructionInfo& threadInfo); - - -///send messages to SPUs - virtual void sendRequest(uint32_t uiCommand, ppu_address_t uiArgument0, uint32_t uiArgument1); - -///check for messages from SPUs - virtual void waitForResponse(unsigned int *puiArgument0, unsigned int *puiArgument1); - -///start the spus (can be called at the beginning of each frame, to make sure that the right SPU program is loaded) - virtual void startSPU(); - -///tell the task scheduler we are done with the SPU tasks - virtual void stopSPU(); - - virtual void setNumTasks(int numTasks) - { - m_maxNumTasks = numTasks; - } - - virtual int getNumTasks() const - { - return m_maxNumTasks; - } - -}; - -#endif //WIN32_THREAD_SUPPORT_H - -#endif //USE_WIN32_THREADING diff --git a/bullet/src/BulletMultiThreaded/btGpu3DGridBroadphase.cpp b/bullet/src/BulletMultiThreaded/btGpu3DGridBroadphase.cpp deleted file mode 100644 index ea0f7e980..000000000 --- a/bullet/src/BulletMultiThreaded/btGpu3DGridBroadphase.cpp +++ /dev/null @@ -1,590 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library, http://bulletphysics.org -Copyright (C) 2006, 2009 Sony Computer Entertainment Inc. - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -///The 3 following lines include the CPU implementation of the kernels, keep them in this order. -#include "BulletMultiThreaded/btGpuDefines.h" -#include "BulletMultiThreaded/btGpuUtilsSharedDefs.h" -#include "BulletMultiThreaded/btGpuUtilsSharedCode.h" - - - -#include "LinearMath/btAlignedAllocator.h" -#include "LinearMath/btQuickprof.h" -#include "BulletCollision/BroadphaseCollision/btOverlappingPairCache.h" - - - -#include "btGpuDefines.h" -#include "btGpuUtilsSharedDefs.h" - -#include "btGpu3DGridBroadphaseSharedDefs.h" - -#include "btGpu3DGridBroadphase.h" -#include //for memset - - -#include - - - -static bt3DGridBroadphaseParams s3DGridBroadphaseParams; - - - -btGpu3DGridBroadphase::btGpu3DGridBroadphase( const btVector3& worldAabbMin,const btVector3& worldAabbMax, - int gridSizeX, int gridSizeY, int gridSizeZ, - int maxSmallProxies, int maxLargeProxies, int maxPairsPerBody, - int maxBodiesPerCell, - btScalar cellFactorAABB) : - btSimpleBroadphase(maxSmallProxies, -// new (btAlignedAlloc(sizeof(btSortedOverlappingPairCache),16)) btSortedOverlappingPairCache), - new (btAlignedAlloc(sizeof(btHashedOverlappingPairCache),16)) btHashedOverlappingPairCache), - m_bInitialized(false), - m_numBodies(0) -{ - _initialize(worldAabbMin, worldAabbMax, gridSizeX, gridSizeY, gridSizeZ, - maxSmallProxies, maxLargeProxies, maxPairsPerBody, - maxBodiesPerCell, cellFactorAABB); -} - - - -btGpu3DGridBroadphase::btGpu3DGridBroadphase( btOverlappingPairCache* overlappingPairCache, - const btVector3& worldAabbMin,const btVector3& worldAabbMax, - int gridSizeX, int gridSizeY, int gridSizeZ, - int maxSmallProxies, int maxLargeProxies, int maxPairsPerBody, - int maxBodiesPerCell, - btScalar cellFactorAABB) : - btSimpleBroadphase(maxSmallProxies, overlappingPairCache), - m_bInitialized(false), - m_numBodies(0) -{ - _initialize(worldAabbMin, worldAabbMax, gridSizeX, gridSizeY, gridSizeZ, - maxSmallProxies, maxLargeProxies, maxPairsPerBody, - maxBodiesPerCell, cellFactorAABB); -} - - - -btGpu3DGridBroadphase::~btGpu3DGridBroadphase() -{ - //btSimpleBroadphase will free memory of btSortedOverlappingPairCache, because m_ownsPairCache - assert(m_bInitialized); - _finalize(); -} - - - -void btGpu3DGridBroadphase::_initialize( const btVector3& worldAabbMin,const btVector3& worldAabbMax, - int gridSizeX, int gridSizeY, int gridSizeZ, - int maxSmallProxies, int maxLargeProxies, int maxPairsPerBody, - int maxBodiesPerCell, - btScalar cellFactorAABB) -{ - // set various paramerers - m_ownsPairCache = true; - m_params.m_gridSizeX = gridSizeX; - m_params.m_gridSizeY = gridSizeY; - m_params.m_gridSizeZ = gridSizeZ; - m_params.m_numCells = m_params.m_gridSizeX * m_params.m_gridSizeY * m_params.m_gridSizeZ; - btVector3 w_org = worldAabbMin; - m_params.m_worldOriginX = w_org.getX(); - m_params.m_worldOriginY = w_org.getY(); - m_params.m_worldOriginZ = w_org.getZ(); - btVector3 w_size = worldAabbMax - worldAabbMin; - m_params.m_cellSizeX = w_size.getX() / m_params.m_gridSizeX; - m_params.m_cellSizeY = w_size.getY() / m_params.m_gridSizeY; - m_params.m_cellSizeZ = w_size.getZ() / m_params.m_gridSizeZ; - m_maxRadius = btMin(btMin(m_params.m_cellSizeX, m_params.m_cellSizeY), m_params.m_cellSizeZ); - m_maxRadius *= btScalar(0.5f); - m_params.m_numBodies = m_numBodies; - m_params.m_maxBodiesPerCell = maxBodiesPerCell; - - m_numLargeHandles = 0; - m_maxLargeHandles = maxLargeProxies; - - m_maxPairsPerBody = maxPairsPerBody; - - m_cellFactorAABB = cellFactorAABB; - - m_LastLargeHandleIndex = -1; - - assert(!m_bInitialized); - // allocate host storage - m_hBodiesHash = new unsigned int[m_maxHandles * 2]; - memset(m_hBodiesHash, 0x00, m_maxHandles*2*sizeof(unsigned int)); - - m_hCellStart = new unsigned int[m_params.m_numCells]; - memset(m_hCellStart, 0x00, m_params.m_numCells * sizeof(unsigned int)); - - m_hPairBuffStartCurr = new unsigned int[m_maxHandles * 2 + 2]; - // --------------- for now, init with m_maxPairsPerBody for each body - m_hPairBuffStartCurr[0] = 0; - m_hPairBuffStartCurr[1] = 0; - for(int i = 1; i <= m_maxHandles; i++) - { - m_hPairBuffStartCurr[i * 2] = m_hPairBuffStartCurr[(i-1) * 2] + m_maxPairsPerBody; - m_hPairBuffStartCurr[i * 2 + 1] = 0; - } - //---------------- - unsigned int numAABB = m_maxHandles + m_maxLargeHandles; - m_hAABB = new bt3DGrid3F1U[numAABB * 2]; // AABB Min & Max - - m_hPairBuff = new unsigned int[m_maxHandles * m_maxPairsPerBody]; - memset(m_hPairBuff, 0x00, m_maxHandles * m_maxPairsPerBody * sizeof(unsigned int)); // needed? - - m_hPairScan = new unsigned int[m_maxHandles + 1]; - - m_hPairOut = new unsigned int[m_maxHandles * m_maxPairsPerBody]; - -// large proxies - - // allocate handles buffer and put all handles on free list - m_pLargeHandlesRawPtr = btAlignedAlloc(sizeof(btSimpleBroadphaseProxy) * m_maxLargeHandles, 16); - m_pLargeHandles = new(m_pLargeHandlesRawPtr) btSimpleBroadphaseProxy[m_maxLargeHandles]; - m_firstFreeLargeHandle = 0; - { - for (int i = m_firstFreeLargeHandle; i < m_maxLargeHandles; i++) - { - m_pLargeHandles[i].SetNextFree(i + 1); - m_pLargeHandles[i].m_uniqueId = m_maxHandles+2+i; - } - m_pLargeHandles[m_maxLargeHandles - 1].SetNextFree(0); - } - -// debug data - m_numPairsAdded = 0; - m_numOverflows = 0; - - m_bInitialized = true; -} - - - -void btGpu3DGridBroadphase::_finalize() -{ - assert(m_bInitialized); - delete [] m_hBodiesHash; - delete [] m_hCellStart; - delete [] m_hPairBuffStartCurr; - delete [] m_hAABB; - delete [] m_hPairBuff; - delete [] m_hPairScan; - delete [] m_hPairOut; - btAlignedFree(m_pLargeHandlesRawPtr); - m_bInitialized = false; -} - - - -void btGpu3DGridBroadphase::calculateOverlappingPairs(btDispatcher* dispatcher) -{ - if(m_numHandles <= 0) - { - BT_PROFILE("addLarge2LargePairsToCache"); - addLarge2LargePairsToCache(dispatcher); - return; - } - // update constants - setParameters(&m_params); - // prepare AABB array - prepareAABB(); - // calculate hash - calcHashAABB(); - // sort bodies based on hash - sortHash(); - // find start of each cell - findCellStart(); - // findOverlappingPairs (small/small) - findOverlappingPairs(); - // findOverlappingPairs (small/large) - findPairsLarge(); - // add pairs to CPU cache - computePairCacheChanges(); - scanOverlappingPairBuff(); - squeezeOverlappingPairBuff(); - addPairsToCache(dispatcher); - // find and add large/large pairs to CPU cache - addLarge2LargePairsToCache(dispatcher); - return; -} - - - -void btGpu3DGridBroadphase::addPairsToCache(btDispatcher* dispatcher) -{ - m_numPairsAdded = 0; - m_numPairsRemoved = 0; - for(int i = 0; i < m_numHandles; i++) - { - unsigned int num = m_hPairScan[i+1] - m_hPairScan[i]; - if(!num) - { - continue; - } - unsigned int* pInp = m_hPairOut + m_hPairScan[i]; - unsigned int index0 = m_hAABB[i * 2].uw; - btSimpleBroadphaseProxy* proxy0 = &m_pHandles[index0]; - for(unsigned int j = 0; j < num; j++) - { - unsigned int indx1_s = pInp[j]; - unsigned int index1 = indx1_s & (~BT_3DGRID_PAIR_ANY_FLG); - btSimpleBroadphaseProxy* proxy1; - if(index1 < (unsigned int)m_maxHandles) - { - proxy1 = &m_pHandles[index1]; - } - else - { - index1 -= m_maxHandles; - btAssert((index1 >= 0) && (index1 < (unsigned int)m_maxLargeHandles)); - proxy1 = &m_pLargeHandles[index1]; - } - if(indx1_s & BT_3DGRID_PAIR_NEW_FLG) - { - m_pairCache->addOverlappingPair(proxy0,proxy1); - m_numPairsAdded++; - } - else - { - m_pairCache->removeOverlappingPair(proxy0,proxy1,dispatcher); - m_numPairsRemoved++; - } - } - } -} - - - -btBroadphaseProxy* btGpu3DGridBroadphase::createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr ,short int collisionFilterGroup,short int collisionFilterMask, btDispatcher* dispatcher,void* multiSapProxy) -{ - btBroadphaseProxy* proxy; - bool bIsLarge = isLargeProxy(aabbMin, aabbMax); - if(bIsLarge) - { - if (m_numLargeHandles >= m_maxLargeHandles) - { - ///you have to increase the cell size, so 'large' proxies become 'small' proxies (fitting a cell) - btAssert(0); - return 0; //should never happen, but don't let the game crash ;-) - } - btAssert((aabbMin[0]<= aabbMax[0]) && (aabbMin[1]<= aabbMax[1]) && (aabbMin[2]<= aabbMax[2])); - int newHandleIndex = allocLargeHandle(); - proxy = new (&m_pLargeHandles[newHandleIndex])btSimpleBroadphaseProxy(aabbMin,aabbMax,shapeType,userPtr,collisionFilterGroup,collisionFilterMask,multiSapProxy); - } - else - { - proxy = btSimpleBroadphase::createProxy(aabbMin, aabbMax, shapeType, userPtr, collisionFilterGroup, collisionFilterMask, dispatcher, multiSapProxy); - } - return proxy; -} - - - -void btGpu3DGridBroadphase::destroyProxy(btBroadphaseProxy* proxy, btDispatcher* dispatcher) -{ - bool bIsLarge = isLargeProxy(proxy); - if(bIsLarge) - { - - btSimpleBroadphaseProxy* proxy0 = static_cast(proxy); - freeLargeHandle(proxy0); - m_pairCache->removeOverlappingPairsContainingProxy(proxy,dispatcher); - } - else - { - btSimpleBroadphase::destroyProxy(proxy, dispatcher); - } - return; -} - - - -void btGpu3DGridBroadphase::resetPool(btDispatcher* dispatcher) -{ - m_hPairBuffStartCurr[0] = 0; - m_hPairBuffStartCurr[1] = 0; - for(int i = 1; i <= m_maxHandles; i++) - { - m_hPairBuffStartCurr[i * 2] = m_hPairBuffStartCurr[(i-1) * 2] + m_maxPairsPerBody; - m_hPairBuffStartCurr[i * 2 + 1] = 0; - } -} - - - -bool btGpu3DGridBroadphase::isLargeProxy(const btVector3& aabbMin, const btVector3& aabbMax) -{ - btVector3 diag = aabbMax - aabbMin; - - ///use the bounding sphere radius of this bounding box, to include rotation - btScalar radius = diag.length() * btScalar(0.5f); - radius *= m_cellFactorAABB; // user-defined factor - - return (radius > m_maxRadius); -} - - - -bool btGpu3DGridBroadphase::isLargeProxy(btBroadphaseProxy* proxy) -{ - return (proxy->getUid() >= (m_maxHandles+2)); -} - - - -void btGpu3DGridBroadphase::addLarge2LargePairsToCache(btDispatcher* dispatcher) -{ - int i,j; - if (m_numLargeHandles <= 0) - { - return; - } - int new_largest_index = -1; - for(i = 0; i <= m_LastLargeHandleIndex; i++) - { - btSimpleBroadphaseProxy* proxy0 = &m_pLargeHandles[i]; - if(!proxy0->m_clientObject) - { - continue; - } - new_largest_index = i; - for(j = i + 1; j <= m_LastLargeHandleIndex; j++) - { - btSimpleBroadphaseProxy* proxy1 = &m_pLargeHandles[j]; - if(!proxy1->m_clientObject) - { - continue; - } - btAssert(proxy0 != proxy1); - btSimpleBroadphaseProxy* p0 = getSimpleProxyFromProxy(proxy0); - btSimpleBroadphaseProxy* p1 = getSimpleProxyFromProxy(proxy1); - if(aabbOverlap(p0,p1)) - { - if (!m_pairCache->findPair(proxy0,proxy1)) - { - m_pairCache->addOverlappingPair(proxy0,proxy1); - } - } - else - { - if(m_pairCache->findPair(proxy0,proxy1)) - { - m_pairCache->removeOverlappingPair(proxy0,proxy1,dispatcher); - } - } - } - } - m_LastLargeHandleIndex = new_largest_index; - return; -} - - - -void btGpu3DGridBroadphase::rayTest(const btVector3& rayFrom,const btVector3& rayTo, btBroadphaseRayCallback& rayCallback) -{ - btSimpleBroadphase::rayTest(rayFrom, rayTo, rayCallback); - for (int i=0; i <= m_LastLargeHandleIndex; i++) - { - btSimpleBroadphaseProxy* proxy = &m_pLargeHandles[i]; - if(!proxy->m_clientObject) - { - continue; - } - rayCallback.process(proxy); - } -} - - - -// -// overrides for CPU version -// - - - -void btGpu3DGridBroadphase::prepareAABB() -{ - BT_PROFILE("prepareAABB"); - bt3DGrid3F1U* pBB = m_hAABB; - int i; - int new_largest_index = -1; - unsigned int num_small = 0; - for(i = 0; i <= m_LastHandleIndex; i++) - { - btSimpleBroadphaseProxy* proxy0 = &m_pHandles[i]; - if(!proxy0->m_clientObject) - { - continue; - } - new_largest_index = i; - pBB->fx = proxy0->m_aabbMin.getX(); - pBB->fy = proxy0->m_aabbMin.getY(); - pBB->fz = proxy0->m_aabbMin.getZ(); - pBB->uw = i; - pBB++; - pBB->fx = proxy0->m_aabbMax.getX(); - pBB->fy = proxy0->m_aabbMax.getY(); - pBB->fz = proxy0->m_aabbMax.getZ(); - pBB->uw = num_small; - pBB++; - num_small++; - } - m_LastHandleIndex = new_largest_index; - new_largest_index = -1; - unsigned int num_large = 0; - for(i = 0; i <= m_LastLargeHandleIndex; i++) - { - btSimpleBroadphaseProxy* proxy0 = &m_pLargeHandles[i]; - if(!proxy0->m_clientObject) - { - continue; - } - new_largest_index = i; - pBB->fx = proxy0->m_aabbMin.getX(); - pBB->fy = proxy0->m_aabbMin.getY(); - pBB->fz = proxy0->m_aabbMin.getZ(); - pBB->uw = i + m_maxHandles; - pBB++; - pBB->fx = proxy0->m_aabbMax.getX(); - pBB->fy = proxy0->m_aabbMax.getY(); - pBB->fz = proxy0->m_aabbMax.getZ(); - pBB->uw = num_large + m_maxHandles; - pBB++; - num_large++; - } - m_LastLargeHandleIndex = new_largest_index; - // paranoid checks - btAssert(num_small == m_numHandles); - btAssert(num_large == m_numLargeHandles); - return; -} - - - -void btGpu3DGridBroadphase::setParameters(bt3DGridBroadphaseParams* hostParams) -{ - s3DGridBroadphaseParams = *hostParams; - return; -} - - - -void btGpu3DGridBroadphase::calcHashAABB() -{ - BT_PROFILE("bt3DGrid_calcHashAABB"); - btGpu_calcHashAABB(m_hAABB, m_hBodiesHash, m_numHandles); - return; -} - - - -void btGpu3DGridBroadphase::sortHash() -{ - class bt3DGridHashKey - { - public: - unsigned int hash; - unsigned int index; - void quickSort(bt3DGridHashKey* pData, int lo, int hi) - { - int i=lo, j=hi; - bt3DGridHashKey x = pData[(lo+hi)/2]; - do - { - while(pData[i].hash > x.hash) i++; - while(x.hash > pData[j].hash) j--; - if(i <= j) - { - bt3DGridHashKey t = pData[i]; - pData[i] = pData[j]; - pData[j] = t; - i++; j--; - } - } while(i <= j); - if(lo < j) pData->quickSort(pData, lo, j); - if(i < hi) pData->quickSort(pData, i, hi); - } - }; - BT_PROFILE("bt3DGrid_sortHash"); - bt3DGridHashKey* pHash = (bt3DGridHashKey*)m_hBodiesHash; - pHash->quickSort(pHash, 0, m_numHandles - 1); - return; -} - - - -void btGpu3DGridBroadphase::findCellStart() -{ - BT_PROFILE("bt3DGrid_findCellStart"); - btGpu_findCellStart(m_hBodiesHash, m_hCellStart, m_numHandles, m_params.m_numCells); - return; -} - - - -void btGpu3DGridBroadphase::findOverlappingPairs() -{ - BT_PROFILE("bt3DGrid_findOverlappingPairs"); - btGpu_findOverlappingPairs(m_hAABB, m_hBodiesHash, m_hCellStart, m_hPairBuff, m_hPairBuffStartCurr, m_numHandles); - return; -} - - - -void btGpu3DGridBroadphase::findPairsLarge() -{ - BT_PROFILE("bt3DGrid_findPairsLarge"); - btGpu_findPairsLarge(m_hAABB, m_hBodiesHash, m_hCellStart, m_hPairBuff, m_hPairBuffStartCurr, m_numHandles, m_numLargeHandles); - return; -} - - - -void btGpu3DGridBroadphase::computePairCacheChanges() -{ - BT_PROFILE("bt3DGrid_computePairCacheChanges"); - btGpu_computePairCacheChanges(m_hPairBuff, m_hPairBuffStartCurr, m_hPairScan, m_hAABB, m_numHandles); - return; -} - - - -void btGpu3DGridBroadphase::scanOverlappingPairBuff() -{ - BT_PROFILE("bt3DGrid_scanOverlappingPairBuff"); - m_hPairScan[0] = 0; - for(int i = 1; i <= m_numHandles; i++) - { - unsigned int delta = m_hPairScan[i]; - m_hPairScan[i] = m_hPairScan[i-1] + delta; - } - return; -} - - - -void btGpu3DGridBroadphase::squeezeOverlappingPairBuff() -{ - BT_PROFILE("bt3DGrid_squeezeOverlappingPairBuff"); - btGpu_squeezeOverlappingPairBuff(m_hPairBuff, m_hPairBuffStartCurr, m_hPairScan, m_hPairOut, m_hAABB, m_numHandles); - return; -} - - - -#include "btGpu3DGridBroadphaseSharedCode.h" - - diff --git a/bullet/src/BulletMultiThreaded/btGpu3DGridBroadphase.h b/bullet/src/BulletMultiThreaded/btGpu3DGridBroadphase.h deleted file mode 100644 index 98d1f8c9b..000000000 --- a/bullet/src/BulletMultiThreaded/btGpu3DGridBroadphase.h +++ /dev/null @@ -1,138 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library, http://bulletphysics.org -Copyright (C) 2006, 2009 Sony Computer Entertainment Inc. - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -//---------------------------------------------------------------------------------------- - -#ifndef BTGPU3DGRIDBROADPHASE_H -#define BTGPU3DGRIDBROADPHASE_H - -//---------------------------------------------------------------------------------------- - -#include "BulletCollision/BroadphaseCollision/btSimpleBroadphase.h" - -#include "btGpu3DGridBroadphaseSharedTypes.h" - -//---------------------------------------------------------------------------------------- - -///The btGpu3DGridBroadphase uses GPU-style code compiled for CPU to compute overlapping pairs - -class btGpu3DGridBroadphase : public btSimpleBroadphase -{ -protected: - bool m_bInitialized; - unsigned int m_numBodies; - unsigned int m_numCells; - unsigned int m_maxPairsPerBody; - btScalar m_cellFactorAABB; - unsigned int m_maxBodiesPerCell; - bt3DGridBroadphaseParams m_params; - btScalar m_maxRadius; - // CPU data - unsigned int* m_hBodiesHash; - unsigned int* m_hCellStart; - unsigned int* m_hPairBuffStartCurr; - bt3DGrid3F1U* m_hAABB; - unsigned int* m_hPairBuff; - unsigned int* m_hPairScan; - unsigned int* m_hPairOut; -// large proxies - int m_numLargeHandles; - int m_maxLargeHandles; - int m_LastLargeHandleIndex; - btSimpleBroadphaseProxy* m_pLargeHandles; - void* m_pLargeHandlesRawPtr; - int m_firstFreeLargeHandle; - int allocLargeHandle() - { - btAssert(m_numLargeHandles < m_maxLargeHandles); - int freeLargeHandle = m_firstFreeLargeHandle; - m_firstFreeLargeHandle = m_pLargeHandles[freeLargeHandle].GetNextFree(); - m_numLargeHandles++; - if(freeLargeHandle > m_LastLargeHandleIndex) - { - m_LastLargeHandleIndex = freeLargeHandle; - } - return freeLargeHandle; - } - void freeLargeHandle(btSimpleBroadphaseProxy* proxy) - { - int handle = int(proxy - m_pLargeHandles); - btAssert((handle >= 0) && (handle < m_maxHandles)); - if(handle == m_LastLargeHandleIndex) - { - m_LastLargeHandleIndex--; - } - proxy->SetNextFree(m_firstFreeLargeHandle); - m_firstFreeLargeHandle = handle; - proxy->m_clientObject = 0; - m_numLargeHandles--; - } - bool isLargeProxy(const btVector3& aabbMin, const btVector3& aabbMax); - bool isLargeProxy(btBroadphaseProxy* proxy); -// debug - unsigned int m_numPairsAdded; - unsigned int m_numPairsRemoved; - unsigned int m_numOverflows; -// -public: - btGpu3DGridBroadphase(const btVector3& worldAabbMin,const btVector3& worldAabbMax, - int gridSizeX, int gridSizeY, int gridSizeZ, - int maxSmallProxies, int maxLargeProxies, int maxPairsPerBody, - int maxBodiesPerCell = 8, - btScalar cellFactorAABB = btScalar(1.0f)); - btGpu3DGridBroadphase( btOverlappingPairCache* overlappingPairCache, - const btVector3& worldAabbMin,const btVector3& worldAabbMax, - int gridSizeX, int gridSizeY, int gridSizeZ, - int maxSmallProxies, int maxLargeProxies, int maxPairsPerBody, - int maxBodiesPerCell = 8, - btScalar cellFactorAABB = btScalar(1.0f)); - virtual ~btGpu3DGridBroadphase(); - virtual void calculateOverlappingPairs(btDispatcher* dispatcher); - - virtual btBroadphaseProxy* createProxy(const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr ,short int collisionFilterGroup,short int collisionFilterMask, btDispatcher* dispatcher,void* multiSapProxy); - virtual void destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher); - virtual void rayTest(const btVector3& rayFrom,const btVector3& rayTo, btBroadphaseRayCallback& rayCallback); - virtual void resetPool(btDispatcher* dispatcher); - -protected: - void _initialize( const btVector3& worldAabbMin,const btVector3& worldAabbMax, - int gridSizeX, int gridSizeY, int gridSizeZ, - int maxSmallProxies, int maxLargeProxies, int maxPairsPerBody, - int maxBodiesPerCell = 8, - btScalar cellFactorAABB = btScalar(1.0f)); - void _finalize(); - void addPairsToCache(btDispatcher* dispatcher); - void addLarge2LargePairsToCache(btDispatcher* dispatcher); - -// overrides for CPU version - virtual void setParameters(bt3DGridBroadphaseParams* hostParams); - virtual void prepareAABB(); - virtual void calcHashAABB(); - virtual void sortHash(); - virtual void findCellStart(); - virtual void findOverlappingPairs(); - virtual void findPairsLarge(); - virtual void computePairCacheChanges(); - virtual void scanOverlappingPairBuff(); - virtual void squeezeOverlappingPairBuff(); -}; - -//---------------------------------------------------------------------------------------- - -#endif //BTGPU3DGRIDBROADPHASE_H - -//---------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------- diff --git a/bullet/src/BulletMultiThreaded/btGpu3DGridBroadphaseSharedCode.h b/bullet/src/BulletMultiThreaded/btGpu3DGridBroadphaseSharedCode.h deleted file mode 100644 index bc4e0552b..000000000 --- a/bullet/src/BulletMultiThreaded/btGpu3DGridBroadphaseSharedCode.h +++ /dev/null @@ -1,430 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library, http://bulletphysics.org -Copyright (C) 2006, 2009 Sony Computer Entertainment Inc. - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -//---------------------------------------------------------------------------------------- - -//---------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------- -// K E R N E L F U N C T I O N S -//---------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------- - -// calculate position in uniform grid -BT_GPU___device__ int3 bt3DGrid_calcGridPos(float4 p) -{ - int3 gridPos; - gridPos.x = (int)floor((p.x - BT_GPU_params.m_worldOriginX) / BT_GPU_params.m_cellSizeX); - gridPos.y = (int)floor((p.y - BT_GPU_params.m_worldOriginY) / BT_GPU_params.m_cellSizeY); - gridPos.z = (int)floor((p.z - BT_GPU_params.m_worldOriginZ) / BT_GPU_params.m_cellSizeZ); - return gridPos; -} // bt3DGrid_calcGridPos() - -//---------------------------------------------------------------------------------------- - -// calculate address in grid from position (clamping to edges) -BT_GPU___device__ uint bt3DGrid_calcGridHash(int3 gridPos) -{ - gridPos.x = BT_GPU_max(0, BT_GPU_min(gridPos.x, (int)BT_GPU_params.m_gridSizeX - 1)); - gridPos.y = BT_GPU_max(0, BT_GPU_min(gridPos.y, (int)BT_GPU_params.m_gridSizeY - 1)); - gridPos.z = BT_GPU_max(0, BT_GPU_min(gridPos.z, (int)BT_GPU_params.m_gridSizeZ - 1)); - return BT_GPU___mul24(BT_GPU___mul24(gridPos.z, BT_GPU_params.m_gridSizeY), BT_GPU_params.m_gridSizeX) + BT_GPU___mul24(gridPos.y, BT_GPU_params.m_gridSizeX) + gridPos.x; -} // bt3DGrid_calcGridHash() - -//---------------------------------------------------------------------------------------- - -// calculate grid hash value for each body using its AABB -BT_GPU___global__ void calcHashAABBD(bt3DGrid3F1U* pAABB, uint2* pHash, uint numBodies) -{ - int index = BT_GPU___mul24(BT_GPU_blockIdx.x, BT_GPU_blockDim.x) + BT_GPU_threadIdx.x; - if(index >= (int)numBodies) - { - return; - } - bt3DGrid3F1U bbMin = pAABB[index*2]; - bt3DGrid3F1U bbMax = pAABB[index*2 + 1]; - float4 pos; - pos.x = (bbMin.fx + bbMax.fx) * 0.5f; - pos.y = (bbMin.fy + bbMax.fy) * 0.5f; - pos.z = (bbMin.fz + bbMax.fz) * 0.5f; - // get address in grid - int3 gridPos = bt3DGrid_calcGridPos(pos); - uint gridHash = bt3DGrid_calcGridHash(gridPos); - // store grid hash and body index - pHash[index] = BT_GPU_make_uint2(gridHash, index); -} // calcHashAABBD() - -//---------------------------------------------------------------------------------------- - -BT_GPU___global__ void findCellStartD(uint2* pHash, uint* cellStart, uint numBodies) -{ - int index = BT_GPU___mul24(BT_GPU_blockIdx.x, BT_GPU_blockDim.x) + BT_GPU_threadIdx.x; - if(index >= (int)numBodies) - { - return; - } - uint2 sortedData = pHash[index]; - // Load hash data into shared memory so that we can look - // at neighboring body's hash value without loading - // two hash values per thread - BT_GPU___shared__ uint sharedHash[257]; - sharedHash[BT_GPU_threadIdx.x+1] = sortedData.x; - if((index > 0) && (BT_GPU_threadIdx.x == 0)) - { - // first thread in block must load neighbor body hash - volatile uint2 prevData = pHash[index-1]; - sharedHash[0] = prevData.x; - } - BT_GPU___syncthreads(); - if((index == 0) || (sortedData.x != sharedHash[BT_GPU_threadIdx.x])) - { - cellStart[sortedData.x] = index; - } -} // findCellStartD() - -//---------------------------------------------------------------------------------------- - -BT_GPU___device__ uint cudaTestAABBOverlap(bt3DGrid3F1U min0, bt3DGrid3F1U max0, bt3DGrid3F1U min1, bt3DGrid3F1U max1) -{ - return (min0.fx <= max1.fx)&& (min1.fx <= max0.fx) && - (min0.fy <= max1.fy)&& (min1.fy <= max0.fy) && - (min0.fz <= max1.fz)&& (min1.fz <= max0.fz); -} // cudaTestAABBOverlap() - -//---------------------------------------------------------------------------------------- - -BT_GPU___device__ void findPairsInCell( int3 gridPos, - uint index, - uint2* pHash, - uint* pCellStart, - bt3DGrid3F1U* pAABB, - uint* pPairBuff, - uint2* pPairBuffStartCurr, - uint numBodies) -{ - if ( (gridPos.x < 0) || (gridPos.x > (int)BT_GPU_params.m_gridSizeX - 1) - || (gridPos.y < 0) || (gridPos.y > (int)BT_GPU_params.m_gridSizeY - 1) - || (gridPos.z < 0) || (gridPos.z > (int)BT_GPU_params.m_gridSizeZ - 1)) - { - return; - } - uint gridHash = bt3DGrid_calcGridHash(gridPos); - // get start of bucket for this cell - uint bucketStart = pCellStart[gridHash]; - if (bucketStart == 0xffffffff) - { - return; // cell empty - } - // iterate over bodies in this cell - uint2 sortedData = pHash[index]; - uint unsorted_indx = sortedData.y; - bt3DGrid3F1U min0 = BT_GPU_FETCH(pAABB, unsorted_indx*2); - bt3DGrid3F1U max0 = BT_GPU_FETCH(pAABB, unsorted_indx*2 + 1); - uint handleIndex = min0.uw; - uint2 start_curr = pPairBuffStartCurr[handleIndex]; - uint start = start_curr.x; - uint curr = start_curr.y; - uint2 start_curr_next = pPairBuffStartCurr[handleIndex+1]; - uint curr_max = start_curr_next.x - start - 1; - uint bucketEnd = bucketStart + BT_GPU_params.m_maxBodiesPerCell; - bucketEnd = (bucketEnd > numBodies) ? numBodies : bucketEnd; - for(uint index2 = bucketStart; index2 < bucketEnd; index2++) - { - uint2 cellData = pHash[index2]; - if (cellData.x != gridHash) - { - break; // no longer in same bucket - } - uint unsorted_indx2 = cellData.y; - if (unsorted_indx2 < unsorted_indx) // check not colliding with self - { - bt3DGrid3F1U min1 = BT_GPU_FETCH(pAABB, unsorted_indx2*2); - bt3DGrid3F1U max1 = BT_GPU_FETCH(pAABB, unsorted_indx2*2 + 1); - if(cudaTestAABBOverlap(min0, max0, min1, max1)) - { - uint handleIndex2 = min1.uw; - uint k; - for(k = 0; k < curr; k++) - { - uint old_pair = pPairBuff[start+k] & (~BT_3DGRID_PAIR_ANY_FLG); - if(old_pair == handleIndex2) - { - pPairBuff[start+k] |= BT_3DGRID_PAIR_FOUND_FLG; - break; - } - } - if(k == curr) - { - if(curr >= curr_max) - { // not a good solution, but let's avoid crash - break; - } - pPairBuff[start+curr] = handleIndex2 | BT_3DGRID_PAIR_NEW_FLG; - curr++; - } - } - } - } - pPairBuffStartCurr[handleIndex] = BT_GPU_make_uint2(start, curr); - return; -} // findPairsInCell() - -//---------------------------------------------------------------------------------------- - -BT_GPU___global__ void findOverlappingPairsD( bt3DGrid3F1U* pAABB, uint2* pHash, uint* pCellStart, - uint* pPairBuff, uint2* pPairBuffStartCurr, uint numBodies) -{ - int index = BT_GPU___mul24(BT_GPU_blockIdx.x, BT_GPU_blockDim.x) + BT_GPU_threadIdx.x; - if(index >= (int)numBodies) - { - return; - } - uint2 sortedData = pHash[index]; - uint unsorted_indx = sortedData.y; - bt3DGrid3F1U bbMin = BT_GPU_FETCH(pAABB, unsorted_indx*2); - bt3DGrid3F1U bbMax = BT_GPU_FETCH(pAABB, unsorted_indx*2 + 1); - float4 pos; - pos.x = (bbMin.fx + bbMax.fx) * 0.5f; - pos.y = (bbMin.fy + bbMax.fy) * 0.5f; - pos.z = (bbMin.fz + bbMax.fz) * 0.5f; - // get address in grid - int3 gridPos = bt3DGrid_calcGridPos(pos); - // examine only neighbouring cells - for(int z=-1; z<=1; z++) { - for(int y=-1; y<=1; y++) { - for(int x=-1; x<=1; x++) { - findPairsInCell(gridPos + BT_GPU_make_int3(x, y, z), index, pHash, pCellStart, pAABB, pPairBuff, pPairBuffStartCurr, numBodies); - } - } - } -} // findOverlappingPairsD() - -//---------------------------------------------------------------------------------------- - -BT_GPU___global__ void findPairsLargeD( bt3DGrid3F1U* pAABB, uint2* pHash, uint* pCellStart, uint* pPairBuff, - uint2* pPairBuffStartCurr, uint numBodies, uint numLarge) -{ - int index = BT_GPU___mul24(BT_GPU_blockIdx.x, BT_GPU_blockDim.x) + BT_GPU_threadIdx.x; - if(index >= (int)numBodies) - { - return; - } - uint2 sortedData = pHash[index]; - uint unsorted_indx = sortedData.y; - bt3DGrid3F1U min0 = BT_GPU_FETCH(pAABB, unsorted_indx*2); - bt3DGrid3F1U max0 = BT_GPU_FETCH(pAABB, unsorted_indx*2 + 1); - uint handleIndex = min0.uw; - uint2 start_curr = pPairBuffStartCurr[handleIndex]; - uint start = start_curr.x; - uint curr = start_curr.y; - uint2 start_curr_next = pPairBuffStartCurr[handleIndex+1]; - uint curr_max = start_curr_next.x - start - 1; - for(uint i = 0; i < numLarge; i++) - { - uint indx2 = numBodies + i; - bt3DGrid3F1U min1 = BT_GPU_FETCH(pAABB, indx2*2); - bt3DGrid3F1U max1 = BT_GPU_FETCH(pAABB, indx2*2 + 1); - if(cudaTestAABBOverlap(min0, max0, min1, max1)) - { - uint k; - uint handleIndex2 = min1.uw; - for(k = 0; k < curr; k++) - { - uint old_pair = pPairBuff[start+k] & (~BT_3DGRID_PAIR_ANY_FLG); - if(old_pair == handleIndex2) - { - pPairBuff[start+k] |= BT_3DGRID_PAIR_FOUND_FLG; - break; - } - } - if(k == curr) - { - pPairBuff[start+curr] = handleIndex2 | BT_3DGRID_PAIR_NEW_FLG; - if(curr >= curr_max) - { // not a good solution, but let's avoid crash - break; - } - curr++; - } - } - } - pPairBuffStartCurr[handleIndex] = BT_GPU_make_uint2(start, curr); - return; -} // findPairsLargeD() - -//---------------------------------------------------------------------------------------- - -BT_GPU___global__ void computePairCacheChangesD(uint* pPairBuff, uint2* pPairBuffStartCurr, - uint* pPairScan, bt3DGrid3F1U* pAABB, uint numBodies) -{ - int index = BT_GPU___mul24(BT_GPU_blockIdx.x, BT_GPU_blockDim.x) + BT_GPU_threadIdx.x; - if(index >= (int)numBodies) - { - return; - } - bt3DGrid3F1U bbMin = pAABB[index * 2]; - uint handleIndex = bbMin.uw; - uint2 start_curr = pPairBuffStartCurr[handleIndex]; - uint start = start_curr.x; - uint curr = start_curr.y; - uint *pInp = pPairBuff + start; - uint num_changes = 0; - for(uint k = 0; k < curr; k++, pInp++) - { - if(!((*pInp) & BT_3DGRID_PAIR_FOUND_FLG)) - { - num_changes++; - } - } - pPairScan[index+1] = num_changes; -} // computePairCacheChangesD() - -//---------------------------------------------------------------------------------------- - -BT_GPU___global__ void squeezeOverlappingPairBuffD(uint* pPairBuff, uint2* pPairBuffStartCurr, uint* pPairScan, - uint* pPairOut, bt3DGrid3F1U* pAABB, uint numBodies) -{ - int index = BT_GPU___mul24(BT_GPU_blockIdx.x, BT_GPU_blockDim.x) + BT_GPU_threadIdx.x; - if(index >= (int)numBodies) - { - return; - } - bt3DGrid3F1U bbMin = pAABB[index * 2]; - uint handleIndex = bbMin.uw; - uint2 start_curr = pPairBuffStartCurr[handleIndex]; - uint start = start_curr.x; - uint curr = start_curr.y; - uint* pInp = pPairBuff + start; - uint* pOut = pPairOut + pPairScan[index]; - uint* pOut2 = pInp; - uint num = 0; - for(uint k = 0; k < curr; k++, pInp++) - { - if(!((*pInp) & BT_3DGRID_PAIR_FOUND_FLG)) - { - *pOut = *pInp; - pOut++; - } - if((*pInp) & BT_3DGRID_PAIR_ANY_FLG) - { - *pOut2 = (*pInp) & (~BT_3DGRID_PAIR_ANY_FLG); - pOut2++; - num++; - } - } - pPairBuffStartCurr[handleIndex] = BT_GPU_make_uint2(start, num); -} // squeezeOverlappingPairBuffD() - - -//---------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------- -// E N D O F K E R N E L F U N C T I O N S -//---------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------- - -extern "C" -{ - -//---------------------------------------------------------------------------------------- - -void BT_GPU_PREF(calcHashAABB)(bt3DGrid3F1U* pAABB, unsigned int* hash, unsigned int numBodies) -{ - int numThreads, numBlocks; - BT_GPU_PREF(computeGridSize)(numBodies, 256, numBlocks, numThreads); - // execute the kernel - BT_GPU_EXECKERNEL(numBlocks, numThreads, calcHashAABBD, (pAABB, (uint2*)hash, numBodies)); - // check if kernel invocation generated an error - BT_GPU_CHECK_ERROR("calcHashAABBD kernel execution failed"); -} // calcHashAABB() - -//---------------------------------------------------------------------------------------- - -void BT_GPU_PREF(findCellStart(unsigned int* hash, unsigned int* cellStart, unsigned int numBodies, unsigned int numCells)) -{ - int numThreads, numBlocks; - BT_GPU_PREF(computeGridSize)(numBodies, 256, numBlocks, numThreads); - BT_GPU_SAFE_CALL(BT_GPU_Memset(cellStart, 0xffffffff, numCells*sizeof(uint))); - BT_GPU_EXECKERNEL(numBlocks, numThreads, findCellStartD, ((uint2*)hash, (uint*)cellStart, numBodies)); - BT_GPU_CHECK_ERROR("Kernel execution failed: findCellStartD"); -} // findCellStart() - -//---------------------------------------------------------------------------------------- - -void BT_GPU_PREF(findOverlappingPairs(bt3DGrid3F1U* pAABB, unsigned int* pHash, unsigned int* pCellStart, unsigned int* pPairBuff, unsigned int* pPairBuffStartCurr, unsigned int numBodies)) -{ -#if B_CUDA_USE_TEX - BT_GPU_SAFE_CALL(cudaBindTexture(0, pAABBTex, pAABB, numBodies * 2 * sizeof(bt3DGrid3F1U))); -#endif - int numThreads, numBlocks; - BT_GPU_PREF(computeGridSize)(numBodies, 64, numBlocks, numThreads); - BT_GPU_EXECKERNEL(numBlocks, numThreads, findOverlappingPairsD, (pAABB,(uint2*)pHash,(uint*)pCellStart,(uint*)pPairBuff,(uint2*)pPairBuffStartCurr,numBodies)); - BT_GPU_CHECK_ERROR("Kernel execution failed: bt_CudaFindOverlappingPairsD"); -#if B_CUDA_USE_TEX - BT_GPU_SAFE_CALL(cudaUnbindTexture(pAABBTex)); -#endif -} // findOverlappingPairs() - -//---------------------------------------------------------------------------------------- - -void BT_GPU_PREF(findPairsLarge(bt3DGrid3F1U* pAABB, unsigned int* pHash, unsigned int* pCellStart, unsigned int* pPairBuff, unsigned int* pPairBuffStartCurr, unsigned int numBodies, unsigned int numLarge)) -{ -#if B_CUDA_USE_TEX - BT_GPU_SAFE_CALL(cudaBindTexture(0, pAABBTex, pAABB, (numBodies+numLarge) * 2 * sizeof(bt3DGrid3F1U))); -#endif - int numThreads, numBlocks; - BT_GPU_PREF(computeGridSize)(numBodies, 64, numBlocks, numThreads); - BT_GPU_EXECKERNEL(numBlocks, numThreads, findPairsLargeD, (pAABB,(uint2*)pHash,(uint*)pCellStart,(uint*)pPairBuff,(uint2*)pPairBuffStartCurr,numBodies,numLarge)); - BT_GPU_CHECK_ERROR("Kernel execution failed: btCuda_findPairsLargeD"); -#if B_CUDA_USE_TEX - BT_GPU_SAFE_CALL(cudaUnbindTexture(pAABBTex)); -#endif -} // findPairsLarge() - -//---------------------------------------------------------------------------------------- - -void BT_GPU_PREF(computePairCacheChanges(unsigned int* pPairBuff, unsigned int* pPairBuffStartCurr, unsigned int* pPairScan, bt3DGrid3F1U* pAABB, unsigned int numBodies)) -{ - int numThreads, numBlocks; - BT_GPU_PREF(computeGridSize)(numBodies, 256, numBlocks, numThreads); - BT_GPU_EXECKERNEL(numBlocks, numThreads, computePairCacheChangesD, ((uint*)pPairBuff,(uint2*)pPairBuffStartCurr,(uint*)pPairScan,pAABB,numBodies)); - BT_GPU_CHECK_ERROR("Kernel execution failed: btCudaComputePairCacheChangesD"); -} // computePairCacheChanges() - -//---------------------------------------------------------------------------------------- - -void BT_GPU_PREF(squeezeOverlappingPairBuff(unsigned int* pPairBuff, unsigned int* pPairBuffStartCurr, unsigned int* pPairScan, unsigned int* pPairOut, bt3DGrid3F1U* pAABB, unsigned int numBodies)) -{ - int numThreads, numBlocks; - BT_GPU_PREF(computeGridSize)(numBodies, 256, numBlocks, numThreads); - BT_GPU_EXECKERNEL(numBlocks, numThreads, squeezeOverlappingPairBuffD, ((uint*)pPairBuff,(uint2*)pPairBuffStartCurr,(uint*)pPairScan,(uint*)pPairOut,pAABB,numBodies)); - BT_GPU_CHECK_ERROR("Kernel execution failed: btCudaSqueezeOverlappingPairBuffD"); -} // btCuda_squeezeOverlappingPairBuff() - -//------------------------------------------------------------------------------------------------ - -} // extern "C" - -//------------------------------------------------------------------------------------------------ -//------------------------------------------------------------------------------------------------ -//------------------------------------------------------------------------------------------------ diff --git a/bullet/src/BulletMultiThreaded/btGpu3DGridBroadphaseSharedDefs.h b/bullet/src/BulletMultiThreaded/btGpu3DGridBroadphaseSharedDefs.h deleted file mode 100644 index 2e35e4997..000000000 --- a/bullet/src/BulletMultiThreaded/btGpu3DGridBroadphaseSharedDefs.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library, http://bulletphysics.org -Copyright (C) 2006, 2009 Sony Computer Entertainment Inc. - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -//---------------------------------------------------------------------------------------- - -// Shared definitions for GPU-based 3D Grid collision detection broadphase - -//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -// Keep this file free from Bullet headers -// it is included into both CUDA and CPU code -//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -//---------------------------------------------------------------------------------------- - -#ifndef BTGPU3DGRIDBROADPHASESHAREDDEFS_H -#define BTGPU3DGRIDBROADPHASESHAREDDEFS_H - -//---------------------------------------------------------------------------------------- - -#include "btGpu3DGridBroadphaseSharedTypes.h" - -//---------------------------------------------------------------------------------------- - -extern "C" -{ - -//---------------------------------------------------------------------------------------- - -void BT_GPU_PREF(calcHashAABB)(bt3DGrid3F1U* pAABB, unsigned int* hash, unsigned int numBodies); - -void BT_GPU_PREF(findCellStart)(unsigned int* hash, unsigned int* cellStart, unsigned int numBodies, unsigned int numCells); - -void BT_GPU_PREF(findOverlappingPairs)(bt3DGrid3F1U* pAABB, unsigned int* pHash, unsigned int* pCellStart, unsigned int* pPairBuff, unsigned int* pPairBuffStartCurr, unsigned int numBodies); - -void BT_GPU_PREF(findPairsLarge)(bt3DGrid3F1U* pAABB, unsigned int* pHash, unsigned int* pCellStart, unsigned int* pPairBuff, unsigned int* pPairBuffStartCurr, unsigned int numBodies, unsigned int numLarge); - -void BT_GPU_PREF(computePairCacheChanges)(unsigned int* pPairBuff, unsigned int* pPairBuffStartCurr, unsigned int* pPairScan, bt3DGrid3F1U* pAABB, unsigned int numBodies); - -void BT_GPU_PREF(squeezeOverlappingPairBuff)(unsigned int* pPairBuff, unsigned int* pPairBuffStartCurr, unsigned int* pPairScan, unsigned int* pPairOut, bt3DGrid3F1U* pAABB, unsigned int numBodies); - - -//---------------------------------------------------------------------------------------- - -} // extern "C" - -//---------------------------------------------------------------------------------------- - -#endif // BTGPU3DGRIDBROADPHASESHAREDDEFS_H \ No newline at end of file diff --git a/bullet/src/BulletMultiThreaded/btGpu3DGridBroadphaseSharedTypes.h b/bullet/src/BulletMultiThreaded/btGpu3DGridBroadphaseSharedTypes.h deleted file mode 100644 index 2b0811565..000000000 --- a/bullet/src/BulletMultiThreaded/btGpu3DGridBroadphaseSharedTypes.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library, http://bulletphysics.org -Copyright (C) 2006, 2009 Sony Computer Entertainment Inc. - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -//---------------------------------------------------------------------------------------- - -// Shared definitions for GPU-based 3D Grid collision detection broadphase - -//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -// Keep this file free from Bullet headers -// it is included into both CUDA and CPU code -//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -//---------------------------------------------------------------------------------------- - -#ifndef BTGPU3DGRIDBROADPHASESHAREDTYPES_H -#define BTGPU3DGRIDBROADPHASESHAREDTYPES_H - -//---------------------------------------------------------------------------------------- - -#define BT_3DGRID_PAIR_FOUND_FLG (0x40000000) -#define BT_3DGRID_PAIR_NEW_FLG (0x20000000) -#define BT_3DGRID_PAIR_ANY_FLG (BT_3DGRID_PAIR_FOUND_FLG | BT_3DGRID_PAIR_NEW_FLG) - -//---------------------------------------------------------------------------------------- - -struct bt3DGridBroadphaseParams -{ - unsigned int m_gridSizeX; - unsigned int m_gridSizeY; - unsigned int m_gridSizeZ; - unsigned int m_numCells; - float m_worldOriginX; - float m_worldOriginY; - float m_worldOriginZ; - float m_cellSizeX; - float m_cellSizeY; - float m_cellSizeZ; - unsigned int m_numBodies; - unsigned int m_maxBodiesPerCell; -}; - -//---------------------------------------------------------------------------------------- - -struct bt3DGrid3F1U -{ - float fx; - float fy; - float fz; - unsigned int uw; -}; - -//---------------------------------------------------------------------------------------- - -#endif // BTGPU3DGRIDBROADPHASESHAREDTYPES_H \ No newline at end of file diff --git a/bullet/src/BulletMultiThreaded/btGpuDefines.h b/bullet/src/BulletMultiThreaded/btGpuDefines.h deleted file mode 100644 index f9315ab64..000000000 --- a/bullet/src/BulletMultiThreaded/btGpuDefines.h +++ /dev/null @@ -1,211 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library, http://bulletphysics.org -Copyright (C) 2006, 2009 Sony Computer Entertainment Inc. - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - - -// definitions for "GPU on CPU" code - - -#ifndef BT_GPU_DEFINES_H -#define BT_GPU_DEFINES_H - -typedef unsigned int uint; - -struct int2 -{ - int x, y; -}; - -struct uint2 -{ - unsigned int x, y; -}; - -struct int3 -{ - int x, y, z; -}; - -struct uint3 -{ - unsigned int x, y, z; -}; - -struct float4 -{ - float x, y, z, w; -}; - -struct float3 -{ - float x, y, z; -}; - - -#define BT_GPU___device__ inline -#define BT_GPU___devdata__ -#define BT_GPU___constant__ -#define BT_GPU_max(a, b) ((a) > (b) ? (a) : (b)) -#define BT_GPU_min(a, b) ((a) < (b) ? (a) : (b)) -#define BT_GPU_params s3DGridBroadphaseParams -#define BT_GPU___mul24(a, b) ((a)*(b)) -#define BT_GPU___global__ inline -#define BT_GPU___shared__ static -#define BT_GPU___syncthreads() -#define CUDART_PI_F SIMD_PI - -static inline uint2 bt3dGrid_make_uint2(unsigned int x, unsigned int y) -{ - uint2 t; t.x = x; t.y = y; return t; -} -#define BT_GPU_make_uint2(x, y) bt3dGrid_make_uint2(x, y) - -static inline int3 bt3dGrid_make_int3(int x, int y, int z) -{ - int3 t; t.x = x; t.y = y; t.z = z; return t; -} -#define BT_GPU_make_int3(x, y, z) bt3dGrid_make_int3(x, y, z) - -static inline float3 bt3dGrid_make_float3(float x, float y, float z) -{ - float3 t; t.x = x; t.y = y; t.z = z; return t; -} -#define BT_GPU_make_float3(x, y, z) bt3dGrid_make_float3(x, y, z) - -static inline float3 bt3dGrid_make_float34(float4 f) -{ - float3 t; t.x = f.x; t.y = f.y; t.z = f.z; return t; -} -#define BT_GPU_make_float34(f) bt3dGrid_make_float34(f) - -static inline float3 bt3dGrid_make_float31(float f) -{ - float3 t; t.x = t.y = t.z = f; return t; -} -#define BT_GPU_make_float31(x) bt3dGrid_make_float31(x) - -static inline float4 bt3dGrid_make_float42(float3 v, float f) -{ - float4 t; t.x = v.x; t.y = v.y; t.z = v.z; t.w = f; return t; -} -#define BT_GPU_make_float42(a, b) bt3dGrid_make_float42(a, b) - -static inline float4 bt3dGrid_make_float44(float a, float b, float c, float d) -{ - float4 t; t.x = a; t.y = b; t.z = c; t.w = d; return t; -} -#define BT_GPU_make_float44(a, b, c, d) bt3dGrid_make_float44(a, b, c, d) - -inline int3 operator+(int3 a, int3 b) -{ - return bt3dGrid_make_int3(a.x + b.x, a.y + b.y, a.z + b.z); -} - -inline float4 operator+(const float4& a, const float4& b) -{ - float4 r; r.x = a.x+b.x; r.y = a.y+b.y; r.z = a.z+b.z; r.w = a.w+b.w; return r; -} -inline float4 operator*(const float4& a, float fact) -{ - float4 r; r.x = a.x*fact; r.y = a.y*fact; r.z = a.z*fact; r.w = a.w*fact; return r; -} -inline float4 operator*(float fact, float4& a) -{ - return (a * fact); -} -inline float4& operator*=(float4& a, float fact) -{ - a = fact * a; - return a; -} -inline float4& operator+=(float4& a, const float4& b) -{ - a = a + b; - return a; -} - -inline float3 operator+(const float3& a, const float3& b) -{ - float3 r; r.x = a.x+b.x; r.y = a.y+b.y; r.z = a.z+b.z; return r; -} -inline float3 operator-(const float3& a, const float3& b) -{ - float3 r; r.x = a.x-b.x; r.y = a.y-b.y; r.z = a.z-b.z; return r; -} -static inline float bt3dGrid_dot(float3& a, float3& b) -{ - return a.x*b.x+a.y*b.y+a.z*b.z; -} -#define BT_GPU_dot(a,b) bt3dGrid_dot(a,b) - -static inline float bt3dGrid_dot4(float4& a, float4& b) -{ - return a.x*b.x+a.y*b.y+a.z*b.z+a.w*b.w; -} -#define BT_GPU_dot4(a,b) bt3dGrid_dot4(a,b) - -static inline float3 bt3dGrid_cross(const float3& a, const float3& b) -{ - float3 r; r.x = a.y*b.z-a.z*b.y; r.y = -a.x*b.z+a.z*b.x; r.z = a.x*b.y-a.y*b.x; return r; -} -#define BT_GPU_cross(a,b) bt3dGrid_cross(a,b) - - -inline float3 operator*(const float3& a, float fact) -{ - float3 r; r.x = a.x*fact; r.y = a.y*fact; r.z = a.z*fact; return r; -} - - -inline float3& operator+=(float3& a, const float3& b) -{ - a = a + b; - return a; -} -inline float3& operator-=(float3& a, const float3& b) -{ - a = a - b; - return a; -} -inline float3& operator*=(float3& a, float fact) -{ - a = a * fact; - return a; -} -inline float3 operator-(const float3& v) -{ - float3 r; r.x = -v.x; r.y = -v.y; r.z = -v.z; return r; -} - - -#define BT_GPU_FETCH(a, b) a[b] -#define BT_GPU_FETCH4(a, b) a[b] -#define BT_GPU_PREF(func) btGpu_##func -#define BT_GPU_SAFE_CALL(func) func -#define BT_GPU_Memset memset -#define BT_GPU_MemcpyToSymbol(a, b, c) memcpy(&a, b, c) -#define BT_GPU_BindTexture(a, b, c, d) -#define BT_GPU_UnbindTexture(a) - -static uint2 s_blockIdx, s_blockDim, s_threadIdx; -#define BT_GPU_blockIdx s_blockIdx -#define BT_GPU_blockDim s_blockDim -#define BT_GPU_threadIdx s_threadIdx -#define BT_GPU_EXECKERNEL(numb, numt, kfunc, args) {s_blockDim.x=numt;for(int nb=0;nb //for uint32_t etc. -#include "PlatformDefinitions.h" -#include "PpuAddressSpace.h" - -class btThreadSupportInterface -{ -public: - - virtual ~btThreadSupportInterface(); - -///send messages to SPUs - virtual void sendRequest(uint32_t uiCommand, ppu_address_t uiArgument0, uint32_t uiArgument1) =0; - -///check for messages from SPUs - virtual void waitForResponse(unsigned int *puiArgument0, unsigned int *puiArgument1) =0; - -///start the spus (can be called at the beginning of each frame, to make sure that the right SPU program is loaded) - virtual void startSPU() =0; - -///tell the task scheduler we are done with the SPU tasks - virtual void stopSPU()=0; - - ///tell the task scheduler to use no more than numTasks tasks - virtual void setNumTasks(int numTasks)=0; - - virtual int getNumTasks() const = 0; - -}; - -#endif //THREAD_SUPPORT_INTERFACE_H - diff --git a/bullet/src/BulletMultiThreaded/vectormath/scalar/cpp/mat_aos.h b/bullet/src/BulletMultiThreaded/vectormath/scalar/cpp/mat_aos.h deleted file mode 100644 index 0f2a85057..000000000 --- a/bullet/src/BulletMultiThreaded/vectormath/scalar/cpp/mat_aos.h +++ /dev/null @@ -1,1643 +0,0 @@ -/* - Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. - All rights reserved. - - Redistribution and use in source and binary forms, - with or without modification, are permitted provided that the - following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the Sony Computer Entertainment Inc nor the names - of its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef _VECTORMATH_MAT_AOS_CPP_H -#define _VECTORMATH_MAT_AOS_CPP_H - -namespace Vectormath { -namespace Aos { - -//----------------------------------------------------------------------------- -// Constants - -#define _VECTORMATH_PI_OVER_2 1.570796327f - -//----------------------------------------------------------------------------- -// Definitions - -inline Matrix3::Matrix3( const Matrix3 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; -} - -inline Matrix3::Matrix3( float scalar ) -{ - mCol0 = Vector3( scalar ); - mCol1 = Vector3( scalar ); - mCol2 = Vector3( scalar ); -} - -inline Matrix3::Matrix3( const Quat & unitQuat ) -{ - float qx, qy, qz, qw, qx2, qy2, qz2, qxqx2, qyqy2, qzqz2, qxqy2, qyqz2, qzqw2, qxqz2, qyqw2, qxqw2; - qx = unitQuat.getX(); - qy = unitQuat.getY(); - qz = unitQuat.getZ(); - qw = unitQuat.getW(); - qx2 = ( qx + qx ); - qy2 = ( qy + qy ); - qz2 = ( qz + qz ); - qxqx2 = ( qx * qx2 ); - qxqy2 = ( qx * qy2 ); - qxqz2 = ( qx * qz2 ); - qxqw2 = ( qw * qx2 ); - qyqy2 = ( qy * qy2 ); - qyqz2 = ( qy * qz2 ); - qyqw2 = ( qw * qy2 ); - qzqz2 = ( qz * qz2 ); - qzqw2 = ( qw * qz2 ); - mCol0 = Vector3( ( ( 1.0f - qyqy2 ) - qzqz2 ), ( qxqy2 + qzqw2 ), ( qxqz2 - qyqw2 ) ); - mCol1 = Vector3( ( qxqy2 - qzqw2 ), ( ( 1.0f - qxqx2 ) - qzqz2 ), ( qyqz2 + qxqw2 ) ); - mCol2 = Vector3( ( qxqz2 + qyqw2 ), ( qyqz2 - qxqw2 ), ( ( 1.0f - qxqx2 ) - qyqy2 ) ); -} - -inline Matrix3::Matrix3( const Vector3 & _col0, const Vector3 & _col1, const Vector3 & _col2 ) -{ - mCol0 = _col0; - mCol1 = _col1; - mCol2 = _col2; -} - -inline Matrix3 & Matrix3::setCol0( const Vector3 & _col0 ) -{ - mCol0 = _col0; - return *this; -} - -inline Matrix3 & Matrix3::setCol1( const Vector3 & _col1 ) -{ - mCol1 = _col1; - return *this; -} - -inline Matrix3 & Matrix3::setCol2( const Vector3 & _col2 ) -{ - mCol2 = _col2; - return *this; -} - -inline Matrix3 & Matrix3::setCol( int col, const Vector3 & vec ) -{ - *(&mCol0 + col) = vec; - return *this; -} - -inline Matrix3 & Matrix3::setRow( int row, const Vector3 & vec ) -{ - mCol0.setElem( row, vec.getElem( 0 ) ); - mCol1.setElem( row, vec.getElem( 1 ) ); - mCol2.setElem( row, vec.getElem( 2 ) ); - return *this; -} - -inline Matrix3 & Matrix3::setElem( int col, int row, float val ) -{ - Vector3 tmpV3_0; - tmpV3_0 = this->getCol( col ); - tmpV3_0.setElem( row, val ); - this->setCol( col, tmpV3_0 ); - return *this; -} - -inline float Matrix3::getElem( int col, int row ) const -{ - return this->getCol( col ).getElem( row ); -} - -inline const Vector3 Matrix3::getCol0( ) const -{ - return mCol0; -} - -inline const Vector3 Matrix3::getCol1( ) const -{ - return mCol1; -} - -inline const Vector3 Matrix3::getCol2( ) const -{ - return mCol2; -} - -inline const Vector3 Matrix3::getCol( int col ) const -{ - return *(&mCol0 + col); -} - -inline const Vector3 Matrix3::getRow( int row ) const -{ - return Vector3( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ) ); -} - -inline Vector3 & Matrix3::operator []( int col ) -{ - return *(&mCol0 + col); -} - -inline const Vector3 Matrix3::operator []( int col ) const -{ - return *(&mCol0 + col); -} - -inline Matrix3 & Matrix3::operator =( const Matrix3 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; - return *this; -} - -inline const Matrix3 transpose( const Matrix3 & mat ) -{ - return Matrix3( - Vector3( mat.getCol0().getX(), mat.getCol1().getX(), mat.getCol2().getX() ), - Vector3( mat.getCol0().getY(), mat.getCol1().getY(), mat.getCol2().getY() ), - Vector3( mat.getCol0().getZ(), mat.getCol1().getZ(), mat.getCol2().getZ() ) - ); -} - -inline const Matrix3 inverse( const Matrix3 & mat ) -{ - Vector3 tmp0, tmp1, tmp2; - float detinv; - tmp0 = cross( mat.getCol1(), mat.getCol2() ); - tmp1 = cross( mat.getCol2(), mat.getCol0() ); - tmp2 = cross( mat.getCol0(), mat.getCol1() ); - detinv = ( 1.0f / dot( mat.getCol2(), tmp2 ) ); - return Matrix3( - Vector3( ( tmp0.getX() * detinv ), ( tmp1.getX() * detinv ), ( tmp2.getX() * detinv ) ), - Vector3( ( tmp0.getY() * detinv ), ( tmp1.getY() * detinv ), ( tmp2.getY() * detinv ) ), - Vector3( ( tmp0.getZ() * detinv ), ( tmp1.getZ() * detinv ), ( tmp2.getZ() * detinv ) ) - ); -} - -inline float determinant( const Matrix3 & mat ) -{ - return dot( mat.getCol2(), cross( mat.getCol0(), mat.getCol1() ) ); -} - -inline const Matrix3 Matrix3::operator +( const Matrix3 & mat ) const -{ - return Matrix3( - ( mCol0 + mat.mCol0 ), - ( mCol1 + mat.mCol1 ), - ( mCol2 + mat.mCol2 ) - ); -} - -inline const Matrix3 Matrix3::operator -( const Matrix3 & mat ) const -{ - return Matrix3( - ( mCol0 - mat.mCol0 ), - ( mCol1 - mat.mCol1 ), - ( mCol2 - mat.mCol2 ) - ); -} - -inline Matrix3 & Matrix3::operator +=( const Matrix3 & mat ) -{ - *this = *this + mat; - return *this; -} - -inline Matrix3 & Matrix3::operator -=( const Matrix3 & mat ) -{ - *this = *this - mat; - return *this; -} - -inline const Matrix3 Matrix3::operator -( ) const -{ - return Matrix3( - ( -mCol0 ), - ( -mCol1 ), - ( -mCol2 ) - ); -} - -inline const Matrix3 absPerElem( const Matrix3 & mat ) -{ - return Matrix3( - absPerElem( mat.getCol0() ), - absPerElem( mat.getCol1() ), - absPerElem( mat.getCol2() ) - ); -} - -inline const Matrix3 Matrix3::operator *( float scalar ) const -{ - return Matrix3( - ( mCol0 * scalar ), - ( mCol1 * scalar ), - ( mCol2 * scalar ) - ); -} - -inline Matrix3 & Matrix3::operator *=( float scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline const Matrix3 operator *( float scalar, const Matrix3 & mat ) -{ - return mat * scalar; -} - -inline const Vector3 Matrix3::operator *( const Vector3 & vec ) const -{ - return Vector3( - ( ( ( mCol0.getX() * vec.getX() ) + ( mCol1.getX() * vec.getY() ) ) + ( mCol2.getX() * vec.getZ() ) ), - ( ( ( mCol0.getY() * vec.getX() ) + ( mCol1.getY() * vec.getY() ) ) + ( mCol2.getY() * vec.getZ() ) ), - ( ( ( mCol0.getZ() * vec.getX() ) + ( mCol1.getZ() * vec.getY() ) ) + ( mCol2.getZ() * vec.getZ() ) ) - ); -} - -inline const Matrix3 Matrix3::operator *( const Matrix3 & mat ) const -{ - return Matrix3( - ( *this * mat.mCol0 ), - ( *this * mat.mCol1 ), - ( *this * mat.mCol2 ) - ); -} - -inline Matrix3 & Matrix3::operator *=( const Matrix3 & mat ) -{ - *this = *this * mat; - return *this; -} - -inline const Matrix3 mulPerElem( const Matrix3 & mat0, const Matrix3 & mat1 ) -{ - return Matrix3( - mulPerElem( mat0.getCol0(), mat1.getCol0() ), - mulPerElem( mat0.getCol1(), mat1.getCol1() ), - mulPerElem( mat0.getCol2(), mat1.getCol2() ) - ); -} - -inline const Matrix3 Matrix3::identity( ) -{ - return Matrix3( - Vector3::xAxis( ), - Vector3::yAxis( ), - Vector3::zAxis( ) - ); -} - -inline const Matrix3 Matrix3::rotationX( float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - return Matrix3( - Vector3::xAxis( ), - Vector3( 0.0f, c, s ), - Vector3( 0.0f, -s, c ) - ); -} - -inline const Matrix3 Matrix3::rotationY( float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - return Matrix3( - Vector3( c, 0.0f, -s ), - Vector3::yAxis( ), - Vector3( s, 0.0f, c ) - ); -} - -inline const Matrix3 Matrix3::rotationZ( float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - return Matrix3( - Vector3( c, s, 0.0f ), - Vector3( -s, c, 0.0f ), - Vector3::zAxis( ) - ); -} - -inline const Matrix3 Matrix3::rotationZYX( const Vector3 & radiansXYZ ) -{ - float sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; - sX = sinf( radiansXYZ.getX() ); - cX = cosf( radiansXYZ.getX() ); - sY = sinf( radiansXYZ.getY() ); - cY = cosf( radiansXYZ.getY() ); - sZ = sinf( radiansXYZ.getZ() ); - cZ = cosf( radiansXYZ.getZ() ); - tmp0 = ( cZ * sY ); - tmp1 = ( sZ * sY ); - return Matrix3( - Vector3( ( cZ * cY ), ( sZ * cY ), -sY ), - Vector3( ( ( tmp0 * sX ) - ( sZ * cX ) ), ( ( tmp1 * sX ) + ( cZ * cX ) ), ( cY * sX ) ), - Vector3( ( ( tmp0 * cX ) + ( sZ * sX ) ), ( ( tmp1 * cX ) - ( cZ * sX ) ), ( cY * cX ) ) - ); -} - -inline const Matrix3 Matrix3::rotation( float radians, const Vector3 & unitVec ) -{ - float x, y, z, s, c, oneMinusC, xy, yz, zx; - s = sinf( radians ); - c = cosf( radians ); - x = unitVec.getX(); - y = unitVec.getY(); - z = unitVec.getZ(); - xy = ( x * y ); - yz = ( y * z ); - zx = ( z * x ); - oneMinusC = ( 1.0f - c ); - return Matrix3( - Vector3( ( ( ( x * x ) * oneMinusC ) + c ), ( ( xy * oneMinusC ) + ( z * s ) ), ( ( zx * oneMinusC ) - ( y * s ) ) ), - Vector3( ( ( xy * oneMinusC ) - ( z * s ) ), ( ( ( y * y ) * oneMinusC ) + c ), ( ( yz * oneMinusC ) + ( x * s ) ) ), - Vector3( ( ( zx * oneMinusC ) + ( y * s ) ), ( ( yz * oneMinusC ) - ( x * s ) ), ( ( ( z * z ) * oneMinusC ) + c ) ) - ); -} - -inline const Matrix3 Matrix3::rotation( const Quat & unitQuat ) -{ - return Matrix3( unitQuat ); -} - -inline const Matrix3 Matrix3::scale( const Vector3 & scaleVec ) -{ - return Matrix3( - Vector3( scaleVec.getX(), 0.0f, 0.0f ), - Vector3( 0.0f, scaleVec.getY(), 0.0f ), - Vector3( 0.0f, 0.0f, scaleVec.getZ() ) - ); -} - -inline const Matrix3 appendScale( const Matrix3 & mat, const Vector3 & scaleVec ) -{ - return Matrix3( - ( mat.getCol0() * scaleVec.getX( ) ), - ( mat.getCol1() * scaleVec.getY( ) ), - ( mat.getCol2() * scaleVec.getZ( ) ) - ); -} - -inline const Matrix3 prependScale( const Vector3 & scaleVec, const Matrix3 & mat ) -{ - return Matrix3( - mulPerElem( mat.getCol0(), scaleVec ), - mulPerElem( mat.getCol1(), scaleVec ), - mulPerElem( mat.getCol2(), scaleVec ) - ); -} - -inline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, bool select1 ) -{ - return Matrix3( - select( mat0.getCol0(), mat1.getCol0(), select1 ), - select( mat0.getCol1(), mat1.getCol1(), select1 ), - select( mat0.getCol2(), mat1.getCol2(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Matrix3 & mat ) -{ - print( mat.getRow( 0 ) ); - print( mat.getRow( 1 ) ); - print( mat.getRow( 2 ) ); -} - -inline void print( const Matrix3 & mat, const char * name ) -{ - printf("%s:\n", name); - print( mat ); -} - -#endif - -inline Matrix4::Matrix4( const Matrix4 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; - mCol3 = mat.mCol3; -} - -inline Matrix4::Matrix4( float scalar ) -{ - mCol0 = Vector4( scalar ); - mCol1 = Vector4( scalar ); - mCol2 = Vector4( scalar ); - mCol3 = Vector4( scalar ); -} - -inline Matrix4::Matrix4( const Transform3 & mat ) -{ - mCol0 = Vector4( mat.getCol0(), 0.0f ); - mCol1 = Vector4( mat.getCol1(), 0.0f ); - mCol2 = Vector4( mat.getCol2(), 0.0f ); - mCol3 = Vector4( mat.getCol3(), 1.0f ); -} - -inline Matrix4::Matrix4( const Vector4 & _col0, const Vector4 & _col1, const Vector4 & _col2, const Vector4 & _col3 ) -{ - mCol0 = _col0; - mCol1 = _col1; - mCol2 = _col2; - mCol3 = _col3; -} - -inline Matrix4::Matrix4( const Matrix3 & mat, const Vector3 & translateVec ) -{ - mCol0 = Vector4( mat.getCol0(), 0.0f ); - mCol1 = Vector4( mat.getCol1(), 0.0f ); - mCol2 = Vector4( mat.getCol2(), 0.0f ); - mCol3 = Vector4( translateVec, 1.0f ); -} - -inline Matrix4::Matrix4( const Quat & unitQuat, const Vector3 & translateVec ) -{ - Matrix3 mat; - mat = Matrix3( unitQuat ); - mCol0 = Vector4( mat.getCol0(), 0.0f ); - mCol1 = Vector4( mat.getCol1(), 0.0f ); - mCol2 = Vector4( mat.getCol2(), 0.0f ); - mCol3 = Vector4( translateVec, 1.0f ); -} - -inline Matrix4 & Matrix4::setCol0( const Vector4 & _col0 ) -{ - mCol0 = _col0; - return *this; -} - -inline Matrix4 & Matrix4::setCol1( const Vector4 & _col1 ) -{ - mCol1 = _col1; - return *this; -} - -inline Matrix4 & Matrix4::setCol2( const Vector4 & _col2 ) -{ - mCol2 = _col2; - return *this; -} - -inline Matrix4 & Matrix4::setCol3( const Vector4 & _col3 ) -{ - mCol3 = _col3; - return *this; -} - -inline Matrix4 & Matrix4::setCol( int col, const Vector4 & vec ) -{ - *(&mCol0 + col) = vec; - return *this; -} - -inline Matrix4 & Matrix4::setRow( int row, const Vector4 & vec ) -{ - mCol0.setElem( row, vec.getElem( 0 ) ); - mCol1.setElem( row, vec.getElem( 1 ) ); - mCol2.setElem( row, vec.getElem( 2 ) ); - mCol3.setElem( row, vec.getElem( 3 ) ); - return *this; -} - -inline Matrix4 & Matrix4::setElem( int col, int row, float val ) -{ - Vector4 tmpV3_0; - tmpV3_0 = this->getCol( col ); - tmpV3_0.setElem( row, val ); - this->setCol( col, tmpV3_0 ); - return *this; -} - -inline float Matrix4::getElem( int col, int row ) const -{ - return this->getCol( col ).getElem( row ); -} - -inline const Vector4 Matrix4::getCol0( ) const -{ - return mCol0; -} - -inline const Vector4 Matrix4::getCol1( ) const -{ - return mCol1; -} - -inline const Vector4 Matrix4::getCol2( ) const -{ - return mCol2; -} - -inline const Vector4 Matrix4::getCol3( ) const -{ - return mCol3; -} - -inline const Vector4 Matrix4::getCol( int col ) const -{ - return *(&mCol0 + col); -} - -inline const Vector4 Matrix4::getRow( int row ) const -{ - return Vector4( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ), mCol3.getElem( row ) ); -} - -inline Vector4 & Matrix4::operator []( int col ) -{ - return *(&mCol0 + col); -} - -inline const Vector4 Matrix4::operator []( int col ) const -{ - return *(&mCol0 + col); -} - -inline Matrix4 & Matrix4::operator =( const Matrix4 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; - mCol3 = mat.mCol3; - return *this; -} - -inline const Matrix4 transpose( const Matrix4 & mat ) -{ - return Matrix4( - Vector4( mat.getCol0().getX(), mat.getCol1().getX(), mat.getCol2().getX(), mat.getCol3().getX() ), - Vector4( mat.getCol0().getY(), mat.getCol1().getY(), mat.getCol2().getY(), mat.getCol3().getY() ), - Vector4( mat.getCol0().getZ(), mat.getCol1().getZ(), mat.getCol2().getZ(), mat.getCol3().getZ() ), - Vector4( mat.getCol0().getW(), mat.getCol1().getW(), mat.getCol2().getW(), mat.getCol3().getW() ) - ); -} - -inline const Matrix4 inverse( const Matrix4 & mat ) -{ - Vector4 res0, res1, res2, res3; - float mA, mB, mC, mD, mE, mF, mG, mH, mI, mJ, mK, mL, mM, mN, mO, mP, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, detInv; - mA = mat.getCol0().getX(); - mB = mat.getCol0().getY(); - mC = mat.getCol0().getZ(); - mD = mat.getCol0().getW(); - mE = mat.getCol1().getX(); - mF = mat.getCol1().getY(); - mG = mat.getCol1().getZ(); - mH = mat.getCol1().getW(); - mI = mat.getCol2().getX(); - mJ = mat.getCol2().getY(); - mK = mat.getCol2().getZ(); - mL = mat.getCol2().getW(); - mM = mat.getCol3().getX(); - mN = mat.getCol3().getY(); - mO = mat.getCol3().getZ(); - mP = mat.getCol3().getW(); - tmp0 = ( ( mK * mD ) - ( mC * mL ) ); - tmp1 = ( ( mO * mH ) - ( mG * mP ) ); - tmp2 = ( ( mB * mK ) - ( mJ * mC ) ); - tmp3 = ( ( mF * mO ) - ( mN * mG ) ); - tmp4 = ( ( mJ * mD ) - ( mB * mL ) ); - tmp5 = ( ( mN * mH ) - ( mF * mP ) ); - res0.setX( ( ( ( mJ * tmp1 ) - ( mL * tmp3 ) ) - ( mK * tmp5 ) ) ); - res0.setY( ( ( ( mN * tmp0 ) - ( mP * tmp2 ) ) - ( mO * tmp4 ) ) ); - res0.setZ( ( ( ( mD * tmp3 ) + ( mC * tmp5 ) ) - ( mB * tmp1 ) ) ); - res0.setW( ( ( ( mH * tmp2 ) + ( mG * tmp4 ) ) - ( mF * tmp0 ) ) ); - detInv = ( 1.0f / ( ( ( ( mA * res0.getX() ) + ( mE * res0.getY() ) ) + ( mI * res0.getZ() ) ) + ( mM * res0.getW() ) ) ); - res1.setX( ( mI * tmp1 ) ); - res1.setY( ( mM * tmp0 ) ); - res1.setZ( ( mA * tmp1 ) ); - res1.setW( ( mE * tmp0 ) ); - res3.setX( ( mI * tmp3 ) ); - res3.setY( ( mM * tmp2 ) ); - res3.setZ( ( mA * tmp3 ) ); - res3.setW( ( mE * tmp2 ) ); - res2.setX( ( mI * tmp5 ) ); - res2.setY( ( mM * tmp4 ) ); - res2.setZ( ( mA * tmp5 ) ); - res2.setW( ( mE * tmp4 ) ); - tmp0 = ( ( mI * mB ) - ( mA * mJ ) ); - tmp1 = ( ( mM * mF ) - ( mE * mN ) ); - tmp2 = ( ( mI * mD ) - ( mA * mL ) ); - tmp3 = ( ( mM * mH ) - ( mE * mP ) ); - tmp4 = ( ( mI * mC ) - ( mA * mK ) ); - tmp5 = ( ( mM * mG ) - ( mE * mO ) ); - res2.setX( ( ( ( mL * tmp1 ) - ( mJ * tmp3 ) ) + res2.getX() ) ); - res2.setY( ( ( ( mP * tmp0 ) - ( mN * tmp2 ) ) + res2.getY() ) ); - res2.setZ( ( ( ( mB * tmp3 ) - ( mD * tmp1 ) ) - res2.getZ() ) ); - res2.setW( ( ( ( mF * tmp2 ) - ( mH * tmp0 ) ) - res2.getW() ) ); - res3.setX( ( ( ( mJ * tmp5 ) - ( mK * tmp1 ) ) + res3.getX() ) ); - res3.setY( ( ( ( mN * tmp4 ) - ( mO * tmp0 ) ) + res3.getY() ) ); - res3.setZ( ( ( ( mC * tmp1 ) - ( mB * tmp5 ) ) - res3.getZ() ) ); - res3.setW( ( ( ( mG * tmp0 ) - ( mF * tmp4 ) ) - res3.getW() ) ); - res1.setX( ( ( ( mK * tmp3 ) - ( mL * tmp5 ) ) - res1.getX() ) ); - res1.setY( ( ( ( mO * tmp2 ) - ( mP * tmp4 ) ) - res1.getY() ) ); - res1.setZ( ( ( ( mD * tmp5 ) - ( mC * tmp3 ) ) + res1.getZ() ) ); - res1.setW( ( ( ( mH * tmp4 ) - ( mG * tmp2 ) ) + res1.getW() ) ); - return Matrix4( - ( res0 * detInv ), - ( res1 * detInv ), - ( res2 * detInv ), - ( res3 * detInv ) - ); -} - -inline const Matrix4 affineInverse( const Matrix4 & mat ) -{ - Transform3 affineMat; - affineMat.setCol0( mat.getCol0().getXYZ( ) ); - affineMat.setCol1( mat.getCol1().getXYZ( ) ); - affineMat.setCol2( mat.getCol2().getXYZ( ) ); - affineMat.setCol3( mat.getCol3().getXYZ( ) ); - return Matrix4( inverse( affineMat ) ); -} - -inline const Matrix4 orthoInverse( const Matrix4 & mat ) -{ - Transform3 affineMat; - affineMat.setCol0( mat.getCol0().getXYZ( ) ); - affineMat.setCol1( mat.getCol1().getXYZ( ) ); - affineMat.setCol2( mat.getCol2().getXYZ( ) ); - affineMat.setCol3( mat.getCol3().getXYZ( ) ); - return Matrix4( orthoInverse( affineMat ) ); -} - -inline float determinant( const Matrix4 & mat ) -{ - float dx, dy, dz, dw, mA, mB, mC, mD, mE, mF, mG, mH, mI, mJ, mK, mL, mM, mN, mO, mP, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; - mA = mat.getCol0().getX(); - mB = mat.getCol0().getY(); - mC = mat.getCol0().getZ(); - mD = mat.getCol0().getW(); - mE = mat.getCol1().getX(); - mF = mat.getCol1().getY(); - mG = mat.getCol1().getZ(); - mH = mat.getCol1().getW(); - mI = mat.getCol2().getX(); - mJ = mat.getCol2().getY(); - mK = mat.getCol2().getZ(); - mL = mat.getCol2().getW(); - mM = mat.getCol3().getX(); - mN = mat.getCol3().getY(); - mO = mat.getCol3().getZ(); - mP = mat.getCol3().getW(); - tmp0 = ( ( mK * mD ) - ( mC * mL ) ); - tmp1 = ( ( mO * mH ) - ( mG * mP ) ); - tmp2 = ( ( mB * mK ) - ( mJ * mC ) ); - tmp3 = ( ( mF * mO ) - ( mN * mG ) ); - tmp4 = ( ( mJ * mD ) - ( mB * mL ) ); - tmp5 = ( ( mN * mH ) - ( mF * mP ) ); - dx = ( ( ( mJ * tmp1 ) - ( mL * tmp3 ) ) - ( mK * tmp5 ) ); - dy = ( ( ( mN * tmp0 ) - ( mP * tmp2 ) ) - ( mO * tmp4 ) ); - dz = ( ( ( mD * tmp3 ) + ( mC * tmp5 ) ) - ( mB * tmp1 ) ); - dw = ( ( ( mH * tmp2 ) + ( mG * tmp4 ) ) - ( mF * tmp0 ) ); - return ( ( ( ( mA * dx ) + ( mE * dy ) ) + ( mI * dz ) ) + ( mM * dw ) ); -} - -inline const Matrix4 Matrix4::operator +( const Matrix4 & mat ) const -{ - return Matrix4( - ( mCol0 + mat.mCol0 ), - ( mCol1 + mat.mCol1 ), - ( mCol2 + mat.mCol2 ), - ( mCol3 + mat.mCol3 ) - ); -} - -inline const Matrix4 Matrix4::operator -( const Matrix4 & mat ) const -{ - return Matrix4( - ( mCol0 - mat.mCol0 ), - ( mCol1 - mat.mCol1 ), - ( mCol2 - mat.mCol2 ), - ( mCol3 - mat.mCol3 ) - ); -} - -inline Matrix4 & Matrix4::operator +=( const Matrix4 & mat ) -{ - *this = *this + mat; - return *this; -} - -inline Matrix4 & Matrix4::operator -=( const Matrix4 & mat ) -{ - *this = *this - mat; - return *this; -} - -inline const Matrix4 Matrix4::operator -( ) const -{ - return Matrix4( - ( -mCol0 ), - ( -mCol1 ), - ( -mCol2 ), - ( -mCol3 ) - ); -} - -inline const Matrix4 absPerElem( const Matrix4 & mat ) -{ - return Matrix4( - absPerElem( mat.getCol0() ), - absPerElem( mat.getCol1() ), - absPerElem( mat.getCol2() ), - absPerElem( mat.getCol3() ) - ); -} - -inline const Matrix4 Matrix4::operator *( float scalar ) const -{ - return Matrix4( - ( mCol0 * scalar ), - ( mCol1 * scalar ), - ( mCol2 * scalar ), - ( mCol3 * scalar ) - ); -} - -inline Matrix4 & Matrix4::operator *=( float scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline const Matrix4 operator *( float scalar, const Matrix4 & mat ) -{ - return mat * scalar; -} - -inline const Vector4 Matrix4::operator *( const Vector4 & vec ) const -{ - return Vector4( - ( ( ( ( mCol0.getX() * vec.getX() ) + ( mCol1.getX() * vec.getY() ) ) + ( mCol2.getX() * vec.getZ() ) ) + ( mCol3.getX() * vec.getW() ) ), - ( ( ( ( mCol0.getY() * vec.getX() ) + ( mCol1.getY() * vec.getY() ) ) + ( mCol2.getY() * vec.getZ() ) ) + ( mCol3.getY() * vec.getW() ) ), - ( ( ( ( mCol0.getZ() * vec.getX() ) + ( mCol1.getZ() * vec.getY() ) ) + ( mCol2.getZ() * vec.getZ() ) ) + ( mCol3.getZ() * vec.getW() ) ), - ( ( ( ( mCol0.getW() * vec.getX() ) + ( mCol1.getW() * vec.getY() ) ) + ( mCol2.getW() * vec.getZ() ) ) + ( mCol3.getW() * vec.getW() ) ) - ); -} - -inline const Vector4 Matrix4::operator *( const Vector3 & vec ) const -{ - return Vector4( - ( ( ( mCol0.getX() * vec.getX() ) + ( mCol1.getX() * vec.getY() ) ) + ( mCol2.getX() * vec.getZ() ) ), - ( ( ( mCol0.getY() * vec.getX() ) + ( mCol1.getY() * vec.getY() ) ) + ( mCol2.getY() * vec.getZ() ) ), - ( ( ( mCol0.getZ() * vec.getX() ) + ( mCol1.getZ() * vec.getY() ) ) + ( mCol2.getZ() * vec.getZ() ) ), - ( ( ( mCol0.getW() * vec.getX() ) + ( mCol1.getW() * vec.getY() ) ) + ( mCol2.getW() * vec.getZ() ) ) - ); -} - -inline const Vector4 Matrix4::operator *( const Point3 & pnt ) const -{ - return Vector4( - ( ( ( ( mCol0.getX() * pnt.getX() ) + ( mCol1.getX() * pnt.getY() ) ) + ( mCol2.getX() * pnt.getZ() ) ) + mCol3.getX() ), - ( ( ( ( mCol0.getY() * pnt.getX() ) + ( mCol1.getY() * pnt.getY() ) ) + ( mCol2.getY() * pnt.getZ() ) ) + mCol3.getY() ), - ( ( ( ( mCol0.getZ() * pnt.getX() ) + ( mCol1.getZ() * pnt.getY() ) ) + ( mCol2.getZ() * pnt.getZ() ) ) + mCol3.getZ() ), - ( ( ( ( mCol0.getW() * pnt.getX() ) + ( mCol1.getW() * pnt.getY() ) ) + ( mCol2.getW() * pnt.getZ() ) ) + mCol3.getW() ) - ); -} - -inline const Matrix4 Matrix4::operator *( const Matrix4 & mat ) const -{ - return Matrix4( - ( *this * mat.mCol0 ), - ( *this * mat.mCol1 ), - ( *this * mat.mCol2 ), - ( *this * mat.mCol3 ) - ); -} - -inline Matrix4 & Matrix4::operator *=( const Matrix4 & mat ) -{ - *this = *this * mat; - return *this; -} - -inline const Matrix4 Matrix4::operator *( const Transform3 & tfrm ) const -{ - return Matrix4( - ( *this * tfrm.getCol0() ), - ( *this * tfrm.getCol1() ), - ( *this * tfrm.getCol2() ), - ( *this * Point3( tfrm.getCol3() ) ) - ); -} - -inline Matrix4 & Matrix4::operator *=( const Transform3 & tfrm ) -{ - *this = *this * tfrm; - return *this; -} - -inline const Matrix4 mulPerElem( const Matrix4 & mat0, const Matrix4 & mat1 ) -{ - return Matrix4( - mulPerElem( mat0.getCol0(), mat1.getCol0() ), - mulPerElem( mat0.getCol1(), mat1.getCol1() ), - mulPerElem( mat0.getCol2(), mat1.getCol2() ), - mulPerElem( mat0.getCol3(), mat1.getCol3() ) - ); -} - -inline const Matrix4 Matrix4::identity( ) -{ - return Matrix4( - Vector4::xAxis( ), - Vector4::yAxis( ), - Vector4::zAxis( ), - Vector4::wAxis( ) - ); -} - -inline Matrix4 & Matrix4::setUpper3x3( const Matrix3 & mat3 ) -{ - mCol0.setXYZ( mat3.getCol0() ); - mCol1.setXYZ( mat3.getCol1() ); - mCol2.setXYZ( mat3.getCol2() ); - return *this; -} - -inline const Matrix3 Matrix4::getUpper3x3( ) const -{ - return Matrix3( - mCol0.getXYZ( ), - mCol1.getXYZ( ), - mCol2.getXYZ( ) - ); -} - -inline Matrix4 & Matrix4::setTranslation( const Vector3 & translateVec ) -{ - mCol3.setXYZ( translateVec ); - return *this; -} - -inline const Vector3 Matrix4::getTranslation( ) const -{ - return mCol3.getXYZ( ); -} - -inline const Matrix4 Matrix4::rotationX( float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - return Matrix4( - Vector4::xAxis( ), - Vector4( 0.0f, c, s, 0.0f ), - Vector4( 0.0f, -s, c, 0.0f ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotationY( float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - return Matrix4( - Vector4( c, 0.0f, -s, 0.0f ), - Vector4::yAxis( ), - Vector4( s, 0.0f, c, 0.0f ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotationZ( float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - return Matrix4( - Vector4( c, s, 0.0f, 0.0f ), - Vector4( -s, c, 0.0f, 0.0f ), - Vector4::zAxis( ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotationZYX( const Vector3 & radiansXYZ ) -{ - float sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; - sX = sinf( radiansXYZ.getX() ); - cX = cosf( radiansXYZ.getX() ); - sY = sinf( radiansXYZ.getY() ); - cY = cosf( radiansXYZ.getY() ); - sZ = sinf( radiansXYZ.getZ() ); - cZ = cosf( radiansXYZ.getZ() ); - tmp0 = ( cZ * sY ); - tmp1 = ( sZ * sY ); - return Matrix4( - Vector4( ( cZ * cY ), ( sZ * cY ), -sY, 0.0f ), - Vector4( ( ( tmp0 * sX ) - ( sZ * cX ) ), ( ( tmp1 * sX ) + ( cZ * cX ) ), ( cY * sX ), 0.0f ), - Vector4( ( ( tmp0 * cX ) + ( sZ * sX ) ), ( ( tmp1 * cX ) - ( cZ * sX ) ), ( cY * cX ), 0.0f ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotation( float radians, const Vector3 & unitVec ) -{ - float x, y, z, s, c, oneMinusC, xy, yz, zx; - s = sinf( radians ); - c = cosf( radians ); - x = unitVec.getX(); - y = unitVec.getY(); - z = unitVec.getZ(); - xy = ( x * y ); - yz = ( y * z ); - zx = ( z * x ); - oneMinusC = ( 1.0f - c ); - return Matrix4( - Vector4( ( ( ( x * x ) * oneMinusC ) + c ), ( ( xy * oneMinusC ) + ( z * s ) ), ( ( zx * oneMinusC ) - ( y * s ) ), 0.0f ), - Vector4( ( ( xy * oneMinusC ) - ( z * s ) ), ( ( ( y * y ) * oneMinusC ) + c ), ( ( yz * oneMinusC ) + ( x * s ) ), 0.0f ), - Vector4( ( ( zx * oneMinusC ) + ( y * s ) ), ( ( yz * oneMinusC ) - ( x * s ) ), ( ( ( z * z ) * oneMinusC ) + c ), 0.0f ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotation( const Quat & unitQuat ) -{ - return Matrix4( Transform3::rotation( unitQuat ) ); -} - -inline const Matrix4 Matrix4::scale( const Vector3 & scaleVec ) -{ - return Matrix4( - Vector4( scaleVec.getX(), 0.0f, 0.0f, 0.0f ), - Vector4( 0.0f, scaleVec.getY(), 0.0f, 0.0f ), - Vector4( 0.0f, 0.0f, scaleVec.getZ(), 0.0f ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 appendScale( const Matrix4 & mat, const Vector3 & scaleVec ) -{ - return Matrix4( - ( mat.getCol0() * scaleVec.getX( ) ), - ( mat.getCol1() * scaleVec.getY( ) ), - ( mat.getCol2() * scaleVec.getZ( ) ), - mat.getCol3() - ); -} - -inline const Matrix4 prependScale( const Vector3 & scaleVec, const Matrix4 & mat ) -{ - Vector4 scale4; - scale4 = Vector4( scaleVec, 1.0f ); - return Matrix4( - mulPerElem( mat.getCol0(), scale4 ), - mulPerElem( mat.getCol1(), scale4 ), - mulPerElem( mat.getCol2(), scale4 ), - mulPerElem( mat.getCol3(), scale4 ) - ); -} - -inline const Matrix4 Matrix4::translation( const Vector3 & translateVec ) -{ - return Matrix4( - Vector4::xAxis( ), - Vector4::yAxis( ), - Vector4::zAxis( ), - Vector4( translateVec, 1.0f ) - ); -} - -inline const Matrix4 Matrix4::lookAt( const Point3 & eyePos, const Point3 & lookAtPos, const Vector3 & upVec ) -{ - Matrix4 m4EyeFrame; - Vector3 v3X, v3Y, v3Z; - v3Y = normalize( upVec ); - v3Z = normalize( ( eyePos - lookAtPos ) ); - v3X = normalize( cross( v3Y, v3Z ) ); - v3Y = cross( v3Z, v3X ); - m4EyeFrame = Matrix4( Vector4( v3X ), Vector4( v3Y ), Vector4( v3Z ), Vector4( eyePos ) ); - return orthoInverse( m4EyeFrame ); -} - -inline const Matrix4 Matrix4::perspective( float fovyRadians, float aspect, float zNear, float zFar ) -{ - float f, rangeInv; - f = tanf( ( (float)( _VECTORMATH_PI_OVER_2 ) - ( 0.5f * fovyRadians ) ) ); - rangeInv = ( 1.0f / ( zNear - zFar ) ); - return Matrix4( - Vector4( ( f / aspect ), 0.0f, 0.0f, 0.0f ), - Vector4( 0.0f, f, 0.0f, 0.0f ), - Vector4( 0.0f, 0.0f, ( ( zNear + zFar ) * rangeInv ), -1.0f ), - Vector4( 0.0f, 0.0f, ( ( ( zNear * zFar ) * rangeInv ) * 2.0f ), 0.0f ) - ); -} - -inline const Matrix4 Matrix4::frustum( float left, float right, float bottom, float top, float zNear, float zFar ) -{ - float sum_rl, sum_tb, sum_nf, inv_rl, inv_tb, inv_nf, n2; - sum_rl = ( right + left ); - sum_tb = ( top + bottom ); - sum_nf = ( zNear + zFar ); - inv_rl = ( 1.0f / ( right - left ) ); - inv_tb = ( 1.0f / ( top - bottom ) ); - inv_nf = ( 1.0f / ( zNear - zFar ) ); - n2 = ( zNear + zNear ); - return Matrix4( - Vector4( ( n2 * inv_rl ), 0.0f, 0.0f, 0.0f ), - Vector4( 0.0f, ( n2 * inv_tb ), 0.0f, 0.0f ), - Vector4( ( sum_rl * inv_rl ), ( sum_tb * inv_tb ), ( sum_nf * inv_nf ), -1.0f ), - Vector4( 0.0f, 0.0f, ( ( n2 * inv_nf ) * zFar ), 0.0f ) - ); -} - -inline const Matrix4 Matrix4::orthographic( float left, float right, float bottom, float top, float zNear, float zFar ) -{ - float sum_rl, sum_tb, sum_nf, inv_rl, inv_tb, inv_nf; - sum_rl = ( right + left ); - sum_tb = ( top + bottom ); - sum_nf = ( zNear + zFar ); - inv_rl = ( 1.0f / ( right - left ) ); - inv_tb = ( 1.0f / ( top - bottom ) ); - inv_nf = ( 1.0f / ( zNear - zFar ) ); - return Matrix4( - Vector4( ( inv_rl + inv_rl ), 0.0f, 0.0f, 0.0f ), - Vector4( 0.0f, ( inv_tb + inv_tb ), 0.0f, 0.0f ), - Vector4( 0.0f, 0.0f, ( inv_nf + inv_nf ), 0.0f ), - Vector4( ( -sum_rl * inv_rl ), ( -sum_tb * inv_tb ), ( sum_nf * inv_nf ), 1.0f ) - ); -} - -inline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, bool select1 ) -{ - return Matrix4( - select( mat0.getCol0(), mat1.getCol0(), select1 ), - select( mat0.getCol1(), mat1.getCol1(), select1 ), - select( mat0.getCol2(), mat1.getCol2(), select1 ), - select( mat0.getCol3(), mat1.getCol3(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Matrix4 & mat ) -{ - print( mat.getRow( 0 ) ); - print( mat.getRow( 1 ) ); - print( mat.getRow( 2 ) ); - print( mat.getRow( 3 ) ); -} - -inline void print( const Matrix4 & mat, const char * name ) -{ - printf("%s:\n", name); - print( mat ); -} - -#endif - -inline Transform3::Transform3( const Transform3 & tfrm ) -{ - mCol0 = tfrm.mCol0; - mCol1 = tfrm.mCol1; - mCol2 = tfrm.mCol2; - mCol3 = tfrm.mCol3; -} - -inline Transform3::Transform3( float scalar ) -{ - mCol0 = Vector3( scalar ); - mCol1 = Vector3( scalar ); - mCol2 = Vector3( scalar ); - mCol3 = Vector3( scalar ); -} - -inline Transform3::Transform3( const Vector3 & _col0, const Vector3 & _col1, const Vector3 & _col2, const Vector3 & _col3 ) -{ - mCol0 = _col0; - mCol1 = _col1; - mCol2 = _col2; - mCol3 = _col3; -} - -inline Transform3::Transform3( const Matrix3 & tfrm, const Vector3 & translateVec ) -{ - this->setUpper3x3( tfrm ); - this->setTranslation( translateVec ); -} - -inline Transform3::Transform3( const Quat & unitQuat, const Vector3 & translateVec ) -{ - this->setUpper3x3( Matrix3( unitQuat ) ); - this->setTranslation( translateVec ); -} - -inline Transform3 & Transform3::setCol0( const Vector3 & _col0 ) -{ - mCol0 = _col0; - return *this; -} - -inline Transform3 & Transform3::setCol1( const Vector3 & _col1 ) -{ - mCol1 = _col1; - return *this; -} - -inline Transform3 & Transform3::setCol2( const Vector3 & _col2 ) -{ - mCol2 = _col2; - return *this; -} - -inline Transform3 & Transform3::setCol3( const Vector3 & _col3 ) -{ - mCol3 = _col3; - return *this; -} - -inline Transform3 & Transform3::setCol( int col, const Vector3 & vec ) -{ - *(&mCol0 + col) = vec; - return *this; -} - -inline Transform3 & Transform3::setRow( int row, const Vector4 & vec ) -{ - mCol0.setElem( row, vec.getElem( 0 ) ); - mCol1.setElem( row, vec.getElem( 1 ) ); - mCol2.setElem( row, vec.getElem( 2 ) ); - mCol3.setElem( row, vec.getElem( 3 ) ); - return *this; -} - -inline Transform3 & Transform3::setElem( int col, int row, float val ) -{ - Vector3 tmpV3_0; - tmpV3_0 = this->getCol( col ); - tmpV3_0.setElem( row, val ); - this->setCol( col, tmpV3_0 ); - return *this; -} - -inline float Transform3::getElem( int col, int row ) const -{ - return this->getCol( col ).getElem( row ); -} - -inline const Vector3 Transform3::getCol0( ) const -{ - return mCol0; -} - -inline const Vector3 Transform3::getCol1( ) const -{ - return mCol1; -} - -inline const Vector3 Transform3::getCol2( ) const -{ - return mCol2; -} - -inline const Vector3 Transform3::getCol3( ) const -{ - return mCol3; -} - -inline const Vector3 Transform3::getCol( int col ) const -{ - return *(&mCol0 + col); -} - -inline const Vector4 Transform3::getRow( int row ) const -{ - return Vector4( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ), mCol3.getElem( row ) ); -} - -inline Vector3 & Transform3::operator []( int col ) -{ - return *(&mCol0 + col); -} - -inline const Vector3 Transform3::operator []( int col ) const -{ - return *(&mCol0 + col); -} - -inline Transform3 & Transform3::operator =( const Transform3 & tfrm ) -{ - mCol0 = tfrm.mCol0; - mCol1 = tfrm.mCol1; - mCol2 = tfrm.mCol2; - mCol3 = tfrm.mCol3; - return *this; -} - -inline const Transform3 inverse( const Transform3 & tfrm ) -{ - Vector3 tmp0, tmp1, tmp2, inv0, inv1, inv2; - float detinv; - tmp0 = cross( tfrm.getCol1(), tfrm.getCol2() ); - tmp1 = cross( tfrm.getCol2(), tfrm.getCol0() ); - tmp2 = cross( tfrm.getCol0(), tfrm.getCol1() ); - detinv = ( 1.0f / dot( tfrm.getCol2(), tmp2 ) ); - inv0 = Vector3( ( tmp0.getX() * detinv ), ( tmp1.getX() * detinv ), ( tmp2.getX() * detinv ) ); - inv1 = Vector3( ( tmp0.getY() * detinv ), ( tmp1.getY() * detinv ), ( tmp2.getY() * detinv ) ); - inv2 = Vector3( ( tmp0.getZ() * detinv ), ( tmp1.getZ() * detinv ), ( tmp2.getZ() * detinv ) ); - return Transform3( - inv0, - inv1, - inv2, - Vector3( ( -( ( inv0 * tfrm.getCol3().getX() ) + ( ( inv1 * tfrm.getCol3().getY() ) + ( inv2 * tfrm.getCol3().getZ() ) ) ) ) ) - ); -} - -inline const Transform3 orthoInverse( const Transform3 & tfrm ) -{ - Vector3 inv0, inv1, inv2; - inv0 = Vector3( tfrm.getCol0().getX(), tfrm.getCol1().getX(), tfrm.getCol2().getX() ); - inv1 = Vector3( tfrm.getCol0().getY(), tfrm.getCol1().getY(), tfrm.getCol2().getY() ); - inv2 = Vector3( tfrm.getCol0().getZ(), tfrm.getCol1().getZ(), tfrm.getCol2().getZ() ); - return Transform3( - inv0, - inv1, - inv2, - Vector3( ( -( ( inv0 * tfrm.getCol3().getX() ) + ( ( inv1 * tfrm.getCol3().getY() ) + ( inv2 * tfrm.getCol3().getZ() ) ) ) ) ) - ); -} - -inline const Transform3 absPerElem( const Transform3 & tfrm ) -{ - return Transform3( - absPerElem( tfrm.getCol0() ), - absPerElem( tfrm.getCol1() ), - absPerElem( tfrm.getCol2() ), - absPerElem( tfrm.getCol3() ) - ); -} - -inline const Vector3 Transform3::operator *( const Vector3 & vec ) const -{ - return Vector3( - ( ( ( mCol0.getX() * vec.getX() ) + ( mCol1.getX() * vec.getY() ) ) + ( mCol2.getX() * vec.getZ() ) ), - ( ( ( mCol0.getY() * vec.getX() ) + ( mCol1.getY() * vec.getY() ) ) + ( mCol2.getY() * vec.getZ() ) ), - ( ( ( mCol0.getZ() * vec.getX() ) + ( mCol1.getZ() * vec.getY() ) ) + ( mCol2.getZ() * vec.getZ() ) ) - ); -} - -inline const Point3 Transform3::operator *( const Point3 & pnt ) const -{ - return Point3( - ( ( ( ( mCol0.getX() * pnt.getX() ) + ( mCol1.getX() * pnt.getY() ) ) + ( mCol2.getX() * pnt.getZ() ) ) + mCol3.getX() ), - ( ( ( ( mCol0.getY() * pnt.getX() ) + ( mCol1.getY() * pnt.getY() ) ) + ( mCol2.getY() * pnt.getZ() ) ) + mCol3.getY() ), - ( ( ( ( mCol0.getZ() * pnt.getX() ) + ( mCol1.getZ() * pnt.getY() ) ) + ( mCol2.getZ() * pnt.getZ() ) ) + mCol3.getZ() ) - ); -} - -inline const Transform3 Transform3::operator *( const Transform3 & tfrm ) const -{ - return Transform3( - ( *this * tfrm.mCol0 ), - ( *this * tfrm.mCol1 ), - ( *this * tfrm.mCol2 ), - Vector3( ( *this * Point3( tfrm.mCol3 ) ) ) - ); -} - -inline Transform3 & Transform3::operator *=( const Transform3 & tfrm ) -{ - *this = *this * tfrm; - return *this; -} - -inline const Transform3 mulPerElem( const Transform3 & tfrm0, const Transform3 & tfrm1 ) -{ - return Transform3( - mulPerElem( tfrm0.getCol0(), tfrm1.getCol0() ), - mulPerElem( tfrm0.getCol1(), tfrm1.getCol1() ), - mulPerElem( tfrm0.getCol2(), tfrm1.getCol2() ), - mulPerElem( tfrm0.getCol3(), tfrm1.getCol3() ) - ); -} - -inline const Transform3 Transform3::identity( ) -{ - return Transform3( - Vector3::xAxis( ), - Vector3::yAxis( ), - Vector3::zAxis( ), - Vector3( 0.0f ) - ); -} - -inline Transform3 & Transform3::setUpper3x3( const Matrix3 & tfrm ) -{ - mCol0 = tfrm.getCol0(); - mCol1 = tfrm.getCol1(); - mCol2 = tfrm.getCol2(); - return *this; -} - -inline const Matrix3 Transform3::getUpper3x3( ) const -{ - return Matrix3( mCol0, mCol1, mCol2 ); -} - -inline Transform3 & Transform3::setTranslation( const Vector3 & translateVec ) -{ - mCol3 = translateVec; - return *this; -} - -inline const Vector3 Transform3::getTranslation( ) const -{ - return mCol3; -} - -inline const Transform3 Transform3::rotationX( float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - return Transform3( - Vector3::xAxis( ), - Vector3( 0.0f, c, s ), - Vector3( 0.0f, -s, c ), - Vector3( 0.0f ) - ); -} - -inline const Transform3 Transform3::rotationY( float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - return Transform3( - Vector3( c, 0.0f, -s ), - Vector3::yAxis( ), - Vector3( s, 0.0f, c ), - Vector3( 0.0f ) - ); -} - -inline const Transform3 Transform3::rotationZ( float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - return Transform3( - Vector3( c, s, 0.0f ), - Vector3( -s, c, 0.0f ), - Vector3::zAxis( ), - Vector3( 0.0f ) - ); -} - -inline const Transform3 Transform3::rotationZYX( const Vector3 & radiansXYZ ) -{ - float sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; - sX = sinf( radiansXYZ.getX() ); - cX = cosf( radiansXYZ.getX() ); - sY = sinf( radiansXYZ.getY() ); - cY = cosf( radiansXYZ.getY() ); - sZ = sinf( radiansXYZ.getZ() ); - cZ = cosf( radiansXYZ.getZ() ); - tmp0 = ( cZ * sY ); - tmp1 = ( sZ * sY ); - return Transform3( - Vector3( ( cZ * cY ), ( sZ * cY ), -sY ), - Vector3( ( ( tmp0 * sX ) - ( sZ * cX ) ), ( ( tmp1 * sX ) + ( cZ * cX ) ), ( cY * sX ) ), - Vector3( ( ( tmp0 * cX ) + ( sZ * sX ) ), ( ( tmp1 * cX ) - ( cZ * sX ) ), ( cY * cX ) ), - Vector3( 0.0f ) - ); -} - -inline const Transform3 Transform3::rotation( float radians, const Vector3 & unitVec ) -{ - return Transform3( Matrix3::rotation( radians, unitVec ), Vector3( 0.0f ) ); -} - -inline const Transform3 Transform3::rotation( const Quat & unitQuat ) -{ - return Transform3( Matrix3( unitQuat ), Vector3( 0.0f ) ); -} - -inline const Transform3 Transform3::scale( const Vector3 & scaleVec ) -{ - return Transform3( - Vector3( scaleVec.getX(), 0.0f, 0.0f ), - Vector3( 0.0f, scaleVec.getY(), 0.0f ), - Vector3( 0.0f, 0.0f, scaleVec.getZ() ), - Vector3( 0.0f ) - ); -} - -inline const Transform3 appendScale( const Transform3 & tfrm, const Vector3 & scaleVec ) -{ - return Transform3( - ( tfrm.getCol0() * scaleVec.getX( ) ), - ( tfrm.getCol1() * scaleVec.getY( ) ), - ( tfrm.getCol2() * scaleVec.getZ( ) ), - tfrm.getCol3() - ); -} - -inline const Transform3 prependScale( const Vector3 & scaleVec, const Transform3 & tfrm ) -{ - return Transform3( - mulPerElem( tfrm.getCol0(), scaleVec ), - mulPerElem( tfrm.getCol1(), scaleVec ), - mulPerElem( tfrm.getCol2(), scaleVec ), - mulPerElem( tfrm.getCol3(), scaleVec ) - ); -} - -inline const Transform3 Transform3::translation( const Vector3 & translateVec ) -{ - return Transform3( - Vector3::xAxis( ), - Vector3::yAxis( ), - Vector3::zAxis( ), - translateVec - ); -} - -inline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, bool select1 ) -{ - return Transform3( - select( tfrm0.getCol0(), tfrm1.getCol0(), select1 ), - select( tfrm0.getCol1(), tfrm1.getCol1(), select1 ), - select( tfrm0.getCol2(), tfrm1.getCol2(), select1 ), - select( tfrm0.getCol3(), tfrm1.getCol3(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Transform3 & tfrm ) -{ - print( tfrm.getRow( 0 ) ); - print( tfrm.getRow( 1 ) ); - print( tfrm.getRow( 2 ) ); -} - -inline void print( const Transform3 & tfrm, const char * name ) -{ - printf("%s:\n", name); - print( tfrm ); -} - -#endif - -inline Quat::Quat( const Matrix3 & tfrm ) -{ - float trace, radicand, scale, xx, yx, zx, xy, yy, zy, xz, yz, zz, tmpx, tmpy, tmpz, tmpw, qx, qy, qz, qw; - int negTrace, ZgtX, ZgtY, YgtX; - int largestXorY, largestYorZ, largestZorX; - - xx = tfrm.getCol0().getX(); - yx = tfrm.getCol0().getY(); - zx = tfrm.getCol0().getZ(); - xy = tfrm.getCol1().getX(); - yy = tfrm.getCol1().getY(); - zy = tfrm.getCol1().getZ(); - xz = tfrm.getCol2().getX(); - yz = tfrm.getCol2().getY(); - zz = tfrm.getCol2().getZ(); - - trace = ( ( xx + yy ) + zz ); - - negTrace = ( trace < 0.0f ); - ZgtX = zz > xx; - ZgtY = zz > yy; - YgtX = yy > xx; - largestXorY = ( !ZgtX || !ZgtY ) && negTrace; - largestYorZ = ( YgtX || ZgtX ) && negTrace; - largestZorX = ( ZgtY || !YgtX ) && negTrace; - - if ( largestXorY ) - { - zz = -zz; - xy = -xy; - } - if ( largestYorZ ) - { - xx = -xx; - yz = -yz; - } - if ( largestZorX ) - { - yy = -yy; - zx = -zx; - } - - radicand = ( ( ( xx + yy ) + zz ) + 1.0f ); - scale = ( 0.5f * ( 1.0f / sqrtf( radicand ) ) ); - - tmpx = ( ( zy - yz ) * scale ); - tmpy = ( ( xz - zx ) * scale ); - tmpz = ( ( yx - xy ) * scale ); - tmpw = ( radicand * scale ); - qx = tmpx; - qy = tmpy; - qz = tmpz; - qw = tmpw; - - if ( largestXorY ) - { - qx = tmpw; - qy = tmpz; - qz = tmpy; - qw = tmpx; - } - if ( largestYorZ ) - { - tmpx = qx; - tmpz = qz; - qx = qy; - qy = tmpx; - qz = qw; - qw = tmpz; - } - - mX = qx; - mY = qy; - mZ = qz; - mW = qw; -} - -inline const Matrix3 outer( const Vector3 & tfrm0, const Vector3 & tfrm1 ) -{ - return Matrix3( - ( tfrm0 * tfrm1.getX( ) ), - ( tfrm0 * tfrm1.getY( ) ), - ( tfrm0 * tfrm1.getZ( ) ) - ); -} - -inline const Matrix4 outer( const Vector4 & tfrm0, const Vector4 & tfrm1 ) -{ - return Matrix4( - ( tfrm0 * tfrm1.getX( ) ), - ( tfrm0 * tfrm1.getY( ) ), - ( tfrm0 * tfrm1.getZ( ) ), - ( tfrm0 * tfrm1.getW( ) ) - ); -} - -inline const Vector3 rowMul( const Vector3 & vec, const Matrix3 & mat ) -{ - return Vector3( - ( ( ( vec.getX() * mat.getCol0().getX() ) + ( vec.getY() * mat.getCol0().getY() ) ) + ( vec.getZ() * mat.getCol0().getZ() ) ), - ( ( ( vec.getX() * mat.getCol1().getX() ) + ( vec.getY() * mat.getCol1().getY() ) ) + ( vec.getZ() * mat.getCol1().getZ() ) ), - ( ( ( vec.getX() * mat.getCol2().getX() ) + ( vec.getY() * mat.getCol2().getY() ) ) + ( vec.getZ() * mat.getCol2().getZ() ) ) - ); -} - -inline const Matrix3 crossMatrix( const Vector3 & vec ) -{ - return Matrix3( - Vector3( 0.0f, vec.getZ(), -vec.getY() ), - Vector3( -vec.getZ(), 0.0f, vec.getX() ), - Vector3( vec.getY(), -vec.getX(), 0.0f ) - ); -} - -inline const Matrix3 crossMatrixMul( const Vector3 & vec, const Matrix3 & mat ) -{ - return Matrix3( cross( vec, mat.getCol0() ), cross( vec, mat.getCol1() ), cross( vec, mat.getCol2() ) ); -} - -} // namespace Aos -} // namespace Vectormath - -#endif diff --git a/bullet/src/BulletMultiThreaded/vectormath/scalar/cpp/quat_aos.h b/bullet/src/BulletMultiThreaded/vectormath/scalar/cpp/quat_aos.h deleted file mode 100644 index 85c9e888b..000000000 --- a/bullet/src/BulletMultiThreaded/vectormath/scalar/cpp/quat_aos.h +++ /dev/null @@ -1,443 +0,0 @@ -/* - Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. - All rights reserved. - - Redistribution and use in source and binary forms, - with or without modification, are permitted provided that the - following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the Sony Computer Entertainment Inc nor the names - of its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef _VECTORMATH_QUAT_AOS_CPP_H -#define _VECTORMATH_QUAT_AOS_CPP_H -//----------------------------------------------------------------------------- -// Definitions - -#ifndef _VECTORMATH_INTERNAL_FUNCTIONS -#define _VECTORMATH_INTERNAL_FUNCTIONS - -#endif - -namespace Vectormath { -namespace Aos { - - -inline void loadXYZW( Quat & quat, const float* quad ) -{ - quat = Quat( *quad ); -} - -inline void storeXYZW( Quat vec, float * fptr ) -{ - vec = Quat(fptr[0],fptr[1],fptr[2],fptr[3]); -} - -inline Quat::Quat( const Quat & quat ) -{ - mX = quat.mX; - mY = quat.mY; - mZ = quat.mZ; - mW = quat.mW; -} - -inline Quat::Quat( float _x, float _y, float _z, float _w ) -{ - mX = _x; - mY = _y; - mZ = _z; - mW = _w; -} - -inline Quat::Quat( const Vector3 & xyz, float _w ) -{ - this->setXYZ( xyz ); - this->setW( _w ); -} - -inline Quat::Quat( const Vector4 & vec ) -{ - mX = vec.getX(); - mY = vec.getY(); - mZ = vec.getZ(); - mW = vec.getW(); -} - -inline Quat::Quat( float scalar ) -{ - mX = scalar; - mY = scalar; - mZ = scalar; - mW = scalar; -} - -inline const Quat Quat::identity( ) -{ - return Quat( 0.0f, 0.0f, 0.0f, 1.0f ); -} - -inline const Quat lerp( float t, const Quat & quat0, const Quat & quat1 ) -{ - return ( quat0 + ( ( quat1 - quat0 ) * t ) ); -} - -inline const Quat slerp( float t, const Quat & unitQuat0, const Quat & unitQuat1 ) -{ - Quat start; - float recipSinAngle, scale0, scale1, cosAngle, angle; - cosAngle = dot( unitQuat0, unitQuat1 ); - if ( cosAngle < 0.0f ) { - cosAngle = -cosAngle; - start = ( -unitQuat0 ); - } else { - start = unitQuat0; - } - if ( cosAngle < _VECTORMATH_SLERP_TOL ) { - angle = acosf( cosAngle ); - recipSinAngle = ( 1.0f / sinf( angle ) ); - scale0 = ( sinf( ( ( 1.0f - t ) * angle ) ) * recipSinAngle ); - scale1 = ( sinf( ( t * angle ) ) * recipSinAngle ); - } else { - scale0 = ( 1.0f - t ); - scale1 = t; - } - return ( ( start * scale0 ) + ( unitQuat1 * scale1 ) ); -} - -inline const Quat squad( float t, const Quat & unitQuat0, const Quat & unitQuat1, const Quat & unitQuat2, const Quat & unitQuat3 ) -{ - Quat tmp0, tmp1; - tmp0 = slerp( t, unitQuat0, unitQuat3 ); - tmp1 = slerp( t, unitQuat1, unitQuat2 ); - return slerp( ( ( 2.0f * t ) * ( 1.0f - t ) ), tmp0, tmp1 ); -} - -inline Quat & Quat::operator =( const Quat & quat ) -{ - mX = quat.mX; - mY = quat.mY; - mZ = quat.mZ; - mW = quat.mW; - return *this; -} - -inline Quat & Quat::setXYZ( const Vector3 & vec ) -{ - mX = vec.getX(); - mY = vec.getY(); - mZ = vec.getZ(); - return *this; -} - -inline const Vector3 Quat::getXYZ( ) const -{ - return Vector3( mX, mY, mZ ); -} - -inline Quat & Quat::setX( float _x ) -{ - mX = _x; - return *this; -} - -inline float Quat::getX( ) const -{ - return mX; -} - -inline Quat & Quat::setY( float _y ) -{ - mY = _y; - return *this; -} - -inline float Quat::getY( ) const -{ - return mY; -} - -inline Quat & Quat::setZ( float _z ) -{ - mZ = _z; - return *this; -} - -inline float Quat::getZ( ) const -{ - return mZ; -} - -inline Quat & Quat::setW( float _w ) -{ - mW = _w; - return *this; -} - -inline float Quat::getW( ) const -{ - return mW; -} - -inline Quat & Quat::setElem( int idx, float value ) -{ - *(&mX + idx) = value; - return *this; -} - -inline float Quat::getElem( int idx ) const -{ - return *(&mX + idx); -} - -inline float & Quat::operator []( int idx ) -{ - return *(&mX + idx); -} - -inline float Quat::operator []( int idx ) const -{ - return *(&mX + idx); -} - -inline const Quat Quat::operator +( const Quat & quat ) const -{ - return Quat( - ( mX + quat.mX ), - ( mY + quat.mY ), - ( mZ + quat.mZ ), - ( mW + quat.mW ) - ); -} - -inline const Quat Quat::operator -( const Quat & quat ) const -{ - return Quat( - ( mX - quat.mX ), - ( mY - quat.mY ), - ( mZ - quat.mZ ), - ( mW - quat.mW ) - ); -} - -inline const Quat Quat::operator *( float scalar ) const -{ - return Quat( - ( mX * scalar ), - ( mY * scalar ), - ( mZ * scalar ), - ( mW * scalar ) - ); -} - -inline Quat & Quat::operator +=( const Quat & quat ) -{ - *this = *this + quat; - return *this; -} - -inline Quat & Quat::operator -=( const Quat & quat ) -{ - *this = *this - quat; - return *this; -} - -inline Quat & Quat::operator *=( float scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline const Quat Quat::operator /( float scalar ) const -{ - return Quat( - ( mX / scalar ), - ( mY / scalar ), - ( mZ / scalar ), - ( mW / scalar ) - ); -} - -inline Quat & Quat::operator /=( float scalar ) -{ - *this = *this / scalar; - return *this; -} - -inline const Quat Quat::operator -( ) const -{ - return Quat( - -mX, - -mY, - -mZ, - -mW - ); -} - -inline const Quat operator *( float scalar, const Quat & quat ) -{ - return quat * scalar; -} - -inline float dot( const Quat & quat0, const Quat & quat1 ) -{ - float result; - result = ( quat0.getX() * quat1.getX() ); - result = ( result + ( quat0.getY() * quat1.getY() ) ); - result = ( result + ( quat0.getZ() * quat1.getZ() ) ); - result = ( result + ( quat0.getW() * quat1.getW() ) ); - return result; -} - -inline float norm( const Quat & quat ) -{ - float result; - result = ( quat.getX() * quat.getX() ); - result = ( result + ( quat.getY() * quat.getY() ) ); - result = ( result + ( quat.getZ() * quat.getZ() ) ); - result = ( result + ( quat.getW() * quat.getW() ) ); - return result; -} - -inline float length( const Quat & quat ) -{ - return sqrtf( norm( quat ) ); -} - -inline const Quat normalize( const Quat & quat ) -{ - float lenSqr, lenInv; - lenSqr = norm( quat ); - lenInv = ( 1.0f / sqrtf( lenSqr ) ); - return Quat( - ( quat.getX() * lenInv ), - ( quat.getY() * lenInv ), - ( quat.getZ() * lenInv ), - ( quat.getW() * lenInv ) - ); -} - -inline const Quat Quat::rotation( const Vector3 & unitVec0, const Vector3 & unitVec1 ) -{ - float cosHalfAngleX2, recipCosHalfAngleX2; - cosHalfAngleX2 = sqrtf( ( 2.0f * ( 1.0f + dot( unitVec0, unitVec1 ) ) ) ); - recipCosHalfAngleX2 = ( 1.0f / cosHalfAngleX2 ); - return Quat( ( cross( unitVec0, unitVec1 ) * recipCosHalfAngleX2 ), ( cosHalfAngleX2 * 0.5f ) ); -} - -inline const Quat Quat::rotation( float radians, const Vector3 & unitVec ) -{ - float s, c, angle; - angle = ( radians * 0.5f ); - s = sinf( angle ); - c = cosf( angle ); - return Quat( ( unitVec * s ), c ); -} - -inline const Quat Quat::rotationX( float radians ) -{ - float s, c, angle; - angle = ( radians * 0.5f ); - s = sinf( angle ); - c = cosf( angle ); - return Quat( s, 0.0f, 0.0f, c ); -} - -inline const Quat Quat::rotationY( float radians ) -{ - float s, c, angle; - angle = ( radians * 0.5f ); - s = sinf( angle ); - c = cosf( angle ); - return Quat( 0.0f, s, 0.0f, c ); -} - -inline const Quat Quat::rotationZ( float radians ) -{ - float s, c, angle; - angle = ( radians * 0.5f ); - s = sinf( angle ); - c = cosf( angle ); - return Quat( 0.0f, 0.0f, s, c ); -} - -inline const Quat Quat::operator *( const Quat & quat ) const -{ - return Quat( - ( ( ( ( mW * quat.mX ) + ( mX * quat.mW ) ) + ( mY * quat.mZ ) ) - ( mZ * quat.mY ) ), - ( ( ( ( mW * quat.mY ) + ( mY * quat.mW ) ) + ( mZ * quat.mX ) ) - ( mX * quat.mZ ) ), - ( ( ( ( mW * quat.mZ ) + ( mZ * quat.mW ) ) + ( mX * quat.mY ) ) - ( mY * quat.mX ) ), - ( ( ( ( mW * quat.mW ) - ( mX * quat.mX ) ) - ( mY * quat.mY ) ) - ( mZ * quat.mZ ) ) - ); -} - -inline Quat & Quat::operator *=( const Quat & quat ) -{ - *this = *this * quat; - return *this; -} - -inline const Vector3 rotate( const Quat & quat, const Vector3 & vec ) -{ - float tmpX, tmpY, tmpZ, tmpW; - tmpX = ( ( ( quat.getW() * vec.getX() ) + ( quat.getY() * vec.getZ() ) ) - ( quat.getZ() * vec.getY() ) ); - tmpY = ( ( ( quat.getW() * vec.getY() ) + ( quat.getZ() * vec.getX() ) ) - ( quat.getX() * vec.getZ() ) ); - tmpZ = ( ( ( quat.getW() * vec.getZ() ) + ( quat.getX() * vec.getY() ) ) - ( quat.getY() * vec.getX() ) ); - tmpW = ( ( ( quat.getX() * vec.getX() ) + ( quat.getY() * vec.getY() ) ) + ( quat.getZ() * vec.getZ() ) ); - return Vector3( - ( ( ( ( tmpW * quat.getX() ) + ( tmpX * quat.getW() ) ) - ( tmpY * quat.getZ() ) ) + ( tmpZ * quat.getY() ) ), - ( ( ( ( tmpW * quat.getY() ) + ( tmpY * quat.getW() ) ) - ( tmpZ * quat.getX() ) ) + ( tmpX * quat.getZ() ) ), - ( ( ( ( tmpW * quat.getZ() ) + ( tmpZ * quat.getW() ) ) - ( tmpX * quat.getY() ) ) + ( tmpY * quat.getX() ) ) - ); -} - -inline const Quat conj( const Quat & quat ) -{ - return Quat( -quat.getX(), -quat.getY(), -quat.getZ(), quat.getW() ); -} - -inline const Quat select( const Quat & quat0, const Quat & quat1, bool select1 ) -{ - return Quat( - ( select1 )? quat1.getX() : quat0.getX(), - ( select1 )? quat1.getY() : quat0.getY(), - ( select1 )? quat1.getZ() : quat0.getZ(), - ( select1 )? quat1.getW() : quat0.getW() - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Quat & quat ) -{ - printf( "( %f %f %f %f )\n", quat.getX(), quat.getY(), quat.getZ(), quat.getW() ); -} - -inline void print( const Quat & quat, const char * name ) -{ - printf( "%s: ( %f %f %f %f )\n", name, quat.getX(), quat.getY(), quat.getZ(), quat.getW() ); -} - -#endif - -} // namespace Aos -} // namespace Vectormath - -#endif diff --git a/bullet/src/BulletMultiThreaded/vectormath/scalar/cpp/vec_aos.h b/bullet/src/BulletMultiThreaded/vectormath/scalar/cpp/vec_aos.h deleted file mode 100644 index 1d6e7e6f1..000000000 --- a/bullet/src/BulletMultiThreaded/vectormath/scalar/cpp/vec_aos.h +++ /dev/null @@ -1,1193 +0,0 @@ -/* - Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. - All rights reserved. - - Redistribution and use in source and binary forms, - with or without modification, are permitted provided that the - following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the Sony Computer Entertainment Inc nor the names - of its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef _VECTORMATH_VEC_AOS_CPP_H -#define _VECTORMATH_VEC_AOS_CPP_H -//----------------------------------------------------------------------------- -// Constants - -#define _VECTORMATH_SLERP_TOL 0.999f - -//----------------------------------------------------------------------------- -// Definitions - -#ifndef _VECTORMATH_INTERNAL_FUNCTIONS -#define _VECTORMATH_INTERNAL_FUNCTIONS - -#endif - -namespace Vectormath { -namespace Aos { - -inline Vector3::Vector3( const Vector3 & vec ) -{ - mX = vec.mX; - mY = vec.mY; - mZ = vec.mZ; -} - -inline Vector3::Vector3( float _x, float _y, float _z ) -{ - mX = _x; - mY = _y; - mZ = _z; -} - -inline Vector3::Vector3( const Point3 & pnt ) -{ - mX = pnt.getX(); - mY = pnt.getY(); - mZ = pnt.getZ(); -} - -inline Vector3::Vector3( float scalar ) -{ - mX = scalar; - mY = scalar; - mZ = scalar; -} - -inline const Vector3 Vector3::xAxis( ) -{ - return Vector3( 1.0f, 0.0f, 0.0f ); -} - -inline const Vector3 Vector3::yAxis( ) -{ - return Vector3( 0.0f, 1.0f, 0.0f ); -} - -inline const Vector3 Vector3::zAxis( ) -{ - return Vector3( 0.0f, 0.0f, 1.0f ); -} - -inline const Vector3 lerp( float t, const Vector3 & vec0, const Vector3 & vec1 ) -{ - return ( vec0 + ( ( vec1 - vec0 ) * t ) ); -} - -inline const Vector3 slerp( float t, const Vector3 & unitVec0, const Vector3 & unitVec1 ) -{ - float recipSinAngle, scale0, scale1, cosAngle, angle; - cosAngle = dot( unitVec0, unitVec1 ); - if ( cosAngle < _VECTORMATH_SLERP_TOL ) { - angle = acosf( cosAngle ); - recipSinAngle = ( 1.0f / sinf( angle ) ); - scale0 = ( sinf( ( ( 1.0f - t ) * angle ) ) * recipSinAngle ); - scale1 = ( sinf( ( t * angle ) ) * recipSinAngle ); - } else { - scale0 = ( 1.0f - t ); - scale1 = t; - } - return ( ( unitVec0 * scale0 ) + ( unitVec1 * scale1 ) ); -} - -inline void loadXYZ( Vector3 & vec, const float * quad ) -{ - vec = Vector3( *quad ); -} - -inline void loadXYZW( Vector4 & vec, const float * quad ) -{ - vec = Vector4( *quad ); -} - - -inline void storeXYZ( Vector3 vec, float * fptr ) -{ - vec = Vector3(fptr[0],fptr[1],fptr[2]); -} - - - - - -inline Vector3 & Vector3::operator =( const Vector3 & vec ) -{ - mX = vec.mX; - mY = vec.mY; - mZ = vec.mZ; - return *this; -} - -inline Vector3 & Vector3::setX( float _x ) -{ - mX = _x; - return *this; -} - -inline float Vector3::getX( ) const -{ - return mX; -} - -inline Vector3 & Vector3::setY( float _y ) -{ - mY = _y; - return *this; -} - -inline float Vector3::getY( ) const -{ - return mY; -} - -inline Vector3 & Vector3::setZ( float _z ) -{ - mZ = _z; - return *this; -} - -inline float Vector3::getZ( ) const -{ - return mZ; -} - -inline Vector3 & Vector3::setElem( int idx, float value ) -{ - *(&mX + idx) = value; - return *this; -} - -inline float Vector3::getElem( int idx ) const -{ - return *(&mX + idx); -} - -inline float & Vector3::operator []( int idx ) -{ - return *(&mX + idx); -} - -inline float Vector3::operator []( int idx ) const -{ - return *(&mX + idx); -} - -inline const Vector3 Vector3::operator +( const Vector3 & vec ) const -{ - return Vector3( - ( mX + vec.mX ), - ( mY + vec.mY ), - ( mZ + vec.mZ ) - ); -} - -inline const Vector3 Vector3::operator -( const Vector3 & vec ) const -{ - return Vector3( - ( mX - vec.mX ), - ( mY - vec.mY ), - ( mZ - vec.mZ ) - ); -} - -inline const Point3 Vector3::operator +( const Point3 & pnt ) const -{ - return Point3( - ( mX + pnt.getX() ), - ( mY + pnt.getY() ), - ( mZ + pnt.getZ() ) - ); -} - -inline const Vector3 Vector3::operator *( float scalar ) const -{ - return Vector3( - ( mX * scalar ), - ( mY * scalar ), - ( mZ * scalar ) - ); -} - -inline Vector3 & Vector3::operator +=( const Vector3 & vec ) -{ - *this = *this + vec; - return *this; -} - -inline Vector3 & Vector3::operator -=( const Vector3 & vec ) -{ - *this = *this - vec; - return *this; -} - -inline Vector3 & Vector3::operator *=( float scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline const Vector3 Vector3::operator /( float scalar ) const -{ - return Vector3( - ( mX / scalar ), - ( mY / scalar ), - ( mZ / scalar ) - ); -} - -inline Vector3 & Vector3::operator /=( float scalar ) -{ - *this = *this / scalar; - return *this; -} - -inline const Vector3 Vector3::operator -( ) const -{ - return Vector3( - -mX, - -mY, - -mZ - ); -} - -inline const Vector3 operator *( float scalar, const Vector3 & vec ) -{ - return vec * scalar; -} - -inline const Vector3 mulPerElem( const Vector3 & vec0, const Vector3 & vec1 ) -{ - return Vector3( - ( vec0.getX() * vec1.getX() ), - ( vec0.getY() * vec1.getY() ), - ( vec0.getZ() * vec1.getZ() ) - ); -} - -inline const Vector3 divPerElem( const Vector3 & vec0, const Vector3 & vec1 ) -{ - return Vector3( - ( vec0.getX() / vec1.getX() ), - ( vec0.getY() / vec1.getY() ), - ( vec0.getZ() / vec1.getZ() ) - ); -} - -inline const Vector3 recipPerElem( const Vector3 & vec ) -{ - return Vector3( - ( 1.0f / vec.getX() ), - ( 1.0f / vec.getY() ), - ( 1.0f / vec.getZ() ) - ); -} - -inline const Vector3 sqrtPerElem( const Vector3 & vec ) -{ - return Vector3( - sqrtf( vec.getX() ), - sqrtf( vec.getY() ), - sqrtf( vec.getZ() ) - ); -} - -inline const Vector3 rsqrtPerElem( const Vector3 & vec ) -{ - return Vector3( - ( 1.0f / sqrtf( vec.getX() ) ), - ( 1.0f / sqrtf( vec.getY() ) ), - ( 1.0f / sqrtf( vec.getZ() ) ) - ); -} - -inline const Vector3 absPerElem( const Vector3 & vec ) -{ - return Vector3( - fabsf( vec.getX() ), - fabsf( vec.getY() ), - fabsf( vec.getZ() ) - ); -} - -inline const Vector3 copySignPerElem( const Vector3 & vec0, const Vector3 & vec1 ) -{ - return Vector3( - ( vec1.getX() < 0.0f )? -fabsf( vec0.getX() ) : fabsf( vec0.getX() ), - ( vec1.getY() < 0.0f )? -fabsf( vec0.getY() ) : fabsf( vec0.getY() ), - ( vec1.getZ() < 0.0f )? -fabsf( vec0.getZ() ) : fabsf( vec0.getZ() ) - ); -} - -inline const Vector3 maxPerElem( const Vector3 & vec0, const Vector3 & vec1 ) -{ - return Vector3( - (vec0.getX() > vec1.getX())? vec0.getX() : vec1.getX(), - (vec0.getY() > vec1.getY())? vec0.getY() : vec1.getY(), - (vec0.getZ() > vec1.getZ())? vec0.getZ() : vec1.getZ() - ); -} - -inline float maxElem( const Vector3 & vec ) -{ - float result; - result = (vec.getX() > vec.getY())? vec.getX() : vec.getY(); - result = (vec.getZ() > result)? vec.getZ() : result; - return result; -} - -inline const Vector3 minPerElem( const Vector3 & vec0, const Vector3 & vec1 ) -{ - return Vector3( - (vec0.getX() < vec1.getX())? vec0.getX() : vec1.getX(), - (vec0.getY() < vec1.getY())? vec0.getY() : vec1.getY(), - (vec0.getZ() < vec1.getZ())? vec0.getZ() : vec1.getZ() - ); -} - -inline float minElem( const Vector3 & vec ) -{ - float result; - result = (vec.getX() < vec.getY())? vec.getX() : vec.getY(); - result = (vec.getZ() < result)? vec.getZ() : result; - return result; -} - -inline float sum( const Vector3 & vec ) -{ - float result; - result = ( vec.getX() + vec.getY() ); - result = ( result + vec.getZ() ); - return result; -} - -inline float dot( const Vector3 & vec0, const Vector3 & vec1 ) -{ - float result; - result = ( vec0.getX() * vec1.getX() ); - result = ( result + ( vec0.getY() * vec1.getY() ) ); - result = ( result + ( vec0.getZ() * vec1.getZ() ) ); - return result; -} - -inline float lengthSqr( const Vector3 & vec ) -{ - float result; - result = ( vec.getX() * vec.getX() ); - result = ( result + ( vec.getY() * vec.getY() ) ); - result = ( result + ( vec.getZ() * vec.getZ() ) ); - return result; -} - -inline float length( const Vector3 & vec ) -{ - return sqrtf( lengthSqr( vec ) ); -} - -inline const Vector3 normalize( const Vector3 & vec ) -{ - float lenSqr, lenInv; - lenSqr = lengthSqr( vec ); - lenInv = ( 1.0f / sqrtf( lenSqr ) ); - return Vector3( - ( vec.getX() * lenInv ), - ( vec.getY() * lenInv ), - ( vec.getZ() * lenInv ) - ); -} - -inline const Vector3 cross( const Vector3 & vec0, const Vector3 & vec1 ) -{ - return Vector3( - ( ( vec0.getY() * vec1.getZ() ) - ( vec0.getZ() * vec1.getY() ) ), - ( ( vec0.getZ() * vec1.getX() ) - ( vec0.getX() * vec1.getZ() ) ), - ( ( vec0.getX() * vec1.getY() ) - ( vec0.getY() * vec1.getX() ) ) - ); -} - -inline const Vector3 select( const Vector3 & vec0, const Vector3 & vec1, bool select1 ) -{ - return Vector3( - ( select1 )? vec1.getX() : vec0.getX(), - ( select1 )? vec1.getY() : vec0.getY(), - ( select1 )? vec1.getZ() : vec0.getZ() - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Vector3 & vec ) -{ - printf( "( %f %f %f )\n", vec.getX(), vec.getY(), vec.getZ() ); -} - -inline void print( const Vector3 & vec, const char * name ) -{ - printf( "%s: ( %f %f %f )\n", name, vec.getX(), vec.getY(), vec.getZ() ); -} - -#endif - -inline Vector4::Vector4( const Vector4 & vec ) -{ - mX = vec.mX; - mY = vec.mY; - mZ = vec.mZ; - mW = vec.mW; -} - -inline Vector4::Vector4( float _x, float _y, float _z, float _w ) -{ - mX = _x; - mY = _y; - mZ = _z; - mW = _w; -} - -inline Vector4::Vector4( const Vector3 & xyz, float _w ) -{ - this->setXYZ( xyz ); - this->setW( _w ); -} - -inline Vector4::Vector4( const Vector3 & vec ) -{ - mX = vec.getX(); - mY = vec.getY(); - mZ = vec.getZ(); - mW = 0.0f; -} - -inline Vector4::Vector4( const Point3 & pnt ) -{ - mX = pnt.getX(); - mY = pnt.getY(); - mZ = pnt.getZ(); - mW = 1.0f; -} - -inline Vector4::Vector4( const Quat & quat ) -{ - mX = quat.getX(); - mY = quat.getY(); - mZ = quat.getZ(); - mW = quat.getW(); -} - -inline Vector4::Vector4( float scalar ) -{ - mX = scalar; - mY = scalar; - mZ = scalar; - mW = scalar; -} - -inline const Vector4 Vector4::xAxis( ) -{ - return Vector4( 1.0f, 0.0f, 0.0f, 0.0f ); -} - -inline const Vector4 Vector4::yAxis( ) -{ - return Vector4( 0.0f, 1.0f, 0.0f, 0.0f ); -} - -inline const Vector4 Vector4::zAxis( ) -{ - return Vector4( 0.0f, 0.0f, 1.0f, 0.0f ); -} - -inline const Vector4 Vector4::wAxis( ) -{ - return Vector4( 0.0f, 0.0f, 0.0f, 1.0f ); -} - -inline const Vector4 lerp( float t, const Vector4 & vec0, const Vector4 & vec1 ) -{ - return ( vec0 + ( ( vec1 - vec0 ) * t ) ); -} - -inline const Vector4 slerp( float t, const Vector4 & unitVec0, const Vector4 & unitVec1 ) -{ - float recipSinAngle, scale0, scale1, cosAngle, angle; - cosAngle = dot( unitVec0, unitVec1 ); - if ( cosAngle < _VECTORMATH_SLERP_TOL ) { - angle = acosf( cosAngle ); - recipSinAngle = ( 1.0f / sinf( angle ) ); - scale0 = ( sinf( ( ( 1.0f - t ) * angle ) ) * recipSinAngle ); - scale1 = ( sinf( ( t * angle ) ) * recipSinAngle ); - } else { - scale0 = ( 1.0f - t ); - scale1 = t; - } - return ( ( unitVec0 * scale0 ) + ( unitVec1 * scale1 ) ); -} - -inline Vector4 & Vector4::operator =( const Vector4 & vec ) -{ - mX = vec.mX; - mY = vec.mY; - mZ = vec.mZ; - mW = vec.mW; - return *this; -} - -inline Vector4 & Vector4::setXYZ( const Vector3 & vec ) -{ - mX = vec.getX(); - mY = vec.getY(); - mZ = vec.getZ(); - return *this; -} - -inline const Vector3 Vector4::getXYZ( ) const -{ - return Vector3( mX, mY, mZ ); -} - -inline Vector4 & Vector4::setX( float _x ) -{ - mX = _x; - return *this; -} - -inline float Vector4::getX( ) const -{ - return mX; -} - -inline Vector4 & Vector4::setY( float _y ) -{ - mY = _y; - return *this; -} - -inline float Vector4::getY( ) const -{ - return mY; -} - -inline Vector4 & Vector4::setZ( float _z ) -{ - mZ = _z; - return *this; -} - -inline float Vector4::getZ( ) const -{ - return mZ; -} - -inline Vector4 & Vector4::setW( float _w ) -{ - mW = _w; - return *this; -} - -inline float Vector4::getW( ) const -{ - return mW; -} - -inline Vector4 & Vector4::setElem( int idx, float value ) -{ - *(&mX + idx) = value; - return *this; -} - -inline float Vector4::getElem( int idx ) const -{ - return *(&mX + idx); -} - -inline float & Vector4::operator []( int idx ) -{ - return *(&mX + idx); -} - -inline float Vector4::operator []( int idx ) const -{ - return *(&mX + idx); -} - -inline const Vector4 Vector4::operator +( const Vector4 & vec ) const -{ - return Vector4( - ( mX + vec.mX ), - ( mY + vec.mY ), - ( mZ + vec.mZ ), - ( mW + vec.mW ) - ); -} - -inline const Vector4 Vector4::operator -( const Vector4 & vec ) const -{ - return Vector4( - ( mX - vec.mX ), - ( mY - vec.mY ), - ( mZ - vec.mZ ), - ( mW - vec.mW ) - ); -} - -inline const Vector4 Vector4::operator *( float scalar ) const -{ - return Vector4( - ( mX * scalar ), - ( mY * scalar ), - ( mZ * scalar ), - ( mW * scalar ) - ); -} - -inline Vector4 & Vector4::operator +=( const Vector4 & vec ) -{ - *this = *this + vec; - return *this; -} - -inline Vector4 & Vector4::operator -=( const Vector4 & vec ) -{ - *this = *this - vec; - return *this; -} - -inline Vector4 & Vector4::operator *=( float scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline const Vector4 Vector4::operator /( float scalar ) const -{ - return Vector4( - ( mX / scalar ), - ( mY / scalar ), - ( mZ / scalar ), - ( mW / scalar ) - ); -} - -inline Vector4 & Vector4::operator /=( float scalar ) -{ - *this = *this / scalar; - return *this; -} - -inline const Vector4 Vector4::operator -( ) const -{ - return Vector4( - -mX, - -mY, - -mZ, - -mW - ); -} - -inline const Vector4 operator *( float scalar, const Vector4 & vec ) -{ - return vec * scalar; -} - -inline const Vector4 mulPerElem( const Vector4 & vec0, const Vector4 & vec1 ) -{ - return Vector4( - ( vec0.getX() * vec1.getX() ), - ( vec0.getY() * vec1.getY() ), - ( vec0.getZ() * vec1.getZ() ), - ( vec0.getW() * vec1.getW() ) - ); -} - -inline const Vector4 divPerElem( const Vector4 & vec0, const Vector4 & vec1 ) -{ - return Vector4( - ( vec0.getX() / vec1.getX() ), - ( vec0.getY() / vec1.getY() ), - ( vec0.getZ() / vec1.getZ() ), - ( vec0.getW() / vec1.getW() ) - ); -} - -inline const Vector4 recipPerElem( const Vector4 & vec ) -{ - return Vector4( - ( 1.0f / vec.getX() ), - ( 1.0f / vec.getY() ), - ( 1.0f / vec.getZ() ), - ( 1.0f / vec.getW() ) - ); -} - -inline const Vector4 sqrtPerElem( const Vector4 & vec ) -{ - return Vector4( - sqrtf( vec.getX() ), - sqrtf( vec.getY() ), - sqrtf( vec.getZ() ), - sqrtf( vec.getW() ) - ); -} - -inline const Vector4 rsqrtPerElem( const Vector4 & vec ) -{ - return Vector4( - ( 1.0f / sqrtf( vec.getX() ) ), - ( 1.0f / sqrtf( vec.getY() ) ), - ( 1.0f / sqrtf( vec.getZ() ) ), - ( 1.0f / sqrtf( vec.getW() ) ) - ); -} - -inline const Vector4 absPerElem( const Vector4 & vec ) -{ - return Vector4( - fabsf( vec.getX() ), - fabsf( vec.getY() ), - fabsf( vec.getZ() ), - fabsf( vec.getW() ) - ); -} - -inline const Vector4 copySignPerElem( const Vector4 & vec0, const Vector4 & vec1 ) -{ - return Vector4( - ( vec1.getX() < 0.0f )? -fabsf( vec0.getX() ) : fabsf( vec0.getX() ), - ( vec1.getY() < 0.0f )? -fabsf( vec0.getY() ) : fabsf( vec0.getY() ), - ( vec1.getZ() < 0.0f )? -fabsf( vec0.getZ() ) : fabsf( vec0.getZ() ), - ( vec1.getW() < 0.0f )? -fabsf( vec0.getW() ) : fabsf( vec0.getW() ) - ); -} - -inline const Vector4 maxPerElem( const Vector4 & vec0, const Vector4 & vec1 ) -{ - return Vector4( - (vec0.getX() > vec1.getX())? vec0.getX() : vec1.getX(), - (vec0.getY() > vec1.getY())? vec0.getY() : vec1.getY(), - (vec0.getZ() > vec1.getZ())? vec0.getZ() : vec1.getZ(), - (vec0.getW() > vec1.getW())? vec0.getW() : vec1.getW() - ); -} - -inline float maxElem( const Vector4 & vec ) -{ - float result; - result = (vec.getX() > vec.getY())? vec.getX() : vec.getY(); - result = (vec.getZ() > result)? vec.getZ() : result; - result = (vec.getW() > result)? vec.getW() : result; - return result; -} - -inline const Vector4 minPerElem( const Vector4 & vec0, const Vector4 & vec1 ) -{ - return Vector4( - (vec0.getX() < vec1.getX())? vec0.getX() : vec1.getX(), - (vec0.getY() < vec1.getY())? vec0.getY() : vec1.getY(), - (vec0.getZ() < vec1.getZ())? vec0.getZ() : vec1.getZ(), - (vec0.getW() < vec1.getW())? vec0.getW() : vec1.getW() - ); -} - -inline float minElem( const Vector4 & vec ) -{ - float result; - result = (vec.getX() < vec.getY())? vec.getX() : vec.getY(); - result = (vec.getZ() < result)? vec.getZ() : result; - result = (vec.getW() < result)? vec.getW() : result; - return result; -} - -inline float sum( const Vector4 & vec ) -{ - float result; - result = ( vec.getX() + vec.getY() ); - result = ( result + vec.getZ() ); - result = ( result + vec.getW() ); - return result; -} - -inline float dot( const Vector4 & vec0, const Vector4 & vec1 ) -{ - float result; - result = ( vec0.getX() * vec1.getX() ); - result = ( result + ( vec0.getY() * vec1.getY() ) ); - result = ( result + ( vec0.getZ() * vec1.getZ() ) ); - result = ( result + ( vec0.getW() * vec1.getW() ) ); - return result; -} - -inline float lengthSqr( const Vector4 & vec ) -{ - float result; - result = ( vec.getX() * vec.getX() ); - result = ( result + ( vec.getY() * vec.getY() ) ); - result = ( result + ( vec.getZ() * vec.getZ() ) ); - result = ( result + ( vec.getW() * vec.getW() ) ); - return result; -} - -inline float length( const Vector4 & vec ) -{ - return sqrtf( lengthSqr( vec ) ); -} - -inline const Vector4 normalize( const Vector4 & vec ) -{ - float lenSqr, lenInv; - lenSqr = lengthSqr( vec ); - lenInv = ( 1.0f / sqrtf( lenSqr ) ); - return Vector4( - ( vec.getX() * lenInv ), - ( vec.getY() * lenInv ), - ( vec.getZ() * lenInv ), - ( vec.getW() * lenInv ) - ); -} - -inline const Vector4 select( const Vector4 & vec0, const Vector4 & vec1, bool select1 ) -{ - return Vector4( - ( select1 )? vec1.getX() : vec0.getX(), - ( select1 )? vec1.getY() : vec0.getY(), - ( select1 )? vec1.getZ() : vec0.getZ(), - ( select1 )? vec1.getW() : vec0.getW() - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Vector4 & vec ) -{ - printf( "( %f %f %f %f )\n", vec.getX(), vec.getY(), vec.getZ(), vec.getW() ); -} - -inline void print( const Vector4 & vec, const char * name ) -{ - printf( "%s: ( %f %f %f %f )\n", name, vec.getX(), vec.getY(), vec.getZ(), vec.getW() ); -} - -#endif - -inline Point3::Point3( const Point3 & pnt ) -{ - mX = pnt.mX; - mY = pnt.mY; - mZ = pnt.mZ; -} - -inline Point3::Point3( float _x, float _y, float _z ) -{ - mX = _x; - mY = _y; - mZ = _z; -} - -inline Point3::Point3( const Vector3 & vec ) -{ - mX = vec.getX(); - mY = vec.getY(); - mZ = vec.getZ(); -} - -inline Point3::Point3( float scalar ) -{ - mX = scalar; - mY = scalar; - mZ = scalar; -} - -inline const Point3 lerp( float t, const Point3 & pnt0, const Point3 & pnt1 ) -{ - return ( pnt0 + ( ( pnt1 - pnt0 ) * t ) ); -} - -inline Point3 & Point3::operator =( const Point3 & pnt ) -{ - mX = pnt.mX; - mY = pnt.mY; - mZ = pnt.mZ; - return *this; -} - -inline Point3 & Point3::setX( float _x ) -{ - mX = _x; - return *this; -} - -inline float Point3::getX( ) const -{ - return mX; -} - -inline Point3 & Point3::setY( float _y ) -{ - mY = _y; - return *this; -} - -inline float Point3::getY( ) const -{ - return mY; -} - -inline Point3 & Point3::setZ( float _z ) -{ - mZ = _z; - return *this; -} - -inline float Point3::getZ( ) const -{ - return mZ; -} - -inline Point3 & Point3::setElem( int idx, float value ) -{ - *(&mX + idx) = value; - return *this; -} - -inline float Point3::getElem( int idx ) const -{ - return *(&mX + idx); -} - -inline float & Point3::operator []( int idx ) -{ - return *(&mX + idx); -} - -inline float Point3::operator []( int idx ) const -{ - return *(&mX + idx); -} - -inline const Vector3 Point3::operator -( const Point3 & pnt ) const -{ - return Vector3( - ( mX - pnt.mX ), - ( mY - pnt.mY ), - ( mZ - pnt.mZ ) - ); -} - -inline const Point3 Point3::operator +( const Vector3 & vec ) const -{ - return Point3( - ( mX + vec.getX() ), - ( mY + vec.getY() ), - ( mZ + vec.getZ() ) - ); -} - -inline const Point3 Point3::operator -( const Vector3 & vec ) const -{ - return Point3( - ( mX - vec.getX() ), - ( mY - vec.getY() ), - ( mZ - vec.getZ() ) - ); -} - -inline Point3 & Point3::operator +=( const Vector3 & vec ) -{ - *this = *this + vec; - return *this; -} - -inline Point3 & Point3::operator -=( const Vector3 & vec ) -{ - *this = *this - vec; - return *this; -} - -inline const Point3 mulPerElem( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return Point3( - ( pnt0.getX() * pnt1.getX() ), - ( pnt0.getY() * pnt1.getY() ), - ( pnt0.getZ() * pnt1.getZ() ) - ); -} - -inline const Point3 divPerElem( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return Point3( - ( pnt0.getX() / pnt1.getX() ), - ( pnt0.getY() / pnt1.getY() ), - ( pnt0.getZ() / pnt1.getZ() ) - ); -} - -inline const Point3 recipPerElem( const Point3 & pnt ) -{ - return Point3( - ( 1.0f / pnt.getX() ), - ( 1.0f / pnt.getY() ), - ( 1.0f / pnt.getZ() ) - ); -} - -inline const Point3 sqrtPerElem( const Point3 & pnt ) -{ - return Point3( - sqrtf( pnt.getX() ), - sqrtf( pnt.getY() ), - sqrtf( pnt.getZ() ) - ); -} - -inline const Point3 rsqrtPerElem( const Point3 & pnt ) -{ - return Point3( - ( 1.0f / sqrtf( pnt.getX() ) ), - ( 1.0f / sqrtf( pnt.getY() ) ), - ( 1.0f / sqrtf( pnt.getZ() ) ) - ); -} - -inline const Point3 absPerElem( const Point3 & pnt ) -{ - return Point3( - fabsf( pnt.getX() ), - fabsf( pnt.getY() ), - fabsf( pnt.getZ() ) - ); -} - -inline const Point3 copySignPerElem( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return Point3( - ( pnt1.getX() < 0.0f )? -fabsf( pnt0.getX() ) : fabsf( pnt0.getX() ), - ( pnt1.getY() < 0.0f )? -fabsf( pnt0.getY() ) : fabsf( pnt0.getY() ), - ( pnt1.getZ() < 0.0f )? -fabsf( pnt0.getZ() ) : fabsf( pnt0.getZ() ) - ); -} - -inline const Point3 maxPerElem( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return Point3( - (pnt0.getX() > pnt1.getX())? pnt0.getX() : pnt1.getX(), - (pnt0.getY() > pnt1.getY())? pnt0.getY() : pnt1.getY(), - (pnt0.getZ() > pnt1.getZ())? pnt0.getZ() : pnt1.getZ() - ); -} - -inline float maxElem( const Point3 & pnt ) -{ - float result; - result = (pnt.getX() > pnt.getY())? pnt.getX() : pnt.getY(); - result = (pnt.getZ() > result)? pnt.getZ() : result; - return result; -} - -inline const Point3 minPerElem( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return Point3( - (pnt0.getX() < pnt1.getX())? pnt0.getX() : pnt1.getX(), - (pnt0.getY() < pnt1.getY())? pnt0.getY() : pnt1.getY(), - (pnt0.getZ() < pnt1.getZ())? pnt0.getZ() : pnt1.getZ() - ); -} - -inline float minElem( const Point3 & pnt ) -{ - float result; - result = (pnt.getX() < pnt.getY())? pnt.getX() : pnt.getY(); - result = (pnt.getZ() < result)? pnt.getZ() : result; - return result; -} - -inline float sum( const Point3 & pnt ) -{ - float result; - result = ( pnt.getX() + pnt.getY() ); - result = ( result + pnt.getZ() ); - return result; -} - -inline const Point3 scale( const Point3 & pnt, float scaleVal ) -{ - return mulPerElem( pnt, Point3( scaleVal ) ); -} - -inline const Point3 scale( const Point3 & pnt, const Vector3 & scaleVec ) -{ - return mulPerElem( pnt, Point3( scaleVec ) ); -} - -inline float projection( const Point3 & pnt, const Vector3 & unitVec ) -{ - float result; - result = ( pnt.getX() * unitVec.getX() ); - result = ( result + ( pnt.getY() * unitVec.getY() ) ); - result = ( result + ( pnt.getZ() * unitVec.getZ() ) ); - return result; -} - -inline float distSqrFromOrigin( const Point3 & pnt ) -{ - return lengthSqr( Vector3( pnt ) ); -} - -inline float distFromOrigin( const Point3 & pnt ) -{ - return length( Vector3( pnt ) ); -} - -inline float distSqr( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return lengthSqr( ( pnt1 - pnt0 ) ); -} - -inline float dist( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return length( ( pnt1 - pnt0 ) ); -} - -inline const Point3 select( const Point3 & pnt0, const Point3 & pnt1, bool select1 ) -{ - return Point3( - ( select1 )? pnt1.getX() : pnt0.getX(), - ( select1 )? pnt1.getY() : pnt0.getY(), - ( select1 )? pnt1.getZ() : pnt0.getZ() - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Point3 & pnt ) -{ - printf( "( %f %f %f )\n", pnt.getX(), pnt.getY(), pnt.getZ() ); -} - -inline void print( const Point3 & pnt, const char * name ) -{ - printf( "%s: ( %f %f %f )\n", name, pnt.getX(), pnt.getY(), pnt.getZ() ); -} - -#endif - -} // namespace Aos -} // namespace Vectormath - -#endif diff --git a/bullet/src/BulletMultiThreaded/vectormath/scalar/cpp/vectormath_aos.h b/bullet/src/BulletMultiThreaded/vectormath/scalar/cpp/vectormath_aos.h deleted file mode 100644 index a41d22ad2..000000000 --- a/bullet/src/BulletMultiThreaded/vectormath/scalar/cpp/vectormath_aos.h +++ /dev/null @@ -1,1809 +0,0 @@ -/* - Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. - All rights reserved. - - Redistribution and use in source and binary forms, - with or without modification, are permitted provided that the - following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the Sony Computer Entertainment Inc nor the names - of its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef _VECTORMATH_AOS_CPP_SCALAR_H -#define _VECTORMATH_AOS_CPP_SCALAR_H - -#include - -#ifdef _VECTORMATH_DEBUG -#include -#endif - -namespace Vectormath { - -namespace Aos { - -//----------------------------------------------------------------------------- -// Forward Declarations -// - -class Vector3; -class Vector4; -class Point3; -class Quat; -class Matrix3; -class Matrix4; -class Transform3; - -// A 3-D vector in array-of-structures format -// -class Vector3 -{ - float mX; - float mY; - float mZ; -#ifndef __GNUC__ - float d; -#endif - -public: - // Default constructor; does no initialization - // - inline Vector3( ) { }; - - // Copy a 3-D vector - // - inline Vector3( const Vector3 & vec ); - - // Construct a 3-D vector from x, y, and z elements - // - inline Vector3( float x, float y, float z ); - - // Copy elements from a 3-D point into a 3-D vector - // - explicit inline Vector3( const Point3 & pnt ); - - // Set all elements of a 3-D vector to the same scalar value - // - explicit inline Vector3( float scalar ); - - // Assign one 3-D vector to another - // - inline Vector3 & operator =( const Vector3 & vec ); - - // Set the x element of a 3-D vector - // - inline Vector3 & setX( float x ); - - // Set the y element of a 3-D vector - // - inline Vector3 & setY( float y ); - - // Set the z element of a 3-D vector - // - inline Vector3 & setZ( float z ); - - // Get the x element of a 3-D vector - // - inline float getX( ) const; - - // Get the y element of a 3-D vector - // - inline float getY( ) const; - - // Get the z element of a 3-D vector - // - inline float getZ( ) const; - - // Set an x, y, or z element of a 3-D vector by index - // - inline Vector3 & setElem( int idx, float value ); - - // Get an x, y, or z element of a 3-D vector by index - // - inline float getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - inline float & operator []( int idx ); - - // Subscripting operator to get an element - // - inline float operator []( int idx ) const; - - // Add two 3-D vectors - // - inline const Vector3 operator +( const Vector3 & vec ) const; - - // Subtract a 3-D vector from another 3-D vector - // - inline const Vector3 operator -( const Vector3 & vec ) const; - - // Add a 3-D vector to a 3-D point - // - inline const Point3 operator +( const Point3 & pnt ) const; - - // Multiply a 3-D vector by a scalar - // - inline const Vector3 operator *( float scalar ) const; - - // Divide a 3-D vector by a scalar - // - inline const Vector3 operator /( float scalar ) const; - - // Perform compound assignment and addition with a 3-D vector - // - inline Vector3 & operator +=( const Vector3 & vec ); - - // Perform compound assignment and subtraction by a 3-D vector - // - inline Vector3 & operator -=( const Vector3 & vec ); - - // Perform compound assignment and multiplication by a scalar - // - inline Vector3 & operator *=( float scalar ); - - // Perform compound assignment and division by a scalar - // - inline Vector3 & operator /=( float scalar ); - - // Negate all elements of a 3-D vector - // - inline const Vector3 operator -( ) const; - - // Construct x axis - // - static inline const Vector3 xAxis( ); - - // Construct y axis - // - static inline const Vector3 yAxis( ); - - // Construct z axis - // - static inline const Vector3 zAxis( ); - -} -#ifdef __GNUC__ -__attribute__ ((aligned(16))) -#endif -; - -// Multiply a 3-D vector by a scalar -// -inline const Vector3 operator *( float scalar, const Vector3 & vec ); - -// Multiply two 3-D vectors per element -// -inline const Vector3 mulPerElem( const Vector3 & vec0, const Vector3 & vec1 ); - -// Divide two 3-D vectors per element -// NOTE: -// Floating-point behavior matches standard library function divf4. -// -inline const Vector3 divPerElem( const Vector3 & vec0, const Vector3 & vec1 ); - -// Compute the reciprocal of a 3-D vector per element -// NOTE: -// Floating-point behavior matches standard library function recipf4. -// -inline const Vector3 recipPerElem( const Vector3 & vec ); - -// Compute the square root of a 3-D vector per element -// NOTE: -// Floating-point behavior matches standard library function sqrtf4. -// -inline const Vector3 sqrtPerElem( const Vector3 & vec ); - -// Compute the reciprocal square root of a 3-D vector per element -// NOTE: -// Floating-point behavior matches standard library function rsqrtf4. -// -inline const Vector3 rsqrtPerElem( const Vector3 & vec ); - -// Compute the absolute value of a 3-D vector per element -// -inline const Vector3 absPerElem( const Vector3 & vec ); - -// Copy sign from one 3-D vector to another, per element -// -inline const Vector3 copySignPerElem( const Vector3 & vec0, const Vector3 & vec1 ); - -// Maximum of two 3-D vectors per element -// -inline const Vector3 maxPerElem( const Vector3 & vec0, const Vector3 & vec1 ); - -// Minimum of two 3-D vectors per element -// -inline const Vector3 minPerElem( const Vector3 & vec0, const Vector3 & vec1 ); - -// Maximum element of a 3-D vector -// -inline float maxElem( const Vector3 & vec ); - -// Minimum element of a 3-D vector -// -inline float minElem( const Vector3 & vec ); - -// Compute the sum of all elements of a 3-D vector -// -inline float sum( const Vector3 & vec ); - -// Compute the dot product of two 3-D vectors -// -inline float dot( const Vector3 & vec0, const Vector3 & vec1 ); - -// Compute the square of the length of a 3-D vector -// -inline float lengthSqr( const Vector3 & vec ); - -// Compute the length of a 3-D vector -// -inline float length( const Vector3 & vec ); - -// Normalize a 3-D vector -// NOTE: -// The result is unpredictable when all elements of vec are at or near zero. -// -inline const Vector3 normalize( const Vector3 & vec ); - -// Compute cross product of two 3-D vectors -// -inline const Vector3 cross( const Vector3 & vec0, const Vector3 & vec1 ); - -// Outer product of two 3-D vectors -// -inline const Matrix3 outer( const Vector3 & vec0, const Vector3 & vec1 ); - -// Pre-multiply a row vector by a 3x3 matrix -// -inline const Vector3 rowMul( const Vector3 & vec, const Matrix3 & mat ); - -// Cross-product matrix of a 3-D vector -// -inline const Matrix3 crossMatrix( const Vector3 & vec ); - -// Create cross-product matrix and multiply -// NOTE: -// Faster than separately creating a cross-product matrix and multiplying. -// -inline const Matrix3 crossMatrixMul( const Vector3 & vec, const Matrix3 & mat ); - -// Linear interpolation between two 3-D vectors -// NOTE: -// Does not clamp t between 0 and 1. -// -inline const Vector3 lerp( float t, const Vector3 & vec0, const Vector3 & vec1 ); - -// Spherical linear interpolation between two 3-D vectors -// NOTE: -// The result is unpredictable if the vectors point in opposite directions. -// Does not clamp t between 0 and 1. -// -inline const Vector3 slerp( float t, const Vector3 & unitVec0, const Vector3 & unitVec1 ); - -// Conditionally select between two 3-D vectors -// -inline const Vector3 select( const Vector3 & vec0, const Vector3 & vec1, bool select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3-D vector -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Vector3 & vec ); - -// Print a 3-D vector and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Vector3 & vec, const char * name ); - -#endif - -// A 4-D vector in array-of-structures format -// -class Vector4 -{ - float mX; - float mY; - float mZ; - float mW; - -public: - // Default constructor; does no initialization - // - inline Vector4( ) { }; - - // Copy a 4-D vector - // - inline Vector4( const Vector4 & vec ); - - // Construct a 4-D vector from x, y, z, and w elements - // - inline Vector4( float x, float y, float z, float w ); - - // Construct a 4-D vector from a 3-D vector and a scalar - // - inline Vector4( const Vector3 & xyz, float w ); - - // Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0 - // - explicit inline Vector4( const Vector3 & vec ); - - // Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1 - // - explicit inline Vector4( const Point3 & pnt ); - - // Copy elements from a quaternion into a 4-D vector - // - explicit inline Vector4( const Quat & quat ); - - // Set all elements of a 4-D vector to the same scalar value - // - explicit inline Vector4( float scalar ); - - // Assign one 4-D vector to another - // - inline Vector4 & operator =( const Vector4 & vec ); - - // Set the x, y, and z elements of a 4-D vector - // NOTE: - // This function does not change the w element. - // - inline Vector4 & setXYZ( const Vector3 & vec ); - - // Get the x, y, and z elements of a 4-D vector - // - inline const Vector3 getXYZ( ) const; - - // Set the x element of a 4-D vector - // - inline Vector4 & setX( float x ); - - // Set the y element of a 4-D vector - // - inline Vector4 & setY( float y ); - - // Set the z element of a 4-D vector - // - inline Vector4 & setZ( float z ); - - // Set the w element of a 4-D vector - // - inline Vector4 & setW( float w ); - - // Get the x element of a 4-D vector - // - inline float getX( ) const; - - // Get the y element of a 4-D vector - // - inline float getY( ) const; - - // Get the z element of a 4-D vector - // - inline float getZ( ) const; - - // Get the w element of a 4-D vector - // - inline float getW( ) const; - - // Set an x, y, z, or w element of a 4-D vector by index - // - inline Vector4 & setElem( int idx, float value ); - - // Get an x, y, z, or w element of a 4-D vector by index - // - inline float getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - inline float & operator []( int idx ); - - // Subscripting operator to get an element - // - inline float operator []( int idx ) const; - - // Add two 4-D vectors - // - inline const Vector4 operator +( const Vector4 & vec ) const; - - // Subtract a 4-D vector from another 4-D vector - // - inline const Vector4 operator -( const Vector4 & vec ) const; - - // Multiply a 4-D vector by a scalar - // - inline const Vector4 operator *( float scalar ) const; - - // Divide a 4-D vector by a scalar - // - inline const Vector4 operator /( float scalar ) const; - - // Perform compound assignment and addition with a 4-D vector - // - inline Vector4 & operator +=( const Vector4 & vec ); - - // Perform compound assignment and subtraction by a 4-D vector - // - inline Vector4 & operator -=( const Vector4 & vec ); - - // Perform compound assignment and multiplication by a scalar - // - inline Vector4 & operator *=( float scalar ); - - // Perform compound assignment and division by a scalar - // - inline Vector4 & operator /=( float scalar ); - - // Negate all elements of a 4-D vector - // - inline const Vector4 operator -( ) const; - - // Construct x axis - // - static inline const Vector4 xAxis( ); - - // Construct y axis - // - static inline const Vector4 yAxis( ); - - // Construct z axis - // - static inline const Vector4 zAxis( ); - - // Construct w axis - // - static inline const Vector4 wAxis( ); - -} -#ifdef __GNUC__ -__attribute__ ((aligned(16))) -#endif -; - -// Multiply a 4-D vector by a scalar -// -inline const Vector4 operator *( float scalar, const Vector4 & vec ); - -// Multiply two 4-D vectors per element -// -inline const Vector4 mulPerElem( const Vector4 & vec0, const Vector4 & vec1 ); - -// Divide two 4-D vectors per element -// NOTE: -// Floating-point behavior matches standard library function divf4. -// -inline const Vector4 divPerElem( const Vector4 & vec0, const Vector4 & vec1 ); - -// Compute the reciprocal of a 4-D vector per element -// NOTE: -// Floating-point behavior matches standard library function recipf4. -// -inline const Vector4 recipPerElem( const Vector4 & vec ); - -// Compute the square root of a 4-D vector per element -// NOTE: -// Floating-point behavior matches standard library function sqrtf4. -// -inline const Vector4 sqrtPerElem( const Vector4 & vec ); - -// Compute the reciprocal square root of a 4-D vector per element -// NOTE: -// Floating-point behavior matches standard library function rsqrtf4. -// -inline const Vector4 rsqrtPerElem( const Vector4 & vec ); - -// Compute the absolute value of a 4-D vector per element -// -inline const Vector4 absPerElem( const Vector4 & vec ); - -// Copy sign from one 4-D vector to another, per element -// -inline const Vector4 copySignPerElem( const Vector4 & vec0, const Vector4 & vec1 ); - -// Maximum of two 4-D vectors per element -// -inline const Vector4 maxPerElem( const Vector4 & vec0, const Vector4 & vec1 ); - -// Minimum of two 4-D vectors per element -// -inline const Vector4 minPerElem( const Vector4 & vec0, const Vector4 & vec1 ); - -// Maximum element of a 4-D vector -// -inline float maxElem( const Vector4 & vec ); - -// Minimum element of a 4-D vector -// -inline float minElem( const Vector4 & vec ); - -// Compute the sum of all elements of a 4-D vector -// -inline float sum( const Vector4 & vec ); - -// Compute the dot product of two 4-D vectors -// -inline float dot( const Vector4 & vec0, const Vector4 & vec1 ); - -// Compute the square of the length of a 4-D vector -// -inline float lengthSqr( const Vector4 & vec ); - -// Compute the length of a 4-D vector -// -inline float length( const Vector4 & vec ); - -// Normalize a 4-D vector -// NOTE: -// The result is unpredictable when all elements of vec are at or near zero. -// -inline const Vector4 normalize( const Vector4 & vec ); - -// Outer product of two 4-D vectors -// -inline const Matrix4 outer( const Vector4 & vec0, const Vector4 & vec1 ); - -// Linear interpolation between two 4-D vectors -// NOTE: -// Does not clamp t between 0 and 1. -// -inline const Vector4 lerp( float t, const Vector4 & vec0, const Vector4 & vec1 ); - -// Spherical linear interpolation between two 4-D vectors -// NOTE: -// The result is unpredictable if the vectors point in opposite directions. -// Does not clamp t between 0 and 1. -// -inline const Vector4 slerp( float t, const Vector4 & unitVec0, const Vector4 & unitVec1 ); - -// Conditionally select between two 4-D vectors -// -inline const Vector4 select( const Vector4 & vec0, const Vector4 & vec1, bool select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 4-D vector -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Vector4 & vec ); - -// Print a 4-D vector and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Vector4 & vec, const char * name ); - -#endif - -// A 3-D point in array-of-structures format -// -class Point3 -{ - float mX; - float mY; - float mZ; -#ifndef __GNUC__ - float d; -#endif - -public: - // Default constructor; does no initialization - // - inline Point3( ) { }; - - // Copy a 3-D point - // - inline Point3( const Point3 & pnt ); - - // Construct a 3-D point from x, y, and z elements - // - inline Point3( float x, float y, float z ); - - // Copy elements from a 3-D vector into a 3-D point - // - explicit inline Point3( const Vector3 & vec ); - - // Set all elements of a 3-D point to the same scalar value - // - explicit inline Point3( float scalar ); - - // Assign one 3-D point to another - // - inline Point3 & operator =( const Point3 & pnt ); - - // Set the x element of a 3-D point - // - inline Point3 & setX( float x ); - - // Set the y element of a 3-D point - // - inline Point3 & setY( float y ); - - // Set the z element of a 3-D point - // - inline Point3 & setZ( float z ); - - // Get the x element of a 3-D point - // - inline float getX( ) const; - - // Get the y element of a 3-D point - // - inline float getY( ) const; - - // Get the z element of a 3-D point - // - inline float getZ( ) const; - - // Set an x, y, or z element of a 3-D point by index - // - inline Point3 & setElem( int idx, float value ); - - // Get an x, y, or z element of a 3-D point by index - // - inline float getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - inline float & operator []( int idx ); - - // Subscripting operator to get an element - // - inline float operator []( int idx ) const; - - // Subtract a 3-D point from another 3-D point - // - inline const Vector3 operator -( const Point3 & pnt ) const; - - // Add a 3-D point to a 3-D vector - // - inline const Point3 operator +( const Vector3 & vec ) const; - - // Subtract a 3-D vector from a 3-D point - // - inline const Point3 operator -( const Vector3 & vec ) const; - - // Perform compound assignment and addition with a 3-D vector - // - inline Point3 & operator +=( const Vector3 & vec ); - - // Perform compound assignment and subtraction by a 3-D vector - // - inline Point3 & operator -=( const Vector3 & vec ); - -} -#ifdef __GNUC__ -__attribute__ ((aligned(16))) -#endif -; - -// Multiply two 3-D points per element -// -inline const Point3 mulPerElem( const Point3 & pnt0, const Point3 & pnt1 ); - -// Divide two 3-D points per element -// NOTE: -// Floating-point behavior matches standard library function divf4. -// -inline const Point3 divPerElem( const Point3 & pnt0, const Point3 & pnt1 ); - -// Compute the reciprocal of a 3-D point per element -// NOTE: -// Floating-point behavior matches standard library function recipf4. -// -inline const Point3 recipPerElem( const Point3 & pnt ); - -// Compute the square root of a 3-D point per element -// NOTE: -// Floating-point behavior matches standard library function sqrtf4. -// -inline const Point3 sqrtPerElem( const Point3 & pnt ); - -// Compute the reciprocal square root of a 3-D point per element -// NOTE: -// Floating-point behavior matches standard library function rsqrtf4. -// -inline const Point3 rsqrtPerElem( const Point3 & pnt ); - -// Compute the absolute value of a 3-D point per element -// -inline const Point3 absPerElem( const Point3 & pnt ); - -// Copy sign from one 3-D point to another, per element -// -inline const Point3 copySignPerElem( const Point3 & pnt0, const Point3 & pnt1 ); - -// Maximum of two 3-D points per element -// -inline const Point3 maxPerElem( const Point3 & pnt0, const Point3 & pnt1 ); - -// Minimum of two 3-D points per element -// -inline const Point3 minPerElem( const Point3 & pnt0, const Point3 & pnt1 ); - -// Maximum element of a 3-D point -// -inline float maxElem( const Point3 & pnt ); - -// Minimum element of a 3-D point -// -inline float minElem( const Point3 & pnt ); - -// Compute the sum of all elements of a 3-D point -// -inline float sum( const Point3 & pnt ); - -// Apply uniform scale to a 3-D point -// -inline const Point3 scale( const Point3 & pnt, float scaleVal ); - -// Apply non-uniform scale to a 3-D point -// -inline const Point3 scale( const Point3 & pnt, const Vector3 & scaleVec ); - -// Scalar projection of a 3-D point on a unit-length 3-D vector -// -inline float projection( const Point3 & pnt, const Vector3 & unitVec ); - -// Compute the square of the distance of a 3-D point from the coordinate-system origin -// -inline float distSqrFromOrigin( const Point3 & pnt ); - -// Compute the distance of a 3-D point from the coordinate-system origin -// -inline float distFromOrigin( const Point3 & pnt ); - -// Compute the square of the distance between two 3-D points -// -inline float distSqr( const Point3 & pnt0, const Point3 & pnt1 ); - -// Compute the distance between two 3-D points -// -inline float dist( const Point3 & pnt0, const Point3 & pnt1 ); - -// Linear interpolation between two 3-D points -// NOTE: -// Does not clamp t between 0 and 1. -// -inline const Point3 lerp( float t, const Point3 & pnt0, const Point3 & pnt1 ); - -// Conditionally select between two 3-D points -// -inline const Point3 select( const Point3 & pnt0, const Point3 & pnt1, bool select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3-D point -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Point3 & pnt ); - -// Print a 3-D point and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Point3 & pnt, const char * name ); - -#endif - -// A quaternion in array-of-structures format -// -class Quat -{ - float mX; - float mY; - float mZ; - float mW; - -public: - // Default constructor; does no initialization - // - inline Quat( ) { }; - - // Copy a quaternion - // - inline Quat( const Quat & quat ); - - // Construct a quaternion from x, y, z, and w elements - // - inline Quat( float x, float y, float z, float w ); - - // Construct a quaternion from a 3-D vector and a scalar - // - inline Quat( const Vector3 & xyz, float w ); - - // Copy elements from a 4-D vector into a quaternion - // - explicit inline Quat( const Vector4 & vec ); - - // Convert a rotation matrix to a unit-length quaternion - // - explicit inline Quat( const Matrix3 & rotMat ); - - // Set all elements of a quaternion to the same scalar value - // - explicit inline Quat( float scalar ); - - // Assign one quaternion to another - // - inline Quat & operator =( const Quat & quat ); - - // Set the x, y, and z elements of a quaternion - // NOTE: - // This function does not change the w element. - // - inline Quat & setXYZ( const Vector3 & vec ); - - // Get the x, y, and z elements of a quaternion - // - inline const Vector3 getXYZ( ) const; - - // Set the x element of a quaternion - // - inline Quat & setX( float x ); - - // Set the y element of a quaternion - // - inline Quat & setY( float y ); - - // Set the z element of a quaternion - // - inline Quat & setZ( float z ); - - // Set the w element of a quaternion - // - inline Quat & setW( float w ); - - // Get the x element of a quaternion - // - inline float getX( ) const; - - // Get the y element of a quaternion - // - inline float getY( ) const; - - // Get the z element of a quaternion - // - inline float getZ( ) const; - - // Get the w element of a quaternion - // - inline float getW( ) const; - - // Set an x, y, z, or w element of a quaternion by index - // - inline Quat & setElem( int idx, float value ); - - // Get an x, y, z, or w element of a quaternion by index - // - inline float getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - inline float & operator []( int idx ); - - // Subscripting operator to get an element - // - inline float operator []( int idx ) const; - - // Add two quaternions - // - inline const Quat operator +( const Quat & quat ) const; - - // Subtract a quaternion from another quaternion - // - inline const Quat operator -( const Quat & quat ) const; - - // Multiply two quaternions - // - inline const Quat operator *( const Quat & quat ) const; - - // Multiply a quaternion by a scalar - // - inline const Quat operator *( float scalar ) const; - - // Divide a quaternion by a scalar - // - inline const Quat operator /( float scalar ) const; - - // Perform compound assignment and addition with a quaternion - // - inline Quat & operator +=( const Quat & quat ); - - // Perform compound assignment and subtraction by a quaternion - // - inline Quat & operator -=( const Quat & quat ); - - // Perform compound assignment and multiplication by a quaternion - // - inline Quat & operator *=( const Quat & quat ); - - // Perform compound assignment and multiplication by a scalar - // - inline Quat & operator *=( float scalar ); - - // Perform compound assignment and division by a scalar - // - inline Quat & operator /=( float scalar ); - - // Negate all elements of a quaternion - // - inline const Quat operator -( ) const; - - // Construct an identity quaternion - // - static inline const Quat identity( ); - - // Construct a quaternion to rotate between two unit-length 3-D vectors - // NOTE: - // The result is unpredictable if unitVec0 and unitVec1 point in opposite directions. - // - static inline const Quat rotation( const Vector3 & unitVec0, const Vector3 & unitVec1 ); - - // Construct a quaternion to rotate around a unit-length 3-D vector - // - static inline const Quat rotation( float radians, const Vector3 & unitVec ); - - // Construct a quaternion to rotate around the x axis - // - static inline const Quat rotationX( float radians ); - - // Construct a quaternion to rotate around the y axis - // - static inline const Quat rotationY( float radians ); - - // Construct a quaternion to rotate around the z axis - // - static inline const Quat rotationZ( float radians ); - -} -#ifdef __GNUC__ -__attribute__ ((aligned(16))) -#endif -; - -// Multiply a quaternion by a scalar -// -inline const Quat operator *( float scalar, const Quat & quat ); - -// Compute the conjugate of a quaternion -// -inline const Quat conj( const Quat & quat ); - -// Use a unit-length quaternion to rotate a 3-D vector -// -inline const Vector3 rotate( const Quat & unitQuat, const Vector3 & vec ); - -// Compute the dot product of two quaternions -// -inline float dot( const Quat & quat0, const Quat & quat1 ); - -// Compute the norm of a quaternion -// -inline float norm( const Quat & quat ); - -// Compute the length of a quaternion -// -inline float length( const Quat & quat ); - -// Normalize a quaternion -// NOTE: -// The result is unpredictable when all elements of quat are at or near zero. -// -inline const Quat normalize( const Quat & quat ); - -// Linear interpolation between two quaternions -// NOTE: -// Does not clamp t between 0 and 1. -// -inline const Quat lerp( float t, const Quat & quat0, const Quat & quat1 ); - -// Spherical linear interpolation between two quaternions -// NOTE: -// Interpolates along the shortest path between orientations. -// Does not clamp t between 0 and 1. -// -inline const Quat slerp( float t, const Quat & unitQuat0, const Quat & unitQuat1 ); - -// Spherical quadrangle interpolation -// -inline const Quat squad( float t, const Quat & unitQuat0, const Quat & unitQuat1, const Quat & unitQuat2, const Quat & unitQuat3 ); - -// Conditionally select between two quaternions -// -inline const Quat select( const Quat & quat0, const Quat & quat1, bool select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a quaternion -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Quat & quat ); - -// Print a quaternion and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Quat & quat, const char * name ); - -#endif - -// A 3x3 matrix in array-of-structures format -// -class Matrix3 -{ - Vector3 mCol0; - Vector3 mCol1; - Vector3 mCol2; - -public: - // Default constructor; does no initialization - // - inline Matrix3( ) { }; - - // Copy a 3x3 matrix - // - inline Matrix3( const Matrix3 & mat ); - - // Construct a 3x3 matrix containing the specified columns - // - inline Matrix3( const Vector3 & col0, const Vector3 & col1, const Vector3 & col2 ); - - // Construct a 3x3 rotation matrix from a unit-length quaternion - // - explicit inline Matrix3( const Quat & unitQuat ); - - // Set all elements of a 3x3 matrix to the same scalar value - // - explicit inline Matrix3( float scalar ); - - // Assign one 3x3 matrix to another - // - inline Matrix3 & operator =( const Matrix3 & mat ); - - // Set column 0 of a 3x3 matrix - // - inline Matrix3 & setCol0( const Vector3 & col0 ); - - // Set column 1 of a 3x3 matrix - // - inline Matrix3 & setCol1( const Vector3 & col1 ); - - // Set column 2 of a 3x3 matrix - // - inline Matrix3 & setCol2( const Vector3 & col2 ); - - // Get column 0 of a 3x3 matrix - // - inline const Vector3 getCol0( ) const; - - // Get column 1 of a 3x3 matrix - // - inline const Vector3 getCol1( ) const; - - // Get column 2 of a 3x3 matrix - // - inline const Vector3 getCol2( ) const; - - // Set the column of a 3x3 matrix referred to by the specified index - // - inline Matrix3 & setCol( int col, const Vector3 & vec ); - - // Set the row of a 3x3 matrix referred to by the specified index - // - inline Matrix3 & setRow( int row, const Vector3 & vec ); - - // Get the column of a 3x3 matrix referred to by the specified index - // - inline const Vector3 getCol( int col ) const; - - // Get the row of a 3x3 matrix referred to by the specified index - // - inline const Vector3 getRow( int row ) const; - - // Subscripting operator to set or get a column - // - inline Vector3 & operator []( int col ); - - // Subscripting operator to get a column - // - inline const Vector3 operator []( int col ) const; - - // Set the element of a 3x3 matrix referred to by column and row indices - // - inline Matrix3 & setElem( int col, int row, float val ); - - // Get the element of a 3x3 matrix referred to by column and row indices - // - inline float getElem( int col, int row ) const; - - // Add two 3x3 matrices - // - inline const Matrix3 operator +( const Matrix3 & mat ) const; - - // Subtract a 3x3 matrix from another 3x3 matrix - // - inline const Matrix3 operator -( const Matrix3 & mat ) const; - - // Negate all elements of a 3x3 matrix - // - inline const Matrix3 operator -( ) const; - - // Multiply a 3x3 matrix by a scalar - // - inline const Matrix3 operator *( float scalar ) const; - - // Multiply a 3x3 matrix by a 3-D vector - // - inline const Vector3 operator *( const Vector3 & vec ) const; - - // Multiply two 3x3 matrices - // - inline const Matrix3 operator *( const Matrix3 & mat ) const; - - // Perform compound assignment and addition with a 3x3 matrix - // - inline Matrix3 & operator +=( const Matrix3 & mat ); - - // Perform compound assignment and subtraction by a 3x3 matrix - // - inline Matrix3 & operator -=( const Matrix3 & mat ); - - // Perform compound assignment and multiplication by a scalar - // - inline Matrix3 & operator *=( float scalar ); - - // Perform compound assignment and multiplication by a 3x3 matrix - // - inline Matrix3 & operator *=( const Matrix3 & mat ); - - // Construct an identity 3x3 matrix - // - static inline const Matrix3 identity( ); - - // Construct a 3x3 matrix to rotate around the x axis - // - static inline const Matrix3 rotationX( float radians ); - - // Construct a 3x3 matrix to rotate around the y axis - // - static inline const Matrix3 rotationY( float radians ); - - // Construct a 3x3 matrix to rotate around the z axis - // - static inline const Matrix3 rotationZ( float radians ); - - // Construct a 3x3 matrix to rotate around the x, y, and z axes - // - static inline const Matrix3 rotationZYX( const Vector3 & radiansXYZ ); - - // Construct a 3x3 matrix to rotate around a unit-length 3-D vector - // - static inline const Matrix3 rotation( float radians, const Vector3 & unitVec ); - - // Construct a rotation matrix from a unit-length quaternion - // - static inline const Matrix3 rotation( const Quat & unitQuat ); - - // Construct a 3x3 matrix to perform scaling - // - static inline const Matrix3 scale( const Vector3 & scaleVec ); - -}; -// Multiply a 3x3 matrix by a scalar -// -inline const Matrix3 operator *( float scalar, const Matrix3 & mat ); - -// Append (post-multiply) a scale transformation to a 3x3 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Matrix3 appendScale( const Matrix3 & mat, const Vector3 & scaleVec ); - -// Prepend (pre-multiply) a scale transformation to a 3x3 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Matrix3 prependScale( const Vector3 & scaleVec, const Matrix3 & mat ); - -// Multiply two 3x3 matrices per element -// -inline const Matrix3 mulPerElem( const Matrix3 & mat0, const Matrix3 & mat1 ); - -// Compute the absolute value of a 3x3 matrix per element -// -inline const Matrix3 absPerElem( const Matrix3 & mat ); - -// Transpose of a 3x3 matrix -// -inline const Matrix3 transpose( const Matrix3 & mat ); - -// Compute the inverse of a 3x3 matrix -// NOTE: -// Result is unpredictable when the determinant of mat is equal to or near 0. -// -inline const Matrix3 inverse( const Matrix3 & mat ); - -// Determinant of a 3x3 matrix -// -inline float determinant( const Matrix3 & mat ); - -// Conditionally select between two 3x3 matrices -// -inline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, bool select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3x3 matrix -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Matrix3 & mat ); - -// Print a 3x3 matrix and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Matrix3 & mat, const char * name ); - -#endif - -// A 4x4 matrix in array-of-structures format -// -class Matrix4 -{ - Vector4 mCol0; - Vector4 mCol1; - Vector4 mCol2; - Vector4 mCol3; - -public: - // Default constructor; does no initialization - // - inline Matrix4( ) { }; - - // Copy a 4x4 matrix - // - inline Matrix4( const Matrix4 & mat ); - - // Construct a 4x4 matrix containing the specified columns - // - inline Matrix4( const Vector4 & col0, const Vector4 & col1, const Vector4 & col2, const Vector4 & col3 ); - - // Construct a 4x4 matrix from a 3x4 transformation matrix - // - explicit inline Matrix4( const Transform3 & mat ); - - // Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector - // - inline Matrix4( const Matrix3 & mat, const Vector3 & translateVec ); - - // Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector - // - inline Matrix4( const Quat & unitQuat, const Vector3 & translateVec ); - - // Set all elements of a 4x4 matrix to the same scalar value - // - explicit inline Matrix4( float scalar ); - - // Assign one 4x4 matrix to another - // - inline Matrix4 & operator =( const Matrix4 & mat ); - - // Set the upper-left 3x3 submatrix - // NOTE: - // This function does not change the bottom row elements. - // - inline Matrix4 & setUpper3x3( const Matrix3 & mat3 ); - - // Get the upper-left 3x3 submatrix of a 4x4 matrix - // - inline const Matrix3 getUpper3x3( ) const; - - // Set translation component - // NOTE: - // This function does not change the bottom row elements. - // - inline Matrix4 & setTranslation( const Vector3 & translateVec ); - - // Get the translation component of a 4x4 matrix - // - inline const Vector3 getTranslation( ) const; - - // Set column 0 of a 4x4 matrix - // - inline Matrix4 & setCol0( const Vector4 & col0 ); - - // Set column 1 of a 4x4 matrix - // - inline Matrix4 & setCol1( const Vector4 & col1 ); - - // Set column 2 of a 4x4 matrix - // - inline Matrix4 & setCol2( const Vector4 & col2 ); - - // Set column 3 of a 4x4 matrix - // - inline Matrix4 & setCol3( const Vector4 & col3 ); - - // Get column 0 of a 4x4 matrix - // - inline const Vector4 getCol0( ) const; - - // Get column 1 of a 4x4 matrix - // - inline const Vector4 getCol1( ) const; - - // Get column 2 of a 4x4 matrix - // - inline const Vector4 getCol2( ) const; - - // Get column 3 of a 4x4 matrix - // - inline const Vector4 getCol3( ) const; - - // Set the column of a 4x4 matrix referred to by the specified index - // - inline Matrix4 & setCol( int col, const Vector4 & vec ); - - // Set the row of a 4x4 matrix referred to by the specified index - // - inline Matrix4 & setRow( int row, const Vector4 & vec ); - - // Get the column of a 4x4 matrix referred to by the specified index - // - inline const Vector4 getCol( int col ) const; - - // Get the row of a 4x4 matrix referred to by the specified index - // - inline const Vector4 getRow( int row ) const; - - // Subscripting operator to set or get a column - // - inline Vector4 & operator []( int col ); - - // Subscripting operator to get a column - // - inline const Vector4 operator []( int col ) const; - - // Set the element of a 4x4 matrix referred to by column and row indices - // - inline Matrix4 & setElem( int col, int row, float val ); - - // Get the element of a 4x4 matrix referred to by column and row indices - // - inline float getElem( int col, int row ) const; - - // Add two 4x4 matrices - // - inline const Matrix4 operator +( const Matrix4 & mat ) const; - - // Subtract a 4x4 matrix from another 4x4 matrix - // - inline const Matrix4 operator -( const Matrix4 & mat ) const; - - // Negate all elements of a 4x4 matrix - // - inline const Matrix4 operator -( ) const; - - // Multiply a 4x4 matrix by a scalar - // - inline const Matrix4 operator *( float scalar ) const; - - // Multiply a 4x4 matrix by a 4-D vector - // - inline const Vector4 operator *( const Vector4 & vec ) const; - - // Multiply a 4x4 matrix by a 3-D vector - // - inline const Vector4 operator *( const Vector3 & vec ) const; - - // Multiply a 4x4 matrix by a 3-D point - // - inline const Vector4 operator *( const Point3 & pnt ) const; - - // Multiply two 4x4 matrices - // - inline const Matrix4 operator *( const Matrix4 & mat ) const; - - // Multiply a 4x4 matrix by a 3x4 transformation matrix - // - inline const Matrix4 operator *( const Transform3 & tfrm ) const; - - // Perform compound assignment and addition with a 4x4 matrix - // - inline Matrix4 & operator +=( const Matrix4 & mat ); - - // Perform compound assignment and subtraction by a 4x4 matrix - // - inline Matrix4 & operator -=( const Matrix4 & mat ); - - // Perform compound assignment and multiplication by a scalar - // - inline Matrix4 & operator *=( float scalar ); - - // Perform compound assignment and multiplication by a 4x4 matrix - // - inline Matrix4 & operator *=( const Matrix4 & mat ); - - // Perform compound assignment and multiplication by a 3x4 transformation matrix - // - inline Matrix4 & operator *=( const Transform3 & tfrm ); - - // Construct an identity 4x4 matrix - // - static inline const Matrix4 identity( ); - - // Construct a 4x4 matrix to rotate around the x axis - // - static inline const Matrix4 rotationX( float radians ); - - // Construct a 4x4 matrix to rotate around the y axis - // - static inline const Matrix4 rotationY( float radians ); - - // Construct a 4x4 matrix to rotate around the z axis - // - static inline const Matrix4 rotationZ( float radians ); - - // Construct a 4x4 matrix to rotate around the x, y, and z axes - // - static inline const Matrix4 rotationZYX( const Vector3 & radiansXYZ ); - - // Construct a 4x4 matrix to rotate around a unit-length 3-D vector - // - static inline const Matrix4 rotation( float radians, const Vector3 & unitVec ); - - // Construct a rotation matrix from a unit-length quaternion - // - static inline const Matrix4 rotation( const Quat & unitQuat ); - - // Construct a 4x4 matrix to perform scaling - // - static inline const Matrix4 scale( const Vector3 & scaleVec ); - - // Construct a 4x4 matrix to perform translation - // - static inline const Matrix4 translation( const Vector3 & translateVec ); - - // Construct viewing matrix based on eye position, position looked at, and up direction - // - static inline const Matrix4 lookAt( const Point3 & eyePos, const Point3 & lookAtPos, const Vector3 & upVec ); - - // Construct a perspective projection matrix - // - static inline const Matrix4 perspective( float fovyRadians, float aspect, float zNear, float zFar ); - - // Construct a perspective projection matrix based on frustum - // - static inline const Matrix4 frustum( float left, float right, float bottom, float top, float zNear, float zFar ); - - // Construct an orthographic projection matrix - // - static inline const Matrix4 orthographic( float left, float right, float bottom, float top, float zNear, float zFar ); - -}; -// Multiply a 4x4 matrix by a scalar -// -inline const Matrix4 operator *( float scalar, const Matrix4 & mat ); - -// Append (post-multiply) a scale transformation to a 4x4 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Matrix4 appendScale( const Matrix4 & mat, const Vector3 & scaleVec ); - -// Prepend (pre-multiply) a scale transformation to a 4x4 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Matrix4 prependScale( const Vector3 & scaleVec, const Matrix4 & mat ); - -// Multiply two 4x4 matrices per element -// -inline const Matrix4 mulPerElem( const Matrix4 & mat0, const Matrix4 & mat1 ); - -// Compute the absolute value of a 4x4 matrix per element -// -inline const Matrix4 absPerElem( const Matrix4 & mat ); - -// Transpose of a 4x4 matrix -// -inline const Matrix4 transpose( const Matrix4 & mat ); - -// Compute the inverse of a 4x4 matrix -// NOTE: -// Result is unpredictable when the determinant of mat is equal to or near 0. -// -inline const Matrix4 inverse( const Matrix4 & mat ); - -// Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix -// NOTE: -// This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. The result is unpredictable when the determinant of mat is equal to or near 0. -// -inline const Matrix4 affineInverse( const Matrix4 & mat ); - -// Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix -// NOTE: -// This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. -// -inline const Matrix4 orthoInverse( const Matrix4 & mat ); - -// Determinant of a 4x4 matrix -// -inline float determinant( const Matrix4 & mat ); - -// Conditionally select between two 4x4 matrices -// -inline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, bool select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 4x4 matrix -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Matrix4 & mat ); - -// Print a 4x4 matrix and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Matrix4 & mat, const char * name ); - -#endif - -// A 3x4 transformation matrix in array-of-structures format -// -class Transform3 -{ - Vector3 mCol0; - Vector3 mCol1; - Vector3 mCol2; - Vector3 mCol3; - -public: - // Default constructor; does no initialization - // - inline Transform3( ) { }; - - // Copy a 3x4 transformation matrix - // - inline Transform3( const Transform3 & tfrm ); - - // Construct a 3x4 transformation matrix containing the specified columns - // - inline Transform3( const Vector3 & col0, const Vector3 & col1, const Vector3 & col2, const Vector3 & col3 ); - - // Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector - // - inline Transform3( const Matrix3 & tfrm, const Vector3 & translateVec ); - - // Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector - // - inline Transform3( const Quat & unitQuat, const Vector3 & translateVec ); - - // Set all elements of a 3x4 transformation matrix to the same scalar value - // - explicit inline Transform3( float scalar ); - - // Assign one 3x4 transformation matrix to another - // - inline Transform3 & operator =( const Transform3 & tfrm ); - - // Set the upper-left 3x3 submatrix - // - inline Transform3 & setUpper3x3( const Matrix3 & mat3 ); - - // Get the upper-left 3x3 submatrix of a 3x4 transformation matrix - // - inline const Matrix3 getUpper3x3( ) const; - - // Set translation component - // - inline Transform3 & setTranslation( const Vector3 & translateVec ); - - // Get the translation component of a 3x4 transformation matrix - // - inline const Vector3 getTranslation( ) const; - - // Set column 0 of a 3x4 transformation matrix - // - inline Transform3 & setCol0( const Vector3 & col0 ); - - // Set column 1 of a 3x4 transformation matrix - // - inline Transform3 & setCol1( const Vector3 & col1 ); - - // Set column 2 of a 3x4 transformation matrix - // - inline Transform3 & setCol2( const Vector3 & col2 ); - - // Set column 3 of a 3x4 transformation matrix - // - inline Transform3 & setCol3( const Vector3 & col3 ); - - // Get column 0 of a 3x4 transformation matrix - // - inline const Vector3 getCol0( ) const; - - // Get column 1 of a 3x4 transformation matrix - // - inline const Vector3 getCol1( ) const; - - // Get column 2 of a 3x4 transformation matrix - // - inline const Vector3 getCol2( ) const; - - // Get column 3 of a 3x4 transformation matrix - // - inline const Vector3 getCol3( ) const; - - // Set the column of a 3x4 transformation matrix referred to by the specified index - // - inline Transform3 & setCol( int col, const Vector3 & vec ); - - // Set the row of a 3x4 transformation matrix referred to by the specified index - // - inline Transform3 & setRow( int row, const Vector4 & vec ); - - // Get the column of a 3x4 transformation matrix referred to by the specified index - // - inline const Vector3 getCol( int col ) const; - - // Get the row of a 3x4 transformation matrix referred to by the specified index - // - inline const Vector4 getRow( int row ) const; - - // Subscripting operator to set or get a column - // - inline Vector3 & operator []( int col ); - - // Subscripting operator to get a column - // - inline const Vector3 operator []( int col ) const; - - // Set the element of a 3x4 transformation matrix referred to by column and row indices - // - inline Transform3 & setElem( int col, int row, float val ); - - // Get the element of a 3x4 transformation matrix referred to by column and row indices - // - inline float getElem( int col, int row ) const; - - // Multiply a 3x4 transformation matrix by a 3-D vector - // - inline const Vector3 operator *( const Vector3 & vec ) const; - - // Multiply a 3x4 transformation matrix by a 3-D point - // - inline const Point3 operator *( const Point3 & pnt ) const; - - // Multiply two 3x4 transformation matrices - // - inline const Transform3 operator *( const Transform3 & tfrm ) const; - - // Perform compound assignment and multiplication by a 3x4 transformation matrix - // - inline Transform3 & operator *=( const Transform3 & tfrm ); - - // Construct an identity 3x4 transformation matrix - // - static inline const Transform3 identity( ); - - // Construct a 3x4 transformation matrix to rotate around the x axis - // - static inline const Transform3 rotationX( float radians ); - - // Construct a 3x4 transformation matrix to rotate around the y axis - // - static inline const Transform3 rotationY( float radians ); - - // Construct a 3x4 transformation matrix to rotate around the z axis - // - static inline const Transform3 rotationZ( float radians ); - - // Construct a 3x4 transformation matrix to rotate around the x, y, and z axes - // - static inline const Transform3 rotationZYX( const Vector3 & radiansXYZ ); - - // Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector - // - static inline const Transform3 rotation( float radians, const Vector3 & unitVec ); - - // Construct a rotation matrix from a unit-length quaternion - // - static inline const Transform3 rotation( const Quat & unitQuat ); - - // Construct a 3x4 transformation matrix to perform scaling - // - static inline const Transform3 scale( const Vector3 & scaleVec ); - - // Construct a 3x4 transformation matrix to perform translation - // - static inline const Transform3 translation( const Vector3 & translateVec ); - -}; -// Append (post-multiply) a scale transformation to a 3x4 transformation matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Transform3 appendScale( const Transform3 & tfrm, const Vector3 & scaleVec ); - -// Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Transform3 prependScale( const Vector3 & scaleVec, const Transform3 & tfrm ); - -// Multiply two 3x4 transformation matrices per element -// -inline const Transform3 mulPerElem( const Transform3 & tfrm0, const Transform3 & tfrm1 ); - -// Compute the absolute value of a 3x4 transformation matrix per element -// -inline const Transform3 absPerElem( const Transform3 & tfrm ); - -// Inverse of a 3x4 transformation matrix -// NOTE: -// Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0. -// -inline const Transform3 inverse( const Transform3 & tfrm ); - -// Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix -// NOTE: -// This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions. -// -inline const Transform3 orthoInverse( const Transform3 & tfrm ); - -// Conditionally select between two 3x4 transformation matrices -// -inline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, bool select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3x4 transformation matrix -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Transform3 & tfrm ); - -// Print a 3x4 transformation matrix and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Transform3 & tfrm, const char * name ); - -#endif - -} // namespace Aos -} // namespace Vectormath - -#include "vec_aos.h" -#include "quat_aos.h" -#include "mat_aos.h" - -#endif diff --git a/bullet/src/BulletMultiThreaded/vectormath2bullet.h b/bullet/src/BulletMultiThreaded/vectormath2bullet.h deleted file mode 100644 index 092adde68..000000000 --- a/bullet/src/BulletMultiThreaded/vectormath2bullet.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. - All rights reserved. - - Redistribution and use in source and binary forms, - with or without modification, are permitted provided that the - following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the Sony Computer Entertainment Inc nor the names - of its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef AOS_VECTORMATH_BULLET_CONVERT_H -#define AOS_VECTORMATH_BULLET_CONVERT_H - -#include -//#include "BulletMultiThreaded/vectormath/scalar/cpp/vectormath_aos.h" - -#include "LinearMath/btVector3.h" -#include "LinearMath/btQuaternion.h" -#include "LinearMath/btMatrix3x3.h" - -inline Vectormath::Aos::Vector3 getVmVector3(const btVector3& bulletVec) -{ - return Vectormath::Aos::Vector3(bulletVec.getX(),bulletVec.getY(),bulletVec.getZ()); -} - -inline btVector3 getBtVector3(const Vectormath::Aos::Vector3& vmVec) -{ - return btVector3(vmVec.getX(),vmVec.getY(),vmVec.getZ()); -} -inline btVector3 getBtVector3(const Vectormath::Aos::Point3& vmVec) -{ - return btVector3(vmVec.getX(),vmVec.getY(),vmVec.getZ()); -} - -inline Vectormath::Aos::Quat getVmQuat(const btQuaternion& bulletQuat) -{ - Vectormath::Aos::Quat vmQuat(bulletQuat.getX(),bulletQuat.getY(),bulletQuat.getZ(),bulletQuat.getW()); - return vmQuat; -} - -inline btQuaternion getBtQuat(const Vectormath::Aos::Quat& vmQuat) -{ - return btQuaternion (vmQuat.getX(),vmQuat.getY(),vmQuat.getZ(),vmQuat.getW()); -} - -inline Vectormath::Aos::Matrix3 getVmMatrix3(const btMatrix3x3& btMat) -{ - Vectormath::Aos::Matrix3 mat( - getVmVector3(btMat.getColumn(0)), - getVmVector3(btMat.getColumn(1)), - getVmVector3(btMat.getColumn(2))); - return mat; -} - - -#endif //AOS_VECTORMATH_BULLET_CONVERT_H diff --git a/bullet/src/BulletSoftBody/CMakeLists.txt b/bullet/src/BulletSoftBody/CMakeLists.txt deleted file mode 100644 index 7329c258f..000000000 --- a/bullet/src/BulletSoftBody/CMakeLists.txt +++ /dev/null @@ -1,48 +0,0 @@ - -INCLUDE_DIRECTORIES( -${BULLET_PHYSICS_SOURCE_DIR}/src -) - -SET(BulletSoftBody_SRCS - btSoftBody.cpp - btSoftBodyConcaveCollisionAlgorithm.cpp - btSoftBodyHelpers.cpp - btSoftBodyRigidBodyCollisionConfiguration.cpp - btSoftRigidCollisionAlgorithm.cpp - btSoftRigidDynamicsWorld.cpp - btSoftSoftCollisionAlgorithm.cpp -) - -SET(BulletSoftBody_HDRS - btSoftBody.h - btSoftBodyConcaveCollisionAlgorithm.h - btSoftBodyHelpers.h - btSoftBodyRigidBodyCollisionConfiguration.h - btSoftRigidCollisionAlgorithm.h - btSoftRigidDynamicsWorld.h - btSoftSoftCollisionAlgorithm.h - btSparseSDF.h -) - - - -ADD_LIBRARY(BulletSoftBody ${BulletSoftBody_SRCS} ${BulletSoftBody_HDRS}) -SET_TARGET_PROPERTIES(BulletSoftBody PROPERTIES VERSION ${BULLET_VERSION}) -SET_TARGET_PROPERTIES(BulletSoftBody PROPERTIES SOVERSION ${BULLET_VERSION}) -IF (BUILD_SHARED_LIBS) - TARGET_LINK_LIBRARIES(BulletSoftBody BulletDynamics) -ENDIF (BUILD_SHARED_LIBS) - -IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) - IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) - INSTALL(TARGETS BulletSoftBody DESTINATION .) - ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) - INSTALL(TARGETS BulletSoftBody DESTINATION lib${LIB_SUFFIX}) - INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION include FILES_MATCHING PATTERN "*.h") - ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) -ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) - -IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) - SET_TARGET_PROPERTIES(BulletSoftBody PROPERTIES FRAMEWORK true) - SET_TARGET_PROPERTIES(BulletSoftBody PROPERTIES PUBLIC_HEADER ${BulletSoftBody_HDRS}) -ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) diff --git a/bullet/src/BulletSoftBody/Jamfile b/bullet/src/BulletSoftBody/Jamfile deleted file mode 100644 index 16dc6aa38..000000000 --- a/bullet/src/BulletSoftBody/Jamfile +++ /dev/null @@ -1,9 +0,0 @@ - -SubDir TOP src BulletSoftBody ; - -Description bulletsoftbody : "Bullet Softbody Dynamics" ; -Library bulletsoftbody : - [ Wildcard *.h *.cpp ] -; - -LibDepends bulletsoftbody : bulletdynamics bulletcollision ; diff --git a/bullet/src/BulletSoftBody/btSoftBody.cpp b/bullet/src/BulletSoftBody/btSoftBody.cpp deleted file mode 100644 index b5bf9a227..000000000 --- a/bullet/src/BulletSoftBody/btSoftBody.cpp +++ /dev/null @@ -1,2917 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ -///btSoftBody implementation by Nathanael Presson - -#include "btSoftBodyInternals.h" - -// -btSoftBody::btSoftBody(btSoftBodyWorldInfo* worldInfo,int node_count, const btVector3* x, const btScalar* m) -:m_worldInfo(worldInfo) -{ - /* Init */ - m_internalType = CO_SOFT_BODY; - m_cfg.aeromodel = eAeroModel::V_Point; - m_cfg.kVCF = 1; - m_cfg.kDG = 0; - m_cfg.kLF = 0; - m_cfg.kDP = 0; - m_cfg.kPR = 0; - m_cfg.kVC = 0; - m_cfg.kDF = (btScalar)0.2; - m_cfg.kMT = 0; - m_cfg.kCHR = (btScalar)1.0; - m_cfg.kKHR = (btScalar)0.1; - m_cfg.kSHR = (btScalar)1.0; - m_cfg.kAHR = (btScalar)0.7; - m_cfg.kSRHR_CL = (btScalar)0.1; - m_cfg.kSKHR_CL = (btScalar)1; - m_cfg.kSSHR_CL = (btScalar)0.5; - m_cfg.kSR_SPLT_CL = (btScalar)0.5; - m_cfg.kSK_SPLT_CL = (btScalar)0.5; - m_cfg.kSS_SPLT_CL = (btScalar)0.5; - m_cfg.maxvolume = (btScalar)1; - m_cfg.timescale = 1; - m_cfg.viterations = 0; - m_cfg.piterations = 1; - m_cfg.diterations = 0; - m_cfg.citerations = 4; - m_cfg.collisions = fCollision::Default; - m_pose.m_bvolume = false; - m_pose.m_bframe = false; - m_pose.m_volume = 0; - m_pose.m_com = btVector3(0,0,0); - m_pose.m_rot.setIdentity(); - m_pose.m_scl.setIdentity(); - m_tag = 0; - m_timeacc = 0; - m_bUpdateRtCst = true; - m_bounds[0] = btVector3(0,0,0); - m_bounds[1] = btVector3(0,0,0); - m_worldTransform.setIdentity(); - setSolver(eSolverPresets::Positions); - /* Default material */ - Material* pm=appendMaterial(); - pm->m_kLST = 1; - pm->m_kAST = 1; - pm->m_kVST = 1; - pm->m_flags = fMaterial::Default; - /* Collision shape */ - ///for now, create a collision shape internally - m_collisionShape = new btSoftBodyCollisionShape(this); - m_collisionShape->setMargin(0.25); - /* Nodes */ - const btScalar margin=getCollisionShape()->getMargin(); - m_nodes.resize(node_count); - for(int i=0,ni=node_count;i0?1/n.m_im:0; - n.m_leaf = m_ndbvt.insert(btDbvtVolume::FromCR(n.m_x,margin),&n); - n.m_material= pm; - } - updateBounds(); - - m_initialWorldTransform.setIdentity(); -} - -// -btSoftBody::~btSoftBody() -{ - //for now, delete the internal shape - delete m_collisionShape; - int i; - - releaseClusters(); - for(i=0;i0) - *pm=*m_materials[0]; - else - ZeroInitialize(*pm); - m_materials.push_back(pm); - return(pm); -} - -// -void btSoftBody::appendNote( const char* text, - const btVector3& o, - const btVector4& c, - Node* n0, - Node* n1, - Node* n2, - Node* n3) -{ - Note n; - ZeroInitialize(n); - n.m_rank = 0; - n.m_text = text; - n.m_offset = o; - n.m_coords[0] = c.x(); - n.m_coords[1] = c.y(); - n.m_coords[2] = c.z(); - n.m_coords[3] = c.w(); - n.m_nodes[0] = n0;n.m_rank+=n0?1:0; - n.m_nodes[1] = n1;n.m_rank+=n1?1:0; - n.m_nodes[2] = n2;n.m_rank+=n2?1:0; - n.m_nodes[3] = n3;n.m_rank+=n3?1:0; - m_notes.push_back(n); -} - -// -void btSoftBody::appendNote( const char* text, - const btVector3& o, - Node* feature) -{ - appendNote(text,o,btVector4(1,0,0,0),feature); -} - -// -void btSoftBody::appendNote( const char* text, - const btVector3& o, - Link* feature) -{ - static const btScalar w=1/(btScalar)2; - appendNote(text,o,btVector4(w,w,0,0), feature->m_n[0], - feature->m_n[1]); -} - -// -void btSoftBody::appendNote( const char* text, - const btVector3& o, - Face* feature) -{ - static const btScalar w=1/(btScalar)3; - appendNote(text,o,btVector4(w,w,w,0), feature->m_n[0], - feature->m_n[1], - feature->m_n[2]); -} - -// -void btSoftBody::appendNode( const btVector3& x,btScalar m) -{ - if(m_nodes.capacity()==m_nodes.size()) - { - pointersToIndices(); - m_nodes.reserve(m_nodes.size()*2+1); - indicesToPointers(); - } - const btScalar margin=getCollisionShape()->getMargin(); - m_nodes.push_back(Node()); - Node& n=m_nodes[m_nodes.size()-1]; - ZeroInitialize(n); - n.m_x = x; - n.m_q = n.m_x; - n.m_im = m>0?1/m:0; - n.m_material = m_materials[0]; - n.m_leaf = m_ndbvt.insert(btDbvtVolume::FromCR(n.m_x,margin),&n); -} - -// -void btSoftBody::appendLink(int model,Material* mat) -{ - Link l; - if(model>=0) - l=m_links[model]; - else - { ZeroInitialize(l);l.m_material=mat?mat:m_materials[0]; } - m_links.push_back(l); -} - -// -void btSoftBody::appendLink( int node0, - int node1, - Material* mat, - bool bcheckexist) -{ - appendLink(&m_nodes[node0],&m_nodes[node1],mat,bcheckexist); -} - -// -void btSoftBody::appendLink( Node* node0, - Node* node1, - Material* mat, - bool bcheckexist) -{ - if((!bcheckexist)||(!checkLink(node0,node1))) - { - appendLink(-1,mat); - Link& l=m_links[m_links.size()-1]; - l.m_n[0] = node0; - l.m_n[1] = node1; - l.m_rl = (l.m_n[0]->m_x-l.m_n[1]->m_x).length(); - m_bUpdateRtCst=true; - } -} - -// -void btSoftBody::appendFace(int model,Material* mat) -{ - Face f; - if(model>=0) - { f=m_faces[model]; } - else - { ZeroInitialize(f);f.m_material=mat?mat:m_materials[0]; } - m_faces.push_back(f); -} - -// -void btSoftBody::appendFace(int node0,int node1,int node2,Material* mat) -{ - if (node0==node1) - return; - if (node1==node2) - return; - if (node2==node0) - return; - - appendFace(-1,mat); - Face& f=m_faces[m_faces.size()-1]; - btAssert(node0!=node1); - btAssert(node1!=node2); - btAssert(node2!=node0); - f.m_n[0] = &m_nodes[node0]; - f.m_n[1] = &m_nodes[node1]; - f.m_n[2] = &m_nodes[node2]; - f.m_ra = AreaOf( f.m_n[0]->m_x, - f.m_n[1]->m_x, - f.m_n[2]->m_x); - m_bUpdateRtCst=true; -} - -// -void btSoftBody::appendTetra(int model,Material* mat) -{ -Tetra t; -if(model>=0) - t=m_tetras[model]; - else - { ZeroInitialize(t);t.m_material=mat?mat:m_materials[0]; } -m_tetras.push_back(t); -} - -// -void btSoftBody::appendTetra(int node0, - int node1, - int node2, - int node3, - Material* mat) -{ - appendTetra(-1,mat); - Tetra& t=m_tetras[m_tetras.size()-1]; - t.m_n[0] = &m_nodes[node0]; - t.m_n[1] = &m_nodes[node1]; - t.m_n[2] = &m_nodes[node2]; - t.m_n[3] = &m_nodes[node3]; - t.m_rv = VolumeOf(t.m_n[0]->m_x,t.m_n[1]->m_x,t.m_n[2]->m_x,t.m_n[3]->m_x); - m_bUpdateRtCst=true; -} - -// -void btSoftBody::appendAnchor(int node,btRigidBody* body, bool disableCollisionBetweenLinkedBodies) -{ - if (disableCollisionBetweenLinkedBodies) - { - if (m_collisionDisabledObjects.findLinearSearch(body)==m_collisionDisabledObjects.size()) - { - m_collisionDisabledObjects.push_back(body); - } - } - - Anchor a; - a.m_node = &m_nodes[node]; - a.m_body = body; - a.m_local = body->getInterpolationWorldTransform().inverse()*a.m_node->m_x; - a.m_node->m_battach = 1; - m_anchors.push_back(a); -} - -// -void btSoftBody::appendLinearJoint(const LJoint::Specs& specs,Cluster* body0,Body body1) -{ - LJoint* pj = new(btAlignedAlloc(sizeof(LJoint),16)) LJoint(); - pj->m_bodies[0] = body0; - pj->m_bodies[1] = body1; - pj->m_refs[0] = pj->m_bodies[0].xform().inverse()*specs.position; - pj->m_refs[1] = pj->m_bodies[1].xform().inverse()*specs.position; - pj->m_cfm = specs.cfm; - pj->m_erp = specs.erp; - pj->m_split = specs.split; - m_joints.push_back(pj); -} - -// -void btSoftBody::appendLinearJoint(const LJoint::Specs& specs,Body body) -{ - appendLinearJoint(specs,m_clusters[0],body); -} - -// -void btSoftBody::appendLinearJoint(const LJoint::Specs& specs,btSoftBody* body) -{ - appendLinearJoint(specs,m_clusters[0],body->m_clusters[0]); -} - -// -void btSoftBody::appendAngularJoint(const AJoint::Specs& specs,Cluster* body0,Body body1) -{ - AJoint* pj = new(btAlignedAlloc(sizeof(AJoint),16)) AJoint(); - pj->m_bodies[0] = body0; - pj->m_bodies[1] = body1; - pj->m_refs[0] = pj->m_bodies[0].xform().inverse().getBasis()*specs.axis; - pj->m_refs[1] = pj->m_bodies[1].xform().inverse().getBasis()*specs.axis; - pj->m_cfm = specs.cfm; - pj->m_erp = specs.erp; - pj->m_split = specs.split; - pj->m_icontrol = specs.icontrol; - m_joints.push_back(pj); -} - -// -void btSoftBody::appendAngularJoint(const AJoint::Specs& specs,Body body) -{ - appendAngularJoint(specs,m_clusters[0],body); -} - -// -void btSoftBody::appendAngularJoint(const AJoint::Specs& specs,btSoftBody* body) -{ - appendAngularJoint(specs,m_clusters[0],body->m_clusters[0]); -} - -// -void btSoftBody::addForce(const btVector3& force) -{ - for(int i=0,ni=m_nodes.size();i0) - { - n.m_f += force; - } -} - -// -void btSoftBody::addVelocity(const btVector3& velocity) -{ - for(int i=0,ni=m_nodes.size();i0) - { - n.m_v = velocity; - } - } -} - - -// -void btSoftBody::addVelocity(const btVector3& velocity,int node) -{ - Node& n=m_nodes[node]; - if(n.m_im>0) - { - n.m_v += velocity; - } -} - -// -void btSoftBody::setMass(int node,btScalar mass) -{ - m_nodes[node].m_im=mass>0?1/mass:0; - m_bUpdateRtCst=true; -} - -// -btScalar btSoftBody::getMass(int node) const -{ - return(m_nodes[node].m_im>0?1/m_nodes[node].m_im:0); -} - -// -btScalar btSoftBody::getTotalMass() const -{ - btScalar mass=0; - for(int i=0;im_x, - f.m_n[1]->m_x, - f.m_n[2]->m_x); - for(int j=0;j<3;++j) - { - f.m_n[j]->m_im+=twicearea; - } - } - for( i=0;i ranks; -ranks.resize(m_nodes.size(),0); -for(int i=0;im_im+=btFabs(t.m_rv); - ranks[int(t.m_n[j]-&m_nodes[0])]+=1; - } - } -for(int i=0;i0) - { - m_nodes[i].m_im=ranks[i]/m_nodes[i].m_im; - } - } -setTotalMass(mass,false); -} - -// -void btSoftBody::setVolumeDensity(btScalar density) -{ -btScalar volume=0; -for(int i=0;igetMargin(); - ATTRIBUTE_ALIGNED16(btDbvtVolume) vol; - - for(int i=0,ni=m_nodes.size();igetMargin(); - ATTRIBUTE_ALIGNED16(btDbvtVolume) vol; - - for(int i=0,ni=m_nodes.size();i0 ? - 1/(m_nodes[i].m_im*tmass) : - kmass/tmass; - } - /* Pos */ - const btVector3 com=evaluateCom(); - m_pose.m_pos.resize(m_nodes.size()); - for( i=0,ni=m_nodes.size();i0) - { - int i,ni; - - const btVector3 org=m_nodes[0].m_x; - for(i=0,ni=m_faces.size();im_x-org,btCross(f.m_n[1]->m_x-org,f.m_n[2]->m_x-org)); - } - vol/=(btScalar)6; - } - return(vol); -} - -// -int btSoftBody::clusterCount() const -{ - return(m_clusters.size()); -} - -// -btVector3 btSoftBody::clusterCom(const Cluster* cluster) -{ - btVector3 com(0,0,0); - for(int i=0,ni=cluster->m_nodes.size();im_nodes[i]->m_x*cluster->m_masses[i]; - } - return(com*cluster->m_imass); -} - -// -btVector3 btSoftBody::clusterCom(int cluster) const -{ - return(clusterCom(m_clusters[cluster])); -} - -// -btVector3 btSoftBody::clusterVelocity(const Cluster* cluster,const btVector3& rpos) -{ - return(cluster->m_lv+btCross(cluster->m_av,rpos)); -} - -// -void btSoftBody::clusterVImpulse(Cluster* cluster,const btVector3& rpos,const btVector3& impulse) -{ - const btVector3 li=cluster->m_imass*impulse; - const btVector3 ai=cluster->m_invwi*btCross(rpos,impulse); - cluster->m_vimpulses[0]+=li;cluster->m_lv+=li; - cluster->m_vimpulses[1]+=ai;cluster->m_av+=ai; - cluster->m_nvimpulses++; -} - -// -void btSoftBody::clusterDImpulse(Cluster* cluster,const btVector3& rpos,const btVector3& impulse) -{ - const btVector3 li=cluster->m_imass*impulse; - const btVector3 ai=cluster->m_invwi*btCross(rpos,impulse); - cluster->m_dimpulses[0]+=li; - cluster->m_dimpulses[1]+=ai; - cluster->m_ndimpulses++; -} - -// -void btSoftBody::clusterImpulse(Cluster* cluster,const btVector3& rpos,const Impulse& impulse) -{ - if(impulse.m_asVelocity) clusterVImpulse(cluster,rpos,impulse.m_velocity); - if(impulse.m_asDrift) clusterDImpulse(cluster,rpos,impulse.m_drift); -} - -// -void btSoftBody::clusterVAImpulse(Cluster* cluster,const btVector3& impulse) -{ - const btVector3 ai=cluster->m_invwi*impulse; - cluster->m_vimpulses[1]+=ai;cluster->m_av+=ai; - cluster->m_nvimpulses++; -} - -// -void btSoftBody::clusterDAImpulse(Cluster* cluster,const btVector3& impulse) -{ - const btVector3 ai=cluster->m_invwi*impulse; - cluster->m_dimpulses[1]+=ai; - cluster->m_ndimpulses++; -} - -// -void btSoftBody::clusterAImpulse(Cluster* cluster,const Impulse& impulse) -{ - if(impulse.m_asVelocity) clusterVAImpulse(cluster,impulse.m_velocity); - if(impulse.m_asDrift) clusterDAImpulse(cluster,impulse.m_drift); -} - -// -void btSoftBody::clusterDCImpulse(Cluster* cluster,const btVector3& impulse) -{ - cluster->m_dimpulses[0]+=impulse*cluster->m_imass; - cluster->m_ndimpulses++; -} - -struct NodeLinks -{ - btAlignedObjectArray m_links; -}; - - - -// -int btSoftBody::generateBendingConstraints(int distance,Material* mat) -{ - int i,j; - - if(distance>1) - { - /* Build graph */ - const int n=m_nodes.size(); - const unsigned inf=(~(unsigned)0)>>1; - unsigned* adj=new unsigned[n*n]; - - -#define IDX(_x_,_y_) ((_y_)*n+(_x_)) - for(j=0;j nodeLinks; - - - /* Build node links */ - nodeLinks.resize(m_nodes.size()); - - for( i=0;isum) - { - adj[IDX(i,j)]=adj[IDX(j,i)]=sum; - } - } - - } - } - } - } else - { - ///generic Floyd's algorithm - for(int k=0;ksum) - { - adj[IDX(i,j)]=adj[IDX(j,i)]=sum; - } - } - } - } - } - - - /* Build links */ - int nlinks=0; - for(j=0;jm_leaf) m_cdbvt.remove(c->m_leaf); - c->~Cluster(); - btAlignedFree(c); - m_clusters.remove(c); -} - -// -void btSoftBody::releaseClusters() -{ - while(m_clusters.size()>0) releaseCluster(0); -} - -// -int btSoftBody::generateClusters(int k,int maxiterations) -{ - int i; - releaseClusters(); - m_clusters.resize(btMin(k,m_nodes.size())); - for(i=0;im_collide= true; - } - k=m_clusters.size(); - if(k>0) - { - /* Initialize */ - btAlignedObjectArray centers; - btVector3 cog(0,0,0); - int i; - for(i=0;im_nodes.push_back(&m_nodes[i]); - } - cog/=(btScalar)m_nodes.size(); - centers.resize(k,cog); - /* Iterate */ - const btScalar slope=16; - bool changed; - int iterations=0; - do { - const btScalar w=2-btMin(1,iterations/slope); - changed=false; - iterations++; - int i; - - for(i=0;im_nodes.size();++j) - { - c+=m_clusters[i]->m_nodes[j]->m_x; - } - if(m_clusters[i]->m_nodes.size()) - { - c /= (btScalar)m_clusters[i]->m_nodes.size(); - c = centers[i]+(c-centers[i])*w; - changed |= ((c-centers[i]).length2()>SIMD_EPSILON); - centers[i] = c; - m_clusters[i]->m_nodes.resize(0); - } - } - for(i=0;im_nodes.push_back(&m_nodes[i]); - } - } while(changed&&(iterations cids; - cids.resize(m_nodes.size(),-1); - for(i=0;im_nodes.size();++j) - { - cids[int(m_clusters[i]->m_nodes[j]-&m_nodes[0])]=i; - } - } - for(i=0;im_nodes.findLinearSearch(&m_nodes[kid])==m_clusters[cid]->m_nodes.size()) - { - m_clusters[cid]->m_nodes.push_back(&m_nodes[kid]); - } - } - } - } - } - /* Master */ - if(m_clusters.size()>1) - { - Cluster* pmaster=new(btAlignedAlloc(sizeof(Cluster),16)) Cluster(); - pmaster->m_collide = false; - pmaster->m_nodes.reserve(m_nodes.size()); - for(int i=0;im_nodes.push_back(&m_nodes[i]); - m_clusters.push_back(pmaster); - btSwap(m_clusters[0],m_clusters[m_clusters.size()-1]); - } - /* Terminate */ - for(i=0;im_nodes.size()==0) - { - releaseCluster(i--); - } - } - } else - { - //create a cluster for each tetrahedron (if tetrahedra exist) or each face - if (m_tetras.size()) - { - m_clusters.resize(m_tetras.size()); - for(i=0;im_collide= true; - } - for (i=0;im_nodes.push_back(m_tetras[i].m_n[j]); - } - } - - } else - { - m_clusters.resize(m_faces.size()); - for(i=0;im_collide= true; - } - - for(i=0;im_nodes.push_back(m_faces[i].m_n[j]); - } - } - } - } - - if (m_clusters.size()) - { - initializeClusters(); - updateClusters(); - - - //for self-collision - m_clusterConnectivity.resize(m_clusters.size()*m_clusters.size()); - { - for (int c0=0;c0m_clusterIndex=c0; - for (int c1=0;c1m_nodes.size();i++) - { - for (int j=0;jm_nodes.size();j++) - { - if (cla->m_nodes[i] == clb->m_nodes[j]) - { - connected=true; - break; - } - } - } - m_clusterConnectivity[c0+c1*m_clusters.size()]=connected; - } - } - } - } - - return(m_clusters.size()); -} - -// -void btSoftBody::refine(ImplicitFn* ifn,btScalar accurary,bool cut) -{ - const Node* nbase = &m_nodes[0]; - int ncount = m_nodes.size(); - btSymMatrix edges(ncount,-2); - int newnodes=0; - int i,j,k,ni; - - /* Filter out */ - for(i=0;iEval(l.m_n[0]->m_x),ifn->Eval(l.m_n[1]->m_x))) - { - btSwap(m_links[i],m_links[m_links.size()-1]); - m_links.pop_back();--i; - } - } - } - /* Fill edges */ - for(i=0;i0) - { - const btVector3 x=Lerp(a.m_x,b.m_x,t); - const btVector3 v=Lerp(a.m_v,b.m_v,t); - btScalar m=0; - if(a.m_im>0) - { - if(b.m_im>0) - { - const btScalar ma=1/a.m_im; - const btScalar mb=1/b.m_im; - const btScalar mc=Lerp(ma,mb,t); - const btScalar f=(ma+mb)/(ma+mb+mc); - a.m_im=1/(ma*f); - b.m_im=1/(mb*f); - m=mc*f; - } - else - { a.m_im/=0.5;m=1/a.m_im; } - } - else - { - if(b.m_im>0) - { b.m_im/=0.5;m=1/b.m_im; } - else - m=0; - } - appendNode(x,m); - edges(i,j)=m_nodes.size()-1; - m_nodes[edges(i,j)].m_v=v; - ++newnodes; - } - } - } - } - nbase=&m_nodes[0]; - /* Refine links */ - for(i=0,ni=m_links.size();i0) - { - appendLink(i); - Link* pft[]={ &m_links[i], - &m_links[m_links.size()-1]}; - pft[0]->m_n[0]=&m_nodes[idx[0]]; - pft[0]->m_n[1]=&m_nodes[ni]; - pft[1]->m_n[0]=&m_nodes[ni]; - pft[1]->m_n[1]=&m_nodes[idx[1]]; - } - } - } - /* Refine faces */ - for(i=0;i0) - { - appendFace(i); - const int l=(k+1)%3; - Face* pft[]={ &m_faces[i], - &m_faces[m_faces.size()-1]}; - pft[0]->m_n[0]=&m_nodes[idx[l]]; - pft[0]->m_n[1]=&m_nodes[idx[j]]; - pft[0]->m_n[2]=&m_nodes[ni]; - pft[1]->m_n[0]=&m_nodes[ni]; - pft[1]->m_n[1]=&m_nodes[idx[k]]; - pft[1]->m_n[2]=&m_nodes[idx[l]]; - appendLink(ni,idx[l],pft[0]->m_material); - --i;break; - } - } - } - } - /* Cut */ - if(cut) - { - btAlignedObjectArray cnodes; - const int pcount=ncount; - int i; - ncount=m_nodes.size(); - cnodes.resize(ncount,0); - /* Nodes */ - for(i=0;i=pcount)||(btFabs(ifn->Eval(x))0) { m*=0.5;m_nodes[i].m_im/=0.5; } - appendNode(x,m); - cnodes[i]=m_nodes.size()-1; - m_nodes[cnodes[i]].m_v=v; - } - } - nbase=&m_nodes[0]; - /* Links */ - for(i=0,ni=m_links.size();iEval(m_nodes[id[0]].m_x)Eval(m_nodes[id[1]].m_x)Eval(n[0]->m_x)Eval(n[1]->m_x)Eval(n[2]->m_x) ranks; - btAlignedObjectArray todelete; - ranks.resize(nnodes,0); - for(i=0,ni=m_links.size();i=0;--i) - { - if(!ranks[i]) todelete.push_back(i); - } - if(todelete.size()) - { - btAlignedObjectArray& map=ranks; - for(int i=0;im_v=v; - pn[1]->m_v=v; - for(i=0,ni=m_links.size();im_n[1]=pn[mtch]; - pft[1]->m_n[0]=pn[1-mtch]; - done=true; - } - } - for(i=0,ni=m_faces.size();im_n[l]=pn[mtch]; - pft[1]->m_n[k]=pn[1-mtch]; - appendLink(pn[0],pft[0]->m_n[(l+1)%3],pft[0]->m_material,true); - appendLink(pn[1],pft[0]->m_n[(l+1)%3],pft[0]->m_material,true); - } - } - } - if(!done) - { - m_ndbvt.remove(pn[0]->m_leaf); - m_ndbvt.remove(pn[1]->m_leaf); - m_nodes.pop_back(); - m_nodes.pop_back(); - } - return(done); -} - -// -bool btSoftBody::rayTest(const btVector3& rayFrom, - const btVector3& rayTo, - sRayCast& results) -{ - if(m_faces.size()&&m_fdbvt.empty()) - initializeFaceTree(); - - results.body = this; - results.fraction = 1.f; - results.feature = eFeature::None; - results.index = -1; - - return(rayTest(rayFrom,rayTo,results.fraction,results.feature,results.index,false)!=0); -} - -// -void btSoftBody::setSolver(eSolverPresets::_ preset) -{ - m_cfg.m_vsequence.clear(); - m_cfg.m_psequence.clear(); - m_cfg.m_dsequence.clear(); - switch(preset) - { - case eSolverPresets::Positions: - m_cfg.m_psequence.push_back(ePSolver::Anchors); - m_cfg.m_psequence.push_back(ePSolver::RContacts); - m_cfg.m_psequence.push_back(ePSolver::SContacts); - m_cfg.m_psequence.push_back(ePSolver::Linear); - break; - case eSolverPresets::Velocities: - m_cfg.m_vsequence.push_back(eVSolver::Linear); - - m_cfg.m_psequence.push_back(ePSolver::Anchors); - m_cfg.m_psequence.push_back(ePSolver::RContacts); - m_cfg.m_psequence.push_back(ePSolver::SContacts); - - m_cfg.m_dsequence.push_back(ePSolver::Linear); - break; - } -} - -// -void btSoftBody::predictMotion(btScalar dt) -{ - int i,ni; - - /* Update */ - if(m_bUpdateRtCst) - { - m_bUpdateRtCst=false; - updateConstants(); - m_fdbvt.clear(); - if(m_cfg.collisions&fCollision::VF_SS) - { - initializeFaceTree(); - } - } - - /* Prepare */ - m_sst.sdt = dt*m_cfg.timescale; - m_sst.isdt = 1/m_sst.sdt; - m_sst.velmrg = m_sst.sdt*3; - m_sst.radmrg = getCollisionShape()->getMargin(); - m_sst.updmrg = m_sst.radmrg*(btScalar)0.25; - /* Forces */ - addVelocity(m_worldInfo->m_gravity*m_sst.sdt); - applyForces(); - /* Integrate */ - for(i=0,ni=m_nodes.size();im_v+ - f.m_n[1]->m_v+ - f.m_n[2]->m_v)/3; - vol = VolumeOf(f,m_sst.radmrg); - m_fdbvt.update( f.m_leaf, - vol, - v*m_sst.velmrg, - m_sst.updmrg); - } - } - /* Pose */ - updatePose(); - /* Match */ - if(m_pose.m_bframe&&(m_cfg.kMT>0)) - { - const btMatrix3x3 posetrs=m_pose.m_rot; - for(int i=0,ni=m_nodes.size();i0) - { - const btVector3 x=posetrs*m_pose.m_pos[i]+m_pose.m_com; - n.m_x=Lerp(n.m_x,x,m_cfg.kMT); - } - } - } - /* Clear contacts */ - m_rcontacts.resize(0); - m_scontacts.resize(0); - /* Optimize dbvt's */ - m_ndbvt.optimizeIncremental(1); - m_fdbvt.optimizeIncremental(1); - m_cdbvt.optimizeIncremental(1); -} - -// -void btSoftBody::solveConstraints() -{ - /* Apply clusters */ - applyClusters(false); - /* Prepare links */ - - int i,ni; - - for(i=0,ni=m_links.size();im_q-l.m_n[0]->m_q; - l.m_c2 = 1/(l.m_c3.length2()*l.m_c0); - } - /* Prepare anchors */ - for(i=0,ni=m_anchors.size();igetWorldTransform().getBasis()*a.m_local; - a.m_c0 = ImpulseMatrix( m_sst.sdt, - a.m_node->m_im, - a.m_body->getInvMass(), - a.m_body->getInvInertiaTensorWorld(), - ra); - a.m_c1 = ra; - a.m_c2 = m_sst.sdt*a.m_node->m_im; - a.m_body->activate(); - } - /* Solve velocities */ - if(m_cfg.viterations>0) - { - /* Solve */ - for(int isolve=0;isolve0) - { - for(int isolve=0;isolve0) - { - const btScalar vcf=m_cfg.kVCF*m_sst.isdt; - for(i=0,ni=m_nodes.size();i& bodies) -{ - const int nb=bodies.size(); - int iterations=0; - int i; - - for(i=0;im_cfg.citerations); - } - for(i=0;iprepareClusters(iterations); - } - for(i=0;isolveClusters(sor); - } - } - for(i=0;icleanupClusters(); - } -} - -// -void btSoftBody::integrateMotion() -{ - /* Update */ - updateNormals(); -} - -// -btSoftBody::RayFromToCaster::RayFromToCaster(const btVector3& rayFrom,const btVector3& rayTo,btScalar mxt) -{ - m_rayFrom = rayFrom; - m_rayNormalizedDirection = (rayTo-rayFrom); - m_rayTo = rayTo; - m_mint = mxt; - m_face = 0; - m_tests = 0; -} - -// -void btSoftBody::RayFromToCaster::Process(const btDbvtNode* leaf) -{ - btSoftBody::Face& f=*(btSoftBody::Face*)leaf->data; - const btScalar t=rayFromToTriangle( m_rayFrom,m_rayTo,m_rayNormalizedDirection, - f.m_n[0]->m_x, - f.m_n[1]->m_x, - f.m_n[2]->m_x, - m_mint); - if((t>0)&&(tteps)&&(tceps) && - (btDot(n,btCross(b-hit,c-hit))>ceps) && - (btDot(n,btCross(c-hit,a-hit))>ceps)) - { - return(t); - } - } - } - return(-1); -} - -// -void btSoftBody::pointersToIndices() -{ -#define PTR2IDX(_p_,_b_) reinterpret_cast((_p_)-(_b_)) - btSoftBody::Node* base=&m_nodes[0]; - int i,ni; - - for(i=0,ni=m_nodes.size();idata=*(void**)&i; - } - } - for(i=0,ni=m_links.size();idata=*(void**)&i; - } - } - for(i=0,ni=m_anchors.size();idata=&m_nodes[i]; - } - } - for(i=0,ni=m_links.size();idata=&m_faces[i]; - } - } - for(i=0,ni=m_anchors.size();im_x, - f.m_n[1]->m_x, - f.m_n[2]->m_x, - mint); - if(t>0) - { - ++cnt; - if(!bcountonly) - { - feature=btSoftBody::eFeature::Face; - index=i; - mint=t; - } - } - } - } - else - {/* Use dbvt */ - RayFromToCaster collider(rayFrom,rayTo,mint); - - btDbvt::rayTest(m_fdbvt.m_root,rayFrom,rayTo,collider); - if(collider.m_face) - { - mint=collider.m_mint; - feature=btSoftBody::eFeature::Face; - index=(int)(collider.m_face-&m_faces[0]); - cnt=1; - } - } - return(cnt); -} - -// -void btSoftBody::initializeFaceTree() -{ - m_fdbvt.clear(); - for(int i=0;igetCollisionShape(); - btRigidBody* tmpRigid = btRigidBody::upcast(colObj); - const btTransform& wtr=tmpRigid? tmpRigid->getInterpolationWorldTransform() : colObj->getWorldTransform(); - btScalar dst=m_worldInfo->m_sparsesdf.Evaluate( wtr.invXform(x), - shp, - nrm, - margin); - if(dst<0) - { - cti.m_colObj = colObj; - cti.m_normal = wtr.getBasis()*nrm; - cti.m_offset = -btDot( cti.m_normal, - x-cti.m_normal*dst); - return(true); - } - return(false); -} - -// -void btSoftBody::updateNormals() -{ - const btVector3 zv(0,0,0); - int i,ni; - - for(i=0,ni=m_nodes.size();im_x-f.m_n[0]->m_x, - f.m_n[2]->m_x-f.m_n[0]->m_x); - f.m_normal=n.normalized(); - f.m_n[0]->m_n+=n; - f.m_n[1]->m_n+=n; - f.m_n[2]->m_n+=n; - } - for(i=0,ni=m_nodes.size();iSIMD_EPSILON) - m_nodes[i].m_n /= len; - } -} - -// -void btSoftBody::updateBounds() -{ - if(m_ndbvt.m_root) - { - const btVector3& mins=m_ndbvt.m_root->volume.Mins(); - const btVector3& maxs=m_ndbvt.m_root->volume.Maxs(); - const btScalar csm=getCollisionShape()->getMargin(); - const btVector3 mrg=btVector3( csm, - csm, - csm)*1; // ??? to investigate... - m_bounds[0]=mins-mrg; - m_bounds[1]=maxs+mrg; - if(0!=getBroadphaseHandle()) - { - m_worldInfo->m_broadphase->setAabb( getBroadphaseHandle(), - m_bounds[0], - m_bounds[1], - m_worldInfo->m_dispatcher); - } - } - else - { - m_bounds[0]= - m_bounds[1]=btVector3(0,0,0); - } -} - - -// -void btSoftBody::updatePose() -{ - if(m_pose.m_bframe) - { - btSoftBody::Pose& pose=m_pose; - const btVector3 com=evaluateCom(); - /* Com */ - pose.m_com = com; - /* Rotation */ - btMatrix3x3 Apq; - const btScalar eps=SIMD_EPSILON; - Apq[0]=Apq[1]=Apq[2]=btVector3(0,0,0); - Apq[0].setX(eps);Apq[1].setY(eps*2);Apq[2].setZ(eps*3); - for(int i=0,ni=m_nodes.size();i1) - { - const btScalar idet=Clamp( 1/pose.m_scl.determinant(), - 1,m_cfg.maxvolume); - pose.m_scl=Mul(pose.m_scl,idet); - } - - } -} - -// -void btSoftBody::updateConstants() -{ - int i,ni; - - /* Links */ - for(i=0,ni=m_links.size();im_x-l.m_n[1]->m_x).length(); - l.m_c0 = (l.m_n[0]->m_im+l.m_n[1]->m_im)/m.m_kLST; - l.m_c1 = l.m_rl*l.m_rl; - } - /* Faces */ - for(i=0,ni=m_faces.size();im_x,f.m_n[1]->m_x,f.m_n[2]->m_x); - } - /* Area's */ - btAlignedObjectArray counts; - counts.resize(m_nodes.size(),0); - for(i=0,ni=m_nodes.size();im_area+=btFabs(f.m_ra); - } - } - for(i=0,ni=m_nodes.size();i0) - m_nodes[i].m_area/=(btScalar)counts[i]; - else - m_nodes[i].m_area=0; - } -} - -// -void btSoftBody::initializeClusters() -{ - int i; - - for( i=0;im_im==0) - { - c.m_containsAnchor = true; - c.m_masses[j] = BT_LARGE_FLOAT; - } else - { - c.m_masses[j] = btScalar(1.)/c.m_nodes[j]->m_im; - } - c.m_imass += c.m_masses[j]; - } - c.m_imass = btScalar(1.)/c.m_imass; - c.m_com = btSoftBody::clusterCom(&c); - c.m_lv = btVector3(0,0,0); - c.m_av = btVector3(0,0,0); - c.m_leaf = 0; - /* Inertia */ - btMatrix3x3& ii=c.m_locii; - ii[0]=ii[1]=ii[2]=btVector3(0,0,0); - { - int i,ni; - - for(i=0,ni=c.m_nodes.size();im_x-c.m_com; - const btVector3 q=k*k; - const btScalar m=c.m_masses[i]; - ii[0][0] += m*(q[1]+q[2]); - ii[1][1] += m*(q[0]+q[2]); - ii[2][2] += m*(q[0]+q[1]); - ii[0][1] -= m*k[0]*k[1]; - ii[0][2] -= m*k[0]*k[2]; - ii[1][2] -= m*k[1]*k[2]; - } - } - ii[1][0]=ii[0][1]; - ii[2][0]=ii[0][2]; - ii[2][1]=ii[1][2]; - - ii = ii.inverse(); - - /* Frame */ - c.m_framexform.setIdentity(); - c.m_framexform.setOrigin(c.m_com); - c.m_framerefs.resize(c.m_nodes.size()); - { - int i; - for(i=0;im_x-c.m_com; - } - } - } -} - -// -void btSoftBody::updateClusters() -{ - BT_PROFILE("UpdateClusters"); - int i; - - for(i=0;im_x-c.m_com; - const btVector3& b=c.m_framerefs[i]; - m[0]+=a[0]*b;m[1]+=a[1]*b;m[2]+=a[2]*b; - } - PolarDecompose(m,r,s); - c.m_framexform.setOrigin(c.m_com); - c.m_framexform.setBasis(r); - /* Inertia */ -#if 1/* Constant */ - c.m_invwi=c.m_framexform.getBasis()*c.m_locii*c.m_framexform.getBasis().transpose(); -#else -#if 0/* Sphere */ - const btScalar rk=(2*c.m_extents.length2())/(5*c.m_imass); - const btVector3 inertia(rk,rk,rk); - const btVector3 iin(btFabs(inertia[0])>SIMD_EPSILON?1/inertia[0]:0, - btFabs(inertia[1])>SIMD_EPSILON?1/inertia[1]:0, - btFabs(inertia[2])>SIMD_EPSILON?1/inertia[2]:0); - - c.m_invwi=c.m_xform.getBasis().scaled(iin)*c.m_xform.getBasis().transpose(); -#else/* Actual */ - c.m_invwi[0]=c.m_invwi[1]=c.m_invwi[2]=btVector3(0,0,0); - for(int i=0;im_x-c.m_com; - const btVector3 q=k*k; - const btScalar m=1/c.m_nodes[i]->m_im; - c.m_invwi[0][0] += m*(q[1]+q[2]); - c.m_invwi[1][1] += m*(q[0]+q[2]); - c.m_invwi[2][2] += m*(q[0]+q[1]); - c.m_invwi[0][1] -= m*k[0]*k[1]; - c.m_invwi[0][2] -= m*k[0]*k[2]; - c.m_invwi[1][2] -= m*k[1]*k[2]; - } - c.m_invwi[1][0]=c.m_invwi[0][1]; - c.m_invwi[2][0]=c.m_invwi[0][2]; - c.m_invwi[2][1]=c.m_invwi[1][2]; - c.m_invwi=c.m_invwi.inverse(); -#endif -#endif - /* Velocities */ - c.m_lv=btVector3(0,0,0); - c.m_av=btVector3(0,0,0); - { - int i; - - for(i=0;im_v*c.m_masses[i]; - c.m_lv += v; - c.m_av += btCross(c.m_nodes[i]->m_x-c.m_com,v); - } - } - c.m_lv=c.m_imass*c.m_lv*(1-c.m_ldamping); - c.m_av=c.m_invwi*c.m_av*(1-c.m_adamping); - c.m_vimpulses[0] = - c.m_vimpulses[1] = btVector3(0,0,0); - c.m_dimpulses[0] = - c.m_dimpulses[1] = btVector3(0,0,0); - c.m_nvimpulses = 0; - c.m_ndimpulses = 0; - /* Matching */ - if(c.m_matching>0) - { - for(int j=0;jm_x; - btVector3 mx=mi; - for(int j=1;jm_x); - mx.setMax(c.m_nodes[j]->m_x); - } - ATTRIBUTE_ALIGNED16(btDbvtVolume) bounds=btDbvtVolume::FromMM(mi,mx); - if(c.m_leaf) - m_cdbvt.update(c.m_leaf,bounds,c.m_lv*m_sst.sdt*3,m_sst.radmrg); - else - c.m_leaf=m_cdbvt.insert(bounds,&c); - } - } - } - - -} - - - - -// -void btSoftBody::cleanupClusters() -{ - for(int i=0;iTerminate(m_sst.sdt); - if(m_joints[i]->m_delete) - { - btAlignedFree(m_joints[i]); - m_joints.remove(m_joints[i--]); - } - } -} - -// -void btSoftBody::prepareClusters(int iterations) -{ - for(int i=0;iPrepare(m_sst.sdt,iterations); - } -} - - -// -void btSoftBody::solveClusters(btScalar sor) -{ - for(int i=0,ni=m_joints.size();iSolve(m_sst.sdt,sor); - } -} - -// -void btSoftBody::applyClusters(bool drift) -{ - BT_PROFILE("ApplyClusters"); - const btScalar f0=m_sst.sdt; - //const btScalar f1=f0/2; - btAlignedObjectArray deltas; - btAlignedObjectArray weights; - deltas.resize(m_nodes.size(),btVector3(0,0,0)); - weights.resize(m_nodes.size(),0); - int i; - - if(drift) - { - for(i=0;im_x; - const btScalar q=c.m_masses[j]; - deltas[idx] += (v+btCross(w,x-c.m_com))*q; - weights[idx] += q; - } - } - } - for(i=0;i0) m_nodes[i].m_x+=deltas[i]/weights[i]; - } -} - -// -void btSoftBody::dampClusters() -{ - int i; - - for(i=0;i0) - { - for(int j=0;j0) - { - const btVector3 vx=c.m_lv+btCross(c.m_av,c.m_nodes[j]->m_q-c.m_com); - if(vx.length2()<=n.m_v.length2()) - { - n.m_v += c.m_ndamping*(vx-n.m_v); - } - } - } - } - } -} - -// -void btSoftBody::Joint::Prepare(btScalar dt,int) -{ - m_bodies[0].activate(); - m_bodies[1].activate(); -} - -// -void btSoftBody::LJoint::Prepare(btScalar dt,int iterations) -{ - static const btScalar maxdrift=4; - Joint::Prepare(dt,iterations); - m_rpos[0] = m_bodies[0].xform()*m_refs[0]; - m_rpos[1] = m_bodies[1].xform()*m_refs[1]; - m_drift = Clamp(m_rpos[0]-m_rpos[1],maxdrift)*m_erp/dt; - m_rpos[0] -= m_bodies[0].xform().getOrigin(); - m_rpos[1] -= m_bodies[1].xform().getOrigin(); - m_massmatrix = ImpulseMatrix( m_bodies[0].invMass(),m_bodies[0].invWorldInertia(),m_rpos[0], - m_bodies[1].invMass(),m_bodies[1].invWorldInertia(),m_rpos[1]); - if(m_split>0) - { - m_sdrift = m_massmatrix*(m_drift*m_split); - m_drift *= 1-m_split; - } - m_drift /=(btScalar)iterations; -} - -// -void btSoftBody::LJoint::Solve(btScalar dt,btScalar sor) -{ - const btVector3 va=m_bodies[0].velocity(m_rpos[0]); - const btVector3 vb=m_bodies[1].velocity(m_rpos[1]); - const btVector3 vr=va-vb; - btSoftBody::Impulse impulse; - impulse.m_asVelocity = 1; - impulse.m_velocity = m_massmatrix*(m_drift+vr*m_cfm)*sor; - m_bodies[0].applyImpulse(-impulse,m_rpos[0]); - m_bodies[1].applyImpulse( impulse,m_rpos[1]); -} - -// -void btSoftBody::LJoint::Terminate(btScalar dt) -{ - if(m_split>0) - { - m_bodies[0].applyDImpulse(-m_sdrift,m_rpos[0]); - m_bodies[1].applyDImpulse( m_sdrift,m_rpos[1]); - } -} - -// -void btSoftBody::AJoint::Prepare(btScalar dt,int iterations) -{ - static const btScalar maxdrift=SIMD_PI/16; - m_icontrol->Prepare(this); - Joint::Prepare(dt,iterations); - m_axis[0] = m_bodies[0].xform().getBasis()*m_refs[0]; - m_axis[1] = m_bodies[1].xform().getBasis()*m_refs[1]; - m_drift = NormalizeAny(btCross(m_axis[1],m_axis[0])); - m_drift *= btMin(maxdrift,btAcos(Clamp(btDot(m_axis[0],m_axis[1]),-1,+1))); - m_drift *= m_erp/dt; - m_massmatrix= AngularImpulseMatrix(m_bodies[0].invWorldInertia(),m_bodies[1].invWorldInertia()); - if(m_split>0) - { - m_sdrift = m_massmatrix*(m_drift*m_split); - m_drift *= 1-m_split; - } - m_drift /=(btScalar)iterations; -} - -// -void btSoftBody::AJoint::Solve(btScalar dt,btScalar sor) -{ - const btVector3 va=m_bodies[0].angularVelocity(); - const btVector3 vb=m_bodies[1].angularVelocity(); - const btVector3 vr=va-vb; - const btScalar sp=btDot(vr,m_axis[0]); - const btVector3 vc=vr-m_axis[0]*m_icontrol->Speed(this,sp); - btSoftBody::Impulse impulse; - impulse.m_asVelocity = 1; - impulse.m_velocity = m_massmatrix*(m_drift+vc*m_cfm)*sor; - m_bodies[0].applyAImpulse(-impulse); - m_bodies[1].applyAImpulse( impulse); -} - -// -void btSoftBody::AJoint::Terminate(btScalar dt) -{ - if(m_split>0) - { - m_bodies[0].applyDAImpulse(-m_sdrift); - m_bodies[1].applyDAImpulse( m_sdrift); - } -} - -// -void btSoftBody::CJoint::Prepare(btScalar dt,int iterations) -{ - Joint::Prepare(dt,iterations); - const bool dodrift=(m_life==0); - m_delete=(++m_life)>m_maxlife; - if(dodrift) - { - m_drift=m_drift*m_erp/dt; - if(m_split>0) - { - m_sdrift = m_massmatrix*(m_drift*m_split); - m_drift *= 1-m_split; - } - m_drift/=(btScalar)iterations; - } - else - { - m_drift=m_sdrift=btVector3(0,0,0); - } -} - -// -void btSoftBody::CJoint::Solve(btScalar dt,btScalar sor) -{ - const btVector3 va=m_bodies[0].velocity(m_rpos[0]); - const btVector3 vb=m_bodies[1].velocity(m_rpos[1]); - const btVector3 vrel=va-vb; - const btScalar rvac=btDot(vrel,m_normal); - btSoftBody::Impulse impulse; - impulse.m_asVelocity = 1; - impulse.m_velocity = m_drift; - if(rvac<0) - { - const btVector3 iv=m_normal*rvac; - const btVector3 fv=vrel-iv; - impulse.m_velocity += iv+fv*m_friction; - } - impulse.m_velocity=m_massmatrix*impulse.m_velocity*sor; - - if (m_bodies[0].m_soft==m_bodies[1].m_soft) - { - if ((impulse.m_velocity.getX() ==impulse.m_velocity.getX())&&(impulse.m_velocity.getY() ==impulse.m_velocity.getY())&& - (impulse.m_velocity.getZ() ==impulse.m_velocity.getZ())) - { - if (impulse.m_asVelocity) - { - if (impulse.m_velocity.length() m_maxSelfCollisionImpulse) - { - - } else - { - m_bodies[0].applyImpulse(-impulse*m_bodies[0].m_soft->m_selfCollisionImpulseFactor,m_rpos[0]); - m_bodies[1].applyImpulse( impulse*m_bodies[0].m_soft->m_selfCollisionImpulseFactor,m_rpos[1]); - } - } - } - } else - { - m_bodies[0].applyImpulse(-impulse,m_rpos[0]); - m_bodies[1].applyImpulse( impulse,m_rpos[1]); - } -} - -// -void btSoftBody::CJoint::Terminate(btScalar dt) -{ - if(m_split>0) - { - m_bodies[0].applyDImpulse(-m_sdrift,m_rpos[0]); - m_bodies[1].applyDImpulse( m_sdrift,m_rpos[1]); - } -} - -// -void btSoftBody::applyForces() -{ - - BT_PROFILE("SoftBody applyForces"); - const btScalar dt=m_sst.sdt; - const btScalar kLF=m_cfg.kLF; - const btScalar kDG=m_cfg.kDG; - const btScalar kPR=m_cfg.kPR; - const btScalar kVC=m_cfg.kVC; - const bool as_lift=kLF>0; - const bool as_drag=kDG>0; - const bool as_pressure=kPR!=0; - const bool as_volume=kVC>0; - const bool as_aero= as_lift || - as_drag ; - const bool as_vaero= as_aero && - (m_cfg.aeromodel=btSoftBody::eAeroModel::F_TwoSided); - const bool use_medium= as_aero; - const bool use_volume= as_pressure || - as_volume ; - btScalar volume=0; - btScalar ivolumetp=0; - btScalar dvolumetv=0; - btSoftBody::sMedium medium; - if(use_volume) - { - volume = getVolume(); - ivolumetp = 1/btFabs(volume)*kPR; - dvolumetv = (m_pose.m_volume-volume)*kVC; - } - /* Per vertex forces */ - int i,ni; - - for(i=0,ni=m_nodes.size();i0) - { - if(use_medium) - { - EvaluateMedium(m_worldInfo,n.m_x,medium); - /* Aerodynamics */ - if(as_vaero) - { - const btVector3 rel_v=n.m_v-medium.m_velocity; - const btScalar rel_v2=rel_v.length2(); - if(rel_v2>SIMD_EPSILON) - { - btVector3 nrm=n.m_n; - /* Setup normal */ - switch(m_cfg.aeromodel) - { - case btSoftBody::eAeroModel::V_Point: - nrm=NormalizeAny(rel_v);break; - case btSoftBody::eAeroModel::V_TwoSided: - nrm*=(btScalar)(btDot(nrm,rel_v)<0?-1:+1);break; - } - const btScalar dvn=btDot(rel_v,nrm); - /* Compute forces */ - if(dvn>0) - { - btVector3 force(0,0,0); - const btScalar c0 = n.m_area*dvn*rel_v2/2; - const btScalar c1 = c0*medium.m_density; - force += nrm*(-c1*kLF); - force += rel_v.normalized()*(-c1*kDG); - ApplyClampedForce(n,force,dt); - } - } - } - } - /* Pressure */ - if(as_pressure) - { - n.m_f += n.m_n*(n.m_area*ivolumetp); - } - /* Volume */ - if(as_volume) - { - n.m_f += n.m_n*(n.m_area*dvolumetv); - } - } - } - /* Per face forces */ - for(i=0,ni=m_faces.size();im_v+f.m_n[1]->m_v+f.m_n[2]->m_v)/3; - const btVector3 x=(f.m_n[0]->m_x+f.m_n[1]->m_x+f.m_n[2]->m_x)/3; - EvaluateMedium(m_worldInfo,x,medium); - const btVector3 rel_v=v-medium.m_velocity; - const btScalar rel_v2=rel_v.length2(); - if(rel_v2>SIMD_EPSILON) - { - btVector3 nrm=f.m_normal; - /* Setup normal */ - switch(m_cfg.aeromodel) - { - case btSoftBody::eAeroModel::F_TwoSided: - nrm*=(btScalar)(btDot(nrm,rel_v)<0?-1:+1);break; - } - const btScalar dvn=btDot(rel_v,nrm); - /* Compute forces */ - if(dvn>0) - { - btVector3 force(0,0,0); - const btScalar c0 = f.m_ra*dvn*rel_v2; - const btScalar c1 = c0*medium.m_density; - force += nrm*(-c1*kLF); - force += rel_v.normalized()*(-c1*kDG); - force /= 3; - for(int j=0;j<3;++j) ApplyClampedForce(*f.m_n[j],force,dt); - } - } - } - } -} - -// -void btSoftBody::PSolve_Anchors(btSoftBody* psb,btScalar kst,btScalar ti) -{ - const btScalar kAHR=psb->m_cfg.kAHR*kst; - const btScalar dt=psb->m_sst.sdt; - for(int i=0,ni=psb->m_anchors.size();im_anchors[i]; - const btTransform& t=a.m_body->getInterpolationWorldTransform(); - Node& n=*a.m_node; - const btVector3 wa=t*a.m_local; - const btVector3 va=a.m_body->getVelocityInLocalPoint(a.m_c1)*dt; - const btVector3 vb=n.m_x-n.m_q; - const btVector3 vr=(va-vb)+(wa-n.m_x)*kAHR; - const btVector3 impulse=a.m_c0*vr; - n.m_x+=impulse*a.m_c2; - a.m_body->applyImpulse(-impulse,a.m_c1); - } -} - -// -void btSoftBody::PSolve_RContacts(btSoftBody* psb,btScalar kst,btScalar ti) -{ - const btScalar dt=psb->m_sst.sdt; - const btScalar mrg=psb->getCollisionShape()->getMargin(); - for(int i=0,ni=psb->m_rcontacts.size();im_rcontacts[i]; - const sCti& cti=c.m_cti; - btRigidBody* tmpRigid = btRigidBody::upcast(cti.m_colObj); - - const btVector3 va=tmpRigid ? tmpRigid->getVelocityInLocalPoint(c.m_c1)*dt : btVector3(0,0,0); - const btVector3 vb=c.m_node->m_x-c.m_node->m_q; - const btVector3 vr=vb-va; - const btScalar dn=btDot(vr,cti.m_normal); - if(dn<=SIMD_EPSILON) - { - const btScalar dp=btMin(btDot(c.m_node->m_x,cti.m_normal)+cti.m_offset,mrg); - const btVector3 fv=vr-cti.m_normal*dn; - const btVector3 impulse=c.m_c0*((vr-fv*c.m_c3+cti.m_normal*(dp*c.m_c4))*kst); - c.m_node->m_x-=impulse*c.m_c2; - if (tmpRigid) - tmpRigid->applyImpulse(impulse,c.m_c1); - } - } -} - -// -void btSoftBody::PSolve_SContacts(btSoftBody* psb,btScalar,btScalar ti) -{ - for(int i=0,ni=psb->m_scontacts.size();im_scontacts[i]; - const btVector3& nr=c.m_normal; - Node& n=*c.m_node; - Face& f=*c.m_face; - const btVector3 p=BaryEval( f.m_n[0]->m_x, - f.m_n[1]->m_x, - f.m_n[2]->m_x, - c.m_weights); - const btVector3 q=BaryEval( f.m_n[0]->m_q, - f.m_n[1]->m_q, - f.m_n[2]->m_q, - c.m_weights); - const btVector3 vr=(n.m_x-n.m_q)-(p-q); - btVector3 corr(0,0,0); - btScalar dot = btDot(vr,nr); - if(dot<0) - { - const btScalar j=c.m_margin-(btDot(nr,n.m_x)-btDot(nr,p)); - corr+=c.m_normal*j; - } - corr -= ProjectOnPlane(vr,nr)*c.m_friction; - n.m_x += corr*c.m_cfm[0]; - f.m_n[0]->m_x -= corr*(c.m_cfm[1]*c.m_weights.x()); - f.m_n[1]->m_x -= corr*(c.m_cfm[1]*c.m_weights.y()); - f.m_n[2]->m_x -= corr*(c.m_cfm[1]*c.m_weights.z()); - } -} - -// -void btSoftBody::PSolve_Links(btSoftBody* psb,btScalar kst,btScalar ti) -{ - for(int i=0,ni=psb->m_links.size();im_links[i]; - if(l.m_c0>0) - { - Node& a=*l.m_n[0]; - Node& b=*l.m_n[1]; - const btVector3 del=b.m_x-a.m_x; - const btScalar len=del.length2(); - const btScalar k=((l.m_c1-len)/(l.m_c0*(l.m_c1+len)))*kst; - //const btScalar t=k*a.m_im; - a.m_x-=del*(k*a.m_im); - b.m_x+=del*(k*b.m_im); - } - } -} - -// -void btSoftBody::VSolve_Links(btSoftBody* psb,btScalar kst) -{ - for(int i=0,ni=psb->m_links.size();im_links[i]; - Node** n=l.m_n; - const btScalar j=-btDot(l.m_c3,n[0]->m_v-n[1]->m_v)*l.m_c2*kst; - n[0]->m_v+= l.m_c3*(j*n[0]->m_im); - n[1]->m_v-= l.m_c3*(j*n[1]->m_im); - } -} - -// -btSoftBody::psolver_t btSoftBody::getSolver(ePSolver::_ solver) -{ - switch(solver) - { - case ePSolver::Anchors: - return(&btSoftBody::PSolve_Anchors); - case ePSolver::Linear: - return(&btSoftBody::PSolve_Links); - case ePSolver::RContacts: - return(&btSoftBody::PSolve_RContacts); - case ePSolver::SContacts: - return(&btSoftBody::PSolve_SContacts); - } - return(0); -} - -// -btSoftBody::vsolver_t btSoftBody::getSolver(eVSolver::_ solver) -{ - switch(solver) - { - case eVSolver::Linear: return(&btSoftBody::VSolve_Links); - } - return(0); -} - -// -void btSoftBody::defaultCollisionHandler(btCollisionObject* pco) -{ - switch(m_cfg.collisions&fCollision::RVSmask) - { - case fCollision::SDF_RS: - { - btSoftColliders::CollideSDF_RS docollide; - btRigidBody* prb1=btRigidBody::upcast(pco); - btTransform wtr=prb1 ? prb1->getInterpolationWorldTransform() : pco->getWorldTransform(); - - const btTransform ctr=pco->getWorldTransform(); - const btScalar timemargin=(wtr.getOrigin()-ctr.getOrigin()).length(); - const btScalar basemargin=getCollisionShape()->getMargin(); - btVector3 mins; - btVector3 maxs; - ATTRIBUTE_ALIGNED16(btDbvtVolume) volume; - pco->getCollisionShape()->getAabb( pco->getInterpolationWorldTransform(), - mins, - maxs); - volume=btDbvtVolume::FromMM(mins,maxs); - volume.Expand(btVector3(basemargin,basemargin,basemargin)); - docollide.psb = this; - docollide.m_colObj1 = pco; - docollide.m_rigidBody = prb1; - - docollide.dynmargin = basemargin+timemargin; - docollide.stamargin = basemargin; - m_ndbvt.collideTV(m_ndbvt.m_root,volume,docollide); - } - break; - case fCollision::CL_RS: - { - btSoftColliders::CollideCL_RS collider; - collider.Process(this,pco); - } - break; - } -} - -// -void btSoftBody::defaultCollisionHandler(btSoftBody* psb) -{ - const int cf=m_cfg.collisions&psb->m_cfg.collisions; - switch(cf&fCollision::SVSmask) - { - case fCollision::CL_SS: - { - - //support self-collision if CL_SELF flag set - if (this!=psb || psb->m_cfg.collisions&fCollision::CL_SELF) - { - btSoftColliders::CollideCL_SS docollide; - docollide.Process(this,psb); - } - - } - break; - case fCollision::VF_SS: - { - //only self-collision for Cluster, not Vertex-Face yet - if (this!=psb) - { - btSoftColliders::CollideVF_SS docollide; - /* common */ - docollide.mrg= getCollisionShape()->getMargin()+ - psb->getCollisionShape()->getMargin(); - /* psb0 nodes vs psb1 faces */ - docollide.psb[0]=this; - docollide.psb[1]=psb; - docollide.psb[0]->m_ndbvt.collideTT( docollide.psb[0]->m_ndbvt.m_root, - docollide.psb[1]->m_fdbvt.m_root, - docollide); - /* psb1 nodes vs psb0 faces */ - docollide.psb[0]=psb; - docollide.psb[1]=this; - docollide.psb[0]->m_ndbvt.collideTT( docollide.psb[0]->m_ndbvt.m_root, - docollide.psb[1]->m_fdbvt.m_root, - docollide); - } - } - break; - default: - { - - } - } -} diff --git a/bullet/src/BulletSoftBody/btSoftBody.h b/bullet/src/BulletSoftBody/btSoftBody.h deleted file mode 100644 index 35a3af6d4..000000000 --- a/bullet/src/BulletSoftBody/btSoftBody.h +++ /dev/null @@ -1,891 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ -///btSoftBody implementation by Nathanael Presson - -#ifndef _BT_SOFT_BODY_H -#define _BT_SOFT_BODY_H - -#include "LinearMath/btAlignedObjectArray.h" -#include "LinearMath/btTransform.h" -#include "LinearMath/btIDebugDraw.h" -#include "BulletDynamics/Dynamics/btRigidBody.h" - -#include "BulletCollision/CollisionShapes/btConcaveShape.h" -#include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h" -#include "btSparseSDF.h" -#include "BulletCollision/BroadphaseCollision/btDbvt.h" - -class btBroadphaseInterface; -class btDispatcher; - -/* btSoftBodyWorldInfo */ -struct btSoftBodyWorldInfo -{ - btScalar air_density; - btScalar water_density; - btScalar water_offset; - btVector3 water_normal; - btBroadphaseInterface* m_broadphase; - btDispatcher* m_dispatcher; - btVector3 m_gravity; - btSparseSdf<3> m_sparsesdf; -}; - - -///The btSoftBody is an class to simulate cloth and volumetric soft bodies. -///There is two-way interaction between btSoftBody and btRigidBody/btCollisionObject. -class btSoftBody : public btCollisionObject -{ -public: - btAlignedObjectArray m_collisionDisabledObjects; - - // - // Enumerations - // - - ///eAeroModel - struct eAeroModel { enum _ { - V_Point, ///Vertex normals are oriented toward velocity - V_TwoSided, ///Vertex normals are fliped to match velocity - V_OneSided, ///Vertex normals are taken as it is - F_TwoSided, ///Face normals are fliped to match velocity - F_OneSided, ///Face normals are taken as it is - END - };}; - - ///eVSolver : velocities solvers - struct eVSolver { enum _ { - Linear, ///Linear solver - END - };}; - - ///ePSolver : positions solvers - struct ePSolver { enum _ { - Linear, ///Linear solver - Anchors, ///Anchor solver - RContacts, ///Rigid contacts solver - SContacts, ///Soft contacts solver - END - };}; - - ///eSolverPresets - struct eSolverPresets { enum _ { - Positions, - Velocities, - Default = Positions, - END - };}; - - ///eFeature - struct eFeature { enum _ { - None, - Node, - Link, - Face, - END - };}; - - typedef btAlignedObjectArray tVSolverArray; - typedef btAlignedObjectArray tPSolverArray; - - // - // Flags - // - - ///fCollision - struct fCollision { enum _ { - RVSmask = 0x000f, ///Rigid versus soft mask - SDF_RS = 0x0001, ///SDF based rigid vs soft - CL_RS = 0x0002, ///Cluster vs convex rigid vs soft - - SVSmask = 0x0030, ///Rigid versus soft mask - VF_SS = 0x0010, ///Vertex vs face soft vs soft handling - CL_SS = 0x0020, ///Cluster vs cluster soft vs soft handling - CL_SELF = 0x0040, ///Cluster soft body self collision - /* presets */ - Default = SDF_RS, - END - };}; - - ///fMaterial - struct fMaterial { enum _ { - DebugDraw = 0x0001, /// Enable debug draw - /* presets */ - Default = DebugDraw, - END - };}; - - // - // API Types - // - - /* sRayCast */ - struct sRayCast - { - btSoftBody* body; /// soft body - eFeature::_ feature; /// feature type - int index; /// feature index - btScalar fraction; /// time of impact fraction (rayorg+(rayto-rayfrom)*fraction) - }; - - /* ImplicitFn */ - struct ImplicitFn - { - virtual btScalar Eval(const btVector3& x)=0; - }; - - // - // Internal types - // - - typedef btAlignedObjectArray tScalarArray; - typedef btAlignedObjectArray tVector3Array; - - /* sCti is Softbody contact info */ - struct sCti - { - btCollisionObject* m_colObj; /* Rigid body */ - btVector3 m_normal; /* Outward normal */ - btScalar m_offset; /* Offset from origin */ - }; - - /* sMedium */ - struct sMedium - { - btVector3 m_velocity; /* Velocity */ - btScalar m_pressure; /* Pressure */ - btScalar m_density; /* Density */ - }; - - /* Base type */ - struct Element - { - void* m_tag; // User data - Element() : m_tag(0) {} - }; - /* Material */ - struct Material : Element - { - btScalar m_kLST; // Linear stiffness coefficient [0,1] - btScalar m_kAST; // Area/Angular stiffness coefficient [0,1] - btScalar m_kVST; // Volume stiffness coefficient [0,1] - int m_flags; // Flags - }; - - /* Feature */ - struct Feature : Element - { - Material* m_material; // Material - }; - /* Node */ - struct Node : Feature - { - btVector3 m_x; // Position - btVector3 m_q; // Previous step position - btVector3 m_v; // Velocity - btVector3 m_f; // Force accumulator - btVector3 m_n; // Normal - btScalar m_im; // 1/mass - btScalar m_area; // Area - btDbvtNode* m_leaf; // Leaf data - int m_battach:1; // Attached - }; - /* Link */ - struct Link : Feature - { - Node* m_n[2]; // Node pointers - btScalar m_rl; // Rest length - int m_bbending:1; // Bending link - btScalar m_c0; // (ima+imb)*kLST - btScalar m_c1; // rl^2 - btScalar m_c2; // |gradient|^2/c0 - btVector3 m_c3; // gradient - }; - /* Face */ - struct Face : Feature - { - Node* m_n[3]; // Node pointers - btVector3 m_normal; // Normal - btScalar m_ra; // Rest area - btDbvtNode* m_leaf; // Leaf data - }; - /* Tetra */ - struct Tetra : Feature - { - Node* m_n[4]; // Node pointers - btScalar m_rv; // Rest volume - btDbvtNode* m_leaf; // Leaf data - btVector3 m_c0[4]; // gradients - btScalar m_c1; // (4*kVST)/(im0+im1+im2+im3) - btScalar m_c2; // m_c1/sum(|g0..3|^2) - }; - /* RContact */ - struct RContact - { - sCti m_cti; // Contact infos - Node* m_node; // Owner node - btMatrix3x3 m_c0; // Impulse matrix - btVector3 m_c1; // Relative anchor - btScalar m_c2; // ima*dt - btScalar m_c3; // Friction - btScalar m_c4; // Hardness - }; - /* SContact */ - struct SContact - { - Node* m_node; // Node - Face* m_face; // Face - btVector3 m_weights; // Weigths - btVector3 m_normal; // Normal - btScalar m_margin; // Margin - btScalar m_friction; // Friction - btScalar m_cfm[2]; // Constraint force mixing - }; - /* Anchor */ - struct Anchor - { - Node* m_node; // Node pointer - btVector3 m_local; // Anchor position in body space - btRigidBody* m_body; // Body - btMatrix3x3 m_c0; // Impulse matrix - btVector3 m_c1; // Relative anchor - btScalar m_c2; // ima*dt - }; - /* Note */ - struct Note : Element - { - const char* m_text; // Text - btVector3 m_offset; // Offset - int m_rank; // Rank - Node* m_nodes[4]; // Nodes - btScalar m_coords[4]; // Coordinates - }; - /* Pose */ - struct Pose - { - bool m_bvolume; // Is valid - bool m_bframe; // Is frame - btScalar m_volume; // Rest volume - tVector3Array m_pos; // Reference positions - tScalarArray m_wgh; // Weights - btVector3 m_com; // COM - btMatrix3x3 m_rot; // Rotation - btMatrix3x3 m_scl; // Scale - btMatrix3x3 m_aqq; // Base scaling - }; - /* Cluster */ - struct Cluster - { - btAlignedObjectArray m_nodes; - tScalarArray m_masses; - tVector3Array m_framerefs; - btTransform m_framexform; - btScalar m_idmass; - btScalar m_imass; - btMatrix3x3 m_locii; - btMatrix3x3 m_invwi; - btVector3 m_com; - btVector3 m_vimpulses[2]; - btVector3 m_dimpulses[2]; - int m_nvimpulses; - int m_ndimpulses; - btVector3 m_lv; - btVector3 m_av; - btDbvtNode* m_leaf; - btScalar m_ndamping; /* Node damping */ - btScalar m_ldamping; /* Linear damping */ - btScalar m_adamping; /* Angular damping */ - btScalar m_matching; - btScalar m_maxSelfCollisionImpulse; - btScalar m_selfCollisionImpulseFactor; - bool m_containsAnchor; - bool m_collide; - int m_clusterIndex; - Cluster() : m_leaf(0),m_ndamping(0),m_ldamping(0),m_adamping(0),m_matching(0) - ,m_maxSelfCollisionImpulse(100.f), - m_selfCollisionImpulseFactor(0.01f), - m_containsAnchor(false) - {} - }; - /* Impulse */ - struct Impulse - { - btVector3 m_velocity; - btVector3 m_drift; - int m_asVelocity:1; - int m_asDrift:1; - Impulse() : m_velocity(0,0,0),m_drift(0,0,0),m_asVelocity(0),m_asDrift(0) {} - Impulse operator -() const - { - Impulse i=*this; - i.m_velocity=-i.m_velocity; - i.m_drift=-i.m_drift; - return(i); - } - Impulse operator*(btScalar x) const - { - Impulse i=*this; - i.m_velocity*=x; - i.m_drift*=x; - return(i); - } - }; - /* Body */ - struct Body - { - Cluster* m_soft; - btRigidBody* m_rigid; - btCollisionObject* m_collisionObject; - - Body() : m_soft(0),m_rigid(0),m_collisionObject(0) {} - Body(Cluster* p) : m_soft(p),m_rigid(0),m_collisionObject(0) {} - Body(btCollisionObject* colObj) : m_soft(0),m_collisionObject(colObj) - { - m_rigid = btRigidBody::upcast(m_collisionObject); - } - - void activate() const - { - if(m_rigid) m_rigid->activate(); - } - const btMatrix3x3& invWorldInertia() const - { - static const btMatrix3x3 iwi(0,0,0,0,0,0,0,0,0); - if(m_rigid) return(m_rigid->getInvInertiaTensorWorld()); - if(m_soft) return(m_soft->m_invwi); - return(iwi); - } - btScalar invMass() const - { - if(m_rigid) return(m_rigid->getInvMass()); - if(m_soft) return(m_soft->m_imass); - return(0); - } - const btTransform& xform() const - { - static const btTransform identity=btTransform::getIdentity(); - if(m_collisionObject) return(m_collisionObject->getInterpolationWorldTransform()); - if(m_soft) return(m_soft->m_framexform); - return(identity); - } - btVector3 linearVelocity() const - { - if(m_rigid) return(m_rigid->getLinearVelocity()); - if(m_soft) return(m_soft->m_lv); - return(btVector3(0,0,0)); - } - btVector3 angularVelocity(const btVector3& rpos) const - { - if(m_rigid) return(btCross(m_rigid->getAngularVelocity(),rpos)); - if(m_soft) return(btCross(m_soft->m_av,rpos)); - return(btVector3(0,0,0)); - } - btVector3 angularVelocity() const - { - if(m_rigid) return(m_rigid->getAngularVelocity()); - if(m_soft) return(m_soft->m_av); - return(btVector3(0,0,0)); - } - btVector3 velocity(const btVector3& rpos) const - { - return(linearVelocity()+angularVelocity(rpos)); - } - void applyVImpulse(const btVector3& impulse,const btVector3& rpos) const - { - if(m_rigid) m_rigid->applyImpulse(impulse,rpos); - if(m_soft) btSoftBody::clusterVImpulse(m_soft,rpos,impulse); - } - void applyDImpulse(const btVector3& impulse,const btVector3& rpos) const - { - if(m_rigid) m_rigid->applyImpulse(impulse,rpos); - if(m_soft) btSoftBody::clusterDImpulse(m_soft,rpos,impulse); - } - void applyImpulse(const Impulse& impulse,const btVector3& rpos) const - { - if(impulse.m_asVelocity) - { -// printf("impulse.m_velocity = %f,%f,%f\n",impulse.m_velocity.getX(),impulse.m_velocity.getY(),impulse.m_velocity.getZ()); - applyVImpulse(impulse.m_velocity,rpos); - } - if(impulse.m_asDrift) - { -// printf("impulse.m_drift = %f,%f,%f\n",impulse.m_drift.getX(),impulse.m_drift.getY(),impulse.m_drift.getZ()); - applyDImpulse(impulse.m_drift,rpos); - } - } - void applyVAImpulse(const btVector3& impulse) const - { - if(m_rigid) m_rigid->applyTorqueImpulse(impulse); - if(m_soft) btSoftBody::clusterVAImpulse(m_soft,impulse); - } - void applyDAImpulse(const btVector3& impulse) const - { - if(m_rigid) m_rigid->applyTorqueImpulse(impulse); - if(m_soft) btSoftBody::clusterDAImpulse(m_soft,impulse); - } - void applyAImpulse(const Impulse& impulse) const - { - if(impulse.m_asVelocity) applyVAImpulse(impulse.m_velocity); - if(impulse.m_asDrift) applyDAImpulse(impulse.m_drift); - } - void applyDCImpulse(const btVector3& impulse) const - { - if(m_rigid) m_rigid->applyCentralImpulse(impulse); - if(m_soft) btSoftBody::clusterDCImpulse(m_soft,impulse); - } - }; - /* Joint */ - struct Joint - { - struct eType { enum _ { - Linear, - Angular, - Contact - };}; - struct Specs - { - Specs() : erp(1),cfm(1),split(1) {} - btScalar erp; - btScalar cfm; - btScalar split; - }; - Body m_bodies[2]; - btVector3 m_refs[2]; - btScalar m_cfm; - btScalar m_erp; - btScalar m_split; - btVector3 m_drift; - btVector3 m_sdrift; - btMatrix3x3 m_massmatrix; - bool m_delete; - virtual ~Joint() {} - Joint() : m_delete(false) {} - virtual void Prepare(btScalar dt,int iterations); - virtual void Solve(btScalar dt,btScalar sor)=0; - virtual void Terminate(btScalar dt)=0; - virtual eType::_ Type() const=0; - }; - /* LJoint */ - struct LJoint : Joint - { - struct Specs : Joint::Specs - { - btVector3 position; - }; - btVector3 m_rpos[2]; - void Prepare(btScalar dt,int iterations); - void Solve(btScalar dt,btScalar sor); - void Terminate(btScalar dt); - eType::_ Type() const { return(eType::Linear); } - }; - /* AJoint */ - struct AJoint : Joint - { - struct IControl - { - virtual void Prepare(AJoint*) {} - virtual btScalar Speed(AJoint*,btScalar current) { return(current); } - static IControl* Default() { static IControl def;return(&def); } - }; - struct Specs : Joint::Specs - { - Specs() : icontrol(IControl::Default()) {} - btVector3 axis; - IControl* icontrol; - }; - btVector3 m_axis[2]; - IControl* m_icontrol; - void Prepare(btScalar dt,int iterations); - void Solve(btScalar dt,btScalar sor); - void Terminate(btScalar dt); - eType::_ Type() const { return(eType::Angular); } - }; - /* CJoint */ - struct CJoint : Joint - { - int m_life; - int m_maxlife; - btVector3 m_rpos[2]; - btVector3 m_normal; - btScalar m_friction; - void Prepare(btScalar dt,int iterations); - void Solve(btScalar dt,btScalar sor); - void Terminate(btScalar dt); - eType::_ Type() const { return(eType::Contact); } - }; - /* Config */ - struct Config - { - eAeroModel::_ aeromodel; // Aerodynamic model (default: V_Point) - btScalar kVCF; // Velocities correction factor (Baumgarte) - btScalar kDP; // Damping coefficient [0,1] - btScalar kDG; // Drag coefficient [0,+inf] - btScalar kLF; // Lift coefficient [0,+inf] - btScalar kPR; // Pressure coefficient [-inf,+inf] - btScalar kVC; // Volume conversation coefficient [0,+inf] - btScalar kDF; // Dynamic friction coefficient [0,1] - btScalar kMT; // Pose matching coefficient [0,1] - btScalar kCHR; // Rigid contacts hardness [0,1] - btScalar kKHR; // Kinetic contacts hardness [0,1] - btScalar kSHR; // Soft contacts hardness [0,1] - btScalar kAHR; // Anchors hardness [0,1] - btScalar kSRHR_CL; // Soft vs rigid hardness [0,1] (cluster only) - btScalar kSKHR_CL; // Soft vs kinetic hardness [0,1] (cluster only) - btScalar kSSHR_CL; // Soft vs soft hardness [0,1] (cluster only) - btScalar kSR_SPLT_CL; // Soft vs rigid impulse split [0,1] (cluster only) - btScalar kSK_SPLT_CL; // Soft vs rigid impulse split [0,1] (cluster only) - btScalar kSS_SPLT_CL; // Soft vs rigid impulse split [0,1] (cluster only) - btScalar maxvolume; // Maximum volume ratio for pose - btScalar timescale; // Time scale - int viterations; // Velocities solver iterations - int piterations; // Positions solver iterations - int diterations; // Drift solver iterations - int citerations; // Cluster solver iterations - int collisions; // Collisions flags - tVSolverArray m_vsequence; // Velocity solvers sequence - tPSolverArray m_psequence; // Position solvers sequence - tPSolverArray m_dsequence; // Drift solvers sequence - }; - /* SolverState */ - struct SolverState - { - btScalar sdt; // dt*timescale - btScalar isdt; // 1/sdt - btScalar velmrg; // velocity margin - btScalar radmrg; // radial margin - btScalar updmrg; // Update margin - }; - /// RayFromToCaster takes a ray from, ray to (instead of direction!) - struct RayFromToCaster : btDbvt::ICollide - { - btVector3 m_rayFrom; - btVector3 m_rayTo; - btVector3 m_rayNormalizedDirection; - btScalar m_mint; - Face* m_face; - int m_tests; - RayFromToCaster(const btVector3& rayFrom,const btVector3& rayTo,btScalar mxt); - void Process(const btDbvtNode* leaf); - - static inline btScalar rayFromToTriangle(const btVector3& rayFrom, - const btVector3& rayTo, - const btVector3& rayNormalizedDirection, - const btVector3& a, - const btVector3& b, - const btVector3& c, - btScalar maxt=SIMD_INFINITY); - }; - - // - // Typedef's - // - - typedef void (*psolver_t)(btSoftBody*,btScalar,btScalar); - typedef void (*vsolver_t)(btSoftBody*,btScalar); - typedef btAlignedObjectArray tClusterArray; - typedef btAlignedObjectArray tNoteArray; - typedef btAlignedObjectArray tNodeArray; - typedef btAlignedObjectArray tLeafArray; - typedef btAlignedObjectArray tLinkArray; - typedef btAlignedObjectArray tFaceArray; - typedef btAlignedObjectArray tTetraArray; - typedef btAlignedObjectArray tAnchorArray; - typedef btAlignedObjectArray tRContactArray; - typedef btAlignedObjectArray tSContactArray; - typedef btAlignedObjectArray tMaterialArray; - typedef btAlignedObjectArray tJointArray; - typedef btAlignedObjectArray tSoftBodyArray; - - // - // Fields - // - - Config m_cfg; // Configuration - SolverState m_sst; // Solver state - Pose m_pose; // Pose - void* m_tag; // User data - btSoftBodyWorldInfo* m_worldInfo; // World info - tNoteArray m_notes; // Notes - tNodeArray m_nodes; // Nodes - tLinkArray m_links; // Links - tFaceArray m_faces; // Faces - tTetraArray m_tetras; // Tetras - tAnchorArray m_anchors; // Anchors - tRContactArray m_rcontacts; // Rigid contacts - tSContactArray m_scontacts; // Soft contacts - tJointArray m_joints; // Joints - tMaterialArray m_materials; // Materials - btScalar m_timeacc; // Time accumulator - btVector3 m_bounds[2]; // Spatial bounds - bool m_bUpdateRtCst; // Update runtime constants - btDbvt m_ndbvt; // Nodes tree - btDbvt m_fdbvt; // Faces tree - btDbvt m_cdbvt; // Clusters tree - tClusterArray m_clusters; // Clusters - - btAlignedObjectArraym_clusterConnectivity;//cluster connectivity, for self-collision - - btTransform m_initialWorldTransform; - - // - // Api - // - - /* ctor */ - btSoftBody( btSoftBodyWorldInfo* worldInfo,int node_count, - const btVector3* x, - const btScalar* m); - /* dtor */ - virtual ~btSoftBody(); - /* Check for existing link */ - - btAlignedObjectArray m_userIndexMapping; - - btSoftBodyWorldInfo* getWorldInfo() - { - return m_worldInfo; - } - - ///@todo: avoid internal softbody shape hack and move collision code to collision library - virtual void setCollisionShape(btCollisionShape* collisionShape) - { - - } - - bool checkLink( int node0, - int node1) const; - bool checkLink( const Node* node0, - const Node* node1) const; - /* Check for existring face */ - bool checkFace( int node0, - int node1, - int node2) const; - /* Append material */ - Material* appendMaterial(); - /* Append note */ - void appendNote( const char* text, - const btVector3& o, - const btVector4& c=btVector4(1,0,0,0), - Node* n0=0, - Node* n1=0, - Node* n2=0, - Node* n3=0); - void appendNote( const char* text, - const btVector3& o, - Node* feature); - void appendNote( const char* text, - const btVector3& o, - Link* feature); - void appendNote( const char* text, - const btVector3& o, - Face* feature); - /* Append node */ - void appendNode( const btVector3& x,btScalar m); - /* Append link */ - void appendLink(int model=-1,Material* mat=0); - void appendLink( int node0, - int node1, - Material* mat=0, - bool bcheckexist=false); - void appendLink( Node* node0, - Node* node1, - Material* mat=0, - bool bcheckexist=false); - /* Append face */ - void appendFace(int model=-1,Material* mat=0); - void appendFace( int node0, - int node1, - int node2, - Material* mat=0); - void appendTetra(int model,Material* mat); - // - void appendTetra(int node0, - int node1, - int node2, - int node3, - Material* mat=0); - - - /* Append anchor */ - void appendAnchor( int node, - btRigidBody* body, bool disableCollisionBetweenLinkedBodies=false); - /* Append linear joint */ - void appendLinearJoint(const LJoint::Specs& specs,Cluster* body0,Body body1); - void appendLinearJoint(const LJoint::Specs& specs,Body body=Body()); - void appendLinearJoint(const LJoint::Specs& specs,btSoftBody* body); - /* Append linear joint */ - void appendAngularJoint(const AJoint::Specs& specs,Cluster* body0,Body body1); - void appendAngularJoint(const AJoint::Specs& specs,Body body=Body()); - void appendAngularJoint(const AJoint::Specs& specs,btSoftBody* body); - /* Add force (or gravity) to the entire body */ - void addForce( const btVector3& force); - /* Add force (or gravity) to a node of the body */ - void addForce( const btVector3& force, - int node); - /* Add velocity to the entire body */ - void addVelocity( const btVector3& velocity); - - /* Set velocity for the entire body */ - void setVelocity( const btVector3& velocity); - - /* Add velocity to a node of the body */ - void addVelocity( const btVector3& velocity, - int node); - /* Set mass */ - void setMass( int node, - btScalar mass); - /* Get mass */ - btScalar getMass( int node) const; - /* Get total mass */ - btScalar getTotalMass() const; - /* Set total mass (weighted by previous masses) */ - void setTotalMass( btScalar mass, - bool fromfaces=false); - /* Set total density */ - void setTotalDensity(btScalar density); - /* Set volume mass (using tetrahedrons) */ - void setVolumeMass( btScalar mass); - /* Set volume density (using tetrahedrons) */ - void setVolumeDensity( btScalar density); - /* Transform */ - void transform( const btTransform& trs); - /* Translate */ - void translate( const btVector3& trs); - /* Rotate */ - void rotate( const btQuaternion& rot); - /* Scale */ - void scale( const btVector3& scl); - /* Set current state as pose */ - void setPose( bool bvolume, - bool bframe); - /* Return the volume */ - btScalar getVolume() const; - /* Cluster count */ - int clusterCount() const; - /* Cluster center of mass */ - static btVector3 clusterCom(const Cluster* cluster); - btVector3 clusterCom(int cluster) const; - /* Cluster velocity at rpos */ - static btVector3 clusterVelocity(const Cluster* cluster,const btVector3& rpos); - /* Cluster impulse */ - static void clusterVImpulse(Cluster* cluster,const btVector3& rpos,const btVector3& impulse); - static void clusterDImpulse(Cluster* cluster,const btVector3& rpos,const btVector3& impulse); - static void clusterImpulse(Cluster* cluster,const btVector3& rpos,const Impulse& impulse); - static void clusterVAImpulse(Cluster* cluster,const btVector3& impulse); - static void clusterDAImpulse(Cluster* cluster,const btVector3& impulse); - static void clusterAImpulse(Cluster* cluster,const Impulse& impulse); - static void clusterDCImpulse(Cluster* cluster,const btVector3& impulse); - /* Generate bending constraints based on distance in the adjency graph */ - int generateBendingConstraints( int distance, - Material* mat=0); - /* Randomize constraints to reduce solver bias */ - void randomizeConstraints(); - /* Release clusters */ - void releaseCluster(int index); - void releaseClusters(); - /* Generate clusters (K-mean) */ - ///generateClusters with k=0 will create a convex cluster for each tetrahedron or triangle - ///otherwise an approximation will be used (better performance) - int generateClusters(int k,int maxiterations=8192); - /* Refine */ - void refine(ImplicitFn* ifn,btScalar accurary,bool cut); - /* CutLink */ - bool cutLink(int node0,int node1,btScalar position); - bool cutLink(const Node* node0,const Node* node1,btScalar position); - - ///Ray casting using rayFrom and rayTo in worldspace, (not direction!) - bool rayTest(const btVector3& rayFrom, - const btVector3& rayTo, - sRayCast& results); - /* Solver presets */ - void setSolver(eSolverPresets::_ preset); - /* predictMotion */ - void predictMotion(btScalar dt); - /* solveConstraints */ - void solveConstraints(); - /* staticSolve */ - void staticSolve(int iterations); - /* solveCommonConstraints */ - static void solveCommonConstraints(btSoftBody** bodies,int count,int iterations); - /* solveClusters */ - static void solveClusters(const btAlignedObjectArray& bodies); - /* integrateMotion */ - void integrateMotion(); - /* defaultCollisionHandlers */ - void defaultCollisionHandler(btCollisionObject* pco); - void defaultCollisionHandler(btSoftBody* psb); - - // - // Cast - // - - static const btSoftBody* upcast(const btCollisionObject* colObj) - { - if (colObj->getInternalType()==CO_SOFT_BODY) - return (const btSoftBody*)colObj; - return 0; - } - static btSoftBody* upcast(btCollisionObject* colObj) - { - if (colObj->getInternalType()==CO_SOFT_BODY) - return (btSoftBody*)colObj; - return 0; - } - - // - // ::btCollisionObject - // - - virtual void getAabb(btVector3& aabbMin,btVector3& aabbMax) const - { - aabbMin = m_bounds[0]; - aabbMax = m_bounds[1]; - } - // - // Private - // - void pointersToIndices(); - void indicesToPointers(const int* map=0); - - int rayTest(const btVector3& rayFrom,const btVector3& rayTo, - btScalar& mint,eFeature::_& feature,int& index,bool bcountonly) const; - void initializeFaceTree(); - btVector3 evaluateCom() const; - bool checkContact(btCollisionObject* colObj,const btVector3& x,btScalar margin,btSoftBody::sCti& cti) const; - void updateNormals(); - void updateBounds(); - void updatePose(); - void updateConstants(); - void initializeClusters(); - void updateClusters(); - void cleanupClusters(); - void prepareClusters(int iterations); - void solveClusters(btScalar sor); - void applyClusters(bool drift); - void dampClusters(); - void applyForces(); - static void PSolve_Anchors(btSoftBody* psb,btScalar kst,btScalar ti); - static void PSolve_RContacts(btSoftBody* psb,btScalar kst,btScalar ti); - static void PSolve_SContacts(btSoftBody* psb,btScalar,btScalar ti); - static void PSolve_Links(btSoftBody* psb,btScalar kst,btScalar ti); - static void VSolve_Links(btSoftBody* psb,btScalar kst); - static psolver_t getSolver(ePSolver::_ solver); - static vsolver_t getSolver(eVSolver::_ solver); - -}; - - - -#endif //_BT_SOFT_BODY_H diff --git a/bullet/src/BulletSoftBody/btSoftBodyConcaveCollisionAlgorithm.cpp b/bullet/src/BulletSoftBody/btSoftBodyConcaveCollisionAlgorithm.cpp deleted file mode 100644 index 5fab6b62a..000000000 --- a/bullet/src/BulletSoftBody/btSoftBodyConcaveCollisionAlgorithm.cpp +++ /dev/null @@ -1,368 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#include "btSoftBodyConcaveCollisionAlgorithm.h" -#include "BulletCollision/CollisionDispatch/btCollisionObject.h" -#include "BulletCollision/CollisionShapes/btMultiSphereShape.h" -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" -#include "BulletCollision/CollisionShapes/btConcaveShape.h" -#include "BulletCollision/CollisionDispatch/btManifoldResult.h" -#include "BulletCollision/NarrowPhaseCollision/btRaycastCallback.h" -#include "BulletCollision/CollisionShapes/btTriangleShape.h" -#include "BulletCollision/CollisionShapes/btSphereShape.h" -#include "BulletCollision/CollisionShapes/btTetrahedronShape.h" -#include "BulletCollision/CollisionShapes/btConvexHullShape.h" - - - -#include "LinearMath/btIDebugDraw.h" -#include "BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h" -#include "BulletSoftBody/btSoftBody.h" - -#define BT_SOFTBODY_TRIANGLE_EXTRUSION btScalar(0.06)//make this configurable - -btSoftBodyConcaveCollisionAlgorithm::btSoftBodyConcaveCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1,bool isSwapped) -: btCollisionAlgorithm(ci), -m_isSwapped(isSwapped), -m_btSoftBodyTriangleCallback(ci.m_dispatcher1,body0,body1,isSwapped) -{ -} - - - -btSoftBodyConcaveCollisionAlgorithm::~btSoftBodyConcaveCollisionAlgorithm() -{ -} - - - -btSoftBodyTriangleCallback::btSoftBodyTriangleCallback(btDispatcher* dispatcher,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped): -m_dispatcher(dispatcher), -m_dispatchInfoPtr(0) -{ - m_softBody = (btSoftBody*) (isSwapped? body1:body0); - m_triBody = isSwapped? body0:body1; - - // - // create the manifold from the dispatcher 'manifold pool' - // - // m_manifoldPtr = m_dispatcher->getNewManifold(m_convexBody,m_triBody); - - clearCache(); -} - -btSoftBodyTriangleCallback::~btSoftBodyTriangleCallback() -{ - clearCache(); - // m_dispatcher->releaseManifold( m_manifoldPtr ); - -} - - -void btSoftBodyTriangleCallback::clearCache() -{ - for (int i=0;im_childShape); - m_softBody->getWorldInfo()->m_sparsesdf.RemoveReferences(tmp->m_childShape);//necessary? - delete tmp->m_childShape; - } - m_shapeCache.clear(); -} - - -void btSoftBodyTriangleCallback::processTriangle(btVector3* triangle,int partId, int triangleIndex) -{ - //just for debugging purposes - //printf("triangle %d",m_triangleCount++); - btCollisionObject* ob = static_cast(m_triBody); - btCollisionAlgorithmConstructionInfo ci; - ci.m_dispatcher1 = m_dispatcher; - - ///debug drawing of the overlapping triangles - if (m_dispatchInfoPtr && m_dispatchInfoPtr->m_debugDraw && m_dispatchInfoPtr->m_debugDraw->getDebugMode() &btIDebugDraw::DBG_DrawWireframe) - { - btVector3 color(255,255,0); - btTransform& tr = ob->getWorldTransform(); - m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[0]),tr(triangle[1]),color); - m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[1]),tr(triangle[2]),color); - m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[2]),tr(triangle[0]),color); - } - - btTriIndex triIndex(partId,triangleIndex,0); - btHashKey triKey(triIndex.getUid()); - - - btTriIndex* shapeIndex = m_shapeCache[triKey]; - if (shapeIndex) - { - btCollisionShape* tm = shapeIndex->m_childShape; - btAssert(tm); - - //copy over user pointers to temporary shape - tm->setUserPointer(ob->getRootCollisionShape()->getUserPointer()); - - btCollisionShape* tmpShape = ob->getCollisionShape(); - ob->internalSetTemporaryCollisionShape( tm ); - - - btCollisionAlgorithm* colAlgo = ci.m_dispatcher1->findAlgorithm(m_softBody,m_triBody,0);//m_manifoldPtr); - - colAlgo->processCollision(m_softBody,m_triBody,*m_dispatchInfoPtr,m_resultOut); - colAlgo->~btCollisionAlgorithm(); - ci.m_dispatcher1->freeCollisionAlgorithm(colAlgo); - ob->internalSetTemporaryCollisionShape( tmpShape); - return; - } - - //aabb filter is already applied! - - //btCollisionObject* colObj = static_cast(m_convexProxy->m_clientObject); - - // if (m_softBody->getCollisionShape()->getShapeType()== - { - // btVector3 other; - btVector3 normal = (triangle[1]-triangle[0]).cross(triangle[2]-triangle[0]); - normal.normalize(); - normal*= BT_SOFTBODY_TRIANGLE_EXTRUSION; - // other=(triangle[0]+triangle[1]+triangle[2])*0.333333f; - // other+=normal*22.f; - btVector3 pts[6] = {triangle[0]+normal, - triangle[1]+normal, - triangle[2]+normal, - triangle[0]-normal, - triangle[1]-normal, - triangle[2]-normal}; - - btConvexHullShape* tm = new btConvexHullShape(&pts[0].getX(),6); - - - // btBU_Simplex1to4 tm(triangle[0],triangle[1],triangle[2],other); - - //btTriangleShape tm(triangle[0],triangle[1],triangle[2]); - // tm.setMargin(m_collisionMarginTriangle); - - //copy over user pointers to temporary shape - tm->setUserPointer(ob->getRootCollisionShape()->getUserPointer()); - - btCollisionShape* tmpShape = ob->getCollisionShape(); - ob->internalSetTemporaryCollisionShape( tm ); - - - btCollisionAlgorithm* colAlgo = ci.m_dispatcher1->findAlgorithm(m_softBody,m_triBody,0);//m_manifoldPtr); - ///this should use the btDispatcher, so the actual registered algorithm is used - // btConvexConvexAlgorithm cvxcvxalgo(m_manifoldPtr,ci,m_convexBody,m_triBody); - - //m_resultOut->setShapeIdentifiersB(partId,triangleIndex); - // cvxcvxalgo.processCollision(m_convexBody,m_triBody,*m_dispatchInfoPtr,m_resultOut); - colAlgo->processCollision(m_softBody,m_triBody,*m_dispatchInfoPtr,m_resultOut); - colAlgo->~btCollisionAlgorithm(); - ci.m_dispatcher1->freeCollisionAlgorithm(colAlgo); - - - ob->internalSetTemporaryCollisionShape( tmpShape ); - triIndex.m_childShape = tm; - m_shapeCache.insert(triKey,triIndex); - - } - - - -} - - - -void btSoftBodyTriangleCallback::setTimeStepAndCounters(btScalar collisionMarginTriangle,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) -{ - m_dispatchInfoPtr = &dispatchInfo; - m_collisionMarginTriangle = collisionMarginTriangle+btScalar(BT_SOFTBODY_TRIANGLE_EXTRUSION); - m_resultOut = resultOut; - - - btVector3 aabbWorldSpaceMin,aabbWorldSpaceMax; - m_softBody->getAabb(aabbWorldSpaceMin,aabbWorldSpaceMax); - btVector3 halfExtents = (aabbWorldSpaceMax-aabbWorldSpaceMin)*btScalar(0.5); - btVector3 softBodyCenter = (aabbWorldSpaceMax+aabbWorldSpaceMin)*btScalar(0.5); - - btTransform softTransform; - softTransform.setIdentity(); - softTransform.setOrigin(softBodyCenter); - - btTransform convexInTriangleSpace; - convexInTriangleSpace = m_triBody->getWorldTransform().inverse() * softTransform; - btTransformAabb(halfExtents,m_collisionMarginTriangle,convexInTriangleSpace,m_aabbMin,m_aabbMax); -} - -void btSoftBodyConcaveCollisionAlgorithm::clearCache() -{ - m_btSoftBodyTriangleCallback.clearCache(); - -} - -void btSoftBodyConcaveCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) -{ - - - //btCollisionObject* convexBody = m_isSwapped ? body1 : body0; - btCollisionObject* triBody = m_isSwapped ? body0 : body1; - - if (triBody->getCollisionShape()->isConcave()) - { - - - btCollisionObject* triOb = triBody; - btConcaveShape* concaveShape = static_cast( triOb->getCollisionShape()); - - // if (convexBody->getCollisionShape()->isConvex()) - { - btScalar collisionMarginTriangle = concaveShape->getMargin(); - - // resultOut->setPersistentManifold(m_btSoftBodyTriangleCallback.m_manifoldPtr); - m_btSoftBodyTriangleCallback.setTimeStepAndCounters(collisionMarginTriangle,dispatchInfo,resultOut); - - //Disable persistency. previously, some older algorithm calculated all contacts in one go, so you can clear it here. - //m_dispatcher->clearManifold(m_btSoftBodyTriangleCallback.m_manifoldPtr); - - // m_btSoftBodyTriangleCallback.m_manifoldPtr->setBodies(convexBody,triBody); - - - concaveShape->processAllTriangles( &m_btSoftBodyTriangleCallback,m_btSoftBodyTriangleCallback.getAabbMin(),m_btSoftBodyTriangleCallback.getAabbMax()); - - // resultOut->refreshContactPoints(); - - } - - } - -} - - -btScalar btSoftBodyConcaveCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) -{ - (void)resultOut; - (void)dispatchInfo; - btCollisionObject* convexbody = m_isSwapped ? body1 : body0; - btCollisionObject* triBody = m_isSwapped ? body0 : body1; - - - //quick approximation using raycast, todo: hook up to the continuous collision detection (one of the btConvexCast) - - //only perform CCD above a certain threshold, this prevents blocking on the long run - //because object in a blocked ccd state (hitfraction<1) get their linear velocity halved each frame... - btScalar squareMot0 = (convexbody->getInterpolationWorldTransform().getOrigin() - convexbody->getWorldTransform().getOrigin()).length2(); - if (squareMot0 < convexbody->getCcdSquareMotionThreshold()) - { - return btScalar(1.); - } - - //const btVector3& from = convexbody->m_worldTransform.getOrigin(); - //btVector3 to = convexbody->m_interpolationWorldTransform.getOrigin(); - //todo: only do if the motion exceeds the 'radius' - - btTransform triInv = triBody->getWorldTransform().inverse(); - btTransform convexFromLocal = triInv * convexbody->getWorldTransform(); - btTransform convexToLocal = triInv * convexbody->getInterpolationWorldTransform(); - - struct LocalTriangleSphereCastCallback : public btTriangleCallback - { - btTransform m_ccdSphereFromTrans; - btTransform m_ccdSphereToTrans; - btTransform m_meshTransform; - - btScalar m_ccdSphereRadius; - btScalar m_hitFraction; - - - LocalTriangleSphereCastCallback(const btTransform& from,const btTransform& to,btScalar ccdSphereRadius,btScalar hitFraction) - :m_ccdSphereFromTrans(from), - m_ccdSphereToTrans(to), - m_ccdSphereRadius(ccdSphereRadius), - m_hitFraction(hitFraction) - { - } - - - virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex) - { - (void)partId; - (void)triangleIndex; - //do a swept sphere for now - btTransform ident; - ident.setIdentity(); - btConvexCast::CastResult castResult; - castResult.m_fraction = m_hitFraction; - btSphereShape pointShape(m_ccdSphereRadius); - btTriangleShape triShape(triangle[0],triangle[1],triangle[2]); - btVoronoiSimplexSolver simplexSolver; - btSubsimplexConvexCast convexCaster(&pointShape,&triShape,&simplexSolver); - //GjkConvexCast convexCaster(&pointShape,convexShape,&simplexSolver); - //ContinuousConvexCollision convexCaster(&pointShape,convexShape,&simplexSolver,0); - //local space? - - if (convexCaster.calcTimeOfImpact(m_ccdSphereFromTrans,m_ccdSphereToTrans, - ident,ident,castResult)) - { - if (m_hitFraction > castResult.m_fraction) - m_hitFraction = castResult.m_fraction; - } - - } - - }; - - - - - - if (triBody->getCollisionShape()->isConcave()) - { - btVector3 rayAabbMin = convexFromLocal.getOrigin(); - rayAabbMin.setMin(convexToLocal.getOrigin()); - btVector3 rayAabbMax = convexFromLocal.getOrigin(); - rayAabbMax.setMax(convexToLocal.getOrigin()); - btScalar ccdRadius0 = convexbody->getCcdSweptSphereRadius(); - rayAabbMin -= btVector3(ccdRadius0,ccdRadius0,ccdRadius0); - rayAabbMax += btVector3(ccdRadius0,ccdRadius0,ccdRadius0); - - btScalar curHitFraction = btScalar(1.); //is this available? - LocalTriangleSphereCastCallback raycastCallback(convexFromLocal,convexToLocal, - convexbody->getCcdSweptSphereRadius(),curHitFraction); - - raycastCallback.m_hitFraction = convexbody->getHitFraction(); - - btCollisionObject* concavebody = triBody; - - btConcaveShape* triangleMesh = (btConcaveShape*) concavebody->getCollisionShape(); - - if (triangleMesh) - { - triangleMesh->processAllTriangles(&raycastCallback,rayAabbMin,rayAabbMax); - } - - - - if (raycastCallback.m_hitFraction < convexbody->getHitFraction()) - { - convexbody->setHitFraction( raycastCallback.m_hitFraction); - return raycastCallback.m_hitFraction; - } - } - - return btScalar(1.); - -} diff --git a/bullet/src/BulletSoftBody/btSoftBodyConcaveCollisionAlgorithm.h b/bullet/src/BulletSoftBody/btSoftBodyConcaveCollisionAlgorithm.h deleted file mode 100644 index cddcf2cda..000000000 --- a/bullet/src/BulletSoftBody/btSoftBodyConcaveCollisionAlgorithm.h +++ /dev/null @@ -1,153 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef SOFT_BODY_CONCAVE_COLLISION_ALGORITHM_H -#define SOFT_BODY_CONCAVE_COLLISION_ALGORITHM_H - -#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h" -#include "BulletCollision/BroadphaseCollision/btDispatcher.h" -#include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h" -#include "BulletCollision/CollisionShapes/btTriangleCallback.h" -#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h" -class btDispatcher; -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" -#include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h" -class btSoftBody; -class btCollisionShape; - -#include "LinearMath/btHashMap.h" - -#include "BulletCollision/BroadphaseCollision/btQuantizedBvh.h" //for definition of MAX_NUM_PARTS_IN_BITS - -struct btTriIndex -{ - int m_PartIdTriangleIndex; - class btCollisionShape* m_childShape; - - btTriIndex(int partId,int triangleIndex,btCollisionShape* shape) - { - m_PartIdTriangleIndex = (partId<<(31-MAX_NUM_PARTS_IN_BITS)) | triangleIndex; - m_childShape = shape; - } - - int getTriangleIndex() const - { - // Get only the lower bits where the triangle index is stored - return (m_PartIdTriangleIndex&~((~0)<<(31-MAX_NUM_PARTS_IN_BITS))); - } - int getPartId() const - { - // Get only the highest bits where the part index is stored - return (m_PartIdTriangleIndex>>(31-MAX_NUM_PARTS_IN_BITS)); - } - int getUid() const - { - return m_PartIdTriangleIndex; - } -}; - - -///For each triangle in the concave mesh that overlaps with the AABB of a soft body (m_softBody), processTriangle is called. -class btSoftBodyTriangleCallback : public btTriangleCallback -{ - btSoftBody* m_softBody; - btCollisionObject* m_triBody; - - btVector3 m_aabbMin; - btVector3 m_aabbMax ; - - btManifoldResult* m_resultOut; - - btDispatcher* m_dispatcher; - const btDispatcherInfo* m_dispatchInfoPtr; - btScalar m_collisionMarginTriangle; - - btHashMap,btTriIndex> m_shapeCache; - -public: - int m_triangleCount; - - // btPersistentManifold* m_manifoldPtr; - - btSoftBodyTriangleCallback(btDispatcher* dispatcher,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped); - - void setTimeStepAndCounters(btScalar collisionMarginTriangle,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); - - virtual ~btSoftBodyTriangleCallback(); - - virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex); - - void clearCache(); - - SIMD_FORCE_INLINE const btVector3& getAabbMin() const - { - return m_aabbMin; - } - SIMD_FORCE_INLINE const btVector3& getAabbMax() const - { - return m_aabbMax; - } - -}; - - - - -/// btSoftBodyConcaveCollisionAlgorithm supports collision between soft body shapes and (concave) trianges meshes. -class btSoftBodyConcaveCollisionAlgorithm : public btCollisionAlgorithm -{ - - bool m_isSwapped; - - btSoftBodyTriangleCallback m_btSoftBodyTriangleCallback; - -public: - - btSoftBodyConcaveCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped); - - virtual ~btSoftBodyConcaveCollisionAlgorithm(); - - virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); - - btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); - - virtual void getAllContactManifolds(btManifoldArray& manifoldArray) - { - //we don't add any manifolds - } - - void clearCache(); - - struct CreateFunc :public btCollisionAlgorithmCreateFunc - { - virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1) - { - void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btSoftBodyConcaveCollisionAlgorithm)); - return new(mem) btSoftBodyConcaveCollisionAlgorithm(ci,body0,body1,false); - } - }; - - struct SwappedCreateFunc :public btCollisionAlgorithmCreateFunc - { - virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1) - { - void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btSoftBodyConcaveCollisionAlgorithm)); - return new(mem) btSoftBodyConcaveCollisionAlgorithm(ci,body0,body1,true); - } - }; - -}; - -#endif //SOFT_BODY_CONCAVE_COLLISION_ALGORITHM_H diff --git a/bullet/src/BulletSoftBody/btSoftBodyHelpers.cpp b/bullet/src/BulletSoftBody/btSoftBodyHelpers.cpp deleted file mode 100644 index 8b38a5247..000000000 --- a/bullet/src/BulletSoftBody/btSoftBodyHelpers.cpp +++ /dev/null @@ -1,1006 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ -///btSoftBodyHelpers.cpp by Nathanael Presson - -#include "btSoftBodyInternals.h" -#include -#include -#include "btSoftBodyHelpers.h" -#include "LinearMath/btConvexHull.h" - -// -static void drawVertex( btIDebugDraw* idraw, - const btVector3& x,btScalar s,const btVector3& c) -{ - idraw->drawLine(x-btVector3(s,0,0),x+btVector3(s,0,0),c); - idraw->drawLine(x-btVector3(0,s,0),x+btVector3(0,s,0),c); - idraw->drawLine(x-btVector3(0,0,s),x+btVector3(0,0,s),c); -} - -// -static void drawBox( btIDebugDraw* idraw, - const btVector3& mins, - const btVector3& maxs, - const btVector3& color) -{ - const btVector3 c[]={ btVector3(mins.x(),mins.y(),mins.z()), - btVector3(maxs.x(),mins.y(),mins.z()), - btVector3(maxs.x(),maxs.y(),mins.z()), - btVector3(mins.x(),maxs.y(),mins.z()), - btVector3(mins.x(),mins.y(),maxs.z()), - btVector3(maxs.x(),mins.y(),maxs.z()), - btVector3(maxs.x(),maxs.y(),maxs.z()), - btVector3(mins.x(),maxs.y(),maxs.z())}; - idraw->drawLine(c[0],c[1],color);idraw->drawLine(c[1],c[2],color); - idraw->drawLine(c[2],c[3],color);idraw->drawLine(c[3],c[0],color); - idraw->drawLine(c[4],c[5],color);idraw->drawLine(c[5],c[6],color); - idraw->drawLine(c[6],c[7],color);idraw->drawLine(c[7],c[4],color); - idraw->drawLine(c[0],c[4],color);idraw->drawLine(c[1],c[5],color); - idraw->drawLine(c[2],c[6],color);idraw->drawLine(c[3],c[7],color); -} - -// -static void drawTree( btIDebugDraw* idraw, - const btDbvtNode* node, - int depth, - const btVector3& ncolor, - const btVector3& lcolor, - int mindepth, - int maxdepth) -{ - if(node) - { - if(node->isinternal()&&((depthchilds[0],depth+1,ncolor,lcolor,mindepth,maxdepth); - drawTree(idraw,node->childs[1],depth+1,ncolor,lcolor,mindepth,maxdepth); - } - if(depth>=mindepth) - { - const btScalar scl=(btScalar)(node->isinternal()?1:1); - const btVector3 mi=node->volume.Center()-node->volume.Extents()*scl; - const btVector3 mx=node->volume.Center()+node->volume.Extents()*scl; - drawBox(idraw,mi,mx,node->isleaf()?lcolor:ncolor); - } - } -} - -// -template -static inline T sum(const btAlignedObjectArray& items) -{ - T v; - if(items.size()) - { - v=items[0]; - for(int i=1,ni=items.size();i -static inline void add(btAlignedObjectArray& items,const Q& value) -{ - for(int i=0,ni=items.size();i -static inline void mul(btAlignedObjectArray& items,const Q& value) -{ - for(int i=0,ni=items.size();i -static inline T average(const btAlignedObjectArray& items) -{ - const btScalar n=(btScalar)(items.size()>0?items.size():1); - return(sum(items)/n); -} - -// -static inline btScalar tetravolume(const btVector3& x0, - const btVector3& x1, - const btVector3& x2, - const btVector3& x3) -{ - const btVector3 a=x1-x0; - const btVector3 b=x2-x0; - const btVector3 c=x3-x0; - return(btDot(a,btCross(b,c))); -} - -// -#if 0 -static btVector3 stresscolor(btScalar stress) -{ - static const btVector3 spectrum[]= { btVector3(1,0,1), - btVector3(0,0,1), - btVector3(0,1,1), - btVector3(0,1,0), - btVector3(1,1,0), - btVector3(1,0,0), - btVector3(1,0,0)}; - static const int ncolors=sizeof(spectrum)/sizeof(spectrum[0])-1; - static const btScalar one=1; - stress=btMax(0,btMin(1,stress))*ncolors; - const int sel=(int)stress; - const btScalar frc=stress-sel; - return(spectrum[sel]+(spectrum[sel+1]-spectrum[sel])*frc); -} -#endif - -// -void btSoftBodyHelpers::Draw( btSoftBody* psb, - btIDebugDraw* idraw, - int drawflags) -{ - const btScalar scl=(btScalar)0.1; - const btScalar nscl=scl*5; - const btVector3 lcolor=btVector3(0,0,0); - const btVector3 ncolor=btVector3(1,1,1); - const btVector3 ccolor=btVector3(1,0,0); - int i,j,nj; - - /* Nodes */ - if(0!=(drawflags&fDrawFlags::Nodes)) - { - for(i=0;im_nodes.size();++i) - { - const btSoftBody::Node& n=psb->m_nodes[i]; - if(0==(n.m_material->m_flags&btSoftBody::fMaterial::DebugDraw)) continue; - idraw->drawLine(n.m_x-btVector3(scl,0,0),n.m_x+btVector3(scl,0,0),btVector3(1,0,0)); - idraw->drawLine(n.m_x-btVector3(0,scl,0),n.m_x+btVector3(0,scl,0),btVector3(0,1,0)); - idraw->drawLine(n.m_x-btVector3(0,0,scl),n.m_x+btVector3(0,0,scl),btVector3(0,0,1)); - } - } - /* Links */ - if(0!=(drawflags&fDrawFlags::Links)) - { - for(i=0;im_links.size();++i) - { - const btSoftBody::Link& l=psb->m_links[i]; - if(0==(l.m_material->m_flags&btSoftBody::fMaterial::DebugDraw)) continue; - idraw->drawLine(l.m_n[0]->m_x,l.m_n[1]->m_x,lcolor); - } - } - /* Normals */ - if(0!=(drawflags&fDrawFlags::Normals)) - { - for(i=0;im_nodes.size();++i) - { - const btSoftBody::Node& n=psb->m_nodes[i]; - if(0==(n.m_material->m_flags&btSoftBody::fMaterial::DebugDraw)) continue; - const btVector3 d=n.m_n*nscl; - idraw->drawLine(n.m_x,n.m_x+d,ncolor); - idraw->drawLine(n.m_x,n.m_x-d,ncolor*0.5); - } - } - /* Contacts */ - if(0!=(drawflags&fDrawFlags::Contacts)) - { - static const btVector3 axis[]={btVector3(1,0,0), - btVector3(0,1,0), - btVector3(0,0,1)}; - for(i=0;im_rcontacts.size();++i) - { - const btSoftBody::RContact& c=psb->m_rcontacts[i]; - const btVector3 o= c.m_node->m_x-c.m_cti.m_normal* - (btDot(c.m_node->m_x,c.m_cti.m_normal)+c.m_cti.m_offset); - const btVector3 x=btCross(c.m_cti.m_normal,axis[c.m_cti.m_normal.minAxis()]).normalized(); - const btVector3 y=btCross(x,c.m_cti.m_normal).normalized(); - idraw->drawLine(o-x*nscl,o+x*nscl,ccolor); - idraw->drawLine(o-y*nscl,o+y*nscl,ccolor); - idraw->drawLine(o,o+c.m_cti.m_normal*nscl*3,btVector3(1,1,0)); - } - } - /* Anchors */ - if(0!=(drawflags&fDrawFlags::Anchors)) - { - for(i=0;im_anchors.size();++i) - { - const btSoftBody::Anchor& a=psb->m_anchors[i]; - const btVector3 q=a.m_body->getWorldTransform()*a.m_local; - drawVertex(idraw,a.m_node->m_x,0.25,btVector3(1,0,0)); - drawVertex(idraw,q,0.25,btVector3(0,1,0)); - idraw->drawLine(a.m_node->m_x,q,btVector3(1,1,1)); - } - for(i=0;im_nodes.size();++i) - { - const btSoftBody::Node& n=psb->m_nodes[i]; - if(0==(n.m_material->m_flags&btSoftBody::fMaterial::DebugDraw)) continue; - if(n.m_im<=0) - { - drawVertex(idraw,n.m_x,0.25,btVector3(1,0,0)); - } - } - } - /* Faces */ - if(0!=(drawflags&fDrawFlags::Faces)) - { - const btScalar scl=(btScalar)0.8; - const btScalar alp=(btScalar)1; - const btVector3 col(0,(btScalar)0.7,0); - for(i=0;im_faces.size();++i) - { - const btSoftBody::Face& f=psb->m_faces[i]; - if(0==(f.m_material->m_flags&btSoftBody::fMaterial::DebugDraw)) continue; - const btVector3 x[]={f.m_n[0]->m_x,f.m_n[1]->m_x,f.m_n[2]->m_x}; - const btVector3 c=(x[0]+x[1]+x[2])/3; - idraw->drawTriangle((x[0]-c)*scl+c, - (x[1]-c)*scl+c, - (x[2]-c)*scl+c, - col,alp); - } - } - /* Clusters */ - if(0!=(drawflags&fDrawFlags::Clusters)) - { - srand(1806); - for(i=0;im_clusters.size();++i) - { - if(psb->m_clusters[i]->m_collide) - { - btVector3 color( rand()/(btScalar)RAND_MAX, - rand()/(btScalar)RAND_MAX, - rand()/(btScalar)RAND_MAX); - color=color.normalized()*0.75; - btAlignedObjectArray vertices; - vertices.resize(psb->m_clusters[i]->m_nodes.size()); - for(j=0,nj=vertices.size();jm_clusters[i]->m_nodes[j]->m_x; - } - HullDesc hdsc(QF_TRIANGLES,vertices.size(),&vertices[0]); - HullResult hres; - HullLibrary hlib; - hdsc.mMaxVertices=vertices.size(); - hlib.CreateConvexHull(hdsc,hres); - const btVector3 center=average(hres.m_OutputVertices); - add(hres.m_OutputVertices,-center); - mul(hres.m_OutputVertices,(btScalar)1); - add(hres.m_OutputVertices,center); - for(j=0;j<(int)hres.mNumFaces;++j) - { - const int idx[]={hres.m_Indices[j*3+0],hres.m_Indices[j*3+1],hres.m_Indices[j*3+2]}; - idraw->drawTriangle(hres.m_OutputVertices[idx[0]], - hres.m_OutputVertices[idx[1]], - hres.m_OutputVertices[idx[2]], - color,1); - } - hlib.ReleaseResult(hres); - } - /* Velocities */ -#if 0 - for(int j=0;jm_clusters[i].m_nodes.size();++j) - { - const btSoftBody::Cluster& c=psb->m_clusters[i]; - const btVector3 r=c.m_nodes[j]->m_x-c.m_com; - const btVector3 v=c.m_lv+btCross(c.m_av,r); - idraw->drawLine(c.m_nodes[j]->m_x,c.m_nodes[j]->m_x+v,btVector3(1,0,0)); - } -#endif - /* Frame */ - btSoftBody::Cluster& c=*psb->m_clusters[i]; - idraw->drawLine(c.m_com,c.m_framexform*btVector3(10,0,0),btVector3(1,0,0)); - idraw->drawLine(c.m_com,c.m_framexform*btVector3(0,10,0),btVector3(0,1,0)); - idraw->drawLine(c.m_com,c.m_framexform*btVector3(0,0,10),btVector3(0,0,1)); - } - } - - /* Tetras */ - if(0!=(drawflags&fDrawFlags::Tetras)) - { - const btScalar scl=(btScalar)0.8; - const btScalar alp=(btScalar)1; - const btVector3 col((btScalar)0.7,(btScalar)0.7,(btScalar)0.7); - for(int i=0;im_tetras.size();++i) - { - const btSoftBody::Tetra& t=psb->m_tetras[i]; - if(0==(t.m_material->m_flags&btSoftBody::fMaterial::DebugDraw)) continue; - const btVector3 x[]={t.m_n[0]->m_x,t.m_n[1]->m_x,t.m_n[2]->m_x,t.m_n[3]->m_x}; - const btVector3 c=(x[0]+x[1]+x[2]+x[3])/4; - idraw->drawTriangle((x[0]-c)*scl+c,(x[1]-c)*scl+c,(x[2]-c)*scl+c,col,alp); - idraw->drawTriangle((x[0]-c)*scl+c,(x[1]-c)*scl+c,(x[3]-c)*scl+c,col,alp); - idraw->drawTriangle((x[1]-c)*scl+c,(x[2]-c)*scl+c,(x[3]-c)*scl+c,col,alp); - idraw->drawTriangle((x[2]-c)*scl+c,(x[0]-c)*scl+c,(x[3]-c)*scl+c,col,alp); - } - } - - /* Notes */ - if(0!=(drawflags&fDrawFlags::Notes)) - { - for(i=0;im_notes.size();++i) - { - const btSoftBody::Note& n=psb->m_notes[i]; - btVector3 p=n.m_offset; - for(int j=0;jm_x*n.m_coords[j]; - } - idraw->draw3dText(p,n.m_text); - } - } - /* Node tree */ - if(0!=(drawflags&fDrawFlags::NodeTree)) DrawNodeTree(psb,idraw); - /* Face tree */ - if(0!=(drawflags&fDrawFlags::FaceTree)) DrawFaceTree(psb,idraw); - /* Cluster tree */ - if(0!=(drawflags&fDrawFlags::ClusterTree)) DrawClusterTree(psb,idraw); - /* Joints */ - if(0!=(drawflags&fDrawFlags::Joints)) - { - for(i=0;im_joints.size();++i) - { - const btSoftBody::Joint* pj=psb->m_joints[i]; - switch(pj->Type()) - { - case btSoftBody::Joint::eType::Linear: - { - const btSoftBody::LJoint* pjl=(const btSoftBody::LJoint*)pj; - const btVector3 a0=pj->m_bodies[0].xform()*pjl->m_refs[0]; - const btVector3 a1=pj->m_bodies[1].xform()*pjl->m_refs[1]; - idraw->drawLine(pj->m_bodies[0].xform().getOrigin(),a0,btVector3(1,1,0)); - idraw->drawLine(pj->m_bodies[1].xform().getOrigin(),a1,btVector3(0,1,1)); - drawVertex(idraw,a0,0.25,btVector3(1,1,0)); - drawVertex(idraw,a1,0.25,btVector3(0,1,1)); - } - break; - case btSoftBody::Joint::eType::Angular: - { - //const btSoftBody::AJoint* pja=(const btSoftBody::AJoint*)pj; - const btVector3 o0=pj->m_bodies[0].xform().getOrigin(); - const btVector3 o1=pj->m_bodies[1].xform().getOrigin(); - const btVector3 a0=pj->m_bodies[0].xform().getBasis()*pj->m_refs[0]; - const btVector3 a1=pj->m_bodies[1].xform().getBasis()*pj->m_refs[1]; - idraw->drawLine(o0,o0+a0*10,btVector3(1,1,0)); - idraw->drawLine(o0,o0+a1*10,btVector3(1,1,0)); - idraw->drawLine(o1,o1+a0*10,btVector3(0,1,1)); - idraw->drawLine(o1,o1+a1*10,btVector3(0,1,1)); - } - } - } - } -} - -// -void btSoftBodyHelpers::DrawInfos( btSoftBody* psb, - btIDebugDraw* idraw, - bool masses, - bool areas, - bool /*stress*/) -{ - for(int i=0;im_nodes.size();++i) - { - const btSoftBody::Node& n=psb->m_nodes[i]; - char text[2048]={0}; - char buff[1024]; - if(masses) - { - sprintf(buff," M(%.2f)",1/n.m_im); - strcat(text,buff); - } - if(areas) - { - sprintf(buff," A(%.2f)",n.m_area); - strcat(text,buff); - } - if(text[0]) idraw->draw3dText(n.m_x,text); - } -} - -// -void btSoftBodyHelpers::DrawNodeTree( btSoftBody* psb, - btIDebugDraw* idraw, - int mindepth, - int maxdepth) -{ - drawTree(idraw,psb->m_ndbvt.m_root,0,btVector3(1,0,1),btVector3(1,1,1),mindepth,maxdepth); -} - -// -void btSoftBodyHelpers::DrawFaceTree( btSoftBody* psb, - btIDebugDraw* idraw, - int mindepth, - int maxdepth) -{ - drawTree(idraw,psb->m_fdbvt.m_root,0,btVector3(0,1,0),btVector3(1,0,0),mindepth,maxdepth); -} - -// -void btSoftBodyHelpers::DrawClusterTree( btSoftBody* psb, - btIDebugDraw* idraw, - int mindepth, - int maxdepth) -{ - drawTree(idraw,psb->m_cdbvt.m_root,0,btVector3(0,1,1),btVector3(1,0,0),mindepth,maxdepth); -} - -// -void btSoftBodyHelpers::DrawFrame( btSoftBody* psb, - btIDebugDraw* idraw) -{ - if(psb->m_pose.m_bframe) - { - static const btScalar ascl=10; - static const btScalar nscl=(btScalar)0.1; - const btVector3 com=psb->m_pose.m_com; - const btMatrix3x3 trs=psb->m_pose.m_rot*psb->m_pose.m_scl; - const btVector3 Xaxis=(trs*btVector3(1,0,0)).normalized(); - const btVector3 Yaxis=(trs*btVector3(0,1,0)).normalized(); - const btVector3 Zaxis=(trs*btVector3(0,0,1)).normalized(); - idraw->drawLine(com,com+Xaxis*ascl,btVector3(1,0,0)); - idraw->drawLine(com,com+Yaxis*ascl,btVector3(0,1,0)); - idraw->drawLine(com,com+Zaxis*ascl,btVector3(0,0,1)); - for(int i=0;im_pose.m_pos.size();++i) - { - const btVector3 x=com+trs*psb->m_pose.m_pos[i]; - drawVertex(idraw,x,nscl,btVector3(1,0,1)); - } - } -} - -// -btSoftBody* btSoftBodyHelpers::CreateRope( btSoftBodyWorldInfo& worldInfo, const btVector3& from, - const btVector3& to, - int res, - int fixeds) -{ - /* Create nodes */ - const int r=res+2; - btVector3* x=new btVector3[r]; - btScalar* m=new btScalar[r]; - int i; - - for(i=0;isetMass(0,0); - if(fixeds&2) psb->setMass(r-1,0); - delete[] x; - delete[] m; - /* Create links */ - for(i=1;iappendLink(i-1,i); - } - /* Finished */ - return(psb); -} - -// -btSoftBody* btSoftBodyHelpers::CreatePatch(btSoftBodyWorldInfo& worldInfo,const btVector3& corner00, - const btVector3& corner10, - const btVector3& corner01, - const btVector3& corner11, - int resx, - int resy, - int fixeds, - bool gendiags) -{ -#define IDX(_x_,_y_) ((_y_)*rx+(_x_)) - /* Create nodes */ - if((resx<2)||(resy<2)) return(0); - const int rx=resx; - const int ry=resy; - const int tot=rx*ry; - btVector3* x=new btVector3[tot]; - btScalar* m=new btScalar[tot]; - int iy; - - for(iy=0;iysetMass(IDX(0,0),0); - if(fixeds&2) psb->setMass(IDX(rx-1,0),0); - if(fixeds&4) psb->setMass(IDX(0,ry-1),0); - if(fixeds&8) psb->setMass(IDX(rx-1,ry-1),0); - delete[] x; - delete[] m; - /* Create links and faces */ - for(iy=0;iyappendLink(idx,IDX(ix+1,iy)); - if(mdy) psb->appendLink(idx,IDX(ix,iy+1)); - if(mdx&&mdy) - { - if((ix+iy)&1) - { - psb->appendFace(IDX(ix,iy),IDX(ix+1,iy),IDX(ix+1,iy+1)); - psb->appendFace(IDX(ix,iy),IDX(ix+1,iy+1),IDX(ix,iy+1)); - if(gendiags) - { - psb->appendLink(IDX(ix,iy),IDX(ix+1,iy+1)); - } - } - else - { - psb->appendFace(IDX(ix,iy+1),IDX(ix,iy),IDX(ix+1,iy)); - psb->appendFace(IDX(ix,iy+1),IDX(ix+1,iy),IDX(ix+1,iy+1)); - if(gendiags) - { - psb->appendLink(IDX(ix+1,iy),IDX(ix,iy+1)); - } - } - } - } - } - /* Finished */ -#undef IDX - return(psb); -} - -// -btSoftBody* btSoftBodyHelpers::CreatePatchUV(btSoftBodyWorldInfo& worldInfo, - const btVector3& corner00, - const btVector3& corner10, - const btVector3& corner01, - const btVector3& corner11, - int resx, - int resy, - int fixeds, - bool gendiags, - float* tex_coords) -{ - - /* - * - * corners: - * - * [0][0] corner00 ------- corner01 [resx][0] - * | | - * | | - * [0][resy] corner10 -------- corner11 [resx][resy] - * - * - * - * - * - * - * "fixedgs" map: - * - * corner00 --> +1 - * corner01 --> +2 - * corner10 --> +4 - * corner11 --> +8 - * upper middle --> +16 - * left middle --> +32 - * right middle --> +64 - * lower middle --> +128 - * center --> +256 - * - * - * tex_coords size (resx-1)*(resy-1)*12 - * - * - * - * SINGLE QUAD INTERNALS - * - * 1) btSoftBody's nodes and links, - * diagonal link is optional ("gendiags") - * - * - * node00 ------ node01 - * | . - * | . - * | . - * | . - * | . - * node10 node11 - * - * - * - * 2) Faces: - * two triangles, - * UV Coordinates (hier example for single quad) - * - * (0,1) (0,1) (1,1) - * 1 |\ 3 \-----| 2 - * | \ \ | - * | \ \ | - * | \ \ | - * | \ \ | - * 2 |-----\ 3 \| 1 - * (0,0) (1,0) (1,0) - * - * - * - * - * - * - */ - -#define IDX(_x_,_y_) ((_y_)*rx+(_x_)) - /* Create nodes */ - if((resx<2)||(resy<2)) return(0); - const int rx=resx; - const int ry=resy; - const int tot=rx*ry; - btVector3* x=new btVector3[tot]; - btScalar* m=new btScalar[tot]; - - int iy; - - for(iy=0;iysetMass(IDX(0,0),0); - if(fixeds&2) psb->setMass(IDX(rx-1,0),0); - if(fixeds&4) psb->setMass(IDX(0,ry-1),0); - if(fixeds&8) psb->setMass(IDX(rx-1,ry-1),0); - if(fixeds&16) psb->setMass(IDX((rx-1)/2,0),0); - if(fixeds&32) psb->setMass(IDX(0,(ry-1)/2),0); - if(fixeds&64) psb->setMass(IDX(rx-1,(ry-1)/2),0); - if(fixeds&128) psb->setMass(IDX((rx-1)/2,ry-1),0); - if(fixeds&256) psb->setMass(IDX((rx-1)/2,(ry-1)/2),0); - delete[] x; - delete[] m; - - - int z = 0; - /* Create links and faces */ - for(iy=0;iyappendLink(node00,node01); - if(mdy) psb->appendLink(node00,node10); - if(mdx&&mdy) - { - psb->appendFace(node00,node10,node11); - if (tex_coords) { - tex_coords[z+0]=CalculateUV(resx,resy,ix,iy,0); - tex_coords[z+1]=CalculateUV(resx,resy,ix,iy,1); - tex_coords[z+2]=CalculateUV(resx,resy,ix,iy,0); - tex_coords[z+3]=CalculateUV(resx,resy,ix,iy,2); - tex_coords[z+4]=CalculateUV(resx,resy,ix,iy,3); - tex_coords[z+5]=CalculateUV(resx,resy,ix,iy,2); - } - psb->appendFace(node11,node01,node00); - if (tex_coords) { - tex_coords[z+6 ]=CalculateUV(resx,resy,ix,iy,3); - tex_coords[z+7 ]=CalculateUV(resx,resy,ix,iy,2); - tex_coords[z+8 ]=CalculateUV(resx,resy,ix,iy,3); - tex_coords[z+9 ]=CalculateUV(resx,resy,ix,iy,1); - tex_coords[z+10]=CalculateUV(resx,resy,ix,iy,0); - tex_coords[z+11]=CalculateUV(resx,resy,ix,iy,1); - } - if (gendiags) psb->appendLink(node00,node11); - z += 12; - } - } - } - /* Finished */ -#undef IDX - return(psb); -} - -float btSoftBodyHelpers::CalculateUV(int resx,int resy,int ix,int iy,int id) -{ - - /* - * - * - * node00 --- node01 - * | | - * node10 --- node11 - * - * - * ID map: - * - * node00 s --> 0 - * node00 t --> 1 - * - * node01 s --> 3 - * node01 t --> 1 - * - * node10 s --> 0 - * node10 t --> 2 - * - * node11 s --> 3 - * node11 t --> 2 - * - * - */ - - float tc=0.0f; - if (id == 0) { - tc = (1.0f/((resx-1))*ix); - } - else if (id==1) { - tc = (1.0f/((resy-1))*(resy-1-iy)); - } - else if (id==2) { - tc = (1.0f/((resy-1))*(resy-1-iy-1)); - } - else if (id==3) { - tc = (1.0f/((resx-1))*(ix+1)); - } - return tc; -} -// -btSoftBody* btSoftBodyHelpers::CreateEllipsoid(btSoftBodyWorldInfo& worldInfo,const btVector3& center, - const btVector3& radius, - int res) -{ - struct Hammersley - { - static void Generate(btVector3* x,int n) - { - for(int i=0;i>=1) if(j&1) t+=p; - btScalar w=2*t-1; - btScalar a=(SIMD_PI+2*i*SIMD_PI)/n; - btScalar s=btSqrt(1-w*w); - *x++=btVector3(s*btCos(a),s*btSin(a),w); - } - } - }; - btAlignedObjectArray vtx; - vtx.resize(3+res); - Hammersley::Generate(&vtx[0],vtx.size()); - for(int i=0;i chks; - btAlignedObjectArray vtx; - chks.resize(maxidx*maxidx,false); - vtx.resize(maxidx); - for(i=0,j=0,ni=maxidx*3;iappendLink(idx[j],idx[k]); - } - } -#undef IDX - psb->appendFace(idx[0],idx[1],idx[2]); - } - psb->randomizeConstraints(); - return(psb); -} - -// -btSoftBody* btSoftBodyHelpers::CreateFromConvexHull(btSoftBodyWorldInfo& worldInfo, const btVector3* vertices, - int nvertices) -{ - HullDesc hdsc(QF_TRIANGLES,nvertices,vertices); - HullResult hres; - HullLibrary hlib;/*??*/ - hdsc.mMaxVertices=nvertices; - hlib.CreateConvexHull(hdsc,hres); - btSoftBody* psb=new btSoftBody(&worldInfo,(int)hres.mNumOutputVertices, - &hres.m_OutputVertices[0],0); - for(int i=0;i<(int)hres.mNumFaces;++i) - { - const int idx[]={ hres.m_Indices[i*3+0], - hres.m_Indices[i*3+1], - hres.m_Indices[i*3+2]}; - if(idx[0]appendLink( idx[0],idx[1]); - if(idx[1]appendLink( idx[1],idx[2]); - if(idx[2]appendLink( idx[2],idx[0]); - psb->appendFace(idx[0],idx[1],idx[2]); - } - hlib.ReleaseResult(hres); - psb->randomizeConstraints(); - return(psb); -} - - - - -static int nextLine(const char* buffer) -{ - int numBytesRead=0; - - while (*buffer != '\n') - { - buffer++; - numBytesRead++; - } - - - if (buffer[0]==0x0a) - { - buffer++; - numBytesRead++; - } - return numBytesRead; -} - -/* Create from TetGen .ele, .face, .node data */ -btSoftBody* btSoftBodyHelpers::CreateFromTetGenData(btSoftBodyWorldInfo& worldInfo, - const char* ele, - const char* face, - const char* node, - bool bfacelinks, - bool btetralinks, - bool bfacesfromtetras) -{ -btAlignedObjectArray pos; -int nnode=0; -int ndims=0; -int nattrb=0; -int hasbounds=0; -int result = sscanf(node,"%d %d %d %d",&nnode,&ndims,&nattrb,&hasbounds); -result = sscanf(node,"%d %d %d %d",&nnode,&ndims,&nattrb,&hasbounds); -node += nextLine(node); - -pos.resize(nnode); -for(int i=0;i>index; -// sn>>x;sn>>y;sn>>z; - node += nextLine(node); - - //for(int j=0;j>a; - - //if(hasbounds) - // sn>>bound; - - pos[index].setX(btScalar(x)); - pos[index].setY(btScalar(y)); - pos[index].setZ(btScalar(z)); - } -btSoftBody* psb=new btSoftBody(&worldInfo,nnode,&pos[0],0); -#if 0 -if(face&&face[0]) - { - int nface=0; - sf>>nface;sf>>hasbounds; - for(int i=0;i>index; - sf>>ni[0];sf>>ni[1];sf>>ni[2]; - sf>>bound; - psb->appendFace(ni[0],ni[1],ni[2]); - if(btetralinks) - { - psb->appendLink(ni[0],ni[1],0,true); - psb->appendLink(ni[1],ni[2],0,true); - psb->appendLink(ni[2],ni[0],0,true); - } - } - } -#endif - -if(ele&&ele[0]) - { - int ntetra=0; - int ncorner=0; - int neattrb=0; - sscanf(ele,"%d %d %d",&ntetra,&ncorner,&neattrb); - ele += nextLine(ele); - - //se>>ntetra;se>>ncorner;se>>neattrb; - for(int i=0;i>index; - //se>>ni[0];se>>ni[1];se>>ni[2];se>>ni[3]; - sscanf(ele,"%d %d %d %d %d",&index,&ni[0],&ni[1],&ni[2],&ni[3]); - ele+=nextLine(ele); - //for(int j=0;j>a; - psb->appendTetra(ni[0],ni[1],ni[2],ni[3]); - if(btetralinks) - { - psb->appendLink(ni[0],ni[1],0,true); - psb->appendLink(ni[1],ni[2],0,true); - psb->appendLink(ni[2],ni[0],0,true); - psb->appendLink(ni[0],ni[3],0,true); - psb->appendLink(ni[1],ni[3],0,true); - psb->appendLink(ni[2],ni[3],0,true); - } - } - } -printf("Nodes: %u\r\n",psb->m_nodes.size()); -printf("Links: %u\r\n",psb->m_links.size()); -printf("Faces: %u\r\n",psb->m_faces.size()); -printf("Tetras: %u\r\n",psb->m_tetras.size()); -return(psb); -} - diff --git a/bullet/src/BulletSoftBody/btSoftBodyHelpers.h b/bullet/src/BulletSoftBody/btSoftBodyHelpers.h deleted file mode 100644 index 119d71c29..000000000 --- a/bullet/src/BulletSoftBody/btSoftBodyHelpers.h +++ /dev/null @@ -1,141 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2008 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef SOFT_BODY_HELPERS_H -#define SOFT_BODY_HELPERS_H - -#include "btSoftBody.h" - -// -// Helpers -// - -/* fDrawFlags */ -struct fDrawFlags { enum _ { - Nodes = 0x0001, - Links = 0x0002, - Faces = 0x0004, - Tetras = 0x0008, - Normals = 0x0010, - Contacts = 0x0020, - Anchors = 0x0040, - Notes = 0x0080, - Clusters = 0x0100, - NodeTree = 0x0200, - FaceTree = 0x0400, - ClusterTree = 0x0800, - Joints = 0x1000, - /* presets */ - Std = Links+Faces+Tetras+Anchors+Notes+Joints, - StdTetra = Std-Faces+Tetras -};}; - -struct btSoftBodyHelpers -{ - /* Draw body */ - static void Draw( btSoftBody* psb, - btIDebugDraw* idraw, - int drawflags=fDrawFlags::Std); - /* Draw body infos */ - static void DrawInfos( btSoftBody* psb, - btIDebugDraw* idraw, - bool masses, - bool areas, - bool stress); - /* Draw node tree */ - static void DrawNodeTree( btSoftBody* psb, - btIDebugDraw* idraw, - int mindepth=0, - int maxdepth=-1); - /* Draw face tree */ - static void DrawFaceTree( btSoftBody* psb, - btIDebugDraw* idraw, - int mindepth=0, - int maxdepth=-1); - /* Draw cluster tree */ - static void DrawClusterTree(btSoftBody* psb, - btIDebugDraw* idraw, - int mindepth=0, - int maxdepth=-1); - /* Draw rigid frame */ - static void DrawFrame( btSoftBody* psb, - btIDebugDraw* idraw); - /* Create a rope */ - static btSoftBody* CreateRope( btSoftBodyWorldInfo& worldInfo, - const btVector3& from, - const btVector3& to, - int res, - int fixeds); - /* Create a patch */ - static btSoftBody* CreatePatch(btSoftBodyWorldInfo& worldInfo, - const btVector3& corner00, - const btVector3& corner10, - const btVector3& corner01, - const btVector3& corner11, - int resx, - int resy, - int fixeds, - bool gendiags); - /* Create a patch with UV Texture Coordinates */ - static btSoftBody* CreatePatchUV(btSoftBodyWorldInfo& worldInfo, - const btVector3& corner00, - const btVector3& corner10, - const btVector3& corner01, - const btVector3& corner11, - int resx, - int resy, - int fixeds, - bool gendiags, - float* tex_coords=0); - static float CalculateUV(int resx,int resy,int ix,int iy,int id); - /* Create an ellipsoid */ - static btSoftBody* CreateEllipsoid(btSoftBodyWorldInfo& worldInfo, - const btVector3& center, - const btVector3& radius, - int res); - /* Create from trimesh */ - static btSoftBody* CreateFromTriMesh( btSoftBodyWorldInfo& worldInfo, - const btScalar* vertices, - const int* triangles, - int ntriangles); - /* Create from convex-hull */ - static btSoftBody* CreateFromConvexHull( btSoftBodyWorldInfo& worldInfo, - const btVector3* vertices, - int nvertices); - - - /* Export TetGen compatible .smesh file */ - static void ExportAsSMeshFile( btSoftBody* psb, - const char* filename); - /* Create from TetGen .ele, .face, .node files */ - static btSoftBody* CreateFromTetGenFile( btSoftBodyWorldInfo& worldInfo, - const char* ele, - const char* face, - const char* node, - bool bfacelinks, - bool btetralinks, - bool bfacesfromtetras); - /* Create from TetGen .ele, .face, .node data */ - static btSoftBody* CreateFromTetGenData( btSoftBodyWorldInfo& worldInfo, - const char* ele, - const char* face, - const char* node, - bool bfacelinks, - bool btetralinks, - bool bfacesfromtetras); - -}; - -#endif //SOFT_BODY_HELPERS_H diff --git a/bullet/src/BulletSoftBody/btSoftBodyInternals.h b/bullet/src/BulletSoftBody/btSoftBodyInternals.h deleted file mode 100644 index 627310588..000000000 --- a/bullet/src/BulletSoftBody/btSoftBodyInternals.h +++ /dev/null @@ -1,931 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ -///btSoftBody implementation by Nathanael Presson - -#ifndef _BT_SOFT_BODY_INTERNALS_H -#define _BT_SOFT_BODY_INTERNALS_H - -#include "btSoftBody.h" - - -#include "LinearMath/btQuickprof.h" -#include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h" -#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h" -#include "BulletCollision/CollisionShapes/btConvexInternalShape.h" -#include "BulletCollision/NarrowPhaseCollision/btGjkEpa2.h" - -// -// btSymMatrix -// -template -struct btSymMatrix -{ - btSymMatrix() : dim(0) {} - btSymMatrix(int n,const T& init=T()) { resize(n,init); } - void resize(int n,const T& init=T()) { dim=n;store.resize((n*(n+1))/2,init); } - int index(int c,int r) const { if(c>r) btSwap(c,r);btAssert(r store; - int dim; -}; - -// -// btSoftBodyCollisionShape -// -class btSoftBodyCollisionShape : public btConcaveShape -{ -public: - btSoftBody* m_body; - - btSoftBodyCollisionShape(btSoftBody* backptr) - { - m_shapeType = SOFTBODY_SHAPE_PROXYTYPE; - m_body=backptr; - } - - virtual ~btSoftBodyCollisionShape() - { - - } - - void processAllTriangles(btTriangleCallback* /*callback*/,const btVector3& /*aabbMin*/,const btVector3& /*aabbMax*/) const - { - //not yet - btAssert(0); - } - - ///getAabb returns the axis aligned bounding box in the coordinate frame of the given transform t. - virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const - { - /* t should be identity, but better be safe than...fast? */ - const btVector3 mins=m_body->m_bounds[0]; - const btVector3 maxs=m_body->m_bounds[1]; - const btVector3 crns[]={t*btVector3(mins.x(),mins.y(),mins.z()), - t*btVector3(maxs.x(),mins.y(),mins.z()), - t*btVector3(maxs.x(),maxs.y(),mins.z()), - t*btVector3(mins.x(),maxs.y(),mins.z()), - t*btVector3(mins.x(),mins.y(),maxs.z()), - t*btVector3(maxs.x(),mins.y(),maxs.z()), - t*btVector3(maxs.x(),maxs.y(),maxs.z()), - t*btVector3(mins.x(),maxs.y(),maxs.z())}; - aabbMin=aabbMax=crns[0]; - for(int i=1;i<8;++i) - { - aabbMin.setMin(crns[i]); - aabbMax.setMax(crns[i]); - } - } - - - virtual void setLocalScaling(const btVector3& /*scaling*/) - { - ///na - } - virtual const btVector3& getLocalScaling() const - { - static const btVector3 dummy(1,1,1); - return dummy; - } - virtual void calculateLocalInertia(btScalar /*mass*/,btVector3& /*inertia*/) const - { - ///not yet - btAssert(0); - } - virtual const char* getName()const - { - return "SoftBody"; - } - -}; - -// -// btSoftClusterCollisionShape -// -class btSoftClusterCollisionShape : public btConvexInternalShape -{ -public: - const btSoftBody::Cluster* m_cluster; - - btSoftClusterCollisionShape (const btSoftBody::Cluster* cluster) : m_cluster(cluster) { setMargin(0); } - - - virtual btVector3 localGetSupportingVertex(const btVector3& vec) const - { - btSoftBody::Node* const * n=&m_cluster->m_nodes[0]; - btScalar d=btDot(vec,n[0]->m_x); - int j=0; - for(int i=1,ni=m_cluster->m_nodes.size();im_x); - if(k>d) { d=k;j=i; } - } - return(n[j]->m_x); - } - virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const - { - return(localGetSupportingVertex(vec)); - } - //notice that the vectors should be unit length - virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const - {} - - - virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const - {} - - virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const - {} - - virtual int getShapeType() const { return SOFTBODY_SHAPE_PROXYTYPE; } - - //debugging - virtual const char* getName()const {return "SOFTCLUSTER";} - - virtual void setMargin(btScalar margin) - { - btConvexInternalShape::setMargin(margin); - } - virtual btScalar getMargin() const - { - return getMargin(); - } -}; - -// -// Inline's -// - -// -template -static inline void ZeroInitialize(T& value) -{ - static const T zerodummy; - value=zerodummy; -} -// -template -static inline bool CompLess(const T& a,const T& b) -{ return(a -static inline bool CompGreater(const T& a,const T& b) -{ return(a>b); } -// -template -static inline T Lerp(const T& a,const T& b,btScalar t) -{ return(a+(b-a)*t); } -// -template -static inline T InvLerp(const T& a,const T& b,btScalar t) -{ return((b+a*t-b*t)/(a*b)); } -// -static inline btMatrix3x3 Lerp( const btMatrix3x3& a, - const btMatrix3x3& b, - btScalar t) -{ - btMatrix3x3 r; - r[0]=Lerp(a[0],b[0],t); - r[1]=Lerp(a[1],b[1],t); - r[2]=Lerp(a[2],b[2],t); - return(r); -} -// -static inline btVector3 Clamp(const btVector3& v,btScalar maxlength) -{ - const btScalar sql=v.length2(); - if(sql>(maxlength*maxlength)) - return((v*maxlength)/btSqrt(sql)); - else - return(v); -} -// -template -static inline T Clamp(const T& x,const T& l,const T& h) -{ return(xh?h:x); } -// -template -static inline T Sq(const T& x) -{ return(x*x); } -// -template -static inline T Cube(const T& x) -{ return(x*x*x); } -// -template -static inline T Sign(const T& x) -{ return((T)(x<0?-1:+1)); } -// -template -static inline bool SameSign(const T& x,const T& y) -{ return((x*y)>0); } -// -static inline btScalar ClusterMetric(const btVector3& x,const btVector3& y) -{ - const btVector3 d=x-y; - return(btFabs(d[0])+btFabs(d[1])+btFabs(d[2])); -} -// -static inline btMatrix3x3 ScaleAlongAxis(const btVector3& a,btScalar s) -{ - const btScalar xx=a.x()*a.x(); - const btScalar yy=a.y()*a.y(); - const btScalar zz=a.z()*a.z(); - const btScalar xy=a.x()*a.y(); - const btScalar yz=a.y()*a.z(); - const btScalar zx=a.z()*a.x(); - btMatrix3x3 m; - m[0]=btVector3(1-xx+xx*s,xy*s-xy,zx*s-zx); - m[1]=btVector3(xy*s-xy,1-yy+yy*s,yz*s-yz); - m[2]=btVector3(zx*s-zx,yz*s-yz,1-zz+zz*s); - return(m); -} -// -static inline btMatrix3x3 Cross(const btVector3& v) -{ - btMatrix3x3 m; - m[0]=btVector3(0,-v.z(),+v.y()); - m[1]=btVector3(+v.z(),0,-v.x()); - m[2]=btVector3(-v.y(),+v.x(),0); - return(m); -} -// -static inline btMatrix3x3 Diagonal(btScalar x) -{ - btMatrix3x3 m; - m[0]=btVector3(x,0,0); - m[1]=btVector3(0,x,0); - m[2]=btVector3(0,0,x); - return(m); -} -// -static inline btMatrix3x3 Add(const btMatrix3x3& a, - const btMatrix3x3& b) -{ - btMatrix3x3 r; - for(int i=0;i<3;++i) r[i]=a[i]+b[i]; - return(r); -} -// -static inline btMatrix3x3 Sub(const btMatrix3x3& a, - const btMatrix3x3& b) -{ - btMatrix3x3 r; - for(int i=0;i<3;++i) r[i]=a[i]-b[i]; - return(r); -} -// -static inline btMatrix3x3 Mul(const btMatrix3x3& a, - btScalar b) -{ - btMatrix3x3 r; - for(int i=0;i<3;++i) r[i]=a[i]*b; - return(r); -} -// -static inline void Orthogonalize(btMatrix3x3& m) -{ - m[2]=btCross(m[0],m[1]).normalized(); - m[1]=btCross(m[2],m[0]).normalized(); - m[0]=btCross(m[1],m[2]).normalized(); -} -// -static inline btMatrix3x3 MassMatrix(btScalar im,const btMatrix3x3& iwi,const btVector3& r) -{ - const btMatrix3x3 cr=Cross(r); - return(Sub(Diagonal(im),cr*iwi*cr)); -} - -// -static inline btMatrix3x3 ImpulseMatrix( btScalar dt, - btScalar ima, - btScalar imb, - const btMatrix3x3& iwi, - const btVector3& r) -{ - return(Diagonal(1/dt)*Add(Diagonal(ima),MassMatrix(imb,iwi,r)).inverse()); -} - -// -static inline btMatrix3x3 ImpulseMatrix( btScalar ima,const btMatrix3x3& iia,const btVector3& ra, - btScalar imb,const btMatrix3x3& iib,const btVector3& rb) -{ - return(Add(MassMatrix(ima,iia,ra),MassMatrix(imb,iib,rb)).inverse()); -} - -// -static inline btMatrix3x3 AngularImpulseMatrix( const btMatrix3x3& iia, - const btMatrix3x3& iib) -{ - return(Add(iia,iib).inverse()); -} - -// -static inline btVector3 ProjectOnAxis( const btVector3& v, - const btVector3& a) -{ - return(a*btDot(v,a)); -} -// -static inline btVector3 ProjectOnPlane( const btVector3& v, - const btVector3& a) -{ - return(v-ProjectOnAxis(v,a)); -} - -// -static inline void ProjectOrigin( const btVector3& a, - const btVector3& b, - btVector3& prj, - btScalar& sqd) -{ - const btVector3 d=b-a; - const btScalar m2=d.length2(); - if(m2>SIMD_EPSILON) - { - const btScalar t=Clamp(-btDot(a,d)/m2,0,1); - const btVector3 p=a+d*t; - const btScalar l2=p.length2(); - if(l2SIMD_EPSILON) - { - const btVector3 n=q/btSqrt(m2); - const btScalar k=btDot(a,n); - const btScalar k2=k*k; - if(k20)&& - (btDot(btCross(b-p,c-p),q)>0)&& - (btDot(btCross(c-p,a-p),q)>0)) - { - prj=p; - sqd=k2; - } - else - { - ProjectOrigin(a,b,prj,sqd); - ProjectOrigin(b,c,prj,sqd); - ProjectOrigin(c,a,prj,sqd); - } - } - } -} - -// -template -static inline T BaryEval( const T& a, - const T& b, - const T& c, - const btVector3& coord) -{ - return(a*coord.x()+b*coord.y()+c*coord.z()); -} -// -static inline btVector3 BaryCoord( const btVector3& a, - const btVector3& b, - const btVector3& c, - const btVector3& p) -{ - const btScalar w[]={ btCross(a-p,b-p).length(), - btCross(b-p,c-p).length(), - btCross(c-p,a-p).length()}; - const btScalar isum=1/(w[0]+w[1]+w[2]); - return(btVector3(w[1]*isum,w[2]*isum,w[0]*isum)); -} - -// -static btScalar ImplicitSolve( btSoftBody::ImplicitFn* fn, - const btVector3& a, - const btVector3& b, - const btScalar accuracy, - const int maxiterations=256) -{ - btScalar span[2]={0,1}; - btScalar values[2]={fn->Eval(a),fn->Eval(b)}; - if(values[0]>values[1]) - { - btSwap(span[0],span[1]); - btSwap(values[0],values[1]); - } - if(values[0]>-accuracy) return(-1); - if(values[1]<+accuracy) return(-1); - for(int i=0;iEval(Lerp(a,b,t)); - if((t<=0)||(t>=1)) break; - if(btFabs(v)SIMD_EPSILON) - return(v/l); - else - return(btVector3(0,0,0)); -} - -// -static inline btDbvtVolume VolumeOf( const btSoftBody::Face& f, - btScalar margin) -{ - const btVector3* pts[]={ &f.m_n[0]->m_x, - &f.m_n[1]->m_x, - &f.m_n[2]->m_x}; - btDbvtVolume vol=btDbvtVolume::FromPoints(pts,3); - vol.Expand(btVector3(margin,margin,margin)); - return(vol); -} - -// -static inline btVector3 CenterOf( const btSoftBody::Face& f) -{ - return((f.m_n[0]->m_x+f.m_n[1]->m_x+f.m_n[2]->m_x)/3); -} - -// -static inline btScalar AreaOf( const btVector3& x0, - const btVector3& x1, - const btVector3& x2) -{ - const btVector3 a=x1-x0; - const btVector3 b=x2-x0; - const btVector3 cr=btCross(a,b); - const btScalar area=cr.length(); - return(area); -} - -// -static inline btScalar VolumeOf( const btVector3& x0, - const btVector3& x1, - const btVector3& x2, - const btVector3& x3) -{ - const btVector3 a=x1-x0; - const btVector3 b=x2-x0; - const btVector3 c=x3-x0; - return(btDot(a,btCross(b,c))); -} - -// -static void EvaluateMedium( const btSoftBodyWorldInfo* wfi, - const btVector3& x, - btSoftBody::sMedium& medium) -{ - medium.m_velocity = btVector3(0,0,0); - medium.m_pressure = 0; - medium.m_density = wfi->air_density; - if(wfi->water_density>0) - { - const btScalar depth=-(btDot(x,wfi->water_normal)+wfi->water_offset); - if(depth>0) - { - medium.m_density = wfi->water_density; - medium.m_pressure = depth*wfi->water_density*wfi->m_gravity.length(); - } - } -} - -// -static inline void ApplyClampedForce( btSoftBody::Node& n, - const btVector3& f, - btScalar dt) -{ - const btScalar dtim=dt*n.m_im; - if((f*dtim).length2()>n.m_v.length2()) - {/* Clamp */ - n.m_f-=ProjectOnAxis(n.m_v,f.normalized())/dtim; - } - else - {/* Apply */ - n.m_f+=f; - } -} - -// -static inline int MatchEdge( const btSoftBody::Node* a, - const btSoftBody::Node* b, - const btSoftBody::Node* ma, - const btSoftBody::Node* mb) -{ - if((a==ma)&&(b==mb)) return(0); - if((a==mb)&&(b==ma)) return(1); - return(-1); -} - -// -// btEigen : Extract eigen system, -// straitforward implementation of http://math.fullerton.edu/mathews/n2003/JacobiMethodMod.html -// outputs are NOT sorted. -// -struct btEigen -{ - static int system(btMatrix3x3& a,btMatrix3x3* vectors,btVector3* values=0) - { - static const int maxiterations=16; - static const btScalar accuracy=(btScalar)0.0001; - btMatrix3x3& v=*vectors; - int iterations=0; - vectors->setIdentity(); - do { - int p=0,q=1; - if(btFabs(a[p][q])accuracy) - { - const btScalar w=(a[q][q]-a[p][p])/(2*a[p][q]); - const btScalar z=btFabs(w); - const btScalar t=w/(z*(btSqrt(1+w*w)+z)); - if(t==t)/* [WARNING] let hope that one does not get thrown aways by some compilers... */ - { - const btScalar c=1/btSqrt(t*t+1); - const btScalar s=c*t; - mulPQ(a,c,s,p,q); - mulTPQ(a,c,s,p,q); - mulPQ(v,c,s,p,q); - } else break; - } else break; - } while((++iterations)accuracy) det=ndet; else break; - } - /* Final orthogonalization */ - Orthogonalize(q); - /* Compute 'S' */ - s=q.transpose()*m; - } - else - { - q.setIdentity(); - s.setIdentity(); - } - return(i); -} - -// -// btSoftColliders -// -struct btSoftColliders -{ - // - // ClusterBase - // - struct ClusterBase : btDbvt::ICollide - { - btScalar erp; - btScalar idt; - btScalar m_margin; - btScalar friction; - btScalar threshold; - ClusterBase() - { - erp =(btScalar)1; - idt =0; - m_margin =0; - friction =0; - threshold =(btScalar)0; - } - bool SolveContact( const btGjkEpaSolver2::sResults& res, - btSoftBody::Body ba,btSoftBody::Body bb, - btSoftBody::CJoint& joint) - { - if(res.distancedata; - btSoftClusterCollisionShape cshape(cluster); - - const btConvexShape* rshape=(const btConvexShape*)m_colObj->getCollisionShape(); - - ///don't collide an anchored cluster with a static/kinematic object - if(m_colObj->isStaticOrKinematicObject() && cluster->m_containsAnchor) - return; - - btGjkEpaSolver2::sResults res; - if(btGjkEpaSolver2::SignedDistance( &cshape,btTransform::getIdentity(), - rshape,m_colObj->getInterpolationWorldTransform(), - btVector3(1,0,0),res)) - { - btSoftBody::CJoint joint; - if(SolveContact(res,cluster,m_colObj,joint))//prb,joint)) - { - btSoftBody::CJoint* pj=new(btAlignedAlloc(sizeof(btSoftBody::CJoint),16)) btSoftBody::CJoint(); - *pj=joint;psb->m_joints.push_back(pj); - if(m_colObj->isStaticOrKinematicObject()) - { - pj->m_erp *= psb->m_cfg.kSKHR_CL; - pj->m_split *= psb->m_cfg.kSK_SPLT_CL; - } - else - { - pj->m_erp *= psb->m_cfg.kSRHR_CL; - pj->m_split *= psb->m_cfg.kSR_SPLT_CL; - } - } - } - } - void Process(btSoftBody* ps,btCollisionObject* colOb) - { - psb = ps; - m_colObj = colOb; - idt = ps->m_sst.isdt; - m_margin = m_colObj->getCollisionShape()->getMargin()+psb->getCollisionShape()->getMargin(); - ///Bullet rigid body uses multiply instead of minimum to determine combined friction. Some customization would be useful. - friction = btMin(psb->m_cfg.kDF,m_colObj->getFriction()); - btVector3 mins; - btVector3 maxs; - - ATTRIBUTE_ALIGNED16(btDbvtVolume) volume; - colOb->getCollisionShape()->getAabb(colOb->getInterpolationWorldTransform(),mins,maxs); - volume=btDbvtVolume::FromMM(mins,maxs); - volume.Expand(btVector3(1,1,1)*m_margin); - ps->m_cdbvt.collideTV(ps->m_cdbvt.m_root,volume,*this); - } - }; - // - // CollideCL_SS - // - struct CollideCL_SS : ClusterBase - { - btSoftBody* bodies[2]; - void Process(const btDbvtNode* la,const btDbvtNode* lb) - { - btSoftBody::Cluster* cla=(btSoftBody::Cluster*)la->data; - btSoftBody::Cluster* clb=(btSoftBody::Cluster*)lb->data; - - - bool connected=false; - if ((bodies[0]==bodies[1])&&(bodies[0]->m_clusterConnectivity.size())) - { - connected = bodies[0]->m_clusterConnectivity[cla->m_clusterIndex+bodies[0]->m_clusters.size()*clb->m_clusterIndex]; - } - - if (!connected) - { - btSoftClusterCollisionShape csa(cla); - btSoftClusterCollisionShape csb(clb); - btGjkEpaSolver2::sResults res; - if(btGjkEpaSolver2::SignedDistance( &csa,btTransform::getIdentity(), - &csb,btTransform::getIdentity(), - cla->m_com-clb->m_com,res)) - { - btSoftBody::CJoint joint; - if(SolveContact(res,cla,clb,joint)) - { - btSoftBody::CJoint* pj=new(btAlignedAlloc(sizeof(btSoftBody::CJoint),16)) btSoftBody::CJoint(); - *pj=joint;bodies[0]->m_joints.push_back(pj); - pj->m_erp *= btMax(bodies[0]->m_cfg.kSSHR_CL,bodies[1]->m_cfg.kSSHR_CL); - pj->m_split *= (bodies[0]->m_cfg.kSS_SPLT_CL+bodies[1]->m_cfg.kSS_SPLT_CL)/2; - } - } - } else - { - static int count=0; - count++; - //printf("count=%d\n",count); - - } - } - void Process(btSoftBody* psa,btSoftBody* psb) - { - idt = psa->m_sst.isdt; - //m_margin = (psa->getCollisionShape()->getMargin()+psb->getCollisionShape()->getMargin())/2; - m_margin = (psa->getCollisionShape()->getMargin()+psb->getCollisionShape()->getMargin()); - friction = btMin(psa->m_cfg.kDF,psb->m_cfg.kDF); - bodies[0] = psa; - bodies[1] = psb; - psa->m_cdbvt.collideTT(psa->m_cdbvt.m_root,psb->m_cdbvt.m_root,*this); - } - }; - // - // CollideSDF_RS - // - struct CollideSDF_RS : btDbvt::ICollide - { - void Process(const btDbvtNode* leaf) - { - btSoftBody::Node* node=(btSoftBody::Node*)leaf->data; - DoNode(*node); - } - void DoNode(btSoftBody::Node& n) const - { - const btScalar m=n.m_im>0?dynmargin:stamargin; - btSoftBody::RContact c; - if( (!n.m_battach)&& - psb->checkContact(m_colObj1,n.m_x,m,c.m_cti)) - { - const btScalar ima=n.m_im; - const btScalar imb= m_rigidBody? m_rigidBody->getInvMass() : 0.f; - const btScalar ms=ima+imb; - if(ms>0) - { - const btTransform& wtr=m_rigidBody?m_rigidBody->getInterpolationWorldTransform() : m_colObj1->getWorldTransform(); - static const btMatrix3x3 iwiStatic(0,0,0,0,0,0,0,0,0); - const btMatrix3x3& iwi=m_rigidBody?m_rigidBody->getInvInertiaTensorWorld() : iwiStatic; - const btVector3 ra=n.m_x-wtr.getOrigin(); - const btVector3 va=m_rigidBody ? m_rigidBody->getVelocityInLocalPoint(ra)*psb->m_sst.sdt : btVector3(0,0,0); - const btVector3 vb=n.m_x-n.m_q; - const btVector3 vr=vb-va; - const btScalar dn=btDot(vr,c.m_cti.m_normal); - const btVector3 fv=vr-c.m_cti.m_normal*dn; - const btScalar fc=psb->m_cfg.kDF*m_colObj1->getFriction(); - c.m_node = &n; - c.m_c0 = ImpulseMatrix(psb->m_sst.sdt,ima,imb,iwi,ra); - c.m_c1 = ra; - c.m_c2 = ima*psb->m_sst.sdt; - c.m_c3 = fv.length2()<(btFabs(dn)*fc)?0:1-fc; - c.m_c4 = m_colObj1->isStaticOrKinematicObject()?psb->m_cfg.kKHR:psb->m_cfg.kCHR; - psb->m_rcontacts.push_back(c); - if (m_rigidBody) - m_rigidBody->activate(); - } - } - } - btSoftBody* psb; - btCollisionObject* m_colObj1; - btRigidBody* m_rigidBody; - btScalar dynmargin; - btScalar stamargin; - }; - // - // CollideVF_SS - // - struct CollideVF_SS : btDbvt::ICollide - { - void Process(const btDbvtNode* lnode, - const btDbvtNode* lface) - { - btSoftBody::Node* node=(btSoftBody::Node*)lnode->data; - btSoftBody::Face* face=(btSoftBody::Face*)lface->data; - btVector3 o=node->m_x; - btVector3 p; - btScalar d=SIMD_INFINITY; - ProjectOrigin( face->m_n[0]->m_x-o, - face->m_n[1]->m_x-o, - face->m_n[2]->m_x-o, - p,d); - const btScalar m=mrg+(o-node->m_q).length()*2; - if(d<(m*m)) - { - const btSoftBody::Node* n[]={face->m_n[0],face->m_n[1],face->m_n[2]}; - const btVector3 w=BaryCoord(n[0]->m_x,n[1]->m_x,n[2]->m_x,p+o); - const btScalar ma=node->m_im; - btScalar mb=BaryEval(n[0]->m_im,n[1]->m_im,n[2]->m_im,w); - if( (n[0]->m_im<=0)|| - (n[1]->m_im<=0)|| - (n[2]->m_im<=0)) - { - mb=0; - } - const btScalar ms=ma+mb; - if(ms>0) - { - btSoftBody::SContact c; - c.m_normal = p/-btSqrt(d); - c.m_margin = m; - c.m_node = node; - c.m_face = face; - c.m_weights = w; - c.m_friction = btMax(psb[0]->m_cfg.kDF,psb[1]->m_cfg.kDF); - c.m_cfm[0] = ma/ms*psb[0]->m_cfg.kSHR; - c.m_cfm[1] = mb/ms*psb[1]->m_cfg.kSHR; - psb[0]->m_scontacts.push_back(c); - } - } - } - btSoftBody* psb[2]; - btScalar mrg; - }; -}; - -#endif //_BT_SOFT_BODY_INTERNALS_H diff --git a/bullet/src/BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.cpp b/bullet/src/BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.cpp deleted file mode 100644 index eec75bfd3..000000000 --- a/bullet/src/BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btSoftBodyRigidBodyCollisionConfiguration.h" -#include "btSoftRigidCollisionAlgorithm.h" -#include "btSoftBodyConcaveCollisionAlgorithm.h" -#include "btSoftSoftCollisionAlgorithm.h" - -#include "LinearMath/btPoolAllocator.h" - -#define ENABLE_SOFTBODY_CONCAVE_COLLISIONS 1 - -btSoftBodyRigidBodyCollisionConfiguration::btSoftBodyRigidBodyCollisionConfiguration(const btDefaultCollisionConstructionInfo& constructionInfo) -:btDefaultCollisionConfiguration(constructionInfo) -{ - void* mem; - - mem = btAlignedAlloc(sizeof(btSoftSoftCollisionAlgorithm::CreateFunc),16); - m_softSoftCreateFunc = new(mem) btSoftSoftCollisionAlgorithm::CreateFunc; - - mem = btAlignedAlloc(sizeof(btSoftRigidCollisionAlgorithm::CreateFunc),16); - m_softRigidConvexCreateFunc = new(mem) btSoftRigidCollisionAlgorithm::CreateFunc; - - mem = btAlignedAlloc(sizeof(btSoftRigidCollisionAlgorithm::CreateFunc),16); - m_swappedSoftRigidConvexCreateFunc = new(mem) btSoftRigidCollisionAlgorithm::CreateFunc; - m_swappedSoftRigidConvexCreateFunc->m_swapped=true; - -#ifdef ENABLE_SOFTBODY_CONCAVE_COLLISIONS - mem = btAlignedAlloc(sizeof(btSoftBodyConcaveCollisionAlgorithm::CreateFunc),16); - m_softRigidConcaveCreateFunc = new(mem) btSoftBodyConcaveCollisionAlgorithm::CreateFunc; - - mem = btAlignedAlloc(sizeof(btSoftBodyConcaveCollisionAlgorithm::CreateFunc),16); - m_swappedSoftRigidConcaveCreateFunc = new(mem) btSoftBodyConcaveCollisionAlgorithm::SwappedCreateFunc; - m_swappedSoftRigidConcaveCreateFunc->m_swapped=true; -#endif - - //replace pool by a new one, with potential larger size - - if (m_ownsCollisionAlgorithmPool && m_collisionAlgorithmPool) - { - int curElemSize = m_collisionAlgorithmPool->getElementSize(); - ///calculate maximum element size, big enough to fit any collision algorithm in the memory pool - - - int maxSize0 = sizeof(btSoftSoftCollisionAlgorithm); - int maxSize1 = sizeof(btSoftRigidCollisionAlgorithm); - int maxSize2 = sizeof(btSoftBodyConcaveCollisionAlgorithm); - - int collisionAlgorithmMaxElementSize = btMax(maxSize0,maxSize1); - collisionAlgorithmMaxElementSize = btMax(collisionAlgorithmMaxElementSize,maxSize2); - - if (collisionAlgorithmMaxElementSize > curElemSize) - { - m_collisionAlgorithmPool->~btPoolAllocator(); - btAlignedFree(m_collisionAlgorithmPool); - void* mem = btAlignedAlloc(sizeof(btPoolAllocator),16); - m_collisionAlgorithmPool = new(mem) btPoolAllocator(collisionAlgorithmMaxElementSize,constructionInfo.m_defaultMaxCollisionAlgorithmPoolSize); - } - } - -} - -btSoftBodyRigidBodyCollisionConfiguration::~btSoftBodyRigidBodyCollisionConfiguration() -{ - m_softSoftCreateFunc->~btCollisionAlgorithmCreateFunc(); - btAlignedFree( m_softSoftCreateFunc); - - m_softRigidConvexCreateFunc->~btCollisionAlgorithmCreateFunc(); - btAlignedFree( m_softRigidConvexCreateFunc); - - m_swappedSoftRigidConvexCreateFunc->~btCollisionAlgorithmCreateFunc(); - btAlignedFree( m_swappedSoftRigidConvexCreateFunc); - -#ifdef ENABLE_SOFTBODY_CONCAVE_COLLISIONS - m_softRigidConcaveCreateFunc->~btCollisionAlgorithmCreateFunc(); - btAlignedFree( m_softRigidConcaveCreateFunc); - - m_swappedSoftRigidConcaveCreateFunc->~btCollisionAlgorithmCreateFunc(); - btAlignedFree( m_swappedSoftRigidConcaveCreateFunc); -#endif -} - -///creation of soft-soft and soft-rigid, and otherwise fallback to base class implementation -btCollisionAlgorithmCreateFunc* btSoftBodyRigidBodyCollisionConfiguration::getCollisionAlgorithmCreateFunc(int proxyType0,int proxyType1) -{ - - ///try to handle the softbody interactions first - - if ((proxyType0 == SOFTBODY_SHAPE_PROXYTYPE ) && (proxyType1==SOFTBODY_SHAPE_PROXYTYPE)) - { - return m_softSoftCreateFunc; - } - - ///softbody versus convex - if (proxyType0 == SOFTBODY_SHAPE_PROXYTYPE && btBroadphaseProxy::isConvex(proxyType1)) - { - return m_softRigidConvexCreateFunc; - } - - ///convex versus soft body - if (btBroadphaseProxy::isConvex(proxyType0) && proxyType1 == SOFTBODY_SHAPE_PROXYTYPE ) - { - return m_swappedSoftRigidConvexCreateFunc; - } - -#ifdef ENABLE_SOFTBODY_CONCAVE_COLLISIONS - ///softbody versus convex - if (proxyType0 == SOFTBODY_SHAPE_PROXYTYPE && btBroadphaseProxy::isConcave(proxyType1)) - { - return m_softRigidConcaveCreateFunc; - } - - ///convex versus soft body - if (btBroadphaseProxy::isConcave(proxyType0) && proxyType1 == SOFTBODY_SHAPE_PROXYTYPE ) - { - return m_swappedSoftRigidConcaveCreateFunc; - } -#endif - - ///fallback to the regular rigid collision shape - return btDefaultCollisionConfiguration::getCollisionAlgorithmCreateFunc(proxyType0,proxyType1); -} diff --git a/bullet/src/BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.h b/bullet/src/BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.h deleted file mode 100644 index 17a8296d5..000000000 --- a/bullet/src/BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef BT_SOFTBODY_RIGIDBODY_COLLISION_CONFIGURATION -#define BT_SOFTBODY_RIGIDBODY_COLLISION_CONFIGURATION - -#include "BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h" - -class btVoronoiSimplexSolver; -class btGjkEpaPenetrationDepthSolver; - - -///btSoftBodyRigidBodyCollisionConfiguration add softbody interaction on top of btDefaultCollisionConfiguration -class btSoftBodyRigidBodyCollisionConfiguration : public btDefaultCollisionConfiguration -{ - - //default CreationFunctions, filling the m_doubleDispatch table - btCollisionAlgorithmCreateFunc* m_softSoftCreateFunc; - btCollisionAlgorithmCreateFunc* m_softRigidConvexCreateFunc; - btCollisionAlgorithmCreateFunc* m_swappedSoftRigidConvexCreateFunc; - btCollisionAlgorithmCreateFunc* m_softRigidConcaveCreateFunc; - btCollisionAlgorithmCreateFunc* m_swappedSoftRigidConcaveCreateFunc; - -public: - - btSoftBodyRigidBodyCollisionConfiguration(const btDefaultCollisionConstructionInfo& constructionInfo = btDefaultCollisionConstructionInfo()); - - virtual ~btSoftBodyRigidBodyCollisionConfiguration(); - - ///creation of soft-soft and soft-rigid, and otherwise fallback to base class implementation - virtual btCollisionAlgorithmCreateFunc* getCollisionAlgorithmCreateFunc(int proxyType0,int proxyType1); - -}; - -#endif //BT_SOFTBODY_RIGIDBODY_COLLISION_CONFIGURATION - diff --git a/bullet/src/BulletSoftBody/btSoftRigidCollisionAlgorithm.cpp b/bullet/src/BulletSoftBody/btSoftRigidCollisionAlgorithm.cpp deleted file mode 100644 index db9d057ae..000000000 --- a/bullet/src/BulletSoftBody/btSoftRigidCollisionAlgorithm.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btSoftRigidCollisionAlgorithm.h" -#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h" -#include "BulletCollision/CollisionShapes/btSphereShape.h" -#include "BulletCollision/CollisionShapes/btBoxShape.h" -#include "BulletCollision/CollisionDispatch/btCollisionObject.h" -#include "btSoftBody.h" -///TODO: include all the shapes that the softbody can collide with -///alternatively, implement special case collision algorithms (just like for rigid collision shapes) - -//#include - -btSoftRigidCollisionAlgorithm::btSoftRigidCollisionAlgorithm(btPersistentManifold* /*mf*/,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* /*col0*/,btCollisionObject* /*col1*/, bool isSwapped) -: btCollisionAlgorithm(ci), -//m_ownManifold(false), -//m_manifoldPtr(mf), -m_isSwapped(isSwapped) -{ -} - - -btSoftRigidCollisionAlgorithm::~btSoftRigidCollisionAlgorithm() -{ - - //m_softBody->m_overlappingRigidBodies.remove(m_rigidCollisionObject); - - /*if (m_ownManifold) - { - if (m_manifoldPtr) - m_dispatcher->releaseManifold(m_manifoldPtr); - } - */ - -} - - -#include - -void btSoftRigidCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) -{ - (void)dispatchInfo; - (void)resultOut; - //printf("btSoftRigidCollisionAlgorithm\n"); - - btSoftBody* softBody = m_isSwapped? (btSoftBody*)body1 : (btSoftBody*)body0; - btCollisionObject* rigidCollisionObject = m_isSwapped? body0 : body1; - - if (softBody->m_collisionDisabledObjects.findLinearSearch(rigidCollisionObject)==softBody->m_collisionDisabledObjects.size()) - { - softBody->defaultCollisionHandler(rigidCollisionObject); - } - - -} - -btScalar btSoftRigidCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* col0,btCollisionObject* col1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) -{ - (void)resultOut; - (void)dispatchInfo; - (void)col0; - (void)col1; - - //not yet - return btScalar(1.); -} - - - diff --git a/bullet/src/BulletSoftBody/btSoftRigidCollisionAlgorithm.h b/bullet/src/BulletSoftBody/btSoftRigidCollisionAlgorithm.h deleted file mode 100644 index e89570af3..000000000 --- a/bullet/src/BulletSoftBody/btSoftRigidCollisionAlgorithm.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef SOFT_RIGID_COLLISION_ALGORITHM_H -#define SOFT_RIGID_COLLISION_ALGORITHM_H - -#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h" -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" -#include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h" -class btPersistentManifold; -#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h" - -#include "LinearMath/btVector3.h" -class btSoftBody; - -/// btSoftRigidCollisionAlgorithm provides collision detection between btSoftBody and btRigidBody -class btSoftRigidCollisionAlgorithm : public btCollisionAlgorithm -{ - // bool m_ownManifold; - // btPersistentManifold* m_manifoldPtr; - - btSoftBody* m_softBody; - btCollisionObject* m_rigidCollisionObject; - - ///for rigid versus soft (instead of soft versus rigid), we use this swapped boolean - bool m_isSwapped; - -public: - - btSoftRigidCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1, bool isSwapped); - - virtual ~btSoftRigidCollisionAlgorithm(); - - virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); - - virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); - - virtual void getAllContactManifolds(btManifoldArray& manifoldArray) - { - //we don't add any manifolds - } - - - struct CreateFunc :public btCollisionAlgorithmCreateFunc - { - virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1) - { - void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btSoftRigidCollisionAlgorithm)); - if (!m_swapped) - { - return new(mem) btSoftRigidCollisionAlgorithm(0,ci,body0,body1,false); - } else - { - return new(mem) btSoftRigidCollisionAlgorithm(0,ci,body0,body1,true); - } - } - }; - -}; - -#endif //SOFT_RIGID_COLLISION_ALGORITHM_H - - diff --git a/bullet/src/BulletSoftBody/btSoftRigidDynamicsWorld.cpp b/bullet/src/BulletSoftBody/btSoftRigidDynamicsWorld.cpp deleted file mode 100644 index 784e491a9..000000000 --- a/bullet/src/BulletSoftBody/btSoftRigidDynamicsWorld.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#include "btSoftRigidDynamicsWorld.h" -#include "LinearMath/btQuickprof.h" - -//softbody & helpers -#include "btSoftBody.h" -#include "btSoftBodyHelpers.h" - - - - - -btSoftRigidDynamicsWorld::btSoftRigidDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration) -:btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver,collisionConfiguration) -{ - m_drawFlags = fDrawFlags::Std; - m_drawNodeTree = true; - m_drawFaceTree = false; - m_drawClusterTree = false; - m_sbi.m_broadphase = pairCache; - m_sbi.m_dispatcher = dispatcher; - m_sbi.m_sparsesdf.Initialize(); - m_sbi.m_sparsesdf.Reset(); - -} - -btSoftRigidDynamicsWorld::~btSoftRigidDynamicsWorld() -{ - -} - -void btSoftRigidDynamicsWorld::predictUnconstraintMotion(btScalar timeStep) -{ - btDiscreteDynamicsWorld::predictUnconstraintMotion( timeStep); - - for ( int i=0;ipredictMotion(timeStep); - } -} - -void btSoftRigidDynamicsWorld::internalSingleStepSimulation( btScalar timeStep) -{ - btDiscreteDynamicsWorld::internalSingleStepSimulation( timeStep ); - - ///solve soft bodies constraints - solveSoftBodiesConstraints(); - - //self collisions - for ( int i=0;idefaultCollisionHandler(psb); - } - - ///update soft bodies - updateSoftBodies(); - -} - -void btSoftRigidDynamicsWorld::updateSoftBodies() -{ - BT_PROFILE("updateSoftBodies"); - - for ( int i=0;iintegrateMotion(); - } -} - -void btSoftRigidDynamicsWorld::solveSoftBodiesConstraints() -{ - BT_PROFILE("solveSoftConstraints"); - - if(m_softBodies.size()) - { - btSoftBody::solveClusters(m_softBodies); - } - - for(int i=0;isolveConstraints(); - } -} - -void btSoftRigidDynamicsWorld::addSoftBody(btSoftBody* body,short int collisionFilterGroup,short int collisionFilterMask) -{ - m_softBodies.push_back(body); - - btCollisionWorld::addCollisionObject(body, - collisionFilterGroup, - collisionFilterMask); - -} - -void btSoftRigidDynamicsWorld::removeSoftBody(btSoftBody* body) -{ - m_softBodies.remove(body); - - btCollisionWorld::removeCollisionObject(body); -} - -void btSoftRigidDynamicsWorld::removeCollisionObject(btCollisionObject* collisionObject) -{ - btSoftBody* body = btSoftBody::upcast(collisionObject); - if (body) - removeSoftBody(body); - else - btDiscreteDynamicsWorld::removeCollisionObject(collisionObject); -} - -void btSoftRigidDynamicsWorld::debugDrawWorld() -{ - btDiscreteDynamicsWorld::debugDrawWorld(); - - if (getDebugDrawer()) - { - int i; - for ( i=0;im_softBodies.size();i++) - { - btSoftBody* psb=(btSoftBody*)this->m_softBodies[i]; - btSoftBodyHelpers::DrawFrame(psb,m_debugDrawer); - btSoftBodyHelpers::Draw(psb,m_debugDrawer,m_drawFlags); - if (m_debugDrawer && (m_debugDrawer->getDebugMode() & btIDebugDraw::DBG_DrawAabb)) - { - if(m_drawNodeTree) btSoftBodyHelpers::DrawNodeTree(psb,m_debugDrawer); - if(m_drawFaceTree) btSoftBodyHelpers::DrawFaceTree(psb,m_debugDrawer); - if(m_drawClusterTree) btSoftBodyHelpers::DrawClusterTree(psb,m_debugDrawer); - } - } - } -} diff --git a/bullet/src/BulletSoftBody/btSoftRigidDynamicsWorld.h b/bullet/src/BulletSoftBody/btSoftRigidDynamicsWorld.h deleted file mode 100644 index 5bc7fe88c..000000000 --- a/bullet/src/BulletSoftBody/btSoftRigidDynamicsWorld.h +++ /dev/null @@ -1,85 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef BT_SOFT_RIGID_DYNAMICS_WORLD_H -#define BT_SOFT_RIGID_DYNAMICS_WORLD_H - -#include "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h" -#include "btSoftBody.h" - -typedef btAlignedObjectArray btSoftBodyArray; - -class btSoftRigidDynamicsWorld : public btDiscreteDynamicsWorld -{ - - btSoftBodyArray m_softBodies; - int m_drawFlags; - bool m_drawNodeTree; - bool m_drawFaceTree; - bool m_drawClusterTree; - btSoftBodyWorldInfo m_sbi; - -protected: - - virtual void predictUnconstraintMotion(btScalar timeStep); - - virtual void internalSingleStepSimulation( btScalar timeStep); - - void updateSoftBodies(); - - void solveSoftBodiesConstraints(); - - -public: - - btSoftRigidDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration); - - virtual ~btSoftRigidDynamicsWorld(); - - virtual void debugDrawWorld(); - - void addSoftBody(btSoftBody* body,short int collisionFilterGroup=btBroadphaseProxy::DefaultFilter,short int collisionFilterMask=btBroadphaseProxy::AllFilter); - - void removeSoftBody(btSoftBody* body); - - ///removeCollisionObject will first check if it is a rigid body, if so call removeRigidBody otherwise call btDiscreteDynamicsWorld::removeCollisionObject - virtual void removeCollisionObject(btCollisionObject* collisionObject); - - int getDrawFlags() const { return(m_drawFlags); } - void setDrawFlags(int f) { m_drawFlags=f; } - - btSoftBodyWorldInfo& getWorldInfo() - { - return m_sbi; - } - const btSoftBodyWorldInfo& getWorldInfo() const - { - return m_sbi; - } - - - btSoftBodyArray& getSoftBodyArray() - { - return m_softBodies; - } - - const btSoftBodyArray& getSoftBodyArray() const - { - return m_softBodies; - } - -}; - -#endif //BT_SOFT_RIGID_DYNAMICS_WORLD_H diff --git a/bullet/src/BulletSoftBody/btSoftSoftCollisionAlgorithm.cpp b/bullet/src/BulletSoftBody/btSoftSoftCollisionAlgorithm.cpp deleted file mode 100644 index 2ae8c26e2..000000000 --- a/bullet/src/BulletSoftBody/btSoftSoftCollisionAlgorithm.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btSoftSoftCollisionAlgorithm.h" -#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h" -#include "BulletCollision/CollisionShapes/btBoxShape.h" -#include "BulletCollision/CollisionDispatch/btCollisionObject.h" -#include "btSoftBody.h" - -#define USE_PERSISTENT_CONTACTS 1 - -btSoftSoftCollisionAlgorithm::btSoftSoftCollisionAlgorithm(btPersistentManifold* /*mf*/,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* /*obj0*/,btCollisionObject* /*obj1*/) -: btCollisionAlgorithm(ci) -//m_ownManifold(false), -//m_manifoldPtr(mf) -{ -} - -btSoftSoftCollisionAlgorithm::~btSoftSoftCollisionAlgorithm() -{ -} - -void btSoftSoftCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& /*dispatchInfo*/,btManifoldResult* /*resultOut*/) -{ - btSoftBody* soft0 = (btSoftBody*)body0; - btSoftBody* soft1 = (btSoftBody*)body1; - soft0->defaultCollisionHandler(soft1); -} - -btScalar btSoftSoftCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* /*body0*/,btCollisionObject* /*body1*/,const btDispatcherInfo& /*dispatchInfo*/,btManifoldResult* /*resultOut*/) -{ - //not yet - return 1.f; -} diff --git a/bullet/src/BulletSoftBody/btSoftSoftCollisionAlgorithm.h b/bullet/src/BulletSoftBody/btSoftSoftCollisionAlgorithm.h deleted file mode 100644 index 415c4b42a..000000000 --- a/bullet/src/BulletSoftBody/btSoftSoftCollisionAlgorithm.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef SOFT_SOFT_COLLISION_ALGORITHM_H -#define SOFT_SOFT_COLLISION_ALGORITHM_H - -#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h" -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" -#include "BulletCollision/BroadphaseCollision/btDispatcher.h" -#include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h" - -class btPersistentManifold; -class btSoftBody; - -///collision detection between two btSoftBody shapes -class btSoftSoftCollisionAlgorithm : public btCollisionAlgorithm -{ - bool m_ownManifold; - btPersistentManifold* m_manifoldPtr; - - btSoftBody* m_softBody0; - btSoftBody* m_softBody1; - - -public: - btSoftSoftCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci) - : btCollisionAlgorithm(ci) {} - - virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); - - virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); - - virtual void getAllContactManifolds(btManifoldArray& manifoldArray) - { - if (m_manifoldPtr && m_ownManifold) - manifoldArray.push_back(m_manifoldPtr); - } - - btSoftSoftCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1); - - virtual ~btSoftSoftCollisionAlgorithm(); - - struct CreateFunc :public btCollisionAlgorithmCreateFunc - { - virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1) - { - int bbsize = sizeof(btSoftSoftCollisionAlgorithm); - void* ptr = ci.m_dispatcher1->allocateCollisionAlgorithm(bbsize); - return new(ptr) btSoftSoftCollisionAlgorithm(0,ci,body0,body1); - } - }; - -}; - -#endif //SOFT_SOFT_COLLISION_ALGORITHM_H - - diff --git a/bullet/src/BulletSoftBody/btSparseSDF.h b/bullet/src/BulletSoftBody/btSparseSDF.h deleted file mode 100644 index 955881751..000000000 --- a/bullet/src/BulletSoftBody/btSparseSDF.h +++ /dev/null @@ -1,306 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ -///btSparseSdf implementation by Nathanael Presson - -#ifndef _14F9D17F_EAE8_4aba_B41C_292DB2AA70F3_ -#define _14F9D17F_EAE8_4aba_B41C_292DB2AA70F3_ - -#include "BulletCollision/CollisionDispatch/btCollisionObject.h" -#include "BulletCollision/NarrowPhaseCollision/btGjkEpa2.h" - -// Modified Paul Hsieh hash -template -unsigned int HsiehHash(const void* pdata) -{ - const unsigned short* data=(const unsigned short*)pdata; - unsigned hash=DWORDLEN<<2,tmp; - for(int i=0;i>11; - } - hash^=hash<<3;hash+=hash>>5; - hash^=hash<<4;hash+=hash>>17; - hash^=hash<<25;hash+=hash>>6; - return(hash); -} - -template -struct btSparseSdf -{ - // - // Inner types - // - struct IntFrac - { - int b; - int i; - btScalar f; - }; - struct Cell - { - btScalar d[CELLSIZE+1][CELLSIZE+1][CELLSIZE+1]; - int c[3]; - int puid; - unsigned hash; - btCollisionShape* pclient; - Cell* next; - }; - // - // Fields - // - - btAlignedObjectArray cells; - btScalar voxelsz; - int puid; - int ncells; - int nprobes; - int nqueries; - - // - // Methods - // - - // - void Initialize(int hashsize=2383) - { - cells.resize(hashsize,0); - Reset(); - } - // - void Reset() - { - for(int i=0,ni=cells.size();inext; - delete pc; - pc=pn; - } - } - voxelsz =0.25; - puid =0; - ncells =0; - nprobes =1; - nqueries =1; - } - // - void GarbageCollect(int lifetime=256) - { - const int life=puid-lifetime; - for(int i=0;inext; - if(pc->puidnext=pn; else root=pn; - delete pc;pc=pp;--ncells; - } - pp=pc;pc=pn; - } - } - //printf("GC[%d]: %d cells, PpQ: %f\r\n",puid,ncells,nprobes/(btScalar)nqueries); - nqueries=1; - nprobes=1; - ++puid; ///@todo: Reset puid's when int range limit is reached */ - /* else setup a priority list... */ - } - // - int RemoveReferences(btCollisionShape* pcs) - { - int refcount=0; - for(int i=0;inext; - if(pc->pclient==pcs) - { - if(pp) pp->next=pn; else root=pn; - delete pc;pc=pp;++refcount; - } - pp=pc;pc=pn; - } - } - return(refcount); - } - // - btScalar Evaluate( const btVector3& x, - btCollisionShape* shape, - btVector3& normal, - btScalar margin) - { - /* Lookup cell */ - const btVector3 scx=x/voxelsz; - const IntFrac ix=Decompose(scx.x()); - const IntFrac iy=Decompose(scx.y()); - const IntFrac iz=Decompose(scx.z()); - const unsigned h=Hash(ix.b,iy.b,iz.b,shape); - Cell*& root=cells[static_cast(h%cells.size())]; - Cell* c=root; - ++nqueries; - while(c) - { - ++nprobes; - if( (c->hash==h) && - (c->c[0]==ix.b) && - (c->c[1]==iy.b) && - (c->c[2]==iz.b) && - (c->pclient==shape)) - { break; } - else - { c=c->next; } - } - if(!c) - { - ++nprobes; - ++ncells; - c=new Cell(); - c->next=root;root=c; - c->pclient=shape; - c->hash=h; - c->c[0]=ix.b;c->c[1]=iy.b;c->c[2]=iz.b; - BuildCell(*c); - } - c->puid=puid; - /* Extract infos */ - const int o[]={ ix.i,iy.i,iz.i}; - const btScalar d[]={ c->d[o[0]+0][o[1]+0][o[2]+0], - c->d[o[0]+1][o[1]+0][o[2]+0], - c->d[o[0]+1][o[1]+1][o[2]+0], - c->d[o[0]+0][o[1]+1][o[2]+0], - c->d[o[0]+0][o[1]+0][o[2]+1], - c->d[o[0]+1][o[1]+0][o[2]+1], - c->d[o[0]+1][o[1]+1][o[2]+1], - c->d[o[0]+0][o[1]+1][o[2]+1]}; - /* Normal */ -#if 1 - const btScalar gx[]={ d[1]-d[0],d[2]-d[3], - d[5]-d[4],d[6]-d[7]}; - const btScalar gy[]={ d[3]-d[0],d[2]-d[1], - d[7]-d[4],d[6]-d[5]}; - const btScalar gz[]={ d[4]-d[0],d[5]-d[1], - d[7]-d[3],d[6]-d[2]}; - normal.setX(Lerp( Lerp(gx[0],gx[1],iy.f), - Lerp(gx[2],gx[3],iy.f),iz.f)); - normal.setY(Lerp( Lerp(gy[0],gy[1],ix.f), - Lerp(gy[2],gy[3],ix.f),iz.f)); - normal.setZ(Lerp( Lerp(gz[0],gz[1],ix.f), - Lerp(gz[2],gz[3],ix.f),iy.f)); - normal = normal.normalized(); -#else - normal = btVector3(d[1]-d[0],d[3]-d[0],d[4]-d[0]).normalized(); -#endif - /* Distance */ - const btScalar d0=Lerp(Lerp(d[0],d[1],ix.f), - Lerp(d[3],d[2],ix.f),iy.f); - const btScalar d1=Lerp(Lerp(d[4],d[5],ix.f), - Lerp(d[7],d[6],ix.f),iy.f); - return(Lerp(d0,d1,iz.f)-margin); - } - // - void BuildCell(Cell& c) - { - const btVector3 org=btVector3( (btScalar)c.c[0], - (btScalar)c.c[1], - (btScalar)c.c[2]) * - CELLSIZE*voxelsz; - for(int k=0;k<=CELLSIZE;++k) - { - const btScalar z=voxelsz*k+org.z(); - for(int j=0;j<=CELLSIZE;++j) - { - const btScalar y=voxelsz*j+org.y(); - for(int i=0;i<=CELLSIZE;++i) - { - const btScalar x=voxelsz*i+org.x(); - c.d[i][j][k]=DistanceToShape( btVector3(x,y,z), - c.pclient); - } - } - } - } - // - static inline btScalar DistanceToShape(const btVector3& x, - btCollisionShape* shape) - { - btTransform unit; - unit.setIdentity(); - if(shape->isConvex()) - { - btGjkEpaSolver2::sResults res; - btConvexShape* csh=static_cast(shape); - return(btGjkEpaSolver2::SignedDistance(x,0,csh,unit,res)); - } - return(0); - } - // - static inline IntFrac Decompose(btScalar x) - { - /* That one need a lot of improvements... */ - /* Remove test, faster floor... */ - IntFrac r; - x/=CELLSIZE; - const int o=x<0?(int)(-x+1):0; - x+=o;r.b=(int)x; - const btScalar k=(x-r.b)*CELLSIZE; - r.i=(int)k;r.f=k-r.i;r.b-=o; - return(r); - } - // - static inline btScalar Lerp(btScalar a,btScalar b,btScalar t) - { - return(a+(b-a)*t); - } - - - - // - static inline unsigned int Hash(int x,int y,int z,btCollisionShape* shape) - { - struct btS - { - int x,y,z; - void* p; - }; - - btS myset; - - myset.x=x;myset.y=y;myset.z=z;myset.p=shape; - const void* ptr = &myset; - - unsigned int result = HsiehHash (ptr); - - - return result; - } -}; - - -#endif diff --git a/bullet/src/CMakeLists.txt b/bullet/src/CMakeLists.txt deleted file mode 100644 index 185557845..000000000 --- a/bullet/src/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -if (CMAKE_SIZEOF_VOID_P MATCHES "8") -SUBDIRS( BulletSoftBody BulletCollision BulletDynamics LinearMath ) -else (CMAKE_SIZEOF_VOID_P MATCHES "8") -SUBDIRS( BulletMultiThreaded BulletSoftBody BulletCollision BulletDynamics LinearMath ) -endif (CMAKE_SIZEOF_VOID_P MATCHES "8") - -#INSTALL of other files requires CMake 2.6 -IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) - IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) - # Don't actually need to install any common files, the frameworks include everything - ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) - INSTALL(FILES btBulletCollisionCommon.h btBulletDynamicsCommon.h Bullet-C-Api.h DESTINATION include) - ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) -ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) - diff --git a/bullet/src/Jamfile b/bullet/src/Jamfile deleted file mode 100644 index 5a51b510d..000000000 --- a/bullet/src/Jamfile +++ /dev/null @@ -1,7 +0,0 @@ -SubDir TOP src ; -SubInclude TOP src BulletMultiThreaded ; -SubInclude TOP src BulletSoftBody ; -SubInclude TOP src BulletCollision ; -SubInclude TOP src BulletDynamics ; -SubInclude TOP src LinearMath ; -Recurse InstallHeader : .h ; diff --git a/bullet/src/LinearMath/CMakeLists.txt b/bullet/src/LinearMath/CMakeLists.txt deleted file mode 100644 index 869050e9a..000000000 --- a/bullet/src/LinearMath/CMakeLists.txt +++ /dev/null @@ -1,55 +0,0 @@ - -INCLUDE_DIRECTORIES( - ${BULLET_PHYSICS_SOURCE_DIR}/src -) - -SET(LinearMath_SRCS - btAlignedAllocator.cpp - btConvexHull.cpp - btGeometryUtil.cpp - btQuickprof.cpp -) - -SET(LinearMath_HDRS - btAabbUtil2.h - btAlignedAllocator.h - btAlignedObjectArray.h - btConvexHull.h - btDefaultMotionState.h - btGeometryUtil.h - btHashMap.h - btIDebugDraw.h - btList.h - btMatrix3x3.h - btMinMax.h - btMotionState.h - btPoolAllocator.h - btQuadWord.h - btQuaternion.h - btQuickprof.h - btRandom.h - btScalar.h - btStackAlloc.h - btTransform.h - btTransformUtil.h - btVector3.h -) - -ADD_LIBRARY(LinearMath ${LinearMath_SRCS} ${LinearMath_HDRS}) -SET_TARGET_PROPERTIES(LinearMath PROPERTIES VERSION ${BULLET_VERSION}) -SET_TARGET_PROPERTIES(LinearMath PROPERTIES SOVERSION ${BULLET_VERSION}) - -#FILES_MATCHING requires CMake 2.6 -IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) - IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) - INSTALL(TARGETS LinearMath DESTINATION .) - ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) - INSTALL(TARGETS LinearMath DESTINATION lib${LIB_SUFFIX}) - INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION include FILES_MATCHING PATTERN "*.h") - ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) -ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) - -IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) - SET_TARGET_PROPERTIES(LinearMath PROPERTIES FRAMEWORK true) - SET_TARGET_PROPERTIES(LinearMath PROPERTIES PUBLIC_HEADER ${LinearMath_HDRS}) -ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) diff --git a/bullet/src/LinearMath/Jamfile b/bullet/src/LinearMath/Jamfile deleted file mode 100644 index 41faa3a55..000000000 --- a/bullet/src/LinearMath/Jamfile +++ /dev/null @@ -1,10 +0,0 @@ - -SubDir TOP src LinearMath ; - -Description bulletmath : "Bullet Math Library" ; - -Library bulletmath : -[ Wildcard *.h *.cpp ] - ; - -#InstallHeader [ Wildcard *.h ] ; diff --git a/bullet/src/LinearMath/btAabbUtil2.h b/bullet/src/LinearMath/btAabbUtil2.h deleted file mode 100644 index b7bfa0418..000000000 --- a/bullet/src/LinearMath/btAabbUtil2.h +++ /dev/null @@ -1,236 +0,0 @@ -/* -Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - - -#ifndef AABB_UTIL2 -#define AABB_UTIL2 - -#include "btTransform.h" -#include "btVector3.h" -#include "btMinMax.h" - - - -SIMD_FORCE_INLINE void AabbExpand (btVector3& aabbMin, - btVector3& aabbMax, - const btVector3& expansionMin, - const btVector3& expansionMax) -{ - aabbMin = aabbMin + expansionMin; - aabbMax = aabbMax + expansionMax; -} - -/// conservative test for overlap between two aabbs -SIMD_FORCE_INLINE bool TestPointAgainstAabb2(const btVector3 &aabbMin1, const btVector3 &aabbMax1, - const btVector3 &point) -{ - bool overlap = true; - overlap = (aabbMin1.getX() > point.getX() || aabbMax1.getX() < point.getX()) ? false : overlap; - overlap = (aabbMin1.getZ() > point.getZ() || aabbMax1.getZ() < point.getZ()) ? false : overlap; - overlap = (aabbMin1.getY() > point.getY() || aabbMax1.getY() < point.getY()) ? false : overlap; - return overlap; -} - - -/// conservative test for overlap between two aabbs -SIMD_FORCE_INLINE bool TestAabbAgainstAabb2(const btVector3 &aabbMin1, const btVector3 &aabbMax1, - const btVector3 &aabbMin2, const btVector3 &aabbMax2) -{ - bool overlap = true; - overlap = (aabbMin1.getX() > aabbMax2.getX() || aabbMax1.getX() < aabbMin2.getX()) ? false : overlap; - overlap = (aabbMin1.getZ() > aabbMax2.getZ() || aabbMax1.getZ() < aabbMin2.getZ()) ? false : overlap; - overlap = (aabbMin1.getY() > aabbMax2.getY() || aabbMax1.getY() < aabbMin2.getY()) ? false : overlap; - return overlap; -} - -/// conservative test for overlap between triangle and aabb -SIMD_FORCE_INLINE bool TestTriangleAgainstAabb2(const btVector3 *vertices, - const btVector3 &aabbMin, const btVector3 &aabbMax) -{ - const btVector3 &p1 = vertices[0]; - const btVector3 &p2 = vertices[1]; - const btVector3 &p3 = vertices[2]; - - if (btMin(btMin(p1[0], p2[0]), p3[0]) > aabbMax[0]) return false; - if (btMax(btMax(p1[0], p2[0]), p3[0]) < aabbMin[0]) return false; - - if (btMin(btMin(p1[2], p2[2]), p3[2]) > aabbMax[2]) return false; - if (btMax(btMax(p1[2], p2[2]), p3[2]) < aabbMin[2]) return false; - - if (btMin(btMin(p1[1], p2[1]), p3[1]) > aabbMax[1]) return false; - if (btMax(btMax(p1[1], p2[1]), p3[1]) < aabbMin[1]) return false; - return true; -} - - -SIMD_FORCE_INLINE int btOutcode(const btVector3& p,const btVector3& halfExtent) -{ - return (p.getX() < -halfExtent.getX() ? 0x01 : 0x0) | - (p.getX() > halfExtent.getX() ? 0x08 : 0x0) | - (p.getY() < -halfExtent.getY() ? 0x02 : 0x0) | - (p.getY() > halfExtent.getY() ? 0x10 : 0x0) | - (p.getZ() < -halfExtent.getZ() ? 0x4 : 0x0) | - (p.getZ() > halfExtent.getZ() ? 0x20 : 0x0); -} - - - -SIMD_FORCE_INLINE bool btRayAabb2(const btVector3& rayFrom, - const btVector3& rayInvDirection, - const unsigned int raySign[3], - const btVector3 bounds[2], - btScalar& tmin, - btScalar lambda_min, - btScalar lambda_max) -{ - btScalar tmax, tymin, tymax, tzmin, tzmax; - tmin = (bounds[raySign[0]].getX() - rayFrom.getX()) * rayInvDirection.getX(); - tmax = (bounds[1-raySign[0]].getX() - rayFrom.getX()) * rayInvDirection.getX(); - tymin = (bounds[raySign[1]].getY() - rayFrom.getY()) * rayInvDirection.getY(); - tymax = (bounds[1-raySign[1]].getY() - rayFrom.getY()) * rayInvDirection.getY(); - - if ( (tmin > tymax) || (tymin > tmax) ) - return false; - - if (tymin > tmin) - tmin = tymin; - - if (tymax < tmax) - tmax = tymax; - - tzmin = (bounds[raySign[2]].getZ() - rayFrom.getZ()) * rayInvDirection.getZ(); - tzmax = (bounds[1-raySign[2]].getZ() - rayFrom.getZ()) * rayInvDirection.getZ(); - - if ( (tmin > tzmax) || (tzmin > tmax) ) - return false; - if (tzmin > tmin) - tmin = tzmin; - if (tzmax < tmax) - tmax = tzmax; - return ( (tmin < lambda_max) && (tmax > lambda_min) ); -} - -SIMD_FORCE_INLINE bool btRayAabb(const btVector3& rayFrom, - const btVector3& rayTo, - const btVector3& aabbMin, - const btVector3& aabbMax, - btScalar& param, btVector3& normal) -{ - btVector3 aabbHalfExtent = (aabbMax-aabbMin)* btScalar(0.5); - btVector3 aabbCenter = (aabbMax+aabbMin)* btScalar(0.5); - btVector3 source = rayFrom - aabbCenter; - btVector3 target = rayTo - aabbCenter; - int sourceOutcode = btOutcode(source,aabbHalfExtent); - int targetOutcode = btOutcode(target,aabbHalfExtent); - if ((sourceOutcode & targetOutcode) == 0x0) - { - btScalar lambda_enter = btScalar(0.0); - btScalar lambda_exit = param; - btVector3 r = target - source; - int i; - btScalar normSign = 1; - btVector3 hitNormal(0,0,0); - int bit=1; - - for (int j=0;j<2;j++) - { - for (i = 0; i != 3; ++i) - { - if (sourceOutcode & bit) - { - btScalar lambda = (-source[i] - aabbHalfExtent[i]*normSign) / r[i]; - if (lambda_enter <= lambda) - { - lambda_enter = lambda; - hitNormal.setValue(0,0,0); - hitNormal[i] = normSign; - } - } - else if (targetOutcode & bit) - { - btScalar lambda = (-source[i] - aabbHalfExtent[i]*normSign) / r[i]; - btSetMin(lambda_exit, lambda); - } - bit<<=1; - } - normSign = btScalar(-1.); - } - if (lambda_enter <= lambda_exit) - { - param = lambda_enter; - normal = hitNormal; - return true; - } - } - return false; -} - - - -SIMD_FORCE_INLINE void btTransformAabb(const btVector3& halfExtents, btScalar margin,const btTransform& t,btVector3& aabbMinOut,btVector3& aabbMaxOut) -{ - btVector3 halfExtentsWithMargin = halfExtents+btVector3(margin,margin,margin); - btMatrix3x3 abs_b = t.getBasis().absolute(); - btVector3 center = t.getOrigin(); - btVector3 extent = btVector3(abs_b[0].dot(halfExtentsWithMargin), - abs_b[1].dot(halfExtentsWithMargin), - abs_b[2].dot(halfExtentsWithMargin)); - aabbMinOut = center - extent; - aabbMaxOut = center + extent; -} - - -SIMD_FORCE_INLINE void btTransformAabb(const btVector3& localAabbMin,const btVector3& localAabbMax, btScalar margin,const btTransform& trans,btVector3& aabbMinOut,btVector3& aabbMaxOut) -{ - btAssert(localAabbMin.getX() <= localAabbMax.getX()); - btAssert(localAabbMin.getY() <= localAabbMax.getY()); - btAssert(localAabbMin.getZ() <= localAabbMax.getZ()); - btVector3 localHalfExtents = btScalar(0.5)*(localAabbMax-localAabbMin); - localHalfExtents+=btVector3(margin,margin,margin); - - btVector3 localCenter = btScalar(0.5)*(localAabbMax+localAabbMin); - btMatrix3x3 abs_b = trans.getBasis().absolute(); - btVector3 center = trans(localCenter); - btVector3 extent = btVector3(abs_b[0].dot(localHalfExtents), - abs_b[1].dot(localHalfExtents), - abs_b[2].dot(localHalfExtents)); - aabbMinOut = center-extent; - aabbMaxOut = center+extent; -} - -#define USE_BANCHLESS 1 -#ifdef USE_BANCHLESS - //This block replaces the block below and uses no branches, and replaces the 8 bit return with a 32 bit return for improved performance (~3x on XBox 360) - SIMD_FORCE_INLINE unsigned testQuantizedAabbAgainstQuantizedAabb(const unsigned short int* aabbMin1,const unsigned short int* aabbMax1,const unsigned short int* aabbMin2,const unsigned short int* aabbMax2) - { - return static_cast(btSelect((unsigned)((aabbMin1[0] <= aabbMax2[0]) & (aabbMax1[0] >= aabbMin2[0]) - & (aabbMin1[2] <= aabbMax2[2]) & (aabbMax1[2] >= aabbMin2[2]) - & (aabbMin1[1] <= aabbMax2[1]) & (aabbMax1[1] >= aabbMin2[1])), - 1, 0)); - } -#else - SIMD_FORCE_INLINE bool testQuantizedAabbAgainstQuantizedAabb(const unsigned short int* aabbMin1,const unsigned short int* aabbMax1,const unsigned short int* aabbMin2,const unsigned short int* aabbMax2) - { - bool overlap = true; - overlap = (aabbMin1[0] > aabbMax2[0] || aabbMax1[0] < aabbMin2[0]) ? false : overlap; - overlap = (aabbMin1[2] > aabbMax2[2] || aabbMax1[2] < aabbMin2[2]) ? false : overlap; - overlap = (aabbMin1[1] > aabbMax2[1] || aabbMax1[1] < aabbMin2[1]) ? false : overlap; - return overlap; - } -#endif //USE_BANCHLESS - -#endif - - diff --git a/bullet/src/LinearMath/btAlignedAllocator.cpp b/bullet/src/LinearMath/btAlignedAllocator.cpp deleted file mode 100644 index f9e8b01cc..000000000 --- a/bullet/src/LinearMath/btAlignedAllocator.cpp +++ /dev/null @@ -1,205 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btAlignedAllocator.h" - -int gNumAlignedAllocs = 0; -int gNumAlignedFree = 0; -int gTotalBytesAlignedAllocs = 0;//detect memory leaks - -static void *btAllocDefault(size_t size) -{ - return malloc(size); -} - -static void btFreeDefault(void *ptr) -{ - free(ptr); -} - -static btAllocFunc *sAllocFunc = btAllocDefault; -static btFreeFunc *sFreeFunc = btFreeDefault; - - - -#if defined (BT_HAS_ALIGNED_ALLOCATOR) -#include -static void *btAlignedAllocDefault(size_t size, int alignment) -{ - return _aligned_malloc(size, (size_t)alignment); -} - -static void btAlignedFreeDefault(void *ptr) -{ - _aligned_free(ptr); -} -#elif defined(__CELLOS_LV2__) -#include - -static inline void *btAlignedAllocDefault(size_t size, int alignment) -{ - return memalign(alignment, size); -} - -static inline void btAlignedFreeDefault(void *ptr) -{ - free(ptr); -} -#else -static inline void *btAlignedAllocDefault(size_t size, int alignment) -{ - void *ret; - char *real; - unsigned long offset; - - real = (char *)sAllocFunc(size + sizeof(void *) + (alignment-1)); - if (real) { - offset = (alignment - (unsigned long)(real + sizeof(void *))) & (alignment-1); - ret = (void *)((real + sizeof(void *)) + offset); - *((void **)(ret)-1) = (void *)(real); - } else { - ret = (void *)(real); - } - return (ret); -} - -static inline void btAlignedFreeDefault(void *ptr) -{ - void* real; - - if (ptr) { - real = *((void **)(ptr)-1); - sFreeFunc(real); - } -} -#endif - - -static btAlignedAllocFunc *sAlignedAllocFunc = btAlignedAllocDefault; -static btAlignedFreeFunc *sAlignedFreeFunc = btAlignedFreeDefault; - -void btAlignedAllocSetCustomAligned(btAlignedAllocFunc *allocFunc, btAlignedFreeFunc *freeFunc) -{ - sAlignedAllocFunc = allocFunc ? allocFunc : btAlignedAllocDefault; - sAlignedFreeFunc = freeFunc ? freeFunc : btAlignedFreeDefault; -} - -void btAlignedAllocSetCustom(btAllocFunc *allocFunc, btFreeFunc *freeFunc) -{ - sAllocFunc = allocFunc ? allocFunc : btAllocDefault; - sFreeFunc = freeFunc ? freeFunc : btFreeDefault; -} - -#ifdef BT_DEBUG_MEMORY_ALLOCATIONS -//this generic allocator provides the total allocated number of bytes -#include - -void* btAlignedAllocInternal (size_t size, int alignment,int line,char* filename) -{ - void *ret; - char *real; - unsigned long offset; - - gTotalBytesAlignedAllocs += size; - gNumAlignedAllocs++; - - - real = (char *)sAllocFunc(size + 2*sizeof(void *) + (alignment-1)); - if (real) { - offset = (alignment - (unsigned long)(real + 2*sizeof(void *))) & -(alignment-1); - ret = (void *)((real + 2*sizeof(void *)) + offset); - *((void **)(ret)-1) = (void *)(real); - *((int*)(ret)-2) = size; - - } else { - ret = (void *)(real);//?? - } - - printf("allocation#%d at address %x, from %s,line %d, size %d\n",gNumAlignedAllocs,real, filename,line,size); - - int* ptr = (int*)ret; - *ptr = 12; - return (ret); -} - -void btAlignedFreeInternal (void* ptr,int line,char* filename) -{ - - void* real; - gNumAlignedFree++; - - if (ptr) { - real = *((void **)(ptr)-1); - int size = *((int*)(ptr)-2); - gTotalBytesAlignedAllocs -= size; - - printf("free #%d at address %x, from %s,line %d, size %d\n",gNumAlignedFree,real, filename,line,size); - - sFreeFunc(real); - } else - { - printf("NULL ptr\n"); - } -} - -#else //BT_DEBUG_MEMORY_ALLOCATIONS - -void* btAlignedAllocInternal (size_t size, int alignment) -{ - gNumAlignedAllocs++; - void* ptr; -#if defined (BT_HAS_ALIGNED_ALLOCATOR) || defined(__CELLOS_LV2__) - ptr = sAlignedAllocFunc(size, alignment); -#else - char *real; - unsigned long offset; - - real = (char *)sAllocFunc(size + sizeof(void *) + (alignment-1)); - if (real) { - offset = (alignment - (unsigned long)(real + sizeof(void *))) & (alignment-1); - ptr = (void *)((real + sizeof(void *)) + offset); - *((void **)(ptr)-1) = (void *)(real); - } else { - ptr = (void *)(real); - } -#endif // defined (BT_HAS_ALIGNED_ALLOCATOR) || defined(__CELLOS_LV2__) -// printf("btAlignedAllocInternal %d, %x\n",size,ptr); - return ptr; -} - -void btAlignedFreeInternal (void* ptr) -{ - if (!ptr) - { - return; - } - - gNumAlignedFree++; -// printf("btAlignedFreeInternal %x\n",ptr); -#if defined (BT_HAS_ALIGNED_ALLOCATOR) || defined(__CELLOS_LV2__) - sAlignedFreeFunc(ptr); -#else - void* real; - - if (ptr) { - real = *((void **)(ptr)-1); - sFreeFunc(real); - } -#endif // defined (BT_HAS_ALIGNED_ALLOCATOR) || defined(__CELLOS_LV2__) -} - -#endif //BT_DEBUG_MEMORY_ALLOCATIONS - diff --git a/bullet/src/LinearMath/btAlignedAllocator.h b/bullet/src/LinearMath/btAlignedAllocator.h deleted file mode 100644 index a95f9911f..000000000 --- a/bullet/src/LinearMath/btAlignedAllocator.h +++ /dev/null @@ -1,107 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef BT_ALIGNED_ALLOCATOR -#define BT_ALIGNED_ALLOCATOR - -///we probably replace this with our own aligned memory allocator -///so we replace _aligned_malloc and _aligned_free with our own -///that is better portable and more predictable - -#include "btScalar.h" -//#define BT_DEBUG_MEMORY_ALLOCATIONS 1 -#ifdef BT_DEBUG_MEMORY_ALLOCATIONS - -#define btAlignedAlloc(a,b) \ - btAlignedAllocInternal(a,b,__LINE__,__FILE__) - -#define btAlignedFree(ptr) \ - btAlignedFreeInternal(ptr,__LINE__,__FILE__) - -void* btAlignedAllocInternal (size_t size, int alignment,int line,char* filename); - -void btAlignedFreeInternal (void* ptr,int line,char* filename); - -#else - void* btAlignedAllocInternal (size_t size, int alignment); - void btAlignedFreeInternal (void* ptr); - - #define btAlignedAlloc(size,alignment) btAlignedAllocInternal(size,alignment) - #define btAlignedFree(ptr) btAlignedFreeInternal(ptr) - -#endif -typedef int size_type; - -typedef void *(btAlignedAllocFunc)(size_t size, int alignment); -typedef void (btAlignedFreeFunc)(void *memblock); -typedef void *(btAllocFunc)(size_t size); -typedef void (btFreeFunc)(void *memblock); - -///The developer can let all Bullet memory allocations go through a custom memory allocator, using btAlignedAllocSetCustom -void btAlignedAllocSetCustom(btAllocFunc *allocFunc, btFreeFunc *freeFunc); -///If the developer has already an custom aligned allocator, then btAlignedAllocSetCustomAligned can be used. The default aligned allocator pre-allocates extra memory using the non-aligned allocator, and instruments it. -void btAlignedAllocSetCustomAligned(btAlignedAllocFunc *allocFunc, btAlignedFreeFunc *freeFunc); - - -///The btAlignedAllocator is a portable class for aligned memory allocations. -///Default implementations for unaligned and aligned allocations can be overridden by a custom allocator using btAlignedAllocSetCustom and btAlignedAllocSetCustomAligned. -template < typename T , unsigned Alignment > -class btAlignedAllocator { - - typedef btAlignedAllocator< T , Alignment > self_type; - -public: - - //just going down a list: - btAlignedAllocator() {} - /* - btAlignedAllocator( const self_type & ) {} - */ - - template < typename Other > - btAlignedAllocator( const btAlignedAllocator< Other , Alignment > & ) {} - - typedef const T* const_pointer; - typedef const T& const_reference; - typedef T* pointer; - typedef T& reference; - typedef T value_type; - - pointer address ( reference ref ) const { return &ref; } - const_pointer address ( const_reference ref ) const { return &ref; } - pointer allocate ( size_type n , const_pointer * hint = 0 ) { - (void)hint; - return reinterpret_cast< pointer >(btAlignedAlloc( sizeof(value_type) * n , Alignment )); - } - void construct ( pointer ptr , const value_type & value ) { new (ptr) value_type( value ); } - void deallocate( pointer ptr ) { - btAlignedFree( reinterpret_cast< void * >( ptr ) ); - } - void destroy ( pointer ptr ) { ptr->~value_type(); } - - - template < typename O > struct rebind { - typedef btAlignedAllocator< O , Alignment > other; - }; - template < typename O > - self_type & operator=( const btAlignedAllocator< O , Alignment > & ) { return *this; } - - friend bool operator==( const self_type & , const self_type & ) { return true; } -}; - - - -#endif //BT_ALIGNED_ALLOCATOR - diff --git a/bullet/src/LinearMath/btAlignedObjectArray.h b/bullet/src/LinearMath/btAlignedObjectArray.h deleted file mode 100644 index 03d69a752..000000000 --- a/bullet/src/LinearMath/btAlignedObjectArray.h +++ /dev/null @@ -1,452 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#ifndef BT_OBJECT_ARRAY__ -#define BT_OBJECT_ARRAY__ - -#include "btScalar.h" // has definitions like SIMD_FORCE_INLINE -#include "btAlignedAllocator.h" - -///If the platform doesn't support placement new, you can disable BT_USE_PLACEMENT_NEW -///then the btAlignedObjectArray doesn't support objects with virtual methods, and non-trivial constructors/destructors -///You can enable BT_USE_MEMCPY, then swapping elements in the array will use memcpy instead of operator= -///see discussion here: http://continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=1231 and -///http://www.continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=1240 - -#define BT_USE_PLACEMENT_NEW 1 -//#define BT_USE_MEMCPY 1 //disable, because it is cumbersome to find out for each platform where memcpy is defined. It can be in or or otherwise... - -#ifdef BT_USE_MEMCPY -#include -#include -#endif //BT_USE_MEMCPY - -#ifdef BT_USE_PLACEMENT_NEW -#include //for placement new -#endif //BT_USE_PLACEMENT_NEW - - -///The btAlignedObjectArray template class uses a subset of the stl::vector interface for its methods -///It is developed to replace stl::vector to avoid portability issues, including STL alignment issues to add SIMD/SSE data -template -//template -class btAlignedObjectArray -{ - btAlignedAllocator m_allocator; - - int m_size; - int m_capacity; - T* m_data; - //PCK: added this line - bool m_ownsMemory; - - protected: - SIMD_FORCE_INLINE int allocSize(int size) - { - return (size ? size*2 : 1); - } - SIMD_FORCE_INLINE void copy(int start,int end, T* dest) const - { - int i; - for (i=start;i size()) - { - reserve(newsize); - } -#ifdef BT_USE_PLACEMENT_NEW - for (int i=curSize;i - void quickSortInternal(L CompareFunc,int lo, int hi) - { - // lo is the lower index, hi is the upper index - // of the region of array a that is to be sorted - int i=lo, j=hi; - T x=m_data[(lo+hi)/2]; - - // partition - do - { - while (CompareFunc(m_data[i],x)) - i++; - while (CompareFunc(x,m_data[j])) - j--; - if (i<=j) - { - swap(i,j); - i++; j--; - } - } while (i<=j); - - // recursion - if (lo - void quickSort(L CompareFunc) - { - //don't sort 0 or 1 elements - if (size()>1) - { - quickSortInternal(CompareFunc,0,size()-1); - } - } - - - ///heap sort from http://www.csse.monash.edu.au/~lloyd/tildeAlgDS/Sort/Heap/ - template - void downHeap(T *pArr, int k, int n,L CompareFunc) - { - /* PRE: a[k+1..N] is a heap */ - /* POST: a[k..N] is a heap */ - - T temp = pArr[k - 1]; - /* k has child(s) */ - while (k <= n/2) - { - int child = 2*k; - - if ((child < n) && CompareFunc(pArr[child - 1] , pArr[child])) - { - child++; - } - /* pick larger child */ - if (CompareFunc(temp , pArr[child - 1])) - { - /* move child up */ - pArr[k - 1] = pArr[child - 1]; - k = child; - } - else - { - break; - } - } - pArr[k - 1] = temp; - } /*downHeap*/ - - void swap(int index0,int index1) - { -#ifdef BT_USE_MEMCPY - char temp[sizeof(T)]; - memcpy(temp,&m_data[index0],sizeof(T)); - memcpy(&m_data[index0],&m_data[index1],sizeof(T)); - memcpy(&m_data[index1],temp,sizeof(T)); -#else - T temp = m_data[index0]; - m_data[index0] = m_data[index1]; - m_data[index1] = temp; -#endif //BT_USE_PLACEMENT_NEW - - } - - template - void heapSort(L CompareFunc) - { - /* sort a[0..N-1], N.B. 0 to N-1 */ - int k; - int n = m_size; - for (k = n/2; k > 0; k--) - { - downHeap(m_data, k, n, CompareFunc); - } - - /* a[1..N] is now a heap */ - while ( n>=1 ) - { - swap(0,n-1); /* largest of a[0..n-1] */ - - - n = n - 1; - /* restore a[1..i-1] heap */ - downHeap(m_data, 1, n, CompareFunc); - } - } - - ///non-recursive binary search, assumes sorted array - int findBinarySearch(const T& key) const - { - int first = 0; - int last = size(); - - //assume sorted array - while (first <= last) { - int mid = (first + last) / 2; // compute mid point. - if (key > m_data[mid]) - first = mid + 1; // repeat search in top half. - else if (key < m_data[mid]) - last = mid - 1; // repeat search in bottom half. - else - return mid; // found it. return position ///// - } - return size(); // failed to find key - } - - - int findLinearSearch(const T& key) const - { - int index=size(); - int i; - - for (i=0;i - -#include "btConvexHull.h" -#include "LinearMath/btAlignedObjectArray.h" -#include "LinearMath/btMinMax.h" -#include "LinearMath/btVector3.h" - - - -template -void Swap(T &a,T &b) -{ - T tmp = a; - a=b; - b=tmp; -} - - -//---------------------------------- - -class int3 -{ -public: - int x,y,z; - int3(){}; - int3(int _x,int _y, int _z){x=_x;y=_y;z=_z;} - const int& operator[](int i) const {return (&x)[i];} - int& operator[](int i) {return (&x)[i];} -}; - - -//------- btPlane ---------- - - -inline btPlane PlaneFlip(const btPlane &plane){return btPlane(-plane.normal,-plane.dist);} -inline int operator==( const btPlane &a, const btPlane &b ) { return (a.normal==b.normal && a.dist==b.dist); } -inline int coplanar( const btPlane &a, const btPlane &b ) { return (a==b || a==PlaneFlip(b)); } - - -//--------- Utility Functions ------ - -btVector3 PlaneLineIntersection(const btPlane &plane, const btVector3 &p0, const btVector3 &p1); -btVector3 PlaneProject(const btPlane &plane, const btVector3 &point); - -btVector3 ThreePlaneIntersection(const btPlane &p0,const btPlane &p1, const btPlane &p2); -btVector3 ThreePlaneIntersection(const btPlane &p0,const btPlane &p1, const btPlane &p2) -{ - btVector3 N1 = p0.normal; - btVector3 N2 = p1.normal; - btVector3 N3 = p2.normal; - - btVector3 n2n3; n2n3 = N2.cross(N3); - btVector3 n3n1; n3n1 = N3.cross(N1); - btVector3 n1n2; n1n2 = N1.cross(N2); - - btScalar quotient = (N1.dot(n2n3)); - - btAssert(btFabs(quotient) > btScalar(0.000001)); - - quotient = btScalar(-1.) / quotient; - n2n3 *= p0.dist; - n3n1 *= p1.dist; - n1n2 *= p2.dist; - btVector3 potentialVertex = n2n3; - potentialVertex += n3n1; - potentialVertex += n1n2; - potentialVertex *= quotient; - - btVector3 result(potentialVertex.getX(),potentialVertex.getY(),potentialVertex.getZ()); - return result; - -} - -btScalar DistanceBetweenLines(const btVector3 &ustart, const btVector3 &udir, const btVector3 &vstart, const btVector3 &vdir, btVector3 *upoint=NULL, btVector3 *vpoint=NULL); -btVector3 TriNormal(const btVector3 &v0, const btVector3 &v1, const btVector3 &v2); -btVector3 NormalOf(const btVector3 *vert, const int n); - - -btVector3 PlaneLineIntersection(const btPlane &plane, const btVector3 &p0, const btVector3 &p1) -{ - // returns the point where the line p0-p1 intersects the plane n&d - static btVector3 dif; - dif = p1-p0; - btScalar dn= btDot(plane.normal,dif); - btScalar t = -(plane.dist+btDot(plane.normal,p0) )/dn; - return p0 + (dif*t); -} - -btVector3 PlaneProject(const btPlane &plane, const btVector3 &point) -{ - return point - plane.normal * (btDot(point,plane.normal)+plane.dist); -} - -btVector3 TriNormal(const btVector3 &v0, const btVector3 &v1, const btVector3 &v2) -{ - // return the normal of the triangle - // inscribed by v0, v1, and v2 - btVector3 cp=btCross(v1-v0,v2-v1); - btScalar m=cp.length(); - if(m==0) return btVector3(1,0,0); - return cp*(btScalar(1.0)/m); -} - - -btScalar DistanceBetweenLines(const btVector3 &ustart, const btVector3 &udir, const btVector3 &vstart, const btVector3 &vdir, btVector3 *upoint, btVector3 *vpoint) -{ - static btVector3 cp; - cp = btCross(udir,vdir).normalized(); - - btScalar distu = -btDot(cp,ustart); - btScalar distv = -btDot(cp,vstart); - btScalar dist = (btScalar)fabs(distu-distv); - if(upoint) - { - btPlane plane; - plane.normal = btCross(vdir,cp).normalized(); - plane.dist = -btDot(plane.normal,vstart); - *upoint = PlaneLineIntersection(plane,ustart,ustart+udir); - } - if(vpoint) - { - btPlane plane; - plane.normal = btCross(udir,cp).normalized(); - plane.dist = -btDot(plane.normal,ustart); - *vpoint = PlaneLineIntersection(plane,vstart,vstart+vdir); - } - return dist; -} - - - - - - - -#define COPLANAR (0) -#define UNDER (1) -#define OVER (2) -#define SPLIT (OVER|UNDER) -#define PAPERWIDTH (btScalar(0.001)) - -btScalar planetestepsilon = PAPERWIDTH; - - - -typedef ConvexH::HalfEdge HalfEdge; - -ConvexH::ConvexH(int vertices_size,int edges_size,int facets_size) -{ - vertices.resize(vertices_size); - edges.resize(edges_size); - facets.resize(facets_size); -} - - -int PlaneTest(const btPlane &p, const btVector3 &v); -int PlaneTest(const btPlane &p, const btVector3 &v) { - btScalar a = btDot(v,p.normal)+p.dist; - int flag = (a>planetestepsilon)?OVER:((a<-planetestepsilon)?UNDER:COPLANAR); - return flag; -} - -int SplitTest(ConvexH &convex,const btPlane &plane); -int SplitTest(ConvexH &convex,const btPlane &plane) { - int flag=0; - for(int i=0;i -int maxdirfiltered(const T *p,int count,const T &dir,btAlignedObjectArray &allow) -{ - btAssert(count); - int m=-1; - for(int i=0;ibtDot(p[m],dir)) - m=i; - } - btAssert(m!=-1); - return m; -} - -btVector3 orth(const btVector3 &v); -btVector3 orth(const btVector3 &v) -{ - btVector3 a=btCross(v,btVector3(0,0,1)); - btVector3 b=btCross(v,btVector3(0,1,0)); - if (a.length() > b.length()) - { - return a.normalized(); - } else { - return b.normalized(); - } -} - - -template -int maxdirsterid(const T *p,int count,const T &dir,btAlignedObjectArray &allow) -{ - int m=-1; - while(m==-1) - { - m = maxdirfiltered(p,count,dir,allow); - if(allow[m]==3) return m; - T u = orth(dir); - T v = btCross(u,dir); - int ma=-1; - for(btScalar x = btScalar(0.0) ; x<= btScalar(360.0) ; x+= btScalar(45.0)) - { - btScalar s = btSin(SIMD_RADS_PER_DEG*(x)); - btScalar c = btCos(SIMD_RADS_PER_DEG*(x)); - int mb = maxdirfiltered(p,count,dir+(u*s+v*c)*btScalar(0.025),allow); - if(ma==m && mb==m) - { - allow[m]=3; - return m; - } - if(ma!=-1 && ma!=mb) // Yuck - this is really ugly - { - int mc = ma; - for(btScalar xx = x-btScalar(40.0) ; xx <= x ; xx+= btScalar(5.0)) - { - btScalar s = btSin(SIMD_RADS_PER_DEG*(xx)); - btScalar c = btCos(SIMD_RADS_PER_DEG*(xx)); - int md = maxdirfiltered(p,count,dir+(u*s+v*c)*btScalar(0.025),allow); - if(mc==m && md==m) - { - allow[m]=3; - return m; - } - mc=md; - } - } - ma=mb; - } - allow[m]=0; - m=-1; - } - btAssert(0); - return m; -} - - - - -int operator ==(const int3 &a,const int3 &b); -int operator ==(const int3 &a,const int3 &b) -{ - for(int i=0;i<3;i++) - { - if(a[i]!=b[i]) return 0; - } - return 1; -} - - -int above(btVector3* vertices,const int3& t, const btVector3 &p, btScalar epsilon); -int above(btVector3* vertices,const int3& t, const btVector3 &p, btScalar epsilon) -{ - btVector3 n=TriNormal(vertices[t[0]],vertices[t[1]],vertices[t[2]]); - return (btDot(n,p-vertices[t[0]]) > epsilon); // EPSILON??? -} -int hasedge(const int3 &t, int a,int b); -int hasedge(const int3 &t, int a,int b) -{ - for(int i=0;i<3;i++) - { - int i1= (i+1)%3; - if(t[i]==a && t[i1]==b) return 1; - } - return 0; -} -int hasvert(const int3 &t, int v); -int hasvert(const int3 &t, int v) -{ - return (t[0]==v || t[1]==v || t[2]==v) ; -} -int shareedge(const int3 &a,const int3 &b); -int shareedge(const int3 &a,const int3 &b) -{ - int i; - for(i=0;i<3;i++) - { - int i1= (i+1)%3; - if(hasedge(a,b[i1],b[i])) return 1; - } - return 0; -} - -class btHullTriangle; - - - -class btHullTriangle : public int3 -{ -public: - int3 n; - int id; - int vmax; - btScalar rise; - btHullTriangle(int a,int b,int c):int3(a,b,c),n(-1,-1,-1) - { - vmax=-1; - rise = btScalar(0.0); - } - ~btHullTriangle() - { - } - int &neib(int a,int b); -}; - - -int &btHullTriangle::neib(int a,int b) -{ - static int er=-1; - int i; - for(i=0;i<3;i++) - { - int i1=(i+1)%3; - int i2=(i+2)%3; - if((*this)[i]==a && (*this)[i1]==b) return n[i2]; - if((*this)[i]==b && (*this)[i1]==a) return n[i2]; - } - btAssert(0); - return er; -} -void HullLibrary::b2bfix(btHullTriangle* s,btHullTriangle*t) -{ - int i; - for(i=0;i<3;i++) - { - int i1=(i+1)%3; - int i2=(i+2)%3; - int a = (*s)[i1]; - int b = (*s)[i2]; - btAssert(m_tris[s->neib(a,b)]->neib(b,a) == s->id); - btAssert(m_tris[t->neib(a,b)]->neib(b,a) == t->id); - m_tris[s->neib(a,b)]->neib(b,a) = t->neib(b,a); - m_tris[t->neib(b,a)]->neib(a,b) = s->neib(a,b); - } -} - -void HullLibrary::removeb2b(btHullTriangle* s,btHullTriangle*t) -{ - b2bfix(s,t); - deAllocateTriangle(s); - - deAllocateTriangle(t); -} - -void HullLibrary::checkit(btHullTriangle *t) -{ - (void)t; - - int i; - btAssert(m_tris[t->id]==t); - for(i=0;i<3;i++) - { - int i1=(i+1)%3; - int i2=(i+2)%3; - int a = (*t)[i1]; - int b = (*t)[i2]; - - // release compile fix - (void)i1; - (void)i2; - (void)a; - (void)b; - - btAssert(a!=b); - btAssert( m_tris[t->n[i]]->neib(b,a) == t->id); - } -} - -btHullTriangle* HullLibrary::allocateTriangle(int a,int b,int c) -{ - void* mem = btAlignedAlloc(sizeof(btHullTriangle),16); - btHullTriangle* tr = new (mem)btHullTriangle(a,b,c); - tr->id = m_tris.size(); - m_tris.push_back(tr); - - return tr; -} - -void HullLibrary::deAllocateTriangle(btHullTriangle* tri) -{ - btAssert(m_tris[tri->id]==tri); - m_tris[tri->id]=NULL; - tri->~btHullTriangle(); - btAlignedFree(tri); -} - - -void HullLibrary::extrude(btHullTriangle *t0,int v) -{ - int3 t= *t0; - int n = m_tris.size(); - btHullTriangle* ta = allocateTriangle(v,t[1],t[2]); - ta->n = int3(t0->n[0],n+1,n+2); - m_tris[t0->n[0]]->neib(t[1],t[2]) = n+0; - btHullTriangle* tb = allocateTriangle(v,t[2],t[0]); - tb->n = int3(t0->n[1],n+2,n+0); - m_tris[t0->n[1]]->neib(t[2],t[0]) = n+1; - btHullTriangle* tc = allocateTriangle(v,t[0],t[1]); - tc->n = int3(t0->n[2],n+0,n+1); - m_tris[t0->n[2]]->neib(t[0],t[1]) = n+2; - checkit(ta); - checkit(tb); - checkit(tc); - if(hasvert(*m_tris[ta->n[0]],v)) removeb2b(ta,m_tris[ta->n[0]]); - if(hasvert(*m_tris[tb->n[0]],v)) removeb2b(tb,m_tris[tb->n[0]]); - if(hasvert(*m_tris[tc->n[0]],v)) removeb2b(tc,m_tris[tc->n[0]]); - deAllocateTriangle(t0); - -} - -btHullTriangle* HullLibrary::extrudable(btScalar epsilon) -{ - int i; - btHullTriangle *t=NULL; - for(i=0;iriserise)) - { - t = m_tris[i]; - } - } - return (t->rise >epsilon)?t:NULL ; -} - - - - -int4 HullLibrary::FindSimplex(btVector3 *verts,int verts_count,btAlignedObjectArray &allow) -{ - btVector3 basis[3]; - basis[0] = btVector3( btScalar(0.01), btScalar(0.02), btScalar(1.0) ); - int p0 = maxdirsterid(verts,verts_count, basis[0],allow); - int p1 = maxdirsterid(verts,verts_count,-basis[0],allow); - basis[0] = verts[p0]-verts[p1]; - if(p0==p1 || basis[0]==btVector3(0,0,0)) - return int4(-1,-1,-1,-1); - basis[1] = btCross(btVector3( btScalar(1),btScalar(0.02), btScalar(0)),basis[0]); - basis[2] = btCross(btVector3(btScalar(-0.02), btScalar(1), btScalar(0)),basis[0]); - if (basis[1].length() > basis[2].length()) - { - basis[1].normalize(); - } else { - basis[1] = basis[2]; - basis[1].normalize (); - } - int p2 = maxdirsterid(verts,verts_count,basis[1],allow); - if(p2 == p0 || p2 == p1) - { - p2 = maxdirsterid(verts,verts_count,-basis[1],allow); - } - if(p2 == p0 || p2 == p1) - return int4(-1,-1,-1,-1); - basis[1] = verts[p2] - verts[p0]; - basis[2] = btCross(basis[1],basis[0]).normalized(); - int p3 = maxdirsterid(verts,verts_count,basis[2],allow); - if(p3==p0||p3==p1||p3==p2) p3 = maxdirsterid(verts,verts_count,-basis[2],allow); - if(p3==p0||p3==p1||p3==p2) - return int4(-1,-1,-1,-1); - btAssert(!(p0==p1||p0==p2||p0==p3||p1==p2||p1==p3||p2==p3)); - if(btDot(verts[p3]-verts[p0],btCross(verts[p1]-verts[p0],verts[p2]-verts[p0])) <0) {Swap(p2,p3);} - return int4(p0,p1,p2,p3); -} - -int HullLibrary::calchullgen(btVector3 *verts,int verts_count, int vlimit) -{ - if(verts_count <4) return 0; - if(vlimit==0) vlimit=1000000000; - int j; - btVector3 bmin(*verts),bmax(*verts); - btAlignedObjectArray isextreme; - isextreme.reserve(verts_count); - btAlignedObjectArray allow; - allow.reserve(verts_count); - - for(j=0;jn=int3(2,3,1); - btHullTriangle *t1 = allocateTriangle(p[3],p[2],p[0]); t1->n=int3(3,2,0); - btHullTriangle *t2 = allocateTriangle(p[0],p[1],p[3]); t2->n=int3(0,1,3); - btHullTriangle *t3 = allocateTriangle(p[1],p[0],p[2]); t3->n=int3(1,0,2); - isextreme[p[0]]=isextreme[p[1]]=isextreme[p[2]]=isextreme[p[3]]=1; - checkit(t0);checkit(t1);checkit(t2);checkit(t3); - - for(j=0;jvmax<0); - btVector3 n=TriNormal(verts[(*t)[0]],verts[(*t)[1]],verts[(*t)[2]]); - t->vmax = maxdirsterid(verts,verts_count,n,allow); - t->rise = btDot(n,verts[t->vmax]-verts[(*t)[0]]); - } - btHullTriangle *te; - vlimit-=4; - while(vlimit >0 && ((te=extrudable(epsilon)) != 0)) - { - int3 ti=*te; - int v=te->vmax; - btAssert(v != -1); - btAssert(!isextreme[v]); // wtf we've already done this vertex - isextreme[v]=1; - //if(v==p0 || v==p1 || v==p2 || v==p3) continue; // done these already - j=m_tris.size(); - while(j--) { - if(!m_tris[j]) continue; - int3 t=*m_tris[j]; - if(above(verts,t,verts[v],btScalar(0.01)*epsilon)) - { - extrude(m_tris[j],v); - } - } - // now check for those degenerate cases where we have a flipped triangle or a really skinny triangle - j=m_tris.size(); - while(j--) - { - if(!m_tris[j]) continue; - if(!hasvert(*m_tris[j],v)) break; - int3 nt=*m_tris[j]; - if(above(verts,nt,center,btScalar(0.01)*epsilon) || btCross(verts[nt[1]]-verts[nt[0]],verts[nt[2]]-verts[nt[1]]).length()< epsilon*epsilon*btScalar(0.1) ) - { - btHullTriangle *nb = m_tris[m_tris[j]->n[0]]; - btAssert(nb);btAssert(!hasvert(*nb,v));btAssert(nb->idvmax>=0) break; - btVector3 n=TriNormal(verts[(*t)[0]],verts[(*t)[1]],verts[(*t)[2]]); - t->vmax = maxdirsterid(verts,verts_count,n,allow); - if(isextreme[t->vmax]) - { - t->vmax=-1; // already done that vertex - algorithm needs to be able to terminate. - } - else - { - t->rise = btDot(n,verts[t->vmax]-verts[(*t)[0]]); - } - } - vlimit --; - } - return 1; -} - -int HullLibrary::calchull(btVector3 *verts,int verts_count, TUIntArray& tris_out, int &tris_count,int vlimit) -{ - int rc=calchullgen(verts,verts_count, vlimit) ; - if(!rc) return 0; - btAlignedObjectArray ts; - int i; - - for(i=0;i(ts[i]); - } - m_tris.resize(0); - - return 1; -} - - - - - -bool HullLibrary::ComputeHull(unsigned int vcount,const btVector3 *vertices,PHullResult &result,unsigned int vlimit) -{ - - int tris_count; - int ret = calchull( (btVector3 *) vertices, (int) vcount, result.m_Indices, tris_count, static_cast(vlimit) ); - if(!ret) return false; - result.mIndexCount = (unsigned int) (tris_count*3); - result.mFaceCount = (unsigned int) tris_count; - result.mVertices = (btVector3*) vertices; - result.mVcount = (unsigned int) vcount; - return true; - -} - - -void ReleaseHull(PHullResult &result); -void ReleaseHull(PHullResult &result) -{ - if ( result.m_Indices.size() ) - { - result.m_Indices.clear(); - } - - result.mVcount = 0; - result.mIndexCount = 0; - result.mVertices = 0; -} - - -//********************************************************************* -//********************************************************************* -//******** HullLib header -//********************************************************************* -//********************************************************************* - -//********************************************************************* -//********************************************************************* -//******** HullLib implementation -//********************************************************************* -//********************************************************************* - -HullError HullLibrary::CreateConvexHull(const HullDesc &desc, // describes the input request - HullResult &result) // contains the resulst -{ - HullError ret = QE_FAIL; - - - PHullResult hr; - - unsigned int vcount = desc.mVcount; - if ( vcount < 8 ) vcount = 8; - - btAlignedObjectArray vertexSource; - vertexSource.resize(static_cast(vcount)); - - btVector3 scale; - - unsigned int ovcount; - - bool ok = CleanupVertices(desc.mVcount,desc.mVertices, desc.mVertexStride, ovcount, &vertexSource[0], desc.mNormalEpsilon, scale ); // normalize point cloud, remove duplicates! - - if ( ok ) - { - - -// if ( 1 ) // scale vertices back to their original size. - { - for (unsigned int i=0; i(i)]; - v[0]*=scale[0]; - v[1]*=scale[1]; - v[2]*=scale[2]; - } - } - - ok = ComputeHull(ovcount,&vertexSource[0],hr,desc.mMaxVertices); - - if ( ok ) - { - - // re-index triangle mesh so it refers to only used vertices, rebuild a new vertex table. - btAlignedObjectArray vertexScratch; - vertexScratch.resize(static_cast(hr.mVcount)); - - BringOutYourDead(hr.mVertices,hr.mVcount, &vertexScratch[0], ovcount, &hr.m_Indices[0], hr.mIndexCount ); - - ret = QE_OK; - - if ( desc.HasHullFlag(QF_TRIANGLES) ) // if he wants the results as triangle! - { - result.mPolygons = false; - result.mNumOutputVertices = ovcount; - result.m_OutputVertices.resize(static_cast(ovcount)); - result.mNumFaces = hr.mFaceCount; - result.mNumIndices = hr.mIndexCount; - - result.m_Indices.resize(static_cast(hr.mIndexCount)); - - memcpy(&result.m_OutputVertices[0], &vertexScratch[0], sizeof(btVector3)*ovcount ); - - if ( desc.HasHullFlag(QF_REVERSE_ORDER) ) - { - - const unsigned int *source = &hr.m_Indices[0]; - unsigned int *dest = &result.m_Indices[0]; - - for (unsigned int i=0; i(ovcount)); - result.mNumFaces = hr.mFaceCount; - result.mNumIndices = hr.mIndexCount+hr.mFaceCount; - result.m_Indices.resize(static_cast(result.mNumIndices)); - memcpy(&result.m_OutputVertices[0], &vertexScratch[0], sizeof(btVector3)*ovcount ); - -// if ( 1 ) - { - const unsigned int *source = &hr.m_Indices[0]; - unsigned int *dest = &result.m_Indices[0]; - for (unsigned int i=0; i bmax[j] ) bmax[j] = p[j]; - } - } - } - - btScalar dx = bmax[0] - bmin[0]; - btScalar dy = bmax[1] - bmin[1]; - btScalar dz = bmax[2] - bmin[2]; - - btVector3 center; - - center[0] = dx*btScalar(0.5) + bmin[0]; - center[1] = dy*btScalar(0.5) + bmin[1]; - center[2] = dz*btScalar(0.5) + bmin[2]; - - if ( dx < EPSILON || dy < EPSILON || dz < EPSILON || svcount < 3 ) - { - - btScalar len = FLT_MAX; - - if ( dx > EPSILON && dx < len ) len = dx; - if ( dy > EPSILON && dy < len ) len = dy; - if ( dz > EPSILON && dz < len ) len = dz; - - if ( len == FLT_MAX ) - { - dx = dy = dz = btScalar(0.01); // one centimeter - } - else - { - if ( dx < EPSILON ) dx = len * btScalar(0.05); // 1/5th the shortest non-zero edge. - if ( dy < EPSILON ) dy = len * btScalar(0.05); - if ( dz < EPSILON ) dz = len * btScalar(0.05); - } - - btScalar x1 = center[0] - dx; - btScalar x2 = center[0] + dx; - - btScalar y1 = center[1] - dy; - btScalar y2 = center[1] + dy; - - btScalar z1 = center[2] - dz; - btScalar z2 = center[2] + dz; - - addPoint(vcount,vertices,x1,y1,z1); - addPoint(vcount,vertices,x2,y1,z1); - addPoint(vcount,vertices,x2,y2,z1); - addPoint(vcount,vertices,x1,y2,z1); - addPoint(vcount,vertices,x1,y1,z2); - addPoint(vcount,vertices,x2,y1,z2); - addPoint(vcount,vertices,x2,y2,z2); - addPoint(vcount,vertices,x1,y2,z2); - - return true; // return cube - - - } - else - { - if ( scale ) - { - scale[0] = dx; - scale[1] = dy; - scale[2] = dz; - - recip[0] = 1 / dx; - recip[1] = 1 / dy; - recip[2] = 1 / dz; - - center[0]*=recip[0]; - center[1]*=recip[1]; - center[2]*=recip[2]; - - } - - } - - - - vtx = (const char *) svertices; - - for (unsigned int i=0; igetX(); - btScalar py = p->getY(); - btScalar pz = p->getZ(); - - if ( scale ) - { - px = px*recip[0]; // normalize - py = py*recip[1]; // normalize - pz = pz*recip[2]; // normalize - } - -// if ( 1 ) - { - unsigned int j; - - for (j=0; j dist2 ) - { - v[0] = px; - v[1] = py; - v[2] = pz; - - } - - break; - } - } - - if ( j == vcount ) - { - btVector3& dest = vertices[vcount]; - dest[0] = px; - dest[1] = py; - dest[2] = pz; - vcount++; - } - m_vertexIndexMapping.push_back(j); - } - } - - // ok..now make sure we didn't prune so many vertices it is now invalid. -// if ( 1 ) - { - btScalar bmin[3] = { FLT_MAX, FLT_MAX, FLT_MAX }; - btScalar bmax[3] = { -FLT_MAX, -FLT_MAX, -FLT_MAX }; - - for (unsigned int i=0; i bmax[j] ) bmax[j] = p[j]; - } - } - - btScalar dx = bmax[0] - bmin[0]; - btScalar dy = bmax[1] - bmin[1]; - btScalar dz = bmax[2] - bmin[2]; - - if ( dx < EPSILON || dy < EPSILON || dz < EPSILON || vcount < 3) - { - btScalar cx = dx*btScalar(0.5) + bmin[0]; - btScalar cy = dy*btScalar(0.5) + bmin[1]; - btScalar cz = dz*btScalar(0.5) + bmin[2]; - - btScalar len = FLT_MAX; - - if ( dx >= EPSILON && dx < len ) len = dx; - if ( dy >= EPSILON && dy < len ) len = dy; - if ( dz >= EPSILON && dz < len ) len = dz; - - if ( len == FLT_MAX ) - { - dx = dy = dz = btScalar(0.01); // one centimeter - } - else - { - if ( dx < EPSILON ) dx = len * btScalar(0.05); // 1/5th the shortest non-zero edge. - if ( dy < EPSILON ) dy = len * btScalar(0.05); - if ( dz < EPSILON ) dz = len * btScalar(0.05); - } - - btScalar x1 = cx - dx; - btScalar x2 = cx + dx; - - btScalar y1 = cy - dy; - btScalar y2 = cy + dy; - - btScalar z1 = cz - dz; - btScalar z2 = cz + dz; - - vcount = 0; // add box - - addPoint(vcount,vertices,x1,y1,z1); - addPoint(vcount,vertices,x2,y1,z1); - addPoint(vcount,vertices,x2,y2,z1); - addPoint(vcount,vertices,x1,y2,z1); - addPoint(vcount,vertices,x1,y1,z2); - addPoint(vcount,vertices,x2,y1,z2); - addPoint(vcount,vertices,x2,y2,z2); - addPoint(vcount,vertices,x1,y2,z2); - - return true; - } - } - - return true; -} - -void HullLibrary::BringOutYourDead(const btVector3* verts,unsigned int vcount, btVector3* overts,unsigned int &ocount,unsigned int *indices,unsigned indexcount) -{ - btAlignedObjectArraytmpIndices; - tmpIndices.resize(m_vertexIndexMapping.size()); - int i; - - for (i=0;i(vcount)); - memset(&usedIndices[0],0,sizeof(unsigned int)*vcount); - - ocount = 0; - - for (i=0; i= 0 && v < vcount ); - - if ( usedIndices[static_cast(v)] ) // if already remapped - { - indices[i] = usedIndices[static_cast(v)]-1; // index to new array - } - else - { - - indices[i] = ocount; // new index mapping - - overts[ocount][0] = verts[v][0]; // copy old vert to new vert array - overts[ocount][1] = verts[v][1]; - overts[ocount][2] = verts[v][2]; - - for (int k=0;k=0 && ocount <= vcount ); - - usedIndices[static_cast(v)] = ocount; // assign new index remapping - - - } - } - - -} diff --git a/bullet/src/LinearMath/btConvexHull.h b/bullet/src/LinearMath/btConvexHull.h deleted file mode 100644 index b82e5f0e8..000000000 --- a/bullet/src/LinearMath/btConvexHull.h +++ /dev/null @@ -1,241 +0,0 @@ - -/* -Stan Melax Convex Hull Computation -Copyright (c) 2008 Stan Melax http://www.melax.com/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -///includes modifications/improvements by John Ratcliff, see BringOutYourDead below. - -#ifndef CD_HULL_H -#define CD_HULL_H - -#include "LinearMath/btVector3.h" -#include "LinearMath/btAlignedObjectArray.h" - -typedef btAlignedObjectArray TUIntArray; - -class HullResult -{ -public: - HullResult(void) - { - mPolygons = true; - mNumOutputVertices = 0; - mNumFaces = 0; - mNumIndices = 0; - } - bool mPolygons; // true if indices represents polygons, false indices are triangles - unsigned int mNumOutputVertices; // number of vertices in the output hull - btAlignedObjectArray m_OutputVertices; // array of vertices - unsigned int mNumFaces; // the number of faces produced - unsigned int mNumIndices; // the total number of indices - btAlignedObjectArray m_Indices; // pointer to indices. - -// If triangles, then indices are array indexes into the vertex list. -// If polygons, indices are in the form (number of points in face) (p1, p2, p3, ..) etc.. -}; - -enum HullFlag -{ - QF_TRIANGLES = (1<<0), // report results as triangles, not polygons. - QF_REVERSE_ORDER = (1<<1), // reverse order of the triangle indices. - QF_DEFAULT = QF_TRIANGLES -}; - - -class HullDesc -{ -public: - HullDesc(void) - { - mFlags = QF_DEFAULT; - mVcount = 0; - mVertices = 0; - mVertexStride = sizeof(btVector3); - mNormalEpsilon = 0.001f; - mMaxVertices = 4096; // maximum number of points to be considered for a convex hull. - mMaxFaces = 4096; - }; - - HullDesc(HullFlag flag, - unsigned int vcount, - const btVector3 *vertices, - unsigned int stride = sizeof(btVector3)) - { - mFlags = flag; - mVcount = vcount; - mVertices = vertices; - mVertexStride = stride; - mNormalEpsilon = btScalar(0.001); - mMaxVertices = 4096; - } - - bool HasHullFlag(HullFlag flag) const - { - if ( mFlags & flag ) return true; - return false; - } - - void SetHullFlag(HullFlag flag) - { - mFlags|=flag; - } - - void ClearHullFlag(HullFlag flag) - { - mFlags&=~flag; - } - - unsigned int mFlags; // flags to use when generating the convex hull. - unsigned int mVcount; // number of vertices in the input point cloud - const btVector3 *mVertices; // the array of vertices. - unsigned int mVertexStride; // the stride of each vertex, in bytes. - btScalar mNormalEpsilon; // the epsilon for removing duplicates. This is a normalized value, if normalized bit is on. - unsigned int mMaxVertices; // maximum number of vertices to be considered for the hull! - unsigned int mMaxFaces; -}; - -enum HullError -{ - QE_OK, // success! - QE_FAIL // failed. -}; - -class btPlane -{ - public: - btVector3 normal; - btScalar dist; // distance below origin - the D from plane equasion Ax+By+Cz+D=0 - btPlane(const btVector3 &n,btScalar d):normal(n),dist(d){} - btPlane():normal(),dist(0){} - -}; - - - -class ConvexH -{ - public: - class HalfEdge - { - public: - short ea; // the other half of the edge (index into edges list) - unsigned char v; // the vertex at the start of this edge (index into vertices list) - unsigned char p; // the facet on which this edge lies (index into facets list) - HalfEdge(){} - HalfEdge(short _ea,unsigned char _v, unsigned char _p):ea(_ea),v(_v),p(_p){} - }; - ConvexH() - { - } - ~ConvexH() - { - } - btAlignedObjectArray vertices; - btAlignedObjectArray edges; - btAlignedObjectArray facets; - ConvexH(int vertices_size,int edges_size,int facets_size); -}; - - -class int4 -{ -public: - int x,y,z,w; - int4(){}; - int4(int _x,int _y, int _z,int _w){x=_x;y=_y;z=_z;w=_w;} - const int& operator[](int i) const {return (&x)[i];} - int& operator[](int i) {return (&x)[i];} -}; - -class PHullResult -{ -public: - - PHullResult(void) - { - mVcount = 0; - mIndexCount = 0; - mFaceCount = 0; - mVertices = 0; - } - - unsigned int mVcount; - unsigned int mIndexCount; - unsigned int mFaceCount; - btVector3* mVertices; - TUIntArray m_Indices; -}; - - - -///The HullLibrary class can create a convex hull from a collection of vertices, using the ComputeHull method. -///The btShapeHull class uses this HullLibrary to create a approximate convex mesh given a general (non-polyhedral) convex shape. -class HullLibrary -{ - - btAlignedObjectArray m_tris; - -public: - - btAlignedObjectArray m_vertexIndexMapping; - - - HullError CreateConvexHull(const HullDesc& desc, // describes the input request - HullResult& result); // contains the resulst - HullError ReleaseResult(HullResult &result); // release memory allocated for this result, we are done with it. - -private: - - bool ComputeHull(unsigned int vcount,const btVector3 *vertices,PHullResult &result,unsigned int vlimit); - - class btHullTriangle* allocateTriangle(int a,int b,int c); - void deAllocateTriangle(btHullTriangle*); - void b2bfix(btHullTriangle* s,btHullTriangle*t); - - void removeb2b(btHullTriangle* s,btHullTriangle*t); - - void checkit(btHullTriangle *t); - - btHullTriangle* extrudable(btScalar epsilon); - - int calchull(btVector3 *verts,int verts_count, TUIntArray& tris_out, int &tris_count,int vlimit); - - int calchullgen(btVector3 *verts,int verts_count, int vlimit); - - int4 FindSimplex(btVector3 *verts,int verts_count,btAlignedObjectArray &allow); - - class ConvexH* ConvexHCrop(ConvexH& convex,const btPlane& slice); - - void extrude(class btHullTriangle* t0,int v); - - ConvexH* test_cube(); - - //BringOutYourDead (John Ratcliff): When you create a convex hull you hand it a large input set of vertices forming a 'point cloud'. - //After the hull is generated it give you back a set of polygon faces which index the *original* point cloud. - //The thing is, often times, there are many 'dead vertices' in the point cloud that are on longer referenced by the hull. - //The routine 'BringOutYourDead' find only the referenced vertices, copies them to an new buffer, and re-indexes the hull so that it is a minimal representation. - void BringOutYourDead(const btVector3* verts,unsigned int vcount, btVector3* overts,unsigned int &ocount,unsigned int* indices,unsigned indexcount); - - bool CleanupVertices(unsigned int svcount, - const btVector3* svertices, - unsigned int stride, - unsigned int &vcount, // output number of vertices - btVector3* vertices, // location to store the results. - btScalar normalepsilon, - btVector3& scale); -}; - - -#endif - diff --git a/bullet/src/LinearMath/btDefaultMotionState.h b/bullet/src/LinearMath/btDefaultMotionState.h deleted file mode 100644 index 23990a7c3..000000000 --- a/bullet/src/LinearMath/btDefaultMotionState.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef DEFAULT_MOTION_STATE_H -#define DEFAULT_MOTION_STATE_H - -#include "btMotionState.h" - -///The btDefaultMotionState provides a common implementation to synchronize world transforms with offsets. -struct btDefaultMotionState : public btMotionState -{ - btTransform m_graphicsWorldTrans; - btTransform m_centerOfMassOffset; - btTransform m_startWorldTrans; - void* m_userPointer; - - btDefaultMotionState(const btTransform& startTrans = btTransform::getIdentity(),const btTransform& centerOfMassOffset = btTransform::getIdentity()) - : m_graphicsWorldTrans(startTrans), - m_centerOfMassOffset(centerOfMassOffset), - m_startWorldTrans(startTrans), - m_userPointer(0) - - { - } - - ///synchronizes world transform from user to physics - virtual void getWorldTransform(btTransform& centerOfMassWorldTrans ) const - { - centerOfMassWorldTrans = m_centerOfMassOffset.inverse() * m_graphicsWorldTrans ; - } - - ///synchronizes world transform from physics to user - ///Bullet only calls the update of worldtransform for active objects - virtual void setWorldTransform(const btTransform& centerOfMassWorldTrans) - { - m_graphicsWorldTrans = centerOfMassWorldTrans * m_centerOfMassOffset ; - } - - - -}; - -#endif //DEFAULT_MOTION_STATE_H diff --git a/bullet/src/LinearMath/btGeometryUtil.cpp b/bullet/src/LinearMath/btGeometryUtil.cpp deleted file mode 100644 index 5fce2e150..000000000 --- a/bullet/src/LinearMath/btGeometryUtil.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/* -Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - - -#include "btGeometryUtil.h" - - -/* - Make sure this dummy function never changes so that it - can be used by probes that are checking whether the - library is actually installed. -*/ -extern "C" -{ - void btBulletMathProbe (); - - void btBulletMathProbe () {} -} - - -bool btGeometryUtil::isPointInsidePlanes(const btAlignedObjectArray& planeEquations, const btVector3& point, btScalar margin) -{ - int numbrushes = planeEquations.size(); - for (int i=0;ibtScalar(0.)) - { - return false; - } - } - return true; - -} - - -bool btGeometryUtil::areVerticesBehindPlane(const btVector3& planeNormal, const btAlignedObjectArray& vertices, btScalar margin) -{ - int numvertices = vertices.size(); - for (int i=0;ibtScalar(0.)) - { - return false; - } - } - return true; -} - -bool notExist(const btVector3& planeEquation,const btAlignedObjectArray& planeEquations); - -bool notExist(const btVector3& planeEquation,const btAlignedObjectArray& planeEquations) -{ - int numbrushes = planeEquations.size(); - for (int i=0;i btScalar(0.999)) - { - return false; - } - } - return true; -} - -void btGeometryUtil::getPlaneEquationsFromVertices(btAlignedObjectArray& vertices, btAlignedObjectArray& planeEquationsOut ) -{ - const int numvertices = vertices.size(); - // brute force: - for (int i=0;i btScalar(0.0001)) - { - planeEquation.normalize(); - if (notExist(planeEquation,planeEquationsOut)) - { - planeEquation[3] = -planeEquation.dot(N1); - - //check if inside, and replace supportingVertexOut if needed - if (areVerticesBehindPlane(planeEquation,vertices,btScalar(0.01))) - { - planeEquationsOut.push_back(planeEquation); - } - } - } - normalSign = btScalar(-1.); - } - - } - } - } - -} - -void btGeometryUtil::getVerticesFromPlaneEquations(const btAlignedObjectArray& planeEquations , btAlignedObjectArray& verticesOut ) -{ - const int numbrushes = planeEquations.size(); - // brute force: - for (int i=0;i btScalar(0.0001) ) && - ( n3n1.length2() > btScalar(0.0001) ) && - ( n1n2.length2() > btScalar(0.0001) ) ) - { - //point P out of 3 plane equations: - - // d1 ( N2 * N3 ) + d2 ( N3 * N1 ) + d3 ( N1 * N2 ) - //P = ------------------------------------------------------------------------- - // N1 . ( N2 * N3 ) - - - btScalar quotient = (N1.dot(n2n3)); - if (btFabs(quotient) > btScalar(0.000001)) - { - quotient = btScalar(-1.) / quotient; - n2n3 *= N1[3]; - n3n1 *= N2[3]; - n1n2 *= N3[3]; - btVector3 potentialVertex = n2n3; - potentialVertex += n3n1; - potentialVertex += n1n2; - potentialVertex *= quotient; - - //check if inside, and replace supportingVertexOut if needed - if (isPointInsidePlanes(planeEquations,potentialVertex,btScalar(0.01))) - { - verticesOut.push_back(potentialVertex); - } - } - } - } - } - } -} - diff --git a/bullet/src/LinearMath/btGeometryUtil.h b/bullet/src/LinearMath/btGeometryUtil.h deleted file mode 100644 index c18d6835f..000000000 --- a/bullet/src/LinearMath/btGeometryUtil.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#ifndef BT_GEOMETRY_UTIL_H -#define BT_GEOMETRY_UTIL_H - -#include "btVector3.h" -#include "btAlignedObjectArray.h" - -///The btGeometryUtil helper class provides a few methods to convert between plane equations and vertices. -class btGeometryUtil -{ - public: - - - static void getPlaneEquationsFromVertices(btAlignedObjectArray& vertices, btAlignedObjectArray& planeEquationsOut ); - - static void getVerticesFromPlaneEquations(const btAlignedObjectArray& planeEquations , btAlignedObjectArray& verticesOut ); - - static bool isInside(const btAlignedObjectArray& vertices, const btVector3& planeNormal, btScalar margin); - - static bool isPointInsidePlanes(const btAlignedObjectArray& planeEquations, const btVector3& point, btScalar margin); - - static bool areVerticesBehindPlane(const btVector3& planeNormal, const btAlignedObjectArray& vertices, btScalar margin); - -}; - - -#endif //BT_GEOMETRY_UTIL_H - diff --git a/bullet/src/LinearMath/btHashMap.h b/bullet/src/LinearMath/btHashMap.h deleted file mode 100644 index 08718d510..000000000 --- a/bullet/src/LinearMath/btHashMap.h +++ /dev/null @@ -1,406 +0,0 @@ -#ifndef BT_HASH_MAP_H -#define BT_HASH_MAP_H - -#include "btAlignedObjectArray.h" - -///very basic hashable string implementation, compatible with btHashMap -struct btHashString -{ - const char* m_string; - unsigned int m_hash; - - SIMD_FORCE_INLINE unsigned int getHash()const - { - return m_hash; - } - - btHashString(const char* name) - :m_string(name) - { - /* magic numbers from http://www.isthe.com/chongo/tech/comp/fnv/ */ - static const unsigned int InitialFNV = 2166136261u; - static const unsigned int FNVMultiple = 16777619u; - - /* Fowler / Noll / Vo (FNV) Hash */ - unsigned int hash = InitialFNV; - - for(int i = 0; m_string[i]; i++) - { - hash = hash ^ (m_string[i]); /* xor the low 8 bits */ - hash = hash * FNVMultiple; /* multiply by the magic number */ - } - m_hash = hash; - } - - int portableStringCompare(const char* src, const char* dst) const - { - int ret = 0 ; - - while( ! (ret = *(unsigned char *)src - *(unsigned char *)dst) && *dst) - ++src, ++dst; - - if ( ret < 0 ) - ret = -1 ; - else if ( ret > 0 ) - ret = 1 ; - - return( ret ); - } - - bool equals(const btHashString& other) const - { - return (m_string == other.m_string) || - (0==portableStringCompare(m_string,other.m_string)); - - } - -}; - -const int BT_HASH_NULL=0xffffffff; - -template -class btHashKey -{ - int m_uid; -public: - - btHashKey(int uid) - :m_uid(uid) - { - } - - int getUid1() const - { - return m_uid; - } - - bool equals(const btHashKey& other) const - { - return getUid1() == other.getUid1(); - } - //to our success - SIMD_FORCE_INLINE unsigned int getHash()const - { - int key = m_uid; - // Thomas Wang's hash - key += ~(key << 15); - key ^= (key >> 10); - key += (key << 3); - key ^= (key >> 6); - key += ~(key << 11); - key ^= (key >> 16); - return key; - } - - -}; - -class btHashInt -{ - int m_uid; -public: - - btHashInt(int uid) - :m_uid(uid) - { - } - - int getUid1() const - { - return m_uid; - } - - bool equals(const btHashInt& other) const - { - return getUid1() == other.getUid1(); - } - //to our success - SIMD_FORCE_INLINE unsigned int getHash()const - { - int key = m_uid; - // Thomas Wang's hash - key += ~(key << 15); - key ^= (key >> 10); - key += (key << 3); - key ^= (key >> 6); - key += ~(key << 11); - key ^= (key >> 16); - return key; - } -}; - -class btHashKeyPtr -{ - void* m_pointer; -public: - - btHashKeyPtr(void* ptr) - :m_pointer(ptr) - { - } - - const void* getPointer() const - { - return m_pointer; - } - - bool equals(const btHashKeyPtr& other) const - { - return getPointer() == other.getPointer(); - } - - //to our success - SIMD_FORCE_INLINE unsigned int getHash()const - { - const bool VOID_IS_8 = ((sizeof(void*)==8)); - int* intPtr = (int*)&m_pointer; - - int key = VOID_IS_8? intPtr[0]+intPtr[1] : intPtr[0]; - - // Thomas Wang's hash - key += ~(key << 15); - key ^= (key >> 10); - key += (key << 3); - key ^= (key >> 6); - key += ~(key << 11); - key ^= (key >> 16); - - return key; - } - - -}; - -///The btHashMap template class implements a generic and lightweight hashmap. -///A basic sample of how to use btHashMap is located in Demos\BasicDemo\main.cpp -template -class btHashMap -{ - - btAlignedObjectArray m_hashTable; - btAlignedObjectArray m_next; - - btAlignedObjectArray m_valueArray; - btAlignedObjectArray m_keyArray; - - void growTables(const Key& key) - { - int newCapacity = m_valueArray.capacity(); - - if (m_hashTable.size() < newCapacity) - { - //grow hashtable and next table - int curHashtableSize = m_hashTable.size(); - - m_hashTable.resize(newCapacity); - m_next.resize(newCapacity); - - int i; - - for (i= 0; i < newCapacity; ++i) - { - m_hashTable[i] = BT_HASH_NULL; - } - for (i = 0; i < newCapacity; ++i) - { - m_next[i] = BT_HASH_NULL; - } - - for(i=0;i= (unsigned int)m_hashTable.size()) - { - return BT_HASH_NULL; - } - - int index = m_hashTable[hash]; - while ((index != BT_HASH_NULL) && key.equals(m_keyArray[index]) == false) - { - index = m_next[index]; - } - return index; - } - - void clear() - { - m_hashTable.clear(); - m_next.clear(); - m_valueArray.clear(); - m_keyArray.clear(); - } - -}; - -#endif //BT_HASH_MAP_H diff --git a/bullet/src/LinearMath/btIDebugDraw.h b/bullet/src/LinearMath/btIDebugDraw.h deleted file mode 100644 index c7f7b2061..000000000 --- a/bullet/src/LinearMath/btIDebugDraw.h +++ /dev/null @@ -1,287 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#ifndef IDEBUG_DRAW__H -#define IDEBUG_DRAW__H - -#include "btVector3.h" -#include "btTransform.h" - - -///The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations. -///Typical use case: create a debug drawer object, and assign it to a btCollisionWorld or btDynamicsWorld using setDebugDrawer and call debugDrawWorld. -///A class that implements the btIDebugDraw interface has to implement the drawLine method at a minimum. -class btIDebugDraw -{ - public: - - enum DebugDrawModes - { - DBG_NoDebug=0, - DBG_DrawWireframe = 1, - DBG_DrawAabb=2, - DBG_DrawFeaturesText=4, - DBG_DrawContactPoints=8, - DBG_NoDeactivation=16, - DBG_NoHelpText = 32, - DBG_DrawText=64, - DBG_ProfileTimings = 128, - DBG_EnableSatComparison = 256, - DBG_DisableBulletLCP = 512, - DBG_EnableCCD = 1024, - DBG_DrawConstraints = (1 << 11), - DBG_DrawConstraintLimits = (1 << 12), - DBG_FastWireframe = (1<<13), - DBG_MAX_DEBUG_DRAW_MODE - }; - - virtual ~btIDebugDraw() {}; - - virtual void drawLine(const btVector3& from,const btVector3& to, const btVector3& fromColor, const btVector3& toColor) - { - drawLine (from, to, fromColor); - } - - virtual void drawBox (const btVector3& boxMin, const btVector3& boxMax, const btVector3& color, btScalar alpha) - { - } - - virtual void drawSphere (const btVector3& p, btScalar radius, const btVector3& color) - { - } - - virtual void drawLine(const btVector3& from,const btVector3& to,const btVector3& color)=0; - - virtual void drawTriangle(const btVector3& v0,const btVector3& v1,const btVector3& v2,const btVector3& /*n0*/,const btVector3& /*n1*/,const btVector3& /*n2*/,const btVector3& color, btScalar alpha) - { - drawTriangle(v0,v1,v2,color,alpha); - } - virtual void drawTriangle(const btVector3& v0,const btVector3& v1,const btVector3& v2,const btVector3& color, btScalar /*alpha*/) - { - drawLine(v0,v1,color); - drawLine(v1,v2,color); - drawLine(v2,v0,color); - } - - virtual void drawContactPoint(const btVector3& PointOnB,const btVector3& normalOnB,btScalar distance,int lifeTime,const btVector3& color)=0; - - virtual void reportErrorWarning(const char* warningString) = 0; - - virtual void draw3dText(const btVector3& location,const char* textString) = 0; - - virtual void setDebugMode(int debugMode) =0; - - virtual int getDebugMode() const = 0; - - inline void drawAabb(const btVector3& from,const btVector3& to,const btVector3& color) - { - - btVector3 halfExtents = (to-from)* 0.5f; - btVector3 center = (to+from) *0.5f; - int i,j; - - btVector3 edgecoord(1.f,1.f,1.f),pa,pb; - for (i=0;i<4;i++) - { - for (j=0;j<3;j++) - { - pa = btVector3(edgecoord[0]*halfExtents[0], edgecoord[1]*halfExtents[1], - edgecoord[2]*halfExtents[2]); - pa+=center; - - int othercoord = j%3; - edgecoord[othercoord]*=-1.f; - pb = btVector3(edgecoord[0]*halfExtents[0], edgecoord[1]*halfExtents[1], - edgecoord[2]*halfExtents[2]); - pb+=center; - - drawLine(pa,pb,color); - } - edgecoord = btVector3(-1.f,-1.f,-1.f); - if (i<3) - edgecoord[i]*=-1.f; - } - } - void drawTransform(const btTransform& transform, btScalar orthoLen) - { - btVector3 start = transform.getOrigin(); - drawLine(start, start+transform.getBasis() * btVector3(orthoLen, 0, 0), btVector3(0.7f,0,0)); - drawLine(start, start+transform.getBasis() * btVector3(0, orthoLen, 0), btVector3(0,0.7f,0)); - drawLine(start, start+transform.getBasis() * btVector3(0, 0, orthoLen), btVector3(0,0,0.7f)); - } - - void drawArc(const btVector3& center, const btVector3& normal, const btVector3& axis, btScalar radiusA, btScalar radiusB, btScalar minAngle, btScalar maxAngle, - const btVector3& color, bool drawSect, btScalar stepDegrees = btScalar(10.f)) - { - const btVector3& vx = axis; - btVector3 vy = normal.cross(axis); - btScalar step = stepDegrees * SIMD_RADS_PER_DEG; - int nSteps = (int)((maxAngle - minAngle) / step); - if(!nSteps) nSteps = 1; - btVector3 prev = center + radiusA * vx * btCos(minAngle) + radiusB * vy * btSin(minAngle); - if(drawSect) - { - drawLine(center, prev, color); - } - for(int i = 1; i <= nSteps; i++) - { - btScalar angle = minAngle + (maxAngle - minAngle) * btScalar(i) / btScalar(nSteps); - btVector3 next = center + radiusA * vx * btCos(angle) + radiusB * vy * btSin(angle); - drawLine(prev, next, color); - prev = next; - } - if(drawSect) - { - drawLine(center, prev, color); - } - } - void drawSpherePatch(const btVector3& center, const btVector3& up, const btVector3& axis, btScalar radius, - btScalar minTh, btScalar maxTh, btScalar minPs, btScalar maxPs, const btVector3& color, btScalar stepDegrees = btScalar(10.f)) - { - btVector3 vA[74]; - btVector3 vB[74]; - btVector3 *pvA = vA, *pvB = vB, *pT; - btVector3 npole = center + up * radius; - btVector3 spole = center - up * radius; - btVector3 arcStart; - btScalar step = stepDegrees * SIMD_RADS_PER_DEG; - const btVector3& kv = up; - const btVector3& iv = axis; - btVector3 jv = kv.cross(iv); - bool drawN = false; - bool drawS = false; - if(minTh <= -SIMD_HALF_PI) - { - minTh = -SIMD_HALF_PI + step; - drawN = true; - } - if(maxTh >= SIMD_HALF_PI) - { - maxTh = SIMD_HALF_PI - step; - drawS = true; - } - if(minTh > maxTh) - { - minTh = -SIMD_HALF_PI + step; - maxTh = SIMD_HALF_PI - step; - drawN = drawS = true; - } - int n_hor = (int)((maxTh - minTh) / step) + 1; - if(n_hor < 2) n_hor = 2; - btScalar step_h = (maxTh - minTh) / btScalar(n_hor - 1); - bool isClosed = false; - if(minPs > maxPs) - { - minPs = -SIMD_PI + step; - maxPs = SIMD_PI; - isClosed = true; - } - else if((maxPs - minPs) >= SIMD_PI * btScalar(2.f)) - { - isClosed = true; - } - else - { - isClosed = false; - } - int n_vert = (int)((maxPs - minPs) / step) + 1; - if(n_vert < 2) n_vert = 2; - btScalar step_v = (maxPs - minPs) / btScalar(n_vert - 1); - for(int i = 0; i < n_hor; i++) - { - btScalar th = minTh + btScalar(i) * step_h; - btScalar sth = radius * btSin(th); - btScalar cth = radius * btCos(th); - for(int j = 0; j < n_vert; j++) - { - btScalar psi = minPs + btScalar(j) * step_v; - btScalar sps = btSin(psi); - btScalar cps = btCos(psi); - pvB[j] = center + cth * cps * iv + cth * sps * jv + sth * kv; - if(i) - { - drawLine(pvA[j], pvB[j], color); - } - else if(drawS) - { - drawLine(spole, pvB[j], color); - } - if(j) - { - drawLine(pvB[j-1], pvB[j], color); - } - else - { - arcStart = pvB[j]; - } - if((i == (n_hor - 1)) && drawN) - { - drawLine(npole, pvB[j], color); - } - if(isClosed) - { - if(j == (n_vert-1)) - { - drawLine(arcStart, pvB[j], color); - } - } - else - { - if(((!i) || (i == (n_hor-1))) && ((!j) || (j == (n_vert-1)))) - { - drawLine(center, pvB[j], color); - } - } - } - pT = pvA; pvA = pvB; pvB = pT; - } - } - - void drawBox(const btVector3& bbMin, const btVector3& bbMax, const btVector3& color) - { - drawLine(btVector3(bbMin[0], bbMin[1], bbMin[2]), btVector3(bbMax[0], bbMin[1], bbMin[2]), color); - drawLine(btVector3(bbMax[0], bbMin[1], bbMin[2]), btVector3(bbMax[0], bbMax[1], bbMin[2]), color); - drawLine(btVector3(bbMax[0], bbMax[1], bbMin[2]), btVector3(bbMin[0], bbMax[1], bbMin[2]), color); - drawLine(btVector3(bbMin[0], bbMax[1], bbMin[2]), btVector3(bbMin[0], bbMin[1], bbMin[2]), color); - drawLine(btVector3(bbMin[0], bbMin[1], bbMin[2]), btVector3(bbMin[0], bbMin[1], bbMax[2]), color); - drawLine(btVector3(bbMax[0], bbMin[1], bbMin[2]), btVector3(bbMax[0], bbMin[1], bbMax[2]), color); - drawLine(btVector3(bbMax[0], bbMax[1], bbMin[2]), btVector3(bbMax[0], bbMax[1], bbMax[2]), color); - drawLine(btVector3(bbMin[0], bbMax[1], bbMin[2]), btVector3(bbMin[0], bbMax[1], bbMax[2]), color); - drawLine(btVector3(bbMin[0], bbMin[1], bbMax[2]), btVector3(bbMax[0], bbMin[1], bbMax[2]), color); - drawLine(btVector3(bbMax[0], bbMin[1], bbMax[2]), btVector3(bbMax[0], bbMax[1], bbMax[2]), color); - drawLine(btVector3(bbMax[0], bbMax[1], bbMax[2]), btVector3(bbMin[0], bbMax[1], bbMax[2]), color); - drawLine(btVector3(bbMin[0], bbMax[1], bbMax[2]), btVector3(bbMin[0], bbMin[1], bbMax[2]), color); - } - void drawBox(const btVector3& bbMin, const btVector3& bbMax, const btTransform& trans, const btVector3& color) - { - drawLine(trans * btVector3(bbMin[0], bbMin[1], bbMin[2]), trans * btVector3(bbMax[0], bbMin[1], bbMin[2]), color); - drawLine(trans * btVector3(bbMax[0], bbMin[1], bbMin[2]), trans * btVector3(bbMax[0], bbMax[1], bbMin[2]), color); - drawLine(trans * btVector3(bbMax[0], bbMax[1], bbMin[2]), trans * btVector3(bbMin[0], bbMax[1], bbMin[2]), color); - drawLine(trans * btVector3(bbMin[0], bbMax[1], bbMin[2]), trans * btVector3(bbMin[0], bbMin[1], bbMin[2]), color); - drawLine(trans * btVector3(bbMin[0], bbMin[1], bbMin[2]), trans * btVector3(bbMin[0], bbMin[1], bbMax[2]), color); - drawLine(trans * btVector3(bbMax[0], bbMin[1], bbMin[2]), trans * btVector3(bbMax[0], bbMin[1], bbMax[2]), color); - drawLine(trans * btVector3(bbMax[0], bbMax[1], bbMin[2]), trans * btVector3(bbMax[0], bbMax[1], bbMax[2]), color); - drawLine(trans * btVector3(bbMin[0], bbMax[1], bbMin[2]), trans * btVector3(bbMin[0], bbMax[1], bbMax[2]), color); - drawLine(trans * btVector3(bbMin[0], bbMin[1], bbMax[2]), trans * btVector3(bbMax[0], bbMin[1], bbMax[2]), color); - drawLine(trans * btVector3(bbMax[0], bbMin[1], bbMax[2]), trans * btVector3(bbMax[0], bbMax[1], bbMax[2]), color); - drawLine(trans * btVector3(bbMax[0], bbMax[1], bbMax[2]), trans * btVector3(bbMin[0], bbMax[1], bbMax[2]), color); - drawLine(trans * btVector3(bbMin[0], bbMax[1], bbMax[2]), trans * btVector3(bbMin[0], bbMin[1], bbMax[2]), color); - } -}; - - -#endif //IDEBUG_DRAW__H - diff --git a/bullet/src/LinearMath/btList.h b/bullet/src/LinearMath/btList.h deleted file mode 100644 index c0d1d9d6e..000000000 --- a/bullet/src/LinearMath/btList.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - - -#ifndef GEN_LIST_H -#define GEN_LIST_H - -class btGEN_Link { -public: - btGEN_Link() : m_next(0), m_prev(0) {} - btGEN_Link(btGEN_Link *next, btGEN_Link *prev) : m_next(next), m_prev(prev) {} - - btGEN_Link *getNext() const { return m_next; } - btGEN_Link *getPrev() const { return m_prev; } - - bool isHead() const { return m_prev == 0; } - bool isTail() const { return m_next == 0; } - - void insertBefore(btGEN_Link *link) { - m_next = link; - m_prev = link->m_prev; - m_next->m_prev = this; - m_prev->m_next = this; - } - - void insertAfter(btGEN_Link *link) { - m_next = link->m_next; - m_prev = link; - m_next->m_prev = this; - m_prev->m_next = this; - } - - void remove() { - m_next->m_prev = m_prev; - m_prev->m_next = m_next; - } - -private: - btGEN_Link *m_next; - btGEN_Link *m_prev; -}; - -class btGEN_List { -public: - btGEN_List() : m_head(&m_tail, 0), m_tail(0, &m_head) {} - - btGEN_Link *getHead() const { return m_head.getNext(); } - btGEN_Link *getTail() const { return m_tail.getPrev(); } - - void addHead(btGEN_Link *link) { link->insertAfter(&m_head); } - void addTail(btGEN_Link *link) { link->insertBefore(&m_tail); } - -private: - btGEN_Link m_head; - btGEN_Link m_tail; -}; - -#endif - - - diff --git a/bullet/src/LinearMath/btMatrix3x3.h b/bullet/src/LinearMath/btMatrix3x3.h deleted file mode 100644 index 6ca9ef964..000000000 --- a/bullet/src/LinearMath/btMatrix3x3.h +++ /dev/null @@ -1,650 +0,0 @@ -/* -Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#ifndef BT_MATRIX3x3_H -#define BT_MATRIX3x3_H - -#include "btVector3.h" -#include "btQuaternion.h" - - - -/**@brief The btMatrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with btQuaternion, btTransform and btVector3. -* Make sure to only include a pure orthogonal matrix without scaling. */ -class btMatrix3x3 { - - ///Data storage for the matrix, each vector is a row of the matrix - btVector3 m_el[3]; - -public: - /** @brief No initializaion constructor */ - btMatrix3x3 () {} - - // explicit btMatrix3x3(const btScalar *m) { setFromOpenGLSubMatrix(m); } - - /**@brief Constructor from Quaternion */ - explicit btMatrix3x3(const btQuaternion& q) { setRotation(q); } - /* - template - Matrix3x3(const btScalar& yaw, const btScalar& pitch, const btScalar& roll) - { - setEulerYPR(yaw, pitch, roll); - } - */ - /** @brief Constructor with row major formatting */ - btMatrix3x3(const btScalar& xx, const btScalar& xy, const btScalar& xz, - const btScalar& yx, const btScalar& yy, const btScalar& yz, - const btScalar& zx, const btScalar& zy, const btScalar& zz) - { - setValue(xx, xy, xz, - yx, yy, yz, - zx, zy, zz); - } - /** @brief Copy constructor */ - SIMD_FORCE_INLINE btMatrix3x3 (const btMatrix3x3& other) - { - m_el[0] = other.m_el[0]; - m_el[1] = other.m_el[1]; - m_el[2] = other.m_el[2]; - } - /** @brief Assignment Operator */ - SIMD_FORCE_INLINE btMatrix3x3& operator=(const btMatrix3x3& other) - { - m_el[0] = other.m_el[0]; - m_el[1] = other.m_el[1]; - m_el[2] = other.m_el[2]; - return *this; - } - - /** @brief Get a column of the matrix as a vector - * @param i Column number 0 indexed */ - SIMD_FORCE_INLINE btVector3 getColumn(int i) const - { - return btVector3(m_el[0][i],m_el[1][i],m_el[2][i]); - } - - - /** @brief Get a row of the matrix as a vector - * @param i Row number 0 indexed */ - SIMD_FORCE_INLINE const btVector3& getRow(int i) const - { - btFullAssert(0 <= i && i < 3); - return m_el[i]; - } - - /** @brief Get a mutable reference to a row of the matrix as a vector - * @param i Row number 0 indexed */ - SIMD_FORCE_INLINE btVector3& operator[](int i) - { - btFullAssert(0 <= i && i < 3); - return m_el[i]; - } - - /** @brief Get a const reference to a row of the matrix as a vector - * @param i Row number 0 indexed */ - SIMD_FORCE_INLINE const btVector3& operator[](int i) const - { - btFullAssert(0 <= i && i < 3); - return m_el[i]; - } - - /** @brief Multiply by the target matrix on the right - * @param m Rotation matrix to be applied - * Equivilant to this = this * m */ - btMatrix3x3& operator*=(const btMatrix3x3& m); - - /** @brief Set from a carray of btScalars - * @param m A pointer to the beginning of an array of 9 btScalars */ - void setFromOpenGLSubMatrix(const btScalar *m) - { - m_el[0].setValue(m[0],m[4],m[8]); - m_el[1].setValue(m[1],m[5],m[9]); - m_el[2].setValue(m[2],m[6],m[10]); - - } - /** @brief Set the values of the matrix explicitly (row major) - * @param xx Top left - * @param xy Top Middle - * @param xz Top Right - * @param yx Middle Left - * @param yy Middle Middle - * @param yz Middle Right - * @param zx Bottom Left - * @param zy Bottom Middle - * @param zz Bottom Right*/ - void setValue(const btScalar& xx, const btScalar& xy, const btScalar& xz, - const btScalar& yx, const btScalar& yy, const btScalar& yz, - const btScalar& zx, const btScalar& zy, const btScalar& zz) - { - m_el[0].setValue(xx,xy,xz); - m_el[1].setValue(yx,yy,yz); - m_el[2].setValue(zx,zy,zz); - } - - /** @brief Set the matrix from a quaternion - * @param q The Quaternion to match */ - void setRotation(const btQuaternion& q) - { - btScalar d = q.length2(); - btFullAssert(d != btScalar(0.0)); - btScalar s = btScalar(2.0) / d; - btScalar xs = q.x() * s, ys = q.y() * s, zs = q.z() * s; - btScalar wx = q.w() * xs, wy = q.w() * ys, wz = q.w() * zs; - btScalar xx = q.x() * xs, xy = q.x() * ys, xz = q.x() * zs; - btScalar yy = q.y() * ys, yz = q.y() * zs, zz = q.z() * zs; - setValue(btScalar(1.0) - (yy + zz), xy - wz, xz + wy, - xy + wz, btScalar(1.0) - (xx + zz), yz - wx, - xz - wy, yz + wx, btScalar(1.0) - (xx + yy)); - } - - - /** @brief Set the matrix from euler angles using YPR around YXZ respectively - * @param yaw Yaw about Y axis - * @param pitch Pitch about X axis - * @param roll Roll about Z axis - */ - void setEulerYPR(const btScalar& yaw, const btScalar& pitch, const btScalar& roll) - { - setEulerZYX(roll, pitch, yaw); - } - - /** @brief Set the matrix from euler angles YPR around ZYX axes - * @param eulerX Roll about X axis - * @param eulerY Pitch around Y axis - * @param eulerZ Yaw aboud Z axis - * - * These angles are used to produce a rotation matrix. The euler - * angles are applied in ZYX order. I.e a vector is first rotated - * about X then Y and then Z - **/ - void setEulerZYX(btScalar eulerX,btScalar eulerY,btScalar eulerZ) { - ///@todo proposed to reverse this since it's labeled zyx but takes arguments xyz and it will match all other parts of the code - btScalar ci ( btCos(eulerX)); - btScalar cj ( btCos(eulerY)); - btScalar ch ( btCos(eulerZ)); - btScalar si ( btSin(eulerX)); - btScalar sj ( btSin(eulerY)); - btScalar sh ( btSin(eulerZ)); - btScalar cc = ci * ch; - btScalar cs = ci * sh; - btScalar sc = si * ch; - btScalar ss = si * sh; - - setValue(cj * ch, sj * sc - cs, sj * cc + ss, - cj * sh, sj * ss + cc, sj * cs - sc, - -sj, cj * si, cj * ci); - } - - /**@brief Set the matrix to the identity */ - void setIdentity() - { - setValue(btScalar(1.0), btScalar(0.0), btScalar(0.0), - btScalar(0.0), btScalar(1.0), btScalar(0.0), - btScalar(0.0), btScalar(0.0), btScalar(1.0)); - } - - static const btMatrix3x3& getIdentity() - { - static const btMatrix3x3 identityMatrix(btScalar(1.0), btScalar(0.0), btScalar(0.0), - btScalar(0.0), btScalar(1.0), btScalar(0.0), - btScalar(0.0), btScalar(0.0), btScalar(1.0)); - return identityMatrix; - } - - /**@brief Fill the values of the matrix into a 9 element array - * @param m The array to be filled */ - void getOpenGLSubMatrix(btScalar *m) const - { - m[0] = btScalar(m_el[0].x()); - m[1] = btScalar(m_el[1].x()); - m[2] = btScalar(m_el[2].x()); - m[3] = btScalar(0.0); - m[4] = btScalar(m_el[0].y()); - m[5] = btScalar(m_el[1].y()); - m[6] = btScalar(m_el[2].y()); - m[7] = btScalar(0.0); - m[8] = btScalar(m_el[0].z()); - m[9] = btScalar(m_el[1].z()); - m[10] = btScalar(m_el[2].z()); - m[11] = btScalar(0.0); - } - - /**@brief Get the matrix represented as a quaternion - * @param q The quaternion which will be set */ - void getRotation(btQuaternion& q) const - { - btScalar trace = m_el[0].x() + m_el[1].y() + m_el[2].z(); - btScalar temp[4]; - - if (trace > btScalar(0.0)) - { - btScalar s = btSqrt(trace + btScalar(1.0)); - temp[3]=(s * btScalar(0.5)); - s = btScalar(0.5) / s; - - temp[0]=((m_el[2].y() - m_el[1].z()) * s); - temp[1]=((m_el[0].z() - m_el[2].x()) * s); - temp[2]=((m_el[1].x() - m_el[0].y()) * s); - } - else - { - int i = m_el[0].x() < m_el[1].y() ? - (m_el[1].y() < m_el[2].z() ? 2 : 1) : - (m_el[0].x() < m_el[2].z() ? 2 : 0); - int j = (i + 1) % 3; - int k = (i + 2) % 3; - - btScalar s = btSqrt(m_el[i][i] - m_el[j][j] - m_el[k][k] + btScalar(1.0)); - temp[i] = s * btScalar(0.5); - s = btScalar(0.5) / s; - - temp[3] = (m_el[k][j] - m_el[j][k]) * s; - temp[j] = (m_el[j][i] + m_el[i][j]) * s; - temp[k] = (m_el[k][i] + m_el[i][k]) * s; - } - q.setValue(temp[0],temp[1],temp[2],temp[3]); - } - - /**@brief Get the matrix represented as euler angles around YXZ, roundtrip with setEulerYPR - * @param yaw Yaw around Y axis - * @param pitch Pitch around X axis - * @param roll around Z axis */ - void getEulerYPR(btScalar& yaw, btScalar& pitch, btScalar& roll) const - { - - // first use the normal calculus - yaw = btScalar(btAtan2(m_el[1].x(), m_el[0].x())); - pitch = btScalar(btAsin(-m_el[2].x())); - roll = btScalar(btAtan2(m_el[2].y(), m_el[2].z())); - - // on pitch = +/-HalfPI - if (btFabs(pitch)==SIMD_HALF_PI) - { - if (yaw>0) - yaw-=SIMD_PI; - else - yaw+=SIMD_PI; - - if (roll>0) - roll-=SIMD_PI; - else - roll+=SIMD_PI; - } - }; - - - /**@brief Get the matrix represented as euler angles around ZYX - * @param yaw Yaw around X axis - * @param pitch Pitch around Y axis - * @param roll around X axis - * @param solution_number Which solution of two possible solutions ( 1 or 2) are possible values*/ - void getEulerZYX(btScalar& yaw, btScalar& pitch, btScalar& roll, unsigned int solution_number = 1) const - { - struct Euler - { - btScalar yaw; - btScalar pitch; - btScalar roll; - }; - - Euler euler_out; - Euler euler_out2; //second solution - //get the pointer to the raw data - - // Check that pitch is not at a singularity - if (btFabs(m_el[2].x()) >= 1) - { - euler_out.yaw = 0; - euler_out2.yaw = 0; - - // From difference of angles formula - btScalar delta = btAtan2(m_el[0].x(),m_el[0].z()); - if (m_el[2].x() > 0) //gimbal locked up - { - euler_out.pitch = SIMD_PI / btScalar(2.0); - euler_out2.pitch = SIMD_PI / btScalar(2.0); - euler_out.roll = euler_out.pitch + delta; - euler_out2.roll = euler_out.pitch + delta; - } - else // gimbal locked down - { - euler_out.pitch = -SIMD_PI / btScalar(2.0); - euler_out2.pitch = -SIMD_PI / btScalar(2.0); - euler_out.roll = -euler_out.pitch + delta; - euler_out2.roll = -euler_out.pitch + delta; - } - } - else - { - euler_out.pitch = - btAsin(m_el[2].x()); - euler_out2.pitch = SIMD_PI - euler_out.pitch; - - euler_out.roll = btAtan2(m_el[2].y()/btCos(euler_out.pitch), - m_el[2].z()/btCos(euler_out.pitch)); - euler_out2.roll = btAtan2(m_el[2].y()/btCos(euler_out2.pitch), - m_el[2].z()/btCos(euler_out2.pitch)); - - euler_out.yaw = btAtan2(m_el[1].x()/btCos(euler_out.pitch), - m_el[0].x()/btCos(euler_out.pitch)); - euler_out2.yaw = btAtan2(m_el[1].x()/btCos(euler_out2.pitch), - m_el[0].x()/btCos(euler_out2.pitch)); - } - - if (solution_number == 1) - { - yaw = euler_out.yaw; - pitch = euler_out.pitch; - roll = euler_out.roll; - } - else - { - yaw = euler_out2.yaw; - pitch = euler_out2.pitch; - roll = euler_out2.roll; - } - } - - /**@brief Create a scaled copy of the matrix - * @param s Scaling vector The elements of the vector will scale each column */ - - btMatrix3x3 scaled(const btVector3& s) const - { - return btMatrix3x3(m_el[0].x() * s.x(), m_el[0].y() * s.y(), m_el[0].z() * s.z(), - m_el[1].x() * s.x(), m_el[1].y() * s.y(), m_el[1].z() * s.z(), - m_el[2].x() * s.x(), m_el[2].y() * s.y(), m_el[2].z() * s.z()); - } - - /**@brief Return the determinant of the matrix */ - btScalar determinant() const; - /**@brief Return the adjoint of the matrix */ - btMatrix3x3 adjoint() const; - /**@brief Return the matrix with all values non negative */ - btMatrix3x3 absolute() const; - /**@brief Return the transpose of the matrix */ - btMatrix3x3 transpose() const; - /**@brief Return the inverse of the matrix */ - btMatrix3x3 inverse() const; - - btMatrix3x3 transposeTimes(const btMatrix3x3& m) const; - btMatrix3x3 timesTranspose(const btMatrix3x3& m) const; - - SIMD_FORCE_INLINE btScalar tdotx(const btVector3& v) const - { - return m_el[0].x() * v.x() + m_el[1].x() * v.y() + m_el[2].x() * v.z(); - } - SIMD_FORCE_INLINE btScalar tdoty(const btVector3& v) const - { - return m_el[0].y() * v.x() + m_el[1].y() * v.y() + m_el[2].y() * v.z(); - } - SIMD_FORCE_INLINE btScalar tdotz(const btVector3& v) const - { - return m_el[0].z() * v.x() + m_el[1].z() * v.y() + m_el[2].z() * v.z(); - } - - - /**@brief diagonalizes this matrix by the Jacobi method. - * @param rot stores the rotation from the coordinate system in which the matrix is diagonal to the original - * coordinate system, i.e., old_this = rot * new_this * rot^T. - * @param threshold See iteration - * @param iteration The iteration stops when all off-diagonal elements are less than the threshold multiplied - * by the sum of the absolute values of the diagonal, or when maxSteps have been executed. - * - * Note that this matrix is assumed to be symmetric. - */ - void diagonalize(btMatrix3x3& rot, btScalar threshold, int maxSteps) - { - rot.setIdentity(); - for (int step = maxSteps; step > 0; step--) - { - // find off-diagonal element [p][q] with largest magnitude - int p = 0; - int q = 1; - int r = 2; - btScalar max = btFabs(m_el[0][1]); - btScalar v = btFabs(m_el[0][2]); - if (v > max) - { - q = 2; - r = 1; - max = v; - } - v = btFabs(m_el[1][2]); - if (v > max) - { - p = 1; - q = 2; - r = 0; - max = v; - } - - btScalar t = threshold * (btFabs(m_el[0][0]) + btFabs(m_el[1][1]) + btFabs(m_el[2][2])); - if (max <= t) - { - if (max <= SIMD_EPSILON * t) - { - return; - } - step = 1; - } - - // compute Jacobi rotation J which leads to a zero for element [p][q] - btScalar mpq = m_el[p][q]; - btScalar theta = (m_el[q][q] - m_el[p][p]) / (2 * mpq); - btScalar theta2 = theta * theta; - btScalar cos; - btScalar sin; - if (theta2 * theta2 < btScalar(10 / SIMD_EPSILON)) - { - t = (theta >= 0) ? 1 / (theta + btSqrt(1 + theta2)) - : 1 / (theta - btSqrt(1 + theta2)); - cos = 1 / btSqrt(1 + t * t); - sin = cos * t; - } - else - { - // approximation for large theta-value, i.e., a nearly diagonal matrix - t = 1 / (theta * (2 + btScalar(0.5) / theta2)); - cos = 1 - btScalar(0.5) * t * t; - sin = cos * t; - } - - // apply rotation to matrix (this = J^T * this * J) - m_el[p][q] = m_el[q][p] = 0; - m_el[p][p] -= t * mpq; - m_el[q][q] += t * mpq; - btScalar mrp = m_el[r][p]; - btScalar mrq = m_el[r][q]; - m_el[r][p] = m_el[p][r] = cos * mrp - sin * mrq; - m_el[r][q] = m_el[q][r] = cos * mrq + sin * mrp; - - // apply rotation to rot (rot = rot * J) - for (int i = 0; i < 3; i++) - { - btVector3& row = rot[i]; - mrp = row[p]; - mrq = row[q]; - row[p] = cos * mrp - sin * mrq; - row[q] = cos * mrq + sin * mrp; - } - } - } - - - - - /**@brief Calculate the matrix cofactor - * @param r1 The first row to use for calculating the cofactor - * @param c1 The first column to use for calculating the cofactor - * @param r1 The second row to use for calculating the cofactor - * @param c1 The second column to use for calculating the cofactor - * See http://en.wikipedia.org/wiki/Cofactor_(linear_algebra) for more details - */ - btScalar cofac(int r1, int c1, int r2, int c2) const - { - return m_el[r1][c1] * m_el[r2][c2] - m_el[r1][c2] * m_el[r2][c1]; - } - - virtual void serialize(struct btMatrix3x3Data& dataOut) const; - - virtual void deSerialize(const struct btMatrix3x3Data& dataIn); - -}; - - -SIMD_FORCE_INLINE btMatrix3x3& -btMatrix3x3::operator*=(const btMatrix3x3& m) -{ - setValue(m.tdotx(m_el[0]), m.tdoty(m_el[0]), m.tdotz(m_el[0]), - m.tdotx(m_el[1]), m.tdoty(m_el[1]), m.tdotz(m_el[1]), - m.tdotx(m_el[2]), m.tdoty(m_el[2]), m.tdotz(m_el[2])); - return *this; -} - -SIMD_FORCE_INLINE btScalar -btMatrix3x3::determinant() const -{ - return btTriple((*this)[0], (*this)[1], (*this)[2]); -} - - -SIMD_FORCE_INLINE btMatrix3x3 -btMatrix3x3::absolute() const -{ - return btMatrix3x3( - btFabs(m_el[0].x()), btFabs(m_el[0].y()), btFabs(m_el[0].z()), - btFabs(m_el[1].x()), btFabs(m_el[1].y()), btFabs(m_el[1].z()), - btFabs(m_el[2].x()), btFabs(m_el[2].y()), btFabs(m_el[2].z())); -} - -SIMD_FORCE_INLINE btMatrix3x3 -btMatrix3x3::transpose() const -{ - return btMatrix3x3(m_el[0].x(), m_el[1].x(), m_el[2].x(), - m_el[0].y(), m_el[1].y(), m_el[2].y(), - m_el[0].z(), m_el[1].z(), m_el[2].z()); -} - -SIMD_FORCE_INLINE btMatrix3x3 -btMatrix3x3::adjoint() const -{ - return btMatrix3x3(cofac(1, 1, 2, 2), cofac(0, 2, 2, 1), cofac(0, 1, 1, 2), - cofac(1, 2, 2, 0), cofac(0, 0, 2, 2), cofac(0, 2, 1, 0), - cofac(1, 0, 2, 1), cofac(0, 1, 2, 0), cofac(0, 0, 1, 1)); -} - -SIMD_FORCE_INLINE btMatrix3x3 -btMatrix3x3::inverse() const -{ - btVector3 co(cofac(1, 1, 2, 2), cofac(1, 2, 2, 0), cofac(1, 0, 2, 1)); - btScalar det = (*this)[0].dot(co); - btFullAssert(det != btScalar(0.0)); - btScalar s = btScalar(1.0) / det; - return btMatrix3x3(co.x() * s, cofac(0, 2, 2, 1) * s, cofac(0, 1, 1, 2) * s, - co.y() * s, cofac(0, 0, 2, 2) * s, cofac(0, 2, 1, 0) * s, - co.z() * s, cofac(0, 1, 2, 0) * s, cofac(0, 0, 1, 1) * s); -} - -SIMD_FORCE_INLINE btMatrix3x3 -btMatrix3x3::transposeTimes(const btMatrix3x3& m) const -{ - return btMatrix3x3( - m_el[0].x() * m[0].x() + m_el[1].x() * m[1].x() + m_el[2].x() * m[2].x(), - m_el[0].x() * m[0].y() + m_el[1].x() * m[1].y() + m_el[2].x() * m[2].y(), - m_el[0].x() * m[0].z() + m_el[1].x() * m[1].z() + m_el[2].x() * m[2].z(), - m_el[0].y() * m[0].x() + m_el[1].y() * m[1].x() + m_el[2].y() * m[2].x(), - m_el[0].y() * m[0].y() + m_el[1].y() * m[1].y() + m_el[2].y() * m[2].y(), - m_el[0].y() * m[0].z() + m_el[1].y() * m[1].z() + m_el[2].y() * m[2].z(), - m_el[0].z() * m[0].x() + m_el[1].z() * m[1].x() + m_el[2].z() * m[2].x(), - m_el[0].z() * m[0].y() + m_el[1].z() * m[1].y() + m_el[2].z() * m[2].y(), - m_el[0].z() * m[0].z() + m_el[1].z() * m[1].z() + m_el[2].z() * m[2].z()); -} - -SIMD_FORCE_INLINE btMatrix3x3 -btMatrix3x3::timesTranspose(const btMatrix3x3& m) const -{ - return btMatrix3x3( - m_el[0].dot(m[0]), m_el[0].dot(m[1]), m_el[0].dot(m[2]), - m_el[1].dot(m[0]), m_el[1].dot(m[1]), m_el[1].dot(m[2]), - m_el[2].dot(m[0]), m_el[2].dot(m[1]), m_el[2].dot(m[2])); - -} - -SIMD_FORCE_INLINE btVector3 -operator*(const btMatrix3x3& m, const btVector3& v) -{ - return btVector3(m[0].dot(v), m[1].dot(v), m[2].dot(v)); -} - - -SIMD_FORCE_INLINE btVector3 -operator*(const btVector3& v, const btMatrix3x3& m) -{ - return btVector3(m.tdotx(v), m.tdoty(v), m.tdotz(v)); -} - -SIMD_FORCE_INLINE btMatrix3x3 -operator*(const btMatrix3x3& m1, const btMatrix3x3& m2) -{ - return btMatrix3x3( - m2.tdotx( m1[0]), m2.tdoty( m1[0]), m2.tdotz( m1[0]), - m2.tdotx( m1[1]), m2.tdoty( m1[1]), m2.tdotz( m1[1]), - m2.tdotx( m1[2]), m2.tdoty( m1[2]), m2.tdotz( m1[2])); -} - -/* -SIMD_FORCE_INLINE btMatrix3x3 btMultTransposeLeft(const btMatrix3x3& m1, const btMatrix3x3& m2) { -return btMatrix3x3( -m1[0][0] * m2[0][0] + m1[1][0] * m2[1][0] + m1[2][0] * m2[2][0], -m1[0][0] * m2[0][1] + m1[1][0] * m2[1][1] + m1[2][0] * m2[2][1], -m1[0][0] * m2[0][2] + m1[1][0] * m2[1][2] + m1[2][0] * m2[2][2], -m1[0][1] * m2[0][0] + m1[1][1] * m2[1][0] + m1[2][1] * m2[2][0], -m1[0][1] * m2[0][1] + m1[1][1] * m2[1][1] + m1[2][1] * m2[2][1], -m1[0][1] * m2[0][2] + m1[1][1] * m2[1][2] + m1[2][1] * m2[2][2], -m1[0][2] * m2[0][0] + m1[1][2] * m2[1][0] + m1[2][2] * m2[2][0], -m1[0][2] * m2[0][1] + m1[1][2] * m2[1][1] + m1[2][2] * m2[2][1], -m1[0][2] * m2[0][2] + m1[1][2] * m2[1][2] + m1[2][2] * m2[2][2]); -} -*/ - -/**@brief Equality operator between two matrices -* It will test all elements are equal. */ -SIMD_FORCE_INLINE bool operator==(const btMatrix3x3& m1, const btMatrix3x3& m2) -{ - return ( m1[0][0] == m2[0][0] && m1[1][0] == m2[1][0] && m1[2][0] == m2[2][0] && - m1[0][1] == m2[0][1] && m1[1][1] == m2[1][1] && m1[2][1] == m2[2][1] && - m1[0][2] == m2[0][2] && m1[1][2] == m2[1][2] && m1[2][2] == m2[2][2] ); -} - -///for serialization -struct btMatrix3x3Data -{ - btVector3Data m_el[3]; -}; - - -SIMD_FORCE_INLINE void btMatrix3x3::serialize(struct btMatrix3x3Data& dataOut) const -{ - for (int i=0;i<3;i++) - m_el[i].serialize(dataOut.m_el[i]); -} - -SIMD_FORCE_INLINE void btMatrix3x3::deSerialize(const struct btMatrix3x3Data& dataIn) -{ - for (int i=0;i<3;i++) - m_el[i].deSerialize(dataIn.m_el[i]); -} - -#endif //BT_MATRIX3x3_H - diff --git a/bullet/src/LinearMath/btMinMax.h b/bullet/src/LinearMath/btMinMax.h deleted file mode 100644 index be379ec44..000000000 --- a/bullet/src/LinearMath/btMinMax.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - - -#ifndef GEN_MINMAX_H -#define GEN_MINMAX_H - -template -SIMD_FORCE_INLINE const T& btMin(const T& a, const T& b) -{ - return a < b ? a : b ; -} - -template -SIMD_FORCE_INLINE const T& btMax(const T& a, const T& b) -{ - return a > b ? a : b; -} - -template -SIMD_FORCE_INLINE const T& GEN_clamped(const T& a, const T& lb, const T& ub) -{ - return a < lb ? lb : (ub < a ? ub : a); -} - -template -SIMD_FORCE_INLINE void btSetMin(T& a, const T& b) -{ - if (b < a) - { - a = b; - } -} - -template -SIMD_FORCE_INLINE void btSetMax(T& a, const T& b) -{ - if (a < b) - { - a = b; - } -} - -template -SIMD_FORCE_INLINE void GEN_clamp(T& a, const T& lb, const T& ub) -{ - if (a < lb) - { - a = lb; - } - else if (ub < a) - { - a = ub; - } -} - -#endif diff --git a/bullet/src/LinearMath/btMotionState.h b/bullet/src/LinearMath/btMotionState.h deleted file mode 100644 index c97922665..000000000 --- a/bullet/src/LinearMath/btMotionState.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef BT_MOTIONSTATE_H -#define BT_MOTIONSTATE_H - -#include "btTransform.h" - -///The btMotionState interface class allows the dynamics world to synchronize and interpolate the updated world transforms with graphics -///For optimizations, potentially only moving objects get synchronized (using setWorldPosition/setWorldOrientation) -class btMotionState -{ - public: - - virtual ~btMotionState() - { - - } - - virtual void getWorldTransform(btTransform& worldTrans ) const =0; - - //Bullet only calls the update of worldtransform for active objects - virtual void setWorldTransform(const btTransform& worldTrans)=0; - - -}; - -#endif //BT_MOTIONSTATE_H diff --git a/bullet/src/LinearMath/btPoolAllocator.h b/bullet/src/LinearMath/btPoolAllocator.h deleted file mode 100644 index 8dcfbd6b0..000000000 --- a/bullet/src/LinearMath/btPoolAllocator.h +++ /dev/null @@ -1,102 +0,0 @@ -/* -Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#ifndef _BT_POOL_ALLOCATOR_H -#define _BT_POOL_ALLOCATOR_H - -#include "btScalar.h" -#include "btAlignedAllocator.h" - -///The btPoolAllocator class allows to efficiently allocate a large pool of objects, instead of dynamically allocating them separately. -class btPoolAllocator -{ - int m_elemSize; - int m_maxElements; - int m_freeCount; - void* m_firstFree; - unsigned char* m_pool; - -public: - - btPoolAllocator(int elemSize, int maxElements) - :m_elemSize(elemSize), - m_maxElements(maxElements) - { - m_pool = (unsigned char*) btAlignedAlloc( static_cast(m_elemSize*m_maxElements),16); - - unsigned char* p = m_pool; - m_firstFree = p; - m_freeCount = m_maxElements; - int count = m_maxElements; - while (--count) { - *(void**)p = (p + m_elemSize); - p += m_elemSize; - } - *(void**)p = 0; - } - - ~btPoolAllocator() - { - btAlignedFree( m_pool); - } - - int getFreeCount() const - { - return m_freeCount; - } - - void* allocate(int size) - { - // release mode fix - (void)size; - btAssert(!size || size<=m_elemSize); - btAssert(m_freeCount>0); - void* result = m_firstFree; - m_firstFree = *(void**)m_firstFree; - --m_freeCount; - return result; - } - - bool validPtr(void* ptr) - { - if (ptr) { - if (((unsigned char*)ptr >= m_pool && (unsigned char*)ptr < m_pool + m_maxElements * m_elemSize)) - { - return true; - } - } - return false; - } - - void freeMemory(void* ptr) - { - if (ptr) { - btAssert((unsigned char*)ptr >= m_pool && (unsigned char*)ptr < m_pool + m_maxElements * m_elemSize); - - *(void**)ptr = m_firstFree; - m_firstFree = ptr; - ++m_freeCount; - } - } - - int getElementSize() const - { - return m_elemSize; - } - - -}; - -#endif //_BT_POOL_ALLOCATOR_H diff --git a/bullet/src/LinearMath/btQuadWord.h b/bullet/src/LinearMath/btQuadWord.h deleted file mode 100644 index d8c2e5e9b..000000000 --- a/bullet/src/LinearMath/btQuadWord.h +++ /dev/null @@ -1,180 +0,0 @@ -/* -Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#ifndef SIMD_QUADWORD_H -#define SIMD_QUADWORD_H - -#include "btScalar.h" -#include "btMinMax.h" - - -#if defined (__CELLOS_LV2) && defined (__SPU__) -#include -#endif - -/**@brief The btQuadWord class is base class for btVector3 and btQuaternion. - * Some issues under PS3 Linux with IBM 2.1 SDK, gcc compiler prevent from using aligned quadword. - */ -#ifndef USE_LIBSPE2 -ATTRIBUTE_ALIGNED16(class) btQuadWord -#else -class btQuadWord -#endif -{ -protected: - -#if defined (__SPU__) && defined (__CELLOS_LV2__) - union { - vec_float4 mVec128; - btScalar m_floats[4]; - }; -public: - vec_float4 get128() const - { - return mVec128; - } -protected: -#else //__CELLOS_LV2__ __SPU__ - btScalar m_floats[4]; -#endif //__CELLOS_LV2__ __SPU__ - - public: - - - /**@brief Return the x value */ - SIMD_FORCE_INLINE const btScalar& getX() const { return m_floats[0]; } - /**@brief Return the y value */ - SIMD_FORCE_INLINE const btScalar& getY() const { return m_floats[1]; } - /**@brief Return the z value */ - SIMD_FORCE_INLINE const btScalar& getZ() const { return m_floats[2]; } - /**@brief Set the x value */ - SIMD_FORCE_INLINE void setX(btScalar x) { m_floats[0] = x;}; - /**@brief Set the y value */ - SIMD_FORCE_INLINE void setY(btScalar y) { m_floats[1] = y;}; - /**@brief Set the z value */ - SIMD_FORCE_INLINE void setZ(btScalar z) { m_floats[2] = z;}; - /**@brief Set the w value */ - SIMD_FORCE_INLINE void setW(btScalar w) { m_floats[3] = w;}; - /**@brief Return the x value */ - SIMD_FORCE_INLINE const btScalar& x() const { return m_floats[0]; } - /**@brief Return the y value */ - SIMD_FORCE_INLINE const btScalar& y() const { return m_floats[1]; } - /**@brief Return the z value */ - SIMD_FORCE_INLINE const btScalar& z() const { return m_floats[2]; } - /**@brief Return the w value */ - SIMD_FORCE_INLINE const btScalar& w() const { return m_floats[3]; } - - //SIMD_FORCE_INLINE btScalar& operator[](int i) { return (&m_floats[0])[i]; } - //SIMD_FORCE_INLINE const btScalar& operator[](int i) const { return (&m_floats[0])[i]; } - ///operator btScalar*() replaces operator[], using implicit conversion. We added operator != and operator == to avoid pointer comparisons. - SIMD_FORCE_INLINE operator btScalar *() { return &m_floats[0]; } - SIMD_FORCE_INLINE operator const btScalar *() const { return &m_floats[0]; } - - SIMD_FORCE_INLINE bool operator==(const btQuadWord& other) const - { - return ((m_floats[3]==other.m_floats[3]) && (m_floats[2]==other.m_floats[2]) && (m_floats[1]==other.m_floats[1]) && (m_floats[0]==other.m_floats[0])); - } - - SIMD_FORCE_INLINE bool operator!=(const btQuadWord& other) const - { - return !(*this == other); - } - - /**@brief Set x,y,z and zero w - * @param x Value of x - * @param y Value of y - * @param z Value of z - */ - SIMD_FORCE_INLINE void setValue(const btScalar& x, const btScalar& y, const btScalar& z) - { - m_floats[0]=x; - m_floats[1]=y; - m_floats[2]=z; - m_floats[3] = 0.f; - } - -/* void getValue(btScalar *m) const - { - m[0] = m_floats[0]; - m[1] = m_floats[1]; - m[2] = m_floats[2]; - } -*/ -/**@brief Set the values - * @param x Value of x - * @param y Value of y - * @param z Value of z - * @param w Value of w - */ - SIMD_FORCE_INLINE void setValue(const btScalar& x, const btScalar& y, const btScalar& z,const btScalar& w) - { - m_floats[0]=x; - m_floats[1]=y; - m_floats[2]=z; - m_floats[3]=w; - } - /**@brief No initialization constructor */ - SIMD_FORCE_INLINE btQuadWord() - // :m_floats[0](btScalar(0.)),m_floats[1](btScalar(0.)),m_floats[2](btScalar(0.)),m_floats[3](btScalar(0.)) - { - } - - /**@brief Three argument constructor (zeros w) - * @param x Value of x - * @param y Value of y - * @param z Value of z - */ - SIMD_FORCE_INLINE btQuadWord(const btScalar& x, const btScalar& y, const btScalar& z) - { - m_floats[0] = x, m_floats[1] = y, m_floats[2] = z, m_floats[3] = 0.0f; - } - -/**@brief Initializing constructor - * @param x Value of x - * @param y Value of y - * @param z Value of z - * @param w Value of w - */ - SIMD_FORCE_INLINE btQuadWord(const btScalar& x, const btScalar& y, const btScalar& z,const btScalar& w) - { - m_floats[0] = x, m_floats[1] = y, m_floats[2] = z, m_floats[3] = w; - } - - /**@brief Set each element to the max of the current values and the values of another btQuadWord - * @param other The other btQuadWord to compare with - */ - SIMD_FORCE_INLINE void setMax(const btQuadWord& other) - { - btSetMax(m_floats[0], other.m_floats[0]); - btSetMax(m_floats[1], other.m_floats[1]); - btSetMax(m_floats[2], other.m_floats[2]); - btSetMax(m_floats[3], other.m_floats[3]); - } - /**@brief Set each element to the min of the current values and the values of another btQuadWord - * @param other The other btQuadWord to compare with - */ - SIMD_FORCE_INLINE void setMin(const btQuadWord& other) - { - btSetMin(m_floats[0], other.m_floats[0]); - btSetMin(m_floats[1], other.m_floats[1]); - btSetMin(m_floats[2], other.m_floats[2]); - btSetMin(m_floats[3], other.m_floats[3]); - } - - - -}; - -#endif //SIMD_QUADWORD_H diff --git a/bullet/src/LinearMath/btQuaternion.h b/bullet/src/LinearMath/btQuaternion.h deleted file mode 100644 index d557aa8f9..000000000 --- a/bullet/src/LinearMath/btQuaternion.h +++ /dev/null @@ -1,433 +0,0 @@ -/* -Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - - -#ifndef SIMD__QUATERNION_H_ -#define SIMD__QUATERNION_H_ - - -#include "btVector3.h" -#include "btQuadWord.h" - -/**@brief The btQuaternion implements quaternion to perform linear algebra rotations in combination with btMatrix3x3, btVector3 and btTransform. */ -class btQuaternion : public btQuadWord { -public: - /**@brief No initialization constructor */ - btQuaternion() {} - - // template - // explicit Quaternion(const btScalar *v) : Tuple4(v) {} - /**@brief Constructor from scalars */ - btQuaternion(const btScalar& x, const btScalar& y, const btScalar& z, const btScalar& w) - : btQuadWord(x, y, z, w) - {} - /**@brief Axis angle Constructor - * @param axis The axis which the rotation is around - * @param angle The magnitude of the rotation around the angle (Radians) */ - btQuaternion(const btVector3& axis, const btScalar& angle) - { - setRotation(axis, angle); - } - /**@brief Constructor from Euler angles - * @param yaw Angle around Y unless BT_EULER_DEFAULT_ZYX defined then Z - * @param pitch Angle around X unless BT_EULER_DEFAULT_ZYX defined then Y - * @param roll Angle around Z unless BT_EULER_DEFAULT_ZYX defined then X */ - btQuaternion(const btScalar& yaw, const btScalar& pitch, const btScalar& roll) - { -#ifndef BT_EULER_DEFAULT_ZYX - setEuler(yaw, pitch, roll); -#else - setEulerZYX(yaw, pitch, roll); -#endif - } - /**@brief Set the rotation using axis angle notation - * @param axis The axis around which to rotate - * @param angle The magnitude of the rotation in Radians */ - void setRotation(const btVector3& axis, const btScalar& angle) - { - btScalar d = axis.length(); - btAssert(d != btScalar(0.0)); - btScalar s = btSin(angle * btScalar(0.5)) / d; - setValue(axis.x() * s, axis.y() * s, axis.z() * s, - btCos(angle * btScalar(0.5))); - } - /**@brief Set the quaternion using Euler angles - * @param yaw Angle around Y - * @param pitch Angle around X - * @param roll Angle around Z */ - void setEuler(const btScalar& yaw, const btScalar& pitch, const btScalar& roll) - { - btScalar halfYaw = btScalar(yaw) * btScalar(0.5); - btScalar halfPitch = btScalar(pitch) * btScalar(0.5); - btScalar halfRoll = btScalar(roll) * btScalar(0.5); - btScalar cosYaw = btCos(halfYaw); - btScalar sinYaw = btSin(halfYaw); - btScalar cosPitch = btCos(halfPitch); - btScalar sinPitch = btSin(halfPitch); - btScalar cosRoll = btCos(halfRoll); - btScalar sinRoll = btSin(halfRoll); - setValue(cosRoll * sinPitch * cosYaw + sinRoll * cosPitch * sinYaw, - cosRoll * cosPitch * sinYaw - sinRoll * sinPitch * cosYaw, - sinRoll * cosPitch * cosYaw - cosRoll * sinPitch * sinYaw, - cosRoll * cosPitch * cosYaw + sinRoll * sinPitch * sinYaw); - } - /**@brief Set the quaternion using euler angles - * @param yaw Angle around Z - * @param pitch Angle around Y - * @param roll Angle around X */ - void setEulerZYX(const btScalar& yaw, const btScalar& pitch, const btScalar& roll) - { - btScalar halfYaw = btScalar(yaw) * btScalar(0.5); - btScalar halfPitch = btScalar(pitch) * btScalar(0.5); - btScalar halfRoll = btScalar(roll) * btScalar(0.5); - btScalar cosYaw = btCos(halfYaw); - btScalar sinYaw = btSin(halfYaw); - btScalar cosPitch = btCos(halfPitch); - btScalar sinPitch = btSin(halfPitch); - btScalar cosRoll = btCos(halfRoll); - btScalar sinRoll = btSin(halfRoll); - setValue(sinRoll * cosPitch * cosYaw - cosRoll * sinPitch * sinYaw, //x - cosRoll * sinPitch * cosYaw + sinRoll * cosPitch * sinYaw, //y - cosRoll * cosPitch * sinYaw - sinRoll * sinPitch * cosYaw, //z - cosRoll * cosPitch * cosYaw + sinRoll * sinPitch * sinYaw); //formerly yzx - } - /**@brief Add two quaternions - * @param q The quaternion to add to this one */ - SIMD_FORCE_INLINE btQuaternion& operator+=(const btQuaternion& q) - { - m_floats[0] += q.x(); m_floats[1] += q.y(); m_floats[2] += q.z(); m_floats[3] += q.m_floats[3]; - return *this; - } - - /**@brief Subtract out a quaternion - * @param q The quaternion to subtract from this one */ - btQuaternion& operator-=(const btQuaternion& q) - { - m_floats[0] -= q.x(); m_floats[1] -= q.y(); m_floats[2] -= q.z(); m_floats[3] -= q.m_floats[3]; - return *this; - } - - /**@brief Scale this quaternion - * @param s The scalar to scale by */ - btQuaternion& operator*=(const btScalar& s) - { - m_floats[0] *= s; m_floats[1] *= s; m_floats[2] *= s; m_floats[3] *= s; - return *this; - } - - /**@brief Multiply this quaternion by q on the right - * @param q The other quaternion - * Equivilant to this = this * q */ - btQuaternion& operator*=(const btQuaternion& q) - { - setValue(m_floats[3] * q.x() + m_floats[0] * q.m_floats[3] + m_floats[1] * q.z() - m_floats[2] * q.y(), - m_floats[3] * q.y() + m_floats[1] * q.m_floats[3] + m_floats[2] * q.x() - m_floats[0] * q.z(), - m_floats[3] * q.z() + m_floats[2] * q.m_floats[3] + m_floats[0] * q.y() - m_floats[1] * q.x(), - m_floats[3] * q.m_floats[3] - m_floats[0] * q.x() - m_floats[1] * q.y() - m_floats[2] * q.z()); - return *this; - } - /**@brief Return the dot product between this quaternion and another - * @param q The other quaternion */ - btScalar dot(const btQuaternion& q) const - { - return m_floats[0] * q.x() + m_floats[1] * q.y() + m_floats[2] * q.z() + m_floats[3] * q.m_floats[3]; - } - - /**@brief Return the length squared of the quaternion */ - btScalar length2() const - { - return dot(*this); - } - - /**@brief Return the length of the quaternion */ - btScalar length() const - { - return btSqrt(length2()); - } - - /**@brief Normalize the quaternion - * Such that x^2 + y^2 + z^2 +w^2 = 1 */ - btQuaternion& normalize() - { - return *this /= length(); - } - - /**@brief Return a scaled version of this quaternion - * @param s The scale factor */ - SIMD_FORCE_INLINE btQuaternion - operator*(const btScalar& s) const - { - return btQuaternion(x() * s, y() * s, z() * s, m_floats[3] * s); - } - - - /**@brief Return an inversely scaled versionof this quaternion - * @param s The inverse scale factor */ - btQuaternion operator/(const btScalar& s) const - { - btAssert(s != btScalar(0.0)); - return *this * (btScalar(1.0) / s); - } - - /**@brief Inversely scale this quaternion - * @param s The scale factor */ - btQuaternion& operator/=(const btScalar& s) - { - btAssert(s != btScalar(0.0)); - return *this *= btScalar(1.0) / s; - } - - /**@brief Return a normalized version of this quaternion */ - btQuaternion normalized() const - { - return *this / length(); - } - /**@brief Return the angle between this quaternion and the other - * @param q The other quaternion */ - btScalar angle(const btQuaternion& q) const - { - btScalar s = btSqrt(length2() * q.length2()); - btAssert(s != btScalar(0.0)); - return btAcos(dot(q) / s); - } - /**@brief Return the angle of rotation represented by this quaternion */ - btScalar getAngle() const - { - btScalar s = btScalar(2.) * btAcos(m_floats[3]); - return s; - } - - /**@brief Return the axis of the rotation represented by this quaternion */ - btVector3 getAxis() const - { - btScalar s_squared = btScalar(1.) - btPow(m_floats[3], btScalar(2.)); - if (s_squared < btScalar(10.) * SIMD_EPSILON) //Check for divide by zero - return btVector3(1.0, 0.0, 0.0); // Arbitrary - btScalar s = btSqrt(s_squared); - return btVector3(m_floats[0] / s, m_floats[1] / s, m_floats[2] / s); - } - - /**@brief Return the inverse of this quaternion */ - btQuaternion inverse() const - { - return btQuaternion(-m_floats[0], -m_floats[1], -m_floats[2], m_floats[3]); - } - - /**@brief Return the sum of this quaternion and the other - * @param q2 The other quaternion */ - SIMD_FORCE_INLINE btQuaternion - operator+(const btQuaternion& q2) const - { - const btQuaternion& q1 = *this; - return btQuaternion(q1.x() + q2.x(), q1.y() + q2.y(), q1.z() + q2.z(), q1.m_floats[3] + q2.m_floats[3]); - } - - /**@brief Return the difference between this quaternion and the other - * @param q2 The other quaternion */ - SIMD_FORCE_INLINE btQuaternion - operator-(const btQuaternion& q2) const - { - const btQuaternion& q1 = *this; - return btQuaternion(q1.x() - q2.x(), q1.y() - q2.y(), q1.z() - q2.z(), q1.m_floats[3] - q2.m_floats[3]); - } - - /**@brief Return the negative of this quaternion - * This simply negates each element */ - SIMD_FORCE_INLINE btQuaternion operator-() const - { - const btQuaternion& q2 = *this; - return btQuaternion( - q2.x(), - q2.y(), - q2.z(), - q2.m_floats[3]); - } - /**@todo document this and it's use */ - SIMD_FORCE_INLINE btQuaternion farthest( const btQuaternion& qd) const - { - btQuaternion diff,sum; - diff = *this - qd; - sum = *this + qd; - if( diff.dot(diff) > sum.dot(sum) ) - return qd; - return (-qd); - } - - /**@todo document this and it's use */ - SIMD_FORCE_INLINE btQuaternion nearest( const btQuaternion& qd) const - { - btQuaternion diff,sum; - diff = *this - qd; - sum = *this + qd; - if( diff.dot(diff) < sum.dot(sum) ) - return qd; - return (-qd); - } - - - /**@brief Return the quaternion which is the result of Spherical Linear Interpolation between this and the other quaternion - * @param q The other quaternion to interpolate with - * @param t The ratio between this and q to interpolate. If t = 0 the result is this, if t=1 the result is q. - * Slerp interpolates assuming constant velocity. */ - btQuaternion slerp(const btQuaternion& q, const btScalar& t) const - { - btScalar theta = angle(q); - if (theta != btScalar(0.0)) - { - btScalar d = btScalar(1.0) / btSin(theta); - btScalar s0 = btSin((btScalar(1.0) - t) * theta); - btScalar s1 = btSin(t * theta); - if (dot(q) < 0) // Take care of long angle case see http://en.wikipedia.org/wiki/Slerp - return btQuaternion((m_floats[0] * s0 + -q.x() * s1) * d, - (m_floats[1] * s0 + -q.y() * s1) * d, - (m_floats[2] * s0 + -q.z() * s1) * d, - (m_floats[3] * s0 + -q.m_floats[3] * s1) * d); - else - return btQuaternion((m_floats[0] * s0 + q.x() * s1) * d, - (m_floats[1] * s0 + q.y() * s1) * d, - (m_floats[2] * s0 + q.z() * s1) * d, - (m_floats[3] * s0 + q.m_floats[3] * s1) * d); - - } - else - { - return *this; - } - } - - static const btQuaternion& getIdentity() - { - static const btQuaternion identityQuat(btScalar(0.),btScalar(0.),btScalar(0.),btScalar(1.)); - return identityQuat; - } - - SIMD_FORCE_INLINE const btScalar& getW() const { return m_floats[3]; } - - -}; - - -/**@brief Return the negative of a quaternion */ -SIMD_FORCE_INLINE btQuaternion -operator-(const btQuaternion& q) -{ - return btQuaternion(-q.x(), -q.y(), -q.z(), -q.w()); -} - - - -/**@brief Return the product of two quaternions */ -SIMD_FORCE_INLINE btQuaternion -operator*(const btQuaternion& q1, const btQuaternion& q2) { - return btQuaternion(q1.w() * q2.x() + q1.x() * q2.w() + q1.y() * q2.z() - q1.z() * q2.y(), - q1.w() * q2.y() + q1.y() * q2.w() + q1.z() * q2.x() - q1.x() * q2.z(), - q1.w() * q2.z() + q1.z() * q2.w() + q1.x() * q2.y() - q1.y() * q2.x(), - q1.w() * q2.w() - q1.x() * q2.x() - q1.y() * q2.y() - q1.z() * q2.z()); -} - -SIMD_FORCE_INLINE btQuaternion -operator*(const btQuaternion& q, const btVector3& w) -{ - return btQuaternion( q.w() * w.x() + q.y() * w.z() - q.z() * w.y(), - q.w() * w.y() + q.z() * w.x() - q.x() * w.z(), - q.w() * w.z() + q.x() * w.y() - q.y() * w.x(), - -q.x() * w.x() - q.y() * w.y() - q.z() * w.z()); -} - -SIMD_FORCE_INLINE btQuaternion -operator*(const btVector3& w, const btQuaternion& q) -{ - return btQuaternion( w.x() * q.w() + w.y() * q.z() - w.z() * q.y(), - w.y() * q.w() + w.z() * q.x() - w.x() * q.z(), - w.z() * q.w() + w.x() * q.y() - w.y() * q.x(), - -w.x() * q.x() - w.y() * q.y() - w.z() * q.z()); -} - -/**@brief Calculate the dot product between two quaternions */ -SIMD_FORCE_INLINE btScalar -dot(const btQuaternion& q1, const btQuaternion& q2) -{ - return q1.dot(q2); -} - - -/**@brief Return the length of a quaternion */ -SIMD_FORCE_INLINE btScalar -length(const btQuaternion& q) -{ - return q.length(); -} - -/**@brief Return the angle between two quaternions*/ -SIMD_FORCE_INLINE btScalar -angle(const btQuaternion& q1, const btQuaternion& q2) -{ - return q1.angle(q2); -} - -/**@brief Return the inverse of a quaternion*/ -SIMD_FORCE_INLINE btQuaternion -inverse(const btQuaternion& q) -{ - return q.inverse(); -} - -/**@brief Return the result of spherical linear interpolation betwen two quaternions - * @param q1 The first quaternion - * @param q2 The second quaternion - * @param t The ration between q1 and q2. t = 0 return q1, t=1 returns q2 - * Slerp assumes constant velocity between positions. */ -SIMD_FORCE_INLINE btQuaternion -slerp(const btQuaternion& q1, const btQuaternion& q2, const btScalar& t) -{ - return q1.slerp(q2, t); -} - -SIMD_FORCE_INLINE btVector3 -quatRotate(const btQuaternion& rotation, const btVector3& v) -{ - btQuaternion q = rotation * v; - q *= rotation.inverse(); - return btVector3(q.getX(),q.getY(),q.getZ()); -} - -SIMD_FORCE_INLINE btQuaternion -shortestArcQuat(const btVector3& v0, const btVector3& v1) // Game Programming Gems 2.10. make sure v0,v1 are normalized -{ - btVector3 c = v0.cross(v1); - btScalar d = v0.dot(v1); - - if (d < -1.0 + SIMD_EPSILON) - { - btVector3 n,unused; - btPlaneSpace1(v0,n,unused); - return btQuaternion(n.x(),n.y(),n.z(),0.0f); // just pick any vector that is orthogonal to v0 - } - - btScalar s = btSqrt((1.0f + d) * 2.0f); - btScalar rs = 1.0f / s; - - return btQuaternion(c.getX()*rs,c.getY()*rs,c.getZ()*rs,s * 0.5f); -} - -SIMD_FORCE_INLINE btQuaternion -shortestArcQuatNormalize2(btVector3& v0,btVector3& v1) -{ - v0.normalize(); - v1.normalize(); - return shortestArcQuat(v0,v1); -} - -#endif - - - - diff --git a/bullet/src/LinearMath/btQuickprof.cpp b/bullet/src/LinearMath/btQuickprof.cpp deleted file mode 100644 index 15f67b946..000000000 --- a/bullet/src/LinearMath/btQuickprof.cpp +++ /dev/null @@ -1,346 +0,0 @@ -/* - -/*************************************************************************************************** -** -** profile.cpp -** -** Real-Time Hierarchical Profiling for Game Programming Gems 3 -** -** by Greg Hjelstrom & Byon Garrabrant -** -***************************************************************************************************/ - -// Credits: The Clock class was inspired by the Timer classes in -// Ogre (www.ogre3d.org). - -#include "LinearMath/btQuickprof.h" - - -#ifdef USE_BT_CLOCK - -static btClock gProfileClock; - -inline void Profile_Get_Ticks(unsigned long int * ticks) -{ - *ticks = gProfileClock.getTimeMicroseconds(); -} - -inline float Profile_Get_Tick_Rate(void) -{ -// return 1000000.f; - return 1000.f; - -} - - - -/*************************************************************************************************** -** -** CProfileNode -** -***************************************************************************************************/ - -/*********************************************************************************************** - * INPUT: * - * name - pointer to a static string which is the name of this profile node * - * parent - parent pointer * - * * - * WARNINGS: * - * The name is assumed to be a static pointer, only the pointer is stored and compared for * - * efficiency reasons. * - *=============================================================================================*/ -CProfileNode::CProfileNode( const char * name, CProfileNode * parent ) : - Name( name ), - TotalCalls( 0 ), - TotalTime( 0 ), - StartTime( 0 ), - RecursionCounter( 0 ), - Parent( parent ), - Child( NULL ), - Sibling( NULL ) -{ - Reset(); -} - - -void CProfileNode::CleanupMemory() -{ - delete ( Child); - Child = NULL; - delete ( Sibling); - Sibling = NULL; -} - -CProfileNode::~CProfileNode( void ) -{ - delete ( Child); - delete ( Sibling); -} - - -/*********************************************************************************************** - * INPUT: * - * name - static string pointer to the name of the node we are searching for * - * * - * WARNINGS: * - * All profile names are assumed to be static strings so this function uses pointer compares * - * to find the named node. * - *=============================================================================================*/ -CProfileNode * CProfileNode::Get_Sub_Node( const char * name ) -{ - // Try to find this sub node - CProfileNode * child = Child; - while ( child ) { - if ( child->Name == name ) { - return child; - } - child = child->Sibling; - } - - // We didn't find it, so add it - - CProfileNode * node = new CProfileNode( name, this ); - node->Sibling = Child; - Child = node; - return node; -} - - -void CProfileNode::Reset( void ) -{ - TotalCalls = 0; - TotalTime = 0.0f; - - - if ( Child ) { - Child->Reset(); - } - if ( Sibling ) { - Sibling->Reset(); - } -} - - -void CProfileNode::Call( void ) -{ - TotalCalls++; - if (RecursionCounter++ == 0) { - Profile_Get_Ticks(&StartTime); - } -} - - -bool CProfileNode::Return( void ) -{ - if ( --RecursionCounter == 0 && TotalCalls != 0 ) { - unsigned long int time; - Profile_Get_Ticks(&time); - time-=StartTime; - TotalTime += (float)time / Profile_Get_Tick_Rate(); - } - return ( RecursionCounter == 0 ); -} - - -/*************************************************************************************************** -** -** CProfileIterator -** -***************************************************************************************************/ -CProfileIterator::CProfileIterator( CProfileNode * start ) -{ - CurrentParent = start; - CurrentChild = CurrentParent->Get_Child(); -} - - -void CProfileIterator::First(void) -{ - CurrentChild = CurrentParent->Get_Child(); -} - - -void CProfileIterator::Next(void) -{ - CurrentChild = CurrentChild->Get_Sibling(); -} - - -bool CProfileIterator::Is_Done(void) -{ - return CurrentChild == NULL; -} - - -void CProfileIterator::Enter_Child( int index ) -{ - CurrentChild = CurrentParent->Get_Child(); - while ( (CurrentChild != NULL) && (index != 0) ) { - index--; - CurrentChild = CurrentChild->Get_Sibling(); - } - - if ( CurrentChild != NULL ) { - CurrentParent = CurrentChild; - CurrentChild = CurrentParent->Get_Child(); - } -} - - -void CProfileIterator::Enter_Parent( void ) -{ - if ( CurrentParent->Get_Parent() != NULL ) { - CurrentParent = CurrentParent->Get_Parent(); - } - CurrentChild = CurrentParent->Get_Child(); -} - - -/*************************************************************************************************** -** -** CProfileManager -** -***************************************************************************************************/ - -CProfileNode CProfileManager::Root( "Root", NULL ); -CProfileNode * CProfileManager::CurrentNode = &CProfileManager::Root; -int CProfileManager::FrameCounter = 0; -unsigned long int CProfileManager::ResetTime = 0; - - -/*********************************************************************************************** - * CProfileManager::Start_Profile -- Begin a named profile * - * * - * Steps one level deeper into the tree, if a child already exists with the specified name * - * then it accumulates the profiling; otherwise a new child node is added to the profile tree. * - * * - * INPUT: * - * name - name of this profiling record * - * * - * WARNINGS: * - * The string used is assumed to be a static string; pointer compares are used throughout * - * the profiling code for efficiency. * - *=============================================================================================*/ -void CProfileManager::Start_Profile( const char * name ) -{ - if (name != CurrentNode->Get_Name()) { - CurrentNode = CurrentNode->Get_Sub_Node( name ); - } - - CurrentNode->Call(); -} - - -/*********************************************************************************************** - * CProfileManager::Stop_Profile -- Stop timing and record the results. * - *=============================================================================================*/ -void CProfileManager::Stop_Profile( void ) -{ - // Return will indicate whether we should back up to our parent (we may - // be profiling a recursive function) - if (CurrentNode->Return()) { - CurrentNode = CurrentNode->Get_Parent(); - } -} - - -/*********************************************************************************************** - * CProfileManager::Reset -- Reset the contents of the profiling system * - * * - * This resets everything except for the tree structure. All of the timing data is reset. * - *=============================================================================================*/ -void CProfileManager::Reset( void ) -{ - gProfileClock.reset(); - Root.Reset(); - Root.Call(); - FrameCounter = 0; - Profile_Get_Ticks(&ResetTime); -} - - -/*********************************************************************************************** - * CProfileManager::Increment_Frame_Counter -- Increment the frame counter * - *=============================================================================================*/ -void CProfileManager::Increment_Frame_Counter( void ) -{ - FrameCounter++; -} - - -/*********************************************************************************************** - * CProfileManager::Get_Time_Since_Reset -- returns the elapsed time since last reset * - *=============================================================================================*/ -float CProfileManager::Get_Time_Since_Reset( void ) -{ - unsigned long int time; - Profile_Get_Ticks(&time); - time -= ResetTime; - return (float)time / Profile_Get_Tick_Rate(); -} - -#include - -void CProfileManager::dumpRecursive(CProfileIterator* profileIterator, int spacing) -{ - profileIterator->First(); - if (profileIterator->Is_Done()) - return; - - float accumulated_time=0,parent_time = profileIterator->Is_Root() ? CProfileManager::Get_Time_Since_Reset() : profileIterator->Get_Current_Parent_Total_Time(); - int i; - int frames_since_reset = CProfileManager::Get_Frame_Count_Since_Reset(); - for (i=0;iGet_Current_Parent_Name(), parent_time ); - float totalTime = 0.f; - - - int numChildren = 0; - - for (i = 0; !profileIterator->Is_Done(); i++,profileIterator->Next()) - { - numChildren++; - float current_total_time = profileIterator->Get_Current_Total_Time(); - accumulated_time += current_total_time; - float fraction = parent_time > SIMD_EPSILON ? (current_total_time / parent_time) * 100 : 0.f; - { - int i; for (i=0;iGet_Current_Name(), fraction,(current_total_time / (double)frames_since_reset),profileIterator->Get_Current_Total_Calls()); - totalTime += current_total_time; - //recurse into children - } - - if (parent_time < accumulated_time) - { - printf("what's wrong\n"); - } - for (i=0;i SIMD_EPSILON ? ((parent_time - accumulated_time) / parent_time) * 100 : 0.f, parent_time - accumulated_time); - - for (i=0;iEnter_Child(i); - dumpRecursive(profileIterator,spacing+3); - profileIterator->Enter_Parent(); - } -} - - - -void CProfileManager::dumpAll() -{ - CProfileIterator* profileIterator = 0; - profileIterator = CProfileManager::Get_Iterator(); - - dumpRecursive(profileIterator,0); - - CProfileManager::Release_Iterator(profileIterator); -} - - - -#endif //USE_BT_CLOCK - diff --git a/bullet/src/LinearMath/btQuickprof.h b/bullet/src/LinearMath/btQuickprof.h deleted file mode 100644 index 9c1e09eb8..000000000 --- a/bullet/src/LinearMath/btQuickprof.h +++ /dev/null @@ -1,370 +0,0 @@ - -/*************************************************************************************************** -** -** Real-Time Hierarchical Profiling for Game Programming Gems 3 -** -** by Greg Hjelstrom & Byon Garrabrant -** -***************************************************************************************************/ - -// Credits: The Clock class was inspired by the Timer classes in -// Ogre (www.ogre3d.org). - - - -#ifndef QUICK_PROF_H -#define QUICK_PROF_H - -//To disable built-in profiling, please comment out next line -//#define BT_NO_PROFILE 1 -#ifndef BT_NO_PROFILE - -#include "btScalar.h" -#include "LinearMath/btAlignedAllocator.h" -#include - - - - -//if you don't need btClock, you can comment next line -#define USE_BT_CLOCK 1 - -#ifdef USE_BT_CLOCK -#ifdef __CELLOS_LV2__ -#include -#include -#include -#endif - -#if defined (SUNOS) || defined (__SUNOS__) -#include -#endif - -#if defined(WIN32) || defined(_WIN32) - -#define USE_WINDOWS_TIMERS -#define WIN32_LEAN_AND_MEAN -#define NOWINRES -#define NOMCX -#define NOIME -#ifdef _XBOX -#include -#else -#include -#endif -#include - -#else -#include -#endif - -#define mymin(a,b) (a > b ? a : b) - -///The btClock is a portable basic clock that measures accurate time in seconds, use for profiling. -class btClock -{ -public: - btClock() - { -#ifdef USE_WINDOWS_TIMERS - QueryPerformanceFrequency(&mClockFrequency); -#endif - reset(); - } - - ~btClock() - { - } - - /// Resets the initial reference time. - void reset() - { -#ifdef USE_WINDOWS_TIMERS - QueryPerformanceCounter(&mStartTime); - mStartTick = GetTickCount(); - mPrevElapsedTime = 0; -#else -#ifdef __CELLOS_LV2__ - - typedef uint64_t ClockSize; - ClockSize newTime; - //__asm __volatile__( "mftb %0" : "=r" (newTime) : : "memory"); - SYS_TIMEBASE_GET( newTime ); - mStartTime = newTime; -#else - gettimeofday(&mStartTime, 0); -#endif - -#endif - } - - /// Returns the time in ms since the last call to reset or since - /// the btClock was created. - unsigned long int getTimeMilliseconds() - { -#ifdef USE_WINDOWS_TIMERS - LARGE_INTEGER currentTime; - QueryPerformanceCounter(¤tTime); - LONGLONG elapsedTime = currentTime.QuadPart - - mStartTime.QuadPart; - - // Compute the number of millisecond ticks elapsed. - unsigned long msecTicks = (unsigned long)(1000 * elapsedTime / - mClockFrequency.QuadPart); - - // Check for unexpected leaps in the Win32 performance counter. - // (This is caused by unexpected data across the PCI to ISA - // bridge, aka south bridge. See Microsoft KB274323.) - unsigned long elapsedTicks = GetTickCount() - mStartTick; - signed long msecOff = (signed long)(msecTicks - elapsedTicks); - if (msecOff < -100 || msecOff > 100) - { - // Adjust the starting time forwards. - LONGLONG msecAdjustment = mymin(msecOff * - mClockFrequency.QuadPart / 1000, elapsedTime - - mPrevElapsedTime); - mStartTime.QuadPart += msecAdjustment; - elapsedTime -= msecAdjustment; - - // Recompute the number of millisecond ticks elapsed. - msecTicks = (unsigned long)(1000 * elapsedTime / - mClockFrequency.QuadPart); - } - - // Store the current elapsed time for adjustments next time. - mPrevElapsedTime = elapsedTime; - - return msecTicks; -#else - -#ifdef __CELLOS_LV2__ - uint64_t freq=sys_time_get_timebase_frequency(); - double dFreq=((double) freq) / 1000.0; - typedef uint64_t ClockSize; - ClockSize newTime; - SYS_TIMEBASE_GET( newTime ); - //__asm __volatile__( "mftb %0" : "=r" (newTime) : : "memory"); - - return (unsigned long int)((double(newTime-mStartTime)) / dFreq); -#else - - struct timeval currentTime; - gettimeofday(¤tTime, 0); - return (currentTime.tv_sec - mStartTime.tv_sec) * 1000 + - (currentTime.tv_usec - mStartTime.tv_usec) / 1000; -#endif //__CELLOS_LV2__ -#endif - } - - /// Returns the time in us since the last call to reset or since - /// the Clock was created. - unsigned long int getTimeMicroseconds() - { -#ifdef USE_WINDOWS_TIMERS - LARGE_INTEGER currentTime; - QueryPerformanceCounter(¤tTime); - LONGLONG elapsedTime = currentTime.QuadPart - - mStartTime.QuadPart; - - // Compute the number of millisecond ticks elapsed. - unsigned long msecTicks = (unsigned long)(1000 * elapsedTime / - mClockFrequency.QuadPart); - - // Check for unexpected leaps in the Win32 performance counter. - // (This is caused by unexpected data across the PCI to ISA - // bridge, aka south bridge. See Microsoft KB274323.) - unsigned long elapsedTicks = GetTickCount() - mStartTick; - signed long msecOff = (signed long)(msecTicks - elapsedTicks); - if (msecOff < -100 || msecOff > 100) - { - // Adjust the starting time forwards. - LONGLONG msecAdjustment = mymin(msecOff * - mClockFrequency.QuadPart / 1000, elapsedTime - - mPrevElapsedTime); - mStartTime.QuadPart += msecAdjustment; - elapsedTime -= msecAdjustment; - } - - // Store the current elapsed time for adjustments next time. - mPrevElapsedTime = elapsedTime; - - // Convert to microseconds. - unsigned long usecTicks = (unsigned long)(1000000 * elapsedTime / - mClockFrequency.QuadPart); - - return usecTicks; -#else - -#ifdef __CELLOS_LV2__ - uint64_t freq=sys_time_get_timebase_frequency(); - double dFreq=((double) freq)/ 1000000.0; - typedef uint64_t ClockSize; - ClockSize newTime; - //__asm __volatile__( "mftb %0" : "=r" (newTime) : : "memory"); - SYS_TIMEBASE_GET( newTime ); - - return (unsigned long int)((double(newTime-mStartTime)) / dFreq); -#else - - struct timeval currentTime; - gettimeofday(¤tTime, 0); - return (currentTime.tv_sec - mStartTime.tv_sec) * 1000000 + - (currentTime.tv_usec - mStartTime.tv_usec); -#endif//__CELLOS_LV2__ -#endif - } - -private: -#ifdef USE_WINDOWS_TIMERS - LARGE_INTEGER mClockFrequency; - DWORD mStartTick; - LONGLONG mPrevElapsedTime; - LARGE_INTEGER mStartTime; -#else -#ifdef __CELLOS_LV2__ - uint64_t mStartTime; -#else - struct timeval mStartTime; -#endif -#endif //__CELLOS_LV2__ - -}; - -#endif //USE_BT_CLOCK - - - - -///A node in the Profile Hierarchy Tree -class CProfileNode { - -public: - CProfileNode( const char * name, CProfileNode * parent ); - ~CProfileNode( void ); - - CProfileNode * Get_Sub_Node( const char * name ); - - CProfileNode * Get_Parent( void ) { return Parent; } - CProfileNode * Get_Sibling( void ) { return Sibling; } - CProfileNode * Get_Child( void ) { return Child; } - - void CleanupMemory(); - void Reset( void ); - void Call( void ); - bool Return( void ); - - const char * Get_Name( void ) { return Name; } - int Get_Total_Calls( void ) { return TotalCalls; } - float Get_Total_Time( void ) { return TotalTime; } - -protected: - - const char * Name; - int TotalCalls; - float TotalTime; - unsigned long int StartTime; - int RecursionCounter; - - CProfileNode * Parent; - CProfileNode * Child; - CProfileNode * Sibling; -}; - -///An iterator to navigate through the tree -class CProfileIterator -{ -public: - // Access all the children of the current parent - void First(void); - void Next(void); - bool Is_Done(void); - bool Is_Root(void) { return (CurrentParent->Get_Parent() == 0); } - - void Enter_Child( int index ); // Make the given child the new parent - void Enter_Largest_Child( void ); // Make the largest child the new parent - void Enter_Parent( void ); // Make the current parent's parent the new parent - - // Access the current child - const char * Get_Current_Name( void ) { return CurrentChild->Get_Name(); } - int Get_Current_Total_Calls( void ) { return CurrentChild->Get_Total_Calls(); } - float Get_Current_Total_Time( void ) { return CurrentChild->Get_Total_Time(); } - - // Access the current parent - const char * Get_Current_Parent_Name( void ) { return CurrentParent->Get_Name(); } - int Get_Current_Parent_Total_Calls( void ) { return CurrentParent->Get_Total_Calls(); } - float Get_Current_Parent_Total_Time( void ) { return CurrentParent->Get_Total_Time(); } - -protected: - - CProfileNode * CurrentParent; - CProfileNode * CurrentChild; - - CProfileIterator( CProfileNode * start ); - friend class CProfileManager; -}; - - -///The Manager for the Profile system -class CProfileManager { -public: - static void Start_Profile( const char * name ); - static void Stop_Profile( void ); - - static void CleanupMemory(void) - { - Root.CleanupMemory(); - } - - static void Reset( void ); - static void Increment_Frame_Counter( void ); - static int Get_Frame_Count_Since_Reset( void ) { return FrameCounter; } - static float Get_Time_Since_Reset( void ); - - static CProfileIterator * Get_Iterator( void ) - { - - return new CProfileIterator( &Root ); - } - static void Release_Iterator( CProfileIterator * iterator ) { delete ( iterator); } - - static void dumpRecursive(CProfileIterator* profileIterator, int spacing); - - static void dumpAll(); - -private: - static CProfileNode Root; - static CProfileNode * CurrentNode; - static int FrameCounter; - static unsigned long int ResetTime; -}; - - -///ProfileSampleClass is a simple way to profile a function's scope -///Use the BT_PROFILE macro at the start of scope to time -class CProfileSample { -public: - CProfileSample( const char * name ) - { - CProfileManager::Start_Profile( name ); - } - - ~CProfileSample( void ) - { - CProfileManager::Stop_Profile(); - } -}; - - -#define BT_PROFILE( name ) CProfileSample __profile( name ) - -#else - -#define BT_PROFILE( name ) - -#endif //#ifndef BT_NO_PROFILE - - - -#endif //QUICK_PROF_H - - diff --git a/bullet/src/LinearMath/btRandom.h b/bullet/src/LinearMath/btRandom.h deleted file mode 100644 index ebd6c390f..000000000 --- a/bullet/src/LinearMath/btRandom.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - - -#ifndef GEN_RANDOM_H -#define GEN_RANDOM_H - -#ifdef MT19937 - -#include -#include - -#define GEN_RAND_MAX UINT_MAX - -SIMD_FORCE_INLINE void GEN_srand(unsigned int seed) { init_genrand(seed); } -SIMD_FORCE_INLINE unsigned int GEN_rand() { return genrand_int32(); } - -#else - -#include - -#define GEN_RAND_MAX RAND_MAX - -SIMD_FORCE_INLINE void GEN_srand(unsigned int seed) { srand(seed); } -SIMD_FORCE_INLINE unsigned int GEN_rand() { return rand(); } - -#endif - -#endif - diff --git a/bullet/src/LinearMath/btScalar.h b/bullet/src/LinearMath/btScalar.h deleted file mode 100644 index 70994c19d..000000000 --- a/bullet/src/LinearMath/btScalar.h +++ /dev/null @@ -1,505 +0,0 @@ -/* -Copyright (c) 2003-2009 Erwin Coumans http://bullet.googlecode.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - - -#ifndef SIMD___SCALAR_H -#define SIMD___SCALAR_H - -#include -#include //size_t for MSVC 6.0 -#include -#include -#include - -/* SVN $Revision$ on $Date$ from http://bullet.googlecode.com*/ -#define BT_BULLET_VERSION 275 - -inline int btGetVersion() -{ - return BT_BULLET_VERSION; -} - -#if defined(DEBUG) || defined (_DEBUG) -#define BT_DEBUG -#endif - - -#ifdef WIN32 - - #if defined(__MINGW32__) || defined(__CYGWIN__) || (defined (_MSC_VER) && _MSC_VER < 1300) - - #define SIMD_FORCE_INLINE inline - #define ATTRIBUTE_ALIGNED16(a) a - #define ATTRIBUTE_ALIGNED128(a) a - #else - //#define BT_HAS_ALIGNED_ALLOCATOR - #pragma warning(disable : 4324) // disable padding warning -// #pragma warning(disable:4530) // Disable the exception disable but used in MSCV Stl warning. -// #pragma warning(disable:4996) //Turn off warnings about deprecated C routines -// #pragma warning(disable:4786) // Disable the "debug name too long" warning - - #define SIMD_FORCE_INLINE __forceinline - #define ATTRIBUTE_ALIGNED16(a) __declspec(align(16)) a - #define ATTRIBUTE_ALIGNED128(a) __declspec (align(128)) a - #ifdef _XBOX - #define BT_USE_VMX128 - - #include - #define BT_HAVE_NATIVE_FSEL - #define btFsel(a,b,c) __fsel((a),(b),(c)) - #else - -#if (defined (WIN32) && (_MSC_VER) && _MSC_VER >= 1400) && (!defined (BT_USE_DOUBLE_PRECISION)) - #define BT_USE_SSE - #include -#endif - - #endif//_XBOX - - #endif //__MINGW32__ - - #include -#ifdef BT_DEBUG - #define btAssert assert -#else - #define btAssert(x) -#endif - //btFullAssert is optional, slows down a lot - #define btFullAssert(x) - - #define btLikely(_c) _c - #define btUnlikely(_c) _c - -#else - -#if defined (__CELLOS_LV2__) - #define SIMD_FORCE_INLINE inline - #define ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16))) - #define ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128))) - #ifndef assert - #include - #endif -#ifdef BT_DEBUG - #define btAssert assert -#else - #define btAssert(x) -#endif - //btFullAssert is optional, slows down a lot - #define btFullAssert(x) - - #define btLikely(_c) _c - #define btUnlikely(_c) _c - -#else - -#ifdef USE_LIBSPE2 - - #define SIMD_FORCE_INLINE __inline - #define ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16))) - #define ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128))) - #ifndef assert - #include - #endif -#ifdef BT_DEBUG - #define btAssert assert -#else - #define btAssert(x) -#endif - //btFullAssert is optional, slows down a lot - #define btFullAssert(x) - - - #define btLikely(_c) __builtin_expect((_c), 1) - #define btUnlikely(_c) __builtin_expect((_c), 0) - - -#else - //non-windows systems - -#if (defined (__APPLE__) && defined (__i386__) && (!defined (BT_USE_DOUBLE_PRECISION))) - #define BT_USE_SSE - #include - - #define SIMD_FORCE_INLINE inline -///@todo: check out alignment methods for other platforms/compilers - #define ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16))) - #define ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128))) - #ifndef assert - #include - #endif - - #if defined(DEBUG) || defined (_DEBUG) - #define btAssert assert - #else - #define btAssert(x) - #endif - - //btFullAssert is optional, slows down a lot - #define btFullAssert(x) - #define btLikely(_c) _c - #define btUnlikely(_c) _c - -#else - - #define SIMD_FORCE_INLINE inline - ///@todo: check out alignment methods for other platforms/compilers - ///#define ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16))) - ///#define ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128))) - #define ATTRIBUTE_ALIGNED16(a) a - #define ATTRIBUTE_ALIGNED128(a) a - #ifndef assert - #include - #endif - -#if defined(DEBUG) || defined (_DEBUG) - #define btAssert assert -#else - #define btAssert(x) -#endif - - //btFullAssert is optional, slows down a lot - #define btFullAssert(x) - #define btLikely(_c) _c - #define btUnlikely(_c) _c -#endif //__APPLE__ - -#endif // LIBSPE2 - -#endif //__CELLOS_LV2__ -#endif - - -///The btScalar type abstracts floating point numbers, to easily switch between double and single floating point precision. -#if defined(BT_USE_DOUBLE_PRECISION) -typedef double btScalar; -//this number could be bigger in double precision -#define BT_LARGE_FLOAT 1e30 -#else -typedef float btScalar; -//keep BT_LARGE_FLOAT*BT_LARGE_FLOAT < FLT_MAX -#define BT_LARGE_FLOAT 1e18f -#endif - - - -#define BT_DECLARE_ALIGNED_ALLOCATOR() \ - SIMD_FORCE_INLINE void* operator new(size_t sizeInBytes) { return btAlignedAlloc(sizeInBytes,16); } \ - SIMD_FORCE_INLINE void operator delete(void* ptr) { btAlignedFree(ptr); } \ - SIMD_FORCE_INLINE void* operator new(size_t, void* ptr) { return ptr; } \ - SIMD_FORCE_INLINE void operator delete(void*, void*) { } \ - SIMD_FORCE_INLINE void* operator new[](size_t sizeInBytes) { return btAlignedAlloc(sizeInBytes,16); } \ - SIMD_FORCE_INLINE void operator delete[](void* ptr) { btAlignedFree(ptr); } \ - SIMD_FORCE_INLINE void* operator new[](size_t, void* ptr) { return ptr; } \ - SIMD_FORCE_INLINE void operator delete[](void*, void*) { } \ - - - -#if defined(BT_USE_DOUBLE_PRECISION) || defined(BT_FORCE_DOUBLE_FUNCTIONS) - -SIMD_FORCE_INLINE btScalar btSqrt(btScalar x) { return sqrt(x); } -SIMD_FORCE_INLINE btScalar btFabs(btScalar x) { return fabs(x); } -SIMD_FORCE_INLINE btScalar btCos(btScalar x) { return cos(x); } -SIMD_FORCE_INLINE btScalar btSin(btScalar x) { return sin(x); } -SIMD_FORCE_INLINE btScalar btTan(btScalar x) { return tan(x); } -SIMD_FORCE_INLINE btScalar btAcos(btScalar x) { if (xbtScalar(1)) x=btScalar(1); return acos(x); } -SIMD_FORCE_INLINE btScalar btAsin(btScalar x) { if (xbtScalar(1)) x=btScalar(1); return asin(x); } -SIMD_FORCE_INLINE btScalar btAtan(btScalar x) { return atan(x); } -SIMD_FORCE_INLINE btScalar btAtan2(btScalar x, btScalar y) { return atan2(x, y); } -SIMD_FORCE_INLINE btScalar btExp(btScalar x) { return exp(x); } -SIMD_FORCE_INLINE btScalar btLog(btScalar x) { return log(x); } -SIMD_FORCE_INLINE btScalar btPow(btScalar x,btScalar y) { return pow(x,y); } -SIMD_FORCE_INLINE btScalar btFmod(btScalar x,btScalar y) { return fmod(x,y); } - -#else - -SIMD_FORCE_INLINE btScalar btSqrt(btScalar y) -{ -#ifdef USE_APPROXIMATION - double x, z, tempf; - unsigned long *tfptr = ((unsigned long *)&tempf) + 1; - - tempf = y; - *tfptr = (0xbfcdd90a - *tfptr)>>1; /* estimate of 1/sqrt(y) */ - x = tempf; - z = y*btScalar(0.5); /* hoist out the /2 */ - x = (btScalar(1.5)*x)-(x*x)*(x*z); /* iteration formula */ - x = (btScalar(1.5)*x)-(x*x)*(x*z); - x = (btScalar(1.5)*x)-(x*x)*(x*z); - x = (btScalar(1.5)*x)-(x*x)*(x*z); - x = (btScalar(1.5)*x)-(x*x)*(x*z); - return x*y; -#else - return sqrtf(y); -#endif -} -SIMD_FORCE_INLINE btScalar btFabs(btScalar x) { return fabsf(x); } -SIMD_FORCE_INLINE btScalar btCos(btScalar x) { return cosf(x); } -SIMD_FORCE_INLINE btScalar btSin(btScalar x) { return sinf(x); } -SIMD_FORCE_INLINE btScalar btTan(btScalar x) { return tanf(x); } -SIMD_FORCE_INLINE btScalar btAcos(btScalar x) { - btAssert(x <= btScalar(1.)); - if (xbtScalar(1)) - x=btScalar(1); - return acosf(x); -} -SIMD_FORCE_INLINE btScalar btAsin(btScalar x) { - if (xbtScalar(1)) - x=btScalar(1); - return asinf(x); -} -SIMD_FORCE_INLINE btScalar btAtan(btScalar x) { return atanf(x); } -SIMD_FORCE_INLINE btScalar btAtan2(btScalar x, btScalar y) { return atan2f(x, y); } -SIMD_FORCE_INLINE btScalar btExp(btScalar x) { return expf(x); } -SIMD_FORCE_INLINE btScalar btLog(btScalar x) { return logf(x); } -SIMD_FORCE_INLINE btScalar btPow(btScalar x,btScalar y) { return powf(x,y); } -SIMD_FORCE_INLINE btScalar btFmod(btScalar x,btScalar y) { return fmodf(x,y); } - -#endif - -#define SIMD_2_PI btScalar(6.283185307179586232) -#define SIMD_PI (SIMD_2_PI * btScalar(0.5)) -#define SIMD_HALF_PI (SIMD_2_PI * btScalar(0.25)) -#define SIMD_RADS_PER_DEG (SIMD_2_PI / btScalar(360.0)) -#define SIMD_DEGS_PER_RAD (btScalar(360.0) / SIMD_2_PI) -#define SIMDSQRT12 btScalar(0.7071067811865475244008443621048490) - -#define btRecipSqrt(x) ((btScalar)(btScalar(1.0)/btSqrt(btScalar(x)))) /* reciprocal square root */ - - -#ifdef BT_USE_DOUBLE_PRECISION -#define SIMD_EPSILON DBL_EPSILON -#define SIMD_INFINITY DBL_MAX -#else -#define SIMD_EPSILON FLT_EPSILON -#define SIMD_INFINITY FLT_MAX -#endif - -SIMD_FORCE_INLINE btScalar btAtan2Fast(btScalar y, btScalar x) -{ - btScalar coeff_1 = SIMD_PI / 4.0f; - btScalar coeff_2 = 3.0f * coeff_1; - btScalar abs_y = btFabs(y); - btScalar angle; - if (x >= 0.0f) { - btScalar r = (x - abs_y) / (x + abs_y); - angle = coeff_1 - coeff_1 * r; - } else { - btScalar r = (x + abs_y) / (abs_y - x); - angle = coeff_2 - coeff_1 * r; - } - return (y < 0.0f) ? -angle : angle; -} - -SIMD_FORCE_INLINE bool btFuzzyZero(btScalar x) { return btFabs(x) < SIMD_EPSILON; } - -SIMD_FORCE_INLINE bool btEqual(btScalar a, btScalar eps) { - return (((a) <= eps) && !((a) < -eps)); -} -SIMD_FORCE_INLINE bool btGreaterEqual (btScalar a, btScalar eps) { - return (!((a) <= eps)); -} - - -SIMD_FORCE_INLINE int btIsNegative(btScalar x) { - return x < btScalar(0.0) ? 1 : 0; -} - -SIMD_FORCE_INLINE btScalar btRadians(btScalar x) { return x * SIMD_RADS_PER_DEG; } -SIMD_FORCE_INLINE btScalar btDegrees(btScalar x) { return x * SIMD_DEGS_PER_RAD; } - -#define BT_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name - -#ifndef btFsel -SIMD_FORCE_INLINE btScalar btFsel(btScalar a, btScalar b, btScalar c) -{ - return a >= 0 ? b : c; -} -#endif -#define btFsels(a,b,c) (btScalar)btFsel(a,b,c) - - -SIMD_FORCE_INLINE bool btMachineIsLittleEndian() -{ - long int i = 1; - const char *p = (const char *) &i; - if (p[0] == 1) // Lowest address contains the least significant byte - return true; - else - return false; -} - - - -///btSelect avoids branches, which makes performance much better for consoles like Playstation 3 and XBox 360 -///Thanks Phil Knight. See also http://www.cellperformance.com/articles/2006/04/more_techniques_for_eliminatin_1.html -SIMD_FORCE_INLINE unsigned btSelect(unsigned condition, unsigned valueIfConditionNonZero, unsigned valueIfConditionZero) -{ - // Set testNz to 0xFFFFFFFF if condition is nonzero, 0x00000000 if condition is zero - // Rely on positive value or'ed with its negative having sign bit on - // and zero value or'ed with its negative (which is still zero) having sign bit off - // Use arithmetic shift right, shifting the sign bit through all 32 bits - unsigned testNz = (unsigned)(((int)condition | -(int)condition) >> 31); - unsigned testEqz = ~testNz; - return ((valueIfConditionNonZero & testNz) | (valueIfConditionZero & testEqz)); -} -SIMD_FORCE_INLINE int btSelect(unsigned condition, int valueIfConditionNonZero, int valueIfConditionZero) -{ - unsigned testNz = (unsigned)(((int)condition | -(int)condition) >> 31); - unsigned testEqz = ~testNz; - return static_cast((valueIfConditionNonZero & testNz) | (valueIfConditionZero & testEqz)); -} -SIMD_FORCE_INLINE float btSelect(unsigned condition, float valueIfConditionNonZero, float valueIfConditionZero) -{ -#ifdef BT_HAVE_NATIVE_FSEL - return (float)btFsel((btScalar)condition - btScalar(1.0f), valueIfConditionNonZero, valueIfConditionZero); -#else - return (condition != 0) ? valueIfConditionNonZero : valueIfConditionZero; -#endif -} - -template SIMD_FORCE_INLINE void btSwap(T& a, T& b) -{ - T tmp = a; - a = b; - b = tmp; -} - - -//PCK: endian swapping functions -SIMD_FORCE_INLINE unsigned btSwapEndian(unsigned val) -{ - return (((val & 0xff000000) >> 24) | ((val & 0x00ff0000) >> 8) | ((val & 0x0000ff00) << 8) | ((val & 0x000000ff) << 24)); -} - -SIMD_FORCE_INLINE unsigned short btSwapEndian(unsigned short val) -{ - return static_cast(((val & 0xff00) >> 8) | ((val & 0x00ff) << 8)); -} - -SIMD_FORCE_INLINE unsigned btSwapEndian(int val) -{ - return btSwapEndian((unsigned)val); -} - -SIMD_FORCE_INLINE unsigned short btSwapEndian(short val) -{ - return btSwapEndian((unsigned short) val); -} - -///btSwapFloat uses using char pointers to swap the endianness -////btSwapFloat/btSwapDouble will NOT return a float, because the machine might 'correct' invalid floating point values -///Not all values of sign/exponent/mantissa are valid floating point numbers according to IEEE 754. -///When a floating point unit is faced with an invalid value, it may actually change the value, or worse, throw an exception. -///In most systems, running user mode code, you wouldn't get an exception, but instead the hardware/os/runtime will 'fix' the number for you. -///so instead of returning a float/double, we return integer/long long integer -SIMD_FORCE_INLINE unsigned int btSwapEndianFloat(float d) -{ - unsigned int a = 0; - unsigned char *dst = (unsigned char *)&a; - unsigned char *src = (unsigned char *)&d; - - dst[0] = src[3]; - dst[1] = src[2]; - dst[2] = src[1]; - dst[3] = src[0]; - return a; -} - -// unswap using char pointers -SIMD_FORCE_INLINE float btUnswapEndianFloat(unsigned int a) -{ - float d = 0.0f; - unsigned char *src = (unsigned char *)&a; - unsigned char *dst = (unsigned char *)&d; - - dst[0] = src[3]; - dst[1] = src[2]; - dst[2] = src[1]; - dst[3] = src[0]; - - return d; -} - - -// swap using char pointers -SIMD_FORCE_INLINE void btSwapEndianDouble(double d, unsigned char* dst) -{ - unsigned char *src = (unsigned char *)&d; - - dst[0] = src[7]; - dst[1] = src[6]; - dst[2] = src[5]; - dst[3] = src[4]; - dst[4] = src[3]; - dst[5] = src[2]; - dst[6] = src[1]; - dst[7] = src[0]; - -} - -// unswap using char pointers -SIMD_FORCE_INLINE double btUnswapEndianDouble(const unsigned char *src) -{ - double d = 0.0; - unsigned char *dst = (unsigned char *)&d; - - dst[0] = src[7]; - dst[1] = src[6]; - dst[2] = src[5]; - dst[3] = src[4]; - dst[4] = src[3]; - dst[5] = src[2]; - dst[6] = src[1]; - dst[7] = src[0]; - - return d; -} - -// returns normalized value in range [-SIMD_PI, SIMD_PI] -SIMD_FORCE_INLINE btScalar btNormalizeAngle(btScalar angleInRadians) -{ - angleInRadians = btFmod(angleInRadians, SIMD_2_PI); - if(angleInRadians < -SIMD_PI) - { - return angleInRadians + SIMD_2_PI; - } - else if(angleInRadians > SIMD_PI) - { - return angleInRadians - SIMD_2_PI; - } - else - { - return angleInRadians; - } -} - -///rudimentary class to provide type info -struct btTypedObject -{ - btTypedObject(int objectType) - :m_objectType(objectType) - { - } - int m_objectType; - inline int getObjectType() const - { - return m_objectType; - } -}; -#endif //SIMD___SCALAR_H diff --git a/bullet/src/LinearMath/btSerializer.h b/bullet/src/LinearMath/btSerializer.h deleted file mode 100644 index 636b8f1dc..000000000 --- a/bullet/src/LinearMath/btSerializer.h +++ /dev/null @@ -1,288 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef BT_SERIALIZER_H -#define BT_SERIALIZER_H - -#include "btScalar.h" // has definitions like SIMD_FORCE_INLINE -#include "btStackAlloc.h" - -class btChunk -{ -public: - int m_chunkCode; - int m_length; - void *m_oldPtr; - int m_dna_nr; - int m_number; -}; - - -///Allow to serialize data in a chunk format -class btSerializer -{ - public: - - virtual ~btSerializer() {} - - virtual btChunk* allocate(size_t size,int numElements) = 0; - -}; - - -#define BT_HEADER_LENGTH 12 - - -class btDefaultSerializer -{ -public: - - btAlignedObjectArray mTypes; - btAlignedObjectArray mStructs; - btAlignedObjectArray mTlens; - btHashMap mStructReverse; - btHashMap mTypeLookup; - - btAlignedObjectArray m_chunkPtrs; - - int m_totalSize; - unsigned char* m_buffer; - int m_bufferPointer; - - - - - void* m_dna; - int m_dnaLength; - - - btDefaultSerializer(int totalSize) - :m_totalSize(totalSize), - m_bufferPointer(0) -// m_dna(0), -// m_dnaLength(0) - { - m_buffer = (unsigned char*)btAlignedAlloc(16,totalSize); - m_bufferPointer += BT_HEADER_LENGTH; - - memcpy(m_buffer, "BULLET ", 7); - int endian= 1; - endian= ((char*)&endian)[0]; - - if (endian) - { - m_buffer[7] = '_'; - } else - { - m_buffer[7] = '-'; - } - if (sizeof(void*)==8) - { - m_buffer[8]='V'; - } else - { - m_buffer[8]='v'; - } - - m_buffer[9] = '2'; - m_buffer[10] = '7'; - m_buffer[11] = '5'; - - - - } - - virtual ~btDefaultSerializer() - { - btAlignedFree(m_buffer); - } - - int getReverseType(const char *type) const - { - - btHashString key(type); - const int* valuePtr = mTypeLookup.find(key); - if (valuePtr) - return *valuePtr; - - return -1; - } - - void writeDNA() - { - unsigned char* dnaTarget = m_buffer+m_bufferPointer; - memcpy(dnaTarget,m_dna,m_dnaLength); - m_bufferPointer += m_dnaLength; - } - - virtual btChunk* allocate(size_t size, int numElements) - { - - unsigned char* ptr = m_buffer+m_bufferPointer; - m_bufferPointer += size*numElements+sizeof(btChunk); - - unsigned char* data = ptr + sizeof(btChunk); - - btChunk* chunk = (btChunk*)ptr; - chunk->m_chunkCode = 0; - chunk->m_oldPtr = data; - chunk->m_length = size; - chunk->m_number = numElements; - - m_chunkPtrs.push_back(chunk); - - return chunk; - } - - - void initDNA(const char* bdna,int dnalen) - { - - m_dna = btAlignedAlloc(dnalen,16); - memcpy(m_dna,bdna,dnalen); - m_dnaLength = dnalen; - - int *intPtr=0;short *shtPtr=0; - char *cp = 0;int dataLen =0;long nr=0; - intPtr = (int*)bdna; - - /* - SDNA (4 bytes) (magic number) - NAME (4 bytes) - (4 bytes) amount of names (int) - - - */ - - if (strncmp((const char*)bdna, "SDNA", 4)==0) - { - // skip ++ NAME - intPtr++; intPtr++; - } - - // Parse names - - dataLen = *intPtr; - intPtr++; - - cp = (char*)intPtr; - for (int i=0; i amount of types (int) - - - */ - - intPtr = (int*)cp; - assert(strncmp(cp, "TYPE", 4)==0); intPtr++; - - dataLen = *intPtr; - intPtr++; - - cp = (char*)intPtr; - for (int i=0; i (short) the lengths of types - - */ - - // Parse type lens - intPtr = (int*)cp; - assert(strncmp(cp, "TLEN", 4)==0); intPtr++; - - dataLen = (int)mTypes.size(); - - shtPtr = (short*)intPtr; - for (int i=0; i amount of structs (int) - - - - - - - */ - - intPtr = (int*)shtPtr; - cp = (char*)intPtr; - assert(strncmp(cp, "STRC", 4)==0); intPtr++; - - dataLen = *intPtr; - intPtr++; - - - shtPtr = (short*)intPtr; - for (int i=0; i(totalsize - usedsize); - } - - unsigned char* allocate(unsigned int size) - { - const unsigned int nus(usedsize+size); - if(nusprevious = current; - pb->address = data+usedsize; - current = pb; - return(pb); - } - SIMD_FORCE_INLINE void endBlock(btBlock* block) - { - btAssert(block==current); - //Raise(L"Unmatched blocks"); - if(block==current) - { - current = block->previous; - usedsize = (unsigned int)((block->address-data)-sizeof(btBlock)); - } - } - -private: - void ctor() - { - data = 0; - totalsize = 0; - usedsize = 0; - current = 0; - ischild = false; - } - unsigned char* data; - unsigned int totalsize; - unsigned int usedsize; - btBlock* current; - bool ischild; -}; - -#endif //BT_STACK_ALLOC diff --git a/bullet/src/LinearMath/btTransform.h b/bullet/src/LinearMath/btTransform.h deleted file mode 100644 index 6e97f61ac..000000000 --- a/bullet/src/LinearMath/btTransform.h +++ /dev/null @@ -1,265 +0,0 @@ -/* -Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - - -#ifndef btTransform_H -#define btTransform_H - - -#include "btMatrix3x3.h" - - - -/**@brief The btTransform class supports rigid transforms with only translation and rotation and no scaling/shear. - *It can be used in combination with btVector3, btQuaternion and btMatrix3x3 linear algebra classes. */ -class btTransform { - - ///Storage for the rotation - btMatrix3x3 m_basis; - ///Storage for the translation - btVector3 m_origin; - -public: - - /**@brief No initialization constructor */ - btTransform() {} - /**@brief Constructor from btQuaternion (optional btVector3 ) - * @param q Rotation from quaternion - * @param c Translation from Vector (default 0,0,0) */ - explicit SIMD_FORCE_INLINE btTransform(const btQuaternion& q, - const btVector3& c = btVector3(btScalar(0), btScalar(0), btScalar(0))) - : m_basis(q), - m_origin(c) - {} - - /**@brief Constructor from btMatrix3x3 (optional btVector3) - * @param b Rotation from Matrix - * @param c Translation from Vector default (0,0,0)*/ - explicit SIMD_FORCE_INLINE btTransform(const btMatrix3x3& b, - const btVector3& c = btVector3(btScalar(0), btScalar(0), btScalar(0))) - : m_basis(b), - m_origin(c) - {} - /**@brief Copy constructor */ - SIMD_FORCE_INLINE btTransform (const btTransform& other) - : m_basis(other.m_basis), - m_origin(other.m_origin) - { - } - /**@brief Assignment Operator */ - SIMD_FORCE_INLINE btTransform& operator=(const btTransform& other) - { - m_basis = other.m_basis; - m_origin = other.m_origin; - return *this; - } - - - /**@brief Set the current transform as the value of the product of two transforms - * @param t1 Transform 1 - * @param t2 Transform 2 - * This = Transform1 * Transform2 */ - SIMD_FORCE_INLINE void mult(const btTransform& t1, const btTransform& t2) { - m_basis = t1.m_basis * t2.m_basis; - m_origin = t1(t2.m_origin); - } - -/* void multInverseLeft(const btTransform& t1, const btTransform& t2) { - btVector3 v = t2.m_origin - t1.m_origin; - m_basis = btMultTransposeLeft(t1.m_basis, t2.m_basis); - m_origin = v * t1.m_basis; - } - */ - -/**@brief Return the transform of the vector */ - SIMD_FORCE_INLINE btVector3 operator()(const btVector3& x) const - { - return btVector3(m_basis[0].dot(x) + m_origin.x(), - m_basis[1].dot(x) + m_origin.y(), - m_basis[2].dot(x) + m_origin.z()); - } - - /**@brief Return the transform of the vector */ - SIMD_FORCE_INLINE btVector3 operator*(const btVector3& x) const - { - return (*this)(x); - } - - /**@brief Return the transform of the btQuaternion */ - SIMD_FORCE_INLINE btQuaternion operator*(const btQuaternion& q) const - { - return getRotation() * q; - } - - /**@brief Return the basis matrix for the rotation */ - SIMD_FORCE_INLINE btMatrix3x3& getBasis() { return m_basis; } - /**@brief Return the basis matrix for the rotation */ - SIMD_FORCE_INLINE const btMatrix3x3& getBasis() const { return m_basis; } - - /**@brief Return the origin vector translation */ - SIMD_FORCE_INLINE btVector3& getOrigin() { return m_origin; } - /**@brief Return the origin vector translation */ - SIMD_FORCE_INLINE const btVector3& getOrigin() const { return m_origin; } - - /**@brief Return a quaternion representing the rotation */ - btQuaternion getRotation() const { - btQuaternion q; - m_basis.getRotation(q); - return q; - } - - - /**@brief Set from an array - * @param m A pointer to a 15 element array (12 rotation(row major padded on the right by 1), and 3 translation */ - void setFromOpenGLMatrix(const btScalar *m) - { - m_basis.setFromOpenGLSubMatrix(m); - m_origin.setValue(m[12],m[13],m[14]); - } - - /**@brief Fill an array representation - * @param m A pointer to a 15 element array (12 rotation(row major padded on the right by 1), and 3 translation */ - void getOpenGLMatrix(btScalar *m) const - { - m_basis.getOpenGLSubMatrix(m); - m[12] = m_origin.x(); - m[13] = m_origin.y(); - m[14] = m_origin.z(); - m[15] = btScalar(1.0); - } - - /**@brief Set the translational element - * @param origin The vector to set the translation to */ - SIMD_FORCE_INLINE void setOrigin(const btVector3& origin) - { - m_origin = origin; - } - - SIMD_FORCE_INLINE btVector3 invXform(const btVector3& inVec) const; - - - /**@brief Set the rotational element by btMatrix3x3 */ - SIMD_FORCE_INLINE void setBasis(const btMatrix3x3& basis) - { - m_basis = basis; - } - - /**@brief Set the rotational element by btQuaternion */ - SIMD_FORCE_INLINE void setRotation(const btQuaternion& q) - { - m_basis.setRotation(q); - } - - - /**@brief Set this transformation to the identity */ - void setIdentity() - { - m_basis.setIdentity(); - m_origin.setValue(btScalar(0.0), btScalar(0.0), btScalar(0.0)); - } - - /**@brief Multiply this Transform by another(this = this * another) - * @param t The other transform */ - btTransform& operator*=(const btTransform& t) - { - m_origin += m_basis * t.m_origin; - m_basis *= t.m_basis; - return *this; - } - - /**@brief Return the inverse of this transform */ - btTransform inverse() const - { - btMatrix3x3 inv = m_basis.transpose(); - return btTransform(inv, inv * -m_origin); - } - - /**@brief Return the inverse of this transform times the other transform - * @param t The other transform - * return this.inverse() * the other */ - btTransform inverseTimes(const btTransform& t) const; - - /**@brief Return the product of this transform and the other */ - btTransform operator*(const btTransform& t) const; - - /**@brief Return an identity transform */ - static const btTransform& getIdentity() - { - static const btTransform identityTransform(btMatrix3x3::getIdentity()); - return identityTransform; - } - - virtual void serialize(struct btTransformData& dataOut) const; - - virtual void deSerialize(const struct btTransformData& dataIn); - -}; - - -SIMD_FORCE_INLINE btVector3 -btTransform::invXform(const btVector3& inVec) const -{ - btVector3 v = inVec - m_origin; - return (m_basis.transpose() * v); -} - -SIMD_FORCE_INLINE btTransform -btTransform::inverseTimes(const btTransform& t) const -{ - btVector3 v = t.getOrigin() - m_origin; - return btTransform(m_basis.transposeTimes(t.m_basis), - v * m_basis); -} - -SIMD_FORCE_INLINE btTransform -btTransform::operator*(const btTransform& t) const -{ - return btTransform(m_basis * t.m_basis, - (*this)(t.m_origin)); -} - -/**@brief Test if two transforms have all elements equal */ -SIMD_FORCE_INLINE bool operator==(const btTransform& t1, const btTransform& t2) -{ - return ( t1.getBasis() == t2.getBasis() && - t1.getOrigin() == t2.getOrigin() ); -} - -///for serialization -struct btTransformData -{ - btMatrix3x3Data m_basis; - btVector3Data m_origin; -}; - -SIMD_FORCE_INLINE void btTransform::serialize(btTransformData& dataOut) const -{ - m_basis.serialize(dataOut.m_basis); - m_origin.serialize(dataOut.m_origin); -} - -SIMD_FORCE_INLINE void btTransform::deSerialize(const btTransformData& dataIn) -{ - m_basis.deSerialize(dataIn.m_basis); - m_origin.deSerialize(dataIn.m_origin); -} - -#endif - - - - - - diff --git a/bullet/src/LinearMath/btTransformUtil.h b/bullet/src/LinearMath/btTransformUtil.h deleted file mode 100644 index c5c981dbe..000000000 --- a/bullet/src/LinearMath/btTransformUtil.h +++ /dev/null @@ -1,230 +0,0 @@ -/* -Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#ifndef SIMD_TRANSFORM_UTIL_H -#define SIMD_TRANSFORM_UTIL_H - -#include "btTransform.h" -#define ANGULAR_MOTION_THRESHOLD btScalar(0.5)*SIMD_HALF_PI - - - - -SIMD_FORCE_INLINE btVector3 btAabbSupport(const btVector3& halfExtents,const btVector3& supportDir) -{ - return btVector3(supportDir.x() < btScalar(0.0) ? -halfExtents.x() : halfExtents.x(), - supportDir.y() < btScalar(0.0) ? -halfExtents.y() : halfExtents.y(), - supportDir.z() < btScalar(0.0) ? -halfExtents.z() : halfExtents.z()); -} - - - - - - -/// Utils related to temporal transforms -class btTransformUtil -{ - -public: - - static void integrateTransform(const btTransform& curTrans,const btVector3& linvel,const btVector3& angvel,btScalar timeStep,btTransform& predictedTransform) - { - predictedTransform.setOrigin(curTrans.getOrigin() + linvel * timeStep); -// #define QUATERNION_DERIVATIVE - #ifdef QUATERNION_DERIVATIVE - btQuaternion predictedOrn = curTrans.getRotation(); - predictedOrn += (angvel * predictedOrn) * (timeStep * btScalar(0.5)); - predictedOrn.normalize(); - #else - //Exponential map - //google for "Practical Parameterization of Rotations Using the Exponential Map", F. Sebastian Grassia - - btVector3 axis; - btScalar fAngle = angvel.length(); - //limit the angular motion - if (fAngle*timeStep > ANGULAR_MOTION_THRESHOLD) - { - fAngle = ANGULAR_MOTION_THRESHOLD / timeStep; - } - - if ( fAngle < btScalar(0.001) ) - { - // use Taylor's expansions of sync function - axis = angvel*( btScalar(0.5)*timeStep-(timeStep*timeStep*timeStep)*(btScalar(0.020833333333))*fAngle*fAngle ); - } - else - { - // sync(fAngle) = sin(c*fAngle)/t - axis = angvel*( btSin(btScalar(0.5)*fAngle*timeStep)/fAngle ); - } - btQuaternion dorn (axis.x(),axis.y(),axis.z(),btCos( fAngle*timeStep*btScalar(0.5) )); - btQuaternion orn0 = curTrans.getRotation(); - - btQuaternion predictedOrn = dorn * orn0; - predictedOrn.normalize(); - #endif - predictedTransform.setRotation(predictedOrn); - } - - static void calculateVelocityQuaternion(const btVector3& pos0,const btVector3& pos1,const btQuaternion& orn0,const btQuaternion& orn1,btScalar timeStep,btVector3& linVel,btVector3& angVel) - { - linVel = (pos1 - pos0) / timeStep; - btVector3 axis; - btScalar angle; - if (orn0 != orn1) - { - calculateDiffAxisAngleQuaternion(orn0,orn1,axis,angle); - angVel = axis * angle / timeStep; - } else - { - angVel.setValue(0,0,0); - } - } - - static void calculateDiffAxisAngleQuaternion(const btQuaternion& orn0,const btQuaternion& orn1a,btVector3& axis,btScalar& angle) - { - btQuaternion orn1 = orn0.nearest(orn1a); - btQuaternion dorn = orn1 * orn0.inverse(); - ///floating point inaccuracy can lead to w component > 1..., which breaks - dorn.normalize(); - angle = dorn.getAngle(); - axis = btVector3(dorn.x(),dorn.y(),dorn.z()); - axis[3] = btScalar(0.); - //check for axis length - btScalar len = axis.length2(); - if (len < SIMD_EPSILON*SIMD_EPSILON) - axis = btVector3(btScalar(1.),btScalar(0.),btScalar(0.)); - else - axis /= btSqrt(len); - } - - static void calculateVelocity(const btTransform& transform0,const btTransform& transform1,btScalar timeStep,btVector3& linVel,btVector3& angVel) - { - linVel = (transform1.getOrigin() - transform0.getOrigin()) / timeStep; - btVector3 axis; - btScalar angle; - calculateDiffAxisAngle(transform0,transform1,axis,angle); - angVel = axis * angle / timeStep; - } - - static void calculateDiffAxisAngle(const btTransform& transform0,const btTransform& transform1,btVector3& axis,btScalar& angle) - { - btMatrix3x3 dmat = transform1.getBasis() * transform0.getBasis().inverse(); - btQuaternion dorn; - dmat.getRotation(dorn); - - ///floating point inaccuracy can lead to w component > 1..., which breaks - dorn.normalize(); - - angle = dorn.getAngle(); - axis = btVector3(dorn.x(),dorn.y(),dorn.z()); - axis[3] = btScalar(0.); - //check for axis length - btScalar len = axis.length2(); - if (len < SIMD_EPSILON*SIMD_EPSILON) - axis = btVector3(btScalar(1.),btScalar(0.),btScalar(0.)); - else - axis /= btSqrt(len); - } - -}; - - -///The btConvexSeparatingDistanceUtil can help speed up convex collision detection -///by conservatively updating a cached separating distance/vector instead of re-calculating the closest distance -class btConvexSeparatingDistanceUtil -{ - btQuaternion m_ornA; - btQuaternion m_ornB; - btVector3 m_posA; - btVector3 m_posB; - - btVector3 m_separatingNormal; - - btScalar m_boundingRadiusA; - btScalar m_boundingRadiusB; - btScalar m_separatingDistance; - -public: - - btConvexSeparatingDistanceUtil(btScalar boundingRadiusA,btScalar boundingRadiusB) - :m_boundingRadiusA(boundingRadiusA), - m_boundingRadiusB(boundingRadiusB), - m_separatingDistance(0.f) - { - } - - btScalar getConservativeSeparatingDistance() - { - return m_separatingDistance; - } - - void updateSeparatingDistance(const btTransform& transA,const btTransform& transB) - { - const btVector3& toPosA = transA.getOrigin(); - const btVector3& toPosB = transB.getOrigin(); - btQuaternion toOrnA = transA.getRotation(); - btQuaternion toOrnB = transB.getRotation(); - - if (m_separatingDistance>0.f) - { - - - btVector3 linVelA,angVelA,linVelB,angVelB; - btTransformUtil::calculateVelocityQuaternion(m_posA,toPosA,m_ornA,toOrnA,btScalar(1.),linVelA,angVelA); - btTransformUtil::calculateVelocityQuaternion(m_posB,toPosB,m_ornB,toOrnB,btScalar(1.),linVelB,angVelB); - btScalar maxAngularProjectedVelocity = angVelA.length() * m_boundingRadiusA + angVelB.length() * m_boundingRadiusB; - btVector3 relLinVel = (linVelB-linVelA); - btScalar relLinVelocLength = (linVelB-linVelA).dot(m_separatingNormal); - if (relLinVelocLength<0.f) - { - relLinVelocLength = 0.f; - } - - btScalar projectedMotion = maxAngularProjectedVelocity +relLinVelocLength; - m_separatingDistance -= projectedMotion; - } - - m_posA = toPosA; - m_posB = toPosB; - m_ornA = toOrnA; - m_ornB = toOrnB; - } - - void initSeparatingDistance(const btVector3& separatingVector,btScalar separatingDistance,const btTransform& transA,const btTransform& transB) - { - m_separatingDistance = separatingDistance; - - if (m_separatingDistance>0.f) - { - m_separatingNormal = separatingVector; - - const btVector3& toPosA = transA.getOrigin(); - const btVector3& toPosB = transB.getOrigin(); - btQuaternion toOrnA = transA.getRotation(); - btQuaternion toOrnB = transB.getRotation(); - m_posA = toPosA; - m_posB = toPosB; - m_ornA = toOrnA; - m_ornB = toOrnB; - } - } - -}; - - -#endif //SIMD_TRANSFORM_UTIL_H - diff --git a/bullet/src/LinearMath/btVector3.h b/bullet/src/LinearMath/btVector3.h deleted file mode 100644 index 7332dcef1..000000000 --- a/bullet/src/LinearMath/btVector3.h +++ /dev/null @@ -1,682 +0,0 @@ -/* -Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - - -#ifndef SIMD__VECTOR3_H -#define SIMD__VECTOR3_H - - -#include "btScalar.h" -#include "btMinMax.h" - - - - -/**@brief btVector3 can be used to represent 3D points and vectors. - * It has an un-used w component to suit 16-byte alignment when btVector3 is stored in containers. This extra component can be used by derived classes (Quaternion?) or by user - * Ideally, this class should be replaced by a platform optimized SIMD version that keeps the data in registers - */ -ATTRIBUTE_ALIGNED16(class) btVector3 -{ -public: - -#if defined (__SPU__) && defined (__CELLOS_LV2__) - btScalar m_floats[4]; -public: - SIMD_FORCE_INLINE const vec_float4& get128() const - { - return *((const vec_float4*)&m_floats[0]); - } -public: -#else //__CELLOS_LV2__ __SPU__ -#ifdef BT_USE_SSE // WIN32 - union { - __m128 mVec128; - btScalar m_floats[4]; - }; - SIMD_FORCE_INLINE __m128 get128() const - { - return mVec128; - } - SIMD_FORCE_INLINE void set128(__m128 v128) - { - mVec128 = v128; - } -#else - btScalar m_floats[4]; -#endif -#endif //__CELLOS_LV2__ __SPU__ - - public: - - /**@brief No initialization constructor */ - SIMD_FORCE_INLINE btVector3() {} - - - - /**@brief Constructor from scalars - * @param x X value - * @param y Y value - * @param z Z value - */ - SIMD_FORCE_INLINE btVector3(const btScalar& x, const btScalar& y, const btScalar& z) - { - m_floats[0] = x; - m_floats[1] = y; - m_floats[2] = z; - m_floats[3] = btScalar(0.); - } - - -/**@brief Add a vector to this one - * @param The vector to add to this one */ - SIMD_FORCE_INLINE btVector3& operator+=(const btVector3& v) - { - - m_floats[0] += v.m_floats[0]; m_floats[1] += v.m_floats[1];m_floats[2] += v.m_floats[2]; - return *this; - } - - - /**@brief Subtract a vector from this one - * @param The vector to subtract */ - SIMD_FORCE_INLINE btVector3& operator-=(const btVector3& v) - { - m_floats[0] -= v.m_floats[0]; m_floats[1] -= v.m_floats[1];m_floats[2] -= v.m_floats[2]; - return *this; - } - /**@brief Scale the vector - * @param s Scale factor */ - SIMD_FORCE_INLINE btVector3& operator*=(const btScalar& s) - { - m_floats[0] *= s; m_floats[1] *= s;m_floats[2] *= s; - return *this; - } - - /**@brief Inversely scale the vector - * @param s Scale factor to divide by */ - SIMD_FORCE_INLINE btVector3& operator/=(const btScalar& s) - { - btFullAssert(s != btScalar(0.0)); - return *this *= btScalar(1.0) / s; - } - - /**@brief Return the dot product - * @param v The other vector in the dot product */ - SIMD_FORCE_INLINE btScalar dot(const btVector3& v) const - { - return m_floats[0] * v.m_floats[0] + m_floats[1] * v.m_floats[1] +m_floats[2] * v.m_floats[2]; - } - - /**@brief Return the length of the vector squared */ - SIMD_FORCE_INLINE btScalar length2() const - { - return dot(*this); - } - - /**@brief Return the length of the vector */ - SIMD_FORCE_INLINE btScalar length() const - { - return btSqrt(length2()); - } - - /**@brief Return the distance squared between the ends of this and another vector - * This is symantically treating the vector like a point */ - SIMD_FORCE_INLINE btScalar distance2(const btVector3& v) const; - - /**@brief Return the distance between the ends of this and another vector - * This is symantically treating the vector like a point */ - SIMD_FORCE_INLINE btScalar distance(const btVector3& v) const; - - /**@brief Normalize this vector - * x^2 + y^2 + z^2 = 1 */ - SIMD_FORCE_INLINE btVector3& normalize() - { - return *this /= length(); - } - - /**@brief Return a normalized version of this vector */ - SIMD_FORCE_INLINE btVector3 normalized() const; - - /**@brief Rotate this vector - * @param wAxis The axis to rotate about - * @param angle The angle to rotate by */ - SIMD_FORCE_INLINE btVector3 rotate( const btVector3& wAxis, const btScalar angle ); - - /**@brief Return the angle between this and another vector - * @param v The other vector */ - SIMD_FORCE_INLINE btScalar angle(const btVector3& v) const - { - btScalar s = btSqrt(length2() * v.length2()); - btFullAssert(s != btScalar(0.0)); - return btAcos(dot(v) / s); - } - /**@brief Return a vector will the absolute values of each element */ - SIMD_FORCE_INLINE btVector3 absolute() const - { - return btVector3( - btFabs(m_floats[0]), - btFabs(m_floats[1]), - btFabs(m_floats[2])); - } - /**@brief Return the cross product between this and another vector - * @param v The other vector */ - SIMD_FORCE_INLINE btVector3 cross(const btVector3& v) const - { - return btVector3( - m_floats[1] * v.m_floats[2] -m_floats[2] * v.m_floats[1], - m_floats[2] * v.m_floats[0] - m_floats[0] * v.m_floats[2], - m_floats[0] * v.m_floats[1] - m_floats[1] * v.m_floats[0]); - } - - SIMD_FORCE_INLINE btScalar triple(const btVector3& v1, const btVector3& v2) const - { - return m_floats[0] * (v1.m_floats[1] * v2.m_floats[2] - v1.m_floats[2] * v2.m_floats[1]) + - m_floats[1] * (v1.m_floats[2] * v2.m_floats[0] - v1.m_floats[0] * v2.m_floats[2]) + - m_floats[2] * (v1.m_floats[0] * v2.m_floats[1] - v1.m_floats[1] * v2.m_floats[0]); - } - - /**@brief Return the axis with the smallest value - * Note return values are 0,1,2 for x, y, or z */ - SIMD_FORCE_INLINE int minAxis() const - { - return m_floats[0] < m_floats[1] ? (m_floats[0] return this, t=1 => return other) */ - SIMD_FORCE_INLINE btVector3 lerp(const btVector3& v, const btScalar& t) const - { - return btVector3(m_floats[0] + (v.m_floats[0] - m_floats[0]) * t, - m_floats[1] + (v.m_floats[1] - m_floats[1]) * t, - m_floats[2] + (v.m_floats[2] -m_floats[2]) * t); - } - - /**@brief Elementwise multiply this vector by the other - * @param v The other vector */ - SIMD_FORCE_INLINE btVector3& operator*=(const btVector3& v) - { - m_floats[0] *= v.m_floats[0]; m_floats[1] *= v.m_floats[1];m_floats[2] *= v.m_floats[2]; - return *this; - } - - /**@brief Return the x value */ - SIMD_FORCE_INLINE const btScalar& getX() const { return m_floats[0]; } - /**@brief Return the y value */ - SIMD_FORCE_INLINE const btScalar& getY() const { return m_floats[1]; } - /**@brief Return the z value */ - SIMD_FORCE_INLINE const btScalar& getZ() const { return m_floats[2]; } - /**@brief Set the x value */ - SIMD_FORCE_INLINE void setX(btScalar x) { m_floats[0] = x;}; - /**@brief Set the y value */ - SIMD_FORCE_INLINE void setY(btScalar y) { m_floats[1] = y;}; - /**@brief Set the z value */ - SIMD_FORCE_INLINE void setZ(btScalar z) {m_floats[2] = z;}; - /**@brief Set the w value */ - SIMD_FORCE_INLINE void setW(btScalar w) { m_floats[3] = w;}; - /**@brief Return the x value */ - SIMD_FORCE_INLINE const btScalar& x() const { return m_floats[0]; } - /**@brief Return the y value */ - SIMD_FORCE_INLINE const btScalar& y() const { return m_floats[1]; } - /**@brief Return the z value */ - SIMD_FORCE_INLINE const btScalar& z() const { return m_floats[2]; } - /**@brief Return the w value */ - SIMD_FORCE_INLINE const btScalar& w() const { return m_floats[3]; } - - //SIMD_FORCE_INLINE btScalar& operator[](int i) { return (&m_floats[0])[i]; } - //SIMD_FORCE_INLINE const btScalar& operator[](int i) const { return (&m_floats[0])[i]; } - ///operator btScalar*() replaces operator[], using implicit conversion. We added operator != and operator == to avoid pointer comparisons. - SIMD_FORCE_INLINE operator btScalar *() { return &m_floats[0]; } - SIMD_FORCE_INLINE operator const btScalar *() const { return &m_floats[0]; } - - SIMD_FORCE_INLINE bool operator==(const btVector3& other) const - { - return ((m_floats[3]==other.m_floats[3]) && (m_floats[2]==other.m_floats[2]) && (m_floats[1]==other.m_floats[1]) && (m_floats[0]==other.m_floats[0])); - } - - SIMD_FORCE_INLINE bool operator!=(const btVector3& other) const - { - return !(*this == other); - } - - /**@brief Set each element to the max of the current values and the values of another btVector3 - * @param other The other btVector3 to compare with - */ - SIMD_FORCE_INLINE void setMax(const btVector3& other) - { - btSetMax(m_floats[0], other.m_floats[0]); - btSetMax(m_floats[1], other.m_floats[1]); - btSetMax(m_floats[2], other.m_floats[2]); - btSetMax(m_floats[3], other.w()); - } - /**@brief Set each element to the min of the current values and the values of another btVector3 - * @param other The other btVector3 to compare with - */ - SIMD_FORCE_INLINE void setMin(const btVector3& other) - { - btSetMin(m_floats[0], other.m_floats[0]); - btSetMin(m_floats[1], other.m_floats[1]); - btSetMin(m_floats[2], other.m_floats[2]); - btSetMin(m_floats[3], other.w()); - } - - SIMD_FORCE_INLINE void setValue(const btScalar& x, const btScalar& y, const btScalar& z) - { - m_floats[0]=x; - m_floats[1]=y; - m_floats[2]=z; - m_floats[3] = btScalar(0.); - } - - void getSkewSymmetricMatrix(btVector3* v0,btVector3* v1,btVector3* v2) const - { - v0->setValue(0. ,-z() ,y()); - v1->setValue(z() ,0. ,-x()); - v2->setValue(-y() ,x() ,0.); - } - - void setZero() - { - setValue(btScalar(0.),btScalar(0.),btScalar(0.)); - } - - SIMD_FORCE_INLINE void serialize(struct btVector3Data& dataOut) const; - - SIMD_FORCE_INLINE void deSerialize(const struct btVector3Data& dataIn); -}; - -/**@brief Return the sum of two vectors (Point symantics)*/ -SIMD_FORCE_INLINE btVector3 -operator+(const btVector3& v1, const btVector3& v2) -{ - return btVector3(v1.m_floats[0] + v2.m_floats[0], v1.m_floats[1] + v2.m_floats[1], v1.m_floats[2] + v2.m_floats[2]); -} - -/**@brief Return the elementwise product of two vectors */ -SIMD_FORCE_INLINE btVector3 -operator*(const btVector3& v1, const btVector3& v2) -{ - return btVector3(v1.m_floats[0] * v2.m_floats[0], v1.m_floats[1] * v2.m_floats[1], v1.m_floats[2] * v2.m_floats[2]); -} - -/**@brief Return the difference between two vectors */ -SIMD_FORCE_INLINE btVector3 -operator-(const btVector3& v1, const btVector3& v2) -{ - return btVector3(v1.m_floats[0] - v2.m_floats[0], v1.m_floats[1] - v2.m_floats[1], v1.m_floats[2] - v2.m_floats[2]); -} -/**@brief Return the negative of the vector */ -SIMD_FORCE_INLINE btVector3 -operator-(const btVector3& v) -{ - return btVector3(-v.m_floats[0], -v.m_floats[1], -v.m_floats[2]); -} - -/**@brief Return the vector scaled by s */ -SIMD_FORCE_INLINE btVector3 -operator*(const btVector3& v, const btScalar& s) -{ - return btVector3(v.m_floats[0] * s, v.m_floats[1] * s, v.m_floats[2] * s); -} - -/**@brief Return the vector scaled by s */ -SIMD_FORCE_INLINE btVector3 -operator*(const btScalar& s, const btVector3& v) -{ - return v * s; -} - -/**@brief Return the vector inversely scaled by s */ -SIMD_FORCE_INLINE btVector3 -operator/(const btVector3& v, const btScalar& s) -{ - btFullAssert(s != btScalar(0.0)); - return v * (btScalar(1.0) / s); -} - -/**@brief Return the vector inversely scaled by s */ -SIMD_FORCE_INLINE btVector3 -operator/(const btVector3& v1, const btVector3& v2) -{ - return btVector3(v1.m_floats[0] / v2.m_floats[0],v1.m_floats[1] / v2.m_floats[1],v1.m_floats[2] / v2.m_floats[2]); -} - -/**@brief Return the dot product between two vectors */ -SIMD_FORCE_INLINE btScalar -btDot(const btVector3& v1, const btVector3& v2) -{ - return v1.dot(v2); -} - - -/**@brief Return the distance squared between two vectors */ -SIMD_FORCE_INLINE btScalar -btDistance2(const btVector3& v1, const btVector3& v2) -{ - return v1.distance2(v2); -} - - -/**@brief Return the distance between two vectors */ -SIMD_FORCE_INLINE btScalar -btDistance(const btVector3& v1, const btVector3& v2) -{ - return v1.distance(v2); -} - -/**@brief Return the angle between two vectors */ -SIMD_FORCE_INLINE btScalar -btAngle(const btVector3& v1, const btVector3& v2) -{ - return v1.angle(v2); -} - -/**@brief Return the cross product of two vectors */ -SIMD_FORCE_INLINE btVector3 -btCross(const btVector3& v1, const btVector3& v2) -{ - return v1.cross(v2); -} - -SIMD_FORCE_INLINE btScalar -btTriple(const btVector3& v1, const btVector3& v2, const btVector3& v3) -{ - return v1.triple(v2, v3); -} - -/**@brief Return the linear interpolation between two vectors - * @param v1 One vector - * @param v2 The other vector - * @param t The ration of this to v (t = 0 => return v1, t=1 => return v2) */ -SIMD_FORCE_INLINE btVector3 -lerp(const btVector3& v1, const btVector3& v2, const btScalar& t) -{ - return v1.lerp(v2, t); -} - - - -SIMD_FORCE_INLINE btScalar btVector3::distance2(const btVector3& v) const -{ - return (v - *this).length2(); -} - -SIMD_FORCE_INLINE btScalar btVector3::distance(const btVector3& v) const -{ - return (v - *this).length(); -} - -SIMD_FORCE_INLINE btVector3 btVector3::normalized() const -{ - return *this / length(); -} - -SIMD_FORCE_INLINE btVector3 btVector3::rotate( const btVector3& wAxis, const btScalar angle ) -{ - // wAxis must be a unit lenght vector - - btVector3 o = wAxis * wAxis.dot( *this ); - btVector3 x = *this - o; - btVector3 y; - - y = wAxis.cross( *this ); - - return ( o + x * btCos( angle ) + y * btSin( angle ) ); -} - -class btVector4 : public btVector3 -{ -public: - - SIMD_FORCE_INLINE btVector4() {} - - - SIMD_FORCE_INLINE btVector4(const btScalar& x, const btScalar& y, const btScalar& z,const btScalar& w) - : btVector3(x,y,z) - { - m_floats[3] = w; - } - - - SIMD_FORCE_INLINE btVector4 absolute4() const - { - return btVector4( - btFabs(m_floats[0]), - btFabs(m_floats[1]), - btFabs(m_floats[2]), - btFabs(m_floats[3])); - } - - - - btScalar getW() const { return m_floats[3];} - - - SIMD_FORCE_INLINE int maxAxis4() const - { - int maxIndex = -1; - btScalar maxVal = btScalar(-BT_LARGE_FLOAT); - if (m_floats[0] > maxVal) - { - maxIndex = 0; - maxVal = m_floats[0]; - } - if (m_floats[1] > maxVal) - { - maxIndex = 1; - maxVal = m_floats[1]; - } - if (m_floats[2] > maxVal) - { - maxIndex = 2; - maxVal =m_floats[2]; - } - if (m_floats[3] > maxVal) - { - maxIndex = 3; - maxVal = m_floats[3]; - } - - - - - return maxIndex; - - } - - - SIMD_FORCE_INLINE int minAxis4() const - { - int minIndex = -1; - btScalar minVal = btScalar(BT_LARGE_FLOAT); - if (m_floats[0] < minVal) - { - minIndex = 0; - minVal = m_floats[0]; - } - if (m_floats[1] < minVal) - { - minIndex = 1; - minVal = m_floats[1]; - } - if (m_floats[2] < minVal) - { - minIndex = 2; - minVal =m_floats[2]; - } - if (m_floats[3] < minVal) - { - minIndex = 3; - minVal = m_floats[3]; - } - - return minIndex; - - } - - - SIMD_FORCE_INLINE int closestAxis4() const - { - return absolute4().maxAxis4(); - } - - - - - /**@brief Set x,y,z and zero w - * @param x Value of x - * @param y Value of y - * @param z Value of z - */ - - -/* void getValue(btScalar *m) const - { - m[0] = m_floats[0]; - m[1] = m_floats[1]; - m[2] =m_floats[2]; - } -*/ -/**@brief Set the values - * @param x Value of x - * @param y Value of y - * @param z Value of z - * @param w Value of w - */ - SIMD_FORCE_INLINE void setValue(const btScalar& x, const btScalar& y, const btScalar& z,const btScalar& w) - { - m_floats[0]=x; - m_floats[1]=y; - m_floats[2]=z; - m_floats[3]=w; - } - - -}; - - -///btSwapVector3Endian swaps vector endianness, useful for network and cross-platform serialization -SIMD_FORCE_INLINE void btSwapScalarEndian(const btScalar& sourceVal, btScalar& destVal) -{ - #ifdef BT_USE_DOUBLE_PRECISION - unsigned char* dest = (unsigned char*) &destVal; - unsigned char* src = (unsigned char*) &sourceVal; - dest[0] = src[7]; - dest[1] = src[6]; - dest[2] = src[5]; - dest[3] = src[4]; - dest[4] = src[3]; - dest[5] = src[2]; - dest[6] = src[1]; - dest[7] = src[0]; -#else - unsigned char* dest = (unsigned char*) &destVal; - unsigned char* src = (unsigned char*) &sourceVal; - dest[0] = src[3]; - dest[1] = src[2]; - dest[2] = src[1]; - dest[3] = src[0]; -#endif //BT_USE_DOUBLE_PRECISION -} -///btSwapVector3Endian swaps vector endianness, useful for network and cross-platform serialization -SIMD_FORCE_INLINE void btSwapVector3Endian(const btVector3& sourceVec, btVector3& destVec) -{ - for (int i=0;i<4;i++) - { - btSwapScalarEndian(sourceVec[i],destVec[i]); - } - -} - -///btUnSwapVector3Endian swaps vector endianness, useful for network and cross-platform serialization -SIMD_FORCE_INLINE void btUnSwapVector3Endian(btVector3& vector) -{ - - btVector3 swappedVec; - for (int i=0;i<4;i++) - { - btSwapScalarEndian(vector[i],swappedVec[i]); - } - vector = swappedVec; -} - -SIMD_FORCE_INLINE void btPlaneSpace1 (const btVector3& n, btVector3& p, btVector3& q) -{ - if (btFabs(n.z()) > SIMDSQRT12) { - // choose p in y-z plane - btScalar a = n[1]*n[1] + n[2]*n[2]; - btScalar k = btRecipSqrt (a); - p.setValue(0,-n[2]*k,n[1]*k); - // set q = n x p - q.setValue(a*k,-n[0]*p[2],n[0]*p[1]); - } - else { - // choose p in x-y plane - btScalar a = n.x()*n.x() + n.y()*n.y(); - btScalar k = btRecipSqrt (a); - p.setValue(-n.y()*k,n.x()*k,0); - // set q = n x p - q.setValue(-n.z()*p.y(),n.z()*p.x(),a*k); - } -} - -struct btVector3Data -{ - btScalar m_floats[4]; -}; - -SIMD_FORCE_INLINE void btVector3::serialize(struct btVector3Data& dataOut) const -{ - ///could also do a memcpy, check if it is worth it - for (int i=0;i<4;i++) - dataOut.m_floats[i] = m_floats[i]; -} - -SIMD_FORCE_INLINE void btVector3::deSerialize(const struct btVector3Data& dataIn) -{ - for (int i=0;i<4;i++) - m_floats[i] = dataIn.m_floats[i]; -} - - -#endif //SIMD__VECTOR3_H diff --git a/bullet/src/LinearMath/ibmsdk/Makefile b/bullet/src/LinearMath/ibmsdk/Makefile deleted file mode 100644 index a80570aea..000000000 --- a/bullet/src/LinearMath/ibmsdk/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -#### Source code Dirs -VPATH = ../ - -ROOT = ../../.. - -#### Library -LIBRARY_ppu = bulletmath.a - -#### Compiler flags -CPPFLAGS = \ --DUSE_LIBSPE2 \ --I$(ROOT)/src \ --I$(SDKINC) - -#### Optimization level flags -#CC_OPT_LEVEL = $(CC_OPT_LEVEL_DEBUG) -CC_OPT_LEVEL = -O3 - -##### Objects to be archived in lib - -OBJS = \ -btAlignedAllocator.o \ -btGeometryUtil.o \ -btQuickprof.o - -#### Install directories -INSTALL_DIR = $(ROOT)/lib/ibmsdk -INSTALL_FILES = $(LIBRARY_ppu) - -IBM_CELLSDK_VERSION := $(shell if [ -d /opt/cell ]; then echo "3.0"; fi) - -ifeq ("$(IBM_CELLSDK_VERSION)","3.0") - CELL_TOP ?= /opt/cell/sdk - include $(CELL_TOP)/buildutils/make.footer -else - CELL_TOP ?= /opt/ibm/cell-sdk/prototype - include $(CELL_TOP)/make.footer -endif - diff --git a/bullet/src/Makefile.am b/bullet/src/Makefile.am deleted file mode 100644 index 146235e2f..000000000 --- a/bullet/src/Makefile.am +++ /dev/null @@ -1,545 +0,0 @@ -bullet_includedir = $(includedir)/bullet -nobase_bullet_include_HEADERS = \ - btBulletDynamicsCommon.h \ - Bullet-C-Api.h \ - btBulletCollisionCommon.h - -if CONDITIONAL_BUILD_MULTITHREADED -nobase_bullet_include_HEADERS += \ - BulletMultiThreaded/PosixThreadSupport.h \ - BulletMultiThreaded/vectormath/scalar/cpp/mat_aos.h \ - BulletMultiThreaded/vectormath/scalar/cpp/vec_aos.h \ - BulletMultiThreaded/vectormath/scalar/cpp/quat_aos.h \ - BulletMultiThreaded/vectormath/scalar/cpp/vectormath_aos.h \ - BulletMultiThreaded/PpuAddressSpace.h \ - BulletMultiThreaded/SpuCollisionTaskProcess.h \ - BulletMultiThreaded/PlatformDefinitions.h \ - BulletMultiThreaded/vectormath2bullet.h \ - BulletMultiThreaded/SpuGatheringCollisionDispatcher.h \ - BulletMultiThreaded/SpuCollisionObjectWrapper.h \ - BulletMultiThreaded/SpuSampleTaskProcess.h \ - BulletMultiThreaded/SpuNarrowPhaseCollisionTask/boxBoxDistance.h \ - BulletMultiThreaded/SpuNarrowPhaseCollisionTask/Box.h \ - BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuMinkowskiPenetrationDepthSolver.h \ - BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuLocalSupport.h \ - BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuCollisionShapes.h \ - BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.h \ - BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuConvexPenetrationDepthSolver.h \ - BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuContactResult.h \ - BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuPreferredPenetrationDirections.h \ - BulletMultiThreaded/SpuSync.h \ - BulletMultiThreaded/btThreadSupportInterface.h \ - BulletMultiThreaded/SpuLibspe2Support.h \ - BulletMultiThreaded/SpuSampleTask/SpuSampleTask.h \ - BulletMultiThreaded/SpuFakeDma.h \ - BulletMultiThreaded/SpuContactManifoldCollisionAlgorithm.h \ - BulletMultiThreaded/SpuDoubleBuffer.h \ - BulletMultiThreaded/Win32ThreadSupport.h \ - BulletMultiThreaded/SequentialThreadSupport.h - -lib_LTLIBRARIES = libbulletmath.la libbulletcollision.la libbulletdynamics.la libbulletsoftbody.la libbulletmultithreaded.la - -libbulletmultithreaded_la_CXXFLAGS = ${CXXFLAGS} -I./BulletMultiThreaded/vectormath/scalar/cpp -libbulletmultithreaded_la_SOURCES =\ - BulletMultiThreaded/SpuCollisionObjectWrapper.cpp \ - BulletMultiThreaded/SpuSampleTask/SpuSampleTask.cpp \ - BulletMultiThreaded/SpuLibspe2Support.cpp \ - BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuContactResult.cpp \ - BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.cpp \ - BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuMinkowskiPenetrationDepthSolver.cpp \ - BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuCollisionShapes.cpp \ - BulletMultiThreaded/btThreadSupportInterface.cpp \ - BulletMultiThreaded/SequentialThreadSupport.cpp \ - BulletMultiThreaded/SpuGatheringCollisionDispatcher.cpp \ - BulletMultiThreaded/Win32ThreadSupport.cpp \ - BulletMultiThreaded/SpuFakeDma.cpp \ - BulletMultiThreaded/PosixThreadSupport.cpp \ - BulletMultiThreaded/SpuCollisionTaskProcess.cpp \ - BulletMultiThreaded/SpuContactManifoldCollisionAlgorithm.cpp \ - BulletMultiThreaded/SpuSampleTaskProcess.cpp \ - BulletMultiThreaded/SpuSampleTask/SpuSampleTask.h \ - BulletMultiThreaded/PpuAddressSpace.h \ - BulletMultiThreaded/SpuSampleTaskProcess.h \ - BulletMultiThreaded/SequentialThreadSupport.h \ - BulletMultiThreaded/PlatformDefinitions.h \ - BulletMultiThreaded/Win32ThreadSupport.h \ - BulletMultiThreaded/SpuContactManifoldCollisionAlgorithm.h \ - BulletMultiThreaded/btThreadSupportInterface.h \ - BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.h \ - BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuConvexPenetrationDepthSolver.h \ - BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuPreferredPenetrationDirections.h \ - BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuCollisionShapes.h \ - BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuLocalSupport.h \ - BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuMinkowskiPenetrationDepthSolver.h \ - BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuContactResult.h \ - BulletMultiThreaded/SpuGatheringCollisionDispatcher.h \ - BulletMultiThreaded/SpuFakeDma.h \ - BulletMultiThreaded/SpuSync.h \ - BulletMultiThreaded/SpuCollisionObjectWrapper.h \ - BulletMultiThreaded/SpuDoubleBuffer.h \ - BulletMultiThreaded/SpuCollisionTaskProcess.h \ - BulletMultiThreaded/PosixThreadSupport.h \ - BulletMultiThreaded/SpuLibspe2Support.h \ - BulletMultiThreaded/SpuNarrowPhaseCollisionTask/boxBoxDistance.cpp \ - BulletMultiThreaded/SpuNarrowPhaseCollisionTask/boxBoxDistance.h \ - BulletMultiThreaded/SpuNarrowPhaseCollisionTask/Box.h - -else -lib_LTLIBRARIES = libbulletmath.la libbulletcollision.la libbulletdynamics.la libbulletsoftbody.la -endif - - -libbulletmath_la_SOURCES = \ - LinearMath/btQuickprof.cpp \ - LinearMath/btGeometryUtil.cpp \ - LinearMath/btAlignedAllocator.cpp \ - LinearMath/btConvexHull.cpp \ - LinearMath/btHashMap.h \ - LinearMath/btConvexHull.h \ - LinearMath/btAabbUtil2.h \ - LinearMath/btGeometryUtil.h \ - LinearMath/btQuadWord.h \ - LinearMath/btPoolAllocator.h \ - LinearMath/btScalar.h \ - LinearMath/btMinMax.h \ - LinearMath/btVector3.h \ - LinearMath/btList.h \ - LinearMath/btStackAlloc.h \ - LinearMath/btMatrix3x3.h \ - LinearMath/btMotionState.h \ - LinearMath/btAlignedAllocator.h \ - LinearMath/btQuaternion.h \ - LinearMath/btAlignedObjectArray.h \ - LinearMath/btQuickprof.h \ - LinearMath/btTransformUtil.h \ - LinearMath/btTransform.h \ - LinearMath/btDefaultMotionState.h \ - LinearMath/btIDebugDraw.h \ - LinearMath/btRandom.h - - -libbulletcollision_la_SOURCES = \ - BulletCollision/NarrowPhaseCollision/btRaycastCallback.cpp \ - BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp \ - BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.cpp \ - BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp \ - BulletCollision/NarrowPhaseCollision/btGjkConvexCast.cpp \ - BulletCollision/NarrowPhaseCollision/btPersistentManifold.cpp \ - BulletCollision/NarrowPhaseCollision/btConvexCast.cpp \ - BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.cpp \ - BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp \ - BulletCollision/NarrowPhaseCollision/btGjkEpa2.cpp \ - BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.cpp \ - BulletCollision/CollisionDispatch/btActivatingCollisionAlgorithm.cpp \ - BulletCollision/CollisionDispatch/btCollisionObject.cpp \ - BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.cpp \ - BulletCollision/CollisionDispatch/btGhostObject.cpp \ - BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.cpp \ - BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.cpp \ - BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp \ - BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp \ - BulletCollision/CollisionDispatch/btSimulationIslandManager.cpp \ - BulletCollision/CollisionDispatch/btBoxBoxDetector.cpp \ - BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.cpp \ - BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp \ - BulletCollision/CollisionDispatch/btBoxBoxCollisionAlgorithm.cpp \ - BulletCollision/CollisionDispatch/btBox2dBox2dCollisionAlgorithm.cpp \ - BulletCollision/CollisionDispatch/SphereTriangleDetector.cpp \ - BulletCollision/CollisionDispatch/btManifoldResult.cpp \ - BulletCollision/CollisionDispatch/btCollisionWorld.cpp \ - BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.cpp \ - BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp \ - BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.cpp \ - BulletCollision/CollisionDispatch/btUnionFind.cpp \ - BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp \ - BulletCollision/CollisionShapes/btTetrahedronShape.cpp \ - BulletCollision/CollisionShapes/btShapeHull.cpp \ - BulletCollision/CollisionShapes/btMinkowskiSumShape.cpp \ - BulletCollision/CollisionShapes/btCompoundShape.cpp \ - BulletCollision/CollisionShapes/btConeShape.cpp \ - BulletCollision/CollisionShapes/btMultiSphereShape.cpp \ - BulletCollision/CollisionShapes/btUniformScalingShape.cpp \ - BulletCollision/CollisionShapes/btSphereShape.cpp \ - BulletCollision/CollisionShapes/btTriangleIndexVertexArray.cpp \ - BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp \ - BulletCollision/CollisionShapes/btTriangleMeshShape.cpp \ - BulletCollision/CollisionShapes/btTriangleBuffer.cpp \ - BulletCollision/CollisionShapes/btStaticPlaneShape.cpp \ - BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp \ - BulletCollision/CollisionShapes/btEmptyShape.cpp \ - BulletCollision/CollisionShapes/btCollisionShape.cpp \ - BulletCollision/CollisionShapes/btConvexShape.cpp \ - BulletCollision/CollisionShapes/btConvex2dShape.cpp \ - BulletCollision/CollisionShapes/btConvexInternalShape.cpp \ - BulletCollision/CollisionShapes/btConvexHullShape.cpp \ - BulletCollision/CollisionShapes/btTriangleCallback.cpp \ - BulletCollision/CollisionShapes/btCapsuleShape.cpp \ - BulletCollision/CollisionShapes/btConvexTriangleMeshShape.cpp \ - BulletCollision/CollisionShapes/btConcaveShape.cpp \ - BulletCollision/CollisionShapes/btConvexPointCloudShape.cpp \ - BulletCollision/CollisionShapes/btBoxShape.cpp \ - BulletCollision/CollisionShapes/btBox2dShape.cpp \ - BulletCollision/CollisionShapes/btOptimizedBvh.cpp \ - BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp \ - BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.cpp \ - BulletCollision/CollisionShapes/btCylinderShape.cpp \ - BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.cpp \ - BulletCollision/CollisionShapes/btStridingMeshInterface.cpp \ - BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.cpp \ - BulletCollision/CollisionShapes/btTriangleMesh.cpp \ - BulletCollision/BroadphaseCollision/btAxisSweep3.cpp \ - BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp \ - BulletCollision/BroadphaseCollision/btDbvtBroadphase.cpp \ - BulletCollision/BroadphaseCollision/btMultiSapBroadphase.cpp \ - BulletCollision/BroadphaseCollision/btDispatcher.cpp \ - BulletCollision/BroadphaseCollision/btBroadphaseProxy.cpp \ - BulletCollision/BroadphaseCollision/btQuantizedBvh.cpp \ - BulletCollision/BroadphaseCollision/btCollisionAlgorithm.cpp \ - BulletCollision/BroadphaseCollision/btDbvt.cpp \ - BulletCollision/BroadphaseCollision/btSimpleBroadphase.cpp \ - BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h \ - BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h \ - BulletCollision/NarrowPhaseCollision/btConvexCast.h \ - BulletCollision/NarrowPhaseCollision/btGjkEpa2.h \ - BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h \ - BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h \ - BulletCollision/NarrowPhaseCollision/btPointCollector.h \ - BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h \ - BulletCollision/NarrowPhaseCollision/btSimplexSolverInterface.h \ - BulletCollision/NarrowPhaseCollision/btRaycastCallback.h \ - BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.h \ - BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h \ - BulletCollision/NarrowPhaseCollision/btPersistentManifold.h \ - BulletCollision/NarrowPhaseCollision/btGjkConvexCast.h \ - BulletCollision/NarrowPhaseCollision/btManifoldPoint.h \ - BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h \ - BulletCollision/CollisionDispatch/btCollisionObject.h \ - BulletCollision/CollisionDispatch/btGhostObject.h \ - BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.h \ - BulletCollision/CollisionDispatch/btBoxBoxCollisionAlgorithm.h \ - BulletCollision/CollisionDispatch/btBox2dBox2dCollisionAlgorithm.h \ - BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.h \ - BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.h \ - BulletCollision/CollisionDispatch/btCollisionCreateFunc.h \ - BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.h \ - BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.h \ - BulletCollision/CollisionDispatch/btBoxBoxDetector.h \ - BulletCollision/CollisionDispatch/btCollisionDispatcher.h \ - BulletCollision/CollisionDispatch/SphereTriangleDetector.h \ - BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.h \ - BulletCollision/CollisionDispatch/btUnionFind.h \ - BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h \ - BulletCollision/CollisionDispatch/btSimulationIslandManager.h \ - BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h \ - BulletCollision/CollisionDispatch/btCollisionWorld.h \ - BulletCollision/CollisionDispatch/btManifoldResult.h \ - BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.h \ - BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.h \ - BulletCollision/CollisionDispatch/btCollisionConfiguration.h \ - BulletCollision/CollisionShapes/btConvexShape.h \ - BulletCollision/CollisionShapes/btConvex2dShape.h \ - BulletCollision/CollisionShapes/btTriangleCallback.h \ - BulletCollision/CollisionShapes/btPolyhedralConvexShape.h \ - BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.h \ - BulletCollision/CollisionShapes/btCompoundShape.h \ - BulletCollision/CollisionShapes/btBoxShape.h \ - BulletCollision/CollisionShapes/btBox2dShape.h \ - BulletCollision/CollisionShapes/btMultiSphereShape.h \ - BulletCollision/CollisionShapes/btCollisionMargin.h \ - BulletCollision/CollisionShapes/btConcaveShape.h \ - BulletCollision/CollisionShapes/btConvexTriangleMeshShape.h \ - BulletCollision/CollisionShapes/btEmptyShape.h \ - BulletCollision/CollisionShapes/btUniformScalingShape.h \ - BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h \ - BulletCollision/CollisionShapes/btMaterial.h \ - BulletCollision/CollisionShapes/btTriangleIndexVertexArray.h \ - BulletCollision/CollisionShapes/btSphereShape.h \ - BulletCollision/CollisionShapes/btConvexPointCloudShape.h \ - BulletCollision/CollisionShapes/btCapsuleShape.h \ - BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h \ - BulletCollision/CollisionShapes/btCollisionShape.h \ - BulletCollision/CollisionShapes/btStaticPlaneShape.h \ - BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h \ - BulletCollision/CollisionShapes/btTriangleMeshShape.h \ - BulletCollision/CollisionShapes/btStridingMeshInterface.h \ - BulletCollision/CollisionShapes/btTriangleMesh.h \ - BulletCollision/CollisionShapes/btTriangleBuffer.h \ - BulletCollision/CollisionShapes/btShapeHull.h \ - BulletCollision/CollisionShapes/btMinkowskiSumShape.h \ - BulletCollision/CollisionShapes/btOptimizedBvh.h \ - BulletCollision/CollisionShapes/btTriangleShape.h \ - BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.h \ - BulletCollision/CollisionShapes/btCylinderShape.h \ - BulletCollision/CollisionShapes/btTetrahedronShape.h \ - BulletCollision/CollisionShapes/btConvexInternalShape.h \ - BulletCollision/CollisionShapes/btConeShape.h \ - BulletCollision/CollisionShapes/btConvexHullShape.h \ - BulletCollision/BroadphaseCollision/btAxisSweep3.h \ - BulletCollision/BroadphaseCollision/btDbvtBroadphase.h \ - BulletCollision/BroadphaseCollision/btSimpleBroadphase.h \ - BulletCollision/BroadphaseCollision/btMultiSapBroadphase.h \ - BulletCollision/BroadphaseCollision/btDbvt.h \ - BulletCollision/BroadphaseCollision/btOverlappingPairCallback.h \ - BulletCollision/BroadphaseCollision/btDispatcher.h \ - BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h \ - BulletCollision/BroadphaseCollision/btBroadphaseProxy.h \ - BulletCollision/BroadphaseCollision/btOverlappingPairCache.h \ - BulletCollision/BroadphaseCollision/btBroadphaseInterface.h \ - BulletCollision/BroadphaseCollision/btQuantizedBvh.h \ - BulletCollision/Gimpact/btGImpactBvh.cpp\ - BulletCollision/Gimpact/btGImpactQuantizedBvh.cpp\ - BulletCollision/Gimpact/btTriangleShapeEx.cpp\ - BulletCollision/Gimpact/btGImpactCollisionAlgorithm.cpp\ - BulletCollision/Gimpact/btGImpactShape.cpp\ - BulletCollision/Gimpact/gim_box_set.cpp\ - BulletCollision/Gimpact/gim_contact.cpp\ - BulletCollision/Gimpact/gim_memory.cpp\ - BulletCollision/Gimpact/gim_tri_collision.cpp - -libbulletdynamics_la_SOURCES = \ - BulletDynamics/Dynamics/btContinuousDynamicsWorld.cpp \ - BulletDynamics/Dynamics/btRigidBody.cpp \ - BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp \ - BulletDynamics/Dynamics/Bullet-C-API.cpp \ - BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp \ - BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.cpp \ - BulletDynamics/ConstraintSolver/btGeneric6DofSpringConstraint.cpp \ - BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.cpp \ - BulletDynamics/ConstraintSolver/btPoint2PointConstraint.cpp \ - BulletDynamics/ConstraintSolver/btTypedConstraint.cpp \ - BulletDynamics/ConstraintSolver/btContactConstraint.cpp \ - BulletDynamics/ConstraintSolver/btSliderConstraint.cpp \ - BulletDynamics/ConstraintSolver/btConeTwistConstraint.cpp \ - BulletDynamics/ConstraintSolver/btHingeConstraint.cpp \ - BulletDynamics/ConstraintSolver/btHinge2Constraint.cpp \ - BulletDynamics/ConstraintSolver/btUniversalConstraint.cpp \ - BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp \ - BulletDynamics/Vehicle/btWheelInfo.cpp \ - BulletDynamics/Vehicle/btRaycastVehicle.cpp \ - BulletDynamics/Character/btKinematicCharacterController.cpp \ - BulletDynamics/Character/btKinematicCharacterController.h \ - BulletDynamics/Character/btCharacterControllerInterface.h \ - BulletDynamics/Dynamics/btActionInterface.h \ - BulletDynamics/Dynamics/btContinuousDynamicsWorld.h \ - BulletDynamics/Dynamics/btSimpleDynamicsWorld.h \ - BulletDynamics/Dynamics/btRigidBody.h \ - BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h \ - BulletDynamics/Dynamics/btDynamicsWorld.h \ - BulletDynamics/ConstraintSolver/btSolverBody.h \ - BulletDynamics/ConstraintSolver/btConstraintSolver.h \ - BulletDynamics/ConstraintSolver/btConeTwistConstraint.h \ - BulletDynamics/ConstraintSolver/btTypedConstraint.h \ - BulletDynamics/ConstraintSolver/btContactSolverInfo.h \ - BulletDynamics/ConstraintSolver/btContactConstraint.h \ - BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h \ - BulletDynamics/ConstraintSolver/btJacobianEntry.h \ - BulletDynamics/ConstraintSolver/btSolverConstraint.h \ - BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h \ - BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h \ - BulletDynamics/ConstraintSolver/btGeneric6DofSpringConstraint.h \ - BulletDynamics/ConstraintSolver/btSliderConstraint.h \ - BulletDynamics/ConstraintSolver/btHingeConstraint.h \ - BulletDynamics/ConstraintSolver/btHinge2Constraint.h \ - BulletDynamics/ConstraintSolver/btUniversalConstraint.h \ - BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.h \ - BulletDynamics/Vehicle/btVehicleRaycaster.h \ - BulletDynamics/Vehicle/btRaycastVehicle.h \ - BulletDynamics/Vehicle/btWheelInfo.h - -libbulletsoftbody_la_SOURCES = \ - BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.cpp \ - BulletSoftBody/btSoftBody.cpp \ - BulletSoftBody/btSoftRigidCollisionAlgorithm.cpp \ - BulletSoftBody/btSoftBodyConcaveCollisionAlgorithm.cpp \ - BulletSoftBody/btSoftRigidDynamicsWorld.cpp \ - BulletSoftBody/btSoftBodyHelpers.cpp \ - BulletSoftBody/btSoftSoftCollisionAlgorithm.cpp \ - BulletSoftBody/btSparseSDF.h \ - BulletSoftBody/btSoftRigidCollisionAlgorithm.h \ - BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.h \ - BulletSoftBody/btSoftBody.h \ - BulletSoftBody/btSoftSoftCollisionAlgorithm.h \ - BulletSoftBody/btSoftBodyInternals.h \ - BulletSoftBody/btSoftBodyConcaveCollisionAlgorithm.h \ - BulletSoftBody/btSoftRigidDynamicsWorld.h \ - BulletSoftBody/btSoftBodyHelpers.h - - - -nobase_bullet_include_HEADERS += \ - BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.h \ - BulletSoftBody/btSoftBodyInternals.h \ - BulletSoftBody/btSoftBodyConcaveCollisionAlgorithm.h \ - BulletSoftBody/btSoftSoftCollisionAlgorithm.h \ - BulletSoftBody/btSoftBody.h \ - BulletSoftBody/btSoftBodyHelpers.h \ - BulletSoftBody/btSparseSDF.h \ - BulletSoftBody/btSoftRigidCollisionAlgorithm.h \ - BulletSoftBody/btSoftRigidDynamicsWorld.h \ - BulletDynamics/Vehicle/btRaycastVehicle.h \ - BulletDynamics/Vehicle/btWheelInfo.h \ - BulletDynamics/Vehicle/btVehicleRaycaster.h \ - BulletDynamics/Dynamics/btActionInterface.h \ - BulletDynamics/Dynamics/btContinuousDynamicsWorld.h \ - BulletDynamics/Dynamics/btRigidBody.h \ - BulletDynamics/Dynamics/btDynamicsWorld.h \ - BulletDynamics/Dynamics/btSimpleDynamicsWorld.h \ - BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h \ - BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h \ - BulletDynamics/ConstraintSolver/btSolverConstraint.h \ - BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h \ - BulletDynamics/ConstraintSolver/btTypedConstraint.h \ - BulletDynamics/ConstraintSolver/btSliderConstraint.h \ - BulletDynamics/ConstraintSolver/btConstraintSolver.h \ - BulletDynamics/ConstraintSolver/btContactConstraint.h \ - BulletDynamics/ConstraintSolver/btContactSolverInfo.h \ - BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h \ - BulletDynamics/ConstraintSolver/btGeneric6DofSpringConstraint.h \ - BulletDynamics/ConstraintSolver/btJacobianEntry.h \ - BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.h \ - BulletDynamics/ConstraintSolver/btConeTwistConstraint.h \ - BulletDynamics/ConstraintSolver/btHingeConstraint.h \ - BulletDynamics/ConstraintSolver/btHinge2Constraint.h \ - BulletDynamics/ConstraintSolver/btUniversalConstraint.h \ - BulletDynamics/ConstraintSolver/btSolverBody.h \ - BulletDynamics/Character/btCharacterControllerInterface.h \ - BulletDynamics/Character/btKinematicCharacterController.h \ - BulletCollision/CollisionShapes/btShapeHull.h \ - BulletCollision/CollisionShapes/btConcaveShape.h \ - BulletCollision/CollisionShapes/btCollisionMargin.h \ - BulletCollision/CollisionShapes/btCompoundShape.h \ - BulletCollision/CollisionShapes/btConvexHullShape.h \ - BulletCollision/CollisionShapes/btCylinderShape.h \ - BulletCollision/CollisionShapes/btTriangleMesh.h \ - BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h \ - BulletCollision/CollisionShapes/btUniformScalingShape.h \ - BulletCollision/CollisionShapes/btConvexPointCloudShape.h \ - BulletCollision/CollisionShapes/btTetrahedronShape.h \ - BulletCollision/CollisionShapes/btCapsuleShape.h \ - BulletCollision/CollisionShapes/btSphereShape.h \ - BulletCollision/CollisionShapes/btMultiSphereShape.h \ - BulletCollision/CollisionShapes/btConvexInternalShape.h \ - BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h \ - BulletCollision/CollisionShapes/btStridingMeshInterface.h \ - BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h \ - BulletCollision/CollisionShapes/btEmptyShape.h \ - BulletCollision/CollisionShapes/btOptimizedBvh.h \ - BulletCollision/CollisionShapes/btConvexTriangleMeshShape.h \ - BulletCollision/CollisionShapes/btTriangleCallback.h \ - BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.h \ - BulletCollision/CollisionShapes/btTriangleIndexVertexArray.h \ - BulletCollision/CollisionShapes/btTriangleBuffer.h \ - BulletCollision/CollisionShapes/btConvexShape.h \ - BulletCollision/CollisionShapes/btConvex2dShape.h \ - BulletCollision/CollisionShapes/btStaticPlaneShape.h \ - BulletCollision/CollisionShapes/btConeShape.h \ - BulletCollision/CollisionShapes/btCollisionShape.h \ - BulletCollision/CollisionShapes/btTriangleShape.h \ - BulletCollision/CollisionShapes/btBoxShape.h \ - BulletCollision/CollisionShapes/btBox2dShape.h \ - BulletCollision/CollisionShapes/btMinkowskiSumShape.h \ - BulletCollision/CollisionShapes/btTriangleMeshShape.h \ - BulletCollision/CollisionShapes/btMaterial.h \ - BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.h \ - BulletCollision/CollisionShapes/btPolyhedralConvexShape.h \ - BulletCollision/NarrowPhaseCollision/btConvexCast.h \ - BulletCollision/NarrowPhaseCollision/btGjkEpa2.h \ - BulletCollision/NarrowPhaseCollision/btSimplexSolverInterface.h \ - BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.h \ - BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h \ - BulletCollision/NarrowPhaseCollision/btGjkConvexCast.h \ - BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h \ - BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h \ - BulletCollision/NarrowPhaseCollision/btPersistentManifold.h \ - BulletCollision/NarrowPhaseCollision/btManifoldPoint.h \ - BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h \ - BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h \ - BulletCollision/NarrowPhaseCollision/btRaycastCallback.h \ - BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h \ - BulletCollision/NarrowPhaseCollision/btPointCollector.h \ - BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h \ - BulletCollision/BroadphaseCollision/btDbvt.h \ - BulletCollision/BroadphaseCollision/btDispatcher.h \ - BulletCollision/BroadphaseCollision/btDbvtBroadphase.h \ - BulletCollision/BroadphaseCollision/btSimpleBroadphase.h \ - BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h \ - BulletCollision/BroadphaseCollision/btOverlappingPairCallback.h \ - BulletCollision/BroadphaseCollision/btMultiSapBroadphase.h \ - BulletCollision/BroadphaseCollision/btQuantizedBvh.h \ - BulletCollision/BroadphaseCollision/btAxisSweep3.h \ - BulletCollision/BroadphaseCollision/btBroadphaseInterface.h \ - BulletCollision/BroadphaseCollision/btOverlappingPairCache.h \ - BulletCollision/BroadphaseCollision/btBroadphaseProxy.h \ - BulletCollision/CollisionDispatch/btUnionFind.h \ - BulletCollision/CollisionDispatch/btCollisionConfiguration.h \ - BulletCollision/CollisionDispatch/btCollisionDispatcher.h \ - BulletCollision/CollisionDispatch/SphereTriangleDetector.h \ - BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.h \ - BulletCollision/CollisionDispatch/btCollisionWorld.h \ - BulletCollision/CollisionDispatch/btCollisionCreateFunc.h \ - BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.h \ - BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.h \ - BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.h \ - BulletCollision/CollisionDispatch/btCollisionObject.h \ - BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.h \ - BulletCollision/CollisionDispatch/btBoxBoxCollisionAlgorithm.h \ - BulletCollision/CollisionDispatch/btBox2dBox2dCollisionAlgorithm.h \ - BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h \ - BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h \ - BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.h \ - BulletCollision/CollisionDispatch/btGhostObject.h \ - BulletCollision/CollisionDispatch/btSimulationIslandManager.h \ - BulletCollision/CollisionDispatch/btActivatingCollisionAlgorithm.h \ - BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.h \ - BulletCollision/CollisionDispatch/btBoxBoxDetector.h \ - BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.h \ - BulletCollision/CollisionDispatch/btManifoldResult.h \ - BulletCollision/Gimpact/gim_memory.h \ - BulletCollision/Gimpact/gim_clip_polygon.h \ - BulletCollision/Gimpact/gim_bitset.h \ - BulletCollision/Gimpact/gim_linear_math.h \ - BulletCollision/Gimpact/btGeometryOperations.h \ - BulletCollision/Gimpact/btGImpactCollisionAlgorithm.h \ - BulletCollision/Gimpact/btGImpactBvh.h \ - BulletCollision/Gimpact/gim_box_set.h \ - BulletCollision/Gimpact/gim_array.h \ - BulletCollision/Gimpact/btGImpactShape.h \ - BulletCollision/Gimpact/btTriangleShapeEx.h \ - BulletCollision/Gimpact/btClipPolygon.h \ - BulletCollision/Gimpact/gim_box_collision.h \ - BulletCollision/Gimpact/gim_tri_collision.h \ - BulletCollision/Gimpact/gim_geometry.h \ - BulletCollision/Gimpact/gim_math.h \ - BulletCollision/Gimpact/btQuantization.h \ - BulletCollision/Gimpact/btGImpactQuantizedBvh.h \ - BulletCollision/Gimpact/gim_geom_types.h \ - BulletCollision/Gimpact/gim_basic_geometry_operations.h \ - BulletCollision/Gimpact/gim_contact.h \ - BulletCollision/Gimpact/gim_hash_table.h \ - BulletCollision/Gimpact/gim_radixsort.h \ - BulletCollision/Gimpact/btGImpactMassUtil.h \ - BulletCollision/Gimpact/btGenericPoolAllocator.h \ - BulletCollision/Gimpact/btBoxCollision.h \ - BulletCollision/Gimpact/btContactProcessing.h \ - LinearMath/btGeometryUtil.h \ - LinearMath/btConvexHull.h \ - LinearMath/btList.h \ - LinearMath/btMatrix3x3.h \ - LinearMath/btVector3.h \ - LinearMath/btPoolAllocator.h \ - LinearMath/btScalar.h \ - LinearMath/btDefaultMotionState.h \ - LinearMath/btTransform.h \ - LinearMath/btQuadWord.h \ - LinearMath/btAabbUtil2.h \ - LinearMath/btTransformUtil.h \ - LinearMath/btRandom.h \ - LinearMath/btQuaternion.h \ - LinearMath/btMinMax.h \ - LinearMath/btMotionState.h \ - LinearMath/btIDebugDraw.h \ - LinearMath/btAlignedAllocator.h \ - LinearMath/btStackAlloc.h \ - LinearMath/btAlignedObjectArray.h \ - LinearMath/btHashMap.h \ - LinearMath/btQuickprof.h diff --git a/bullet/src/MiniCL/cl.h b/bullet/src/MiniCL/cl.h deleted file mode 100644 index b0cda4237..000000000 --- a/bullet/src/MiniCL/cl.h +++ /dev/null @@ -1,865 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008-2009 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and/or associated documentation files (the - * "Materials"), to deal in the Materials without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Materials, and to - * permit persons to whom the Materials are furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. - ******************************************************************************/ - -#ifndef __OPENCL_CL_H -#define __OPENCL_CL_H - -#ifdef __APPLE__ -#include -#else -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/******************************************************************************/ - -typedef struct _cl_platform_id * cl_platform_id; -typedef struct _cl_device_id * cl_device_id; -typedef struct _cl_context * cl_context; -typedef struct _cl_command_queue * cl_command_queue; -typedef struct _cl_mem * cl_mem; -typedef struct _cl_program * cl_program; -typedef struct _cl_kernel * cl_kernel; -typedef struct _cl_event * cl_event; -typedef struct _cl_sampler * cl_sampler; - -typedef cl_uint cl_bool; /* WARNING! Unlike cl_ types in cl_platform.h, cl_bool is not guaranteed to be the same size as the bool in kernels. */ -typedef cl_ulong cl_bitfield; -typedef cl_bitfield cl_device_type; -typedef cl_uint cl_platform_info; -typedef cl_uint cl_device_info; -typedef cl_bitfield cl_device_address_info; -typedef cl_bitfield cl_device_fp_config; -typedef cl_uint cl_device_mem_cache_type; -typedef cl_uint cl_device_local_mem_type; -typedef cl_bitfield cl_device_exec_capabilities; -typedef cl_bitfield cl_command_queue_properties; - -typedef intptr_t cl_context_properties; -typedef cl_uint cl_context_info; -typedef cl_uint cl_command_queue_info; -typedef cl_uint cl_channel_order; -typedef cl_uint cl_channel_type; -typedef cl_bitfield cl_mem_flags; -typedef cl_uint cl_mem_object_type; -typedef cl_uint cl_mem_info; -typedef cl_uint cl_image_info; -typedef cl_uint cl_addressing_mode; -typedef cl_uint cl_filter_mode; -typedef cl_uint cl_sampler_info; -typedef cl_bitfield cl_map_flags; -typedef cl_uint cl_program_info; -typedef cl_uint cl_program_build_info; -typedef cl_int cl_build_status; -typedef cl_uint cl_kernel_info; -typedef cl_uint cl_kernel_work_group_info; -typedef cl_uint cl_event_info; -typedef cl_uint cl_command_type; -typedef cl_uint cl_profiling_info; - -typedef struct _cl_image_format { - cl_channel_order image_channel_order; - cl_channel_type image_channel_data_type; -} cl_image_format; - -/******************************************************************************/ - -// Error Codes -#define CL_SUCCESS 0 -#define CL_DEVICE_NOT_FOUND -1 -#define CL_DEVICE_NOT_AVAILABLE -2 -#define CL_DEVICE_COMPILER_NOT_AVAILABLE -3 -#define CL_MEM_OBJECT_ALLOCATION_FAILURE -4 -#define CL_OUT_OF_RESOURCES -5 -#define CL_OUT_OF_HOST_MEMORY -6 -#define CL_PROFILING_INFO_NOT_AVAILABLE -7 -#define CL_MEM_COPY_OVERLAP -8 -#define CL_IMAGE_FORMAT_MISMATCH -9 -#define CL_IMAGE_FORMAT_NOT_SUPPORTED -10 -#define CL_BUILD_PROGRAM_FAILURE -11 -#define CL_MAP_FAILURE -12 - -#define CL_INVALID_VALUE -30 -#define CL_INVALID_DEVICE_TYPE -31 -#define CL_INVALID_PLATFORM -32 -#define CL_INVALID_DEVICE -33 -#define CL_INVALID_CONTEXT -34 -#define CL_INVALID_QUEUE_PROPERTIES -35 -#define CL_INVALID_COMMAND_QUEUE -36 -#define CL_INVALID_HOST_PTR -37 -#define CL_INVALID_MEM_OBJECT -38 -#define CL_INVALID_IMAGE_FORMAT_DESCRIPTOR -39 -#define CL_INVALID_IMAGE_SIZE -40 -#define CL_INVALID_SAMPLER -41 -#define CL_INVALID_BINARY -42 -#define CL_INVALID_BUILD_OPTIONS -43 -#define CL_INVALID_PROGRAM -44 -#define CL_INVALID_PROGRAM_EXECUTABLE -45 -#define CL_INVALID_KERNEL_NAME -46 -#define CL_INVALID_KERNEL_DEFINITION -47 -#define CL_INVALID_KERNEL -48 -#define CL_INVALID_ARG_INDEX -49 -#define CL_INVALID_ARG_VALUE -50 -#define CL_INVALID_ARG_SIZE -51 -#define CL_INVALID_KERNEL_ARGS -52 -#define CL_INVALID_WORK_DIMENSION -53 -#define CL_INVALID_WORK_GROUP_SIZE -54 -#define CL_INVALID_WORK_ITEM_SIZE -55 -#define CL_INVALID_GLOBAL_OFFSET -56 -#define CL_INVALID_EVENT_WAIT_LIST -57 -#define CL_INVALID_EVENT -58 -#define CL_INVALID_OPERATION -59 -#define CL_INVALID_GL_OBJECT -60 -#define CL_INVALID_BUFFER_SIZE -61 -#define CL_INVALID_MIP_LEVEL -62 - -// OpenCL Version -#define CL_VERSION_1_0 1 - -// cl_bool -#define CL_FALSE 0 -#define CL_TRUE 1 - -// cl_platform_info -#define CL_PLATFORM_PROFILE 0x0900 -#define CL_PLATFORM_VERSION 0x0901 -#define CL_PLATFORM_NAME 0x0902 -#define CL_PLATFORM_VENDOR 0x0903 -#define CL_PLATFORM_EXTENSIONS 0x0904 - -// cl_device_type - bitfield -#define CL_DEVICE_TYPE_DEFAULT (1 << 0) -#define CL_DEVICE_TYPE_CPU (1 << 1) -#define CL_DEVICE_TYPE_GPU (1 << 2) -#define CL_DEVICE_TYPE_ACCELERATOR (1 << 3) -#define CL_DEVICE_TYPE_ALL 0xFFFFFFFF - -// cl_device_info -#define CL_DEVICE_TYPE 0x1000 -#define CL_DEVICE_VENDOR_ID 0x1001 -#define CL_DEVICE_MAX_COMPUTE_UNITS 0x1002 -#define CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS 0x1003 -#define CL_DEVICE_MAX_WORK_GROUP_SIZE 0x1004 -#define CL_DEVICE_MAX_WORK_ITEM_SIZES 0x1005 -#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR 0x1006 -#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT 0x1007 -#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT 0x1008 -#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG 0x1009 -#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT 0x100A -#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE 0x100B -#define CL_DEVICE_MAX_CLOCK_FREQUENCY 0x100C -#define CL_DEVICE_ADDRESS_BITS 0x100D -#define CL_DEVICE_MAX_READ_IMAGE_ARGS 0x100E -#define CL_DEVICE_MAX_WRITE_IMAGE_ARGS 0x100F -#define CL_DEVICE_MAX_MEM_ALLOC_SIZE 0x1010 -#define CL_DEVICE_IMAGE2D_MAX_WIDTH 0x1011 -#define CL_DEVICE_IMAGE2D_MAX_HEIGHT 0x1012 -#define CL_DEVICE_IMAGE3D_MAX_WIDTH 0x1013 -#define CL_DEVICE_IMAGE3D_MAX_HEIGHT 0x1014 -#define CL_DEVICE_IMAGE3D_MAX_DEPTH 0x1015 -#define CL_DEVICE_IMAGE_SUPPORT 0x1016 -#define CL_DEVICE_MAX_PARAMETER_SIZE 0x1017 -#define CL_DEVICE_MAX_SAMPLERS 0x1018 -#define CL_DEVICE_MEM_BASE_ADDR_ALIGN 0x1019 -#define CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE 0x101A -#define CL_DEVICE_SINGLE_FP_CONFIG 0x101B -#define CL_DEVICE_GLOBAL_MEM_CACHE_TYPE 0x101C -#define CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE 0x101D -#define CL_DEVICE_GLOBAL_MEM_CACHE_SIZE 0x101E -#define CL_DEVICE_GLOBAL_MEM_SIZE 0x101F -#define CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE 0x1020 -#define CL_DEVICE_MAX_CONSTANT_ARGS 0x1021 -#define CL_DEVICE_LOCAL_MEM_TYPE 0x1022 -#define CL_DEVICE_LOCAL_MEM_SIZE 0x1023 -#define CL_DEVICE_ERROR_CORRECTION_SUPPORT 0x1024 -#define CL_DEVICE_PROFILING_TIMER_RESOLUTION 0x1025 -#define CL_DEVICE_ENDIAN_LITTLE 0x1026 -#define CL_DEVICE_AVAILABLE 0x1027 -#define CL_DEVICE_COMPILER_AVAILABLE 0x1028 -#define CL_DEVICE_EXECUTION_CAPABILITIES 0x1029 -#define CL_DEVICE_QUEUE_PROPERTIES 0x102A -#define CL_DEVICE_NAME 0x102B -#define CL_DEVICE_VENDOR 0x102C -#define CL_DRIVER_VERSION 0x102D -#define CL_DEVICE_PROFILE 0x102E -#define CL_DEVICE_VERSION 0x102F -#define CL_DEVICE_EXTENSIONS 0x1030 -#define CL_DEVICE_PLATFORM 0x1031 - -// cl_device_address_info - bitfield -#define CL_DEVICE_ADDRESS_32_BITS (1 << 0) -#define CL_DEVICE_ADDRESS_64_BITS (1 << 1) - -// cl_device_fp_config - bitfield -#define CL_FP_DENORM (1 << 0) -#define CL_FP_INF_NAN (1 << 1) -#define CL_FP_ROUND_TO_NEAREST (1 << 2) -#define CL_FP_ROUND_TO_ZERO (1 << 3) -#define CL_FP_ROUND_TO_INF (1 << 4) -#define CL_FP_FMA (1 << 5) - -// cl_device_mem_cache_type -#define CL_NONE 0x0 -#define CL_READ_ONLY_CACHE 0x1 -#define CL_READ_WRITE_CACHE 0x2 - -// cl_device_local_mem_type -#define CL_LOCAL 0x1 -#define CL_GLOBAL 0x2 - -// cl_device_exec_capabilities - bitfield -#define CL_EXEC_KERNEL (1 << 0) -#define CL_EXEC_NATIVE_KERNEL (1 << 1) - -// cl_command_queue_properties - bitfield -#define CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE (1 << 0) -#define CL_QUEUE_PROFILING_ENABLE (1 << 1) - -// cl_context_info -#define CL_CONTEXT_REFERENCE_COUNT 0x1080 -#define CL_CONTEXT_NUM_DEVICES 0x1081 -#define CL_CONTEXT_DEVICES 0x1082 -#define CL_CONTEXT_PROPERTIES 0x1083 -#define CL_CONTEXT_PLATFORM 0x1084 - -// cl_command_queue_info -#define CL_QUEUE_CONTEXT 0x1090 -#define CL_QUEUE_DEVICE 0x1091 -#define CL_QUEUE_REFERENCE_COUNT 0x1092 -#define CL_QUEUE_PROPERTIES 0x1093 - -// cl_mem_flags - bitfield -#define CL_MEM_READ_WRITE (1 << 0) -#define CL_MEM_WRITE_ONLY (1 << 1) -#define CL_MEM_READ_ONLY (1 << 2) -#define CL_MEM_USE_HOST_PTR (1 << 3) -#define CL_MEM_ALLOC_HOST_PTR (1 << 4) -#define CL_MEM_COPY_HOST_PTR (1 << 5) - -// cl_channel_order -#define CL_R 0x10B0 -#define CL_A 0x10B1 -#define CL_RG 0x10B2 -#define CL_RA 0x10B3 -#define CL_RGB 0x10B4 -#define CL_RGBA 0x10B5 -#define CL_BGRA 0x10B6 -#define CL_ARGB 0x10B7 -#define CL_INTENSITY 0x10B8 -#define CL_LUMINANCE 0x10B9 - -// cl_channel_type -#define CL_SNORM_INT8 0x10D0 -#define CL_SNORM_INT16 0x10D1 -#define CL_UNORM_INT8 0x10D2 -#define CL_UNORM_INT16 0x10D3 -#define CL_UNORM_SHORT_565 0x10D4 -#define CL_UNORM_SHORT_555 0x10D5 -#define CL_UNORM_INT_101010 0x10D6 -#define CL_SIGNED_INT8 0x10D7 -#define CL_SIGNED_INT16 0x10D8 -#define CL_SIGNED_INT32 0x10D9 -#define CL_UNSIGNED_INT8 0x10DA -#define CL_UNSIGNED_INT16 0x10DB -#define CL_UNSIGNED_INT32 0x10DC -#define CL_HALF_FLOAT 0x10DD -#define CL_FLOAT 0x10DE - -// cl_mem_object_type -#define CL_MEM_OBJECT_BUFFER 0x10F0 -#define CL_MEM_OBJECT_IMAGE2D 0x10F1 -#define CL_MEM_OBJECT_IMAGE3D 0x10F2 - -// cl_mem_info -#define CL_MEM_TYPE 0x1100 -#define CL_MEM_FLAGS 0x1101 -#define CL_MEM_SIZE 0x1102 -#define CL_MEM_HOST_PTR 0x1103 -#define CL_MEM_MAP_COUNT 0x1104 -#define CL_MEM_REFERENCE_COUNT 0x1105 -#define CL_MEM_CONTEXT 0x1106 - -// cl_image_info -#define CL_IMAGE_FORMAT 0x1110 -#define CL_IMAGE_ELEMENT_SIZE 0x1111 -#define CL_IMAGE_ROW_PITCH 0x1112 -#define CL_IMAGE_SLICE_PITCH 0x1113 -#define CL_IMAGE_WIDTH 0x1114 -#define CL_IMAGE_HEIGHT 0x1115 -#define CL_IMAGE_DEPTH 0x1116 - -// cl_addressing_mode -#define CL_ADDRESS_NONE 0x1130 -#define CL_ADDRESS_CLAMP_TO_EDGE 0x1131 -#define CL_ADDRESS_CLAMP 0x1132 -#define CL_ADDRESS_REPEAT 0x1133 - -// cl_filter_mode -#define CL_FILTER_NEAREST 0x1140 -#define CL_FILTER_LINEAR 0x1141 - -// cl_sampler_info -#define CL_SAMPLER_REFERENCE_COUNT 0x1150 -#define CL_SAMPLER_CONTEXT 0x1151 -#define CL_SAMPLER_NORMALIZED_COORDS 0x1152 -#define CL_SAMPLER_ADDRESSING_MODE 0x1153 -#define CL_SAMPLER_FILTER_MODE 0x1154 - -// cl_map_flags - bitfield -#define CL_MAP_READ (1 << 0) -#define CL_MAP_WRITE (1 << 1) - -// cl_program_info -#define CL_PROGRAM_REFERENCE_COUNT 0x1160 -#define CL_PROGRAM_CONTEXT 0x1161 -#define CL_PROGRAM_NUM_DEVICES 0x1162 -#define CL_PROGRAM_DEVICES 0x1163 -#define CL_PROGRAM_SOURCE 0x1164 -#define CL_PROGRAM_BINARY_SIZES 0x1165 -#define CL_PROGRAM_BINARIES 0x1166 - -// cl_program_build_info -#define CL_PROGRAM_BUILD_STATUS 0x1181 -#define CL_PROGRAM_BUILD_OPTIONS 0x1182 -#define CL_PROGRAM_BUILD_LOG 0x1183 - -// cl_build_status -#define CL_BUILD_SUCCESS 0 -#define CL_BUILD_NONE -1 -#define CL_BUILD_ERROR -2 -#define CL_BUILD_IN_PROGRESS -3 - -// cl_kernel_info -#define CL_KERNEL_FUNCTION_NAME 0x1190 -#define CL_KERNEL_NUM_ARGS 0x1191 -#define CL_KERNEL_REFERENCE_COUNT 0x1192 -#define CL_KERNEL_CONTEXT 0x1193 -#define CL_KERNEL_PROGRAM 0x1194 - -// cl_kernel_work_group_info -#define CL_KERNEL_WORK_GROUP_SIZE 0x11B0 -#define CL_KERNEL_COMPILE_WORK_GROUP_SIZE 0x11B1 -#define CL_KERNEL_LOCAL_MEM_SIZE 0x11B2 - -// cl_event_info -#define CL_EVENT_COMMAND_QUEUE 0x11D0 -#define CL_EVENT_COMMAND_TYPE 0x11D1 -#define CL_EVENT_REFERENCE_COUNT 0x11D2 -#define CL_EVENT_COMMAND_EXECUTION_STATUS 0x11D3 - -// cl_command_type -#define CL_COMMAND_NDRANGE_KERNEL 0x11F0 -#define CL_COMMAND_TASK 0x11F1 -#define CL_COMMAND_NATIVE_KERNEL 0x11F2 -#define CL_COMMAND_READ_BUFFER 0x11F3 -#define CL_COMMAND_WRITE_BUFFER 0x11F4 -#define CL_COMMAND_COPY_BUFFER 0x11F5 -#define CL_COMMAND_READ_IMAGE 0x11F6 -#define CL_COMMAND_WRITE_IMAGE 0x11F7 -#define CL_COMMAND_COPY_IMAGE 0x11F8 -#define CL_COMMAND_COPY_IMAGE_TO_BUFFER 0x11F9 -#define CL_COMMAND_COPY_BUFFER_TO_IMAGE 0x11FA -#define CL_COMMAND_MAP_BUFFER 0x11FB -#define CL_COMMAND_MAP_IMAGE 0x11FC -#define CL_COMMAND_UNMAP_MEM_OBJECT 0x11FD -#define CL_COMMAND_MARKER 0x11FE -#define CL_COMMAND_WAIT_FOR_EVENTS 0x11FF -#define CL_COMMAND_BARRIER 0x1200 -#define CL_COMMAND_ACQUIRE_GL_OBJECTS 0x1201 -#define CL_COMMAND_RELEASE_GL_OBJECTS 0x1202 - -// command execution status -#define CL_COMPLETE 0x0 -#define CL_RUNNING 0x1 -#define CL_SUBMITTED 0x2 -#define CL_QUEUED 0x3 - -// cl_profiling_info -#define CL_PROFILING_COMMAND_QUEUED 0x1280 -#define CL_PROFILING_COMMAND_SUBMIT 0x1281 -#define CL_PROFILING_COMMAND_START 0x1282 -#define CL_PROFILING_COMMAND_END 0x1283 - -/********************************************************************************************************/ - -// Platform API -extern CL_API_ENTRY cl_int CL_API_CALL -clGetPlatformIDs(cl_uint /* num_entries */, - cl_platform_id * /* platforms */, - cl_uint * /* num_platforms */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clGetPlatformInfo(cl_platform_id /* platform */, - cl_platform_info /* param_name */, - size_t /* param_value_size */, - void * /* param_value */, - size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; - -// Device APIs -extern CL_API_ENTRY cl_int CL_API_CALL -clGetDeviceIDs(cl_platform_id /* platform */, - cl_device_type /* device_type */, - cl_uint /* num_entries */, - cl_device_id * /* devices */, - cl_uint * /* num_devices */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clGetDeviceInfo(cl_device_id /* device */, - cl_device_info /* param_name */, - size_t /* param_value_size */, - void * /* param_value */, - size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; - -// Context APIs -extern CL_API_ENTRY cl_context CL_API_CALL -clCreateContext(cl_context_properties * /* properties */, - cl_uint /* num_devices */, - const cl_device_id * /* devices */, - void (*pfn_notify)(const char *, const void *, size_t, void *) /* pfn_notify */, - void * /* user_data */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_context CL_API_CALL -clCreateContextFromType(cl_context_properties * /* properties */, - cl_device_type /* device_type */, - void (*pfn_notify)(const char *, const void *, size_t, void *) /* pfn_notify */, - void * /* user_data */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clRetainContext(cl_context /* context */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clReleaseContext(cl_context /* context */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clGetContextInfo(cl_context /* context */, - cl_context_info /* param_name */, - size_t /* param_value_size */, - void * /* param_value */, - size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; - -// Command Queue APIs -extern CL_API_ENTRY cl_command_queue CL_API_CALL -clCreateCommandQueue(cl_context /* context */, - cl_device_id /* device */, - cl_command_queue_properties /* properties */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clRetainCommandQueue(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clReleaseCommandQueue(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clGetCommandQueueInfo(cl_command_queue /* command_queue */, - cl_command_queue_info /* param_name */, - size_t /* param_value_size */, - void * /* param_value */, - size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clSetCommandQueueProperty(cl_command_queue /* command_queue */, - cl_command_queue_properties /* properties */, - cl_bool /* enable */, - cl_command_queue_properties * /* old_properties */) CL_API_SUFFIX__VERSION_1_0; - -// Memory Object APIs -extern CL_API_ENTRY cl_mem CL_API_CALL -clCreateBuffer(cl_context /* context */, - cl_mem_flags /* flags */, - size_t /* size */, - void * /* host_ptr */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_mem CL_API_CALL -clCreateImage2D(cl_context /* context */, - cl_mem_flags /* flags */, - const cl_image_format * /* image_format */, - size_t /* image_width */, - size_t /* image_height */, - size_t /* image_row_pitch */, - void * /* host_ptr */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_mem CL_API_CALL -clCreateImage3D(cl_context /* context */, - cl_mem_flags /* flags */, - const cl_image_format * /* image_format */, - size_t /* image_width */, - size_t /* image_height */, - size_t /* image_depth */, - size_t /* image_row_pitch */, - size_t /* image_slice_pitch */, - void * /* host_ptr */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clRetainMemObject(cl_mem /* memobj */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clReleaseMemObject(cl_mem /* memobj */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clGetSupportedImageFormats(cl_context /* context */, - cl_mem_flags /* flags */, - cl_mem_object_type /* image_type */, - cl_uint /* num_entries */, - cl_image_format * /* image_formats */, - cl_uint * /* num_image_formats */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clGetMemObjectInfo(cl_mem /* memobj */, - cl_mem_info /* param_name */, - size_t /* param_value_size */, - void * /* param_value */, - size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clGetImageInfo(cl_mem /* image */, - cl_image_info /* param_name */, - size_t /* param_value_size */, - void * /* param_value */, - size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; - -// Sampler APIs -extern CL_API_ENTRY cl_sampler CL_API_CALL -clCreateSampler(cl_context /* context */, - cl_bool /* normalized_coords */, - cl_addressing_mode /* addressing_mode */, - cl_filter_mode /* filter_mode */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clRetainSampler(cl_sampler /* sampler */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clReleaseSampler(cl_sampler /* sampler */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clGetSamplerInfo(cl_sampler /* sampler */, - cl_sampler_info /* param_name */, - size_t /* param_value_size */, - void * /* param_value */, - size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; - -// Program Object APIs -extern CL_API_ENTRY cl_program CL_API_CALL -clCreateProgramWithSource(cl_context /* context */, - cl_uint /* count */, - const char ** /* strings */, - const size_t * /* lengths */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_program CL_API_CALL -clCreateProgramWithBinary(cl_context /* context */, - cl_uint /* num_devices */, - const cl_device_id * /* device_list */, - const size_t * /* lengths */, - const unsigned char ** /* binaries */, - cl_int * /* binary_status */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clRetainProgram(cl_program /* program */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clReleaseProgram(cl_program /* program */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clBuildProgram(cl_program /* program */, - cl_uint /* num_devices */, - const cl_device_id * /* device_list */, - const char * /* options */, - void (*pfn_notify)(cl_program /* program */, void * /* user_data */), - void * /* user_data */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clUnloadCompiler(void) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clGetProgramInfo(cl_program /* program */, - cl_program_info /* param_name */, - size_t /* param_value_size */, - void * /* param_value */, - size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clGetProgramBuildInfo(cl_program /* program */, - cl_device_id /* device */, - cl_program_build_info /* param_name */, - size_t /* param_value_size */, - void * /* param_value */, - size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; - -// Kernel Object APIs -extern CL_API_ENTRY cl_kernel CL_API_CALL -clCreateKernel(cl_program /* program */, - const char * /* kernel_name */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clCreateKernelsInProgram(cl_program /* program */, - cl_uint /* num_kernels */, - cl_kernel * /* kernels */, - cl_uint * /* num_kernels_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clRetainKernel(cl_kernel /* kernel */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clReleaseKernel(cl_kernel /* kernel */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clSetKernelArg(cl_kernel /* kernel */, - cl_uint /* arg_index */, - size_t /* arg_size */, - const void * /* arg_value */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clGetKernelInfo(cl_kernel /* kernel */, - cl_kernel_info /* param_name */, - size_t /* param_value_size */, - void * /* param_value */, - size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clGetKernelWorkGroupInfo(cl_kernel /* kernel */, - cl_device_id /* device */, - cl_kernel_work_group_info /* param_name */, - size_t /* param_value_size */, - void * /* param_value */, - size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; - -// Event Object APIs -extern CL_API_ENTRY cl_int CL_API_CALL -clWaitForEvents(cl_uint /* num_events */, - const cl_event * /* event_list */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clGetEventInfo(cl_event /* event */, - cl_event_info /* param_name */, - size_t /* param_value_size */, - void * /* param_value */, - size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clRetainEvent(cl_event /* event */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clReleaseEvent(cl_event /* event */) CL_API_SUFFIX__VERSION_1_0; - -// Profiling APIs -extern CL_API_ENTRY cl_int CL_API_CALL -clGetEventProfilingInfo(cl_event /* event */, - cl_profiling_info /* param_name */, - size_t /* param_value_size */, - void * /* param_value */, - size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; - -// Flush and Finish APIs -extern CL_API_ENTRY cl_int CL_API_CALL -clFlush(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clFinish(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0; - -// Enqueued Commands APIs -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueReadBuffer(cl_command_queue /* command_queue */, - cl_mem /* buffer */, - cl_bool /* blocking_read */, - size_t /* offset */, - size_t /* cb */, - void * /* ptr */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueWriteBuffer(cl_command_queue /* command_queue */, - cl_mem /* buffer */, - cl_bool /* blocking_write */, - size_t /* offset */, - size_t /* cb */, - const void * /* ptr */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueCopyBuffer(cl_command_queue /* command_queue */, - cl_mem /* src_buffer */, - cl_mem /* dst_buffer */, - size_t /* src_offset */, - size_t /* dst_offset */, - size_t /* cb */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueReadImage(cl_command_queue /* command_queue */, - cl_mem /* image */, - cl_bool /* blocking_read */, - const size_t * /* origin[3] */, - const size_t * /* region[3] */, - size_t /* row_pitch */, - size_t /* slice_pitch */, - void * /* ptr */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueWriteImage(cl_command_queue /* command_queue */, - cl_mem /* image */, - cl_bool /* blocking_write */, - const size_t * /* origin[3] */, - const size_t * /* region[3] */, - size_t /* input_row_pitch */, - size_t /* input_slice_pitch */, - const void * /* ptr */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueCopyImage(cl_command_queue /* command_queue */, - cl_mem /* src_image */, - cl_mem /* dst_image */, - const size_t * /* src_origin[3] */, - const size_t * /* dst_origin[3] */, - const size_t * /* region[3] */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueCopyImageToBuffer(cl_command_queue /* command_queue */, - cl_mem /* src_image */, - cl_mem /* dst_buffer */, - const size_t * /* src_origin[3] */, - const size_t * /* region[3] */, - size_t /* dst_offset */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueCopyBufferToImage(cl_command_queue /* command_queue */, - cl_mem /* src_buffer */, - cl_mem /* dst_image */, - size_t /* src_offset */, - const size_t * /* dst_origin[3] */, - const size_t * /* region[3] */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY void * CL_API_CALL -clEnqueueMapBuffer(cl_command_queue /* command_queue */, - cl_mem /* buffer */, - cl_bool /* blocking_map */, - cl_map_flags /* map_flags */, - size_t /* offset */, - size_t /* cb */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY void * CL_API_CALL -clEnqueueMapImage(cl_command_queue /* command_queue */, - cl_mem /* image */, - cl_bool /* blocking_map */, - cl_map_flags /* map_flags */, - const size_t * /* origin[3] */, - const size_t * /* region[3] */, - size_t * /* image_row_pitch */, - size_t * /* image_slice_pitch */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueUnmapMemObject(cl_command_queue /* command_queue */, - cl_mem /* memobj */, - void * /* mapped_ptr */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueNDRangeKernel(cl_command_queue /* command_queue */, - cl_kernel /* kernel */, - cl_uint /* work_dim */, - const size_t * /* global_work_offset */, - const size_t * /* global_work_size */, - const size_t * /* local_work_size */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueTask(cl_command_queue /* command_queue */, - cl_kernel /* kernel */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueNativeKernel(cl_command_queue /* command_queue */, - void (*user_func)(void *), - void * /* args */, - size_t /* cb_args */, - cl_uint /* num_mem_objects */, - const cl_mem * /* mem_list */, - const void ** /* args_mem_loc */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueMarker(cl_command_queue /* command_queue */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueWaitForEvents(cl_command_queue /* command_queue */, - cl_uint /* num_events */, - const cl_event * /* event_list */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueBarrier(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0; - -#ifdef __cplusplus -} -#endif - -#endif // __OPENCL_CL_H - diff --git a/bullet/src/MiniCL/cl_gl.h b/bullet/src/MiniCL/cl_gl.h deleted file mode 100644 index 71bdaaa6e..000000000 --- a/bullet/src/MiniCL/cl_gl.h +++ /dev/null @@ -1,113 +0,0 @@ -/********************************************************************************** - * Copyright (c) 2008-2009 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and/or associated documentation files (the - * "Materials"), to deal in the Materials without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Materials, and to - * permit persons to whom the Materials are furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. - **********************************************************************************/ - -#ifndef __OPENCL_CL_GL_H -#define __OPENCL_CL_GL_H - -#ifdef __APPLE__ -#include -#else -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -// NOTE: Make sure that appropriate GL header file is included separately - -typedef cl_uint cl_gl_object_type; -typedef cl_uint cl_gl_texture_info; -typedef cl_uint cl_gl_platform_info; - -// cl_gl_object_type -#define CL_GL_OBJECT_BUFFER 0x2000 -#define CL_GL_OBJECT_TEXTURE2D 0x2001 -#define CL_GL_OBJECT_TEXTURE3D 0x2002 -#define CL_GL_OBJECT_RENDERBUFFER 0x2003 - -// cl_gl_texture_info -#define CL_GL_TEXTURE_TARGET 0x2004 -#define CL_GL_MIPMAP_LEVEL 0x2005 - -extern CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromGLBuffer(cl_context /* context */, - cl_mem_flags /* flags */, - GLuint /* bufobj */, - int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromGLTexture2D(cl_context /* context */, - cl_mem_flags /* flags */, - GLenum /* target */, - GLint /* miplevel */, - GLuint /* texture */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromGLTexture3D(cl_context /* context */, - cl_mem_flags /* flags */, - GLenum /* target */, - GLint /* miplevel */, - GLuint /* texture */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromGLRenderbuffer(cl_context /* context */, - cl_mem_flags /* flags */, - GLuint /* renderbuffer */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clGetGLObjectInfo(cl_mem /* memobj */, - cl_gl_object_type * /* gl_object_type */, - GLuint * /* gl_object_name */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clGetGLTextureInfo(cl_mem /* memobj */, - cl_gl_texture_info /* param_name */, - size_t /* param_value_size */, - void * /* param_value */, - size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueAcquireGLObjects(cl_command_queue /* command_queue */, - cl_uint /* num_objects */, - const cl_mem * /* mem_objects */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueReleaseGLObjects(cl_command_queue /* command_queue */, - cl_uint /* num_objects */, - const cl_mem * /* mem_objects */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; - -#ifdef __cplusplus -} -#endif - -#endif // __OPENCL_CL_GL_H diff --git a/bullet/src/MiniCL/cl_platform.h b/bullet/src/MiniCL/cl_platform.h deleted file mode 100644 index 522512996..000000000 --- a/bullet/src/MiniCL/cl_platform.h +++ /dev/null @@ -1,244 +0,0 @@ -/********************************************************************************** - * Copyright (c) 2008-2009 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and/or associated documentation files (the - * "Materials"), to deal in the Materials without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Materials, and to - * permit persons to whom the Materials are furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. - **********************************************************************************/ - -#ifndef __CL_PLATFORM_H -#define __CL_PLATFORM_H - -#ifdef __APPLE__ - /* Contains #defines for AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER below */ - #include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#define CL_API_ENTRY -#define CL_API_CALL -#ifdef __APPLE__ -#define CL_API_SUFFIX__VERSION_1_0 // AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER -#define CL_EXTENSION_WEAK_LINK __attribute__((weak_import)) -#else -#define CL_API_SUFFIX__VERSION_1_0 -#define CL_EXTENSION_WEAK_LINK -#endif - -#ifdef WIN32 -typedef signed __int8 int8_t; -typedef unsigned __int8 uint8_t; -typedef signed __int16 int16_t; -typedef unsigned __int16 uint16_t; -typedef signed __int32 int32_t; -typedef unsigned __int32 uint32_t; -typedef signed __int64 int64_t; -typedef unsigned __int64 uint64_t; - -typedef int8_t cl_char; -typedef uint8_t cl_uchar; -typedef int16_t cl_short ; -typedef uint16_t cl_ushort ; -typedef int32_t cl_int ; -typedef uint32_t cl_uint ; -typedef int64_t cl_long ; -typedef uint64_t cl_ulong ; - -typedef uint16_t cl_half ; -typedef float cl_float ; -typedef double cl_double ; - - -typedef int8_t cl_char2[2] ; -typedef int8_t cl_char4[4] ; -typedef int8_t cl_char8[8] ; -typedef int8_t cl_char16[16] ; -typedef uint8_t cl_uchar2[2] ; -typedef uint8_t cl_uchar4[4] ; -typedef uint8_t cl_uchar8[8] ; -typedef uint8_t cl_uchar16[16] ; - -typedef int16_t cl_short2[2] ; -typedef int16_t cl_short4[4] ; -typedef int16_t cl_short8[8] ; -typedef int16_t cl_short16[16] ; -typedef uint16_t cl_ushort2[2] ; -typedef uint16_t cl_ushort4[4] ; -typedef uint16_t cl_ushort8[8] ; -typedef uint16_t cl_ushort16[16] ; - -typedef int32_t cl_int2[2] ; -typedef int32_t cl_int4[4] ; -typedef int32_t cl_int8[8] ; -typedef int32_t cl_int16[16] ; -typedef uint32_t cl_uint2[2] ; -typedef uint32_t cl_uint4[4] ; -typedef uint32_t cl_uint8[8] ; -typedef uint32_t cl_uint16[16] ; - -typedef int64_t cl_long2[2] ; -typedef int64_t cl_long4[4] ; -typedef int64_t cl_long8[8] ; -typedef int64_t cl_long16[16] ; -typedef uint64_t cl_ulong2[2] ; -typedef uint64_t cl_ulong4[4] ; -typedef uint64_t cl_ulong8[8] ; -typedef uint64_t cl_ulong16[16] ; - -typedef float cl_float2[2] ; -typedef float cl_float4[4] ; -typedef float cl_float8[8] ; -typedef float cl_float16[16] ; - -typedef double cl_double2[2] ; -typedef double cl_double4[4] ; -typedef double cl_double8[8] ; -typedef double cl_double16[16] ; - - -#else -#include - -/* scalar types */ -typedef int8_t cl_char; -typedef uint8_t cl_uchar; -typedef int16_t cl_short __attribute__((aligned(2))); -typedef uint16_t cl_ushort __attribute__((aligned(2))); -typedef int32_t cl_int __attribute__((aligned(4))); -typedef uint32_t cl_uint __attribute__((aligned(4))); -typedef int64_t cl_long __attribute__((aligned(8))); -typedef uint64_t cl_ulong __attribute__((aligned(8))); - -typedef uint16_t cl_half __attribute__((aligned(2))); -typedef float cl_float __attribute__((aligned(4))); -typedef double cl_double __attribute__((aligned(8))); - - -/* - * Vector types - * - * Note: OpenCL requires that all types be naturally aligned. - * This means that vector types must be naturally aligned. - * For example, a vector of four floats must be aligned to - * a 16 byte boundary (calculated as 4 * the natural 4-byte - * alignment of the float). The alignment qualifiers here - * will only function properly if your compiler supports them - * and if you don't actively work to defeat them. For example, - * in order for a cl_float4 to be 16 byte aligned in a struct, - * the start of the struct must itself be 16-byte aligned. - * - * Maintaining proper alignment is the user's responsibility. - */ -typedef int8_t cl_char2[2] __attribute__((aligned(2))); -typedef int8_t cl_char4[4] __attribute__((aligned(4))); -typedef int8_t cl_char8[8] __attribute__((aligned(8))); -typedef int8_t cl_char16[16] __attribute__((aligned(16))); -typedef uint8_t cl_uchar2[2] __attribute__((aligned(2))); -typedef uint8_t cl_uchar4[4] __attribute__((aligned(4))); -typedef uint8_t cl_uchar8[8] __attribute__((aligned(8))); -typedef uint8_t cl_uchar16[16] __attribute__((aligned(16))); - -typedef int16_t cl_short2[2] __attribute__((aligned(4))); -typedef int16_t cl_short4[4] __attribute__((aligned(8))); -typedef int16_t cl_short8[8] __attribute__((aligned(16))); -typedef int16_t cl_short16[16] __attribute__((aligned(32))); -typedef uint16_t cl_ushort2[2] __attribute__((aligned(4))); -typedef uint16_t cl_ushort4[4] __attribute__((aligned(8))); -typedef uint16_t cl_ushort8[8] __attribute__((aligned(16))); -typedef uint16_t cl_ushort16[16] __attribute__((aligned(32))); - -typedef int32_t cl_int2[2] __attribute__((aligned(8))); -typedef int32_t cl_int4[4] __attribute__((aligned(16))); -typedef int32_t cl_int8[8] __attribute__((aligned(32))); -typedef int32_t cl_int16[16] __attribute__((aligned(64))); -typedef uint32_t cl_uint2[2] __attribute__((aligned(8))); -typedef uint32_t cl_uint4[4] __attribute__((aligned(16))); -typedef uint32_t cl_uint8[8] __attribute__((aligned(32))); -typedef uint32_t cl_uint16[16] __attribute__((aligned(64))); - -typedef int64_t cl_long2[2] __attribute__((aligned(16))); -typedef int64_t cl_long4[4] __attribute__((aligned(32))); -typedef int64_t cl_long8[8] __attribute__((aligned(64))); -typedef int64_t cl_long16[16] __attribute__((aligned(128))); -typedef uint64_t cl_ulong2[2] __attribute__((aligned(16))); -typedef uint64_t cl_ulong4[4] __attribute__((aligned(32))); -typedef uint64_t cl_ulong8[8] __attribute__((aligned(64))); -typedef uint64_t cl_ulong16[16] __attribute__((aligned(128))); - -typedef float cl_float2[2] __attribute__((aligned(8))); -typedef float cl_float4[4] __attribute__((aligned(16))); -typedef float cl_float8[8] __attribute__((aligned(32))); -typedef float cl_float16[16] __attribute__((aligned(64))); - -typedef double cl_double2[2] __attribute__((aligned(16))); -typedef double cl_double4[4] __attribute__((aligned(32))); -typedef double cl_double8[8] __attribute__((aligned(64))); -typedef double cl_double16[16] __attribute__((aligned(128))); -#endif - -#include - -/* and a few goodies to go with them */ -#define CL_CHAR_BIT 8 -#define CL_SCHAR_MAX 127 -#define CL_SCHAR_MIN (-127-1) -#define CL_CHAR_MAX CL_SCHAR_MAX -#define CL_CHAR_MIN CL_SCHAR_MIN -#define CL_UCHAR_MAX 255 -#define CL_SHRT_MAX 32767 -#define CL_SHRT_MIN (-32767-1) -#define CL_USHRT_MAX 65535 -#define CL_INT_MAX 2147483647 -#define CL_INT_MIN (-2147483647-1) -#define CL_UINT_MAX 0xffffffffU -#define CL_LONG_MAX ((cl_long) 0x7FFFFFFFFFFFFFFFLL) -#define CL_LONG_MIN ((cl_long) -0x7FFFFFFFFFFFFFFFLL - 1LL) -#define CL_ULONG_MAX ((cl_ulong) 0xFFFFFFFFFFFFFFFFULL) - -#define CL_FLT_DIG 6 -#define CL_FLT_MANT_DIG 24 -#define CL_FLT_MAX_10_EXP +38 -#define CL_FLT_MAX_EXP +128 -#define CL_FLT_MIN_10_EXP -37 -#define CL_FLT_MIN_EXP -125 -#define CL_FLT_RADIX 2 -#define CL_FLT_MAX 0x1.fffffep127f -#define CL_FLT_MIN 0x1.0p-126f -#define CL_FLT_EPSILON 0x1.0p-23f - -#define CL_DBL_DIG 15 -#define CL_DBL_MANT_DIG 53 -#define CL_DBL_MAX_10_EXP +308 -#define CL_DBL_MAX_EXP +1024 -#define CL_DBL_MIN_10_EXP -307 -#define CL_DBL_MIN_EXP -1021 -#define CL_DBL_RADIX 2 -#define CL_DBL_MAX 0x1.fffffffffffffp1023 -#define CL_DBL_MIN 0x1.0p-1022 -#define CL_DBL_EPSILON 0x1.0p-52 - -/* There are no vector types for half */ - -#ifdef __cplusplus -} -#endif - -#endif // __CL_PLATFORM_H diff --git a/bullet/src/btBulletCollisionCommon.h b/bullet/src/btBulletCollisionCommon.h deleted file mode 100644 index 34f03c364..000000000 --- a/bullet/src/btBulletCollisionCommon.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef BULLET_COLLISION_COMMON_H -#define BULLET_COLLISION_COMMON_H - -///Common headerfile includes for Bullet Collision Detection - -///Bullet's btCollisionWorld and btCollisionObject definitions -#include "BulletCollision/CollisionDispatch/btCollisionWorld.h" -#include "BulletCollision/CollisionDispatch/btCollisionObject.h" - -///Collision Shapes -#include "BulletCollision/CollisionShapes/btBoxShape.h" -#include "BulletCollision/CollisionShapes/btSphereShape.h" -#include "BulletCollision/CollisionShapes/btCapsuleShape.h" -#include "BulletCollision/CollisionShapes/btCylinderShape.h" -#include "BulletCollision/CollisionShapes/btConeShape.h" -#include "BulletCollision/CollisionShapes/btStaticPlaneShape.h" -#include "BulletCollision/CollisionShapes/btConvexHullShape.h" -#include "BulletCollision/CollisionShapes/btTriangleMesh.h" -#include "BulletCollision/CollisionShapes/btConvexTriangleMeshShape.h" -#include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h" -#include "BulletCollision/CollisionShapes/btTriangleMeshShape.h" -#include "BulletCollision/CollisionShapes/btTriangleIndexVertexArray.h" -#include "BulletCollision/CollisionShapes/btCompoundShape.h" -#include "BulletCollision/CollisionShapes/btTetrahedronShape.h" -#include "BulletCollision/CollisionShapes/btEmptyShape.h" -#include "BulletCollision/CollisionShapes/btMultiSphereShape.h" -#include "BulletCollision/CollisionShapes/btUniformScalingShape.h" - -///Narrowphase Collision Detector -#include "BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.h" - -//btSphereBoxCollisionAlgorithm is broken, use gjk for now -//#include "BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.h" -#include "BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h" - -///Dispatching and generation of collision pairs (broadphase) -#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h" -#include "BulletCollision/BroadphaseCollision/btSimpleBroadphase.h" -#include "BulletCollision/BroadphaseCollision/btAxisSweep3.h" -#include "BulletCollision/BroadphaseCollision/btMultiSapBroadphase.h" -#include "BulletCollision/BroadphaseCollision/btDbvtBroadphase.h" - -///Math library & Utils -#include "LinearMath/btQuaternion.h" -#include "LinearMath/btTransform.h" -#include "LinearMath/btDefaultMotionState.h" -#include "LinearMath/btQuickprof.h" -#include "LinearMath/btIDebugDraw.h" - -#endif //BULLET_COLLISION_COMMON_H - diff --git a/bullet/src/btBulletDynamicsCommon.h b/bullet/src/btBulletDynamicsCommon.h deleted file mode 100644 index 6b210c186..000000000 --- a/bullet/src/btBulletDynamicsCommon.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef BULLET_DYNAMICS_COMMON_H -#define BULLET_DYNAMICS_COMMON_H - -///Common headerfile includes for Bullet Dynamics, including Collision Detection -#include "btBulletCollisionCommon.h" - -#include "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h" -#include "BulletDynamics/Dynamics/btContinuousDynamicsWorld.h" - -#include "BulletDynamics/Dynamics/btSimpleDynamicsWorld.h" -#include "BulletDynamics/Dynamics/btRigidBody.h" - -#include "BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h" -#include "BulletDynamics/ConstraintSolver/btHingeConstraint.h" -#include "BulletDynamics/ConstraintSolver/btConeTwistConstraint.h" -#include "BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h" -#include "BulletDynamics/ConstraintSolver/btSliderConstraint.h" -#include "BulletDynamics/ConstraintSolver/btGeneric6DofSpringConstraint.h" -#include "BulletDynamics/ConstraintSolver/btUniversalConstraint.h" -#include "BulletDynamics/ConstraintSolver/btHinge2Constraint.h" - -#include "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h" - - -///Vehicle simulation, with wheel contact simulated by raycasts -#include "BulletDynamics/Vehicle/btRaycastVehicle.h" - - - - - - -#endif //BULLET_DYNAMICS_COMMON_H - diff --git a/bullet/src/ibmsdk/Makefile b/bullet/src/ibmsdk/Makefile deleted file mode 100644 index 42d5af9ce..000000000 --- a/bullet/src/ibmsdk/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -#### Visit Bullet library ibmsdk dirs and build code - -DIRS := \ -../BulletCollision/ibmsdk \ -../BulletDynamics/ibmsdk \ -../LinearMath/ibmsdk - -IBM_CELLSDK_VERSION := $(shell if [ -d /opt/cell ]; then echo "3.0"; fi) - -ifeq ("$(IBM_CELLSDK_VERSION)","3.0") - CELL_TOP ?= /opt/cell/sdk - include $(CELL_TOP)/buildutils/make.footer -else - CELL_TOP ?= /opt/ibm/cell-sdk/prototype - include $(CELL_TOP)/make.footer -endif diff --git a/data/CgFX/basic-lighting/Blinn.cgfx b/data/CgFX/basic-lighting/Blinn.cgfx new file mode 100644 index 000000000..5d6de57da --- /dev/null +++ b/data/CgFX/basic-lighting/Blinn.cgfx @@ -0,0 +1,456 @@ +/*********************************************************************NVMH3**** +$Revision$ + +Copyright NVIDIA Corporation 2007 +TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED +*AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS +BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES +WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, +BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY +LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF +NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + + +To learn more about shading, shaders, and to bounce ideas off other shader + authors and users, visit the NVIDIA Shader Library Forums at: + + http://developer.nvidia.com/forums/ + +******************************************************************************/ + +#define FLIP_TEXTURE_Y + +float Script : STANDARDSGLOBAL < + string UIWidget = "none"; + string ScriptClass = "object"; + string ScriptOrder = "standard"; + string ScriptOutput = "color"; + string Script = "Technique=Main;"; +> = 0.8; + +//// UN-TWEAKABLES - AUTOMATICALLY-TRACKED TRANSFORMS //////////////// + +float4x4 WorldITXf : WorldInverseTranspose < string UIWidget="None"; >; +float4x4 WvpXf : WorldViewProjection < string UIWidget="None"; >; +float4x4 WorldXf : World < string UIWidget="None"; >; +float4x4 ViewIXf : ViewInverse < string UIWidget="None"; >; + +//// TWEAKABLE PARAMETERS //////////////////// + +/// Point Lamp 0 //////////// +float3 Lamp0Pos : Position < + string Object = "PointLight0"; + string UIName = "Lamp 0 Position"; + string Space = "World"; +> = {-0.5f,2.0f,1.25f}; + +float3 Lamp0Color : Specular < + string UIName = "Lamp 0"; + string Object = "Pointlight0"; + string UIWidget = "Color"; +> = {1.0f,1.0f,1.0f}; + +// Ambient Light +float3 AmbiColor : Ambient < + string UIName = "Ambient Light"; + string UIWidget = "Color"; +> = {0.07f,0.07f,0.07f}; + +float Ks < + string UIWidget = "slider"; + float UIMin = 0.0; + float UIMax = 1.0; + float UIStep = 0.05; + string UIName = "Specular"; +> = 0.4; + +float Eccentricity < + string UIWidget = "slider"; + float UIMin = 0.0; + float UIMax = 1.0; + float UIStep = 0.0001; + string UIName = "Highlight Eccentricity"; +> = 0.3; + + +//////// COLOR & TEXTURE ///////////////////// + +/// the ambient material colour +float4 m_Ambient; + +/// the diffuse colour +float4 m_Diffuse; + +/// the specular colour +float4 m_Specular; + +/// the emission colour +float4 m_Emission; + +/// the transparency colour +float4 m_Transparency; + +/// the shininess +float m_Shininess; + +texture ColorTexture < + string ResourceName = "default_color.dds"; + string UIName = "Diffuse Texture"; + string ResourceType = "2D"; +>; + +sampler2D ColorSampler = sampler_state { + Texture = ; + MinFilter = LinearMipMapLinear; + MagFilter = Linear; + WrapS = Repeat; + WrapT = Repeat; +}; + +texture SpecularTexture < + string ResourceName = "checker.dds"; + string UIName = "Specular Texture"; + string ResourceType = "2D"; +>; + +sampler2D SpecularSampler = sampler_state { + Texture = ; + MinFilter = LinearMipMapLinear; + MagFilter = Linear; + WrapS = Repeat; + WrapT = Repeat; +}; + +texture TranspTexture < + string ResourceName = "checker.dds"; + string UIName = "Transp Texture"; + string ResourceType = "2D"; +>; + +sampler2D TranspSampler = sampler_state { + Texture = ; + MinFilter = LinearMipMapLinear; + MagFilter = Linear; + WrapS = Repeat; + WrapT = Repeat; +}; + +//////// CONNECTOR DATA STRUCTURES /////////// + +/* data from application vertex buffer */ +struct appdata { + float3 Position : POSITION; + float4 UV : TEXCOORD0; + float4 Normal : NORMAL; + float4 Tangent : TANGENT0; + float4 Binormal : BINORMAL0; +}; + +/* data passed from vertex shader to pixel shader */ +struct vertexOutput { + float4 HPosition : POSITION; + float2 UV : TEXCOORD0; + // The following values are passed in "World" coordinates since + // it tends to be the most flexible and easy for handling + // reflections, sky lighting, and other "global" effects. + float3 LightVec : TEXCOORD1; + float3 WorldNormal : TEXCOORD2; + float3 WorldTangent : TEXCOORD3; + float3 WorldBinormal : TEXCOORD4; + float3 WorldView : TEXCOORD5; +}; + +///////// VERTEX SHADING ///////////////////// + +/*********** Generic Vertex Shader ******/ + +vertexOutput std_VS(appdata IN) { + vertexOutput OUT = (vertexOutput)0; + OUT.WorldNormal = mul(WorldITXf,IN.Normal).xyz; + OUT.WorldTangent = mul(WorldITXf,IN.Tangent).xyz; + OUT.WorldBinormal = mul(WorldITXf,IN.Binormal).xyz; + float4 Po = float4(IN.Position.xyz,1); + float3 Pw = mul(WorldXf,Po).xyz; + OUT.LightVec = (Lamp0Pos - Pw); +#ifdef FLIP_TEXTURE_Y + OUT.UV = float2(IN.UV.x,(1.0-IN.UV.y)); +#else /* !FLIP_TEXTURE_Y */ + OUT.UV = IN.UV.xy; +#endif /* !FLIP_TEXTURE_Y */ + OUT.WorldView = normalize(float3(ViewIXf[0].w,ViewIXf[1].w,ViewIXf[2].w) - Pw); + OUT.HPosition = mul(WvpXf,Po); + return OUT; +} + +///////// PIXEL SHADING ////////////////////// + +// Utility function for blinn shading + +void blinn_shading(vertexOutput IN, + float3 LightColor, + float3 Nn, + float3 Ln, + float3 Vn, + out float3 DiffuseContrib, + out float3 SpecularContrib) +{ + float3 Hn = normalize(Vn + Ln); + float hdn = dot(Hn,Nn); + float3 R = reflect(-Ln,Nn); + float rdv = dot(R,Vn); + rdv = max(rdv,0.001); + float ldn=dot(Ln,Nn); + ldn = max(ldn,0.0); + float ndv = dot(Nn,Vn); + float hdv = dot(Hn,Vn); + float eSq = Eccentricity*Eccentricity; + float distrib = eSq / (rdv * rdv * (eSq - 1.0) + 1.0); + distrib = distrib * distrib; + float Gb = 2.0 * hdn * ndv / hdv; + float Gc = 2.0 * hdn * ldn / hdv; + float Ga = min(1.0,min(Gb,Gc)); + float fresnelHack = 1.0 - pow(ndv,5.0); + hdn = distrib * Ga * fresnelHack / ndv; + DiffuseContrib = ldn * LightColor; + SpecularContrib = max(hdn * Ks * LightColor,0.0); +} + +float4 std_PS(vertexOutput IN, + float face : FACE) : COLOR { + float3 diffContrib; + float3 specContrib; + float3 Ln = normalize(IN.LightVec); + float3 Vn = normalize(IN.WorldView); + float3 Nn = face * normalize(IN.WorldNormal); + blinn_shading(IN,Lamp0Color,Nn,Ln,Vn,diffContrib,specContrib); + float4 textureColor = tex2D(ColorSampler,IN.UV); + float3 diffuseTerm = textureColor.rgb * (diffContrib+AmbiColor); + float3 specularTerm = m_Specular.rgb * specContrib; + float3 result = specularTerm + diffuseTerm; + float alpha = textureColor.a; + return float4(result,alpha); +} + +float4 No_Texture_PS(vertexOutput IN, + float face : FACE) : COLOR { + float3 diffContrib; + float3 specContrib; + float3 Ln = normalize(IN.LightVec); + float3 Vn = normalize(IN.WorldView); + float3 Nn = face * normalize(IN.WorldNormal); + blinn_shading(IN,Lamp0Color,Nn,Ln,Vn,diffContrib,specContrib); + float3 diffuseTerm = m_Diffuse.rgb * (diffContrib+AmbiColor); + float3 specularTerm = m_Specular.rgb * specContrib; + float3 result = specularTerm + diffuseTerm; + float alpha = m_Diffuse.a; + return float4(result,alpha); +} + +float4 Specular_Texture_PS(vertexOutput IN, + float face : FACE) : COLOR { + float3 diffContrib; + float3 specContrib; + float3 Ln = normalize(IN.LightVec); + float3 Vn = normalize(IN.WorldView); + float3 Nn = face * normalize(IN.WorldNormal); + blinn_shading(IN,Lamp0Color,Nn,Ln,Vn,diffContrib,specContrib); + float4 textureColor = tex2D(ColorSampler,IN.UV); + float3 diffuseTerm = textureColor.rgb * (diffContrib+AmbiColor); + float4 specularTextureColor = tex2D(SpecularSampler, IN.UV); + float specularMask = dot( specularTextureColor.rgb, float3(1,1,1) ) / 3.0f; // average of r,g,b + float3 specularTerm = specularMask * specContrib; + float3 result = specularTerm + diffuseTerm; + float alpha = textureColor.a; + return float4(result,alpha); +} + +float4 Transp_Texture_PS(vertexOutput IN, + float face : FACE) : COLOR { + float3 diffContrib; + float3 specContrib; + float3 Ln = normalize(IN.LightVec); + float3 Vn = normalize(IN.WorldView); + float3 Nn = face * normalize(IN.WorldNormal); + blinn_shading(IN,Lamp0Color,Nn,Ln,Vn,diffContrib,specContrib); + float4 textureColor = tex2D(ColorSampler,IN.UV); + float4 transpColor = tex2D(TranspSampler,IN.UV); + float3 diffuseTerm = textureColor.rgb * (diffContrib+AmbiColor); + float3 specularTerm = m_Specular.rgb * specContrib; + float3 result = specularTerm + diffuseTerm; + float alpha = transpColor.r; // assuming r,g,and b has same value + return float4(result,alpha); +} + +float4 Specular_Transp_Texture_PS(vertexOutput IN, + float face : FACE) : COLOR { + float3 diffContrib; + float3 specContrib; + float3 Ln = normalize(IN.LightVec); + float3 Vn = normalize(IN.WorldView); + float3 Nn = face * normalize(IN.WorldNormal); + blinn_shading(IN,Lamp0Color,Nn,Ln,Vn,diffContrib,specContrib); + float4 textureColor = tex2D(ColorSampler,IN.UV); + float3 diffuseTerm = textureColor.rgb * (diffContrib+AmbiColor); + float4 specularTextureColor = tex2D(SpecularSampler, IN.UV); + float specularMask = dot( specularTextureColor.rgb, float3(1,1,1) ) / 3.0f; // average of r,g,b + float3 specularTerm = specularMask * specContrib; + float4 transpColor = tex2D(TranspSampler,IN.UV); + float3 result = specularTerm + diffuseTerm; + float alpha = transpColor.r; // assuming r,g,and b has same value + return float4(result,alpha); +} +///// TECHNIQUES ///////////////////////////// + + +technique Main < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = true; + CullFaceEnable = false; + BlendEnable = false; + DepthFunc = LEqual; + FragmentProgram = compile fp40 std_PS(); + } +} + +technique Main_Blending < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = false; + CullFaceEnable = false; + BlendEnable = true; + BlendFunc = float2(SrcAlpha, OneMinusSrcAlpha); + DepthFunc = LEqual; + FragmentProgram = compile fp40 std_PS(); + } +} + +technique Main_Alphatest < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = true; + CullFaceEnable = false; + AlphaFunc = float2(Greater, 0.1f); + AlphaTestEnable = true; + FragmentProgram = compile fp40 std_PS(); + } +} + +technique No_Texture < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = true; + CullFaceEnable = false; + BlendEnable = false; + DepthFunc = LEqual; + FragmentProgram = compile fp40 No_Texture_PS(); + } +} + +technique No_Texture_Blending < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = false; + CullFaceEnable = false; + BlendEnable = true; + BlendFunc = float2(SrcAlpha, OneMinusSrcAlpha); + DepthFunc = LEqual; + FragmentProgram = compile fp40 No_Texture_PS(); + } +} + +technique Main_Specular < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = true; + CullFaceEnable = false; + BlendEnable = false; + DepthFunc = LEqual; + FragmentProgram = compile fp40 Specular_Texture_PS(); + } +} + +technique Main_Specular_Blending < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = false; + CullFaceEnable = false; + BlendEnable = true; + BlendFunc = float2(SrcAlpha, OneMinusSrcAlpha); + DepthFunc = LEqual; + FragmentProgram = compile fp40 Specular_Texture_PS(); + } +} + +technique Main_Transp_Blending < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = false; + CullFaceEnable = false; + BlendEnable = true; + BlendFunc = float2(SrcAlpha, OneMinusSrcAlpha); + DepthFunc = LEqual; + FragmentProgram = compile fp40 Transp_Texture_PS(); + } +} + +technique Main_Specular_Transp_Blending < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = false; + CullFaceEnable = false; + BlendEnable = true; + BlendFunc = float2(SrcAlpha, OneMinusSrcAlpha); + DepthFunc = LEqual; + FragmentProgram = compile fp40 Specular_Transp_Texture_PS(); + } +} + +/////////////////////////////////////// eof // diff --git a/data/CgFX/basic-lighting/Blinn_bump_reflect.cgfx b/data/CgFX/basic-lighting/Blinn_bump_reflect.cgfx new file mode 100644 index 000000000..fccc94853 --- /dev/null +++ b/data/CgFX/basic-lighting/Blinn_bump_reflect.cgfx @@ -0,0 +1,257 @@ +/*********************************************************************NVMH3**** +$Revision$ + +Copyright NVIDIA Corporation 2007 +TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED +*AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS +BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES +WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, +BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY +LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF +NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + + +To learn more about shading, shaders, and to bounce ideas off other shader + authors and users, visit the NVIDIA Shader Library Forums at: + + http://developer.nvidia.com/forums/ + +******************************************************************************/ + +// #define FLIP_TEXTURE_Y + +float Script : STANDARDSGLOBAL < + string UIWidget = "none"; + string ScriptClass = "object"; + string ScriptOrder = "standard"; + string ScriptOutput = "color"; + string Script = "Technique=Main;"; +> = 0.8; + +//// UN-TWEAKABLES - AUTOMATICALLY-TRACKED TRANSFORMS //////////////// + +float4x4 WorldITXf : WorldInverseTranspose < string UIWidget="None"; >; +float4x4 WvpXf : WorldViewProjection < string UIWidget="None"; >; +float4x4 WorldXf : World < string UIWidget="None"; >; +float4x4 ViewIXf : ViewInverse < string UIWidget="None"; >; + +//// TWEAKABLE PARAMETERS //////////////////// + +/// Point Lamp 0 //////////// +float3 Lamp0Pos : Position < + string Object = "PointLight0"; + string UIName = "Lamp 0 Position"; + string Space = "World"; +> = {-0.5f,2.0f,1.25f}; +float3 Lamp0Color : Specular < + string UIName = "Lamp 0"; + string Object = "Pointlight0"; + string UIWidget = "Color"; +> = {1.0f,1.0f,1.0f}; + +// Ambient Light +float3 AmbiColor : Ambient < + string UIName = "Ambient Light"; + string UIWidget = "Color"; +> = {0.07f,0.07f,0.07f}; + +float Ks < + string UIWidget = "slider"; + float UIMin = 0.0; + float UIMax = 1.0; + float UIStep = 0.05; + string UIName = "Specular"; +> = 0.4; + +float Eccentricity < + string UIWidget = "slider"; + float UIMin = 0.0; + float UIMax = 1.0; + float UIStep = 0.0001; + string UIName = "Highlight Eccentricity"; +> = 0.3; + + +float Bump < + string UIWidget = "slider"; + float UIMin = 0.0; + float UIMax = 3.0; + float UIStep = 0.01; + string UIName = "Bumpiness"; +> = 1.0; + +float Kr < + string UIWidget = "slider"; + float UIMin = 0.0; + float UIMax = 1.0; + float UIStep = 0.01; + string UIName = "Reflection Strength"; +> = 0.5; + +//////// COLOR & TEXTURE ///////////////////// + +texture ColorTexture < + string ResourceName = "default_color.dds"; + string UIName = "Diffuse Texture"; + string ResourceType = "2D"; +>; + +sampler2D ColorSampler = sampler_state { + Texture = ; + MinFilter = LinearMipMapLinear; + MagFilter = Linear; + WrapS = Repeat; + WrapT = Repeat; +}; + +texture NormalTexture < + string ResourceName = "default_bump_normal.dds"; + string UIName = "Normal-Map Texture"; + string ResourceType = "2D"; +>; + +sampler2D NormalSampler = sampler_state { + Texture = ; + MinFilter = LinearMipMapLinear; + MagFilter = Linear; + WrapS = Repeat; + WrapT = Repeat; +}; + +texture EnvTexture : ENVIRONMENT < + string ResourceName = "default_reflection.dds"; + string UIName = "Environment"; + string ResourceType = "Cube"; +>; + +samplerCUBE EnvSampler = sampler_state { + Texture = ; + MagFilter = Linear; + MinFilter = LinearMipMapLinear; + WrapS = ClampToEdge; + WrapT = ClampToEdge; + WrapR = ClampToEdge; +}; + + +//////// CONNECTOR DATA STRUCTURES /////////// + +/* data from application vertex buffer */ +struct appdata { + float3 Position : POSITION; + float4 UV : TEXCOORD0; + float4 Normal : NORMAL; + float4 Tangent : TANGENT0; + float4 Binormal : BINORMAL0; +}; + +/* data passed from vertex shader to pixel shader */ +struct vertexOutput { + float4 HPosition : POSITION; + float2 UV : TEXCOORD0; + // The following values are passed in "World" coordinates since + // it tends to be the most flexible and easy for handling + // reflections, sky lighting, and other "global" effects. + float3 LightVec : TEXCOORD1; + float3 WorldNormal : TEXCOORD2; + float3 WorldTangent : TEXCOORD3; + float3 WorldBinormal : TEXCOORD4; + float3 WorldView : TEXCOORD5; +}; + +///////// VERTEX SHADING ///////////////////// + +/*********** Generic Vertex Shader ******/ + +vertexOutput std_VS(appdata IN) { + vertexOutput OUT = (vertexOutput)0; + OUT.WorldNormal = mul(WorldITXf,IN.Normal).xyz; + OUT.WorldTangent = mul(WorldITXf,IN.Tangent).xyz; + OUT.WorldBinormal = mul(WorldITXf,IN.Binormal).xyz; + float4 Po = float4(IN.Position.xyz,1); + float3 Pw = mul(WorldXf,Po).xyz; + OUT.LightVec = (Lamp0Pos - Pw); +#ifdef FLIP_TEXTURE_Y + OUT.UV = float2(IN.UV.x,(1.0-IN.UV.y)); +#else /* !FLIP_TEXTURE_Y */ + OUT.UV = IN.UV.xy; +#endif /* !FLIP_TEXTURE_Y */ + OUT.WorldView = normalize(float3(ViewIXf[0].w,ViewIXf[1].w,ViewIXf[2].w) - Pw); + OUT.HPosition = mul(WvpXf,Po); + return OUT; +} + +///////// PIXEL SHADING ////////////////////// + +// Utility function for blinn shading + +void blinn_shading(vertexOutput IN, + float3 LightColor, + float3 Nn, + float3 Ln, + float3 Vn, + out float3 DiffuseContrib, + out float3 SpecularContrib) +{ + float3 Hn = normalize(Vn + Ln); + float hdn = dot(Hn,Nn); + float3 R = reflect(-Ln,Nn); + float rdv = dot(R,Vn); + rdv = max(rdv,0.001); + float ldn=dot(Ln,Nn); + ldn = max(ldn,0.0); + float ndv = dot(Nn,Vn); + float hdv = dot(Hn,Vn); + float eSq = Eccentricity*Eccentricity; + float distrib = eSq / (rdv * rdv * (eSq - 1.0) + 1.0); + distrib = distrib * distrib; + float Gb = 2.0 * hdn * ndv / hdv; + float Gc = 2.0 * hdn * ldn / hdv; + float Ga = min(1.0,min(Gb,Gc)); + float fresnelHack = 1.0 - pow(ndv,5.0); + hdn = distrib * Ga * fresnelHack / ndv; + DiffuseContrib = ldn * LightColor; + SpecularContrib = hdn * Ks * LightColor; +} + +float4 std_PS(vertexOutput IN) : COLOR { + float3 diffContrib; + float3 specContrib; + float3 Ln = normalize(IN.LightVec); + float3 Vn = normalize(IN.WorldView); + float3 Nn = normalize(IN.WorldNormal); + float3 Tn = normalize(IN.WorldTangent); + float3 Bn = normalize(IN.WorldBinormal); + float3 bump = Bump * (tex2D(NormalSampler,IN.UV).rgb - float3(0.5,0.5,0.5)); + Nn = Nn + bump.x*Tn + bump.y*Bn; + Nn = normalize(Nn); + blinn_shading(IN,Lamp0Color,Nn,Ln,Vn,diffContrib,specContrib); + float3 diffuseColor = tex2D(ColorSampler,IN.UV).rgb; + float3 result = specContrib+(diffuseColor*(diffContrib+AmbiColor)); + float3 R = -reflect(Vn,Nn); + float3 reflColor = Kr * texCUBE(EnvSampler,R.xyz).rgb; + result += diffuseColor*reflColor; + return float4(result,1); +} + +///// TECHNIQUES ///////////////////////////// + +technique Main < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = true; + CullFaceEnable = false; + BlendEnable = false; + DepthFunc = LEqual; + FragmentProgram = compile fp40 std_PS(); + } +} + +/////////////////////////////////////// eof // diff --git a/data/CgFX/basic-lighting/Document1.dae b/data/CgFX/basic-lighting/Document1.dae new file mode 100644 index 000000000..e7ceae74b --- /dev/null +++ b/data/CgFX/basic-lighting/Document1.dae @@ -0,0 +1,1394 @@ + + + + + Administrator + NVIDIA FX Composer 2.5 + + + + 2009-01-01T09:24:30Z + FXComposer, NVIDIA + 2009-02-05T07:00:24Z + + + <unit/> + <up_axis>Y_UP</up_axis> + </asset> + <library_visual_scenes> + <visual_scene id="DefaultScene" name="DefaultScene"> + <node id="Node" name="Node" layer=""> + <matrix sid="">1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</matrix> + <instance_geometry url="#Sphere" sid="GeometryInstance" name="Sphere"> + <bind_material> + <technique_common> + <instance_material symbol="SphereMaterial" target="#Lambert_bump_reflect"/> + </technique_common> + </bind_material> + </instance_geometry> + </node> + <extra type="evaluatescene_enables"> + <technique profile="NVIDIA_FXCOMPOSER"/> + </extra> + </visual_scene> + </library_visual_scenes> + <library_images> + <image id="default_color" name="default_color"> + <init_from>../../../../program%20files%20(x86)/nvidia%20corporation/fx%20composer%202.5/media/textures/default_color.dds</init_from> + </image> + <image id="checker" name="checker"> + <init_from>../../../../program%20files%20(x86)/nvidia%20corporation/fx%20composer%202.5/media/textures/2d/checker.dds</init_from> + </image> + <image id="default_bump_normal" name="default_bump_normal"> + <init_from>../../../../program%20files%20(x86)/nvidia%20corporation/fx%20composer%202.5/media/textures/default_bump_normal.dds</init_from> + </image> + <image id="default_reflection" name="default_reflection"> + <init_from>../../../../program%20files%20(x86)/nvidia%20corporation/fx%20composer%202.5/media/textures/default_reflection.dds</init_from> + </image> + </library_images> + <library_effects> + <effect id="Effect" name="DefaultEffect"> + <profile_COMMON> + <newparam sid="Script"> + <semantic>STANDARDSGLOBAL</semantic> + <float>0.8</float> + </newparam> + <newparam sid="EmissionColor"> + <semantic>EMISSION</semantic> + <float4>0 0 0 1</float4> + </newparam> + <newparam sid="AmbientColor"> + <float4>0 0 0 1</float4> + </newparam> + <newparam sid="DiffuseColor"> + <float4>1 1 1 1</float4> + </newparam> + <newparam sid="EnvironmentColor"> + <float4>1 1 1 1</float4> + </newparam> + <newparam sid="Reflectivity"> + <float>0.5</float> + </newparam> + <newparam sid="SpecularColor"> + <semantic>SPECULAR</semantic> + <float4>1 1 1 1</float4> + </newparam> + <newparam sid="SpecularShininess"> + <float>10</float> + </newparam> + <newparam sid="TransparentColor"> + <float4>0 0 0 1</float4> + </newparam> + <newparam sid="Transparency"> + <float>1</float> + </newparam> + <newparam sid="Index_Of_Refraction"> + <float>1</float> + </newparam> + <technique sid="CommonProfile"> + <phong> + <emission> + <param ref="EmissionColor"/> + </emission> + <ambient> + <param ref="AmbientColor"/> + </ambient> + <diffuse> + <param ref="DiffuseColor"/> + </diffuse> + <specular> + <param ref="SpecularColor"/> + </specular> + <shininess> + <param ref="SpecularShininess"/> + </shininess> + <reflective> + <param ref="EnvironmentColor"/> + </reflective> + <reflectivity> + <param ref="Reflectivity"/> + </reflectivity> + <transparent> + <param ref="TransparentColor"/> + </transparent> + <transparency> + <param ref="Transparency"/> + </transparency> + <index_of_refraction> + <param ref="Index_Of_Refraction"/> + </index_of_refraction> + </phong> + </technique> + </profile_COMMON> + </effect> + <effect id="Effect1" name="Phong"> + <profile_COMMON> + <technique sid="__fxc_remove_profile_COMMON"> + <constant/> + </technique> + </profile_COMMON> + <extra type="import"> + <technique profile="NVIDIA_FXCOMPOSER"> + <import url="Phong.cgfx" compiler_options="" profile="cgfx"/> + </technique> + </extra> + </effect> + <effect id="Effect2" name="Blinn"> + <profile_COMMON> + <technique sid="__fxc_remove_profile_COMMON"> + <constant/> + </technique> + </profile_COMMON> + <extra type="import"> + <technique profile="NVIDIA_FXCOMPOSER"> + <import url="Blinn.cgfx" compiler_options="" profile="cgfx"/> + </technique> + </extra> + </effect> + <effect id="Effect3" name="Lambert"> + <profile_COMMON> + <technique sid="__fxc_remove_profile_COMMON"> + <constant/> + </technique> + </profile_COMMON> + <extra type="import"> + <technique profile="NVIDIA_FXCOMPOSER"> + <import url="Lambert.cgfx" compiler_options="" profile="cgfx"/> + </technique> + </extra> + </effect> + <effect id="Effect4" name="simple"> + <profile_COMMON> + <technique sid="__fxc_remove_profile_COMMON"> + <constant/> + </technique> + </profile_COMMON> + <extra type="import"> + <technique profile="NVIDIA_FXCOMPOSER"> + <import url="simple.cgfx" compiler_options="" profile="cgfx"/> + </technique> + </extra> + </effect> + <effect id="Effect5" name="Phong_bump_reflect"> + <profile_COMMON> + <technique sid="__fxc_remove_profile_COMMON"> + <constant/> + </technique> + </profile_COMMON> + <extra type="import"> + <technique profile="NVIDIA_FXCOMPOSER"> + <import url="Phong_bump_reflect.cgfx" compiler_options="" profile="cgfx"/> + </technique> + </extra> + </effect> + <effect id="Effect6" name="Blinn_bump_reflect"> + <profile_COMMON> + <technique sid="__fxc_remove_profile_COMMON"> + <constant/> + </technique> + </profile_COMMON> + <extra type="import"> + <technique profile="NVIDIA_FXCOMPOSER"> + <import url="Blinn_bump_reflect.cgfx" compiler_options="" profile="cgfx"/> + </technique> + </extra> + </effect> + <effect id="Effect7" name="Lambert_bump_reflect"> + <profile_COMMON> + <technique sid="__fxc_remove_profile_COMMON"> + <constant/> + </technique> + </profile_COMMON> + <extra type="import"> + <technique profile="NVIDIA_FXCOMPOSER"> + <import url="Lambert_bump_reflect.cgfx" compiler_options="" profile="cgfx"/> + </technique> + </extra> + </effect> + </library_effects> + <library_materials> + <material id="DefaultMaterial" name="DefaultMaterial"> + <instance_effect url="#Effect"> + <technique_hint platform="PC-OGL" ref="CommonProfile"/> + <technique_hint platform="PC-D3D" ref="CommonProfile"/> + <technique_hint platform="PC-D3D10" ref="CommonProfile"/> + <setparam ref="EmissionColor"> + <float4>0 0 0 1</float4> + </setparam> + <setparam ref="AmbientColor"> + <float4>0 0 0 1</float4> + </setparam> + <setparam ref="DiffuseColor"> + <float4>1 1 1 1</float4> + </setparam> + <setparam ref="EnvironmentColor"> + <float4>1 1 1 1</float4> + </setparam> + <setparam ref="Reflectivity"> + <float>0.5</float> + </setparam> + <setparam ref="SpecularColor"> + <float4>1 1 1 1</float4> + </setparam> + <setparam ref="SpecularShininess"> + <float>10</float> + </setparam> + <setparam ref="TransparentColor"> + <float4>0 0 0 1</float4> + </setparam> + <setparam ref="Transparency"> + <float>1</float> + </setparam> + <setparam ref="Index_Of_Refraction"> + <float>1</float> + </setparam> + </instance_effect> + </material> + <material id="Phong" name="Phong_Material"> + <instance_effect url="#Effect1"> + <technique_hint platform="PC-OGL" ref="Main"/> + <setparam ref="Script"> + <float>0.8</float> + </setparam> + <setparam ref="WorldITXf"> + <float4x4>1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</float4x4> + </setparam> + <setparam ref="WvpXf"> + <float4x4>-0.0188329 1.50929 0.835685 0.835583 -5.4207e-007 2.29578 -0.549411 -0.549344 3.33303 0.00852854 0.00472183 0.00472126 9.23178e-006 -1.5976e-005 5.10234 5.10536</float4x4> + </setparam> + <setparam ref="WorldXf"> + <float4x4>1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</float4x4> + </setparam> + <setparam ref="ViewIXf"> + <float4x4>-0.00565031 -2.10329e-007 0.999984 0 0.549335 0.835597 0.00310409 0 -0.835583 0.549344 -0.00472128 -0 -4.26595 2.8046 -0.0241066 1</float4x4> + </setparam> + <setparam ref="Lamp0Pos"> + <float3>2 2 2</float3> + </setparam> + <setparam ref="Lamp0Color"> + <float4>1 1 1 1</float4> + </setparam> + <setparam ref="AmbiColor"> + <float3>0.07 0.07 0.07</float3> + </setparam> + <setparam ref="Ks"> + <float>0.4</float> + </setparam> + <setparam ref="SpecExpon"> + <float>55</float> + </setparam> + <setparam ref="m_Ambient"> + <float4>0 0 0 0</float4> + </setparam> + <setparam ref="m_Diffuse"> + <float4>0 0 0 0</float4> + </setparam> + <setparam ref="m_Specular"> + <float4>1 1 1 1</float4> + </setparam> + <setparam ref="m_Emission"> + <float4>0 0 0 0</float4> + </setparam> + <setparam ref="m_Transparency"> + <float4>0 0 0 0</float4> + </setparam> + <setparam ref="m_Shininess"> + <float>0</float> + </setparam> + <setparam ref="ColorTexture"> + <surface type="2D"> + <init_from>default_color</init_from> + <format>R8G8B8A8</format> + <size>1024 512 1</size> + </surface> + </setparam> + <setparam ref="SpecularTexture"> + <surface type="2D"> + <init_from>checker</init_from> + <format>R8G8B8A8</format> + <size>256 256 1</size> + </surface> + </setparam> + </instance_effect> + </material> + <material id="Blinn" name="Blinn_Material"> + <instance_effect url="#Effect2"> + <technique_hint platform="PC-OGL" ref="Main"/> + <setparam ref="Script"> + <float>0.8</float> + </setparam> + <setparam ref="WorldITXf"> + <float4x4>1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</float4x4> + </setparam> + <setparam ref="WvpXf"> + <float4x4>-0.0188329 1.50929 0.835685 0.835583 -5.4207e-007 2.29578 -0.549411 -0.549344 3.33303 0.00852854 0.00472183 0.00472126 9.23178e-006 -1.5976e-005 5.10234 5.10536</float4x4> + </setparam> + <setparam ref="WorldXf"> + <float4x4>1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</float4x4> + </setparam> + <setparam ref="ViewIXf"> + <float4x4>-0.00565031 -2.10329e-007 0.999984 0 0.549335 0.835597 0.00310409 0 -0.835583 0.549344 -0.00472128 -0 -4.26595 2.8046 -0.0241066 1</float4x4> + </setparam> + <setparam ref="Lamp0Pos"> + <float3>2 2 2</float3> + </setparam> + <setparam ref="Lamp0Color"> + <float4>1 1 1 1</float4> + </setparam> + <setparam ref="AmbiColor"> + <float3>0.07 0.07 0.07</float3> + </setparam> + <setparam ref="Ks"> + <float>0.4</float> + </setparam> + <setparam ref="Eccentricity"> + <float>0.3</float> + </setparam> + <setparam ref="m_Ambient"> + <float4>0 0 0 0</float4> + </setparam> + <setparam ref="m_Diffuse"> + <float4>0 0 0 0</float4> + </setparam> + <setparam ref="m_Specular"> + <float4>0 0 0 0</float4> + </setparam> + <setparam ref="m_Emission"> + <float4>0 0 0 0</float4> + </setparam> + <setparam ref="m_Transparency"> + <float4>0 0 0 0</float4> + </setparam> + <setparam ref="m_Shininess"> + <float>0</float> + </setparam> + <setparam ref="ColorTexture"> + <surface type="2D"> + <init_from>default_color</init_from> + <format>R8G8B8A8</format> + <size>1024 512 1</size> + </surface> + </setparam> + <setparam ref="SpecularTexture"> + <surface type="2D"> + <init_from>checker</init_from> + <format>R8G8B8A8</format> + <size>256 256 1</size> + </surface> + </setparam> + </instance_effect> + </material> + <material id="Lambert" name="Lambert_Material"> + <instance_effect url="#Effect3"> + <technique_hint platform="PC-OGL" ref="Main"/> + <setparam ref="Script"> + <float>0.8</float> + </setparam> + <setparam ref="WorldITXf"> + <float4x4>1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</float4x4> + </setparam> + <setparam ref="WvpXf"> + <float4x4>-0.0188329 1.50929 0.835685 0.835583 -5.4207e-007 2.29578 -0.549411 -0.549344 3.33303 0.00852854 0.00472183 0.00472126 9.23178e-006 -1.5976e-005 5.10234 5.10536</float4x4> + </setparam> + <setparam ref="WorldXf"> + <float4x4>1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</float4x4> + </setparam> + <setparam ref="ViewIXf"> + <float4x4>-0.00565031 -2.10329e-007 0.999984 0 0.549335 0.835597 0.00310409 0 -0.835583 0.549344 -0.00472128 -0 -4.26595 2.8046 -0.0241066 1</float4x4> + </setparam> + <setparam ref="Lamp0Pos"> + <float3>2 2 2</float3> + </setparam> + <setparam ref="Lamp0Color"> + <float4>1 1 1 1</float4> + </setparam> + <setparam ref="AmbiColor"> + <float3>0.07 0.07 0.07</float3> + </setparam> + <setparam ref="m_Ambient"> + <float4>0 0 0 0</float4> + </setparam> + <setparam ref="m_Diffuse"> + <float4>0 0 0 0</float4> + </setparam> + <setparam ref="m_Specular"> + <float4>0 0 0 0</float4> + </setparam> + <setparam ref="m_Emission"> + <float4>0 0 0 0</float4> + </setparam> + <setparam ref="m_Transparency"> + <float4>0 0 0 0</float4> + </setparam> + <setparam ref="m_Shininess"> + <float>0</float> + </setparam> + <setparam ref="ColorTexture"> + <surface type="2D"> + <init_from>default_color</init_from> + <format>R8G8B8A8</format> + <size>1024 512 1</size> + </surface> + </setparam> + </instance_effect> + </material> + <material id="simple" name="simple_Material"> + <instance_effect url="#Effect4"> + <technique_hint platform="PC-OGL" ref="Main"/> + </instance_effect> + </material> + <material id="Phong_bump_reflect" name="Phong_bump_reflect_Material"> + <instance_effect url="#Effect5"> + <technique_hint platform="PC-OGL" ref="Main"/> + <setparam ref="Script"> + <float>0.8</float> + </setparam> + <setparam ref="WorldITXf"> + <float4x4>1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</float4x4> + </setparam> + <setparam ref="WvpXf"> + <float4x4>-0.0188329 1.50929 0.835685 0.835583 -5.4207e-007 2.29578 -0.549411 -0.549344 3.33303 0.00852854 0.00472183 0.00472126 9.23178e-006 -1.5976e-005 5.10234 5.10536</float4x4> + </setparam> + <setparam ref="WorldXf"> + <float4x4>1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</float4x4> + </setparam> + <setparam ref="ViewIXf"> + <float4x4>-0.00565031 -2.10329e-007 0.999984 0 0.549335 0.835597 0.00310409 0 -0.835583 0.549344 -0.00472128 -0 -4.26595 2.8046 -0.0241066 1</float4x4> + </setparam> + <setparam ref="Lamp0Pos"> + <float3>2 2 2</float3> + </setparam> + <setparam ref="Lamp0Color"> + <float4>1 1 1 1</float4> + </setparam> + <setparam ref="AmbiColor"> + <float3>0.07 0.07 0.07</float3> + </setparam> + <setparam ref="Ks"> + <float>0.4</float> + </setparam> + <setparam ref="SpecExpon"> + <float>55</float> + </setparam> + <setparam ref="Bump"> + <float>1</float> + </setparam> + <setparam ref="Kr"> + <float>0.5</float> + </setparam> + <setparam ref="ColorTexture"> + <surface type="2D"> + <init_from>default_color</init_from> + <format>R8G8B8A8</format> + <size>1024 512 1</size> + </surface> + </setparam> + <setparam ref="NormalTexture"> + <surface type="2D"> + <init_from>default_bump_normal</init_from> + <format>R8G8B8A8</format> + <size>1024 512 1</size> + </surface> + </setparam> + <setparam ref="EnvTexture"> + <surface type="CUBE"> + <init_from>default_reflection</init_from> + <format>R8G8B8A8</format> + <size>512 512 1</size> + </surface> + </setparam> + </instance_effect> + </material> + <material id="Blinn_bump_reflect" name="Blinn_bump_reflect_Material"> + <instance_effect url="#Effect6"> + <technique_hint platform="PC-OGL" ref="Main"/> + <setparam ref="Script"> + <float>0.8</float> + </setparam> + <setparam ref="WorldITXf"> + <float4x4>1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</float4x4> + </setparam> + <setparam ref="WvpXf"> + <float4x4>-0.0188329 1.50929 0.835685 0.835583 -5.4207e-007 2.29578 -0.549411 -0.549344 3.33303 0.00852854 0.00472183 0.00472126 9.23178e-006 -1.5976e-005 5.10234 5.10536</float4x4> + </setparam> + <setparam ref="WorldXf"> + <float4x4>1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</float4x4> + </setparam> + <setparam ref="ViewIXf"> + <float4x4>-0.00565031 -2.10329e-007 0.999984 0 0.549335 0.835597 0.00310409 0 -0.835583 0.549344 -0.00472128 -0 -4.26595 2.8046 -0.0241066 1</float4x4> + </setparam> + <setparam ref="Lamp0Pos"> + <float3>2 2 2</float3> + </setparam> + <setparam ref="Lamp0Color"> + <float4>1 1 1 1</float4> + </setparam> + <setparam ref="AmbiColor"> + <float3>0.07 0.07 0.07</float3> + </setparam> + <setparam ref="Ks"> + <float>0.4</float> + </setparam> + <setparam ref="Eccentricity"> + <float>0.3</float> + </setparam> + <setparam ref="Bump"> + <float>1</float> + </setparam> + <setparam ref="Kr"> + <float>0.5</float> + </setparam> + <setparam ref="ColorTexture"> + <surface type="2D"> + <init_from>default_color</init_from> + <format>R8G8B8A8</format> + <size>1024 512 1</size> + </surface> + </setparam> + <setparam ref="NormalTexture"> + <surface type="2D"> + <init_from>default_bump_normal</init_from> + <format>R8G8B8A8</format> + <size>1024 512 1</size> + </surface> + </setparam> + <setparam ref="EnvTexture"> + <surface type="CUBE"> + <init_from>default_reflection</init_from> + <format>R8G8B8A8</format> + <size>512 512 1</size> + </surface> + </setparam> + </instance_effect> + </material> + <material id="Lambert_bump_reflect" name="Lambert_bump_reflect_Material"> + <instance_effect url="#Effect7"> + <technique_hint platform="PC-OGL" ref="Main"/> + <setparam ref="Script"> + <float>0.8</float> + </setparam> + <setparam ref="WorldITXf"> + <float4x4>1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</float4x4> + </setparam> + <setparam ref="WvpXf"> + <float4x4>-0.0188329 1.50929 0.835685 0.835583 -5.4207e-007 2.29578 -0.549411 -0.549344 3.33303 0.00852854 0.00472183 0.00472126 9.23178e-006 -1.5976e-005 5.10234 5.10536</float4x4> + </setparam> + <setparam ref="WorldXf"> + <float4x4>1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</float4x4> + </setparam> + <setparam ref="ViewIXf"> + <float4x4>-0.00565031 -2.10329e-007 0.999984 0 0.549335 0.835597 0.00310409 0 -0.835583 0.549344 -0.00472128 -0 -4.26595 2.8046 -0.0241066 1</float4x4> + </setparam> + <setparam ref="Lamp0Pos"> + <float3>-0.5 2 1.25</float3> + </setparam> + <setparam ref="Lamp0Color"> + <float3>1 1 1</float3> + </setparam> + <setparam ref="AmbiColor"> + <float3>0.07 0.07 0.07</float3> + </setparam> + <setparam ref="Bump"> + <float>1</float> + </setparam> + <setparam ref="Kr"> + <float>1</float> + </setparam> + <setparam ref="KrMin"> + <float>0.05</float> + </setparam> + <setparam ref="FresExp"> + <float>4</float> + </setparam> + <setparam ref="ColorTexture"> + <surface type="2D"> + <init_from>default_color</init_from> + <format>R8G8B8A8</format> + <size>1024 512 1</size> + </surface> + </setparam> + <setparam ref="NormalTexture"> + <surface type="2D"> + <init_from>default_bump_normal</init_from> + <format>R8G8B8A8</format> + <size>1024 512 1</size> + </surface> + </setparam> + <setparam ref="EnvTexture"> + <surface type="CUBE"> + <init_from>default_reflection</init_from> + <format>R8G8B8A8</format> + <size>512 512 1</size> + </surface> + </setparam> + </instance_effect> + </material> + </library_materials> + <library_geometries> + <geometry id="Sphere" name="Sphere"> + <mesh> + <source id="FXStream" name="FXStream"> + <float_array id="FXStream-array" count="2268">0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 -0 -1 -0 -0 -1 -0 -0 -1 -0 -0 -1 -0 -0 -1 -0 -0 -1 -0 -0 -1 -0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0.116093 -0.993238 0 0.112719 -0.993238 0.0277828 0.102795 -0.993238 0.0539509 0.0868966 -0.993238 0.0769837 0.0659481 -0.993238 0.0955424 0.041167 -0.993238 0.108549 0.0139934 -0.993238 0.115246 -0.0139934 -0.993238 0.115246 -0.041167 -0.993238 0.108549 -0.0659482 -0.993238 0.0955424 -0.0868966 -0.993238 0.0769837 -0.102795 -0.993238 0.0539509 -0.112719 -0.993238 0.0277828 -0.116093 -0.993238 -1.01491e-008 -0.112719 -0.993238 -0.0277828 -0.102795 -0.993238 -0.0539509 -0.0868966 -0.993238 -0.0769837 -0.0659481 -0.993238 -0.0955424 -0.041167 -0.993238 -0.108549 -0.0139934 -0.993238 -0.115246 0.0139934 -0.993238 -0.115246 0.041167 -0.993238 -0.108548 0.0659482 -0.993238 -0.0955424 0.0868966 -0.993238 -0.0769836 0.102795 -0.993238 -0.0539509 0.112719 -0.993238 -0.0277828 0.116093 -0.993238 2.02983e-008 0.230616 -0.973045 0 0.223915 -0.973045 0.05519 0.2042 -0.973045 0.107173 0.172618 -0.973045 0.152927 0.131005 -0.973045 0.189793 0.0817775 -0.973045 0.21563 0.0277977 -0.973045 0.228934 -0.0277977 -0.973045 0.228934 -0.0817775 -0.973045 0.21563 -0.131005 -0.973045 0.189793 -0.172618 -0.973045 0.152927 -0.2042 -0.973045 0.107173 -0.223915 -0.973045 0.05519 -0.230616 -0.973045 -2.01611e-008 -0.223915 -0.973045 -0.05519 -0.2042 -0.973045 -0.107173 -0.172618 -0.973045 -0.152927 -0.131005 -0.973045 -0.189793 -0.0817774 -0.973045 -0.21563 -0.0277977 -0.973045 -0.228934 0.0277977 -0.973045 -0.228934 0.0817776 -0.973045 -0.21563 0.131005 -0.973045 -0.189793 0.172619 -0.973045 -0.152927 0.2042 -0.973045 -0.107173 0.223915 -0.973045 -0.05519 0.230616 -0.973045 4.03222e-008 0.34202 -0.939693 0 0.332082 -0.939693 0.0818508 0.302844 -0.939693 0.158945 0.256006 -0.939693 0.226801 0.19429 -0.939693 0.281477 0.121282 -0.939693 0.319794 0.041226 -0.939693 0.339526 -0.041226 -0.939693 0.339526 -0.121282 -0.939693 0.319794 -0.19429 -0.939693 0.281477 -0.256006 -0.939693 0.226801 -0.302844 -0.939693 0.158945 -0.332082 -0.939693 0.0818508 -0.34202 -0.939693 -2.99004e-008 -0.332082 -0.939693 -0.0818508 -0.302844 -0.939693 -0.158945 -0.256006 -0.939693 -0.226801 -0.19429 -0.939693 -0.281477 -0.121282 -0.939693 -0.319794 -0.041226 -0.939693 -0.339526 0.041226 -0.939693 -0.339526 0.121282 -0.939693 -0.319794 0.19429 -0.939693 -0.281477 0.256006 -0.939693 -0.226801 0.302844 -0.939693 -0.158945 0.332082 -0.939693 -0.0818508 0.34202 -0.939693 5.98007e-008 0.448799 -0.893633 0 0.435758 -0.893633 0.107405 0.397392 -0.893633 0.208567 0.335931 -0.893633 0.297609 0.254947 -0.893633 0.369354 0.159146 -0.893633 0.419635 0.0540968 -0.893633 0.445527 -0.0540968 -0.893633 0.445527 -0.159146 -0.893633 0.419634 -0.254947 -0.893633 0.369354 -0.335931 -0.893633 0.297609 -0.397392 -0.893633 0.208567 -0.435758 -0.893633 0.107405 -0.448799 -0.893633 -3.92353e-008 -0.435758 -0.893633 -0.107405 -0.397392 -0.893633 -0.208567 -0.335931 -0.893633 -0.297609 -0.254947 -0.893633 -0.369355 -0.159146 -0.893633 -0.419635 -0.0540968 -0.893633 -0.445527 0.0540968 -0.893633 -0.445527 0.159146 -0.893633 -0.419634 0.254947 -0.893633 -0.369354 0.335931 -0.893633 -0.297609 0.397392 -0.893633 -0.208567 0.435758 -0.893633 -0.107405 0.448799 -0.893633 7.84705e-008 0.549509 -0.835488 0 0.533541 -0.835488 0.131506 0.486566 -0.835488 0.25537 0.411313 -0.835488 0.364392 0.312157 -0.835488 0.452237 0.194859 -0.835488 0.5138 0.066236 -0.835488 0.545502 -0.066236 -0.835488 0.545502 -0.194859 -0.835488 0.5138 -0.312157 -0.835488 0.452237 -0.411313 -0.835488 0.364392 -0.486566 -0.835488 0.255369 -0.533541 -0.835488 0.131506 -0.549509 -0.835488 -4.80396e-008 -0.533541 -0.835488 -0.131506 -0.486566 -0.835488 -0.25537 -0.411313 -0.835488 -0.364392 -0.312157 -0.835488 -0.452237 -0.194858 -0.835488 -0.5138 -0.066236 -0.835488 -0.545502 0.066236 -0.835488 -0.545502 0.194859 -0.835488 -0.5138 0.312157 -0.835488 -0.452237 0.411313 -0.835488 -0.364392 0.486566 -0.835488 -0.25537 0.533541 -0.835488 -0.131506 0.549509 -0.835488 9.60792e-008 0.642788 -0.766044 0 0.624109 -0.766044 0.153829 0.56916 -0.766044 0.298718 0.481133 -0.766044 0.426247 0.365145 -0.766044 0.529004 0.227936 -0.766044 0.601017 0.0774795 -0.766044 0.638101 -0.0774795 -0.766044 0.638101 -0.227936 -0.766044 0.601017 -0.365145 -0.766044 0.529004 -0.481133 -0.766044 0.426247 -0.56916 -0.766044 0.298718 -0.624109 -0.766044 0.153829 -0.642788 -0.766044 -5.61943e-008 -0.624109 -0.766044 -0.153829 -0.56916 -0.766044 -0.298718 -0.481133 -0.766044 -0.426247 -0.365145 -0.766044 -0.529004 -0.227935 -0.766044 -0.601017 -0.0774795 -0.766044 -0.638101 0.0774795 -0.766044 -0.638101 0.227936 -0.766044 -0.601017 0.365145 -0.766044 -0.529004 0.481134 -0.766044 -0.426247 0.56916 -0.766044 -0.298718 0.624109 -0.766044 -0.153829 0.642788 -0.766044 1.12389e-007 0.727374 -0.686242 0 0.706237 -0.686242 0.174072 0.644057 -0.686242 0.338027 0.544447 -0.686242 0.482338 0.413195 -0.686242 0.598617 0.25793 -0.686242 0.680106 0.0876752 -0.686242 0.72207 -0.0876753 -0.686242 0.72207 -0.25793 -0.686242 0.680106 -0.413195 -0.686242 0.598617 -0.544447 -0.686242 0.482338 -0.644057 -0.686242 0.338027 -0.706237 -0.686242 0.174072 -0.727374 -0.686242 -6.3589e-008 -0.706237 -0.686242 -0.174072 -0.644057 -0.686242 -0.338027 -0.544447 -0.686242 -0.482338 -0.413195 -0.686242 -0.598617 -0.25793 -0.686242 -0.680106 -0.0876752 -0.686242 -0.72207 0.0876752 -0.686242 -0.72207 0.25793 -0.686242 -0.680106 0.413195 -0.686242 -0.598617 0.544447 -0.686242 -0.482338 0.644057 -0.686242 -0.338027 0.706237 -0.686242 -0.174072 0.727374 -0.686242 1.27178e-007 0.802123 -0.597159 0 0.778815 -0.597159 0.191961 0.710245 -0.597159 0.372765 0.600398 -0.597159 0.531906 0.455658 -0.597159 0.660134 0.284437 -0.597159 0.749998 0.0966853 -0.597159 0.796275 -0.0966853 -0.597159 0.796275 -0.284437 -0.597159 0.749998 -0.455658 -0.597159 0.660134 -0.600398 -0.597159 0.531906 -0.710245 -0.597159 0.372765 -0.778815 -0.597159 0.191961 -0.802123 -0.597159 -7.01238e-008 -0.778815 -0.597159 -0.191961 -0.710245 -0.597159 -0.372765 -0.600398 -0.597159 -0.531906 -0.455658 -0.597159 -0.660135 -0.284437 -0.597159 -0.749998 -0.0966853 -0.597159 -0.796275 0.0966853 -0.597159 -0.796275 0.284437 -0.597159 -0.749998 0.455658 -0.597159 -0.660134 0.600398 -0.597159 -0.531906 0.710245 -0.597159 -0.372765 0.778815 -0.597159 -0.191961 0.802123 -0.597159 1.40248e-007 0.866025 -0.5 0 0.84086 -0.5 0.207253 0.766827 -0.5 0.402462 0.648229 -0.5 0.574281 0.491958 -0.5 0.712725 0.307097 -0.5 0.809748 0.104388 -0.5 0.859711 -0.104388 -0.5 0.859711 -0.307097 -0.5 0.809748 -0.491959 -0.5 0.712725 -0.648229 -0.5 0.574281 -0.766827 -0.5 0.402462 -0.84086 -0.5 0.207253 -0.866025 -0.5 -7.57103e-008 -0.84086 -0.5 -0.207254 -0.766827 -0.5 -0.402462 -0.648229 -0.5 -0.574281 -0.491958 -0.5 -0.712725 -0.307097 -0.5 -0.809748 -0.104388 -0.5 -0.859711 0.104388 -0.5 -0.859711 0.307097 -0.5 -0.809748 0.491959 -0.5 -0.712725 0.64823 -0.5 -0.574281 0.766827 -0.5 -0.402462 0.84086 -0.5 -0.207253 0.866025 -0.5 1.51421e-007 0.918216 -0.39608 0 0.891534 -0.39608 0.219744 0.81304 -0.39608 0.426716 0.687295 -0.39608 0.60889 0.521606 -0.39608 0.755677 0.325604 -0.39608 0.858547 0.110679 -0.39608 0.911521 -0.110679 -0.39608 0.911521 -0.325604 -0.39608 0.858547 -0.521606 -0.39608 0.755677 -0.687295 -0.39608 0.60889 -0.81304 -0.39608 0.426716 -0.891534 -0.39608 0.219744 -0.918216 -0.39608 -8.0273e-008 -0.891534 -0.39608 -0.219744 -0.81304 -0.39608 -0.426716 -0.687295 -0.39608 -0.60889 -0.521606 -0.39608 -0.755677 -0.325604 -0.39608 -0.858547 -0.110679 -0.39608 -0.911521 0.110679 -0.39608 -0.911521 0.325604 -0.39608 -0.858547 0.521606 -0.39608 -0.755677 0.687295 -0.39608 -0.60889 0.81304 -0.39608 -0.426716 0.891534 -0.39608 -0.219743 0.918216 -0.39608 1.60546e-007 0.95799 -0.286803 0 0.930152 -0.286803 0.229262 0.848258 -0.286803 0.4452 0.717065 -0.286803 0.635265 0.5442 -0.286803 0.78841 0.339708 -0.286803 0.895736 0.115473 -0.286803 0.951005 -0.115473 -0.286803 0.951005 -0.339708 -0.286803 0.895736 -0.5442 -0.286803 0.78841 -0.717065 -0.286803 0.635265 -0.848258 -0.286803 0.4452 -0.930152 -0.286803 0.229262 -0.95799 -0.286803 -8.37501e-008 -0.930152 -0.286803 -0.229262 -0.848258 -0.286803 -0.4452 -0.717065 -0.286803 -0.635265 -0.5442 -0.286803 -0.78841 -0.339707 -0.286803 -0.895736 -0.115473 -0.286803 -0.951005 0.115473 -0.286803 -0.951005 0.339708 -0.286803 -0.895736 0.5442 -0.286803 -0.78841 0.717066 -0.286803 -0.635264 0.848258 -0.286803 -0.4452 0.930152 -0.286803 -0.229262 0.95799 -0.286803 1.675e-007 0.984808 -0.173648 0 0.956191 -0.173648 0.23568 0.872004 -0.173648 0.457663 0.737139 -0.173648 0.653048 0.559435 -0.173648 0.810481 0.349218 -0.173648 0.920811 0.118705 -0.173648 0.977627 -0.118706 -0.173648 0.977627 -0.349218 -0.173648 0.920811 -0.559435 -0.173648 0.810481 -0.737139 -0.173648 0.653048 -0.872004 -0.173648 0.457663 -0.956191 -0.173648 0.23568 -0.984808 -0.173648 -8.60946e-008 -0.956191 -0.173648 -0.23568 -0.872004 -0.173648 -0.457663 -0.737139 -0.173648 -0.653048 -0.559434 -0.173648 -0.810481 -0.349217 -0.173648 -0.920811 -0.118705 -0.173648 -0.977627 0.118706 -0.173648 -0.977627 0.349218 -0.173648 -0.920811 0.559435 -0.173648 -0.810481 0.737139 -0.173648 -0.653048 0.872004 -0.173648 -0.457663 0.956191 -0.173648 -0.23568 0.984808 -0.173648 1.72189e-007 0.998308 -0.0581448 0 0.969299 -0.0581448 0.238911 0.883958 -0.0581448 0.463937 0.747244 -0.0581448 0.662001 0.567104 -0.0581448 0.821592 0.354005 -0.0581448 0.933434 0.120333 -0.0581448 0.991029 -0.120333 -0.0581448 0.991029 -0.354005 -0.0581448 0.933434 -0.567104 -0.0581448 0.821591 -0.747244 -0.0581448 0.662001 -0.883958 -0.0581448 0.463937 -0.969299 -0.0581448 0.238911 -0.998308 -0.0581448 -8.72749e-008 -0.969299 -0.0581448 -0.238911 -0.883958 -0.0581448 -0.463937 -0.747244 -0.0581448 -0.662001 -0.567104 -0.0581448 -0.821592 -0.354005 -0.0581448 -0.933434 -0.120333 -0.0581448 -0.991029 0.120333 -0.0581448 -0.991029 0.354005 -0.0581448 -0.933434 0.567104 -0.0581448 -0.821591 0.747245 -0.0581448 -0.662001 0.883958 -0.0581448 -0.463937 0.969299 -0.0581448 -0.238911 0.998308 -0.0581448 1.7455e-007 0.998308 0.0581448 0 0.969299 0.0581448 0.238911 0.883958 0.0581448 0.463937 0.747244 0.0581448 0.662001 0.567104 0.0581448 0.821592 0.354005 0.0581448 0.933434 0.120333 0.0581448 0.991029 -0.120333 0.0581448 0.991029 -0.354005 0.0581448 0.933434 -0.567104 0.0581448 0.821591 -0.747244 0.0581448 0.662001 -0.883958 0.0581448 0.463937 -0.969299 0.0581448 0.238911 -0.998308 0.0581448 -8.72749e-008 -0.969299 0.0581448 -0.238911 -0.883958 0.0581448 -0.463937 -0.747244 0.0581448 -0.662001 -0.567104 0.0581448 -0.821592 -0.354005 0.0581448 -0.933434 -0.120333 0.0581448 -0.991029 0.120333 0.0581448 -0.991029 0.354005 0.0581448 -0.933434 0.567104 0.0581448 -0.821591 0.747245 0.0581448 -0.662001 0.883958 0.0581448 -0.463937 0.969299 0.0581448 -0.238911 0.998308 0.0581448 1.7455e-007 0.984808 0.173648 0 0.956191 0.173648 0.23568 0.872004 0.173648 0.457663 0.737139 0.173648 0.653048 0.559435 0.173648 0.810481 0.349218 0.173648 0.920811 0.118705 0.173648 0.977627 -0.118706 0.173648 0.977627 -0.349218 0.173648 0.920811 -0.559435 0.173648 0.810481 -0.737139 0.173648 0.653048 -0.872004 0.173648 0.457663 -0.956191 0.173648 0.23568 -0.984808 0.173648 -8.60946e-008 -0.956191 0.173648 -0.23568 -0.872004 0.173648 -0.457663 -0.737139 0.173648 -0.653048 -0.559434 0.173648 -0.810481 -0.349217 0.173648 -0.920811 -0.118705 0.173648 -0.977627 0.118706 0.173648 -0.977627 0.349218 0.173648 -0.920811 0.559435 0.173648 -0.810481 0.737139 0.173648 -0.653048 0.872004 0.173648 -0.457663 0.956191 0.173648 -0.23568 0.984808 0.173648 1.72189e-007 0.95799 0.286803 0 0.930152 0.286803 0.229262 0.848258 0.286803 0.4452 0.717065 0.286803 0.635265 0.5442 0.286803 0.78841 0.339708 0.286803 0.895736 0.115473 0.286803 0.951005 -0.115473 0.286803 0.951005 -0.339708 0.286803 0.895736 -0.5442 0.286803 0.78841 -0.717065 0.286803 0.635265 -0.848258 0.286803 0.4452 -0.930152 0.286803 0.229262 -0.95799 0.286803 -8.37501e-008 -0.930152 0.286803 -0.229262 -0.848258 0.286803 -0.4452 -0.717065 0.286803 -0.635265 -0.5442 0.286803 -0.78841 -0.339707 0.286803 -0.895736 -0.115473 0.286803 -0.951005 0.115473 0.286803 -0.951005 0.339708 0.286803 -0.895736 0.5442 0.286803 -0.78841 0.717066 0.286803 -0.635264 0.848258 0.286803 -0.4452 0.930152 0.286803 -0.229262 0.95799 0.286803 1.675e-007 0.918216 0.39608 0 0.891534 0.39608 0.219744 0.81304 0.39608 0.426716 0.687295 0.39608 0.60889 0.521606 0.39608 0.755677 0.325604 0.39608 0.858547 0.110679 0.39608 0.911521 -0.110679 0.39608 0.911521 -0.325604 0.39608 0.858547 -0.521606 0.39608 0.755677 -0.687295 0.39608 0.60889 -0.81304 0.39608 0.426716 -0.891534 0.39608 0.219744 -0.918216 0.39608 -8.0273e-008 -0.891534 0.39608 -0.219744 -0.81304 0.39608 -0.426716 -0.687295 0.39608 -0.60889 -0.521606 0.39608 -0.755677 -0.325604 0.39608 -0.858547 -0.110679 0.39608 -0.911521 0.110679 0.39608 -0.911521 0.325604 0.39608 -0.858547 0.521606 0.39608 -0.755677 0.687295 0.39608 -0.60889 0.81304 0.39608 -0.426716 0.891534 0.39608 -0.219743 0.918216 0.39608 1.60546e-007 0.866025 0.5 0 0.84086 0.5 0.207253 0.766827 0.5 0.402462 0.648229 0.5 0.574281 0.491958 0.5 0.712725 0.307097 0.5 0.809748 0.104388 0.5 0.859711 -0.104388 0.5 0.859711 -0.307097 0.5 0.809748 -0.491959 0.5 0.712725 -0.648229 0.5 0.574281 -0.766827 0.5 0.402462 -0.84086 0.5 0.207253 -0.866025 0.5 -7.57103e-008 -0.84086 0.5 -0.207254 -0.766827 0.5 -0.402462 -0.648229 0.5 -0.574281 -0.491958 0.5 -0.712725 -0.307097 0.5 -0.809748 -0.104388 0.5 -0.859711 0.104388 0.5 -0.859711 0.307097 0.5 -0.809748 0.491959 0.5 -0.712725 0.64823 0.5 -0.574281 0.766827 0.5 -0.402462 0.84086 0.5 -0.207253 0.866025 0.5 1.51421e-007 0.802123 0.597159 0 0.778815 0.597159 0.191961 0.710245 0.597159 0.372765 0.600398 0.597159 0.531906 0.455658 0.597159 0.660134 0.284437 0.597159 0.749998 0.0966853 0.597159 0.796275 -0.0966853 0.597159 0.796275 -0.284437 0.597159 0.749998 -0.455658 0.597159 0.660134 -0.600398 0.597159 0.531906 -0.710245 0.597159 0.372765 -0.778815 0.597159 0.191961 -0.802123 0.597159 -7.01238e-008 -0.778815 0.597159 -0.191961 -0.710245 0.597159 -0.372765 -0.600398 0.597159 -0.531906 -0.455658 0.597159 -0.660135 -0.284437 0.597159 -0.749998 -0.0966853 0.597159 -0.796275 0.0966853 0.597159 -0.796275 0.284437 0.597159 -0.749998 0.455658 0.597159 -0.660134 0.600398 0.597159 -0.531906 0.710245 0.597159 -0.372765 0.778815 0.597159 -0.191961 0.802123 0.597159 1.40248e-007 0.727374 0.686242 0 0.706237 0.686242 0.174072 0.644057 0.686242 0.338027 0.544447 0.686242 0.482338 0.413195 0.686242 0.598617 0.25793 0.686242 0.680106 0.0876752 0.686242 0.72207 -0.0876753 0.686242 0.72207 -0.25793 0.686242 0.680106 -0.413195 0.686242 0.598617 -0.544447 0.686242 0.482338 -0.644057 0.686242 0.338027 -0.706237 0.686242 0.174072 -0.727374 0.686242 -6.3589e-008 -0.706237 0.686242 -0.174072 -0.644057 0.686242 -0.338027 -0.544447 0.686242 -0.482338 -0.413195 0.686242 -0.598617 -0.25793 0.686242 -0.680106 -0.0876752 0.686242 -0.72207 0.0876752 0.686242 -0.72207 0.25793 0.686242 -0.680106 0.413195 0.686242 -0.598617 0.544447 0.686242 -0.482338 0.644057 0.686242 -0.338027 0.706237 0.686242 -0.174072 0.727374 0.686242 1.27178e-007 0.642788 0.766044 0 0.624109 0.766044 0.153829 0.56916 0.766044 0.298718 0.481133 0.766044 0.426247 0.365145 0.766044 0.529004 0.227936 0.766044 0.601017 0.0774795 0.766044 0.638101 -0.0774795 0.766044 0.638101 -0.227936 0.766044 0.601017 -0.365145 0.766044 0.529004 -0.481133 0.766044 0.426247 -0.56916 0.766044 0.298718 -0.624109 0.766044 0.153829 -0.642788 0.766044 -5.61943e-008 -0.624109 0.766044 -0.153829 -0.56916 0.766044 -0.298718 -0.481133 0.766044 -0.426247 -0.365145 0.766044 -0.529004 -0.227935 0.766044 -0.601017 -0.0774795 0.766044 -0.638101 0.0774795 0.766044 -0.638101 0.227936 0.766044 -0.601017 0.365145 0.766044 -0.529004 0.481134 0.766044 -0.426247 0.56916 0.766044 -0.298718 0.624109 0.766044 -0.153829 0.642788 0.766044 1.12389e-007 0.549509 0.835488 0 0.533541 0.835488 0.131506 0.486566 0.835488 0.25537 0.411313 0.835488 0.364392 0.312157 0.835488 0.452237 0.194859 0.835488 0.5138 0.066236 0.835488 0.545502 -0.066236 0.835488 0.545502 -0.194859 0.835488 0.5138 -0.312157 0.835488 0.452237 -0.411313 0.835488 0.364392 -0.486566 0.835488 0.255369 -0.533541 0.835488 0.131506 -0.549509 0.835488 -4.80396e-008 -0.533541 0.835488 -0.131506 -0.486566 0.835488 -0.25537 -0.411313 0.835488 -0.364392 -0.312157 0.835488 -0.452237 -0.194858 0.835488 -0.5138 -0.066236 0.835488 -0.545502 0.066236 0.835488 -0.545502 0.194859 0.835488 -0.5138 0.312157 0.835488 -0.452237 0.411313 0.835488 -0.364392 0.486566 0.835488 -0.25537 0.533541 0.835488 -0.131506 0.549509 0.835488 9.60792e-008 0.448799 0.893633 0 0.435758 0.893633 0.107405 0.397392 0.893633 0.208567 0.335931 0.893633 0.297609 0.254947 0.893633 0.369354 0.159146 0.893633 0.419635 0.0540968 0.893633 0.445527 -0.0540968 0.893633 0.445527 -0.159146 0.893633 0.419634 -0.254947 0.893633 0.369354 -0.335931 0.893633 0.297609 -0.397392 0.893633 0.208567 -0.435758 0.893633 0.107405 -0.448799 0.893633 -3.92353e-008 -0.435758 0.893633 -0.107405 -0.397392 0.893633 -0.208567 -0.335931 0.893633 -0.297609 -0.254947 0.893633 -0.369355 -0.159146 0.893633 -0.419635 -0.0540968 0.893633 -0.445527 0.0540968 0.893633 -0.445527 0.159146 0.893633 -0.419634 0.254947 0.893633 -0.369354 0.335931 0.893633 -0.297609 0.397392 0.893633 -0.208567 0.435758 0.893633 -0.107405 0.448799 0.893633 7.84705e-008 0.34202 0.939693 0 0.332082 0.939693 0.0818508 0.302844 0.939693 0.158945 0.256006 0.939693 0.226801 0.19429 0.939693 0.281477 0.121282 0.939693 0.319794 0.041226 0.939693 0.339526 -0.041226 0.939693 0.339526 -0.121282 0.939693 0.319794 -0.19429 0.939693 0.281477 -0.256006 0.939693 0.226801 -0.302844 0.939693 0.158945 -0.332082 0.939693 0.0818508 -0.34202 0.939693 -2.99004e-008 -0.332082 0.939693 -0.0818508 -0.302844 0.939693 -0.158945 -0.256006 0.939693 -0.226801 -0.19429 0.939693 -0.281477 -0.121282 0.939693 -0.319794 -0.041226 0.939693 -0.339526 0.041226 0.939693 -0.339526 0.121282 0.939693 -0.319794 0.19429 0.939693 -0.281477 0.256006 0.939693 -0.226801 0.302844 0.939693 -0.158945 0.332082 0.939693 -0.0818508 0.34202 0.939693 5.98007e-008 0.230616 0.973045 0 0.223915 0.973045 0.05519 0.2042 0.973045 0.107173 0.172618 0.973045 0.152927 0.131005 0.973045 0.189793 0.0817775 0.973045 0.21563 0.0277977 0.973045 0.228934 -0.0277977 0.973045 0.228934 -0.0817775 0.973045 0.21563 -0.131005 0.973045 0.189793 -0.172618 0.973045 0.152927 -0.2042 0.973045 0.107173 -0.223915 0.973045 0.05519 -0.230616 0.973045 -2.01611e-008 -0.223915 0.973045 -0.05519 -0.2042 0.973045 -0.107173 -0.172618 0.973045 -0.152927 -0.131005 0.973045 -0.189793 -0.0817774 0.973045 -0.21563 -0.0277977 0.973045 -0.228934 0.0277977 0.973045 -0.228934 0.0817776 0.973045 -0.21563 0.131005 0.973045 -0.189793 0.172619 0.973045 -0.152927 0.2042 0.973045 -0.107173 0.223915 0.973045 -0.05519 0.230616 0.973045 4.03222e-008 0.116093 0.993238 0 0.112719 0.993238 0.0277828 0.102795 0.993238 0.0539509 0.0868966 0.993238 0.0769837 0.0659481 0.993238 0.0955424 0.041167 0.993238 0.108549 0.0139934 0.993238 0.115246 -0.0139934 0.993238 0.115246 -0.041167 0.993238 0.108549 -0.0659482 0.993238 0.0955424 -0.0868966 0.993238 0.0769837 -0.102795 0.993238 0.0539509 -0.112719 0.993238 0.0277828 -0.116093 0.993238 -1.01491e-008 -0.112719 0.993238 -0.0277828 -0.102795 0.993238 -0.0539509 -0.0868966 0.993238 -0.0769837 -0.0659481 0.993238 -0.0955424 -0.041167 0.993238 -0.108549 -0.0139934 0.993238 -0.115246 0.0139934 0.993238 -0.115246 0.041167 0.993238 -0.108548 0.0659482 0.993238 -0.0955424 0.0868966 0.993238 -0.0769836 0.102795 0.993238 -0.0539509 0.112719 0.993238 -0.0277828 0.116093 0.993238 2.02983e-008 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0</float_array> + <technique_common> + <accessor count="756" source="#FXStream-array" stride="3"> + <param name="X" type="float"/> + <param name="Y" type="float"/> + <param name="Z" type="float"/> + </accessor> + </technique_common> + </source> + <source id="FXStream2" name="FXStream"> + <float_array id="FXStream2-array" count="2268">0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 -0 -1 -0 -0 -1 -0 -0 -1 -0 -0 -1 -0 -0 -1 -0 -0 -1 -0 -0 -1 -0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0.116093 -0.993238 0 0.112719 -0.993238 0.0277828 0.102795 -0.993238 0.0539509 0.0868966 -0.993238 0.0769837 0.0659481 -0.993238 0.0955424 0.041167 -0.993238 0.108549 0.0139934 -0.993238 0.115246 -0.0139934 -0.993238 0.115246 -0.041167 -0.993238 0.108549 -0.0659482 -0.993238 0.0955424 -0.0868966 -0.993238 0.0769837 -0.102795 -0.993238 0.0539509 -0.112719 -0.993238 0.0277828 -0.116093 -0.993238 -1.01491e-008 -0.112719 -0.993238 -0.0277828 -0.102795 -0.993238 -0.0539509 -0.0868966 -0.993238 -0.0769837 -0.0659481 -0.993238 -0.0955424 -0.041167 -0.993238 -0.108549 -0.0139934 -0.993238 -0.115246 0.0139934 -0.993238 -0.115246 0.041167 -0.993238 -0.108548 0.0659482 -0.993238 -0.0955424 0.0868966 -0.993238 -0.0769836 0.102795 -0.993238 -0.0539509 0.112719 -0.993238 -0.0277828 0.116093 -0.993238 2.02983e-008 0.230616 -0.973045 0 0.223915 -0.973045 0.05519 0.2042 -0.973045 0.107173 0.172618 -0.973045 0.152927 0.131005 -0.973045 0.189793 0.0817775 -0.973045 0.21563 0.0277977 -0.973045 0.228934 -0.0277977 -0.973045 0.228934 -0.0817775 -0.973045 0.21563 -0.131005 -0.973045 0.189793 -0.172618 -0.973045 0.152927 -0.2042 -0.973045 0.107173 -0.223915 -0.973045 0.05519 -0.230616 -0.973045 -2.01611e-008 -0.223915 -0.973045 -0.05519 -0.2042 -0.973045 -0.107173 -0.172618 -0.973045 -0.152927 -0.131005 -0.973045 -0.189793 -0.0817774 -0.973045 -0.21563 -0.0277977 -0.973045 -0.228934 0.0277977 -0.973045 -0.228934 0.0817776 -0.973045 -0.21563 0.131005 -0.973045 -0.189793 0.172619 -0.973045 -0.152927 0.2042 -0.973045 -0.107173 0.223915 -0.973045 -0.05519 0.230616 -0.973045 4.03222e-008 0.34202 -0.939693 0 0.332082 -0.939693 0.0818508 0.302844 -0.939693 0.158945 0.256006 -0.939693 0.226801 0.19429 -0.939693 0.281477 0.121282 -0.939693 0.319794 0.041226 -0.939693 0.339526 -0.041226 -0.939693 0.339526 -0.121282 -0.939693 0.319794 -0.19429 -0.939693 0.281477 -0.256006 -0.939693 0.226801 -0.302844 -0.939693 0.158945 -0.332082 -0.939693 0.0818508 -0.34202 -0.939693 -2.99004e-008 -0.332082 -0.939693 -0.0818508 -0.302844 -0.939693 -0.158945 -0.256006 -0.939693 -0.226801 -0.19429 -0.939693 -0.281477 -0.121282 -0.939693 -0.319794 -0.041226 -0.939693 -0.339526 0.041226 -0.939693 -0.339526 0.121282 -0.939693 -0.319794 0.19429 -0.939693 -0.281477 0.256006 -0.939693 -0.226801 0.302844 -0.939693 -0.158945 0.332082 -0.939693 -0.0818508 0.34202 -0.939693 5.98007e-008 0.448799 -0.893633 0 0.435758 -0.893633 0.107405 0.397392 -0.893633 0.208567 0.335931 -0.893633 0.297609 0.254947 -0.893633 0.369354 0.159146 -0.893633 0.419635 0.0540968 -0.893633 0.445527 -0.0540968 -0.893633 0.445527 -0.159146 -0.893633 0.419634 -0.254947 -0.893633 0.369354 -0.335931 -0.893633 0.297609 -0.397392 -0.893633 0.208567 -0.435758 -0.893633 0.107405 -0.448799 -0.893633 -3.92353e-008 -0.435758 -0.893633 -0.107405 -0.397392 -0.893633 -0.208567 -0.335931 -0.893633 -0.297609 -0.254947 -0.893633 -0.369355 -0.159146 -0.893633 -0.419635 -0.0540968 -0.893633 -0.445527 0.0540968 -0.893633 -0.445527 0.159146 -0.893633 -0.419634 0.254947 -0.893633 -0.369354 0.335931 -0.893633 -0.297609 0.397392 -0.893633 -0.208567 0.435758 -0.893633 -0.107405 0.448799 -0.893633 7.84705e-008 0.549509 -0.835488 0 0.533541 -0.835488 0.131506 0.486566 -0.835488 0.25537 0.411313 -0.835488 0.364392 0.312157 -0.835488 0.452237 0.194859 -0.835488 0.5138 0.066236 -0.835488 0.545502 -0.066236 -0.835488 0.545502 -0.194859 -0.835488 0.5138 -0.312157 -0.835488 0.452237 -0.411313 -0.835488 0.364392 -0.486566 -0.835488 0.255369 -0.533541 -0.835488 0.131506 -0.549509 -0.835488 -4.80396e-008 -0.533541 -0.835488 -0.131506 -0.486566 -0.835488 -0.25537 -0.411313 -0.835488 -0.364392 -0.312157 -0.835488 -0.452237 -0.194858 -0.835488 -0.5138 -0.066236 -0.835488 -0.545502 0.066236 -0.835488 -0.545502 0.194859 -0.835488 -0.5138 0.312157 -0.835488 -0.452237 0.411313 -0.835488 -0.364392 0.486566 -0.835488 -0.25537 0.533541 -0.835488 -0.131506 0.549509 -0.835488 9.60792e-008 0.642788 -0.766044 0 0.624109 -0.766044 0.153829 0.56916 -0.766044 0.298718 0.481133 -0.766044 0.426247 0.365145 -0.766044 0.529004 0.227936 -0.766044 0.601017 0.0774795 -0.766044 0.638101 -0.0774795 -0.766044 0.638101 -0.227936 -0.766044 0.601017 -0.365145 -0.766044 0.529004 -0.481133 -0.766044 0.426247 -0.56916 -0.766044 0.298718 -0.624109 -0.766044 0.153829 -0.642788 -0.766044 -5.61943e-008 -0.624109 -0.766044 -0.153829 -0.56916 -0.766044 -0.298718 -0.481133 -0.766044 -0.426247 -0.365145 -0.766044 -0.529004 -0.227935 -0.766044 -0.601017 -0.0774795 -0.766044 -0.638101 0.0774795 -0.766044 -0.638101 0.227936 -0.766044 -0.601017 0.365145 -0.766044 -0.529004 0.481134 -0.766044 -0.426247 0.56916 -0.766044 -0.298718 0.624109 -0.766044 -0.153829 0.642788 -0.766044 1.12389e-007 0.727374 -0.686242 0 0.706237 -0.686242 0.174072 0.644057 -0.686242 0.338027 0.544447 -0.686242 0.482338 0.413195 -0.686242 0.598617 0.25793 -0.686242 0.680106 0.0876752 -0.686242 0.72207 -0.0876753 -0.686242 0.72207 -0.25793 -0.686242 0.680106 -0.413195 -0.686242 0.598617 -0.544447 -0.686242 0.482338 -0.644057 -0.686242 0.338027 -0.706237 -0.686242 0.174072 -0.727374 -0.686242 -6.3589e-008 -0.706237 -0.686242 -0.174072 -0.644057 -0.686242 -0.338027 -0.544447 -0.686242 -0.482338 -0.413195 -0.686242 -0.598617 -0.25793 -0.686242 -0.680106 -0.0876752 -0.686242 -0.72207 0.0876752 -0.686242 -0.72207 0.25793 -0.686242 -0.680106 0.413195 -0.686242 -0.598617 0.544447 -0.686242 -0.482338 0.644057 -0.686242 -0.338027 0.706237 -0.686242 -0.174072 0.727374 -0.686242 1.27178e-007 0.802123 -0.597159 0 0.778815 -0.597159 0.191961 0.710245 -0.597159 0.372765 0.600398 -0.597159 0.531906 0.455658 -0.597159 0.660134 0.284437 -0.597159 0.749998 0.0966853 -0.597159 0.796275 -0.0966853 -0.597159 0.796275 -0.284437 -0.597159 0.749998 -0.455658 -0.597159 0.660134 -0.600398 -0.597159 0.531906 -0.710245 -0.597159 0.372765 -0.778815 -0.597159 0.191961 -0.802123 -0.597159 -7.01238e-008 -0.778815 -0.597159 -0.191961 -0.710245 -0.597159 -0.372765 -0.600398 -0.597159 -0.531906 -0.455658 -0.597159 -0.660135 -0.284437 -0.597159 -0.749998 -0.0966853 -0.597159 -0.796275 0.0966853 -0.597159 -0.796275 0.284437 -0.597159 -0.749998 0.455658 -0.597159 -0.660134 0.600398 -0.597159 -0.531906 0.710245 -0.597159 -0.372765 0.778815 -0.597159 -0.191961 0.802123 -0.597159 1.40248e-007 0.866025 -0.5 0 0.84086 -0.5 0.207253 0.766827 -0.5 0.402462 0.648229 -0.5 0.574281 0.491958 -0.5 0.712725 0.307097 -0.5 0.809748 0.104388 -0.5 0.859711 -0.104388 -0.5 0.859711 -0.307097 -0.5 0.809748 -0.491959 -0.5 0.712725 -0.648229 -0.5 0.574281 -0.766827 -0.5 0.402462 -0.84086 -0.5 0.207253 -0.866025 -0.5 -7.57103e-008 -0.84086 -0.5 -0.207254 -0.766827 -0.5 -0.402462 -0.648229 -0.5 -0.574281 -0.491958 -0.5 -0.712725 -0.307097 -0.5 -0.809748 -0.104388 -0.5 -0.859711 0.104388 -0.5 -0.859711 0.307097 -0.5 -0.809748 0.491959 -0.5 -0.712725 0.64823 -0.5 -0.574281 0.766827 -0.5 -0.402462 0.84086 -0.5 -0.207253 0.866025 -0.5 1.51421e-007 0.918216 -0.39608 0 0.891534 -0.39608 0.219744 0.81304 -0.39608 0.426716 0.687295 -0.39608 0.60889 0.521606 -0.39608 0.755677 0.325604 -0.39608 0.858547 0.110679 -0.39608 0.911521 -0.110679 -0.39608 0.911521 -0.325604 -0.39608 0.858547 -0.521606 -0.39608 0.755677 -0.687295 -0.39608 0.60889 -0.81304 -0.39608 0.426716 -0.891534 -0.39608 0.219744 -0.918216 -0.39608 -8.0273e-008 -0.891534 -0.39608 -0.219744 -0.81304 -0.39608 -0.426716 -0.687295 -0.39608 -0.60889 -0.521606 -0.39608 -0.755677 -0.325604 -0.39608 -0.858547 -0.110679 -0.39608 -0.911521 0.110679 -0.39608 -0.911521 0.325604 -0.39608 -0.858547 0.521606 -0.39608 -0.755677 0.687295 -0.39608 -0.60889 0.81304 -0.39608 -0.426716 0.891534 -0.39608 -0.219743 0.918216 -0.39608 1.60546e-007 0.95799 -0.286803 0 0.930152 -0.286803 0.229262 0.848258 -0.286803 0.4452 0.717065 -0.286803 0.635265 0.5442 -0.286803 0.78841 0.339708 -0.286803 0.895736 0.115473 -0.286803 0.951005 -0.115473 -0.286803 0.951005 -0.339708 -0.286803 0.895736 -0.5442 -0.286803 0.78841 -0.717065 -0.286803 0.635265 -0.848258 -0.286803 0.4452 -0.930152 -0.286803 0.229262 -0.95799 -0.286803 -8.37501e-008 -0.930152 -0.286803 -0.229262 -0.848258 -0.286803 -0.4452 -0.717065 -0.286803 -0.635265 -0.5442 -0.286803 -0.78841 -0.339707 -0.286803 -0.895736 -0.115473 -0.286803 -0.951005 0.115473 -0.286803 -0.951005 0.339708 -0.286803 -0.895736 0.5442 -0.286803 -0.78841 0.717066 -0.286803 -0.635264 0.848258 -0.286803 -0.4452 0.930152 -0.286803 -0.229262 0.95799 -0.286803 1.675e-007 0.984808 -0.173648 0 0.956191 -0.173648 0.23568 0.872004 -0.173648 0.457663 0.737139 -0.173648 0.653048 0.559435 -0.173648 0.810481 0.349218 -0.173648 0.920811 0.118705 -0.173648 0.977627 -0.118706 -0.173648 0.977627 -0.349218 -0.173648 0.920811 -0.559435 -0.173648 0.810481 -0.737139 -0.173648 0.653048 -0.872004 -0.173648 0.457663 -0.956191 -0.173648 0.23568 -0.984808 -0.173648 -8.60946e-008 -0.956191 -0.173648 -0.23568 -0.872004 -0.173648 -0.457663 -0.737139 -0.173648 -0.653048 -0.559434 -0.173648 -0.810481 -0.349217 -0.173648 -0.920811 -0.118705 -0.173648 -0.977627 0.118706 -0.173648 -0.977627 0.349218 -0.173648 -0.920811 0.559435 -0.173648 -0.810481 0.737139 -0.173648 -0.653048 0.872004 -0.173648 -0.457663 0.956191 -0.173648 -0.23568 0.984808 -0.173648 1.72189e-007 0.998308 -0.0581448 0 0.969299 -0.0581448 0.238911 0.883958 -0.0581448 0.463937 0.747244 -0.0581448 0.662001 0.567104 -0.0581448 0.821592 0.354005 -0.0581448 0.933434 0.120333 -0.0581448 0.991029 -0.120333 -0.0581448 0.991029 -0.354005 -0.0581448 0.933434 -0.567104 -0.0581448 0.821591 -0.747244 -0.0581448 0.662001 -0.883958 -0.0581448 0.463937 -0.969299 -0.0581448 0.238911 -0.998308 -0.0581448 -8.72749e-008 -0.969299 -0.0581448 -0.238911 -0.883958 -0.0581448 -0.463937 -0.747244 -0.0581448 -0.662001 -0.567104 -0.0581448 -0.821592 -0.354005 -0.0581448 -0.933434 -0.120333 -0.0581448 -0.991029 0.120333 -0.0581448 -0.991029 0.354005 -0.0581448 -0.933434 0.567104 -0.0581448 -0.821591 0.747245 -0.0581448 -0.662001 0.883958 -0.0581448 -0.463937 0.969299 -0.0581448 -0.238911 0.998308 -0.0581448 1.7455e-007 0.998308 0.0581448 0 0.969299 0.0581448 0.238911 0.883958 0.0581448 0.463937 0.747244 0.0581448 0.662001 0.567104 0.0581448 0.821592 0.354005 0.0581448 0.933434 0.120333 0.0581448 0.991029 -0.120333 0.0581448 0.991029 -0.354005 0.0581448 0.933434 -0.567104 0.0581448 0.821591 -0.747244 0.0581448 0.662001 -0.883958 0.0581448 0.463937 -0.969299 0.0581448 0.238911 -0.998308 0.0581448 -8.72749e-008 -0.969299 0.0581448 -0.238911 -0.883958 0.0581448 -0.463937 -0.747244 0.0581448 -0.662001 -0.567104 0.0581448 -0.821592 -0.354005 0.0581448 -0.933434 -0.120333 0.0581448 -0.991029 0.120333 0.0581448 -0.991029 0.354005 0.0581448 -0.933434 0.567104 0.0581448 -0.821591 0.747245 0.0581448 -0.662001 0.883958 0.0581448 -0.463937 0.969299 0.0581448 -0.238911 0.998308 0.0581448 1.7455e-007 0.984808 0.173648 0 0.956191 0.173648 0.23568 0.872004 0.173648 0.457663 0.737139 0.173648 0.653048 0.559435 0.173648 0.810481 0.349218 0.173648 0.920811 0.118705 0.173648 0.977627 -0.118706 0.173648 0.977627 -0.349218 0.173648 0.920811 -0.559435 0.173648 0.810481 -0.737139 0.173648 0.653048 -0.872004 0.173648 0.457663 -0.956191 0.173648 0.23568 -0.984808 0.173648 -8.60946e-008 -0.956191 0.173648 -0.23568 -0.872004 0.173648 -0.457663 -0.737139 0.173648 -0.653048 -0.559434 0.173648 -0.810481 -0.349217 0.173648 -0.920811 -0.118705 0.173648 -0.977627 0.118706 0.173648 -0.977627 0.349218 0.173648 -0.920811 0.559435 0.173648 -0.810481 0.737139 0.173648 -0.653048 0.872004 0.173648 -0.457663 0.956191 0.173648 -0.23568 0.984808 0.173648 1.72189e-007 0.95799 0.286803 0 0.930152 0.286803 0.229262 0.848258 0.286803 0.4452 0.717065 0.286803 0.635265 0.5442 0.286803 0.78841 0.339708 0.286803 0.895736 0.115473 0.286803 0.951005 -0.115473 0.286803 0.951005 -0.339708 0.286803 0.895736 -0.5442 0.286803 0.78841 -0.717065 0.286803 0.635265 -0.848258 0.286803 0.4452 -0.930152 0.286803 0.229262 -0.95799 0.286803 -8.37501e-008 -0.930152 0.286803 -0.229262 -0.848258 0.286803 -0.4452 -0.717065 0.286803 -0.635265 -0.5442 0.286803 -0.78841 -0.339707 0.286803 -0.895736 -0.115473 0.286803 -0.951005 0.115473 0.286803 -0.951005 0.339708 0.286803 -0.895736 0.5442 0.286803 -0.78841 0.717066 0.286803 -0.635264 0.848258 0.286803 -0.4452 0.930152 0.286803 -0.229262 0.95799 0.286803 1.675e-007 0.918216 0.39608 0 0.891534 0.39608 0.219744 0.81304 0.39608 0.426716 0.687295 0.39608 0.60889 0.521606 0.39608 0.755677 0.325604 0.39608 0.858547 0.110679 0.39608 0.911521 -0.110679 0.39608 0.911521 -0.325604 0.39608 0.858547 -0.521606 0.39608 0.755677 -0.687295 0.39608 0.60889 -0.81304 0.39608 0.426716 -0.891534 0.39608 0.219744 -0.918216 0.39608 -8.0273e-008 -0.891534 0.39608 -0.219744 -0.81304 0.39608 -0.426716 -0.687295 0.39608 -0.60889 -0.521606 0.39608 -0.755677 -0.325604 0.39608 -0.858547 -0.110679 0.39608 -0.911521 0.110679 0.39608 -0.911521 0.325604 0.39608 -0.858547 0.521606 0.39608 -0.755677 0.687295 0.39608 -0.60889 0.81304 0.39608 -0.426716 0.891534 0.39608 -0.219743 0.918216 0.39608 1.60546e-007 0.866025 0.5 0 0.84086 0.5 0.207253 0.766827 0.5 0.402462 0.648229 0.5 0.574281 0.491958 0.5 0.712725 0.307097 0.5 0.809748 0.104388 0.5 0.859711 -0.104388 0.5 0.859711 -0.307097 0.5 0.809748 -0.491959 0.5 0.712725 -0.648229 0.5 0.574281 -0.766827 0.5 0.402462 -0.84086 0.5 0.207253 -0.866025 0.5 -7.57103e-008 -0.84086 0.5 -0.207254 -0.766827 0.5 -0.402462 -0.648229 0.5 -0.574281 -0.491958 0.5 -0.712725 -0.307097 0.5 -0.809748 -0.104388 0.5 -0.859711 0.104388 0.5 -0.859711 0.307097 0.5 -0.809748 0.491959 0.5 -0.712725 0.64823 0.5 -0.574281 0.766827 0.5 -0.402462 0.84086 0.5 -0.207253 0.866025 0.5 1.51421e-007 0.802123 0.597159 0 0.778815 0.597159 0.191961 0.710245 0.597159 0.372765 0.600398 0.597159 0.531906 0.455658 0.597159 0.660134 0.284437 0.597159 0.749998 0.0966853 0.597159 0.796275 -0.0966853 0.597159 0.796275 -0.284437 0.597159 0.749998 -0.455658 0.597159 0.660134 -0.600398 0.597159 0.531906 -0.710245 0.597159 0.372765 -0.778815 0.597159 0.191961 -0.802123 0.597159 -7.01238e-008 -0.778815 0.597159 -0.191961 -0.710245 0.597159 -0.372765 -0.600398 0.597159 -0.531906 -0.455658 0.597159 -0.660135 -0.284437 0.597159 -0.749998 -0.0966853 0.597159 -0.796275 0.0966853 0.597159 -0.796275 0.284437 0.597159 -0.749998 0.455658 0.597159 -0.660134 0.600398 0.597159 -0.531906 0.710245 0.597159 -0.372765 0.778815 0.597159 -0.191961 0.802123 0.597159 1.40248e-007 0.727374 0.686242 0 0.706237 0.686242 0.174072 0.644057 0.686242 0.338027 0.544447 0.686242 0.482338 0.413195 0.686242 0.598617 0.25793 0.686242 0.680106 0.0876752 0.686242 0.72207 -0.0876753 0.686242 0.72207 -0.25793 0.686242 0.680106 -0.413195 0.686242 0.598617 -0.544447 0.686242 0.482338 -0.644057 0.686242 0.338027 -0.706237 0.686242 0.174072 -0.727374 0.686242 -6.3589e-008 -0.706237 0.686242 -0.174072 -0.644057 0.686242 -0.338027 -0.544447 0.686242 -0.482338 -0.413195 0.686242 -0.598617 -0.25793 0.686242 -0.680106 -0.0876752 0.686242 -0.72207 0.0876752 0.686242 -0.72207 0.25793 0.686242 -0.680106 0.413195 0.686242 -0.598617 0.544447 0.686242 -0.482338 0.644057 0.686242 -0.338027 0.706237 0.686242 -0.174072 0.727374 0.686242 1.27178e-007 0.642788 0.766044 0 0.624109 0.766044 0.153829 0.56916 0.766044 0.298718 0.481133 0.766044 0.426247 0.365145 0.766044 0.529004 0.227936 0.766044 0.601017 0.0774795 0.766044 0.638101 -0.0774795 0.766044 0.638101 -0.227936 0.766044 0.601017 -0.365145 0.766044 0.529004 -0.481133 0.766044 0.426247 -0.56916 0.766044 0.298718 -0.624109 0.766044 0.153829 -0.642788 0.766044 -5.61943e-008 -0.624109 0.766044 -0.153829 -0.56916 0.766044 -0.298718 -0.481133 0.766044 -0.426247 -0.365145 0.766044 -0.529004 -0.227935 0.766044 -0.601017 -0.0774795 0.766044 -0.638101 0.0774795 0.766044 -0.638101 0.227936 0.766044 -0.601017 0.365145 0.766044 -0.529004 0.481134 0.766044 -0.426247 0.56916 0.766044 -0.298718 0.624109 0.766044 -0.153829 0.642788 0.766044 1.12389e-007 0.549509 0.835488 0 0.533541 0.835488 0.131506 0.486566 0.835488 0.25537 0.411313 0.835488 0.364392 0.312157 0.835488 0.452237 0.194859 0.835488 0.5138 0.066236 0.835488 0.545502 -0.066236 0.835488 0.545502 -0.194859 0.835488 0.5138 -0.312157 0.835488 0.452237 -0.411313 0.835488 0.364392 -0.486566 0.835488 0.255369 -0.533541 0.835488 0.131506 -0.549509 0.835488 -4.80396e-008 -0.533541 0.835488 -0.131506 -0.486566 0.835488 -0.25537 -0.411313 0.835488 -0.364392 -0.312157 0.835488 -0.452237 -0.194858 0.835488 -0.5138 -0.066236 0.835488 -0.545502 0.066236 0.835488 -0.545502 0.194859 0.835488 -0.5138 0.312157 0.835488 -0.452237 0.411313 0.835488 -0.364392 0.486566 0.835488 -0.25537 0.533541 0.835488 -0.131506 0.549509 0.835488 9.60792e-008 0.448799 0.893633 0 0.435758 0.893633 0.107405 0.397392 0.893633 0.208567 0.335931 0.893633 0.297609 0.254947 0.893633 0.369354 0.159146 0.893633 0.419635 0.0540968 0.893633 0.445527 -0.0540968 0.893633 0.445527 -0.159146 0.893633 0.419634 -0.254947 0.893633 0.369354 -0.335931 0.893633 0.297609 -0.397392 0.893633 0.208567 -0.435758 0.893633 0.107405 -0.448799 0.893633 -3.92353e-008 -0.435758 0.893633 -0.107405 -0.397392 0.893633 -0.208567 -0.335931 0.893633 -0.297609 -0.254947 0.893633 -0.369355 -0.159146 0.893633 -0.419635 -0.0540968 0.893633 -0.445527 0.0540968 0.893633 -0.445527 0.159146 0.893633 -0.419634 0.254947 0.893633 -0.369354 0.335931 0.893633 -0.297609 0.397392 0.893633 -0.208567 0.435758 0.893633 -0.107405 0.448799 0.893633 7.84705e-008 0.34202 0.939693 0 0.332082 0.939693 0.0818508 0.302844 0.939693 0.158945 0.256006 0.939693 0.226801 0.19429 0.939693 0.281477 0.121282 0.939693 0.319794 0.041226 0.939693 0.339526 -0.041226 0.939693 0.339526 -0.121282 0.939693 0.319794 -0.19429 0.939693 0.281477 -0.256006 0.939693 0.226801 -0.302844 0.939693 0.158945 -0.332082 0.939693 0.0818508 -0.34202 0.939693 -2.99004e-008 -0.332082 0.939693 -0.0818508 -0.302844 0.939693 -0.158945 -0.256006 0.939693 -0.226801 -0.19429 0.939693 -0.281477 -0.121282 0.939693 -0.319794 -0.041226 0.939693 -0.339526 0.041226 0.939693 -0.339526 0.121282 0.939693 -0.319794 0.19429 0.939693 -0.281477 0.256006 0.939693 -0.226801 0.302844 0.939693 -0.158945 0.332082 0.939693 -0.0818508 0.34202 0.939693 5.98007e-008 0.230616 0.973045 0 0.223915 0.973045 0.05519 0.2042 0.973045 0.107173 0.172618 0.973045 0.152927 0.131005 0.973045 0.189793 0.0817775 0.973045 0.21563 0.0277977 0.973045 0.228934 -0.0277977 0.973045 0.228934 -0.0817775 0.973045 0.21563 -0.131005 0.973045 0.189793 -0.172618 0.973045 0.152927 -0.2042 0.973045 0.107173 -0.223915 0.973045 0.05519 -0.230616 0.973045 -2.01611e-008 -0.223915 0.973045 -0.05519 -0.2042 0.973045 -0.107173 -0.172618 0.973045 -0.152927 -0.131005 0.973045 -0.189793 -0.0817774 0.973045 -0.21563 -0.0277977 0.973045 -0.228934 0.0277977 0.973045 -0.228934 0.0817776 0.973045 -0.21563 0.131005 0.973045 -0.189793 0.172619 0.973045 -0.152927 0.2042 0.973045 -0.107173 0.223915 0.973045 -0.05519 0.230616 0.973045 4.03222e-008 0.116093 0.993238 0 0.112719 0.993238 0.0277828 0.102795 0.993238 0.0539509 0.0868966 0.993238 0.0769837 0.0659481 0.993238 0.0955424 0.041167 0.993238 0.108549 0.0139934 0.993238 0.115246 -0.0139934 0.993238 0.115246 -0.041167 0.993238 0.108549 -0.0659482 0.993238 0.0955424 -0.0868966 0.993238 0.0769837 -0.102795 0.993238 0.0539509 -0.112719 0.993238 0.0277828 -0.116093 0.993238 -1.01491e-008 -0.112719 0.993238 -0.0277828 -0.102795 0.993238 -0.0539509 -0.0868966 0.993238 -0.0769837 -0.0659481 0.993238 -0.0955424 -0.041167 0.993238 -0.108549 -0.0139934 0.993238 -0.115246 0.0139934 0.993238 -0.115246 0.041167 0.993238 -0.108548 0.0659482 0.993238 -0.0955424 0.0868966 0.993238 -0.0769836 0.102795 0.993238 -0.0539509 0.112719 0.993238 -0.0277828 0.116093 0.993238 2.02983e-008 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0</float_array> + <technique_common> + <accessor count="756" source="#FXStream2-array" stride="3"> + <param name="X" type="float"/> + <param name="Y" type="float"/> + <param name="Z" type="float"/> + </accessor> + </technique_common> + </source> + <source id="FXStream1" name="FXStream"> + <float_array id="FXStream1-array" count="1512">1.01852 0 0.980057 0 0.941595 0 0.903134 0 0.864672 0 0.826211 0 0.787749 0 0.749288 0 0.710826 0 0.672365 0 0.633903 0 0.595442 0 0.55698 0 0.518519 0 0.480057 0 0.441595 0 0.403134 0 0.364672 0 0.326211 0 0.287749 0 0.249288 0 0.210826 0 0.172365 0 0.133903 0 0.0954416 0 0.0569801 0 0.0185185 0 1 0.037037 0.961538 0.037037 0.923077 0.037037 0.884615 0.037037 0.846154 0.037037 0.807692 0.037037 0.769231 0.037037 0.730769 0.037037 0.692308 0.037037 0.653846 0.037037 0.615385 0.037037 0.576923 0.037037 0.538462 0.037037 0.5 0.037037 0.461538 0.037037 0.423077 0.037037 0.384615 0.037037 0.346154 0.037037 0.307692 0.037037 0.269231 0.037037 0.230769 0.037037 0.192308 0.037037 0.153846 0.037037 0.115385 0.037037 0.0769231 0.037037 0.0384616 0.037037 0 0.037037 1 0.0740741 0.961538 0.0740741 0.923077 0.0740741 0.884615 0.0740741 0.846154 0.0740741 0.807692 0.0740741 0.769231 0.0740741 0.730769 0.0740741 0.692308 0.0740741 0.653846 0.0740741 0.615385 0.0740741 0.576923 0.0740741 0.538462 0.0740741 0.5 0.0740741 0.461538 0.0740741 0.423077 0.0740741 0.384615 0.0740741 0.346154 0.0740741 0.307692 0.0740741 0.269231 0.0740741 0.230769 0.0740741 0.192308 0.0740741 0.153846 0.0740741 0.115385 0.0740741 0.0769231 0.0740741 0.0384616 0.0740741 0 0.0740741 1 0.111111 0.961538 0.111111 0.923077 0.111111 0.884615 0.111111 0.846154 0.111111 0.807692 0.111111 0.769231 0.111111 0.730769 0.111111 0.692308 0.111111 0.653846 0.111111 0.615385 0.111111 0.576923 0.111111 0.538462 0.111111 0.5 0.111111 0.461538 0.111111 0.423077 0.111111 0.384615 0.111111 0.346154 0.111111 0.307692 0.111111 0.269231 0.111111 0.230769 0.111111 0.192308 0.111111 0.153846 0.111111 0.115385 0.111111 0.0769231 0.111111 0.0384616 0.111111 0 0.111111 1 0.148148 0.961538 0.148148 0.923077 0.148148 0.884615 0.148148 0.846154 0.148148 0.807692 0.148148 0.769231 0.148148 0.730769 0.148148 0.692308 0.148148 0.653846 0.148148 0.615385 0.148148 0.576923 0.148148 0.538462 0.148148 0.5 0.148148 0.461538 0.148148 0.423077 0.148148 0.384615 0.148148 0.346154 0.148148 0.307692 0.148148 0.269231 0.148148 0.230769 0.148148 0.192308 0.148148 0.153846 0.148148 0.115385 0.148148 0.0769231 0.148148 0.0384616 0.148148 0 0.148148 1 0.185185 0.961538 0.185185 0.923077 0.185185 0.884615 0.185185 0.846154 0.185185 0.807692 0.185185 0.769231 0.185185 0.730769 0.185185 0.692308 0.185185 0.653846 0.185185 0.615385 0.185185 0.576923 0.185185 0.538462 0.185185 0.5 0.185185 0.461538 0.185185 0.423077 0.185185 0.384615 0.185185 0.346154 0.185185 0.307692 0.185185 0.269231 0.185185 0.230769 0.185185 0.192308 0.185185 0.153846 0.185185 0.115385 0.185185 0.0769231 0.185185 0.0384616 0.185185 0 0.185185 1 0.222222 0.961538 0.222222 0.923077 0.222222 0.884615 0.222222 0.846154 0.222222 0.807692 0.222222 0.769231 0.222222 0.730769 0.222222 0.692308 0.222222 0.653846 0.222222 0.615385 0.222222 0.576923 0.222222 0.538462 0.222222 0.5 0.222222 0.461538 0.222222 0.423077 0.222222 0.384615 0.222222 0.346154 0.222222 0.307692 0.222222 0.269231 0.222222 0.230769 0.222222 0.192308 0.222222 0.153846 0.222222 0.115385 0.222222 0.0769231 0.222222 0.0384616 0.222222 0 0.222222 1 0.259259 0.961538 0.259259 0.923077 0.259259 0.884615 0.259259 0.846154 0.259259 0.807692 0.259259 0.769231 0.259259 0.730769 0.259259 0.692308 0.259259 0.653846 0.259259 0.615385 0.259259 0.576923 0.259259 0.538462 0.259259 0.5 0.259259 0.461538 0.259259 0.423077 0.259259 0.384615 0.259259 0.346154 0.259259 0.307692 0.259259 0.269231 0.259259 0.230769 0.259259 0.192308 0.259259 0.153846 0.259259 0.115385 0.259259 0.0769231 0.259259 0.0384616 0.259259 0 0.259259 1 0.296296 0.961538 0.296296 0.923077 0.296296 0.884615 0.296296 0.846154 0.296296 0.807692 0.296296 0.769231 0.296296 0.730769 0.296296 0.692308 0.296296 0.653846 0.296296 0.615385 0.296296 0.576923 0.296296 0.538462 0.296296 0.5 0.296296 0.461538 0.296296 0.423077 0.296296 0.384615 0.296296 0.346154 0.296296 0.307692 0.296296 0.269231 0.296296 0.230769 0.296296 0.192308 0.296296 0.153846 0.296296 0.115385 0.296296 0.0769231 0.296296 0.0384616 0.296296 0 0.296296 1 0.333333 0.961538 0.333333 0.923077 0.333333 0.884615 0.333333 0.846154 0.333333 0.807692 0.333333 0.769231 0.333333 0.730769 0.333333 0.692308 0.333333 0.653846 0.333333 0.615385 0.333333 0.576923 0.333333 0.538462 0.333333 0.5 0.333333 0.461538 0.333333 0.423077 0.333333 0.384615 0.333333 0.346154 0.333333 0.307692 0.333333 0.269231 0.333333 0.230769 0.333333 0.192308 0.333333 0.153846 0.333333 0.115385 0.333333 0.0769231 0.333333 0.0384616 0.333333 0 0.333333 1 0.37037 0.961538 0.37037 0.923077 0.37037 0.884615 0.37037 0.846154 0.37037 0.807692 0.37037 0.769231 0.37037 0.730769 0.37037 0.692308 0.37037 0.653846 0.37037 0.615385 0.37037 0.576923 0.37037 0.538462 0.37037 0.5 0.37037 0.461538 0.37037 0.423077 0.37037 0.384615 0.37037 0.346154 0.37037 0.307692 0.37037 0.269231 0.37037 0.230769 0.37037 0.192308 0.37037 0.153846 0.37037 0.115385 0.37037 0.0769231 0.37037 0.0384616 0.37037 0 0.37037 1 0.407407 0.961538 0.407407 0.923077 0.407407 0.884615 0.407407 0.846154 0.407407 0.807692 0.407407 0.769231 0.407407 0.730769 0.407407 0.692308 0.407407 0.653846 0.407407 0.615385 0.407407 0.576923 0.407407 0.538462 0.407407 0.5 0.407407 0.461538 0.407407 0.423077 0.407407 0.384615 0.407407 0.346154 0.407407 0.307692 0.407407 0.269231 0.407407 0.230769 0.407407 0.192308 0.407407 0.153846 0.407407 0.115385 0.407407 0.0769231 0.407407 0.0384616 0.407407 0 0.407407 1 0.444444 0.961538 0.444444 0.923077 0.444444 0.884615 0.444444 0.846154 0.444444 0.807692 0.444444 0.769231 0.444444 0.730769 0.444444 0.692308 0.444444 0.653846 0.444444 0.615385 0.444444 0.576923 0.444444 0.538462 0.444444 0.5 0.444444 0.461538 0.444444 0.423077 0.444444 0.384615 0.444444 0.346154 0.444444 0.307692 0.444444 0.269231 0.444444 0.230769 0.444444 0.192308 0.444444 0.153846 0.444444 0.115385 0.444444 0.0769231 0.444444 0.0384616 0.444444 0 0.444444 1 0.481481 0.961538 0.481481 0.923077 0.481481 0.884615 0.481481 0.846154 0.481481 0.807692 0.481481 0.769231 0.481481 0.730769 0.481481 0.692308 0.481481 0.653846 0.481481 0.615385 0.481481 0.576923 0.481481 0.538462 0.481481 0.5 0.481481 0.461538 0.481481 0.423077 0.481481 0.384615 0.481481 0.346154 0.481481 0.307692 0.481481 0.269231 0.481481 0.230769 0.481481 0.192308 0.481481 0.153846 0.481481 0.115385 0.481481 0.0769231 0.481481 0.0384616 0.481481 0 0.481481 1 0.518519 0.961538 0.518519 0.923077 0.518519 0.884615 0.518519 0.846154 0.518519 0.807692 0.518519 0.769231 0.518519 0.730769 0.518519 0.692308 0.518519 0.653846 0.518519 0.615385 0.518519 0.576923 0.518519 0.538462 0.518519 0.5 0.518519 0.461538 0.518519 0.423077 0.518519 0.384615 0.518519 0.346154 0.518519 0.307692 0.518519 0.269231 0.518519 0.230769 0.518519 0.192308 0.518519 0.153846 0.518519 0.115385 0.518519 0.0769231 0.518519 0.0384616 0.518519 0 0.518519 1 0.555556 0.961538 0.555556 0.923077 0.555556 0.884615 0.555556 0.846154 0.555556 0.807692 0.555556 0.769231 0.555556 0.730769 0.555556 0.692308 0.555556 0.653846 0.555556 0.615385 0.555556 0.576923 0.555556 0.538462 0.555556 0.5 0.555556 0.461538 0.555556 0.423077 0.555556 0.384615 0.555556 0.346154 0.555556 0.307692 0.555556 0.269231 0.555556 0.230769 0.555556 0.192308 0.555556 0.153846 0.555556 0.115385 0.555556 0.0769231 0.555556 0.0384616 0.555556 0 0.555556 1 0.592593 0.961538 0.592593 0.923077 0.592593 0.884615 0.592593 0.846154 0.592593 0.807692 0.592593 0.769231 0.592593 0.730769 0.592593 0.692308 0.592593 0.653846 0.592593 0.615385 0.592593 0.576923 0.592593 0.538462 0.592593 0.5 0.592593 0.461538 0.592593 0.423077 0.592593 0.384615 0.592593 0.346154 0.592593 0.307692 0.592593 0.269231 0.592593 0.230769 0.592593 0.192308 0.592593 0.153846 0.592593 0.115385 0.592593 0.0769231 0.592593 0.0384616 0.592593 0 0.592593 1 0.62963 0.961538 0.62963 0.923077 0.62963 0.884615 0.62963 0.846154 0.62963 0.807692 0.62963 0.769231 0.62963 0.730769 0.62963 0.692308 0.62963 0.653846 0.62963 0.615385 0.62963 0.576923 0.62963 0.538462 0.62963 0.5 0.62963 0.461538 0.62963 0.423077 0.62963 0.384615 0.62963 0.346154 0.62963 0.307692 0.62963 0.269231 0.62963 0.230769 0.62963 0.192308 0.62963 0.153846 0.62963 0.115385 0.62963 0.0769231 0.62963 0.0384616 0.62963 0 0.62963 1 0.666667 0.961538 0.666667 0.923077 0.666667 0.884615 0.666667 0.846154 0.666667 0.807692 0.666667 0.769231 0.666667 0.730769 0.666667 0.692308 0.666667 0.653846 0.666667 0.615385 0.666667 0.576923 0.666667 0.538462 0.666667 0.5 0.666667 0.461538 0.666667 0.423077 0.666667 0.384615 0.666667 0.346154 0.666667 0.307692 0.666667 0.269231 0.666667 0.230769 0.666667 0.192308 0.666667 0.153846 0.666667 0.115385 0.666667 0.0769231 0.666667 0.0384616 0.666667 0 0.666667 1 0.703704 0.961538 0.703704 0.923077 0.703704 0.884615 0.703704 0.846154 0.703704 0.807692 0.703704 0.769231 0.703704 0.730769 0.703704 0.692308 0.703704 0.653846 0.703704 0.615385 0.703704 0.576923 0.703704 0.538462 0.703704 0.5 0.703704 0.461538 0.703704 0.423077 0.703704 0.384615 0.703704 0.346154 0.703704 0.307692 0.703704 0.269231 0.703704 0.230769 0.703704 0.192308 0.703704 0.153846 0.703704 0.115385 0.703704 0.0769231 0.703704 0.0384616 0.703704 0 0.703704 1 0.740741 0.961538 0.740741 0.923077 0.740741 0.884615 0.740741 0.846154 0.740741 0.807692 0.740741 0.769231 0.740741 0.730769 0.740741 0.692308 0.740741 0.653846 0.740741 0.615385 0.740741 0.576923 0.740741 0.538462 0.740741 0.5 0.740741 0.461538 0.740741 0.423077 0.740741 0.384615 0.740741 0.346154 0.740741 0.307692 0.740741 0.269231 0.740741 0.230769 0.740741 0.192308 0.740741 0.153846 0.740741 0.115385 0.740741 0.0769231 0.740741 0.0384616 0.740741 0 0.740741 1 0.777778 0.961538 0.777778 0.923077 0.777778 0.884615 0.777778 0.846154 0.777778 0.807692 0.777778 0.769231 0.777778 0.730769 0.777778 0.692308 0.777778 0.653846 0.777778 0.615385 0.777778 0.576923 0.777778 0.538462 0.777778 0.5 0.777778 0.461538 0.777778 0.423077 0.777778 0.384615 0.777778 0.346154 0.777778 0.307692 0.777778 0.269231 0.777778 0.230769 0.777778 0.192308 0.777778 0.153846 0.777778 0.115385 0.777778 0.0769231 0.777778 0.0384616 0.777778 0 0.777778 1 0.814815 0.961538 0.814815 0.923077 0.814815 0.884615 0.814815 0.846154 0.814815 0.807692 0.814815 0.769231 0.814815 0.730769 0.814815 0.692308 0.814815 0.653846 0.814815 0.615385 0.814815 0.576923 0.814815 0.538462 0.814815 0.5 0.814815 0.461538 0.814815 0.423077 0.814815 0.384615 0.814815 0.346154 0.814815 0.307692 0.814815 0.269231 0.814815 0.230769 0.814815 0.192308 0.814815 0.153846 0.814815 0.115385 0.814815 0.0769231 0.814815 0.0384616 0.814815 0 0.814815 1 0.851852 0.961538 0.851852 0.923077 0.851852 0.884615 0.851852 0.846154 0.851852 0.807692 0.851852 0.769231 0.851852 0.730769 0.851852 0.692308 0.851852 0.653846 0.851852 0.615385 0.851852 0.576923 0.851852 0.538462 0.851852 0.5 0.851852 0.461538 0.851852 0.423077 0.851852 0.384615 0.851852 0.346154 0.851852 0.307692 0.851852 0.269231 0.851852 0.230769 0.851852 0.192308 0.851852 0.153846 0.851852 0.115385 0.851852 0.0769231 0.851852 0.0384616 0.851852 0 0.851852 1 0.888889 0.961538 0.888889 0.923077 0.888889 0.884615 0.888889 0.846154 0.888889 0.807692 0.888889 0.769231 0.888889 0.730769 0.888889 0.692308 0.888889 0.653846 0.888889 0.615385 0.888889 0.576923 0.888889 0.538462 0.888889 0.5 0.888889 0.461538 0.888889 0.423077 0.888889 0.384615 0.888889 0.346154 0.888889 0.307692 0.888889 0.269231 0.888889 0.230769 0.888889 0.192308 0.888889 0.153846 0.888889 0.115385 0.888889 0.0769231 0.888889 0.0384616 0.888889 0 0.888889 1 0.925926 0.961538 0.925926 0.923077 0.925926 0.884615 0.925926 0.846154 0.925926 0.807692 0.925926 0.769231 0.925926 0.730769 0.925926 0.692308 0.925926 0.653846 0.925926 0.615385 0.925926 0.576923 0.925926 0.538462 0.925926 0.5 0.925926 0.461538 0.925926 0.423077 0.925926 0.384615 0.925926 0.346154 0.925926 0.307692 0.925926 0.269231 0.925926 0.230769 0.925926 0.192308 0.925926 0.153846 0.925926 0.115385 0.925926 0.0769231 0.925926 0.0384616 0.925926 0 0.925926 1 0.962963 0.961538 0.962963 0.923077 0.962963 0.884615 0.962963 0.846154 0.962963 0.807692 0.962963 0.769231 0.962963 0.730769 0.962963 0.692308 0.962963 0.653846 0.962963 0.615385 0.962963 0.576923 0.962963 0.538462 0.962963 0.5 0.962963 0.461538 0.962963 0.423077 0.962963 0.384615 0.962963 0.346154 0.962963 0.307692 0.962963 0.269231 0.962963 0.230769 0.962963 0.192308 0.962963 0.153846 0.962963 0.115385 0.962963 0.0769231 0.962963 0.0384616 0.962963 0 0.962963 0.981481 1 0.94302 1 0.904558 1 0.866097 1 0.827635 1 0.789174 1 0.750712 1 0.712251 1 0.673789 1 0.635328 1 0.596866 1 0.558405 1 0.519943 1 0.481481 1 0.44302 1 0.404558 1 0.366097 1 0.327635 1 0.289174 1 0.250712 1 0.212251 1 0.173789 1 0.135328 1 0.0968661 1 0.0584046 1 0.019943 1 -0.0185185 1</float_array> + <technique_common> + <accessor count="756" source="#FXStream1-array" stride="2"> + <param name="S" type="float"/> + <param name="T" type="float"/> + </accessor> + </technique_common> + </source> + <vertices id="Sphere-Vertex-0"> + <input semantic="POSITION" source="#FXStream"/> + <input semantic="NORMAL" source="#FXStream2"/> + <input semantic="TEXCOORD" source="#FXStream1"/> + </vertices> + <polygons count="702" material="SphereMaterial"> + <input offset="0" semantic="VERTEX" source="#Sphere-Vertex-0"/> + <p>54 55 28 27</p> + <p>55 56 29 28</p> + <p>56 57 30 29</p> + <p>57 58 31 30</p> + <p>58 59 32 31</p> + <p>59 60 33 32</p> + <p>60 61 34 33</p> + <p>61 62 35 34</p> + <p>62 63 36 35</p> + <p>63 64 37 36</p> + <p>64 65 38 37</p> + <p>65 66 39 38</p> + <p>66 67 40 39</p> + <p>67 68 41 40</p> + <p>68 69 42 41</p> + <p>69 70 43 42</p> + <p>70 71 44 43</p> + <p>71 72 45 44</p> + <p>72 73 46 45</p> + <p>73 74 47 46</p> + <p>74 75 48 47</p> + <p>75 76 49 48</p> + <p>76 77 50 49</p> + <p>77 78 51 50</p> + <p>78 79 52 51</p> + <p>79 80 53 52</p> + <p>81 82 55 54</p> + <p>82 83 56 55</p> + <p>83 84 57 56</p> + <p>84 85 58 57</p> + <p>85 86 59 58</p> + <p>86 87 60 59</p> + <p>87 88 61 60</p> + <p>88 89 62 61</p> + <p>89 90 63 62</p> + <p>90 91 64 63</p> + <p>91 92 65 64</p> + <p>92 93 66 65</p> + <p>93 94 67 66</p> + <p>94 95 68 67</p> + <p>95 96 69 68</p> + <p>96 97 70 69</p> + <p>97 98 71 70</p> + <p>98 99 72 71</p> + <p>99 100 73 72</p> + <p>100 101 74 73</p> + <p>101 102 75 74</p> + <p>102 103 76 75</p> + <p>103 104 77 76</p> + <p>104 105 78 77</p> + <p>105 106 79 78</p> + <p>106 107 80 79</p> + <p>108 109 82 81</p> + <p>109 110 83 82</p> + <p>110 111 84 83</p> + <p>111 112 85 84</p> + <p>112 113 86 85</p> + <p>113 114 87 86</p> + <p>114 115 88 87</p> + <p>115 116 89 88</p> + <p>116 117 90 89</p> + <p>117 118 91 90</p> + <p>118 119 92 91</p> + <p>119 120 93 92</p> + <p>120 121 94 93</p> + <p>121 122 95 94</p> + <p>122 123 96 95</p> + <p>123 124 97 96</p> + <p>124 125 98 97</p> + <p>125 126 99 98</p> + <p>126 127 100 99</p> + <p>127 128 101 100</p> + <p>128 129 102 101</p> + <p>129 130 103 102</p> + <p>130 131 104 103</p> + <p>131 132 105 104</p> + <p>132 133 106 105</p> + <p>133 134 107 106</p> + <p>135 136 109 108</p> + <p>136 137 110 109</p> + <p>137 138 111 110</p> + <p>138 139 112 111</p> + <p>139 140 113 112</p> + <p>140 141 114 113</p> + <p>141 142 115 114</p> + <p>142 143 116 115</p> + <p>143 144 117 116</p> + <p>144 145 118 117</p> + <p>145 146 119 118</p> + <p>146 147 120 119</p> + <p>147 148 121 120</p> + <p>148 149 122 121</p> + <p>149 150 123 122</p> + <p>150 151 124 123</p> + <p>151 152 125 124</p> + <p>152 153 126 125</p> + <p>153 154 127 126</p> + <p>154 155 128 127</p> + <p>155 156 129 128</p> + <p>156 157 130 129</p> + <p>157 158 131 130</p> + <p>158 159 132 131</p> + <p>159 160 133 132</p> + <p>160 161 134 133</p> + <p>162 163 136 135</p> + <p>163 164 137 136</p> + <p>164 165 138 137</p> + <p>165 166 139 138</p> + <p>166 167 140 139</p> + <p>167 168 141 140</p> + <p>168 169 142 141</p> + <p>169 170 143 142</p> + <p>170 171 144 143</p> + <p>171 172 145 144</p> + <p>172 173 146 145</p> + <p>173 174 147 146</p> + <p>174 175 148 147</p> + <p>175 176 149 148</p> + <p>176 177 150 149</p> + <p>177 178 151 150</p> + <p>178 179 152 151</p> + <p>179 180 153 152</p> + <p>180 181 154 153</p> + <p>181 182 155 154</p> + <p>182 183 156 155</p> + <p>183 184 157 156</p> + <p>184 185 158 157</p> + <p>185 186 159 158</p> + <p>186 187 160 159</p> + <p>187 188 161 160</p> + <p>189 190 163 162</p> + <p>190 191 164 163</p> + <p>191 192 165 164</p> + <p>192 193 166 165</p> + <p>193 194 167 166</p> + <p>194 195 168 167</p> + <p>195 196 169 168</p> + <p>196 197 170 169</p> + <p>197 198 171 170</p> + <p>198 199 172 171</p> + <p>199 200 173 172</p> + <p>200 201 174 173</p> + <p>201 202 175 174</p> + <p>202 203 176 175</p> + <p>203 204 177 176</p> + <p>204 205 178 177</p> + <p>205 206 179 178</p> + <p>206 207 180 179</p> + <p>207 208 181 180</p> + <p>208 209 182 181</p> + <p>209 210 183 182</p> + <p>210 211 184 183</p> + <p>211 212 185 184</p> + <p>212 213 186 185</p> + <p>213 214 187 186</p> + <p>214 215 188 187</p> + <p>216 217 190 189</p> + <p>217 218 191 190</p> + <p>218 219 192 191</p> + <p>219 220 193 192</p> + <p>220 221 194 193</p> + <p>221 222 195 194</p> + <p>222 223 196 195</p> + <p>223 224 197 196</p> + <p>224 225 198 197</p> + <p>225 226 199 198</p> + <p>226 227 200 199</p> + <p>227 228 201 200</p> + <p>228 229 202 201</p> + <p>229 230 203 202</p> + <p>230 231 204 203</p> + <p>231 232 205 204</p> + <p>232 233 206 205</p> + <p>233 234 207 206</p> + <p>234 235 208 207</p> + <p>235 236 209 208</p> + <p>236 237 210 209</p> + <p>237 238 211 210</p> + <p>238 239 212 211</p> + <p>239 240 213 212</p> + <p>240 241 214 213</p> + <p>241 242 215 214</p> + <p>243 244 217 216</p> + <p>244 245 218 217</p> + <p>245 246 219 218</p> + <p>246 247 220 219</p> + <p>247 248 221 220</p> + <p>248 249 222 221</p> + <p>249 250 223 222</p> + <p>250 251 224 223</p> + <p>251 252 225 224</p> + <p>252 253 226 225</p> + <p>253 254 227 226</p> + <p>254 255 228 227</p> + <p>255 256 229 228</p> + <p>256 257 230 229</p> + <p>257 258 231 230</p> + <p>258 259 232 231</p> + <p>259 260 233 232</p> + <p>260 261 234 233</p> + <p>261 262 235 234</p> + <p>262 263 236 235</p> + <p>263 264 237 236</p> + <p>264 265 238 237</p> + <p>265 266 239 238</p> + <p>266 267 240 239</p> + <p>267 268 241 240</p> + <p>268 269 242 241</p> + <p>270 271 244 243</p> + <p>271 272 245 244</p> + <p>272 273 246 245</p> + <p>273 274 247 246</p> + <p>274 275 248 247</p> + <p>275 276 249 248</p> + <p>276 277 250 249</p> + <p>277 278 251 250</p> + <p>278 279 252 251</p> + <p>279 280 253 252</p> + <p>280 281 254 253</p> + <p>281 282 255 254</p> + <p>282 283 256 255</p> + <p>283 284 257 256</p> + <p>284 285 258 257</p> + <p>285 286 259 258</p> + <p>286 287 260 259</p> + <p>287 288 261 260</p> + <p>288 289 262 261</p> + <p>289 290 263 262</p> + <p>290 291 264 263</p> + <p>291 292 265 264</p> + <p>292 293 266 265</p> + <p>293 294 267 266</p> + <p>294 295 268 267</p> + <p>295 296 269 268</p> + <p>297 298 271 270</p> + <p>298 299 272 271</p> + <p>299 300 273 272</p> + <p>300 301 274 273</p> + <p>301 302 275 274</p> + <p>302 303 276 275</p> + <p>303 304 277 276</p> + <p>304 305 278 277</p> + <p>305 306 279 278</p> + <p>306 307 280 279</p> + <p>307 308 281 280</p> + <p>308 309 282 281</p> + <p>309 310 283 282</p> + <p>310 311 284 283</p> + <p>311 312 285 284</p> + <p>312 313 286 285</p> + <p>313 314 287 286</p> + <p>314 315 288 287</p> + <p>315 316 289 288</p> + <p>316 317 290 289</p> + <p>317 318 291 290</p> + <p>318 319 292 291</p> + <p>319 320 293 292</p> + <p>320 321 294 293</p> + <p>321 322 295 294</p> + <p>322 323 296 295</p> + <p>324 325 298 297</p> + <p>325 326 299 298</p> + <p>326 327 300 299</p> + <p>327 328 301 300</p> + <p>328 329 302 301</p> + <p>329 330 303 302</p> + <p>330 331 304 303</p> + <p>331 332 305 304</p> + <p>332 333 306 305</p> + <p>333 334 307 306</p> + <p>334 335 308 307</p> + <p>335 336 309 308</p> + <p>336 337 310 309</p> + <p>337 338 311 310</p> + <p>338 339 312 311</p> + <p>339 340 313 312</p> + <p>340 341 314 313</p> + <p>341 342 315 314</p> + <p>342 343 316 315</p> + <p>343 344 317 316</p> + <p>344 345 318 317</p> + <p>345 346 319 318</p> + <p>346 347 320 319</p> + <p>347 348 321 320</p> + <p>348 349 322 321</p> + <p>349 350 323 322</p> + <p>351 352 325 324</p> + <p>352 353 326 325</p> + <p>353 354 327 326</p> + <p>354 355 328 327</p> + <p>355 356 329 328</p> + <p>356 357 330 329</p> + <p>357 358 331 330</p> + <p>358 359 332 331</p> + <p>359 360 333 332</p> + <p>360 361 334 333</p> + <p>361 362 335 334</p> + <p>362 363 336 335</p> + <p>363 364 337 336</p> + <p>364 365 338 337</p> + <p>365 366 339 338</p> + <p>366 367 340 339</p> + <p>367 368 341 340</p> + <p>368 369 342 341</p> + <p>369 370 343 342</p> + <p>370 371 344 343</p> + <p>371 372 345 344</p> + <p>372 373 346 345</p> + <p>373 374 347 346</p> + <p>374 375 348 347</p> + <p>375 376 349 348</p> + <p>376 377 350 349</p> + <p>378 379 352 351</p> + <p>379 380 353 352</p> + <p>380 381 354 353</p> + <p>381 382 355 354</p> + <p>382 383 356 355</p> + <p>383 384 357 356</p> + <p>384 385 358 357</p> + <p>385 386 359 358</p> + <p>386 387 360 359</p> + <p>387 388 361 360</p> + <p>388 389 362 361</p> + <p>389 390 363 362</p> + <p>390 391 364 363</p> + <p>391 392 365 364</p> + <p>392 393 366 365</p> + <p>393 394 367 366</p> + <p>394 395 368 367</p> + <p>395 396 369 368</p> + <p>396 397 370 369</p> + <p>397 398 371 370</p> + <p>398 399 372 371</p> + <p>399 400 373 372</p> + <p>400 401 374 373</p> + <p>401 402 375 374</p> + <p>402 403 376 375</p> + <p>403 404 377 376</p> + <p>405 406 379 378</p> + <p>406 407 380 379</p> + <p>407 408 381 380</p> + <p>408 409 382 381</p> + <p>409 410 383 382</p> + <p>410 411 384 383</p> + <p>411 412 385 384</p> + <p>412 413 386 385</p> + <p>413 414 387 386</p> + <p>414 415 388 387</p> + <p>415 416 389 388</p> + <p>416 417 390 389</p> + <p>417 418 391 390</p> + <p>418 419 392 391</p> + <p>419 420 393 392</p> + <p>420 421 394 393</p> + <p>421 422 395 394</p> + <p>422 423 396 395</p> + <p>423 424 397 396</p> + <p>424 425 398 397</p> + <p>425 426 399 398</p> + <p>426 427 400 399</p> + <p>427 428 401 400</p> + <p>428 429 402 401</p> + <p>429 430 403 402</p> + <p>430 431 404 403</p> + <p>432 433 406 405</p> + <p>433 434 407 406</p> + <p>434 435 408 407</p> + <p>435 436 409 408</p> + <p>436 437 410 409</p> + <p>437 438 411 410</p> + <p>438 439 412 411</p> + <p>439 440 413 412</p> + <p>440 441 414 413</p> + <p>441 442 415 414</p> + <p>442 443 416 415</p> + <p>443 444 417 416</p> + <p>444 445 418 417</p> + <p>445 446 419 418</p> + <p>446 447 420 419</p> + <p>447 448 421 420</p> + <p>448 449 422 421</p> + <p>449 450 423 422</p> + <p>450 451 424 423</p> + <p>451 452 425 424</p> + <p>452 453 426 425</p> + <p>453 454 427 426</p> + <p>454 455 428 427</p> + <p>455 456 429 428</p> + <p>456 457 430 429</p> + <p>457 458 431 430</p> + <p>459 460 433 432</p> + <p>460 461 434 433</p> + <p>461 462 435 434</p> + <p>462 463 436 435</p> + <p>463 464 437 436</p> + <p>464 465 438 437</p> + <p>465 466 439 438</p> + <p>466 467 440 439</p> + <p>467 468 441 440</p> + <p>468 469 442 441</p> + <p>469 470 443 442</p> + <p>470 471 444 443</p> + <p>471 472 445 444</p> + <p>472 473 446 445</p> + <p>473 474 447 446</p> + <p>474 475 448 447</p> + <p>475 476 449 448</p> + <p>476 477 450 449</p> + <p>477 478 451 450</p> + <p>478 479 452 451</p> + <p>479 480 453 452</p> + <p>480 481 454 453</p> + <p>481 482 455 454</p> + <p>482 483 456 455</p> + <p>483 484 457 456</p> + <p>484 485 458 457</p> + <p>486 487 460 459</p> + <p>487 488 461 460</p> + <p>488 489 462 461</p> + <p>489 490 463 462</p> + <p>490 491 464 463</p> + <p>491 492 465 464</p> + <p>492 493 466 465</p> + <p>493 494 467 466</p> + <p>494 495 468 467</p> + <p>495 496 469 468</p> + <p>496 497 470 469</p> + <p>497 498 471 470</p> + <p>498 499 472 471</p> + <p>499 500 473 472</p> + <p>500 501 474 473</p> + <p>501 502 475 474</p> + <p>502 503 476 475</p> + <p>503 504 477 476</p> + <p>504 505 478 477</p> + <p>505 506 479 478</p> + <p>506 507 480 479</p> + <p>507 508 481 480</p> + <p>508 509 482 481</p> + <p>509 510 483 482</p> + <p>510 511 484 483</p> + <p>511 512 485 484</p> + <p>513 514 487 486</p> + <p>514 515 488 487</p> + <p>515 516 489 488</p> + <p>516 517 490 489</p> + <p>517 518 491 490</p> + <p>518 519 492 491</p> + <p>519 520 493 492</p> + <p>520 521 494 493</p> + <p>521 522 495 494</p> + <p>522 523 496 495</p> + <p>523 524 497 496</p> + <p>524 525 498 497</p> + <p>525 526 499 498</p> + <p>526 527 500 499</p> + <p>527 528 501 500</p> + <p>528 529 502 501</p> + <p>529 530 503 502</p> + <p>530 531 504 503</p> + <p>531 532 505 504</p> + <p>532 533 506 505</p> + <p>533 534 507 506</p> + <p>534 535 508 507</p> + <p>535 536 509 508</p> + <p>536 537 510 509</p> + <p>537 538 511 510</p> + <p>538 539 512 511</p> + <p>540 541 514 513</p> + <p>541 542 515 514</p> + <p>542 543 516 515</p> + <p>543 544 517 516</p> + <p>544 545 518 517</p> + <p>545 546 519 518</p> + <p>546 547 520 519</p> + <p>547 548 521 520</p> + <p>548 549 522 521</p> + <p>549 550 523 522</p> + <p>550 551 524 523</p> + <p>551 552 525 524</p> + <p>552 553 526 525</p> + <p>553 554 527 526</p> + <p>554 555 528 527</p> + <p>555 556 529 528</p> + <p>556 557 530 529</p> + <p>557 558 531 530</p> + <p>558 559 532 531</p> + <p>559 560 533 532</p> + <p>560 561 534 533</p> + <p>561 562 535 534</p> + <p>562 563 536 535</p> + <p>563 564 537 536</p> + <p>564 565 538 537</p> + <p>565 566 539 538</p> + <p>567 568 541 540</p> + <p>568 569 542 541</p> + <p>569 570 543 542</p> + <p>570 571 544 543</p> + <p>571 572 545 544</p> + <p>572 573 546 545</p> + <p>573 574 547 546</p> + <p>574 575 548 547</p> + <p>575 576 549 548</p> + <p>576 577 550 549</p> + <p>577 578 551 550</p> + <p>578 579 552 551</p> + <p>579 580 553 552</p> + <p>580 581 554 553</p> + <p>581 582 555 554</p> + <p>582 583 556 555</p> + <p>583 584 557 556</p> + <p>584 585 558 557</p> + <p>585 586 559 558</p> + <p>586 587 560 559</p> + <p>587 588 561 560</p> + <p>588 589 562 561</p> + <p>589 590 563 562</p> + <p>590 591 564 563</p> + <p>591 592 565 564</p> + <p>592 593 566 565</p> + <p>594 595 568 567</p> + <p>595 596 569 568</p> + <p>596 597 570 569</p> + <p>597 598 571 570</p> + <p>598 599 572 571</p> + <p>599 600 573 572</p> + <p>600 601 574 573</p> + <p>601 602 575 574</p> + <p>602 603 576 575</p> + <p>603 604 577 576</p> + <p>604 605 578 577</p> + <p>605 606 579 578</p> + <p>606 607 580 579</p> + <p>607 608 581 580</p> + <p>608 609 582 581</p> + <p>609 610 583 582</p> + <p>610 611 584 583</p> + <p>611 612 585 584</p> + <p>612 613 586 585</p> + <p>613 614 587 586</p> + <p>614 615 588 587</p> + <p>615 616 589 588</p> + <p>616 617 590 589</p> + <p>617 618 591 590</p> + <p>618 619 592 591</p> + <p>619 620 593 592</p> + <p>621 622 595 594</p> + <p>622 623 596 595</p> + <p>623 624 597 596</p> + <p>624 625 598 597</p> + <p>625 626 599 598</p> + <p>626 627 600 599</p> + <p>627 628 601 600</p> + <p>628 629 602 601</p> + <p>629 630 603 602</p> + <p>630 631 604 603</p> + <p>631 632 605 604</p> + <p>632 633 606 605</p> + <p>633 634 607 606</p> + <p>634 635 608 607</p> + <p>635 636 609 608</p> + <p>636 637 610 609</p> + <p>637 638 611 610</p> + <p>638 639 612 611</p> + <p>639 640 613 612</p> + <p>640 641 614 613</p> + <p>641 642 615 614</p> + <p>642 643 616 615</p> + <p>643 644 617 616</p> + <p>644 645 618 617</p> + <p>645 646 619 618</p> + <p>646 647 620 619</p> + <p>648 649 622 621</p> + <p>649 650 623 622</p> + <p>650 651 624 623</p> + <p>651 652 625 624</p> + <p>652 653 626 625</p> + <p>653 654 627 626</p> + <p>654 655 628 627</p> + <p>655 656 629 628</p> + <p>656 657 630 629</p> + <p>657 658 631 630</p> + <p>658 659 632 631</p> + <p>659 660 633 632</p> + <p>660 661 634 633</p> + <p>661 662 635 634</p> + <p>662 663 636 635</p> + <p>663 664 637 636</p> + <p>664 665 638 637</p> + <p>665 666 639 638</p> + <p>666 667 640 639</p> + <p>667 668 641 640</p> + <p>668 669 642 641</p> + <p>669 670 643 642</p> + <p>670 671 644 643</p> + <p>671 672 645 644</p> + <p>672 673 646 645</p> + <p>673 674 647 646</p> + <p>675 676 649 648</p> + <p>676 677 650 649</p> + <p>677 678 651 650</p> + <p>678 679 652 651</p> + <p>679 680 653 652</p> + <p>680 681 654 653</p> + <p>681 682 655 654</p> + <p>682 683 656 655</p> + <p>683 684 657 656</p> + <p>684 685 658 657</p> + <p>685 686 659 658</p> + <p>686 687 660 659</p> + <p>687 688 661 660</p> + <p>688 689 662 661</p> + <p>689 690 663 662</p> + <p>690 691 664 663</p> + <p>691 692 665 664</p> + <p>692 693 666 665</p> + <p>693 694 667 666</p> + <p>694 695 668 667</p> + <p>695 696 669 668</p> + <p>696 697 670 669</p> + <p>697 698 671 670</p> + <p>698 699 672 671</p> + <p>699 700 673 672</p> + <p>700 701 674 673</p> + <p>702 703 676 675</p> + <p>703 704 677 676</p> + <p>704 705 678 677</p> + <p>705 706 679 678</p> + <p>706 707 680 679</p> + <p>707 708 681 680</p> + <p>708 709 682 681</p> + <p>709 710 683 682</p> + <p>710 711 684 683</p> + <p>711 712 685 684</p> + <p>712 713 686 685</p> + <p>713 714 687 686</p> + <p>714 715 688 687</p> + <p>715 716 689 688</p> + <p>716 717 690 689</p> + <p>717 718 691 690</p> + <p>718 719 692 691</p> + <p>719 720 693 692</p> + <p>720 721 694 693</p> + <p>721 722 695 694</p> + <p>722 723 696 695</p> + <p>723 724 697 696</p> + <p>724 725 698 697</p> + <p>725 726 699 698</p> + <p>726 727 700 699</p> + <p>727 728 701 700</p> + <p>27 28 0</p> + <p>28 29 1</p> + <p>29 30 2</p> + <p>30 31 3</p> + <p>31 32 4</p> + <p>32 33 5</p> + <p>33 34 6</p> + <p>34 35 7</p> + <p>35 36 8</p> + <p>36 37 9</p> + <p>37 38 10</p> + <p>38 39 11</p> + <p>39 40 12</p> + <p>40 41 13</p> + <p>41 42 14</p> + <p>42 43 15</p> + <p>43 44 16</p> + <p>44 45 17</p> + <p>45 46 18</p> + <p>46 47 19</p> + <p>47 48 20</p> + <p>48 49 21</p> + <p>49 50 22</p> + <p>50 51 23</p> + <p>51 52 24</p> + <p>52 53 25</p> + <p>703 702 729</p> + <p>704 703 730</p> + <p>705 704 731</p> + <p>706 705 732</p> + <p>707 706 733</p> + <p>708 707 734</p> + <p>709 708 735</p> + <p>710 709 736</p> + <p>711 710 737</p> + <p>712 711 738</p> + <p>713 712 739</p> + <p>714 713 740</p> + <p>715 714 741</p> + <p>716 715 742</p> + <p>717 716 743</p> + <p>718 717 744</p> + <p>719 718 745</p> + <p>720 719 746</p> + <p>721 720 747</p> + <p>722 721 748</p> + <p>723 722 749</p> + <p>724 723 750</p> + <p>725 724 751</p> + <p>726 725 752</p> + <p>727 726 753</p> + <p>728 727 754</p> + </polygons> + </mesh> + </geometry> + </library_geometries> + <library_lights> + <light id="PointLight" name="PointLight"> + <technique_common> + <point> + <color>1 1 1</color> + <constant_attenuation>1</constant_attenuation> + <linear_attenuation>0</linear_attenuation> + <quadratic_attenuation>0</quadratic_attenuation> + </point> + </technique_common> + </light> + <light id="DirectionalLight" name="DirectionalLight"> + <technique_common> + <directional> + <color>1 1 1</color> + </directional> + </technique_common> + </light> + </library_lights> + <scene> + <instance_visual_scene url="#DefaultScene"/> + </scene> +</COLLADA> diff --git a/data/CgFX/basic-lighting/Lambert.cgfx b/data/CgFX/basic-lighting/Lambert.cgfx new file mode 100644 index 000000000..e27db52f9 --- /dev/null +++ b/data/CgFX/basic-lighting/Lambert.cgfx @@ -0,0 +1,285 @@ +/*********************************************************************NVMH3**** +$Revision$ + +Copyright NVIDIA Corporation 2007 +TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED +*AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS +BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES +WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, +BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY +LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF +NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + + +To learn more about shading, shaders, and to bounce ideas off other shader + authors and users, visit the NVIDIA Shader Library Forums at: + + http://developer.nvidia.com/forums/ + +******************************************************************************/ + +#define FLIP_TEXTURE_Y + +float Script : STANDARDSGLOBAL < + string UIWidget = "none"; + string ScriptClass = "object"; + string ScriptOrder = "standard"; + string ScriptOutput = "color"; + string Script = "Technique=Main;"; +> = 0.8; + +//// UN-TWEAKABLES - AUTOMATICALLY-TRACKED TRANSFORMS //////////////// + +float4x4 WorldITXf : WorldInverseTranspose < string UIWidget="None"; >; +float4x4 WvpXf : WorldViewProjection < string UIWidget="None"; >; +float4x4 WorldXf : World < string UIWidget="None"; >; +float4x4 ViewIXf : ViewInverse < string UIWidget="None"; >; + +//// TWEAKABLE PARAMETERS //////////////////// + +/// Point Lamp 0 //////////// +float3 Lamp0Pos : Position < + string Object = "PointLight0"; + string UIName = "Lamp 0 Position"; + string Space = "World"; +> = {-0.5f,2.0f,1.25f}; + +float3 Lamp0Color : Specular < + string UIName = "Lamp 0"; + string Object = "Pointlight0"; + string UIWidget = "Color"; +> = {1.0f,1.0f,1.0f}; + +// Ambient Light +float3 AmbiColor : Ambient < + string UIName = "Ambient Light"; + string UIWidget = "Color"; +> = {0.07f,0.07f,0.07f}; + + +//////// COLOR & TEXTURE ///////////////////// + +/// the ambient material colour +float4 m_Ambient; + +/// the diffuse colour +float4 m_Diffuse; + +/// the specular colour +float4 m_Specular; + +/// the emission colour +float4 m_Emission; + +/// the transparency colour +float4 m_Transparency; + +/// the shininess +float m_Shininess; + +texture ColorTexture < + string ResourceName = "default_color.dds"; + string UIName = "Diffuse Texture"; + string ResourceType = "2D"; +>; + +sampler2D ColorSampler = sampler_state { + Texture = <ColorTexture>; + MinFilter = LinearMipMapLinear; + MagFilter = Linear; + WrapS = Repeat; + WrapT = Repeat; +}; + +//////// CONNECTOR DATA STRUCTURES /////////// + +/* data from application vertex buffer */ +struct appdata { + float3 Position : POSITION; + float4 UV : TEXCOORD0; + float4 Normal : NORMAL; + float4 Tangent : TANGENT0; + float4 Binormal : BINORMAL0; +}; + +/* data passed from vertex shader to pixel shader */ +struct vertexOutput { + float4 HPosition : POSITION; + float2 UV : TEXCOORD0; + // The following values are passed in "World" coordinates since + // it tends to be the most flexible and easy for handling + // reflections, sky lighting, and other "global" effects. + float3 LightVec : TEXCOORD1; + float3 WorldNormal : TEXCOORD2; + float3 WorldTangent : TEXCOORD3; + float3 WorldBinormal : TEXCOORD4; + float3 WorldView : TEXCOORD5; +}; + +///////// VERTEX SHADING ///////////////////// + +/*********** Generic Vertex Shader ******/ + +vertexOutput std_VS(appdata IN) { + vertexOutput OUT = (vertexOutput)0; + OUT.WorldNormal = mul(WorldITXf,IN.Normal).xyz; + OUT.WorldTangent = mul(WorldITXf,IN.Tangent).xyz; + OUT.WorldBinormal = mul(WorldITXf,IN.Binormal).xyz; + float4 Po = float4(IN.Position.xyz,1); + float3 Pw = mul(WorldXf,Po).xyz; + OUT.LightVec = (Lamp0Pos - Pw); +#ifdef FLIP_TEXTURE_Y + OUT.UV = float2(IN.UV.x,(1.0-IN.UV.y)); +#else /* !FLIP_TEXTURE_Y */ + OUT.UV = IN.UV.xy; +#endif /* !FLIP_TEXTURE_Y */ + OUT.WorldView = normalize(float3(ViewIXf[0].w,ViewIXf[1].w,ViewIXf[2].w) - Pw); + OUT.HPosition = mul(WvpXf,Po); + return OUT; +} + +///////// PIXEL SHADING ////////////////////// + +float4 std_PS(vertexOutput IN, + float face : FACE) : COLOR { + float3 Ln = normalize(IN.LightVec); + float3 Nn = face * normalize(IN.WorldNormal); + float ldn = dot(Ln,Nn); + ldn = max(ldn,0.0); + float4 textureColor = tex2D(ColorSampler,IN.UV); + float3 result = textureColor.rgb * (ldn * Lamp0Color + AmbiColor); + // return as float4 + return float4(result, textureColor.a); +} + +float4 No_Texture_PS(vertexOutput IN, + float face : FACE) : COLOR { + float3 Ln = normalize(IN.LightVec); + float3 Nn = face * normalize(IN.WorldNormal); + float ldn = dot(Ln,Nn); + ldn = max(ldn,0.0); + float3 result = m_Diffuse.rgb * (ldn * Lamp0Color + AmbiColor); + // return as float4 + return float4(result, m_Diffuse.a); +} + +///// TECHNIQUES ///////////////////////////// + +technique Main < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = true; + CullFaceEnable = false; + BlendEnable = false; + DepthFunc = LEqual; + FragmentProgram = compile fp40 std_PS(); + } +} + +technique Main_Blending < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = false; + CullFaceEnable = false; + BlendEnable = true; + BlendFunc = float2(SrcAlpha, OneMinusSrcAlpha); + DepthFunc = LEqual; + FragmentProgram = compile fp40 std_PS(); + } +} + +technique Main_Alphatest < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = true; + CullFaceEnable = false; + AlphaFunc = float2(Greater, 0.1f); + AlphaTestEnable = true; + FragmentProgram = compile fp40 std_PS(); + } +} + +technique No_Texture < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = true; + CullFaceEnable = false; + BlendEnable = false; + DepthFunc = LEqual; + FragmentProgram = compile fp40 No_Texture_PS(); + } +} + +technique No_Texture_Blending < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = false; + CullFaceEnable = false; + BlendEnable = true; + BlendFunc = float2(SrcAlpha, OneMinusSrcAlpha); + DepthFunc = LEqual; + FragmentProgram = compile fp40 No_Texture_PS(); + } +} + +technique Main_Specular < // this is dummy. Lambert does not have specular + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = true; + CullFaceEnable = false; + BlendEnable = false; + DepthFunc = LEqual; + FragmentProgram = compile fp40 std_PS(); + } +} + +technique Main_Specular_Blending < // this is dummy. Lambert does not have specular + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = false; + CullFaceEnable = false; + BlendEnable = true; + BlendFunc = float2(SrcAlpha, OneMinusSrcAlpha); + DepthFunc = LEqual; + FragmentProgram = compile fp40 std_PS(); + } +} + +/////////////////////////////////////// eof // diff --git a/data/CgFX/basic-lighting/Lambert_bump_reflect.cgfx b/data/CgFX/basic-lighting/Lambert_bump_reflect.cgfx new file mode 100644 index 000000000..1907f5934 --- /dev/null +++ b/data/CgFX/basic-lighting/Lambert_bump_reflect.cgfx @@ -0,0 +1,227 @@ +/*********************************************************************NVMH3**** +$Revision$ + +Copyright NVIDIA Corporation 2007 +TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED +*AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS +BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES +WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, +BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY +LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF +NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + + +To learn more about shading, shaders, and to bounce ideas off other shader + authors and users, visit the NVIDIA Shader Library Forums at: + + http://developer.nvidia.com/forums/ + +******************************************************************************/ + +// #define FLIP_TEXTURE_Y + +float Script : STANDARDSGLOBAL < + string UIWidget = "none"; + string ScriptClass = "object"; + string ScriptOrder = "standard"; + string ScriptOutput = "color"; + string Script = "Technique=Main;"; +> = 0.8; + +//// UN-TWEAKABLES - AUTOMATICALLY-TRACKED TRANSFORMS //////////////// + +float4x4 WorldITXf : WorldInverseTranspose < string UIWidget="None"; >; +float4x4 WvpXf : WorldViewProjection < string UIWidget="None"; >; +float4x4 WorldXf : World < string UIWidget="None"; >; +float4x4 ViewIXf : ViewInverse < string UIWidget="None"; >; + +//// TWEAKABLE PARAMETERS //////////////////// + +/// Point Lamp 0 //////////// +float3 Lamp0Pos : Position < + string Object = "PointLight0"; + string UIName = "Lamp 0 Position"; + string Space = "World"; +> = {-0.5f,2.0f,1.25f}; +float3 Lamp0Color : Specular < + string UIName = "Lamp 0"; + string Object = "Pointlight0"; + string UIWidget = "Color"; +> = {1.0f,1.0f,1.0f}; + +// Ambient Light +float3 AmbiColor : Ambient < + string UIName = "Ambient Light"; + string UIWidget = "Color"; +> = {0.07f,0.07f,0.07f}; + + +float Bump < + string UIWidget = "slider"; + float UIMin = 0.0; + float UIMax = 3.0; + float UIStep = 0.01; + string UIName = "Bumpiness"; +> = 1.0; + +float Kr < + string UIWidget = "slider"; + float UIMin = 0.0; + float UIMax = 1.0; + float UIStep = 0.01; + string UIName = "Reflection Strength"; +> = 1.0; + +float KrMin < + string UIWidget = "slider"; + float UIMin = 0.0; + float UIMax = 0.25; + float UIStep = 0.001; + string UIName = "Fresnel Scale"; +> = 0.05; + +float FresExp < + string UIWidget = "slider"; + float UIMin = 0.0; + float UIMax = 5.0; + float UIStep = 0.5; + string UIName = "Fresnel Exponent"; +> = 4.0; + +//////// COLOR & TEXTURE ///////////////////// + +texture ColorTexture < + string ResourceName = "default_color.dds"; + string UIName = "Diffuse Texture"; + string ResourceType = "2D"; +>; + +sampler2D ColorSampler = sampler_state { + Texture = <ColorTexture>; + MinFilter = LinearMipMapLinear; + MagFilter = Linear; + WrapS = Repeat; + WrapT = Repeat; +}; + +texture NormalTexture < + string ResourceName = "default_bump_normal.dds"; + string UIName = "Normal-Map Texture"; + string ResourceType = "2D"; +>; + +sampler2D NormalSampler = sampler_state { + Texture = <NormalTexture>; + MinFilter = LinearMipMapLinear; + MagFilter = Linear; + WrapS = Repeat; + WrapT = Repeat; +}; + +texture EnvTexture : ENVIRONMENT < + string ResourceName = "default_reflection.dds"; + string UIName = "Environment"; + string ResourceType = "Cube"; +>; + +samplerCUBE EnvSampler = sampler_state { + Texture = <EnvTexture>; + MagFilter = Linear; + MinFilter = LinearMipMapLinear; + WrapS = ClampToEdge; + WrapT = ClampToEdge; + WrapR = ClampToEdge; +}; + + +//////// CONNECTOR DATA STRUCTURES /////////// + +/* data from application vertex buffer */ +struct appdata { + float3 Position : POSITION; + float4 UV : TEXCOORD0; + float4 Normal : NORMAL; + float4 Tangent : TANGENT0; + float4 Binormal : BINORMAL0; +}; + +/* data passed from vertex shader to pixel shader */ +struct vertexOutput { + float4 HPosition : POSITION; + float2 UV : TEXCOORD0; + // The following values are passed in "World" coordinates since + // it tends to be the most flexible and easy for handling + // reflections, sky lighting, and other "global" effects. + float3 LightVec : TEXCOORD1; + float3 WorldNormal : TEXCOORD2; + float3 WorldTangent : TEXCOORD3; + float3 WorldBinormal : TEXCOORD4; + float3 WorldView : TEXCOORD5; +}; + +///////// VERTEX SHADING ///////////////////// + +/*********** Generic Vertex Shader ******/ + +vertexOutput std_VS(appdata IN) { + vertexOutput OUT = (vertexOutput)0; + OUT.WorldNormal = mul(WorldITXf,IN.Normal).xyz; + OUT.WorldTangent = mul(WorldITXf,IN.Tangent).xyz; + OUT.WorldBinormal = mul(WorldITXf,IN.Binormal).xyz; + float4 Po = float4(IN.Position.xyz,1); + float3 Pw = mul(WorldXf,Po).xyz; + OUT.LightVec = (Lamp0Pos - Pw); +#ifdef FLIP_TEXTURE_Y + OUT.UV = float2(IN.UV.x,(1.0-IN.UV.y)); +#else /* !FLIP_TEXTURE_Y */ + OUT.UV = IN.UV.xy; +#endif /* !FLIP_TEXTURE_Y */ + OUT.WorldView = normalize(float3(ViewIXf[0].w,ViewIXf[1].w,ViewIXf[2].w) - Pw); + OUT.HPosition = mul(WvpXf,Po); + return OUT; +} + +///////// PIXEL SHADING ////////////////////// + +float4 std_PS(vertexOutput IN) : COLOR { + float3 Ln = normalize(IN.LightVec); + float3 Nn = normalize(IN.WorldNormal); + float3 Tn = normalize(IN.WorldTangent); + float3 Bn = normalize(IN.WorldBinormal); + float3 bump = Bump * (tex2D(NormalSampler,IN.UV).rgb - float3(0.5,0.5,0.5)); + Nn = Nn + bump.x*Tn + bump.y*Bn; + Nn = normalize(Nn); + float ldn = dot(Ln,Nn); + ldn = max(ldn,0.0); + float3 diffuseColor = tex2D(ColorSampler,IN.UV).rgb; + float3 result = diffuseColor * (ldn * Lamp0Color + AmbiColor); + float3 Vn = normalize(IN.WorldView); + float3 R = -reflect(Vn,Nn); + float vdn = dot(Vn,Nn); + half fres = KrMin + (Kr-KrMin) * pow(1-abs(vdn),FresExp); + float3 reflColor = fres * texCUBE(EnvSampler,R.xyz).rgb; + result += reflColor; + return float4(result,1); +} + +///// TECHNIQUES ///////////////////////////// + +technique Main < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = true; + CullFaceEnable = false; + BlendEnable = false; + DepthFunc = LEqual; + FragmentProgram = compile fp40 std_PS(); + } +} + +/////////////////////////////////////// eof // diff --git a/data/CgFX/basic-lighting/Phong.cgfx b/data/CgFX/basic-lighting/Phong.cgfx new file mode 100644 index 000000000..65508198f --- /dev/null +++ b/data/CgFX/basic-lighting/Phong.cgfx @@ -0,0 +1,360 @@ +/*********************************************************************NVMH3**** +$Revision$ + +Copyright NVIDIA Corporation 2007 +TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED +*AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS +BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES +WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, +BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY +LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF +NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + + +To learn more about shading, shaders, and to bounce ideas off other shader + authors and users, visit the NVIDIA Shader Library Forums at: + + http://developer.nvidia.com/forums/ + +******************************************************************************/ + +#define FLIP_TEXTURE_Y + +float Script : STANDARDSGLOBAL < + string UIWidget = "none"; + string ScriptClass = "object"; + string ScriptOrder = "standard"; + string ScriptOutput = "color"; + string Script = "Technique=Main;"; +> = 0.8; + +//// UN-TWEAKABLES - AUTOMATICALLY-TRACKED TRANSFORMS //////////////// + +float4x4 WorldITXf : WorldInverseTranspose < string UIWidget="None"; >; +float4x4 WvpXf : WorldViewProjection < string UIWidget="None"; >; +float4x4 WorldXf : World < string UIWidget="None"; >; +float4x4 ViewIXf : ViewInverse < string UIWidget="None"; >; + +//// TWEAKABLE PARAMETERS //////////////////// + +/// Point Lamp 0 //////////// +float3 Lamp0Pos : Position < + string Object = "PointLight0"; + string UIName = "Lamp 0 Position"; + string Space = "World"; +> = {-0.5f,2.0f,1.25f}; +float3 Lamp0Color : Specular < + string UIName = "Lamp 0"; + string Object = "Pointlight0"; + string UIWidget = "Color"; +> = {1.0f,1.0f,1.0f}; + +// Ambient Light +float3 AmbiColor : Ambient < + string UIName = "Ambient Light"; + string UIWidget = "Color"; +> = {0.07f,0.07f,0.07f}; + +float Ks < + string UIWidget = "slider"; + float UIMin = 0.0; + float UIMax = 1.0; + float UIStep = 0.05; + string UIName = "Specular"; +> = 0.4; + +float SpecExpon : SpecularPower < + string UIWidget = "slider"; + float UIMin = 1.0; + float UIMax = 128.0; + float UIStep = 1.0; + string UIName = "Specular Power"; +> = 55.0; + + +//////// COLOR & TEXTURE ///////////////////// + +/// the ambient material colour +float4 m_Ambient; + +/// the diffuse colour +float4 m_Diffuse; + +/// the specular colour +float4 m_Specular; + +/// the emission colour +float4 m_Emission; + +/// the transparency colour +float4 m_Transparency; + +/// the shininess +float m_Shininess; + +texture ColorTexture < + string ResourceName = "default_color.dds"; + string UIName = "Diffuse Texture"; + string ResourceType = "2D"; +>; + +sampler2D ColorSampler = sampler_state { + Texture = <ColorTexture>; + MinFilter = LinearMipMapLinear; + MagFilter = Linear; + WrapS = Repeat; + WrapT = Repeat; +}; + +texture SpecularTexture < + string ResourceName = "checker.dds"; + string UIName = "Specular Texture"; + string ResourceType = "2D"; +>; + +sampler2D SpecularSampler = sampler_state { + Texture = <SpecularTexture>; + MinFilter = LinearMipMapLinear; + MagFilter = Linear; + WrapS = Repeat; + WrapT = Repeat; +}; + +//////// CONNECTOR DATA STRUCTURES /////////// + +/* data from application vertex buffer */ +struct appdata { + float3 Position : POSITION; + float4 UV : TEXCOORD0; + float4 Normal : NORMAL; + float4 Tangent : TANGENT0; + float4 Binormal : BINORMAL0; +}; + +/* data passed from vertex shader to pixel shader */ +struct vertexOutput { + float4 HPosition : POSITION; + float2 UV : TEXCOORD0; + // The following values are passed in "World" coordinates since + // it tends to be the most flexible and easy for handling + // reflections, sky lighting, and other "global" effects. + float3 LightVec : TEXCOORD1; + float3 WorldNormal : TEXCOORD2; + float3 WorldTangent : TEXCOORD3; + float3 WorldBinormal : TEXCOORD4; + float3 WorldView : TEXCOORD5; +}; + +///////// VERTEX SHADING ///////////////////// + +/*********** Generic Vertex Shader ******/ + +vertexOutput std_VS(appdata IN) { + vertexOutput OUT = (vertexOutput)0; + OUT.WorldNormal = mul(WorldITXf,IN.Normal).xyz; + OUT.WorldTangent = mul(WorldITXf,IN.Tangent).xyz; + OUT.WorldBinormal = mul(WorldITXf,IN.Binormal).xyz; + float4 Po = float4(IN.Position.xyz,1); + float3 Pw = mul(WorldXf,Po).xyz; + OUT.LightVec = (Lamp0Pos - Pw); +#ifdef FLIP_TEXTURE_Y + OUT.UV = float2(IN.UV.x,(1.0-IN.UV.y)); +#else /* !FLIP_TEXTURE_Y */ + OUT.UV = IN.UV.xy; +#endif /* !FLIP_TEXTURE_Y */ + OUT.WorldView = normalize(float3(ViewIXf[0].w,ViewIXf[1].w,ViewIXf[2].w) - Pw); + OUT.HPosition = mul(WvpXf,Po); + return OUT; +} + +///////// PIXEL SHADING ////////////////////// + +// Utility function for phong shading + +void phong_shading(vertexOutput IN, + float3 LightColor, + float3 Nn, + float3 Ln, + float3 Vn, + out float3 DiffuseContrib, + out float3 SpecularContrib) +{ + float3 Hn = normalize(Vn + Ln); + float4 litV = lit(dot(Ln,Nn),dot(Hn,Nn),SpecExpon); + DiffuseContrib = litV.y * LightColor; + SpecularContrib = litV.y * litV.z * Ks * LightColor; +} + +float4 std_PS(vertexOutput IN, + float face : FACE) : COLOR { + float3 diffContrib; + float3 specContrib; + float3 Ln = normalize(IN.LightVec); + float3 Vn = normalize(IN.WorldView); + float3 Nn = face * normalize(IN.WorldNormal); + phong_shading(IN,Lamp0Color,Nn,Ln,Vn,diffContrib,specContrib); + float4 textureColor = tex2D(ColorSampler,IN.UV); + float3 diffuseTerm = textureColor.rgb * (diffContrib+AmbiColor); + float3 specularTerm = m_Specular.rgb * specContrib; + float3 result = specularTerm + diffuseTerm; + float alpha = textureColor.a; + return float4(result, alpha); +} + +float4 No_Texture_PS(vertexOutput IN, + float face : FACE) : COLOR { + float3 diffContrib; + float3 specContrib; + float3 Ln = normalize(IN.LightVec); + float3 Vn = normalize(IN.WorldView); + float3 Nn = face * normalize(IN.WorldNormal); + phong_shading(IN,Lamp0Color,Nn,Ln,Vn,diffContrib,specContrib); + float3 diffuseTerm = m_Diffuse.rgb * (diffContrib+AmbiColor); + float3 specularTerm = m_Specular.rgb * specContrib; + float3 result = specularTerm + diffuseTerm; + float alpha = m_Diffuse.a; + return float4(result, alpha); +} + +float4 Specular_Texture_PS(vertexOutput IN, + float face : FACE) : COLOR { + float3 diffContrib; + float3 specContrib; + float3 Ln = normalize(IN.LightVec); + float3 Vn = normalize(IN.WorldView); + float3 Nn = face * normalize(IN.WorldNormal); + phong_shading(IN,Lamp0Color,Nn,Ln,Vn,diffContrib,specContrib); + + float4 textureColor = tex2D(ColorSampler,IN.UV); + float3 diffuseTerm = textureColor.rgb * (diffContrib+AmbiColor); + + float4 specularTextureColor = tex2D(SpecularSampler, IN.UV); + float specularMask = dot( specularTextureColor.rgb, float3(1,1,1) ) / 3.0f; // average of r,g,b + float3 specularTerm = specularMask * specContrib; + + float3 result = specularTerm + diffuseTerm; + float alpha = textureColor.a; + return float4(result, alpha); +} + +///// TECHNIQUES ///////////////////////////// + +technique Main < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = true; + CullFaceEnable = false; + BlendEnable = false; + DepthFunc = LEqual; + FragmentProgram = compile fp40 std_PS(); + } +} + +technique Main_Blending < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = false; + CullFaceEnable = false; + BlendEnable = true; + BlendFunc = float2(SrcAlpha, OneMinusSrcAlpha); + DepthFunc = LEqual; + FragmentProgram = compile fp40 std_PS(); + } +} + +technique Main_Alphatest < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = true; + CullFaceEnable = false; + AlphaFunc = float2(Greater, 0.1f); + AlphaTestEnable = true; + FragmentProgram = compile fp40 std_PS(); + } +} + +technique No_Texture < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = true; + CullFaceEnable = false; + BlendEnable = false; + DepthFunc = LEqual; + FragmentProgram = compile fp40 No_Texture_PS(); + } +} + +technique No_Texture_Blending < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = false; + CullFaceEnable = false; + BlendEnable = true; + BlendFunc = float2(SrcAlpha, OneMinusSrcAlpha); + DepthFunc = LEqual; + FragmentProgram = compile fp40 No_Texture_PS(); + } +} + +technique Main_Specular < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = true; + CullFaceEnable = false; + BlendEnable = false; + DepthFunc = LEqual; + FragmentProgram = compile fp40 Specular_Texture_PS(); + } +} + +technique Main_Specular_Blending < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = false; + CullFaceEnable = false; + //AlphaFunc = float2(Greater, 0.1f); + //AlphaTestEnable = true; + BlendEnable = true; + BlendFunc = float2(SrcAlpha, OneMinusSrcAlpha); + DepthFunc = LEqual; + FragmentProgram = compile fp40 Specular_Texture_PS(); + } +} +/////////////////////////////////////// eof // diff --git a/data/CgFX/basic-lighting/Phong_bump_reflect.cgfx b/data/CgFX/basic-lighting/Phong_bump_reflect.cgfx new file mode 100644 index 000000000..73f5168fa --- /dev/null +++ b/data/CgFX/basic-lighting/Phong_bump_reflect.cgfx @@ -0,0 +1,241 @@ +/*********************************************************************NVMH3**** +$Revision$ + +Copyright NVIDIA Corporation 2007 +TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED +*AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS +BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES +WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, +BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY +LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF +NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + + +To learn more about shading, shaders, and to bounce ideas off other shader + authors and users, visit the NVIDIA Shader Library Forums at: + + http://developer.nvidia.com/forums/ + +******************************************************************************/ + +// #define FLIP_TEXTURE_Y + +float Script : STANDARDSGLOBAL < + string UIWidget = "none"; + string ScriptClass = "object"; + string ScriptOrder = "standard"; + string ScriptOutput = "color"; + string Script = "Technique=Main;"; +> = 0.8; + +//// UN-TWEAKABLES - AUTOMATICALLY-TRACKED TRANSFORMS //////////////// + +float4x4 WorldITXf : WorldInverseTranspose < string UIWidget="None"; >; +float4x4 WvpXf : WorldViewProjection < string UIWidget="None"; >; +float4x4 WorldXf : World < string UIWidget="None"; >; +float4x4 ViewIXf : ViewInverse < string UIWidget="None"; >; + +//// TWEAKABLE PARAMETERS //////////////////// + +/// Point Lamp 0 //////////// +float3 Lamp0Pos : Position < + string Object = "PointLight0"; + string UIName = "Lamp 0 Position"; + string Space = "World"; +> = {-0.5f,2.0f,1.25f}; +float3 Lamp0Color : Specular < + string UIName = "Lamp 0"; + string Object = "Pointlight0"; + string UIWidget = "Color"; +> = {1.0f,1.0f,1.0f}; + +// Ambient Light +float3 AmbiColor : Ambient < + string UIName = "Ambient Light"; + string UIWidget = "Color"; +> = {0.07f,0.07f,0.07f}; + +float Ks < + string UIWidget = "slider"; + float UIMin = 0.0; + float UIMax = 1.0; + float UIStep = 0.05; + string UIName = "Specular"; +> = 0.4; + +float SpecExpon : SpecularPower < + string UIWidget = "slider"; + float UIMin = 1.0; + float UIMax = 128.0; + float UIStep = 1.0; + string UIName = "Specular Power"; +> = 55.0; + + +float Bump < + string UIWidget = "slider"; + float UIMin = 0.0; + float UIMax = 3.0; + float UIStep = 0.01; + string UIName = "Bumpiness"; +> = 1.0; + +float Kr < + string UIWidget = "slider"; + float UIMin = 0.0; + float UIMax = 1.0; + float UIStep = 0.01; + string UIName = "Reflection Strength"; +> = 0.5; + +//////// COLOR & TEXTURE ///////////////////// + +texture ColorTexture < + string ResourceName = "default_color.dds"; + string UIName = "Diffuse Texture"; + string ResourceType = "2D"; +>; + +sampler2D ColorSampler = sampler_state { + Texture = <ColorTexture>; + MinFilter = LinearMipMapLinear; + MagFilter = Linear; + WrapS = Repeat; + WrapT = Repeat; +}; + +texture NormalTexture < + string ResourceName = "default_bump_normal.dds"; + string UIName = "Normal-Map Texture"; + string ResourceType = "2D"; +>; + +sampler2D NormalSampler = sampler_state { + Texture = <NormalTexture>; + MinFilter = LinearMipMapLinear; + MagFilter = Linear; + WrapS = Repeat; + WrapT = Repeat; +}; + +texture EnvTexture : ENVIRONMENT < + string ResourceName = "default_reflection.dds"; + string UIName = "Environment"; + string ResourceType = "Cube"; +>; + +samplerCUBE EnvSampler = sampler_state { + Texture = <EnvTexture>; + MagFilter = Linear; + MinFilter = LinearMipMapLinear; + WrapS = ClampToEdge; + WrapT = ClampToEdge; + WrapR = ClampToEdge; +}; + +//////// CONNECTOR DATA STRUCTURES /////////// + +/* data from application vertex buffer */ +struct appdata { + float3 Position : POSITION; + float4 UV : TEXCOORD0; + float4 Normal : NORMAL; + float4 Tangent : TANGENT0; + float4 Binormal : BINORMAL0; +}; + +/* data passed from vertex shader to pixel shader */ +struct vertexOutput { + float4 HPosition : POSITION; + float2 UV : TEXCOORD0; + // The following values are passed in "World" coordinates since + // it tends to be the most flexible and easy for handling + // reflections, sky lighting, and other "global" effects. + float3 LightVec : TEXCOORD1; + float3 WorldNormal : TEXCOORD2; + float3 WorldTangent : TEXCOORD3; + float3 WorldBinormal : TEXCOORD4; + float3 WorldView : TEXCOORD5; +}; + +///////// VERTEX SHADING ///////////////////// + +/*********** Generic Vertex Shader ******/ + +vertexOutput std_VS(appdata IN) { + vertexOutput OUT = (vertexOutput)0; + OUT.WorldNormal = mul(WorldITXf,IN.Normal).xyz; + OUT.WorldTangent = mul(WorldITXf,IN.Tangent).xyz; + OUT.WorldBinormal = mul(WorldITXf,IN.Binormal).xyz; + float4 Po = float4(IN.Position.xyz,1); + float3 Pw = mul(WorldXf,Po).xyz; + OUT.LightVec = (Lamp0Pos - Pw); +#ifdef FLIP_TEXTURE_Y + OUT.UV = float2(IN.UV.x,(1.0-IN.UV.y)); +#else /* !FLIP_TEXTURE_Y */ + OUT.UV = IN.UV.xy; +#endif /* !FLIP_TEXTURE_Y */ + OUT.WorldView = normalize(float3(ViewIXf[0].w,ViewIXf[1].w,ViewIXf[2].w) - Pw); + OUT.HPosition = mul(WvpXf,Po); + return OUT; +} + +///////// PIXEL SHADING ////////////////////// + +// Utility function for phong shading + +void phong_shading(vertexOutput IN, + float3 LightColor, + float3 Nn, + float3 Ln, + float3 Vn, + out float3 DiffuseContrib, + out float3 SpecularContrib) +{ + float3 Hn = normalize(Vn + Ln); + float4 litV = lit(dot(Ln,Nn),dot(Hn,Nn),SpecExpon); + DiffuseContrib = litV.y * LightColor; + SpecularContrib = litV.y * litV.z * Ks * LightColor; +} + +float4 std_PS(vertexOutput IN) : COLOR { + float3 diffContrib; + float3 specContrib; + float3 Ln = normalize(IN.LightVec); + float3 Vn = normalize(IN.WorldView); + float3 Nn = normalize(IN.WorldNormal); + float3 Tn = normalize(IN.WorldTangent); + float3 Bn = normalize(IN.WorldBinormal); + float3 bump = Bump * (tex2D(NormalSampler,IN.UV).rgb - float3(0.5,0.5,0.5)); + Nn = Nn + bump.x*Tn + bump.y*Bn; + Nn = normalize(Nn); + phong_shading(IN,Lamp0Color,Nn,Ln,Vn,diffContrib,specContrib); + float3 diffuseColor = tex2D(ColorSampler,IN.UV).rgb; + float3 result = specContrib+(diffuseColor*(diffContrib+AmbiColor)); + float3 R = -reflect(Vn,Nn); + float3 reflColor = Kr * texCUBE(EnvSampler,R.xyz).rgb; + result += diffuseColor*reflColor; + return float4(result,1); +} + +///// TECHNIQUES ///////////////////////////// + +technique Main < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = true; + CullFaceEnable = false; + BlendEnable = false; + DepthFunc = LEqual; + FragmentProgram = compile fp40 std_PS(); + } +} + +/////////////////////////////////////// eof // diff --git a/data/CgFX/basic-lighting/basic-lighting.fxcproj b/data/CgFX/basic-lighting/basic-lighting.fxcproj new file mode 100644 index 000000000..9e9e29d9a --- /dev/null +++ b/data/CgFX/basic-lighting/basic-lighting.fxcproj @@ -0,0 +1,99 @@ +<project> + <current_configuration value="Debug" /> + <configurations> + <configuration name="Debug"> + <settings category="Project\Direct3D\HLSL Compiler"> + <CompilerOptions value="" /> + </settings> + <settings category="Project\Direct3D10\HLSL Compiler"> + <CompilerOptions value="" /> + </settings> + <settings category="Project\OpenGL\CgCompiler"> + <CompilerOptions value="" /> + </settings> + <settings category="Project\Paths"> + <Includes value="" /> + <Models value="" /> + <Scripts value="" /> + <Shaders value="" /> + <Textures value="" /> + </settings> + <settings category="Project\Settings"> + <BindLightToUnboundMaterials value="False" /> + </settings> + <settings category="Project\COLLADA Common Profile"> + <EnvironmentMap value="" /> + <DisableCommonProfileTransparency value="False" /> + </settings> + </configuration> + <configuration name="Release"> + <settings category="Project\Direct3D\HLSL Compiler"> + <CompilerOptions value="" /> + </settings> + <settings category="Project\Direct3D10\HLSL Compiler"> + <CompilerOptions value="" /> + </settings> + <settings category="Project\OpenGL\CgCompiler"> + <CompilerOptions value="" /> + </settings> + <settings category="Project\Paths"> + <Includes value="" /> + <Models value="" /> + <Scripts value="" /> + <Shaders value="" /> + <Textures value="" /> + </settings> + <settings category="Project\Settings"> + <BindLightToUnboundMaterials value="False" /> + </settings> + <settings category="Project\COLLADA Common Profile"> + <EnvironmentMap value="" /> + <DisableCommonProfileTransparency value="False" /> + </settings> + </configuration> + </configurations> + <assetFile uri="Document1.dae" referenced="False" /> + <activeAssetCollection uri="Document1.dae" /> + <customConfigurations> + <FXComposer.Scene.Services.FXRenderPortService> + <defaultScene sceneUri="Document1.dae#DefaultScene" /> + <camera type="Top" scene="Document1.dae#DefaultScene"> + <focallength>2.120135</focallength> + <fov>40</fov> + <zoomrect>0 0 1 1</zoomrect> + <viewtransform>1 0 0 0 0 5.960463E-08 -0.9999998 0 0 0.9999998 5.960463E-08 0 0 2.120135 0 1 </viewtransform> + </camera> + <camera type="Front" scene="Document1.dae#DefaultScene"> + <focallength>2.120135</focallength> + <fov>40</fov> + <zoomrect>0 0 1 1</zoomrect> + <viewtransform>1 0 0 0 0 1 0 0 0 0 1 0 0 0 2.120135 1 </viewtransform> + </camera> + <camera type="Right" scene="Document1.dae#DefaultScene"> + <focallength>2.120135</focallength> + <fov>40</fov> + <zoomrect>0 0 1 1</zoomrect> + <viewtransform>5.960463E-08 0 -0.9999998 0 0 1 0 0 0.9999998 0 5.960463E-08 0 2.120135 0 0 1 </viewtransform> + </camera> + <camera type="Perspective" scene="Document1.dae#DefaultScene"> + <focallength>5.105366</focallength> + <fov>40</fov> + <zoomrect>0 0 1 1</zoomrect> + <viewtransform>-0.005650305 -2.098426E-07 0.9999841 0 0.5493351 0.8355966 0.00310409 0 -0.8355833 0.5493439 -0.004721277 0 -4.26595 2.804603 -0.02410657 1 </viewtransform> + </camera> + <renderPort name="Render" /> + </FXComposer.Scene.Services.FXRenderPortService> + <FXComposer.Scene.Services.FXSceneService> + <grid_settings sceneUri="Document1.dae#DefaultScene"> + <show_grid value="True" /> + <axes_color value="0, 0, 0, 1" /> + <size value="17.32051" /> + <major_ticks_color value="0.25, 0.25, 0.25, 1" /> + <major_tick_every_nth value="10" /> + <ticks_color value="0.425, 0.425, 0.425, 1" /> + <ticks_interval_in_units value="0.3464102" /> + </grid_settings> + <background_color color="0.5 0.5 0.5 0" /> + </FXComposer.Scene.Services.FXSceneService> + </customConfigurations> +</project> \ No newline at end of file diff --git a/data/CgFX/basic-lighting/simple.cgfx b/data/CgFX/basic-lighting/simple.cgfx new file mode 100644 index 000000000..4ef9f90f5 --- /dev/null +++ b/data/CgFX/basic-lighting/simple.cgfx @@ -0,0 +1,54 @@ +float4 main(float4 uv : TEXCOORD3) : COLOR +{ + return float4(1,0,0,1); +} + +technique Main { + pass { + VertexProgram = NULL; + FragmentProgram = compile arbfp1 main(); + } +} + +technique Main_Blending { + pass { + VertexProgram = NULL; + FragmentProgram = compile arbfp1 main(); + } +} + +technique Main_Alphatest { + pass { + VertexProgram = NULL; + FragmentProgram = compile arbfp1 main(); + } +} + +technique No_Texture { + pass { + VertexProgram = NULL; + FragmentProgram = compile arbfp1 main(); + } +} + +technique No_Texture_Blending { + pass { + VertexProgram = NULL; + FragmentProgram = compile arbfp1 main(); + } +} + +technique Main_Specular { + pass { + VertexProgram = NULL; + FragmentProgram = compile arbfp1 main(); + } +} + +technique Main_Specular_Blending { + pass { + VertexProgram = NULL; + FragmentProgram = compile arbfp1 main(); + } +} + diff --git a/data/DassakV1.0.mb b/data/DassakV1.0.mb new file mode 100644 index 000000000..607ae1814 Binary files /dev/null and b/data/DassakV1.0.mb differ diff --git a/data/GoblinV1.0.mb b/data/GoblinV1.0.mb new file mode 100644 index 000000000..76f24e6b9 Binary files /dev/null and b/data/GoblinV1.0.mb differ diff --git a/data/anim.camera b/data/anim.camera new file mode 100644 index 000000000..197b98e5a --- /dev/null +++ b/data/anim.camera @@ -0,0 +1,10 @@ +zoom= 1008.199890 +rotx= 15.500000 +roty= 43.500000 +tx= 0.000000 +ty= -70.000000 +lastx= 0.000000 +lasty= 0.000000 +zoomStep= 0.100000 +panStep= 0.050000 +ROTATION= 0.000000 \ No newline at end of file diff --git a/data/anim.conf b/data/anim.conf new file mode 100644 index 000000000..76c2ce921 --- /dev/null +++ b/data/anim.conf @@ -0,0 +1,3 @@ +camera anim.camera +model anim.mb +anim anim.mb diff --git a/data/anim.mb b/data/anim.mb new file mode 100644 index 000000000..7cfd1ea7e Binary files /dev/null and b/data/anim.mb differ diff --git a/data/boy3.conf b/data/boy3.conf new file mode 100644 index 000000000..d80925e3a --- /dev/null +++ b/data/boy3.conf @@ -0,0 +1,2 @@ +camera middle.camera +model boy3.mb diff --git a/data/boy3.mb b/data/boy3.mb new file mode 100644 index 000000000..e15bc24ab Binary files /dev/null and b/data/boy3.mb differ diff --git a/data/character.camera b/data/character.camera new file mode 100644 index 000000000..27f3ed77e --- /dev/null +++ b/data/character.camera @@ -0,0 +1,10 @@ +zoom= 34.300049 +rotx= 15.500000 +roty= 43.500000 +tx= -0.700000 +ty= -0.549990 +lastx= 800.000000 +lasty= 1054.000000 +zoomStep= 0.100000 +panStep= 0.050000 +ROTATION= 0.000000 \ No newline at end of file diff --git a/data/character.conf b/data/character.conf new file mode 100644 index 000000000..16667d360 --- /dev/null +++ b/data/character.conf @@ -0,0 +1,2 @@ +camera character.camera +model character_jump_70.mb diff --git a/data/character_jump_70.mb b/data/character_jump_70.mb new file mode 100644 index 000000000..27c0da720 Binary files /dev/null and b/data/character_jump_70.mb differ diff --git a/data/generi_rig.mb b/data/generi_rig.mb new file mode 100644 index 000000000..81a03d7db Binary files /dev/null and b/data/generi_rig.mb differ diff --git a/data/generi_rig_v1.1/generi_rig.mb b/data/generi_rig_v1.1/generi_rig.mb new file mode 100644 index 000000000..1588b8895 Binary files /dev/null and b/data/generi_rig_v1.1/generi_rig.mb differ diff --git a/data/middle.camera b/data/middle.camera new file mode 100644 index 000000000..1f82269e8 --- /dev/null +++ b/data/middle.camera @@ -0,0 +1,10 @@ +zoom= 178.650024 +rotx= 5.000000 +roty= 38.500000 +tx= 0.600000 +ty= -6.250000 +lastx= 0.000000 +lasty= 0.000000 +zoomStep= 0.050000 +panStep= 0.050000 +ROTATION= 0.000000 diff --git a/data/middle.conf b/data/middle.conf new file mode 100644 index 000000000..6ad1e4f2a --- /dev/null +++ b/data/middle.conf @@ -0,0 +1,5 @@ +camera middle.camera +model boy3.mb +model generi_rig.mb +model character_jump_70.mb + diff --git a/data/multi-materials.conf b/data/multi-materials.conf new file mode 100644 index 000000000..8043a1f81 --- /dev/null +++ b/data/multi-materials.conf @@ -0,0 +1,2 @@ +camera simple-all.camera +model multi-materials.mb diff --git a/data/multi-materials.mb b/data/multi-materials.mb new file mode 100644 index 000000000..99e22024b Binary files /dev/null and b/data/multi-materials.mb differ diff --git a/data/simple-all.camera b/data/simple-all.camera new file mode 100644 index 000000000..3be038830 --- /dev/null +++ b/data/simple-all.camera @@ -0,0 +1,11 @@ +zoom= 315.750214 +rotx= 19.500000 +roty= -30.000000 +tx= -0.199997 +ty= -2.899998 +lastx= 0.000000 +lasty= 0.000000 +zoomStep= 0.050000 +panStep= 0.050000 +ROTATION= 0.000000 + \ No newline at end of file diff --git a/data/simple-all.conf b/data/simple-all.conf new file mode 100644 index 000000000..3a8ebf15a --- /dev/null +++ b/data/simple-all.conf @@ -0,0 +1,4 @@ +camera simple-all.camera +model simple-blendshapes.mb +model simplest.mb +model multi-materials.mb diff --git a/data/simple-anims.camera b/data/simple-anims.camera new file mode 100644 index 000000000..43dbeb968 --- /dev/null +++ b/data/simple-anims.camera @@ -0,0 +1,10 @@ +zoom= 192.249969 +rotx= 21.500000 +roty= -51.000000 +tx= 0.050000 +ty= -0.800000 +lastx= 0.000000 +lasty= 0.000000 +zoomStep= 0.050000 +panStep= 0.050000 +ROTATION= 0.000000 \ No newline at end of file diff --git a/data/simple-anims.conf b/data/simple-anims.conf new file mode 100644 index 000000000..90c6cf4bb --- /dev/null +++ b/data/simple-anims.conf @@ -0,0 +1,4 @@ +camera simple-anims.camera +model simple-anims/simple-model.mb +anim simple-anims/simple-anim1.mb +anim simple-anims/simple-anim2.mb diff --git a/data/simple-anims/simple-anim1.anim b/data/simple-anims/simple-anim1.anim new file mode 100644 index 000000000..62566a2f2 --- /dev/null +++ b/data/simple-anims/simple-anim1.anim @@ -0,0 +1,70 @@ +ANIMATION simple-anim1.mb + StartTime 0.0166667 + EndTime 0.5 + NumFrames 30 + NumBlendShapes 0 + JOINTANIM + NumJointAnims 1 + joint2 2077434157 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.08393 +0.00117 +0.01389 +0.99637 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.17598 +0.00245 +0.01372 +0.98429 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.27271 +0.00380 +0.01341 +0.96199 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.37049 +0.00516 +0.01294 +0.92873 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.46574 +0.00649 +0.01233 +0.88481 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.55520 +0.00774 +0.01159 +0.83160 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.63616 +0.00887 +0.01075 +0.77143 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.70668 +0.00985 +0.00986 +0.70739 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.76564 +0.01067 +0.00896 +0.64312 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.81273 +0.01133 +0.00812 +0.58248 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.84828 +0.01182 +0.00738 +0.52937 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.87302 +0.01217 +0.00679 +0.48748 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.88769 +0.01237 +0.00641 +0.46022 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.89264 +0.01244 +0.00628 +0.45056 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.88833 +0.01238 +0.00640 +0.45900 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.87555 +0.01220 +0.00673 +0.48293 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.85407 +0.01190 +0.00725 +0.51998 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.82331 +0.01147 +0.00791 +0.56742 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.78265 +0.01091 +0.00867 +0.62231 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.73169 +0.01020 +0.00950 +0.68150 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.67046 +0.00934 +0.01034 +0.74181 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.59958 +0.00836 +0.01115 +0.80019 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.52030 +0.00725 +0.01190 +0.85387 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.43449 +0.00606 +0.01255 +0.90057 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.34452 +0.00480 +0.01308 +0.93867 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.25317 +0.00353 +0.01348 +0.96732 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.16336 +0.00228 +0.01375 +0.98647 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.07805 +0.00109 +0.01389 +0.99685 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + diff --git a/data/simple-anims/simple-anim1.mb b/data/simple-anims/simple-anim1.mb new file mode 100644 index 000000000..01f79e5d2 Binary files /dev/null and b/data/simple-anims/simple-anim1.mb differ diff --git a/data/simple-anims/simple-anim2.anim b/data/simple-anims/simple-anim2.anim new file mode 100644 index 000000000..137247a0b --- /dev/null +++ b/data/simple-anims/simple-anim2.anim @@ -0,0 +1,70 @@ +ANIMATION simple-anim2.mb + StartTime 0.0166667 + EndTime 0.5 + NumFrames 30 + NumBlendShapes 0 + JOINTANIM + NumJointAnims 1 + joint2 2077434157 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.62641 -0.73069 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.63762 -1.53830 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.64962 -2.40184 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.66210 -3.30035 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.67477 -4.21284 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.68735 -5.11833 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.69953 -5.99586 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.71104 -6.82445 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.72158 -7.58311 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.73085 -8.25087 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.73857 -8.80675 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.74445 -9.22978 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.74819 -9.49898 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.74950 -9.59338 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.74835 -9.51095 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.74508 -9.27502 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.73991 -8.90266 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.73308 -8.41091 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.72483 -7.81683 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.71539 -7.13748 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.70501 -6.38990 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.69391 -5.59116 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.68235 -4.75832 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.67054 -3.90841 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.65874 -3.05851 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.64717 -2.22566 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.63608 -1.42693 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.62569 -0.67935 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + diff --git a/data/simple-anims/simple-anim2.mb b/data/simple-anims/simple-anim2.mb new file mode 100644 index 000000000..79b3cd11f Binary files /dev/null and b/data/simple-anims/simple-anim2.mb differ diff --git a/data/simple-anims/simple-model.mb b/data/simple-anims/simple-model.mb new file mode 100644 index 000000000..e1c0b6cb9 Binary files /dev/null and b/data/simple-anims/simple-model.mb differ diff --git a/data/simple-anims/simple-model.model b/data/simple-anims/simple-model.model new file mode 100644 index 000000000..0ab080263 --- /dev/null +++ b/data/simple-anims/simple-model.model @@ -0,0 +1,304 @@ +TEXTURES +NumTextures= 0 +METERIALS +NumMaterials= 1 + MaterialType= 0 + LAMBERT lambert1 + materialID= 1 + ambient 0.00000 0.00000 0.00000 tex= 0 + diffuse 0.50000 0.50000 0.50000 tex= 0 + incandescence 0.00000 0.00000 0.00000 tex= 0 + transparency 0.00000 0.00000 0.00000 tex= 0 + normalmap tex= 0 +MESHES +NumMeshes= 3 + MESH pCubeShape1 + meshID= 1 + ParentHash= 0 + NumBlendshapeWeights 0 + IsSkinned 1 + SKIN skinCluster1 + NumInfluences 3 + 3805966487 2077434157 215224763 + Stride 16 + // Vertices format: Position.xyz | Normal.xyz | UV | JointIndices.0123 | JointWeights.0123 + NumVerts 48 + -1.77500 -6.64200 +1.33200 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 +0.00000 +0.00000 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 +0.00000 + +1.77500 -6.64200 +1.33200 +0.00000 +0.00000 +1.00000 +1.00000 +0.00000 +0.00000 +0.00000 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 +0.00000 + +1.77500 -3.32100 +1.33200 +0.00000 +0.00000 +1.00000 +1.00000 +0.25000 +0.00000 +1.00000 +0.00000 +0.00000 +0.99747 +0.00253 +0.00000 +0.00000 + -1.77500 -3.32100 +1.33200 +0.00000 +0.00000 +1.00000 +0.00000 +0.25000 +0.00000 +1.00000 +0.00000 +0.00000 +0.99745 +0.00255 +0.00000 +0.00000 + +1.77500 -0.00000 +1.33200 +0.00000 +0.00000 +1.00000 +1.00000 +0.50000 +0.00000 +1.00000 +0.00000 +0.00000 +0.50013 +0.49987 +0.00000 +0.00000 + -1.77500 -0.00000 +1.33200 +0.00000 +0.00000 +1.00000 +0.00000 +0.50000 +0.00000 +1.00000 +0.00000 +0.00000 +0.50124 +0.49876 +0.00000 +0.00000 + +1.77500 +3.32100 +1.33200 +0.00000 +0.00000 +1.00000 +1.00000 +0.75000 +1.00000 +0.00000 +2.00000 +0.00000 +0.99432 +0.00305 +0.00264 +0.00000 + -1.77500 +3.32100 +1.33200 +0.00000 +0.00000 +1.00000 +0.00000 +0.75000 +1.00000 +2.00000 +0.00000 +0.00000 +0.99364 +0.00328 +0.00308 +0.00000 + +1.77500 +6.64200 +1.33200 +0.00000 +0.00000 +1.00000 +1.00000 +1.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.50000 +0.50000 +0.00000 +0.00000 + -1.77500 +6.64200 +1.33200 +0.00000 +0.00000 +1.00000 +0.00000 +1.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.50000 +0.50000 +0.00000 +0.00000 + -1.77500 +6.64200 +1.33200 +0.00000 +1.00000 +0.00000 +0.00000 +1.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.50000 +0.50000 +0.00000 +0.00000 + +1.77500 +6.64200 +1.33200 +0.00000 +1.00000 +0.00000 +1.00000 +1.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.50000 +0.50000 +0.00000 +0.00000 + +1.77500 +6.64200 -1.33200 +0.00000 +1.00000 +0.00000 +1.00000 +2.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.50000 +0.50000 +0.00000 +0.00000 + -1.77500 +6.64200 -1.33200 +0.00000 +1.00000 +0.00000 +0.00000 +2.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.50000 +0.50000 +0.00000 +0.00000 + -1.77500 +6.64200 -1.33200 +0.00000 +0.00000 -1.00000 +0.00000 +2.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.50000 +0.50000 +0.00000 +0.00000 + +1.77500 +6.64200 -1.33200 +0.00000 +0.00000 -1.00000 +1.00000 +2.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.50000 +0.50000 +0.00000 +0.00000 + +1.77500 +3.32100 -1.33200 +0.00000 +0.00000 -1.00000 +1.00000 +2.25000 +1.00000 +0.00000 +2.00000 +0.00000 +0.99432 +0.00305 +0.00264 +0.00000 + -1.77500 +3.32100 -1.33200 +0.00000 +0.00000 -1.00000 +0.00000 +2.25000 +1.00000 +2.00000 +0.00000 +0.00000 +0.99364 +0.00328 +0.00308 +0.00000 + +1.77500 -0.00000 -1.33200 +0.00000 +0.00000 -1.00000 +1.00000 +2.50000 +0.00000 +1.00000 +0.00000 +0.00000 +0.50013 +0.49987 +0.00000 +0.00000 + -1.77500 -0.00000 -1.33200 +0.00000 +0.00000 -1.00000 +0.00000 +2.50000 +0.00000 +1.00000 +0.00000 +0.00000 +0.50124 +0.49876 +0.00000 +0.00000 + +1.77500 -3.32100 -1.33200 +0.00000 +0.00000 -1.00000 +1.00000 +2.75000 +0.00000 +1.00000 +0.00000 +0.00000 +0.99747 +0.00253 +0.00000 +0.00000 + -1.77500 -3.32100 -1.33200 +0.00000 +0.00000 -1.00000 +0.00000 +2.75000 +0.00000 +1.00000 +0.00000 +0.00000 +0.99745 +0.00255 +0.00000 +0.00000 + +1.77500 -6.64200 -1.33200 +0.00000 +0.00000 -1.00000 +1.00000 +3.00000 +0.00000 +0.00000 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 +0.00000 + -1.77500 -6.64200 -1.33200 +0.00000 +0.00000 -1.00000 +0.00000 +3.00000 +0.00000 +0.00000 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 +0.00000 + -1.77500 -6.64200 -1.33200 +0.00000 -1.00000 +0.00000 +0.00000 +3.00000 +0.00000 +0.00000 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 +0.00000 + +1.77500 -6.64200 -1.33200 +0.00000 -1.00000 +0.00000 +1.00000 +3.00000 +0.00000 +0.00000 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 +0.00000 + +1.77500 -6.64200 +1.33200 +0.00000 -1.00000 +0.00000 +1.00000 +4.00000 +0.00000 +0.00000 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 +0.00000 + -1.77500 -6.64200 +1.33200 +0.00000 -1.00000 +0.00000 +0.00000 +4.00000 +0.00000 +0.00000 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 +0.00000 + +1.77500 -6.64200 +1.33200 +1.00000 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 +0.00000 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 +0.00000 + +1.77500 -6.64200 -1.33200 +1.00000 +0.00000 +0.00000 +2.00000 +0.00000 +0.00000 +0.00000 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 +0.00000 + +1.77500 -3.32100 -1.33200 +1.00000 +0.00000 +0.00000 +2.00000 +0.25000 +0.00000 +1.00000 +0.00000 +0.00000 +0.99747 +0.00253 +0.00000 +0.00000 + +1.77500 -3.32100 +1.33200 +1.00000 +0.00000 +0.00000 +1.00000 +0.25000 +0.00000 +1.00000 +0.00000 +0.00000 +0.99747 +0.00253 +0.00000 +0.00000 + +1.77500 -0.00000 -1.33200 +1.00000 +0.00000 +0.00000 +2.00000 +0.50000 +0.00000 +1.00000 +0.00000 +0.00000 +0.50013 +0.49987 +0.00000 +0.00000 + +1.77500 -0.00000 +1.33200 +1.00000 +0.00000 +0.00000 +1.00000 +0.50000 +0.00000 +1.00000 +0.00000 +0.00000 +0.50013 +0.49987 +0.00000 +0.00000 + +1.77500 +3.32100 -1.33200 +1.00000 +0.00000 +0.00000 +2.00000 +0.75000 +1.00000 +0.00000 +2.00000 +0.00000 +0.99432 +0.00305 +0.00264 +0.00000 + +1.77500 +3.32100 +1.33200 +1.00000 +0.00000 +0.00000 +1.00000 +0.75000 +1.00000 +0.00000 +2.00000 +0.00000 +0.99432 +0.00305 +0.00264 +0.00000 + +1.77500 +6.64200 -1.33200 +1.00000 +0.00000 +0.00000 +2.00000 +1.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.50000 +0.50000 +0.00000 +0.00000 + +1.77500 +6.64200 +1.33200 +1.00000 +0.00000 +0.00000 +1.00000 +1.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.50000 +0.50000 +0.00000 +0.00000 + -1.77500 -6.64200 -1.33200 -1.00000 +0.00000 +0.00000 -1.00000 +0.00000 +0.00000 +0.00000 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 +0.00000 + -1.77500 -6.64200 +1.33200 -1.00000 +0.00000 +0.00000 +0.00000 +0.00000 +0.00000 +0.00000 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 +0.00000 + -1.77500 -3.32100 +1.33200 -1.00000 +0.00000 +0.00000 +0.00000 +0.25000 +0.00000 +1.00000 +0.00000 +0.00000 +0.99745 +0.00255 +0.00000 +0.00000 + -1.77500 -3.32100 -1.33200 -1.00000 +0.00000 +0.00000 -1.00000 +0.25000 +0.00000 +1.00000 +0.00000 +0.00000 +0.99745 +0.00255 +0.00000 +0.00000 + -1.77500 -0.00000 +1.33200 -1.00000 +0.00000 +0.00000 +0.00000 +0.50000 +0.00000 +1.00000 +0.00000 +0.00000 +0.50124 +0.49876 +0.00000 +0.00000 + -1.77500 -0.00000 -1.33200 -1.00000 +0.00000 +0.00000 -1.00000 +0.50000 +0.00000 +1.00000 +0.00000 +0.00000 +0.50124 +0.49876 +0.00000 +0.00000 + -1.77500 +3.32100 +1.33200 -1.00000 +0.00000 +0.00000 +0.00000 +0.75000 +1.00000 +2.00000 +0.00000 +0.00000 +0.99364 +0.00328 +0.00308 +0.00000 + -1.77500 +3.32100 -1.33200 -1.00000 +0.00000 +0.00000 -1.00000 +0.75000 +1.00000 +2.00000 +0.00000 +0.00000 +0.99364 +0.00328 +0.00308 +0.00000 + -1.77500 +6.64200 +1.33200 -1.00000 +0.00000 +0.00000 +0.00000 +1.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.50000 +0.50000 +0.00000 +0.00000 + -1.77500 +6.64200 -1.33200 -1.00000 +0.00000 +0.00000 -1.00000 +1.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.50000 +0.50000 +0.00000 +0.00000 + // + // Material Groups: + MaterialCount= 1 + MaterialID= 1 + // Triangles: + TriCount 36 + 0 1 2 + 0 2 3 + 3 2 4 + 3 4 5 + 5 4 6 + 5 6 7 + 7 6 8 + 7 8 9 + 10 11 12 + 10 12 13 + 14 15 16 + 14 16 17 + 17 16 18 + 17 18 19 + 19 18 20 + 19 20 21 + 21 20 22 + 21 22 23 + 24 25 26 + 24 26 27 + 28 29 30 + 28 30 31 + 31 30 32 + 31 32 33 + 33 32 34 + 33 34 35 + 35 34 36 + 35 36 37 + 38 39 40 + 38 40 41 + 41 40 42 + 41 42 43 + 43 42 44 + 43 44 45 + 45 44 46 + 45 46 47 + MESH pCubeShape3 + meshID= 2 + ParentHash= 3936665616 + NumBlendshapeWeights 0 + IsSkinned 0 + Stride 8 + // Vertices format: Position.xyz | Normal.xyz | UV + NumVerts 24 + -3.03392 +9.21412 +3.03392 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 + +3.03392 +9.21412 +3.03392 +0.00000 +0.00000 +1.00000 +1.00000 +0.00000 + +3.03392 +15.28197 +3.03392 +0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + -3.03392 +15.28197 +3.03392 +0.00000 +0.00000 +1.00000 +0.00000 +1.00000 + -3.03392 +15.28197 +3.03392 +0.00000 +1.00000 +0.00000 +0.00000 +1.00000 + +3.03392 +15.28197 +3.03392 +0.00000 +1.00000 +0.00000 +1.00000 +1.00000 + +3.03392 +15.28197 -3.03392 +0.00000 +1.00000 +0.00000 +1.00000 +2.00000 + -3.03392 +15.28197 -3.03392 +0.00000 +1.00000 +0.00000 +0.00000 +2.00000 + -3.03392 +15.28197 -3.03392 +0.00000 +0.00000 -1.00000 +0.00000 +2.00000 + +3.03392 +15.28197 -3.03392 +0.00000 +0.00000 -1.00000 +1.00000 +2.00000 + +3.03392 +9.21412 -3.03392 +0.00000 +0.00000 -1.00000 +1.00000 +3.00000 + -3.03392 +9.21412 -3.03392 +0.00000 +0.00000 -1.00000 +0.00000 +3.00000 + -3.03392 +9.21412 -3.03392 +0.00000 -1.00000 +0.00000 +0.00000 +3.00000 + +3.03392 +9.21412 -3.03392 +0.00000 -1.00000 +0.00000 +1.00000 +3.00000 + +3.03392 +9.21412 +3.03392 +0.00000 -1.00000 +0.00000 +1.00000 +4.00000 + -3.03392 +9.21412 +3.03392 +0.00000 -1.00000 +0.00000 +0.00000 +4.00000 + +3.03392 +9.21412 +3.03392 +1.00000 +0.00000 +0.00000 +1.00000 +0.00000 + +3.03392 +9.21412 -3.03392 +1.00000 +0.00000 +0.00000 +2.00000 +0.00000 + +3.03392 +15.28197 -3.03392 +1.00000 +0.00000 +0.00000 +2.00000 +1.00000 + +3.03392 +15.28197 +3.03392 +1.00000 +0.00000 +0.00000 +1.00000 +1.00000 + -3.03392 +9.21412 -3.03392 -1.00000 +0.00000 +0.00000 -1.00000 +0.00000 + -3.03392 +9.21412 +3.03392 -1.00000 +0.00000 +0.00000 +0.00000 +0.00000 + -3.03392 +15.28197 +3.03392 -1.00000 +0.00000 +0.00000 +0.00000 +1.00000 + -3.03392 +15.28197 -3.03392 -1.00000 +0.00000 +0.00000 -1.00000 +1.00000 + // + // Material Groups: + MaterialCount= 1 + MaterialID= 1 + // Triangles: + TriCount 12 + 0 1 2 + 0 2 3 + 4 5 6 + 4 6 7 + 8 9 10 + 8 10 11 + 12 13 14 + 12 14 15 + 16 17 18 + 16 18 19 + 20 21 22 + 20 22 23 + MESH pCubeShape2 + meshID= 3 + ParentHash= 0 + NumBlendshapeWeights 0 + IsSkinned 0 + Stride 8 + // Vertices format: Position.xyz | Normal.xyz | UV + NumVerts 24 + -0.50000 -0.50000 +0.50000 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 + +0.50000 -0.50000 +0.50000 +0.00000 +0.00000 +1.00000 +1.00000 +0.00000 + +0.50000 +0.50000 +0.50000 +0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + -0.50000 +0.50000 +0.50000 +0.00000 +0.00000 +1.00000 +0.00000 +1.00000 + -0.50000 +0.50000 +0.50000 +0.00000 +1.00000 +0.00000 +0.00000 +1.00000 + +0.50000 +0.50000 +0.50000 +0.00000 +1.00000 +0.00000 +1.00000 +1.00000 + +0.50000 +0.50000 -0.50000 +0.00000 +1.00000 +0.00000 +1.00000 +2.00000 + -0.50000 +0.50000 -0.50000 +0.00000 +1.00000 +0.00000 +0.00000 +2.00000 + -0.50000 +0.50000 -0.50000 +0.00000 +0.00000 -1.00000 +0.00000 +2.00000 + +0.50000 +0.50000 -0.50000 +0.00000 +0.00000 -1.00000 +1.00000 +2.00000 + +0.50000 -0.50000 -0.50000 +0.00000 +0.00000 -1.00000 +1.00000 +3.00000 + -0.50000 -0.50000 -0.50000 +0.00000 +0.00000 -1.00000 +0.00000 +3.00000 + -0.50000 -0.50000 -0.50000 +0.00000 -1.00000 +0.00000 +0.00000 +3.00000 + +0.50000 -0.50000 -0.50000 +0.00000 -1.00000 +0.00000 +1.00000 +3.00000 + +0.50000 -0.50000 +0.50000 +0.00000 -1.00000 +0.00000 +1.00000 +4.00000 + -0.50000 -0.50000 +0.50000 +0.00000 -1.00000 +0.00000 +0.00000 +4.00000 + +0.50000 -0.50000 +0.50000 +1.00000 +0.00000 +0.00000 +1.00000 +0.00000 + +0.50000 -0.50000 -0.50000 +1.00000 +0.00000 +0.00000 +2.00000 +0.00000 + +0.50000 +0.50000 -0.50000 +1.00000 +0.00000 +0.00000 +2.00000 +1.00000 + +0.50000 +0.50000 +0.50000 +1.00000 +0.00000 +0.00000 +1.00000 +1.00000 + -0.50000 -0.50000 -0.50000 -1.00000 +0.00000 +0.00000 -1.00000 +0.00000 + -0.50000 -0.50000 +0.50000 -1.00000 +0.00000 +0.00000 +0.00000 +0.00000 + -0.50000 +0.50000 +0.50000 -1.00000 +0.00000 +0.00000 +0.00000 +1.00000 + -0.50000 +0.50000 -0.50000 -1.00000 +0.00000 +0.00000 -1.00000 +1.00000 + // + // Material Groups: + MaterialCount= 1 + MaterialID= 1 + // Triangles: + TriCount 12 + 0 1 2 + 0 2 3 + 4 5 6 + 4 6 7 + 8 9 10 + 8 10 11 + 12 13 14 + 12 14 15 + 16 17 18 + 16 18 19 + 20 21 22 + 20 22 23 +SKELETON +numJoints 4 + JOINT joint1 + nameHash 3805966487 + parentIndex -1 + Transformation 1 +0.00000 +0.00000 +0.70218 +0.71200 -0.02297 -6.56968 +0.00000 +1.00000 +1.00000 +1.00000 + JOINT joint2 + nameHash 2077434157 + parentIndex 0 + Transformation 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + JOINT joint3 + nameHash 215224763 + parentIndex 1 + Transformation 1 +0.70215 +0.71203 +0.00000 +0.00000 +6.57032 +0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + JOINT pCube3 + nameHash 3936665616 + parentIndex 2 + Transformation 1 -0.01398 +0.99990 +0.00000 +0.00000 +0.16205 -6.61368 -0.00000 +1.00000 +1.00000 +1.00000 + +ANIMATION simple-model.mb + StartTime 0.0166667 + EndTime 0.5 + NumFrames 30 + NumBlendShapes 0 + JOINTANIM + NumJointAnims 1 + joint2 2077434157 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.12194 +0.99254 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.28170 +0.95950 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.44371 +0.89617 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.58792 +0.80892 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.70009 +0.71406 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.77363 +0.63363 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.80715 +0.59035 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.79772 +0.60303 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.72988 +0.68357 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.58993 +0.80745 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.37624 +0.92652 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.10599 +0.99437 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.18288 +0.98313 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.44469 +0.89569 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.64482 +0.76434 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.77076 +0.63713 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.82760 +0.56132 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.84122 +0.54069 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.83486 +0.55046 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.81053 +0.58570 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.76834 +0.64005 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.70798 +0.70623 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.62992 +0.77666 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.53615 +0.84412 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.43054 +0.90257 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.31865 +0.94787 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.20721 +0.97830 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.10335 +0.99464 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + diff --git a/data/simple-blendshapes.mb b/data/simple-blendshapes.mb new file mode 100644 index 000000000..956aee567 Binary files /dev/null and b/data/simple-blendshapes.mb differ diff --git a/data/simplest-180.mb b/data/simplest-180.mb new file mode 100644 index 000000000..c463ddfca Binary files /dev/null and b/data/simplest-180.mb differ diff --git a/data/simplest-tex.bmp b/data/simplest-tex.bmp new file mode 100644 index 000000000..f326a4165 Binary files /dev/null and b/data/simplest-tex.bmp differ diff --git a/data/simplest-tex.dds b/data/simplest-tex.dds new file mode 100644 index 000000000..30919e680 Binary files /dev/null and b/data/simplest-tex.dds differ diff --git a/data/simplest-tex.mb b/data/simplest-tex.mb new file mode 100644 index 000000000..9a12c59ca Binary files /dev/null and b/data/simplest-tex.mb differ diff --git a/data/simplest.conf b/data/simplest.conf new file mode 100644 index 000000000..0ff47f428 --- /dev/null +++ b/data/simplest.conf @@ -0,0 +1,2 @@ +camera simple-all.camera +model simplest.mb diff --git a/data/simplest.mb b/data/simplest.mb new file mode 100644 index 000000000..bbb335e68 Binary files /dev/null and b/data/simplest.mb differ diff --git a/data/simplest.model b/data/simplest.model new file mode 100644 index 000000000..27de7535f --- /dev/null +++ b/data/simplest.model @@ -0,0 +1,308 @@ +TEXTURES +NumTextures= 0 +METERIALS +NumMaterials= 1 + MaterialType= 0 + LAMBERT lambert1 + materialID= 1 + ambient 0.00000 0.00000 0.00000 tex= 0 + diffuse 0.50000 0.50000 0.50000 tex= 0 + incandescence 0.00000 0.00000 0.00000 tex= 0 + transparency 0.00000 0.00000 0.00000 tex= 0 + normalmap tex= 0 +MESHES +NumMeshes= 3 + MESH pCubeShape1 + meshID= 1 + ParentHash= 0 + NumBlendshapeWeights 0 + IsSkinned 1 + SKIN skinCluster1 + NumInfluences 3 + 3805966487 2077434157 215224763 + Stride 16 + // Vertices format: Position.xyz | Normal.xyz | UV | JointIndices.0123 | JointWeights.0123 + NumVerts 48 + -1.77500 -9.21352 +1.33200 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 +0.00000 +1.00000 +2.00000 +0.00000 +0.98127 +0.01663 +0.00211 +0.00000 + +1.77500 -9.21352 +1.33200 +0.00000 +0.00000 +1.00000 +1.00000 +0.00000 +0.00000 +1.00000 +2.00000 +0.00000 +0.98058 +0.01726 +0.00216 +0.00000 + +1.77500 -4.60676 +1.33200 +0.00000 +0.00000 +1.00000 +1.00000 +0.25000 +0.00000 +1.00000 +2.00000 +0.00000 +0.96510 +0.03354 +0.00136 +0.00000 + -1.77500 -4.60676 +1.33200 +0.00000 +0.00000 +1.00000 +0.00000 +0.25000 +0.00000 +1.00000 +2.00000 +0.00000 +0.96587 +0.03276 +0.00138 +0.00000 + +1.77500 -0.00000 +1.33200 +0.00000 +0.00000 +1.00000 +1.00000 +0.50000 +0.00000 +1.00000 +2.00000 +0.00000 +0.49775 +0.49765 +0.00460 +0.00000 + -1.77500 -0.00000 +1.33200 +0.00000 +0.00000 +1.00000 +0.00000 +0.50000 +0.00000 +1.00000 +2.00000 +0.00000 +0.49768 +0.49669 +0.00563 +0.00000 + +1.77500 +4.60676 +1.33200 +0.00000 +0.00000 +1.00000 +1.00000 +0.75000 +1.00000 +2.00000 +0.00000 +0.00000 +0.75107 +0.22109 +0.02783 +0.00000 + -1.77500 +4.60676 +1.33200 +0.00000 +0.00000 +1.00000 +0.00000 +0.75000 +1.00000 +2.00000 +0.00000 +0.00000 +0.74292 +0.23018 +0.02690 +0.00000 + +1.77500 +9.21352 +1.33200 +0.00000 +0.00000 +1.00000 +1.00000 +1.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.49565 +0.49565 +0.00870 +0.00000 + -1.77500 +9.21352 +1.33200 +0.00000 +0.00000 +1.00000 +0.00000 +1.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.49581 +0.49581 +0.00837 +0.00000 + -1.77500 +9.21352 +1.33200 +0.00000 +1.00000 +0.00000 +0.00000 +1.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.49581 +0.49581 +0.00837 +0.00000 + +1.77500 +9.21352 +1.33200 +0.00000 +1.00000 +0.00000 +1.00000 +1.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.49565 +0.49565 +0.00870 +0.00000 + +1.77500 +9.21352 -1.33200 +0.00000 +1.00000 +0.00000 +1.00000 +2.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.49565 +0.49565 +0.00870 +0.00000 + -1.77500 +9.21352 -1.33200 +0.00000 +1.00000 +0.00000 +0.00000 +2.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.49581 +0.49581 +0.00837 +0.00000 + -1.77500 +9.21352 -1.33200 +0.00000 +0.00000 -1.00000 +0.00000 +2.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.49581 +0.49581 +0.00837 +0.00000 + +1.77500 +9.21352 -1.33200 +0.00000 +0.00000 -1.00000 +1.00000 +2.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.49565 +0.49565 +0.00870 +0.00000 + +1.77500 +4.60676 -1.33200 +0.00000 +0.00000 -1.00000 +1.00000 +2.25000 +1.00000 +2.00000 +0.00000 +0.00000 +0.75107 +0.22109 +0.02783 +0.00000 + -1.77500 +4.60676 -1.33200 +0.00000 +0.00000 -1.00000 +0.00000 +2.25000 +1.00000 +2.00000 +0.00000 +0.00000 +0.74292 +0.23018 +0.02690 +0.00000 + +1.77500 -0.00000 -1.33200 +0.00000 +0.00000 -1.00000 +1.00000 +2.50000 +0.00000 +1.00000 +2.00000 +0.00000 +0.49775 +0.49765 +0.00460 +0.00000 + -1.77500 -0.00000 -1.33200 +0.00000 +0.00000 -1.00000 +0.00000 +2.50000 +0.00000 +1.00000 +2.00000 +0.00000 +0.49768 +0.49669 +0.00563 +0.00000 + +1.77500 -4.60676 -1.33200 +0.00000 +0.00000 -1.00000 +1.00000 +2.75000 +0.00000 +1.00000 +2.00000 +0.00000 +0.96510 +0.03354 +0.00136 +0.00000 + -1.77500 -4.60676 -1.33200 +0.00000 +0.00000 -1.00000 +0.00000 +2.75000 +0.00000 +1.00000 +2.00000 +0.00000 +0.96587 +0.03276 +0.00138 +0.00000 + +1.77500 -9.21352 -1.33200 +0.00000 +0.00000 -1.00000 +1.00000 +3.00000 +0.00000 +1.00000 +2.00000 +0.00000 +0.98058 +0.01726 +0.00216 +0.00000 + -1.77500 -9.21352 -1.33200 +0.00000 +0.00000 -1.00000 +0.00000 +3.00000 +0.00000 +1.00000 +2.00000 +0.00000 +0.98127 +0.01663 +0.00211 +0.00000 + -1.77500 -9.21352 -1.33200 +0.00000 -1.00000 +0.00000 +0.00000 +3.00000 +0.00000 +1.00000 +2.00000 +0.00000 +0.98127 +0.01663 +0.00211 +0.00000 + +1.77500 -9.21352 -1.33200 +0.00000 -1.00000 +0.00000 +1.00000 +3.00000 +0.00000 +1.00000 +2.00000 +0.00000 +0.98058 +0.01726 +0.00216 +0.00000 + +1.77500 -9.21352 +1.33200 +0.00000 -1.00000 +0.00000 +1.00000 +4.00000 +0.00000 +1.00000 +2.00000 +0.00000 +0.98058 +0.01726 +0.00216 +0.00000 + -1.77500 -9.21352 +1.33200 +0.00000 -1.00000 +0.00000 +0.00000 +4.00000 +0.00000 +1.00000 +2.00000 +0.00000 +0.98127 +0.01663 +0.00211 +0.00000 + +1.77500 -9.21352 +1.33200 +1.00000 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 +1.00000 +2.00000 +0.00000 +0.98058 +0.01726 +0.00216 +0.00000 + +1.77500 -9.21352 -1.33200 +1.00000 +0.00000 +0.00000 +2.00000 +0.00000 +0.00000 +1.00000 +2.00000 +0.00000 +0.98058 +0.01726 +0.00216 +0.00000 + +1.77500 -4.60676 -1.33200 +1.00000 +0.00000 +0.00000 +2.00000 +0.25000 +0.00000 +1.00000 +2.00000 +0.00000 +0.96510 +0.03354 +0.00136 +0.00000 + +1.77500 -4.60676 +1.33200 +1.00000 +0.00000 +0.00000 +1.00000 +0.25000 +0.00000 +1.00000 +2.00000 +0.00000 +0.96510 +0.03354 +0.00136 +0.00000 + +1.77500 -0.00000 -1.33200 +1.00000 +0.00000 +0.00000 +2.00000 +0.50000 +0.00000 +1.00000 +2.00000 +0.00000 +0.49775 +0.49765 +0.00460 +0.00000 + +1.77500 -0.00000 +1.33200 +1.00000 +0.00000 +0.00000 +1.00000 +0.50000 +0.00000 +1.00000 +2.00000 +0.00000 +0.49775 +0.49765 +0.00460 +0.00000 + +1.77500 +4.60676 -1.33200 +1.00000 +0.00000 +0.00000 +2.00000 +0.75000 +1.00000 +2.00000 +0.00000 +0.00000 +0.75107 +0.22109 +0.02783 +0.00000 + +1.77500 +4.60676 +1.33200 +1.00000 +0.00000 +0.00000 +1.00000 +0.75000 +1.00000 +2.00000 +0.00000 +0.00000 +0.75107 +0.22109 +0.02783 +0.00000 + +1.77500 +9.21352 -1.33200 +1.00000 +0.00000 +0.00000 +2.00000 +1.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.49565 +0.49565 +0.00870 +0.00000 + +1.77500 +9.21352 +1.33200 +1.00000 +0.00000 +0.00000 +1.00000 +1.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.49565 +0.49565 +0.00870 +0.00000 + -1.77500 -9.21352 -1.33200 -1.00000 +0.00000 +0.00000 -1.00000 +0.00000 +0.00000 +1.00000 +2.00000 +0.00000 +0.98127 +0.01663 +0.00211 +0.00000 + -1.77500 -9.21352 +1.33200 -1.00000 +0.00000 +0.00000 +0.00000 +0.00000 +0.00000 +1.00000 +2.00000 +0.00000 +0.98127 +0.01663 +0.00211 +0.00000 + -1.77500 -4.60676 +1.33200 -1.00000 +0.00000 +0.00000 +0.00000 +0.25000 +0.00000 +1.00000 +2.00000 +0.00000 +0.96587 +0.03276 +0.00138 +0.00000 + -1.77500 -4.60676 -1.33200 -1.00000 +0.00000 +0.00000 -1.00000 +0.25000 +0.00000 +1.00000 +2.00000 +0.00000 +0.96587 +0.03276 +0.00138 +0.00000 + -1.77500 -0.00000 +1.33200 -1.00000 +0.00000 +0.00000 +0.00000 +0.50000 +0.00000 +1.00000 +2.00000 +0.00000 +0.49768 +0.49669 +0.00563 +0.00000 + -1.77500 -0.00000 -1.33200 -1.00000 +0.00000 +0.00000 -1.00000 +0.50000 +0.00000 +1.00000 +2.00000 +0.00000 +0.49768 +0.49669 +0.00563 +0.00000 + -1.77500 +4.60676 +1.33200 -1.00000 +0.00000 +0.00000 +0.00000 +0.75000 +1.00000 +2.00000 +0.00000 +0.00000 +0.74292 +0.23018 +0.02690 +0.00000 + -1.77500 +4.60676 -1.33200 -1.00000 +0.00000 +0.00000 -1.00000 +0.75000 +1.00000 +2.00000 +0.00000 +0.00000 +0.74292 +0.23018 +0.02690 +0.00000 + -1.77500 +9.21352 +1.33200 -1.00000 +0.00000 +0.00000 +0.00000 +1.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.49581 +0.49581 +0.00837 +0.00000 + -1.77500 +9.21352 -1.33200 -1.00000 +0.00000 +0.00000 -1.00000 +1.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.49581 +0.49581 +0.00837 +0.00000 + // + // Material Groups: + MaterialCount= 1 + MaterialID= 1 + // Triangles: + TriCount 36 + 0 1 2 + 0 2 3 + 3 2 4 + 3 4 5 + 5 4 6 + 5 6 7 + 7 6 8 + 7 8 9 + 10 11 12 + 10 12 13 + 14 15 16 + 14 16 17 + 17 16 18 + 17 18 19 + 19 18 20 + 19 20 21 + 21 20 22 + 21 22 23 + 24 25 26 + 24 26 27 + 28 29 30 + 28 30 31 + 31 30 32 + 31 32 33 + 33 32 34 + 33 34 35 + 35 34 36 + 35 36 37 + 38 39 40 + 38 40 41 + 41 40 42 + 41 42 43 + 43 42 44 + 43 44 45 + 45 44 46 + 45 46 47 + MESH pCubeShape3 + meshID= 2 + ParentHash= 3936665616 + NumBlendshapeWeights 0 + IsSkinned 0 + Stride 8 + // Vertices format: Position.xyz | Normal.xyz | UV + NumVerts 24 + -3.03392 +9.21412 +3.03392 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 + +3.03392 +9.21412 +3.03392 +0.00000 +0.00000 +1.00000 +1.00000 +0.00000 + +3.03392 +15.28197 +3.03392 +0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + -3.03392 +15.28197 +3.03392 +0.00000 +0.00000 +1.00000 +0.00000 +1.00000 + -3.03392 +15.28197 +3.03392 +0.00000 +1.00000 +0.00000 +0.00000 +1.00000 + +3.03392 +15.28197 +3.03392 +0.00000 +1.00000 +0.00000 +1.00000 +1.00000 + +3.03392 +15.28197 -3.03392 +0.00000 +1.00000 +0.00000 +1.00000 +2.00000 + -3.03392 +15.28197 -3.03392 +0.00000 +1.00000 +0.00000 +0.00000 +2.00000 + -3.03392 +15.28197 -3.03392 +0.00000 +0.00000 -1.00000 +0.00000 +2.00000 + +3.03392 +15.28197 -3.03392 +0.00000 +0.00000 -1.00000 +1.00000 +2.00000 + +3.03392 +9.21412 -3.03392 +0.00000 +0.00000 -1.00000 +1.00000 +3.00000 + -3.03392 +9.21412 -3.03392 +0.00000 +0.00000 -1.00000 +0.00000 +3.00000 + -3.03392 +9.21412 -3.03392 +0.00000 -1.00000 +0.00000 +0.00000 +3.00000 + +3.03392 +9.21412 -3.03392 +0.00000 -1.00000 +0.00000 +1.00000 +3.00000 + +3.03392 +9.21412 +3.03392 +0.00000 -1.00000 +0.00000 +1.00000 +4.00000 + -3.03392 +9.21412 +3.03392 +0.00000 -1.00000 +0.00000 +0.00000 +4.00000 + +3.03392 +9.21412 +3.03392 +1.00000 +0.00000 +0.00000 +1.00000 +0.00000 + +3.03392 +9.21412 -3.03392 +1.00000 +0.00000 +0.00000 +2.00000 +0.00000 + +3.03392 +15.28197 -3.03392 +1.00000 +0.00000 +0.00000 +2.00000 +1.00000 + +3.03392 +15.28197 +3.03392 +1.00000 +0.00000 +0.00000 +1.00000 +1.00000 + -3.03392 +9.21412 -3.03392 -1.00000 +0.00000 +0.00000 -1.00000 +0.00000 + -3.03392 +9.21412 +3.03392 -1.00000 +0.00000 +0.00000 +0.00000 +0.00000 + -3.03392 +15.28197 +3.03392 -1.00000 +0.00000 +0.00000 +0.00000 +1.00000 + -3.03392 +15.28197 -3.03392 -1.00000 +0.00000 +0.00000 -1.00000 +1.00000 + // + // Material Groups: + MaterialCount= 1 + MaterialID= 1 + // Triangles: + TriCount 12 + 0 1 2 + 0 2 3 + 4 5 6 + 4 6 7 + 8 9 10 + 8 10 11 + 12 13 14 + 12 14 15 + 16 17 18 + 16 18 19 + 20 21 22 + 20 22 23 + MESH pCubeShape2 + meshID= 3 + ParentHash= 2644766854 + NumBlendshapeWeights 0 + IsSkinned 0 + Stride 8 + // Vertices format: Position.xyz | Normal.xyz | UV + NumVerts 24 + -0.50000 -0.50000 +0.50000 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 + +0.50000 -0.50000 +0.50000 +0.00000 +0.00000 +1.00000 +1.00000 +0.00000 + +0.50000 +0.50000 +0.50000 +0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + -0.50000 +0.50000 +0.50000 +0.00000 +0.00000 +1.00000 +0.00000 +1.00000 + -0.50000 +0.50000 +0.50000 +0.00000 +1.00000 +0.00000 +0.00000 +1.00000 + +0.50000 +0.50000 +0.50000 +0.00000 +1.00000 +0.00000 +1.00000 +1.00000 + +0.50000 +0.50000 -0.50000 +0.00000 +1.00000 +0.00000 +1.00000 +2.00000 + -0.50000 +0.50000 -0.50000 +0.00000 +1.00000 +0.00000 +0.00000 +2.00000 + -0.50000 +0.50000 -0.50000 +0.00000 +0.00000 -1.00000 +0.00000 +2.00000 + +0.50000 +0.50000 -0.50000 +0.00000 +0.00000 -1.00000 +1.00000 +2.00000 + +0.50000 -0.50000 -0.50000 +0.00000 +0.00000 -1.00000 +1.00000 +3.00000 + -0.50000 -0.50000 -0.50000 +0.00000 +0.00000 -1.00000 +0.00000 +3.00000 + -0.50000 -0.50000 -0.50000 +0.00000 -1.00000 +0.00000 +0.00000 +3.00000 + +0.50000 -0.50000 -0.50000 +0.00000 -1.00000 +0.00000 +1.00000 +3.00000 + +0.50000 -0.50000 +0.50000 +0.00000 -1.00000 +0.00000 +1.00000 +4.00000 + -0.50000 -0.50000 +0.50000 +0.00000 -1.00000 +0.00000 +0.00000 +4.00000 + +0.50000 -0.50000 +0.50000 +1.00000 +0.00000 +0.00000 +1.00000 +0.00000 + +0.50000 -0.50000 -0.50000 +1.00000 +0.00000 +0.00000 +2.00000 +0.00000 + +0.50000 +0.50000 -0.50000 +1.00000 +0.00000 +0.00000 +2.00000 +1.00000 + +0.50000 +0.50000 +0.50000 +1.00000 +0.00000 +0.00000 +1.00000 +1.00000 + -0.50000 -0.50000 -0.50000 -1.00000 +0.00000 +0.00000 -1.00000 +0.00000 + -0.50000 -0.50000 +0.50000 -1.00000 +0.00000 +0.00000 +0.00000 +0.00000 + -0.50000 +0.50000 +0.50000 -1.00000 +0.00000 +0.00000 +0.00000 +1.00000 + -0.50000 +0.50000 -0.50000 -1.00000 +0.00000 +0.00000 -1.00000 +1.00000 + // + // Material Groups: + MaterialCount= 1 + MaterialID= 1 + // Triangles: + TriCount 12 + 0 1 2 + 0 2 3 + 4 5 6 + 4 6 7 + 8 9 10 + 8 10 11 + 12 13 14 + 12 14 15 + 16 17 18 + 16 18 19 + 20 21 22 + 20 22 23 +SKELETON +numJoints 5 + JOINT joint1 + nameHash 3805966487 + parentIndex -1 + Transformation 1 +0.00000 +0.00000 +0.70218 +0.71200 -0.02297 -6.56968 +0.00000 +1.00000 +1.00000 +1.00000 + JOINT joint2 + nameHash 2077434157 + parentIndex 0 + Transformation 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + JOINT joint3 + nameHash 215224763 + parentIndex 1 + Transformation 1 +0.70215 +0.71203 +0.00000 +0.00000 +6.57032 +0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + JOINT pCube3 + nameHash 3936665616 + parentIndex 2 + Transformation 1 -0.01398 +0.99990 +0.00000 +0.00000 +0.16205 -6.61368 -0.00000 +1.00000 +1.00000 +1.00000 + JOINT pCube2 + nameHash 2644766854 + parentIndex 0 + Transformation 1 +0.00000 +0.00000 -0.70218 +0.71200 -3.13390 -0.06650 +0.00000 +14.05556 +1.00000 +11.08333 + +ANIMATION simplest.mb + StartTime 0.0166667 + EndTime 0.5 + NumFrames 30 + NumBlendShapes 0 + JOINTANIM + NumJointAnims 1 + joint2 2077434157 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.12194 +0.99254 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.28170 +0.95950 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.44371 +0.89617 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.58792 +0.80892 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.70009 +0.71406 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.77363 +0.63363 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.80715 +0.59035 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.79772 +0.60303 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.72988 +0.68357 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.58993 +0.80745 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.37624 +0.92652 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.10599 +0.99437 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.18288 +0.98313 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.44469 +0.89569 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.64482 +0.76434 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.77076 +0.63713 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.82760 +0.56132 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.84122 +0.54069 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.83486 +0.55046 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.81053 +0.58570 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.76834 +0.64005 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.70798 +0.70623 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.62992 +0.77666 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.53615 +0.84412 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.43054 +0.90257 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.31865 +0.94787 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.20721 +0.97830 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.10335 +0.99464 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + diff --git a/data/simplest.scene b/data/simplest.scene new file mode 100644 index 000000000..89b02f9eb --- /dev/null +++ b/data/simplest.scene @@ -0,0 +1,2 @@ +camera simple-all.camera +model simplest.model diff --git a/data/test-maya7.bat b/data/test-maya7.bat new file mode 100644 index 000000000..011fcb778 --- /dev/null +++ b/data/test-maya7.bat @@ -0,0 +1,13 @@ +SET MAYA_LOCATION=C:\Program Files (x86)\Alias\Maya7.0 +SET PATH=C:\Program Files (x86)\NVIDIA Corporation\Cg\bin;C:\Program Files (x86)\Alias\Maya7.0\bin;%PATH% + +Exporter simple-all.conf +Exporter simple-anims.conf +Exporter middle.conf +Exporter anim.conf + +Loader simple-all.scene +Loader simple-anims.scene +Loader middle.scene +Loader anim.scene + diff --git a/data/test.bat b/data/test.bat new file mode 100644 index 000000000..28b777d75 --- /dev/null +++ b/data/test.bat @@ -0,0 +1,13 @@ +SET MAYA_LOCATION=C:\Program Files\Autodesk\Maya2009 +SET PATH=C:\Program Files (x86)\NVIDIA Corporation\Cg\bin;C:\Program Files\Autodesk\Maya2009\bin;%PATH% + +Exporter simple-all.conf +Exporter simple-anims.conf +Exporter middle.conf +Exporter anim.conf + +Loader simple-all.scene +Loader simple-anims.scene +Loader middle.scene +Loader anim.scene + diff --git a/data2009/CgFX/basic-lighting/Blinn.cgfx b/data2009/CgFX/basic-lighting/Blinn.cgfx new file mode 100644 index 000000000..5d6de57da --- /dev/null +++ b/data2009/CgFX/basic-lighting/Blinn.cgfx @@ -0,0 +1,456 @@ +/*********************************************************************NVMH3**** +$Revision$ + +Copyright NVIDIA Corporation 2007 +TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED +*AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS +BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES +WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, +BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY +LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF +NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + + +To learn more about shading, shaders, and to bounce ideas off other shader + authors and users, visit the NVIDIA Shader Library Forums at: + + http://developer.nvidia.com/forums/ + +******************************************************************************/ + +#define FLIP_TEXTURE_Y + +float Script : STANDARDSGLOBAL < + string UIWidget = "none"; + string ScriptClass = "object"; + string ScriptOrder = "standard"; + string ScriptOutput = "color"; + string Script = "Technique=Main;"; +> = 0.8; + +//// UN-TWEAKABLES - AUTOMATICALLY-TRACKED TRANSFORMS //////////////// + +float4x4 WorldITXf : WorldInverseTranspose < string UIWidget="None"; >; +float4x4 WvpXf : WorldViewProjection < string UIWidget="None"; >; +float4x4 WorldXf : World < string UIWidget="None"; >; +float4x4 ViewIXf : ViewInverse < string UIWidget="None"; >; + +//// TWEAKABLE PARAMETERS //////////////////// + +/// Point Lamp 0 //////////// +float3 Lamp0Pos : Position < + string Object = "PointLight0"; + string UIName = "Lamp 0 Position"; + string Space = "World"; +> = {-0.5f,2.0f,1.25f}; + +float3 Lamp0Color : Specular < + string UIName = "Lamp 0"; + string Object = "Pointlight0"; + string UIWidget = "Color"; +> = {1.0f,1.0f,1.0f}; + +// Ambient Light +float3 AmbiColor : Ambient < + string UIName = "Ambient Light"; + string UIWidget = "Color"; +> = {0.07f,0.07f,0.07f}; + +float Ks < + string UIWidget = "slider"; + float UIMin = 0.0; + float UIMax = 1.0; + float UIStep = 0.05; + string UIName = "Specular"; +> = 0.4; + +float Eccentricity < + string UIWidget = "slider"; + float UIMin = 0.0; + float UIMax = 1.0; + float UIStep = 0.0001; + string UIName = "Highlight Eccentricity"; +> = 0.3; + + +//////// COLOR & TEXTURE ///////////////////// + +/// the ambient material colour +float4 m_Ambient; + +/// the diffuse colour +float4 m_Diffuse; + +/// the specular colour +float4 m_Specular; + +/// the emission colour +float4 m_Emission; + +/// the transparency colour +float4 m_Transparency; + +/// the shininess +float m_Shininess; + +texture ColorTexture < + string ResourceName = "default_color.dds"; + string UIName = "Diffuse Texture"; + string ResourceType = "2D"; +>; + +sampler2D ColorSampler = sampler_state { + Texture = <ColorTexture>; + MinFilter = LinearMipMapLinear; + MagFilter = Linear; + WrapS = Repeat; + WrapT = Repeat; +}; + +texture SpecularTexture < + string ResourceName = "checker.dds"; + string UIName = "Specular Texture"; + string ResourceType = "2D"; +>; + +sampler2D SpecularSampler = sampler_state { + Texture = <SpecularTexture>; + MinFilter = LinearMipMapLinear; + MagFilter = Linear; + WrapS = Repeat; + WrapT = Repeat; +}; + +texture TranspTexture < + string ResourceName = "checker.dds"; + string UIName = "Transp Texture"; + string ResourceType = "2D"; +>; + +sampler2D TranspSampler = sampler_state { + Texture = <TranspTexture>; + MinFilter = LinearMipMapLinear; + MagFilter = Linear; + WrapS = Repeat; + WrapT = Repeat; +}; + +//////// CONNECTOR DATA STRUCTURES /////////// + +/* data from application vertex buffer */ +struct appdata { + float3 Position : POSITION; + float4 UV : TEXCOORD0; + float4 Normal : NORMAL; + float4 Tangent : TANGENT0; + float4 Binormal : BINORMAL0; +}; + +/* data passed from vertex shader to pixel shader */ +struct vertexOutput { + float4 HPosition : POSITION; + float2 UV : TEXCOORD0; + // The following values are passed in "World" coordinates since + // it tends to be the most flexible and easy for handling + // reflections, sky lighting, and other "global" effects. + float3 LightVec : TEXCOORD1; + float3 WorldNormal : TEXCOORD2; + float3 WorldTangent : TEXCOORD3; + float3 WorldBinormal : TEXCOORD4; + float3 WorldView : TEXCOORD5; +}; + +///////// VERTEX SHADING ///////////////////// + +/*********** Generic Vertex Shader ******/ + +vertexOutput std_VS(appdata IN) { + vertexOutput OUT = (vertexOutput)0; + OUT.WorldNormal = mul(WorldITXf,IN.Normal).xyz; + OUT.WorldTangent = mul(WorldITXf,IN.Tangent).xyz; + OUT.WorldBinormal = mul(WorldITXf,IN.Binormal).xyz; + float4 Po = float4(IN.Position.xyz,1); + float3 Pw = mul(WorldXf,Po).xyz; + OUT.LightVec = (Lamp0Pos - Pw); +#ifdef FLIP_TEXTURE_Y + OUT.UV = float2(IN.UV.x,(1.0-IN.UV.y)); +#else /* !FLIP_TEXTURE_Y */ + OUT.UV = IN.UV.xy; +#endif /* !FLIP_TEXTURE_Y */ + OUT.WorldView = normalize(float3(ViewIXf[0].w,ViewIXf[1].w,ViewIXf[2].w) - Pw); + OUT.HPosition = mul(WvpXf,Po); + return OUT; +} + +///////// PIXEL SHADING ////////////////////// + +// Utility function for blinn shading + +void blinn_shading(vertexOutput IN, + float3 LightColor, + float3 Nn, + float3 Ln, + float3 Vn, + out float3 DiffuseContrib, + out float3 SpecularContrib) +{ + float3 Hn = normalize(Vn + Ln); + float hdn = dot(Hn,Nn); + float3 R = reflect(-Ln,Nn); + float rdv = dot(R,Vn); + rdv = max(rdv,0.001); + float ldn=dot(Ln,Nn); + ldn = max(ldn,0.0); + float ndv = dot(Nn,Vn); + float hdv = dot(Hn,Vn); + float eSq = Eccentricity*Eccentricity; + float distrib = eSq / (rdv * rdv * (eSq - 1.0) + 1.0); + distrib = distrib * distrib; + float Gb = 2.0 * hdn * ndv / hdv; + float Gc = 2.0 * hdn * ldn / hdv; + float Ga = min(1.0,min(Gb,Gc)); + float fresnelHack = 1.0 - pow(ndv,5.0); + hdn = distrib * Ga * fresnelHack / ndv; + DiffuseContrib = ldn * LightColor; + SpecularContrib = max(hdn * Ks * LightColor,0.0); +} + +float4 std_PS(vertexOutput IN, + float face : FACE) : COLOR { + float3 diffContrib; + float3 specContrib; + float3 Ln = normalize(IN.LightVec); + float3 Vn = normalize(IN.WorldView); + float3 Nn = face * normalize(IN.WorldNormal); + blinn_shading(IN,Lamp0Color,Nn,Ln,Vn,diffContrib,specContrib); + float4 textureColor = tex2D(ColorSampler,IN.UV); + float3 diffuseTerm = textureColor.rgb * (diffContrib+AmbiColor); + float3 specularTerm = m_Specular.rgb * specContrib; + float3 result = specularTerm + diffuseTerm; + float alpha = textureColor.a; + return float4(result,alpha); +} + +float4 No_Texture_PS(vertexOutput IN, + float face : FACE) : COLOR { + float3 diffContrib; + float3 specContrib; + float3 Ln = normalize(IN.LightVec); + float3 Vn = normalize(IN.WorldView); + float3 Nn = face * normalize(IN.WorldNormal); + blinn_shading(IN,Lamp0Color,Nn,Ln,Vn,diffContrib,specContrib); + float3 diffuseTerm = m_Diffuse.rgb * (diffContrib+AmbiColor); + float3 specularTerm = m_Specular.rgb * specContrib; + float3 result = specularTerm + diffuseTerm; + float alpha = m_Diffuse.a; + return float4(result,alpha); +} + +float4 Specular_Texture_PS(vertexOutput IN, + float face : FACE) : COLOR { + float3 diffContrib; + float3 specContrib; + float3 Ln = normalize(IN.LightVec); + float3 Vn = normalize(IN.WorldView); + float3 Nn = face * normalize(IN.WorldNormal); + blinn_shading(IN,Lamp0Color,Nn,Ln,Vn,diffContrib,specContrib); + float4 textureColor = tex2D(ColorSampler,IN.UV); + float3 diffuseTerm = textureColor.rgb * (diffContrib+AmbiColor); + float4 specularTextureColor = tex2D(SpecularSampler, IN.UV); + float specularMask = dot( specularTextureColor.rgb, float3(1,1,1) ) / 3.0f; // average of r,g,b + float3 specularTerm = specularMask * specContrib; + float3 result = specularTerm + diffuseTerm; + float alpha = textureColor.a; + return float4(result,alpha); +} + +float4 Transp_Texture_PS(vertexOutput IN, + float face : FACE) : COLOR { + float3 diffContrib; + float3 specContrib; + float3 Ln = normalize(IN.LightVec); + float3 Vn = normalize(IN.WorldView); + float3 Nn = face * normalize(IN.WorldNormal); + blinn_shading(IN,Lamp0Color,Nn,Ln,Vn,diffContrib,specContrib); + float4 textureColor = tex2D(ColorSampler,IN.UV); + float4 transpColor = tex2D(TranspSampler,IN.UV); + float3 diffuseTerm = textureColor.rgb * (diffContrib+AmbiColor); + float3 specularTerm = m_Specular.rgb * specContrib; + float3 result = specularTerm + diffuseTerm; + float alpha = transpColor.r; // assuming r,g,and b has same value + return float4(result,alpha); +} + +float4 Specular_Transp_Texture_PS(vertexOutput IN, + float face : FACE) : COLOR { + float3 diffContrib; + float3 specContrib; + float3 Ln = normalize(IN.LightVec); + float3 Vn = normalize(IN.WorldView); + float3 Nn = face * normalize(IN.WorldNormal); + blinn_shading(IN,Lamp0Color,Nn,Ln,Vn,diffContrib,specContrib); + float4 textureColor = tex2D(ColorSampler,IN.UV); + float3 diffuseTerm = textureColor.rgb * (diffContrib+AmbiColor); + float4 specularTextureColor = tex2D(SpecularSampler, IN.UV); + float specularMask = dot( specularTextureColor.rgb, float3(1,1,1) ) / 3.0f; // average of r,g,b + float3 specularTerm = specularMask * specContrib; + float4 transpColor = tex2D(TranspSampler,IN.UV); + float3 result = specularTerm + diffuseTerm; + float alpha = transpColor.r; // assuming r,g,and b has same value + return float4(result,alpha); +} +///// TECHNIQUES ///////////////////////////// + + +technique Main < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = true; + CullFaceEnable = false; + BlendEnable = false; + DepthFunc = LEqual; + FragmentProgram = compile fp40 std_PS(); + } +} + +technique Main_Blending < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = false; + CullFaceEnable = false; + BlendEnable = true; + BlendFunc = float2(SrcAlpha, OneMinusSrcAlpha); + DepthFunc = LEqual; + FragmentProgram = compile fp40 std_PS(); + } +} + +technique Main_Alphatest < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = true; + CullFaceEnable = false; + AlphaFunc = float2(Greater, 0.1f); + AlphaTestEnable = true; + FragmentProgram = compile fp40 std_PS(); + } +} + +technique No_Texture < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = true; + CullFaceEnable = false; + BlendEnable = false; + DepthFunc = LEqual; + FragmentProgram = compile fp40 No_Texture_PS(); + } +} + +technique No_Texture_Blending < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = false; + CullFaceEnable = false; + BlendEnable = true; + BlendFunc = float2(SrcAlpha, OneMinusSrcAlpha); + DepthFunc = LEqual; + FragmentProgram = compile fp40 No_Texture_PS(); + } +} + +technique Main_Specular < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = true; + CullFaceEnable = false; + BlendEnable = false; + DepthFunc = LEqual; + FragmentProgram = compile fp40 Specular_Texture_PS(); + } +} + +technique Main_Specular_Blending < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = false; + CullFaceEnable = false; + BlendEnable = true; + BlendFunc = float2(SrcAlpha, OneMinusSrcAlpha); + DepthFunc = LEqual; + FragmentProgram = compile fp40 Specular_Texture_PS(); + } +} + +technique Main_Transp_Blending < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = false; + CullFaceEnable = false; + BlendEnable = true; + BlendFunc = float2(SrcAlpha, OneMinusSrcAlpha); + DepthFunc = LEqual; + FragmentProgram = compile fp40 Transp_Texture_PS(); + } +} + +technique Main_Specular_Transp_Blending < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = false; + CullFaceEnable = false; + BlendEnable = true; + BlendFunc = float2(SrcAlpha, OneMinusSrcAlpha); + DepthFunc = LEqual; + FragmentProgram = compile fp40 Specular_Transp_Texture_PS(); + } +} + +/////////////////////////////////////// eof // diff --git a/data2009/CgFX/basic-lighting/Blinn_bump_reflect.cgfx b/data2009/CgFX/basic-lighting/Blinn_bump_reflect.cgfx new file mode 100644 index 000000000..fccc94853 --- /dev/null +++ b/data2009/CgFX/basic-lighting/Blinn_bump_reflect.cgfx @@ -0,0 +1,257 @@ +/*********************************************************************NVMH3**** +$Revision$ + +Copyright NVIDIA Corporation 2007 +TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED +*AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS +BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES +WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, +BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY +LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF +NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + + +To learn more about shading, shaders, and to bounce ideas off other shader + authors and users, visit the NVIDIA Shader Library Forums at: + + http://developer.nvidia.com/forums/ + +******************************************************************************/ + +// #define FLIP_TEXTURE_Y + +float Script : STANDARDSGLOBAL < + string UIWidget = "none"; + string ScriptClass = "object"; + string ScriptOrder = "standard"; + string ScriptOutput = "color"; + string Script = "Technique=Main;"; +> = 0.8; + +//// UN-TWEAKABLES - AUTOMATICALLY-TRACKED TRANSFORMS //////////////// + +float4x4 WorldITXf : WorldInverseTranspose < string UIWidget="None"; >; +float4x4 WvpXf : WorldViewProjection < string UIWidget="None"; >; +float4x4 WorldXf : World < string UIWidget="None"; >; +float4x4 ViewIXf : ViewInverse < string UIWidget="None"; >; + +//// TWEAKABLE PARAMETERS //////////////////// + +/// Point Lamp 0 //////////// +float3 Lamp0Pos : Position < + string Object = "PointLight0"; + string UIName = "Lamp 0 Position"; + string Space = "World"; +> = {-0.5f,2.0f,1.25f}; +float3 Lamp0Color : Specular < + string UIName = "Lamp 0"; + string Object = "Pointlight0"; + string UIWidget = "Color"; +> = {1.0f,1.0f,1.0f}; + +// Ambient Light +float3 AmbiColor : Ambient < + string UIName = "Ambient Light"; + string UIWidget = "Color"; +> = {0.07f,0.07f,0.07f}; + +float Ks < + string UIWidget = "slider"; + float UIMin = 0.0; + float UIMax = 1.0; + float UIStep = 0.05; + string UIName = "Specular"; +> = 0.4; + +float Eccentricity < + string UIWidget = "slider"; + float UIMin = 0.0; + float UIMax = 1.0; + float UIStep = 0.0001; + string UIName = "Highlight Eccentricity"; +> = 0.3; + + +float Bump < + string UIWidget = "slider"; + float UIMin = 0.0; + float UIMax = 3.0; + float UIStep = 0.01; + string UIName = "Bumpiness"; +> = 1.0; + +float Kr < + string UIWidget = "slider"; + float UIMin = 0.0; + float UIMax = 1.0; + float UIStep = 0.01; + string UIName = "Reflection Strength"; +> = 0.5; + +//////// COLOR & TEXTURE ///////////////////// + +texture ColorTexture < + string ResourceName = "default_color.dds"; + string UIName = "Diffuse Texture"; + string ResourceType = "2D"; +>; + +sampler2D ColorSampler = sampler_state { + Texture = <ColorTexture>; + MinFilter = LinearMipMapLinear; + MagFilter = Linear; + WrapS = Repeat; + WrapT = Repeat; +}; + +texture NormalTexture < + string ResourceName = "default_bump_normal.dds"; + string UIName = "Normal-Map Texture"; + string ResourceType = "2D"; +>; + +sampler2D NormalSampler = sampler_state { + Texture = <NormalTexture>; + MinFilter = LinearMipMapLinear; + MagFilter = Linear; + WrapS = Repeat; + WrapT = Repeat; +}; + +texture EnvTexture : ENVIRONMENT < + string ResourceName = "default_reflection.dds"; + string UIName = "Environment"; + string ResourceType = "Cube"; +>; + +samplerCUBE EnvSampler = sampler_state { + Texture = <EnvTexture>; + MagFilter = Linear; + MinFilter = LinearMipMapLinear; + WrapS = ClampToEdge; + WrapT = ClampToEdge; + WrapR = ClampToEdge; +}; + + +//////// CONNECTOR DATA STRUCTURES /////////// + +/* data from application vertex buffer */ +struct appdata { + float3 Position : POSITION; + float4 UV : TEXCOORD0; + float4 Normal : NORMAL; + float4 Tangent : TANGENT0; + float4 Binormal : BINORMAL0; +}; + +/* data passed from vertex shader to pixel shader */ +struct vertexOutput { + float4 HPosition : POSITION; + float2 UV : TEXCOORD0; + // The following values are passed in "World" coordinates since + // it tends to be the most flexible and easy for handling + // reflections, sky lighting, and other "global" effects. + float3 LightVec : TEXCOORD1; + float3 WorldNormal : TEXCOORD2; + float3 WorldTangent : TEXCOORD3; + float3 WorldBinormal : TEXCOORD4; + float3 WorldView : TEXCOORD5; +}; + +///////// VERTEX SHADING ///////////////////// + +/*********** Generic Vertex Shader ******/ + +vertexOutput std_VS(appdata IN) { + vertexOutput OUT = (vertexOutput)0; + OUT.WorldNormal = mul(WorldITXf,IN.Normal).xyz; + OUT.WorldTangent = mul(WorldITXf,IN.Tangent).xyz; + OUT.WorldBinormal = mul(WorldITXf,IN.Binormal).xyz; + float4 Po = float4(IN.Position.xyz,1); + float3 Pw = mul(WorldXf,Po).xyz; + OUT.LightVec = (Lamp0Pos - Pw); +#ifdef FLIP_TEXTURE_Y + OUT.UV = float2(IN.UV.x,(1.0-IN.UV.y)); +#else /* !FLIP_TEXTURE_Y */ + OUT.UV = IN.UV.xy; +#endif /* !FLIP_TEXTURE_Y */ + OUT.WorldView = normalize(float3(ViewIXf[0].w,ViewIXf[1].w,ViewIXf[2].w) - Pw); + OUT.HPosition = mul(WvpXf,Po); + return OUT; +} + +///////// PIXEL SHADING ////////////////////// + +// Utility function for blinn shading + +void blinn_shading(vertexOutput IN, + float3 LightColor, + float3 Nn, + float3 Ln, + float3 Vn, + out float3 DiffuseContrib, + out float3 SpecularContrib) +{ + float3 Hn = normalize(Vn + Ln); + float hdn = dot(Hn,Nn); + float3 R = reflect(-Ln,Nn); + float rdv = dot(R,Vn); + rdv = max(rdv,0.001); + float ldn=dot(Ln,Nn); + ldn = max(ldn,0.0); + float ndv = dot(Nn,Vn); + float hdv = dot(Hn,Vn); + float eSq = Eccentricity*Eccentricity; + float distrib = eSq / (rdv * rdv * (eSq - 1.0) + 1.0); + distrib = distrib * distrib; + float Gb = 2.0 * hdn * ndv / hdv; + float Gc = 2.0 * hdn * ldn / hdv; + float Ga = min(1.0,min(Gb,Gc)); + float fresnelHack = 1.0 - pow(ndv,5.0); + hdn = distrib * Ga * fresnelHack / ndv; + DiffuseContrib = ldn * LightColor; + SpecularContrib = hdn * Ks * LightColor; +} + +float4 std_PS(vertexOutput IN) : COLOR { + float3 diffContrib; + float3 specContrib; + float3 Ln = normalize(IN.LightVec); + float3 Vn = normalize(IN.WorldView); + float3 Nn = normalize(IN.WorldNormal); + float3 Tn = normalize(IN.WorldTangent); + float3 Bn = normalize(IN.WorldBinormal); + float3 bump = Bump * (tex2D(NormalSampler,IN.UV).rgb - float3(0.5,0.5,0.5)); + Nn = Nn + bump.x*Tn + bump.y*Bn; + Nn = normalize(Nn); + blinn_shading(IN,Lamp0Color,Nn,Ln,Vn,diffContrib,specContrib); + float3 diffuseColor = tex2D(ColorSampler,IN.UV).rgb; + float3 result = specContrib+(diffuseColor*(diffContrib+AmbiColor)); + float3 R = -reflect(Vn,Nn); + float3 reflColor = Kr * texCUBE(EnvSampler,R.xyz).rgb; + result += diffuseColor*reflColor; + return float4(result,1); +} + +///// TECHNIQUES ///////////////////////////// + +technique Main < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = true; + CullFaceEnable = false; + BlendEnable = false; + DepthFunc = LEqual; + FragmentProgram = compile fp40 std_PS(); + } +} + +/////////////////////////////////////// eof // diff --git a/data2009/CgFX/basic-lighting/Document1.dae b/data2009/CgFX/basic-lighting/Document1.dae new file mode 100644 index 000000000..e7ceae74b --- /dev/null +++ b/data2009/CgFX/basic-lighting/Document1.dae @@ -0,0 +1,1394 @@ +<?xml version="1.0"?> +<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1"> + <asset> + <contributor> + <author>Administrator</author> + <authoring_tool>NVIDIA FX Composer 2.5</authoring_tool> + <comments/> + <copyright/> + </contributor> + <created>2009-01-01T09:24:30Z</created> + <keywords>FXComposer, NVIDIA</keywords> + <modified>2009-02-05T07:00:24Z</modified> + <subject/> + <title/> + <unit/> + <up_axis>Y_UP</up_axis> + </asset> + <library_visual_scenes> + <visual_scene id="DefaultScene" name="DefaultScene"> + <node id="Node" name="Node" layer=""> + <matrix sid="">1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</matrix> + <instance_geometry url="#Sphere" sid="GeometryInstance" name="Sphere"> + <bind_material> + <technique_common> + <instance_material symbol="SphereMaterial" target="#Lambert_bump_reflect"/> + </technique_common> + </bind_material> + </instance_geometry> + </node> + <extra type="evaluatescene_enables"> + <technique profile="NVIDIA_FXCOMPOSER"/> + </extra> + </visual_scene> + </library_visual_scenes> + <library_images> + <image id="default_color" name="default_color"> + <init_from>../../../../program%20files%20(x86)/nvidia%20corporation/fx%20composer%202.5/media/textures/default_color.dds</init_from> + </image> + <image id="checker" name="checker"> + <init_from>../../../../program%20files%20(x86)/nvidia%20corporation/fx%20composer%202.5/media/textures/2d/checker.dds</init_from> + </image> + <image id="default_bump_normal" name="default_bump_normal"> + <init_from>../../../../program%20files%20(x86)/nvidia%20corporation/fx%20composer%202.5/media/textures/default_bump_normal.dds</init_from> + </image> + <image id="default_reflection" name="default_reflection"> + <init_from>../../../../program%20files%20(x86)/nvidia%20corporation/fx%20composer%202.5/media/textures/default_reflection.dds</init_from> + </image> + </library_images> + <library_effects> + <effect id="Effect" name="DefaultEffect"> + <profile_COMMON> + <newparam sid="Script"> + <semantic>STANDARDSGLOBAL</semantic> + <float>0.8</float> + </newparam> + <newparam sid="EmissionColor"> + <semantic>EMISSION</semantic> + <float4>0 0 0 1</float4> + </newparam> + <newparam sid="AmbientColor"> + <float4>0 0 0 1</float4> + </newparam> + <newparam sid="DiffuseColor"> + <float4>1 1 1 1</float4> + </newparam> + <newparam sid="EnvironmentColor"> + <float4>1 1 1 1</float4> + </newparam> + <newparam sid="Reflectivity"> + <float>0.5</float> + </newparam> + <newparam sid="SpecularColor"> + <semantic>SPECULAR</semantic> + <float4>1 1 1 1</float4> + </newparam> + <newparam sid="SpecularShininess"> + <float>10</float> + </newparam> + <newparam sid="TransparentColor"> + <float4>0 0 0 1</float4> + </newparam> + <newparam sid="Transparency"> + <float>1</float> + </newparam> + <newparam sid="Index_Of_Refraction"> + <float>1</float> + </newparam> + <technique sid="CommonProfile"> + <phong> + <emission> + <param ref="EmissionColor"/> + </emission> + <ambient> + <param ref="AmbientColor"/> + </ambient> + <diffuse> + <param ref="DiffuseColor"/> + </diffuse> + <specular> + <param ref="SpecularColor"/> + </specular> + <shininess> + <param ref="SpecularShininess"/> + </shininess> + <reflective> + <param ref="EnvironmentColor"/> + </reflective> + <reflectivity> + <param ref="Reflectivity"/> + </reflectivity> + <transparent> + <param ref="TransparentColor"/> + </transparent> + <transparency> + <param ref="Transparency"/> + </transparency> + <index_of_refraction> + <param ref="Index_Of_Refraction"/> + </index_of_refraction> + </phong> + </technique> + </profile_COMMON> + </effect> + <effect id="Effect1" name="Phong"> + <profile_COMMON> + <technique sid="__fxc_remove_profile_COMMON"> + <constant/> + </technique> + </profile_COMMON> + <extra type="import"> + <technique profile="NVIDIA_FXCOMPOSER"> + <import url="Phong.cgfx" compiler_options="" profile="cgfx"/> + </technique> + </extra> + </effect> + <effect id="Effect2" name="Blinn"> + <profile_COMMON> + <technique sid="__fxc_remove_profile_COMMON"> + <constant/> + </technique> + </profile_COMMON> + <extra type="import"> + <technique profile="NVIDIA_FXCOMPOSER"> + <import url="Blinn.cgfx" compiler_options="" profile="cgfx"/> + </technique> + </extra> + </effect> + <effect id="Effect3" name="Lambert"> + <profile_COMMON> + <technique sid="__fxc_remove_profile_COMMON"> + <constant/> + </technique> + </profile_COMMON> + <extra type="import"> + <technique profile="NVIDIA_FXCOMPOSER"> + <import url="Lambert.cgfx" compiler_options="" profile="cgfx"/> + </technique> + </extra> + </effect> + <effect id="Effect4" name="simple"> + <profile_COMMON> + <technique sid="__fxc_remove_profile_COMMON"> + <constant/> + </technique> + </profile_COMMON> + <extra type="import"> + <technique profile="NVIDIA_FXCOMPOSER"> + <import url="simple.cgfx" compiler_options="" profile="cgfx"/> + </technique> + </extra> + </effect> + <effect id="Effect5" name="Phong_bump_reflect"> + <profile_COMMON> + <technique sid="__fxc_remove_profile_COMMON"> + <constant/> + </technique> + </profile_COMMON> + <extra type="import"> + <technique profile="NVIDIA_FXCOMPOSER"> + <import url="Phong_bump_reflect.cgfx" compiler_options="" profile="cgfx"/> + </technique> + </extra> + </effect> + <effect id="Effect6" name="Blinn_bump_reflect"> + <profile_COMMON> + <technique sid="__fxc_remove_profile_COMMON"> + <constant/> + </technique> + </profile_COMMON> + <extra type="import"> + <technique profile="NVIDIA_FXCOMPOSER"> + <import url="Blinn_bump_reflect.cgfx" compiler_options="" profile="cgfx"/> + </technique> + </extra> + </effect> + <effect id="Effect7" name="Lambert_bump_reflect"> + <profile_COMMON> + <technique sid="__fxc_remove_profile_COMMON"> + <constant/> + </technique> + </profile_COMMON> + <extra type="import"> + <technique profile="NVIDIA_FXCOMPOSER"> + <import url="Lambert_bump_reflect.cgfx" compiler_options="" profile="cgfx"/> + </technique> + </extra> + </effect> + </library_effects> + <library_materials> + <material id="DefaultMaterial" name="DefaultMaterial"> + <instance_effect url="#Effect"> + <technique_hint platform="PC-OGL" ref="CommonProfile"/> + <technique_hint platform="PC-D3D" ref="CommonProfile"/> + <technique_hint platform="PC-D3D10" ref="CommonProfile"/> + <setparam ref="EmissionColor"> + <float4>0 0 0 1</float4> + </setparam> + <setparam ref="AmbientColor"> + <float4>0 0 0 1</float4> + </setparam> + <setparam ref="DiffuseColor"> + <float4>1 1 1 1</float4> + </setparam> + <setparam ref="EnvironmentColor"> + <float4>1 1 1 1</float4> + </setparam> + <setparam ref="Reflectivity"> + <float>0.5</float> + </setparam> + <setparam ref="SpecularColor"> + <float4>1 1 1 1</float4> + </setparam> + <setparam ref="SpecularShininess"> + <float>10</float> + </setparam> + <setparam ref="TransparentColor"> + <float4>0 0 0 1</float4> + </setparam> + <setparam ref="Transparency"> + <float>1</float> + </setparam> + <setparam ref="Index_Of_Refraction"> + <float>1</float> + </setparam> + </instance_effect> + </material> + <material id="Phong" name="Phong_Material"> + <instance_effect url="#Effect1"> + <technique_hint platform="PC-OGL" ref="Main"/> + <setparam ref="Script"> + <float>0.8</float> + </setparam> + <setparam ref="WorldITXf"> + <float4x4>1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</float4x4> + </setparam> + <setparam ref="WvpXf"> + <float4x4>-0.0188329 1.50929 0.835685 0.835583 -5.4207e-007 2.29578 -0.549411 -0.549344 3.33303 0.00852854 0.00472183 0.00472126 9.23178e-006 -1.5976e-005 5.10234 5.10536</float4x4> + </setparam> + <setparam ref="WorldXf"> + <float4x4>1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</float4x4> + </setparam> + <setparam ref="ViewIXf"> + <float4x4>-0.00565031 -2.10329e-007 0.999984 0 0.549335 0.835597 0.00310409 0 -0.835583 0.549344 -0.00472128 -0 -4.26595 2.8046 -0.0241066 1</float4x4> + </setparam> + <setparam ref="Lamp0Pos"> + <float3>2 2 2</float3> + </setparam> + <setparam ref="Lamp0Color"> + <float4>1 1 1 1</float4> + </setparam> + <setparam ref="AmbiColor"> + <float3>0.07 0.07 0.07</float3> + </setparam> + <setparam ref="Ks"> + <float>0.4</float> + </setparam> + <setparam ref="SpecExpon"> + <float>55</float> + </setparam> + <setparam ref="m_Ambient"> + <float4>0 0 0 0</float4> + </setparam> + <setparam ref="m_Diffuse"> + <float4>0 0 0 0</float4> + </setparam> + <setparam ref="m_Specular"> + <float4>1 1 1 1</float4> + </setparam> + <setparam ref="m_Emission"> + <float4>0 0 0 0</float4> + </setparam> + <setparam ref="m_Transparency"> + <float4>0 0 0 0</float4> + </setparam> + <setparam ref="m_Shininess"> + <float>0</float> + </setparam> + <setparam ref="ColorTexture"> + <surface type="2D"> + <init_from>default_color</init_from> + <format>R8G8B8A8</format> + <size>1024 512 1</size> + </surface> + </setparam> + <setparam ref="SpecularTexture"> + <surface type="2D"> + <init_from>checker</init_from> + <format>R8G8B8A8</format> + <size>256 256 1</size> + </surface> + </setparam> + </instance_effect> + </material> + <material id="Blinn" name="Blinn_Material"> + <instance_effect url="#Effect2"> + <technique_hint platform="PC-OGL" ref="Main"/> + <setparam ref="Script"> + <float>0.8</float> + </setparam> + <setparam ref="WorldITXf"> + <float4x4>1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</float4x4> + </setparam> + <setparam ref="WvpXf"> + <float4x4>-0.0188329 1.50929 0.835685 0.835583 -5.4207e-007 2.29578 -0.549411 -0.549344 3.33303 0.00852854 0.00472183 0.00472126 9.23178e-006 -1.5976e-005 5.10234 5.10536</float4x4> + </setparam> + <setparam ref="WorldXf"> + <float4x4>1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</float4x4> + </setparam> + <setparam ref="ViewIXf"> + <float4x4>-0.00565031 -2.10329e-007 0.999984 0 0.549335 0.835597 0.00310409 0 -0.835583 0.549344 -0.00472128 -0 -4.26595 2.8046 -0.0241066 1</float4x4> + </setparam> + <setparam ref="Lamp0Pos"> + <float3>2 2 2</float3> + </setparam> + <setparam ref="Lamp0Color"> + <float4>1 1 1 1</float4> + </setparam> + <setparam ref="AmbiColor"> + <float3>0.07 0.07 0.07</float3> + </setparam> + <setparam ref="Ks"> + <float>0.4</float> + </setparam> + <setparam ref="Eccentricity"> + <float>0.3</float> + </setparam> + <setparam ref="m_Ambient"> + <float4>0 0 0 0</float4> + </setparam> + <setparam ref="m_Diffuse"> + <float4>0 0 0 0</float4> + </setparam> + <setparam ref="m_Specular"> + <float4>0 0 0 0</float4> + </setparam> + <setparam ref="m_Emission"> + <float4>0 0 0 0</float4> + </setparam> + <setparam ref="m_Transparency"> + <float4>0 0 0 0</float4> + </setparam> + <setparam ref="m_Shininess"> + <float>0</float> + </setparam> + <setparam ref="ColorTexture"> + <surface type="2D"> + <init_from>default_color</init_from> + <format>R8G8B8A8</format> + <size>1024 512 1</size> + </surface> + </setparam> + <setparam ref="SpecularTexture"> + <surface type="2D"> + <init_from>checker</init_from> + <format>R8G8B8A8</format> + <size>256 256 1</size> + </surface> + </setparam> + </instance_effect> + </material> + <material id="Lambert" name="Lambert_Material"> + <instance_effect url="#Effect3"> + <technique_hint platform="PC-OGL" ref="Main"/> + <setparam ref="Script"> + <float>0.8</float> + </setparam> + <setparam ref="WorldITXf"> + <float4x4>1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</float4x4> + </setparam> + <setparam ref="WvpXf"> + <float4x4>-0.0188329 1.50929 0.835685 0.835583 -5.4207e-007 2.29578 -0.549411 -0.549344 3.33303 0.00852854 0.00472183 0.00472126 9.23178e-006 -1.5976e-005 5.10234 5.10536</float4x4> + </setparam> + <setparam ref="WorldXf"> + <float4x4>1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</float4x4> + </setparam> + <setparam ref="ViewIXf"> + <float4x4>-0.00565031 -2.10329e-007 0.999984 0 0.549335 0.835597 0.00310409 0 -0.835583 0.549344 -0.00472128 -0 -4.26595 2.8046 -0.0241066 1</float4x4> + </setparam> + <setparam ref="Lamp0Pos"> + <float3>2 2 2</float3> + </setparam> + <setparam ref="Lamp0Color"> + <float4>1 1 1 1</float4> + </setparam> + <setparam ref="AmbiColor"> + <float3>0.07 0.07 0.07</float3> + </setparam> + <setparam ref="m_Ambient"> + <float4>0 0 0 0</float4> + </setparam> + <setparam ref="m_Diffuse"> + <float4>0 0 0 0</float4> + </setparam> + <setparam ref="m_Specular"> + <float4>0 0 0 0</float4> + </setparam> + <setparam ref="m_Emission"> + <float4>0 0 0 0</float4> + </setparam> + <setparam ref="m_Transparency"> + <float4>0 0 0 0</float4> + </setparam> + <setparam ref="m_Shininess"> + <float>0</float> + </setparam> + <setparam ref="ColorTexture"> + <surface type="2D"> + <init_from>default_color</init_from> + <format>R8G8B8A8</format> + <size>1024 512 1</size> + </surface> + </setparam> + </instance_effect> + </material> + <material id="simple" name="simple_Material"> + <instance_effect url="#Effect4"> + <technique_hint platform="PC-OGL" ref="Main"/> + </instance_effect> + </material> + <material id="Phong_bump_reflect" name="Phong_bump_reflect_Material"> + <instance_effect url="#Effect5"> + <technique_hint platform="PC-OGL" ref="Main"/> + <setparam ref="Script"> + <float>0.8</float> + </setparam> + <setparam ref="WorldITXf"> + <float4x4>1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</float4x4> + </setparam> + <setparam ref="WvpXf"> + <float4x4>-0.0188329 1.50929 0.835685 0.835583 -5.4207e-007 2.29578 -0.549411 -0.549344 3.33303 0.00852854 0.00472183 0.00472126 9.23178e-006 -1.5976e-005 5.10234 5.10536</float4x4> + </setparam> + <setparam ref="WorldXf"> + <float4x4>1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</float4x4> + </setparam> + <setparam ref="ViewIXf"> + <float4x4>-0.00565031 -2.10329e-007 0.999984 0 0.549335 0.835597 0.00310409 0 -0.835583 0.549344 -0.00472128 -0 -4.26595 2.8046 -0.0241066 1</float4x4> + </setparam> + <setparam ref="Lamp0Pos"> + <float3>2 2 2</float3> + </setparam> + <setparam ref="Lamp0Color"> + <float4>1 1 1 1</float4> + </setparam> + <setparam ref="AmbiColor"> + <float3>0.07 0.07 0.07</float3> + </setparam> + <setparam ref="Ks"> + <float>0.4</float> + </setparam> + <setparam ref="SpecExpon"> + <float>55</float> + </setparam> + <setparam ref="Bump"> + <float>1</float> + </setparam> + <setparam ref="Kr"> + <float>0.5</float> + </setparam> + <setparam ref="ColorTexture"> + <surface type="2D"> + <init_from>default_color</init_from> + <format>R8G8B8A8</format> + <size>1024 512 1</size> + </surface> + </setparam> + <setparam ref="NormalTexture"> + <surface type="2D"> + <init_from>default_bump_normal</init_from> + <format>R8G8B8A8</format> + <size>1024 512 1</size> + </surface> + </setparam> + <setparam ref="EnvTexture"> + <surface type="CUBE"> + <init_from>default_reflection</init_from> + <format>R8G8B8A8</format> + <size>512 512 1</size> + </surface> + </setparam> + </instance_effect> + </material> + <material id="Blinn_bump_reflect" name="Blinn_bump_reflect_Material"> + <instance_effect url="#Effect6"> + <technique_hint platform="PC-OGL" ref="Main"/> + <setparam ref="Script"> + <float>0.8</float> + </setparam> + <setparam ref="WorldITXf"> + <float4x4>1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</float4x4> + </setparam> + <setparam ref="WvpXf"> + <float4x4>-0.0188329 1.50929 0.835685 0.835583 -5.4207e-007 2.29578 -0.549411 -0.549344 3.33303 0.00852854 0.00472183 0.00472126 9.23178e-006 -1.5976e-005 5.10234 5.10536</float4x4> + </setparam> + <setparam ref="WorldXf"> + <float4x4>1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</float4x4> + </setparam> + <setparam ref="ViewIXf"> + <float4x4>-0.00565031 -2.10329e-007 0.999984 0 0.549335 0.835597 0.00310409 0 -0.835583 0.549344 -0.00472128 -0 -4.26595 2.8046 -0.0241066 1</float4x4> + </setparam> + <setparam ref="Lamp0Pos"> + <float3>2 2 2</float3> + </setparam> + <setparam ref="Lamp0Color"> + <float4>1 1 1 1</float4> + </setparam> + <setparam ref="AmbiColor"> + <float3>0.07 0.07 0.07</float3> + </setparam> + <setparam ref="Ks"> + <float>0.4</float> + </setparam> + <setparam ref="Eccentricity"> + <float>0.3</float> + </setparam> + <setparam ref="Bump"> + <float>1</float> + </setparam> + <setparam ref="Kr"> + <float>0.5</float> + </setparam> + <setparam ref="ColorTexture"> + <surface type="2D"> + <init_from>default_color</init_from> + <format>R8G8B8A8</format> + <size>1024 512 1</size> + </surface> + </setparam> + <setparam ref="NormalTexture"> + <surface type="2D"> + <init_from>default_bump_normal</init_from> + <format>R8G8B8A8</format> + <size>1024 512 1</size> + </surface> + </setparam> + <setparam ref="EnvTexture"> + <surface type="CUBE"> + <init_from>default_reflection</init_from> + <format>R8G8B8A8</format> + <size>512 512 1</size> + </surface> + </setparam> + </instance_effect> + </material> + <material id="Lambert_bump_reflect" name="Lambert_bump_reflect_Material"> + <instance_effect url="#Effect7"> + <technique_hint platform="PC-OGL" ref="Main"/> + <setparam ref="Script"> + <float>0.8</float> + </setparam> + <setparam ref="WorldITXf"> + <float4x4>1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</float4x4> + </setparam> + <setparam ref="WvpXf"> + <float4x4>-0.0188329 1.50929 0.835685 0.835583 -5.4207e-007 2.29578 -0.549411 -0.549344 3.33303 0.00852854 0.00472183 0.00472126 9.23178e-006 -1.5976e-005 5.10234 5.10536</float4x4> + </setparam> + <setparam ref="WorldXf"> + <float4x4>1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</float4x4> + </setparam> + <setparam ref="ViewIXf"> + <float4x4>-0.00565031 -2.10329e-007 0.999984 0 0.549335 0.835597 0.00310409 0 -0.835583 0.549344 -0.00472128 -0 -4.26595 2.8046 -0.0241066 1</float4x4> + </setparam> + <setparam ref="Lamp0Pos"> + <float3>-0.5 2 1.25</float3> + </setparam> + <setparam ref="Lamp0Color"> + <float3>1 1 1</float3> + </setparam> + <setparam ref="AmbiColor"> + <float3>0.07 0.07 0.07</float3> + </setparam> + <setparam ref="Bump"> + <float>1</float> + </setparam> + <setparam ref="Kr"> + <float>1</float> + </setparam> + <setparam ref="KrMin"> + <float>0.05</float> + </setparam> + <setparam ref="FresExp"> + <float>4</float> + </setparam> + <setparam ref="ColorTexture"> + <surface type="2D"> + <init_from>default_color</init_from> + <format>R8G8B8A8</format> + <size>1024 512 1</size> + </surface> + </setparam> + <setparam ref="NormalTexture"> + <surface type="2D"> + <init_from>default_bump_normal</init_from> + <format>R8G8B8A8</format> + <size>1024 512 1</size> + </surface> + </setparam> + <setparam ref="EnvTexture"> + <surface type="CUBE"> + <init_from>default_reflection</init_from> + <format>R8G8B8A8</format> + <size>512 512 1</size> + </surface> + </setparam> + </instance_effect> + </material> + </library_materials> + <library_geometries> + <geometry id="Sphere" name="Sphere"> + <mesh> + <source id="FXStream" name="FXStream"> + <float_array id="FXStream-array" count="2268">0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 -0 -1 -0 -0 -1 -0 -0 -1 -0 -0 -1 -0 -0 -1 -0 -0 -1 -0 -0 -1 -0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0.116093 -0.993238 0 0.112719 -0.993238 0.0277828 0.102795 -0.993238 0.0539509 0.0868966 -0.993238 0.0769837 0.0659481 -0.993238 0.0955424 0.041167 -0.993238 0.108549 0.0139934 -0.993238 0.115246 -0.0139934 -0.993238 0.115246 -0.041167 -0.993238 0.108549 -0.0659482 -0.993238 0.0955424 -0.0868966 -0.993238 0.0769837 -0.102795 -0.993238 0.0539509 -0.112719 -0.993238 0.0277828 -0.116093 -0.993238 -1.01491e-008 -0.112719 -0.993238 -0.0277828 -0.102795 -0.993238 -0.0539509 -0.0868966 -0.993238 -0.0769837 -0.0659481 -0.993238 -0.0955424 -0.041167 -0.993238 -0.108549 -0.0139934 -0.993238 -0.115246 0.0139934 -0.993238 -0.115246 0.041167 -0.993238 -0.108548 0.0659482 -0.993238 -0.0955424 0.0868966 -0.993238 -0.0769836 0.102795 -0.993238 -0.0539509 0.112719 -0.993238 -0.0277828 0.116093 -0.993238 2.02983e-008 0.230616 -0.973045 0 0.223915 -0.973045 0.05519 0.2042 -0.973045 0.107173 0.172618 -0.973045 0.152927 0.131005 -0.973045 0.189793 0.0817775 -0.973045 0.21563 0.0277977 -0.973045 0.228934 -0.0277977 -0.973045 0.228934 -0.0817775 -0.973045 0.21563 -0.131005 -0.973045 0.189793 -0.172618 -0.973045 0.152927 -0.2042 -0.973045 0.107173 -0.223915 -0.973045 0.05519 -0.230616 -0.973045 -2.01611e-008 -0.223915 -0.973045 -0.05519 -0.2042 -0.973045 -0.107173 -0.172618 -0.973045 -0.152927 -0.131005 -0.973045 -0.189793 -0.0817774 -0.973045 -0.21563 -0.0277977 -0.973045 -0.228934 0.0277977 -0.973045 -0.228934 0.0817776 -0.973045 -0.21563 0.131005 -0.973045 -0.189793 0.172619 -0.973045 -0.152927 0.2042 -0.973045 -0.107173 0.223915 -0.973045 -0.05519 0.230616 -0.973045 4.03222e-008 0.34202 -0.939693 0 0.332082 -0.939693 0.0818508 0.302844 -0.939693 0.158945 0.256006 -0.939693 0.226801 0.19429 -0.939693 0.281477 0.121282 -0.939693 0.319794 0.041226 -0.939693 0.339526 -0.041226 -0.939693 0.339526 -0.121282 -0.939693 0.319794 -0.19429 -0.939693 0.281477 -0.256006 -0.939693 0.226801 -0.302844 -0.939693 0.158945 -0.332082 -0.939693 0.0818508 -0.34202 -0.939693 -2.99004e-008 -0.332082 -0.939693 -0.0818508 -0.302844 -0.939693 -0.158945 -0.256006 -0.939693 -0.226801 -0.19429 -0.939693 -0.281477 -0.121282 -0.939693 -0.319794 -0.041226 -0.939693 -0.339526 0.041226 -0.939693 -0.339526 0.121282 -0.939693 -0.319794 0.19429 -0.939693 -0.281477 0.256006 -0.939693 -0.226801 0.302844 -0.939693 -0.158945 0.332082 -0.939693 -0.0818508 0.34202 -0.939693 5.98007e-008 0.448799 -0.893633 0 0.435758 -0.893633 0.107405 0.397392 -0.893633 0.208567 0.335931 -0.893633 0.297609 0.254947 -0.893633 0.369354 0.159146 -0.893633 0.419635 0.0540968 -0.893633 0.445527 -0.0540968 -0.893633 0.445527 -0.159146 -0.893633 0.419634 -0.254947 -0.893633 0.369354 -0.335931 -0.893633 0.297609 -0.397392 -0.893633 0.208567 -0.435758 -0.893633 0.107405 -0.448799 -0.893633 -3.92353e-008 -0.435758 -0.893633 -0.107405 -0.397392 -0.893633 -0.208567 -0.335931 -0.893633 -0.297609 -0.254947 -0.893633 -0.369355 -0.159146 -0.893633 -0.419635 -0.0540968 -0.893633 -0.445527 0.0540968 -0.893633 -0.445527 0.159146 -0.893633 -0.419634 0.254947 -0.893633 -0.369354 0.335931 -0.893633 -0.297609 0.397392 -0.893633 -0.208567 0.435758 -0.893633 -0.107405 0.448799 -0.893633 7.84705e-008 0.549509 -0.835488 0 0.533541 -0.835488 0.131506 0.486566 -0.835488 0.25537 0.411313 -0.835488 0.364392 0.312157 -0.835488 0.452237 0.194859 -0.835488 0.5138 0.066236 -0.835488 0.545502 -0.066236 -0.835488 0.545502 -0.194859 -0.835488 0.5138 -0.312157 -0.835488 0.452237 -0.411313 -0.835488 0.364392 -0.486566 -0.835488 0.255369 -0.533541 -0.835488 0.131506 -0.549509 -0.835488 -4.80396e-008 -0.533541 -0.835488 -0.131506 -0.486566 -0.835488 -0.25537 -0.411313 -0.835488 -0.364392 -0.312157 -0.835488 -0.452237 -0.194858 -0.835488 -0.5138 -0.066236 -0.835488 -0.545502 0.066236 -0.835488 -0.545502 0.194859 -0.835488 -0.5138 0.312157 -0.835488 -0.452237 0.411313 -0.835488 -0.364392 0.486566 -0.835488 -0.25537 0.533541 -0.835488 -0.131506 0.549509 -0.835488 9.60792e-008 0.642788 -0.766044 0 0.624109 -0.766044 0.153829 0.56916 -0.766044 0.298718 0.481133 -0.766044 0.426247 0.365145 -0.766044 0.529004 0.227936 -0.766044 0.601017 0.0774795 -0.766044 0.638101 -0.0774795 -0.766044 0.638101 -0.227936 -0.766044 0.601017 -0.365145 -0.766044 0.529004 -0.481133 -0.766044 0.426247 -0.56916 -0.766044 0.298718 -0.624109 -0.766044 0.153829 -0.642788 -0.766044 -5.61943e-008 -0.624109 -0.766044 -0.153829 -0.56916 -0.766044 -0.298718 -0.481133 -0.766044 -0.426247 -0.365145 -0.766044 -0.529004 -0.227935 -0.766044 -0.601017 -0.0774795 -0.766044 -0.638101 0.0774795 -0.766044 -0.638101 0.227936 -0.766044 -0.601017 0.365145 -0.766044 -0.529004 0.481134 -0.766044 -0.426247 0.56916 -0.766044 -0.298718 0.624109 -0.766044 -0.153829 0.642788 -0.766044 1.12389e-007 0.727374 -0.686242 0 0.706237 -0.686242 0.174072 0.644057 -0.686242 0.338027 0.544447 -0.686242 0.482338 0.413195 -0.686242 0.598617 0.25793 -0.686242 0.680106 0.0876752 -0.686242 0.72207 -0.0876753 -0.686242 0.72207 -0.25793 -0.686242 0.680106 -0.413195 -0.686242 0.598617 -0.544447 -0.686242 0.482338 -0.644057 -0.686242 0.338027 -0.706237 -0.686242 0.174072 -0.727374 -0.686242 -6.3589e-008 -0.706237 -0.686242 -0.174072 -0.644057 -0.686242 -0.338027 -0.544447 -0.686242 -0.482338 -0.413195 -0.686242 -0.598617 -0.25793 -0.686242 -0.680106 -0.0876752 -0.686242 -0.72207 0.0876752 -0.686242 -0.72207 0.25793 -0.686242 -0.680106 0.413195 -0.686242 -0.598617 0.544447 -0.686242 -0.482338 0.644057 -0.686242 -0.338027 0.706237 -0.686242 -0.174072 0.727374 -0.686242 1.27178e-007 0.802123 -0.597159 0 0.778815 -0.597159 0.191961 0.710245 -0.597159 0.372765 0.600398 -0.597159 0.531906 0.455658 -0.597159 0.660134 0.284437 -0.597159 0.749998 0.0966853 -0.597159 0.796275 -0.0966853 -0.597159 0.796275 -0.284437 -0.597159 0.749998 -0.455658 -0.597159 0.660134 -0.600398 -0.597159 0.531906 -0.710245 -0.597159 0.372765 -0.778815 -0.597159 0.191961 -0.802123 -0.597159 -7.01238e-008 -0.778815 -0.597159 -0.191961 -0.710245 -0.597159 -0.372765 -0.600398 -0.597159 -0.531906 -0.455658 -0.597159 -0.660135 -0.284437 -0.597159 -0.749998 -0.0966853 -0.597159 -0.796275 0.0966853 -0.597159 -0.796275 0.284437 -0.597159 -0.749998 0.455658 -0.597159 -0.660134 0.600398 -0.597159 -0.531906 0.710245 -0.597159 -0.372765 0.778815 -0.597159 -0.191961 0.802123 -0.597159 1.40248e-007 0.866025 -0.5 0 0.84086 -0.5 0.207253 0.766827 -0.5 0.402462 0.648229 -0.5 0.574281 0.491958 -0.5 0.712725 0.307097 -0.5 0.809748 0.104388 -0.5 0.859711 -0.104388 -0.5 0.859711 -0.307097 -0.5 0.809748 -0.491959 -0.5 0.712725 -0.648229 -0.5 0.574281 -0.766827 -0.5 0.402462 -0.84086 -0.5 0.207253 -0.866025 -0.5 -7.57103e-008 -0.84086 -0.5 -0.207254 -0.766827 -0.5 -0.402462 -0.648229 -0.5 -0.574281 -0.491958 -0.5 -0.712725 -0.307097 -0.5 -0.809748 -0.104388 -0.5 -0.859711 0.104388 -0.5 -0.859711 0.307097 -0.5 -0.809748 0.491959 -0.5 -0.712725 0.64823 -0.5 -0.574281 0.766827 -0.5 -0.402462 0.84086 -0.5 -0.207253 0.866025 -0.5 1.51421e-007 0.918216 -0.39608 0 0.891534 -0.39608 0.219744 0.81304 -0.39608 0.426716 0.687295 -0.39608 0.60889 0.521606 -0.39608 0.755677 0.325604 -0.39608 0.858547 0.110679 -0.39608 0.911521 -0.110679 -0.39608 0.911521 -0.325604 -0.39608 0.858547 -0.521606 -0.39608 0.755677 -0.687295 -0.39608 0.60889 -0.81304 -0.39608 0.426716 -0.891534 -0.39608 0.219744 -0.918216 -0.39608 -8.0273e-008 -0.891534 -0.39608 -0.219744 -0.81304 -0.39608 -0.426716 -0.687295 -0.39608 -0.60889 -0.521606 -0.39608 -0.755677 -0.325604 -0.39608 -0.858547 -0.110679 -0.39608 -0.911521 0.110679 -0.39608 -0.911521 0.325604 -0.39608 -0.858547 0.521606 -0.39608 -0.755677 0.687295 -0.39608 -0.60889 0.81304 -0.39608 -0.426716 0.891534 -0.39608 -0.219743 0.918216 -0.39608 1.60546e-007 0.95799 -0.286803 0 0.930152 -0.286803 0.229262 0.848258 -0.286803 0.4452 0.717065 -0.286803 0.635265 0.5442 -0.286803 0.78841 0.339708 -0.286803 0.895736 0.115473 -0.286803 0.951005 -0.115473 -0.286803 0.951005 -0.339708 -0.286803 0.895736 -0.5442 -0.286803 0.78841 -0.717065 -0.286803 0.635265 -0.848258 -0.286803 0.4452 -0.930152 -0.286803 0.229262 -0.95799 -0.286803 -8.37501e-008 -0.930152 -0.286803 -0.229262 -0.848258 -0.286803 -0.4452 -0.717065 -0.286803 -0.635265 -0.5442 -0.286803 -0.78841 -0.339707 -0.286803 -0.895736 -0.115473 -0.286803 -0.951005 0.115473 -0.286803 -0.951005 0.339708 -0.286803 -0.895736 0.5442 -0.286803 -0.78841 0.717066 -0.286803 -0.635264 0.848258 -0.286803 -0.4452 0.930152 -0.286803 -0.229262 0.95799 -0.286803 1.675e-007 0.984808 -0.173648 0 0.956191 -0.173648 0.23568 0.872004 -0.173648 0.457663 0.737139 -0.173648 0.653048 0.559435 -0.173648 0.810481 0.349218 -0.173648 0.920811 0.118705 -0.173648 0.977627 -0.118706 -0.173648 0.977627 -0.349218 -0.173648 0.920811 -0.559435 -0.173648 0.810481 -0.737139 -0.173648 0.653048 -0.872004 -0.173648 0.457663 -0.956191 -0.173648 0.23568 -0.984808 -0.173648 -8.60946e-008 -0.956191 -0.173648 -0.23568 -0.872004 -0.173648 -0.457663 -0.737139 -0.173648 -0.653048 -0.559434 -0.173648 -0.810481 -0.349217 -0.173648 -0.920811 -0.118705 -0.173648 -0.977627 0.118706 -0.173648 -0.977627 0.349218 -0.173648 -0.920811 0.559435 -0.173648 -0.810481 0.737139 -0.173648 -0.653048 0.872004 -0.173648 -0.457663 0.956191 -0.173648 -0.23568 0.984808 -0.173648 1.72189e-007 0.998308 -0.0581448 0 0.969299 -0.0581448 0.238911 0.883958 -0.0581448 0.463937 0.747244 -0.0581448 0.662001 0.567104 -0.0581448 0.821592 0.354005 -0.0581448 0.933434 0.120333 -0.0581448 0.991029 -0.120333 -0.0581448 0.991029 -0.354005 -0.0581448 0.933434 -0.567104 -0.0581448 0.821591 -0.747244 -0.0581448 0.662001 -0.883958 -0.0581448 0.463937 -0.969299 -0.0581448 0.238911 -0.998308 -0.0581448 -8.72749e-008 -0.969299 -0.0581448 -0.238911 -0.883958 -0.0581448 -0.463937 -0.747244 -0.0581448 -0.662001 -0.567104 -0.0581448 -0.821592 -0.354005 -0.0581448 -0.933434 -0.120333 -0.0581448 -0.991029 0.120333 -0.0581448 -0.991029 0.354005 -0.0581448 -0.933434 0.567104 -0.0581448 -0.821591 0.747245 -0.0581448 -0.662001 0.883958 -0.0581448 -0.463937 0.969299 -0.0581448 -0.238911 0.998308 -0.0581448 1.7455e-007 0.998308 0.0581448 0 0.969299 0.0581448 0.238911 0.883958 0.0581448 0.463937 0.747244 0.0581448 0.662001 0.567104 0.0581448 0.821592 0.354005 0.0581448 0.933434 0.120333 0.0581448 0.991029 -0.120333 0.0581448 0.991029 -0.354005 0.0581448 0.933434 -0.567104 0.0581448 0.821591 -0.747244 0.0581448 0.662001 -0.883958 0.0581448 0.463937 -0.969299 0.0581448 0.238911 -0.998308 0.0581448 -8.72749e-008 -0.969299 0.0581448 -0.238911 -0.883958 0.0581448 -0.463937 -0.747244 0.0581448 -0.662001 -0.567104 0.0581448 -0.821592 -0.354005 0.0581448 -0.933434 -0.120333 0.0581448 -0.991029 0.120333 0.0581448 -0.991029 0.354005 0.0581448 -0.933434 0.567104 0.0581448 -0.821591 0.747245 0.0581448 -0.662001 0.883958 0.0581448 -0.463937 0.969299 0.0581448 -0.238911 0.998308 0.0581448 1.7455e-007 0.984808 0.173648 0 0.956191 0.173648 0.23568 0.872004 0.173648 0.457663 0.737139 0.173648 0.653048 0.559435 0.173648 0.810481 0.349218 0.173648 0.920811 0.118705 0.173648 0.977627 -0.118706 0.173648 0.977627 -0.349218 0.173648 0.920811 -0.559435 0.173648 0.810481 -0.737139 0.173648 0.653048 -0.872004 0.173648 0.457663 -0.956191 0.173648 0.23568 -0.984808 0.173648 -8.60946e-008 -0.956191 0.173648 -0.23568 -0.872004 0.173648 -0.457663 -0.737139 0.173648 -0.653048 -0.559434 0.173648 -0.810481 -0.349217 0.173648 -0.920811 -0.118705 0.173648 -0.977627 0.118706 0.173648 -0.977627 0.349218 0.173648 -0.920811 0.559435 0.173648 -0.810481 0.737139 0.173648 -0.653048 0.872004 0.173648 -0.457663 0.956191 0.173648 -0.23568 0.984808 0.173648 1.72189e-007 0.95799 0.286803 0 0.930152 0.286803 0.229262 0.848258 0.286803 0.4452 0.717065 0.286803 0.635265 0.5442 0.286803 0.78841 0.339708 0.286803 0.895736 0.115473 0.286803 0.951005 -0.115473 0.286803 0.951005 -0.339708 0.286803 0.895736 -0.5442 0.286803 0.78841 -0.717065 0.286803 0.635265 -0.848258 0.286803 0.4452 -0.930152 0.286803 0.229262 -0.95799 0.286803 -8.37501e-008 -0.930152 0.286803 -0.229262 -0.848258 0.286803 -0.4452 -0.717065 0.286803 -0.635265 -0.5442 0.286803 -0.78841 -0.339707 0.286803 -0.895736 -0.115473 0.286803 -0.951005 0.115473 0.286803 -0.951005 0.339708 0.286803 -0.895736 0.5442 0.286803 -0.78841 0.717066 0.286803 -0.635264 0.848258 0.286803 -0.4452 0.930152 0.286803 -0.229262 0.95799 0.286803 1.675e-007 0.918216 0.39608 0 0.891534 0.39608 0.219744 0.81304 0.39608 0.426716 0.687295 0.39608 0.60889 0.521606 0.39608 0.755677 0.325604 0.39608 0.858547 0.110679 0.39608 0.911521 -0.110679 0.39608 0.911521 -0.325604 0.39608 0.858547 -0.521606 0.39608 0.755677 -0.687295 0.39608 0.60889 -0.81304 0.39608 0.426716 -0.891534 0.39608 0.219744 -0.918216 0.39608 -8.0273e-008 -0.891534 0.39608 -0.219744 -0.81304 0.39608 -0.426716 -0.687295 0.39608 -0.60889 -0.521606 0.39608 -0.755677 -0.325604 0.39608 -0.858547 -0.110679 0.39608 -0.911521 0.110679 0.39608 -0.911521 0.325604 0.39608 -0.858547 0.521606 0.39608 -0.755677 0.687295 0.39608 -0.60889 0.81304 0.39608 -0.426716 0.891534 0.39608 -0.219743 0.918216 0.39608 1.60546e-007 0.866025 0.5 0 0.84086 0.5 0.207253 0.766827 0.5 0.402462 0.648229 0.5 0.574281 0.491958 0.5 0.712725 0.307097 0.5 0.809748 0.104388 0.5 0.859711 -0.104388 0.5 0.859711 -0.307097 0.5 0.809748 -0.491959 0.5 0.712725 -0.648229 0.5 0.574281 -0.766827 0.5 0.402462 -0.84086 0.5 0.207253 -0.866025 0.5 -7.57103e-008 -0.84086 0.5 -0.207254 -0.766827 0.5 -0.402462 -0.648229 0.5 -0.574281 -0.491958 0.5 -0.712725 -0.307097 0.5 -0.809748 -0.104388 0.5 -0.859711 0.104388 0.5 -0.859711 0.307097 0.5 -0.809748 0.491959 0.5 -0.712725 0.64823 0.5 -0.574281 0.766827 0.5 -0.402462 0.84086 0.5 -0.207253 0.866025 0.5 1.51421e-007 0.802123 0.597159 0 0.778815 0.597159 0.191961 0.710245 0.597159 0.372765 0.600398 0.597159 0.531906 0.455658 0.597159 0.660134 0.284437 0.597159 0.749998 0.0966853 0.597159 0.796275 -0.0966853 0.597159 0.796275 -0.284437 0.597159 0.749998 -0.455658 0.597159 0.660134 -0.600398 0.597159 0.531906 -0.710245 0.597159 0.372765 -0.778815 0.597159 0.191961 -0.802123 0.597159 -7.01238e-008 -0.778815 0.597159 -0.191961 -0.710245 0.597159 -0.372765 -0.600398 0.597159 -0.531906 -0.455658 0.597159 -0.660135 -0.284437 0.597159 -0.749998 -0.0966853 0.597159 -0.796275 0.0966853 0.597159 -0.796275 0.284437 0.597159 -0.749998 0.455658 0.597159 -0.660134 0.600398 0.597159 -0.531906 0.710245 0.597159 -0.372765 0.778815 0.597159 -0.191961 0.802123 0.597159 1.40248e-007 0.727374 0.686242 0 0.706237 0.686242 0.174072 0.644057 0.686242 0.338027 0.544447 0.686242 0.482338 0.413195 0.686242 0.598617 0.25793 0.686242 0.680106 0.0876752 0.686242 0.72207 -0.0876753 0.686242 0.72207 -0.25793 0.686242 0.680106 -0.413195 0.686242 0.598617 -0.544447 0.686242 0.482338 -0.644057 0.686242 0.338027 -0.706237 0.686242 0.174072 -0.727374 0.686242 -6.3589e-008 -0.706237 0.686242 -0.174072 -0.644057 0.686242 -0.338027 -0.544447 0.686242 -0.482338 -0.413195 0.686242 -0.598617 -0.25793 0.686242 -0.680106 -0.0876752 0.686242 -0.72207 0.0876752 0.686242 -0.72207 0.25793 0.686242 -0.680106 0.413195 0.686242 -0.598617 0.544447 0.686242 -0.482338 0.644057 0.686242 -0.338027 0.706237 0.686242 -0.174072 0.727374 0.686242 1.27178e-007 0.642788 0.766044 0 0.624109 0.766044 0.153829 0.56916 0.766044 0.298718 0.481133 0.766044 0.426247 0.365145 0.766044 0.529004 0.227936 0.766044 0.601017 0.0774795 0.766044 0.638101 -0.0774795 0.766044 0.638101 -0.227936 0.766044 0.601017 -0.365145 0.766044 0.529004 -0.481133 0.766044 0.426247 -0.56916 0.766044 0.298718 -0.624109 0.766044 0.153829 -0.642788 0.766044 -5.61943e-008 -0.624109 0.766044 -0.153829 -0.56916 0.766044 -0.298718 -0.481133 0.766044 -0.426247 -0.365145 0.766044 -0.529004 -0.227935 0.766044 -0.601017 -0.0774795 0.766044 -0.638101 0.0774795 0.766044 -0.638101 0.227936 0.766044 -0.601017 0.365145 0.766044 -0.529004 0.481134 0.766044 -0.426247 0.56916 0.766044 -0.298718 0.624109 0.766044 -0.153829 0.642788 0.766044 1.12389e-007 0.549509 0.835488 0 0.533541 0.835488 0.131506 0.486566 0.835488 0.25537 0.411313 0.835488 0.364392 0.312157 0.835488 0.452237 0.194859 0.835488 0.5138 0.066236 0.835488 0.545502 -0.066236 0.835488 0.545502 -0.194859 0.835488 0.5138 -0.312157 0.835488 0.452237 -0.411313 0.835488 0.364392 -0.486566 0.835488 0.255369 -0.533541 0.835488 0.131506 -0.549509 0.835488 -4.80396e-008 -0.533541 0.835488 -0.131506 -0.486566 0.835488 -0.25537 -0.411313 0.835488 -0.364392 -0.312157 0.835488 -0.452237 -0.194858 0.835488 -0.5138 -0.066236 0.835488 -0.545502 0.066236 0.835488 -0.545502 0.194859 0.835488 -0.5138 0.312157 0.835488 -0.452237 0.411313 0.835488 -0.364392 0.486566 0.835488 -0.25537 0.533541 0.835488 -0.131506 0.549509 0.835488 9.60792e-008 0.448799 0.893633 0 0.435758 0.893633 0.107405 0.397392 0.893633 0.208567 0.335931 0.893633 0.297609 0.254947 0.893633 0.369354 0.159146 0.893633 0.419635 0.0540968 0.893633 0.445527 -0.0540968 0.893633 0.445527 -0.159146 0.893633 0.419634 -0.254947 0.893633 0.369354 -0.335931 0.893633 0.297609 -0.397392 0.893633 0.208567 -0.435758 0.893633 0.107405 -0.448799 0.893633 -3.92353e-008 -0.435758 0.893633 -0.107405 -0.397392 0.893633 -0.208567 -0.335931 0.893633 -0.297609 -0.254947 0.893633 -0.369355 -0.159146 0.893633 -0.419635 -0.0540968 0.893633 -0.445527 0.0540968 0.893633 -0.445527 0.159146 0.893633 -0.419634 0.254947 0.893633 -0.369354 0.335931 0.893633 -0.297609 0.397392 0.893633 -0.208567 0.435758 0.893633 -0.107405 0.448799 0.893633 7.84705e-008 0.34202 0.939693 0 0.332082 0.939693 0.0818508 0.302844 0.939693 0.158945 0.256006 0.939693 0.226801 0.19429 0.939693 0.281477 0.121282 0.939693 0.319794 0.041226 0.939693 0.339526 -0.041226 0.939693 0.339526 -0.121282 0.939693 0.319794 -0.19429 0.939693 0.281477 -0.256006 0.939693 0.226801 -0.302844 0.939693 0.158945 -0.332082 0.939693 0.0818508 -0.34202 0.939693 -2.99004e-008 -0.332082 0.939693 -0.0818508 -0.302844 0.939693 -0.158945 -0.256006 0.939693 -0.226801 -0.19429 0.939693 -0.281477 -0.121282 0.939693 -0.319794 -0.041226 0.939693 -0.339526 0.041226 0.939693 -0.339526 0.121282 0.939693 -0.319794 0.19429 0.939693 -0.281477 0.256006 0.939693 -0.226801 0.302844 0.939693 -0.158945 0.332082 0.939693 -0.0818508 0.34202 0.939693 5.98007e-008 0.230616 0.973045 0 0.223915 0.973045 0.05519 0.2042 0.973045 0.107173 0.172618 0.973045 0.152927 0.131005 0.973045 0.189793 0.0817775 0.973045 0.21563 0.0277977 0.973045 0.228934 -0.0277977 0.973045 0.228934 -0.0817775 0.973045 0.21563 -0.131005 0.973045 0.189793 -0.172618 0.973045 0.152927 -0.2042 0.973045 0.107173 -0.223915 0.973045 0.05519 -0.230616 0.973045 -2.01611e-008 -0.223915 0.973045 -0.05519 -0.2042 0.973045 -0.107173 -0.172618 0.973045 -0.152927 -0.131005 0.973045 -0.189793 -0.0817774 0.973045 -0.21563 -0.0277977 0.973045 -0.228934 0.0277977 0.973045 -0.228934 0.0817776 0.973045 -0.21563 0.131005 0.973045 -0.189793 0.172619 0.973045 -0.152927 0.2042 0.973045 -0.107173 0.223915 0.973045 -0.05519 0.230616 0.973045 4.03222e-008 0.116093 0.993238 0 0.112719 0.993238 0.0277828 0.102795 0.993238 0.0539509 0.0868966 0.993238 0.0769837 0.0659481 0.993238 0.0955424 0.041167 0.993238 0.108549 0.0139934 0.993238 0.115246 -0.0139934 0.993238 0.115246 -0.041167 0.993238 0.108549 -0.0659482 0.993238 0.0955424 -0.0868966 0.993238 0.0769837 -0.102795 0.993238 0.0539509 -0.112719 0.993238 0.0277828 -0.116093 0.993238 -1.01491e-008 -0.112719 0.993238 -0.0277828 -0.102795 0.993238 -0.0539509 -0.0868966 0.993238 -0.0769837 -0.0659481 0.993238 -0.0955424 -0.041167 0.993238 -0.108549 -0.0139934 0.993238 -0.115246 0.0139934 0.993238 -0.115246 0.041167 0.993238 -0.108548 0.0659482 0.993238 -0.0955424 0.0868966 0.993238 -0.0769836 0.102795 0.993238 -0.0539509 0.112719 0.993238 -0.0277828 0.116093 0.993238 2.02983e-008 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0</float_array> + <technique_common> + <accessor count="756" source="#FXStream-array" stride="3"> + <param name="X" type="float"/> + <param name="Y" type="float"/> + <param name="Z" type="float"/> + </accessor> + </technique_common> + </source> + <source id="FXStream2" name="FXStream"> + <float_array id="FXStream2-array" count="2268">0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 -0 -1 -0 -0 -1 -0 -0 -1 -0 -0 -1 -0 -0 -1 -0 -0 -1 -0 -0 -1 -0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0.116093 -0.993238 0 0.112719 -0.993238 0.0277828 0.102795 -0.993238 0.0539509 0.0868966 -0.993238 0.0769837 0.0659481 -0.993238 0.0955424 0.041167 -0.993238 0.108549 0.0139934 -0.993238 0.115246 -0.0139934 -0.993238 0.115246 -0.041167 -0.993238 0.108549 -0.0659482 -0.993238 0.0955424 -0.0868966 -0.993238 0.0769837 -0.102795 -0.993238 0.0539509 -0.112719 -0.993238 0.0277828 -0.116093 -0.993238 -1.01491e-008 -0.112719 -0.993238 -0.0277828 -0.102795 -0.993238 -0.0539509 -0.0868966 -0.993238 -0.0769837 -0.0659481 -0.993238 -0.0955424 -0.041167 -0.993238 -0.108549 -0.0139934 -0.993238 -0.115246 0.0139934 -0.993238 -0.115246 0.041167 -0.993238 -0.108548 0.0659482 -0.993238 -0.0955424 0.0868966 -0.993238 -0.0769836 0.102795 -0.993238 -0.0539509 0.112719 -0.993238 -0.0277828 0.116093 -0.993238 2.02983e-008 0.230616 -0.973045 0 0.223915 -0.973045 0.05519 0.2042 -0.973045 0.107173 0.172618 -0.973045 0.152927 0.131005 -0.973045 0.189793 0.0817775 -0.973045 0.21563 0.0277977 -0.973045 0.228934 -0.0277977 -0.973045 0.228934 -0.0817775 -0.973045 0.21563 -0.131005 -0.973045 0.189793 -0.172618 -0.973045 0.152927 -0.2042 -0.973045 0.107173 -0.223915 -0.973045 0.05519 -0.230616 -0.973045 -2.01611e-008 -0.223915 -0.973045 -0.05519 -0.2042 -0.973045 -0.107173 -0.172618 -0.973045 -0.152927 -0.131005 -0.973045 -0.189793 -0.0817774 -0.973045 -0.21563 -0.0277977 -0.973045 -0.228934 0.0277977 -0.973045 -0.228934 0.0817776 -0.973045 -0.21563 0.131005 -0.973045 -0.189793 0.172619 -0.973045 -0.152927 0.2042 -0.973045 -0.107173 0.223915 -0.973045 -0.05519 0.230616 -0.973045 4.03222e-008 0.34202 -0.939693 0 0.332082 -0.939693 0.0818508 0.302844 -0.939693 0.158945 0.256006 -0.939693 0.226801 0.19429 -0.939693 0.281477 0.121282 -0.939693 0.319794 0.041226 -0.939693 0.339526 -0.041226 -0.939693 0.339526 -0.121282 -0.939693 0.319794 -0.19429 -0.939693 0.281477 -0.256006 -0.939693 0.226801 -0.302844 -0.939693 0.158945 -0.332082 -0.939693 0.0818508 -0.34202 -0.939693 -2.99004e-008 -0.332082 -0.939693 -0.0818508 -0.302844 -0.939693 -0.158945 -0.256006 -0.939693 -0.226801 -0.19429 -0.939693 -0.281477 -0.121282 -0.939693 -0.319794 -0.041226 -0.939693 -0.339526 0.041226 -0.939693 -0.339526 0.121282 -0.939693 -0.319794 0.19429 -0.939693 -0.281477 0.256006 -0.939693 -0.226801 0.302844 -0.939693 -0.158945 0.332082 -0.939693 -0.0818508 0.34202 -0.939693 5.98007e-008 0.448799 -0.893633 0 0.435758 -0.893633 0.107405 0.397392 -0.893633 0.208567 0.335931 -0.893633 0.297609 0.254947 -0.893633 0.369354 0.159146 -0.893633 0.419635 0.0540968 -0.893633 0.445527 -0.0540968 -0.893633 0.445527 -0.159146 -0.893633 0.419634 -0.254947 -0.893633 0.369354 -0.335931 -0.893633 0.297609 -0.397392 -0.893633 0.208567 -0.435758 -0.893633 0.107405 -0.448799 -0.893633 -3.92353e-008 -0.435758 -0.893633 -0.107405 -0.397392 -0.893633 -0.208567 -0.335931 -0.893633 -0.297609 -0.254947 -0.893633 -0.369355 -0.159146 -0.893633 -0.419635 -0.0540968 -0.893633 -0.445527 0.0540968 -0.893633 -0.445527 0.159146 -0.893633 -0.419634 0.254947 -0.893633 -0.369354 0.335931 -0.893633 -0.297609 0.397392 -0.893633 -0.208567 0.435758 -0.893633 -0.107405 0.448799 -0.893633 7.84705e-008 0.549509 -0.835488 0 0.533541 -0.835488 0.131506 0.486566 -0.835488 0.25537 0.411313 -0.835488 0.364392 0.312157 -0.835488 0.452237 0.194859 -0.835488 0.5138 0.066236 -0.835488 0.545502 -0.066236 -0.835488 0.545502 -0.194859 -0.835488 0.5138 -0.312157 -0.835488 0.452237 -0.411313 -0.835488 0.364392 -0.486566 -0.835488 0.255369 -0.533541 -0.835488 0.131506 -0.549509 -0.835488 -4.80396e-008 -0.533541 -0.835488 -0.131506 -0.486566 -0.835488 -0.25537 -0.411313 -0.835488 -0.364392 -0.312157 -0.835488 -0.452237 -0.194858 -0.835488 -0.5138 -0.066236 -0.835488 -0.545502 0.066236 -0.835488 -0.545502 0.194859 -0.835488 -0.5138 0.312157 -0.835488 -0.452237 0.411313 -0.835488 -0.364392 0.486566 -0.835488 -0.25537 0.533541 -0.835488 -0.131506 0.549509 -0.835488 9.60792e-008 0.642788 -0.766044 0 0.624109 -0.766044 0.153829 0.56916 -0.766044 0.298718 0.481133 -0.766044 0.426247 0.365145 -0.766044 0.529004 0.227936 -0.766044 0.601017 0.0774795 -0.766044 0.638101 -0.0774795 -0.766044 0.638101 -0.227936 -0.766044 0.601017 -0.365145 -0.766044 0.529004 -0.481133 -0.766044 0.426247 -0.56916 -0.766044 0.298718 -0.624109 -0.766044 0.153829 -0.642788 -0.766044 -5.61943e-008 -0.624109 -0.766044 -0.153829 -0.56916 -0.766044 -0.298718 -0.481133 -0.766044 -0.426247 -0.365145 -0.766044 -0.529004 -0.227935 -0.766044 -0.601017 -0.0774795 -0.766044 -0.638101 0.0774795 -0.766044 -0.638101 0.227936 -0.766044 -0.601017 0.365145 -0.766044 -0.529004 0.481134 -0.766044 -0.426247 0.56916 -0.766044 -0.298718 0.624109 -0.766044 -0.153829 0.642788 -0.766044 1.12389e-007 0.727374 -0.686242 0 0.706237 -0.686242 0.174072 0.644057 -0.686242 0.338027 0.544447 -0.686242 0.482338 0.413195 -0.686242 0.598617 0.25793 -0.686242 0.680106 0.0876752 -0.686242 0.72207 -0.0876753 -0.686242 0.72207 -0.25793 -0.686242 0.680106 -0.413195 -0.686242 0.598617 -0.544447 -0.686242 0.482338 -0.644057 -0.686242 0.338027 -0.706237 -0.686242 0.174072 -0.727374 -0.686242 -6.3589e-008 -0.706237 -0.686242 -0.174072 -0.644057 -0.686242 -0.338027 -0.544447 -0.686242 -0.482338 -0.413195 -0.686242 -0.598617 -0.25793 -0.686242 -0.680106 -0.0876752 -0.686242 -0.72207 0.0876752 -0.686242 -0.72207 0.25793 -0.686242 -0.680106 0.413195 -0.686242 -0.598617 0.544447 -0.686242 -0.482338 0.644057 -0.686242 -0.338027 0.706237 -0.686242 -0.174072 0.727374 -0.686242 1.27178e-007 0.802123 -0.597159 0 0.778815 -0.597159 0.191961 0.710245 -0.597159 0.372765 0.600398 -0.597159 0.531906 0.455658 -0.597159 0.660134 0.284437 -0.597159 0.749998 0.0966853 -0.597159 0.796275 -0.0966853 -0.597159 0.796275 -0.284437 -0.597159 0.749998 -0.455658 -0.597159 0.660134 -0.600398 -0.597159 0.531906 -0.710245 -0.597159 0.372765 -0.778815 -0.597159 0.191961 -0.802123 -0.597159 -7.01238e-008 -0.778815 -0.597159 -0.191961 -0.710245 -0.597159 -0.372765 -0.600398 -0.597159 -0.531906 -0.455658 -0.597159 -0.660135 -0.284437 -0.597159 -0.749998 -0.0966853 -0.597159 -0.796275 0.0966853 -0.597159 -0.796275 0.284437 -0.597159 -0.749998 0.455658 -0.597159 -0.660134 0.600398 -0.597159 -0.531906 0.710245 -0.597159 -0.372765 0.778815 -0.597159 -0.191961 0.802123 -0.597159 1.40248e-007 0.866025 -0.5 0 0.84086 -0.5 0.207253 0.766827 -0.5 0.402462 0.648229 -0.5 0.574281 0.491958 -0.5 0.712725 0.307097 -0.5 0.809748 0.104388 -0.5 0.859711 -0.104388 -0.5 0.859711 -0.307097 -0.5 0.809748 -0.491959 -0.5 0.712725 -0.648229 -0.5 0.574281 -0.766827 -0.5 0.402462 -0.84086 -0.5 0.207253 -0.866025 -0.5 -7.57103e-008 -0.84086 -0.5 -0.207254 -0.766827 -0.5 -0.402462 -0.648229 -0.5 -0.574281 -0.491958 -0.5 -0.712725 -0.307097 -0.5 -0.809748 -0.104388 -0.5 -0.859711 0.104388 -0.5 -0.859711 0.307097 -0.5 -0.809748 0.491959 -0.5 -0.712725 0.64823 -0.5 -0.574281 0.766827 -0.5 -0.402462 0.84086 -0.5 -0.207253 0.866025 -0.5 1.51421e-007 0.918216 -0.39608 0 0.891534 -0.39608 0.219744 0.81304 -0.39608 0.426716 0.687295 -0.39608 0.60889 0.521606 -0.39608 0.755677 0.325604 -0.39608 0.858547 0.110679 -0.39608 0.911521 -0.110679 -0.39608 0.911521 -0.325604 -0.39608 0.858547 -0.521606 -0.39608 0.755677 -0.687295 -0.39608 0.60889 -0.81304 -0.39608 0.426716 -0.891534 -0.39608 0.219744 -0.918216 -0.39608 -8.0273e-008 -0.891534 -0.39608 -0.219744 -0.81304 -0.39608 -0.426716 -0.687295 -0.39608 -0.60889 -0.521606 -0.39608 -0.755677 -0.325604 -0.39608 -0.858547 -0.110679 -0.39608 -0.911521 0.110679 -0.39608 -0.911521 0.325604 -0.39608 -0.858547 0.521606 -0.39608 -0.755677 0.687295 -0.39608 -0.60889 0.81304 -0.39608 -0.426716 0.891534 -0.39608 -0.219743 0.918216 -0.39608 1.60546e-007 0.95799 -0.286803 0 0.930152 -0.286803 0.229262 0.848258 -0.286803 0.4452 0.717065 -0.286803 0.635265 0.5442 -0.286803 0.78841 0.339708 -0.286803 0.895736 0.115473 -0.286803 0.951005 -0.115473 -0.286803 0.951005 -0.339708 -0.286803 0.895736 -0.5442 -0.286803 0.78841 -0.717065 -0.286803 0.635265 -0.848258 -0.286803 0.4452 -0.930152 -0.286803 0.229262 -0.95799 -0.286803 -8.37501e-008 -0.930152 -0.286803 -0.229262 -0.848258 -0.286803 -0.4452 -0.717065 -0.286803 -0.635265 -0.5442 -0.286803 -0.78841 -0.339707 -0.286803 -0.895736 -0.115473 -0.286803 -0.951005 0.115473 -0.286803 -0.951005 0.339708 -0.286803 -0.895736 0.5442 -0.286803 -0.78841 0.717066 -0.286803 -0.635264 0.848258 -0.286803 -0.4452 0.930152 -0.286803 -0.229262 0.95799 -0.286803 1.675e-007 0.984808 -0.173648 0 0.956191 -0.173648 0.23568 0.872004 -0.173648 0.457663 0.737139 -0.173648 0.653048 0.559435 -0.173648 0.810481 0.349218 -0.173648 0.920811 0.118705 -0.173648 0.977627 -0.118706 -0.173648 0.977627 -0.349218 -0.173648 0.920811 -0.559435 -0.173648 0.810481 -0.737139 -0.173648 0.653048 -0.872004 -0.173648 0.457663 -0.956191 -0.173648 0.23568 -0.984808 -0.173648 -8.60946e-008 -0.956191 -0.173648 -0.23568 -0.872004 -0.173648 -0.457663 -0.737139 -0.173648 -0.653048 -0.559434 -0.173648 -0.810481 -0.349217 -0.173648 -0.920811 -0.118705 -0.173648 -0.977627 0.118706 -0.173648 -0.977627 0.349218 -0.173648 -0.920811 0.559435 -0.173648 -0.810481 0.737139 -0.173648 -0.653048 0.872004 -0.173648 -0.457663 0.956191 -0.173648 -0.23568 0.984808 -0.173648 1.72189e-007 0.998308 -0.0581448 0 0.969299 -0.0581448 0.238911 0.883958 -0.0581448 0.463937 0.747244 -0.0581448 0.662001 0.567104 -0.0581448 0.821592 0.354005 -0.0581448 0.933434 0.120333 -0.0581448 0.991029 -0.120333 -0.0581448 0.991029 -0.354005 -0.0581448 0.933434 -0.567104 -0.0581448 0.821591 -0.747244 -0.0581448 0.662001 -0.883958 -0.0581448 0.463937 -0.969299 -0.0581448 0.238911 -0.998308 -0.0581448 -8.72749e-008 -0.969299 -0.0581448 -0.238911 -0.883958 -0.0581448 -0.463937 -0.747244 -0.0581448 -0.662001 -0.567104 -0.0581448 -0.821592 -0.354005 -0.0581448 -0.933434 -0.120333 -0.0581448 -0.991029 0.120333 -0.0581448 -0.991029 0.354005 -0.0581448 -0.933434 0.567104 -0.0581448 -0.821591 0.747245 -0.0581448 -0.662001 0.883958 -0.0581448 -0.463937 0.969299 -0.0581448 -0.238911 0.998308 -0.0581448 1.7455e-007 0.998308 0.0581448 0 0.969299 0.0581448 0.238911 0.883958 0.0581448 0.463937 0.747244 0.0581448 0.662001 0.567104 0.0581448 0.821592 0.354005 0.0581448 0.933434 0.120333 0.0581448 0.991029 -0.120333 0.0581448 0.991029 -0.354005 0.0581448 0.933434 -0.567104 0.0581448 0.821591 -0.747244 0.0581448 0.662001 -0.883958 0.0581448 0.463937 -0.969299 0.0581448 0.238911 -0.998308 0.0581448 -8.72749e-008 -0.969299 0.0581448 -0.238911 -0.883958 0.0581448 -0.463937 -0.747244 0.0581448 -0.662001 -0.567104 0.0581448 -0.821592 -0.354005 0.0581448 -0.933434 -0.120333 0.0581448 -0.991029 0.120333 0.0581448 -0.991029 0.354005 0.0581448 -0.933434 0.567104 0.0581448 -0.821591 0.747245 0.0581448 -0.662001 0.883958 0.0581448 -0.463937 0.969299 0.0581448 -0.238911 0.998308 0.0581448 1.7455e-007 0.984808 0.173648 0 0.956191 0.173648 0.23568 0.872004 0.173648 0.457663 0.737139 0.173648 0.653048 0.559435 0.173648 0.810481 0.349218 0.173648 0.920811 0.118705 0.173648 0.977627 -0.118706 0.173648 0.977627 -0.349218 0.173648 0.920811 -0.559435 0.173648 0.810481 -0.737139 0.173648 0.653048 -0.872004 0.173648 0.457663 -0.956191 0.173648 0.23568 -0.984808 0.173648 -8.60946e-008 -0.956191 0.173648 -0.23568 -0.872004 0.173648 -0.457663 -0.737139 0.173648 -0.653048 -0.559434 0.173648 -0.810481 -0.349217 0.173648 -0.920811 -0.118705 0.173648 -0.977627 0.118706 0.173648 -0.977627 0.349218 0.173648 -0.920811 0.559435 0.173648 -0.810481 0.737139 0.173648 -0.653048 0.872004 0.173648 -0.457663 0.956191 0.173648 -0.23568 0.984808 0.173648 1.72189e-007 0.95799 0.286803 0 0.930152 0.286803 0.229262 0.848258 0.286803 0.4452 0.717065 0.286803 0.635265 0.5442 0.286803 0.78841 0.339708 0.286803 0.895736 0.115473 0.286803 0.951005 -0.115473 0.286803 0.951005 -0.339708 0.286803 0.895736 -0.5442 0.286803 0.78841 -0.717065 0.286803 0.635265 -0.848258 0.286803 0.4452 -0.930152 0.286803 0.229262 -0.95799 0.286803 -8.37501e-008 -0.930152 0.286803 -0.229262 -0.848258 0.286803 -0.4452 -0.717065 0.286803 -0.635265 -0.5442 0.286803 -0.78841 -0.339707 0.286803 -0.895736 -0.115473 0.286803 -0.951005 0.115473 0.286803 -0.951005 0.339708 0.286803 -0.895736 0.5442 0.286803 -0.78841 0.717066 0.286803 -0.635264 0.848258 0.286803 -0.4452 0.930152 0.286803 -0.229262 0.95799 0.286803 1.675e-007 0.918216 0.39608 0 0.891534 0.39608 0.219744 0.81304 0.39608 0.426716 0.687295 0.39608 0.60889 0.521606 0.39608 0.755677 0.325604 0.39608 0.858547 0.110679 0.39608 0.911521 -0.110679 0.39608 0.911521 -0.325604 0.39608 0.858547 -0.521606 0.39608 0.755677 -0.687295 0.39608 0.60889 -0.81304 0.39608 0.426716 -0.891534 0.39608 0.219744 -0.918216 0.39608 -8.0273e-008 -0.891534 0.39608 -0.219744 -0.81304 0.39608 -0.426716 -0.687295 0.39608 -0.60889 -0.521606 0.39608 -0.755677 -0.325604 0.39608 -0.858547 -0.110679 0.39608 -0.911521 0.110679 0.39608 -0.911521 0.325604 0.39608 -0.858547 0.521606 0.39608 -0.755677 0.687295 0.39608 -0.60889 0.81304 0.39608 -0.426716 0.891534 0.39608 -0.219743 0.918216 0.39608 1.60546e-007 0.866025 0.5 0 0.84086 0.5 0.207253 0.766827 0.5 0.402462 0.648229 0.5 0.574281 0.491958 0.5 0.712725 0.307097 0.5 0.809748 0.104388 0.5 0.859711 -0.104388 0.5 0.859711 -0.307097 0.5 0.809748 -0.491959 0.5 0.712725 -0.648229 0.5 0.574281 -0.766827 0.5 0.402462 -0.84086 0.5 0.207253 -0.866025 0.5 -7.57103e-008 -0.84086 0.5 -0.207254 -0.766827 0.5 -0.402462 -0.648229 0.5 -0.574281 -0.491958 0.5 -0.712725 -0.307097 0.5 -0.809748 -0.104388 0.5 -0.859711 0.104388 0.5 -0.859711 0.307097 0.5 -0.809748 0.491959 0.5 -0.712725 0.64823 0.5 -0.574281 0.766827 0.5 -0.402462 0.84086 0.5 -0.207253 0.866025 0.5 1.51421e-007 0.802123 0.597159 0 0.778815 0.597159 0.191961 0.710245 0.597159 0.372765 0.600398 0.597159 0.531906 0.455658 0.597159 0.660134 0.284437 0.597159 0.749998 0.0966853 0.597159 0.796275 -0.0966853 0.597159 0.796275 -0.284437 0.597159 0.749998 -0.455658 0.597159 0.660134 -0.600398 0.597159 0.531906 -0.710245 0.597159 0.372765 -0.778815 0.597159 0.191961 -0.802123 0.597159 -7.01238e-008 -0.778815 0.597159 -0.191961 -0.710245 0.597159 -0.372765 -0.600398 0.597159 -0.531906 -0.455658 0.597159 -0.660135 -0.284437 0.597159 -0.749998 -0.0966853 0.597159 -0.796275 0.0966853 0.597159 -0.796275 0.284437 0.597159 -0.749998 0.455658 0.597159 -0.660134 0.600398 0.597159 -0.531906 0.710245 0.597159 -0.372765 0.778815 0.597159 -0.191961 0.802123 0.597159 1.40248e-007 0.727374 0.686242 0 0.706237 0.686242 0.174072 0.644057 0.686242 0.338027 0.544447 0.686242 0.482338 0.413195 0.686242 0.598617 0.25793 0.686242 0.680106 0.0876752 0.686242 0.72207 -0.0876753 0.686242 0.72207 -0.25793 0.686242 0.680106 -0.413195 0.686242 0.598617 -0.544447 0.686242 0.482338 -0.644057 0.686242 0.338027 -0.706237 0.686242 0.174072 -0.727374 0.686242 -6.3589e-008 -0.706237 0.686242 -0.174072 -0.644057 0.686242 -0.338027 -0.544447 0.686242 -0.482338 -0.413195 0.686242 -0.598617 -0.25793 0.686242 -0.680106 -0.0876752 0.686242 -0.72207 0.0876752 0.686242 -0.72207 0.25793 0.686242 -0.680106 0.413195 0.686242 -0.598617 0.544447 0.686242 -0.482338 0.644057 0.686242 -0.338027 0.706237 0.686242 -0.174072 0.727374 0.686242 1.27178e-007 0.642788 0.766044 0 0.624109 0.766044 0.153829 0.56916 0.766044 0.298718 0.481133 0.766044 0.426247 0.365145 0.766044 0.529004 0.227936 0.766044 0.601017 0.0774795 0.766044 0.638101 -0.0774795 0.766044 0.638101 -0.227936 0.766044 0.601017 -0.365145 0.766044 0.529004 -0.481133 0.766044 0.426247 -0.56916 0.766044 0.298718 -0.624109 0.766044 0.153829 -0.642788 0.766044 -5.61943e-008 -0.624109 0.766044 -0.153829 -0.56916 0.766044 -0.298718 -0.481133 0.766044 -0.426247 -0.365145 0.766044 -0.529004 -0.227935 0.766044 -0.601017 -0.0774795 0.766044 -0.638101 0.0774795 0.766044 -0.638101 0.227936 0.766044 -0.601017 0.365145 0.766044 -0.529004 0.481134 0.766044 -0.426247 0.56916 0.766044 -0.298718 0.624109 0.766044 -0.153829 0.642788 0.766044 1.12389e-007 0.549509 0.835488 0 0.533541 0.835488 0.131506 0.486566 0.835488 0.25537 0.411313 0.835488 0.364392 0.312157 0.835488 0.452237 0.194859 0.835488 0.5138 0.066236 0.835488 0.545502 -0.066236 0.835488 0.545502 -0.194859 0.835488 0.5138 -0.312157 0.835488 0.452237 -0.411313 0.835488 0.364392 -0.486566 0.835488 0.255369 -0.533541 0.835488 0.131506 -0.549509 0.835488 -4.80396e-008 -0.533541 0.835488 -0.131506 -0.486566 0.835488 -0.25537 -0.411313 0.835488 -0.364392 -0.312157 0.835488 -0.452237 -0.194858 0.835488 -0.5138 -0.066236 0.835488 -0.545502 0.066236 0.835488 -0.545502 0.194859 0.835488 -0.5138 0.312157 0.835488 -0.452237 0.411313 0.835488 -0.364392 0.486566 0.835488 -0.25537 0.533541 0.835488 -0.131506 0.549509 0.835488 9.60792e-008 0.448799 0.893633 0 0.435758 0.893633 0.107405 0.397392 0.893633 0.208567 0.335931 0.893633 0.297609 0.254947 0.893633 0.369354 0.159146 0.893633 0.419635 0.0540968 0.893633 0.445527 -0.0540968 0.893633 0.445527 -0.159146 0.893633 0.419634 -0.254947 0.893633 0.369354 -0.335931 0.893633 0.297609 -0.397392 0.893633 0.208567 -0.435758 0.893633 0.107405 -0.448799 0.893633 -3.92353e-008 -0.435758 0.893633 -0.107405 -0.397392 0.893633 -0.208567 -0.335931 0.893633 -0.297609 -0.254947 0.893633 -0.369355 -0.159146 0.893633 -0.419635 -0.0540968 0.893633 -0.445527 0.0540968 0.893633 -0.445527 0.159146 0.893633 -0.419634 0.254947 0.893633 -0.369354 0.335931 0.893633 -0.297609 0.397392 0.893633 -0.208567 0.435758 0.893633 -0.107405 0.448799 0.893633 7.84705e-008 0.34202 0.939693 0 0.332082 0.939693 0.0818508 0.302844 0.939693 0.158945 0.256006 0.939693 0.226801 0.19429 0.939693 0.281477 0.121282 0.939693 0.319794 0.041226 0.939693 0.339526 -0.041226 0.939693 0.339526 -0.121282 0.939693 0.319794 -0.19429 0.939693 0.281477 -0.256006 0.939693 0.226801 -0.302844 0.939693 0.158945 -0.332082 0.939693 0.0818508 -0.34202 0.939693 -2.99004e-008 -0.332082 0.939693 -0.0818508 -0.302844 0.939693 -0.158945 -0.256006 0.939693 -0.226801 -0.19429 0.939693 -0.281477 -0.121282 0.939693 -0.319794 -0.041226 0.939693 -0.339526 0.041226 0.939693 -0.339526 0.121282 0.939693 -0.319794 0.19429 0.939693 -0.281477 0.256006 0.939693 -0.226801 0.302844 0.939693 -0.158945 0.332082 0.939693 -0.0818508 0.34202 0.939693 5.98007e-008 0.230616 0.973045 0 0.223915 0.973045 0.05519 0.2042 0.973045 0.107173 0.172618 0.973045 0.152927 0.131005 0.973045 0.189793 0.0817775 0.973045 0.21563 0.0277977 0.973045 0.228934 -0.0277977 0.973045 0.228934 -0.0817775 0.973045 0.21563 -0.131005 0.973045 0.189793 -0.172618 0.973045 0.152927 -0.2042 0.973045 0.107173 -0.223915 0.973045 0.05519 -0.230616 0.973045 -2.01611e-008 -0.223915 0.973045 -0.05519 -0.2042 0.973045 -0.107173 -0.172618 0.973045 -0.152927 -0.131005 0.973045 -0.189793 -0.0817774 0.973045 -0.21563 -0.0277977 0.973045 -0.228934 0.0277977 0.973045 -0.228934 0.0817776 0.973045 -0.21563 0.131005 0.973045 -0.189793 0.172619 0.973045 -0.152927 0.2042 0.973045 -0.107173 0.223915 0.973045 -0.05519 0.230616 0.973045 4.03222e-008 0.116093 0.993238 0 0.112719 0.993238 0.0277828 0.102795 0.993238 0.0539509 0.0868966 0.993238 0.0769837 0.0659481 0.993238 0.0955424 0.041167 0.993238 0.108549 0.0139934 0.993238 0.115246 -0.0139934 0.993238 0.115246 -0.041167 0.993238 0.108549 -0.0659482 0.993238 0.0955424 -0.0868966 0.993238 0.0769837 -0.102795 0.993238 0.0539509 -0.112719 0.993238 0.0277828 -0.116093 0.993238 -1.01491e-008 -0.112719 0.993238 -0.0277828 -0.102795 0.993238 -0.0539509 -0.0868966 0.993238 -0.0769837 -0.0659481 0.993238 -0.0955424 -0.041167 0.993238 -0.108549 -0.0139934 0.993238 -0.115246 0.0139934 0.993238 -0.115246 0.041167 0.993238 -0.108548 0.0659482 0.993238 -0.0955424 0.0868966 0.993238 -0.0769836 0.102795 0.993238 -0.0539509 0.112719 0.993238 -0.0277828 0.116093 0.993238 2.02983e-008 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0</float_array> + <technique_common> + <accessor count="756" source="#FXStream2-array" stride="3"> + <param name="X" type="float"/> + <param name="Y" type="float"/> + <param name="Z" type="float"/> + </accessor> + </technique_common> + </source> + <source id="FXStream1" name="FXStream"> + <float_array id="FXStream1-array" count="1512">1.01852 0 0.980057 0 0.941595 0 0.903134 0 0.864672 0 0.826211 0 0.787749 0 0.749288 0 0.710826 0 0.672365 0 0.633903 0 0.595442 0 0.55698 0 0.518519 0 0.480057 0 0.441595 0 0.403134 0 0.364672 0 0.326211 0 0.287749 0 0.249288 0 0.210826 0 0.172365 0 0.133903 0 0.0954416 0 0.0569801 0 0.0185185 0 1 0.037037 0.961538 0.037037 0.923077 0.037037 0.884615 0.037037 0.846154 0.037037 0.807692 0.037037 0.769231 0.037037 0.730769 0.037037 0.692308 0.037037 0.653846 0.037037 0.615385 0.037037 0.576923 0.037037 0.538462 0.037037 0.5 0.037037 0.461538 0.037037 0.423077 0.037037 0.384615 0.037037 0.346154 0.037037 0.307692 0.037037 0.269231 0.037037 0.230769 0.037037 0.192308 0.037037 0.153846 0.037037 0.115385 0.037037 0.0769231 0.037037 0.0384616 0.037037 0 0.037037 1 0.0740741 0.961538 0.0740741 0.923077 0.0740741 0.884615 0.0740741 0.846154 0.0740741 0.807692 0.0740741 0.769231 0.0740741 0.730769 0.0740741 0.692308 0.0740741 0.653846 0.0740741 0.615385 0.0740741 0.576923 0.0740741 0.538462 0.0740741 0.5 0.0740741 0.461538 0.0740741 0.423077 0.0740741 0.384615 0.0740741 0.346154 0.0740741 0.307692 0.0740741 0.269231 0.0740741 0.230769 0.0740741 0.192308 0.0740741 0.153846 0.0740741 0.115385 0.0740741 0.0769231 0.0740741 0.0384616 0.0740741 0 0.0740741 1 0.111111 0.961538 0.111111 0.923077 0.111111 0.884615 0.111111 0.846154 0.111111 0.807692 0.111111 0.769231 0.111111 0.730769 0.111111 0.692308 0.111111 0.653846 0.111111 0.615385 0.111111 0.576923 0.111111 0.538462 0.111111 0.5 0.111111 0.461538 0.111111 0.423077 0.111111 0.384615 0.111111 0.346154 0.111111 0.307692 0.111111 0.269231 0.111111 0.230769 0.111111 0.192308 0.111111 0.153846 0.111111 0.115385 0.111111 0.0769231 0.111111 0.0384616 0.111111 0 0.111111 1 0.148148 0.961538 0.148148 0.923077 0.148148 0.884615 0.148148 0.846154 0.148148 0.807692 0.148148 0.769231 0.148148 0.730769 0.148148 0.692308 0.148148 0.653846 0.148148 0.615385 0.148148 0.576923 0.148148 0.538462 0.148148 0.5 0.148148 0.461538 0.148148 0.423077 0.148148 0.384615 0.148148 0.346154 0.148148 0.307692 0.148148 0.269231 0.148148 0.230769 0.148148 0.192308 0.148148 0.153846 0.148148 0.115385 0.148148 0.0769231 0.148148 0.0384616 0.148148 0 0.148148 1 0.185185 0.961538 0.185185 0.923077 0.185185 0.884615 0.185185 0.846154 0.185185 0.807692 0.185185 0.769231 0.185185 0.730769 0.185185 0.692308 0.185185 0.653846 0.185185 0.615385 0.185185 0.576923 0.185185 0.538462 0.185185 0.5 0.185185 0.461538 0.185185 0.423077 0.185185 0.384615 0.185185 0.346154 0.185185 0.307692 0.185185 0.269231 0.185185 0.230769 0.185185 0.192308 0.185185 0.153846 0.185185 0.115385 0.185185 0.0769231 0.185185 0.0384616 0.185185 0 0.185185 1 0.222222 0.961538 0.222222 0.923077 0.222222 0.884615 0.222222 0.846154 0.222222 0.807692 0.222222 0.769231 0.222222 0.730769 0.222222 0.692308 0.222222 0.653846 0.222222 0.615385 0.222222 0.576923 0.222222 0.538462 0.222222 0.5 0.222222 0.461538 0.222222 0.423077 0.222222 0.384615 0.222222 0.346154 0.222222 0.307692 0.222222 0.269231 0.222222 0.230769 0.222222 0.192308 0.222222 0.153846 0.222222 0.115385 0.222222 0.0769231 0.222222 0.0384616 0.222222 0 0.222222 1 0.259259 0.961538 0.259259 0.923077 0.259259 0.884615 0.259259 0.846154 0.259259 0.807692 0.259259 0.769231 0.259259 0.730769 0.259259 0.692308 0.259259 0.653846 0.259259 0.615385 0.259259 0.576923 0.259259 0.538462 0.259259 0.5 0.259259 0.461538 0.259259 0.423077 0.259259 0.384615 0.259259 0.346154 0.259259 0.307692 0.259259 0.269231 0.259259 0.230769 0.259259 0.192308 0.259259 0.153846 0.259259 0.115385 0.259259 0.0769231 0.259259 0.0384616 0.259259 0 0.259259 1 0.296296 0.961538 0.296296 0.923077 0.296296 0.884615 0.296296 0.846154 0.296296 0.807692 0.296296 0.769231 0.296296 0.730769 0.296296 0.692308 0.296296 0.653846 0.296296 0.615385 0.296296 0.576923 0.296296 0.538462 0.296296 0.5 0.296296 0.461538 0.296296 0.423077 0.296296 0.384615 0.296296 0.346154 0.296296 0.307692 0.296296 0.269231 0.296296 0.230769 0.296296 0.192308 0.296296 0.153846 0.296296 0.115385 0.296296 0.0769231 0.296296 0.0384616 0.296296 0 0.296296 1 0.333333 0.961538 0.333333 0.923077 0.333333 0.884615 0.333333 0.846154 0.333333 0.807692 0.333333 0.769231 0.333333 0.730769 0.333333 0.692308 0.333333 0.653846 0.333333 0.615385 0.333333 0.576923 0.333333 0.538462 0.333333 0.5 0.333333 0.461538 0.333333 0.423077 0.333333 0.384615 0.333333 0.346154 0.333333 0.307692 0.333333 0.269231 0.333333 0.230769 0.333333 0.192308 0.333333 0.153846 0.333333 0.115385 0.333333 0.0769231 0.333333 0.0384616 0.333333 0 0.333333 1 0.37037 0.961538 0.37037 0.923077 0.37037 0.884615 0.37037 0.846154 0.37037 0.807692 0.37037 0.769231 0.37037 0.730769 0.37037 0.692308 0.37037 0.653846 0.37037 0.615385 0.37037 0.576923 0.37037 0.538462 0.37037 0.5 0.37037 0.461538 0.37037 0.423077 0.37037 0.384615 0.37037 0.346154 0.37037 0.307692 0.37037 0.269231 0.37037 0.230769 0.37037 0.192308 0.37037 0.153846 0.37037 0.115385 0.37037 0.0769231 0.37037 0.0384616 0.37037 0 0.37037 1 0.407407 0.961538 0.407407 0.923077 0.407407 0.884615 0.407407 0.846154 0.407407 0.807692 0.407407 0.769231 0.407407 0.730769 0.407407 0.692308 0.407407 0.653846 0.407407 0.615385 0.407407 0.576923 0.407407 0.538462 0.407407 0.5 0.407407 0.461538 0.407407 0.423077 0.407407 0.384615 0.407407 0.346154 0.407407 0.307692 0.407407 0.269231 0.407407 0.230769 0.407407 0.192308 0.407407 0.153846 0.407407 0.115385 0.407407 0.0769231 0.407407 0.0384616 0.407407 0 0.407407 1 0.444444 0.961538 0.444444 0.923077 0.444444 0.884615 0.444444 0.846154 0.444444 0.807692 0.444444 0.769231 0.444444 0.730769 0.444444 0.692308 0.444444 0.653846 0.444444 0.615385 0.444444 0.576923 0.444444 0.538462 0.444444 0.5 0.444444 0.461538 0.444444 0.423077 0.444444 0.384615 0.444444 0.346154 0.444444 0.307692 0.444444 0.269231 0.444444 0.230769 0.444444 0.192308 0.444444 0.153846 0.444444 0.115385 0.444444 0.0769231 0.444444 0.0384616 0.444444 0 0.444444 1 0.481481 0.961538 0.481481 0.923077 0.481481 0.884615 0.481481 0.846154 0.481481 0.807692 0.481481 0.769231 0.481481 0.730769 0.481481 0.692308 0.481481 0.653846 0.481481 0.615385 0.481481 0.576923 0.481481 0.538462 0.481481 0.5 0.481481 0.461538 0.481481 0.423077 0.481481 0.384615 0.481481 0.346154 0.481481 0.307692 0.481481 0.269231 0.481481 0.230769 0.481481 0.192308 0.481481 0.153846 0.481481 0.115385 0.481481 0.0769231 0.481481 0.0384616 0.481481 0 0.481481 1 0.518519 0.961538 0.518519 0.923077 0.518519 0.884615 0.518519 0.846154 0.518519 0.807692 0.518519 0.769231 0.518519 0.730769 0.518519 0.692308 0.518519 0.653846 0.518519 0.615385 0.518519 0.576923 0.518519 0.538462 0.518519 0.5 0.518519 0.461538 0.518519 0.423077 0.518519 0.384615 0.518519 0.346154 0.518519 0.307692 0.518519 0.269231 0.518519 0.230769 0.518519 0.192308 0.518519 0.153846 0.518519 0.115385 0.518519 0.0769231 0.518519 0.0384616 0.518519 0 0.518519 1 0.555556 0.961538 0.555556 0.923077 0.555556 0.884615 0.555556 0.846154 0.555556 0.807692 0.555556 0.769231 0.555556 0.730769 0.555556 0.692308 0.555556 0.653846 0.555556 0.615385 0.555556 0.576923 0.555556 0.538462 0.555556 0.5 0.555556 0.461538 0.555556 0.423077 0.555556 0.384615 0.555556 0.346154 0.555556 0.307692 0.555556 0.269231 0.555556 0.230769 0.555556 0.192308 0.555556 0.153846 0.555556 0.115385 0.555556 0.0769231 0.555556 0.0384616 0.555556 0 0.555556 1 0.592593 0.961538 0.592593 0.923077 0.592593 0.884615 0.592593 0.846154 0.592593 0.807692 0.592593 0.769231 0.592593 0.730769 0.592593 0.692308 0.592593 0.653846 0.592593 0.615385 0.592593 0.576923 0.592593 0.538462 0.592593 0.5 0.592593 0.461538 0.592593 0.423077 0.592593 0.384615 0.592593 0.346154 0.592593 0.307692 0.592593 0.269231 0.592593 0.230769 0.592593 0.192308 0.592593 0.153846 0.592593 0.115385 0.592593 0.0769231 0.592593 0.0384616 0.592593 0 0.592593 1 0.62963 0.961538 0.62963 0.923077 0.62963 0.884615 0.62963 0.846154 0.62963 0.807692 0.62963 0.769231 0.62963 0.730769 0.62963 0.692308 0.62963 0.653846 0.62963 0.615385 0.62963 0.576923 0.62963 0.538462 0.62963 0.5 0.62963 0.461538 0.62963 0.423077 0.62963 0.384615 0.62963 0.346154 0.62963 0.307692 0.62963 0.269231 0.62963 0.230769 0.62963 0.192308 0.62963 0.153846 0.62963 0.115385 0.62963 0.0769231 0.62963 0.0384616 0.62963 0 0.62963 1 0.666667 0.961538 0.666667 0.923077 0.666667 0.884615 0.666667 0.846154 0.666667 0.807692 0.666667 0.769231 0.666667 0.730769 0.666667 0.692308 0.666667 0.653846 0.666667 0.615385 0.666667 0.576923 0.666667 0.538462 0.666667 0.5 0.666667 0.461538 0.666667 0.423077 0.666667 0.384615 0.666667 0.346154 0.666667 0.307692 0.666667 0.269231 0.666667 0.230769 0.666667 0.192308 0.666667 0.153846 0.666667 0.115385 0.666667 0.0769231 0.666667 0.0384616 0.666667 0 0.666667 1 0.703704 0.961538 0.703704 0.923077 0.703704 0.884615 0.703704 0.846154 0.703704 0.807692 0.703704 0.769231 0.703704 0.730769 0.703704 0.692308 0.703704 0.653846 0.703704 0.615385 0.703704 0.576923 0.703704 0.538462 0.703704 0.5 0.703704 0.461538 0.703704 0.423077 0.703704 0.384615 0.703704 0.346154 0.703704 0.307692 0.703704 0.269231 0.703704 0.230769 0.703704 0.192308 0.703704 0.153846 0.703704 0.115385 0.703704 0.0769231 0.703704 0.0384616 0.703704 0 0.703704 1 0.740741 0.961538 0.740741 0.923077 0.740741 0.884615 0.740741 0.846154 0.740741 0.807692 0.740741 0.769231 0.740741 0.730769 0.740741 0.692308 0.740741 0.653846 0.740741 0.615385 0.740741 0.576923 0.740741 0.538462 0.740741 0.5 0.740741 0.461538 0.740741 0.423077 0.740741 0.384615 0.740741 0.346154 0.740741 0.307692 0.740741 0.269231 0.740741 0.230769 0.740741 0.192308 0.740741 0.153846 0.740741 0.115385 0.740741 0.0769231 0.740741 0.0384616 0.740741 0 0.740741 1 0.777778 0.961538 0.777778 0.923077 0.777778 0.884615 0.777778 0.846154 0.777778 0.807692 0.777778 0.769231 0.777778 0.730769 0.777778 0.692308 0.777778 0.653846 0.777778 0.615385 0.777778 0.576923 0.777778 0.538462 0.777778 0.5 0.777778 0.461538 0.777778 0.423077 0.777778 0.384615 0.777778 0.346154 0.777778 0.307692 0.777778 0.269231 0.777778 0.230769 0.777778 0.192308 0.777778 0.153846 0.777778 0.115385 0.777778 0.0769231 0.777778 0.0384616 0.777778 0 0.777778 1 0.814815 0.961538 0.814815 0.923077 0.814815 0.884615 0.814815 0.846154 0.814815 0.807692 0.814815 0.769231 0.814815 0.730769 0.814815 0.692308 0.814815 0.653846 0.814815 0.615385 0.814815 0.576923 0.814815 0.538462 0.814815 0.5 0.814815 0.461538 0.814815 0.423077 0.814815 0.384615 0.814815 0.346154 0.814815 0.307692 0.814815 0.269231 0.814815 0.230769 0.814815 0.192308 0.814815 0.153846 0.814815 0.115385 0.814815 0.0769231 0.814815 0.0384616 0.814815 0 0.814815 1 0.851852 0.961538 0.851852 0.923077 0.851852 0.884615 0.851852 0.846154 0.851852 0.807692 0.851852 0.769231 0.851852 0.730769 0.851852 0.692308 0.851852 0.653846 0.851852 0.615385 0.851852 0.576923 0.851852 0.538462 0.851852 0.5 0.851852 0.461538 0.851852 0.423077 0.851852 0.384615 0.851852 0.346154 0.851852 0.307692 0.851852 0.269231 0.851852 0.230769 0.851852 0.192308 0.851852 0.153846 0.851852 0.115385 0.851852 0.0769231 0.851852 0.0384616 0.851852 0 0.851852 1 0.888889 0.961538 0.888889 0.923077 0.888889 0.884615 0.888889 0.846154 0.888889 0.807692 0.888889 0.769231 0.888889 0.730769 0.888889 0.692308 0.888889 0.653846 0.888889 0.615385 0.888889 0.576923 0.888889 0.538462 0.888889 0.5 0.888889 0.461538 0.888889 0.423077 0.888889 0.384615 0.888889 0.346154 0.888889 0.307692 0.888889 0.269231 0.888889 0.230769 0.888889 0.192308 0.888889 0.153846 0.888889 0.115385 0.888889 0.0769231 0.888889 0.0384616 0.888889 0 0.888889 1 0.925926 0.961538 0.925926 0.923077 0.925926 0.884615 0.925926 0.846154 0.925926 0.807692 0.925926 0.769231 0.925926 0.730769 0.925926 0.692308 0.925926 0.653846 0.925926 0.615385 0.925926 0.576923 0.925926 0.538462 0.925926 0.5 0.925926 0.461538 0.925926 0.423077 0.925926 0.384615 0.925926 0.346154 0.925926 0.307692 0.925926 0.269231 0.925926 0.230769 0.925926 0.192308 0.925926 0.153846 0.925926 0.115385 0.925926 0.0769231 0.925926 0.0384616 0.925926 0 0.925926 1 0.962963 0.961538 0.962963 0.923077 0.962963 0.884615 0.962963 0.846154 0.962963 0.807692 0.962963 0.769231 0.962963 0.730769 0.962963 0.692308 0.962963 0.653846 0.962963 0.615385 0.962963 0.576923 0.962963 0.538462 0.962963 0.5 0.962963 0.461538 0.962963 0.423077 0.962963 0.384615 0.962963 0.346154 0.962963 0.307692 0.962963 0.269231 0.962963 0.230769 0.962963 0.192308 0.962963 0.153846 0.962963 0.115385 0.962963 0.0769231 0.962963 0.0384616 0.962963 0 0.962963 0.981481 1 0.94302 1 0.904558 1 0.866097 1 0.827635 1 0.789174 1 0.750712 1 0.712251 1 0.673789 1 0.635328 1 0.596866 1 0.558405 1 0.519943 1 0.481481 1 0.44302 1 0.404558 1 0.366097 1 0.327635 1 0.289174 1 0.250712 1 0.212251 1 0.173789 1 0.135328 1 0.0968661 1 0.0584046 1 0.019943 1 -0.0185185 1</float_array> + <technique_common> + <accessor count="756" source="#FXStream1-array" stride="2"> + <param name="S" type="float"/> + <param name="T" type="float"/> + </accessor> + </technique_common> + </source> + <vertices id="Sphere-Vertex-0"> + <input semantic="POSITION" source="#FXStream"/> + <input semantic="NORMAL" source="#FXStream2"/> + <input semantic="TEXCOORD" source="#FXStream1"/> + </vertices> + <polygons count="702" material="SphereMaterial"> + <input offset="0" semantic="VERTEX" source="#Sphere-Vertex-0"/> + <p>54 55 28 27</p> + <p>55 56 29 28</p> + <p>56 57 30 29</p> + <p>57 58 31 30</p> + <p>58 59 32 31</p> + <p>59 60 33 32</p> + <p>60 61 34 33</p> + <p>61 62 35 34</p> + <p>62 63 36 35</p> + <p>63 64 37 36</p> + <p>64 65 38 37</p> + <p>65 66 39 38</p> + <p>66 67 40 39</p> + <p>67 68 41 40</p> + <p>68 69 42 41</p> + <p>69 70 43 42</p> + <p>70 71 44 43</p> + <p>71 72 45 44</p> + <p>72 73 46 45</p> + <p>73 74 47 46</p> + <p>74 75 48 47</p> + <p>75 76 49 48</p> + <p>76 77 50 49</p> + <p>77 78 51 50</p> + <p>78 79 52 51</p> + <p>79 80 53 52</p> + <p>81 82 55 54</p> + <p>82 83 56 55</p> + <p>83 84 57 56</p> + <p>84 85 58 57</p> + <p>85 86 59 58</p> + <p>86 87 60 59</p> + <p>87 88 61 60</p> + <p>88 89 62 61</p> + <p>89 90 63 62</p> + <p>90 91 64 63</p> + <p>91 92 65 64</p> + <p>92 93 66 65</p> + <p>93 94 67 66</p> + <p>94 95 68 67</p> + <p>95 96 69 68</p> + <p>96 97 70 69</p> + <p>97 98 71 70</p> + <p>98 99 72 71</p> + <p>99 100 73 72</p> + <p>100 101 74 73</p> + <p>101 102 75 74</p> + <p>102 103 76 75</p> + <p>103 104 77 76</p> + <p>104 105 78 77</p> + <p>105 106 79 78</p> + <p>106 107 80 79</p> + <p>108 109 82 81</p> + <p>109 110 83 82</p> + <p>110 111 84 83</p> + <p>111 112 85 84</p> + <p>112 113 86 85</p> + <p>113 114 87 86</p> + <p>114 115 88 87</p> + <p>115 116 89 88</p> + <p>116 117 90 89</p> + <p>117 118 91 90</p> + <p>118 119 92 91</p> + <p>119 120 93 92</p> + <p>120 121 94 93</p> + <p>121 122 95 94</p> + <p>122 123 96 95</p> + <p>123 124 97 96</p> + <p>124 125 98 97</p> + <p>125 126 99 98</p> + <p>126 127 100 99</p> + <p>127 128 101 100</p> + <p>128 129 102 101</p> + <p>129 130 103 102</p> + <p>130 131 104 103</p> + <p>131 132 105 104</p> + <p>132 133 106 105</p> + <p>133 134 107 106</p> + <p>135 136 109 108</p> + <p>136 137 110 109</p> + <p>137 138 111 110</p> + <p>138 139 112 111</p> + <p>139 140 113 112</p> + <p>140 141 114 113</p> + <p>141 142 115 114</p> + <p>142 143 116 115</p> + <p>143 144 117 116</p> + <p>144 145 118 117</p> + <p>145 146 119 118</p> + <p>146 147 120 119</p> + <p>147 148 121 120</p> + <p>148 149 122 121</p> + <p>149 150 123 122</p> + <p>150 151 124 123</p> + <p>151 152 125 124</p> + <p>152 153 126 125</p> + <p>153 154 127 126</p> + <p>154 155 128 127</p> + <p>155 156 129 128</p> + <p>156 157 130 129</p> + <p>157 158 131 130</p> + <p>158 159 132 131</p> + <p>159 160 133 132</p> + <p>160 161 134 133</p> + <p>162 163 136 135</p> + <p>163 164 137 136</p> + <p>164 165 138 137</p> + <p>165 166 139 138</p> + <p>166 167 140 139</p> + <p>167 168 141 140</p> + <p>168 169 142 141</p> + <p>169 170 143 142</p> + <p>170 171 144 143</p> + <p>171 172 145 144</p> + <p>172 173 146 145</p> + <p>173 174 147 146</p> + <p>174 175 148 147</p> + <p>175 176 149 148</p> + <p>176 177 150 149</p> + <p>177 178 151 150</p> + <p>178 179 152 151</p> + <p>179 180 153 152</p> + <p>180 181 154 153</p> + <p>181 182 155 154</p> + <p>182 183 156 155</p> + <p>183 184 157 156</p> + <p>184 185 158 157</p> + <p>185 186 159 158</p> + <p>186 187 160 159</p> + <p>187 188 161 160</p> + <p>189 190 163 162</p> + <p>190 191 164 163</p> + <p>191 192 165 164</p> + <p>192 193 166 165</p> + <p>193 194 167 166</p> + <p>194 195 168 167</p> + <p>195 196 169 168</p> + <p>196 197 170 169</p> + <p>197 198 171 170</p> + <p>198 199 172 171</p> + <p>199 200 173 172</p> + <p>200 201 174 173</p> + <p>201 202 175 174</p> + <p>202 203 176 175</p> + <p>203 204 177 176</p> + <p>204 205 178 177</p> + <p>205 206 179 178</p> + <p>206 207 180 179</p> + <p>207 208 181 180</p> + <p>208 209 182 181</p> + <p>209 210 183 182</p> + <p>210 211 184 183</p> + <p>211 212 185 184</p> + <p>212 213 186 185</p> + <p>213 214 187 186</p> + <p>214 215 188 187</p> + <p>216 217 190 189</p> + <p>217 218 191 190</p> + <p>218 219 192 191</p> + <p>219 220 193 192</p> + <p>220 221 194 193</p> + <p>221 222 195 194</p> + <p>222 223 196 195</p> + <p>223 224 197 196</p> + <p>224 225 198 197</p> + <p>225 226 199 198</p> + <p>226 227 200 199</p> + <p>227 228 201 200</p> + <p>228 229 202 201</p> + <p>229 230 203 202</p> + <p>230 231 204 203</p> + <p>231 232 205 204</p> + <p>232 233 206 205</p> + <p>233 234 207 206</p> + <p>234 235 208 207</p> + <p>235 236 209 208</p> + <p>236 237 210 209</p> + <p>237 238 211 210</p> + <p>238 239 212 211</p> + <p>239 240 213 212</p> + <p>240 241 214 213</p> + <p>241 242 215 214</p> + <p>243 244 217 216</p> + <p>244 245 218 217</p> + <p>245 246 219 218</p> + <p>246 247 220 219</p> + <p>247 248 221 220</p> + <p>248 249 222 221</p> + <p>249 250 223 222</p> + <p>250 251 224 223</p> + <p>251 252 225 224</p> + <p>252 253 226 225</p> + <p>253 254 227 226</p> + <p>254 255 228 227</p> + <p>255 256 229 228</p> + <p>256 257 230 229</p> + <p>257 258 231 230</p> + <p>258 259 232 231</p> + <p>259 260 233 232</p> + <p>260 261 234 233</p> + <p>261 262 235 234</p> + <p>262 263 236 235</p> + <p>263 264 237 236</p> + <p>264 265 238 237</p> + <p>265 266 239 238</p> + <p>266 267 240 239</p> + <p>267 268 241 240</p> + <p>268 269 242 241</p> + <p>270 271 244 243</p> + <p>271 272 245 244</p> + <p>272 273 246 245</p> + <p>273 274 247 246</p> + <p>274 275 248 247</p> + <p>275 276 249 248</p> + <p>276 277 250 249</p> + <p>277 278 251 250</p> + <p>278 279 252 251</p> + <p>279 280 253 252</p> + <p>280 281 254 253</p> + <p>281 282 255 254</p> + <p>282 283 256 255</p> + <p>283 284 257 256</p> + <p>284 285 258 257</p> + <p>285 286 259 258</p> + <p>286 287 260 259</p> + <p>287 288 261 260</p> + <p>288 289 262 261</p> + <p>289 290 263 262</p> + <p>290 291 264 263</p> + <p>291 292 265 264</p> + <p>292 293 266 265</p> + <p>293 294 267 266</p> + <p>294 295 268 267</p> + <p>295 296 269 268</p> + <p>297 298 271 270</p> + <p>298 299 272 271</p> + <p>299 300 273 272</p> + <p>300 301 274 273</p> + <p>301 302 275 274</p> + <p>302 303 276 275</p> + <p>303 304 277 276</p> + <p>304 305 278 277</p> + <p>305 306 279 278</p> + <p>306 307 280 279</p> + <p>307 308 281 280</p> + <p>308 309 282 281</p> + <p>309 310 283 282</p> + <p>310 311 284 283</p> + <p>311 312 285 284</p> + <p>312 313 286 285</p> + <p>313 314 287 286</p> + <p>314 315 288 287</p> + <p>315 316 289 288</p> + <p>316 317 290 289</p> + <p>317 318 291 290</p> + <p>318 319 292 291</p> + <p>319 320 293 292</p> + <p>320 321 294 293</p> + <p>321 322 295 294</p> + <p>322 323 296 295</p> + <p>324 325 298 297</p> + <p>325 326 299 298</p> + <p>326 327 300 299</p> + <p>327 328 301 300</p> + <p>328 329 302 301</p> + <p>329 330 303 302</p> + <p>330 331 304 303</p> + <p>331 332 305 304</p> + <p>332 333 306 305</p> + <p>333 334 307 306</p> + <p>334 335 308 307</p> + <p>335 336 309 308</p> + <p>336 337 310 309</p> + <p>337 338 311 310</p> + <p>338 339 312 311</p> + <p>339 340 313 312</p> + <p>340 341 314 313</p> + <p>341 342 315 314</p> + <p>342 343 316 315</p> + <p>343 344 317 316</p> + <p>344 345 318 317</p> + <p>345 346 319 318</p> + <p>346 347 320 319</p> + <p>347 348 321 320</p> + <p>348 349 322 321</p> + <p>349 350 323 322</p> + <p>351 352 325 324</p> + <p>352 353 326 325</p> + <p>353 354 327 326</p> + <p>354 355 328 327</p> + <p>355 356 329 328</p> + <p>356 357 330 329</p> + <p>357 358 331 330</p> + <p>358 359 332 331</p> + <p>359 360 333 332</p> + <p>360 361 334 333</p> + <p>361 362 335 334</p> + <p>362 363 336 335</p> + <p>363 364 337 336</p> + <p>364 365 338 337</p> + <p>365 366 339 338</p> + <p>366 367 340 339</p> + <p>367 368 341 340</p> + <p>368 369 342 341</p> + <p>369 370 343 342</p> + <p>370 371 344 343</p> + <p>371 372 345 344</p> + <p>372 373 346 345</p> + <p>373 374 347 346</p> + <p>374 375 348 347</p> + <p>375 376 349 348</p> + <p>376 377 350 349</p> + <p>378 379 352 351</p> + <p>379 380 353 352</p> + <p>380 381 354 353</p> + <p>381 382 355 354</p> + <p>382 383 356 355</p> + <p>383 384 357 356</p> + <p>384 385 358 357</p> + <p>385 386 359 358</p> + <p>386 387 360 359</p> + <p>387 388 361 360</p> + <p>388 389 362 361</p> + <p>389 390 363 362</p> + <p>390 391 364 363</p> + <p>391 392 365 364</p> + <p>392 393 366 365</p> + <p>393 394 367 366</p> + <p>394 395 368 367</p> + <p>395 396 369 368</p> + <p>396 397 370 369</p> + <p>397 398 371 370</p> + <p>398 399 372 371</p> + <p>399 400 373 372</p> + <p>400 401 374 373</p> + <p>401 402 375 374</p> + <p>402 403 376 375</p> + <p>403 404 377 376</p> + <p>405 406 379 378</p> + <p>406 407 380 379</p> + <p>407 408 381 380</p> + <p>408 409 382 381</p> + <p>409 410 383 382</p> + <p>410 411 384 383</p> + <p>411 412 385 384</p> + <p>412 413 386 385</p> + <p>413 414 387 386</p> + <p>414 415 388 387</p> + <p>415 416 389 388</p> + <p>416 417 390 389</p> + <p>417 418 391 390</p> + <p>418 419 392 391</p> + <p>419 420 393 392</p> + <p>420 421 394 393</p> + <p>421 422 395 394</p> + <p>422 423 396 395</p> + <p>423 424 397 396</p> + <p>424 425 398 397</p> + <p>425 426 399 398</p> + <p>426 427 400 399</p> + <p>427 428 401 400</p> + <p>428 429 402 401</p> + <p>429 430 403 402</p> + <p>430 431 404 403</p> + <p>432 433 406 405</p> + <p>433 434 407 406</p> + <p>434 435 408 407</p> + <p>435 436 409 408</p> + <p>436 437 410 409</p> + <p>437 438 411 410</p> + <p>438 439 412 411</p> + <p>439 440 413 412</p> + <p>440 441 414 413</p> + <p>441 442 415 414</p> + <p>442 443 416 415</p> + <p>443 444 417 416</p> + <p>444 445 418 417</p> + <p>445 446 419 418</p> + <p>446 447 420 419</p> + <p>447 448 421 420</p> + <p>448 449 422 421</p> + <p>449 450 423 422</p> + <p>450 451 424 423</p> + <p>451 452 425 424</p> + <p>452 453 426 425</p> + <p>453 454 427 426</p> + <p>454 455 428 427</p> + <p>455 456 429 428</p> + <p>456 457 430 429</p> + <p>457 458 431 430</p> + <p>459 460 433 432</p> + <p>460 461 434 433</p> + <p>461 462 435 434</p> + <p>462 463 436 435</p> + <p>463 464 437 436</p> + <p>464 465 438 437</p> + <p>465 466 439 438</p> + <p>466 467 440 439</p> + <p>467 468 441 440</p> + <p>468 469 442 441</p> + <p>469 470 443 442</p> + <p>470 471 444 443</p> + <p>471 472 445 444</p> + <p>472 473 446 445</p> + <p>473 474 447 446</p> + <p>474 475 448 447</p> + <p>475 476 449 448</p> + <p>476 477 450 449</p> + <p>477 478 451 450</p> + <p>478 479 452 451</p> + <p>479 480 453 452</p> + <p>480 481 454 453</p> + <p>481 482 455 454</p> + <p>482 483 456 455</p> + <p>483 484 457 456</p> + <p>484 485 458 457</p> + <p>486 487 460 459</p> + <p>487 488 461 460</p> + <p>488 489 462 461</p> + <p>489 490 463 462</p> + <p>490 491 464 463</p> + <p>491 492 465 464</p> + <p>492 493 466 465</p> + <p>493 494 467 466</p> + <p>494 495 468 467</p> + <p>495 496 469 468</p> + <p>496 497 470 469</p> + <p>497 498 471 470</p> + <p>498 499 472 471</p> + <p>499 500 473 472</p> + <p>500 501 474 473</p> + <p>501 502 475 474</p> + <p>502 503 476 475</p> + <p>503 504 477 476</p> + <p>504 505 478 477</p> + <p>505 506 479 478</p> + <p>506 507 480 479</p> + <p>507 508 481 480</p> + <p>508 509 482 481</p> + <p>509 510 483 482</p> + <p>510 511 484 483</p> + <p>511 512 485 484</p> + <p>513 514 487 486</p> + <p>514 515 488 487</p> + <p>515 516 489 488</p> + <p>516 517 490 489</p> + <p>517 518 491 490</p> + <p>518 519 492 491</p> + <p>519 520 493 492</p> + <p>520 521 494 493</p> + <p>521 522 495 494</p> + <p>522 523 496 495</p> + <p>523 524 497 496</p> + <p>524 525 498 497</p> + <p>525 526 499 498</p> + <p>526 527 500 499</p> + <p>527 528 501 500</p> + <p>528 529 502 501</p> + <p>529 530 503 502</p> + <p>530 531 504 503</p> + <p>531 532 505 504</p> + <p>532 533 506 505</p> + <p>533 534 507 506</p> + <p>534 535 508 507</p> + <p>535 536 509 508</p> + <p>536 537 510 509</p> + <p>537 538 511 510</p> + <p>538 539 512 511</p> + <p>540 541 514 513</p> + <p>541 542 515 514</p> + <p>542 543 516 515</p> + <p>543 544 517 516</p> + <p>544 545 518 517</p> + <p>545 546 519 518</p> + <p>546 547 520 519</p> + <p>547 548 521 520</p> + <p>548 549 522 521</p> + <p>549 550 523 522</p> + <p>550 551 524 523</p> + <p>551 552 525 524</p> + <p>552 553 526 525</p> + <p>553 554 527 526</p> + <p>554 555 528 527</p> + <p>555 556 529 528</p> + <p>556 557 530 529</p> + <p>557 558 531 530</p> + <p>558 559 532 531</p> + <p>559 560 533 532</p> + <p>560 561 534 533</p> + <p>561 562 535 534</p> + <p>562 563 536 535</p> + <p>563 564 537 536</p> + <p>564 565 538 537</p> + <p>565 566 539 538</p> + <p>567 568 541 540</p> + <p>568 569 542 541</p> + <p>569 570 543 542</p> + <p>570 571 544 543</p> + <p>571 572 545 544</p> + <p>572 573 546 545</p> + <p>573 574 547 546</p> + <p>574 575 548 547</p> + <p>575 576 549 548</p> + <p>576 577 550 549</p> + <p>577 578 551 550</p> + <p>578 579 552 551</p> + <p>579 580 553 552</p> + <p>580 581 554 553</p> + <p>581 582 555 554</p> + <p>582 583 556 555</p> + <p>583 584 557 556</p> + <p>584 585 558 557</p> + <p>585 586 559 558</p> + <p>586 587 560 559</p> + <p>587 588 561 560</p> + <p>588 589 562 561</p> + <p>589 590 563 562</p> + <p>590 591 564 563</p> + <p>591 592 565 564</p> + <p>592 593 566 565</p> + <p>594 595 568 567</p> + <p>595 596 569 568</p> + <p>596 597 570 569</p> + <p>597 598 571 570</p> + <p>598 599 572 571</p> + <p>599 600 573 572</p> + <p>600 601 574 573</p> + <p>601 602 575 574</p> + <p>602 603 576 575</p> + <p>603 604 577 576</p> + <p>604 605 578 577</p> + <p>605 606 579 578</p> + <p>606 607 580 579</p> + <p>607 608 581 580</p> + <p>608 609 582 581</p> + <p>609 610 583 582</p> + <p>610 611 584 583</p> + <p>611 612 585 584</p> + <p>612 613 586 585</p> + <p>613 614 587 586</p> + <p>614 615 588 587</p> + <p>615 616 589 588</p> + <p>616 617 590 589</p> + <p>617 618 591 590</p> + <p>618 619 592 591</p> + <p>619 620 593 592</p> + <p>621 622 595 594</p> + <p>622 623 596 595</p> + <p>623 624 597 596</p> + <p>624 625 598 597</p> + <p>625 626 599 598</p> + <p>626 627 600 599</p> + <p>627 628 601 600</p> + <p>628 629 602 601</p> + <p>629 630 603 602</p> + <p>630 631 604 603</p> + <p>631 632 605 604</p> + <p>632 633 606 605</p> + <p>633 634 607 606</p> + <p>634 635 608 607</p> + <p>635 636 609 608</p> + <p>636 637 610 609</p> + <p>637 638 611 610</p> + <p>638 639 612 611</p> + <p>639 640 613 612</p> + <p>640 641 614 613</p> + <p>641 642 615 614</p> + <p>642 643 616 615</p> + <p>643 644 617 616</p> + <p>644 645 618 617</p> + <p>645 646 619 618</p> + <p>646 647 620 619</p> + <p>648 649 622 621</p> + <p>649 650 623 622</p> + <p>650 651 624 623</p> + <p>651 652 625 624</p> + <p>652 653 626 625</p> + <p>653 654 627 626</p> + <p>654 655 628 627</p> + <p>655 656 629 628</p> + <p>656 657 630 629</p> + <p>657 658 631 630</p> + <p>658 659 632 631</p> + <p>659 660 633 632</p> + <p>660 661 634 633</p> + <p>661 662 635 634</p> + <p>662 663 636 635</p> + <p>663 664 637 636</p> + <p>664 665 638 637</p> + <p>665 666 639 638</p> + <p>666 667 640 639</p> + <p>667 668 641 640</p> + <p>668 669 642 641</p> + <p>669 670 643 642</p> + <p>670 671 644 643</p> + <p>671 672 645 644</p> + <p>672 673 646 645</p> + <p>673 674 647 646</p> + <p>675 676 649 648</p> + <p>676 677 650 649</p> + <p>677 678 651 650</p> + <p>678 679 652 651</p> + <p>679 680 653 652</p> + <p>680 681 654 653</p> + <p>681 682 655 654</p> + <p>682 683 656 655</p> + <p>683 684 657 656</p> + <p>684 685 658 657</p> + <p>685 686 659 658</p> + <p>686 687 660 659</p> + <p>687 688 661 660</p> + <p>688 689 662 661</p> + <p>689 690 663 662</p> + <p>690 691 664 663</p> + <p>691 692 665 664</p> + <p>692 693 666 665</p> + <p>693 694 667 666</p> + <p>694 695 668 667</p> + <p>695 696 669 668</p> + <p>696 697 670 669</p> + <p>697 698 671 670</p> + <p>698 699 672 671</p> + <p>699 700 673 672</p> + <p>700 701 674 673</p> + <p>702 703 676 675</p> + <p>703 704 677 676</p> + <p>704 705 678 677</p> + <p>705 706 679 678</p> + <p>706 707 680 679</p> + <p>707 708 681 680</p> + <p>708 709 682 681</p> + <p>709 710 683 682</p> + <p>710 711 684 683</p> + <p>711 712 685 684</p> + <p>712 713 686 685</p> + <p>713 714 687 686</p> + <p>714 715 688 687</p> + <p>715 716 689 688</p> + <p>716 717 690 689</p> + <p>717 718 691 690</p> + <p>718 719 692 691</p> + <p>719 720 693 692</p> + <p>720 721 694 693</p> + <p>721 722 695 694</p> + <p>722 723 696 695</p> + <p>723 724 697 696</p> + <p>724 725 698 697</p> + <p>725 726 699 698</p> + <p>726 727 700 699</p> + <p>727 728 701 700</p> + <p>27 28 0</p> + <p>28 29 1</p> + <p>29 30 2</p> + <p>30 31 3</p> + <p>31 32 4</p> + <p>32 33 5</p> + <p>33 34 6</p> + <p>34 35 7</p> + <p>35 36 8</p> + <p>36 37 9</p> + <p>37 38 10</p> + <p>38 39 11</p> + <p>39 40 12</p> + <p>40 41 13</p> + <p>41 42 14</p> + <p>42 43 15</p> + <p>43 44 16</p> + <p>44 45 17</p> + <p>45 46 18</p> + <p>46 47 19</p> + <p>47 48 20</p> + <p>48 49 21</p> + <p>49 50 22</p> + <p>50 51 23</p> + <p>51 52 24</p> + <p>52 53 25</p> + <p>703 702 729</p> + <p>704 703 730</p> + <p>705 704 731</p> + <p>706 705 732</p> + <p>707 706 733</p> + <p>708 707 734</p> + <p>709 708 735</p> + <p>710 709 736</p> + <p>711 710 737</p> + <p>712 711 738</p> + <p>713 712 739</p> + <p>714 713 740</p> + <p>715 714 741</p> + <p>716 715 742</p> + <p>717 716 743</p> + <p>718 717 744</p> + <p>719 718 745</p> + <p>720 719 746</p> + <p>721 720 747</p> + <p>722 721 748</p> + <p>723 722 749</p> + <p>724 723 750</p> + <p>725 724 751</p> + <p>726 725 752</p> + <p>727 726 753</p> + <p>728 727 754</p> + </polygons> + </mesh> + </geometry> + </library_geometries> + <library_lights> + <light id="PointLight" name="PointLight"> + <technique_common> + <point> + <color>1 1 1</color> + <constant_attenuation>1</constant_attenuation> + <linear_attenuation>0</linear_attenuation> + <quadratic_attenuation>0</quadratic_attenuation> + </point> + </technique_common> + </light> + <light id="DirectionalLight" name="DirectionalLight"> + <technique_common> + <directional> + <color>1 1 1</color> + </directional> + </technique_common> + </light> + </library_lights> + <scene> + <instance_visual_scene url="#DefaultScene"/> + </scene> +</COLLADA> diff --git a/data2009/CgFX/basic-lighting/Lambert.cgfx b/data2009/CgFX/basic-lighting/Lambert.cgfx new file mode 100644 index 000000000..e27db52f9 --- /dev/null +++ b/data2009/CgFX/basic-lighting/Lambert.cgfx @@ -0,0 +1,285 @@ +/*********************************************************************NVMH3**** +$Revision$ + +Copyright NVIDIA Corporation 2007 +TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED +*AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS +BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES +WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, +BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY +LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF +NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + + +To learn more about shading, shaders, and to bounce ideas off other shader + authors and users, visit the NVIDIA Shader Library Forums at: + + http://developer.nvidia.com/forums/ + +******************************************************************************/ + +#define FLIP_TEXTURE_Y + +float Script : STANDARDSGLOBAL < + string UIWidget = "none"; + string ScriptClass = "object"; + string ScriptOrder = "standard"; + string ScriptOutput = "color"; + string Script = "Technique=Main;"; +> = 0.8; + +//// UN-TWEAKABLES - AUTOMATICALLY-TRACKED TRANSFORMS //////////////// + +float4x4 WorldITXf : WorldInverseTranspose < string UIWidget="None"; >; +float4x4 WvpXf : WorldViewProjection < string UIWidget="None"; >; +float4x4 WorldXf : World < string UIWidget="None"; >; +float4x4 ViewIXf : ViewInverse < string UIWidget="None"; >; + +//// TWEAKABLE PARAMETERS //////////////////// + +/// Point Lamp 0 //////////// +float3 Lamp0Pos : Position < + string Object = "PointLight0"; + string UIName = "Lamp 0 Position"; + string Space = "World"; +> = {-0.5f,2.0f,1.25f}; + +float3 Lamp0Color : Specular < + string UIName = "Lamp 0"; + string Object = "Pointlight0"; + string UIWidget = "Color"; +> = {1.0f,1.0f,1.0f}; + +// Ambient Light +float3 AmbiColor : Ambient < + string UIName = "Ambient Light"; + string UIWidget = "Color"; +> = {0.07f,0.07f,0.07f}; + + +//////// COLOR & TEXTURE ///////////////////// + +/// the ambient material colour +float4 m_Ambient; + +/// the diffuse colour +float4 m_Diffuse; + +/// the specular colour +float4 m_Specular; + +/// the emission colour +float4 m_Emission; + +/// the transparency colour +float4 m_Transparency; + +/// the shininess +float m_Shininess; + +texture ColorTexture < + string ResourceName = "default_color.dds"; + string UIName = "Diffuse Texture"; + string ResourceType = "2D"; +>; + +sampler2D ColorSampler = sampler_state { + Texture = <ColorTexture>; + MinFilter = LinearMipMapLinear; + MagFilter = Linear; + WrapS = Repeat; + WrapT = Repeat; +}; + +//////// CONNECTOR DATA STRUCTURES /////////// + +/* data from application vertex buffer */ +struct appdata { + float3 Position : POSITION; + float4 UV : TEXCOORD0; + float4 Normal : NORMAL; + float4 Tangent : TANGENT0; + float4 Binormal : BINORMAL0; +}; + +/* data passed from vertex shader to pixel shader */ +struct vertexOutput { + float4 HPosition : POSITION; + float2 UV : TEXCOORD0; + // The following values are passed in "World" coordinates since + // it tends to be the most flexible and easy for handling + // reflections, sky lighting, and other "global" effects. + float3 LightVec : TEXCOORD1; + float3 WorldNormal : TEXCOORD2; + float3 WorldTangent : TEXCOORD3; + float3 WorldBinormal : TEXCOORD4; + float3 WorldView : TEXCOORD5; +}; + +///////// VERTEX SHADING ///////////////////// + +/*********** Generic Vertex Shader ******/ + +vertexOutput std_VS(appdata IN) { + vertexOutput OUT = (vertexOutput)0; + OUT.WorldNormal = mul(WorldITXf,IN.Normal).xyz; + OUT.WorldTangent = mul(WorldITXf,IN.Tangent).xyz; + OUT.WorldBinormal = mul(WorldITXf,IN.Binormal).xyz; + float4 Po = float4(IN.Position.xyz,1); + float3 Pw = mul(WorldXf,Po).xyz; + OUT.LightVec = (Lamp0Pos - Pw); +#ifdef FLIP_TEXTURE_Y + OUT.UV = float2(IN.UV.x,(1.0-IN.UV.y)); +#else /* !FLIP_TEXTURE_Y */ + OUT.UV = IN.UV.xy; +#endif /* !FLIP_TEXTURE_Y */ + OUT.WorldView = normalize(float3(ViewIXf[0].w,ViewIXf[1].w,ViewIXf[2].w) - Pw); + OUT.HPosition = mul(WvpXf,Po); + return OUT; +} + +///////// PIXEL SHADING ////////////////////// + +float4 std_PS(vertexOutput IN, + float face : FACE) : COLOR { + float3 Ln = normalize(IN.LightVec); + float3 Nn = face * normalize(IN.WorldNormal); + float ldn = dot(Ln,Nn); + ldn = max(ldn,0.0); + float4 textureColor = tex2D(ColorSampler,IN.UV); + float3 result = textureColor.rgb * (ldn * Lamp0Color + AmbiColor); + // return as float4 + return float4(result, textureColor.a); +} + +float4 No_Texture_PS(vertexOutput IN, + float face : FACE) : COLOR { + float3 Ln = normalize(IN.LightVec); + float3 Nn = face * normalize(IN.WorldNormal); + float ldn = dot(Ln,Nn); + ldn = max(ldn,0.0); + float3 result = m_Diffuse.rgb * (ldn * Lamp0Color + AmbiColor); + // return as float4 + return float4(result, m_Diffuse.a); +} + +///// TECHNIQUES ///////////////////////////// + +technique Main < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = true; + CullFaceEnable = false; + BlendEnable = false; + DepthFunc = LEqual; + FragmentProgram = compile fp40 std_PS(); + } +} + +technique Main_Blending < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = false; + CullFaceEnable = false; + BlendEnable = true; + BlendFunc = float2(SrcAlpha, OneMinusSrcAlpha); + DepthFunc = LEqual; + FragmentProgram = compile fp40 std_PS(); + } +} + +technique Main_Alphatest < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = true; + CullFaceEnable = false; + AlphaFunc = float2(Greater, 0.1f); + AlphaTestEnable = true; + FragmentProgram = compile fp40 std_PS(); + } +} + +technique No_Texture < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = true; + CullFaceEnable = false; + BlendEnable = false; + DepthFunc = LEqual; + FragmentProgram = compile fp40 No_Texture_PS(); + } +} + +technique No_Texture_Blending < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = false; + CullFaceEnable = false; + BlendEnable = true; + BlendFunc = float2(SrcAlpha, OneMinusSrcAlpha); + DepthFunc = LEqual; + FragmentProgram = compile fp40 No_Texture_PS(); + } +} + +technique Main_Specular < // this is dummy. Lambert does not have specular + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = true; + CullFaceEnable = false; + BlendEnable = false; + DepthFunc = LEqual; + FragmentProgram = compile fp40 std_PS(); + } +} + +technique Main_Specular_Blending < // this is dummy. Lambert does not have specular + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = false; + CullFaceEnable = false; + BlendEnable = true; + BlendFunc = float2(SrcAlpha, OneMinusSrcAlpha); + DepthFunc = LEqual; + FragmentProgram = compile fp40 std_PS(); + } +} + +/////////////////////////////////////// eof // diff --git a/data2009/CgFX/basic-lighting/Lambert_bump_reflect.cgfx b/data2009/CgFX/basic-lighting/Lambert_bump_reflect.cgfx new file mode 100644 index 000000000..1907f5934 --- /dev/null +++ b/data2009/CgFX/basic-lighting/Lambert_bump_reflect.cgfx @@ -0,0 +1,227 @@ +/*********************************************************************NVMH3**** +$Revision$ + +Copyright NVIDIA Corporation 2007 +TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED +*AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS +BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES +WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, +BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY +LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF +NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + + +To learn more about shading, shaders, and to bounce ideas off other shader + authors and users, visit the NVIDIA Shader Library Forums at: + + http://developer.nvidia.com/forums/ + +******************************************************************************/ + +// #define FLIP_TEXTURE_Y + +float Script : STANDARDSGLOBAL < + string UIWidget = "none"; + string ScriptClass = "object"; + string ScriptOrder = "standard"; + string ScriptOutput = "color"; + string Script = "Technique=Main;"; +> = 0.8; + +//// UN-TWEAKABLES - AUTOMATICALLY-TRACKED TRANSFORMS //////////////// + +float4x4 WorldITXf : WorldInverseTranspose < string UIWidget="None"; >; +float4x4 WvpXf : WorldViewProjection < string UIWidget="None"; >; +float4x4 WorldXf : World < string UIWidget="None"; >; +float4x4 ViewIXf : ViewInverse < string UIWidget="None"; >; + +//// TWEAKABLE PARAMETERS //////////////////// + +/// Point Lamp 0 //////////// +float3 Lamp0Pos : Position < + string Object = "PointLight0"; + string UIName = "Lamp 0 Position"; + string Space = "World"; +> = {-0.5f,2.0f,1.25f}; +float3 Lamp0Color : Specular < + string UIName = "Lamp 0"; + string Object = "Pointlight0"; + string UIWidget = "Color"; +> = {1.0f,1.0f,1.0f}; + +// Ambient Light +float3 AmbiColor : Ambient < + string UIName = "Ambient Light"; + string UIWidget = "Color"; +> = {0.07f,0.07f,0.07f}; + + +float Bump < + string UIWidget = "slider"; + float UIMin = 0.0; + float UIMax = 3.0; + float UIStep = 0.01; + string UIName = "Bumpiness"; +> = 1.0; + +float Kr < + string UIWidget = "slider"; + float UIMin = 0.0; + float UIMax = 1.0; + float UIStep = 0.01; + string UIName = "Reflection Strength"; +> = 1.0; + +float KrMin < + string UIWidget = "slider"; + float UIMin = 0.0; + float UIMax = 0.25; + float UIStep = 0.001; + string UIName = "Fresnel Scale"; +> = 0.05; + +float FresExp < + string UIWidget = "slider"; + float UIMin = 0.0; + float UIMax = 5.0; + float UIStep = 0.5; + string UIName = "Fresnel Exponent"; +> = 4.0; + +//////// COLOR & TEXTURE ///////////////////// + +texture ColorTexture < + string ResourceName = "default_color.dds"; + string UIName = "Diffuse Texture"; + string ResourceType = "2D"; +>; + +sampler2D ColorSampler = sampler_state { + Texture = <ColorTexture>; + MinFilter = LinearMipMapLinear; + MagFilter = Linear; + WrapS = Repeat; + WrapT = Repeat; +}; + +texture NormalTexture < + string ResourceName = "default_bump_normal.dds"; + string UIName = "Normal-Map Texture"; + string ResourceType = "2D"; +>; + +sampler2D NormalSampler = sampler_state { + Texture = <NormalTexture>; + MinFilter = LinearMipMapLinear; + MagFilter = Linear; + WrapS = Repeat; + WrapT = Repeat; +}; + +texture EnvTexture : ENVIRONMENT < + string ResourceName = "default_reflection.dds"; + string UIName = "Environment"; + string ResourceType = "Cube"; +>; + +samplerCUBE EnvSampler = sampler_state { + Texture = <EnvTexture>; + MagFilter = Linear; + MinFilter = LinearMipMapLinear; + WrapS = ClampToEdge; + WrapT = ClampToEdge; + WrapR = ClampToEdge; +}; + + +//////// CONNECTOR DATA STRUCTURES /////////// + +/* data from application vertex buffer */ +struct appdata { + float3 Position : POSITION; + float4 UV : TEXCOORD0; + float4 Normal : NORMAL; + float4 Tangent : TANGENT0; + float4 Binormal : BINORMAL0; +}; + +/* data passed from vertex shader to pixel shader */ +struct vertexOutput { + float4 HPosition : POSITION; + float2 UV : TEXCOORD0; + // The following values are passed in "World" coordinates since + // it tends to be the most flexible and easy for handling + // reflections, sky lighting, and other "global" effects. + float3 LightVec : TEXCOORD1; + float3 WorldNormal : TEXCOORD2; + float3 WorldTangent : TEXCOORD3; + float3 WorldBinormal : TEXCOORD4; + float3 WorldView : TEXCOORD5; +}; + +///////// VERTEX SHADING ///////////////////// + +/*********** Generic Vertex Shader ******/ + +vertexOutput std_VS(appdata IN) { + vertexOutput OUT = (vertexOutput)0; + OUT.WorldNormal = mul(WorldITXf,IN.Normal).xyz; + OUT.WorldTangent = mul(WorldITXf,IN.Tangent).xyz; + OUT.WorldBinormal = mul(WorldITXf,IN.Binormal).xyz; + float4 Po = float4(IN.Position.xyz,1); + float3 Pw = mul(WorldXf,Po).xyz; + OUT.LightVec = (Lamp0Pos - Pw); +#ifdef FLIP_TEXTURE_Y + OUT.UV = float2(IN.UV.x,(1.0-IN.UV.y)); +#else /* !FLIP_TEXTURE_Y */ + OUT.UV = IN.UV.xy; +#endif /* !FLIP_TEXTURE_Y */ + OUT.WorldView = normalize(float3(ViewIXf[0].w,ViewIXf[1].w,ViewIXf[2].w) - Pw); + OUT.HPosition = mul(WvpXf,Po); + return OUT; +} + +///////// PIXEL SHADING ////////////////////// + +float4 std_PS(vertexOutput IN) : COLOR { + float3 Ln = normalize(IN.LightVec); + float3 Nn = normalize(IN.WorldNormal); + float3 Tn = normalize(IN.WorldTangent); + float3 Bn = normalize(IN.WorldBinormal); + float3 bump = Bump * (tex2D(NormalSampler,IN.UV).rgb - float3(0.5,0.5,0.5)); + Nn = Nn + bump.x*Tn + bump.y*Bn; + Nn = normalize(Nn); + float ldn = dot(Ln,Nn); + ldn = max(ldn,0.0); + float3 diffuseColor = tex2D(ColorSampler,IN.UV).rgb; + float3 result = diffuseColor * (ldn * Lamp0Color + AmbiColor); + float3 Vn = normalize(IN.WorldView); + float3 R = -reflect(Vn,Nn); + float vdn = dot(Vn,Nn); + half fres = KrMin + (Kr-KrMin) * pow(1-abs(vdn),FresExp); + float3 reflColor = fres * texCUBE(EnvSampler,R.xyz).rgb; + result += reflColor; + return float4(result,1); +} + +///// TECHNIQUES ///////////////////////////// + +technique Main < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = true; + CullFaceEnable = false; + BlendEnable = false; + DepthFunc = LEqual; + FragmentProgram = compile fp40 std_PS(); + } +} + +/////////////////////////////////////// eof // diff --git a/data2009/CgFX/basic-lighting/Phong.cgfx b/data2009/CgFX/basic-lighting/Phong.cgfx new file mode 100644 index 000000000..65508198f --- /dev/null +++ b/data2009/CgFX/basic-lighting/Phong.cgfx @@ -0,0 +1,360 @@ +/*********************************************************************NVMH3**** +$Revision$ + +Copyright NVIDIA Corporation 2007 +TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED +*AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS +BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES +WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, +BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY +LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF +NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + + +To learn more about shading, shaders, and to bounce ideas off other shader + authors and users, visit the NVIDIA Shader Library Forums at: + + http://developer.nvidia.com/forums/ + +******************************************************************************/ + +#define FLIP_TEXTURE_Y + +float Script : STANDARDSGLOBAL < + string UIWidget = "none"; + string ScriptClass = "object"; + string ScriptOrder = "standard"; + string ScriptOutput = "color"; + string Script = "Technique=Main;"; +> = 0.8; + +//// UN-TWEAKABLES - AUTOMATICALLY-TRACKED TRANSFORMS //////////////// + +float4x4 WorldITXf : WorldInverseTranspose < string UIWidget="None"; >; +float4x4 WvpXf : WorldViewProjection < string UIWidget="None"; >; +float4x4 WorldXf : World < string UIWidget="None"; >; +float4x4 ViewIXf : ViewInverse < string UIWidget="None"; >; + +//// TWEAKABLE PARAMETERS //////////////////// + +/// Point Lamp 0 //////////// +float3 Lamp0Pos : Position < + string Object = "PointLight0"; + string UIName = "Lamp 0 Position"; + string Space = "World"; +> = {-0.5f,2.0f,1.25f}; +float3 Lamp0Color : Specular < + string UIName = "Lamp 0"; + string Object = "Pointlight0"; + string UIWidget = "Color"; +> = {1.0f,1.0f,1.0f}; + +// Ambient Light +float3 AmbiColor : Ambient < + string UIName = "Ambient Light"; + string UIWidget = "Color"; +> = {0.07f,0.07f,0.07f}; + +float Ks < + string UIWidget = "slider"; + float UIMin = 0.0; + float UIMax = 1.0; + float UIStep = 0.05; + string UIName = "Specular"; +> = 0.4; + +float SpecExpon : SpecularPower < + string UIWidget = "slider"; + float UIMin = 1.0; + float UIMax = 128.0; + float UIStep = 1.0; + string UIName = "Specular Power"; +> = 55.0; + + +//////// COLOR & TEXTURE ///////////////////// + +/// the ambient material colour +float4 m_Ambient; + +/// the diffuse colour +float4 m_Diffuse; + +/// the specular colour +float4 m_Specular; + +/// the emission colour +float4 m_Emission; + +/// the transparency colour +float4 m_Transparency; + +/// the shininess +float m_Shininess; + +texture ColorTexture < + string ResourceName = "default_color.dds"; + string UIName = "Diffuse Texture"; + string ResourceType = "2D"; +>; + +sampler2D ColorSampler = sampler_state { + Texture = <ColorTexture>; + MinFilter = LinearMipMapLinear; + MagFilter = Linear; + WrapS = Repeat; + WrapT = Repeat; +}; + +texture SpecularTexture < + string ResourceName = "checker.dds"; + string UIName = "Specular Texture"; + string ResourceType = "2D"; +>; + +sampler2D SpecularSampler = sampler_state { + Texture = <SpecularTexture>; + MinFilter = LinearMipMapLinear; + MagFilter = Linear; + WrapS = Repeat; + WrapT = Repeat; +}; + +//////// CONNECTOR DATA STRUCTURES /////////// + +/* data from application vertex buffer */ +struct appdata { + float3 Position : POSITION; + float4 UV : TEXCOORD0; + float4 Normal : NORMAL; + float4 Tangent : TANGENT0; + float4 Binormal : BINORMAL0; +}; + +/* data passed from vertex shader to pixel shader */ +struct vertexOutput { + float4 HPosition : POSITION; + float2 UV : TEXCOORD0; + // The following values are passed in "World" coordinates since + // it tends to be the most flexible and easy for handling + // reflections, sky lighting, and other "global" effects. + float3 LightVec : TEXCOORD1; + float3 WorldNormal : TEXCOORD2; + float3 WorldTangent : TEXCOORD3; + float3 WorldBinormal : TEXCOORD4; + float3 WorldView : TEXCOORD5; +}; + +///////// VERTEX SHADING ///////////////////// + +/*********** Generic Vertex Shader ******/ + +vertexOutput std_VS(appdata IN) { + vertexOutput OUT = (vertexOutput)0; + OUT.WorldNormal = mul(WorldITXf,IN.Normal).xyz; + OUT.WorldTangent = mul(WorldITXf,IN.Tangent).xyz; + OUT.WorldBinormal = mul(WorldITXf,IN.Binormal).xyz; + float4 Po = float4(IN.Position.xyz,1); + float3 Pw = mul(WorldXf,Po).xyz; + OUT.LightVec = (Lamp0Pos - Pw); +#ifdef FLIP_TEXTURE_Y + OUT.UV = float2(IN.UV.x,(1.0-IN.UV.y)); +#else /* !FLIP_TEXTURE_Y */ + OUT.UV = IN.UV.xy; +#endif /* !FLIP_TEXTURE_Y */ + OUT.WorldView = normalize(float3(ViewIXf[0].w,ViewIXf[1].w,ViewIXf[2].w) - Pw); + OUT.HPosition = mul(WvpXf,Po); + return OUT; +} + +///////// PIXEL SHADING ////////////////////// + +// Utility function for phong shading + +void phong_shading(vertexOutput IN, + float3 LightColor, + float3 Nn, + float3 Ln, + float3 Vn, + out float3 DiffuseContrib, + out float3 SpecularContrib) +{ + float3 Hn = normalize(Vn + Ln); + float4 litV = lit(dot(Ln,Nn),dot(Hn,Nn),SpecExpon); + DiffuseContrib = litV.y * LightColor; + SpecularContrib = litV.y * litV.z * Ks * LightColor; +} + +float4 std_PS(vertexOutput IN, + float face : FACE) : COLOR { + float3 diffContrib; + float3 specContrib; + float3 Ln = normalize(IN.LightVec); + float3 Vn = normalize(IN.WorldView); + float3 Nn = face * normalize(IN.WorldNormal); + phong_shading(IN,Lamp0Color,Nn,Ln,Vn,diffContrib,specContrib); + float4 textureColor = tex2D(ColorSampler,IN.UV); + float3 diffuseTerm = textureColor.rgb * (diffContrib+AmbiColor); + float3 specularTerm = m_Specular.rgb * specContrib; + float3 result = specularTerm + diffuseTerm; + float alpha = textureColor.a; + return float4(result, alpha); +} + +float4 No_Texture_PS(vertexOutput IN, + float face : FACE) : COLOR { + float3 diffContrib; + float3 specContrib; + float3 Ln = normalize(IN.LightVec); + float3 Vn = normalize(IN.WorldView); + float3 Nn = face * normalize(IN.WorldNormal); + phong_shading(IN,Lamp0Color,Nn,Ln,Vn,diffContrib,specContrib); + float3 diffuseTerm = m_Diffuse.rgb * (diffContrib+AmbiColor); + float3 specularTerm = m_Specular.rgb * specContrib; + float3 result = specularTerm + diffuseTerm; + float alpha = m_Diffuse.a; + return float4(result, alpha); +} + +float4 Specular_Texture_PS(vertexOutput IN, + float face : FACE) : COLOR { + float3 diffContrib; + float3 specContrib; + float3 Ln = normalize(IN.LightVec); + float3 Vn = normalize(IN.WorldView); + float3 Nn = face * normalize(IN.WorldNormal); + phong_shading(IN,Lamp0Color,Nn,Ln,Vn,diffContrib,specContrib); + + float4 textureColor = tex2D(ColorSampler,IN.UV); + float3 diffuseTerm = textureColor.rgb * (diffContrib+AmbiColor); + + float4 specularTextureColor = tex2D(SpecularSampler, IN.UV); + float specularMask = dot( specularTextureColor.rgb, float3(1,1,1) ) / 3.0f; // average of r,g,b + float3 specularTerm = specularMask * specContrib; + + float3 result = specularTerm + diffuseTerm; + float alpha = textureColor.a; + return float4(result, alpha); +} + +///// TECHNIQUES ///////////////////////////// + +technique Main < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = true; + CullFaceEnable = false; + BlendEnable = false; + DepthFunc = LEqual; + FragmentProgram = compile fp40 std_PS(); + } +} + +technique Main_Blending < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = false; + CullFaceEnable = false; + BlendEnable = true; + BlendFunc = float2(SrcAlpha, OneMinusSrcAlpha); + DepthFunc = LEqual; + FragmentProgram = compile fp40 std_PS(); + } +} + +technique Main_Alphatest < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = true; + CullFaceEnable = false; + AlphaFunc = float2(Greater, 0.1f); + AlphaTestEnable = true; + FragmentProgram = compile fp40 std_PS(); + } +} + +technique No_Texture < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = true; + CullFaceEnable = false; + BlendEnable = false; + DepthFunc = LEqual; + FragmentProgram = compile fp40 No_Texture_PS(); + } +} + +technique No_Texture_Blending < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = false; + CullFaceEnable = false; + BlendEnable = true; + BlendFunc = float2(SrcAlpha, OneMinusSrcAlpha); + DepthFunc = LEqual; + FragmentProgram = compile fp40 No_Texture_PS(); + } +} + +technique Main_Specular < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = true; + CullFaceEnable = false; + BlendEnable = false; + DepthFunc = LEqual; + FragmentProgram = compile fp40 Specular_Texture_PS(); + } +} + +technique Main_Specular_Blending < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = false; + CullFaceEnable = false; + //AlphaFunc = float2(Greater, 0.1f); + //AlphaTestEnable = true; + BlendEnable = true; + BlendFunc = float2(SrcAlpha, OneMinusSrcAlpha); + DepthFunc = LEqual; + FragmentProgram = compile fp40 Specular_Texture_PS(); + } +} +/////////////////////////////////////// eof // diff --git a/data2009/CgFX/basic-lighting/Phong_bump_reflect.cgfx b/data2009/CgFX/basic-lighting/Phong_bump_reflect.cgfx new file mode 100644 index 000000000..73f5168fa --- /dev/null +++ b/data2009/CgFX/basic-lighting/Phong_bump_reflect.cgfx @@ -0,0 +1,241 @@ +/*********************************************************************NVMH3**** +$Revision$ + +Copyright NVIDIA Corporation 2007 +TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED +*AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS +BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES +WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, +BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY +LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF +NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + + +To learn more about shading, shaders, and to bounce ideas off other shader + authors and users, visit the NVIDIA Shader Library Forums at: + + http://developer.nvidia.com/forums/ + +******************************************************************************/ + +// #define FLIP_TEXTURE_Y + +float Script : STANDARDSGLOBAL < + string UIWidget = "none"; + string ScriptClass = "object"; + string ScriptOrder = "standard"; + string ScriptOutput = "color"; + string Script = "Technique=Main;"; +> = 0.8; + +//// UN-TWEAKABLES - AUTOMATICALLY-TRACKED TRANSFORMS //////////////// + +float4x4 WorldITXf : WorldInverseTranspose < string UIWidget="None"; >; +float4x4 WvpXf : WorldViewProjection < string UIWidget="None"; >; +float4x4 WorldXf : World < string UIWidget="None"; >; +float4x4 ViewIXf : ViewInverse < string UIWidget="None"; >; + +//// TWEAKABLE PARAMETERS //////////////////// + +/// Point Lamp 0 //////////// +float3 Lamp0Pos : Position < + string Object = "PointLight0"; + string UIName = "Lamp 0 Position"; + string Space = "World"; +> = {-0.5f,2.0f,1.25f}; +float3 Lamp0Color : Specular < + string UIName = "Lamp 0"; + string Object = "Pointlight0"; + string UIWidget = "Color"; +> = {1.0f,1.0f,1.0f}; + +// Ambient Light +float3 AmbiColor : Ambient < + string UIName = "Ambient Light"; + string UIWidget = "Color"; +> = {0.07f,0.07f,0.07f}; + +float Ks < + string UIWidget = "slider"; + float UIMin = 0.0; + float UIMax = 1.0; + float UIStep = 0.05; + string UIName = "Specular"; +> = 0.4; + +float SpecExpon : SpecularPower < + string UIWidget = "slider"; + float UIMin = 1.0; + float UIMax = 128.0; + float UIStep = 1.0; + string UIName = "Specular Power"; +> = 55.0; + + +float Bump < + string UIWidget = "slider"; + float UIMin = 0.0; + float UIMax = 3.0; + float UIStep = 0.01; + string UIName = "Bumpiness"; +> = 1.0; + +float Kr < + string UIWidget = "slider"; + float UIMin = 0.0; + float UIMax = 1.0; + float UIStep = 0.01; + string UIName = "Reflection Strength"; +> = 0.5; + +//////// COLOR & TEXTURE ///////////////////// + +texture ColorTexture < + string ResourceName = "default_color.dds"; + string UIName = "Diffuse Texture"; + string ResourceType = "2D"; +>; + +sampler2D ColorSampler = sampler_state { + Texture = <ColorTexture>; + MinFilter = LinearMipMapLinear; + MagFilter = Linear; + WrapS = Repeat; + WrapT = Repeat; +}; + +texture NormalTexture < + string ResourceName = "default_bump_normal.dds"; + string UIName = "Normal-Map Texture"; + string ResourceType = "2D"; +>; + +sampler2D NormalSampler = sampler_state { + Texture = <NormalTexture>; + MinFilter = LinearMipMapLinear; + MagFilter = Linear; + WrapS = Repeat; + WrapT = Repeat; +}; + +texture EnvTexture : ENVIRONMENT < + string ResourceName = "default_reflection.dds"; + string UIName = "Environment"; + string ResourceType = "Cube"; +>; + +samplerCUBE EnvSampler = sampler_state { + Texture = <EnvTexture>; + MagFilter = Linear; + MinFilter = LinearMipMapLinear; + WrapS = ClampToEdge; + WrapT = ClampToEdge; + WrapR = ClampToEdge; +}; + +//////// CONNECTOR DATA STRUCTURES /////////// + +/* data from application vertex buffer */ +struct appdata { + float3 Position : POSITION; + float4 UV : TEXCOORD0; + float4 Normal : NORMAL; + float4 Tangent : TANGENT0; + float4 Binormal : BINORMAL0; +}; + +/* data passed from vertex shader to pixel shader */ +struct vertexOutput { + float4 HPosition : POSITION; + float2 UV : TEXCOORD0; + // The following values are passed in "World" coordinates since + // it tends to be the most flexible and easy for handling + // reflections, sky lighting, and other "global" effects. + float3 LightVec : TEXCOORD1; + float3 WorldNormal : TEXCOORD2; + float3 WorldTangent : TEXCOORD3; + float3 WorldBinormal : TEXCOORD4; + float3 WorldView : TEXCOORD5; +}; + +///////// VERTEX SHADING ///////////////////// + +/*********** Generic Vertex Shader ******/ + +vertexOutput std_VS(appdata IN) { + vertexOutput OUT = (vertexOutput)0; + OUT.WorldNormal = mul(WorldITXf,IN.Normal).xyz; + OUT.WorldTangent = mul(WorldITXf,IN.Tangent).xyz; + OUT.WorldBinormal = mul(WorldITXf,IN.Binormal).xyz; + float4 Po = float4(IN.Position.xyz,1); + float3 Pw = mul(WorldXf,Po).xyz; + OUT.LightVec = (Lamp0Pos - Pw); +#ifdef FLIP_TEXTURE_Y + OUT.UV = float2(IN.UV.x,(1.0-IN.UV.y)); +#else /* !FLIP_TEXTURE_Y */ + OUT.UV = IN.UV.xy; +#endif /* !FLIP_TEXTURE_Y */ + OUT.WorldView = normalize(float3(ViewIXf[0].w,ViewIXf[1].w,ViewIXf[2].w) - Pw); + OUT.HPosition = mul(WvpXf,Po); + return OUT; +} + +///////// PIXEL SHADING ////////////////////// + +// Utility function for phong shading + +void phong_shading(vertexOutput IN, + float3 LightColor, + float3 Nn, + float3 Ln, + float3 Vn, + out float3 DiffuseContrib, + out float3 SpecularContrib) +{ + float3 Hn = normalize(Vn + Ln); + float4 litV = lit(dot(Ln,Nn),dot(Hn,Nn),SpecExpon); + DiffuseContrib = litV.y * LightColor; + SpecularContrib = litV.y * litV.z * Ks * LightColor; +} + +float4 std_PS(vertexOutput IN) : COLOR { + float3 diffContrib; + float3 specContrib; + float3 Ln = normalize(IN.LightVec); + float3 Vn = normalize(IN.WorldView); + float3 Nn = normalize(IN.WorldNormal); + float3 Tn = normalize(IN.WorldTangent); + float3 Bn = normalize(IN.WorldBinormal); + float3 bump = Bump * (tex2D(NormalSampler,IN.UV).rgb - float3(0.5,0.5,0.5)); + Nn = Nn + bump.x*Tn + bump.y*Bn; + Nn = normalize(Nn); + phong_shading(IN,Lamp0Color,Nn,Ln,Vn,diffContrib,specContrib); + float3 diffuseColor = tex2D(ColorSampler,IN.UV).rgb; + float3 result = specContrib+(diffuseColor*(diffContrib+AmbiColor)); + float3 R = -reflect(Vn,Nn); + float3 reflColor = Kr * texCUBE(EnvSampler,R.xyz).rgb; + result += diffuseColor*reflColor; + return float4(result,1); +} + +///// TECHNIQUES ///////////////////////////// + +technique Main < + string Script = "Pass=p0;"; +> { + pass p0 < + string Script = "Draw=geometry;"; + > { + VertexProgram = compile vp40 std_VS(); + DepthTestEnable = true; + DepthMask = true; + CullFaceEnable = false; + BlendEnable = false; + DepthFunc = LEqual; + FragmentProgram = compile fp40 std_PS(); + } +} + +/////////////////////////////////////// eof // diff --git a/data2009/CgFX/basic-lighting/simple.cgfx b/data2009/CgFX/basic-lighting/simple.cgfx new file mode 100644 index 000000000..4ef9f90f5 --- /dev/null +++ b/data2009/CgFX/basic-lighting/simple.cgfx @@ -0,0 +1,54 @@ +float4 main(float4 uv : TEXCOORD3) : COLOR +{ + return float4(1,0,0,1); +} + +technique Main { + pass { + VertexProgram = NULL; + FragmentProgram = compile arbfp1 main(); + } +} + +technique Main_Blending { + pass { + VertexProgram = NULL; + FragmentProgram = compile arbfp1 main(); + } +} + +technique Main_Alphatest { + pass { + VertexProgram = NULL; + FragmentProgram = compile arbfp1 main(); + } +} + +technique No_Texture { + pass { + VertexProgram = NULL; + FragmentProgram = compile arbfp1 main(); + } +} + +technique No_Texture_Blending { + pass { + VertexProgram = NULL; + FragmentProgram = compile arbfp1 main(); + } +} + +technique Main_Specular { + pass { + VertexProgram = NULL; + FragmentProgram = compile arbfp1 main(); + } +} + +technique Main_Specular_Blending { + pass { + VertexProgram = NULL; + FragmentProgram = compile arbfp1 main(); + } +} + diff --git a/data2009/DassakV1.0.mb b/data2009/DassakV1.0.mb new file mode 100644 index 000000000..08f6b23e1 Binary files /dev/null and b/data2009/DassakV1.0.mb differ diff --git a/data2009/GoblinV1.0.mb b/data2009/GoblinV1.0.mb new file mode 100644 index 000000000..e16192aef Binary files /dev/null and b/data2009/GoblinV1.0.mb differ diff --git a/data2009/anim.camera b/data2009/anim.camera new file mode 100644 index 000000000..197b98e5a --- /dev/null +++ b/data2009/anim.camera @@ -0,0 +1,10 @@ +zoom= 1008.199890 +rotx= 15.500000 +roty= 43.500000 +tx= 0.000000 +ty= -70.000000 +lastx= 0.000000 +lasty= 0.000000 +zoomStep= 0.100000 +panStep= 0.050000 +ROTATION= 0.000000 \ No newline at end of file diff --git a/data2009/anim.conf b/data2009/anim.conf new file mode 100644 index 000000000..76c2ce921 --- /dev/null +++ b/data2009/anim.conf @@ -0,0 +1,3 @@ +camera anim.camera +model anim.mb +anim anim.mb diff --git a/data2009/anim.mb b/data2009/anim.mb new file mode 100644 index 000000000..9d69ac3d4 Binary files /dev/null and b/data2009/anim.mb differ diff --git a/data2009/boy3.conf b/data2009/boy3.conf new file mode 100644 index 000000000..d80925e3a --- /dev/null +++ b/data2009/boy3.conf @@ -0,0 +1,2 @@ +camera middle.camera +model boy3.mb diff --git a/data2009/boy3.mb b/data2009/boy3.mb new file mode 100644 index 000000000..9c80049d0 Binary files /dev/null and b/data2009/boy3.mb differ diff --git a/data2009/character.camera b/data2009/character.camera new file mode 100644 index 000000000..27f3ed77e --- /dev/null +++ b/data2009/character.camera @@ -0,0 +1,10 @@ +zoom= 34.300049 +rotx= 15.500000 +roty= 43.500000 +tx= -0.700000 +ty= -0.549990 +lastx= 800.000000 +lasty= 1054.000000 +zoomStep= 0.100000 +panStep= 0.050000 +ROTATION= 0.000000 \ No newline at end of file diff --git a/data2009/character.conf b/data2009/character.conf new file mode 100644 index 000000000..16667d360 --- /dev/null +++ b/data2009/character.conf @@ -0,0 +1,2 @@ +camera character.camera +model character_jump_70.mb diff --git a/data2009/character_jump_70.mb b/data2009/character_jump_70.mb new file mode 100644 index 000000000..c12be708f Binary files /dev/null and b/data2009/character_jump_70.mb differ diff --git a/data2009/generi_rig.mb b/data2009/generi_rig.mb new file mode 100644 index 000000000..978a5bc70 Binary files /dev/null and b/data2009/generi_rig.mb differ diff --git a/data2009/middle.camera b/data2009/middle.camera new file mode 100644 index 000000000..1f82269e8 --- /dev/null +++ b/data2009/middle.camera @@ -0,0 +1,10 @@ +zoom= 178.650024 +rotx= 5.000000 +roty= 38.500000 +tx= 0.600000 +ty= -6.250000 +lastx= 0.000000 +lasty= 0.000000 +zoomStep= 0.050000 +panStep= 0.050000 +ROTATION= 0.000000 diff --git a/data2009/middle.conf b/data2009/middle.conf new file mode 100644 index 000000000..6ad1e4f2a --- /dev/null +++ b/data2009/middle.conf @@ -0,0 +1,5 @@ +camera middle.camera +model boy3.mb +model generi_rig.mb +model character_jump_70.mb + diff --git a/data2009/multi-materials.conf b/data2009/multi-materials.conf new file mode 100644 index 000000000..8043a1f81 --- /dev/null +++ b/data2009/multi-materials.conf @@ -0,0 +1,2 @@ +camera simple-all.camera +model multi-materials.mb diff --git a/data2009/multi-materials.mb b/data2009/multi-materials.mb new file mode 100644 index 000000000..9feb4d4d1 Binary files /dev/null and b/data2009/multi-materials.mb differ diff --git a/data2009/simple-all.camera b/data2009/simple-all.camera new file mode 100644 index 000000000..3be038830 --- /dev/null +++ b/data2009/simple-all.camera @@ -0,0 +1,11 @@ +zoom= 315.750214 +rotx= 19.500000 +roty= -30.000000 +tx= -0.199997 +ty= -2.899998 +lastx= 0.000000 +lasty= 0.000000 +zoomStep= 0.050000 +panStep= 0.050000 +ROTATION= 0.000000 + \ No newline at end of file diff --git a/data2009/simple-all.conf b/data2009/simple-all.conf new file mode 100644 index 000000000..3a8ebf15a --- /dev/null +++ b/data2009/simple-all.conf @@ -0,0 +1,4 @@ +camera simple-all.camera +model simple-blendshapes.mb +model simplest.mb +model multi-materials.mb diff --git a/data2009/simple-anims.camera b/data2009/simple-anims.camera new file mode 100644 index 000000000..43dbeb968 --- /dev/null +++ b/data2009/simple-anims.camera @@ -0,0 +1,10 @@ +zoom= 192.249969 +rotx= 21.500000 +roty= -51.000000 +tx= 0.050000 +ty= -0.800000 +lastx= 0.000000 +lasty= 0.000000 +zoomStep= 0.050000 +panStep= 0.050000 +ROTATION= 0.000000 \ No newline at end of file diff --git a/data2009/simple-anims.conf b/data2009/simple-anims.conf new file mode 100644 index 000000000..90c6cf4bb --- /dev/null +++ b/data2009/simple-anims.conf @@ -0,0 +1,4 @@ +camera simple-anims.camera +model simple-anims/simple-model.mb +anim simple-anims/simple-anim1.mb +anim simple-anims/simple-anim2.mb diff --git a/data2009/simple-anims/simple-anim1.anim b/data2009/simple-anims/simple-anim1.anim new file mode 100644 index 000000000..62566a2f2 --- /dev/null +++ b/data2009/simple-anims/simple-anim1.anim @@ -0,0 +1,70 @@ +ANIMATION simple-anim1.mb + StartTime 0.0166667 + EndTime 0.5 + NumFrames 30 + NumBlendShapes 0 + JOINTANIM + NumJointAnims 1 + joint2 2077434157 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.08393 +0.00117 +0.01389 +0.99637 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.17598 +0.00245 +0.01372 +0.98429 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.27271 +0.00380 +0.01341 +0.96199 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.37049 +0.00516 +0.01294 +0.92873 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.46574 +0.00649 +0.01233 +0.88481 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.55520 +0.00774 +0.01159 +0.83160 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.63616 +0.00887 +0.01075 +0.77143 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.70668 +0.00985 +0.00986 +0.70739 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.76564 +0.01067 +0.00896 +0.64312 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.81273 +0.01133 +0.00812 +0.58248 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.84828 +0.01182 +0.00738 +0.52937 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.87302 +0.01217 +0.00679 +0.48748 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.88769 +0.01237 +0.00641 +0.46022 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.89264 +0.01244 +0.00628 +0.45056 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.88833 +0.01238 +0.00640 +0.45900 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.87555 +0.01220 +0.00673 +0.48293 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.85407 +0.01190 +0.00725 +0.51998 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.82331 +0.01147 +0.00791 +0.56742 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.78265 +0.01091 +0.00867 +0.62231 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.73169 +0.01020 +0.00950 +0.68150 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.67046 +0.00934 +0.01034 +0.74181 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.59958 +0.00836 +0.01115 +0.80019 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.52030 +0.00725 +0.01190 +0.85387 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.43449 +0.00606 +0.01255 +0.90057 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.34452 +0.00480 +0.01308 +0.93867 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.25317 +0.00353 +0.01348 +0.96732 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.16336 +0.00228 +0.01375 +0.98647 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.07805 +0.00109 +0.01389 +0.99685 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + diff --git a/data2009/simple-anims/simple-anim1.mb b/data2009/simple-anims/simple-anim1.mb new file mode 100644 index 000000000..01f79e5d2 Binary files /dev/null and b/data2009/simple-anims/simple-anim1.mb differ diff --git a/data2009/simple-anims/simple-anim2.anim b/data2009/simple-anims/simple-anim2.anim new file mode 100644 index 000000000..137247a0b --- /dev/null +++ b/data2009/simple-anims/simple-anim2.anim @@ -0,0 +1,70 @@ +ANIMATION simple-anim2.mb + StartTime 0.0166667 + EndTime 0.5 + NumFrames 30 + NumBlendShapes 0 + JOINTANIM + NumJointAnims 1 + joint2 2077434157 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.62641 -0.73069 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.63762 -1.53830 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.64962 -2.40184 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.66210 -3.30035 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.67477 -4.21284 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.68735 -5.11833 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.69953 -5.99586 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.71104 -6.82445 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.72158 -7.58311 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.73085 -8.25087 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.73857 -8.80675 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.74445 -9.22978 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.74819 -9.49898 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.74950 -9.59338 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.74835 -9.51095 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.74508 -9.27502 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.73991 -8.90266 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.73308 -8.41091 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.72483 -7.81683 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.71539 -7.13748 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.70501 -6.38990 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.69391 -5.59116 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.68235 -4.75832 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.67054 -3.90841 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.65874 -3.05851 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.64717 -2.22566 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.63608 -1.42693 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.62569 -0.67935 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + diff --git a/data2009/simple-anims/simple-anim2.mb b/data2009/simple-anims/simple-anim2.mb new file mode 100644 index 000000000..79b3cd11f Binary files /dev/null and b/data2009/simple-anims/simple-anim2.mb differ diff --git a/data2009/simple-anims/simple-model.mb b/data2009/simple-anims/simple-model.mb new file mode 100644 index 000000000..e1c0b6cb9 Binary files /dev/null and b/data2009/simple-anims/simple-model.mb differ diff --git a/data2009/simple-anims/simple-model.model b/data2009/simple-anims/simple-model.model new file mode 100644 index 000000000..0ab080263 --- /dev/null +++ b/data2009/simple-anims/simple-model.model @@ -0,0 +1,304 @@ +TEXTURES +NumTextures= 0 +METERIALS +NumMaterials= 1 + MaterialType= 0 + LAMBERT lambert1 + materialID= 1 + ambient 0.00000 0.00000 0.00000 tex= 0 + diffuse 0.50000 0.50000 0.50000 tex= 0 + incandescence 0.00000 0.00000 0.00000 tex= 0 + transparency 0.00000 0.00000 0.00000 tex= 0 + normalmap tex= 0 +MESHES +NumMeshes= 3 + MESH pCubeShape1 + meshID= 1 + ParentHash= 0 + NumBlendshapeWeights 0 + IsSkinned 1 + SKIN skinCluster1 + NumInfluences 3 + 3805966487 2077434157 215224763 + Stride 16 + // Vertices format: Position.xyz | Normal.xyz | UV | JointIndices.0123 | JointWeights.0123 + NumVerts 48 + -1.77500 -6.64200 +1.33200 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 +0.00000 +0.00000 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 +0.00000 + +1.77500 -6.64200 +1.33200 +0.00000 +0.00000 +1.00000 +1.00000 +0.00000 +0.00000 +0.00000 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 +0.00000 + +1.77500 -3.32100 +1.33200 +0.00000 +0.00000 +1.00000 +1.00000 +0.25000 +0.00000 +1.00000 +0.00000 +0.00000 +0.99747 +0.00253 +0.00000 +0.00000 + -1.77500 -3.32100 +1.33200 +0.00000 +0.00000 +1.00000 +0.00000 +0.25000 +0.00000 +1.00000 +0.00000 +0.00000 +0.99745 +0.00255 +0.00000 +0.00000 + +1.77500 -0.00000 +1.33200 +0.00000 +0.00000 +1.00000 +1.00000 +0.50000 +0.00000 +1.00000 +0.00000 +0.00000 +0.50013 +0.49987 +0.00000 +0.00000 + -1.77500 -0.00000 +1.33200 +0.00000 +0.00000 +1.00000 +0.00000 +0.50000 +0.00000 +1.00000 +0.00000 +0.00000 +0.50124 +0.49876 +0.00000 +0.00000 + +1.77500 +3.32100 +1.33200 +0.00000 +0.00000 +1.00000 +1.00000 +0.75000 +1.00000 +0.00000 +2.00000 +0.00000 +0.99432 +0.00305 +0.00264 +0.00000 + -1.77500 +3.32100 +1.33200 +0.00000 +0.00000 +1.00000 +0.00000 +0.75000 +1.00000 +2.00000 +0.00000 +0.00000 +0.99364 +0.00328 +0.00308 +0.00000 + +1.77500 +6.64200 +1.33200 +0.00000 +0.00000 +1.00000 +1.00000 +1.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.50000 +0.50000 +0.00000 +0.00000 + -1.77500 +6.64200 +1.33200 +0.00000 +0.00000 +1.00000 +0.00000 +1.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.50000 +0.50000 +0.00000 +0.00000 + -1.77500 +6.64200 +1.33200 +0.00000 +1.00000 +0.00000 +0.00000 +1.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.50000 +0.50000 +0.00000 +0.00000 + +1.77500 +6.64200 +1.33200 +0.00000 +1.00000 +0.00000 +1.00000 +1.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.50000 +0.50000 +0.00000 +0.00000 + +1.77500 +6.64200 -1.33200 +0.00000 +1.00000 +0.00000 +1.00000 +2.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.50000 +0.50000 +0.00000 +0.00000 + -1.77500 +6.64200 -1.33200 +0.00000 +1.00000 +0.00000 +0.00000 +2.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.50000 +0.50000 +0.00000 +0.00000 + -1.77500 +6.64200 -1.33200 +0.00000 +0.00000 -1.00000 +0.00000 +2.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.50000 +0.50000 +0.00000 +0.00000 + +1.77500 +6.64200 -1.33200 +0.00000 +0.00000 -1.00000 +1.00000 +2.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.50000 +0.50000 +0.00000 +0.00000 + +1.77500 +3.32100 -1.33200 +0.00000 +0.00000 -1.00000 +1.00000 +2.25000 +1.00000 +0.00000 +2.00000 +0.00000 +0.99432 +0.00305 +0.00264 +0.00000 + -1.77500 +3.32100 -1.33200 +0.00000 +0.00000 -1.00000 +0.00000 +2.25000 +1.00000 +2.00000 +0.00000 +0.00000 +0.99364 +0.00328 +0.00308 +0.00000 + +1.77500 -0.00000 -1.33200 +0.00000 +0.00000 -1.00000 +1.00000 +2.50000 +0.00000 +1.00000 +0.00000 +0.00000 +0.50013 +0.49987 +0.00000 +0.00000 + -1.77500 -0.00000 -1.33200 +0.00000 +0.00000 -1.00000 +0.00000 +2.50000 +0.00000 +1.00000 +0.00000 +0.00000 +0.50124 +0.49876 +0.00000 +0.00000 + +1.77500 -3.32100 -1.33200 +0.00000 +0.00000 -1.00000 +1.00000 +2.75000 +0.00000 +1.00000 +0.00000 +0.00000 +0.99747 +0.00253 +0.00000 +0.00000 + -1.77500 -3.32100 -1.33200 +0.00000 +0.00000 -1.00000 +0.00000 +2.75000 +0.00000 +1.00000 +0.00000 +0.00000 +0.99745 +0.00255 +0.00000 +0.00000 + +1.77500 -6.64200 -1.33200 +0.00000 +0.00000 -1.00000 +1.00000 +3.00000 +0.00000 +0.00000 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 +0.00000 + -1.77500 -6.64200 -1.33200 +0.00000 +0.00000 -1.00000 +0.00000 +3.00000 +0.00000 +0.00000 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 +0.00000 + -1.77500 -6.64200 -1.33200 +0.00000 -1.00000 +0.00000 +0.00000 +3.00000 +0.00000 +0.00000 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 +0.00000 + +1.77500 -6.64200 -1.33200 +0.00000 -1.00000 +0.00000 +1.00000 +3.00000 +0.00000 +0.00000 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 +0.00000 + +1.77500 -6.64200 +1.33200 +0.00000 -1.00000 +0.00000 +1.00000 +4.00000 +0.00000 +0.00000 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 +0.00000 + -1.77500 -6.64200 +1.33200 +0.00000 -1.00000 +0.00000 +0.00000 +4.00000 +0.00000 +0.00000 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 +0.00000 + +1.77500 -6.64200 +1.33200 +1.00000 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 +0.00000 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 +0.00000 + +1.77500 -6.64200 -1.33200 +1.00000 +0.00000 +0.00000 +2.00000 +0.00000 +0.00000 +0.00000 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 +0.00000 + +1.77500 -3.32100 -1.33200 +1.00000 +0.00000 +0.00000 +2.00000 +0.25000 +0.00000 +1.00000 +0.00000 +0.00000 +0.99747 +0.00253 +0.00000 +0.00000 + +1.77500 -3.32100 +1.33200 +1.00000 +0.00000 +0.00000 +1.00000 +0.25000 +0.00000 +1.00000 +0.00000 +0.00000 +0.99747 +0.00253 +0.00000 +0.00000 + +1.77500 -0.00000 -1.33200 +1.00000 +0.00000 +0.00000 +2.00000 +0.50000 +0.00000 +1.00000 +0.00000 +0.00000 +0.50013 +0.49987 +0.00000 +0.00000 + +1.77500 -0.00000 +1.33200 +1.00000 +0.00000 +0.00000 +1.00000 +0.50000 +0.00000 +1.00000 +0.00000 +0.00000 +0.50013 +0.49987 +0.00000 +0.00000 + +1.77500 +3.32100 -1.33200 +1.00000 +0.00000 +0.00000 +2.00000 +0.75000 +1.00000 +0.00000 +2.00000 +0.00000 +0.99432 +0.00305 +0.00264 +0.00000 + +1.77500 +3.32100 +1.33200 +1.00000 +0.00000 +0.00000 +1.00000 +0.75000 +1.00000 +0.00000 +2.00000 +0.00000 +0.99432 +0.00305 +0.00264 +0.00000 + +1.77500 +6.64200 -1.33200 +1.00000 +0.00000 +0.00000 +2.00000 +1.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.50000 +0.50000 +0.00000 +0.00000 + +1.77500 +6.64200 +1.33200 +1.00000 +0.00000 +0.00000 +1.00000 +1.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.50000 +0.50000 +0.00000 +0.00000 + -1.77500 -6.64200 -1.33200 -1.00000 +0.00000 +0.00000 -1.00000 +0.00000 +0.00000 +0.00000 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 +0.00000 + -1.77500 -6.64200 +1.33200 -1.00000 +0.00000 +0.00000 +0.00000 +0.00000 +0.00000 +0.00000 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 +0.00000 + -1.77500 -3.32100 +1.33200 -1.00000 +0.00000 +0.00000 +0.00000 +0.25000 +0.00000 +1.00000 +0.00000 +0.00000 +0.99745 +0.00255 +0.00000 +0.00000 + -1.77500 -3.32100 -1.33200 -1.00000 +0.00000 +0.00000 -1.00000 +0.25000 +0.00000 +1.00000 +0.00000 +0.00000 +0.99745 +0.00255 +0.00000 +0.00000 + -1.77500 -0.00000 +1.33200 -1.00000 +0.00000 +0.00000 +0.00000 +0.50000 +0.00000 +1.00000 +0.00000 +0.00000 +0.50124 +0.49876 +0.00000 +0.00000 + -1.77500 -0.00000 -1.33200 -1.00000 +0.00000 +0.00000 -1.00000 +0.50000 +0.00000 +1.00000 +0.00000 +0.00000 +0.50124 +0.49876 +0.00000 +0.00000 + -1.77500 +3.32100 +1.33200 -1.00000 +0.00000 +0.00000 +0.00000 +0.75000 +1.00000 +2.00000 +0.00000 +0.00000 +0.99364 +0.00328 +0.00308 +0.00000 + -1.77500 +3.32100 -1.33200 -1.00000 +0.00000 +0.00000 -1.00000 +0.75000 +1.00000 +2.00000 +0.00000 +0.00000 +0.99364 +0.00328 +0.00308 +0.00000 + -1.77500 +6.64200 +1.33200 -1.00000 +0.00000 +0.00000 +0.00000 +1.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.50000 +0.50000 +0.00000 +0.00000 + -1.77500 +6.64200 -1.33200 -1.00000 +0.00000 +0.00000 -1.00000 +1.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.50000 +0.50000 +0.00000 +0.00000 + // + // Material Groups: + MaterialCount= 1 + MaterialID= 1 + // Triangles: + TriCount 36 + 0 1 2 + 0 2 3 + 3 2 4 + 3 4 5 + 5 4 6 + 5 6 7 + 7 6 8 + 7 8 9 + 10 11 12 + 10 12 13 + 14 15 16 + 14 16 17 + 17 16 18 + 17 18 19 + 19 18 20 + 19 20 21 + 21 20 22 + 21 22 23 + 24 25 26 + 24 26 27 + 28 29 30 + 28 30 31 + 31 30 32 + 31 32 33 + 33 32 34 + 33 34 35 + 35 34 36 + 35 36 37 + 38 39 40 + 38 40 41 + 41 40 42 + 41 42 43 + 43 42 44 + 43 44 45 + 45 44 46 + 45 46 47 + MESH pCubeShape3 + meshID= 2 + ParentHash= 3936665616 + NumBlendshapeWeights 0 + IsSkinned 0 + Stride 8 + // Vertices format: Position.xyz | Normal.xyz | UV + NumVerts 24 + -3.03392 +9.21412 +3.03392 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 + +3.03392 +9.21412 +3.03392 +0.00000 +0.00000 +1.00000 +1.00000 +0.00000 + +3.03392 +15.28197 +3.03392 +0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + -3.03392 +15.28197 +3.03392 +0.00000 +0.00000 +1.00000 +0.00000 +1.00000 + -3.03392 +15.28197 +3.03392 +0.00000 +1.00000 +0.00000 +0.00000 +1.00000 + +3.03392 +15.28197 +3.03392 +0.00000 +1.00000 +0.00000 +1.00000 +1.00000 + +3.03392 +15.28197 -3.03392 +0.00000 +1.00000 +0.00000 +1.00000 +2.00000 + -3.03392 +15.28197 -3.03392 +0.00000 +1.00000 +0.00000 +0.00000 +2.00000 + -3.03392 +15.28197 -3.03392 +0.00000 +0.00000 -1.00000 +0.00000 +2.00000 + +3.03392 +15.28197 -3.03392 +0.00000 +0.00000 -1.00000 +1.00000 +2.00000 + +3.03392 +9.21412 -3.03392 +0.00000 +0.00000 -1.00000 +1.00000 +3.00000 + -3.03392 +9.21412 -3.03392 +0.00000 +0.00000 -1.00000 +0.00000 +3.00000 + -3.03392 +9.21412 -3.03392 +0.00000 -1.00000 +0.00000 +0.00000 +3.00000 + +3.03392 +9.21412 -3.03392 +0.00000 -1.00000 +0.00000 +1.00000 +3.00000 + +3.03392 +9.21412 +3.03392 +0.00000 -1.00000 +0.00000 +1.00000 +4.00000 + -3.03392 +9.21412 +3.03392 +0.00000 -1.00000 +0.00000 +0.00000 +4.00000 + +3.03392 +9.21412 +3.03392 +1.00000 +0.00000 +0.00000 +1.00000 +0.00000 + +3.03392 +9.21412 -3.03392 +1.00000 +0.00000 +0.00000 +2.00000 +0.00000 + +3.03392 +15.28197 -3.03392 +1.00000 +0.00000 +0.00000 +2.00000 +1.00000 + +3.03392 +15.28197 +3.03392 +1.00000 +0.00000 +0.00000 +1.00000 +1.00000 + -3.03392 +9.21412 -3.03392 -1.00000 +0.00000 +0.00000 -1.00000 +0.00000 + -3.03392 +9.21412 +3.03392 -1.00000 +0.00000 +0.00000 +0.00000 +0.00000 + -3.03392 +15.28197 +3.03392 -1.00000 +0.00000 +0.00000 +0.00000 +1.00000 + -3.03392 +15.28197 -3.03392 -1.00000 +0.00000 +0.00000 -1.00000 +1.00000 + // + // Material Groups: + MaterialCount= 1 + MaterialID= 1 + // Triangles: + TriCount 12 + 0 1 2 + 0 2 3 + 4 5 6 + 4 6 7 + 8 9 10 + 8 10 11 + 12 13 14 + 12 14 15 + 16 17 18 + 16 18 19 + 20 21 22 + 20 22 23 + MESH pCubeShape2 + meshID= 3 + ParentHash= 0 + NumBlendshapeWeights 0 + IsSkinned 0 + Stride 8 + // Vertices format: Position.xyz | Normal.xyz | UV + NumVerts 24 + -0.50000 -0.50000 +0.50000 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 + +0.50000 -0.50000 +0.50000 +0.00000 +0.00000 +1.00000 +1.00000 +0.00000 + +0.50000 +0.50000 +0.50000 +0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + -0.50000 +0.50000 +0.50000 +0.00000 +0.00000 +1.00000 +0.00000 +1.00000 + -0.50000 +0.50000 +0.50000 +0.00000 +1.00000 +0.00000 +0.00000 +1.00000 + +0.50000 +0.50000 +0.50000 +0.00000 +1.00000 +0.00000 +1.00000 +1.00000 + +0.50000 +0.50000 -0.50000 +0.00000 +1.00000 +0.00000 +1.00000 +2.00000 + -0.50000 +0.50000 -0.50000 +0.00000 +1.00000 +0.00000 +0.00000 +2.00000 + -0.50000 +0.50000 -0.50000 +0.00000 +0.00000 -1.00000 +0.00000 +2.00000 + +0.50000 +0.50000 -0.50000 +0.00000 +0.00000 -1.00000 +1.00000 +2.00000 + +0.50000 -0.50000 -0.50000 +0.00000 +0.00000 -1.00000 +1.00000 +3.00000 + -0.50000 -0.50000 -0.50000 +0.00000 +0.00000 -1.00000 +0.00000 +3.00000 + -0.50000 -0.50000 -0.50000 +0.00000 -1.00000 +0.00000 +0.00000 +3.00000 + +0.50000 -0.50000 -0.50000 +0.00000 -1.00000 +0.00000 +1.00000 +3.00000 + +0.50000 -0.50000 +0.50000 +0.00000 -1.00000 +0.00000 +1.00000 +4.00000 + -0.50000 -0.50000 +0.50000 +0.00000 -1.00000 +0.00000 +0.00000 +4.00000 + +0.50000 -0.50000 +0.50000 +1.00000 +0.00000 +0.00000 +1.00000 +0.00000 + +0.50000 -0.50000 -0.50000 +1.00000 +0.00000 +0.00000 +2.00000 +0.00000 + +0.50000 +0.50000 -0.50000 +1.00000 +0.00000 +0.00000 +2.00000 +1.00000 + +0.50000 +0.50000 +0.50000 +1.00000 +0.00000 +0.00000 +1.00000 +1.00000 + -0.50000 -0.50000 -0.50000 -1.00000 +0.00000 +0.00000 -1.00000 +0.00000 + -0.50000 -0.50000 +0.50000 -1.00000 +0.00000 +0.00000 +0.00000 +0.00000 + -0.50000 +0.50000 +0.50000 -1.00000 +0.00000 +0.00000 +0.00000 +1.00000 + -0.50000 +0.50000 -0.50000 -1.00000 +0.00000 +0.00000 -1.00000 +1.00000 + // + // Material Groups: + MaterialCount= 1 + MaterialID= 1 + // Triangles: + TriCount 12 + 0 1 2 + 0 2 3 + 4 5 6 + 4 6 7 + 8 9 10 + 8 10 11 + 12 13 14 + 12 14 15 + 16 17 18 + 16 18 19 + 20 21 22 + 20 22 23 +SKELETON +numJoints 4 + JOINT joint1 + nameHash 3805966487 + parentIndex -1 + Transformation 1 +0.00000 +0.00000 +0.70218 +0.71200 -0.02297 -6.56968 +0.00000 +1.00000 +1.00000 +1.00000 + JOINT joint2 + nameHash 2077434157 + parentIndex 0 + Transformation 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + JOINT joint3 + nameHash 215224763 + parentIndex 1 + Transformation 1 +0.70215 +0.71203 +0.00000 +0.00000 +6.57032 +0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + JOINT pCube3 + nameHash 3936665616 + parentIndex 2 + Transformation 1 -0.01398 +0.99990 +0.00000 +0.00000 +0.16205 -6.61368 -0.00000 +1.00000 +1.00000 +1.00000 + +ANIMATION simple-model.mb + StartTime 0.0166667 + EndTime 0.5 + NumFrames 30 + NumBlendShapes 0 + JOINTANIM + NumJointAnims 1 + joint2 2077434157 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.12194 +0.99254 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.28170 +0.95950 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.44371 +0.89617 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.58792 +0.80892 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.70009 +0.71406 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.77363 +0.63363 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.80715 +0.59035 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.79772 +0.60303 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.72988 +0.68357 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.58993 +0.80745 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.37624 +0.92652 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.10599 +0.99437 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.18288 +0.98313 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.44469 +0.89569 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.64482 +0.76434 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.77076 +0.63713 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.82760 +0.56132 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.84122 +0.54069 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.83486 +0.55046 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.81053 +0.58570 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.76834 +0.64005 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.70798 +0.70623 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.62992 +0.77666 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.53615 +0.84412 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.43054 +0.90257 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.31865 +0.94787 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.20721 +0.97830 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.10335 +0.99464 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + diff --git a/data2009/simple-blendshapes.mb b/data2009/simple-blendshapes.mb new file mode 100644 index 000000000..93ca83750 Binary files /dev/null and b/data2009/simple-blendshapes.mb differ diff --git a/data2009/simplest-tex.bmp b/data2009/simplest-tex.bmp new file mode 100644 index 000000000..f326a4165 Binary files /dev/null and b/data2009/simplest-tex.bmp differ diff --git a/data2009/simplest-tex.dds b/data2009/simplest-tex.dds new file mode 100644 index 000000000..30919e680 Binary files /dev/null and b/data2009/simplest-tex.dds differ diff --git a/data2009/simplest-tex.mb b/data2009/simplest-tex.mb new file mode 100644 index 000000000..2d2265a8c Binary files /dev/null and b/data2009/simplest-tex.mb differ diff --git a/data2009/simplest.conf b/data2009/simplest.conf new file mode 100644 index 000000000..0ff47f428 --- /dev/null +++ b/data2009/simplest.conf @@ -0,0 +1,2 @@ +camera simple-all.camera +model simplest.mb diff --git a/data2009/simplest.mb b/data2009/simplest.mb new file mode 100644 index 000000000..f06a7de98 Binary files /dev/null and b/data2009/simplest.mb differ diff --git a/data2009/simplest.model b/data2009/simplest.model new file mode 100644 index 000000000..27de7535f --- /dev/null +++ b/data2009/simplest.model @@ -0,0 +1,308 @@ +TEXTURES +NumTextures= 0 +METERIALS +NumMaterials= 1 + MaterialType= 0 + LAMBERT lambert1 + materialID= 1 + ambient 0.00000 0.00000 0.00000 tex= 0 + diffuse 0.50000 0.50000 0.50000 tex= 0 + incandescence 0.00000 0.00000 0.00000 tex= 0 + transparency 0.00000 0.00000 0.00000 tex= 0 + normalmap tex= 0 +MESHES +NumMeshes= 3 + MESH pCubeShape1 + meshID= 1 + ParentHash= 0 + NumBlendshapeWeights 0 + IsSkinned 1 + SKIN skinCluster1 + NumInfluences 3 + 3805966487 2077434157 215224763 + Stride 16 + // Vertices format: Position.xyz | Normal.xyz | UV | JointIndices.0123 | JointWeights.0123 + NumVerts 48 + -1.77500 -9.21352 +1.33200 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 +0.00000 +1.00000 +2.00000 +0.00000 +0.98127 +0.01663 +0.00211 +0.00000 + +1.77500 -9.21352 +1.33200 +0.00000 +0.00000 +1.00000 +1.00000 +0.00000 +0.00000 +1.00000 +2.00000 +0.00000 +0.98058 +0.01726 +0.00216 +0.00000 + +1.77500 -4.60676 +1.33200 +0.00000 +0.00000 +1.00000 +1.00000 +0.25000 +0.00000 +1.00000 +2.00000 +0.00000 +0.96510 +0.03354 +0.00136 +0.00000 + -1.77500 -4.60676 +1.33200 +0.00000 +0.00000 +1.00000 +0.00000 +0.25000 +0.00000 +1.00000 +2.00000 +0.00000 +0.96587 +0.03276 +0.00138 +0.00000 + +1.77500 -0.00000 +1.33200 +0.00000 +0.00000 +1.00000 +1.00000 +0.50000 +0.00000 +1.00000 +2.00000 +0.00000 +0.49775 +0.49765 +0.00460 +0.00000 + -1.77500 -0.00000 +1.33200 +0.00000 +0.00000 +1.00000 +0.00000 +0.50000 +0.00000 +1.00000 +2.00000 +0.00000 +0.49768 +0.49669 +0.00563 +0.00000 + +1.77500 +4.60676 +1.33200 +0.00000 +0.00000 +1.00000 +1.00000 +0.75000 +1.00000 +2.00000 +0.00000 +0.00000 +0.75107 +0.22109 +0.02783 +0.00000 + -1.77500 +4.60676 +1.33200 +0.00000 +0.00000 +1.00000 +0.00000 +0.75000 +1.00000 +2.00000 +0.00000 +0.00000 +0.74292 +0.23018 +0.02690 +0.00000 + +1.77500 +9.21352 +1.33200 +0.00000 +0.00000 +1.00000 +1.00000 +1.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.49565 +0.49565 +0.00870 +0.00000 + -1.77500 +9.21352 +1.33200 +0.00000 +0.00000 +1.00000 +0.00000 +1.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.49581 +0.49581 +0.00837 +0.00000 + -1.77500 +9.21352 +1.33200 +0.00000 +1.00000 +0.00000 +0.00000 +1.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.49581 +0.49581 +0.00837 +0.00000 + +1.77500 +9.21352 +1.33200 +0.00000 +1.00000 +0.00000 +1.00000 +1.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.49565 +0.49565 +0.00870 +0.00000 + +1.77500 +9.21352 -1.33200 +0.00000 +1.00000 +0.00000 +1.00000 +2.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.49565 +0.49565 +0.00870 +0.00000 + -1.77500 +9.21352 -1.33200 +0.00000 +1.00000 +0.00000 +0.00000 +2.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.49581 +0.49581 +0.00837 +0.00000 + -1.77500 +9.21352 -1.33200 +0.00000 +0.00000 -1.00000 +0.00000 +2.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.49581 +0.49581 +0.00837 +0.00000 + +1.77500 +9.21352 -1.33200 +0.00000 +0.00000 -1.00000 +1.00000 +2.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.49565 +0.49565 +0.00870 +0.00000 + +1.77500 +4.60676 -1.33200 +0.00000 +0.00000 -1.00000 +1.00000 +2.25000 +1.00000 +2.00000 +0.00000 +0.00000 +0.75107 +0.22109 +0.02783 +0.00000 + -1.77500 +4.60676 -1.33200 +0.00000 +0.00000 -1.00000 +0.00000 +2.25000 +1.00000 +2.00000 +0.00000 +0.00000 +0.74292 +0.23018 +0.02690 +0.00000 + +1.77500 -0.00000 -1.33200 +0.00000 +0.00000 -1.00000 +1.00000 +2.50000 +0.00000 +1.00000 +2.00000 +0.00000 +0.49775 +0.49765 +0.00460 +0.00000 + -1.77500 -0.00000 -1.33200 +0.00000 +0.00000 -1.00000 +0.00000 +2.50000 +0.00000 +1.00000 +2.00000 +0.00000 +0.49768 +0.49669 +0.00563 +0.00000 + +1.77500 -4.60676 -1.33200 +0.00000 +0.00000 -1.00000 +1.00000 +2.75000 +0.00000 +1.00000 +2.00000 +0.00000 +0.96510 +0.03354 +0.00136 +0.00000 + -1.77500 -4.60676 -1.33200 +0.00000 +0.00000 -1.00000 +0.00000 +2.75000 +0.00000 +1.00000 +2.00000 +0.00000 +0.96587 +0.03276 +0.00138 +0.00000 + +1.77500 -9.21352 -1.33200 +0.00000 +0.00000 -1.00000 +1.00000 +3.00000 +0.00000 +1.00000 +2.00000 +0.00000 +0.98058 +0.01726 +0.00216 +0.00000 + -1.77500 -9.21352 -1.33200 +0.00000 +0.00000 -1.00000 +0.00000 +3.00000 +0.00000 +1.00000 +2.00000 +0.00000 +0.98127 +0.01663 +0.00211 +0.00000 + -1.77500 -9.21352 -1.33200 +0.00000 -1.00000 +0.00000 +0.00000 +3.00000 +0.00000 +1.00000 +2.00000 +0.00000 +0.98127 +0.01663 +0.00211 +0.00000 + +1.77500 -9.21352 -1.33200 +0.00000 -1.00000 +0.00000 +1.00000 +3.00000 +0.00000 +1.00000 +2.00000 +0.00000 +0.98058 +0.01726 +0.00216 +0.00000 + +1.77500 -9.21352 +1.33200 +0.00000 -1.00000 +0.00000 +1.00000 +4.00000 +0.00000 +1.00000 +2.00000 +0.00000 +0.98058 +0.01726 +0.00216 +0.00000 + -1.77500 -9.21352 +1.33200 +0.00000 -1.00000 +0.00000 +0.00000 +4.00000 +0.00000 +1.00000 +2.00000 +0.00000 +0.98127 +0.01663 +0.00211 +0.00000 + +1.77500 -9.21352 +1.33200 +1.00000 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 +1.00000 +2.00000 +0.00000 +0.98058 +0.01726 +0.00216 +0.00000 + +1.77500 -9.21352 -1.33200 +1.00000 +0.00000 +0.00000 +2.00000 +0.00000 +0.00000 +1.00000 +2.00000 +0.00000 +0.98058 +0.01726 +0.00216 +0.00000 + +1.77500 -4.60676 -1.33200 +1.00000 +0.00000 +0.00000 +2.00000 +0.25000 +0.00000 +1.00000 +2.00000 +0.00000 +0.96510 +0.03354 +0.00136 +0.00000 + +1.77500 -4.60676 +1.33200 +1.00000 +0.00000 +0.00000 +1.00000 +0.25000 +0.00000 +1.00000 +2.00000 +0.00000 +0.96510 +0.03354 +0.00136 +0.00000 + +1.77500 -0.00000 -1.33200 +1.00000 +0.00000 +0.00000 +2.00000 +0.50000 +0.00000 +1.00000 +2.00000 +0.00000 +0.49775 +0.49765 +0.00460 +0.00000 + +1.77500 -0.00000 +1.33200 +1.00000 +0.00000 +0.00000 +1.00000 +0.50000 +0.00000 +1.00000 +2.00000 +0.00000 +0.49775 +0.49765 +0.00460 +0.00000 + +1.77500 +4.60676 -1.33200 +1.00000 +0.00000 +0.00000 +2.00000 +0.75000 +1.00000 +2.00000 +0.00000 +0.00000 +0.75107 +0.22109 +0.02783 +0.00000 + +1.77500 +4.60676 +1.33200 +1.00000 +0.00000 +0.00000 +1.00000 +0.75000 +1.00000 +2.00000 +0.00000 +0.00000 +0.75107 +0.22109 +0.02783 +0.00000 + +1.77500 +9.21352 -1.33200 +1.00000 +0.00000 +0.00000 +2.00000 +1.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.49565 +0.49565 +0.00870 +0.00000 + +1.77500 +9.21352 +1.33200 +1.00000 +0.00000 +0.00000 +1.00000 +1.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.49565 +0.49565 +0.00870 +0.00000 + -1.77500 -9.21352 -1.33200 -1.00000 +0.00000 +0.00000 -1.00000 +0.00000 +0.00000 +1.00000 +2.00000 +0.00000 +0.98127 +0.01663 +0.00211 +0.00000 + -1.77500 -9.21352 +1.33200 -1.00000 +0.00000 +0.00000 +0.00000 +0.00000 +0.00000 +1.00000 +2.00000 +0.00000 +0.98127 +0.01663 +0.00211 +0.00000 + -1.77500 -4.60676 +1.33200 -1.00000 +0.00000 +0.00000 +0.00000 +0.25000 +0.00000 +1.00000 +2.00000 +0.00000 +0.96587 +0.03276 +0.00138 +0.00000 + -1.77500 -4.60676 -1.33200 -1.00000 +0.00000 +0.00000 -1.00000 +0.25000 +0.00000 +1.00000 +2.00000 +0.00000 +0.96587 +0.03276 +0.00138 +0.00000 + -1.77500 -0.00000 +1.33200 -1.00000 +0.00000 +0.00000 +0.00000 +0.50000 +0.00000 +1.00000 +2.00000 +0.00000 +0.49768 +0.49669 +0.00563 +0.00000 + -1.77500 -0.00000 -1.33200 -1.00000 +0.00000 +0.00000 -1.00000 +0.50000 +0.00000 +1.00000 +2.00000 +0.00000 +0.49768 +0.49669 +0.00563 +0.00000 + -1.77500 +4.60676 +1.33200 -1.00000 +0.00000 +0.00000 +0.00000 +0.75000 +1.00000 +2.00000 +0.00000 +0.00000 +0.74292 +0.23018 +0.02690 +0.00000 + -1.77500 +4.60676 -1.33200 -1.00000 +0.00000 +0.00000 -1.00000 +0.75000 +1.00000 +2.00000 +0.00000 +0.00000 +0.74292 +0.23018 +0.02690 +0.00000 + -1.77500 +9.21352 +1.33200 -1.00000 +0.00000 +0.00000 +0.00000 +1.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.49581 +0.49581 +0.00837 +0.00000 + -1.77500 +9.21352 -1.33200 -1.00000 +0.00000 +0.00000 -1.00000 +1.00000 +1.00000 +2.00000 +0.00000 +0.00000 +0.49581 +0.49581 +0.00837 +0.00000 + // + // Material Groups: + MaterialCount= 1 + MaterialID= 1 + // Triangles: + TriCount 36 + 0 1 2 + 0 2 3 + 3 2 4 + 3 4 5 + 5 4 6 + 5 6 7 + 7 6 8 + 7 8 9 + 10 11 12 + 10 12 13 + 14 15 16 + 14 16 17 + 17 16 18 + 17 18 19 + 19 18 20 + 19 20 21 + 21 20 22 + 21 22 23 + 24 25 26 + 24 26 27 + 28 29 30 + 28 30 31 + 31 30 32 + 31 32 33 + 33 32 34 + 33 34 35 + 35 34 36 + 35 36 37 + 38 39 40 + 38 40 41 + 41 40 42 + 41 42 43 + 43 42 44 + 43 44 45 + 45 44 46 + 45 46 47 + MESH pCubeShape3 + meshID= 2 + ParentHash= 3936665616 + NumBlendshapeWeights 0 + IsSkinned 0 + Stride 8 + // Vertices format: Position.xyz | Normal.xyz | UV + NumVerts 24 + -3.03392 +9.21412 +3.03392 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 + +3.03392 +9.21412 +3.03392 +0.00000 +0.00000 +1.00000 +1.00000 +0.00000 + +3.03392 +15.28197 +3.03392 +0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + -3.03392 +15.28197 +3.03392 +0.00000 +0.00000 +1.00000 +0.00000 +1.00000 + -3.03392 +15.28197 +3.03392 +0.00000 +1.00000 +0.00000 +0.00000 +1.00000 + +3.03392 +15.28197 +3.03392 +0.00000 +1.00000 +0.00000 +1.00000 +1.00000 + +3.03392 +15.28197 -3.03392 +0.00000 +1.00000 +0.00000 +1.00000 +2.00000 + -3.03392 +15.28197 -3.03392 +0.00000 +1.00000 +0.00000 +0.00000 +2.00000 + -3.03392 +15.28197 -3.03392 +0.00000 +0.00000 -1.00000 +0.00000 +2.00000 + +3.03392 +15.28197 -3.03392 +0.00000 +0.00000 -1.00000 +1.00000 +2.00000 + +3.03392 +9.21412 -3.03392 +0.00000 +0.00000 -1.00000 +1.00000 +3.00000 + -3.03392 +9.21412 -3.03392 +0.00000 +0.00000 -1.00000 +0.00000 +3.00000 + -3.03392 +9.21412 -3.03392 +0.00000 -1.00000 +0.00000 +0.00000 +3.00000 + +3.03392 +9.21412 -3.03392 +0.00000 -1.00000 +0.00000 +1.00000 +3.00000 + +3.03392 +9.21412 +3.03392 +0.00000 -1.00000 +0.00000 +1.00000 +4.00000 + -3.03392 +9.21412 +3.03392 +0.00000 -1.00000 +0.00000 +0.00000 +4.00000 + +3.03392 +9.21412 +3.03392 +1.00000 +0.00000 +0.00000 +1.00000 +0.00000 + +3.03392 +9.21412 -3.03392 +1.00000 +0.00000 +0.00000 +2.00000 +0.00000 + +3.03392 +15.28197 -3.03392 +1.00000 +0.00000 +0.00000 +2.00000 +1.00000 + +3.03392 +15.28197 +3.03392 +1.00000 +0.00000 +0.00000 +1.00000 +1.00000 + -3.03392 +9.21412 -3.03392 -1.00000 +0.00000 +0.00000 -1.00000 +0.00000 + -3.03392 +9.21412 +3.03392 -1.00000 +0.00000 +0.00000 +0.00000 +0.00000 + -3.03392 +15.28197 +3.03392 -1.00000 +0.00000 +0.00000 +0.00000 +1.00000 + -3.03392 +15.28197 -3.03392 -1.00000 +0.00000 +0.00000 -1.00000 +1.00000 + // + // Material Groups: + MaterialCount= 1 + MaterialID= 1 + // Triangles: + TriCount 12 + 0 1 2 + 0 2 3 + 4 5 6 + 4 6 7 + 8 9 10 + 8 10 11 + 12 13 14 + 12 14 15 + 16 17 18 + 16 18 19 + 20 21 22 + 20 22 23 + MESH pCubeShape2 + meshID= 3 + ParentHash= 2644766854 + NumBlendshapeWeights 0 + IsSkinned 0 + Stride 8 + // Vertices format: Position.xyz | Normal.xyz | UV + NumVerts 24 + -0.50000 -0.50000 +0.50000 +0.00000 +0.00000 +1.00000 +0.00000 +0.00000 + +0.50000 -0.50000 +0.50000 +0.00000 +0.00000 +1.00000 +1.00000 +0.00000 + +0.50000 +0.50000 +0.50000 +0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + -0.50000 +0.50000 +0.50000 +0.00000 +0.00000 +1.00000 +0.00000 +1.00000 + -0.50000 +0.50000 +0.50000 +0.00000 +1.00000 +0.00000 +0.00000 +1.00000 + +0.50000 +0.50000 +0.50000 +0.00000 +1.00000 +0.00000 +1.00000 +1.00000 + +0.50000 +0.50000 -0.50000 +0.00000 +1.00000 +0.00000 +1.00000 +2.00000 + -0.50000 +0.50000 -0.50000 +0.00000 +1.00000 +0.00000 +0.00000 +2.00000 + -0.50000 +0.50000 -0.50000 +0.00000 +0.00000 -1.00000 +0.00000 +2.00000 + +0.50000 +0.50000 -0.50000 +0.00000 +0.00000 -1.00000 +1.00000 +2.00000 + +0.50000 -0.50000 -0.50000 +0.00000 +0.00000 -1.00000 +1.00000 +3.00000 + -0.50000 -0.50000 -0.50000 +0.00000 +0.00000 -1.00000 +0.00000 +3.00000 + -0.50000 -0.50000 -0.50000 +0.00000 -1.00000 +0.00000 +0.00000 +3.00000 + +0.50000 -0.50000 -0.50000 +0.00000 -1.00000 +0.00000 +1.00000 +3.00000 + +0.50000 -0.50000 +0.50000 +0.00000 -1.00000 +0.00000 +1.00000 +4.00000 + -0.50000 -0.50000 +0.50000 +0.00000 -1.00000 +0.00000 +0.00000 +4.00000 + +0.50000 -0.50000 +0.50000 +1.00000 +0.00000 +0.00000 +1.00000 +0.00000 + +0.50000 -0.50000 -0.50000 +1.00000 +0.00000 +0.00000 +2.00000 +0.00000 + +0.50000 +0.50000 -0.50000 +1.00000 +0.00000 +0.00000 +2.00000 +1.00000 + +0.50000 +0.50000 +0.50000 +1.00000 +0.00000 +0.00000 +1.00000 +1.00000 + -0.50000 -0.50000 -0.50000 -1.00000 +0.00000 +0.00000 -1.00000 +0.00000 + -0.50000 -0.50000 +0.50000 -1.00000 +0.00000 +0.00000 +0.00000 +0.00000 + -0.50000 +0.50000 +0.50000 -1.00000 +0.00000 +0.00000 +0.00000 +1.00000 + -0.50000 +0.50000 -0.50000 -1.00000 +0.00000 +0.00000 -1.00000 +1.00000 + // + // Material Groups: + MaterialCount= 1 + MaterialID= 1 + // Triangles: + TriCount 12 + 0 1 2 + 0 2 3 + 4 5 6 + 4 6 7 + 8 9 10 + 8 10 11 + 12 13 14 + 12 14 15 + 16 17 18 + 16 18 19 + 20 21 22 + 20 22 23 +SKELETON +numJoints 5 + JOINT joint1 + nameHash 3805966487 + parentIndex -1 + Transformation 1 +0.00000 +0.00000 +0.70218 +0.71200 -0.02297 -6.56968 +0.00000 +1.00000 +1.00000 +1.00000 + JOINT joint2 + nameHash 2077434157 + parentIndex 0 + Transformation 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + JOINT joint3 + nameHash 215224763 + parentIndex 1 + Transformation 1 +0.70215 +0.71203 +0.00000 +0.00000 +6.57032 +0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + JOINT pCube3 + nameHash 3936665616 + parentIndex 2 + Transformation 1 -0.01398 +0.99990 +0.00000 +0.00000 +0.16205 -6.61368 -0.00000 +1.00000 +1.00000 +1.00000 + JOINT pCube2 + nameHash 2644766854 + parentIndex 0 + Transformation 1 +0.00000 +0.00000 -0.70218 +0.71200 -3.13390 -0.06650 +0.00000 +14.05556 +1.00000 +11.08333 + +ANIMATION simplest.mb + StartTime 0.0166667 + EndTime 0.5 + NumFrames 30 + NumBlendShapes 0 + JOINTANIM + NumJointAnims 1 + joint2 2077434157 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.12194 +0.99254 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.28170 +0.95950 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.44371 +0.89617 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.58792 +0.80892 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.70009 +0.71406 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.77363 +0.63363 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.80715 +0.59035 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.79772 +0.60303 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.72988 +0.68357 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.58993 +0.80745 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.37624 +0.92652 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 -0.10599 +0.99437 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.18288 +0.98313 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.44469 +0.89569 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.64482 +0.76434 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.77076 +0.63713 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.82760 +0.56132 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.84122 +0.54069 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.83486 +0.55046 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.81053 +0.58570 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.76834 +0.64005 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.70798 +0.70623 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.62992 +0.77666 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.53615 +0.84412 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.43054 +0.90257 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.31865 +0.94787 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.20721 +0.97830 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.10335 +0.99464 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + 1 +0.00000 +0.00000 +0.01394 +0.99990 +6.61626 -0.00000 +0.00000 +1.00000 +1.00000 +1.00000 + + diff --git a/data2009/simplest.scene b/data2009/simplest.scene new file mode 100644 index 000000000..89b02f9eb --- /dev/null +++ b/data2009/simplest.scene @@ -0,0 +1,2 @@ +camera simple-all.camera +model simplest.model diff --git a/data2009/sphere.camera b/data2009/sphere.camera new file mode 100644 index 000000000..43dbeb968 --- /dev/null +++ b/data2009/sphere.camera @@ -0,0 +1,10 @@ +zoom= 192.249969 +rotx= 21.500000 +roty= -51.000000 +tx= 0.050000 +ty= -0.800000 +lastx= 0.000000 +lasty= 0.000000 +zoomStep= 0.050000 +panStep= 0.050000 +ROTATION= 0.000000 \ No newline at end of file diff --git a/data2009/sphere.conf b/data2009/sphere.conf new file mode 100644 index 000000000..866936a42 --- /dev/null +++ b/data2009/sphere.conf @@ -0,0 +1,2 @@ +camera sphere.camera +model sphere.mb diff --git a/data2009/sphere.mb b/data2009/sphere.mb new file mode 100644 index 000000000..8bfc7a9be Binary files /dev/null and b/data2009/sphere.mb differ diff --git a/data2009/test.bat b/data2009/test.bat new file mode 100644 index 000000000..e9a6dbdd9 --- /dev/null +++ b/data2009/test.bat @@ -0,0 +1,10 @@ +Exporter simple-all.conf +Exporter simple-anims.conf +Exporter middle.conf +Exporter anim.conf + +Loader simple-all.scene +Loader simple-anims.scene +Loader middle.scene +Loader anim.scene + diff --git a/gamekit/0_FPS_Template.blend b/gamekit/0_FPS_Template.blend deleted file mode 100644 index 7c1cd56f7..000000000 Binary files a/gamekit/0_FPS_Template.blend and /dev/null differ diff --git a/gamekit/1_water_mill.blend b/gamekit/1_water_mill.blend deleted file mode 100644 index 4da959b79..000000000 Binary files a/gamekit/1_water_mill.blend and /dev/null differ diff --git a/gamekit/BigEndian.blend b/gamekit/BigEndian.blend deleted file mode 100644 index 286d4d5a6..000000000 Binary files a/gamekit/BigEndian.blend and /dev/null differ diff --git a/gamekit/BulletBlendReader.cpp b/gamekit/BulletBlendReader.cpp deleted file mode 100644 index 58f6557c7..000000000 --- a/gamekit/BulletBlendReader.cpp +++ /dev/null @@ -1,3441 +0,0 @@ -/* -GameKit -Copyright (c) 2009 Erwin Coumans http://gamekit.googlecode.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - - -//#define DUMP_BLOCK_NAMES 1 - - -#include "BulletBlendReader.h" -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -#include "abs-file.h" - -#include "readblend.h" -#include "blendtype.h" -#include "btBulletDynamicsCommon.h" -#include "BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h" -#include "BulletCollision/Gimpact/btGImpactShape.h" -#include <stdio.h> - - -int gTotalExpands=0; -char gTmpFieldBuffer[4*1024*1024]; - - -static char* gBuffer = 0; -static int gCurrentFilePtr = 0; -static int gFileSize = 0; - - -long MY_FILELENGTH(FILE *fp) { - long currentpos = ftell(fp); /* save current cursor position */ - long newpos; - fseek(fp, 0, SEEK_END); /* seek to end */ - newpos = ftell(fp); /* find position of end -- this is the length */ - fseek(fp, currentpos, SEEK_SET); /* restore previous cursor position */ - return newpos; -} - - -MY_FILETYPE* MY_FILE_OPEN_FOR_READ(FILE* fp) -{ - long currentpos = ftell(fp); /* save current cursor position */ - long newpos; - int bytesRead; - - fseek(fp, 0, SEEK_END); /* seek to end */ - newpos = ftell(fp); /* find position of end -- this is the length */ - fseek(fp, currentpos, SEEK_SET); /* restore previous cursor position */ - - gFileSize = newpos; - - gBuffer = (char*)malloc(gFileSize); - bytesRead = fread(gBuffer,gFileSize,1,fp); - return gBuffer; -} - -char* btReadBuffer(FILE* fp, int* fileSize) -{ - char* membuf = MY_FILE_OPEN_FOR_READ(fp); - *fileSize = gFileSize; - return membuf; -} - - -MY_FILETYPE* MY_OPEN_FOR_READ(const char *const filename) -{ - FILE* gFile = fopen(filename,"rb"); - if (gFile) - { - MY_FILE_OPEN_FOR_READ (gFile); - gCurrentFilePtr = 0; - fclose(gFile); - gFile = 0; - return gBuffer; - } - return 0; -} - -int MY_GETC(MY_FILETYPE *const fp) -{ - return gBuffer[gCurrentFilePtr++]; -} - -void MY_SEEK(MY_FILETYPE* fp,int pos) -{ - gCurrentFilePtr = pos; -} - -#define MY_REWIND(fp) MY_SEEK(fp,0) -int MY_READ(unsigned char* dest,int size,int num,MY_FILETYPE* fp) -{ - int n; - memcpy(dest,&gBuffer[gCurrentFilePtr],size*num); - gCurrentFilePtr += size*num; - return num; -} - -unsigned char* MY_FAKE_READ(int size,int num,MY_FILETYPE* fp) -{ - unsigned char* ptr = (unsigned char*) &gBuffer[gCurrentFilePtr]; - gCurrentFilePtr += size*num; - return ptr; -} - - -void MY_CLOSE(MY_FILETYPE* fp) -{ - free(gBuffer); - gBuffer = 0; - gCurrentFilePtr = 0; - gFileSize = 0; - -} - -int MY_TELL(MY_FILETYPE* fp) -{ - return gCurrentFilePtr; -} - -int MY_ATEOF(MY_FILETYPE* fp) -{ - return gCurrentFilePtr<gFileSize? 0 : 1; -} - - -int readData(char* file, BlendFile* bf); - -BulletBlendReader::BulletBlendReader(btDynamicsWorld* destinationWorld) -:m_bf(0), -m_destinationWorld(destinationWorld) -{ - -} - - - - - -int BulletBlendReader::readFile(FILE* posixFile, int verboseDumpAllTypes) -{ - MY_FILETYPE* buffer; - - buffer = MY_FILE_OPEN_FOR_READ(posixFile); - - m_bf = blend_read(buffer); - - if (!m_bf) - { - fprintf(stderr, "couldn't read blender file. :(\n"); - MY_CLOSE(buffer); - return 0; - } - - readData(buffer,m_bf); - - if (verboseDumpAllTypes) - { - blend_dump_typedefs(m_bf); - } - - MY_CLOSE(buffer); - - return 1; -} - - - -BulletBlendReader::~BulletBlendReader() -{ - ///@todo: delete/close file/data structures - -} - -static int -name_is_pointer(char* name) { - int len = strlen(name); - /*fprintf(stderr,"[%s]",name);*/ - if (len >= 1) { - if (name[0] == '*') - return 1; - } - if (len >= 2) { - if (name[1] == '*') - return 1; - } - return 0; -} - -static int -name_is_array(char* name, int* dim1, int* dim2) { - int len = strlen(name); - /*fprintf(stderr,"[%s]",name);*/ - /*if (len >= 1) { - if (name[len-1] != ']') - return 1; - } - return 0;*/ - char *bp; - int num; - if (dim1) { - *dim1 = 1; - } - if (dim2) { - *dim2 = 1; - } - bp = strchr(name, '['); - if (!bp) { - return 0; - } - num = 0; - while (++bp < name+len-1) { - const char c = *bp; - if (c == ']') { - break; - } - if (c <= '9' && c >= '0') { - num *= 10; - num += (c - '0'); - } else { - printf("array parse error.\n"); - return 0; - } - } - if (dim2) { - *dim2 = num; - } - - /* find second dim, if any. */ - bp = strchr(bp, '['); - if (!bp) { - return 1; /* at least we got the first dim. */ - } - num = 0; - while (++bp < name+len-1) { - const char c = *bp; - if (c == ']') { - break; - } - if (c <= '9' && c >= '0') { - num *= 10; - num += (c - '0'); - } else { - printf("array2 parse error.\n"); - return 1; - } - } - if (dim1) { - if (dim2) { - *dim1 = *dim2; - *dim2 = num; - } else { - *dim1 = num; - } - } - - return 1; -} - - - - -/* recursively count the number of fields and array items in this -structure, for the purposes of skipping in the field offset array */ -static long -get_num_type_segments(BlendFile* blend_file, - BlendObject obj) -{ - int i; - long rtn = 0; - int dim1,dim2; - - name_is_array(blend_file->names[obj.name], - &dim1, &dim2); - - if (name_is_pointer(blend_file->names[obj.name]) || - !blend_file->types[obj.type].is_struct) { - return (1 * dim1 * dim2); - } - - /* fprintf(stderr, "STRUCTYAYYY ");*/ - - for (i=0; i<blend_file->types[obj.type].fieldnames_count; ++i) { - BlendObject qo = obj; - qo.type = blend_file->types[obj.type].fieldtypes[i]; - qo.name = blend_file->types[obj.type].fieldnames[i]; - qo.field_index = i; - rtn += get_num_type_segments(blend_file, qo) * dim1 * dim2; - } - - return (rtn); -} - - -static int -blend_type_basename_compare(const char *fancy, const char *raw) { - const int flen = strlen(fancy); - const int rlen = strlen(raw); - int i, strcmp_result = 123; - - i = 0; - while (i < flen && (fancy[i]=='*' || fancy[i]=='(')) { - ++i; - } - - strcmp_result = strncmp(&fancy[i], raw, rlen); - - if (strcmp_result == 0 && flen > rlen+i) { - i = rlen + i; - if (fancy[i] != ')' && fancy[i] != '(' && fancy[i] != '[') { - strcmp_result = -1; - } - } - - return strcmp_result; -} - - -static BlendObjType -typestring_to_blendobj_type(BlendFile* blend_file, - const char* type_name) -{ - if (blend_type_basename_compare(type_name, "char") == 0) { - return BLEND_OBJ_CHAR8; - } else if (blend_type_basename_compare(type_name, "uchar") == 0) { - return BLEND_OBJ_UCHAR8; - } else if (blend_type_basename_compare(type_name, "short") == 0) { - return BLEND_OBJ_SHORT16; - } else if (blend_type_basename_compare(type_name, "ushort") == 0) { - return BLEND_OBJ_USHORT16; - } else if (blend_type_basename_compare(type_name, "int") == 0) { - return BLEND_OBJ_LONG32; - } else if (blend_type_basename_compare(type_name, "long") == 0) { - return BLEND_OBJ_LONG32; - } else if (blend_type_basename_compare(type_name, "ulong") == 0) { - return BLEND_OBJ_ULONG32; - } else if (blend_type_basename_compare(type_name, "float") == 0) { - return BLEND_OBJ_FLOAT; - } else if (blend_type_basename_compare(type_name, "double") == 0) { - return BLEND_OBJ_DOUBLE; - } else if (blend_type_basename_compare(type_name, "void") == 0) { - return BLEND_OBJ_OPAQUE; - } else { - return BLEND_OBJ_STRUCT; /* structure */ - } -} - - -static BlendBlock * -blendBlockFromBlendpointer(BlendFile *blend_file, - uint32_t blendpointer) -{ - int i; - - /* fprintf(stderr, "%04x: ", blendpointer);*/ - - if (blendpointer != 0) { - for (i=0; i<blend_file->m_blocks.size(); ++i) { - /*fprintf(stderr, "%04x? ", blend_file->blocks[i].blender_pointer); */ - if (blend_file->m_blocks[i]->blender_pointer1 == blendpointer) { - return blend_file->m_blocks[i]; - } - } - } - - return NULL; -} - -#define NUM_KEYWORDS 11 -char* keywords[NUM_KEYWORDS] = {"FileGlobal", "Scene", "Object", "bSensor", "bKeyboardSensor", "bAlwaysSensor", "bController","bActuator","bIpoActuator","bRigidBodyJointConstraint", "bConstraint"}; - -bool BulletBlendReader::needsExtraction(const char* type_name) -{ - bool found = false; - - for (int i=0;i<NUM_KEYWORDS;i++) - { - char* keyword = keywords[i]; - - if (strcmp(type_name,keyword)==0) - return true; - } - return false; -} - - -int -blend_object_getstring(BlendFile* blend_file, - BlendObject obj, - char *dest, int max_chars) -{ - int strpos = 0; - int dim1, dim2; - int rtn = 1; - BlendObjType bo_type; - - name_is_array(blend_file->names[obj.name], - &dim1, &dim2); - - if (dim2 < max_chars) { - max_chars = dim2; - } - - bo_type = blend_object_type(blend_file, obj); - if (! (bo_type==BLEND_OBJ_CHAR8 || bo_type==BLEND_OBJ_UCHAR8)) { - printf("tried to get string from an object that's not of type uchar/char. (is type %d)\n", bo_type); - rtn = 0; - goto done; - } - - for (strpos=0; strpos<max_chars-1; ++strpos) { - char c; - if (!blend_object_array_getdata(blend_file, &c, obj, 0, strpos)) { - printf("unexpected error accessing array. :(\n"); - rtn = 0; - goto done; - } - if (c == '\0') { - goto done; - } - dest[strpos] = c; - } - -done: - dest[strpos] = '\0'; - return rtn; -} - - -int -blend_object_get_IDname(BlendFile* blend_file, - BlendObject obj, - char *dest, int max_chars) -{ - if (BLEND_OBJ_STRUCT == blend_object_type(blend_file, obj)) { - BlendObject idstruc_obj; - /* See if this structure has an 'id' field */ - if (blend_object_structure_getfield(blend_file, &idstruc_obj, - obj, "id")) { - /* we have an 'id' field -- look for a 'name' field within it */ - BlendObject name_obj; - /* An ID field should have a 'name' field, but we'll make sure... */ - if (BLEND_OBJ_STRUCT == blend_object_type(blend_file, idstruc_obj) && - blend_object_structure_getfield(blend_file, &name_obj, - idstruc_obj, "name")) { - /* great, get the string from the 'name' field. */ - if (blend_object_getstring(blend_file, name_obj, - dest, max_chars)) { - return 1; - } else { - printf("oh no, couldn't extract string.\n"); - } - } else { - /* next entry please. */ - } - } else { - /* this block's type structure doesn't have an ID field at all */ - } - } else { - /* this block's type isn't a structure */ - printf("non-objectstruct type of type %d\n", blend_object_type(blend_file, obj)); - } - - return 0; /* failure */ -} - - -btDataObject* BulletBlendReader::extractSingleObject(BlendObject* objPtr, bool verboseDumpAllBlocks) -{ - btAssert(objPtr); - - BlendObject& obj = *objPtr; - btDataObject* dob = new btDataObject(); - int sz = sizeof(btDataValue); - BlendBlock* block = (BlendBlock*)obj.block; - BlendObjType objType; - - int fieldType,fieldName; - - if (m_bf->types[obj.type].is_struct) - { - int i; - int field_index = 0; - for (i=0; i<m_bf->types[obj.type].fieldnames_count; ++i) { - //printf("filename = %s\n",m_bf->names[m_bf->types[obj.type].fieldnames[i]]); - fieldType = m_bf->types[obj.type].fieldtypes[i]; - fieldName = m_bf->types[obj.type].fieldnames[i]; - if (verboseDumpAllBlocks) - printf("\n %s %s = ",m_bf->types[fieldType].name, m_bf->names[fieldName]); - - - int dim1=1; - int dim2=1; - name_is_array(m_bf->names[fieldName], &dim1, &dim2); - - int k,l; - void** ptrptr; - - btDataValue* val = new btDataValue(); - val->m_name = fieldName; - val->m_type = fieldType; - - dob->m_dataMap.insert(m_bf->names[fieldName],val); - - - ///for arrays, use an aligned object array. This is very bloated. - - btDataValue* arrayVal = 0; - - - - ///this access is a bloated, will probably make special cases for common arrays - if (dim1>1 || dim2>1) - { - arrayVal = val; - arrayVal->m_valueArray.resize(dim1); - for (int i=0;i<dim1;i++) - { - arrayVal->m_valueArray[i].m_name = fieldName; - arrayVal->m_valueArray[i].m_type = fieldType; - arrayVal->m_valueArray[i].m_valueArray.resize(dim2); - - for (int j=0;j<dim2;j++) - { - arrayVal->m_valueArray[i].m_valueArray[j].m_name = fieldName; - arrayVal->m_valueArray[i].m_valueArray[j].m_type = fieldType; - } - } - } - - - for (k=0;k<dim1;k++) - { - for (l=0;l<dim2;l++) - { - if (arrayVal) - val = &arrayVal->m_valueArray[k].m_valueArray[l]; - - ptrptr = (void**)&block->m_array_entries_[0]->field_bytes[block->m_array_entries_[0]->m_field_offsets[field_index+dim2*k+ l]]; - - objType = typestring_to_blendobj_type(m_bf, m_bf->types[fieldType].name) ; - if (ptrptr) - { - switch (objType) - { - case BLEND_OBJ_NULL: - { - break; - } - - case BLEND_OBJ_UCHAR8: - { - val->m_iValue = *(unsigned char*)ptrptr; - if (verboseDumpAllBlocks) - printf("%d ",val->m_iValue); - break; - } - case BLEND_OBJ_CHAR8: - { - val->m_iValue = *(char*)ptrptr; - if (verboseDumpAllBlocks) - printf("%d ",val->m_iValue); - break; - } - case BLEND_OBJ_USHORT16: - { - val->m_iValue = *(unsigned short int*)ptrptr; - if (verboseDumpAllBlocks) - printf("%d ",val->m_iValue); - break; - } - case BLEND_OBJ_SHORT16: - { - val->m_iValue = *(short int*)ptrptr; - if (verboseDumpAllBlocks) - printf("%d ",val->m_iValue); - break; - } - case BLEND_OBJ_ULONG32: - { - val->m_uiValue = *(unsigned int*)ptrptr; - if (verboseDumpAllBlocks) - printf("%d ",val->m_uiValue); - break; - } - case BLEND_OBJ_LONG32: - { - val->m_iValue = *(int*)ptrptr; - if (verboseDumpAllBlocks) - printf("%d ",val->m_iValue); - break; - } - case BLEND_OBJ_FLOAT: - { - val->m_fValue = *(float *)ptrptr; - if (verboseDumpAllBlocks) - printf("%f ",val->m_fValue); - break; - } - case BLEND_OBJ_DOUBLE: - { - double val = *(double *)ptrptr; - if (verboseDumpAllBlocks) - printf("%f ",val); - break; - } - case BLEND_OBJ_POINTER: - { - void* val = *ptrptr; - if (verboseDumpAllBlocks) - printf("0x%x ",val); - break; - } - case BLEND_OBJ_OPAQUE: - case BLEND_OBJ_STRUCT: - { - char dest[1024]; - int isListBase = 0; - int max_chars = 1023; - - - if (!strcmp(m_bf->types[m_bf->types[obj.type].fieldtypes[i]].name,"ListBase")) - { - isListBase =1; - } - if (name_is_pointer(m_bf->names[m_bf->types[obj.type].fieldnames[i]]) || isListBase) - { - - uint32_t ptr = *(uint32_t*)ptrptr; - if (ptr) - { - BlendObject idstruc_obj; - BlendBlock* block; - BlendObject name_obj; - - - - BlendBlock * curveblockptr = blendBlockFromBlendpointer(m_bf, ptr); - if (curveblockptr) - { - idstruc_obj = blend_block_get_object(m_bf, curveblockptr, 0); - block = (BlendBlock*)idstruc_obj.block; - val->m_uiValue = block->blender_pointer1; - - if (BLEND_OBJ_STRUCT == blend_object_type(m_bf, idstruc_obj) && - blend_object_structure_getfield(m_bf, &name_obj, - idstruc_obj, "name")) { - /* great, get the string from the 'name' field. */ - if (blend_object_getstring(m_bf, name_obj, - dest, max_chars)) { - if (verboseDumpAllBlocks) - printf("\"%s\" ",dest); - - } else { - if (verboseDumpAllBlocks) - printf("0x%x ",block->blender_pointer1); - } - } else { - if (verboseDumpAllBlocks) - printf("0x%x ",block->blender_pointer1); - } - } else - { - if (verboseDumpAllBlocks) - printf("NULL "); - } - - } else - { - if (verboseDumpAllBlocks) - printf("NULL "); - } - } else - { - if (!strcmp(m_bf->names[m_bf->types[obj.type].fieldnames[i]],"id")) - { - if (blend_object_get_IDname(m_bf, obj, dest, max_chars)) - { - if (verboseDumpAllBlocks) - printf("\"%s\" ",dest); - break; - } - } - if (verboseDumpAllBlocks) - printf("Embedded struct"); - - } - break; - } - default: - { - if (verboseDumpAllBlocks) - printf("unknown value"); - } - } - } - } - } - - - - { - int fos; - BlendObject qo = obj; - qo.type = m_bf->types[obj.type].fieldtypes[i]; - qo.name = m_bf->types[obj.type].fieldnames[i]; - qo.field_index = field_index; - fos = get_num_type_segments(m_bf, qo); - field_index += fos; - } - } - } - - dob->m_blenderPointer = block->blender_pointer1; - m_dataObjects.insert(block->blender_pointer1,dob); - - return dob; -} - - - - -#define CONSTRAINT_TYPE_RIGIDBODYJOINT 17 -#define CONSTRAINT_RB_BALL 1 -#define CONSTRAINT_RB_HINGE 2 -#define CONSTRAINT_RB_CONETWIST 4 -#define CONSTRAINT_RB_VEHICLE 11 -#define CONSTRAINT_RB_GENERIC6DOF 12 - -///flags -#define CONSTRAINT_DISABLE_LINKED_COLLISION 0x80 - - - -void BulletBlendReader::convertConstraints() -{ - - int i; - for (i=0;i<m_visibleGameObjects.size();i++) - { - btDataObject* ob = m_visibleGameObjects[i]; - unsigned int cPtr = ob->getIntValue("constraints"); - if (cPtr) - { - btDataObject** constraintPtr = m_dataObjects[cPtr]; - if (constraintPtr && *constraintPtr) - { - btDataObject* constraint = *constraintPtr; - int constraintType = constraint->getIntValue("type",0); - if (constraintType==CONSTRAINT_TYPE_RIGIDBODYJOINT) - { - unsigned int dataPtr = constraint->getIntValue("*data",0); - if (dataPtr) - { - - btDataObject** rbConstraintPtr = m_dataObjects[dataPtr]; - if (rbConstraintPtr && *rbConstraintPtr) - { - btDataObject* rbConstraint = *rbConstraintPtr; - - unsigned int rbConstraintType = rbConstraint->getIntValue("type",0); - -///some debugging, spit out all the fields -#if 0 - for (int k=0;k<rbConstraint->m_dataMap.size();k++) - { - const btHashString& structName = rbConstraint->m_dataMap.getKey(k); - const btDataValue* valPtr = *rbConstraint->m_dataMap.find(structName); - } -#endif - - btVector3 pivotInA(rbConstraint->getFloatValue("pivX"),rbConstraint->getFloatValue("pivY"),rbConstraint->getFloatValue("pivZ")); - btVector3 pivotInB(0,0,0); - btCollisionObject* colObj = (btCollisionObject*) ob->m_userPointer; - btRigidBody* rbA = btRigidBody::upcast(colObj); - btRigidBody* rbB = 0; - - int flag = rbConstraint->getIntValue("flag"); - bool disableCollisionBetweenLinkedBodies = (flag & CONSTRAINT_DISABLE_LINKED_COLLISION) != 0; - - if (rbA) - { - unsigned int objectBPtr = rbConstraint->getIntValue("*tar"); - if (objectBPtr) - { - btDataObject** dataBPtr = m_dataObjects[objectBPtr]; - if (dataBPtr && *dataBPtr) - { - btDataObject* dataB = *dataBPtr; - btCollisionObject* colObjB = (btCollisionObject*)dataB->m_userPointer; - rbB = btRigidBody::upcast(colObjB); - pivotInB = rbB->getCenterOfMassTransform().inverse()(rbA->getCenterOfMassTransform()(pivotInA)); - } - } - - float radsPerDeg = 6.283185307179586232f / 360.f; - - //localConstraintFrameBasis - btMatrix3x3 localCFrame; - localCFrame.setEulerZYX(radsPerDeg*rbConstraint->getFloatValue("axX"),radsPerDeg*rbConstraint->getFloatValue("axY"),radsPerDeg*rbConstraint->getFloatValue("axZ")); - btVector3 axisInA = localCFrame.getColumn(0); - btVector3 axis1 = localCFrame.getColumn(1); - btVector3 axis2 = localCFrame.getColumn(2); - bool angularOnly = false; - - - /* important: these defines need to match up with PHY_DynamicTypes headerfile */ - switch (rbConstraintType) - { - - case CONSTRAINT_RB_BALL: - { - btPoint2PointConstraint* p2p = 0; - - if (rbB) - { - p2p = new btPoint2PointConstraint(*rbA,*rbB,pivotInA,pivotInB); - } else - { - p2p = new btPoint2PointConstraint(*rbA,pivotInA); - } - - m_destinationWorld->addConstraint(p2p); - - break; - } - case CONSTRAINT_RB_HINGE: - { - btHingeConstraint* hinge = 0; - if (rbB) - { - btVector3 axisInB = rbB ? - (rbB->getCenterOfMassTransform().getBasis().inverse()*(rbA->getCenterOfMassTransform().getBasis() * axisInA)) : - rbA->getCenterOfMassTransform().getBasis() * axisInA; - - hinge = new btHingeConstraint(*rbA,*rbB,pivotInA,pivotInB,axisInA,axisInB); - - - } else - { - hinge = new btHingeConstraint(*rbA, pivotInA,axisInA); - - } - hinge->setAngularOnly(angularOnly); - - //m_constraints.push_back(hinge); - m_destinationWorld->addConstraint(hinge,disableCollisionBetweenLinkedBodies); - //hinge->setUserConstraintId(gConstraintUid++); - //hinge->setUserConstraintType(type); - break; - } - case CONSTRAINT_RB_CONETWIST: - { - break; - } - case CONSTRAINT_RB_VEHICLE: - { - break; - } - case CONSTRAINT_RB_GENERIC6DOF: - { - - btTransform frameInA; - btTransform frameInB; - if (axis1.length() == 0.0) - { - btPlaneSpace1( axisInA, axis1, axis2 ); - } - frameInA.getBasis().setValue( axisInA.x(), axis1.x(), axis2.x(), - axisInA.y(), axis1.y(), axis2.y(), - axisInA.z(), axis1.z(), axis2.z() ); - frameInA.setOrigin( pivotInA ); - btTransform inv = rbB->getCenterOfMassTransform().inverse(); - btTransform globalFrameA = rbA->getCenterOfMassTransform() * frameInA; - frameInB = inv * globalFrameA; - bool useReferenceFrameA = true; - btGeneric6DofSpringConstraint* genericConstraint = new btGeneric6DofSpringConstraint(*rbA,*rbB, frameInA,frameInB,useReferenceFrameA); - m_destinationWorld->addConstraint(genericConstraint,disableCollisionBetweenLinkedBodies); - - //if it is a generic 6DOF constraint, set all the limits accordingly - int dof; - int dofbit=1; - for (dof=0;dof<6;dof++) - { - if (flag & dofbit) - { - ///this access is a bloated, will probably make special cases for common arrays - btScalar minLimit = (*rbConstraint->m_dataMap.find("minLimit[6]"))->m_valueArray[0].m_valueArray[dof].m_fValue; - btScalar maxLimit = (*rbConstraint->m_dataMap.find("maxLimit[6]"))->m_valueArray[0].m_valueArray[dof].m_fValue; - genericConstraint->setLimit(dof,minLimit,maxLimit); - } else - { - //minLimit > maxLimit means free(disabled limit) for this degree of freedom - genericConstraint->setLimit(dof,1,-1); - } - dofbit<<=1; - } - break; - } - - default: - { - printf("unsupported rigid body constraint type\n"); - } - } - } //if (rbA) - } - } - - } - } - } - - } -} - -void BulletBlendReader::convertAllObjects(int verboseDumpAllBlocks) -{ - - if (!m_bf) - { - printf("ERROR: no file loaded, use openFile first\n"); - return; - } - - if (verboseDumpAllBlocks) - { - blend_dump_blocks(m_bf); - } - - int sceneVisibleLayer = 1; - btDataObject* fileGlobalObject =0; - - - int j; - for (j=0; j<m_bf->m_blocks.size(); ++j) - { - { - int entry_count = blend_block_get_entry_count(m_bf, m_bf->m_blocks[j]); - if (entry_count!=1) - { - //printf("entry_count=%d\n",entry_count); - } - for (int i=0; i<entry_count; ++i) - { - BlendObject obj = blend_block_get_object(m_bf, m_bf->m_blocks[j], i); - - - - - BlendObject data_obj; - BlendObject data_obj2; - - BlendBlock* tmpBlock=0; - - { - const char* type_name = m_bf->types[obj.type].name; - - if (verboseDumpAllBlocks) - { - printf("\ntype_name=%s. ",type_name); - printf("block blenderptr = 0x%lx",m_bf->m_blocks[j]->blender_pointer1); - } - - btDataObject* dob = 0; - - if (needsExtraction(type_name)) - { - dob = extractSingleObject(&obj,verboseDumpAllBlocks); - } - - if (strcmp(type_name,"FileGlobal")==0) - { - printf("Found FileGlobal\n"); - short minversion = dob->getIntValue("minversion",123); - short manversion = dob->getIntValue("manversion",123); - int curScene = dob->getIntValue("*curscene",0); - printf("minversion = %d\n",minversion); - BlendBlock* block = (BlendBlock*)obj.block; - fileGlobalObject = dob; - //blend_object_dump_field(m_bf, obj); - } - - if (strcmp(type_name,"Scene")==0) - { - printf("Found a scene\n"); - - if (fileGlobalObject && fileGlobalObject->getIntValue("*curscene",0)==dob->m_blenderPointer) - { - sceneVisibleLayer = dob->getIntValue("lay",0); - } - - - } - - - if (strcmp(type_name,"Object")==0) - { - bObj tmpObj; - blend_acquire_obj_from_obj(m_bf,&obj,&tmpObj,0); - int obLayer = dob->getIntValue("lay",0); - - ///only convert objects that are in a visible layer - if (obLayer & sceneVisibleLayer) - { - btCollisionObject* colObj = convertSingleObject(&tmpObj); - if (colObj) - { - dob->m_userPointer = colObj; - } - m_visibleGameObjects.push_back(dob); - } - - } - - if (strcmp(type_name,"Mesh")==0) - { - //printf("object type_name = %s\n",type_name); - bMesh tmpMesh; - blend_acquire_mesh_from_obj(m_bf, &obj, &tmpMesh); - convertSingleMesh(&tmpMesh); - } - } - } - } - } - - createParentChildHierarchy(); - - ///now fix up some constraint and logic bricks - - convertConstraints(); - - convertLogicBricks(); - -} - - - -///for each Blender Object, this method will be called to convert/retrieve data from the bObj -btCollisionObject* BulletBlendReader::convertSingleObject(_bObj* object) -{ - - switch (object->type) - { - case BOBJ_TYPE_MESH: - break; - - case BOBJ_TYPE_CAMERA: - addCamera(object); - return 0; - case BOBJ_TYPE_LAMP: - addLight(object); - return 0; - default: - { - } - - }; - - //let's try to create some static collision shapes from the triangle meshes - if (object->data.mesh) - { - btTriangleMesh* meshInterface = new btTriangleMesh(); - - btVector3 minVert(1e30f,1e3f,1e30f); - btVector3 maxVert(-1e30f,-1e30f,-1e30f); - for (int t=0;t<object->data.mesh->face_count;t++) - { - - float* vt0 = object->data.mesh->vert[object->data.mesh->face[t].v[0]].xyz; - btVector3 vtx0(vt0[0],vt0[1],vt0[2]); - minVert.setMin(vtx0); maxVert.setMax(vtx0); - float* vt1 = object->data.mesh->vert[object->data.mesh->face[t].v[1]].xyz; - btVector3 vtx1(vt1[0],vt1[1],vt1[2]); - minVert.setMin(vtx1); maxVert.setMax(vtx1); - float* vt2 = object->data.mesh->vert[object->data.mesh->face[t].v[2]].xyz; - btVector3 vtx2(vt2[0],vt2[1],vt2[2]); - minVert.setMin(vtx2); maxVert.setMax(vtx2); - meshInterface ->addTriangle(vtx0,vtx1,vtx2); - - if (object->data.mesh->face[t].v[3]) - { - float* vt3 = object->data.mesh->vert[object->data.mesh->face[t].v[3]].xyz; - btVector3 vtx3(vt3[0],vt3[1],vt3[2]); - minVert.setMin(vtx3); maxVert.setMax(vtx3); - meshInterface ->addTriangle(vtx0,vtx3,vtx2);//? - } - } - if (!meshInterface->getNumTriangles()) - return 0; - -/* boundtype */ -#define OB_BOUND_BOX 0 -#define OB_BOUND_SPHERE 1 -#define OB_BOUND_CYLINDER 2 -#define OB_BOUND_CONE 3 -#define OB_BOUND_POLYH 4 -#define OB_BOUND_POLYT 5 -#define OB_BOUND_DYN_MESH 6 - -/* ob->gameflag */ -#define OB_DYNAMIC 1 -//#define OB_CHILD 2 -//#define OB_ACTOR 4 -//#define OB_INERTIA_LOCK_X 8 -//#define OB_INERTIA_LOCK_Y 16 -//#define OB_INERTIA_LOCK_Z 32 -//#define OB_DO_FH 64 -//#define OB_ROT_FH 128 -//#define OB_ANISOTROPIC_FRICTION 256 -//#define OB_GHOST 512 -#define OB_RIGID_BODY 1024 -//#define OB_BOUNDS 2048 - -//#define OB_COLLISION_RESPONSE 4096//?? -//#define OB_COLLISION 65536 -//#define OB_SOFT_BODY 0x20000 - - btVector3 localPos = (minVert+maxVert)*0.5f; - btVector3 localSize= (maxVert-minVert)*0.5f; - - - btTransform worldTrans; - worldTrans.setIdentity(); - worldTrans.setOrigin(btVector3(object->location[0],object->location[1],object->location[2])); - // blenderobject->loc[0]+blenderobject->dloc[0]//?? - - //btVector3 eulerXYZ(object->rotphr[0],object->rotphr[1],object->rotphr[2]); - worldTrans.getBasis().setEulerZYX(object->rotphr[0],object->rotphr[1],object->rotphr[2]); - btVector3 scale(object->scaling[0],object->scaling[1],object->scaling[2]); - - if ( (object->gameflag & OB_RIGID_BODY) || (object->gameflag & OB_DYNAMIC)) - { - //m_destinationWorld->addRigidBody( - btCollisionShape* colShape = 0; - - switch (object->boundtype) - { - case OB_BOUND_SPHERE: - { - btScalar radius = localSize[localSize.maxAxis()]; - colShape = new btSphereShape(radius); - break; - }; - case OB_BOUND_BOX: - { - colShape = new btBoxShape(localSize); - break; - } - case OB_BOUND_CYLINDER: - { - colShape = new btCylinderShapeZ(localSize); - break; - } - case OB_BOUND_CONE: - { - btScalar radius = btMax(localSize[0], localSize[1]); - btScalar height = 2.f*localSize[2]; - colShape = new btConeShapeZ(radius,height); - break; - } - case OB_BOUND_POLYT: - - { - //better to approximate it, using btShapeHull - colShape = new btConvexTriangleMeshShape(meshInterface); - break; - } - case OB_BOUND_POLYH: - case OB_BOUND_DYN_MESH: - { - btGImpactMeshShape* gimpact = new btGImpactMeshShape(meshInterface); - gimpact->postUpdate(); - colShape = gimpact; - break; - } - - default: - { - - } - }; - - if (colShape) - { - colShape->setLocalScaling(scale); - btVector3 inertia; - colShape->calculateLocalInertia(object->mass,inertia); - btRigidBody* body = new btRigidBody(object->mass,0,colShape,inertia); - if (!(object->gameflag & OB_RIGID_BODY)) - { - body->setAngularFactor(0.f); - } - body->setWorldTransform(worldTrans); - m_destinationWorld->addRigidBody(body); - //body->setActivationState(DISABLE_DEACTIVATION); - - void* gfxObject = createGraphicsObject(object,body); - body->setUserPointer(gfxObject); - - return body; - } - - } else - { - - btCollisionShape* colShape =0; - if (meshInterface->getNumTriangles()>0) - { - btBvhTriangleMeshShape* childShape = new btBvhTriangleMeshShape(meshInterface,true); - - if (scale[0]!=1. || scale[1]!=1. || scale[2]!=1.) - { - colShape = new btScaledBvhTriangleMeshShape(childShape,scale); - } else - { - colShape = childShape; - } - - btVector3 inertia(0,0,0); - btRigidBody* colObj = new btRigidBody(0.f,0,colShape,inertia); - colObj->setWorldTransform(worldTrans); - colObj->setCollisionShape(colShape); - - m_destinationWorld->addRigidBody(colObj); - - void* gfxObject = createGraphicsObject(object,colObj); - colObj->setUserPointer(gfxObject); - - return colObj; - - } - - } - } - return 0; -} - -void BulletBlendReader::convertSingleMesh(_bMesh* mesh) -{ - -} - - - - - - - - -extern int MY_READ(unsigned char* dest,int size,int num,MY_FILETYPE* fp); - - - -static unsigned long -read_ulong(MY_FILETYPE* file) { - unsigned char c[4]; - if (MY_READ(c, 4, 1, file) == 1) { - return c[0] | (c[1]<<8) | (c[2]<<16) | (c[3]<<24); - } else { - return 0xFFFFFFFF; - } -} -#define EXPANDO1(ARRAY,ADDITION) \ - do { \ - (ARRAY) = (BlendField*)realloc((ARRAY), sizeof((ARRAY)[0]) * (1 + (ARRAY##_count))); \ - (ARRAY)[ARRAY##_count] = (ADDITION); \ - ++(ARRAY##_count); \ - } while(0) - -#define EXPANDO2(ARRAY,ADDITION) \ - do { \ - (ARRAY) = (BlendBlock*)realloc((ARRAY), sizeof((ARRAY)[0]) * (1 + (ARRAY##_count))); \ - (ARRAY)[ARRAY##_count] = (ADDITION); \ - ++(ARRAY##_count); \ - } while(0) - - -#define EXPANDO3(ARRAY,ADDITION) \ - do { \ - (ARRAY) = (int*)realloc((ARRAY), sizeof((ARRAY)[0]) * (1 + (ARRAY##_count))); \ - (ARRAY)[ARRAY##_count] = (ADDITION); \ - ++(ARRAY##_count); \ - } while(0) - -#define EXPANDO4(ARRAY,ADDITION) \ - do { \ - (ARRAY) = (char*)realloc((ARRAY), sizeof((ARRAY)[0]) * (1 + (ARRAY##_count))); \ - (ARRAY)[ARRAY##_count] = (ADDITION); \ - ++(ARRAY##_count); \ - } while(0) - - -#define EXPANDO6(ARRAY,ADDITION) \ - do { \ - (ARRAY) = (BlendType*)realloc((ARRAY), sizeof((ARRAY)[0]) * (1 + (ARRAY##_count))); \ - (ARRAY)[ARRAY##_count] = (ADDITION); \ - ++(ARRAY##_count); \ - } while(0) - -#define EXPANDO5(ARRAY,ADDITION) \ - do { \ - (ARRAY) = (char**)realloc((ARRAY), sizeof((ARRAY)[0]) * (1 + (ARRAY##_count))); \ - (ARRAY)[ARRAY##_count] = (ADDITION); \ - ++(ARRAY##_count); \ - } while(0) - - -#define EXPANDO_MULTIPLE(ARRAY,ADDITIONPTR,NUMBER) \ - do { \ - (ARRAY) = (char*)realloc((ARRAY), sizeof((ARRAY)[0]) * (NUMBER +(ARRAY##_count))); \ - memcpy(&(ARRAY)[ARRAY##_count], ADDITIONPTR, sizeof((ARRAY)[0]) * NUMBER); \ - (ARRAY##_count) += NUMBER; \ - } while(0) - -#define SIZE_ROUNDUP(SIZE) (((SIZE) + sizeof(int) - 1) & ~(sizeof(int) - 1)) - - -static void -recursively_read_type(MY_FILETYPE* file, BlendFile* bf, - unsigned long section_type, - BlendField* field) -{ - char *new_data = NULL; - int new_data_size = 0; - int dim1, dim2; - - if (bf->types[section_type].is_struct) { - int i; - /*fprintf(stderr, "type%d(%s)is_struct(%d) ", section_type, bf->types[section_type].name, bf->types[section_type].size);*/ - for (i=0; i<bf->types[section_type].fieldtypes_count; ++i) { - /*fprintf(stderr, "@%d ", i);*/ - int j,k; -#if 0 - if (name_is_array(bf->names[bf->types[section_type].fieldnames[i]], - &j,&k) || 1) { - dprintf(stderr, " %s/%s=[%d][%d] ", - bf->types[bf->types[section_type].fieldtypes[i]].name, - bf->names[bf->types[section_type].fieldnames[i]], j, k); - } -#endif - if (name_is_pointer(bf->names[bf->types[section_type].fieldnames[i]])) { - /*fprintf(stderr, "*(4) ");*/ - name_is_array(bf->names[bf->types[section_type].fieldnames[i]], - &dim1,&dim2); - new_data_size = SIZE_ROUNDUP(4); - new_data = (char*)malloc(new_data_size); - /*fprintf(stderr, " ");*/ - for (j=0; j<dim1; ++j) { - for (k=0; k<dim2; ++k) { - /*fprintf(stderr, "*");*/ - new_data[0] = MY_GETC(file); - new_data[1] = MY_GETC(file); - new_data[2] = MY_GETC(file); - new_data[3] = MY_GETC(file); - //EXPANDO(field->field_offsets, field->field_bytes_count); - - //field->field_offsets = (int*)realloc((field->field_offsets), sizeof((field->field_offsets)[0]) * (1 + (field->field_offsets_count))); - //field->field_offsets[field->field_offsets_count] = (field->field_bytes_count); - field->m_field_offsets.push_back(field->field_bytes_count); - ++field->field_offsets_count; - - - // EXPANDO_MULTIPLE(field->field_bytes, new_data, new_data_size); - { - //field->field_bytes = (char*)realloc((field->field_bytes), sizeof((field->field_bytes)[0]) * (new_data_size +(field->field_bytes_count))); - //memcpy(&(field->field_bytes)[field->field_bytes_count], new_data, sizeof((field->field_bytes)[0]) * new_data_size); - - memcpy( &gTmpFieldBuffer[field->field_bytes_count],new_data,new_data_size); - field->field_bytes_count += new_data_size; - gTotalExpands++; - } - - /*fprintf(stderr, "N*(%d) ", new_data_size);*/ - } - } - free(new_data); - } else { - name_is_array(bf->names[bf->types[section_type].fieldnames[i]], - &dim1,&dim2); - /*fprintf(stderr, " ");*/ - for (j=0; j<dim1; ++j) { - for (k=0; k<dim2; ++k) { - /*fprintf(stderr, "R");*/ - recursively_read_type(file, bf, - bf->types[section_type].fieldtypes[i], - field); - } - } - } - } - } else { - /*fprintf(stderr, "type%d(%s)plain(%d) ", section_type, bf->types[section_type].name, bf->types[section_type].size); */ - new_data_size = SIZE_ROUNDUP(bf->types[section_type].m_size); - /*fprintf(stderr, "%d... ", bf->types[section_type].size); - if (bf->types[section_type].size > 4) { - fprintf(stderr, "%d ", field->field_bytes_count); - }*/ - if (new_data_size) { - -#ifdef REAL_READ - new_data = (char*)malloc(new_data_size); - MY_READ((unsigned char*)new_data, 1, bf->types[section_type].size, file); - EXPANDO3(field->field_offsets, field->field_bytes_count); - EXPANDO_MULTIPLE(field->field_bytes, new_data, new_data_size); - /*fprintf(stderr, "ND(%d) ", new_data_size); */ - free(new_data); -#else - new_data = &gTmpFieldBuffer[field->field_bytes_count];//(char*)malloc(new_data_size); - MY_READ((unsigned char*)new_data, 1, bf->types[section_type].m_size, file); - - //new_data = (char*)MY_FAKE_READ(1, bf->types[section_type].size, file); - //EXPANDO3(field->field_offsets, field->field_bytes_count); - field->m_field_offsets.push_back(field->field_bytes_count); - field->field_offsets_count++; - - - - { - //EXPANDO_MULTIPLE(field->field_bytes, new_data, new_data_size); - //field->field_bytes = (char*)realloc((field->field_bytes), sizeof((field->field_bytes)[0]) * (new_data_size +(field->field_bytes_count))); - //memcpy(&(field->field_bytes)[field->field_bytes_count], new_data, sizeof((field->field_bytes)[0]) * new_data_size); - //memcpy( &gTmpFieldBuffer[field->field_bytes_count],new_data,new_data_size); - field->field_bytes_count += new_data_size; - } - //free(new_data); - gTotalExpands++; - /*fprintf(stderr, "ND(%d) ", new_data_size); */ - -#endif//REAL_READ - } else { - //dprintf(stderr, " <NUL[%d]> ", bf->types[section_type].size); - printf(" <NUL[%d]> ", bf->types[section_type].m_size); - } - } - -} - - -void BulletBlendReader::read_type(char* file, BlendFile* bf, unsigned long section_type,BlendField& rtn) -{ - rtn.field_bytes = NULL; - rtn.field_bytes_count = 0; - //rtn.field_offsets = NULL; - rtn.field_offsets_count = 0; - -// memset(gTmpFieldBuffer,0,1024*1024); - recursively_read_type(file, bf, section_type, &rtn); - rtn.field_bytes = (char*)malloc(rtn.field_bytes_count); - memcpy(rtn.field_bytes,gTmpFieldBuffer,rtn.field_bytes_count); -} - -int BulletBlendReader::readData(char* file, BlendFile* bf) -{ -//blend_read_data(MY_FILETYPE* file, BlendFile* bf) - long next_block_start = 12; - int finished_extracting = 0; - char section_name[5] = {0,0, 0,0, 0}; - int blockiter = 0; - - - /* slurp up the whole file block by block! */ - - do { - - unsigned long section_size; - unsigned long section_pointer; - unsigned long section_type; - unsigned long section_ents; - MY_SEEK(file, next_block_start); - - blockiter++; - MY_READ((unsigned char*)section_name, 4, 1, file); - - - if (strcmp(section_name, "DNA1") != 0) { - - - int i; - BlendBlock* blockPtr = new BlendBlock; - BlendBlock& block = *blockPtr; - - - if (strcmp(section_name, "IM") == 0) { - //printf("image\n"); - } - - - - - if (strcmp(section_name, "IP") == 0) { - //printf("ipo\n"); - } - - section_size = read_ulong(file); - section_pointer = read_ulong(file); - section_type = read_ulong(file); - section_type = bf->strc_indices[section_type]; - section_ents = read_ulong(file); - -// if (dumpNames) - { -// printf("section_name = %s, section_type = %d / %s\n",section_name,section_type,bf->types[section_type]); - - } - - memcpy(block.tag, section_name, 4); - block.tag[4] = '\0'; - block.type_index = section_type; - block.blender_pointer1 = section_pointer; - /*block.fixed_pointer = NULL;*/ - //block.array_entries = NULL; - - //block.array_entries_count = 0; - block.customData = 0; - block.customDataSize = 0; - - // dprintf(stderr, "\nsizeof(%s)=%ld: %s[%ld]\n", section_name, section_size, bf->types[section_type].name, section_ents); - - if (strcmp("Link",bf->types[section_type].name)==0) - { - if (section_size>0) - { - //read customData - block.customData= (char*)malloc(section_size); - block.customDataSize = section_size; - MY_READ((unsigned char*)block.customData,1,section_size,file); - } - } else - { - for (i=0; i<section_ents; ++i) { - BlendField* field = new BlendField; - read_type(file, bf, section_type,*field); - block.m_array_entries_.push_back(field); - } - } - - bf->m_blocks.push_back(blockPtr); - - next_block_start += 4+4+4+4+4 + section_size; - -#ifdef B_DEBUG - if (MY_TELL(file) > next_block_start) { - //dprintf(stderr, " **OVER-READ(%ld,%ld)** ", MY_TELL(file), next_block_start); - if (strcmp(bf->types[section_type].name, "Link") == 0 && - MY_TELL(file) - next_block_start == 4) { - //dprintf(stderr, "<- don't panic, known Link struct weirdness."); - } else { - dprintf(stderr, "<- okay, PANIC!"); - } - //dprintf(stderr, "\n"); - } else if (MY_TELL(file) < next_block_start) { - /*dprintf(stderr, " **under-READ(%ld,%ld)** ", - MY_TELL(file), next_block_start);*/ - } else { - /*dprintf(stderr, " :) ");*/ - } -#endif - - } else { - finished_extracting = 1; - } - - } while (!finished_extracting); - - return 1; - -} - - - -static unsigned short -read_ushort(MY_FILETYPE* file) { - unsigned char c[2]; - if (MY_READ(c, 2, 1, file) == 1) - { - return c[0] | (c[1]<<8); - } else { - return 0xFFFF; - } -} - - -static long -seek_past_string(MY_FILETYPE* file, const char *str) { - const int match_max = strlen(str); - int match_now = 0; - - do { - const char c = MY_GETC(file); - if (c == str[match_now]) { - ++match_now; - } else { - match_now = 0; - } - } while(match_now < match_max && - !MY_ATEOF(file)); - - if (MY_ATEOF(file)) { - return -1; - } - - return MY_TELL(file) - match_max; -} - - - -static long -read_long(MY_FILETYPE* file) { - unsigned char c[4]; - if (MY_READ(c, 4, 1, file) == 1) { - return ((unsigned long)c[0] | (c[1]<<8) | (c[2]<<16) | (c[3]<<24)); - } else { - return 0xFFFFFFFF; - } -} - -BlendFile* blend_read(char* file) -{ - char blender_mark[10] = {0,0,0,0, 0,0,0,0,0,0}; - BlendFile *bf; - long sdnaname_offs, type_offs, tlen_offs, strc_offs, endb_offs; - long sdnaname_size, type_size, tlen_size, strc_size; - long sdnaname_ents, type_ents, tlen_ents, strc_ents; - - MY_REWIND(file); - - /* Check file signature */ - - MY_READ((unsigned char*)blender_mark, 1, 9, file); - if (strcmp(blender_mark, "BLENDER_v") != 0) { - printf("Not a valid Blender file (.blend file needs to be written on a 32bit little-endian machine)\n"); - return NULL; - } - - /* Alloc a handle to return */ - - bf = new BlendFile(); - - bf->types = NULL; - bf->types_count = 0; - bf->names = NULL; - bf->names_count = 0; - bf->m_blocks.clear();// = NULL; - //bf->blocks_count = 0; - bf->strc_indices = NULL; - bf->strc_indices_count = 0; - bf->name_undef = -1; - - - - /* Scan the whole file (!) for file section markers */ - - sdnaname_offs = seek_past_string(file, "SDNANAME"); - sdnaname_ents = read_long(file); - type_offs = seek_past_string(file, "TYPE"); - type_ents = read_long(file); - tlen_offs = seek_past_string(file, "TLEN"); - tlen_ents = type_ents; - strc_offs = seek_past_string(file, "STRC"); - strc_ents = read_long(file); - endb_offs = seek_past_string(file, "ENDB"); - - if (sdnaname_offs == -1 || type_offs == -1 || tlen_offs == -1 || - strc_offs == -1 || endb_offs == -1) - { - printf("Couldn't find all necessary file markers. :(\n"); - return NULL; - } - - /* Move marker offsets to point to the start of each one's block */ - - sdnaname_offs += 8 + 4; - sdnaname_size = type_offs - sdnaname_offs; - - type_offs += 4 + 4; - type_size = tlen_offs - type_offs; - - tlen_offs += 4; - tlen_size = strc_offs - tlen_offs; - - strc_offs += 4 + 4; - strc_size = endb_offs - strc_offs; - - /* read the NAME table */ - - MY_SEEK(file, sdnaname_offs); - { - long offs = 0; - int i; - char *top_block_name; - - for (i=0; i<sdnaname_ents; ++i) { - int finished_name = 0; - char *this_name_chars = NULL; - int this_name_chars_count = 0; - - do { - const char c = MY_GETC(file); - ++offs; - if (offs == sdnaname_size || - c == '\0') { - finished_name = 1; - } - - EXPANDO4(this_name_chars, c); - } while (!finished_name); - - /*fprintf(stderr, "%s ", this_name_chars); */ - - EXPANDO5(bf->names, this_name_chars); - } - - /* our top-block name */ -#define BLEND_TOP_BLOCK_NAME "READBLEND_TOP_BLOCK" - top_block_name = (char*)calloc(1, 1+strlen(BLEND_TOP_BLOCK_NAME)); - strcpy(top_block_name, BLEND_TOP_BLOCK_NAME); - bf->name_undef = bf->names_count; - EXPANDO5(bf->names, top_block_name); - } - - /* read the TYPE table */ - - MY_SEEK(file, type_offs); - { - long offs = 0; - int i; - - for (i=0; i<type_ents; ++i) { - int finished_type = 0; - char *this_type_chars = NULL; - int this_type_chars_count = 0; - BlendType bt; - - do { - const char c = MY_GETC(file); - ++offs; - if (offs == type_size || - c == '\0') { - finished_type = 1; - } - - EXPANDO4(this_type_chars, c); - } while (!finished_type); - - bt.name = this_type_chars; - bt.m_size = -1; - bt.is_struct = 0; - bt.fieldtypes_count = 0; - bt.fieldtypes = NULL; - bt.fieldnames_count = 0; - bt.fieldnames = NULL; - - /* fprintf(stderr, "(%d:%s)", bt.size, bt.name);*/ - - EXPANDO6(bf->types, bt); - } - } - - /* read the TLEN table */ - - MY_SEEK(file, tlen_offs); - { - int i; - for (i=0; i<bf->types_count; ++i) { - unsigned short len = read_ushort(file); - bf->types[i].m_size = len; - /*fprintf(stderr, "sizeof(%s)=%d ", bf->types[i].name, len); */ - } - } - - /* Read the STRC table */ - - MY_SEEK(file, strc_offs); - { - int i,j; - for (i=0; i<strc_ents; ++i) { - unsigned short struc_type_index, num_fields; - struc_type_index = read_ushort(file); - num_fields = read_ushort(file); - bf->types[struc_type_index].is_struct = 1; - EXPANDO3(bf->strc_indices, struc_type_index); - /*dprintf(stderr, "\n%s: ", bf->types[struc_type_index].name); */ - for (j=0; j<num_fields; ++j) { - unsigned short ftype = read_ushort(file); - unsigned short fname = read_ushort(file); - EXPANDO3(bf->types[struc_type_index].fieldtypes, ftype); - EXPANDO3(bf->types[struc_type_index].fieldnames, fname); - /*dprintf(stderr, "%s %s , ", bf->types[ftype].name, bf->names[fname]); */ - } - } - } - - //blend_read_data(file, bf); - - /* Return the new handle */ - - return bf; -} - -/* endianness conversion macros */ -#define BGETLEUINT16(p) ((uint16_t) ( \ - ( ((uint16_t)*( 1 + (uint8_t*)(p) ))<<8 ) | \ - ( ((uint16_t)*( 0 + (uint8_t*)(p) ))<<0 ) \ - ) ) -#define BGETLEINT16(p) ((int16_t) BGETLEUINT16(p)) -#define BGETLEUINT32(p) ((uint32_t) ( \ - ( ((uint32_t)*( 3 + (uint8_t*)(p) ))<<24 ) | \ - ( ((uint32_t)*( 2 + (uint8_t*)(p) ))<<16 ) | \ - ( ((uint32_t)*( 1 + (uint8_t*)(p) ))<<8 ) | \ - ( ((uint32_t)*( 0 + (uint8_t*)(p) ))<<0 ) \ - ) ) -#define BGETLEINT32(p) ((int32_t) BGETLEUINT32(p)) -#define BGETLEUINT64(p) ((uint64_t) ( \ - ( ((uint64_t)*( 7 + (uint8_t*)(p) ))<<56 ) | \ - ( ((uint64_t)*( 6 + (uint8_t*)(p) ))<<48 ) | \ - ( ((uint64_t)*( 5 + (uint8_t*)(p) ))<<40 ) | \ - ( ((uint64_t)*( 4 + (uint8_t*)(p) ))<<32 ) | \ - ( ((uint64_t)*( 3 + (uint8_t*)(p) ))<<24 ) | \ - ( ((uint64_t)*( 2 + (uint8_t*)(p) ))<<16 ) | \ - ( ((uint64_t)*( 1 + (uint8_t*)(p) ))<<8 ) | \ - ( ((uint64_t)*( 0 + (uint8_t*)(p) ))<<0 ) \ - ) ) -#define BGETLEINT64(p) ((int64_t) BGETLEUINT64(p)) -static float BGETLEFLOAT32(char *p) { - union { /* use type-punning, or aliasing optimization will kick our arse */ - uint32_t u32; - float f32; - } punner; - punner.u32 = BGETLEUINT32(p); - return punner.f32; -} -static double BGETLEDOUBLE64(char *p) { - union { /* use type-punning, or aliasing optimization will kick our arse */ - uint64_t u64; - float f64; - } punner; - punner.u64 = BGETLEUINT64(p); - return punner.f64; -} - -int -blend_object_array_getdata(BlendFile* blend_file, - void* dest, BlendObject obj, - int dim_index_1, int dim_index_2) -{ - const char* type_name = blend_file->types[obj.type].name; - const BlendBlock* bb = (const BlendBlock*)obj.block; - - void* data; - int dim1, dim2; - - if (!bb->m_array_entries_.size()) - return 0; - - const BlendField *bf = bb->m_array_entries_[obj.entry_index]; - - name_is_array(blend_file->names[obj.name], &dim1, &dim2); - /*dprintf(stderr, "copying:'%s'[%d][%d] (of [%d][%d]) ", type_name, dim_index_1, dim_index_2, dim1, dim2);*/ - - if (dim_index_1 >= dim1 || - dim_index_2 >= dim2) { - printf("Array index (%d,%d) out of bounds for dimensionality [%d][%d]\n", dim_index_1, dim_index_2, dim1, dim2); - return 0; - } - - data = &bf->field_bytes[bf->m_field_offsets[obj.field_index + dim2*dim_index_1 + dim_index_2]]; - /*dprintf(stderr, "fi[%d]byteo[%d]", obj.field_index, - bf->field_offsets[obj.field_index + - dim2*dim_index_1 + dim_index_2]);*/ - - if (name_is_pointer(blend_file->names[obj.name])) { - *(BlendBlock **)dest = - blend_block_from_blendpointer(blend_file, - BGETLEUINT32(data)); - return 1; - } - - /* FIXME: might be a good idea to do less-crappy word-size conversions - here -- these might read beyond the end of malloc'd blocks if we - ever change our field-padding policy. There were endian problems - too; these are believed fixed now. */ - /* The signed conversions look strange because they have to sign-expand - negative results without relying on right-shifts which have undefined - behaviour on negative data according to ANSI C. */ - if (blend_type_basename_compare(type_name, "char") == 0) { - *(char*)dest = (*(char*)data) << (8*sizeof(char)-8) / (1<<(8*sizeof(char)-8)); - } else if (blend_type_basename_compare(type_name, "uchar") == 0) { - *(unsigned char*)dest = *(unsigned char*)data; - } else if (blend_type_basename_compare(type_name, "short") == 0) { - *(int16_t*)dest = BGETLEINT16(data) << (8*sizeof(int16_t)-16) / (1<<(8*sizeof(int16_t)-16)); - } else if (blend_type_basename_compare(type_name, "ushort") == 0) { - *(uint16_t*)dest = BGETLEUINT16(data); - } else if (blend_type_basename_compare(type_name, "int") == 0) { - *(int32_t*)dest = BGETLEINT32(data) << (8*sizeof(int32_t)-32) / (1<<(8*sizeof(int32_t)-32)); - } else if (blend_type_basename_compare(type_name, "long") == 0) { - *(int32_t*)dest = BGETLEINT32(data) << (8*sizeof(int32_t)-32) / (1<<(8*sizeof(int32_t)-32)); - } else if (blend_type_basename_compare(type_name, "ulong") == 0) { - *(uint32_t*)dest = BGETLEUINT32(data); - } else if (blend_type_basename_compare(type_name, "float") == 0) { - *(float*)dest = BGETLEFLOAT32((char*)data); - /*fprintf(stderr, "GOT{%f'%f} ", *(float*)dest, *(float*)data);*/ - } else if (blend_type_basename_compare(type_name, "double") == 0) { - *(double*)dest = BGETLEDOUBLE64((char*)data); - } else if (blend_type_basename_compare(type_name, "void") == 0) { - printf("Tried to fetch a void.\n"); - return 0; - } else { - printf("Tried to fetch a whole structure.\n"); - return 0; - } - return 1; /* success */ -} - -static BlendObjType -typelong_to_blendobj_type(BlendFile* blend_file, - long btype, long bname) -{ - if (name_is_pointer(blend_file->names[bname])) { - return BLEND_OBJ_POINTER; - } else if (blend_file->types[btype].is_struct) { - return BLEND_OBJ_STRUCT; - } else { - return typestring_to_blendobj_type(blend_file, - blend_file->types[btype].name); - } -} - - - -BlendObjType -blend_object_type(BlendFile* blend_file, - BlendObject obj) { - return typelong_to_blendobj_type(blend_file, - obj.type, - obj.name); -} - - -int -blend_object_structure_getfield(BlendFile* blend_file, - BlendObject *result, - BlendObject obj, - const char* field_name) -{ - if (blend_file->types[obj.type].is_struct) { - int i; - int field_index = 0; - for (i=0; i<blend_file->types[obj.type].fieldnames_count; ++i) { - if (blend_type_basename_compare( - blend_file->names[blend_file->types[obj.type].fieldnames[i]], - field_name) - == 0) { - result->type = blend_file->types[obj.type].fieldtypes[i]; - result->name = blend_file->types[obj.type].fieldnames[i]; - result->block = obj.block; - result->entry_index = obj.entry_index; - result->field_index = field_index; - return 1; - } - - { - BlendObject qo = obj; - int fos; - qo.type = blend_file->types[obj.type].fieldtypes[i]; - qo.name = blend_file->types[obj.type].fieldnames[i]; - qo.field_index = field_index; - fos = get_num_type_segments(blend_file, qo); - /*fprintf(stderr, ">>%s %s:%d ", - blend_file->types[qo.type].name, - blend_file->names[qo.name], fos);*/ - field_index += fos; - } - } - return 0; - } else { - printf("Indexed object isn't a structure!\n"); - return 0; - } -} - -BlendObject -blend_block_get_object(BlendFile* blend_file, - BlendBlock * block, - int entry_index) -{ - BlendObject bo; - const BlendBlock* bb = (const BlendBlock *)block; - /*BlendField *bf = &bb->array_entries[entry_index]; */ - - bo.type = bb->type_index; - bo.name = blend_file->name_undef; - bo.block = block; - bo.entry_index = entry_index; - bo.field_index = 0; - - return bo; -} - -#define MAX_CACHED_IMAGES 1024 -BlendBlock * tCachedTPage[MAX_CACHED_IMAGES]; -bImage* tCachedImages[MAX_CACHED_IMAGES]; -int gNumCachedImages=0; - -#ifndef LEN3POW2 -/* length squared */ -#define LEN3POW2(xd,yd,zd) ((xd)*(xd) + (yd)*(yd) + (zd)*(zd)) -#endif - -#ifndef LEN3 -/* length (expensive) */ -#define LEN3(xd,yd,zd) (sqrt(LEN3POW2((xd),(yd),(zd)))) -#endif - -#ifndef NORMALIZE3 -/* vector normalization (expensive) */ -#define NORMALIZE3(xd,yd,zd) \ - do { \ - const double norm3_macro_len3 = LEN3((xd),(yd),(zd)); \ - if (norm3_macro_len3 != 0.0F) \ -{ \ - (xd) = (xd) / norm3_macro_len3; \ - (yd) = (yd) / norm3_macro_len3; \ - (zd) = (zd) / norm3_macro_len3; \ -} \ - } while (0) -#endif - - -void -blend_acquire_mesh_from_obj(BlendFile *bf, BlendObject *meobj, bMesh *mesh) -{ - { - BlendObject obj; - BlendBlock * vblock, *fblock, *cblock, *ttblock,*mtblock,*dblock, *matlink; - int i; - int32_t ldata = 123456; - float fdata1, fdata2, fdata3; - - blend_init_mesh(mesh); - - if (!(blend_object_structure_getfield(bf, &obj, *meobj, - "totvert") && - blend_object_getdata(bf, &ldata, obj))) - { - printf("invalid mesh 0x1\n"); - meobj->type = BOBJ_TYPE_INVALID_MESH; - return; - } - mesh->vert_count = ldata; - - if (!(blend_object_structure_getfield(bf, &obj, *meobj, - "totface") && - blend_object_getdata(bf, &ldata, obj))) - { - printf("invalid mesh 0x2\n"); - meobj->type = BOBJ_TYPE_INVALID_MESH; - return; - } - mesh->face_count = ldata; - - //printf("%d verts, %d faces...\n", mesh->vert_count, mesh->face_count); - - if (!(blend_object_structure_getfield(bf, &obj, *meobj, - "mface") && - blend_object_getdata(bf, &fblock, obj))) - { - printf("invalid mesh 0x3\n"); - meobj->type = BOBJ_TYPE_INVALID_MESH; - return; - } - /* null fblock is okay */ - - if (blend_object_structure_getfield(bf, &obj, *meobj, - "mat") && - blend_object_getdata(bf, &matlink, obj) && matlink) { - /* found an indirect material link, follow it */ - BlendObject matlinkobj = blend_block_get_object(bf, matlink, 0); - BlendBlock * matblock; - if (obj.block) - { - if (blend_object_structure_getfield(bf, &obj, matlinkobj, - "next") && - blend_object_getdata(bf, &matblock, obj)) { - if (matblock) { - BlendObject matobj = blend_block_get_object(bf, matblock, 0); - mesh->material = blend_alloc_material(); - blend_acquire_material_from_obj(bf, &matobj, mesh->material); - } else { - /* um, okay, link went nowhere, leave mesh->material NULL */ - } - } else { - //abort();//might fail? - } - } - } else { - /* no material -- mesh->material will remain NULL */ - } - - if (!(blend_object_structure_getfield(bf, &obj, *meobj, - "mvert") && - blend_object_getdata(bf, &vblock, obj))) { - abort(); - } - /* null vblock is okay */ - - if (!(blend_object_structure_getfield(bf, &obj, *meobj, - "tface") && - blend_object_getdata(bf, &ttblock, obj))) { - abort(); - } - - if (!(blend_object_structure_getfield(bf, &obj, *meobj, - "mtface") && - blend_object_getdata(bf, &mtblock, obj))) { - mtblock=0; - } - - if (!(blend_object_structure_getfield(bf, &obj, *meobj, - "mcol") && - blend_object_getdata(bf, &cblock, obj))) { - abort(); - } - - if (!(blend_object_structure_getfield(bf, &obj, *meobj, - "dvert") && - blend_object_getdata(bf, &dblock, obj))) { - /* sometimes there isn't a dvert block... */ - dblock = NULL; - } - - mesh->vert = (bVert*) malloc(sizeof(bVert) * mesh->vert_count); - - for (i=0; i<mesh->vert_count; ++i) { - BlendObject obj = blend_block_get_object(bf, vblock, i); - BlendObject aobj; - float fdata1, fdata2, fdata3; - int32_t sdata1, sdata2, sdata3; - //char cdata; - short int cdata; - cdata=0; - - mesh->vert[i].xyz[0] = - mesh->vert[i].xyz[1] = - mesh->vert[i].xyz[2] = -12345; - mesh->vert[i].cnormal[0] = - mesh->vert[i].cnormal[1] = - mesh->vert[i].cnormal[2] = -12345; - mesh->vert[i].mat = -1; - - if (!(blend_object_structure_getfield(bf, &aobj, obj, "co") && - blend_object_array_getdata(bf, &fdata1, aobj, 0,0) && - blend_object_array_getdata(bf, &fdata2, aobj, 0,1) && - blend_object_array_getdata(bf, &fdata3, aobj, 0,2))) { - abort(); - } - mesh->vert[i].xyz[0] = fdata1; - mesh->vert[i].xyz[1] = fdata2; - mesh->vert[i].xyz[2] = fdata3; - - if (!(blend_object_structure_getfield(bf, &aobj, obj, "no") && - blend_object_array_getdata(bf, &sdata1, aobj, 0,0) && - blend_object_array_getdata(bf, &sdata2, aobj, 0,1) && - blend_object_array_getdata(bf, &sdata3, aobj, 0,2))) { - abort(); - } - mesh->vert[i].cnormal[0] = sdata1; - mesh->vert[i].cnormal[1] = sdata2; - mesh->vert[i].cnormal[2] = sdata3; - /*fprintf(stderr, "%f ", LEN3(mesh->vert[i].normal[0], - mesh->vert[i].normal[1], - mesh->vert[i].normal[2]));*/ - if (sdata1 != 0 || sdata2 != 0 || sdata3 != 0) { - NORMALIZE3(mesh->vert[i].cnormal[0], - mesh->vert[i].cnormal[1], - mesh->vert[i].cnormal[2]); - } - - if (!(blend_object_structure_getfield(bf, &aobj, obj, "mat_nr") && - blend_object_getdata(bf, &cdata, aobj))) { - abort(); - } - mesh->vert[i].mat = cdata; - } - - mesh->face = (bFace*)malloc(sizeof(bFace) * mesh->face_count); - - for (i=0; i<mesh->face_count; ++i) { - int j,k; - BlendObject obj = blend_block_get_object(bf, fblock, i); - BlendObject aobj; - //char cdata; - int cdata; - cdata=0; - - - mesh->face[i].v[0] = mesh->face[i].v[1] = - mesh->face[i].v[2] = mesh->face[i].v[3] = -1; - mesh->face[i].mat = -1; - mesh->face[i].flags = 0; - - for (j=0; j<4; ++j) { - for (k=0; k<3; ++k) { - mesh->face[i].rgba[j][k] = 1.0; - } - mesh->face[i].rgba[j][3] = 1.0f; - mesh->face[i].uv[j][0] = 0.0f; - mesh->face[i].uv[j][1] = 0.0f; - mesh->face[i].m_image = NULL; - } - - if (blend_object_structure_getfield(bf, &aobj, obj, "v1")) { - if (0!=strcmp(bf->types[aobj.type].name,"int") && - 0!=strcmp(bf->types[aobj.type].name,"ushort")) { - printf("Expected vertex-index type to be 'ushort' or 'int', got '%s'\n", bf->types[aobj.type].name); - abort(); - } - - if (0==strcmp(bf->types[aobj.type].name,"int")) { - /* index type is a 32bit int, generated by newish Blenders */ - int32_t idata; - if (!(blend_object_structure_getfield(bf, &aobj, obj, "v1") && - blend_object_getdata(bf, &idata, aobj))) { - abort(); - } - mesh->face[i].v[0] = idata; - - if (!(blend_object_structure_getfield(bf, &aobj, obj, "v2") && - blend_object_getdata(bf, &idata, aobj))) { - abort(); - } - mesh->face[i].v[1] = idata; - - if (!(blend_object_structure_getfield(bf, &aobj, obj, "v3") && - blend_object_getdata(bf, &idata, aobj))) { - abort(); - } - mesh->face[i].v[2] = idata; - - if (!(blend_object_structure_getfield(bf, &aobj, obj, "v4") && - blend_object_getdata(bf, &idata, aobj))) { - abort(); - } - mesh->face[i].v[3] = idata; - } else { - /* index type is a 16bit ushort, generated by old Blenders */ - uint16_t usdata; - if (!(blend_object_structure_getfield(bf, &aobj, obj, "v1") && - blend_object_getdata(bf, &usdata, aobj))) { - abort(); - } - mesh->face[i].v[0] = usdata; - - if (!(blend_object_structure_getfield(bf, &aobj, obj, "v2") && - blend_object_getdata(bf, &usdata, aobj))) { - abort(); - } - mesh->face[i].v[1] = usdata; - - if (!(blend_object_structure_getfield(bf, &aobj, obj, "v3") && - blend_object_getdata(bf, &usdata, aobj))) { - abort(); - } - mesh->face[i].v[2] = usdata; - - if (!(blend_object_structure_getfield(bf, &aobj, obj, "v4") && - blend_object_getdata(bf, &usdata, aobj))) { - abort(); - } - mesh->face[i].v[3] = usdata; - } - } else { - abort(); - } - - if (!(blend_object_structure_getfield(bf, &aobj, obj, "mat_nr") && - blend_object_getdata(bf, &cdata, aobj))) { - abort(); - } - mesh->face[i].mat = cdata; - - if (!(blend_object_structure_getfield(bf, &aobj, obj, "flag") && - blend_object_getdata(bf, &cdata, aobj))) { - abort(); - } - mesh->face[i].flags = cdata; - } - - if (cblock) { - /* we have vertex colours */ - for (i=0; i<mesh->face_count; ++i) { - int j; - - unsigned int cdata; - //unsigned char cdata; - BlendObject aobj; - cdata=0; - - for (j=0; j<4; ++j) { - BlendObject obj = blend_block_get_object(bf, cblock, i*4+j); - if (!(blend_object_structure_getfield(bf, &aobj, obj, "b") && - blend_object_getdata(bf, &cdata, aobj))) { - abort(); - } - mesh->face[i].rgba[j][0] = cdata / 255.0f; - - if (!(blend_object_structure_getfield(bf, &aobj, obj, "g") && - blend_object_getdata(bf, &cdata, aobj))) { - abort(); - } - mesh->face[i].rgba[j][1] = cdata / 255.0f; - - if (!(blend_object_structure_getfield(bf, &aobj, obj, "r") && - blend_object_getdata(bf, &cdata, aobj))) { - abort(); - } - mesh->face[i].rgba[j][2] = cdata / 255.0f; - - /* alpha seems to be nonsense :( */ - /* - if (!(blend_object_structure_getfield(bf, &aobj, obj, "a") && - blend_object_getdata(bf, &cdata, aobj))) { - abort(); - } - mesh->face[i].rgba[j][3] = cdata / 255.0f; - */ - mesh->face[i].rgba[j][3] = 1.0f; - } - } - } else { - /* !cblock (no vertex colours) */ - for (i=0; i<mesh->face_count; ++i) { - int j; - for (j=0; j<4; ++j) { - mesh->face[i].rgba[j][0] = 1.0f; - mesh->face[i].rgba[j][1] = 1.0f; - mesh->face[i].rgba[j][2] = 1.0f; - mesh->face[i].rgba[j][3] = 1.0f; - } - } - } - - if (mtblock) - { - /* we have tex co-ords */ - for (i=0; i<mesh->face_count; ++i) - { - int j,k; - void *pdata; - BlendObject aobj; - BlendObject obj = blend_block_get_object(bf, mtblock, i); - BlendObject obj2,obj3; - unsigned char flag; - unsigned short int mode; - - BlendBlock * tpageptr; - - if (blend_object_structure_getfield(bf, &obj3, obj, "flag")) - { - blend_object_getdata(bf, &flag, obj3); - mesh->face[i].m_flag = flag; - } else - { - mesh->face[i].m_flag = 0; - } - - if (blend_object_structure_getfield(bf, &obj3, obj, "mode")) - { - blend_object_getdata(bf, &mode, obj3); - mesh->face[i].m_mode = mode; - } else - { - mesh->face[i].m_mode = 0; - } - - if ((blend_object_structure_getfield(bf, &obj3, obj, "tpage") - && blend_object_getdata(bf, &tpageptr, obj3))) - { - - mesh->face[i].m_image = 0; - - for (j=0; j<4; ++j) - { - uint32_t uldata; - for (k=0; k<2; ++k) { - float fdata; - if (!(blend_object_structure_getfield(bf, &aobj, obj, "uv") && - blend_object_array_getdata(bf, &fdata, aobj, j,k))) { - abort(); - } - mesh->face[i].uv[j][k] = fdata; - } - mesh->face[i].uv[j][1] = 1.0f - mesh->face[i].uv[j][1]; - /* texture face colour... not sure how this conceptually - differs from the face vertex colours, but it does. */ - - /* in its usual inconsistant style, blender packs this - RGBA value into the bytes of an unsigned long... */ - - } - - //printf("got tpage\n"); - - { - int k; - for (k=0;k<gNumCachedImages;k++) - { - if (tCachedTPage[k]==tpageptr) - { - mesh->face[i].m_image=tCachedImages[k]; - break; - } - } - } - - if (!mesh->face[i].m_image) - { - bImage* bimg= (bImage*)malloc (sizeof(bImage)); - tCachedImages[gNumCachedImages]=bimg; - tCachedTPage[gNumCachedImages] = tpageptr; - gNumCachedImages++; - mesh->face[i].m_image = bimg; - bimg->m_packedImagePtr = 0; - bimg->m_sizePackedImage = 0; - - if (tpageptr) - { - BlendObject name_block; - BlendObject tpage = blend_block_get_object(bf,tpageptr,0); - - BlendObject okblock; - - - if ((blend_object_structure_getfield(bf, &okblock, tpage, "ok"))) - { - short int okval; - if (blend_object_getdata(bf,&okval,okblock)) - { -// printf("ok=%d\n",okval); - bimg->m_ok = okval; - } else - { - bimg->m_ok=0; - } - - } - - if ((blend_object_structure_getfield(bf, &okblock, tpage, "xrep"))) - { - short int xrep; - if (blend_object_getdata(bf,&xrep,okblock)) - { -// printf("xrep=%d\n",xrep); - bimg->m_xrep = xrep; - } else - { - bimg->m_xrep = 0; - } - } - - if ((blend_object_structure_getfield(bf, &okblock, tpage, "yrep"))) - { - short int yrep; - if (blend_object_getdata(bf,&yrep,okblock)) - { -// printf("yrep=%d\n",yrep); - bimg->m_yrep = yrep; - } else - { - bimg->m_yrep = 0; - } - } - - mesh->face[i].image_id = 0; - { - BlendBlock * packptr; - - if ((blend_object_structure_getfield(bf, &obj3, tpage, "packedfile") - && blend_object_getdata(bf, &packptr, obj3))) - { - if (packptr) - { - BlendObject packfile= blend_block_get_object(bf,packptr,0); - BlendBlock * dataptr; - if ((blend_object_structure_getfield(bf, &obj3, packfile, "data") - && blend_object_getdata(bf, &dataptr, obj3))) - { - /*BlendObject data= blend_block_get_object(bf,dataptr,0); - char dest[1024]; - blend_object_getstring(bf,data,dest,1023); - */ - -// printf("...\n"); - - //if (blend_object_structure_getfield(bf, &obj2, ipo,"curve")) - { - BlendBlock* block = (BlendBlock*)obj3.block; - - - void** ptrptr = (void**) &block->m_array_entries_[0]->field_bytes[block->m_array_entries_[0]->m_field_offsets[obj3.field_index]]; - BlendBlock * ptr = (BlendBlock *)*ptrptr; - if (ptr) - { - ///todo: fix ptr issue - BlendBlock * curveblockptr = blend_block_from_blendpointer(bf, (uint32_t)ptr); - BlendObject curve = blend_block_get_object(bf, curveblockptr, 0); - BlendBlock* bb = (BlendBlock* )curve.block; - BlendBlock imgblock; - mesh->face[i].image_id = (BlendBlock *)bb->blender_pointer1; - //imgblock = blend_block_get_object(bf, bb->blender_pointer, 0); - bimg->m_packedImagePtr = bb->customData; - bimg->m_sizePackedImage = bb->customDataSize; - } - - } - } - - - } - - } - } - - - - - if ((blend_object_structure_getfield(bf, &name_block, tpage, "name"))) - { - int max_chars=127; - - if (blend_object_getstring(bf,name_block,bimg->m_imagePathName, max_chars)) - { -// printf("texname=%s\n",bimg->m_imagePathName); - } - - } - - - - } - - } - - - } - - - - - } - } - else - { - if (ttblock) { - /* we have tex co-ords */ - for (i=0; i<mesh->face_count; ++i) { - int j,k; - void *pdata; - BlendObject aobj; - BlendObject obj = blend_block_get_object(bf, ttblock, i); - - if (!(blend_object_structure_getfield(bf, &aobj, obj, "tpage") && - blend_object_getdata(bf, &pdata, aobj))) { - abort(); - } - mesh->face[i].image_id = (BlendBlock *)pdata; - - for (j=0; j<4; ++j) { - uint32_t uldata; - for (k=0; k<2; ++k) { - float fdata; - if (!(blend_object_structure_getfield(bf, &aobj, obj, "uv") && - blend_object_array_getdata(bf, &fdata, aobj, j,k))) { - abort(); - } - mesh->face[i].uv[j][k] = fdata; - } - mesh->face[i].uv[j][1] = 1.0f - mesh->face[i].uv[j][1]; - /* texture face colour... not sure how this conceptually - differs from the face vertex colours, but it does. */ - if (!(blend_object_structure_getfield(bf, &aobj, obj, "col") && - blend_object_array_getdata(bf, &uldata, aobj, 0,j))) { - abort(); - } - /* in its usual inconsistant style, blender packs this - RGBA value into the bytes of an unsigned long... */ - mesh->face[i].rgba2[j][0] = ((uldata >> 24) & 0xFF) / 255.0f; - mesh->face[i].rgba2[j][1] = ((uldata >> 16) & 0xFF) / 255.0f; - mesh->face[i].rgba2[j][2] = ((uldata >> 8) & 0xFF) / 255.0f; - mesh->face[i].rgba2[j][3] = ((uldata >> 0) & 0xFF) / 255.0f; - } - /*mesh->face[i].uv[0][0]=0; mesh->face[i].uv[0][1]=0; - mesh->face[i].uv[1][0]=1; mesh->face[i].uv[1][1]=0; - mesh->face[i].uv[2][0]=1; mesh->face[i].uv[2][1]=1; - mesh->face[i].uv[3][0]=0; mesh->face[i].uv[3][1]=1;*/ - - } - } else { - /* !tblock (no texture co-ords, no face tex-colours) */ - for (i=0; i<mesh->face_count; ++i) { - int j; - for (j=0; j<4; ++j) { - mesh->face[i].rgba2[j][0] = 1.0f; - mesh->face[i].rgba2[j][1] = 1.0f; - mesh->face[i].rgba2[j][2] = 1.0f; - mesh->face[i].rgba2[j][3] = 1.0f; - } - } - } - } - - if (mtblock) - { - BlendObject obj = blend_block_get_object(bf, mtblock, 0); - - //6155 - } - - - if (dblock) { - /* we have vertex deformation weights */ - for (i=0; i<mesh->vert_count; ++i) { - int j; - int32_t ldata; - float fdata; - BlendBlock * pdata; - BlendObject aobj; - BlendObject obj = blend_block_get_object(bf, dblock, i); - - if (!(blend_object_structure_getfield(bf, &aobj, obj, "totweight") && - blend_object_getdata(bf, &ldata, aobj))) { - abort(); - } - mesh->vert[i].deform_weights_count = ldata; - mesh->vert[i].deform_weights = (bDeformWeight*) malloc(ldata*sizeof(bDeformWeight)); - - if (!(blend_object_structure_getfield(bf, &aobj, obj, "dw") && - blend_object_getdata(bf, &pdata, aobj))) { - abort(); - } - - for (j=0; j<mesh->vert[i].deform_weights_count; ++j) { - BlendObject dwobj = blend_block_get_object(bf, pdata, j); - - if (!(blend_object_structure_getfield(bf, &aobj, dwobj, "def_nr") - && blend_object_getdata(bf, &ldata, aobj))) { - abort(); - } - mesh->vert[i].deform_weights[j].bone_id = ldata; - - if (!(blend_object_structure_getfield(bf, &aobj, dwobj, "weight") - && blend_object_getdata(bf, &fdata, aobj))) { - abort(); - } - mesh->vert[i].deform_weights[j].weight = fdata; - } - } - } else { - /* !dblock (no vertex deformation weights) */ - for (i=0; i<mesh->vert_count; ++i) { - mesh->vert[i].deform_weights = NULL; - mesh->vert[i].deform_weights_count = 0; - } - } - } -} - -int -blend_block_get_entry_count(BlendFile* blend_file, - BlendBlock * block) -{ - const BlendBlock* bb = (const BlendBlock*)block; - return bb->m_array_entries_.size();//>array_entries_count;; -} - -void -blend_init_mesh(bMesh *mesh) -{ - int i,j; - mesh->vert = NULL; - mesh->vert_count = 0; - mesh->face = NULL; - mesh->face_count = 0; - mesh->material = NULL; -} - - - -void extract_curve_bezier_triples(BlendFile *bf, BlendObject* curve) -{ - BlendObject newObj; - BlendBlock * bezTriplePtr; - int i; - int totvert=0; - - - - - - if (!(blend_object_structure_getfield(bf, &newObj, *curve,"totvert") && blend_object_getdata(bf, &totvert, newObj))) - { - return; - } - - printf("Curve with %d bezier triples\n",totvert); - - if (!(blend_object_structure_getfield(bf, &newObj, *curve,"bezt") && blend_object_getdata(bf, &bezTriplePtr, newObj))) - { - printf("invalid bezTriplePtr 0x1\n"); - } - - for ( i=0;i<totvert;i++) - { - - - - if (bezTriplePtr) - { - BlendObject bezTriple; - BlendBlock * vecPtr; - bezTriple = blend_block_get_object(bf, bezTriplePtr, i); - { - BlendObject vecOb; - - if (blend_object_structure_getfield(bf, &vecOb, bezTriple, "vec")) - { - float v0; - int i,j; - - for (i=0;i<3;i++) - { - for (j=0;j<3;j++) - { - if (blend_object_array_getdata(bf, &v0, vecOb, i,j)) - { - //printf("IpoCurve.bezt.vec[%d][%d]=%f\n",i,j,v0); - } - } - } - } - - } - } - } -} - - - - -void -blend_acquire_obj_from_obj(BlendFile *bf, BlendObject *objobj, - bObj *outobj, BlendObject **mallocdoutblendobject) -{ - - BlendObject obj, dataobj; - BlendBlock * block,*ipoblock,*curveblock=0; - short sdata = 12345; - -#define B_IDNAME_MAX_SIZE 80 - char *idname = (char*)malloc(1 + B_IDNAME_MAX_SIZE); - float fdata1, fdata2, fdata3; - - if (mallocdoutblendobject) *mallocdoutblendobject = NULL; - - blend_init_obj(outobj); - - if (!(blend_object_structure_getfield(bf, &obj, *objobj, - "type") && - blend_object_getdata(bf, &sdata, obj))) - { - abort(); /* couldn't get type */ - } else { - switch (sdata) { - case 1: /* mesh */ - outobj->type = BOBJ_TYPE_MESH; break; - case 10: /* lamp */ - outobj->type = BOBJ_TYPE_LAMP; break; - case 11: /* camera */ - outobj->type = BOBJ_TYPE_CAMERA; break; - default: - outobj->type = BOBJ_TYPE_UNKNOWN; break; - } - } - - if (blend_object_get_IDname(bf, *objobj, idname, B_IDNAME_MAX_SIZE)) { - outobj->name = idname; - } else { - free(idname); - abort(); /* couldn't get obj name */ - } - - /* now we override the mesh transform with the object's. should - we merge, instead??? - hm, dunno, don't think so. */ - - - if (blend_object_structure_getfield(bf, &obj, *objobj, "loc") && - blend_object_array_getdata(bf, &fdata1, obj, 0,0) && - blend_object_array_getdata(bf, &fdata2, obj, 0,1) && - blend_object_array_getdata(bf, &fdata3, obj, 0,2)) { - outobj->location[0] = fdata1; - outobj->location[1] = fdata2; - outobj->location[2] = fdata3; - } else { - outobj->location[0] = - outobj->location[1] = - outobj->location[2] = 0.0f; - } - - if (blend_object_structure_getfield(bf, &obj, *objobj, "size") && - blend_object_array_getdata(bf, &fdata1, obj, 0,0) && - blend_object_array_getdata(bf, &fdata2, obj, 0,1) && - blend_object_array_getdata(bf, &fdata3, obj, 0,2)) { - outobj->scaling[0] = fdata1; - outobj->scaling[1] = fdata2; - outobj->scaling[2] = fdata3; - } else { - outobj->scaling[0] = - outobj->scaling[1] = - outobj->scaling[2] = 1.0f; - } - - if (blend_object_structure_getfield(bf, &obj, *objobj, "rot") && - blend_object_array_getdata(bf, &fdata1, obj, 0,0) && - blend_object_array_getdata(bf, &fdata2, obj, 0,1) && - blend_object_array_getdata(bf, &fdata3, obj, 0,2)) { - outobj->rotphr[0] = fdata1; - outobj->rotphr[1] = fdata2; - outobj->rotphr[2] = fdata3; - } else { - outobj->rotphr[0] = - outobj->rotphr[1] = - outobj->rotphr[2] = 0.0f; - } - - if (blend_object_structure_getfield(bf, &obj, *objobj, "parentinv")) { - int i,j; - for (i=0; i<4; ++i) { - for (j=0; j<4; ++j) { - blend_object_array_getdata(bf, &fdata1, obj, i,j); - outobj->parentimat[i][j] = fdata1; - } - } - } -#if 0 - if (blend_object_structure_getfield(bf, &obj, *objobj, "transflag")) { - char cdata; - /* TODO: decode what these flags precisely mean. */ - /* top bit is 'powertrack' */ - if (blend_object_getdata(bf, &cdata, obj)) { - outobj->transflags = (unsigned char)cdata; - } - } -#endif - - outobj->mass = 0.f; - if (blend_object_structure_getfield(bf, &obj, *objobj, "mass")) - { - float mass; - if (blend_object_getdata(bf, &mass, obj)) - { - outobj->mass = mass; - } - } - - - - - if ((blend_object_structure_getfield(bf, &obj, *objobj,"ipo") && blend_object_getdata(bf, &ipoblock, obj))) - { - if (ipoblock) - { - BlendObject ipo = blend_block_get_object(bf, ipoblock, 0); -#define MAX_CHARS 31 - char iponame[MAX_CHARS]; - BlendObject obj2,obj3; - - blend_object_get_IDname(bf,ipo,iponame,MAX_CHARS-1); -// printf("ipo.ID.name = %s\n",iponame); - - if (blend_object_structure_getfield(bf, &obj2, ipo,"curve")) - { - - BlendBlock* block = (BlendBlock*)obj2.block; - - - void** ptrptr = (void**)&block->m_array_entries_[0]->field_bytes[block->m_array_entries_[0]->m_field_offsets[obj2.field_index]]; - BlendBlock * ptrlast; - BlendBlock * ptr = (BlendBlock *)*ptrptr; - ptrptr++; - ptrlast= (BlendBlock *)*ptrptr; - - - //ptrptr++; contains the 'last' pointer - if (ptr) - { - BlendBlock * curveblockptr = blend_block_from_blendpointer(bf, (uint32_t)ptr); - BlendObject curve; - BlendBlock* block3; - BlendBlock* block2; - BlendObject newObj,nextOb; - BlendBlock * nextPtr; - - printf("Found IpoCurve(s) (ListBase)\n"); - - curve = blend_block_get_object(bf, curveblockptr, 0); - block3 = (BlendBlock*)curve.block; - - - block2 = (BlendBlock*)obj.block; - - - - do { - extract_curve_bezier_triples(bf, &curve); - - //blend_acquire_obj_from_obj(bf,&obj,&tmpObj,0); - if (!(blend_object_structure_getfield(bf, &nextOb, curve,"next") && blend_object_getdata(bf, &nextPtr, nextOb))) - { - printf("error: no next?\n"); - } else - { - ///this 'next' object would let you iterate over the linked list until next == 0 - if (nextPtr) - { - BlendBlock* block3; - nextOb = blend_block_get_object(bf, nextPtr, 0); - block3 = (BlendBlock*)nextOb.block; - curve = nextOb; - } - } - - - } while (nextPtr); - - - - - - - } - - } - - - } - } - - - - - outobj->boundtype = 0; - if (blend_object_structure_getfield(bf, &obj, *objobj, "boundtype")) - { - short int boundtype; - if (blend_object_getdata(bf, &boundtype, obj)) - { - outobj->boundtype= boundtype; - } - } - - outobj->gameflag = 0; - if (blend_object_structure_getfield(bf, &obj, *objobj, "gameflag")) - { - int gameflag; - if (blend_object_getdata(bf, &gameflag, obj)) - { - outobj->gameflag= gameflag; - } - } - - - - - if (blend_object_structure_getfield(bf, &obj, *objobj, "obmat")) { - int i,j; - for (i=0; i<4; ++i) { - for (j=0; j<4; ++j) { - blend_object_array_getdata(bf, &fdata1, obj, i,j); - outobj->transform[i][j] = fdata1; -// printf("%0.3f ", fdata1); - } -// printf("\n"); - } - } - - /* get actual mesh obj here */ - - if (! (blend_object_structure_getfield(bf, &obj, *objobj, "data") && - blend_object_getdata(bf, &block, obj))) - { - printf("no mesh\n"); - outobj->data.mesh = 0; - return; - //abort(); - } - - if (block == NULL) { - outobj->type = BOBJ_TYPE_NULL; - } else { - dataobj = blend_block_get_object(bf, block, 0); - if (mallocdoutblendobject) { - *mallocdoutblendobject = (BlendObject*)malloc(sizeof(BlendObject)); - **mallocdoutblendobject = dataobj; - } - } - - - switch (outobj->type) { - case BOBJ_TYPE_MESH: - outobj->data.mesh = blend_alloc_mesh(); - blend_acquire_mesh_from_obj(bf, &dataobj, outobj->data.mesh); - break; - case BOBJ_TYPE_UNKNOWN: - default: - case BOBJ_TYPE_NULL: - outobj->data.dummy = NULL; - break; - } - -} - - - - -BlendBlock * -blend_block_from_blendpointer(BlendFile *blend_file, - uint32_t blendpointer) -{ - int i; - - /* fprintf(stderr, "%04x: ", blendpointer);*/ - - if (blendpointer != 0) { - for (i=0; i<blend_file->m_blocks.size(); ++i) { - /*fprintf(stderr, "%04x? ", blend_file->blocks[i].blender_pointer); */ - if (blend_file->m_blocks[i]->blender_pointer1 == blendpointer) { - return blend_file->m_blocks[i]; - } - } - } - - return NULL; -} - - -void -blend_acquire_material_from_obj(BlendFile *bf, BlendObject *matobj, - bMaterial *mat) -{ - BlendObject obj; - int i; - int32_t ldata = 123456; - float fdata = 123456.0; - - blend_init_material(mat); - - if ((blend_object_structure_getfield(bf, &obj, *matobj, "r") && - blend_object_getdata(bf, &fdata, obj))) { - mat->colour_rgba[0] = fdata; - } - if ((blend_object_structure_getfield(bf, &obj, *matobj, "g") && - blend_object_getdata(bf, &fdata, obj))) { - mat->colour_rgba[1] = fdata; - } - if ((blend_object_structure_getfield(bf, &obj, *matobj, "b") && - blend_object_getdata(bf, &fdata, obj))) { - mat->colour_rgba[2] = fdata; - } - if ((blend_object_structure_getfield(bf, &obj, *matobj, "alpha") && - blend_object_getdata(bf, &fdata, obj))) { - mat->colour_rgba[3] = fdata; - } - if ((blend_object_structure_getfield(bf, &obj, *matobj, "emit") && - blend_object_getdata(bf, &fdata, obj))) { - mat->emit = fdata; - } - - if (!(blend_object_structure_getfield(bf, &obj, *matobj, "mode") && - blend_object_getdata(bf, &ldata, obj))) { - abort(); - } - if (ldata & 0x04) { - mat->feature_mask |= BMAT_FEATURE_SHADELESS; - } - if (ldata & 0x08) { - mat->feature_mask |= BMAT_FEATURE_WIRE; - } - if (ldata & 0x10) { - mat->feature_mask |= BMAT_FEATURE_VCOLLIGHT; - } - if (ldata & 0x80) { - mat->feature_mask |= BMAT_FEATURE_VCOLPAINT; - } - if (ldata & (1024 | 512 | 256)) { /* not sure about this, it's strange. */ - mat->feature_mask |= BMAT_FEATURE_TEXFACE; - } - - for (i=0; i<BLENDER_MAX_TEX_LAYERS; ++i) { - BlendBlock * texl_block; - if (blend_object_structure_getfield(bf, &obj, *matobj, "mtex") && - blend_object_array_getdata(bf, &texl_block, obj, 0,i) && texl_block) { - BlendObject tlobj = blend_block_get_object(bf, texl_block, 0); - mat->tex_layer[i] = blend_alloc_texlayer(); - /*fprintf(stderr, "GETTING LAYER AT POS %d\n", i);*/ - blend_acquire_texlayer_from_obj(bf, &tlobj, mat->tex_layer[i]); - } else { - /*fprintf(stderr, "NOTHING FOUND AT POS %d\n", i);*/ - } - } -} - - -bMaterial * -blend_alloc_material(void) { - return (bMaterial *) malloc(sizeof(bMaterial)); -} - -int -blend_object_getdata(BlendFile* blend_file, - void* dest, BlendObject obj) -{ - int dim1, dim2; - - if (name_is_array(blend_file->names[obj.name], &dim1, &dim2)) { - if (dim1 != 1 || dim2 != 1) { - printf("Tried to fetch a whole array.\n"); - return 0; - } - } - - return (blend_object_array_getdata(blend_file, dest, obj, 0, 0)); -} - -bMesh* blend_alloc_mesh(void) { - return (bMesh*)malloc(sizeof(bMesh)); -} - -static void bMatIdentity(bMatrix mat) { - int i,j; - for (i=0; i<4; ++i) { - for (j=0; j<4; ++j) { - mat[i][j] = 0.0f; - } - mat[i][i] = 1.0f; - } -} - - - -void -blend_init_obj(bObj *obj) { - obj->type = BOBJ_TYPE_UNKNOWN; - obj->name = NULL; - bMatIdentity(obj->transform); - bMatIdentity(obj->parentimat); - obj->location[0] = - obj->location[1] = - obj->location[2] = 0.0f; - obj->scaling[0] = - obj->scaling[1] = - obj->scaling[2] = 1.0f; - obj->rotphr[0] = - obj->rotphr[1] = - obj->rotphr[2] = 0.0f; - obj->data.dummy = NULL; - obj->transflags = 0; -} - - -void /* MTex */ -blend_acquire_texlayer_from_obj(BlendFile *bf, BlendObject *tlobj, - bTexLayer *tl) -{ - BlendObject obj; - BlendBlock * tex_block; - short sdata = 12345; - - blend_init_texlayer(tl); - - if (!(blend_object_structure_getfield(bf, &obj, *tlobj, - "mapto") && - blend_object_getdata(bf, &sdata, obj))) { - abort(); - } - if (sdata & 0x01) { - tl->affects_mask |= BTEX_AFFECT_COLOUR; - } - if (sdata & 0x40) { - tl->affects_mask |= BTEX_AFFECT_EMIT; - } - if (sdata & 0x80) { - tl->affects_mask |= BTEX_AFFECT_ALPHA; - } - /* note: mapto not fully decoded. */ - - if (!(blend_object_structure_getfield(bf, &obj, *tlobj, - "texflag") && - blend_object_getdata(bf, &sdata, obj))) { - abort(); - } - if (sdata & 0x02) { - tl->affects_mask |= BTEX_AFFECT_STENCIL; - } - - if (!(blend_object_structure_getfield(bf, &obj, *tlobj, - "texco") && - blend_object_getdata(bf, &sdata, obj))) { - abort(); - } - switch (sdata) { - case 1: - case 2: - tl->coords_type = BTEX_COORDS_REFLECT; - break; - case 16: - tl->coords_type = BTEX_COORDS_UV; - break; - default: - /* I haven't seen this happen, but it probably does... */ - tl->coords_type = BTEX_COORDS_NONE; - break; - } - - if (!(blend_object_structure_getfield(bf, &obj, *tlobj, - "blendtype") && - blend_object_getdata(bf, &sdata, obj))) { - abort(); - } - tl->blend_mode = sdata; /* not decoded yet :( */ - - if (blend_object_structure_getfield(bf, &obj, *tlobj, "tex") && - blend_object_getdata(bf, &tex_block, obj) && tex_block) { - BlendObject tobj = blend_block_get_object(bf, tex_block, 0); - BlendBlock * im_block; - BlendObject obj; - - if (!(blend_object_structure_getfield(bf, &obj, tobj, "extend") && - blend_object_getdata(bf, &sdata, obj))) { - abort(); - } - tl->is_st_clamped = !(sdata & 2 /*'repeat'*/); - /*fprintf(stderr, "CLAMP=%d (was %d)\n", tl->is_st_clamped, sdata);*/ - if (!(blend_object_structure_getfield(bf, &obj, tobj, "xrepeat") && - blend_object_getdata(bf, &sdata, obj))) { - tl->xrepeat = 1; - } else { - tl->xrepeat = sdata; - } - if (!(blend_object_structure_getfield(bf, &obj, tobj, "yrepeat") && - blend_object_getdata(bf, &sdata, obj))) { - tl->yrepeat = 1; - } else { - tl->yrepeat = sdata; - } - if (!(blend_object_structure_getfield(bf, &obj, tobj, "flag") && - blend_object_getdata(bf, &sdata, obj))) { - abort(); - } else { - tl->flags = sdata; - } - if (!(blend_object_structure_getfield(bf, &obj, tobj, "imaflag") && - blend_object_getdata(bf, &sdata, obj))) { - abort(); - } else { - if (sdata & 0x0001) { - tl->flags |= BIMG_FLAG_INTERPOLATE; - } - if (sdata & 0x0004) { - tl->flags |= BIMG_FLAG_MIPMAP; - } - if (sdata & 0x0100) { - tl->flags |= BIMG_FLAG_ANTIALIAS; - } - } - if (!(blend_object_structure_getfield(bf, &obj, tobj, "type") && - blend_object_getdata(bf, &sdata, obj))) { - abort(); - } else { - tl->Ntype = sdata; - } - if (blend_object_structure_getfield(bf, &obj, tobj, "ima") && - blend_object_getdata(bf, &im_block, obj) && im_block) { - BlendObject imobj = blend_block_get_object(bf, im_block, 0); -#define BF_IMAGE_FILENAME_MAXSIZE 160 - tl->filename = (char*)malloc(BF_IMAGE_FILENAME_MAXSIZE); - if (!(blend_object_structure_getfield(bf, &obj, imobj, "name") && - blend_object_getstring(bf, obj, - tl->filename, BF_IMAGE_FILENAME_MAXSIZE))) { - abort(); - } - } - } else { - abort(); - } -} - - - -bTexLayer * -blend_alloc_texlayer(void) { - return (bTexLayer *)malloc(sizeof(bTexLayer)); -} - -void -blend_init_material(bMaterial *mat) { - int i; - for (i=0; i<BLENDER_MAX_TEX_LAYERS; ++i) { - mat->tex_layer[i] = NULL; - } - mat->feature_mask = 0; - for (i=0; i<4; ++i) { - mat->colour_rgba[i] = 1.0f; - } - mat->emit = 0.0f; -} - -void -blend_init_texlayer(bTexLayer *tl) { - tl->filename = NULL; - tl->affects_mask = 0; - tl->blend_mode = BTEX_BLEND_NORMAL; - tl->coords_type = BTEX_COORDS_NONE; - tl->is_st_clamped = 0; - tl->flags = 0; - tl->Nflags = tl->Ntype = 0; - tl->xrepeat = tl->yrepeat = 1; -} - - -void -blend_dump_typedefs(BlendFile* bf) -{ - int i; - - /* dump out display of types and their sizes */ - for (i=0; i<bf->types_count; ++i) { - /* if (!bf->types[i].is_struct)*/ - { - printf("%3d: sizeof(%s%s)=%d", - i, - bf->types[i].is_struct ? "struct " : "atomic ", - bf->types[i].name, bf->types[i].m_size); - if (bf->types[i].is_struct) { - int j; - printf(", %d fields: { ", bf->types[i].fieldtypes_count); - for (j=0; j<bf->types[i].fieldtypes_count; ++j) { - printf("%s %s", - bf->types[bf->types[i].fieldtypes[j]].name, - bf->names[bf->types[i].fieldnames[j]]); - if (j == bf->types[i].fieldtypes_count-1) { - printf(";}"); - } else { - printf("; "); - } - } - } - printf("\n\n"); - - } - } -} - - -typedef struct { - BlendObject found; - int success; - const char* IDname; - int just_print_it; -} IDFinderData; - - -static BLENDBLOCKCALLBACK_RETURN -block_ID_finder(BLENDBLOCKCALLBACK_ARGS) { - int entry_count = blend_block_get_entry_count(blend_file, block); - int want_more = 1; - IDFinderData *ifd = (IDFinderData*)userdata; - int i; - - if (ifd->IDname) { /* don't freak out, but hmm, do we do the right thing? */ - const int strl = strlen(ifd->IDname); - char *obj_string = (char *)malloc(3+ strl); - - for (i=0; i<entry_count; ++i) { - BlendObject obj = blend_block_get_object(blend_file, block, i); - blend_object_get_IDname(blend_file, obj, - obj_string, strl+1); - - if (strcmp(obj_string, ifd->IDname) == 0) { - ifd->found = obj; - ifd->success = 1; - want_more = 0; - goto done; - } else { - /* next entry please. */ - } - } - -done:; - free(obj_string); - } - - return want_more; -} - - - -void -blend_dump_blocks(BlendFile* bf) -{ - int i; - IDFinderData ifd; - - ifd.success = 0; - ifd.IDname = NULL; - ifd.just_print_it = 1; - - for (i=0; i<bf->m_blocks.size(); ++i) { - BlendBlock* bb = bf->m_blocks[i]; - printf("tag='%s'\tptr=%p\ttype=%s\t[%4d]", - bb->tag, /*bb->blender_pointer,*/ bb->blender_pointer1, - bf->types[bb->type_index].name, - bb->m_array_entries_.size()); - block_ID_finder(bb, bf, &ifd); - printf("\n"); - } -} \ No newline at end of file diff --git a/gamekit/BulletBlendReader.h b/gamekit/BulletBlendReader.h deleted file mode 100644 index e2f14cef2..000000000 --- a/gamekit/BulletBlendReader.h +++ /dev/null @@ -1,289 +0,0 @@ -/* -GameKit -Copyright (c) 2009 Erwin Coumans http://gamekit.googlecode.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef BULLET_BLEND_READER_H -#define BULLET_BLEND_READER_H - -#include <stdio.h> -#include "readblend.h" -#include "LinearMath/btAlignedObjectArray.h" -#include "LinearMath/btHashMap.h" -class btCollisionObject; - - - -typedef struct _BlendField BlendField; -struct _BlendField { - char* field_bytes; - int field_bytes_count; - - /* the offset into field_bytes at which each field of a - structure begins. this is so we can keep the data aligned - correctly for various architectures. a non-structure type - is equivalent to a structure with a single field. - */ - btAlignedObjectArray<int> m_field_offsets; - int field_offsets_count; -}; -struct BlendBlock { - char tag[5]; - uint32_t blender_pointer1; - /*void* fixed_pointer;*/ - - int type_index; - /* a block is simply an array of its type as defined by type_index. - array_entries is an array of pointers to each entry in the block's - array. - */ - btAlignedObjectArray<BlendField*> m_array_entries_; - - void* customData; /* for Link blocks, with custom data such as .jpg pictures etc */ - int customDataSize; -}; - - - - -/* the types extracted from the Blender file */ -typedef struct _BlendType BlendType; -struct _BlendType { - char* name; - int m_size; - - int is_struct; - - /* if is_struct... this defines the types of each of the structure fields */ - int fieldtypes_count; - int* fieldtypes; /* type indices */ - int fieldnames_count; - int* fieldnames; /* name indices */ -}; - - - - - - -/* the opaque BlendFile structure */ -struct BlendFile{ - BlendType* types; - int types_count; - - char* *names; - int names_count; - - int* strc_indices; - int strc_indices_count; - - btAlignedObjectArray<BlendBlock*> m_blocks; - //int blocks_count; - - int name_undef; /* index of the name we add specially for top blocks */ - -}; - - -struct btDataValue -{ - int m_type; - int m_name; - - btDataValue() - :m_ptr(0) - { - - } - btAlignedObjectArray<btDataValue> m_valueArray; - union - { - char m_cValue; - unsigned char m_ucValue; - int m_iValue; - unsigned int m_uiValue; - float m_fValue; - void* m_ptr; - }; -}; - - - - -struct btDataObject -{ - btHashMap<btHashString,btDataValue*> m_dataMap; - unsigned int m_blenderPointer; - void* m_userPointer; - - btDataObject() - :m_blenderPointer(0), - m_userPointer(0) - { - } - - int getIntValue(const char* fieldName, int defaultValue=0) - { - btDataValue** valPtr = m_dataMap[fieldName]; - if (valPtr && *valPtr) - { - return (*valPtr)->m_iValue; - } - return defaultValue; - } - - float getFloatValue(const char* fieldName, float defaultValue=0.) - { - btDataValue** valPtr = m_dataMap[fieldName]; - if (valPtr && *valPtr) - { - return (*valPtr)->m_fValue; - } - return defaultValue; - } -}; - - -struct btTypedLogicBrick -{ - int m_type; - btDataObject* m_ownerObject; - - btTypedLogicBrick(btDataObject* ownerObject, int type) - :m_type(type), - m_ownerObject(ownerObject) - { - } - -}; - -//quick prototyping of some logic brick converting and processing system -struct btSensor : public btTypedLogicBrick -{ - btSensor(btDataObject* ownerObject,int type) - :btTypedLogicBrick(ownerObject,type) - { - } - -}; - -struct btController : public btTypedLogicBrick -{ - btController(btDataObject* ownerObject,int type) - :btTypedLogicBrick(ownerObject,type) - { - } -}; - -struct btActuator : public btTypedLogicBrick -{ - btActuator(btDataObject* ownerObject,int type) - :btTypedLogicBrick(ownerObject,type) - { - } -}; - -struct btLogicManager -{ - btAlignedObjectArray<btSensor*> m_sensors; - btAlignedObjectArray<btController*> m_controllers; - btAlignedObjectArray<btActuator*> m_actuators; - - void processLogicBricks(btScalar deltaTime) - { - int i; - //process all sensors - - for (i=0;i<m_sensors.size();i++) - { -// printf("processing a sensor of type %d\n",m_sensors[i]->m_type); - } - - //process all controllers - for (i=0;i<m_controllers.size();i++) - { -// printf("processing a controller of type %d\n",m_controllers[i]->m_type); - } - - //process all actuators - for (i=0;i<m_actuators.size();i++) - { -// printf("processing an actuator of type %d\n",m_actuators[i]->m_type); - } - - } - -}; - - -char* btReadBuffer(FILE* fp, int* fileSize=0); - - -class BulletBlendReader -{ - - struct BlendFile* m_bf; - -protected: - - class btDynamicsWorld* m_destinationWorld; - - btHashMap<btHashInt,btDataObject*> m_dataObjects; - - - ///m_visibleGameObjects is a subset of m_dataObjects of only the visible game objects, handy for iterating, adding logic bricks/physics constraints etc - btAlignedObjectArray<btDataObject*> m_visibleGameObjects; - - void read_type(char* file, BlendFile* bf, unsigned long section_type, BlendField & rtn); - int readData(char* file, BlendFile* bf); - -public: - - BulletBlendReader(class btDynamicsWorld* destinationWorld); - - virtual ~BulletBlendReader(); - - ///if you already have a file pointer, call readFile - int readFile( FILE* file, int verboseDumpAllTypes = false); - - ///if you only have a fileName, call openFile - //int openFile(const char* fileName); - - bool needsExtraction(const char* type_name); - - btDataObject* extractSingleObject(BlendObject*, bool verboseDumpAllBlocks); - - void convertAllObjects(int verboseDumpAllBlocks=false); - - ///for each Blender Object, this method will be called to convert/retrieve data from the bObj - virtual btCollisionObject* convertSingleObject(struct _bObj* object); - - virtual void convertSingleMesh(struct _bMesh* mesh); - - virtual void convertConstraints(); - - virtual void convertLogicBricks() = 0; - - virtual void createParentChildHierarchy()=0; - - //after each object is converter, including collision object, create a graphics object (and bind them) - virtual void* createGraphicsObject(_bObj* tmpObject, class btCollisionObject* bulletObject)=0; - - virtual void addCamera(_bObj* tmpObject)=0; - - virtual void addLight(_bObj* tmpObject)=0; - -}; - - -#endif //BULLET_BLEND_READER_H \ No newline at end of file diff --git a/gamekit/BulletBlendReaderNew.cpp b/gamekit/BulletBlendReaderNew.cpp deleted file mode 100644 index 51adba5d0..000000000 --- a/gamekit/BulletBlendReaderNew.cpp +++ /dev/null @@ -1,686 +0,0 @@ -/* -GameKit -Copyright (c) 2009 Erwin Coumans http://gamekit.googlecode.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "IrrBlendNew.h" -#include "BulletIrrlichtUtils.h" -#include "btBulletDynamicsCommon.h" -#include "autogenerated/blender.h" -#include "bMain.h" -#include "bBlenderFile.h" -#include "btBulletFile.h" -#include "LinearMath/btserializer.h" - -#include "BulletCollision/Gimpact/btGImpactShape.h" -#include "BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h" - -#include "bDNA.h" - -extern unsigned char BulletDNAstr[]; -extern int BulletDNAlen; - - -BulletBlendReaderNew::BulletBlendReaderNew(class btDynamicsWorld* destinationWorld) -:m_blendFile(0), -m_destinationWorld(destinationWorld) -{ -} - -BulletBlendReaderNew::~BulletBlendReaderNew() -{ - if (m_blendFile) - { - delete m_blendFile; - } -} - - ///if you already have a file pointer, call readFile -int BulletBlendReaderNew::readFile(char* memoryBuffer, int fileLen, int verboseDumpAllTypes ) -{ - if (m_blendFile) - { - delete m_blendFile; - } - - m_blendFile = new bParse::bBlenderFile(memoryBuffer, fileLen); - bool ok = (m_blendFile->getFlags()& bParse::FD_OK)!=0; - if (ok) - m_blendFile->parse(verboseDumpAllTypes); - - if (verboseDumpAllTypes) - { - m_blendFile->dumpChunks(m_blendFile->getFileDNA()); - } - return ok; -} - -int BulletBlendReaderNew::writeFile(const char* fileName) -{ - bool replaceOldPointers = true; - return m_blendFile->write(fileName); -} - - - -void BulletBlendReaderNew::convertAllObjects(int verboseDumpAllBlocks) -{ - btAssert(m_blendFile); - - bParse::bMain* mainPtr = m_blendFile->getMain(); - - // bMain contains sorted void* pointers. - - // Iterate through the scene. - bParse::bListBasePtr *sceneBase = mainPtr->getScene(); - int numScenes = sceneBase->size(); - printf("File contains %i scene(s)\n", numScenes); - - bParse::bListBasePtr* objBase = mainPtr->getObject(); - int numObj = objBase->size(); - printf("File contains %i object(s)\n", numObj); - - bParse::bListBasePtr* camBase = mainPtr->getCamera(); - int numCam = camBase->size(); - printf("File contains %i camera(s)\n", numCam); - - - Blender::FileGlobal* glob = (Blender::FileGlobal*)m_blendFile->getFileGlobal(); - -//#define CHECK_ACTIONS -#ifdef CHECK_ACTIONS - bParse::bListBasePtr *ptr = mainPtr->getAction(); - for (size_t i=0; i<ptr->size(); i++) - { - - Blender::bAction* action = (Blender::bAction*)ptr->at(i); - Blender::bActionChannel *achan= static_cast<Blender::bActionChannel*>(action->chanbase.first); - while (achan) - { - printf(achan->name); - achan= achan->next; - } - } -#endif//CHECK_ACTIONS - - -//#define EXTRACT_ALL_SCENES 1 -#ifdef EXTRACT_ALL_SCENES - for (int sce = 0; sce<numScenes; sce++) - { - // Get the scene structure. - Blender::Scene *scene = (Blender::Scene*) sceneBase->at(sce); -#else - { - Blender::Scene* scene = (Blender::Scene*) glob->curscene; -#endif - - if (!scene) - { - printf("Warning: no default scene, perhaps an old Blender version? Taking first scene.\n"); - if (numScenes) - { - scene = (Blender::Scene*) sceneBase->at(0); - } - } - // Loop all objects in the scene. - Blender::Base *base = scene ? (Blender::Base*)scene->base.first : 0; - - if (!base) - { - printf("Warning: no scene\n"); - } - - - while (base) - { - if (base->object) - { - Blender::Object *ob = base->object; - ///only process objects in active scene layer - if (ob->lay & scene->lay) - { - if (verboseDumpAllBlocks) - printf("Current object : %s\n", ob->id.name); - - switch (ob->type) - { - //OB_MESH - case 1: - { - if (verboseDumpAllBlocks) - { - printf("\tObject is a mesh\n"); - } - - if (ob->data) - { - Blender::Mesh *me = (Blender::Mesh*)ob->data; - - - if (verboseDumpAllBlocks) - { - printf("\t\tFound mesh data for %s\n", me->id.name); - printf("\t\tTotal verts %i, faces %i\n", me->totvert, me->totface); - } - - btCollisionObject* bulletObject = createBulletObject(ob); - - } - }break; - - //OB_LAMP - case 10: - { - - if (verboseDumpAllBlocks) - { - printf ("\tObject is a lamp\n"); - } - - if (ob->data) - { - Blender::Lamp *la = (Blender::Lamp*)ob->data; - if (verboseDumpAllBlocks) - { - printf("\t\tFound lamp data for %s\n", la->id.name); - printf("\t\tRGB, %f,%f,%f\n", la->r, la->g, la->b); - } - - addLight(ob); - } - - }break; - //OB_CAMERA - case 11: - { - if (verboseDumpAllBlocks) - { - printf ("\tObject is a camera\n"); - } - - if (ob->data) - { - Blender::Camera *cam = (Blender::Camera*)ob->data; - if (verboseDumpAllBlocks) - { - printf("\t\tFound camera data for %s\n", cam->id.name); - printf("\t\t(lens, near, far) %f,%f,%f\n", cam->lens, cam->clipsta, cam->clipend); - } - - addCamera(ob); - } - }break; - } - } - } - base = (Blender::Base*)base->next; - } - } - - createParentChildHierarchy(); - - convertConstraints(); - - if (verboseDumpAllBlocks) - { - m_blendFile->dumpChunks(m_blendFile->getFileDNA()); - } - - -//#define TEST_CREATE_BULLET_FILE -#ifdef TEST_CREATE_BULLET_FILE - - - btDefaultSerializer* serializer = new btDefaultSerializer(1024*1024*5); - serializer->initDNA((const char*)BulletDNAstr,BulletDNAlen); - - btCollisionObject* colObj = new btCollisionObject(); - btBoxShape* boxShape = new btBoxShape(btVector3(1,2,3)); - colObj->setCollisionShape(boxShape); - - btRigidBody* body = new btRigidBody(1.f,0,boxShape); - //try to create a Bullet file... - - - { - int len = colObj->calculateSerializeBufferSize(); - btChunk* chunk = serializer->allocate(len,1); - const char* structType = colObj->serialize(chunk->m_oldPtr); - chunk->m_dna_nr = serializer->getReverseType(structType); - chunk->m_chunkCode = BT_COLLISIONOBJECT_CODE; - chunk->m_oldPtr = colObj; - } - - { - int len = boxShape->calculateSerializeBufferSize(); - btChunk* chunk = serializer->allocate(len,1); - const char* structType = boxShape->serialize(chunk->m_oldPtr); - chunk->m_dna_nr = serializer->getReverseType(structType); - chunk->m_chunkCode = BT_BOXSHAPE_CODE; - chunk->m_oldPtr = boxShape; - } - - { - int len = body->calculateSerializeBufferSize(); - btChunk* chunk = serializer->allocate(len,1); - const char* structType = body->serialize(chunk->m_oldPtr); - chunk->m_dna_nr = serializer->getReverseType(structType); - chunk->m_chunkCode = BT_COLLISIONOBJECT_CODE; - chunk->m_oldPtr = body; - } - - - - //bulletFile->resolvePointers(); - //bulletFile->updateOldPointers(); - - bool fixupPointers = true; - - serializer->writeDNA(); - - //bulletFile->write("testFile.bullet", fixupPointers ); - - FILE* f2 = fopen("testFile.bullet","wb"); - fwrite(serializer->m_buffer,serializer->m_bufferPointer,1,f2); - fclose(f2); - - - //serializer->write("testFile.bullet"); - - //int bufSize = boxShape->calculateSerializeBufferSize(); - //boxShape->serialize(buf); - - - bParse::btBulletFile* bulletFile2 = new bParse::btBulletFile("testFile.bullet"); - bool ok = (bulletFile2->getFlags()& bParse::FD_OK)!=0; - bool verboseDumpAllTypes = true; - if (ok) - bulletFile2->parse(verboseDumpAllTypes); - - if (verboseDumpAllTypes) - { - bulletFile2->dumpChunks(bulletFile2->getFileDNA()); - } -#endif - -} - - - -btCollisionObject* BulletBlendReaderNew::createBulletObject(Blender::Object* object) -{ - Blender::Mesh *me = (Blender::Mesh*)object->data; - - //let's try to create some static collision shapes from the triangle meshes - if (me && me->mface) - { - btTriangleMesh* meshInterface = new btTriangleMesh(); - - btVector3 minVert(1e30f,1e3f,1e30f); - btVector3 maxVert(-1e30f,-1e30f,-1e30f); - - for (int t=0;t<me->totface;t++) - { - - - int v[4] = {me->mface[t].v1,me->mface[t].v2,me->mface[t].v3,me->mface[t].v4}; - - btVector3 vtx0(me->mvert[v[0]].co.x,me->mvert[v[0]].co.y,me->mvert[v[0]].co.z); - minVert.setMin(vtx0); maxVert.setMax(vtx0); - btVector3 vtx1(me->mvert[v[1]].co.x,me->mvert[v[1]].co.y,me->mvert[v[1]].co.z); - minVert.setMin(vtx1); maxVert.setMax(vtx1); - btVector3 vtx2(me->mvert[v[2]].co.x,me->mvert[v[2]].co.y,me->mvert[v[2]].co.z); - minVert.setMin(vtx2); maxVert.setMax(vtx2); - meshInterface ->addTriangle(vtx0,vtx1,vtx2); - - if (v[3]) - { - btVector3 vtx3(me->mvert[v[3]].co.x,me->mvert[v[3]].co.y,me->mvert[v[3]].co.z); - minVert.setMin(vtx3); maxVert.setMax(vtx3); - meshInterface ->addTriangle(vtx0,vtx3,vtx2); - } - } - if (!meshInterface->getNumTriangles()) - return 0; - -/* boundtype */ -#define OB_BOUND_BOX 0 -#define OB_BOUND_SPHERE 1 -#define OB_BOUND_CYLINDER 2 -#define OB_BOUND_CONE 3 -#define OB_BOUND_POLYH 4 -#define OB_BOUND_POLYT 5 -#define OB_BOUND_DYN_MESH 6 - -/* ob->gameflag */ -#define OB_DYNAMIC 1 -//#define OB_CHILD 2 -//#define OB_ACTOR 4 -//#define OB_INERTIA_LOCK_X 8 -//#define OB_INERTIA_LOCK_Y 16 -//#define OB_INERTIA_LOCK_Z 32 -//#define OB_DO_FH 64 -//#define OB_ROT_FH 128 -//#define OB_ANISOTROPIC_FRICTION 256 -//#define OB_GHOST 512 -#define OB_RIGID_BODY 1024 -//#define OB_BOUNDS 2048 - -//#define OB_COLLISION_RESPONSE 4096//?? -//#define OB_COLLISION 65536 -//#define OB_SOFT_BODY 0x20000 - - btVector3 localPos = (minVert+maxVert)*0.5f; - btVector3 localSize= (maxVert-minVert)*0.5f; - - - btTransform worldTrans; - worldTrans.setIdentity(); - worldTrans.setOrigin(btVector3(object->loc.x,object->loc.y,object->loc.z)); - // blenderobject->loc[0]+blenderobject->dloc[0]//?? - - worldTrans.getBasis().setEulerZYX(object->rot.x,object->rot.y,object->rot.z); - btVector3 scale(object->size.x,object->size.y,object->size.z); - - if ( (object->gameflag & OB_RIGID_BODY) || (object->gameflag & OB_DYNAMIC)) - { - //m_destinationWorld->addRigidBody( - btCollisionShape* colShape = 0; - - switch (object->boundtype) - { - case OB_BOUND_SPHERE: - { - btScalar radius = localSize[localSize.maxAxis()]; - colShape = new btSphereShape(radius); - break; - }; - case OB_BOUND_BOX: - { - colShape = new btBoxShape(localSize); - break; - } - case OB_BOUND_CYLINDER: - { - colShape = new btCylinderShapeZ(localSize); - break; - } - case OB_BOUND_CONE: - { - btScalar radius = btMax(localSize[0], localSize[1]); - btScalar height = 2.f*localSize[2]; - colShape = new btConeShapeZ(radius,height); - break; - } - case OB_BOUND_POLYT: - - { - //better to approximate it, using btShapeHull - colShape = new btConvexTriangleMeshShape(meshInterface); - break; - } - case OB_BOUND_POLYH: - case OB_BOUND_DYN_MESH: - { - btGImpactMeshShape* gimpact = new btGImpactMeshShape(meshInterface); - gimpact->postUpdate(); - colShape = gimpact; - break; - } - - default: - { - - } - }; - - if (colShape) - { - colShape->setLocalScaling(scale); - btVector3 inertia; - colShape->calculateLocalInertia(object->mass,inertia); - btRigidBody* body = new btRigidBody(object->mass,0,colShape,inertia); - if (!(object->gameflag & OB_RIGID_BODY)) - { - body->setAngularFactor(0.f); - } - body->setWorldTransform(worldTrans); - m_destinationWorld->addRigidBody(body); - //body->setActivationState(DISABLE_DEACTIVATION); - - void* gfxObject = createGraphicsObject(object,body); - body->setUserPointer(gfxObject); - - return body; - } - - } else - { - - btCollisionShape* colShape =0; - if (meshInterface->getNumTriangles()>0) - { - btBvhTriangleMeshShape* childShape = new btBvhTriangleMeshShape(meshInterface,true); - - if (scale[0]!=1. || scale[1]!=1. || scale[2]!=1.) - { - colShape = new btScaledBvhTriangleMeshShape(childShape,scale); - } else - { - colShape = childShape; - } - - btVector3 inertia(0,0,0); - btRigidBody* colObj = new btRigidBody(0.f,0,colShape,inertia); - colObj->setWorldTransform(worldTrans); - colObj->setCollisionShape(colShape); - - m_destinationWorld->addRigidBody(colObj); - - void* gfxObject = createGraphicsObject(object,colObj); - colObj->setUserPointer(gfxObject); - - return colObj; - - } - - } - } - - return 0; -} - - - - -#define CONSTRAINT_TYPE_RIGIDBODYJOINT 17 -#define CONSTRAINT_RB_BALL 1 -#define CONSTRAINT_RB_HINGE 2 -#define CONSTRAINT_RB_CONETWIST 4 -#define CONSTRAINT_RB_VEHICLE 11 -#define CONSTRAINT_RB_GENERIC6DOF 12 - -///flags -#define CONSTRAINT_DISABLE_LINKED_COLLISION 0x80 - -///slow search, add acceleration structure if necessary -btCollisionObject* BulletBlendReaderNew::findCollisionObject(Blender::Object* ob) -{ - int i; - for (i=0;i<m_destinationWorld->getNumCollisionObjects();i++) - { - btCollisionObject* colObj = m_destinationWorld->getCollisionObjectArray()[i]; - IrrlichtMeshContainer* imc = (IrrlichtMeshContainer*)colObj->getUserPointer(); - if (!imc) - continue; - Blender::Object* obj2 = (Blender::Object*)imc->m_userPointer; - if (ob == obj2) - return colObj; - } - return 0; -} - -void BulletBlendReaderNew::convertConstraints() -{ - - int i; - - for (i=0;i<this->m_destinationWorld->getNumCollisionObjects();i++) - { - btCollisionObject* colObj = m_destinationWorld->getCollisionObjectArray()[i]; - IrrlichtMeshContainer* imc = (IrrlichtMeshContainer*)colObj->getUserPointer(); - if (!imc) - continue; - Blender::Object* obj = (Blender::Object*)imc->m_userPointer; - if (!obj) - continue; - - Blender::bConstraint* constraint = (Blender::bConstraint*)obj->constraints.first; - - while (constraint) - { - if (constraint->type == CONSTRAINT_TYPE_RIGIDBODYJOINT) - { - Blender::bRigidBodyJointConstraint* rbConstraint = (Blender::bRigidBodyJointConstraint*)constraint->data; - btVector3 pivotInA(rbConstraint->pivX,rbConstraint->pivY,rbConstraint->pivZ); - btVector3 pivotInB(0,0,0); - btRigidBody* rbA = btRigidBody::upcast(colObj); - btRigidBody* rbB = 0; - int flag = rbConstraint->flag; - - rbConstraint->tar; - - btCollisionObject* colObjB = (btCollisionObject*)findCollisionObject(rbConstraint->tar); - if (colObjB) - { - rbB = btRigidBody::upcast(colObjB); - pivotInB = rbB->getCenterOfMassTransform().inverse()(rbA->getCenterOfMassTransform()(pivotInA)); - } - bool disableCollisionBetweenLinkedBodies = (flag & CONSTRAINT_DISABLE_LINKED_COLLISION) != 0; - - float radsPerDeg = 6.283185307179586232f / 360.f; - - //localConstraintFrameBasis - btMatrix3x3 localCFrame; - localCFrame.setEulerZYX(radsPerDeg*rbConstraint->axX,radsPerDeg*rbConstraint->axY,radsPerDeg*rbConstraint->axZ); - btVector3 axisInA = localCFrame.getColumn(0); - btVector3 axis1 = localCFrame.getColumn(1); - btVector3 axis2 = localCFrame.getColumn(2); - bool angularOnly = false; - - /* important: these defines need to match up with PHY_DynamicTypes headerfile */ - switch (rbConstraint->type) - { - - case CONSTRAINT_RB_BALL: - { - btPoint2PointConstraint* p2p = 0; - - if (rbB) - { - p2p = new btPoint2PointConstraint(*rbA,*rbB,pivotInA,pivotInB); - } else - { - p2p = new btPoint2PointConstraint(*rbA,pivotInA); - } - - m_destinationWorld->addConstraint(p2p); - - break; - } - case CONSTRAINT_RB_HINGE: - { - btHingeConstraint* hinge = 0; - if (rbB) - { - btVector3 axisInB = rbB ? - (rbB->getCenterOfMassTransform().getBasis().inverse()*(rbA->getCenterOfMassTransform().getBasis() * axisInA)) : - rbA->getCenterOfMassTransform().getBasis() * axisInA; - - hinge = new btHingeConstraint(*rbA,*rbB,pivotInA,pivotInB,axisInA,axisInB); - - - } else - { - hinge = new btHingeConstraint(*rbA, pivotInA,axisInA); - - } - hinge->setAngularOnly(angularOnly); - - //m_constraints.push_back(hinge); - m_destinationWorld->addConstraint(hinge,disableCollisionBetweenLinkedBodies); - //hinge->setUserConstraintId(gConstraintUid++); - //hinge->setUserConstraintType(type); - break; - } - case CONSTRAINT_RB_CONETWIST: - { - break; - } - case CONSTRAINT_RB_VEHICLE: - { - break; - } - case CONSTRAINT_RB_GENERIC6DOF: - { - - btTransform frameInA; - btTransform frameInB; - if (axis1.length() == 0.0) - { - btPlaneSpace1( axisInA, axis1, axis2 ); - } - frameInA.getBasis().setValue( axisInA.x(), axis1.x(), axis2.x(), - axisInA.y(), axis1.y(), axis2.y(), - axisInA.z(), axis1.z(), axis2.z() ); - frameInA.setOrigin( pivotInA ); - btTransform inv = rbB->getCenterOfMassTransform().inverse(); - btTransform globalFrameA = rbA->getCenterOfMassTransform() * frameInA; - frameInB = inv * globalFrameA; - bool useReferenceFrameA = true; - btGeneric6DofSpringConstraint* genericConstraint = new btGeneric6DofSpringConstraint(*rbA,*rbB, frameInA,frameInB,useReferenceFrameA); - m_destinationWorld->addConstraint(genericConstraint,disableCollisionBetweenLinkedBodies); - - //if it is a generic 6DOF constraint, set all the limits accordingly - int dof; - int dofbit=1; - for (dof=0;dof<6;dof++) - { - if (flag & dofbit) - { - ///this access is a bloated, will probably make special cases for common arrays - btScalar minLimit = rbConstraint->minLimit[dof]; - btScalar maxLimit = rbConstraint->maxLimit[dof]; - genericConstraint->setLimit(dof,minLimit,maxLimit); - } else - { - //minLimit > maxLimit means free(disabled limit) for this degree of freedom - genericConstraint->setLimit(dof,1,-1); - } - dofbit<<=1; - } - break; - } - - default: - { - printf("unsupported rigid body constraint type\n"); - } - } - } - constraint = constraint->next; - } - } -} - diff --git a/gamekit/BulletBlendReaderNew.h b/gamekit/BulletBlendReaderNew.h deleted file mode 100644 index dfc75d725..000000000 --- a/gamekit/BulletBlendReaderNew.h +++ /dev/null @@ -1,78 +0,0 @@ -/* -GameKit -Copyright (c) 2009 Erwin Coumans http://gamekit.googlecode.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef __BULLET_BLEND_NEW_H -#define __BULLET_BLEND_NEW_H - -namespace Blender -{ - class Object; -}; -namespace bParse -{ - class bBlenderFile; -}; - -class btCollisionObject; - - -///BulletBlendReaderNew is based on Charlie's 2006 .blend reader, supporting reading of 32bit/64bit, little and big endian .blend files -class BulletBlendReaderNew -{ - -protected: - - bParse::bBlenderFile* m_blendFile; - - class btDynamicsWorld* m_destinationWorld; - -// btHashMap<btHashInt,btDataObject*> m_dataObjects; - - ///m_visibleGameObjects is a subset of m_dataObjects of only the visible game objects, handy for iterating, adding logic bricks/physics constraints etc -// btAlignedObjectArray<btDataObject*> m_visibleGameObjects; - - btCollisionObject* createBulletObject(Blender::Object* object); - - btCollisionObject* findCollisionObject(Blender::Object* ob); - -public: - - BulletBlendReaderNew(class btDynamicsWorld* destinationWorld); - - virtual ~BulletBlendReaderNew(); - - ///if you already have a file pointer, call readFile - int readFile(char* memoryBuffer, int len, int verboseDumpAllTypes = false); - - int writeFile(const char* fileName); - - void convertAllObjects(int verboseDumpAllBlocks=false); - - virtual void convertConstraints(); - - virtual void convertLogicBricks() = 0; - - virtual void createParentChildHierarchy()=0; - - //after each object is converter, including collision object, create a graphics object (and bind them) - virtual void* createGraphicsObject(Blender::Object* tmpObject, class btCollisionObject* bulletObject)=0; - - virtual void addCamera(Blender::Object* tmpObject)=0; - - virtual void addLight(Blender::Object* tmpObject)=0; - -}; - -#endif //__BULLET_BLEND_NEW_H diff --git a/gamekit/BulletDNA.cpp b/gamekit/BulletDNA.cpp deleted file mode 100644 index 3115aed40..000000000 --- a/gamekit/BulletDNA.cpp +++ /dev/null @@ -1,89 +0,0 @@ -unsigned char BulletDNAstr[]= { -83,68,78,65,78,65,77,69,64,0,0,0,109,95,115,105,122,101,0,109, -95,99,97,112,97,99,105,116,121,0,42,109,95,100,97,116,97,0,109,95, -99,111,108,108,105,115,105,111,110,83,104,97,112,101,115,0,109,95,99,111, -108,108,105,115,105,111,110,79,98,106,101,99,116,115,0,109,95,99,111,110, -115,116,114,97,105,110,116,115,0,42,102,105,114,115,116,0,42,108,97,115, -116,0,109,95,102,108,111,97,116,115,91,52,93,0,121,97,119,0,112,105, -116,99,104,0,114,111,108,108,0,109,95,101,108,91,51,93,0,109,95,98, -97,115,105,115,0,109,95,111,114,105,103,105,110,0,42,109,95,117,115,101, -114,80,111,105,110,116,101,114,0,109,95,115,104,97,112,101,84,121,112,101, -0,109,95,112,97,100,100,105,110,103,91,52,93,0,109,95,104,97,108,102, -69,120,116,101,110,116,115,0,109,95,108,111,99,97,108,83,99,97,108,105, -110,103,0,109,95,119,111,114,108,100,84,114,97,110,115,102,111,114,109,0, -109,95,105,110,116,101,114,112,111,108,97,116,105,111,110,87,111,114,108,100, -84,114,97,110,115,102,111,114,109,0,109,95,105,110,116,101,114,112,111,108, -97,116,105,111,110,76,105,110,101,97,114,86,101,108,111,99,105,116,121,0, -109,95,105,110,116,101,114,112,111,108,97,116,105,111,110,65,110,103,117,108, -97,114,86,101,108,111,99,105,116,121,0,109,95,97,110,105,115,111,116,114, -111,112,105,99,70,114,105,99,116,105,111,110,0,109,95,104,97,115,65,110, -105,115,111,116,114,111,112,105,99,70,114,105,99,116,105,111,110,0,109,95, -99,111,110,116,97,99,116,80,114,111,99,101,115,115,105,110,103,84,104,114, -101,115,104,111,108,100,0,42,109,95,98,114,111,97,100,112,104,97,115,101, -72,97,110,100,108,101,0,42,109,95,99,111,108,108,105,115,105,111,110,83, -104,97,112,101,0,42,109,95,114,111,111,116,67,111,108,108,105,115,105,111, -110,83,104,97,112,101,0,109,95,99,111,108,108,105,115,105,111,110,70,108, -97,103,115,0,109,95,105,115,108,97,110,100,84,97,103,49,0,109,95,99, -111,109,112,97,110,105,111,110,73,100,0,109,95,97,99,116,105,118,97,116, -105,111,110,83,116,97,116,101,49,0,109,95,100,101,97,99,116,105,118,97, -116,105,111,110,84,105,109,101,0,109,95,102,114,105,99,116,105,111,110,0, -109,95,114,101,115,116,105,116,117,116,105,111,110,0,109,95,105,110,116,101, -114,110,97,108,84,121,112,101,0,42,109,95,117,115,101,114,79,98,106,101, -99,116,80,111,105,110,116,101,114,0,109,95,104,105,116,70,114,97,99,116, -105,111,110,0,109,95,99,99,100,83,119,101,112,116,83,112,104,101,114,101, -82,97,100,105,117,115,0,109,95,99,99,100,77,111,116,105,111,110,84,104, -114,101,115,104,111,108,100,0,109,95,99,104,101,99,107,67,111,108,108,105, -100,101,87,105,116,104,0,109,95,105,110,118,73,110,101,114,116,105,97,84, -101,110,115,111,114,87,111,114,108,100,0,109,95,108,105,110,101,97,114,86, -101,108,111,99,105,116,121,0,109,95,97,110,103,117,108,97,114,86,101,108, -111,99,105,116,121,0,109,95,105,110,118,101,114,115,101,77,97,115,115,0, -109,95,97,110,103,117,108,97,114,70,97,99,116,111,114,0,109,95,108,105, -110,101,97,114,70,97,99,116,111,114,0,109,95,103,114,97,118,105,116,121, -0,109,95,103,114,97,118,105,116,121,95,97,99,99,101,108,101,114,97,116, -105,111,110,0,109,95,105,110,118,73,110,101,114,116,105,97,76,111,99,97, -108,0,109,95,116,111,116,97,108,70,111,114,99,101,0,109,95,116,111,116, -97,108,84,111,114,113,117,101,0,109,95,108,105,110,101,97,114,68,97,109, -112,105,110,103,0,109,95,97,110,103,117,108,97,114,68,97,109,112,105,110, -103,0,109,95,97,100,100,105,116,105,111,110,97,108,68,97,109,112,105,110, -103,0,109,95,97,100,100,105,116,105,111,110,97,108,68,97,109,112,105,110, -103,70,97,99,116,111,114,0,109,95,97,100,100,105,116,105,111,110,97,108, -76,105,110,101,97,114,68,97,109,112,105,110,103,84,104,114,101,115,104,111, -108,100,83,113,114,0,109,95,97,100,100,105,116,105,111,110,97,108,65,110, -103,117,108,97,114,68,97,109,112,105,110,103,84,104,114,101,115,104,111,108, -100,83,113,114,0,109,95,97,100,100,105,116,105,111,110,97,108,65,110,103, -117,108,97,114,68,97,109,112,105,110,103,70,97,99,116,111,114,0,109,95, -108,105,110,101,97,114,83,108,101,101,112,105,110,103,84,104,114,101,115,104, -111,108,100,0,109,95,97,110,103,117,108,97,114,83,108,101,101,112,105,110, -103,84,104,114,101,115,104,111,108,100,0,109,95,99,111,108,108,105,115,105, -111,110,79,98,106,101,99,116,68,97,116,97,0,0,0,0,84,89,80,69, -22,0,0,0,99,104,97,114,0,117,99,104,97,114,0,115,104,111,114,116, -0,117,115,104,111,114,116,0,105,110,116,0,108,111,110,103,0,117,108,111, -110,103,0,102,108,111,97,116,0,100,111,117,98,108,101,0,118,111,105,100, -0,98,116,83,99,97,108,97,114,0,80,111,105,110,116,101,114,65,114,114, -97,121,0,98,116,80,104,121,115,105,99,115,83,121,115,116,101,109,0,76, -105,115,116,66,97,115,101,0,98,116,86,101,99,116,111,114,51,68,97,116, -97,0,69,117,108,101,114,0,98,116,77,97,116,114,105,120,51,120,51,68, -97,116,97,0,98,116,84,114,97,110,115,102,111,114,109,68,97,116,97,0, -98,116,67,111,108,108,105,115,105,111,110,83,104,97,112,101,68,97,116,97, -0,98,116,66,111,120,83,104,97,112,101,68,97,116,97,0,98,116,67,111, -108,108,105,115,105,111,110,79,98,106,101,99,116,68,97,116,97,0,98,116, -82,105,103,105,100,66,111,100,121,68,97,116,97,0,0,0,84,76,69,78, -1,0,1,0,2,0,2,0,4,0,4,0,4,0,4,0,8,0,0,0, -4,0,12,0,36,0,8,0,16,0,12,0,48,0,64,0,12,0,32,0, --8,0,-32,1,83,84,82,67,11,0,0,0,11,0,3,0,4,0,0,0, -4,0,1,0,9,0,2,0,12,0,3,0,11,0,3,0,11,0,4,0, -11,0,5,0,13,0,2,0,9,0,6,0,9,0,7,0,14,0,1,0, -10,0,8,0,15,0,3,0,10,0,9,0,10,0,10,0,10,0,11,0, -16,0,1,0,14,0,12,0,17,0,2,0,16,0,13,0,14,0,14,0, -18,0,3,0,9,0,15,0,4,0,16,0,0,0,17,0,19,0,2,0, -14,0,18,0,14,0,19,0,20,0,23,0,17,0,20,0,17,0,21,0, -14,0,22,0,14,0,23,0,14,0,24,0,4,0,25,0,10,0,26,0, -9,0,27,0,9,0,28,0,18,0,29,0,4,0,30,0,4,0,31,0, -4,0,32,0,4,0,33,0,10,0,34,0,10,0,35,0,10,0,36,0, -4,0,37,0,9,0,38,0,10,0,39,0,10,0,40,0,10,0,41,0, -4,0,42,0,21,0,21,0,16,0,43,0,14,0,44,0,14,0,45,0, -10,0,46,0,14,0,47,0,14,0,48,0,14,0,49,0,14,0,50,0, -14,0,51,0,14,0,52,0,14,0,53,0,10,0,54,0,10,0,55,0, -4,0,56,0,10,0,57,0,10,0,58,0,10,0,59,0,10,0,60,0, -10,0,61,0,10,0,62,0,20,0,63,0,}; -int BulletDNAlen= sizeof(BulletDNAstr); diff --git a/gamekit/BulletIrrlichtUtils.cpp b/gamekit/BulletIrrlichtUtils.cpp deleted file mode 100644 index aefaf2b5d..000000000 --- a/gamekit/BulletIrrlichtUtils.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/* -GameKit -Copyright (c) 2009 Erwin Coumans http://gamekit.googlecode.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#include "BulletIrrlichtUtils.h" -#include <irrlicht.h> -#include "btBulletDynamicsCommon.h" - -btScalar physicsWorldScaling = 1.f; -using namespace irr; - -//Blender/OpenGL -//left/right = X axis -//front/back = Y axis -//top/bottom = Z axis -// -//In DirectX's and Irrlicht's and many other coordinate systems it's like this -// -//left/right = X axis -//top/bottom = Y axis -//front/back = Z axis - - - - -void norShortToFloat(const short *shnor, float *fnor) -{ - fnor[0] = shnor[0] / NOR_SHORTTOFLOAT; - fnor[1] = shnor[1] / NOR_SHORTTOFLOAT; - fnor[2] = shnor[2] / NOR_SHORTTOFLOAT; -} - - -void MatrixToEuler(const btMatrix3x3& mat,btVector3& TEuler) -{ - irr::core::matrix4 imat; - float m[16]; - m[0] = mat[IRR_X][IRR_X]; - m[1] = IRR_X_M*IRR_Y_M*mat[IRR_Y][IRR_X]; - m[2] = IRR_X_M*IRR_Z_M*mat[IRR_Z][IRR_X]; - m[3] = 0; - - m[4] = IRR_X_M*IRR_Y_M*mat[IRR_X][IRR_Y]; - m[5] = mat[IRR_Y][IRR_Y]; - m[6] = IRR_Y_M*IRR_Z_M*mat[IRR_Z][IRR_Y]; - m[7] = 0; - - m[8] = IRR_X_M*IRR_Z_M*mat[IRR_X][IRR_Z]; - m[9] = IRR_Y_M*IRR_Z_M*mat[IRR_Y][IRR_Z]; - m[10] = mat[IRR_Z][IRR_Z]; - m[11] = 0; - - m[12] = 0;//IRR_X_M*btr.getOrigin()[IRR_X]; - m[13] = 0;//IRR_Y_M*btr.getOrigin()[IRR_Y]; - m[14] = 0;//IRR_Z_M*btr.getOrigin()[IRR_Z]; - m[15] = 0; - - imat.setM(m); - - irr::core::vector3df eulerrot = imat.getRotationDegrees(); - TEuler[0] = eulerrot.X; - TEuler[1] = eulerrot.Y; - TEuler[2] = eulerrot.Z; -} - - - - -IrrMotionState::IrrMotionState() -{ -} - -IrrMotionState::~IrrMotionState() -{ -} - -///synchronizes world transform from user to physics -void IrrMotionState::getWorldTransform(btTransform& centerOfMassWorldTrans ) const -{ - centerOfMassWorldTrans = m_graphicsWorldTrans; -} - -void IrrMotionState::addIrrlichtNode(irr::scene::ISceneNode* node) -{ - m_irrNodes.push_back(node); -} - -///synchronizes world transform from physics to user -///Bullet only calls the update of worldtransform for active objects -void IrrMotionState::setWorldTransform(const btTransform& centerOfMassWorldTrans) -{ - - m_startWorldTrans = centerOfMassWorldTrans; - m_graphicsWorldTrans = centerOfMassWorldTrans; - - const btVector3& Point = centerOfMassWorldTrans.getOrigin(); - // Set rotation - btVector3 EulerRotation; - MatrixToEuler(centerOfMassWorldTrans.getBasis(), EulerRotation); - - for (int i=0;i<m_irrNodes.size();i++) - { - m_irrNodes[i]->setPosition(irr::core::vector3df((f32)Point[IRR_X], (f32)Point[IRR_Y], (f32)Point[IRR_Z])/physicsWorldScaling); - m_irrNodes[i]->setRotation(irr::core::vector3df(EulerRotation[0], EulerRotation[1], EulerRotation[2])); - - } -} diff --git a/gamekit/BulletIrrlichtUtils.h b/gamekit/BulletIrrlichtUtils.h deleted file mode 100644 index 4c987c7dd..000000000 --- a/gamekit/BulletIrrlichtUtils.h +++ /dev/null @@ -1,111 +0,0 @@ -/* -GameKit -Copyright (c) 2009 Erwin Coumans http://gamekit.googlecode.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef BULLET_IRRLICHT_UTILS_H -#define BULLET_IRRLICHT_UTILS_H - -namespace irr -{ - namespace scene - { - class ISceneNode; - } -}; - - - -class btTransform; -class btMatrix3x3; -class btVector3; - -#include "LinearMath/btAlignedObjectArray.h" -#include "LinearMath/btDefaultMotionState.h" - -struct IrrlichtMeshContainer -{ - btAlignedObjectArray<irr::scene::ISceneNode*> m_sceneNodes; - void* m_userPointer; -}; - - -#define NOR_SHORTTOFLOAT 32767.0f - -///mapping between right handed and left-handed coordinate system -#define SWAP_COORDINATE_SYSTEMS -#ifdef SWAP_COORDINATE_SYSTEMS - -#define IRR_X 0 -#define IRR_Y 2 -#define IRR_Z 1 - -#define IRR_X_M 1.f -#define IRR_Y_M 1.f -#define IRR_Z_M 1.f - -///also winding is different -#define IRR_TRI_0_X 0 -#define IRR_TRI_0_Y 2 -#define IRR_TRI_0_Z 1 - -#define IRR_TRI_1_X 0 -#define IRR_TRI_1_Y 3 -#define IRR_TRI_1_Z 2 -#else -#define IRR_X 0 -#define IRR_Y 1 -#define IRR_Z 2 - -#define IRR_X_M 1.f -#define IRR_Y_M 1.f -#define IRR_Z_M 1.f - -///also winding is different -#define IRR_TRI_0_X 0 -#define IRR_TRI_0_Y 1 -#define IRR_TRI_0_Z 2 - -#define IRR_TRI_1_X 0 -#define IRR_TRI_1_Y 2 -#define IRR_TRI_1_Z 3 -#endif - - - -void norShortToFloat(const short *shnor, float *fnor); - -void MatrixToEuler(const btMatrix3x3& mat,btVector3& TEuler); - -///This class sychronizes the world transform between Bullet rigid bodies and their accompanying Irrlicht nodes -class IrrMotionState : public btDefaultMotionState -{ - btAlignedObjectArray<irr::scene::ISceneNode*> m_irrNodes; -public: - - IrrMotionState(); - - virtual ~IrrMotionState(); - - ///synchronizes world transform from user to physics - virtual void getWorldTransform(btTransform& centerOfMassWorldTrans ) const ; - - void addIrrlichtNode(irr::scene::ISceneNode* node); - - ///synchronizes world transform from physics to user - ///Bullet only calls the update of worldtransform for active objects - virtual void setWorldTransform(const btTransform& centerOfMassWorldTrans); - -}; - -#endif //BULLET_IRRLICHT_UTILS_H diff --git a/gamekit/CMakeLists.txt b/gamekit/CMakeLists.txt deleted file mode 100644 index a14e85acd..000000000 --- a/gamekit/CMakeLists.txt +++ /dev/null @@ -1,112 +0,0 @@ - -# You shouldn't have to modify anything below this line -######################################################## - - -IF (WIN32 AND MSVC) - SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DYNAMICBASE") -ENDIF (WIN32 AND MSVC) - -LINK_DIRECTORIES( -"C:/MinGW/lib" -) - -INCLUDE_DIRECTORIES( -${IRRLICHT_SOURCE_DIR}/include ${BULLET_PHYSICS_SOURCE_DIR}/src -) - -SET (EXTRA_LIBS ) - -IF(APPLE) - SET(EXETYPE MACOSX_BUNDLE) - SET_SOURCE_FILES_PROPERTIES( MainMenu.nib PROPERTIES MACOSX_PACKAGE_LOCATION Resources ) - #SET(GUI_TYPE MACOSX_BUNDLE) - INCLUDE_DIRECTORIES ( /Developer/Headers/FlatCarbon ) - FIND_LIBRARY(CARBON_LIBRARY Carbon) - FIND_LIBRARY(QUICKTIME_LIBRARY QuickTime ) - FIND_LIBRARY(APP_SERVICES_LIBRARY ApplicationServices ) - FIND_LIBRARY(Foundation_FRAMEWORKS Foundation ) - FIND_LIBRARY(CoreFoundation_FRAMEWORKS CoreFoundation ) - FIND_LIBRARY(APPKIT_LIBRARY AppKit ) - MARK_AS_ADVANCED (CARBON_LIBRARY - QUICKTIME_LIBRARY - APP_SERVICES_LIBRARY) - SET(EXTRA_LIBS ${APPKIT_LIBRARY} ${Foundation_FRAMEWORKS} ${CoreFoundation_FRAMEWORKS} ${CARBON_LIBRARY} ${QUICKTIME_LIBRARY} ${APP_SERVICES_LIBRARY}) - -IF (X11_VIDEO_LIBRARY) - SET(EXTRA_LIBS ${EXTRA_LIBS} ${X11_VIDEO_LIBRARY} ) -ENDIF (X11_VIDEO_LIBRARY) - - - -ELSE (APPLE) - -IF (X11_VIDEO_LIBRARY) - SET(EXTRA_LIBS ${EXTRA_LIBS} Xxf86vm ) -ENDIF (X11_VIDEO_LIBRARY) - -ENDIF (APPLE) - -SET(bParse_SRCS - bChunk.cpp - bChunk.h - bCommon.h - bDefines.h - bDNA.cpp - bDNA.h - bFile.cpp - bFile.h - bBlenderFile.cpp - bBlenderFile.h - btBulletFile.cpp - btBulletFile.h - bMain.cpp - bMain.h - dna249.cpp - dna249-64bit.cpp - BulletDNA.cpp -) - - -SET(GameKit_SRCS - clubsilo_packed.blend - PhysicsAnimationBakingDemo.blend - BulletBlendReader.cpp - BulletBlendReader.h - BulletBlendReaderNew.cpp - BulletBlendReaderNew.h - BulletIrrlichtUtils.cpp - BulletIrrlichtUtils.h - IrrBlend.cpp - IrrBlend.h - IrrBlendNew.cpp - IrrBlendNew.h - - main.cpp -) - - -LINK_LIBRARIES( - BulletSoftBody BulletDynamics BulletCollision LinearMath Irrlicht ${EXTRA_LIBS} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ${X11_VIDEO_LIBRARY} -) - -IF (APPLE) - SET (NibFile MainMenu.nib) - SET (RESOURCS $(NibFile)) - SET_SOURCE_FILES_PROPERTIES( PhysicsAnimationBakingDemo.blend PROPERTIES MACOSX_PACKAGE_LOCATION Resources ) - SET_SOURCE_FILES_PROPERTIES( clubsilo_packed.blend PROPERTIES MACOSX_PACKAGE_LOCATION Resources ) - ADD_EXECUTABLE(GameKit - MACOSX_BUNDLE - MainMenu.nib - ${GameKit_SRCS} - ${bParse_SRCS} - - ) -ELSE (APPLE) - ADD_EXECUTABLE(GameKit - ${GameKit_SRCS} - ${bParse_SRCS} - - ) -ENDIF (APPLE) - diff --git a/gamekit/IrrBlend.cpp b/gamekit/IrrBlend.cpp deleted file mode 100644 index 9d0d94ac8..000000000 --- a/gamekit/IrrBlend.cpp +++ /dev/null @@ -1,562 +0,0 @@ -/* -GameKit -Copyright (c) 2009 Erwin Coumans http://gamekit.googlecode.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "IrrBlend.h" -#include "BulletIrrlichtUtils.h" - - -using namespace irr; - - - - -IrrlichtBulletBlendReader::IrrlichtBulletBlendReader(irr::IrrlichtDevice* device,irr::scene::ISceneManager* irrlichtSceneManager, btDiscreteDynamicsWorld* bulletWorld, btLogicManager* logicManager) - :BulletBlendReader(bulletWorld), - m_device(device), - m_sceneManager(irrlichtSceneManager), - m_logicManager(logicManager), - m_guid(666) -{ -} - -void IrrlichtBulletBlendReader::addCamera(_bObj* tmpObject) -{ - irr::scene::ICameraSceneNode* cam = m_sceneManager->getActiveCamera(); - if (cam) - { - cam->setPosition(irr::core::vector3df(tmpObject->location[IRR_X],tmpObject->location[IRR_Y],tmpObject->location[IRR_Z])); - btMatrix3x3 mat; - mat.setEulerZYX(tmpObject->rotphr[0],tmpObject->rotphr[1],tmpObject->rotphr[2]); - btVector3 EulerRotation; - MatrixToEuler(mat, EulerRotation); - cam->setRotation(core::vector3df(EulerRotation[0], EulerRotation[1], EulerRotation[2])); - cam->updateAbsolutePosition(); - - } -} - -void IrrlichtBulletBlendReader::addLight(_bObj* tmpObject) -{ - -} - - -void* IrrlichtBulletBlendReader::createGraphicsObject(_bObj* tmpObject, class btCollisionObject* bulletObject) -{ - - - IrrlichtMeshContainer* meshContainer = 0; - - - btRigidBody* body = btRigidBody::upcast(bulletObject); - IrrMotionState* newMotionState = 0; - - if (body) - { - if (!bulletObject->isStaticOrKinematicObject()) - { - newMotionState = new IrrMotionState(); - newMotionState->setWorldTransform(body->getWorldTransform()); - body->setMotionState(newMotionState); - } - } - - - if (tmpObject->data.mesh && tmpObject->data.mesh->vert_count && tmpObject->data.mesh->face_count) - { - if (tmpObject->data.mesh->vert_count> 16300) - { - printf("tmpObject->data.mesh->vert_count = %d\n",tmpObject->data.mesh->vert_count); - } - - int maxVerts = btMin(16300,btMax(tmpObject->data.mesh->face_count*3*2,(tmpObject->data.mesh->vert_count-6))); - - video::S3DVertex* orgVertices= new video::S3DVertex[tmpObject->data.mesh->vert_count]; - video::S3DVertex* newVertices= new video::S3DVertex[maxVerts]; - - for (int v=0;v<tmpObject->data.mesh->vert_count;v++) - { - float* vt3 = tmpObject->data.mesh->vert[v].xyz; - orgVertices[v] = video::S3DVertex( IRR_X_M*vt3[IRR_X], IRR_Y_M*vt3[IRR_Y], IRR_Z_M*vt3[IRR_Z], 1,1,0, video::SColor(255,255,255,255), 0, 1); - } - - - int numVertices = 0; - int numTriangles=0; - int numIndices = 0; - int currentIndex = 0; - - - int maxNumIndices = tmpObject->data.mesh->face_count*4*2; - - unsigned short int* indices= new unsigned short int[maxNumIndices]; - - for (int t=0;t<tmpObject->data.mesh->face_count;t++) - { - if (currentIndex>maxNumIndices) - break; - - int originalIndex = tmpObject->data.mesh->face[t].v[IRR_TRI_0_X]; - indices[numIndices] = currentIndex; - newVertices[indices[numIndices]] = orgVertices[originalIndex]; - newVertices[indices[numIndices]].TCoords.X = tmpObject->data.mesh->face[t].uv[IRR_TRI_0_X][0]; - newVertices[indices[numIndices]].TCoords.Y = tmpObject->data.mesh->face[t].uv[IRR_TRI_0_X][1]; - numIndices++; - currentIndex++; - numVertices++; - - originalIndex = tmpObject->data.mesh->face[t].v[IRR_TRI_0_Y]; - indices[numIndices] = currentIndex; - newVertices[indices[numIndices]] = orgVertices[originalIndex]; - newVertices[indices[numIndices]].TCoords.X = tmpObject->data.mesh->face[t].uv[IRR_TRI_0_Y][0]; - newVertices[indices[numIndices]].TCoords.Y = tmpObject->data.mesh->face[t].uv[IRR_TRI_0_Y][1]; - numIndices++; - currentIndex++; - numVertices++; - - originalIndex = tmpObject->data.mesh->face[t].v[IRR_TRI_0_Z]; - indices[numIndices] = currentIndex; - newVertices[indices[numIndices]] = orgVertices[originalIndex]; - newVertices[indices[numIndices]].TCoords.X = tmpObject->data.mesh->face[t].uv[IRR_TRI_0_Z][0]; - newVertices[indices[numIndices]].TCoords.Y = tmpObject->data.mesh->face[t].uv[IRR_TRI_0_Z][1]; - numIndices++; - currentIndex++; - numVertices++; - numTriangles++; - - if (tmpObject->data.mesh->face[t].v[3]) - { - originalIndex = tmpObject->data.mesh->face[t].v[IRR_TRI_1_X]; - indices[numIndices]= currentIndex; - newVertices[currentIndex] = orgVertices[originalIndex]; - newVertices[currentIndex].TCoords.X = tmpObject->data.mesh->face[t].uv[IRR_TRI_1_X][0]; - newVertices[currentIndex].TCoords.Y = tmpObject->data.mesh->face[t].uv[IRR_TRI_1_X][1]; - numIndices++; - numVertices++; - currentIndex++; - - originalIndex = tmpObject->data.mesh->face[t].v[IRR_TRI_1_Y]; - indices[numIndices]= currentIndex; - newVertices[currentIndex] = orgVertices[originalIndex]; - newVertices[currentIndex].TCoords.X = tmpObject->data.mesh->face[t].uv[IRR_TRI_1_Y][0]; - newVertices[currentIndex].TCoords.Y = tmpObject->data.mesh->face[t].uv[IRR_TRI_1_Y][1]; - numIndices++; - numVertices++; - currentIndex++; - - originalIndex = tmpObject->data.mesh->face[t].v[IRR_TRI_1_Z]; - indices[numIndices]= currentIndex; - newVertices[currentIndex] = orgVertices[originalIndex]; - newVertices[currentIndex].TCoords.X = tmpObject->data.mesh->face[t].uv[IRR_TRI_1_Z][0]; - newVertices[currentIndex].TCoords.Y = tmpObject->data.mesh->face[t].uv[IRR_TRI_1_Z][1]; - - numIndices++; - numVertices++; - currentIndex++; - - numTriangles++; - } - - - ///subdivide the mesh into smaller parts, so that indices fit in short int - if (numVertices>=maxVerts) - { - scene::ISceneNode* node = createMeshNode(newVertices,numVertices,indices,numIndices,numTriangles,bulletObject,tmpObject); - if (!meshContainer) - meshContainer = new IrrlichtMeshContainer(); - meshContainer->m_sceneNodes.push_back(node); - - if (newMotionState && node) - newMotionState->addIrrlichtNode(node); - - numVertices = 0; - numTriangles = 0; - numIndices = 0; - - numVertices = 0; - currentIndex = 0; - - indices= new unsigned short int[tmpObject->data.mesh->face_count*4*2]; - } - } - - if (numTriangles>0) - { - scene::ISceneNode* node = createMeshNode(newVertices,numVertices,indices,numIndices,numTriangles,bulletObject,tmpObject); - - if (!meshContainer) - meshContainer = new IrrlichtMeshContainer(); - meshContainer->m_sceneNodes.push_back(node); - - if (newMotionState && node) - newMotionState->addIrrlichtNode(node); - - - } - } - - return meshContainer; - -} - -scene::ISceneNode* IrrlichtBulletBlendReader::createMeshNode(video::S3DVertex* vertices, int numVertices, unsigned short int* indices, int numIndices,int numTriangles,class btCollisionObject* bulletObject,_bObj* tmpObject) -{ - scene::ISceneNode* myNode = 0; - - irr::video::ITexture* texture0=0; - video::IVideoDriver* driver = m_sceneManager->getVideoDriver(); - - if (tmpObject->data.mesh->face[0].m_image) - { - const char* fileName = tmpObject->data.mesh->face[0].m_image->m_imagePathName; - - texture0 = driver->findTexture(fileName); - if (!texture0) - { - void* jpgData = tmpObject->data.mesh->face[0].m_image->m_packedImagePtr; - int jpgSize = tmpObject->data.mesh->face[0].m_image->m_sizePackedImage; - if (jpgSize) - { - io::IReadFile* file = m_device->getFileSystem()->createMemoryReadFile(jpgData,jpgSize,fileName,false); - if (file) - { - texture0 = driver->getTexture(file); - //printf("width = %d, height = %d\n",texture0->getSize().Width,texture0->getSize().Height); - } - } - } - } - - if (!texture0) - { - static irr::video::ITexture* notFoundTexture = 0; - if (!notFoundTexture) - { - unsigned char* imageData=new unsigned char[256*256*3]; - for(int y=0;y<256;++y) - { - const int t=y>>4; - unsigned char* pi=imageData+y*256*3; - for(int x=0;x<256;++x) - { - const int s=x>>4; - const unsigned char b=180; - unsigned char c=b+((s+t&1)&1)*(255-b); - pi[0]= 255; - pi[1]=pi[2]=c;pi+=3; - } - } - irr::core::dimension2d<unsigned int> dim(256,256); - irr::video::IImage* image = driver->createImageFromData(irr::video::ECF_R8G8B8,dim,imageData); - delete imageData; - notFoundTexture = driver->addTexture("notFound",image); - image->drop(); - } - - texture0 = notFoundTexture; - } - - if (texture0) - { - - -#ifdef USE_CUSTOM_NODE - myNode = new CSampleSceneNode(m_sceneManager->getRootSceneNode(), m_sceneManager, m_guid++,vertices,numVertices,indices,numTriangles,texture0); -#else - irr::scene::SMesh* mesh = new irr::scene::SMesh(); - irr::scene::SMeshBuffer* meshbuf = new irr::scene::SMeshBuffer(); - meshbuf->append(vertices,numVertices,indices,numTriangles*3); - mesh->addMeshBuffer(meshbuf); - irr::scene::SAnimatedMesh* animMesh = new irr::scene::SAnimatedMesh(mesh); -#ifdef USE_VBO - animMesh->setHardwareMappingHint(scene::EHM_STATIC); -#endif //USE_VBO - myNode = m_sceneManager->addMeshSceneNode(animMesh); - myNode->setMaterialTexture(0,texture0); - myNode->setMaterialFlag(irr::video::EMF_LIGHTING,false); -#endif - - // Set rotation - btVector3 EulerRotation; - btTransform btr = bulletObject->getWorldTransform(); - - btMatrix3x3 bmat33 = btr.getBasis(); - - irr::core::matrix4 imat; - float m[16]; - m[0] = btr.getBasis()[IRR_X][IRR_X]; - m[1] = IRR_X_M*IRR_Y_M*btr.getBasis()[IRR_Y][IRR_X]; - m[2] = IRR_X_M*IRR_Z_M*btr.getBasis()[IRR_Z][IRR_X]; - m[3] = 0; - - m[4] = IRR_X_M*IRR_Y_M*btr.getBasis()[IRR_X][IRR_Y]; - m[5] = btr.getBasis()[IRR_Y][IRR_Y]; - m[6] = IRR_Y_M*IRR_Z_M*btr.getBasis()[IRR_Z][IRR_Y]; - m[7] = 0; - - m[8] = IRR_X_M*IRR_Z_M*btr.getBasis()[IRR_X][IRR_Z]; - m[9] = IRR_Y_M*IRR_Z_M*btr.getBasis()[IRR_Y][IRR_Z]; - m[10] = btr.getBasis()[IRR_Z][IRR_Z]; - m[11] = 0; - - m[12] = IRR_X_M*btr.getOrigin()[IRR_X]; - m[13] = IRR_Y_M*btr.getOrigin()[IRR_Y]; - m[14] = IRR_Z_M*btr.getOrigin()[IRR_Z]; - m[15] = 0; - - imat.setM(m); - - irr::core::vector3df eulerrot = imat.getRotationDegrees(); - myNode->setRotation(eulerrot); - myNode->setPosition(irr::core::vector3df(IRR_X_M*btr.getOrigin()[IRR_X], IRR_Y_M*btr.getOrigin()[IRR_Y], IRR_Z_M*btr.getOrigin()[IRR_Z])); - - - - myNode->setScale(core::vector3df(tmpObject->scaling[IRR_X],tmpObject->scaling[IRR_Y],tmpObject->scaling[IRR_Z])); - myNode->getParent()->setPosition(irr::core::vector3df(0,0,0)); - myNode->getParent()->setRotation(irr::core::vector3df(0,0,0)); -#ifndef USE_CUSTOM_NODE - mesh->recalculateBoundingBox(); - animMesh->recalculateBoundingBox(); - animMesh->setDirty(); -#endif - } - return myNode; -} - - -void IrrlichtBulletBlendReader::createParentChildHierarchy() -{ - int i; - for (i=0;i<m_visibleGameObjects.size();i++) - { - btDataObject* ob = m_visibleGameObjects[i]; - - int parentBlendPtr = ob->getIntValue("*parent"); - if (parentBlendPtr) - { - btDataObject* parentPtr = *m_dataObjects[parentBlendPtr]; - - btCollisionObject* colParent = (btCollisionObject*) parentPtr->m_userPointer; - btCollisionObject* colObj = (btCollisionObject*)ob->m_userPointer; - if (colObj && colParent) - { - IrrlichtMeshContainer* childNode = (IrrlichtMeshContainer*) colObj->getUserPointer(); - IrrlichtMeshContainer* parentNode = (IrrlichtMeshContainer*) colParent->getUserPointer(); - if (childNode && parentNode) - { - for (int i=0;i<childNode->m_sceneNodes.size();i++) - { - if (parentNode->m_sceneNodes.size() && childNode->m_sceneNodes.size()) - { - - //don't do physics with this - //todo: add it to the collision compound (if flags are set) - m_destinationWorld->removeCollisionObject(colObj); - - childNode->m_sceneNodes[i]->setParent(parentNode->m_sceneNodes[0]); - -#if 0 - ///todo: deal with 'parentinv' - btDataValue* parentInverseOb = *ob->m_dataMap.find("parentinv[4][4]"); - btScalar m[16]; - - { - for (int i=0;i<4;i++) - for (int j=0;j<4;j++) - { - m[i+j*4] = parentInverseOb->m_valueArray[i].m_valueArray[j].m_fValue; - } - } - - btTransform trans; - trans.setFromOpenGLMatrix(m); -#endif - ///disconnect the rigidbody update for child objects - colObj->setUserPointer(0); - //childNode->m_sceneNodes[i]->setPosition(irr::core::vector3df(trans.getOrigin()[0],trans.getOrigin()[1],trans.getOrigin()[2])); - //childNode->m_sceneNodes[i]->setRotation(irr::core::vector3df(0,0,0)); - - } - } - } - } - } - - - - - } -} - - - -#define SENS_ALWAYS 0 -#define SENS_TOUCH 1 -#define SENS_NEAR 2 -#define SENS_KEYBOARD 3 -#define SENS_PROPERTY 4 -#define SENS_MOUSE 5 -#define SENS_COLLISION 6 -#define SENS_RADAR 7 -#define SENS_RANDOM 8 -#define SENS_RAY 9 -#define SENS_MESSAGE 10 -#define SENS_JOYSTICK 11 -#define SENS_ACTUATOR 12 -#define SENS_DELAY 13 -#define SENS_ARMATURE 14 - -#define CONT_LOGIC_AND 0 -#define CONT_LOGIC_OR 1 -#define CONT_EXPRESSION 2 -#define CONT_PYTHON 3 -#define CONT_LOGIC_NAND 4 -#define CONT_LOGIC_NOR 5 -#define CONT_LOGIC_XOR 6 -#define CONT_LOGIC_XNOR 7 - - -#define ACT_OBJECT 0 -#define ACT_IPO 1 -#define ACT_LAMP 2 -#define ACT_CAMERA 3 -#define ACT_MATERIAL 4 -#define ACT_SOUND 5 -#define ACT_PROPERTY 6 - /* these two obsolete since 2.02 */ -#define ACT_ADD_OBJECT 7 -#define ACT_END_OBJECT 8 - -#define ACT_CONSTRAINT 9 -#define ACT_EDIT_OBJECT 10 -#define ACT_SCENE 11 -#define ACT_GROUP 12 -#define ACT_RANDOM 13 -#define ACT_MESSAGE 14 -#define ACT_ACTION 15 /* __ NLA */ -#define ACT_GAME 17 -#define ACT_VISIBILITY 18 -#define ACT_2DFILTER 19 -#define ACT_PARENT 20 -#define ACT_SHAPEACTION 21 -#define ACT_STATE 22 -#define ACT_ARMATURE 23 - -btDataObject* IrrlichtBulletBlendReader::getObjectMemberPtrByName(btDataObject* ob, const char* ptrName) -{ - unsigned int cPtr = ob->getIntValue(ptrName); - if (cPtr) - { - btDataObject** dataPtr = m_dataObjects[cPtr]; - - if (dataPtr&& *dataPtr) - { - btDataObject* dataObject = *dataPtr; - return dataObject; - } - } - return 0; -} - -void IrrlichtBulletBlendReader::convertLogicBricks() -{ - int i; - for (i=0;i<m_visibleGameObjects.size();i++) - { - btDataObject* ob = m_visibleGameObjects[i]; - { - btDataObject* sensorOb = getObjectMemberPtrByName(ob,"sensors"); - while (sensorOb) - { - int sensType = sensorOb->getIntValue("type"); - switch (sensType) - { - case SENS_ALWAYS: - { - - btSensor* sensor = new btSensor(ob,sensType); - m_logicManager->m_sensors.push_back(sensor); - break; - } - - default: - { - printf("Unsupported sensor type %d\n",sensType); - } - } - - unsigned int nextIntPtr = sensorOb->getIntValue("*next"); - sensorOb = nextIntPtr ? *m_dataObjects[nextIntPtr] : 0; - } - } - - { - btDataObject* controllerOb = getObjectMemberPtrByName(ob,"controllers"); - while (controllerOb) - { - int conType = controllerOb->getIntValue("type"); - switch (conType) - { - case CONT_LOGIC_AND: - { - - btController* controller = new btController(ob,conType); - m_logicManager->m_controllers.push_back(controller); - break; - } - - default: - { - printf("Unsupported controller type %d\n",conType); - } - } - - unsigned int nextIntPtr = controllerOb->getIntValue("*next"); - controllerOb = nextIntPtr ? *m_dataObjects[nextIntPtr] : 0; - } - } - - { - btDataObject* actuatorOb = getObjectMemberPtrByName(ob,"actuators"); - while (actuatorOb ) - { - int acType = actuatorOb ->getIntValue("type"); - switch (acType) - { - case ACT_SCENE: - case ACT_IPO: - { - - btActuator* actuator = new btActuator(ob,acType); - m_logicManager->m_actuators.push_back(actuator); - break; - } - - - default: - { - printf("Unsupported actuator type %d\n",acType); - } - } - - unsigned int nextIntPtr = actuatorOb ->getIntValue("*next"); - actuatorOb = nextIntPtr ? *m_dataObjects[nextIntPtr] : 0; - } - } - - - } -} \ No newline at end of file diff --git a/gamekit/IrrBlend.h b/gamekit/IrrBlend.h deleted file mode 100644 index 556c9b765..000000000 --- a/gamekit/IrrBlend.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -GameKit -Copyright (c) 2009 Erwin Coumans http://gamekit.googlecode.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef IRRLICHT_BULLET_BLEND_READER_H -#define IRRLICHT_BULLET_BLEND_READER_H - -#include "BulletBlendReader.h" - -#include <irrlicht.h> -#include "btBulletDynamicsCommon.h" - - -class IrrlichtBulletBlendReader : public BulletBlendReader -{ - - irr::IrrlichtDevice* m_device; - irr::scene::ISceneManager* m_sceneManager; - btLogicManager* m_logicManager; - - int m_guid; - -public: - IrrlichtBulletBlendReader(irr::IrrlichtDevice* device,irr::scene::ISceneManager* irrlichtSceneManager, btDiscreteDynamicsWorld* bulletWorld, btLogicManager* logicManager); - - virtual void addCamera(_bObj* tmpObject); - - virtual void addLight(_bObj* tmpObject); - - virtual void* createGraphicsObject(_bObj* tmpObject, class btCollisionObject* bulletObject); - - irr::scene::ISceneNode* createMeshNode(irr::video::S3DVertex* vertices, int numVertices, unsigned short int* indices, int numIndices,int numTriangles,class btCollisionObject* bulletObject,_bObj* tmpObject); - - virtual void createParentChildHierarchy(); - - btDataObject* getObjectMemberPtrByName(btDataObject* ob, const char* ptrName); - - virtual void convertLogicBricks(); - -}; - - -#endif /IRRLICHT_BULLET_BLEND_READER_H - diff --git a/gamekit/IrrBlendNew.cpp b/gamekit/IrrBlendNew.cpp deleted file mode 100644 index 0c884c822..000000000 --- a/gamekit/IrrBlendNew.cpp +++ /dev/null @@ -1,585 +0,0 @@ -/* -GameKit -Copyright (c) 2009 Erwin Coumans http://gamekit.googlecode.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "IrrBlendNew.h" -#include "BulletIrrlichtUtils.h" -#include "autogenerated/blender.h" -#include "bMain.h" -#include "bBlenderFile.h" - - - -IrrBlendNew::IrrBlendNew(irr::IrrlichtDevice* device,irr::scene::ISceneManager* irrlichtSceneManager, btDiscreteDynamicsWorld* bulletWorld, btLogicManager* logicManager) -:BulletBlendReaderNew(bulletWorld), -m_device(device), -m_sceneManager(irrlichtSceneManager), -m_logicManager(logicManager), -m_notFoundTexture(0) -{ - -} - - -IrrBlendNew::~IrrBlendNew() -{ - -} - - -void IrrBlendNew::convertLogicBricks() -{ -} - - -void IrrBlendNew::createParentChildHierarchy() -{ - - int i; - btAlignedObjectArray<btCollisionObject*>children; - - for (i=0;i<this->m_destinationWorld->getNumCollisionObjects();i++) - { - btCollisionObject* childColObj = m_destinationWorld->getCollisionObjectArray()[i]; - IrrlichtMeshContainer* childNode = (IrrlichtMeshContainer*)childColObj->getUserPointer(); - if (!childNode) - continue; - Blender::Object* obj = (Blender::Object*)childNode->m_userPointer; - if (!obj) - continue; - - if (obj->parent) - { - ///@todo: deal with 'parentinv' - btCollisionObject* colParent = (btCollisionObject*) obj->parent->vnode; - - IrrlichtMeshContainer* parentNode = colParent ? (IrrlichtMeshContainer*) colParent->getUserPointer(): 0; - - if(parentNode && parentNode->m_sceneNodes.size()) - { - for (int i=0;i<childNode->m_sceneNodes.size();i++) - { - childNode->m_sceneNodes[i]->setParent(parentNode->m_sceneNodes[0]); - } - } - children.push_back(childColObj); - } - } - - - for (i=0;i<children.size();i++) - { - btCollisionObject* childColObj = children[i]; - m_destinationWorld->removeCollisionObject(childColObj); - ///disconnect the rigidbody update for child objects - childColObj->setUserPointer(0); - } -} - - - -//after each object is converter, including collision object, create a graphics object (and bind them) -void* IrrBlendNew::createGraphicsObject(Blender::Object* tmpObject, class btCollisionObject* bulletObject) -{ - - IrrlichtMeshContainer* meshContainer = 0; - bParse::bMain* mainPtr = m_blendFile->getMain(); - - - btRigidBody* body = bulletObject ? btRigidBody::upcast(bulletObject) : 0; - IrrMotionState* newMotionState = 0; - - if (body) - { - if (!bulletObject->isStaticOrKinematicObject()) - { - newMotionState = new IrrMotionState(); - newMotionState->setWorldTransform(body->getWorldTransform()); - body->setMotionState(newMotionState); - } - } - - Blender::Mesh *me = (Blender::Mesh*)tmpObject->data; - - if (me && me->totvert && me->totface) - { - if (me->totvert> 16300) - { - printf("me->totvert = %d\n",me->totvert); - } - - - int maxVerts = btMin(16300,btMax(me->totface*3*2,(me->totvert-6))); - - irr::video::S3DVertex* orgVertices= new irr::video::S3DVertex[me->totvert]; - irr::video::S3DVertex* newVertices= new irr::video::S3DVertex[maxVerts]; - - - if (!me->mvert) - return 0; - - float nor[3] = {0.f, 0.f, 0.f}; - - for (int v=0;v<me->totvert;v++) - { - float* vt3 = &me->mvert[v].co.x; - norShortToFloat(me->mvert[v].no, nor); - orgVertices[v] = irr::video::S3DVertex( IRR_X_M*vt3[IRR_X], IRR_Y_M*vt3[IRR_Y], IRR_Z_M*vt3[IRR_Z], nor[IRR_X], nor[IRR_Y], nor[IRR_Z], irr::video::SColor(255,255,255,255), 0, 1); - } - - - int numVertices = 0; - int numTriangles=0; - int numIndices = 0; - int currentIndex = 0; - - - - int maxNumIndices = me->totface*4*2; - - unsigned short int* indices= new unsigned short int[maxNumIndices]; - - for (int t=0;t<me->totface;t++) - { - if (currentIndex>maxNumIndices) - break; - - int v[4] = {me->mface[t].v1,me->mface[t].v2,me->mface[t].v3,me->mface[t].v4}; - - bool smooth = me->mface[t].flag & 1; // ME_SMOOTH - - // if mface !ME_SMOOTH use face normal in place of vert norms - if(!smooth) - { - irr::core::vector3df normal = irr::core::plane3df(orgVertices[v[0]].Pos, orgVertices[v[1]].Pos, orgVertices[v[2]].Pos).Normal; - normal.invert(); - - orgVertices[v[0]].Normal = normal; - orgVertices[v[1]].Normal = normal; - orgVertices[v[2]].Normal = normal; - if(v[3]) - orgVertices[v[3]].Normal = normal; - } - - int originalIndex = v[IRR_TRI_0_X]; - indices[numIndices] = currentIndex; - newVertices[indices[numIndices]] = orgVertices[originalIndex]; - if (me->mtface) - { - newVertices[indices[numIndices]].TCoords.X = me->mtface[t].uv[IRR_TRI_0_X][0]; - newVertices[indices[numIndices]].TCoords.Y = 1.f - me->mtface[t].uv[IRR_TRI_0_X][1]; - } else - { - newVertices[indices[numIndices]].TCoords.X = 0; - newVertices[indices[numIndices]].TCoords.Y = 0; - } - numIndices++; - currentIndex++; - numVertices++; - - originalIndex = v[IRR_TRI_0_Y]; - indices[numIndices] = currentIndex; - newVertices[indices[numIndices]] = orgVertices[originalIndex]; - if (me->mtface) - { - newVertices[indices[numIndices]].TCoords.X = me->mtface[t].uv[IRR_TRI_0_Y][0]; - newVertices[indices[numIndices]].TCoords.Y = 1.f - me->mtface[t].uv[IRR_TRI_0_Y][1]; - } else - { - newVertices[indices[numIndices]].TCoords.X = 0; - newVertices[indices[numIndices]].TCoords.Y = 0; - } - numIndices++; - currentIndex++; - numVertices++; - - originalIndex = v[IRR_TRI_0_Z]; - indices[numIndices] = currentIndex; - newVertices[indices[numIndices]] = orgVertices[originalIndex]; - if (me->mtface) - { - newVertices[indices[numIndices]].TCoords.X = me->mtface[t].uv[IRR_TRI_0_Z][0]; - newVertices[indices[numIndices]].TCoords.Y = 1.f - me->mtface[t].uv[IRR_TRI_0_Z][1]; - } else - { - newVertices[indices[numIndices]].TCoords.X = 0; - newVertices[indices[numIndices]].TCoords.Y = 0; - } - numIndices++; - currentIndex++; - numVertices++; - numTriangles++; - - if (v[3]) - { - originalIndex = v[IRR_TRI_1_X]; - indices[numIndices]= currentIndex; - newVertices[currentIndex] = orgVertices[originalIndex]; - if (me->mtface) - { - newVertices[currentIndex].TCoords.X = me->mtface[t].uv[IRR_TRI_1_X][0]; - newVertices[currentIndex].TCoords.Y = 1.f - me->mtface[t].uv[IRR_TRI_1_X][1]; - } else - { - newVertices[currentIndex].TCoords.X = 0; - newVertices[currentIndex].TCoords.Y = 0; - } - numIndices++; - numVertices++; - currentIndex++; - - originalIndex =v[IRR_TRI_1_Y]; - indices[numIndices]= currentIndex; - newVertices[currentIndex] = orgVertices[originalIndex]; - if (me->mtface) - { - newVertices[currentIndex].TCoords.X = me->mtface[t].uv[IRR_TRI_1_Y][0]; - newVertices[currentIndex].TCoords.Y = 1.f - me->mtface[t].uv[IRR_TRI_1_Y][1]; - } else - { - newVertices[currentIndex].TCoords.X = 0; - newVertices[currentIndex].TCoords.Y = 0; - } - numIndices++; - numVertices++; - currentIndex++; - - originalIndex = v[IRR_TRI_1_Z]; - indices[numIndices]= currentIndex; - newVertices[currentIndex] = orgVertices[originalIndex]; - if (me->mtface) - { - newVertices[currentIndex].TCoords.X = me->mtface[t].uv[IRR_TRI_1_Z][0]; - newVertices[currentIndex].TCoords.Y = 1.f - me->mtface[t].uv[IRR_TRI_1_Z][1]; - } else - { - newVertices[currentIndex].TCoords.X = 0; - newVertices[currentIndex].TCoords.Y = 0; - } - - numIndices++; - numVertices++; - currentIndex++; - - numTriangles++; - } - - - ///subdivide the mesh into smaller parts, so that indices fit in short int - if (numVertices>=maxVerts) - { - irr::scene::ISceneNode* node = createMeshNode(newVertices,numVertices,indices,numIndices,numTriangles,bulletObject,tmpObject); - if (!meshContainer) - meshContainer = new IrrlichtMeshContainer(); - - meshContainer->m_userPointer = tmpObject; - meshContainer->m_sceneNodes.push_back(node); - - if (newMotionState && node) - newMotionState->addIrrlichtNode(node); - - numVertices = 0; - numTriangles = 0; - numIndices = 0; - - numVertices = 0; - currentIndex = 0; - - indices= new unsigned short int[me->totface*4*2]; - } - } - - if (numTriangles>0) - { - irr::scene::ISceneNode* node = createMeshNode(newVertices,numVertices,indices,numIndices,numTriangles,bulletObject,tmpObject); - - if (!meshContainer) - meshContainer = new IrrlichtMeshContainer(); - - meshContainer->m_userPointer = tmpObject; - meshContainer->m_sceneNodes.push_back(node); - - if (newMotionState && node) - newMotionState->addIrrlichtNode(node); - - - } - } - - ///quick hack to get access to collision objects (for parent/hierarchy rebuild) - tmpObject->vnode = bulletObject; - - return meshContainer; - -} - - -irr::scene::ISceneNode* IrrBlendNew::createMeshNode(irr::video::S3DVertex* vertices, int numVertices, unsigned short int* indices, int numIndices,int numTriangles,class btCollisionObject* bulletObject,Blender::Object* tmpObject) -{ - - irr::scene::ISceneNode* myNode = 0; - - irr::video::ITexture* texture0=0; - irr::video::IVideoDriver* driver = m_sceneManager->getVideoDriver(); - - Blender::Mesh *me = (Blender::Mesh*)tmpObject->data; - Blender::Image* image = 0; - - bParse::bMain* mainPtr = m_blendFile->getMain(); - - - - if (me->mtface && me->mtface[0].tpage) - { - //image = (Blender::Image*)m_blendFile->getMain()->findLibPointer(me->mtface[0].tpage); - image = me->mtface[0].tpage; - } - - if (image) - { - const char* fileName = image->name; - - texture0 = driver->findTexture(fileName); - if (!texture0) - { - if (image->packedfile) - { - void* jpgData = image->packedfile->data; - int jpgSize = image->packedfile->size; - if (jpgSize) - { - irr::io::IReadFile* file = m_device->getFileSystem()->createMemoryReadFile(jpgData,jpgSize,fileName,false); - if (file) - { - texture0 = driver->getTexture(file); - printf("width = %d, height = %d\n",texture0->getSize().Width,texture0->getSize().Height); - } - } - } - } - - - } - - - if (!texture0) - { - - if (!m_notFoundTexture) - { - unsigned char* imageData=new unsigned char[256*256*3]; - for(int y=0;y<256;++y) - { - const int t=y>>4; - unsigned char* pi=imageData+y*256*3; - for(int x=0;x<256;++x) - { - const int s=x>>4; - const unsigned char b=180; - unsigned char c=b+((s+t&1)&1)*(255-b); - pi[0]= 255; - pi[1]=pi[2]=c;pi+=3; - } - } - irr::core::dimension2d<unsigned int> dim(256,256); - irr::video::IImage* imag = driver->createImageFromData(irr::video::ECF_R8G8B8,dim,imageData); - delete imageData; - m_notFoundTexture = driver->addTexture("notFound",imag); - imag->drop(); - } - - texture0 = m_notFoundTexture; - } - - if (texture0) - { - - -#ifdef USE_CUSTOM_NODE - myNode = new CSampleSceneNode(m_sceneManager->getRootSceneNode(), m_sceneManager, m_guid++,vertices,numVertices,indices,numTriangles,texture0); -#else - irr::scene::SMesh* mesh = new irr::scene::SMesh(); - irr::scene::SMeshBuffer* meshbuf = new irr::scene::SMeshBuffer(); - meshbuf->append(vertices,numVertices,indices,numTriangles*3); - mesh->addMeshBuffer(meshbuf); - irr::scene::SAnimatedMesh* animMesh = new irr::scene::SAnimatedMesh(mesh); -#ifdef USE_VBO - animMesh->setHardwareMappingHint(scene::EHM_STATIC); -#endif //USE_VBO - myNode = m_sceneManager->addMeshSceneNode(animMesh); - - if(me->mtface) - { - myNode->setMaterialTexture(0,texture0); - - if(me->mtface[0].mode & 16) // TF_LIGHT - { - myNode->setMaterialFlag(irr::video::EMF_LIGHTING, true); - myNode->setMaterialFlag(irr::video::EMF_NORMALIZE_NORMALS, true); - } - else - { - myNode->setMaterialFlag(irr::video::EMF_LIGHTING, false); - myNode->setMaterialFlag(irr::video::EMF_NORMALIZE_NORMALS, false); - } - - - if(me->mtface[0].mode & 512) // TF_TWOSIDE - myNode->getMaterial(0).BackfaceCulling = false; - - //myNode->getMaterial(0).GouraudShading = false; - - if(me->mtface[0].tpage) - { - switch(me->mtface[0].transp) - { - case 0: // TF_SOLID - myNode->setMaterialType(irr::video::EMT_SOLID); - break; - case 1: // TF_ADD - myNode->setMaterialType(irr::video::EMT_TRANSPARENT_ADD_COLOR); - break; - case 2: // TF_ALPHA - myNode->setMaterialType(irr::video::EMT_TRANSPARENT_ALPHA_CHANNEL); - break; - case 4: // TF_CLIP / BUG: no lighting with this mode, fixed in irrlicht trunk/1.7 - myNode->setMaterialType(irr::video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF); - break; - } - } - } - else - { - myNode->setMaterialFlag(irr::video::EMF_LIGHTING, true); - myNode->setMaterialFlag(irr::video::EMF_NORMALIZE_NORMALS, true); - } -#endif - - // Set rotation - btVector3 EulerRotation; - btTransform btr; - if (bulletObject) - { - btr = bulletObject->getWorldTransform(); - } else - { - float loc[3] = {tmpObject->loc.x,tmpObject->loc.y,tmpObject->loc.z}; - // btr.setOrigin(btVector3(loc[IRR_X],loc[IRR_Y],loc[IRR_Z])); - btr.setOrigin(btVector3(loc[0],loc[1],loc[2])); - - btMatrix3x3 rot; - rot.setEulerZYX(tmpObject->rot.x,tmpObject->rot.y,tmpObject->rot.z); - btr.setBasis(rot); - } - - - btMatrix3x3 bmat33 = btr.getBasis(); - - irr::core::matrix4 imat; - float m[16]; - m[0] = btr.getBasis()[IRR_X][IRR_X]; - m[1] = IRR_X_M*IRR_Y_M*btr.getBasis()[IRR_Y][IRR_X]; - m[2] = IRR_X_M*IRR_Z_M*btr.getBasis()[IRR_Z][IRR_X]; - m[3] = 0; - - m[4] = IRR_X_M*IRR_Y_M*btr.getBasis()[IRR_X][IRR_Y]; - m[5] = btr.getBasis()[IRR_Y][IRR_Y]; - m[6] = IRR_Y_M*IRR_Z_M*btr.getBasis()[IRR_Z][IRR_Y]; - m[7] = 0; - - m[8] = IRR_X_M*IRR_Z_M*btr.getBasis()[IRR_X][IRR_Z]; - m[9] = IRR_Y_M*IRR_Z_M*btr.getBasis()[IRR_Y][IRR_Z]; - m[10] = btr.getBasis()[IRR_Z][IRR_Z]; - m[11] = 0; - - m[12] = IRR_X_M*btr.getOrigin()[IRR_X]; - m[13] = IRR_Y_M*btr.getOrigin()[IRR_Y]; - m[14] = IRR_Z_M*btr.getOrigin()[IRR_Z]; - m[15] = 0; - - imat.setM(m); - - irr::core::vector3df eulerrot = imat.getRotationDegrees(); - myNode->setRotation(eulerrot); - myNode->setPosition(irr::core::vector3df(IRR_X_M*btr.getOrigin()[IRR_X], IRR_Y_M*btr.getOrigin()[IRR_Y], IRR_Z_M*btr.getOrigin()[IRR_Z])); - - - - float scaling[3] = {tmpObject->size.x,tmpObject->size.y,tmpObject->size.z}; - - myNode->setScale(irr::core::vector3df(scaling[IRR_X],scaling[IRR_Y],scaling[IRR_Z])); - myNode->getParent()->setPosition(irr::core::vector3df(0,0,0)); - myNode->getParent()->setRotation(irr::core::vector3df(0,0,0)); -#ifndef USE_CUSTOM_NODE - mesh->recalculateBoundingBox(); - animMesh->recalculateBoundingBox(); - animMesh->setDirty(); -#endif - } - return myNode; - -} - -void IrrBlendNew::addCamera(Blender::Object* tmpObject) -{ - irr::scene::ICameraSceneNode* cam = m_sceneManager->getActiveCamera(); - if (cam) - { - float pos[3] = {tmpObject->loc.x,tmpObject->loc.y,tmpObject->loc.z}; - cam->setPosition(irr::core::vector3df(pos[IRR_X],pos[IRR_Y],pos[IRR_Z])); - btMatrix3x3 mat; - mat.setEulerZYX(tmpObject->rot.x,tmpObject->rot.y,tmpObject->rot.z); - btVector3 EulerRotation; - MatrixToEuler(mat, EulerRotation); - cam->setRotation(irr::core::vector3df(EulerRotation[0], EulerRotation[1], EulerRotation[2])); - cam->updateAbsolutePosition(); - } -} - -void IrrBlendNew::addLight(Blender::Object* tmpObject) -{ - float pos[3] = {tmpObject->loc.x,tmpObject->loc.y,tmpObject->loc.z}; - float rot[3] = {irr::core::radToDeg(tmpObject->rot.x), irr::core::radToDeg(tmpObject->rot.y), irr::core::radToDeg(tmpObject->rot.z)}; - - rot[0] *= -1; - rot[1] *= -1; - rot[2] *= -1; - - Blender::Lamp *la = (Blender::Lamp*)tmpObject->data; - - irr::scene::ILightSceneNode* light = m_sceneManager->addLightSceneNode(0, irr::core::vector3df(pos[IRR_X], pos[IRR_Y], pos[IRR_Z]), - irr::video::SColorf(la->r*la->energy, la->g*la->energy, la->b*la->energy, 0.0f), la->dist); - - irr::video::SLight slight; - switch(la->type) - { - case 0: - light->setLightType(irr::video::ELT_POINT); - break; - case 2: - light->setLightType(irr::video::ELT_SPOT); - light->setRotation(irr::core::vector3df(90.f + rot[IRR_TRI_0_X], rot[IRR_TRI_0_Y], rot[IRR_TRI_0_Z])); - - slight = light->getLightData(); - slight.InnerCone = la->spotblend * 180.f; - slight.OuterCone = la->spotsize; - slight.Falloff = la->spotblend * 180.f; - light->setLightData(slight); - break; - case 3: - light->setLightType(irr::video::ELT_DIRECTIONAL); - light->setRotation(irr::core::vector3df(90.f + rot[IRR_TRI_0_X], rot[IRR_TRI_0_Y], rot[IRR_TRI_0_Z])); - break; - } -} diff --git a/gamekit/IrrBlendNew.h b/gamekit/IrrBlendNew.h deleted file mode 100644 index 73eadd86d..000000000 --- a/gamekit/IrrBlendNew.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -GameKit -Copyright (c) 2009 Erwin Coumans http://gamekit.googlecode.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef __IRR_BLEND_NEW_H -#define __IRR_BLEND_NEW_H - -#include "BulletBlendReaderNew.h" - - - -#include <irrlicht.h> -#include <iostream> - -#include "btBulletDynamicsCommon.h" -#include "BulletBlendReaderNew.h" -struct btLogicManager; -class btDiscreteDynamicsWorld; - - -class IrrBlendNew : public BulletBlendReaderNew -{ - - irr::IrrlichtDevice* m_device; - irr::scene::ISceneManager* m_sceneManager; - btLogicManager* m_logicManager; - irr::video::ITexture* m_notFoundTexture; - int m_guid; - - -public: - IrrBlendNew(irr::IrrlichtDevice* device,irr::scene::ISceneManager* irrlichtSceneManager, btDiscreteDynamicsWorld* bulletWorld, btLogicManager* logicManager); - - virtual ~IrrBlendNew(); - - virtual void addCamera(Blender::Object* tmpObject); - - virtual void addLight(Blender::Object* tmpObject); - - virtual void* createGraphicsObject(Blender::Object* tmpObject, class btCollisionObject* bulletObject); - - irr::scene::ISceneNode* createMeshNode(irr::video::S3DVertex* vertices, int numVertices, unsigned short int* indices, int numIndices,int numTriangles,class btCollisionObject* bulletObject,Blender::Object* tmpObject); - - virtual void createParentChildHierarchy(); - - virtual void convertLogicBricks(); - -}; - - -#endif //__IRR_BLEND_NEW_H diff --git a/gamekit/MainMenu.nib/classes.nib b/gamekit/MainMenu.nib/classes.nib deleted file mode 100644 index b9b4b09f6..000000000 --- a/gamekit/MainMenu.nib/classes.nib +++ /dev/null @@ -1,4 +0,0 @@ -{ - IBClasses = ({CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }); - IBVersion = 1; -} \ No newline at end of file diff --git a/gamekit/MainMenu.nib/info.nib b/gamekit/MainMenu.nib/info.nib deleted file mode 100644 index d4de41f96..000000000 --- a/gamekit/MainMenu.nib/info.nib +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> -<plist version="1.0"> -<dict> - <key>IBDocumentLocation</key> - <string>195 413 356 240 0 0 1680 1028 </string> - <key>IBEditorPositions</key> - <dict> - <key>29</key> - <string>62 343 338 44 0 0 1680 1028 </string> - </dict> - <key>IBFramework Version</key> - <string>443.0</string> - <key>IBSystem Version</key> - <string>8F46</string> -</dict> -</plist> diff --git a/gamekit/MainMenu.nib/keyedobjects.nib b/gamekit/MainMenu.nib/keyedobjects.nib deleted file mode 100644 index 1a561028d..000000000 Binary files a/gamekit/MainMenu.nib/keyedobjects.nib and /dev/null differ diff --git a/gamekit/PhysicsAnimationBakingDemo.blend b/gamekit/PhysicsAnimationBakingDemo.blend deleted file mode 100644 index 7a5067e5f..000000000 Binary files a/gamekit/PhysicsAnimationBakingDemo.blend and /dev/null differ diff --git a/gamekit/abs-file.h b/gamekit/abs-file.h deleted file mode 100644 index 6dd9d26eb..000000000 --- a/gamekit/abs-file.h +++ /dev/null @@ -1,261 +0,0 @@ -/* - * stdio/physfs abstraction layer 2004-02-06 - * - * Adam D. Moss <adam@gimp.org> <aspirin@icculus.org> - * - * These wrapper macros and functions are designed to allow a program - * to perform file I/O with identical semantics and syntax regardless - * of whether PhysicsFS is being used or not. - */ -#ifndef _ABS_FILE_H -#define _ABS_FILE_H - -#ifdef _MSC_VER - typedef unsigned char uint8_t; - typedef unsigned long int uint64_t; - typedef unsigned int uint32_t; - typedef int int32_t; - typedef unsigned short uint16_t; - typedef short int16_t; -#else -#include <stdint.h> - -#endif - -/* -PLEASE NOTE: This license applies to abs-file.h ONLY; The version of -PhysicsFS itself which you are using may have been released under a -license with additional restrictions. - -Copyright (C) 2002-2004 Adam D. Moss (the "Author"). All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is fur- -nished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT- -NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON- -NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of the Author of the -Software shall not be used in advertising or otherwise to promote the sale, -use or other dealings in this Software without prior written authorization -from the Author. -*/ - -#include <stdlib.h> -#include <stdio.h> - -/* - * API: - * - * Macro/function use like stdio equivalent... - * -------------- ---------------------------- - * MY_FILETYPE FILE - * MY_OPEN_FOR_READ fopen(..., "rb") - * MY_READ fread(...) - * MY_GETC fgetc(...) - * MY_GETS fgets(...) - * MY_OPEN_FOR_WRITE fopen(..., "wb") - * MY_WRITE fwrite(...) - * MY_PUTC fputc(...) - * MY_PUTS fputs(...) - * MY_CLOSE fclose(...) - * MY_ATEOF feof(...) - * MY_TELL ftell(...) - * MY_SEEK fseek(..., SEEK_SET) - * MY_REWIND rewind(...) - * MY_SETBUFFER (not a standard for stdio, does nothing there) - * MY_FILELENGTH (not a standard for stdio, but implemented anyway) - */ - -/* - * Important DEFINEs: - * - * It is important to define these consistantly across the various - * compilation modules of your program if you wish to exchange file - * handles between them. - * - * USE_PHYSFS: Define USE_PHYSFS if PhysicsFS is being used; note that if - * you do intend to use PhysicsFS then you will still need to initialize - * PhysicsFS yourself and set up its search-paths. - * - * Optional DEFINEs: - * - * PHYSFS_DEFAULT_BUFFER_SIZE <bytes>: If set then abs-file.h sets the - * PhysicsFS buffer size to this value whenever you open a file. You - * may over-ride this on a per-filehandle basis by using the - * MY_SETBUFFER() macro (which simply does nothing when not using - * PhysicsFS). If you have not defined this value explicitly then - * abs-file.h will default to the same default buffer size as used by - * stdio if it can be determined, or 8192 bytes otherwise. - */ - -#ifndef PHYSFS_DEFAULT_BUFFER_SIZE -#ifdef BUFSIZ -#define PHYSFS_DEFAULT_BUFFER_SIZE BUFSIZ -#else -#define PHYSFS_DEFAULT_BUFFER_SIZE 8192 -#endif -#endif - -#ifdef USE_PHYSFS - -#include <physfs.h> -#define MY_FILETYPE PHYSFS_file -#define MY_SETBUFFER(fp,size) PHYSFS_setBuffer(fp,size) -#define MY_READ(p,s,n,fp) PHYSFS_read(fp,p,s,n) -#define MY_WRITE(p,s,n,fp) PHYSFS_write(fp,p,s,n) -#if PHYSFS_DEFAULT_BUFFER_SIZE -static MY_FILETYPE* MY_OPEN_FOR_READ(const char *const filename) -{ - MY_FILETYPE *const file = PHYSFS_openRead(filename); - if (file) { - MY_SETBUFFER(file, PHYSFS_DEFAULT_BUFFER_SIZE); - } - return file; -} -static MY_FILETYPE* MY_OPEN_FOR_WRITE(const char *const filename) -{ - MY_FILETYPE *const file = PHYSFS_openWrite(filename); - if (file) { - MY_SETBUFFER(file, PHYSFS_DEFAULT_BUFFER_SIZE); - } - return file; -} -#else -#define MY_OPEN_FOR_READ(fn) PHYSFS_openRead(fn) -#define MY_OPEN_FOR_WRITE(fn) PHYSFS_openWrite(fn) -#endif -static int MY_GETC(MY_FILETYPE *const fp) { - unsigned char c; - /*if (PHYSFS_eof(fp)) { - return EOF; - } - MY_READ(&c, 1, 1, fp);*/ - if (MY_READ(&c, 1, 1, fp) != 1) { - return EOF; - } - return c; -} -static char * MY_GETS(char * const str, const int size, - MY_FILETYPE *const fp) { - int i = 0; - int c; - do { - if (i == size-1) { - break; - } - c = MY_GETC(fp); - if (c == EOF) { - break; - } - str[i++] = c; - } while (c != '\0' && - c != -1 && - c != '\n'); - str[i] = '\0'; - if (i == 0) { - return NULL; - } - return str; -} -static int MY_PUTC(int c, MY_FILETYPE *const fp) { - unsigned char cc = (unsigned char)c; - if (MY_WRITE(&cc, 1, 1, fp) != 1) { - return EOF; - } - return (int)cc; -} -static int MY_PUTS(const char *s, MY_FILETYPE *const fp) { - int i = 0; - while (s[i] != '\0') { - if (MY_PUTC(s[i], fp) == EOF) { - return EOF; - } - ++i; - } - if (MY_PUTC('\n', fp) == EOF) { - return EOF; - } - return 0; -} -#define MY_CLOSE(fp) (0==PHYSFS_close(fp)) -#define MY_ATEOF(fp) PHYSFS_eof(fp) -#define MY_TELL(fp) PHYSFS_tell(fp) -#define MY_SEEK(fp,o) (0==PHYSFS_seek(fp,o)) -#define MY_REWIND(fp) MY_SEEK(fp,0) -#define MY_FILELENGTH(fp) PHYSFS_fileLength(fp) - -#else /* !USE_PHYSFS */ - -//#define USE_POSIX_FILES 1 -#ifdef USE_POSIX_FILES -#define MY_FILETYPE FILE -#define MY_READ(p,s,n,fp) fread(p,s,n,fp) -#define MY_WRITE(p,s,n,fp) fwrite(p,s,n,fp) -#define MY_OPEN_FOR_READ(n) fopen(n, "rb") -#define MY_OPEN_FOR_WRITE(n) fopen(n, "wb") -#define MY_GETC(fp) fgetc(fp) -#define MY_GETS(str,size,fp) fgets(str,size,fp) -#define MY_PUTC(c,fp) fputc(c,fp) -#define MY_PUTS(str,fp) fput(str,fp) -#define MY_CLOSE(fp) fclose(fp) -#define MY_ATEOF(fp) feof(fp) -#define MY_TELL(fp) ftell(fp) -#define MY_SEEK(fp,o) fseek(fp,o, SEEK_SET) -#define MY_REWIND(fp) rewind(fp) -#define MY_SETBUFFER(fp,size) -/* a TODO from ryan: "seeking to the end followed by an ftell() is probably -more portable, but you can also use fileno() to get a handle from a -(FILE *) to use with fstat()...on supported platforms, that is, most -platforms, this is probably faster." */ -static long MY_FILELENGTH(FILE *fp) { - long currentpos = ftell(fp); /* save current cursor position */ - long newpos; - fseek(fp, 0, SEEK_END); /* seek to end */ - newpos = ftell(fp); /* find position of end -- this is the length */ - fseek(fp, currentpos, SEEK_SET); /* restore previous cursor position */ - return newpos; -} -#else -#include <string.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#define MY_FILETYPE char - - -long MY_FILELENGTH(FILE *fp); -MY_FILETYPE* MY_FILE_OPEN_FOR_READ(FILE* fp); -MY_FILETYPE* MY_OPEN_FOR_READ(const char *const filename); -int MY_GETC(MY_FILETYPE *const fp); -void MY_SEEK(MY_FILETYPE* fp,int pos); -#define MY_REWIND(fp) MY_SEEK(fp,0) -int MY_READ(unsigned char* dest,int size,int num,MY_FILETYPE* fp); -unsigned char* MY_FAKE_READ(int size,int num,MY_FILETYPE* fp); - -void MY_CLOSE(MY_FILETYPE* fp); -int MY_TELL(MY_FILETYPE* fp); -int MY_ATEOF(MY_FILETYPE* fp); - -#ifdef __cplusplus -} -#endif - -#endif //USE_POSIX_FILES - -#endif /* USE_PHYSFS */ - -#endif /* _ABS_FILE_H */ diff --git a/gamekit/autogenerated/blender.h b/gamekit/autogenerated/blender.h deleted file mode 100644 index c1fda47a9..000000000 --- a/gamekit/autogenerated/blender.h +++ /dev/null @@ -1,335 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_H__ -#define __BLENDER_H__ -#include "blender_Link.h" -#include "blender_LinkData.h" -#include "blender_ListBase.h" -#include "blender_vec2s.h" -#include "blender_vec2i.h" -#include "blender_vec2f.h" -#include "blender_vec2d.h" -#include "blender_vec3i.h" -#include "blender_vec3f.h" -#include "blender_vec3d.h" -#include "blender_vec4i.h" -#include "blender_vec4f.h" -#include "blender_vec4d.h" -#include "blender_rcti.h" -#include "blender_rctf.h" -#include "blender_IDPropertyData.h" -#include "blender_IDProperty.h" -#include "blender_ID.h" -#include "blender_Library.h" -#include "blender_PreviewImage.h" -#include "blender_IpoDriver.h" -#include "blender_IpoCurve.h" -#include "blender_Ipo.h" -#include "blender_KeyBlock.h" -#include "blender_Key.h" -#include "blender_ScriptLink.h" -#include "blender_TextLine.h" -#include "blender_TextMarker.h" -#include "blender_Text.h" -#include "blender_PackedFile.h" -#include "blender_Camera.h" -#include "blender_ImageUser.h" -#include "blender_Image.h" -#include "blender_MTex.h" -#include "blender_PluginTex.h" -#include "blender_CBData.h" -#include "blender_ColorBand.h" -#include "blender_EnvMap.h" -#include "blender_Tex.h" -#include "blender_TexMapping.h" -#include "blender_Lamp.h" -#include "blender_Wave.h" -#include "blender_Material.h" -#include "blender_VFont.h" -#include "blender_MetaElem.h" -#include "blender_MetaBall.h" -#include "blender_BezTriple.h" -#include "blender_BPoint.h" -#include "blender_Nurb.h" -#include "blender_CharInfo.h" -#include "blender_TextBox.h" -#include "blender_Curve.h" -#include "blender_Mesh.h" -#include "blender_TFace.h" -#include "blender_MFace.h" -#include "blender_MEdge.h" -#include "blender_MDeformWeight.h" -#include "blender_MDeformVert.h" -#include "blender_MVert.h" -#include "blender_MCol.h" -#include "blender_MTexPoly.h" -#include "blender_MLoopUV.h" -#include "blender_MLoopCol.h" -#include "blender_MSticky.h" -#include "blender_MSelect.h" -#include "blender_MTFace.h" -#include "blender_MFloatProperty.h" -#include "blender_MIntProperty.h" -#include "blender_MStringProperty.h" -#include "blender_OrigSpaceFace.h" -#include "blender_MultiresCol.h" -#include "blender_MultiresColFace.h" -#include "blender_MultiresFace.h" -#include "blender_MultiresEdge.h" -#include "blender_MultiresLevel.h" -#include "blender_Multires.h" -#include "blender_PartialVisibility.h" -#include "blender_ModifierData.h" -#include "blender_SubsurfModifierData.h" -#include "blender_LatticeModifierData.h" -#include "blender_CurveModifierData.h" -#include "blender_BuildModifierData.h" -#include "blender_MaskModifierData.h" -#include "blender_ArrayModifierData.h" -#include "blender_MirrorModifierData.h" -#include "blender_EdgeSplitModifierData.h" -#include "blender_BevelModifierData.h" -#include "blender_BMeshModifierData.h" -#include "blender_DisplaceModifierData.h" -#include "blender_UVProjectModifierData.h" -#include "blender_DecimateModifierData.h" -#include "blender_SmoothModifierData.h" -#include "blender_CastModifierData.h" -#include "blender_WaveModifierData.h" -#include "blender_ArmatureModifierData.h" -#include "blender_HookModifierData.h" -#include "blender_SoftbodyModifierData.h" -#include "blender_ClothModifierData.h" -#include "blender_CollisionModifierData.h" -#include "blender_SurfaceModifierData.h" -#include "blender_BooleanModifierData.h" -#include "blender_MDefInfluence.h" -#include "blender_MDefCell.h" -#include "blender_MeshDeformModifierData.h" -#include "blender_ParticleSystemModifierData.h" -#include "blender_ParticleInstanceModifierData.h" -#include "blender_ExplodeModifierData.h" -#include "blender_FluidsimModifierData.h" -#include "blender_ShrinkwrapModifierData.h" -#include "blender_SimpleDeformModifierData.h" -#include "blender_Lattice.h" -#include "blender_bDeformGroup.h" -#include "blender_BoundBox.h" -#include "blender_Object.h" -#include "blender_ObHook.h" -#include "blender_PartDeflect.h" -#include "blender_PointCache.h" -#include "blender_SBVertex.h" -#include "blender_BulletSoftBody.h" -#include "blender_SoftBody.h" -#include "blender_FluidsimSettings.h" -#include "blender_World.h" -#include "blender_Radio.h" -#include "blender_Base.h" -#include "blender_AviCodecData.h" -#include "blender_QuicktimeCodecData.h" -#include "blender_FFMpegCodecData.h" -#include "blender_AudioData.h" -#include "blender_SceneRenderLayer.h" -#include "blender_RenderData.h" -#include "blender_RenderProfile.h" -#include "blender_GameFraming.h" -#include "blender_TimeMarker.h" -#include "blender_ImagePaintSettings.h" -#include "blender_ParticleBrushData.h" -#include "blender_ParticleEditSettings.h" -#include "blender_TransformOrientation.h" -#include "blender_ToolSettings.h" -#include "blender_BrushData.h" -#include "blender_SculptData.h" -#include "blender_Scene.h" -#include "blender_BGpic.h" -#include "blender_View3D.h" -#include "blender_View2D.h" -#include "blender_SpaceLink.h" -#include "blender_SpaceInfo.h" -#include "blender_SpaceIpo.h" -#include "blender_SpaceButs.h" -#include "blender_SpaceSeq.h" -#include "blender_SpaceFile.h" -#include "blender_SpaceOops.h" -#include "blender_SpaceImage.h" -#include "blender_SpaceNla.h" -#include "blender_SpaceText.h" -#include "blender_Script.h" -#include "blender_SpaceScript.h" -#include "blender_SpaceTime.h" -#include "blender_SpaceNode.h" -#include "blender_SpaceImaSel.h" -#include "blender_ThemeUI.h" -#include "blender_ThemeSpace.h" -#include "blender_ThemeWireColor.h" -#include "blender_bTheme.h" -#include "blender_SolidLight.h" -#include "blender_UserDef.h" -#include "blender_bScreen.h" -#include "blender_ScrVert.h" -#include "blender_ScrEdge.h" -#include "blender_Panel.h" -#include "blender_ScrArea.h" -#include "blender_FileGlobal.h" -#include "blender_StripElem.h" -#include "blender_TStripElem.h" -#include "blender_StripCrop.h" -#include "blender_StripTransform.h" -#include "blender_StripColorBalance.h" -#include "blender_StripProxy.h" -#include "blender_Strip.h" -#include "blender_PluginSeq.h" -#include "blender_Sequence.h" -#include "blender_MetaStack.h" -#include "blender_Editing.h" -#include "blender_WipeVars.h" -#include "blender_GlowVars.h" -#include "blender_TransformVars.h" -#include "blender_SolidColorVars.h" -#include "blender_SpeedControlVars.h" -#include "blender_Effect.h" -#include "blender_BuildEff.h" -#include "blender_PartEff.h" -#include "blender_WaveEff.h" -#include "blender_TreeStoreElem.h" -#include "blender_TreeStore.h" -#include "blender_Oops.h" -#include "blender_bProperty.h" -#include "blender_bNearSensor.h" -#include "blender_bMouseSensor.h" -#include "blender_bTouchSensor.h" -#include "blender_bKeyboardSensor.h" -#include "blender_bPropertySensor.h" -#include "blender_bActuatorSensor.h" -#include "blender_bDelaySensor.h" -#include "blender_bCollisionSensor.h" -#include "blender_bRadarSensor.h" -#include "blender_bRandomSensor.h" -#include "blender_bRaySensor.h" -#include "blender_bMessageSensor.h" -#include "blender_bSensor.h" -#include "blender_bJoystickSensor.h" -#include "blender_bExpressionCont.h" -#include "blender_bPythonCont.h" -#include "blender_bController.h" -#include "blender_bAddObjectActuator.h" -#include "blender_bActionActuator.h" -#include "blender_bSoundActuator.h" -#include "blender_bCDActuator.h" -#include "blender_bEditObjectActuator.h" -#include "blender_bSceneActuator.h" -#include "blender_bPropertyActuator.h" -#include "blender_bObjectActuator.h" -#include "blender_bIpoActuator.h" -#include "blender_bCameraActuator.h" -#include "blender_bConstraintActuator.h" -#include "blender_bGroupActuator.h" -#include "blender_bRandomActuator.h" -#include "blender_bMessageActuator.h" -#include "blender_bGameActuator.h" -#include "blender_bVisibilityActuator.h" -#include "blender_bTwoDFilterActuator.h" -#include "blender_bParentActuator.h" -#include "blender_bStateActuator.h" -#include "blender_bActuator.h" -#include "blender_FreeCamera.h" -#include "blender_bSound.h" -#include "blender_bSoundListener.h" -#include "blender_SpaceSound.h" -#include "blender_GroupObject.h" -#include "blender_Group.h" -#include "blender_Bone.h" -#include "blender_bArmature.h" -#include "blender_bPoseChannel.h" -#include "blender_bPose.h" -#include "blender_bActionGroup.h" -#include "blender_bActionChannel.h" -#include "blender_bAction.h" -#include "blender_SpaceAction.h" -#include "blender_bConstraintChannel.h" -#include "blender_bConstraint.h" -#include "blender_bConstraintTarget.h" -#include "blender_bPythonConstraint.h" -#include "blender_bKinematicConstraint.h" -#include "blender_bTrackToConstraint.h" -#include "blender_bRotateLikeConstraint.h" -#include "blender_bLocateLikeConstraint.h" -#include "blender_bMinMaxConstraint.h" -#include "blender_bSizeLikeConstraint.h" -#include "blender_bActionConstraint.h" -#include "blender_bLockTrackConstraint.h" -#include "blender_bFollowPathConstraint.h" -#include "blender_bStretchToConstraint.h" -#include "blender_bRigidBodyJointConstraint.h" -#include "blender_bClampToConstraint.h" -#include "blender_bChildOfConstraint.h" -#include "blender_bTransformConstraint.h" -#include "blender_bLocLimitConstraint.h" -#include "blender_bRotLimitConstraint.h" -#include "blender_bSizeLimitConstraint.h" -#include "blender_bDistLimitConstraint.h" -#include "blender_bShrinkwrapConstraint.h" -#include "blender_bActionModifier.h" -#include "blender_bActionStrip.h" -#include "blender_bNodeStack.h" -#include "blender_bNodeSocket.h" -#include "blender_bNode.h" -#include "blender_bNodeLink.h" -#include "blender_bNodeTree.h" -#include "blender_NodeImageAnim.h" -#include "blender_NodeBlurData.h" -#include "blender_NodeDBlurData.h" -#include "blender_NodeBilateralBlurData.h" -#include "blender_NodeHueSat.h" -#include "blender_NodeImageFile.h" -#include "blender_NodeChroma.h" -#include "blender_NodeTwoXYs.h" -#include "blender_NodeTwoFloats.h" -#include "blender_NodeGeometry.h" -#include "blender_NodeVertexCol.h" -#include "blender_NodeDefocus.h" -#include "blender_NodeScriptDict.h" -#include "blender_NodeGlare.h" -#include "blender_NodeTonemap.h" -#include "blender_NodeLensDist.h" -#include "blender_TexNodeOutput.h" -#include "blender_CurveMapPoint.h" -#include "blender_CurveMap.h" -#include "blender_CurveMapping.h" -#include "blender_BrushClone.h" -#include "blender_Brush.h" -#include "blender_CustomDataLayer.h" -#include "blender_CustomData.h" -#include "blender_HairKey.h" -#include "blender_ParticleKey.h" -#include "blender_ChildParticle.h" -#include "blender_ParticleData.h" -#include "blender_ParticleSettings.h" -#include "blender_ParticleSystem.h" -#include "blender_ClothSimSettings.h" -#include "blender_ClothCollSettings.h" -#include "blender_bGPDspoint.h" -#include "blender_bGPDstroke.h" -#include "blender_bGPDframe.h" -#include "blender_bGPDlayer.h" -#include "blender_bGPdata.h" -#endif//__BLENDER_H__ \ No newline at end of file diff --git a/gamekit/autogenerated/blender_ArmatureModifierData.h b/gamekit/autogenerated/blender_ArmatureModifierData.h deleted file mode 100644 index 3007b960f..000000000 --- a/gamekit/autogenerated/blender_ArmatureModifierData.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_ARMATUREMODIFIERDATA__H__ -#define __BLENDER_ARMATUREMODIFIERDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ModifierData.h" - -namespace Blender { - - - // ---------------------------------------------- // - class ArmatureModifierData - { - public: - ModifierData modifier; - short deformflag; - short multi; - int pad2; - Object *object; - float *prevCos; - char defgrp_name[32]; - }; -} - - -#endif//__BLENDER_ARMATUREMODIFIERDATA__H__ diff --git a/gamekit/autogenerated/blender_ArrayModifierData.h b/gamekit/autogenerated/blender_ArrayModifierData.h deleted file mode 100644 index eeff38daf..000000000 --- a/gamekit/autogenerated/blender_ArrayModifierData.h +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_ARRAYMODIFIERDATA__H__ -#define __BLENDER_ARRAYMODIFIERDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ModifierData.h" - -namespace Blender { - - - // ---------------------------------------------- // - class ArrayModifierData - { - public: - ModifierData modifier; - Object *start_cap; - Object *end_cap; - Object *curve_ob; - Object *offset_ob; - vec3f offset; - vec3f scale; - float length; - float merge_dist; - int fit_type; - int offset_type; - int flags; - int count; - }; -} - - -#endif//__BLENDER_ARRAYMODIFIERDATA__H__ diff --git a/gamekit/autogenerated/blender_AudioData.h b/gamekit/autogenerated/blender_AudioData.h deleted file mode 100644 index 66f94ebc4..000000000 --- a/gamekit/autogenerated/blender_AudioData.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_AUDIODATA__H__ -#define __BLENDER_AUDIODATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class AudioData - { - public: - int mixrate; - float main; - short flag; - short pad[3]; - }; -} - - -#endif//__BLENDER_AUDIODATA__H__ diff --git a/gamekit/autogenerated/blender_AviCodecData.h b/gamekit/autogenerated/blender_AviCodecData.h deleted file mode 100644 index 5f1d58ecf..000000000 --- a/gamekit/autogenerated/blender_AviCodecData.h +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_AVICODECDATA__H__ -#define __BLENDER_AVICODECDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class AviCodecData - { - public: - void *lpFormat; - void *lpParms; - int cbFormat; - int cbParms; - int fccType; - int fccHandler; - int dwKeyFrameEvery; - int dwQuality; - int dwBytesPerSecond; - int dwFlags; - int dwInterleaveEvery; - int pad; - char avicodecname[128]; - }; -} - - -#endif//__BLENDER_AVICODECDATA__H__ diff --git a/gamekit/autogenerated/blender_BGpic.h b/gamekit/autogenerated/blender_BGpic.h deleted file mode 100644 index 51601d370..000000000 --- a/gamekit/autogenerated/blender_BGpic.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BGPIC__H__ -#define __BLENDER_BGPIC__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ImageUser.h" - -namespace Blender { - - - // ---------------------------------------------- // - class BGpic - { - public: - Image *ima; - ImageUser iuser; - float xof; - float yof; - float size; - float zoom; - float blend; - short xim; - short yim; - }; -} - - -#endif//__BLENDER_BGPIC__H__ diff --git a/gamekit/autogenerated/blender_BMeshModifierData.h b/gamekit/autogenerated/blender_BMeshModifierData.h deleted file mode 100644 index 1f622f0cc..000000000 --- a/gamekit/autogenerated/blender_BMeshModifierData.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BMESHMODIFIERDATA__H__ -#define __BLENDER_BMESHMODIFIERDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ModifierData.h" - -namespace Blender { - - - // ---------------------------------------------- // - class BMeshModifierData - { - public: - ModifierData modifier; - float pad; - int type; - }; -} - - -#endif//__BLENDER_BMESHMODIFIERDATA__H__ diff --git a/gamekit/autogenerated/blender_BPoint.h b/gamekit/autogenerated/blender_BPoint.h deleted file mode 100644 index f18ce3320..000000000 --- a/gamekit/autogenerated/blender_BPoint.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BPOINT__H__ -#define __BLENDER_BPOINT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class BPoint - { - public: - vec4f vec; - float alfa; - float weight; - short f1; - short hide; - float radius; - float pad; - }; -} - - -#endif//__BLENDER_BPOINT__H__ diff --git a/gamekit/autogenerated/blender_Base.h b/gamekit/autogenerated/blender_Base.h deleted file mode 100644 index f4297e26a..000000000 --- a/gamekit/autogenerated/blender_Base.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BASE__H__ -#define __BLENDER_BASE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class Base - { - public: - Base *next; - Base *prev; - int lay; - int selcol; - int flag; - short sx; - short sy; - Object *object; - }; -} - - -#endif//__BLENDER_BASE__H__ diff --git a/gamekit/autogenerated/blender_BevelModifierData.h b/gamekit/autogenerated/blender_BevelModifierData.h deleted file mode 100644 index e80342d54..000000000 --- a/gamekit/autogenerated/blender_BevelModifierData.h +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BEVELMODIFIERDATA__H__ -#define __BLENDER_BEVELMODIFIERDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ModifierData.h" - -namespace Blender { - - - // ---------------------------------------------- // - class BevelModifierData - { - public: - ModifierData modifier; - float value; - int res; - int pad; - short flags; - short val_flags; - short lim_flags; - short e_flags; - float bevel_angle; - char defgrp_name[32]; - }; -} - - -#endif//__BLENDER_BEVELMODIFIERDATA__H__ diff --git a/gamekit/autogenerated/blender_BezTriple.h b/gamekit/autogenerated/blender_BezTriple.h deleted file mode 100644 index b33fb9ab8..000000000 --- a/gamekit/autogenerated/blender_BezTriple.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BEZTRIPLE__H__ -#define __BLENDER_BEZTRIPLE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class BezTriple - { - public: - float vec[3][3]; - float alfa; - float weight; - float radius; - short h1; - short h2; - char f1; - char f2; - char f3; - char hide; - }; -} - - -#endif//__BLENDER_BEZTRIPLE__H__ diff --git a/gamekit/autogenerated/blender_Bone.h b/gamekit/autogenerated/blender_Bone.h deleted file mode 100644 index d59ae625e..000000000 --- a/gamekit/autogenerated/blender_Bone.h +++ /dev/null @@ -1,64 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BONE__H__ -#define __BLENDER_BONE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ListBase.h" - -namespace Blender { - - - // ---------------------------------------------- // - class Bone - { - public: - Bone *next; - Bone *prev; - Bone *parent; - ListBase childbase; - char name[32]; - float roll; - vec3f head; - vec3f tail; - float bone_mat[3][3]; - int flag; - vec3f arm_head; - vec3f arm_tail; - float arm_mat[4][4]; - float dist; - float weight; - float xwidth; - float length; - float zwidth; - float ease1; - float ease2; - float rad_head; - float rad_tail; - vec3f size; - short layer; - short segments; - }; -} - - -#endif//__BLENDER_BONE__H__ diff --git a/gamekit/autogenerated/blender_BooleanModifierData.h b/gamekit/autogenerated/blender_BooleanModifierData.h deleted file mode 100644 index 6978b99ed..000000000 --- a/gamekit/autogenerated/blender_BooleanModifierData.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BOOLEANMODIFIERDATA__H__ -#define __BLENDER_BOOLEANMODIFIERDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ModifierData.h" - -namespace Blender { - - - // ---------------------------------------------- // - class BooleanModifierData - { - public: - ModifierData modifier; - Object *object; - int operation; - int pad; - }; -} - - -#endif//__BLENDER_BOOLEANMODIFIERDATA__H__ diff --git a/gamekit/autogenerated/blender_BoundBox.h b/gamekit/autogenerated/blender_BoundBox.h deleted file mode 100644 index 43a8b7d03..000000000 --- a/gamekit/autogenerated/blender_BoundBox.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BOUNDBOX__H__ -#define __BLENDER_BOUNDBOX__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class BoundBox - { - public: - float vec[8][3]; - int flag; - int pad; - }; -} - - -#endif//__BLENDER_BOUNDBOX__H__ diff --git a/gamekit/autogenerated/blender_Brush.h b/gamekit/autogenerated/blender_Brush.h deleted file mode 100644 index bc27b7989..000000000 --- a/gamekit/autogenerated/blender_Brush.h +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BRUSH__H__ -#define __BLENDER_BRUSH__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_BrushClone.h" -#include "blender_ID.h" - -namespace Blender { - - - // ---------------------------------------------- // - class Brush - { - public: - ID id; - short flag; - short blend; - int size; - float innerradius; - float spacing; - float rate; - vec3f rgb; - float alpha; - short texact; - short pad; - MTex *mtex[18]; - BrushClone clone; - }; -} - - -#endif//__BLENDER_BRUSH__H__ diff --git a/gamekit/autogenerated/blender_BrushClone.h b/gamekit/autogenerated/blender_BrushClone.h deleted file mode 100644 index 4bea608eb..000000000 --- a/gamekit/autogenerated/blender_BrushClone.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BRUSHCLONE__H__ -#define __BLENDER_BRUSHCLONE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class BrushClone - { - public: - Image *image; - float offset[2]; - float alpha; - float pad; - }; -} - - -#endif//__BLENDER_BRUSHCLONE__H__ diff --git a/gamekit/autogenerated/blender_BrushData.h b/gamekit/autogenerated/blender_BrushData.h deleted file mode 100644 index 0b6985b2f..000000000 --- a/gamekit/autogenerated/blender_BrushData.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BRUSHDATA__H__ -#define __BLENDER_BRUSHDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class BrushData - { - public: - short size; - char strength; - char dir; - char view; - char flag; - char pad[2]; - }; -} - - -#endif//__BLENDER_BRUSHDATA__H__ diff --git a/gamekit/autogenerated/blender_BuildEff.h b/gamekit/autogenerated/blender_BuildEff.h deleted file mode 100644 index 085addc86..000000000 --- a/gamekit/autogenerated/blender_BuildEff.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BUILDEFF__H__ -#define __BLENDER_BUILDEFF__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class BuildEff - { - public: - BuildEff *next; - BuildEff *prev; - short type; - short flag; - short buttype; - short rt; - float len; - float sfra; - }; -} - - -#endif//__BLENDER_BUILDEFF__H__ diff --git a/gamekit/autogenerated/blender_BuildModifierData.h b/gamekit/autogenerated/blender_BuildModifierData.h deleted file mode 100644 index 4fc40adf1..000000000 --- a/gamekit/autogenerated/blender_BuildModifierData.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BUILDMODIFIERDATA__H__ -#define __BLENDER_BUILDMODIFIERDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ModifierData.h" - -namespace Blender { - - - // ---------------------------------------------- // - class BuildModifierData - { - public: - ModifierData modifier; - float start; - float length; - int randomize; - int seed; - }; -} - - -#endif//__BLENDER_BUILDMODIFIERDATA__H__ diff --git a/gamekit/autogenerated/blender_BulletSoftBody.h b/gamekit/autogenerated/blender_BulletSoftBody.h deleted file mode 100644 index 7cc0bc984..000000000 --- a/gamekit/autogenerated/blender_BulletSoftBody.h +++ /dev/null @@ -1,68 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BULLETSOFTBODY__H__ -#define __BLENDER_BULLETSOFTBODY__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class BulletSoftBody - { - public: - int flag; - float linStiff; - float angStiff; - float volume; - int viterations; - int piterations; - int diterations; - int citerations; - float kSRHR_CL; - float kSKHR_CL; - float kSSHR_CL; - float kSR_SPLT_CL; - float kSK_SPLT_CL; - float kSS_SPLT_CL; - float kVCF; - float kDP; - float kDG; - float kLF; - float kPR; - float kVC; - float kDF; - float kMT; - float kCHR; - float kKHR; - float kSHR; - float kAHR; - int collisionflags; - int numclusteriterations; - float welding; - float margin; - }; -} - - -#endif//__BLENDER_BULLETSOFTBODY__H__ diff --git a/gamekit/autogenerated/blender_CBData.h b/gamekit/autogenerated/blender_CBData.h deleted file mode 100644 index 7397af49c..000000000 --- a/gamekit/autogenerated/blender_CBData.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_CBDATA__H__ -#define __BLENDER_CBDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class CBData - { - public: - float r; - float g; - float b; - float a; - float pos; - int cur; - }; -} - - -#endif//__BLENDER_CBDATA__H__ diff --git a/gamekit/autogenerated/blender_Camera.h b/gamekit/autogenerated/blender_Camera.h deleted file mode 100644 index 82b3548bb..000000000 --- a/gamekit/autogenerated/blender_Camera.h +++ /dev/null @@ -1,60 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_CAMERA__H__ -#define __BLENDER_CAMERA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ID.h" -#include "blender_ScriptLink.h" - -namespace Blender { - - - // ---------------------------------------------- // - class Camera - { - public: - ID id; - short type; - short flag; - float passepartalpha; - float angle; - float clipsta; - float clipend; - float lens; - float ortho_scale; - float drawsize; - float shiftx; - float shifty; - float YF_dofdist; - float YF_aperture; - short YF_bkhtype; - short YF_bkhbias; - float YF_bkhrot; - Ipo *ipo; - ScriptLink scriptlink; - Object *dof_ob; - }; -} - - -#endif//__BLENDER_CAMERA__H__ diff --git a/gamekit/autogenerated/blender_CastModifierData.h b/gamekit/autogenerated/blender_CastModifierData.h deleted file mode 100644 index 23787efe5..000000000 --- a/gamekit/autogenerated/blender_CastModifierData.h +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_CASTMODIFIERDATA__H__ -#define __BLENDER_CASTMODIFIERDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ModifierData.h" - -namespace Blender { - - - // ---------------------------------------------- // - class CastModifierData - { - public: - ModifierData modifier; - Object *object; - float fac; - float radius; - float size; - char defgrp_name[32]; - short flag; - short type; - }; -} - - -#endif//__BLENDER_CASTMODIFIERDATA__H__ diff --git a/gamekit/autogenerated/blender_CharInfo.h b/gamekit/autogenerated/blender_CharInfo.h deleted file mode 100644 index 8ce8cf980..000000000 --- a/gamekit/autogenerated/blender_CharInfo.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_CHARINFO__H__ -#define __BLENDER_CHARINFO__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class CharInfo - { - public: - short kern; - short mat_nr; - char flag; - char pad; - short pad2; - }; -} - - -#endif//__BLENDER_CHARINFO__H__ diff --git a/gamekit/autogenerated/blender_ChildParticle.h b/gamekit/autogenerated/blender_ChildParticle.h deleted file mode 100644 index bab66dba8..000000000 --- a/gamekit/autogenerated/blender_ChildParticle.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_CHILDPARTICLE__H__ -#define __BLENDER_CHILDPARTICLE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class ChildParticle - { - public: - int num; - int parent; - int pa[4]; - vec4f w; - vec4f fuv; - float foffset; - vec3f rand; - }; -} - - -#endif//__BLENDER_CHILDPARTICLE__H__ diff --git a/gamekit/autogenerated/blender_ClothCollSettings.h b/gamekit/autogenerated/blender_ClothCollSettings.h deleted file mode 100644 index e5fae62b8..000000000 --- a/gamekit/autogenerated/blender_ClothCollSettings.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_CLOTHCOLLSETTINGS__H__ -#define __BLENDER_CLOTHCOLLSETTINGS__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class ClothCollSettings - { - public: - bInvalidHandle *collision_list; - float epsilon; - float self_friction; - float friction; - float selfepsilon; - int flags; - short self_loop_count; - short loop_count; - }; -} - - -#endif//__BLENDER_CLOTHCOLLSETTINGS__H__ diff --git a/gamekit/autogenerated/blender_ClothModifierData.h b/gamekit/autogenerated/blender_ClothModifierData.h deleted file mode 100644 index 67e457b65..000000000 --- a/gamekit/autogenerated/blender_ClothModifierData.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_CLOTHMODIFIERDATA__H__ -#define __BLENDER_CLOTHMODIFIERDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ModifierData.h" - -namespace Blender { - - - // ---------------------------------------------- // - class ClothModifierData - { - public: - ModifierData modifier; - bInvalidHandle *clothObject; - ClothSimSettings *sim_parms; - ClothCollSettings *coll_parms; - PointCache *point_cache; - }; -} - - -#endif//__BLENDER_CLOTHMODIFIERDATA__H__ diff --git a/gamekit/autogenerated/blender_ClothSimSettings.h b/gamekit/autogenerated/blender_ClothSimSettings.h deleted file mode 100644 index 50a85dbd9..000000000 --- a/gamekit/autogenerated/blender_ClothSimSettings.h +++ /dev/null @@ -1,72 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_CLOTHSIMSETTINGS__H__ -#define __BLENDER_CLOTHSIMSETTINGS__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class ClothSimSettings - { - public: - bInvalidHandle *cache; - float mingoal; - float Cdis; - float Cvi; - float gravity; - vec3f unknown; - float dt; - float mass; - float structural; - float shear; - float bending; - float max_bend; - float max_struct; - float max_shear; - float avg_spring_len; - float timescale; - float maxgoal; - float eff_force_scale; - float eff_wind_scale; - float sim_time_old; - float defgoal; - float goalspring; - float goalfrict; - int stepsPerFrame; - int flags; - int preroll; - int maxspringlen; - short solver_type; - short vgroup_bend; - short vgroup_mass; - short vgroup_struct; - short presets; - short pad; - int pad2; - }; -} - - -#endif//__BLENDER_CLOTHSIMSETTINGS__H__ diff --git a/gamekit/autogenerated/blender_CollisionModifierData.h b/gamekit/autogenerated/blender_CollisionModifierData.h deleted file mode 100644 index 45d0f74f7..000000000 --- a/gamekit/autogenerated/blender_CollisionModifierData.h +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_COLLISIONMODIFIERDATA__H__ -#define __BLENDER_COLLISIONMODIFIERDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ModifierData.h" - -namespace Blender { - - - // ---------------------------------------------- // - class CollisionModifierData - { - public: - ModifierData modifier; - MVert *x; - MVert *xnew; - MVert *xold; - MVert *current_xnew; - MVert *current_x; - MVert *current_v; - MFace *mfaces; - int numverts; - int numfaces; - short absorption; - short pad; - float time; - bInvalidHandle *bvhtree; - }; -} - - -#endif//__BLENDER_COLLISIONMODIFIERDATA__H__ diff --git a/gamekit/autogenerated/blender_ColorBand.h b/gamekit/autogenerated/blender_ColorBand.h deleted file mode 100644 index 8ab167a64..000000000 --- a/gamekit/autogenerated/blender_ColorBand.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_COLORBAND__H__ -#define __BLENDER_COLORBAND__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_CBData.h" - -namespace Blender { - - - // ---------------------------------------------- // - class ColorBand - { - public: - short flag; - short tot; - short cur; - short ipotype; - CBData data[32]; - }; -} - - -#endif//__BLENDER_COLORBAND__H__ diff --git a/gamekit/autogenerated/blender_Common.h b/gamekit/autogenerated/blender_Common.h deleted file mode 100644 index 3094d680c..000000000 --- a/gamekit/autogenerated/blender_Common.h +++ /dev/null @@ -1,343 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDERCOMMON_H__ -#define __BLENDERCOMMON_H__ - -// put an empty struct in the case -typedef struct bInvalidHandle { - int unused; -}bInvalidHandle; - -namespace Blender { - class Link; - class LinkData; - class ListBase; - class vec2s; - class vec2i; - class vec2f; - class vec2d; - class vec3i; - class vec3f; - class vec3d; - class vec4i; - class vec4f; - class vec4d; - class rcti; - class rctf; - class IDPropertyData; - class IDProperty; - class ID; - class Library; - class PreviewImage; - class IpoDriver; - class IpoCurve; - class Ipo; - class KeyBlock; - class Key; - class ScriptLink; - class TextLine; - class TextMarker; - class Text; - class PackedFile; - class Camera; - class ImageUser; - class Image; - class MTex; - class PluginTex; - class CBData; - class ColorBand; - class EnvMap; - class Tex; - class TexMapping; - class Lamp; - class Wave; - class Material; - class VFont; - class MetaElem; - class MetaBall; - class BezTriple; - class BPoint; - class Nurb; - class CharInfo; - class TextBox; - class Curve; - class Mesh; - class TFace; - class MFace; - class MEdge; - class MDeformWeight; - class MDeformVert; - class MVert; - class MCol; - class MTexPoly; - class MLoopUV; - class MLoopCol; - class MSticky; - class MSelect; - class MTFace; - class MFloatProperty; - class MIntProperty; - class MStringProperty; - class OrigSpaceFace; - class MultiresCol; - class MultiresColFace; - class MultiresFace; - class MultiresEdge; - class MultiresLevel; - class Multires; - class PartialVisibility; - class ModifierData; - class SubsurfModifierData; - class LatticeModifierData; - class CurveModifierData; - class BuildModifierData; - class MaskModifierData; - class ArrayModifierData; - class MirrorModifierData; - class EdgeSplitModifierData; - class BevelModifierData; - class BMeshModifierData; - class DisplaceModifierData; - class UVProjectModifierData; - class DecimateModifierData; - class SmoothModifierData; - class CastModifierData; - class WaveModifierData; - class ArmatureModifierData; - class HookModifierData; - class SoftbodyModifierData; - class ClothModifierData; - class CollisionModifierData; - class SurfaceModifierData; - class BooleanModifierData; - class MDefInfluence; - class MDefCell; - class MeshDeformModifierData; - class ParticleSystemModifierData; - class ParticleInstanceModifierData; - class ExplodeModifierData; - class FluidsimModifierData; - class ShrinkwrapModifierData; - class SimpleDeformModifierData; - class Lattice; - class bDeformGroup; - class BoundBox; - class Object; - class ObHook; - class PartDeflect; - class PointCache; - class SBVertex; - class BulletSoftBody; - class SoftBody; - class FluidsimSettings; - class World; - class Radio; - class Base; - class AviCodecData; - class QuicktimeCodecData; - class FFMpegCodecData; - class AudioData; - class SceneRenderLayer; - class RenderData; - class RenderProfile; - class GameFraming; - class TimeMarker; - class ImagePaintSettings; - class ParticleBrushData; - class ParticleEditSettings; - class TransformOrientation; - class ToolSettings; - class BrushData; - class SculptData; - class Scene; - class BGpic; - class View3D; - class View2D; - class SpaceLink; - class SpaceInfo; - class SpaceIpo; - class SpaceButs; - class SpaceSeq; - class SpaceFile; - class SpaceOops; - class SpaceImage; - class SpaceNla; - class SpaceText; - class Script; - class SpaceScript; - class SpaceTime; - class SpaceNode; - class SpaceImaSel; - class ThemeUI; - class ThemeSpace; - class ThemeWireColor; - class bTheme; - class SolidLight; - class UserDef; - class bScreen; - class ScrVert; - class ScrEdge; - class Panel; - class ScrArea; - class FileGlobal; - class StripElem; - class TStripElem; - class StripCrop; - class StripTransform; - class StripColorBalance; - class StripProxy; - class Strip; - class PluginSeq; - class Sequence; - class MetaStack; - class Editing; - class WipeVars; - class GlowVars; - class TransformVars; - class SolidColorVars; - class SpeedControlVars; - class Effect; - class BuildEff; - class PartEff; - class WaveEff; - class TreeStoreElem; - class TreeStore; - class Oops; - class bProperty; - class bNearSensor; - class bMouseSensor; - class bTouchSensor; - class bKeyboardSensor; - class bPropertySensor; - class bActuatorSensor; - class bDelaySensor; - class bCollisionSensor; - class bRadarSensor; - class bRandomSensor; - class bRaySensor; - class bMessageSensor; - class bSensor; - class bJoystickSensor; - class bExpressionCont; - class bPythonCont; - class bController; - class bAddObjectActuator; - class bActionActuator; - class bSoundActuator; - class bCDActuator; - class bEditObjectActuator; - class bSceneActuator; - class bPropertyActuator; - class bObjectActuator; - class bIpoActuator; - class bCameraActuator; - class bConstraintActuator; - class bGroupActuator; - class bRandomActuator; - class bMessageActuator; - class bGameActuator; - class bVisibilityActuator; - class bTwoDFilterActuator; - class bParentActuator; - class bStateActuator; - class bActuator; - class FreeCamera; - class bSound; - class bSoundListener; - class SpaceSound; - class GroupObject; - class Group; - class Bone; - class bArmature; - class bPoseChannel; - class bPose; - class bActionGroup; - class bActionChannel; - class bAction; - class SpaceAction; - class bConstraintChannel; - class bConstraint; - class bConstraintTarget; - class bPythonConstraint; - class bKinematicConstraint; - class bTrackToConstraint; - class bRotateLikeConstraint; - class bLocateLikeConstraint; - class bMinMaxConstraint; - class bSizeLikeConstraint; - class bActionConstraint; - class bLockTrackConstraint; - class bFollowPathConstraint; - class bStretchToConstraint; - class bRigidBodyJointConstraint; - class bClampToConstraint; - class bChildOfConstraint; - class bTransformConstraint; - class bLocLimitConstraint; - class bRotLimitConstraint; - class bSizeLimitConstraint; - class bDistLimitConstraint; - class bShrinkwrapConstraint; - class bActionModifier; - class bActionStrip; - class bNodeStack; - class bNodeSocket; - class bNode; - class bNodeLink; - class bNodeTree; - class NodeImageAnim; - class NodeBlurData; - class NodeDBlurData; - class NodeBilateralBlurData; - class NodeHueSat; - class NodeImageFile; - class NodeChroma; - class NodeTwoXYs; - class NodeTwoFloats; - class NodeGeometry; - class NodeVertexCol; - class NodeDefocus; - class NodeScriptDict; - class NodeGlare; - class NodeTonemap; - class NodeLensDist; - class TexNodeOutput; - class CurveMapPoint; - class CurveMap; - class CurveMapping; - class BrushClone; - class Brush; - class CustomDataLayer; - class CustomData; - class HairKey; - class ParticleKey; - class ChildParticle; - class ParticleData; - class ParticleSettings; - class ParticleSystem; - class ClothSimSettings; - class ClothCollSettings; - class bGPDspoint; - class bGPDstroke; - class bGPDframe; - class bGPDlayer; - class bGPdata; -} -#endif//__BLENDERCOMMON_H__ \ No newline at end of file diff --git a/gamekit/autogenerated/blender_Curve.h b/gamekit/autogenerated/blender_Curve.h deleted file mode 100644 index 5a92c9819..000000000 --- a/gamekit/autogenerated/blender_Curve.h +++ /dev/null @@ -1,98 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_CURVE__H__ -#define __BLENDER_CURVE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_CharInfo.h" -#include "blender_ID.h" -#include "blender_ListBase.h" - -namespace Blender { - - - // ---------------------------------------------- // - class Curve - { - public: - ID id; - BoundBox *bb; - ListBase nurb; - ListBase disp; - Object *bevobj; - Object *taperobj; - Object *textoncurve; - Ipo *ipo; - bInvalidHandle *path; - Key *key; - Material **mat; - ListBase bev; - vec3f loc; - vec3f size; - vec3f rot; - int texflag; - short pathlen; - short totcol; - short flag; - short bevresol; - float width; - float ext1; - float ext2; - short resolu; - short resolv; - short resolu_ren; - short resolv_ren; - int pad2; - short len; - short lines; - short pos; - short spacemode; - float spacing; - float linedist; - float shear; - float fsize; - float wordspace; - float ulpos; - float ulheight; - float xof; - float yof; - float linewidth; - char *str; - char family[24]; - VFont *vfont; - VFont *vfontb; - VFont *vfonti; - VFont *vfontbi; - int sepchar; - int totbox; - int actbox; - int pad; - TextBox *tb; - int selstart; - int selend; - CharInfo *strinfo; - CharInfo curinfo; - }; -} - - -#endif//__BLENDER_CURVE__H__ diff --git a/gamekit/autogenerated/blender_CurveMap.h b/gamekit/autogenerated/blender_CurveMap.h deleted file mode 100644 index 320345077..000000000 --- a/gamekit/autogenerated/blender_CurveMap.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_CURVEMAP__H__ -#define __BLENDER_CURVEMAP__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class CurveMap - { - public: - short totpoint; - short flag; - float range; - float mintable; - float maxtable; - float ext_in[2]; - float ext_out[2]; - CurveMapPoint *curve; - CurveMapPoint *table; - CurveMapPoint *premultable; - }; -} - - -#endif//__BLENDER_CURVEMAP__H__ diff --git a/gamekit/autogenerated/blender_CurveMapPoint.h b/gamekit/autogenerated/blender_CurveMapPoint.h deleted file mode 100644 index 4546c77e3..000000000 --- a/gamekit/autogenerated/blender_CurveMapPoint.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_CURVEMAPPOINT__H__ -#define __BLENDER_CURVEMAPPOINT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class CurveMapPoint - { - public: - float x; - float y; - short flag; - short shorty; - }; -} - - -#endif//__BLENDER_CURVEMAPPOINT__H__ diff --git a/gamekit/autogenerated/blender_CurveMapping.h b/gamekit/autogenerated/blender_CurveMapping.h deleted file mode 100644 index b94a4d1bd..000000000 --- a/gamekit/autogenerated/blender_CurveMapping.h +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_CURVEMAPPING__H__ -#define __BLENDER_CURVEMAPPING__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_CurveMap.h" -#include "blender_rctf.h" - -namespace Blender { - - - // ---------------------------------------------- // - class CurveMapping - { - public: - int flag; - int cur; - rctf curr; - rctf clipr; - CurveMap cm[4]; - vec3f black; - vec3f white; - vec3f bwmul; - vec3f sample; - }; -} - - -#endif//__BLENDER_CURVEMAPPING__H__ diff --git a/gamekit/autogenerated/blender_CurveModifierData.h b/gamekit/autogenerated/blender_CurveModifierData.h deleted file mode 100644 index 971290de1..000000000 --- a/gamekit/autogenerated/blender_CurveModifierData.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_CURVEMODIFIERDATA__H__ -#define __BLENDER_CURVEMODIFIERDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ModifierData.h" - -namespace Blender { - - - // ---------------------------------------------- // - class CurveModifierData - { - public: - ModifierData modifier; - Object *object; - char name[32]; - short defaxis; - char pad[6]; - }; -} - - -#endif//__BLENDER_CURVEMODIFIERDATA__H__ diff --git a/gamekit/autogenerated/blender_CustomData.h b/gamekit/autogenerated/blender_CustomData.h deleted file mode 100644 index d69dfa448..000000000 --- a/gamekit/autogenerated/blender_CustomData.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_CUSTOMDATA__H__ -#define __BLENDER_CUSTOMDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class CustomData - { - public: - CustomDataLayer *layers; - int totlayer; - int maxlayer; - int totsize; - int pad; - void *pool; - }; -} - - -#endif//__BLENDER_CUSTOMDATA__H__ diff --git a/gamekit/autogenerated/blender_CustomDataLayer.h b/gamekit/autogenerated/blender_CustomDataLayer.h deleted file mode 100644 index b509d05b3..000000000 --- a/gamekit/autogenerated/blender_CustomDataLayer.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_CUSTOMDATALAYER__H__ -#define __BLENDER_CUSTOMDATALAYER__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class CustomDataLayer - { - public: - int type; - int offset; - int flag; - int active; - int active_rnd; - int active_clone; - int active_mask; - char pad[4]; - char name[32]; - void *data; - }; -} - - -#endif//__BLENDER_CUSTOMDATALAYER__H__ diff --git a/gamekit/autogenerated/blender_DecimateModifierData.h b/gamekit/autogenerated/blender_DecimateModifierData.h deleted file mode 100644 index 9be73c82d..000000000 --- a/gamekit/autogenerated/blender_DecimateModifierData.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_DECIMATEMODIFIERDATA__H__ -#define __BLENDER_DECIMATEMODIFIERDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ModifierData.h" - -namespace Blender { - - - // ---------------------------------------------- // - class DecimateModifierData - { - public: - ModifierData modifier; - float percent; - int faceCount; - }; -} - - -#endif//__BLENDER_DECIMATEMODIFIERDATA__H__ diff --git a/gamekit/autogenerated/blender_DisplaceModifierData.h b/gamekit/autogenerated/blender_DisplaceModifierData.h deleted file mode 100644 index 02b5d9d7c..000000000 --- a/gamekit/autogenerated/blender_DisplaceModifierData.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_DISPLACEMODIFIERDATA__H__ -#define __BLENDER_DISPLACEMODIFIERDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ModifierData.h" - -namespace Blender { - - - // ---------------------------------------------- // - class DisplaceModifierData - { - public: - ModifierData modifier; - Tex *texture; - float strength; - int direction; - char defgrp_name[32]; - float midlevel; - int texmapping; - Object *map_object; - char uvlayer_name[32]; - int uvlayer_tmp; - int pad; - }; -} - - -#endif//__BLENDER_DISPLACEMODIFIERDATA__H__ diff --git a/gamekit/autogenerated/blender_EdgeSplitModifierData.h b/gamekit/autogenerated/blender_EdgeSplitModifierData.h deleted file mode 100644 index c16c497d3..000000000 --- a/gamekit/autogenerated/blender_EdgeSplitModifierData.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_EDGESPLITMODIFIERDATA__H__ -#define __BLENDER_EDGESPLITMODIFIERDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ModifierData.h" - -namespace Blender { - - - // ---------------------------------------------- // - class EdgeSplitModifierData - { - public: - ModifierData modifier; - float split_angle; - int flags; - }; -} - - -#endif//__BLENDER_EDGESPLITMODIFIERDATA__H__ diff --git a/gamekit/autogenerated/blender_Editing.h b/gamekit/autogenerated/blender_Editing.h deleted file mode 100644 index a4a135075..000000000 --- a/gamekit/autogenerated/blender_Editing.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_EDITING__H__ -#define __BLENDER_EDITING__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ListBase.h" - -namespace Blender { - - - // ---------------------------------------------- // - class Editing - { - public: - ListBase *seqbasep; - ListBase seqbase; - ListBase metastack; - short flag; - short pad; - int rt; - }; -} - - -#endif//__BLENDER_EDITING__H__ diff --git a/gamekit/autogenerated/blender_Effect.h b/gamekit/autogenerated/blender_Effect.h deleted file mode 100644 index 01b69d950..000000000 --- a/gamekit/autogenerated/blender_Effect.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_EFFECT__H__ -#define __BLENDER_EFFECT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class Effect - { - public: - Effect *next; - Effect *prev; - short type; - short flag; - short buttype; - short rt; - }; -} - - -#endif//__BLENDER_EFFECT__H__ diff --git a/gamekit/autogenerated/blender_EnvMap.h b/gamekit/autogenerated/blender_EnvMap.h deleted file mode 100644 index d11a0a03d..000000000 --- a/gamekit/autogenerated/blender_EnvMap.h +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_ENVMAP__H__ -#define __BLENDER_ENVMAP__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class EnvMap - { - public: - Object *object; - Image *ima; - bInvalidHandle *cube[6]; - float imat[4][4]; - float obimat[3][3]; - short type; - short stype; - float clipsta; - float clipend; - float viewscale; - int notlay; - short cuberes; - short depth; - int ok; - int lastframe; - short recalc; - short lastsize; - }; -} - - -#endif//__BLENDER_ENVMAP__H__ diff --git a/gamekit/autogenerated/blender_ExplodeModifierData.h b/gamekit/autogenerated/blender_ExplodeModifierData.h deleted file mode 100644 index b1073d0f5..000000000 --- a/gamekit/autogenerated/blender_ExplodeModifierData.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_EXPLODEMODIFIERDATA__H__ -#define __BLENDER_EXPLODEMODIFIERDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ModifierData.h" - -namespace Blender { - - - // ---------------------------------------------- // - class ExplodeModifierData - { - public: - ModifierData modifier; - int *facepa; - short flag; - short vgroup; - float protect; - }; -} - - -#endif//__BLENDER_EXPLODEMODIFIERDATA__H__ diff --git a/gamekit/autogenerated/blender_FFMpegCodecData.h b/gamekit/autogenerated/blender_FFMpegCodecData.h deleted file mode 100644 index a343e8c8f..000000000 --- a/gamekit/autogenerated/blender_FFMpegCodecData.h +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_FFMPEGCODECDATA__H__ -#define __BLENDER_FFMPEGCODECDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class FFMpegCodecData - { - public: - int type; - int codec; - int audio_codec; - int video_bitrate; - int audio_bitrate; - int gop_size; - int flags; - int rc_min_rate; - int rc_max_rate; - int rc_buffer_size; - int mux_packet_size; - int mux_rate; - IDProperty *properties; - }; -} - - -#endif//__BLENDER_FFMPEGCODECDATA__H__ diff --git a/gamekit/autogenerated/blender_FileGlobal.h b/gamekit/autogenerated/blender_FileGlobal.h deleted file mode 100644 index b7d456784..000000000 --- a/gamekit/autogenerated/blender_FileGlobal.h +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_FILEGLOBAL__H__ -#define __BLENDER_FILEGLOBAL__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class FileGlobal - { - public: - char subvstr[4]; - short subversion; - short pads; - short minversion; - short minsubversion; - short displaymode; - short winpos; - void *curscreen; - void *curscene; - int fileflags; - int globalf; - }; -} - - -#endif//__BLENDER_FILEGLOBAL__H__ diff --git a/gamekit/autogenerated/blender_FluidsimModifierData.h b/gamekit/autogenerated/blender_FluidsimModifierData.h deleted file mode 100644 index 8fe1a4963..000000000 --- a/gamekit/autogenerated/blender_FluidsimModifierData.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_FLUIDSIMMODIFIERDATA__H__ -#define __BLENDER_FLUIDSIMMODIFIERDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ModifierData.h" - -namespace Blender { - - - // ---------------------------------------------- // - class FluidsimModifierData - { - public: - ModifierData modifier; - FluidsimSettings *fss; - PointCache *point_cache; - }; -} - - -#endif//__BLENDER_FLUIDSIMMODIFIERDATA__H__ diff --git a/gamekit/autogenerated/blender_FluidsimSettings.h b/gamekit/autogenerated/blender_FluidsimSettings.h deleted file mode 100644 index 0bb46f0cc..000000000 --- a/gamekit/autogenerated/blender_FluidsimSettings.h +++ /dev/null @@ -1,86 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_FLUIDSIMSETTINGS__H__ -#define __BLENDER_FLUIDSIMSETTINGS__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class FluidsimSettings - { - public: - short type; - short show_advancedoptions; - short resolutionxyz; - short previewresxyz; - float realsize; - short guiDisplayMode; - short renderDisplayMode; - float viscosityValue; - short viscosityMode; - short viscosityExponent; - float gravx; - float gravy; - float gravz; - float animStart; - float animEnd; - float gstar; - int maxRefine; - float iniVelx; - float iniVely; - float iniVelz; - Mesh *orgMesh; - Mesh *meshSurface; - Mesh *meshBB; - char surfdataPath[240]; - vec3f bbStart; - vec3f bbSize; - Ipo *ipo; - short typeFlags; - char domainNovecgen; - char volumeInitType; - float partSlipValue; - int generateTracers; - float generateParticles; - float surfaceSmoothing; - int surfaceSubdivs; - int flag; - float particleInfSize; - float particleInfAlpha; - float farFieldSize; - MVert *meshSurfNormals; - float cpsTimeStart; - float cpsTimeEnd; - float cpsQuality; - float attractforceStrength; - float attractforceRadius; - float velocityforceStrength; - float velocityforceRadius; - int lastgoodframe; - }; -} - - -#endif//__BLENDER_FLUIDSIMSETTINGS__H__ diff --git a/gamekit/autogenerated/blender_FreeCamera.h b/gamekit/autogenerated/blender_FreeCamera.h deleted file mode 100644 index 87fc1a47d..000000000 --- a/gamekit/autogenerated/blender_FreeCamera.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_FREECAMERA__H__ -#define __BLENDER_FREECAMERA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class FreeCamera - { - public: - float mass; - float accelleration; - float maxspeed; - float maxrotspeed; - float maxtiltspeed; - int flag; - float rotdamp; - float tiltdamp; - float speeddamp; - float pad; - }; -} - - -#endif//__BLENDER_FREECAMERA__H__ diff --git a/gamekit/autogenerated/blender_GameFraming.h b/gamekit/autogenerated/blender_GameFraming.h deleted file mode 100644 index dfb73d467..000000000 --- a/gamekit/autogenerated/blender_GameFraming.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_GAMEFRAMING__H__ -#define __BLENDER_GAMEFRAMING__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class GameFraming - { - public: - vec3f col; - char type; - char pad1; - char pad2; - char pad3; - }; -} - - -#endif//__BLENDER_GAMEFRAMING__H__ diff --git a/gamekit/autogenerated/blender_GlowVars.h b/gamekit/autogenerated/blender_GlowVars.h deleted file mode 100644 index bc0b1b15c..000000000 --- a/gamekit/autogenerated/blender_GlowVars.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_GLOWVARS__H__ -#define __BLENDER_GLOWVARS__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class GlowVars - { - public: - float fMini; - float fClamp; - float fBoost; - float dDist; - int dQuality; - int bNoComp; - }; -} - - -#endif//__BLENDER_GLOWVARS__H__ diff --git a/gamekit/autogenerated/blender_Group.h b/gamekit/autogenerated/blender_Group.h deleted file mode 100644 index b2a3fa114..000000000 --- a/gamekit/autogenerated/blender_Group.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_GROUP__H__ -#define __BLENDER_GROUP__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ID.h" -#include "blender_ListBase.h" - -namespace Blender { - - - // ---------------------------------------------- // - class Group - { - public: - ID id; - ListBase gobject; - int layer; - vec3f dupli_ofs; - }; -} - - -#endif//__BLENDER_GROUP__H__ diff --git a/gamekit/autogenerated/blender_GroupObject.h b/gamekit/autogenerated/blender_GroupObject.h deleted file mode 100644 index a63dffaa8..000000000 --- a/gamekit/autogenerated/blender_GroupObject.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_GROUPOBJECT__H__ -#define __BLENDER_GROUPOBJECT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class GroupObject - { - public: - GroupObject *next; - GroupObject *prev; - Object *ob; - void *lampren; - int recalc; - int pad; - }; -} - - -#endif//__BLENDER_GROUPOBJECT__H__ diff --git a/gamekit/autogenerated/blender_HairKey.h b/gamekit/autogenerated/blender_HairKey.h deleted file mode 100644 index 4d8c4527d..000000000 --- a/gamekit/autogenerated/blender_HairKey.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_HAIRKEY__H__ -#define __BLENDER_HAIRKEY__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class HairKey - { - public: - vec3f co; - float time; - float weight; - short editflag; - short pad; - }; -} - - -#endif//__BLENDER_HAIRKEY__H__ diff --git a/gamekit/autogenerated/blender_HookModifierData.h b/gamekit/autogenerated/blender_HookModifierData.h deleted file mode 100644 index e2677fb3f..000000000 --- a/gamekit/autogenerated/blender_HookModifierData.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_HOOKMODIFIERDATA__H__ -#define __BLENDER_HOOKMODIFIERDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ModifierData.h" - -namespace Blender { - - - // ---------------------------------------------- // - class HookModifierData - { - public: - ModifierData modifier; - Object *object; - float parentinv[4][4]; - vec3f cent; - float falloff; - int *indexar; - int totindex; - float force; - char name[32]; - }; -} - - -#endif//__BLENDER_HOOKMODIFIERDATA__H__ diff --git a/gamekit/autogenerated/blender_ID.h b/gamekit/autogenerated/blender_ID.h deleted file mode 100644 index f5ca8e016..000000000 --- a/gamekit/autogenerated/blender_ID.h +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_ID__H__ -#define __BLENDER_ID__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class ID - { - public: - void *next; - void *prev; - ID *newid; - Library *lib; - char name[24]; - short us; - short flag; - int icon_id; - IDProperty *properties; - }; -} - - -#endif//__BLENDER_ID__H__ diff --git a/gamekit/autogenerated/blender_IDProperty.h b/gamekit/autogenerated/blender_IDProperty.h deleted file mode 100644 index 1eeafc985..000000000 --- a/gamekit/autogenerated/blender_IDProperty.h +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_IDPROPERTY__H__ -#define __BLENDER_IDPROPERTY__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_IDPropertyData.h" - -namespace Blender { - - - // ---------------------------------------------- // - class IDProperty - { - public: - IDProperty *next; - IDProperty *prev; - char name[32]; - char type; - char subtype; - short flag; - int saved; - IDPropertyData data; - int len; - int totallen; - }; -} - - -#endif//__BLENDER_IDPROPERTY__H__ diff --git a/gamekit/autogenerated/blender_IDPropertyData.h b/gamekit/autogenerated/blender_IDPropertyData.h deleted file mode 100644 index 3ed2f6fd3..000000000 --- a/gamekit/autogenerated/blender_IDPropertyData.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_IDPROPERTYDATA__H__ -#define __BLENDER_IDPROPERTYDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ListBase.h" - -namespace Blender { - - - // ---------------------------------------------- // - class IDPropertyData - { - public: - void *pointer; - ListBase group; - int val; - int val2; - }; -} - - -#endif//__BLENDER_IDPROPERTYDATA__H__ diff --git a/gamekit/autogenerated/blender_Image.h b/gamekit/autogenerated/blender_Image.h deleted file mode 100644 index b160fd834..000000000 --- a/gamekit/autogenerated/blender_Image.h +++ /dev/null @@ -1,72 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_IMAGE__H__ -#define __BLENDER_IMAGE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ID.h" -#include "blender_ListBase.h" - -namespace Blender { - - - // ---------------------------------------------- // - class Image - { - public: - ID id; - char name[240]; - ListBase ibufs; - bInvalidHandle *gputexture; - bInvalidHandle *anim; - bInvalidHandle *rr; - short ok; - short flag; - short source; - short type; - short pad; - short pad1; - int lastframe; - short tpageflag; - short totbind; - short xrep; - short yrep; - short twsta; - short twend; - int bindcode; - int *repbind; - PackedFile *packedfile; - PreviewImage *preview; - float lastupdate; - int lastused; - short animspeed; - short gen_x; - short gen_y; - short gen_type; - float aspx; - float aspy; - void *vnode; - }; -} - - -#endif//__BLENDER_IMAGE__H__ diff --git a/gamekit/autogenerated/blender_ImagePaintSettings.h b/gamekit/autogenerated/blender_ImagePaintSettings.h deleted file mode 100644 index 42997cc79..000000000 --- a/gamekit/autogenerated/blender_ImagePaintSettings.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_IMAGEPAINTSETTINGS__H__ -#define __BLENDER_IMAGEPAINTSETTINGS__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class ImagePaintSettings - { - public: - Brush *brush; - short flag; - short tool; - short seam_bleed; - short normal_angle; - }; -} - - -#endif//__BLENDER_IMAGEPAINTSETTINGS__H__ diff --git a/gamekit/autogenerated/blender_ImageUser.h b/gamekit/autogenerated/blender_ImageUser.h deleted file mode 100644 index 2194397da..000000000 --- a/gamekit/autogenerated/blender_ImageUser.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_IMAGEUSER__H__ -#define __BLENDER_IMAGEUSER__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class ImageUser - { - public: - int framenr; - int frames; - int offset; - int sfra; - short fie_ima; - short cycl; - short flag; - short ok; - short multi_index; - short layer; - short pass; - short menunr; - }; -} - - -#endif//__BLENDER_IMAGEUSER__H__ diff --git a/gamekit/autogenerated/blender_Ipo.h b/gamekit/autogenerated/blender_Ipo.h deleted file mode 100644 index f8c42deec..000000000 --- a/gamekit/autogenerated/blender_Ipo.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_IPO__H__ -#define __BLENDER_IPO__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ID.h" -#include "blender_ListBase.h" -#include "blender_rctf.h" - -namespace Blender { - - - // ---------------------------------------------- // - class Ipo - { - public: - ID id; - ListBase curve; - rctf cur; - short blocktype; - short showkey; - short muteipo; - short pad; - }; -} - - -#endif//__BLENDER_IPO__H__ diff --git a/gamekit/autogenerated/blender_IpoCurve.h b/gamekit/autogenerated/blender_IpoCurve.h deleted file mode 100644 index 7c70f5548..000000000 --- a/gamekit/autogenerated/blender_IpoCurve.h +++ /dev/null @@ -1,60 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_IPOCURVE__H__ -#define __BLENDER_IPOCURVE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_rctf.h" - -namespace Blender { - - - // ---------------------------------------------- // - class IpoCurve - { - public: - IpoCurve *next; - IpoCurve *prev; - BPoint *bp; - BezTriple *bezt; - rctf maxrct; - rctf totrct; - short blocktype; - short adrcode; - short vartype; - short totvert; - short ipo; - short extrap; - short flag; - short rt; - float ymin; - float ymax; - int bitmask; - float slide_min; - float slide_max; - float curval; - IpoDriver *driver; - }; -} - - -#endif//__BLENDER_IPOCURVE__H__ diff --git a/gamekit/autogenerated/blender_IpoDriver.h b/gamekit/autogenerated/blender_IpoDriver.h deleted file mode 100644 index bfd62dd44..000000000 --- a/gamekit/autogenerated/blender_IpoDriver.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_IPODRIVER__H__ -#define __BLENDER_IPODRIVER__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class IpoDriver - { - public: - Object *ob; - short blocktype; - short adrcode; - short type; - short flag; - char name[128]; - }; -} - - -#endif//__BLENDER_IPODRIVER__H__ diff --git a/gamekit/autogenerated/blender_Key.h b/gamekit/autogenerated/blender_Key.h deleted file mode 100644 index 6eac8295b..000000000 --- a/gamekit/autogenerated/blender_Key.h +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_KEY__H__ -#define __BLENDER_KEY__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ID.h" -#include "blender_ListBase.h" - -namespace Blender { - - - // ---------------------------------------------- // - class Key - { - public: - ID id; - KeyBlock *refkey; - char elemstr[32]; - int elemsize; - float curval; - ListBase block; - Ipo *ipo; - ID *from; - short type; - short totkey; - short slurph; - short flag; - }; -} - - -#endif//__BLENDER_KEY__H__ diff --git a/gamekit/autogenerated/blender_KeyBlock.h b/gamekit/autogenerated/blender_KeyBlock.h deleted file mode 100644 index 83e7831d2..000000000 --- a/gamekit/autogenerated/blender_KeyBlock.h +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_KEYBLOCK__H__ -#define __BLENDER_KEYBLOCK__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class KeyBlock - { - public: - KeyBlock *next; - KeyBlock *prev; - float pos; - float curval; - short type; - short adrcode; - short relative; - short flag; - int totelem; - int pad2; - void *data; - float *weights; - char name[32]; - char vgroup[32]; - float slidermin; - float slidermax; - }; -} - - -#endif//__BLENDER_KEYBLOCK__H__ diff --git a/gamekit/autogenerated/blender_LBuf.h b/gamekit/autogenerated/blender_LBuf.h deleted file mode 100644 index 9e4053c12..000000000 --- a/gamekit/autogenerated/blender_LBuf.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_LBUF__H__ -#define __BLENDER_LBUF__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class LBuf - { - public: - short tot; - short max; - int pad; - Object **ob; - }; -} - - -#endif//__BLENDER_LBUF__H__ diff --git a/gamekit/autogenerated/blender_Lamp.h b/gamekit/autogenerated/blender_Lamp.h deleted file mode 100644 index c7529e713..000000000 --- a/gamekit/autogenerated/blender_Lamp.h +++ /dev/null @@ -1,120 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_LAMP__H__ -#define __BLENDER_LAMP__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ID.h" -#include "blender_ScriptLink.h" - -namespace Blender { - - - // ---------------------------------------------- // - class Lamp - { - public: - ID id; - short type; - short pad3; - int mode; - short colormodel; - short totex; - float r; - float g; - float b; - float k; - float shdwr; - float shdwg; - float shdwb; - float shdwpad; - float energy; - float dist; - float spotsize; - float spotblend; - float haint; - float att1; - float att2; - CurveMapping *curfalloff; - short falloff_type; - short pad2; - float clipsta; - float clipend; - float shadspotsize; - float bias; - float soft; - short bufsize; - short samp; - short buffers; - short filtertype; - char bufflag; - char buftype; - short ray_samp; - short ray_sampy; - short ray_sampz; - short ray_samp_type; - short area_shape; - float area_size; - float area_sizey; - float area_sizez; - float adapt_thresh; - short ray_samp_method; - short pad1; - short texact; - short shadhalostep; - short sun_effect_type; - short skyblendtype; - float horizon_brightness; - float spread; - float sun_brightness; - float sun_size; - float backscattered_light; - float sun_intensity; - float atm_turbidity; - float atm_inscattering_factor; - float atm_extinction_factor; - float atm_distance_factor; - float skyblendfac; - float sky_exposure; - short sky_colorspace; - short pad4; - int YF_numphotons; - int YF_numsearch; - short YF_phdepth; - short YF_useqmc; - short YF_bufsize; - short YF_pad; - float YF_causticblur; - float YF_ltradius; - float YF_glowint; - float YF_glowofs; - short YF_glowtype; - short YF_pad2; - MTex *mtex[18]; - Ipo *ipo; - PreviewImage *preview; - ScriptLink scriptlink; - }; -} - - -#endif//__BLENDER_LAMP__H__ diff --git a/gamekit/autogenerated/blender_Lattice.h b/gamekit/autogenerated/blender_Lattice.h deleted file mode 100644 index 0674882dc..000000000 --- a/gamekit/autogenerated/blender_Lattice.h +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_LATTICE__H__ -#define __BLENDER_LATTICE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ID.h" - -namespace Blender { - - - // ---------------------------------------------- // - class Lattice - { - public: - ID id; - short pntsu; - short pntsv; - short pntsw; - short flag; - short opntsu; - short opntsv; - short opntsw; - short pad2; - char typeu; - char typev; - char typew; - char type; - int pad; - float fu; - float fv; - float fw; - float du; - float dv; - float dw; - BPoint *def; - Ipo *ipo; - Key *key; - MDeformVert *dvert; - }; -} - - -#endif//__BLENDER_LATTICE__H__ diff --git a/gamekit/autogenerated/blender_LatticeModifierData.h b/gamekit/autogenerated/blender_LatticeModifierData.h deleted file mode 100644 index 3cfed89c4..000000000 --- a/gamekit/autogenerated/blender_LatticeModifierData.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_LATTICEMODIFIERDATA__H__ -#define __BLENDER_LATTICEMODIFIERDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ModifierData.h" - -namespace Blender { - - - // ---------------------------------------------- // - class LatticeModifierData - { - public: - ModifierData modifier; - Object *object; - char name[32]; - }; -} - - -#endif//__BLENDER_LATTICEMODIFIERDATA__H__ diff --git a/gamekit/autogenerated/blender_Library.h b/gamekit/autogenerated/blender_Library.h deleted file mode 100644 index de250cdca..000000000 --- a/gamekit/autogenerated/blender_Library.h +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_LIBRARY__H__ -#define __BLENDER_LIBRARY__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ID.h" - -namespace Blender { - - - // ---------------------------------------------- // - class Library - { - public: - ID id; - ID *idblock; - bInvalidHandle *filedata; - char name[240]; - char filename[240]; - int tot; - int pad; - Library *parent; - }; -} - - -#endif//__BLENDER_LIBRARY__H__ diff --git a/gamekit/autogenerated/blender_Link.h b/gamekit/autogenerated/blender_Link.h deleted file mode 100644 index 3850fee4a..000000000 --- a/gamekit/autogenerated/blender_Link.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_LINK__H__ -#define __BLENDER_LINK__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class Link - { - public: - Link *next; - Link *prev; - }; -} - - -#endif//__BLENDER_LINK__H__ diff --git a/gamekit/autogenerated/blender_LinkData.h b/gamekit/autogenerated/blender_LinkData.h deleted file mode 100644 index f3cb160cd..000000000 --- a/gamekit/autogenerated/blender_LinkData.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_LINKDATA__H__ -#define __BLENDER_LINKDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class LinkData - { - public: - LinkData *next; - LinkData *prev; - void *data; - }; -} - - -#endif//__BLENDER_LINKDATA__H__ diff --git a/gamekit/autogenerated/blender_ListBase.h b/gamekit/autogenerated/blender_ListBase.h deleted file mode 100644 index c0e0f66a1..000000000 --- a/gamekit/autogenerated/blender_ListBase.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_LISTBASE__H__ -#define __BLENDER_LISTBASE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class ListBase - { - public: - void *first; - void *last; - }; -} - - -#endif//__BLENDER_LISTBASE__H__ diff --git a/gamekit/autogenerated/blender_MCol.h b/gamekit/autogenerated/blender_MCol.h deleted file mode 100644 index c824a3e20..000000000 --- a/gamekit/autogenerated/blender_MCol.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_MCOL__H__ -#define __BLENDER_MCOL__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class MCol - { - public: - char a; - char r; - char g; - char b; - }; -} - - -#endif//__BLENDER_MCOL__H__ diff --git a/gamekit/autogenerated/blender_MDefCell.h b/gamekit/autogenerated/blender_MDefCell.h deleted file mode 100644 index 767a44388..000000000 --- a/gamekit/autogenerated/blender_MDefCell.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_MDEFCELL__H__ -#define __BLENDER_MDEFCELL__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class MDefCell - { - public: - int offset; - int totinfluence; - }; -} - - -#endif//__BLENDER_MDEFCELL__H__ diff --git a/gamekit/autogenerated/blender_MDefInfluence.h b/gamekit/autogenerated/blender_MDefInfluence.h deleted file mode 100644 index 9da48ef44..000000000 --- a/gamekit/autogenerated/blender_MDefInfluence.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_MDEFINFLUENCE__H__ -#define __BLENDER_MDEFINFLUENCE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class MDefInfluence - { - public: - int vertex; - float weight; - }; -} - - -#endif//__BLENDER_MDEFINFLUENCE__H__ diff --git a/gamekit/autogenerated/blender_MDeformVert.h b/gamekit/autogenerated/blender_MDeformVert.h deleted file mode 100644 index ff2f9d036..000000000 --- a/gamekit/autogenerated/blender_MDeformVert.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_MDEFORMVERT__H__ -#define __BLENDER_MDEFORMVERT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class MDeformVert - { - public: - MDeformWeight *dw; - int totweight; - int flag; - }; -} - - -#endif//__BLENDER_MDEFORMVERT__H__ diff --git a/gamekit/autogenerated/blender_MDeformWeight.h b/gamekit/autogenerated/blender_MDeformWeight.h deleted file mode 100644 index 35699d13b..000000000 --- a/gamekit/autogenerated/blender_MDeformWeight.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_MDEFORMWEIGHT__H__ -#define __BLENDER_MDEFORMWEIGHT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class MDeformWeight - { - public: - int def_nr; - float weight; - }; -} - - -#endif//__BLENDER_MDEFORMWEIGHT__H__ diff --git a/gamekit/autogenerated/blender_MEdge.h b/gamekit/autogenerated/blender_MEdge.h deleted file mode 100644 index 84337ed38..000000000 --- a/gamekit/autogenerated/blender_MEdge.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_MEDGE__H__ -#define __BLENDER_MEDGE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class MEdge - { - public: - int v1; - int v2; - char crease; - char bweight; - short flag; - }; -} - - -#endif//__BLENDER_MEDGE__H__ diff --git a/gamekit/autogenerated/blender_MFace.h b/gamekit/autogenerated/blender_MFace.h deleted file mode 100644 index e3fd49e3b..000000000 --- a/gamekit/autogenerated/blender_MFace.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_MFACE__H__ -#define __BLENDER_MFACE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class MFace - { - public: - int v1; - int v2; - int v3; - int v4; - char pad; - char mat_nr; - char edcode; - char flag; - }; -} - - -#endif//__BLENDER_MFACE__H__ diff --git a/gamekit/autogenerated/blender_MFloatProperty.h b/gamekit/autogenerated/blender_MFloatProperty.h deleted file mode 100644 index 69fc723ae..000000000 --- a/gamekit/autogenerated/blender_MFloatProperty.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_MFLOATPROPERTY__H__ -#define __BLENDER_MFLOATPROPERTY__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class MFloatProperty - { - public: - float f; - }; -} - - -#endif//__BLENDER_MFLOATPROPERTY__H__ diff --git a/gamekit/autogenerated/blender_MIntProperty.h b/gamekit/autogenerated/blender_MIntProperty.h deleted file mode 100644 index 49c47262a..000000000 --- a/gamekit/autogenerated/blender_MIntProperty.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_MINTPROPERTY__H__ -#define __BLENDER_MINTPROPERTY__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class MIntProperty - { - public: - int i; - }; -} - - -#endif//__BLENDER_MINTPROPERTY__H__ diff --git a/gamekit/autogenerated/blender_MLoopCol.h b/gamekit/autogenerated/blender_MLoopCol.h deleted file mode 100644 index 2f0783a66..000000000 --- a/gamekit/autogenerated/blender_MLoopCol.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_MLOOPCOL__H__ -#define __BLENDER_MLOOPCOL__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class MLoopCol - { - public: - char a; - char r; - char g; - char b; - int pad; - }; -} - - -#endif//__BLENDER_MLOOPCOL__H__ diff --git a/gamekit/autogenerated/blender_MLoopUV.h b/gamekit/autogenerated/blender_MLoopUV.h deleted file mode 100644 index 41568fbb8..000000000 --- a/gamekit/autogenerated/blender_MLoopUV.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_MLOOPUV__H__ -#define __BLENDER_MLOOPUV__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class MLoopUV - { - public: - float uv[2]; - }; -} - - -#endif//__BLENDER_MLOOPUV__H__ diff --git a/gamekit/autogenerated/blender_MSelect.h b/gamekit/autogenerated/blender_MSelect.h deleted file mode 100644 index c7da2580a..000000000 --- a/gamekit/autogenerated/blender_MSelect.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_MSELECT__H__ -#define __BLENDER_MSELECT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class MSelect - { - public: - int index; - int type; - }; -} - - -#endif//__BLENDER_MSELECT__H__ diff --git a/gamekit/autogenerated/blender_MSticky.h b/gamekit/autogenerated/blender_MSticky.h deleted file mode 100644 index a7e42239d..000000000 --- a/gamekit/autogenerated/blender_MSticky.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_MSTICKY__H__ -#define __BLENDER_MSTICKY__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class MSticky - { - public: - float co[2]; - }; -} - - -#endif//__BLENDER_MSTICKY__H__ diff --git a/gamekit/autogenerated/blender_MStringProperty.h b/gamekit/autogenerated/blender_MStringProperty.h deleted file mode 100644 index d421ad053..000000000 --- a/gamekit/autogenerated/blender_MStringProperty.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_MSTRINGPROPERTY__H__ -#define __BLENDER_MSTRINGPROPERTY__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class MStringProperty - { - public: - char s[256]; - }; -} - - -#endif//__BLENDER_MSTRINGPROPERTY__H__ diff --git a/gamekit/autogenerated/blender_MTFace.h b/gamekit/autogenerated/blender_MTFace.h deleted file mode 100644 index 9e8232ee4..000000000 --- a/gamekit/autogenerated/blender_MTFace.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_MTFACE__H__ -#define __BLENDER_MTFACE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class MTFace - { - public: - float uv[4][2]; - Image *tpage; - char flag; - char transp; - short mode; - short tile; - short unwrap; - }; -} - - -#endif//__BLENDER_MTFACE__H__ diff --git a/gamekit/autogenerated/blender_MTex.h b/gamekit/autogenerated/blender_MTex.h deleted file mode 100644 index 9758d3a71..000000000 --- a/gamekit/autogenerated/blender_MTex.h +++ /dev/null @@ -1,69 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_MTEX__H__ -#define __BLENDER_MTEX__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class MTex - { - public: - short texco; - short mapto; - short maptoneg; - short blendtype; - Object *object; - Tex *tex; - char uvname[32]; - char projx; - char projy; - char projz; - char mapping; - vec3f ofs; - vec3f size; - short texflag; - short colormodel; - short pmapto; - short pmaptoneg; - short normapspace; - short which_output; - short pad[2]; - float r; - float g; - float b; - float k; - float def_var; - float rt; - float colfac; - float norfac; - float varfac; - float dispfac; - float warpfac; - }; -} - - -#endif//__BLENDER_MTEX__H__ diff --git a/gamekit/autogenerated/blender_MTexPoly.h b/gamekit/autogenerated/blender_MTexPoly.h deleted file mode 100644 index 93e6ba941..000000000 --- a/gamekit/autogenerated/blender_MTexPoly.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_MTEXPOLY__H__ -#define __BLENDER_MTEXPOLY__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class MTexPoly - { - public: - Image *tpage; - char flag; - char transp; - short mode; - short tile; - short unwrap; - }; -} - - -#endif//__BLENDER_MTEXPOLY__H__ diff --git a/gamekit/autogenerated/blender_MVert.h b/gamekit/autogenerated/blender_MVert.h deleted file mode 100644 index d262d9208..000000000 --- a/gamekit/autogenerated/blender_MVert.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_MVERT__H__ -#define __BLENDER_MVERT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class MVert - { - public: - vec3f co; - short no[3]; - char flag; - char mat_nr; - char bweight; - char pad[3]; - }; -} - - -#endif//__BLENDER_MVERT__H__ diff --git a/gamekit/autogenerated/blender_MaskModifierData.h b/gamekit/autogenerated/blender_MaskModifierData.h deleted file mode 100644 index ce0e0d814..000000000 --- a/gamekit/autogenerated/blender_MaskModifierData.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_MASKMODIFIERDATA__H__ -#define __BLENDER_MASKMODIFIERDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ModifierData.h" - -namespace Blender { - - - // ---------------------------------------------- // - class MaskModifierData - { - public: - ModifierData modifier; - Object *ob_arm; - char vgroup[32]; - int mode; - int flag; - }; -} - - -#endif//__BLENDER_MASKMODIFIERDATA__H__ diff --git a/gamekit/autogenerated/blender_Material.h b/gamekit/autogenerated/blender_Material.h deleted file mode 100644 index f885a43dd..000000000 --- a/gamekit/autogenerated/blender_Material.h +++ /dev/null @@ -1,170 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_MATERIAL__H__ -#define __BLENDER_MATERIAL__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ID.h" -#include "blender_ListBase.h" -#include "blender_ScriptLink.h" - -namespace Blender { - - - // ---------------------------------------------- // - class Material - { - public: - ID id; - short colormodel; - short flag; - float r; - float g; - float b; - float specr; - float specg; - float specb; - float mirr; - float mirg; - float mirb; - float ambr; - float ambb; - float ambg; - float amb; - float emit; - float ang; - float spectra; - float ray_mirror; - float alpha; - float ref; - float spec; - float zoffs; - float add; - float translucency; - float fresnel_mir; - float fresnel_mir_i; - float fresnel_tra; - float fresnel_tra_i; - float filter; - float tx_limit; - float tx_falloff; - short ray_depth; - short ray_depth_tra; - short har; - char seed1; - char seed2; - float gloss_mir; - float gloss_tra; - short samp_gloss_mir; - short samp_gloss_tra; - float adapt_thresh_mir; - float adapt_thresh_tra; - float aniso_gloss_mir; - float dist_mir; - short fadeto_mir; - short shade_flag; - int mode; - int mode_l; - short flarec; - short starc; - short linec; - short ringc; - float hasize; - float flaresize; - float subsize; - float flareboost; - float strand_sta; - float strand_end; - float strand_ease; - float strand_surfnor; - float strand_min; - float strand_widthfade; - char strand_uvname[32]; - float sbias; - float lbias; - float shad_alpha; - int septex; - char rgbsel; - char texact; - char pr_type; - char use_nodes; - short pr_back; - short pr_lamp; - short pad4; - short ml_flag; - short diff_shader; - short spec_shader; - float roughness; - float refrac; - vec4f param; - float rms; - float darkness; - short texco; - short mapto; - ColorBand *ramp_col; - ColorBand *ramp_spec; - char rampin_col; - char rampin_spec; - char rampblend_col; - char rampblend_spec; - short ramp_show; - short pad3; - float rampfac_col; - float rampfac_spec; - MTex *mtex[18]; - bNodeTree *nodetree; - Ipo *ipo; - Group *group; - PreviewImage *preview; - float friction; - float fh; - float reflect; - float fhdist; - float xyfrict; - short dynamode; - short pad2; - vec3f sss_radius; - vec3f sss_col; - float sss_error; - float sss_scale; - float sss_ior; - float sss_colfac; - float sss_texfac; - float sss_front; - float sss_back; - short sss_flag; - short sss_preset; - float YF_ar; - float YF_ag; - float YF_ab; - float YF_dscale; - float YF_dpwr; - int YF_dsmp; - int YF_preset; - int YF_djit; - ScriptLink scriptlink; - ListBase gpumaterial; - }; -} - - -#endif//__BLENDER_MATERIAL__H__ diff --git a/gamekit/autogenerated/blender_Mesh.h b/gamekit/autogenerated/blender_Mesh.h deleted file mode 100644 index 6efd0fcfa..000000000 --- a/gamekit/autogenerated/blender_Mesh.h +++ /dev/null @@ -1,80 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_MESH__H__ -#define __BLENDER_MESH__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_CustomData.h" -#include "blender_ID.h" -#include "blender_ListBase.h" - -namespace Blender { - - - // ---------------------------------------------- // - class Mesh - { - public: - ID id; - BoundBox *bb; - ListBase effect; - Ipo *ipo; - Key *key; - Material **mat; - MFace *mface; - MTFace *mtface; - TFace *tface; - MVert *mvert; - MEdge *medge; - MDeformVert *dvert; - MCol *mcol; - MSticky *msticky; - Mesh *texcomesh; - MSelect *mselect; - CustomData vdata; - CustomData edata; - CustomData fdata; - int totvert; - int totedge; - int totface; - int totselect; - int act_face; - int texflag; - vec3f loc; - vec3f size; - vec3f rot; - float cubemapsize; - float pad; - short smoothresh; - short flag; - short subdiv; - short subdivr; - short totcol; - short subsurftype; - Multires *mr; - PartialVisibility *pv; - void *vnode; - }; -} - - -#endif//__BLENDER_MESH__H__ diff --git a/gamekit/autogenerated/blender_MeshDeformModifierData.h b/gamekit/autogenerated/blender_MeshDeformModifierData.h deleted file mode 100644 index 34b3acda5..000000000 --- a/gamekit/autogenerated/blender_MeshDeformModifierData.h +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_MESHDEFORMMODIFIERDATA__H__ -#define __BLENDER_MESHDEFORMMODIFIERDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ModifierData.h" - -namespace Blender { - - - // ---------------------------------------------- // - class MeshDeformModifierData - { - public: - ModifierData modifier; - Object *object; - char defgrp_name[32]; - short gridsize; - short needbind; - short flag; - short pad; - float *bindweights; - float *bindcos; - int totvert; - int totcagevert; - MDefCell *dyngrid; - MDefInfluence *dyninfluences; - int *dynverts; - int *pad2; - int dyngridsize; - int totinfluence; - vec3f dyncellmin; - float dyncellwidth; - float bindmat[4][4]; - }; -} - - -#endif//__BLENDER_MESHDEFORMMODIFIERDATA__H__ diff --git a/gamekit/autogenerated/blender_MetaBall.h b/gamekit/autogenerated/blender_MetaBall.h deleted file mode 100644 index e7cd1f25a..000000000 --- a/gamekit/autogenerated/blender_MetaBall.h +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_METABALL__H__ -#define __BLENDER_METABALL__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ID.h" -#include "blender_ListBase.h" - -namespace Blender { - - - // ---------------------------------------------- // - class MetaBall - { - public: - ID id; - BoundBox *bb; - ListBase elems; - ListBase disp; - Ipo *ipo; - Material **mat; - short flag; - short totcol; - int texflag; - vec3f loc; - vec3f size; - vec3f rot; - float wiresize; - float rendersize; - float thresh; - }; -} - - -#endif//__BLENDER_METABALL__H__ diff --git a/gamekit/autogenerated/blender_MetaElem.h b/gamekit/autogenerated/blender_MetaElem.h deleted file mode 100644 index d9dc0f97d..000000000 --- a/gamekit/autogenerated/blender_MetaElem.h +++ /dev/null @@ -1,64 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_METAELEM__H__ -#define __BLENDER_METAELEM__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class MetaElem - { - public: - MetaElem *next; - MetaElem *prev; - BoundBox *bb; - int i1; - int j1; - int k1; - int i2; - int j2; - int k2; - short type; - short flag; - short selcol1; - short selcol2; - float x; - float y; - float z; - vec4f quat; - float expx; - float expy; - float expz; - float rad; - float rad2; - float s; - float len; - float *mat; - float *imat; - }; -} - - -#endif//__BLENDER_METAELEM__H__ diff --git a/gamekit/autogenerated/blender_MetaStack.h b/gamekit/autogenerated/blender_MetaStack.h deleted file mode 100644 index 14534c548..000000000 --- a/gamekit/autogenerated/blender_MetaStack.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_METASTACK__H__ -#define __BLENDER_METASTACK__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class MetaStack - { - public: - MetaStack *next; - MetaStack *prev; - ListBase *oldbasep; - Sequence *parseq; - }; -} - - -#endif//__BLENDER_METASTACK__H__ diff --git a/gamekit/autogenerated/blender_MirrorModifierData.h b/gamekit/autogenerated/blender_MirrorModifierData.h deleted file mode 100644 index f1f455441..000000000 --- a/gamekit/autogenerated/blender_MirrorModifierData.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_MIRRORMODIFIERDATA__H__ -#define __BLENDER_MIRRORMODIFIERDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ModifierData.h" - -namespace Blender { - - - // ---------------------------------------------- // - class MirrorModifierData - { - public: - ModifierData modifier; - short axis; - short flag; - float tolerance; - Object *mirror_ob; - }; -} - - -#endif//__BLENDER_MIRRORMODIFIERDATA__H__ diff --git a/gamekit/autogenerated/blender_ModifierData.h b/gamekit/autogenerated/blender_ModifierData.h deleted file mode 100644 index 749ea9858..000000000 --- a/gamekit/autogenerated/blender_ModifierData.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_MODIFIERDATA__H__ -#define __BLENDER_MODIFIERDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class ModifierData - { - public: - ModifierData *next; - ModifierData *prev; - int type; - int mode; - char name[32]; - char *error; - }; -} - - -#endif//__BLENDER_MODIFIERDATA__H__ diff --git a/gamekit/autogenerated/blender_Multires.h b/gamekit/autogenerated/blender_Multires.h deleted file mode 100644 index 1118ae469..000000000 --- a/gamekit/autogenerated/blender_Multires.h +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_MULTIRES__H__ -#define __BLENDER_MULTIRES__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_CustomData.h" -#include "blender_ListBase.h" - -namespace Blender { - - - // ---------------------------------------------- // - class Multires - { - public: - ListBase levels; - MVert *verts; - char level_count; - char current; - char newlvl; - char edgelvl; - char pinlvl; - char renderlvl; - char use_col; - char flag; - CustomData vdata; - CustomData fdata; - short *edge_flags; - char *edge_creases; - }; -} - - -#endif//__BLENDER_MULTIRES__H__ diff --git a/gamekit/autogenerated/blender_MultiresCol.h b/gamekit/autogenerated/blender_MultiresCol.h deleted file mode 100644 index 51676eb94..000000000 --- a/gamekit/autogenerated/blender_MultiresCol.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_MULTIRESCOL__H__ -#define __BLENDER_MULTIRESCOL__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class MultiresCol - { - public: - float a; - float r; - float g; - float b; - }; -} - - -#endif//__BLENDER_MULTIRESCOL__H__ diff --git a/gamekit/autogenerated/blender_MultiresColFace.h b/gamekit/autogenerated/blender_MultiresColFace.h deleted file mode 100644 index 2ae03165b..000000000 --- a/gamekit/autogenerated/blender_MultiresColFace.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_MULTIRESCOLFACE__H__ -#define __BLENDER_MULTIRESCOLFACE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_MultiresCol.h" - -namespace Blender { - - - // ---------------------------------------------- // - class MultiresColFace - { - public: - MultiresCol col[4]; - }; -} - - -#endif//__BLENDER_MULTIRESCOLFACE__H__ diff --git a/gamekit/autogenerated/blender_MultiresEdge.h b/gamekit/autogenerated/blender_MultiresEdge.h deleted file mode 100644 index 3dc7674cc..000000000 --- a/gamekit/autogenerated/blender_MultiresEdge.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_MULTIRESEDGE__H__ -#define __BLENDER_MULTIRESEDGE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class MultiresEdge - { - public: - int v[2]; - int mid; - }; -} - - -#endif//__BLENDER_MULTIRESEDGE__H__ diff --git a/gamekit/autogenerated/blender_MultiresFace.h b/gamekit/autogenerated/blender_MultiresFace.h deleted file mode 100644 index d9027d255..000000000 --- a/gamekit/autogenerated/blender_MultiresFace.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_MULTIRESFACE__H__ -#define __BLENDER_MULTIRESFACE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class MultiresFace - { - public: - int v[4]; - int mid; - char flag; - char mat_nr; - char pad[2]; - }; -} - - -#endif//__BLENDER_MULTIRESFACE__H__ diff --git a/gamekit/autogenerated/blender_MultiresLevel.h b/gamekit/autogenerated/blender_MultiresLevel.h deleted file mode 100644 index 8cef4b6b2..000000000 --- a/gamekit/autogenerated/blender_MultiresLevel.h +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_MULTIRESLEVEL__H__ -#define __BLENDER_MULTIRESLEVEL__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class MultiresLevel - { - public: - MultiresLevel *next; - MultiresLevel *prev; - MultiresFace *faces; - MultiresColFace *colfaces; - MultiresEdge *edges; - char *edge_boundary_states; - ListBase *vert_edge_map; - ListBase *vert_face_map; - bInvalidHandle *map_mem; - int totvert; - int totface; - int totedge; - int pad; - MVert *verts; - }; -} - - -#endif//__BLENDER_MULTIRESLEVEL__H__ diff --git a/gamekit/autogenerated/blender_NodeBilateralBlurData.h b/gamekit/autogenerated/blender_NodeBilateralBlurData.h deleted file mode 100644 index 9a534006a..000000000 --- a/gamekit/autogenerated/blender_NodeBilateralBlurData.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_NODEBILATERALBLURDATA__H__ -#define __BLENDER_NODEBILATERALBLURDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class NodeBilateralBlurData - { - public: - float sigma_color; - float sigma_space; - short iter; - short pad; - }; -} - - -#endif//__BLENDER_NODEBILATERALBLURDATA__H__ diff --git a/gamekit/autogenerated/blender_NodeBlurData.h b/gamekit/autogenerated/blender_NodeBlurData.h deleted file mode 100644 index e9c6a4325..000000000 --- a/gamekit/autogenerated/blender_NodeBlurData.h +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_NODEBLURDATA__H__ -#define __BLENDER_NODEBLURDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class NodeBlurData - { - public: - short sizex; - short sizey; - short samples; - short maxspeed; - short minspeed; - short relative; - float fac; - float percentx; - float percenty; - short filtertype; - char bokeh; - char gamma; - short curved; - short pad; - int image_in_width; - int image_in_height; - }; -} - - -#endif//__BLENDER_NODEBLURDATA__H__ diff --git a/gamekit/autogenerated/blender_NodeChroma.h b/gamekit/autogenerated/blender_NodeChroma.h deleted file mode 100644 index ab8439119..000000000 --- a/gamekit/autogenerated/blender_NodeChroma.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_NODECHROMA__H__ -#define __BLENDER_NODECHROMA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class NodeChroma - { - public: - float t1; - float t2; - float t3; - float fsize; - float fstrength; - float falpha; - vec4f key; - }; -} - - -#endif//__BLENDER_NODECHROMA__H__ diff --git a/gamekit/autogenerated/blender_NodeDBlurData.h b/gamekit/autogenerated/blender_NodeDBlurData.h deleted file mode 100644 index 64a540cff..000000000 --- a/gamekit/autogenerated/blender_NodeDBlurData.h +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_NODEDBLURDATA__H__ -#define __BLENDER_NODEDBLURDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class NodeDBlurData - { - public: - float center_x; - float center_y; - float distance; - float angle; - float spin; - float zoom; - short iter; - char wrap; - char pad; - }; -} - - -#endif//__BLENDER_NODEDBLURDATA__H__ diff --git a/gamekit/autogenerated/blender_NodeDefocus.h b/gamekit/autogenerated/blender_NodeDefocus.h deleted file mode 100644 index 2e21dac1a..000000000 --- a/gamekit/autogenerated/blender_NodeDefocus.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_NODEDEFOCUS__H__ -#define __BLENDER_NODEDEFOCUS__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class NodeDefocus - { - public: - char bktype; - char rotation; - char preview; - char gamco; - short samples; - short no_zbuf; - float fstop; - float maxblur; - float bthresh; - float scale; - }; -} - - -#endif//__BLENDER_NODEDEFOCUS__H__ diff --git a/gamekit/autogenerated/blender_NodeGeometry.h b/gamekit/autogenerated/blender_NodeGeometry.h deleted file mode 100644 index 64c5a5d8d..000000000 --- a/gamekit/autogenerated/blender_NodeGeometry.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_NODEGEOMETRY__H__ -#define __BLENDER_NODEGEOMETRY__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class NodeGeometry - { - public: - char uvname[32]; - char colname[32]; - }; -} - - -#endif//__BLENDER_NODEGEOMETRY__H__ diff --git a/gamekit/autogenerated/blender_NodeGlare.h b/gamekit/autogenerated/blender_NodeGlare.h deleted file mode 100644 index b3c8521a9..000000000 --- a/gamekit/autogenerated/blender_NodeGlare.h +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_NODEGLARE__H__ -#define __BLENDER_NODEGLARE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class NodeGlare - { - public: - char quality; - char type; - char iter; - char angle; - char angle_ofs; - char size; - char pad[2]; - float colmod; - float mix; - float threshold; - float fade; - }; -} - - -#endif//__BLENDER_NODEGLARE__H__ diff --git a/gamekit/autogenerated/blender_NodeHueSat.h b/gamekit/autogenerated/blender_NodeHueSat.h deleted file mode 100644 index bf3ffce73..000000000 --- a/gamekit/autogenerated/blender_NodeHueSat.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_NODEHUESAT__H__ -#define __BLENDER_NODEHUESAT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class NodeHueSat - { - public: - float hue; - float sat; - float val; - }; -} - - -#endif//__BLENDER_NODEHUESAT__H__ diff --git a/gamekit/autogenerated/blender_NodeImageAnim.h b/gamekit/autogenerated/blender_NodeImageAnim.h deleted file mode 100644 index b180fe8f6..000000000 --- a/gamekit/autogenerated/blender_NodeImageAnim.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_NODEIMAGEANIM__H__ -#define __BLENDER_NODEIMAGEANIM__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class NodeImageAnim - { - public: - int frames; - int sfra; - int nr; - char cyclic; - char movie; - short pad; - }; -} - - -#endif//__BLENDER_NODEIMAGEANIM__H__ diff --git a/gamekit/autogenerated/blender_NodeImageFile.h b/gamekit/autogenerated/blender_NodeImageFile.h deleted file mode 100644 index 7608982e2..000000000 --- a/gamekit/autogenerated/blender_NodeImageFile.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_NODEIMAGEFILE__H__ -#define __BLENDER_NODEIMAGEFILE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class NodeImageFile - { - public: - char name[256]; - short imtype; - short subimtype; - short quality; - short codec; - int sfra; - int efra; - }; -} - - -#endif//__BLENDER_NODEIMAGEFILE__H__ diff --git a/gamekit/autogenerated/blender_NodeLensDist.h b/gamekit/autogenerated/blender_NodeLensDist.h deleted file mode 100644 index 98bdc30dc..000000000 --- a/gamekit/autogenerated/blender_NodeLensDist.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_NODELENSDIST__H__ -#define __BLENDER_NODELENSDIST__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class NodeLensDist - { - public: - short jit; - short proj; - short fit; - short pad; - }; -} - - -#endif//__BLENDER_NODELENSDIST__H__ diff --git a/gamekit/autogenerated/blender_NodeScriptDict.h b/gamekit/autogenerated/blender_NodeScriptDict.h deleted file mode 100644 index 2fe878aa2..000000000 --- a/gamekit/autogenerated/blender_NodeScriptDict.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_NODESCRIPTDICT__H__ -#define __BLENDER_NODESCRIPTDICT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class NodeScriptDict - { - public: - void *dict; - void *node; - }; -} - - -#endif//__BLENDER_NODESCRIPTDICT__H__ diff --git a/gamekit/autogenerated/blender_NodeTonemap.h b/gamekit/autogenerated/blender_NodeTonemap.h deleted file mode 100644 index e4ddad70f..000000000 --- a/gamekit/autogenerated/blender_NodeTonemap.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_NODETONEMAP__H__ -#define __BLENDER_NODETONEMAP__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class NodeTonemap - { - public: - float key; - float offset; - float gamma; - float f; - float m; - float a; - float c; - int type; - }; -} - - -#endif//__BLENDER_NODETONEMAP__H__ diff --git a/gamekit/autogenerated/blender_NodeTwoFloats.h b/gamekit/autogenerated/blender_NodeTwoFloats.h deleted file mode 100644 index 421bb8b8c..000000000 --- a/gamekit/autogenerated/blender_NodeTwoFloats.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_NODETWOFLOATS__H__ -#define __BLENDER_NODETWOFLOATS__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class NodeTwoFloats - { - public: - float x; - float y; - }; -} - - -#endif//__BLENDER_NODETWOFLOATS__H__ diff --git a/gamekit/autogenerated/blender_NodeTwoXYs.h b/gamekit/autogenerated/blender_NodeTwoXYs.h deleted file mode 100644 index 4fa19d285..000000000 --- a/gamekit/autogenerated/blender_NodeTwoXYs.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_NODETWOXYS__H__ -#define __BLENDER_NODETWOXYS__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class NodeTwoXYs - { - public: - short x1; - short x2; - short y1; - short y2; - }; -} - - -#endif//__BLENDER_NODETWOXYS__H__ diff --git a/gamekit/autogenerated/blender_NodeVertexCol.h b/gamekit/autogenerated/blender_NodeVertexCol.h deleted file mode 100644 index 19b57efc0..000000000 --- a/gamekit/autogenerated/blender_NodeVertexCol.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_NODEVERTEXCOL__H__ -#define __BLENDER_NODEVERTEXCOL__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class NodeVertexCol - { - public: - char name[32]; - }; -} - - -#endif//__BLENDER_NODEVERTEXCOL__H__ diff --git a/gamekit/autogenerated/blender_Nurb.h b/gamekit/autogenerated/blender_Nurb.h deleted file mode 100644 index 5e6fd3777..000000000 --- a/gamekit/autogenerated/blender_Nurb.h +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_NURB__H__ -#define __BLENDER_NURB__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class Nurb - { - public: - Nurb *next; - Nurb *prev; - short type; - short mat_nr; - short hide; - short flag; - short pntsu; - short pntsv; - short resolu; - short resolv; - short orderu; - short orderv; - short flagu; - short flagv; - float *knotsu; - float *knotsv; - BPoint *bp; - BezTriple *bezt; - short tilt_interp; - short radius_interp; - int charidx; - }; -} - - -#endif//__BLENDER_NURB__H__ diff --git a/gamekit/autogenerated/blender_ObHook.h b/gamekit/autogenerated/blender_ObHook.h deleted file mode 100644 index c60cb530b..000000000 --- a/gamekit/autogenerated/blender_ObHook.h +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_OBHOOK__H__ -#define __BLENDER_OBHOOK__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class ObHook - { - public: - ObHook *next; - ObHook *prev; - Object *parent; - float parentinv[4][4]; - float mat[4][4]; - vec3f cent; - float falloff; - char name[32]; - int *indexar; - int totindex; - int curindex; - short type; - short active; - float force; - }; -} - - -#endif//__BLENDER_OBHOOK__H__ diff --git a/gamekit/autogenerated/blender_Object.h b/gamekit/autogenerated/blender_Object.h deleted file mode 100644 index 74ee88833..000000000 --- a/gamekit/autogenerated/blender_Object.h +++ /dev/null @@ -1,152 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_OBJECT__H__ -#define __BLENDER_OBJECT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ID.h" -#include "blender_ListBase.h" -#include "blender_ScriptLink.h" - -namespace Blender { - - - // ---------------------------------------------- // - class Object - { - public: - ID id; - short type; - short partype; - int par1; - int par2; - int par3; - char parsubstr[32]; - Object *parent; - Object *track; - Object *proxy; - Object *proxy_group; - Object *proxy_from; - Ipo *ipo; - bInvalidHandle *path; - BoundBox *bb; - bAction *action; - bAction *poselib; - bPose *pose; - void *data; - ListBase constraintChannels; - ListBase effect; - ListBase disp; - ListBase defbase; - ListBase modifiers; - Material **mat; - vec3f loc; - vec3f dloc; - vec3f orig; - vec3f size; - vec3f dsize; - vec3f rot; - vec3f drot; - float obmat[4][4]; - float parentinv[4][4]; - float constinv[4][4]; - float imat[4][4]; - int lay; - short flag; - short colbits; - short transflag; - short ipoflag; - short trackflag; - short upflag; - short nlaflag; - short protectflag; - short ipowin; - short scaflag; - short scavisflag; - short boundtype; - int dupon; - int dupoff; - int dupsta; - int dupend; - float sf; - float ctime; - float mass; - float damping; - float inertia; - float formfactor; - float rdamping; - float sizefac; - float margin; - float max_vel; - float min_vel; - float m_contactProcessingThreshold; - char dt; - char dtx; - char totcol; - char actcol; - char empty_drawtype; - char pad1[3]; - float empty_drawsize; - float dupfacesca; - ScriptLink scriptlink; - ListBase prop; - ListBase sensors; - ListBase controllers; - ListBase actuators; - vec3f bbsize; - short index; - short actdef; - vec4f col; - int gameflag; - int gameflag2; - BulletSoftBody *bsoft; - short softflag; - short recalc; - vec3f anisotropicFriction; - ListBase constraints; - ListBase nlastrips; - ListBase hooks; - ListBase particlesystem; - PartDeflect *pd; - SoftBody *soft; - Group *dup_group; - short fluidsimFlag; - short restrictflag; - short shapenr; - short shapeflag; - float smoothresh; - short recalco; - short body_type; - FluidsimSettings *fluidsimSettings; - bInvalidHandle *derivedDeform; - bInvalidHandle *derivedFinal; - int lastDataMask; - int state; - int init_state; - int pad2; - void *vnode; - ListBase gpulamp; - }; -} - - -#endif//__BLENDER_OBJECT__H__ diff --git a/gamekit/autogenerated/blender_OcInfo.h b/gamekit/autogenerated/blender_OcInfo.h deleted file mode 100644 index 32c7cc6d2..000000000 --- a/gamekit/autogenerated/blender_OcInfo.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_OCINFO__H__ -#define __BLENDER_OCINFO__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class OcInfo - { - public: - vec3f dvec; - vec3f size; - }; -} - - -#endif//__BLENDER_OCINFO__H__ diff --git a/gamekit/autogenerated/blender_Oops.h b/gamekit/autogenerated/blender_Oops.h deleted file mode 100644 index 337426382..000000000 --- a/gamekit/autogenerated/blender_Oops.h +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_OOPS__H__ -#define __BLENDER_OOPS__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ListBase.h" - -namespace Blender { - - - // ---------------------------------------------- // - class Oops - { - public: - Oops *next; - Oops *prev; - short type; - short flag; - short dt; - short hide; - float x; - float y; - float dx; - float dy; - ID *id; - ListBase link; - }; -} - - -#endif//__BLENDER_OOPS__H__ diff --git a/gamekit/autogenerated/blender_OrigSpaceFace.h b/gamekit/autogenerated/blender_OrigSpaceFace.h deleted file mode 100644 index 505123557..000000000 --- a/gamekit/autogenerated/blender_OrigSpaceFace.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_ORIGSPACEFACE__H__ -#define __BLENDER_ORIGSPACEFACE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class OrigSpaceFace - { - public: - float uv[4][2]; - }; -} - - -#endif//__BLENDER_ORIGSPACEFACE__H__ diff --git a/gamekit/autogenerated/blender_PackedFile.h b/gamekit/autogenerated/blender_PackedFile.h deleted file mode 100644 index 70aaee446..000000000 --- a/gamekit/autogenerated/blender_PackedFile.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_PACKEDFILE__H__ -#define __BLENDER_PACKEDFILE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class PackedFile - { - public: - int size; - int seek; - int flags; - int pad; - void *data; - }; -} - - -#endif//__BLENDER_PACKEDFILE__H__ diff --git a/gamekit/autogenerated/blender_Panel.h b/gamekit/autogenerated/blender_Panel.h deleted file mode 100644 index 0fbdb7f3b..000000000 --- a/gamekit/autogenerated/blender_Panel.h +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_PANEL__H__ -#define __BLENDER_PANEL__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class Panel - { - public: - Panel *next; - Panel *prev; - char panelname[64]; - char tabname[64]; - char drawname[64]; - short ofsx; - short ofsy; - short sizex; - short sizey; - short flag; - short active; - short control; - short snap; - short old_ofsx; - short old_ofsy; - int sortcounter; - Panel *paneltab; - }; -} - - -#endif//__BLENDER_PANEL__H__ diff --git a/gamekit/autogenerated/blender_PartDeflect.h b/gamekit/autogenerated/blender_PartDeflect.h deleted file mode 100644 index 28dd9682d..000000000 --- a/gamekit/autogenerated/blender_PartDeflect.h +++ /dev/null @@ -1,74 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_PARTDEFLECT__H__ -#define __BLENDER_PARTDEFLECT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class PartDeflect - { - public: - short deflect; - short forcefield; - short flag; - short falloff; - float pdef_damp; - float pdef_rdamp; - float pdef_perm; - float pdef_frict; - float pdef_rfrict; - float f_strength; - float f_power; - float f_dist; - float f_damp; - float maxdist; - float mindist; - float maxrad; - float minrad; - float f_power_r; - float pdef_sbdamp; - float pdef_sbift; - float pdef_sboft; - float clump_fac; - float clump_pow; - float kink_freq; - float kink_shape; - float kink_amp; - float free_end; - float tex_nabla; - short tex_mode; - short kink; - short kink_axis; - short rt2; - Tex *tex; - bInvalidHandle *rng; - float f_noise; - int seed; - }; -} - - -#endif//__BLENDER_PARTDEFLECT__H__ diff --git a/gamekit/autogenerated/blender_PartEff.h b/gamekit/autogenerated/blender_PartEff.h deleted file mode 100644 index 17d8ccd01..000000000 --- a/gamekit/autogenerated/blender_PartEff.h +++ /dev/null @@ -1,83 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_PARTEFF__H__ -#define __BLENDER_PARTEFF__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class PartEff - { - public: - PartEff *next; - PartEff *prev; - short type; - short flag; - short buttype; - short stype; - short vertgroup; - short userjit; - float sta; - float end; - float lifetime; - int totpart; - int totkey; - int seed; - float normfac; - float obfac; - float randfac; - float texfac; - float randlife; - vec3f force; - float damp; - float nabla; - float vectsize; - float maxlen; - float pad; - vec3f defvec; - vec4f mult; - vec4f life; - short child[4]; - short mat[4]; - short texmap; - short curmult; - short staticstep; - short omat; - short timetex; - short speedtex; - short flag2; - short flag2neg; - short disp; - short vertgroup_v; - char vgroupname[32]; - char vgroupname_v[32]; - float imat[4][4]; - bInvalidHandle *keys; - Group *group; - }; -} - - -#endif//__BLENDER_PARTEFF__H__ diff --git a/gamekit/autogenerated/blender_PartialVisibility.h b/gamekit/autogenerated/blender_PartialVisibility.h deleted file mode 100644 index 0751d4f8e..000000000 --- a/gamekit/autogenerated/blender_PartialVisibility.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_PARTIALVISIBILITY__H__ -#define __BLENDER_PARTIALVISIBILITY__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class PartialVisibility - { - public: - int *vert_map; - int *edge_map; - MFace *old_faces; - MEdge *old_edges; - int totface; - int totedge; - int totvert; - int pad; - }; -} - - -#endif//__BLENDER_PARTIALVISIBILITY__H__ diff --git a/gamekit/autogenerated/blender_ParticleBrushData.h b/gamekit/autogenerated/blender_ParticleBrushData.h deleted file mode 100644 index dddc0c47f..000000000 --- a/gamekit/autogenerated/blender_ParticleBrushData.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_PARTICLEBRUSHDATA__H__ -#define __BLENDER_PARTICLEBRUSHDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class ParticleBrushData - { - public: - short size; - short strength; - short step; - short invert; - }; -} - - -#endif//__BLENDER_PARTICLEBRUSHDATA__H__ diff --git a/gamekit/autogenerated/blender_ParticleData.h b/gamekit/autogenerated/blender_ParticleData.h deleted file mode 100644 index d0b964072..000000000 --- a/gamekit/autogenerated/blender_ParticleData.h +++ /dev/null @@ -1,65 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_PARTICLEDATA__H__ -#define __BLENDER_PARTICLEDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ParticleKey.h" - -namespace Blender { - - - // ---------------------------------------------- // - class ParticleData - { - public: - Object *stick_ob; - ParticleKey state; - ParticleKey prev_state; - HairKey *hair; - ParticleKey *keys; - vec4f i_rot; - vec4f r_rot; - vec3f r_ave; - vec3f r_ve; - vec4f fuv; - float foffset; - float time; - float lifetime; - float dietime; - float bank; - float size; - float sizemul; - int num; - int num_dmcache; - int pad; - int totkey; - int bpi; - short flag; - short alive; - short loop; - short rt2; - }; -} - - -#endif//__BLENDER_PARTICLEDATA__H__ diff --git a/gamekit/autogenerated/blender_ParticleEditSettings.h b/gamekit/autogenerated/blender_ParticleEditSettings.h deleted file mode 100644 index 9bed8b286..000000000 --- a/gamekit/autogenerated/blender_ParticleEditSettings.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_PARTICLEEDITSETTINGS__H__ -#define __BLENDER_PARTICLEEDITSETTINGS__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ParticleBrushData.h" - -namespace Blender { - - - // ---------------------------------------------- // - class ParticleEditSettings - { - public: - short flag; - short totrekey; - short totaddkey; - short brushtype; - ParticleBrushData brush[7]; - float emitterdist; - int draw_timed; - }; -} - - -#endif//__BLENDER_PARTICLEEDITSETTINGS__H__ diff --git a/gamekit/autogenerated/blender_ParticleInstanceModifierData.h b/gamekit/autogenerated/blender_ParticleInstanceModifierData.h deleted file mode 100644 index 89a812faf..000000000 --- a/gamekit/autogenerated/blender_ParticleInstanceModifierData.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_PARTICLEINSTANCEMODIFIERDATA__H__ -#define __BLENDER_PARTICLEINSTANCEMODIFIERDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ModifierData.h" - -namespace Blender { - - - // ---------------------------------------------- // - class ParticleInstanceModifierData - { - public: - ModifierData modifier; - Object *ob; - short psys; - short flag; - short rt[2]; - }; -} - - -#endif//__BLENDER_PARTICLEINSTANCEMODIFIERDATA__H__ diff --git a/gamekit/autogenerated/blender_ParticleKey.h b/gamekit/autogenerated/blender_ParticleKey.h deleted file mode 100644 index 8f4958fbf..000000000 --- a/gamekit/autogenerated/blender_ParticleKey.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_PARTICLEKEY__H__ -#define __BLENDER_PARTICLEKEY__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class ParticleKey - { - public: - vec3f co; - vec3f vel; - vec4f rot; - vec3f ave; - float time; - }; -} - - -#endif//__BLENDER_PARTICLEKEY__H__ diff --git a/gamekit/autogenerated/blender_ParticleSettings.h b/gamekit/autogenerated/blender_ParticleSettings.h deleted file mode 100644 index c6c5cec28..000000000 --- a/gamekit/autogenerated/blender_ParticleSettings.h +++ /dev/null @@ -1,151 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_PARTICLESETTINGS__H__ -#define __BLENDER_PARTICLESETTINGS__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ID.h" - -namespace Blender { - - - // ---------------------------------------------- // - class ParticleSettings - { - public: - ID id; - int flag; - short type; - short from; - short distr; - short phystype; - short rotmode; - short avemode; - short reactevent; - short draw; - short draw_as; - short draw_size; - short childtype; - short draw_step; - short ren_step; - short hair_step; - short keys_step; - short adapt_angle; - short adapt_pix; - short disp; - short omat; - short interpolation; - short rotfrom; - short integrator; - short kink; - short kink_axis; - short nbetween; - short boidneighbours; - short bb_align; - short bb_uv_split; - short bb_anim; - short bb_split_offset; - float bb_tilt; - float bb_rand_tilt; - float bb_offset[2]; - short simplify_flag; - short simplify_refsize; - float simplify_rate; - float simplify_transition; - float simplify_viewport; - float sta; - float end; - float lifetime; - float randlife; - float timetweak; - float jitfac; - float keyed_time; - float eff_hair; - float rt; - int totpart; - int userjit; - int grid_res; - float normfac; - float obfac; - float randfac; - float partfac; - float tanfac; - float tanphase; - float reactfac; - float avefac; - float phasefac; - float randrotfac; - float randphasefac; - float mass; - float size; - float randsize; - float reactshape; - vec3f acc; - float dragfac; - float brownfac; - float dampfac; - float length; - float abslength; - float randlength; - int child_nbr; - int ren_child_nbr; - float parents; - float childsize; - float childrandsize; - float childrad; - float childflat; - float childspread; - float clumpfac; - float clumppow; - float kink_amp; - float kink_freq; - float kink_shape; - float rough1; - float rough1_size; - float rough2; - float rough2_size; - float rough2_thres; - float rough_end; - float rough_end_shape; - float branch_thres; - float draw_line[2]; - float max_vel; - float max_lat_acc; - float max_tan_acc; - float average_vel; - float banking; - float max_bank; - float groundz; - float boidfac[8]; - char boidrule[8]; - Group *dup_group; - Group *eff_group; - Object *dup_ob; - Object *bb_ob; - Ipo *ipo; - PartDeflect *pd; - PartDeflect *pd2; - }; -} - - -#endif//__BLENDER_PARTICLESETTINGS__H__ diff --git a/gamekit/autogenerated/blender_ParticleSystem.h b/gamekit/autogenerated/blender_ParticleSystem.h deleted file mode 100644 index e41cb3d58..000000000 --- a/gamekit/autogenerated/blender_ParticleSystem.h +++ /dev/null @@ -1,76 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_PARTICLESYSTEM__H__ -#define __BLENDER_PARTICLESYSTEM__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ListBase.h" - -namespace Blender { - - - // ---------------------------------------------- // - class ParticleSystem - { - public: - ParticleSystem *next; - ParticleSystem *prev; - ParticleSettings *part; - ParticleData *particles; - ChildParticle *child; - bInvalidHandle *edit; - bInvalidHandle **pathcache; - bInvalidHandle **childcache; - ListBase pathcachebufs; - ListBase childcachebufs; - SoftBody *soft; - Object *target_ob; - Object *keyed_ob; - Object *lattice; - ListBase effectors; - ListBase reactevents; - float imat[4][4]; - float cfra; - int seed; - int flag; - int totpart; - int totchild; - int totcached; - int totchildcache; - int rt; - short recalc; - short target_psys; - short keyed_psys; - short totkeyed; - short softflag; - short bakespace; - char bb_uvname[3][32]; - short vgroup[12]; - short vg_neg; - short rt3; - void *renderdata; - PointCache *pointcache; - }; -} - - -#endif//__BLENDER_PARTICLESYSTEM__H__ diff --git a/gamekit/autogenerated/blender_ParticleSystemModifierData.h b/gamekit/autogenerated/blender_ParticleSystemModifierData.h deleted file mode 100644 index f10f44c37..000000000 --- a/gamekit/autogenerated/blender_ParticleSystemModifierData.h +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_PARTICLESYSTEMMODIFIERDATA__H__ -#define __BLENDER_PARTICLESYSTEMMODIFIERDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ModifierData.h" - -namespace Blender { - - - // ---------------------------------------------- // - class ParticleSystemModifierData - { - public: - ModifierData modifier; - ParticleSystem *psys; - bInvalidHandle *dm; - int totdmvert; - int totdmedge; - int totdmface; - short flag; - short rt; - }; -} - - -#endif//__BLENDER_PARTICLESYSTEMMODIFIERDATA__H__ diff --git a/gamekit/autogenerated/blender_PluginSeq.h b/gamekit/autogenerated/blender_PluginSeq.h deleted file mode 100644 index 4f3b8fcce..000000000 --- a/gamekit/autogenerated/blender_PluginSeq.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_PLUGINSEQ__H__ -#define __BLENDER_PLUGINSEQ__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class PluginSeq - { - public: - char name[256]; - void *handle; - char *pname; - int vars; - int version; - void *varstr; - float *cfra; - float data[32]; - void *instance_private_data; - void **current_private_data; - void (*doit)(); - void (*callback)(); - }; -} - - -#endif//__BLENDER_PLUGINSEQ__H__ diff --git a/gamekit/autogenerated/blender_PluginTex.h b/gamekit/autogenerated/blender_PluginTex.h deleted file mode 100644 index 683640086..000000000 --- a/gamekit/autogenerated/blender_PluginTex.h +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_PLUGINTEX__H__ -#define __BLENDER_PLUGINTEX__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class PluginTex - { - public: - char name[160]; - void *handle; - char *pname; - char *stnames; - int stypes; - int vars; - void *varstr; - float *result; - float *cfra; - float data[32]; - int (*doit)(); - void (*instance_init)(); - void (*callback)(); - int version; - int pad; - }; -} - - -#endif//__BLENDER_PLUGINTEX__H__ diff --git a/gamekit/autogenerated/blender_PointCache.h b/gamekit/autogenerated/blender_PointCache.h deleted file mode 100644 index af723da30..000000000 --- a/gamekit/autogenerated/blender_PointCache.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_POINTCACHE__H__ -#define __BLENDER_POINTCACHE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class PointCache - { - public: - int flag; - int simframe; - int startframe; - int endframe; - int editframe; - }; -} - - -#endif//__BLENDER_POINTCACHE__H__ diff --git a/gamekit/autogenerated/blender_PreviewImage.h b/gamekit/autogenerated/blender_PreviewImage.h deleted file mode 100644 index 5cbd27c4d..000000000 --- a/gamekit/autogenerated/blender_PreviewImage.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_PREVIEWIMAGE__H__ -#define __BLENDER_PREVIEWIMAGE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class PreviewImage - { - public: - int w[2]; - int h[2]; - short changed[2]; - short pad0; - short pad1; - int *rect[2]; - }; -} - - -#endif//__BLENDER_PREVIEWIMAGE__H__ diff --git a/gamekit/autogenerated/blender_QuicktimeCodecData.h b/gamekit/autogenerated/blender_QuicktimeCodecData.h deleted file mode 100644 index 8ef3e53c9..000000000 --- a/gamekit/autogenerated/blender_QuicktimeCodecData.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_QUICKTIMECODECDATA__H__ -#define __BLENDER_QUICKTIMECODECDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class QuicktimeCodecData - { - public: - void *cdParms; - void *pad; - int cdSize; - int pad2; - char qtcodecname[128]; - }; -} - - -#endif//__BLENDER_QUICKTIMECODECDATA__H__ diff --git a/gamekit/autogenerated/blender_Radio.h b/gamekit/autogenerated/blender_Radio.h deleted file mode 100644 index 3aa90835c..000000000 --- a/gamekit/autogenerated/blender_Radio.h +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_RADIO__H__ -#define __BLENDER_RADIO__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class Radio - { - public: - short hemires; - short maxiter; - short drawtype; - short flag; - short subshootp; - short subshoote; - short nodelim; - short maxsublamp; - short pama; - short pami; - short elma; - short elmi; - int maxnode; - float convergence; - float radfac; - float gamma; - }; -} - - -#endif//__BLENDER_RADIO__H__ diff --git a/gamekit/autogenerated/blender_RenderData.h b/gamekit/autogenerated/blender_RenderData.h deleted file mode 100644 index 28b04c365..000000000 --- a/gamekit/autogenerated/blender_RenderData.h +++ /dev/null @@ -1,172 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_RENDERDATA__H__ -#define __BLENDER_RENDERDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_FFMpegCodecData.h" -#include "blender_ListBase.h" -#include "blender_rctf.h" -#include "blender_rcti.h" - -namespace Blender { - - - // ---------------------------------------------- // - class RenderData - { - public: - AviCodecData *avicodecdata; - QuicktimeCodecData *qtcodecdata; - FFMpegCodecData ffcodecdata; - int cfra; - int sfra; - int efra; - int psfra; - int pefra; - int images; - int framapto; - short flag; - short threads; - float ctime; - float framelen; - float blurfac; - float edgeR; - float edgeG; - float edgeB; - short fullscreen; - short xplay; - short yplay; - short freqplay; - short depth; - short attrib; - short rt1; - short rt2; - short stereomode; - short dimensionspreset; - short filtertype; - short size; - short maximsize; - short xsch; - short ysch; - short xparts; - short yparts; - short winpos; - short planes; - short imtype; - short subimtype; - short bufflag; - short quality; - short rpad; - short rpad1; - short rpad2; - int scemode; - int mode; - short renderer; - short ocres; - short alphamode; - short osa; - short frs_sec; - short edgeint; - rctf safety; - rctf border; - rcti disprect; - ListBase layers; - short actlay; - short pad; - float xasp; - float yasp; - float frs_sec_base; - float gauss; - float postmul; - float postgamma; - float posthue; - float postsat; - float dither_intensity; - short bake_osa; - short bake_filter; - short bake_mode; - short bake_flag; - short bake_normal_space; - short bake_quad_split; - float bake_maxdist; - float bake_biasdist; - float bake_pad; - short GIquality; - short GIcache; - short GImethod; - short GIphotons; - short GIdirect; - short YF_AA; - short YFexportxml; - short YF_nobump; - short YF_clamprgb; - short yfpad1; - int GIdepth; - int GIcausdepth; - int GIpixelspersample; - int GIphotoncount; - int GImixphotons; - float GIphotonradius; - int YF_raydepth; - int YF_AApasses; - int YF_AAsamples; - int yfpad2; - float GIshadowquality; - float GIrefinement; - float GIpower; - float GIindirpower; - float YF_gamma; - float YF_exposure; - float YF_raybias; - float YF_AApixelsize; - float YF_AAthreshold; - char backbuf[160]; - char pic[160]; - int stamp; - short stamp_font_id; - short pad3; - char stamp_udata[160]; - vec4f fg_stamp; - vec4f bg_stamp; - int simplify_subsurf; - int simplify_shadowsamples; - float simplify_particles; - float simplify_aosss; - short cineonwhite; - short cineonblack; - float cineongamma; - short jp2_preset; - short jp2_depth; - int rpad3; - short domeres; - short domemode; - short domeangle; - short dometilt; - float domeresbuf; - float pad2; - Text *dometext; - }; -} - - -#endif//__BLENDER_RENDERDATA__H__ diff --git a/gamekit/autogenerated/blender_RenderProfile.h b/gamekit/autogenerated/blender_RenderProfile.h deleted file mode 100644 index 4994648e0..000000000 --- a/gamekit/autogenerated/blender_RenderProfile.h +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_RENDERPROFILE__H__ -#define __BLENDER_RENDERPROFILE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class RenderProfile - { - public: - RenderProfile *next; - RenderProfile *prev; - char name[32]; - short particle_perc; - short subsurf_max; - short shadbufsample_max; - short pad1; - float ao_error; - float pad2; - }; -} - - -#endif//__BLENDER_RENDERPROFILE__H__ diff --git a/gamekit/autogenerated/blender_SBVertex.h b/gamekit/autogenerated/blender_SBVertex.h deleted file mode 100644 index daa726b4b..000000000 --- a/gamekit/autogenerated/blender_SBVertex.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_SBVERTEX__H__ -#define __BLENDER_SBVERTEX__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class SBVertex - { - public: - vec4f vec; - }; -} - - -#endif//__BLENDER_SBVERTEX__H__ diff --git a/gamekit/autogenerated/blender_Scene.h b/gamekit/autogenerated/blender_Scene.h deleted file mode 100644 index a8cecfaf1..000000000 --- a/gamekit/autogenerated/blender_Scene.h +++ /dev/null @@ -1,88 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_SCENE__H__ -#define __BLENDER_SCENE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_AudioData.h" -#include "blender_GameFraming.h" -#include "blender_ID.h" -#include "blender_ListBase.h" -#include "blender_RenderData.h" -#include "blender_ScriptLink.h" -#include "blender_SculptData.h" - -namespace Blender { - - - // ---------------------------------------------- // - class Scene - { - public: - ID id; - Object *camera; - World *world; - Scene *set; - Image *ima; - ListBase base; - Base *basact; - vec3f cursor; - vec3f twcent; - vec3f twmin; - vec3f twmax; - int lay; - float editbutsize; - short selectmode; - short proportional; - short prop_mode; - short automerge; - short pad5; - short pad6; - short autokey_mode; - short use_nodes; - bNodeTree *nodetree; - void *ed; - Radio *radio; - GameFraming framing; - ToolSettings *toolsettings; - RenderData r; - AudioData audio; - ScriptLink scriptlink; - ListBase markers; - ListBase transform_spaces; - short jumpframe; - short snap_mode; - short snap_flag; - short snap_target; - bInvalidHandle *theDag; - short dagisvalid; - short dagflags; - short pad4; - short recalc; - SculptData sculptdata; - int frame_step; - int pad; - }; -} - - -#endif//__BLENDER_SCENE__H__ diff --git a/gamekit/autogenerated/blender_SceneRenderLayer.h b/gamekit/autogenerated/blender_SceneRenderLayer.h deleted file mode 100644 index 4e8d75655..000000000 --- a/gamekit/autogenerated/blender_SceneRenderLayer.h +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_SCENERENDERLAYER__H__ -#define __BLENDER_SCENERENDERLAYER__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class SceneRenderLayer - { - public: - SceneRenderLayer *next; - SceneRenderLayer *prev; - char name[32]; - Material *mat_override; - Group *light_override; - int lay; - int lay_zmask; - int layflag; - int pad; - int passflag; - int pass_xor; - }; -} - - -#endif//__BLENDER_SCENERENDERLAYER__H__ diff --git a/gamekit/autogenerated/blender_ScrArea.h b/gamekit/autogenerated/blender_ScrArea.h deleted file mode 100644 index fae879573..000000000 --- a/gamekit/autogenerated/blender_ScrArea.h +++ /dev/null @@ -1,71 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_SCRAREA__H__ -#define __BLENDER_SCRAREA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ListBase.h" -#include "blender_ScriptLink.h" -#include "blender_rcti.h" - -namespace Blender { - - - // ---------------------------------------------- // - class ScrArea - { - public: - ScrArea *next; - ScrArea *prev; - ScrVert *v1; - ScrVert *v2; - ScrVert *v3; - ScrVert *v4; - bScreen *full; - float winmat[4][4]; - rcti totrct; - rcti headrct; - rcti winrct; - short headwin; - short win; - short headertype; - char spacetype; - char butspacetype; - short winx; - short winy; - char head_swap; - char head_equal; - char win_swap; - char win_equal; - short headbutlen; - short headbutofs; - short cursor; - short flag; - ScriptLink scriptlink; - ListBase spacedata; - ListBase uiblocks; - ListBase panels; - }; -} - - -#endif//__BLENDER_SCRAREA__H__ diff --git a/gamekit/autogenerated/blender_ScrEdge.h b/gamekit/autogenerated/blender_ScrEdge.h deleted file mode 100644 index f6ec7b695..000000000 --- a/gamekit/autogenerated/blender_ScrEdge.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_SCREDGE__H__ -#define __BLENDER_SCREDGE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class ScrEdge - { - public: - ScrEdge *next; - ScrEdge *prev; - ScrVert *v1; - ScrVert *v2; - short border; - short flag; - int pad; - }; -} - - -#endif//__BLENDER_SCREDGE__H__ diff --git a/gamekit/autogenerated/blender_ScrVert.h b/gamekit/autogenerated/blender_ScrVert.h deleted file mode 100644 index 9d2c01e71..000000000 --- a/gamekit/autogenerated/blender_ScrVert.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_SCRVERT__H__ -#define __BLENDER_SCRVERT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_vec2s.h" - -namespace Blender { - - - // ---------------------------------------------- // - class ScrVert - { - public: - ScrVert *next; - ScrVert *prev; - ScrVert *newv; - vec2s vec; - int flag; - }; -} - - -#endif//__BLENDER_SCRVERT__H__ diff --git a/gamekit/autogenerated/blender_Script.h b/gamekit/autogenerated/blender_Script.h deleted file mode 100644 index 91736c91b..000000000 --- a/gamekit/autogenerated/blender_Script.h +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_SCRIPT__H__ -#define __BLENDER_SCRIPT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ID.h" - -namespace Blender { - - - // ---------------------------------------------- // - class Script - { - public: - ID id; - void *py_draw; - void *py_event; - void *py_button; - void *py_browsercallback; - void *py_globaldict; - int flags; - int lastspace; - char scriptname[256]; - char scriptarg[256]; - }; -} - - -#endif//__BLENDER_SCRIPT__H__ diff --git a/gamekit/autogenerated/blender_ScriptLink.h b/gamekit/autogenerated/blender_ScriptLink.h deleted file mode 100644 index bda567a5d..000000000 --- a/gamekit/autogenerated/blender_ScriptLink.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_SCRIPTLINK__H__ -#define __BLENDER_SCRIPTLINK__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class ScriptLink - { - public: - ID **scripts; - short *flag; - short actscript; - short totscript; - int pad; - }; -} - - -#endif//__BLENDER_SCRIPTLINK__H__ diff --git a/gamekit/autogenerated/blender_SculptData.h b/gamekit/autogenerated/blender_SculptData.h deleted file mode 100644 index f911b0fb8..000000000 --- a/gamekit/autogenerated/blender_SculptData.h +++ /dev/null @@ -1,65 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_SCULPTDATA__H__ -#define __BLENDER_SCULPTDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_BrushData.h" - -namespace Blender { - - - // ---------------------------------------------- // - class SculptData - { - public: - bInvalidHandle *session; - MTex *mtex[18]; - CurveMapping *cumap; - BrushData drawbrush; - BrushData smoothbrush; - BrushData pinchbrush; - BrushData inflatebrush; - BrushData grabbrush; - BrushData layerbrush; - BrushData flattenbrush; - vec3f pivot; - short brush_type; - short texact; - short texnr; - short spacing; - char texrept; - char texfade; - char texsep; - char averaging; - char flags; - char tablet_size; - char tablet_strength; - char symm; - char rake; - char axislock; - char pad[2]; - }; -} - - -#endif//__BLENDER_SCULPTDATA__H__ diff --git a/gamekit/autogenerated/blender_Sequence.h b/gamekit/autogenerated/blender_Sequence.h deleted file mode 100644 index ad57a337a..000000000 --- a/gamekit/autogenerated/blender_Sequence.h +++ /dev/null @@ -1,82 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_SEQUENCE__H__ -#define __BLENDER_SEQUENCE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ListBase.h" - -namespace Blender { - - - // ---------------------------------------------- // - class Sequence - { - public: - Sequence *next; - Sequence *prev; - void *tmp; - void *lib; - char name[24]; - int flag; - int type; - int len; - int start; - int startofs; - int endofs; - int startstill; - int endstill; - int machine; - int depth; - int startdisp; - int enddisp; - float mul; - float handsize; - int sfra; - int anim_preseek; - Strip *strip; - Ipo *ipo; - Scene *scene; - bInvalidHandle *anim; - float facf0; - float facf1; - PluginSeq *plugin; - Sequence *seq1; - Sequence *seq2; - Sequence *seq3; - ListBase seqbase; - bSound *sound; - bInvalidHandle *hdaudio; - float level; - float pan; - int scenenr; - float strobe; - void *effectdata; - int anim_startofs; - int anim_endofs; - int blend_mode; - float blend_opacity; - }; -} - - -#endif//__BLENDER_SEQUENCE__H__ diff --git a/gamekit/autogenerated/blender_ShrinkwrapModifierData.h b/gamekit/autogenerated/blender_ShrinkwrapModifierData.h deleted file mode 100644 index c4d7fa629..000000000 --- a/gamekit/autogenerated/blender_ShrinkwrapModifierData.h +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_SHRINKWRAPMODIFIERDATA__H__ -#define __BLENDER_SHRINKWRAPMODIFIERDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ModifierData.h" - -namespace Blender { - - - // ---------------------------------------------- // - class ShrinkwrapModifierData - { - public: - ModifierData modifier; - Object *target; - Object *auxTarget; - char vgroup_name[32]; - float keepDist; - short shrinkType; - short shrinkOpts; - char projAxis; - char subsurfLevels; - char pad[6]; - }; -} - - -#endif//__BLENDER_SHRINKWRAPMODIFIERDATA__H__ diff --git a/gamekit/autogenerated/blender_SimpleDeformModifierData.h b/gamekit/autogenerated/blender_SimpleDeformModifierData.h deleted file mode 100644 index 3a1159ccd..000000000 --- a/gamekit/autogenerated/blender_SimpleDeformModifierData.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_SIMPLEDEFORMMODIFIERDATA__H__ -#define __BLENDER_SIMPLEDEFORMMODIFIERDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ModifierData.h" - -namespace Blender { - - - // ---------------------------------------------- // - class SimpleDeformModifierData - { - public: - ModifierData modifier; - Object *origin; - char vgroup_name[32]; - float factor; - float limit[2]; - char mode; - char axis; - char originOpts; - char pad; - }; -} - - -#endif//__BLENDER_SIMPLEDEFORMMODIFIERDATA__H__ diff --git a/gamekit/autogenerated/blender_SmoothModifierData.h b/gamekit/autogenerated/blender_SmoothModifierData.h deleted file mode 100644 index beef19b69..000000000 --- a/gamekit/autogenerated/blender_SmoothModifierData.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_SMOOTHMODIFIERDATA__H__ -#define __BLENDER_SMOOTHMODIFIERDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ModifierData.h" - -namespace Blender { - - - // ---------------------------------------------- // - class SmoothModifierData - { - public: - ModifierData modifier; - float fac; - char defgrp_name[32]; - short flag; - short repeat; - }; -} - - -#endif//__BLENDER_SMOOTHMODIFIERDATA__H__ diff --git a/gamekit/autogenerated/blender_SoftBody.h b/gamekit/autogenerated/blender_SoftBody.h deleted file mode 100644 index de092fb54..000000000 --- a/gamekit/autogenerated/blender_SoftBody.h +++ /dev/null @@ -1,87 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_SOFTBODY__H__ -#define __BLENDER_SOFTBODY__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class SoftBody - { - public: - ParticleSystem *particles; - int totpoint; - int totspring; - bInvalidHandle *bpoint; - bInvalidHandle *bspring; - char pad; - char msg_lock; - short msg_value; - float nodemass; - char namedVG_Mass[32]; - float grav; - float mediafrict; - float rklimit; - float physics_speed; - float goalspring; - float goalfrict; - float mingoal; - float maxgoal; - float defgoal; - short vertgroup; - char namedVG_Softgoal[32]; - short fuzzyness; - float inspring; - float infrict; - char namedVG_Spring_K[32]; - int sfra; - int efra; - int interval; - short local; - short solverflags; - SBVertex **keys; - int totpointkey; - int totkey; - float secondspring; - float colball; - float balldamp; - float ballstiff; - short sbc_mode; - short aeroedge; - short minloops; - short maxloops; - short choke; - short solver_ID; - short plastic; - short springpreload; - bInvalidHandle *scratch; - float shearstiff; - float inpush; - PointCache *pointcache; - }; -} - - -#endif//__BLENDER_SOFTBODY__H__ diff --git a/gamekit/autogenerated/blender_SoftbodyModifierData.h b/gamekit/autogenerated/blender_SoftbodyModifierData.h deleted file mode 100644 index e19a90cb5..000000000 --- a/gamekit/autogenerated/blender_SoftbodyModifierData.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_SOFTBODYMODIFIERDATA__H__ -#define __BLENDER_SOFTBODYMODIFIERDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ModifierData.h" - -namespace Blender { - - - // ---------------------------------------------- // - class SoftbodyModifierData - { - public: - ModifierData modifier; - }; -} - - -#endif//__BLENDER_SOFTBODYMODIFIERDATA__H__ diff --git a/gamekit/autogenerated/blender_SolidColorVars.h b/gamekit/autogenerated/blender_SolidColorVars.h deleted file mode 100644 index bb5716ac5..000000000 --- a/gamekit/autogenerated/blender_SolidColorVars.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_SOLIDCOLORVARS__H__ -#define __BLENDER_SOLIDCOLORVARS__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class SolidColorVars - { - public: - vec3f col; - float pad; - }; -} - - -#endif//__BLENDER_SOLIDCOLORVARS__H__ diff --git a/gamekit/autogenerated/blender_SolidLight.h b/gamekit/autogenerated/blender_SolidLight.h deleted file mode 100644 index 5f5839f23..000000000 --- a/gamekit/autogenerated/blender_SolidLight.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_SOLIDLIGHT__H__ -#define __BLENDER_SOLIDLIGHT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class SolidLight - { - public: - int flag; - int pad; - vec4f col; - vec4f spec; - vec4f vec; - }; -} - - -#endif//__BLENDER_SOLIDLIGHT__H__ diff --git a/gamekit/autogenerated/blender_SpaceAction.h b/gamekit/autogenerated/blender_SpaceAction.h deleted file mode 100644 index 51a8cb5f9..000000000 --- a/gamekit/autogenerated/blender_SpaceAction.h +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_SPACEACTION__H__ -#define __BLENDER_SPACEACTION__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_View2D.h" - -namespace Blender { - - - // ---------------------------------------------- // - class SpaceAction - { - public: - SpaceLink *next; - SpaceLink *prev; - int spacetype; - float blockscale; - ScrArea *area; - short blockhandler[8]; - View2D v2d; - bAction *action; - char mode; - char autosnap; - short flag; - short actnr; - short pin; - short lock; - short actwidth; - float timeslide; - }; -} - - -#endif//__BLENDER_SPACEACTION__H__ diff --git a/gamekit/autogenerated/blender_SpaceButs.h b/gamekit/autogenerated/blender_SpaceButs.h deleted file mode 100644 index 7a5a664a5..000000000 --- a/gamekit/autogenerated/blender_SpaceButs.h +++ /dev/null @@ -1,68 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_SPACEBUTS__H__ -#define __BLENDER_SPACEBUTS__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_View2D.h" - -namespace Blender { - - - // ---------------------------------------------- // - class SpaceButs - { - public: - SpaceLink *next; - SpaceLink *prev; - int spacetype; - float blockscale; - ScrArea *area; - bInvalidHandle *ri; - short blockhandler[8]; - short cursens; - short curact; - short align; - short tabo; - View2D v2d; - short mainb; - short menunr; - short pin; - short mainbo; - void *lockpoin; - short texnr; - char texfrom; - char showgroup; - short modeltype; - short scriptblock; - short scaflag; - short re_align; - short oldkeypress; - char pad; - char flag; - char texact; - char tab[7]; - }; -} - - -#endif//__BLENDER_SPACEBUTS__H__ diff --git a/gamekit/autogenerated/blender_SpaceFile.h b/gamekit/autogenerated/blender_SpaceFile.h deleted file mode 100644 index 3c6c29e59..000000000 --- a/gamekit/autogenerated/blender_SpaceFile.h +++ /dev/null @@ -1,71 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_SPACEFILE__H__ -#define __BLENDER_SPACEFILE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class SpaceFile - { - public: - SpaceLink *next; - SpaceLink *prev; - int spacetype; - float blockscale; - ScrArea *area; - short blockhandler[8]; - bInvalidHandle *filelist; - int totfile; - char title[24]; - char dir[240]; - char file[80]; - short type; - short ofs; - short flag; - short sort; - short maxnamelen; - short collums; - short f_fp; - short pad1; - int pad2; - char fp_str[8]; - bInvalidHandle *libfiledata; - short retval; - short menu; - short act; - short ipotype; - void (*returnfunc)(); - void (*returnfunc_event)(); - void (*returnfunc_args)(); - void *arg1; - void *arg2; - short *menup; - char *pupmenu; - }; -} - - -#endif//__BLENDER_SPACEFILE__H__ diff --git a/gamekit/autogenerated/blender_SpaceImaSel.h b/gamekit/autogenerated/blender_SpaceImaSel.h deleted file mode 100644 index 2c3b46e28..000000000 --- a/gamekit/autogenerated/blender_SpaceImaSel.h +++ /dev/null @@ -1,82 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_SPACEIMASEL__H__ -#define __BLENDER_SPACEIMASEL__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_View2D.h" -#include "blender_rcti.h" - -namespace Blender { - - - // ---------------------------------------------- // - class SpaceImaSel - { - public: - SpaceLink *next; - SpaceLink *prev; - int spacetype; - float blockscale; - ScrArea *area; - short blockhandler[8]; - View2D v2d; - bInvalidHandle *files; - char title[24]; - char dir[240]; - char file[80]; - short type; - short menu; - short flag; - short sort; - void *curfont; - int active_file; - int numtilesx; - int numtilesy; - int selstate; - rcti viewrect; - rcti bookmarkrect; - float scrollpos; - float scrollheight; - float scrollarea; - float aspect; - short retval; - short ipotype; - short filter; - short active_bookmark; - short pad; - short pad1; - short prv_w; - short prv_h; - void (*returnfunc)(); - void (*returnfunc_event)(); - void (*returnfunc_args)(); - void *arg1; - void *arg2; - short *menup; - char *pupmenu; - bInvalidHandle *img; - }; -} - - -#endif//__BLENDER_SPACEIMASEL__H__ diff --git a/gamekit/autogenerated/blender_SpaceImage.h b/gamekit/autogenerated/blender_SpaceImage.h deleted file mode 100644 index d8c709c15..000000000 --- a/gamekit/autogenerated/blender_SpaceImage.h +++ /dev/null @@ -1,69 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_SPACEIMAGE__H__ -#define __BLENDER_SPACEIMAGE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ImageUser.h" -#include "blender_View2D.h" - -namespace Blender { - - - // ---------------------------------------------- // - class SpaceImage - { - public: - SpaceLink *next; - SpaceLink *prev; - int spacetype; - float blockscale; - ScrArea *area; - short blockhandler[8]; - View2D v2d; - Image *image; - ImageUser iuser; - CurveMapping *cumap; - short mode; - short menunr; - short imanr; - short curtile; - int flag; - short selectmode; - short imtypenr; - short lock; - short pin; - float zoom; - char dt_uv; - char sticky; - char dt_uvstretch; - char pad[5]; - float xof; - float yof; - float centx; - float centy; - bGPdata *gpd; - }; -} - - -#endif//__BLENDER_SPACEIMAGE__H__ diff --git a/gamekit/autogenerated/blender_SpaceInfo.h b/gamekit/autogenerated/blender_SpaceInfo.h deleted file mode 100644 index 5761b7796..000000000 --- a/gamekit/autogenerated/blender_SpaceInfo.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_SPACEINFO__H__ -#define __BLENDER_SPACEINFO__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class SpaceInfo - { - public: - SpaceLink *next; - SpaceLink *prev; - int spacetype; - float blockscale; - ScrArea *area; - short blockhandler[8]; - }; -} - - -#endif//__BLENDER_SPACEINFO__H__ diff --git a/gamekit/autogenerated/blender_SpaceIpo.h b/gamekit/autogenerated/blender_SpaceIpo.h deleted file mode 100644 index 8e6a454ab..000000000 --- a/gamekit/autogenerated/blender_SpaceIpo.h +++ /dev/null @@ -1,68 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_SPACEIPO__H__ -#define __BLENDER_SPACEIPO__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ListBase.h" -#include "blender_View2D.h" -#include "blender_rctf.h" - -namespace Blender { - - - // ---------------------------------------------- // - class SpaceIpo - { - public: - SpaceLink *next; - SpaceLink *prev; - int spacetype; - float blockscale; - ScrArea *area; - short blockhandler[8]; - int rowbut; - int pad2; - View2D v2d; - void *editipo; - ListBase ipokey; - Ipo *ipo; - ID *from; - char actname[32]; - char constname[32]; - char bonename[32]; - short totipo; - short pin; - short butofs; - short channel; - short showkey; - short blocktype; - short menunr; - short lock; - int flag; - vec3f median; - rctf tot; - }; -} - - -#endif//__BLENDER_SPACEIPO__H__ diff --git a/gamekit/autogenerated/blender_SpaceLink.h b/gamekit/autogenerated/blender_SpaceLink.h deleted file mode 100644 index d641f6777..000000000 --- a/gamekit/autogenerated/blender_SpaceLink.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_SPACELINK__H__ -#define __BLENDER_SPACELINK__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class SpaceLink - { - public: - SpaceLink *next; - SpaceLink *prev; - int spacetype; - float blockscale; - ScrArea *area; - short blockhandler[8]; - }; -} - - -#endif//__BLENDER_SPACELINK__H__ diff --git a/gamekit/autogenerated/blender_SpaceNla.h b/gamekit/autogenerated/blender_SpaceNla.h deleted file mode 100644 index 219e36377..000000000 --- a/gamekit/autogenerated/blender_SpaceNla.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_SPACENLA__H__ -#define __BLENDER_SPACENLA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_View2D.h" - -namespace Blender { - - - // ---------------------------------------------- // - class SpaceNla - { - public: - SpaceLink *next; - SpaceLink *prev; - int spacetype; - float blockscale; - ScrArea *area; - short blockhandler[8]; - short menunr; - short lock; - short autosnap; - short flag; - View2D v2d; - }; -} - - -#endif//__BLENDER_SPACENLA__H__ diff --git a/gamekit/autogenerated/blender_SpaceNode.h b/gamekit/autogenerated/blender_SpaceNode.h deleted file mode 100644 index 004daa9ef..000000000 --- a/gamekit/autogenerated/blender_SpaceNode.h +++ /dev/null @@ -1,60 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_SPACENODE__H__ -#define __BLENDER_SPACENODE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_View2D.h" - -namespace Blender { - - - // ---------------------------------------------- // - class SpaceNode - { - public: - SpaceLink *next; - SpaceLink *prev; - int spacetype; - float blockscale; - ScrArea *area; - short blockhandler[8]; - View2D v2d; - ID *id; - ID *from; - short flag; - short menunr; - float aspect; - void *curfont; - float xof; - float yof; - bNodeTree *nodetree; - bNodeTree *edittree; - int treetype; - short texfrom; - short pad; - bGPdata *gpd; - }; -} - - -#endif//__BLENDER_SPACENODE__H__ diff --git a/gamekit/autogenerated/blender_SpaceOops.h b/gamekit/autogenerated/blender_SpaceOops.h deleted file mode 100644 index 1d74b7712..000000000 --- a/gamekit/autogenerated/blender_SpaceOops.h +++ /dev/null @@ -1,64 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_SPACEOOPS__H__ -#define __BLENDER_SPACEOOPS__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ListBase.h" -#include "blender_TreeStoreElem.h" -#include "blender_View2D.h" - -namespace Blender { - - - // ---------------------------------------------- // - class SpaceOops - { - public: - SpaceLink *next; - SpaceLink *prev; - int spacetype; - float blockscale; - ScrArea *area; - short blockhandler[8]; - View2D v2d; - ListBase oops; - short pin; - short visiflag; - short flag; - short rt; - void *lockpoin; - ListBase tree; - TreeStore *treestore; - char search_string[32]; - TreeStoreElem search_tse; - int search_flags; - int do_; - short type; - short outlinevis; - short storeflag; - short deps_flags; - }; -} - - -#endif//__BLENDER_SPACEOOPS__H__ diff --git a/gamekit/autogenerated/blender_SpaceScript.h b/gamekit/autogenerated/blender_SpaceScript.h deleted file mode 100644 index 68650912c..000000000 --- a/gamekit/autogenerated/blender_SpaceScript.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_SPACESCRIPT__H__ -#define __BLENDER_SPACESCRIPT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class SpaceScript - { - public: - SpaceLink *next; - SpaceLink *prev; - int spacetype; - float blockscale; - ScrArea *area; - Script *script; - short flags; - short menunr; - int pad1; - void *but_refs; - }; -} - - -#endif//__BLENDER_SPACESCRIPT__H__ diff --git a/gamekit/autogenerated/blender_SpaceSeq.h b/gamekit/autogenerated/blender_SpaceSeq.h deleted file mode 100644 index 68108cd4e..000000000 --- a/gamekit/autogenerated/blender_SpaceSeq.h +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_SPACESEQ__H__ -#define __BLENDER_SPACESEQ__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_View2D.h" - -namespace Blender { - - - // ---------------------------------------------- // - class SpaceSeq - { - public: - SpaceLink *next; - SpaceLink *prev; - int spacetype; - float blockscale; - ScrArea *area; - short blockhandler[8]; - View2D v2d; - float xof; - float yof; - short mainb; - short render_size; - short chanshown; - short zebra; - int flag; - float zoom; - bGPdata *gpd; - }; -} - - -#endif//__BLENDER_SPACESEQ__H__ diff --git a/gamekit/autogenerated/blender_SpaceSound.h b/gamekit/autogenerated/blender_SpaceSound.h deleted file mode 100644 index 1656aa376..000000000 --- a/gamekit/autogenerated/blender_SpaceSound.h +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_SPACESOUND__H__ -#define __BLENDER_SPACESOUND__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_View2D.h" - -namespace Blender { - - - // ---------------------------------------------- // - class SpaceSound - { - public: - SpaceLink *next; - SpaceLink *prev; - int spacetype; - float blockscale; - ScrArea *area; - View2D v2d; - bSound *sound; - short mode; - short sndnr; - short xof; - short yof; - short flag; - short lock; - int pad2; - }; -} - - -#endif//__BLENDER_SPACESOUND__H__ diff --git a/gamekit/autogenerated/blender_SpaceText.h b/gamekit/autogenerated/blender_SpaceText.h deleted file mode 100644 index 1dff3078b..000000000 --- a/gamekit/autogenerated/blender_SpaceText.h +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_SPACETEXT__H__ -#define __BLENDER_SPACETEXT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_rcti.h" - -namespace Blender { - - - // ---------------------------------------------- // - class SpaceText - { - public: - SpaceLink *next; - SpaceLink *prev; - int spacetype; - float blockscale; - ScrArea *area; - short blockhandler[8]; - Text *text; - int top; - int viewlines; - short flags; - short menunr; - int font_id; - int lheight; - int left; - int showlinenrs; - int tabnumber; - int currtab_set; - int showsyntax; - int overwrite; - float pix_per_line; - rcti txtscroll; - rcti txtbar; - int wordwrap; - int doplugins; - }; -} - - -#endif//__BLENDER_SPACETEXT__H__ diff --git a/gamekit/autogenerated/blender_SpaceTime.h b/gamekit/autogenerated/blender_SpaceTime.h deleted file mode 100644 index dd6b2a2ed..000000000 --- a/gamekit/autogenerated/blender_SpaceTime.h +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_SPACETIME__H__ -#define __BLENDER_SPACETIME__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_View2D.h" - -namespace Blender { - - - // ---------------------------------------------- // - class SpaceTime - { - public: - SpaceLink *next; - SpaceLink *prev; - int spacetype; - float blockscale; - ScrArea *area; - View2D v2d; - int flag; - int redraws; - }; -} - - -#endif//__BLENDER_SPACETIME__H__ diff --git a/gamekit/autogenerated/blender_SpeedControlVars.h b/gamekit/autogenerated/blender_SpeedControlVars.h deleted file mode 100644 index 6992d1382..000000000 --- a/gamekit/autogenerated/blender_SpeedControlVars.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_SPEEDCONTROLVARS__H__ -#define __BLENDER_SPEEDCONTROLVARS__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class SpeedControlVars - { - public: - float *frameMap; - float globalSpeed; - int flags; - int length; - int lastValidFrame; - int blendFrames; - int pad; - }; -} - - -#endif//__BLENDER_SPEEDCONTROLVARS__H__ diff --git a/gamekit/autogenerated/blender_Strip.h b/gamekit/autogenerated/blender_Strip.h deleted file mode 100644 index 872eecf99..000000000 --- a/gamekit/autogenerated/blender_Strip.h +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_STRIP__H__ -#define __BLENDER_STRIP__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class Strip - { - public: - Strip *next; - Strip *prev; - int rt; - int len; - int us; - int done; - int startstill; - int endstill; - StripElem *stripdata; - char dir[160]; - int orx; - int ory; - StripProxy *proxy; - StripCrop *crop; - StripTransform *transform; - StripColorBalance *color_balance; - TStripElem *tstripdata; - TStripElem *tstripdata_startstill; - TStripElem *tstripdata_endstill; - bInvalidHandle *ibuf_startstill; - bInvalidHandle *ibuf_endstill; - }; -} - - -#endif//__BLENDER_STRIP__H__ diff --git a/gamekit/autogenerated/blender_StripColorBalance.h b/gamekit/autogenerated/blender_StripColorBalance.h deleted file mode 100644 index 952e7d88d..000000000 --- a/gamekit/autogenerated/blender_StripColorBalance.h +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_STRIPCOLORBALANCE__H__ -#define __BLENDER_STRIPCOLORBALANCE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class StripColorBalance - { - public: - vec3f lift; - vec3f gamma; - vec3f gain; - int flag; - int mode; - float exposure; - float saturation; - int pad; - bInvalidHandle *gui; - }; -} - - -#endif//__BLENDER_STRIPCOLORBALANCE__H__ diff --git a/gamekit/autogenerated/blender_StripCrop.h b/gamekit/autogenerated/blender_StripCrop.h deleted file mode 100644 index b444b8514..000000000 --- a/gamekit/autogenerated/blender_StripCrop.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_STRIPCROP__H__ -#define __BLENDER_STRIPCROP__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class StripCrop - { - public: - int top; - int bottom; - int left; - int right; - }; -} - - -#endif//__BLENDER_STRIPCROP__H__ diff --git a/gamekit/autogenerated/blender_StripElem.h b/gamekit/autogenerated/blender_StripElem.h deleted file mode 100644 index 997cf660d..000000000 --- a/gamekit/autogenerated/blender_StripElem.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_STRIPELEM__H__ -#define __BLENDER_STRIPELEM__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class StripElem - { - public: - char name[80]; - }; -} - - -#endif//__BLENDER_STRIPELEM__H__ diff --git a/gamekit/autogenerated/blender_StripProxy.h b/gamekit/autogenerated/blender_StripProxy.h deleted file mode 100644 index b64f69d6b..000000000 --- a/gamekit/autogenerated/blender_StripProxy.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_STRIPPROXY__H__ -#define __BLENDER_STRIPPROXY__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class StripProxy - { - public: - char dir[160]; - char file[80]; - bInvalidHandle *anim; - short size; - short quality; - int pad; - }; -} - - -#endif//__BLENDER_STRIPPROXY__H__ diff --git a/gamekit/autogenerated/blender_StripTransform.h b/gamekit/autogenerated/blender_StripTransform.h deleted file mode 100644 index 24ea8aef4..000000000 --- a/gamekit/autogenerated/blender_StripTransform.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_STRIPTRANSFORM__H__ -#define __BLENDER_STRIPTRANSFORM__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class StripTransform - { - public: - int xofs; - int yofs; - }; -} - - -#endif//__BLENDER_STRIPTRANSFORM__H__ diff --git a/gamekit/autogenerated/blender_SubsurfModifierData.h b/gamekit/autogenerated/blender_SubsurfModifierData.h deleted file mode 100644 index 7e95a07da..000000000 --- a/gamekit/autogenerated/blender_SubsurfModifierData.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_SUBSURFMODIFIERDATA__H__ -#define __BLENDER_SUBSURFMODIFIERDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ModifierData.h" - -namespace Blender { - - - // ---------------------------------------------- // - class SubsurfModifierData - { - public: - ModifierData modifier; - short subdivType; - short levels; - short renderLevels; - short flags; - void *emCache; - void *mCache; - }; -} - - -#endif//__BLENDER_SUBSURFMODIFIERDATA__H__ diff --git a/gamekit/autogenerated/blender_SurfaceModifierData.h b/gamekit/autogenerated/blender_SurfaceModifierData.h deleted file mode 100644 index 5fe0a8390..000000000 --- a/gamekit/autogenerated/blender_SurfaceModifierData.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_SURFACEMODIFIERDATA__H__ -#define __BLENDER_SURFACEMODIFIERDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ModifierData.h" - -namespace Blender { - - - // ---------------------------------------------- // - class SurfaceModifierData - { - public: - ModifierData modifier; - bInvalidHandle *dm; - bInvalidHandle *bvhtree; - }; -} - - -#endif//__BLENDER_SURFACEMODIFIERDATA__H__ diff --git a/gamekit/autogenerated/blender_TFace.h b/gamekit/autogenerated/blender_TFace.h deleted file mode 100644 index 74bdd8b8b..000000000 --- a/gamekit/autogenerated/blender_TFace.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_TFACE__H__ -#define __BLENDER_TFACE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class TFace - { - public: - void *tpage; - float uv[4][2]; - int col[4]; - char flag; - char transp; - short mode; - short tile; - short unwrap; - }; -} - - -#endif//__BLENDER_TFACE__H__ diff --git a/gamekit/autogenerated/blender_TStripElem.h b/gamekit/autogenerated/blender_TStripElem.h deleted file mode 100644 index acf210265..000000000 --- a/gamekit/autogenerated/blender_TStripElem.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_TSTRIPELEM__H__ -#define __BLENDER_TSTRIPELEM__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class TStripElem - { - public: - bInvalidHandle *ibuf; - bInvalidHandle *ibuf_comp; - TStripElem *se1; - TStripElem *se2; - TStripElem *se3; - short ok; - short flag; - int nr; - }; -} - - -#endif//__BLENDER_TSTRIPELEM__H__ diff --git a/gamekit/autogenerated/blender_Tex.h b/gamekit/autogenerated/blender_Tex.h deleted file mode 100644 index 4c758d640..000000000 --- a/gamekit/autogenerated/blender_Tex.h +++ /dev/null @@ -1,96 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_TEX__H__ -#define __BLENDER_TEX__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ID.h" -#include "blender_ImageUser.h" - -namespace Blender { - - - // ---------------------------------------------- // - class Tex - { - public: - ID id; - float noisesize; - float turbul; - float bright; - float contrast; - float rfac; - float gfac; - float bfac; - float filtersize; - float mg_H; - float mg_lacunarity; - float mg_octaves; - float mg_offset; - float mg_gain; - float dist_amount; - float ns_outscale; - float vn_w1; - float vn_w2; - float vn_w3; - float vn_w4; - float vn_mexp; - short vn_distm; - short vn_coltype; - short noisedepth; - short noisetype; - short noisebasis; - short noisebasis2; - short imaflag; - short flag; - short type; - short stype; - float cropxmin; - float cropymin; - float cropxmax; - float cropymax; - short xrepeat; - short yrepeat; - short extend; - short fie_ima; - int len; - int frames; - int offset; - int sfra; - float checkerdist; - float nabla; - float norfac; - ImageUser iuser; - bNodeTree *nodetree; - Ipo *ipo; - Image *ima; - PluginTex *plugin; - ColorBand *coba; - EnvMap *env; - PreviewImage *preview; - char use_nodes; - char pad[7]; - }; -} - - -#endif//__BLENDER_TEX__H__ diff --git a/gamekit/autogenerated/blender_TexMapping.h b/gamekit/autogenerated/blender_TexMapping.h deleted file mode 100644 index 4e9a81bbb..000000000 --- a/gamekit/autogenerated/blender_TexMapping.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_TEXMAPPING__H__ -#define __BLENDER_TEXMAPPING__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class TexMapping - { - public: - vec3f loc; - vec3f rot; - vec3f size; - int flag; - float mat[4][4]; - vec3f min; - vec3f max; - Object *ob; - }; -} - - -#endif//__BLENDER_TEXMAPPING__H__ diff --git a/gamekit/autogenerated/blender_TexNodeOutput.h b/gamekit/autogenerated/blender_TexNodeOutput.h deleted file mode 100644 index a9b05eb26..000000000 --- a/gamekit/autogenerated/blender_TexNodeOutput.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_TEXNODEOUTPUT__H__ -#define __BLENDER_TEXNODEOUTPUT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class TexNodeOutput - { - public: - char name[32]; - }; -} - - -#endif//__BLENDER_TEXNODEOUTPUT__H__ diff --git a/gamekit/autogenerated/blender_Text.h b/gamekit/autogenerated/blender_Text.h deleted file mode 100644 index e2a094a1d..000000000 --- a/gamekit/autogenerated/blender_Text.h +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_TEXT__H__ -#define __BLENDER_TEXT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ID.h" -#include "blender_ListBase.h" - -namespace Blender { - - - // ---------------------------------------------- // - class Text - { - public: - ID id; - char *name; - int flags; - int nlines; - ListBase lines; - TextLine *curl; - TextLine *sell; - int curc; - int selc; - ListBase markers; - char *undo_buf; - int undo_pos; - int undo_len; - void *compiled; - double mtime; - }; -} - - -#endif//__BLENDER_TEXT__H__ diff --git a/gamekit/autogenerated/blender_TextBox.h b/gamekit/autogenerated/blender_TextBox.h deleted file mode 100644 index 304a9f1a1..000000000 --- a/gamekit/autogenerated/blender_TextBox.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_TEXTBOX__H__ -#define __BLENDER_TEXTBOX__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class TextBox - { - public: - float x; - float y; - float w; - float h; - }; -} - - -#endif//__BLENDER_TEXTBOX__H__ diff --git a/gamekit/autogenerated/blender_TextLine.h b/gamekit/autogenerated/blender_TextLine.h deleted file mode 100644 index 129102fa8..000000000 --- a/gamekit/autogenerated/blender_TextLine.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_TEXTLINE__H__ -#define __BLENDER_TEXTLINE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class TextLine - { - public: - TextLine *next; - TextLine *prev; - char *line; - char *format; - int len; - int blen; - }; -} - - -#endif//__BLENDER_TEXTLINE__H__ diff --git a/gamekit/autogenerated/blender_TextMarker.h b/gamekit/autogenerated/blender_TextMarker.h deleted file mode 100644 index 3512c9f8d..000000000 --- a/gamekit/autogenerated/blender_TextMarker.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_TEXTMARKER__H__ -#define __BLENDER_TEXTMARKER__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class TextMarker - { - public: - TextMarker *next; - TextMarker *prev; - int lineno; - int start; - int end; - int pad1; - int group; - int flags; - char color[4]; - char pad[4]; - }; -} - - -#endif//__BLENDER_TEXTMARKER__H__ diff --git a/gamekit/autogenerated/blender_ThemeSpace.h b/gamekit/autogenerated/blender_ThemeSpace.h deleted file mode 100644 index b8df6ea14..000000000 --- a/gamekit/autogenerated/blender_ThemeSpace.h +++ /dev/null @@ -1,92 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_THEMESPACE__H__ -#define __BLENDER_THEMESPACE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class ThemeSpace - { - public: - char back[4]; - char text[4]; - char text_hi[4]; - char header[4]; - char panel[4]; - char shade1[4]; - char shade2[4]; - char hilite[4]; - char grid[4]; - char wire[4]; - char select[4]; - char lamp[4]; - char active[4]; - char group[4]; - char group_active[4]; - char transform[4]; - char vertex[4]; - char vertex_select[4]; - char edge[4]; - char edge_select[4]; - char edge_seam[4]; - char edge_sharp[4]; - char edge_facesel[4]; - char face[4]; - char face_select[4]; - char face_dot[4]; - char normal[4]; - char bone_solid[4]; - char bone_pose[4]; - char strip[4]; - char strip_select[4]; - char cframe[4]; - char pad[4]; - char vertex_size; - char facedot_size; - char bpad[2]; - char syntaxl[4]; - char syntaxn[4]; - char syntaxb[4]; - char syntaxv[4]; - char syntaxc[4]; - char movie[4]; - char image[4]; - char scene[4]; - char audio[4]; - char effect[4]; - char plugin[4]; - char transition[4]; - char meta[4]; - char editmesh_active[4]; - char handle_vertex[4]; - char handle_vertex_select[4]; - char handle_vertex_size; - char hpad[7]; - }; -} - - -#endif//__BLENDER_THEMESPACE__H__ diff --git a/gamekit/autogenerated/blender_ThemeUI.h b/gamekit/autogenerated/blender_ThemeUI.h deleted file mode 100644 index 768ccfa4f..000000000 --- a/gamekit/autogenerated/blender_ThemeUI.h +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_THEMEUI__H__ -#define __BLENDER_THEMEUI__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class ThemeUI - { - public: - char outline[4]; - char neutral[4]; - char action[4]; - char setting[4]; - char setting1[4]; - char setting2[4]; - char num[4]; - char textfield[4]; - char textfield_hi[4]; - char popup[4]; - char text[4]; - char text_hi[4]; - char menu_back[4]; - char menu_item[4]; - char menu_hilite[4]; - char menu_text[4]; - char menu_text_hi[4]; - char but_drawtype; - char pad[3]; - char iconfile[80]; - }; -} - - -#endif//__BLENDER_THEMEUI__H__ diff --git a/gamekit/autogenerated/blender_ThemeWireColor.h b/gamekit/autogenerated/blender_ThemeWireColor.h deleted file mode 100644 index 1aa2baee5..000000000 --- a/gamekit/autogenerated/blender_ThemeWireColor.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_THEMEWIRECOLOR__H__ -#define __BLENDER_THEMEWIRECOLOR__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class ThemeWireColor - { - public: - char solid[4]; - char select[4]; - char active[4]; - short flag; - short pad; - }; -} - - -#endif//__BLENDER_THEMEWIRECOLOR__H__ diff --git a/gamekit/autogenerated/blender_TimeMarker.h b/gamekit/autogenerated/blender_TimeMarker.h deleted file mode 100644 index f0d27c25e..000000000 --- a/gamekit/autogenerated/blender_TimeMarker.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_TIMEMARKER__H__ -#define __BLENDER_TIMEMARKER__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class TimeMarker - { - public: - TimeMarker *next; - TimeMarker *prev; - int frame; - char name[64]; - int flag; - }; -} - - -#endif//__BLENDER_TIMEMARKER__H__ diff --git a/gamekit/autogenerated/blender_ToolSettings.h b/gamekit/autogenerated/blender_ToolSettings.h deleted file mode 100644 index d9ab065ed..000000000 --- a/gamekit/autogenerated/blender_ToolSettings.h +++ /dev/null @@ -1,96 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_TOOLSETTINGS__H__ -#define __BLENDER_TOOLSETTINGS__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ImagePaintSettings.h" -#include "blender_ParticleEditSettings.h" - -namespace Blender { - - - // ---------------------------------------------- // - class ToolSettings - { - public: - short cornertype; - short editbutflag; - float jointrilimit; - float degr; - short step; - short turn; - float extr_offs; - float doublimit; - short segments; - short rings; - short vertices; - short unwrapper; - float uvcalc_radius; - float uvcalc_cubesize; - float uvcalc_margin; - float pad; - short uvcalc_mapdir; - short uvcalc_mapalign; - short uvcalc_flag; - short autoik_chainlen; - ImagePaintSettings imapaint; - ParticleEditSettings particle; - float select_thresh; - float clean_thresh; - char retopo_mode; - char retopo_paint_tool; - char line_div; - char ellipse_div; - char retopo_hotspot; - char multires_subdiv_type; - short skgen_resolution; - float skgen_threshold_internal; - float skgen_threshold_external; - float skgen_length_ratio; - float skgen_length_limit; - float skgen_angle_limit; - float skgen_correlation_limit; - float skgen_symmetry_limit; - float skgen_retarget_angle_weight; - float skgen_retarget_length_weight; - float skgen_retarget_distance_weight; - short skgen_options; - char skgen_postpro; - char skgen_postpro_passes; - char skgen_subdivisions[3]; - char skgen_multi_level; - Object *skgen_template; - char bone_sketching; - char bone_sketching_convert; - char skgen_subdivision_number; - char skgen_retarget_options; - char skgen_retarget_roll; - char skgen_side_string[8]; - char skgen_num_string[8]; - char edge_mode; - char pad3[2]; - }; -} - - -#endif//__BLENDER_TOOLSETTINGS__H__ diff --git a/gamekit/autogenerated/blender_TransformOrientation.h b/gamekit/autogenerated/blender_TransformOrientation.h deleted file mode 100644 index 81ba43ae1..000000000 --- a/gamekit/autogenerated/blender_TransformOrientation.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_TRANSFORMORIENTATION__H__ -#define __BLENDER_TRANSFORMORIENTATION__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class TransformOrientation - { - public: - TransformOrientation *next; - TransformOrientation *prev; - char name[36]; - float mat[3][3]; - }; -} - - -#endif//__BLENDER_TRANSFORMORIENTATION__H__ diff --git a/gamekit/autogenerated/blender_TransformVars.h b/gamekit/autogenerated/blender_TransformVars.h deleted file mode 100644 index fdacc6438..000000000 --- a/gamekit/autogenerated/blender_TransformVars.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_TRANSFORMVARS__H__ -#define __BLENDER_TRANSFORMVARS__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class TransformVars - { - public: - float ScalexIni; - float ScaleyIni; - float ScalexFin; - float ScaleyFin; - float xIni; - float xFin; - float yIni; - float yFin; - float rotIni; - float rotFin; - int percent; - int interpolation; - }; -} - - -#endif//__BLENDER_TRANSFORMVARS__H__ diff --git a/gamekit/autogenerated/blender_TreeStore.h b/gamekit/autogenerated/blender_TreeStore.h deleted file mode 100644 index a9099f161..000000000 --- a/gamekit/autogenerated/blender_TreeStore.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_TREESTORE__H__ -#define __BLENDER_TREESTORE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class TreeStore - { - public: - int totelem; - int usedelem; - TreeStoreElem *data; - }; -} - - -#endif//__BLENDER_TREESTORE__H__ diff --git a/gamekit/autogenerated/blender_TreeStoreElem.h b/gamekit/autogenerated/blender_TreeStoreElem.h deleted file mode 100644 index 8e9287e0e..000000000 --- a/gamekit/autogenerated/blender_TreeStoreElem.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_TREESTOREELEM__H__ -#define __BLENDER_TREESTOREELEM__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class TreeStoreElem - { - public: - short type; - short nr; - short flag; - short used; - ID *id; - }; -} - - -#endif//__BLENDER_TREESTOREELEM__H__ diff --git a/gamekit/autogenerated/blender_UVProjectModifierData.h b/gamekit/autogenerated/blender_UVProjectModifierData.h deleted file mode 100644 index 289b2adde..000000000 --- a/gamekit/autogenerated/blender_UVProjectModifierData.h +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_UVPROJECTMODIFIERDATA__H__ -#define __BLENDER_UVPROJECTMODIFIERDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ModifierData.h" - -namespace Blender { - - - // ---------------------------------------------- // - class UVProjectModifierData - { - public: - ModifierData modifier; - Object *projectors[10]; - Image *image; - int flags; - int num_projectors; - float aspectx; - float aspecty; - char uvlayer_name[32]; - int uvlayer_tmp; - int pad; - }; -} - - -#endif//__BLENDER_UVPROJECTMODIFIERDATA__H__ diff --git a/gamekit/autogenerated/blender_UserDef.h b/gamekit/autogenerated/blender_UserDef.h deleted file mode 100644 index 60b66122d..000000000 --- a/gamekit/autogenerated/blender_UserDef.h +++ /dev/null @@ -1,107 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_USERDEF__H__ -#define __BLENDER_USERDEF__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ColorBand.h" -#include "blender_ListBase.h" -#include "blender_SolidLight.h" - -namespace Blender { - - - // ---------------------------------------------- // - class UserDef - { - public: - int flag; - int dupflag; - int savetime; - char tempdir[160]; - char fontdir[160]; - char renderdir[160]; - char textudir[160]; - char plugtexdir[160]; - char plugseqdir[160]; - char pythondir[160]; - char sounddir[160]; - char yfexportdir[160]; - short versions; - short vrmlflag; - int gameflags; - int wheellinescroll; - int uiflag; - int language; - short userpref; - short viewzoom; - short console_buffer; - short console_out; - int mixbufsize; - int fontsize; - short encoding; - short transopts; - short menuthreshold1; - short menuthreshold2; - char fontname[256]; - ListBase themes; - short undosteps; - short undomemory; - short gp_manhattendist; - short gp_euclideandist; - short gp_eraser; - short gp_settings; - short tb_leftmouse; - short tb_rightmouse; - SolidLight light[3]; - short tw_hotspot; - short tw_flag; - short tw_handlesize; - short tw_size; - int textimeout; - int texcollectrate; - int memcachelimit; - int prefetchframes; - short frameserverport; - short pad_rot_angle; - short obcenter_dia; - short rvisize; - short rvibright; - short recent_files; - short smooth_viewtx; - short glreslimit; - short ndof_pan; - short ndof_rotate; - short curssize; - short pad1; - char pad[8]; - char versemaster[160]; - char verseuser[160]; - float glalphaclip; - short autokey_mode; - short autokey_flag; - ColorBand coba_weight; - }; -} - - -#endif//__BLENDER_USERDEF__H__ diff --git a/gamekit/autogenerated/blender_VFont.h b/gamekit/autogenerated/blender_VFont.h deleted file mode 100644 index 0a7f99aed..000000000 --- a/gamekit/autogenerated/blender_VFont.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_VFONT__H__ -#define __BLENDER_VFONT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ID.h" - -namespace Blender { - - - // ---------------------------------------------- // - class VFont - { - public: - ID id; - char name[256]; - float scale; - float pad; - bInvalidHandle *data; - PackedFile *packedfile; - }; -} - - -#endif//__BLENDER_VFONT__H__ diff --git a/gamekit/autogenerated/blender_View2D.h b/gamekit/autogenerated/blender_View2D.h deleted file mode 100644 index 142cc589b..000000000 --- a/gamekit/autogenerated/blender_View2D.h +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_VIEW2D__H__ -#define __BLENDER_VIEW2D__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_rctf.h" -#include "blender_rcti.h" - -namespace Blender { - - - // ---------------------------------------------- // - class View2D - { - public: - rctf tot; - rctf cur; - rcti vert; - rcti hor; - rcti mask; - float min[2]; - float max[2]; - float minzoom; - float maxzoom; - short scroll; - short keeptot; - short keepaspect; - short keepzoom; - short oldwinx; - short oldwiny; - int flag; - float cursor[2]; - short around; - char pad[6]; - }; -} - - -#endif//__BLENDER_VIEW2D__H__ diff --git a/gamekit/autogenerated/blender_View3D.h b/gamekit/autogenerated/blender_View3D.h deleted file mode 100644 index 5e788667a..000000000 --- a/gamekit/autogenerated/blender_View3D.h +++ /dev/null @@ -1,117 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_VIEW3D__H__ -#define __BLENDER_VIEW3D__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ListBase.h" - -#undef near -#undef far - -namespace Blender { - - - // ---------------------------------------------- // - class View3D - { - public: - SpaceLink *next; - SpaceLink *prev; - int spacetype; - float blockscale; - ScrArea *area; - short blockhandler[8]; - float viewmat[4][4]; - float viewinv[4][4]; - float persmat[4][4]; - float persinv[4][4]; - float winmat1[4][4]; - float viewmat1[4][4]; - vec4f viewquat; - float dist; - float zfac; - int lay_used; - short persp; - short view; - Object *camera; - Object *ob_centre; - BGpic *bgpic; - View3D *localvd; - bInvalidHandle *ri; - bInvalidHandle *retopo_view_data; - bInvalidHandle *depths; - char ob_centre_bone[32]; - short drawtype; - short localview; - int lay; - int layact; - short scenelock; - short around; - short camzoom; - char pivot_last; - char pad1; - float lens; - float grid; - float gridview; - float pixsize; - float near; - float far; - float camdx; - float camdy; - vec3f ofs; - vec3f cursor; - short gridlines; - short viewbut; - short gridflag; - short modeselect; - short menunr; - short texnr; - short twtype; - short twmode; - short twflag; - short twdrawflag; - float twmat[4][4]; - float clip[4][4]; - BoundBox *clipbb; - ListBase afterdraw; - short zbuf; - short transp; - short xray; - short flag; - short flag2; - short gridsubdiv; - short keyflags; - char ndofmode; - char ndoffilter; - void *properties_storage; - bGPdata *gpd; - vec4f lviewquat; - short lpersp; - short lview; - short pad5; - short pad6; - }; -} - - -#endif//__BLENDER_VIEW3D__H__ diff --git a/gamekit/autogenerated/blender_Wave.h b/gamekit/autogenerated/blender_Wave.h deleted file mode 100644 index 7539cbbbd..000000000 --- a/gamekit/autogenerated/blender_Wave.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_WAVE__H__ -#define __BLENDER_WAVE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ID.h" - -namespace Blender { - - - // ---------------------------------------------- // - class Wave - { - public: - ID id; - Ipo *ipo; - }; -} - - -#endif//__BLENDER_WAVE__H__ diff --git a/gamekit/autogenerated/blender_WaveEff.h b/gamekit/autogenerated/blender_WaveEff.h deleted file mode 100644 index 0864b3d46..000000000 --- a/gamekit/autogenerated/blender_WaveEff.h +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_WAVEEFF__H__ -#define __BLENDER_WAVEEFF__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class WaveEff - { - public: - WaveEff *next; - WaveEff *prev; - short type; - short flag; - short buttype; - short stype; - float startx; - float starty; - float height; - float width; - float narrow; - float speed; - float minfac; - float damp; - float timeoffs; - float lifetime; - }; -} - - -#endif//__BLENDER_WAVEEFF__H__ diff --git a/gamekit/autogenerated/blender_WaveModifierData.h b/gamekit/autogenerated/blender_WaveModifierData.h deleted file mode 100644 index 2890c5618..000000000 --- a/gamekit/autogenerated/blender_WaveModifierData.h +++ /dev/null @@ -1,60 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_WAVEMODIFIERDATA__H__ -#define __BLENDER_WAVEMODIFIERDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ModifierData.h" - -namespace Blender { - - - // ---------------------------------------------- // - class WaveModifierData - { - public: - ModifierData modifier; - Object *objectcenter; - char defgrp_name[32]; - Tex *texture; - Object *map_object; - short flag; - short pad; - float startx; - float starty; - float height; - float width; - float narrow; - float speed; - float damp; - float falloff; - int texmapping; - int uvlayer_tmp; - char uvlayer_name[32]; - float timeoffs; - float lifetime; - float pad1; - }; -} - - -#endif//__BLENDER_WAVEMODIFIERDATA__H__ diff --git a/gamekit/autogenerated/blender_WipeVars.h b/gamekit/autogenerated/blender_WipeVars.h deleted file mode 100644 index 0b7cd1206..000000000 --- a/gamekit/autogenerated/blender_WipeVars.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_WIPEVARS__H__ -#define __BLENDER_WIPEVARS__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class WipeVars - { - public: - float edgeWidth; - float angle; - short forward; - short wipetype; - }; -} - - -#endif//__BLENDER_WIPEVARS__H__ diff --git a/gamekit/autogenerated/blender_World.h b/gamekit/autogenerated/blender_World.h deleted file mode 100644 index debee52cb..000000000 --- a/gamekit/autogenerated/blender_World.h +++ /dev/null @@ -1,111 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_WORLD__H__ -#define __BLENDER_WORLD__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ID.h" -#include "blender_ScriptLink.h" - -namespace Blender { - - - // ---------------------------------------------- // - class World - { - public: - ID id; - short colormodel; - short totex; - short texact; - short mistype; - float horr; - float horg; - float horb; - float hork; - float zenr; - float zeng; - float zenb; - float zenk; - float ambr; - float ambg; - float ambb; - float ambk; - int fastcol; - float exposure; - float exp; - float range; - float linfac; - float logfac; - float gravity; - float activityBoxRadius; - short skytype; - short mode; - short occlusionRes; - short physicsEngine; - short ticrate; - short maxlogicstep; - short physubstep; - short maxphystep; - float misi; - float miststa; - float mistdist; - float misthi; - float starr; - float starg; - float starb; - float stark; - float starsize; - float starmindist; - float stardist; - float starcolnoise; - short dofsta; - short dofend; - short dofmin; - short dofmax; - float aodist; - float aodistfac; - float aoenergy; - float aobias; - short aomode; - short aosamp; - short aomix; - short aocolor; - float ao_adapt_thresh; - float ao_adapt_speed_fac; - float ao_approx_error; - float ao_approx_correction; - short ao_samp_method; - short ao_gather_method; - short ao_approx_passes; - short pad1; - float *aosphere; - float *aotables; - Ipo *ipo; - MTex *mtex[18]; - PreviewImage *preview; - ScriptLink scriptlink; - }; -} - - -#endif//__BLENDER_WORLD__H__ diff --git a/gamekit/autogenerated/blender_bAction.h b/gamekit/autogenerated/blender_bAction.h deleted file mode 100644 index 8352c6f06..000000000 --- a/gamekit/autogenerated/blender_bAction.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BACTION__H__ -#define __BLENDER_BACTION__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ID.h" -#include "blender_ListBase.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bAction - { - public: - ID id; - ListBase chanbase; - ListBase groups; - ListBase markers; - int active_marker; - int pad; - }; -} - - -#endif//__BLENDER_BACTION__H__ diff --git a/gamekit/autogenerated/blender_bActionActuator.h b/gamekit/autogenerated/blender_bActionActuator.h deleted file mode 100644 index 673f8866a..000000000 --- a/gamekit/autogenerated/blender_bActionActuator.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BACTIONACTUATOR__H__ -#define __BLENDER_BACTIONACTUATOR__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bActionActuator - { - public: - bAction *act; - short type; - short flag; - int sta; - int end; - char name[32]; - char frameProp[32]; - short blendin; - short priority; - short end_reset; - short strideaxis; - float stridelength; - }; -} - - -#endif//__BLENDER_BACTIONACTUATOR__H__ diff --git a/gamekit/autogenerated/blender_bActionChannel.h b/gamekit/autogenerated/blender_bActionChannel.h deleted file mode 100644 index 7b1781ec3..000000000 --- a/gamekit/autogenerated/blender_bActionChannel.h +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BACTIONCHANNEL__H__ -#define __BLENDER_BACTIONCHANNEL__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ListBase.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bActionChannel - { - public: - bActionChannel *next; - bActionChannel *prev; - bActionGroup *grp; - Ipo *ipo; - ListBase constraintChannels; - int flag; - char name[32]; - int reserved1; - }; -} - - -#endif//__BLENDER_BACTIONCHANNEL__H__ diff --git a/gamekit/autogenerated/blender_bActionConstraint.h b/gamekit/autogenerated/blender_bActionConstraint.h deleted file mode 100644 index 15ac01347..000000000 --- a/gamekit/autogenerated/blender_bActionConstraint.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BACTIONCONSTRAINT__H__ -#define __BLENDER_BACTIONCONSTRAINT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bActionConstraint - { - public: - Object *tar; - short type; - short local; - int start; - int end; - float min; - float max; - int pad; - bAction *act; - char subtarget[32]; - }; -} - - -#endif//__BLENDER_BACTIONCONSTRAINT__H__ diff --git a/gamekit/autogenerated/blender_bActionGroup.h b/gamekit/autogenerated/blender_bActionGroup.h deleted file mode 100644 index 8ca12efa4..000000000 --- a/gamekit/autogenerated/blender_bActionGroup.h +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BACTIONGROUP__H__ -#define __BLENDER_BACTIONGROUP__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ListBase.h" -#include "blender_ThemeWireColor.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bActionGroup - { - public: - bActionGroup *next; - bActionGroup *prev; - ListBase channels; - int flag; - int customCol; - char name[32]; - ThemeWireColor cs; - }; -} - - -#endif//__BLENDER_BACTIONGROUP__H__ diff --git a/gamekit/autogenerated/blender_bActionModifier.h b/gamekit/autogenerated/blender_bActionModifier.h deleted file mode 100644 index 4f025f7f0..000000000 --- a/gamekit/autogenerated/blender_bActionModifier.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BACTIONMODIFIER__H__ -#define __BLENDER_BACTIONMODIFIER__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bActionModifier - { - public: - bActionModifier *next; - bActionModifier *prev; - short type; - short flag; - char channel[32]; - float noisesize; - float turbul; - short channels; - short no_rot_axis; - Object *ob; - }; -} - - -#endif//__BLENDER_BACTIONMODIFIER__H__ diff --git a/gamekit/autogenerated/blender_bActionStrip.h b/gamekit/autogenerated/blender_bActionStrip.h deleted file mode 100644 index 0be134a34..000000000 --- a/gamekit/autogenerated/blender_bActionStrip.h +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BACTIONSTRIP__H__ -#define __BLENDER_BACTIONSTRIP__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ListBase.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bActionStrip - { - public: - bActionStrip *next; - bActionStrip *prev; - short flag; - short mode; - short stride_axis; - short curmod; - Ipo *ipo; - bAction *act; - Object *object; - float start; - float end; - float actstart; - float actend; - float actoffs; - float stridelen; - float repeat; - float scale; - float blendin; - float blendout; - char stridechannel[32]; - char offs_bone[32]; - ListBase modifiers; - }; -} - - -#endif//__BLENDER_BACTIONSTRIP__H__ diff --git a/gamekit/autogenerated/blender_bActuator.h b/gamekit/autogenerated/blender_bActuator.h deleted file mode 100644 index fcf820281..000000000 --- a/gamekit/autogenerated/blender_bActuator.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BACTUATOR__H__ -#define __BLENDER_BACTUATOR__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bActuator - { - public: - bActuator *next; - bActuator *prev; - bActuator *mynew; - short type; - short flag; - short otype; - short go; - char name[32]; - void *data; - Object *ob; - }; -} - - -#endif//__BLENDER_BACTUATOR__H__ diff --git a/gamekit/autogenerated/blender_bActuatorSensor.h b/gamekit/autogenerated/blender_bActuatorSensor.h deleted file mode 100644 index c80a61555..000000000 --- a/gamekit/autogenerated/blender_bActuatorSensor.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BACTUATORSENSOR__H__ -#define __BLENDER_BACTUATORSENSOR__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bActuatorSensor - { - public: - int type; - int pad; - char name[32]; - }; -} - - -#endif//__BLENDER_BACTUATORSENSOR__H__ diff --git a/gamekit/autogenerated/blender_bAddObjectActuator.h b/gamekit/autogenerated/blender_bAddObjectActuator.h deleted file mode 100644 index 12a48e51d..000000000 --- a/gamekit/autogenerated/blender_bAddObjectActuator.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BADDOBJECTACTUATOR__H__ -#define __BLENDER_BADDOBJECTACTUATOR__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bAddObjectActuator - { - public: - int time; - int pad; - Object *ob; - }; -} - - -#endif//__BLENDER_BADDOBJECTACTUATOR__H__ diff --git a/gamekit/autogenerated/blender_bArmature.h b/gamekit/autogenerated/blender_bArmature.h deleted file mode 100644 index 0aded0fda..000000000 --- a/gamekit/autogenerated/blender_bArmature.h +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BARMATURE__H__ -#define __BLENDER_BARMATURE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ID.h" -#include "blender_ListBase.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bArmature - { - public: - ID id; - ListBase bonebase; - ListBase chainbase; - int flag; - int drawtype; - short deformflag; - short pathflag; - short layer; - short layer_protected; - short ghostep; - short ghostsize; - short ghosttype; - short pathsize; - int ghostsf; - int ghostef; - int pathsf; - int pathef; - int pathbc; - int pathac; - }; -} - - -#endif//__BLENDER_BARMATURE__H__ diff --git a/gamekit/autogenerated/blender_bCDActuator.h b/gamekit/autogenerated/blender_bCDActuator.h deleted file mode 100644 index c7e4f079b..000000000 --- a/gamekit/autogenerated/blender_bCDActuator.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BCDACTUATOR__H__ -#define __BLENDER_BCDACTUATOR__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bCDActuator - { - public: - short flag; - short sndnr; - int sta; - int end; - short type; - short track; - float volume; - }; -} - - -#endif//__BLENDER_BCDACTUATOR__H__ diff --git a/gamekit/autogenerated/blender_bCameraActuator.h b/gamekit/autogenerated/blender_bCameraActuator.h deleted file mode 100644 index 704d612d6..000000000 --- a/gamekit/autogenerated/blender_bCameraActuator.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BCAMERAACTUATOR__H__ -#define __BLENDER_BCAMERAACTUATOR__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bCameraActuator - { - public: - Object *ob; - float height; - float min; - float max; - float fac; - short flag; - short axis; - float visifac; - }; -} - - -#endif//__BLENDER_BCAMERAACTUATOR__H__ diff --git a/gamekit/autogenerated/blender_bChildOfConstraint.h b/gamekit/autogenerated/blender_bChildOfConstraint.h deleted file mode 100644 index 3344147b8..000000000 --- a/gamekit/autogenerated/blender_bChildOfConstraint.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BCHILDOFCONSTRAINT__H__ -#define __BLENDER_BCHILDOFCONSTRAINT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bChildOfConstraint - { - public: - Object *tar; - int flag; - int pad; - float invmat[4][4]; - char subtarget[32]; - }; -} - - -#endif//__BLENDER_BCHILDOFCONSTRAINT__H__ diff --git a/gamekit/autogenerated/blender_bClampToConstraint.h b/gamekit/autogenerated/blender_bClampToConstraint.h deleted file mode 100644 index cfae575a3..000000000 --- a/gamekit/autogenerated/blender_bClampToConstraint.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BCLAMPTOCONSTRAINT__H__ -#define __BLENDER_BCLAMPTOCONSTRAINT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bClampToConstraint - { - public: - Object *tar; - int flag; - int flag2; - }; -} - - -#endif//__BLENDER_BCLAMPTOCONSTRAINT__H__ diff --git a/gamekit/autogenerated/blender_bCollisionSensor.h b/gamekit/autogenerated/blender_bCollisionSensor.h deleted file mode 100644 index 97af95950..000000000 --- a/gamekit/autogenerated/blender_bCollisionSensor.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BCOLLISIONSENSOR__H__ -#define __BLENDER_BCOLLISIONSENSOR__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bCollisionSensor - { - public: - char name[32]; - char materialName[32]; - short damptimer; - short damp; - short mode; - short pad2; - }; -} - - -#endif//__BLENDER_BCOLLISIONSENSOR__H__ diff --git a/gamekit/autogenerated/blender_bConstraint.h b/gamekit/autogenerated/blender_bConstraint.h deleted file mode 100644 index a8c1756ba..000000000 --- a/gamekit/autogenerated/blender_bConstraint.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BCONSTRAINT__H__ -#define __BLENDER_BCONSTRAINT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bConstraint - { - public: - bConstraint *next; - bConstraint *prev; - void *data; - short type; - short flag; - char ownspace; - char tarspace; - char name[30]; - float enforce; - float headtail; - int pad; - Ipo *ipo; - }; -} - - -#endif//__BLENDER_BCONSTRAINT__H__ diff --git a/gamekit/autogenerated/blender_bConstraintActuator.h b/gamekit/autogenerated/blender_bConstraintActuator.h deleted file mode 100644 index a874549cb..000000000 --- a/gamekit/autogenerated/blender_bConstraintActuator.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BCONSTRAINTACTUATOR__H__ -#define __BLENDER_BCONSTRAINTACTUATOR__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bConstraintActuator - { - public: - short type; - short mode; - short flag; - short damp; - short time; - short rotdamp; - int pad; - vec3f minloc; - vec3f maxloc; - vec3f minrot; - vec3f maxrot; - char matprop[32]; - }; -} - - -#endif//__BLENDER_BCONSTRAINTACTUATOR__H__ diff --git a/gamekit/autogenerated/blender_bConstraintChannel.h b/gamekit/autogenerated/blender_bConstraintChannel.h deleted file mode 100644 index c7358519b..000000000 --- a/gamekit/autogenerated/blender_bConstraintChannel.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BCONSTRAINTCHANNEL__H__ -#define __BLENDER_BCONSTRAINTCHANNEL__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bConstraintChannel - { - public: - bConstraintChannel *next; - bConstraintChannel *prev; - Ipo *ipo; - short flag; - char name[30]; - }; -} - - -#endif//__BLENDER_BCONSTRAINTCHANNEL__H__ diff --git a/gamekit/autogenerated/blender_bConstraintTarget.h b/gamekit/autogenerated/blender_bConstraintTarget.h deleted file mode 100644 index 27a2bb5fe..000000000 --- a/gamekit/autogenerated/blender_bConstraintTarget.h +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BCONSTRAINTTARGET__H__ -#define __BLENDER_BCONSTRAINTTARGET__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bConstraintTarget - { - public: - bConstraintTarget *next; - bConstraintTarget *prev; - Object *tar; - char subtarget[32]; - float matrix[4][4]; - short space; - short flag; - short type; - short pad; - }; -} - - -#endif//__BLENDER_BCONSTRAINTTARGET__H__ diff --git a/gamekit/autogenerated/blender_bController.h b/gamekit/autogenerated/blender_bController.h deleted file mode 100644 index ebb8c2082..000000000 --- a/gamekit/autogenerated/blender_bController.h +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BCONTROLLER__H__ -#define __BLENDER_BCONTROLLER__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bController - { - public: - bController *next; - bController *prev; - bController *mynew; - short type; - short flag; - short inputs; - short totlinks; - short otype; - short totslinks; - short pad2; - short pad3; - char name[32]; - void *data; - bActuator **links; - bSensor **slinks; - short val; - short valo; - int state_mask; - }; -} - - -#endif//__BLENDER_BCONTROLLER__H__ diff --git a/gamekit/autogenerated/blender_bDeformGroup.h b/gamekit/autogenerated/blender_bDeformGroup.h deleted file mode 100644 index b3087708b..000000000 --- a/gamekit/autogenerated/blender_bDeformGroup.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BDEFORMGROUP__H__ -#define __BLENDER_BDEFORMGROUP__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bDeformGroup - { - public: - bDeformGroup *next; - bDeformGroup *prev; - char name[32]; - }; -} - - -#endif//__BLENDER_BDEFORMGROUP__H__ diff --git a/gamekit/autogenerated/blender_bDelaySensor.h b/gamekit/autogenerated/blender_bDelaySensor.h deleted file mode 100644 index b9cb34fb4..000000000 --- a/gamekit/autogenerated/blender_bDelaySensor.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BDELAYSENSOR__H__ -#define __BLENDER_BDELAYSENSOR__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bDelaySensor - { - public: - short delay; - short duration; - short flag; - short pad; - }; -} - - -#endif//__BLENDER_BDELAYSENSOR__H__ diff --git a/gamekit/autogenerated/blender_bDistLimitConstraint.h b/gamekit/autogenerated/blender_bDistLimitConstraint.h deleted file mode 100644 index 1fbf7b345..000000000 --- a/gamekit/autogenerated/blender_bDistLimitConstraint.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BDISTLIMITCONSTRAINT__H__ -#define __BLENDER_BDISTLIMITCONSTRAINT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bDistLimitConstraint - { - public: - Object *tar; - char subtarget[32]; - float dist; - float soft; - short flag; - short mode; - int pad; - }; -} - - -#endif//__BLENDER_BDISTLIMITCONSTRAINT__H__ diff --git a/gamekit/autogenerated/blender_bDistanceLimitConstraint.h b/gamekit/autogenerated/blender_bDistanceLimitConstraint.h deleted file mode 100644 index e76f5a258..000000000 --- a/gamekit/autogenerated/blender_bDistanceLimitConstraint.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BDISTANCELIMITCONSTRAINT__H__ -#define __BLENDER_BDISTANCELIMITCONSTRAINT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bDistanceLimitConstraint - { - public: - Object *tar; - char subtarget[32]; - float pad1; - float pad2; - float distance; - vec3f offset; - }; -} - - -#endif//__BLENDER_BDISTANCELIMITCONSTRAINT__H__ diff --git a/gamekit/autogenerated/blender_bEditObjectActuator.h b/gamekit/autogenerated/blender_bEditObjectActuator.h deleted file mode 100644 index 7730459f7..000000000 --- a/gamekit/autogenerated/blender_bEditObjectActuator.h +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BEDITOBJECTACTUATOR__H__ -#define __BLENDER_BEDITOBJECTACTUATOR__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bEditObjectActuator - { - public: - int time; - short type; - short flag; - Object *ob; - Mesh *me; - char name[32]; - vec3f linVelocity; - vec3f angVelocity; - float mass; - short localflag; - short dyn_operation; - }; -} - - -#endif//__BLENDER_BEDITOBJECTACTUATOR__H__ diff --git a/gamekit/autogenerated/blender_bExpressionCont.h b/gamekit/autogenerated/blender_bExpressionCont.h deleted file mode 100644 index b03b7da17..000000000 --- a/gamekit/autogenerated/blender_bExpressionCont.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BEXPRESSIONCONT__H__ -#define __BLENDER_BEXPRESSIONCONT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bExpressionCont - { - public: - char str[128]; - }; -} - - -#endif//__BLENDER_BEXPRESSIONCONT__H__ diff --git a/gamekit/autogenerated/blender_bFollowPathConstraint.h b/gamekit/autogenerated/blender_bFollowPathConstraint.h deleted file mode 100644 index 433839393..000000000 --- a/gamekit/autogenerated/blender_bFollowPathConstraint.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BFOLLOWPATHCONSTRAINT__H__ -#define __BLENDER_BFOLLOWPATHCONSTRAINT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bFollowPathConstraint - { - public: - Object *tar; - float offset; - int followflag; - int trackflag; - int upflag; - }; -} - - -#endif//__BLENDER_BFOLLOWPATHCONSTRAINT__H__ diff --git a/gamekit/autogenerated/blender_bGPDframe.h b/gamekit/autogenerated/blender_bGPDframe.h deleted file mode 100644 index 61d5736a8..000000000 --- a/gamekit/autogenerated/blender_bGPDframe.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BGPDFRAME__H__ -#define __BLENDER_BGPDFRAME__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ListBase.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bGPDframe - { - public: - bGPDframe *next; - bGPDframe *prev; - ListBase strokes; - int framenum; - int flag; - }; -} - - -#endif//__BLENDER_BGPDFRAME__H__ diff --git a/gamekit/autogenerated/blender_bGPDlayer.h b/gamekit/autogenerated/blender_bGPDlayer.h deleted file mode 100644 index 8390ee5e3..000000000 --- a/gamekit/autogenerated/blender_bGPDlayer.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BGPDLAYER__H__ -#define __BLENDER_BGPDLAYER__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ListBase.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bGPDlayer - { - public: - bGPDlayer *next; - bGPDlayer *prev; - ListBase frames; - bGPDframe *actframe; - int flag; - short thickness; - short gstep; - vec4f color; - char info[128]; - }; -} - - -#endif//__BLENDER_BGPDLAYER__H__ diff --git a/gamekit/autogenerated/blender_bGPDspoint.h b/gamekit/autogenerated/blender_bGPDspoint.h deleted file mode 100644 index 500b936bc..000000000 --- a/gamekit/autogenerated/blender_bGPDspoint.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BGPDSPOINT__H__ -#define __BLENDER_BGPDSPOINT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bGPDspoint - { - public: - float x; - float y; - float z; - float pressure; - }; -} - - -#endif//__BLENDER_BGPDSPOINT__H__ diff --git a/gamekit/autogenerated/blender_bGPDstroke.h b/gamekit/autogenerated/blender_bGPDstroke.h deleted file mode 100644 index bb40a3c76..000000000 --- a/gamekit/autogenerated/blender_bGPDstroke.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BGPDSTROKE__H__ -#define __BLENDER_BGPDSTROKE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bGPDstroke - { - public: - bGPDstroke *next; - bGPDstroke *prev; - bGPDspoint *points; - int totpoints; - short thickness; - short flag; - }; -} - - -#endif//__BLENDER_BGPDSTROKE__H__ diff --git a/gamekit/autogenerated/blender_bGPdata.h b/gamekit/autogenerated/blender_bGPdata.h deleted file mode 100644 index 318136c6c..000000000 --- a/gamekit/autogenerated/blender_bGPdata.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BGPDATA__H__ -#define __BLENDER_BGPDATA__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ListBase.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bGPdata - { - public: - ListBase layers; - int flag; - short sbuffer_size; - short sbuffer_sflag; - void *sbuffer; - }; -} - - -#endif//__BLENDER_BGPDATA__H__ diff --git a/gamekit/autogenerated/blender_bGameActuator.h b/gamekit/autogenerated/blender_bGameActuator.h deleted file mode 100644 index c785908ed..000000000 --- a/gamekit/autogenerated/blender_bGameActuator.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BGAMEACTUATOR__H__ -#define __BLENDER_BGAMEACTUATOR__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bGameActuator - { - public: - short flag; - short type; - int sta; - int end; - char filename[64]; - char loadaniname[64]; - }; -} - - -#endif//__BLENDER_BGAMEACTUATOR__H__ diff --git a/gamekit/autogenerated/blender_bGroupActuator.h b/gamekit/autogenerated/blender_bGroupActuator.h deleted file mode 100644 index 31a5a1fd2..000000000 --- a/gamekit/autogenerated/blender_bGroupActuator.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BGROUPACTUATOR__H__ -#define __BLENDER_BGROUPACTUATOR__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bGroupActuator - { - public: - short flag; - short type; - int sta; - int end; - char name[32]; - short pad[3]; - short cur; - short butsta; - short butend; - Group *group; - }; -} - - -#endif//__BLENDER_BGROUPACTUATOR__H__ diff --git a/gamekit/autogenerated/blender_bIpoActuator.h b/gamekit/autogenerated/blender_bIpoActuator.h deleted file mode 100644 index e56416bf9..000000000 --- a/gamekit/autogenerated/blender_bIpoActuator.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BIPOACTUATOR__H__ -#define __BLENDER_BIPOACTUATOR__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bIpoActuator - { - public: - short flag; - short type; - int sta; - int end; - char name[32]; - char frameProp[32]; - short pad1; - short cur; - short butsta; - short butend; - }; -} - - -#endif//__BLENDER_BIPOACTUATOR__H__ diff --git a/gamekit/autogenerated/blender_bJoystickSensor.h b/gamekit/autogenerated/blender_bJoystickSensor.h deleted file mode 100644 index 1795d2b9d..000000000 --- a/gamekit/autogenerated/blender_bJoystickSensor.h +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BJOYSTICKSENSOR__H__ -#define __BLENDER_BJOYSTICKSENSOR__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bJoystickSensor - { - public: - char name[32]; - char type; - char joyindex; - short flag; - short axis; - short axis_single; - int axisf; - int button; - int hat; - int hatf; - int precision; - }; -} - - -#endif//__BLENDER_BJOYSTICKSENSOR__H__ diff --git a/gamekit/autogenerated/blender_bKeyboardSensor.h b/gamekit/autogenerated/blender_bKeyboardSensor.h deleted file mode 100644 index 57ee703fb..000000000 --- a/gamekit/autogenerated/blender_bKeyboardSensor.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BKEYBOARDSENSOR__H__ -#define __BLENDER_BKEYBOARDSENSOR__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bKeyboardSensor - { - public: - short key; - short qual; - short type; - short qual2; - char targetName[32]; - char toggleName[32]; - }; -} - - -#endif//__BLENDER_BKEYBOARDSENSOR__H__ diff --git a/gamekit/autogenerated/blender_bKinematicConstraint.h b/gamekit/autogenerated/blender_bKinematicConstraint.h deleted file mode 100644 index 8cbb073e6..000000000 --- a/gamekit/autogenerated/blender_bKinematicConstraint.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BKINEMATICCONSTRAINT__H__ -#define __BLENDER_BKINEMATICCONSTRAINT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bKinematicConstraint - { - public: - Object *tar; - short iterations; - short flag; - short rootbone; - short max_rootbone; - char subtarget[32]; - Object *poletar; - char polesubtarget[32]; - float poleangle; - float weight; - float orientweight; - vec3f grabtarget; - }; -} - - -#endif//__BLENDER_BKINEMATICCONSTRAINT__H__ diff --git a/gamekit/autogenerated/blender_bLocLimitConstraint.h b/gamekit/autogenerated/blender_bLocLimitConstraint.h deleted file mode 100644 index 9701a6232..000000000 --- a/gamekit/autogenerated/blender_bLocLimitConstraint.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BLOCLIMITCONSTRAINT__H__ -#define __BLENDER_BLOCLIMITCONSTRAINT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bLocLimitConstraint - { - public: - float xmin; - float xmax; - float ymin; - float ymax; - float zmin; - float zmax; - short flag; - short flag2; - }; -} - - -#endif//__BLENDER_BLOCLIMITCONSTRAINT__H__ diff --git a/gamekit/autogenerated/blender_bLocateLikeConstraint.h b/gamekit/autogenerated/blender_bLocateLikeConstraint.h deleted file mode 100644 index 3a05069ff..000000000 --- a/gamekit/autogenerated/blender_bLocateLikeConstraint.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BLOCATELIKECONSTRAINT__H__ -#define __BLENDER_BLOCATELIKECONSTRAINT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bLocateLikeConstraint - { - public: - Object *tar; - int flag; - int reserved1; - char subtarget[32]; - }; -} - - -#endif//__BLENDER_BLOCATELIKECONSTRAINT__H__ diff --git a/gamekit/autogenerated/blender_bLockTrackConstraint.h b/gamekit/autogenerated/blender_bLockTrackConstraint.h deleted file mode 100644 index 7d9a54673..000000000 --- a/gamekit/autogenerated/blender_bLockTrackConstraint.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BLOCKTRACKCONSTRAINT__H__ -#define __BLENDER_BLOCKTRACKCONSTRAINT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bLockTrackConstraint - { - public: - Object *tar; - int trackflag; - int lockflag; - char subtarget[32]; - }; -} - - -#endif//__BLENDER_BLOCKTRACKCONSTRAINT__H__ diff --git a/gamekit/autogenerated/blender_bMessageActuator.h b/gamekit/autogenerated/blender_bMessageActuator.h deleted file mode 100644 index 0793836ca..000000000 --- a/gamekit/autogenerated/blender_bMessageActuator.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BMESSAGEACTUATOR__H__ -#define __BLENDER_BMESSAGEACTUATOR__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bMessageActuator - { - public: - char toPropName[32]; - Object *toObject; - char subject[32]; - short bodyType; - short pad1; - int pad2; - char body[32]; - }; -} - - -#endif//__BLENDER_BMESSAGEACTUATOR__H__ diff --git a/gamekit/autogenerated/blender_bMessageSensor.h b/gamekit/autogenerated/blender_bMessageSensor.h deleted file mode 100644 index 0b9e22049..000000000 --- a/gamekit/autogenerated/blender_bMessageSensor.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BMESSAGESENSOR__H__ -#define __BLENDER_BMESSAGESENSOR__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bMessageSensor - { - public: - Object *fromObject; - char subject[32]; - char body[32]; - }; -} - - -#endif//__BLENDER_BMESSAGESENSOR__H__ diff --git a/gamekit/autogenerated/blender_bMinMaxConstraint.h b/gamekit/autogenerated/blender_bMinMaxConstraint.h deleted file mode 100644 index e2c4f9d13..000000000 --- a/gamekit/autogenerated/blender_bMinMaxConstraint.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BMINMAXCONSTRAINT__H__ -#define __BLENDER_BMINMAXCONSTRAINT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bMinMaxConstraint - { - public: - Object *tar; - int minmaxflag; - float offset; - int flag; - short sticky; - short stuck; - short pad1; - short pad2; - vec3f cache; - char subtarget[32]; - }; -} - - -#endif//__BLENDER_BMINMAXCONSTRAINT__H__ diff --git a/gamekit/autogenerated/blender_bMouseSensor.h b/gamekit/autogenerated/blender_bMouseSensor.h deleted file mode 100644 index 09c6dc98a..000000000 --- a/gamekit/autogenerated/blender_bMouseSensor.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BMOUSESENSOR__H__ -#define __BLENDER_BMOUSESENSOR__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bMouseSensor - { - public: - short type; - short flag; - short pad1; - short pad2; - }; -} - - -#endif//__BLENDER_BMOUSESENSOR__H__ diff --git a/gamekit/autogenerated/blender_bNearSensor.h b/gamekit/autogenerated/blender_bNearSensor.h deleted file mode 100644 index aa56ab217..000000000 --- a/gamekit/autogenerated/blender_bNearSensor.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BNEARSENSOR__H__ -#define __BLENDER_BNEARSENSOR__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bNearSensor - { - public: - char name[32]; - float dist; - float resetdist; - int lastval; - int pad; - }; -} - - -#endif//__BLENDER_BNEARSENSOR__H__ diff --git a/gamekit/autogenerated/blender_bNode.h b/gamekit/autogenerated/blender_bNode.h deleted file mode 100644 index 91ed645aa..000000000 --- a/gamekit/autogenerated/blender_bNode.h +++ /dev/null @@ -1,72 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BNODE__H__ -#define __BLENDER_BNODE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ListBase.h" -#include "blender_rctf.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bNode - { - public: - bNode *next; - bNode *prev; - bNode *new_node; - char name[32]; - char username[32]; - short type; - short flag; - short done; - short level; - short lasty; - short menunr; - short stack_index; - short nr; - ListBase inputs; - ListBase outputs; - ID *id; - void *storage; - float locx; - float locy; - float width; - float miniwidth; - short custom1; - short custom2; - float custom3; - float custom4; - short need_exec; - short exec; - rctf totr; - rctf butr; - rctf prvr; - bInvalidHandle *preview; - bInvalidHandle *typeinfo; - }; -} - - -#endif//__BLENDER_BNODE__H__ diff --git a/gamekit/autogenerated/blender_bNodeLink.h b/gamekit/autogenerated/blender_bNodeLink.h deleted file mode 100644 index 694064790..000000000 --- a/gamekit/autogenerated/blender_bNodeLink.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BNODELINK__H__ -#define __BLENDER_BNODELINK__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bNodeLink - { - public: - bNodeLink *next; - bNodeLink *prev; - bNode *fromnode; - bNode *tonode; - bNodeSocket *fromsock; - bNodeSocket *tosock; - }; -} - - -#endif//__BLENDER_BNODELINK__H__ diff --git a/gamekit/autogenerated/blender_bNodeSocket.h b/gamekit/autogenerated/blender_bNodeSocket.h deleted file mode 100644 index e2a8f2047..000000000 --- a/gamekit/autogenerated/blender_bNodeSocket.h +++ /dev/null @@ -1,57 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BNODESOCKET__H__ -#define __BLENDER_BNODESOCKET__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_bNodeStack.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bNodeSocket - { - public: - bNodeSocket *next; - bNodeSocket *prev; - bNodeSocket *new_sock; - char name[32]; - bNodeStack ns; - short type; - short flag; - short limit; - short stack_index; - short intern; - short stack_index_ext; - int pad1; - float locx; - float locy; - int own_index; - int to_index; - bNodeSocket *tosock; - bNodeLink *link; - }; -} - - -#endif//__BLENDER_BNODESOCKET__H__ diff --git a/gamekit/autogenerated/blender_bNodeStack.h b/gamekit/autogenerated/blender_bNodeStack.h deleted file mode 100644 index 79c753da9..000000000 --- a/gamekit/autogenerated/blender_bNodeStack.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BNODESTACK__H__ -#define __BLENDER_BNODESTACK__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bNodeStack - { - public: - vec4f vec; - float min; - float max; - void *data; - short hasinput; - short hasoutput; - short datatype; - short sockettype; - }; -} - - -#endif//__BLENDER_BNODESTACK__H__ diff --git a/gamekit/autogenerated/blender_bNodeTree.h b/gamekit/autogenerated/blender_bNodeTree.h deleted file mode 100644 index 64e28e29b..000000000 --- a/gamekit/autogenerated/blender_bNodeTree.h +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BNODETREE__H__ -#define __BLENDER_BNODETREE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ID.h" -#include "blender_ListBase.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bNodeTree - { - public: - ID id; - ListBase nodes; - ListBase links; - bNodeStack *stack; - ListBase *threadstack; - int type; - int init; - int stacksize; - int cur_index; - ListBase alltypes; - bInvalidHandle *owntype; - bNodeSocket *selin; - bNodeSocket *selout; - void (*timecursor)(); - void (*stats_draw)(); - int (*test_break)(); - }; -} - - -#endif//__BLENDER_BNODETREE__H__ diff --git a/gamekit/autogenerated/blender_bObjectActuator.h b/gamekit/autogenerated/blender_bObjectActuator.h deleted file mode 100644 index 3136670e6..000000000 --- a/gamekit/autogenerated/blender_bObjectActuator.h +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BOBJECTACTUATOR__H__ -#define __BLENDER_BOBJECTACTUATOR__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bObjectActuator - { - public: - short flag; - short type; - short otype; - short damping; - vec3f forceloc; - vec3f forcerot; - vec3f loc; - vec3f rot; - vec3f dloc; - vec3f drot; - vec3f linearvelocity; - vec3f angularvelocity; - Object *reference; - }; -} - - -#endif//__BLENDER_BOBJECTACTUATOR__H__ diff --git a/gamekit/autogenerated/blender_bParentActuator.h b/gamekit/autogenerated/blender_bParentActuator.h deleted file mode 100644 index 2d7ac98d8..000000000 --- a/gamekit/autogenerated/blender_bParentActuator.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BPARENTACTUATOR__H__ -#define __BLENDER_BPARENTACTUATOR__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bParentActuator - { - public: - char pad[2]; - short flag; - int type; - Object *ob; - }; -} - - -#endif//__BLENDER_BPARENTACTUATOR__H__ diff --git a/gamekit/autogenerated/blender_bPose.h b/gamekit/autogenerated/blender_bPose.h deleted file mode 100644 index bc665e433..000000000 --- a/gamekit/autogenerated/blender_bPose.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BPOSE__H__ -#define __BLENDER_BPOSE__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ListBase.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bPose - { - public: - ListBase chanbase; - short flag; - short proxy_layer; - float ctime; - vec3f stride_offset; - vec3f cyclic_offset; - ListBase agroups; - int active_group; - int pad; - }; -} - - -#endif//__BLENDER_BPOSE__H__ diff --git a/gamekit/autogenerated/blender_bPoseChannel.h b/gamekit/autogenerated/blender_bPoseChannel.h deleted file mode 100644 index 170001649..000000000 --- a/gamekit/autogenerated/blender_bPoseChannel.h +++ /dev/null @@ -1,73 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BPOSECHANNEL__H__ -#define __BLENDER_BPOSECHANNEL__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ListBase.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bPoseChannel - { - public: - bPoseChannel *next; - bPoseChannel *prev; - ListBase constraints; - char name[32]; - short flag; - short constflag; - short ikflag; - short selectflag; - short protectflag; - short agrp_index; - int pathlen; - int pathsf; - int pathef; - Bone *bone; - bPoseChannel *parent; - bPoseChannel *child; - ListBase iktree; - void *b_bone_mats; - void *dual_quat; - void *b_bone_dual_quats; - vec3f loc; - vec3f size; - vec4f quat; - float chan_mat[4][4]; - float pose_mat[4][4]; - float constinv[4][4]; - vec3f pose_head; - vec3f pose_tail; - vec3f limitmin; - vec3f limitmax; - vec3f stiffness; - float ikstretch; - float *path; - Object *custom; - }; -} - - -#endif//__BLENDER_BPOSECHANNEL__H__ diff --git a/gamekit/autogenerated/blender_bProperty.h b/gamekit/autogenerated/blender_bProperty.h deleted file mode 100644 index b557ccdd4..000000000 --- a/gamekit/autogenerated/blender_bProperty.h +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BPROPERTY__H__ -#define __BLENDER_BPROPERTY__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bProperty - { - public: - bProperty *next; - bProperty *prev; - char name[32]; - short type; - short otype; - int data; - int old; - short flag; - short pad; - void *poin; - void *oldpoin; - }; -} - - -#endif//__BLENDER_BPROPERTY__H__ diff --git a/gamekit/autogenerated/blender_bPropertyActuator.h b/gamekit/autogenerated/blender_bPropertyActuator.h deleted file mode 100644 index f13a51666..000000000 --- a/gamekit/autogenerated/blender_bPropertyActuator.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BPROPERTYACTUATOR__H__ -#define __BLENDER_BPROPERTYACTUATOR__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bPropertyActuator - { - public: - int flag; - int type; - char name[32]; - char value[32]; - Object *ob; - }; -} - - -#endif//__BLENDER_BPROPERTYACTUATOR__H__ diff --git a/gamekit/autogenerated/blender_bPropertySensor.h b/gamekit/autogenerated/blender_bPropertySensor.h deleted file mode 100644 index a82965257..000000000 --- a/gamekit/autogenerated/blender_bPropertySensor.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BPROPERTYSENSOR__H__ -#define __BLENDER_BPROPERTYSENSOR__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bPropertySensor - { - public: - int type; - int pad; - char name[32]; - char value[32]; - char maxvalue[32]; - }; -} - - -#endif//__BLENDER_BPROPERTYSENSOR__H__ diff --git a/gamekit/autogenerated/blender_bPythonConstraint.h b/gamekit/autogenerated/blender_bPythonConstraint.h deleted file mode 100644 index 4ff9c9b43..000000000 --- a/gamekit/autogenerated/blender_bPythonConstraint.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BPYTHONCONSTRAINT__H__ -#define __BLENDER_BPYTHONCONSTRAINT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ListBase.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bPythonConstraint - { - public: - Text *text; - IDProperty *prop; - int flag; - int tarnum; - ListBase targets; - Object *tar; - char subtarget[32]; - }; -} - - -#endif//__BLENDER_BPYTHONCONSTRAINT__H__ diff --git a/gamekit/autogenerated/blender_bPythonCont.h b/gamekit/autogenerated/blender_bPythonCont.h deleted file mode 100644 index c81dc2d4a..000000000 --- a/gamekit/autogenerated/blender_bPythonCont.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BPYTHONCONT__H__ -#define __BLENDER_BPYTHONCONT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bPythonCont - { - public: - Text *text; - char module[64]; - int mode; - int flag; - }; -} - - -#endif//__BLENDER_BPYTHONCONT__H__ diff --git a/gamekit/autogenerated/blender_bRadarSensor.h b/gamekit/autogenerated/blender_bRadarSensor.h deleted file mode 100644 index 03f304dc4..000000000 --- a/gamekit/autogenerated/blender_bRadarSensor.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BRADARSENSOR__H__ -#define __BLENDER_BRADARSENSOR__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bRadarSensor - { - public: - char name[32]; - float angle; - float range; - short flag; - short axis; - }; -} - - -#endif//__BLENDER_BRADARSENSOR__H__ diff --git a/gamekit/autogenerated/blender_bRandomActuator.h b/gamekit/autogenerated/blender_bRandomActuator.h deleted file mode 100644 index aadb257c9..000000000 --- a/gamekit/autogenerated/blender_bRandomActuator.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BRANDOMACTUATOR__H__ -#define __BLENDER_BRANDOMACTUATOR__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bRandomActuator - { - public: - int seed; - int distribution; - int int_arg_1; - int int_arg_2; - float float_arg_1; - float float_arg_2; - char propname[32]; - }; -} - - -#endif//__BLENDER_BRANDOMACTUATOR__H__ diff --git a/gamekit/autogenerated/blender_bRandomSensor.h b/gamekit/autogenerated/blender_bRandomSensor.h deleted file mode 100644 index d75a510c6..000000000 --- a/gamekit/autogenerated/blender_bRandomSensor.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BRANDOMSENSOR__H__ -#define __BLENDER_BRANDOMSENSOR__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bRandomSensor - { - public: - char name[32]; - int seed; - int delay; - }; -} - - -#endif//__BLENDER_BRANDOMSENSOR__H__ diff --git a/gamekit/autogenerated/blender_bRaySensor.h b/gamekit/autogenerated/blender_bRaySensor.h deleted file mode 100644 index 5fec10e82..000000000 --- a/gamekit/autogenerated/blender_bRaySensor.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BRAYSENSOR__H__ -#define __BLENDER_BRAYSENSOR__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bRaySensor - { - public: - char name[32]; - float range; - char propname[32]; - char matname[32]; - short mode; - short pad1; - int axisflag; - }; -} - - -#endif//__BLENDER_BRAYSENSOR__H__ diff --git a/gamekit/autogenerated/blender_bRigidBodyJointConstraint.h b/gamekit/autogenerated/blender_bRigidBodyJointConstraint.h deleted file mode 100644 index bb5601b28..000000000 --- a/gamekit/autogenerated/blender_bRigidBodyJointConstraint.h +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BRIGIDBODYJOINTCONSTRAINT__H__ -#define __BLENDER_BRIGIDBODYJOINTCONSTRAINT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bRigidBodyJointConstraint - { - public: - Object *tar; - Object *child; - int type; - float pivX; - float pivY; - float pivZ; - float axX; - float axY; - float axZ; - float minLimit[6]; - float maxLimit[6]; - float extraFz; - short flag; - short pad; - short pad1; - short pad2; - }; -} - - -#endif//__BLENDER_BRIGIDBODYJOINTCONSTRAINT__H__ diff --git a/gamekit/autogenerated/blender_bRotLimitConstraint.h b/gamekit/autogenerated/blender_bRotLimitConstraint.h deleted file mode 100644 index 283d0510c..000000000 --- a/gamekit/autogenerated/blender_bRotLimitConstraint.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BROTLIMITCONSTRAINT__H__ -#define __BLENDER_BROTLIMITCONSTRAINT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bRotLimitConstraint - { - public: - float xmin; - float xmax; - float ymin; - float ymax; - float zmin; - float zmax; - short flag; - short flag2; - }; -} - - -#endif//__BLENDER_BROTLIMITCONSTRAINT__H__ diff --git a/gamekit/autogenerated/blender_bRotateLikeConstraint.h b/gamekit/autogenerated/blender_bRotateLikeConstraint.h deleted file mode 100644 index 56cf0a66e..000000000 --- a/gamekit/autogenerated/blender_bRotateLikeConstraint.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BROTATELIKECONSTRAINT__H__ -#define __BLENDER_BROTATELIKECONSTRAINT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bRotateLikeConstraint - { - public: - Object *tar; - int flag; - int reserved1; - char subtarget[32]; - }; -} - - -#endif//__BLENDER_BROTATELIKECONSTRAINT__H__ diff --git a/gamekit/autogenerated/blender_bRotationConstraint.h b/gamekit/autogenerated/blender_bRotationConstraint.h deleted file mode 100644 index c42081bca..000000000 --- a/gamekit/autogenerated/blender_bRotationConstraint.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BROTATIONCONSTRAINT__H__ -#define __BLENDER_BROTATIONCONSTRAINT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bRotationConstraint - { - public: - float xmin; - float xmax; - float ymin; - float ymax; - float zmin; - float zmax; - }; -} - - -#endif//__BLENDER_BROTATIONCONSTRAINT__H__ diff --git a/gamekit/autogenerated/blender_bSceneActuator.h b/gamekit/autogenerated/blender_bSceneActuator.h deleted file mode 100644 index 8f422318b..000000000 --- a/gamekit/autogenerated/blender_bSceneActuator.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BSCENEACTUATOR__H__ -#define __BLENDER_BSCENEACTUATOR__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bSceneActuator - { - public: - short type; - short flag; - int pad; - Scene *scene; - Object *camera; - }; -} - - -#endif//__BLENDER_BSCENEACTUATOR__H__ diff --git a/gamekit/autogenerated/blender_bScreen.h b/gamekit/autogenerated/blender_bScreen.h deleted file mode 100644 index 7f8253eaa..000000000 --- a/gamekit/autogenerated/blender_bScreen.h +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BSCREEN__H__ -#define __BLENDER_BSCREEN__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ID.h" -#include "blender_ListBase.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bScreen - { - public: - ID id; - ListBase vertbase; - ListBase edgebase; - ListBase areabase; - Scene *scene; - short startx; - short endx; - short starty; - short endy; - short sizex; - short sizey; - short scenenr; - short screennr; - short full; - short pad; - short mainwin; - short winakt; - short handler[8]; - }; -} - - -#endif//__BLENDER_BSCREEN__H__ diff --git a/gamekit/autogenerated/blender_bSensor.h b/gamekit/autogenerated/blender_bSensor.h deleted file mode 100644 index 2915ff73a..000000000 --- a/gamekit/autogenerated/blender_bSensor.h +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BSENSOR__H__ -#define __BLENDER_BSENSOR__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bSensor - { - public: - bSensor *next; - bSensor *prev; - short type; - short otype; - short flag; - short pulse; - short freq; - short totlinks; - short pad1; - short pad2; - char name[32]; - void *data; - bController **links; - Object *ob; - short invert; - short level; - short tap; - short pad; - }; -} - - -#endif//__BLENDER_BSENSOR__H__ diff --git a/gamekit/autogenerated/blender_bShrinkwrapConstraint.h b/gamekit/autogenerated/blender_bShrinkwrapConstraint.h deleted file mode 100644 index cbe63c9c8..000000000 --- a/gamekit/autogenerated/blender_bShrinkwrapConstraint.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BSHRINKWRAPCONSTRAINT__H__ -#define __BLENDER_BSHRINKWRAPCONSTRAINT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bShrinkwrapConstraint - { - public: - Object *target; - float dist; - short shrinkType; - char projAxis; - char pad[9]; - }; -} - - -#endif//__BLENDER_BSHRINKWRAPCONSTRAINT__H__ diff --git a/gamekit/autogenerated/blender_bSizeLikeConstraint.h b/gamekit/autogenerated/blender_bSizeLikeConstraint.h deleted file mode 100644 index a4b828f33..000000000 --- a/gamekit/autogenerated/blender_bSizeLikeConstraint.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BSIZELIKECONSTRAINT__H__ -#define __BLENDER_BSIZELIKECONSTRAINT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bSizeLikeConstraint - { - public: - Object *tar; - int flag; - int reserved1; - char subtarget[32]; - }; -} - - -#endif//__BLENDER_BSIZELIKECONSTRAINT__H__ diff --git a/gamekit/autogenerated/blender_bSizeLimitConstraint.h b/gamekit/autogenerated/blender_bSizeLimitConstraint.h deleted file mode 100644 index 9cb9f0567..000000000 --- a/gamekit/autogenerated/blender_bSizeLimitConstraint.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BSIZELIMITCONSTRAINT__H__ -#define __BLENDER_BSIZELIMITCONSTRAINT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bSizeLimitConstraint - { - public: - float xmin; - float xmax; - float ymin; - float ymax; - float zmin; - float zmax; - short flag; - short flag2; - }; -} - - -#endif//__BLENDER_BSIZELIMITCONSTRAINT__H__ diff --git a/gamekit/autogenerated/blender_bSound.h b/gamekit/autogenerated/blender_bSound.h deleted file mode 100644 index 8b327d610..000000000 --- a/gamekit/autogenerated/blender_bSound.h +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BSOUND__H__ -#define __BLENDER_BSOUND__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ID.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bSound - { - public: - ID id; - char name[160]; - bInvalidHandle *sample; - void *stream; - PackedFile *packedfile; - PackedFile *newpackedfile; - void *snd_sound; - Ipo *ipo; - float volume; - float panning; - float attenuation; - float pitch; - float min_gain; - float max_gain; - float distance; - int flags; - int streamlen; - char channels; - char highprio; - char pad[10]; - }; -} - - -#endif//__BLENDER_BSOUND__H__ diff --git a/gamekit/autogenerated/blender_bSoundActuator.h b/gamekit/autogenerated/blender_bSoundActuator.h deleted file mode 100644 index 4a54c7327..000000000 --- a/gamekit/autogenerated/blender_bSoundActuator.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BSOUNDACTUATOR__H__ -#define __BLENDER_BSOUNDACTUATOR__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bSoundActuator - { - public: - short flag; - short sndnr; - int sta; - int end; - short pad1[2]; - bSound *sound; - short type; - short makecopy; - short copymade; - short pad2[1]; - }; -} - - -#endif//__BLENDER_BSOUNDACTUATOR__H__ diff --git a/gamekit/autogenerated/blender_bSoundListener.h b/gamekit/autogenerated/blender_bSoundListener.h deleted file mode 100644 index 5abc1c9b3..000000000 --- a/gamekit/autogenerated/blender_bSoundListener.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BSOUNDLISTENER__H__ -#define __BLENDER_BSOUNDLISTENER__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ID.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bSoundListener - { - public: - ID id; - float gain; - float dopplerfactor; - float dopplervelocity; - short numsoundsblender; - short numsoundsgameengine; - }; -} - - -#endif//__BLENDER_BSOUNDLISTENER__H__ diff --git a/gamekit/autogenerated/blender_bStateActuator.h b/gamekit/autogenerated/blender_bStateActuator.h deleted file mode 100644 index 3ac7bfd13..000000000 --- a/gamekit/autogenerated/blender_bStateActuator.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BSTATEACTUATOR__H__ -#define __BLENDER_BSTATEACTUATOR__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bStateActuator - { - public: - int type; - int mask; - }; -} - - -#endif//__BLENDER_BSTATEACTUATOR__H__ diff --git a/gamekit/autogenerated/blender_bStretchToConstraint.h b/gamekit/autogenerated/blender_bStretchToConstraint.h deleted file mode 100644 index 7f3ef0c79..000000000 --- a/gamekit/autogenerated/blender_bStretchToConstraint.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BSTRETCHTOCONSTRAINT__H__ -#define __BLENDER_BSTRETCHTOCONSTRAINT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bStretchToConstraint - { - public: - Object *tar; - int volmode; - int plane; - float orglength; - float bulge; - char subtarget[32]; - }; -} - - -#endif//__BLENDER_BSTRETCHTOCONSTRAINT__H__ diff --git a/gamekit/autogenerated/blender_bTheme.h b/gamekit/autogenerated/blender_bTheme.h deleted file mode 100644 index ac5073aec..000000000 --- a/gamekit/autogenerated/blender_bTheme.h +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BTHEME__H__ -#define __BLENDER_BTHEME__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" -#include "blender_ThemeSpace.h" -#include "blender_ThemeUI.h" -#include "blender_ThemeWireColor.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bTheme - { - public: - bTheme *next; - bTheme *prev; - char name[32]; - ThemeUI tui; - ThemeSpace tbuts; - ThemeSpace tv3d; - ThemeSpace tfile; - ThemeSpace tipo; - ThemeSpace tinfo; - ThemeSpace tsnd; - ThemeSpace tact; - ThemeSpace tnla; - ThemeSpace tseq; - ThemeSpace tima; - ThemeSpace timasel; - ThemeSpace text; - ThemeSpace toops; - ThemeSpace ttime; - ThemeSpace tnode; - ThemeWireColor tarm[20]; - char bpad[4]; - char bpad1[4]; - }; -} - - -#endif//__BLENDER_BTHEME__H__ diff --git a/gamekit/autogenerated/blender_bTouchSensor.h b/gamekit/autogenerated/blender_bTouchSensor.h deleted file mode 100644 index 8f3fb281b..000000000 --- a/gamekit/autogenerated/blender_bTouchSensor.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BTOUCHSENSOR__H__ -#define __BLENDER_BTOUCHSENSOR__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bTouchSensor - { - public: - char name[32]; - Material *ma; - float dist; - float pad; - }; -} - - -#endif//__BLENDER_BTOUCHSENSOR__H__ diff --git a/gamekit/autogenerated/blender_bTrackToConstraint.h b/gamekit/autogenerated/blender_bTrackToConstraint.h deleted file mode 100644 index 04de0945e..000000000 --- a/gamekit/autogenerated/blender_bTrackToConstraint.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BTRACKTOCONSTRAINT__H__ -#define __BLENDER_BTRACKTOCONSTRAINT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bTrackToConstraint - { - public: - Object *tar; - int reserved1; - int reserved2; - int flags; - int pad; - char subtarget[32]; - }; -} - - -#endif//__BLENDER_BTRACKTOCONSTRAINT__H__ diff --git a/gamekit/autogenerated/blender_bTransformConstraint.h b/gamekit/autogenerated/blender_bTransformConstraint.h deleted file mode 100644 index f952e4994..000000000 --- a/gamekit/autogenerated/blender_bTransformConstraint.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BTRANSFORMCONSTRAINT__H__ -#define __BLENDER_BTRANSFORMCONSTRAINT__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bTransformConstraint - { - public: - Object *tar; - char subtarget[32]; - short from; - short to; - char map[3]; - char expo; - vec3f from_min; - vec3f from_max; - vec3f to_min; - vec3f to_max; - }; -} - - -#endif//__BLENDER_BTRANSFORMCONSTRAINT__H__ diff --git a/gamekit/autogenerated/blender_bTwoDFilterActuator.h b/gamekit/autogenerated/blender_bTwoDFilterActuator.h deleted file mode 100644 index 1f9fe14ed..000000000 --- a/gamekit/autogenerated/blender_bTwoDFilterActuator.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BTWODFILTERACTUATOR__H__ -#define __BLENDER_BTWODFILTERACTUATOR__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bTwoDFilterActuator - { - public: - char pad[4]; - short type; - short flag; - int int_arg; - float float_arg; - Text *text; - }; -} - - -#endif//__BLENDER_BTWODFILTERACTUATOR__H__ diff --git a/gamekit/autogenerated/blender_bVisibilityActuator.h b/gamekit/autogenerated/blender_bVisibilityActuator.h deleted file mode 100644 index 0ceecfaa7..000000000 --- a/gamekit/autogenerated/blender_bVisibilityActuator.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_BVISIBILITYACTUATOR__H__ -#define __BLENDER_BVISIBILITYACTUATOR__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class bVisibilityActuator - { - public: - int flag; - }; -} - - -#endif//__BLENDER_BVISIBILITYACTUATOR__H__ diff --git a/gamekit/autogenerated/blender_rctf.h b/gamekit/autogenerated/blender_rctf.h deleted file mode 100644 index 2ff6cbc19..000000000 --- a/gamekit/autogenerated/blender_rctf.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_RCTF__H__ -#define __BLENDER_RCTF__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class rctf - { - public: - float xmin; - float xmax; - float ymin; - float ymax; - }; -} - - -#endif//__BLENDER_RCTF__H__ diff --git a/gamekit/autogenerated/blender_rcti.h b/gamekit/autogenerated/blender_rcti.h deleted file mode 100644 index 9e15f52af..000000000 --- a/gamekit/autogenerated/blender_rcti.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_RCTI__H__ -#define __BLENDER_RCTI__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class rcti - { - public: - int xmin; - int xmax; - int ymin; - int ymax; - }; -} - - -#endif//__BLENDER_RCTI__H__ diff --git a/gamekit/autogenerated/blender_vec2d.h b/gamekit/autogenerated/blender_vec2d.h deleted file mode 100644 index 0a37e2db2..000000000 --- a/gamekit/autogenerated/blender_vec2d.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_VEC2D__H__ -#define __BLENDER_VEC2D__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class vec2d - { - public: - double x; - double y; - }; -} - - -#endif//__BLENDER_VEC2D__H__ diff --git a/gamekit/autogenerated/blender_vec2f.h b/gamekit/autogenerated/blender_vec2f.h deleted file mode 100644 index 01cfa05b3..000000000 --- a/gamekit/autogenerated/blender_vec2f.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_VEC2F__H__ -#define __BLENDER_VEC2F__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class vec2f - { - public: - float x; - float y; - }; -} - - -#endif//__BLENDER_VEC2F__H__ diff --git a/gamekit/autogenerated/blender_vec2i.h b/gamekit/autogenerated/blender_vec2i.h deleted file mode 100644 index 71e97fed4..000000000 --- a/gamekit/autogenerated/blender_vec2i.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_VEC2I__H__ -#define __BLENDER_VEC2I__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class vec2i - { - public: - int x; - int y; - }; -} - - -#endif//__BLENDER_VEC2I__H__ diff --git a/gamekit/autogenerated/blender_vec2s.h b/gamekit/autogenerated/blender_vec2s.h deleted file mode 100644 index 9bf2f1444..000000000 --- a/gamekit/autogenerated/blender_vec2s.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_VEC2S__H__ -#define __BLENDER_VEC2S__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class vec2s - { - public: - short x; - short y; - }; -} - - -#endif//__BLENDER_VEC2S__H__ diff --git a/gamekit/autogenerated/blender_vec3d.h b/gamekit/autogenerated/blender_vec3d.h deleted file mode 100644 index be252804e..000000000 --- a/gamekit/autogenerated/blender_vec3d.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_VEC3D__H__ -#define __BLENDER_VEC3D__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class vec3d - { - public: - double x; - double y; - double z; - }; -} - - -#endif//__BLENDER_VEC3D__H__ diff --git a/gamekit/autogenerated/blender_vec3f.h b/gamekit/autogenerated/blender_vec3f.h deleted file mode 100644 index 5390da6ff..000000000 --- a/gamekit/autogenerated/blender_vec3f.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_VEC3F__H__ -#define __BLENDER_VEC3F__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class vec3f - { - public: - float x; - float y; - float z; - }; -} - - -#endif//__BLENDER_VEC3F__H__ diff --git a/gamekit/autogenerated/blender_vec3i.h b/gamekit/autogenerated/blender_vec3i.h deleted file mode 100644 index 8761bcac8..000000000 --- a/gamekit/autogenerated/blender_vec3i.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_VEC3I__H__ -#define __BLENDER_VEC3I__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class vec3i - { - public: - int x; - int y; - int z; - }; -} - - -#endif//__BLENDER_VEC3I__H__ diff --git a/gamekit/autogenerated/blender_vec4d.h b/gamekit/autogenerated/blender_vec4d.h deleted file mode 100644 index 0c20d0b63..000000000 --- a/gamekit/autogenerated/blender_vec4d.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_VEC4D__H__ -#define __BLENDER_VEC4D__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class vec4d - { - public: - double x; - double y; - double z; - double w; - }; -} - - -#endif//__BLENDER_VEC4D__H__ diff --git a/gamekit/autogenerated/blender_vec4f.h b/gamekit/autogenerated/blender_vec4f.h deleted file mode 100644 index 6f7ad90e9..000000000 --- a/gamekit/autogenerated/blender_vec4f.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_VEC4F__H__ -#define __BLENDER_VEC4F__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class vec4f - { - public: - float x; - float y; - float z; - float w; - }; -} - - -#endif//__BLENDER_VEC4F__H__ diff --git a/gamekit/autogenerated/blender_vec4i.h b/gamekit/autogenerated/blender_vec4i.h deleted file mode 100644 index 80d5a97f1..000000000 --- a/gamekit/autogenerated/blender_vec4i.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2006 Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BLENDER_VEC4I__H__ -#define __BLENDER_VEC4I__H__ - - -// -------------------------------------------------- // -#include "blender_Common.h" - -namespace Blender { - - - // ---------------------------------------------- // - class vec4i - { - public: - int x; - int y; - int z; - int w; - }; -} - - -#endif//__BLENDER_VEC4I__H__ diff --git a/gamekit/bBlenderFile.cpp b/gamekit/bBlenderFile.cpp deleted file mode 100644 index 034c15376..000000000 --- a/gamekit/bBlenderFile.cpp +++ /dev/null @@ -1,225 +0,0 @@ -/* -bParse -Copyright (c) 2006-2009 Charlie C & Erwin Coumans http://gamekit.googlecode.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "bBlenderFile.h" -#include "bMain.h" -#include "bDefines.h" -#include "bDNA.h" -#include "autogenerated/blender.h" // for Blender::ListBase -#include <stdio.h> -#include <string.h> - -// 32 && 64 bit versions -extern unsigned char DNAstr[]; -extern int DNAlen; - -extern unsigned char DNAstr64[]; -extern int DNAlen64; - - -using namespace bParse; - -bBlenderFile::bBlenderFile(const char* fileName) -:bFile(fileName, "BLENDER") -{ - mMain= new bMain(this, fileName, mVersion); -} - - - -bBlenderFile::bBlenderFile(char *memoryBuffer, int len) -:bFile(memoryBuffer,len, "BLENDER"), -mMain(0) -{ - mMain= new bMain(this, "memoryBuf", mVersion); -} - - -bBlenderFile::~bBlenderFile() -{ - delete mMain; -} - - -bMain* bBlenderFile::getMain() -{ - return mMain; -} - -// ----------------------------------------------------- // -void bBlenderFile::parseData() -{ - printf ("Building datablocks\n"); - printf ("Chunk size = %d\n",CHUNK_HEADER_LEN); - printf ("File chunk size = %d\n", ChunkUtils::getOffset(mFlags)); - - const bool swap = (mFlags&FD_ENDIAN_SWAP)!=0; - - - - char *dataPtr = mFileBuffer+mDataStart; - - bChunkInd dataChunk; - dataChunk.code = 0; - - - //dataPtr += ChunkUtils::getNextBlock(&dataChunk, dataPtr, mFlags); - int seek = ChunkUtils::getNextBlock(&dataChunk, dataPtr, mFlags); - //dataPtr += ChunkUtils::getOffset(mFlags); - char *dataPtrHead = 0; - - while (dataChunk.code != DNA1) - { - - - - - // one behind - if (dataChunk.code == SDNA) break; - //if (dataChunk.code == DNA1) break; - - // same as (BHEAD+DATA dependancy) - dataPtrHead = dataPtr+ChunkUtils::getOffset(mFlags); - char *id = readStruct(dataPtrHead, dataChunk); - - // lookup maps - if (id) - { - mLibPointers.insert(dataChunk.oldPtr, (bStructHandle*)id); - - m_chunks.push_back(dataChunk); - // block it - bListBasePtr *listID = mMain->getListBasePtr(dataChunk.code); - if (listID) - listID->push_back((bStructHandle*)id); - } - - if (dataChunk.code == GLOB) - { - m_glob = (bStructHandle*) id; - } - - // next please! - dataPtr += seek; - - seek = ChunkUtils::getNextBlock(&dataChunk, dataPtr, mFlags); - if (seek < 0) - break; - } - -} - -void bBlenderFile::addDataBlock(char* dataBlock) -{ - mMain->addDatablock(dataBlock); -} - - - - - -// 32 && 64 bit versions -extern unsigned char DNAstr[]; -extern int DNAlen; - -//unsigned char DNAstr[]={0}; -//int DNAlen=0; - - -extern unsigned char DNAstr64[]; -extern int DNAlen64; - - -void bBlenderFile::writeDNA(FILE* fp) -{ - - bChunkInd dataChunk; - dataChunk.code = DNA1; - dataChunk.dna_nr = 0; - dataChunk.nr = 1; - - if (VOID_IS_8) - { - dataChunk.len = DNAlen64; - dataChunk.oldPtr = DNAstr64; - fwrite(&dataChunk,sizeof(bChunkInd),1,fp); - fwrite(DNAstr64, DNAlen64,1,fp); - } - else - { - dataChunk.len = DNAlen; - dataChunk.oldPtr = DNAstr; - fwrite(&dataChunk,sizeof(bChunkInd),1,fp); - fwrite(DNAstr, DNAlen,1,fp); - } -} - -void bBlenderFile::parse(bool verboseDumpAllTypes) -{ - if (VOID_IS_8) - { - parseInternal(verboseDumpAllTypes,(char*)DNAstr64,DNAlen64); - } - else - { - parseInternal(verboseDumpAllTypes,(char*)DNAstr,DNAlen); - } -} - -// experimental -int bBlenderFile::write(const char* fileName, bool fixupPointers) -{ - FILE *fp = fopen(fileName, "wb"); - if (fp) - { - char header[SIZEOFBLENDERHEADER] ; - memcpy(header, m_headerString, 7); - int endian= 1; - endian= ((char*)&endian)[0]; - - if (endian) - { - header[7] = '_'; - } else - { - header[7] = '-'; - } - if (VOID_IS_8) - { - header[8]='V'; - } else - { - header[8]='v'; - } - - header[9] = '2'; - header[10] = '4'; - header[11] = '9'; - - fwrite(header,SIZEOFBLENDERHEADER,1,fp); - - writeChunks(fp, fixupPointers); - - writeDNA(fp); - - fclose(fp); - - } else - { - printf("Error: cannot open file %s for writing\n",fileName); - return 0; - } - return 1; -} \ No newline at end of file diff --git a/gamekit/bBlenderFile.h b/gamekit/bBlenderFile.h deleted file mode 100644 index 9ae9198ec..000000000 --- a/gamekit/bBlenderFile.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -bParse -Copyright (c) 2006-2009 Charlie C & Erwin Coumans http://gamekit.googlecode.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef B_BLENDER_FILE_H -#define B_BLENDER_FILE_H - - -#include "bFile.h" - -namespace bParse { - - // ----------------------------------------------------- // - class bBlenderFile : public bFile - { - - protected: - bMain* mMain; - - bStructHandle* m_glob; - - - public: - - bBlenderFile(const char* fileName); - - bBlenderFile(char *memoryBuffer, int len); - - virtual ~bBlenderFile(); - - bMain* getMain(); - - virtual void addDataBlock(char* dataBlock); - - bStructHandle* getFileGlobal() - { - return m_glob; - } - - // experimental - virtual int write(const char* fileName, bool fixupPointers = false); - - virtual void parse(bool verboseDumpAllTypes); - - virtual void parseData(); - - virtual void writeDNA(FILE* fp); - - }; -}; - -#endif //B_BLENDER_FILE_H diff --git a/gamekit/bChunk.cpp b/gamekit/bChunk.cpp deleted file mode 100644 index 737e60bb5..000000000 --- a/gamekit/bChunk.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/* -bParse -Copyright (c) 2006-2009 Charlie C & Erwin Coumans http://gamekit.googlecode.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ -#include <memory.h> -#include "bChunk.h" -#include "bDefines.h" -#include "bFile.h" - -using namespace bParse; - - -// ----------------------------------------------------- // -short ChunkUtils::swapShort(short sht) -{ - SWITCH_SHORT(sht); - return sht; -} - -// ----------------------------------------------------- // -int ChunkUtils::swapInt(int inte) -{ - SWITCH_INT(inte); - return inte; -} - -// ----------------------------------------------------- // -long64 ChunkUtils::swapLong64(long64 lng) -{ - SWITCH_LONGINT(lng); - return lng; -} - -// ----------------------------------------------------- // -int ChunkUtils::getOffset(int flags) -{ - // if the file is saved in a - // different format, get the - // file's chunk size - int res = CHUNK_HEADER_LEN; - - if (VOID_IS_8) - { - if (flags &FD_BITS_VARIES) - res = sizeof(bChunkPtr4); - } - else - { - if (flags &FD_BITS_VARIES) - res = sizeof(bChunkPtr8); - } - return res; -} - - -// ----------------------------------------------------- // -int ChunkUtils::getNextBlock(bChunkInd *dataChunk, char *dataPtr, const int flags) -{ - bool swap = false; - bool varies = false; - - if (flags &FD_ENDIAN_SWAP) swap = true; - if (flags &FD_BITS_VARIES) varies = true; - - if (VOID_IS_8) - { - if (varies) - { - bChunkPtr4 head; - memcpy(&head, dataPtr, sizeof(bChunkPtr4)); - - - bChunkPtr8 chunk; - - chunk.code = head.code; - chunk.len = head.len; - chunk.old = head.old; - chunk.dna_nr = head.dna_nr; - chunk.nr = head.nr; - - if (swap) - { - if ((chunk.code & 0xFFFF)==0) - chunk.code >>=16; - - SWITCH_INT(chunk.len); - SWITCH_INT(chunk.dna_nr); - SWITCH_INT(chunk.nr); - } - - - memcpy(dataChunk, &chunk, sizeof(bChunkInd)); - } - else - { - bChunkPtr8 c; - memcpy(&c, dataPtr, sizeof(bChunkPtr8)); - - if (swap) - { - if ((c.code & 0xFFFF)==0) - c.code >>=16; - - SWITCH_INT(c.len); - SWITCH_INT(c.dna_nr); - SWITCH_INT(c.nr); - } - - memcpy(dataChunk, &c, sizeof(bChunkInd)); - } - } - else - { - if (varies) - { - bChunkPtr8 head; - memcpy(&head, dataPtr, sizeof(bChunkPtr8)); - - - bChunkPtr4 chunk; - chunk.code = head.code; - chunk.len = head.len; - - long64 oldPtr =0; - - memcpy(&oldPtr, &head.old, 8); - chunk.old = (int)(oldPtr >> 3); - - chunk.dna_nr = head.dna_nr; - chunk.nr = head.nr; - - if (swap) - { - if ((chunk.code & 0xFFFF)==0) - chunk.code >>=16; - - SWITCH_INT(chunk.len); - SWITCH_INT(chunk.dna_nr); - SWITCH_INT(chunk.nr); - } - - memcpy(dataChunk, &chunk, sizeof(bChunkInd)); - } - else - { - bChunkPtr4 c; - memcpy(&c, dataPtr, sizeof(bChunkPtr4)); - - if (swap) - { - if ((c.code & 0xFFFF)==0) - c.code >>=16; - - SWITCH_INT(c.len); - SWITCH_INT(c.dna_nr); - SWITCH_INT(c.nr); - } - memcpy(dataChunk, &c, sizeof(bChunkInd)); - } - } - - if (dataChunk->len < 0) - return -1; - -#if 0 - print ("----------"); - print (dataChunk->code); - print (dataChunk->len); - print (dataChunk->old); - print (dataChunk->dna_nr); - print (dataChunk->nr); -#endif - return (dataChunk->len+getOffset(flags)); -} - - - -//eof diff --git a/gamekit/bChunk.h b/gamekit/bChunk.h deleted file mode 100644 index 524c78442..000000000 --- a/gamekit/bChunk.h +++ /dev/null @@ -1,85 +0,0 @@ -/* -bParse -Copyright (c) 2006-2009 Charlie C & Erwin Coumans http://gamekit.googlecode.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef __BCHUNK_H__ -#define __BCHUNK_H__ - - -#ifdef WIN32 - #define long64 __int64 -#else - #define long64 long long -#endif - - -namespace bParse { - - - // ----------------------------------------------------- // - class bChunkPtr4 - { - public: - bChunkPtr4(){} - int code; - int len; - int old; - int dna_nr; - int nr; - }; - - // ----------------------------------------------------- // - class bChunkPtr8 - { - public: - bChunkPtr8(){} - int code, len; - long64 old; - int dna_nr, nr; - }; - - // ----------------------------------------------------- // - class bChunkInd - { - public: - bChunkInd(){} - int code, len; - void *oldPtr; - int dna_nr, nr; - }; - - - // ----------------------------------------------------- // - class ChunkUtils - { - public: - // buffer offset util - static int getNextBlock(bChunkInd *dataChunk, char *dataPtr, const int flags); - - // file chunk offset - static int getOffset(int flags); - - // endian utils - static short swapShort(short sht); - static int swapInt(int inte); - static long64 swapLong64(long64 lng); - - }; - - - const int CHUNK_HEADER_LEN = ((sizeof(bChunkInd))); - const bool VOID_IS_8 = ((sizeof(void*)==8)); -} - -#endif//__BCHUNK_H__ diff --git a/gamekit/bCommon.h b/gamekit/bCommon.h deleted file mode 100644 index c145ce79f..000000000 --- a/gamekit/bCommon.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -bParse -Copyright (c) 2006-2009 Charlie C & Erwin Coumans http://gamekit.googlecode.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef __BCOMMON_H__ -#define __BCOMMON_H__ - - -#include <assert.h> -//#include "bLog.h" -#include "LinearMath/btAlignedObjectArray.h" -#include "LinearMath/btHashMap.h" - -namespace bParse { - - class bMain; - class bFileData; - class bFile; - class bDNA; - - // delete void* undefined - typedef struct bStructHandle {int unused;}bStructHandle; - typedef btAlignedObjectArray<bStructHandle*> bListBasePtr; - typedef btHashMap<btHashKeyPtr, bStructHandle*> bPtrMap; -} - - -#endif//__BCOMMON_H__ diff --git a/gamekit/bDNA.cpp b/gamekit/bDNA.cpp deleted file mode 100644 index 47b7eca0d..000000000 --- a/gamekit/bDNA.cpp +++ /dev/null @@ -1,624 +0,0 @@ -/* -bParse -Copyright (c) 2006-2009 Charlie C & Erwin Coumans http://gamekit.googlecode.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ -#include <assert.h> - -#include "bDNA.h" -#include "bChunk.h" -#include <string.h> -#include <stdlib.h> -#include <stdio.h> - -using namespace bParse; - - -// ----------------------------------------------------- // -bDNA::bDNA() - : mPtrLen(0) -{ - // -- -} - -// ----------------------------------------------------- // -bDNA::~bDNA() -{ - // -- -} - -// ----------------------------------------------------- // -bool bDNA::lessThan(bDNA *file) -{ - return ( m_Names.size() < file->m_Names.size()); -} - -// ----------------------------------------------------- // -char *bDNA::getName(int ind) -{ - assert(ind <= (int)m_Names.size()); - return m_Names[ind].m_name; -} - - -// ----------------------------------------------------- // -char *bDNA::getType(int ind) -{ - assert(ind<= (int)mTypes.size()); - return mTypes[ind]; -} - - -// ----------------------------------------------------- // -short *bDNA::getStruct(int ind) -{ - assert(ind <= (int)mStructs.size()); - return mStructs[ind]; -} - - -// ----------------------------------------------------- // -short bDNA::getLength(int ind) -{ - assert(ind <= (int)mTlens.size()); - return mTlens[ind]; -} - - -// ----------------------------------------------------- // -int bDNA::getReverseType(short type) -{ - - int* intPtr = mStructReverse.find(type); - if (intPtr) - return *intPtr; - - return -1; -} - -// ----------------------------------------------------- // -int bDNA::getReverseType(const char *type) -{ - - btHashString key(type); - int* valuePtr = mTypeLookup.find(key); - if (valuePtr) - return *valuePtr; - - return -1; -} - -// ----------------------------------------------------- // -int bDNA::getNumStructs() -{ - return (int)mStructs.size(); -} - -// ----------------------------------------------------- // -bool bDNA::flagNotEqual(int dna_nr) -{ - assert(dna_nr <= (int)mCMPFlags.size()); - return mCMPFlags[dna_nr] == FDF_STRUCT_NEQU; -} - -// ----------------------------------------------------- // -bool bDNA::flagEqual(int dna_nr) -{ - assert(dna_nr <= (int)mCMPFlags.size()); - int flag = mCMPFlags[dna_nr]; - return flag == FDF_STRUCT_EQU; -} - -// ----------------------------------------------------- // -bool bDNA::flagNone(int dna_nr) -{ - assert(dna_nr <= (int)mCMPFlags.size()); - return mCMPFlags[dna_nr] == FDF_NONE; -} - -// ----------------------------------------------------- // -int bDNA::getPointerSize() -{ - return mPtrLen; -} - -// ----------------------------------------------------- // -void bDNA::initRecurseCmpFlags(int iter) -{ - // iter is FDF_STRUCT_NEQU - - short *oldStrc = mStructs[iter]; - short type = oldStrc[0]; - - for (int i=0; i<(int)mStructs.size(); i++) - { - if (i != iter && mCMPFlags[i] == FDF_STRUCT_EQU ) - { - short *curStruct = mStructs[i]; - int eleLen = curStruct[1]; - curStruct+=2; - - for (int j=0; j<eleLen; j++, curStruct+=2) - { - if (curStruct[0] == type) - { - //char *name = m_Names[curStruct[1]].m_name; - //if (name[0] != '*') - if (m_Names[curStruct[1]].m_isPointer) - { - mCMPFlags[i] = FDF_STRUCT_NEQU; - initRecurseCmpFlags(i); - } - } - } - } - } -} - -// ----------------------------------------------------- // -void bDNA::initCmpFlags(bDNA *memDNA) -{ - - // compare the file to memory - // this ptr should be the file data - - - assert(!m_Names.size() == 0 && "SDNA empty!"); - mCMPFlags.resize(mStructs.size(), FDF_NONE); - - - - for (int i=0; i<(int)mStructs.size(); i++) - { - short *oldStruct = mStructs[i]; - - int oldLookup = getReverseType(oldStruct[0]); - if (oldLookup == -1) - { - mCMPFlags[i] = FDF_NONE; - continue; - } -//#define SLOW_FORWARD_COMPATIBLE 1 -#ifdef SLOW_FORWARD_COMPATIBLE - char* typeName = mTypes[oldLookup]; - int newLookup = memDNA->getReverseType(typeName); - if (newLookup == -1) - { - mCMPFlags[i] = FDF_NONE; - continue; - } - short *curStruct = memDNA->mStructs[newLookup]; -#else - // memory for file - - if (oldLookup < memDNA->mStructs.size()) - { - short *curStruct = memDNA->mStructs[oldLookup]; -#endif - - - - // rebuild... - mCMPFlags[i] = FDF_STRUCT_NEQU; - -#if 1 - if (curStruct[1] == oldStruct[1]) - { - // type len same ... - if (mTlens[oldStruct[0]] == memDNA->mTlens[curStruct[0]]) - { - bool isSame = true; - int elementLength = oldStruct[1]; - - - curStruct+=2; - oldStruct+=2; - - - for (int j=0; j<elementLength; j++, curStruct+=2, oldStruct+=2) - { - // type the same - if (strcmp(mTypes[oldStruct[0]], memDNA->mTypes[curStruct[0]])!=0) - { - isSame=false; - break; - } - - // name the same - if (strcmp(m_Names[oldStruct[1]].m_name, memDNA->m_Names[curStruct[1]].m_name)!=0) - { - isSame=false; - break; - } - } - // flag valid == - if (isSame) - mCMPFlags[i] = FDF_STRUCT_EQU; - } - } -#endif - } - } - - - - - - // recurse in - for (int i=0; i<(int)mStructs.size(); i++) - { - if (mCMPFlags[i] == FDF_STRUCT_NEQU) - initRecurseCmpFlags(i); - } -} - - - - -static int name_is_array(char* name, int* dim1, int* dim2) { - int len = strlen(name); - /*fprintf(stderr,"[%s]",name);*/ - /*if (len >= 1) { - if (name[len-1] != ']') - return 1; - } - return 0;*/ - char *bp; - int num; - if (dim1) { - *dim1 = 1; - } - if (dim2) { - *dim2 = 1; - } - bp = strchr(name, '['); - if (!bp) { - return 0; - } - num = 0; - while (++bp < name+len-1) { - const char c = *bp; - if (c == ']') { - break; - } - if (c <= '9' && c >= '0') { - num *= 10; - num += (c - '0'); - } else { - printf("array parse error.\n"); - return 0; - } - } - if (dim2) { - *dim2 = num; - } - - /* find second dim, if any. */ - bp = strchr(bp, '['); - if (!bp) { - return 1; /* at least we got the first dim. */ - } - num = 0; - while (++bp < name+len-1) { - const char c = *bp; - if (c == ']') { - break; - } - if (c <= '9' && c >= '0') { - num *= 10; - num += (c - '0'); - } else { - printf("array2 parse error.\n"); - return 1; - } - } - if (dim1) { - if (dim2) { - *dim1 = *dim2; - *dim2 = num; - } else { - *dim1 = num; - } - } - - return 1; -} - - -// ----------------------------------------------------- // -void bDNA::init(char *data, int len, bool swap) -{ - int *intPtr=0;short *shtPtr=0; - char *cp = 0;int dataLen =0;long nr=0; - intPtr = (int*)data; - - /* - SDNA (4 bytes) (magic number) - NAME (4 bytes) - <nr> (4 bytes) amount of names (int) - <string> - <string> - */ - - if (strncmp(data, "SDNA", 4)==0) - { - // skip ++ NAME - intPtr++; intPtr++; - } - - - - // Parse names - if (swap) dataLen = ChunkUtils::swapInt(*intPtr); - else dataLen = *intPtr; - intPtr++; - - cp = (char*)intPtr; - for (int i=0; i<dataLen; i++) - { - bNameInfo info; - info.m_name = cp; - info.m_isPointer = (info.m_name[0] == '*') || (info.m_name[1] == '*'); - name_is_array(info.m_name,&info.m_dim0,&info.m_dim1); - m_Names.push_back(info); - while (*cp)cp++; - cp++; - } - - - { - nr= (long)cp; - long mask=3; - nr= ((nr+3)&~3)-nr; - while (nr--) - { - cp++; - } - } - - - /* - TYPE (4 bytes) - <nr> amount of types (int) - <string> - <string> - */ - - intPtr = (int*)cp; - assert(strncmp(cp, "TYPE", 4)==0); intPtr++; - - if (swap) dataLen = ChunkUtils::swapInt(*intPtr); - else dataLen = *intPtr; - intPtr++; - - cp = (char*)intPtr; - for (int i=0; i<dataLen; i++) - { - mTypes.push_back(cp); - while (*cp)cp++; - cp++; - } - -{ - nr= (long)cp; - long mask=3; - nr= ((nr+3)&~3)-nr; - while (nr--) - { - cp++; - } - } - - - /* - TLEN (4 bytes) - <len> (short) the lengths of types - <len> - */ - - // Parse type lens - intPtr = (int*)cp; - assert(strncmp(cp, "TLEN", 4)==0); intPtr++; - - dataLen = (int)mTypes.size(); - - shtPtr = (short*)intPtr; - for (int i=0; i<dataLen; i++, shtPtr++) - { - if (swap) - shtPtr[0] = ChunkUtils::swapShort(shtPtr[0]); - mTlens.push_back(shtPtr[0]); - } - - if (dataLen & 1) shtPtr++; - - /* - STRC (4 bytes) - <nr> amount of structs (int) - <typenr> - <nr_of_elems> - <typenr> - <namenr> - <typenr> - <namenr> - */ - - intPtr = (int*)shtPtr; - cp = (char*)intPtr; - assert(strncmp(cp, "STRC", 4)==0); intPtr++; - - if (swap) dataLen = ChunkUtils::swapInt(*intPtr); - else dataLen = *intPtr; - intPtr++; - - - shtPtr = (short*)intPtr; - for (int i=0; i<dataLen; i++) - { - mStructs.push_back (shtPtr); - if (swap) - { - shtPtr[0]= ChunkUtils::swapShort(shtPtr[0]); - shtPtr[1]= ChunkUtils::swapShort(shtPtr[1]); - - int len = shtPtr[1]; - shtPtr+= 2; - - for (int a=0; a<len; a++, shtPtr+=2) - { - shtPtr[0]= ChunkUtils::swapShort(shtPtr[0]); - shtPtr[1]= ChunkUtils::swapShort(shtPtr[1]); - } - } - else - shtPtr+= (2*shtPtr[1])+2; - } - - - // build reverse lookups - for (int i=0; i<(int)mStructs.size(); i++) - { - short *strc = mStructs.at(i); - if (!mPtrLen && strcmp(mTypes[strc[0]],"ListBase")==0) - { - mPtrLen = mTlens[strc[0]]/2; - } - - mStructReverse.insert(strc[0], i); - mTypeLookup.insert(btHashString(mTypes[strc[0]]),i); - } -} - - -// ----------------------------------------------------- // -int bDNA::getArraySize(char* string) -{ - int ret = 1; - int len = strlen(string); - - - char* next = 0; - for (int i=0; i<len; i++) - { - char c = string[i]; - - if (c == '[') - next = &string[i+1]; - else if (c==']') - if (next) - ret *= atoi(next); - } - -// print (string << ' ' << ret); - return ret; -} - - -void bDNA::dumpTypeDefinitions() -{ - int i; - - int numTypes = mTypes.size(); - - for (i=0;i<numTypes;i++) - { - - } - - for (int i=0; i<(int)mStructs.size(); i++) - { - int totalBytes=0; - short *oldStruct = mStructs[i]; - - int oldLookup = getReverseType(oldStruct[0]); - if (oldLookup == -1) - { - mCMPFlags[i] = FDF_NONE; - continue; - } - - short* newStruct = mStructs[oldLookup]; - char* typeName = mTypes[newStruct[0]]; - printf("%3d: %s ",i,typeName); - - //char *name = mNames[oldStruct[1]]; - int len = oldStruct[1]; - printf(" (%d fields) ",len); - oldStruct+=2; - - printf("{"); - int j; - for (j=0; j<len; ++j,oldStruct+=2) { - const char* name = m_Names[oldStruct[1]].m_name; - printf("%s %s", mTypes[oldStruct[0]],name); - int elemNumBytes= 0; - int arrayDimensions = getArraySizeNew(oldStruct[1]); - - if (m_Names[oldStruct[1]].m_isPointer) - { - elemNumBytes = VOID_IS_8 ? 8 : 4; - } else - { - elemNumBytes = getLength(oldStruct[0]); - } - printf(" /* %d bytes */",elemNumBytes*arrayDimensions); - - if (j == len-1) { - printf(";}"); - } else { - printf("; "); - } - totalBytes+=elemNumBytes*arrayDimensions; - } - printf("\ntotalBytes=%d\n\n",totalBytes); - - } - - - -#if 0 - /* dump out display of types and their sizes */ - for (i=0; i<bf->types_count; ++i) { - /* if (!bf->types[i].is_struct)*/ - { - printf("%3d: sizeof(%s%s)=%d", - i, - bf->types[i].is_struct ? "struct " : "atomic ", - bf->types[i].name, bf->types[i].size); - if (bf->types[i].is_struct) { - int j; - printf(", %d fields: { ", bf->types[i].fieldtypes_count); - for (j=0; j<bf->types[i].fieldtypes_count; ++j) { - printf("%s %s", - bf->types[bf->types[i].fieldtypes[j]].name, - bf->names[bf->types[i].fieldnames[j]]); - if (j == bf->types[i].fieldtypes_count-1) { - printf(";}"); - } else { - printf("; "); - } - } - } - printf("\n\n"); - - } - } -#endif - -} - - - - -//eof - - diff --git a/gamekit/bDNA.h b/gamekit/bDNA.h deleted file mode 100644 index 8caff1e8b..000000000 --- a/gamekit/bDNA.h +++ /dev/null @@ -1,109 +0,0 @@ -/* -bParse -Copyright (c) 2006-2009 Charlie C & Erwin Coumans http://gamekit.googlecode.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef __BDNA_H__ -#define __BDNA_H__ - - -#include "bCommon.h" - -namespace bParse { - - struct bNameInfo - { - char* m_name; - bool m_isPointer; - int m_dim0; - int m_dim1; - }; - - class bDNA - { - public: - bDNA(); - ~bDNA(); - - void init(char *data, int len, bool swap=false); - - int getArraySize(char* str); - int getArraySizeNew(short name) - { - const bNameInfo& nameInfo = m_Names[name]; - return nameInfo.m_dim0*nameInfo.m_dim1; - } - int getElementSize(short type, short name) - { - const bNameInfo& nameInfo = m_Names[name]; - int size = nameInfo.m_isPointer ? mPtrLen*nameInfo.m_dim0*nameInfo.m_dim1 : mTlens[type]*nameInfo.m_dim0*nameInfo.m_dim1; - return size; - } - - int getNumNames() const - { - return m_Names.size(); - } - - char *getName(int ind); - char *getType(int ind); - short *getStruct(int ind); - short getLength(int ind); - int getReverseType(short type); - int getReverseType(const char *type); - - - int getNumStructs(); - - // - bool lessThan(bDNA* other); - - void initCmpFlags(bDNA *memDNA); - bool flagNotEqual(int dna_nr); - bool flagEqual(int dna_nr); - bool flagNone(int dna_nr); - - - int getPointerSize(); - - void dumpTypeDefinitions(); - - - private: - enum FileDNAFlags - { - FDF_NONE=0, - FDF_STRUCT_NEQU, - FDF_STRUCT_EQU - }; - - void initRecurseCmpFlags(int i); - - btAlignedObjectArray<int> mCMPFlags; - - btAlignedObjectArray<bNameInfo> m_Names; - btAlignedObjectArray<char*> mTypes; - btAlignedObjectArray<short*> mStructs; - btAlignedObjectArray<short> mTlens; - btHashMap<btHashInt, int> mStructReverse; - btHashMap<btHashString,int> mTypeLookup; - - int mPtrLen; - - - - }; -} - - -#endif//__BDNA_H__ diff --git a/gamekit/bDefines.h b/gamekit/bDefines.h deleted file mode 100644 index dc221ff9e..000000000 --- a/gamekit/bDefines.h +++ /dev/null @@ -1,140 +0,0 @@ -/* Copyright (C) 2006-2009 Charlie C & Erwin Coumans http://gamekit.googlecode.com -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -#ifndef __B_DEFINES_H__ -#define __B_DEFINES_H__ - - -// MISC defines, see BKE_global.h, BKE_utildefines.h -#define SIZEOFBLENDERHEADER 12 - - -// ------------------------------------------------------------ -#if defined(__sgi) || defined (__sparc) || defined (__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__BIG_ENDIAN__) -# define MAKE_ID(a,b,c,d) ( (int)(a)<<24 | (int)(b)<<16 | (c)<<8 | (d) ) -#else -# define MAKE_ID(a,b,c,d) ( (int)(d)<<24 | (int)(c)<<16 | (b)<<8 | (a) ) -#endif - - -// ------------------------------------------------------------ -#if defined(__sgi) || defined(__sparc) || defined(__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__BIG_ENDIAN__) -# define MAKE_ID2(c, d) ( (c)<<8 | (d) ) -# define MOST_SIG_BYTE 0 -# define BBIG_ENDIAN -#else -# define MAKE_ID2(c, d) ( (d)<<8 | (c) ) -# define MOST_SIG_BYTE 1 -# define BLITTLE_ENDIAN -#endif - -// ------------------------------------------------------------ -#define ID_SCE MAKE_ID2('S', 'C') -#define ID_LI MAKE_ID2('L', 'I') -#define ID_OB MAKE_ID2('O', 'B') -#define ID_ME MAKE_ID2('M', 'E') -#define ID_CU MAKE_ID2('C', 'U') -#define ID_MB MAKE_ID2('M', 'B') -#define ID_MA MAKE_ID2('M', 'A') -#define ID_TE MAKE_ID2('T', 'E') -#define ID_IM MAKE_ID2('I', 'M') -#define ID_IK MAKE_ID2('I', 'K') -#define ID_WV MAKE_ID2('W', 'V') -#define ID_LT MAKE_ID2('L', 'T') -#define ID_SE MAKE_ID2('S', 'E') -#define ID_LF MAKE_ID2('L', 'F') -#define ID_LA MAKE_ID2('L', 'A') -#define ID_CA MAKE_ID2('C', 'A') -#define ID_IP MAKE_ID2('I', 'P') -#define ID_KE MAKE_ID2('K', 'E') -#define ID_WO MAKE_ID2('W', 'O') -#define ID_SCR MAKE_ID2('S', 'R') -#define ID_VF MAKE_ID2('V', 'F') -#define ID_TXT MAKE_ID2('T', 'X') -#define ID_SO MAKE_ID2('S', 'O') -#define ID_SAMPLE MAKE_ID2('S', 'A') -#define ID_GR MAKE_ID2('G', 'R') -#define ID_ID MAKE_ID2('I', 'D') -#define ID_AR MAKE_ID2('A', 'R') -#define ID_AC MAKE_ID2('A', 'C') -#define ID_SCRIPT MAKE_ID2('P', 'Y') -#define ID_FLUIDSIM MAKE_ID2('F', 'S') -#define ID_NT MAKE_ID2('N', 'T') -#define ID_BR MAKE_ID2('B', 'R') - - -#define ID_SEQ MAKE_ID2('S', 'Q') -#define ID_CO MAKE_ID2('C', 'O') -#define ID_PO MAKE_ID2('A', 'C') -#define ID_NLA MAKE_ID2('N', 'L') - -#define ID_VS MAKE_ID2('V', 'S') -#define ID_VN MAKE_ID2('V', 'N') - - -// ------------------------------------------------------------ -#define FORM MAKE_ID('F','O','R','M') -#define DDG1 MAKE_ID('3','D','G','1') -#define DDG2 MAKE_ID('3','D','G','2') -#define DDG3 MAKE_ID('3','D','G','3') -#define DDG4 MAKE_ID('3','D','G','4') -#define GOUR MAKE_ID('G','O','U','R') -#define BLEN MAKE_ID('B','L','E','N') -#define DER_ MAKE_ID('D','E','R','_') -#define V100 MAKE_ID('V','1','0','0') -#define DATA MAKE_ID('D','A','T','A') -#define GLOB MAKE_ID('G','L','O','B') -#define IMAG MAKE_ID('I','M','A','G') -#define TEST MAKE_ID('T','E','S','T') -#define USER MAKE_ID('U','S','E','R') - - -// ------------------------------------------------------------ -#define DNA1 MAKE_ID('D','N','A','1') -#define REND MAKE_ID('R','E','N','D') -#define ENDB MAKE_ID('E','N','D','B') -#define NAME MAKE_ID('N','A','M','E') -#define SDNA MAKE_ID('S','D','N','A') -#define TYPE MAKE_ID('T','Y','P','E') -#define TLEN MAKE_ID('T','L','E','N') -#define STRC MAKE_ID('S','T','R','C') - - -// ------------------------------------------------------------ -#define SWITCH_INT(a) { \ - char s_i, *p_i; \ - p_i= (char *)&(a); \ - s_i=p_i[0]; p_i[0]=p_i[3]; p_i[3]=s_i; \ - s_i=p_i[1]; p_i[1]=p_i[2]; p_i[2]=s_i; } - -// ------------------------------------------------------------ -#define SWITCH_SHORT(a) { \ - char s_i, *p_i; \ - p_i= (char *)&(a); \ - s_i=p_i[0]; p_i[0]=p_i[1]; p_i[1]=s_i; } - -// ------------------------------------------------------------ -#define SWITCH_LONGINT(a) { \ - char s_i, *p_i; \ - p_i= (char *)&(a); \ - s_i=p_i[0]; p_i[0]=p_i[7]; p_i[7]=s_i; \ - s_i=p_i[1]; p_i[1]=p_i[6]; p_i[6]=s_i; \ - s_i=p_i[2]; p_i[2]=p_i[5]; p_i[5]=s_i; \ - s_i=p_i[3]; p_i[3]=p_i[4]; p_i[4]=s_i; } - -#endif//__B_DEFINES_H__ diff --git a/gamekit/bFile.cpp b/gamekit/bFile.cpp deleted file mode 100644 index e589e61e3..000000000 --- a/gamekit/bFile.cpp +++ /dev/null @@ -1,961 +0,0 @@ -/* -bParse -Copyright (c) 2006-2009 Charlie C & Erwin Coumans http://gamekit.googlecode.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ -#include "bFile.h" -#include "bCommon.h" -#include "bMain.h" -#include "bChunk.h" -#include "bDNA.h" -#include <math.h> -#include <string.h> -#include <stdlib.h> -#define SIZEOFBLENDERHEADER 12 - -using namespace bParse; - - -int numallocs = 0; - -// ----------------------------------------------------- // -bFile::bFile(const char *filename, const char headerString[7]) - : mOwnsBuffer(true), - mFileBuffer(0), - mFileLen(0), - mVersion(0), - mDataStart(0), - mFileDNA(0), - mMemoryDNA(0), - mFlags(FD_INVALID) -{ - for (int i=0;i<7;i++) - { - m_headerString[i] = headerString[i]; - } - - FILE *fp = fopen(filename, "rb"); - if (fp) - { - fseek(fp, 0L, SEEK_END); - mFileLen = ftell(fp); - fseek(fp, 0L, SEEK_SET); - - mFileBuffer = (char*)malloc(mFileLen+1); - fread(mFileBuffer, mFileLen, 1, fp); - - fclose(fp); - - // - parseHeader(); - - } -} - -// ----------------------------------------------------- // -bFile::bFile( char *memoryBuffer, int len, const char headerString[7]) -: mOwnsBuffer(false), - mFileBuffer(0), - mFileLen(0), - mVersion(0), - mDataStart(0), - mFileDNA(0), - mMemoryDNA(0), - mFlags(FD_INVALID) -{ - for (int i=0;i<7;i++) - { - m_headerString[i] = headerString[i]; - } - mFileBuffer = memoryBuffer; - mFileLen = len; - - parseHeader(); - -} - - -// ----------------------------------------------------- // -bFile::~bFile() -{ - if (mOwnsBuffer && mFileBuffer) - { - free(mFileBuffer); - mFileBuffer = 0; - } - - - delete mMemoryDNA; - delete mFileDNA; -} - - - - - -// ----------------------------------------------------- // -void bFile::parseHeader() -{ - char *blenderBuf = mFileBuffer; - char header[SIZEOFBLENDERHEADER+1] ; - memcpy(header, blenderBuf, SIZEOFBLENDERHEADER); - header[SIZEOFBLENDERHEADER]='\0'; - - if (strncmp(header, m_headerString, 7)!=0) - { - printf ("Invalid blend file..."); - return; - } - - char *ver = header+9; - mVersion = atoi(ver); - if (mVersion <= 241) - printf ("Warning, %d not fully tested : <= 242\n", mVersion); - - - int endian= 1; - endian= ((char*)&endian)[0]; - - // swap ptr sizes... - if (header[7]=='-') - { - mFlags |= FD_FILE_64; - if (!VOID_IS_8) - mFlags |= FD_BITS_VARIES; - } - else if (VOID_IS_8) mFlags |= FD_BITS_VARIES; - - // swap endian... - if (header[8]=='V' && endian ==1) - mFlags |= FD_ENDIAN_SWAP; - else - if (endian==0) - mFlags |= FD_ENDIAN_SWAP; - - - printf (header); - printf ("\nsizeof(void*) == %d\n",sizeof(void*)); - const char* endStr = ((mFlags & FD_ENDIAN_SWAP)!=0) ? "yes" : "no"; - printf ("Swapping endian? %s\n",endStr); - const char* bitStr = (mFlags &FD_FILE_64)!=0 ? "64 bit" : "32bit"; - printf ("File format is %s\n",bitStr); - const char* varStr = (mFlags & FD_BITS_VARIES)!=0 ? "yes" : "no"; - printf ("Varing pointer sizes? %s\n",varStr); - - - mFlags |= FD_OK; -} - -// ----------------------------------------------------- // -bool bFile::ok() -{ - return (mFlags &FD_OK)!=0; -} - -// ----------------------------------------------------- // -void bFile::parseInternal(bool verboseDumpAllTypes, char* memDna,int memDnaLength) -{ - if ( (mFlags &FD_OK) ==0) - return; - - char *blenderData = mFileBuffer; - int sdnaPos=0; - - char *tempBuffer = blenderData; - for (int i=0; i<mFileLen; i++) - { - // looking for the data's starting position - // and the start of SDNA decls - - if (!mDataStart && strncmp(tempBuffer, "REND", 4)==0) - mDataStart = i; - if (!sdnaPos && strncmp(tempBuffer, "SDNA", 4)==0) - sdnaPos = i; - - if (mDataStart && sdnaPos) break; - tempBuffer++; - } - - mFileDNA = new bDNA(); - mFileDNA->init(blenderData+sdnaPos, mFileLen-sdnaPos, (mFlags & FD_ENDIAN_SWAP)!=0); - - if (verboseDumpAllTypes) - { - mFileDNA->dumpTypeDefinitions(); - } - - mMemoryDNA = new bDNA(); - mMemoryDNA->init(memDna,memDnaLength); - - - - - ///@todo we need a better version check, add version/sub version info from FileGlobal into memory DNA/header files - if (mMemoryDNA->getNumNames() != mFileDNA->getNumNames()) - { - mFlags |= FD_VERSION_VARIES; - printf ("Warning, file DNA is different than built in, performance is reduced. Best to re-export file with a matching version/platform"); - } - - // as long as it kept up to date it will be ok!! - if (mMemoryDNA->lessThan(mFileDNA)) - { - printf ("Warning, file DNA is newer than built in."); - } - - mFileDNA->initCmpFlags(mMemoryDNA); - - parseData(); - - resolvePointers(); - - updateOldPointers(); - - printf("numAllocs = %d\n",numallocs); -} - - - -// ----------------------------------------------------- // -void bFile::swap(char *head, bChunkInd& dataChunk) -{ - char *data = head; - short *strc = mFileDNA->getStruct(dataChunk.dna_nr); - int len = mFileDNA->getLength(strc[0]); - - for (int i=0; i<dataChunk.nr; i++) - { - swapStruct(dataChunk.dna_nr, data); - data+=len; - } -} - - - -// ----------------------------------------------------- // -char* bFile::readStruct(char *head, bChunkInd& dataChunk) -{ - if (mFlags & FD_ENDIAN_SWAP) - swap(head, dataChunk); - - - - if (!mFileDNA->flagEqual(dataChunk.dna_nr)) - { - // Ouch! need to rebuild the struct - short *oldStruct,*curStruct; - char *oldType, *newType; - int oldLen, curLen, reverseOld; - - - oldStruct = mFileDNA->getStruct(dataChunk.dna_nr); - oldType = mFileDNA->getType(oldStruct[0]); - oldLen = mFileDNA->getLength(oldStruct[0]); - - ///don't try to convert Link block data, just memcpy it. Other data can be converted. - if (strcmp("Link",oldType)!=0) - { - reverseOld = mMemoryDNA->getReverseType(oldType); - - if ((reverseOld!=-1)) - { - // make sure it's here - //assert(reverseOld!= -1 && "getReverseType() returned -1, struct required!"); - - // - curStruct = mMemoryDNA->getStruct(reverseOld); - newType = mMemoryDNA->getType(curStruct[0]); - curLen = mMemoryDNA->getLength(curStruct[0]); - - - - // make sure it's the same - assert((strcmp(oldType, newType)==0) && "internal error, struct mismatch!"); - - - numallocs++; - // numBlocks * length - char *dataAlloc = new char[(dataChunk.nr*curLen)+1]; - memset(dataAlloc, 0, (dataChunk.nr*curLen)+1); - - // track allocated - addDataBlock(dataAlloc); - - char *cur = dataAlloc; - char *old = head; - for (int block=0; block<dataChunk.nr; block++) - { - bool fixupPointers = true; - parseStruct(cur, old, dataChunk.dna_nr, reverseOld, fixupPointers); - mLibPointers.insert(old,(bStructHandle*)cur); - - cur += curLen; - old += oldLen; - } - return dataAlloc; - } - } else - { - //printf("Link found\n"); - } - } else - { -//#define DEBUG_EQUAL_STRUCTS -#ifdef DEBUG_EQUAL_STRUCTS - short *oldStruct; - char *oldType; - oldStruct = mFileDNA->getStruct(dataChunk.dna_nr); - oldType = mFileDNA->getType(oldStruct[0]); - printf("%s equal structure, just memcpy\n",oldType); -#endif // - } - - - char *dataAlloc = new char[(dataChunk.len)+1]; - memset(dataAlloc, 0, dataChunk.len+1); - - - // track allocated - addDataBlock(dataAlloc); - - memcpy(dataAlloc, head, dataChunk.len); - return dataAlloc; - -} - - -// ----------------------------------------------------- // -void bFile::parseStruct(char *strcPtr, char *dtPtr, int old_dna, int new_dna, bool fixupPointers) -{ - if (old_dna == -1) return; - if (new_dna == -1) return; - - //disable this, because we need to fixup pointers/ListBase - if (0)//mFileDNA->flagEqual(old_dna)) - { - short *strc = mFileDNA->getStruct(old_dna); - int len = mFileDNA->getLength(strc[0]); - - memcpy(strcPtr, dtPtr, len); - return; - } - - // Ok, now build the struct - char *memType, *memName, *cpc, *cpo; - short *fileStruct, *filePtrOld, *memoryStruct, *firstStruct; - int elementLength, size, revType, old_nr, new_nr, fpLen; - short firstStructType; - - - // File to memory lookup - memoryStruct = mMemoryDNA->getStruct(new_dna); - fileStruct = mFileDNA->getStruct(old_dna); - firstStruct = fileStruct; - - - filePtrOld = fileStruct; - firstStructType = mMemoryDNA->getStruct(0)[0]; - - // Get number of elements - elementLength = memoryStruct[1]; - memoryStruct+=2; - - cpc = strcPtr; cpo = 0; - for (int ele=0; ele<elementLength; ele++, memoryStruct+=2) - { - memType = mMemoryDNA->getType(memoryStruct[0]); - memName = mMemoryDNA->getName(memoryStruct[1]); - - - size = mMemoryDNA->getElementSize(memoryStruct[0], memoryStruct[1]); - revType = mMemoryDNA->getReverseType(memoryStruct[0]); - - if (revType != -1 && memoryStruct[0]>=firstStructType && memName[0] != '*') - { - cpo = getFileElement(firstStruct, memName, memType, dtPtr, &filePtrOld); - if (cpo) - { - old_nr = mFileDNA->getReverseType(memType); - new_nr = revType; - fpLen = mFileDNA->getElementSize(filePtrOld[0], filePtrOld[1]); - - - parseStruct(cpc, cpo, old_nr, new_nr,fixupPointers); - cpc+=size; - cpo+=fpLen; - } - else - cpc+=size; - } - else - { - getMatchingFileDNA(fileStruct, memName, memType, cpc, dtPtr,fixupPointers); - cpc+=size; - } - - } -} - -// ----------------------------------------------------- // -static void getElement(int arrayLen, const char *cur, const char *old, char *oldPtr, char *curData) -{ -#define getEle(value, current, type, cast, size, ptr)\ - if (strcmp(current, type)==0)\ - {\ - value = (*(cast*)ptr);\ - ptr += size;\ - } - -#define setEle(value, current, type, cast, size, ptr)\ - if (strcmp(current, type)==0)\ - {\ - (*(cast*)ptr) = value;\ - ptr += size;\ - } - double value = 0.0; - - for (int i=0; i<arrayLen; i++) - { - getEle(value, old, "char", char, sizeof(char), oldPtr); - setEle(value, cur, "char", char, sizeof(char), curData); - getEle(value, old, "short", short, sizeof(short), oldPtr); - setEle(value, cur, "short", short, sizeof(short), curData); - getEle(value, old, "ushort", unsigned short, sizeof(unsigned short), oldPtr); - setEle(value, cur, "ushort", unsigned short, sizeof(unsigned short), curData); - getEle(value, old, "int", int, sizeof(int), oldPtr); - setEle(value, cur, "int", int, sizeof(int), curData); - getEle(value, old, "long", int, sizeof(int), oldPtr); - setEle(value, cur, "long", int, sizeof(int), curData); - getEle(value, old, "float", float, sizeof(float), oldPtr); - setEle(value, cur, "float", float, sizeof(float), curData); - getEle(value, old, "double", double, sizeof(double), oldPtr); - setEle(value, cur, "double", double, sizeof(double), curData); - } -} - - -// ----------------------------------------------------- // -void bFile::swapData(char *data, short type, int arraySize) -{ - if (mFlags &FD_ENDIAN_SWAP) - { - if (type == 2 || type == 3) - { - short *sp = (short*)data; - for (int i=0; i<arraySize; i++) - { - sp[0] = ChunkUtils::swapShort(sp[0]); - sp++; - } - } - if (type>3 && type <8) - { - char c; - char *cp = data; - for (int i=0; i<arraySize; i++) - { - c = cp[0]; - cp[0] = cp[3]; - cp[3] = c; - c = cp[1]; - cp[1] = cp[2]; - cp[2] = c; - cp+=4; - } - } - } -} - - -void bFile::swapPtr(char *dst, char *src) -{ - int ptrFile = mFileDNA->getPointerSize(); - int ptrMem = mMemoryDNA->getPointerSize(); - - if (!src && !dst) - return; - - if (ptrFile == ptrMem) - memcpy(dst, src, ptrMem); - else if (ptrMem==4 && ptrFile==8) - { - long64 longValue = *((long64*)src); - *((int*)dst) = (int)(longValue>>3); - } - else if (ptrMem==8 && ptrFile==4) - *((long64*)dst)= *((int*)src); - else - { - printf ("%d %d\n", ptrFile,ptrMem); - assert(0 && "Invalid pointer len"); - } -} - -// ----------------------------------------------------- // -void bFile::getMatchingFileDNA(short* dna_addr, const char* lookupName, const char* lookupType, char *strcData, char *data, bool fixupPointers) -{ - // find the matching memory dna data - // to the file being loaded. Fill the - // memory with the file data... - - int len = dna_addr[1]; - dna_addr+=2; - - for (int i=0; i<len; i++, dna_addr+=2) - { - const char* type = mFileDNA->getType(dna_addr[0]); - const char* name = mFileDNA->getName(dna_addr[1]); - - int eleLen = mFileDNA->getElementSize(dna_addr[0], dna_addr[1]); - - - if (strcmp(lookupName, name)==0) - { - //int arrayLenold = mFileDNA->getArraySize((char*)name.c_str()); - int arrayLen = mFileDNA->getArraySizeNew(dna_addr[1]); - //assert(arrayLenold == arrayLen); - - if (name[0] == '*') - { - // cast pointers - int ptrFile = mFileDNA->getPointerSize(); - int ptrMem = mMemoryDNA->getPointerSize(); - - swapPtr(strcData, data); - - if (fixupPointers) - { - if (arrayLen > 1) - { - void **sarray = (void**)strcData; - void **darray = (void**)data; - - for (int a=0; a<arrayLen; a++) - { - swapPtr((char*)&sarray[a], (char*)&darray[a]); - m_pointerFixupArray.push_back((char*)&sarray[a]); - } - } - else - { - if (name[1] == '*') - m_pointerPtrFixupArray.push_back(strcData); - else - m_pointerFixupArray.push_back(strcData); - } - } - else - { -// printf("skipped %s %s : %x\n",type.c_str(),name.c_str(),strcData); - } - - } - - else if (strcmp(type, lookupType)==0) - memcpy(strcData, data, eleLen); - else - getElement(arrayLen, lookupType, type, data, strcData); - - // -- - return; - } - data+=eleLen; - } -} - - -// ----------------------------------------------------- // -char* bFile::getFileElement(short *firstStruct, char *lookupName, char *lookupType, char *data, short **foundPos) -{ - short *old = firstStruct;//mFileDNA->getStruct(old_nr); - int elementLength = old[1]; - old+=2; - - for (int i=0; i<elementLength; i++, old+=2) - { - char* type = mFileDNA->getType(old[0]); - char* name = mFileDNA->getName(old[1]); - int len = mFileDNA->getElementSize(old[0], old[1]); - - if (strcmp(lookupName, name)==0) - { - if (strcmp(type, lookupType)==0) - { - if (foundPos) - *foundPos = old; - return data; - } - return 0; - } - data+=len; - } - return 0; -} - - -// ----------------------------------------------------- // -void bFile::swapStruct(int dna_nr, char *data) -{ - if (dna_nr == -1) return; - - short *strc = mFileDNA->getStruct(dna_nr); - short *firstStrc = strc; - - int elementLen= strc[1]; - strc+=2; - - short first = mFileDNA->getStruct(0)[0]; - - char *buf = data; - for (int i=0; i<elementLen; i++, strc+=2) - { - char *type = mFileDNA->getType(strc[0]); - char *name = mFileDNA->getName(strc[1]); - - int size = mFileDNA->getElementSize(strc[0], strc[1]); - if (strc[0] >= first && name[0]!='*') - { - int old_nr = mFileDNA->getReverseType(type); - swapStruct(old_nr,buf); - } - else - { - //int arrayLenOld = mFileDNA->getArraySize(name); - int arrayLen = mFileDNA->getArraySizeNew(strc[1]); - //assert(arrayLenOld == arrayLen); - - swapData(buf, strc[0], arrayLen); - } - buf+=size; - } -} - - - -void bFile::resolvePointersMismatch() -{ -// printf("resolvePointersStructMismatch\n"); - - int i; - - for (i=0;i< m_pointerFixupArray.size();i++) - { - char* cur = m_pointerFixupArray.at(i); - void** ptrptr = (void**) cur; - void* ptr = *ptrptr; - ptr = findLibPointer(ptr); - if (ptr) - { - //printf("Fixup pointer!\n"); - *(ptrptr) = ptr; - } else - { -// printf("pointer not found: %x\n",cur); - } - } - - for (i=0;i< m_pointerPtrFixupArray.size();i++) - { - char* cur= m_pointerPtrFixupArray.at(i); - void** ptrptr = (void**)cur; - void *ptr = findLibPointer(*ptrptr); - if (ptr) - { - (*ptrptr) = ptr; - - void **array= (void**)(*(ptrptr)); - - int n=0, n2=0; - int swapoffs = mFileDNA->getPointerSize() > mMemoryDNA->getPointerSize() ? 2 : 1; - void *np = array[n]; - while(np) - { - if (mFlags & FD_BITS_VARIES) - swapPtr((char*)&array[n], (char*)&array[n2]); - - np = findLibPointer(array[n]); - if (np) - array[n] = np; - ++n; - n2 += swapoffs; - } - } - } -} - - -///this loop only works fine if the Blender DNA structure of the file matches the headerfiles -void bFile::resolvePointersChunk(const bChunkInd& dataChunk) -{ - bParse::bDNA* fileDna = mFileDNA ? mFileDNA : mMemoryDNA; - - short int* oldStruct = fileDna->getStruct(dataChunk.dna_nr); - short oldLen = fileDna->getLength(oldStruct[0]); - char* structType = fileDna->getType(oldStruct[0]); - - char* cur = (char*)findLibPointer(dataChunk.oldPtr); - for (int block=0; block<dataChunk.nr; block++) - { - resolvePointersStructRecursive(cur,dataChunk.dna_nr); - cur += oldLen; - } -} - - -void bFile::resolvePointersStructRecursive(char *strcPtr, int dna_nr) -{ - - bParse::bDNA* fileDna = mFileDNA ? mFileDNA : mMemoryDNA; - - char* memType; - char* memName; - short firstStructType = fileDna->getStruct(0)[0]; - - - char* elemPtr= strcPtr; - - short int* oldStruct = fileDna->getStruct(dna_nr); - - int elementLength = oldStruct[1]; - oldStruct+=2; - - - for (int ele=0; ele<elementLength; ele++, oldStruct+=2) - { - - memType = fileDna->getType(oldStruct[0]); - memName = fileDna->getName(oldStruct[1]); - //printf("%s %s\n",memType,memName); - - int arrayLen = fileDna->getArraySizeNew(oldStruct[1]); - if (memName[0] == '*') - { - if (arrayLen > 1) - { - void **array= (void**)elemPtr; - for (int a=0; a<arrayLen; a++) - array[a] = findLibPointer(array[a]); - } - else - { - void** ptrptr = (void**) elemPtr; - void* ptr = *ptrptr; - ptr = findLibPointer(ptr); - if (ptr) - { - // printf("Fixup pointer at 0x%x from 0x%x to 0x%x!\n",ptrptr,*ptrptr,ptr); - *(ptrptr) = ptr; - if (memName[1] == '*' && ptrptr && *ptrptr) - { - // This will only work if the given **array is continuous - void **array= (void**)*(ptrptr); - void *np= array[0]; - int n=0; - while (np) - { - np= findLibPointer(array[n]); - if (np) array[n]= np; - n++; - } - } - } else - { - // printf("Cannot fixup pointer at 0x%x from 0x%x to 0x%x!\n",ptrptr,*ptrptr,ptr); - } - } - } else - { - int revType = fileDna->getReverseType(oldStruct[0]); - if (oldStruct[0]>=firstStructType) //revType != -1 && - { - resolvePointersStructRecursive(elemPtr,revType); - } - } - - int size = fileDna->getElementSize(oldStruct[0], oldStruct[1]); - elemPtr+=size; - - } -} - - -///Resolve pointers replaces the original pointers in structures, and linked lists by the new in-memory structures -void bFile::resolvePointers() -{ - bParse::bDNA* fileDna = mFileDNA ? mFileDNA : mMemoryDNA; - - printf("resolvePointers start\n"); - char *dataPtr = mFileBuffer+mDataStart; - - if (1) //mFlags & (FD_BITS_VARIES | FD_VERSION_VARIES)) - { - resolvePointersMismatch(); - } - - { - for (int i=0;i<m_chunks.size();i++) - { - const bChunkInd& dataChunk = m_chunks.at(i); - - if (!mFileDNA || fileDna->flagEqual(dataChunk.dna_nr)) - { - //dataChunk.len - short int* oldStruct = fileDna->getStruct(dataChunk.dna_nr); - char* oldType = fileDna->getType(oldStruct[0]); - - //printf("------------------------------------------"); - //printf("Struct %s\n",oldType); - - resolvePointersChunk(dataChunk); - } else - { - //printf("skipping mStruct\n"); - } - } - } - - printf("resolvePointers end\n"); -} - - -// ----------------------------------------------------- // -void* bFile::findLibPointer(void *ptr) -{ - - bStructHandle** ptrptr = getLibPointers().find(ptr); - if (ptrptr) - return *ptrptr; - return 0; -} - - -void bFile::updateOldPointers() -{ - int i; - - for (i=0;i<m_chunks.size();i++) - { - bChunkInd& dataChunk = m_chunks[i]; - dataChunk.oldPtr = findLibPointer(dataChunk.oldPtr); - } -} -void bFile::dumpChunks(bParse::bDNA* dna) -{ - int i; - - for (i=0;i<m_chunks.size();i++) - { - bChunkInd& dataChunk = m_chunks[i]; - char* codeptr = (char*)&dataChunk.code; - char codestr[5] = {codeptr[0],codeptr[1],codeptr[2],codeptr[3],0}; - - short* newStruct = dna->getStruct(dataChunk.dna_nr); - char* typeName = dna->getType(newStruct[0]); - printf("%3d: %s ",i,typeName); - - printf("code=%s ",codestr); - - printf("ptr=%p ",dataChunk.oldPtr); - printf("len=%d ",dataChunk.len); - printf("nr=%d ",dataChunk.nr); - if (dataChunk.nr!=1) - { - printf("not 1\n"); - } - printf("\n"); - - - - - } - -#if 0 - IDFinderData ifd; - ifd.success = 0; - ifd.IDname = NULL; - ifd.just_print_it = 1; - for (i=0; i<bf->m_blocks.size(); ++i) - { - BlendBlock* bb = bf->m_blocks[i]; - printf("tag='%s'\tptr=%p\ttype=%s\t[%4d]", bb->tag, bb,bf->types[bb->type_index].name,bb->m_array_entries_.size()); - block_ID_finder(bb, bf, &ifd); - printf("\n"); - } -#endif - -} - - -void bFile::writeChunks(FILE* fp, bool fixupPointers) -{ - bParse::bDNA* fileDna = mFileDNA ? mFileDNA : mMemoryDNA; - - for (int i=0;i<m_chunks.size();i++) - { - bChunkInd& dataChunk = m_chunks.at(i); - - // Ouch! need to rebuild the struct - short *oldStruct,*curStruct; - char *oldType, *newType; - int oldLen, curLen, reverseOld; - - oldStruct = fileDna->getStruct(dataChunk.dna_nr); - oldType = fileDna->getType(oldStruct[0]); - oldLen = fileDna->getLength(oldStruct[0]); - ///don't try to convert Link block data, just memcpy it. Other data can be converted. - reverseOld = mMemoryDNA->getReverseType(oldType); - - - if ((reverseOld!=-1)) - { - // make sure it's here - //assert(reverseOld!= -1 && "getReverseType() returned -1, struct required!"); - // - curStruct = mMemoryDNA->getStruct(reverseOld); - newType = mMemoryDNA->getType(curStruct[0]); - // make sure it's the same - assert((strcmp(oldType, newType)==0) && "internal error, struct mismatch!"); - - - curLen = mMemoryDNA->getLength(curStruct[0]); - dataChunk.dna_nr = reverseOld; - if (strcmp("Link",oldType)!=0) - { - dataChunk.len = curLen * dataChunk.nr; - } else - { -// printf("keep length of link = %d\n",dataChunk.len); - } - - //write the structure header - fwrite(&dataChunk,sizeof(bChunkInd),1,fp); - - - - short int* curStruct1 = mMemoryDNA->getStruct(dataChunk.dna_nr); - assert(curStruct1 == curStruct); - - char* cur = fixupPointers ? (char*)findLibPointer(dataChunk.oldPtr) : (char*)dataChunk.oldPtr; - - //write the actual contents of the structure(s) - fwrite(cur,dataChunk.len,1,fp); - } else - { - printf("serious error, struct mismatch: don't write\n"); - } - } - -} - - -//eof - diff --git a/gamekit/bFile.h b/gamekit/bFile.h deleted file mode 100644 index 2515d4b7c..000000000 --- a/gamekit/bFile.h +++ /dev/null @@ -1,144 +0,0 @@ -/* -bParse -Copyright (c) 2006-2009 Charlie C & Erwin Coumans http://gamekit.googlecode.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef __BFILE_H__ -#define __BFILE_H__ - -#include "bCommon.h" -#include "bChunk.h" -#include <stdio.h> - -namespace bParse { - - // ----------------------------------------------------- // - enum bFileFlags - { - FD_INVALID =0, - FD_OK =1, - FD_VOID_IS_8 =2, - FD_ENDIAN_SWAP =4, - FD_FILE_64 =8, - FD_BITS_VARIES =16, - FD_VERSION_VARIES = 32 - }; - - - // ----------------------------------------------------- // - class bFile - { - protected: - - char m_headerString[7]; - - bool mOwnsBuffer; - char* mFileBuffer; - int mFileLen; - int mVersion; - - - bPtrMap mLibPointers; - - int mDataStart; - bDNA* mFileDNA; - bDNA* mMemoryDNA; - - btAlignedObjectArray<char*> m_pointerFixupArray; - btAlignedObjectArray<char*> m_pointerPtrFixupArray; - - btAlignedObjectArray<bChunkInd> m_chunks; - - // - - bPtrMap mDataPointers; - - - - int mFlags; - - virtual void parseHeader(); - - virtual void parseData() = 0; - - void resolvePointersMismatch(); - void resolvePointersChunk(const bChunkInd& dataChunk); - - void resolvePointersStructRecursive(char *strcPtr, int old_dna); - void swapPtr(char *dst, char *src); - - void parseStruct(char *strcPtr, char *dtPtr, int old_dna, int new_dna, bool fixupPointers); - void getMatchingFileDNA(short* old, const char* lookupName, const char* lookupType, char *strcData, char *data, bool fixupPointers); - char* getFileElement(short *firstStruct, char *lookupName, char *lookupType, char *data, short **foundPos); - - - void swap(char *head, class bChunkInd& ch); - - void swapData(char *data, short type, int arraySize); - void swapStruct(int dna_nr, char *data); - - - - - char* readStruct(char *head, class bChunkInd& chunk); - char *getAsString(int code); - - void parseInternal(bool verboseDumpAllTypes, char* memDna,int memDnaLength); - - public: - bFile(const char *filename, const char headerString[7]); - - //todo: make memoryBuffer const char - //bFile( const char *memoryBuffer, int len); - bFile( char *memoryBuffer, int len, const char headerString[7]); - ~bFile(); - - bDNA* getFileDNA() - { - return mFileDNA; - } - - virtual void addDataBlock(char* dataBlock) = 0; - - int getFlags() const - { - return mFlags; - } - - bPtrMap& getLibPointers() - { - return mLibPointers; - } - - void* findLibPointer(void *ptr); - - bool ok(); - - virtual void parse(bool verboseDumpAllTypes) = 0; - - virtual int write(const char* fileName, bool fixupPointers=false) = 0; - - virtual void writeChunks(FILE* fp, bool fixupPointers ); - - virtual void writeDNA(FILE* fp) = 0; - - void updateOldPointers(); - void resolvePointers(); - - void dumpChunks(bDNA* dna); - - }; -} - - -#endif//__BFILE_H__ diff --git a/gamekit/bMain.cpp b/gamekit/bMain.cpp deleted file mode 100644 index 01b210c5a..000000000 --- a/gamekit/bMain.cpp +++ /dev/null @@ -1,392 +0,0 @@ -/* -bParse -Copyright (c) 2006-2009 Charlie C & Erwin Coumans http://gamekit.googlecode.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "bMain.h" -#include "bBlenderFile.h" -#include "bDefines.h" -#include "bChunk.h" -#include "bDNA.h" - -using namespace bParse; - - -// ----------------------------------------------------- // -bMain::bMain(bBlenderFile *filePtr, const char *baseName, int fileVersion) - : mFP(filePtr), - mVersion(fileVersion), - mName(baseName) -{ - mData.insert(ID_SCE,bListBasePtr()); - mData.insert(ID_LI,bListBasePtr()); - mData.insert(ID_OB,bListBasePtr()); - mData.insert(ID_ME,bListBasePtr()); - mData.insert(ID_CU,bListBasePtr()); - mData.insert(ID_MB,bListBasePtr()); - mData.insert(ID_MA,bListBasePtr()); - mData.insert(ID_TE,bListBasePtr()); - mData.insert(ID_IM,bListBasePtr()); - mData.insert(ID_WV,bListBasePtr()); - mData.insert(ID_LT,bListBasePtr()); - mData.insert(ID_LA,bListBasePtr()); - mData.insert(ID_CA,bListBasePtr()); - mData.insert(ID_IP,bListBasePtr()); - mData.insert(ID_KE,bListBasePtr()); - mData.insert(ID_WO,bListBasePtr()); - mData.insert(ID_SCR,bListBasePtr()); - mData.insert(ID_VF,bListBasePtr()); - mData.insert(ID_TXT,bListBasePtr()); - mData.insert(ID_SO,bListBasePtr()); - mData.insert(ID_GR,bListBasePtr()); - mData.insert(ID_AR,bListBasePtr()); - mData.insert(ID_AC,bListBasePtr()); - mData.insert(ID_NT,bListBasePtr()); - mData.insert(ID_BR,bListBasePtr()); - mData.insert(ID_SCRIPT, bListBasePtr()); -} - - -// ----------------------------------------------------- // -bMain::~bMain() -{ - // allocated data blocks! - - int sz = mPool.size(); - for (int i=0;i<sz;i++) - { - delete [] mPool[i]; - } -} - -// ----------------------------------------------------- // -int bMain::getVersion() -{ - return mVersion; -} - -// ----------------------------------------------------- // -const char *bMain::getName() -{ - return mName; -} - -// ----------------------------------------------------- // -void bMain::addDatablock(void *allocated) -{ - assert(allocated); - mPool.push_back((bStructHandle*)allocated); -} - - - - -// ------------------------------------------------------------// -void bMain::linkList(void *listBasePtr) -{ - - struct ListBase // local Blender::ListBase - { - void *first; - void *last; - }; - - struct Link // local Blender::Link - { - void *next; - void *prev; - }; - - - ListBase *base = (ListBase*)listBasePtr; - - if (!base || !base->first) - return; - - base->first = mFP->findLibPointer(base->first); - if (!base->first) - { - base->last = 0; - return; - } - - void *prev = 0; - Link *l = (Link*)base->first; - while (l) - { - l->next = mFP->findLibPointer(l->next); - l->prev = l->next; - prev = l->next; - l = (Link*)l->next; - } -} - -// ------------------------------------------------------------// -bListBasePtr* bMain::getListBasePtr(int listBaseCode) -{ - bListBasePtr *ptr = _findCode(listBaseCode); - if (!ptr) - return 0; - return ptr; -} - -// ------------------------------------------------------------// -bListBasePtr *bMain::_findCode(int code) -{ - - bListBasePtr* lbPtr = mData.find(code); - return lbPtr; -} - - -// ------------------------------------------------------------// -bListBasePtr *bMain::getScene() -{ - bListBasePtr *ptr = _findCode(ID_SCE); - if (!ptr) - return 0; - return ptr; -} - -// ------------------------------------------------------------// -bListBasePtr *bMain::getLibrary() -{ - bListBasePtr *ptr = _findCode(ID_LI); - if (!ptr) - return 0; - return ptr; -} -// ------------------------------------------------------------// -bListBasePtr *bMain::getObject() -{ - bListBasePtr *ptr = _findCode(ID_OB); - if (!ptr) - return 0; - return ptr; -} - -// ------------------------------------------------------------// -bListBasePtr *bMain::getMesh() -{ - bListBasePtr *ptr = _findCode(ID_ME); - if (!ptr) - return 0; - return ptr; -} - -// ------------------------------------------------------------// -bListBasePtr *bMain::getCurve() -{ - bListBasePtr *ptr = _findCode(ID_CU); - if (!ptr) - return 0; - return ptr; -} - - - -// ------------------------------------------------------------// -bListBasePtr *bMain::getMball() -{ - bListBasePtr *ptr = _findCode(ID_MB); - if (!ptr) - return 0; - return ptr; -} - -// ------------------------------------------------------------// -bListBasePtr *bMain::getMat() -{ - bListBasePtr *ptr = _findCode(ID_MA); - if (!ptr) - return 0; - return ptr; -} - -// ------------------------------------------------------------// -bListBasePtr *bMain::getTex() -{ - bListBasePtr *ptr = _findCode(ID_TE); - if (!ptr) - return 0; - return ptr; -} - - -// ------------------------------------------------------------// -bListBasePtr *bMain::getImage() -{ - bListBasePtr *ptr = _findCode(ID_IM); - if (!ptr) - return 0; - return ptr; -} - -// ------------------------------------------------------------// -bListBasePtr *bMain::getWave() -{ - bListBasePtr *ptr = _findCode(ID_WV); - if (!ptr) - return 0; - return ptr; -} - -// ------------------------------------------------------------// -bListBasePtr *bMain::getLatt() -{ - bListBasePtr *ptr = _findCode(ID_LT); - if (!ptr) - return 0; - return ptr; -} - -// ------------------------------------------------------------// -bListBasePtr *bMain::getLamp() -{ - bListBasePtr *ptr = _findCode(ID_LA); - if (!ptr) - return 0; - return ptr; -} - -// ------------------------------------------------------------// -bListBasePtr *bMain::getCamera() -{ - bListBasePtr *ptr = _findCode(ID_CA); - if (!ptr) - return 0; - return ptr; -} - -// ------------------------------------------------------------// -bListBasePtr *bMain::getIpo() -{ - bListBasePtr *ptr = _findCode(ID_IP); - if (!ptr) - return 0; - return ptr; -} - -// ------------------------------------------------------------// -bListBasePtr *bMain::getKey() -{ - bListBasePtr *ptr = _findCode(ID_KE); - if (!ptr) - return 0; - return ptr; -} - -// ------------------------------------------------------------// -bListBasePtr *bMain::getWorld() -{ - bListBasePtr *ptr = _findCode(ID_WO); - if (!ptr) - return 0; - return ptr; -} - - -// ------------------------------------------------------------// -bListBasePtr *bMain::getScreen() -{ - bListBasePtr *ptr = _findCode(ID_SCR); - if (!ptr) - return 0; - return ptr; -} - -// ------------------------------------------------------------// -bListBasePtr *bMain::getScript() -{ - bListBasePtr *ptr = _findCode(ID_SCRIPT); - if (!ptr) - return 0; - return ptr; -} - -// ------------------------------------------------------------// -bListBasePtr *bMain::getVfont() -{ - bListBasePtr *ptr = _findCode(ID_VF); - if (!ptr) - return 0; - return ptr; -} - -// ------------------------------------------------------------// -bListBasePtr *bMain::getText() -{ - bListBasePtr *ptr = _findCode(ID_TXT); - if (!ptr) - return 0; - return ptr; -} - -// ------------------------------------------------------------// -bListBasePtr *bMain::getSound() -{ - bListBasePtr *ptr = _findCode(ID_SO); - if (!ptr) - return 0; - return ptr; -} - -// ------------------------------------------------------------// -bListBasePtr *bMain::getGroup() -{ - bListBasePtr *ptr = _findCode(ID_GR); - if (!ptr) - return 0; - return ptr; -} - -// ------------------------------------------------------------// -bListBasePtr *bMain::getArmature() -{ - bListBasePtr *ptr = _findCode(ID_AR); - if (!ptr) - return 0; - return ptr; -} - -// ------------------------------------------------------------// -bListBasePtr *bMain::getAction() -{ - bListBasePtr *ptr = _findCode(ID_AC); - if (!ptr) - return 0; - return ptr; -} - - -// ------------------------------------------------------------// -bListBasePtr *bMain::getNodetree() -{ - bListBasePtr *ptr = _findCode(ID_NT); - if (!ptr) - return 0; - return ptr; -} - -// ------------------------------------------------------------// -bListBasePtr *bMain::getBrush() -{ - bListBasePtr *ptr = _findCode(ID_BR); - if (!ptr) - return 0; - return ptr; -} - - - -//eof diff --git a/gamekit/bMain.h b/gamekit/bMain.h deleted file mode 100644 index e313b9975..000000000 --- a/gamekit/bMain.h +++ /dev/null @@ -1,110 +0,0 @@ -/* -bParse -Copyright (c) 2006-2009 Charlie C & Erwin Coumans http://gamekit.googlecode.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef __BMAIN_H__ -#define __BMAIN_H__ - -#include "bCommon.h" -#include "bChunk.h" -#include "LinearMath/btHashMap.h" - - -namespace bParse -{ - class bDNA; - - class bBlenderFile; -}; - - - -namespace bParse { - - - // ----------------------------------------------------- // - - typedef btHashMap<btHashInt,bListBasePtr> bMainDataMap; - - - - // ----------------------------------------------------- // - class bMain - { - //private: - public: - bBlenderFile* mFP; - bListBasePtr mPool; - - int mVersion; - const char* mName; - - bMainDataMap mData; - - - - - bListBasePtr *_findCode(int code); - - public: - bMain(bBlenderFile *filePtr, const char *baseName, int fileVersion); - ~bMain(); - - int getVersion(); - const char *getName(); - - bListBasePtr *getListBasePtr(int listBaseCode); - - - bListBasePtr *getScene(); - bListBasePtr *getLibrary(); - bListBasePtr *getObject(); - bListBasePtr *getMesh(); - bListBasePtr *getCurve(); - bListBasePtr *getMball(); - bListBasePtr *getMat(); - bListBasePtr *getTex(); - bListBasePtr *getImage(); - bListBasePtr *getWave(); - bListBasePtr *getLatt(); - bListBasePtr *getLamp(); - bListBasePtr *getCamera(); - bListBasePtr *getIpo(); - bListBasePtr *getKey(); - bListBasePtr *getWorld(); - bListBasePtr *getScreen(); - bListBasePtr *getScript(); - bListBasePtr *getVfont(); - bListBasePtr *getText(); - bListBasePtr *getSound(); - bListBasePtr *getGroup(); - bListBasePtr *getArmature(); - bListBasePtr *getAction(); - bListBasePtr *getNodetree(); - bListBasePtr *getBrush(); - - - - // tracking allocated memory - void addDatablock(void *allocated); - - - // -- - - void linkList(void *listBasePtr); - }; -} - - -#endif//__BMAIN_H__ diff --git a/gamekit/blendtype.h b/gamekit/blendtype.h deleted file mode 100644 index 30f6ba89f..000000000 --- a/gamekit/blendtype.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef BLEND_TYPE_H -#define BLEND_TYPE_H -#include "abs-file.h" - - -#ifdef __cplusplus -extern "C" { -#endif - - - - - -#ifdef __cplusplus -} -#endif - -#endif //BLEND_TYPE_H \ No newline at end of file diff --git a/gamekit/btBulletFile.cpp b/gamekit/btBulletFile.cpp deleted file mode 100644 index 035c0c31c..000000000 --- a/gamekit/btBulletFile.cpp +++ /dev/null @@ -1,246 +0,0 @@ -/* -bParse -Copyright (c) 2006-2009 Erwin Coumans http://gamekit.googlecode.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "btBulletFile.h" -#include "bDefines.h" -#include "bDNA.h" -#include <string.h> - - -// 32 && 64 bit versions -extern unsigned char BulletDNAstr[]; -extern int BulletDNAlen; - -//not yetto. extern unsigned char DNAstr64[]; -//not yetto. extern int DNAlen64; - - -using namespace bParse; - -btBulletFile::btBulletFile() -:bFile("", "BULLET ") -{ - mMemoryDNA = new bDNA(); - mMemoryDNA->init((char*)BulletDNAstr,BulletDNAlen); -} - - -btBulletFile::btBulletFile(const char* fileName) -:bFile(fileName, "BULLET ") -{ -} - - - -btBulletFile::btBulletFile(char *memoryBuffer, int len) -:bFile(memoryBuffer,len, "BULLET ") -{ - -} - - -btBulletFile::~btBulletFile() -{ - -} - - - -// ----------------------------------------------------- // -void btBulletFile::parseData() -{ - printf ("Building datablocks"); - printf ("Chunk size = %d",CHUNK_HEADER_LEN); - printf ("File chunk size = %d",ChunkUtils::getOffset(mFlags)); - - const bool swap = (mFlags&FD_ENDIAN_SWAP)!=0; - - - mDataStart = 12; - - char *dataPtr = mFileBuffer+mDataStart; - - bChunkInd dataChunk; - dataChunk.code = 0; - - - //dataPtr += ChunkUtils::getNextBlock(&dataChunk, dataPtr, mFlags); - int seek = ChunkUtils::getNextBlock(&dataChunk, dataPtr, mFlags); - //dataPtr += ChunkUtils::getOffset(mFlags); - char *dataPtrHead = 0; - - while (dataChunk.code != DNA1) - { - - - - - // one behind - if (dataChunk.code == SDNA) break; - //if (dataChunk.code == DNA1) break; - - // same as (BHEAD+DATA dependancy) - dataPtrHead = dataPtr+ChunkUtils::getOffset(mFlags); - char *id = readStruct(dataPtrHead, dataChunk); - - // lookup maps - if (id) - { - mLibPointers.insert(dataChunk.oldPtr, (bStructHandle*)id); - - m_chunks.push_back(dataChunk); - // block it - //bListBasePtr *listID = mMain->getListBasePtr(dataChunk.code); - //if (listID) - // listID->push_back((bStructHandle*)id); - } - - if (dataChunk.code == BT_COLLISIONOBJECT_CODE) - { - m_collisionObjects.push_back((bStructHandle*) id); - } - - if (dataChunk.code == BT_BOXSHAPE_CODE) - { - m_collisionShapes.push_back((bStructHandle*) id); - } - -// if (dataChunk.code == GLOB) -// { -// m_glob = (bStructHandle*) id; -// } - - // next please! - dataPtr += seek; - - seek = ChunkUtils::getNextBlock(&dataChunk, dataPtr, mFlags); - if (seek < 0) - break; - } - -} - -void btBulletFile::addDataBlock(char* dataBlock) -{ - //mMain->addDatablock(dataBlock); -} - - - - -void btBulletFile::writeDNA(FILE* fp) -{ - - bChunkInd dataChunk; - dataChunk.code = DNA1; - dataChunk.dna_nr = 0; - dataChunk.nr = 1; - - if (VOID_IS_8) - { - //dataChunk.len = DNAlen64; - //dataChunk.oldPtr = DNAstr64; - //fwrite(&dataChunk,sizeof(bChunkInd),1,fp); - //fwrite(DNAstr64, DNAlen64,1,fp); - } - else - { - dataChunk.len = BulletDNAlen; - dataChunk.oldPtr = BulletDNAstr; - fwrite(&dataChunk,sizeof(bChunkInd),1,fp); - fwrite(BulletDNAstr, BulletDNAlen,1,fp); - } -} - -void btBulletFile::parse(bool verboseDumpAllTypes) -{ - if (VOID_IS_8) - { - exit(0); - //parseInternal(verboseDumpAllTypes,(char*)DNAstr64,DNAlen64); - } - else - { - parseInternal(verboseDumpAllTypes,(char*)BulletDNAstr,BulletDNAlen); - } -} - -// experimental -int btBulletFile::write(const char* fileName, bool fixupPointers) -{ - FILE *fp = fopen(fileName, "wb"); - if (fp) - { - char header[SIZEOFBLENDERHEADER] ; - memcpy(header, m_headerString, 7); - int endian= 1; - endian= ((char*)&endian)[0]; - - if (endian) - { - header[7] = '_'; - } else - { - header[7] = '-'; - } - if (VOID_IS_8) - { - header[8]='V'; - } else - { - header[8]='v'; - } - - header[9] = '2'; - header[10] = '7'; - header[11] = '5'; - - fwrite(header,SIZEOFBLENDERHEADER,1,fp); - - writeChunks(fp, fixupPointers); - - writeDNA(fp); - - fclose(fp); - - } else - { - printf("Error: cannot open file %s for writing\n",fileName); - return 0; - } - return 1; -} - - - -void btBulletFile::addStruct(const char* structType,void* data, int len, void* oldPtr, int code) -{ - - bParse::bChunkInd dataChunk; - dataChunk.code = code; - dataChunk.nr = 1; - dataChunk.len = len; - dataChunk.dna_nr = mMemoryDNA->getReverseType(structType); - dataChunk.oldPtr = oldPtr; - - ///Perform structure size validation - short* structInfo= mMemoryDNA->getStruct(dataChunk.dna_nr); - int elemBytes = mMemoryDNA->getLength(structInfo[0]); -// int elemBytes = mMemoryDNA->getElementSize(structInfo[0],structInfo[1]); - assert(len==elemBytes); - - mLibPointers.insert(dataChunk.oldPtr, (bStructHandle*)data); - m_chunks.push_back(dataChunk); -} \ No newline at end of file diff --git a/gamekit/btBulletFile.h b/gamekit/btBulletFile.h deleted file mode 100644 index 0523494dd..000000000 --- a/gamekit/btBulletFile.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -bParse -Copyright (c) 2006-2009 Charlie C & Erwin Coumans http://gamekit.googlecode.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef BT_BULLET_FILE_H -#define BT_BULLET_FILE_H - - -#include "bFile.h" -#include "LinearMath/btAlignedObjectArray.h" -#include "bDefines.h" - -#define BT_COLLISIONOBJECT_CODE MAKE_ID('C','O','B','J') -#define BT_RIGIDBODY_CODE MAKE_ID('R','B','D','Y') -#define BT_BOXSHAPE_CODE MAKE_ID('B','O','X','S') - -namespace bParse { - - // ----------------------------------------------------- // - class btBulletFile : public bFile - { - - protected: - - - public: - - btAlignedObjectArray<bStructHandle*> m_collisionObjects; - - btAlignedObjectArray<bStructHandle*> m_collisionShapes; - - btBulletFile(); - - btBulletFile(const char* fileName); - - btBulletFile(char *memoryBuffer, int len); - - virtual ~btBulletFile(); - - virtual void addDataBlock(char* dataBlock); - - - // experimental - virtual int write(const char* fileName, bool fixupPointers=false); - - virtual void parse(bool verboseDumpAllTypes); - - virtual void parseData(); - - virtual void writeDNA(FILE* fp); - - void addStruct(const char* structType,void* data, int len, void* oldPtr, int code); - - }; -}; - -#endif //BT_BULLET_FILE_H diff --git a/gamekit/chain_demo_1.0.blend b/gamekit/chain_demo_1.0.blend deleted file mode 100644 index 91f67853f..000000000 Binary files a/gamekit/chain_demo_1.0.blend and /dev/null differ diff --git a/gamekit/clubsilo_packed.blend b/gamekit/clubsilo_packed.blend deleted file mode 100644 index b47eee7c5..000000000 Binary files a/gamekit/clubsilo_packed.blend and /dev/null differ diff --git a/gamekit/cube_ipo_180.blend b/gamekit/cube_ipo_180.blend deleted file mode 100644 index 6790f502b..000000000 Binary files a/gamekit/cube_ipo_180.blend and /dev/null differ diff --git a/gamekit/cube_ipo_204.blend b/gamekit/cube_ipo_204.blend deleted file mode 100644 index a263481b4..000000000 Binary files a/gamekit/cube_ipo_204.blend and /dev/null differ diff --git a/gamekit/cube_tex_204.blend b/gamekit/cube_tex_204.blend deleted file mode 100644 index 0c5558910..000000000 Binary files a/gamekit/cube_tex_204.blend and /dev/null differ diff --git a/gamekit/cube_tex_4.blend b/gamekit/cube_tex_4.blend deleted file mode 100644 index 19738defc..000000000 Binary files a/gamekit/cube_tex_4.blend and /dev/null differ diff --git a/gamekit/dna249-64bit.cpp b/gamekit/dna249-64bit.cpp deleted file mode 100644 index 2c430f47e..000000000 --- a/gamekit/dna249-64bit.cpp +++ /dev/null @@ -1,1411 +0,0 @@ -/* -bParse -Copyright (c) 2006-2009 Charlie C & Erwin Coumans http://gamekit.googlecode.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ -unsigned char DNAstr64[]= { -83,68,78,65,78,65,77,69,119,9,0,0,42,110,101,120,116,0,42,112,114,101,118,0,42,100,97,116,97,0,42,102,105, -114,115,116,0,42,108,97,115,116,0,120,0,121,0,122,0,119,0,120,109,105,110,0,120,109,97,120,0,121,109,105,110, -0,121,109,97,120,0,42,112,111,105,110,116,101,114,0,103,114,111,117,112,0,118,97,108,0,118,97,108,50,0,110,97, -109,101,91,51,50,93,0,116,121,112,101,0,115,117,98,116,121,112,101,0,102,108,97,103,0,115,97,118,101,100,0,100, -97,116,97,0,108,101,110,0,116,111,116,97,108,108,101,110,0,42,110,101,119,105,100,0,42,108,105,98,0,110,97,109, -101,91,50,52,93,0,117,115,0,105,99,111,110,95,105,100,0,42,112,114,111,112,101,114,116,105,101,115,0,105,100,0, -42,105,100,98,108,111,99,107,0,42,102,105,108,101,100,97,116,97,0,110,97,109,101,91,50,52,48,93,0,102,105,108, -101,110,97,109,101,91,50,52,48,93,0,116,111,116,0,112,97,100,0,42,112,97,114,101,110,116,0,119,91,50,93,0, -104,91,50,93,0,99,104,97,110,103,101,100,91,50,93,0,112,97,100,48,0,112,97,100,49,0,42,114,101,99,116,91, -50,93,0,42,111,98,0,98,108,111,99,107,116,121,112,101,0,97,100,114,99,111,100,101,0,110,97,109,101,91,49,50, -56,93,0,42,98,112,0,42,98,101,122,116,0,109,97,120,114,99,116,0,116,111,116,114,99,116,0,118,97,114,116,121, -112,101,0,116,111,116,118,101,114,116,0,105,112,111,0,101,120,116,114,97,112,0,114,116,0,98,105,116,109,97,115,107, -0,115,108,105,100,101,95,109,105,110,0,115,108,105,100,101,95,109,97,120,0,99,117,114,118,97,108,0,42,100,114,105, -118,101,114,0,99,117,114,118,101,0,99,117,114,0,115,104,111,119,107,101,121,0,109,117,116,101,105,112,111,0,112,111, -115,0,114,101,108,97,116,105,118,101,0,116,111,116,101,108,101,109,0,112,97,100,50,0,42,119,101,105,103,104,116,115, -0,118,103,114,111,117,112,91,51,50,93,0,115,108,105,100,101,114,109,105,110,0,115,108,105,100,101,114,109,97,120,0, -42,114,101,102,107,101,121,0,101,108,101,109,115,116,114,91,51,50,93,0,101,108,101,109,115,105,122,101,0,98,108,111, -99,107,0,42,105,112,111,0,42,102,114,111,109,0,116,111,116,107,101,121,0,115,108,117,114,112,104,0,42,42,115,99, -114,105,112,116,115,0,42,102,108,97,103,0,97,99,116,115,99,114,105,112,116,0,116,111,116,115,99,114,105,112,116,0, -42,108,105,110,101,0,42,102,111,114,109,97,116,0,98,108,101,110,0,108,105,110,101,110,111,0,115,116,97,114,116,0, -101,110,100,0,102,108,97,103,115,0,99,111,108,111,114,91,52,93,0,112,97,100,91,52,93,0,42,110,97,109,101,0, -110,108,105,110,101,115,0,108,105,110,101,115,0,42,99,117,114,108,0,42,115,101,108,108,0,99,117,114,99,0,115,101, -108,99,0,109,97,114,107,101,114,115,0,42,117,110,100,111,95,98,117,102,0,117,110,100,111,95,112,111,115,0,117,110, -100,111,95,108,101,110,0,42,99,111,109,112,105,108,101,100,0,109,116,105,109,101,0,115,105,122,101,0,115,101,101,107, -0,112,97,115,115,101,112,97,114,116,97,108,112,104,97,0,97,110,103,108,101,0,99,108,105,112,115,116,97,0,99,108, -105,112,101,110,100,0,108,101,110,115,0,111,114,116,104,111,95,115,99,97,108,101,0,100,114,97,119,115,105,122,101,0, -115,104,105,102,116,120,0,115,104,105,102,116,121,0,89,70,95,100,111,102,100,105,115,116,0,89,70,95,97,112,101,114, -116,117,114,101,0,89,70,95,98,107,104,116,121,112,101,0,89,70,95,98,107,104,98,105,97,115,0,89,70,95,98,107, -104,114,111,116,0,115,99,114,105,112,116,108,105,110,107,0,42,100,111,102,95,111,98,0,102,114,97,109,101,110,114,0, -102,114,97,109,101,115,0,111,102,102,115,101,116,0,115,102,114,97,0,102,105,101,95,105,109,97,0,99,121,99,108,0, -111,107,0,109,117,108,116,105,95,105,110,100,101,120,0,108,97,121,101,114,0,112,97,115,115,0,109,101,110,117,110,114, -0,105,98,117,102,115,0,42,103,112,117,116,101,120,116,117,114,101,0,42,97,110,105,109,0,42,114,114,0,115,111,117, -114,99,101,0,108,97,115,116,102,114,97,109,101,0,116,112,97,103,101,102,108,97,103,0,116,111,116,98,105,110,100,0, -120,114,101,112,0,121,114,101,112,0,116,119,115,116,97,0,116,119,101,110,100,0,98,105,110,100,99,111,100,101,0,42, -114,101,112,98,105,110,100,0,42,112,97,99,107,101,100,102,105,108,101,0,42,112,114,101,118,105,101,119,0,108,97,115, -116,117,112,100,97,116,101,0,108,97,115,116,117,115,101,100,0,97,110,105,109,115,112,101,101,100,0,103,101,110,95,120, -0,103,101,110,95,121,0,103,101,110,95,116,121,112,101,0,97,115,112,120,0,97,115,112,121,0,42,118,110,111,100,101, -0,116,101,120,99,111,0,109,97,112,116,111,0,109,97,112,116,111,110,101,103,0,98,108,101,110,100,116,121,112,101,0, -42,111,98,106,101,99,116,0,42,116,101,120,0,117,118,110,97,109,101,91,51,50,93,0,112,114,111,106,120,0,112,114, -111,106,121,0,112,114,111,106,122,0,109,97,112,112,105,110,103,0,111,102,115,91,51,93,0,115,105,122,101,91,51,93, -0,116,101,120,102,108,97,103,0,99,111,108,111,114,109,111,100,101,108,0,112,109,97,112,116,111,0,112,109,97,112,116, -111,110,101,103,0,110,111,114,109,97,112,115,112,97,99,101,0,119,104,105,99,104,95,111,117,116,112,117,116,0,112,97, -100,91,50,93,0,114,0,103,0,98,0,107,0,100,101,102,95,118,97,114,0,99,111,108,102,97,99,0,110,111,114,102, -97,99,0,118,97,114,102,97,99,0,100,105,115,112,102,97,99,0,119,97,114,112,102,97,99,0,110,97,109,101,91,49, -54,48,93,0,42,104,97,110,100,108,101,0,42,112,110,97,109,101,0,42,115,116,110,97,109,101,115,0,115,116,121,112, -101,115,0,118,97,114,115,0,42,118,97,114,115,116,114,0,42,114,101,115,117,108,116,0,42,99,102,114,97,0,100,97, -116,97,91,51,50,93,0,40,42,100,111,105,116,41,40,41,0,40,42,105,110,115,116,97,110,99,101,95,105,110,105,116, -41,40,41,0,40,42,99,97,108,108,98,97,99,107,41,40,41,0,118,101,114,115,105,111,110,0,97,0,105,112,111,116, -121,112,101,0,42,105,109,97,0,42,99,117,98,101,91,54,93,0,105,109,97,116,91,52,93,91,52,93,0,111,98,105, -109,97,116,91,51,93,91,51,93,0,115,116,121,112,101,0,118,105,101,119,115,99,97,108,101,0,110,111,116,108,97,121, -0,99,117,98,101,114,101,115,0,100,101,112,116,104,0,114,101,99,97,108,99,0,108,97,115,116,115,105,122,101,0,110, -111,105,115,101,115,105,122,101,0,116,117,114,98,117,108,0,98,114,105,103,104,116,0,99,111,110,116,114,97,115,116,0, -114,102,97,99,0,103,102,97,99,0,98,102,97,99,0,102,105,108,116,101,114,115,105,122,101,0,109,103,95,72,0,109, -103,95,108,97,99,117,110,97,114,105,116,121,0,109,103,95,111,99,116,97,118,101,115,0,109,103,95,111,102,102,115,101, -116,0,109,103,95,103,97,105,110,0,100,105,115,116,95,97,109,111,117,110,116,0,110,115,95,111,117,116,115,99,97,108, -101,0,118,110,95,119,49,0,118,110,95,119,50,0,118,110,95,119,51,0,118,110,95,119,52,0,118,110,95,109,101,120, -112,0,118,110,95,100,105,115,116,109,0,118,110,95,99,111,108,116,121,112,101,0,110,111,105,115,101,100,101,112,116,104, -0,110,111,105,115,101,116,121,112,101,0,110,111,105,115,101,98,97,115,105,115,0,110,111,105,115,101,98,97,115,105,115, -50,0,105,109,97,102,108,97,103,0,99,114,111,112,120,109,105,110,0,99,114,111,112,121,109,105,110,0,99,114,111,112, -120,109,97,120,0,99,114,111,112,121,109,97,120,0,120,114,101,112,101,97,116,0,121,114,101,112,101,97,116,0,101,120, -116,101,110,100,0,99,104,101,99,107,101,114,100,105,115,116,0,110,97,98,108,97,0,105,117,115,101,114,0,42,110,111, -100,101,116,114,101,101,0,42,112,108,117,103,105,110,0,42,99,111,98,97,0,42,101,110,118,0,117,115,101,95,110,111, -100,101,115,0,112,97,100,91,55,93,0,108,111,99,91,51,93,0,114,111,116,91,51,93,0,109,97,116,91,52,93,91, -52,93,0,109,105,110,91,51,93,0,109,97,120,91,51,93,0,112,97,100,51,0,109,111,100,101,0,116,111,116,101,120, -0,115,104,100,119,114,0,115,104,100,119,103,0,115,104,100,119,98,0,115,104,100,119,112,97,100,0,101,110,101,114,103, -121,0,100,105,115,116,0,115,112,111,116,115,105,122,101,0,115,112,111,116,98,108,101,110,100,0,104,97,105,110,116,0, -97,116,116,49,0,97,116,116,50,0,42,99,117,114,102,97,108,108,111,102,102,0,102,97,108,108,111,102,102,95,116,121, -112,101,0,115,104,97,100,115,112,111,116,115,105,122,101,0,98,105,97,115,0,115,111,102,116,0,98,117,102,115,105,122, -101,0,115,97,109,112,0,98,117,102,102,101,114,115,0,102,105,108,116,101,114,116,121,112,101,0,98,117,102,102,108,97, -103,0,98,117,102,116,121,112,101,0,114,97,121,95,115,97,109,112,0,114,97,121,95,115,97,109,112,121,0,114,97,121, -95,115,97,109,112,122,0,114,97,121,95,115,97,109,112,95,116,121,112,101,0,97,114,101,97,95,115,104,97,112,101,0, -97,114,101,97,95,115,105,122,101,0,97,114,101,97,95,115,105,122,101,121,0,97,114,101,97,95,115,105,122,101,122,0, -97,100,97,112,116,95,116,104,114,101,115,104,0,114,97,121,95,115,97,109,112,95,109,101,116,104,111,100,0,116,101,120, -97,99,116,0,115,104,97,100,104,97,108,111,115,116,101,112,0,115,117,110,95,101,102,102,101,99,116,95,116,121,112,101, -0,115,107,121,98,108,101,110,100,116,121,112,101,0,104,111,114,105,122,111,110,95,98,114,105,103,104,116,110,101,115,115, -0,115,112,114,101,97,100,0,115,117,110,95,98,114,105,103,104,116,110,101,115,115,0,115,117,110,95,115,105,122,101,0, -98,97,99,107,115,99,97,116,116,101,114,101,100,95,108,105,103,104,116,0,115,117,110,95,105,110,116,101,110,115,105,116, -121,0,97,116,109,95,116,117,114,98,105,100,105,116,121,0,97,116,109,95,105,110,115,99,97,116,116,101,114,105,110,103, -95,102,97,99,116,111,114,0,97,116,109,95,101,120,116,105,110,99,116,105,111,110,95,102,97,99,116,111,114,0,97,116, -109,95,100,105,115,116,97,110,99,101,95,102,97,99,116,111,114,0,115,107,121,98,108,101,110,100,102,97,99,0,115,107, -121,95,101,120,112,111,115,117,114,101,0,115,107,121,95,99,111,108,111,114,115,112,97,99,101,0,112,97,100,52,0,89, -70,95,110,117,109,112,104,111,116,111,110,115,0,89,70,95,110,117,109,115,101,97,114,99,104,0,89,70,95,112,104,100, -101,112,116,104,0,89,70,95,117,115,101,113,109,99,0,89,70,95,98,117,102,115,105,122,101,0,89,70,95,112,97,100, -0,89,70,95,99,97,117,115,116,105,99,98,108,117,114,0,89,70,95,108,116,114,97,100,105,117,115,0,89,70,95,103, -108,111,119,105,110,116,0,89,70,95,103,108,111,119,111,102,115,0,89,70,95,103,108,111,119,116,121,112,101,0,89,70, -95,112,97,100,50,0,42,109,116,101,120,91,49,56,93,0,115,112,101,99,114,0,115,112,101,99,103,0,115,112,101,99, -98,0,109,105,114,114,0,109,105,114,103,0,109,105,114,98,0,97,109,98,114,0,97,109,98,98,0,97,109,98,103,0, -97,109,98,0,101,109,105,116,0,97,110,103,0,115,112,101,99,116,114,97,0,114,97,121,95,109,105,114,114,111,114,0, -97,108,112,104,97,0,114,101,102,0,115,112,101,99,0,122,111,102,102,115,0,97,100,100,0,116,114,97,110,115,108,117, -99,101,110,99,121,0,102,114,101,115,110,101,108,95,109,105,114,0,102,114,101,115,110,101,108,95,109,105,114,95,105,0, -102,114,101,115,110,101,108,95,116,114,97,0,102,114,101,115,110,101,108,95,116,114,97,95,105,0,102,105,108,116,101,114, -0,116,120,95,108,105,109,105,116,0,116,120,95,102,97,108,108,111,102,102,0,114,97,121,95,100,101,112,116,104,0,114, -97,121,95,100,101,112,116,104,95,116,114,97,0,104,97,114,0,115,101,101,100,49,0,115,101,101,100,50,0,103,108,111, -115,115,95,109,105,114,0,103,108,111,115,115,95,116,114,97,0,115,97,109,112,95,103,108,111,115,115,95,109,105,114,0, -115,97,109,112,95,103,108,111,115,115,95,116,114,97,0,97,100,97,112,116,95,116,104,114,101,115,104,95,109,105,114,0, -97,100,97,112,116,95,116,104,114,101,115,104,95,116,114,97,0,97,110,105,115,111,95,103,108,111,115,115,95,109,105,114, -0,100,105,115,116,95,109,105,114,0,102,97,100,101,116,111,95,109,105,114,0,115,104,97,100,101,95,102,108,97,103,0, -109,111,100,101,95,108,0,102,108,97,114,101,99,0,115,116,97,114,99,0,108,105,110,101,99,0,114,105,110,103,99,0, -104,97,115,105,122,101,0,102,108,97,114,101,115,105,122,101,0,115,117,98,115,105,122,101,0,102,108,97,114,101,98,111, -111,115,116,0,115,116,114,97,110,100,95,115,116,97,0,115,116,114,97,110,100,95,101,110,100,0,115,116,114,97,110,100, -95,101,97,115,101,0,115,116,114,97,110,100,95,115,117,114,102,110,111,114,0,115,116,114,97,110,100,95,109,105,110,0, -115,116,114,97,110,100,95,119,105,100,116,104,102,97,100,101,0,115,116,114,97,110,100,95,117,118,110,97,109,101,91,51, -50,93,0,115,98,105,97,115,0,108,98,105,97,115,0,115,104,97,100,95,97,108,112,104,97,0,115,101,112,116,101,120, -0,114,103,98,115,101,108,0,112,114,95,116,121,112,101,0,112,114,95,98,97,99,107,0,112,114,95,108,97,109,112,0, -109,108,95,102,108,97,103,0,100,105,102,102,95,115,104,97,100,101,114,0,115,112,101,99,95,115,104,97,100,101,114,0, -114,111,117,103,104,110,101,115,115,0,114,101,102,114,97,99,0,112,97,114,97,109,91,52,93,0,114,109,115,0,100,97, -114,107,110,101,115,115,0,42,114,97,109,112,95,99,111,108,0,42,114,97,109,112,95,115,112,101,99,0,114,97,109,112, -105,110,95,99,111,108,0,114,97,109,112,105,110,95,115,112,101,99,0,114,97,109,112,98,108,101,110,100,95,99,111,108, -0,114,97,109,112,98,108,101,110,100,95,115,112,101,99,0,114,97,109,112,95,115,104,111,119,0,114,97,109,112,102,97, -99,95,99,111,108,0,114,97,109,112,102,97,99,95,115,112,101,99,0,42,103,114,111,117,112,0,102,114,105,99,116,105, -111,110,0,102,104,0,114,101,102,108,101,99,116,0,102,104,100,105,115,116,0,120,121,102,114,105,99,116,0,100,121,110, -97,109,111,100,101,0,115,115,115,95,114,97,100,105,117,115,91,51,93,0,115,115,115,95,99,111,108,91,51,93,0,115, -115,115,95,101,114,114,111,114,0,115,115,115,95,115,99,97,108,101,0,115,115,115,95,105,111,114,0,115,115,115,95,99, -111,108,102,97,99,0,115,115,115,95,116,101,120,102,97,99,0,115,115,115,95,102,114,111,110,116,0,115,115,115,95,98, -97,99,107,0,115,115,115,95,102,108,97,103,0,115,115,115,95,112,114,101,115,101,116,0,89,70,95,97,114,0,89,70, -95,97,103,0,89,70,95,97,98,0,89,70,95,100,115,99,97,108,101,0,89,70,95,100,112,119,114,0,89,70,95,100, -115,109,112,0,89,70,95,112,114,101,115,101,116,0,89,70,95,100,106,105,116,0,103,112,117,109,97,116,101,114,105,97, -108,0,110,97,109,101,91,50,53,54,93,0,115,99,97,108,101,0,42,98,98,0,105,49,0,106,49,0,107,49,0,105, -50,0,106,50,0,107,50,0,115,101,108,99,111,108,49,0,115,101,108,99,111,108,50,0,113,117,97,116,91,52,93,0, -101,120,112,120,0,101,120,112,121,0,101,120,112,122,0,114,97,100,0,114,97,100,50,0,115,0,42,109,97,116,0,42, -105,109,97,116,0,101,108,101,109,115,0,100,105,115,112,0,42,42,109,97,116,0,116,111,116,99,111,108,0,119,105,114, -101,115,105,122,101,0,114,101,110,100,101,114,115,105,122,101,0,116,104,114,101,115,104,0,118,101,99,91,51,93,91,51, -93,0,97,108,102,97,0,119,101,105,103,104,116,0,114,97,100,105,117,115,0,104,49,0,104,50,0,102,49,0,102,50, -0,102,51,0,104,105,100,101,0,118,101,99,91,52,93,0,109,97,116,95,110,114,0,112,110,116,115,117,0,112,110,116, -115,118,0,114,101,115,111,108,117,0,114,101,115,111,108,118,0,111,114,100,101,114,117,0,111,114,100,101,114,118,0,102, -108,97,103,117,0,102,108,97,103,118,0,42,107,110,111,116,115,117,0,42,107,110,111,116,115,118,0,116,105,108,116,95, -105,110,116,101,114,112,0,114,97,100,105,117,115,95,105,110,116,101,114,112,0,99,104,97,114,105,100,120,0,107,101,114, -110,0,104,0,110,117,114,98,0,42,98,101,118,111,98,106,0,42,116,97,112,101,114,111,98,106,0,42,116,101,120,116, -111,110,99,117,114,118,101,0,42,112,97,116,104,0,42,107,101,121,0,98,101,118,0,112,97,116,104,108,101,110,0,98, -101,118,114,101,115,111,108,0,119,105,100,116,104,0,101,120,116,49,0,101,120,116,50,0,114,101,115,111,108,117,95,114, -101,110,0,114,101,115,111,108,118,95,114,101,110,0,115,112,97,99,101,109,111,100,101,0,115,112,97,99,105,110,103,0, -108,105,110,101,100,105,115,116,0,115,104,101,97,114,0,102,115,105,122,101,0,119,111,114,100,115,112,97,99,101,0,117, -108,112,111,115,0,117,108,104,101,105,103,104,116,0,120,111,102,0,121,111,102,0,108,105,110,101,119,105,100,116,104,0, -42,115,116,114,0,102,97,109,105,108,121,91,50,52,93,0,42,118,102,111,110,116,0,42,118,102,111,110,116,98,0,42, -118,102,111,110,116,105,0,42,118,102,111,110,116,98,105,0,115,101,112,99,104,97,114,0,116,111,116,98,111,120,0,97, -99,116,98,111,120,0,42,116,98,0,115,101,108,115,116,97,114,116,0,115,101,108,101,110,100,0,42,115,116,114,105,110, -102,111,0,99,117,114,105,110,102,111,0,101,102,102,101,99,116,0,42,109,102,97,99,101,0,42,109,116,102,97,99,101, -0,42,116,102,97,99,101,0,42,109,118,101,114,116,0,42,109,101,100,103,101,0,42,100,118,101,114,116,0,42,109,99, -111,108,0,42,109,115,116,105,99,107,121,0,42,116,101,120,99,111,109,101,115,104,0,42,109,115,101,108,101,99,116,0, -118,100,97,116,97,0,101,100,97,116,97,0,102,100,97,116,97,0,116,111,116,101,100,103,101,0,116,111,116,102,97,99, -101,0,116,111,116,115,101,108,101,99,116,0,97,99,116,95,102,97,99,101,0,99,117,98,101,109,97,112,115,105,122,101, -0,115,109,111,111,116,104,114,101,115,104,0,115,117,98,100,105,118,0,115,117,98,100,105,118,114,0,115,117,98,115,117, -114,102,116,121,112,101,0,42,109,114,0,42,112,118,0,42,116,112,97,103,101,0,117,118,91,52,93,91,50,93,0,99, -111,108,91,52,93,0,116,114,97,110,115,112,0,116,105,108,101,0,117,110,119,114,97,112,0,118,49,0,118,50,0,118, -51,0,118,52,0,101,100,99,111,100,101,0,99,114,101,97,115,101,0,98,119,101,105,103,104,116,0,100,101,102,95,110, -114,0,42,100,119,0,116,111,116,119,101,105,103,104,116,0,99,111,91,51,93,0,110,111,91,51,93,0,112,97,100,91, -51,93,0,117,118,91,50,93,0,99,111,91,50,93,0,105,110,100,101,120,0,102,0,105,0,115,91,50,53,54,93,0, -118,91,52,93,0,109,105,100,0,118,91,50,93,0,42,102,97,99,101,115,0,42,99,111,108,102,97,99,101,115,0,42, -101,100,103,101,115,0,42,101,100,103,101,95,98,111,117,110,100,97,114,121,95,115,116,97,116,101,115,0,42,118,101,114, -116,95,101,100,103,101,95,109,97,112,0,42,118,101,114,116,95,102,97,99,101,95,109,97,112,0,42,109,97,112,95,109, -101,109,0,42,118,101,114,116,115,0,108,101,118,101,108,115,0,108,101,118,101,108,95,99,111,117,110,116,0,99,117,114, -114,101,110,116,0,110,101,119,108,118,108,0,101,100,103,101,108,118,108,0,112,105,110,108,118,108,0,114,101,110,100,101, -114,108,118,108,0,117,115,101,95,99,111,108,0,42,101,100,103,101,95,102,108,97,103,115,0,42,101,100,103,101,95,99, -114,101,97,115,101,115,0,42,118,101,114,116,95,109,97,112,0,42,101,100,103,101,95,109,97,112,0,42,111,108,100,95, -102,97,99,101,115,0,42,111,108,100,95,101,100,103,101,115,0,42,101,114,114,111,114,0,109,111,100,105,102,105,101,114, -0,115,117,98,100,105,118,84,121,112,101,0,114,101,110,100,101,114,76,101,118,101,108,115,0,42,101,109,67,97,99,104, -101,0,42,109,67,97,99,104,101,0,100,101,102,97,120,105,115,0,112,97,100,91,54,93,0,108,101,110,103,116,104,0, -114,97,110,100,111,109,105,122,101,0,115,101,101,100,0,42,111,98,95,97,114,109,0,42,115,116,97,114,116,95,99,97, -112,0,42,101,110,100,95,99,97,112,0,42,99,117,114,118,101,95,111,98,0,42,111,102,102,115,101,116,95,111,98,0, -111,102,102,115,101,116,91,51,93,0,115,99,97,108,101,91,51,93,0,109,101,114,103,101,95,100,105,115,116,0,102,105, -116,95,116,121,112,101,0,111,102,102,115,101,116,95,116,121,112,101,0,99,111,117,110,116,0,97,120,105,115,0,116,111, -108,101,114,97,110,99,101,0,42,109,105,114,114,111,114,95,111,98,0,115,112,108,105,116,95,97,110,103,108,101,0,118, -97,108,117,101,0,114,101,115,0,118,97,108,95,102,108,97,103,115,0,108,105,109,95,102,108,97,103,115,0,101,95,102, -108,97,103,115,0,98,101,118,101,108,95,97,110,103,108,101,0,100,101,102,103,114,112,95,110,97,109,101,91,51,50,93, -0,42,116,101,120,116,117,114,101,0,115,116,114,101,110,103,116,104,0,100,105,114,101,99,116,105,111,110,0,109,105,100, -108,101,118,101,108,0,116,101,120,109,97,112,112,105,110,103,0,42,109,97,112,95,111,98,106,101,99,116,0,117,118,108, -97,121,101,114,95,110,97,109,101,91,51,50,93,0,117,118,108,97,121,101,114,95,116,109,112,0,42,112,114,111,106,101, -99,116,111,114,115,91,49,48,93,0,42,105,109,97,103,101,0,110,117,109,95,112,114,111,106,101,99,116,111,114,115,0, -97,115,112,101,99,116,120,0,97,115,112,101,99,116,121,0,112,101,114,99,101,110,116,0,102,97,99,101,67,111,117,110, -116,0,102,97,99,0,114,101,112,101,97,116,0,42,111,98,106,101,99,116,99,101,110,116,101,114,0,115,116,97,114,116, -120,0,115,116,97,114,116,121,0,104,101,105,103,104,116,0,110,97,114,114,111,119,0,115,112,101,101,100,0,100,97,109, -112,0,102,97,108,108,111,102,102,0,116,105,109,101,111,102,102,115,0,108,105,102,101,116,105,109,101,0,100,101,102,111, -114,109,102,108,97,103,0,109,117,108,116,105,0,42,112,114,101,118,67,111,115,0,112,97,114,101,110,116,105,110,118,91, -52,93,91,52,93,0,99,101,110,116,91,51,93,0,42,105,110,100,101,120,97,114,0,116,111,116,105,110,100,101,120,0, -102,111,114,99,101,0,42,99,108,111,116,104,79,98,106,101,99,116,0,42,115,105,109,95,112,97,114,109,115,0,42,99, -111,108,108,95,112,97,114,109,115,0,42,112,111,105,110,116,95,99,97,99,104,101,0,42,120,0,42,120,110,101,119,0, -42,120,111,108,100,0,42,99,117,114,114,101,110,116,95,120,110,101,119,0,42,99,117,114,114,101,110,116,95,120,0,42, -99,117,114,114,101,110,116,95,118,0,42,109,102,97,99,101,115,0,110,117,109,118,101,114,116,115,0,110,117,109,102,97, -99,101,115,0,97,98,115,111,114,112,116,105,111,110,0,116,105,109,101,0,42,98,118,104,116,114,101,101,0,42,100,109, -0,111,112,101,114,97,116,105,111,110,0,118,101,114,116,101,120,0,116,111,116,105,110,102,108,117,101,110,99,101,0,103, -114,105,100,115,105,122,101,0,110,101,101,100,98,105,110,100,0,42,98,105,110,100,119,101,105,103,104,116,115,0,42,98, -105,110,100,99,111,115,0,116,111,116,99,97,103,101,118,101,114,116,0,42,100,121,110,103,114,105,100,0,42,100,121,110, -105,110,102,108,117,101,110,99,101,115,0,42,100,121,110,118,101,114,116,115,0,42,112,97,100,50,0,100,121,110,103,114, -105,100,115,105,122,101,0,100,121,110,99,101,108,108,109,105,110,91,51,93,0,100,121,110,99,101,108,108,119,105,100,116, -104,0,98,105,110,100,109,97,116,91,52,93,91,52,93,0,42,112,115,121,115,0,116,111,116,100,109,118,101,114,116,0, -116,111,116,100,109,101,100,103,101,0,116,111,116,100,109,102,97,99,101,0,112,115,121,115,0,114,116,91,50,93,0,42, -102,97,99,101,112,97,0,118,103,114,111,117,112,0,112,114,111,116,101,99,116,0,42,102,115,115,0,42,116,97,114,103, -101,116,0,42,97,117,120,84,97,114,103,101,116,0,118,103,114,111,117,112,95,110,97,109,101,91,51,50,93,0,107,101, -101,112,68,105,115,116,0,115,104,114,105,110,107,84,121,112,101,0,115,104,114,105,110,107,79,112,116,115,0,112,114,111, -106,65,120,105,115,0,115,117,98,115,117,114,102,76,101,118,101,108,115,0,42,111,114,105,103,105,110,0,102,97,99,116, -111,114,0,108,105,109,105,116,91,50,93,0,111,114,105,103,105,110,79,112,116,115,0,112,110,116,115,119,0,111,112,110, -116,115,117,0,111,112,110,116,115,118,0,111,112,110,116,115,119,0,116,121,112,101,117,0,116,121,112,101,118,0,116,121, -112,101,119,0,102,117,0,102,118,0,102,119,0,100,117,0,100,118,0,100,119,0,42,100,101,102,0,118,101,99,91,56, -93,91,51,93,0,112,97,114,116,121,112,101,0,112,97,114,49,0,112,97,114,50,0,112,97,114,51,0,112,97,114,115, -117,98,115,116,114,91,51,50,93,0,42,116,114,97,99,107,0,42,112,114,111,120,121,0,42,112,114,111,120,121,95,103, -114,111,117,112,0,42,112,114,111,120,121,95,102,114,111,109,0,42,97,99,116,105,111,110,0,42,112,111,115,101,108,105, -98,0,42,112,111,115,101,0,99,111,110,115,116,114,97,105,110,116,67,104,97,110,110,101,108,115,0,100,101,102,98,97, -115,101,0,109,111,100,105,102,105,101,114,115,0,100,108,111,99,91,51,93,0,111,114,105,103,91,51,93,0,100,115,105, -122,101,91,51,93,0,100,114,111,116,91,51,93,0,111,98,109,97,116,91,52,93,91,52,93,0,99,111,110,115,116,105, -110,118,91,52,93,91,52,93,0,108,97,121,0,99,111,108,98,105,116,115,0,116,114,97,110,115,102,108,97,103,0,105, -112,111,102,108,97,103,0,116,114,97,99,107,102,108,97,103,0,117,112,102,108,97,103,0,110,108,97,102,108,97,103,0, -112,114,111,116,101,99,116,102,108,97,103,0,105,112,111,119,105,110,0,115,99,97,102,108,97,103,0,115,99,97,118,105, -115,102,108,97,103,0,98,111,117,110,100,116,121,112,101,0,100,117,112,111,110,0,100,117,112,111,102,102,0,100,117,112, -115,116,97,0,100,117,112,101,110,100,0,115,102,0,99,116,105,109,101,0,109,97,115,115,0,100,97,109,112,105,110,103, -0,105,110,101,114,116,105,97,0,102,111,114,109,102,97,99,116,111,114,0,114,100,97,109,112,105,110,103,0,115,105,122, -101,102,97,99,0,109,97,114,103,105,110,0,109,97,120,95,118,101,108,0,109,105,110,95,118,101,108,0,109,95,99,111, -110,116,97,99,116,80,114,111,99,101,115,115,105,110,103,84,104,114,101,115,104,111,108,100,0,100,116,0,100,116,120,0, -97,99,116,99,111,108,0,101,109,112,116,121,95,100,114,97,119,116,121,112,101,0,112,97,100,49,91,51,93,0,101,109, -112,116,121,95,100,114,97,119,115,105,122,101,0,100,117,112,102,97,99,101,115,99,97,0,112,114,111,112,0,115,101,110, -115,111,114,115,0,99,111,110,116,114,111,108,108,101,114,115,0,97,99,116,117,97,116,111,114,115,0,98,98,115,105,122, -101,91,51,93,0,97,99,116,100,101,102,0,103,97,109,101,102,108,97,103,0,103,97,109,101,102,108,97,103,50,0,42, -98,115,111,102,116,0,115,111,102,116,102,108,97,103,0,97,110,105,115,111,116,114,111,112,105,99,70,114,105,99,116,105, -111,110,91,51,93,0,99,111,110,115,116,114,97,105,110,116,115,0,110,108,97,115,116,114,105,112,115,0,104,111,111,107, -115,0,112,97,114,116,105,99,108,101,115,121,115,116,101,109,0,42,112,100,0,42,115,111,102,116,0,42,100,117,112,95, -103,114,111,117,112,0,102,108,117,105,100,115,105,109,70,108,97,103,0,114,101,115,116,114,105,99,116,102,108,97,103,0, -115,104,97,112,101,110,114,0,115,104,97,112,101,102,108,97,103,0,114,101,99,97,108,99,111,0,98,111,100,121,95,116, -121,112,101,0,42,102,108,117,105,100,115,105,109,83,101,116,116,105,110,103,115,0,42,100,101,114,105,118,101,100,68,101, -102,111,114,109,0,42,100,101,114,105,118,101,100,70,105,110,97,108,0,108,97,115,116,68,97,116,97,77,97,115,107,0, -115,116,97,116,101,0,105,110,105,116,95,115,116,97,116,101,0,103,112,117,108,97,109,112,0,99,117,114,105,110,100,101, -120,0,97,99,116,105,118,101,0,100,101,102,108,101,99,116,0,102,111,114,99,101,102,105,101,108,100,0,112,100,101,102, -95,100,97,109,112,0,112,100,101,102,95,114,100,97,109,112,0,112,100,101,102,95,112,101,114,109,0,112,100,101,102,95, -102,114,105,99,116,0,112,100,101,102,95,114,102,114,105,99,116,0,102,95,115,116,114,101,110,103,116,104,0,102,95,112, -111,119,101,114,0,102,95,100,105,115,116,0,102,95,100,97,109,112,0,109,97,120,100,105,115,116,0,109,105,110,100,105, -115,116,0,109,97,120,114,97,100,0,109,105,110,114,97,100,0,102,95,112,111,119,101,114,95,114,0,112,100,101,102,95, -115,98,100,97,109,112,0,112,100,101,102,95,115,98,105,102,116,0,112,100,101,102,95,115,98,111,102,116,0,99,108,117, -109,112,95,102,97,99,0,99,108,117,109,112,95,112,111,119,0,107,105,110,107,95,102,114,101,113,0,107,105,110,107,95, -115,104,97,112,101,0,107,105,110,107,95,97,109,112,0,102,114,101,101,95,101,110,100,0,116,101,120,95,110,97,98,108, -97,0,116,101,120,95,109,111,100,101,0,107,105,110,107,0,107,105,110,107,95,97,120,105,115,0,114,116,50,0,42,114, -110,103,0,102,95,110,111,105,115,101,0,115,105,109,102,114,97,109,101,0,115,116,97,114,116,102,114,97,109,101,0,101, -110,100,102,114,97,109,101,0,101,100,105,116,102,114,97,109,101,0,108,105,110,83,116,105,102,102,0,97,110,103,83,116, -105,102,102,0,118,111,108,117,109,101,0,118,105,116,101,114,97,116,105,111,110,115,0,112,105,116,101,114,97,116,105,111, -110,115,0,100,105,116,101,114,97,116,105,111,110,115,0,99,105,116,101,114,97,116,105,111,110,115,0,107,83,82,72,82, -95,67,76,0,107,83,75,72,82,95,67,76,0,107,83,83,72,82,95,67,76,0,107,83,82,95,83,80,76,84,95,67, -76,0,107,83,75,95,83,80,76,84,95,67,76,0,107,83,83,95,83,80,76,84,95,67,76,0,107,86,67,70,0,107, -68,80,0,107,68,71,0,107,76,70,0,107,80,82,0,107,86,67,0,107,68,70,0,107,77,84,0,107,67,72,82,0, -107,75,72,82,0,107,83,72,82,0,107,65,72,82,0,99,111,108,108,105,115,105,111,110,102,108,97,103,115,0,110,117, -109,99,108,117,115,116,101,114,105,116,101,114,97,116,105,111,110,115,0,119,101,108,100,105,110,103,0,42,112,97,114,116, -105,99,108,101,115,0,116,111,116,112,111,105,110,116,0,116,111,116,115,112,114,105,110,103,0,42,98,112,111,105,110,116, -0,42,98,115,112,114,105,110,103,0,109,115,103,95,108,111,99,107,0,109,115,103,95,118,97,108,117,101,0,110,111,100, -101,109,97,115,115,0,110,97,109,101,100,86,71,95,77,97,115,115,91,51,50,93,0,103,114,97,118,0,109,101,100,105, -97,102,114,105,99,116,0,114,107,108,105,109,105,116,0,112,104,121,115,105,99,115,95,115,112,101,101,100,0,103,111,97, -108,115,112,114,105,110,103,0,103,111,97,108,102,114,105,99,116,0,109,105,110,103,111,97,108,0,109,97,120,103,111,97, -108,0,100,101,102,103,111,97,108,0,118,101,114,116,103,114,111,117,112,0,110,97,109,101,100,86,71,95,83,111,102,116, -103,111,97,108,91,51,50,93,0,102,117,122,122,121,110,101,115,115,0,105,110,115,112,114,105,110,103,0,105,110,102,114, -105,99,116,0,110,97,109,101,100,86,71,95,83,112,114,105,110,103,95,75,91,51,50,93,0,101,102,114,97,0,105,110, -116,101,114,118,97,108,0,108,111,99,97,108,0,115,111,108,118,101,114,102,108,97,103,115,0,42,42,107,101,121,115,0, -116,111,116,112,111,105,110,116,107,101,121,0,115,101,99,111,110,100,115,112,114,105,110,103,0,99,111,108,98,97,108,108, -0,98,97,108,108,100,97,109,112,0,98,97,108,108,115,116,105,102,102,0,115,98,99,95,109,111,100,101,0,97,101,114, -111,101,100,103,101,0,109,105,110,108,111,111,112,115,0,109,97,120,108,111,111,112,115,0,99,104,111,107,101,0,115,111, -108,118,101,114,95,73,68,0,112,108,97,115,116,105,99,0,115,112,114,105,110,103,112,114,101,108,111,97,100,0,42,115, -99,114,97,116,99,104,0,115,104,101,97,114,115,116,105,102,102,0,105,110,112,117,115,104,0,42,112,111,105,110,116,99, -97,99,104,101,0,115,104,111,119,95,97,100,118,97,110,99,101,100,111,112,116,105,111,110,115,0,114,101,115,111,108,117, -116,105,111,110,120,121,122,0,112,114,101,118,105,101,119,114,101,115,120,121,122,0,114,101,97,108,115,105,122,101,0,103, -117,105,68,105,115,112,108,97,121,77,111,100,101,0,114,101,110,100,101,114,68,105,115,112,108,97,121,77,111,100,101,0, -118,105,115,99,111,115,105,116,121,86,97,108,117,101,0,118,105,115,99,111,115,105,116,121,77,111,100,101,0,118,105,115, -99,111,115,105,116,121,69,120,112,111,110,101,110,116,0,103,114,97,118,120,0,103,114,97,118,121,0,103,114,97,118,122, -0,97,110,105,109,83,116,97,114,116,0,97,110,105,109,69,110,100,0,103,115,116,97,114,0,109,97,120,82,101,102,105, -110,101,0,105,110,105,86,101,108,120,0,105,110,105,86,101,108,121,0,105,110,105,86,101,108,122,0,42,111,114,103,77, -101,115,104,0,42,109,101,115,104,83,117,114,102,97,99,101,0,42,109,101,115,104,66,66,0,115,117,114,102,100,97,116, -97,80,97,116,104,91,50,52,48,93,0,98,98,83,116,97,114,116,91,51,93,0,98,98,83,105,122,101,91,51,93,0, -116,121,112,101,70,108,97,103,115,0,100,111,109,97,105,110,78,111,118,101,99,103,101,110,0,118,111,108,117,109,101,73, -110,105,116,84,121,112,101,0,112,97,114,116,83,108,105,112,86,97,108,117,101,0,103,101,110,101,114,97,116,101,84,114, -97,99,101,114,115,0,103,101,110,101,114,97,116,101,80,97,114,116,105,99,108,101,115,0,115,117,114,102,97,99,101,83, -109,111,111,116,104,105,110,103,0,115,117,114,102,97,99,101,83,117,98,100,105,118,115,0,112,97,114,116,105,99,108,101, -73,110,102,83,105,122,101,0,112,97,114,116,105,99,108,101,73,110,102,65,108,112,104,97,0,102,97,114,70,105,101,108, -100,83,105,122,101,0,42,109,101,115,104,83,117,114,102,78,111,114,109,97,108,115,0,99,112,115,84,105,109,101,83,116, -97,114,116,0,99,112,115,84,105,109,101,69,110,100,0,99,112,115,81,117,97,108,105,116,121,0,97,116,116,114,97,99, -116,102,111,114,99,101,83,116,114,101,110,103,116,104,0,97,116,116,114,97,99,116,102,111,114,99,101,82,97,100,105,117, -115,0,118,101,108,111,99,105,116,121,102,111,114,99,101,83,116,114,101,110,103,116,104,0,118,101,108,111,99,105,116,121, -102,111,114,99,101,82,97,100,105,117,115,0,108,97,115,116,103,111,111,100,102,114,97,109,101,0,109,105,115,116,121,112, -101,0,104,111,114,114,0,104,111,114,103,0,104,111,114,98,0,104,111,114,107,0,122,101,110,114,0,122,101,110,103,0, -122,101,110,98,0,122,101,110,107,0,97,109,98,107,0,102,97,115,116,99,111,108,0,101,120,112,111,115,117,114,101,0, -101,120,112,0,114,97,110,103,101,0,108,105,110,102,97,99,0,108,111,103,102,97,99,0,103,114,97,118,105,116,121,0, -97,99,116,105,118,105,116,121,66,111,120,82,97,100,105,117,115,0,115,107,121,116,121,112,101,0,111,99,99,108,117,115, -105,111,110,82,101,115,0,112,104,121,115,105,99,115,69,110,103,105,110,101,0,116,105,99,114,97,116,101,0,109,97,120, -108,111,103,105,99,115,116,101,112,0,112,104,121,115,117,98,115,116,101,112,0,109,97,120,112,104,121,115,116,101,112,0, -109,105,115,105,0,109,105,115,116,115,116,97,0,109,105,115,116,100,105,115,116,0,109,105,115,116,104,105,0,115,116,97, -114,114,0,115,116,97,114,103,0,115,116,97,114,98,0,115,116,97,114,107,0,115,116,97,114,115,105,122,101,0,115,116, -97,114,109,105,110,100,105,115,116,0,115,116,97,114,100,105,115,116,0,115,116,97,114,99,111,108,110,111,105,115,101,0, -100,111,102,115,116,97,0,100,111,102,101,110,100,0,100,111,102,109,105,110,0,100,111,102,109,97,120,0,97,111,100,105, -115,116,0,97,111,100,105,115,116,102,97,99,0,97,111,101,110,101,114,103,121,0,97,111,98,105,97,115,0,97,111,109, -111,100,101,0,97,111,115,97,109,112,0,97,111,109,105,120,0,97,111,99,111,108,111,114,0,97,111,95,97,100,97,112, -116,95,116,104,114,101,115,104,0,97,111,95,97,100,97,112,116,95,115,112,101,101,100,95,102,97,99,0,97,111,95,97, -112,112,114,111,120,95,101,114,114,111,114,0,97,111,95,97,112,112,114,111,120,95,99,111,114,114,101,99,116,105,111,110, -0,97,111,95,115,97,109,112,95,109,101,116,104,111,100,0,97,111,95,103,97,116,104,101,114,95,109,101,116,104,111,100, -0,97,111,95,97,112,112,114,111,120,95,112,97,115,115,101,115,0,42,97,111,115,112,104,101,114,101,0,42,97,111,116, -97,98,108,101,115,0,104,101,109,105,114,101,115,0,109,97,120,105,116,101,114,0,100,114,97,119,116,121,112,101,0,115, -117,98,115,104,111,111,116,112,0,115,117,98,115,104,111,111,116,101,0,110,111,100,101,108,105,109,0,109,97,120,115,117, -98,108,97,109,112,0,112,97,109,97,0,112,97,109,105,0,101,108,109,97,0,101,108,109,105,0,109,97,120,110,111,100, -101,0,99,111,110,118,101,114,103,101,110,99,101,0,114,97,100,102,97,99,0,103,97,109,109,97,0,115,101,108,99,111, -108,0,115,120,0,115,121,0,42,108,112,70,111,114,109,97,116,0,42,108,112,80,97,114,109,115,0,99,98,70,111,114, -109,97,116,0,99,98,80,97,114,109,115,0,102,99,99,84,121,112,101,0,102,99,99,72,97,110,100,108,101,114,0,100, -119,75,101,121,70,114,97,109,101,69,118,101,114,121,0,100,119,81,117,97,108,105,116,121,0,100,119,66,121,116,101,115, -80,101,114,83,101,99,111,110,100,0,100,119,70,108,97,103,115,0,100,119,73,110,116,101,114,108,101,97,118,101,69,118, -101,114,121,0,97,118,105,99,111,100,101,99,110,97,109,101,91,49,50,56,93,0,42,99,100,80,97,114,109,115,0,42, -112,97,100,0,99,100,83,105,122,101,0,113,116,99,111,100,101,99,110,97,109,101,91,49,50,56,93,0,99,111,100,101, -99,0,97,117,100,105,111,95,99,111,100,101,99,0,118,105,100,101,111,95,98,105,116,114,97,116,101,0,97,117,100,105, -111,95,98,105,116,114,97,116,101,0,103,111,112,95,115,105,122,101,0,114,99,95,109,105,110,95,114,97,116,101,0,114, -99,95,109,97,120,95,114,97,116,101,0,114,99,95,98,117,102,102,101,114,95,115,105,122,101,0,109,117,120,95,112,97, -99,107,101,116,95,115,105,122,101,0,109,117,120,95,114,97,116,101,0,109,105,120,114,97,116,101,0,109,97,105,110,0, -42,109,97,116,95,111,118,101,114,114,105,100,101,0,42,108,105,103,104,116,95,111,118,101,114,114,105,100,101,0,108,97, -121,95,122,109,97,115,107,0,108,97,121,102,108,97,103,0,112,97,115,115,102,108,97,103,0,112,97,115,115,95,120,111, -114,0,42,97,118,105,99,111,100,101,99,100,97,116,97,0,42,113,116,99,111,100,101,99,100,97,116,97,0,102,102,99, -111,100,101,99,100,97,116,97,0,99,102,114,97,0,112,115,102,114,97,0,112,101,102,114,97,0,105,109,97,103,101,115, -0,102,114,97,109,97,112,116,111,0,116,104,114,101,97,100,115,0,102,114,97,109,101,108,101,110,0,98,108,117,114,102, -97,99,0,101,100,103,101,82,0,101,100,103,101,71,0,101,100,103,101,66,0,102,117,108,108,115,99,114,101,101,110,0, -120,112,108,97,121,0,121,112,108,97,121,0,102,114,101,113,112,108,97,121,0,97,116,116,114,105,98,0,114,116,49,0, -115,116,101,114,101,111,109,111,100,101,0,100,105,109,101,110,115,105,111,110,115,112,114,101,115,101,116,0,109,97,120,105, -109,115,105,122,101,0,120,115,99,104,0,121,115,99,104,0,120,112,97,114,116,115,0,121,112,97,114,116,115,0,119,105, -110,112,111,115,0,112,108,97,110,101,115,0,105,109,116,121,112,101,0,115,117,98,105,109,116,121,112,101,0,113,117,97, -108,105,116,121,0,114,112,97,100,0,114,112,97,100,49,0,114,112,97,100,50,0,115,99,101,109,111,100,101,0,114,101, -110,100,101,114,101,114,0,111,99,114,101,115,0,97,108,112,104,97,109,111,100,101,0,111,115,97,0,102,114,115,95,115, -101,99,0,101,100,103,101,105,110,116,0,115,97,102,101,116,121,0,98,111,114,100,101,114,0,100,105,115,112,114,101,99, -116,0,108,97,121,101,114,115,0,97,99,116,108,97,121,0,120,97,115,112,0,121,97,115,112,0,102,114,115,95,115,101, -99,95,98,97,115,101,0,103,97,117,115,115,0,112,111,115,116,109,117,108,0,112,111,115,116,103,97,109,109,97,0,112, -111,115,116,104,117,101,0,112,111,115,116,115,97,116,0,100,105,116,104,101,114,95,105,110,116,101,110,115,105,116,121,0, -98,97,107,101,95,111,115,97,0,98,97,107,101,95,102,105,108,116,101,114,0,98,97,107,101,95,109,111,100,101,0,98, -97,107,101,95,102,108,97,103,0,98,97,107,101,95,110,111,114,109,97,108,95,115,112,97,99,101,0,98,97,107,101,95, -113,117,97,100,95,115,112,108,105,116,0,98,97,107,101,95,109,97,120,100,105,115,116,0,98,97,107,101,95,98,105,97, -115,100,105,115,116,0,98,97,107,101,95,112,97,100,0,71,73,113,117,97,108,105,116,121,0,71,73,99,97,99,104,101, -0,71,73,109,101,116,104,111,100,0,71,73,112,104,111,116,111,110,115,0,71,73,100,105,114,101,99,116,0,89,70,95, -65,65,0,89,70,101,120,112,111,114,116,120,109,108,0,89,70,95,110,111,98,117,109,112,0,89,70,95,99,108,97,109, -112,114,103,98,0,121,102,112,97,100,49,0,71,73,100,101,112,116,104,0,71,73,99,97,117,115,100,101,112,116,104,0, -71,73,112,105,120,101,108,115,112,101,114,115,97,109,112,108,101,0,71,73,112,104,111,116,111,110,99,111,117,110,116,0, -71,73,109,105,120,112,104,111,116,111,110,115,0,71,73,112,104,111,116,111,110,114,97,100,105,117,115,0,89,70,95,114, -97,121,100,101,112,116,104,0,89,70,95,65,65,112,97,115,115,101,115,0,89,70,95,65,65,115,97,109,112,108,101,115, -0,121,102,112,97,100,50,0,71,73,115,104,97,100,111,119,113,117,97,108,105,116,121,0,71,73,114,101,102,105,110,101, -109,101,110,116,0,71,73,112,111,119,101,114,0,71,73,105,110,100,105,114,112,111,119,101,114,0,89,70,95,103,97,109, -109,97,0,89,70,95,101,120,112,111,115,117,114,101,0,89,70,95,114,97,121,98,105,97,115,0,89,70,95,65,65,112, -105,120,101,108,115,105,122,101,0,89,70,95,65,65,116,104,114,101,115,104,111,108,100,0,98,97,99,107,98,117,102,91, -49,54,48,93,0,112,105,99,91,49,54,48,93,0,115,116,97,109,112,0,115,116,97,109,112,95,102,111,110,116,95,105, -100,0,115,116,97,109,112,95,117,100,97,116,97,91,49,54,48,93,0,102,103,95,115,116,97,109,112,91,52,93,0,98, -103,95,115,116,97,109,112,91,52,93,0,115,105,109,112,108,105,102,121,95,115,117,98,115,117,114,102,0,115,105,109,112, -108,105,102,121,95,115,104,97,100,111,119,115,97,109,112,108,101,115,0,115,105,109,112,108,105,102,121,95,112,97,114,116, -105,99,108,101,115,0,115,105,109,112,108,105,102,121,95,97,111,115,115,115,0,99,105,110,101,111,110,119,104,105,116,101, -0,99,105,110,101,111,110,98,108,97,99,107,0,99,105,110,101,111,110,103,97,109,109,97,0,106,112,50,95,112,114,101, -115,101,116,0,106,112,50,95,100,101,112,116,104,0,114,112,97,100,51,0,100,111,109,101,114,101,115,0,100,111,109,101, -109,111,100,101,0,100,111,109,101,97,110,103,108,101,0,100,111,109,101,116,105,108,116,0,100,111,109,101,114,101,115,98, -117,102,0,42,100,111,109,101,116,101,120,116,0,112,97,114,116,105,99,108,101,95,112,101,114,99,0,115,117,98,115,117, -114,102,95,109,97,120,0,115,104,97,100,98,117,102,115,97,109,112,108,101,95,109,97,120,0,97,111,95,101,114,114,111, -114,0,99,111,108,91,51,93,0,102,114,97,109,101,0,110,97,109,101,91,54,52,93,0,42,98,114,117,115,104,0,116, -111,111,108,0,115,101,97,109,95,98,108,101,101,100,0,110,111,114,109,97,108,95,97,110,103,108,101,0,115,116,101,112, -0,105,110,118,101,114,116,0,116,111,116,114,101,107,101,121,0,116,111,116,97,100,100,107,101,121,0,98,114,117,115,104, -116,121,112,101,0,98,114,117,115,104,91,55,93,0,101,109,105,116,116,101,114,100,105,115,116,0,100,114,97,119,95,116, -105,109,101,100,0,110,97,109,101,91,51,54,93,0,109,97,116,91,51,93,91,51,93,0,99,111,114,110,101,114,116,121, -112,101,0,101,100,105,116,98,117,116,102,108,97,103,0,106,111,105,110,116,114,105,108,105,109,105,116,0,100,101,103,114, -0,116,117,114,110,0,101,120,116,114,95,111,102,102,115,0,100,111,117,98,108,105,109,105,116,0,115,101,103,109,101,110, -116,115,0,114,105,110,103,115,0,118,101,114,116,105,99,101,115,0,117,110,119,114,97,112,112,101,114,0,117,118,99,97, -108,99,95,114,97,100,105,117,115,0,117,118,99,97,108,99,95,99,117,98,101,115,105,122,101,0,117,118,99,97,108,99, -95,109,97,114,103,105,110,0,117,118,99,97,108,99,95,109,97,112,100,105,114,0,117,118,99,97,108,99,95,109,97,112, -97,108,105,103,110,0,117,118,99,97,108,99,95,102,108,97,103,0,97,117,116,111,105,107,95,99,104,97,105,110,108,101, -110,0,105,109,97,112,97,105,110,116,0,112,97,114,116,105,99,108,101,0,115,101,108,101,99,116,95,116,104,114,101,115, -104,0,99,108,101,97,110,95,116,104,114,101,115,104,0,114,101,116,111,112,111,95,109,111,100,101,0,114,101,116,111,112, -111,95,112,97,105,110,116,95,116,111,111,108,0,108,105,110,101,95,100,105,118,0,101,108,108,105,112,115,101,95,100,105, -118,0,114,101,116,111,112,111,95,104,111,116,115,112,111,116,0,109,117,108,116,105,114,101,115,95,115,117,98,100,105,118, -95,116,121,112,101,0,115,107,103,101,110,95,114,101,115,111,108,117,116,105,111,110,0,115,107,103,101,110,95,116,104,114, -101,115,104,111,108,100,95,105,110,116,101,114,110,97,108,0,115,107,103,101,110,95,116,104,114,101,115,104,111,108,100,95, -101,120,116,101,114,110,97,108,0,115,107,103,101,110,95,108,101,110,103,116,104,95,114,97,116,105,111,0,115,107,103,101, -110,95,108,101,110,103,116,104,95,108,105,109,105,116,0,115,107,103,101,110,95,97,110,103,108,101,95,108,105,109,105,116, -0,115,107,103,101,110,95,99,111,114,114,101,108,97,116,105,111,110,95,108,105,109,105,116,0,115,107,103,101,110,95,115, -121,109,109,101,116,114,121,95,108,105,109,105,116,0,115,107,103,101,110,95,114,101,116,97,114,103,101,116,95,97,110,103, -108,101,95,119,101,105,103,104,116,0,115,107,103,101,110,95,114,101,116,97,114,103,101,116,95,108,101,110,103,116,104,95, -119,101,105,103,104,116,0,115,107,103,101,110,95,114,101,116,97,114,103,101,116,95,100,105,115,116,97,110,99,101,95,119, -101,105,103,104,116,0,115,107,103,101,110,95,111,112,116,105,111,110,115,0,115,107,103,101,110,95,112,111,115,116,112,114, -111,0,115,107,103,101,110,95,112,111,115,116,112,114,111,95,112,97,115,115,101,115,0,115,107,103,101,110,95,115,117,98, -100,105,118,105,115,105,111,110,115,91,51,93,0,115,107,103,101,110,95,109,117,108,116,105,95,108,101,118,101,108,0,42, -115,107,103,101,110,95,116,101,109,112,108,97,116,101,0,98,111,110,101,95,115,107,101,116,99,104,105,110,103,0,98,111, -110,101,95,115,107,101,116,99,104,105,110,103,95,99,111,110,118,101,114,116,0,115,107,103,101,110,95,115,117,98,100,105, -118,105,115,105,111,110,95,110,117,109,98,101,114,0,115,107,103,101,110,95,114,101,116,97,114,103,101,116,95,111,112,116, -105,111,110,115,0,115,107,103,101,110,95,114,101,116,97,114,103,101,116,95,114,111,108,108,0,115,107,103,101,110,95,115, -105,100,101,95,115,116,114,105,110,103,91,56,93,0,115,107,103,101,110,95,110,117,109,95,115,116,114,105,110,103,91,56, -93,0,101,100,103,101,95,109,111,100,101,0,112,97,100,51,91,50,93,0,100,105,114,0,118,105,101,119,0,42,115,101, -115,115,105,111,110,0,42,99,117,109,97,112,0,100,114,97,119,98,114,117,115,104,0,115,109,111,111,116,104,98,114,117, -115,104,0,112,105,110,99,104,98,114,117,115,104,0,105,110,102,108,97,116,101,98,114,117,115,104,0,103,114,97,98,98, -114,117,115,104,0,108,97,121,101,114,98,114,117,115,104,0,102,108,97,116,116,101,110,98,114,117,115,104,0,112,105,118, -111,116,91,51,93,0,98,114,117,115,104,95,116,121,112,101,0,116,101,120,110,114,0,116,101,120,114,101,112,116,0,116, -101,120,102,97,100,101,0,116,101,120,115,101,112,0,97,118,101,114,97,103,105,110,103,0,116,97,98,108,101,116,95,115, -105,122,101,0,116,97,98,108,101,116,95,115,116,114,101,110,103,116,104,0,115,121,109,109,0,114,97,107,101,0,97,120, -105,115,108,111,99,107,0,42,99,97,109,101,114,97,0,42,119,111,114,108,100,0,42,115,101,116,0,98,97,115,101,0, -42,98,97,115,97,99,116,0,99,117,114,115,111,114,91,51,93,0,116,119,99,101,110,116,91,51,93,0,116,119,109,105, -110,91,51,93,0,116,119,109,97,120,91,51,93,0,101,100,105,116,98,117,116,115,105,122,101,0,115,101,108,101,99,116, -109,111,100,101,0,112,114,111,112,111,114,116,105,111,110,97,108,0,112,114,111,112,95,109,111,100,101,0,97,117,116,111, -109,101,114,103,101,0,112,97,100,53,0,112,97,100,54,0,97,117,116,111,107,101,121,95,109,111,100,101,0,42,101,100, -0,42,114,97,100,105,111,0,102,114,97,109,105,110,103,0,42,116,111,111,108,115,101,116,116,105,110,103,115,0,97,117, -100,105,111,0,116,114,97,110,115,102,111,114,109,95,115,112,97,99,101,115,0,106,117,109,112,102,114,97,109,101,0,115, -110,97,112,95,109,111,100,101,0,115,110,97,112,95,102,108,97,103,0,115,110,97,112,95,116,97,114,103,101,116,0,42, -116,104,101,68,97,103,0,100,97,103,105,115,118,97,108,105,100,0,100,97,103,102,108,97,103,115,0,115,99,117,108,112, -116,100,97,116,97,0,102,114,97,109,101,95,115,116,101,112,0,122,111,111,109,0,98,108,101,110,100,0,120,105,109,0, -121,105,109,0,115,112,97,99,101,116,121,112,101,0,98,108,111,99,107,115,99,97,108,101,0,42,97,114,101,97,0,98, -108,111,99,107,104,97,110,100,108,101,114,91,56,93,0,118,105,101,119,109,97,116,91,52,93,91,52,93,0,118,105,101, -119,105,110,118,91,52,93,91,52,93,0,112,101,114,115,109,97,116,91,52,93,91,52,93,0,112,101,114,115,105,110,118, -91,52,93,91,52,93,0,119,105,110,109,97,116,49,91,52,93,91,52,93,0,118,105,101,119,109,97,116,49,91,52,93, -91,52,93,0,118,105,101,119,113,117,97,116,91,52,93,0,122,102,97,99,0,108,97,121,95,117,115,101,100,0,112,101, -114,115,112,0,42,111,98,95,99,101,110,116,114,101,0,42,98,103,112,105,99,0,42,108,111,99,97,108,118,100,0,42, -114,105,0,42,114,101,116,111,112,111,95,118,105,101,119,95,100,97,116,97,0,42,100,101,112,116,104,115,0,111,98,95, -99,101,110,116,114,101,95,98,111,110,101,91,51,50,93,0,108,111,99,97,108,118,105,101,119,0,108,97,121,97,99,116, -0,115,99,101,110,101,108,111,99,107,0,97,114,111,117,110,100,0,99,97,109,122,111,111,109,0,112,105,118,111,116,95, -108,97,115,116,0,103,114,105,100,0,103,114,105,100,118,105,101,119,0,112,105,120,115,105,122,101,0,110,101,97,114,0, -102,97,114,0,99,97,109,100,120,0,99,97,109,100,121,0,103,114,105,100,108,105,110,101,115,0,118,105,101,119,98,117, -116,0,103,114,105,100,102,108,97,103,0,109,111,100,101,115,101,108,101,99,116,0,116,119,116,121,112,101,0,116,119,109, -111,100,101,0,116,119,102,108,97,103,0,116,119,100,114,97,119,102,108,97,103,0,116,119,109,97,116,91,52,93,91,52, -93,0,99,108,105,112,91,52,93,91,52,93,0,42,99,108,105,112,98,98,0,97,102,116,101,114,100,114,97,119,0,122, -98,117,102,0,120,114,97,121,0,102,108,97,103,50,0,103,114,105,100,115,117,98,100,105,118,0,107,101,121,102,108,97, -103,115,0,110,100,111,102,109,111,100,101,0,110,100,111,102,102,105,108,116,101,114,0,42,112,114,111,112,101,114,116,105, -101,115,95,115,116,111,114,97,103,101,0,42,103,112,100,0,108,118,105,101,119,113,117,97,116,91,52,93,0,108,112,101, -114,115,112,0,108,118,105,101,119,0,118,101,114,116,0,104,111,114,0,109,97,115,107,0,109,105,110,91,50,93,0,109, -97,120,91,50,93,0,109,105,110,122,111,111,109,0,109,97,120,122,111,111,109,0,115,99,114,111,108,108,0,107,101,101, -112,116,111,116,0,107,101,101,112,97,115,112,101,99,116,0,107,101,101,112,122,111,111,109,0,111,108,100,119,105,110,120, -0,111,108,100,119,105,110,121,0,99,117,114,115,111,114,91,50,93,0,114,111,119,98,117,116,0,118,50,100,0,42,101, -100,105,116,105,112,111,0,105,112,111,107,101,121,0,97,99,116,110,97,109,101,91,51,50,93,0,99,111,110,115,116,110, -97,109,101,91,51,50,93,0,98,111,110,101,110,97,109,101,91,51,50,93,0,116,111,116,105,112,111,0,112,105,110,0, -98,117,116,111,102,115,0,99,104,97,110,110,101,108,0,108,111,99,107,0,109,101,100,105,97,110,91,51,93,0,99,117, -114,115,101,110,115,0,99,117,114,97,99,116,0,97,108,105,103,110,0,116,97,98,111,0,109,97,105,110,98,0,109,97, -105,110,98,111,0,42,108,111,99,107,112,111,105,110,0,116,101,120,102,114,111,109,0,115,104,111,119,103,114,111,117,112, -0,109,111,100,101,108,116,121,112,101,0,115,99,114,105,112,116,98,108,111,99,107,0,114,101,95,97,108,105,103,110,0, -111,108,100,107,101,121,112,114,101,115,115,0,116,97,98,91,55,93,0,114,101,110,100,101,114,95,115,105,122,101,0,99, -104,97,110,115,104,111,119,110,0,122,101,98,114,97,0,42,102,105,108,101,108,105,115,116,0,116,111,116,102,105,108,101, -0,116,105,116,108,101,91,50,52,93,0,100,105,114,91,50,52,48,93,0,102,105,108,101,91,56,48,93,0,111,102,115, -0,115,111,114,116,0,109,97,120,110,97,109,101,108,101,110,0,99,111,108,108,117,109,115,0,102,95,102,112,0,102,112, -95,115,116,114,91,56,93,0,42,108,105,98,102,105,108,101,100,97,116,97,0,114,101,116,118,97,108,0,109,101,110,117, -0,97,99,116,0,40,42,114,101,116,117,114,110,102,117,110,99,41,40,41,0,40,42,114,101,116,117,114,110,102,117,110, -99,95,101,118,101,110,116,41,40,41,0,40,42,114,101,116,117,114,110,102,117,110,99,95,97,114,103,115,41,40,41,0, -42,97,114,103,49,0,42,97,114,103,50,0,42,109,101,110,117,112,0,42,112,117,112,109,101,110,117,0,111,111,112,115, -0,118,105,115,105,102,108,97,103,0,116,114,101,101,0,42,116,114,101,101,115,116,111,114,101,0,115,101,97,114,99,104, -95,115,116,114,105,110,103,91,51,50,93,0,115,101,97,114,99,104,95,116,115,101,0,115,101,97,114,99,104,95,102,108, -97,103,115,0,100,111,95,0,111,117,116,108,105,110,101,118,105,115,0,115,116,111,114,101,102,108,97,103,0,100,101,112, -115,95,102,108,97,103,115,0,105,109,97,110,114,0,99,117,114,116,105,108,101,0,105,109,116,121,112,101,110,114,0,100, -116,95,117,118,0,115,116,105,99,107,121,0,100,116,95,117,118,115,116,114,101,116,99,104,0,112,97,100,91,53,93,0, -99,101,110,116,120,0,99,101,110,116,121,0,97,117,116,111,115,110,97,112,0,42,116,101,120,116,0,116,111,112,0,118, -105,101,119,108,105,110,101,115,0,102,111,110,116,95,105,100,0,108,104,101,105,103,104,116,0,108,101,102,116,0,115,104, -111,119,108,105,110,101,110,114,115,0,116,97,98,110,117,109,98,101,114,0,99,117,114,114,116,97,98,95,115,101,116,0, -115,104,111,119,115,121,110,116,97,120,0,111,118,101,114,119,114,105,116,101,0,112,105,120,95,112,101,114,95,108,105,110, -101,0,116,120,116,115,99,114,111,108,108,0,116,120,116,98,97,114,0,119,111,114,100,119,114,97,112,0,100,111,112,108, -117,103,105,110,115,0,42,112,121,95,100,114,97,119,0,42,112,121,95,101,118,101,110,116,0,42,112,121,95,98,117,116, -116,111,110,0,42,112,121,95,98,114,111,119,115,101,114,99,97,108,108,98,97,99,107,0,42,112,121,95,103,108,111,98, -97,108,100,105,99,116,0,108,97,115,116,115,112,97,99,101,0,115,99,114,105,112,116,110,97,109,101,91,50,53,54,93, -0,115,99,114,105,112,116,97,114,103,91,50,53,54,93,0,42,115,99,114,105,112,116,0,42,98,117,116,95,114,101,102, -115,0,114,101,100,114,97,119,115,0,42,105,100,0,97,115,112,101,99,116,0,42,99,117,114,102,111,110,116,0,42,101, -100,105,116,116,114,101,101,0,116,114,101,101,116,121,112,101,0,42,102,105,108,101,115,0,97,99,116,105,118,101,95,102, -105,108,101,0,110,117,109,116,105,108,101,115,120,0,110,117,109,116,105,108,101,115,121,0,115,101,108,115,116,97,116,101, -0,118,105,101,119,114,101,99,116,0,98,111,111,107,109,97,114,107,114,101,99,116,0,115,99,114,111,108,108,112,111,115, -0,115,99,114,111,108,108,104,101,105,103,104,116,0,115,99,114,111,108,108,97,114,101,97,0,97,99,116,105,118,101,95, -98,111,111,107,109,97,114,107,0,112,114,118,95,119,0,112,114,118,95,104,0,42,105,109,103,0,111,117,116,108,105,110, -101,91,52,93,0,110,101,117,116,114,97,108,91,52,93,0,97,99,116,105,111,110,91,52,93,0,115,101,116,116,105,110, -103,91,52,93,0,115,101,116,116,105,110,103,49,91,52,93,0,115,101,116,116,105,110,103,50,91,52,93,0,110,117,109, -91,52,93,0,116,101,120,116,102,105,101,108,100,91,52,93,0,116,101,120,116,102,105,101,108,100,95,104,105,91,52,93, -0,112,111,112,117,112,91,52,93,0,116,101,120,116,91,52,93,0,116,101,120,116,95,104,105,91,52,93,0,109,101,110, -117,95,98,97,99,107,91,52,93,0,109,101,110,117,95,105,116,101,109,91,52,93,0,109,101,110,117,95,104,105,108,105, -116,101,91,52,93,0,109,101,110,117,95,116,101,120,116,91,52,93,0,109,101,110,117,95,116,101,120,116,95,104,105,91, -52,93,0,98,117,116,95,100,114,97,119,116,121,112,101,0,105,99,111,110,102,105,108,101,91,56,48,93,0,98,97,99, -107,91,52,93,0,104,101,97,100,101,114,91,52,93,0,112,97,110,101,108,91,52,93,0,115,104,97,100,101,49,91,52, -93,0,115,104,97,100,101,50,91,52,93,0,104,105,108,105,116,101,91,52,93,0,103,114,105,100,91,52,93,0,119,105, -114,101,91,52,93,0,115,101,108,101,99,116,91,52,93,0,108,97,109,112,91,52,93,0,97,99,116,105,118,101,91,52, -93,0,103,114,111,117,112,91,52,93,0,103,114,111,117,112,95,97,99,116,105,118,101,91,52,93,0,116,114,97,110,115, -102,111,114,109,91,52,93,0,118,101,114,116,101,120,91,52,93,0,118,101,114,116,101,120,95,115,101,108,101,99,116,91, -52,93,0,101,100,103,101,91,52,93,0,101,100,103,101,95,115,101,108,101,99,116,91,52,93,0,101,100,103,101,95,115, -101,97,109,91,52,93,0,101,100,103,101,95,115,104,97,114,112,91,52,93,0,101,100,103,101,95,102,97,99,101,115,101, -108,91,52,93,0,102,97,99,101,91,52,93,0,102,97,99,101,95,115,101,108,101,99,116,91,52,93,0,102,97,99,101, -95,100,111,116,91,52,93,0,110,111,114,109,97,108,91,52,93,0,98,111,110,101,95,115,111,108,105,100,91,52,93,0, -98,111,110,101,95,112,111,115,101,91,52,93,0,115,116,114,105,112,91,52,93,0,115,116,114,105,112,95,115,101,108,101, -99,116,91,52,93,0,99,102,114,97,109,101,91,52,93,0,118,101,114,116,101,120,95,115,105,122,101,0,102,97,99,101, -100,111,116,95,115,105,122,101,0,98,112,97,100,91,50,93,0,115,121,110,116,97,120,108,91,52,93,0,115,121,110,116, -97,120,110,91,52,93,0,115,121,110,116,97,120,98,91,52,93,0,115,121,110,116,97,120,118,91,52,93,0,115,121,110, -116,97,120,99,91,52,93,0,109,111,118,105,101,91,52,93,0,105,109,97,103,101,91,52,93,0,115,99,101,110,101,91, -52,93,0,97,117,100,105,111,91,52,93,0,101,102,102,101,99,116,91,52,93,0,112,108,117,103,105,110,91,52,93,0, -116,114,97,110,115,105,116,105,111,110,91,52,93,0,109,101,116,97,91,52,93,0,101,100,105,116,109,101,115,104,95,97, -99,116,105,118,101,91,52,93,0,104,97,110,100,108,101,95,118,101,114,116,101,120,91,52,93,0,104,97,110,100,108,101, -95,118,101,114,116,101,120,95,115,101,108,101,99,116,91,52,93,0,104,97,110,100,108,101,95,118,101,114,116,101,120,95, -115,105,122,101,0,104,112,97,100,91,55,93,0,115,111,108,105,100,91,52,93,0,116,117,105,0,116,98,117,116,115,0, -116,118,51,100,0,116,102,105,108,101,0,116,105,112,111,0,116,105,110,102,111,0,116,115,110,100,0,116,97,99,116,0, -116,110,108,97,0,116,115,101,113,0,116,105,109,97,0,116,105,109,97,115,101,108,0,116,101,120,116,0,116,111,111,112, -115,0,116,116,105,109,101,0,116,110,111,100,101,0,116,97,114,109,91,50,48,93,0,98,112,97,100,91,52,93,0,98, -112,97,100,49,91,52,93,0,115,112,101,99,91,52,93,0,100,117,112,102,108,97,103,0,115,97,118,101,116,105,109,101, -0,116,101,109,112,100,105,114,91,49,54,48,93,0,102,111,110,116,100,105,114,91,49,54,48,93,0,114,101,110,100,101, -114,100,105,114,91,49,54,48,93,0,116,101,120,116,117,100,105,114,91,49,54,48,93,0,112,108,117,103,116,101,120,100, -105,114,91,49,54,48,93,0,112,108,117,103,115,101,113,100,105,114,91,49,54,48,93,0,112,121,116,104,111,110,100,105, -114,91,49,54,48,93,0,115,111,117,110,100,100,105,114,91,49,54,48,93,0,121,102,101,120,112,111,114,116,100,105,114, -91,49,54,48,93,0,118,101,114,115,105,111,110,115,0,118,114,109,108,102,108,97,103,0,103,97,109,101,102,108,97,103, -115,0,119,104,101,101,108,108,105,110,101,115,99,114,111,108,108,0,117,105,102,108,97,103,0,108,97,110,103,117,97,103, -101,0,117,115,101,114,112,114,101,102,0,118,105,101,119,122,111,111,109,0,99,111,110,115,111,108,101,95,98,117,102,102, -101,114,0,99,111,110,115,111,108,101,95,111,117,116,0,109,105,120,98,117,102,115,105,122,101,0,102,111,110,116,115,105, -122,101,0,101,110,99,111,100,105,110,103,0,116,114,97,110,115,111,112,116,115,0,109,101,110,117,116,104,114,101,115,104, -111,108,100,49,0,109,101,110,117,116,104,114,101,115,104,111,108,100,50,0,102,111,110,116,110,97,109,101,91,50,53,54, -93,0,116,104,101,109,101,115,0,117,110,100,111,115,116,101,112,115,0,117,110,100,111,109,101,109,111,114,121,0,103,112, -95,109,97,110,104,97,116,116,101,110,100,105,115,116,0,103,112,95,101,117,99,108,105,100,101,97,110,100,105,115,116,0, -103,112,95,101,114,97,115,101,114,0,103,112,95,115,101,116,116,105,110,103,115,0,116,98,95,108,101,102,116,109,111,117, -115,101,0,116,98,95,114,105,103,104,116,109,111,117,115,101,0,108,105,103,104,116,91,51,93,0,116,119,95,104,111,116, -115,112,111,116,0,116,119,95,102,108,97,103,0,116,119,95,104,97,110,100,108,101,115,105,122,101,0,116,119,95,115,105, -122,101,0,116,101,120,116,105,109,101,111,117,116,0,116,101,120,99,111,108,108,101,99,116,114,97,116,101,0,109,101,109, -99,97,99,104,101,108,105,109,105,116,0,112,114,101,102,101,116,99,104,102,114,97,109,101,115,0,102,114,97,109,101,115, -101,114,118,101,114,112,111,114,116,0,112,97,100,95,114,111,116,95,97,110,103,108,101,0,111,98,99,101,110,116,101,114, -95,100,105,97,0,114,118,105,115,105,122,101,0,114,118,105,98,114,105,103,104,116,0,114,101,99,101,110,116,95,102,105, -108,101,115,0,115,109,111,111,116,104,95,118,105,101,119,116,120,0,103,108,114,101,115,108,105,109,105,116,0,110,100,111, -102,95,112,97,110,0,110,100,111,102,95,114,111,116,97,116,101,0,99,117,114,115,115,105,122,101,0,112,97,100,91,56, -93,0,118,101,114,115,101,109,97,115,116,101,114,91,49,54,48,93,0,118,101,114,115,101,117,115,101,114,91,49,54,48, -93,0,103,108,97,108,112,104,97,99,108,105,112,0,97,117,116,111,107,101,121,95,102,108,97,103,0,99,111,98,97,95, -119,101,105,103,104,116,0,118,101,114,116,98,97,115,101,0,101,100,103,101,98,97,115,101,0,97,114,101,97,98,97,115, -101,0,42,115,99,101,110,101,0,101,110,100,120,0,101,110,100,121,0,115,105,122,101,120,0,115,105,122,101,121,0,115, -99,101,110,101,110,114,0,115,99,114,101,101,110,110,114,0,102,117,108,108,0,109,97,105,110,119,105,110,0,119,105,110, -97,107,116,0,104,97,110,100,108,101,114,91,56,93,0,42,110,101,119,118,0,118,101,99,0,42,118,49,0,42,118,50, -0,112,97,110,101,108,110,97,109,101,91,54,52,93,0,116,97,98,110,97,109,101,91,54,52,93,0,100,114,97,119,110, -97,109,101,91,54,52,93,0,111,102,115,120,0,111,102,115,121,0,99,111,110,116,114,111,108,0,115,110,97,112,0,111, -108,100,95,111,102,115,120,0,111,108,100,95,111,102,115,121,0,115,111,114,116,99,111,117,110,116,101,114,0,42,112,97, -110,101,108,116,97,98,0,42,118,51,0,42,118,52,0,42,102,117,108,108,0,119,105,110,109,97,116,91,52,93,91,52, -93,0,104,101,97,100,114,99,116,0,119,105,110,114,99,116,0,104,101,97,100,119,105,110,0,119,105,110,0,104,101,97, -100,101,114,116,121,112,101,0,98,117,116,115,112,97,99,101,116,121,112,101,0,119,105,110,120,0,119,105,110,121,0,104, -101,97,100,95,115,119,97,112,0,104,101,97,100,95,101,113,117,97,108,0,119,105,110,95,115,119,97,112,0,119,105,110, -95,101,113,117,97,108,0,104,101,97,100,98,117,116,108,101,110,0,104,101,97,100,98,117,116,111,102,115,0,99,117,114, -115,111,114,0,115,112,97,99,101,100,97,116,97,0,117,105,98,108,111,99,107,115,0,112,97,110,101,108,115,0,115,117, -98,118,115,116,114,91,52,93,0,115,117,98,118,101,114,115,105,111,110,0,112,97,100,115,0,109,105,110,118,101,114,115, -105,111,110,0,109,105,110,115,117,98,118,101,114,115,105,111,110,0,100,105,115,112,108,97,121,109,111,100,101,0,42,99, -117,114,115,99,114,101,101,110,0,42,99,117,114,115,99,101,110,101,0,102,105,108,101,102,108,97,103,115,0,103,108,111, -98,97,108,102,0,110,97,109,101,91,56,48,93,0,42,105,98,117,102,0,42,105,98,117,102,95,99,111,109,112,0,42, -115,101,49,0,42,115,101,50,0,42,115,101,51,0,110,114,0,98,111,116,116,111,109,0,114,105,103,104,116,0,120,111, -102,115,0,121,111,102,115,0,108,105,102,116,91,51,93,0,103,97,109,109,97,91,51,93,0,103,97,105,110,91,51,93, -0,115,97,116,117,114,97,116,105,111,110,0,42,103,117,105,0,100,105,114,91,49,54,48,93,0,100,111,110,101,0,115, -116,97,114,116,115,116,105,108,108,0,101,110,100,115,116,105,108,108,0,42,115,116,114,105,112,100,97,116,97,0,111,114, -120,0,111,114,121,0,42,99,114,111,112,0,42,116,114,97,110,115,102,111,114,109,0,42,99,111,108,111,114,95,98,97, -108,97,110,99,101,0,42,116,115,116,114,105,112,100,97,116,97,0,42,116,115,116,114,105,112,100,97,116,97,95,115,116, -97,114,116,115,116,105,108,108,0,42,116,115,116,114,105,112,100,97,116,97,95,101,110,100,115,116,105,108,108,0,42,105, -98,117,102,95,115,116,97,114,116,115,116,105,108,108,0,42,105,98,117,102,95,101,110,100,115,116,105,108,108,0,42,105, -110,115,116,97,110,99,101,95,112,114,105,118,97,116,101,95,100,97,116,97,0,42,42,99,117,114,114,101,110,116,95,112, -114,105,118,97,116,101,95,100,97,116,97,0,42,116,109,112,0,115,116,97,114,116,111,102,115,0,101,110,100,111,102,115, -0,109,97,99,104,105,110,101,0,115,116,97,114,116,100,105,115,112,0,101,110,100,100,105,115,112,0,109,117,108,0,104, -97,110,100,115,105,122,101,0,97,110,105,109,95,112,114,101,115,101,101,107,0,42,115,116,114,105,112,0,102,97,99,102, -48,0,102,97,99,102,49,0,42,115,101,113,49,0,42,115,101,113,50,0,42,115,101,113,51,0,115,101,113,98,97,115, -101,0,42,115,111,117,110,100,0,42,104,100,97,117,100,105,111,0,108,101,118,101,108,0,112,97,110,0,115,116,114,111, -98,101,0,42,101,102,102,101,99,116,100,97,116,97,0,97,110,105,109,95,115,116,97,114,116,111,102,115,0,97,110,105, -109,95,101,110,100,111,102,115,0,98,108,101,110,100,95,109,111,100,101,0,98,108,101,110,100,95,111,112,97,99,105,116, -121,0,42,111,108,100,98,97,115,101,112,0,42,112,97,114,115,101,113,0,42,115,101,113,98,97,115,101,112,0,109,101, -116,97,115,116,97,99,107,0,101,100,103,101,87,105,100,116,104,0,102,111,114,119,97,114,100,0,119,105,112,101,116,121, -112,101,0,102,77,105,110,105,0,102,67,108,97,109,112,0,102,66,111,111,115,116,0,100,68,105,115,116,0,100,81,117, -97,108,105,116,121,0,98,78,111,67,111,109,112,0,83,99,97,108,101,120,73,110,105,0,83,99,97,108,101,121,73,110, -105,0,83,99,97,108,101,120,70,105,110,0,83,99,97,108,101,121,70,105,110,0,120,73,110,105,0,120,70,105,110,0, -121,73,110,105,0,121,70,105,110,0,114,111,116,73,110,105,0,114,111,116,70,105,110,0,105,110,116,101,114,112,111,108, -97,116,105,111,110,0,42,102,114,97,109,101,77,97,112,0,103,108,111,98,97,108,83,112,101,101,100,0,108,97,115,116, -86,97,108,105,100,70,114,97,109,101,0,98,108,101,110,100,70,114,97,109,101,115,0,98,117,116,116,121,112,101,0,117, -115,101,114,106,105,116,0,115,116,97,0,116,111,116,112,97,114,116,0,110,111,114,109,102,97,99,0,111,98,102,97,99, -0,114,97,110,100,102,97,99,0,116,101,120,102,97,99,0,114,97,110,100,108,105,102,101,0,102,111,114,99,101,91,51, -93,0,118,101,99,116,115,105,122,101,0,109,97,120,108,101,110,0,100,101,102,118,101,99,91,51,93,0,109,117,108,116, -91,52,93,0,108,105,102,101,91,52,93,0,99,104,105,108,100,91,52,93,0,109,97,116,91,52,93,0,116,101,120,109, -97,112,0,99,117,114,109,117,108,116,0,115,116,97,116,105,99,115,116,101,112,0,111,109,97,116,0,116,105,109,101,116, -101,120,0,115,112,101,101,100,116,101,120,0,102,108,97,103,50,110,101,103,0,118,101,114,116,103,114,111,117,112,95,118, -0,118,103,114,111,117,112,110,97,109,101,91,51,50,93,0,118,103,114,111,117,112,110,97,109,101,95,118,91,51,50,93, -0,42,107,101,121,115,0,109,105,110,102,97,99,0,117,115,101,100,0,117,115,101,100,101,108,101,109,0,100,120,0,100, -121,0,108,105,110,107,0,111,116,121,112,101,0,111,108,100,0,42,112,111,105,110,0,42,111,108,100,112,111,105,110,0, -114,101,115,101,116,100,105,115,116,0,108,97,115,116,118,97,108,0,42,109,97,0,107,101,121,0,113,117,97,108,0,113, -117,97,108,50,0,116,97,114,103,101,116,78,97,109,101,91,51,50,93,0,116,111,103,103,108,101,78,97,109,101,91,51, -50,93,0,118,97,108,117,101,91,51,50,93,0,109,97,120,118,97,108,117,101,91,51,50,93,0,100,101,108,97,121,0, -100,117,114,97,116,105,111,110,0,109,97,116,101,114,105,97,108,78,97,109,101,91,51,50,93,0,100,97,109,112,116,105, -109,101,114,0,112,114,111,112,110,97,109,101,91,51,50,93,0,109,97,116,110,97,109,101,91,51,50,93,0,97,120,105, -115,102,108,97,103,0,42,102,114,111,109,79,98,106,101,99,116,0,115,117,98,106,101,99,116,91,51,50,93,0,98,111, -100,121,91,51,50,93,0,112,117,108,115,101,0,102,114,101,113,0,116,111,116,108,105,110,107,115,0,42,42,108,105,110, -107,115,0,116,97,112,0,106,111,121,105,110,100,101,120,0,97,120,105,115,95,115,105,110,103,108,101,0,97,120,105,115, -102,0,98,117,116,116,111,110,0,104,97,116,0,104,97,116,102,0,112,114,101,99,105,115,105,111,110,0,115,116,114,91, -49,50,56,93,0,109,111,100,117,108,101,91,54,52,93,0,42,109,121,110,101,119,0,105,110,112,117,116,115,0,116,111, -116,115,108,105,110,107,115,0,42,42,115,108,105,110,107,115,0,118,97,108,111,0,115,116,97,116,101,95,109,97,115,107, -0,42,97,99,116,0,102,114,97,109,101,80,114,111,112,91,51,50,93,0,98,108,101,110,100,105,110,0,112,114,105,111, -114,105,116,121,0,101,110,100,95,114,101,115,101,116,0,115,116,114,105,100,101,97,120,105,115,0,115,116,114,105,100,101, -108,101,110,103,116,104,0,115,110,100,110,114,0,112,97,100,49,91,50,93,0,109,97,107,101,99,111,112,121,0,99,111, -112,121,109,97,100,101,0,112,97,100,50,91,49,93,0,116,114,97,99,107,0,42,109,101,0,108,105,110,86,101,108,111, -99,105,116,121,91,51,93,0,97,110,103,86,101,108,111,99,105,116,121,91,51,93,0,108,111,99,97,108,102,108,97,103, -0,100,121,110,95,111,112,101,114,97,116,105,111,110,0,102,111,114,99,101,108,111,99,91,51,93,0,102,111,114,99,101, -114,111,116,91,51,93,0,108,105,110,101,97,114,118,101,108,111,99,105,116,121,91,51,93,0,97,110,103,117,108,97,114, -118,101,108,111,99,105,116,121,91,51,93,0,42,114,101,102,101,114,101,110,99,101,0,98,117,116,115,116,97,0,98,117, -116,101,110,100,0,109,105,110,0,109,97,120,0,118,105,115,105,102,97,99,0,114,111,116,100,97,109,112,0,109,105,110, -108,111,99,91,51,93,0,109,97,120,108,111,99,91,51,93,0,109,105,110,114,111,116,91,51,93,0,109,97,120,114,111, -116,91,51,93,0,109,97,116,112,114,111,112,91,51,50,93,0,100,105,115,116,114,105,98,117,116,105,111,110,0,105,110, -116,95,97,114,103,95,49,0,105,110,116,95,97,114,103,95,50,0,102,108,111,97,116,95,97,114,103,95,49,0,102,108, -111,97,116,95,97,114,103,95,50,0,116,111,80,114,111,112,78,97,109,101,91,51,50,93,0,42,116,111,79,98,106,101, -99,116,0,98,111,100,121,84,121,112,101,0,102,105,108,101,110,97,109,101,91,54,52,93,0,108,111,97,100,97,110,105, -110,97,109,101,91,54,52,93,0,105,110,116,95,97,114,103,0,102,108,111,97,116,95,97,114,103,0,103,111,0,97,99, -99,101,108,108,101,114,97,116,105,111,110,0,109,97,120,115,112,101,101,100,0,109,97,120,114,111,116,115,112,101,101,100, -0,109,97,120,116,105,108,116,115,112,101,101,100,0,116,105,108,116,100,97,109,112,0,115,112,101,101,100,100,97,109,112, -0,42,115,97,109,112,108,101,0,42,115,116,114,101,97,109,0,42,110,101,119,112,97,99,107,101,100,102,105,108,101,0, -42,115,110,100,95,115,111,117,110,100,0,112,97,110,110,105,110,103,0,97,116,116,101,110,117,97,116,105,111,110,0,112, -105,116,99,104,0,109,105,110,95,103,97,105,110,0,109,97,120,95,103,97,105,110,0,100,105,115,116,97,110,99,101,0, -115,116,114,101,97,109,108,101,110,0,99,104,97,110,110,101,108,115,0,104,105,103,104,112,114,105,111,0,112,97,100,91, -49,48,93,0,103,97,105,110,0,100,111,112,112,108,101,114,102,97,99,116,111,114,0,100,111,112,112,108,101,114,118,101, -108,111,99,105,116,121,0,110,117,109,115,111,117,110,100,115,98,108,101,110,100,101,114,0,110,117,109,115,111,117,110,100, -115,103,97,109,101,101,110,103,105,110,101,0,42,108,97,109,112,114,101,110,0,103,111,98,106,101,99,116,0,100,117,112, -108,105,95,111,102,115,91,51,93,0,99,104,105,108,100,98,97,115,101,0,114,111,108,108,0,104,101,97,100,91,51,93, -0,116,97,105,108,91,51,93,0,98,111,110,101,95,109,97,116,91,51,93,91,51,93,0,97,114,109,95,104,101,97,100, -91,51,93,0,97,114,109,95,116,97,105,108,91,51,93,0,97,114,109,95,109,97,116,91,52,93,91,52,93,0,120,119, -105,100,116,104,0,122,119,105,100,116,104,0,101,97,115,101,49,0,101,97,115,101,50,0,114,97,100,95,104,101,97,100, -0,114,97,100,95,116,97,105,108,0,98,111,110,101,98,97,115,101,0,99,104,97,105,110,98,97,115,101,0,112,97,116, -104,102,108,97,103,0,108,97,121,101,114,95,112,114,111,116,101,99,116,101,100,0,103,104,111,115,116,101,112,0,103,104, -111,115,116,115,105,122,101,0,103,104,111,115,116,116,121,112,101,0,112,97,116,104,115,105,122,101,0,103,104,111,115,116, -115,102,0,103,104,111,115,116,101,102,0,112,97,116,104,115,102,0,112,97,116,104,101,102,0,112,97,116,104,98,99,0, -112,97,116,104,97,99,0,99,111,110,115,116,102,108,97,103,0,105,107,102,108,97,103,0,115,101,108,101,99,116,102,108, -97,103,0,97,103,114,112,95,105,110,100,101,120,0,42,98,111,110,101,0,42,99,104,105,108,100,0,105,107,116,114,101, -101,0,42,98,95,98,111,110,101,95,109,97,116,115,0,42,100,117,97,108,95,113,117,97,116,0,42,98,95,98,111,110, -101,95,100,117,97,108,95,113,117,97,116,115,0,99,104,97,110,95,109,97,116,91,52,93,91,52,93,0,112,111,115,101, -95,109,97,116,91,52,93,91,52,93,0,112,111,115,101,95,104,101,97,100,91,51,93,0,112,111,115,101,95,116,97,105, -108,91,51,93,0,108,105,109,105,116,109,105,110,91,51,93,0,108,105,109,105,116,109,97,120,91,51,93,0,115,116,105, -102,102,110,101,115,115,91,51,93,0,105,107,115,116,114,101,116,99,104,0,42,99,117,115,116,111,109,0,99,104,97,110, -98,97,115,101,0,112,114,111,120,121,95,108,97,121,101,114,0,115,116,114,105,100,101,95,111,102,102,115,101,116,91,51, -93,0,99,121,99,108,105,99,95,111,102,102,115,101,116,91,51,93,0,97,103,114,111,117,112,115,0,97,99,116,105,118, -101,95,103,114,111,117,112,0,99,117,115,116,111,109,67,111,108,0,99,115,0,42,103,114,112,0,114,101,115,101,114,118, -101,100,49,0,103,114,111,117,112,115,0,97,99,116,105,118,101,95,109,97,114,107,101,114,0,97,99,116,110,114,0,97, -99,116,119,105,100,116,104,0,116,105,109,101,115,108,105,100,101,0,110,97,109,101,91,51,48,93,0,111,119,110,115,112, -97,99,101,0,116,97,114,115,112,97,99,101,0,101,110,102,111,114,99,101,0,104,101,97,100,116,97,105,108,0,42,116, -97,114,0,115,117,98,116,97,114,103,101,116,91,51,50,93,0,109,97,116,114,105,120,91,52,93,91,52,93,0,115,112, -97,99,101,0,42,112,114,111,112,0,116,97,114,110,117,109,0,116,97,114,103,101,116,115,0,105,116,101,114,97,116,105, -111,110,115,0,114,111,111,116,98,111,110,101,0,109,97,120,95,114,111,111,116,98,111,110,101,0,42,112,111,108,101,116, -97,114,0,112,111,108,101,115,117,98,116,97,114,103,101,116,91,51,50,93,0,112,111,108,101,97,110,103,108,101,0,111, -114,105,101,110,116,119,101,105,103,104,116,0,103,114,97,98,116,97,114,103,101,116,91,51,93,0,114,101,115,101,114,118, -101,100,50,0,109,105,110,109,97,120,102,108,97,103,0,115,116,117,99,107,0,99,97,99,104,101,91,51,93,0,108,111, -99,107,102,108,97,103,0,102,111,108,108,111,119,102,108,97,103,0,118,111,108,109,111,100,101,0,112,108,97,110,101,0, -111,114,103,108,101,110,103,116,104,0,98,117,108,103,101,0,112,105,118,88,0,112,105,118,89,0,112,105,118,90,0,97, -120,88,0,97,120,89,0,97,120,90,0,109,105,110,76,105,109,105,116,91,54,93,0,109,97,120,76,105,109,105,116,91, -54,93,0,101,120,116,114,97,70,122,0,105,110,118,109,97,116,91,52,93,91,52,93,0,102,114,111,109,0,116,111,0, -109,97,112,91,51,93,0,101,120,112,111,0,102,114,111,109,95,109,105,110,91,51,93,0,102,114,111,109,95,109,97,120, -91,51,93,0,116,111,95,109,105,110,91,51,93,0,116,111,95,109,97,120,91,51,93,0,122,109,105,110,0,122,109,97, -120,0,112,97,100,91,57,93,0,99,104,97,110,110,101,108,91,51,50,93,0,110,111,95,114,111,116,95,97,120,105,115, -0,115,116,114,105,100,101,95,97,120,105,115,0,99,117,114,109,111,100,0,97,99,116,115,116,97,114,116,0,97,99,116, -101,110,100,0,97,99,116,111,102,102,115,0,115,116,114,105,100,101,108,101,110,0,98,108,101,110,100,111,117,116,0,115, -116,114,105,100,101,99,104,97,110,110,101,108,91,51,50,93,0,111,102,102,115,95,98,111,110,101,91,51,50,93,0,104, -97,115,105,110,112,117,116,0,104,97,115,111,117,116,112,117,116,0,100,97,116,97,116,121,112,101,0,115,111,99,107,101, -116,116,121,112,101,0,42,110,101,119,95,115,111,99,107,0,110,115,0,108,105,109,105,116,0,115,116,97,99,107,95,105, -110,100,101,120,0,105,110,116,101,114,110,0,115,116,97,99,107,95,105,110,100,101,120,95,101,120,116,0,108,111,99,120, -0,108,111,99,121,0,111,119,110,95,105,110,100,101,120,0,116,111,95,105,110,100,101,120,0,42,116,111,115,111,99,107, -0,42,108,105,110,107,0,42,110,101,119,95,110,111,100,101,0,117,115,101,114,110,97,109,101,91,51,50,93,0,108,97, -115,116,121,0,111,117,116,112,117,116,115,0,42,115,116,111,114,97,103,101,0,109,105,110,105,119,105,100,116,104,0,99, -117,115,116,111,109,49,0,99,117,115,116,111,109,50,0,99,117,115,116,111,109,51,0,99,117,115,116,111,109,52,0,110, -101,101,100,95,101,120,101,99,0,101,120,101,99,0,116,111,116,114,0,98,117,116,114,0,112,114,118,114,0,42,116,121, -112,101,105,110,102,111,0,42,102,114,111,109,110,111,100,101,0,42,116,111,110,111,100,101,0,42,102,114,111,109,115,111, -99,107,0,110,111,100,101,115,0,108,105,110,107,115,0,42,115,116,97,99,107,0,42,116,104,114,101,97,100,115,116,97, -99,107,0,105,110,105,116,0,115,116,97,99,107,115,105,122,101,0,99,117,114,95,105,110,100,101,120,0,97,108,108,116, -121,112,101,115,0,42,111,119,110,116,121,112,101,0,42,115,101,108,105,110,0,42,115,101,108,111,117,116,0,40,42,116, -105,109,101,99,117,114,115,111,114,41,40,41,0,40,42,115,116,97,116,115,95,100,114,97,119,41,40,41,0,40,42,116, -101,115,116,95,98,114,101,97,107,41,40,41,0,99,121,99,108,105,99,0,109,111,118,105,101,0,115,97,109,112,108,101, -115,0,109,105,110,115,112,101,101,100,0,112,101,114,99,101,110,116,120,0,112,101,114,99,101,110,116,121,0,98,111,107, -101,104,0,99,117,114,118,101,100,0,105,109,97,103,101,95,105,110,95,119,105,100,116,104,0,105,109,97,103,101,95,105, -110,95,104,101,105,103,104,116,0,99,101,110,116,101,114,95,120,0,99,101,110,116,101,114,95,121,0,115,112,105,110,0, -105,116,101,114,0,119,114,97,112,0,115,105,103,109,97,95,99,111,108,111,114,0,115,105,103,109,97,95,115,112,97,99, -101,0,104,117,101,0,115,97,116,0,116,49,0,116,50,0,116,51,0,102,115,116,114,101,110,103,116,104,0,102,97,108, -112,104,97,0,107,101,121,91,52,93,0,120,49,0,120,50,0,121,49,0,121,50,0,99,111,108,110,97,109,101,91,51, -50,93,0,98,107,116,121,112,101,0,114,111,116,97,116,105,111,110,0,112,114,101,118,105,101,119,0,103,97,109,99,111, -0,110,111,95,122,98,117,102,0,102,115,116,111,112,0,109,97,120,98,108,117,114,0,98,116,104,114,101,115,104,0,42, -100,105,99,116,0,42,110,111,100,101,0,97,110,103,108,101,95,111,102,115,0,99,111,108,109,111,100,0,109,105,120,0, -116,104,114,101,115,104,111,108,100,0,102,97,100,101,0,109,0,99,0,106,105,116,0,112,114,111,106,0,102,105,116,0, -115,104,111,114,116,121,0,109,105,110,116,97,98,108,101,0,109,97,120,116,97,98,108,101,0,101,120,116,95,105,110,91, -50,93,0,101,120,116,95,111,117,116,91,50,93,0,42,99,117,114,118,101,0,42,116,97,98,108,101,0,42,112,114,101, -109,117,108,116,97,98,108,101,0,99,117,114,114,0,99,108,105,112,114,0,99,109,91,52,93,0,98,108,97,99,107,91, -51,93,0,119,104,105,116,101,91,51,93,0,98,119,109,117,108,91,51,93,0,115,97,109,112,108,101,91,51,93,0,111, -102,102,115,101,116,91,50,93,0,105,110,110,101,114,114,97,100,105,117,115,0,114,97,116,101,0,114,103,98,91,51,93, -0,99,108,111,110,101,0,97,99,116,105,118,101,95,114,110,100,0,97,99,116,105,118,101,95,99,108,111,110,101,0,97, -99,116,105,118,101,95,109,97,115,107,0,42,108,97,121,101,114,115,0,116,111,116,108,97,121,101,114,0,109,97,120,108, -97,121,101,114,0,116,111,116,115,105,122,101,0,42,112,111,111,108,0,101,100,105,116,102,108,97,103,0,118,101,108,91, -51,93,0,114,111,116,91,52,93,0,97,118,101,91,51,93,0,110,117,109,0,112,97,114,101,110,116,0,112,97,91,52, -93,0,119,91,52,93,0,102,117,118,91,52,93,0,102,111,102,102,115,101,116,0,114,97,110,100,91,51,93,0,42,115, -116,105,99,107,95,111,98,0,112,114,101,118,95,115,116,97,116,101,0,42,104,97,105,114,0,105,95,114,111,116,91,52, -93,0,114,95,114,111,116,91,52,93,0,114,95,97,118,101,91,51,93,0,114,95,118,101,91,51,93,0,100,105,101,116, -105,109,101,0,98,97,110,107,0,115,105,122,101,109,117,108,0,110,117,109,95,100,109,99,97,99,104,101,0,98,112,105, -0,97,108,105,118,101,0,108,111,111,112,0,100,105,115,116,114,0,112,104,121,115,116,121,112,101,0,114,111,116,109,111, -100,101,0,97,118,101,109,111,100,101,0,114,101,97,99,116,101,118,101,110,116,0,100,114,97,119,0,100,114,97,119,95, -97,115,0,100,114,97,119,95,115,105,122,101,0,99,104,105,108,100,116,121,112,101,0,100,114,97,119,95,115,116,101,112, -0,114,101,110,95,115,116,101,112,0,104,97,105,114,95,115,116,101,112,0,107,101,121,115,95,115,116,101,112,0,97,100, -97,112,116,95,97,110,103,108,101,0,97,100,97,112,116,95,112,105,120,0,114,111,116,102,114,111,109,0,105,110,116,101, -103,114,97,116,111,114,0,110,98,101,116,119,101,101,110,0,98,111,105,100,110,101,105,103,104,98,111,117,114,115,0,98, -98,95,97,108,105,103,110,0,98,98,95,117,118,95,115,112,108,105,116,0,98,98,95,97,110,105,109,0,98,98,95,115, -112,108,105,116,95,111,102,102,115,101,116,0,98,98,95,116,105,108,116,0,98,98,95,114,97,110,100,95,116,105,108,116, -0,98,98,95,111,102,102,115,101,116,91,50,93,0,115,105,109,112,108,105,102,121,95,102,108,97,103,0,115,105,109,112, -108,105,102,121,95,114,101,102,115,105,122,101,0,115,105,109,112,108,105,102,121,95,114,97,116,101,0,115,105,109,112,108, -105,102,121,95,116,114,97,110,115,105,116,105,111,110,0,115,105,109,112,108,105,102,121,95,118,105,101,119,112,111,114,116, -0,116,105,109,101,116,119,101,97,107,0,106,105,116,102,97,99,0,107,101,121,101,100,95,116,105,109,101,0,101,102,102, -95,104,97,105,114,0,103,114,105,100,95,114,101,115,0,112,97,114,116,102,97,99,0,116,97,110,102,97,99,0,116,97, -110,112,104,97,115,101,0,114,101,97,99,116,102,97,99,0,97,118,101,102,97,99,0,112,104,97,115,101,102,97,99,0, -114,97,110,100,114,111,116,102,97,99,0,114,97,110,100,112,104,97,115,101,102,97,99,0,114,97,110,100,115,105,122,101, -0,114,101,97,99,116,115,104,97,112,101,0,97,99,99,91,51,93,0,100,114,97,103,102,97,99,0,98,114,111,119,110, -102,97,99,0,100,97,109,112,102,97,99,0,97,98,115,108,101,110,103,116,104,0,114,97,110,100,108,101,110,103,116,104, -0,99,104,105,108,100,95,110,98,114,0,114,101,110,95,99,104,105,108,100,95,110,98,114,0,112,97,114,101,110,116,115, -0,99,104,105,108,100,115,105,122,101,0,99,104,105,108,100,114,97,110,100,115,105,122,101,0,99,104,105,108,100,114,97, -100,0,99,104,105,108,100,102,108,97,116,0,99,104,105,108,100,115,112,114,101,97,100,0,99,108,117,109,112,102,97,99, -0,99,108,117,109,112,112,111,119,0,114,111,117,103,104,49,0,114,111,117,103,104,49,95,115,105,122,101,0,114,111,117, -103,104,50,0,114,111,117,103,104,50,95,115,105,122,101,0,114,111,117,103,104,50,95,116,104,114,101,115,0,114,111,117, -103,104,95,101,110,100,0,114,111,117,103,104,95,101,110,100,95,115,104,97,112,101,0,98,114,97,110,99,104,95,116,104, -114,101,115,0,100,114,97,119,95,108,105,110,101,91,50,93,0,109,97,120,95,108,97,116,95,97,99,99,0,109,97,120, -95,116,97,110,95,97,99,99,0,97,118,101,114,97,103,101,95,118,101,108,0,98,97,110,107,105,110,103,0,109,97,120, -95,98,97,110,107,0,103,114,111,117,110,100,122,0,98,111,105,100,102,97,99,91,56,93,0,98,111,105,100,114,117,108, -101,91,56,93,0,42,101,102,102,95,103,114,111,117,112,0,42,100,117,112,95,111,98,0,42,98,98,95,111,98,0,42, -112,100,50,0,42,112,97,114,116,0,42,101,100,105,116,0,42,42,112,97,116,104,99,97,99,104,101,0,42,42,99,104, -105,108,100,99,97,99,104,101,0,112,97,116,104,99,97,99,104,101,98,117,102,115,0,99,104,105,108,100,99,97,99,104, -101,98,117,102,115,0,42,116,97,114,103,101,116,95,111,98,0,42,107,101,121,101,100,95,111,98,0,42,108,97,116,116, -105,99,101,0,101,102,102,101,99,116,111,114,115,0,114,101,97,99,116,101,118,101,110,116,115,0,116,111,116,99,104,105, -108,100,0,116,111,116,99,97,99,104,101,100,0,116,111,116,99,104,105,108,100,99,97,99,104,101,0,116,97,114,103,101, -116,95,112,115,121,115,0,107,101,121,101,100,95,112,115,121,115,0,116,111,116,107,101,121,101,100,0,98,97,107,101,115, -112,97,99,101,0,98,98,95,117,118,110,97,109,101,91,51,93,91,51,50,93,0,118,103,114,111,117,112,91,49,50,93, -0,118,103,95,110,101,103,0,114,116,51,0,42,114,101,110,100,101,114,100,97,116,97,0,42,99,97,99,104,101,0,67, -100,105,115,0,67,118,105,0,91,51,93,0,115,116,114,117,99,116,117,114,97,108,0,98,101,110,100,105,110,103,0,109, -97,120,95,98,101,110,100,0,109,97,120,95,115,116,114,117,99,116,0,109,97,120,95,115,104,101,97,114,0,97,118,103, -95,115,112,114,105,110,103,95,108,101,110,0,116,105,109,101,115,99,97,108,101,0,101,102,102,95,102,111,114,99,101,95, -115,99,97,108,101,0,101,102,102,95,119,105,110,100,95,115,99,97,108,101,0,115,105,109,95,116,105,109,101,95,111,108, -100,0,115,116,101,112,115,80,101,114,70,114,97,109,101,0,112,114,101,114,111,108,108,0,109,97,120,115,112,114,105,110, -103,108,101,110,0,115,111,108,118,101,114,95,116,121,112,101,0,118,103,114,111,117,112,95,98,101,110,100,0,118,103,114, -111,117,112,95,109,97,115,115,0,118,103,114,111,117,112,95,115,116,114,117,99,116,0,112,114,101,115,101,116,115,0,42, -99,111,108,108,105,115,105,111,110,95,108,105,115,116,0,101,112,115,105,108,111,110,0,115,101,108,102,95,102,114,105,99, -116,105,111,110,0,115,101,108,102,101,112,115,105,108,111,110,0,115,101,108,102,95,108,111,111,112,95,99,111,117,110,116, -0,108,111,111,112,95,99,111,117,110,116,0,112,114,101,115,115,117,114,101,0,42,112,111,105,110,116,115,0,116,111,116, -112,111,105,110,116,115,0,116,104,105,99,107,110,101,115,115,0,115,116,114,111,107,101,115,0,102,114,97,109,101,110,117, -109,0,42,97,99,116,102,114,97,109,101,0,103,115,116,101,112,0,105,110,102,111,91,49,50,56,93,0,115,98,117,102, -102,101,114,95,115,105,122,101,0,115,98,117,102,102,101,114,95,115,102,108,97,103,0,42,115,98,117,102,102,101,114,0, -0,0,0,84,89,80,69,100,1,0,0,99,104,97,114,0,117,99,104,97,114,0,115,104,111,114,116,0,117,115,104,111, -114,116,0,105,110,116,0,108,111,110,103,0,117,108,111,110,103,0,102,108,111,97,116,0,100,111,117,98,108,101,0,118, -111,105,100,0,76,105,110,107,0,76,105,110,107,68,97,116,97,0,76,105,115,116,66,97,115,101,0,118,101,99,50,115, -0,118,101,99,50,105,0,118,101,99,50,102,0,118,101,99,50,100,0,118,101,99,51,105,0,118,101,99,51,102,0,118, -101,99,51,100,0,118,101,99,52,105,0,118,101,99,52,102,0,118,101,99,52,100,0,114,99,116,105,0,114,99,116,102, -0,73,68,80,114,111,112,101,114,116,121,68,97,116,97,0,73,68,80,114,111,112,101,114,116,121,0,73,68,0,76,105, -98,114,97,114,121,0,70,105,108,101,68,97,116,97,0,80,114,101,118,105,101,119,73,109,97,103,101,0,73,112,111,68, -114,105,118,101,114,0,79,98,106,101,99,116,0,73,112,111,67,117,114,118,101,0,66,80,111,105,110,116,0,66,101,122, -84,114,105,112,108,101,0,73,112,111,0,75,101,121,66,108,111,99,107,0,75,101,121,0,83,99,114,105,112,116,76,105, -110,107,0,84,101,120,116,76,105,110,101,0,84,101,120,116,77,97,114,107,101,114,0,84,101,120,116,0,80,97,99,107, -101,100,70,105,108,101,0,67,97,109,101,114,97,0,73,109,97,103,101,85,115,101,114,0,73,109,97,103,101,0,71,80, -85,84,101,120,116,117,114,101,0,97,110,105,109,0,82,101,110,100,101,114,82,101,115,117,108,116,0,77,84,101,120,0, -84,101,120,0,80,108,117,103,105,110,84,101,120,0,67,66,68,97,116,97,0,67,111,108,111,114,66,97,110,100,0,69, -110,118,77,97,112,0,73,109,66,117,102,0,98,78,111,100,101,84,114,101,101,0,84,101,120,77,97,112,112,105,110,103, -0,76,97,109,112,0,67,117,114,118,101,77,97,112,112,105,110,103,0,87,97,118,101,0,77,97,116,101,114,105,97,108, -0,71,114,111,117,112,0,86,70,111,110,116,0,86,70,111,110,116,68,97,116,97,0,77,101,116,97,69,108,101,109,0, -66,111,117,110,100,66,111,120,0,77,101,116,97,66,97,108,108,0,78,117,114,98,0,67,104,97,114,73,110,102,111,0, -84,101,120,116,66,111,120,0,67,117,114,118,101,0,80,97,116,104,0,77,101,115,104,0,77,70,97,99,101,0,77,84, -70,97,99,101,0,84,70,97,99,101,0,77,86,101,114,116,0,77,69,100,103,101,0,77,68,101,102,111,114,109,86,101, -114,116,0,77,67,111,108,0,77,83,116,105,99,107,121,0,77,83,101,108,101,99,116,0,67,117,115,116,111,109,68,97, -116,97,0,77,117,108,116,105,114,101,115,0,80,97,114,116,105,97,108,86,105,115,105,98,105,108,105,116,121,0,77,68, -101,102,111,114,109,87,101,105,103,104,116,0,77,84,101,120,80,111,108,121,0,77,76,111,111,112,85,86,0,77,76,111, -111,112,67,111,108,0,77,70,108,111,97,116,80,114,111,112,101,114,116,121,0,77,73,110,116,80,114,111,112,101,114,116, -121,0,77,83,116,114,105,110,103,80,114,111,112,101,114,116,121,0,79,114,105,103,83,112,97,99,101,70,97,99,101,0, -77,117,108,116,105,114,101,115,67,111,108,0,77,117,108,116,105,114,101,115,67,111,108,70,97,99,101,0,77,117,108,116, -105,114,101,115,70,97,99,101,0,77,117,108,116,105,114,101,115,69,100,103,101,0,77,117,108,116,105,114,101,115,76,101, -118,101,108,0,77,117,108,116,105,114,101,115,77,97,112,78,111,100,101,0,77,111,100,105,102,105,101,114,68,97,116,97, -0,83,117,98,115,117,114,102,77,111,100,105,102,105,101,114,68,97,116,97,0,76,97,116,116,105,99,101,77,111,100,105, -102,105,101,114,68,97,116,97,0,67,117,114,118,101,77,111,100,105,102,105,101,114,68,97,116,97,0,66,117,105,108,100, -77,111,100,105,102,105,101,114,68,97,116,97,0,77,97,115,107,77,111,100,105,102,105,101,114,68,97,116,97,0,65,114, -114,97,121,77,111,100,105,102,105,101,114,68,97,116,97,0,77,105,114,114,111,114,77,111,100,105,102,105,101,114,68,97, -116,97,0,69,100,103,101,83,112,108,105,116,77,111,100,105,102,105,101,114,68,97,116,97,0,66,101,118,101,108,77,111, -100,105,102,105,101,114,68,97,116,97,0,66,77,101,115,104,77,111,100,105,102,105,101,114,68,97,116,97,0,68,105,115, -112,108,97,99,101,77,111,100,105,102,105,101,114,68,97,116,97,0,85,86,80,114,111,106,101,99,116,77,111,100,105,102, -105,101,114,68,97,116,97,0,68,101,99,105,109,97,116,101,77,111,100,105,102,105,101,114,68,97,116,97,0,83,109,111, -111,116,104,77,111,100,105,102,105,101,114,68,97,116,97,0,67,97,115,116,77,111,100,105,102,105,101,114,68,97,116,97, -0,87,97,118,101,77,111,100,105,102,105,101,114,68,97,116,97,0,65,114,109,97,116,117,114,101,77,111,100,105,102,105, -101,114,68,97,116,97,0,72,111,111,107,77,111,100,105,102,105,101,114,68,97,116,97,0,83,111,102,116,98,111,100,121, -77,111,100,105,102,105,101,114,68,97,116,97,0,67,108,111,116,104,77,111,100,105,102,105,101,114,68,97,116,97,0,67, -108,111,116,104,0,67,108,111,116,104,83,105,109,83,101,116,116,105,110,103,115,0,67,108,111,116,104,67,111,108,108,83, -101,116,116,105,110,103,115,0,80,111,105,110,116,67,97,99,104,101,0,67,111,108,108,105,115,105,111,110,77,111,100,105, -102,105,101,114,68,97,116,97,0,66,86,72,84,114,101,101,0,83,117,114,102,97,99,101,77,111,100,105,102,105,101,114, -68,97,116,97,0,68,101,114,105,118,101,100,77,101,115,104,0,66,86,72,84,114,101,101,70,114,111,109,77,101,115,104, -0,66,111,111,108,101,97,110,77,111,100,105,102,105,101,114,68,97,116,97,0,77,68,101,102,73,110,102,108,117,101,110, -99,101,0,77,68,101,102,67,101,108,108,0,77,101,115,104,68,101,102,111,114,109,77,111,100,105,102,105,101,114,68,97, -116,97,0,80,97,114,116,105,99,108,101,83,121,115,116,101,109,77,111,100,105,102,105,101,114,68,97,116,97,0,80,97, -114,116,105,99,108,101,83,121,115,116,101,109,0,80,97,114,116,105,99,108,101,73,110,115,116,97,110,99,101,77,111,100, -105,102,105,101,114,68,97,116,97,0,69,120,112,108,111,100,101,77,111,100,105,102,105,101,114,68,97,116,97,0,70,108, -117,105,100,115,105,109,77,111,100,105,102,105,101,114,68,97,116,97,0,70,108,117,105,100,115,105,109,83,101,116,116,105, -110,103,115,0,83,104,114,105,110,107,119,114,97,112,77,111,100,105,102,105,101,114,68,97,116,97,0,83,105,109,112,108, -101,68,101,102,111,114,109,77,111,100,105,102,105,101,114,68,97,116,97,0,76,97,116,116,105,99,101,0,98,68,101,102, -111,114,109,71,114,111,117,112,0,98,65,99,116,105,111,110,0,98,80,111,115,101,0,66,117,108,108,101,116,83,111,102, -116,66,111,100,121,0,80,97,114,116,68,101,102,108,101,99,116,0,83,111,102,116,66,111,100,121,0,79,98,72,111,111, -107,0,82,78,71,0,83,66,86,101,114,116,101,120,0,66,111,100,121,80,111,105,110,116,0,66,111,100,121,83,112,114, -105,110,103,0,83,66,83,99,114,97,116,99,104,0,87,111,114,108,100,0,82,97,100,105,111,0,66,97,115,101,0,65, -118,105,67,111,100,101,99,68,97,116,97,0,81,117,105,99,107,116,105,109,101,67,111,100,101,99,68,97,116,97,0,70, -70,77,112,101,103,67,111,100,101,99,68,97,116,97,0,65,117,100,105,111,68,97,116,97,0,83,99,101,110,101,82,101, -110,100,101,114,76,97,121,101,114,0,82,101,110,100,101,114,68,97,116,97,0,82,101,110,100,101,114,80,114,111,102,105, -108,101,0,71,97,109,101,70,114,97,109,105,110,103,0,84,105,109,101,77,97,114,107,101,114,0,73,109,97,103,101,80, -97,105,110,116,83,101,116,116,105,110,103,115,0,66,114,117,115,104,0,80,97,114,116,105,99,108,101,66,114,117,115,104, -68,97,116,97,0,80,97,114,116,105,99,108,101,69,100,105,116,83,101,116,116,105,110,103,115,0,84,114,97,110,115,102, -111,114,109,79,114,105,101,110,116,97,116,105,111,110,0,84,111,111,108,83,101,116,116,105,110,103,115,0,66,114,117,115, -104,68,97,116,97,0,83,99,117,108,112,116,68,97,116,97,0,83,99,117,108,112,116,83,101,115,115,105,111,110,0,83, -99,101,110,101,0,68,97,103,70,111,114,101,115,116,0,66,71,112,105,99,0,86,105,101,119,51,68,0,83,112,97,99, -101,76,105,110,107,0,83,99,114,65,114,101,97,0,82,101,110,100,101,114,73,110,102,111,0,82,101,116,111,112,111,86, -105,101,119,68,97,116,97,0,86,105,101,119,68,101,112,116,104,115,0,98,71,80,100,97,116,97,0,86,105,101,119,50, -68,0,83,112,97,99,101,73,110,102,111,0,83,112,97,99,101,73,112,111,0,83,112,97,99,101,66,117,116,115,0,83, -112,97,99,101,83,101,113,0,83,112,97,99,101,70,105,108,101,0,100,105,114,101,110,116,114,121,0,66,108,101,110,100, -72,97,110,100,108,101,0,83,112,97,99,101,79,111,112,115,0,84,114,101,101,83,116,111,114,101,0,84,114,101,101,83, -116,111,114,101,69,108,101,109,0,83,112,97,99,101,73,109,97,103,101,0,83,112,97,99,101,78,108,97,0,83,112,97, -99,101,84,101,120,116,0,83,99,114,105,112,116,0,83,112,97,99,101,83,99,114,105,112,116,0,83,112,97,99,101,84, -105,109,101,0,83,112,97,99,101,78,111,100,101,0,83,112,97,99,101,73,109,97,83,101,108,0,70,105,108,101,76,105, -115,116,0,84,104,101,109,101,85,73,0,84,104,101,109,101,83,112,97,99,101,0,84,104,101,109,101,87,105,114,101,67, -111,108,111,114,0,98,84,104,101,109,101,0,83,111,108,105,100,76,105,103,104,116,0,85,115,101,114,68,101,102,0,98, -83,99,114,101,101,110,0,83,99,114,86,101,114,116,0,83,99,114,69,100,103,101,0,80,97,110,101,108,0,70,105,108, -101,71,108,111,98,97,108,0,83,116,114,105,112,69,108,101,109,0,84,83,116,114,105,112,69,108,101,109,0,83,116,114, -105,112,67,114,111,112,0,83,116,114,105,112,84,114,97,110,115,102,111,114,109,0,83,116,114,105,112,67,111,108,111,114, -66,97,108,97,110,99,101,0,83,116,114,105,112,67,111,108,111,114,66,97,108,97,110,99,101,71,85,73,72,101,108,112, -101,114,0,83,116,114,105,112,80,114,111,120,121,0,83,116,114,105,112,0,80,108,117,103,105,110,83,101,113,0,83,101, -113,117,101,110,99,101,0,98,83,111,117,110,100,0,104,100,97,117,100,105,111,0,77,101,116,97,83,116,97,99,107,0, -69,100,105,116,105,110,103,0,87,105,112,101,86,97,114,115,0,71,108,111,119,86,97,114,115,0,84,114,97,110,115,102, -111,114,109,86,97,114,115,0,83,111,108,105,100,67,111,108,111,114,86,97,114,115,0,83,112,101,101,100,67,111,110,116, -114,111,108,86,97,114,115,0,69,102,102,101,99,116,0,66,117,105,108,100,69,102,102,0,80,97,114,116,69,102,102,0, -80,97,114,116,105,99,108,101,0,87,97,118,101,69,102,102,0,79,111,112,115,0,98,80,114,111,112,101,114,116,121,0, -98,78,101,97,114,83,101,110,115,111,114,0,98,77,111,117,115,101,83,101,110,115,111,114,0,98,84,111,117,99,104,83, -101,110,115,111,114,0,98,75,101,121,98,111,97,114,100,83,101,110,115,111,114,0,98,80,114,111,112,101,114,116,121,83, -101,110,115,111,114,0,98,65,99,116,117,97,116,111,114,83,101,110,115,111,114,0,98,68,101,108,97,121,83,101,110,115, -111,114,0,98,67,111,108,108,105,115,105,111,110,83,101,110,115,111,114,0,98,82,97,100,97,114,83,101,110,115,111,114, -0,98,82,97,110,100,111,109,83,101,110,115,111,114,0,98,82,97,121,83,101,110,115,111,114,0,98,77,101,115,115,97, -103,101,83,101,110,115,111,114,0,98,83,101,110,115,111,114,0,98,67,111,110,116,114,111,108,108,101,114,0,98,74,111, -121,115,116,105,99,107,83,101,110,115,111,114,0,98,69,120,112,114,101,115,115,105,111,110,67,111,110,116,0,98,80,121, -116,104,111,110,67,111,110,116,0,98,65,99,116,117,97,116,111,114,0,98,65,100,100,79,98,106,101,99,116,65,99,116, -117,97,116,111,114,0,98,65,99,116,105,111,110,65,99,116,117,97,116,111,114,0,98,83,111,117,110,100,65,99,116,117, -97,116,111,114,0,98,67,68,65,99,116,117,97,116,111,114,0,98,69,100,105,116,79,98,106,101,99,116,65,99,116,117, -97,116,111,114,0,98,83,99,101,110,101,65,99,116,117,97,116,111,114,0,98,80,114,111,112,101,114,116,121,65,99,116, -117,97,116,111,114,0,98,79,98,106,101,99,116,65,99,116,117,97,116,111,114,0,98,73,112,111,65,99,116,117,97,116, -111,114,0,98,67,97,109,101,114,97,65,99,116,117,97,116,111,114,0,98,67,111,110,115,116,114,97,105,110,116,65,99, -116,117,97,116,111,114,0,98,71,114,111,117,112,65,99,116,117,97,116,111,114,0,98,82,97,110,100,111,109,65,99,116, -117,97,116,111,114,0,98,77,101,115,115,97,103,101,65,99,116,117,97,116,111,114,0,98,71,97,109,101,65,99,116,117, -97,116,111,114,0,98,86,105,115,105,98,105,108,105,116,121,65,99,116,117,97,116,111,114,0,98,84,119,111,68,70,105, -108,116,101,114,65,99,116,117,97,116,111,114,0,98,80,97,114,101,110,116,65,99,116,117,97,116,111,114,0,98,83,116, -97,116,101,65,99,116,117,97,116,111,114,0,70,114,101,101,67,97,109,101,114,97,0,98,83,97,109,112,108,101,0,98, -83,111,117,110,100,76,105,115,116,101,110,101,114,0,83,112,97,99,101,83,111,117,110,100,0,71,114,111,117,112,79,98, -106,101,99,116,0,66,111,110,101,0,98,65,114,109,97,116,117,114,101,0,98,80,111,115,101,67,104,97,110,110,101,108, -0,98,65,99,116,105,111,110,71,114,111,117,112,0,98,65,99,116,105,111,110,67,104,97,110,110,101,108,0,83,112,97, -99,101,65,99,116,105,111,110,0,98,67,111,110,115,116,114,97,105,110,116,67,104,97,110,110,101,108,0,98,67,111,110, -115,116,114,97,105,110,116,0,98,67,111,110,115,116,114,97,105,110,116,84,97,114,103,101,116,0,98,80,121,116,104,111, -110,67,111,110,115,116,114,97,105,110,116,0,98,75,105,110,101,109,97,116,105,99,67,111,110,115,116,114,97,105,110,116, -0,98,84,114,97,99,107,84,111,67,111,110,115,116,114,97,105,110,116,0,98,82,111,116,97,116,101,76,105,107,101,67, -111,110,115,116,114,97,105,110,116,0,98,76,111,99,97,116,101,76,105,107,101,67,111,110,115,116,114,97,105,110,116,0, -98,77,105,110,77,97,120,67,111,110,115,116,114,97,105,110,116,0,98,83,105,122,101,76,105,107,101,67,111,110,115,116, -114,97,105,110,116,0,98,65,99,116,105,111,110,67,111,110,115,116,114,97,105,110,116,0,98,76,111,99,107,84,114,97, -99,107,67,111,110,115,116,114,97,105,110,116,0,98,70,111,108,108,111,119,80,97,116,104,67,111,110,115,116,114,97,105, -110,116,0,98,83,116,114,101,116,99,104,84,111,67,111,110,115,116,114,97,105,110,116,0,98,82,105,103,105,100,66,111, -100,121,74,111,105,110,116,67,111,110,115,116,114,97,105,110,116,0,98,67,108,97,109,112,84,111,67,111,110,115,116,114, -97,105,110,116,0,98,67,104,105,108,100,79,102,67,111,110,115,116,114,97,105,110,116,0,98,84,114,97,110,115,102,111, -114,109,67,111,110,115,116,114,97,105,110,116,0,98,76,111,99,76,105,109,105,116,67,111,110,115,116,114,97,105,110,116, -0,98,82,111,116,76,105,109,105,116,67,111,110,115,116,114,97,105,110,116,0,98,83,105,122,101,76,105,109,105,116,67, -111,110,115,116,114,97,105,110,116,0,98,68,105,115,116,76,105,109,105,116,67,111,110,115,116,114,97,105,110,116,0,98, -83,104,114,105,110,107,119,114,97,112,67,111,110,115,116,114,97,105,110,116,0,98,65,99,116,105,111,110,77,111,100,105, -102,105,101,114,0,98,65,99,116,105,111,110,83,116,114,105,112,0,98,78,111,100,101,83,116,97,99,107,0,98,78,111, -100,101,83,111,99,107,101,116,0,98,78,111,100,101,76,105,110,107,0,98,78,111,100,101,0,98,78,111,100,101,80,114, -101,118,105,101,119,0,98,78,111,100,101,84,121,112,101,0,78,111,100,101,73,109,97,103,101,65,110,105,109,0,78,111, -100,101,66,108,117,114,68,97,116,97,0,78,111,100,101,68,66,108,117,114,68,97,116,97,0,78,111,100,101,66,105,108, -97,116,101,114,97,108,66,108,117,114,68,97,116,97,0,78,111,100,101,72,117,101,83,97,116,0,78,111,100,101,73,109, -97,103,101,70,105,108,101,0,78,111,100,101,67,104,114,111,109,97,0,78,111,100,101,84,119,111,88,89,115,0,78,111, -100,101,84,119,111,70,108,111,97,116,115,0,78,111,100,101,71,101,111,109,101,116,114,121,0,78,111,100,101,86,101,114, -116,101,120,67,111,108,0,78,111,100,101,68,101,102,111,99,117,115,0,78,111,100,101,83,99,114,105,112,116,68,105,99, -116,0,78,111,100,101,71,108,97,114,101,0,78,111,100,101,84,111,110,101,109,97,112,0,78,111,100,101,76,101,110,115, -68,105,115,116,0,84,101,120,78,111,100,101,79,117,116,112,117,116,0,67,117,114,118,101,77,97,112,80,111,105,110,116, -0,67,117,114,118,101,77,97,112,0,66,114,117,115,104,67,108,111,110,101,0,67,117,115,116,111,109,68,97,116,97,76, -97,121,101,114,0,72,97,105,114,75,101,121,0,80,97,114,116,105,99,108,101,75,101,121,0,67,104,105,108,100,80,97, -114,116,105,99,108,101,0,80,97,114,116,105,99,108,101,68,97,116,97,0,80,97,114,116,105,99,108,101,83,101,116,116, -105,110,103,115,0,80,97,114,116,105,99,108,101,69,100,105,116,0,80,97,114,116,105,99,108,101,67,97,99,104,101,75, -101,121,0,76,105,110,107,78,111,100,101,0,98,71,80,68,115,112,111,105,110,116,0,98,71,80,68,115,116,114,111,107, -101,0,98,71,80,68,102,114,97,109,101,0,98,71,80,68,108,97,121,101,114,0,0,84,76,69,78,1,0,1,0,2, -0,2,0,4,0,4,0,4,0,4,0,8,0,0,0,16,0,24,0,16,0,4,0,8,0,8,0,16,0,12,0,12, -0,24,0,16,0,16,0,32,0,16,0,16,0,32,0,96,0,72,0,72,2,0,0,40,0,-112,0,48,4,112,0,36, -0,56,0,112,0,-128,0,-96,0,24,0,40,0,48,0,-80,0,24,0,-88,0,32,0,-72,1,0,0,0,0,0,0,-112, -0,64,1,120,1,24,0,8,3,-56,0,0,0,-56,0,-120,0,-16,1,56,1,80,0,-16,2,104,0,96,1,0,0,-128, -0,104,0,-72,0,80,0,8,0,16,0,-96,1,0,0,-112,1,20,0,48,0,64,0,24,0,12,0,16,0,4,0,8, -0,8,0,32,0,112,0,48,0,8,0,16,0,8,0,8,0,4,0,4,0,0,1,32,0,16,0,64,0,24,0,12, -0,96,0,0,0,64,0,88,0,104,0,112,0,80,0,112,0,-112,0,80,0,72,0,120,0,72,0,-88,0,-48,0,72, -0,104,0,120,0,-48,0,120,0,-56,0,64,0,96,0,0,0,-120,0,32,0,20,0,-112,0,0,0,80,0,0,0,0, -0,80,0,8,0,8,0,0,1,96,0,-104,1,80,0,80,0,80,0,-72,1,-128,0,120,0,-104,0,48,0,-128,0,72, -0,120,0,-120,0,16,1,-32,0,0,0,16,0,0,0,0,0,0,0,-32,1,40,0,40,0,-72,0,-104,0,56,0,16, -0,88,0,-24,3,64,0,16,0,88,0,16,0,24,1,8,0,72,0,88,0,-16,0,8,0,-8,0,0,0,64,6,0, -0,64,0,88,3,48,0,8,1,0,0,0,0,0,0,32,0,-120,0,48,0,120,1,-16,0,-40,0,-8,1,0,0,0, -0,48,1,16,0,16,0,32,1,-64,0,-112,0,120,2,56,0,-80,0,0,1,-72,2,0,0,-104,0,-48,0,16,0,64, -14,56,0,40,12,-88,0,32,0,40,0,-16,0,40,0,80,0,48,0,16,0,8,0,64,0,0,0,0,1,32,1,-56, -1,8,1,72,1,0,0,32,0,48,0,12,0,24,0,48,0,16,0,32,0,24,0,32,0,72,1,0,0,64,0,64, -0,80,0,48,0,8,0,48,0,72,0,104,0,40,0,8,0,72,0,44,0,40,0,108,0,72,0,96,0,104,0,60, -0,-128,0,80,0,80,0,16,0,96,0,32,0,20,0,88,0,24,0,80,0,112,0,84,0,32,0,96,0,64,0,56, -0,112,0,-116,0,4,0,24,0,16,0,8,0,40,0,0,0,88,0,-64,0,40,0,24,1,-104,0,-48,1,88,0,88, -0,-48,0,56,0,80,0,-128,0,80,0,112,0,56,0,48,0,48,0,72,0,48,0,72,0,48,0,24,0,56,0,104, -0,16,0,112,0,96,0,28,0,28,0,28,0,56,0,24,0,72,0,-88,0,40,0,-112,0,48,0,-8,0,0,0,0, -0,16,0,40,0,28,0,12,0,12,0,16,1,40,0,8,0,8,0,64,0,32,0,24,0,16,0,24,0,32,0,8, -0,32,0,12,0,56,0,24,0,72,0,24,0,56,0,72,0,8,1,16,2,0,0,0,0,0,0,16,0,32,0,40, -0,-64,0,83,84,82,67,57,1,0,0,10,0,2,0,10,0,0,0,10,0,1,0,11,0,3,0,11,0,0,0,11, -0,1,0,9,0,2,0,12,0,2,0,9,0,3,0,9,0,4,0,13,0,2,0,2,0,5,0,2,0,6,0,14, -0,2,0,4,0,5,0,4,0,6,0,15,0,2,0,7,0,5,0,7,0,6,0,16,0,2,0,8,0,5,0,8, -0,6,0,17,0,3,0,4,0,5,0,4,0,6,0,4,0,7,0,18,0,3,0,7,0,5,0,7,0,6,0,7, -0,7,0,19,0,3,0,8,0,5,0,8,0,6,0,8,0,7,0,20,0,4,0,4,0,5,0,4,0,6,0,4, -0,7,0,4,0,8,0,21,0,4,0,7,0,5,0,7,0,6,0,7,0,7,0,7,0,8,0,22,0,4,0,8, -0,5,0,8,0,6,0,8,0,7,0,8,0,8,0,23,0,4,0,4,0,9,0,4,0,10,0,4,0,11,0,4, -0,12,0,24,0,4,0,7,0,9,0,7,0,10,0,7,0,11,0,7,0,12,0,25,0,4,0,9,0,13,0,12, -0,14,0,4,0,15,0,4,0,16,0,26,0,10,0,26,0,0,0,26,0,1,0,0,0,17,0,0,0,18,0,0, -0,19,0,2,0,20,0,4,0,21,0,25,0,22,0,4,0,23,0,4,0,24,0,27,0,9,0,9,0,0,0,9, -0,1,0,27,0,25,0,28,0,26,0,0,0,27,0,2,0,28,0,2,0,20,0,4,0,29,0,26,0,30,0,28, -0,8,0,27,0,31,0,27,0,32,0,29,0,33,0,0,0,34,0,0,0,35,0,4,0,36,0,4,0,37,0,28, -0,38,0,30,0,6,0,4,0,39,0,4,0,40,0,2,0,41,0,2,0,42,0,2,0,43,0,4,0,44,0,31, -0,6,0,32,0,45,0,2,0,46,0,2,0,47,0,2,0,18,0,2,0,20,0,0,0,48,0,33,0,21,0,33, -0,0,0,33,0,1,0,34,0,49,0,35,0,50,0,24,0,51,0,24,0,52,0,2,0,46,0,2,0,47,0,2, -0,53,0,2,0,54,0,2,0,55,0,2,0,56,0,2,0,20,0,2,0,57,0,7,0,11,0,7,0,12,0,4, -0,58,0,7,0,59,0,7,0,60,0,7,0,61,0,31,0,62,0,36,0,7,0,27,0,31,0,12,0,63,0,24, -0,64,0,2,0,46,0,2,0,65,0,2,0,66,0,2,0,37,0,37,0,16,0,37,0,0,0,37,0,1,0,7, -0,67,0,7,0,61,0,2,0,18,0,2,0,47,0,2,0,68,0,2,0,20,0,4,0,69,0,4,0,70,0,9, -0,2,0,7,0,71,0,0,0,17,0,0,0,72,0,7,0,73,0,7,0,74,0,38,0,12,0,27,0,31,0,37, -0,75,0,0,0,76,0,4,0,77,0,7,0,61,0,12,0,78,0,36,0,79,0,27,0,80,0,2,0,18,0,2, -0,81,0,2,0,82,0,2,0,20,0,39,0,5,0,27,0,83,0,2,0,84,0,2,0,85,0,2,0,86,0,4, -0,37,0,40,0,6,0,40,0,0,0,40,0,1,0,0,0,87,0,0,0,88,0,4,0,23,0,4,0,89,0,41, -0,10,0,41,0,0,0,41,0,1,0,4,0,90,0,4,0,91,0,4,0,92,0,4,0,43,0,4,0,14,0,4, -0,93,0,0,0,94,0,0,0,95,0,42,0,15,0,27,0,31,0,0,0,96,0,4,0,93,0,4,0,97,0,12, -0,98,0,40,0,99,0,40,0,100,0,4,0,101,0,4,0,102,0,12,0,103,0,0,0,104,0,4,0,105,0,4, -0,106,0,9,0,107,0,8,0,108,0,43,0,5,0,4,0,109,0,4,0,110,0,4,0,93,0,4,0,37,0,9, -0,2,0,44,0,20,0,27,0,31,0,2,0,18,0,2,0,20,0,7,0,111,0,7,0,112,0,7,0,113,0,7, -0,114,0,7,0,115,0,7,0,116,0,7,0,117,0,7,0,118,0,7,0,119,0,7,0,120,0,7,0,121,0,2, -0,122,0,2,0,123,0,7,0,124,0,36,0,79,0,39,0,125,0,32,0,126,0,45,0,12,0,4,0,127,0,4, -0,-128,0,4,0,-127,0,4,0,-126,0,2,0,-125,0,2,0,-124,0,2,0,20,0,2,0,-123,0,2,0,-122,0,2, -0,-121,0,2,0,-120,0,2,0,-119,0,46,0,32,0,27,0,31,0,0,0,34,0,12,0,-118,0,47,0,-117,0,48, -0,-116,0,49,0,-115,0,2,0,-123,0,2,0,20,0,2,0,-114,0,2,0,18,0,2,0,37,0,2,0,43,0,4, -0,-113,0,2,0,-112,0,2,0,-111,0,2,0,-110,0,2,0,-109,0,2,0,-108,0,2,0,-107,0,4,0,-106,0,4, -0,-105,0,43,0,-104,0,30,0,-103,0,7,0,-102,0,4,0,-101,0,2,0,-100,0,2,0,-99,0,2,0,-98,0,2, -0,-97,0,7,0,-96,0,7,0,-95,0,9,0,-94,0,50,0,31,0,2,0,-93,0,2,0,-92,0,2,0,-91,0,2, -0,-90,0,32,0,-89,0,51,0,-88,0,0,0,-87,0,0,0,-86,0,0,0,-85,0,0,0,-84,0,0,0,-83,0,7, -0,-82,0,7,0,-81,0,2,0,-80,0,2,0,-79,0,2,0,-78,0,2,0,-77,0,2,0,-76,0,2,0,-75,0,2, -0,-74,0,7,0,-73,0,7,0,-72,0,7,0,-71,0,7,0,-70,0,7,0,-69,0,7,0,57,0,7,0,-68,0,7, -0,-67,0,7,0,-66,0,7,0,-65,0,7,0,-64,0,52,0,15,0,0,0,-63,0,9,0,-62,0,0,0,-61,0,0, -0,-60,0,4,0,-59,0,4,0,-58,0,9,0,-57,0,7,0,-56,0,7,0,-55,0,7,0,-54,0,4,0,-53,0,9, -0,-52,0,9,0,-51,0,4,0,-50,0,4,0,37,0,53,0,6,0,7,0,-73,0,7,0,-72,0,7,0,-71,0,7, -0,-49,0,7,0,67,0,4,0,64,0,54,0,5,0,2,0,20,0,2,0,36,0,2,0,64,0,2,0,-48,0,53, -0,-54,0,55,0,17,0,32,0,-89,0,46,0,-47,0,56,0,-46,0,7,0,-45,0,7,0,-44,0,2,0,18,0,2, -0,-43,0,7,0,113,0,7,0,114,0,7,0,-42,0,4,0,-41,0,2,0,-40,0,2,0,-39,0,4,0,-123,0,4, -0,-113,0,2,0,-38,0,2,0,-37,0,51,0,56,0,27,0,31,0,7,0,-36,0,7,0,-35,0,7,0,-34,0,7, -0,-33,0,7,0,-32,0,7,0,-31,0,7,0,-30,0,7,0,-29,0,7,0,-28,0,7,0,-27,0,7,0,-26,0,7, -0,-25,0,7,0,-24,0,7,0,-23,0,7,0,-22,0,7,0,-21,0,7,0,-20,0,7,0,-19,0,7,0,-18,0,7, -0,-17,0,2,0,-16,0,2,0,-15,0,2,0,-14,0,2,0,-13,0,2,0,-12,0,2,0,-11,0,2,0,-10,0,2, -0,20,0,2,0,18,0,2,0,-43,0,7,0,-9,0,7,0,-8,0,7,0,-7,0,7,0,-6,0,2,0,-5,0,2, -0,-4,0,2,0,-3,0,2,0,-125,0,4,0,23,0,4,0,-128,0,4,0,-127,0,4,0,-126,0,7,0,-2,0,7, -0,-1,0,7,0,-67,0,45,0,0,1,57,0,1,1,36,0,79,0,46,0,-47,0,52,0,2,1,54,0,3,1,55, -0,4,1,30,0,-103,0,0,0,5,1,0,0,6,1,58,0,8,0,7,0,7,1,7,0,8,1,7,0,-81,0,4, -0,20,0,7,0,9,1,7,0,10,1,7,0,11,1,32,0,45,0,59,0,80,0,27,0,31,0,2,0,18,0,2, -0,12,1,4,0,13,1,2,0,-79,0,2,0,14,1,7,0,-73,0,7,0,-72,0,7,0,-71,0,7,0,-70,0,7, -0,15,1,7,0,16,1,7,0,17,1,7,0,18,1,7,0,19,1,7,0,20,1,7,0,21,1,7,0,22,1,7, -0,23,1,7,0,24,1,7,0,25,1,60,0,26,1,2,0,27,1,2,0,70,0,7,0,113,0,7,0,114,0,7, -0,28,1,7,0,29,1,7,0,30,1,2,0,31,1,2,0,32,1,2,0,33,1,2,0,34,1,0,0,35,1,0, -0,36,1,2,0,37,1,2,0,38,1,2,0,39,1,2,0,40,1,2,0,41,1,7,0,42,1,7,0,43,1,7, -0,44,1,7,0,45,1,2,0,46,1,2,0,43,0,2,0,47,1,2,0,48,1,2,0,49,1,2,0,50,1,7, -0,51,1,7,0,52,1,7,0,53,1,7,0,54,1,7,0,55,1,7,0,56,1,7,0,57,1,7,0,58,1,7, -0,59,1,7,0,60,1,7,0,61,1,7,0,62,1,2,0,63,1,2,0,64,1,4,0,65,1,4,0,66,1,2, -0,67,1,2,0,68,1,2,0,69,1,2,0,70,1,7,0,71,1,7,0,72,1,7,0,73,1,7,0,74,1,2, -0,75,1,2,0,76,1,50,0,77,1,36,0,79,0,30,0,-103,0,39,0,125,0,61,0,2,0,27,0,31,0,36, -0,79,0,62,0,-127,0,27,0,31,0,2,0,-79,0,2,0,20,0,7,0,-73,0,7,0,-72,0,7,0,-71,0,7, -0,78,1,7,0,79,1,7,0,80,1,7,0,81,1,7,0,82,1,7,0,83,1,7,0,84,1,7,0,85,1,7, -0,86,1,7,0,87,1,7,0,88,1,7,0,89,1,7,0,90,1,7,0,91,1,7,0,92,1,7,0,93,1,7, -0,94,1,7,0,95,1,7,0,96,1,7,0,97,1,7,0,98,1,7,0,99,1,7,0,100,1,7,0,101,1,7, -0,102,1,7,0,103,1,7,0,104,1,2,0,105,1,2,0,106,1,2,0,107,1,0,0,108,1,0,0,109,1,7, -0,110,1,7,0,111,1,2,0,112,1,2,0,113,1,7,0,114,1,7,0,115,1,7,0,116,1,7,0,117,1,2, -0,118,1,2,0,119,1,4,0,13,1,4,0,120,1,2,0,121,1,2,0,122,1,2,0,123,1,2,0,124,1,7, -0,125,1,7,0,126,1,7,0,127,1,7,0,-128,1,7,0,-127,1,7,0,-126,1,7,0,-125,1,7,0,-124,1,7, -0,-123,1,7,0,-122,1,0,0,-121,1,7,0,-120,1,7,0,-119,1,7,0,-118,1,4,0,-117,1,0,0,-116,1,0, -0,47,1,0,0,-115,1,0,0,5,1,2,0,-114,1,2,0,-113,1,2,0,64,1,2,0,-112,1,2,0,-111,1,2, -0,-110,1,7,0,-109,1,7,0,-108,1,7,0,-107,1,7,0,-106,1,7,0,-105,1,2,0,-93,0,2,0,-92,0,54, -0,-104,1,54,0,-103,1,0,0,-102,1,0,0,-101,1,0,0,-100,1,0,0,-99,1,2,0,-98,1,2,0,12,1,7, -0,-97,1,7,0,-96,1,50,0,77,1,57,0,1,1,36,0,79,0,63,0,-95,1,30,0,-103,0,7,0,-94,1,7, -0,-93,1,7,0,-92,1,7,0,-91,1,7,0,-90,1,2,0,-89,1,2,0,70,0,7,0,-88,1,7,0,-87,1,7, -0,-86,1,7,0,-85,1,7,0,-84,1,7,0,-83,1,7,0,-82,1,7,0,-81,1,7,0,-80,1,2,0,-79,1,2, -0,-78,1,7,0,-77,1,7,0,-76,1,7,0,-75,1,7,0,-74,1,7,0,-73,1,4,0,-72,1,4,0,-71,1,4, -0,-70,1,39,0,125,0,12,0,-69,1,64,0,6,0,27,0,31,0,0,0,-68,1,7,0,-67,1,7,0,37,0,65, -0,2,0,43,0,-104,0,66,0,26,0,66,0,0,0,66,0,1,0,67,0,-66,1,4,0,-65,1,4,0,-64,1,4, -0,-63,1,4,0,-62,1,4,0,-61,1,4,0,-60,1,2,0,18,0,2,0,20,0,2,0,-59,1,2,0,-58,1,7, -0,5,0,7,0,6,0,7,0,7,0,7,0,-57,1,7,0,-56,1,7,0,-55,1,7,0,-54,1,7,0,-53,1,7, -0,-52,1,7,0,-51,1,7,0,23,0,7,0,-50,1,7,0,-49,1,68,0,15,0,27,0,31,0,67,0,-66,1,12, -0,-48,1,12,0,-47,1,36,0,79,0,62,0,-46,1,2,0,20,0,2,0,-45,1,4,0,-80,0,7,0,7,1,7, -0,-81,0,7,0,8,1,7,0,-44,1,7,0,-43,1,7,0,-42,1,35,0,10,0,7,0,-41,1,7,0,-40,1,7, -0,-39,1,7,0,-38,1,2,0,-37,1,2,0,-36,1,0,0,-35,1,0,0,-34,1,0,0,-33,1,0,0,-32,1,34, -0,7,0,7,0,-31,1,7,0,-40,1,7,0,-39,1,2,0,-35,1,2,0,-32,1,7,0,-38,1,7,0,37,0,69, -0,21,0,69,0,0,0,69,0,1,0,2,0,18,0,2,0,-30,1,2,0,-32,1,2,0,20,0,2,0,-29,1,2, -0,-28,1,2,0,-27,1,2,0,-26,1,2,0,-25,1,2,0,-24,1,2,0,-23,1,2,0,-22,1,7,0,-21,1,7, -0,-20,1,34,0,49,0,35,0,50,0,2,0,-19,1,2,0,-18,1,4,0,-17,1,70,0,5,0,2,0,-16,1,2, -0,-30,1,0,0,20,0,0,0,37,0,2,0,70,0,71,0,4,0,7,0,5,0,7,0,6,0,7,0,8,0,7, -0,-15,1,72,0,57,0,27,0,31,0,67,0,-66,1,12,0,-14,1,12,0,-47,1,32,0,-13,1,32,0,-12,1,32, -0,-11,1,36,0,79,0,73,0,-10,1,38,0,-9,1,62,0,-46,1,12,0,-8,1,7,0,7,1,7,0,-81,0,7, -0,8,1,4,0,-80,0,2,0,-7,1,2,0,-45,1,2,0,20,0,2,0,-6,1,7,0,-5,1,7,0,-4,1,7, -0,-3,1,2,0,-27,1,2,0,-26,1,2,0,-2,1,2,0,-1,1,4,0,70,0,2,0,23,0,2,0,98,0,2, -0,67,0,2,0,0,2,7,0,1,2,7,0,2,2,7,0,3,2,7,0,4,2,7,0,5,2,7,0,6,2,7, -0,7,2,7,0,8,2,7,0,9,2,7,0,10,2,0,0,11,2,0,0,12,2,64,0,13,2,64,0,14,2,64, -0,15,2,64,0,16,2,4,0,17,2,4,0,18,2,4,0,19,2,4,0,37,0,71,0,20,2,4,0,21,2,4, -0,22,2,70,0,23,2,70,0,24,2,74,0,39,0,27,0,31,0,67,0,-66,1,12,0,25,2,36,0,79,0,38, -0,-9,1,62,0,-46,1,75,0,26,2,76,0,27,2,77,0,28,2,78,0,29,2,79,0,30,2,80,0,31,2,81, -0,32,2,82,0,33,2,74,0,34,2,83,0,35,2,84,0,36,2,84,0,37,2,84,0,38,2,4,0,54,0,4, -0,39,2,4,0,40,2,4,0,41,2,4,0,42,2,4,0,-80,0,7,0,7,1,7,0,-81,0,7,0,8,1,7, -0,43,2,7,0,37,0,2,0,44,2,2,0,20,0,2,0,45,2,2,0,46,2,2,0,-45,1,2,0,47,2,85, -0,48,2,86,0,49,2,9,0,-94,0,77,0,8,0,9,0,50,2,7,0,51,2,4,0,52,2,0,0,20,0,0, -0,53,2,2,0,13,1,2,0,54,2,2,0,55,2,75,0,8,0,4,0,56,2,4,0,57,2,4,0,58,2,4, -0,59,2,0,0,37,0,0,0,-30,1,0,0,60,2,0,0,20,0,79,0,5,0,4,0,56,2,4,0,57,2,0, -0,61,2,0,0,62,2,2,0,20,0,87,0,2,0,4,0,63,2,7,0,-39,1,80,0,3,0,87,0,64,2,4, -0,65,2,4,0,20,0,78,0,6,0,7,0,66,2,2,0,67,2,0,0,20,0,0,0,-30,1,0,0,62,2,0, -0,68,2,81,0,4,0,0,0,-49,0,0,0,-73,0,0,0,-72,0,0,0,-71,0,88,0,6,0,46,0,50,2,0, -0,20,0,0,0,53,2,2,0,13,1,2,0,54,2,2,0,55,2,89,0,1,0,7,0,69,2,90,0,5,0,0, -0,-49,0,0,0,-73,0,0,0,-72,0,0,0,-71,0,4,0,37,0,82,0,1,0,7,0,70,2,83,0,2,0,4, -0,71,2,4,0,18,0,76,0,7,0,7,0,51,2,46,0,50,2,0,0,20,0,0,0,53,2,2,0,13,1,2, -0,54,2,2,0,55,2,91,0,1,0,7,0,72,2,92,0,1,0,4,0,73,2,93,0,1,0,0,0,74,2,94, -0,1,0,7,0,51,2,95,0,4,0,7,0,-49,0,7,0,-73,0,7,0,-72,0,7,0,-71,0,96,0,1,0,95, -0,52,2,97,0,5,0,4,0,75,2,4,0,76,2,0,0,20,0,0,0,-30,1,0,0,-74,0,98,0,2,0,4, -0,77,2,4,0,76,2,99,0,14,0,99,0,0,0,99,0,1,0,97,0,78,2,96,0,79,2,98,0,80,2,0, -0,81,2,12,0,82,2,12,0,83,2,100,0,84,2,4,0,54,0,4,0,40,2,4,0,39,2,4,0,37,0,78, -0,85,2,85,0,14,0,12,0,86,2,78,0,85,2,0,0,87,2,0,0,88,2,0,0,89,2,0,0,90,2,0, -0,91,2,0,0,92,2,0,0,93,2,0,0,20,0,84,0,36,2,84,0,38,2,2,0,94,2,0,0,95,2,86, -0,8,0,4,0,96,2,4,0,97,2,75,0,98,2,79,0,99,2,4,0,40,2,4,0,39,2,4,0,54,0,4, -0,37,0,101,0,6,0,101,0,0,0,101,0,1,0,4,0,18,0,4,0,13,1,0,0,17,0,0,0,100,2,102, -0,7,0,101,0,101,2,2,0,102,2,2,0,86,2,2,0,103,2,2,0,93,0,9,0,104,2,9,0,105,2,103, -0,3,0,101,0,101,2,32,0,-89,0,0,0,17,0,104,0,5,0,101,0,101,2,32,0,-89,0,0,0,17,0,2, -0,106,2,0,0,107,2,105,0,5,0,101,0,101,2,7,0,91,0,7,0,108,2,4,0,109,2,4,0,110,2,106, -0,5,0,101,0,101,2,32,0,111,2,0,0,72,0,4,0,13,1,4,0,20,0,107,0,13,0,101,0,101,2,32, -0,112,2,32,0,113,2,32,0,114,2,32,0,115,2,7,0,116,2,7,0,117,2,7,0,108,2,7,0,118,2,4, -0,119,2,4,0,120,2,4,0,93,0,4,0,121,2,108,0,5,0,101,0,101,2,2,0,122,2,2,0,20,0,7, -0,123,2,32,0,124,2,109,0,3,0,101,0,101,2,7,0,125,2,4,0,93,0,110,0,10,0,101,0,101,2,7, -0,126,2,4,0,127,2,4,0,37,0,2,0,93,0,2,0,-128,2,2,0,-127,2,2,0,-126,2,7,0,-125,2,0, -0,-124,2,111,0,3,0,101,0,101,2,7,0,37,0,4,0,18,0,112,0,11,0,101,0,101,2,51,0,-123,2,7, -0,-122,2,4,0,-121,2,0,0,-124,2,7,0,-120,2,4,0,-119,2,32,0,-118,2,0,0,-117,2,4,0,-116,2,4, -0,37,0,113,0,10,0,101,0,101,2,32,0,-115,2,46,0,-114,2,4,0,93,0,4,0,-113,2,7,0,-112,2,7, -0,-111,2,0,0,-117,2,4,0,-116,2,4,0,37,0,114,0,3,0,101,0,101,2,7,0,-110,2,4,0,-109,2,115, -0,5,0,101,0,101,2,7,0,-108,2,0,0,-124,2,2,0,20,0,2,0,-107,2,116,0,8,0,101,0,101,2,32, -0,-89,0,7,0,-108,2,7,0,-38,1,7,0,109,0,0,0,-124,2,2,0,20,0,2,0,18,0,117,0,21,0,101, -0,101,2,32,0,-106,2,0,0,-124,2,51,0,-123,2,32,0,-118,2,2,0,20,0,2,0,37,0,7,0,-105,2,7, -0,-104,2,7,0,-103,2,7,0,-5,1,7,0,-102,2,7,0,-101,2,7,0,-100,2,7,0,-99,2,4,0,-119,2,4, -0,-116,2,0,0,-117,2,7,0,-98,2,7,0,-97,2,7,0,43,0,118,0,7,0,101,0,101,2,2,0,-96,2,2, -0,-95,2,4,0,70,0,32,0,-89,0,7,0,-94,2,0,0,-124,2,119,0,9,0,101,0,101,2,32,0,-89,0,7, -0,-93,2,7,0,-92,2,7,0,-99,2,4,0,-91,2,4,0,-90,2,7,0,-89,2,0,0,17,0,120,0,1,0,101, -0,101,2,121,0,5,0,101,0,101,2,122,0,-88,2,123,0,-87,2,124,0,-86,2,125,0,-85,2,126,0,14,0,101, -0,101,2,78,0,-84,2,78,0,-83,2,78,0,-82,2,78,0,-81,2,78,0,-80,2,78,0,-79,2,75,0,-78,2,4, -0,-77,2,4,0,-76,2,2,0,-75,2,2,0,37,0,7,0,-74,2,127,0,-73,2,-128,0,3,0,101,0,101,2,-127, -0,-72,2,-126,0,-73,2,-125,0,4,0,101,0,101,2,32,0,-89,0,4,0,-71,2,4,0,37,0,-124,0,2,0,4, -0,-70,2,7,0,-39,1,-123,0,2,0,4,0,-127,0,4,0,-69,2,-122,0,20,0,101,0,101,2,32,0,-89,0,0, -0,-124,2,2,0,-68,2,2,0,-67,2,2,0,20,0,2,0,37,0,7,0,-66,2,7,0,-65,2,4,0,54,0,4, -0,-64,2,-123,0,-63,2,-124,0,-62,2,4,0,-61,2,4,0,-60,2,4,0,-59,2,4,0,-69,2,7,0,-58,2,7, -0,-57,2,7,0,-56,2,-121,0,8,0,101,0,101,2,-120,0,-55,2,-127,0,-72,2,4,0,-54,2,4,0,-53,2,4, -0,-52,2,2,0,20,0,2,0,57,0,-119,0,5,0,101,0,101,2,32,0,45,0,2,0,-51,2,2,0,20,0,2, -0,-50,2,-118,0,5,0,101,0,101,2,4,0,-49,2,2,0,20,0,2,0,-48,2,7,0,-47,2,-117,0,3,0,101, -0,101,2,-116,0,-46,2,125,0,-85,2,-115,0,10,0,101,0,101,2,32,0,-45,2,32,0,-44,2,0,0,-43,2,7, -0,-42,2,2,0,-41,2,2,0,-40,2,0,0,-39,2,0,0,-38,2,0,0,107,2,-114,0,9,0,101,0,101,2,32, -0,-37,2,0,0,-43,2,7,0,-36,2,7,0,-35,2,0,0,13,1,0,0,122,2,0,0,-34,2,0,0,37,0,-113, -0,24,0,27,0,31,0,2,0,-29,1,2,0,-28,1,2,0,-33,2,2,0,20,0,2,0,-32,2,2,0,-31,2,2, -0,-30,2,2,0,70,0,0,0,-29,2,0,0,-28,2,0,0,-27,2,0,0,18,0,4,0,37,0,7,0,-26,2,7, -0,-25,2,7,0,-24,2,7,0,-23,2,7,0,-22,2,7,0,-21,2,34,0,-20,2,36,0,79,0,38,0,-9,1,80, -0,31,2,-112,0,3,0,-112,0,0,0,-112,0,1,0,0,0,17,0,67,0,3,0,7,0,-19,2,4,0,20,0,4, -0,37,0,32,0,111,0,27,0,31,0,2,0,18,0,2,0,-18,2,4,0,-17,2,4,0,-16,2,4,0,-15,2,0, -0,-14,2,32,0,38,0,32,0,-13,2,32,0,-12,2,32,0,-11,2,32,0,-10,2,36,0,79,0,73,0,-10,1,67, -0,-66,1,-111,0,-9,2,-111,0,-8,2,-110,0,-7,2,9,0,2,0,12,0,-6,2,12,0,25,2,12,0,-47,1,12, -0,-5,2,12,0,-4,2,62,0,-46,1,7,0,7,1,7,0,-3,2,7,0,-2,2,7,0,-81,0,7,0,-1,2,7, -0,8,1,7,0,0,3,7,0,1,3,7,0,-93,2,7,0,2,3,7,0,-45,0,4,0,3,3,2,0,20,0,2, -0,4,3,2,0,5,3,2,0,6,3,2,0,7,3,2,0,8,3,2,0,9,3,2,0,10,3,2,0,11,3,2, -0,12,3,2,0,13,3,2,0,14,3,4,0,15,3,4,0,16,3,4,0,17,3,4,0,18,3,7,0,19,3,7, -0,20,3,7,0,21,3,7,0,22,3,7,0,23,3,7,0,24,3,7,0,25,3,7,0,26,3,7,0,27,3,7, -0,28,3,7,0,29,3,7,0,30,3,0,0,31,3,0,0,32,3,0,0,-45,1,0,0,33,3,0,0,34,3,0, -0,35,3,7,0,36,3,7,0,37,3,39,0,125,0,12,0,38,3,12,0,39,3,12,0,40,3,12,0,41,3,7, -0,42,3,2,0,71,2,2,0,43,3,7,0,52,2,4,0,44,3,4,0,45,3,-109,0,46,3,2,0,47,3,2, -0,-38,0,7,0,48,3,12,0,49,3,12,0,50,3,12,0,51,3,12,0,52,3,-108,0,53,3,-107,0,54,3,63, -0,55,3,2,0,56,3,2,0,57,3,2,0,58,3,2,0,59,3,7,0,44,2,2,0,60,3,2,0,61,3,-116, -0,62,3,-127,0,63,3,-127,0,64,3,4,0,65,3,4,0,66,3,4,0,67,3,4,0,70,0,9,0,-94,0,12, -0,68,3,-106,0,14,0,-106,0,0,0,-106,0,1,0,32,0,38,0,7,0,-93,2,7,0,9,1,7,0,-92,2,7, -0,-99,2,0,0,17,0,4,0,-91,2,4,0,-90,2,4,0,69,3,2,0,18,0,2,0,70,3,7,0,-89,2,-108, -0,36,0,2,0,71,3,2,0,72,3,2,0,20,0,2,0,-99,2,7,0,73,3,7,0,74,3,7,0,75,3,7, -0,76,3,7,0,77,3,7,0,78,3,7,0,79,3,7,0,80,3,7,0,81,3,7,0,82,3,7,0,83,3,7, -0,84,3,7,0,85,3,7,0,86,3,7,0,87,3,7,0,88,3,7,0,89,3,7,0,90,3,7,0,91,3,7, -0,92,3,7,0,93,3,7,0,94,3,7,0,95,3,7,0,96,3,2,0,97,3,2,0,98,3,2,0,99,3,2, -0,100,3,51,0,-88,0,-105,0,101,3,7,0,102,3,4,0,110,2,125,0,5,0,4,0,20,0,4,0,103,3,4, -0,104,3,4,0,105,3,4,0,106,3,-104,0,1,0,7,0,-31,1,-109,0,30,0,4,0,20,0,7,0,107,3,7, -0,108,3,7,0,109,3,4,0,110,3,4,0,111,3,4,0,112,3,4,0,113,3,7,0,114,3,7,0,115,3,7, -0,116,3,7,0,117,3,7,0,118,3,7,0,119,3,7,0,120,3,7,0,121,3,7,0,122,3,7,0,123,3,7, -0,124,3,7,0,125,3,7,0,126,3,7,0,127,3,7,0,-128,3,7,0,-127,3,7,0,-126,3,7,0,-125,3,4, -0,-124,3,4,0,-123,3,7,0,-122,3,7,0,27,3,-107,0,49,0,-120,0,-121,3,4,0,-120,3,4,0,-119,3,-103, -0,-118,3,-102,0,-117,3,0,0,37,0,0,0,-116,3,2,0,-115,3,7,0,-114,3,0,0,-113,3,7,0,-112,3,7, -0,-111,3,7,0,-110,3,7,0,-109,3,7,0,-108,3,7,0,-107,3,7,0,-106,3,7,0,-105,3,7,0,-104,3,2, -0,-103,3,0,0,-102,3,2,0,-101,3,7,0,-100,3,7,0,-99,3,0,0,-98,3,4,0,-126,0,4,0,-97,3,4, -0,-96,3,2,0,-95,3,2,0,-94,3,-104,0,-93,3,4,0,-92,3,4,0,81,0,7,0,-91,3,7,0,-90,3,7, -0,-89,3,7,0,-88,3,2,0,-87,3,2,0,-86,3,2,0,-85,3,2,0,-84,3,2,0,-83,3,2,0,-82,3,2, -0,-81,3,2,0,-80,3,-101,0,-79,3,7,0,-78,3,7,0,-77,3,125,0,-76,3,-116,0,48,0,2,0,18,0,2, -0,-75,3,2,0,-74,3,2,0,-73,3,7,0,-72,3,2,0,-71,3,2,0,-70,3,7,0,-69,3,2,0,-68,3,2, -0,-67,3,7,0,-66,3,7,0,-65,3,7,0,-64,3,7,0,-63,3,7,0,-62,3,7,0,-61,3,4,0,-60,3,7, -0,-59,3,7,0,-58,3,7,0,-57,3,74,0,-56,3,74,0,-55,3,74,0,-54,3,0,0,-53,3,7,0,-52,3,7, -0,-51,3,36,0,79,0,2,0,-50,3,0,0,-49,3,0,0,-48,3,7,0,-47,3,4,0,-46,3,7,0,-45,3,7, -0,-44,3,4,0,-43,3,4,0,20,0,7,0,-42,3,7,0,-41,3,7,0,-40,3,78,0,-39,3,7,0,-38,3,7, -0,-37,3,7,0,-36,3,7,0,-35,3,7,0,-34,3,7,0,-33,3,7,0,-32,3,4,0,-31,3,-100,0,71,0,27, -0,31,0,2,0,-79,0,2,0,14,1,2,0,47,1,2,0,-30,3,7,0,-29,3,7,0,-28,3,7,0,-27,3,7, -0,-26,3,7,0,-25,3,7,0,-24,3,7,0,-23,3,7,0,-22,3,7,0,84,1,7,0,86,1,7,0,85,1,7, -0,-21,3,4,0,-20,3,7,0,-19,3,7,0,-18,3,7,0,-17,3,7,0,-16,3,7,0,-15,3,7,0,-14,3,7, -0,-13,3,2,0,-12,3,2,0,13,1,2,0,-11,3,2,0,-10,3,2,0,-9,3,2,0,-8,3,2,0,-7,3,2, -0,-6,3,7,0,-5,3,7,0,-4,3,7,0,-3,3,7,0,-2,3,7,0,-1,3,7,0,0,4,7,0,1,4,7, -0,2,4,7,0,3,4,7,0,4,4,7,0,5,4,7,0,6,4,2,0,7,4,2,0,8,4,2,0,9,4,2, -0,10,4,7,0,11,4,7,0,12,4,7,0,13,4,7,0,14,4,2,0,15,4,2,0,16,4,2,0,17,4,2, -0,18,4,7,0,19,4,7,0,20,4,7,0,21,4,7,0,22,4,2,0,23,4,2,0,24,4,2,0,25,4,2, -0,43,0,7,0,26,4,7,0,27,4,36,0,79,0,50,0,77,1,30,0,-103,0,39,0,125,0,-99,0,16,0,2, -0,28,4,2,0,29,4,2,0,30,4,2,0,20,0,2,0,31,4,2,0,32,4,2,0,33,4,2,0,34,4,2, -0,35,4,2,0,36,4,2,0,37,4,2,0,38,4,4,0,39,4,7,0,40,4,7,0,41,4,7,0,42,4,-98, -0,8,0,-98,0,0,0,-98,0,1,0,4,0,3,3,4,0,43,4,4,0,20,0,2,0,44,4,2,0,45,4,32, -0,-89,0,-97,0,13,0,9,0,46,4,9,0,47,4,4,0,48,4,4,0,49,4,4,0,50,4,4,0,51,4,4, -0,52,4,4,0,53,4,4,0,54,4,4,0,55,4,4,0,56,4,4,0,37,0,0,0,57,4,-96,0,5,0,9, -0,58,4,9,0,59,4,4,0,60,4,4,0,70,0,0,0,61,4,-95,0,13,0,4,0,18,0,4,0,62,4,4, -0,63,4,4,0,64,4,4,0,65,4,4,0,66,4,4,0,93,0,4,0,67,4,4,0,68,4,4,0,69,4,4, -0,70,4,4,0,71,4,26,0,30,0,-94,0,4,0,4,0,72,4,7,0,73,4,2,0,20,0,2,0,68,2,-93, -0,11,0,-93,0,0,0,-93,0,1,0,0,0,17,0,62,0,74,4,63,0,75,4,4,0,3,3,4,0,76,4,4, -0,77,4,4,0,37,0,4,0,78,4,4,0,79,4,-92,0,-126,0,-97,0,80,4,-96,0,81,4,-95,0,82,4,4, -0,83,4,4,0,-126,0,4,0,-97,3,4,0,84,4,4,0,85,4,4,0,86,4,4,0,87,4,2,0,20,0,2, -0,88,4,7,0,20,3,7,0,89,4,7,0,90,4,7,0,91,4,7,0,92,4,7,0,93,4,2,0,94,4,2, -0,95,4,2,0,96,4,2,0,97,4,2,0,-39,0,2,0,98,4,2,0,99,4,2,0,100,3,2,0,100,4,2, -0,101,4,2,0,34,1,2,0,109,0,2,0,102,4,2,0,103,4,2,0,104,4,2,0,105,4,2,0,106,4,2, -0,107,4,2,0,108,4,2,0,109,4,2,0,110,4,2,0,35,1,2,0,111,4,2,0,112,4,2,0,113,4,2, -0,114,4,4,0,115,4,4,0,13,1,2,0,116,4,2,0,117,4,2,0,118,4,2,0,119,4,2,0,120,4,2, -0,121,4,24,0,122,4,24,0,123,4,23,0,124,4,12,0,125,4,2,0,126,4,2,0,37,0,7,0,127,4,7, -0,-128,4,7,0,-127,4,7,0,-126,4,7,0,-125,4,7,0,-124,4,7,0,-123,4,7,0,-122,4,7,0,-121,4,2, -0,-120,4,2,0,-119,4,2,0,-118,4,2,0,-117,4,2,0,-116,4,2,0,-115,4,7,0,-114,4,7,0,-113,4,7, -0,-112,4,2,0,-111,4,2,0,-110,4,2,0,-109,4,2,0,-108,4,2,0,-107,4,2,0,-106,4,2,0,-105,4,2, -0,-104,4,2,0,-103,4,2,0,-102,4,4,0,-101,4,4,0,-100,4,4,0,-99,4,4,0,-98,4,4,0,-97,4,7, -0,-96,4,4,0,-95,4,4,0,-94,4,4,0,-93,4,4,0,-92,4,7,0,-91,4,7,0,-90,4,7,0,-89,4,7, -0,-88,4,7,0,-87,4,7,0,-86,4,7,0,-85,4,7,0,-84,4,7,0,-83,4,0,0,-82,4,0,0,-81,4,4, -0,-80,4,2,0,-79,4,2,0,12,1,0,0,-78,4,7,0,-77,4,7,0,-76,4,4,0,-75,4,4,0,-74,4,7, -0,-73,4,7,0,-72,4,2,0,-71,4,2,0,-70,4,7,0,-69,4,2,0,-68,4,2,0,-67,4,4,0,-66,4,2, -0,-65,4,2,0,-64,4,2,0,-63,4,2,0,-62,4,7,0,-61,4,7,0,70,0,42,0,-60,4,-91,0,9,0,-91, -0,0,0,-91,0,1,0,0,0,17,0,2,0,-59,4,2,0,-58,4,2,0,-57,4,2,0,43,0,7,0,-56,4,7, -0,70,0,-90,0,5,0,7,0,-55,4,0,0,18,0,0,0,43,0,0,0,70,0,0,0,12,1,-89,0,5,0,-89, -0,0,0,-89,0,1,0,4,0,-54,4,0,0,-53,4,4,0,20,0,-88,0,5,0,-87,0,-52,4,2,0,20,0,2, -0,-51,4,2,0,-50,4,2,0,-49,4,-86,0,4,0,2,0,109,0,2,0,-122,2,2,0,-48,4,2,0,-47,4,-85, -0,7,0,2,0,20,0,2,0,-46,4,2,0,-45,4,2,0,-44,4,-86,0,-43,4,7,0,-42,4,4,0,-41,4,-84, -0,4,0,-84,0,0,0,-84,0,1,0,0,0,-40,4,7,0,-39,4,-83,0,56,0,2,0,-38,4,2,0,-37,4,7, -0,-36,4,7,0,-35,4,2,0,-48,4,2,0,-34,4,7,0,-33,4,7,0,-32,4,2,0,-31,4,2,0,-30,4,2, -0,-29,4,2,0,-28,4,7,0,-27,4,7,0,-26,4,7,0,-25,4,7,0,37,0,2,0,-24,4,2,0,-23,4,2, -0,-22,4,2,0,-21,4,-88,0,-20,4,-85,0,-19,4,7,0,-18,4,7,0,-17,4,0,0,-16,4,0,0,-15,4,0, -0,-14,4,0,0,-13,4,0,0,-12,4,0,0,-11,4,2,0,-10,4,7,0,-9,4,7,0,-8,4,7,0,-7,4,7, -0,-6,4,7,0,-5,4,7,0,-4,4,7,0,-3,4,7,0,-2,4,7,0,-1,4,7,0,0,5,2,0,1,5,0, -0,2,5,0,0,3,5,0,0,4,5,0,0,5,5,32,0,6,5,0,0,7,5,0,0,8,5,0,0,9,5,0, -0,10,5,0,0,11,5,0,0,12,5,0,0,13,5,0,0,14,5,0,0,15,5,-82,0,6,0,2,0,109,0,0, -0,-122,2,0,0,16,5,0,0,17,5,0,0,20,0,0,0,-74,0,-81,0,26,0,-80,0,18,5,50,0,77,1,60, -0,19,5,-82,0,20,5,-82,0,21,5,-82,0,22,5,-82,0,23,5,-82,0,24,5,-82,0,25,5,-82,0,26,5,7, -0,27,5,2,0,28,5,2,0,47,1,2,0,29,5,2,0,1,2,0,0,30,5,0,0,31,5,0,0,32,5,0, -0,33,5,0,0,93,0,0,0,34,5,0,0,35,5,0,0,36,5,0,0,37,5,0,0,38,5,0,0,-74,0,-79, -0,43,0,27,0,31,0,32,0,39,5,-100,0,40,5,-79,0,41,5,46,0,-47,0,12,0,42,5,-98,0,43,5,7, -0,44,5,7,0,45,5,7,0,46,5,7,0,47,5,4,0,3,3,7,0,48,5,2,0,49,5,2,0,50,5,2, -0,51,5,2,0,52,5,2,0,53,5,2,0,54,5,2,0,55,5,2,0,5,1,57,0,1,1,9,0,56,5,-99, -0,57,5,-90,0,58,5,-83,0,59,5,-92,0,-73,0,-94,0,60,5,39,0,125,0,12,0,103,0,12,0,61,5,2, -0,62,5,2,0,63,5,2,0,64,5,2,0,65,5,-78,0,66,5,2,0,67,5,2,0,68,5,2,0,64,1,2, -0,-38,0,-81,0,69,5,4,0,70,5,4,0,37,0,-77,0,9,0,46,0,-47,0,45,0,0,1,7,0,8,2,7, -0,9,2,7,0,109,0,7,0,71,5,7,0,72,5,2,0,73,5,2,0,74,5,-76,0,75,0,-75,0,0,0,-75, -0,1,0,4,0,75,5,7,0,76,5,-74,0,77,5,2,0,78,5,7,0,79,5,7,0,80,5,7,0,81,5,7, -0,82,5,7,0,83,5,7,0,84,5,7,0,85,5,7,0,20,1,7,0,86,5,4,0,87,5,2,0,88,5,2, -0,17,5,32,0,39,5,32,0,89,5,-77,0,90,5,-76,0,91,5,-73,0,92,5,-72,0,93,5,-71,0,94,5,0, -0,95,5,2,0,30,4,2,0,96,5,4,0,3,3,4,0,97,5,2,0,98,5,2,0,99,5,2,0,100,5,0, -0,101,5,0,0,43,0,7,0,115,0,7,0,102,5,7,0,103,5,7,0,104,5,7,0,105,5,7,0,106,5,7, -0,107,5,7,0,108,5,7,0,-82,0,7,0,44,5,2,0,109,5,2,0,110,5,2,0,111,5,2,0,112,5,2, -0,-119,0,2,0,29,5,2,0,113,5,2,0,114,5,2,0,115,5,2,0,116,5,7,0,117,5,7,0,118,5,67, -0,119,5,12,0,120,5,2,0,121,5,2,0,53,2,2,0,122,5,2,0,20,0,2,0,123,5,2,0,124,5,2, -0,125,5,0,0,126,5,0,0,127,5,9,0,-128,5,-70,0,-127,5,7,0,-126,5,2,0,-125,5,2,0,-124,5,2, -0,53,5,2,0,54,5,-69,0,19,0,24,0,36,0,24,0,64,0,23,0,-123,5,23,0,-122,5,23,0,-121,5,7, -0,-120,5,7,0,-119,5,7,0,-118,5,7,0,-117,5,2,0,-116,5,2,0,-115,5,2,0,-114,5,2,0,-113,5,2, -0,-112,5,2,0,-111,5,4,0,20,0,7,0,-110,5,2,0,99,5,0,0,107,2,-75,0,6,0,-75,0,0,0,-75, -0,1,0,4,0,75,5,7,0,76,5,-74,0,77,5,2,0,78,5,-68,0,6,0,-75,0,0,0,-75,0,1,0,4, -0,75,5,7,0,76,5,-74,0,77,5,2,0,78,5,-67,0,27,0,-75,0,0,0,-75,0,1,0,4,0,75,5,7, -0,76,5,-74,0,77,5,2,0,78,5,4,0,-109,5,4,0,70,0,-69,0,-108,5,9,0,-107,5,12,0,-106,5,36, -0,79,0,27,0,80,0,0,0,-105,5,0,0,-104,5,0,0,-103,5,2,0,-102,5,2,0,-101,5,2,0,-100,5,2, -0,-99,5,2,0,65,0,2,0,46,0,2,0,-119,0,2,0,-98,5,4,0,20,0,7,0,-97,5,24,0,36,0,-66, -0,29,0,-75,0,0,0,-75,0,1,0,4,0,75,5,7,0,76,5,-74,0,77,5,-73,0,92,5,2,0,78,5,2, -0,-96,5,2,0,-95,5,2,0,-94,5,2,0,-93,5,-69,0,-108,5,2,0,-92,5,2,0,-119,0,2,0,-101,5,2, -0,-91,5,9,0,-90,5,2,0,29,5,0,0,-89,5,0,0,-88,5,2,0,-87,5,2,0,-86,5,2,0,12,3,2, -0,-85,5,2,0,-84,5,0,0,37,0,0,0,20,0,0,0,47,1,0,0,-83,5,-65,0,16,0,-75,0,0,0,-75, -0,1,0,4,0,75,5,7,0,76,5,-74,0,77,5,2,0,78,5,-69,0,-108,5,7,0,8,2,7,0,9,2,2, -0,-92,5,2,0,-82,5,2,0,-81,5,2,0,-80,5,4,0,20,0,7,0,71,5,-70,0,-127,5,-64,0,33,0,-75, -0,0,0,-75,0,1,0,4,0,75,5,7,0,76,5,-74,0,77,5,2,0,78,5,-63,0,-79,5,4,0,-78,5,0, -0,-77,5,0,0,-76,5,0,0,-75,5,2,0,18,0,2,0,-74,5,2,0,20,0,2,0,-73,5,2,0,-72,5,2, -0,-71,5,2,0,-70,5,2,0,43,0,4,0,70,0,0,0,-69,5,-62,0,-68,5,2,0,-67,5,2,0,-66,5,2, -0,-65,5,2,0,-48,0,9,0,-64,5,9,0,-63,5,9,0,-62,5,9,0,-61,5,9,0,-60,5,2,0,-59,5,0, -0,-58,5,-61,0,23,0,-75,0,0,0,-75,0,1,0,4,0,75,5,7,0,76,5,-74,0,77,5,2,0,78,5,-69, -0,-108,5,12,0,-57,5,2,0,-101,5,2,0,-56,5,2,0,20,0,2,0,57,0,9,0,-90,5,12,0,-55,5,-60, -0,-54,5,0,0,-53,5,-59,0,-52,5,4,0,-51,5,4,0,-50,5,2,0,18,0,2,0,-49,5,2,0,-48,5,2, -0,-47,5,-58,0,29,0,-75,0,0,0,-75,0,1,0,4,0,75,5,7,0,76,5,-74,0,77,5,2,0,78,5,-69, -0,-108,5,46,0,-114,2,45,0,0,1,60,0,19,5,2,0,13,1,2,0,-119,0,2,0,-46,5,2,0,-45,5,4, -0,20,0,2,0,49,5,2,0,-44,5,2,0,-98,5,2,0,-101,5,7,0,71,5,0,0,-43,5,0,0,-42,5,0, -0,-41,5,0,0,-40,5,7,0,8,2,7,0,9,2,7,0,-39,5,7,0,-38,5,-70,0,-127,5,-57,0,11,0,-75, -0,0,0,-75,0,1,0,4,0,75,5,7,0,76,5,-74,0,77,5,2,0,78,5,2,0,-119,0,2,0,-98,5,2, -0,-37,5,2,0,20,0,-69,0,-108,5,-56,0,24,0,-75,0,0,0,-75,0,1,0,4,0,75,5,7,0,76,5,-74, -0,77,5,2,0,78,5,42,0,-36,5,4,0,-35,5,4,0,-34,5,2,0,93,0,2,0,-119,0,4,0,-33,5,4, -0,-32,5,4,0,-31,5,4,0,-30,5,4,0,-29,5,4,0,-28,5,4,0,-27,5,4,0,-26,5,7,0,-25,5,23, -0,-24,5,23,0,-23,5,4,0,-22,5,4,0,-21,5,-55,0,10,0,27,0,31,0,9,0,-20,5,9,0,-19,5,9, -0,-18,5,9,0,-17,5,9,0,-16,5,4,0,93,0,4,0,-15,5,0,0,-14,5,0,0,-13,5,-54,0,10,0,-75, -0,0,0,-75,0,1,0,4,0,75,5,7,0,76,5,-74,0,77,5,-55,0,-12,5,2,0,93,0,2,0,-119,0,4, -0,43,0,9,0,-11,5,-53,0,8,0,-75,0,0,0,-75,0,1,0,4,0,75,5,7,0,76,5,-74,0,77,5,-69, -0,-108,5,4,0,20,0,4,0,-10,5,-52,0,21,0,-75,0,0,0,-75,0,1,0,4,0,75,5,7,0,76,5,-74, -0,77,5,2,0,78,5,-69,0,-108,5,27,0,-9,5,27,0,80,0,2,0,20,0,2,0,-119,0,7,0,-8,5,9, -0,-7,5,7,0,8,2,7,0,9,2,57,0,1,1,57,0,-6,5,4,0,-5,5,2,0,-89,5,2,0,37,0,-70, -0,-127,5,-51,0,42,0,-75,0,0,0,-75,0,1,0,4,0,75,5,7,0,76,5,-74,0,77,5,2,0,78,5,-69, -0,-108,5,-50,0,-4,5,0,0,-77,5,0,0,-76,5,0,0,-75,5,2,0,18,0,2,0,-66,5,2,0,20,0,2, -0,-73,5,9,0,-7,5,4,0,-3,5,4,0,-2,5,4,0,-1,5,4,0,0,6,23,0,1,6,23,0,2,6,7, -0,3,6,7,0,4,6,7,0,5,6,7,0,-8,5,2,0,-67,5,2,0,-48,0,2,0,102,1,2,0,6,6,2, -0,37,0,2,0,43,0,2,0,7,6,2,0,8,6,9,0,-64,5,9,0,-63,5,9,0,-62,5,9,0,-61,5,9, -0,-60,5,2,0,-59,5,0,0,-58,5,56,0,9,6,-49,0,20,0,0,0,10,6,0,0,11,6,0,0,12,6,0, -0,13,6,0,0,14,6,0,0,15,6,0,0,16,6,0,0,17,6,0,0,18,6,0,0,19,6,0,0,20,6,0, -0,21,6,0,0,22,6,0,0,23,6,0,0,24,6,0,0,25,6,0,0,26,6,0,0,27,6,0,0,68,2,0, -0,28,6,-48,0,54,0,0,0,29,6,0,0,20,6,0,0,21,6,0,0,30,6,0,0,31,6,0,0,32,6,0, -0,33,6,0,0,34,6,0,0,35,6,0,0,36,6,0,0,37,6,0,0,38,6,0,0,39,6,0,0,40,6,0, -0,41,6,0,0,42,6,0,0,43,6,0,0,44,6,0,0,45,6,0,0,46,6,0,0,47,6,0,0,48,6,0, -0,49,6,0,0,50,6,0,0,51,6,0,0,52,6,0,0,53,6,0,0,54,6,0,0,55,6,0,0,56,6,0, -0,57,6,0,0,58,6,0,0,95,0,0,0,59,6,0,0,60,6,0,0,61,6,0,0,62,6,0,0,63,6,0, -0,64,6,0,0,65,6,0,0,66,6,0,0,67,6,0,0,68,6,0,0,69,6,0,0,70,6,0,0,71,6,0, -0,72,6,0,0,73,6,0,0,74,6,0,0,75,6,0,0,76,6,0,0,77,6,0,0,78,6,0,0,79,6,-47, -0,5,0,0,0,80,6,0,0,37,6,0,0,39,6,2,0,20,0,2,0,37,0,-46,0,22,0,-46,0,0,0,-46, -0,1,0,0,0,17,0,-49,0,81,6,-48,0,82,6,-48,0,83,6,-48,0,84,6,-48,0,85,6,-48,0,86,6,-48, -0,87,6,-48,0,88,6,-48,0,89,6,-48,0,90,6,-48,0,91,6,-48,0,92,6,-48,0,93,6,-48,0,94,6,-48, -0,95,6,-48,0,96,6,-47,0,97,6,0,0,98,6,0,0,99,6,-45,0,5,0,4,0,20,0,4,0,37,0,7, -0,52,2,7,0,100,6,7,0,-31,1,-44,0,66,0,4,0,20,0,4,0,101,6,4,0,102,6,0,0,103,6,0, -0,104,6,0,0,105,6,0,0,106,6,0,0,107,6,0,0,108,6,0,0,109,6,0,0,110,6,0,0,111,6,2, -0,112,6,2,0,113,6,4,0,114,6,4,0,115,6,4,0,116,6,4,0,117,6,2,0,118,6,2,0,119,6,2, -0,120,6,2,0,121,6,4,0,122,6,4,0,123,6,2,0,124,6,2,0,125,6,2,0,126,6,2,0,127,6,0, -0,-128,6,12,0,-127,6,2,0,-126,6,2,0,-125,6,2,0,-124,6,2,0,-123,6,2,0,-122,6,2,0,-121,6,2, -0,-120,6,2,0,-119,6,-45,0,-118,6,2,0,-117,6,2,0,-116,6,2,0,-115,6,2,0,-114,6,4,0,-113,6,4, -0,-112,6,4,0,-111,6,4,0,-110,6,2,0,-109,6,2,0,-108,6,2,0,-107,6,2,0,-106,6,2,0,-105,6,2, -0,-104,6,2,0,-103,6,2,0,-102,6,2,0,-101,6,2,0,-100,6,2,0,-99,6,2,0,37,0,0,0,-98,6,0, -0,-97,6,0,0,-96,6,7,0,-95,6,2,0,55,5,2,0,-94,6,54,0,-93,6,-43,0,18,0,27,0,31,0,12, -0,-92,6,12,0,-91,6,12,0,-90,6,-79,0,-89,6,2,0,-105,2,2,0,-88,6,2,0,-104,2,2,0,-87,6,2, -0,-86,6,2,0,-85,6,2,0,-84,6,2,0,-83,6,2,0,-82,6,2,0,37,0,2,0,-81,6,2,0,-80,6,2, -0,-79,6,-42,0,5,0,-42,0,0,0,-42,0,1,0,-42,0,-78,6,13,0,-77,6,4,0,20,0,-41,0,7,0,-41, -0,0,0,-41,0,1,0,-42,0,-76,6,-42,0,-75,6,2,0,123,4,2,0,20,0,4,0,37,0,-40,0,17,0,-40, -0,0,0,-40,0,1,0,0,0,-74,6,0,0,-73,6,0,0,-72,6,2,0,-71,6,2,0,-70,6,2,0,-86,6,2, -0,-85,6,2,0,20,0,2,0,70,3,2,0,-69,6,2,0,-68,6,2,0,-67,6,2,0,-66,6,4,0,-65,6,-40, -0,-64,6,-74,0,30,0,-74,0,0,0,-74,0,1,0,-42,0,-76,6,-42,0,-75,6,-42,0,-63,6,-42,0,-62,6,-43, -0,-61,6,7,0,-60,6,23,0,52,0,23,0,-59,6,23,0,-58,6,2,0,-57,6,2,0,-56,6,2,0,-55,6,0, -0,75,5,0,0,-54,6,2,0,-53,6,2,0,-52,6,0,0,-51,6,0,0,-50,6,0,0,-49,6,0,0,-48,6,2, -0,-47,6,2,0,-46,6,2,0,-45,6,2,0,20,0,39,0,125,0,12,0,-44,6,12,0,-43,6,12,0,-42,6,-39, -0,11,0,0,0,-41,6,2,0,-40,6,2,0,-39,6,2,0,-38,6,2,0,-37,6,2,0,-36,6,2,0,107,4,9, -0,-35,6,9,0,-34,6,4,0,-33,6,4,0,-32,6,-38,0,1,0,0,0,-31,6,-37,0,8,0,56,0,-30,6,56, -0,-29,6,-37,0,-28,6,-37,0,-27,6,-37,0,-26,6,2,0,-123,0,2,0,20,0,4,0,-25,6,-36,0,4,0,4, -0,-35,5,4,0,-24,6,4,0,-31,5,4,0,-23,6,-35,0,2,0,4,0,-22,6,4,0,-21,6,-34,0,9,0,7, -0,-20,6,7,0,-19,6,7,0,-18,6,4,0,20,0,4,0,13,1,7,0,-19,3,7,0,-17,6,4,0,37,0,-33, -0,-16,6,-32,0,6,0,0,0,-15,6,0,0,-75,5,48,0,-116,0,2,0,109,0,2,0,111,4,4,0,37,0,-31, -0,21,0,-31,0,0,0,-31,0,1,0,4,0,57,0,4,0,23,0,4,0,28,0,4,0,-14,6,4,0,-13,6,4, -0,-12,6,-38,0,-11,6,0,0,-15,6,4,0,-10,6,4,0,-9,6,-32,0,-12,2,-36,0,-8,6,-35,0,-7,6,-34, -0,-6,6,-37,0,-5,6,-37,0,-4,6,-37,0,-3,6,56,0,-2,6,56,0,-1,6,-30,0,12,0,0,0,-68,1,9, -0,-62,0,0,0,-61,0,4,0,-58,0,4,0,-50,0,9,0,-57,0,7,0,-55,0,7,0,-54,0,9,0,0,7,9, -0,1,7,9,0,-53,0,9,0,-51,0,-29,0,43,0,-29,0,0,0,-29,0,1,0,9,0,2,7,9,0,26,0,0, -0,27,0,4,0,20,0,4,0,18,0,4,0,23,0,4,0,91,0,4,0,3,7,4,0,4,7,4,0,-13,6,4, -0,-12,6,4,0,5,7,4,0,-39,0,4,0,6,7,4,0,7,7,7,0,8,7,7,0,9,7,4,0,-126,0,4, -0,10,7,-31,0,11,7,36,0,79,0,-79,0,-89,6,48,0,-116,0,7,0,12,7,7,0,13,7,-30,0,2,1,-29, -0,14,7,-29,0,15,7,-29,0,16,7,12,0,17,7,-28,0,18,7,-27,0,19,7,7,0,20,7,7,0,21,7,4, -0,-84,6,7,0,22,7,9,0,23,7,4,0,24,7,4,0,25,7,4,0,26,7,7,0,27,7,-26,0,4,0,-26, -0,0,0,-26,0,1,0,12,0,28,7,-29,0,29,7,-25,0,6,0,12,0,30,7,12,0,17,7,12,0,31,7,2, -0,20,0,2,0,37,0,4,0,57,0,-24,0,4,0,7,0,32,7,7,0,112,0,2,0,33,7,2,0,34,7,-23, -0,6,0,7,0,35,7,7,0,36,7,7,0,37,7,7,0,38,7,4,0,39,7,4,0,40,7,-22,0,12,0,7, -0,41,7,7,0,42,7,7,0,43,7,7,0,44,7,7,0,45,7,7,0,46,7,7,0,47,7,7,0,48,7,7, -0,49,7,7,0,50,7,4,0,-110,2,4,0,51,7,-21,0,2,0,7,0,-55,4,7,0,37,0,-20,0,7,0,7, -0,52,7,7,0,53,7,4,0,93,0,4,0,108,2,4,0,54,7,4,0,55,7,4,0,37,0,-19,0,6,0,-19, -0,0,0,-19,0,1,0,2,0,18,0,2,0,20,0,2,0,56,7,2,0,57,0,-18,0,8,0,-18,0,0,0,-18, -0,1,0,2,0,18,0,2,0,20,0,2,0,56,7,2,0,57,0,7,0,23,0,7,0,-126,0,-17,0,45,0,-17, -0,0,0,-17,0,1,0,2,0,18,0,2,0,20,0,2,0,56,7,2,0,-43,0,2,0,-103,3,2,0,57,7,7, -0,58,7,7,0,92,0,7,0,-97,2,4,0,59,7,4,0,81,0,4,0,110,2,7,0,60,7,7,0,61,7,7, -0,62,7,7,0,63,7,7,0,64,7,7,0,65,7,7,0,-100,2,7,0,-1,0,7,0,66,7,7,0,67,7,7, -0,37,0,7,0,68,7,7,0,69,7,7,0,70,7,2,0,71,7,2,0,72,7,2,0,73,7,2,0,74,7,2, -0,75,7,2,0,76,7,2,0,77,7,2,0,78,7,2,0,123,5,2,0,79,7,2,0,-47,1,2,0,80,7,0, -0,81,7,0,0,82,7,7,0,-45,0,-16,0,83,7,63,0,-95,1,-15,0,16,0,-15,0,0,0,-15,0,1,0,2, -0,18,0,2,0,20,0,2,0,56,7,2,0,-43,0,7,0,-105,2,7,0,-104,2,7,0,-103,2,7,0,-5,1,7, -0,-102,2,7,0,-101,2,7,0,84,7,7,0,-100,2,7,0,-98,2,7,0,-97,2,-59,0,5,0,2,0,18,0,2, -0,-25,6,2,0,20,0,2,0,85,7,27,0,-9,5,-60,0,3,0,4,0,69,0,4,0,86,7,-59,0,2,0,-14, -0,12,0,-14,0,0,0,-14,0,1,0,2,0,18,0,2,0,20,0,2,0,31,3,2,0,-32,1,7,0,5,0,7, -0,6,0,7,0,87,7,7,0,88,7,27,0,-9,5,12,0,89,7,-13,0,11,0,-13,0,0,0,-13,0,1,0,0, -0,17,0,2,0,18,0,2,0,90,7,4,0,22,0,4,0,91,7,2,0,20,0,2,0,37,0,9,0,92,7,9, -0,93,7,-12,0,5,0,0,0,17,0,7,0,20,1,7,0,94,7,4,0,95,7,4,0,37,0,-11,0,4,0,2, -0,18,0,2,0,20,0,2,0,43,0,2,0,70,0,-10,0,4,0,0,0,17,0,62,0,96,7,7,0,20,1,7, -0,37,0,-9,0,6,0,2,0,97,7,2,0,98,7,2,0,18,0,2,0,99,7,0,0,100,7,0,0,101,7,-8, -0,5,0,4,0,18,0,4,0,37,0,0,0,17,0,0,0,102,7,0,0,103,7,-7,0,3,0,4,0,18,0,4, -0,37,0,0,0,17,0,-6,0,4,0,2,0,104,7,2,0,105,7,2,0,20,0,2,0,37,0,-5,0,6,0,0, -0,17,0,0,0,106,7,2,0,107,7,2,0,-100,2,2,0,13,1,2,0,70,0,-4,0,5,0,0,0,17,0,7, -0,112,0,7,0,-17,3,2,0,20,0,2,0,122,2,-3,0,3,0,0,0,17,0,4,0,110,2,4,0,104,7,-2, -0,7,0,0,0,17,0,7,0,-17,3,0,0,108,7,0,0,109,7,2,0,13,1,2,0,43,0,4,0,110,7,-1, -0,3,0,32,0,111,7,0,0,112,7,0,0,113,7,0,1,18,0,0,1,0,0,0,1,1,0,2,0,18,0,2, -0,90,7,2,0,20,0,2,0,114,7,2,0,115,7,2,0,116,7,2,0,43,0,2,0,70,0,0,0,17,0,9, -0,2,0,1,1,117,7,32,0,45,0,2,0,-47,4,2,0,20,7,2,0,118,7,2,0,37,0,2,1,11,0,0, -0,17,0,0,0,18,0,0,0,119,7,2,0,20,0,2,0,122,2,2,0,120,7,4,0,121,7,4,0,122,7,4, -0,123,7,4,0,124,7,4,0,125,7,3,1,1,0,0,0,126,7,4,1,4,0,42,0,-36,5,0,0,127,7,4, -0,13,1,4,0,20,0,1,1,18,0,1,1,0,0,1,1,1,0,1,1,-128,7,2,0,18,0,2,0,20,0,2, -0,-127,7,2,0,116,7,2,0,90,7,2,0,-126,7,2,0,70,0,2,0,12,1,0,0,17,0,9,0,2,0,5, -1,117,7,0,1,-125,7,2,0,15,0,2,0,-124,7,4,0,-123,7,6,1,3,0,4,0,-74,2,4,0,37,0,32, -0,45,0,7,1,12,0,-111,0,-122,7,2,0,18,0,2,0,20,0,4,0,58,7,4,0,92,0,0,0,17,0,0, -0,-121,7,2,0,-120,7,2,0,-119,7,2,0,-118,7,2,0,-117,7,7,0,-116,7,8,1,10,0,2,0,20,0,2, -0,-115,7,4,0,58,7,4,0,92,0,2,0,-114,7,-28,0,18,7,2,0,18,0,2,0,-113,7,2,0,-112,7,2, -0,-111,7,9,1,7,0,2,0,20,0,2,0,-115,7,4,0,58,7,4,0,92,0,2,0,18,0,2,0,-110,7,7, -0,109,3,10,1,11,0,4,0,-74,2,2,0,18,0,2,0,20,0,32,0,45,0,74,0,-109,7,0,0,17,0,7, -0,-108,7,7,0,-107,7,7,0,21,3,2,0,-106,7,2,0,-105,7,11,1,5,0,2,0,18,0,2,0,20,0,4, -0,37,0,-79,0,-89,6,32,0,39,5,12,1,5,0,4,0,20,0,4,0,18,0,0,0,17,0,0,0,102,7,32, -0,45,0,13,1,13,0,2,0,20,0,2,0,18,0,2,0,90,7,2,0,22,3,7,0,-104,7,7,0,-103,7,7, -0,7,1,7,0,8,1,7,0,-3,2,7,0,0,3,7,0,-102,7,7,0,-101,7,32,0,-100,7,14,1,10,0,2, -0,20,0,2,0,18,0,4,0,58,7,4,0,92,0,0,0,17,0,0,0,-121,7,2,0,43,0,2,0,64,0,2, -0,-99,7,2,0,-98,7,15,1,8,0,32,0,45,0,7,0,-103,2,7,0,-97,7,7,0,-96,7,7,0,-108,2,2, -0,20,0,2,0,122,2,7,0,-95,7,16,1,12,0,2,0,18,0,2,0,13,1,2,0,20,0,2,0,-100,2,2, -0,-74,2,2,0,-94,7,4,0,37,0,7,0,-93,7,7,0,-92,7,7,0,-91,7,7,0,-90,7,0,0,-89,7,17, -1,10,0,2,0,20,0,2,0,18,0,4,0,58,7,4,0,92,0,0,0,17,0,2,0,68,2,2,0,64,0,2, -0,-99,7,2,0,-98,7,63,0,-95,1,18,1,7,0,4,0,110,2,4,0,-88,7,4,0,-87,7,4,0,-86,7,7, -0,-85,7,7,0,-84,7,0,0,108,7,19,1,7,0,0,0,-83,7,32,0,-82,7,0,0,112,7,2,0,-81,7,2, -0,43,0,4,0,70,0,0,0,113,7,20,1,6,0,2,0,20,0,2,0,18,0,4,0,58,7,4,0,92,0,0, -0,-80,7,0,0,-79,7,21,1,1,0,4,0,20,0,22,1,6,0,0,0,95,0,2,0,18,0,2,0,20,0,4, -0,-78,7,7,0,-77,7,42,0,-36,5,23,1,4,0,0,0,-74,0,2,0,20,0,4,0,18,0,32,0,45,0,24, -1,2,0,4,0,18,0,4,0,-121,5,5,1,10,0,5,1,0,0,5,1,1,0,5,1,-128,7,2,0,18,0,2, -0,20,0,2,0,90,7,2,0,-76,7,0,0,17,0,9,0,2,0,32,0,45,0,25,1,10,0,7,0,21,3,7, -0,-75,7,7,0,-74,7,7,0,-73,7,7,0,-72,7,4,0,20,0,7,0,-94,7,7,0,-71,7,7,0,-70,7,7, -0,37,0,-28,0,20,0,27,0,31,0,0,0,-63,0,26,1,-69,7,9,0,-68,7,43,0,-104,0,43,0,-67,7,9, -0,-66,7,36,0,79,0,7,0,109,3,7,0,-65,7,7,0,-64,7,7,0,-63,7,7,0,-62,7,7,0,-61,7,7, -0,-60,7,4,0,93,0,4,0,-59,7,0,0,-58,7,0,0,-57,7,0,0,-56,7,27,1,6,0,27,0,31,0,7, -0,-55,7,7,0,-54,7,7,0,-53,7,2,0,-52,7,2,0,-51,7,28,1,14,0,-75,0,0,0,-75,0,1,0,4, -0,75,5,7,0,76,5,-74,0,77,5,-69,0,-108,5,-28,0,18,7,2,0,13,1,2,0,-115,7,2,0,8,2,2, -0,9,2,2,0,20,0,2,0,-98,5,4,0,70,0,29,1,6,0,29,1,0,0,29,1,1,0,32,0,45,0,9, -0,-50,7,4,0,-38,0,4,0,37,0,63,0,4,0,27,0,31,0,12,0,-49,7,4,0,-121,0,7,0,-48,7,30, -1,25,0,30,1,0,0,30,1,1,0,30,1,38,0,12,0,-47,7,0,0,17,0,7,0,-46,7,7,0,-45,7,7, -0,-44,7,7,0,-43,7,4,0,20,0,7,0,-42,7,7,0,-41,7,7,0,-40,7,7,0,20,1,7,0,-39,1,7, -0,-39,7,7,0,108,2,7,0,-38,7,7,0,-37,7,7,0,-36,7,7,0,-35,7,7,0,-34,7,7,0,-81,0,2, -0,-121,0,2,0,-31,4,31,1,19,0,27,0,31,0,12,0,-33,7,12,0,-32,7,4,0,20,0,4,0,30,4,2, -0,-96,2,2,0,-31,7,2,0,-121,0,2,0,-30,7,2,0,-29,7,2,0,-28,7,2,0,-27,7,2,0,-26,7,4, -0,-25,7,4,0,-24,7,4,0,-23,7,4,0,-22,7,4,0,-21,7,4,0,-20,7,32,1,34,0,32,1,0,0,32, -1,1,0,12,0,49,3,0,0,17,0,2,0,20,0,2,0,-19,7,2,0,-18,7,2,0,-17,7,2,0,10,3,2, -0,-16,7,4,0,-7,1,4,0,-23,7,4,0,-22,7,30,1,-15,7,32,1,38,0,32,1,-14,7,12,0,-13,7,9, -0,-12,7,9,0,-11,7,9,0,-10,7,7,0,7,1,7,0,-81,0,7,0,-57,1,7,0,-9,7,7,0,-8,7,7, -0,2,3,7,0,-7,7,7,0,-6,7,7,0,-5,7,7,0,-4,7,7,0,-3,7,7,0,-2,7,7,0,-10,1,32, -0,-1,7,-110,0,9,0,12,0,0,8,2,0,20,0,2,0,1,8,7,0,20,3,7,0,2,8,7,0,3,8,12, -0,4,8,4,0,5,8,4,0,37,0,33,1,7,0,33,1,0,0,33,1,1,0,12,0,-58,7,4,0,20,0,4, -0,6,8,0,0,17,0,-47,0,7,8,34,1,8,0,34,1,0,0,34,1,1,0,33,1,8,8,36,0,79,0,12, -0,-6,2,4,0,20,0,0,0,17,0,4,0,9,8,-111,0,6,0,27,0,31,0,12,0,0,8,12,0,10,8,12, -0,103,0,4,0,11,8,4,0,37,0,35,1,16,0,-75,0,0,0,-75,0,1,0,4,0,75,5,7,0,76,5,-74, -0,77,5,2,0,78,5,-69,0,-108,5,-111,0,-9,2,0,0,13,1,0,0,-37,5,2,0,20,0,2,0,12,8,2, -0,-101,5,2,0,-98,5,2,0,13,8,7,0,14,8,36,1,5,0,36,1,0,0,36,1,1,0,36,0,79,0,2, -0,20,0,0,0,15,8,37,1,12,0,37,1,0,0,37,1,1,0,9,0,2,0,2,0,18,0,2,0,20,0,0, -0,16,8,0,0,17,8,0,0,15,8,7,0,18,8,7,0,19,8,4,0,37,0,36,0,79,0,38,1,9,0,38, -1,0,0,38,1,1,0,32,0,20,8,0,0,21,8,7,0,22,8,2,0,23,8,2,0,20,0,2,0,18,0,2, -0,37,0,39,1,7,0,42,0,-36,5,26,0,24,8,4,0,20,0,4,0,25,8,12,0,26,8,32,0,20,8,0, -0,21,8,40,1,12,0,32,0,20,8,2,0,27,8,2,0,20,0,2,0,28,8,2,0,29,8,0,0,21,8,32, -0,30,8,0,0,31,8,7,0,32,8,7,0,-39,1,7,0,33,8,7,0,34,8,41,1,6,0,32,0,20,8,4, -0,9,8,4,0,35,8,4,0,93,0,4,0,37,0,0,0,21,8,42,1,4,0,32,0,20,8,4,0,20,0,4, -0,9,8,0,0,21,8,43,1,4,0,32,0,20,8,4,0,20,0,4,0,9,8,0,0,21,8,44,1,10,0,32, -0,20,8,4,0,36,8,7,0,-127,0,4,0,20,0,2,0,-42,5,2,0,37,8,2,0,43,0,2,0,70,0,7, -0,38,8,0,0,21,8,45,1,4,0,32,0,20,8,4,0,20,0,4,0,9,8,0,0,21,8,46,1,10,0,32, -0,20,8,2,0,18,0,2,0,-95,3,4,0,91,0,4,0,92,0,7,0,-97,7,7,0,-96,7,4,0,37,0,-111, -0,-122,7,0,0,21,8,47,1,4,0,32,0,20,8,4,0,7,3,4,0,39,8,0,0,21,8,48,1,5,0,32, -0,20,8,7,0,-127,0,4,0,40,8,4,0,7,3,4,0,8,3,49,1,6,0,32,0,20,8,4,0,41,8,4, -0,42,8,7,0,43,8,7,0,44,8,0,0,21,8,50,1,16,0,32,0,20,8,32,0,-14,7,4,0,18,0,7, -0,45,8,7,0,46,8,7,0,47,8,7,0,48,8,7,0,49,8,7,0,50,8,7,0,51,8,7,0,52,8,7, -0,53,8,2,0,20,0,2,0,37,0,2,0,43,0,2,0,70,0,51,1,3,0,32,0,20,8,4,0,20,0,4, -0,123,5,52,1,5,0,32,0,20,8,4,0,20,0,4,0,37,0,7,0,54,8,0,0,21,8,53,1,10,0,32, -0,20,8,0,0,21,8,2,0,55,8,2,0,56,8,0,0,57,8,0,0,58,8,7,0,59,8,7,0,60,8,7, -0,61,8,7,0,62,8,54,1,8,0,7,0,9,0,7,0,10,0,7,0,11,0,7,0,12,0,7,0,63,8,7, -0,64,8,2,0,20,0,2,0,123,5,55,1,8,0,7,0,9,0,7,0,10,0,7,0,11,0,7,0,12,0,7, -0,63,8,7,0,64,8,2,0,20,0,2,0,123,5,56,1,8,0,7,0,9,0,7,0,10,0,7,0,11,0,7, -0,12,0,7,0,63,8,7,0,64,8,2,0,20,0,2,0,123,5,57,1,7,0,32,0,20,8,0,0,21,8,7, -0,20,1,7,0,30,1,2,0,20,0,2,0,13,1,4,0,37,0,58,1,5,0,32,0,-45,2,7,0,20,1,2, -0,-41,2,0,0,-39,2,0,0,65,8,59,1,10,0,59,1,0,0,59,1,1,0,2,0,18,0,2,0,20,0,0, -0,66,8,7,0,-36,0,7,0,-35,0,2,0,-58,7,2,0,67,8,32,0,45,0,60,1,22,0,60,1,0,0,60, -1,1,0,2,0,20,0,2,0,13,1,2,0,68,8,2,0,69,8,36,0,79,0,-111,0,-122,7,32,0,-89,0,7, -0,91,0,7,0,92,0,7,0,70,8,7,0,71,8,7,0,72,8,7,0,73,8,7,0,-107,2,7,0,-67,1,7, -0,-120,7,7,0,74,8,0,0,75,8,0,0,76,8,12,0,-4,2,61,1,8,0,7,0,-31,1,7,0,-97,7,7, -0,-96,7,9,0,2,0,2,0,77,8,2,0,78,8,2,0,79,8,2,0,80,8,62,1,18,0,62,1,0,0,62, -1,1,0,62,1,81,8,0,0,17,0,61,1,82,8,2,0,18,0,2,0,20,0,2,0,83,8,2,0,84,8,2, -0,85,8,2,0,86,8,4,0,43,0,7,0,87,8,7,0,88,8,4,0,89,8,4,0,90,8,62,1,91,8,63, -1,92,8,64,1,32,0,64,1,0,0,64,1,1,0,64,1,93,8,0,0,17,0,0,0,94,8,2,0,18,0,2, -0,20,0,2,0,-14,6,2,0,20,7,2,0,95,8,2,0,-119,0,2,0,84,8,2,0,-25,6,12,0,-127,7,12, -0,96,8,27,0,-9,5,9,0,97,8,7,0,87,8,7,0,88,8,7,0,-5,1,7,0,98,8,2,0,99,8,2, -0,100,8,7,0,101,8,7,0,102,8,2,0,103,8,2,0,104,8,24,0,105,8,24,0,106,8,24,0,107,8,65, -1,-103,0,66,1,108,8,63,1,6,0,63,1,0,0,63,1,1,0,64,1,109,8,64,1,110,8,62,1,111,8,62, -1,91,8,57,0,16,0,27,0,31,0,12,0,112,8,12,0,113,8,61,1,114,8,12,0,115,8,4,0,18,0,4, -0,116,8,4,0,117,8,4,0,118,8,12,0,119,8,66,1,120,8,62,1,121,8,62,1,122,8,9,0,123,8,9, -0,124,8,4,0,125,8,67,1,6,0,4,0,-128,0,4,0,-126,0,4,0,-25,6,0,0,126,8,0,0,127,8,2, -0,37,0,68,1,16,0,2,0,-86,6,2,0,-85,6,2,0,-128,8,2,0,-74,7,2,0,-127,8,2,0,68,0,7, -0,-108,2,7,0,-126,8,7,0,-125,8,2,0,34,1,0,0,-124,8,0,0,42,4,2,0,-123,8,2,0,37,0,4, -0,-122,8,4,0,-121,8,69,1,9,0,7,0,-120,8,7,0,-119,8,7,0,-60,7,7,0,112,0,7,0,-118,8,7, -0,71,5,2,0,-117,8,0,0,-116,8,0,0,37,0,70,1,4,0,7,0,-115,8,7,0,-114,8,2,0,-117,8,2, -0,37,0,71,1,3,0,7,0,-113,8,7,0,-112,8,7,0,15,0,72,1,7,0,0,0,-68,1,2,0,109,4,2, -0,110,4,2,0,111,4,2,0,62,4,4,0,-126,0,4,0,-97,3,73,1,7,0,7,0,-111,8,7,0,-110,8,7, -0,-109,8,7,0,4,2,7,0,-108,8,7,0,-107,8,7,0,-106,8,74,1,4,0,2,0,-105,8,2,0,-104,8,2, -0,-103,8,2,0,-102,8,75,1,2,0,7,0,5,0,7,0,6,0,76,1,2,0,0,0,-87,0,0,0,-101,8,77, -1,1,0,0,0,17,0,78,1,10,0,0,0,-100,8,0,0,-99,8,0,0,-98,8,0,0,-97,8,2,0,-128,8,2, -0,-96,8,7,0,-95,8,7,0,-94,8,7,0,-93,8,7,0,-67,1,79,1,2,0,9,0,-92,8,9,0,-91,8,80, -1,11,0,0,0,111,4,0,0,18,0,0,0,-117,8,0,0,112,0,0,0,-90,8,0,0,109,0,0,0,-74,0,7, -0,-89,8,7,0,-88,8,7,0,-87,8,7,0,-86,8,81,1,8,0,7,0,97,7,7,0,-127,0,7,0,42,4,7, -0,72,2,7,0,-85,8,7,0,-49,0,7,0,-84,8,4,0,18,0,82,1,4,0,2,0,-83,8,2,0,-82,8,2, -0,-81,8,2,0,37,0,83,1,1,0,0,0,17,0,84,1,4,0,7,0,5,0,7,0,6,0,2,0,20,0,2, -0,-80,8,85,1,10,0,2,0,-120,3,2,0,20,0,7,0,-17,3,7,0,-79,8,7,0,-78,8,7,0,-77,8,7, -0,-76,8,84,1,-75,8,84,1,-74,8,84,1,-73,8,60,0,9,0,4,0,20,0,4,0,64,0,24,0,-72,8,24, -0,-71,8,85,1,-70,8,7,0,-69,8,7,0,-68,8,7,0,-67,8,7,0,-66,8,86,1,4,0,46,0,-114,2,7, -0,-65,8,7,0,92,1,7,0,37,0,-87,0,13,0,27,0,31,0,2,0,20,0,2,0,72,5,4,0,109,0,7, -0,-64,8,7,0,1,2,7,0,-63,8,7,0,-62,8,7,0,92,1,2,0,47,1,2,0,37,0,50,0,77,1,86, -1,-61,8,87,1,10,0,4,0,18,0,4,0,-127,0,4,0,20,0,4,0,70,3,4,0,-60,8,4,0,-59,8,4, -0,-58,8,0,0,95,0,0,0,17,0,9,0,2,0,84,0,6,0,87,1,-57,8,4,0,-56,8,4,0,-55,8,4, -0,-54,8,4,0,37,0,9,0,-53,8,88,1,5,0,7,0,66,2,7,0,-74,2,7,0,-39,1,2,0,-52,8,2, -0,37,0,89,1,5,0,7,0,66,2,7,0,-51,8,7,0,-50,8,7,0,-49,8,7,0,-74,2,90,1,7,0,4, -0,-48,8,4,0,-47,8,4,0,-46,8,7,0,-45,8,7,0,-44,8,7,0,-43,8,7,0,-42,8,91,1,26,0,32, -0,-41,8,89,1,66,3,89,1,-40,8,88,1,-39,8,89,1,83,7,7,0,-38,8,7,0,-37,8,7,0,-36,8,7, -0,-35,8,7,0,-44,8,7,0,-43,8,7,0,-74,2,7,0,-97,2,7,0,-34,8,7,0,-33,8,7,0,109,0,7, -0,-32,8,4,0,-48,8,4,0,-31,8,4,0,37,0,4,0,81,0,4,0,-30,8,2,0,20,0,2,0,-29,8,2, -0,-28,8,2,0,100,3,92,1,112,0,27,0,31,0,4,0,20,0,2,0,18,0,2,0,55,8,2,0,-27,8,2, -0,-26,8,2,0,-25,8,2,0,-24,8,2,0,-23,8,2,0,-22,8,2,0,-21,8,2,0,-20,8,2,0,-19,8,2, -0,-18,8,2,0,-17,8,2,0,-16,8,2,0,-15,8,2,0,-14,8,2,0,-13,8,2,0,-47,1,2,0,76,7,2, -0,51,7,2,0,-12,8,2,0,-11,8,2,0,98,3,2,0,99,3,2,0,-10,8,2,0,-9,8,2,0,-8,8,2, -0,-7,8,2,0,-6,8,2,0,-5,8,7,0,-4,8,7,0,-3,8,7,0,-2,8,2,0,-1,8,2,0,0,9,7, -0,1,9,7,0,2,9,7,0,3,9,7,0,58,7,7,0,92,0,7,0,-97,2,7,0,64,7,7,0,4,9,7, -0,5,9,7,0,6,9,7,0,7,9,7,0,57,0,4,0,59,7,4,0,57,7,4,0,8,9,7,0,60,7,7, -0,61,7,7,0,62,7,7,0,9,9,7,0,10,9,7,0,11,9,7,0,12,9,7,0,13,9,7,0,14,9,7, -0,15,9,7,0,16,9,7,0,21,3,7,0,109,0,7,0,17,9,7,0,18,9,7,0,19,9,7,0,20,9,7, -0,21,9,7,0,22,9,7,0,108,2,7,0,23,9,7,0,24,9,4,0,25,9,4,0,26,9,7,0,27,9,7, -0,28,9,7,0,29,9,7,0,30,9,7,0,31,9,7,0,32,9,7,0,33,9,7,0,34,9,7,0,94,3,7, -0,92,3,7,0,93,3,7,0,35,9,7,0,36,9,7,0,37,9,7,0,38,9,7,0,39,9,7,0,40,9,7, -0,41,9,7,0,42,9,7,0,43,9,7,0,28,3,7,0,44,9,7,0,45,9,7,0,46,9,7,0,47,9,7, -0,48,9,7,0,49,9,7,0,50,9,0,0,51,9,63,0,55,3,63,0,52,9,32,0,53,9,32,0,54,9,36, -0,79,0,-108,0,53,3,-108,0,55,9,-120,0,37,0,-120,0,0,0,-120,0,1,0,92,1,56,9,91,1,-121,3,90, -1,-14,7,93,1,57,9,94,1,58,9,94,1,59,9,12,0,60,9,12,0,61,9,-107,0,54,3,32,0,62,9,32, -0,63,9,32,0,64,9,12,0,65,9,12,0,66,9,7,0,-45,0,7,0,83,4,4,0,110,2,4,0,20,0,4, -0,59,7,4,0,67,9,4,0,68,9,4,0,69,9,4,0,57,0,2,0,-38,0,2,0,70,9,2,0,71,9,2, -0,72,9,2,0,47,3,2,0,73,9,0,0,74,9,2,0,75,9,2,0,76,9,2,0,77,9,9,0,78,9,125, -0,-76,3,123,0,34,0,95,1,79,9,7,0,-106,3,7,0,80,9,7,0,81,9,7,0,-14,3,7,0,82,9,7, -0,31,3,7,0,21,3,7,0,83,9,7,0,3,2,7,0,84,9,7,0,85,9,7,0,86,9,7,0,87,9,7, -0,88,9,7,0,89,9,7,0,-105,3,7,0,90,9,7,0,91,9,7,0,92,9,7,0,-104,3,7,0,-108,3,7, -0,-107,3,4,0,93,9,4,0,93,0,4,0,94,9,4,0,95,9,2,0,96,9,2,0,97,9,2,0,98,9,2, -0,99,9,2,0,100,9,2,0,37,0,4,0,70,0,124,0,8,0,95,1,101,9,7,0,102,9,7,0,103,9,7, -0,-94,1,7,0,104,9,4,0,93,0,2,0,105,9,2,0,106,9,96,1,4,0,7,0,5,0,7,0,6,0,7, -0,7,0,7,0,107,9,97,1,6,0,97,1,0,0,97,1,1,0,96,1,108,9,4,0,109,9,2,0,110,9,2, -0,20,0,98,1,5,0,98,1,0,0,98,1,1,0,12,0,111,9,4,0,112,9,4,0,20,0,99,1,9,0,99, -1,0,0,99,1,1,0,12,0,-128,0,98,1,113,9,4,0,20,0,2,0,110,9,2,0,114,9,7,0,94,0,0, -0,115,9,-70,0,5,0,12,0,125,4,4,0,20,0,2,0,116,9,2,0,117,9,9,0,118,9,69,78,68,66,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -}; -int DNAlen64= sizeof(DNAstr64); diff --git a/gamekit/dna249.cpp b/gamekit/dna249.cpp deleted file mode 100644 index 6a178205a..000000000 --- a/gamekit/dna249.cpp +++ /dev/null @@ -1,1411 +0,0 @@ -/* -bParse -Copyright (c) 2006-2009 Charlie C & Erwin Coumans http://gamekit.googlecode.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ -unsigned char DNAstr[]= { -83,68,78,65,78,65,77,69,119,9,0,0,42,110,101,120,116,0,42,112,114,101,118,0,42,100,97,116,97,0,42,102,105, -114,115,116,0,42,108,97,115,116,0,120,0,121,0,122,0,119,0,120,109,105,110,0,120,109,97,120,0,121,109,105,110, -0,121,109,97,120,0,42,112,111,105,110,116,101,114,0,103,114,111,117,112,0,118,97,108,0,118,97,108,50,0,110,97, -109,101,91,51,50,93,0,116,121,112,101,0,115,117,98,116,121,112,101,0,102,108,97,103,0,115,97,118,101,100,0,100, -97,116,97,0,108,101,110,0,116,111,116,97,108,108,101,110,0,42,110,101,119,105,100,0,42,108,105,98,0,110,97,109, -101,91,50,52,93,0,117,115,0,105,99,111,110,95,105,100,0,42,112,114,111,112,101,114,116,105,101,115,0,105,100,0, -42,105,100,98,108,111,99,107,0,42,102,105,108,101,100,97,116,97,0,110,97,109,101,91,50,52,48,93,0,102,105,108, -101,110,97,109,101,91,50,52,48,93,0,116,111,116,0,112,97,100,0,42,112,97,114,101,110,116,0,119,91,50,93,0, -104,91,50,93,0,99,104,97,110,103,101,100,91,50,93,0,112,97,100,48,0,112,97,100,49,0,42,114,101,99,116,91, -50,93,0,42,111,98,0,98,108,111,99,107,116,121,112,101,0,97,100,114,99,111,100,101,0,110,97,109,101,91,49,50, -56,93,0,42,98,112,0,42,98,101,122,116,0,109,97,120,114,99,116,0,116,111,116,114,99,116,0,118,97,114,116,121, -112,101,0,116,111,116,118,101,114,116,0,105,112,111,0,101,120,116,114,97,112,0,114,116,0,98,105,116,109,97,115,107, -0,115,108,105,100,101,95,109,105,110,0,115,108,105,100,101,95,109,97,120,0,99,117,114,118,97,108,0,42,100,114,105, -118,101,114,0,99,117,114,118,101,0,99,117,114,0,115,104,111,119,107,101,121,0,109,117,116,101,105,112,111,0,112,111, -115,0,114,101,108,97,116,105,118,101,0,116,111,116,101,108,101,109,0,112,97,100,50,0,42,119,101,105,103,104,116,115, -0,118,103,114,111,117,112,91,51,50,93,0,115,108,105,100,101,114,109,105,110,0,115,108,105,100,101,114,109,97,120,0, -42,114,101,102,107,101,121,0,101,108,101,109,115,116,114,91,51,50,93,0,101,108,101,109,115,105,122,101,0,98,108,111, -99,107,0,42,105,112,111,0,42,102,114,111,109,0,116,111,116,107,101,121,0,115,108,117,114,112,104,0,42,42,115,99, -114,105,112,116,115,0,42,102,108,97,103,0,97,99,116,115,99,114,105,112,116,0,116,111,116,115,99,114,105,112,116,0, -42,108,105,110,101,0,42,102,111,114,109,97,116,0,98,108,101,110,0,108,105,110,101,110,111,0,115,116,97,114,116,0, -101,110,100,0,102,108,97,103,115,0,99,111,108,111,114,91,52,93,0,112,97,100,91,52,93,0,42,110,97,109,101,0, -110,108,105,110,101,115,0,108,105,110,101,115,0,42,99,117,114,108,0,42,115,101,108,108,0,99,117,114,99,0,115,101, -108,99,0,109,97,114,107,101,114,115,0,42,117,110,100,111,95,98,117,102,0,117,110,100,111,95,112,111,115,0,117,110, -100,111,95,108,101,110,0,42,99,111,109,112,105,108,101,100,0,109,116,105,109,101,0,115,105,122,101,0,115,101,101,107, -0,112,97,115,115,101,112,97,114,116,97,108,112,104,97,0,97,110,103,108,101,0,99,108,105,112,115,116,97,0,99,108, -105,112,101,110,100,0,108,101,110,115,0,111,114,116,104,111,95,115,99,97,108,101,0,100,114,97,119,115,105,122,101,0, -115,104,105,102,116,120,0,115,104,105,102,116,121,0,89,70,95,100,111,102,100,105,115,116,0,89,70,95,97,112,101,114, -116,117,114,101,0,89,70,95,98,107,104,116,121,112,101,0,89,70,95,98,107,104,98,105,97,115,0,89,70,95,98,107, -104,114,111,116,0,115,99,114,105,112,116,108,105,110,107,0,42,100,111,102,95,111,98,0,102,114,97,109,101,110,114,0, -102,114,97,109,101,115,0,111,102,102,115,101,116,0,115,102,114,97,0,102,105,101,95,105,109,97,0,99,121,99,108,0, -111,107,0,109,117,108,116,105,95,105,110,100,101,120,0,108,97,121,101,114,0,112,97,115,115,0,109,101,110,117,110,114, -0,105,98,117,102,115,0,42,103,112,117,116,101,120,116,117,114,101,0,42,97,110,105,109,0,42,114,114,0,115,111,117, -114,99,101,0,108,97,115,116,102,114,97,109,101,0,116,112,97,103,101,102,108,97,103,0,116,111,116,98,105,110,100,0, -120,114,101,112,0,121,114,101,112,0,116,119,115,116,97,0,116,119,101,110,100,0,98,105,110,100,99,111,100,101,0,42, -114,101,112,98,105,110,100,0,42,112,97,99,107,101,100,102,105,108,101,0,42,112,114,101,118,105,101,119,0,108,97,115, -116,117,112,100,97,116,101,0,108,97,115,116,117,115,101,100,0,97,110,105,109,115,112,101,101,100,0,103,101,110,95,120, -0,103,101,110,95,121,0,103,101,110,95,116,121,112,101,0,97,115,112,120,0,97,115,112,121,0,42,118,110,111,100,101, -0,116,101,120,99,111,0,109,97,112,116,111,0,109,97,112,116,111,110,101,103,0,98,108,101,110,100,116,121,112,101,0, -42,111,98,106,101,99,116,0,42,116,101,120,0,117,118,110,97,109,101,91,51,50,93,0,112,114,111,106,120,0,112,114, -111,106,121,0,112,114,111,106,122,0,109,97,112,112,105,110,103,0,111,102,115,91,51,93,0,115,105,122,101,91,51,93, -0,116,101,120,102,108,97,103,0,99,111,108,111,114,109,111,100,101,108,0,112,109,97,112,116,111,0,112,109,97,112,116, -111,110,101,103,0,110,111,114,109,97,112,115,112,97,99,101,0,119,104,105,99,104,95,111,117,116,112,117,116,0,112,97, -100,91,50,93,0,114,0,103,0,98,0,107,0,100,101,102,95,118,97,114,0,99,111,108,102,97,99,0,110,111,114,102, -97,99,0,118,97,114,102,97,99,0,100,105,115,112,102,97,99,0,119,97,114,112,102,97,99,0,110,97,109,101,91,49, -54,48,93,0,42,104,97,110,100,108,101,0,42,112,110,97,109,101,0,42,115,116,110,97,109,101,115,0,115,116,121,112, -101,115,0,118,97,114,115,0,42,118,97,114,115,116,114,0,42,114,101,115,117,108,116,0,42,99,102,114,97,0,100,97, -116,97,91,51,50,93,0,40,42,100,111,105,116,41,40,41,0,40,42,105,110,115,116,97,110,99,101,95,105,110,105,116, -41,40,41,0,40,42,99,97,108,108,98,97,99,107,41,40,41,0,118,101,114,115,105,111,110,0,97,0,105,112,111,116, -121,112,101,0,42,105,109,97,0,42,99,117,98,101,91,54,93,0,105,109,97,116,91,52,93,91,52,93,0,111,98,105, -109,97,116,91,51,93,91,51,93,0,115,116,121,112,101,0,118,105,101,119,115,99,97,108,101,0,110,111,116,108,97,121, -0,99,117,98,101,114,101,115,0,100,101,112,116,104,0,114,101,99,97,108,99,0,108,97,115,116,115,105,122,101,0,110, -111,105,115,101,115,105,122,101,0,116,117,114,98,117,108,0,98,114,105,103,104,116,0,99,111,110,116,114,97,115,116,0, -114,102,97,99,0,103,102,97,99,0,98,102,97,99,0,102,105,108,116,101,114,115,105,122,101,0,109,103,95,72,0,109, -103,95,108,97,99,117,110,97,114,105,116,121,0,109,103,95,111,99,116,97,118,101,115,0,109,103,95,111,102,102,115,101, -116,0,109,103,95,103,97,105,110,0,100,105,115,116,95,97,109,111,117,110,116,0,110,115,95,111,117,116,115,99,97,108, -101,0,118,110,95,119,49,0,118,110,95,119,50,0,118,110,95,119,51,0,118,110,95,119,52,0,118,110,95,109,101,120, -112,0,118,110,95,100,105,115,116,109,0,118,110,95,99,111,108,116,121,112,101,0,110,111,105,115,101,100,101,112,116,104, -0,110,111,105,115,101,116,121,112,101,0,110,111,105,115,101,98,97,115,105,115,0,110,111,105,115,101,98,97,115,105,115, -50,0,105,109,97,102,108,97,103,0,99,114,111,112,120,109,105,110,0,99,114,111,112,121,109,105,110,0,99,114,111,112, -120,109,97,120,0,99,114,111,112,121,109,97,120,0,120,114,101,112,101,97,116,0,121,114,101,112,101,97,116,0,101,120, -116,101,110,100,0,99,104,101,99,107,101,114,100,105,115,116,0,110,97,98,108,97,0,105,117,115,101,114,0,42,110,111, -100,101,116,114,101,101,0,42,112,108,117,103,105,110,0,42,99,111,98,97,0,42,101,110,118,0,117,115,101,95,110,111, -100,101,115,0,112,97,100,91,55,93,0,108,111,99,91,51,93,0,114,111,116,91,51,93,0,109,97,116,91,52,93,91, -52,93,0,109,105,110,91,51,93,0,109,97,120,91,51,93,0,112,97,100,51,0,109,111,100,101,0,116,111,116,101,120, -0,115,104,100,119,114,0,115,104,100,119,103,0,115,104,100,119,98,0,115,104,100,119,112,97,100,0,101,110,101,114,103, -121,0,100,105,115,116,0,115,112,111,116,115,105,122,101,0,115,112,111,116,98,108,101,110,100,0,104,97,105,110,116,0, -97,116,116,49,0,97,116,116,50,0,42,99,117,114,102,97,108,108,111,102,102,0,102,97,108,108,111,102,102,95,116,121, -112,101,0,115,104,97,100,115,112,111,116,115,105,122,101,0,98,105,97,115,0,115,111,102,116,0,98,117,102,115,105,122, -101,0,115,97,109,112,0,98,117,102,102,101,114,115,0,102,105,108,116,101,114,116,121,112,101,0,98,117,102,102,108,97, -103,0,98,117,102,116,121,112,101,0,114,97,121,95,115,97,109,112,0,114,97,121,95,115,97,109,112,121,0,114,97,121, -95,115,97,109,112,122,0,114,97,121,95,115,97,109,112,95,116,121,112,101,0,97,114,101,97,95,115,104,97,112,101,0, -97,114,101,97,95,115,105,122,101,0,97,114,101,97,95,115,105,122,101,121,0,97,114,101,97,95,115,105,122,101,122,0, -97,100,97,112,116,95,116,104,114,101,115,104,0,114,97,121,95,115,97,109,112,95,109,101,116,104,111,100,0,116,101,120, -97,99,116,0,115,104,97,100,104,97,108,111,115,116,101,112,0,115,117,110,95,101,102,102,101,99,116,95,116,121,112,101, -0,115,107,121,98,108,101,110,100,116,121,112,101,0,104,111,114,105,122,111,110,95,98,114,105,103,104,116,110,101,115,115, -0,115,112,114,101,97,100,0,115,117,110,95,98,114,105,103,104,116,110,101,115,115,0,115,117,110,95,115,105,122,101,0, -98,97,99,107,115,99,97,116,116,101,114,101,100,95,108,105,103,104,116,0,115,117,110,95,105,110,116,101,110,115,105,116, -121,0,97,116,109,95,116,117,114,98,105,100,105,116,121,0,97,116,109,95,105,110,115,99,97,116,116,101,114,105,110,103, -95,102,97,99,116,111,114,0,97,116,109,95,101,120,116,105,110,99,116,105,111,110,95,102,97,99,116,111,114,0,97,116, -109,95,100,105,115,116,97,110,99,101,95,102,97,99,116,111,114,0,115,107,121,98,108,101,110,100,102,97,99,0,115,107, -121,95,101,120,112,111,115,117,114,101,0,115,107,121,95,99,111,108,111,114,115,112,97,99,101,0,112,97,100,52,0,89, -70,95,110,117,109,112,104,111,116,111,110,115,0,89,70,95,110,117,109,115,101,97,114,99,104,0,89,70,95,112,104,100, -101,112,116,104,0,89,70,95,117,115,101,113,109,99,0,89,70,95,98,117,102,115,105,122,101,0,89,70,95,112,97,100, -0,89,70,95,99,97,117,115,116,105,99,98,108,117,114,0,89,70,95,108,116,114,97,100,105,117,115,0,89,70,95,103, -108,111,119,105,110,116,0,89,70,95,103,108,111,119,111,102,115,0,89,70,95,103,108,111,119,116,121,112,101,0,89,70, -95,112,97,100,50,0,42,109,116,101,120,91,49,56,93,0,115,112,101,99,114,0,115,112,101,99,103,0,115,112,101,99, -98,0,109,105,114,114,0,109,105,114,103,0,109,105,114,98,0,97,109,98,114,0,97,109,98,98,0,97,109,98,103,0, -97,109,98,0,101,109,105,116,0,97,110,103,0,115,112,101,99,116,114,97,0,114,97,121,95,109,105,114,114,111,114,0, -97,108,112,104,97,0,114,101,102,0,115,112,101,99,0,122,111,102,102,115,0,97,100,100,0,116,114,97,110,115,108,117, -99,101,110,99,121,0,102,114,101,115,110,101,108,95,109,105,114,0,102,114,101,115,110,101,108,95,109,105,114,95,105,0, -102,114,101,115,110,101,108,95,116,114,97,0,102,114,101,115,110,101,108,95,116,114,97,95,105,0,102,105,108,116,101,114, -0,116,120,95,108,105,109,105,116,0,116,120,95,102,97,108,108,111,102,102,0,114,97,121,95,100,101,112,116,104,0,114, -97,121,95,100,101,112,116,104,95,116,114,97,0,104,97,114,0,115,101,101,100,49,0,115,101,101,100,50,0,103,108,111, -115,115,95,109,105,114,0,103,108,111,115,115,95,116,114,97,0,115,97,109,112,95,103,108,111,115,115,95,109,105,114,0, -115,97,109,112,95,103,108,111,115,115,95,116,114,97,0,97,100,97,112,116,95,116,104,114,101,115,104,95,109,105,114,0, -97,100,97,112,116,95,116,104,114,101,115,104,95,116,114,97,0,97,110,105,115,111,95,103,108,111,115,115,95,109,105,114, -0,100,105,115,116,95,109,105,114,0,102,97,100,101,116,111,95,109,105,114,0,115,104,97,100,101,95,102,108,97,103,0, -109,111,100,101,95,108,0,102,108,97,114,101,99,0,115,116,97,114,99,0,108,105,110,101,99,0,114,105,110,103,99,0, -104,97,115,105,122,101,0,102,108,97,114,101,115,105,122,101,0,115,117,98,115,105,122,101,0,102,108,97,114,101,98,111, -111,115,116,0,115,116,114,97,110,100,95,115,116,97,0,115,116,114,97,110,100,95,101,110,100,0,115,116,114,97,110,100, -95,101,97,115,101,0,115,116,114,97,110,100,95,115,117,114,102,110,111,114,0,115,116,114,97,110,100,95,109,105,110,0, -115,116,114,97,110,100,95,119,105,100,116,104,102,97,100,101,0,115,116,114,97,110,100,95,117,118,110,97,109,101,91,51, -50,93,0,115,98,105,97,115,0,108,98,105,97,115,0,115,104,97,100,95,97,108,112,104,97,0,115,101,112,116,101,120, -0,114,103,98,115,101,108,0,112,114,95,116,121,112,101,0,112,114,95,98,97,99,107,0,112,114,95,108,97,109,112,0, -109,108,95,102,108,97,103,0,100,105,102,102,95,115,104,97,100,101,114,0,115,112,101,99,95,115,104,97,100,101,114,0, -114,111,117,103,104,110,101,115,115,0,114,101,102,114,97,99,0,112,97,114,97,109,91,52,93,0,114,109,115,0,100,97, -114,107,110,101,115,115,0,42,114,97,109,112,95,99,111,108,0,42,114,97,109,112,95,115,112,101,99,0,114,97,109,112, -105,110,95,99,111,108,0,114,97,109,112,105,110,95,115,112,101,99,0,114,97,109,112,98,108,101,110,100,95,99,111,108, -0,114,97,109,112,98,108,101,110,100,95,115,112,101,99,0,114,97,109,112,95,115,104,111,119,0,114,97,109,112,102,97, -99,95,99,111,108,0,114,97,109,112,102,97,99,95,115,112,101,99,0,42,103,114,111,117,112,0,102,114,105,99,116,105, -111,110,0,102,104,0,114,101,102,108,101,99,116,0,102,104,100,105,115,116,0,120,121,102,114,105,99,116,0,100,121,110, -97,109,111,100,101,0,115,115,115,95,114,97,100,105,117,115,91,51,93,0,115,115,115,95,99,111,108,91,51,93,0,115, -115,115,95,101,114,114,111,114,0,115,115,115,95,115,99,97,108,101,0,115,115,115,95,105,111,114,0,115,115,115,95,99, -111,108,102,97,99,0,115,115,115,95,116,101,120,102,97,99,0,115,115,115,95,102,114,111,110,116,0,115,115,115,95,98, -97,99,107,0,115,115,115,95,102,108,97,103,0,115,115,115,95,112,114,101,115,101,116,0,89,70,95,97,114,0,89,70, -95,97,103,0,89,70,95,97,98,0,89,70,95,100,115,99,97,108,101,0,89,70,95,100,112,119,114,0,89,70,95,100, -115,109,112,0,89,70,95,112,114,101,115,101,116,0,89,70,95,100,106,105,116,0,103,112,117,109,97,116,101,114,105,97, -108,0,110,97,109,101,91,50,53,54,93,0,115,99,97,108,101,0,42,98,98,0,105,49,0,106,49,0,107,49,0,105, -50,0,106,50,0,107,50,0,115,101,108,99,111,108,49,0,115,101,108,99,111,108,50,0,113,117,97,116,91,52,93,0, -101,120,112,120,0,101,120,112,121,0,101,120,112,122,0,114,97,100,0,114,97,100,50,0,115,0,42,109,97,116,0,42, -105,109,97,116,0,101,108,101,109,115,0,100,105,115,112,0,42,42,109,97,116,0,116,111,116,99,111,108,0,119,105,114, -101,115,105,122,101,0,114,101,110,100,101,114,115,105,122,101,0,116,104,114,101,115,104,0,118,101,99,91,51,93,91,51, -93,0,97,108,102,97,0,119,101,105,103,104,116,0,114,97,100,105,117,115,0,104,49,0,104,50,0,102,49,0,102,50, -0,102,51,0,104,105,100,101,0,118,101,99,91,52,93,0,109,97,116,95,110,114,0,112,110,116,115,117,0,112,110,116, -115,118,0,114,101,115,111,108,117,0,114,101,115,111,108,118,0,111,114,100,101,114,117,0,111,114,100,101,114,118,0,102, -108,97,103,117,0,102,108,97,103,118,0,42,107,110,111,116,115,117,0,42,107,110,111,116,115,118,0,116,105,108,116,95, -105,110,116,101,114,112,0,114,97,100,105,117,115,95,105,110,116,101,114,112,0,99,104,97,114,105,100,120,0,107,101,114, -110,0,104,0,110,117,114,98,0,42,98,101,118,111,98,106,0,42,116,97,112,101,114,111,98,106,0,42,116,101,120,116, -111,110,99,117,114,118,101,0,42,112,97,116,104,0,42,107,101,121,0,98,101,118,0,112,97,116,104,108,101,110,0,98, -101,118,114,101,115,111,108,0,119,105,100,116,104,0,101,120,116,49,0,101,120,116,50,0,114,101,115,111,108,117,95,114, -101,110,0,114,101,115,111,108,118,95,114,101,110,0,115,112,97,99,101,109,111,100,101,0,115,112,97,99,105,110,103,0, -108,105,110,101,100,105,115,116,0,115,104,101,97,114,0,102,115,105,122,101,0,119,111,114,100,115,112,97,99,101,0,117, -108,112,111,115,0,117,108,104,101,105,103,104,116,0,120,111,102,0,121,111,102,0,108,105,110,101,119,105,100,116,104,0, -42,115,116,114,0,102,97,109,105,108,121,91,50,52,93,0,42,118,102,111,110,116,0,42,118,102,111,110,116,98,0,42, -118,102,111,110,116,105,0,42,118,102,111,110,116,98,105,0,115,101,112,99,104,97,114,0,116,111,116,98,111,120,0,97, -99,116,98,111,120,0,42,116,98,0,115,101,108,115,116,97,114,116,0,115,101,108,101,110,100,0,42,115,116,114,105,110, -102,111,0,99,117,114,105,110,102,111,0,101,102,102,101,99,116,0,42,109,102,97,99,101,0,42,109,116,102,97,99,101, -0,42,116,102,97,99,101,0,42,109,118,101,114,116,0,42,109,101,100,103,101,0,42,100,118,101,114,116,0,42,109,99, -111,108,0,42,109,115,116,105,99,107,121,0,42,116,101,120,99,111,109,101,115,104,0,42,109,115,101,108,101,99,116,0, -118,100,97,116,97,0,101,100,97,116,97,0,102,100,97,116,97,0,116,111,116,101,100,103,101,0,116,111,116,102,97,99, -101,0,116,111,116,115,101,108,101,99,116,0,97,99,116,95,102,97,99,101,0,99,117,98,101,109,97,112,115,105,122,101, -0,115,109,111,111,116,104,114,101,115,104,0,115,117,98,100,105,118,0,115,117,98,100,105,118,114,0,115,117,98,115,117, -114,102,116,121,112,101,0,42,109,114,0,42,112,118,0,42,116,112,97,103,101,0,117,118,91,52,93,91,50,93,0,99, -111,108,91,52,93,0,116,114,97,110,115,112,0,116,105,108,101,0,117,110,119,114,97,112,0,118,49,0,118,50,0,118, -51,0,118,52,0,101,100,99,111,100,101,0,99,114,101,97,115,101,0,98,119,101,105,103,104,116,0,100,101,102,95,110, -114,0,42,100,119,0,116,111,116,119,101,105,103,104,116,0,99,111,91,51,93,0,110,111,91,51,93,0,112,97,100,91, -51,93,0,117,118,91,50,93,0,99,111,91,50,93,0,105,110,100,101,120,0,102,0,105,0,115,91,50,53,54,93,0, -118,91,52,93,0,109,105,100,0,118,91,50,93,0,42,102,97,99,101,115,0,42,99,111,108,102,97,99,101,115,0,42, -101,100,103,101,115,0,42,101,100,103,101,95,98,111,117,110,100,97,114,121,95,115,116,97,116,101,115,0,42,118,101,114, -116,95,101,100,103,101,95,109,97,112,0,42,118,101,114,116,95,102,97,99,101,95,109,97,112,0,42,109,97,112,95,109, -101,109,0,42,118,101,114,116,115,0,108,101,118,101,108,115,0,108,101,118,101,108,95,99,111,117,110,116,0,99,117,114, -114,101,110,116,0,110,101,119,108,118,108,0,101,100,103,101,108,118,108,0,112,105,110,108,118,108,0,114,101,110,100,101, -114,108,118,108,0,117,115,101,95,99,111,108,0,42,101,100,103,101,95,102,108,97,103,115,0,42,101,100,103,101,95,99, -114,101,97,115,101,115,0,42,118,101,114,116,95,109,97,112,0,42,101,100,103,101,95,109,97,112,0,42,111,108,100,95, -102,97,99,101,115,0,42,111,108,100,95,101,100,103,101,115,0,42,101,114,114,111,114,0,109,111,100,105,102,105,101,114, -0,115,117,98,100,105,118,84,121,112,101,0,114,101,110,100,101,114,76,101,118,101,108,115,0,42,101,109,67,97,99,104, -101,0,42,109,67,97,99,104,101,0,100,101,102,97,120,105,115,0,112,97,100,91,54,93,0,108,101,110,103,116,104,0, -114,97,110,100,111,109,105,122,101,0,115,101,101,100,0,42,111,98,95,97,114,109,0,42,115,116,97,114,116,95,99,97, -112,0,42,101,110,100,95,99,97,112,0,42,99,117,114,118,101,95,111,98,0,42,111,102,102,115,101,116,95,111,98,0, -111,102,102,115,101,116,91,51,93,0,115,99,97,108,101,91,51,93,0,109,101,114,103,101,95,100,105,115,116,0,102,105, -116,95,116,121,112,101,0,111,102,102,115,101,116,95,116,121,112,101,0,99,111,117,110,116,0,97,120,105,115,0,116,111, -108,101,114,97,110,99,101,0,42,109,105,114,114,111,114,95,111,98,0,115,112,108,105,116,95,97,110,103,108,101,0,118, -97,108,117,101,0,114,101,115,0,118,97,108,95,102,108,97,103,115,0,108,105,109,95,102,108,97,103,115,0,101,95,102, -108,97,103,115,0,98,101,118,101,108,95,97,110,103,108,101,0,100,101,102,103,114,112,95,110,97,109,101,91,51,50,93, -0,42,116,101,120,116,117,114,101,0,115,116,114,101,110,103,116,104,0,100,105,114,101,99,116,105,111,110,0,109,105,100, -108,101,118,101,108,0,116,101,120,109,97,112,112,105,110,103,0,42,109,97,112,95,111,98,106,101,99,116,0,117,118,108, -97,121,101,114,95,110,97,109,101,91,51,50,93,0,117,118,108,97,121,101,114,95,116,109,112,0,42,112,114,111,106,101, -99,116,111,114,115,91,49,48,93,0,42,105,109,97,103,101,0,110,117,109,95,112,114,111,106,101,99,116,111,114,115,0, -97,115,112,101,99,116,120,0,97,115,112,101,99,116,121,0,112,101,114,99,101,110,116,0,102,97,99,101,67,111,117,110, -116,0,102,97,99,0,114,101,112,101,97,116,0,42,111,98,106,101,99,116,99,101,110,116,101,114,0,115,116,97,114,116, -120,0,115,116,97,114,116,121,0,104,101,105,103,104,116,0,110,97,114,114,111,119,0,115,112,101,101,100,0,100,97,109, -112,0,102,97,108,108,111,102,102,0,116,105,109,101,111,102,102,115,0,108,105,102,101,116,105,109,101,0,100,101,102,111, -114,109,102,108,97,103,0,109,117,108,116,105,0,42,112,114,101,118,67,111,115,0,112,97,114,101,110,116,105,110,118,91, -52,93,91,52,93,0,99,101,110,116,91,51,93,0,42,105,110,100,101,120,97,114,0,116,111,116,105,110,100,101,120,0, -102,111,114,99,101,0,42,99,108,111,116,104,79,98,106,101,99,116,0,42,115,105,109,95,112,97,114,109,115,0,42,99, -111,108,108,95,112,97,114,109,115,0,42,112,111,105,110,116,95,99,97,99,104,101,0,42,120,0,42,120,110,101,119,0, -42,120,111,108,100,0,42,99,117,114,114,101,110,116,95,120,110,101,119,0,42,99,117,114,114,101,110,116,95,120,0,42, -99,117,114,114,101,110,116,95,118,0,42,109,102,97,99,101,115,0,110,117,109,118,101,114,116,115,0,110,117,109,102,97, -99,101,115,0,97,98,115,111,114,112,116,105,111,110,0,116,105,109,101,0,42,98,118,104,116,114,101,101,0,42,100,109, -0,111,112,101,114,97,116,105,111,110,0,118,101,114,116,101,120,0,116,111,116,105,110,102,108,117,101,110,99,101,0,103, -114,105,100,115,105,122,101,0,110,101,101,100,98,105,110,100,0,42,98,105,110,100,119,101,105,103,104,116,115,0,42,98, -105,110,100,99,111,115,0,116,111,116,99,97,103,101,118,101,114,116,0,42,100,121,110,103,114,105,100,0,42,100,121,110, -105,110,102,108,117,101,110,99,101,115,0,42,100,121,110,118,101,114,116,115,0,42,112,97,100,50,0,100,121,110,103,114, -105,100,115,105,122,101,0,100,121,110,99,101,108,108,109,105,110,91,51,93,0,100,121,110,99,101,108,108,119,105,100,116, -104,0,98,105,110,100,109,97,116,91,52,93,91,52,93,0,42,112,115,121,115,0,116,111,116,100,109,118,101,114,116,0, -116,111,116,100,109,101,100,103,101,0,116,111,116,100,109,102,97,99,101,0,112,115,121,115,0,114,116,91,50,93,0,42, -102,97,99,101,112,97,0,118,103,114,111,117,112,0,112,114,111,116,101,99,116,0,42,102,115,115,0,42,116,97,114,103, -101,116,0,42,97,117,120,84,97,114,103,101,116,0,118,103,114,111,117,112,95,110,97,109,101,91,51,50,93,0,107,101, -101,112,68,105,115,116,0,115,104,114,105,110,107,84,121,112,101,0,115,104,114,105,110,107,79,112,116,115,0,112,114,111, -106,65,120,105,115,0,115,117,98,115,117,114,102,76,101,118,101,108,115,0,42,111,114,105,103,105,110,0,102,97,99,116, -111,114,0,108,105,109,105,116,91,50,93,0,111,114,105,103,105,110,79,112,116,115,0,112,110,116,115,119,0,111,112,110, -116,115,117,0,111,112,110,116,115,118,0,111,112,110,116,115,119,0,116,121,112,101,117,0,116,121,112,101,118,0,116,121, -112,101,119,0,102,117,0,102,118,0,102,119,0,100,117,0,100,118,0,100,119,0,42,100,101,102,0,118,101,99,91,56, -93,91,51,93,0,112,97,114,116,121,112,101,0,112,97,114,49,0,112,97,114,50,0,112,97,114,51,0,112,97,114,115, -117,98,115,116,114,91,51,50,93,0,42,116,114,97,99,107,0,42,112,114,111,120,121,0,42,112,114,111,120,121,95,103, -114,111,117,112,0,42,112,114,111,120,121,95,102,114,111,109,0,42,97,99,116,105,111,110,0,42,112,111,115,101,108,105, -98,0,42,112,111,115,101,0,99,111,110,115,116,114,97,105,110,116,67,104,97,110,110,101,108,115,0,100,101,102,98,97, -115,101,0,109,111,100,105,102,105,101,114,115,0,100,108,111,99,91,51,93,0,111,114,105,103,91,51,93,0,100,115,105, -122,101,91,51,93,0,100,114,111,116,91,51,93,0,111,98,109,97,116,91,52,93,91,52,93,0,99,111,110,115,116,105, -110,118,91,52,93,91,52,93,0,108,97,121,0,99,111,108,98,105,116,115,0,116,114,97,110,115,102,108,97,103,0,105, -112,111,102,108,97,103,0,116,114,97,99,107,102,108,97,103,0,117,112,102,108,97,103,0,110,108,97,102,108,97,103,0, -112,114,111,116,101,99,116,102,108,97,103,0,105,112,111,119,105,110,0,115,99,97,102,108,97,103,0,115,99,97,118,105, -115,102,108,97,103,0,98,111,117,110,100,116,121,112,101,0,100,117,112,111,110,0,100,117,112,111,102,102,0,100,117,112, -115,116,97,0,100,117,112,101,110,100,0,115,102,0,99,116,105,109,101,0,109,97,115,115,0,100,97,109,112,105,110,103, -0,105,110,101,114,116,105,97,0,102,111,114,109,102,97,99,116,111,114,0,114,100,97,109,112,105,110,103,0,115,105,122, -101,102,97,99,0,109,97,114,103,105,110,0,109,97,120,95,118,101,108,0,109,105,110,95,118,101,108,0,109,95,99,111, -110,116,97,99,116,80,114,111,99,101,115,115,105,110,103,84,104,114,101,115,104,111,108,100,0,100,116,0,100,116,120,0, -97,99,116,99,111,108,0,101,109,112,116,121,95,100,114,97,119,116,121,112,101,0,112,97,100,49,91,51,93,0,101,109, -112,116,121,95,100,114,97,119,115,105,122,101,0,100,117,112,102,97,99,101,115,99,97,0,112,114,111,112,0,115,101,110, -115,111,114,115,0,99,111,110,116,114,111,108,108,101,114,115,0,97,99,116,117,97,116,111,114,115,0,98,98,115,105,122, -101,91,51,93,0,97,99,116,100,101,102,0,103,97,109,101,102,108,97,103,0,103,97,109,101,102,108,97,103,50,0,42, -98,115,111,102,116,0,115,111,102,116,102,108,97,103,0,97,110,105,115,111,116,114,111,112,105,99,70,114,105,99,116,105, -111,110,91,51,93,0,99,111,110,115,116,114,97,105,110,116,115,0,110,108,97,115,116,114,105,112,115,0,104,111,111,107, -115,0,112,97,114,116,105,99,108,101,115,121,115,116,101,109,0,42,112,100,0,42,115,111,102,116,0,42,100,117,112,95, -103,114,111,117,112,0,102,108,117,105,100,115,105,109,70,108,97,103,0,114,101,115,116,114,105,99,116,102,108,97,103,0, -115,104,97,112,101,110,114,0,115,104,97,112,101,102,108,97,103,0,114,101,99,97,108,99,111,0,98,111,100,121,95,116, -121,112,101,0,42,102,108,117,105,100,115,105,109,83,101,116,116,105,110,103,115,0,42,100,101,114,105,118,101,100,68,101, -102,111,114,109,0,42,100,101,114,105,118,101,100,70,105,110,97,108,0,108,97,115,116,68,97,116,97,77,97,115,107,0, -115,116,97,116,101,0,105,110,105,116,95,115,116,97,116,101,0,103,112,117,108,97,109,112,0,99,117,114,105,110,100,101, -120,0,97,99,116,105,118,101,0,100,101,102,108,101,99,116,0,102,111,114,99,101,102,105,101,108,100,0,112,100,101,102, -95,100,97,109,112,0,112,100,101,102,95,114,100,97,109,112,0,112,100,101,102,95,112,101,114,109,0,112,100,101,102,95, -102,114,105,99,116,0,112,100,101,102,95,114,102,114,105,99,116,0,102,95,115,116,114,101,110,103,116,104,0,102,95,112, -111,119,101,114,0,102,95,100,105,115,116,0,102,95,100,97,109,112,0,109,97,120,100,105,115,116,0,109,105,110,100,105, -115,116,0,109,97,120,114,97,100,0,109,105,110,114,97,100,0,102,95,112,111,119,101,114,95,114,0,112,100,101,102,95, -115,98,100,97,109,112,0,112,100,101,102,95,115,98,105,102,116,0,112,100,101,102,95,115,98,111,102,116,0,99,108,117, -109,112,95,102,97,99,0,99,108,117,109,112,95,112,111,119,0,107,105,110,107,95,102,114,101,113,0,107,105,110,107,95, -115,104,97,112,101,0,107,105,110,107,95,97,109,112,0,102,114,101,101,95,101,110,100,0,116,101,120,95,110,97,98,108, -97,0,116,101,120,95,109,111,100,101,0,107,105,110,107,0,107,105,110,107,95,97,120,105,115,0,114,116,50,0,42,114, -110,103,0,102,95,110,111,105,115,101,0,115,105,109,102,114,97,109,101,0,115,116,97,114,116,102,114,97,109,101,0,101, -110,100,102,114,97,109,101,0,101,100,105,116,102,114,97,109,101,0,108,105,110,83,116,105,102,102,0,97,110,103,83,116, -105,102,102,0,118,111,108,117,109,101,0,118,105,116,101,114,97,116,105,111,110,115,0,112,105,116,101,114,97,116,105,111, -110,115,0,100,105,116,101,114,97,116,105,111,110,115,0,99,105,116,101,114,97,116,105,111,110,115,0,107,83,82,72,82, -95,67,76,0,107,83,75,72,82,95,67,76,0,107,83,83,72,82,95,67,76,0,107,83,82,95,83,80,76,84,95,67, -76,0,107,83,75,95,83,80,76,84,95,67,76,0,107,83,83,95,83,80,76,84,95,67,76,0,107,86,67,70,0,107, -68,80,0,107,68,71,0,107,76,70,0,107,80,82,0,107,86,67,0,107,68,70,0,107,77,84,0,107,67,72,82,0, -107,75,72,82,0,107,83,72,82,0,107,65,72,82,0,99,111,108,108,105,115,105,111,110,102,108,97,103,115,0,110,117, -109,99,108,117,115,116,101,114,105,116,101,114,97,116,105,111,110,115,0,119,101,108,100,105,110,103,0,42,112,97,114,116, -105,99,108,101,115,0,116,111,116,112,111,105,110,116,0,116,111,116,115,112,114,105,110,103,0,42,98,112,111,105,110,116, -0,42,98,115,112,114,105,110,103,0,109,115,103,95,108,111,99,107,0,109,115,103,95,118,97,108,117,101,0,110,111,100, -101,109,97,115,115,0,110,97,109,101,100,86,71,95,77,97,115,115,91,51,50,93,0,103,114,97,118,0,109,101,100,105, -97,102,114,105,99,116,0,114,107,108,105,109,105,116,0,112,104,121,115,105,99,115,95,115,112,101,101,100,0,103,111,97, -108,115,112,114,105,110,103,0,103,111,97,108,102,114,105,99,116,0,109,105,110,103,111,97,108,0,109,97,120,103,111,97, -108,0,100,101,102,103,111,97,108,0,118,101,114,116,103,114,111,117,112,0,110,97,109,101,100,86,71,95,83,111,102,116, -103,111,97,108,91,51,50,93,0,102,117,122,122,121,110,101,115,115,0,105,110,115,112,114,105,110,103,0,105,110,102,114, -105,99,116,0,110,97,109,101,100,86,71,95,83,112,114,105,110,103,95,75,91,51,50,93,0,101,102,114,97,0,105,110, -116,101,114,118,97,108,0,108,111,99,97,108,0,115,111,108,118,101,114,102,108,97,103,115,0,42,42,107,101,121,115,0, -116,111,116,112,111,105,110,116,107,101,121,0,115,101,99,111,110,100,115,112,114,105,110,103,0,99,111,108,98,97,108,108, -0,98,97,108,108,100,97,109,112,0,98,97,108,108,115,116,105,102,102,0,115,98,99,95,109,111,100,101,0,97,101,114, -111,101,100,103,101,0,109,105,110,108,111,111,112,115,0,109,97,120,108,111,111,112,115,0,99,104,111,107,101,0,115,111, -108,118,101,114,95,73,68,0,112,108,97,115,116,105,99,0,115,112,114,105,110,103,112,114,101,108,111,97,100,0,42,115, -99,114,97,116,99,104,0,115,104,101,97,114,115,116,105,102,102,0,105,110,112,117,115,104,0,42,112,111,105,110,116,99, -97,99,104,101,0,115,104,111,119,95,97,100,118,97,110,99,101,100,111,112,116,105,111,110,115,0,114,101,115,111,108,117, -116,105,111,110,120,121,122,0,112,114,101,118,105,101,119,114,101,115,120,121,122,0,114,101,97,108,115,105,122,101,0,103, -117,105,68,105,115,112,108,97,121,77,111,100,101,0,114,101,110,100,101,114,68,105,115,112,108,97,121,77,111,100,101,0, -118,105,115,99,111,115,105,116,121,86,97,108,117,101,0,118,105,115,99,111,115,105,116,121,77,111,100,101,0,118,105,115, -99,111,115,105,116,121,69,120,112,111,110,101,110,116,0,103,114,97,118,120,0,103,114,97,118,121,0,103,114,97,118,122, -0,97,110,105,109,83,116,97,114,116,0,97,110,105,109,69,110,100,0,103,115,116,97,114,0,109,97,120,82,101,102,105, -110,101,0,105,110,105,86,101,108,120,0,105,110,105,86,101,108,121,0,105,110,105,86,101,108,122,0,42,111,114,103,77, -101,115,104,0,42,109,101,115,104,83,117,114,102,97,99,101,0,42,109,101,115,104,66,66,0,115,117,114,102,100,97,116, -97,80,97,116,104,91,50,52,48,93,0,98,98,83,116,97,114,116,91,51,93,0,98,98,83,105,122,101,91,51,93,0, -116,121,112,101,70,108,97,103,115,0,100,111,109,97,105,110,78,111,118,101,99,103,101,110,0,118,111,108,117,109,101,73, -110,105,116,84,121,112,101,0,112,97,114,116,83,108,105,112,86,97,108,117,101,0,103,101,110,101,114,97,116,101,84,114, -97,99,101,114,115,0,103,101,110,101,114,97,116,101,80,97,114,116,105,99,108,101,115,0,115,117,114,102,97,99,101,83, -109,111,111,116,104,105,110,103,0,115,117,114,102,97,99,101,83,117,98,100,105,118,115,0,112,97,114,116,105,99,108,101, -73,110,102,83,105,122,101,0,112,97,114,116,105,99,108,101,73,110,102,65,108,112,104,97,0,102,97,114,70,105,101,108, -100,83,105,122,101,0,42,109,101,115,104,83,117,114,102,78,111,114,109,97,108,115,0,99,112,115,84,105,109,101,83,116, -97,114,116,0,99,112,115,84,105,109,101,69,110,100,0,99,112,115,81,117,97,108,105,116,121,0,97,116,116,114,97,99, -116,102,111,114,99,101,83,116,114,101,110,103,116,104,0,97,116,116,114,97,99,116,102,111,114,99,101,82,97,100,105,117, -115,0,118,101,108,111,99,105,116,121,102,111,114,99,101,83,116,114,101,110,103,116,104,0,118,101,108,111,99,105,116,121, -102,111,114,99,101,82,97,100,105,117,115,0,108,97,115,116,103,111,111,100,102,114,97,109,101,0,109,105,115,116,121,112, -101,0,104,111,114,114,0,104,111,114,103,0,104,111,114,98,0,104,111,114,107,0,122,101,110,114,0,122,101,110,103,0, -122,101,110,98,0,122,101,110,107,0,97,109,98,107,0,102,97,115,116,99,111,108,0,101,120,112,111,115,117,114,101,0, -101,120,112,0,114,97,110,103,101,0,108,105,110,102,97,99,0,108,111,103,102,97,99,0,103,114,97,118,105,116,121,0, -97,99,116,105,118,105,116,121,66,111,120,82,97,100,105,117,115,0,115,107,121,116,121,112,101,0,111,99,99,108,117,115, -105,111,110,82,101,115,0,112,104,121,115,105,99,115,69,110,103,105,110,101,0,116,105,99,114,97,116,101,0,109,97,120, -108,111,103,105,99,115,116,101,112,0,112,104,121,115,117,98,115,116,101,112,0,109,97,120,112,104,121,115,116,101,112,0, -109,105,115,105,0,109,105,115,116,115,116,97,0,109,105,115,116,100,105,115,116,0,109,105,115,116,104,105,0,115,116,97, -114,114,0,115,116,97,114,103,0,115,116,97,114,98,0,115,116,97,114,107,0,115,116,97,114,115,105,122,101,0,115,116, -97,114,109,105,110,100,105,115,116,0,115,116,97,114,100,105,115,116,0,115,116,97,114,99,111,108,110,111,105,115,101,0, -100,111,102,115,116,97,0,100,111,102,101,110,100,0,100,111,102,109,105,110,0,100,111,102,109,97,120,0,97,111,100,105, -115,116,0,97,111,100,105,115,116,102,97,99,0,97,111,101,110,101,114,103,121,0,97,111,98,105,97,115,0,97,111,109, -111,100,101,0,97,111,115,97,109,112,0,97,111,109,105,120,0,97,111,99,111,108,111,114,0,97,111,95,97,100,97,112, -116,95,116,104,114,101,115,104,0,97,111,95,97,100,97,112,116,95,115,112,101,101,100,95,102,97,99,0,97,111,95,97, -112,112,114,111,120,95,101,114,114,111,114,0,97,111,95,97,112,112,114,111,120,95,99,111,114,114,101,99,116,105,111,110, -0,97,111,95,115,97,109,112,95,109,101,116,104,111,100,0,97,111,95,103,97,116,104,101,114,95,109,101,116,104,111,100, -0,97,111,95,97,112,112,114,111,120,95,112,97,115,115,101,115,0,42,97,111,115,112,104,101,114,101,0,42,97,111,116, -97,98,108,101,115,0,104,101,109,105,114,101,115,0,109,97,120,105,116,101,114,0,100,114,97,119,116,121,112,101,0,115, -117,98,115,104,111,111,116,112,0,115,117,98,115,104,111,111,116,101,0,110,111,100,101,108,105,109,0,109,97,120,115,117, -98,108,97,109,112,0,112,97,109,97,0,112,97,109,105,0,101,108,109,97,0,101,108,109,105,0,109,97,120,110,111,100, -101,0,99,111,110,118,101,114,103,101,110,99,101,0,114,97,100,102,97,99,0,103,97,109,109,97,0,115,101,108,99,111, -108,0,115,120,0,115,121,0,42,108,112,70,111,114,109,97,116,0,42,108,112,80,97,114,109,115,0,99,98,70,111,114, -109,97,116,0,99,98,80,97,114,109,115,0,102,99,99,84,121,112,101,0,102,99,99,72,97,110,100,108,101,114,0,100, -119,75,101,121,70,114,97,109,101,69,118,101,114,121,0,100,119,81,117,97,108,105,116,121,0,100,119,66,121,116,101,115, -80,101,114,83,101,99,111,110,100,0,100,119,70,108,97,103,115,0,100,119,73,110,116,101,114,108,101,97,118,101,69,118, -101,114,121,0,97,118,105,99,111,100,101,99,110,97,109,101,91,49,50,56,93,0,42,99,100,80,97,114,109,115,0,42, -112,97,100,0,99,100,83,105,122,101,0,113,116,99,111,100,101,99,110,97,109,101,91,49,50,56,93,0,99,111,100,101, -99,0,97,117,100,105,111,95,99,111,100,101,99,0,118,105,100,101,111,95,98,105,116,114,97,116,101,0,97,117,100,105, -111,95,98,105,116,114,97,116,101,0,103,111,112,95,115,105,122,101,0,114,99,95,109,105,110,95,114,97,116,101,0,114, -99,95,109,97,120,95,114,97,116,101,0,114,99,95,98,117,102,102,101,114,95,115,105,122,101,0,109,117,120,95,112,97, -99,107,101,116,95,115,105,122,101,0,109,117,120,95,114,97,116,101,0,109,105,120,114,97,116,101,0,109,97,105,110,0, -42,109,97,116,95,111,118,101,114,114,105,100,101,0,42,108,105,103,104,116,95,111,118,101,114,114,105,100,101,0,108,97, -121,95,122,109,97,115,107,0,108,97,121,102,108,97,103,0,112,97,115,115,102,108,97,103,0,112,97,115,115,95,120,111, -114,0,42,97,118,105,99,111,100,101,99,100,97,116,97,0,42,113,116,99,111,100,101,99,100,97,116,97,0,102,102,99, -111,100,101,99,100,97,116,97,0,99,102,114,97,0,112,115,102,114,97,0,112,101,102,114,97,0,105,109,97,103,101,115, -0,102,114,97,109,97,112,116,111,0,116,104,114,101,97,100,115,0,102,114,97,109,101,108,101,110,0,98,108,117,114,102, -97,99,0,101,100,103,101,82,0,101,100,103,101,71,0,101,100,103,101,66,0,102,117,108,108,115,99,114,101,101,110,0, -120,112,108,97,121,0,121,112,108,97,121,0,102,114,101,113,112,108,97,121,0,97,116,116,114,105,98,0,114,116,49,0, -115,116,101,114,101,111,109,111,100,101,0,100,105,109,101,110,115,105,111,110,115,112,114,101,115,101,116,0,109,97,120,105, -109,115,105,122,101,0,120,115,99,104,0,121,115,99,104,0,120,112,97,114,116,115,0,121,112,97,114,116,115,0,119,105, -110,112,111,115,0,112,108,97,110,101,115,0,105,109,116,121,112,101,0,115,117,98,105,109,116,121,112,101,0,113,117,97, -108,105,116,121,0,114,112,97,100,0,114,112,97,100,49,0,114,112,97,100,50,0,115,99,101,109,111,100,101,0,114,101, -110,100,101,114,101,114,0,111,99,114,101,115,0,97,108,112,104,97,109,111,100,101,0,111,115,97,0,102,114,115,95,115, -101,99,0,101,100,103,101,105,110,116,0,115,97,102,101,116,121,0,98,111,114,100,101,114,0,100,105,115,112,114,101,99, -116,0,108,97,121,101,114,115,0,97,99,116,108,97,121,0,120,97,115,112,0,121,97,115,112,0,102,114,115,95,115,101, -99,95,98,97,115,101,0,103,97,117,115,115,0,112,111,115,116,109,117,108,0,112,111,115,116,103,97,109,109,97,0,112, -111,115,116,104,117,101,0,112,111,115,116,115,97,116,0,100,105,116,104,101,114,95,105,110,116,101,110,115,105,116,121,0, -98,97,107,101,95,111,115,97,0,98,97,107,101,95,102,105,108,116,101,114,0,98,97,107,101,95,109,111,100,101,0,98, -97,107,101,95,102,108,97,103,0,98,97,107,101,95,110,111,114,109,97,108,95,115,112,97,99,101,0,98,97,107,101,95, -113,117,97,100,95,115,112,108,105,116,0,98,97,107,101,95,109,97,120,100,105,115,116,0,98,97,107,101,95,98,105,97, -115,100,105,115,116,0,98,97,107,101,95,112,97,100,0,71,73,113,117,97,108,105,116,121,0,71,73,99,97,99,104,101, -0,71,73,109,101,116,104,111,100,0,71,73,112,104,111,116,111,110,115,0,71,73,100,105,114,101,99,116,0,89,70,95, -65,65,0,89,70,101,120,112,111,114,116,120,109,108,0,89,70,95,110,111,98,117,109,112,0,89,70,95,99,108,97,109, -112,114,103,98,0,121,102,112,97,100,49,0,71,73,100,101,112,116,104,0,71,73,99,97,117,115,100,101,112,116,104,0, -71,73,112,105,120,101,108,115,112,101,114,115,97,109,112,108,101,0,71,73,112,104,111,116,111,110,99,111,117,110,116,0, -71,73,109,105,120,112,104,111,116,111,110,115,0,71,73,112,104,111,116,111,110,114,97,100,105,117,115,0,89,70,95,114, -97,121,100,101,112,116,104,0,89,70,95,65,65,112,97,115,115,101,115,0,89,70,95,65,65,115,97,109,112,108,101,115, -0,121,102,112,97,100,50,0,71,73,115,104,97,100,111,119,113,117,97,108,105,116,121,0,71,73,114,101,102,105,110,101, -109,101,110,116,0,71,73,112,111,119,101,114,0,71,73,105,110,100,105,114,112,111,119,101,114,0,89,70,95,103,97,109, -109,97,0,89,70,95,101,120,112,111,115,117,114,101,0,89,70,95,114,97,121,98,105,97,115,0,89,70,95,65,65,112, -105,120,101,108,115,105,122,101,0,89,70,95,65,65,116,104,114,101,115,104,111,108,100,0,98,97,99,107,98,117,102,91, -49,54,48,93,0,112,105,99,91,49,54,48,93,0,115,116,97,109,112,0,115,116,97,109,112,95,102,111,110,116,95,105, -100,0,115,116,97,109,112,95,117,100,97,116,97,91,49,54,48,93,0,102,103,95,115,116,97,109,112,91,52,93,0,98, -103,95,115,116,97,109,112,91,52,93,0,115,105,109,112,108,105,102,121,95,115,117,98,115,117,114,102,0,115,105,109,112, -108,105,102,121,95,115,104,97,100,111,119,115,97,109,112,108,101,115,0,115,105,109,112,108,105,102,121,95,112,97,114,116, -105,99,108,101,115,0,115,105,109,112,108,105,102,121,95,97,111,115,115,115,0,99,105,110,101,111,110,119,104,105,116,101, -0,99,105,110,101,111,110,98,108,97,99,107,0,99,105,110,101,111,110,103,97,109,109,97,0,106,112,50,95,112,114,101, -115,101,116,0,106,112,50,95,100,101,112,116,104,0,114,112,97,100,51,0,100,111,109,101,114,101,115,0,100,111,109,101, -109,111,100,101,0,100,111,109,101,97,110,103,108,101,0,100,111,109,101,116,105,108,116,0,100,111,109,101,114,101,115,98, -117,102,0,42,100,111,109,101,116,101,120,116,0,112,97,114,116,105,99,108,101,95,112,101,114,99,0,115,117,98,115,117, -114,102,95,109,97,120,0,115,104,97,100,98,117,102,115,97,109,112,108,101,95,109,97,120,0,97,111,95,101,114,114,111, -114,0,99,111,108,91,51,93,0,102,114,97,109,101,0,110,97,109,101,91,54,52,93,0,42,98,114,117,115,104,0,116, -111,111,108,0,115,101,97,109,95,98,108,101,101,100,0,110,111,114,109,97,108,95,97,110,103,108,101,0,115,116,101,112, -0,105,110,118,101,114,116,0,116,111,116,114,101,107,101,121,0,116,111,116,97,100,100,107,101,121,0,98,114,117,115,104, -116,121,112,101,0,98,114,117,115,104,91,55,93,0,101,109,105,116,116,101,114,100,105,115,116,0,100,114,97,119,95,116, -105,109,101,100,0,110,97,109,101,91,51,54,93,0,109,97,116,91,51,93,91,51,93,0,99,111,114,110,101,114,116,121, -112,101,0,101,100,105,116,98,117,116,102,108,97,103,0,106,111,105,110,116,114,105,108,105,109,105,116,0,100,101,103,114, -0,116,117,114,110,0,101,120,116,114,95,111,102,102,115,0,100,111,117,98,108,105,109,105,116,0,115,101,103,109,101,110, -116,115,0,114,105,110,103,115,0,118,101,114,116,105,99,101,115,0,117,110,119,114,97,112,112,101,114,0,117,118,99,97, -108,99,95,114,97,100,105,117,115,0,117,118,99,97,108,99,95,99,117,98,101,115,105,122,101,0,117,118,99,97,108,99, -95,109,97,114,103,105,110,0,117,118,99,97,108,99,95,109,97,112,100,105,114,0,117,118,99,97,108,99,95,109,97,112, -97,108,105,103,110,0,117,118,99,97,108,99,95,102,108,97,103,0,97,117,116,111,105,107,95,99,104,97,105,110,108,101, -110,0,105,109,97,112,97,105,110,116,0,112,97,114,116,105,99,108,101,0,115,101,108,101,99,116,95,116,104,114,101,115, -104,0,99,108,101,97,110,95,116,104,114,101,115,104,0,114,101,116,111,112,111,95,109,111,100,101,0,114,101,116,111,112, -111,95,112,97,105,110,116,95,116,111,111,108,0,108,105,110,101,95,100,105,118,0,101,108,108,105,112,115,101,95,100,105, -118,0,114,101,116,111,112,111,95,104,111,116,115,112,111,116,0,109,117,108,116,105,114,101,115,95,115,117,98,100,105,118, -95,116,121,112,101,0,115,107,103,101,110,95,114,101,115,111,108,117,116,105,111,110,0,115,107,103,101,110,95,116,104,114, -101,115,104,111,108,100,95,105,110,116,101,114,110,97,108,0,115,107,103,101,110,95,116,104,114,101,115,104,111,108,100,95, -101,120,116,101,114,110,97,108,0,115,107,103,101,110,95,108,101,110,103,116,104,95,114,97,116,105,111,0,115,107,103,101, -110,95,108,101,110,103,116,104,95,108,105,109,105,116,0,115,107,103,101,110,95,97,110,103,108,101,95,108,105,109,105,116, -0,115,107,103,101,110,95,99,111,114,114,101,108,97,116,105,111,110,95,108,105,109,105,116,0,115,107,103,101,110,95,115, -121,109,109,101,116,114,121,95,108,105,109,105,116,0,115,107,103,101,110,95,114,101,116,97,114,103,101,116,95,97,110,103, -108,101,95,119,101,105,103,104,116,0,115,107,103,101,110,95,114,101,116,97,114,103,101,116,95,108,101,110,103,116,104,95, -119,101,105,103,104,116,0,115,107,103,101,110,95,114,101,116,97,114,103,101,116,95,100,105,115,116,97,110,99,101,95,119, -101,105,103,104,116,0,115,107,103,101,110,95,111,112,116,105,111,110,115,0,115,107,103,101,110,95,112,111,115,116,112,114, -111,0,115,107,103,101,110,95,112,111,115,116,112,114,111,95,112,97,115,115,101,115,0,115,107,103,101,110,95,115,117,98, -100,105,118,105,115,105,111,110,115,91,51,93,0,115,107,103,101,110,95,109,117,108,116,105,95,108,101,118,101,108,0,42, -115,107,103,101,110,95,116,101,109,112,108,97,116,101,0,98,111,110,101,95,115,107,101,116,99,104,105,110,103,0,98,111, -110,101,95,115,107,101,116,99,104,105,110,103,95,99,111,110,118,101,114,116,0,115,107,103,101,110,95,115,117,98,100,105, -118,105,115,105,111,110,95,110,117,109,98,101,114,0,115,107,103,101,110,95,114,101,116,97,114,103,101,116,95,111,112,116, -105,111,110,115,0,115,107,103,101,110,95,114,101,116,97,114,103,101,116,95,114,111,108,108,0,115,107,103,101,110,95,115, -105,100,101,95,115,116,114,105,110,103,91,56,93,0,115,107,103,101,110,95,110,117,109,95,115,116,114,105,110,103,91,56, -93,0,101,100,103,101,95,109,111,100,101,0,112,97,100,51,91,50,93,0,100,105,114,0,118,105,101,119,0,42,115,101, -115,115,105,111,110,0,42,99,117,109,97,112,0,100,114,97,119,98,114,117,115,104,0,115,109,111,111,116,104,98,114,117, -115,104,0,112,105,110,99,104,98,114,117,115,104,0,105,110,102,108,97,116,101,98,114,117,115,104,0,103,114,97,98,98, -114,117,115,104,0,108,97,121,101,114,98,114,117,115,104,0,102,108,97,116,116,101,110,98,114,117,115,104,0,112,105,118, -111,116,91,51,93,0,98,114,117,115,104,95,116,121,112,101,0,116,101,120,110,114,0,116,101,120,114,101,112,116,0,116, -101,120,102,97,100,101,0,116,101,120,115,101,112,0,97,118,101,114,97,103,105,110,103,0,116,97,98,108,101,116,95,115, -105,122,101,0,116,97,98,108,101,116,95,115,116,114,101,110,103,116,104,0,115,121,109,109,0,114,97,107,101,0,97,120, -105,115,108,111,99,107,0,42,99,97,109,101,114,97,0,42,119,111,114,108,100,0,42,115,101,116,0,98,97,115,101,0, -42,98,97,115,97,99,116,0,99,117,114,115,111,114,91,51,93,0,116,119,99,101,110,116,91,51,93,0,116,119,109,105, -110,91,51,93,0,116,119,109,97,120,91,51,93,0,101,100,105,116,98,117,116,115,105,122,101,0,115,101,108,101,99,116, -109,111,100,101,0,112,114,111,112,111,114,116,105,111,110,97,108,0,112,114,111,112,95,109,111,100,101,0,97,117,116,111, -109,101,114,103,101,0,112,97,100,53,0,112,97,100,54,0,97,117,116,111,107,101,121,95,109,111,100,101,0,42,101,100, -0,42,114,97,100,105,111,0,102,114,97,109,105,110,103,0,42,116,111,111,108,115,101,116,116,105,110,103,115,0,97,117, -100,105,111,0,116,114,97,110,115,102,111,114,109,95,115,112,97,99,101,115,0,106,117,109,112,102,114,97,109,101,0,115, -110,97,112,95,109,111,100,101,0,115,110,97,112,95,102,108,97,103,0,115,110,97,112,95,116,97,114,103,101,116,0,42, -116,104,101,68,97,103,0,100,97,103,105,115,118,97,108,105,100,0,100,97,103,102,108,97,103,115,0,115,99,117,108,112, -116,100,97,116,97,0,102,114,97,109,101,95,115,116,101,112,0,122,111,111,109,0,98,108,101,110,100,0,120,105,109,0, -121,105,109,0,115,112,97,99,101,116,121,112,101,0,98,108,111,99,107,115,99,97,108,101,0,42,97,114,101,97,0,98, -108,111,99,107,104,97,110,100,108,101,114,91,56,93,0,118,105,101,119,109,97,116,91,52,93,91,52,93,0,118,105,101, -119,105,110,118,91,52,93,91,52,93,0,112,101,114,115,109,97,116,91,52,93,91,52,93,0,112,101,114,115,105,110,118, -91,52,93,91,52,93,0,119,105,110,109,97,116,49,91,52,93,91,52,93,0,118,105,101,119,109,97,116,49,91,52,93, -91,52,93,0,118,105,101,119,113,117,97,116,91,52,93,0,122,102,97,99,0,108,97,121,95,117,115,101,100,0,112,101, -114,115,112,0,42,111,98,95,99,101,110,116,114,101,0,42,98,103,112,105,99,0,42,108,111,99,97,108,118,100,0,42, -114,105,0,42,114,101,116,111,112,111,95,118,105,101,119,95,100,97,116,97,0,42,100,101,112,116,104,115,0,111,98,95, -99,101,110,116,114,101,95,98,111,110,101,91,51,50,93,0,108,111,99,97,108,118,105,101,119,0,108,97,121,97,99,116, -0,115,99,101,110,101,108,111,99,107,0,97,114,111,117,110,100,0,99,97,109,122,111,111,109,0,112,105,118,111,116,95, -108,97,115,116,0,103,114,105,100,0,103,114,105,100,118,105,101,119,0,112,105,120,115,105,122,101,0,110,101,97,114,0, -102,97,114,0,99,97,109,100,120,0,99,97,109,100,121,0,103,114,105,100,108,105,110,101,115,0,118,105,101,119,98,117, -116,0,103,114,105,100,102,108,97,103,0,109,111,100,101,115,101,108,101,99,116,0,116,119,116,121,112,101,0,116,119,109, -111,100,101,0,116,119,102,108,97,103,0,116,119,100,114,97,119,102,108,97,103,0,116,119,109,97,116,91,52,93,91,52, -93,0,99,108,105,112,91,52,93,91,52,93,0,42,99,108,105,112,98,98,0,97,102,116,101,114,100,114,97,119,0,122, -98,117,102,0,120,114,97,121,0,102,108,97,103,50,0,103,114,105,100,115,117,98,100,105,118,0,107,101,121,102,108,97, -103,115,0,110,100,111,102,109,111,100,101,0,110,100,111,102,102,105,108,116,101,114,0,42,112,114,111,112,101,114,116,105, -101,115,95,115,116,111,114,97,103,101,0,42,103,112,100,0,108,118,105,101,119,113,117,97,116,91,52,93,0,108,112,101, -114,115,112,0,108,118,105,101,119,0,118,101,114,116,0,104,111,114,0,109,97,115,107,0,109,105,110,91,50,93,0,109, -97,120,91,50,93,0,109,105,110,122,111,111,109,0,109,97,120,122,111,111,109,0,115,99,114,111,108,108,0,107,101,101, -112,116,111,116,0,107,101,101,112,97,115,112,101,99,116,0,107,101,101,112,122,111,111,109,0,111,108,100,119,105,110,120, -0,111,108,100,119,105,110,121,0,99,117,114,115,111,114,91,50,93,0,114,111,119,98,117,116,0,118,50,100,0,42,101, -100,105,116,105,112,111,0,105,112,111,107,101,121,0,97,99,116,110,97,109,101,91,51,50,93,0,99,111,110,115,116,110, -97,109,101,91,51,50,93,0,98,111,110,101,110,97,109,101,91,51,50,93,0,116,111,116,105,112,111,0,112,105,110,0, -98,117,116,111,102,115,0,99,104,97,110,110,101,108,0,108,111,99,107,0,109,101,100,105,97,110,91,51,93,0,99,117, -114,115,101,110,115,0,99,117,114,97,99,116,0,97,108,105,103,110,0,116,97,98,111,0,109,97,105,110,98,0,109,97, -105,110,98,111,0,42,108,111,99,107,112,111,105,110,0,116,101,120,102,114,111,109,0,115,104,111,119,103,114,111,117,112, -0,109,111,100,101,108,116,121,112,101,0,115,99,114,105,112,116,98,108,111,99,107,0,114,101,95,97,108,105,103,110,0, -111,108,100,107,101,121,112,114,101,115,115,0,116,97,98,91,55,93,0,114,101,110,100,101,114,95,115,105,122,101,0,99, -104,97,110,115,104,111,119,110,0,122,101,98,114,97,0,42,102,105,108,101,108,105,115,116,0,116,111,116,102,105,108,101, -0,116,105,116,108,101,91,50,52,93,0,100,105,114,91,50,52,48,93,0,102,105,108,101,91,56,48,93,0,111,102,115, -0,115,111,114,116,0,109,97,120,110,97,109,101,108,101,110,0,99,111,108,108,117,109,115,0,102,95,102,112,0,102,112, -95,115,116,114,91,56,93,0,42,108,105,98,102,105,108,101,100,97,116,97,0,114,101,116,118,97,108,0,109,101,110,117, -0,97,99,116,0,40,42,114,101,116,117,114,110,102,117,110,99,41,40,41,0,40,42,114,101,116,117,114,110,102,117,110, -99,95,101,118,101,110,116,41,40,41,0,40,42,114,101,116,117,114,110,102,117,110,99,95,97,114,103,115,41,40,41,0, -42,97,114,103,49,0,42,97,114,103,50,0,42,109,101,110,117,112,0,42,112,117,112,109,101,110,117,0,111,111,112,115, -0,118,105,115,105,102,108,97,103,0,116,114,101,101,0,42,116,114,101,101,115,116,111,114,101,0,115,101,97,114,99,104, -95,115,116,114,105,110,103,91,51,50,93,0,115,101,97,114,99,104,95,116,115,101,0,115,101,97,114,99,104,95,102,108, -97,103,115,0,100,111,95,0,111,117,116,108,105,110,101,118,105,115,0,115,116,111,114,101,102,108,97,103,0,100,101,112, -115,95,102,108,97,103,115,0,105,109,97,110,114,0,99,117,114,116,105,108,101,0,105,109,116,121,112,101,110,114,0,100, -116,95,117,118,0,115,116,105,99,107,121,0,100,116,95,117,118,115,116,114,101,116,99,104,0,112,97,100,91,53,93,0, -99,101,110,116,120,0,99,101,110,116,121,0,97,117,116,111,115,110,97,112,0,42,116,101,120,116,0,116,111,112,0,118, -105,101,119,108,105,110,101,115,0,102,111,110,116,95,105,100,0,108,104,101,105,103,104,116,0,108,101,102,116,0,115,104, -111,119,108,105,110,101,110,114,115,0,116,97,98,110,117,109,98,101,114,0,99,117,114,114,116,97,98,95,115,101,116,0, -115,104,111,119,115,121,110,116,97,120,0,111,118,101,114,119,114,105,116,101,0,112,105,120,95,112,101,114,95,108,105,110, -101,0,116,120,116,115,99,114,111,108,108,0,116,120,116,98,97,114,0,119,111,114,100,119,114,97,112,0,100,111,112,108, -117,103,105,110,115,0,42,112,121,95,100,114,97,119,0,42,112,121,95,101,118,101,110,116,0,42,112,121,95,98,117,116, -116,111,110,0,42,112,121,95,98,114,111,119,115,101,114,99,97,108,108,98,97,99,107,0,42,112,121,95,103,108,111,98, -97,108,100,105,99,116,0,108,97,115,116,115,112,97,99,101,0,115,99,114,105,112,116,110,97,109,101,91,50,53,54,93, -0,115,99,114,105,112,116,97,114,103,91,50,53,54,93,0,42,115,99,114,105,112,116,0,42,98,117,116,95,114,101,102, -115,0,114,101,100,114,97,119,115,0,42,105,100,0,97,115,112,101,99,116,0,42,99,117,114,102,111,110,116,0,42,101, -100,105,116,116,114,101,101,0,116,114,101,101,116,121,112,101,0,42,102,105,108,101,115,0,97,99,116,105,118,101,95,102, -105,108,101,0,110,117,109,116,105,108,101,115,120,0,110,117,109,116,105,108,101,115,121,0,115,101,108,115,116,97,116,101, -0,118,105,101,119,114,101,99,116,0,98,111,111,107,109,97,114,107,114,101,99,116,0,115,99,114,111,108,108,112,111,115, -0,115,99,114,111,108,108,104,101,105,103,104,116,0,115,99,114,111,108,108,97,114,101,97,0,97,99,116,105,118,101,95, -98,111,111,107,109,97,114,107,0,112,114,118,95,119,0,112,114,118,95,104,0,42,105,109,103,0,111,117,116,108,105,110, -101,91,52,93,0,110,101,117,116,114,97,108,91,52,93,0,97,99,116,105,111,110,91,52,93,0,115,101,116,116,105,110, -103,91,52,93,0,115,101,116,116,105,110,103,49,91,52,93,0,115,101,116,116,105,110,103,50,91,52,93,0,110,117,109, -91,52,93,0,116,101,120,116,102,105,101,108,100,91,52,93,0,116,101,120,116,102,105,101,108,100,95,104,105,91,52,93, -0,112,111,112,117,112,91,52,93,0,116,101,120,116,91,52,93,0,116,101,120,116,95,104,105,91,52,93,0,109,101,110, -117,95,98,97,99,107,91,52,93,0,109,101,110,117,95,105,116,101,109,91,52,93,0,109,101,110,117,95,104,105,108,105, -116,101,91,52,93,0,109,101,110,117,95,116,101,120,116,91,52,93,0,109,101,110,117,95,116,101,120,116,95,104,105,91, -52,93,0,98,117,116,95,100,114,97,119,116,121,112,101,0,105,99,111,110,102,105,108,101,91,56,48,93,0,98,97,99, -107,91,52,93,0,104,101,97,100,101,114,91,52,93,0,112,97,110,101,108,91,52,93,0,115,104,97,100,101,49,91,52, -93,0,115,104,97,100,101,50,91,52,93,0,104,105,108,105,116,101,91,52,93,0,103,114,105,100,91,52,93,0,119,105, -114,101,91,52,93,0,115,101,108,101,99,116,91,52,93,0,108,97,109,112,91,52,93,0,97,99,116,105,118,101,91,52, -93,0,103,114,111,117,112,91,52,93,0,103,114,111,117,112,95,97,99,116,105,118,101,91,52,93,0,116,114,97,110,115, -102,111,114,109,91,52,93,0,118,101,114,116,101,120,91,52,93,0,118,101,114,116,101,120,95,115,101,108,101,99,116,91, -52,93,0,101,100,103,101,91,52,93,0,101,100,103,101,95,115,101,108,101,99,116,91,52,93,0,101,100,103,101,95,115, -101,97,109,91,52,93,0,101,100,103,101,95,115,104,97,114,112,91,52,93,0,101,100,103,101,95,102,97,99,101,115,101, -108,91,52,93,0,102,97,99,101,91,52,93,0,102,97,99,101,95,115,101,108,101,99,116,91,52,93,0,102,97,99,101, -95,100,111,116,91,52,93,0,110,111,114,109,97,108,91,52,93,0,98,111,110,101,95,115,111,108,105,100,91,52,93,0, -98,111,110,101,95,112,111,115,101,91,52,93,0,115,116,114,105,112,91,52,93,0,115,116,114,105,112,95,115,101,108,101, -99,116,91,52,93,0,99,102,114,97,109,101,91,52,93,0,118,101,114,116,101,120,95,115,105,122,101,0,102,97,99,101, -100,111,116,95,115,105,122,101,0,98,112,97,100,91,50,93,0,115,121,110,116,97,120,108,91,52,93,0,115,121,110,116, -97,120,110,91,52,93,0,115,121,110,116,97,120,98,91,52,93,0,115,121,110,116,97,120,118,91,52,93,0,115,121,110, -116,97,120,99,91,52,93,0,109,111,118,105,101,91,52,93,0,105,109,97,103,101,91,52,93,0,115,99,101,110,101,91, -52,93,0,97,117,100,105,111,91,52,93,0,101,102,102,101,99,116,91,52,93,0,112,108,117,103,105,110,91,52,93,0, -116,114,97,110,115,105,116,105,111,110,91,52,93,0,109,101,116,97,91,52,93,0,101,100,105,116,109,101,115,104,95,97, -99,116,105,118,101,91,52,93,0,104,97,110,100,108,101,95,118,101,114,116,101,120,91,52,93,0,104,97,110,100,108,101, -95,118,101,114,116,101,120,95,115,101,108,101,99,116,91,52,93,0,104,97,110,100,108,101,95,118,101,114,116,101,120,95, -115,105,122,101,0,104,112,97,100,91,55,93,0,115,111,108,105,100,91,52,93,0,116,117,105,0,116,98,117,116,115,0, -116,118,51,100,0,116,102,105,108,101,0,116,105,112,111,0,116,105,110,102,111,0,116,115,110,100,0,116,97,99,116,0, -116,110,108,97,0,116,115,101,113,0,116,105,109,97,0,116,105,109,97,115,101,108,0,116,101,120,116,0,116,111,111,112, -115,0,116,116,105,109,101,0,116,110,111,100,101,0,116,97,114,109,91,50,48,93,0,98,112,97,100,91,52,93,0,98, -112,97,100,49,91,52,93,0,115,112,101,99,91,52,93,0,100,117,112,102,108,97,103,0,115,97,118,101,116,105,109,101, -0,116,101,109,112,100,105,114,91,49,54,48,93,0,102,111,110,116,100,105,114,91,49,54,48,93,0,114,101,110,100,101, -114,100,105,114,91,49,54,48,93,0,116,101,120,116,117,100,105,114,91,49,54,48,93,0,112,108,117,103,116,101,120,100, -105,114,91,49,54,48,93,0,112,108,117,103,115,101,113,100,105,114,91,49,54,48,93,0,112,121,116,104,111,110,100,105, -114,91,49,54,48,93,0,115,111,117,110,100,100,105,114,91,49,54,48,93,0,121,102,101,120,112,111,114,116,100,105,114, -91,49,54,48,93,0,118,101,114,115,105,111,110,115,0,118,114,109,108,102,108,97,103,0,103,97,109,101,102,108,97,103, -115,0,119,104,101,101,108,108,105,110,101,115,99,114,111,108,108,0,117,105,102,108,97,103,0,108,97,110,103,117,97,103, -101,0,117,115,101,114,112,114,101,102,0,118,105,101,119,122,111,111,109,0,99,111,110,115,111,108,101,95,98,117,102,102, -101,114,0,99,111,110,115,111,108,101,95,111,117,116,0,109,105,120,98,117,102,115,105,122,101,0,102,111,110,116,115,105, -122,101,0,101,110,99,111,100,105,110,103,0,116,114,97,110,115,111,112,116,115,0,109,101,110,117,116,104,114,101,115,104, -111,108,100,49,0,109,101,110,117,116,104,114,101,115,104,111,108,100,50,0,102,111,110,116,110,97,109,101,91,50,53,54, -93,0,116,104,101,109,101,115,0,117,110,100,111,115,116,101,112,115,0,117,110,100,111,109,101,109,111,114,121,0,103,112, -95,109,97,110,104,97,116,116,101,110,100,105,115,116,0,103,112,95,101,117,99,108,105,100,101,97,110,100,105,115,116,0, -103,112,95,101,114,97,115,101,114,0,103,112,95,115,101,116,116,105,110,103,115,0,116,98,95,108,101,102,116,109,111,117, -115,101,0,116,98,95,114,105,103,104,116,109,111,117,115,101,0,108,105,103,104,116,91,51,93,0,116,119,95,104,111,116, -115,112,111,116,0,116,119,95,102,108,97,103,0,116,119,95,104,97,110,100,108,101,115,105,122,101,0,116,119,95,115,105, -122,101,0,116,101,120,116,105,109,101,111,117,116,0,116,101,120,99,111,108,108,101,99,116,114,97,116,101,0,109,101,109, -99,97,99,104,101,108,105,109,105,116,0,112,114,101,102,101,116,99,104,102,114,97,109,101,115,0,102,114,97,109,101,115, -101,114,118,101,114,112,111,114,116,0,112,97,100,95,114,111,116,95,97,110,103,108,101,0,111,98,99,101,110,116,101,114, -95,100,105,97,0,114,118,105,115,105,122,101,0,114,118,105,98,114,105,103,104,116,0,114,101,99,101,110,116,95,102,105, -108,101,115,0,115,109,111,111,116,104,95,118,105,101,119,116,120,0,103,108,114,101,115,108,105,109,105,116,0,110,100,111, -102,95,112,97,110,0,110,100,111,102,95,114,111,116,97,116,101,0,99,117,114,115,115,105,122,101,0,112,97,100,91,56, -93,0,118,101,114,115,101,109,97,115,116,101,114,91,49,54,48,93,0,118,101,114,115,101,117,115,101,114,91,49,54,48, -93,0,103,108,97,108,112,104,97,99,108,105,112,0,97,117,116,111,107,101,121,95,102,108,97,103,0,99,111,98,97,95, -119,101,105,103,104,116,0,118,101,114,116,98,97,115,101,0,101,100,103,101,98,97,115,101,0,97,114,101,97,98,97,115, -101,0,42,115,99,101,110,101,0,101,110,100,120,0,101,110,100,121,0,115,105,122,101,120,0,115,105,122,101,121,0,115, -99,101,110,101,110,114,0,115,99,114,101,101,110,110,114,0,102,117,108,108,0,109,97,105,110,119,105,110,0,119,105,110, -97,107,116,0,104,97,110,100,108,101,114,91,56,93,0,42,110,101,119,118,0,118,101,99,0,42,118,49,0,42,118,50, -0,112,97,110,101,108,110,97,109,101,91,54,52,93,0,116,97,98,110,97,109,101,91,54,52,93,0,100,114,97,119,110, -97,109,101,91,54,52,93,0,111,102,115,120,0,111,102,115,121,0,99,111,110,116,114,111,108,0,115,110,97,112,0,111, -108,100,95,111,102,115,120,0,111,108,100,95,111,102,115,121,0,115,111,114,116,99,111,117,110,116,101,114,0,42,112,97, -110,101,108,116,97,98,0,42,118,51,0,42,118,52,0,42,102,117,108,108,0,119,105,110,109,97,116,91,52,93,91,52, -93,0,104,101,97,100,114,99,116,0,119,105,110,114,99,116,0,104,101,97,100,119,105,110,0,119,105,110,0,104,101,97, -100,101,114,116,121,112,101,0,98,117,116,115,112,97,99,101,116,121,112,101,0,119,105,110,120,0,119,105,110,121,0,104, -101,97,100,95,115,119,97,112,0,104,101,97,100,95,101,113,117,97,108,0,119,105,110,95,115,119,97,112,0,119,105,110, -95,101,113,117,97,108,0,104,101,97,100,98,117,116,108,101,110,0,104,101,97,100,98,117,116,111,102,115,0,99,117,114, -115,111,114,0,115,112,97,99,101,100,97,116,97,0,117,105,98,108,111,99,107,115,0,112,97,110,101,108,115,0,115,117, -98,118,115,116,114,91,52,93,0,115,117,98,118,101,114,115,105,111,110,0,112,97,100,115,0,109,105,110,118,101,114,115, -105,111,110,0,109,105,110,115,117,98,118,101,114,115,105,111,110,0,100,105,115,112,108,97,121,109,111,100,101,0,42,99, -117,114,115,99,114,101,101,110,0,42,99,117,114,115,99,101,110,101,0,102,105,108,101,102,108,97,103,115,0,103,108,111, -98,97,108,102,0,110,97,109,101,91,56,48,93,0,42,105,98,117,102,0,42,105,98,117,102,95,99,111,109,112,0,42, -115,101,49,0,42,115,101,50,0,42,115,101,51,0,110,114,0,98,111,116,116,111,109,0,114,105,103,104,116,0,120,111, -102,115,0,121,111,102,115,0,108,105,102,116,91,51,93,0,103,97,109,109,97,91,51,93,0,103,97,105,110,91,51,93, -0,115,97,116,117,114,97,116,105,111,110,0,42,103,117,105,0,100,105,114,91,49,54,48,93,0,100,111,110,101,0,115, -116,97,114,116,115,116,105,108,108,0,101,110,100,115,116,105,108,108,0,42,115,116,114,105,112,100,97,116,97,0,111,114, -120,0,111,114,121,0,42,99,114,111,112,0,42,116,114,97,110,115,102,111,114,109,0,42,99,111,108,111,114,95,98,97, -108,97,110,99,101,0,42,116,115,116,114,105,112,100,97,116,97,0,42,116,115,116,114,105,112,100,97,116,97,95,115,116, -97,114,116,115,116,105,108,108,0,42,116,115,116,114,105,112,100,97,116,97,95,101,110,100,115,116,105,108,108,0,42,105, -98,117,102,95,115,116,97,114,116,115,116,105,108,108,0,42,105,98,117,102,95,101,110,100,115,116,105,108,108,0,42,105, -110,115,116,97,110,99,101,95,112,114,105,118,97,116,101,95,100,97,116,97,0,42,42,99,117,114,114,101,110,116,95,112, -114,105,118,97,116,101,95,100,97,116,97,0,42,116,109,112,0,115,116,97,114,116,111,102,115,0,101,110,100,111,102,115, -0,109,97,99,104,105,110,101,0,115,116,97,114,116,100,105,115,112,0,101,110,100,100,105,115,112,0,109,117,108,0,104, -97,110,100,115,105,122,101,0,97,110,105,109,95,112,114,101,115,101,101,107,0,42,115,116,114,105,112,0,102,97,99,102, -48,0,102,97,99,102,49,0,42,115,101,113,49,0,42,115,101,113,50,0,42,115,101,113,51,0,115,101,113,98,97,115, -101,0,42,115,111,117,110,100,0,42,104,100,97,117,100,105,111,0,108,101,118,101,108,0,112,97,110,0,115,116,114,111, -98,101,0,42,101,102,102,101,99,116,100,97,116,97,0,97,110,105,109,95,115,116,97,114,116,111,102,115,0,97,110,105, -109,95,101,110,100,111,102,115,0,98,108,101,110,100,95,109,111,100,101,0,98,108,101,110,100,95,111,112,97,99,105,116, -121,0,42,111,108,100,98,97,115,101,112,0,42,112,97,114,115,101,113,0,42,115,101,113,98,97,115,101,112,0,109,101, -116,97,115,116,97,99,107,0,101,100,103,101,87,105,100,116,104,0,102,111,114,119,97,114,100,0,119,105,112,101,116,121, -112,101,0,102,77,105,110,105,0,102,67,108,97,109,112,0,102,66,111,111,115,116,0,100,68,105,115,116,0,100,81,117, -97,108,105,116,121,0,98,78,111,67,111,109,112,0,83,99,97,108,101,120,73,110,105,0,83,99,97,108,101,121,73,110, -105,0,83,99,97,108,101,120,70,105,110,0,83,99,97,108,101,121,70,105,110,0,120,73,110,105,0,120,70,105,110,0, -121,73,110,105,0,121,70,105,110,0,114,111,116,73,110,105,0,114,111,116,70,105,110,0,105,110,116,101,114,112,111,108, -97,116,105,111,110,0,42,102,114,97,109,101,77,97,112,0,103,108,111,98,97,108,83,112,101,101,100,0,108,97,115,116, -86,97,108,105,100,70,114,97,109,101,0,98,108,101,110,100,70,114,97,109,101,115,0,98,117,116,116,121,112,101,0,117, -115,101,114,106,105,116,0,115,116,97,0,116,111,116,112,97,114,116,0,110,111,114,109,102,97,99,0,111,98,102,97,99, -0,114,97,110,100,102,97,99,0,116,101,120,102,97,99,0,114,97,110,100,108,105,102,101,0,102,111,114,99,101,91,51, -93,0,118,101,99,116,115,105,122,101,0,109,97,120,108,101,110,0,100,101,102,118,101,99,91,51,93,0,109,117,108,116, -91,52,93,0,108,105,102,101,91,52,93,0,99,104,105,108,100,91,52,93,0,109,97,116,91,52,93,0,116,101,120,109, -97,112,0,99,117,114,109,117,108,116,0,115,116,97,116,105,99,115,116,101,112,0,111,109,97,116,0,116,105,109,101,116, -101,120,0,115,112,101,101,100,116,101,120,0,102,108,97,103,50,110,101,103,0,118,101,114,116,103,114,111,117,112,95,118, -0,118,103,114,111,117,112,110,97,109,101,91,51,50,93,0,118,103,114,111,117,112,110,97,109,101,95,118,91,51,50,93, -0,42,107,101,121,115,0,109,105,110,102,97,99,0,117,115,101,100,0,117,115,101,100,101,108,101,109,0,100,120,0,100, -121,0,108,105,110,107,0,111,116,121,112,101,0,111,108,100,0,42,112,111,105,110,0,42,111,108,100,112,111,105,110,0, -114,101,115,101,116,100,105,115,116,0,108,97,115,116,118,97,108,0,42,109,97,0,107,101,121,0,113,117,97,108,0,113, -117,97,108,50,0,116,97,114,103,101,116,78,97,109,101,91,51,50,93,0,116,111,103,103,108,101,78,97,109,101,91,51, -50,93,0,118,97,108,117,101,91,51,50,93,0,109,97,120,118,97,108,117,101,91,51,50,93,0,100,101,108,97,121,0, -100,117,114,97,116,105,111,110,0,109,97,116,101,114,105,97,108,78,97,109,101,91,51,50,93,0,100,97,109,112,116,105, -109,101,114,0,112,114,111,112,110,97,109,101,91,51,50,93,0,109,97,116,110,97,109,101,91,51,50,93,0,97,120,105, -115,102,108,97,103,0,42,102,114,111,109,79,98,106,101,99,116,0,115,117,98,106,101,99,116,91,51,50,93,0,98,111, -100,121,91,51,50,93,0,112,117,108,115,101,0,102,114,101,113,0,116,111,116,108,105,110,107,115,0,42,42,108,105,110, -107,115,0,116,97,112,0,106,111,121,105,110,100,101,120,0,97,120,105,115,95,115,105,110,103,108,101,0,97,120,105,115, -102,0,98,117,116,116,111,110,0,104,97,116,0,104,97,116,102,0,112,114,101,99,105,115,105,111,110,0,115,116,114,91, -49,50,56,93,0,109,111,100,117,108,101,91,54,52,93,0,42,109,121,110,101,119,0,105,110,112,117,116,115,0,116,111, -116,115,108,105,110,107,115,0,42,42,115,108,105,110,107,115,0,118,97,108,111,0,115,116,97,116,101,95,109,97,115,107, -0,42,97,99,116,0,102,114,97,109,101,80,114,111,112,91,51,50,93,0,98,108,101,110,100,105,110,0,112,114,105,111, -114,105,116,121,0,101,110,100,95,114,101,115,101,116,0,115,116,114,105,100,101,97,120,105,115,0,115,116,114,105,100,101, -108,101,110,103,116,104,0,115,110,100,110,114,0,112,97,100,49,91,50,93,0,109,97,107,101,99,111,112,121,0,99,111, -112,121,109,97,100,101,0,112,97,100,50,91,49,93,0,116,114,97,99,107,0,42,109,101,0,108,105,110,86,101,108,111, -99,105,116,121,91,51,93,0,97,110,103,86,101,108,111,99,105,116,121,91,51,93,0,108,111,99,97,108,102,108,97,103, -0,100,121,110,95,111,112,101,114,97,116,105,111,110,0,102,111,114,99,101,108,111,99,91,51,93,0,102,111,114,99,101, -114,111,116,91,51,93,0,108,105,110,101,97,114,118,101,108,111,99,105,116,121,91,51,93,0,97,110,103,117,108,97,114, -118,101,108,111,99,105,116,121,91,51,93,0,42,114,101,102,101,114,101,110,99,101,0,98,117,116,115,116,97,0,98,117, -116,101,110,100,0,109,105,110,0,109,97,120,0,118,105,115,105,102,97,99,0,114,111,116,100,97,109,112,0,109,105,110, -108,111,99,91,51,93,0,109,97,120,108,111,99,91,51,93,0,109,105,110,114,111,116,91,51,93,0,109,97,120,114,111, -116,91,51,93,0,109,97,116,112,114,111,112,91,51,50,93,0,100,105,115,116,114,105,98,117,116,105,111,110,0,105,110, -116,95,97,114,103,95,49,0,105,110,116,95,97,114,103,95,50,0,102,108,111,97,116,95,97,114,103,95,49,0,102,108, -111,97,116,95,97,114,103,95,50,0,116,111,80,114,111,112,78,97,109,101,91,51,50,93,0,42,116,111,79,98,106,101, -99,116,0,98,111,100,121,84,121,112,101,0,102,105,108,101,110,97,109,101,91,54,52,93,0,108,111,97,100,97,110,105, -110,97,109,101,91,54,52,93,0,105,110,116,95,97,114,103,0,102,108,111,97,116,95,97,114,103,0,103,111,0,97,99, -99,101,108,108,101,114,97,116,105,111,110,0,109,97,120,115,112,101,101,100,0,109,97,120,114,111,116,115,112,101,101,100, -0,109,97,120,116,105,108,116,115,112,101,101,100,0,116,105,108,116,100,97,109,112,0,115,112,101,101,100,100,97,109,112, -0,42,115,97,109,112,108,101,0,42,115,116,114,101,97,109,0,42,110,101,119,112,97,99,107,101,100,102,105,108,101,0, -42,115,110,100,95,115,111,117,110,100,0,112,97,110,110,105,110,103,0,97,116,116,101,110,117,97,116,105,111,110,0,112, -105,116,99,104,0,109,105,110,95,103,97,105,110,0,109,97,120,95,103,97,105,110,0,100,105,115,116,97,110,99,101,0, -115,116,114,101,97,109,108,101,110,0,99,104,97,110,110,101,108,115,0,104,105,103,104,112,114,105,111,0,112,97,100,91, -49,48,93,0,103,97,105,110,0,100,111,112,112,108,101,114,102,97,99,116,111,114,0,100,111,112,112,108,101,114,118,101, -108,111,99,105,116,121,0,110,117,109,115,111,117,110,100,115,98,108,101,110,100,101,114,0,110,117,109,115,111,117,110,100, -115,103,97,109,101,101,110,103,105,110,101,0,42,108,97,109,112,114,101,110,0,103,111,98,106,101,99,116,0,100,117,112, -108,105,95,111,102,115,91,51,93,0,99,104,105,108,100,98,97,115,101,0,114,111,108,108,0,104,101,97,100,91,51,93, -0,116,97,105,108,91,51,93,0,98,111,110,101,95,109,97,116,91,51,93,91,51,93,0,97,114,109,95,104,101,97,100, -91,51,93,0,97,114,109,95,116,97,105,108,91,51,93,0,97,114,109,95,109,97,116,91,52,93,91,52,93,0,120,119, -105,100,116,104,0,122,119,105,100,116,104,0,101,97,115,101,49,0,101,97,115,101,50,0,114,97,100,95,104,101,97,100, -0,114,97,100,95,116,97,105,108,0,98,111,110,101,98,97,115,101,0,99,104,97,105,110,98,97,115,101,0,112,97,116, -104,102,108,97,103,0,108,97,121,101,114,95,112,114,111,116,101,99,116,101,100,0,103,104,111,115,116,101,112,0,103,104, -111,115,116,115,105,122,101,0,103,104,111,115,116,116,121,112,101,0,112,97,116,104,115,105,122,101,0,103,104,111,115,116, -115,102,0,103,104,111,115,116,101,102,0,112,97,116,104,115,102,0,112,97,116,104,101,102,0,112,97,116,104,98,99,0, -112,97,116,104,97,99,0,99,111,110,115,116,102,108,97,103,0,105,107,102,108,97,103,0,115,101,108,101,99,116,102,108, -97,103,0,97,103,114,112,95,105,110,100,101,120,0,42,98,111,110,101,0,42,99,104,105,108,100,0,105,107,116,114,101, -101,0,42,98,95,98,111,110,101,95,109,97,116,115,0,42,100,117,97,108,95,113,117,97,116,0,42,98,95,98,111,110, -101,95,100,117,97,108,95,113,117,97,116,115,0,99,104,97,110,95,109,97,116,91,52,93,91,52,93,0,112,111,115,101, -95,109,97,116,91,52,93,91,52,93,0,112,111,115,101,95,104,101,97,100,91,51,93,0,112,111,115,101,95,116,97,105, -108,91,51,93,0,108,105,109,105,116,109,105,110,91,51,93,0,108,105,109,105,116,109,97,120,91,51,93,0,115,116,105, -102,102,110,101,115,115,91,51,93,0,105,107,115,116,114,101,116,99,104,0,42,99,117,115,116,111,109,0,99,104,97,110, -98,97,115,101,0,112,114,111,120,121,95,108,97,121,101,114,0,115,116,114,105,100,101,95,111,102,102,115,101,116,91,51, -93,0,99,121,99,108,105,99,95,111,102,102,115,101,116,91,51,93,0,97,103,114,111,117,112,115,0,97,99,116,105,118, -101,95,103,114,111,117,112,0,99,117,115,116,111,109,67,111,108,0,99,115,0,42,103,114,112,0,114,101,115,101,114,118, -101,100,49,0,103,114,111,117,112,115,0,97,99,116,105,118,101,95,109,97,114,107,101,114,0,97,99,116,110,114,0,97, -99,116,119,105,100,116,104,0,116,105,109,101,115,108,105,100,101,0,110,97,109,101,91,51,48,93,0,111,119,110,115,112, -97,99,101,0,116,97,114,115,112,97,99,101,0,101,110,102,111,114,99,101,0,104,101,97,100,116,97,105,108,0,42,116, -97,114,0,115,117,98,116,97,114,103,101,116,91,51,50,93,0,109,97,116,114,105,120,91,52,93,91,52,93,0,115,112, -97,99,101,0,42,112,114,111,112,0,116,97,114,110,117,109,0,116,97,114,103,101,116,115,0,105,116,101,114,97,116,105, -111,110,115,0,114,111,111,116,98,111,110,101,0,109,97,120,95,114,111,111,116,98,111,110,101,0,42,112,111,108,101,116, -97,114,0,112,111,108,101,115,117,98,116,97,114,103,101,116,91,51,50,93,0,112,111,108,101,97,110,103,108,101,0,111, -114,105,101,110,116,119,101,105,103,104,116,0,103,114,97,98,116,97,114,103,101,116,91,51,93,0,114,101,115,101,114,118, -101,100,50,0,109,105,110,109,97,120,102,108,97,103,0,115,116,117,99,107,0,99,97,99,104,101,91,51,93,0,108,111, -99,107,102,108,97,103,0,102,111,108,108,111,119,102,108,97,103,0,118,111,108,109,111,100,101,0,112,108,97,110,101,0, -111,114,103,108,101,110,103,116,104,0,98,117,108,103,101,0,112,105,118,88,0,112,105,118,89,0,112,105,118,90,0,97, -120,88,0,97,120,89,0,97,120,90,0,109,105,110,76,105,109,105,116,91,54,93,0,109,97,120,76,105,109,105,116,91, -54,93,0,101,120,116,114,97,70,122,0,105,110,118,109,97,116,91,52,93,91,52,93,0,102,114,111,109,0,116,111,0, -109,97,112,91,51,93,0,101,120,112,111,0,102,114,111,109,95,109,105,110,91,51,93,0,102,114,111,109,95,109,97,120, -91,51,93,0,116,111,95,109,105,110,91,51,93,0,116,111,95,109,97,120,91,51,93,0,122,109,105,110,0,122,109,97, -120,0,112,97,100,91,57,93,0,99,104,97,110,110,101,108,91,51,50,93,0,110,111,95,114,111,116,95,97,120,105,115, -0,115,116,114,105,100,101,95,97,120,105,115,0,99,117,114,109,111,100,0,97,99,116,115,116,97,114,116,0,97,99,116, -101,110,100,0,97,99,116,111,102,102,115,0,115,116,114,105,100,101,108,101,110,0,98,108,101,110,100,111,117,116,0,115, -116,114,105,100,101,99,104,97,110,110,101,108,91,51,50,93,0,111,102,102,115,95,98,111,110,101,91,51,50,93,0,104, -97,115,105,110,112,117,116,0,104,97,115,111,117,116,112,117,116,0,100,97,116,97,116,121,112,101,0,115,111,99,107,101, -116,116,121,112,101,0,42,110,101,119,95,115,111,99,107,0,110,115,0,108,105,109,105,116,0,115,116,97,99,107,95,105, -110,100,101,120,0,105,110,116,101,114,110,0,115,116,97,99,107,95,105,110,100,101,120,95,101,120,116,0,108,111,99,120, -0,108,111,99,121,0,111,119,110,95,105,110,100,101,120,0,116,111,95,105,110,100,101,120,0,42,116,111,115,111,99,107, -0,42,108,105,110,107,0,42,110,101,119,95,110,111,100,101,0,117,115,101,114,110,97,109,101,91,51,50,93,0,108,97, -115,116,121,0,111,117,116,112,117,116,115,0,42,115,116,111,114,97,103,101,0,109,105,110,105,119,105,100,116,104,0,99, -117,115,116,111,109,49,0,99,117,115,116,111,109,50,0,99,117,115,116,111,109,51,0,99,117,115,116,111,109,52,0,110, -101,101,100,95,101,120,101,99,0,101,120,101,99,0,116,111,116,114,0,98,117,116,114,0,112,114,118,114,0,42,116,121, -112,101,105,110,102,111,0,42,102,114,111,109,110,111,100,101,0,42,116,111,110,111,100,101,0,42,102,114,111,109,115,111, -99,107,0,110,111,100,101,115,0,108,105,110,107,115,0,42,115,116,97,99,107,0,42,116,104,114,101,97,100,115,116,97, -99,107,0,105,110,105,116,0,115,116,97,99,107,115,105,122,101,0,99,117,114,95,105,110,100,101,120,0,97,108,108,116, -121,112,101,115,0,42,111,119,110,116,121,112,101,0,42,115,101,108,105,110,0,42,115,101,108,111,117,116,0,40,42,116, -105,109,101,99,117,114,115,111,114,41,40,41,0,40,42,115,116,97,116,115,95,100,114,97,119,41,40,41,0,40,42,116, -101,115,116,95,98,114,101,97,107,41,40,41,0,99,121,99,108,105,99,0,109,111,118,105,101,0,115,97,109,112,108,101, -115,0,109,105,110,115,112,101,101,100,0,112,101,114,99,101,110,116,120,0,112,101,114,99,101,110,116,121,0,98,111,107, -101,104,0,99,117,114,118,101,100,0,105,109,97,103,101,95,105,110,95,119,105,100,116,104,0,105,109,97,103,101,95,105, -110,95,104,101,105,103,104,116,0,99,101,110,116,101,114,95,120,0,99,101,110,116,101,114,95,121,0,115,112,105,110,0, -105,116,101,114,0,119,114,97,112,0,115,105,103,109,97,95,99,111,108,111,114,0,115,105,103,109,97,95,115,112,97,99, -101,0,104,117,101,0,115,97,116,0,116,49,0,116,50,0,116,51,0,102,115,116,114,101,110,103,116,104,0,102,97,108, -112,104,97,0,107,101,121,91,52,93,0,120,49,0,120,50,0,121,49,0,121,50,0,99,111,108,110,97,109,101,91,51, -50,93,0,98,107,116,121,112,101,0,114,111,116,97,116,105,111,110,0,112,114,101,118,105,101,119,0,103,97,109,99,111, -0,110,111,95,122,98,117,102,0,102,115,116,111,112,0,109,97,120,98,108,117,114,0,98,116,104,114,101,115,104,0,42, -100,105,99,116,0,42,110,111,100,101,0,97,110,103,108,101,95,111,102,115,0,99,111,108,109,111,100,0,109,105,120,0, -116,104,114,101,115,104,111,108,100,0,102,97,100,101,0,109,0,99,0,106,105,116,0,112,114,111,106,0,102,105,116,0, -115,104,111,114,116,121,0,109,105,110,116,97,98,108,101,0,109,97,120,116,97,98,108,101,0,101,120,116,95,105,110,91, -50,93,0,101,120,116,95,111,117,116,91,50,93,0,42,99,117,114,118,101,0,42,116,97,98,108,101,0,42,112,114,101, -109,117,108,116,97,98,108,101,0,99,117,114,114,0,99,108,105,112,114,0,99,109,91,52,93,0,98,108,97,99,107,91, -51,93,0,119,104,105,116,101,91,51,93,0,98,119,109,117,108,91,51,93,0,115,97,109,112,108,101,91,51,93,0,111, -102,102,115,101,116,91,50,93,0,105,110,110,101,114,114,97,100,105,117,115,0,114,97,116,101,0,114,103,98,91,51,93, -0,99,108,111,110,101,0,97,99,116,105,118,101,95,114,110,100,0,97,99,116,105,118,101,95,99,108,111,110,101,0,97, -99,116,105,118,101,95,109,97,115,107,0,42,108,97,121,101,114,115,0,116,111,116,108,97,121,101,114,0,109,97,120,108, -97,121,101,114,0,116,111,116,115,105,122,101,0,42,112,111,111,108,0,101,100,105,116,102,108,97,103,0,118,101,108,91, -51,93,0,114,111,116,91,52,93,0,97,118,101,91,51,93,0,110,117,109,0,112,97,114,101,110,116,0,112,97,91,52, -93,0,119,91,52,93,0,102,117,118,91,52,93,0,102,111,102,102,115,101,116,0,114,97,110,100,91,51,93,0,42,115, -116,105,99,107,95,111,98,0,112,114,101,118,95,115,116,97,116,101,0,42,104,97,105,114,0,105,95,114,111,116,91,52, -93,0,114,95,114,111,116,91,52,93,0,114,95,97,118,101,91,51,93,0,114,95,118,101,91,51,93,0,100,105,101,116, -105,109,101,0,98,97,110,107,0,115,105,122,101,109,117,108,0,110,117,109,95,100,109,99,97,99,104,101,0,98,112,105, -0,97,108,105,118,101,0,108,111,111,112,0,100,105,115,116,114,0,112,104,121,115,116,121,112,101,0,114,111,116,109,111, -100,101,0,97,118,101,109,111,100,101,0,114,101,97,99,116,101,118,101,110,116,0,100,114,97,119,0,100,114,97,119,95, -97,115,0,100,114,97,119,95,115,105,122,101,0,99,104,105,108,100,116,121,112,101,0,100,114,97,119,95,115,116,101,112, -0,114,101,110,95,115,116,101,112,0,104,97,105,114,95,115,116,101,112,0,107,101,121,115,95,115,116,101,112,0,97,100, -97,112,116,95,97,110,103,108,101,0,97,100,97,112,116,95,112,105,120,0,114,111,116,102,114,111,109,0,105,110,116,101, -103,114,97,116,111,114,0,110,98,101,116,119,101,101,110,0,98,111,105,100,110,101,105,103,104,98,111,117,114,115,0,98, -98,95,97,108,105,103,110,0,98,98,95,117,118,95,115,112,108,105,116,0,98,98,95,97,110,105,109,0,98,98,95,115, -112,108,105,116,95,111,102,102,115,101,116,0,98,98,95,116,105,108,116,0,98,98,95,114,97,110,100,95,116,105,108,116, -0,98,98,95,111,102,102,115,101,116,91,50,93,0,115,105,109,112,108,105,102,121,95,102,108,97,103,0,115,105,109,112, -108,105,102,121,95,114,101,102,115,105,122,101,0,115,105,109,112,108,105,102,121,95,114,97,116,101,0,115,105,109,112,108, -105,102,121,95,116,114,97,110,115,105,116,105,111,110,0,115,105,109,112,108,105,102,121,95,118,105,101,119,112,111,114,116, -0,116,105,109,101,116,119,101,97,107,0,106,105,116,102,97,99,0,107,101,121,101,100,95,116,105,109,101,0,101,102,102, -95,104,97,105,114,0,103,114,105,100,95,114,101,115,0,112,97,114,116,102,97,99,0,116,97,110,102,97,99,0,116,97, -110,112,104,97,115,101,0,114,101,97,99,116,102,97,99,0,97,118,101,102,97,99,0,112,104,97,115,101,102,97,99,0, -114,97,110,100,114,111,116,102,97,99,0,114,97,110,100,112,104,97,115,101,102,97,99,0,114,97,110,100,115,105,122,101, -0,114,101,97,99,116,115,104,97,112,101,0,97,99,99,91,51,93,0,100,114,97,103,102,97,99,0,98,114,111,119,110, -102,97,99,0,100,97,109,112,102,97,99,0,97,98,115,108,101,110,103,116,104,0,114,97,110,100,108,101,110,103,116,104, -0,99,104,105,108,100,95,110,98,114,0,114,101,110,95,99,104,105,108,100,95,110,98,114,0,112,97,114,101,110,116,115, -0,99,104,105,108,100,115,105,122,101,0,99,104,105,108,100,114,97,110,100,115,105,122,101,0,99,104,105,108,100,114,97, -100,0,99,104,105,108,100,102,108,97,116,0,99,104,105,108,100,115,112,114,101,97,100,0,99,108,117,109,112,102,97,99, -0,99,108,117,109,112,112,111,119,0,114,111,117,103,104,49,0,114,111,117,103,104,49,95,115,105,122,101,0,114,111,117, -103,104,50,0,114,111,117,103,104,50,95,115,105,122,101,0,114,111,117,103,104,50,95,116,104,114,101,115,0,114,111,117, -103,104,95,101,110,100,0,114,111,117,103,104,95,101,110,100,95,115,104,97,112,101,0,98,114,97,110,99,104,95,116,104, -114,101,115,0,100,114,97,119,95,108,105,110,101,91,50,93,0,109,97,120,95,108,97,116,95,97,99,99,0,109,97,120, -95,116,97,110,95,97,99,99,0,97,118,101,114,97,103,101,95,118,101,108,0,98,97,110,107,105,110,103,0,109,97,120, -95,98,97,110,107,0,103,114,111,117,110,100,122,0,98,111,105,100,102,97,99,91,56,93,0,98,111,105,100,114,117,108, -101,91,56,93,0,42,101,102,102,95,103,114,111,117,112,0,42,100,117,112,95,111,98,0,42,98,98,95,111,98,0,42, -112,100,50,0,42,112,97,114,116,0,42,101,100,105,116,0,42,42,112,97,116,104,99,97,99,104,101,0,42,42,99,104, -105,108,100,99,97,99,104,101,0,112,97,116,104,99,97,99,104,101,98,117,102,115,0,99,104,105,108,100,99,97,99,104, -101,98,117,102,115,0,42,116,97,114,103,101,116,95,111,98,0,42,107,101,121,101,100,95,111,98,0,42,108,97,116,116, -105,99,101,0,101,102,102,101,99,116,111,114,115,0,114,101,97,99,116,101,118,101,110,116,115,0,116,111,116,99,104,105, -108,100,0,116,111,116,99,97,99,104,101,100,0,116,111,116,99,104,105,108,100,99,97,99,104,101,0,116,97,114,103,101, -116,95,112,115,121,115,0,107,101,121,101,100,95,112,115,121,115,0,116,111,116,107,101,121,101,100,0,98,97,107,101,115, -112,97,99,101,0,98,98,95,117,118,110,97,109,101,91,51,93,91,51,50,93,0,118,103,114,111,117,112,91,49,50,93, -0,118,103,95,110,101,103,0,114,116,51,0,42,114,101,110,100,101,114,100,97,116,97,0,42,99,97,99,104,101,0,67, -100,105,115,0,67,118,105,0,91,51,93,0,115,116,114,117,99,116,117,114,97,108,0,98,101,110,100,105,110,103,0,109, -97,120,95,98,101,110,100,0,109,97,120,95,115,116,114,117,99,116,0,109,97,120,95,115,104,101,97,114,0,97,118,103, -95,115,112,114,105,110,103,95,108,101,110,0,116,105,109,101,115,99,97,108,101,0,101,102,102,95,102,111,114,99,101,95, -115,99,97,108,101,0,101,102,102,95,119,105,110,100,95,115,99,97,108,101,0,115,105,109,95,116,105,109,101,95,111,108, -100,0,115,116,101,112,115,80,101,114,70,114,97,109,101,0,112,114,101,114,111,108,108,0,109,97,120,115,112,114,105,110, -103,108,101,110,0,115,111,108,118,101,114,95,116,121,112,101,0,118,103,114,111,117,112,95,98,101,110,100,0,118,103,114, -111,117,112,95,109,97,115,115,0,118,103,114,111,117,112,95,115,116,114,117,99,116,0,112,114,101,115,101,116,115,0,42, -99,111,108,108,105,115,105,111,110,95,108,105,115,116,0,101,112,115,105,108,111,110,0,115,101,108,102,95,102,114,105,99, -116,105,111,110,0,115,101,108,102,101,112,115,105,108,111,110,0,115,101,108,102,95,108,111,111,112,95,99,111,117,110,116, -0,108,111,111,112,95,99,111,117,110,116,0,112,114,101,115,115,117,114,101,0,42,112,111,105,110,116,115,0,116,111,116, -112,111,105,110,116,115,0,116,104,105,99,107,110,101,115,115,0,115,116,114,111,107,101,115,0,102,114,97,109,101,110,117, -109,0,42,97,99,116,102,114,97,109,101,0,103,115,116,101,112,0,105,110,102,111,91,49,50,56,93,0,115,98,117,102, -102,101,114,95,115,105,122,101,0,115,98,117,102,102,101,114,95,115,102,108,97,103,0,42,115,98,117,102,102,101,114,0, -0,0,0,84,89,80,69,100,1,0,0,99,104,97,114,0,117,99,104,97,114,0,115,104,111,114,116,0,117,115,104,111, -114,116,0,105,110,116,0,108,111,110,103,0,117,108,111,110,103,0,102,108,111,97,116,0,100,111,117,98,108,101,0,118, -111,105,100,0,76,105,110,107,0,76,105,110,107,68,97,116,97,0,76,105,115,116,66,97,115,101,0,118,101,99,50,115, -0,118,101,99,50,105,0,118,101,99,50,102,0,118,101,99,50,100,0,118,101,99,51,105,0,118,101,99,51,102,0,118, -101,99,51,100,0,118,101,99,52,105,0,118,101,99,52,102,0,118,101,99,52,100,0,114,99,116,105,0,114,99,116,102, -0,73,68,80,114,111,112,101,114,116,121,68,97,116,97,0,73,68,80,114,111,112,101,114,116,121,0,73,68,0,76,105, -98,114,97,114,121,0,70,105,108,101,68,97,116,97,0,80,114,101,118,105,101,119,73,109,97,103,101,0,73,112,111,68, -114,105,118,101,114,0,79,98,106,101,99,116,0,73,112,111,67,117,114,118,101,0,66,80,111,105,110,116,0,66,101,122, -84,114,105,112,108,101,0,73,112,111,0,75,101,121,66,108,111,99,107,0,75,101,121,0,83,99,114,105,112,116,76,105, -110,107,0,84,101,120,116,76,105,110,101,0,84,101,120,116,77,97,114,107,101,114,0,84,101,120,116,0,80,97,99,107, -101,100,70,105,108,101,0,67,97,109,101,114,97,0,73,109,97,103,101,85,115,101,114,0,73,109,97,103,101,0,71,80, -85,84,101,120,116,117,114,101,0,97,110,105,109,0,82,101,110,100,101,114,82,101,115,117,108,116,0,77,84,101,120,0, -84,101,120,0,80,108,117,103,105,110,84,101,120,0,67,66,68,97,116,97,0,67,111,108,111,114,66,97,110,100,0,69, -110,118,77,97,112,0,73,109,66,117,102,0,98,78,111,100,101,84,114,101,101,0,84,101,120,77,97,112,112,105,110,103, -0,76,97,109,112,0,67,117,114,118,101,77,97,112,112,105,110,103,0,87,97,118,101,0,77,97,116,101,114,105,97,108, -0,71,114,111,117,112,0,86,70,111,110,116,0,86,70,111,110,116,68,97,116,97,0,77,101,116,97,69,108,101,109,0, -66,111,117,110,100,66,111,120,0,77,101,116,97,66,97,108,108,0,78,117,114,98,0,67,104,97,114,73,110,102,111,0, -84,101,120,116,66,111,120,0,67,117,114,118,101,0,80,97,116,104,0,77,101,115,104,0,77,70,97,99,101,0,77,84, -70,97,99,101,0,84,70,97,99,101,0,77,86,101,114,116,0,77,69,100,103,101,0,77,68,101,102,111,114,109,86,101, -114,116,0,77,67,111,108,0,77,83,116,105,99,107,121,0,77,83,101,108,101,99,116,0,67,117,115,116,111,109,68,97, -116,97,0,77,117,108,116,105,114,101,115,0,80,97,114,116,105,97,108,86,105,115,105,98,105,108,105,116,121,0,77,68, -101,102,111,114,109,87,101,105,103,104,116,0,77,84,101,120,80,111,108,121,0,77,76,111,111,112,85,86,0,77,76,111, -111,112,67,111,108,0,77,70,108,111,97,116,80,114,111,112,101,114,116,121,0,77,73,110,116,80,114,111,112,101,114,116, -121,0,77,83,116,114,105,110,103,80,114,111,112,101,114,116,121,0,79,114,105,103,83,112,97,99,101,70,97,99,101,0, -77,117,108,116,105,114,101,115,67,111,108,0,77,117,108,116,105,114,101,115,67,111,108,70,97,99,101,0,77,117,108,116, -105,114,101,115,70,97,99,101,0,77,117,108,116,105,114,101,115,69,100,103,101,0,77,117,108,116,105,114,101,115,76,101, -118,101,108,0,77,117,108,116,105,114,101,115,77,97,112,78,111,100,101,0,77,111,100,105,102,105,101,114,68,97,116,97, -0,83,117,98,115,117,114,102,77,111,100,105,102,105,101,114,68,97,116,97,0,76,97,116,116,105,99,101,77,111,100,105, -102,105,101,114,68,97,116,97,0,67,117,114,118,101,77,111,100,105,102,105,101,114,68,97,116,97,0,66,117,105,108,100, -77,111,100,105,102,105,101,114,68,97,116,97,0,77,97,115,107,77,111,100,105,102,105,101,114,68,97,116,97,0,65,114, -114,97,121,77,111,100,105,102,105,101,114,68,97,116,97,0,77,105,114,114,111,114,77,111,100,105,102,105,101,114,68,97, -116,97,0,69,100,103,101,83,112,108,105,116,77,111,100,105,102,105,101,114,68,97,116,97,0,66,101,118,101,108,77,111, -100,105,102,105,101,114,68,97,116,97,0,66,77,101,115,104,77,111,100,105,102,105,101,114,68,97,116,97,0,68,105,115, -112,108,97,99,101,77,111,100,105,102,105,101,114,68,97,116,97,0,85,86,80,114,111,106,101,99,116,77,111,100,105,102, -105,101,114,68,97,116,97,0,68,101,99,105,109,97,116,101,77,111,100,105,102,105,101,114,68,97,116,97,0,83,109,111, -111,116,104,77,111,100,105,102,105,101,114,68,97,116,97,0,67,97,115,116,77,111,100,105,102,105,101,114,68,97,116,97, -0,87,97,118,101,77,111,100,105,102,105,101,114,68,97,116,97,0,65,114,109,97,116,117,114,101,77,111,100,105,102,105, -101,114,68,97,116,97,0,72,111,111,107,77,111,100,105,102,105,101,114,68,97,116,97,0,83,111,102,116,98,111,100,121, -77,111,100,105,102,105,101,114,68,97,116,97,0,67,108,111,116,104,77,111,100,105,102,105,101,114,68,97,116,97,0,67, -108,111,116,104,0,67,108,111,116,104,83,105,109,83,101,116,116,105,110,103,115,0,67,108,111,116,104,67,111,108,108,83, -101,116,116,105,110,103,115,0,80,111,105,110,116,67,97,99,104,101,0,67,111,108,108,105,115,105,111,110,77,111,100,105, -102,105,101,114,68,97,116,97,0,66,86,72,84,114,101,101,0,83,117,114,102,97,99,101,77,111,100,105,102,105,101,114, -68,97,116,97,0,68,101,114,105,118,101,100,77,101,115,104,0,66,86,72,84,114,101,101,70,114,111,109,77,101,115,104, -0,66,111,111,108,101,97,110,77,111,100,105,102,105,101,114,68,97,116,97,0,77,68,101,102,73,110,102,108,117,101,110, -99,101,0,77,68,101,102,67,101,108,108,0,77,101,115,104,68,101,102,111,114,109,77,111,100,105,102,105,101,114,68,97, -116,97,0,80,97,114,116,105,99,108,101,83,121,115,116,101,109,77,111,100,105,102,105,101,114,68,97,116,97,0,80,97, -114,116,105,99,108,101,83,121,115,116,101,109,0,80,97,114,116,105,99,108,101,73,110,115,116,97,110,99,101,77,111,100, -105,102,105,101,114,68,97,116,97,0,69,120,112,108,111,100,101,77,111,100,105,102,105,101,114,68,97,116,97,0,70,108, -117,105,100,115,105,109,77,111,100,105,102,105,101,114,68,97,116,97,0,70,108,117,105,100,115,105,109,83,101,116,116,105, -110,103,115,0,83,104,114,105,110,107,119,114,97,112,77,111,100,105,102,105,101,114,68,97,116,97,0,83,105,109,112,108, -101,68,101,102,111,114,109,77,111,100,105,102,105,101,114,68,97,116,97,0,76,97,116,116,105,99,101,0,98,68,101,102, -111,114,109,71,114,111,117,112,0,98,65,99,116,105,111,110,0,98,80,111,115,101,0,66,117,108,108,101,116,83,111,102, -116,66,111,100,121,0,80,97,114,116,68,101,102,108,101,99,116,0,83,111,102,116,66,111,100,121,0,79,98,72,111,111, -107,0,82,78,71,0,83,66,86,101,114,116,101,120,0,66,111,100,121,80,111,105,110,116,0,66,111,100,121,83,112,114, -105,110,103,0,83,66,83,99,114,97,116,99,104,0,87,111,114,108,100,0,82,97,100,105,111,0,66,97,115,101,0,65, -118,105,67,111,100,101,99,68,97,116,97,0,81,117,105,99,107,116,105,109,101,67,111,100,101,99,68,97,116,97,0,70, -70,77,112,101,103,67,111,100,101,99,68,97,116,97,0,65,117,100,105,111,68,97,116,97,0,83,99,101,110,101,82,101, -110,100,101,114,76,97,121,101,114,0,82,101,110,100,101,114,68,97,116,97,0,82,101,110,100,101,114,80,114,111,102,105, -108,101,0,71,97,109,101,70,114,97,109,105,110,103,0,84,105,109,101,77,97,114,107,101,114,0,73,109,97,103,101,80, -97,105,110,116,83,101,116,116,105,110,103,115,0,66,114,117,115,104,0,80,97,114,116,105,99,108,101,66,114,117,115,104, -68,97,116,97,0,80,97,114,116,105,99,108,101,69,100,105,116,83,101,116,116,105,110,103,115,0,84,114,97,110,115,102, -111,114,109,79,114,105,101,110,116,97,116,105,111,110,0,84,111,111,108,83,101,116,116,105,110,103,115,0,66,114,117,115, -104,68,97,116,97,0,83,99,117,108,112,116,68,97,116,97,0,83,99,117,108,112,116,83,101,115,115,105,111,110,0,83, -99,101,110,101,0,68,97,103,70,111,114,101,115,116,0,66,71,112,105,99,0,86,105,101,119,51,68,0,83,112,97,99, -101,76,105,110,107,0,83,99,114,65,114,101,97,0,82,101,110,100,101,114,73,110,102,111,0,82,101,116,111,112,111,86, -105,101,119,68,97,116,97,0,86,105,101,119,68,101,112,116,104,115,0,98,71,80,100,97,116,97,0,86,105,101,119,50, -68,0,83,112,97,99,101,73,110,102,111,0,83,112,97,99,101,73,112,111,0,83,112,97,99,101,66,117,116,115,0,83, -112,97,99,101,83,101,113,0,83,112,97,99,101,70,105,108,101,0,100,105,114,101,110,116,114,121,0,66,108,101,110,100, -72,97,110,100,108,101,0,83,112,97,99,101,79,111,112,115,0,84,114,101,101,83,116,111,114,101,0,84,114,101,101,83, -116,111,114,101,69,108,101,109,0,83,112,97,99,101,73,109,97,103,101,0,83,112,97,99,101,78,108,97,0,83,112,97, -99,101,84,101,120,116,0,83,99,114,105,112,116,0,83,112,97,99,101,83,99,114,105,112,116,0,83,112,97,99,101,84, -105,109,101,0,83,112,97,99,101,78,111,100,101,0,83,112,97,99,101,73,109,97,83,101,108,0,70,105,108,101,76,105, -115,116,0,84,104,101,109,101,85,73,0,84,104,101,109,101,83,112,97,99,101,0,84,104,101,109,101,87,105,114,101,67, -111,108,111,114,0,98,84,104,101,109,101,0,83,111,108,105,100,76,105,103,104,116,0,85,115,101,114,68,101,102,0,98, -83,99,114,101,101,110,0,83,99,114,86,101,114,116,0,83,99,114,69,100,103,101,0,80,97,110,101,108,0,70,105,108, -101,71,108,111,98,97,108,0,83,116,114,105,112,69,108,101,109,0,84,83,116,114,105,112,69,108,101,109,0,83,116,114, -105,112,67,114,111,112,0,83,116,114,105,112,84,114,97,110,115,102,111,114,109,0,83,116,114,105,112,67,111,108,111,114, -66,97,108,97,110,99,101,0,83,116,114,105,112,67,111,108,111,114,66,97,108,97,110,99,101,71,85,73,72,101,108,112, -101,114,0,83,116,114,105,112,80,114,111,120,121,0,83,116,114,105,112,0,80,108,117,103,105,110,83,101,113,0,83,101, -113,117,101,110,99,101,0,98,83,111,117,110,100,0,104,100,97,117,100,105,111,0,77,101,116,97,83,116,97,99,107,0, -69,100,105,116,105,110,103,0,87,105,112,101,86,97,114,115,0,71,108,111,119,86,97,114,115,0,84,114,97,110,115,102, -111,114,109,86,97,114,115,0,83,111,108,105,100,67,111,108,111,114,86,97,114,115,0,83,112,101,101,100,67,111,110,116, -114,111,108,86,97,114,115,0,69,102,102,101,99,116,0,66,117,105,108,100,69,102,102,0,80,97,114,116,69,102,102,0, -80,97,114,116,105,99,108,101,0,87,97,118,101,69,102,102,0,79,111,112,115,0,98,80,114,111,112,101,114,116,121,0, -98,78,101,97,114,83,101,110,115,111,114,0,98,77,111,117,115,101,83,101,110,115,111,114,0,98,84,111,117,99,104,83, -101,110,115,111,114,0,98,75,101,121,98,111,97,114,100,83,101,110,115,111,114,0,98,80,114,111,112,101,114,116,121,83, -101,110,115,111,114,0,98,65,99,116,117,97,116,111,114,83,101,110,115,111,114,0,98,68,101,108,97,121,83,101,110,115, -111,114,0,98,67,111,108,108,105,115,105,111,110,83,101,110,115,111,114,0,98,82,97,100,97,114,83,101,110,115,111,114, -0,98,82,97,110,100,111,109,83,101,110,115,111,114,0,98,82,97,121,83,101,110,115,111,114,0,98,77,101,115,115,97, -103,101,83,101,110,115,111,114,0,98,83,101,110,115,111,114,0,98,67,111,110,116,114,111,108,108,101,114,0,98,74,111, -121,115,116,105,99,107,83,101,110,115,111,114,0,98,69,120,112,114,101,115,115,105,111,110,67,111,110,116,0,98,80,121, -116,104,111,110,67,111,110,116,0,98,65,99,116,117,97,116,111,114,0,98,65,100,100,79,98,106,101,99,116,65,99,116, -117,97,116,111,114,0,98,65,99,116,105,111,110,65,99,116,117,97,116,111,114,0,98,83,111,117,110,100,65,99,116,117, -97,116,111,114,0,98,67,68,65,99,116,117,97,116,111,114,0,98,69,100,105,116,79,98,106,101,99,116,65,99,116,117, -97,116,111,114,0,98,83,99,101,110,101,65,99,116,117,97,116,111,114,0,98,80,114,111,112,101,114,116,121,65,99,116, -117,97,116,111,114,0,98,79,98,106,101,99,116,65,99,116,117,97,116,111,114,0,98,73,112,111,65,99,116,117,97,116, -111,114,0,98,67,97,109,101,114,97,65,99,116,117,97,116,111,114,0,98,67,111,110,115,116,114,97,105,110,116,65,99, -116,117,97,116,111,114,0,98,71,114,111,117,112,65,99,116,117,97,116,111,114,0,98,82,97,110,100,111,109,65,99,116, -117,97,116,111,114,0,98,77,101,115,115,97,103,101,65,99,116,117,97,116,111,114,0,98,71,97,109,101,65,99,116,117, -97,116,111,114,0,98,86,105,115,105,98,105,108,105,116,121,65,99,116,117,97,116,111,114,0,98,84,119,111,68,70,105, -108,116,101,114,65,99,116,117,97,116,111,114,0,98,80,97,114,101,110,116,65,99,116,117,97,116,111,114,0,98,83,116, -97,116,101,65,99,116,117,97,116,111,114,0,70,114,101,101,67,97,109,101,114,97,0,98,83,97,109,112,108,101,0,98, -83,111,117,110,100,76,105,115,116,101,110,101,114,0,83,112,97,99,101,83,111,117,110,100,0,71,114,111,117,112,79,98, -106,101,99,116,0,66,111,110,101,0,98,65,114,109,97,116,117,114,101,0,98,80,111,115,101,67,104,97,110,110,101,108, -0,98,65,99,116,105,111,110,71,114,111,117,112,0,98,65,99,116,105,111,110,67,104,97,110,110,101,108,0,83,112,97, -99,101,65,99,116,105,111,110,0,98,67,111,110,115,116,114,97,105,110,116,67,104,97,110,110,101,108,0,98,67,111,110, -115,116,114,97,105,110,116,0,98,67,111,110,115,116,114,97,105,110,116,84,97,114,103,101,116,0,98,80,121,116,104,111, -110,67,111,110,115,116,114,97,105,110,116,0,98,75,105,110,101,109,97,116,105,99,67,111,110,115,116,114,97,105,110,116, -0,98,84,114,97,99,107,84,111,67,111,110,115,116,114,97,105,110,116,0,98,82,111,116,97,116,101,76,105,107,101,67, -111,110,115,116,114,97,105,110,116,0,98,76,111,99,97,116,101,76,105,107,101,67,111,110,115,116,114,97,105,110,116,0, -98,77,105,110,77,97,120,67,111,110,115,116,114,97,105,110,116,0,98,83,105,122,101,76,105,107,101,67,111,110,115,116, -114,97,105,110,116,0,98,65,99,116,105,111,110,67,111,110,115,116,114,97,105,110,116,0,98,76,111,99,107,84,114,97, -99,107,67,111,110,115,116,114,97,105,110,116,0,98,70,111,108,108,111,119,80,97,116,104,67,111,110,115,116,114,97,105, -110,116,0,98,83,116,114,101,116,99,104,84,111,67,111,110,115,116,114,97,105,110,116,0,98,82,105,103,105,100,66,111, -100,121,74,111,105,110,116,67,111,110,115,116,114,97,105,110,116,0,98,67,108,97,109,112,84,111,67,111,110,115,116,114, -97,105,110,116,0,98,67,104,105,108,100,79,102,67,111,110,115,116,114,97,105,110,116,0,98,84,114,97,110,115,102,111, -114,109,67,111,110,115,116,114,97,105,110,116,0,98,76,111,99,76,105,109,105,116,67,111,110,115,116,114,97,105,110,116, -0,98,82,111,116,76,105,109,105,116,67,111,110,115,116,114,97,105,110,116,0,98,83,105,122,101,76,105,109,105,116,67, -111,110,115,116,114,97,105,110,116,0,98,68,105,115,116,76,105,109,105,116,67,111,110,115,116,114,97,105,110,116,0,98, -83,104,114,105,110,107,119,114,97,112,67,111,110,115,116,114,97,105,110,116,0,98,65,99,116,105,111,110,77,111,100,105, -102,105,101,114,0,98,65,99,116,105,111,110,83,116,114,105,112,0,98,78,111,100,101,83,116,97,99,107,0,98,78,111, -100,101,83,111,99,107,101,116,0,98,78,111,100,101,76,105,110,107,0,98,78,111,100,101,0,98,78,111,100,101,80,114, -101,118,105,101,119,0,98,78,111,100,101,84,121,112,101,0,78,111,100,101,73,109,97,103,101,65,110,105,109,0,78,111, -100,101,66,108,117,114,68,97,116,97,0,78,111,100,101,68,66,108,117,114,68,97,116,97,0,78,111,100,101,66,105,108, -97,116,101,114,97,108,66,108,117,114,68,97,116,97,0,78,111,100,101,72,117,101,83,97,116,0,78,111,100,101,73,109, -97,103,101,70,105,108,101,0,78,111,100,101,67,104,114,111,109,97,0,78,111,100,101,84,119,111,88,89,115,0,78,111, -100,101,84,119,111,70,108,111,97,116,115,0,78,111,100,101,71,101,111,109,101,116,114,121,0,78,111,100,101,86,101,114, -116,101,120,67,111,108,0,78,111,100,101,68,101,102,111,99,117,115,0,78,111,100,101,83,99,114,105,112,116,68,105,99, -116,0,78,111,100,101,71,108,97,114,101,0,78,111,100,101,84,111,110,101,109,97,112,0,78,111,100,101,76,101,110,115, -68,105,115,116,0,84,101,120,78,111,100,101,79,117,116,112,117,116,0,67,117,114,118,101,77,97,112,80,111,105,110,116, -0,67,117,114,118,101,77,97,112,0,66,114,117,115,104,67,108,111,110,101,0,67,117,115,116,111,109,68,97,116,97,76, -97,121,101,114,0,72,97,105,114,75,101,121,0,80,97,114,116,105,99,108,101,75,101,121,0,67,104,105,108,100,80,97, -114,116,105,99,108,101,0,80,97,114,116,105,99,108,101,68,97,116,97,0,80,97,114,116,105,99,108,101,83,101,116,116, -105,110,103,115,0,80,97,114,116,105,99,108,101,69,100,105,116,0,80,97,114,116,105,99,108,101,67,97,99,104,101,75, -101,121,0,76,105,110,107,78,111,100,101,0,98,71,80,68,115,112,111,105,110,116,0,98,71,80,68,115,116,114,111,107, -101,0,98,71,80,68,102,114,97,109,101,0,98,71,80,68,108,97,121,101,114,0,0,84,76,69,78,1,0,1,0,2, -0,2,0,4,0,4,0,4,0,4,0,8,0,0,0,8,0,12,0,8,0,4,0,8,0,8,0,16,0,12,0,12, -0,24,0,16,0,16,0,32,0,16,0,16,0,20,0,76,0,52,0,40,2,0,0,32,0,-116,0,80,3,92,0,36, -0,56,0,84,0,112,0,120,0,16,0,24,0,40,0,120,0,20,0,-124,0,32,0,-128,1,0,0,0,0,0,0,-120, -0,16,1,84,1,24,0,8,3,-88,0,0,0,124,0,-124,0,-128,1,8,1,56,0,108,2,76,0,68,1,0,0,108, -0,104,0,-120,0,56,0,8,0,16,0,56,1,0,0,24,1,20,0,44,0,60,0,24,0,12,0,12,0,4,0,8, -0,8,0,24,0,76,0,32,0,8,0,12,0,8,0,8,0,4,0,4,0,0,1,32,0,16,0,64,0,24,0,12, -0,56,0,0,0,52,0,68,0,88,0,96,0,68,0,96,0,116,0,64,0,60,0,108,0,60,0,-108,0,-104,0,60, -0,92,0,104,0,-72,0,100,0,-76,0,52,0,68,0,0,0,-124,0,28,0,20,0,100,0,0,0,60,0,0,0,0, -0,64,0,8,0,8,0,-40,0,76,0,64,1,64,0,64,0,60,0,-92,1,108,0,104,0,116,0,40,0,84,0,56, -0,120,0,-128,0,-8,0,-48,0,0,0,16,0,0,0,0,0,0,0,108,1,40,0,28,0,-80,0,-112,0,52,0,16, -0,72,0,-48,3,56,0,16,0,80,0,12,0,-72,0,8,0,72,0,80,0,-24,0,8,0,-88,0,0,0,124,5,0, -0,60,0,28,3,36,0,-52,0,0,0,0,0,0,0,20,0,-120,0,36,0,88,1,-36,0,-56,0,-56,1,0,0,0, -0,8,1,12,0,12,0,8,1,-76,0,-128,0,80,2,36,0,-92,0,-36,0,-124,2,0,0,-104,0,-48,0,16,0,56, -14,56,0,32,12,120,0,20,0,24,0,-28,0,32,0,80,0,28,0,16,0,8,0,60,0,0,0,-4,0,-16,0,-88, -1,-60,0,28,1,0,0,16,0,28,0,12,0,24,0,48,0,16,0,28,0,16,0,24,0,56,1,0,0,56,0,44, -0,64,0,48,0,8,0,44,0,72,0,104,0,40,0,8,0,72,0,44,0,40,0,108,0,68,0,76,0,80,0,60, -0,-128,0,76,0,60,0,12,0,92,0,28,0,20,0,80,0,16,0,76,0,108,0,84,0,28,0,96,0,60,0,56, -0,108,0,-116,0,4,0,20,0,12,0,8,0,40,0,0,0,68,0,-80,0,24,0,4,1,116,0,-104,1,72,0,64, -0,-64,0,44,0,64,0,116,0,60,0,104,0,52,0,44,0,44,0,68,0,44,0,64,0,44,0,20,0,52,0,96, -0,12,0,108,0,92,0,28,0,28,0,28,0,52,0,20,0,60,0,-116,0,36,0,120,0,24,0,-52,0,0,0,0, -0,16,0,40,0,28,0,12,0,12,0,16,1,40,0,8,0,8,0,64,0,32,0,24,0,8,0,24,0,32,0,8, -0,32,0,12,0,44,0,20,0,68,0,24,0,56,0,72,0,-4,0,-32,1,0,0,0,0,0,0,16,0,20,0,24, -0,-84,0,83,84,82,67,57,1,0,0,10,0,2,0,10,0,0,0,10,0,1,0,11,0,3,0,11,0,0,0,11, -0,1,0,9,0,2,0,12,0,2,0,9,0,3,0,9,0,4,0,13,0,2,0,2,0,5,0,2,0,6,0,14, -0,2,0,4,0,5,0,4,0,6,0,15,0,2,0,7,0,5,0,7,0,6,0,16,0,2,0,8,0,5,0,8, -0,6,0,17,0,3,0,4,0,5,0,4,0,6,0,4,0,7,0,18,0,3,0,7,0,5,0,7,0,6,0,7, -0,7,0,19,0,3,0,8,0,5,0,8,0,6,0,8,0,7,0,20,0,4,0,4,0,5,0,4,0,6,0,4, -0,7,0,4,0,8,0,21,0,4,0,7,0,5,0,7,0,6,0,7,0,7,0,7,0,8,0,22,0,4,0,8, -0,5,0,8,0,6,0,8,0,7,0,8,0,8,0,23,0,4,0,4,0,9,0,4,0,10,0,4,0,11,0,4, -0,12,0,24,0,4,0,7,0,9,0,7,0,10,0,7,0,11,0,7,0,12,0,25,0,4,0,9,0,13,0,12, -0,14,0,4,0,15,0,4,0,16,0,26,0,10,0,26,0,0,0,26,0,1,0,0,0,17,0,0,0,18,0,0, -0,19,0,2,0,20,0,4,0,21,0,25,0,22,0,4,0,23,0,4,0,24,0,27,0,9,0,9,0,0,0,9, -0,1,0,27,0,25,0,28,0,26,0,0,0,27,0,2,0,28,0,2,0,20,0,4,0,29,0,26,0,30,0,28, -0,8,0,27,0,31,0,27,0,32,0,29,0,33,0,0,0,34,0,0,0,35,0,4,0,36,0,4,0,37,0,28, -0,38,0,30,0,6,0,4,0,39,0,4,0,40,0,2,0,41,0,2,0,42,0,2,0,43,0,4,0,44,0,31, -0,6,0,32,0,45,0,2,0,46,0,2,0,47,0,2,0,18,0,2,0,20,0,0,0,48,0,33,0,21,0,33, -0,0,0,33,0,1,0,34,0,49,0,35,0,50,0,24,0,51,0,24,0,52,0,2,0,46,0,2,0,47,0,2, -0,53,0,2,0,54,0,2,0,55,0,2,0,56,0,2,0,20,0,2,0,57,0,7,0,11,0,7,0,12,0,4, -0,58,0,7,0,59,0,7,0,60,0,7,0,61,0,31,0,62,0,36,0,7,0,27,0,31,0,12,0,63,0,24, -0,64,0,2,0,46,0,2,0,65,0,2,0,66,0,2,0,37,0,37,0,16,0,37,0,0,0,37,0,1,0,7, -0,67,0,7,0,61,0,2,0,18,0,2,0,47,0,2,0,68,0,2,0,20,0,4,0,69,0,4,0,70,0,9, -0,2,0,7,0,71,0,0,0,17,0,0,0,72,0,7,0,73,0,7,0,74,0,38,0,12,0,27,0,31,0,37, -0,75,0,0,0,76,0,4,0,77,0,7,0,61,0,12,0,78,0,36,0,79,0,27,0,80,0,2,0,18,0,2, -0,81,0,2,0,82,0,2,0,20,0,39,0,5,0,27,0,83,0,2,0,84,0,2,0,85,0,2,0,86,0,4, -0,37,0,40,0,6,0,40,0,0,0,40,0,1,0,0,0,87,0,0,0,88,0,4,0,23,0,4,0,89,0,41, -0,10,0,41,0,0,0,41,0,1,0,4,0,90,0,4,0,91,0,4,0,92,0,4,0,43,0,4,0,14,0,4, -0,93,0,0,0,94,0,0,0,95,0,42,0,15,0,27,0,31,0,0,0,96,0,4,0,93,0,4,0,97,0,12, -0,98,0,40,0,99,0,40,0,100,0,4,0,101,0,4,0,102,0,12,0,103,0,0,0,104,0,4,0,105,0,4, -0,106,0,9,0,107,0,8,0,108,0,43,0,5,0,4,0,109,0,4,0,110,0,4,0,93,0,4,0,37,0,9, -0,2,0,44,0,20,0,27,0,31,0,2,0,18,0,2,0,20,0,7,0,111,0,7,0,112,0,7,0,113,0,7, -0,114,0,7,0,115,0,7,0,116,0,7,0,117,0,7,0,118,0,7,0,119,0,7,0,120,0,7,0,121,0,2, -0,122,0,2,0,123,0,7,0,124,0,36,0,79,0,39,0,125,0,32,0,126,0,45,0,12,0,4,0,127,0,4, -0,-128,0,4,0,-127,0,4,0,-126,0,2,0,-125,0,2,0,-124,0,2,0,20,0,2,0,-123,0,2,0,-122,0,2, -0,-121,0,2,0,-120,0,2,0,-119,0,46,0,32,0,27,0,31,0,0,0,34,0,12,0,-118,0,47,0,-117,0,48, -0,-116,0,49,0,-115,0,2,0,-123,0,2,0,20,0,2,0,-114,0,2,0,18,0,2,0,37,0,2,0,43,0,4, -0,-113,0,2,0,-112,0,2,0,-111,0,2,0,-110,0,2,0,-109,0,2,0,-108,0,2,0,-107,0,4,0,-106,0,4, -0,-105,0,43,0,-104,0,30,0,-103,0,7,0,-102,0,4,0,-101,0,2,0,-100,0,2,0,-99,0,2,0,-98,0,2, -0,-97,0,7,0,-96,0,7,0,-95,0,9,0,-94,0,50,0,31,0,2,0,-93,0,2,0,-92,0,2,0,-91,0,2, -0,-90,0,32,0,-89,0,51,0,-88,0,0,0,-87,0,0,0,-86,0,0,0,-85,0,0,0,-84,0,0,0,-83,0,7, -0,-82,0,7,0,-81,0,2,0,-80,0,2,0,-79,0,2,0,-78,0,2,0,-77,0,2,0,-76,0,2,0,-75,0,2, -0,-74,0,7,0,-73,0,7,0,-72,0,7,0,-71,0,7,0,-70,0,7,0,-69,0,7,0,57,0,7,0,-68,0,7, -0,-67,0,7,0,-66,0,7,0,-65,0,7,0,-64,0,52,0,15,0,0,0,-63,0,9,0,-62,0,0,0,-61,0,0, -0,-60,0,4,0,-59,0,4,0,-58,0,9,0,-57,0,7,0,-56,0,7,0,-55,0,7,0,-54,0,4,0,-53,0,9, -0,-52,0,9,0,-51,0,4,0,-50,0,4,0,37,0,53,0,6,0,7,0,-73,0,7,0,-72,0,7,0,-71,0,7, -0,-49,0,7,0,67,0,4,0,64,0,54,0,5,0,2,0,20,0,2,0,36,0,2,0,64,0,2,0,-48,0,53, -0,-54,0,55,0,17,0,32,0,-89,0,46,0,-47,0,56,0,-46,0,7,0,-45,0,7,0,-44,0,2,0,18,0,2, -0,-43,0,7,0,113,0,7,0,114,0,7,0,-42,0,4,0,-41,0,2,0,-40,0,2,0,-39,0,4,0,-123,0,4, -0,-113,0,2,0,-38,0,2,0,-37,0,51,0,56,0,27,0,31,0,7,0,-36,0,7,0,-35,0,7,0,-34,0,7, -0,-33,0,7,0,-32,0,7,0,-31,0,7,0,-30,0,7,0,-29,0,7,0,-28,0,7,0,-27,0,7,0,-26,0,7, -0,-25,0,7,0,-24,0,7,0,-23,0,7,0,-22,0,7,0,-21,0,7,0,-20,0,7,0,-19,0,7,0,-18,0,7, -0,-17,0,2,0,-16,0,2,0,-15,0,2,0,-14,0,2,0,-13,0,2,0,-12,0,2,0,-11,0,2,0,-10,0,2, -0,20,0,2,0,18,0,2,0,-43,0,7,0,-9,0,7,0,-8,0,7,0,-7,0,7,0,-6,0,2,0,-5,0,2, -0,-4,0,2,0,-3,0,2,0,-125,0,4,0,23,0,4,0,-128,0,4,0,-127,0,4,0,-126,0,7,0,-2,0,7, -0,-1,0,7,0,-67,0,45,0,0,1,57,0,1,1,36,0,79,0,46,0,-47,0,52,0,2,1,54,0,3,1,55, -0,4,1,30,0,-103,0,0,0,5,1,0,0,6,1,58,0,8,0,7,0,7,1,7,0,8,1,7,0,-81,0,4, -0,20,0,7,0,9,1,7,0,10,1,7,0,11,1,32,0,45,0,59,0,80,0,27,0,31,0,2,0,18,0,2, -0,12,1,4,0,13,1,2,0,-79,0,2,0,14,1,7,0,-73,0,7,0,-72,0,7,0,-71,0,7,0,-70,0,7, -0,15,1,7,0,16,1,7,0,17,1,7,0,18,1,7,0,19,1,7,0,20,1,7,0,21,1,7,0,22,1,7, -0,23,1,7,0,24,1,7,0,25,1,60,0,26,1,2,0,27,1,2,0,70,0,7,0,113,0,7,0,114,0,7, -0,28,1,7,0,29,1,7,0,30,1,2,0,31,1,2,0,32,1,2,0,33,1,2,0,34,1,0,0,35,1,0, -0,36,1,2,0,37,1,2,0,38,1,2,0,39,1,2,0,40,1,2,0,41,1,7,0,42,1,7,0,43,1,7, -0,44,1,7,0,45,1,2,0,46,1,2,0,43,0,2,0,47,1,2,0,48,1,2,0,49,1,2,0,50,1,7, -0,51,1,7,0,52,1,7,0,53,1,7,0,54,1,7,0,55,1,7,0,56,1,7,0,57,1,7,0,58,1,7, -0,59,1,7,0,60,1,7,0,61,1,7,0,62,1,2,0,63,1,2,0,64,1,4,0,65,1,4,0,66,1,2, -0,67,1,2,0,68,1,2,0,69,1,2,0,70,1,7,0,71,1,7,0,72,1,7,0,73,1,7,0,74,1,2, -0,75,1,2,0,76,1,50,0,77,1,36,0,79,0,30,0,-103,0,39,0,125,0,61,0,2,0,27,0,31,0,36, -0,79,0,62,0,-127,0,27,0,31,0,2,0,-79,0,2,0,20,0,7,0,-73,0,7,0,-72,0,7,0,-71,0,7, -0,78,1,7,0,79,1,7,0,80,1,7,0,81,1,7,0,82,1,7,0,83,1,7,0,84,1,7,0,85,1,7, -0,86,1,7,0,87,1,7,0,88,1,7,0,89,1,7,0,90,1,7,0,91,1,7,0,92,1,7,0,93,1,7, -0,94,1,7,0,95,1,7,0,96,1,7,0,97,1,7,0,98,1,7,0,99,1,7,0,100,1,7,0,101,1,7, -0,102,1,7,0,103,1,7,0,104,1,2,0,105,1,2,0,106,1,2,0,107,1,0,0,108,1,0,0,109,1,7, -0,110,1,7,0,111,1,2,0,112,1,2,0,113,1,7,0,114,1,7,0,115,1,7,0,116,1,7,0,117,1,2, -0,118,1,2,0,119,1,4,0,13,1,4,0,120,1,2,0,121,1,2,0,122,1,2,0,123,1,2,0,124,1,7, -0,125,1,7,0,126,1,7,0,127,1,7,0,-128,1,7,0,-127,1,7,0,-126,1,7,0,-125,1,7,0,-124,1,7, -0,-123,1,7,0,-122,1,0,0,-121,1,7,0,-120,1,7,0,-119,1,7,0,-118,1,4,0,-117,1,0,0,-116,1,0, -0,47,1,0,0,-115,1,0,0,5,1,2,0,-114,1,2,0,-113,1,2,0,64,1,2,0,-112,1,2,0,-111,1,2, -0,-110,1,7,0,-109,1,7,0,-108,1,7,0,-107,1,7,0,-106,1,7,0,-105,1,2,0,-93,0,2,0,-92,0,54, -0,-104,1,54,0,-103,1,0,0,-102,1,0,0,-101,1,0,0,-100,1,0,0,-99,1,2,0,-98,1,2,0,12,1,7, -0,-97,1,7,0,-96,1,50,0,77,1,57,0,1,1,36,0,79,0,63,0,-95,1,30,0,-103,0,7,0,-94,1,7, -0,-93,1,7,0,-92,1,7,0,-91,1,7,0,-90,1,2,0,-89,1,2,0,70,0,7,0,-88,1,7,0,-87,1,7, -0,-86,1,7,0,-85,1,7,0,-84,1,7,0,-83,1,7,0,-82,1,7,0,-81,1,7,0,-80,1,2,0,-79,1,2, -0,-78,1,7,0,-77,1,7,0,-76,1,7,0,-75,1,7,0,-74,1,7,0,-73,1,4,0,-72,1,4,0,-71,1,4, -0,-70,1,39,0,125,0,12,0,-69,1,64,0,6,0,27,0,31,0,0,0,-68,1,7,0,-67,1,7,0,37,0,65, -0,2,0,43,0,-104,0,66,0,26,0,66,0,0,0,66,0,1,0,67,0,-66,1,4,0,-65,1,4,0,-64,1,4, -0,-63,1,4,0,-62,1,4,0,-61,1,4,0,-60,1,2,0,18,0,2,0,20,0,2,0,-59,1,2,0,-58,1,7, -0,5,0,7,0,6,0,7,0,7,0,7,0,-57,1,7,0,-56,1,7,0,-55,1,7,0,-54,1,7,0,-53,1,7, -0,-52,1,7,0,-51,1,7,0,23,0,7,0,-50,1,7,0,-49,1,68,0,15,0,27,0,31,0,67,0,-66,1,12, -0,-48,1,12,0,-47,1,36,0,79,0,62,0,-46,1,2,0,20,0,2,0,-45,1,4,0,-80,0,7,0,7,1,7, -0,-81,0,7,0,8,1,7,0,-44,1,7,0,-43,1,7,0,-42,1,35,0,10,0,7,0,-41,1,7,0,-40,1,7, -0,-39,1,7,0,-38,1,2,0,-37,1,2,0,-36,1,0,0,-35,1,0,0,-34,1,0,0,-33,1,0,0,-32,1,34, -0,7,0,7,0,-31,1,7,0,-40,1,7,0,-39,1,2,0,-35,1,2,0,-32,1,7,0,-38,1,7,0,37,0,69, -0,21,0,69,0,0,0,69,0,1,0,2,0,18,0,2,0,-30,1,2,0,-32,1,2,0,20,0,2,0,-29,1,2, -0,-28,1,2,0,-27,1,2,0,-26,1,2,0,-25,1,2,0,-24,1,2,0,-23,1,2,0,-22,1,7,0,-21,1,7, -0,-20,1,34,0,49,0,35,0,50,0,2,0,-19,1,2,0,-18,1,4,0,-17,1,70,0,5,0,2,0,-16,1,2, -0,-30,1,0,0,20,0,0,0,37,0,2,0,70,0,71,0,4,0,7,0,5,0,7,0,6,0,7,0,8,0,7, -0,-15,1,72,0,57,0,27,0,31,0,67,0,-66,1,12,0,-14,1,12,0,-47,1,32,0,-13,1,32,0,-12,1,32, -0,-11,1,36,0,79,0,73,0,-10,1,38,0,-9,1,62,0,-46,1,12,0,-8,1,7,0,7,1,7,0,-81,0,7, -0,8,1,4,0,-80,0,2,0,-7,1,2,0,-45,1,2,0,20,0,2,0,-6,1,7,0,-5,1,7,0,-4,1,7, -0,-3,1,2,0,-27,1,2,0,-26,1,2,0,-2,1,2,0,-1,1,4,0,70,0,2,0,23,0,2,0,98,0,2, -0,67,0,2,0,0,2,7,0,1,2,7,0,2,2,7,0,3,2,7,0,4,2,7,0,5,2,7,0,6,2,7, -0,7,2,7,0,8,2,7,0,9,2,7,0,10,2,0,0,11,2,0,0,12,2,64,0,13,2,64,0,14,2,64, -0,15,2,64,0,16,2,4,0,17,2,4,0,18,2,4,0,19,2,4,0,37,0,71,0,20,2,4,0,21,2,4, -0,22,2,70,0,23,2,70,0,24,2,74,0,39,0,27,0,31,0,67,0,-66,1,12,0,25,2,36,0,79,0,38, -0,-9,1,62,0,-46,1,75,0,26,2,76,0,27,2,77,0,28,2,78,0,29,2,79,0,30,2,80,0,31,2,81, -0,32,2,82,0,33,2,74,0,34,2,83,0,35,2,84,0,36,2,84,0,37,2,84,0,38,2,4,0,54,0,4, -0,39,2,4,0,40,2,4,0,41,2,4,0,42,2,4,0,-80,0,7,0,7,1,7,0,-81,0,7,0,8,1,7, -0,43,2,7,0,37,0,2,0,44,2,2,0,20,0,2,0,45,2,2,0,46,2,2,0,-45,1,2,0,47,2,85, -0,48,2,86,0,49,2,9,0,-94,0,77,0,8,0,9,0,50,2,7,0,51,2,4,0,52,2,0,0,20,0,0, -0,53,2,2,0,13,1,2,0,54,2,2,0,55,2,75,0,8,0,4,0,56,2,4,0,57,2,4,0,58,2,4, -0,59,2,0,0,37,0,0,0,-30,1,0,0,60,2,0,0,20,0,79,0,5,0,4,0,56,2,4,0,57,2,0, -0,61,2,0,0,62,2,2,0,20,0,87,0,2,0,4,0,63,2,7,0,-39,1,80,0,3,0,87,0,64,2,4, -0,65,2,4,0,20,0,78,0,6,0,7,0,66,2,2,0,67,2,0,0,20,0,0,0,-30,1,0,0,62,2,0, -0,68,2,81,0,4,0,0,0,-49,0,0,0,-73,0,0,0,-72,0,0,0,-71,0,88,0,6,0,46,0,50,2,0, -0,20,0,0,0,53,2,2,0,13,1,2,0,54,2,2,0,55,2,89,0,1,0,7,0,69,2,90,0,5,0,0, -0,-49,0,0,0,-73,0,0,0,-72,0,0,0,-71,0,4,0,37,0,82,0,1,0,7,0,70,2,83,0,2,0,4, -0,71,2,4,0,18,0,76,0,7,0,7,0,51,2,46,0,50,2,0,0,20,0,0,0,53,2,2,0,13,1,2, -0,54,2,2,0,55,2,91,0,1,0,7,0,72,2,92,0,1,0,4,0,73,2,93,0,1,0,0,0,74,2,94, -0,1,0,7,0,51,2,95,0,4,0,7,0,-49,0,7,0,-73,0,7,0,-72,0,7,0,-71,0,96,0,1,0,95, -0,52,2,97,0,5,0,4,0,75,2,4,0,76,2,0,0,20,0,0,0,-30,1,0,0,-74,0,98,0,2,0,4, -0,77,2,4,0,76,2,99,0,14,0,99,0,0,0,99,0,1,0,97,0,78,2,96,0,79,2,98,0,80,2,0, -0,81,2,12,0,82,2,12,0,83,2,100,0,84,2,4,0,54,0,4,0,40,2,4,0,39,2,4,0,37,0,78, -0,85,2,85,0,14,0,12,0,86,2,78,0,85,2,0,0,87,2,0,0,88,2,0,0,89,2,0,0,90,2,0, -0,91,2,0,0,92,2,0,0,93,2,0,0,20,0,84,0,36,2,84,0,38,2,2,0,94,2,0,0,95,2,86, -0,8,0,4,0,96,2,4,0,97,2,75,0,98,2,79,0,99,2,4,0,40,2,4,0,39,2,4,0,54,0,4, -0,37,0,101,0,6,0,101,0,0,0,101,0,1,0,4,0,18,0,4,0,13,1,0,0,17,0,0,0,100,2,102, -0,7,0,101,0,101,2,2,0,102,2,2,0,86,2,2,0,103,2,2,0,93,0,9,0,104,2,9,0,105,2,103, -0,3,0,101,0,101,2,32,0,-89,0,0,0,17,0,104,0,5,0,101,0,101,2,32,0,-89,0,0,0,17,0,2, -0,106,2,0,0,107,2,105,0,5,0,101,0,101,2,7,0,91,0,7,0,108,2,4,0,109,2,4,0,110,2,106, -0,5,0,101,0,101,2,32,0,111,2,0,0,72,0,4,0,13,1,4,0,20,0,107,0,13,0,101,0,101,2,32, -0,112,2,32,0,113,2,32,0,114,2,32,0,115,2,7,0,116,2,7,0,117,2,7,0,108,2,7,0,118,2,4, -0,119,2,4,0,120,2,4,0,93,0,4,0,121,2,108,0,5,0,101,0,101,2,2,0,122,2,2,0,20,0,7, -0,123,2,32,0,124,2,109,0,3,0,101,0,101,2,7,0,125,2,4,0,93,0,110,0,10,0,101,0,101,2,7, -0,126,2,4,0,127,2,4,0,37,0,2,0,93,0,2,0,-128,2,2,0,-127,2,2,0,-126,2,7,0,-125,2,0, -0,-124,2,111,0,3,0,101,0,101,2,7,0,37,0,4,0,18,0,112,0,11,0,101,0,101,2,51,0,-123,2,7, -0,-122,2,4,0,-121,2,0,0,-124,2,7,0,-120,2,4,0,-119,2,32,0,-118,2,0,0,-117,2,4,0,-116,2,4, -0,37,0,113,0,10,0,101,0,101,2,32,0,-115,2,46,0,-114,2,4,0,93,0,4,0,-113,2,7,0,-112,2,7, -0,-111,2,0,0,-117,2,4,0,-116,2,4,0,37,0,114,0,3,0,101,0,101,2,7,0,-110,2,4,0,-109,2,115, -0,5,0,101,0,101,2,7,0,-108,2,0,0,-124,2,2,0,20,0,2,0,-107,2,116,0,8,0,101,0,101,2,32, -0,-89,0,7,0,-108,2,7,0,-38,1,7,0,109,0,0,0,-124,2,2,0,20,0,2,0,18,0,117,0,21,0,101, -0,101,2,32,0,-106,2,0,0,-124,2,51,0,-123,2,32,0,-118,2,2,0,20,0,2,0,37,0,7,0,-105,2,7, -0,-104,2,7,0,-103,2,7,0,-5,1,7,0,-102,2,7,0,-101,2,7,0,-100,2,7,0,-99,2,4,0,-119,2,4, -0,-116,2,0,0,-117,2,7,0,-98,2,7,0,-97,2,7,0,43,0,118,0,7,0,101,0,101,2,2,0,-96,2,2, -0,-95,2,4,0,70,0,32,0,-89,0,7,0,-94,2,0,0,-124,2,119,0,9,0,101,0,101,2,32,0,-89,0,7, -0,-93,2,7,0,-92,2,7,0,-99,2,4,0,-91,2,4,0,-90,2,7,0,-89,2,0,0,17,0,120,0,1,0,101, -0,101,2,121,0,5,0,101,0,101,2,122,0,-88,2,123,0,-87,2,124,0,-86,2,125,0,-85,2,126,0,14,0,101, -0,101,2,78,0,-84,2,78,0,-83,2,78,0,-82,2,78,0,-81,2,78,0,-80,2,78,0,-79,2,75,0,-78,2,4, -0,-77,2,4,0,-76,2,2,0,-75,2,2,0,37,0,7,0,-74,2,127,0,-73,2,-128,0,3,0,101,0,101,2,-127, -0,-72,2,-126,0,-73,2,-125,0,4,0,101,0,101,2,32,0,-89,0,4,0,-71,2,4,0,37,0,-124,0,2,0,4, -0,-70,2,7,0,-39,1,-123,0,2,0,4,0,-127,0,4,0,-69,2,-122,0,20,0,101,0,101,2,32,0,-89,0,0, -0,-124,2,2,0,-68,2,2,0,-67,2,2,0,20,0,2,0,37,0,7,0,-66,2,7,0,-65,2,4,0,54,0,4, -0,-64,2,-123,0,-63,2,-124,0,-62,2,4,0,-61,2,4,0,-60,2,4,0,-59,2,4,0,-69,2,7,0,-58,2,7, -0,-57,2,7,0,-56,2,-121,0,8,0,101,0,101,2,-120,0,-55,2,-127,0,-72,2,4,0,-54,2,4,0,-53,2,4, -0,-52,2,2,0,20,0,2,0,57,0,-119,0,5,0,101,0,101,2,32,0,45,0,2,0,-51,2,2,0,20,0,2, -0,-50,2,-118,0,5,0,101,0,101,2,4,0,-49,2,2,0,20,0,2,0,-48,2,7,0,-47,2,-117,0,3,0,101, -0,101,2,-116,0,-46,2,125,0,-85,2,-115,0,10,0,101,0,101,2,32,0,-45,2,32,0,-44,2,0,0,-43,2,7, -0,-42,2,2,0,-41,2,2,0,-40,2,0,0,-39,2,0,0,-38,2,0,0,107,2,-114,0,9,0,101,0,101,2,32, -0,-37,2,0,0,-43,2,7,0,-36,2,7,0,-35,2,0,0,13,1,0,0,122,2,0,0,-34,2,0,0,37,0,-113, -0,24,0,27,0,31,0,2,0,-29,1,2,0,-28,1,2,0,-33,2,2,0,20,0,2,0,-32,2,2,0,-31,2,2, -0,-30,2,2,0,70,0,0,0,-29,2,0,0,-28,2,0,0,-27,2,0,0,18,0,4,0,37,0,7,0,-26,2,7, -0,-25,2,7,0,-24,2,7,0,-23,2,7,0,-22,2,7,0,-21,2,34,0,-20,2,36,0,79,0,38,0,-9,1,80, -0,31,2,-112,0,3,0,-112,0,0,0,-112,0,1,0,0,0,17,0,67,0,3,0,7,0,-19,2,4,0,20,0,4, -0,37,0,32,0,111,0,27,0,31,0,2,0,18,0,2,0,-18,2,4,0,-17,2,4,0,-16,2,4,0,-15,2,0, -0,-14,2,32,0,38,0,32,0,-13,2,32,0,-12,2,32,0,-11,2,32,0,-10,2,36,0,79,0,73,0,-10,1,67, -0,-66,1,-111,0,-9,2,-111,0,-8,2,-110,0,-7,2,9,0,2,0,12,0,-6,2,12,0,25,2,12,0,-47,1,12, -0,-5,2,12,0,-4,2,62,0,-46,1,7,0,7,1,7,0,-3,2,7,0,-2,2,7,0,-81,0,7,0,-1,2,7, -0,8,1,7,0,0,3,7,0,1,3,7,0,-93,2,7,0,2,3,7,0,-45,0,4,0,3,3,2,0,20,0,2, -0,4,3,2,0,5,3,2,0,6,3,2,0,7,3,2,0,8,3,2,0,9,3,2,0,10,3,2,0,11,3,2, -0,12,3,2,0,13,3,2,0,14,3,4,0,15,3,4,0,16,3,4,0,17,3,4,0,18,3,7,0,19,3,7, -0,20,3,7,0,21,3,7,0,22,3,7,0,23,3,7,0,24,3,7,0,25,3,7,0,26,3,7,0,27,3,7, -0,28,3,7,0,29,3,7,0,30,3,0,0,31,3,0,0,32,3,0,0,-45,1,0,0,33,3,0,0,34,3,0, -0,35,3,7,0,36,3,7,0,37,3,39,0,125,0,12,0,38,3,12,0,39,3,12,0,40,3,12,0,41,3,7, -0,42,3,2,0,71,2,2,0,43,3,7,0,52,2,4,0,44,3,4,0,45,3,-109,0,46,3,2,0,47,3,2, -0,-38,0,7,0,48,3,12,0,49,3,12,0,50,3,12,0,51,3,12,0,52,3,-108,0,53,3,-107,0,54,3,63, -0,55,3,2,0,56,3,2,0,57,3,2,0,58,3,2,0,59,3,7,0,44,2,2,0,60,3,2,0,61,3,-116, -0,62,3,-127,0,63,3,-127,0,64,3,4,0,65,3,4,0,66,3,4,0,67,3,4,0,70,0,9,0,-94,0,12, -0,68,3,-106,0,14,0,-106,0,0,0,-106,0,1,0,32,0,38,0,7,0,-93,2,7,0,9,1,7,0,-92,2,7, -0,-99,2,0,0,17,0,4,0,-91,2,4,0,-90,2,4,0,69,3,2,0,18,0,2,0,70,3,7,0,-89,2,-108, -0,36,0,2,0,71,3,2,0,72,3,2,0,20,0,2,0,-99,2,7,0,73,3,7,0,74,3,7,0,75,3,7, -0,76,3,7,0,77,3,7,0,78,3,7,0,79,3,7,0,80,3,7,0,81,3,7,0,82,3,7,0,83,3,7, -0,84,3,7,0,85,3,7,0,86,3,7,0,87,3,7,0,88,3,7,0,89,3,7,0,90,3,7,0,91,3,7, -0,92,3,7,0,93,3,7,0,94,3,7,0,95,3,7,0,96,3,2,0,97,3,2,0,98,3,2,0,99,3,2, -0,100,3,51,0,-88,0,-105,0,101,3,7,0,102,3,4,0,110,2,125,0,5,0,4,0,20,0,4,0,103,3,4, -0,104,3,4,0,105,3,4,0,106,3,-104,0,1,0,7,0,-31,1,-109,0,30,0,4,0,20,0,7,0,107,3,7, -0,108,3,7,0,109,3,4,0,110,3,4,0,111,3,4,0,112,3,4,0,113,3,7,0,114,3,7,0,115,3,7, -0,116,3,7,0,117,3,7,0,118,3,7,0,119,3,7,0,120,3,7,0,121,3,7,0,122,3,7,0,123,3,7, -0,124,3,7,0,125,3,7,0,126,3,7,0,127,3,7,0,-128,3,7,0,-127,3,7,0,-126,3,7,0,-125,3,4, -0,-124,3,4,0,-123,3,7,0,-122,3,7,0,27,3,-107,0,49,0,-120,0,-121,3,4,0,-120,3,4,0,-119,3,-103, -0,-118,3,-102,0,-117,3,0,0,37,0,0,0,-116,3,2,0,-115,3,7,0,-114,3,0,0,-113,3,7,0,-112,3,7, -0,-111,3,7,0,-110,3,7,0,-109,3,7,0,-108,3,7,0,-107,3,7,0,-106,3,7,0,-105,3,7,0,-104,3,2, -0,-103,3,0,0,-102,3,2,0,-101,3,7,0,-100,3,7,0,-99,3,0,0,-98,3,4,0,-126,0,4,0,-97,3,4, -0,-96,3,2,0,-95,3,2,0,-94,3,-104,0,-93,3,4,0,-92,3,4,0,81,0,7,0,-91,3,7,0,-90,3,7, -0,-89,3,7,0,-88,3,2,0,-87,3,2,0,-86,3,2,0,-85,3,2,0,-84,3,2,0,-83,3,2,0,-82,3,2, -0,-81,3,2,0,-80,3,-101,0,-79,3,7,0,-78,3,7,0,-77,3,125,0,-76,3,-116,0,48,0,2,0,18,0,2, -0,-75,3,2,0,-74,3,2,0,-73,3,7,0,-72,3,2,0,-71,3,2,0,-70,3,7,0,-69,3,2,0,-68,3,2, -0,-67,3,7,0,-66,3,7,0,-65,3,7,0,-64,3,7,0,-63,3,7,0,-62,3,7,0,-61,3,4,0,-60,3,7, -0,-59,3,7,0,-58,3,7,0,-57,3,74,0,-56,3,74,0,-55,3,74,0,-54,3,0,0,-53,3,7,0,-52,3,7, -0,-51,3,36,0,79,0,2,0,-50,3,0,0,-49,3,0,0,-48,3,7,0,-47,3,4,0,-46,3,7,0,-45,3,7, -0,-44,3,4,0,-43,3,4,0,20,0,7,0,-42,3,7,0,-41,3,7,0,-40,3,78,0,-39,3,7,0,-38,3,7, -0,-37,3,7,0,-36,3,7,0,-35,3,7,0,-34,3,7,0,-33,3,7,0,-32,3,4,0,-31,3,-100,0,71,0,27, -0,31,0,2,0,-79,0,2,0,14,1,2,0,47,1,2,0,-30,3,7,0,-29,3,7,0,-28,3,7,0,-27,3,7, -0,-26,3,7,0,-25,3,7,0,-24,3,7,0,-23,3,7,0,-22,3,7,0,84,1,7,0,86,1,7,0,85,1,7, -0,-21,3,4,0,-20,3,7,0,-19,3,7,0,-18,3,7,0,-17,3,7,0,-16,3,7,0,-15,3,7,0,-14,3,7, -0,-13,3,2,0,-12,3,2,0,13,1,2,0,-11,3,2,0,-10,3,2,0,-9,3,2,0,-8,3,2,0,-7,3,2, -0,-6,3,7,0,-5,3,7,0,-4,3,7,0,-3,3,7,0,-2,3,7,0,-1,3,7,0,0,4,7,0,1,4,7, -0,2,4,7,0,3,4,7,0,4,4,7,0,5,4,7,0,6,4,2,0,7,4,2,0,8,4,2,0,9,4,2, -0,10,4,7,0,11,4,7,0,12,4,7,0,13,4,7,0,14,4,2,0,15,4,2,0,16,4,2,0,17,4,2, -0,18,4,7,0,19,4,7,0,20,4,7,0,21,4,7,0,22,4,2,0,23,4,2,0,24,4,2,0,25,4,2, -0,43,0,7,0,26,4,7,0,27,4,36,0,79,0,50,0,77,1,30,0,-103,0,39,0,125,0,-99,0,16,0,2, -0,28,4,2,0,29,4,2,0,30,4,2,0,20,0,2,0,31,4,2,0,32,4,2,0,33,4,2,0,34,4,2, -0,35,4,2,0,36,4,2,0,37,4,2,0,38,4,4,0,39,4,7,0,40,4,7,0,41,4,7,0,42,4,-98, -0,8,0,-98,0,0,0,-98,0,1,0,4,0,3,3,4,0,43,4,4,0,20,0,2,0,44,4,2,0,45,4,32, -0,-89,0,-97,0,13,0,9,0,46,4,9,0,47,4,4,0,48,4,4,0,49,4,4,0,50,4,4,0,51,4,4, -0,52,4,4,0,53,4,4,0,54,4,4,0,55,4,4,0,56,4,4,0,37,0,0,0,57,4,-96,0,5,0,9, -0,58,4,9,0,59,4,4,0,60,4,4,0,70,0,0,0,61,4,-95,0,13,0,4,0,18,0,4,0,62,4,4, -0,63,4,4,0,64,4,4,0,65,4,4,0,66,4,4,0,93,0,4,0,67,4,4,0,68,4,4,0,69,4,4, -0,70,4,4,0,71,4,26,0,30,0,-94,0,4,0,4,0,72,4,7,0,73,4,2,0,20,0,2,0,68,2,-93, -0,11,0,-93,0,0,0,-93,0,1,0,0,0,17,0,62,0,74,4,63,0,75,4,4,0,3,3,4,0,76,4,4, -0,77,4,4,0,37,0,4,0,78,4,4,0,79,4,-92,0,-126,0,-97,0,80,4,-96,0,81,4,-95,0,82,4,4, -0,83,4,4,0,-126,0,4,0,-97,3,4,0,84,4,4,0,85,4,4,0,86,4,4,0,87,4,2,0,20,0,2, -0,88,4,7,0,20,3,7,0,89,4,7,0,90,4,7,0,91,4,7,0,92,4,7,0,93,4,2,0,94,4,2, -0,95,4,2,0,96,4,2,0,97,4,2,0,-39,0,2,0,98,4,2,0,99,4,2,0,100,3,2,0,100,4,2, -0,101,4,2,0,34,1,2,0,109,0,2,0,102,4,2,0,103,4,2,0,104,4,2,0,105,4,2,0,106,4,2, -0,107,4,2,0,108,4,2,0,109,4,2,0,110,4,2,0,35,1,2,0,111,4,2,0,112,4,2,0,113,4,2, -0,114,4,4,0,115,4,4,0,13,1,2,0,116,4,2,0,117,4,2,0,118,4,2,0,119,4,2,0,120,4,2, -0,121,4,24,0,122,4,24,0,123,4,23,0,124,4,12,0,125,4,2,0,126,4,2,0,37,0,7,0,127,4,7, -0,-128,4,7,0,-127,4,7,0,-126,4,7,0,-125,4,7,0,-124,4,7,0,-123,4,7,0,-122,4,7,0,-121,4,2, -0,-120,4,2,0,-119,4,2,0,-118,4,2,0,-117,4,2,0,-116,4,2,0,-115,4,7,0,-114,4,7,0,-113,4,7, -0,-112,4,2,0,-111,4,2,0,-110,4,2,0,-109,4,2,0,-108,4,2,0,-107,4,2,0,-106,4,2,0,-105,4,2, -0,-104,4,2,0,-103,4,2,0,-102,4,4,0,-101,4,4,0,-100,4,4,0,-99,4,4,0,-98,4,4,0,-97,4,7, -0,-96,4,4,0,-95,4,4,0,-94,4,4,0,-93,4,4,0,-92,4,7,0,-91,4,7,0,-90,4,7,0,-89,4,7, -0,-88,4,7,0,-87,4,7,0,-86,4,7,0,-85,4,7,0,-84,4,7,0,-83,4,0,0,-82,4,0,0,-81,4,4, -0,-80,4,2,0,-79,4,2,0,12,1,0,0,-78,4,7,0,-77,4,7,0,-76,4,4,0,-75,4,4,0,-74,4,7, -0,-73,4,7,0,-72,4,2,0,-71,4,2,0,-70,4,7,0,-69,4,2,0,-68,4,2,0,-67,4,4,0,-66,4,2, -0,-65,4,2,0,-64,4,2,0,-63,4,2,0,-62,4,7,0,-61,4,7,0,70,0,42,0,-60,4,-91,0,9,0,-91, -0,0,0,-91,0,1,0,0,0,17,0,2,0,-59,4,2,0,-58,4,2,0,-57,4,2,0,43,0,7,0,-56,4,7, -0,70,0,-90,0,5,0,7,0,-55,4,0,0,18,0,0,0,43,0,0,0,70,0,0,0,12,1,-89,0,5,0,-89, -0,0,0,-89,0,1,0,4,0,-54,4,0,0,-53,4,4,0,20,0,-88,0,5,0,-87,0,-52,4,2,0,20,0,2, -0,-51,4,2,0,-50,4,2,0,-49,4,-86,0,4,0,2,0,109,0,2,0,-122,2,2,0,-48,4,2,0,-47,4,-85, -0,7,0,2,0,20,0,2,0,-46,4,2,0,-45,4,2,0,-44,4,-86,0,-43,4,7,0,-42,4,4,0,-41,4,-84, -0,4,0,-84,0,0,0,-84,0,1,0,0,0,-40,4,7,0,-39,4,-83,0,56,0,2,0,-38,4,2,0,-37,4,7, -0,-36,4,7,0,-35,4,2,0,-48,4,2,0,-34,4,7,0,-33,4,7,0,-32,4,2,0,-31,4,2,0,-30,4,2, -0,-29,4,2,0,-28,4,7,0,-27,4,7,0,-26,4,7,0,-25,4,7,0,37,0,2,0,-24,4,2,0,-23,4,2, -0,-22,4,2,0,-21,4,-88,0,-20,4,-85,0,-19,4,7,0,-18,4,7,0,-17,4,0,0,-16,4,0,0,-15,4,0, -0,-14,4,0,0,-13,4,0,0,-12,4,0,0,-11,4,2,0,-10,4,7,0,-9,4,7,0,-8,4,7,0,-7,4,7, -0,-6,4,7,0,-5,4,7,0,-4,4,7,0,-3,4,7,0,-2,4,7,0,-1,4,7,0,0,5,2,0,1,5,0, -0,2,5,0,0,3,5,0,0,4,5,0,0,5,5,32,0,6,5,0,0,7,5,0,0,8,5,0,0,9,5,0, -0,10,5,0,0,11,5,0,0,12,5,0,0,13,5,0,0,14,5,0,0,15,5,-82,0,6,0,2,0,109,0,0, -0,-122,2,0,0,16,5,0,0,17,5,0,0,20,0,0,0,-74,0,-81,0,26,0,-80,0,18,5,50,0,77,1,60, -0,19,5,-82,0,20,5,-82,0,21,5,-82,0,22,5,-82,0,23,5,-82,0,24,5,-82,0,25,5,-82,0,26,5,7, -0,27,5,2,0,28,5,2,0,47,1,2,0,29,5,2,0,1,2,0,0,30,5,0,0,31,5,0,0,32,5,0, -0,33,5,0,0,93,0,0,0,34,5,0,0,35,5,0,0,36,5,0,0,37,5,0,0,38,5,0,0,-74,0,-79, -0,43,0,27,0,31,0,32,0,39,5,-100,0,40,5,-79,0,41,5,46,0,-47,0,12,0,42,5,-98,0,43,5,7, -0,44,5,7,0,45,5,7,0,46,5,7,0,47,5,4,0,3,3,7,0,48,5,2,0,49,5,2,0,50,5,2, -0,51,5,2,0,52,5,2,0,53,5,2,0,54,5,2,0,55,5,2,0,5,1,57,0,1,1,9,0,56,5,-99, -0,57,5,-90,0,58,5,-83,0,59,5,-92,0,-73,0,-94,0,60,5,39,0,125,0,12,0,103,0,12,0,61,5,2, -0,62,5,2,0,63,5,2,0,64,5,2,0,65,5,-78,0,66,5,2,0,67,5,2,0,68,5,2,0,64,1,2, -0,-38,0,-81,0,69,5,4,0,70,5,4,0,37,0,-77,0,9,0,46,0,-47,0,45,0,0,1,7,0,8,2,7, -0,9,2,7,0,109,0,7,0,71,5,7,0,72,5,2,0,73,5,2,0,74,5,-76,0,75,0,-75,0,0,0,-75, -0,1,0,4,0,75,5,7,0,76,5,-74,0,77,5,2,0,78,5,7,0,79,5,7,0,80,5,7,0,81,5,7, -0,82,5,7,0,83,5,7,0,84,5,7,0,85,5,7,0,20,1,7,0,86,5,4,0,87,5,2,0,88,5,2, -0,17,5,32,0,39,5,32,0,89,5,-77,0,90,5,-76,0,91,5,-73,0,92,5,-72,0,93,5,-71,0,94,5,0, -0,95,5,2,0,30,4,2,0,96,5,4,0,3,3,4,0,97,5,2,0,98,5,2,0,99,5,2,0,100,5,0, -0,101,5,0,0,43,0,7,0,115,0,7,0,102,5,7,0,103,5,7,0,104,5,7,0,105,5,7,0,106,5,7, -0,107,5,7,0,108,5,7,0,-82,0,7,0,44,5,2,0,109,5,2,0,110,5,2,0,111,5,2,0,112,5,2, -0,-119,0,2,0,29,5,2,0,113,5,2,0,114,5,2,0,115,5,2,0,116,5,7,0,117,5,7,0,118,5,67, -0,119,5,12,0,120,5,2,0,121,5,2,0,53,2,2,0,122,5,2,0,20,0,2,0,123,5,2,0,124,5,2, -0,125,5,0,0,126,5,0,0,127,5,9,0,-128,5,-70,0,-127,5,7,0,-126,5,2,0,-125,5,2,0,-124,5,2, -0,53,5,2,0,54,5,-69,0,19,0,24,0,36,0,24,0,64,0,23,0,-123,5,23,0,-122,5,23,0,-121,5,7, -0,-120,5,7,0,-119,5,7,0,-118,5,7,0,-117,5,2,0,-116,5,2,0,-115,5,2,0,-114,5,2,0,-113,5,2, -0,-112,5,2,0,-111,5,4,0,20,0,7,0,-110,5,2,0,99,5,0,0,107,2,-75,0,6,0,-75,0,0,0,-75, -0,1,0,4,0,75,5,7,0,76,5,-74,0,77,5,2,0,78,5,-68,0,6,0,-75,0,0,0,-75,0,1,0,4, -0,75,5,7,0,76,5,-74,0,77,5,2,0,78,5,-67,0,27,0,-75,0,0,0,-75,0,1,0,4,0,75,5,7, -0,76,5,-74,0,77,5,2,0,78,5,4,0,-109,5,4,0,70,0,-69,0,-108,5,9,0,-107,5,12,0,-106,5,36, -0,79,0,27,0,80,0,0,0,-105,5,0,0,-104,5,0,0,-103,5,2,0,-102,5,2,0,-101,5,2,0,-100,5,2, -0,-99,5,2,0,65,0,2,0,46,0,2,0,-119,0,2,0,-98,5,4,0,20,0,7,0,-97,5,24,0,36,0,-66, -0,29,0,-75,0,0,0,-75,0,1,0,4,0,75,5,7,0,76,5,-74,0,77,5,-73,0,92,5,2,0,78,5,2, -0,-96,5,2,0,-95,5,2,0,-94,5,2,0,-93,5,-69,0,-108,5,2,0,-92,5,2,0,-119,0,2,0,-101,5,2, -0,-91,5,9,0,-90,5,2,0,29,5,0,0,-89,5,0,0,-88,5,2,0,-87,5,2,0,-86,5,2,0,12,3,2, -0,-85,5,2,0,-84,5,0,0,37,0,0,0,20,0,0,0,47,1,0,0,-83,5,-65,0,16,0,-75,0,0,0,-75, -0,1,0,4,0,75,5,7,0,76,5,-74,0,77,5,2,0,78,5,-69,0,-108,5,7,0,8,2,7,0,9,2,2, -0,-92,5,2,0,-82,5,2,0,-81,5,2,0,-80,5,4,0,20,0,7,0,71,5,-70,0,-127,5,-64,0,33,0,-75, -0,0,0,-75,0,1,0,4,0,75,5,7,0,76,5,-74,0,77,5,2,0,78,5,-63,0,-79,5,4,0,-78,5,0, -0,-77,5,0,0,-76,5,0,0,-75,5,2,0,18,0,2,0,-74,5,2,0,20,0,2,0,-73,5,2,0,-72,5,2, -0,-71,5,2,0,-70,5,2,0,43,0,4,0,70,0,0,0,-69,5,-62,0,-68,5,2,0,-67,5,2,0,-66,5,2, -0,-65,5,2,0,-48,0,9,0,-64,5,9,0,-63,5,9,0,-62,5,9,0,-61,5,9,0,-60,5,2,0,-59,5,0, -0,-58,5,-61,0,23,0,-75,0,0,0,-75,0,1,0,4,0,75,5,7,0,76,5,-74,0,77,5,2,0,78,5,-69, -0,-108,5,12,0,-57,5,2,0,-101,5,2,0,-56,5,2,0,20,0,2,0,57,0,9,0,-90,5,12,0,-55,5,-60, -0,-54,5,0,0,-53,5,-59,0,-52,5,4,0,-51,5,4,0,-50,5,2,0,18,0,2,0,-49,5,2,0,-48,5,2, -0,-47,5,-58,0,29,0,-75,0,0,0,-75,0,1,0,4,0,75,5,7,0,76,5,-74,0,77,5,2,0,78,5,-69, -0,-108,5,46,0,-114,2,45,0,0,1,60,0,19,5,2,0,13,1,2,0,-119,0,2,0,-46,5,2,0,-45,5,4, -0,20,0,2,0,49,5,2,0,-44,5,2,0,-98,5,2,0,-101,5,7,0,71,5,0,0,-43,5,0,0,-42,5,0, -0,-41,5,0,0,-40,5,7,0,8,2,7,0,9,2,7,0,-39,5,7,0,-38,5,-70,0,-127,5,-57,0,11,0,-75, -0,0,0,-75,0,1,0,4,0,75,5,7,0,76,5,-74,0,77,5,2,0,78,5,2,0,-119,0,2,0,-98,5,2, -0,-37,5,2,0,20,0,-69,0,-108,5,-56,0,24,0,-75,0,0,0,-75,0,1,0,4,0,75,5,7,0,76,5,-74, -0,77,5,2,0,78,5,42,0,-36,5,4,0,-35,5,4,0,-34,5,2,0,93,0,2,0,-119,0,4,0,-33,5,4, -0,-32,5,4,0,-31,5,4,0,-30,5,4,0,-29,5,4,0,-28,5,4,0,-27,5,4,0,-26,5,7,0,-25,5,23, -0,-24,5,23,0,-23,5,4,0,-22,5,4,0,-21,5,-55,0,10,0,27,0,31,0,9,0,-20,5,9,0,-19,5,9, -0,-18,5,9,0,-17,5,9,0,-16,5,4,0,93,0,4,0,-15,5,0,0,-14,5,0,0,-13,5,-54,0,10,0,-75, -0,0,0,-75,0,1,0,4,0,75,5,7,0,76,5,-74,0,77,5,-55,0,-12,5,2,0,93,0,2,0,-119,0,4, -0,43,0,9,0,-11,5,-53,0,8,0,-75,0,0,0,-75,0,1,0,4,0,75,5,7,0,76,5,-74,0,77,5,-69, -0,-108,5,4,0,20,0,4,0,-10,5,-52,0,21,0,-75,0,0,0,-75,0,1,0,4,0,75,5,7,0,76,5,-74, -0,77,5,2,0,78,5,-69,0,-108,5,27,0,-9,5,27,0,80,0,2,0,20,0,2,0,-119,0,7,0,-8,5,9, -0,-7,5,7,0,8,2,7,0,9,2,57,0,1,1,57,0,-6,5,4,0,-5,5,2,0,-89,5,2,0,37,0,-70, -0,-127,5,-51,0,42,0,-75,0,0,0,-75,0,1,0,4,0,75,5,7,0,76,5,-74,0,77,5,2,0,78,5,-69, -0,-108,5,-50,0,-4,5,0,0,-77,5,0,0,-76,5,0,0,-75,5,2,0,18,0,2,0,-66,5,2,0,20,0,2, -0,-73,5,9,0,-7,5,4,0,-3,5,4,0,-2,5,4,0,-1,5,4,0,0,6,23,0,1,6,23,0,2,6,7, -0,3,6,7,0,4,6,7,0,5,6,7,0,-8,5,2,0,-67,5,2,0,-48,0,2,0,102,1,2,0,6,6,2, -0,37,0,2,0,43,0,2,0,7,6,2,0,8,6,9,0,-64,5,9,0,-63,5,9,0,-62,5,9,0,-61,5,9, -0,-60,5,2,0,-59,5,0,0,-58,5,56,0,9,6,-49,0,20,0,0,0,10,6,0,0,11,6,0,0,12,6,0, -0,13,6,0,0,14,6,0,0,15,6,0,0,16,6,0,0,17,6,0,0,18,6,0,0,19,6,0,0,20,6,0, -0,21,6,0,0,22,6,0,0,23,6,0,0,24,6,0,0,25,6,0,0,26,6,0,0,27,6,0,0,68,2,0, -0,28,6,-48,0,54,0,0,0,29,6,0,0,20,6,0,0,21,6,0,0,30,6,0,0,31,6,0,0,32,6,0, -0,33,6,0,0,34,6,0,0,35,6,0,0,36,6,0,0,37,6,0,0,38,6,0,0,39,6,0,0,40,6,0, -0,41,6,0,0,42,6,0,0,43,6,0,0,44,6,0,0,45,6,0,0,46,6,0,0,47,6,0,0,48,6,0, -0,49,6,0,0,50,6,0,0,51,6,0,0,52,6,0,0,53,6,0,0,54,6,0,0,55,6,0,0,56,6,0, -0,57,6,0,0,58,6,0,0,95,0,0,0,59,6,0,0,60,6,0,0,61,6,0,0,62,6,0,0,63,6,0, -0,64,6,0,0,65,6,0,0,66,6,0,0,67,6,0,0,68,6,0,0,69,6,0,0,70,6,0,0,71,6,0, -0,72,6,0,0,73,6,0,0,74,6,0,0,75,6,0,0,76,6,0,0,77,6,0,0,78,6,0,0,79,6,-47, -0,5,0,0,0,80,6,0,0,37,6,0,0,39,6,2,0,20,0,2,0,37,0,-46,0,22,0,-46,0,0,0,-46, -0,1,0,0,0,17,0,-49,0,81,6,-48,0,82,6,-48,0,83,6,-48,0,84,6,-48,0,85,6,-48,0,86,6,-48, -0,87,6,-48,0,88,6,-48,0,89,6,-48,0,90,6,-48,0,91,6,-48,0,92,6,-48,0,93,6,-48,0,94,6,-48, -0,95,6,-48,0,96,6,-47,0,97,6,0,0,98,6,0,0,99,6,-45,0,5,0,4,0,20,0,4,0,37,0,7, -0,52,2,7,0,100,6,7,0,-31,1,-44,0,66,0,4,0,20,0,4,0,101,6,4,0,102,6,0,0,103,6,0, -0,104,6,0,0,105,6,0,0,106,6,0,0,107,6,0,0,108,6,0,0,109,6,0,0,110,6,0,0,111,6,2, -0,112,6,2,0,113,6,4,0,114,6,4,0,115,6,4,0,116,6,4,0,117,6,2,0,118,6,2,0,119,6,2, -0,120,6,2,0,121,6,4,0,122,6,4,0,123,6,2,0,124,6,2,0,125,6,2,0,126,6,2,0,127,6,0, -0,-128,6,12,0,-127,6,2,0,-126,6,2,0,-125,6,2,0,-124,6,2,0,-123,6,2,0,-122,6,2,0,-121,6,2, -0,-120,6,2,0,-119,6,-45,0,-118,6,2,0,-117,6,2,0,-116,6,2,0,-115,6,2,0,-114,6,4,0,-113,6,4, -0,-112,6,4,0,-111,6,4,0,-110,6,2,0,-109,6,2,0,-108,6,2,0,-107,6,2,0,-106,6,2,0,-105,6,2, -0,-104,6,2,0,-103,6,2,0,-102,6,2,0,-101,6,2,0,-100,6,2,0,-99,6,2,0,37,0,0,0,-98,6,0, -0,-97,6,0,0,-96,6,7,0,-95,6,2,0,55,5,2,0,-94,6,54,0,-93,6,-43,0,18,0,27,0,31,0,12, -0,-92,6,12,0,-91,6,12,0,-90,6,-79,0,-89,6,2,0,-105,2,2,0,-88,6,2,0,-104,2,2,0,-87,6,2, -0,-86,6,2,0,-85,6,2,0,-84,6,2,0,-83,6,2,0,-82,6,2,0,37,0,2,0,-81,6,2,0,-80,6,2, -0,-79,6,-42,0,5,0,-42,0,0,0,-42,0,1,0,-42,0,-78,6,13,0,-77,6,4,0,20,0,-41,0,7,0,-41, -0,0,0,-41,0,1,0,-42,0,-76,6,-42,0,-75,6,2,0,123,4,2,0,20,0,4,0,37,0,-40,0,17,0,-40, -0,0,0,-40,0,1,0,0,0,-74,6,0,0,-73,6,0,0,-72,6,2,0,-71,6,2,0,-70,6,2,0,-86,6,2, -0,-85,6,2,0,20,0,2,0,70,3,2,0,-69,6,2,0,-68,6,2,0,-67,6,2,0,-66,6,4,0,-65,6,-40, -0,-64,6,-74,0,30,0,-74,0,0,0,-74,0,1,0,-42,0,-76,6,-42,0,-75,6,-42,0,-63,6,-42,0,-62,6,-43, -0,-61,6,7,0,-60,6,23,0,52,0,23,0,-59,6,23,0,-58,6,2,0,-57,6,2,0,-56,6,2,0,-55,6,0, -0,75,5,0,0,-54,6,2,0,-53,6,2,0,-52,6,0,0,-51,6,0,0,-50,6,0,0,-49,6,0,0,-48,6,2, -0,-47,6,2,0,-46,6,2,0,-45,6,2,0,20,0,39,0,125,0,12,0,-44,6,12,0,-43,6,12,0,-42,6,-39, -0,11,0,0,0,-41,6,2,0,-40,6,2,0,-39,6,2,0,-38,6,2,0,-37,6,2,0,-36,6,2,0,107,4,9, -0,-35,6,9,0,-34,6,4,0,-33,6,4,0,-32,6,-38,0,1,0,0,0,-31,6,-37,0,8,0,56,0,-30,6,56, -0,-29,6,-37,0,-28,6,-37,0,-27,6,-37,0,-26,6,2,0,-123,0,2,0,20,0,4,0,-25,6,-36,0,4,0,4, -0,-35,5,4,0,-24,6,4,0,-31,5,4,0,-23,6,-35,0,2,0,4,0,-22,6,4,0,-21,6,-34,0,9,0,7, -0,-20,6,7,0,-19,6,7,0,-18,6,4,0,20,0,4,0,13,1,7,0,-19,3,7,0,-17,6,4,0,37,0,-33, -0,-16,6,-32,0,6,0,0,0,-15,6,0,0,-75,5,48,0,-116,0,2,0,109,0,2,0,111,4,4,0,37,0,-31, -0,21,0,-31,0,0,0,-31,0,1,0,4,0,57,0,4,0,23,0,4,0,28,0,4,0,-14,6,4,0,-13,6,4, -0,-12,6,-38,0,-11,6,0,0,-15,6,4,0,-10,6,4,0,-9,6,-32,0,-12,2,-36,0,-8,6,-35,0,-7,6,-34, -0,-6,6,-37,0,-5,6,-37,0,-4,6,-37,0,-3,6,56,0,-2,6,56,0,-1,6,-30,0,12,0,0,0,-68,1,9, -0,-62,0,0,0,-61,0,4,0,-58,0,4,0,-50,0,9,0,-57,0,7,0,-55,0,7,0,-54,0,9,0,0,7,9, -0,1,7,9,0,-53,0,9,0,-51,0,-29,0,43,0,-29,0,0,0,-29,0,1,0,9,0,2,7,9,0,26,0,0, -0,27,0,4,0,20,0,4,0,18,0,4,0,23,0,4,0,91,0,4,0,3,7,4,0,4,7,4,0,-13,6,4, -0,-12,6,4,0,5,7,4,0,-39,0,4,0,6,7,4,0,7,7,7,0,8,7,7,0,9,7,4,0,-126,0,4, -0,10,7,-31,0,11,7,36,0,79,0,-79,0,-89,6,48,0,-116,0,7,0,12,7,7,0,13,7,-30,0,2,1,-29, -0,14,7,-29,0,15,7,-29,0,16,7,12,0,17,7,-28,0,18,7,-27,0,19,7,7,0,20,7,7,0,21,7,4, -0,-84,6,7,0,22,7,9,0,23,7,4,0,24,7,4,0,25,7,4,0,26,7,7,0,27,7,-26,0,4,0,-26, -0,0,0,-26,0,1,0,12,0,28,7,-29,0,29,7,-25,0,6,0,12,0,30,7,12,0,17,7,12,0,31,7,2, -0,20,0,2,0,37,0,4,0,57,0,-24,0,4,0,7,0,32,7,7,0,112,0,2,0,33,7,2,0,34,7,-23, -0,6,0,7,0,35,7,7,0,36,7,7,0,37,7,7,0,38,7,4,0,39,7,4,0,40,7,-22,0,12,0,7, -0,41,7,7,0,42,7,7,0,43,7,7,0,44,7,7,0,45,7,7,0,46,7,7,0,47,7,7,0,48,7,7, -0,49,7,7,0,50,7,4,0,-110,2,4,0,51,7,-21,0,2,0,7,0,-55,4,7,0,37,0,-20,0,7,0,7, -0,52,7,7,0,53,7,4,0,93,0,4,0,108,2,4,0,54,7,4,0,55,7,4,0,37,0,-19,0,6,0,-19, -0,0,0,-19,0,1,0,2,0,18,0,2,0,20,0,2,0,56,7,2,0,57,0,-18,0,8,0,-18,0,0,0,-18, -0,1,0,2,0,18,0,2,0,20,0,2,0,56,7,2,0,57,0,7,0,23,0,7,0,-126,0,-17,0,45,0,-17, -0,0,0,-17,0,1,0,2,0,18,0,2,0,20,0,2,0,56,7,2,0,-43,0,2,0,-103,3,2,0,57,7,7, -0,58,7,7,0,92,0,7,0,-97,2,4,0,59,7,4,0,81,0,4,0,110,2,7,0,60,7,7,0,61,7,7, -0,62,7,7,0,63,7,7,0,64,7,7,0,65,7,7,0,-100,2,7,0,-1,0,7,0,66,7,7,0,67,7,7, -0,37,0,7,0,68,7,7,0,69,7,7,0,70,7,2,0,71,7,2,0,72,7,2,0,73,7,2,0,74,7,2, -0,75,7,2,0,76,7,2,0,77,7,2,0,78,7,2,0,123,5,2,0,79,7,2,0,-47,1,2,0,80,7,0, -0,81,7,0,0,82,7,7,0,-45,0,-16,0,83,7,63,0,-95,1,-15,0,16,0,-15,0,0,0,-15,0,1,0,2, -0,18,0,2,0,20,0,2,0,56,7,2,0,-43,0,7,0,-105,2,7,0,-104,2,7,0,-103,2,7,0,-5,1,7, -0,-102,2,7,0,-101,2,7,0,84,7,7,0,-100,2,7,0,-98,2,7,0,-97,2,-59,0,5,0,2,0,18,0,2, -0,-25,6,2,0,20,0,2,0,85,7,27,0,-9,5,-60,0,3,0,4,0,69,0,4,0,86,7,-59,0,2,0,-14, -0,12,0,-14,0,0,0,-14,0,1,0,2,0,18,0,2,0,20,0,2,0,31,3,2,0,-32,1,7,0,5,0,7, -0,6,0,7,0,87,7,7,0,88,7,27,0,-9,5,12,0,89,7,-13,0,11,0,-13,0,0,0,-13,0,1,0,0, -0,17,0,2,0,18,0,2,0,90,7,4,0,22,0,4,0,91,7,2,0,20,0,2,0,37,0,9,0,92,7,9, -0,93,7,-12,0,5,0,0,0,17,0,7,0,20,1,7,0,94,7,4,0,95,7,4,0,37,0,-11,0,4,0,2, -0,18,0,2,0,20,0,2,0,43,0,2,0,70,0,-10,0,4,0,0,0,17,0,62,0,96,7,7,0,20,1,7, -0,37,0,-9,0,6,0,2,0,97,7,2,0,98,7,2,0,18,0,2,0,99,7,0,0,100,7,0,0,101,7,-8, -0,5,0,4,0,18,0,4,0,37,0,0,0,17,0,0,0,102,7,0,0,103,7,-7,0,3,0,4,0,18,0,4, -0,37,0,0,0,17,0,-6,0,4,0,2,0,104,7,2,0,105,7,2,0,20,0,2,0,37,0,-5,0,6,0,0, -0,17,0,0,0,106,7,2,0,107,7,2,0,-100,2,2,0,13,1,2,0,70,0,-4,0,5,0,0,0,17,0,7, -0,112,0,7,0,-17,3,2,0,20,0,2,0,122,2,-3,0,3,0,0,0,17,0,4,0,110,2,4,0,104,7,-2, -0,7,0,0,0,17,0,7,0,-17,3,0,0,108,7,0,0,109,7,2,0,13,1,2,0,43,0,4,0,110,7,-1, -0,3,0,32,0,111,7,0,0,112,7,0,0,113,7,0,1,18,0,0,1,0,0,0,1,1,0,2,0,18,0,2, -0,90,7,2,0,20,0,2,0,114,7,2,0,115,7,2,0,116,7,2,0,43,0,2,0,70,0,0,0,17,0,9, -0,2,0,1,1,117,7,32,0,45,0,2,0,-47,4,2,0,20,7,2,0,118,7,2,0,37,0,2,1,11,0,0, -0,17,0,0,0,18,0,0,0,119,7,2,0,20,0,2,0,122,2,2,0,120,7,4,0,121,7,4,0,122,7,4, -0,123,7,4,0,124,7,4,0,125,7,3,1,1,0,0,0,126,7,4,1,4,0,42,0,-36,5,0,0,127,7,4, -0,13,1,4,0,20,0,1,1,18,0,1,1,0,0,1,1,1,0,1,1,-128,7,2,0,18,0,2,0,20,0,2, -0,-127,7,2,0,116,7,2,0,90,7,2,0,-126,7,2,0,70,0,2,0,12,1,0,0,17,0,9,0,2,0,5, -1,117,7,0,1,-125,7,2,0,15,0,2,0,-124,7,4,0,-123,7,6,1,3,0,4,0,-74,2,4,0,37,0,32, -0,45,0,7,1,12,0,-111,0,-122,7,2,0,18,0,2,0,20,0,4,0,58,7,4,0,92,0,0,0,17,0,0, -0,-121,7,2,0,-120,7,2,0,-119,7,2,0,-118,7,2,0,-117,7,7,0,-116,7,8,1,10,0,2,0,20,0,2, -0,-115,7,4,0,58,7,4,0,92,0,2,0,-114,7,-28,0,18,7,2,0,18,0,2,0,-113,7,2,0,-112,7,2, -0,-111,7,9,1,7,0,2,0,20,0,2,0,-115,7,4,0,58,7,4,0,92,0,2,0,18,0,2,0,-110,7,7, -0,109,3,10,1,11,0,4,0,-74,2,2,0,18,0,2,0,20,0,32,0,45,0,74,0,-109,7,0,0,17,0,7, -0,-108,7,7,0,-107,7,7,0,21,3,2,0,-106,7,2,0,-105,7,11,1,5,0,2,0,18,0,2,0,20,0,4, -0,37,0,-79,0,-89,6,32,0,39,5,12,1,5,0,4,0,20,0,4,0,18,0,0,0,17,0,0,0,102,7,32, -0,45,0,13,1,13,0,2,0,20,0,2,0,18,0,2,0,90,7,2,0,22,3,7,0,-104,7,7,0,-103,7,7, -0,7,1,7,0,8,1,7,0,-3,2,7,0,0,3,7,0,-102,7,7,0,-101,7,32,0,-100,7,14,1,10,0,2, -0,20,0,2,0,18,0,4,0,58,7,4,0,92,0,0,0,17,0,0,0,-121,7,2,0,43,0,2,0,64,0,2, -0,-99,7,2,0,-98,7,15,1,8,0,32,0,45,0,7,0,-103,2,7,0,-97,7,7,0,-96,7,7,0,-108,2,2, -0,20,0,2,0,122,2,7,0,-95,7,16,1,12,0,2,0,18,0,2,0,13,1,2,0,20,0,2,0,-100,2,2, -0,-74,2,2,0,-94,7,4,0,37,0,7,0,-93,7,7,0,-92,7,7,0,-91,7,7,0,-90,7,0,0,-89,7,17, -1,10,0,2,0,20,0,2,0,18,0,4,0,58,7,4,0,92,0,0,0,17,0,2,0,68,2,2,0,64,0,2, -0,-99,7,2,0,-98,7,63,0,-95,1,18,1,7,0,4,0,110,2,4,0,-88,7,4,0,-87,7,4,0,-86,7,7, -0,-85,7,7,0,-84,7,0,0,108,7,19,1,7,0,0,0,-83,7,32,0,-82,7,0,0,112,7,2,0,-81,7,2, -0,43,0,4,0,70,0,0,0,113,7,20,1,6,0,2,0,20,0,2,0,18,0,4,0,58,7,4,0,92,0,0, -0,-80,7,0,0,-79,7,21,1,1,0,4,0,20,0,22,1,6,0,0,0,95,0,2,0,18,0,2,0,20,0,4, -0,-78,7,7,0,-77,7,42,0,-36,5,23,1,4,0,0,0,-74,0,2,0,20,0,4,0,18,0,32,0,45,0,24, -1,2,0,4,0,18,0,4,0,-121,5,5,1,10,0,5,1,0,0,5,1,1,0,5,1,-128,7,2,0,18,0,2, -0,20,0,2,0,90,7,2,0,-76,7,0,0,17,0,9,0,2,0,32,0,45,0,25,1,10,0,7,0,21,3,7, -0,-75,7,7,0,-74,7,7,0,-73,7,7,0,-72,7,4,0,20,0,7,0,-94,7,7,0,-71,7,7,0,-70,7,7, -0,37,0,-28,0,20,0,27,0,31,0,0,0,-63,0,26,1,-69,7,9,0,-68,7,43,0,-104,0,43,0,-67,7,9, -0,-66,7,36,0,79,0,7,0,109,3,7,0,-65,7,7,0,-64,7,7,0,-63,7,7,0,-62,7,7,0,-61,7,7, -0,-60,7,4,0,93,0,4,0,-59,7,0,0,-58,7,0,0,-57,7,0,0,-56,7,27,1,6,0,27,0,31,0,7, -0,-55,7,7,0,-54,7,7,0,-53,7,2,0,-52,7,2,0,-51,7,28,1,14,0,-75,0,0,0,-75,0,1,0,4, -0,75,5,7,0,76,5,-74,0,77,5,-69,0,-108,5,-28,0,18,7,2,0,13,1,2,0,-115,7,2,0,8,2,2, -0,9,2,2,0,20,0,2,0,-98,5,4,0,70,0,29,1,6,0,29,1,0,0,29,1,1,0,32,0,45,0,9, -0,-50,7,4,0,-38,0,4,0,37,0,63,0,4,0,27,0,31,0,12,0,-49,7,4,0,-121,0,7,0,-48,7,30, -1,25,0,30,1,0,0,30,1,1,0,30,1,38,0,12,0,-47,7,0,0,17,0,7,0,-46,7,7,0,-45,7,7, -0,-44,7,7,0,-43,7,4,0,20,0,7,0,-42,7,7,0,-41,7,7,0,-40,7,7,0,20,1,7,0,-39,1,7, -0,-39,7,7,0,108,2,7,0,-38,7,7,0,-37,7,7,0,-36,7,7,0,-35,7,7,0,-34,7,7,0,-81,0,2, -0,-121,0,2,0,-31,4,31,1,19,0,27,0,31,0,12,0,-33,7,12,0,-32,7,4,0,20,0,4,0,30,4,2, -0,-96,2,2,0,-31,7,2,0,-121,0,2,0,-30,7,2,0,-29,7,2,0,-28,7,2,0,-27,7,2,0,-26,7,4, -0,-25,7,4,0,-24,7,4,0,-23,7,4,0,-22,7,4,0,-21,7,4,0,-20,7,32,1,34,0,32,1,0,0,32, -1,1,0,12,0,49,3,0,0,17,0,2,0,20,0,2,0,-19,7,2,0,-18,7,2,0,-17,7,2,0,10,3,2, -0,-16,7,4,0,-7,1,4,0,-23,7,4,0,-22,7,30,1,-15,7,32,1,38,0,32,1,-14,7,12,0,-13,7,9, -0,-12,7,9,0,-11,7,9,0,-10,7,7,0,7,1,7,0,-81,0,7,0,-57,1,7,0,-9,7,7,0,-8,7,7, -0,2,3,7,0,-7,7,7,0,-6,7,7,0,-5,7,7,0,-4,7,7,0,-3,7,7,0,-2,7,7,0,-10,1,32, -0,-1,7,-110,0,9,0,12,0,0,8,2,0,20,0,2,0,1,8,7,0,20,3,7,0,2,8,7,0,3,8,12, -0,4,8,4,0,5,8,4,0,37,0,33,1,7,0,33,1,0,0,33,1,1,0,12,0,-58,7,4,0,20,0,4, -0,6,8,0,0,17,0,-47,0,7,8,34,1,8,0,34,1,0,0,34,1,1,0,33,1,8,8,36,0,79,0,12, -0,-6,2,4,0,20,0,0,0,17,0,4,0,9,8,-111,0,6,0,27,0,31,0,12,0,0,8,12,0,10,8,12, -0,103,0,4,0,11,8,4,0,37,0,35,1,16,0,-75,0,0,0,-75,0,1,0,4,0,75,5,7,0,76,5,-74, -0,77,5,2,0,78,5,-69,0,-108,5,-111,0,-9,2,0,0,13,1,0,0,-37,5,2,0,20,0,2,0,12,8,2, -0,-101,5,2,0,-98,5,2,0,13,8,7,0,14,8,36,1,5,0,36,1,0,0,36,1,1,0,36,0,79,0,2, -0,20,0,0,0,15,8,37,1,12,0,37,1,0,0,37,1,1,0,9,0,2,0,2,0,18,0,2,0,20,0,0, -0,16,8,0,0,17,8,0,0,15,8,7,0,18,8,7,0,19,8,4,0,37,0,36,0,79,0,38,1,9,0,38, -1,0,0,38,1,1,0,32,0,20,8,0,0,21,8,7,0,22,8,2,0,23,8,2,0,20,0,2,0,18,0,2, -0,37,0,39,1,7,0,42,0,-36,5,26,0,24,8,4,0,20,0,4,0,25,8,12,0,26,8,32,0,20,8,0, -0,21,8,40,1,12,0,32,0,20,8,2,0,27,8,2,0,20,0,2,0,28,8,2,0,29,8,0,0,21,8,32, -0,30,8,0,0,31,8,7,0,32,8,7,0,-39,1,7,0,33,8,7,0,34,8,41,1,6,0,32,0,20,8,4, -0,9,8,4,0,35,8,4,0,93,0,4,0,37,0,0,0,21,8,42,1,4,0,32,0,20,8,4,0,20,0,4, -0,9,8,0,0,21,8,43,1,4,0,32,0,20,8,4,0,20,0,4,0,9,8,0,0,21,8,44,1,10,0,32, -0,20,8,4,0,36,8,7,0,-127,0,4,0,20,0,2,0,-42,5,2,0,37,8,2,0,43,0,2,0,70,0,7, -0,38,8,0,0,21,8,45,1,4,0,32,0,20,8,4,0,20,0,4,0,9,8,0,0,21,8,46,1,10,0,32, -0,20,8,2,0,18,0,2,0,-95,3,4,0,91,0,4,0,92,0,7,0,-97,7,7,0,-96,7,4,0,37,0,-111, -0,-122,7,0,0,21,8,47,1,4,0,32,0,20,8,4,0,7,3,4,0,39,8,0,0,21,8,48,1,5,0,32, -0,20,8,7,0,-127,0,4,0,40,8,4,0,7,3,4,0,8,3,49,1,6,0,32,0,20,8,4,0,41,8,4, -0,42,8,7,0,43,8,7,0,44,8,0,0,21,8,50,1,16,0,32,0,20,8,32,0,-14,7,4,0,18,0,7, -0,45,8,7,0,46,8,7,0,47,8,7,0,48,8,7,0,49,8,7,0,50,8,7,0,51,8,7,0,52,8,7, -0,53,8,2,0,20,0,2,0,37,0,2,0,43,0,2,0,70,0,51,1,3,0,32,0,20,8,4,0,20,0,4, -0,123,5,52,1,5,0,32,0,20,8,4,0,20,0,4,0,37,0,7,0,54,8,0,0,21,8,53,1,10,0,32, -0,20,8,0,0,21,8,2,0,55,8,2,0,56,8,0,0,57,8,0,0,58,8,7,0,59,8,7,0,60,8,7, -0,61,8,7,0,62,8,54,1,8,0,7,0,9,0,7,0,10,0,7,0,11,0,7,0,12,0,7,0,63,8,7, -0,64,8,2,0,20,0,2,0,123,5,55,1,8,0,7,0,9,0,7,0,10,0,7,0,11,0,7,0,12,0,7, -0,63,8,7,0,64,8,2,0,20,0,2,0,123,5,56,1,8,0,7,0,9,0,7,0,10,0,7,0,11,0,7, -0,12,0,7,0,63,8,7,0,64,8,2,0,20,0,2,0,123,5,57,1,7,0,32,0,20,8,0,0,21,8,7, -0,20,1,7,0,30,1,2,0,20,0,2,0,13,1,4,0,37,0,58,1,5,0,32,0,-45,2,7,0,20,1,2, -0,-41,2,0,0,-39,2,0,0,65,8,59,1,10,0,59,1,0,0,59,1,1,0,2,0,18,0,2,0,20,0,0, -0,66,8,7,0,-36,0,7,0,-35,0,2,0,-58,7,2,0,67,8,32,0,45,0,60,1,22,0,60,1,0,0,60, -1,1,0,2,0,20,0,2,0,13,1,2,0,68,8,2,0,69,8,36,0,79,0,-111,0,-122,7,32,0,-89,0,7, -0,91,0,7,0,92,0,7,0,70,8,7,0,71,8,7,0,72,8,7,0,73,8,7,0,-107,2,7,0,-67,1,7, -0,-120,7,7,0,74,8,0,0,75,8,0,0,76,8,12,0,-4,2,61,1,8,0,7,0,-31,1,7,0,-97,7,7, -0,-96,7,9,0,2,0,2,0,77,8,2,0,78,8,2,0,79,8,2,0,80,8,62,1,18,0,62,1,0,0,62, -1,1,0,62,1,81,8,0,0,17,0,61,1,82,8,2,0,18,0,2,0,20,0,2,0,83,8,2,0,84,8,2, -0,85,8,2,0,86,8,4,0,43,0,7,0,87,8,7,0,88,8,4,0,89,8,4,0,90,8,62,1,91,8,63, -1,92,8,64,1,32,0,64,1,0,0,64,1,1,0,64,1,93,8,0,0,17,0,0,0,94,8,2,0,18,0,2, -0,20,0,2,0,-14,6,2,0,20,7,2,0,95,8,2,0,-119,0,2,0,84,8,2,0,-25,6,12,0,-127,7,12, -0,96,8,27,0,-9,5,9,0,97,8,7,0,87,8,7,0,88,8,7,0,-5,1,7,0,98,8,2,0,99,8,2, -0,100,8,7,0,101,8,7,0,102,8,2,0,103,8,2,0,104,8,24,0,105,8,24,0,106,8,24,0,107,8,65, -1,-103,0,66,1,108,8,63,1,6,0,63,1,0,0,63,1,1,0,64,1,109,8,64,1,110,8,62,1,111,8,62, -1,91,8,57,0,16,0,27,0,31,0,12,0,112,8,12,0,113,8,61,1,114,8,12,0,115,8,4,0,18,0,4, -0,116,8,4,0,117,8,4,0,118,8,12,0,119,8,66,1,120,8,62,1,121,8,62,1,122,8,9,0,123,8,9, -0,124,8,4,0,125,8,67,1,6,0,4,0,-128,0,4,0,-126,0,4,0,-25,6,0,0,126,8,0,0,127,8,2, -0,37,0,68,1,16,0,2,0,-86,6,2,0,-85,6,2,0,-128,8,2,0,-74,7,2,0,-127,8,2,0,68,0,7, -0,-108,2,7,0,-126,8,7,0,-125,8,2,0,34,1,0,0,-124,8,0,0,42,4,2,0,-123,8,2,0,37,0,4, -0,-122,8,4,0,-121,8,69,1,9,0,7,0,-120,8,7,0,-119,8,7,0,-60,7,7,0,112,0,7,0,-118,8,7, -0,71,5,2,0,-117,8,0,0,-116,8,0,0,37,0,70,1,4,0,7,0,-115,8,7,0,-114,8,2,0,-117,8,2, -0,37,0,71,1,3,0,7,0,-113,8,7,0,-112,8,7,0,15,0,72,1,7,0,0,0,-68,1,2,0,109,4,2, -0,110,4,2,0,111,4,2,0,62,4,4,0,-126,0,4,0,-97,3,73,1,7,0,7,0,-111,8,7,0,-110,8,7, -0,-109,8,7,0,4,2,7,0,-108,8,7,0,-107,8,7,0,-106,8,74,1,4,0,2,0,-105,8,2,0,-104,8,2, -0,-103,8,2,0,-102,8,75,1,2,0,7,0,5,0,7,0,6,0,76,1,2,0,0,0,-87,0,0,0,-101,8,77, -1,1,0,0,0,17,0,78,1,10,0,0,0,-100,8,0,0,-99,8,0,0,-98,8,0,0,-97,8,2,0,-128,8,2, -0,-96,8,7,0,-95,8,7,0,-94,8,7,0,-93,8,7,0,-67,1,79,1,2,0,9,0,-92,8,9,0,-91,8,80, -1,11,0,0,0,111,4,0,0,18,0,0,0,-117,8,0,0,112,0,0,0,-90,8,0,0,109,0,0,0,-74,0,7, -0,-89,8,7,0,-88,8,7,0,-87,8,7,0,-86,8,81,1,8,0,7,0,97,7,7,0,-127,0,7,0,42,4,7, -0,72,2,7,0,-85,8,7,0,-49,0,7,0,-84,8,4,0,18,0,82,1,4,0,2,0,-83,8,2,0,-82,8,2, -0,-81,8,2,0,37,0,83,1,1,0,0,0,17,0,84,1,4,0,7,0,5,0,7,0,6,0,2,0,20,0,2, -0,-80,8,85,1,10,0,2,0,-120,3,2,0,20,0,7,0,-17,3,7,0,-79,8,7,0,-78,8,7,0,-77,8,7, -0,-76,8,84,1,-75,8,84,1,-74,8,84,1,-73,8,60,0,9,0,4,0,20,0,4,0,64,0,24,0,-72,8,24, -0,-71,8,85,1,-70,8,7,0,-69,8,7,0,-68,8,7,0,-67,8,7,0,-66,8,86,1,4,0,46,0,-114,2,7, -0,-65,8,7,0,92,1,7,0,37,0,-87,0,13,0,27,0,31,0,2,0,20,0,2,0,72,5,4,0,109,0,7, -0,-64,8,7,0,1,2,7,0,-63,8,7,0,-62,8,7,0,92,1,2,0,47,1,2,0,37,0,50,0,77,1,86, -1,-61,8,87,1,10,0,4,0,18,0,4,0,-127,0,4,0,20,0,4,0,70,3,4,0,-60,8,4,0,-59,8,4, -0,-58,8,0,0,95,0,0,0,17,0,9,0,2,0,84,0,6,0,87,1,-57,8,4,0,-56,8,4,0,-55,8,4, -0,-54,8,4,0,37,0,9,0,-53,8,88,1,5,0,7,0,66,2,7,0,-74,2,7,0,-39,1,2,0,-52,8,2, -0,37,0,89,1,5,0,7,0,66,2,7,0,-51,8,7,0,-50,8,7,0,-49,8,7,0,-74,2,90,1,7,0,4, -0,-48,8,4,0,-47,8,4,0,-46,8,7,0,-45,8,7,0,-44,8,7,0,-43,8,7,0,-42,8,91,1,26,0,32, -0,-41,8,89,1,66,3,89,1,-40,8,88,1,-39,8,89,1,83,7,7,0,-38,8,7,0,-37,8,7,0,-36,8,7, -0,-35,8,7,0,-44,8,7,0,-43,8,7,0,-74,2,7,0,-97,2,7,0,-34,8,7,0,-33,8,7,0,109,0,7, -0,-32,8,4,0,-48,8,4,0,-31,8,4,0,37,0,4,0,81,0,4,0,-30,8,2,0,20,0,2,0,-29,8,2, -0,-28,8,2,0,100,3,92,1,112,0,27,0,31,0,4,0,20,0,2,0,18,0,2,0,55,8,2,0,-27,8,2, -0,-26,8,2,0,-25,8,2,0,-24,8,2,0,-23,8,2,0,-22,8,2,0,-21,8,2,0,-20,8,2,0,-19,8,2, -0,-18,8,2,0,-17,8,2,0,-16,8,2,0,-15,8,2,0,-14,8,2,0,-13,8,2,0,-47,1,2,0,76,7,2, -0,51,7,2,0,-12,8,2,0,-11,8,2,0,98,3,2,0,99,3,2,0,-10,8,2,0,-9,8,2,0,-8,8,2, -0,-7,8,2,0,-6,8,2,0,-5,8,7,0,-4,8,7,0,-3,8,7,0,-2,8,2,0,-1,8,2,0,0,9,7, -0,1,9,7,0,2,9,7,0,3,9,7,0,58,7,7,0,92,0,7,0,-97,2,7,0,64,7,7,0,4,9,7, -0,5,9,7,0,6,9,7,0,7,9,7,0,57,0,4,0,59,7,4,0,57,7,4,0,8,9,7,0,60,7,7, -0,61,7,7,0,62,7,7,0,9,9,7,0,10,9,7,0,11,9,7,0,12,9,7,0,13,9,7,0,14,9,7, -0,15,9,7,0,16,9,7,0,21,3,7,0,109,0,7,0,17,9,7,0,18,9,7,0,19,9,7,0,20,9,7, -0,21,9,7,0,22,9,7,0,108,2,7,0,23,9,7,0,24,9,4,0,25,9,4,0,26,9,7,0,27,9,7, -0,28,9,7,0,29,9,7,0,30,9,7,0,31,9,7,0,32,9,7,0,33,9,7,0,34,9,7,0,94,3,7, -0,92,3,7,0,93,3,7,0,35,9,7,0,36,9,7,0,37,9,7,0,38,9,7,0,39,9,7,0,40,9,7, -0,41,9,7,0,42,9,7,0,43,9,7,0,28,3,7,0,44,9,7,0,45,9,7,0,46,9,7,0,47,9,7, -0,48,9,7,0,49,9,7,0,50,9,0,0,51,9,63,0,55,3,63,0,52,9,32,0,53,9,32,0,54,9,36, -0,79,0,-108,0,53,3,-108,0,55,9,-120,0,37,0,-120,0,0,0,-120,0,1,0,92,1,56,9,91,1,-121,3,90, -1,-14,7,93,1,57,9,94,1,58,9,94,1,59,9,12,0,60,9,12,0,61,9,-107,0,54,3,32,0,62,9,32, -0,63,9,32,0,64,9,12,0,65,9,12,0,66,9,7,0,-45,0,7,0,83,4,4,0,110,2,4,0,20,0,4, -0,59,7,4,0,67,9,4,0,68,9,4,0,69,9,4,0,57,0,2,0,-38,0,2,0,70,9,2,0,71,9,2, -0,72,9,2,0,47,3,2,0,73,9,0,0,74,9,2,0,75,9,2,0,76,9,2,0,77,9,9,0,78,9,125, -0,-76,3,123,0,34,0,95,1,79,9,7,0,-106,3,7,0,80,9,7,0,81,9,7,0,-14,3,7,0,82,9,7, -0,31,3,7,0,21,3,7,0,83,9,7,0,3,2,7,0,84,9,7,0,85,9,7,0,86,9,7,0,87,9,7, -0,88,9,7,0,89,9,7,0,-105,3,7,0,90,9,7,0,91,9,7,0,92,9,7,0,-104,3,7,0,-108,3,7, -0,-107,3,4,0,93,9,4,0,93,0,4,0,94,9,4,0,95,9,2,0,96,9,2,0,97,9,2,0,98,9,2, -0,99,9,2,0,100,9,2,0,37,0,4,0,70,0,124,0,8,0,95,1,101,9,7,0,102,9,7,0,103,9,7, -0,-94,1,7,0,104,9,4,0,93,0,2,0,105,9,2,0,106,9,96,1,4,0,7,0,5,0,7,0,6,0,7, -0,7,0,7,0,107,9,97,1,6,0,97,1,0,0,97,1,1,0,96,1,108,9,4,0,109,9,2,0,110,9,2, -0,20,0,98,1,5,0,98,1,0,0,98,1,1,0,12,0,111,9,4,0,112,9,4,0,20,0,99,1,9,0,99, -1,0,0,99,1,1,0,12,0,-128,0,98,1,113,9,4,0,20,0,2,0,110,9,2,0,114,9,7,0,94,0,0, -0,115,9,-70,0,5,0,12,0,125,4,4,0,20,0,2,0,116,9,2,0,117,9,9,0,118,9,69,78,68,66,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -}; -int DNAlen= sizeof(DNAstr); diff --git a/gamekit/game_250_zipped.blend b/gamekit/game_250_zipped.blend deleted file mode 100644 index b9d3ade2f..000000000 Binary files a/gamekit/game_250_zipped.blend and /dev/null differ diff --git a/gamekit/hinge.blend b/gamekit/hinge.blend deleted file mode 100644 index 57142f669..000000000 Binary files a/gamekit/hinge.blend and /dev/null differ diff --git a/gamekit/light.blend b/gamekit/light.blend deleted file mode 100644 index 15fc3ce6c..000000000 Binary files a/gamekit/light.blend and /dev/null differ diff --git a/gamekit/main.cpp b/gamekit/main.cpp deleted file mode 100644 index 37dab2481..000000000 --- a/gamekit/main.cpp +++ /dev/null @@ -1,451 +0,0 @@ -/* -GameKit -Copyright (c) 2009 Erwin Coumans http://gamekit.googlecode.com - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -///Note: this is based on Irrlicht Example 003 Custom SceneNode, so the copyright of the original parts belongs to Irrlicht - -///you can disable custom node, to use irr::scene::SAnimatedMesh in Irrlicht 1.5 -//#define USE_CUSTOM_NODE 1 - -///You can enable vertex buffer objects (VBO) for Irrlicht 1.5 -#define USE_VBO 1 - -#include <irrlicht.h> -#include <iostream> -#include "IrrBlend.h" -#include "IrrBlendNew.h" -#include "btBulletDynamicsCommon.h" - - -///The TEST_ECHO_BLEND_READER define is to test reading .blend files using another 'readblend' implementation by Charlie C from 2006 -///it has been written in C++ and is compatible with 32,64 bit .blend files, and both little and big endian - -#define TEST_ECHO_BLEND_READER //use bParse (if disabled use readblend .blend parser) -//#define BATCH_UNIT_TESTING //run through an array of test .blend files - - -using namespace irr; -IrrlichtDevice* device=0; - -bool gPause=false; -bool gWireframe = false; - - - -class MyEventReceiver : public IEventReceiver -{ -public: - // This is the one method that we have to implement - virtual bool OnEvent(const SEvent& event) - { - // Remember whether each key is down or up - if (event.EventType == irr::EET_KEY_INPUT_EVENT) - { - KeyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown; - - - if (IsKeyDown(irr::KEY_KEY_Q)) - { - exit(0); - } - if (IsKeyDown(irr::KEY_SPACE)) - { - gPause = !gPause; - } - if (IsKeyDown(irr::KEY_KEY_W)) - { - gWireframe = !gWireframe; - } - } - - return false; - } - - // This is used to check whether a key is being held down - virtual bool IsKeyDown(EKEY_CODE keyCode) const - { - return KeyIsDown[keyCode]; - } - - MyEventReceiver() - { - for (u32 i=0; i<KEY_KEY_CODES_COUNT; ++i) - KeyIsDown[i] = false; - } - -private: - // We use this array to store the current state of each key - bool KeyIsDown[KEY_KEY_CODES_COUNT]; -}; - - -#ifdef __APPLE__ -#define MAXPATHLEN 512 -char* AppleGetBundleDirectory(void) { - CFURLRef bundleURL; - CFStringRef pathStr; - static char path[MAXPATHLEN]; - memset(path,MAXPATHLEN,0); - CFBundleRef mainBundle = CFBundleGetMainBundle(); - - bundleURL = CFBundleCopyBundleURL(mainBundle); - pathStr = CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle); - CFStringGetCString(pathStr, path, MAXPATHLEN, kCFStringEncodingASCII); - CFRelease(pathStr); - CFRelease(bundleURL); - return path; -} -#endif - - -char* fileNames[] = { - "clubsilo_packed.blend", //blender 2.49b -> no conversion if using bParse - "multimat.blend",//multi materials - "light.blend",//lights - "game_250_zipped.blend",//test zipped forward compatibility - "momo_ogreSmallAnim.blend", //skeletal animation - "cube_tex_4.blend", //64bit test - "PhysicsAnimationBakingDemo.blend",//physics - "BigEndian.blend",//big endian - "cube_ipo_180.blend",//test an old Blender version - ""//terminator -}; - - - -int main(int argc,char** argv) -{ - - int sz = sizeof(btCollisionObject); - int sz2 = sizeof(btRigidBody); - - int numfiles = sizeof(fileNames); - for (int i=0;strlen(fileNames[i]);i++) - { - const char* fileName = fileNames[i]; - - if (argv[0]) - printf("argv[0]=%s\n",argv[0]); - - int verboseDumpAllTypes = false;//true; - int verboseDumpAllBlocks = false;//false;//true; - - printf("Usage:\nGameKit [-verbose] [blendfile.blend]\n"); - - if (argc>1 && argv[1]) - { - if (!strcmp(argv[1],"-verbose")) - { - verboseDumpAllTypes = true; - verboseDumpAllBlocks = true; - printf("enable verbose output: verboseDumpAllTypes and verboseDumpAllBlocks\n"); - } - } - - #if __APPLE__ - printf("Or double-click on the GameKit application. You can copy a file game.blend in the same directory as the GameKit application (not inside the bundle)\n"); - #endif - - FILE* file = fopen(fileName,"rb"); - if (argc>1 || !file) - { - #if __APPLE__ - - char newName[1024]; - - char* bundlePath = AppleGetBundleDirectory(); - //cut off the .app filename - char* lastSlash=0; - if( lastSlash = strrchr( bundlePath, '/' ) ) - *lastSlash = '\0'; - sprintf(newName,"%s/%s",bundlePath,"game.blend"); - file = fopen(newName,"rb"); - - // how do you debug the Bundle execution, without a console? - FILE* dump = fopen ("/out.txt","wb"); - fwrite(newName,1,strlen(newName),dump); - fclose(dump); - - if (!file) - { - sprintf(newName,"%s/%s/%s",AppleGetBundleDirectory(),"Contents/Resources",fileName); - file=fopen(newName,"rb"); - if (!file) - printf("cannot open file %s.\n",newName); - } - - - - #else - - char newName[1024]; - newName[0] = 0; - - switch (argc) - { - case 2: - { - if (argv[1]) - fileName = argv[1]; - break; - } - case 3: - { - if (argv[2]) - fileName = argv[2]; - } - - default: - { - } - } - - sprintf(newName,"%s",fileName); - file = fopen(newName,"rb"); - //printf("cannot open file %s.\n",newName); - - #endif//__APPLE__ - if (!file) - { - printf("cannot open file %s.\n",argv[1]); - exit(0); - } - } - - - // let user select driver type - - video::E_DRIVER_TYPE driverType; - #if 0 - printf("Please select the driver you want for this example:\n"\ - " (a) Direct3D 9.0c\n (b) Direct3D 8.1\n (c) OpenGL 1.5\n"\ - " (d) Software Renderer\n (e) Burning's Software Renderer\n"\ - " (f) NullDevice\n (otherKey) exit\n\n"); - - char i; - std::cin >> i; - switch(i) - { - case 'a': driverType = video::EDT_DIRECT3D9;break; - case 'b': driverType = video::EDT_DIRECT3D8;break; - case 'c': driverType = video::EDT_OPENGL; break; - case 'd': driverType = video::EDT_SOFTWARE; break; - case 'e': driverType = video::EDT_BURNINGSVIDEO;break; - case 'f': driverType = video::EDT_NULL; break; - default: return 0; - } - #else - //driverType = video::EDT_BURNINGSVIDEO; - - //driverType = video::EDT_DIRECT3D9; - driverType = video::EDT_OPENGL; - - #endif - // create device - - MyEventReceiver receiver; - - core::dimension2d<unsigned int>dim(640, 480); - device = createDevice(driverType, dim, 32, false,false,false,&receiver); - //device = createDevice(driverType, core::dimension2d<s32>(640, 480), 32, false,false,true,&receiver); - //device = createDevice(driverType, core::dimension2d<s32>(640, 480), 32, true,false,true,&receiver); - // device->setResizeAble(true); - - - - //device = createDevice(driverType, core::dimension2d<s32>(1024, 768), 32, true); - - if (device == 0) - return 1; // could not create selected driver. - - // create engine and camera - - device->setWindowCaption(L"Custom Scene Node - Irrlicht Engine Demo"); - - - video::IVideoDriver* driver = device->getVideoDriver(); - scene::ISceneManager* smgr = device->getSceneManager(); - - irr::scene::ICameraSceneNode* cam = smgr->addCameraSceneNodeFPS(0,20,0.01f,100); - //irr::scene::ICameraSceneNode* cam = smgr->addCameraSceneNodeMaya(0, core::vector3df(0,-40,0), core::vector3df(0,0,0)); - //irr::scene::ICameraSceneNode* cam = smgr->addCameraSceneNodeFPS(0,10,10); - //irr::scene::ICameraSceneNode* cam = smgr->addCameraSceneNode(0, core::vector3df(0,50,30), core::vector3df(0,0,0)); - //cam->setUpVector(irr::core::vector3df(0,1,0)); - - - btCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration(); - btBroadphaseInterface* pairCache = new btDbvtBroadphase(); - btDispatcher* dispatcher = new btCollisionDispatcher(collisionConfiguration); - btConstraintSolver* constraintSolver = new btSequentialImpulseConstraintSolver(); - btDiscreteDynamicsWorld* physicsWorld = new btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver,collisionConfiguration); - - btLogicManager* logicManager = new btLogicManager(); - - - //#ifdef SWAP_COORDINATE_SYSTEMS - physicsWorld->setGravity(btVector3(0,0,-10)); - //#endif //SWAP_COORDINATE_SYSTEMS - - #ifdef TEST_ECHO_BLEND_READER - - int fileLen; - char*memoryBuffer = btReadBuffer(file,&fileLen); - - - - - - // char* copyBuf = (char*) malloc (fileLen); - - // for (int i=0;i<10;i++) - { - // memcpy(copyBuf,memoryBuffer,fileLen); - - - IrrBlendNew bulletBlendReaderNew(device,smgr,physicsWorld,logicManager); - if (!bulletBlendReaderNew.readFile(memoryBuffer,fileLen,verboseDumpAllTypes)) - { - { - bool ignoreCase=false; - bool ignorePath=true; - bool result = device->getFileSystem()->addFileArchive(fileName,ignoreCase,ignorePath); - irr::io::IReadFile* zipfile = device->getFileSystem()->createAndOpenFile(fileName); - if (zipfile) - { - char* uncompressedBuf = (char*)malloc (zipfile->getSize()); - int readbytes = zipfile->read(uncompressedBuf,zipfile->getSize()); - if (!bulletBlendReaderNew.readFile(uncompressedBuf,readbytes,verboseDumpAllTypes)) - { - printf("Can't open compressed .blend file (%s), please submit an issue in http://gamekit.googlecode.com and attach .blend file\n",fileName); - exit(0); - } - } - else - { - printf("Can't open .blend file (%s) please submit an issue in http://gamekit.googlecode.com and attach .blend file\n",fileName); - exit(0); - } - - } - } - - bulletBlendReaderNew.convertAllObjects(verboseDumpAllBlocks); - - //#define TEST_FILE_WRITING 1 - #if TEST_FILE_WRITING - bulletBlendReaderNew.writeFile("test.blend"); - bulletBlendReaderNew.writeFile("test2.blend"); - - - - FILE* fileTest = fopen("test2.blend","rb"); - int fileLenTest; - char*memoryBufferTest = btReadBuffer(fileTest,&fileLenTest); - IrrBlendNew bulletBlendReaderNewTest(device,smgr,physicsWorld,logicManager); - if (!bulletBlendReaderNewTest.readFile(memoryBufferTest,fileLenTest,verboseDumpAllTypes)) - { - printf("Failing reading back written test.blend\n"); - } - #endif - - - - - - } - - - - - fseek(file, 0, SEEK_SET); /* seek to start */ - - - #else - - IrrlichtBulletBlendReader bulletBlendReader(device,smgr,physicsWorld,logicManager); - if (!bulletBlendReader.readFile(file,verboseDumpAllTypes)) - { - printf("cannot read Blender file %s.\n",argv[1]); - fclose(file); - exit(0); - } else - { - bulletBlendReader.convertAllObjects(verboseDumpAllBlocks); - } - #endif //TEST_ECHO_BLEND_READER - - - // add ambient lighting when converted scene contains zero lights - if(smgr->getSceneNodeFromType(irr::scene::ESNT_LIGHT) == NULL) - { - scene::ILightSceneNode* light1 = - smgr->addLightSceneNode(0, core::vector3df(0,0,0), - video::SColorf(1.0f, 1.0f, 1.0f, 0.0f), 45.f); - - light1->setLightType(irr::video::ELT_DIRECTIONAL); - light1->setRotation(irr::core::vector3df(90.0f, 0.0f, 0.0f)); - smgr->setAmbientLight(video::SColor(0,20,20,20)); - } - - /* - Now draw everything and finish. - */ - u32 frames=0; - - //comment-out next line for batch testing - -#ifndef BATCH_UNIT_TESTING - while(device->run()) -#endif //BATCH_UNIT_TESTING - { - - static int ms = device->getTimer()->getTime(); - int newTime = device->getTimer()->getTime(); - int deltaTimeMs = newTime-ms; - ms = newTime; - btScalar deltaTime = deltaTimeMs*0.001f; - - - if (!gPause) - physicsWorld->stepSimulation(deltaTime); - - - driver->beginScene(true, true, video::SColor(0,100,100,100)); - - logicManager->processLogicBricks(deltaTime); - - smgr->drawAll(); - - driver->endScene(); - if (++frames==100) - { - core::stringw str = L"GameKit http://gamekit.googlecode.com (Bullet+Irrlicht) ["; - str += driver->getName(); - str += L"] FPS: "; - str += (s32)driver->getFPS(); - str += L" (press q to quit)"; - - device->setWindowCaption(str.c_str()); - frames=0; - } - - - } - - - device->drop(); - } - return 0; -} - diff --git a/gamekit/momo_ogreSmallAnim.blend b/gamekit/momo_ogreSmallAnim.blend deleted file mode 100644 index 5559fa66c..000000000 Binary files a/gamekit/momo_ogreSmallAnim.blend and /dev/null differ diff --git a/gamekit/readblend.h b/gamekit/readblend.h deleted file mode 100644 index 01a47644f..000000000 --- a/gamekit/readblend.h +++ /dev/null @@ -1,494 +0,0 @@ -/*************************************************************** - * readblend.h -- - * ReadBlend, a data extraction API for Blender's .blend files - * - * (c) 2003 Adam D. Moss <adam@gimp.org> <aspirin@icculus.org> - * - */ - -/* VERSION HISTORY - * 2003-04-05 : v1.0 - * 2008-10-05 : v1.1-beta - */ - -/* Blender files are 'curiously' structured and this is mirrored in - * the low-level data access API (the section labelled 'Low-level - * querying functions'). - * - * The mid-level data access API (the section labelled 'Mid-level - * querying functions') tries to provide some handy utilities to - * ease your data-extraction pain, and finally the (partially written) - * high-level data access API incorporates semantic knowledge of Blender's - * useful high-level types such as Meshes and Materials to shield you - * from the full horror. - */ -#ifndef _READBLEND_H -#define _READBLEND_H - -#include <stdlib.h> -//#include <stdint.h> -#include <math.h> -#include <stdlib.h>//size_t for MSVC 6.0 - -//#include <cfloat> -#include <float.h> - -#include "abs-file.h" - -/* TODO: Doxygen me. */ - - -#include "blendtype.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -struct BlendBlock; - -/**************************************/ -/* .blend handle load/free functions */ -/*************************************/ - - -/* Pass in an already-opened file handle; this function will then - examine the file to check that it is a Blender file and scan the - entire file to extract all vital information (quite expensive) - before any query operations can be performed. The resulting - .blend data handle is returned. -*/ - -struct BlendFile* blend_read(MY_FILETYPE* file); - - -/* Free all of the given BlendFile data (note: obviously, do not attempt - to extract data from a BlendFile which has been freed!) */ - -void blend_free(BlendFile* blend_file); - - -/********************************/ -/* Public data querying types */ -/********************************/ - - -/* heed this enum well. */ -typedef enum { - /* you're unlikely to encounter these in the wild. */ - BLEND_OBJ_NULL, - BLEND_OBJ_OPAQUE, - - /* these object types are fetchable as-is */ - BLEND_OBJ_UCHAR8, - BLEND_OBJ_CHAR8, - BLEND_OBJ_USHORT16, - BLEND_OBJ_SHORT16, - BLEND_OBJ_ULONG32, - BLEND_OBJ_LONG32, - BLEND_OBJ_FLOAT, - BLEND_OBJ_DOUBLE, - BLEND_OBJ_POINTER, - - /* you'll need to extract the fields from these individually */ - BLEND_OBJ_STRUCT -} BlendObjType; - - - -/* note: treat this as an opaque type and you'll live longer. */ -typedef struct { - long type; long name; BlendBlock * block; - long entry_index; long field_index; -} BlendObject; - - -/* The callback type for passing to blend_foreach_block() (the callback - should return zero if it doesn't want to see any more blocks.) */ -#define BLENDBLOCKCALLBACK_RETURN int -#define BLENDBLOCKCALLBACK_ARGS BlendBlock * block, \ - BlendFile* blend_file, \ - void* userdata -typedef BLENDBLOCKCALLBACK_RETURN(BlendBlockCallback) - (BLENDBLOCKCALLBACK_ARGS); - - -/********************************/ -/* File info dumping functions */ -/********************************/ - -/* these functions simply print dumps of information about the given - BlendFile. These are vital for familiarising yourself with the - structure of Blender's various scene objects if you're using the - low/mid-level APIs to construct queries to extract information about - specific types of objects that haven't been conveniently abstracted by - the high-level API yet. (That is, most of them right now, particularly - the more obscure or deprecated ones.) */ - -/* print out the size, field-types and field-names of all of the varieties - of types (atomic and struct) represented within this BlendFile. The - sizes are the in-file representations; the in-memory representations - are potentially subject to additional padding and conversions. -*/ -void blend_dump_typedefs(BlendFile* bf); - -/* For every top-level block of data in the file, print the block's - tag, its in-memory address, its type, and the number of entries of that - type. (Every pointer in a structure should point to one of these - in-memory block addresses because we convert from in-file pointers to - in-memory pointers automagically; a few in-file pointers within structures - do actually point somewhere into the middle of a block or nowhere, which we - don't currently support and silently convert to NULL.) Also, any structs - at the top-level with an id->name have that name printed out. */ -void blend_dump_blocks(BlendFile* bf); - - -/********************************/ -/* Low-level querying functions */ -/********************************/ - - -/* Calls the user-supplied callback function for every top-level - data block in the .blend file. You can use this to count blocks - (which is pretty pointless) or search for a particular block you're - interested in. */ -void blend_foreach_block(BlendFile* blend_file, - BlendBlockCallback* func, - void* userdata); - -/* Returns the tag-name ('IM', 'DATA', 'ME', etc) for the given - top-level data block. */ -const char* blend_block_get_tagname(BlendFile* blend_file, - BlendBlock * block); - -/* Returns the type of the given top-level data block in raw - string form ('uchar', 'float', 'MFace', 'Mesh', etc). */ -const char* blend_block_get_typename(BlendFile* blend_file, - BlendBlock * block); - -/* Translate a pointer from the file's raw data into a BlendBlock * - that you can query via the API. You will usually NOT need to ever - use this unless you're manually extracting pointers from opaque raw data - types. Returns NULL on failure or if the input pointer is really NULL. */ -BlendBlock * blend_block_from_blendpointer(BlendFile *blend_file, - uint32_t blendpointer); - -/* Returns the number of entries there are in the given top-level - data block (a top-level data block is like an array of entries of a specific - Blender type, this type usually being one of Blender's structs). */ -int blend_block_get_entry_count(BlendFile* blend_file, - BlendBlock * block); - -/* This gets an object handle on the Nth piece of data (in the range - 0..TOTAL-1, where TOTAL is the figure returned by - blend_block_get_entry_count() ) in the given top-level block. */ -BlendObject blend_block_get_object(BlendFile* blend_file, - BlendBlock * block, - int entry_index); - -/* Returns a BlendObjType enum handy for checking that the general type - of the object you have a handle on is what you're expecting. */ -BlendObjType blend_object_type(BlendFile* blend_file, - BlendObject obj); - -/* Given a BlendObject of type BLEND_OBJ_STRUCT in 'obj', fill in the - BlendObject pointed to by 'result' with a handle to the named - field of that structure (note that the resulting data object might - itself be a structure!). 0 is returned on failure (i.e. this structure - does not have a field of the requested name, or you supplied an - object which is not a structure). */ -int blend_object_structure_getfield(BlendFile* blend_file, - BlendObject *result, - BlendObject obj, - const char* field_name); - -/* Gets the size (in elements) of an object which is a 1D or 2D array. - A non-array is equivalent to an array of size 1x1. A 1D array will - always have dim1 == 1. */ -void blend_object_array_getdims(BlendFile* blend_file, - BlendObject obj, - int* dim1, int* dim2); - -/* This fetches a piece of data from the .blend file in a format - suitable for your architecture (i.e. ints will be of proper size - and endianness, pointers are transformed to valid BlendBlockPointers - or NULL, etc) into the address pointed to by dest. It's up to you to - check that the data you're asking for will fit into the type you're - trying to put it in (use blend_object_type() and see the BlendObjType - enum to check that the object's type is the one you're expecting.) - - Composite structures (BLEND_OBJ_STRUCT) are not handled atomically; - use blend_object_structure_getfield() to extract each named field from - a structure individually. - - 1 is returned on success. Failure occurs when you try to extract - data from a structure (see blend_object_structure_getfield()) or - an array (use blend_object_array_getdata()). -*/ -int blend_object_getdata(BlendFile* blend_file, - void* dest, BlendObject obj); - -/* This operates like blend_object_getdata() except that it is happy - to copy an item of data out of an array. The array is always treated - as two-dimensional (data[dimension1][dimension2]); if you're accessing - a one-dimensional array then simply specify dim_index_1 as 0. - (Indices are in the range 0..DIMSIZE-1.) - - Similarly, plain non-array data can be fetched by specifying - dim_index_1 == dim_index_2 == 0. This makes - blend_object_array_getdata(bf, dest, obj, 0, 0) equivalent to - blend_object_getdata(bf, dest, obj) except that it is happy to - be called with an array, from which it will extract the first - element. - - Like blend_object_getdata(), it will not fetch a structure (from - an array of structures; fortunately I've not seen a .blend file - featuring an array of structures so we'll bridge that API gap - when we come to it). - */ -int blend_object_array_getdata(BlendFile* blend_file, - void* dest, BlendObject obj, - int dim_index_1, int dim_index_2); - -/********************************/ -/* Mid-level querying functions */ -/********************************/ - -typedef unsigned long BlendLayerMask; - -/* extract a string from a char-array or uchar-array object, up to - max_chars in length including the \0 terminator. If the object is - a two-dimensional array then the first string is extracted. Returns - 0 on failure. -*/ -int blend_object_getstring(BlendFile* blend_file, - BlendObject obj, - char *dest, int max_chars); - -/* Searches the file for a top-level object with the given ID name. - Typical ID names are 'OBCamera', 'MECircle.003', 'MAplastic', 'TEgrass' etc. - The first two characters of an ID name keep the namespaces separate, - so that a material (MA) with the name 'metal' is distinguishable from - a texture (TE) with the name 'metal'. That's a foible of Blender itself. - - blend_object_get_by_IDname() returns 0 on failure. It only returns one - object of the given IDname; there should indeed be only one, as Blender - enforces this uniqueness. - */ -int blend_object_get_by_IDname(BlendFile* blend_file, - BlendObject *result, - const char* IDname); -/* get string from [obj].ID.name -- caller allocs/frees */ -int blend_object_get_IDname(BlendFile* blend_file, - BlendObject obj, - char *dest, int max_chars); - -/* returns !0 if the blender Object whose handle is objobj is a top-level - object -- that is, it's not a child of another Object. */ -int blend_obj_is_rootobject(BlendFile *bf, BlendObject *objobj); -/* return the layers (bitmask) that an Object lives on. */ -BlendLayerMask blend_obj_get_layermask(BlendFile *bf, BlendObject *objobj); - -/* These functions can be a bit slow -- each one requires a linear scan - of the file's blocks. But they're handy... */ -/* Return number of children that this Object has. Can be 0. */ -int blend_obj_get_childcount(BlendFile *bf, BlendObject *objobj); -/* Gets child number childnum of the Object. childnum=0 returns - the first, childnum=1 returns the second, etc. */ -BlendBlock * blend_obj_get_child(BlendFile *bf, BlendObject *objobj, - int childnum); - -/*********************************/ -/* High-level querying functions */ -/*********************************/ - -typedef struct { - int bone_id; - float weight; -} bDeformWeight; - -typedef struct { - float xyz[3]; - float cnormal[3]; /* cosmetic normal */ - int mat; - bDeformWeight* deform_weights; - int deform_weights_count; -} bVert; - - -#define BVERT_HAS_CNORMAL(BV) ((BV)->cnormal[0] != 0.0f || \ - (BV)->cnormal[1] != 0.0f || \ - (BV)->cnormal[2] != 0.0f) - -#define BFACE_FLAG_SMOOTH 0x01 - -typedef struct _bImage { - - void* m_packedImagePtr; - int m_sizePackedImage; - char m_imagePathName [128]; - - int m_ok; - - int m_xrep; - int m_yrep; - -} bImage; - -typedef struct { - int v[4]; - float rgba[4][4]; /* vertex colours */ - float rgba2[4][4]; /* texture face colours (errrr...?) */ - float uv[4][2]; - bImage* m_image; - int mat; - unsigned char flags; - int m_flag; - int m_mode; - BlendBlock * image_id; -} bFace; - - -#define BFACE_HAS_TEXTURE(BF) ((BF)->image_id != NULL) -#define BFACE_IS_QUAD(BF) ((BF)->v[3] != 0) -#define BFACE_IS_TRI(BF) ((BF)->v[2] != 0 && (BF)->v[3] == 0) -#define BFACE_IS_LINE(BF) ((BF)->v[1] != 0 && (BF)->v[2] == 0) - -typedef enum { - BTEX_AFFECT_COLOUR = 0x01, - BTEX_AFFECT_ALPHA = 0x02, - BTEX_AFFECT_EMIT = 0x04, - BTEX_AFFECT_NORMAL = 0x08, - BTEX_AFFECT_NEGNORM = 0x10, - BTEX_AFFECT_STENCIL = 0x20 /* not really an 'affect' in blender, but it is */ -} bTexLayerAffects; - -typedef enum { - BTEX_BLEND_NORMAL, /* 'mix' */ - BTEX_BLEND_MULTIPLY, /* 'mul' -- modulate. */ - BTEX_BLEND_ADD, - BTEX_BLEND_SUB -} bTexLayerBlendmode; - -typedef enum { - BTEX_COORDS_NONE, - BTEX_COORDS_UV, - BTEX_COORDS_REFLECT -} bTexLayerCoordsType; - -typedef enum { - BIMG_FLAG_INTERPOLATE = 0x01, /* upsample */ - BIMG_FLAG_ANTIALIAS = 0x02, /* downsample */ - BIMG_FLAG_MIPMAP = 0x04 /* use mipmaps */ -} bTexImageFlags; - -typedef struct { - char *filename; /* image file name -- absolute path! -- NULL if not image. */ - int affects_mask; - int blend_mode; - bTexLayerCoordsType coords_type; - /* Tex substruct */ - int is_st_clamped; /* otherwise, repeat... (GL texwrap mode.) */ - int flags; - short Nflags, Ntype; /* not decoded yet */ - short xrepeat, yrepeat; /* amounts to scale texcoords by, really */ -} bTexLayer; - -typedef enum { - BMAT_FEATURE_VCOLLIGHT = 0x01, - BMAT_FEATURE_VCOLPAINT = 0x02, - BMAT_FEATURE_TEXFACE = 0x04, - BMAT_FEATURE_SHADELESS = 0x08, - BMAT_FEATURE_WIRE = 0x10 /* wireframe rendering */ -} bMatFeatureMask; - -#define BLENDER_MAX_TEX_LAYERS 8 -typedef struct { - bTexLayer *tex_layer[BLENDER_MAX_TEX_LAYERS]; - //bMatFeatureMask feature_mask; - int feature_mask; - float colour_rgba[4]; /* main material colour */ - float emit; /* emissive strength, 0..1 */ -} bMaterial; - -typedef float bMatrix[4][4]; - -typedef struct _bMesh{ - bVert *vert; - int vert_count; - bFace *face; - int face_count; - bMaterial *material; /* or NULL if none */ -} bMesh; - -typedef enum { - BOBJ_TYPE_UNKNOWN, - BOBJ_TYPE_NULL, /* indicates object has no data associated with it! */ - BOBJ_TYPE_MESH, - BOBJ_TYPE_INVALID_MESH, - BOBJ_TYPE_CAMERA, - BOBJ_TYPE_LAMP -} bObjType; - -typedef enum { - BAQ_INCLUDE_CHILDREN = 0x0001 -} bAcquireFlags; - -typedef struct _bObj{ - bObjType type; - char *name; - - bMatrix transform; /* local transformation matrix */ - bMatrix parentimat; /* parent's inverse transform matrix */ - float scaling[3]; /* scaling component of transform */ - float rotphr[3]; /* pitch/head/roll rotation component of transform (use for normals) */ - float location[3]; /* location component of transform */ - unsigned char transflags; /* NOT DECODED YET, RAW BYTE */ - float mass;//used for rigid body dynamics - int gameflag; //used to detect object type (static, ghost, dynamic, rigid body, soft body) - int boundtype; //used to detect collision shape type - - union { - void *dummy; - bMesh *mesh; - } data; - -} bObj; - - -bObj *blend_alloc_obj(void); -void blend_init_obj(bObj *obj); -void blend_free_obj(bObj *obj); -void blend_free_obj_inner(bObj *obj); -void blend_acquire_obj_from_obj(BlendFile *bf, BlendObject *objobj, - bObj *outobj, - /* malloc'd BlendObject will be written here if pointer if non-NULL: */ BlendObject **outblendobject); - -bMesh *blend_alloc_mesh(void); -void blend_init_mesh(bMesh *mesh); -void blend_free_mesh_inner(bMesh *mesh); -void blend_free_mesh(bMesh *mesh); -void blend_acquire_mesh(const char *fname, const char *want_name, bMesh *mesh); -void blend_acquire_mesh_from_obj(BlendFile *bf, - BlendObject *meobj, - bMesh *mesh); -/* apply transformation found in 'obj' to 'mesh' */ -void blend_transform_mesh_from_obj(bMesh *mesh, bObj *obj); - -bMaterial *blend_alloc_material(void); -void blend_init_material(bMaterial *mat); -void blend_free_material(bMaterial *mat); -void blend_acquire_material_from_obj(BlendFile *bf, BlendObject *meobj, - bMaterial *mat); - -bTexLayer *blend_alloc_texlayer(void); -void blend_init_texlayer(bTexLayer *tl); -void blend_free_texlayer(bTexLayer *tl); -void blend_acquire_texlayer_from_obj(BlendFile *bf, BlendObject *tlobj, - bTexLayer *tl); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/irrlicht-1.6/CMakeLists.txt b/irrlicht-1.6/CMakeLists.txt deleted file mode 100644 index 30033c160..000000000 --- a/irrlicht-1.6/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -cmake_minimum_required(VERSION 2.4) - -PROJECT(IRRLICHT) - -SET(IRRLICHT_VERSION 1.6) - -IF (NOT CMAKE_BUILD_TYPE) -# SET(CMAKE_BUILD_TYPE "Debug") - SET(CMAKE_BUILD_TYPE "Release") -ENDIF (NOT CMAKE_BUILD_TYPE) - - - IF(COMMAND cmake_policy) - cmake_policy(SET CMP0003 NEW) -ENDIF(COMMAND cmake_policy) - - -# This is the shortcut to finding GLU and OpenGL if they are properly installed on your system -# This should be the case. - -FIND_PACKAGE(OpenGL) -IF (OPENGL_FOUND) -MESSAGE("OPENGL FOUND") -MESSAGE(${OPENGL_LIBRARIES}) -ELSE (OPENGL_FOUND) -MESSAGE("OPENGL NOT FOUND") -SET(OPENGL_gl_LIBRARY opengl32) -SET(OPENGL_glu_LIBRARY glu32) -ENDIF (OPENGL_FOUND) - -# ADD_DEFINITIONS(-DBT_USE_FREEGLUT) - -FIND_PACKAGE(GLU) - - - -SUBDIRS(source) diff --git a/irrlicht-1.6/changes.txt b/irrlicht-1.6/changes.txt deleted file mode 100644 index 710418a93..000000000 --- a/irrlicht-1.6/changes.txt +++ /dev/null @@ -1,3174 +0,0 @@ -Changes in version 1.5 (15.12.2008) - - - Construction calls for FPS camera changed to take speed in units/milliseconds, just as the setSpeed method does. - - - Code::Blocks workspaces added. C::B projects (using gcc) now output to /lib/gcc and /bin/gcc, when built on either Windows or Linux. - - - Added a test suite in the /tests directory. This can be used to perform regression tests, and should be updated with new tests to verify fixes or validate new features. - - - Changed the preferred way of altering light node's radius: Use the new member methods of ILightSceneNode instead of directly modifying the SLight structure. - - - Changed the initial attenuation back to (0,1/radius,0). To override this value simply change the attenuation in the SLight (lightnode->getLightData().Attenuation.set(x,y,z)) - - - Dirty fix for OSX device setResizable and a bug fix to do with resizing the device. - - - Terrain heightmap and texture were flipped in order to draw them as expected (looking onto the terrain from high above will just look like the actual texture/heightmap). - - - Significant internal change to the way that FPS camera jump speed and collision response animator gravity interact. The behaviour is now much more realistic, but it will require you to adjust your jump speed and gravity. - - - Skybox won't be culled anymore by nearplane or farplane. - - - BBoxes of animated meshes (skinned meshes) are updated again. - - - Lost devices (as found with D3D) are properly handled now. So the screen can be resized or minimized without crashing the app. - - - Renamed IGUIElement::setRelativePosition(const core::rect<f32>& r) to IGUIElement::setRelativePositionProportional(), as it has radically different functionality from setRelativePosition(const core::rect<s32>& r) - - - Added IGUIElement::setRelativePosition(const core::position2di & position) to set a new position while retaining the existing height and width. - - - Many Collada fixes. z_up coords are supported now, texture coords are properly loaded. Transparency is supported. - - - Camera scene node rotation and target can now be bound together so that changing one automatically changes the other (as the FPS camera has always done). See ICameraSceneNode::bindTargetAndRotation() - - - Removed the extra libpng files for OSX. OSX now also uses the default libpng. - - - Enhanced PCX support with some more color formats and write support. - - - Fixed LMTS problems with extra data in files. - - - Removed VS6 .dsw / .dsp project files - VS6 is no longer supported. - - - Particles can be scaled during animations. Particle scaling needs to happen in the emitter now, instead of in the Particle system scene node. Deprecation methods will guide the user. - - - ISceneNode::setParent and addChild now updates node SceneManager pointers if the node was from another SceneManager. - - - Basic support for joystick input events on Windows, Linux, SDL and OSX. Tested with wired Logitech and Thrustmaster wired controllers and XBox 360 wireless controller ( http://tattiebogle.net/index.php/ProjectRoot/Xbox360Controller/OsxDriver ) - - - Fixed scaled octree nodes being incorrectly frustum culled. - - - FSAA under OpenGL and Win32 added. Now all hw drivers and platforms should support it. - - - Unlimited RTT fix for D3D systems. Depth buffers are now shared if possible, otherwise a new depth buffer is generated. In order to save VidMem one should create RTTs starting with the largest one. - - - Avoid RTTs with nonFBO-support under OpenGL which are larger than the screen. Since we rely on rendering into textures in this case we need to clamp the size by the screensize. - - - Fixes for getAbsoluteFilename under Linux in order to return a filename instead of en empty string in case the file doesn't exist. - - - Use absolute path names when creating / finding textures. - - - Font tool implementation for Linux with xft, by Neil Burlock. - - - Support for normals and UV coords from DeclData in .x files. - - - Modified line2d<T>::intersectWith() to cover more cases. - - - Added IVideoDriver::drawPixel(). - - - Moved the window pointer from endScene to beginScene, as this is required for OpenGL support of external window pointers. - - - Fix for terrain culling. - - - Added minimize button to win32 window (if resizable) - - - Major API change: RTTs are now created via addRenderTargetTexture instead of createRenderTargetTexture, which allows to retrieve them from the texture cache, but also changes the way of removing the RTTs, and especially one must not drop the pointer anymore. - - - WindowsCE-Bugfix - - - disableFeature can be used to override feature support of the video driver. - - - draw2DImage can now also handle RTTs under OpenGL (which were flipped before). - - - Ogre mesh format fixes for proper texture support. - - - Added .obj mesh writer. - - - Some core::string constructors made explicit to avoid unintended conversions. Just add core::stringc() or core::stringw() around the old code to avoid warnings. - - - IdentityMatrix is now a properly defined global, with external visibility on all platforms. - - - Bugfix for context releases with glx 1.3 on error. - - - Removed constraints for sizes of the terrain scene node. - - - Support for 32bit indices in a special MeshBuffer class. - - - isBetweenPoints return true now even for the begin and end points, i.e. line segments are now including their start and end. - - - Fix XML reader creation for non-existing files and invalid callbacks. - - - Changed interpretation of MaterialTypeParam==0 in transparent materials. Now it's consistent with all other values, but one has to set the value to 0.5 to get the old behavior (slightly faster rendering, but no smooth borders) - - - Replaced transformBox by transformBoxEx in some internal methods to avoid major malfunction of the transformations. - - - Fix use of zip file inside zip files. - - - Avoid loading textures which are not used by the mesh in b3d loader. - - - Added scaleTCoords methods to MeshManipulator - - - Enable use of other meshes for shadow mesh generation, can be used to speed up shadow generation and rendering for complex meshes. Patch based on a version by tonic. - - - Fixed usage of SIrrCreationParameters struct, which dind't have copy constructor and assignment operator anymore, since the Irrlicht version string was made const. - - - New glext.h (version 41) and glxext.h (version 20) supporting OpenGL 3.0 - - - Added support for read-only locking of textures. Can speed up those calls. - - - Added support for locking RTTs under OpenGL. - - - Implementation of UserData events from system events. - - - ICameraSceneNode::setIsOrthogonal replaced by a parameter to setProjectionMatrix. - - - All meshbuffers are now dynamically allocated to avoid problems with grabbed buffers, which may be deleted before the last drop happens (due to static memory allocation). - - - Enhanced scene graph traversal with example from rogerborg. - - - FPS camera disabling of event receiver works better now. - - - scene deserialization allows for a user defined callback after a new scene node is created. - - - Fixed tangent mesh loading from .irrmesh files. - - - OpenGL clamp modes are now properly set. - - - IMeshManipulator::transformMesh renamed to transform, also supports meshbuffers now. - scaleMesh renamed to scale, supports meshbuffers as well. - - - vector3d::rotationToDirection added. - - - New mesh generators for cone and cylinder. - - - Hardware accelerated Vertex and Index Buffer support finally integrated into Irrlicht. Thanks to a resource handling idea by Klasker and the almost immediate implementation by Luke, Irrlicht now supports VBOs under OpenGL and D3D. - Hardware buffers make rendering the same vertices much faster. To use this feature with a mesh, simply set a usage type via MeshBuffer->setHardwareMappingHint(scene::EHM_STATIC). The driver will upload the vertices and indices on the next draw and reuse this information without the need to upload it each frame. - Vertex and Index buffers can also be updated separately, which is e.g. useful for the terrain node's LOD. - - - Changed FBO creation according to Nadro's patch. Seems to have zbuffer problems currently. - - - Update to libpng 1.2.29 - - - Compiler flag for PerfHUD support added. - - - recalculateNormals and tangent space creation enhancements by ryanclark. - - - Added getColorFormat methods for device and driver, returning the color format of the device's window and the driver's framebuffer. - - - Added isFullscreen method. - - - Added isWindowFocused and isWindowMinimized methods. - - - Screenshots are now always made from the frontbuffer, so always the last completely rendered image is captured. However, overlapping windows may corrupt those parts of the screenshot (as was previously happening with d3d already). - - - New device creation parameter to disable Irrlicht's system event handling. - - - New device creation parameter to specify depth bits. - - - New device creation parameter to request alpha channel in framebuffer. - - - Draw2DImage methods under OpenGL now also handle RTTs correctly. - - - Fixed RTT bug which lead to strangely clamped textures. - - - Speed improvement for screenshots on some Intel cards under OpenGL. - - - My3D file loader fixed. - - - Terrain mesh performance increased. - - - Fixed mem leak in cube node. - - - Compiler errors in shaders won't corrupt the material renderer list anymore. - - - Quake3 shader files now have properly working texture matrices again. - - - FPS and Maya style cameras are now standard cameras with a special animator. - - ISceneNodeAnimator now inherits IEventReceiver - - New method ISceneNodeAnimator::isEventReceiverEnabled, returns false by default - - CCameraSceneNode::OnEvent passes events to animators with enabled event receivers - - ISceneNodeAnimatorCameraFPS and ISceneNodeAnimatorCameraMaya interfaces for changing camera settings at run-time. - - - Changed SExposedVideoData to use void* instead of s32. Fixed 64bit portability. - - - Added support for front face culling. - - - Fix for HLSL shaders in one file. - - - Billboard::setColor bug fix by rogerborg. - - - Scene node sorting uses squared distances now. - - - Enhanced API for hte math functions. Many of them will now return a reference to *this for chained method invocations. - - - prevent .x loader to load .xml files. - - - AntiAlias support for OSX device. - - - Period character handling bug fixed. - - - New filesystem methods for filename handling. - - - added getVideoModeList and getDesktopResolution support for OSX - - - Octree supports tangent meshes now. Some performance improvements for the generation. - - - Fix mouse pointer and fullscreen mode problems in OSX. - - - Make cube and sphere scene node a mesh scene node (for access to the cube/sphere mesh). - - - Support for normal maps in 3ds files. Mem leak fixed. Loading for files with keyframe data fixed. - - - BillboardTextSceneNode is now an IBillboardSceneNode and an ITextSceneNode. - - - Support for external windows under Linux. - - - .X loader bug fixes. - - - Better debug visualization for MeshSceneNodes. - - - Fixed bug in material serialization when using the NullDriver. - - - Fix for Win32 CursorControl::setVisible - - - Support for LWO files. - - - Support for Collada 1.4 files. - - - Better and faster terrain smoothing by Frosty Topaz. - - - Fixed a performance bug in ISceneNode constructor reported by izhbq412 - - - Win32 device now makes the cursor invisible immediately when setVisible(false) is called. - - - Command line tool for mesh conversion added. - - - Added volume light scene node - - - .obj files now won't duplicate vertices unnecessarily. This allows recalculation of smooth normals and other things, and is also faster when rendering. The loading is a little slower now. - They also support normal maps and texture clamping now. Group support added, can be ignored via scene manager attribute scene::OBJ_LOADER_IGNORE_GROUPS. - Normals will be calculated if the file doesn't provide them. - - - Better fix for hires timers on dual core machines by RogerBorg - - - added Initial Windows Mobile 6 Version. - - Windows Mobile 6 SDK - - Visual Studio 2005 - - - Added checks to avoid buffer overrun in b3d loader. Enabled normals calculation in all cases, previously it was not done for lightmapped meshes. - Fixed transparency support. Added mipmap creation flag support which might disable mipmap creation too often. Should be checked. - - - Burningvideo: MipMap Selection repaired - - - renamed private Driver function getTextureSizeFromImageSize to getTextureSizeFromSurfaceSize - - - Added collision manager speedup patch by RogerBorg. - - - D3D drivers now releases the IImage member from initialization, thus freeing lots of memory. The image is accessible via the driver anyway. - - - SDL device character handling enhanced. - - - MeshBuffers can now access the elements of the S3DVertex base class in all vertex types directly, instead of using the getVertices() pointer access. This simplifies simple mesh manipulations as it does not require a switch statement over all vertex types. - - - More OpenGL renderstate bugs fixed - - - GLSL changes for setting arrays. Also allow for only pixel or vertex shader to be set. - - - Bugfix for removeChild in AnimatedMeshSceneNode. - - - Some bugfixes for Joint handling and skinned meshes. Added getJointCount in IAnimatedMeshSceneNode and isStatic in ISkinnedMesh. - - - Added WAL image format support based on the original loader by Murphy McCauley, written for Irrlicht around version 0.7. - - - OpenGL RTTs now also support alpha values. - - - New method driver->getVendorInfo() to query information about the actual hardware driver. - - - Fixed somed CQuake3ShaderSceneNode problems. - - - Changed BurningsVideo internal Vertex Format. version changed to 0.39 - - - SceneManager: - Removed the seperate rendering states for quake3 Shader Scene Nodes. - Nodes are now solid or transparent. ( but still more states are needed ) - - - GUI: - - - Editbox didn't draw children - - Checking IsEnabled is now consistent across all GUI elements - - Move window to front bug fixed. - - Disabling the BMP loader now compiles without the built-in font - - Added setTextAlignment to IGUIComboBox - - Avoid dropping skin pointer which is in use. - - Better warning for fonts without regions (sometimes wrong file is loaded by the user). - - Fixed a bug in CGUISpriteBank which caused a crash when a non-looping animated sprite reached the end of its animation. - - Modal screens no longer flash invisible children when rejecting a focus change. - - Finally added StarSonata patch with table element and TabControl additions. Table is based on MultiColor listbox by Acki, and has loads of changes by CuteAlien. - -------------------------------------------- -Changes in version 1.4.2 (22.9.2008) - - - Unified the handling of zwrite enable with transparent materials on all hw accelerated drivers. This means that all transparent materials will now disable ZWrite, ignoring the material flag. - There is a scene manager attribute, though, which will revert this behavior to the usual SMaterial driven way. Simply call - SceneManager->getParameters()->setAttribute(scene::ALLOW_ZWRITE_ON_TRANSPARENT, true) and set the SMaterial flag as desired. - - - Some changes for texture matrices in q3 shaders. - - - Added BlindSide's irrAllocator patch for proper TextureMatrix release under Win32 with any CRT library. - - - Added VC9 project files. - - - Added getEmitter for particle system scene nodes. - - - Fixed rounding problem in getScreenCoordinatesFrom3DPosition - - - Fixed Software renderer color flicker, was a shift bug I believe. - - - irrMap fix to make root node always black, by rogerborg. - - - Possible core dump fixed in particle system node, by CuteAlien. - - - Mem leak fixed in b3d loader. - - - Avoid double rendering of child nodes of joints. - - - Support for d3d draw2dimage clipping by CuteAlien. - - - Fixed an animation transition bug, pointed out by wuallen. - - - Fixed the major problem with OpenGL drivers, that claim to be 2.x compatible, but don't offer NPOT support (well, they do, but only in sw rendering...). Now we check for the extension string only. - - - Fixed .obj loader bug which inserted vertices in wrong buffers. - - - Fixed minor mem leak in Linux device. - -------------------------------------------- -Changes in version 1.4.1 (04 Jun 2008) - - - MD3 meshes are movable again. - - - New JPG image writer version by Vitek. - - - Texture matrix fixes, all methods should now work as expected. - - - Some container methods now return the this pointer after member functions have been called on them, in order to allow call chains. - - - Some new methods for SColorf access, for uniform API of all colors. - - - bug fix for SMaterialLayer equality check. Did only check the TextureMatrix pointers, instead of the matrices. - - - New getMesh method for the SceneManager, which takes an IReadFile instead of a filename. - - - Support for flags _WIN32 and _WIN64 in addition to WIN32 and WIN64 added, this simplifies usage of Irrlicht headers under MSVC. - - - Fixed a crash in GUIMeshViewer - - - new string method findLastChar by Halifax - - - GUIEditBox got the 1 pixel shift after click fixed. - - - Some debug visualization has been fixed for skinned meshes - - - Undef PI symbol before declaring core::PI to avoid compilation problems - - - SAnimatedMesh now properly returns properties of Meshes[0] if those exist, such that it should be usable in place of an SMesh again. - - - Fixed 2d initialisation in opengl and d3d9 driver. This should fix problems with render states mixing up and distrubing, e.g. skin effects. - - - Avoid a crash when passing setSkin the current skin - - - Fixed current frame calculation for non-looped animations. Bug reported by greenya. - - - Fixed bug in CBillboardSceneNode::setColor, reported by rogerborg - - - Fixed clipping of menu, toolbar and combo box GUI elements, reported by greenya - - setNotClipped now applies all the way up to the root of the GUI environment, rather than just to the next parent - - - Made new scene managers use the original manager's GUIEnvironment, reported by MasterGod - - - Fixed IGUICheckBox::setEnabled, reported by Dorth - - - Fixed the FollowSpline animator to avoid crashes when only one waypoint is given. - - - OpenGL VolumeShadow now uses glPolygonOffset to avoid zbuffer artifacts. - - - Fixed meshbuffer corruption in append methods. - - - Fixed mem leaks in irrArray. - - - Fixed minor bugs in ISceneNode and ISceneManager. - - - Fixed the MeshCache handling of GeometryCreator meshes. - - - Terrain LOD bugfix. - - - Some Collada 1.3 loader enhancements and bug fixes. - - - Fixed a bug in CGUISpriteBank which caused a crash when a non-looping animated sprite reached the end of its animation. - - - Enhanced the .obj loader with the patch from ryanclark. This allows for recalculation of smoothed normals of the mesh, also should decrease the tri count on some meshes. - - - Avoid the global Logger to be destroyed too early. - - - Function setbit was renamed to setbit_cond to avoid name clashes. - - - Fixed .x animations with multiple references to the same joint from different meshes. Fixed texture path problems. - - - Support for Milkshape 1.8 files, also with multiple weights per joint. - - - The config file now also supports _IRR_OSX_PLATFORM_ and _IRR_USE_OSX_DEVICE_. This allows to use the Linux device (X11 support) on OSX. - - - Avoid terrain scene node crash when heightmap cannot be loaded. - - - Speed improvements for WaterSceneNode. - - - FlyCircle animator now also works for upvectors (Direction parameter) which are not (0,1,0). Is also faster now, since most calculations are done on init. Thanks to Dorth for working on this. - - - The 3ds loader correctly creates a texture matrix when texture tiling properties are found in the file. - - - Fix for S3DVertex comparison operators. Used some wrong logic. - - - Bugfix getCurrentRenderTargetSize in D3D drivers. Due to signature differences a wrong virtual method was chosen. Thanks to Jiang for finding it. - -------------------------------------------- -Changes in version 1.4 (30 Nov 2007) - - - Major API change: All material properties which are available per texture layer (curently texture, texture matrix, texture filters, and texture wrap mode) are separated into a new struct SMaterialLayer. You can access them via the array TextureLayer[] in SMaterial. The texture matrix methods in SMaterial are still alive, and also textures can be accessed via methods in SMaterial now. But still, many places in user code need some update (usually changing material.Textures[i] to material.TextureLayer[i].Texture etc.) - - - Major API rewriting for proper const usage. Now, most getter methods are const and so are the larger parameters and return values. Moreover, many methods taking only unsigned numbers now use u32 instead of s32 in order to recognize this limitation from the method's signature. - - - the base class for nearly all Irrlicht classes has been renamed from IUnknown to IReferenceCounted - - - Fixed Skybox texture orientations. They are now displayed non-flipped. Existing skyboxes have to be changed, though: Exchange left and right texture. Textures from Terragen and other tools can be used directly, now. Quake maps will also need the right/left exchange. - - - Added ITexture::isRenderTarget() - - - 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 - extension .irrmesh. Irrlicht is able to write every IMesh to this file format, and of course to - read it back again. - - - Irrlicht is now able to write Meshes out into files. Use ISceneManager::createMeshWriter() - to obtain an interface with which you can write out meshes. Currently, an own .irrmesh - file format is supported as well as the COLLADA file format. - - - fixed the keyboard autorepeat difference betwenn Linux and Windows. Thanks to denton we now have only KeyPressed events on both systems in case of autorepeat. - - - Added several new particle emitters and affectors from IrrSpintz. Also some new getter and setter methods were added. - - - D3D transparent materials do not disable zbuffer writing automatically anymore. This has to be done by the user to keep those settings configurable. - - - OpenGL texture now also require a regenerateMipmapLevels() after unlocking. This is the same as for d3d devices now. - - - Point sprite support in the driver. Point sprites use just one 3d vertex and a size to create a textured billboard on the GPU. This can provide fast particle systems, especially in combination with shaders. The proper particle extension will follow later on as it needs some more refactoring. - - - OpenGL 2D drawing accuracy fix by tuXXX - - - Added OnResize and getCurrentRenderTargetSize to the software video drivers. - - - Added Spot light type for dynamic lights. Note that both position and direction for all dynamic lights are now determined by the LightSceneNode, the SLight attributes are only used for internal purposes. - API change! One can easily work around this change by setting the LightSceneNode's Position and Rotation instead of the SLight's. This change won't provoke a compile error, though, and can hence go unrecognized besides the visual problems. - The lights use a default direction (0,0,-1) which is rotated by the usual scene node transformations and can hence be modified by scene node animators. - A change in the Radius usage can lead to strange artifacts. Just increase the Radius in this case. further handling of Radius is to be discussed. - - - Added per pixel fog support for OpenGL. - - - Added driver support for user defined clip planes, based on mandrav's patch. - The OpenGL version is more picky about ModelView matrices, so it's best to set the projection plane at the time it is used. - - - .obj files now load relative indices correctly. Collada files load textures. - - - A new MeshBuffer implementation is publicly available. It supports a shared vertex list for all MeshBuffers, used for MS3D meshes. - - - MeshBuffers can recalculate their BoundingBoxes on their own now, no need for MeshManipulators. New append methods help to merge MeshBuffers. take care that the types match! - - - The new texture generation mode is working. With ETCF_NO_ALPHA_CHANNEL textures are generated without ALPHA bits reserved. - - - D3D9 hardware mipmap updates are re-enabled, problems should be reported. - - - In some cases fullscreeen modes under win32 should have a better frame rate now. - - - Fixed the hillplane mesh to work with non-quadratic dimensions as well. Changed the interface also, so use a u32 dimension to specify the tilecount now. - - - Hires timers are disabled on windows systems with more than one CPU, due to bugs - in the BIOS of many multi-core motherboards. To enable hires timers in your project, - use SetProcessAffinityMask to set to use only one CPU before creating the device. - - - OpenGL render targets now the same way up as the other drivers. If you have - written opengl shaders that use render targets then you'll need to change your - texture coordinates accordingly. - - - Fixed some OpenGL renderstate stuff. setBasicRenderstate returns with - active texture layer 0. The material renderer must return from OnUnset - with the same active texture layer. The alpha test is disabled and the - texture mode should be GL_MODULATE. - - - Fixed CSoftwareTexture2::getOriginalSize, reported by CaptainPants. Added a - new method CSoftwareTexture2::getMaxMipMapSize to return the size of the largest - mipmap, which is used by texelarea instead of getOriginalSize. - - - Changed parameter order of addArrowMesh and added default parameters such - that it's enough to set the color (or even just the name). - - - Fixed bugs in MY3D and OBJ loader. - - - Added IMeshCache::clearUnusedMeshes(). This allows the user to remove - meshes that are sitting in the mesh cache but aren't used by any scene nodes. - This is useful for example when changing levels. - - - Added IUnknown::getReferenceCount() - - - createDevice now reports errors if the driverType is unknown, previously it - created a window but populated it with a null driver without any warning. - - - Fixed a bug in CBillboardTextSceneNode::setText where the old text was not - cleared. - - - Changed irrArray::linear_search to use the == operator rather than < - This may be slower in some cases, but it no longer returns false positives - when searching arrays of classes that override the < operator but - !(x<y) && !(y<x) does not necessarily mean x==y (vectors, positions etc). - - - Fixed getSize/getOriginalSize method inversion in OpenGL textures. - - - Added per texture-layer filter settings, i.e. one can choose to filter - only chosen texture layers. If all layers are set to the same value the - convenience function material.setFlag(EMF_BILINEAR_FILTER, boolean) can be - used, TRILINEAR_FILTER and ANISOTROPIC_FILTER do work, too. In all other - cases material.BilinearFilter[i] (resp. TrilinerFilter[i] or - AnisotropicFilter[i]) shall are to be used. - - - Added adjustable Attenuation for dynamic lights. This allows to change the - intensity of a light based on its distance. The default attenuation changed - from (0,1/radius,0) to (1,0,0) which means no effect by distance. Good - values for distance effects simply add small values to the second and third - element. - - - Fixed a typo to do with 2nd light vectors in opengl parallax and normal map - renderers. - -GUI: - - - Fixes to menu and listbox (de)serialization, and custom listbox colors by CuteAlien. - - - Added EGET_ELEMENT_CLOSED GUI event type. Absorb this event to cancel closing a window. - - - Added _IRR_COMPILE_WITH_GUI_ to allow compiling without the GUI. - This is useful if you use another GUI system (ie CEGUI) or are using Irrlicht - inside another window. You will have to supply an external IGUIFont if you wish - to use font scene nodes as there will be no GUI environment available to load fonts. - - - Added 7 more symbols to the built-in font and skin. - EGDI_MORE_LEFT, EGDI_MORE_RIGHT, EGDI_MORE_UP, EGDI_MORE_DOWN: "<<" symbols - indicating there is more content in that direction. - EGDI_WINDOW_RESIZE: Window symbol for resizing by clicking the bottom right - corner of a window. - EGDI_EXPAND, EGDI_COLLAPSE: Plus and minus buttons for trees. - - - Added IGUISkin::draw2dRectangle, so skins can override the default highlight. - - - EGET_ELEMENT_FOCUS_LOST and EGET_ELEMENT_FOCUSED events can now be absorbed - by returning true in OnEvent. Absorbing these events will cancel the focus - change. - - - IGUIEnvironment::setFocus and removeFocus now return bools. - - - New SEvent.GUIEvent.Element. Points to a second element that is being - used in the event. During a EGET_ELEMENT_FOCUS_LOST event it points - to the element which would like the focus. - - - Fixed the default font icons so they have a black border and are not - invisible in default listboxes. Old font tool textures now keep their color - so colorful fonts are possible by editing the font's texture. The colors of - completely transparent areas are no longer kept when generating the texture - from an image. Added builtInFont.bmp for ease of editing. - - - IGUIElement changes: - - Most elements can now be accessed using the keyboard. Use space and return - to select or deselect, escape to cancel selection (ie while pressing a - button with space or return), and the cursor keys where appropriate. - - Added navigation through the GUI using tab and the shift and control keys. - Use these new methods to control tab navigation: - setTabStop - set this to true if the focus will vist the element. - isTabStop - returns true if the focus will visit the element. - setTabOrder - Sets the order of focus within this tab group, - Only one element in each group should have the same TabOrder number. - Set to -1 to add to the end of the group. - setTabGroup - set this to true if the element is a group that contains - other elements, and can be navigated with ctrl+tab/ctrl+shift+tab. - isTabGroup - returns true if the element is a tab group. - getTabGroup - returns the tab group that the element belongs to. - getNextElement - searches for the next element which would be focused - within the element's children, only useful if you are doing your own - custom navigation. - - Added isMychild, to check if an element is descended from this one. - - Added isPointInside, which is called by getElementFromPoint. Override this - when making non-rectangular elements. - - OnEvent no longer absorbs events by default. - - Serialize/deserialize now call getter and setter functions, in case people - override these and don't use the internal protected variables. - - added getAbsoluteClippingRect, returns the visible area of an element. - - - Added IGUISpinBox, by Michael Zeilfelder (CuteAlien). - - - IGUIEditBox new methods: - setWordWrap/isWordWrapEnabled, to split words on to the next line. - setMultiLine and isMultiLineEnabled, inserts a newline instead of sending - EGET_EDITBOX_ENTER events. - setPasswordBox/isPasswordBox to use the edit box for password input. - setTextAlignment, to align the text to left, right, top, bottom and centers - setAutoScroll, to enable and disable automatic scrolling with the cursor - - - IGUIStaticText new methods setDrawBorder and setTextAlignment. - - - IGUIListBox changes: - Added setAutoScrollEnabled and isAutoScrollEnabled, for automatic scrolling - when selecting or adding an item. - Scrollbars are now only visible when the list doesn't fit in the visible area. - You can now type an item's text to select it. - - - IGUIScrollBar new methods set/getLargeStep - -------------------------------------------- -Changes in version 1.3.1 (20 Jun 2007) - - - Fixed a bug with negative exponents in fast_atof, posted by RVL - - - renamed IAnimatedMeshSceneNode::getAbsoluteTransformation to - getMD3TagTransformation to avoid conflicts with - ISceneNode::getAbsoluteTransformation - - - Added rect::constrainTo for locking a rectangle inside another without - resizing it - - - Moved the OpenGL API functions from COpenGL driver into new extension - handler. Thereby, some renaming took place - the ARB and EXT suffix was - removed. Simply rename the functions in case you use them. - - - matrix4 is now a template internally such that also int and double matrices - are possible now. - - - CMeshBuffer is a new template replacing all previous SMeshBuffer* classes. - New mesh buffers can be easily implemented based on this code. - - - Ogre 1.40 files now also load. - - - New filename based methods in the MeshCache. - - - CSphereSceneNode is now texture wrapped with sphere mapping by exactly one - texture. Only a small error on the top remained. - - - The Sky box scene node now clamps its textures by default (meaning no - more ugly artifacts at the borders). - - - Frustum culling fixed by using the fixed classifyPointRelation function. - - - Some fixes in the 3d basic structures: plane3d.classifyPointRelation now - correctly returns the relation, it returned the opposite before. Also - renamed existsInterSection to existsIntersection for consistency. - triangle3d.isOnSameSide is now private - it's just a helper class not - intended for further use. - - - Added IFileSystem::getFileDir, to get the directory when given a file - name. Submitted by Jeff Myers - - - Updated to latest PNG library (1.2.18), fixing a vulnerability. - Also changed some data structures which should make the library 64bit - compatible. - - - Changed the external window pointer from s32 to void*. This makes the - mechanism 64bit safe, but also breaks the API. You have to cast to - void* now. - - - Moved image scaling algorithms to CImage class and made them public. This - replaces lots of code from the hardware textures. It should also fix the - missing MipMaps in OpenGL if the driver does not support mipmap generation. - - - Added support for texture creation flags in OpenGL. This changes some - textures to other color formats than in previous versions. - - - MD2 normals fixed. - - - Some defines for the platform choice have changed their names and semantics. - E.g. IRR_LINUX is now _IRR_LINUX_PLATFORM_ for os specific things and - _IRR_USE_LINUX_DEVICE_ to choose the original X11 IrrLinux device. - - - Added an SDL device for cross-platform window support. Especially useful - for embedded systems and others without hardware acceleration. This device - is mutually exclusive with the other devices and requires linking against - the SDL library. - - - Q3 shader crash fix. - - - Fixed the too small D3D texture bug. - - - The OpenGL texture is internally stored as a CImage now. - - - Fixed some Borland compiler problems. - - - ShadowVolume init bug fixed. - - - MS3D rotation bug fixed. - - - setFrameLoop bug fixed. - - - Fixed OpenGL's draw2DImage texture inits to avoid texture confusion. - - - Fixed getHeight from terrain scene node. - - - The FPS counter now works as in previous releases, the accumulating counter - can be enabled by a parameter. - - - getType() is now const correct (API Changes) - - - Added scissor test to opengl draw2DImage method that ignored clip. - - - Fixed a bug in rect::isValid, it was almost always true. - - - Fixed wrong particle emission. - - - Added LinuxDevice setResizeAble implementation. - - - Enumeration values of the ESCENE_NODE_TYPE enum are no longer ints but four - character codes. If you were using them as index previously, this is no longer possible. - - - There is now a way to set which scene manager should recieve user input, when working - with multiple scene managers: IrrlichtDevice::setInputReceivingSceneManager(). - - - ICursorControl now supports setting a reference rectangle. - If this rect is set, the cursor position is not being calculated relative to - the rendering window but to this rect. You can set the rect pointer to 0 to disable - this feature again. This feature is useful when rendering into parts of foreign windows - for example in an editor. See ICursorControl::setReferenceRect() for details. - (Windows only implementation currently) - - - It is now possible to clone single scene nodes (ISceneNode::clone()) and to create copies - of a whole scene graph (ISceneManager::createNewSceneManager(cloneContent=true); - - - IAttributes now supports a user pointer (void*) - - - Added query methods to scene manager: Find Scene nodes by type - getSceneNodesFromType - - - Added min and max functions with 3 values: core::min_ and core::max_ - - - Fixed a crash when using Octtrees caused by unnecessary dropping of meshes when - deserializing the scene node. - - - Removed an array::erase from Octtrees and Octtree triangle selector. - - - Removed a bug which caused irrlicht to crash when using animated .x files as static meshes. - -GUI: - - - Added EGUI_DEFAULT_FONT for skins, default fonts can now be set for windows, menus, buttons and tooltips. - use IGUISkin::setFont and getFont to use them. Fonts are not serialized with saveGUI yet - - - Added EGDC_TOOLTIP_BACKGROUND for setting background color of tooltips. - - - Tooltips now appear relative to mouse position, also they do not appear for 500ms. - - - Fixed a memory leak when dropping the GUIEnvironment when a tooltip was present. - - - Added IGUIStaticText::setDrawBackground and IGUIStaticText::setBackgroundColor. - - - Fixed a messagebox focus bug when no 'okay' button was present. - - - Added setColor and setScaleImage to GUIImage. - - - GUIListBox highlighted area now clips properly. - - - added getOSOperator to GUIEnvironment (for clipboard access in elements) and updated CGUIEditBox. - - - Can now load/save gui environment from/to an element. - - - Most element set functions now have a corresponding get or is function. - (API change) IGUIButton::getUseAlphaChannel is now isAlphaChannelUsed, to fit with other is* functions. - - - Fixed a bug with resizing the gui environment when the device is resized - - - Modal screens now resize to fit their parent. - - - XML bitmap fonts now load textures from the XML file directory rather than the current one. - - - Fixed a small bug with click areas in combo boxes. - - - Fixed a bug in clear() when an element was hovered or had focus - - - Fixed a bug when loading fonts with uppercase letters in the name in case-sensitive filesystems - -GUI Editor: - - - Added cut/copy/paste using clipboard and xml (via memory file). Will have problems in Linux due - to no clipboard support - - - Added texture attribute element - - - Added CGUIPanel, a container with optional scrollbars. Originally submitted by Asger Feldthaus - -------------------------------------------- -Changes in version 1.3 (15 Mar 2007) - -- SMaterial structure changed: - - Enable Irrlicht to change TextureAddress Mode (Clamping), for each layer separately - - Added Texture matrices to SMaterial for all texture layers - - Removed the anonymous union/struct access to textures and material flags. - Now, Texture1..4 is removed - use Textures[i] instead - The Flags[x] is replaced by setFlags(x, bool) resp. getFlags(x) - -- The methods OnPreRender and OnPostRender of ISceneNode have been changed to - OnRegisterSceneNode() and OnAnimate(). Also, they are now called at different - times: OnAnimate is called every frame before anything else, removing the - one-frame-lag Irrlicht suffered until now. To make most of your own scene - nodes work again, it should be enough to rename OnPreRender() - to OnRegisterSceneNode() and OnPostRender() to OnAnimate() in most cases. - -- ISceneNode::getMaterialCount and getMaterial now use u32 instead of s32. You will also need - to update this in your custom scene nodes. - -- matrix4 speed enhancement, testing for identity before multiply. faster check for identity - for the positive case using an additional boolean flag. - The internal array M is now private, changing the API. Use mat[x] instead of mat.M[x]. - The pointer to M is acquired by mat.pointer(), some methods take a matrix4 reference - instead of a f32*. - -- Some more suppport for tangent meshes - -- Several alpha blend fixes in several drivers and methods - -Font improvements: - - - Changed built-in IGUIFont to IGUIFontBitmap and added options for more fonts. - CGUIFont now supports UCS-2 and may span many textures, loads from XML (Unicode support planned) - - - Started a font tool for creating the new XML fonts, including generating vector fonts - (currently not backward compatible with old fonts, only works for Win2K+, some bugs still) - - - Font interface now supports kerning- kerning pairs, per letter and global kerning widths, - although he internal font only supports global and per-letter. - - - added _IRR_COMPILE_WITH_SOFTWARE_ and _IRR_COMPILE_WITH_BURNINGSVIDEO_ to compile config - - -- GUI enhancements: - - - GUI Serialization with loadGUI and saveGUI, and serializable custom GUI elements via factories - - - Started a GUI Editor as a GUI element factory example (work in progress) - - - New IGUIElement functions: isSubElement & setSubElement for child elements created by their parents - (eg. a scrollbar on a list box). Set it if you don't want an element to be serialized - - - New GUI event, EGET_ELEMENT_FOCUSED - - - GUI environment ELEMENT_FOCUS_LOST event now sets the element as the caller, focus_lost events - are now usually passed to parent elements, so elements now check if they are the caller before - updating (so users can catch focus lost events without them being eaten by the elements) - - - Buttons, checkboxes and tab controls now only activate when the mouse is released over them. - - - Windows mouse-up events are now caught outside the window, so mouse coords may now be negative. - could cause problems with draggable user windows, as they may now be dragged off screen. - - - Elements can now automatically resize to fit their parents, or align themselves to an edge: - setAlignment(left, right, top, bottom) - sets how each edge aligns to its parent, - through EGUI_ALIGNMENT enum - EGUIA_UPPERLEFT - default behaviour, aligns to top or left edge - EGUIA_LOWERRIGHT - aligns to the lower or right edge - EGUIA_CENTER - moves relative to the center of its parent - EGUIA_SCALE - uses relative scale - - - setMaxSize, setMinSize - sets the maximum and minimum sizes for automatic resizing, - use 0 for no maximum size. - - - setRelativePosition now takes a rect<f32> for relative positioning within their parents - - - getFileSystem added to the GUI environment - - - New IGUISpriteBank, used to hold 2d image data like fonts and GUI icons. - Icons provided by the built-in font are now accessed through the skin's sprite bank. - Users can override the icons by setting a different sprite bank and setting new sprites. - - - Skins are now serializable and are loaded/saved with the GUI. - - - IGUIStaticText getter/setter functions patch by rogerborg. - -- added 3d TextSceneNode2. to view a Text in real 3D Space - in fact it is a combination of Billboard & TextSceneNode - -- Burning Video (the second but only complete software renderer) - - New Compile Config BURNINGVIDEO_RENDERER_ULTRA_FAST - - New Compile Config BURNINGVIDEO_RENDERER_FAST - touching the 20fps border in the demo ( P4 mobile 2Ghz ). 15fps average. - ( Compile config Release Fast-FPU ) - - - VertexCache for Tansformed & Light Vertices - boost small drawPrimitive Calls ( 2DRectangle, Billboard ) and Real Index Triangles - - - Bilinear Dither - - clipping test ( compare instead of generic plane normal ) - - support for NOT using vertexcolor - #define SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - -- added vertex to color to billboard. - shade top & shade down. - to support some static lighting effect on billboards - -- Implemented line rendering for SoftwareDriver - -- XMLWriter fix for 32bit wchar_t (esp. for big endian) - -- updated to latest PNG library - -- implemented CImagerWriterJpeg::writeImage - -- The ISceneManager::addCameraSceneNodeFPS() has a new parameter named 'jumpSpeed' - and a Key Map Entry. - -- added param to IIImageWriteFile::writeImage - control Parameter for the backend ( e.g. jpeg compression level ) - -- addContextMenu: CGUIEnvironment::addContextMenu set the focus on the submenu. - -- Added IFileSystem::createMemoryReadFile for accessing memory like a file. - -- Added core::map class submitted by Nastase Catalin (Kat'Oun) - -- Fix vertex colors for .x and .ms3d, alpha bug in .obj - -- Fixed 16bit depth screens under Windows. - -- Implemented getMeshBuffer(SMaterial) for all AnimatedMeshes. - It was returning 0 for all implementations previously. User defined IMesh derivates - will also have to implement it now due to the removed empty implementation. - -- Added yield() method to IrrlichtDevice which allows to pause the Irrlicht process for - a very short time. This allows other processes to execute without a major - penalty for the Irrlicht application. - -- Added sleep() methd to IrrlichtDevice, for pausing the Irrlicht process for a longer - amount of time. - -- Auto-split mesh to 16bit buffers in 3ds loader - -- 8bit RGB332 image format support - -- isActive() under Linux now behaves like the Windows variant: True iff window has focus - -- Fixed(?) the glXGetProcAddress problems with different drivers - -- B3D changes by Luke: - Texture scaling bugfix, support for alpha blending, new option to normalise weights, - animation code optimization, fixed memory leak - -- ROUNDING_ERROR is now ROUNDING_ERROR_32 or ROUNDING_ERROR_64 - -- Material ZBuffer flag changed to a u32 value - Reason: change ( off or on ) to , off, lequal, equal - Necessary for multi-pass if previous stage has had transparency - -- DebugDataVisible is now an enum of flags - show normals is supported ( uses the new build in arrowmesh ) - -- New Function: GeometryCreator - addArrowMesh. build a closed cylinder and a cone - used to show normals as debug feature - -- New Function: - CMeshManipulator::transformMesh(scene::IMesh* mesh, const core::matrix4& m) const - transforms VertexPosition and VertexNormal - -- BUGFIX: CGUIButton notified Pressed when Mouse was clicked Inside ( correct ) - but also left up outside rectangle ( incorrect) - -- BUGFIX: Octree:getPolys(const scene::SViewFrustum& frustum, SIndexData* idxdata) - was recursive calling invisible children - -- CFileList: Changed FileListEntry sorting to - a) Directory comes first - b) sorting ignores case - so it feel's more like common browers - -- added a Texture transform to IVideoDriver::setTransform - -- quaternion::getmatrix - in fact the getmatrix version is returning the transposed. - i'm quite sure that this is the wrong implementation. - so this should be verified to remove the getmatrix_transposed version... - -- Quake3 Map Loader: - new loading method - - Bezier Patches with LOD more than 3 - - Multiple Meshes, stay compatible with the previous version - - Indexed Triangle List - - initial support for quake3 Shaders and Entities - - Shaders are parsed. When it's possible to resolve a 2 Texture Scheme it's taken - Shaders exist in namespace scene::quake3 - - The Example Quake3Map shows how to continue applying the Q3Shaders with SceneNodes - ( for example animmap converts to TextureAnimator.) - TODO: use the Irrlicht Variable Syntax to remove redundant code.. - -- added getVertexPitch() to IMeshBuffer interface - -- added generic isupper, isspace.. functions to coreutil.h to remove dependencies for ctype.h - ( future: it's possibly to use binary comparison test..) - removed 1000's include of string.h and moved one to irrstring.h - in preparing of complete removing the MSVC. - -- moved fast_atof.h to the public include - added strtol10 to remove dependencies for stdlib.h - anyway math.h is needed for powf - -- core::vector3d - added getInterpolated_quadratic. - vector3d<T> getInterpolated_quadratic(const vector3d<T>& v2, const vector3d<T>& v3, const T d) const - // this*(1-d)*(1-d) + 2 * v2 * (1-d) + v3 * d * d; - -- irrstring: added param start to findLast(T c, s32 start = -1 ) - reason: to continue searching reverse on a specific position - (parameter is checked against boundaries ) - -- added operation reciprocal_squareroot to irrmath. - core::reciprocal_squareroot = 1.f / sqrtf ( x ) - changed the core::vector3df normalize vector. - specialized templates are not allowed in irrlicht currently, so it's only for f32 for now. - a C function and a NVidia Version are in irrmath.h - -- add Primitives to CFPSCounter - and changed interpolation to 1500ms instead of 2000ms - and rounding to ceiling.. - -- added Interface setAmbientLight to ISceneManager - it was a Bug, because SceneManager always calls Driver therefore AmbientLight has to be set in SceneManager. - -- changed GUIFont & FontTool to support kerning ( on a global basis ) - very basic mode.. apply an offset for position - useful for example if you want to apply an outline stroke in your favorite - and therefore let the texture grow. - and to correct the border back on drawing, specify the parameter in IGUIFont. - this is quite useful if you want to use more artistic fonts. - default = 0 - better kerning would need a seperate coordinate set for each symbol. - -- changed MD2_FRAME_SHIFT to lower framerate - -> lower IPol - problems can occur if somebody uses hardcoded frame-numbers instead - of Animation name... - -- changed spelling "frustrum" to "frustum" - -> changed also SViewFrustrum.h to SViewFrustum.h - -- changed Parameter AutomaticCulling from bool to enum E_CULLING_TYPE - to support more than two culling modes. - - added Frustum culling ( it's a copy & paste from the octree ) - added initial bounding sphere - used for culling point lights.. - -- Added getSystemMemory and getProcessorSpeedMHz for Windows and Linux to the OSOperator, submitted by Vitek. - -------------------------------------------- -Changes in version 1.2 (29 Nov 2006) - -- Added Solaris/Sparc port (basically some compiler define statements). Irrlicht and the examples should compile out-of-the-box on Suns with the usual Makefiles and gnumake. - -- Added texture matrix support for hardware accelerated drivers. This allows for efficient texture coord manipulations for complete meshes at once. - -- Multisampling with OpenGL under Linux added - -- Non-power-of-two textures are left unscaled if the driver supports such textures. - -- new draw2DImage method that speeds up drawing many quads from the same texture. Font drawing is improved by this under OpenGL. - -- TGA files are now always correctly flipped and loaded if compressed. All PNG color formats are now supported, including correct alpha handling. - -- 3ds mesh loader fix in texture loading, now loads some textures that were not loaded before, but might introduce problems with very recent files. OGRE mesh loader bugfixes and lightmap support. Several B3d mesh loader updates. Obj and mtl loader enhancements. - -- A new compile flag (IRR_OPENGL_USE_EXTPOINTER) allows Irrlicht to either use OpenGL extension function pointers or direct OpenGL calls. - -- OpenGL now uses frame buffer objects for render targets larger than the screen, supplied by Mandrav - -- Split ESNRP_LIGHT_AND_CAMERA passes into ESNRP_LIGHT and ESNRP_CAMERA to fix a problem with lights being rendered before cameras in OpenGL (thanks again to Vitek for finding this). ESNRP_LIGHT_AND_CAMERA is now deprecated. - -- Fixed many OpenGL render state problems which were related to wrong texture states. The textures are now enabled and disabled by the material renderers in OnSetMaterial. Also enabled the texture state cache which helps preventing texture changes just as the one for D3Dx. Thanks to hey_i_am_real for some good hints on where the problem was located. - -- Added compile flag _IRR_COMPILE_WITH_X11_ which is by default enabled. Disabling the flag removes all X11 dependencies from Irrlicht and allows for a headless Linux Irrlicht server - added by request :-) - -- Win32 OpenGL driver tries to use the requested bpp size. - -- Default texture format is now A8R8G8B8 if not explicitly specified. This fixes some color artifacts with lightmaps. Bugfix submitted by hey_i_am_real. - -- In OnPostRender all transformations were taken as relative and multiplied with the root transformation matrix every time due to a wrong check for the real root node. This shoudl increase render performance for scenes with lots of (invisible) nodes. - -- Added correct list copy constructor. - -- Color selection dialog added. - -- New GUI skin "Burning Skin". - it's a black & white skin. look elegant on true-color. - and looks ok on 1-Bit ( e.g. no vertex color in burnings video ) - -- GUIStatic text is correctly grayed out if disabled. - -- Added getHeight method for terrain node submitted by Spintz. It calculates the height from the base mesh instead of requiring ray casts and collision detection and is much faster. - -- New methods core::lerp to linearly interpolate two floats and SColor.getLuminance to calculate luminance of RGB color. - -- MAJOR API CHANGE: - Fixed matrix access methods mat(x,y). These were previously said to be (row,column) but actually were (column, row). This lead to some confusion and made their use quite tricky. Irrlicht code is updated for the new method, but applications will silently fail now (i.e. compile without errors, but not working as expected). - -- Update to zlib-1.2.3 - -- Fixed vertex alpha handling in DirectX drivers. - -- Image writers fixed and working (at least for little endian systems). - -- VSync under Linux fixed and correctly working. - -- New os::Byteswap::byteswap methods which can be used for byteswapping (endianess correction) in mesh loaders and image loaders. - -- New video driver feature to check for multitexture feature. - -- Direct3D drivers update the devicelost variable if reseeting failed with this return code. - -- VideoModeList under Linux is correctly filled now. No glX calls are made if GLX extension is not found - only software drivers are available then. RandR extension can be enabled with a new compile flag in IrrCompileConfig.h, either instead of XF86VidMode or in addition. - -- Big Endian support for MS3D loader. - -- Apfelbaum software renderer: basic mipmap support (per triangle), switch for using w-buffer instad z-buffer ( default on ) - -- Better FPU support: Changed various fpu-call's in whole project (main reason to use faster float to int conversion on x86. ( fistp )) - -- changed Visual Studio 7.1 vcproj project config "Release Fast FPU" to __fastcall in /QIfist - -- CGUIFont added True Alpha Font Support. (currently it's a little hack, but it'a good starting point. Fonts are back compatible. To use the new feature make first pixel half transparent in the font file.) - -- Scolor: replaced s16 color with u16 color, replaced s32 color with u32 color to get rid of unnecessary arithmetic shift - -- Colorconverter: X8R8G8B8toA1R5G5B5, set Alpha High, minor: A1R5G5B5toA8R8G8B8 changed if (a) to conditional set - -- CImage: added boxfilter (weigthed average), (generic, slow) - -- The scene manager now sets an ambient light color when calling ISceneManager::drawAll(). - You can influence this by calling ISceneManager::setAmbientLight(). That light color - is also stored when saving .irr files via ISceneManager::saveScene(). - -- Loaded COLLADA files which contained only one single mesh now behave like all the - other loaded meshes, and the #meshname workaround has been removed. - -- File lists are now sorted. - -- Dynamically checking the OpenGL version now instead of at compile time to call the supported methods of the executing machine, not that one of the compile host. This should fix the extension check and the automatic mipmap update. - -- Fixed vertex alpha handling of 2D images with OpenGL. - -- Default depth buffer under Windows now 24bit to avoid zbuffer fighting. - -- Fixed light count in OpenGL. - -- Particle emitters can now be enabled/disabled via a new method. - -- Sky dome is rotatable just like the sky box. - -- Rotation animator can be applied to several nodes now, before it only rotated the first one it was applied to. - -- Support for drawing other vertex primitive lists such as triangle strips. - -- Default specular color is white again, thus simply enabling shininess is enough to get speculars. - -- Some .x loader and animator improvements. Vertex color support. - -- isActive now also work under Linux. - -------------------------------------------- - -Changes in version 1.1 (06 Aug 2006) - -- New example to show some features of the .irr format - -- Added support for making screenshots in all video drivers and a general - possibility to save any IImage to several file formats. - Some image writers are not yet implemented. As a testcase screenshots - are now available in the demo by pressing F9. - This code was contributed by Travis Vitek. - -- Changed EAMTS_OCT to EAMT_OCT. - -- Improved .3ds and .obj file importers. - -- Added support for .b3d (Blitz Basic) submitted by Luke Hoschke and - .pak (Quake archive) files submitted by skreamz. - -- Added sky dome implementation contributed by Anders la Cour-Harbo (alc). - -- In addition to the Cube scene node (formerly test scene node) there is now also a sphere scene node available, - with an adjustable amount of polygons. Use ISceneManager::addSphereSceneNode to create it. - Thx to Alfaz93 for making available his code on which this node is based on. - Note that both nodes now use default material settings, e.g. lighting is enabled by default. - -- Fixed Linux keyhandling for many keys. - -- The aspect ratio has been inverted in the matrix, which means when setting a new aspect ratio - for cameras, set it to screen.width/screen.height now instead of screen.height/screen.width - as previously. - -- added support for reading/importing binary .x files. - -- .ms3d and .x normals are now correctly transformed in animations, bounding - boxes are slightly better transformed, but not yet correct. - -- Added possibility to load and save Irrlicht scenes to and from xml files via - ISceneManager::saveScene and ISceneManager::loadScene. Note that not all - scene nodes are supported yet, but most features should already work. - -- Bounding box of the Skybox corrected (set to null) - -- The SMaterial structure now supports 4 textures. (Currently ignored by the renderers and their materials.) - -- Test scene node renamed to CubeSceneNode. - -- Added scene node animator factories. This is the same as scene node - factories, but for scene node animators. - -- Added scene node factories. This is an interface making it possible to dynamicly - create scene nodes. To be able to add custom scene nodes to Irrlicht and - to make it possible for the scene manager to save and load those external scene nodes, simply - implement this interface and register it in you scene manager via ISceneManager:: - registerSceneNodeFactory - -- Introduced IMeshSceneNode interface with the possibility to set readonly materials to make - it possible to use the mesh materials directly instead of overriding them. In this way - it is possible to change the materials of a mesh causing all mesh scene nodes - referencing this mesh to change, too. - -- Added possibility to load OGRE .mesh files directly, thanks to Christian Stehno who contributed - a loader for this. - -- Merged with Irrlicht 1.0 for MacOS - -- Added a method getType() to ISceneNodeAnimator. - -- There is now a system to serialize and deserialize attributes of scene nodes. In this way - it should be quite simple to to expose the attributes of your scene node for scripting - languages, editors, debuggers or xml serialization purposes. - -- Irrlicht containers and strings now have allocators, making it possible to - use them across .dll boundaries. - -- Changed the name of scene nodes from wide character to to char* for speed and memory reasons. - -- Renamed IStringParameter class to IAttributes and enhanced it to be able to - serialize its content into and from xml. - -- Textures now have a method getName(). - -- Added the methods getTextureCount() and getTextureByIndex() to IVideoDriver. - -- Most classes now derive virtually from IUnknown. - -------------------------------------------- -Changes in version 1.0 (19 Apr 2006) - -- Irrlicht now will load d3d 9 dlls (like d3dx9_27.dll) manually if needed. If you compile irrlicht - with an SDK which needs one of these dlls, irrlicht will now also start up on a pc without - these Dlls installed. Note that now these dlls will also only be loaded if your application - uses shaders. If the dlls are missing, shader support will be disabled. - -- The Apfelbaum Software Software Renderer now works in 32 bit and is capable of rendering dynamic - lighting as well as doing alpha channel blending. - -- Added support for the Code::Blocks IDE (http://www.codeblocks.org) - -- It is now possible to draw temporarily to foreign windows, by specifying a window handle when - calling IVideoDriver::endScene(). Note: This does not work in fullscreen mode and is not - implemented for all devices (only for D3D8, D3D9, Software1 and Software2, and only for Windows). - In addition, you can also specify the source rectangle to present. - -- Picking is now more accurate and also works with view ports and better with orthogonal cameras. - -- Scene Nodes now have an additional flag, IsDebugObject. This denotes if a - scene node is a debug object. Debug objects have some special properties, - for example they can be easily excluded - from collision detection, picking or from serialization, etc. - -- Scene Nodes now have the possibility to return their type using - virtual ESCENE_NODE_TYPE getType(). - -- Improved support for orthogonal rendering: Skyboxes and billboards can be - used with orthogonal cameras now, too. - -- Fixed a bug in collision - -- Fixed some marshalling bugs in Irrlicht.NET - -- Some fixes to make gcc 4 happy. - -- Fixed a bug which caused the engine to crash when trying to use the - apfelbaum software rasterizer with linux - -- Several improvements to Irrlicht.NET, for example string output for vectors, viewfrustrum access - for cameras, drawing of bounding boxes, support for orthogonal cameras. - -- Updated DMF importer to support new DeleD functionalities, solid materials will now be - shown correctly again in Irrlicht. Thanks to Salvatore "Il Buzzo". - -- Added a method to change the return value of ICameraSceneNode::isOrthogonal - -- Improved md2 animation playback - -- Fixed the REFLECTION_2_LAYER materials. Now also works for OpenGL. Had to change the parameters - of this material (for all drivers), the reflection is now at texture 2 and the diffuse map at - texture 1. This was the other way round before. - -- Added examples for csharp, visualbasic, delphi.net and boo. - -- Several other small bug fixes. - -------------------------------------------------------------------------------------- -Changes in version 0.14.0 (30 November 2005) - -- Irrlicht now includes another video driver type. Together with D3D8, D3D9, OpenGL, the NULL - driver and the Software Renderer, an Irrlicht user now has the decision between 6 renderers: - The new included renderer is The Apfelbaum Software Renderer, an alternative software renderer - for Irrlicht. Basically it can be described as the Irrlicht Software renderer on steroids. - It rasterizes 3D geometry perfectly: It is able to perform correct 3d clipping, perspective - correct texture mapping, perspective correct color mapping, and renders sub pixel correct, - sub texel correct primitives. In addition, it does bilinear texel filtering and supports more - materials than the EDT_SOFTWARE driver. In short: It looks a lot like the already available hardware - accelerated drivers, but without hardware. :) This renderer has been written entirely by - Thomas Alten, thanks a lot for this huge contribution. - -- Irrlicht now supports anisotropic filtering. Use the SMaterial::AnisotropicFilter member or - EMF_ANISOTROPIC_FILTER flag to enable it. I implemented this for all 3 hardware accelerated - drivers: D3D8, D3D9 and OpenGL. - -- Irrlicht now supports the recently released new microsoft compiler. Irrlicht versions compiled - with older verions of this compiler can now also be used with the new one, which wasn't possible - previously because of a name mangeling issue. - -- All 2D drawing functions can now be used to draw into textures (render targets). This also - means for example that the whole GUI environment can be rendered into textures. - -- Irrlicht.NET now supports shaders. - -- Irrlicht now loads all textures in 32 bit mode by default. (Previously this - was 16bit). To change this behaviour back again, use - device->getVideoDriver()->setTextureCreationFlag(ETCF_ALWAYS_16_BIT, true); - -- Irrlicht.NET now supports Particlesystems and Shaders. Thanks to a code - contribution by Delight. - -- Fixed a bug in the mipmap generation. Now mipmaps are not that blurry - anymore and the rendering quality has been improved a lot. - -- It is now possible to assign a userData int to callback functions of shaders. In this way it - it easily possible to use the same callback method for multiple materials and distinguish - between them during the call. - -- Directional lights are now supported in the OpenGL and D3D drivers. To switch on directional - lighting, set the light type to ELT_DIRECTIONAL in the SLight structure. - -- Fixed several bugs in the GLSL implementation. Thanks to Michael Zoech for - sending in his improvements. - -- For the windows version of Irrlicht, the engine now displays an icon in the - program window, if there is one available in the start path with the name "irr.ico". - -- It is now possible to use images with alpha channels on buttons. Use the new - IGUIButton::setUseAlphaChannel() method to enable this feature. - -- The scene manager has a new method getSceneNodeFromName() which finds a scene node by its name. - -- It is now also possible to attach scene nodes to joints/bones of sceletal animated .x files. - (Using IAnimatedMesh->getXJointNode() ). This was previously only possible with milkshape models. - -- Billboards now draw their bounding box when debugdata is set to visible for them. - -- Lights now draw their bounding box and radius when debugdata is set to visible for them. - -- Upgraded to irrXML 1.2. Thanks to some hints by Patrik Mller, irrXML, the XML parser used - by the Irrlicht Engine now has CDATA support and some other useful new features. - -- Support for VisualC++ (Express) 2005. Added a project file and a IrrlichtPropsVC2005.vsprops - file which sets the no deprecate define and adds needed libraries. - -- Fixed size of the bounding box of billboards. - -- Billboards are now also culled by default, increasing rendering speed a bit. - -- Fixed a bug which caused the .ms3d loader to crash when loading .ms3d files - without materials. Thanks to sdi2000 for posting this. - -- Fixed a bug causing the possibility to crash when destructing the scene - graph or a scene node with children. - -- Fixed some bugs which caused invalid RTT operations, when for example the - render target texture was smaller than the screen. - -- Fixed a heavy bug in Irrlicht.NET causing lots of memory leaks when drawing text. - -- Fixed a bug in the attachement of scene nodes to animated X files. - -- Fixed a bug in the .NET Vector3D addition operator. - -- Updated to Salvatore Russo's DMF loader version 1.3. Notes by him: - This version just adds some new functionalities. First of all Alpha Blended Textures are now - supported by DeleD as well as loader. Because of some trouble with Irrlicht 0.12.0 TGA loading, - TGA textures are always flipped so I've added a parameter so that you can choose to - flip or not all TGA textures coords, this way: - SceneManager->getParameters()->setParameter(scene::DMF_FLIP_ALPHA_TEXTURES, true); - you can also set material transparent reference value by setting: - SceneManager->getParameters()->setParameter(scene::DMF_ALPHA_CHANNEL_REF, 0.01); - you can use every value beetween 0 and 1, but to respect DeleD rapresentation - 0.01 is OK, just a note, if you set 0, it's just like you set 0.5, this means - that each pixel found corresponding to a position in alpha map that has a value<127 - won't be drawn. - -- Fixed a small bug in the line breaking algorithm. - -- Fixed a bug which caused the engine to display strange artifact pixels when drawing 2D images - like text in screens which odd resolutions. - -- Slightly changed the interface of createDevice and createDeviceEx(): the version parameter - now is a char* instead of wchar_t*. Also, IrrlichtDevice::getVersion() now returns char* - instead of wchar_t*. - -- Fixed some parts in the source to make Irrlicht compile in Linux 64. - -- Renamed the EDT_DIRECTX8, EDT_DIRECTX9, _IRR_COMPILE_WITH_DIRECTX_8_ and - _IRR_COMPILE_WITH_DIRECTX_8_ enumeration literals to EDT_DIRECT3D8, EDT_DIRECT3D9, - _IRR_COMPILE_WITH_DIRECT3D_8_ and _IRR_COMPILE_WITH_DIRECT3D_9_. You might need to - update your code and compilation settings with these new names. - -- Added the remaining '..' directory in the linux version of the file list - -- Updated to a faster version of the TerrainSceneNode by Spintz. Much thanks again! - -- Fixed a bug causing billboards to be displayed upside down. - -- The D3D drivers now won't crash anymore when they get feeded with nullpointers as shader constants. - -- Irrlicht now identifies the Linux platform it runs on and returns a more detailed string - when calling getOperationSystemVersion(). - -- Fixed some bugs in several collision test methods thanks to Spintz. - -- Updated font tool - -- Made the list::iterator constructor which took a sklistnode as parameter private, - to make Irrlicht compatible with the Errlicht interface. - -------------------------------------------------------------------------------------- -Changes in version 0.12.0 (24 August 2005) - -- It is now possible to have multiple scene managers. Use ISceneManager::createNewSceneManager() - to create a new one. This can be used to easily draw and/or store two independent scenes at - the same time. - -- Irrlicht now supports GLSL, the OpenGL Shading Language, which means Irrlicht now - supports 14 shading modes/languages: ARB Vertex Programs, ARB Pixel Programs, HLSL, - GLSL 100, GLSL 110VS1.1, VS2.0, VS3.0, PS1.1, PS1.2, PS1.3, PS1.4, PS2.0, PS3.0. - Lots of thanks go to William Finlayson for implementing this and making available his code - to be used in Irrlicht. - -- Added support for pixel shader 3.0 and vertex shader 3.0. - -- Irrlicht now supports detail maps, use EMT_DETAIL_MAP for this. The new terrain scene node - tutorial shows how to use detail maps. - -- Again some changes have been made in Irrlicht.NET. For example it is now a little bit more memory - friendly, I removed several bugs and made the terrain scene node, realtime shadows and key codes - available. - In addition, I extended the .net example application a lot, just try it out. - -- I've worked around a heavy bug in the microsoft compiler which caused lots of bugs in Irrlicht.NET. - They are all fixed now. See http://support.microsoft.com/default.aspx?kbid=823071 for details. - -- The timer of the engine has been enhanced a lot, which maybe needs a little change in your - project if you are upgrading from an older version of Irrlicht. It is now possible - to set the speed of the timer, a new time value, and to start and stop it. Also, all - calls to getTime() will now return the same value within the same drawing frame. - The timer will only advance when ITimer::tick() is called. IrrlichtDevice::run() will - call this method automaticly, but if you aren't using this method, and you are wondering - why your scene is not animating anymore, just call Device->getTimer()->tick() before - drawing your scene. If you need the system time, not the new virtual time, - use ITimer::getRealTime(). - -- The material EMT_TRANSPARENT_ALPHA_CHANNEL now is using a configurable alpha ref value. - The default value is 127, which means people who are using this material for drawing - things like grass, trees etc will get nice results automaticly when changing to 0.12.0. - To change to a different alpha ref value, just change SMaterial::MaterialTypeParam value. - See EMT_TRANSPARENT_ALPHA_CHANNEL for details. - Also, this fixes two bugs: - - A bug causing the D3D versions not looking like the OpenGL version. - - A second bug which caused the texture to look like disappearing when looking at from far away. - -- Upgraded to a new dmf loader version by Salvatore Russo which is able to use a texture path - and material directories. Set DMF_USE_MATERIALS_DIRS and DMF_TEXTURE_PATH using the - ISceneManager::getParameters() method. - -- It is now possible to set a separate scale for the second texture coordinate set in the - terrain scene node when calling ITerrainSceneNode::scaleTexture(). This is useful when using - detail maps on the terrain. - -- Added a new material flag named EMF_NORMALIZE_NORMALS. You can enable this if you need - to scale a dynamic lighted model. Usually, its normals will get scaled too then and it - will get darker. If you enable the EMF_NORMALIZE_NORMALS flag, the normals will be - normalized again. - -- When loading Milkshape .ms3d files, Irrlicht also loads materials and tries to apply the textures. - Thanks to atomice for this patch. - -- The ISceneManager::addCameraSceneNodeFPS() has a new parameter named 'noVerticalMovement' with which - it is possible to disable vertical movement of the FPS camera and make the camera behave just like - in most ego shooters today. - -- Made Irrlicht 64 bit compatible, removing some 32 bit only constructs. However, I wasn't able to - test it out extensively. If you are compiling Irrlicht for a 64 bit windows environment and get - a linker problem, try playerdark's solution: - "The linker settings are so that no machine is specified in the drop down field, instead, - the command line option /MACHINE:x86 is set manually which interferes with the 64 bit linker - of course. Removing that from the 64 bit version (and replacing it with the drop down selection - in the 32 bit version for that matter) fixed the linker problem." - -- There is now a IrrlichtDevice::postEventFromUser() method available, to make it possible to - post key or mouse input events to the engine if you are using an own input library for - example for doing joystick input. - -- The GUI Environment now has an own basic RTTI system, and all IGUIElement derived classes - have a method named getType(). This is needed for the .NET wrapper but will be used - later for serializing and deserializing. - If you wrote your own GUIElements, you need to set the type for your element as first parameter - in the constructor of IGUIElement. For own (=unknown) elements, simply use EGUIET_ELEMENT. - -- Thanks to William Finlayson, Irrlicht now also supports RTT (render to texture) when - rendering using OpenGL. - -- Thanks to William Finlayson, the EMT_REFLECTION_2_LAYER is now implemented in the - OpenGL version of Irrlicht, too. - -- There is now a mesh cache interface available. With this, is is possible to get access to - all loaded meshes, and to remove them to free memory. You can get access to the cache - using ISceneManager::getMeshCache(). Please note that the addMesh() method of ISceneManager - now is now longer available, you can find it now in the IMeshCache interface. - -- The VideoDriver now has a method for clearing the zbuffer at any time: IVideoDriver::clearZBuffer(). - With this, it is for example easily possible to overlay two scenes. - -- Fixed a bug which caused Irrlicht to crash when loading grayscale jpeg files. - -- Somebody sent me an .x file (tank_human1_crashes_irrlicht.zip) which caused Irrlicht to crash. - It seems I've lost that mail, but maybe you are reading this: It's fixed now. :) - -- Fixed a bug which caused the diffuse maps of lightmaps to disappear under certain circumstances - in OpenGL. - -- Its now possible to make IGUIStaticText draw its background. - -- Removed the first two default parameters from - IGPUProgrammingServices::addShaderMaterialFromFiles() to prevent SWIG - to create non compilable wrapper code. - -- Fixed a small bug which caused the terrain scene node to be culled incorrectly. - -- Changed the names the driver return (now "OpenGL 1.5", "Direct3D 9.0" and "Direct3D 8.1") - -- Added a new macro _IRR_DEBUG_BREAK_IF which is now used instead of the _asm int 3 break points in - debug mode. - -- Fixed a bug were the software renderer didn't clip 2d rectangles. This effect was visible for - example when using list boxes, selecting an entry at the end an scrolling up so that it wasn't - visible anymore. - -- There is now a new gui event available (named EGET_COMBO_BOX_CHANGED) which will be - sent when the selected item in a combo box has been changed. Finally. - -- Fixed a Problem which caused an empty window to be created when a rendering device - could not be initialized under special circumstances. Thanks to Sascha Plumhoff for - the bug report. - -- Fixed a bug with the FileList in Linux, reported by DrAnonymous and fixed by William Finlayson. - -- Fixed some bad documentation bugs. - -- The XWindow handle is now exposed too, via IVideoDriver::getExposedVideoData(). - -------------------------------------------------------------------------------------- -Changes in version 0.11.0 (08 July 2005) - -- Antialiasing is now supported by Irrlicht in the D3D8 and D3D9 renderer. To switch - it on, use createDeviceEx() and set SIrrlichtCreationParameters::AntiAlias to true. - -- Irrlicht.NET can now run inside a pre created Windows.Form window. - -- I'm no longer providing a Visual Studio 7.0 project/solution file for the Irrlicht - Engine sourcecode, only 7.1 and 6.0 are supported. If you are using Visual Studio 7.0, - just open the .dsp file for Visual Studio 6.0, it will be converted automaticly. - -- Irrlicht.NET includes now all basic GUI Elements and can capture GUI events. There are - still some features missing, but it is already enough to do simple things like showing - message boxes, displaying images, getting input strings, etc. - -- Improved the .NET documentation a bit. - -- There is a full implemented ISceneCollisionManager now available in Irrlicht.NET. - -- The Linux OpenGL renderer now supports mip mapping. - -- It is now possible to compile Irrlicht as shared lib in Linux. To do this, go into the source - folder and run 'make sharedlib'. This should create a libIrrlicht.so.0.11.0 file in - lib/Linux. To install it in /usr/local/lib, you can run 'make install'. - -- The drawing of the GUI system has been refactored and a lot of redundant code has - been removed. - -- The new method IVideoDriver::draw2DRectangle() is able to draw rectangles not only - filled with a single color, but with a gradient from four colors. This is implemented - in all drivers except the Software driver which still uses one color for this method. - -- It is now possible to customize the GUI system's skin a lot more: Simply implement your - own IGUISkin interface and implement the draw..() methods. - -- There are now two build-in skins available: Windows Classic and Windows Metallic. The - default skin is now Windows Metallic, if you want to change back to the old skin, use the - following code: - gui::IGUISkin* newskin = environment->createSkin(gui::EGST_WINDOWS_CLASSIC); - environment->setSkin(newskin); - newskin->drop(); - -- Added improved keyboard input handling for the Linux version of Irrlicht, thanks to - Fabien Coutant for the fix. - -- Fixed a bug in the Linux OpenGLDriver which caused to load a wrong OpenGL extension - and made multitexturing look quite strange. Thanks to hybrid for spotting out that - bug. - -- COLLADA file loading now works the same like the loading of other meshes: Just - call ISceneManager::getMesh("yourfile") and display it using for example - ISceneManager::addAnimatedMesh(yourLoadedMesh); - To make it possible to create instances from meshes, lights and cameras in COLLADA - files again as in irrlicht 0.10, just enable the collada instance creating mode: - SceneManager->getParameters()->setParameter(COLLADA_CREATE_SCENE_INSTANCES, true); - -- Added lots of useful methods to the IStringParameters class. It is now possible to - set not only strings but also boolean, integer and float values as parameters. -- Fixed a bug with the TRANSPARENT_ALPHA_CHANNEL materials in all renderers to make them - work more as expected: They didn't write to the zbuffer. If you are using this - material and you don't want the new setting, just set the ZWriteEnable flag in the - SMaterial structure of your transparent material to false. Thanks to Fabien to - point this out. - -- There are now some new defines making it possible to use system installed libs instead of - the ones which come with Irrlicht: _IRR_USE_NON_SYSTEM_JPEG_LIB_, - _IRR_USE_NON_SYSTEM_LIB_PNG_ and _IRR_USE_NON_SYSTEM_ZLIB_, which are defined by default - in the file IrrCompileConfig.h - -- Renamed ISceneManager::getStringParameters() to ISceneManager::getParameters() -- Changed the define _IRR_D3D_SHADER_DEBUGGING to _IRR_D3D_NO_SHADER_DEBUGGING to be - able to make it defined by default and to let it be included in the doxygen documentation. - -- The SceneManager now does not do any culling tests for cameras, lights and skyboxes. - -- Added a transformBoxEx() method to matrix4 which transforms a bounding box more accurate. - -- Small edit box copy & paste bug fixed thanks to Fish HF - -- Fixed a bug which caused the engine to read windows messages when embedded in - a custom win32 control when called IrrlichtDevice::setResizeAble(). Thanks for - Duncan Mac Leod to find that bug. - -- Fixed a bug in the HLSL renderer which caused Irrlicht to crash, if no vertex shader - was specified. Thanks to mightypanda for reporting this. - -- Fixed a bug in the normal map generation thanks to jox. Parallax mapping and - normalmapping now even look a lot better because of this. ;) - -- Updated to irrXML 1.1: - - The XML parser is now also able to parse embedded text correctly when it is shorter than - 2 characters. - - The XML parser now treats whitespace quite smart and doesn't report it when it is - obviously used for formatting the xml file. (Text won't be reported when it only contains - whitespace and is shorter than 3 characters) - - The XML parser won't crash anymore when the xml file is malformed and an attribute has - an opening but no closing attribute. - - Removed a documentation which claimed that the xml parser doesn't work as the xml standard - when replacing special characters, which wasn't true. - -------------------------------------------------------------------------------------- -Changes in version 0.10.0 (26 May 2005) - -- The engine is now able to use parallax mapping. It's implemented for D3D9, D3D8 and OpenGL. - The perPixelLighing tutorial shows how to use it. Thanks go to Terry Welsh who wrote - the 'Parallax Mapping with Offset Limiting'-paper on which the Irrlicht implementation - is based and who allowed me to use his texture for use in the example. - -- Added render to texture support. Currently, only the D3D9, D3D8 and the software renderer - are able to use this feature. There is a new example, showing how to render scenes into - a texture. - -- Irrlicht now can load .png textures. There is also a new compile configuration - define to exclude the png loading option: _IRR_COMPILE_WITH_LIBPNG_. Thanks to - rt who originally wrote the png loader and who allowed me to use and modify his code - and place it under the Irrlicht Engine license. - -- Added support for COLLADA files. COLLADA is an open Digital Asset Exchange Schema for the - interactive 3D industry. There are exporters and importers for this format available - for most of the big 3d packages at http://collada.org. Irrlicht can import COLLADA files - by using the ISceneManager::getMesh() method. As COLLADA need not contain only one single mesh - but multiple meshes and a whole scene setup with lights, cameras and mesh instances, - this loader sets up a scene as described by the COLLADA file instead of loading - and returning one mesh. The returned mesh is just a dummy object. However, if the - COLLADA file does not include any <instance> tags, only meshes will be loaded by the - engine and no scene nodes should be created. Meshes included in - the scene will be added into the scene manager with the following naming scheme: - path/to/file/file.dea#meshname. The loading of such meshes is logged. - Currently, this loader is able to create meshes (made of only polygons), lights, - and cameras. Materials and animations are currently not supported but this will - change with future releases. - -- Added Delgine DeleD .dmf mesh loading support. I simply added Salvatore Russo's .dmf loader to - Irrlicht, and changed some parts of it. Thanks to Salvatore for his work and for allowing - me to use his code in Irrlicht and put it under Irrlicht's license. - -- Specular highlights are now finally usable the engine. To activate, simply set the shininess - of a scene node to a value other than 0: sceneNode->getMaterial(0).Shininess = 20.0f; - You can also change the color of the highlights using - sceneNode->getMaterial(0).SpecularColor.set(255,255,255,255);. The specular color of the - dynamic lights will influence the highlight color, too, but they are set to a useful - value by default when creating the light. This feature is currently only available in - the D3D drivers. - -- Added a new material type: EMT_TRANSPARENT_ALPHA_CHANNEL_REF. This draws a pixel of the - material only when the alpha channel has a value greater than 128. It is ideal for drawing - for example leafes of plants and does not use alpha blending, so it is a lot faster than - EMT_TRANSPARENT_ALPHA_CHANNEL. - -- There is now a createDeviceEx() method with which it is possible to create an Irrlicht Engine - device into an already existing window. This currently only works in Windows. - This method will be extended in the future with other options. - -- Irrlicht.NET has been extended with ports of the SceneNodeAnimators, TriangleSelectors - the FileSystem and Font drawing. Also the documentation of it has been improved a lot. - -- There are two new tutorials/examples available. One demonstrates how to use render to texture - feature, the other one shows how to run Irrlicht inside a precreated Win32 window/widget. - This means there are now 17 examples available in the SDK. - -- The software renderer now renders 3d geometry transparent when its material is - somewhat transparent. - -- The XML Parser has been enhanced. Several small bugs have been fixed and there are some - new features: The parser can now read ASCII, UTF-8, UTF-16 and UTF-32 (both little and - big endian) files, and return the parsed string data in one selectable format from the - same list. In addition, it is now completely independent from Irrlicht. If you wish to - use the parser without the engine, take a look at the newly created project at - http://irrxml.sourceforge.net. - -- Upgraded to DirectX Exporter Mod 1.3.1 - -- Upgraded dev-cpp project file to Dev-C++ 4.9.9.2. Removed dependency to zlib and - jpeglib for devcpp, the necessary .c files are now simply included in the project. - -- Renamed the VisualStudio and DevCpp sub directories in the SDK to Win32-gcc, - Win32-VisualStudio. - -- Fixed a bug in irrXML causing it to replace xml characters wrongly sometimes. - -- The C++ decorations at createDevice() have been added again, because lots of people - started to mix the gcc and the microsoft .DLL and got confused why the thing crashed - at random positions. - -- Moved heapsink and heapsort into the core namespace. - -- Updated to My3D version 3.15 - -- Fixed the wrongly drawn alpha channel material in OpenGL driver and a problem with the - VertexAlpha material in the same driver. - -- Implemented multipass rendering in the OCTTree scene node now too. This means that octtrees can - now contain transparent materials as well. - -- Improved string comparison speed, especially when comparing with pointer to char or w_char, - no more temporary strings are being constructed now. In addition, there are some new - string comparison methods in this class. - -- Added string::replace() method. - -- Added string::trim() method. - -- Addes string::erase() method. - -- Fixed a bug in array which caused data corruption if an element which already inside the - the array was pushed_back. Thanks to vox for reporting this and to provide a solutin - -- Added ISceneManager::addMesh() method. - -- Added IMeshManipulator::recalculateNormals(IMeshBuffer*) method. - -- The file array.h has been renamed to irrArray.h - -- Due to a bug, Irrlicht 0.9 didn't cull the scene nodes anymore which resulted in a huge - performance loss. This is fixed now. - -- After lots releases ignoring the 'make the fps camera smoother request', it is now - finally integrated. - -- Removed audiere dependency and the mp3 file, reeducing SDK download size. - -- A bug was fixed causing the binding of the wrong fragment program sometimes in OpenGL. - -- Lots of internal filenames have been renamed. All CVideo* files have been renamed to - fit the other name conventions, CD3D9Driver.h into CD3D9Driver.h for example. - -- The IMaterialRenderer interface now has the new method getRenderCapability() which - returns if the material is able to be rendererd with all settings on current hardware. - -- Added IMeshManipulator::setVertexColors(); - -- Added float color reading support in the 3DS loader. - -- video::EVDF_BILINEAR_FILER renamed to EVDF_BILINEAR_FILTER - -- core::equals function added. - -- fixed a small bug in fast_atof thanks to jox - -- Added a method ICamera::isOrthogonal() which is being used by - ISceneCollisionManager::getRayFromScreenCoordinates(), thanks to a bug report and fix by - jox in this thread: http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=6243 - -- Added some fixes to the GUI environment to make the parent and child pointers be more - consistent as suggested by jox in this thread: http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=6220 - -- Fixed a bug which caused the ambient light not to be reset after a window resize in D3D8 and 9. - Thanks to jox for this bug report and fix. - -- vector3df equals method added. - -- added SColorf::getInterpolated() method - -- Moved ITextSceneNode interface to include folder. - -- Fixed a small bug in the My3DLoader which failed sometimes finding the right textures. - -- Fixed bounding box problem with meshes without joints in .X file loader, thanks to - jox. (http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=6669) - -- Fixed IFileSystem::getWorkingDirectory in Linux version. - (http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=6678) - -------------------------------------------------------------------------------------- -Changes in version 0.9 (28 Mar 2005) - -- There is now a 100% working terrain renderer available. The old buggy and unfinished terrain - scene node has been replaced by a new TerrainSceneNode which is based on Spintz's - GeoMipMapSceneNode and Soconnes terrain renderer. Lots of thanks for their work on - this and that they allowed it to be modified and integrated into Irrlicht. - -- It is now possible for a scene node to draw itself in multiple passes. This means it can - register itself for multiple render passes (E_SCENE_NODE_RENDER_PASS) and during rendering - it can query the current render pass using ISceneManager::getSceneNodeRenderPass(). With - this, SceneNodes can contain solid and transparent materials at the same time and will be - rendered in the correct order from now on. - The IAnimatedMeshSceneNode and the IMeshSceneNode implement this feature, so it is now - possible to create for example cars with transparent windows without the need of a separate - scene node. Because of this change, all render time enumeration values have been renamed. - -- Irrlicht is now able to load OCT files directly. OCT files - can be created with Paul Nette's Radiosity Processor from http://www.fluidstudios.com - or exported from Blender with Murphy McCauley's exporter. This exporter can be found - in the directory \exporters\OCTTools of the Irrlicht SDK or from his homepage - http://www.constantthought.com/project/OCTTools. A lot of thanks go to Murphy McCauley - for this work on this and his permission to include his OCTTools into Irrlicht. - -- Irrlicht is now able to load Cartography shop 4 (.csm) files directly. A lot of - thanks go to Saurav Mohapatra for this work on this and his permission to adapt and - include his IrrCSM library into Irrlicht. If you are using .csm files, please note that - you'll have to set the path of the textures before loading meshes. You can do this using - SceneManager->getStringParameters()->setParameter(scene::CSM_TEXTURE_PATH, - "path/to/your/textures");. The original loader can be obtained from - http://www.geocities.com/standard_template/index.html - -- Irrlicht is now able to load Pulsar LMTools (.lmts) files directly because it now - integrates a modified version of Jonas Petersen's lmts loader in version 1.5 (from - http://development.mindfloaters.de/). Lots of thanks go to him for creating this - loader and giving his permission to add it to Irrlicht. If you are using this loader, - please note that you can set the path of the textures before loading .lmts files. - You can do this using SceneManager->getStringParameters()->setParameter( - scene::LMTS_TEXTURE_PATH, "path/to/your/textures"); - -- Irrlicht is now able to load my3D files directly. The My3DTools 3.12 loader by - Zhuck Dimitry was (a bit modified and) integrated into the engine. Lots of thanks - go to him for his work and for giving his permission to do that. Newer versions - of this loader can be found at http://my3dproject.nm.ru. The exporters for this - file format have also been added into the \exporters directory of the SDK. - -- To be able to replace built-in meshloaders with newer external versions without the - need of recompiling the engine, now mesh loaders which are added to the engine using - ISceneManager::addExternalMeshLoader() are prefered over built-in mesh loaders. - Thanks to for his suggestion of this. - -- D3D8 and D3D9 support for dev-cpp has been improved. If you are using Dev-Cpp and - a DirectX-Devpack for recompiling the engine, just add - -DIRR_COMPILE_WITH_DX9_DEV_PACK to your compiler - settings and something like -ld3dx9 -ld3dx8 to the linker settings and - press 'compile'. - -- The SceneManager now contains an interface for storing and exchanging parameters. - ISceneManager::getStringParameters() returns IStringParameters, which can be used for - example by extensions like external mesh loaders to set and read independent parameters. - This is also currently used by the newly built in CMS, LMTS and MY3D loader: It is possible to - set a value 'CSM_TexturePath', 'LMTS_TexturePath' or 'MY3D_TexturePath' to let them know - the path of the textures. - -- IAnimatedMeshSceneNode now has two new methods for being able to have more influcence - on the animation playback: It is now possible to set the playback mode to looped or - non looped with IAnimatedMeshSceneNode::setLoopMode() and it is possible to set - a callback interface which will be called when animation playback has finished - using IAnimatedMeshSceneNode::setAnimationEndCallback(). Thanks to Electron for his - suggestion for this addition. - -- The software renderer has a new triangle renderer specialized on disabled zread and write. - This means that skyboxes are now rendered in the correct order when using the software - renderer. - -- Multitexturing and other extensions in Linux are now turned on by default. There is a new - #define in the file IrrCompileConfig.h for disabling this again: LINUX_OPENGL_USE_EXTENSIONS - -- There is now a EET_USER_EVENT user event type for making it possible to send custom - events through the system. - -- The setTarget()-method of the FPSCameraSceneNode now is finally correctly implemented. - -- Changing parents of scene nodes is now much safer. The parent member of a scene node now is - set to 0 in all cases and should never point to invalid data when rearranging the scene node - tree. In addition, there is now a getParent() method in the ISceneNode class. - -- Debug breakpoints using "_asm int 3" are now only being used when in debug mode and - using Micosoft's compiler. Now more exotic compilers like BorlandC++ will like - Irrlicht better because of this. - -- Updated zlib version to 1.2.2 - -- An implementation of 3D triangle clipping in the software renderer has been started. It - is not 100% ready, but it is a beginning. This means now for version 0.9, that there are - not that much artifact triangles drawn anymore. But this means also that drawing is - a lot faster and that triangles clipped at the border of the screen will disappear - too fast. If anyone wants to finish the drawClippedIndexedTriangleListT() method - in the CSoftwareDriver class, he is welcome :) - -- There is a new parameter in the IVideoDriver::createImageFromData() which causes the - image to be able to own foreign memory. - -- A renderstate setting has been fixed which caused to disable mip maps on wrong geometry - when there was other geometry which had no mip maps. At least this bug doesn't appear - on my hardware any more, I hope this means the problem it is now fixed. - -- A bug in the D3D version of the stencil shadows has been fixed thanks to Murphy. Sometimes - you could see a small shadow similar to the the real shadow in the scene. This should now - be fixed. - -- Irrlicht can now draw non filled concyclic reqular 2d polyons like triangles, tetragons, - pentagons, hexagons, heptagons, octagons, enneagons, decagons, hendecagons, dodecagon and - triskaidecagons. And circles. Yes, I was a little bit bored. Christian Lins made a - suggestion to add 2D circle drawing support to Irrlicht, and I did this, but also added - support for drawing these figures using the same method. Check out - IVideoDriver::draw2DPolygon(). - -- Removed a memory leak when creating hlsl pixel shaders. - -- I've made varoius updates to the documentation and moved to doxygen 1.4 - -- Fixed a bug in the xml reader which caused it to crash when reading empty xml files. - -- Removed the buggy bsp tree scene node from the engine. - -- Tweaked some settings with some GUI elements. - -- ISceneNode::getAbsolutePosition now should be way faster. - -- Applied a fix by William Finlayson to the opengl stencil shadow drawing code which - fixes several bugs. - -- There is now a min_ and max_ template function available in the core namespace. - -- Added some bugfixes to MayaCameraSceneNode by jox. An even more improved version can - be found at http://development.mindfloaters.de/Downloads.12.0.html. - -- core::array now has a push_front method. - -- core::array now has an insert method. (Thanks to jox) - -- IrrlichtDevice now has a getEventReceiver() method. - -- Fixed a mouse wheel - mouse coordinates bug thanks to a bug report and fix by jox. - -- Changed the first parameter in IGUIContextMenu::addItem(wchar_t* text, ...) to const. - Thanks to jox.. again. :) - -- Fixed ignore path bug in zip file reader thanks to Pr3t3nd3r. It is now possible - to use zip files with the complete path to the files from the archive. - -- Fixed matrix4::rotateVect method after a suggestion by several users. (I think Electron, - Pr3t3nd3r, Jox) Thanks all :) - -- Fixed a bug in CGUIEditbox that enables you to write more characters than the max set - limit, thanks to Rush for the bug report and fix. - -- Added getAngleTrig() method to vector2d as suggested by Pr3t3nd3r, thanks! - -- After a suggestion by schick, plane3d<T> now stores the normal vector first, and then - the distance to the origin. - -- A bug was fixed which caused 2D elements to be drawn with a second texture set in OpenGL - mode when 3D geometry with >1 textures has been rendered before. This effect has often - been reported as darkened 2D gui in the forum. - -- A bug in IrrCompileConfig prevented users to be able to recompile irrlicht with D3D9 - with gcc. This is now fixed, thanks to Jedive. - -- The project setup for Dev-C++ is now nicer. Added lots of folders and cleaned up the - whole setup a little bit with this. - -- Fixed a small bug in CGUIScrollbar reported by Klaus Niederkrueger. - -- The Checkbox rect is now clipped correctly, thanks to jox for that bug report. - -- The debug names of all scene nodes and GUI elements are now set correctly. - -- Applied a patch making it possible to compile Irrlicht without OpenGL in Linux. - -- core::rect::clipAgainst was fixed thanks to a bug report and correction by Jox. - -------------------------------------------------------------------------------------- -Changes in version 0.8 (19 Feb 2005) - -- Irrlicht now supports HLSL. This is possible using the new - IGPUProgrammingServices::addHighLevelShaderMaterial() methods. Also, methods for setting high - level shader constants have been added. - -- Irrlicht.NET now supports events and cursor control. This means now you can read mouse - and keyboard input from .NET projects like C# and VB.net too. - -- There are three new built in materials for doing normal/bump mapping available: - EMT_NORMAL_MAP_SOLID, EMT_NORMAL_MAP_TRANSPARENT_ADD_COLOR and - EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA. If the hardware does not - support these, the materials will fall back to their base materials. To be able to - use these materials, there is the new vertex type 'S3DVertexTangents', the material - does not work with any other vertex types. There are some new methods to create meshes - with this vertex type (IMeshManipulator::createMeshWithTangents()). - -- A new example/tutorial (11.PerPixelLighting) shows how to use per pixel lighting - in your applications. - -- The software renderer now works in Linux, too. - -- Irrlicht now has a built-in normal map generator. It creates on the fly 32 and 16 bit - normal maps from height maps (IVideoDriver::makeNormalMapTexture). As most other things - in Irrlicht, the generator does not depend on D3D, D3DX or OpenGL. - -- Added shader debugging capabilities to Irrlicht. If _IRR_D3D_SHADER_DEBUGGING is - defined in IrrCompileConfig.h (commented out by default), it is now possible to - debug all D3D9 shaders in VisualStudio. All shaders (which have been generated in memory - or read from archives for example) will be emitted into a temporary file for this purpose. - To debug your shaders, choose Debug->Direct3D->StartWithDirect3DDebugging in Visual Studio, - and for every shader a file named 'irr_dbg_shader_%%.vsh' or 'irr_dbg_shader_%%.psh' - will be created. Drag'n'drop the file you want to debug into visual studio. That's it. - You can now set breakpoints and watch registers etc. This works both with ASM, HLSL, - pixel and vertex shaders. - Note that the engine will run in D3D REF for this, which is a lot slower than HAL. - -- Support for compressed .tga texture loading added. (Support from 0.4.1 was buggy) - Thanks to neojzs for posting his improvement. - -- Support for 32 bit .bmp texture loading added. - -- Global particles are now possible. Use IParticleSystem::setParticlesAreGlobal() - to switch between global and local particles. A demonstration of this can be seen in the - new tutorial (11.SpecialFX2). - -- It is now possible to let IGUIImages draw themselves using the alpha channel of the texture - they show. Use IGUIImage::setUseAlphaChannel() for this. - -- ITexture now has a method for rebuilding the mip map levels: regenerateMipMapLevels(). - This is useful for example after locking and modifying the texture. - -- Gravity acceleration speed in CollisionResponseAnimator was changed thanks to a suggestion - by Morrog. The accelerationPerSecond value has been removed beacause of this, you - can now control everything just with the gravity vector. Note that the gravity value - must now be a little bit smaller to achieve the same effect as before. - -- Fixed a problem with several material renderers which weren't able to update their states - at the right time sometimes. A new method OnRender() will be called every time the - material is actually used. - -- Adjusted all tutorials to fit some interface changes. - -- Changed the opengl shader of tutorial 10 to fit the d3d shaders. The now look the same. - -- The MeshManipulator has a new method createMeshWithTangents() which creates a mesh - with normals, tangents and binormals from any mesh. - -- Wrong 2D alpha channel renderstates have been set when using D3D9 and 8. This has been fixed now. - -- When loading 32 bit images with an alpha channel and storing them internally as 16 bit, the - alpha channel got lost. This is now fixed, the remaining one bit alpha channel is now - stored correctly. - -- There is a new overloaded IGUIEnvironment::addImage method, which creates an image directly with - a texture as parameter, adjusting its size to the original size of the texture. - -- A small bug in rect<T>::isValid() has been fixed, thanks to jox. - -- Fixed a bug in D3D8, D3D9 and OpenGL, which caused Materials be set and unset with an unequal - amount when mixing 3d with 2d grafics or stencil buffer shadows. - -- If you are recompiling the whole engine with Visual Studio 6 (which means - Irrlicht.dll, NOT the application which is using Irrlicht), DirectX9 support is disabled - now by default, because Microsoft stopped support for DX9 on VS6 in December - 2004. You can reenable this by uncommenting the new define at the bottom of - IrrCompileConfig.h, if you have an old SDK for example. - -- The mixed fvf and vertex shader system in D3D8 caused a slight issue in Irrlicht ending up - in really messed up render states sometimes. This is now fixed. - -- A major bug with the OpenGL renderer which occured on some OpenGL implementations - has been removed thanks to a bugfix by Murphy and a great report and some investigations - by ElectroDruid. - -- Sorting transparent scene nodes was broken in all previous versions of Irrlicht. This - didn't attract a lot attention because most users used the ADD_COLOR transparencies for which - the sorting is not relevant. Thanks to Morrog and mmm76, sorting now is right. -- After the application window is resized, getViewport() no longer returns viewport as the - first time the window has been created. - -- The draw primitive functions are no longer wrongly checking the maximum primitive count with - the vertex amount value. Thanks to Spintz for the bug report. - -- Template materials in X files just like exported in the panda exporter are now - supported, thanks to JoeWright. - -- Changed the stringc typedef slightly to make it work with people not using - namespace irr. Thanks to schick. - -- Refactored the MeshManipulator code, which in some cases now uses template methods for performing - calculations on different vertex types. - -- Fixed an interface problem with newer versions of libJPEG. - Thanks to Fabien Coutant and Simon Barner for some help and clues into the right direction. - Was not able to add system specific zlib/jpeglib support due to issues on - some strange systems/users and a lack of time, sorry. - -- Typo in plane3d and triangle3d: method isFrontFacting renamed to isFrontFacing. - -------------------------------------------------------------------------------------- -Changes in version 0.7.1: (26 Sep 2004) - -- Fixed some bugs which prevented the engine to compile with gcc 3.4.1. - -- Fixed a problem with the OpenGL driver, which caused the renderstates not to be reset correctly - when drawing scene nodes with reflective materials. - -- Fixed error in Irrlicht's software mip map generation, which caused that some mipmap levels - looked strange. This fix was found by jox, the hardcore bug fixer, - so many thanks go to him. Again. :) - -- Disabled hardware mip map generation in D3D9 again, because it seems to cause problems on - some hardware. I don't have any hardware where this problem occurs, but I hope this helps. - -- Fixed a small bug in fast_atof submitted in the forum by da_dude. - -- Fixed string operator + after a bug report by osre and a fix suggestion by jox. - -- IEventReceiver now has a virtual destructor for the people who needed it. - -- 3DS-Loader patched due to some suggestions of Daniel Azkona Coya. - -------------------------------------------------------------------------------------- -Changes in version 0.7: (11 Sep 2004) - -- The first version of Irrlicht.NET is included in this release. It is a managed C++ - wrapper .DLL which makes the most important features of the engine available for all - .NET languages. The wrapper is incomplete, but it can already be used. - You can find the documentation for this .DLL in the compiled help file doc\IrrlichtNET.chm. - There are also two very basic examples available, which show how to use Irrlicht.NET - from C# and VisualBasic. - -- Low level vertex and pixel shader programming is now possible. There are - now some methods with wich you can write GPU programs in vertex/pixel shader assembler - using Direct3D 8 and 9 and in ARB vertex and fragment program assembler for OpenGL. - You can use the IGPUProgrammingServices interface which can be reached by - IVideoDriver->getGPUProgrammingServices() for this. The new material types you can create - with this can be combined with all other already existing material types. - For example, it is possible to create a new material which uses a vertex shader to - calculate texture coordinates and diffuse colors, and let this be rendered by the built in - material video::EMT_TRANSPARENT_ADD_COLOR. - Support for high level programming languages like GLSL or HLSL is planned for the - following releases. Also note that you won't be able to use all techniques shaders offer with - Irrlicht, due to its current high level abstraction of the 3D APIs. For example, the engine - does not expose vertex streams or vertex buffers currently. - -- There is a new tutorial showing how to use shaders with the engine. In addition, all - old tutorials have been rewritten and adapted. For example, the hello world - tutorial now also shows how to set up visual studio .NET to use it with - the engine. - -- Hardware mip map level generation of textures is now supported when using D3D9. - -- Internal pointers and data of the video drivers can now be exposed for experienced users with - VideoDriver::getExposedVideoData(). For example, you can get a pointer to the IDirect3DDevice9 - interface and the HWND window handle, if the engine is running with D3D9. - -- The createDevice() function has a new additional parameter: bool vsync. With this, it is now - possible to enable or disable the waiting for the vertical retrace period. This is implemented - in D3D9, D3D8, and the Windows OpenGL driver only, the software driver will ignore this flag. - -- The engine now behaves like in the documentation: irr::createDevice() returns 0, if - the desired driver could not be initialized. - -- There is a new SceneNode available: The ITextSceneNode is able to display 2D text at a - position in 3D space. Use ISceneManager::addTextSceneNode() to create one. - -- Finally now all VideoDrivers have a draw2DLine() implementation, thanks to some additions sent in - by Vash TheStampede. - -- Applied some changes to the compilation configuration, so that it should now - be easier to use the engine with XBOX projects. Thanks to MattyBoy for sending - in some clues for this. - -- Some improvements for the linux version of the engine: The NULL device is finally fully operational with Linux - too, and also all examples and even the techdemo compile and run with this OS. - -- The default field of view in the cameras of the irrlicht engine was a little bit - extreme, so I changed it now from core::PI / 3.5f to core::PI / 2.5f. - -- Added a new draw2DImage method for partially draw a 2d Texture, as sent in by zola with - implementations for OpenGL, D3D8 and D3D9. Software implementation is missing. - -- The string class is now able to convert integer values into a string or append it as string - to itself. - -- Added a getDriverType() method to the IVideoDriver interface. - -- Added a getTransform() method to the IVideoDriver interface. - -- The EMT_TRANSPARENT_ALPHA_CHANNEL material in OpenGL is now implemented. - -- The integrated XML Parser now works better with different text file formats. (ASCII, UFT-16,..) - -- IGUIEdit Box now feels more like a windows editbox, thanks to some changes by Jox - -- Added a new method to IVideoDriver: createImageFromData as suggested by Oliver Klems. - -- Fixed a the EMT_TRANSPARENT_ALPHA_CHANNEL problem in D3D8 and D3D9 due to a suggestion by Jox. - -- Added 3 methods created by zola to the quaternion class: fromAngleAxis(), toEuler() and - operator*(vector3df&). - -- A bug in a matrix multiplication operator was fixed. - -- Changed visual studio project files to version 7.1, but provided 7.0 project files - for people with that version. - -- Added SceneNodeAnimatorRotation rotation fix as posted by warui - -- Added normalization fix to vector2d and 3d. Warui suggested a fix like that in the forum. - The one I made has the same result, but is a little bit faster. - -- Fixed some problems with the drawStencilShadow() method in the OpenGL implementation of the - IVideoDriver interface after some suggestions by Nicholas Bray. - -- Added IGUIButton::setPressed() and isPressed(). - -- Fixed checkPrimitiveCount() bug in NullDevice. - -- Applied jox's matrix4::getRotationDegrees() fix, many thanks for posting this! - -- Changed aabbox3d::getExtend() to getExtent(). - -- Changed IXMLReader::isEmtpyElement() to isEmptyElement() - -- Fixed a bug in CSceneManager::getSceneNodeFromId() which caused the engine to crash sometimes. - -- Fixed a bug in CGUISkin::setSize reported by REAPER. This method never worked before. - -- Improved texture mapping and normals of the TestSceneNode, thanks go again to Jox. - -- ScrollBar is now posting mousewheel events, thanks go to REAPER to post this bug and a fix for it. - -- Added - operator to vector2d and vector3d, thanks to calimero - -- Fixed a bug in vector2d::getAngle() and vector2d::rotateBy() thanks to Jox. - -- Fixed a bug in quaternion::set(f32 x, f32 y, f32 z) thanks again to Jox. - -- Fixed a bug in list::insert_before and list::insert_after, reported by Haddock. - -- Fixed a bug in XML Parser which caused a seqfault on linux. Thanks for G.o.D reporting this problem. - -- EDriverType enumeration renamed to E_DRIVER_TYPE - -- SceneNodeRenderTime enumeration renamed to E_SCENE_NODE_RENDER_PASS - -------------------------------------------------------------------------------------- -Changes in version 0.6: (09 Mar 2004) - -- Irrlicht now includes its own XML parser. It provides forward-only, read-only - access to a stream of non validated XML data. It can read everywhere Irrlicht can, - also in compressed .zip-Files for example. Use IFileSystem::createXMLReader() to - use it. - -- Like the new XMLReader, there is also a IXMLWriter available for making it easier - to write xml files. - -- There is a new tutorial available in the SDK. It is for more advanced users, and - shows how to create a 3d model viewer with the engine easily. It shows how to - use menus, tabcontrols, edit-, message- and sky boxes. - The resulting program can also be used as tool, to check if the engine - loads exported 3d models correctly. - -- Again, there are some new GUI widgets available: A ComboBox, a ToolBar, a PushButton - and an ImageButton. The last two are simply the old IGUIButton, but it is now able - to display additional images and behave like a PushButton. - -- It is now possible to make the drawing window resizeable, if it is in windowed mode. - Use IVideoDriver::setResizeAble(true) to do this. - -- The .x file reader and animation player now should work with 99% of all text .x files. - This is achieved by most of the following bug fixes. - -- Fixed a huge bug in the .x file reader, which caused that negative coordinates were - interpreted as positive ones sometimes. This caused that sometimes .x animations - were played wrong. - -- Slerp interpolation of the quaternion class fixed. This means that also some bugs - in the animation of .x files are removed now. - -- Added virtual joints to not weighted vertices to improve .x file animations. - -- The FileSystem is now 100% implemented. Finally it is now possible to write files - too. There is a new Class IWriteFile and the corresponding - IFileSystem::createAndWriteFile() - -- Added lots of text and sample code to the documentation. In most parts - documentation should be clearer now. - -- The ISceneManager has a clear() method, which clears the whole scene, all scene nodes - are removed. - -- All ISceneNodes now own a new method called removeAll(), which deletes all children - of the node. - -- Fixed a bug which prevented the possibility to compile directx8 without - having installed directx9. - -- Fixed a bug in 3d line dawing in D3D 8 and 9. - -- All video drivers now print out the gfx adapter type, vendor and driver version - into the log strings. - -- The D3D9 device is now as fast as the D3D8 device. - -- The string class has an additional new constructor for creating a string from - character data with a specific length. - -- Bug fixed in string class assignment operator which might cause a crash in very - special circumstances. - -- Added a findNext() method to the string class. - -- The ISceneNode class now has a isDebugDataVisible() method. - -- Some lines were changed to make the source of the engine compatible to VS.NET 2003. - -- Some functionality of the IFileList and IFileSystem was missing in the Linux version - of the engine. This caused the FileOpen-Dialog not to work. I fixed this problem. - -- The Middle and Right mouse button were swapped in the Linux version. This is now - fixed. - -- Multitexturing should now work with most linux systems too, thanks to a bug - report by Martin Piskernig. - -- The logger now has an additional log() method which accepts another combination - of strings. - -- Fixed a bug which caused fonts to be displayed very transparent in OpenGL. - -- Removed one of the redundant overloaded IGUIEnvironment::updateAbsolutePosition() - methods. - -- Fixed lots of clipping problems in all GUI Widgets. - -- core::rect has the new methods getCenter() and isValid(). - -- Scrollbar buttons are now disabled if it is not possible to scroll. - -------------------------------------------------------------------------------------- -Changes in version 0.5: (17 Feb 2004) - -------------------------------------- -/ Highlights in short: -/ * DirectX 9 support -/ * .x file support in all render devices including opengl and software -/ * new materials like lightmaps with dynamic lighting -/ * fog -/ * stencil buffer shadows now also work in OpenGL device -/ * more gui widgets: tab controls, edit boxes, menus -/ * spline animation support -/ * mouse wheel support -/ * triangle fan drawing -/ * quaternions -/ * improved keyboard input control -/ * lots of bugfixes including improved quake 3 map support -------------------------------------- - -- DirectX 9 is now supported by Irrlicht. This does not mean that it replaces - DirectX 8. The engine now supports both. You can now select between OpenGL, - DirectX8, DirectX9, Software and the Null device. - -- The engine now is able to read and display .x files. Using - Microsoft's excellent .x file exporter for Maya or MAX which comes - with the DX8 and DX9 SDK, it is now possible to create content for - the engine easily. Using .X files with Irrlicht is independent of D3D, - they can be used with OpenGL and with Linux for example too. - Currently only text file .x files are supported, and some animated .x - files may be displayed not 100% correctly, because the animation player - may still have some small bugs. It works perfectly with most .x files which - come with the DX9-SDK. Some skinned mesh .x files which use - quaternions for animating joints have some problems, there might be a - bug somewhere. I commented the lines with a possible bug in CXAnimationPlayer.cpp. - -- The GUI Environment now supports edit boxes. They should support unicode input - from every keyboard around the world, scrolling, copying and pasting (exchanging - data with the clipboard directly), maximum character amount, marking and all - shortcuts like ctrl+X, ctrl+V, ctrg+C, shift+Left, shift+Right, Home, End, - and so on. Wow, I never programmed an edit box, its much more work than it - seems to be. - -- Tabcontrols are now available in the GUI environment. It is also - possible to create tabs without tabcontrols, to be able to create - invisible gui elements for grouping other elements together. - -- Another new supported GUI Element are context menus. They support - ordinary text menu items, separators and sub menus. In Addition, - a standard menu as seen at the top of most windows can be - created easily with them. - -- Rewrote all tutorials to fit the new API. - -- Spline animations are now supported thanks to a spline scene node animator - written by Matthias Gall. - -- Taskswitching now works with Direct3D 8 and 9 devices in fullscreen mode. - -- Added Material types EMT_LIGHTMAP_LIGHTING, EMT_LIGHTMAP_LIGHTING_M2, - EMT_LIGHTMAP_LIGHTING_M4 and EMT_LIGHTMAP_ADD. - -- The engine now supports drawing of trianglefans. To do this, use - IVideoDriver::drawIndexedTriangleFan(). Mario Gruber sent in code for this, - so lots of thanks go to him! - -- It is now possible to draw 3d objects with fog. Simply switch on the fog flag - in the objects material. To change to way fog is drawn (per pixel/vertex, color, - linear/expontential) use IVideoDriver::setFog(); - -- With IrrlichtDevice::getOSOperator() a pointer to an interface is returned, with - wich it is possible to do some operation system specific operations. Currently - there are only 3 methods supported, but more will be added in the future. - -- Mouse wheel input is now supported. - -- The Key Event structure of SEvent now contains a Char entry, describing the - corresponding character of the pressed key. Also two bools were added, - specifying if shift or ctrl was pressed too. - -- The version of the Operating System is now printed out into the log at - startup. - -- There is now a non-const getBoundingBox() method in IMeshBuffer and - IMesh available. - -- IGUIElement now has a method getElementFromId(), which searches children - (and its children if wanted) for an element with a specific id. If you - want to search all items, just do - IGUIEnvironment::getRootGUIElement::getElementFromId(). - -- ISceneNode::updateAbsolutePosition() is now public - -- Small bug fixed in CMeshManipulator::scaleMesh(). - -- The engine now supports Quaternions. - -- A bug was fixed causing the windows caption not to be displayed in - Windows 95/98/ME. - -- IGUIEnvironment::getBuildInFont() was renamed to getBuiltInFont(). - -- IGUIElement::bringToFront() is able to brint a child to the front. - Windows for example are now using this new feature. - -- Changed the texture mapping of the test scene node a little bit based on - code sent in by Dr Andros C Bragianos. - -- Added code to fix some bug in some ATI drivers. Thanks to ariaci for posting - this code. - -- Stencil buffer shadows now also work with the OpenGL device, they worked only - in D3D in earlier versions. Lots of thanks go to Philipp Dortmann, who - sent in a modification to the opengl driver! - -- IGUIStaticText::setWordWarp() renamed to setWordWrap(), - IGUIStaticText::enableOverrrideColor() renamed to enableOverrideColor() - [thanks to saigumi] - -- A bug was fixed, causing that the window was not able to be closed with Alt+F4 - in Win95/98. - -- Optimized the Octree-Scene node a little bit for getting more rendering speed. - Culling is now done with the real frustum, not the bounding box around it. - Speed increase is about 5%, it's not much but ok. - -- Bug fixed in the Quake 3 .bsp file loader, which caused holes to appear in - some maps. - -- Combination of 3D displaying and drawing GUI elements was improved, and the - priority of input receiving of 3d cameras and gui elements swapped. - -- A bug in the static text was fixed, which caused it to draw itself outside - of its clipping rectangle. - -- KeyFocus and MouseFocus methods in GUIEnvironment are now merged into one method. - -- The Clamptexturecoordinates flag in the material was removed. - -- IVideoDriver::draw3DLine in all devices was improved. - -- The devcpp-version of the binary DLL which comes with the SDK is now faster. - I'll compile this version from now on always with optimization switched on. - -- Other, Minor New/Changed methods in public interfaces: - * buildShadowMatrix in matrix4 - * getRotationDegrees in matrix4 (sent in by Chev) - * rotateVect in matrix4 - * linear_search in array - * recalculateBoundingBox in MeshManipulator - * ISceneManager::addStaticText() now has a parameter for word wrapping - * getCharacterFromPos() in IGUIFont - * drawMeshBuffer() in IVideoDriver; - * interpolate() in matrix4 - * getLast in array - -------------------------------------------------------------------------------------- -Changes in version 0.4.2: (13 Dec 2003) - -- The engine does no more use only 16 bit textures internaly. Now all - other texture formats are supported too. This means higher precision - and better quality images. In this context, the ISurface interface has - been replaced by IImage, and the ISurfaceLoader by IImageLoader. - -- By changing the texture creation mode of the IVideoDriver, it is now - possible to influence how textures are created: You can choose between - 'optimized for speed', 'optimized for quality' or simply set constant - bit depth like 'always 32 bit'. Also, you can now enable and disable - Mip map generation with these flags. Take a look at - IVideoDriver::setTextureCreationFlag() for details. - -- There is now some support for outdoor or terrain rendering available. - You can create a static mesh from a heightmap and a texture using - ISceneManager::addTerrainMesh(). You can specify a huge texture if you - like, even bigger as your hardware allows to render, because the texture - will be splitted up if necessary. - Another possibility for doing terrain rendering is the new Terrain Scene - node. But it is only in a very early alpha stage, I disabled for example - the use of different level of details. - -- It is now possible to load software images into memory from files on - disk, without creating a hardware texture. You can do this by calling - IVideoDriver::createImageFromFile(). This is very useful for example - for loading heighmaps for terrain renderers. - -- The Quake 3 Map Loader now supports curved surfaces, thanks to by Dean P. Macri - who sent in his code. (He also sent in lots of other cool stuff, which I will merge - with the code of next releases, lots of thanks to him!) - -- It is now possible to control what text is printed out to the console and - the debug window of Visual Studio. By getting a pointer to the ILogger - interface, is is possible to adjust if Warning, Error or Informational - texts should be printed out. In addition, now every text can be catched - by the event receiver. - -- The engine is now capable of loading .PCX files. Only a few PCX formats - are supported currently, but at least the common used formats - of most textures of the quake 2 models. Thanks go to Dean P. Macri who - sent in the code for the new PCXLoader! - -- A new Scene node is available, which simply does nothing. It is useful for doing - advanced transformations or for structuring the scene graph. - -- The ISceneManager::addOctTreeSceneNode() now takes AnimatedMeshes as parameter. - If this new method is called, the first frame in the animated mesh is taken as - mesh to construct the octree. This means that you won't have to write - addOctTreeSceneNode(yourMesh->getMesh(0)) anymore, but can use - addOctTreeSceneNode(yourMesh), which is a little bit more intuitive. - -- The Driver type enumeration have been adapted to the Irrlicht - naming conventions. For example instead of writing DT_OPENGL, now write - EDT_OPENGL. - -- The ITexture interface has two new methods for getting the size of the - texture: ITexture::getSize() and ITexture::getOriginalSize(). This replaces - the old getDimension()-method and allows to disable bugs which are generated - by the automatic scaling to optimal sizes of textures. - -- There are some new keycodes available: KEY_COMMA, KEY_PLUS, KEY_MINUS, KEY_PERIOD. - -- There are now 3 lightmap Material types: EMT_LIGHTMAP, EMT_LIGHTMAP_M2 and - EMT_LIGHTMAP_M4, which are making the lightmaps 2 or 4 times brighter. If you used - the Material EMT_LIGHTMAP in your code, you should replace it now with - EMT_LIGHTMAP_M4. - -- The transformation enumeration names have been adapted to the irrlicht - naming conventions. For example instead of writing TS_VIEW, now write - ETS_VIEW. - -- Video driver feature enumeration names have been changed from - EK3DVDF_... to EVDF_... - -- The GUIEnvironment now has a new method: getRootGUIElement(). With this it - is possible now to add external created custom GUI Elements to the gui environment, - without an existing internal GUI element as parent. - -- The setViewPort()-Method of the OpenGL-device now works, too. Nothing stands now - in the way of creating splitscreen applications using the OpenGL device. - Oliver Klems sent code for this, I slightly modified it. Thank you! - -- Corrected a bug, which made the EMT_REFLECTION_2_LAYER Material disappear on some - hardware. - -- Sirshane sent in a bug fix: It is now possible to make the mouse cursor - invisible in the Linux version of the engine. Thanx sirshane! - -- getFrameNr() of IAnimatedMeshSceneNode is now public. - -- Again a small bug in the 3ds file loader was fixed. - -- A small bug causing light positions being transformed in the OpenGL - driver differently compared to D3D. Thanx to Matthias Gall for reporting - this! - -- Typing error fixed: ISceneCollisionMananger::getRayFromScreenCoordiantes renamed to - getRayFromScreenCoordinates. - -- Linux support with multitexturing and mipmap generation has been improved. - -- A bug was fixed wich caused the Engine not to run when compiled - as dynamic library under linux. Thanks to Shane Parker who pointed out - the problem. - -- A bug was fixed in position2d.h in the operator +=, and the list iterator now - has per and postfix operators. Thanks to Isometric God for spotting this out. - -- A bug was fixed in the Metatriangleselector, causing it to detect only collisions - with the last TriangleSelector in it. - -------------------------------------------------------------------------------------- -Changes in version 0.4.1: (18 Sep 2003) - -- Input events are now processed faster than repaint and window events. This - means that input commands now effect things directly, in earlier versions - there could be a delay when there were low frames per second. Some people - noticed this when moving with the fps camera in large levels: The camera - sometimes stopped seconds after the button was released. This is now fixed. - -- A Message Box is now available in the GUI Environment. It looks like the - windows message boxes and supports OK, Cancel, Yes and No buttons, which - can be combined freely. Also, it shows multiline text and adjusts its size - based on the amount of text it shows, so it should be very useful for displaying - (debug) messages during runtime. - -- It is now possible to make all windows (message boxes, file open dialogs, - simple windows) modal. - -- IGUIStaticText now supports multiline text via automatic word warp and manual - line breaking with '\n'. You only need to switch it on with - yourText->setWordWrap(true); - -- Non default MD2 animations are now supported. Which means simply that you can - enumerate the names of all md2 animations and the AnimatedMeshSceneNode now supports - a setMD2Animation() with a character string as parameter instead of a constant. - -- You do not need an event receiver anymore for sending user events to the active - camera, this is now done autmaticly. In addition, it is now possible to - set a new event receiver during runtime of the engine using IrrlichtDevice:: - setEventReceiver(). - -- It is now possible to disable and enable the input receiver of a camera. This - is useful for example for removing the users control of the camera. To do this, - call camera->setInputReceiverEnabled(false); - -- The first person shooter camera now supports a keymap: You can define your own - key mapping to control the camera when you create it with ISceneManager:: - addCameraSceneNodeFPS(). - -- Thanks to Jon Pry, the engine now also loads compressed TGA texture files. Now only - 8 bit palette using TGAs are missing. :) - -- There are methods for converting 3d coordinates in 2d coordinates and the other - way round. You can find them as two new methods of the ISceneCollisionManager: - getRayFromScreenCoordiantes() and getScreenCoordinatesFrom3DPosition(). - -- There are now access methods in IGUIWindow for getting pointers to the - maximize, minimize and close buttons, to be able to remove them for - example. - -- Before starting up the engine, a version check now is performed and a warning is - written, if Irrlicht.DLL version and header version of your application do - not match. - -- A bug with the skybox has been fixed: In OpenGL, it was possible to see the - borders of the skybox. In addition, when a skybox was visible, there were - errors in the texture coordinates of other meshes. This is all fixed now. - -- A bug has been fixed causing the engine to crash when removing gui childs - which where created inside the .dll but are removed from outside. - -- A bug was fixed causing the engine to crash when drawing debug data of - octtree scene nodes with geometry data with vertices with one texture - coordiante. - -- Multitexturing now works with linux, too. Thanx to Jon Pry again, for showing - me where the problem was. - -- The bug (reported by saigumi) preventing scene nodes attached to a camera - from moving correctly is now fixed. - -- The "Climb-Walls" bug (reported first by Matthias Gall) is fixed. Gravity - acceleration is now quadratic instead of linear. - -- A warning is now printed out, if more vertices are rendererd with one call - than the hardware supports. - -- Other, Minor New/Changed methods in public interfaces: - * get and setText() in IGUISkin - * += operators are now available in the string class. - * setRelativePosition() in IGUIElement - * enumeration EKEY_CODES renamed to EKEY_CODE - * getMaximalPrimitiveCount() in IVideoDriver - * getAnimationCount() in IAnimatedMeshMD2 - * getAnimationName() in IAnimatedMeshMD2 - -------------------------------------------------------------------------------------- -Changes in version 0.4: (04 Sep 2003) - -- Collision detection and reponse based on ellipsoids in now implemented. - There is a new method available in the ISceneCollisionMananger, which returns - a collision response point. In addition, a new SceneNodeAnimator is available, - which causes a scene node, to which it is attached to, not to move through - walls, to climb stairs and to be affected by gravity. This scene node animator - can be attached to any scene node. For example adding it to the FPSCamera, it makes - the user possible to walk through the 3d world as in first person shooters. - -- There is now a full featured Particle System included in the engine for - creating fire, explosions, snow, smoke and so on. - It is customizeable and extensible. There is a ParticleSystemScene node - available in the SceneManager and some standard particle emitters and - affectors are already implemented. - -- Realistic water: The engine now features an IWaterSurfaceScene node, which - animates a static mesh with water waves. In combination with the new - EMT_REFLECTION or EMT_TRANSPARENT_REFLECTION material type, you can easily - create realistic animated water surfaces. - -- Triangle base picking is now possible using the ISceneCollisionMananager. - If a collision happened, the intersection point and the triangle causing - the intersection is returned. - -- Stencil shadows are now drawn using the ZFail method by default, but it is - possible to choose ZPass, if wished. This means that the camera may now move - inside the shadow volumes and no errors will occur. In addition a stencil - shadow bug is now fixed: In 0.3 there where no shadows visible in the TechDemo. - -- The interface of ISceneNode has changed: There is no more a RelativeTransformation - and AnimatedRelativeTransformation matrix. They have been replaced by 3 vectors: - RelativeTranslation, RelativeRotation and RelativeScale, which can be accessed by - the corresponing get() and set() methods. This simplifies the interface - a lot. Also, the set/getRelativePosition was renamed to set/getPosition. - -- The new IAnimatedMeshMD2 interface now returns start, begin time and - fps of every MD2 animation type. In this context, IAnimatedMeshSceneNode - got a new method called setMD2Animation(), which accepts a single constant - like EMAT_ATTACK, which starts and plays the fitting animation (attack - animation in this case), simplifying the interface a lot. - -- Some scene nodes can now draw debug data like their bounding boxes. - This feature is switched on for a single node by calling - ISceneNode::setDebugDataVisible(true). Looks really interesting for - animated scene nodes like particle systems or animated meshes. - -- There is now a IGUIInOutFader avaiable, which is able to fade in or - out the whole screen or parts of it. - -- The new IVideoModeList is a list with all available video modes. It can - be retrieved with IrrlichtDevice::getVideoModeList(). If you are confused - now, because you think you have to create an Irrlicht Device with a video - mode before being able to get the video mode list, let me tell you that - there is no need to start up an Irrlicht Device with DT_DIRECTX8, DT_OPENGL or - DT_SOFTWARE: For this (and for lots of other reasons) the null device, - DT_NULL exists. - -- With the new IMeshManipulator interface accessible with - ISceneManager::getMeshManipulator() it is possible to perform some basic - operations on meshes: Flipping all surfaces, recalculating all normals, - scaling the mesh, creating a new texture mapping and so on. - -- A new material for creating water surfaces or glass with reflections on it - is available: EMT_REFLECTION_2_LAYER and EMT_TRANSPARENT_REFLECTION_2_LAYER. - It has uses a reflection map, and an additional optional texture. - The transparency of this material is set by the alpha color value in the vertices. - -- Another new material is EMT_SOLID_2_LAYER. It is a material with 2 textures, - blended together with the alpha value of the vertex color. This material is - currently only available in DirectX. - -- Trilinear Filtering is now supported by the engine. - There is a new option in SMaterial: TrilinearFilter and EMF_TRILINEAR_FILTER. - -- The addChild() method of the IAnimatedMeshSceneNode for adding SceneNodes to - joints of skeletal animated meshes was removed. - Instead there is now a new method: getMS3DJointNode(). This returns a pointer - to a child node, wich has the same transformation as the corrsesponding joint. - In this way it is possible to do more advanced operations with joints and - attaching scene nodes to joints. Also, the IAnimatedMeshMS3D interface now gives - access to all joints. In this way, you can easily enumerate all names of all - joints in the mesh. - -- Font and color of every IGUIStaticText can now be set separately, without - modifying the IGUISkin. - -- There is now a ELEMENT_LEFT gui event, which all hovered elements receive when they - are left. - -- All features of the FileOpenDialog are now working. - -- Debug informations are now printed out to the console window - also on the win32 platform. - -- FPSCamera now supports setTarget(). Its not precise but working. - -- Textures of 3ds files are now loaded from the same directory in which the - 3ds file is. If the texture is not found there, the texture is tried to be - loaded from the current working directory. - -- A small bug in the 3ds file loader has been fixed. There were 3ds files exported - by anim8or, where the reading of the 3ds file never stopped. - -- It is now possible to configure the minimal amount of polygons contained - in every node in an OctTree via addOctTreeSceneNode(). - -- There is a new template class in the core namespace: triangle3d. With this, - it is easy to find intersections between lines and triangles, find out if - a point is within a triangle and so on. - -- A small bug in ISceneManager::addHillPlaneMesh() was fixed: Now the right tile - amount is created. - -- There is a new SceneNode available: IDummyTransformationSceneNode. It exists - for making it possible to insert matrix transformations anywhere into the - scene graph. - -- Added a new SceneNode animator for deleting Scene nodes automaticly after some - time. Create it with ISceneManager::createDeleteAnimator(). - -- The techdemo now is interactive. After a short non-interactive flight over - the quake 3 level, you are placed as player inside the level, may move around, - shoot fire balls and take a look at some animated characters which are placed - on the map. - -- I fixed a bug which caused the screen get black when choosing shadows and fullscreen - on some special 3d adapters. - -- I fixed some bugs in the linux port: The timer returned an incorrect time, causing - wrong animations everywhere and the releasing of keys and mouse buttons was not - sent as event. In addition, I placed a copy of the zlib.a and jpeglib.a into the - /lib/Linux directory and changed the Makefiles of the examples and the source - of the engine for doing this automaticly in the future, so I hope there will be no - problems with other versions of zlib and jpeglib anymore. - -- There are 2 new tutorials: One showing how to do collision detection and - for special effects. - -- Other, Minor New/Changed methods in public interfaces: - * getVersion() in IrrlichtDevice - * getLengthSQ() in vector3d - * getInterpolated() in vector3d - * getInterpolated() in SColor - * getAngle() in vector2d - * getAngleWith() in vector2d - * getPrimitiveCountDrawed() in IVideoDriver renamed to getPrimitiveCountDrawn() - * getSceneNodeFromSceenCoordinates() renamed to getSceneNodeFromScreenCoordinates() - * getMeshType() in IAnimatedMesh - * getInterpolated() in aabbox - * setMD2Animation() in IAnimatedMeshSceneNode - * getFullFileName() in IFileList - * addShadowVolumeSceneNode() in IAnimatedMeshSceneNode extended with zfail parameter - * drawStencilShadowVolume() in IVideoDriver extended with zfail parameter - * getDistanceFromSQ() in vector3d - * subString() in string - * findFirst() in string - * findLast() in string - * getTriangleSelector() in ISceneNode - * setTriangleSelector() in ISceneNode - * draw3DTriangle() in IVideoDriver - * setShadowColor() in ISceneManager - * getShadowColor() in ISceneManager - * addToDeletionQueue() in ISceneManager - * getSceneNodeFromId() in ISceneManager - -------------------------------------------------------------------------------------- -Changes in version 0.3: (18 Jul 2003) - -- Linux port: The Irrlicht Engine now compiles and runs on Linux. Currently only - the OpenGL driver is available. The Software driver would be there too, if - somebody could tell me a fast way to blit a A1R5G5B5 surface to the screen - using X. - All examples do compile and run, but there are some things missing: - * It is not yet possible to make the mouse cursor invisibe. - * The timer seems not to return the currect time. - * Multitexturing does not work correctly on all gfx adapters. - -- Ms3D Animations: The engine is now able to play skeletal animations directy - from Milkshape 3D (.ms3d) files. It is also possible to attach objects to - parts of the animated mesh. For example a weapon to the left hand of - the animated model. - -- Because the swprintf function in Windows32 does not match the ISO C standard, - and it does in linux and all other platforms, there is now a define in Irrlicht.h, - to make the code be the same on all platforms: - #define swprintf _snwprintf - This simply means that you need to add a parameter to your swprintf calls if - you used this function in your win32 irrlicht engine projects. For example instead - of writing - wchar_t tmp[255]; - swprint(tmp, "FPS: %d", fps); - you now write - wchar_t tmp[255]; - swprint(tmp, 255, "FPS: %d", fps); - -- Automatic culling has changed a little bit: It is now done by the SceneManager. - Scene nodes now only need to return a valid, non transformed bounding box to be - culled automaticly. It is explaned in the CustomSceneNode Tutorial how this works. - -- It is now possible to use the engine easily for 2D graphics: There are now to new - methods in the IVideoDriver, which create an 1bit alpha channel for textures - using an color key. The methods are both named makeColorKeyTexture. There is a - tutorial '2d graphics' which explains how this works. - -- The rect template class was removed and replaced by the rectEx class. There - is now only one rectangle template available, called 'rect' for simplifying - the interface. - -- The texture coordinate bug in Milkshape 3d models with lots of shared vertices - was fixed. - -- Bugfix with GUI environment hovering invisible elements. - -- There are two new tutorials: One for 2d graphics, and one for user interface. - -- Tutorial changes: - * All backslashes replaced by slashes in file names in - all tutorials for linux compatibility. - * RectEx replaces with rect in 1.HelloWorld - * Added second parameter to swprintf in 2.Quake3Map - * Added bounding box creation to 3.CustomSceneNode - * Added second parameter to swprintf in 4.Movement - -- New/Changed methods in public interfaces: - * getClosestPoint in line3d - * getMatrixOfMeshPart in IAnimatedMesh - * removeChild in ISceneNode now returns true or false - * addChild in IAnimatedMeshSceneNode - * setParent in ISceneNode - -------------------------------------------------------------------------------------- -Changes in version 0.2.5: (22 Jun 2003) - -- A new material type is available: EMT_TRANSPARENT_VERTEX_ALPHA, which - realizes transparency based on the vertex alpha color. It currently is - only implemented in the DirectX device. - -- There is now an ISceneCollisionManager available. Get it with - getSceneCollisionManager() from the ISceneManager. It currently only implements - picking, but more is coming soon. - -- Automatic Culling based on Bounding Boxes is implemented now. It can be switched on - or off for every SceneNode seperately using ISceneNode::setAutomaticCulling(). - It is on by default. - -- It is now possible to remove loaded textures for freeing memory or reloading them. - Use IVideoDriver::removeTexture() or removeAllTextures(). - -- New drawing methods in the IVideoDriver interface: - * Draw3dLine(), drawing a 3d line. - * Draw3dBox(), which draws an axis aligned bounding box. - * Draw2dLine(), currently only supported by the Software device. - -- MD2 bugfixes: - * There was a small bug with texture coordinates. - * Frames are now correctly interpolated when playing animations. - -- Bugfix in the 3ds file format loader: Single objects in the 3ds file with multiple - materials attached are now loaded correctly. - -- list.h renamed to irrlist.h due to compatibility issues. - -- Now works with Dev-C++ 5 Beta 8. (4.9.8.0) - -- New/Changed methods in public interfaces: - * 'getInverse' in matrix4. - * 'transformBox' in matrix4. - * 'repair' in aabbox. - * 'intersectsWithLine' in aabbox. - * 'getVector' in line3d. - * 'getMiddle' in line3d. - * 'normalize' method in vector3d and vector2d now returns reference to vector. - * 'getTransformedBoundingBox' in ISceneNode. - * 'getChildren' in ISceneNode - * 'setRotation' in ISceneNode - * 'addHillPlaneMesh' in ISceneManager now accepts a texture repeat count parameter. - - -------------------------------------------------------------------------------------- -Changes in version 0.2: (19 May 2003) - -- The engine is now able to load .3ds files, with their materials and textures. - -- There are some new SceneNodeAnimators: A fly straight animator and a texture animator. - -- Texture coordinates can now be set to clamp or wrap mode with - a flag in the SMaterial struct. - -- Skyboxes are implemented. - -- Billboards now work 100% correctly. - -- The IAnimatedMeshSceneNode is now able to draw shadows of itself. To enable this, just call - addShadowVolumeSceneNode(). Please note that shadows are currently just experimental, - there are some bugs, and they only only in Direct3D mode. - -- A small bug in the view frustum and the octree fixed. - -- The default aspect ratio in all camera scene nodes was changed. - -- Some changes and extenstions to the core::matrix4, SViewFrustum, plane3d and - aabbox were made. The plane3dex was removed, there is now only one plane implementation - available. Implemented some ideas and suggestions by Mark Jeacocke. Thanx a lot! - -- The interface for adding dynamic lights has been enhanced. There are some new methods - for handling dynamic light in the IVideoDriver interface. For example, it is now possible - to change the ambient light. - -- There is a new parameter in the createDevice() function, which specifies if the - stencil buffer should be activated. Also, now all parameters have default parameters. - -- There is now a timer object to get the current timer. It can be received using - the getTimer() method from the IrrlichtDevice. - -- The first person shooter camera is now able to be moved by external using - setRelativePosition() and the sceneNodeAnimators. In addition, it now supports - multiple FPS cameras. - -- Mesh format loading extenstions are now possible. To extend the engine with a - mesh format it currently does not support (e.g. .cob), just implement a - IMeshLoader interface and add it to the engine calling - ISceneManager::addExternalMeshLoader(). - -- It is now possible to extend the Irrlicht Engine easily with new texture file format - loaders. If there is an image file format the engine does not support (for example - .gif files) the IImageLoader interface can be implemented to load .gif files - and added to the engine via IVideoDriver::addExternalSurfaceLoader(). - -------------------------------------------------------------------------------------- -Changes in version 0.1.5: (03 Apr 2003) - -- The zlib and libjpeg are now included in the SDK. - -- It is now possible to let the scene manager generate a hilly plane on the fly. - -- The Interface for handling dynamic lights was simplified. - -- The OpenGL 2D and 3D device is now full implemented. - -- There is now a way to access to root scene node from the scene manager, and so it - is possible to add external created custom scene nodes to the scene. - -- There is a new Camera control scene node available in the engine: First Person Shooter - Camera Control. Look with mouse movement, move and strafe with the cursor keys. - -- The engine now compiles with g++ and the Microsoft compilers, which enables it to - develop applications for the engine with VisualC++6.0, VisualC++.NET and Dev-C++. - -- There is now a ICursorControl available in the engine, which is able to modify the - mouse cursor: Get/Set the position of the cursor, make it invisible or visible. - -- video::Color was renamed to video::SColor to fit the Irrlicht Engine naming conventions - and for g++ compatibility issues in the Vertices. - -------------------------------------------------------------------------------------- -Release notes of version 0.1: (14 Mar 2003) - - This is an alpha version of the SDK. So please note that there are - features missing in the engine and maybe also some bugs. The following - list is a complete list of parts of this alpha SDK which do not work - 100% correct. All other parts which can be found in the documentation - and accessed with the Irrlicht header files work and can already be - used. - -- OpenGL Device - The OpenGL Device is currently only able to load textures and draw basic - 3D primitives. No 2D functions, complex materials and dynamic light are - implemented. Please use the DirectX8 or the Software Device instead. - In the next release (0.2) the OpenGL device will be complete. - -- Software Device - Dynamic lighting, multitexturing, 3d clipping and bilinear filtering are - not implemented because the Software Device was intented to to only 2d - functions, the primitive 3d functions are only an addition. Until the - first non beta release (1.0) of the Engine, some more 3d functionality - will be added. - -- BspTree - The binary space partition scene node does not work correctly and has - some bugs in it, which might lead to crashes. Please use the OctTree - scene node instead. There is nearly no difference between the interface - of them. - -- MeshViewerGUIElement - The camera control of this element is currently disabled. - -- FileOpenDialog - Not all functions are implemented. - -- Render to Texture support - Is not implemented yet. - -- MS3D Skeletal Animation - A loaded mesh is currently not animated and only drawn static. - -- Quake 3 maps - No support for curved surfaces yet. - -- Linux Support - The engine currently only runs with Windows platforms. A linux version - will be available somewhere between the versions 0.2 and 0.5, it depends - on the need of the users. - -------------------------------------------------------------------------------------- diff --git a/irrlicht-1.6/doc/irrlicht.chm b/irrlicht-1.6/doc/irrlicht.chm deleted file mode 100644 index c6e01bc65..000000000 Binary files a/irrlicht-1.6/doc/irrlicht.chm and /dev/null differ diff --git a/irrlicht-1.6/doc/readme.txt b/irrlicht-1.6/doc/readme.txt deleted file mode 100644 index 3485418ed..000000000 --- a/irrlicht-1.6/doc/readme.txt +++ /dev/null @@ -1,2 +0,0 @@ -Linux Users: There are some tools at the web for reading .chm files (try http://xchm.sourceforge.net/). -You can find a html version of this documentation at http://irrlicht.sourceforge.net/docu/index.html \ No newline at end of file diff --git a/irrlicht-1.6/doc/upgrade-guide.txt b/irrlicht-1.6/doc/upgrade-guide.txt deleted file mode 100644 index 482065b5a..000000000 --- a/irrlicht-1.6/doc/upgrade-guide.txt +++ /dev/null @@ -1,1586 +0,0 @@ -This file contains API changes between consecutive versions. You can get the -relevant information about all changes to the public Irrlicht API needed for -upgrading your code (esp. custom scene nodes and GUI elements) to a new Irrlicht -version. Since all changes are incremental you should skip forward to the -version you use right now and check each note until you reach the desired -version. -Please note that the changes described here do not contain functional changes, -but only syntactical ones. Also, new methods are not documented here and -have to be looked up in the API documentation instead. - -Basically, all changes have to be reflected in user code where used. Removed -and renamed methods are obviously not existant anymore. A hint is usually given -for such changes on how to remedy the situation. -Changed signatures of methods might go unnoticed. That need not be a bad thing, -e.g. for changes from s32 to u32 the parameters are usually automatically -converted by the compiler. However, one should be careful when writing custom -scene nodes or GUI elements. It might happen that the methods are not properly -chosen as candidates for virtual overloading. So always check that methods in -the user code have the proper signatures just as the interface versions. The -change hint will help to identify necessary changes. - -Changes for Version 1.2 ------------------------ -Removed compile flag (always used where available) -_IRR_LINUX_OPENGL_USE_EXTENSIONS_ - -IAnimatedMeshB3d: -Removed (no replacement available) - virtual void AddMatrixToJoint(s32 jointNumber, core::matrix4* matrix) = 0; - -IGUIElement.h -Changed signatures (made const) - IGUIElement* getParent() const - core::rect<s32> getRelativePosition() const - -IGUITabControl.h -Changed signatures (const param) - virtual IGUITab* addTab(const wchar_t* caption, s32 id=-1) = 0; - -IImage.h -Changed signatures (made const) - virtual ECOLOR_FORMAT getColorFormat() const = 0; - -IParticleAffector.h -Changed inheritance (from irr:IUnknown) - class IParticleAffector : public virtual io::IAttributeExchangingObject - -IParticleEmitter.h -Changed inheritance (from irr:IUnknown) - class IParticleEmitter : public virtual io::IAttributeExchangingObject - -IParticleSystemSceneNode.h -Changed signatures (const param) - virtual IParticleEmitter* createPointEmitter( - const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f), - u32 minParticlesPerSecond = 5, - u32 maxParticlesPerSecond = 10, - video::SColor minStartColor = video::SColor(255,0,0,0), - virtual IParticleEmitter* createBoxEmitter( - const core::aabbox3df& box = core::aabbox3df(-10,28,-10,10,30,10), - const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f), - u32 minParticlesPerSecond = 5, - u32 maxParticlesPerSecond = 10, - video::SColor minStartColor = video::SColor(255,0,0,0), - - virtual IParticleAffector* createGravityAffector( - const core::vector3df& gravity = core::vector3df(0.0f,-0.03f,0.0f), - u32 timeForceLost = 1000) = 0; - -ISceneManager.h -Changed signatures (additional param) - virtual ISceneNodeAnimator* createFlyCircleAnimator(const core::vector3df& center, - f32 radius, f32 speed=0.001f, const core::vector3df& direction= core::vector3df ( 0.f, 1.f, 0.f ) ) = 0; - -ITexture.h -Changed signatures (made const) - virtual ECOLOR_FORMAT getColorFormat() const = 0; - -IVideoDriver.h -Changed signatures (changed default param, use ECF_A1R5G5B5 explicitly for old behavior) - virtual ITexture* addTexture(const core::dimension2d<s32>& size, - const c8* name, ECOLOR_FORMAT format = ECF_A8R8G8B8) = 0; -Changed signatures (made const) - virtual ITexture* createRenderTargetTexture(const core::dimension2d<s32>& size) = 0; - -matrix4.h -Changed signatures (swapped parameter, it was (col, row) before although the names did not represent this) - f32& operator()(s32 row, s32 col); - const f32& operator()(s32 row, s32 col) const; - -S3DVertex.h -Changed signatures (unconst param) - S3DVertex(f32 x, f32 y, f32 z, f32 nx, f32 ny, f32 nz, SColor c, f32 tu, f32 tv); - S3DVertex(const core::vector3df& pos, const core::vector3df& normal, - SColor color, const core::vector2d<f32>& tcoords); - S3DVertex2TCoords(f32 x, f32 y, f32 z, SColor c, f32 tu, f32 tv, f32 tu2, f32 tv2); - S3DVertex2TCoords(const core::vector3df& pos, SColor color, - const core::vector2d<f32>& tcoords, const core::vector2d<f32>& tcoords2); - S3DVertex2TCoords(f32 x, f32 y, f32 z, f32 nx, f32 ny, f32 nz, SColor c, f32 tu, f32 tv); - S3DVertex2TCoords(const core::vector3df& pos, const core::vector3df& normal, - SColor color, const core::vector2d<f32>& tcoords); - S3DVertexTangents(const core::vector3df& pos, - const core::vector2df& tcoords, SColor c); - -SColor.h -Changed signatures (changed param types from signed to unsigned) - inline u16 RGBA16(u32 r, u32 g, u32 b, u32 a); - inline u16 RGB16(u32 r, u32 g, u32 b); - inline u16 X8R8G8B8toA1R5G5B5(u32 color); - inline u32 A1R5G5B5toA8R8G8B8(u32 color); - inline u32 R5G6B5toA8R8G8B8(u16 color); - inline u16 R5G6B5toA1R5G5B5(u16 color); - inline u16 A1R5G5B5toR5G6B5(u16 color); - inline u32 getAlpha(u16 color); - inline u32 getRed(u16 color); - inline u32 getGreen(u16 color); - inline u32 getBlue(u16 color); - inline u32 getLuminance(u16 color); - inline SColor (u32 a, u32 r, u32 g, u32 b); - inline SColor(u32 clr); - inline u32 getAlpha() const - inline u32 getRed() const - inline u32 getGreen() const - inline u32 getBlue() const - inline void setAlpha(u32 a); - inline void setRed(u32 r); - inline void setGreen(u32 g); - inline void setBlue(u32 b); - inline u16 toA1R5G5B5() const - inline void toOpenGLColor(u8* dest) const - inline void set(u32 a, u32 r, u32 g, u32 b); - inline void set(u32 col); -Changed signatures (const param) - inline SColor getInterpolated(const SColor &other, f32 d) const -Changed public member (type changed) - u32 color; - - -Changes for Version 1.3 ------------------------ -Globally renamed Frustrum to Frustum in all signatures and code parts - -IAnimatedMeshB3d.h -Renamed methods (small first letter) - virtual void setInterpolationMode(s32 mode) = 0; - virtual void setAnimateMode(s32 mode) = 0; - -IAnimatedMeshSceneNode.h -changed signature (changed types) - virtual void setAnimationSpeed(f32 framesPerSecond) = 0; - -ICameraSceneNode.h -Renamed methods and changed signature (changed types, frustum renaming) - virtual const SViewFrustum* getViewFrustum() const = 0; - -IFileSystem.h -Renamed method (from addUnZipFileArchive) - virtual bool addFolderFileArchive(const c8* filename, bool ignoreCase = true, bool ignorePaths = true) = 0; - -IGUIContextMenu.h -Changed signature (added param) - virtual s32 addItem(const wchar_t* text, s32 commandId=-1, bool enabled=true, - bool hasSubMenu=false, bool checked=false) = 0; - -IGUIElement.h -Changed inheritance - class IGUIElement : public virtual io::IAttributeExchangingObject, public IEventReceiver -Changed signature (made const) - core::rect<s32> getAbsolutePosition() const - -IGUIEnvironment.h -Changed signature (added param) - virtual IGUIButton* addButton(const core::rect<s32>& rectangle, - IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0, const wchar_t* tooltiptext = 0) = 0; - -IGUIListBox.h -Removed method (Using sprite bank now) - virtual void setIconFont(IGUIFont* font) = 0; -Change signature (changed types, due to sprite bank) - virtual s32 addItem(const wchar_t* text, s32 icon) = 0; - -IGUISkin.h -Changed inheritance - class IGUISkin : public virtual io::IAttributeExchangingObject - -IGUIToolbar.h -Changed signature (Added param for tooltips) - virtual IGUIButton* addButton(s32 id=-1, const wchar_t* text=0, const wchar_t* tooltiptext=0, - video::ITexture* img=0, video::ITexture* pressedimg=0, - bool isPushButton=false, bool useAlphaChannel=false) = 0; - -IImage.h -Changed signature (made const) - virtual u32 getPitch() const = 0; - -IImageWriter.h -Changed signature (additional param) - virtual bool writeImage(io::IWriteFile *file, IImage *image, u32 param = 0) = 0; - -IMeshBuffer.h -Changed signature (changed return type) - virtual u32 getVertexCount() const = 0; - virtual u32 getIndexCount() const = 0; -Removed method (use setBoundingBox instead) - virtual core::aabbox3df& getBoundingBox() = 0; - -IMesh.h -Changed signature (changed types, made const) - virtual u32 getMeshBufferCount() const = 0; - virtual IMeshBuffer* getMeshBuffer(u32 nr) const = 0; -Removed method (use setBoundingBox instead) - virtual core::aabbox3d<f32>& getBoundingBox() = 0; - -IReadFile.h -Changed signature (changed types) - virtual s32 read(void* buffer, u32 sizeToRead) = 0; - -irrArray.h -Changed signature (made const) - s32 binary_search(const T& element, s32 left, s32 right) const - -irrMath.h -Constant changed - const f32 PI = 3.14159265359f; -Constants removed (use RADTODEG64 or DEGTORAD64 instead) - const f64 GRAD_PI = 180.0 / PI64; - const f64 GRAD_PI2 = PI64 / 180.0; -Changed signature (added tolerance parameter) - inline bool equals(const f32 a, const f32 b, const f32 tolerance = ROUNDING_ERROR_32) - -irrString.h -Changed signature (const param) - template <class B> string(const B* const c, u32 length); - template <class B> string(const B* const c); - template <class B> string<T>& operator=(const B* const c); - template <class B> string<T> operator+(const B* const c) const - bool operator ==(const T* const str) const - bool operator !=(const T* const str) const - bool equalsn(const T* const str, int len) const - void append(const T* const other); - s32 findFirstChar(const T* const c, u32 count) const - template <class B> s32 findFirstCharNotInList(const B* const c, u32 count) const - template <class B> s32 findLastCharNotInList(const B* const c, u32 count) const - template <class B> s32 find(const B* const str) const - void operator += (const T* const c); -Changed signature (changed type from signed) - T& operator [](const u32 index) const - u32 size() const - void append(const string<T>& other, u32 length); - void reserve(u32 count); - s32 findNext(T c, u32 startPos) const - string<T> subString(u32 begin, s32 length) const - void erase(u32 index); - void reallocate(u32 new_size); -Changed signature (added param) - s32 findLast(T c, s32 start = -1) const - -ISceneManager.h -Changed signature (changed default param from 128 minimalPolysPerNode) - virtual ISceneNode* addOctTreeSceneNode(IAnimatedMesh* mesh, ISceneNode* parent=0, - s32 id=-1, s32 minimalPolysPerNode=256, bool alsoAddIfMeshPointerZero=false) = 0; - virtual ISceneNode* addOctTreeSceneNode(IMesh* mesh, ISceneNode* parent=0, - s32 id=-1, s32 minimalPolysPerNode=256, bool alsoAddIfMeshPointerZero=false) = 0; -Changed signature (added param) - virtual ICameraSceneNode* addCameraSceneNodeFPS(ISceneNode* parent = 0, - f32 rotateSpeed = 100.0f, f32 moveSpeed = 500.0f, s32 id=-1, - SKeyMap* keyMapArray=0, s32 keyMapSize=0, bool noVerticalMovement=false, - f32 jumpSpeed = 0.f) = 0; - - virtual IBillboardSceneNode* addBillboardSceneNode(ISceneNode* parent = 0, - const core::dimension2d<f32>& size = core::dimension2d<f32>(10.0f, 10.0f), - const core::vector3df& position = core::vector3df(0,0,0), s32 id=-1, - video::SColor shade_top = 0xFFFFFFFF, video::SColor shade_down = 0xFFFFFFFF) = 0; - - virtual ITerrainSceneNode* addTerrainSceneNode( - const c8* heightMapFileName, - ISceneNode* parent=0, s32 id=-1, - const core::vector3df& position = core::vector3df(0.0f,0.0f,0.0f), - const core::vector3df& rotation = core::vector3df(0.0f,0.0f,0.0f), - const core::vector3df& scale = core::vector3df(1.0f,1.0f,1.0f), - video::SColor vertexColor = video::SColor(255,255,255,255), - s32 maxLOD=5, E_TERRAIN_PATCH_SIZE patchSize=ETPS_17, s32 smoothFactor=0) = 0; - - virtual ITerrainSceneNode* addTerrainSceneNode( - io::IReadFile* heightMapFile, - ISceneNode* parent=0, s32 id=-1, - const core::vector3df& position = core::vector3df(0.0f,0.0f,0.0f), - const core::vector3df& rotation = core::vector3df(0.0f,0.0f,0.0f), - const core::vector3df& scale = core::vector3df(1.0f,1.0f,1.0f), - video::SColor vertexColor = video::SColor(255,255,255,255), - s32 maxLOD=5, E_TERRAIN_PATCH_SIZE patchSize=ETPS_17, s32 smoothFactor=0) = 0; -Changed signature (changed return type) - virtual u32 registerNodeForRendering(ISceneNode* node, - E_SCENE_NODE_RENDER_PASS pass = ESNRP_AUTOMATIC) = 0; - -ISceneNodeAnimatorCollisionResponse.h -Changed signature (made const) - virtual void setEllipsoidTranslation(const core::vector3df &translation) = 0; - -ISceneNode.h -Renamed method (from OnPreRender) - virtual void OnRegisterSceneNode(); -Renamed method (from OnPostRender) - virtual void OnAnimate(u32 timeMs); -Changed signature (made const) - virtual const core::aabbox3d<f32> getTransformedBoundingBox() const - const core::matrix4& getAbsoluteTransformation() const - virtual bool isVisible() const - virtual s32 getID() const - scene::ISceneNode* getParent() const - virtual ESCENE_NODE_TYPE getType() const -Changed signature (changed type) - virtual video::SMaterial& getMaterial(u32 num); - void setMaterialTexture(u32 textureLayer, video::ITexture* texture); - void setAutomaticCulling( E_CULLING_TYPE state); - virtual void setDebugDataVisible(E_DEBUG_SCENE_TYPE visible); -Changed signature (changed return type) - virtual u32 getMaterialCount(); - virtual const core::vector3df& getRotation() const - E_CULLING_TYPE getAutomaticCulling() const -Changed signature (changed return type, made const) - E_DEBUG_SCENE_TYPE isDebugDataVisible() const - -ITerrainSceneNode.h -Changed signature (changed return type) - virtual u32 getIndexCount() = 0; - -ITexture.h -Changed signature (changed return type, made const) - virtual u32 getPitch() const = 0; -Removed method (Available in SMaterial now) - core::matrix4& getTransformation(); - -IVideoDriver.h -Changed signature (changed types) - virtual ITexture* getTextureByIndex(u32 index) = 0; - virtual void drawVertexPrimitiveList(const void* vertices, u32 vertexCount, const u16* indexList, u32 triangleCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType) = 0; - virtual void drawIndexedTriangleList(const S3DVertex* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount) = 0; - virtual void drawIndexedTriangleList(const S3DVertex2TCoords* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount) = 0; - virtual void drawIndexedTriangleList(const S3DVertexTangents* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount) = 0; - virtual void drawIndexedTriangleFan(const S3DVertex* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount) = 0; - virtual void drawIndexedTriangleFan(const S3DVertex2TCoords* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount) = 0; - virtual const SLight& getDynamicLight(u32 idx) = 0; - virtual IMaterialRenderer* getMaterialRenderer(u32 idx) = 0; - virtual const c8* getMaterialRendererName(u32 idx) = 0; -Changed signature (const param) - virtual void drawMeshBuffer( const scene::IMeshBuffer* mb) = 0; - virtual io::IAttributes* createAttributesFromMaterial(const video::SMaterial& material) = 0; -Changed signature (added param) - virtual u32 getPrimitiveCountDrawn( u32 param = 0 ) = 0; - virtual bool writeImageToFile(IImage* image, const c8* filename, u32 param = 0) = 0; - virtual IImage* createImageFromData(ECOLOR_FORMAT format, - const core::dimension2d<s32>& size, void *data, - bool ownForeignMemory=false, - bool deleteMemory = true) = 0; -Changed signature (changed return types) - virtual u32 getMaximalDynamicLightAmount() = 0; - virtual u32 getDynamicLightCount() = 0; - virtual u32 getMaximalPrimitiveCount() = 0; - virtual u32 getMaterialRendererCount() = 0; - -matrix4.h -Changed signature (added param) - matrix4( eConstructor constructor = EM4CONST_IDENTITY ); -Changed signature (const param) - f32& operator()(const s32 row, const s32 col); - const f32& operator()(const s32 row, const s32 col) const -Changed signature (param order) - void transformVect( vector3df& out, const vector3df& in ) const; - -quaternion.h -Changed signature (changed return type) - void slerp( quaternion q1, const quaternion q2, f32 interpolate ); - -SColor.h -Renamed method (from getLuminance), changed types - inline s32 getAverage(s16 color); -Changed signature (changed return types) - inline f32 getLuminance() const -Changed signature (const param) - inline SColorf getInterpolated(const SColorf &other, f32 d) const - -SMaterial.h -Constant type changed - const u32 MATERIAL_MAX_TEXTURES = 4; -Type changed - class SMaterial -Public members removed (use Textures[] instead) - ITexture* Texture1; - ITexture* Texture2; - ITexture* Texture3; - ITexture* Texture4; -Public members removed (use setFlag()/getFlag() instead) - Flags[] -Public members changed (type changed) - u32 ZBuffer; -Changed signature (made const) - inline bool operator!=(const SMaterial& b) const - -SMeshBuffer.h -Changed signature (changed param) - virtual u32 getVertexCount() const - virtual u32 getIndexCount() const -Removed method (use setBoundingBox instead) - virtual core::aabbox3d<f32>& getBoundingBox(); - -SMeshBufferLightMap.h -Changed signature (changed param) - virtual u32 getVertexCount() const - virtual u32 getIndexCount() const -Removed method (use setBoundingBox instead) - virtual core::aabbox3d<f32>& getBoundingBox(); - -SMeshBufferTangents.h -Changed signature (changed param) - virtual u32 getVertexCount() const - virtual u32 getIndexCount() const -Removed method (use setBoundingBox instead) - virtual core::aabbox3d<f32>& getBoundingBox(); - -SMesh.h -Changed signature (changed param, made const) - virtual u32 getMeshBufferCount() const - virtual IMeshBuffer* getMeshBuffer(u32 nr) const -Removed method (use setBoundingBox instead); - virtual core::aabbox3d<f32>& getBoundingBox(); - -vector3d.h -Changed signature (changed return type) - T getLength() const -Changed signature (changed type) - vector3d<T> getInterpolated(const vector3d<T>& other, const T d) const - -Changes for Version 1.3.1 -------------------------- -Changed types: - SMeshBuffer* types are now template typedefs from CMeshBuffer - -dimension2d.h -Changed signature (const param) - dimension2d(const T& width, const T& height); - dimension2d<T> operator/(const T& scale); - dimension2d<T> operator*(const T& scale); - -IAnimatedMeshSceneNode.h -Changed signature (made const) - virtual s32 getFrameNr() const = 0; - virtual s32 getStartFrame() const = 0; - virtual s32 getEndFrame() const = 0; -Renamed method (from getAbsoluteTransformation) - virtual const SMD3QuaterionTag& getMD3TagTransformation( const core::stringc & tagname) = 0; - -IGUIButton.h -Renamed method (from getUseAlphaChannel) - virtual bool isAlphaChannelUsed() = 0; - -IGUIElementFactory.h -Changed signature (made const) - EGUI_ELEMENT_TYPE getType() const - virtual const c8* getTypeName() const - -IGUIEnvironment.h -Changed signature (added param) - virtual bool saveGUI(const c8* filename, IGUIElement* start=0) = 0; - virtual bool saveGUI(io::IWriteFile* file, IGUIElement* start=0) = 0; - virtual bool loadGUI(const c8* filename, IGUIElement* parent=0) = 0; - virtual bool loadGUI(io::IReadFile* file, IGUIElement* parent=0) = 0; - -IGUIFontBitmap.h -Changed signature (made const) - virtual EGUI_FONT_TYPE getType() const { return EGFT_BITMAP; } - -IGUIFont.h -Changed signature (made const) - virtual EGUI_FONT_TYPE getType() const { return EGFT_CUSTOM; } - -IGUISkin.h -Changed signature (added param) - virtual IGUIFont* getFont(EGUI_DEFAULT_FONT which=EGDF_DEFAULT) = 0; - virtual void setFont(IGUIFont* font, EGUI_DEFAULT_FONT which=EGDF_DEFAULT) = 0; -Changed signature (made const) - virtual EGUI_SKIN_TYPE getType() const { return EGST_UNKNOWN; }; - -IImage.h -Changed signature (made const) - virtual const core::dimension2d<s32>& getDimension() const = 0; - virtual u32 getRedMask() const = 0; - virtual u32 getGreenMask() const = 0; - virtual u32 getBlueMask() const = 0; - virtual u32 getAlphaMask() const = 0; -Changed signature (changed return type, made const) - virtual u32 getBitsPerPixel() const = 0; - virtual u32 getBytesPerPixel() const = 0; - virtual u32 getImageDataSizeInBytes() const = 0; - virtual u32 getImageDataSizeInPixels() const = 0; -Changed signature (changed param type, made const) - virtual SColor getPixel(u32 x, u32 y) const = 0; - -IMeshCache.h -Changed signature (const param) - virtual void removeMesh(const IAnimatedMesh* const mesh) = 0; -Changed signature (const param, made const) - virtual s32 getMeshIndex(const IAnimatedMesh* const mesh) const = 0; - virtual const c8* getMeshFilename(const IAnimatedMesh* const mesh) const = 0; - virtual const c8* getMeshFilename(const IMesh* const mesh) const = 0; -Changed signature (changed return type, made const) - virtual u32 getMeshCount() const = 0; -Changed signature (changed param type) - virtual IAnimatedMesh* getMeshByIndex(u32 index) = 0; -Changed signature (made const) - virtual const c8* getMeshFilename(u32 index) const = 0; - -IParticleAffector.h -Changed signature (made const) - virtual E_PARTICLE_AFFECTOR_TYPE getType() const = 0; - -IParticleEmitter.h -Changed signature (made const) - virtual E_PARTICLE_EMITTER_TYPE getType() const = 0; - -irrString.h -Changed signature (const param) - string(const double number); -Changed signature (changed return type) - string<T>& operator += (T c); - string<T>& operator += (const string<T>& other); -Changed signature (changed return type, const param) - string<T>& operator += (const T* const c); - string<T>& operator += (const int i); - string<T>& operator += (const double i); - -ISceneManager.h -Changed signature (added param) - virtual ITerrainSceneNode* addTerrainSceneNode( - const c8* heightMapFileName, - ISceneNode* parent=0, s32 id=-1, - const core::vector3df& position = core::vector3df(0.0f,0.0f,0.0f), - const core::vector3df& rotation = core::vector3df(0.0f,0.0f,0.0f), - const core::vector3df& scale = core::vector3df(1.0f,1.0f,1.0f), - video::SColor vertexColor = video::SColor(255,255,255,255), - s32 maxLOD=5, E_TERRAIN_PATCH_SIZE patchSize=ETPS_17, s32 smoothFactor=0, - bool addAlsoIfHeightmapEmpty = false) = 0; - virtual ITerrainSceneNode* addTerrainSceneNode( - io::IReadFile* heightMapFile, - ISceneNode* parent=0, s32 id=-1, - const core::vector3df& position = core::vector3df(0.0f,0.0f,0.0f), - const core::vector3df& rotation = core::vector3df(0.0f,0.0f,0.0f), - const core::vector3df& scale = core::vector3df(1.0f,1.0f,1.0f), - video::SColor vertexColor = video::SColor(255,255,255,255), - s32 maxLOD=5, E_TERRAIN_PATCH_SIZE patchSize=ETPS_17, s32 smoothFactor=0, - bool addAlsoIfHeightmapEmpty = false) = 0; - virtual ISceneManager* createNewSceneManager(bool cloneContent=false) = 0; - -ISceneNodeAnimator.h -Changed signature (made const) - virtual ESCENE_NODE_ANIMATOR_TYPE getType() const - -ITexture.h -Changed signature (made const) - virtual bool hasMipMaps() const - -IVideoDriver.h -Changed signature (reference param) - virtual void draw3DBox(const core::aabbox3d<f32>& box, - SColor color = SColor(255,255,255,255)) = 0; -Changed signature (added defaults for param) - virtual void draw2DImage(video::ITexture* texture, - const core::position2d<s32>& pos, - const core::array<core::rect<s32> >& sourceRects, - const core::array<s32>& indices, - s32 kerningWidth=0, - const core::rect<s32>* clipRect=0, - SColor color=SColor(255,255,255,255), - bool useAlphaChannelOfTexture=false) = 0; -Changed signature (changed return type) - virtual const SExposedVideoData& getExposedVideoData() = 0; - -line3d.h -Changed signature (changed return type) - T getLength() const - -matrix4.h -Changed type to template class - template <class T> class CMatrix4 - typedef CMatrix4<f32> matrix4; -Changed signature (changed return type) - T& operator()(const s32 row, const s32 col); - const T& operator()(const s32 row, const s32 col) const - T& operator[](u32 index); - const T& operator[](u32 index) const -Changed signature (changed param type) - inline CMatrix4<T>& operator=(const T& scalar); - const T* pointer() const - T* pointer(); - CMatrix4<T> operator*(const T& scalar) const; - CMatrix4<T>& operator*=(const T& scalar); - void transformVect(T *out,const core::vector3df &in) const; - void rotateVect(T *out,const core::vector3df &in) const; - void multiplyWith1x4Matrix(T* matrix) const; - CMatrix4<T> interpolate(const core::CMatrix4<T>& b, f32 time) const; - -plane3d.h -Renamed method (from existsInterSection) - bool existsIntersection(const plane3d<T>& other) const - -quaternion.h -Changed signature (unconst param) - void slerp( quaternion q1, quaternion q2, f32 interpolate ); - -SExposedVideoData.h -Removed public member (replaced by X11Display and X11Window) - OpenGLLinux.Window; - -SIrrCreationParameters.h -Changed public member (changed type for 64bit system support) - void* WindowId; - -triangle3d.h -Changed method to private - bool isOnSameSide(const vector3d<T>& p1, const vector3d<T>& p2, - const vector3d<T>& a, const vector3d<T>& b) const - -vector2d.h -Changed signature (changed return value) - T getLength() const - T getDistanceFrom(const vector2d<T>& other) const - -vector3d.h -Changed signature (changed return value) - T getDistanceFrom(const vector3d<T>& other) const - -Changes for Version 1.4 ------------------------ -This release had many changes in API method signatures. Many methods have been -made const, also several parameter types were changed. The two most noticeable -changes (which almost every user of the Irrlicht API will come across) are the -renaming of IUnknown to IReferenceCounted and const-ref change of the SEvent -structure of the OnEvent method. Another important change: DirectX8 support is -now by default disabled, enable the define in IrrCompileConfig.h to restore the -old behavior. - -IReferenceCounted.h -Renamed Type (from IUnknown). This changed most classes in Irrlicht - class IReferenceCounted - -IEventReceiver.h -Changed signature (made const) - virtual bool OnEvent(const SEvent& event) = 0; - -IrrCompileConfig.h -DirectX8 support is now by default disabled - -CMeshBuffer.h -Removed method - virtual u32 getVertexPitch() const - -fast_atof.h -Changed signature to allow optional second parameter - u32 strtol10(const char* in, const char** out=0) - -IAnimatedMesh.h -Changed inheritance (instead of IReferenceCounted) - class IAnimatedMesh : public IMesh -Changed signature (made const) - virtual u32 getFrameCount() const = 0; - -IAnimatedMeshSceneNode.h -Changed signature (changed param type) - virtual void setCurrentFrame(f32 frame) = 0; -Replaced methods (generalized method getJointNode available) - virtual ISceneNode* getMS3DJointNode(const c8* jointName) = 0; - virtual ISceneNode* getXJointNode(const c8* jointName) = 0; - virtual ISceneNode* getB3DJointNode(const c8* jointName) = 0; -Changed signature (changed return type) - virtual f32 getFrameNr() const = 0; -Changed signature (made const) - virtual bool isReadOnlyMaterials() const = 0; - -IAttributeExchangingObject.h -Changed signature (made const) - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const {} - -IAttributes.h -Changed signature (made const, changed param type) - virtual u32 getAttributeCount() const = 0; -Changed signature (added param) - virtual bool read(io::IXMLReader* reader, bool readCurrentElementOnly=false, const wchar_t* elementName=0) = 0; - virtual bool write(io::IXMLWriter* writer, bool writeXMLHeader=false, const wchar_t* elementName=0) = 0; -Changed signature (made const-ref param) - virtual void addMatrix(const c8* attributeName, const core::matrix4& v) = 0; - virtual void setAttribute(const c8* attributeName, const core::matrix4& v) = 0; - virtual void setAttribute(s32 index, const core::matrix4& v) = 0; - -IBillboardSceneNode.h -Changed signature (made const) - virtual const core::dimension2d<f32>& getSize() const = 0; - virtual void getColor(video::SColor & topColor, video::SColor & bottomColor) const = 0; - -ICameraSceneNode.h -Changed signature (made const) - virtual const core::matrix4& getProjectionMatrix() const = 0; - virtual const core::matrix4& getViewMatrix() const = 0; - virtual bool OnEvent(const SEvent& event) = 0; - virtual f32 getNearValue() const = 0; - virtual f32 getFarValue() const = 0; - virtual f32 getAspectRatio() const = 0; - virtual f32 getFOV() const = 0; - virtual bool isInputReceiverEnabled() const = 0; - virtual bool isOrthogonal() const - -ICursorControl.h -Changed signature (made const) - virtual bool isVisible() const = 0; - -IFileList.h -Changed signature (made const, changed param or return types) - virtual u32 getFileCount() const = 0; - virtual const c8* getFileName(u32 index) const = 0; - virtual const c8* getFullFileName(u32 index) = 0; - virtual bool isDirectory(u32 index) const = 0; - -IFileSystem.h 2007-09-17 09:53:10.000000000 +0200 -Changed signature (made const method and const-ref param) - virtual core::stringc getAbsolutePath(const core::stringc& filename) const = 0; - virtual core::stringc getFileDir(const core::stringc& filename) const = 0; -Changed signature (made const) - virtual IFileList* createFileList() const = 0; - virtual bool existFile(const c8* filename) const = 0; - -IGUIButton.h -Changed signature (made const) - virtual bool isPressed() const = 0; - virtual bool isAlphaChannelUsed() const = 0; - virtual bool isPushButton() const = 0; - virtual bool isDrawingBorder() const = 0; - -IGUICheckBox.h -Changed signature (made const) - virtual bool isChecked() const = 0; - -IGUIComboBox.h -Changed signature (made const, changed param or return types) - virtual u32 getItemCount() const = 0; - virtual const wchar_t* getItem(u32 idx) const = 0; - virtual s32 getSelected() const = 0; -Changed signature (changed param or return types) - virtual u32 addItem(const wchar_t* text) = 0; - virtual void removeItem(u32 id) = 0; - -IGUIContextMenu.h -Changed signature (changed param or return types) - virtual u32 getItemCount() const = 0; - virtual u32 addItem(const wchar_t* text, s32 commandId=-1, bool enabled=true, bool hasSubMenu=false, bool checked=false) = 0; - virtual void setItemText(u32 idx, const wchar_t* text) = 0; - virtual void setItemEnabled(u32 idx, bool enabled) = 0; - virtual void setItemChecked(u32 idx, bool enabled) = 0; - virtual void removeItem(u32 idx) = 0; - virtual void setItemCommandId(u32 idx, s32 id) = 0; -Changed signature (made const, changed param or return types) - virtual const wchar_t* getItemText(u32 idx) const = 0; - virtual bool isItemEnabled(u32 idx) const = 0; - virtual bool isItemChecked(u32 idx) const = 0; - virtual s32 getSelectedItem() const = 0; - virtual s32 getItemCommandId(u32 idx) const = 0; - virtual IGUIContextMenu* getSubMenu(u32 idx) const = 0; - -IGUIEditBox.h -Changed signature (changed param or return types) - virtual void setMax(u32 max) = 0; -Changed signature (made const, changed param or return types) - virtual u32 getMax() const = 0; - -IGUIElementFactory.h -Changed signature (made const) - virtual s32 getCreatableGUIElementTypeCount() const = 0; - virtual EGUI_ELEMENT_TYPE getCreateableGUIElementType(s32 idx) const = 0; - virtual const c8* getCreateableGUIElementTypeName(s32 idx) const = 0; - virtual const c8* getCreateableGUIElementTypeName(EGUI_ELEMENT_TYPE type) const = 0; - -IGUIElement.h -Changed signature (made const) - bool isNotClipped() const - virtual bool isVisible() const - virtual bool isSubElement() const - virtual bool isEnabled() const - virtual const wchar_t* getText() const - virtual s32 getID() const - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const -Changed signature (made const-ref param or return type) - virtual const core::stringw& getToolTipText() const - virtual bool OnEvent(const SEvent& event) - -IGUIEnvironment.h -Changed signature (changed return type) - virtual bool setFocus(IGUIElement* element) = 0; - virtual bool removeFocus(IGUIElement* element) = 0; -Changed signature (made const) - virtual IGUIElement* getFocus() const = 0; - virtual bool hasFocus(IGUIElement* element) const = 0; - virtual video::IVideoDriver* getVideoDriver() const = 0; - virtual io::IFileSystem* getFileSystem() const = 0; - virtual IOSOperator* getOSOperator() const = 0; - virtual IGUISkin* getSkin() const = 0; - virtual IGUIFont* getBuiltInFont() const = 0; - virtual IGUIElementFactory* getDefaultGUIElementFactory() const = 0; - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const =0; -Changed signature (made const-ref param or return type) - virtual bool postEventFromUser(const SEvent& event) = 0; -Changed signature (made const, changed param or return types) - virtual u32 getRegisteredGUIElementFactoryCount() const = 0; - virtual IGUIElementFactory* getGUIElementFactory(u32 index) const = 0; - -IGUIFileOpenDialog.h -Changed signature (made const) - virtual const wchar_t* getFileName() const = 0; - -IGUIFontBitmap.h -Changed signature (made const) - virtual IGUISpriteBank* getSpriteBank() const = 0; - virtual u32 getSpriteNoFromChar(const wchar_t *c) const = 0; - virtual s32 getKerningWidth(const wchar_t* thisLetter=0, const wchar_t* previousLetter=0) const = 0; - -IGUIFont.h -Changed signature (made const) - virtual core::dimension2d<s32> getDimension(const wchar_t* text) const = 0; - virtual s32 getCharacterFromPos(const wchar_t* text, s32 pixel_x) const = 0; - virtual s32 getKerningWidth(const wchar_t* thisLetter=0, const wchar_t* previousLetter=0) const = 0; - virtual s32 getKerningHeight() const = 0; - -IGUIListBox.h -Changed signature (made const, changed param or return types) - virtual u32 getItemCount() const = 0; - virtual const wchar_t* getListItem(u32 id) const = 0; - virtual s32 getIcon(u32 index) const = 0; -Changed signature (changed param or return types) - virtual u32 addItem(const wchar_t* text) = 0; - virtual u32 addItem(const wchar_t* text, s32 icon) = 0; - virtual void removeItem(u32 index) = 0; -Changed signature (made const) - virtual s32 getSelected() const = 0; - -IGUIMeshViewer.h -Changed signature (made const) - virtual const video::SMaterial& getMaterial() const = 0; - -IGUIScrollBar.h -Changed signature (made const) - virtual s32 getMax() const = 0; - virtual s32 getSmallStep() const = 0; - virtual s32 getPos() const = 0; - -IGUISkin.h -Changed signature (made const) - virtual video::SColor getColor(EGUI_DEFAULT_COLOR color) const = 0; - virtual s32 getSize(EGUI_DEFAULT_SIZE size) const = 0; - virtual const wchar_t* getDefaultText(EGUI_DEFAULT_TEXT text) const = 0; - virtual IGUIFont* getFont(EGUI_DEFAULT_FONT which=EGDF_DEFAULT) const = 0; - virtual IGUISpriteBank* getSpriteBank() const = 0; - virtual u32 getIcon(EGUI_DEFAULT_ICON icon) const = 0; - -IGUISpriteBank.h -Changed signature (made const) - virtual u32 getTextureCount() const = 0; - virtual video::ITexture* getTexture(u32 index) const = 0; - -IGUIStaticText.h -Changed signature (made const) - virtual IGUIFont* getOverrideFont(void) const = 0; - virtual video::SColor const& getOverrideColor(void) const = 0; - virtual bool isOverrideColorEnabled(void) const = 0; - virtual bool isWordWrapEnabled(void) const = 0; - virtual s32 getTextHeight() const = 0; - virtual s32 getTextWidth(void) const = 0; - -IGUITabControl.h -Changed signature (made const) - virtual s32 getNumber() const = 0; - virtual s32 getTabCount() const = 0; - virtual IGUITab* getTab(s32 idx) const = 0; - virtual s32 getActiveTab() const = 0; - -IGUIWindow.h -Changed signature (made const) - virtual IGUIButton* getCloseButton() const = 0; - virtual IGUIButton* getMinimizeButton() const = 0; - virtual IGUIButton* getMaximizeButton() const = 0; - -IImageLoader.h -Changed signature (made const) - virtual bool isALoadableFileExtension(const c8* fileName) const = 0; - virtual bool isALoadableFileFormat(io::IReadFile* file) const = 0; - virtual IImage* loadImage(io::IReadFile* file) const = 0; - -IImageWriter.h -Changed signature (made const) - virtual bool isAWriteableFileExtension(const c8* fileName) const = 0; - virtual bool writeImage(io::IWriteFile *file, IImage *image, u32 param = 0) const = 0; - -ILogger.h -Changed signature (made const) - virtual ELOG_LEVEL getLogLevel() const = 0; - -IMaterialRenderer.h -Changed signature (made const-ref param) - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, bool resetAllRenderstates, IMaterialRendererServices* services) {}; -Changed signature (made const) - virtual bool isTransparent() const { return false; } - virtual s32 getRenderCapability() const { return 0; } - -IMesh.h -Changed signature (made const) - virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const = 0; - -IMeshLoader.h -Changed signature (made const) - virtual bool isALoadableFileExtension(const c8* fileName) const = 0; - -IMeshManipulator.h -Removed method (now in IMeshBuffer) - virtual void recalculateBoundingBox(scene::IMeshBuffer* buffer) const - -IMeshSceneNode.h -Changed signature (made const) - virtual bool isReadOnlyMaterials() const = 0; - -IOSOperator.h -Changed signature (made const) - virtual const wchar_t* getOperationSystemVersion() const = 0; - virtual void copyToClipboard(const c8* text) const = 0; - virtual c8* getTextFromClipboard() const = 0; - virtual bool getProcessorSpeedMHz(u32* MHz) const = 0; - virtual bool getSystemMemory(u32* Total, u32* Avail) const = 0; - -IParticleAffector.h -Changed signature (made const) - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const {} - -IParticleEmitter.h -Changed signature (made const) - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const {} - -IParticleSystemSceneNode.h -Changed signature (changed return type, changed param types) - virtual IParticlePointEmitter* createPointEmitter( - const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f), - u32 minParticlesPerSecond = 5, - u32 maxParticlesPerSecond = 10, - const video::SColor& minStartColor = video::SColor(255,0,0,0), - const video::SColor& maxStartColor = video::SColor(255,255,255,255), - u32 lifeTimeMin=2000, u32 lifeTimeMax=4000, - s32 maxAngleDegrees=0) = 0; - virtual IParticleEmitter* createBoxEmitter( - const core::aabbox3df& box = core::aabbox3df(-10,28,-10,10,30,10), - const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f), - u32 minParticlesPerSecond = 5, - u32 maxParticlesPerSecond = 10, - const video::SColor& minStartColor = video::SColor(255,0,0,0), - const video::SColor& maxStartColor = video::SColor(255,255,255,255), - u32 lifeTimeMin=2000, u32 lifeTimeMax=4000, - s32 maxAngleDegrees=0) = 0; - virtual IParticleFadeOutAffector* createFadeOutParticleAffector( - const video::SColor& targetColor = video::SColor(0,0,0,0), - u32 timeNeededToFadeOut = 1000) = 0; - virtual IParticleGravityAffector* createGravityAffector( - const core::vector3df& gravity = core::vector3df(0.0f,-0.03f,0.0f), - u32 timeForceLost = 1000) = 0; - -IQ3Shader.h -Removed method - bool operator < ( const SVariable &other ) const - -IReadFile.h -Changed param types (adapt the correct C-API for file positions) - virtual bool seek(long finalPos, bool relativeMovement = false) = 0; - virtual long getSize() const = 0; - virtual long getPos() const = 0; - IReadFile* createLimitReadFile(const c8* fileName, IReadFile* alreadyOpenedFile, long areaSize); - IReadFile* createMemoryReadFile(void* memory, long size, const c8* fileName, bool deleteMemoryWhenDropped); -Changed signature (made const) - virtual const c8* getFileName() const = 0; - -IrrlichtDevice.h -Changed signature (made const) - virtual bool isWindowActive() const = 0; - virtual const c8* getVersion() const = 0; -Changed signature (made const-ref param) - virtual void postEventFromUser(const SEvent& event) = 0; - -irrList.h -Changed some structures in order to incorporate a ConstIterator class. - Iterator begin() - ConstIterator begin() const - Iterator end() - ConstIterator end() const - Iterator getLast() - ConstIterator getLast() const - void insert_after(const Iterator& it, const T& element) - void insert_before(const Iterator& it, const T& element) - -irrMath.h -Changed signature (Use const references for better class handling) - inline const T& min_(const T& a, const T& b) - inline const T& min_(const T& a, const T& b, const T& c) - inline const T& max_(const T& a, const T& b) - inline const T& max_(const T& a, const T& b, const T& c) - inline T abs_(const T& a) - inline T lerp(const T& a, const T& b, const f32 t) - inline const T clamp (const T& value, const T& low, const T& high) - -irrString.h -Changed signature (made proper const method) - T& operator [](const u32 index) - const T& operator [](const u32 index) const - -irrXML.h -Changed signature (adapt the correct C-API for file positions, made const) - virtual long getSize() const = 0; -Changed signature (changed param types) - virtual unsigned int getAttributeCount() const = 0; - -ISceneManager.h -Changed signature (changed param types) - virtual IAnimatedMesh* addHillPlaneMesh(const c8* name, - const core::dimension2d<f32>& tileSize, const core::dimension2d<u32>& tileCount, - video::SMaterial* material = 0, f32 hillHeight = 0.0f, - const core::dimension2d<f32>& countHills = core::dimension2d<f32>(0.0f, 0.0f), - const core::dimension2d<f32>& textureRepeatCount = core::dimension2d<f32>(1.0f, 1.0f)) = 0; -Changed signature (changed param types and order) - virtual IAnimatedMesh* addArrowMesh(const c8* name, - video::SColor vtxColor0=0xFFFFFFFF, - video::SColor vtxColor1=0xFFFFFFFF, - u32 tesselationCylinder=4, u32 tesselationCone=8, - f32 height=1.f, f32 cylinderHeight=0.6f, - f32 width0=0.05f, f32 width1=0.3f) = 0; -Changed signature (changed param types) - virtual bool postEventFromUser(const SEvent& event) = 0; - virtual ISceneNodeFactory* getSceneNodeFactory(u32 index) = 0; - virtual ISceneNodeAnimatorFactory* getSceneNodeAnimatorFactory(u32 index) = 0; -Changed signature (made const) - virtual E_SCENE_NODE_RENDER_PASS getSceneNodeRenderPass() const = 0; -Changed signature (changed param types, made const) - virtual u32 getRegisteredSceneNodeFactoryCount() const = 0; - virtual u32 getRegisteredSceneNodeAnimatorFactoryCount() const = 0; - virtual const video::SColorf& getAmbientLight() const = 0; - -ISceneNodeAnimatorCollisionResponse.h -Changed signature (made const) - virtual bool isFalling() const = 0; - -ISceneNodeAnimatorFactory.h -Changed signature (changed param types, made const) - virtual u32 getCreatableSceneNodeAnimatorTypeCount() const = 0; - virtual ESCENE_NODE_ANIMATOR_TYPE getCreateableSceneNodeAnimatorType(u32 idx) const = 0; - virtual const c8* getCreateableSceneNodeAnimatorTypeName(u32 idx) const = 0; -Changed signature (made const) - virtual const c8* getCreateableSceneNodeAnimatorTypeName(ESCENE_NODE_ANIMATOR_TYPE type) const = 0; - -ISceneNodeFactory.h -Changed signature (changed param types, made const) - virtual u32 getCreatableSceneNodeTypeCount() const = 0; - virtual ESCENE_NODE_TYPE getCreateableSceneNodeType(u32 idx) const = 0; - virtual const c8* getCreateableSceneNodeTypeName(u32 idx) const = 0; -Changed signature (made const) - virtual const c8* getCreateableSceneNodeTypeName(ESCENE_NODE_TYPE type) const = 0; - -ISceneNode.h -Changed signature (made const) - virtual u32 getMaterialCount() const - bool isDebugObject() const - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const - -IShadowVolumeSceneNode.h -Changed signature (made const param) - virtual void setMeshToRenderFrom(const IMesh* mesh) = 0; - -ITerrainSceneNode.h -Changed signature (made const) - virtual u32 getIndexCount() const = 0; - virtual void getMeshBufferForLOD(SMeshBufferLightMap& mb, s32 LOD) const = 0; - virtual s32 getCurrentLODOfPatches(core::array<s32>& LODs) const = 0; - virtual f32 getHeight( f32 x, f32 y ) const = 0; -Changed signature (made const, made const-ref param) - virtual const core::vector3df& getTerrainCenter() const = 0; - -ITexture.h -Changed signature (made const) - virtual const core::dimension2d<s32>& getOriginalSize() const = 0; - virtual const core::dimension2d<s32>& getSize() const = 0; - virtual E_DRIVER_TYPE getDriverType() const = 0; - const core::stringc& getName() const { return Name; } - -ITimer.h -Changed signature (made const) - virtual u32 getRealTime() const = 0; - virtual u32 getTime() const = 0; - virtual f32 getSpeed() const = 0; - virtual bool isStopped() const = 0; - -ITriangleSelector.h -Changed signature (made const) - virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, - s32& outTriangleCount, const core::matrix4* transform=0) const = 0; - virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, - s32& outTriangleCount, const core::aabbox3d<f32>& box, - const core::matrix4* transform=0) const = 0; - virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, - s32& outTriangleCount, const core::line3d<f32>& line, - const core::matrix4* transform=0) const = 0; - -IVideoDriver.h -Changed signature (made const, changed param type) - virtual u32 getTextureCount() const = 0; -Changed signature (made const param) in all draw2DImage methods - virtual void draw2DImage(const video::ITexture* texture, -Changed signature (made const-ref param, made const) - virtual const core::dimension2d<s32>& getScreenSize() const = 0; - virtual const core::dimension2d<s32>& getCurrentRenderTargetSize() const = 0; -Changed signature (made const) - virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const = 0; - virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) const = 0; - virtual ITexture* createRenderTargetTexture(const core::dimension2d<s32>& size, const c8* name = 0) = 0; - virtual void makeColorKeyTexture(video::ITexture* texture, video::SColor color) const = 0; - virtual void makeColorKeyTexture(video::ITexture* texture, - core::position2d<s32> colorKeyPixelPos) const = 0; - virtual void makeNormalMapTexture(video::ITexture* texture, f32 amplitude=1.0f) const = 0; - virtual s32 getFPS() const = 0; - virtual u32 getPrimitiveCountDrawn( u32 param = 0 ) const = 0; - virtual u32 getMaximalDynamicLightAmount() const = 0; - virtual u32 getDynamicLightCount() const = 0; - virtual const SLight& getDynamicLight(u32 idx) const = 0; - virtual const wchar_t* getName() const = 0; - virtual u32 getMaximalPrimitiveCount() const = 0; - virtual bool getTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag) const = 0; - virtual u32 getMaterialRendererCount() const = 0; - virtual const c8* getMaterialRendererName(u32 idx) const = 0; - virtual E_DRIVER_TYPE getDriverType() const = 0; - -IWriteFile.h -Changed signature (changed param type) - virtual s32 write(const void* buffer, u32 sizeToWrite) = 0; - virtual bool seek(long finalPos, bool relativeMovement = false) = 0; -Changed signature (changed param type, made const) - virtual long getPos() const = 0; -Changed signature (made const) - virtual const c8* getFileName() const = 0; - -line2d.h -Changed signature (made const) - vector2d<T> getUnitVector() const - f64 getAngleWith(const line2d<T>& l) const - T getPointOrientation(const vector2d<T>& point) const - bool isPointOnLine(const vector2d<T>& point) const - -matrix4.h -Changed signature (made template param) - void setTranslation( const vector3d<T>& translation ); - vector3d<T> getTranslation() const; - void setInverseTranslation( const vector3d<T>& translation ); - inline void setRotationRadians( const vector3d<T>& rotation ); - void setRotationDegrees( const vector3d<T>& rotation ); - core::vector3d<T> getRotationDegrees() const; - inline void setInverseRotationRadians( const vector3d<T>& rotation ); - void setInverseRotationDegrees( const vector3d<T>& rotation ); - void setScale( const vector3d<T>& scale ); - core::vector3d<T> getScale() const; - -rect.h -Changed signature (made non-const ref param, C++ conformance) - rect<T>& operator+=(const position2d<T>& pos) - rect<T>& operator-=(const position2d<T>& pos) - -S3DVertex.h -Changed inheritance (S3DVertex is now base class of other vertex types) -struct S3DVertex2TCoords : public S3DVertex -struct S3DVertexTangents : public S3DVertex - -SAnimatedMesh.h -Changed signature (changed param type, made const) - virtual u32 getFrameCount() const - -SColor.h -Changed signature (changed param type) - inline u32 A1R5G5B5toA8R8G8B8(u16 color) - -SLight.h -Removed attribute (use LightSceneNode position instead) - core::vector3df Position; - -SMaterial.h -Changed attribute structure (texture layer properties are now in thenew TextureLayer array). This changes access to Textures, TextureMatrix, TextureWrap, and the filter settings, which are also per-layer now. - SMaterialLayer TextureLayer[MATERIAL_MAX_TEXTURES]; - -vector3d.h -Changed signature (made template param) - bool equals(const vector3d<T>& other, const T tolerance = (T)ROUNDING_ERROR_32 ) const - -Changes for Version 1.4.1 -------------------------- -Since this version is a backward compatible bugfix release, the API changes are only a few. None of them should result -in uncompilable code. Newly found warnings might point out wrongly used variables, additional casts or type changes in the -app should easily fix that. The only change which might go unnoticed by the compiler, but affect the application is the -changed initialization in SColorf. This was done to synchronize with other constructors from SColorf and SColor, though, -so the expectations are now much better met. -Also, OSX users have to adjust the defines in IrrCompileConfig, as we now also have OSX defines in Irrlicht style. It's now -even possible to build with X11 support under OSX without changes in the device code. - -SColor.h -Changed signature (SColorf is now default initialized to alpha=1.0f) - SColorf(f32 r=0.f, f32 g=0.f, f32 b=0.f, f32 a=1.f) : r(r), g(g), b(b), a(a) {} - -IrrCompileConfig.h -Split the OSX define into platform and device (from old MACOSX define) - _IRR_OSX_PLATFORM_ for Apple systems running OSX - _IRR_USE_OSX_DEVICE_ for Cocoa native windowing on OSX - -ISceneManager.h -Added new overload for getMesh with IReadFile instead of filename. - virtual IAnimatedMesh* getMesh(io::IReadFile* file) = 0; - -irrMath.h -Renamed method setbit - REALINLINE void setbit_cond ( u32 &state, s32 condition, u32 mask ) - -ISceneNode.h -Changed signature (because the debug data enum values can be OR'ed to enable multiple debug data types) - virtual void setDebugDataVisible(s32 state) - s32 isDebugDataVisible() const - s32 DebugDataVisible; - -matrix4.h -Changed signature (Added return values to some methods) - inline CMatrix4<T>& setbyproduct(const CMatrix4<T>& other_a,const CMatrix4<T>& other_b ); - CMatrix4<T>& setbyproduct_nocheck(const CMatrix4<T>& other_a,const CMatrix4<T>& other_b ); - inline CMatrix4<T>& makeIdentity(); - CMatrix4<T>& setTranslation( const vector3d<T>& translation ); - CMatrix4<T>& setInverseTranslation( const vector3d<T>& translation ); - inline CMatrix4<T>& setRotationRadians( const vector3d<T>& rotation ); - CMatrix4<T>& setRotationDegrees( const vector3d<T>& rotation ); - inline CMatrix4<T>& setInverseRotationRadians( const vector3d<T>& rotation ); - CMatrix4<T>& setInverseRotationDegrees( const vector3d<T>& rotation ); - CMatrix4<T>& setScale( const vector3d<T>& scale ); - CMatrix4<T>& buildProjectionMatrixPerspectiveFovRH(f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar); - CMatrix4<T>& buildProjectionMatrixPerspectiveFovLH(f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar); - CMatrix4<T>& buildProjectionMatrixPerspectiveRH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar); - CMatrix4<T>& buildProjectionMatrixPerspectiveLH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar); - CMatrix4<T>& buildProjectionMatrixOrthoLH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar); - CMatrix4<T>& buildProjectionMatrixOrthoRH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar); - CMatrix4<T>& buildCameraLookAtMatrixLH(...) - CMatrix4<T>& buildCameraLookAtMatrixRH(...) - CMatrix4<T>& buildShadowMatrix(const core::vector3df& light, core::plane3df plane, f32 point=1.0f); - CMatrix4<T>& buildNDCToDCMatrix( const core::rect<s32>& area, f32 zScale); - CMatrix4<T>& setTextureScale( f32 sx, f32 sy ); - CMatrix4<T>& setTextureRotationCenter( f32 radAngle ); - CMatrix4<T>& setTextureScaleCenter( f32 sx, f32 sy ); - CMatrix4<T>& setTextureTranslate( f32 x, f32 y ); - CMatrix4<T>& setM(const T* data); -Added overload (for one scale value for all axes) - CMatrix4<T>& setScale( const T scale ) { return setScale(core::vector3d<T>(scale,scale,scale)); } - -S3DVertex.h -Added operator - bool operator<(const S3DVertex& other) const - bool operator<(const S3DVertex2TCoords& other) const - bool operator<(const S3DVertexTangents& other) const - -irrString.h -Changed signature (int->u32, negative length didn't make sense) - bool equalsn(const string<T>& other, u32 n) const - bool equalsn(const T* const str, u32 n) const -New overload/missing method (completing the findLast... and find...Char methods) - s32 findLastChar(const T* const c, u32 count) const -Changed signature (Added return value) - string<T>& trim() - -Changes for Version 1.4.2 -------------------------- -This is once more a bugfix release of the 1.4 branch, and hence pretty API-consistent and backward compatible. The major reason to publish this release is the OpenGL bug, which made several OpenGL 2.x drivers run in SW emulation. -However, we also introduced some driver consistency fixes, which might affect your application's behavior. So read through the next points thoroughly. - -SceneParameters.h (and general video driver behavior) -The way Irrlicht handles zbuffer writing with transparent materials has changed. This was an issue ever since, because the default behavior in Irrlicht is to disable writing to the z-buffer for all really transparent, i.e. blending materials. This avoids problems with intersecting faces, but can also break renderings. And this is now consistent for both OpenGL and Direct3D. -If transparent materials should use the SMaterial flag for ZWriteEnable just as other material types use the newly introduced attribute scene::ALLOW_ZWRITE_ON_TRANSPARENT like this: -SceneManager->getParameters()->setAttribute(scene::ALLOW_ZWRITE_ON_TRANSPARENT, true); -All transparent materials will henceforth work as specified by the material flag, until the scenemanager attribute is set to false. - -SMaterialLayer.h -The texture matrix now uses irrAllocator for memory handling. This shouldn't be noticeable from the user application (besides fixed heap corruptions on Windows machines), but is still mentioned for completeness. - -ISceneNode.h -Documentation error. The docs said that children of a scene node are not visible if the node itself is set to visible. This is of course wrong, children inherit non-visibility of the parent and are hence invisible if the parent is. If the parent is visible, the visibility flag of the child determines its status. - -SColor.h -Removed methods (use the unsigned versions and cast in your app if necessary) - inline s32 getRedSigned(u16 color) - inline s32 getGreenSigned(u16 color) - inline s32 getBlueSigned(u16 color) - -IParticleSystemSceneNode.h -Changed default values (the old direction default was no real direction) - virtual IParticleAnimatedMeshSceneNodeEmitter* createAnimatedMeshSceneNodeEmitter(...) - virtual IParticleCylinderEmitter* createCylinderEmitter(...) - virtual IParticleMeshEmitter* createMeshEmitter(...) - -IBoneSceneNode.h -Changed signature (Made const) - virtual E_BONE_SKINNING_SPACE getSkinningSpace() const=0; - -IrrlichtDevice.h -Changed signature (Return value bool instead of void). Returns whether the event has been handled somewhere. - virtual bool postEventFromUser(const SEvent& event) = 0; - -Changes for Version 1.5 ------------------------ -Another major release, so expect API breaks at several places. The changes -herein are described as a difference to Irrlicht 1.4.2. - -The most noticeable changes are the speed factor of the FPS camera (now units/ms -instead of units/s, so divide the parameter by 1000.f) and the new interfaces -of the camera nodes, based on scene node animators. Custom camera nodes should -be adpated to this new scheme, although they might still work. Also, particle -sizes are now set and handled by the emitters, which requires a change of the -particle system constructor call or adaption of the setParticleSize method to -work on the emitters. A deprecation method is issued if the old scheme is used. -Light setting has also changed, the SLight struct is used in even less -situations than before, instead use methods in ILightSceneNode. - -Other changes did change major parts of the underlying structures, but might go -unnoticed on the user level. This includes 32bit indices and Vertex Buffer -Objects. However, VBOs require the user to call setDirty on Meshes or -MeshBuffers after changes to the vertex or index data. The all need only to be -done once before the next render call, but again after subsequent changes later -on. - - -All Mesh types and MeshBuffers: -New methods for VBO support. Once VBOs are enabled for a meshbuffer, changes -will only be effective after a call to setDirty(). VBOs are enabled by default -for some scene nodes. - virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX); - -All MeshBuffers: -Due to the 32bit support, it might happen that indices are stored as 32bit integers. The actual index type can be queried from a mesh buffer. - virtual video::E_INDEX_TYPE getIndexType() const - -IrrCompileConfig.h -Some new defines for configuring Irrlicht -_IRR_USE_WINDOWS_CE_DEVICE_ for Windows CE API based device -_IRR_COMPILE_WITH_JOYSTICK_EVENTS_ to enable joystick support (enabled by default) -_IRR_COMPILE_WITH_LWO_LOADER_ to enable the LWO mesh loader (enabled by default) -_IRR_COMPILE_WITH_OBJ_WRITER_ to enable the OBJ mesh writer (enabled by default) -_IRR_COMPILE_WITH_WAL_LOADER_ to enable the WAL image loader (enabled by default) -_IRR_USE_NVIDIA_PERFHUD_ for support of the PerfHUD tool (disabled by default) - -SceneParameters.h -New parameter scene::OBJ_LOADER_IGNORE_GROUPS, which allows to ignore the group structure of obj files. It's disabled by default, meaning obj groups will be represented by separate meshbuffers. - -SColor.h -Renamed method names of the SColorHSL class - void fromRGB(const SColor &color); - void toRGB(SColor &color) const; - -ITexture.h -Added new parameter - virtual void* lock(bool readOnly = false) = 0; - -IMeshManipulator.h -Renamed methods (the old ones still exist, but are deprecated). The new methods also work on meshbuffers, not just meshes. -(renamed from scaleMesh) - virtual void scale(IMesh* mesh, const core::vector3df& factor) const = 0; -(renamed from transformMesh) - virtual void transform(IMesh* mesh, const core::matrix4& m) const = 0; -Changed signature (Added new parameters to adjust the algorithm) - virtual IMesh* createMeshWithTangents(IMesh* mesh, bool recalculateNormals=false, bool smooth=false, bool angleWeighted=false) const = 0; - -IBillboardTextSceneNode.h -New interface replacing the multiple inheritance from bliiboard and text scene node previously used by the billboard text scene node. - -IParticleSystemSceneNode.h -All emitters have minStartSize and maxStartSize parameters now, since partice size is handled by the emitters now. -Default value added - virtual void setParticlesAreGlobal(bool global=true) = 0; - -fast_atof.h -Signature change (return value changed from u32) -inline s32 strtol10(const char* in, const char** out=0) -Signature change (parameter changed from float) -inline const char* fast_atof_move( const char * in, f32 & out) - -IAnimatedMeshSceneNode.h -Added new parameter (dummy node used for simplifying shadow calculation) - virtual IShadowVolumeSceneNode* addShadowVolumeSceneNode(const IMesh* shadowMesh=0, - s32 id=-1, bool zfailmethod=true, f32 infinity=10000.0f) = 0; - -ISceneManager.h -Removed extra render passes for quake shaders -Changed scene node from ISceneNode to IMeshSceneNode - virtual IMeshSceneNode* addCubeSceneNode(f32 size=10.0f, ISceneNode* parent=0, s32 id=-1, ...) - virtual IMeshSceneNode* addSphereSceneNode(f32 radius=5.0f, s32 polyCount=16, ...) -Changed default value (from 256 to 512, for efficiency on common gfx hardware) - virtual ISceneNode* addOctTreeSceneNode(IAnimatedMesh* mesh, ISceneNode* parent=0, - s32 id=-1, s32 minimalPolysPerNode=512, bool alsoAddIfMeshPointerZero=false) = 0; -Changed default value (from 500.f, to adapt the changed speed scale) - virtual ICameraSceneNode* addCameraSceneNodeFPS(ISceneNode* parent = 0, - f32 rotateSpeed = 100.0f, f32 moveSpeed = .5f, s32 id=-1, ...) -Added default values - virtual ISceneNode* addSkyDomeSceneNode(video::ITexture* texture, - u32 horiRes=16, u32 vertRes=8, - f64 texturePercentage=0.9, f64 spherePercentage=2.0, - ISceneNode* parent=0, s32 id=-1) = 0; -Changed return value (from ITextSceneNode, due to changed inheritance) - virtual IBillboardTextSceneNode* addBillboardTextSceneNode( gui::IGUIFont* font, const wchar_t* text, ...) -Changed default value (gravity, from -100.f) - virtual ISceneNodeAnimatorCollisionResponse* createCollisionResponseAnimator( - ITriangleSelector* world, ISceneNode* sceneNode, - const core::vector3df& ellipsoidRadius = core::vector3df(30,60,30), - const core::vector3df& gravityPerSecond = core::vector3df(0,-10.0f,0), - const core::vector3df& ellipsoidTranslation = core::vector3df(0,0,0), - f32 slidingValue = 0.0005f) = 0; - -ISceneNodeAnimator.h -Changed inheritance (for interactive animators) - class ISceneNodeAnimator : public io::IAttributeExchangingObject, public IEventReceiver -Changed to pure virtual (bug fix) - virtual ISceneNodeAnimator* createClone(ISceneNode* node, ISceneManager* newManager=0) = 0; - -IVideoModeList.h -Changed return value (constification) - virtual const core::dimension2d<s32>& getDesktopResolution() const = 0; - -IBoneSceneNode.h -Deprecation: Use getName instead. - virtual const c8* getBoneName() const; - -vector3d.h -Changed return value (return *this) - vector3d<T>& set(const T nx, const T ny, const T nz) {X=nx; Y=ny; Z=nz; return *this;} - vector3d<T>& set(const vector3d<T>& p) {X=p.X; Y=p.Y; Z=p.Z;return *this;} - vector3d<T>& setLength(T newlength) - vector3d<T>& invert() -Added default value - void rotateXZBy(f64 degrees, const vector3d<T>& center=vector3d<T>()) - void rotateXYBy(f64 degrees, const vector3d<T>& center=vector3d<T>()) - void rotateYZBy(f64 degrees, const vector3d<T>& center=vector3d<T>()) -Changed parameter type (interpolation factor must not be integral) - vector3d<T> getInterpolated(const vector3d<T>& other, f64 d) const - vector3d<T> getInterpolated_quadratic(const vector3d<T>& v2, const vector3d<T>& v3, f64 d) const -Method made const - vector3d<T> getHorizontalAngle() const - -SLight.h -Attenuation can be overridden by ILightSceneMethod setRadius() Attenuation will -change to (0,1.f/radius,0). Can be overridden after radius was set. -The following members are read-only now: - f32 Radius; - E_LIGHT_TYPE Type; - bool CastShadows; - -ITerrainSceneNode.h -Parameter type changed (diue to possible 32bit indices) - virtual void getMeshBufferForLOD(IDynamicMeshBuffer& mb, s32 LOD=0) const =0; -Added dafault value (highest detail) - virtual void setLODOfPatch(s32 patchX, s32 patchZ, s32 LOD=0) =0; - -SExposedVideoData.h -Changed member attributes (from s32, to fix 64bit architecture problems) - void* HWnd; - void* HDc; - void* HRc; - void* HWnd; - -IAnimatedMeshMD3.h -Changed return value (constification) - const SMD3QuaterionTag& operator[](u32 index) const - -IQ3Shader.h -Changed default q3 shader values (from LIGHTMAP_M2) - const video::E_MATERIAL_TYPE defaultMaterialType = video::EMT_LIGHTMAP_M4; - const video::E_MODULATE_FUNC defaultModulate = video::EMFN_MODULATE_4X; - -ISceneNode.h -Method made virtual - virtual const core::matrix4& getAbsoluteTransformation() const -Changed return value (constified) - virtual const core::vector3df& getScale() const - virtual const core::vector3df& getPosition() const - -IEventReceiver.h -Removed member from UserEvent - f32 UserData3; - -SMaterial.h -Changed member type (from u32) - char ZBuffer; - -IGUISkin.h -Added parameter (for alignment) - virtual void draw3DTabButton(IGUIElement* element, bool active, - const core::rect<s32>& rect, const core::rect<s32>* clip=0, gui::EGUI_ALIGNMENT alignment=EGUIA_UPPERLEFT) = 0; - virtual void draw3DTabBody(IGUIElement* element, bool border, bool background, - const core::rect<s32>& rect, const core::rect<s32>* clip=0, s32 tabHeight=-1, gui::EGUI_ALIGNMENT alignment=EGUIA_UPPERLEFT ) = 0; - -quaternion.h -Renamed method (from getDotProduct) - inline f32 dotProduct(const quaternion& other) const; -Changed return value (return *this) - quaternion& set(f32 x, f32 y, f32 z, f32 w); - quaternion& set(f32 x, f32 y, f32 z); - quaternion& set(const core::vector3df& vec); - quaternion& makeInverse(); - quaternion& slerp( quaternion q1, quaternion q2, f32 interpolate ); - quaternion& fromAngleAxis (f32 angle, const vector3df& axis); - quaternion& makeIdentity(); - quaternion& rotationFromTo(const vector3df& from, const vector3df& to); - -IVideoDriver.h -Added parameters (moved from endScene) and added default values - virtual bool beginScene(bool backBuffer=true, bool zBuffer=true, - SColor color=SColor(255,0,0,0), void* windowId=0, - core::rect<s32>* sourceRect=0) = 0; -Removed parameter (move to beginScene) - virtual bool endScene() = 0; -Renamed method (note, also affects ReferenceCount behavior!) -Use addRenderTargetTexture instead of createRenderTargetTexture - virtual ITexture* addRenderTargetTexture(const core::dimension2d<s32>& size, - const c8* name=0) =0; -Changed parameters (for 32bit index support) - virtual void drawVertexPrimitiveList(const void* vertices, u32 vertexCount, - const void* indexList, u32 primCount, E_VERTEX_TYPE vType, - scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType) = 0; -Changed parameter (colors are const pointers now) - virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect, - const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0, - const video::SColor * const colors=0, bool useAlphaChannelOfTexture=false) = 0; - -IQ3LevelMesh.h -Added default value - virtual const quake3::SShader* getShader( const c8* filename, bool fileNameIsValid=true ) = 0; - -ICameraSceneNode.h -Added method parameter (required to set orthogonal together with projection to avoid inconsistencies) - virtual void setProjectionMatrix(const core::matrix4& projection, bool isOrthogonal = false) = 0; -Removed method (use new parameter in setProjectionMatrix) - void setIsOrthogonal( bool orthogonal ) -Constified return value - virtual const core::vector3df& getTarget() const = 0; - virtual const core::vector3df& getUpVector() const = 0; - -matrix4.h -Removed method (use transformPlane) - void transformPlane_new( core::plane3d<f32> &plane) const; -Changed qulifications (to enable use under Win32 systems, too) - IRRLICHT_API extern const matrix4 IdentityMatrix; - -SIrrCreationParameters.h -Changed member attribute types - u8 Bits; - const c8* const SDK_version_do_not_use; - -IGUIElement.h -Renamed method from setRelativePosition (to distinguish rather different parameter interpretation) - void setRelativePositionProportional(const core::rect<f32>& r) - -irrString.h -Constructors made explicit (use core::stringc(var) in places where var was used before) - explicit string(const double number) - explicit string(int number) - explicit string(unsigned int number) -Added parameter (allows use of method for stringw, and other things) - string<T>& trim(const string<T> & whitespace = " \t\n\r") - -vector2d.h -Changed return value (return *this) - vector2d<T>& set(T nx, T ny) {X=nx; Y=ny; return *this; } - vector2d<T>& set(const vector2d<T>& p) { X=p.X; Y=p.Y; return *this; } -Added default value - vector2d<T>& rotateBy(f64 degrees, const vector2d<T>& center=vector2d<T>()) -Changed parameter type (interpolation factor must not be int) - vector2d<T> getInterpolated(const vector2d<T>& other, f64 d) const - vector2d<T> getInterpolated_quadratic(const vector2d<T>& v2, const vector2d<T>& v3, f64 d) const - vector2d<T>& interpolate(const vector2d<T>& a, const vector2d<T>& b, f64 d) - diff --git a/irrlicht-1.6/include/CDynamicMeshBuffer.h b/irrlicht-1.6/include/CDynamicMeshBuffer.h deleted file mode 100644 index ef497d377..000000000 --- a/irrlicht-1.6/include/CDynamicMeshBuffer.h +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright (C) 2008-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_DYNAMIC_MESHBUFFER_H_INCLUDED__ -#define __C_DYNAMIC_MESHBUFFER_H_INCLUDED__ - -#include "IDynamicMeshBuffer.h" - -#include "CVertexBuffer.h" -#include "CIndexBuffer.h" - -namespace irr -{ -namespace scene -{ - - class CDynamicMeshBuffer: public IDynamicMeshBuffer - { - public: - //! constructor - CDynamicMeshBuffer(video::E_VERTEX_TYPE vertexType, video::E_INDEX_TYPE indexType) - { - VertexBuffer=new CVertexBuffer(vertexType); - IndexBuffer=new CIndexBuffer(indexType); - } - - //! destructor - virtual ~CDynamicMeshBuffer() - { - if (VertexBuffer) - VertexBuffer->drop(); - if (IndexBuffer) - IndexBuffer->drop(); - } - - virtual IVertexBuffer& getVertexBuffer() const - { - return *VertexBuffer; - } - - virtual IIndexBuffer& getIndexBuffer() const - { - return *IndexBuffer; - } - - virtual void setVertexBuffer(IVertexBuffer *newVertexBuffer) - { - if (newVertexBuffer) - newVertexBuffer->grab(); - if (VertexBuffer) - VertexBuffer->drop(); - - VertexBuffer=newVertexBuffer; - } - - virtual void setIndexBuffer(IIndexBuffer *newIndexBuffer) - { - if (newIndexBuffer) - newIndexBuffer->grab(); - if (IndexBuffer) - IndexBuffer->drop(); - - IndexBuffer=newIndexBuffer; - } - - //! Get Material of this buffer. - virtual const video::SMaterial& getMaterial() const - { - return Material; - } - - //! Get Material of this buffer. - virtual video::SMaterial& getMaterial() - { - return Material; - } - - //! Get bounding box - virtual const core::aabbox3d<f32>& getBoundingBox() const - { - return BoundingBox; - } - - //! Set bounding box - virtual void setBoundingBox( const core::aabbox3df& box) - { - BoundingBox = box; - } - - //! Recalculate bounding box - virtual void recalculateBoundingBox() - { - if (!getVertexBuffer().size()) - BoundingBox.reset(0,0,0); - else - { - BoundingBox.reset(getVertexBuffer()[0].Pos); - for (u32 i=1; i<getVertexBuffer().size(); ++i) - BoundingBox.addInternalPoint(getVertexBuffer()[i].Pos); - } - } - - video::SMaterial Material; - core::aabbox3d<f32> BoundingBox; - private: - IVertexBuffer *VertexBuffer; - IIndexBuffer *IndexBuffer; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/CIndexBuffer.h b/irrlicht-1.6/include/CIndexBuffer.h deleted file mode 100644 index b5ac958d1..000000000 --- a/irrlicht-1.6/include/CIndexBuffer.h +++ /dev/null @@ -1,225 +0,0 @@ -// Copyright (C) 2008-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_INDEX_BUFFER_H_INCLUDED__ -#define __C_INDEX_BUFFER_H_INCLUDED__ - -#include "IIndexBuffer.h" - -namespace irr -{ -namespace scene -{ - - class CIndexBuffer : public IIndexBuffer - { - - class IIndexList - { - public: - virtual ~IIndexList(){}; - - virtual u32 stride() const =0; - virtual u32 size() const =0; - virtual void push_back(const u32 &element) =0; - virtual u32 operator [](u32 index) const =0; - virtual u32 getLast() =0; - virtual void setValue(u32 index, u32 value) =0; - virtual void set_used(u32 usedNow) =0; - virtual void reallocate(u32 new_size) =0; - virtual u32 allocated_size() const =0; - virtual void* pointer() =0; - virtual video::E_INDEX_TYPE getType() const =0; - }; - - template <class T> - class CSpecificIndexList : public IIndexList - { - public: - core::array<T> Indices; - - virtual u32 stride() const {return sizeof(T);} - - virtual u32 size() const {return Indices.size();} - - virtual void push_back(const u32 &element) - { - Indices.push_back((T&)element); - } - - virtual u32 operator [](u32 index) const - { - return (u32)(Indices[index]); - } - - virtual u32 getLast() {return (u32)Indices.getLast();} - - virtual void setValue(u32 index, u32 value) - { - Indices[index]=(T)value; - } - - virtual void set_used(u32 usedNow) - { - Indices.set_used(usedNow); - } - - virtual void reallocate(u32 new_size) - { - Indices.reallocate(new_size); - } - - virtual u32 allocated_size() const - { - return Indices.allocated_size(); - } - - virtual void* pointer() {return Indices.pointer();} - - virtual video::E_INDEX_TYPE getType() const - { - if (sizeof(T)==sizeof(u16)) - return video::EIT_16BIT; - else - return video::EIT_32BIT; - } - }; - - public: - IIndexList *Indices; - - CIndexBuffer(video::E_INDEX_TYPE IndexType) :Indices(0), MappingHint(EHM_NEVER), ChangedID(1) - { - setType(IndexType); - } - - CIndexBuffer(const IIndexBuffer &IndexBufferCopy) :Indices(0), MappingHint(EHM_NEVER), ChangedID(1) - { - setType(IndexBufferCopy.getType()); - reallocate(IndexBufferCopy.size()); - - for (u32 n=0;n<IndexBufferCopy.size();++n) - push_back(IndexBufferCopy[n]); - } - - virtual ~CIndexBuffer() - { - delete Indices; - } - - //virtual void setType(video::E_INDEX_TYPE IndexType); - virtual void setType(video::E_INDEX_TYPE IndexType) - { - IIndexList *NewIndices=0; - - switch (IndexType) - { - case video::EIT_16BIT: - { - NewIndices=new CSpecificIndexList<u16>; - break; - } - case video::EIT_32BIT: - { - NewIndices=new CSpecificIndexList<u32>; - break; - } - } - - if (Indices) - { - NewIndices->reallocate( Indices->size() ); - - for(u32 n=0;n<Indices->size();++n) - NewIndices->push_back((*Indices)[n]); - - delete Indices; - } - - Indices=NewIndices; - } - - virtual void* getData() {return Indices->pointer();} - - virtual video::E_INDEX_TYPE getType() const {return Indices->getType();} - - virtual u32 stride() const {return Indices->stride();} - - virtual u32 size() const - { - return Indices->size(); - } - - virtual void push_back(const u32 &element) - { - Indices->push_back(element); - } - - virtual u32 operator [](u32 index) const - { - return (*Indices)[index]; - } - - virtual u32 getLast() - { - return Indices->getLast(); - } - - virtual void setValue(u32 index, u32 value) - { - Indices->setValue(index, value); - } - - virtual void set_used(u32 usedNow) - { - Indices->set_used(usedNow); - } - - virtual void reallocate(u32 new_size) - { - Indices->reallocate(new_size); - } - - virtual u32 allocated_size() const - { - return Indices->allocated_size(); - } - - virtual void* pointer() - { - return Indices->pointer(); - } - - //! get the current hardware mapping hint - virtual E_HARDWARE_MAPPING getHardwareMappingHint() const - { - return MappingHint; - } - - //! set the hardware mapping hint, for driver - virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint ) - { - MappingHint=NewMappingHint; - } - - //! flags the mesh as changed, reloads hardware buffers - virtual void setDirty() - { - ++ChangedID; - } - - //! Get the currently used ID for identification of changes. - /** This shouldn't be used for anything outside the VideoDriver. */ - virtual u32 getChangedID() const {return ChangedID;} - - E_HARDWARE_MAPPING MappingHint; - u32 ChangedID; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/CMeshBuffer.h b/irrlicht-1.6/include/CMeshBuffer.h deleted file mode 100644 index e2b2a50fc..000000000 --- a/irrlicht-1.6/include/CMeshBuffer.h +++ /dev/null @@ -1,301 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __T_MESH_BUFFER_H_INCLUDED__ -#define __T_MESH_BUFFER_H_INCLUDED__ - -#include "irrArray.h" -#include "IMeshBuffer.h" - -namespace irr -{ -namespace scene -{ - //! Template implementation of the IMeshBuffer interface - template <class T> - class CMeshBuffer : public IMeshBuffer - { - public: - //! Default constructor for empty meshbuffer - CMeshBuffer():ChangedID_Vertex(1),ChangedID_Index(1),MappingHint_Vertex(EHM_NEVER), MappingHint_Index(EHM_NEVER) - { - #ifdef _DEBUG - setDebugName("SMeshBuffer"); - #endif - } - - - //! Get material of this meshbuffer - /** \return Material of this buffer */ - virtual const video::SMaterial& getMaterial() const - { - return Material; - } - - - //! Get material of this meshbuffer - /** \return Material of this buffer */ - virtual video::SMaterial& getMaterial() - { - return Material; - } - - - //! Get pointer to vertices - /** \return Pointer to vertices. */ - virtual const void* getVertices() const - { - return Vertices.const_pointer(); - } - - - //! Get pointer to vertices - /** \return Pointer to vertices. */ - virtual void* getVertices() - { - return Vertices.pointer(); - } - - - //! Get number of vertices - /** \return Number of vertices. */ - virtual u32 getVertexCount() const - { - return Vertices.size(); - } - - //! Get type of index data which is stored in this meshbuffer. - /** \return Index type of this buffer. */ - virtual video::E_INDEX_TYPE getIndexType() const - { - return video::EIT_16BIT; - } - - //! Get pointer to indices - /** \return Pointer to indices. */ - virtual const u16* getIndices() const - { - return Indices.const_pointer(); - } - - - //! Get pointer to indices - /** \return Pointer to indices. */ - virtual u16* getIndices() - { - return Indices.pointer(); - } - - - //! Get number of indices - /** \return Number of indices. */ - virtual u32 getIndexCount() const - { - return Indices.size(); - } - - - //! Get the axis aligned bounding box - /** \return Axis aligned bounding box of this buffer. */ - virtual const core::aabbox3d<f32>& getBoundingBox() const - { - return BoundingBox; - } - - - //! Set the axis aligned bounding box - /** \param box New axis aligned bounding box for this buffer. */ - //! set user axis aligned bounding box - virtual void setBoundingBox(const core::aabbox3df& box) - { - BoundingBox = box; - } - - - //! Recalculate the bounding box. - /** should be called if the mesh changed. */ - virtual void recalculateBoundingBox() - { - if (Vertices.empty()) - BoundingBox.reset(0,0,0); - else - { - BoundingBox.reset(Vertices[0].Pos); - for (u32 i=1; i<Vertices.size(); ++i) - BoundingBox.addInternalPoint(Vertices[i].Pos); - } - } - - - //! Get type of vertex data stored in this buffer. - /** \return Type of vertex data. */ - virtual video::E_VERTEX_TYPE getVertexType() const - { - return T().getType(); - } - - //! returns position of vertex i - virtual const core::vector3df& getPosition(u32 i) const - { - return Vertices[i].Pos; - } - - //! returns position of vertex i - virtual core::vector3df& getPosition(u32 i) - { - return Vertices[i].Pos; - } - - //! returns normal of vertex i - virtual const core::vector3df& getNormal(u32 i) const - { - return Vertices[i].Normal; - } - - //! returns normal of vertex i - virtual core::vector3df& getNormal(u32 i) - { - return Vertices[i].Normal; - } - - //! returns texture coord of vertex i - virtual const core::vector2df& getTCoords(u32 i) const - { - return Vertices[i].TCoords; - } - - //! returns texture coord of vertex i - virtual core::vector2df& getTCoords(u32 i) - { - return Vertices[i].TCoords; - } - - - //! Append the vertices and indices to the current buffer - /** Only works for compatible types, i.e. either the same type - or the main buffer is of standard type. Otherwise, behavior is - undefined. - */ - virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) - { - if (vertices == getVertices()) - return; - - const u32 vertexCount = getVertexCount(); - u32 i; - - Vertices.reallocate(vertexCount+numVertices); - for (i=0; i<numVertices; ++i) - { - Vertices.push_back(reinterpret_cast<const T*>(vertices)[i]); - BoundingBox.addInternalPoint(reinterpret_cast<const T*>(vertices)[i].Pos); - } - - Indices.reallocate(getIndexCount()+numIndices); - for (i=0; i<numIndices; ++i) - { - Indices.push_back(indices[i]+vertexCount); - } - } - - - //! Append the meshbuffer to the current buffer - /** Only works for compatible types, i.e. either the same type - or the main buffer is of standard type. Otherwise, behavior is - undefined. - \param other Meshbuffer to be appended to this one. - */ - virtual void append(const IMeshBuffer* const other) - { - /* - if (this==other) - return; - - const u32 vertexCount = getVertexCount(); - u32 i; - - Vertices.reallocate(vertexCount+other->getVertexCount()); - for (i=0; i<other->getVertexCount(); ++i) - { - Vertices.push_back(reinterpret_cast<const T*>(other->getVertices())[i]); - } - - Indices.reallocate(getIndexCount()+other->getIndexCount()); - for (i=0; i<other->getIndexCount(); ++i) - { - Indices.push_back(other->getIndices()[i]+vertexCount); - } - BoundingBox.addInternalBox(other->getBoundingBox()); - */ - } - - - //! get the current hardware mapping hint - virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const - { - return MappingHint_Vertex; - } - - //! get the current hardware mapping hint - virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const - { - return MappingHint_Index; - } - - //! set the hardware mapping hint, for driver - virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint, E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX ) - { - if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_VERTEX) - MappingHint_Vertex=NewMappingHint; - if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_INDEX) - MappingHint_Index=NewMappingHint; - } - - - //! flags the mesh as changed, reloads hardware buffers - virtual void setDirty(E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX) - { - if (Buffer==EBT_VERTEX_AND_INDEX ||Buffer==EBT_VERTEX) - ++ChangedID_Vertex; - if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_INDEX) - ++ChangedID_Index; - } - - //! Get the currently used ID for identification of changes. - /** This shouldn't be used for anything outside the VideoDriver. */ - virtual u32 getChangedID_Vertex() const {return ChangedID_Vertex;} - - //! Get the currently used ID for identification of changes. - /** This shouldn't be used for anything outside the VideoDriver. */ - virtual u32 getChangedID_Index() const {return ChangedID_Index;} - - u32 ChangedID_Vertex; - u32 ChangedID_Index; - - //! hardware mapping hint - E_HARDWARE_MAPPING MappingHint_Vertex; - E_HARDWARE_MAPPING MappingHint_Index; - - //! Material for this meshbuffer. - video::SMaterial Material; - //! Vertices of this buffer - core::array<T> Vertices; - //! Indices into the vertices of this buffer. - core::array<u16> Indices; - //! Bounding box of this meshbuffer. - core::aabbox3d<f32> BoundingBox; - }; - - //! Standard meshbuffer - typedef CMeshBuffer<video::S3DVertex> SMeshBuffer; - //! Meshbuffer with two texture coords per vertex, e.g. for lightmaps - typedef CMeshBuffer<video::S3DVertex2TCoords> SMeshBufferLightMap; - //! Meshbuffer with vertices having tangents stored, e.g. for normal mapping - typedef CMeshBuffer<video::S3DVertexTangents> SMeshBufferTangents; -} // end namespace scene -} // end namespace irr - -#endif - - diff --git a/irrlicht-1.6/include/CVertexBuffer.h b/irrlicht-1.6/include/CVertexBuffer.h deleted file mode 100644 index 6d715248b..000000000 --- a/irrlicht-1.6/include/CVertexBuffer.h +++ /dev/null @@ -1,210 +0,0 @@ -// Copyright (C) 2008-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_VERTEX_BUFFER_H_INCLUDED__ -#define __C_VERTEX_BUFFER_H_INCLUDED__ - -#include "IVertexBuffer.h" - - -namespace irr -{ -namespace scene -{ - - class CVertexBuffer : public IVertexBuffer - { - class IVertexList - { - public: - virtual ~IVertexList(){}; - - virtual u32 stride() const =0; - - virtual u32 size() const =0; - - virtual void push_back (const video::S3DVertex &element) =0; - virtual video::S3DVertex& operator [](const u32 index) const =0; - virtual video::S3DVertex& getLast() =0; - virtual void set_used(u32 usedNow) =0; - virtual void reallocate(u32 new_size) =0; - virtual u32 allocated_size() const =0; - virtual video::S3DVertex* pointer() =0; - virtual video::E_VERTEX_TYPE getType() const =0; - }; - - template <class T> - class CSpecificVertexList : public IVertexList - { - public: - core::array<T> Vertices; - - virtual u32 stride() const {return sizeof(T);} - - virtual u32 size() const {return Vertices.size();} - - virtual void push_back (const video::S3DVertex &element) - {Vertices.push_back((T&)element);} - - virtual video::S3DVertex& operator [](const u32 index) const - {return (video::S3DVertex&)Vertices[index];} - - virtual video::S3DVertex& getLast() - {return (video::S3DVertex&)Vertices.getLast();} - - virtual void set_used(u32 usedNow) - {Vertices.set_used(usedNow);} - - virtual void reallocate(u32 new_size) - {Vertices.reallocate(new_size);} - - virtual u32 allocated_size() const - { - return Vertices.allocated_size(); - } - - virtual video::S3DVertex* pointer() {return Vertices.pointer();} - - virtual video::E_VERTEX_TYPE getType() const {return T().getType();} - }; - - public: - IVertexList *Vertices; - - CVertexBuffer(video::E_VERTEX_TYPE vertexType) : Vertices(0), - MappingHint(EHM_NEVER), ChangedID(1) - { - setType(vertexType); - } - - CVertexBuffer(const IVertexBuffer &VertexBufferCopy) : - Vertices(0), MappingHint(EHM_NEVER), - ChangedID(1) - { - setType(VertexBufferCopy.getType()); - reallocate(VertexBufferCopy.size()); - - for (u32 n=0;n<VertexBufferCopy.size();++n) - push_back(VertexBufferCopy[n]); - } - - virtual ~CVertexBuffer() - { - delete Vertices; - } - - - virtual void setType(video::E_VERTEX_TYPE vertexType) - { - IVertexList *NewVertices=0; - - switch (vertexType) - { - case video::EVT_STANDARD: - { - NewVertices=new CSpecificVertexList<video::S3DVertex>; - break; - } - case video::EVT_2TCOORDS: - { - NewVertices=new CSpecificVertexList<video::S3DVertex2TCoords>; - break; - } - case video::EVT_TANGENTS: - { - NewVertices=new CSpecificVertexList<video::S3DVertexTangents>; - break; - } - } - if (Vertices) - { - NewVertices->reallocate( Vertices->size() ); - - for(u32 n=0;n<Vertices->size();++n) - NewVertices->push_back((*Vertices)[n]); - - delete Vertices; - } - - Vertices=NewVertices; - } - - virtual void* getData() {return Vertices->pointer();} - - virtual video::E_VERTEX_TYPE getType() const {return Vertices->getType();} - - virtual u32 stride() const {return Vertices->stride();} - - virtual u32 size() const - { - return Vertices->size(); - } - - virtual void push_back (const video::S3DVertex &element) - { - Vertices->push_back(element); - } - - virtual video::S3DVertex& operator [](const u32 index) const - { - return (*Vertices)[index]; - } - - virtual video::S3DVertex& getLast() - { - return Vertices->getLast(); - } - - virtual void set_used(u32 usedNow) - { - Vertices->set_used(usedNow); - } - - virtual void reallocate(u32 new_size) - { - Vertices->reallocate(new_size); - } - - virtual u32 allocated_size() const - { - return Vertices->allocated_size(); - } - - virtual video::S3DVertex* pointer() - { - return Vertices->pointer(); - } - - //! get the current hardware mapping hint - virtual E_HARDWARE_MAPPING getHardwareMappingHint() const - { - return MappingHint; - } - - //! set the hardware mapping hint, for driver - virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint ) - { - MappingHint=NewMappingHint; - } - - //! flags the mesh as changed, reloads hardware buffers - virtual void setDirty() - { - ++ChangedID; - } - - //! Get the currently used ID for identification of changes. - /** This shouldn't be used for anything outside the VideoDriver. */ - virtual u32 getChangedID() const {return ChangedID;} - - E_HARDWARE_MAPPING MappingHint; - u32 ChangedID; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/ECullingTypes.h b/irrlicht-1.6/include/ECullingTypes.h deleted file mode 100644 index 95c865a84..000000000 --- a/irrlicht-1.6/include/ECullingTypes.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __E_CULLING_TYPES_H_INCLUDED__ -#define __E_CULLING_TYPES_H_INCLUDED__ - -#include "irrTypes.h" - -namespace irr -{ -namespace scene -{ - - //! An enumeration for all types of automatic culling for built-in scene nodes - enum E_CULLING_TYPE - { - EAC_OFF = 0, - EAC_BOX = 1, - EAC_FRUSTUM_BOX = 2, - EAC_FRUSTUM_SPHERE = 4 - }; - - //! Names for culling type - const c8* const AutomaticCullingNames[] = - { - "false", - "box", // camera box against node box - "frustum_box", // camera frustum against node box - "frustum_sphere", // camera frustum against node sphere - 0 - }; - -} // end namespace scene -} // end namespace irr - - -#endif // __E_CULLING_TYPES_H_INCLUDED__ - diff --git a/irrlicht-1.6/include/EDebugSceneTypes.h b/irrlicht-1.6/include/EDebugSceneTypes.h deleted file mode 100644 index 025d22b5c..000000000 --- a/irrlicht-1.6/include/EDebugSceneTypes.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __E_DEBUG_SCENE_TYPES_H_INCLUDED__ -#define __E_DEBUG_SCENE_TYPES_H_INCLUDED__ - -namespace irr -{ -namespace scene -{ - - //! An enumeration for all types of debug data for built-in scene nodes (flags) - enum E_DEBUG_SCENE_TYPE - { - //! No Debug Data ( Default ) - EDS_OFF = 0, - - //! Show Bounding Boxes of SceneNode - EDS_BBOX = 1, - - //! Show Vertex Normals - EDS_NORMALS = 2, - - //! Shows Skeleton/Tags - EDS_SKELETON = 4, - - //! Overlays Mesh Wireframe - EDS_MESH_WIRE_OVERLAY = 8, - - //! Temporary use transparency Material Type - EDS_HALF_TRANSPARENCY = 16, - - //! Show Bounding Boxes of all MeshBuffers - EDS_BBOX_BUFFERS = 32, - - //! EDS_BBOX | EDS_BBOX_BUFFERS - EDS_BBOX_ALL = EDS_BBOX | EDS_BBOX_BUFFERS, - - //! Show all debug infos - EDS_FULL = 0xffffffff - }; - - -} // end namespace scene -} // end namespace irr - - -#endif // __E_DEBUG_SCENE_TYPES_H_INCLUDED__ - diff --git a/irrlicht-1.6/include/EDeviceTypes.h b/irrlicht-1.6/include/EDeviceTypes.h deleted file mode 100644 index 809531fd8..000000000 --- a/irrlicht-1.6/include/EDeviceTypes.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef __E_DEVICE_TYPES_H_INCLUDED__ -#define __E_DEVICE_TYPES_H_INCLUDED__ - -namespace irr -{ - - //! An enum for the different device types supported by the Irrlicht Engine. - enum E_DEVICE_TYPE - { - - //! A device native to Microsoft Windows - /** This device uses the Win32 API and works in all versions of Windows. */ - EIDT_WIN32, - - //! A device native to Windows CE devices - /** This device works on Windows Mobile, Pocket PC and Microsoft SmartPhone devices */ - EIDT_WINCE, - - //! A device native to Unix style operating systems. - /** This device uses the X11 windowing system and works in Linux, Solaris, FreeBSD, OSX and - other operating systems which support X11. */ - EIDT_X11, - - //! A device native to Mac OSX - /** This device uses Apple's Cocoa API and works in Mac OSX 10.2 and above. */ - EIDT_OSX, - - //! A device which uses Simple DirectMedia Layer - /** The SDL device works under all platforms supported by SDL but first must be compiled - in by defining the IRR_USE_SDL_DEVICE macro in IrrCompileConfig.h */ - EIDT_SDL, - - //! A simple text only device supported by all platforms. - /** This device allows applications to run from the command line without opening a window. - It can render the output of the software drivers to the console as ASCII. It only supports - mouse and keyboard in Windows operating systems. */ - EIDT_CONSOLE, - - //! This selection allows Irrlicht to choose the best device from the ones available. - /** If this selection is chosen then Irrlicht will try to use the IrrlichtDevice native - to your operating system. If this is unavailable then the X11, SDL and then console device - will be tried. This ensures that Irrlicht will run even if your platform is unsupported, - although it may not be able to render anything. */ - EIDT_BEST - }; - -} // end namespace irr - -#endif // __E_DEVICE_TYPES_H_INCLUDED__ - diff --git a/irrlicht-1.6/include/EDriverFeatures.h b/irrlicht-1.6/include/EDriverFeatures.h deleted file mode 100644 index 5a521fcbb..000000000 --- a/irrlicht-1.6/include/EDriverFeatures.h +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __E_DRIVER_FEATURES_H_INCLUDED__ -#define __E_DRIVER_FEATURES_H_INCLUDED__ - -namespace irr -{ -namespace video -{ - - //! enumeration for querying features of the video driver. - enum E_VIDEO_DRIVER_FEATURE - { - //! Is driver able to render to a surface? - EVDF_RENDER_TO_TARGET = 0, - - //! Is hardeware transform and lighting supported? - EVDF_HARDWARE_TL, - - //! Are multiple textures per material possible? - EVDF_MULTITEXTURE, - - //! Is driver able to render with a bilinear filter applied? - EVDF_BILINEAR_FILTER, - - //! Can the driver handle mip maps? - EVDF_MIP_MAP, - - //! Can the driver update mip maps automatically? - EVDF_MIP_MAP_AUTO_UPDATE, - - //! Are stencilbuffers switched on and does the device support stencil buffers? - EVDF_STENCIL_BUFFER, - - //! Is Vertex Shader 1.1 supported? - EVDF_VERTEX_SHADER_1_1, - - //! Is Vertex Shader 2.0 supported? - EVDF_VERTEX_SHADER_2_0, - - //! Is Vertex Shader 3.0 supported? - EVDF_VERTEX_SHADER_3_0, - - //! Is Pixel Shader 1.1 supported? - EVDF_PIXEL_SHADER_1_1, - - //! Is Pixel Shader 1.2 supported? - EVDF_PIXEL_SHADER_1_2, - - //! Is Pixel Shader 1.3 supported? - EVDF_PIXEL_SHADER_1_3, - - //! Is Pixel Shader 1.4 supported? - EVDF_PIXEL_SHADER_1_4, - - //! Is Pixel Shader 2.0 supported? - EVDF_PIXEL_SHADER_2_0, - - //! Is Pixel Shader 3.0 supported? - EVDF_PIXEL_SHADER_3_0, - - //! Are ARB vertex programs v1.0 supported? - EVDF_ARB_VERTEX_PROGRAM_1, - - //! Are ARB fragment programs v1.0 supported? - EVDF_ARB_FRAGMENT_PROGRAM_1, - - //! Is GLSL supported? - EVDF_ARB_GLSL, - - //! Is HLSL supported? - EVDF_HLSL, - - //! Are non-square textures supported? - EVDF_TEXTURE_NSQUARE, - - //! Are non-power-of-two textures supported? - EVDF_TEXTURE_NPOT, - - //! Are framebuffer objects supported? - EVDF_FRAMEBUFFER_OBJECT, - - //! Are vertex buffer objects supported? - EVDF_VERTEX_BUFFER_OBJECT, - - //! Supports Alpha To Coverage - EVDF_ALPHA_TO_COVERAGE, - - //! Supports Color masks (disabling color planes in output) - EVDF_COLOR_MASK, - - //! Only used for counting the elements of this enum - EVDF_COUNT - }; - -} // end namespace video -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/include/EDriverTypes.h b/irrlicht-1.6/include/EDriverTypes.h deleted file mode 100644 index 06bd67f54..000000000 --- a/irrlicht-1.6/include/EDriverTypes.h +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __E_DRIVER_TYPES_H_INCLUDED__ -#define __E_DRIVER_TYPES_H_INCLUDED__ - -namespace irr -{ -namespace video -{ - - //! An enum for all types of drivers the Irrlicht Engine supports. - enum E_DRIVER_TYPE - { - //! Null driver, useful for applications to run the engine without visualisation. - /** The null device is able to load textures, but does not - render and display any graphics. */ - EDT_NULL, - - //! The Irrlicht Engine Software renderer. - /** Runs on all platforms, with every hardware. It should only - be used for 2d graphics, but it can also perform some primitive - 3d functions. These 3d drawing functions are quite fast, but - very inaccurate, and don't even support clipping in 3D mode. */ - EDT_SOFTWARE, - - //! The Burning's Software Renderer, an alternative software renderer - /** Basically it can be described as the Irrlicht Software - renderer on steroids. It rasterizes 3D geometry perfectly: It - is able to perform correct 3d clipping, perspective correct - texture mapping, perspective correct color mapping, and renders - sub pixel correct, sub texel correct primitives. In addition, - it does bilinear texel filtering and supports more materials - than the EDT_SOFTWARE driver. This renderer has been written - entirely by Thomas Alten, thanks a lot for this huge - contribution. */ - EDT_BURNINGSVIDEO, - - //! Direct3D8 device, only available on Win32 platforms. - /** Performs hardware accelerated rendering of 3D and 2D - primitives. */ - EDT_DIRECT3D8, - - //! Direct3D 9 device, only available on Win32 platforms. - /** Performs hardware accelerated rendering of 3D and 2D - primitives. */ - EDT_DIRECT3D9, - - //! OpenGL device, available on most platforms. - /** Performs hardware accelerated rendering of 3D and 2D - primitives. */ - EDT_OPENGL - }; - -} // end namespace video -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/include/EGUIAlignment.h b/irrlicht-1.6/include/EGUIAlignment.h deleted file mode 100644 index 9ebd40ce0..000000000 --- a/irrlicht-1.6/include/EGUIAlignment.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __E_GUI_ALIGNMENT_H_INCLUDED__ -#define __E_GUI_ALIGNMENT_H_INCLUDED__ - -namespace irr -{ -namespace gui -{ -enum EGUI_ALIGNMENT -{ - //! Aligned to parent's top or left side (default) - EGUIA_UPPERLEFT=0, - //! Aligned to parent's bottom or right side - EGUIA_LOWERRIGHT, - //! Aligned to the center of parent - EGUIA_CENTER, - //! Stretched to fit parent - EGUIA_SCALE -}; - -//! Names for alignments -const c8* const GUIAlignmentNames[] = -{ - "upperLeft", - "lowerRight", - "center", - "scale", - 0 -}; - -} // namespace gui -} // namespace irr - -#endif // __E_GUI_ALIGNMENT_H_INCLUDED__ - diff --git a/irrlicht-1.6/include/EGUIElementTypes.h b/irrlicht-1.6/include/EGUIElementTypes.h deleted file mode 100644 index 48901795e..000000000 --- a/irrlicht-1.6/include/EGUIElementTypes.h +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __E_GUI_ELEMENT_TYPES_H_INCLUDED__ -#define __E_GUI_ELEMENT_TYPES_H_INCLUDED__ - -#include "irrTypes.h" - -namespace irr -{ -namespace gui -{ - -//! List of all basic Irrlicht GUI elements. -/** An IGUIElement returns this when calling IGUIElement::getType(); */ -enum EGUI_ELEMENT_TYPE -{ - //! A button (IGUIButton) - EGUIET_BUTTON = 0, - - //! A check box (IGUICheckBox) - EGUIET_CHECK_BOX, - - //! A combo box (IGUIComboBox) - EGUIET_COMBO_BOX, - - //! A context menu (IGUIContextMenu) - EGUIET_CONTEXT_MENU, - - //! A menu (IGUIMenu) - EGUIET_MENU, - - //! An edit box (IGUIEditBox) - EGUIET_EDIT_BOX, - - //! A file open dialog (IGUIFileOpenDialog) - EGUIET_FILE_OPEN_DIALOG, - - //! A color select open dialog (IGUIColorSelectDialog) - EGUIET_COLOR_SELECT_DIALOG, - - //! A in/out fader (IGUIInOutFader) - EGUIET_IN_OUT_FADER, - - //! An image (IGUIImage) - EGUIET_IMAGE, - - //! A list box (IGUIListBox) - EGUIET_LIST_BOX, - - //! A mesh viewer (IGUIMeshViewer) - EGUIET_MESH_VIEWER, - - //! A message box (IGUIWindow) - EGUIET_MESSAGE_BOX, - - //! A modal screen - EGUIET_MODAL_SCREEN, - - //! A scroll bar (IGUIScrollBar) - EGUIET_SCROLL_BAR, - - //! A spin box (IGUISpinBox) - EGUIET_SPIN_BOX, - - //! A static text (IGUIStaticText) - EGUIET_STATIC_TEXT, - - //! A tab (IGUITab) - EGUIET_TAB, - - //! A tab control - EGUIET_TAB_CONTROL, - - //! A Table - EGUIET_TABLE, - - //! A tool bar (IGUIToolBar) - EGUIET_TOOL_BAR, - - //! A Tree View - EGUIET_TREE_VIEW, - - //! A window - EGUIET_WINDOW, - - //! Not an element, amount of elements in there - EGUIET_COUNT, - - //! Unknown type. - EGUIET_ELEMENT, - - //! This enum is never used, it only forces the compiler to compile this enumeration to 32 bit. - EGUIET_FORCE_32_BIT = 0x7fffffff - -}; - -//! Names for built-in element types -const c8* const GUIElementTypeNames[] = -{ - "button", - "checkBox", - "comboBox", - "contextMenu", - "menu", - "editBox", - "fileOpenDialog", - "colorSelectDialog", - "inOutFader", - "image", - "listBox", - "meshViewer", - "messageBox", - "modalScreen", - "scrollBar", - "spinBox", - "staticText", - "tab", - "tabControl", - "table", - "toolBar", - "treeview", - "window", - 0 -}; - -} // end namespace gui -} // end namespace irr - -#endif - - - - diff --git a/irrlicht-1.6/include/EHardwareBufferFlags.h b/irrlicht-1.6/include/EHardwareBufferFlags.h deleted file mode 100644 index 46db26a56..000000000 --- a/irrlicht-1.6/include/EHardwareBufferFlags.h +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __E_HARDWARE_BUFFER_FLAGS_INCLUDED__ -#define __E_HARDWARE_BUFFER_FLAGS_INCLUDED__ - -namespace irr -{ -namespace scene -{ - - enum E_HARDWARE_MAPPING - { - //! Don't store on the hardware - EHM_NEVER=0, - - //! Rarely changed, usually stored completely on the hardware - EHM_STATIC, - - //! Sometimes changed, driver optimized placement - EHM_DYNAMIC, - - //! Always changed, cache optimizing on the GPU - EHM_STREAM - }; - - enum E_BUFFER_TYPE - { - //! Does not change anything - EBT_NONE=0, - //! Change the vertex mapping - EBT_VERTEX, - //! Change the index mapping - EBT_INDEX, - //! Change both vertex and index mapping to the same value - EBT_VERTEX_AND_INDEX - }; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/EMaterialFlags.h b/irrlicht-1.6/include/EMaterialFlags.h deleted file mode 100644 index b703ebadb..000000000 --- a/irrlicht-1.6/include/EMaterialFlags.h +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __E_MATERIAL_FLAGS_H_INCLUDED__ -#define __E_MATERIAL_FLAGS_H_INCLUDED__ - -namespace irr -{ -namespace video -{ - - //! Material flags - enum E_MATERIAL_FLAG - { - //! Draw as wireframe or filled triangles? Default: false - EMF_WIREFRAME = 0x1, - - //! Draw as point cloud or filled triangles? Default: false - EMF_POINTCLOUD = 0x2, - - //! Flat or Gouraud shading? Default: true - EMF_GOURAUD_SHADING = 0x4, - - //! Will this material be lighted? Default: true - EMF_LIGHTING = 0x8, - - //! Is the ZBuffer enabled? Default: true - EMF_ZBUFFER = 0x10, - - //! May be written to the zbuffer or is it readonly. Default: true - /** This flag is ignored, if the material type is a transparent type. */ - EMF_ZWRITE_ENABLE = 0x20, - - //! Is backface culling enabled? Default: true - EMF_BACK_FACE_CULLING = 0x40, - - //! Is frontface culling enabled? Default: false - /** Overrides EMF_BACK_FACE_CULLING if both are enabled. */ - EMF_FRONT_FACE_CULLING = 0x80, - - //! Is bilinear filtering enabled? Default: true - EMF_BILINEAR_FILTER = 0x100, - - //! Is trilinear filtering enabled? Default: false - /** If the trilinear filter flag is enabled, - the bilinear filtering flag is ignored. */ - EMF_TRILINEAR_FILTER = 0x200, - - //! Is anisotropic filtering? Default: false - /** In Irrlicht you can use anisotropic texture filtering in - conjunction with bilinear or trilinear texture filtering - to improve rendering results. Primitives will look less - blurry with this flag switched on. */ - EMF_ANISOTROPIC_FILTER = 0x400, - - //! Is fog enabled? Default: false - EMF_FOG_ENABLE = 0x800, - - //! Normalizes normals. Default: false - /** You can enable this if you need to scale a dynamic lighted - model. Usually, its normals will get scaled too then and it - will get darker. If you enable the EMF_NORMALIZE_NORMALS flag, - the normals will be normalized again, and the model will look - as bright as it should. */ - EMF_NORMALIZE_NORMALS = 0x1000, - - //! Access to all layers texture wrap settings. Overwrites separate layer settings. - EMF_TEXTURE_WRAP = 0x2000, - - //! AntiAliasing mode - EMF_ANTI_ALIASING = 0x4000, - - //! ColorMask bits, for enabling the color planes - EMF_COLOR_MASK = 0x8000, - - //! ColorMaterial enum for vertex color interpretation - EMF_COLOR_MATERIAL = 0x10000 - }; - -} // end namespace video -} // end namespace irr - - -#endif // __E_MATERIAL_FLAGS_H_INCLUDED__ - diff --git a/irrlicht-1.6/include/EMaterialTypes.h b/irrlicht-1.6/include/EMaterialTypes.h deleted file mode 100644 index 69f92cdde..000000000 --- a/irrlicht-1.6/include/EMaterialTypes.h +++ /dev/null @@ -1,234 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __E_MATERIAL_TYPES_H_INCLUDED__ -#define __E_MATERIAL_TYPES_H_INCLUDED__ - -namespace irr -{ -namespace video -{ - - //! Abstracted and easy to use fixed function/programmable pipeline material modes. - enum E_MATERIAL_TYPE - { - //! Standard solid material. - /** Only first texture is used, which is supposed to be the - diffuse material. */ - EMT_SOLID = 0, - - //! Solid material with 2 texture layers. - /** The second is blended onto the first using the alpha value - of the vertex colors. This material is currently not implemented in OpenGL. - */ - EMT_SOLID_2_LAYER, - - //! Material type with standard lightmap technique - /** There should be 2 textures: The first texture layer is a - diffuse map, the second is a light map. Dynamic light is - ignored. */ - EMT_LIGHTMAP, - - //! Material type with lightmap technique like EMT_LIGHTMAP. - /** But lightmap and diffuse texture are added instead of modulated. */ - EMT_LIGHTMAP_ADD, - - //! Material type with standard lightmap technique - /** There should be 2 textures: The first texture layer is a - diffuse map, the second is a light map. Dynamic light is - ignored. The texture colors are effectively multiplied by 2 - for brightening. Like known in DirectX as D3DTOP_MODULATE2X. */ - EMT_LIGHTMAP_M2, - - //! Material type with standard lightmap technique - /** There should be 2 textures: The first texture layer is a - diffuse map, the second is a light map. Dynamic light is - ignored. The texture colors are effectively multiplyied by 4 - for brightening. Like known in DirectX as D3DTOP_MODULATE4X. */ - EMT_LIGHTMAP_M4, - - //! Like EMT_LIGHTMAP, but also supports dynamic lighting. - EMT_LIGHTMAP_LIGHTING, - - //! Like EMT_LIGHTMAP_M2, but also supports dynamic lighting. - EMT_LIGHTMAP_LIGHTING_M2, - - //! Like EMT_LIGHTMAP_4, but also supports dynamic lighting. - EMT_LIGHTMAP_LIGHTING_M4, - - //! Detail mapped material. - /** The first texture is diffuse color map, the second is added - to this and usually displayed with a bigger scale value so that - it adds more detail. The detail map is added to the diffuse map - using ADD_SIGNED, so that it is possible to add and substract - color from the diffuse map. For example a value of - (127,127,127) will not change the appearance of the diffuse map - at all. Often used for terrain rendering. */ - EMT_DETAIL_MAP, - - //! Look like a reflection of the environment around it. - /** To make this possible, a texture called 'sphere map' is - used, which must be set as the first texture. */ - EMT_SPHERE_MAP, - - //! A reflecting material with an optional non reflecting texture layer. - /** The reflection map should be set as first texture. */ - EMT_REFLECTION_2_LAYER, - - //! A transparent material. - /** Only the first texture is used. The new color is calculated - by simply adding the source color and the dest color. This - means if for example a billboard using a texture with black - background and a red circle on it is drawn with this material, - the result is that only the red circle will be drawn a little - bit transparent, and everything which was black is 100% - transparent and not visible. This material type is useful for - particle effects. */ - EMT_TRANSPARENT_ADD_COLOR, - - //! Makes the material transparent based on the texture alpha channel. - /** The final color is blended together from the destination - color and the texture color, using the alpha channel value as - blend factor. Only first texture is used. If you are using - this material with small textures, it is a good idea to load - the texture in 32 bit mode - (video::IVideoDriver::setTextureCreationFlag()). Also, an alpha - ref is used, which can be manipulated using - SMaterial::MaterialTypeParam. This value controls how sharp the - edges become when going from a transparent to a solid spot on - the texture. */ - EMT_TRANSPARENT_ALPHA_CHANNEL, - - //! Makes the material transparent based on the texture alpha channel. - /** If the alpha channel value is greater than 127, a - pixel is written to the target, otherwise not. This - material does not use alpha blending and is a lot faster - than EMT_TRANSPARENT_ALPHA_CHANNEL. It is ideal for drawing - stuff like leafes of plants, because the borders are not - blurry but sharp. Only first texture is used. If you are - using this material with small textures and 3d object, it - is a good idea to load the texture in 32 bit mode - (video::IVideoDriver::setTextureCreationFlag()). */ - EMT_TRANSPARENT_ALPHA_CHANNEL_REF, - - //! Makes the material transparent based on the vertex alpha value. - EMT_TRANSPARENT_VERTEX_ALPHA, - - //! A transparent reflecting material with an optional additional non reflecting texture layer. - /** The reflection map should be set as first texture. The - transparency depends on the alpha value in the vertex colors. A - texture which will not reflect can be set as second texture. - Please note that this material type is currently not 100% - implemented in OpenGL. */ - EMT_TRANSPARENT_REFLECTION_2_LAYER, - - //! A solid normal map renderer. - /** First texture is the color map, the second should be the - normal map. Note that you should use this material only when - drawing geometry consisting of vertices of type - S3DVertexTangents (EVT_TANGENTS). You can convert any mesh into - this format using IMeshManipulator::createMeshWithTangents() - (See SpecialFX2 Tutorial). This shader runs on vertex shader - 1.1 and pixel shader 1.1 capable hardware and falls back to a - fixed function lighted material if this hardware is not - available. Only two lights are supported by this shader, if - there are more, the nearest two are chosen. */ - EMT_NORMAL_MAP_SOLID, - - //! A transparent normal map renderer. - /** First texture is the color map, the second should be the - normal map. Note that you should use this material only when - drawing geometry consisting of vertices of type - S3DVertexTangents (EVT_TANGENTS). You can convert any mesh into - this format using IMeshManipulator::createMeshWithTangents() - (See SpecialFX2 Tutorial). This shader runs on vertex shader - 1.1 and pixel shader 1.1 capable hardware and falls back to a - fixed function lighted material if this hardware is not - available. Only two lights are supported by this shader, if - there are more, the nearest two are chosen. */ - EMT_NORMAL_MAP_TRANSPARENT_ADD_COLOR, - - //! A transparent (based on the vertex alpha value) normal map renderer. - /** First texture is the color map, the second should be the - normal map. Note that you should use this material only when - drawing geometry consisting of vertices of type - S3DVertexTangents (EVT_TANGENTS). You can convert any mesh into - this format using IMeshManipulator::createMeshWithTangents() - (See SpecialFX2 Tutorial). This shader runs on vertex shader - 1.1 and pixel shader 1.1 capable hardware and falls back to a - fixed function lighted material if this hardware is not - available. Only two lights are supported by this shader, if - there are more, the nearest two are chosen. */ - EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA, - - //! Just like EMT_NORMAL_MAP_SOLID, but uses parallax mapping. - /** Looks a lot more realistic. This only works when the - hardware supports at least vertex shader 1.1 and pixel shader - 1.4. First texture is the color map, the second should be the - normal map. The normal map texture should contain the height - value in the alpha component. The - IVideoDriver::makeNormalMapTexture() method writes this value - automatically when creating normal maps from a heightmap when - using a 32 bit texture. The height scale of the material - (affecting the bumpiness) is being controlled by the - SMaterial::MaterialTypeParam member. If set to zero, the - default value (0.02f) will be applied. Otherwise the value set - in SMaterial::MaterialTypeParam is taken. This value depends on - with which scale the texture is mapped on the material. Too - high or low values of MaterialTypeParam can result in strange - artifacts. */ - EMT_PARALLAX_MAP_SOLID, - - //! A material like EMT_PARALLAX_MAP_SOLID, but transparent. - /** Using EMT_TRANSPARENT_ADD_COLOR as base material. */ - EMT_PARALLAX_MAP_TRANSPARENT_ADD_COLOR, - - //! A material like EMT_PARALLAX_MAP_SOLID, but transparent. - /** Using EMT_TRANSPARENT_VERTEX_ALPHA as base material. */ - EMT_PARALLAX_MAP_TRANSPARENT_VERTEX_ALPHA, - - //! BlendFunc = source * sourceFactor + dest * destFactor ( E_BLEND_FUNC ) - /** Using only first texture. Generic blending method. */ - EMT_ONETEXTURE_BLEND, - - //! This value is not used. It only forces this enumeration to compile to 32 bit. - EMT_FORCE_32BIT = 0x7fffffff - }; - - //! Array holding the built in material type names - const char* const sBuiltInMaterialTypeNames[] = - { - "solid", - "solid_2layer", - "lightmap", - "lightmap_add", - "lightmap_m2", - "lightmap_m4", - "lightmap_light", - "lightmap_light_m2", - "lightmap_light_m4", - "detail_map", - "sphere_map", - "reflection_2layer", - "trans_add", - "trans_alphach", - "trans_alphach_ref", - "trans_vertex_alpha", - "trans_reflection_2layer", - "normalmap_solid", - "normalmap_trans_add", - "normalmap_trans_vertexalpha", - "parallaxmap_solid", - "parallaxmap_trans_add", - "parallaxmap_trans_vertexalpha", - "onetexture_blend", - 0 - }; - -} // end namespace video -} // end namespace irr - - -#endif // __E_MATERIAL_TYPES_H_INCLUDED__ - diff --git a/irrlicht-1.6/include/EMeshWriterEnums.h b/irrlicht-1.6/include/EMeshWriterEnums.h deleted file mode 100644 index 4e6cd50c3..000000000 --- a/irrlicht-1.6/include/EMeshWriterEnums.h +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (C) 2002-2009 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__ - -#include "irrTypes.h" - -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), - - //! OBJ mesh writer for .obj files - EMWT_OBJ = MAKE_IRR_ID('o','b','j',0), - - //! PLY mesh writer for .ply files - EMWT_PLY = MAKE_IRR_ID('p','l','y',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 consumes less disk space - EMWF_WRITE_COMPRESSED = 0x2, - - //! write in binary format rather than text - EMWF_WRITE_BINARY = 0x4 - }; - -} // end namespace scene -} // end namespace irr - - -#endif // __E_MESH_WRITER_ENUMS_H_INCLUDED__ - diff --git a/irrlicht-1.6/include/EMessageBoxFlags.h b/irrlicht-1.6/include/EMessageBoxFlags.h deleted file mode 100644 index 8e8ead8a9..000000000 --- a/irrlicht-1.6/include/EMessageBoxFlags.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __E_MESSAGE_BOX_FLAGS_H_INCLUDED__ -#define __E_MESSAGE_BOX_FLAGS_H_INCLUDED__ - -namespace irr -{ -namespace gui -{ - -//! enumeration for message box layout flags -enum EMESSAGE_BOX_FLAG -{ - //! Flag for the ok button - EMBF_OK = 0x1, - - //! Flag for the cancel button - EMBF_CANCEL = 0x2, - - //! Flag for the yes button - EMBF_YES = 0x4, - - //! Flag for the no button - EMBF_NO = 0x8, - - //! This value is not used. It only forces this enumeration to compile in 32 bit. - EMBF_FORCE_32BIT = 0x7fffffff -}; - -} // namespace gui -} // namespace irr - -#endif - diff --git a/irrlicht-1.6/include/ESceneNodeAnimatorTypes.h b/irrlicht-1.6/include/ESceneNodeAnimatorTypes.h deleted file mode 100644 index 63a78f7f1..000000000 --- a/irrlicht-1.6/include/ESceneNodeAnimatorTypes.h +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __E_SCENE_NODE_ANIMATOR_TYPES_H_INCLUDED__ -#define __E_SCENE_NODE_ANIMATOR_TYPES_H_INCLUDED__ - -namespace irr -{ -namespace scene -{ - - //! An enumeration for all types of built-in scene node animators - enum ESCENE_NODE_ANIMATOR_TYPE - { - //! Fly circle scene node animator - ESNAT_FLY_CIRCLE = 0, - - //! Fly straight scene node animator - ESNAT_FLY_STRAIGHT, - - //! Follow spline scene node animator - ESNAT_FOLLOW_SPLINE, - - //! Rotation scene node animator - ESNAT_ROTATION, - - //! Texture scene node animator - ESNAT_TEXTURE, - - //! Deletion scene node animator - ESNAT_DELETION, - - //! Collision respose scene node animator - ESNAT_COLLISION_RESPONSE, - - //! FPS camera animator - ESNAT_CAMERA_FPS, - - //! Maya camera animator - ESNAT_CAMERA_MAYA, - - //! Amount of built-in scene node animators - ESNAT_COUNT, - - //! Unknown scene node animator - ESNAT_UNKNOWN, - - //! This enum is never used, it only forces the compiler to compile this enumeration to 32 bit. - ESNAT_FORCE_32_BIT = 0x7fffffff - }; - -} // end namespace scene -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/include/ESceneNodeTypes.h b/irrlicht-1.6/include/ESceneNodeTypes.h deleted file mode 100644 index 0a36bc927..000000000 --- a/irrlicht-1.6/include/ESceneNodeTypes.h +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __E_SCENE_NODE_TYPES_H_INCLUDED__ -#define __E_SCENE_NODE_TYPES_H_INCLUDED__ - -#include "irrTypes.h" - -namespace irr -{ -namespace scene -{ - - //! An enumeration for all types of built-in scene nodes - /** A scene node type is represented by a four character code - such as 'cube' or 'mesh' instead of simple numbers, to avoid - name clashes with external scene nodes.*/ - enum ESCENE_NODE_TYPE - { - //! simple cube scene node - ESNT_CUBE = MAKE_IRR_ID('c','u','b','e'), - - //! Sphere scene node - ESNT_SPHERE = MAKE_IRR_ID('s','p','h','r'), - - //! Text Scene Node - ESNT_TEXT = MAKE_IRR_ID('t','e','x','t'), - - //! Water Surface Scene Node - ESNT_WATER_SURFACE = MAKE_IRR_ID('w','a','t','r'), - - //! Terrain Scene Node - ESNT_TERRAIN = MAKE_IRR_ID('t','e','r','r'), - - //! Sky Box Scene Node - ESNT_SKY_BOX = MAKE_IRR_ID('s','k','y','_'), - - //! Sky Dome Scene Node - ESNT_SKY_DOME = MAKE_IRR_ID('s','k','y','d'), - - //! Shadow Volume Scene Node - ESNT_SHADOW_VOLUME = MAKE_IRR_ID('s','h','d','w'), - - //! OctTree Scene Node - ESNT_OCT_TREE = MAKE_IRR_ID('o','c','t','t'), - - //! Mesh Scene Node - ESNT_MESH = MAKE_IRR_ID('m','e','s','h'), - - //! Light Scene Node - ESNT_LIGHT = MAKE_IRR_ID('l','g','h','t'), - - //! Empty Scene Node - ESNT_EMPTY = MAKE_IRR_ID('e','m','t','y'), - - //! Dummy Transformation Scene Node - ESNT_DUMMY_TRANSFORMATION = MAKE_IRR_ID('d','m','m','y'), - - //! Camera Scene Node - ESNT_CAMERA = MAKE_IRR_ID('c','a','m','_'), - - //! Billboard Scene Node - ESNT_BILLBOARD = MAKE_IRR_ID('b','i','l','l'), - - //! Animated Mesh Scene Node - ESNT_ANIMATED_MESH = MAKE_IRR_ID('a','m','s','h'), - - //! Particle System Scene Node - ESNT_PARTICLE_SYSTEM = MAKE_IRR_ID('p','t','c','l'), - - //! Quake3 Shader Scene Node - ESNT_Q3SHADER_SCENE_NODE = MAKE_IRR_ID('q','3','s','h'), - - //! Quake3 Model Scene Node ( has tag to link to ) - ESNT_MD3_SCENE_NODE = MAKE_IRR_ID('m','d','3','_'), - - //! Volume Light Scene Node - ESNT_VOLUME_LIGHT = MAKE_IRR_ID('v','o','l','l'), - - //! Maya Camera Scene Node - /** Legacy, for loading version <= 1.4.x .irr files */ - ESNT_CAMERA_MAYA = MAKE_IRR_ID('c','a','m','M'), - - //! First Person Shooter Camera - /** Legacy, for loading version <= 1.4.x .irr files */ - ESNT_CAMERA_FPS = MAKE_IRR_ID('c','a','m','F'), - - //! Unknown scene node - ESNT_UNKNOWN = MAKE_IRR_ID('u','n','k','n'), - - //! Will match with any scene node when checking types - ESNT_ANY = MAKE_IRR_ID('a','n','y','_') - }; - - - -} // end namespace scene -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/include/ETerrainElements.h b/irrlicht-1.6/include/ETerrainElements.h deleted file mode 100644 index b71b51507..000000000 --- a/irrlicht-1.6/include/ETerrainElements.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __E_TERRAIN_ELEMENTS_H__ -#define __E_TERRAIN_ELEMENTS_H__ - -namespace irr -{ -namespace scene -{ - - //! enumeration for patch sizes specifying the size of patches in the TerrainSceneNode - enum E_TERRAIN_PATCH_SIZE - { - //! patch size of 9, at most, use 4 levels of detail with this patch size. - ETPS_9 = 9, - - //! patch size of 17, at most, use 5 levels of detail with this patch size. - ETPS_17 = 17, - - //! patch size of 33, at most, use 6 levels of detail with this patch size. - ETPS_33 = 33, - - //! patch size of 65, at most, use 7 levels of detail with this patch size. - ETPS_65 = 65, - - //! patch size of 129, at most, use 8 levels of detail with this patch size. - ETPS_129 = 129 - }; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IAnimatedMesh.h b/irrlicht-1.6/include/IAnimatedMesh.h deleted file mode 100644 index dc6070020..000000000 --- a/irrlicht-1.6/include/IAnimatedMesh.h +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_ANIMATED_MESH_H_INCLUDED__ -#define __I_ANIMATED_MESH_H_INCLUDED__ - -#include "aabbox3d.h" -#include "IMesh.h" - -namespace irr -{ -namespace scene -{ - //! Possible types of (animated) meshes. - enum E_ANIMATED_MESH_TYPE - { - //! Unknown animated mesh type. - EAMT_UNKNOWN = 0, - - //! Quake 2 MD2 model file - EAMT_MD2, - - //! Quake 3 MD3 model file - EAMT_MD3, - - //! Maya .obj static model - EAMT_OBJ, - - //! Quake 3 .bsp static Map - EAMT_BSP, - - //! 3D Studio .3ds file - EAMT_3DS, - - //! My3D Mesh, the file format by Zhuck Dimitry - EAMT_MY3D, - - //! Pulsar LMTools .lmts file. This Irrlicht loader was written by Jonas Petersen - EAMT_LMTS, - - //! Cartography Shop .csm file. This loader was created by Saurav Mohapatra. - EAMT_CSM, - - //! .oct file for Paul Nette's FSRad or from Murphy McCauley's Blender .oct exporter. - /** The oct file format contains 3D geometry and lightmaps and - can be loaded directly by Irrlicht */ - EAMT_OCT, - - //! generic skinned mesh - EAMT_SKINNED - }; - - //! Interface for an animated mesh. - /** There are already simple implementations of this interface available so - you don't have to implement this interface on your own if you need to: - You might want to use irr::scene::SAnimatedMesh, irr::scene::SMesh, - irr::scene::SMeshBuffer etc. */ - class IAnimatedMesh : public IMesh - { - public: - - //! Gets the frame count of the animated mesh. - /** \return Returns the amount of frames. If the amount is 1, - it is a static, non animated mesh. */ - virtual u32 getFrameCount() const = 0; - - //! Returns the IMesh interface for a frame. - /** \param frame: Frame number as zero based index. The maximum - frame number is getFrameCount() - 1; - \param detailLevel: Level of detail. 0 is the lowest, 255 the - highest level of detail. Most meshes will ignore the detail level. - \param startFrameLoop: Because some animated meshes (.MD2) are - blended between 2 static frames, and maybe animated in a loop, - the startFrameLoop and the endFrameLoop have to be defined, to - prevent the animation to be blended between frames which are - outside of this loop. - If startFrameLoop and endFrameLoop are both -1, they are ignored. - \param endFrameLoop: see startFrameLoop. - \return Returns the animated mesh based on a detail level. */ - virtual IMesh* getMesh(s32 frame, s32 detailLevel=255, s32 startFrameLoop=-1, s32 endFrameLoop=-1) = 0; - - //! Returns the type of the animated mesh. - /** In most cases it is not neccessary to use this method. - This is useful for making a safe downcast. For example, - if getMeshType() returns EAMT_MD2 it's safe to cast the - IAnimatedMesh to IAnimatedMeshMD2. - \returns Type of the mesh. */ - virtual E_ANIMATED_MESH_TYPE getMeshType() const - { - return EAMT_UNKNOWN; - } - }; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IAnimatedMeshMD2.h b/irrlicht-1.6/include/IAnimatedMeshMD2.h deleted file mode 100644 index 692a8c50f..000000000 --- a/irrlicht-1.6/include/IAnimatedMeshMD2.h +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_ANIMATED_MESH_MD2_H_INCLUDED__ -#define __I_ANIMATED_MESH_MD2_H_INCLUDED__ - -#include "IAnimatedMesh.h" - -namespace irr -{ -namespace scene -{ - - //! Types of standard md2 animations - enum EMD2_ANIMATION_TYPE - { - EMAT_STAND = 0, - EMAT_RUN, - EMAT_ATTACK, - EMAT_PAIN_A, - EMAT_PAIN_B, - EMAT_PAIN_C, - EMAT_JUMP, - EMAT_FLIP, - EMAT_SALUTE, - EMAT_FALLBACK, - EMAT_WAVE, - EMAT_POINT, - EMAT_CROUCH_STAND, - EMAT_CROUCH_WALK, - EMAT_CROUCH_ATTACK, - EMAT_CROUCH_PAIN, - EMAT_CROUCH_DEATH, - EMAT_DEATH_FALLBACK, - EMAT_DEATH_FALLFORWARD, - EMAT_DEATH_FALLBACKSLOW, - EMAT_BOOM, - - //! Not an animation, but amount of animation types. - EMAT_COUNT - }; - - //! Interface for using some special functions of MD2 meshes - class IAnimatedMeshMD2 : public IAnimatedMesh - { - public: - - //! Get frame loop data for a default MD2 animation type. - /** \param l The EMD2_ANIMATION_TYPE to get the frames for. - \param outBegin The returned beginning frame for animation type specified. - \param outEnd The returned ending frame for the animation type specified. - \param outFPS The number of frames per second, this animation should be played at. - \return beginframe, endframe and frames per second for a default MD2 animation type. */ - virtual void getFrameLoop(EMD2_ANIMATION_TYPE l, s32& outBegin, - s32& outEnd, s32& outFPS) const = 0; - - //! Get frame loop data for a special MD2 animation type, identified by name. - /** \param name Name of the animation. - \param outBegin The returned beginning frame for animation type specified. - \param outEnd The returned ending frame for the animation type specified. - \param outFPS The number of frames per second, this animation should be played at. - \return beginframe, endframe and frames per second for a special MD2 animation type. */ - virtual bool getFrameLoop(const c8* name, - s32& outBegin, s32& outEnd, s32& outFPS) const = 0; - - //! Get amount of md2 animations in this file. - virtual s32 getAnimationCount() const = 0; - - //! Get name of md2 animation. - /** \param nr: Zero based index of animation. */ - virtual const c8* getAnimationName(s32 nr) const = 0; - }; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IAnimatedMeshMD3.h b/irrlicht-1.6/include/IAnimatedMeshMD3.h deleted file mode 100644 index 8aa3ba93b..000000000 --- a/irrlicht-1.6/include/IAnimatedMeshMD3.h +++ /dev/null @@ -1,320 +0,0 @@ -// Copyright (C) 2007-2009 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_ANIMATED_MESH_MD3_H_INCLUDED__ -#define __I_ANIMATED_MESH_MD3_H_INCLUDED__ - -#include "IAnimatedMesh.h" -#include "IQ3Shader.h" -#include "quaternion.h" - -namespace irr -{ -namespace scene -{ - - enum eMD3Models - { - EMD3_HEAD = 0, - EMD3_UPPER, - EMD3_LOWER, - EMD3_WEAPON, - EMD3_NUMMODELS - }; - - //! Animation list - enum EMD3_ANIMATION_TYPE - { - // Animations for both lower and upper parts of the player - EMD3_BOTH_DEATH_1 = 0, - EMD3_BOTH_DEAD_1, - EMD3_BOTH_DEATH_2, - EMD3_BOTH_DEAD_2, - EMD3_BOTH_DEATH_3, - EMD3_BOTH_DEAD_3, - - // Animations for the upper part - EMD3_TORSO_GESTURE, - EMD3_TORSO_ATTACK_1, - EMD3_TORSO_ATTACK_2, - EMD3_TORSO_DROP, - EMD3_TORSO_RAISE, - EMD3_TORSO_STAND_1, - EMD3_TORSO_STAND_2, - - // Animations for the lower part - EMD3_LEGS_WALK_CROUCH, - EMD3_LEGS_WALK, - EMD3_LEGS_RUN, - EMD3_LEGS_BACK, - EMD3_LEGS_SWIM, - EMD3_LEGS_JUMP_1, - EMD3_LEGS_LAND_1, - EMD3_LEGS_JUMP_2, - EMD3_LEGS_LAND_2, - EMD3_LEGS_IDLE, - EMD3_LEGS_IDLE_CROUCH, - EMD3_LEGS_TURN, - - //! Not an animation, but amount of animation types. - EMD3_ANIMATION_COUNT - }; - - struct SMD3AnimationInfo - { - //! First frame - s32 first; - //! Last frame - s32 num; - //! Looping frames - s32 looping; - //! Frames per second - s32 fps; - }; - - -// byte-align structures -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) -# pragma pack( push, packing ) -# pragma pack( 1 ) -# define PACK_STRUCT -#elif defined( __GNUC__ ) -# define PACK_STRUCT __attribute__((packed)) -#else -# error compiler not supported -#endif - - //! this holds the header info of the MD3 file - struct SMD3Header - { - c8 headerID[4]; //id of file, always "IDP3" - s32 Version; //this is a version number, always 15 - s8 fileName[68]; //sometimes left Blank... 65 chars, 32bit aligned == 68 chars - s32 numFrames; //number of KeyFrames - s32 numTags; //number of 'tags' per frame - s32 numMeshes; //number of meshes/skins - s32 numMaxSkins; //maximum number of unique skins used in md3 file. artefact md2 - s32 frameStart; //starting position of frame-structur - s32 tagStart; //starting position of tag-structures - s32 tagEnd; //ending position of tag-structures/starting position of mesh-structures - s32 fileSize; - }; - - //! this holds the header info of an MD3 mesh section - struct SMD3MeshHeader - { - c8 meshID[4]; //id, must be IDP3 - c8 meshName[68]; //name of mesh 65 chars, 32 bit aligned == 68 chars - - s32 numFrames; //number of meshframes in mesh - s32 numShader; //number of skins in mesh - s32 numVertices; //number of vertices - s32 numTriangles; //number of Triangles - - s32 offset_triangles; //starting position of Triangle data, relative to start of Mesh_Header - s32 offset_shaders; //size of header - s32 offset_st; //starting position of texvector data, relative to start of Mesh_Header - s32 vertexStart; //starting position of vertex data,relative to start of Mesh_Header - s32 offset_end; - }; - - - //! Compressed Vertex Data - struct SMD3Vertex - { - s16 position[3]; - u8 normal[2]; - }; - - //! Texture Coordinate - struct SMD3TexCoord - { - f32 u; - f32 v; - }; - - //! Triangle Index - struct SMD3Face - { - s32 Index[3]; - }; - - -// Default alignment -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) -# pragma pack( pop, packing ) -#endif - -#undef PACK_STRUCT - - //! Holding Frame Data for a Mesh - struct SMD3MeshBuffer : public IReferenceCounted - { - SMD3MeshHeader MeshHeader; - - core::stringc Shader; - core::array < s32 > Indices; - core::array < SMD3Vertex > Vertices; - core::array < SMD3TexCoord > Tex; - }; - - //! hold a tag info for connecting meshes - /** Basically its an alternate way to describe a transformation. */ - struct SMD3QuaternionTag - { - virtual ~SMD3QuaternionTag() - { - position.X = 0.f; - } - - // construct copy constructor - SMD3QuaternionTag( const SMD3QuaternionTag & copyMe ) - { - *this = copyMe; - } - - // construct for searching - SMD3QuaternionTag( const core::stringc& name ) - : Name ( name ) {} - - // construct from a matrix - SMD3QuaternionTag ( const core::stringc& name, const core::matrix4 &m ) - : Name(name), position(m.getTranslation()), rotation(m) {} - - // construct from a position and euler angles in degrees - SMD3QuaternionTag ( const core::vector3df &pos, const core::vector3df &angle ) - : position(pos), rotation(angle * core::DEGTORAD) {} - - // set to matrix - void setto ( core::matrix4 &m ) - { - rotation.getMatrix ( m, position ); - } - - bool operator == ( const SMD3QuaternionTag &other ) const - { - return Name == other.Name; - } - - SMD3QuaternionTag & operator=( const SMD3QuaternionTag & copyMe ) - { - Name = copyMe.Name; - position = copyMe.position; - rotation = copyMe.rotation; - return *this; - } - - core::stringc Name; - core::vector3df position; - core::quaternion rotation; - }; - - //! holds a associative list of named quaternions - struct SMD3QuaternionTagList - { - SMD3QuaternionTagList () - { - Container.setAllocStrategy ( core::ALLOC_STRATEGY_SAFE ); - } - - // construct copy constructor - SMD3QuaternionTagList( const SMD3QuaternionTagList & copyMe ) - { - *this = copyMe; - } - - virtual ~SMD3QuaternionTagList () {} - - SMD3QuaternionTag* get ( const core::stringc& name ) - { - SMD3QuaternionTag search ( name ); - s32 index = Container.linear_search ( search ); - if ( index >= 0 ) - return &Container[index]; - return 0; - } - - u32 size () const - { - return Container.size(); - } - - void set_used ( u32 new_size) - { - s32 diff = (s32) new_size - (s32) Container.allocated_size (); - if ( diff > 0 ) - { - SMD3QuaternionTag e ( "" ); - for ( s32 i = 0; i < diff; ++i ) - Container.push_back ( e ); - } - } - - const SMD3QuaternionTag& operator[](u32 index) const - { - return Container[index]; - } - - SMD3QuaternionTag& operator[](u32 index) - { - return Container[index]; - } - - void push_back ( const SMD3QuaternionTag& other ) - { - Container.push_back ( other ); - } - - SMD3QuaternionTagList& operator = (const SMD3QuaternionTagList & copyMe) - { - Container = copyMe.Container; - return *this; - } - - private: - core::array < SMD3QuaternionTag > Container; - }; - - - //! Holding Frames Buffers and Tag Infos - struct SMD3Mesh: public IReferenceCounted - { - SMD3Mesh () - { - MD3Header.numFrames = 0; - } - - virtual ~SMD3Mesh() - { - for (u32 i=0; i<Buffer.size(); ++i) - Buffer[i]->drop(); - } - - core::stringc Name; - core::array < SMD3MeshBuffer * > Buffer; - SMD3QuaternionTagList TagList; - SMD3Header MD3Header; - }; - - - //! Interface for using some special functions of MD3 meshes - class IAnimatedMeshMD3 : public IAnimatedMesh - { - public: - - //! tune how many frames you want to render inbetween. - virtual void setInterpolationShift ( u32 shift, u32 loopMode ) = 0; - - //! get the tag list of the mesh. - virtual SMD3QuaternionTagList *getTagList(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop) = 0; - - //! get the original md3 mesh. - virtual SMD3Mesh * getOriginalMesh () = 0; - }; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IAnimatedMeshSceneNode.h b/irrlicht-1.6/include/IAnimatedMeshSceneNode.h deleted file mode 100644 index a1e024ad1..000000000 --- a/irrlicht-1.6/include/IAnimatedMeshSceneNode.h +++ /dev/null @@ -1,227 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_ANIMATED_MESH_SCENE_NODE_H_INCLUDED__ -#define __I_ANIMATED_MESH_SCENE_NODE_H_INCLUDED__ - -#include "ISceneNode.h" -#include "IBoneSceneNode.h" -#include "IAnimatedMeshMD2.h" -#include "IAnimatedMeshMD3.h" - -namespace irr -{ -namespace scene -{ - class IShadowVolumeSceneNode; - - enum E_JOINT_UPDATE_ON_RENDER - { - //! do nothing - EJUOR_NONE = 0, - - //! get joints positions from the mesh (for attached nodes, etc) - EJUOR_READ, - - //! control joint positions in the mesh (eg. ragdolls, or set the animation from animateJoints() ) - EJUOR_CONTROL, - - //! count of all available interpolation modes - EJUOR_COUNT - }; - - - class IAnimatedMeshSceneNode; - - //! Callback interface for catching events of ended animations. - /** Implement this interface and use - IAnimatedMeshSceneNode::setAnimationEndCallback to be able to - be notified if an animation playback has ended. - **/ - class IAnimationEndCallBack : public virtual IReferenceCounted - { - public: - - //! Will be called when the animation playback has ended. - /** See IAnimatedMeshSceneNode::setAnimationEndCallback for - more informations. - \param node: Node of which the animation has ended. */ - virtual void OnAnimationEnd(IAnimatedMeshSceneNode* node) = 0; - }; - - //! Scene node capable of displaying an animated mesh and its shadow. - /** The shadow is optional: If a shadow should be displayed too, just - invoke the IAnimatedMeshSceneNode::createShadowVolumeSceneNode().*/ - class IAnimatedMeshSceneNode : public ISceneNode - { - public: - - //! Constructor - IAnimatedMeshSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)) - : ISceneNode(parent, mgr, id, position, rotation, scale) {} - - //! Destructor - virtual ~IAnimatedMeshSceneNode() {} - - //! Sets the current frame number. - /** From now on the animation is played from this frame. - \param frame: Number of the frame to let the animation be started from. - The frame number must be a valid frame number of the IMesh used by this - scene node. Set IAnimatedMesh::getMesh() for details. */ - virtual void setCurrentFrame(f32 frame) = 0; - - //! Sets the frame numbers between the animation is looped. - /** The default is 0 - MaximalFrameCount of the mesh. - \param begin: Start frame number of the loop. - \param end: End frame number of the loop. - \return True if successful, false if not. */ - virtual bool setFrameLoop(s32 begin, s32 end) = 0; - - //! Sets the speed with witch the animation is played. - /** \param framesPerSecond: Frames per second played. */ - virtual void setAnimationSpeed(f32 framesPerSecond) = 0; - - //! Creates shadow volume scene node as child of this node. - /** The shadow can be rendered using the ZPass or the zfail - method. ZPass is a little bit faster because the shadow volume - creation is easier, but with this method there occur ugly - looking artifacs when the camera is inside the shadow volume. - These error do not occur with the ZFail method. - \param shadowMesh: Optional custom mesh for shadow volume. - \param id: Id of the shadow scene node. This id can be used to - identify the node later. - \param zfailmethod: If set to true, the shadow will use the - zfail method, if not, zpass is used. - \param infinity: Value used by the shadow volume algorithm to - scale the shadow volume. - \return Pointer to the created shadow scene node. This pointer - should not be dropped. See IReferenceCounted::drop() for more - information. */ - virtual IShadowVolumeSceneNode* addShadowVolumeSceneNode(const IMesh* shadowMesh=0, - s32 id=-1, bool zfailmethod=true, f32 infinity=10000.0f) = 0; - - - //! Get a pointer to a joint in the mesh (if the mesh is a bone based mesh). - /** With this method it is possible to attach scene nodes to - joints for example possible to attach a weapon to the left hand - of an animated model. This example shows how: - \code - ISceneNode* hand = - yourAnimatedMeshSceneNode->getJointNode("LeftHand"); - hand->addChild(weaponSceneNode); - \endcode - Please note that the joint returned by this method may not exist - before this call and the joints in the node were created by it. - \param jointName: Name of the joint. - \return Pointer to the scene node which represents the joint - with the specified name. Returns 0 if the contained mesh is not - an skinned mesh or the name of the joint could not be found. */ - virtual IBoneSceneNode* getJointNode(const c8* jointName)=0; - - //! same as getJointNode(const c8* jointName), but based on id - virtual IBoneSceneNode* getJointNode(u32 jointID) = 0; - - //! Gets joint count. - /** \return Amount of joints in the mesh. */ - virtual u32 getJointCount() const = 0; - - //! Deprecated command, please use getJointNode - virtual ISceneNode* getMS3DJointNode(const c8* jointName) = 0; - - //! Deprecated command, please use getJointNode - virtual ISceneNode* getXJointNode(const c8* jointName) = 0; - - //! Starts a default MD2 animation. - /** With this method it is easily possible to start a Run, - Attack, Die or whatever animation, if the mesh contained in - this scene node is an md2 mesh. Otherwise, nothing happens. - \param anim: An MD2 animation type, which should be played, for - example EMAT_STAND for the standing animation. - \return True if successful, and false if not, for example if - the mesh in the scene node is not a md2 mesh. */ - virtual bool setMD2Animation(EMD2_ANIMATION_TYPE anim) = 0; - - //! Starts a special MD2 animation. - /** With this method it is easily possible to start a Run, - Attack, Die or whatever animation, if the mesh contained in - this scene node is an md2 mesh. Otherwise, nothing happens. - This method uses a character string to identify the animation. - If the animation is a standard md2 animation, you might want to - start this animation with the EMD2_ANIMATION_TYPE enumeration - instead. - \param animationName: Name of the animation which should be - played. - \return Returns true if successful, and false if not, for - example if the mesh in the scene node is not an md2 mesh, or no - animation with this name could be found. */ - virtual bool setMD2Animation(const c8* animationName) = 0; - - //! Returns the current displayed frame number. - virtual f32 getFrameNr() const = 0; - //! Returns the current start frame number. - virtual s32 getStartFrame() const = 0; - //! Returns the current end frame number. - virtual s32 getEndFrame() const = 0; - - //! Sets looping mode which is on by default. - /** If set to false, animations will not be played looped. */ - virtual void setLoopMode(bool playAnimationLooped) = 0; - - //! Sets a callback interface which will be called if an animation playback has ended. - /** Set this to 0 to disable the callback again. - Please note that this will only be called when in non looped - mode, see IAnimatedMeshSceneNode::setLoopMode(). */ - virtual void setAnimationEndCallback(IAnimationEndCallBack* callback=0) = 0; - - //! Sets if the scene node should not copy the materials of the mesh but use them in a read only style. - /* In this way it is possible to change the materials a mesh - causing all mesh scene nodes referencing this mesh to change - too. */ - virtual void setReadOnlyMaterials(bool readonly) = 0; - - //! Returns if the scene node should not copy the materials of the mesh but use them in a read only style - virtual bool isReadOnlyMaterials() const = 0; - - //! Sets a new mesh - virtual void setMesh(IAnimatedMesh* mesh) = 0; - - //! Returns the current mesh - virtual IAnimatedMesh* getMesh(void) = 0; - - //! Get the absolute transformation for a special MD3 Tag if the mesh is a md3 mesh, or the absolutetransformation if it's a normal scenenode - virtual const SMD3QuaternionTag* getMD3TagTransformation( const core::stringc & tagname) = 0; - - //! Set how the joints should be updated on render - virtual void setJointMode(E_JOINT_UPDATE_ON_RENDER mode)=0; - - //! Sets the transition time in seconds - /** Note: This needs to enable joints, and setJointmode set to - EJUOR_CONTROL. You must call animateJoints(), or the mesh will - not animate. */ - virtual void setTransitionTime(f32 Time) =0; - - //! animates the joints in the mesh based on the current frame. - /** Also takes in to account transitions. */ - virtual void animateJoints(bool CalculateAbsolutePositions=true) = 0; - - //! render mesh ignoring its transformation. - /** Used with ragdolls. Culling is unaffected. */ - virtual void setRenderFromIdentity( bool On )=0; - - //! Creates a clone of this scene node and its children. - /** \param newParent An optional new parent. - \param newManager An optional new scene manager. - \return The newly created clone of this node. */ - virtual ISceneNode* clone(ISceneNode* newParent=0, ISceneManager* newManager=0) = 0; - - }; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IAttributeExchangingObject.h b/irrlicht-1.6/include/IAttributeExchangingObject.h deleted file mode 100644 index 0f90e9fc0..000000000 --- a/irrlicht-1.6/include/IAttributeExchangingObject.h +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_ATTRIBUTE_EXCHANGING_OBJECT_H_INCLUDED__ -#define __I_ATTRIBUTE_EXCHANGING_OBJECT_H_INCLUDED__ - -#include "IReferenceCounted.h" - - -namespace irr -{ - -namespace io -{ - -class IAttributes; - -//! Enumeration flags passed through SAttributeReadWriteOptions to the IAttributeExchangingObject object -enum E_ATTRIBUTE_READ_WRITE_FLAGS -{ - //! Serialization/Deserializion is done for an xml file - EARWF_FOR_FILE = 0x00000001, - - //! Serialization/Deserializion is done for an editor property box - EARWF_FOR_EDITOR = 0x00000002, - - //! When writing filenames, relative paths should be used - EARWF_USE_RELATIVE_PATHS = 0x00000004 -}; - - -//! struct holding data describing options -struct SAttributeReadWriteOptions -{ - //! Constructor - SAttributeReadWriteOptions() - : Flags(0), Filename(0) - { - } - - //! Combination of E_ATTRIBUTE_READ_WRITE_FLAGS or other, custom ones - s32 Flags; - - //! Optional filename - const c8* Filename; -}; - - -//! An object which is able to serialize and deserialize its attributes into an attributes object -class IAttributeExchangingObject : virtual public IReferenceCounted -{ -public: - - //! Writes attributes of the object. - /** Implement this to expose the attributes of your scene node animator for - scripting languages, editors, debuggers or xml serialization purposes. */ - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const {} - - //! Reads attributes of the object. - /** Implement this to set the attributes of your scene node animator for - scripting languages, editors, debuggers or xml deserialization purposes. */ - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) {} - -}; - -} // end namespace io -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IAttributes.h b/irrlicht-1.6/include/IAttributes.h deleted file mode 100644 index b0a616fbd..000000000 --- a/irrlicht-1.6/include/IAttributes.h +++ /dev/null @@ -1,768 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_ATTRIBUTES_H_INCLUDED__ -#define __I_ATTRIBUTES_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "SColor.h" -#include "vector3d.h" -#include "vector2d.h" -#include "line2d.h" -#include "line3d.h" -#include "triangle3d.h" -#include "position2d.h" -#include "rect.h" -#include "matrix4.h" -#include "quaternion.h" -#include "plane3d.h" -#include "triangle3d.h" -#include "line2d.h" -#include "line3d.h" -#include "irrString.h" -#include "irrArray.h" -#include "IXMLReader.h" - -namespace irr -{ -namespace video -{ - class ITexture; -} // end namespace video -namespace io -{ - class IXMLWriter; - -//! Types of attributes available for IAttributes -enum E_ATTRIBUTE_TYPE -{ - // integer attribute - EAT_INT = 0, - - // float attribute - EAT_FLOAT, - - // string attribute - EAT_STRING, - - // boolean attribute - EAT_BOOL, - - // enumeration attribute - EAT_ENUM, - - // color attribute - EAT_COLOR, - - // floating point color attribute - EAT_COLORF, - - // 3d vector attribute - EAT_VECTOR3D, - - // 2d position attribute - EAT_POSITION2D, - - // vector 2d - EAT_VECTOR2D, - - // rectangle attribute - EAT_RECT, - - // matrix attribute - EAT_MATRIX, - - // quaternion attribute - EAT_QUATERNION, - - // 3d bounding box - EAT_BBOX, - - // plane - EAT_PLANE, - - // 3d triangle - EAT_TRIANGLE3D, - - // line 2d - EAT_LINE2D, - - // line 3d - EAT_LINE3D, - - // array of stringws attribute - EAT_STRINGWARRAY, - - // array of float - EAT_FLOATARRAY, - - // array of int - EAT_INTARRAY, - - // binary data attribute - EAT_BINARY, - - // texture reference attribute - EAT_TEXTURE, - - // user pointer void* - EAT_USER_POINTER, - - // known attribute type count - EAT_COUNT, - - // unknown attribute - EAT_UNKNOWN -}; - -//! Provides a generic interface for attributes and their values and the possiblity to serialize them -class IAttributes : public virtual IReferenceCounted -{ -public: - - //! Returns amount of attributes in this collection of attributes. - virtual u32 getAttributeCount() const = 0; - - //! Returns attribute name by index. - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual const c8* getAttributeName(s32 index) = 0; - - //! Returns the type of an attribute - //! \param attributeName: Name for the attribute - virtual E_ATTRIBUTE_TYPE getAttributeType(const c8* attributeName) = 0; - - //! Returns attribute type by index. - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual E_ATTRIBUTE_TYPE getAttributeType(s32 index) = 0; - - //! Returns the type string of the attribute - //! \param attributeName: String for the attribute type - virtual const wchar_t* getAttributeTypeString(const c8* attributeName) = 0; - - //! Returns the type string of the attribute by index. - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual const wchar_t* getAttributeTypeString(s32 index) = 0; - - //! Returns if an attribute with a name exists - virtual bool existsAttribute(const c8* attributeName) = 0; - - //! Returns attribute index from name, -1 if not found - virtual s32 findAttribute(const c8* attributeName) = 0; - - //! Removes all attributes - virtual void clear() = 0; - - //! Reads attributes from a xml file. - //! \param reader The XML reader to read from - //! \param readCurrentElementOnly If set to true, reading only works if current element has the name 'attributes' or - //! 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(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 - //! \param writeXMLHeader: Writes a header to the XML file, required if at the beginning of the file - //! \param elementName: The surrounding element name. If it is null, the default one, "attributes" will be taken. - virtual bool write(io::IXMLWriter* writer, bool writeXMLHeader=false, const wchar_t* elementName=0) = 0; - - - /* - - Integer Attribute - - */ - - //! Adds an attribute as integer - virtual void addInt(const c8* attributeName, s32 value) = 0; - - //! Sets an attribute as integer value - virtual void setAttribute(const c8* attributeName, s32 value) = 0; - - //! Gets an attribute as integer value - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual s32 getAttributeAsInt(const c8* attributeName) = 0; - - //! Gets an attribute as integer value - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual s32 getAttributeAsInt(s32 index) = 0; - - //! Sets an attribute as integer value - virtual void setAttribute(s32 index, s32 value) = 0; - - /* - - Float Attribute - - */ - - //! Adds an attribute as float - virtual void addFloat(const c8* attributeName, f32 value) = 0; - - //! Sets a attribute as float value - virtual void setAttribute(const c8* attributeName, f32 value) = 0; - - //! Gets an attribute as float value - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual f32 getAttributeAsFloat(const c8* attributeName) = 0; - - //! Gets an attribute as float value - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual f32 getAttributeAsFloat(s32 index) = 0; - - //! Sets an attribute as float value - virtual void setAttribute(s32 index, f32 value) = 0; - - /* - - String Attribute - - */ - - //! Adds an attribute as string - virtual void addString(const c8* attributeName, const c8* value) = 0; - - //! Sets an attribute value as string. - //! \param attributeName: Name for the attribute - //! \param value: Value for the attribute. Set this to 0 to delete the attribute - virtual void setAttribute(const c8* attributeName, const c8* value) = 0; - - //! Gets an attribute as string. - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - //! or 0 if attribute is not set. - virtual core::stringc getAttributeAsString(const c8* attributeName) = 0; - - //! Gets an attribute as string. - //! \param attributeName Name of the attribute to get. - //! \param target Buffer where the string is copied to. - virtual void getAttributeAsString(const c8* attributeName, c8* target) = 0; - - //! Returns attribute value as string by index. - //! \param index Index value, must be between 0 and getAttributeCount()-1. - virtual core::stringc getAttributeAsString(s32 index) = 0; - - //! Sets an attribute value as string. - //! \param index Index value, must be between 0 and getAttributeCount()-1. - //! \param value String to which the attribute is set. - virtual void setAttribute(s32 index, const c8* value) = 0; - - // wide strings - - //! Adds an attribute as string - virtual void addString(const c8* attributeName, const wchar_t* value) = 0; - - //! Sets an attribute value as string. - //! \param attributeName: Name for the attribute - //! \param value: Value for the attribute. Set this to 0 to delete the attribute - virtual void setAttribute(const c8* attributeName, const wchar_t* value) = 0; - - //! Gets an attribute as string. - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - //! or 0 if attribute is not set. - virtual core::stringw getAttributeAsStringW(const c8* attributeName) = 0; - - //! Gets an attribute as string. - //! \param attributeName: Name of the attribute to get. - //! \param target: Buffer where the string is copied to. - virtual void getAttributeAsStringW(const c8* attributeName, wchar_t* target) = 0; - - //! Returns attribute value as string by index. - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::stringw getAttributeAsStringW(s32 index) = 0; - - //! Sets an attribute value as string. - //! \param index Index value, must be between 0 and getAttributeCount()-1. - //! \param value String to which the attribute is set. - virtual void setAttribute(s32 index, const wchar_t* value) = 0; - - /* - - Binary Data Attribute - - */ - - //! Adds an attribute as binary data - virtual void addBinary(const c8* attributeName, void* data, s32 dataSizeInBytes) = 0; - - //! Sets an attribute as binary data - virtual void setAttribute(const c8* attributeName, void* data, s32 dataSizeInBytes ) = 0; - - //! Gets an attribute as binary data - /** \param attributeName: Name of the attribute to get. - \param outData Pointer to buffer where data shall be stored. - \param maxSizeInBytes Maximum number of bytes to write into outData. - */ - virtual void getAttributeAsBinaryData(const c8* attributeName, void* outData, s32 maxSizeInBytes) = 0; - - //! Gets an attribute as binary data - /** \param index: Index value, must be between 0 and getAttributeCount()-1. - \param outData Pointer to buffer where data shall be stored. - \param maxSizeInBytes Maximum number of bytes to write into outData. - */ - virtual void getAttributeAsBinaryData(s32 index, void* outData, s32 maxSizeInBytes) = 0; - - //! Sets an attribute as binary data - virtual void setAttribute(s32 index, void* data, s32 dataSizeInBytes ) = 0; - - - /* - Array Attribute - */ - - //! Adds an attribute as wide string array - virtual void addArray(const c8* attributeName, core::array<core::stringw> value) = 0; - - //! Sets an attribute value as a wide string array. - //! \param attributeName: Name for the attribute - //! \param value: Value for the attribute. Set this to 0 to delete the attribute - virtual void setAttribute(const c8* attributeName, const core::array<core::stringw> value) = 0; - - //! Gets an attribute as an array of wide strings. - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - //! or 0 if attribute is not set. - virtual core::array<core::stringw> getAttributeAsArray(const c8* attributeName) = 0; - - //! Returns attribute value as an array of wide strings by index. - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::array<core::stringw> getAttributeAsArray(s32 index) = 0; - - //! Sets an attribute as an array of wide strings - virtual void setAttribute(s32 index, core::array<core::stringw> value) = 0; - - - /* - - Bool Attribute - - */ - - //! Adds an attribute as bool - virtual void addBool(const c8* attributeName, bool value) = 0; - - //! Sets an attribute as boolean value - virtual void setAttribute(const c8* attributeName, bool value) = 0; - - //! Gets an attribute as boolean value - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual bool getAttributeAsBool(const c8* attributeName) = 0; - - //! Gets an attribute as boolean value - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual bool getAttributeAsBool(s32 index) = 0; - - //! Sets an attribute as boolean value - virtual void setAttribute(s32 index, bool value) = 0; - - /* - - Enumeration Attribute - - */ - - //! Adds an attribute as enum - virtual void addEnum(const c8* attributeName, const c8* enumValue, const c8* const* enumerationLiterals) = 0; - - //! Adds an attribute as enum - virtual void addEnum(const c8* attributeName, s32 enumValue, const c8* const* enumerationLiterals) = 0; - - //! Sets an attribute as enumeration - virtual void setAttribute(const c8* attributeName, const c8* enumValue, const c8* const* enumerationLiterals) = 0; - - //! Gets an attribute as enumeration - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual const c8* getAttributeAsEnumeration(const c8* attributeName) = 0; - - //! Gets an attribute as enumeration - /** \param attributeName: Name of the attribute to get. - \param enumerationLiteralsToUse: Use these enumeration literals to get - the index value instead of the set ones. This is useful when the - attribute list maybe was read from an xml file, and only contains the - enumeration string, but no information about its index. - \return Returns value of the attribute previously set by setAttribute() - */ - virtual s32 getAttributeAsEnumeration(const c8* attributeName, const c8* const* enumerationLiteralsToUse) = 0; - - //! Gets an attribute as enumeration - /** \param index: Index value, must be between 0 and getAttributeCount()-1. - \param enumerationLiteralsToUse: Use these enumeration literals to get - the index value instead of the set ones. This is useful when the - attribute list maybe was read from an xml file, and only contains the - enumeration string, but no information about its index. - \return Returns value of the attribute previously set by setAttribute() - */ - virtual s32 getAttributeAsEnumeration(s32 index, const c8* const* enumerationLiteralsToUse) = 0; - - //! Gets an attribute as enumeration - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual const c8* getAttributeAsEnumeration(s32 index) = 0; - - //! Gets the list of enumeration literals of an enumeration attribute - //! \param attributeName Name of the attribute to get. - //! \param outLiterals Set of strings to choose the enum name from. - virtual void getAttributeEnumerationLiteralsOfEnumeration(const c8* attributeName, core::array<core::stringc>& outLiterals) = 0; - - //! Gets the list of enumeration literals of an enumeration attribute - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - //! \param outLiterals Set of strings to choose the enum name from. - virtual void getAttributeEnumerationLiteralsOfEnumeration(s32 index, core::array<core::stringc>& outLiterals) = 0; - - //! Sets an attribute as enumeration - virtual void setAttribute(s32 index, const c8* enumValue, const c8* const* enumerationLiterals) = 0; - - - /* - - SColor Attribute - - */ - - //! Adds an attribute as color - virtual void addColor(const c8* attributeName, video::SColor value) = 0; - - - //! Sets a attribute as color - virtual void setAttribute(const c8* attributeName, video::SColor color) = 0; - - //! Gets an attribute as color - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual video::SColor getAttributeAsColor(const c8* attributeName) = 0; - - //! Gets an attribute as color - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual video::SColor getAttributeAsColor(s32 index) = 0; - - //! Sets an attribute as color - virtual void setAttribute(s32 index, video::SColor color) = 0; - - /* - - SColorf Attribute - - */ - - //! Adds an attribute as floating point color - virtual void addColorf(const c8* attributeName, video::SColorf value) = 0; - - //! Sets a attribute as floating point color - virtual void setAttribute(const c8* attributeName, video::SColorf color) = 0; - - //! Gets an attribute as floating point color - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual video::SColorf getAttributeAsColorf(const c8* attributeName) = 0; - - //! Gets an attribute as floating point color - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual video::SColorf getAttributeAsColorf(s32 index) = 0; - - //! Sets an attribute as floating point color - virtual void setAttribute(s32 index, video::SColorf color) = 0; - - - /* - - Vector3d Attribute - - */ - - //! Adds an attribute as 3d vector - virtual void addVector3d(const c8* attributeName, core::vector3df value) = 0; - - //! Sets a attribute as 3d vector - virtual void setAttribute(const c8* attributeName, core::vector3df v) = 0; - - //! Gets an attribute as 3d vector - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::vector3df getAttributeAsVector3d(const c8* attributeName) = 0; - - //! Gets an attribute as 3d vector - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::vector3df getAttributeAsVector3d(s32 index) = 0; - - //! Sets an attribute as vector - virtual void setAttribute(s32 index, core::vector3df v) = 0; - - /* - - Position2d Attribute - - */ - - //! Adds an attribute as 2d position - virtual void addPosition2d(const c8* attributeName, core::position2di value) = 0; - - //! Sets a attribute as 2d position - virtual void setAttribute(const c8* attributeName, core::position2di v) = 0; - - //! Gets an attribute as position - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::position2di getAttributeAsPosition2d(const c8* attributeName) = 0; - - //! Gets an attribute as position - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::position2di getAttributeAsPosition2d(s32 index) = 0; - - //! Sets an attribute as 2d position - virtual void setAttribute(s32 index, core::position2di v) = 0; - - /* - - Rectangle Attribute - - */ - - //! Adds an attribute as rectangle - virtual void addRect(const c8* attributeName, core::rect<s32> value) = 0; - - //! Sets an attribute as rectangle - virtual void setAttribute(const c8* attributeName, core::rect<s32> v) = 0; - - //! Gets an attribute as rectangle - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::rect<s32> getAttributeAsRect(const c8* attributeName) = 0; - - //! Gets an attribute as rectangle - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::rect<s32> getAttributeAsRect(s32 index) = 0; - - //! Sets an attribute as rectangle - virtual void setAttribute(s32 index, core::rect<s32> v) = 0; - - - /* - matrix attribute - */ - - //! Adds an attribute as matrix - virtual void addMatrix(const c8* attributeName, const core::matrix4& v) = 0; - - //! Sets an attribute as matrix - virtual void setAttribute(const c8* attributeName, const core::matrix4& v) = 0; - - //! Gets an attribute as a matrix4 - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::matrix4 getAttributeAsMatrix(const c8* attributeName) = 0; - - //! Gets an attribute as matrix - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::matrix4 getAttributeAsMatrix(s32 index) = 0; - - //! Sets an attribute as matrix - virtual void setAttribute(s32 index, const core::matrix4& v) = 0; - - /* - quaternion attribute - - */ - - //! Adds an attribute as quaternion - virtual void addQuaternion(const c8* attributeName, core::quaternion v) = 0; - - //! Sets an attribute as quaternion - virtual void setAttribute(const c8* attributeName, core::quaternion v) = 0; - - //! Gets an attribute as a quaternion - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::quaternion getAttributeAsQuaternion(const c8* attributeName) = 0; - - //! Gets an attribute as quaternion - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::quaternion getAttributeAsQuaternion(s32 index) = 0; - - //! Sets an attribute as quaternion - virtual void setAttribute(s32 index, core::quaternion v) = 0; - - /* - - 3d bounding box - - */ - - //! Adds an attribute as axis aligned bounding box - virtual void addBox3d(const c8* attributeName, core::aabbox3df v) = 0; - - //! Sets an attribute as axis aligned bounding box - virtual void setAttribute(const c8* attributeName, core::aabbox3df v) = 0; - - //! Gets an attribute as a axis aligned bounding box - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::aabbox3df getAttributeAsBox3d(const c8* attributeName) = 0; - - //! Gets an attribute as axis aligned bounding box - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::aabbox3df getAttributeAsBox3d(s32 index) = 0; - - //! Sets an attribute as axis aligned bounding box - virtual void setAttribute(s32 index, core::aabbox3df v) = 0; - - /* - - plane - - */ - - //! Adds an attribute as 3d plane - virtual void addPlane3d(const c8* attributeName, core::plane3df v) = 0; - - //! Sets an attribute as 3d plane - virtual void setAttribute(const c8* attributeName, core::plane3df v) = 0; - - //! Gets an attribute as a 3d plane - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::plane3df getAttributeAsPlane3d(const c8* attributeName) = 0; - - //! Gets an attribute as 3d plane - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::plane3df getAttributeAsPlane3d(s32 index) = 0; - - //! Sets an attribute as 3d plane - virtual void setAttribute(s32 index, core::plane3df v) = 0; - - - /* - - 3d triangle - - */ - - //! Adds an attribute as 3d triangle - virtual void addTriangle3d(const c8* attributeName, core::triangle3df v) = 0; - - //! Sets an attribute as 3d trianle - virtual void setAttribute(const c8* attributeName, core::triangle3df v) = 0; - - //! Gets an attribute as a 3d triangle - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::triangle3df getAttributeAsTriangle3d(const c8* attributeName) = 0; - - //! Gets an attribute as 3d triangle - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::triangle3df getAttributeAsTriangle3d(s32 index) = 0; - - //! Sets an attribute as 3d triangle - virtual void setAttribute(s32 index, core::triangle3df v) = 0; - - - /* - - line 2d - - */ - - //! Adds an attribute as a 2d line - virtual void addLine2d(const c8* attributeName, core::line2df v) = 0; - - //! Sets an attribute as a 2d line - virtual void setAttribute(const c8* attributeName, core::line2df v) = 0; - - //! Gets an attribute as a 2d line - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::line2df getAttributeAsLine2d(const c8* attributeName) = 0; - - //! Gets an attribute as a 2d line - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::line2df getAttributeAsLine2d(s32 index) = 0; - - //! Sets an attribute as a 2d line - virtual void setAttribute(s32 index, core::line2df v) = 0; - - - /* - - line 3d - - */ - - //! Adds an attribute as a 3d line - virtual void addLine3d(const c8* attributeName, core::line3df v) = 0; - - //! Sets an attribute as a 3d line - virtual void setAttribute(const c8* attributeName, core::line3df v) = 0; - - //! Gets an attribute as a 3d line - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::line3df getAttributeAsLine3d(const c8* attributeName) = 0; - - //! Gets an attribute as a 3d line - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::line3df getAttributeAsLine3d(s32 index) = 0; - - //! Sets an attribute as a 3d line - virtual void setAttribute(s32 index, core::line3df v) = 0; - - - /* - - Texture Attribute - - */ - - //! Adds an attribute as texture reference - virtual void addTexture(const c8* attributeName, video::ITexture* texture) = 0; - - //! Sets an attribute as texture reference - virtual void setAttribute(const c8* attributeName, video::ITexture* texture ) = 0; - - //! Gets an attribute as texture reference - //! \param attributeName: Name of the attribute to get. - virtual video::ITexture* getAttributeAsTexture(const c8* attributeName) = 0; - - //! Gets an attribute as texture reference - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual video::ITexture* getAttributeAsTexture(s32 index) = 0; - - //! Sets an attribute as texture reference - virtual void setAttribute(s32 index, video::ITexture* texture) = 0; - - - /* - - User Pointer Attribute - - */ - - //! Adds an attribute as user pointner - virtual void addUserPointer(const c8* attributeName, void* userPointer) = 0; - - //! Sets an attribute as user pointer - virtual void setAttribute(const c8* attributeName, void* userPointer) = 0; - - //! Gets an attribute as user pointer - //! \param attributeName: Name of the attribute to get. - virtual void* getAttributeAsUserPointer(const c8* attributeName) = 0; - - //! Gets an attribute as user pointer - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual void* getAttributeAsUserPointer(s32 index) = 0; - - //! Sets an attribute as user pointer - virtual void setAttribute(s32 index, void* userPointer) = 0; - -}; - -} // end namespace io -} // end namespace irr - -#endif - - - diff --git a/irrlicht-1.6/include/IBillboardSceneNode.h b/irrlicht-1.6/include/IBillboardSceneNode.h deleted file mode 100644 index 1948fe760..000000000 --- a/irrlicht-1.6/include/IBillboardSceneNode.h +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_BILLBOARD_SCENE_NODE_H_INCLUDED__ -#define __I_BILLBOARD_SCENE_NODE_H_INCLUDED__ - -#include "ISceneNode.h" - -namespace irr -{ -namespace scene -{ - -//! A billboard scene node. -/** A billboard is like a 3d sprite: A 2d element, -which always looks to the camera. It is usually used for explosions, fire, -lensflares, particles and things like that. -*/ -class IBillboardSceneNode : public ISceneNode -{ -public: - - //! Constructor - IBillboardSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position = core::vector3df(0,0,0)) - : ISceneNode(parent, mgr, id, position) {} - - //! Sets the size of the billboard. - virtual void setSize(const core::dimension2d<f32>& size) = 0; - - //! Returns the size of the billboard. - virtual const core::dimension2d<f32>& getSize() const = 0; - - //! Set the color of all vertices of the billboard - /** \param overallColor: the color to set */ - virtual void setColor(const video::SColor & overallColor) = 0; - - //! Set the color of the top and bottom vertices of the billboard - /** \param topColor: the color to set the top vertices - \param bottomColor: the color to set the bottom vertices */ - virtual void setColor(const video::SColor & topColor, const video::SColor & bottomColor) = 0; - - //! Gets the color of the top and bottom vertices of the billboard - /** \param topColor: stores the color of the top vertices - \param bottomColor: stores the color of the bottom vertices */ - virtual void getColor(video::SColor & topColor, video::SColor & bottomColor) const = 0; -}; - -} // end namespace scene -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/include/IBillboardTextSceneNode.h b/irrlicht-1.6/include/IBillboardTextSceneNode.h deleted file mode 100644 index e8aca8e6b..000000000 --- a/irrlicht-1.6/include/IBillboardTextSceneNode.h +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_BILLBOARD_TEXT_SCENE_NODE_H_INCLUDED__ -#define __I_BILLBOARD_TEXT_SCENE_NODE_H_INCLUDED__ - -#include "IBillboardSceneNode.h" - -namespace irr -{ -namespace scene -{ - -//! A billboard text scene node. -/** Acts like a billboard which displays the currently set text. - Due to the exclusion of RTTI in Irrlicht we have to avoid multiple - inheritance. Hence, changes to the ITextSceneNode interface have - to be copied here manually. -*/ -class IBillboardTextSceneNode : public IBillboardSceneNode -{ -public: - - //! Constructor - IBillboardTextSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position = core::vector3df(0,0,0)) - : IBillboardSceneNode(parent, mgr, id, position) {} - - //! Sets the size of the billboard. - virtual void setSize(const core::dimension2d<f32>& size) = 0; - - //! Returns the size of the billboard. - virtual const core::dimension2d<f32>& getSize() const = 0; - - //! Set the color of all vertices of the billboard - /** \param overallColor: the color to set */ - virtual void setColor(const video::SColor & overallColor) = 0; - - //! Set the color of the top and bottom vertices of the billboard - /** \param topColor: the color to set the top vertices - \param bottomColor: the color to set the bottom vertices */ - virtual void setColor(const video::SColor & topColor, const video::SColor & bottomColor) = 0; - - //! Gets the color of the top and bottom vertices of the billboard - /** \param topColor: stores the color of the top vertices - \param bottomColor: stores the color of the bottom vertices */ - virtual void getColor(video::SColor & topColor, video::SColor & bottomColor) const = 0; - - //! sets the text string - virtual void setText(const wchar_t* text) = 0; - - //! sets the color of the text - virtual void setTextColor(video::SColor color) = 0; -}; - -} // end namespace scene -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/include/IBoneSceneNode.h b/irrlicht-1.6/include/IBoneSceneNode.h deleted file mode 100644 index 2fa0b501f..000000000 --- a/irrlicht-1.6/include/IBoneSceneNode.h +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_BONE_SCENE_NODE_H_INCLUDED__ -#define __I_BONE_SCENE_NODE_H_INCLUDED__ - -#include "ISceneNode.h" - -namespace irr -{ -namespace scene -{ - - //! Enumeration for different bone animation modes - enum E_BONE_ANIMATION_MODE - { - //! The bone is usually animated, unless it's parent is not animated - EBAM_AUTOMATIC=0, - - //! The bone is animated by the skin, if it's parent is not animated then animation will resume from this bone onward - EBAM_ANIMATED, - - //! The bone is not animated by the skin - EBAM_UNANIMATED, - - //! Not an animation mode, just here to count the available modes - EBAM_COUNT - - }; - - enum E_BONE_SKINNING_SPACE - { - //! local skinning, standard - EBSS_LOCAL=0, - - //! global skinning - EBSS_GLOBAL, - - EBSS_COUNT - }; - - //! Names for bone animation modes - const c8* const BoneAnimationModeNames[] = - { - "automatic", - "animated", - "unanimated", - 0, - }; - - - //! Interface for bones used for skeletal animation. - /** Used with ISkinnedMesh and IAnimatedMeshSceneNode. */ - class IBoneSceneNode : public ISceneNode - { - public: - - IBoneSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id=-1) : - ISceneNode(parent, mgr, id),positionHint(-1),scaleHint(-1),rotationHint(-1) { } - - //! Get the name of the bone - /** \deprecated Use getName instead. */ - virtual const c8* getBoneName() const { return getName(); } - - //! Get the index of the bone - virtual u32 getBoneIndex() const = 0; - - //! Sets the animation mode of the bone. - /** \return True if successful. (Unused) */ - virtual bool setAnimationMode(E_BONE_ANIMATION_MODE mode) = 0; - - //! Gets the current animation mode of the bone - virtual E_BONE_ANIMATION_MODE getAnimationMode() const = 0; - - //! Get the axis aligned bounding box of this node - virtual const core::aabbox3d<f32>& getBoundingBox() const = 0; - - //! Returns the relative transformation of the scene node. - //virtual core::matrix4 getRelativeTransformation() const = 0; - - //! The animation method. - virtual void OnAnimate(u32 timeMs) =0; - - //! The render method. - /** Does nothing as bones are not visible. */ - virtual void render() { } - - //! How the relative transformation of the bone is used - virtual void setSkinningSpace( E_BONE_SKINNING_SPACE space ) =0; - - //! How the relative transformation of the bone is used - virtual E_BONE_SKINNING_SPACE getSkinningSpace() const =0; - - //! Updates the absolute position based on the relative and the parents position - virtual void updateAbsolutePositionOfAllChildren()=0; - - s32 positionHint; - s32 scaleHint; - s32 rotationHint; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/ICameraSceneNode.h b/irrlicht-1.6/include/ICameraSceneNode.h deleted file mode 100644 index 6851eec57..000000000 --- a/irrlicht-1.6/include/ICameraSceneNode.h +++ /dev/null @@ -1,178 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_CAMERA_SCENE_NODE_H_INCLUDED__ -#define __I_CAMERA_SCENE_NODE_H_INCLUDED__ - -#include "ISceneNode.h" -#include "IEventReceiver.h" - -namespace irr -{ -namespace scene -{ - struct SViewFrustum; - - //! Scene Node which is a (controlable) camera. - /** The whole scene will be rendered from the cameras point of view. - Because the ICameraScenNode is a SceneNode, it can be attached to any - other scene node, and will follow its parents movement, rotation and so - on. - */ - class ICameraSceneNode : public ISceneNode, public IEventReceiver - { - public: - - //! Constructor - ICameraSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f,1.0f,1.0f)) - : ISceneNode(parent, mgr, id, position, rotation, scale), IsOrthogonal(false) {} - - //! Sets the projection matrix of the camera. - /** The core::matrix4 class has some methods to build a - projection matrix. e.g: - core::matrix4::buildProjectionMatrixPerspectiveFovLH. - Note that the matrix will only stay as set by this method until - one of the following Methods are called: setNearValue, - setFarValue, setAspectRatio, setFOV. - \param projection The new projection matrix of the camera. - \param isOrthogonal Set this to true if the matrix is an - orthogonal one (e.g. from matrix4::buildProjectionMatrixOrtho). - */ - virtual void setProjectionMatrix(const core::matrix4& projection, bool isOrthogonal=false) =0; - - //! Gets the current projection matrix of the camera. - /** \return The current projection matrix of the camera. */ - virtual const core::matrix4& getProjectionMatrix() const =0; - - //! Gets the current view matrix of the camera. - /** \return The current view matrix of the camera. */ - virtual const core::matrix4& getViewMatrix() const =0; - - //! Sets a custom view matrix affector. - /** The matrix passed here, will be multiplied with the view - matrix when it gets updated. This allows for custom camera - setups like, for example, a reflection camera. - \param affector The affector matrix. */ - virtual void setViewMatrixAffector(const core::matrix4& affector) =0; - - //! Get the custom view matrix affector. - /** \return The affector matrix. */ - virtual const core::matrix4& getViewMatrixAffector() const =0; - - //! It is possible to send mouse and key events to the camera. - /** Most cameras may ignore this input, but camera scene nodes - which are created for example with - ISceneManager::addCameraSceneNodeMaya or - ISceneManager::addCameraSceneNodeFPS, may want to get - this input for changing their position, look at target or - whatever. */ - virtual bool OnEvent(const SEvent& event) =0; - - //! Sets the look at target of the camera - /** If the camera's target and rotation are bound ( @see - bindTargetAndRotation() ) then calling this will also change - the camera's scene node rotation to match the target. - \param pos Look at target of the camera, in world co-ordinates. */ - virtual void setTarget(const core::vector3df& pos) =0; - - //! Sets the rotation of the node. - /** This only modifies the relative rotation of the node. - If the camera's target and rotation are bound ( @see - bindTargetAndRotation() ) then calling this will also change - the camera's target to match the rotation. - \param rotation New rotation of the node in degrees. */ - virtual void setRotation(const core::vector3df& rotation) =0; - - //! Gets the current look at target of the camera - /** \return The current look at target of the camera, in world co-ordinates */ - virtual const core::vector3df& getTarget() const =0; - - //! Sets the up vector of the camera. - /** \param pos: New upvector of the camera. */ - virtual void setUpVector(const core::vector3df& pos) =0; - - //! Gets the up vector of the camera. - /** \return The up vector of the camera, in world space. */ - virtual const core::vector3df& getUpVector() const =0; - - //! Gets the value of the near plane of the camera. - /** \return The value of the near plane of the camera. */ - virtual f32 getNearValue() const =0; - - //! Gets the value of the far plane of the camera. - /** \return The value of the far plane of the camera. */ - virtual f32 getFarValue() const =0; - - //! Gets the aspect ratio of the camera. - /** \return The aspect ratio of the camera. */ - virtual f32 getAspectRatio() const =0; - - //! Gets the field of view of the camera. - /** \return The field of view of the camera in radiants. */ - virtual f32 getFOV() const =0; - - //! Sets the value of the near clipping plane. (default: 1.0f) - /** \param zn: New z near value. */ - virtual void setNearValue(f32 zn) =0; - - //! Sets the value of the far clipping plane (default: 2000.0f) - /** \param zf: New z far value. */ - virtual void setFarValue(f32 zf) =0; - - //! Sets the aspect ratio (default: 4.0f / 3.0f) - /** \param aspect: New aspect ratio. */ - virtual void setAspectRatio(f32 aspect) =0; - - //! Sets the field of view (Default: PI / 2.5f) - /** \param fovy: New field of view in radiants. */ - virtual void setFOV(f32 fovy) =0; - - //! Get the view frustum. - /** Needed sometimes by bspTree or LOD render nodes. - \return The current view frustum. */ - virtual const SViewFrustum* getViewFrustum() const =0; - - //! Disables or enables the camera to get key or mouse inputs. - /** If this is set to true, the camera will respond to key - inputs otherwise not. */ - virtual void setInputReceiverEnabled(bool enabled) =0; - - //! Checks if the input receiver of the camera is currently enabled. - virtual bool isInputReceiverEnabled() const =0; - - //! Checks if a camera is orthogonal. - virtual bool isOrthogonal() const - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return IsOrthogonal; - } - - //! Binds the camera scene node's rotation to its target position and vice vera, or unbinds them. - /** When bound, calling setRotation() will update the camera's - target position to be along its +Z axis, and likewise calling - setTarget() will update its rotation so that its +Z axis will - point at the target point. FPS camera use this binding by - default; other cameras do not. - \param bound True to bind the camera's scene node rotation - and targetting, false to unbind them. - @see getTargetAndRotationBinding() */ - virtual void bindTargetAndRotation(bool bound) =0; - - //! Queries if the camera scene node's rotation and its target position are bound together. - /** @see bindTargetAndRotation() */ - virtual bool getTargetAndRotationBinding(void) const =0; - - protected: - - bool IsOrthogonal; - }; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/ICursorControl.h b/irrlicht-1.6/include/ICursorControl.h deleted file mode 100644 index 5e2b0d163..000000000 --- a/irrlicht-1.6/include/ICursorControl.h +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_CURSOR_CONTROL_H_INCLUDED__ -#define __I_CURSOR_CONTROL_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "position2d.h" -#include "rect.h" - -namespace irr -{ -namespace gui -{ - - //! Interface to manipulate the mouse cursor. - class ICursorControl : public virtual IReferenceCounted - { - public: - - //! Changes the visible state of the mouse cursor. - /** \param visible: The new visible state. If true, the cursor will be visible, - if false, it will be invisible. */ - virtual void setVisible(bool visible) = 0; - - //! Returns if the cursor is currently visible. - /** \return True if the cursor is visible, false if not. */ - virtual bool isVisible() const = 0; - - //! Sets the new position of the cursor. - /** The position must be - between (0.0f, 0.0f) and (1.0f, 1.0f), where (0.0f, 0.0f) is - the top left corner and (1.0f, 1.0f) is the bottom right corner of the - render window. - \param pos New position of the cursor. */ - virtual void setPosition(const core::position2d<f32> &pos) = 0; - - //! Sets the new position of the cursor. - /** The position must be - between (0.0f, 0.0f) and (1.0f, 1.0f), where (0.0f, 0.0f) is - the top left corner and (1.0f, 1.0f) is the bottom right corner of the - render window. - \param x New x-coord of the cursor. - \param y New x-coord of the cursor. */ - virtual void setPosition(f32 x, f32 y) = 0; - - //! Sets the new position of the cursor. - /** \param pos: New position of the cursor. The coordinates are pixel units. */ - virtual void setPosition(const core::position2d<s32> &pos) = 0; - - //! Sets the new position of the cursor. - /** \param x New x-coord of the cursor. The coordinates are pixel units. - \param y New y-coord of the cursor. The coordinates are pixel units. */ - virtual void setPosition(s32 x, s32 y) = 0; - - //! Returns the current position of the mouse cursor. - /** \return Returns the current position of the cursor. The returned position - is the position of the mouse cursor in pixel units. */ - virtual core::position2d<s32> getPosition() = 0; - - //! Returns the current position of the mouse cursor. - /** \return Returns the current position of the cursor. The returned position - is a value between (0.0f, 0.0f) and (1.0f, 1.0f), where (0.0f, 0.0f) is - the top left corner and (1.0f, 1.0f) is the bottom right corner of the - render window. */ - virtual core::position2d<f32> getRelativePosition() = 0; - - //! Sets an absolute reference rect for setting and retrieving the cursor position. - /** If this rect is set, the cursor position is not being calculated relative to - the rendering window but to this rect. You can set the rect pointer to 0 to disable - this feature again. This feature is useful when rendering into parts of foreign windows - for example in an editor. - \param rect: A pointer to an reference rectangle or 0 to disable the reference rectangle.*/ - virtual void setReferenceRect(core::rect<s32>* rect=0) = 0; - }; - - -} // end namespace gui -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IDummyTransformationSceneNode.h b/irrlicht-1.6/include/IDummyTransformationSceneNode.h deleted file mode 100644 index ce42da855..000000000 --- a/irrlicht-1.6/include/IDummyTransformationSceneNode.h +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_DUMMY_TRANSFORMATION_SCENE_NODE_H_INCLUDED__ -#define __I_DUMMY_TRANSFORMATION_SCENE_NODE_H_INCLUDED__ - -#include "ISceneNode.h" - -namespace irr -{ -namespace scene -{ - -//! Dummy scene node for adding additional transformations to the scene graph. -/** This scene node does not render itself, and does not respond to set/getPosition, -set/getRotation and set/getScale. Its just a simple scene node that takes a -matrix as relative transformation, making it possible to insert any transformation -anywhere into the scene graph. -This scene node is for example used by the IAnimatedMeshSceneNode for emulating -joint scene nodes when playing skeletal animations. -*/ -class IDummyTransformationSceneNode : public ISceneNode -{ -public: - - //! Constructor - IDummyTransformationSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id) - : ISceneNode(parent, mgr, id) {} - - //! Returns a reference to the current relative transformation matrix. - /** This is the matrix, this scene node uses instead of scale, translation - and rotation. */ - virtual core::matrix4& getRelativeTransformationMatrix() = 0; -}; - -} // end namespace scene -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/include/IDynamicMeshBuffer.h b/irrlicht-1.6/include/IDynamicMeshBuffer.h deleted file mode 100644 index 8c86da693..000000000 --- a/irrlicht-1.6/include/IDynamicMeshBuffer.h +++ /dev/null @@ -1,211 +0,0 @@ -// Copyright (C) 2008-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_DYNAMIC_MESH_BUFFER_H_INCLUDED__ -#define __I_DYNAMIC_MESH_BUFFER_H_INCLUDED__ - -#include "IMeshBuffer.h" -#include "IVertexBuffer.h" -#include "IIndexBuffer.h" - -namespace irr -{ -namespace scene -{ - - /** a dynamic meshBuffer */ - class IDynamicMeshBuffer : public IMeshBuffer - { - public: - virtual IVertexBuffer &getVertexBuffer() const =0; - virtual IIndexBuffer &getIndexBuffer() const =0; - - virtual void setVertexBuffer(IVertexBuffer *vertexBuffer) =0; - virtual void setIndexBuffer(IIndexBuffer *indexBuffer) =0; - - //! Get the material of this meshbuffer - /** \return Material of this buffer. */ - virtual video::SMaterial& getMaterial() =0; - - //! Get the material of this meshbuffer - /** \return Material of this buffer. */ - virtual const video::SMaterial& getMaterial() const =0; - - //! Get the axis aligned bounding box of this meshbuffer. - /** \return Axis aligned bounding box of this buffer. */ - virtual const core::aabbox3df& getBoundingBox() const =0; - - //! Set axis aligned bounding box - /** \param box User defined axis aligned bounding box to use - for this buffer. */ - virtual void setBoundingBox(const core::aabbox3df& box) =0; - - //! Recalculates the bounding box. Should be called if the mesh changed. - virtual void recalculateBoundingBox() =0; - - //! Append the vertices and indices to the current buffer - /** Only works for compatible vertex types. - \param vertices Pointer to a vertex array. - \param numVertices Number of vertices in the array. - \param indices Pointer to index array. - \param numIndices Number of indices in array. */ - virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) - { - - } - - //! Append the meshbuffer to the current buffer - /** Only works for compatible vertex types - \param other Buffer to append to this one. */ - virtual void append(const IMeshBuffer* const other) - { - - } - - // ------------------- To be removed? ------------------- // - - //! get the current hardware mapping hint - virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const - { - return getVertexBuffer().getHardwareMappingHint(); - } - - //! get the current hardware mapping hint - virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const - { - return getIndexBuffer().getHardwareMappingHint(); - } - - //! set the hardware mapping hint, for driver - virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint, E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX ) - { - if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_VERTEX) - getVertexBuffer().setHardwareMappingHint(NewMappingHint); - if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_INDEX) - getIndexBuffer().setHardwareMappingHint(NewMappingHint); - } - - //! flags the mesh as changed, reloads hardware buffers - virtual void setDirty(E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX) - { - if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_VERTEX) - getVertexBuffer().setDirty(); - if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_INDEX) - getIndexBuffer().setDirty(); - } - - virtual u32 getChangedID_Vertex() const - { - return getVertexBuffer().getChangedID(); - } - - virtual u32 getChangedID_Index() const - { - return getIndexBuffer().getChangedID(); - } - - // ------------------- Old interface ------------------- // - - //! Get type of vertex data which is stored in this meshbuffer. - /** \return Vertex type of this buffer. */ - virtual video::E_VERTEX_TYPE getVertexType() const - { - return getVertexBuffer().getType(); - } - - //! Get access to vertex data. The data is an array of vertices. - /** Which vertex type is used can be determined by getVertexType(). - \return Pointer to array of vertices. */ - virtual const void* getVertices() const - { - return getVertexBuffer().getData(); - } - - //! Get access to vertex data. The data is an array of vertices. - /** Which vertex type is used can be determined by getVertexType(). - \return Pointer to array of vertices. */ - virtual void* getVertices() - { - return getVertexBuffer().getData(); - } - - //! Get amount of vertices in meshbuffer. - /** \return Number of vertices in this buffer. */ - virtual u32 getVertexCount() const - { - return getVertexBuffer().size(); - } - - //! Get type of index data which is stored in this meshbuffer. - /** \return Index type of this buffer. */ - virtual video::E_INDEX_TYPE getIndexType() const - { - return getIndexBuffer().getType(); - } - - //! Get access to Indices. - /** \return Pointer to indices array. */ - virtual const u16* getIndices() const - { - return (u16*)getIndexBuffer().getData(); - } - - //! Get access to Indices. - /** \return Pointer to indices array. */ - virtual u16* getIndices() - { - return (u16*)getIndexBuffer().getData(); - } - - //! Get amount of indices in this meshbuffer. - /** \return Number of indices in this buffer. */ - virtual u32 getIndexCount() const - { - return getIndexBuffer().size(); - } - - //! returns position of vertex i - virtual const core::vector3df& getPosition(u32 i) const - { - return getVertexBuffer()[i].Pos; - } - - //! returns position of vertex i - virtual core::vector3df& getPosition(u32 i) - { - return getVertexBuffer()[i].Pos; - } - - //! returns texture coords of vertex i - virtual const core::vector2df& getTCoords(u32 i) const - { - return getVertexBuffer()[i].TCoords; - } - - //! returns texture coords of vertex i - virtual core::vector2df& getTCoords(u32 i) - { - return getVertexBuffer()[i].TCoords; - } - - //! returns normal of vertex i - virtual const core::vector3df& getNormal(u32 i) const - { - return getVertexBuffer()[i].Normal; - } - - //! returns normal of vertex i - virtual core::vector3df& getNormal(u32 i) - { - return getVertexBuffer()[i].Normal; - } - }; - - -} // end namespace scene -} // end namespace irr - -#endif - - diff --git a/irrlicht-1.6/include/IEventReceiver.h b/irrlicht-1.6/include/IEventReceiver.h deleted file mode 100644 index 89dd02065..000000000 --- a/irrlicht-1.6/include/IEventReceiver.h +++ /dev/null @@ -1,463 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_EVENT_RECEIVER_H_INCLUDED__ -#define __I_EVENT_RECEIVER_H_INCLUDED__ - -#include "ILogger.h" -#include "position2d.h" -#include "Keycodes.h" -#include "irrString.h" - -namespace irr -{ - //! Enumeration for all event types there are. - enum EEVENT_TYPE - { - //! An event of the graphical user interface. - /** GUI events are created by the GUI environment or the GUI elements in response - to mouse or keyboard events. When a GUI element receives an event it will either - process it and return true, or pass the event to its parent. If an event is not absorbed - before it reaches the root element then it will then be passed to the user receiver. */ - EET_GUI_EVENT = 0, - - //! A mouse input event. - /** Mouse events are created by the device and passed to IrrlichtDevice::postEventFromUser - in response to mouse input received from the operating system. - Mouse events are first passed to the user receiver, then to the GUI environment and its elements, - then finally the input receiving scene manager where it is passed to the active camera. - */ - EET_MOUSE_INPUT_EVENT, - - //! A key input event. - /** Like mouse events, keyboard events are created by the device and passed to - IrrlichtDevice::postEventFromUser. They take the same path as mouse events. */ - EET_KEY_INPUT_EVENT, - - //! A joystick (joypad, gamepad) input event. - /** Joystick events are created by polling all connected joysticks once per - device run() and then passing the events to IrrlichtDevice::postEventFromUser. - They take the same path as mouse events. - Windows, SDL: Implemented. - Linux: Implemented, with POV hat issues. - MacOS / Other: Not yet implemented. - */ - EET_JOYSTICK_INPUT_EVENT, - - //! A log event - /** Log events are only passed to the user receiver if there is one. If they are absorbed by the - user receiver then no text will be sent to the console. */ - EET_LOG_TEXT_EVENT, - - //! A user event with user data. - /** This is not used by Irrlicht and can be used to send user - specific data though the system. The Irrlicht 'window handle' - can be obtained from IrrlichtDevice::getExposedVideoData() - The usage and behaviour depends on the operating system: - Windows: send a WM_USER message to the Irrlicht Window; the - wParam and lParam will be used to populate the - UserData1 and UserData2 members of the SUserEvent. - Linux: send a ClientMessage via XSendEvent to the Irrlicht - Window; the data.l[0] and data.l[1] members will be - casted to s32 and used as UserData1 and UserData2. - MacOS: Not yet implemented - */ - EET_USER_EVENT, - - //! This enum is never used, it only forces the compiler to - //! compile these enumeration values to 32 bit. - EGUIET_FORCE_32_BIT = 0x7fffffff - - }; - - //! Enumeration for all mouse input events - enum EMOUSE_INPUT_EVENT - { - //! Left mouse button was pressed down. - EMIE_LMOUSE_PRESSED_DOWN = 0, - - //! Right mouse button was pressed down. - EMIE_RMOUSE_PRESSED_DOWN, - - //! Middle mouse button was pressed down. - EMIE_MMOUSE_PRESSED_DOWN, - - //! Left mouse button was left up. - EMIE_LMOUSE_LEFT_UP, - - //! Right mouse button was left up. - EMIE_RMOUSE_LEFT_UP, - - //! Middle mouse button was left up. - EMIE_MMOUSE_LEFT_UP, - - //! The mouse cursor changed its position. - EMIE_MOUSE_MOVED, - - //! The mouse wheel was moved. Use Wheel value in event data to find out - //! in what direction and how fast. - EMIE_MOUSE_WHEEL, - - //! Mouse double click. - //! This event is generated after the second EMIE_LMOUSE_PRESSED_DOWN event. - EMIE_MOUSE_DOUBLE_CLICK, - - //! Mouse triple click. - //! This event is generated after the third EMIE_LMOUSE_PRESSED_DOWN event. - EMIE_MOUSE_TRIPLE_CLICK, - - //! No real event. Just for convenience to get number of events - EMIE_COUNT - }; - - //! Masks for mouse button states - enum E_MOUSE_BUTTON_STATE_MASK - { - EMBSM_LEFT = 0x01, - EMBSM_RIGHT = 0x02, - EMBSM_MIDDLE = 0x04, - - //! currently only on windows - EMBSM_EXTRA1 = 0x08, - - //! currently only on windows - EMBSM_EXTRA2 = 0x10, - - EMBSM_FORCE_32_BIT = 0x7fffffff - }; - - namespace gui - { - - class IGUIElement; - - //! Enumeration for all events which are sendable by the gui system - enum EGUI_EVENT_TYPE - { - //! A gui element has lost its focus. - /** GUIEvent.Caller is losing the focus to GUIEvent.Element. - If the event is absorbed then the focus will not be changed. */ - EGET_ELEMENT_FOCUS_LOST = 0, - - //! A gui element has got the focus. - /** If the event is absorbed then the focus will not be changed. */ - EGET_ELEMENT_FOCUSED, - - //! The mouse cursor hovered over a gui element. - EGET_ELEMENT_HOVERED, - - //! The mouse cursor left the hovered element. - EGET_ELEMENT_LEFT, - - //! An element would like to close. - /** Windows and context menus use this event when they would like to close, - this can be cancelled by absorbing the event. */ - EGET_ELEMENT_CLOSED, - - //! A button was clicked. - EGET_BUTTON_CLICKED, - - //! A scrollbar has changed its position. - EGET_SCROLL_BAR_CHANGED, - - //! A checkbox has changed its check state. - EGET_CHECKBOX_CHANGED, - - //! A new item in a listbox was seleted. - EGET_LISTBOX_CHANGED, - - //! An item in the listbox was selected, which was already selected. - EGET_LISTBOX_SELECTED_AGAIN, - - //! A file has been selected in the file dialog - EGET_FILE_SELECTED, - - //! A directory has been selected in the file dialog - EGET_DIRECTORY_SELECTED, - - //! A file open dialog has been closed without choosing a file - EGET_FILE_CHOOSE_DIALOG_CANCELLED, - - //! 'Yes' was clicked on a messagebox - EGET_MESSAGEBOX_YES, - - //! 'No' was clicked on a messagebox - EGET_MESSAGEBOX_NO, - - //! 'OK' was clicked on a messagebox - EGET_MESSAGEBOX_OK, - - //! 'Cancel' was clicked on a messagebox - EGET_MESSAGEBOX_CANCEL, - - //! In an editbox 'ENTER' was pressed - EGET_EDITBOX_ENTER, - - //! The text in an editbox was changed. This does not include automatic changes in text-breaking. - EGET_EDITBOX_CHANGED, - - //! The marked area in an editbox was changed. - EGET_EDITBOX_MARKING_CHANGED, - - //! The tab was changed in an tab control - EGET_TAB_CHANGED, - - //! A menu item was selected in a (context) menu - EGET_MENU_ITEM_SELECTED, - - //! The selection in a combo box has been changed - EGET_COMBO_BOX_CHANGED, - - //! The value of a spin box has changed - EGET_SPINBOX_CHANGED, - - //! A table has changed - EGET_TABLE_CHANGED, - EGET_TABLE_HEADER_CHANGED, - EGET_TABLE_SELECTED_AGAIN, - - //! A tree view node lost selection. See IGUITreeView::getLastEventNode(). - EGET_TREEVIEW_NODE_DESELECT, - - //! A tree view node was selected. See IGUITreeView::getLastEventNode(). - EGET_TREEVIEW_NODE_SELECT, - - //! A tree view node was expanded. See IGUITreeView::getLastEventNode(). - EGET_TREEVIEW_NODE_EXPAND, - - //! A tree view node was collapsed. See IGUITreeView::getLastEventNode(). - EGET_TREEVIEW_NODE_COLLAPS, - - //! No real event. Just for convenience to get number of events - EGET_COUNT - }; - } // end namespace gui - - -//! SEvents hold information about an event. See irr::IEventReceiver for details on event handling. -struct SEvent -{ - //! Any kind of GUI event. - struct SGUIEvent - { - //! IGUIElement who called the event - gui::IGUIElement* Caller; - - //! If the event has something to do with another element, it will be held here. - gui::IGUIElement* Element; - - //! Type of GUI Event - gui::EGUI_EVENT_TYPE EventType; - - }; - - //! Any kind of mouse event. - struct SMouseInput - { - //! X position of mouse cursor - s32 X; - - //! Y position of mouse cursor - s32 Y; - - //! mouse wheel delta, usually 1.0 or -1.0. - /** Only valid if event was EMIE_MOUSE_WHEEL */ - f32 Wheel; - - //! True if shift was also pressed - bool Shift:1; - - //! True if ctrl was also pressed - bool Control:1; - - //! A bitmap of button states. You can use isButtonPressed() to determine - //! if a button is pressed or not. - //! Currently only valid if the event was EMIE_MOUSE_MOVED - u32 ButtonStates; - - //! Is the left button pressed down? - bool isLeftPressed() const { return 0 != ( ButtonStates & EMBSM_LEFT ); } - - //! Is the right button pressed down? - bool isRightPressed() const { return 0 != ( ButtonStates & EMBSM_RIGHT ); } - - //! Is the middle button pressed down? - bool isMiddlePressed() const { return 0 != ( ButtonStates & EMBSM_MIDDLE ); } - - //! Type of mouse event - EMOUSE_INPUT_EVENT Event; - }; - - //! Any kind of keyboard event. - struct SKeyInput - { - //! Character corresponding to the key (0, if not a character) - wchar_t Char; - - //! Key which has been pressed or released - EKEY_CODE Key; - - //! If not true, then the key was left up - bool PressedDown:1; - - //! True if shift was also pressed - bool Shift:1; - - //! True if ctrl was also pressed - bool Control:1; - }; - - //! A joystick event. - /** Unlike other events, joystick events represent the result of polling - * each connected joystick once per run() of the device. Joystick events will - * not be generated by default. If joystick support is available for the - * active device, _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ is defined, and - * @ref IrrlichtDevice::activateJoysticks() has been called, an event of - * this type will be generated once per joystick per @ref IrrlichtDevice::run() - * regardless of whether the state of the joystick has actually changed. */ - struct SJoystickEvent - { - enum - { - NUMBER_OF_BUTTONS = 32, - - AXIS_X = 0, // e.g. analog stick 1 left to right - AXIS_Y, // e.g. analog stick 1 top to bottom - AXIS_Z, // e.g. throttle, or analog 2 stick 2 left to right - AXIS_R, // e.g. rudder, or analog 2 stick 2 top to bottom - AXIS_U, - AXIS_V, - NUMBER_OF_AXES - }; - - /** A bitmap of button states. You can use IsButtonPressed() to - ( check the state of each button from 0 to (NUMBER_OF_BUTTONS - 1) */ - u32 ButtonStates; - - /** For AXIS_X, AXIS_Y, AXIS_Z, AXIS_R, AXIS_U and AXIS_V - * Values are in the range -32768 to 32767, with 0 representing - * the center position. You will receive the raw value from the - * joystick, and so will usually want to implement a dead zone around - * the center of the range. Axes not supported by this joystick will - * always have a value of 0. On Linux, POV hats are represented as axes, - * usually the last two active axis. - */ - s16 Axis[NUMBER_OF_AXES]; - - /** The POV represents the angle of the POV hat in degrees * 100, - * from 0 to 35,900. A value of 65535 indicates that the POV hat - * is centered (or not present). - * This value is only supported on Windows. On Linux, the POV hat - * will be sent as 2 axes instead. */ - u16 POV; - - //! The ID of the joystick which generated this event. - /** This is an internal Irrlicht index; it does not map directly - * to any particular hardware joystick. */ - u8 Joystick; - - //! A helper function to check if a button is pressed. - bool IsButtonPressed(u32 button) const - { - if(button >= (u32)NUMBER_OF_BUTTONS) - return false; - - return (ButtonStates & (1 << button)) ? true : false; - } - }; - - - //! Any kind of log event. - struct SLogEvent - { - //! Pointer to text which has been logged - const c8* Text; - - //! Log level in which the text has been logged - ELOG_LEVEL Level; - }; - - //! Any kind of user event. - struct SUserEvent - { - //! Some user specified data as int - s32 UserData1; - - //! Another user specified data as int - s32 UserData2; - }; - - EEVENT_TYPE EventType; - union - { - struct SGUIEvent GUIEvent; - struct SMouseInput MouseInput; - struct SKeyInput KeyInput; - struct SJoystickEvent JoystickEvent; - struct SLogEvent LogEvent; - struct SUserEvent UserEvent; - }; - -}; - -//! Interface of an object which can receive events. -/** Many of the engine's classes inherit IEventReceiver so they are able to -process events. Events usually start at a postEventFromUser function and are -passed down through a chain of event receivers until OnEvent returns true. See -irr::EEVENT_TYPE for a description of where each type of event starts, and the -path it takes through the system. */ -class IEventReceiver -{ -public: - - //! Destructor - virtual ~IEventReceiver() {} - - //! Called if an event happened. - /** \return True if the event was processed. */ - virtual bool OnEvent(const SEvent& event) = 0; -}; - - -//! Information on a joystick, returned from @ref IrrlichtDevice::activateJoysticks() -struct SJoystickInfo -{ - //! The ID of the joystick - /** This is an internal Irrlicht index; it does not map directly - * to any particular hardware joystick. It corresponds to the - * irr::SJoystickEvent Joystick ID. */ - u8 Joystick; - - //! The name that the joystick uses to identify itself. - core::stringc Name; - - //! The number of buttons that the joystick has. - u32 Buttons; - - //! The number of axes that the joystick has, i.e. X, Y, Z, R, U, V. - /** Note: with a Linux device, the POV hat (if any) will use two axes. These - * will be included in this count. */ - u32 Axes; - - //! An indication of whether the joystick has a POV hat. - /** A Windows device will identify the presence or absence or the POV hat. A - * Linux device cannot, and will always return POV_HAT_UNKNOWN. */ - enum - { - //! A hat is definitely present. - POV_HAT_PRESENT, - - //! A hat is definitely not present. - POV_HAT_ABSENT, - - //! The presence or absence of a hat cannot be determined. - POV_HAT_UNKNOWN - } PovHat; -}; // struct SJoystickInfo - - -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IFileArchive.h b/irrlicht-1.6/include/IFileArchive.h deleted file mode 100644 index be5f45b3d..000000000 --- a/irrlicht-1.6/include/IFileArchive.h +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt/ Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_FILE_ARCHIVE_H_INCLUDED__ -#define __I_FILE_ARCHIVE_H_INCLUDED__ - -#include "IReadFile.h" -#include "IFileList.h" - -namespace irr -{ - -namespace io -{ - -//! FileSystemType: which Filesystem should be used for e.g. browsing -enum EFileSystemType -{ - FILESYSTEM_NATIVE = 0, // Native OS FileSystem - FILESYSTEM_VIRTUAL, // Virtual FileSystem -}; - -//! Contains the different types of archives -enum E_FILE_ARCHIVE_TYPE -{ - //! A PKZIP archive - EFAT_ZIP = MAKE_IRR_ID('Z','I','P', 0), - - //! A gzip archive - EFAT_GZIP = MAKE_IRR_ID('g','z','i','p'), - - //! A virtual directory - EFAT_FOLDER = MAKE_IRR_ID('f','l','d','r'), - - //! An ID Software PAK archive - EFAT_PAK = MAKE_IRR_ID('P','A','K', 0), - - //! A Tape ARchive - EFAT_TAR = MAKE_IRR_ID('T','A','R', 0), - - //! The type of this archive is unknown - EFAT_UNKNOWN = MAKE_IRR_ID('u','n','k','n') -}; - -//! The FileArchive manages archives and provides access to files inside them. -class IFileArchive : public virtual IReferenceCounted -{ -public: - - //! Opens a file based on its name - /** Creates and returns a new IReadFile for a file in the archive. - \param filename The file to open - \return Returns A pointer to the created file on success, - or 0 on failure. */ - virtual IReadFile* createAndOpenFile(const path& filename) =0; - - //! Opens a file based on its position. - /** Creates and returns - \param index The zero based index of the file. - \return Returns a pointer to the created file on success, or 0 on failure. */ - virtual IReadFile* createAndOpenFile(u32 index) =0; - - //! Returns the complete file tree - /** \return Returns the complete directory tree for the archive, - including all files and folders */ - virtual const IFileList* getFileList() const =0; - - //! get the archive type - virtual E_FILE_ARCHIVE_TYPE getType() const { return EFAT_UNKNOWN; } -}; - -//! Class which is able to create an archive from a file. -/** If you want the Irrlicht Engine be able to load archives of -currently unsupported file formats (e.g .wad), then implement -this and add your new Archive loader with -IFileSystem::addArchiveLoader() to the engine. */ -class IArchiveLoader : public virtual IReferenceCounted -{ -public: - //! Check if the file might be loaded by this class - /** Check based on the file extension (e.g. ".zip") - \param fileName Name of file to check. - \return True if file seems to be loadable. */ - virtual bool isALoadableFileFormat(const path& filename) const =0; - - //! Check if the file might be loaded by this class - /** This check may look into the file. - \param file File handle to check. - \return True if file seems to be loadable. */ - virtual bool isALoadableFileFormat(io::IReadFile* file) const =0; - - //! Check to see if the loader can create archives of this type. - /** Check based on the archive type. - \param fileType The archive type to check. - \return True if the archile loader supports this type, false if not */ - virtual bool isALoadableFileFormat(E_FILE_ARCHIVE_TYPE fileType) const =0; - - //! Creates an archive from the filename - /** \param file File handle to check. - \return Pointer to newly created archive, or 0 upon error. */ - virtual IFileArchive* createArchive(const path& filename, bool ignoreCase, bool ignorePaths) const =0; - - //! Creates an archive from the file - /** \param file File handle to check. - \return Pointer to newly created archive, or 0 upon error. */ - virtual IFileArchive* createArchive(io::IReadFile* file, bool ignoreCase, bool ignorePaths) const =0; -}; - - -} // end namespace io -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IFileList.h b/irrlicht-1.6/include/IFileList.h deleted file mode 100644 index c6a1bf8c7..000000000 --- a/irrlicht-1.6/include/IFileList.h +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_FILE_LIST_H_INCLUDED__ -#define __I_FILE_LIST_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "path.h" - -namespace irr -{ -namespace io -{ - -//! Provides a list of files and folders. -/** File lists usually contain a list of all files in a given folder, -but can also contain a complete directory structure. */ -class IFileList : public virtual IReferenceCounted -{ -public: - //! Get the number of files in the filelist. - /** \return Amount of files and directories in the file list. */ - virtual u32 getFileCount() const = 0; - - //! Gets the name of a file in the list, based on an index. - /** The path is not included in this name. Use getFullFileName for this. - \param index is the zero based index of the file which name should - be returned. The index must be less than the amount getFileCount() returns. - \return File name of the file. Returns 0, if an error occured. */ - virtual const io::path& getFileName(u32 index) const = 0; - - //! Gets the full name of a file in the list including the path, based on an index. - /** \param index is the zero based index of the file which name should - be returned. The index must be less than the amount getFileCount() returns. - \return File name of the file. Returns 0, if an error occured. */ - virtual const io::path& getFullFileName(u32 index) const = 0; - - //! Returns the size of a file in the file list, based on an index. - /** \param index is the zero based index of the file which should be returned. - The index must be less than the amount getFileCount() returns. - \return The size of the file in bytes. */ - virtual u32 getFileSize(u32 index) const = 0; - - //! Check if the file is a directory - /** \param index The zero based index which will be checked. The index - must be less than the amount getFileCount() returns. - \return True if the file is a directory, else false. */ - virtual bool isDirectory(u32 index) const = 0; - - //! Searches for a file or folder in the list - /** Searches for a file by name - \param filename The name of the file to search for. - \param isFolder True if you are searching for a file, false if you want a dir. - \return Returns the index of the file in the file list, or -1 if - no matching name name was found. */ - virtual s32 findFile(const io::path& filename, bool isFolder=false) const = 0; - - //! Returns the base path of the file list - virtual const io::path& getPath() const = 0; -}; - -} // end namespace irr -} // end namespace io - - -#endif - diff --git a/irrlicht-1.6/include/IFileSystem.h b/irrlicht-1.6/include/IFileSystem.h deleted file mode 100644 index 36a2ba47b..000000000 --- a/irrlicht-1.6/include/IFileSystem.h +++ /dev/null @@ -1,301 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_FILE_SYSTEM_H_INCLUDED__ -#define __I_FILE_SYSTEM_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "IXMLReader.h" -#include "IFileArchive.h" - -namespace irr -{ -namespace video -{ - class IVideoDriver; -} // end namespace video -namespace io -{ - -class IReadFile; -class IWriteFile; -class IFileList; -class IXMLWriter; -class IAttributes; - - -//! The FileSystem manages files and archives and provides access to them. -/** It manages where files are, so that modules which use the the IO do not -need to know where every file is located. A file could be in a .zip-Archive or -as file on disk, using the IFileSystem makes no difference to this. */ -class IFileSystem : public virtual IReferenceCounted -{ -public: - - //! Opens a file for read access. - /** \param filename: Name of file to open. - \return Returns a pointer to the created file interface. - The returned pointer should be dropped when no longer needed. - See IReferenceCounted::drop() for more information. */ - virtual IReadFile* createAndOpenFile(const path& filename) =0; - - //! Creates an IReadFile interface for accessing memory like a file. - /** This allows you to use a pointer to memory where an IReadFile is requested. - \param memory: A pointer to the start of the file in memory - \param len: The length of the memory in bytes - \param fileName: The name given to this file - \param deleteMemoryWhenDropped: True if the memory should be deleted - along with the IReadFile when it is dropped. - \return Returns a pointer to the created file interface. - The returned pointer should be dropped when no longer needed. - See IReferenceCounted::drop() for more information. - */ - virtual IReadFile* createMemoryReadFile(void* memory, s32 len, const path& fileName, bool deleteMemoryWhenDropped=false) =0; - - //! Creates an IReadFile interface for accessing files inside files. - /** This is useful e.g. for archives. - \param fileName: The name given to this file - \param alreadyOpenedFile: Pointer to the enclosing file - \param pos: Start of the file inside alreadyOpenedFile - \param areaSize: The length of the file - \return A pointer to the created file interface. - The returned pointer should be dropped when no longer needed. - See IReferenceCounted::drop() for more information. - */ - virtual IReadFile* createLimitReadFile(const path& fileName, - IReadFile* alreadyOpenedFile, long pos, long areaSize) =0; - - //! Creates an IWriteFile interface for accessing memory like a file. - /** This allows you to use a pointer to memory where an IWriteFile is requested. - You are responsible for allocating enough memory. - \param memory: A pointer to the start of the file in memory (allocated by you) - \param len: The length of the memory in bytes - \param fileName: The name given to this file - \param deleteMemoryWhenDropped: True if the memory should be deleted - along with the IWriteFile when it is dropped. - \return Returns a pointer to the created file interface. - The returned pointer should be dropped when no longer needed. - See IReferenceCounted::drop() for more information. - */ - virtual IWriteFile* createMemoryWriteFile(void* memory, s32 len, const path& fileName, bool deleteMemoryWhenDropped=false) =0; - - - //! Opens a file for write access. - /** \param filename: Name of file to open. - \param append: If the file already exist, all write operations are - appended to the file. - \return Returns a pointer to the created file interface. 0 is returned, if the - file could not created or opened for writing. - The returned pointer should be dropped when no longer needed. - See IReferenceCounted::drop() for more information. */ - virtual IWriteFile* createAndWriteFile(const path& filename, bool append=false) =0; - - //! Adds an archive to the file system. - /** After calling this, the Irrlicht Engine will also search and open files directly from this archive. - This is useful for hiding data from the end user, speeding up file access and making it possible to - access for example Quake3 .pk3 files, which are no different than .zip files. - By default Irrlicht supports ZIP, PAK, TAR and directories as archives. You can provide your own archive - types by implementing IArchiveLoader and passing an instance to addArchiveLoader. - \param filename: Filename of the archive to add to the file system. - \param ignoreCase: If set to true, files in the archive can be accessed without - writing all letters in the right case. - \param ignorePaths: If set to true, files in the added archive can be accessed - without its complete path. - \param archiveType: If no specific E_FILE_ARCHIVE_TYPE is selected then the type of archive will depend on - the extension of the file name. If you use a different extension then you can use this parameter to force - a specific type of archive. - \return Returns true if the archive was added successfully, false if not. */ - virtual bool addFileArchive(const path& filename, bool ignoreCase=true, bool ignorePaths=true, - E_FILE_ARCHIVE_TYPE archiveType=EFAT_UNKNOWN) =0; - - //! Adds an external archive loader to the engine. - /** Use this function to add support for new archive types to the engine, for example propiatrary or - encyrpted file storage. */ - virtual void addArchiveLoader(IArchiveLoader* loader) =0; - - //! Returns the number of archives currently attached to the file system - virtual u32 getFileArchiveCount() const =0; - - //! Removes an archive from the file system. - /** This will close the archive and free any file handles, but will not close resources which have already - been loaded and are now cached, for example textures and meshes. - \param index: The index of the archive to remove - \return Returns true on success, false on failure */ - virtual bool removeFileArchive(u32 index) =0; - - //! Removes an archive from the file system. - /** This will close the archive and free any file handles, but will not close resources which have already - been loaded and are now cached, for example textures and meshes. - \param index: The index of the archive to remove - \return Returns true on success, false on failure */ - virtual bool removeFileArchive(const path& filename) =0; - - //! Changes the search order of attached archives. - /** - \param sourceIndex: The index of the archive to change - \param relative: The relative change in position, archives with a lower index are searched first */ - virtual bool moveFileArchive(u32 sourceIndex, s32 relative) =0; - - //! Returns the archive at a given index. - virtual IFileArchive* getFileArchive(u32 index) =0; - - //! Adds a zip archive to the file system. Deprecated! This function is provided for compatibility - /** with older versions of Irrlicht and may be removed in future versions, you should use - addFileArchive instead. - After calling this, the Irrlicht Engine will search and open files directly from this archive too. - This is useful for hiding data from the end user, speeding up file access and making it possible to - access for example Quake3 .pk3 files, which are no different than .zip files. - \param filename: Filename of the zip archive to add to the file system. - \param ignoreCase: If set to true, files in the archive can be accessed without - writing all letters in the right case. - \param ignorePaths: If set to true, files in the added archive can be accessed - without its complete path. - \return Returns true if the archive was added successfully, false if not. */ - virtual bool addZipFileArchive(const c8* filename, bool ignoreCase=true, bool ignorePaths=true) - { - return addFileArchive(filename, ignoreCase, ignorePaths, EFAT_ZIP); - } - - //! Adds an unzipped archive (or basedirectory with subdirectories..) to the file system. - /** Deprecated! This function is provided for compatibility with older versions of Irrlicht - and may be removed in future versions, you should use addFileArchive instead. - Useful for handling data which will be in a zip file - \param filename: Filename of the unzipped zip archive base directory to add to the file system. - \param ignoreCase: If set to true, files in the archive can be accessed without - writing all letters in the right case. - \param ignorePaths: If set to true, files in the added archive can be accessed - without its complete path. - \return Returns true if the archive was added successful, false if not. */ - virtual bool addFolderFileArchive(const c8* filename, bool ignoreCase=true, bool ignorePaths=true) - { - return addFileArchive(filename, ignoreCase, ignorePaths, EFAT_FOLDER); - } - - //! Adds a pak archive to the file system. - /** Deprecated! This function is provided for compatibility with older versions of Irrlicht - and may be removed in future versions, you should use addFileArchive instead. - After calling this, the Irrlicht Engine will search and open files directly from this archive too. - This is useful for hiding data from the end user, speeding up file access and making it possible to - access for example Quake2/KingPin/Hexen2 .pak files - \param filename: Filename of the pak archive to add to the file system. - \param ignoreCase: If set to true, files in the archive can be accessed without - writing all letters in the right case. - \param ignorePaths: If set to true, files in the added archive can be accessed - without its complete path.(should not use with Quake2 paks - \return Returns true if the archive was added successful, false if not. */ - virtual bool addPakFileArchive(const c8* filename, bool ignoreCase=true, bool ignorePaths=true) - { - return addFileArchive(filename, ignoreCase, ignorePaths, EFAT_PAK); - } - - //! Get the current working directory. - /** \return Current working directory as a string. */ - virtual const path& getWorkingDirectory() =0; - - //! Changes the current working directory. - /** \param newDirectory: A string specifying the new working directory. - The string is operating system dependent. Under Windows it has - the form "<drive>:\<directory>\<sudirectory>\<..>". An example would be: "C:\Windows\" - \return True if successful, otherwise false. */ - virtual bool changeWorkingDirectoryTo(const path& newDirectory) =0; - - //! Converts a relative path to an absolute (unique) path, resolving symbolic links if required - /** \param filename Possibly relative file or directory name to query. - \result Absolute filename which points to the same file. */ - virtual path getAbsolutePath(const path& filename) const =0; - - //! Returns the directory a file is located in. - /** \param filename: The file to get the directory from. - \return String containing the directory of the file. */ - virtual path getFileDir(const path& filename) const =0; - - //! Returns the base part of a filename, i.e. the name without the directory part. - /** If no directory is prefixed, the full name is returned. - \param filename: The file to get the basename from - \param keepExtension True if filename with extension is returned otherwise everything - after the final '.' is removed as well. */ - virtual path getFileBasename(const path& filename, bool keepExtension=true) const =0; - - //! flatten a path and file name for example: "/you/me/../." becomes "/you" - virtual path& flattenFilename(path& directory, const path& root="/") const =0; - - //! Creates a list of files and directories in the current working directory and returns it. - /** \return a Pointer to the created IFileList is returned. After the list has been used - it has to be deleted using its IFileList::drop() method. - See IReferenceCounted::drop() for more information. */ - virtual IFileList* createFileList() =0; - - //! Set the active type of file system. - virtual EFileSystemType setFileListSystem(EFileSystemType listType) =0; - - //! Determines if a file exists and could be opened. - /** \param filename is the string identifying the file which should be tested for existence. - \return Returns true if file exists, and false if it does not exist or an error occured. */ - virtual bool existFile(const path& filename) const =0; - - //! Creates a XML Reader from a file which returns all parsed strings as wide characters (wchar_t*). - /** Use createXMLReaderUTF8() if you prefer char* instead of wchar_t*. See IIrrXMLReader for - more information on how to use the parser. - \return 0, if file could not be opened, otherwise a pointer to the created - IXMLReader is returned. After use, the reader - has to be deleted using its IXMLReader::drop() method. - See IReferenceCounted::drop() for more information. */ - virtual IXMLReader* createXMLReader(const path& filename) =0; - - //! Creates a XML Reader from a file which returns all parsed strings as wide characters (wchar_t*). - /** Use createXMLReaderUTF8() if you prefer char* instead of wchar_t*. See IIrrXMLReader for - more information on how to use the parser. - \return 0, if file could not be opened, otherwise a pointer to the created - IXMLReader is returned. After use, the reader - has to be deleted using its IXMLReader::drop() method. - See IReferenceCounted::drop() for more information. */ - virtual IXMLReader* createXMLReader(IReadFile* file) =0; - - //! Creates a XML Reader from a file which returns all parsed strings as ASCII/UTF-8 characters (char*). - /** Use createXMLReader() if you prefer wchar_t* instead of char*. See IIrrXMLReader for - more information on how to use the parser. - \return 0, if file could not be opened, otherwise a pointer to the created - IXMLReader is returned. After use, the reader - has to be deleted using its IXMLReaderUTF8::drop() method. - See IReferenceCounted::drop() for more information. */ - virtual IXMLReaderUTF8* createXMLReaderUTF8(const path& filename) =0; - - //! Creates a XML Reader from a file which returns all parsed strings as ASCII/UTF-8 characters (char*). - /** Use createXMLReader() if you prefer wchar_t* instead of char*. See IIrrXMLReader for - more information on how to use the parser. - \return 0, if file could not be opened, otherwise a pointer to the created - IXMLReader is returned. After use, the reader - has to be deleted using its IXMLReaderUTF8::drop() method. - See IReferenceCounted::drop() for more information. */ - virtual IXMLReaderUTF8* createXMLReaderUTF8(IReadFile* file) =0; - - //! Creates a XML Writer from a file. - /** \return 0, if file could not be opened, otherwise a pointer to the created - IXMLWriter is returned. After use, the reader - has to be deleted using its IXMLWriter::drop() method. - See IReferenceCounted::drop() for more information. */ - virtual IXMLWriter* createXMLWriter(const path& filename) =0; - - //! Creates a XML Writer from a file. - /** \return 0, if file could not be opened, otherwise a pointer to the created - IXMLWriter is returned. After use, the reader - has to be deleted using its IXMLWriter::drop() method. - See IReferenceCounted::drop() for more information. */ - virtual IXMLWriter* createXMLWriter(IWriteFile* file) =0; - - //! Creates a new empty collection of attributes, usable for serialization and more. - /** \param driver: Video driver to be used to load textures when specified as attribute values. - Can be null to prevent automatic texture loading by attributes. - \return Pointer to the created object. - If you no longer need the object, you should call IAttributes::drop(). - See IReferenceCounted::drop() for more information. */ - virtual IAttributes* createEmptyAttributes(video::IVideoDriver* driver=0) =0; -}; - - -} // end namespace io -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IGPUProgrammingServices.h b/irrlicht-1.6/include/IGPUProgrammingServices.h deleted file mode 100644 index 42a574ce6..000000000 --- a/irrlicht-1.6/include/IGPUProgrammingServices.h +++ /dev/null @@ -1,309 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GPU_PROGRAMMING_SERVICES_H_INCLUDED__ -#define __I_GPU_PROGRAMMING_SERVICES_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "SMaterial.h" -#include "path.h" - -namespace irr -{ - -namespace io -{ - class IReadFile; -} // end namespace io - -namespace video -{ - -class IVideoDriver; -class IShaderConstantSetCallBack; - -//! Compile target enumeration for the addHighLevelShaderMaterial() method. -enum E_VERTEX_SHADER_TYPE -{ - EVST_VS_1_1 = 0, - EVST_VS_2_0, - EVST_VS_2_a, - EVST_VS_3_0, - - //! This is not a type, but a value indicating how much types there are. - EVST_COUNT -}; - -//! Names for all vertex shader types, each entry corresponds to a E_VERTEX_SHADER_TYPE entry. -const c8* const VERTEX_SHADER_TYPE_NAMES[] = { - "vs_1_1", - "vs_2_0", - "vs_2_a", - "vs_3_0", - 0 }; - -//! Compile target enumeration for the addHighLevelShaderMaterial() method. -enum E_PIXEL_SHADER_TYPE -{ - EPST_PS_1_1 = 0, - EPST_PS_1_2, - EPST_PS_1_3, - EPST_PS_1_4, - EPST_PS_2_0, - EPST_PS_2_a, - EPST_PS_2_b, - EPST_PS_3_0, - - //! This is not a type, but a value indicating how much types there are. - EPST_COUNT -}; - -//! Names for all pixel shader types, each entry corresponds to a E_PIXEL_SHADER_TYPE entry. -const c8* const PIXEL_SHADER_TYPE_NAMES[] = { - "ps_1_1", - "ps_1_2", - "ps_1_3", - "ps_1_4", - "ps_2_0", - "ps_2_a", - "ps_2_b", - "ps_3_0", - 0 }; - -//! Interface making it possible to create and use programs running on the GPU. -class IGPUProgrammingServices -{ -public: - - //! Destructor - virtual ~IGPUProgrammingServices() {} - - //! Adds a new high-level shading material renderer to the VideoDriver. - /** Currently only HLSL/D3D9 and GLSL/OpenGL are supported. - \param vertexShaderProgram: String containing the source of the vertex - shader program. This can be 0 if no vertex program shall be used. - \param vertexShaderEntryPointName: Name of the entry function of the - vertexShaderProgram - \param vsCompileTarget: Vertex shader version where the high level - shader shall be compiled to. - \param pixelShaderProgram: String containing the source of the pixel - shader program. This can be 0 if no pixel shader shall be used. - \param pixelShaderEntryPointName: Entry name of the function of the - pixelShaderEntryPointName - \param psCompileTarget: Pixel shader version where the high level - shader shall be compiled to. - \param callback: Pointer to an implementation of - IShaderConstantSetCallBack in which you can set the needed vertex and - pixel shader program constants. Set this to 0 if you don't need this. - \param baseMaterial: Base material which renderstates will be used to - shade the material. - \param userData: a user data int. This int can be set to any value and - will be set as parameter in the callback method when calling - OnSetConstants(). In this way it is easily possible to use the same - callback method for multiple materials and distinguish between them - during the call. - \return Returns the number of the material type which can be set in - SMaterial::MaterialType to use the renderer. -1 is returned if an - error occured, e.g. if a vertex or pixel shader program could not be - compiled or a compile target is not reachable. The error strings are - then printed to the error log and can be catched with a custom event - receiver. */ - virtual s32 addHighLevelShaderMaterial( - const c8* vertexShaderProgram, - const c8* vertexShaderEntryPointName = "main", - E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1, - const c8* pixelShaderProgram = 0, - const c8* pixelShaderEntryPointName = "main", - E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1, - IShaderConstantSetCallBack* callback = 0, - E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, - s32 userData = 0 ) = 0; - - //! Like IGPUProgrammingServices::addShaderMaterial(), but loads from files. - /** \param vertexShaderProgram: Text file containing the source of the - * vertex shader program. - Set to 0 if no shader shall be created. - \param vertexShaderEntryPointName: Name of the entry function of the - vertexShaderProgram - \param vsCompileTarget: Vertex shader version where the high level - shader shall be compiled to. - \param pixelShaderProgram: Text file containing the source of the pixel - shader program. Set to 0 if no shader shall be created. - \param vertexShaderEntryPointName: Name of the entry function of the - vertexShaderProgram - \param vsCompileTarget: Vertex shader version where the high level - shader shall be compiled to. - \param pixelShaderProgram: String containing the source of the pixel - shader program. This can be 0 if no pixel shader shall be used. - \param pixelShaderEntryPointName: Entry name of the function of the - pixelShaderEntryPointName - \param psCompileTarget: Pixel shader version where the high level - shader shall be compiled to. - \param callback: Pointer to an implementation of - IShaderConstantSetCallBack in which you can set the needed vertex and - pixel shader program constants. Set this to 0 if you don't need this. - \param baseMaterial: Base material which renderstates will be used to - shade the material. - \param userData: a user data int. This int can be set to any value and - will be set as parameter in the callback method when calling - OnSetConstants(). In this way it is easily possible to use the same - callback method for multiple materials and distinguish between them - during the call. - \return Returns the number of the material type which can be set in - SMaterial::MaterialType to use the renderer. -1 is returned if an - error occured, e.g. if a vertex or pixel shader program could not be - compiled or a compile target is not reachable. The error strings are - then printed to the error log and can be catched with a custom event - receiver. */ - virtual s32 addHighLevelShaderMaterialFromFiles( - const io::path& vertexShaderProgramFileName, - const c8* vertexShaderEntryPointName = "main", - E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1, - const io::path& pixelShaderProgramFileName = "", - const c8* pixelShaderEntryPointName = "main", - E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1, - IShaderConstantSetCallBack* callback = 0, - E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, - s32 userData = 0) = 0; - - - //! Like IGPUProgrammingServices::addShaderMaterial(), but loads from files. - /** \param vertexShaderProgram: Text file handle containing the source - * of the vertex shader program. - Set to 0 if no shader shall be created. - \param vertexShaderEntryPointName: Name of the entry function of the - vertexShaderProgram - \param vsCompileTarget: Vertex shader version where the high level - shader shall be compiled to. - \param pixelShaderProgram: Text file containing the source of the pixel - shader program. Set to - \param pixelShaderProgram: Text file handle containing the source of - the pixel shader program. Set to 0 if no shader shall be created. - \param pixelShaderEntryPointName: Entry name of the function of the - pixelShaderEntryPointName - \param psCompileTarget: Pixel shader version where the high level - shader shall be compiled to. - \param callback: Pointer to an implementation of - IShaderConstantSetCallBack in which you can set the needed vertex and - pixel shader program constants. Set this to 0 if you don't need this. - \param baseMaterial: Base material which renderstates will be used to - shade the material. - \param userData: a user data int. This int can be set to any value and - will be set as parameter in the callback method when calling - OnSetConstants(). In this way it is easily possible to use the same - callback method for multiple materials and distinguish between them - during the call. - \return Returns the number of the material type which can be set in - SMaterial::MaterialType to use the renderer. -1 is returned if an - error occured, e.g. if a vertex or pixel shader program could not be - compiled or a compile target is not reachable. The error strings are - then printed to the error log and can be catched with a custom event - receiver. */ - virtual s32 addHighLevelShaderMaterialFromFiles( - io::IReadFile* vertexShaderProgram, - const c8* vertexShaderEntryPointName = "main", - E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1, - io::IReadFile* pixelShaderProgram = 0, - const c8* pixelShaderEntryPointName = "main", - E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1, - IShaderConstantSetCallBack* callback = 0, - E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, - s32 userData = 0) = 0; - - //! Adds a new ASM shader material renderer to the VideoDriver - /** Note that it is a good idea to call IVideoDriver::queryFeature() in - advance to check if the IVideoDriver supports the vertex and/or pixel - shader version your are using. - - The material is added to the VideoDriver like with - IVideoDriver::addMaterialRenderer() and can be used like it had been - added with that method. - \param vertexShaderProgram: String containing the source of the vertex - shader program. This can be 0 if no vertex program shall be used. - - For DX8 programs, the will always input registers look like this: v0: - position, v1: normal, v2: color, v3: texture cooridnates, v4: texture - coordinates 2 if available. - - For DX9 programs, you can manually set the registers using the dcl_ - statements. - \param pixelShaderProgram: String containing the source of the pixel - shader program. This can be 0 if you don't want to use a pixel shader. - \param callback: Pointer to an implementation of - IShaderConstantSetCallBack in which you can set the needed vertex and - pixel shader program constants. Set this to 0 if you don't need this. - \param baseMaterial: Base material which renderstates will be used to - shade the material. - \param userData: a user data int. This int can be set to any value and - will be set as parameter in the callback method when calling - OnSetConstants(). In this way it is easily possible to use the same - callback method for multiple materials and distinguish between them - during the call. - \return Returns the number of the material type which can be set in - SMaterial::MaterialType to use the renderer. -1 is returned if an - error occured. -1 is returned for example if a vertex or pixel shader - program could not be compiled, the error strings are then printed out - into the error log, and can be catched with a custom event receiver. */ - virtual s32 addShaderMaterial(const c8* vertexShaderProgram = 0, - const c8* pixelShaderProgram = 0, - IShaderConstantSetCallBack* callback = 0, - E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, - s32 userData = 0) = 0; - - //! Like IGPUProgrammingServices::addShaderMaterial(), but loads from files. - /** \param vertexShaderProgram: Text file containing the source of the - vertex shader program. Set to 0 if no shader shall be created. - \param pixelShaderProgram: Text file containing the source of the pixel - shader program. Set to 0 if no shader shall be created. - \param callback: Pointer to an IShaderConstantSetCallback object to - which the OnSetConstants function is called. - \param baseMaterial: baseMaterial - \param userData: a user data int. This int can be set to any value and - will be set as parameter in the callback method when calling - OnSetConstants(). In this way it is easily possible to use the same - callback method for multiple materials and distinguish between them - during the call. - \return Returns the number of the material type which can be set in - SMaterial::MaterialType to use the renderer. -1 is returned if an - error occured. -1 is returned for example if a vertex or pixel shader - program could not be compiled, the error strings are then printed out - into the error log, and can be catched with a custom event receiver. */ - virtual s32 addShaderMaterialFromFiles(io::IReadFile* vertexShaderProgram, - io::IReadFile* pixelShaderProgram, - IShaderConstantSetCallBack* callback = 0, - E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, - s32 userData = 0) = 0; - - //! Like IGPUProgrammingServices::addShaderMaterial(), but loads from files. - /** \param vertexShaderProgramFileName: Text file name containing the - source of the vertex shader program. Set to 0 if no shader shall be - created. - \param pixelShaderProgramFileName: Text file name containing the source - of the pixel shader program. Set to 0 if no shader shall be created. - \param callback: Pointer to an IShaderConstantSetCallback object on - which the OnSetConstants function is called. - \param baseMaterial: baseMaterial - \param userData: a user data int. This int can be set to any value and - will be set as parameter in the callback method when calling - OnSetConstants(). In this way it is easily possible to use the same - callback method for multiple materials and distinguish between them - during the call. - \return Returns the number of the material type which can be set in - SMaterial::MaterialType to use the renderer. -1 is returned if an - error occured. -1 is returned for example if a vertex or pixel shader - program could not be compiled, the error strings are then printed out - into the error log, and can be catched with a custom event receiver. */ - virtual s32 addShaderMaterialFromFiles(const io::path& vertexShaderProgramFileName, - const io::path& pixelShaderProgramFileName, - IShaderConstantSetCallBack* callback = 0, - E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, - s32 userData = 0) = 0; -}; - - -} // end namespace video -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IGUIButton.h b/irrlicht-1.6/include/IGUIButton.h deleted file mode 100644 index 16d805052..000000000 --- a/irrlicht-1.6/include/IGUIButton.h +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_BUTTON_H_INCLUDED__ -#define __I_GUI_BUTTON_H_INCLUDED__ - -#include "IGUIElement.h" - -namespace irr -{ - -namespace video -{ - class ITexture; -} // end namespace video - -namespace gui -{ - class IGUIFont; - class IGUISpriteBank; - - enum EGUI_BUTTON_STATE - { - //! The button is not pressed - EGBS_BUTTON_UP=0, - //! The button is currently pressed down - EGBS_BUTTON_DOWN, - //! The mouse cursor is over the button - EGBS_BUTTON_MOUSE_OVER, - //! The mouse cursor is not over the button - EGBS_BUTTON_MOUSE_OFF, - //! The button has the focus - EGBS_BUTTON_FOCUSED, - //! The button doesn't have the focus - EGBS_BUTTON_NOT_FOCUSED, - //! not used, counts the number of enumerated items - EGBS_COUNT - }; - - //! Names for gui button state icons - const c8* const GUIButtonStateNames[] = - { - "buttonUp", - "buttonDown", - "buttonMouseOver", - "buttonMouseOff", - "buttonFocused", - "buttonNotFocused", - 0, - 0, - }; - - //! GUI Button interface. - class IGUIButton : public IGUIElement - { - public: - - //! constructor - IGUIButton(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle) - : IGUIElement(EGUIET_BUTTON, environment, parent, id, rectangle) {} - - //! Sets another skin independent font. - /** If this is set to zero, the button uses the font of the skin. - \param font: New font to set. */ - virtual void setOverrideFont(IGUIFont* font=0) = 0; - - //! Sets an image which should be displayed on the button when it is in normal state. - /** \param image: Image to be displayed */ - virtual void setImage(video::ITexture* image=0) = 0; - - //! Sets a background image for the button when it is in normal state. - /** \param image: Texture containing the image to be displayed - \param pos: Position in the texture, where the image is located */ - virtual void setImage(video::ITexture* image, const core::rect<s32>& pos) = 0; - - //! Sets a background image for the button when it is in pressed state. - /** If no images is specified for the pressed state via - setPressedImage(), this image is also drawn in pressed state. - \param image: Image to be displayed */ - virtual void setPressedImage(video::ITexture* image=0) = 0; - - //! Sets an image which should be displayed on the button when it is in pressed state. - /** \param image: Texture containing the image to be displayed - \param pos: Position in the texture, where the image is located */ - virtual void setPressedImage(video::ITexture* image, const core::rect<s32>& pos) = 0; - - //! Sets the sprite bank used by the button - virtual void setSpriteBank(IGUISpriteBank* bank=0) = 0; - - //! Sets the animated sprite for a specific button state - /** \param index: Number of the sprite within the sprite bank, use -1 for no sprite - \param state: State of the button to set the sprite for - \param index: The sprite number from the current sprite bank - \param color: The color of the sprite - \param loop: True if the animation should loop, false if not - */ - virtual void setSprite(EGUI_BUTTON_STATE state, s32 index, - video::SColor color=video::SColor(255,255,255,255), bool loop=false) = 0; - - //! Sets if the button should behave like a push button. - /** Which means it can be in two states: Normal or Pressed. With a click on the button, - the user can change the state of the button. */ - virtual void setIsPushButton(bool isPushButton=true) = 0; - - //! Sets the pressed state of the button if this is a pushbutton - virtual void setPressed(bool pressed=true) = 0; - - //! Returns if the button is currently pressed - virtual bool isPressed() const = 0; - - //! Sets if the alpha channel should be used for drawing background images on the button (default is false) - virtual void setUseAlphaChannel(bool useAlphaChannel=true) = 0; - - //! Returns if the alpha channel should be used for drawing background images on the button - virtual bool isAlphaChannelUsed() const = 0; - - //! Returns whether the button is a push button - virtual bool isPushButton() const = 0; - - //! Sets if the button should use the skin to draw its border and button face (default is true) - virtual void setDrawBorder(bool border=true) = 0; - - //! Returns if the border and button face are being drawn using the skin - virtual bool isDrawingBorder() const = 0; - - //! Sets if the button should scale the button images to fit - virtual void setScaleImage(bool scaleImage=true) = 0; - - //! Checks whether the button scales the used images - virtual bool isScalingImage() const = 0; - }; - - -} // end namespace gui -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IGUICheckBox.h b/irrlicht-1.6/include/IGUICheckBox.h deleted file mode 100644 index d398ad696..000000000 --- a/irrlicht-1.6/include/IGUICheckBox.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_CHECKBOX_H_INCLUDED__ -#define __I_GUI_CHECKBOX_H_INCLUDED__ - -#include "IGUIElement.h" - -namespace irr -{ -namespace gui -{ - - //! GUI Check box interface. - class IGUICheckBox : public IGUIElement - { - public: - - //! constructor - IGUICheckBox(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle) - : IGUIElement(EGUIET_CHECK_BOX, environment, parent, id, rectangle) {} - - //! Set if box is checked. - virtual void setChecked(bool checked) = 0; - - //! Returns true if box is checked. - virtual bool isChecked() const = 0; - }; - -} // end namespace gui -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IGUIColorSelectDialog.h b/irrlicht-1.6/include/IGUIColorSelectDialog.h deleted file mode 100644 index 342e584f6..000000000 --- a/irrlicht-1.6/include/IGUIColorSelectDialog.h +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_COLOR_SELECT_DIALOG_H_INCLUDED__ -#define __I_GUI_COLOR_SELECT_DIALOG_H_INCLUDED__ - -#include "IGUIElement.h" - -namespace irr -{ -namespace gui -{ - - //! Standard file chooser dialog. - class IGUIColorSelectDialog : public IGUIElement - { - public: - - //! constructor - IGUIColorSelectDialog(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle) - : IGUIElement(EGUIET_COLOR_SELECT_DIALOG, environment, parent, id, rectangle) {} - }; - - -} // end namespace gui -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IGUIComboBox.h b/irrlicht-1.6/include/IGUIComboBox.h deleted file mode 100644 index 57af3c4ab..000000000 --- a/irrlicht-1.6/include/IGUIComboBox.h +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_COMBO_BOX_H_INCLUDED__ -#define __I_GUI_COMBO_BOX_H_INCLUDED__ - -#include "IGUIElement.h" - -namespace irr -{ -namespace gui -{ - - //! Combobox widget - class IGUIComboBox : public IGUIElement - { - public: - - //! constructor - IGUIComboBox(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle) - : IGUIElement(EGUIET_COMBO_BOX, environment, parent, id, rectangle) {} - - //! Returns amount of items in box - virtual u32 getItemCount() const = 0; - - //! Returns string of an item. the idx may be a value from 0 to itemCount-1 - virtual const wchar_t* getItem(u32 idx) const = 0; - - //! Returns item data of an item. the idx may be a value from 0 to itemCount-1 - virtual u32 getItemData(u32 idx) const = 0; - - //! Returns index based on item data - virtual s32 getIndexForItemData(u32 data ) const = 0; - - //! Adds an item and returns the index of it - virtual u32 addItem(const wchar_t* text, u32 data = 0) = 0; - - //! Removes an item from the combo box. - /** Warning. This will change the index of all following items */ - virtual void removeItem(u32 idx) = 0; - - //! Deletes all items in the combo box - virtual void clear() = 0; - - //! Returns id of selected item. returns -1 if no item is selected. - virtual s32 getSelected() const = 0; - - //! Sets the selected item. Set this to -1 if no item should be selected - virtual void setSelected(s32 idx) = 0; - - //! Sets text justification of the text area - /** \param horizontal: EGUIA_UPPERLEFT for left justified (default), - EGUIA_LOWEERRIGHT for right justified, or EGUIA_CENTER for centered text. - \param vertical: EGUIA_UPPERLEFT to align with top edge, - EGUIA_LOWEERRIGHT for bottom edge, or EGUIA_CENTER for centered text (default). */ - virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical) = 0; - }; - - -} // end namespace gui -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IGUIContextMenu.h b/irrlicht-1.6/include/IGUIContextMenu.h deleted file mode 100644 index 5d8cb3c2f..000000000 --- a/irrlicht-1.6/include/IGUIContextMenu.h +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_CONTEXT_MENU_H_INCLUDED__ -#define __I_GUI_CONTEXT_MENU_H_INCLUDED__ - -#include "IGUIElement.h" - -namespace irr -{ -namespace gui -{ - - //! GUI Context menu interface. - class IGUIContextMenu : public IGUIElement - { - public: - - //! constructor - IGUIContextMenu(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle) - : IGUIElement(EGUIET_CONTEXT_MENU, environment, parent, id, rectangle) {} - - //! Get amount of menu items - virtual u32 getItemCount() const = 0; - - //! Adds a menu item. - /** \param text: Text of menu item. Set this to 0 to create - an separator instead of a real item, which is the same like - calling addSeparator(); - \param commandId: Command id of menu item, a simple id you may - set to whatever you want. - \param enabled: Specifies if the menu item should be enabled. - \param hasSubMenu: Set this to true if there should be a submenu - at this item. You can acess this submenu via getSubMenu(). - \param checked: Specifies if the menu item should be initially checked. - \return Returns the index of the new item */ - virtual u32 addItem(const wchar_t* text, s32 commandId=-1, bool enabled=true, - bool hasSubMenu=false, bool checked=false) = 0; - - //! Adds a separator item to the menu - virtual void addSeparator() = 0; - - //! Get text of the menu item. - /** \param idx: Zero based index of the menu item */ - virtual const wchar_t* getItemText(u32 idx) const = 0; - - //! Sets text of the menu item. - /** \param idx: Zero based index of the menu item - \param text: New text of the item. */ - virtual void setItemText(u32 idx, const wchar_t* text) = 0; - - //! Check if a menu item is enabled - /** \param idx: Zero based index of the menu item */ - virtual bool isItemEnabled(u32 idx) const = 0; - - //! Sets if the menu item should be enabled. - /** \param idx: Zero based index of the menu item - \param enabled: True if it is enabled, otherwise false. */ - virtual void setItemEnabled(u32 idx, bool enabled) = 0; - - //! Sets if the menu item should be checked. - /** \param idx: Zero based index of the menu item - \param enabled: True if it is enabled, otherwise false. */ - virtual void setItemChecked(u32 idx, bool enabled) = 0; - - //! Check if a menu item is checked - /** \param idx: Zero based index of the menu item */ - virtual bool isItemChecked(u32 idx) const = 0; - - //! Removes a menu item - /** \param idx: Zero based index of the menu item */ - virtual void removeItem(u32 idx) = 0; - - //! Removes all menu items - virtual void removeAllItems() = 0; - - //! Get the selected item in the menu - /** \return Index of the selected item, -1 if none selected. */ - virtual s32 getSelectedItem() const = 0; - - //! Get the command id of a menu item - /** \param idx: Zero based index of the menu item */ - virtual s32 getItemCommandId(u32 idx) const = 0; - - //! Sets the command id of a menu item - /** \param idx: Zero based index of the menu item - \param id: Command id of menu item, a simple id you may - set to whatever you want. */ - virtual void setItemCommandId(u32 idx, s32 id) = 0; - - //! Get a pointer to the submenu of an item. - /** 0 is returned if there is no submenu - \param idx: Zero based index of the menu item - \return Returns a pointer to the submenu of an item. */ - virtual IGUIContextMenu* getSubMenu(u32 idx) const = 0; - }; - -} // end namespace gui -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IGUIEditBox.h b/irrlicht-1.6/include/IGUIEditBox.h deleted file mode 100644 index 40f9acfc9..000000000 --- a/irrlicht-1.6/include/IGUIEditBox.h +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_EDIT_BOX_H_INCLUDED__ -#define __I_GUI_EDIT_BOX_H_INCLUDED__ - -#include "IGUIElement.h" -#include "SColor.h" - -namespace irr -{ -namespace gui -{ - class IGUIFont; - - //! Single line edit box for editing simple text. - class IGUIEditBox : public IGUIElement - { - public: - - //! constructor - IGUIEditBox(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle) - : IGUIElement(EGUIET_EDIT_BOX, environment, parent, id, rectangle) {} - - //! Sets another skin independent font. - /** If this is set to zero, the button uses the font of the skin. - \param font: New font to set. */ - virtual void setOverrideFont(IGUIFont* font=0) = 0; - - //! Sets another color for the text. - /** If set, the edit box does not use the EGDC_BUTTON_TEXT color defined - in the skin, but the set color instead. You don't need to call - IGUIEditBox::enableOverrrideColor(true) after this, this is done - by this function. - If you set a color, and you want the text displayed with the color - of the skin again, call IGUIEditBox::enableOverrideColor(false); - \param color: New color of the text. */ - virtual void setOverrideColor(video::SColor color) = 0; - - //! Sets if the text should use the overide color or the color in the gui skin. - /** \param enable: If set to true, the override color, which can be set - with IGUIEditBox::setOverrideColor is used, otherwise the - EGDC_BUTTON_TEXT color of the skin. */ - virtual void enableOverrideColor(bool enable) = 0; - - //! Turns the border on or off - /** \param border: true if you want the border to be drawn, false if not */ - virtual void setDrawBorder(bool border) = 0; - - //! Sets text justification mode - /** \param horizontal: EGUIA_UPPERLEFT for left justified (default), - EGUIA_LOWEERRIGHT for right justified, or EGUIA_CENTER for centered text. - \param vertical: EGUIA_UPPERLEFT to align with top edge, - EGUIA_LOWEERRIGHT for bottom edge, or EGUIA_CENTER for centered text (default). */ - virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical) = 0; - - //! Enables or disables word wrap. - /** \param enable: If set to true, words going over one line are - broken to the next line. */ - virtual void setWordWrap(bool enable) = 0; - - //! Checks if word wrap is enabled - /** \return true if word wrap is enabled, false otherwise */ - virtual bool isWordWrapEnabled() const = 0; - - //! Enables or disables newlines. - /** \param enable: If set to true, the EGET_EDITBOX_ENTER event will not be fired, - instead a newline character will be inserted. */ - virtual void setMultiLine(bool enable) = 0; - - //! Checks if multi line editing is enabled - /** \return true if mult-line is enabled, false otherwise */ - virtual bool isMultiLineEnabled() const = 0; - - //! Enables or disables automatic scrolling with cursor position - /** \param enable: If set to true, the text will move around with the cursor position */ - virtual void setAutoScroll(bool enable) = 0; - - //! Checks to see if automatic scrolling is enabled - /** \return true if automatic scrolling is enabled, false if not */ - virtual bool isAutoScrollEnabled() const = 0; - - //! Sets whether the edit box is a password box. Setting this to true will - /** disable MultiLine, WordWrap and the ability to copy with ctrl+c or ctrl+x - \param passwordBox: true to enable password, false to disable - \param passwordChar: the character that is displayed instead of letters */ - virtual void setPasswordBox(bool passwordBox, wchar_t passwordChar = L'*') = 0; - - //! Returns true if the edit box is currently a password box. - virtual bool isPasswordBox() const = 0; - - //! Gets the size area of the text in the edit box - /** \return The size in pixels of the text */ - virtual core::dimension2du getTextDimension() = 0; - - //! Sets the maximum amount of characters which may be entered in the box. - /** \param max: Maximum amount of characters. If 0, the character amount is - infinity. */ - virtual void setMax(u32 max) = 0; - - //! Returns maximum amount of characters, previously set by setMax(); - virtual u32 getMax() const = 0; - }; - - -} // end namespace gui -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IGUIElement.h b/irrlicht-1.6/include/IGUIElement.h deleted file mode 100644 index 818e3afb2..000000000 --- a/irrlicht-1.6/include/IGUIElement.h +++ /dev/null @@ -1,938 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_ELEMENT_H_INCLUDED__ -#define __I_GUI_ELEMENT_H_INCLUDED__ - -#include "IAttributeExchangingObject.h" -#include "irrList.h" -#include "rect.h" -#include "irrString.h" -#include "IEventReceiver.h" -#include "EGUIElementTypes.h" -#include "EGUIAlignment.h" -#include "IAttributes.h" - -namespace irr -{ -namespace gui -{ - -class IGUIEnvironment; - -//! Base class of all GUI elements. -class IGUIElement : public virtual io::IAttributeExchangingObject, public IEventReceiver -{ -public: - - //! Constructor - IGUIElement(EGUI_ELEMENT_TYPE type, IGUIEnvironment* environment, IGUIElement* parent, - s32 id, core::rect<s32> rectangle) - : Parent(0), RelativeRect(rectangle), AbsoluteRect(rectangle), - AbsoluteClippingRect(rectangle), DesiredRect(rectangle), - MaxSize(0,0), MinSize(1,1), IsVisible(true), IsEnabled(true), - IsSubElement(false), NoClip(false), ID(id), IsTabStop(false), TabOrder(-1), IsTabGroup(false), - AlignLeft(EGUIA_UPPERLEFT), AlignRight(EGUIA_UPPERLEFT), AlignTop(EGUIA_UPPERLEFT), AlignBottom(EGUIA_UPPERLEFT), - Environment(environment), Type(type) - { - #ifdef _DEBUG - setDebugName("IGUIElement"); - #endif - - // if we were given a parent to attach to - if (parent) - parent->addChild(this); - - } - - - //! Destructor - virtual ~IGUIElement() - { - // delete all children - core::list<IGUIElement*>::Iterator it = Children.begin(); - for (; it != Children.end(); ++it) - { - (*it)->Parent = 0; - (*it)->drop(); - } - } - - - //! Returns parent of this element. - IGUIElement* getParent() const - { - return Parent; - } - - - //! Returns the relative rectangle of this element. - core::rect<s32> getRelativePosition() const - { - return RelativeRect; - } - - - //! Sets the relative rectangle of this element. - /** \param r The absolute position to set */ - void setRelativePosition(const core::rect<s32>& r) - { - if (Parent) - { - const core::rect<s32>& r2 = Parent->getAbsolutePosition(); - - core::dimension2df d((f32)(r2.getSize().Width), (f32)(r2.getSize().Height)); - - if (AlignLeft == EGUIA_SCALE) - ScaleRect.UpperLeftCorner.X = (f32)r.UpperLeftCorner.X / d.Width; - if (AlignRight == EGUIA_SCALE) - ScaleRect.LowerRightCorner.X = (f32)r.LowerRightCorner.X / d.Width; - if (AlignTop == EGUIA_SCALE) - ScaleRect.UpperLeftCorner.Y = (f32)r.UpperLeftCorner.Y / d.Height; - if (AlignBottom == EGUIA_SCALE) - ScaleRect.LowerRightCorner.Y = (f32)r.LowerRightCorner.Y / d.Height; - } - - DesiredRect = r; - updateAbsolutePosition(); - } - - //! Sets the relative rectangle of this element, maintaining its current width and height - /** \param position The new relative position to set. Width and height will not be changed. */ - void setRelativePosition(const core::position2di & position) - { - const core::dimension2di mySize = RelativeRect.getSize(); - const core::rect<s32> rectangle(position.X, position.Y, - position.X + mySize.Width, position.Y + mySize.Height); - setRelativePosition(rectangle); - } - - - //! Sets the relative rectangle of this element as a proportion of its parent's area. - /** \note This method used to be 'void setRelativePosition(const core::rect<f32>& r)' - \param r The rectangle to set, interpreted as a proportion of the parent's area. - Meaningful values are in the range [0...1], unless you intend this element to spill - outside its parent. */ - void setRelativePositionProportional(const core::rect<f32>& r) - { - if (!Parent) - return; - - const core::dimension2di& d = Parent->getAbsolutePosition().getSize(); - - DesiredRect = core::rect<s32>( - core::floor32((f32)d.Width * r.UpperLeftCorner.X), - core::floor32((f32)d.Height * r.UpperLeftCorner.Y), - core::floor32((f32)d.Width * r.LowerRightCorner.X), - core::floor32((f32)d.Height * r.LowerRightCorner.Y)); - - ScaleRect = r; - - updateAbsolutePosition(); - } - - - //! Gets the absolute rectangle of this element - core::rect<s32> getAbsolutePosition() const - { - return AbsoluteRect; - } - - - //! Returns the visible area of the element. - core::rect<s32> getAbsoluteClippingRect() const - { - return AbsoluteClippingRect; - } - - - //! Sets whether the element will ignore its parent's clipping rectangle - /** \param noClip If true, the element will not be clipped by its parent's clipping rectangle. */ - void setNotClipped(bool noClip) - { - NoClip = noClip; - updateAbsolutePosition(); - } - - - //! Gets whether the element will ignore its parent's clipping rectangle - /** \return true if the element is not clipped by its parent's clipping rectangle. */ - bool isNotClipped() const - { - return NoClip; - } - - - //! Sets the maximum size allowed for this element - /** If set to 0,0, there is no maximum size */ - void setMaxSize(core::dimension2du size) - { - MaxSize = size; - updateAbsolutePosition(); - } - - - //! Sets the minimum size allowed for this element - void setMinSize(core::dimension2du size) - { - MinSize = size; - if (MinSize.Width < 1) - MinSize.Width = 1; - if (MinSize.Height < 1) - MinSize.Height = 1; - updateAbsolutePosition(); - } - - - void setAlignment(EGUI_ALIGNMENT left, EGUI_ALIGNMENT right, EGUI_ALIGNMENT top, EGUI_ALIGNMENT bottom) - { - AlignLeft = left; - AlignRight = right; - AlignTop = top; - AlignBottom = bottom; - - if (Parent) - { - core::rect<s32> r(Parent->getAbsolutePosition()); - - core::dimension2df d((f32)r.getSize().Width, (f32)r.getSize().Height); - - if (AlignLeft == EGUIA_SCALE) - ScaleRect.UpperLeftCorner.X = (f32)DesiredRect.UpperLeftCorner.X / d.Width; - if (AlignRight == EGUIA_SCALE) - ScaleRect.LowerRightCorner.X = (f32)DesiredRect.LowerRightCorner.X / d.Width; - if (AlignTop == EGUIA_SCALE) - ScaleRect.UpperLeftCorner.Y = (f32)DesiredRect.UpperLeftCorner.Y / d.Height; - if (AlignBottom == EGUIA_SCALE) - ScaleRect.LowerRightCorner.Y = (f32)DesiredRect.LowerRightCorner.Y / d.Height; - } - } - - - //! Updates the absolute position. - virtual void updateAbsolutePosition() - { - core::rect<s32> parentAbsolute(0,0,0,0); - core::rect<s32> parentAbsoluteClip; - f32 fw=0.f, fh=0.f; - - if (Parent) - { - parentAbsolute = Parent->AbsoluteRect; - - if (NoClip) - { - IGUIElement* p=this; - while (p && p->Parent) - p = p->Parent; - parentAbsoluteClip = p->AbsoluteClippingRect; - } - else - parentAbsoluteClip = Parent->AbsoluteClippingRect; - } - - const s32 diffx = parentAbsolute.getWidth() - LastParentRect.getWidth(); - const s32 diffy = parentAbsolute.getHeight() - LastParentRect.getHeight(); - - if (AlignLeft == EGUIA_SCALE || AlignRight == EGUIA_SCALE) - fw = (f32)parentAbsolute.getWidth(); - - if (AlignTop == EGUIA_SCALE || AlignBottom == EGUIA_SCALE) - fh = (f32)parentAbsolute.getHeight(); - - switch (AlignLeft) - { - case EGUIA_UPPERLEFT: - break; - case EGUIA_LOWERRIGHT: - DesiredRect.UpperLeftCorner.X += diffx; - break; - case EGUIA_CENTER: - DesiredRect.UpperLeftCorner.X += diffx/2; - break; - case EGUIA_SCALE: - DesiredRect.UpperLeftCorner.X = (s32)(ScaleRect.UpperLeftCorner.X * fw); - break; - } - - switch (AlignRight) - { - case EGUIA_UPPERLEFT: - break; - case EGUIA_LOWERRIGHT: - DesiredRect.LowerRightCorner.X += diffx; - break; - case EGUIA_CENTER: - DesiredRect.LowerRightCorner.X += diffx/2; - break; - case EGUIA_SCALE: - DesiredRect.LowerRightCorner.X = (s32)(ScaleRect.LowerRightCorner.X * fw); - break; - } - - switch (AlignTop) - { - case EGUIA_UPPERLEFT: - break; - case EGUIA_LOWERRIGHT: - DesiredRect.UpperLeftCorner.Y += diffy; - break; - case EGUIA_CENTER: - DesiredRect.UpperLeftCorner.Y += diffy/2; - break; - case EGUIA_SCALE: - DesiredRect.UpperLeftCorner.Y = (s32)(ScaleRect.UpperLeftCorner.Y * fh); - break; - } - - switch (AlignBottom) - { - case EGUIA_UPPERLEFT: - break; - case EGUIA_LOWERRIGHT: - DesiredRect.LowerRightCorner.Y += diffy; - break; - case EGUIA_CENTER: - DesiredRect.LowerRightCorner.Y += diffy/2; - break; - case EGUIA_SCALE: - DesiredRect.LowerRightCorner.Y = (s32)(ScaleRect.LowerRightCorner.Y * fh); - break; - } - - RelativeRect = DesiredRect; - - const s32 w = RelativeRect.getWidth(); - const s32 h = RelativeRect.getHeight(); - - // make sure the desired rectangle is allowed - if (w < (s32)MinSize.Width) - RelativeRect.LowerRightCorner.X = RelativeRect.UpperLeftCorner.X + MinSize.Width; - if (h < (s32)MinSize.Height) - RelativeRect.LowerRightCorner.Y = RelativeRect.UpperLeftCorner.Y + MinSize.Height; - if (MaxSize.Width && w > (s32)MaxSize.Width) - RelativeRect.LowerRightCorner.X = RelativeRect.UpperLeftCorner.X + MaxSize.Width; - if (MaxSize.Height && h > (s32)MaxSize.Height) - RelativeRect.LowerRightCorner.Y = RelativeRect.UpperLeftCorner.Y + MaxSize.Height; - - RelativeRect.repair(); - - AbsoluteRect = RelativeRect + parentAbsolute.UpperLeftCorner; - - if (!Parent) - parentAbsoluteClip = AbsoluteRect; - - AbsoluteClippingRect = AbsoluteRect; - AbsoluteClippingRect.clipAgainst(parentAbsoluteClip); - - LastParentRect = parentAbsolute; - - // update all children - core::list<IGUIElement*>::Iterator it = Children.begin(); - for (; it != Children.end(); ++it) - { - (*it)->updateAbsolutePosition(); - } - } - - - //! Returns the topmost GUI element at the specific position. - /** - This will check this GUI element and all of its descendants, so it - may return this GUI element. To check all GUI elements, call this - function on device->getGUIEnvironment()->getRootGUIElement(). Note - that the root element is the size of the screen, so doing so (with - an on-screen point) will always return the root element if no other - element is above it at that point. - \param point: The point at which to find a GUI element. - \return The topmost GUI element at that point, or 0 if there are - no candidate elements at this point. - */ - IGUIElement* getElementFromPoint(const core::position2d<s32>& point) - { - IGUIElement* target = 0; - - // we have to search from back to front, because later children - // might be drawn over the top of earlier ones. - - core::list<IGUIElement*>::Iterator it = Children.getLast(); - - if (isVisible()) - { - while(it != Children.end()) - { - target = (*it)->getElementFromPoint(point); - if (target) - return target; - - --it; - } - } - - if (isVisible() && isPointInside(point)) - target = this; - - return target; - } - - - //! Returns true if a point is within this element. - /** Elements with a shape other than a rectangle should override this method */ - virtual bool isPointInside(const core::position2d<s32>& point) const - { - return AbsoluteClippingRect.isPointInside(point); - } - - - //! Adds a GUI element as new child of this element. - virtual void addChild(IGUIElement* child) - { - if (child) - { - child->grab(); // prevent destruction when removed - child->remove(); // remove from old parent - child->LastParentRect = getAbsolutePosition(); - child->Parent = this; - Children.push_back(child); - child->updateAbsolutePosition(); - } - } - - //! Removes a child. - virtual void removeChild(IGUIElement* child) - { - core::list<IGUIElement*>::Iterator it = Children.begin(); - for (; it != Children.end(); ++it) - if ((*it) == child) - { - (*it)->Parent = 0; - (*it)->drop(); - Children.erase(it); - return; - } - } - - - //! Removes this element from its parent. - virtual void remove() - { - if (Parent) - Parent->removeChild(this); - } - - - //! Draws the element and its children. - virtual void draw() - { - if ( isVisible() ) - { - core::list<IGUIElement*>::Iterator it = Children.begin(); - for (; it != Children.end(); ++it) - (*it)->draw(); - } - } - - - //! animate the element and its children. - virtual void OnPostRender(u32 timeMs) - { - if ( isVisible() ) - { - core::list<IGUIElement*>::Iterator it = Children.begin(); - for (; it != Children.end(); ++it) - (*it)->OnPostRender( timeMs ); - } - } - - - //! Moves this element. - virtual void move(core::position2d<s32> absoluteMovement) - { - setRelativePosition(DesiredRect + absoluteMovement); - } - - - //! Returns true if element is visible. - virtual bool isVisible() const - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return IsVisible; - } - - - //! Sets the visible state of this element. - virtual void setVisible(bool visible) - { - IsVisible = visible; - } - - - //! Returns true if this element was created as part of its parent control - virtual bool isSubElement() const - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return IsSubElement; - } - - - //! Sets whether this control was created as part of its parent. - /** For example, it is true when a scrollbar is part of a listbox. - SubElements are not saved to disk when calling guiEnvironment->saveGUI() */ - virtual void setSubElement(bool subElement) - { - IsSubElement = subElement; - } - - - //! If set to true, the focus will visit this element when using the tab key to cycle through elements. - /** If this element is a tab group (see isTabGroup/setTabGroup) then - ctrl+tab will be used instead. */ - void setTabStop(bool enable) - { - IsTabStop = enable; - } - - - //! Returns true if this element can be focused by navigating with the tab key - bool isTabStop() const - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return IsTabStop; - } - - - //! Sets the priority of focus when using the tab key to navigate between a group of elements. - /** See setTabGroup, isTabGroup and getTabGroup for information on tab groups. - Elements with a lower number are focused first */ - void setTabOrder(s32 index) - { - // negative = autonumber - if (index < 0) - { - TabOrder = 0; - IGUIElement *el = getTabGroup(); - while (IsTabGroup && el && el->Parent) - el = el->Parent; - - IGUIElement *first=0, *closest=0; - if (el) - { - // find the highest element number - el->getNextElement(-1, true, IsTabGroup, first, closest, true); - if (first) - { - TabOrder = first->getTabOrder() + 1; - } - } - - } - else - TabOrder = index; - } - - - //! Returns the number in the tab order sequence - s32 getTabOrder() const - { - return TabOrder; - } - - - //! Sets whether this element is a container for a group of elements which can be navigated using the tab key. - /** For example, windows are tab groups. - Groups can be navigated using ctrl+tab, providing isTabStop is true. */ - void setTabGroup(bool isGroup) - { - IsTabGroup = isGroup; - } - - - //! Returns true if this element is a tab group. - bool isTabGroup() const - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return IsTabGroup; - } - - - //! Returns the container element which holds all elements in this element's tab group. - IGUIElement* getTabGroup() - { - IGUIElement *ret=this; - - while (ret && !ret->isTabGroup()) - ret = ret->getParent(); - - return ret; - } - - - //! Returns true if element is enabled. - virtual bool isEnabled() const - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return IsEnabled; - } - - - //! Sets the enabled state of this element. - virtual void setEnabled(bool enabled) - { - IsEnabled = enabled; - } - - - //! Sets the new caption of this element. - virtual void setText(const wchar_t* text) - { - Text = text; - } - - - //! Returns caption of this element. - virtual const wchar_t* getText() const - { - return Text.c_str(); - } - - - //! Sets the new caption of this element. - virtual void setToolTipText(const wchar_t* text) - { - ToolTipText = text; - } - - - //! Returns caption of this element. - virtual const core::stringw& getToolTipText() const - { - return ToolTipText; - } - - - //! Returns id. Can be used to identify the element. - virtual s32 getID() const - { - return ID; - } - - - //! Sets the id of this element - virtual void setID(s32 id) - { - ID = id; - } - - - //! Called if an event happened. - virtual bool OnEvent(const SEvent& event) - { - return Parent ? Parent->OnEvent(event) : false; - } - - - //! Brings a child to front - /** \return True if successful, false if not. */ - virtual bool bringToFront(IGUIElement* element) - { - core::list<IGUIElement*>::Iterator it = Children.begin(); - for (; it != Children.end(); ++it) - { - if (element == (*it)) - { - Children.erase(it); - Children.push_back(element); - return true; - } - } - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; - } - - - //! Returns list with children of this element - virtual const core::list<IGUIElement*>& getChildren() const - { - return Children; - } - - - //! Finds the first element with the given id. - /** \param id: Id to search for. - \param searchchildren: Set this to true, if also children of this - element may contain the element with the searched id and they - should be searched too. - \return Returns the first element with the given id. If no element - with this id was found, 0 is returned. */ - virtual IGUIElement* getElementFromId(s32 id, bool searchchildren=false) const - { - IGUIElement* e = 0; - - core::list<IGUIElement*>::ConstIterator it = Children.begin(); - for (; it != Children.end(); ++it) - { - if ((*it)->getID() == id) - return (*it); - - if (searchchildren) - e = (*it)->getElementFromId(id, true); - - if (e) - return e; - } - - return e; - } - - - //! returns true if the given element is a child of this one. - //! \param child: The child element to check - bool isMyChild(IGUIElement* child) const - { - if (!child) - return false; - do - { - if (child->Parent) - child = child->Parent; - - } while (child->Parent && child != this); - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return child == this; - } - - - //! searches elements to find the closest next element to tab to - /** \param startOrder: The TabOrder of the current element, -1 if none - \param reverse: true if searching for a lower number - \param group: true if searching for a higher one - \param first: element with the highest/lowest known tab order depending on search direction - \param closest: the closest match, depending on tab order and direction - \param includeInvisible: includes invisible elements in the search (default=false) - \return true if successfully found an element, false to continue searching/fail */ - bool getNextElement(s32 startOrder, bool reverse, bool group, - IGUIElement*& first, IGUIElement*& closest, bool includeInvisible=false) const - { - // we'll stop searching if we find this number - s32 wanted = startOrder + ( reverse ? -1 : 1 ); - if (wanted==-2) - wanted = 1073741824; // maximum s32 - - core::list<IGUIElement*>::ConstIterator it = Children.begin(); - - s32 closestOrder, currentOrder; - - while(it != Children.end()) - { - // ignore invisible elements and their children - if ( ( (*it)->isVisible() || includeInvisible ) && - (group == true || (*it)->isTabGroup() == false) ) - { - // only check tab stops and those with the same group status - if ((*it)->isTabStop() && ((*it)->isTabGroup() == group)) - { - currentOrder = (*it)->getTabOrder(); - - // is this what we're looking for? - if (currentOrder == wanted) - { - closest = *it; - return true; - } - - // is it closer than the current closest? - if (closest) - { - closestOrder = closest->getTabOrder(); - if ( ( reverse && currentOrder > closestOrder && currentOrder < startOrder) - ||(!reverse && currentOrder < closestOrder && currentOrder > startOrder)) - { - closest = *it; - } - } - else - if ( (reverse && currentOrder < startOrder) || (!reverse && currentOrder > startOrder) ) - { - closest = *it; - } - - // is it before the current first? - if (first) - { - closestOrder = first->getTabOrder(); - - if ( (reverse && closestOrder < currentOrder) || (!reverse && closestOrder > currentOrder) ) - { - first = *it; - } - } - else - { - first = *it; - } - } - // search within children - if ((*it)->getNextElement(startOrder, reverse, group, first, closest)) - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return true; - } - } - ++it; - } - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; - } - - - //! Returns the type of the gui element. - /** This is needed for the .NET wrapper but will be used - later for serializing and deserializing. - If you wrote your own GUIElements, you need to set the type for your element as first parameter - in the constructor of IGUIElement. For own (=unknown) elements, simply use EGUIET_ELEMENT as type */ - EGUI_ELEMENT_TYPE getType() const - { - return Type; - } - - - //! Returns the type name of the gui element. - /** This is needed serializing elements. For serializing your own elements, override this function - and return your own type name which is created by your IGUIElementFactory */ - virtual const c8* getTypeName() const - { - return GUIElementTypeNames[Type]; - } - - - //! Writes attributes of the scene node. - /** Implement this to expose the attributes of your scene node for - scripting languages, editors, debuggers or xml serialization purposes. */ - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const - { - out->addInt("Id", ID ); - out->addString("Caption", getText()); - out->addRect("Rect", DesiredRect); - out->addPosition2d("MinSize", core::position2di(MinSize.Width, MinSize.Height)); - out->addPosition2d("MaxSize", core::position2di(MaxSize.Width, MaxSize.Height)); - out->addEnum("LeftAlign", AlignLeft, GUIAlignmentNames); - out->addEnum("RightAlign", AlignRight, GUIAlignmentNames); - out->addEnum("TopAlign", AlignTop, GUIAlignmentNames); - out->addEnum("BottomAlign", AlignBottom, GUIAlignmentNames); - out->addBool("Visible", IsVisible); - out->addBool("Enabled", IsEnabled); - out->addBool("TabStop", IsTabStop); - out->addBool("TabGroup", IsTabGroup); - out->addInt("TabOrder", TabOrder); - out->addBool("NoClip", NoClip); - } - - - //! Reads attributes of the scene node. - /** Implement this to set the attributes of your scene node for - scripting languages, editors, debuggers or xml deserialization purposes. */ - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) - { - setID(in->getAttributeAsInt("Id")); - setText(in->getAttributeAsStringW("Caption").c_str()); - setVisible(in->getAttributeAsBool("Visible")); - setEnabled(in->getAttributeAsBool("Enabled")); - IsTabStop = in->getAttributeAsBool("TabStop"); - IsTabGroup = in->getAttributeAsBool("TabGroup"); - TabOrder = in->getAttributeAsInt("TabOrder"); - - core::position2di p = in->getAttributeAsPosition2d("MaxSize"); - setMaxSize(core::dimension2du(p.X,p.Y)); - - p = in->getAttributeAsPosition2d("MinSize"); - setMinSize(core::dimension2du(p.X,p.Y)); - - setAlignment((EGUI_ALIGNMENT) in->getAttributeAsEnumeration("LeftAlign", GUIAlignmentNames), - (EGUI_ALIGNMENT)in->getAttributeAsEnumeration("RightAlign", GUIAlignmentNames), - (EGUI_ALIGNMENT)in->getAttributeAsEnumeration("TopAlign", GUIAlignmentNames), - (EGUI_ALIGNMENT)in->getAttributeAsEnumeration("BottomAlign", GUIAlignmentNames)); - - setRelativePosition(in->getAttributeAsRect("Rect")); - - setNotClipped(in->getAttributeAsBool("NoClip")); - } - -protected: - - //! List of all children of this element - core::list<IGUIElement*> Children; - - //! Pointer to the parent - IGUIElement* Parent; - - //! relative rect of element - core::rect<s32> RelativeRect; - - //! absolute rect of element - core::rect<s32> AbsoluteRect; - - //! absolute clipping rect of element - core::rect<s32> AbsoluteClippingRect; - - //! the rectangle the element would prefer to be, - //! if it was not constrained by parent or max/min size - core::rect<s32> DesiredRect; - - //! for calculating the difference when resizing parent - core::rect<s32> LastParentRect; - - //! relative scale of the element inside its parent - core::rect<f32> ScaleRect; - - //! maximum and minimum size of the element - core::dimension2du MaxSize, MinSize; - - //! is visible? - bool IsVisible; - - //! is enabled? - bool IsEnabled; - - //! is a part of a larger whole and should not be serialized? - bool IsSubElement; - - //! does this element ignore its parent's clipping rectangle? - bool NoClip; - - //! caption - core::stringw Text; - - //! tooltip - core::stringw ToolTipText; - - //! id - s32 ID; - - //! tab stop like in windows - bool IsTabStop; - - //! tab order - s32 TabOrder; - - //! tab groups are containers like windows, use ctrl+tab to navigate - bool IsTabGroup; - - //! tells the element how to act when its parent is resized - EGUI_ALIGNMENT AlignLeft, AlignRight, AlignTop, AlignBottom; - - //! GUI Environment - IGUIEnvironment* Environment; - - //! type of element - EGUI_ELEMENT_TYPE Type; -}; - - -} // end namespace gui -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IGUIElementFactory.h b/irrlicht-1.6/include/IGUIElementFactory.h deleted file mode 100644 index 1a3a733d0..000000000 --- a/irrlicht-1.6/include/IGUIElementFactory.h +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_ELEMENT_FACTORY_H_INCLUDED__ -#define __I_GUI_ELEMENT_FACTORY_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "EGUIElementTypes.h" - -namespace irr -{ - -namespace gui -{ - class IGUIElement; - - //! Interface making it possible to dynamicly create GUI elements - /** To be able to add custom elements to Irrlicht and to make it possible for the - scene manager to save and load them, simply implement this interface and register it - in your gui environment via IGUIEnvironment::registerGUIElementFactory. - Note: When implementing your own element factory, don't call IGUIEnvironment::grab() to - increase the reference counter of the environment. This is not necessary because the - it will grab() the factory anyway, and otherwise cyclic references will be created. - */ - class IGUIElementFactory : public virtual IReferenceCounted - { - public: - - //! adds an element to the gui environment based on its type id - /** \param type: Type of the element to add. - \param parent: Parent scene node of the new element, can be null to add to the root. - \return Pointer to the new element or null if not successful. */ - virtual IGUIElement* addGUIElement(EGUI_ELEMENT_TYPE type, IGUIElement* parent=0) = 0; - - //! adds a GUI element to the GUI Environment based on its type name - /** \param typeName: Type name of the element to add. - \param parent: Parent scene node of the new element, can be null to add it to the root. - \return Pointer to the new element or null if not successful. */ - virtual IGUIElement* addGUIElement(const c8* typeName, IGUIElement* parent=0) = 0; - - //! Get amount of GUI element types this factory is able to create - virtual s32 getCreatableGUIElementTypeCount() const = 0; - - //! Get type of a createable element type - /** \param idx: Index of the element type in this factory. Must be a value between 0 and - getCreatableGUIElementTypeCount() */ - virtual EGUI_ELEMENT_TYPE getCreateableGUIElementType(s32 idx) const = 0; - - //! Get type name of a createable GUI element type by index - /** \param idx: Index of the type in this factory. Must be a value between 0 and - getCreatableGUIElementTypeCount() */ - virtual const c8* getCreateableGUIElementTypeName(s32 idx) const = 0; - - //! returns type name of a createable GUI element - /** \param type: Type of GUI element. - \return Name of the type if this factory can create the type, otherwise 0. */ - virtual const c8* getCreateableGUIElementTypeName(EGUI_ELEMENT_TYPE type) const = 0; - }; - - -} // end namespace gui -} // end namespace irr - -#endif // __I_GUI_ELEMENT_FACTORY_H_INCLUDED__ - diff --git a/irrlicht-1.6/include/IGUIEnvironment.h b/irrlicht-1.6/include/IGUIEnvironment.h deleted file mode 100644 index 50acb29ab..000000000 --- a/irrlicht-1.6/include/IGUIEnvironment.h +++ /dev/null @@ -1,577 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_ENVIRONMENT_H_INCLUDED__ -#define __I_GUI_ENVIRONMENT_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "IGUISkin.h" -#include "rect.h" -#include "EMessageBoxFlags.h" -#include "IEventReceiver.h" -#include "IXMLReader.h" -#include "path.h" - -namespace irr -{ - class IOSOperator; - class IEventReceiver; - - namespace io - { - class IXMLWriter; - class IReadFile; - class IWriteFile; - class IFileSystem; - } // end namespace io - namespace video - { - class IVideoDriver; - class ITexture; - } // end namespace video - -namespace gui -{ - -class IGUIElement; -class IGUIFont; -class IGUISpriteBank; -class IGUIScrollBar; -class IGUIImage; -class IGUIMeshViewer; -class IGUICheckBox; -class IGUIListBox; -class IGUITreeView; -class IGUIImageList; -class IGUIFileOpenDialog; -class IGUIColorSelectDialog; -class IGUIInOutFader; -class IGUIStaticText; -class IGUIEditBox; -class IGUISpinBox; -class IGUITabControl; -class IGUITab; -class IGUITable; -class IGUIContextMenu; -class IGUIComboBox; -class IGUIToolBar; -class IGUIButton; -class IGUIWindow; -class IGUIElementFactory; - -//! GUI Environment. Used as factory and manager of all other GUI elements. -class IGUIEnvironment : public virtual IReferenceCounted -{ -public: - - //! Draws all gui elements by traversing the GUI environment starting at the root node. - virtual void drawAll() = 0; - - //! Sets the focus to an element. - /** Causes a EGET_ELEMENT_FOCUS_LOST event followed by a - EGET_ELEMENT_FOCUSED event. If someone absorbed either of the events, - then the focus will not be changed. - \param element Pointer to the element which shall get the focus. - \return True on success, false on failure */ - virtual bool setFocus(IGUIElement* element) = 0; - - //! Returns the element which holds the focus. - /** \return Pointer to the element with focus. */ - virtual IGUIElement* getFocus() const = 0; - - //! Removes the focus from an element. - /** Causes a EGET_ELEMENT_FOCUS_LOST event. If the event is absorbed - then the focus will not be changed. - \param element Pointer to the element which shall lose the focus. - \return True on success, false on failure */ - virtual bool removeFocus(IGUIElement* element) = 0; - - //! Returns whether the element has focus - /** \param element Pointer to the element which is tested. - \return True if the element has focus, else false. */ - virtual bool hasFocus(IGUIElement* element) const = 0; - - //! Returns the current video driver. - /** \return Pointer to the video driver. */ - virtual video::IVideoDriver* getVideoDriver() const = 0; - - //! Returns the file system. - /** \return Pointer to the file system. */ - virtual io::IFileSystem* getFileSystem() const = 0; - - //! returns a pointer to the OS operator - /** \return Pointer to the OS operator. */ - virtual IOSOperator* getOSOperator() const = 0; - - //! Removes all elements from the environment. - virtual void clear() = 0; - - //! Posts an input event to the environment. - /** Usually you do not have to - use this method, it is used by the engine internally. - \param event The event to post. - \return True if succeeded, else false. */ - virtual bool postEventFromUser(const SEvent& event) = 0; - - //! This sets a new event receiver for gui events. - /** Usually you do not have to - use this method, it is used by the engine internally. - \param evr Pointer to the new receiver. */ - virtual void setUserEventReceiver(IEventReceiver* evr) = 0; - - //! Returns pointer to the current gui skin. - /** \return Pointer to the GUI skin. */ - virtual IGUISkin* getSkin() const = 0; - - //! Sets a new GUI Skin - /** You can use this to change the appearance of the whole GUI - Environment. You can set one of the built-in skins or implement your - own class derived from IGUISkin and enable it using this method. - To set for example the built-in Windows classic skin, use the following - code: - \code - gui::IGUISkin* newskin = environment->createSkin(gui::EGST_WINDOWS_CLASSIC); - environment->setSkin(newskin); - newskin->drop(); - \endcode - \param skin New skin to use. - */ - virtual void setSkin(IGUISkin* skin) = 0; - - //! Creates a new GUI Skin based on a template. - /** Use setSkin() to set the created skin. - \param type The type of the new skin. - \return Pointer to the created skin. - If you no longer need it, you should call IGUISkin::drop(). - See IReferenceCounted::drop() for more information. */ - virtual IGUISkin* createSkin(EGUI_SKIN_TYPE type) = 0; - - - //! Creates the image list from the given texture. - /** Loads the font if it was not loaded before. - \param filename Filename of the Font. - \return Pointer to the font. Returns 0 if the font could not be loaded. - This pointer should not be dropped. See IReferenceCounted::drop() for - more information. */ - virtual IGUIImageList* createImageList( video::ITexture* texture, - core::dimension2d<s32> imageSize, bool useAlphaChannel ) = 0; - - //! Returns pointer to the font with the specified filename. - /** Loads the font if it was not loaded before. - \param filename Filename of the Font. - \return Pointer to the font. Returns 0 if the font could not be loaded. - This pointer should not be dropped. See IReferenceCounted::drop() for - more information. */ - virtual IGUIFont* getFont(const io::path& filename) = 0; - - //! Returns the default built-in font. - /** \return Pointer to the default built-in font. - This pointer should not be dropped. See IReferenceCounted::drop() for - more information. */ - virtual IGUIFont* getBuiltInFont() const = 0; - - //! Returns pointer to the sprite bank with the specified file name. - /** Loads the bank if it was not loaded before. - \param filename Filename of the sprite bank's origin. - \return Pointer to the sprite bank. Returns 0 if it could not be loaded. - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual IGUISpriteBank* getSpriteBank(const io::path& filename) = 0; - - //! Adds an empty sprite bank to the manager - /** \param name Name of the new sprite bank. - \return Pointer to the sprite bank. - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual IGUISpriteBank* addEmptySpriteBank(const io::path& name) = 0; - - //! Returns the root gui element. - /** This is the first gui element, the (direct or indirect) parent of all - other gui elements. It is a valid IGUIElement, with dimensions the same - size as the screen. You should not need to use this method directly, unless - you wish to reparent GUI elements to the top level. - \return Pointer to the root element of the GUI. The returned pointer - should not be dropped. See IReferenceCounted::drop() for more - information. */ - virtual IGUIElement* getRootGUIElement() = 0; - - //! Adds a button element. - /** \param rectangle Rectangle specifying the borders of the button. - \param parent Parent gui element of the button. - \param id Id with which the gui element can be identified. - \param text Text displayed on the button. - \param tooltiptext Text displayed in the tooltip. - \return Pointer to the created button. Returns 0 if an error occured. - This pointer should not be dropped. See IReferenceCounted::drop() for - more information. */ - virtual IGUIButton* addButton(const core::rect<s32>& rectangle, - IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0, const wchar_t* tooltiptext = 0) = 0; - - //! Adds an empty window element. - /** \param rectangle Rectangle specifying the borders of the window. - \param modal Defines if the dialog is modal. This means, that all other - gui elements which were created before the window cannot be used until - it is removed. - \param text Text displayed as the window title. - \param parent Parent gui element of the window. - \param id Id with which the gui element can be identified. - \return Pointer to the created window. Returns 0 if an error occured. - This pointer should not be dropped. See IReferenceCounted::drop() for - more information. */ - virtual IGUIWindow* addWindow(const core::rect<s32>& rectangle, bool modal = false, - const wchar_t* text=0, IGUIElement* parent=0, s32 id=-1) = 0; - - //! Adds a modal screen. - /** This control stops its parent's members from being able to receive - input until its last child is removed, it then deletes itself. - \param parent Parent gui element of the modal. - \return Pointer to the created modal. Returns 0 if an error occured. - This pointer should not be dropped. See IReferenceCounted::drop() for - more information. */ - virtual IGUIElement* addModalScreen(IGUIElement* parent) = 0; - - //! Adds a message box. - /** \param caption Text to be displayed the title of the message box. - \param text Text to be displayed in the body of the message box. - \param modal Defines if the dialog is modal. This means, that all other - gui elements which were created before the message box cannot be used - until this messagebox is removed. - \param flags Flags specifying the layout of the message box. For example - to create a message box with an OK and a CANCEL button on it, set this - to (EMBF_OK | EMBF_CANCEL). - \param parent Parent gui element of the message box. - \param id Id with which the gui element can be identified. - \return Pointer to the created message box. Returns 0 if an error - occured. This pointer should not be dropped. See - IReferenceCounted::drop() for more information. */ - virtual IGUIWindow* addMessageBox(const wchar_t* caption, const wchar_t* text=0, - bool modal = true, s32 flags = EMBF_OK, IGUIElement* parent=0, s32 id=-1) = 0; - - //! Adds a scrollbar. - /** \param horizontal Specifies if the scroll bar is drawn horizontal - or vertical. - \param rectangle Rectangle specifying the borders of the scrollbar. - \param parent Parent gui element of the scroll bar. - \param id Id to identify the gui element. - \return Pointer to the created scrollbar. Returns 0 if an error - occured. This pointer should not be dropped. See - IReferenceCounted::drop() for more information. */ - virtual IGUIScrollBar* addScrollBar(bool horizontal, const core::rect<s32>& rectangle, - IGUIElement* parent=0, s32 id=-1) = 0; - - //! Adds an image element. - /** \param image Image to be displayed. - \param pos Position of the image. The width and height of the image is - taken from the image. - \param useAlphaChannel Sets if the image should use the alpha channel - of the texture to draw itself. - \param parent Parent gui element of the image. - \param id Id to identify the gui element. - \param text Title text of the image. - \return Pointer to the created image element. Returns 0 if an error - occured. This pointer should not be dropped. See - IReferenceCounted::drop() for more information. */ - virtual IGUIImage* addImage(video::ITexture* image, core::position2d<s32> pos, - bool useAlphaChannel=true, IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0) = 0; - - //! Adds an image element. - /** Use IGUIImage::setImage later to set the image to be displayed. - \param rectangle Rectangle specifying the borders of the image. - \param parent Parent gui element of the image. - \param id Id to identify the gui element. - \param text Title text of the image. - \return Pointer to the created image element. Returns 0 if an error - occured. This pointer should not be dropped. See - IReferenceCounted::drop() for more information. */ - virtual IGUIImage* addImage(const core::rect<s32>& rectangle, - IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0) = 0; - - //! Adds a checkbox element. - /** \param checked Define the initial state of the check box. - \param rectangle Rectangle specifying the borders of the check box. - \param parent Parent gui element of the check box. - \param id Id to identify the gui element. - \param text Title text of the check box. - \return Pointer to the created check box. Returns 0 if an error - occured. This pointer should not be dropped. See - IReferenceCounted::drop() for more information. */ - virtual IGUICheckBox* addCheckBox(bool checked, const core::rect<s32>& rectangle, - IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0) = 0; - - //! Adds a list box element. - /** \param rectangle Rectangle specifying the borders of the list box. - \param parent Parent gui element of the list box. - \param id Id to identify the gui element. - \param drawBackground Flag whether the background should be drawn. - \return Pointer to the created list box. Returns 0 if an error occured. - This pointer should not be dropped. See IReferenceCounted::drop() for - more information. */ - virtual IGUIListBox* addListBox(const core::rect<s32>& rectangle, - IGUIElement* parent=0, s32 id=-1, bool drawBackground=false) = 0; - - //! Adds a tree view element. - /** \param rectangle Position and dimension of list box. - \param parent Parent gui element of the list box. - \param id Id to identify the gui element. - \param drawBackground Flag whether the background should be drawn. - \return Pointer to the created list box. Returns 0 if an error occured. - This pointer should not be dropped. See IReferenceCounted::drop() for - more information. */ - virtual IGUITreeView* addTreeView(const core::rect<s32>& rectangle, - IGUIElement* parent=0, s32 id=-1, bool drawBackground=false, - bool scrollBarVertical = true, bool scrollBarHorizontal = false) = 0; - - //! Adds a mesh viewer. Not 100% implemented yet. - /** \param rectangle Rectangle specifying the borders of the mesh viewer. - \param parent Parent gui element of the mesh viewer. - \param id Id to identify the gui element. - \param text Title text of the mesh viewer. - \return Pointer to the created mesh viewer. Returns 0 if an error - occured. This pointer should not be dropped. See - IReferenceCounted::drop() for more information. */ - virtual IGUIMeshViewer* addMeshViewer(const core::rect<s32>& rectangle, - IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0) = 0; - - //! Adds a file open dialog. - /** \param title Text to be displayed as the title of the dialog. - \param modal Defines if the dialog is modal. This means, that all other - gui elements which were created before the message box cannot be used - until this messagebox is removed. - \param parent Parent gui element of the dialog. - \param id Id to identify the gui element. - \return Pointer to the created file open dialog. Returns 0 if an error - occured. This pointer should not be dropped. See - IReferenceCounted::drop() for more information. */ - virtual IGUIFileOpenDialog* addFileOpenDialog(const wchar_t* title = 0, - bool modal=true, IGUIElement* parent=0, s32 id=-1) = 0; - - //! Adds a color select dialog. - /** \param title The title of the dialog. - \param modal Defines if the dialog is modal. This means, that all other - gui elements which were created before the dialog cannot be used - until it is removed. - \param parent The parent of the dialog. - \param id The ID of the dialog. - \return Pointer to the created file open dialog. Returns 0 if an error - occured. This pointer should not be dropped. See - IReferenceCounted::drop() for more information. */ - virtual IGUIColorSelectDialog* addColorSelectDialog(const wchar_t* title = 0, - bool modal=true, IGUIElement* parent=0, s32 id=-1) = 0; - - //! Adds a static text. - /** \param text Text to be displayed. Can be altered after creation by SetText(). - \param rectangle Rectangle specifying the borders of the static text - \param border Set to true if the static text should have a 3d border. - \param wordWrap Enable if the text should wrap into multiple lines. - \param parent Parent item of the element, e.g. a window. - \param id The ID of the element. - \param fillBackground Enable if the background shall be filled. - Defaults to false. - \return Pointer to the created static text. Returns 0 if an error - occured. This pointer should not be dropped. See - IReferenceCounted::drop() for more information. */ - virtual IGUIStaticText* addStaticText(const wchar_t* text, const core::rect<s32>& rectangle, - bool border=false, bool wordWrap=true, IGUIElement* parent=0, s32 id=-1, - bool fillBackground = false) = 0; - - //! Adds an edit box. - /** Supports unicode input from every keyboard around the world, - scrolling, copying and pasting (exchanging data with the clipboard - directly), maximum character amount, marking, and all shortcuts like - ctrl+X, ctrl+V, ctrl+C, shift+Left, shift+Right, Home, End, and so on. - \param text Text to be displayed. Can be altered after creation - by setText(). - \param rectangle Rectangle specifying the borders of the edit box. - \param border Set to true if the edit box should have a 3d border. - \param parent Parent item of the element, e.g. a window. - Set it to 0 to place the edit box directly in the environment. - \param id The ID of the element. - \return Pointer to the created edit box. Returns 0 if an error occured. - This pointer should not be dropped. See IReferenceCounted::drop() for - more information. */ - virtual IGUIEditBox* addEditBox(const wchar_t* text, const core::rect<s32>& rectangle, - bool border=true, IGUIElement* parent=0, s32 id=-1) = 0; - - //! Adds a spin box. - /** An edit box with up and down buttons - \param text Text to be displayed. Can be altered after creation by setText(). - \param rectangle Rectangle specifying the borders of the spin box. - \param parent Parent item of the element, e.g. a window. - Set it to 0 to place the spin box directly in the environment. - \param id The ID of the element. - \return Pointer to the created spin box. Returns 0 if an error occured. - This pointer should not be dropped. See IReferenceCounted::drop() for - more information. */ - virtual IGUISpinBox* addSpinBox(const wchar_t* text, const core::rect<s32>& rectangle, - bool border=true,IGUIElement* parent=0, s32 id=-1) = 0; - - //! Adds an element for fading in or out. - /** \param rectangle Rectangle specifying the borders of the fader. - If the pointer is NULL, the whole screen is used. - \param parent Parent item of the element, e.g. a window. - \param id An identifier for the fader. - \return Pointer to the created in-out-fader. Returns 0 if an error - occured. This pointer should not be dropped. See - IReferenceCounted::drop() for more information. */ - virtual IGUIInOutFader* addInOutFader(const core::rect<s32>* rectangle=0, IGUIElement* parent=0, s32 id=-1) = 0; - - //! Adds a tab control to the environment. - /** \param rectangle Rectangle specifying the borders of the tab control. - \param parent Parent item of the element, e.g. a window. - Set it to 0 to place the tab control directly in the environment. - \param fillbackground Specifies if the background of the tab control - should be drawn. - \param border Specifies if a flat 3d border should be drawn. This is - usually not necessary unless you place the control directly into - the environment without a window as parent. - \param id An identifier for the tab control. - \return Pointer to the created tab control element. Returns 0 if an - error occured. This pointer should not be dropped. See - IReferenceCounted::drop() for more information. */ - virtual IGUITabControl* addTabControl(const core::rect<s32>& rectangle, - IGUIElement* parent=0, bool fillbackground=false, - bool border=true, s32 id=-1) = 0; - - //! Adds tab to the environment. - /** You can use this element to group other elements. This is not used - for creating tabs on tab controls, please use IGUITabControl::addTab() - for this instead. - \param rectangle Rectangle specifying the borders of the tab. - \param parent Parent item of the element, e.g. a window. - Set it to 0 to place the tab directly in the environment. - \param id An identifier for the tab. - \return Pointer to the created tab. Returns 0 if an - error occured. This pointer should not be dropped. See - IReferenceCounted::drop() for more information. */ - virtual IGUITab* addTab(const core::rect<s32>& rectangle, - IGUIElement* parent=0, s32 id=-1) = 0; - - //! Adds a context menu to the environment. - /** \param rectangle Rectangle specifying the borders of the menu. - Note that the menu is resizing itself based on what items you add. - \param parent Parent item of the element, e.g. a window. - Set it to 0 to place the menu directly in the environment. - \param id An identifier for the menu. - \return Pointer to the created context menu. Returns 0 if an - error occured. This pointer should not be dropped. See - IReferenceCounted::drop() for more information. */ - virtual IGUIContextMenu* addContextMenu(const core::rect<s32>& rectangle, - IGUIElement* parent=0, s32 id=-1) = 0; - - //! Adds a menu to the environment. - /** This is like the menu you can find on top of most windows in modern - graphical user interfaces. - \param parent Parent item of the element, e.g. a window. - Set it to 0 to place the menu directly in the environment. - \param id An identifier for the menu. - \return Pointer to the created menu. Returns 0 if an - error occured. This pointer should not be dropped. See - IReferenceCounted::drop() for more information. */ - virtual IGUIContextMenu* addMenu(IGUIElement* parent=0, s32 id=-1) = 0; - - //! Adds a toolbar to the environment. - /** It is like a menu that is always placed on top of its parent, and - contains buttons. - \param parent Parent item of the element, e.g. a window. - Set it to 0 to place the tool bar directly in the environment. - \param id An identifier for the tool bar. - \return Pointer to the created tool bar. Returns 0 if an - error occured. This pointer should not be dropped. See - IReferenceCounted::drop() for more information. */ - virtual IGUIToolBar* addToolBar(IGUIElement* parent=0, s32 id=-1) = 0; - - //! Adds a combo box to the environment. - /** \param rectangle Rectangle specifying the borders of the combo box. - \param parent Parent item of the element, e.g. a window. - Set it to 0 to place the combo box directly in the environment. - \param id An identifier for the combo box. - \return Pointer to the created combo box. Returns 0 if an - error occured. This pointer should not be dropped. See - IReferenceCounted::drop() for more information. */ - virtual IGUIComboBox* addComboBox(const core::rect<s32>& rectangle, - IGUIElement* parent=0, s32 id=-1) = 0; - - //! Adds a table to the environment - /** \param rectangle Rectangle specifying the borders of the table. - \param parent Parent item of the element, e.g. a window. Set it to 0 - to place the element directly in the environment. - \param id An identifier for the table. - \param drawBackground Flag whether the background should be drawn. - \return Pointer to the created table. Returns 0 if an error occured. - This pointer should not be dropped. See IReferenceCounted::drop() for - more information. */ - virtual IGUITable* addTable(const core::rect<s32>& rectangle, - IGUIElement* parent=0, s32 id=-1, bool drawBackground=false) =0; - - //! Get the default element factory which can create all built-in elements - /** \return Pointer to the factory. - This pointer should not be dropped. See IReferenceCounted::drop() for - more information. */ - virtual IGUIElementFactory* getDefaultGUIElementFactory() const = 0; - - //! Adds an element factory to the gui environment. - /** Use this to extend the gui environment with new element types which - it should be able to create automatically, for example when loading - data from xml files. - \param factoryToAdd Pointer to new factory. */ - virtual void registerGUIElementFactory(IGUIElementFactory* factoryToAdd) = 0; - - //! Get amount of registered gui element factories. - /** \return Amount of registered gui element factories. */ - virtual u32 getRegisteredGUIElementFactoryCount() const = 0; - - //! Get a gui element factory by index - /** \param index Index of the factory. - \return Factory at given index, or 0 if no such factory exists. */ - virtual IGUIElementFactory* getGUIElementFactory(u32 index) const = 0; - - //! Adds a GUI element by its name - /** Each factory is checked if it can create an element of the given - name. The first match will be created. - \param elementName Name of the element to be created. - \param parent Parent of the new element, if not 0. - \return New GUI element, or 0 if no such element exists. */ - virtual IGUIElement* addGUIElement(const c8* elementName, IGUIElement* parent=0) = 0; - - //! Saves the current gui into a file. - /** \param filename Name of the file. - \param start The GUIElement to start with. Root if 0. - \return True if saving succeeded, else false. */ - virtual bool saveGUI(const io::path& filename, IGUIElement* start=0) = 0; - - //! Saves the current gui into a file. - /** \param file The file to write to. - \param start The GUIElement to start with. Root if 0. - \return True if saving succeeded, else false. */ - virtual bool saveGUI(io::IWriteFile* file, IGUIElement* start=0) = 0; - - //! Loads the gui. Note that the current gui is not cleared before. - /** \param filename Name of the file. - \param parent Parent for the loaded GUI, root if 0. - \return True if loading succeeded, else false. */ - virtual bool loadGUI(const io::path& filename, IGUIElement* parent=0) = 0; - - //! Loads the gui. Note that the current gui is not cleared before. - /** \param file The file to load from. - \param parent Parent for the loaded GUI, root if 0. - \return True if loading succeeded, else false. */ - virtual bool loadGUI(io::IReadFile* file, IGUIElement* parent=0) = 0; - - //! Writes attributes of the gui environment - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const =0; - - //! Reads attributes of the gui environment - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)=0; - - //! writes an element - virtual void writeGUIElement(io::IXMLWriter* writer, IGUIElement* node) =0; - - //! reads an element - virtual void readGUIElement(io::IXMLReader* reader, IGUIElement* node) =0; -}; - - -} // end namespace gui -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IGUIFileOpenDialog.h b/irrlicht-1.6/include/IGUIFileOpenDialog.h deleted file mode 100644 index 1531caaa1..000000000 --- a/irrlicht-1.6/include/IGUIFileOpenDialog.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_FILE_OPEN_DIALOG_H_INCLUDED__ -#define __I_GUI_FILE_OPEN_DIALOG_H_INCLUDED__ - -#include "IGUIElement.h" -#include "path.h" - -namespace irr -{ -namespace gui -{ - - //! Standard file chooser dialog. - class IGUIFileOpenDialog : public IGUIElement - { - public: - - //! constructor - IGUIFileOpenDialog(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle) - : IGUIElement(EGUIET_FILE_OPEN_DIALOG, environment, parent, id, rectangle) {} - - //! Returns the filename of the selected file. Returns NULL, if no file was selected. - virtual const wchar_t* getFileName() const = 0; - - //! Returns the directory of the selected file. Returns NULL, if no directory was selected. - virtual const io::path& getDirectoryName() = 0; - }; - - -} // end namespace gui -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IGUIFont.h b/irrlicht-1.6/include/IGUIFont.h deleted file mode 100644 index 35c94ab33..000000000 --- a/irrlicht-1.6/include/IGUIFont.h +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_FONT_H_INCLUDED__ -#define __I_GUI_FONT_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "SColor.h" -#include "rect.h" -#include "irrString.h" - -namespace irr -{ -namespace gui -{ - -//! An enum for the different types of GUI font. -enum EGUI_FONT_TYPE -{ - //! Bitmap fonts loaded from an XML file or a texture. - EGFT_BITMAP = 0, - - //! Scalable vector fonts loaded from an XML file. - /** These fonts reside in system memory and use no video memory - until they are displayed. These are slower than bitmap fonts - but can be easily scaled and rotated. */ - EGFT_VECTOR, - - //! A font which uses a the native API provided by the operating system. - /** Currently not used. */ - EGFT_OS, - - //! An external font type provided by the user. - EGFT_CUSTOM -}; - -//! Font interface. -class IGUIFont : public virtual IReferenceCounted -{ -public: - - //! Draws some text and clips it to the specified rectangle if wanted. - /** \param text: Text to draw - \param position: Rectangle specifying position where to draw the text. - \param color: Color of the text - \param hcenter: Specifiies if the text should be centered horizontally into the rectangle. - \param vcenter: Specifies if the text should be centered vertically into the rectangle. - \param clip: Optional pointer to a rectangle against which the text will be clipped. - If the pointer is null, no clipping will be done. */ - virtual void draw(const core::stringw& text, const core::rect<s32>& position, - video::SColor color, bool hcenter=false, bool vcenter=false, - const core::rect<s32>* clip=0) = 0; - - //! Calculates the width and height of a given string of text. - /** \return Returns width and height of the area covered by the text if - it would be drawn. */ - virtual core::dimension2d<u32> getDimension(const wchar_t* text) const = 0; - - //! Calculates the index of the character in the text which is on a specific position. - /** \param text: Text string. - \param pixel_x: X pixel position of which the index of the character will be returned. - \return Returns zero based index of the character in the text, and -1 if no no character - is on this position. (=the text is too short). */ - virtual s32 getCharacterFromPos(const wchar_t* text, s32 pixel_x) const = 0; - - //! Returns the type of this font - virtual EGUI_FONT_TYPE getType() const { return EGFT_CUSTOM; } - - //! Sets global kerning width for the font. - virtual void setKerningWidth (s32 kerning) = 0; - - //! Sets global kerning height for the font. - virtual void setKerningHeight (s32 kerning) = 0; - - //! Gets kerning values (distance between letters) for the font. If no parameters are provided, - /** the global kerning distance is returned. - \param thisLetter: If this parameter is provided, the left side kerning - for this letter is added to the global kerning value. For example, a - space might only be one pixel wide, but it may be displayed as several - pixels. - \param previousLetter: If provided, kerning is calculated for both - letters and added to the global kerning value. For example, in a font - which supports kerning pairs a string such as 'Wo' may have the 'o' - tucked neatly under the 'W'. - */ - virtual s32 getKerningWidth(const wchar_t* thisLetter=0, const wchar_t* previousLetter=0) const = 0; - - //! Returns the distance between letters - virtual s32 getKerningHeight() const = 0; - - //! Define which characters should not be drawn by the font. - /** For example " " would not draw any space which is usually blank in - most fonts. - \param invisible: string of symbols, which are not send down to the videodriver - */ - virtual void setInvisibleCharacters( const wchar_t *s ) = 0; -}; - -} // end namespace gui -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IGUIFontBitmap.h b/irrlicht-1.6/include/IGUIFontBitmap.h deleted file mode 100644 index 152ca106d..000000000 --- a/irrlicht-1.6/include/IGUIFontBitmap.h +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_FONT_BITMAP_H_INCLUDED__ -#define __I_GUI_FONT_BITMAP_H_INCLUDED__ - -#include "IGUIFont.h" - -namespace irr -{ -namespace gui -{ - class IGUISpriteBank; - -//! Font interface. -class IGUIFontBitmap : public IGUIFont -{ -public: - - //! Returns the type of this font - virtual EGUI_FONT_TYPE getType() const { return EGFT_BITMAP; } - - //! returns the parsed Symbol Information - virtual IGUISpriteBank* getSpriteBank() const = 0; - - //! returns the sprite number from a given character - virtual u32 getSpriteNoFromChar(const wchar_t *c) const = 0; - - //! Gets kerning values (distance between letters) for the font. If no parameters are provided, - /** the global kerning distance is returned. - \param thisLetter: If this parameter is provided, the left side kerning for this letter is added - to the global kerning value. For example, a space might only be one pixel wide, but it may - be displayed as several pixels. - \param previousLetter: If provided, kerning is calculated for both letters and added to the global - kerning value. For example, EGFT_BITMAP will add the right kerning value of previousLetter to the - left side kerning value of thisLetter, then add the global value. - */ - virtual s32 getKerningWidth(const wchar_t* thisLetter=0, const wchar_t* previousLetter=0) const = 0; -}; - -} // end namespace gui -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IGUIImage.h b/irrlicht-1.6/include/IGUIImage.h deleted file mode 100644 index 55e624731..000000000 --- a/irrlicht-1.6/include/IGUIImage.h +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_IMAGE_H_INCLUDED__ -#define __I_GUI_IMAGE_H_INCLUDED__ - -#include "IGUIElement.h" - -namespace irr -{ -namespace video -{ - class ITexture; -} -namespace gui -{ - - //! GUI element displaying an image. - class IGUIImage : public IGUIElement - { - public: - - //! constructor - IGUIImage(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle) - : IGUIElement(EGUIET_IMAGE, environment, parent, id, rectangle) {} - - //! Sets an image - virtual void setImage(video::ITexture* image) = 0; - - //! Sets the colour of the image - virtual void setColor(video::SColor color) = 0; - - //! Sets if the image should scale to fit the element - virtual void setScaleImage(bool scale) = 0; - - //! Sets if the image should use its alpha channel to draw itself - virtual void setUseAlphaChannel(bool use) = 0; - - //! Returns true if the image is scaled to fit, false if not - virtual bool isImageScaled() const = 0; - - //! Returns true if the image is using the alpha channel, false if not - virtual bool isAlphaChannelUsed() const = 0; - }; - - -} // end namespace gui -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IGUIImageList.h b/irrlicht-1.6/include/IGUIImageList.h deleted file mode 100644 index ee6ec8799..000000000 --- a/irrlicht-1.6/include/IGUIImageList.h +++ /dev/null @@ -1,45 +0,0 @@ -// This file is part of the "Irrlicht Engine". -// written by Reinhard Ostermeier, reinhard@nospam.r-ostermeier.de - -#ifndef __I_GUI_IMAGE_LIST_H_INCLUDED__ -#define __I_GUI_IMAGE_LIST_H_INCLUDED__ - -#include "IGUIElement.h" -#include "rect.h" -#include "irrTypes.h" - -namespace irr -{ -namespace gui -{ - -//! Font interface. -class IGUIImageList : public virtual IReferenceCounted -{ -public: - - //! Destructor - virtual ~IGUIImageList() {}; - - //! Draws an image and clips it to the specified rectangle if wanted - //! \param index: Index of the image - //! \param destPos: Position of the image to draw - //! \param clip: Optional pointer to a rectalgle against which the text will be clipped. - //! If the pointer is null, no clipping will be done. - virtual void draw( s32 index, const core::position2d<s32>& destPos, - const core::rect<s32>* clip = 0 ) = 0; - - //! Returns the count of Images in the list. - //! \return Returns the count of Images in the list. - virtual s32 getImageCount() const = 0; - - //! Returns the size of the images in the list. - //! \return Returns the size of the images in the list. - virtual core::dimension2d<s32> getImageSize() const = 0; -}; - -} // end namespace gui -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IGUIInOutFader.h b/irrlicht-1.6/include/IGUIInOutFader.h deleted file mode 100644 index 373241875..000000000 --- a/irrlicht-1.6/include/IGUIInOutFader.h +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_IN_OUT_FADER_H_INCLUDED__ -#define __I_GUI_IN_OUT_FADER_H_INCLUDED__ - -#include "IGUIElement.h" -#include "SColor.h" - -namespace irr -{ -namespace gui -{ - - //! Element for fading out or in - /** Here is a small example on how the class is used. In this example we fade - in from a total red screen in the beginning. As you can see, the fader is not - only useful for dramatic in and out fading, but also to show that the player - is hit in a first person shooter game for example. - \code - gui::IGUIInOutFader* fader = device->getGUIEnvironment()->addInOutFader(); - fader->setColor(video::SColor(0,255,0,0)); - fader->fadeIn(4000); - \endcode - */ - class IGUIInOutFader : public IGUIElement - { - public: - - //! constructor - IGUIInOutFader(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle) - : IGUIElement(EGUIET_IN_OUT_FADER, environment, parent, id, rectangle) {} - - //! Gets the color to fade out to or to fade in from. - virtual video::SColor getColor() const = 0; - - //! Sets the color to fade out to or to fade in from. - /** \param color: Color to where it is faded out od from it is faded in. */ - virtual void setColor(video::SColor color) = 0; - virtual void setColor(video::SColor source, video::SColor dest) = 0; - - //! Starts the fade in process. - /** In the beginning the whole rect is drawn by the set color - (black by default) and at the end of the overgiven time the - color has faded out. - \param time: Time specifing how long it should need to fade in, - in milliseconds. */ - virtual void fadeIn(u32 time) = 0; - - //! Starts the fade out process. - /** In the beginning everything is visible, and at the end of - the time only the set color (black by the fault) will be drawn. - \param time: Time specifing how long it should need to fade out, - in milliseconds. */ - virtual void fadeOut(u32 time) = 0; - - //! Returns if the fade in or out process is done. - virtual bool isReady() const = 0; - }; - - -} // end namespace gui -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IGUIListBox.h b/irrlicht-1.6/include/IGUIListBox.h deleted file mode 100644 index a88e5118e..000000000 --- a/irrlicht-1.6/include/IGUIListBox.h +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_LIST_BOX_H_INCLUDED__ -#define __I_GUI_LIST_BOX_H_INCLUDED__ - -#include "IGUIElement.h" -#include "SColor.h" - -namespace irr -{ -namespace gui -{ - class IGUISpriteBank; - - //! Enumeration for listbox colors - enum EGUI_LISTBOX_COLOR - { - //! Color of text - EGUI_LBC_TEXT=0, - //! Color of selected text - EGUI_LBC_TEXT_HIGHLIGHT, - //! Color of icon - EGUI_LBC_ICON, - //! Color of selected icon - EGUI_LBC_ICON_HIGHLIGHT, - //! Not used, just counts the number of available colors - EGUI_LBC_COUNT - }; - - - //! Default list box GUI element. - class IGUIListBox : public IGUIElement - { - public: - //! constructor - IGUIListBox(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle) - : IGUIElement(EGUIET_LIST_BOX, environment, parent, id, rectangle) {} - - //! returns amount of list items - virtual u32 getItemCount() const = 0; - - //! returns string of a list item. the may id be a value from 0 to itemCount-1 - virtual const wchar_t* getListItem(u32 id) const = 0; - - //! adds an list item, returns id of item - virtual u32 addItem(const wchar_t* text) = 0; - - //! adds an list item with an icon - /** \param text Text of list entry - \param icon Sprite index of the Icon within the current sprite bank. Set it to -1 if you want no icon - \return The id of the new created item */ - virtual u32 addItem(const wchar_t* text, s32 icon) = 0; - - //! Removes an item from the list - virtual void removeItem(u32 index) = 0; - - //! Returns the icon of an item - virtual s32 getIcon(u32 index) const = 0; - - //! Sets the sprite bank which should be used to draw list icons. - /** This font is set to the sprite bank of the built-in-font by - default. A sprite can be displayed in front of every list item. - An icon is an index within the icon sprite bank. Several - default icons are available in the skin through getIcon. */ - virtual void setSpriteBank(IGUISpriteBank* bank) = 0; - - //! clears the list, deletes all items in the listbox - virtual void clear() = 0; - - //! returns id of selected item. returns -1 if no item is selected. - virtual s32 getSelected() const = 0; - - //! sets the selected item. Set this to -1 if no item should be selected - virtual void setSelected(s32 index) = 0; - - //! sets the selected item. Set this to 0 if no item should be selected - virtual void setSelected(const wchar_t *item) = 0; - - //! set whether the listbox should scroll to new or newly selected items - virtual void setAutoScrollEnabled(bool scroll) = 0; - - //! returns true if automatic scrolling is enabled, false if not. - virtual bool isAutoScrollEnabled() const = 0; - - //! set all item colors at given index to color - virtual void setItemOverrideColor(u32 index, const video::SColor &color) = 0; - - //! set all item colors of specified type at given index to color - virtual void setItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType, const video::SColor &color) = 0; - - //! clear all item colors at index - virtual void clearItemOverrideColor(u32 index) = 0; - - //! clear item color at index for given colortype - virtual void clearItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType) = 0; - - //! has the item at index its color overwritten? - virtual bool hasItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType) const = 0; - - //! return the overwrite color at given item index. - virtual video::SColor getItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType) const = 0; - - //! return the default color which is used for the given colorType - virtual video::SColor getItemDefaultColor(EGUI_LISTBOX_COLOR colorType) const = 0; - - //! set the item at the given index - virtual void setItem(u32 index, const wchar_t* text, s32 icon) = 0; - - //! Insert the item at the given index - /** \return The index on success or -1 on failure. */ - virtual s32 insertItem(u32 index, const wchar_t* text, s32 icon) = 0; - - //! Swap the items at the given indices - virtual void swapItems(u32 index1, u32 index2) = 0; - - //! set global itemHeight - virtual void setItemHeight( s32 height ) = 0; - - //! Sets whether to draw the background - virtual void setDrawBackground(bool draw) = 0; -}; - - -} // end namespace gui -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IGUIMeshViewer.h b/irrlicht-1.6/include/IGUIMeshViewer.h deleted file mode 100644 index 5bc499f5f..000000000 --- a/irrlicht-1.6/include/IGUIMeshViewer.h +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_MESH_VIEWER_H_INCLUDED__ -#define __I_GUI_MESH_VIEWER_H_INCLUDED__ - -#include "IGUIElement.h" - -namespace irr -{ - -namespace video -{ - class SMaterial; -} // end namespace video - -namespace scene -{ - class IAnimatedMesh; -} // end namespace scene - -namespace gui -{ - - //! 3d mesh viewing GUI element. - class IGUIMeshViewer : public IGUIElement - { - public: - - //! constructor - IGUIMeshViewer(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle) - : IGUIElement(EGUIET_MESH_VIEWER, environment, parent, id, rectangle) {} - - //! Sets the mesh to be shown - virtual void setMesh(scene::IAnimatedMesh* mesh) = 0; - - //! Gets the displayed mesh - virtual scene::IAnimatedMesh* getMesh() const = 0; - - //! Sets the material - virtual void setMaterial(const video::SMaterial& material) = 0; - - //! Gets the material - virtual const video::SMaterial& getMaterial() const = 0; - }; - - -} // end namespace gui -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IGUIScrollBar.h b/irrlicht-1.6/include/IGUIScrollBar.h deleted file mode 100644 index 2348df219..000000000 --- a/irrlicht-1.6/include/IGUIScrollBar.h +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_SCROLL_BAR_H_INCLUDED__ -#define __I_GUI_SCROLL_BAR_H_INCLUDED__ - -#include "IGUIElement.h" - -namespace irr -{ -namespace gui -{ - - //! Default scroll bar GUI element. - class IGUIScrollBar : public IGUIElement - { - public: - - //! constructor - IGUIScrollBar(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle) - : IGUIElement(EGUIET_SCROLL_BAR, environment, parent, id, rectangle) {} - - //! sets the maximum value of the scrollbar. - virtual void setMax(s32 max) = 0; - //! gets the maximum value of the scrollbar. - virtual s32 getMax() const = 0; - - //! sets the maximum value of the scrollbar. - virtual void setMin(s32 max) = 0; - //! gets the maximum value of the scrollbar. - virtual s32 getMin() const = 0; - - //! gets the small step value - virtual s32 getSmallStep() const = 0; - - //! Sets the small step - /** That is the amount that the value changes by when clicking - on the buttons or using the cursor keys. */ - virtual void setSmallStep(s32 step) = 0; - - //! gets the large step value - virtual s32 getLargeStep() const = 0; - - //! Sets the large step - /** That is the amount that the value changes by when clicking - in the tray, or using the page up and page down keys. */ - virtual void setLargeStep(s32 step) = 0; - - //! gets the current position of the scrollbar - virtual s32 getPos() const = 0; - - //! sets the current position of the scrollbar - virtual void setPos(s32 pos) = 0; - }; - - -} // end namespace gui -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IGUISkin.h b/irrlicht-1.6/include/IGUISkin.h deleted file mode 100644 index 2a8765cb8..000000000 --- a/irrlicht-1.6/include/IGUISkin.h +++ /dev/null @@ -1,522 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_SKIN_H_INCLUDED__ -#define __I_GUI_SKIN_H_INCLUDED__ - -#include "IAttributeExchangingObject.h" -#include "EGUIAlignment.h" -#include "SColor.h" -#include "rect.h" - -namespace irr -{ -namespace gui -{ - class IGUIFont; - class IGUISpriteBank; - class IGUIElement; - - //! Enumeration of available default skins. - /** To set one of the skins, use the following code, for example to set - the Windows classic skin: - \code - gui::IGUISkin* newskin = environment->createSkin(gui::EGST_WINDOWS_CLASSIC); - environment->setSkin(newskin); - newskin->drop(); - \endcode - */ - enum EGUI_SKIN_TYPE - { - //! Default windows look and feel - EGST_WINDOWS_CLASSIC=0, - //! Like EGST_WINDOWS_CLASSIC, but with metallic shaded windows and buttons - EGST_WINDOWS_METALLIC, - //! Burning's skin - EGST_BURNING_SKIN, - - //! An unknown skin, not serializable at present - EGST_UNKNOWN - }; - - //! Names for gui element types - const c8* const GUISkinTypeNames[] = - { - "windowsClassic", - "windowsMetallic", - "burning", - "unknown", - 0, - }; - - - //! Enumeration for skin colors - enum EGUI_DEFAULT_COLOR - { - //! Dark shadow for three-dimensional display elements. - EGDC_3D_DARK_SHADOW = 0, - //! Shadow color for three-dimensional display elements (for edges facing away from the light source). - EGDC_3D_SHADOW, - //! Face color for three-dimensional display elements and for dialog box backgrounds. - EGDC_3D_FACE, - //! Highlight color for three-dimensional display elements (for edges facing the light source.) - EGDC_3D_HIGH_LIGHT, - //! Light color for three-dimensional display elements (for edges facing the light source.) - EGDC_3D_LIGHT, - //! Active window border. - EGDC_ACTIVE_BORDER, - //! Active window title bar text. - EGDC_ACTIVE_CAPTION, - //! Background color of multiple document interface (MDI) applications. - EGDC_APP_WORKSPACE, - //! Text on a button - EGDC_BUTTON_TEXT, - //! Grayed (disabled) text. - EGDC_GRAY_TEXT, - //! Item(s) selected in a control. - EGDC_HIGH_LIGHT, - //! Text of item(s) selected in a control. - EGDC_HIGH_LIGHT_TEXT, - //! Inactive window border. - EGDC_INACTIVE_BORDER, - //! Inactive window caption. - EGDC_INACTIVE_CAPTION, - //! Tool tip text color - EGDC_TOOLTIP, - //! Tool tip background color - EGDC_TOOLTIP_BACKGROUND, - //! Scrollbar gray area - EGDC_SCROLLBAR, - //! Window background - EGDC_WINDOW, - //! Window symbols like on close buttons, scroll bars and check boxes - EGDC_WINDOW_SYMBOL, - //! Icons in a list or tree - EGDC_ICON, - //! Selected icons in a list or tree - EGDC_ICON_HIGH_LIGHT, - //! this value is not used, it only specifies the amount of default colors - //! available. - EGDC_COUNT - }; - - //! Names for default skin colors - const c8* const GUISkinColorNames[] = - { - "3DDarkShadow", - "3DShadow", - "3DFace", - "3DHighlight", - "3DLight", - "ActiveBorder", - "ActiveCaption", - "AppWorkspace", - "ButtonText", - "GrayText", - "Highlight", - "HighlightText", - "InactiveBorder", - "InactiveCaption", - "ToolTip", - "ToolTipBackground", - "ScrollBar", - "Window", - "WindowSymbol", - "Icon", - "IconHighlight", - 0, - }; - - //! Enumeration for default sizes. - enum EGUI_DEFAULT_SIZE - { - //! default with / height of scrollbar - EGDS_SCROLLBAR_SIZE = 0, - //! height of menu - EGDS_MENU_HEIGHT, - //! width of a window button - EGDS_WINDOW_BUTTON_WIDTH, - //! width of a checkbox check - EGDS_CHECK_BOX_WIDTH, - //! width of a messagebox - EGDS_MESSAGE_BOX_WIDTH, - //! height of a messagebox - EGDS_MESSAGE_BOX_HEIGHT, - //! width of a default button - EGDS_BUTTON_WIDTH, - //! height of a default button - EGDS_BUTTON_HEIGHT, - //! distance for text from background - EGDS_TEXT_DISTANCE_X, - //! distance for text from background - EGDS_TEXT_DISTANCE_Y, - //! distance for text in the title bar, from the left of the window rect - EGDS_TITLEBARTEXT_DISTANCE_X, - //! distance for text in the title bar, from the top of the window rect - EGDS_TITLEBARTEXT_DISTANCE_Y, - //! this value is not used, it only specifies the amount of default sizes - //! available. - EGDS_COUNT - }; - - - //! Names for default skin sizes - const c8* const GUISkinSizeNames[] = - { - "ScrollBarSize", - "MenuHeight", - "WindowButtonWidth", - "CheckBoxWidth", - "MessageBoxWidth", - "MessageBoxHeight", - "ButtonWidth", - "ButtonHeight", - "TextDistanceX", - "TextDistanceY", - "TitleBarTextX", - "TitleBarTextY", - 0, - }; - - - enum EGUI_DEFAULT_TEXT - { - //! Text for the OK button on a message box - EGDT_MSG_BOX_OK = 0, - //! Text for the Cancel button on a message box - EGDT_MSG_BOX_CANCEL, - //! Text for the Yes button on a message box - EGDT_MSG_BOX_YES, - //! Text for the No button on a message box - EGDT_MSG_BOX_NO, - //! Tooltip text for window close button - EGDT_WINDOW_CLOSE, - //! Tooltip text for window maximize button - EGDT_WINDOW_MAXIMIZE, - //! Tooltip text for window minimize button - EGDT_WINDOW_MINIMIZE, - //! Tooltip text for window restore button - EGDT_WINDOW_RESTORE, - - //! this value is not used, it only specifies the number of default texts - EGDT_COUNT - }; - - //! Names for default skin sizes - const c8* const GUISkinTextNames[] = - { - "MessageBoxOkay", - "MessageBoxCancel", - "MessageBoxYes", - "MessageBoxNo", - "WindowButtonClose", - "WindowButtonMaximize", - "WindowButtonMinimize", - "WindowButtonRestore", - 0, - }; - - //! Customizable symbols for GUI - enum EGUI_DEFAULT_ICON - { - //! maximize window button - EGDI_WINDOW_MAXIMIZE = 0, - //! restore window button - EGDI_WINDOW_RESTORE, - //! close window button - EGDI_WINDOW_CLOSE, - //! minimize window button - EGDI_WINDOW_MINIMIZE, - //! resize icon for bottom right corner of a window - EGDI_WINDOW_RESIZE, - //! scroll bar up button - EGDI_CURSOR_UP, - //! scroll bar down button - EGDI_CURSOR_DOWN, - //! scroll bar left button - EGDI_CURSOR_LEFT, - //! scroll bar right button - EGDI_CURSOR_RIGHT, - //! icon for menu children - EGDI_MENU_MORE, - //! tick for checkbox - EGDI_CHECK_BOX_CHECKED, - //! down arrow for dropdown menus - EGDI_DROP_DOWN, - //! smaller up arrow - EGDI_SMALL_CURSOR_UP, - //! smaller down arrow - EGDI_SMALL_CURSOR_DOWN, - //! selection dot in a radio button - EGDI_RADIO_BUTTON_CHECKED, - //! << icon indicating there is more content to the left - EGDI_MORE_LEFT, - //! >> icon indicating that there is more content to the right - EGDI_MORE_RIGHT, - //! icon indicating that there is more content above - EGDI_MORE_UP, - //! icon indicating that there is more content below - EGDI_MORE_DOWN, - //! plus icon for trees - EGDI_EXPAND, - //! minus icon for trees - EGDI_COLLAPSE, - //! file icon for file selection - EGDI_FILE, - //! folder icon for file selection - EGDI_DIRECTORY, - - //! value not used, it only specifies the number of icons - EGDI_COUNT - }; - - const c8* const GUISkinIconNames[] = - { - "windowMaximize", - "windowRestore", - "windowClose", - "windowMinimize", - "windowResize", - "cursorUp", - "cursorDown", - "cursorLeft", - "cursorRight", - "menuMore", - "checkBoxChecked", - "dropDown", - "smallCursorUp", - "smallCursorDown", - "radioButtonChecked", - "moreLeft", - "moreRight", - "moreUp", - "moreDown", - "expand", - "collapse", - "file", - "directory", - 0 - }; - - // Customizable fonts - enum EGUI_DEFAULT_FONT - { - //! For static text, edit boxes, lists and most other places - EGDF_DEFAULT=0, - //! Font for buttons - EGDF_BUTTON, - //! Font for window title bars - EGDF_WINDOW, - //! Font for menu items - EGDF_MENU, - //! Font for tooltips - EGDF_TOOLTIP, - //! this value is not used, it only specifies the amount of default fonts - //! available. - EGDF_COUNT - }; - - const c8* const GUISkinFontNames[] = - { - "defaultFont", - "buttonFont", - "windowFont", - "menuFont", - "tooltipFont", - 0 - }; - - //! A skin modifies the look of the GUI elements. - class IGUISkin : public virtual io::IAttributeExchangingObject - { - public: - - //! returns default color - virtual video::SColor getColor(EGUI_DEFAULT_COLOR color) const = 0; - - //! sets a default color - virtual void setColor(EGUI_DEFAULT_COLOR which, video::SColor newColor) = 0; - - //! returns size for the given size type - virtual s32 getSize(EGUI_DEFAULT_SIZE size) const = 0; - - //! Returns a default text. - /** For example for Message box button captions: - "OK", "Cancel", "Yes", "No" and so on. */ - virtual const wchar_t* getDefaultText(EGUI_DEFAULT_TEXT text) const = 0; - - //! Sets a default text. - /** For example for Message box button captions: - "OK", "Cancel", "Yes", "No" and so on. */ - virtual void setDefaultText(EGUI_DEFAULT_TEXT which, const wchar_t* newText) = 0; - - //! sets a default size - virtual void setSize(EGUI_DEFAULT_SIZE which, s32 size) = 0; - - //! returns the default font - virtual IGUIFont* getFont(EGUI_DEFAULT_FONT which=EGDF_DEFAULT) const = 0; - - //! sets a default font - virtual void setFont(IGUIFont* font, EGUI_DEFAULT_FONT which=EGDF_DEFAULT) = 0; - - //! returns the sprite bank - virtual IGUISpriteBank* getSpriteBank() const = 0; - - //! sets the sprite bank - virtual void setSpriteBank(IGUISpriteBank* bank) = 0; - - //! Returns a default icon - /** Returns the sprite index within the sprite bank */ - virtual u32 getIcon(EGUI_DEFAULT_ICON icon) const = 0; - - //! Sets a default icon - /** Sets the sprite index used for drawing icons like arrows, - close buttons and ticks in checkboxes - \param icon: Enum specifying which icon to change - \param index: The sprite index used to draw this icon */ - virtual void setIcon(EGUI_DEFAULT_ICON icon, u32 index) = 0; - - //! draws a standard 3d button pane - /** Used for drawing for example buttons in normal state. - It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and - EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details. - \param element: Pointer to the element which wishes to draw this. This parameter - is usually not used by IGUISkin, but can be used for example by more complex - implementations to find out how to draw the part exactly. - \param rect: Defining area where to draw. - \param clip: Clip area. */ - virtual void draw3DButtonPaneStandard(IGUIElement* element, - const core::rect<s32>& rect, - const core::rect<s32>* clip=0) = 0; - - //! draws a pressed 3d button pane - /** Used for drawing for example buttons in pressed state. - It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and - EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details. - \param element: Pointer to the element which wishes to draw this. This parameter - is usually not used by IGUISkin, but can be used for example by more complex - implementations to find out how to draw the part exactly. - \param rect: Defining area where to draw. - \param clip: Clip area. */ - virtual void draw3DButtonPanePressed(IGUIElement* element, - const core::rect<s32>& rect, - const core::rect<s32>* clip=0) = 0; - - //! draws a sunken 3d pane - /** Used for drawing the background of edit, combo or check boxes. - \param element: Pointer to the element which wishes to draw this. This parameter - is usually not used by IGUISkin, but can be used for example by more complex - implementations to find out how to draw the part exactly. - \param bgcolor: Background color. - \param flat: Specifies if the sunken pane should be flat or displayed as sunken - deep into the ground. - \param fillBackGround: Specifies if the background should be filled with the background - color or not be drawn at all. - \param rect: Defining area where to draw. - \param clip: Clip area. */ - virtual void draw3DSunkenPane(IGUIElement* element, - video::SColor bgcolor, bool flat, bool fillBackGround, - const core::rect<s32>& rect, - const core::rect<s32>* clip=0) = 0; - - //! draws a window background - /** Used for drawing the background of dialogs and windows. - \param element: Pointer to the element which wishes to draw this. This parameter - is usually not used by IGUISkin, but can be used for example by more complex - implementations to find out how to draw the part exactly. - \param titleBarColor: Title color. - \param drawTitleBar: True to enable title drawing. - \param rect: Defining area where to draw. - \param clip: Clip area. - \return Returns rect where it would be good to draw title bar text. */ - virtual core::rect<s32> draw3DWindowBackground(IGUIElement* element, - bool drawTitleBar, video::SColor titleBarColor, - const core::rect<s32>& rect, - const core::rect<s32>* clip=0) = 0; - - //! draws a standard 3d menu pane - /** Used for drawing for menus and context menus. - It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and - EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details. - \param element: Pointer to the element which wishes to draw this. This parameter - is usually not used by IGUISkin, but can be used for example by more complex - implementations to find out how to draw the part exactly. - \param rect: Defining area where to draw. - \param clip: Clip area. */ - virtual void draw3DMenuPane(IGUIElement* element, - const core::rect<s32>& rect, - const core::rect<s32>* clip=0) = 0; - - //! draws a standard 3d tool bar - /** Used for drawing for toolbars and menus. - \param element: Pointer to the element which wishes to draw this. This parameter - is usually not used by IGUISkin, but can be used for example by more complex - implementations to find out how to draw the part exactly. - \param rect: Defining area where to draw. - \param clip: Clip area. */ - virtual void draw3DToolBar(IGUIElement* element, - const core::rect<s32>& rect, - const core::rect<s32>* clip=0) = 0; - - //! draws a tab button - /** Used for drawing for tab buttons on top of tabs. - \param element: Pointer to the element which wishes to draw this. This parameter - is usually not used by IGUISkin, but can be used for example by more complex - implementations to find out how to draw the part exactly. - \param active: Specifies if the tab is currently active. - \param rect: Defining area where to draw. - \param clip: Clip area. - \param alignment Alignment of GUI element. */ - virtual void draw3DTabButton(IGUIElement* element, bool active, - const core::rect<s32>& rect, const core::rect<s32>* clip=0, gui::EGUI_ALIGNMENT alignment=EGUIA_UPPERLEFT) = 0; - - //! draws a tab control body - /** \param element: Pointer to the element which wishes to draw this. This parameter - is usually not used by IGUISkin, but can be used for example by more complex - implementations to find out how to draw the part exactly. - \param border: Specifies if the border should be drawn. - \param background: Specifies if the background should be drawn. - \param rect: Defining area where to draw. - \param clip: Clip area. - \param tabHeight Height of tab. - \param alignment Alignment of GUI element. */ - virtual void draw3DTabBody(IGUIElement* element, bool border, bool background, - const core::rect<s32>& rect, const core::rect<s32>* clip=0, s32 tabHeight=-1, gui::EGUI_ALIGNMENT alignment=EGUIA_UPPERLEFT ) = 0; - - //! draws an icon, usually from the skin's sprite bank - /** \param element: Pointer to the element which wishes to draw this icon. - This parameter is usually not used by IGUISkin, but can be used for example - by more complex implementations to find out how to draw the part exactly. - \param icon: Specifies the icon to be drawn. - \param position: The position to draw the icon - \param starttime: The time at the start of the animation - \param currenttime: The present time, used to calculate the frame number - \param loop: Whether the animation should loop or not - \param clip: Clip area. */ - virtual void drawIcon(IGUIElement* element, EGUI_DEFAULT_ICON icon, - const core::position2di position, u32 starttime=0, u32 currenttime=0, - bool loop=false, const core::rect<s32>* clip=0) = 0; - - //! draws a 2d rectangle. - /** \param element: Pointer to the element which wishes to draw this icon. - This parameter is usually not used by IGUISkin, but can be used for example - by more complex implementations to find out how to draw the part exactly. - \param color: Color of the rectangle to draw. The alpha component specifies how - transparent the rectangle will be. - \param pos: Position of the rectangle. - \param clip: Pointer to rectangle against which the rectangle will be clipped. - If the pointer is null, no clipping will be performed. */ - virtual void draw2DRectangle(IGUIElement* element, const video::SColor &color, - const core::rect<s32>& pos, const core::rect<s32>* clip = 0) = 0; - - //! get the type of this skin - virtual EGUI_SKIN_TYPE getType() const { return EGST_UNKNOWN; } - }; - - -} // end namespace gui -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IGUISpinBox.h b/irrlicht-1.6/include/IGUISpinBox.h deleted file mode 100644 index b55d911e8..000000000 --- a/irrlicht-1.6/include/IGUISpinBox.h +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (C) 2006-2009 Michael Zeilfelder -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_SPIN_BOX_H_INCLUDED__ -#define __I_GUI_SPIN_BOX_H_INCLUDED__ - -#include "IGUIElement.h" - -namespace irr -{ -namespace gui -{ - class IGUIEditBox; - - //! Single line edit box + spin buttons - class IGUISpinBox : public IGUIElement - { - public: - - //! constructor - IGUISpinBox(IGUIEnvironment* environment, IGUIElement* parent, - s32 id, core::rect<s32> rectangle) - : IGUIElement(EGUIET_SPIN_BOX, environment, parent, id, rectangle) {} - - //! Access the edit box used in the spin control - virtual IGUIEditBox* getEditBox() const = 0; - - //! set the current value of the spinbox - /** \param val: value to be set in the spinbox */ - virtual void setValue(f32 val) = 0; - - //! Get the current value of the spinbox - virtual f32 getValue() const = 0; - - //! set the range of values which can be used in the spinbox - /** \param min: minimum value - \param max: maximum value */ - virtual void setRange(f32 min, f32 max) = 0; - - //! get the minimum value which can be used in the spinbox - virtual f32 getMin() const = 0; - - //! get the maximum value which can be used in the spinbox - virtual f32 getMax() const = 0; - - //! Step size by which values are changed when pressing the spinbuttons - /** The step size also determines the number of decimal places to display - \param step: stepsize used for value changes when pressing spinbuttons */ - virtual void setStepSize(f32 step=1.f) = 0; - - //! Sets the number of decimal places to display. - /** \param places: The number of decimal places to display, use -1 to reset */ - virtual void setDecimalPlaces(s32 places) = 0; - - //! get the current step size - virtual f32 getStepSize() const = 0; - }; - - -} // end namespace gui -} // end namespace irr - -#endif // __I_GUI_SPIN_BOX_H_INCLUDED__ - diff --git a/irrlicht-1.6/include/IGUISpriteBank.h b/irrlicht-1.6/include/IGUISpriteBank.h deleted file mode 100644 index ffe434871..000000000 --- a/irrlicht-1.6/include/IGUISpriteBank.h +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_SPRITE_BANK_H_INCLUDED__ -#define __I_GUI_SPRITE_BANK_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "irrArray.h" -#include "SColor.h" -#include "rect.h" - -namespace irr -{ - -namespace video -{ - class ITexture; -} // end namespace video - -namespace gui -{ - -//! A single sprite frame. -struct SGUISpriteFrame -{ - u32 textureNumber; - u32 rectNumber; -}; - -//! A sprite composed of several frames. -struct SGUISprite -{ - SGUISprite() : Frames(), frameTime(0) {} - - core::array<SGUISpriteFrame> Frames; - u32 frameTime; -}; - - -//! Sprite bank interface. -class IGUISpriteBank : public virtual IReferenceCounted -{ -public: - - //! Returns the list of rectangles held by the sprite bank - virtual core::array< core::rect<s32> >& getPositions() = 0; - - //! Returns the array of animated sprites within the sprite bank - virtual core::array< SGUISprite >& getSprites() = 0; - - //! Returns the number of textures held by the sprite bank - virtual u32 getTextureCount() const = 0; - - //! Gets the texture with the specified index - virtual video::ITexture* getTexture(u32 index) const = 0; - - //! Adds a texture to the sprite bank - virtual void addTexture(video::ITexture* texture) = 0; - - //! Changes one of the textures in the sprite bank - virtual void setTexture(u32 index, video::ITexture* texture) = 0; - - //! Draws a sprite in 2d with position and color - virtual void draw2DSprite(u32 index, const core::position2di& pos, - const core::rect<s32>* clip=0, - const video::SColor& color= video::SColor(255,255,255,255), - u32 starttime=0, u32 currenttime=0, - bool loop=true, bool center=false) = 0; - - //! Draws a sprite batch in 2d using an array of positions and a color - virtual void draw2DSpriteBatch(const core::array<u32>& indices, const core::array<core::position2di>& pos, - const core::rect<s32>* clip=0, - const video::SColor& color= video::SColor(255,255,255,255), - u32 starttime=0, u32 currenttime=0, - bool loop=true, bool center=false) = 0; -}; - - -} // end namespace gui -} // end namespace irr - -#endif // __I_GUI_SPRITE_BANK_H_INCLUDED__ - diff --git a/irrlicht-1.6/include/IGUIStaticText.h b/irrlicht-1.6/include/IGUIStaticText.h deleted file mode 100644 index 18cc2440e..000000000 --- a/irrlicht-1.6/include/IGUIStaticText.h +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_STATIC_TEXT_H_INCLUDED__ -#define __I_GUI_STATIC_TEXT_H_INCLUDED__ - -#include "IGUIElement.h" -#include "SColor.h" - -namespace irr -{ -namespace gui -{ - class IGUIFont; - - //! Multi or single line text label. - class IGUIStaticText : public IGUIElement - { - public: - - //! constructor - IGUIStaticText(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle) - : IGUIElement(EGUIET_STATIC_TEXT, environment, parent, id, rectangle) {} - - //! Sets another skin independent font. - /** If this is set to zero, the button uses the font of the skin. - \param font: New font to set. */ - virtual void setOverrideFont(IGUIFont* font=0) = 0; - - //! Gets the override font (if any) - /** \return The override font (may be 0) */ - virtual IGUIFont* getOverrideFont(void) const = 0; - - //! Sets another color for the text. - /** If set, the static text does not use the EGDC_BUTTON_TEXT color defined - in the skin, but the set color instead. You don't need to call - IGUIStaticText::enableOverrrideColor(true) after this, this is done - by this function. - If you set a color, and you want the text displayed with the color - of the skin again, call IGUIStaticText::enableOverrideColor(false); - \param color: New color of the text. */ - virtual void setOverrideColor(video::SColor color) = 0; - - //! Gets the override color - /** \return: The override color */ - virtual video::SColor const& getOverrideColor(void) const = 0; - - //! Sets if the static text should use the overide color or the color in the gui skin. - /** \param enable: If set to true, the override color, which can be set - with IGUIStaticText::setOverrideColor is used, otherwise the - EGDC_BUTTON_TEXT color of the skin. */ - virtual void enableOverrideColor(bool enable) = 0; - - //! Checks if an override color is enabled - /** \return true if the override color is enabled, false otherwise */ - virtual bool isOverrideColorEnabled(void) const = 0; - - //! Sets another color for the background. - virtual void setBackgroundColor(video::SColor color) = 0; - - //! Sets whether to draw the background - virtual void setDrawBackground(bool draw) = 0; - - //! Sets whether to draw the border - virtual void setDrawBorder(bool draw) = 0; - - //! Sets text justification mode - /** \param horizontal: EGUIA_UPPERLEFT for left justified (default), - EGUIA_LOWEERRIGHT for right justified, or EGUIA_CENTER for centered text. - \param vertical: EGUIA_UPPERLEFT to align with top edge, - EGUIA_LOWEERRIGHT for bottom edge, or EGUIA_CENTER for centered text (default). */ - virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical) = 0; - - //! Enables or disables word wrap for using the static text as multiline text control. - /** \param enable: If set to true, words going over one line are - broken on to the next line. */ - virtual void setWordWrap(bool enable) = 0; - - //! Checks if word wrap is enabled - /** \return true if word wrap is enabled, false otherwise */ - virtual bool isWordWrapEnabled(void) const = 0; - - //! Returns the height of the text in pixels when it is drawn. - /** This is useful for adjusting the layout of gui elements based on the height - of the multiline text in this element. - \return Height of text in pixels. */ - virtual s32 getTextHeight() const = 0; - - //! Returns the width of the current text, in the current font - /** If the text is broken, this returns the width of the widest line - \return The width of the text, or the widest broken line. */ - virtual s32 getTextWidth(void) const = 0; - }; - - -} // end namespace gui -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IGUITabControl.h b/irrlicht-1.6/include/IGUITabControl.h deleted file mode 100644 index ff73825d8..000000000 --- a/irrlicht-1.6/include/IGUITabControl.h +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_TAB_CONTROL_H_INCLUDED__ -#define __I_GUI_TAB_CONTROL_H_INCLUDED__ - -#include "IGUIElement.h" -#include "SColor.h" -#include "IGUISkin.h" - -namespace irr -{ -namespace gui -{ - //! A tab, onto which other gui elements could be added. - class IGUITab : public IGUIElement - { - public: - - //! constructor - IGUITab(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle) - : IGUIElement(EGUIET_TAB, environment, parent, id, rectangle) {} - - //! Returns number of tab if in tabcontrol. - /** Can be accessed later IGUITabControl::getTab() by this number. */ - virtual s32 getNumber() const = 0; - - //! sets if the tab should draw its background - virtual void setDrawBackground(bool draw=true) = 0; - - //! sets the color of the background, if it should be drawn. - virtual void setBackgroundColor(video::SColor c) = 0; - - //! returns true if the tab is drawing its background, false if not - virtual bool isDrawingBackground() const = 0; - - //! returns the color of the background - virtual video::SColor getBackgroundColor() const = 0; - - //! sets the color of the text - virtual void setTextColor(video::SColor c) = 0; - - //! gets the color of the text - virtual video::SColor getTextColor() const = 0; - }; - - //! A standard tab control - class IGUITabControl : public IGUIElement - { - public: - - //! constructor - IGUITabControl(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle) - : IGUIElement(EGUIET_TAB_CONTROL, environment, parent, id, rectangle) {} - - //! Adds a tab - virtual IGUITab* addTab(const wchar_t* caption, s32 id=-1) = 0; - - //! Returns amount of tabs in the tabcontrol - virtual s32 getTabCount() const = 0; - - //! Returns a tab based on zero based index - /** \param idx: zero based index of tab. Is a value betwenn 0 and getTabcount()-1; - \return Returns pointer to the Tab. Returns 0 if no tab - is corresponding to this tab. */ - virtual IGUITab* getTab(s32 idx) const = 0; - - //! Brings a tab to front. - /** \param idx: number of the tab. - \return Returns true if successful. */ - virtual bool setActiveTab(s32 idx) = 0; - - //! Brings a tab to front. - /** \param tab: pointer to the tab. - \return Returns true if successful. */ - virtual bool setActiveTab(IGUIElement *tab) = 0; - - //! Returns which tab is currently active - virtual s32 getActiveTab() const = 0; - - //! Set the height of the tabs - virtual void setTabHeight( s32 height ) = 0; - - //! Get the height of the tabs - /** return Returns the height of the tabs */ - virtual s32 getTabHeight() const = 0; - - //! set the maximal width of a tab. Per default width is 0 which means "no width restriction". - virtual void setTabMaxWidth(s32 width ) = 0; - - //! get the maximal width of a tab - virtual s32 getTabMaxWidth() const = 0; - - //! Set the alignment of the tabs - /** Use EGUIA_UPPERLEFT or EGUIA_LOWERRIGHT */ - virtual void setTabVerticalAlignment( gui::EGUI_ALIGNMENT alignment ) = 0; - - //! Get the alignment of the tabs - /** return Returns the alignment of the tabs */ - virtual gui::EGUI_ALIGNMENT getTabVerticalAlignment() const = 0; - - //! Set the extra width added to tabs on each side of the text - virtual void setTabExtraWidth( s32 extraWidth ) = 0; - - //! Get the extra width added to tabs on each side of the text - /** return Returns the extra width of the tabs */ - virtual s32 getTabExtraWidth() const = 0; - }; - - -} // end namespace gui -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IGUITable.h b/irrlicht-1.6/include/IGUITable.h deleted file mode 100644 index dc9767267..000000000 --- a/irrlicht-1.6/include/IGUITable.h +++ /dev/null @@ -1,197 +0,0 @@ -// Copyright (C) 2003-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_TABLE_H_INCLUDED__ -#define __I_GUI_TABLE_H_INCLUDED__ - -#include "IGUIElement.h" -#include "irrTypes.h" -#include "SColor.h" -#include "IGUISkin.h" - -namespace irr -{ -namespace gui -{ - - //! modes for ordering used when a column header is clicked - enum EGUI_COLUMN_ORDERING - { - //! Do not use ordering - EGCO_NONE, - - //! Send a EGET_TABLE_HEADER_CHANGED message when a column header is clicked. - EGCO_CUSTOM, - - //! Sort it ascending by it's ascii value like: a,b,c,... - EGCO_ASCENDING, - - //! Sort it descending by it's ascii value like: z,x,y,... - EGCO_DESCENDING, - - //! Sort it ascending on first click, descending on next, etc - EGCO_FLIP_ASCENDING_DESCENDING, - - //! Not used as mode, only to get maximum value for this enum - EGCO_COUNT - }; - - //! Names for EGUI_COLUMN_ORDERING types - const c8* const GUIColumnOrderingNames[] = - { - "none", - "custom", - "ascend", - "descend", - "ascend_descend", - 0, - }; - - enum EGUI_ORDERING_MODE - { - //! No element ordering - EGOM_NONE, - - //! Elements are ordered from the smallest to the largest. - EGOM_ASCENDING, - - //! Elements are ordered from the largest to the smallest. - EGOM_DESCENDING, - - //! this value is not used, it only specifies the amount of default ordering types - //! available. - EGOM_COUNT - }; - - const c8* const GUIOrderingModeNames[] = - { - "none", - "ascending", - "descending", - 0 - }; - - enum EGUI_TABLE_DRAW_FLAGS - { - EGTDF_ROWS = 1, - EGTDF_COLUMNS = 2, - EGTDF_ACTIVE_ROW = 4, - EGTDF_COUNT - }; - - //! Default list box GUI element. - class IGUITable : public IGUIElement - { - public: - //! constructor - IGUITable(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle) - : IGUIElement(EGUIET_TABLE, environment, parent, id, rectangle) {} - - //! Adds a column - /** If columnIndex is outside the current range, do push new colum at the end */ - virtual void addColumn(const wchar_t* caption, s32 columnIndex=-1) = 0; - - //! remove a column from the table - virtual void removeColumn(u32 columnIndex) = 0; - - //! Returns the number of columns in the table control - virtual s32 getColumnCount() const = 0; - - //! Makes a column active. This will trigger an ordering process. - /** \param idx: The id of the column to make active. - \param doOrder: Do also the ordering which depending on mode for active column - \return True if successful. */ - virtual bool setActiveColumn(s32 idx, bool doOrder=false) = 0; - - //! Returns which header is currently active - virtual s32 getActiveColumn() const = 0; - - //! Returns the ordering used by the currently active column - virtual EGUI_ORDERING_MODE getActiveColumnOrdering() const = 0; - - //! Set the width of a column - virtual void setColumnWidth(u32 columnIndex, u32 width) = 0; - - //! columns can be resized by drag 'n drop - virtual void setResizableColumns(bool resizable) = 0; - - //! can columns be resized by dran 'n drop? - virtual bool hasResizableColumns() const = 0; - - //! This tells the table control which ordering mode should be used when a column header is clicked. - /** \param columnIndex The index of the column header. - \param mode: One of the modes defined in EGUI_COLUMN_ORDERING */ - virtual void setColumnOrdering(u32 columnIndex, EGUI_COLUMN_ORDERING mode) = 0; - - //! Returns which row is currently selected - virtual s32 getSelected() const = 0; - - //! set wich row is currently selected - virtual void setSelected( s32 index ) = 0; - - //! Get amount of rows in the tabcontrol - virtual s32 getRowCount() const = 0; - - //! adds a row to the table - /** \param rowIndex Zero based index of rows. The row will be - inserted at this position, if a row already exist there, it - will be placed after it. If the row is larger than the actual - number of row by more than one, it won't be created. Note that - if you create a row that's not at the end, there might be - performance issues. - \return index of inserted row. */ - virtual u32 addRow(u32 rowIndex) = 0; - - //! Remove a row from the table - virtual void removeRow(u32 rowIndex) = 0; - - //! clears the table rows, but keeps the columns intact - virtual void clearRows() = 0; - - //! Swap two row positions. This is useful for a custom ordering algo. - virtual void swapRows(u32 rowIndexA, u32 rowIndexB) = 0; - - //! This tells the table to start ordering all the rows. - /** You need to explicitly tell the table to re order the rows - when a new row is added or the cells data is changed. This - makes the system more flexible and doesn't make you pay the - cost of ordering when adding a lot of rows. - \param columnIndex: When set to -1 the active column is used. - \param mode Ordering mode of the rows. */ - virtual void orderRows(s32 columnIndex=-1, EGUI_ORDERING_MODE mode=EGOM_NONE) = 0; - - //! Set the text of a cell - virtual void setCellText(u32 rowIndex, u32 columnIndex, const core::stringw& text) = 0; - - //! Set the text of a cell, and set a color of this cell. - virtual void setCellText(u32 rowIndex, u32 columnIndex, const core::stringw& text, video::SColor color) = 0; - - //! Set the data of a cell - virtual void setCellData(u32 rowIndex, u32 columnIndex, void *data) = 0; - - //! Set the color of a cell text - virtual void setCellColor(u32 rowIndex, u32 columnIndex, video::SColor color) = 0; - - //! Get the text of a cell - virtual const wchar_t* getCellText(u32 rowIndex, u32 columnIndex ) const = 0; - - //! Get the data of a cell - virtual void* getCellData(u32 rowIndex, u32 columnIndex ) const = 0; - - //! clears the table, deletes all items in the table - virtual void clear() = 0; - - //! Set flags, as defined in EGUI_TABLE_DRAW_FLAGS, which influence the layout - virtual void setDrawFlags(s32 flags) = 0; - - //! Get the flags, as defined in EGUI_TABLE_DRAW_FLAGS, which influence the layout - virtual s32 getDrawFlags() const = 0; - }; - - -} // end namespace gui -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IGUIToolbar.h b/irrlicht-1.6/include/IGUIToolbar.h deleted file mode 100644 index 962d624d1..000000000 --- a/irrlicht-1.6/include/IGUIToolbar.h +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_TOOL_BAR_H_INCLUDED__ -#define __I_GUI_TOOL_BAR_H_INCLUDED__ - -#include "IGUIElement.h" - -namespace irr -{ -namespace video -{ - class ITexture; -} // end namespace video -namespace gui -{ - class IGUIButton; - - //! Stays at the top of its parent like the menu bar and contains tool buttons - class IGUIToolBar : public IGUIElement - { - public: - - //! constructor - IGUIToolBar(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle) - : IGUIElement(EGUIET_TOOL_BAR, environment, parent, id, rectangle) {} - - //! Adds a button to the tool bar - virtual IGUIButton* addButton(s32 id=-1, const wchar_t* text=0,const wchar_t* tooltiptext=0, - video::ITexture* img=0, video::ITexture* pressedimg=0, - bool isPushButton=false, bool useAlphaChannel=false) = 0; - }; - - -} // end namespace gui -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IGUITreeView.h b/irrlicht-1.6/include/IGUITreeView.h deleted file mode 100644 index 2d2cace2e..000000000 --- a/irrlicht-1.6/include/IGUITreeView.h +++ /dev/null @@ -1,277 +0,0 @@ -// This file is part of the "Irrlicht Engine". -// written by Reinhard Ostermeier, reinhard@nospam.r-ostermeier.de - -#ifndef __I_GUI_TREE_VIEW_H_INCLUDED__ -#define __I_GUI_TREE_VIEW_H_INCLUDED__ - -#include "IGUIElement.h" -#include "IGUIImageList.h" -#include "irrTypes.h" - -namespace irr -{ -namespace gui -{ - class IGUIFont; - class IGUITreeView; - - - //! Node for gui tree view - class IGUITreeViewNode : public IReferenceCounted - { - public: - //! constructor - IGUITreeViewNode() {} - - //! destructor - virtual ~IGUITreeViewNode() {} - - //! returns the owner (tree view) of this node - virtual IGUITreeView* getOwner() const = 0; - - //! Returns the parent node of this node. - //! For the root node this will return 0. - virtual IGUITreeViewNode* getParent() const = 0; - - //! returns the text of the node - virtual const wchar_t* getText() const = 0; - - //! sets the text of the node - virtual void setText( const wchar_t* text ) = 0; - - //! returns the icon text of the node - virtual const wchar_t* getIcon() const = 0; - - //! sets the icon text of the node - virtual void setIcon( const wchar_t* icon ) = 0; - - //! returns the image index of the node - virtual u32 getImageIndex() const = 0; - - //! sets the image index of the node - virtual void setImageIndex( u32 imageIndex ) = 0; - - //! returns the image index of the node - virtual u32 getSelectedImageIndex() const = 0; - - //! sets the image index of the node - virtual void setSelectedImageIndex( u32 imageIndex ) = 0; - - //! returns the user data (void*) of this node - virtual void* getData() const = 0; - - //! sets the user data (void*) of this node - virtual void setData( void* data ) = 0; - - //! returns the user data2 (IReferenceCounted) of this node - virtual IReferenceCounted* getData2() const = 0; - - //! sets the user data2 (IReferenceCounted) of this node - virtual void setData2( IReferenceCounted* data ) = 0; - - //! returns the child item count - virtual u32 getChildCount() const = 0; - - //! removes all childs (recursive) from this node - virtual void clearChilds() = 0; - - //! returns true if this node has child nodes - virtual bool hasChilds() const = 0; - - //! Adds a new node behind the last child node. - //! \param text text of the new node - //! \param icon icon text of the new node - //! \param imageIndex index of the image for the new node (-1 = none) - //! \param selectedImageIndex index of the selected image for the new node (-1 = same as imageIndex) - //! \param data user data (void*) of the new node - //! \param data2 user data2 (IReferenceCounted*) of the new node - //! \return - //! returns the new node - virtual IGUITreeViewNode* addChildBack( - const wchar_t* text, - const wchar_t* icon = 0, - s32 imageIndex = -1, - s32 selectedImageIndex = -1, - void* data = 0, - IReferenceCounted* data2 = 0 ) = 0; - - //! Adds a new node before the first child node. - //! \param text text of the new node - //! \param icon icon text of the new node - //! \param imageIndex index of the image for the new node (-1 = none) - //! \param selectedImageIndex index of the selected image for the new node (-1 = same as imageIndex) - //! \param data user data (void*) of the new node - //! \param data2 user data2 (IReferenceCounted*) of the new node - //! \return - //! returns the new node - virtual IGUITreeViewNode* addChildFront( - const wchar_t* text, - const wchar_t* icon = 0, - s32 imageIndex = -1, - s32 selectedImageIndex = -1, - void* data = 0, - IReferenceCounted* data2 = 0 ) = 0; - - //! Adds a new node behind the other node. - //! The other node has also te be a child node from this node. - //! \param text text of the new node - //! \param icon icon text of the new node - //! \param imageIndex index of the image for the new node (-1 = none) - //! \param selectedImageIndex index of the selected image for the new node (-1 = same as imageIndex) - //! \param data user data (void*) of the new node - //! \param data2 user data2 (IReferenceCounted*) of the new node - //! \return - //! returns the new node or 0 if other is no child node from this - virtual IGUITreeViewNode* insertChildAfter( - IGUITreeViewNode* other, - const wchar_t* text, - const wchar_t* icon = 0, - s32 imageIndex = -1, - s32 selectedImageIndex = -1, - void* data = 0, - IReferenceCounted* data2 = 0 ) = 0; - - //! Adds a new node before the other node. - //! The other node has also te be a child node from this node. - //! \param text text of the new node - //! \param icon icon text of the new node - //! \param imageIndex index of the image for the new node (-1 = none) - //! \param selectedImageIndex index of the selected image for the new node (-1 = same as imageIndex) - //! \param data user data (void*) of the new node - //! \param data2 user data2 (IReferenceCounted*) of the new node - //! \return - //! returns the new node or 0 if other is no child node from this - virtual IGUITreeViewNode* insertChildBefore( - IGUITreeViewNode* other, - const wchar_t* text, - const wchar_t* icon = 0, - s32 imageIndex = -1, - s32 selectedImageIndex = -1, - void* data = 0, - IReferenceCounted* data2 = 0 ) = 0; - - //! Return the first child node from this node. - //! \return - //! Returns the first child node or 0 if this node has no childs. - virtual IGUITreeViewNode* getFirstChild() const = 0; - - //! Return the last child node from this node. - //! \return - //! Returns the last child node or 0 if this node has no childs. - virtual IGUITreeViewNode* getLastChild() const = 0; - - //! Returns the preverse sibling node from this node. - //! \return - //! Returns the preverse sibling node from this node or 0 if this is - //! the first node from the parent node. - virtual IGUITreeViewNode* getPrevSibling() const = 0; - - //! Returns the next sibling node from this node. - //! \return - //! Returns the next sibling node from this node or 0 if this is - //! the last node from the parent node. - virtual IGUITreeViewNode* getNextSibling() const = 0; - - //! Returns the next visible (expanded, may be out of scrolling) node from this node. - //! \return - //! Returns the next visible node from this node or 0 if this is - //! the last visible node. - virtual IGUITreeViewNode* getNextVisible() const = 0; - - //! Deletes a child node. - // \return - //! Returns true if the node was found as a child and is deleted. - virtual bool deleteChild( IGUITreeViewNode* child ) = 0; - - //! Moves a child node one position up. - //! \return - //! Returns true if the node was found as achild node and was not already the first child. - virtual bool moveChildUp( IGUITreeViewNode* child ) = 0; - - //! Moves a child node one position down. - //! \return - //! Returns true if the node was found as achild node and was not already the last child. - virtual bool moveChildDown( IGUITreeViewNode* child ) = 0; - - //! Returns true if the node is expanded (childs are visible). - virtual bool getExpanded() const = 0; - - //! Sets if the node is expanded. - virtual void setExpanded( bool expanded ) = 0; - - //! Returns true if the node is currently selected. - virtual bool getSelected() const = 0; - - //! Sets this node as selected. - virtual void setSelected( bool selected ) = 0; - - //! Returns true if this node is the root node. - virtual bool isRoot() const = 0; - - //! Returns the level of this node. - //! The root node has level 0. Direct childs of the root has level 1 ... - virtual s32 getLevel() const = 0; - - //! Returns true if this node is visible (all parents are expanded). - virtual bool isVisible() const = 0; - }; - - - //! Default tree view GUI element. - //! Displays a windows like tree buttons to expand/collaps the child nodes of an node - //! and optional tree lines. - //! Each node consits of an text, an icon text and a void pointer for user data. - class IGUITreeView : public IGUIElement - { - public: - //! constructor - IGUITreeView( IGUIEnvironment* environment, IGUIElement* parent, s32 id, - core::rect<s32> rectangle ) - : IGUIElement( EGUIET_TREE_VIEW, environment, parent, id, rectangle ) {} - - //! destructor - virtual ~IGUITreeView() {} - - //! returns the root node (not visible) from the tree. - virtual IGUITreeViewNode* getRoot() const = 0; - - //! returns the selected node of the tree or 0 if none is selected - virtual IGUITreeViewNode* getSelected() const = 0; - - //! returns true if the tree lines are visible - virtual bool getLinesVisible() const = 0; - - //! sets if the tree lines are visible - //! \param visible true for visible, false for invisible - virtual void setLinesVisible( bool visible ) = 0; - - //! Sets the font which should be used as icon font. This font is set to the Irrlicht engine - //! built-in-font by default. Icons can be displayed in front of every list item. - //! An icon is a string, displayed with the icon font. When using the build-in-font of the - //! Irrlicht engine as icon font, the icon strings defined in GUIIcons.h can be used. - virtual void setIconFont( IGUIFont* font ) = 0; - - //! Sets the image list which should be used for the image and selected image of every node. - //! The default is 0 (no images). - virtual void setImageList( IGUIImageList* imageList ) = 0; - - //! Returns the image list which is used for the nodes. - virtual IGUIImageList* getImageList() const = 0; - - //! Sets if the image is left of the icon. Default is true. - virtual void setImageLeftOfIcon( bool bLeftOf ) = 0; - - //! Returns if the Image is left of the icon. Default is true. - virtual bool getImageLeftOfIcon() const = 0; - - //! Returns the node which is associated to the last event. - //! This pointer is only valid inside the OnEvent call! - virtual IGUITreeViewNode* getLastEventNode() const = 0; - }; - - -} // end namespace gui -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IGUIWindow.h b/irrlicht-1.6/include/IGUIWindow.h deleted file mode 100644 index 81cd9a41d..000000000 --- a/irrlicht-1.6/include/IGUIWindow.h +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GUI_WINDOW_H_INCLUDED__ -#define __I_GUI_WINDOW_H_INCLUDED__ - -#include "IGUIElement.h" -#include "EMessageBoxFlags.h" - -namespace irr -{ -namespace gui -{ - class IGUIButton; - - //! Default moveable window GUI element with border, caption and close icons. - class IGUIWindow : public IGUIElement - { - public: - - //! constructor - IGUIWindow(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle) - : IGUIElement(EGUIET_WINDOW, environment, parent, id, rectangle) {} - - //! Returns pointer to the close button - virtual IGUIButton* getCloseButton() const = 0; - - //! Returns pointer to the minimize button - virtual IGUIButton* getMinimizeButton() const = 0; - - //! Returns pointer to the maximize button - virtual IGUIButton* getMaximizeButton() const = 0; - - //! Returns true if the window can be dragged with the mouse, false if not - virtual bool isDraggable() const = 0; - - //! Sets whether the window can be dragged by the mouse - virtual void setDraggable(bool draggable) = 0; - - //! Set if the window background will be drawn - virtual void setDrawBackground(bool draw) = 0; - - //! Get if the window background will be drawn - virtual bool getDrawBackground() const = 0; - - //! Set if the window titlebar will be drawn - //! Note: If the background is not drawn, then the titlebar is automatically also not drawn - virtual void setDrawTitlebar(bool draw) = 0; - - //! Get if the window titlebar will be drawn - virtual bool getDrawTitlebar() const = 0; - }; - - -} // end namespace gui -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IGeometryCreator.h b/irrlicht-1.6/include/IGeometryCreator.h deleted file mode 100644 index d27ea1b82..000000000 --- a/irrlicht-1.6/include/IGeometryCreator.h +++ /dev/null @@ -1,160 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_GEOMETRY_CREATOR_H_INCLUDED__ -#define __I_GEOMETRY_CREATOR_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "IMesh.h" -#include "IImage.h" - -namespace irr -{ -namespace video -{ - class IVideoDriver; - class SMaterial; -} - -namespace scene -{ - -//! Helper class for creating geometry on the fly. -/** You can get an instance of this class through ISceneManager::getGeometryCreator() */ -class IGeometryCreator : public IReferenceCounted -{ -public: - - //! Creates a simple cube mesh. - /** - \param size Dimensions of the cube. - \return Generated mesh. - */ - virtual IMesh* createCubeMesh(const core::vector3df& size=core::vector3df(5.f,5.f,5.f)) const =0; - - //! Create a pseudo-random mesh representing a hilly terrain. - /** - \param tileSize The size of each time. - \param tileCount The number of tiles in each dimension. - \param material The material to apply to the mesh. - \param hillHeight The maximum height of the hills. - \param countHills The number of hills along each dimension. - \param textureRepeatCount The number of times to repeat the material texture along each dimension. - \return Generated mesh. - */ - virtual IMesh* createHillPlaneMesh( - const core::dimension2d<f32>& tileSize, - const core::dimension2d<u32>& tileCount, - video::SMaterial* material, f32 hillHeight, - const core::dimension2d<f32>& countHills, - const core::dimension2d<f32>& textureRepeatCount) const =0; - - //! Create a terrain mesh from an image representing a heightfield. - /** - \param texture The texture to apply to the terrain. - \param heightmap An image that will be interpreted as a heightmap. The - brightness (average colour) of each pixel is interpreted as a height, - with a 255 brightness pixel producing the maximum height. - \param stretchSize The size that each pixel will produce, i.e. a - 512x512 heightmap - and a stretchSize of (10.f, 20.f) will produce a mesh of size - 5120.f x 10240.f - \param maxHeight The maximum height of the terrain. - \param driver The current video driver. - \param defaultVertexBlockSize (to be documented) - \param debugBorders (to be documented) - \return Generated mesh. - */ - virtual IMesh* createTerrainMesh(video::IImage* texture, - video::IImage* heightmap, - const core::dimension2d<f32>& stretchSize, - f32 maxHeight, video::IVideoDriver* driver, - const core::dimension2d<u32>& defaultVertexBlockSize, - bool debugBorders=false) const =0; - - //! Create an arrow mesh, composed of a cylinder and a cone. - /** - \param tesselationCylinder Number of quads composing the cylinder. - \param tesselationCone Number of triangles composing the cone's roof. - \param height Total height of the arrow - \param cylinderHeight Total height of the cylinder, should be lesser - than total height - \param widthCylinder Diameter of the cylinder - \param widthCone Diameter of the cone's base, should be not smaller - than the cylinder's diameter - \param colorCylinder color of the cylinder - \param colorCone color of the cone - \return Generated mesh. - */ - virtual IMesh* createArrowMesh(const u32 tesselationCylinder = 4, - const u32 tesselationCone = 8, const f32 height = 1.f, - const f32 cylinderHeight = 0.6f, const f32 widthCylinder = 0.05f, - const f32 widthCone = 0.3f, const video::SColor colorCylinder = 0xFFFFFFFF, - const video::SColor colorCone = 0xFFFFFFFF) const =0; - - - //! Create a sphere mesh. - /** - \param radius Radius of the sphere - \param polyCountX Number of quads used for the horizontal tiling - \param polyCountY Number of quads used for the vertical tiling - \return Generated mesh. - */ - virtual IMesh* createSphereMesh(f32 radius = 5.f, - u32 polyCountX = 16, u32 polyCountY = 16) const =0; - - //! Create a cylinder mesh. - /** - \param radius Radius of the cylinder. - \param length Length of the cylinder. - \param tesselation Number of quads around the circumference of the cylinder. - \param color The color of the cylinder. - \param closeTop If true, close the ends of the cylinder, otherwise leave them open. - \param oblique (to be documented) - \return Generated mesh. - */ - virtual IMesh* createCylinderMesh(f32 radius, f32 length, - u32 tesselation, - const video::SColor& color=video::SColor(0xffffffff), - bool closeTop=true, f32 oblique=0.f) const =0; - - //! Create a cone mesh. - /** - \param radius Radius of the cone. - \param length Length of the cone. - \param tesselation Number of quads around the circumference of the cone. - \param colorTop The color of the top of the cone. - \param colorBottom The color of the bottom of the cone. - \param oblique (to be documented) - \return Generated mesh. - */ - virtual IMesh* createConeMesh(f32 radius, f32 length, u32 tesselation, - const video::SColor& colorTop=video::SColor(0xffffffff), - const video::SColor& colorBottom=video::SColor(0xffffffff), - f32 oblique=0.f) const =0; - - //! Create a volume light mesh. - /** - \param subdivideU Horizontal patch count. - \param subdivideV Vertical patch count. - \param footColor Color at the bottom of the light. - \param tailColor Color at the mid of the light. - \param lpDistance Virtual distance of the light point for normals. - \param lightDim Dimensions of the light. - \return Generated mesh. - */ - virtual IMesh* createVolumeLightMesh( - const u32 subdivideU=32, const u32 subdivideV=32, - const video::SColor footColor = 0xffffffff, - const video::SColor tailColor = 0xffffffff, - const f32 lpDistance = 8.f, - const core::vector3df& lightDim = core::vector3df(1.f,1.2f,1.f)) const =0; -}; - - -} // end namespace scene -} // end namespace irr - -#endif // __I_GEOMETRY_CREATOR_H_INCLUDED__ - diff --git a/irrlicht-1.6/include/IImage.h b/irrlicht-1.6/include/IImage.h deleted file mode 100644 index 74bddc993..000000000 --- a/irrlicht-1.6/include/IImage.h +++ /dev/null @@ -1,199 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_IMAGE_H_INCLUDED__ -#define __I_IMAGE_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "position2d.h" -#include "rect.h" -#include "SColor.h" - -namespace irr -{ -namespace video -{ - -//! An enum for the color format of textures used by the Irrlicht Engine. -/** A color format specifies how color information is stored. */ -enum ECOLOR_FORMAT -{ - //! 16 bit color format used by the software driver. - /** It is thus preferred by all other irrlicht engine video drivers. - There are 5 bits for every color component, and a single bit is left - for alpha information. */ - ECF_A1R5G5B5 = 0, - - //! Standard 16 bit color format. - ECF_R5G6B5, - - //! 24 bit color, no alpha channel, but 8 bit for red, green and blue. - ECF_R8G8B8, - - //! Default 32 bit color format. 8 bits are used for every component: red, green, blue and alpha. - ECF_A8R8G8B8, - - /** Floating Point formats. The following formats may only be used for render target textures. */ - - //! 16 bit floating point format using 16 bits for the red channel. - ECF_R16F, - - //! 32 bit floating point format using 16 bits for the red channel and 16 bits for the green channel. - ECF_G16R16F, - - //! 64 bit floating point format 16 bits are used for the red, green, blue and alpha channels. - ECF_A16B16G16R16F, - - //! 32 bit floating point format using 32 bits for the red channel. - ECF_R32F, - - //! 64 bit floating point format using 32 bits for the red channel and 32 bits for the green channel. - ECF_G32R32F, - - //! 128 bit floating point format. 32 bits are used for the red, green, blue and alpha channels. - ECF_A32B32G32R32F, - - //! Unknown color format: - ECF_UNKNOWN -}; - - -//! Interface for software image data. -/** Image loaders create these images from files. IVideoDrivers convert -these images into their (hardware) textures. -*/ -class IImage : public virtual IReferenceCounted -{ -public: - - //! Lock function. Use this to get a pointer to the image data. - /** After you don't need the pointer anymore, you must call unlock(). - \return Pointer to the image data. What type of data is pointed to - depends on the color format of the image. For example if the color - format is ECF_A8R8G8B8, it is of u32. Be sure to call unlock() after - you don't need the pointer any more. */ - virtual void* lock() = 0; - - //! Unlock function. - /** Should be called after the pointer received by lock() is not - needed anymore. */ - virtual void unlock() = 0; - - //! Returns width and height of image data. - virtual const core::dimension2d<u32>& getDimension() const = 0; - - //! Returns bits per pixel. - virtual u32 getBitsPerPixel() const = 0; - - //! Returns bytes per pixel - virtual u32 getBytesPerPixel() const = 0; - - //! Returns image data size in bytes - virtual u32 getImageDataSizeInBytes() const = 0; - - //! Returns image data size in pixels - virtual u32 getImageDataSizeInPixels() const = 0; - - //! Returns a pixel - virtual SColor getPixel(u32 x, u32 y) const = 0; - - //! Sets a pixel - virtual void setPixel(u32 x, u32 y, const SColor &color, bool blend = false ) = 0; - - //! Returns the color format - virtual ECOLOR_FORMAT getColorFormat() const = 0; - - //! Returns mask for red value of a pixel - virtual u32 getRedMask() const = 0; - - //! Returns mask for green value of a pixel - virtual u32 getGreenMask() const = 0; - - //! Returns mask for blue value of a pixel - virtual u32 getBlueMask() const = 0; - - //! Returns mask for alpha value of a pixel - virtual u32 getAlphaMask() const = 0; - - //! Returns pitch of image - virtual u32 getPitch() const =0; - - //! Copies the image into the target, scaling the image to fit - virtual void copyToScaling(void* target, u32 width, u32 height, ECOLOR_FORMAT format=ECF_A8R8G8B8, u32 pitch=0) =0; - - //! Copies the image into the target, scaling the image to fit - virtual void copyToScaling(IImage* target) =0; - - //! copies this surface into another - virtual void copyTo(IImage* target, const core::position2d<s32>& pos=core::position2d<s32>(0,0)) =0; - - //! copies this surface into another - virtual void copyTo(IImage* target, const core::position2d<s32>& pos, const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect=0) =0; - - //! copies this surface into another, using the alpha mask, an cliprect and a color to add with - virtual void copyToWithAlpha(IImage* target, const core::position2d<s32>& pos, - const core::rect<s32>& sourceRect, const SColor &color, - const core::rect<s32>* clipRect = 0) =0; - - //! copies this surface into another, scaling it to fit, appyling a box filter - virtual void copyToScalingBoxFilter(IImage* target, s32 bias = 0, bool blend = false) = 0; - - //! fills the surface with black or white - virtual void fill(const SColor &color) =0; - - //! get the amount of Bits per Pixel of the given color format - static u32 getBitsPerPixelFromFormat(const ECOLOR_FORMAT format) - { - switch(format) - { - case ECF_A1R5G5B5: - return 16; - case ECF_R5G6B5: - return 16; - case ECF_R8G8B8: - return 24; - case ECF_A8R8G8B8: - return 32; - case ECF_R16F: - return 16; - case ECF_G16R16F: - return 32; - case ECF_A16B16G16R16F: - return 64; - case ECF_R32F: - return 32; - case ECF_G32R32F: - return 64; - case ECF_A32B32G32R32F: - return 128; - default: - return 0; - } - } - - //! test if the color format is only viable for RenderTarget textures - /** Since we don't have support for e.g. floating point iimage formats - one should test if the color format can be used for arbitrary usage, or - if it is restricted to RTTs. */ - static bool isRenderTargetOnlyFormat(const ECOLOR_FORMAT format) - { - switch(format) - { - case ECF_A1R5G5B5: - case ECF_R5G6B5: - case ECF_R8G8B8: - case ECF_A8R8G8B8: - return false; - default: - return true; - } - } - -}; - -} // end namespace video -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IImageLoader.h b/irrlicht-1.6/include/IImageLoader.h deleted file mode 100644 index 09258b3f6..000000000 --- a/irrlicht-1.6/include/IImageLoader.h +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_SURFACE_LOADER_H_INCLUDED__ -#define __I_SURFACE_LOADER_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "IImage.h" -#include "path.h" - -namespace irr -{ -namespace io -{ - class IReadFile; -} // end namespace io -namespace video -{ - -//! Class which is able to create a image from a file. -/** If you want the Irrlicht Engine be able to load textures of -currently unsupported file formats (e.g .gif), then implement -this and add your new Surface loader with -IVideoDriver::addExternalImageLoader() to the engine. */ -class IImageLoader : public virtual IReferenceCounted -{ -public: - - //! Check if the file might be loaded by this class - /** Check is based on the file extension (e.g. ".tga") - \param fileName Name of file to check. - \return True if file seems to be loadable. */ - virtual bool isALoadableFileExtension(const io::path& filename) const = 0; - - //! Check if the file might be loaded by this class - /** Check might look into the file. - \param file File handle to check. - \return True if file seems to be loadable. */ - virtual bool isALoadableFileFormat(io::IReadFile* file) const = 0; - - //! Creates a surface from the file - /** \param file File handle to check. - \return Pointer to newly created image, or 0 upon error. */ - virtual IImage* loadImage(io::IReadFile* file) const = 0; -}; - - -} // end namespace video -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IImageWriter.h b/irrlicht-1.6/include/IImageWriter.h deleted file mode 100644 index 1c49f3c8d..000000000 --- a/irrlicht-1.6/include/IImageWriter.h +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef _I_IMAGE_WRITER_H_INCLUDED__ -#define _I_IMAGE_WRITER_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "irrString.h" -#include "coreutil.h" - -namespace irr -{ -namespace io -{ - class IWriteFile; -} // end namespace io - -namespace video -{ - class IImage; - - -//! Interface for writing software image data. -class IImageWriter : public IReferenceCounted -{ -public: - //! Check if this writer can write a file with the given extension - /** \param fileName Name of the file to check. - \return True if file extension specifies a writable type. */ - virtual bool isAWriteableFileExtension(const io::path& filename) const = 0; - - //! Write image to file - /** \param file File handle to write to. - \param image Image to write into file. - \param param Writer specific parameter, influencing e.g. quality. - \return True if image was successfully written. */ - virtual bool writeImage(io::IWriteFile *file, IImage *image, u32 param = 0) const = 0; -}; - -} // namespace video -} // namespace irr - -#endif // _I_IMAGE_WRITER_H_INCLUDED__ - diff --git a/irrlicht-1.6/include/IIndexBuffer.h b/irrlicht-1.6/include/IIndexBuffer.h deleted file mode 100644 index b8d3a7e0a..000000000 --- a/irrlicht-1.6/include/IIndexBuffer.h +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (C) 2008-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_INDEX_BUFFER_H_INCLUDED__ -#define __I_INDEX_BUFFER_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "irrArray.h" - -#include "SVertexIndex.h" - -namespace irr -{ - -namespace video -{ - -} - -namespace scene -{ - - class IIndexBuffer : public virtual IReferenceCounted - { - public: - - virtual void* getData() =0; - - virtual video::E_INDEX_TYPE getType() const =0; - virtual void setType(video::E_INDEX_TYPE IndexType) =0; - - virtual u32 stride() const =0; - - virtual u32 size() const =0; - virtual void push_back (const u32 &element) =0; - virtual u32 operator [](u32 index) const =0; - virtual u32 getLast() =0; - virtual void setValue(u32 index, u32 value) =0; - virtual void set_used(u32 usedNow) =0; - virtual void reallocate(u32 new_size) =0; - virtual u32 allocated_size() const=0; - - virtual void* pointer() =0; - - //! get the current hardware mapping hint - virtual E_HARDWARE_MAPPING getHardwareMappingHint() const =0; - - //! set the hardware mapping hint, for driver - virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint ) =0; - - //! flags the meshbuffer as changed, reloads hardware buffers - virtual void setDirty() = 0; - - //! Get the currently used ID for identification of changes. - /** This shouldn't be used for anything outside the VideoDriver. */ - virtual u32 getChangedID() const = 0; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/ILightManager.h b/irrlicht-1.6/include/ILightManager.h deleted file mode 100644 index 274c698ba..000000000 --- a/irrlicht-1.6/include/ILightManager.h +++ /dev/null @@ -1,60 +0,0 @@ -// Written by Colin MacDonald - all rights assigned to Nikolaus Gebhardt -// Copyright (C) 2008 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_LIGHT_MANAGER_H_INCLUDED__ -#define __I_LIGHT_MANAGER_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "irrArray.h" - -namespace irr -{ -namespace scene -{ - class ILightSceneNode; - - //! ILightManager provides an interface for user applications to manipulate the list - //! of lights in the scene. The light list can be trimmed or re-ordered before device/ - //! hardware lights are created, and/or individual lights can be switched on and off - //! before or after each scene node is rendered. - //! It is assumed that the ILightManager implementation will store any data that it wishes - //! to retain, i.e. the ISceneManager to which it is assigned, the lightList, the current - //! render pass, and the current scene node. - class ILightManager : public IReferenceCounted - { - public: - //! Called after the scene's light list has been built, but before rendering has begun. - //! As actual device/hardware lights are not created until the ESNRP_LIGHT render pass, - //! this provides an opportunity for the light manager to trim or re-order the light - //! list, before any device/hardware lights have actually been created. - //! \param[in] smgr: the Scene Manager - //! \param[inout] lightLight: the Scene Manager's light list, which the light manager may - //! modify. This reference will remain valid until OnPostRender(). - virtual void OnPreRender(core::array<ILightSceneNode*> & lightList) = 0; - - //! Called after the last scene node is rendered. - //! After this call returns, the lightList passed to OnPreRender() becomes invalid. - virtual void OnPostRender(void) = 0; - - //! Called before a render pass begins - //! \param[in] renderPass: the render pass that's about to begin - virtual void OnRenderPassPreRender(E_SCENE_NODE_RENDER_PASS renderPass) = 0; - - //! Called after the render pass specified in OnRenderPassPreRender() ends - //! \param[in] renderPass: the render pass that has finished - virtual void OnRenderPassPostRender(E_SCENE_NODE_RENDER_PASS renderPass) = 0; - - //! Called before the given scene node is rendered - //! \param[in] node: the scene node that's about to be rendered - virtual void OnNodePreRender(ISceneNode* node) = 0; - - //! Called after the the node specified in OnNodePreRender() has been rendered - //! \param[in] node: the scene node that has just been rendered - virtual void OnNodePostRender(ISceneNode* node) = 0; - }; -} // end namespace scene -} // end namespace irr - -#endif diff --git a/irrlicht-1.6/include/ILightSceneNode.h b/irrlicht-1.6/include/ILightSceneNode.h deleted file mode 100644 index 53e9f17fd..000000000 --- a/irrlicht-1.6/include/ILightSceneNode.h +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_LIGHT_SCENE_NODE_H_INCLUDED__ -#define __I_LIGHT_SCENE_NODE_H_INCLUDED__ - -#include "ISceneNode.h" -#include "SLight.h" - -namespace irr -{ -namespace scene -{ - -//! Scene node which is a dynamic light. -/** You can switch the light on and off by making it visible or not. It can be -animated by ordinary scene node animators. If the light type is directional or -spot, the direction of the light source is defined by the rotation of the scene -node (assuming (0,0,1) as the local direction of the light). -*/ -class ILightSceneNode : public ISceneNode -{ -public: - - //! constructor - ILightSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position = core::vector3df(0,0,0)) - : ISceneNode(parent, mgr, id, position) {} - - //! Sets the light data associated with this ILightSceneNode - /** \param light The new light data. */ - virtual void setLightData(const video::SLight& light) = 0; - - //! Gets the light data associated with this ILightSceneNode - /** \return The light data. */ - virtual const video::SLight& getLightData() const = 0; - - //! Gets the light data associated with this ILightSceneNode - /** \return The light data. */ - virtual video::SLight& getLightData() = 0; - - //! Sets if the node should be visible or not. - /** All children of this node won't be visible either, when set - to true. - \param isVisible If the node shall be visible. */ - virtual void setVisible(bool isVisible) = 0; - - //! Sets the light's radius of influence. - /** Outside this radius the light won't lighten geometry and cast no - shadows. Setting the radius will also influence the attenuation, setting - it to (0,1/radius,0). If you want to override this behavior, set the - attenuation after the radius. - \param radius The new radius. */ - virtual void setRadius(f32 radius) = 0; - - //! Gets the light's radius of influence. - /** \return The current radius. */ - virtual f32 getRadius() const = 0; - - //! Sets the light type. - /** \param type The new type. */ - virtual void setLightType(video::E_LIGHT_TYPE type) = 0; - - //! Gets the light type. - /** \return The current light type. */ - virtual video::E_LIGHT_TYPE getLightType() const = 0; - - //! Sets whether this light casts shadows. - /** Enabling this flag won't automatically cast shadows, the meshes - will still need shadow scene nodes attached. But one can enable or - disable distinct lights for shadow casting for performance reasons. - \param shadow True if this light shall cast shadows. */ - virtual void enableCastShadow(bool shadow=true) = 0; - - //! Check whether this light casts shadows. - /** \return True if light would cast shadows, else false. */ - virtual bool getCastShadow() const = 0; -}; - -} // end namespace scene -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/include/ILogger.h b/irrlicht-1.6/include/ILogger.h deleted file mode 100644 index fabdacbc1..000000000 --- a/irrlicht-1.6/include/ILogger.h +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_LOGGER_H_INCLUDED__ -#define __I_LOGGER_H_INCLUDED__ - -#include "IReferenceCounted.h" - -namespace irr -{ - -//! Possible log levels. -enum ELOG_LEVEL -{ - //! High log level, warnings, errors and important information texts are printed out. - ELL_INFORMATION = 0, - - //! Default log level, warnings and errors are printed out - ELL_WARNING, - - //! Low log level, only errors are printed into the log - ELL_ERROR, - - //! Nothing is printed out to the log - ELL_NONE -}; - - -//! Interface for logging messages, warnings and errors -class ILogger : public virtual IReferenceCounted -{ -public: - - //! Destructor - virtual ~ILogger() {} - - //! Returns the current set log level. - virtual ELOG_LEVEL getLogLevel() const = 0; - - //! Sets a new log level. - /** With this value, texts which are sent to the logger are filtered - out. For example setting this value to ELL_WARNING, only warnings and - errors are printed out. Setting it to ELL_INFORMATION, which is the - default setting, warnings, errors and informational texts are printed - out. - \param ll: new log level filter value. */ - virtual void setLogLevel(ELOG_LEVEL ll) = 0; - - //! Prints out a text into the log - /** \param text: Text to print out. - \param ll: Log level of the text. If the text is an error, set - it to ELL_ERROR, if it is warning set it to ELL_WARNING, and if it - is just an informational text, set it to ELL_INFORMATION. Texts are - filtered with these levels. If you want to be a text displayed, - independent on what level filter is set, use ELL_NONE. */ - virtual void log(const c8* text, ELOG_LEVEL ll=ELL_INFORMATION) = 0; - - //! Prints out a text into the log - /** \param text: Text to print out. - \param hint: Additional info. This string is added after a " :" to the - string. - \param ll: Log level of the text. If the text is an error, set - it to ELL_ERROR, if it is warning set it to ELL_WARNING, and if it - is just an informational text, set it to ELL_INFORMATION. Texts are - filtered with these levels. If you want to be a text displayed, - independent on what level filter is set, use ELL_NONE. */ - virtual void log(const c8* text, const c8* hint, ELOG_LEVEL ll=ELL_INFORMATION) = 0; - virtual void log(const c8* text, const wchar_t* hint, ELOG_LEVEL ll=ELL_INFORMATION) = 0; - - //! Prints out a text into the log - /** \param text: Text to print out. - \param hint: Additional info. This string is added after a " :" to the - string. - \param ll: Log level of the text. If the text is an error, set - it to ELL_ERROR, if it is warning set it to ELL_WARNING, and if it - is just an informational text, set it to ELL_INFORMATION. Texts are - filtered with these levels. If you want to be a text displayed, - independent on what level filter is set, use ELL_NONE. */ - virtual void log(const wchar_t* text, const wchar_t* hint, ELOG_LEVEL ll=ELL_INFORMATION) = 0; - - //! Prints out a text into the log - /** \param text: Text to print out. - \param ll: Log level of the text. If the text is an error, set - it to ELL_ERROR, if it is warning set it to ELL_WARNING, and if it - is just an informational text, set it to ELL_INFORMATION. Texts are - filtered with these levels. If you want to be a text displayed, - independent on what level filter is set, use ELL_NONE. */ - virtual void log(const wchar_t* text, ELOG_LEVEL ll=ELL_INFORMATION) = 0; -}; - -} // end namespace - -#endif - diff --git a/irrlicht-1.6/include/IMaterialRenderer.h b/irrlicht-1.6/include/IMaterialRenderer.h deleted file mode 100644 index b9396d577..000000000 --- a/irrlicht-1.6/include/IMaterialRenderer.h +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_MATERIAL_RENDERER_H_INCLUDED__ -#define __I_MATERIAL_RENDERER_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "SMaterial.h" -#include "S3DVertex.h" - -namespace irr -{ -namespace video -{ - -class IVideoDriver; -class IMaterialRendererServices; - -//! Interface for material rendering. -/** Can be used to extend the engine with new materials. Refer to -IVideoDriver::addMaterialRenderer() for more informations on how to extend the -engine with new materials. */ -class IMaterialRenderer : public virtual IReferenceCounted -{ -public: - - //! Called by the IVideoDriver implementation the let the renderer set its needed render states. - /** This is called during the IVideoDriver::setMaterial() call. - When overriding this, you can set some renderstates or for example a - vertex or pixel shader if you like. - \param material: The new material parameters to be set. The renderer - may change the material flags in this material. For example if this - material does not accept the zbuffer = true, it can set it to false. - This is useful, because in the next lastMaterial will be just the - material in this call. - \param lastMaterial: The material parameters which have been set before - this material. - \param resetAllRenderstates: True if all renderstates should really be - reset. This is usually true if the last rendering mode was not a usual - 3d rendering mode, but for example a 2d rendering mode. - You should reset really all renderstates if this is true, no matter if - the lastMaterial had some similar settings. This is used because in - most cases, some common renderstates are not changed if they are - already there, for example bilinear filtering, wireframe, - gouraudshading, lighting, zbuffer, zwriteenable, backfaceculling and - fogenable. - \param services: Interface providing some methods for changing - advanced, internal states of a IVideoDriver. */ - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) {} - - //! Called every time before a new bunch of geometry is being drawn using this material with for example drawIndexedTriangleList() call. - /** OnSetMaterial should normally only be called if the renderer decides - that the renderstates should be changed, it won't be called if for - example two drawIndexedTriangleList() will be called with the same - material set. This method will be called every time. This is useful for - example for materials with shaders, which don't only set new - renderstates but also shader constants. - \param service: Pointer to interface providing methos for setting - constants and other things. - \param vtxtype: Vertex type with which the next rendering will be done. - This can be used by the material renderer to set some specific - optimized shaders or if this is an incompatible vertex type for this - renderer, to refuse rendering for example. - \return Returns true if everything is ok, and false if nothing should - be rendered. The material renderer can choose to return false for - example if he doesn't support the specified vertex type. This is - actually done in D3D8 and D3D9 when using a normal mapped material with - a vertex type other than EVT_TANGENTS. */ - virtual bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype) { return true; } - - //! Called by the IVideoDriver to unset this material. - /** Called during the IVideoDriver::setMaterial() call before the new - material will get the OnSetMaterial() call. */ - virtual void OnUnsetMaterial() {} - - //! Returns if the material is transparent. - /** The scene managment needs to know this - for being able to sort the materials by opaque and transparent. */ - virtual bool isTransparent() const { return false; } - - //! Returns the render capability of the material. - /** Because some more complex materials - are implemented in multiple ways and need special hardware capabilities, it is possible - to query how the current material renderer is performing on the current hardware with this - function. - \return Returns 0 if everything is running fine. Any other value is material renderer - specific and means for example that the renderer switched back to a fall back material because - it cannot use the latest shaders. More specific examples: - Fixed function pipeline materials should return 0 in most cases, parallax mapped - material will only return 0 when at least pixel shader 1.4 is available on that machine. */ - virtual s32 getRenderCapability() const { return 0; } -}; - - -} // end namespace video -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IMaterialRendererServices.h b/irrlicht-1.6/include/IMaterialRendererServices.h deleted file mode 100644 index fc726486a..000000000 --- a/irrlicht-1.6/include/IMaterialRendererServices.h +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_MATERIAL_RENDERER_SERVICES_H_INCLUDED__ -#define __I_MATERIAL_RENDERER_SERVICES_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "SMaterial.h" -#include "S3DVertex.h" - -namespace irr -{ -namespace video -{ - -class IVideoDriver; - - -//! Interface providing some methods for changing advanced, internal states of a IVideoDriver. -class IMaterialRendererServices -{ -public: - - //! Destructor - virtual ~IMaterialRendererServices() {} - - //! Can be called by an IMaterialRenderer to make its work easier. - /** Sets all basic renderstates if needed. - Basic render states are diffuse, ambient, specular, and emissive color, - specular power, bilinear and trilinear filtering, wireframe mode, - grouraudshading, lighting, zbuffer, zwriteenable, backfaceculling and - fog enabling. - \param material The new material to be used. - \param lastMaterial The material used until now. - \param resetAllRenderstates Set to true if all renderstates should be - set, regardless of their current state. */ - virtual void setBasicRenderStates(const SMaterial& material, - const SMaterial& lastMaterial, - bool resetAllRenderstates) = 0; - - //! Sets a constant for the vertex shader based on a name. - /** This can be used if you used a high level shader language like GLSL - or HLSL to create a shader. Example: If you created a shader which has - variables named 'mWorldViewProj' (containing the WorldViewProjection - matrix) and another one named 'fTime' containing one float, you can set - them in your IShaderConstantSetCallBack derived class like this: - \code - virtual void OnSetConstants(video::IMaterialRendererServices* services, s32 userData) - { - video::IVideoDriver* driver = services->getVideoDriver(); - - f32 time = (f32)os::Timer::getTime()/100000.0f; - services->setVertexShaderConstant("fTime", &time, 1); - - core::matrix4 worldViewProj(driver->getTransform(video::ETS_PROJECTION)); - worldViewProj *= driver->getTransform(video::ETS_VIEW); - worldViewProj *= driver->getTransform(video::ETS_WORLD); - services->setVertexShaderConstant("mWorldViewProj", worldViewProj.M, 16); - } - \endcode - \param name Name of the variable - \param floats Pointer to array of floats - \param count Amount of floats in array. - \return True if successful. - */ - virtual bool setVertexShaderConstant(const c8* name, const f32* floats, int count) = 0; - - //! Sets a vertex shader constant. - /** Can be used if you created a shader using pixel/vertex shader - assembler or ARB_fragment_program or ARB_vertex_program. - \param data: Data to be set in the constants - \param startRegister: First register to be set - \param constantAmount: Amount of registers to be set. One register consists of 4 floats. */ - virtual void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1) = 0; - - //! Sets a constant for the pixel shader based on a name. - /** This can be used if you used a high level shader language like GLSL - or HLSL to create a shader. See setVertexShaderConstant() for an - example on how to use this. - \param name Name of the variable - \param floats Pointer to array of floats - \param count Amount of floats in array. - \return True if successful. */ - virtual bool setPixelShaderConstant(const c8* name, const f32* floats, int count) = 0; - - //! Sets a pixel shader constant. - /** Can be used if you created a shader using pixel/vertex shader - assembler or ARB_fragment_program or ARB_vertex_program. - \param data Data to be set in the constants - \param startRegister First register to be set. - \param constantAmount Amount of registers to be set. One register consists of 4 floats. */ - virtual void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1) = 0; - - //! Get pointer to the IVideoDriver interface - /** \return Pointer to the IVideoDriver interface */ - virtual IVideoDriver* getVideoDriver() = 0; -}; - -} // end namespace video -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IMesh.h b/irrlicht-1.6/include/IMesh.h deleted file mode 100644 index 17109bff8..000000000 --- a/irrlicht-1.6/include/IMesh.h +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_MESH_H_INCLUDED__ -#define __I_MESH_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "SMaterial.h" -#include "EHardwareBufferFlags.h" - -namespace irr -{ -namespace scene -{ - class IMeshBuffer; - - //! Class which holds the geometry of an object. - /** An IMesh is nothing more than a collection of some mesh buffers - (IMeshBuffer). SMesh is a simple implementation of an IMesh. - A mesh is usually added to an IMeshSceneNode in order to be rendered. - */ - class IMesh : public virtual IReferenceCounted - { - public: - - //! Get the amount of mesh buffers. - /** \return Amount of mesh buffers (IMeshBuffer) in this mesh. */ - virtual u32 getMeshBufferCount() const = 0; - - //! Get pointer to a mesh buffer. - /** \param nr: Zero based index of the mesh buffer. The maximum value is - getMeshBufferCount() - 1; - \return Pointer to the mesh buffer or 0 if there is no such - mesh buffer. */ - virtual IMeshBuffer* getMeshBuffer(u32 nr) const = 0; - - //! Get pointer to a mesh buffer which fits a material - /** \param material: material to search for - \return Pointer to the mesh buffer or 0 if there is no such - mesh buffer. */ - virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const = 0; - - //! Get an axis aligned bounding box of the mesh. - /** \return Bounding box of this mesh. */ - virtual const core::aabbox3d<f32>& getBoundingBox() const = 0; - - //! Set user-defined axis aligned bounding box - /** \param box New bounding box to use for the mesh. */ - virtual void setBoundingBox( const core::aabbox3df& box) = 0; - - //! Sets a flag of all contained materials to a new value. - /** \param flag: Flag to set in all materials. - \param newvalue: New value to set in all materials. */ - virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue) = 0; - - //! Set the hardware mapping hint - /** This methods allows to define optimization hints for the - hardware. This enables, e.g., the use of hardware buffers on - pltforms that support this feature. This can lead to noticeable - performance gains. */ - virtual void setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX) = 0; - - //! Flag the meshbuffer as changed, reloads hardware buffers - /** This method has to be called every time the vertices or - indices have changed. Otherwise, changes won't be updated - on the GPU in the next render cycle. */ - virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX) = 0; - }; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IMeshBuffer.h b/irrlicht-1.6/include/IMeshBuffer.h deleted file mode 100644 index 51947cf8c..000000000 --- a/irrlicht-1.6/include/IMeshBuffer.h +++ /dev/null @@ -1,194 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_MESH_BUFFER_H_INCLUDED__ -#define __I_MESH_BUFFER_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "SMaterial.h" -#include "aabbox3d.h" -#include "S3DVertex.h" -#include "SVertexIndex.h" -#include "EHardwareBufferFlags.h" - -namespace irr -{ -namespace scene -{ - - //! Enumeration for all primitive types there are. - enum E_PRIMITIVE_TYPE - { - //! All vertices are non-connected points. - EPT_POINTS=0, - - //! All vertices form a single connected line. - EPT_LINE_STRIP, - - //! Just as LINE_STRIP, but the last and the first vertex is also connected. - EPT_LINE_LOOP, - - //! Every two vertices are connected creating n/2 lines. - EPT_LINES, - - //! After the first two vertices each vertex defines a new triangle. - //! Always the two last and the new one form a new triangle. - EPT_TRIANGLE_STRIP, - - //! After the first two vertices each vertex defines a new triangle. - //! All around the common first vertex. - EPT_TRIANGLE_FAN, - - //! Explicitly set all vertices for each triangle. - EPT_TRIANGLES, - - //! After the first two vertices each further tw vetices create a quad with the preceding two. - EPT_QUAD_STRIP, - - //! Every four vertices create a quad. - EPT_QUADS, - - //! Just as LINE_LOOP, but filled. - EPT_POLYGON, - - //! The single vertices are expanded to quad billboards on the GPU. - EPT_POINT_SPRITES - }; - - //! Struct for holding a mesh with a single material. - /** A part of an IMesh which has the same material on each face of that - group. Logical groups of an IMesh need not be put into separate mesh - buffers, but can be. Separately animated parts of the mesh must be put - into separate mesh buffers. - Some mesh buffer implementations have limitations on the number of - vertices the buffer can hold. In that case, logical grouping can help. - Moreover, the number of vertices should be optimized for the GPU upload, - which often depends on the type of gfx card. Typial figures are - 1000-10000 vertices per buffer. - SMeshBuffer is a simple implementation of a MeshBuffer, which supports - up to 65535 vertices. - - Since meshbuffers are used for drawing, and hence will be exposed - to the driver, chances are high that they are grab()'ed from somewhere. - It's therefore required to dynamically allocate meshbuffers which are - passed to a video driver and only drop the buffer once it's not used in - the current code block anymore. - */ - class IMeshBuffer : public virtual IReferenceCounted - { - public: - - //! Get the material of this meshbuffer - /** \return Material of this buffer. */ - virtual video::SMaterial& getMaterial() = 0; - - //! Get the material of this meshbuffer - /** \return Material of this buffer. */ - virtual const video::SMaterial& getMaterial() const = 0; - - //! Get type of vertex data which is stored in this meshbuffer. - /** \return Vertex type of this buffer. */ - virtual video::E_VERTEX_TYPE getVertexType() const = 0; - - //! Get access to vertex data. The data is an array of vertices. - /** Which vertex type is used can be determined by getVertexType(). - \return Pointer to array of vertices. */ - virtual const void* getVertices() const = 0; - - //! Get access to vertex data. The data is an array of vertices. - /** Which vertex type is used can be determined by getVertexType(). - \return Pointer to array of vertices. */ - virtual void* getVertices() = 0; - - //! Get amount of vertices in meshbuffer. - /** \return Number of vertices in this buffer. */ - virtual u32 getVertexCount() const = 0; - - //! Get type of index data which is stored in this meshbuffer. - /** \return Index type of this buffer. */ - virtual video::E_INDEX_TYPE getIndexType() const =0; - - //! Get access to Indices. - /** \return Pointer to indices array. */ - virtual const u16* getIndices() const = 0; - - //! Get access to Indices. - /** \return Pointer to indices array. */ - virtual u16* getIndices() = 0; - - //! Get amount of indices in this meshbuffer. - /** \return Number of indices in this buffer. */ - virtual u32 getIndexCount() const = 0; - - //! Get the axis aligned bounding box of this meshbuffer. - /** \return Axis aligned bounding box of this buffer. */ - virtual const core::aabbox3df& getBoundingBox() const = 0; - - //! Set axis aligned bounding box - /** \param box User defined axis aligned bounding box to use - for this buffer. */ - virtual void setBoundingBox(const core::aabbox3df& box) = 0; - - //! Recalculates the bounding box. Should be called if the mesh changed. - virtual void recalculateBoundingBox() = 0; - - //! returns position of vertex i - virtual const core::vector3df& getPosition(u32 i) const = 0; - - //! returns position of vertex i - virtual core::vector3df& getPosition(u32 i) = 0; - - //! returns normal of vertex i - virtual const core::vector3df& getNormal(u32 i) const = 0; - - //! returns normal of vertex i - virtual core::vector3df& getNormal(u32 i) = 0; - - //! returns texture coord of vertex i - virtual const core::vector2df& getTCoords(u32 i) const = 0; - - //! returns texture coord of vertex i - virtual core::vector2df& getTCoords(u32 i) = 0; - - //! Append the vertices and indices to the current buffer - /** Only works for compatible vertex types. - \param vertices Pointer to a vertex array. - \param numVertices Number of vertices in the array. - \param indices Pointer to index array. - \param numIndices Number of indices in array. */ - virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) = 0; - - //! Append the meshbuffer to the current buffer - /** Only works for compatible vertex types - \param other Buffer to append to this one. */ - virtual void append(const IMeshBuffer* const other) = 0; - - //! get the current hardware mapping hint - virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const = 0; - - //! get the current hardware mapping hint - virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const = 0; - - //! set the hardware mapping hint, for driver - virtual void setHardwareMappingHint( E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX ) = 0; - - //! flags the meshbuffer as changed, reloads hardware buffers - virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX) = 0; - - //to be spit into vertex and index buffers: - //! Get the currently used ID for identification of changes. - /** This shouldn't be used for anything outside the VideoDriver. */ - virtual u32 getChangedID_Vertex() const = 0; - - //! Get the currently used ID for identification of changes. - /** This shouldn't be used for anything outside the VideoDriver. */ - virtual u32 getChangedID_Index() const = 0; - }; - -} // end namespace scene -} // end namespace irr - -#endif - - diff --git a/irrlicht-1.6/include/IMeshCache.h b/irrlicht-1.6/include/IMeshCache.h deleted file mode 100644 index 6747b74eb..000000000 --- a/irrlicht-1.6/include/IMeshCache.h +++ /dev/null @@ -1,166 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_MESH_CACHE_H_INCLUDED__ -#define __I_MESH_CACHE_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "path.h" - -namespace irr -{ - -namespace scene -{ - class IMesh; - class IAnimatedMesh; - class IAnimatedMeshSceneNode; - class IMeshLoader; - - //! The mesh cache stores already loaded meshes and provides an interface to them. - /** You can access it using ISceneManager::getMeshCache(). All existing - scene managers will return a pointer to the same mesh cache, because it - is shared between them. With this interface, it is possible to manually - add new loaded meshes (if ISceneManager::getMesh() is not sufficient), - to remove them and to iterate through already loaded meshes. */ - class IMeshCache : public virtual IReferenceCounted - { - public: - - //! Destructor - virtual ~IMeshCache() {} - - //! Adds a mesh to the internal list of loaded meshes. - /** Usually, ISceneManager::getMesh() is called to load a mesh - from a file. That method searches the list of loaded meshes if - a mesh has already been loaded and returns a pointer to if it - is in that list and already in memory. Otherwise it loads the - mesh. With IMeshCache::addMesh(), it is possible to pretend - that a mesh already has been loaded. This method can be used - for example by mesh loaders who need to load more than one mesh - with one call. They can add additional meshes with this method - to the scene manager. The COLLADA loader for example uses this - method. - \param filename Filename of the mesh. When calling - ISceneManager::getMesh() with this name it will return the mesh - set by this method. - \param mesh Pointer to a mesh which will now be referenced by - this name. */ - virtual void addMesh(const io::path& filename, IAnimatedMesh* mesh) = 0; - - //! Removes a mesh from the cache. - /** After loading a mesh with getMesh(), the mesh can be - removed from the cache using this method, freeing a lot of - memory. - \param mesh Pointer to the mesh which shall be removed. */ - virtual void removeMesh(const IAnimatedMesh* const mesh) = 0; - - //! Removes a mesh from the cache. - /** After loading a mesh with getMesh(), the mesh can be - removed from the cache using this method, freeing a lot of - memory. - \param mesh Pointer to the mesh which shall be removed. */ - virtual void removeMesh(const IMesh* const mesh) = 0; - - //! Returns amount of loaded meshes in the cache. - /** You can load new meshes into the cache using getMesh() and - addMesh(). If you ever need to access the internal mesh cache, - you can do this using removeMesh(), getMeshNumber(), - getMeshByIndex() and getMeshFilename(). - \return Number of meshes in cache. */ - virtual u32 getMeshCount() const = 0; - - //! Returns current index number of the mesh, and -1 if it is not in the cache. - /** \param mesh Pointer to the mesh to search for. - \return Index of the mesh in the cache, or -1 if not found. */ - virtual s32 getMeshIndex(const IAnimatedMesh* const mesh) const = 0; - - //! Returns current index number of the mesh, and -1 if it is not in the cache. - /** \param mesh Pointer to the mesh to search for. - \return Index of the mesh in the cache, or -1 if not found. */ - virtual s32 getMeshIndex(const IMesh* const mesh) const = 0; - - //! Returns a mesh based on its index number. - /** \param index: Index of the mesh, number between 0 and - getMeshCount()-1. - Note that this number is only valid until a new mesh is loaded - or removed. - \return Pointer to the mesh or 0 if there is none with this - number. */ - virtual IAnimatedMesh* getMeshByIndex(u32 index) = 0; - - //! Returns a mesh based on its filename. - /** \param filename Name of the mesh. - \return Pointer to the mesh or 0 if there is none with this number. */ - virtual IAnimatedMesh* getMeshByFilename(const io::path& filename) = 0; - - //! Get the filename of a loaded mesh, based on its index. - /** \param index: Index of the mesh, number between 0 and getMeshCount()-1. - \return String with name if mesh was found and has a name, else - 0. */ - virtual const io::path& getMeshFilename(u32 index) const = 0; - - //! Get the filename of a loaded mesh, if there is any. - /** \param mesh Pointer to mesh to query. - \return String with name if mesh was found and has a name, else - 0. */ - virtual const io::path& getMeshFilename(const IAnimatedMesh* const mesh) const = 0; - - //! Get the filename of a loaded mesh, if there is any. - /** \param mesh Pointer to mesh to query. - \return String with name if mesh was found and has a name, else - 0. */ - virtual const io::path& getMeshFilename(const IMesh* const mesh) const = 0; - - //! Renames a loaded mesh. - /** Note that renaming meshes might change the ordering of the - meshes, and so the index of the meshes as returned by - getMeshIndex() or taken by some methods will change. - \param index The index of the mesh in the cache. - \param filename New name for the mesh. - \return True if mesh was renamed. */ - virtual bool setMeshFilename(u32 index, const io::path& filename) = 0; - - //! Renames a loaded mesh. - /** Note that renaming meshes might change the ordering of the - meshes, and so the index of the meshes as returned by - getMeshIndex() or taken by some methods will change. - \param mesh Mesh to be renamed. - \param filename New name for the mesh. - \return True if mesh was renamed. */ - virtual bool setMeshFilename(const IAnimatedMesh* const mesh, const io::path& filename) = 0; - - //! Renames a loaded mesh. - /** Note that renaming meshes might change the ordering of the - meshes, and so the index of the meshes as returned by - getMeshIndex() or taken by some methods will change. - \param mesh Mesh to be renamed. - \param filename New name for the mesh. - \return True if mesh was renamed. */ - virtual bool setMeshFilename(const IMesh* const mesh, const io::path& filename) = 0; - - //! Check if a mesh was already loaded. - /** \param filename Name of the mesh. - \return True if the mesh has been loaded, else false. */ - virtual bool isMeshLoaded(const io::path& filename) = 0; - - //! Clears the whole mesh cache, removing all meshes. - /** All meshes will be reloaded completely when using ISceneManager::getMesh() - after calling this method. - Warning: If you have pointers to meshes that were loaded with ISceneManager::getMesh() - and you did not grab them, then they may become invalid. */ - virtual void clear() = 0; - - //! Clears all meshes that are held in the mesh cache but not used anywhere else. - /** Warning: If you have pointers to meshes that were loaded with ISceneManager::getMesh() - and you did not grab them, then they may become invalid. */ - virtual void clearUnusedMeshes() = 0; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IMeshLoader.h b/irrlicht-1.6/include/IMeshLoader.h deleted file mode 100644 index 323c2740d..000000000 --- a/irrlicht-1.6/include/IMeshLoader.h +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_MESH_LOADER_H_INCLUDED__ -#define __I_MESH_LOADER_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "path.h" - -namespace irr -{ -namespace io -{ - class IReadFile; -} // end namespace io -namespace scene -{ - class IAnimatedMesh; - -//! Class which is able to load an animated mesh from a file. -/** If you want Irrlicht be able to load meshes of -currently unsupported file formats (e.g. .cob), then implement -this and add your new Meshloader with -ISceneManager::addExternalMeshLoader() to the engine. */ -class IMeshLoader : public virtual IReferenceCounted -{ -public: - - //! Destructor - virtual ~IMeshLoader() {} - - //! Returns true if the file might be loaded by this class. - /** This decision should be based on the file extension (e.g. ".cob") - only. - \param fileName Name of the file to test. - \return True if the file might be loaded by this class. */ - virtual bool isALoadableFileExtension(const io::path& filename) const = 0; - - //! Creates/loads an animated mesh from the file. - /** \param file File handler to load the file from. - \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) = 0; -}; - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IMeshManipulator.h b/irrlicht-1.6/include/IMeshManipulator.h deleted file mode 100644 index 3185407fb..000000000 --- a/irrlicht-1.6/include/IMeshManipulator.h +++ /dev/null @@ -1,215 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_MESH_MANIPULATOR_H_INCLUDED__ -#define __I_MESH_MANIPULATOR_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "vector3d.h" -#include "aabbox3d.h" -#include "matrix4.h" -#include "IAnimatedMesh.h" -#include "SColor.h" - -namespace irr -{ -namespace scene -{ - - class IMesh; - class IMeshBuffer; - struct SMesh; - - //! An interface for easy manipulation of meshes. - /** 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 modifications and/or - animations during runtime. - */ - class IMeshManipulator : public virtual IReferenceCounted - { - public: - - //! Flips the direction of surfaces. - /** Changes backfacing triangles to frontfacing - triangles and vice versa. - \param mesh Mesh on which the operation is performed. */ - virtual void flipSurfaces(IMesh* mesh) const = 0; - - //! Sets the alpha vertex color value of the whole mesh to a new value. - /** \param mesh Mesh on which the operation is performed. - \param alpha New alpha value. Must be a value between 0 and 255. */ - virtual void setVertexColorAlpha(IMesh* mesh, s32 alpha) const = 0; - - //! Sets the colors of all vertices to one color - /** \param mesh Mesh on which the operation is performed. - \param color New color. */ - virtual void setVertexColors(IMesh* mesh, video::SColor color) const = 0; - - //! Recalculates all normals of the mesh. - /** \param mesh: Mesh on which the operation is performed. - \param smooth: If the normals shall be smoothed. - \param angleWeighted: If the normals shall be smoothed in relation to their angles. More expensive, but also higher precision. */ - virtual void recalculateNormals(IMesh* mesh, bool smooth = false, bool angleWeighted = false) const = 0; - - //! Recalculates all normals of the mesh buffer. - /** \param buffer: Mesh buffer on which the operation is performed. - \param smooth: If the normals shall be smoothed. - \param angleWeighted: If the normals shall be smoothed in relation to their angles. More expensive, but also higher precision. */ - virtual void recalculateNormals(IMeshBuffer* buffer, bool smooth = false, bool angleWeighted = false) const = 0; - - //! Scales the actual mesh, not a scene node. - /** \param mesh Mesh on which the operation is performed. - \param factor Scale factor for each axis. */ - virtual void scale(IMesh* mesh, const core::vector3df& factor) const = 0; - - //! Scales the actual meshbuffer, not a scene node. - /** \param buffer Meshbuffer on which the operation is performed. - \param factor Scale factor for each axis. */ - virtual void scale(IMeshBuffer* buffer, const core::vector3df& factor) const = 0; - - //! Scales the actual mesh, not a scene node. - /** \deprecated - \param mesh Mesh on which the operation is performed. - \param factor Scale factor for each axis. */ - virtual void scaleMesh(IMesh* mesh, const core::vector3df& factor) const {return scale(mesh,factor);} - - //! Scale the texture coords of a mesh. - /** \param mesh Mesh on which the operation is performed. - \param factor Vector which defines the scale for each axis. - \param level Number of texture coord, starting from 1. Support for level 2 exists for LightMap buffers. */ - virtual void scaleTCoords(scene::IMesh* mesh, const core::vector2df& factor, u32 level=1) const =0; - - //! Scale the texture coords of a meshbuffer. - /** \param buffer Meshbuffer on which the operation is performed. - \param factor Vector which defines the scale for each axis. - \param level Number of texture coord, starting from 1. Support for level 2 exists for LightMap buffers. */ - virtual void scaleTCoords(scene::IMeshBuffer* buffer, const core::vector2df& factor, u32 level=1) const =0; - - //! Applies a transformation to a mesh - /** \param mesh Mesh on which the operation is performed. - \param m transformation matrix. */ - virtual void transform(IMesh* mesh, const core::matrix4& m) const = 0; - - //! Applies a transformation to a meshbuffer - /** \param buffer Meshbuffer on which the operation is performed. - \param m transformation matrix. */ - virtual void transform(IMeshBuffer* buffer, const core::matrix4& m) const = 0; - - //! Applies a transformation to a mesh - /** \deprecated - \param mesh Mesh on which the operation is performed. - \param m transformation matrix. */ - virtual void transformMesh(IMesh* mesh, const core::matrix4& m) const {return transform(mesh,m);} - - //! Clones a static IMesh into a modifiable SMesh. - /** All meshbuffers in the returned SMesh - are of type SMeshBuffer or SMeshBufferLightMap. - \param mesh Mesh to copy. - \return Cloned mesh. If you no longer need the - cloned mesh, you should call SMesh::drop(). See - IReferenceCounted::drop() for more information. */ - virtual SMesh* createMeshCopy(IMesh* mesh) const = 0; - - //! Creates a planar texture mapping on the mesh - /** \param mesh: Mesh on which the operation is performed. - \param resolution: resolution of the planar mapping. This is - the value specifying which is the relation between world space - and texture coordinate space. */ - virtual void makePlanarTextureMapping(IMesh* mesh, f32 resolution=0.001f) const =0; - - //! Creates a planar texture mapping on the meshbuffer - /** \param meshbuffer: Buffer on which the operation is performed. - \param resolution: resolution of the planar mapping. This is - the value specifying which is the relation between world space - and texture coordinate space. */ - virtual void makePlanarTextureMapping(scene::IMeshBuffer* meshbuffer, f32 resolution=0.001f) const =0; - - //! Creates a planar texture mapping on the meshbuffer - /** This method is currently implemented towards the LWO planar mapping. A more general biasing might be required. - \param meshbuffer Buffer on which the operation is performed. - \param resolutionS Resolution of the planar mapping in horizontal direction. This is the ratio between object space and texture space. - \param resolutionT Resolution of the planar mapping in vertical direction. This is the ratio between object space and texture space. - \param axis The axis along which the texture is projected. The allowed values are 0 (X), 1(Y), and 2(Z). - \param offset Vector added to the vertex positions (in object coordinates). - */ - virtual void makePlanarTextureMapping(scene::IMeshBuffer* buffer, f32 resolutionS, f32 resolutionT, u8 axis, const core::vector3df& offset) const =0; - - //! Creates a copy of the mesh, which will only consist of S3DVertexTangents vertices. - /** This is useful if you want to draw tangent space normal - mapped geometry because it calculates the tangent and binormal - data which is needed there. - \param mesh Input mesh - \param recalculateNormals The normals are recalculated if set, - otherwise the original ones are kept. Note that keeping the - normals may introduce inaccurate tangents if the normals are - very different to those calculated from the faces. - \param smooth The normals/tangents are smoothed across the - meshbuffer's faces if this flag is set. - \param angleWeighted Improved smoothing calculation used - \return Mesh consisting only of S3DVertexTangents vertices. If - you no longer need the cloned mesh, you should call - IMesh::drop(). See IReferenceCounted::drop() for more - information. */ - virtual IMesh* createMeshWithTangents(IMesh* mesh, bool recalculateNormals=false, bool smooth=false, bool angleWeighted=false) const = 0; - - //! Creates a copy of the mesh, which will only consist of S3DVertex2TCoord vertices. - /** \param mesh Input mesh - \return Mesh consisting only of S3DVertex2TCoord vertices. If - you no longer need the cloned mesh, you should call - IMesh::drop(). See IReferenceCounted::drop() for more - information. */ - virtual IMesh* createMeshWith2TCoords(IMesh* mesh) const = 0; - - //! Creates a copy of the mesh, which will only consist of S3DVertex vertices. - /** \param mesh Input mesh - \return Mesh consisting only of S3DVertex vertices. If - you no longer need the cloned mesh, you should call - IMesh::drop(). See IReferenceCounted::drop() for more - information. */ - virtual IMesh* createMeshWith1TCoords(IMesh* mesh) const = 0; - - //! Creates a copy of a mesh with all vertices unwelded - /** \param mesh Input mesh - \return Mesh consisting only of unique faces. All vertices - which were previously shared are now duplicated. If you no - longer need the cloned mesh, you should call IMesh::drop(). See - IReferenceCounted::drop() for more information. */ - virtual IMesh* createMeshUniquePrimitives(IMesh* mesh) const = 0; - - //! Creates a copy of a mesh with vertices welded - /** \param mesh Input mesh - \param tolerance The threshold for vertex comparisons. - \return Mesh without redundant vertices. If you no longer need - the cloned mesh, you should call IMesh::drop(). See - IReferenceCounted::drop() for more information. */ - virtual IMesh* createMeshWelded(IMesh* mesh, f32 tolerance=core::ROUNDING_ERROR_f32) const = 0; - - //! Get amount of polygons in mesh. - /** \param mesh Input mesh - \return Number of polygons in mesh. */ - virtual s32 getPolyCount(IMesh* mesh) const = 0; - - //! Get amount of polygons in mesh. - /** \param mesh Input mesh - \return Number of polygons in mesh. */ - virtual s32 getPolyCount(IAnimatedMesh* mesh) const = 0; - - //! Create a new AnimatedMesh and adds the mesh to it - /** \param mesh Input mesh - \param type The type of the animated mesh to create. - \return Newly created animated mesh with mesh as its only - content. When you don't need the animated mesh anymore, you - should call IAnimatedMesh::drop(). See - IReferenceCounted::drop() for more information. */ - virtual IAnimatedMesh * createAnimatedMesh(IMesh* mesh, - scene::E_ANIMATED_MESH_TYPE type = scene::EAMT_UNKNOWN) const = 0; - }; - -} // end namespace scene -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/include/IMeshSceneNode.h b/irrlicht-1.6/include/IMeshSceneNode.h deleted file mode 100644 index 412063155..000000000 --- a/irrlicht-1.6/include/IMeshSceneNode.h +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_MESH_SCENE_NODE_H_INCLUDED__ -#define __I_MESH_SCENE_NODE_H_INCLUDED__ - -#include "ISceneNode.h" - -namespace irr -{ -namespace scene -{ - -class IMesh; - - -//! A scene node displaying a static mesh -class IMeshSceneNode : public ISceneNode -{ -public: - - //! Constructor - /** Use setMesh() to set the mesh to display. - */ - IMeshSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1,1,1)) - : ISceneNode(parent, mgr, id, position, rotation, scale) {} - - //! Sets a new mesh to display - /** \param mesh Mesh to display. */ - virtual void setMesh(IMesh* mesh) = 0; - - //! Get the currently defined mesh for display. - /** \return Pointer to mesh which is displayed by this node. */ - virtual IMesh* getMesh(void) = 0; - - //! Sets if the scene node should not copy the materials of the mesh but use them in a read only style. - /** In this way it is possible to change the materials of a mesh - causing all mesh scene nodes referencing this mesh to change, too. - \param readonly Flag if the materials shall be read-only. */ - virtual void setReadOnlyMaterials(bool readonly) = 0; - - //! Check if the scene node should not copy the materials of the mesh but use them in a read only style - /** This flag can be set by setReadOnlyMaterials(). - \return Whether the materials are read-only. */ - virtual bool isReadOnlyMaterials() const = 0; -}; - -} // end namespace scene -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/include/IMeshWriter.h b/irrlicht-1.6/include/IMeshWriter.h deleted file mode 100644 index 9b8f095a6..000000000 --- a/irrlicht-1.6/include/IMeshWriter.h +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_I_MESH_WRITER_H_INCLUDED__ -#define __IRR_I_MESH_WRITER_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "EMeshWriterEnums.h" - -namespace irr -{ -namespace io -{ - class IWriteFile; -} // end namespace io - -namespace scene -{ - class IMesh; - - //! Interface for writing meshes - class IMeshWriter : public virtual IReferenceCounted - { - public: - - //! Destructor - virtual ~IMeshWriter() {} - - //! Get the type of the mesh writer - /** For own implementations, use MAKE_IRR_ID as shown in the - EMESH_WRITER_TYPE enumeration to return your own unique mesh - type id. - \return Type of the mesh writer. */ - virtual EMESH_WRITER_TYPE getType() const = 0; - - //! Write a static mesh. - /** \param file File handle to write the mesh to. - \param mesh Pointer to mesh to be written. - \param flags Optional flags to set properties of the writer. - \return True if sucessful */ - virtual bool writeMesh(io::IWriteFile* file, scene::IMesh* mesh, - s32 flags=EMWF_NONE) = 0; - - // Writes an animated mesh - // for future use, no writer is able to write animated meshes currently - /* \return Returns true if sucessful */ - //virtual bool writeAnimatedMesh(io::IWriteFile* file, - // scene::IAnimatedMesh* mesh, - // s32 flags=EMWF_NONE) = 0; - }; - - -} // end namespace -} // end namespace - -#endif - diff --git a/irrlicht-1.6/include/IMetaTriangleSelector.h b/irrlicht-1.6/include/IMetaTriangleSelector.h deleted file mode 100644 index a4e07a4dc..000000000 --- a/irrlicht-1.6/include/IMetaTriangleSelector.h +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_META_TRIANGLE_SELECTOR_H_INCLUDED__ -#define __I_META_TRIANGLE_SELECTOR_H_INCLUDED__ - -#include "ITriangleSelector.h" - -namespace irr -{ -namespace scene -{ - -//! Interface for making multiple triangle selectors work as one big selector. -/** This is nothing more than a collection of one or more triangle selectors -providing together the interface of one triangle selector. In this way, -collision tests can be done with different triangle soups in one pass. -*/ -class IMetaTriangleSelector : public ITriangleSelector -{ -public: - - //! Adds a triangle selector to the collection of triangle selectors. - /** \param toAdd: Pointer to an triangle selector to add to the list. */ - virtual void addTriangleSelector(ITriangleSelector* toAdd) = 0; - - //! Removes a specific triangle selector from the collection. - /** \param toRemove: Pointer to an triangle selector which is in the - list but will be removed. - \return True if successful, false if not. */ - virtual bool removeTriangleSelector(ITriangleSelector* toRemove) = 0; - - //! Removes all triangle selectors from the collection. - virtual void removeAllTriangleSelectors() = 0; -}; - -} // end namespace scene -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/include/IOSOperator.h b/irrlicht-1.6/include/IOSOperator.h deleted file mode 100644 index 21ff0877d..000000000 --- a/irrlicht-1.6/include/IOSOperator.h +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_OS_OPERATOR_H_INCLUDED__ -#define __I_OS_OPERATOR_H_INCLUDED__ - -#include "IReferenceCounted.h" - -namespace irr -{ - -//! The Operating system operator provides operation system specific methods and informations. -class IOSOperator : public virtual IReferenceCounted -{ -public: - - //! Destructor - virtual ~IOSOperator() {} - - //! Get the current operation system version as string. - virtual const wchar_t* getOperationSystemVersion() const = 0; - - //! Copies text to the clipboard - virtual void copyToClipboard(const c8* text) const = 0; - - //! Get text from the clipboard - /** \return Returns 0 if no string is in there. */ - virtual const c8* getTextFromClipboard() const = 0; - - //! Get the processor speed in megahertz - /** \param MHz The integer variable to store the speed in. - \return True if successful, false if not */ - virtual bool getProcessorSpeedMHz(u32* MHz) const = 0; - - //! Get the total and available system RAM - /** \param Total: will contain the total system memory - \param Avail: will contain the available memory - \return True if successful, false if not */ - virtual bool getSystemMemory(u32* Total, u32* Avail) const = 0; - -}; - -} // end namespace - -#endif - diff --git a/irrlicht-1.6/include/IParticleAffector.h b/irrlicht-1.6/include/IParticleAffector.h deleted file mode 100644 index f3d742cb5..000000000 --- a/irrlicht-1.6/include/IParticleAffector.h +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_PARTICLE_AFFECTOR_H_INCLUDED__ -#define __I_PARTICLE_AFFECTOR_H_INCLUDED__ - -#include "IAttributeExchangingObject.h" -#include "SParticle.h" - -namespace irr -{ -namespace scene -{ - -//! Types of built in particle affectors -enum E_PARTICLE_AFFECTOR_TYPE -{ - EPAT_NONE = 0, - EPAT_ATTRACT, - EPAT_FADE_OUT, - EPAT_GRAVITY, - EPAT_ROTATE, - EPAT_SCALE, - EPAT_COUNT -}; - -//! Names for built in particle affectors -const c8* const ParticleAffectorTypeNames[] = -{ - "None", - "Attract", - "FadeOut", - "Gravity", - "Rotate", - "Scale", - 0 -}; - -//! A particle affector modifies particles. -class IParticleAffector : public virtual io::IAttributeExchangingObject -{ -public: - - //! constructor - IParticleAffector() : Enabled(true) {} - - //! Affects an array of particles. - /** \param now Current time. (Same as ITimer::getTime() would return) - \param particlearray Array of particles. - \param count Amount of particles in array. */ - virtual void affect(u32 now, SParticle* particlearray, u32 count) = 0; - - //! Sets whether or not the affector is currently enabled. - virtual void setEnabled(bool enabled) { Enabled = enabled; } - - //! Gets whether or not the affector is currently enabled. - virtual bool getEnabled() const { return Enabled; } - - //! Get emitter type - virtual E_PARTICLE_AFFECTOR_TYPE getType() const = 0; - -protected: - bool Enabled; -}; - -} // end namespace scene -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/include/IParticleAnimatedMeshSceneNodeEmitter.h b/irrlicht-1.6/include/IParticleAnimatedMeshSceneNodeEmitter.h deleted file mode 100644 index f29b26a88..000000000 --- a/irrlicht-1.6/include/IParticleAnimatedMeshSceneNodeEmitter.h +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_PARTICLE_ANIMATED_MESH_SCENE_NODE_EMITTER_H_INCLUDED__ -#define __I_PARTICLE_ANIMATED_MESH_SCENE_NODE_EMITTER_H_INCLUDED__ - -#include "IParticleEmitter.h" -#include "IAnimatedMeshSceneNode.h" - -namespace irr -{ -namespace scene -{ - -//! A particle emitter which emits particles from mesh vertices. -class IParticleAnimatedMeshSceneNodeEmitter : public IParticleEmitter -{ -public: - - //! Set Mesh to emit particles from - virtual void setAnimatedMeshSceneNode( IAnimatedMeshSceneNode* node ) = 0; - - //! Set whether to use vertex normal for direction, or direction specified - virtual void setUseNormalDirection( bool useNormalDirection = true ) = 0; - - //! Set the amount that the normal is divided by for getting a particles direction - virtual void setNormalDirectionModifier( f32 normalDirectionModifier ) = 0; - - //! Sets whether to emit min<->max particles for every vertex or to pick min<->max vertices - virtual void setEveryMeshVertex( bool everyMeshVertex = true ) = 0; - - //! Get mesh we're emitting particles from - virtual const IAnimatedMeshSceneNode* getAnimatedMeshSceneNode() const = 0; - - //! Get whether to use vertex normal for direction, or direction specified - virtual bool isUsingNormalDirection() const = 0; - - //! Get the amount that the normal is divided by for getting a particles direction - virtual f32 getNormalDirectionModifier() const = 0; - - //! Gets whether to emit min<->max particles for every vertex or to pick min<->max vertices - virtual bool getEveryMeshVertex() const = 0; - - //! Get emitter type - virtual E_PARTICLE_EMITTER_TYPE getType() const { return EPET_ANIMATED_MESH; } -}; - -} // end namespace scene -} // end namespace irr - - -#endif // __I_PARTICLE_ANIMATED_MESH_SCENE_NODE_EMITTER_H_INCLUDED__ - diff --git a/irrlicht-1.6/include/IParticleAttractionAffector.h b/irrlicht-1.6/include/IParticleAttractionAffector.h deleted file mode 100644 index 3ac81497f..000000000 --- a/irrlicht-1.6/include/IParticleAttractionAffector.h +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_PARTICLE_ATTRACTION_AFFECTOR_H_INCLUDED__ -#define __I_PARTICLE_ATTRACTION_AFFECTOR_H_INCLUDED__ - -#include "IParticleAffector.h" - -namespace irr -{ -namespace scene -{ - -//! A particle affector which attracts or detracts particles. -class IParticleAttractionAffector : public IParticleAffector -{ -public: - - //! Set the point that particles will attract to - virtual void setPoint( const core::vector3df& point ) = 0; - - //! Set whether or not the particles are attracting or detracting - virtual void setAttract( bool attract ) = 0; - - //! Set whether or not this will affect particles in the X direction - virtual void setAffectX( bool affect ) = 0; - - //! Set whether or not this will affect particles in the Y direction - virtual void setAffectY( bool affect ) = 0; - - //! Set whether or not this will affect particles in the Z direction - virtual void setAffectZ( bool affect ) = 0; - - //! Get the point that particles are attracted to - virtual const core::vector3df& getPoint() const = 0; - - //! Get whether or not the particles are attracting or detracting - virtual bool getAttract() const = 0; - - //! Get whether or not the particles X position are affected - virtual bool getAffectX() const = 0; - - //! Get whether or not the particles Y position are affected - virtual bool getAffectY() const = 0; - - //! Get whether or not the particles Z position are affected - virtual bool getAffectZ() const = 0; - - //! Get emitter type - virtual E_PARTICLE_AFFECTOR_TYPE getType() const { return EPAT_ATTRACT; } -}; - -} // end namespace scene -} // end namespace irr - - -#endif // __I_PARTICLE_ATTRACTION_AFFECTOR_H_INCLUDED__ - diff --git a/irrlicht-1.6/include/IParticleBoxEmitter.h b/irrlicht-1.6/include/IParticleBoxEmitter.h deleted file mode 100644 index 5dd1e8a2b..000000000 --- a/irrlicht-1.6/include/IParticleBoxEmitter.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_PARTICLE_BOX_EMITTER_H_INCLUDED__ -#define __I_PARTICLE_BOX_EMITTER_H_INCLUDED__ - -#include "IParticleEmitter.h" -#include "aabbox3d.h" - -namespace irr -{ -namespace scene -{ - -//! A particle emitter which emits particles from a box shaped space -class IParticleBoxEmitter : public IParticleEmitter -{ -public: - - //! Set the box shape - virtual void setBox( const core::aabbox3df& box ) = 0; - - //! Get the box shape set - virtual const core::aabbox3df& getBox() const = 0; - - //! Get emitter type - virtual E_PARTICLE_EMITTER_TYPE getType() const { return EPET_BOX; } -}; - -} // end namespace scene -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/include/IParticleCylinderEmitter.h b/irrlicht-1.6/include/IParticleCylinderEmitter.h deleted file mode 100644 index ed66448f4..000000000 --- a/irrlicht-1.6/include/IParticleCylinderEmitter.h +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_PARTICLE_CYLINDER_EMITTER_H_INCLUDED__ -#define __I_PARTICLE_CYLINDER_EMITTER_H_INCLUDED__ - -#include "IParticleEmitter.h" - -namespace irr -{ -namespace scene -{ - -//! A particle emitter which emits from a cylindrically shaped space. -class IParticleCylinderEmitter : public IParticleEmitter -{ -public: - - //! Set the center of the radius for the cylinder, at one end of the cylinder - virtual void setCenter( const core::vector3df& center ) = 0; - - //! Set the normal of the cylinder - virtual void setNormal( const core::vector3df& normal ) = 0; - - //! Set the radius of the cylinder - virtual void setRadius( f32 radius ) = 0; - - //! Set the length of the cylinder - virtual void setLength( f32 length ) = 0; - - //! Set whether or not to draw points inside the cylinder - virtual void setOutlineOnly( bool outlineOnly = true ) = 0; - - //! Get the center of the cylinder - virtual const core::vector3df& getCenter() const = 0; - - //! Get the normal of the cylinder - virtual const core::vector3df& getNormal() const = 0; - - //! Get the radius of the cylinder - virtual f32 getRadius() const = 0; - - //! Get the center of the cylinder - virtual f32 getLength() const = 0; - - //! Get whether or not to draw points inside the cylinder - virtual bool getOutlineOnly() const = 0; - - //! Get emitter type - virtual E_PARTICLE_EMITTER_TYPE getType() const { return EPET_CYLINDER; } -}; - -} // end namespace scene -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/include/IParticleEmitter.h b/irrlicht-1.6/include/IParticleEmitter.h deleted file mode 100644 index 03c4c6e0e..000000000 --- a/irrlicht-1.6/include/IParticleEmitter.h +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_PARTICLE_EMITTER_H_INCLUDED__ -#define __I_PARTICLE_EMITTER_H_INCLUDED__ - -#include "IAttributeExchangingObject.h" -#include "SParticle.h" - -namespace irr -{ -namespace scene -{ - -//! Types of built in particle emitters -enum E_PARTICLE_EMITTER_TYPE -{ - EPET_POINT = 0, - EPET_ANIMATED_MESH, - EPET_BOX, - EPET_CYLINDER, - EPET_MESH, - EPET_RING, - EPET_SPHERE, - EPET_COUNT -}; - -//! Names for built in particle emitters -const c8* const ParticleEmitterTypeNames[] = -{ - "Point", - "AnimatedMesh", - "Box", - "Cylinder", - "Mesh", - "Ring", - "Sphere", - 0 -}; - -//! A particle emitter for using with particle systems. -/** A Particle emitter emitts new particles into a particle system. -*/ -class IParticleEmitter : public virtual io::IAttributeExchangingObject -{ -public: - - //! Prepares an array with new particles to emitt into the system - /** \param now Current time. - \param timeSinceLastCall Time elapsed since last call, in milliseconds. - \param outArray Pointer which will point to the array with the new - particles to add into the system. - \return Amount of new particles in the array. Can be 0. */ - virtual s32 emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray) = 0; - - //! Set direction the emitter emits particles - virtual void setDirection( const core::vector3df& newDirection ) = 0; - - //! Set minimum number of particles the emitter emits per second - virtual void setMinParticlesPerSecond( u32 minPPS ) = 0; - - //! Set maximum number of particles the emitter emits per second - virtual void setMaxParticlesPerSecond( u32 maxPPS ) = 0; - - //! Set minimum starting color for particles - virtual void setMinStartColor( const video::SColor& color ) = 0; - - //! Set maximum starting color for particles - virtual void setMaxStartColor( const video::SColor& color ) = 0; - - //! Set the maximum starting size for particles - virtual void setMaxStartSize( const core::dimension2df& size ) = 0; - - //! Set the minimum starting size for particles - virtual void setMinStartSize( const core::dimension2df& size ) = 0; - - //! Get direction the emitter emits particles - virtual const core::vector3df& getDirection() const = 0; - - //! Get the minimum number of particles the emitter emits per second - virtual u32 getMinParticlesPerSecond() const = 0; - - //! Get the maximum number of particles the emitter emits per second - virtual u32 getMaxParticlesPerSecond() const = 0; - - //! Get the minimum starting color for particles - virtual const video::SColor& getMinStartColor() const = 0; - - //! Get the maximum starting color for particles - virtual const video::SColor& getMaxStartColor() const = 0; - - //! Get the maximum starting size for particles - virtual const core::dimension2df& getMaxStartSize() const = 0; - - //! Get the minimum starting size for particles - virtual const core::dimension2df& getMinStartSize() const = 0; - - - //! Get emitter type - virtual E_PARTICLE_EMITTER_TYPE getType() const { return EPET_POINT; } -}; - -typedef IParticleEmitter IParticlePointEmitter; - -} // end namespace scene -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/include/IParticleFadeOutAffector.h b/irrlicht-1.6/include/IParticleFadeOutAffector.h deleted file mode 100644 index 54f14da00..000000000 --- a/irrlicht-1.6/include/IParticleFadeOutAffector.h +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_PARTICLE_FADE_OUT_AFFECTOR_H_INCLUDED__ -#define __I_PARTICLE_FADE_OUT_AFFECTOR_H_INCLUDED__ - -#include "IParticleAffector.h" - -namespace irr -{ -namespace scene -{ - -//! A particle affector which fades out the particles. -class IParticleFadeOutAffector : public IParticleAffector -{ -public: - - //! Sets the targetColor, i.e. the color the particles will interpolate to over time. - virtual void setTargetColor( const video::SColor& targetColor ) = 0; - - //! Sets the amount of time it takes for each particle to fade out. - virtual void setFadeOutTime( f32 fadeOutTime ) = 0; - - //! Gets the targetColor, i.e. the color the particles will interpolate to over time. - virtual const video::SColor& getTargetColor() const = 0; - - //! Gets the amount of time it takes for each particle to fade out. - virtual f32 getFadeOutTime() const = 0; - - //! Get emitter type - virtual E_PARTICLE_AFFECTOR_TYPE getType() const { return EPAT_FADE_OUT; } -}; - -} // end namespace scene -} // end namespace irr - - -#endif // __I_PARTICLE_FADE_OUT_AFFECTOR_H_INCLUDED__ - diff --git a/irrlicht-1.6/include/IParticleGravityAffector.h b/irrlicht-1.6/include/IParticleGravityAffector.h deleted file mode 100644 index 45b6da317..000000000 --- a/irrlicht-1.6/include/IParticleGravityAffector.h +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_PARTICLE_GRAVITY_AFFECTOR_H_INCLUDED__ -#define __I_PARTICLE_GRAVITY_AFFECTOR_H_INCLUDED__ - -#include "IParticleAffector.h" - -namespace irr -{ -namespace scene -{ - -//! A particle affector which applies gravity to particles. -class IParticleGravityAffector : public IParticleAffector -{ -public: - - //! Set the time in milliseconds when the gravity force is totally lost - /** At that point the particle does not move any more. */ - virtual void setTimeForceLost( f32 timeForceLost ) = 0; - - //! Set the direction and force of gravity in all 3 dimensions. - virtual void setGravity( const core::vector3df& gravity ) = 0; - - //! Get the time in milliseconds when the gravity force is totally lost - virtual f32 getTimeForceLost() const = 0; - - //! Get the direction and force of gravity. - virtual const core::vector3df& getGravity() const = 0; - - //! Get emitter type - virtual E_PARTICLE_AFFECTOR_TYPE getType() const { return EPAT_GRAVITY; } -}; - -} // end namespace scene -} // end namespace irr - - -#endif // __I_PARTICLE_GRAVITY_AFFECTOR_H_INCLUDED__ - diff --git a/irrlicht-1.6/include/IParticleMeshEmitter.h b/irrlicht-1.6/include/IParticleMeshEmitter.h deleted file mode 100644 index 69761faaa..000000000 --- a/irrlicht-1.6/include/IParticleMeshEmitter.h +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_PARTICLE_MESH_EMITTER_H_INCLUDED__ -#define __I_PARTICLE_MESH_EMITTER_H_INCLUDED__ - -#include "IParticleEmitter.h" -#include "IMesh.h" - -namespace irr -{ -namespace scene -{ - -//! A particle emitter which emits from vertices of a mesh -class IParticleMeshEmitter : public IParticleEmitter -{ -public: - - //! Set Mesh to emit particles from - virtual void setMesh( IMesh* mesh ) = 0; - - //! Set whether to use vertex normal for direction, or direction specified - virtual void setUseNormalDirection( bool useNormalDirection = true ) = 0; - - //! Set the amount that the normal is divided by for getting a particles direction - virtual void setNormalDirectionModifier( f32 normalDirectionModifier ) = 0; - - //! Sets whether to emit min<->max particles for every vertex or to pick min<->max vertices - virtual void setEveryMeshVertex( bool everyMeshVertex = true ) = 0; - - //! Get Mesh we're emitting particles from - virtual const IMesh* getMesh() const = 0; - - //! Get whether to use vertex normal for direction, or direction specified - virtual bool isUsingNormalDirection() const = 0; - - //! Get the amount that the normal is divided by for getting a particles direction - virtual f32 getNormalDirectionModifier() const = 0; - - //! Gets whether to emit min<->max particles for every vertex or to pick min<->max vertices - virtual bool getEveryMeshVertex() const = 0; - - //! Get emitter type - virtual E_PARTICLE_EMITTER_TYPE getType() const { return EPET_MESH; } -}; - -} // end namespace scene -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/include/IParticleRingEmitter.h b/irrlicht-1.6/include/IParticleRingEmitter.h deleted file mode 100644 index 9c3c6b580..000000000 --- a/irrlicht-1.6/include/IParticleRingEmitter.h +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_PARTICLE_RING_EMITTER_H_INCLUDED__ -#define __I_PARTICLE_RING_EMITTER_H_INCLUDED__ - -#include "IParticleEmitter.h" - -namespace irr -{ -namespace scene -{ - -//! A particle emitter which emits particles along a ring shaped area. -class IParticleRingEmitter : public IParticleEmitter -{ -public: - - //! Set the center of the ring - virtual void setCenter( const core::vector3df& center ) = 0; - - //! Set the radius of the ring - virtual void setRadius( f32 radius ) = 0; - - //! Set the thickness of the ring - virtual void setRingThickness( f32 ringThickness ) = 0; - - //! Get the center of the ring - virtual const core::vector3df& getCenter() const = 0; - - //! Get the radius of the ring - virtual f32 getRadius() const = 0; - - //! Get the thickness of the ring - virtual f32 getRingThickness() const = 0; - - //! Get emitter type - virtual E_PARTICLE_EMITTER_TYPE getType() const { return EPET_RING; } -}; - -} // end namespace scene -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/include/IParticleRotationAffector.h b/irrlicht-1.6/include/IParticleRotationAffector.h deleted file mode 100644 index 58c743fda..000000000 --- a/irrlicht-1.6/include/IParticleRotationAffector.h +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_PARTICLE_ROTATION_AFFECTOR_H_INCLUDED__ -#define __I_PARTICLE_ROTATION_AFFECTOR_H_INCLUDED__ - -#include "IParticleAffector.h" - -namespace irr -{ -namespace scene -{ - -//! A particle affector which rotates the particle system. -class IParticleRotationAffector : public IParticleAffector -{ -public: - - //! Set the point that particles will rotate around - virtual void setPivotPoint( const core::vector3df& point ) = 0; - - //! Set the speed in degrees per second in all 3 dimensions - virtual void setSpeed( const core::vector3df& speed ) = 0; - - //! Get the point that particles are attracted to - virtual const core::vector3df& getPivotPoint() const = 0; - - //! Get the speed in degrees per second in all 3 dimensions - virtual const core::vector3df& getSpeed() const = 0; - - //! Get emitter type - virtual E_PARTICLE_AFFECTOR_TYPE getType() const { return EPAT_ROTATE; } -}; - -} // end namespace scene -} // end namespace irr - - -#endif // __I_PARTICLE_ROTATION_AFFECTOR_H_INCLUDED__ - diff --git a/irrlicht-1.6/include/IParticleSphereEmitter.h b/irrlicht-1.6/include/IParticleSphereEmitter.h deleted file mode 100644 index bc1b6eef9..000000000 --- a/irrlicht-1.6/include/IParticleSphereEmitter.h +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_PARTICLE_SPHERE_EMITTER_H_INCLUDED__ -#define __I_PARTICLE_SPHERE_EMITTER_H_INCLUDED__ - -#include "IParticleEmitter.h" - -namespace irr -{ -namespace scene -{ - -//! A particle emitter which emits from a spherical space. -class IParticleSphereEmitter : public IParticleEmitter -{ -public: - - //! Set the center of the sphere for particle emissions - virtual void setCenter( const core::vector3df& center ) = 0; - - //! Set the radius of the sphere for particle emissions - virtual void setRadius( f32 radius ) = 0; - - //! Get the center of the sphere for particle emissions - virtual const core::vector3df& getCenter() const = 0; - - //! Get the radius of the sphere for particle emissions - virtual f32 getRadius() const = 0; - - //! Get emitter type - virtual E_PARTICLE_EMITTER_TYPE getType() const { return EPET_SPHERE; } -}; - -} // end namespace scene -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/include/IParticleSystemSceneNode.h b/irrlicht-1.6/include/IParticleSystemSceneNode.h deleted file mode 100644 index 5835ca07a..000000000 --- a/irrlicht-1.6/include/IParticleSystemSceneNode.h +++ /dev/null @@ -1,500 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_PARTICLE_SYSTEM_SCENE_NODE_H_INCLUDED__ -#define __I_PARTICLE_SYSTEM_SCENE_NODE_H_INCLUDED__ - -#include "ISceneNode.h" -#include "IParticleAnimatedMeshSceneNodeEmitter.h" -#include "IParticleBoxEmitter.h" -#include "IParticleCylinderEmitter.h" -#include "IParticleMeshEmitter.h" -#include "IParticleRingEmitter.h" -#include "IParticleSphereEmitter.h" -#include "IParticleAttractionAffector.h" -#include "IParticleFadeOutAffector.h" -#include "IParticleGravityAffector.h" -#include "IParticleRotationAffector.h" -#include "dimension2d.h" - -namespace irr -{ -namespace scene -{ - -//! A particle system scene node for creating snow, fire, exlosions, smoke... -/** A scene node controlling a particle System. The behavior of the particles -can be controlled by setting the right particle emitters and affectors. -You can for example easily create a campfire by doing this: - -\code - scene::IParticleSystemSceneNode* p = scenemgr->addParticleSystemSceneNode(); - p->setParticleSize(core::dimension2d<f32>(20.0f, 10.0f)); - scene::IParticleEmitter* em = p->createBoxEmitter( - core::aabbox3d<f32>(-5,0,-5,5,1,5), - core::vector3df(0.0f,0.03f,0.0f), - 40,80, video::SColor(0,255,255,255),video::SColor(0,255,255,255), 1100,2000); - p->setEmitter(em); - em->drop(); - scene::IParticleAffector* paf = p->createFadeOutParticleAffector(); - p->addAffector(paf); - paf->drop(); -\endcode - -*/ -class IParticleSystemSceneNode : public ISceneNode -{ -public: - - //! Constructor - IParticleSystemSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)) - : ISceneNode(parent, mgr, id, position, rotation, scale) {} - - //! Sets the size of all particles. - virtual void setParticleSize( - const core::dimension2d<f32> &size = core::dimension2d<f32>(5.0f, 5.0f)) = 0; - - //! Sets if the particles should be global. - /** If they are, the particles are affected by the movement of the - particle system scene node too, otherwise they completely ignore it. - Default is true. */ - virtual void setParticlesAreGlobal(bool global=true) = 0; - - //! Gets the particle emitter, which creates the particles. - /** \return The particle emitter. Can be 0 if none is set. */ - virtual IParticleEmitter* getEmitter() =0; - - //! Sets the particle emitter, which creates the particles. - /** A particle emitter can be created using one of the createEmitter - methods. For example to create and use a simple PointEmitter, call - IParticleEmitter* p = createPointEmitter(); setEmitter(p); p->drop(); - \param emitter: Sets the particle emitter. You can set this to 0 for - removing the current emitter and stopping the particle system emitting - new particles. */ - virtual void setEmitter(IParticleEmitter* emitter) = 0; - - //! Adds new particle effector to the particle system. - /** A particle affector modifies the particles. For example, the FadeOut - affector lets all particles fade out after some time. It is created and - used in this way: - \code - IParticleAffector* p = createFadeOutParticleAffector(); - addAffector(p); - p->drop(); - \endcode - Please note that an affector is not necessary for the particle system to - work. - \param affector: New affector. */ - virtual void addAffector(IParticleAffector* affector) = 0; - - //! Removes all particle affectors in the particle system. - virtual void removeAllAffectors() = 0; - - //! Creates a particle emitter for an animated mesh scene node - /** \param node: Pointer to the animated mesh scene node to emit - particles from - \param useNormalDirection: If true, the direction of each particle - created will be the normal of the vertex that it's emitting from. The - normal is divided by the normalDirectionModifier parameter, which - defaults to 100.0f. - \param direction: Direction and speed of particle emission. - \param normalDirectionModifier: If the emitter is using the normal - direction then the normal of the vertex that is being emitted from is - divided by this number. - \param mbNumber: This allows you to specify a specific meshBuffer for - the IMesh* to emit particles from. The default value is -1, which - means a random meshBuffer picked from all of the meshes meshBuffers - will be selected to pick a random vertex from. If the value is 0 or - greater, it will only pick random vertices from the meshBuffer - specified by this value. - \param everyMeshVertex: If true, the emitter will emit between min/max - particles every second, for every vertex in the mesh, if false, it will - emit between min/max particles from random vertices in the mesh. - \param minParticlesPerSecond: Minimal amount of particles emitted per - second. - \param maxParticlesPerSecond: Maximal amount of particles emitted per - second. - \param minStartColor: Minimal initial start color of a particle. The - real color of every particle is calculated as random interpolation - between minStartColor and maxStartColor. - \param maxStartColor: Maximal initial start color of a particle. The - real color of every particle is calculated as random interpolation - between minStartColor and maxStartColor. - \param lifeTimeMin: Minimal lifetime of a particle, in milliseconds. - \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds. - \param maxAngleDegrees: Maximal angle in degrees, the emitting - direction of the particle will differ from the original direction. - \param minStartSize: Minimal initial start size of a particle. The - real size of every particle is calculated as random interpolation - between minStartSize and maxStartSize. - \param maxStartSize: Maximal initial start size of a particle. The - real size of every particle is calculated as random interpolation - between minStartSize and maxStartSize. - \return Pointer to the created particle emitter. To set this emitter - as new emitter of this particle system, just call setEmitter(). Note - that you'll have to drop() the returned pointer, after you don't need - it any more, see IReferenceCounted::drop() for more informations. */ - virtual IParticleAnimatedMeshSceneNodeEmitter* createAnimatedMeshSceneNodeEmitter( - scene::IAnimatedMeshSceneNode* node, bool useNormalDirection = true, - const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f), - f32 normalDirectionModifier = 100.0f, s32 mbNumber = -1, - bool everyMeshVertex = false, - u32 minParticlesPerSecond = 5, u32 maxParticlesPerSecond = 10, - const video::SColor& minStartColor = video::SColor(255,0,0,0), - const video::SColor& maxStartColor = video::SColor(255,255,255,255), - u32 lifeTimeMin = 2000, u32 lifeTimeMax = 4000, - s32 maxAngleDegrees = 0, - const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f), - const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) ) = 0; - - //! Creates a box particle emitter. - /** \param box: The box for the emitter. - \param direction: Direction and speed of particle emission. - \param minParticlesPerSecond: Minimal amount of particles emitted per - second. - \param maxParticlesPerSecond: Maximal amount of particles emitted per - second. - \param minStartColor: Minimal initial start color of a particle. The - real color of every particle is calculated as random interpolation - between minStartColor and maxStartColor. - \param maxStartColor: Maximal initial start color of a particle. The - real color of every particle is calculated as random interpolation - between minStartColor and maxStartColor. - \param lifeTimeMin: Minimal lifetime of a particle, in milliseconds. - \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds. - \param maxAngleDegrees: Maximal angle in degrees, the emitting - direction of the particle will differ from the original direction. - \param minStartSize: Minimal initial start size of a particle. The - real size of every particle is calculated as random interpolation - between minStartSize and maxStartSize. - \param maxStartSize: Maximal initial start size of a particle. The - real size of every particle is calculated as random interpolation - between minStartSize and maxStartSize. - \return Pointer to the created particle emitter. To set this emitter - as new emitter of this particle system, just call setEmitter(). Note - that you'll have to drop() the returned pointer, after you don't need - it any more, see IReferenceCounted::drop() for more informations. */ - virtual IParticleBoxEmitter* createBoxEmitter( - const core::aabbox3df& box = core::aabbox3df(-10,28,-10,10,30,10), - const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f), - u32 minParticlesPerSecond = 5, - u32 maxParticlesPerSecond = 10, - const video::SColor& minStartColor = video::SColor(255,0,0,0), - const video::SColor& maxStartColor = video::SColor(255,255,255,255), - u32 lifeTimeMin=2000, u32 lifeTimeMax=4000, - s32 maxAngleDegrees=0, - const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f), - const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) ) = 0; - - //! Creates a particle emitter for emitting from a cylinder - /** \param center: The center of the circle at the base of the cylinder - \param radius: The thickness of the cylinder - \param normal: Direction of the length of the cylinder - \param length: The length of the the cylinder - \param outlineOnly: Whether or not to put points inside the cylinder or - on the outline only - \param direction: Direction and speed of particle emission. - \param minParticlesPerSecond: Minimal amount of particles emitted per - second. - \param maxParticlesPerSecond: Maximal amount of particles emitted per - second. - \param minStartColor: Minimal initial start color of a particle. The - real color of every particle is calculated as random interpolation - between minStartColor and maxStartColor. - \param maxStartColor: Maximal initial start color of a particle. The - real color of every particle is calculated as random interpolation - between minStartColor and maxStartColor. - \param lifeTimeMin: Minimal lifetime of a particle, in milliseconds. - \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds. - \param maxAngleDegrees: Maximal angle in degrees, the emitting - direction of the particle will differ from the original direction. - \param minStartSize: Minimal initial start size of a particle. The - real size of every particle is calculated as random interpolation - between minStartSize and maxStartSize. - \param maxStartSize: Maximal initial start size of a particle. The - real size of every particle is calculated as random interpolation - between minStartSize and maxStartSize. - \return Pointer to the created particle emitter. To set this emitter - as new emitter of this particle system, just call setEmitter(). Note - that you'll have to drop() the returned pointer, after you don't need - it any more, see IReferenceCounted::drop() for more informations. */ - virtual IParticleCylinderEmitter* createCylinderEmitter( - const core::vector3df& center, f32 radius, - const core::vector3df& normal, f32 length, - bool outlineOnly = false, - const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f), - u32 minParticlesPerSecond = 5, u32 maxParticlesPerSecond = 10, - const video::SColor& minStartColor = video::SColor(255,0,0,0), - const video::SColor& maxStartColor = video::SColor(255,255,255,255), - u32 lifeTimeMin = 2000, u32 lifeTimeMax = 4000, - s32 maxAngleDegrees = 0, - const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f), - const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) ) = 0; - - //! Creates a mesh particle emitter. - /** \param mesh: Pointer to mesh to emit particles from - \param useNormalDirection: If true, the direction of each particle - created will be the normal of the vertex that it's emitting from. The - normal is divided by the normalDirectionModifier parameter, which - defaults to 100.0f. - \param direction: Direction and speed of particle emission. - \param normalDirectionModifier: If the emitter is using the normal - direction then the normal of the vertex that is being emitted from is - divided by this number. - \param mbNumber: This allows you to specify a specific meshBuffer for - the IMesh* to emit particles from. The default value is -1, which - means a random meshBuffer picked from all of the meshes meshBuffers - will be selected to pick a random vertex from. If the value is 0 or - greater, it will only pick random vertices from the meshBuffer - specified by this value. - \param everyMeshVertex: If true, the emitter will emit between min/max - particles every second, for every vertex in the mesh, if false, it will - emit between min/max particles from random vertices in the mesh. - \param minParticlesPerSecond: Minimal amount of particles emitted per - second. - \param maxParticlesPerSecond: Maximal amount of particles emitted per - second. - \param minStartColor: Minimal initial start color of a particle. The - real color of every particle is calculated as random interpolation - between minStartColor and maxStartColor. - \param maxStartColor: Maximal initial start color of a particle. The - real color of every particle is calculated as random interpolation - between minStartColor and maxStartColor. - \param lifeTimeMin: Minimal lifetime of a particle, in milliseconds. - \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds. - \param maxAngleDegrees: Maximal angle in degrees, the emitting - direction of the particle will differ from the original direction. - \param minStartSize: Minimal initial start size of a particle. The - real size of every particle is calculated as random interpolation - between minStartSize and maxStartSize. - \param maxStartSize: Maximal initial start size of a particle. The - real size of every particle is calculated as random interpolation - between minStartSize and maxStartSize. - \return Pointer to the created particle emitter. To set this emitter - as new emitter of this particle system, just call setEmitter(). Note - that you'll have to drop() the returned pointer, after you don't need - it any more, see IReferenceCounted::drop() for more informations. */ - virtual IParticleMeshEmitter* createMeshEmitter( - scene::IMesh* mesh, bool useNormalDirection = true, - const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f), - f32 normalDirectionModifier = 100.0f, s32 mbNumber = -1, - bool everyMeshVertex = false, - u32 minParticlesPerSecond = 5, u32 maxParticlesPerSecond = 10, - const video::SColor& minStartColor = video::SColor(255,0,0,0), - const video::SColor& maxStartColor = video::SColor(255,255,255,255), - u32 lifeTimeMin = 2000, u32 lifeTimeMax = 4000, - s32 maxAngleDegrees = 0, - const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f), - const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) ) = 0; - - //! Creates a point particle emitter. - /** \param direction: Direction and speed of particle emission. - \param minParticlesPerSecond: Minimal amount of particles emitted per - second. - \param maxParticlesPerSecond: Maximal amount of particles emitted per - second. - \param minStartColor: Minimal initial start color of a particle. The - real color of every particle is calculated as random interpolation - between minStartColor and maxStartColor. - \param maxStartColor: Maximal initial start color of a particle. The - real color of every particle is calculated as random interpolation - between minStartColor and maxStartColor. - \param lifeTimeMin: Minimal lifetime of a particle, in milliseconds. - \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds. - \param maxAngleDegrees: Maximal angle in degrees, the emitting - direction of the particle will differ from the original direction. - \param minStartSize: Minimal initial start size of a particle. The - real size of every particle is calculated as random interpolation - between minStartSize and maxStartSize. - \param maxStartSize: Maximal initial start size of a particle. The - real size of every particle is calculated as random interpolation - between minStartSize and maxStartSize. - \return Pointer to the created particle emitter. To set this emitter - as new emitter of this particle system, just call setEmitter(). Note - that you'll have to drop() the returned pointer, after you don't need - it any more, see IReferenceCounted::drop() for more informations. */ - virtual IParticlePointEmitter* createPointEmitter( - const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f), - u32 minParticlesPerSecond = 5, - u32 maxParticlesPerSecond = 10, - const video::SColor& minStartColor = video::SColor(255,0,0,0), - const video::SColor& maxStartColor = video::SColor(255,255,255,255), - u32 lifeTimeMin=2000, u32 lifeTimeMax=4000, - s32 maxAngleDegrees=0, - const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f), - const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) ) = 0; - - //! Creates a ring particle emitter. - /** \param center: Center of ring - \param radius: Distance of points from center, points will be rotated - around the Y axis at a random 360 degrees and will then be shifted by - the provided ringThickness values in each axis. - \param ringThickness : thickness of the ring or how wide the ring is - \param direction: Direction and speed of particle emission. - \param minParticlesPerSecond: Minimal amount of particles emitted per - second. - \param maxParticlesPerSecond: Maximal amount of particles emitted per - second. - \param minStartColor: Minimal initial start color of a particle. The - real color of every particle is calculated as random interpolation - between minStartColor and maxStartColor. - \param maxStartColor: Maximal initial start color of a particle. The - real color of every particle is calculated as random interpolation - between minStartColor and maxStartColor. - \param lifeTimeMin: Minimal lifetime of a particle, in milliseconds. - \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds. - \param maxAngleDegrees: Maximal angle in degrees, the emitting - direction of the particle will differ from the original direction. - \param minStartSize: Minimal initial start size of a particle. The - real size of every particle is calculated as random interpolation - between minStartSize and maxStartSize. - \param maxStartSize: Maximal initial start size of a particle. The - real size of every particle is calculated as random interpolation - between minStartSize and maxStartSize. - \return Pointer to the created particle emitter. To set this emitter - as new emitter of this particle system, just call setEmitter(). Note - that you'll have to drop() the returned pointer, after you don't need - it any more, see IReferenceCounted::drop() for more informations. */ - virtual IParticleRingEmitter* createRingEmitter( - const core::vector3df& center, f32 radius, f32 ringThickness, - const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f), - u32 minParticlesPerSecond = 5, - u32 maxParticlesPerSecond = 10, - const video::SColor& minStartColor = video::SColor(255,0,0,0), - const video::SColor& maxStartColor = video::SColor(255,255,255,255), - u32 lifeTimeMin=2000, u32 lifeTimeMax=4000, - s32 maxAngleDegrees=0, - const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f), - const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) ) = 0; - - //! Creates a sphere particle emitter. - /** \param center: Center of sphere - \param radius: Radius of sphere - \param direction: Direction and speed of particle emission. - \param minParticlesPerSecond: Minimal amount of particles emitted per - second. - \param maxParticlesPerSecond: Maximal amount of particles emitted per - second. - \param minStartColor: Minimal initial start color of a particle. The - real color of every particle is calculated as random interpolation - between minStartColor and maxStartColor. - \param maxStartColor: Maximal initial start color of a particle. The - real color of every particle is calculated as random interpolation - between minStartColor and maxStartColor. - \param lifeTimeMin: Minimal lifetime of a particle, in milliseconds. - \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds. - \param maxAngleDegrees: Maximal angle in degrees, the emitting - direction of the particle will differ from the original direction. - \param minStartSize: Minimal initial start size of a particle. The - real size of every particle is calculated as random interpolation - between minStartSize and maxStartSize. - \param maxStartSize: Maximal initial start size of a particle. The - real size of every particle is calculated as random interpolation - between minStartSize and maxStartSize. - \return Pointer to the created particle emitter. To set this emitter - as new emitter of this particle system, just call setEmitter(). Note - that you'll have to drop() the returned pointer, after you don't need - it any more, see IReferenceCounted::drop() for more informations. */ - virtual IParticleSphereEmitter* createSphereEmitter( - const core::vector3df& center, f32 radius, - const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f), - u32 minParticlesPerSecond = 5, - u32 maxParticlesPerSecond = 10, - const video::SColor& minStartColor = video::SColor(255,0,0,0), - const video::SColor& maxStartColor = video::SColor(255,255,255,255), - u32 lifeTimeMin=2000, u32 lifeTimeMax=4000, - s32 maxAngleDegrees=0, - const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f), - const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) ) = 0; - - //! Creates a point attraction affector. - /** This affector modifies the positions of the particles and attracts - them to a specified point at a specified speed per second. - \param point: Point to attract particles to. - \param speed: Speed in units per second, to attract to the specified - point. - \param attract: Whether the particles attract or detract from this - point. - \param affectX: Whether or not this will affect the X position of the - particle. - \param affectY: Whether or not this will affect the Y position of the - particle. - \param affectZ: Whether or not this will affect the Z position of the - particle. - \return Pointer to the created particle affector. To add this affector - as new affector of this particle system, just call addAffector(). Note - that you'll have to drop() the returned pointer, after you don't need - it any more, see IReferenceCounted::drop() for more informations. */ - virtual IParticleAttractionAffector* createAttractionAffector( - const core::vector3df& point, f32 speed = 1.0f, bool attract = true, - bool affectX = true, bool affectY = true, bool affectZ = true) = 0; - - //! Creates a scale particle affector. - /** This affector scales the particle to the a multiple of its size defined - by the scaleTo variable. - \param scaleTo: multiple of the size which the particle will be scaled to until deletion - \return Pointer to the created particle affector. - To add this affector as new affector of this particle system, - just call addAffector(). Note that you'll have to drop() the - returned pointer, after you don't need it any more, see - IReferenceCounted::drop() for more information. */ - virtual IParticleAffector* createScaleParticleAffector(const core::dimension2df& scaleTo = core::dimension2df(1.0f, 1.0f)) = 0; - - //! Creates a fade out particle affector. - /** This affector modifies the color of every particle and and reaches - the final color when the particle dies. This affector looks really - good, if the EMT_TRANSPARENT_VERTEX_ALPHA material is used and the - targetColor is video::SColor(0,0,0,0): Particles are fading out into - void with this setting. - \param targetColor: Color whereto the color of the particle is changed. - \param timeNeededToFadeOut: How much time in milli seconds should the - affector need to change the color to the targetColor. - \return Pointer to the created particle affector. To add this affector - as new affector of this particle system, just call addAffector(). Note - that you'll have to drop() the returned pointer, after you don't need - it any more, see IReferenceCounted::drop() for more informations. */ - virtual IParticleFadeOutAffector* createFadeOutParticleAffector( - const video::SColor& targetColor = video::SColor(0,0,0,0), - u32 timeNeededToFadeOut = 1000) = 0; - - //! Creates a gravity affector. - /** This affector modifies the direction of the particle. It assumes - that the particle is fired out of the emitter with huge force, but is - loosing this after some time and is catched by the gravity then. This - affector is ideal for creating things like fountains. - \param gravity: Direction and force of gravity. - \param timeForceLost: Time in milli seconds when the force of the - emitter is totally lost and the particle does not move any more. This - is the time where gravity fully affects the particle. - \return Pointer to the created particle affector. To add this affector - as new affector of this particle system, just call addAffector(). Note - that you'll have to drop() the returned pointer, after you don't need - it any more, see IReferenceCounted::drop() for more informations. */ - virtual IParticleGravityAffector* createGravityAffector( - const core::vector3df& gravity = core::vector3df(0.0f,-0.03f,0.0f), - u32 timeForceLost = 1000) = 0; - - //! Creates a rotation affector. - /** This affector modifies the positions of the particles and attracts - them to a specified point at a specified speed per second. - \param speed: Rotation in degrees per second - \param pivotPoint: Point to rotate the particles around - \return Pointer to the created particle affector. To add this affector - as new affector of this particle system, just call addAffector(). Note - that you'll have to drop() the returned pointer, after you don't need - it any more, see IReferenceCounted::drop() for more informations. */ - virtual IParticleRotationAffector* createRotationAffector( - const core::vector3df& speed = core::vector3df(5.0f,5.0f,5.0f), - const core::vector3df& pivotPoint = core::vector3df(0.0f,0.0f,0.0f) ) = 0; -}; - -} // end namespace scene -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/include/IQ3LevelMesh.h b/irrlicht-1.6/include/IQ3LevelMesh.h deleted file mode 100644 index a0008876c..000000000 --- a/irrlicht-1.6/include/IQ3LevelMesh.h +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_Q3_LEVEL_MESH_H_INCLUDED__ -#define __I_Q3_LEVEL_MESH_H_INCLUDED__ - -#include "IAnimatedMesh.h" -#include "IQ3Shader.h" - -namespace irr -{ -namespace scene -{ - //! Interface for a Mesh which can be loaded directly from a Quake3 .bsp-file. - /** The Mesh tries to load all textures of the map. There are currently - no additional methods in this class, but maybe there will be some in later - releases if there are feature requests. */ - class IQ3LevelMesh : public IAnimatedMesh - { - public: - - //! loads the shader definition from file - /** \param filename Name of the shaderfile, defaults to /scripts if fileNameIsValid is false. - \param fileNameIsValid Specifies whether the filename is valid in the current situation. */ - virtual const quake3::IShader* getShader( const c8* filename, bool fileNameIsValid=true ) = 0; - - //! returns a already loaded Shader - virtual const quake3::IShader* getShader(u32 index) const = 0; - - //! get's an interface to the entities - virtual quake3::tQ3EntityList& getEntityList() = 0; - - }; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IQ3Shader.h b/irrlicht-1.6/include/IQ3Shader.h deleted file mode 100644 index e00b57b12..000000000 --- a/irrlicht-1.6/include/IQ3Shader.h +++ /dev/null @@ -1,879 +0,0 @@ -// Copyright (C) 2006-2009 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_Q3_LEVEL_SHADER_H_INCLUDED__ -#define __I_Q3_LEVEL_SHADER_H_INCLUDED__ - -#include "irrArray.h" -#include "fast_atof.h" -#include "IFileSystem.h" -#include "IVideoDriver.h" -#include "coreutil.h" - -namespace irr -{ -namespace scene -{ -namespace quake3 -{ - - static core::stringc irrEmptyStringc(""); - - //! Hold the different Mesh Types used for getMesh - enum eQ3MeshIndex - { - E_Q3_MESH_GEOMETRY = 0, - E_Q3_MESH_ITEMS, - E_Q3_MESH_BILLBOARD, - E_Q3_MESH_FOG, - E_Q3_MESH_UNRESOLVED, - E_Q3_MESH_SIZE - }; - - /*! used to customize Quake3 BSP Loader - */ - - struct Q3LevelLoadParameter - { - Q3LevelLoadParameter () - :defaultLightMapMaterial ( video::EMT_LIGHTMAP_M4 ), - defaultModulate ( video::EMFN_MODULATE_4X ), - defaultFilter ( video::EMF_BILINEAR_FILTER ), - patchTesselation ( 8 ), - verbose ( 0 ), - startTime ( 0 ), endTime ( 0 ), - mergeShaderBuffer ( 1 ), - cleanUnResolvedMeshes ( 1 ), - loadAllShaders ( 0 ), - loadSkyShader ( 0 ), - alpharef ( 1 ), - swapLump ( 0 ), - #ifdef __BIG_ENDIAN__ - swapHeader ( 1 ) - #else - swapHeader ( 0 ) - #endif - { - memcpy ( scriptDir, "scripts\x0", 8 ); - } - - video::E_MATERIAL_TYPE defaultLightMapMaterial; - video::E_MODULATE_FUNC defaultModulate; - video::E_MATERIAL_FLAG defaultFilter; - s32 patchTesselation; - s32 verbose; - u32 startTime; - u32 endTime; - s32 mergeShaderBuffer; - s32 cleanUnResolvedMeshes; - s32 loadAllShaders; - s32 loadSkyShader; - s32 alpharef; - s32 swapLump; - s32 swapHeader; - c8 scriptDir [ 64 ]; - }; - - // some useful typedefs - typedef core::array< core::stringc > tStringList; - typedef core::array< video::ITexture* > tTexArray; - - // string helper.. TODO: move to generic files - inline s16 isEqual ( const core::stringc &string, u32 &pos, const c8 *list[], u16 listSize ) - { - const char * in = string.c_str () + pos; - - for ( u16 i = 0; i != listSize; ++i ) - { - if (string.size() < pos) - return -2; - u32 len = (u32) strlen ( list[i] ); - if (string.size() < pos+len) - continue; - if ( in [len] != 0 && in [len] != ' ' ) - continue; - if ( strncmp ( in, list[i], len ) ) - continue; - - pos += len + 1; - return (s16) i; - } - return -2; - } - - inline f32 getAsFloat ( const core::stringc &string, u32 &pos ) - { - const char * in = string.c_str () + pos; - - f32 value = 0.f; - pos += (u32) ( core::fast_atof_move ( in, value ) - in ) + 1; - return value; - } - - //! get a quake3 vector translated to irrlicht position (x,-z,y ) - inline core::vector3df getAsVector3df ( const core::stringc &string, u32 &pos ) - { - core::vector3df v; - - v.X = getAsFloat ( string, pos ); - v.Z = getAsFloat ( string, pos ); - v.Y = getAsFloat ( string, pos ); - - return v; - } - - - /* - extract substrings - */ - inline void getAsStringList ( tStringList &list, s32 max, const core::stringc &string, u32 &startPos ) - { - list.clear (); - - s32 finish = 0; - s32 endPos; - do - { - endPos = string.findNext ( ' ', startPos ); - if ( endPos == -1 ) - { - finish = 1; - endPos = string.size(); - } - - list.push_back ( string.subString ( startPos, endPos - startPos ) ); - startPos = endPos + 1; - - if ( list.size() >= (u32) max ) - finish = 1; - - } while ( !finish ); - - } - - //! A blend function for a q3 shader. - struct SBlendFunc - { - SBlendFunc ( video::E_MODULATE_FUNC mod ) - : type ( video::EMT_SOLID ), modulate ( mod ), - param0( 0.f ), - isTransparent ( 0 ) {} - - video::E_MATERIAL_TYPE type; - video::E_MODULATE_FUNC modulate; - - f32 param0; - u32 isTransparent; - }; - - // parses the content of Variable cull - inline bool getCullingFunction ( const core::stringc &cull ) - { - if ( cull.size() == 0 ) - return true; - - bool ret = true; - static const c8 * funclist[] = { "none", "disable", "twosided" }; - - u32 pos = 0; - switch ( isEqual ( cull, pos, funclist, 3 ) ) - { - case 0: - case 1: - case 2: - ret = false; - break; - } - return ret; - } - - // parses the content of Variable depthfunc - // return a z-test - inline u8 getDepthFunction ( const core::stringc &string ) - { - u8 ret = video::ECFN_LESSEQUAL; - - if ( string.size() == 0 ) - return ret; - - static const c8 * funclist[] = { "lequal","equal" }; - - u32 pos = 0; - switch ( isEqual ( string, pos, funclist, 2 ) ) - { - case 0: - ret = video::ECFN_LESSEQUAL; - case 1: - ret = video::ECFN_EQUAL; - break; - } - return ret; - } - - - /*! - parses the content of Variable blendfunc,alphafunc - it also make a hint for rendering as transparent or solid node. - - we assume a typical quake scene would look like this.. - 1) Big Static Mesh ( solid ) - 2) static scene item ( may use transparency ) but rendered in the solid pass - 3) additional transparency item in the transparent pass - - it's not 100% accurate! it just empirical.. - */ - inline static void getBlendFunc ( const core::stringc &string, SBlendFunc &blendfunc ) - { - if ( string.size() == 0 ) - return; - - // maps to E_BLEND_FACTOR - static const c8 * funclist[] = - { - "gl_zero", - "gl_one", - "gl_dst_color", - "gl_one_minus_dst_color", - "gl_src_color", - "gl_one_minus_src_color", - "gl_src_alpha", - "gl_one_minus_src_alpha", - "gl_dst_alpha", - "gl_one_minus_dst_alpha", - "gl_src_alpha_sat", - - "add", - "filter", - "blend", - - "ge128", - "gt0", - }; - - - u32 pos = 0; - s32 srcFact = isEqual ( string, pos, funclist, 16 ); - - if ( srcFact < 0 ) - return; - - u32 resolved = 0; - s32 dstFact = isEqual ( string, pos, funclist, 16 ); - - switch ( srcFact ) - { - case video::EBF_ZERO: - switch ( dstFact ) - { - // gl_zero gl_src_color == gl_dst_color gl_zero - case video::EBF_SRC_COLOR: - blendfunc.type = video::EMT_ONETEXTURE_BLEND; - blendfunc.param0 = video::pack_texureBlendFunc ( video::EBF_DST_COLOR, video::EBF_ZERO, blendfunc.modulate ); - blendfunc.isTransparent = 1; - resolved = 1; - break; - } break; - - case video::EBF_ONE: - switch ( dstFact ) - { - // gl_one gl_zero - case video::EBF_ZERO: - blendfunc.type = video::EMT_SOLID; - blendfunc.isTransparent = 0; - resolved = 1; - break; - - // gl_one gl_one - case video::EBF_ONE: - blendfunc.type = video::EMT_TRANSPARENT_ADD_COLOR; - blendfunc.isTransparent = 1; - resolved = 1; - break; - } break; - - case video::EBF_SRC_ALPHA: - switch ( dstFact ) - { - // gl_src_alpha gl_one_minus_src_alpha - case video::EBF_ONE_MINUS_SRC_ALPHA: - blendfunc.type = video::EMT_TRANSPARENT_ALPHA_CHANNEL; - blendfunc.param0 = 1.f/255.f; - blendfunc.isTransparent = 1; - resolved = 1; - break; - } break; - - case 11: - // add - blendfunc.type = video::EMT_TRANSPARENT_ADD_COLOR; - blendfunc.isTransparent = 1; - resolved = 1; - break; - case 12: - // filter = gl_dst_color gl_zero or gl_zero gl_src_color - blendfunc.type = video::EMT_ONETEXTURE_BLEND; - blendfunc.param0 = video::pack_texureBlendFunc ( video::EBF_DST_COLOR, video::EBF_ZERO, blendfunc.modulate ); - blendfunc.isTransparent = 1; - resolved = 1; - break; - case 13: - // blend = gl_src_alpha gl_one_minus_src_alpha - blendfunc.type = video::EMT_TRANSPARENT_ALPHA_CHANNEL; - blendfunc.param0 = 1.f/255.f; - blendfunc.isTransparent = 1; - resolved = 1; - break; - case 14: - // alphafunc ge128 - blendfunc.type = video::EMT_TRANSPARENT_ALPHA_CHANNEL; - blendfunc.param0 = 0.5f; - blendfunc.isTransparent = 1; - resolved = 1; - break; - case 15: - // alphafunc gt0 - blendfunc.type = video::EMT_TRANSPARENT_ALPHA_CHANNEL; - blendfunc.param0 = 1.f / 255.f; - blendfunc.isTransparent = 1; - resolved = 1; - break; - - } - - // use the generic blender - if ( 0 == resolved ) - { - blendfunc.type = video::EMT_ONETEXTURE_BLEND; - blendfunc.param0 = video::pack_texureBlendFunc ( - (video::E_BLEND_FACTOR) srcFact, - (video::E_BLEND_FACTOR) dstFact, - blendfunc.modulate); - - blendfunc.isTransparent = 1; - } - } - - // random noise [-1;1] - struct Noiser - { - static f32 get () - { - static u32 RandomSeed = 0x69666966; - RandomSeed = (RandomSeed * 3631 + 1); - - f32 value = ( (f32) (RandomSeed & 0x7FFF ) * (1.0f / (f32)(0x7FFF >> 1) ) ) - 1.f; - return value; - } - }; - - enum eQ3ModifierFunction - { - TCMOD = 0, - DEFORMVERTEXES = 1, - RGBGEN = 2, - TCGEN = 3, - MAP = 4, - ALPHAGEN = 5, - - FUNCTION2 = 0x10, - SCROLL = FUNCTION2 + 1, - SCALE = FUNCTION2 + 2, - ROTATE = FUNCTION2 + 3, - STRETCH = FUNCTION2 + 4, - TURBULENCE = FUNCTION2 + 5, - WAVE = FUNCTION2 + 6, - - IDENTITY = FUNCTION2 + 7, - VERTEX = FUNCTION2 + 8, - TEXTURE = FUNCTION2 + 9, - LIGHTMAP = FUNCTION2 + 10, - ENVIRONMENT = FUNCTION2 + 11, - DOLLAR_LIGHTMAP = FUNCTION2 + 12, - BULGE = FUNCTION2 + 13, - AUTOSPRITE = FUNCTION2 + 14, - AUTOSPRITE2 = FUNCTION2 + 15, - TRANSFORM = FUNCTION2 + 16, - EXACTVERTEX = FUNCTION2 + 17, - CONSTANT = FUNCTION2 + 18, - LIGHTINGSPECULAR = FUNCTION2 + 19, - MOVE = FUNCTION2 + 20, - NORMAL = FUNCTION2 + 21, - IDENTITYLIGHTING = FUNCTION2 + 22, - - WAVE_MODIFIER_FUNCTION = 0x30, - SINUS = WAVE_MODIFIER_FUNCTION + 1, - COSINUS = WAVE_MODIFIER_FUNCTION + 2, - SQUARE = WAVE_MODIFIER_FUNCTION + 3, - TRIANGLE = WAVE_MODIFIER_FUNCTION + 4, - SAWTOOTH = WAVE_MODIFIER_FUNCTION + 5, - SAWTOOTH_INVERSE = WAVE_MODIFIER_FUNCTION + 6, - NOISE = WAVE_MODIFIER_FUNCTION + 7, - - - UNKNOWN = -2 - - }; - - struct SModifierFunction - { - SModifierFunction () - : masterfunc0 ( UNKNOWN ), masterfunc1( UNKNOWN ), func ( SINUS ), - tcgen( TEXTURE ), rgbgen ( IDENTITY ), alphagen ( UNKNOWN ), - base ( 0 ), amp ( 1 ), phase ( 0 ), frequency ( 1 ), - wave ( 1 ), - x ( 0 ), y ( 0 ), z( 0 ), count( 0 ) {} - - // "tcmod","deformvertexes","rgbgen", "tcgen" - eQ3ModifierFunction masterfunc0; - // depends - eQ3ModifierFunction masterfunc1; - // depends - eQ3ModifierFunction func; - - eQ3ModifierFunction tcgen; - eQ3ModifierFunction rgbgen; - eQ3ModifierFunction alphagen; - - union - { - f32 base; - f32 bulgewidth; - }; - - union - { - f32 amp; - f32 bulgeheight; - }; - - f32 phase; - - union - { - f32 frequency; - f32 bulgespeed; - }; - - union - { - f32 wave; - f32 div; - }; - - f32 x; - f32 y; - f32 z; - u32 count; - - f32 evaluate ( f32 dt ) const - { - // phase in 0 and 1.. - f32 x = core::fract( (dt + phase ) * frequency ); - f32 y = 0.f; - - switch ( func ) - { - case SINUS: - y = sinf ( x * core::PI * 2.f ); - break; - case COSINUS: - y = cosf ( x * core::PI * 2.f ); - break; - case SQUARE: - y = x < 0.5f ? 1.f : -1.f; - break; - case TRIANGLE: - y = x < 0.5f ? ( 4.f * x ) - 1.f : ( -4.f * x ) + 3.f; - break; - case SAWTOOTH: - y = x; - break; - case SAWTOOTH_INVERSE: - y = 1.f - x; - break; - case NOISE: - y = Noiser::get(); - break; - default: - break; - } - - return base + ( y * amp ); - } - - - }; - - inline core::vector3df getMD3Normal ( u32 i, u32 j ) - { - const f32 lng = i * 2.0f * core::PI / 255.0f; - const f32 lat = j * 2.0f * core::PI / 255.0f; - return core::vector3df(cosf ( lat ) * sinf ( lng ), - sinf ( lat ) * sinf ( lng ), - cosf ( lng )); - } - - // - inline void getModifierFunc ( SModifierFunction& fill, const core::stringc &string, u32 &pos ) - { - if ( string.size() == 0 ) - return; - - static const c8 * funclist[] = - { - "sin","cos","square", - "triangle", "sawtooth","inversesawtooth", "noise" - }; - - fill.func = (eQ3ModifierFunction) isEqual ( string,pos, funclist,7 ); - fill.func = fill.func == UNKNOWN ? SINUS : (eQ3ModifierFunction) ((u32) fill.func + WAVE_MODIFIER_FUNCTION + 1); - - fill.base = getAsFloat ( string, pos ); - fill.amp = getAsFloat ( string, pos ); - fill.phase = getAsFloat ( string, pos ); - fill.frequency = getAsFloat ( string, pos ); - } - - - // name = "a b c .." - struct SVariable - { - core::stringc name; - core::stringc content; - - SVariable ( const c8 * n, const c8 *c = 0 ) : name ( n ), content (c) {} - virtual ~SVariable () {} - - void clear () - { - name = ""; - content = ""; - } - - s32 isValid () const - { - return name.size(); - } - - bool operator == ( const SVariable &other ) const - { - return 0 == strcmp ( name.c_str(), other.name.c_str () ); - } - - bool operator < ( const SVariable &other ) const - { - return 0 > strcmp ( name.c_str(), other.name.c_str () ); - } - - }; - - - // string database. "a" = "Hello", "b" = "1234.6" - struct SVarGroup - { - SVarGroup () { Variable.setAllocStrategy ( core::ALLOC_STRATEGY_SAFE ); } - virtual ~SVarGroup () {} - - u32 isDefined ( const c8 * name, const c8 * content = 0 ) const - { - for ( u32 i = 0; i != Variable.size (); ++i ) - { - if ( 0 == strcmp ( Variable[i].name.c_str(), name ) && - ( 0 == content || strstr ( Variable[i].content.c_str(), content ) ) - ) - { - return i + 1; - } - } - return 0; - } - - // searches for Variable name and returns is content - // if Variable is not found a reference to an Empty String is returned - const core::stringc &get( const c8 * name ) const - { - SVariable search ( name ); - s32 index = Variable.linear_search ( search ); - if ( index < 0 ) - return irrEmptyStringc; - - return Variable [ index ].content; - } - - // set the Variable name - void set ( const c8 * name, const c8 * content = 0 ) - { - u32 index = isDefined ( name, 0 ); - if ( 0 == index ) - { - Variable.push_back ( SVariable ( name, content ) ); - } - else - { - Variable [ index ].content = content; - } - } - - - core::array < SVariable > Variable; - }; - - //! holding a group a variable - struct SVarGroupList: public IReferenceCounted - { - SVarGroupList () - { - VariableGroup.setAllocStrategy ( core::ALLOC_STRATEGY_SAFE ); - } - virtual ~SVarGroupList () {} - - core::array < SVarGroup > VariableGroup; - }; - - - //! A Parsed Shader Holding Variables ordered in Groups - struct IShader - { - IShader () - : ID ( 0 ), VarGroup ( 0 ) {} - virtual ~IShader () {} - - void operator = (const IShader &other ) - { - ID = other.ID; - VarGroup = other.VarGroup; - name = other.name; - } - - bool operator == (const IShader &other ) const - { - return 0 == strcmp ( name.c_str(), other.name.c_str () ); - //return name == other.name; - } - - bool operator < (const IShader &other ) const - { - return strcmp ( name.c_str(), other.name.c_str () ) < 0; - //return name < other.name; - } - - u32 getGroupSize () const - { - if ( 0 == VarGroup ) - return 0; - return VarGroup->VariableGroup.size (); - } - - const SVarGroup * getGroup ( u32 stage ) const - { - if ( 0 == VarGroup || stage >= VarGroup->VariableGroup.size () ) - return 0; - - return &VarGroup->VariableGroup [ stage ]; - } - - // id - s32 ID; - SVarGroupList *VarGroup; // reference - - // Shader: shader name ( also first variable in first Vargroup ) - // Entity: classname ( variable in Group(1) ) - core::stringc name; - }; - - typedef IShader IEntity; - - typedef core::array < IEntity > tQ3EntityList; - - /* - dump shader like original layout, regardless of internal data holding - no recursive folding.. - */ - inline void dumpVarGroup ( core::stringc &dest, const SVarGroup * group, s32 stack ) - { - core::stringc buf; - s32 i; - - - if ( stack > 0 ) - { - buf = ""; - for ( i = 0; i < stack - 1; ++i ) - buf += '\t'; - - buf += "{\n"; - dest.append ( buf ); - } - - for ( u32 g = 0; g != group->Variable.size(); ++g ) - { - buf = ""; - for ( i = 0; i < stack; ++i ) - buf += '\t'; - - buf += group->Variable[g].name; - buf += " "; - buf += group->Variable[g].content; - buf += "\n"; - dest.append ( buf ); - } - - if ( stack > 1 ) - { - buf = ""; - for ( i = 0; i < stack - 1; ++i ) - buf += '\t'; - - buf += "}\n"; - dest.append ( buf ); - } - - } - - /*! - dump a Shader or an Entity - */ - inline core::stringc & dumpShader ( core::stringc &dest, const IShader * shader, bool entity = false ) - { - if ( 0 == shader ) - return dest; - - const SVarGroup * group; - - const u32 size = shader->VarGroup->VariableGroup.size (); - for ( u32 i = 0; i != size; ++i ) - { - group = &shader->VarGroup->VariableGroup[ i ]; - dumpVarGroup ( dest, group, core::clamp( (int)i, 0, 2 ) ); - } - - if ( !entity ) - { - if ( size <= 1 ) - { - dest.append ( "{\n" ); - } - dest.append ( "}\n" ); - } - return dest; - } - - - /* - quake3 doesn't care much about tga & jpg - load one or multiple files stored in name started at startPos to the texture array textures - if texture is not loaded 0 will be added ( to find missing textures easier) - */ - inline void getTextures(tTexArray &textures, - const core::stringc &name, u32 &startPos, - io::IFileSystem *fileSystem, - video::IVideoDriver* driver) - { - static const char * extension[2] = - { - ".jpg", - ".tga" - }; - - tStringList stringList; - getAsStringList ( stringList, -1, name, startPos ); - - textures.clear(); - - core::stringc loadFile; - for ( u32 i = 0; i!= stringList.size (); ++i ) - { - video::ITexture* texture = 0; - for ( u32 g = 0; g != 2 ; ++g ) - { - core::cutFilenameExtension ( loadFile, stringList[i] ); - - if ( loadFile == "$whiteimage" ) - { - texture = driver->getTexture( "$whiteimage" ); - if ( 0 == texture ) - { - core::dimension2du s ( 2, 2 ); - u32 image[4] = { 0xFFFFFFFF, 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF }; - video::IImage* w = driver->createImageFromData ( video::ECF_A8R8G8B8, s,&image ); - texture = driver->addTexture( "$whiteimage", w ); - w->drop (); - } - - } - else - if ( loadFile == "$redimage" ) - { - texture = driver->getTexture( "$redimage" ); - if ( 0 == texture ) - { - core::dimension2du s ( 2, 2 ); - u32 image[4] = { 0xFFFF0000, 0xFFFF0000,0xFFFF0000,0xFFFF0000 }; - video::IImage* w = driver->createImageFromData ( video::ECF_A8R8G8B8, s,&image ); - texture = driver->addTexture( "$redimage", w ); - w->drop (); - } - } - else - if ( loadFile == "$blueimage" ) - { - texture = driver->getTexture( "$blueimage" ); - if ( 0 == texture ) - { - core::dimension2du s ( 2, 2 ); - u32 image[4] = { 0xFF0000FF, 0xFF0000FF,0xFF0000FF,0xFF0000FF }; - video::IImage* w = driver->createImageFromData ( video::ECF_A8R8G8B8, s,&image ); - texture = driver->addTexture( "$blueimage", w ); - w->drop (); - } - } - else - if ( loadFile == "$checkerimage" ) - { - texture = driver->getTexture( "$checkerimage" ); - if ( 0 == texture ) - { - core::dimension2du s ( 2, 2 ); - u32 image[4] = { 0xFFFFFFFF, 0xFF000000,0xFF000000,0xFFFFFFFF }; - video::IImage* w = driver->createImageFromData ( video::ECF_A8R8G8B8, s,&image ); - texture = driver->addTexture( "$checkerimage", w ); - w->drop (); - } - } - else - if ( loadFile == "$lightmap" ) - { - texture = 0; - } - else - { - loadFile.append ( extension[g] ); - } - - if ( fileSystem->existFile ( loadFile ) ) - { - texture = driver->getTexture( loadFile ); - if ( texture ) - break; - texture = 0; - } - } - // take 0 Texture - textures.push_back(texture); - } - } - - - //! Manages various Quake3 Shader Styles - class IShaderManager : public IReferenceCounted - { - }; - -} // end namespace quake3 -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IReadFile.h b/irrlicht-1.6/include/IReadFile.h deleted file mode 100644 index 6f67f5cae..000000000 --- a/irrlicht-1.6/include/IReadFile.h +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_READ_FILE_H_INCLUDED__ -#define __I_READ_FILE_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "coreutil.h" - -namespace irr -{ -namespace io -{ - - //! Interface providing read acess to a file. - class IReadFile : public virtual IReferenceCounted - { - public: - //! Reads an amount of bytes from the file. - /** \param buffer Pointer to buffer where read bytes are written to. - \param sizeToRead Amount of bytes to read from the file. - \return How many bytes were read. */ - virtual s32 read(void* buffer, u32 sizeToRead) = 0; - - //! Changes position in file - /** \param finalPos Destination position in the file. - \param relativeMovement If set to true, the position in the file is - changed relative to current position. Otherwise the position is changed - from beginning of file. - \return True if successful, otherwise false. */ - virtual bool seek(long finalPos, bool relativeMovement = false) = 0; - - //! Get size of file. - /** \return Size of the file in bytes. */ - virtual long getSize() const = 0; - - //! Get the current position in the file. - /** \return Current position in the file in bytes. */ - virtual long getPos() const = 0; - - //! Get name of file. - /** \return File name as zero terminated character string. */ - virtual const io::path& getFileName() const = 0; - }; - - //! Internal function, please do not use. - IReadFile* createReadFile(const io::path& fileName); - //! Internal function, please do not use. - IReadFile* createLimitReadFile(const io::path& fileName, IReadFile* alreadyOpenedFile, long pos, long areaSize); - //! Internal function, please do not use. - IReadFile* createMemoryReadFile(void* memory, long size, const io::path& fileName, bool deleteMemoryWhenDropped); - -} // end namespace io -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IReferenceCounted.h b/irrlicht-1.6/include/IReferenceCounted.h deleted file mode 100644 index 6ed9474b6..000000000 --- a/irrlicht-1.6/include/IReferenceCounted.h +++ /dev/null @@ -1,170 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_IREFERENCE_COUNTED_H_INCLUDED__ -#define __I_IREFERENCE_COUNTED_H_INCLUDED__ - -#include "irrTypes.h" - -namespace irr -{ - - //! Base class of most objects of the Irrlicht Engine. - /** This class provides reference counting through the methods grab() and drop(). - It also is able to store a debug string for every instance of an object. - Most objects of the Irrlicht - Engine are derived from IReferenceCounted, and so they are reference counted. - - When you create an object in the Irrlicht engine, calling a method - which starts with 'create', an object is created, and you get a pointer - to the new object. If you no longer need the object, you have - to call drop(). This will destroy the object, if grab() was not called - in another part of you program, because this part still needs the object. - Note, that you only need to call drop() to the object, if you created it, - and the method had a 'create' in it. - - A simple example: - - If you want to create a texture, you may want to call an imaginable method - IDriver::createTexture. You call - ITexture* texture = driver->createTexture(dimension2d<u32>(128, 128)); - If you no longer need the texture, call texture->drop(). - - If you want to load a texture, you may want to call imaginable method - IDriver::loadTexture. You do this like - ITexture* texture = driver->loadTexture("example.jpg"); - You will not have to drop the pointer to the loaded texture, because - the name of the method does not start with 'create'. The texture - is stored somewhere by the driver. - */ - class IReferenceCounted - { - public: - - //! Constructor. - IReferenceCounted() - : DebugName(0), ReferenceCounter(1) - { - } - - //! Destructor. - virtual ~IReferenceCounted() - { - } - - //! Grabs the object. Increments the reference counter by one. - /** Someone who calls grab() to an object, should later also - call drop() to it. If an object never gets as much drop() as - grab() calls, it will never be destroyed. The - IReferenceCounted class provides a basic reference counting - mechanism with its methods grab() and drop(). Most objects of - the Irrlicht Engine are derived from IReferenceCounted, and so - they are reference counted. - - When you create an object in the Irrlicht engine, calling a - method which starts with 'create', an object is created, and - you get a pointer to the new object. If you no longer need the - object, you have to call drop(). This will destroy the object, - if grab() was not called in another part of you program, - because this part still needs the object. Note, that you only - need to call drop() to the object, if you created it, and the - method had a 'create' in it. - - A simple example: - - If you want to create a texture, you may want to call an - imaginable method IDriver::createTexture. You call - ITexture* texture = driver->createTexture(dimension2d<u32>(128, 128)); - If you no longer need the texture, call texture->drop(). - If you want to load a texture, you may want to call imaginable - method IDriver::loadTexture. You do this like - ITexture* texture = driver->loadTexture("example.jpg"); - You will not have to drop the pointer to the loaded texture, - because the name of the method does not start with 'create'. - The texture is stored somewhere by the driver. */ - void grab() const { ++ReferenceCounter; } - - //! Drops the object. Decrements the reference counter by one. - /** The IReferenceCounted class provides a basic reference - counting mechanism with its methods grab() and drop(). Most - objects of the Irrlicht Engine are derived from - IReferenceCounted, and so they are reference counted. - - When you create an object in the Irrlicht engine, calling a - method which starts with 'create', an object is created, and - you get a pointer to the new object. If you no longer need the - object, you have to call drop(). This will destroy the object, - if grab() was not called in another part of you program, - because this part still needs the object. Note, that you only - need to call drop() to the object, if you created it, and the - method had a 'create' in it. - - A simple example: - - If you want to create a texture, you may want to call an - imaginable method IDriver::createTexture. You call - ITexture* texture = driver->createTexture(dimension2d<u32>(128, 128)); - If you no longer need the texture, call texture->drop(). - If you want to load a texture, you may want to call imaginable - method IDriver::loadTexture. You do this like - ITexture* texture = driver->loadTexture("example.jpg"); - You will not have to drop the pointer to the loaded texture, - because the name of the method does not start with 'create'. - The texture is stored somewhere by the driver. - \return True, if the object was deleted. */ - bool drop() const - { - // someone is doing bad reference counting. - _IRR_DEBUG_BREAK_IF(ReferenceCounter <= 0) - - --ReferenceCounter; - if (!ReferenceCounter) - { - delete this; - return true; - } - - return false; - } - - //! Get the reference count. - /** \return Current value of the reference counter. */ - s32 getReferenceCount() const - { - return ReferenceCounter; - } - - //! Returns the debug name of the object. - /** The Debugname may only be set and changed by the object - itself. This method should only be used in Debug mode. - \return Returns a string, previously set by setDebugName(); */ - const c8* getDebugName() const - { - return DebugName; - } - - protected: - - //! Sets the debug name of the object. - /** The Debugname may only be set and changed by the object - itself. This method should only be used in Debug mode. - \param newName: New debug name to set. */ - void setDebugName(const c8* newName) - { - DebugName = newName; - } - - private: - - //! The debug name. - const c8* DebugName; - - //! The reference counter. Mutable to do reference counting on const objects. - mutable s32 ReferenceCounter; - }; - -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/ISceneCollisionManager.h b/irrlicht-1.6/include/ISceneCollisionManager.h deleted file mode 100644 index a0324ae88..000000000 --- a/irrlicht-1.6/include/ISceneCollisionManager.h +++ /dev/null @@ -1,200 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_SCENE_COLLISION_MANAGER_H_INCLUDED__ -#define __I_SCENE_COLLISION_MANAGER_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "vector3d.h" -#include "triangle3d.h" -#include "position2d.h" -#include "line3d.h" - -namespace irr -{ - -namespace scene -{ - class ISceneNode; - class ICameraSceneNode; - class ITriangleSelector; - - //! The Scene Collision Manager provides methods for performing collision tests and picking on scene nodes. - class ISceneCollisionManager : public virtual IReferenceCounted - { - public: - - //! Finds the collision point of a line and lots of triangles, if there is one. - /** \param ray: Line with witch collisions are tested. - \param selector: TriangleSelector containing the triangles. It - can be created for example using - ISceneManager::createTriangleSelector() or - ISceneManager::createTriangleOctTreeSelector(). - \param outCollisionPoint: If a collision is detected, this will - contain the position of the nearest collision. - \param outTriangle: If a collision is detected, this will - contain the triangle with which the ray collided. - \param outNode: If a collision is detected, this will contain - the scene node associated with the triangle that was hit. - \return True if a collision was detected and false if not. */ - virtual bool getCollisionPoint(const core::line3d<f32>& ray, - ITriangleSelector* selector, core::vector3df& outCollisionPoint, - core::triangle3df& outTriangle, const ISceneNode*& outNode) =0; - - //! Collides a moving ellipsoid with a 3d world with gravity and returns the resulting new position of the ellipsoid. - /** This can be used for moving a character in a 3d world: The - character will slide at walls and is able to walk up stairs. - The method used how to calculate the collision result position - is based on the paper "Improved Collision detection and - Response" by Kasper Fauerby. - \param selector: TriangleSelector containing the triangles of - the world. It can be created for example using - ISceneManager::createTriangleSelector() or - ISceneManager::createTriangleOctTreeSelector(). - \param ellipsoidPosition: Position of the ellipsoid. - \param ellipsoidRadius: Radius of the ellipsoid. - \param ellipsoidDirectionAndSpeed: Direction and speed of the - movement of the ellipsoid. - \param triout: Optional parameter where the last triangle - causing a collision is stored, if there is a collision. - \param outFalling: Is set to true if the ellipsoid is falling - down, caused by gravity. - \param outNode: the node with which the ellipoid collided (if any) - \param slidingSpeed: DOCUMENTATION NEEDED. - \param gravityDirectionAndSpeed: Direction and force of gravity. - \return New position of the ellipsoid. */ - virtual core::vector3df getCollisionResultPosition( - ITriangleSelector* selector, - const core::vector3df &ellipsoidPosition, - const core::vector3df& ellipsoidRadius, - const core::vector3df& ellipsoidDirectionAndSpeed, - core::triangle3df& triout, - core::vector3df& hitPosition, - bool& outFalling, - const ISceneNode*& outNode, - f32 slidingSpeed = 0.0005f, - const core::vector3df& gravityDirectionAndSpeed - = core::vector3df(0.0f, 0.0f, 0.0f)) = 0; - - //! Returns a 3d ray which would go through the 2d screen coodinates. - /** \param pos: Screen coordinates in pixels. - \param camera: Camera from which the ray starts. If null, the - active camera is used. - \return Ray starting from the position of the camera and ending - at a length of the far value of the camera at a position which - would be behind the 2d screen coodinates. */ - virtual core::line3d<f32> getRayFromScreenCoordinates( - const core::position2d<s32> & pos, ICameraSceneNode* camera = 0) = 0; - - //! Calculates 2d screen position from a 3d position. - /** \param pos: 3D position in world space to be transformed - into 2d. - \param camera: Camera to be used. If null, the currently active - camera is used. - \return 2d screen coordinates which a object in the 3d world - would have if it would be rendered to the screen. If the 3d - position is behind the camera, it is set to (-10000,-10000). In - most cases you can ignore this fact, because if you use this - method for drawing a decorator over a 3d object, it will be - clipped by the screen borders. */ - virtual core::position2d<s32> getScreenCoordinatesFrom3DPosition( - const core::vector3df & pos, ICameraSceneNode* camera=0) = 0; - - //! Gets the scene node, which is currently visible under the given screencoordinates, viewed from the currently active camera. - /** The collision tests are done using a bounding box for each - scene node. You can limit the recursive search so just all children of the specified root are tested. - \param pos: Position in pixel screen coordinates, under which - the returned scene node will be. - \param idBitMask: Only scene nodes with an id with bits set - like in this mask will be tested. If the BitMask is 0, this - feature is disabled. - Please note that the default node id of -1 will match with - every bitmask != 0 - \param bNoDebugObjects: Doesn't take debug objects into account - when true. These are scene nodes with IsDebugObject() = true. - \param root If different from 0, the search is limited to the children of this node. - \return Visible scene node under screen coordinates with - matching bits in its id. If there is no scene node under this - position, 0 is returned. */ - virtual ISceneNode* getSceneNodeFromScreenCoordinatesBB(const core::position2d<s32>& pos, - s32 idBitMask=0, bool bNoDebugObjects=false, ISceneNode* root=0) =0; - - //! Returns the nearest scene node which collides with a 3d ray and whose id matches a bitmask. - /** The collision tests are done using a bounding box for each - scene node. The recursive search can be limited be specifying a scene node. - \param ray Line with which collisions are tested. - \param idBitMask Only scene nodes with an id which matches at - least one of the bits contained in this mask will be tested. - However, if this parameter is 0, then all nodes are checked. - \param bNoDebugObjects: Doesn't take debug objects into account when true. These - are scene nodes with IsDebugObject() = true. - \param root If different from 0, the search is limited to the children of this node. - \return Scene node nearest to ray.start, which collides with - the ray and matches the idBitMask, if the mask is not null. If - no scene node is found, 0 is returned. */ - virtual ISceneNode* getSceneNodeFromRayBB(const core::line3d<f32>& ray, - s32 idBitMask=0, bool bNoDebugObjects=false, ISceneNode* root=0) =0; - - //! Get the scene node, which the given camera is looking at and whose id matches the bitmask. - /** A ray is simply casted from the position of the camera to - the view target position, and all scene nodes are tested - against this ray. The collision tests are done using a bounding - box for each scene node. - \param camera: Camera from which the ray is casted. - \param idBitMask: Only scene nodes with an id which matches at least one of the - bits contained in this mask will be tested. However, if this parameter is 0, then - all nodes are checked. - feature is disabled. - Please note that the default node id of -1 will match with - every bitmask != 0 - \param bNoDebugObjects: Doesn't take debug objects into account - when true. These are scene nodes with IsDebugObject() = true. - \return Scene node nearest to the camera, which collides with - the ray and matches the idBitMask, if the mask is not null. If - no scene node is found, 0 is returned. */ - virtual ISceneNode* getSceneNodeFromCameraBB(ICameraSceneNode* camera, - s32 idBitMask=0, bool bNoDebugObjects = false) = 0; - - //! Perform a ray/box and ray/triangle collision check on a heirarchy of scene nodes. - /** This checks all scene nodes under the specified one, first by ray/bounding - box, and then by accurate ray/triangle collision, finding the nearest collision, - and the scene node containg it. It returns the node hit, and (via output - parameters) the position of the collision, and the triangle that was hit. - - All scene nodes in the hierarchy tree under the specified node are checked. Only - notes that are visible, with an ID that matches at least one bit in the supplied - bitmask, and which have a triangle selector are considered as candidates for being hit. - You do not have to build a meta triangle selector; the individual triangle selectors - of each candidate scene node are used automatically. - - \param ray: Line with which collisions are tested. - \param outCollisionPoint: If a collision is detected, this will contain the - position of the nearest collision. - \param outTriangle: If a collision is detected, this will contain the triangle - with which the ray collided. - \param idBitMask: Only scene nodes with an id which matches at least one of the - bits contained in this mask will be tested. However, if this parameter is 0, then - all nodes are checked. - \param collisionRootNode: the scene node at which to begin checking. Only this - node and its children will be checked. If you want to check the entire scene, - pass 0, and the root scene node will be used (this is the default). - \param noDebugObjects: when true, debug objects are not considered viable targets. - Debug objects are scene nodes with IsDebugObject() = true. - \return Returns the scene node containing the hit triangle nearest to ray.start. - If no collision is detected, then 0 is returned. */ - virtual ISceneNode* getSceneNodeAndCollisionPointFromRay( - core::line3df ray, - core::vector3df & outCollisionPoint, - core::triangle3df & outTriangle, - s32 idBitMask = 0, - ISceneNode * collisionRootNode = 0, - bool noDebugObjects = false) = 0; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/ISceneManager.h b/irrlicht-1.6/include/ISceneManager.h deleted file mode 100644 index 373d549fe..000000000 --- a/irrlicht-1.6/include/ISceneManager.h +++ /dev/null @@ -1,1481 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_SCENE_MANAGER_H_INCLUDED__ -#define __I_SCENE_MANAGER_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "irrArray.h" -#include "irrString.h" -#include "path.h" -#include "vector3d.h" -#include "dimension2d.h" -#include "SColor.h" -#include "ETerrainElements.h" -#include "ESceneNodeTypes.h" -#include "ESceneNodeAnimatorTypes.h" -#include "EMeshWriterEnums.h" -#include "SceneParameters.h" -#include "IGeometryCreator.h" -#include "ISkinnedMesh.h" - -namespace irr -{ - struct SKeyMap; - struct SEvent; - -namespace io -{ - class IReadFile; - class IAttributes; - class IWriteFile; - class IFileSystem; -} // end namespace io - -namespace gui -{ - class IGUIFont; - class IGUIEnvironment; -} // end namespace gui - -namespace video -{ - class IVideoDriver; - class SMaterial; - class IImage; - class ITexture; -} // end namespace video - -namespace scene -{ - class IMeshWriter; - - //! Enumeration for render passes. - /** A parameter passed to the registerNodeForRendering() method of the ISceneManager, - specifying when the node wants to be drawn in relation to the other nodes. */ - enum E_SCENE_NODE_RENDER_PASS - { - //! No pass currently active - ESNRP_NONE =0, - - //! Camera pass. The active view is set up here. The very first pass. - ESNRP_CAMERA =1, - - //! In this pass, lights are transformed into camera space and added to the driver - ESNRP_LIGHT =2, - - //! This is used for sky boxes. - ESNRP_SKY_BOX =4, - - //! All normal objects can use this for registering themselves. - /** This value will never be returned by - ISceneManager::getSceneNodeRenderPass(). The scene manager - will determine by itself if an object is transparent or solid - and register the object as SNRT_TRANSPARENT or SNRT_SOLD - automatically if you call registerNodeForRendering with this - value (which is default). Note that it will register the node - only as ONE type. If your scene node has both solid and - transparent material types register it twice (one time as - SNRT_SOLID, the other time as SNRT_TRANSPARENT) and in the - render() method call getSceneNodeRenderPass() to find out the - current render pass and render only the corresponding parts of - the node. */ - ESNRP_AUTOMATIC =24, - - //! Solid scene nodes or special scene nodes without materials. - ESNRP_SOLID =8, - - //! Transparent scene nodes, drawn after solid nodes. They are sorted from back to front and drawn in that order. - ESNRP_TRANSPARENT =16, - - //! Transparent effect scene nodes, drawn after Transparent nodes. They are sorted from back to front and drawn in that order. - ESNRP_TRANSPARENT_EFFECT =32, - - //! Drawn after the transparent nodes, the time for drawing shadow volumes - ESNRP_SHADOW =64 - }; - - class IMesh; - class IMeshBuffer; - class IAnimatedMesh; - class IMeshCache; - class ISceneNode; - class ICameraSceneNode; - class IAnimatedMeshSceneNode; - class ISceneNodeAnimator; - class ISceneNodeAnimatorCollisionResponse; - class ILightSceneNode; - class IBillboardSceneNode; - class ITerrainSceneNode; - class IMeshSceneNode; - class IMeshLoader; - class ISceneCollisionManager; - class IParticleSystemSceneNode; - class IDummyTransformationSceneNode; - class ITriangleSelector; - class IMetaTriangleSelector; - class IMeshManipulator; - class ITextSceneNode; - class IBillboardTextSceneNode; - class IVolumeLightSceneNode; - class ISceneNodeFactory; - class ISceneNodeAnimatorFactory; - class ISceneUserDataSerializer; - class ILightManager; - - namespace quake3 - { - struct IShader; - } // end namespace quake3 - - //! The Scene Manager manages scene nodes, mesh recources, cameras and all the other stuff. - /** All Scene nodes can be created only here. There is a always growing - list of scene nodes for lots of purposes: Indoor rendering scene nodes - like the Octree (addOctTreeSceneNode()) or the terrain renderer - (addTerrainSceneNode()), different Camera scene nodes - (addCameraSceneNode(), addCameraSceneNodeMaya()), scene nodes for Light - (addLightSceneNode()), Billboards (addBillboardSceneNode()) and so on. - A scene node is a node in the hierachical scene graph. Every scene node - may have children, which are other scene nodes. Children move relative - the their parents position. If the parent of a node is not visible, its - children won't be visible, too. In this way, it is for example easily - possible to attach a light to a moving car or to place a walking - character on a moving platform on a moving ship. - The SceneManager is also able to load 3d mesh files of different - formats. Take a look at getMesh() to find out what formats are - supported. And if these formats are not enough use - addExternalMeshLoader() to add new formats to the engine. - */ - class ISceneManager : public virtual IReferenceCounted - { - public: - - //! Destructor - virtual ~ISceneManager() {} - - //! Get pointer to an animateable mesh. Loads the file if not loaded already. - /** - * If you want to remove a loaded mesh from the cache again, use removeMesh(). - * Currently there are the following mesh formats supported: - * <TABLE border="1" cellpadding="2" cellspacing="0"> - * <TR> - * <TD>Format</TD> - * <TD>Description</TD> - * </TR> - * <TR> - * <TD>3D Studio (.3ds)</TD> - * <TD>Loader for 3D-Studio files which lots of 3D packages - * are able to export. Only static meshes are currently - * supported by this importer. </TD> - * </TR> - * <TR> - * <TD>Bliz Basic B3D (.b3d)</TD> - * <TD>Loader for blitz basic files, developed by Mark - * Sibly, also supports animations.</TD> - * </TR> - * <TR> - * <TD>Cartography shop 4 (.csm)</TD> - * <TD>Cartography Shop is a modeling program for creating - * architecture and calculating lighting. Irrlicht can - * directly import .csm files thanks to the IrrCSM library - * created by Saurav Mohapatra which is now integrated - * directly in Irrlicht. If you are using this loader, - * please note that you'll have to set the path of the - * textures before loading .csm files. You can do this - * using - * SceneManager->getParameters()->setAttribute(scene::CSM_TEXTURE_PATH, - * "path/to/your/textures");</TD> - * </TR> - * <TR> - * <TD>COLLADA (.dae, .xml)</TD> - * <TD>COLLADA is an open Digital Asset Exchange Schema for - * the interactive 3D industry. There are exporters and - * importers for this format available for most of the - * big 3d packagesat http://collada.org. Irrlicht can - * import COLLADA files by using the - * ISceneManager::getMesh() method. COLLADA files need - * not contain only one single mesh but multiple meshes - * and a whole scene setup with lights, cameras and mesh - * instances, this loader can set up a scene as - * described by the COLLADA file instead of loading and - * returning one single mesh. By default, this loader - * behaves like the other loaders and does not create - * instances, but it can be switched into this mode by - * using - * SceneManager->getParameters()->setAttribute(COLLADA_CREATE_SCENE_INSTANCES, true); - * Created scene nodes will be named as the names of the - * nodes in the COLLADA file. The returned mesh is just - * a dummy object in this mode. Meshes included in the - * scene will be added into the scene manager with the - * following naming scheme: - * path/to/file/file.dea#meshname. The loading of such - * meshes is logged. Currently, this loader is able to - * create meshes (made of only polygons), lights, and - * cameras. Materials and animations are currently not - * supported but this will change with future releases. - * </TD> - * </TR> - * <TR> - * <TD>Delgine DeleD (.dmf)</TD> - * <TD>DeleD (delgine.com) is a 3D editor and level-editor - * combined into one and is specifically designed for 3D - * game-development. With this loader, it is possible to - * directly load all geometry is as well as textures and - * lightmaps from .dmf files. To set texture and - * material paths, see scene::DMF_USE_MATERIALS_DIRS and - * scene::DMF_TEXTURE_PATH. It is also possible to flip - * the alpha texture by setting - * scene::DMF_FLIP_ALPHA_TEXTURES to true and to set the - * material transparent reference value by setting - * scene::DMF_ALPHA_CHANNEL_REF to a float between 0 and - * 1. The loader is based on Salvatore Russo's .dmf - * loader, I just changed some parts of it. Thanks to - * Salvatore for his work and for allowing me to use his - * code in Irrlicht and put it under Irrlicht's license. - * For newer and more enchanced versions of the loader, - * take a look at delgine.com. - * </TD> - * </TR> - * <TR> - * <TD>DirectX (.x)</TD> - * <TD>Platform independent importer (so not D3D-only) for - * .x files. Most 3D packages can export these natively - * and there are several tools for them available, e.g. - * the Maya exporter included in the DX SDK. - * .x files can include skeletal animations and Irrlicht - * is able to play and display them. Currently, Irrlicht - * only supports uncompressed .x files.</TD> - * </TR> - * <TR> - * <TD>Maya (.obj)</TD> - * <TD>Most 3D software can create .obj files which contain - * static geometry without material data. The material - * files .mtl are also supported. This importer for - * Irrlicht can load them directly. </TD> - * </TR> - * <TR> - * <TD>Milkshape (.ms3d)</TD> - * <TD>.MS3D files contain models and sometimes skeletal - * animations from the Milkshape 3D modeling and animation - * software. This importer for Irrlicht can display and/or - * animate these files. </TD> - * </TR> - * <TR> - * <TD>My3D (.my3d)</TD> - * <TD>.my3D is a flexible 3D file format. The My3DTools - * contains plug-ins to export .my3D files from several - * 3D packages. With this built-in importer, Irrlicht - * can read and display those files directly. This - * loader was written by Zhuck Dimitry who also created - * the whole My3DTools package. If you are using this - * loader, please note that you can set the path of the - * textures before loading .my3d files. You can do this - * using - * SceneManager->getParameters()->setAttribute(scene::MY3D_TEXTURE_PATH, - * "path/to/your/textures"); - * </TD> - * </TR> - * <TR> - * <TD>OCT (.oct)</TD> - * <TD>The oct file format contains 3D geometry and - * lightmaps and can be loaded directly by Irrlicht. OCT - * files<br> can be created by FSRad, Paul Nette's - * radiosity processor or exported from Blender using - * OCTTools which can be found in the exporters/OCTTools - * directory of the SDK. Thanks to Murphy McCauley for - * creating all this.</TD> - * </TR> - * <TR> - * <TD>OGRE Meshes (.mesh)</TD> - * <TD>Ogre .mesh files contain 3D data for the OGRE 3D - * engine. Irrlicht can read and display them directly - * with this importer. To define materials for the mesh, - * copy a .material file named like the corresponding - * .mesh file where the .mesh file is. (For example - * ogrehead.material for ogrehead.mesh). Thanks to - * Christian Stehno who wrote and contributed this - * loader.</TD> - * </TR> - * <TR> - * <TD>Pulsar LMTools (.lmts)</TD> - * <TD>LMTools is a set of tools (Windows & Linux) for - * creating lightmaps. Irrlicht can directly read .lmts - * files thanks to<br> the importer created by Jonas - * Petersen. If you are using this loader, please note - * that you can set the path of the textures before - * loading .lmts files. You can do this using - * SceneManager->getParameters()->setAttribute(scene::LMTS_TEXTURE_PATH, - * "path/to/your/textures"); - * Notes for<br> this version of the loader:<br> - * - It does not recognise/support user data in the - * *.lmts files.<br> - * - The TGAs generated by LMTools don't work in - * Irrlicht for some reason (the textures are upside - * down). Opening and resaving them in a graphics app - * will solve the problem.</TD> - * </TR> - * <TR> - * <TD>Quake 3 levels (.bsp)</TD> - * <TD>Quake 3 is a popular game by IDSoftware, and .pk3 - * files contain .bsp files and textures/lightmaps - * describing huge prelighted levels. Irrlicht can read - * .pk3 and .bsp files directly and thus render Quake 3 - * levels directly. Written by Nikolaus Gebhardt - * enhanced by Dean P. Macri with the curved surfaces - * feature. </TD> - * </TR> - * <TR> - * <TD>Quake 2 models (.md2)</TD> - * <TD>Quake 2 models are characters with morph target - * animation. Irrlicht can read, display and animate - * them directly with this importer. </TD> - * </TR> - * </TABLE> - * - * To load and display a mesh quickly, just do this: - * \code - * SceneManager->addAnimatedMeshSceneNode( - * SceneManager->getMesh("yourmesh.3ds")); - * \endcode - * If you would like to implement and add your own file format loader to Irrlicht, - * see addExternalMeshLoader(). - * \param filename: Filename of the mesh to load. - * \return Null if failed, otherwise pointer to the mesh. - * This pointer should not be dropped. See IReferenceCounted::drop() for more information. - **/ - virtual IAnimatedMesh* getMesh(const io::path& filename) = 0; - - //! Get pointer to an animateable mesh. Loads the file if not loaded already. - /** Works just as getMesh(const char* filename). If you want to - remove a loaded mesh from the cache again, use removeMesh(). - \param file File handle of the mesh to load. - \return NULL if failed and pointer to the mesh if successful. - This pointer should not be dropped. See - IReferenceCounted::drop() for more information. */ - virtual IAnimatedMesh* getMesh(io::IReadFile* file) = 0; - - //! Get interface to the mesh cache which is shared beween all existing scene managers. - /** With this interface, it is possible to manually add new loaded - meshes (if ISceneManager::getMesh() is not sufficient), to remove them and to iterate - through already loaded meshes. */ - virtual IMeshCache* getMeshCache() = 0; - - //! Get the video driver. - /** \return Pointer to the video Driver. - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual video::IVideoDriver* getVideoDriver() = 0; - - //! Get the active GUIEnvironment - /** \return Pointer to the GUIEnvironment - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual gui::IGUIEnvironment* getGUIEnvironment() = 0; - - //! Get the active FileSystem - /** \return Pointer to the FileSystem - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual io::IFileSystem* getFileSystem() = 0; - - //! adds Volume Lighting Scene Node. - /** Example Usage: - scene::IVolumeLightSceneNode * n = smgr->addVolumeLightSceneNode(0, -1, - 32, 32, //Subdivide U/V - video::SColor(0, 180, 180, 180), //foot color - video::SColor(0, 0, 0, 0) //tail color - ); - if (n) - { - n->setScale(core::vector3df(46.0f, 45.0f, 46.0f)); - n->getMaterial(0).setTexture(0, smgr->getVideoDriver()->getTexture("lightFalloff.png")); - } - \return Pointer to the volumeLight if successful, otherwise NULL. - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual IVolumeLightSceneNode* addVolumeLightSceneNode(ISceneNode* parent=0, s32 id=-1, - const u32 subdivU = 32, const u32 subdivV = 32, - const video::SColor foot = video::SColor(51, 0, 230, 180), - const video::SColor tail = video::SColor(0, 0, 0, 0), - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)) = 0; - - //! Adds a cube scene node - /** \param size: Size of the cube, uniformly in each dimension. - \param parent: Parent of the scene node. Can be 0 if no parent. - \param id: Id of the node. This id can be used to identify the scene node. - \param position: Position of the space relative to its parent - where the scene node will be placed. - \param rotation: Initital rotation of the scene node. - \param scale: Initial scale of the scene node. - \return Pointer to the created test scene node. This - pointer should not be dropped. See IReferenceCounted::drop() - for more information. */ - virtual IMeshSceneNode* addCubeSceneNode(f32 size=10.0f, ISceneNode* parent=0, s32 id=-1, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)) = 0; - - //! Adds a sphere scene node of the given radius and detail - /** \param radius: Radius of the sphere. - \param polyCount: Polycount of the sphere, i.e. subdivision in - horizontal and vertical direction. - \param parent: Parent of the scene node. Can be 0 if no parent. - \param id: Id of the node. This id can be used to identify the scene node. - \param position: Position of the space relative to its parent - where the scene node will be placed. - \param rotation: Initital rotation of the scene node. - \param scale: Initial scale of the scene node. - \return Pointer to the created test scene node. This - pointer should not be dropped. See IReferenceCounted::drop() - for more information. */ - virtual IMeshSceneNode* addSphereSceneNode(f32 radius=5.0f, s32 polyCount=16, - ISceneNode* parent=0, s32 id=-1, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)) = 0; - - //! Adds a scene node for rendering an animated mesh model. - /** \param mesh: Pointer to the loaded animated mesh to be displayed. - \param parent: Parent of the scene node. Can be NULL if no parent. - \param id: Id of the node. This id can be used to identify the scene node. - \param position: Position of the space relative to its parent where the - scene node will be placed. - \param rotation: Initital rotation of the scene node. - \param scale: Initial scale of the scene node. - \param alsoAddIfMeshPointerZero: Add the scene node even if a 0 pointer is passed. - \return Pointer to the created scene node. - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual IAnimatedMeshSceneNode* addAnimatedMeshSceneNode(IAnimatedMesh* mesh, - ISceneNode* parent=0, s32 id=-1, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f), - bool alsoAddIfMeshPointerZero=false) = 0; - - //! Adds a scene node for rendering a static mesh. - /** \param mesh: Pointer to the loaded static mesh to be displayed. - \param parent: Parent of the scene node. Can be NULL if no parent. - \param id: Id of the node. This id can be used to identify the scene node. - \param position: Position of the space relative to its parent where the - scene node will be placed. - \param rotation: Initital rotation of the scene node. - \param scale: Initial scale of the scene node. - \param alsoAddIfMeshPointerZero: Add the scene node even if a 0 pointer is passed. - \return Pointer to the created scene node. - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual IMeshSceneNode* addMeshSceneNode(IMesh* mesh, ISceneNode* parent=0, s32 id=-1, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f), - bool alsoAddIfMeshPointerZero=false) = 0; - - //! Adds a scene node for rendering a animated water surface mesh. - /** Looks really good when the Material type EMT_TRANSPARENT_REFLECTION - is used. - \param waveHeight: Height of the water waves. - \param waveSpeed: Speed of the water waves. - \param waveLength: Lenght of a water wave. - \param mesh: Pointer to the loaded static mesh to be displayed with water waves on it. - \param parent: Parent of the scene node. Can be NULL if no parent. - \param id: Id of the node. This id can be used to identify the scene node. - \param position: Position of the space relative to its parent where the - scene node will be placed. - \param rotation: Initital rotation of the scene node. - \param scale: Initial scale of the scene node. - \return Pointer to the created scene node. - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual ISceneNode* addWaterSurfaceSceneNode(IMesh* mesh, - f32 waveHeight=2.0f, f32 waveSpeed=300.0f, f32 waveLength=10.0f, - ISceneNode* parent=0, s32 id=-1, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)) = 0; - - - //! Adds a scene node for rendering using a octtree to the scene graph. - /** This a good method for rendering - scenes with lots of geometry. The Octree is built on the fly from the mesh. - \param mesh: The mesh containing all geometry from which the octtree will be build. - If this animated mesh has more than one frames in it, the first frame is taken. - \param parent: Parent node of the octtree node. - \param id: id of the node. This id can be used to identify the node. - \param minimalPolysPerNode: Specifies the minimal polygons contained a octree node. - If a node gets less polys than this value it will not be split into - smaller nodes. - \param alsoAddIfMeshPointerZero: Add the scene node even if a 0 pointer is passed. - \return Pointer to the OctTree if successful, otherwise 0. - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual IMeshSceneNode* addOctTreeSceneNode(IAnimatedMesh* mesh, ISceneNode* parent=0, - s32 id=-1, s32 minimalPolysPerNode=512, bool alsoAddIfMeshPointerZero=false) = 0; - - //! Adds a scene node for rendering using a octtree to the scene graph. - /** This a good method for rendering scenes with lots of - geometry. The Octree is built on the fly from the mesh, much - faster then a bsp tree. - \param mesh: The mesh containing all geometry from which the octtree will be build. - \param parent: Parent node of the octtree node. - \param id: id of the node. This id can be used to identify the node. - \param minimalPolysPerNode: Specifies the minimal polygons contained a octree node. - If a node gets less polys than this value it will not be split into - smaller nodes. - \param alsoAddIfMeshPointerZero: Add the scene node even if a 0 pointer is passed. - \return Pointer to the octtree if successful, otherwise 0. - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual IMeshSceneNode* addOctTreeSceneNode(IMesh* mesh, ISceneNode* parent=0, - s32 id=-1, s32 minimalPolysPerNode=256, bool alsoAddIfMeshPointerZero=false) = 0; - - //! Adds a camera scene node to the scene graph and sets it as active camera. - /** This camera does not react on user input like for example the one created with - addCameraSceneNodeFPS(). If you want to move or animate it, use animators or the - ISceneNode::setPosition(), ICameraSceneNode::setTarget() etc methods. - By default, a camera's look at position (set with setTarget()) and its scene node - rotation (set with setRotation()) are independent. If you want to be able to - control the direction that the camera looks by using setRotation() then call - ICameraSceneNode::bindTargetAndRotation(true) on it. - \param position: Position of the space relative to its parent where the camera will be placed. - \param lookat: Position where the camera will look at. Also known as target. - \param parent: Parent scene node of the camera. Can be null. If the parent moves, - the camera will move too. - \param id: id of the camera. This id can be used to identify the camera. - \return Pointer to interface to camera if successful, otherwise 0. - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual ICameraSceneNode* addCameraSceneNode(ISceneNode* parent = 0, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& lookat = core::vector3df(0,0,100), s32 id=-1) = 0; - - //! Adds a maya style user controlled camera scene node to the scene graph. - /** This is a standard camera with an animator that provides mouse control similar - to camera in the 3D Software Maya by Alias Wavefront. - \param parent: Parent scene node of the camera. Can be null. - \param rotateSpeed: Rotation speed of the camera. - \param zoomSpeed: Zoom speed of the camera. - \param translationSpeed: TranslationSpeed of the camera. - \param id: id of the camera. This id can be used to identify the camera. - \return Returns a pointer to the interface of the camera if successful, otherwise 0. - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual ICameraSceneNode* addCameraSceneNodeMaya(ISceneNode* parent = 0, - f32 rotateSpeed = -1500.0f, f32 zoomSpeed = 200.0f, - f32 translationSpeed = 1500.0f, s32 id=-1) = 0; - - //! Adds a camera scene node with an animator which provides mouse and keyboard control appropriate for first person shooters (FPS). - /** This FPS camera is intended to provide a demonstration of a - camera that behaves like a typical First Person Shooter. It is - useful for simple demos and prototyping but is not intended to - provide a full solution for a production quality game. It binds - the camera scene node rotation to the look-at target; @see - ICameraSceneNode::bindTargetAndRotation(). With this camera, - you look with the mouse, and move with cursor keys. If you want - to change the key layout, you can specify your own keymap. For - example to make the camera be controlled by the cursor keys AND - the keys W,A,S, and D, do something like this: - \code - SKeyMap keyMap[8]; - keyMap[0].Action = EKA_MOVE_FORWARD; - keyMap[0].KeyCode = KEY_UP; - keyMap[1].Action = EKA_MOVE_FORWARD; - keyMap[1].KeyCode = KEY_KEY_W; - - keyMap[2].Action = EKA_MOVE_BACKWARD; - keyMap[2].KeyCode = KEY_DOWN; - keyMap[3].Action = EKA_MOVE_BACKWARD; - keyMap[3].KeyCode = KEY_KEY_S; - - keyMap[4].Action = EKA_STRAFE_LEFT; - keyMap[4].KeyCode = KEY_LEFT; - keyMap[5].Action = EKA_STRAFE_LEFT; - keyMap[5].KeyCode = KEY_KEY_A; - - keyMap[6].Action = EKA_STRAFE_RIGHT; - keyMap[6].KeyCode = KEY_RIGHT; - keyMap[7].Action = EKA_STRAFE_RIGHT; - keyMap[7].KeyCode = KEY_KEY_D; - - camera = sceneManager->addCameraSceneNodeFPS(0, 100, 500, -1, keyMap, 8); - \endcode - \param parent: Parent scene node of the camera. Can be null. - \param rotateSpeed: Speed in degress with which the camera is - rotated. This can be done only with the mouse. - \param moveSpeed: Speed in units per millisecond with which - the camera is moved. Movement is done with the cursor keys. - \param id: id of the camera. This id can be used to identify - the camera. - \param keyMapArray: Optional pointer to an array of a keymap, - specifying what keys should be used to move the camera. If this - is null, the default keymap is used. You can define actions - more then one time in the array, to bind multiple keys to the - same action. - \param keyMapSize: Amount of items in the keymap array. - \param noVerticalMovement: Setting this to true makes the - camera only move within a horizontal plane, and disables - vertical movement as known from most ego shooters. Default is - 'false', with which it is possible to fly around in space, if - no gravity is there. - \param jumpSpeed: Speed with which the camera is moved when - jumping. - \param invertMouse: Setting this to true makes the camera look - up when the mouse is moved down and down when the mouse is - moved up, the default is 'false' which means it will follow the - movement of the mouse cursor. - \return Pointer to the interface of the camera if successful, - otherwise 0. This pointer should not be dropped. See - IReferenceCounted::drop() for more information. */ - virtual ICameraSceneNode* addCameraSceneNodeFPS(ISceneNode* parent = 0, - f32 rotateSpeed = 100.0f, f32 moveSpeed = 0.5f, s32 id=-1, - SKeyMap* keyMapArray=0, s32 keyMapSize=0, bool noVerticalMovement=false, - f32 jumpSpeed = 0.f, bool invertMouse=false) = 0; - - //! Adds a dynamic light scene node to the scene graph. - /** The light will cast dynamic light on all - other scene nodes in the scene, which have the material flag video::MTF_LIGHTING - turned on. (This is the default setting in most scene nodes). - \param parent: Parent scene node of the light. Can be null. If the parent moves, - the light will move too. - \param position: Position of the space relative to its parent where the light will be placed. - \param color: Diffuse color of the light. Ambient or Specular colors can be set manually with - the ILightSceneNode::getLightData() method. - \param radius: Radius of the light. - \param id: id of the node. This id can be used to identify the node. - \return Pointer to the interface of the light if successful, otherwise NULL. - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual ILightSceneNode* addLightSceneNode(ISceneNode* parent = 0, - const core::vector3df& position = core::vector3df(0,0,0), - video::SColorf color = video::SColorf(1.0f, 1.0f, 1.0f), - f32 radius=100.0f, s32 id=-1) = 0; - - //! Adds a billboard scene node to the scene graph. - /** A billboard is like a 3d sprite: A 2d element, - which always looks to the camera. It is usually used for things like explosions, fire, - lensflares and things like that. - \param parent: Parent scene node of the billboard. Can be null. If the parent moves, - the billboard will move too. - \param position: Position of the space relative to its parent - where the billboard will be placed. - \param size: Size of the billboard. This size is 2 dimensional because a billboard only has - width and height. - \param id: An id of the node. This id can be used to identify the node. - \param colorTop: The color of the vertices at the top of the billboard (default: white). - \param colorBottom: The color of the vertices at the bottom of the billboard (default: white). - \return Pointer to the billboard if successful, otherwise NULL. - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual IBillboardSceneNode* addBillboardSceneNode(ISceneNode* parent = 0, - const core::dimension2d<f32>& size = core::dimension2d<f32>(10.0f, 10.0f), - const core::vector3df& position = core::vector3df(0,0,0), s32 id=-1, - video::SColor colorTop = 0xFFFFFFFF, video::SColor colorBottom = 0xFFFFFFFF) = 0; - - //! Adds a skybox scene node to the scene graph. - /** A skybox is a big cube with 6 textures on it and - is drawn around the camera position. - \param top: Texture for the top plane of the box. - \param bottom: Texture for the bottom plane of the box. - \param left: Texture for the left plane of the box. - \param right: Texture for the right plane of the box. - \param front: Texture for the front plane of the box. - \param back: Texture for the back plane of the box. - \param parent: Parent scene node of the skybox. A skybox usually has no parent, - so this should be null. Note: If a parent is set to the skybox, the box will not - change how it is drawn. - \param id: An id of the node. This id can be used to identify the node. - \return Pointer to the sky box if successful, otherwise NULL. - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual ISceneNode* addSkyBoxSceneNode(video::ITexture* top, video::ITexture* bottom, - video::ITexture* left, video::ITexture* right, video::ITexture* front, - video::ITexture* back, ISceneNode* parent = 0, s32 id=-1) = 0; - - //! Adds a skydome scene node to the scene graph. - /** A skydome is a large (half-) sphere with a panoramic texture - on the inside and is drawn around the camera position. - \param texture: Texture for the dome. - \param horiRes: Number of vertices of a horizontal layer of the sphere. - \param vertRes: Number of vertices of a vertical layer of the sphere. - \param texturePercentage: How much of the height of the - texture is used. Should be between 0 and 1. - \param spherePercentage: How much of the sphere is drawn. - Value should be between 0 and 2, where 1 is an exact - half-sphere and 2 is a full sphere. - \param parent: Parent scene node of the dome. A dome usually has no parent, - so this should be null. Note: If a parent is set, the dome will not - change how it is drawn. - \param id: An id of the node. This id can be used to identify the node. - \return Pointer to the sky dome if successful, otherwise NULL. - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual ISceneNode* addSkyDomeSceneNode(video::ITexture* texture, - u32 horiRes=16, u32 vertRes=8, - f32 texturePercentage=0.9, f32 spherePercentage=2.0,f32 radius = 1000.f, - ISceneNode* parent=0, s32 id=-1) = 0; - - //! Adds a particle system scene node to the scene graph. - /** \param withDefaultEmitter: Creates a default working point emitter - which emitts some particles. Set this to true to see a particle system - in action. If set to false, you'll have to set the emitter you want by - calling IParticleSystemSceneNode::setEmitter(). - \param parent: Parent of the scene node. Can be NULL if no parent. - \param id: Id of the node. This id can be used to identify the scene node. - \param position: Position of the space relative to its parent where the - scene node will be placed. - \param rotation: Initital rotation of the scene node. - \param scale: Initial scale of the scene node. - \return Pointer to the created scene node. - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual IParticleSystemSceneNode* addParticleSystemSceneNode( - bool withDefaultEmitter=true, ISceneNode* parent=0, s32 id=-1, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)) = 0; - - //! Adds a terrain scene node to the scene graph. - /** This node implements is a simple terrain renderer which uses - a technique known as geo mip mapping - for reducing the detail of triangle blocks which are far away. - The code for the TerrainSceneNode is based on the terrain - renderer by Soconne and the GeoMipMapSceneNode developed by - Spintz. They made their code available for Irrlicht and allowed - it to be distributed under this licence. I only modified some - parts. A lot of thanks go to them. - - This scene node is capable of loading terrains and updating - the indices at runtime to enable viewing very large terrains - very quickly. It uses a CLOD (Continuous Level of Detail) - algorithm which updates the indices for each patch based on - a LOD (Level of Detail) which is determined based on a patch's - distance from the camera. - - The patch size of the terrain must always be a size of 2^N+1, - i.e. 8+1(9), 16+1(17), etc. - The MaxLOD available is directly dependent on the patch size - of the terrain. LOD 0 contains all of the indices to draw all - the triangles at the max detail for a patch. As each LOD goes - up by 1 the step taken, in generating indices increases by - -2^LOD, so for LOD 1, the step taken is 2, for LOD 2, the step - taken is 4, LOD 3 - 8, etc. The step can be no larger than - the size of the patch, so having a LOD of 8, with a patch size - of 17, is asking the algoritm to generate indices every 2^8 ( - 256 ) vertices, which is not possible with a patch size of 17. - The maximum LOD for a patch size of 17 is 2^4 ( 16 ). So, - with a MaxLOD of 5, you'll have LOD 0 ( full detail ), LOD 1 ( - every 2 vertices ), LOD 2 ( every 4 vertices ), LOD 3 ( every - 8 vertices ) and LOD 4 ( every 16 vertices ). - \param heightMapFileName: The name of the file on disk, to read vertex data from. This should - be a gray scale bitmap. - \param parent: Parent of the scene node. Can be 0 if no parent. - \param id: Id of the node. This id can be used to identify the scene node. - \param position: The absolute position of this node. - \param rotation: The absolute rotation of this node. ( NOT YET IMPLEMENTED ) - \param scale: The scale factor for the terrain. If you're - using a heightmap of size 129x129 and would like your terrain - to be 12900x12900 in game units, then use a scale factor of ( - core::vector ( 100.0f, 100.0f, 100.0f ). If you use a Y - scaling factor of 0.0f, then your terrain will be flat. - \param vertexColor: The default color of all the vertices. If no texture is associated - with the scene node, then all vertices will be this color. Defaults to white. - \param maxLOD: The maximum LOD (level of detail) for the node. Only change if you - know what you are doing, this might lead to strange behaviour. - \param patchSize: patch size of the terrain. Only change if you - know what you are doing, this might lead to strange behaviour. - \param smoothFactor: The number of times the vertices are smoothed. - \param addAlsoIfHeightmapEmpty: Add terrain node even with empty heightmap. - \return Pointer to the created scene node. Can be null - if the terrain could not be created, for example because the - heightmap could not be loaded. The returned pointer should - not be dropped. See IReferenceCounted::drop() for more - information. */ - virtual ITerrainSceneNode* addTerrainSceneNode( - const io::path& heightMapFileName, - ISceneNode* parent=0, s32 id=-1, - const core::vector3df& position = core::vector3df(0.0f,0.0f,0.0f), - const core::vector3df& rotation = core::vector3df(0.0f,0.0f,0.0f), - const core::vector3df& scale = core::vector3df(1.0f,1.0f,1.0f), - video::SColor vertexColor = video::SColor(255,255,255,255), - s32 maxLOD=5, E_TERRAIN_PATCH_SIZE patchSize=ETPS_17, s32 smoothFactor=0, - bool addAlsoIfHeightmapEmpty = false) = 0; - - //! Adds a terrain scene node to the scene graph. - /** Just like the other addTerrainSceneNode() method, but takes an IReadFile - pointer as parameter for the heightmap. For more informations take a look - at the other function. - \param heightMapFile: The file handle to read vertex data from. This should - be a gray scale bitmap. - \param parent: Parent of the scene node. Can be 0 if no parent. - \param id: Id of the node. This id can be used to identify the scene node. - \param position: The absolute position of this node. - \param rotation: The absolute rotation of this node. ( NOT YET IMPLEMENTED ) - \param scale: The scale factor for the terrain. If you're - using a heightmap of size 129x129 and would like your terrain - to be 12900x12900 in game units, then use a scale factor of ( - core::vector ( 100.0f, 100.0f, 100.0f ). If you use a Y - scaling factor of 0.0f, then your terrain will be flat. - \param vertexColor: The default color of all the vertices. If no texture is associated - with the scene node, then all vertices will be this color. Defaults to white. - \param maxLOD: The maximum LOD (level of detail) for the node. Only change if you - know what you are doing, this might lead to strange behaviour. - \param patchSize: patch size of the terrain. Only change if you - know what you are doing, this might lead to strange behaviour. - \param smoothFactor: The number of times the vertices are smoothed. - \param addAlsoIfHeightmapEmpty: Add terrain node even with empty heightmap. - \return Pointer to the created scene node. Can be null - if the terrain could not be created, for example because the - heightmap could not be loaded. The returned pointer should - not be dropped. See IReferenceCounted::drop() for more - information. */ - virtual ITerrainSceneNode* addTerrainSceneNode( - io::IReadFile* heightMapFile, - ISceneNode* parent=0, s32 id=-1, - const core::vector3df& position = core::vector3df(0.0f,0.0f,0.0f), - const core::vector3df& rotation = core::vector3df(0.0f,0.0f,0.0f), - const core::vector3df& scale = core::vector3df(1.0f,1.0f,1.0f), - video::SColor vertexColor = video::SColor(255,255,255,255), - s32 maxLOD=5, E_TERRAIN_PATCH_SIZE patchSize=ETPS_17, s32 smoothFactor=0, - bool addAlsoIfHeightmapEmpty = false) = 0; - - //! Adds a quake3 scene node to the scene graph. - /** A Quake3 Scene renders multiple meshes for a specific HighLanguage Shader (Quake3 Style ) - \return Pointer to the quake3 scene node if successful, otherwise NULL. - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual IMeshSceneNode* addQuake3SceneNode(IMeshBuffer* meshBuffer, const quake3::IShader * shader, - ISceneNode* parent=0, s32 id=-1 - ) = 0; - - - //! Adds an empty scene node to the scene graph. - /** Can be used for doing advanced transformations - or structuring the scene graph. - \return Pointer to the created scene node. - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual ISceneNode* addEmptySceneNode(ISceneNode* parent=0, s32 id=-1) = 0; - - //! Adds a dummy transformation scene node to the scene graph. - /** This scene node does not render itself, and does not respond to set/getPosition, - set/getRotation and set/getScale. Its just a simple scene node that takes a - matrix as relative transformation, making it possible to insert any transformation - anywhere into the scene graph. - \return Pointer to the created scene node. - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual IDummyTransformationSceneNode* addDummyTransformationSceneNode( - ISceneNode* parent=0, s32 id=-1) = 0; - - //! Adds a text scene node, which is able to display 2d text at a position in three dimensional space - virtual ITextSceneNode* addTextSceneNode(gui::IGUIFont* font, const wchar_t* text, - video::SColor color=video::SColor(100,255,255,255), - ISceneNode* parent = 0, const core::vector3df& position = core::vector3df(0,0,0), - s32 id=-1) = 0; - - //! Adds a text scene node, which uses billboards. The node, and the text on it, will scale with distance. - /** - \param font The font to use on the billboard. Pass 0 to use the GUI environment's default font. - \param text The text to display on the billboard. - \param parent The billboard's parent. Pass 0 to use the root scene node. - \param size The billboard's width and height. - \param position The billboards position relative to its parent. - \param id: An id of the node. This id can be used to identify the node. - \param colorTop: The color of the vertices at the top of the billboard (default: white). - \param colorBottom: The color of the vertices at the bottom of the billboard (default: white). - \return Pointer to the billboard if successful, otherwise NULL. - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual IBillboardTextSceneNode* addBillboardTextSceneNode( gui::IGUIFont* font, const wchar_t* text, - ISceneNode* parent = 0, - const core::dimension2d<f32>& size = core::dimension2d<f32>(10.0f, 10.0f), - const core::vector3df& position = core::vector3df(0,0,0), s32 id=-1, - video::SColor colorTop = 0xFFFFFFFF, video::SColor colorBottom = 0xFFFFFFFF) = 0; - - //! Adds a Hill Plane mesh to the mesh pool. - /** The mesh is generated on the fly - and looks like a plane with some hills on it. It is uses mostly for quick - tests of the engine only. You can specify how many hills there should be - on the plane and how high they should be. Also you must specify a name for - the mesh, because the mesh is added to the mesh pool, and can be retrieved - again using ISceneManager::getMesh() with the name as parameter. - \param name: The name of this mesh which must be specified in order - to be able to retrieve the mesh later with ISceneManager::getMesh(). - \param tileSize: Size of a tile of the mesh. (10.0f, 10.0f) would be a - good value to start, for example. - \param tileCount: Specifies how much tiles there will be. If you specifiy - for example that a tile has the size (10.0f, 10.0f) and the tileCount is - (10,10), than you get a field of 100 tiles which has the dimension 100.0fx100.0f. - \param material: Material of the hill mesh. - \param hillHeight: Height of the hills. If you specify a negative value - you will get holes instead of hills. If the height is 0, no hills will be - created. - \param countHills: Amount of hills on the plane. There will be countHills.X - hills along the X axis and countHills.Y along the Y axis. So in total there - will be countHills.X * countHills.Y hills. - \param textureRepeatCount: Defines how often the texture will be repeated in - x and y direction. - return Null if the creation failed. The reason could be that you - specified some invalid parameters or that a mesh with that name already - exists. If successful, a pointer to the mesh is returned. - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual IAnimatedMesh* addHillPlaneMesh(const io::path& name, - const core::dimension2d<f32>& tileSize, const core::dimension2d<u32>& tileCount, - video::SMaterial* material = 0, f32 hillHeight = 0.0f, - const core::dimension2d<f32>& countHills = core::dimension2d<f32>(0.0f, 0.0f), - const core::dimension2d<f32>& textureRepeatCount = core::dimension2d<f32>(1.0f, 1.0f)) = 0; - - //! Adds a static terrain mesh to the mesh pool. - /** The mesh is generated on the fly - from a texture file and a height map file. Both files may be huge - (8000x8000 pixels would be no problem) because the generator splits the - files into smaller textures if necessary. - You must specify a name for the mesh, because the mesh is added to the mesh pool, - and can be retrieved again using ISceneManager::getMesh() with the name as parameter. - \param meshname: The name of this mesh which must be specified in order - to be able to retrieve the mesh later with ISceneManager::getMesh(). - \param texture: Texture for the terrain. Please note that this is not a - hardware texture as usual (ITexture), but an IImage software texture. - You can load this texture with IVideoDriver::createImageFromFile(). - \param heightmap: A grayscaled heightmap image. Like the texture, - it can be created with IVideoDriver::createImageFromFile(). The amount - of triangles created depends on the size of this texture, so use a small - heightmap to increase rendering speed. - \param stretchSize: Parameter defining how big a is pixel on the heightmap. - \param maxHeight: Defines how high a white pixel on the heighmap is. - \param defaultVertexBlockSize: Defines the initial dimension between vertices. - \return Null if the creation failed. The reason could be that you - specified some invalid parameters, that a mesh with that name already - exists, or that a texture could not be found. If successful, a pointer to the mesh is returned. - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual IAnimatedMesh* addTerrainMesh(const io::path& meshname, - video::IImage* texture, video::IImage* heightmap, - const core::dimension2d<f32>& stretchSize = core::dimension2d<f32>(10.0f,10.0f), - f32 maxHeight=200.0f, - const core::dimension2d<u32>& defaultVertexBlockSize = core::dimension2d<u32>(64,64)) = 0; - - //! add a static arrow mesh to the meshpool - /** \param name Name of the mesh - \param vtxColor0 color of the cylinder - \param vtxColor1 color of the cone - \param tesselationCylinder Number of quads the cylinder side consists of - \param tesselationCone Number of triangles the cone's roof consits of - \param height Total height of the arrow - \param cylinderHeight Total height of the cylinder, should be lesser than total height - \param width0 Diameter of the cylinder - \param width1 Diameter of the cone's base, should be not smaller than the cylinder's diameter - \return Pointer to the arrow mesh if successful, otherwise 0. - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual IAnimatedMesh* addArrowMesh(const io::path& name, - video::SColor vtxColor0=0xFFFFFFFF, - video::SColor vtxColor1=0xFFFFFFFF, - u32 tesselationCylinder=4, u32 tesselationCone=8, - f32 height=1.f, f32 cylinderHeight=0.6f, - f32 width0=0.05f, f32 width1=0.3f) = 0; - - //! add a static sphere mesh to the meshpool - /** \param name Name of the mesh - \param radius Radius of the sphere - \param polyCountX Number of quads used for the horizontal tiling - \param polyCountY Number of quads used for the vertical tiling - \return Pointer to the sphere mesh if successful, otherwise 0. - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual IAnimatedMesh* addSphereMesh(const io::path& name, - f32 radius=5.f, u32 polyCountX = 16, - u32 polyCountY = 16) = 0; - - //! Add a volume light mesh to the meshpool - /** \param name Name of the mesh - \return Pointer to the volume light mesh if successful, otherwise 0. - This pointer should not be dropped. See IReferenceCounted::drop() for more information. - */ - virtual IAnimatedMesh* addVolumeLightMesh(const io::path& name, - const u32 SubdivideU = 32, const u32 SubdivideV = 32, - const video::SColor FootColor = video::SColor(51, 0, 230, 180), - const video::SColor TailColor = video::SColor(0, 0, 0, 0)) = 0; - - //! Gets the root scene node. - /** This is the scene node which is parent - of all scene nodes. The root scene node is a special scene node which - only exists to manage all scene nodes. It will not be rendered and cannot - be removed from the scene. - \return Pointer to the root scene node. - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual ISceneNode* getRootSceneNode() = 0; - - //! Get the first scene node with the specified id. - /** \param id: The id to search for - \param start: Scene node to start from. All children of this scene - node are searched. If null is specified, the root scene node is - taken. - \return Pointer to the first scene node with this id, - and null if no scene node could be found. - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual ISceneNode* getSceneNodeFromId(s32 id, ISceneNode* start=0) = 0; - - //! Get the first scene node with the specified name. - /** \param name: The name to search for - \param start: Scene node to start from. All children of this scene - node are searched. If null is specified, the root scene node is - taken. - \return Pointer to the first scene node with this id, - and null if no scene node could be found. - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual ISceneNode* getSceneNodeFromName(const c8* name, ISceneNode* start=0) = 0; - - //! Get the first scene node with the specified type. - /** \param type: The type to search for - \param start: Scene node to start from. All children of this scene - node are searched. If null is specified, the root scene node is - taken. - \return Pointer to the first scene node with this type, - and null if no scene node could be found. - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual ISceneNode* getSceneNodeFromType(scene::ESCENE_NODE_TYPE type, ISceneNode* start=0) = 0; - - //! Get scene nodes by type. - /** \param type: Type of scene node to find (ESNT_ANY will return all child nodes). - \param outNodes: array to be filled with results. - \param start: Scene node to start from. All children of this scene - node are searched. If null is specified, the root scene node is - taken. */ - virtual void getSceneNodesFromType(ESCENE_NODE_TYPE type, - core::array<scene::ISceneNode*>& outNodes, - ISceneNode* start=0) = 0; - - //! Get the current active camera. - /** \return The active camera is returned. Note that this can - be NULL, if there was no camera created yet. - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual ICameraSceneNode* getActiveCamera() const =0; - - //! Sets the currently active camera. - /** The previous active camera will be deactivated. - \param camera: The new camera which should be active. */ - virtual void setActiveCamera(ICameraSceneNode* camera) = 0; - - //! Sets the color of stencil buffers shadows drawn by the scene manager. - virtual void setShadowColor(video::SColor color = video::SColor(150,0,0,0)) = 0; - - //! Get the current color of shadows. - virtual video::SColor getShadowColor() const = 0; - - //! Registers a node for rendering it at a specific time. - /** This method should only be used by SceneNodes when they get a - ISceneNode::OnRegisterSceneNode() call. - \param node: Node to register for drawing. Usually scene nodes would set 'this' - as parameter here because they want to be drawn. - \param pass: Specifies when the node wants to be drawn in relation to the other nodes. - For example, if the node is a shadow, it usually wants to be drawn after all other nodes - and will use ESNRP_SHADOW for this. See scene::E_SCENE_NODE_RENDER_PASS for details. - \return scene will be rendered ( passed culling ) */ - virtual u32 registerNodeForRendering(ISceneNode* node, - E_SCENE_NODE_RENDER_PASS pass = ESNRP_AUTOMATIC) = 0; - - //! Draws all the scene nodes. - /** This can only be invoked between - IVideoDriver::beginScene() and IVideoDriver::endScene(). Please note that - the scene is not only drawn when calling this, but also animated - by existing scene node animators, culling of scene nodes is done, etc. */ - virtual void drawAll() = 0; - - //! Creates a rotation animator, which rotates the attached scene node around itself. - /** \param rotationSpeed Specifies the speed of the animation in degree per 10 milliseconds. - \return The animator. Attach it to a scene node with ISceneNode::addAnimator() - and the animator will animate it. - If you no longer need the animator, you should call ISceneNodeAnimator::drop(). - See IReferenceCounted::drop() for more information. */ - virtual ISceneNodeAnimator* createRotationAnimator(const core::vector3df& rotationSpeed) = 0; - - //! Creates a fly circle animator, which lets the attached scene node fly around a center. - /** \param center: Center of the circle. - \param radius: Radius of the circle. - \param speed: The orbital speed, in radians per millisecond. - \param direction: Specifies the upvector used for alignment of the mesh. - \param startPosition: The position on the circle where the animator will - begin. Value is in multiples of a circle, i.e. 0.5 is half way around. (phase) - \param radiusEllipsoid: if radiusEllipsoid != 0 then radius2 froms a ellipsoid - begin. Value is in multiples of a circle, i.e. 0.5 is half way around. (phase) - \return The animator. Attach it to a scene node with ISceneNode::addAnimator() - and the animator will animate it. - If you no longer need the animator, you should call ISceneNodeAnimator::drop(). - See IReferenceCounted::drop() for more information. */ - virtual ISceneNodeAnimator* createFlyCircleAnimator( - const core::vector3df& center=core::vector3df(0.f,0.f,0.f), - f32 radius=100.f, f32 speed=0.001f, - const core::vector3df& direction=core::vector3df(0.f, 1.f, 0.f), - f32 startPosition = 0.f, - f32 radiusEllipsoid = 0.f) = 0; - - //! Creates a fly straight animator, which lets the attached scene node fly or move along a line between two points. - /** \param startPoint: Start point of the line. - \param endPoint: End point of the line. - \param timeForWay: Time in milli seconds how long the node should need to - move from the start point to the end point. - \param loop: If set to false, the node stops when the end point is reached. - If loop is true, the node begins again at the start. - \return The animator. Attach it to a scene node with ISceneNode::addAnimator() - and the animator will animate it. - If you no longer need the animator, you should call ISceneNodeAnimator::drop(). - See IReferenceCounted::drop() for more information. */ - virtual ISceneNodeAnimator* createFlyStraightAnimator(const core::vector3df& startPoint, - const core::vector3df& endPoint, u32 timeForWay, bool loop=false, bool pingpong = false) = 0; - - //! Creates a texture animator, which switches the textures of the target scene node based on a list of textures. - /** \param textures: List of textures to use. - \param timePerFrame: Time in milliseconds, how long any texture in the list - should be visible. - \param loop: If set to to false, the last texture remains set, and the animation - stops. If set to true, the animation restarts with the first texture. - \return The animator. Attach it to a scene node with ISceneNode::addAnimator() - and the animator will animate it. - If you no longer need the animator, you should call ISceneNodeAnimator::drop(). - See IReferenceCounted::drop() for more information. */ - virtual ISceneNodeAnimator* createTextureAnimator(const core::array<video::ITexture*>& textures, - s32 timePerFrame, bool loop=true) = 0; - - //! Creates a scene node animator, which deletes the scene node after some time automatically. - /** \param timeMs: Time in milliseconds, after when the node will be deleted. - \return The animator. Attach it to a scene node with ISceneNode::addAnimator() - and the animator will animate it. - If you no longer need the animator, you should call ISceneNodeAnimator::drop(). - See IReferenceCounted::drop() for more information. */ - virtual ISceneNodeAnimator* createDeleteAnimator(u32 timeMs) = 0; - - //! Creates a special scene node animator for doing automatic collision detection and response. - /** See ISceneNodeAnimatorCollisionResponse for details. - \param world: Triangle selector holding all triangles of the world with which - the scene node may collide. You can create a triangle selector with - ISceneManager::createTriangleSelector(); - \param sceneNode: SceneNode which should be manipulated. After you added this animator - to the scene node, the scene node will not be able to move through walls and is - affected by gravity. If you need to teleport the scene node to a new position without - it being effected by the collision geometry, then call sceneNode->setPosition(); then - animator->setTargetNode(sceneNode); - \param ellipsoidRadius: Radius of the ellipsoid with which collision detection and - response is done. If you have got a scene node, and you are unsure about - how big the radius should be, you could use the following code to determine - it: - \code - const core::aabbox3d<f32>& box = yourSceneNode->getBoundingBox(); - core::vector3df radius = box.MaxEdge - box.getCenter(); - \endcode - \param gravityPerSecond: Sets the gravity of the environment, as an acceleration in - units per second per second. If your units are equivalent to metres, then - core::vector3df(0,-10.0f,0) would give an approximately realistic gravity. - You can disable gravity by setting it to core::vector3df(0,0,0). - \param ellipsoidTranslation: By default, the ellipsoid for collision detection is created around - the center of the scene node, which means that the ellipsoid surrounds - it completely. If this is not what you want, you may specify a translation - for the ellipsoid. - \param slidingValue: DOCUMENTATION NEEDED. - \return The animator. Attach it to a scene node with ISceneNode::addAnimator() - and the animator will cause it to do collision detection and response. - If you no longer need the animator, you should call ISceneNodeAnimator::drop(). - See IReferenceCounted::drop() for more information. */ - virtual ISceneNodeAnimatorCollisionResponse* createCollisionResponseAnimator( - ITriangleSelector* world, ISceneNode* sceneNode, - const core::vector3df& ellipsoidRadius = core::vector3df(30,60,30), - const core::vector3df& gravityPerSecond = core::vector3df(0,-10.0f,0), - const core::vector3df& ellipsoidTranslation = core::vector3df(0,0,0), - f32 slidingValue = 0.0005f) = 0; - - //! Creates a follow spline animator. - /** The animator modifies the position of - the attached scene node to make it follow a hermite spline. - It uses a subset of hermite splines: either cardinal splines - (tightness != 0.5) or catmull-rom-splines (tightness == 0.5). - The animator moves from one control point to the next in - 1/speed seconds. This code was sent in by Matthias Gall. - If you no longer need the animator, you should call ISceneNodeAnimator::drop(). - See IReferenceCounted::drop() for more information. */ - virtual ISceneNodeAnimator* createFollowSplineAnimator(s32 startTime, - const core::array< core::vector3df >& points, - f32 speed = 1.0f, f32 tightness = 0.5f) = 0; - - //! Creates a simple ITriangleSelector, based on a mesh. - /** Triangle selectors - can be used for doing collision detection. Don't use this selector - for a huge amount of triangles like in Quake3 maps. - Instead, use for example ISceneManager::createOctTreeTriangleSelector(). - Please note that the created triangle selector is not automaticly attached - to the scene node. You will have to call ISceneNode::setTriangleSelector() - for this. To create and attach a triangle selector is done like this: - \code - ITriangleSelector* s = sceneManager->createTriangleSelector(yourMesh, - yourSceneNode); - yourSceneNode->setTriangleSelector(s); - s->drop(); - \endcode - \param mesh: Mesh of which the triangles are taken. - \param node: Scene node of which visibility and transformation is used. - \return The selector, or null if not successful. - If you no longer need the selector, you should call ITriangleSelector::drop(). - See IReferenceCounted::drop() for more information. */ - virtual ITriangleSelector* createTriangleSelector(IMesh* mesh, ISceneNode* node) = 0; - - //! Creates a simple ITriangleSelector, based on an animated mesh scene node. - //! Details of the mesh associated with the node will be extracted internally. - //! Call ITriangleSelector::update() to have the triangle selector updated based - //! on the current frame of the animated mesh scene node. - //! \param: The animated mesh scene node from which to build the selector - virtual ITriangleSelector* createTriangleSelector(IAnimatedMeshSceneNode* node) = 0; - - - //! Creates a simple dynamic ITriangleSelector, based on a axis aligned bounding box. - /** Triangle selectors - can be used for doing collision detection. Every time when triangles are - queried, the triangle selector gets the bounding box of the scene node, - an creates new triangles. In this way, it works good with animated scene nodes. - \param node: Scene node of which the bounding box, visibility and transformation is used. - \return The selector, or null if not successful. - If you no longer need the selector, you should call ITriangleSelector::drop(). - See IReferenceCounted::drop() for more information. */ - virtual ITriangleSelector* createTriangleSelectorFromBoundingBox(ISceneNode* node) = 0; - - //! Creates a Triangle Selector, optimized by an octtree. - /** Triangle selectors - can be used for doing collision detection. This triangle selector is - optimized for huge amounts of triangle, it organizes them in an octtree. - Please note that the created triangle selector is not automaticly attached - to the scene node. You will have to call ISceneNode::setTriangleSelector() - for this. To create and attach a triangle selector is done like this: - \code - ITriangleSelector* s = sceneManager->createOctTreeTriangleSelector(yourMesh, - yourSceneNode); - yourSceneNode->setTriangleSelector(s); - s->drop(); - \endcode - For more informations and examples on this, take a look at the collision - tutorial in the SDK. - \param mesh: Mesh of which the triangles are taken. - \param node: Scene node of which visibility and transformation is used. - \param minimalPolysPerNode: Specifies the minimal polygons contained a octree node. - If a node gets less polys the this value, it will not be splitted into - smaller nodes. - \return The selector, or null if not successful. - If you no longer need the selector, you should call ITriangleSelector::drop(). - See IReferenceCounted::drop() for more information. */ - virtual ITriangleSelector* createOctTreeTriangleSelector(IMesh* mesh, - ISceneNode* node, s32 minimalPolysPerNode=32) = 0; - - //! Creates a meta triangle selector. - /** A meta triangle selector is nothing more than a - collection of one or more triangle selectors providing together - the interface of one triangle selector. In this way, - collision tests can be done with different triangle soups in one pass. - \return The selector, or null if not successful. - If you no longer need the selector, you should call ITriangleSelector::drop(). - See IReferenceCounted::drop() for more information. */ - virtual IMetaTriangleSelector* createMetaTriangleSelector() = 0; - - //! Creates a triangle selector which can select triangles from a terrain scene node. - /** \param node: Pointer to the created terrain scene node - \param LOD: Level of detail, 0 for highest detail. - \return The selector, or null if not successful. - If you no longer need the selector, you should call ITriangleSelector::drop(). - See IReferenceCounted::drop() for more information. */ - virtual ITriangleSelector* createTerrainTriangleSelector( - ITerrainSceneNode* node, s32 LOD=0) = 0; - - //! Adds an external mesh loader for extending the engine with new file formats. - /** If you want the engine to be extended with - file formats it currently is not able to load (e.g. .cob), just implement - the IMeshLoader interface in your loading class and add it with this method. - Using this method it is also possible to override built-in mesh loaders with - newer or updated versions without the need of recompiling the engine. - \param externalLoader: Implementation of a new mesh loader. */ - virtual void addExternalMeshLoader(IMeshLoader* externalLoader) = 0; - - //! Get pointer to the scene collision manager. - /** \return Pointer to the collision manager - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual ISceneCollisionManager* getSceneCollisionManager() = 0; - - //! Get pointer to the mesh manipulator. - /** \return Pointer to the mesh manipulator - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual IMeshManipulator* getMeshManipulator() = 0; - - //! Adds a scene node to the deletion queue. - /** The scene node is immediatly - deleted when it's secure. Which means when the scene node does not - execute animators and things like that. This method is for example - used for deleting scene nodes by their scene node animators. In - most other cases, a ISceneNode::remove() call is enough, using this - deletion queue is not necessary. - See ISceneManager::createDeleteAnimator() for details. - \param node: Node to detete. */ - virtual void addToDeletionQueue(ISceneNode* node) = 0; - - //! Posts an input event to the environment. - /** Usually you do not have to - use this method, it is used by the internal engine. */ - virtual bool postEventFromUser(const SEvent& event) = 0; - - //! Clears the whole scene. - /** All scene nodes are removed. */ - virtual void clear() = 0; - - //! Get interface to the parameters set in this scene. - /** String parameters can be used by plugins and mesh loaders. - For example the CMS and LMTS loader want a parameter named 'CSM_TexturePath' - and 'LMTS_TexturePath' set to the path were attached textures can be found. See - CSM_TEXTURE_PATH, LMTS_TEXTURE_PATH, MY3D_TEXTURE_PATH, - COLLADA_CREATE_SCENE_INSTANCES, DMF_TEXTURE_PATH and DMF_USE_MATERIALS_DIRS*/ - virtual io::IAttributes* getParameters() = 0; - - //! Get current render pass. - /** All scene nodes are being rendered in a specific order. - First lights, cameras, sky boxes, solid geometry, and then transparent - stuff. During the rendering process, scene nodes may want to know what the scene - manager is rendering currently, because for example they registered for rendering - twice, once for transparent geometry and once for solid. When knowing what rendering - pass currently is active they can render the correct part of their geometry. */ - virtual E_SCENE_NODE_RENDER_PASS getSceneNodeRenderPass() const = 0; - - //! Get the default scene node factory which can create all built in scene nodes - /** \return Pointer to the default scene node factory - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual ISceneNodeFactory* getDefaultSceneNodeFactory() = 0; - - //! Adds a scene node factory to the scene manager. - /** Use this to extend the scene manager with new scene node types which it should be - able to create automaticly, for example when loading data from xml files. */ - virtual void registerSceneNodeFactory(ISceneNodeFactory* factoryToAdd) = 0; - - //! Get amount of registered scene node factories. - virtual u32 getRegisteredSceneNodeFactoryCount() const = 0; - - //! Get a scene node factory by index - /** \return Pointer to the requested scene node factory, or 0 if it does not exist. - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual ISceneNodeFactory* getSceneNodeFactory(u32 index) = 0; - - //! Get the default scene node animator factory which can create all built-in scene node animators - /** \return Pointer to the default scene node animator factory - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual ISceneNodeAnimatorFactory* getDefaultSceneNodeAnimatorFactory() = 0; - - //! Adds a scene node animator factory to the scene manager. - /** Use this to extend the scene manager with new scene node animator types which it should be - able to create automaticly, for example when loading data from xml files. */ - virtual void registerSceneNodeAnimatorFactory(ISceneNodeAnimatorFactory* factoryToAdd) = 0; - - //! Get amount of registered scene node animator factories. - virtual u32 getRegisteredSceneNodeAnimatorFactoryCount() const = 0; - - //! Get scene node animator factory by index - /** \return Pointer to the requested scene node animator factory, or 0 if it does not exist. - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual ISceneNodeAnimatorFactory* getSceneNodeAnimatorFactory(u32 index) = 0; - - //! Get typename from a scene node type or null if not found - virtual const c8* getSceneNodeTypeName(ESCENE_NODE_TYPE type) = 0; - - //! Returns a typename from a scene node animator type or null if not found - virtual const c8* getAnimatorTypeName(ESCENE_NODE_ANIMATOR_TYPE type) = 0; - - //! Adds a scene node to the scene by name - /** \return Pointer to the scene node added by a factory - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual ISceneNode* addSceneNode(const char* sceneNodeTypeName, ISceneNode* parent=0) = 0; - - //! Creates a new scene manager. - /** This can be used to easily draw and/or store two - independent scenes at the same time. The mesh cache will be - shared between all existing scene managers, which means if you - load a mesh in the original scene manager using for example - getMesh(), the mesh will be available in all other scene - managers too, without loading. - The original/main scene manager will still be there and - accessible via IrrlichtDevice::getSceneManager(). If you need - input event in this new scene manager, for example for FPS - cameras, you'll need to forward input to this manually: Just - implement an IEventReceiver and call - yourNewSceneManager->postEventFromUser(), and return true so - that the original scene manager doesn't get the event. - Otherwise, all input will go to the main scene manager - automatically. - If you no longer need the new scene manager, you should call - ISceneManager::drop(). - See IReferenceCounted::drop() for more information. */ - virtual ISceneManager* createNewSceneManager(bool cloneContent=false) = 0; - - //! Saves the current scene into a file. - /** Scene nodes with the option isDebugObject set to true are not being saved. - The scene is usually written to an .irr file, an xml based format. .irr files can - Be edited with the Irrlicht Engine Editor, irrEdit (http://irredit.irrlicht3d.org). - To load .irr files again, see ISceneManager::loadScene(). - \param filename: Name of the file. - \param userDataSerializer: If you want to save some user data for every scene node into the - file, implement the ISceneUserDataSerializer interface and provide it as parameter here. - Otherwise, simply specify 0 as this parameter. - \return True if successful. */ - virtual bool saveScene(const io::path& filename, ISceneUserDataSerializer* userDataSerializer=0) = 0; - - //! Saves the current scene into a file. - /** Scene nodes with the option isDebugObject set to true are not being saved. - The scene is usually written to an .irr file, an xml based format. .irr files can - Be edited with the Irrlicht Engine Editor, irrEdit (http://irredit.irrlicht3d.org). - To load .irr files again, see ISceneManager::loadScene(). - \param file: File where the scene is saved into. - \param userDataSerializer: If you want to save some user data for every scene node into the - file, implement the ISceneUserDataSerializer interface and provide it as parameter here. - Otherwise, simply specify 0 as this parameter. - \return True if successful. */ - virtual bool saveScene(io::IWriteFile* file, ISceneUserDataSerializer* userDataSerializer=0) = 0; - - //! Loads a scene. Note that the current scene is not cleared before. - /** The scene is usually load from an .irr file, an xml based format. .irr files can - Be edited with the Irrlicht Engine Editor, irrEdit (http://irredit.irrlicht3d.org) or - saved directly by the engine using ISceneManager::saveScene(). - \param filename: Name of the file. - \param userDataSerializer: If you want to load user data - possibily saved in that file for some scene nodes in the file, - implement the ISceneUserDataSerializer interface and provide it - as parameter here. Otherwise, simply specify 0 as this - parameter. - \return True if successful. */ - virtual bool loadScene(const io::path& filename, ISceneUserDataSerializer* userDataSerializer=0) = 0; - - //! Loads a scene. Note that the current scene is not cleared before. - /** The scene is usually load from an .irr file, an xml based format. .irr files can - Be edited with the Irrlicht Engine Editor, irrEdit (http://irredit.irrlicht3d.org) or - saved directly by the engine using ISceneManager::saveScene(). - \param file: File where the scene is going to be saved into. - \param userDataSerializer: If you want to load user data - possibily saved in that file for some scene nodes in the file, - implement the ISceneUserDataSerializer interface and provide it - as parameter here. Otherwise, simply specify 0 as this - parameter. - \return True if successful. */ - virtual bool loadScene(io::IReadFile* file, ISceneUserDataSerializer* userDataSerializer=0) = 0; - - //! Get a mesh writer implementation if available - /** Note: You need to drop() the pointer after use again, see IReferenceCounted::drop() - for details. */ - virtual IMeshWriter* createMeshWriter(EMESH_WRITER_TYPE type) = 0; - - //! Get a skinned mesh, which is not available as header-only code - /** Note: You need to drop() the pointer after use again, see IReferenceCounted::drop() - for details. */ - virtual ISkinnedMesh* createSkinnedMesh() = 0; - - //! Sets ambient color of the scene - virtual void setAmbientLight(const video::SColorf &ambientColor) = 0; - - //! Get ambient color of the scene - virtual const video::SColorf& getAmbientLight() const = 0; - - //! Register a custom callbacks manager which gets callbacks during scene rendering. - /** \param[in] lightManager: the new callbacks manager. You may pass 0 to remove the - current callbacks manager and restore the default behaviour. */ - virtual void setLightManager(ILightManager* lightManager) = 0; - - //! Get an instance of a geometry creator. - /** The geometry creator provides some helper methods to create various types of - basic geometry. This can be useful for custom scene nodes. */ - virtual const IGeometryCreator* getGeometryCreator(void) const = 0; - - //! Check if node is culled in current view frustum - /** Please note that depending on the used culling method this - check can be rather coarse, or slow. A positive result is - correct, though, i.e. if this method returns true the node is - positively not visible. The node might still be invisible even - if this method returns false. - \param node The scene node which is checked for culling. - \return True if node is not visible in the current scene, else - false. */ - virtual bool isCulled(const ISceneNode* node) const =0; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/ISceneNode.h b/irrlicht-1.6/include/ISceneNode.h deleted file mode 100644 index a1a77a006..000000000 --- a/irrlicht-1.6/include/ISceneNode.h +++ /dev/null @@ -1,826 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_SCENE_NODE_H_INCLUDED__ -#define __I_SCENE_NODE_H_INCLUDED__ - -#include "IAttributeExchangingObject.h" -#include "ESceneNodeTypes.h" -#include "ECullingTypes.h" -#include "EDebugSceneTypes.h" -#include "ISceneNodeAnimator.h" -#include "ITriangleSelector.h" -#include "SMaterial.h" -#include "irrString.h" -#include "aabbox3d.h" -#include "matrix4.h" -#include "irrList.h" -#include "IAttributes.h" - -namespace irr -{ -namespace scene -{ - class ISceneManager; - - //! Scene node interface. - /** A scene node is a node in the hierarchical scene graph. Every scene - node may have children, which are also scene nodes. Children move - relative to their parent's position. If the parent of a node is not - visible, its children won't be visible either. In this way, it is for - example easily possible to attach a light to a moving car, or to place - a walking character on a moving platform on a moving ship. - */ - class ISceneNode : virtual public io::IAttributeExchangingObject - { - public: - - //! Constructor - ISceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id=-1, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)) - : RelativeTranslation(position), RelativeRotation(rotation), RelativeScale(scale), - Parent(0), SceneManager(mgr), TriangleSelector(0), ID(id), - AutomaticCullingState(EAC_BOX), DebugDataVisible(EDS_OFF), - IsVisible(true), IsDebugObject(false) - { - if (parent) - parent->addChild(this); - - updateAbsolutePosition(); - } - - - //! Destructor - virtual ~ISceneNode() - { - // delete all children - removeAll(); - - // delete all animators - core::list<ISceneNodeAnimator*>::Iterator ait = Animators.begin(); - for (; ait != Animators.end(); ++ait) - (*ait)->drop(); - - if (TriangleSelector) - TriangleSelector->drop(); - } - - - //! This method is called just before the rendering process of the whole scene. - /** Nodes may register themselves in the render pipeline during this call, - precalculate the geometry which should be renderered, and prevent their - children from being able to register themselves if they are clipped by simply - not calling their OnRegisterSceneNode method. - If you are implementing your own scene node, you should overwrite this method - with an implementation code looking like this: - \code - if (IsVisible) - SceneManager->registerNodeForRendering(this); - - ISceneNode::OnRegisterSceneNode(); - \endcode - */ - virtual void OnRegisterSceneNode() - { - if (IsVisible) - { - core::list<ISceneNode*>::Iterator it = Children.begin(); - for (; it != Children.end(); ++it) - (*it)->OnRegisterSceneNode(); - } - } - - - //! OnAnimate() is called just before rendering the whole scene. - /** Nodes may calculate or store animations here, and may do other useful things, - depending on what they are. Also, OnAnimate() should be called for all - child scene nodes here. This method will be called once per frame, independent - of whether the scene node is visible or not. - \param timeMs Current time in milliseconds. */ - virtual void OnAnimate(u32 timeMs) - { - if (IsVisible) - { - // animate this node with all animators - - core::list<ISceneNodeAnimator*>::Iterator ait = Animators.begin(); - while (ait != Animators.end()) - { - // continue to the next node before calling animateNode() - // so that the animator may remove itself from the scene - // node without the iterator becoming invalid - ISceneNodeAnimator* anim = *ait; - ++ait; - anim->animateNode(this, timeMs); - } - - // update absolute position - updateAbsolutePosition(); - - // perform the post render process on all children - - core::list<ISceneNode*>::Iterator it = Children.begin(); - for (; it != Children.end(); ++it) - (*it)->OnAnimate(timeMs); - } - } - - - //! Renders the node. - virtual void render() = 0; - - - //! Returns the name of the node. - /** \return Name as character string. */ - virtual const c8* getName() const - { - return Name.c_str(); - } - - - //! Sets the name of the node. - /** \param name New name of the scene node. */ - virtual void setName(const c8* name) - { - Name = name; - } - - - //! Sets the name of the node. - /** \param name New name of the scene node. */ - virtual void setName(const core::stringc& name) - { - Name = name; - } - - - //! Get the axis aligned, not transformed bounding box of this node. - /** This means that if this node is an animated 3d character, - moving in a room, the bounding box will always be around the - origin. To get the box in real world coordinates, just - transform it with the matrix you receive with - getAbsoluteTransformation() or simply use - getTransformedBoundingBox(), which does the same. - \return The non-transformed bounding box. */ - virtual const core::aabbox3d<f32>& getBoundingBox() const = 0; - - - //! Get the axis aligned, transformed and animated absolute bounding box of this node. - /** \return The transformed bounding box. */ - virtual const core::aabbox3d<f32> getTransformedBoundingBox() const - { - core::aabbox3d<f32> box = getBoundingBox(); - AbsoluteTransformation.transformBoxEx(box); - return box; - } - - - //! Get the absolute transformation of the node. Is recalculated every OnAnimate()-call. - //! \return The absolute transformation matrix. - virtual const core::matrix4& getAbsoluteTransformation() const - { - return AbsoluteTransformation; - } - - - //! Returns the relative transformation of the scene node. - /** The relative transformation is stored internally as 3 - vectors: translation, rotation and scale. To get the relative - transformation matrix, it is calculated from these values. - \return The relative transformation matrix. */ - virtual core::matrix4 getRelativeTransformation() const - { - core::matrix4 mat; - mat.setRotationDegrees(RelativeRotation); - mat.setTranslation(RelativeTranslation); - - if (RelativeScale != core::vector3df(1.f,1.f,1.f)) - { - core::matrix4 smat; - smat.setScale(RelativeScale); - mat *= smat; - } - - return mat; - } - - - //! Returns whether the node should be visible (if all of its parents are visible). - /** This is only an option set by the user, but has nothing to - do with geometry culling - \return The requested visibility of the node, true means - visible (if all parents are also visible). */ - virtual bool isVisible() const - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return IsVisible; - } - - //! Check whether the node is truly visible, taking into accounts its parents' visibility - /** \return true if the node and all its parents are visible, - false if this or any parent node is invisible. */ - virtual bool isTrulyVisible() const - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - if(!IsVisible) - return false; - - if(!Parent) - return true; - - return Parent->isTrulyVisible(); - } - - //! Sets if the node should be visible or not. - /** All children of this node won't be visible either, when set - to false. Invisible nodes are not valid candidates for selection by - collision manager bounding box methods. - \param isVisible If the node shall be visible. */ - virtual void setVisible(bool isVisible) - { - IsVisible = isVisible; - } - - - //! Get the id of the scene node. - /** This id can be used to identify the node. - \return The id. */ - virtual s32 getID() const - { - return ID; - } - - - //! Sets the id of the scene node. - /** This id can be used to identify the node. - \param id The new id. */ - virtual void setID(s32 id) - { - ID = id; - } - - - //! Adds a child to this scene node. - /** If the scene node already has a parent it is first removed - from the other parent. - \param child A pointer to the new child. */ - virtual void addChild(ISceneNode* child) - { - if (child && (child != this)) - { - // Change scene manager? - if (SceneManager != child->SceneManager) - child->setSceneManager(SceneManager); - - child->grab(); - child->remove(); // remove from old parent - Children.push_back(child); - child->Parent = this; - } - } - - - //! Removes a child from this scene node. - /** \param child A pointer to the new child. - \return True if the child was removed, and false if not, - e.g. because it couldn't be found in the children list. */ - virtual bool removeChild(ISceneNode* child) - { - core::list<ISceneNode*>::Iterator it = Children.begin(); - for (; it != Children.end(); ++it) - if ((*it) == child) - { - (*it)->Parent = 0; - (*it)->drop(); - Children.erase(it); - return true; - } - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; - } - - - //! Removes all children of this scene node - virtual void removeAll() - { - core::list<ISceneNode*>::Iterator it = Children.begin(); - for (; it != Children.end(); ++it) - { - (*it)->Parent = 0; - (*it)->drop(); - } - - Children.clear(); - } - - - //! Removes this scene node from the scene, deleting it. - virtual void remove() - { - if (Parent) - Parent->removeChild(this); - } - - - //! Adds an animator which should animate this node. - /** \param animator A pointer to the new animator. */ - virtual void addAnimator(ISceneNodeAnimator* animator) - { - if (animator) - { - Animators.push_back(animator); - animator->grab(); - } - } - - - //! Get a list of all scene node animators. - /** \return The list of animators attached to this node. */ - const core::list<ISceneNodeAnimator*>& getAnimators() const - { - return Animators; - } - - - //! Removes an animator from this scene node. - /** \param animator A pointer to the animator to be deleted. */ - virtual void removeAnimator(ISceneNodeAnimator* animator) - { - core::list<ISceneNodeAnimator*>::Iterator it = Animators.begin(); - for (; it != Animators.end(); ++it) - if ((*it) == animator) - { - (*it)->drop(); - Animators.erase(it); - return; - } - } - - - //! Removes all animators from this scene node. - virtual void removeAnimators() - { - core::list<ISceneNodeAnimator*>::Iterator it = Animators.begin(); - for (; it != Animators.end(); ++it) - (*it)->drop(); - - Animators.clear(); - } - - - //! Returns the material based on the zero based index i. - /** To get the amount of materials used by this scene node, use - getMaterialCount(). This function is needed for inserting the - node into the scene hierarchy at an optimal position for - minimizing renderstate changes, but can also be used to - directly modify the material of a scene node. - \param num Zero based index. The maximal value is getMaterialCount() - 1. - \return The material at that index. */ - virtual video::SMaterial& getMaterial(u32 num) - { - return video::IdentityMaterial; - } - - - //! Get amount of materials used by this scene node. - /** \return Current amount of materials of this scene node. */ - virtual u32 getMaterialCount() const - { - return 0; - } - - - //! Sets all material flags at once to a new value. - /** Useful, for example, if you want the whole mesh to be - affected by light. - \param flag Which flag of all materials to be set. - \param newvalue New value of that flag. */ - void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue) - { - for (u32 i=0; i<getMaterialCount(); ++i) - getMaterial(i).setFlag(flag, newvalue); - } - - - //! Sets the texture of the specified layer in all materials of this scene node to the new texture. - /** \param textureLayer Layer of texture to be set. Must be a - value smaller than MATERIAL_MAX_TEXTURES. - \param texture New texture to be used. */ - void setMaterialTexture(u32 textureLayer, video::ITexture* texture) - { - if (textureLayer >= video::MATERIAL_MAX_TEXTURES) - return; - - for (u32 i=0; i<getMaterialCount(); ++i) - getMaterial(i).setTexture(textureLayer, texture); - } - - - //! Sets the material type of all materials in this scene node to a new material type. - /** \param newType New type of material to be set. */ - void setMaterialType(video::E_MATERIAL_TYPE newType) - { - for (u32 i=0; i<getMaterialCount(); ++i) - getMaterial(i).MaterialType = newType; - } - - - //! Gets the scale of the scene node relative to its parent. - /** This is the scale of this node relative to its parent. - If you want the absolute scale, use - getAbsoluteTransformation().getScale() - \return The scale of the scene node. */ - virtual const core::vector3df& getScale() const - { - return RelativeScale; - } - - - //! Sets the relative scale of the scene node. - /** \param scale New scale of the node, relative to its parent. */ - virtual void setScale(const core::vector3df& scale) - { - RelativeScale = scale; - } - - - //! Gets the rotation of the node relative to its parent. - /** Note that this is the relative rotation of the node. - If you want the absolute rotation, use - getAbsoluteTransformation().getRotation() - \return Current relative rotation of the scene node. */ - virtual const core::vector3df& getRotation() const - { - return RelativeRotation; - } - - - //! Sets the rotation of the node relative to its parent. - /** This only modifies the relative rotation of the node. - \param rotation New rotation of the node in degrees. */ - virtual void setRotation(const core::vector3df& rotation) - { - RelativeRotation = rotation; - } - - - //! Gets the position of the node relative to its parent. - /** Note that the position is relative to the parent. If you want - the position in world coordinates, use getAbsolutePosition() instead. - \return The current position of the node relative to the parent. */ - virtual const core::vector3df& getPosition() const - { - return RelativeTranslation; - } - - - //! Sets the position of the node relative to its parent. - /** Note that the position is relative to the parent. - \param newpos New relative position of the scene node. */ - virtual void setPosition(const core::vector3df& newpos) - { - RelativeTranslation = newpos; - } - - - //! Gets the absolute position of the node in world coordinates. - /** If you want the position of the node relative to its parent, - use getPosition() instead. - \return The current absolute position of the scene node. */ - virtual core::vector3df getAbsolutePosition() const - { - return AbsoluteTransformation.getTranslation(); - } - - - //! Enables or disables automatic culling based on the bounding box. - /** Automatic culling is enabled by default. Note that not - all SceneNodes support culling and that some nodes always cull - their geometry because it is their only reason for existence, - for example the OctreeSceneNode. - \param state The culling state to be used. */ - void setAutomaticCulling( E_CULLING_TYPE state) - { - AutomaticCullingState = state; - } - - - //! Gets the automatic culling state. - /** \return The automatic culling state. */ - E_CULLING_TYPE getAutomaticCulling() const - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return AutomaticCullingState; - } - - - //! Sets if debug data like bounding boxes should be drawn. - /** A bitwise OR of the types from @ref irr::scene::E_DEBUG_SCENE_TYPE. - Please note that not all scene nodes support all debug data types. - \param state The debug data visibility state to be used. */ - virtual void setDebugDataVisible(s32 state) - { - DebugDataVisible = state; - } - - //! Returns if debug data like bounding boxes are drawn. - /** \return A bitwise OR of the debug data values from - @ref irr::scene::E_DEBUG_SCENE_TYPE that are currently visible. */ - s32 isDebugDataVisible() const - { - return DebugDataVisible; - } - - - //! Sets if this scene node is a debug object. - /** Debug objects have some special properties, for example they can be easily - excluded from collision detection or from serialization, etc. */ - void setIsDebugObject(bool debugObject) - { - IsDebugObject = debugObject; - } - - - //! Returns if this scene node is a debug object. - /** Debug objects have some special properties, for example they can be easily - excluded from collision detection or from serialization, etc. - \return If this node is a debug object, true is returned. */ - bool isDebugObject() const - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return IsDebugObject; - } - - - //! Returns a const reference to the list of all children. - /** \return The list of all children of this node. */ - const core::list<ISceneNode*>& getChildren() const - { - return Children; - } - - - //! Changes the parent of the scene node. - /** \param newParent The new parent to be used. */ - virtual void setParent(ISceneNode* newParent) - { - grab(); - remove(); - - Parent = newParent; - - if (Parent) - Parent->addChild(this); - - drop(); - } - - - //! Returns the triangle selector attached to this scene node. - /** The Selector can be used by the engine for doing collision - detection. You can create a TriangleSelector with - ISceneManager::createTriangleSelector() or - ISceneManager::createOctTreeTriangleSelector and set it with - ISceneNode::setTriangleSelector(). If a scene node got no triangle - selector, but collision tests should be done with it, a triangle - selector is created using the bounding box of the scene node. - \return A pointer to the TriangleSelector or 0, if there - is none. */ - virtual ITriangleSelector* getTriangleSelector() const - { - return TriangleSelector; - } - - - //! Sets the triangle selector of the scene node. - /** The Selector can be used by the engine for doing collision - detection. You can create a TriangleSelector with - ISceneManager::createTriangleSelector() or - ISceneManager::createOctTreeTriangleSelector(). Some nodes may - create their own selector by default, so it would be good to - check if there is already a selector in this node by calling - ISceneNode::getTriangleSelector(). - \param selector New triangle selector for this scene node. */ - virtual void setTriangleSelector(ITriangleSelector* selector) - { - if (TriangleSelector != selector) - { - if (TriangleSelector) - TriangleSelector->drop(); - - TriangleSelector = selector; - if (TriangleSelector) - TriangleSelector->grab(); - } - } - - - //! Updates the absolute position based on the relative and the parents position - /** Note: This does not recursively update the parents absolute positions, so if you have a deeper - hierarchy you might want to update the parents first.*/ - virtual void updateAbsolutePosition() - { - if (Parent) - { - AbsoluteTransformation = - Parent->getAbsoluteTransformation() * getRelativeTransformation(); - } - else - AbsoluteTransformation = getRelativeTransformation(); - } - - - //! Returns the parent of this scene node - /** \return A pointer to the parent. */ - scene::ISceneNode* getParent() const - { - return Parent; - } - - - //! Returns type of the scene node - /** \return The type of this node. */ - virtual ESCENE_NODE_TYPE getType() const - { - return ESNT_UNKNOWN; - } - - - //! Writes attributes of the scene node. - /** Implement this to expose the attributes of your scene node - for scripting languages, editors, debuggers or xml - serialization purposes. - \param out The attribute container to write into. - \param options Additional options which might influence the - serialization. */ - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const - { - if (!out) - return; - out->addString ("Name", Name.c_str()); - out->addInt ("Id", ID ); - - out->addVector3d("Position", getPosition() ); - out->addVector3d("Rotation", getRotation() ); - out->addVector3d("Scale", getScale() ); - - out->addBool ("Visible", IsVisible ); - out->addEnum ("AutomaticCulling", AutomaticCullingState, AutomaticCullingNames); - out->addInt ("DebugDataVisible", DebugDataVisible ); - out->addBool ("IsDebugObject", IsDebugObject ); - } - - - //! Reads attributes of the scene node. - /** Implement this to set the attributes of your scene node for - scripting languages, editors, debuggers or xml deserialization - purposes. - \param in The attribute container to read from. - \param options Additional options which might influence the - deserialization. */ - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) - { - if (!in) - return; - Name = in->getAttributeAsString("Name"); - ID = in->getAttributeAsInt("Id"); - - setPosition(in->getAttributeAsVector3d("Position")); - setRotation(in->getAttributeAsVector3d("Rotation")); - setScale(in->getAttributeAsVector3d("Scale")); - - IsVisible = in->getAttributeAsBool("Visible"); - AutomaticCullingState = (scene::E_CULLING_TYPE) in->getAttributeAsEnumeration("AutomaticCulling", - scene::AutomaticCullingNames); - - DebugDataVisible = in->getAttributeAsInt("DebugDataVisible"); - IsDebugObject = in->getAttributeAsBool("IsDebugObject"); - - updateAbsolutePosition(); - } - - //! Creates a clone of this scene node and its children. - /** \param newParent An optional new parent. - \param newManager An optional new scene manager. - \return The newly created clone of this node. */ - virtual ISceneNode* clone(ISceneNode* newParent=0, ISceneManager* newManager=0) - { - return 0; // to be implemented by derived classes - } - - //! Retrieve the scene manager for this node. - /** \return The node's scene manager. */ - virtual ISceneManager* getSceneManager(void) const { return SceneManager; } - - protected: - - //! A clone function for the ISceneNode members. - /** This method can be used by clone() implementations of - derived classes - \param toCopyFrom The node from which the values are copied - \param newManager The new scene manager. */ - void cloneMembers(ISceneNode* toCopyFrom, ISceneManager* newManager) - { - Name = toCopyFrom->Name; - AbsoluteTransformation = toCopyFrom->AbsoluteTransformation; - RelativeTranslation = toCopyFrom->RelativeTranslation; - RelativeRotation = toCopyFrom->RelativeRotation; - RelativeScale = toCopyFrom->RelativeScale; - ID = toCopyFrom->ID; - setTriangleSelector(toCopyFrom->TriangleSelector); - AutomaticCullingState = toCopyFrom->AutomaticCullingState; - DebugDataVisible = toCopyFrom->DebugDataVisible; - IsVisible = toCopyFrom->IsVisible; - IsDebugObject = toCopyFrom->IsDebugObject; - - if (newManager) - SceneManager = newManager; - else - SceneManager = toCopyFrom->SceneManager; - - // clone children - - core::list<ISceneNode*>::Iterator it = toCopyFrom->Children.begin(); - for (; it != toCopyFrom->Children.end(); ++it) - (*it)->clone(this, newManager); - - // clone animators - - core::list<ISceneNodeAnimator*>::Iterator ait = toCopyFrom->Animators.begin(); - for (; ait != toCopyFrom->Animators.end(); ++ait) - { - ISceneNodeAnimator* anim = (*ait)->createClone(this, SceneManager); - if (anim) - { - addAnimator(anim); - anim->drop(); - } - } - } - - //! Sets the new scene manager for this node and all children. - //! Called by addChild when moving nodes between scene managers - void setSceneManager(ISceneManager* newManager) - { - SceneManager = newManager; - - core::list<ISceneNode*>::Iterator it = Children.begin(); - for (; it != Children.end(); ++it) - (*it)->setSceneManager(newManager); - } - - //! Name of the scene node. - core::stringc Name; - - //! Absolute transformation of the node. - core::matrix4 AbsoluteTransformation; - - //! Relative translation of the scene node. - core::vector3df RelativeTranslation; - - //! Relative rotation of the scene node. - core::vector3df RelativeRotation; - - //! Relative scale of the scene node. - core::vector3df RelativeScale; - - //! Pointer to the parent - ISceneNode* Parent; - - //! List of all children of this node - core::list<ISceneNode*> Children; - - //! List of all animator nodes - core::list<ISceneNodeAnimator*> Animators; - - //! Pointer to the scene manager - ISceneManager* SceneManager; - - //! Pointer to the triangle selector - ITriangleSelector* TriangleSelector; - - //! ID of the node. - s32 ID; - - //! Automatic culling state - E_CULLING_TYPE AutomaticCullingState; - - //! Flag if debug data should be drawn, such as Bounding Boxes. - s32 DebugDataVisible; - - //! Is the node visible? - bool IsVisible; - - //! Is debug object? - bool IsDebugObject; - }; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/ISceneNodeAnimator.h b/irrlicht-1.6/include/ISceneNodeAnimator.h deleted file mode 100644 index 02c361490..000000000 --- a/irrlicht-1.6/include/ISceneNodeAnimator.h +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_SCENE_NODE_ANIMATOR_H_INCLUDED__ -#define __I_SCENE_NODE_ANIMATOR_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "vector3d.h" -#include "ESceneNodeAnimatorTypes.h" -#include "IAttributeExchangingObject.h" -#include "IEventReceiver.h" - -namespace irr -{ -namespace io -{ - class IAttributes; -} // end namespace io -namespace scene -{ - class ISceneNode; - class ISceneManager; - - //! Animates a scene node. Can animate position, rotation, material, and so on. - /** A scene node animator is able to animate a scene node in a very simple way. It may - change its position, rotation, scale and/or material. There are lots of animators - to choose from. You can create scene node animators with the ISceneManager interface. - */ - class ISceneNodeAnimator : public io::IAttributeExchangingObject, public IEventReceiver - { - public: - //! Animates a scene node. - /** \param node Node to animate. - \param timeMs Current time in milli seconds. */ - virtual void animateNode(ISceneNode* node, u32 timeMs) =0; - - //! Creates a clone of this animator. - /** Please note that you will have to drop - (IReferenceCounted::drop()) the returned pointer after calling this. */ - virtual ISceneNodeAnimator* createClone(ISceneNode* node, - ISceneManager* newManager=0) =0; - - //! Returns true if this animator receives events. - /** When attached to an active camera, this animator will be - able to respond to events such as mouse and keyboard events. */ - virtual bool isEventReceiverEnabled() const - { - return false; - } - - //! Event receiver, override this function for camera controlling animators - virtual bool OnEvent(const SEvent& event) - { - return false; - } - - //! Returns type of the scene node animator - virtual ESCENE_NODE_ANIMATOR_TYPE getType() const - { - return ESNAT_UNKNOWN; - } - - //! Returns if the animator has finished. - /** This is only valid for non-looping animators with a discrete end state. - \return true if the animator has finished, false if it is still running. */ - virtual bool hasFinished(void) const - { - return false; - } - }; - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/ISceneNodeAnimatorCameraFPS.h b/irrlicht-1.6/include/ISceneNodeAnimatorCameraFPS.h deleted file mode 100644 index 5b21584d4..000000000 --- a/irrlicht-1.6/include/ISceneNodeAnimatorCameraFPS.h +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_SCENE_NODE_ANIMATOR_CAMERA_FPS_H_INCLUDED__ -#define __I_SCENE_NODE_ANIMATOR_CAMERA_FPS_H_INCLUDED__ - -#include "ISceneNodeAnimator.h" -#include "IEventReceiver.h" - -namespace irr -{ - struct SKeyMap; - -namespace scene -{ - - //! Special scene node animator for FPS cameras - /** This scene node animator can be attached to a camera to make it act - like a first person shooter - */ - class ISceneNodeAnimatorCameraFPS : public ISceneNodeAnimator - { - public: - - //! Returns the speed of movement in units per millisecond - virtual f32 getMoveSpeed() const = 0; - - //! Sets the speed of movement in units per millisecond - virtual void setMoveSpeed(f32 moveSpeed) = 0; - - //! Returns the rotation speed in degrees - /** The degrees are equivalent to a half screen movement of the mouse, - i.e. if the mouse cursor had been moved to the border of the screen since - the last animation. */ - virtual f32 getRotateSpeed() const = 0; - - //! Set the rotation speed in degrees - virtual void setRotateSpeed(f32 rotateSpeed) = 0; - - //! Sets the keyboard mapping for this animator - /** \param map Array of keyboard mappings, see irr::SKeyMap - \param count Size of the keyboard map array. */ - virtual void setKeyMap(SKeyMap *map, u32 count) = 0; - - //! Sets whether vertical movement should be allowed. - /** If vertical movement is enabled then the camera may fight with - gravity causing camera shake. Disable this if the camera has - a collision animator with gravity enabled. */ - virtual void setVerticalMovement(bool allow) = 0; - - //! Sets whether the Y axis of the mouse should be inverted. - /** If enabled then moving the mouse down will cause - the camera to look up. It is disabled by default. */ - virtual void setInvertMouse(bool invert) = 0; - }; -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/ISceneNodeAnimatorCameraMaya.h b/irrlicht-1.6/include/ISceneNodeAnimatorCameraMaya.h deleted file mode 100644 index 15b0b869a..000000000 --- a/irrlicht-1.6/include/ISceneNodeAnimatorCameraMaya.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_SCENE_NODE_ANIMATOR_CAMERA_MAYA_H_INCLUDED__ -#define __I_SCENE_NODE_ANIMATOR_CAMERA_MAYA_H_INCLUDED__ - -#include "ISceneNodeAnimator.h" - -namespace irr -{ - -namespace scene -{ - - //! Special scene node animator for Maya-style cameras - /** This scene node animator can be attached to a camera to make it act like a 3d - modelling tool. - The camera is moving relative to the target with the mouse, by pressing either - of the three buttons. - */ - class ISceneNodeAnimatorCameraMaya : public ISceneNodeAnimator - { - public: - - //! Returns the speed of movement - virtual f32 getMoveSpeed() const = 0; - - //! Sets the speed of movement - virtual void setMoveSpeed(f32 moveSpeed) = 0; - - //! Returns the rotation speed - virtual f32 getRotateSpeed() const = 0; - - //! Set the rotation speed - virtual void setRotateSpeed(f32 rotateSpeed) = 0; - - //! Returns the zoom speed - virtual f32 getZoomSpeed() const = 0; - - //! Set the zoom speed - virtual void setZoomSpeed(f32 zoomSpeed) = 0; - - }; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/ISceneNodeAnimatorCollisionResponse.h b/irrlicht-1.6/include/ISceneNodeAnimatorCollisionResponse.h deleted file mode 100644 index f946dd446..000000000 --- a/irrlicht-1.6/include/ISceneNodeAnimatorCollisionResponse.h +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_SCENE_NODE_ANIMATOR_COLLISION_RESPONSE_H_INCLUDED__ -#define __I_SCENE_NODE_ANIMATOR_COLLISION_RESPONSE_H_INCLUDED__ - -#include "ISceneNode.h" - -namespace irr -{ -namespace scene -{ - - class ISceneNodeAnimatorCollisionResponse; - - //! Callback interface for catching events of collisions. - /** Implement this interface and use - ISceneNodeAnimatorCollisionResponse::setCollisionCallback to be able to - be notified if a collision has occurred. - **/ - class ICollisionCallback : public virtual IReferenceCounted - { - public: - - //! Will be called when a collision occurrs. - /** See ISceneNodeAnimatorCollisionResponse::setCollisionCallback for more information. - \param animator: Collision response animator in which the collision occurred. You can call - this animator's methods to find the node, collisionPoint and/or collision triangle. - \retval true if the collision was handled in the animator. The animator's target - node will *not* be stopped at the collision point, but will instead move fully - to the location that triggered the collision check. - \retval false if the collision was not handled in the animator. The animator's - target node will be moved to the collision position. - */ - virtual bool onCollision(const ISceneNodeAnimatorCollisionResponse& animator) = 0; - }; - - //! Special scene node animator for doing automatic collision detection and response. - /** This scene node animator can be attached to any single scene node - and will then prevent it from moving through specified collision geometry - (e.g. walls and floors of the) world, as well as having it fall under gravity. - This animator provides a simple implementation of first person shooter cameras. - Attach it to a camera, and the camera will behave as the player control in a - first person shooter game: The camera stops and slides at walls, walks up stairs, - falls down if there is no floor under it, and so on. - - The animator will treat any change in the position of its target scene - node as movement, including a setPosition(), as movement. If you want to - teleport the target scene node manually to a location without it being effected - by collision geometry, then call setTargetNode(node) after calling node->setPosition(). - */ - class ISceneNodeAnimatorCollisionResponse : public ISceneNodeAnimator - { - public: - - //! Destructor - virtual ~ISceneNodeAnimatorCollisionResponse() {} - - //! Check if the attached scene node is falling. - /** Falling means that there is no blocking wall from the scene - node in the direction of the gravity. The implementation of - this method is very fast, no collision detection is done when - invoking it. - \return True if the scene node is falling, false if not. */ - virtual bool isFalling() const = 0; - - //! Sets the radius of the ellipsoid for collision detection and response. - /** If you have a scene node, and you are unsure about how big - the radius should be, you could use the following code to - determine it: - \code - core::aabbox<f32> box = yourSceneNode->getBoundingBox(); - core::vector3df radius = box.MaxEdge - box.getCenter(); - \endcode - \param radius: New radius of the ellipsoid. */ - virtual void setEllipsoidRadius(const core::vector3df& radius) = 0; - - //! Returns the radius of the ellipsoid for collision detection and response. - /** \return Radius of the ellipsoid. */ - virtual core::vector3df getEllipsoidRadius() const = 0; - - //! Sets the gravity of the environment. - /** A good example value would be core::vector3df(0,-100.0f,0) - for letting gravity affect all object to fall down. For bigger - gravity, make increase the length of the vector. You can - disable gravity by setting it to core::vector3df(0,0,0); - \param gravity: New gravity vector. */ - virtual void setGravity(const core::vector3df& gravity) = 0; - - //! Get current vector of gravity. - //! \return Gravity vector. */ - virtual core::vector3df getGravity() const = 0; - - //! 'Jump' the animator, by adding a jump speed opposite to its gravity - /** \param jumpSpeed The initial speed of the jump; the velocity will be opposite - to this animator's gravity vector. */ - virtual void jump(f32 jumpSpeed) = 0; - - //! Should the Target react on collision ( default = true ) - virtual void setAnimateTarget ( bool enable ) = 0; - virtual bool getAnimateTarget () const = 0; - - //! Set translation of the collision ellipsoid. - /** By default, the ellipsoid for collision detection is - created around the center of the scene node, which means that - the ellipsoid surrounds it completely. If this is not what you - want, you may specify a translation for the ellipsoid. - \param translation: Translation of the ellipsoid relative - to the position of the scene node. */ - virtual void setEllipsoidTranslation(const core::vector3df &translation) = 0; - - //! Get the translation of the ellipsoid for collision detection. - /** See - ISceneNodeAnimatorCollisionResponse::setEllipsoidTranslation() - for more details. - \return Translation of the ellipsoid relative to the position - of the scene node. */ - virtual core::vector3df getEllipsoidTranslation() const = 0; - - //! Sets a triangle selector holding all triangles of the world with which the scene node may collide. - /** \param newWorld: New triangle selector containing triangles - to let the scene node collide with. */ - virtual void setWorld(ITriangleSelector* newWorld) = 0; - - //! Get the current triangle selector containing all triangles for collision detection. - virtual ITriangleSelector* getWorld() const = 0; - - //! Set the single node that this animator will act on. - /** \param node The new target node. Setting this will force the animator to update - its last target position for the node, allowing setPosition() to teleport - the node through collision geometry. */ - virtual void setTargetNode(ISceneNode * node) = 0; - - //! Gets the single node that this animator is acting on. - /** \return The node that this animator is acting on. */ - virtual ISceneNode* getTargetNode(void) const = 0; - - //! Returns true if a collision occurred during the last animateNode() - virtual bool collisionOccurred() const = 0; - - //! Returns the last point of collision. - virtual const core::vector3df & getCollisionPoint() const = 0; - - //! Returns the last triangle that caused a collision - virtual const core::triangle3df & getCollisionTriangle() const = 0; - - //! Returns the position that the target node will be moved to, unless the collision is consumed in a callback). - /** - If you have a collision callback registered, and it consumes the collision, then the - node will ignore the collision and will not stop at this position. Instead, it will - move fully to the position that caused the collision to occur. */ - virtual const core::vector3df & getCollisionResultPosition(void) const = 0; - - //! Returns the node that was collided with. - virtual const ISceneNode* getCollisionNode(void) const = 0; - - //! Sets a callback interface which will be called if a collision occurs. - /** \param callback: collision callback handler that will be called when a collision - occurs. Set this to 0 to disable the callback. - */ - virtual void setCollisionCallback(ICollisionCallback* callback) = 0; - - }; - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/ISceneNodeAnimatorFactory.h b/irrlicht-1.6/include/ISceneNodeAnimatorFactory.h deleted file mode 100644 index 589682b59..000000000 --- a/irrlicht-1.6/include/ISceneNodeAnimatorFactory.h +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_SCENE_NODE_ANIMATOR_FACTORY_H_INCLUDED__ -#define __I_SCENE_NODE_ANIMATOR_FACTORY_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "ESceneNodeAnimatorTypes.h" - -namespace irr -{ -namespace scene -{ - class ISceneNode; - class ISceneNodeAnimator; - - //! Interface for dynamic creation of scene node animators - /** To be able to add custom scene node animators to Irrlicht and to make it possible for the - scene manager to save and load those external animators, simply implement this - interface and register it in you scene manager via ISceneManager::registerSceneNodeAnimatorFactory. - Note: When implementing your own scene node factory, don't call ISceneNodeManager::grab() to - increase the reference counter of the scene node manager. This is not necessary because the - scene node manager will grab() the factory anyway, and otherwise cyclic references will - be created and the scene manager and all its nodes won't get deallocated. - */ - class ISceneNodeAnimatorFactory : public virtual IReferenceCounted - { - public: - - virtual ~ISceneNodeAnimatorFactory() {} - - //! creates a scene node animator based on its type id - /** \param type: Type of the scene node animator to add. - \param target: Target scene node of the new animator. - \return Returns pointer to the new scene node animator or null if not successful. You need to - drop this pointer after calling this, see IReferenceCounted::drop() for details. */ - virtual ISceneNodeAnimator* createSceneNodeAnimator(ESCENE_NODE_ANIMATOR_TYPE type, ISceneNode* target) = 0; - - //! creates a scene node animator based on its type name - /** \param typeName: Type of the scene node animator to add. - \param target: Target scene node of the new animator. - \return Returns pointer to the new scene node animator or null if not successful. You need to - drop this pointer after calling this, see IReferenceCounted::drop() for details. */ - virtual ISceneNodeAnimator* createSceneNodeAnimator(const c8* typeName, ISceneNode* target) = 0; - - //! returns amount of scene node animator types this factory is able to create - virtual u32 getCreatableSceneNodeAnimatorTypeCount() const = 0; - - //! returns type of a createable scene node animator type - /** \param idx: Index of scene node animator type in this factory. Must be a value between 0 and - getCreatableSceneNodeTypeCount() */ - virtual ESCENE_NODE_ANIMATOR_TYPE getCreateableSceneNodeAnimatorType(u32 idx) const = 0; - - //! returns type name of a createable scene node animator type - /** \param idx: Index of scene node animator type in this factory. Must be a value between 0 and - getCreatableSceneNodeAnimatorTypeCount() */ - virtual const c8* getCreateableSceneNodeAnimatorTypeName(u32 idx) const = 0; - - //! returns type name of a createable scene node animator type - /** \param type: Type of scene node animator. - \return: Returns name of scene node animator type if this factory can create the type, otherwise 0. */ - virtual const c8* getCreateableSceneNodeAnimatorTypeName(ESCENE_NODE_ANIMATOR_TYPE type) const = 0; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/ISceneNodeFactory.h b/irrlicht-1.6/include/ISceneNodeFactory.h deleted file mode 100644 index 798f702e2..000000000 --- a/irrlicht-1.6/include/ISceneNodeFactory.h +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_SCENE_NODE_FACTORY_H_INCLUDED__ -#define __I_SCENE_NODE_FACTORY_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "ESceneNodeTypes.h" - -namespace irr -{ - -namespace scene -{ - class ISceneNode; - - //! Interface for dynamic creation of scene nodes - /** To be able to add custom scene nodes to Irrlicht and to make it possible for the - scene manager to save and load those external scene nodes, simply implement this - interface and register it in you scene manager via ISceneManager::registerSceneNodeFactory. - Note: When implementing your own scene node factory, don't call ISceneNodeManager::grab() to - increase the reference counter of the scene node manager. This is not necessary because the - scene node manager will grab() the factory anyway, and otherwise cyclic references will - be created and the scene manager and all its nodes won't get deallocated. - */ - class ISceneNodeFactory : public virtual IReferenceCounted - { - public: - //! adds a scene node to the scene graph based on its type id - /** \param type: Type of the scene node to add. - \param parent: Parent scene node of the new node, can be null to add the scene node to the root. - \return Returns pointer to the new scene node or null if not successful. - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual ISceneNode* addSceneNode(ESCENE_NODE_TYPE type, ISceneNode* parent=0) = 0; - - //! adds a scene node to the scene graph based on its type name - /** \param typeName: Type name of the scene node to add. - \param parent: Parent scene node of the new node, can be null to add the scene node to the root. - \return Returns pointer to the new scene node or null if not successful. - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual ISceneNode* addSceneNode(const c8* typeName, ISceneNode* parent=0) = 0; - - //! returns amount of scene node types this factory is able to create - virtual u32 getCreatableSceneNodeTypeCount() const = 0; - - //! returns type of a createable scene node type - /** \param idx: Index of scene node type in this factory. Must be a value between 0 and - getCreatableSceneNodeTypeCount() */ - virtual ESCENE_NODE_TYPE getCreateableSceneNodeType(u32 idx) const = 0; - - //! returns type name of a createable scene node type by index - /** \param idx: Index of scene node type in this factory. Must be a value between 0 and - getCreatableSceneNodeTypeCount() */ - virtual const c8* getCreateableSceneNodeTypeName(u32 idx) const = 0; - - //! returns type name of a createable scene node type - /** \param type: Type of scene node. - \return: Returns name of scene node type if this factory can create the type, otherwise 0. */ - virtual const c8* getCreateableSceneNodeTypeName(ESCENE_NODE_TYPE type) const = 0; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/ISceneUserDataSerializer.h b/irrlicht-1.6/include/ISceneUserDataSerializer.h deleted file mode 100644 index 33c299da2..000000000 --- a/irrlicht-1.6/include/ISceneUserDataSerializer.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_SCENE_USER_DATA_SERIALIZER_H_INCLUDED__ -#define __I_SCENE_USER_DATA_SERIALIZER_H_INCLUDED__ - -#include "IReferenceCounted.h" - -namespace irr -{ -namespace io -{ - class IAttributes; -} // end namespace io -namespace scene -{ - class ISceneNode; - -//! Interface to read and write user data to and from .irr files. -/** This interface is to be implemented by the user, to make it possible to read -and write user data when reading or writing .irr files via ISceneManager. -To be used with ISceneManager::loadScene() and ISceneManager::saveScene() */ -class ISceneUserDataSerializer -{ -public: - - virtual ~ISceneUserDataSerializer() {} - - //! Called when the scene manager create a scene node while loading a file. - virtual void OnCreateNode(ISceneNode* node) = 0; - - //! Called when the scene manager read a scene node while loading a file. - /** The userData pointer contains a list of attributes with userData which - were attached to the scene node in the read scene file.*/ - virtual void OnReadUserData(ISceneNode* forSceneNode, io::IAttributes* userData) = 0; - - //! Called when the scene manager is writing a scene node to an xml file for example. - /** Implement this method and return a list of attributes containing the user data - you want to be saved together with the scene node. Return 0 if no user data should - be added. Please note that the scene manager will call drop() to the returned pointer - after it no longer needs it, so if you didn't create a new object for the return value - and returning a longer existing IAttributes object, simply call grab() before returning it. */ - virtual io::IAttributes* createUserData(ISceneNode* forSceneNode) = 0; -}; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IShaderConstantSetCallBack.h b/irrlicht-1.6/include/IShaderConstantSetCallBack.h deleted file mode 100644 index 84469710c..000000000 --- a/irrlicht-1.6/include/IShaderConstantSetCallBack.h +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_SHADER_CONSTANT_SET_CALLBACT_H_INCLUDED__ -#define __I_SHADER_CONSTANT_SET_CALLBACT_H_INCLUDED__ - -#include "IReferenceCounted.h" - -namespace irr -{ -namespace video -{ - class IMaterialRendererServices; - -//! Interface making it possible to set constants for gpu programs every frame. -/** Implement this interface in an own class and pass a pointer to it to one of -the methods in IGPUProgrammingServices when creating a shader. The -OnSetConstants method will be called every frame now. */ -class IShaderConstantSetCallBack : public virtual IReferenceCounted -{ -public: - - //! Called to let the callBack know the used material (optional method) - /** - \code - class MyCallBack : public IShaderConstantSetCallBack - { - const video::SMaterial *UsedMaterial; - - OnSetMaterial(const video::SMaterial& material) - { - UsedMaterial=&material; - } - - OnSetConstants(IMaterialRendererServices* services, s32 userData) - { - services->setVertexShaderConstant("myColor", reinterpret_cast<f32*>(&UsedMaterial->color), 4); - } - } - \endcode - */ - virtual void OnSetMaterial(const SMaterial& material) { } - - //! Called by the engine when the vertex and/or pixel shader constants for an material renderer should be set. - /** - Implement the IShaderConstantSetCallBack in an own class and implement your own - OnSetConstants method using the given IMaterialRendererServices interface. - Pass a pointer to this class to one of the methods in IGPUProgrammingServices - when creating a shader. The OnSetConstants method will now be called every time - before geometry is being drawn using your shader material. A sample implementation - would look like this: - \code - virtual void OnSetConstants(video::IMaterialRendererServices* services, s32 userData) - { - video::IVideoDriver* driver = services->getVideoDriver(); - - // set clip matrix at register 4 - core::matrix4 worldViewProj(driver->getTransform(video::ETS_PROJECTION)); - worldViewProj *= driver->getTransform(video::ETS_VIEW); - worldViewProj *= driver->getTransform(video::ETS_WORLD); - services->setVertexShaderConstant(&worldViewProj.M[0], 4, 4); - // for high level shading languages, this would be another solution: - //services->setVertexShaderConstant("mWorldViewProj", worldViewProj.M, 16); - - // set some light color at register 9 - video::SColorf col(0.0f,1.0f,1.0f,0.0f); - services->setVertexShaderConstant(reinterpret_cast<const f32*>(&col), 9, 1); - // for high level shading languages, this would be another solution: - //services->setVertexShaderConstant("myColor", reinterpret_cast<f32*>(&col), 4); - } - \endcode - \param services: Pointer to an interface providing methods to set the constants for the shader. - \param userData: Userdata int which can be specified when creating the shader. - */ - virtual void OnSetConstants(IMaterialRendererServices* services, s32 userData) = 0; -}; - - -} // end namespace video -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IShadowVolumeSceneNode.h b/irrlicht-1.6/include/IShadowVolumeSceneNode.h deleted file mode 100644 index e0e838f63..000000000 --- a/irrlicht-1.6/include/IShadowVolumeSceneNode.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_SHADOW_VOLUME_SCENE_NODE_H_INCLUDED__ -#define __I_SHADOW_VOLUME_SCENE_NODE_H_INCLUDED__ - -#include "ISceneNode.h" - -namespace irr -{ -namespace scene -{ - class IMesh; - - //! Scene node for rendering a shadow volume into a stencil buffer. - class IShadowVolumeSceneNode : public ISceneNode - { - public: - - //! constructor - IShadowVolumeSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id) - : ISceneNode(parent, mgr, id) {} - - //! Sets the mesh from which the shadow volume should be generated. - /** To optimize shadow rendering, use a simpler mesh for shadows. - */ - virtual void setShadowMesh(const IMesh* mesh) = 0; - - //! Updates the shadow volumes for current light positions. - virtual void updateShadowVolumes() = 0; - }; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/ISkinnedMesh.h b/irrlicht-1.6/include/ISkinnedMesh.h deleted file mode 100644 index 2c8b5bb68..000000000 --- a/irrlicht-1.6/include/ISkinnedMesh.h +++ /dev/null @@ -1,221 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_SKINNED_MESH_H_INCLUDED__ -#define __I_SKINNED_MESH_H_INCLUDED__ - -#include "irrArray.h" -#include "IBoneSceneNode.h" -#include "IAnimatedMesh.h" -#include "SSkinMeshBuffer.h" - -namespace irr -{ -namespace scene -{ - - enum E_INTERPOLATION_MODE - { - // constant interpolation - EIM_CONSTANT = 0, - - // linear interpolation - EIM_LINEAR, - - //! count of all available interpolation modes - EIM_COUNT - }; - - - //! Interface for using some special functions of Skinned meshes - class ISkinnedMesh : public IAnimatedMesh - { - public: - - //! Gets joint count. - /** \return Amount of joints in the skeletal animated mesh. */ - virtual u32 getJointCount() const = 0; - - //! Gets the name of a joint. - /** \param number: Zero based index of joint. The last joint - has the number getJointCount()-1; - \return Name of joint and null if an error happened. */ - virtual const c8* getJointName(u32 number) const = 0; - - //! Gets a joint number from its name - /** \param name: Name of the joint. - \return Number of the joint or -1 if not found. */ - virtual s32 getJointNumber(const c8* name) const = 0; - - //! Use animation from another mesh - /** The animation is linked (not copied) based on joint names - so make sure they are unique. - \return True if all joints in this mesh were - matched up (empty names will not be matched, and it's case - sensitive). Unmatched joints will not be animated. */ - virtual bool useAnimationFrom(const ISkinnedMesh *mesh) = 0; - - //! Update Normals when Animating - /** \param on If false don't animate, which is faster. - Else update normals, which allows for proper lighting of - animated meshes. */ - virtual void updateNormalsWhenAnimating(bool on) = 0; - - //! Sets Interpolation Mode - virtual void setInterpolationMode(E_INTERPOLATION_MODE mode) = 0; - - //! Animates this mesh's joints based on frame input - virtual void animateMesh(f32 frame, f32 blend)=0; - - //! Preforms a software skin on this mesh based of joint positions - virtual void skinMesh() = 0; - - //! converts the vertex type of all meshbuffers to tangents. - /** E.g. used for bump mapping. */ - virtual void convertMeshToTangents() = 0; - - //! Allows to enable hardware skinning. - /* This feature is not implementated in Irrlicht yet */ - virtual bool setHardwareSkinning(bool on) = 0; - - //! A vertex weight - struct SWeight - { - //! Index of the mesh buffer - u16 buffer_id; //I doubt 32bits is needed - - //! Index of the vertex - u32 vertex_id; //Store global ID here - - //! Weight Strength/Percentage (0-1) - f32 strength; - - private: - //! Internal members used by CSkinnedMesh - friend class CSkinnedMesh; - bool *Moved; - core::vector3df StaticPos; - core::vector3df StaticNormal; - }; - - - //! Animation keyframe which describes a new position - struct SPositionKey - { - f32 frame; - core::vector3df position; - }; - - //! Animation keyframe which describes a new scale - struct SScaleKey - { - f32 frame; - core::vector3df scale; - }; - - //! Animation keyframe which describes a new rotation - struct SRotationKey - { - f32 frame; - core::quaternion rotation; - }; - - //! Joints - struct SJoint - { - SJoint() : UseAnimationFrom(0), LocalAnimatedMatrix_Animated(false), GlobalSkinningSpace(false), - positionHint(-1),scaleHint(-1),rotationHint(-1) - { - } - - //! The name of this joint - core::stringc Name; - - //! Local matrix of this joint - core::matrix4 LocalMatrix; - - //! List of child joints - core::array<SJoint*> Children; - - //! List of attached meshes - core::array<u32> AttachedMeshes; - - //! Animation keys causing translation change - core::array<SPositionKey> PositionKeys; - - //! Animation keys causing scale change - core::array<SScaleKey> ScaleKeys; - - //! Animation keys causing rotation change - core::array<SRotationKey> RotationKeys; - - //! Skin weights - core::array<SWeight> Weights; - - //! Unnecessary for loaders, will be overwritten on finalize - core::matrix4 GlobalMatrix; - core::matrix4 GlobalAnimatedMatrix; - core::matrix4 LocalAnimatedMatrix; - core::vector3df Animatedposition; - core::vector3df Animatedscale; - core::quaternion Animatedrotation; - - core::matrix4 GlobalInversedMatrix; //the x format pre-calculates this - - private: - //! Internal members used by CSkinnedMesh - friend class CSkinnedMesh; - - SJoint *UseAnimationFrom; - bool LocalAnimatedMatrix_Animated; - - bool GlobalSkinningSpace; - - s32 positionHint; - s32 scaleHint; - s32 rotationHint; - }; - - - //Interface for the mesh loaders (finalize should lock these functions, and they should have some prefix like loader_ - - //these functions will use the needed arrays, set values, etc to help the loaders - - //! exposed for loaders: to add mesh buffers - virtual core::array<SSkinMeshBuffer*>& getMeshBuffers() = 0; - - //! exposed for loaders: joints list - virtual core::array<SJoint*>& getAllJoints() = 0; - - //! exposed for loaders: joints list - virtual const core::array<SJoint*>& getAllJoints() const = 0; - - //! loaders should call this after populating the mesh - virtual void finalize() = 0; - - //! Adds a new meshbuffer to the mesh, access it as last one - virtual SSkinMeshBuffer* addMeshBuffer() = 0; - - //! Adds a new joint to the mesh, access it as last one - virtual SJoint* addJoint(SJoint *parent=0) = 0; - - //! Adds a new weight to the mesh, access it as last one - virtual SWeight* addWeight(SJoint *joint) = 0; - - //! Adds a new position key to the mesh, access it as last one - virtual SPositionKey* addPositionKey(SJoint *joint) = 0; - //! Adds a new scale key to the mesh, access it as last one - virtual SScaleKey* addScaleKey(SJoint *joint) = 0; - //! Adds a new rotation key to the mesh, access it as last one - virtual SRotationKey* addRotationKey(SJoint *joint) = 0; - - //! Check if the mesh is non-animated - virtual bool isStatic()=0; - }; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/ITerrainSceneNode.h b/irrlicht-1.6/include/ITerrainSceneNode.h deleted file mode 100644 index 88f645334..000000000 --- a/irrlicht-1.6/include/ITerrainSceneNode.h +++ /dev/null @@ -1,182 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -// The code for the TerrainSceneNode is based on the terrain renderer by -// Soconne and the GeoMipMapSceneNode developed by Spintz. They made their -// code available for Irrlicht and allowed it to be distributed under this -// licence. I only modified some parts. A lot of thanks go to them. - -#ifndef __I_TERRAIN_SCENE_NODE_H__ -#define __I_TERRAIN_SCENE_NODE_H__ - -#include "ETerrainElements.h" -#include "ISceneNode.h" -#include "IDynamicMeshBuffer.h" -#include "irrArray.h" - -namespace irr -{ -namespace io -{ - class IReadFile; -} // end namespace io -namespace scene -{ - class IMesh; - - //! A scene node for displaying terrain using the geo mip map algorithm. - /** The code for the TerrainSceneNode is based on the Terrain renderer by Soconne and - * the GeoMipMapSceneNode developed by Spintz. They made their code available for Irrlicht - * and allowed it to be distributed under this licence. I only modified some parts. - * A lot of thanks go to them. - * - * This scene node is capable of very quickly loading - * terrains and updating the indices at runtime to enable viewing very large terrains. It uses a - * CLOD (Continuous Level of Detail) algorithm which updates the indices for each patch based on - * a LOD (Level of Detail) which is determined based on a patch's distance from the camera. - * - * The Patch Size of the terrain must always be a size of ( 2^N+1, i.e. 8+1(9), 16+1(17), etc. ). - * The MaxLOD available is directly dependent on the patch size of the terrain. LOD 0 contains all - * of the indices to draw all the triangles at the max detail for a patch. As each LOD goes up by 1 - * the step taken, in generating indices increases by - 2^LOD, so for LOD 1, the step taken is 2, for - * LOD 2, the step taken is 4, LOD 3 - 8, etc. The step can be no larger than the size of the patch, - * so having a LOD of 8, with a patch size of 17, is asking the algoritm to generate indices every - * 2^8 ( 256 ) vertices, which is not possible with a patch size of 17. The maximum LOD for a patch - * size of 17 is 2^4 ( 16 ). So, with a MaxLOD of 5, you'll have LOD 0 ( full detail ), LOD 1 ( every - * 2 vertices ), LOD 2 ( every 4 vertices ), LOD 3 ( every 8 vertices ) and LOD 4 ( every 16 vertices ). - **/ - class ITerrainSceneNode : public ISceneNode - { - public: - //! Constructor - ITerrainSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position = core::vector3df(0.0f, 0.0f, 0.0f), - const core::vector3df& rotation = core::vector3df(0.0f, 0.0f, 0.0f), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f) ) - : ISceneNode (parent, mgr, id, position, rotation, scale) {} - - //! Get the bounding box of the terrain. - /** \return The bounding box of the entire terrain. */ - virtual const core::aabbox3d<f32>& getBoundingBox() const =0; - - //! Get the bounding box of a patch - /** \return The bounding box of the chosen patch. */ - virtual const core::aabbox3d<f32>& getBoundingBox(s32 patchX, s32 patchZ) const =0; - - //! Get the number of indices currently in the meshbuffer - /** \return The index count. */ - virtual u32 getIndexCount() const =0; - - //! Get pointer to the mesh - /** \return Pointer to the mesh. */ - virtual IMesh* getMesh() =0; - - //! Get pointer to the buffer used by the terrain (most users will not need this) - virtual IMeshBuffer* getRenderBuffer() =0; - - - //! Gets the meshbuffer data based on a specified level of detail. - /** \param mb A reference to an IDynamicMeshBuffer object - \param LOD The level of detail you want the indices from. */ - virtual void getMeshBufferForLOD(IDynamicMeshBuffer& mb, s32 LOD=0) const =0; - - //! Gets the indices for a specified patch at a specified Level of Detail. - /** \param indices A reference to an array of u32 indices. - \param patchX Patch x coordinate. - \param patchZ Patch z coordinate. - \param LOD The level of detail to get for that patch. If -1, - then get the CurrentLOD. If the CurrentLOD is set to -1, - meaning it's not shown, then it will retrieve the triangles at - the highest LOD (0). - \return Number of indices put into the buffer. */ - virtual s32 getIndicesForPatch(core::array<u32>& indices, - s32 patchX, s32 patchZ, s32 LOD=0) =0; - - //! Populates an array with the CurrentLOD of each patch. - /** \param LODs A reference to a core::array<s32> to hold the - values - \return Number of elements in the array */ - virtual s32 getCurrentLODOfPatches(core::array<s32>& LODs) const =0; - - //! Manually sets the LOD of a patch - /** \param patchX Patch x coordinate. - \param patchZ Patch z coordinate. - \param LOD The level of detail to set the patch to. */ - virtual void setLODOfPatch(s32 patchX, s32 patchZ, s32 LOD=0) =0; - - //! Get center of terrain. - virtual const core::vector3df& getTerrainCenter() const =0; - - //! Get height of a point of the terrain. - virtual f32 getHeight(f32 x, f32 y) const =0; - - //! Sets the movement camera threshold. - /** It is used to determine when to recalculate - indices for the scene node. The default value is 10.0f. */ - virtual void setCameraMovementDelta(f32 delta) =0; - - //! Sets the rotation camera threshold. - /** It is used to determine when to recalculate - indices for the scene node. The default value is 1.0f. */ - virtual void setCameraRotationDelta(f32 delta) =0; - - //! Sets whether or not the node should dynamically update its associated selector when the geomipmap data changes. - /** \param bVal: Boolean value representing whether or not to update selector dynamically. */ - virtual void setDynamicSelectorUpdate(bool bVal) =0; - - //! Override the default generation of distance thresholds. - /** For determining the LOD a patch is rendered at. If any LOD - is overridden, then the scene node will no longer apply scaling - factors to these values. If you override these distances, and - then apply a scale to the scene node, it is your responsibility - to update the new distances to work best with your new terrain - size. */ - virtual bool overrideLODDistance(s32 LOD, f64 newDistance) =0; - - //! Scales the base texture, similar to makePlanarTextureMapping. - /** \param scale The scaling amount. Values above 1.0 - increase the number of time the texture is drawn on the - terrain. Values below 0 will decrease the number of times the - texture is drawn on the terrain. Using negative values will - flip the texture, as well as still scaling it. - \param scale2 If set to 0 (default value), this will set the - second texture coordinate set to the same values as in the - first set. If this is another value than zero, it will scale - the second texture coordinate set by this value. */ - virtual void scaleTexture(f32 scale = 1.0f, f32 scale2=0.0f) =0; - - //! Initializes the terrain data. Loads the vertices from the heightMapFile. - /** The file must contain a loadable image of the heightmap. The heightmap - must be square. - \param file The file to read the image from. File is not rewinded. - \param vertexColor Color of all vertices. - \param smoothFactor Number of smoothing passes. */ - virtual bool loadHeightMap(io::IReadFile* file, - video::SColor vertexColor=video::SColor(255,255,255,255), - s32 smoothFactor=0) =0; - - //! Initializes the terrain data. Loads the vertices from the heightMapFile. - /** The data is interpreted as (signed) integers of the given bit size or - floats (with 32bits, signed). Allowed bitsizes for integers are - 8, 16, and 32. The heightmap must be square. - \param file The file to read the RAW data from. File is not rewinded. - \param bitsPerPixel Size of data if integers used, for floats always use 32. - \param signedData Whether we use signed or unsigned ints, ignored for floats. - \param floatVals Whether the data is float or int. - \param width Width (and also Height, as it must be square) of the heightmap. Use 0 for autocalculating from the filesize. - \param vertexColor Color of all vertices. - \param smoothFactor Number of smoothing passes. */ - virtual bool loadHeightMapRAW(io::IReadFile* file, s32 bitsPerPixel=16, - bool signedData=false, bool floatVals=false, s32 width=0, - video::SColor vertexColor=video::SColor(255,255,255,255), - s32 smoothFactor=0) =0; - - }; - -} // end namespace scene -} // end namespace irr - - -#endif // __I_TERRAIN_SCENE_NODE_H__ - diff --git a/irrlicht-1.6/include/ITextSceneNode.h b/irrlicht-1.6/include/ITextSceneNode.h deleted file mode 100644 index 9542199e0..000000000 --- a/irrlicht-1.6/include/ITextSceneNode.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_TEXT_SCENE_NODE_H_INCLUDED__ -#define __I_TEXT_SCENE_NODE_H_INCLUDED__ - -#include "ISceneNode.h" - -namespace irr -{ -namespace scene -{ - -//! A scene node for displaying 2d text at a position in three dimensional space -class ITextSceneNode : public ISceneNode -{ -public: - - //! constructor - ITextSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position = core::vector3df(0,0,0)) - : ISceneNode(parent, mgr, id, position) {} - - //! sets the text string - virtual void setText(const wchar_t* text) = 0; - - //! sets the color of the text - virtual void setTextColor(video::SColor color) = 0; -}; - -} // end namespace scene -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/include/ITexture.h b/irrlicht-1.6/include/ITexture.h deleted file mode 100644 index 62d4c3ac9..000000000 --- a/irrlicht-1.6/include/ITexture.h +++ /dev/null @@ -1,189 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_TEXTURE_H_INCLUDED__ -#define __I_TEXTURE_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "IImage.h" -#include "dimension2d.h" -#include "EDriverTypes.h" -#include "path.h" -#include "matrix4.h" - -namespace irr -{ -namespace video -{ - - -//! Enumeration flags telling the video driver in which format textures should be created. -enum E_TEXTURE_CREATION_FLAG -{ - /** Forces the driver to create 16 bit textures always, independent of - which format the file on disk has. When choosing this you may loose - some color detail, but gain much speed and memory. 16 bit textures can - be transferred twice as fast as 32 bit textures and only use half of - the space in memory. - When using this flag, it does not make sense to use the flags - ETCF_ALWAYS_32_BIT, ETCF_OPTIMIZED_FOR_QUALITY, or - ETCF_OPTIMIZED_FOR_SPEED at the same time. */ - ETCF_ALWAYS_16_BIT = 0x00000001, - - /** Forces the driver to create 32 bit textures always, independent of - which format the file on disk has. Please note that some drivers (like - the software device) will ignore this, because they are only able to - create and use 16 bit textures. - When using this flag, it does not make sense to use the flags - ETCF_ALWAYS_16_BIT, ETCF_OPTIMIZED_FOR_QUALITY, or - ETCF_OPTIMIZED_FOR_SPEED at the same time. */ - ETCF_ALWAYS_32_BIT = 0x00000002, - - /** Lets the driver decide in which format the textures are created and - tries to make the textures look as good as possible. Usually it simply - chooses the format in which the texture was stored on disk. - When using this flag, it does not make sense to use the flags - ETCF_ALWAYS_16_BIT, ETCF_ALWAYS_32_BIT, or ETCF_OPTIMIZED_FOR_SPEED at - the same time. */ - ETCF_OPTIMIZED_FOR_QUALITY = 0x00000004, - - /** Lets the driver decide in which format the textures are created and - tries to create them maximizing render speed. - When using this flag, it does not make sense to use the flags - ETCF_ALWAYS_16_BIT, ETCF_ALWAYS_32_BIT, or ETCF_OPTIMIZED_FOR_QUALITY, - at the same time. */ - ETCF_OPTIMIZED_FOR_SPEED = 0x00000008, - - /** Automatically creates mip map levels for the textures. */ - ETCF_CREATE_MIP_MAPS = 0x00000010, - - /** Discard any alpha layer and use non-alpha color format. */ - ETCF_NO_ALPHA_CHANNEL = 0x00000020, - - //! Allow the Driver to use Non-Power-2-Textures - /** BurningVideo can handle Non-Power-2 Textures in 2D (GUI), but not it 3D. */ - ETCF_ALLOW_NON_POWER_2 = 0x00000040, - - /** This flag is never used, it only forces the compiler to compile - these enumeration values to 32 bit. */ - ETCF_FORCE_32_BIT_DO_NOT_USE = 0x7fffffff -}; - - -//! Helper function, helps to get the desired texture creation format from the flags. -/** \return Either ETCF_ALWAYS_32_BIT, ETCF_ALWAYS_16_BIT, -ETCF_OPTIMIZED_FOR_QUALITY, or ETCF_OPTIMIZED_FOR_SPEED. */ -inline E_TEXTURE_CREATION_FLAG getTextureFormatFromFlags(u32 flags) -{ - if (flags & ETCF_OPTIMIZED_FOR_SPEED) - return ETCF_OPTIMIZED_FOR_SPEED; - if (flags & ETCF_ALWAYS_16_BIT) - return ETCF_ALWAYS_16_BIT; - if (flags & ETCF_ALWAYS_32_BIT) - return ETCF_ALWAYS_32_BIT; - if (flags & ETCF_OPTIMIZED_FOR_QUALITY) - return ETCF_OPTIMIZED_FOR_QUALITY; - return ETCF_OPTIMIZED_FOR_SPEED; -} - - -//! Interface of a Video Driver dependent Texture. -/** An ITexture is created by an IVideoDriver by using IVideoDriver::addTexture -or IVideoDriver::getTexture. After that, the texture may only be used by this -VideoDriver. As you can imagine, textures of the DirectX and the OpenGL device -will, e.g., not be compatible. An exception is the Software device and the -NULL device, their textures are compatible. If you try to use a texture -created by one device with an other device, the device will refuse to do that -and write a warning or an error message to the output buffer. -*/ -class ITexture : public virtual IReferenceCounted -{ -public: - - //! constructor - ITexture(const io::path& name) : Name(name) - { - Name.make_lower(); - } - - //! Lock function. - /** Locks the Texture and returns a pointer to access the - pixels. After lock() has been called and all operations on the pixels - are done, you must call unlock(). - Locks are not accumulating, hence one unlock will do for an arbitrary - number of previous locks. - \param readOnly Specifies that no changes to the locked texture are - made. Unspecified behavior will arise if still write access happens. - \return Returns a pointer to the pixel data. The format of the pixel can - be determined by using getColorFormat(). 0 is returned, if - the texture cannot be locked. */ - virtual void* lock(bool readOnly = false) = 0; - - //! Unlock function. Must be called after a lock() to the texture. - /** One should avoid to call unlock more than once before another lock. */ - virtual void unlock() = 0; - - //! Get original size of the texture. - /** The texture is usually scaled, if it was created with an unoptimal - size. For example if the size of the texture file it was loaded from - was not a power of two. This returns the size of the texture, it had - before it was scaled. Can be useful when drawing 2d images on the - screen, which should have the exact size of the original texture. Use - ITexture::getSize() if you want to know the real size it has now stored - in the system. - \return The original size of the texture. */ - virtual const core::dimension2d<u32>& getOriginalSize() const = 0; - - //! Get dimension (=size) of the texture. - /** \return The size of the texture. */ - virtual const core::dimension2d<u32>& getSize() const = 0; - - //! Get driver type of texture. - /** This is the driver, which created the texture. This method is used - internally by the video devices, to check, if they may use a texture - because textures may be incompatible between different devices. - \return Driver type of texture. */ - virtual E_DRIVER_TYPE getDriverType() const = 0; - - //! Get the color format of texture. - /** \return The color format of texture. */ - virtual ECOLOR_FORMAT getColorFormat() const = 0; - - //! Get pitch of texture (in bytes). - /** The pitch is the amount of bytes used for a row of pixels in a - texture. - \return Pitch of texture in bytes. */ - virtual u32 getPitch() const = 0; - - //! Check whether the texture has MipMaps - /** \return True if texture has MipMaps, else false. */ - virtual bool hasMipMaps() const { return false; } - - //! Returns if the texture has an alpha channel - virtual bool hasAlpha() const { - return getColorFormat () == video::ECF_A8R8G8B8 || getColorFormat () == video::ECF_A1R5G5B5; - } - - //! Regenerates the mip map levels of the texture. - /** Required after modifying the texture, usually after calling unlock(). */ - virtual void regenerateMipMapLevels() = 0; - - //! Check whether the texture is a render target - /** \return True if this is a render target, otherwise false. */ - virtual bool isRenderTarget() const { return false; } - - //! Get name of texture (in most cases this is the filename) - const io::path& getName() const { return Name; } - -protected: - - io::path Name; -}; - - -} // end namespace video -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/ITimer.h b/irrlicht-1.6/include/ITimer.h deleted file mode 100644 index 104225eed..000000000 --- a/irrlicht-1.6/include/ITimer.h +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_TIMER_H_INCLUDED__ -#define __I_TIMER_H_INCLUDED__ - -#include "IReferenceCounted.h" - -namespace irr -{ - -//! Interface for getting and manipulating the virtual time -class ITimer : public virtual IReferenceCounted -{ -public: - - //! destructor - virtual ~ITimer() {} - - //! Returns current real time in milliseconds of the system. - /** This value does not start with 0 when the application starts. - For example in one implementation the value returned could be the - amount of milliseconds which have elapsed since the system was started. - */ - virtual u32 getRealTime() const = 0; - - //! Returns current virtual time in milliseconds. - /** This value starts with 0 and can be manipulated using setTime(), - stopTimer(), startTimer(), etc. This value depends on the set speed of - the timer if the timer is stopped, etc. If you need the system time, - use getRealTime() */ - virtual u32 getTime() const = 0; - - //! sets current virtual time - virtual void setTime(u32 time) = 0; - - //! Stops the virtual timer. - /** The timer is reference counted, which means everything which calls - stop() will also have to call start(), otherwise the timer may not - start/stop correctly again. */ - virtual void stop() = 0; - - //! Starts the virtual timer. - /** The timer is reference counted, which means everything which calls - stop() will also have to call start(), otherwise the timer may not - start/stop correctly again. */ - virtual void start() = 0; - - //! Sets the speed of the timer - /** The speed is the factor with which the time is running faster or - slower then the real system time. */ - virtual void setSpeed(f32 speed = 1.0f) = 0; - - //! Returns current speed of the timer - /** The speed is the factor with which the time is running faster or - slower then the real system time. */ - virtual f32 getSpeed() const = 0; - - //! Returns if the virtual timer is currently stopped - virtual bool isStopped() const = 0; - - //! Advances the virtual time - /** Makes the virtual timer update the time value based on the real - time. This is called automatically when calling IrrlichtDevice::run(), - but you can call it manually if you don't use this method. */ - virtual void tick() = 0; -}; - -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/ITriangleSelector.h b/irrlicht-1.6/include/ITriangleSelector.h deleted file mode 100644 index 65de25922..000000000 --- a/irrlicht-1.6/include/ITriangleSelector.h +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_TRIANGLE_SELECTOR_H_INCLUDED__ -#define __I_TRIANGLE_SELECTOR_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "triangle3d.h" -#include "aabbox3d.h" -#include "matrix4.h" -#include "line3d.h" - -namespace irr -{ -namespace scene -{ - -class ISceneNode; - -//! Interface to return triangles with specific properties. -/** Every ISceneNode may have a triangle selector, available with -ISceneNode::getTriangleScelector() or ISceneManager::createTriangleSelector. -This is used for doing collision detection: For example if you know, that a -collision may have happened in the area between (1,1,1) and (10,10,10), you -can get all triangles of the scene node in this area with the -ITriangleSelector easily and check every triangle if it collided. */ -class ITriangleSelector : public virtual IReferenceCounted -{ -public: - - //! Destructor - virtual ~ITriangleSelector() {} - - //! Returns amount of all available triangles in this selector - virtual s32 getTriangleCount() const = 0; - - //! Gets the triangles for one associated node. - /** - This returns all triangles for one scene node associated with this - selector. If there is more than one scene node associated (e.g. for - an IMetaTriangleSelector) this this function may be called multiple - times to retrieve all triangles. - \param triangles: Array where the resulting triangles will be - written to. - \param arraySize: Size of the target array. - \param outTriangleCount: Amount of triangles which have been written - into the array. - \param transform: Pointer to matrix for transforming the triangles - before they are returned. Useful for example to scale all triangles - down into an ellipsoid space. If this pointer is null, no - transformation will be done. */ - virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, - s32& outTriangleCount, const core::matrix4* transform=0) const = 0; - - //! Gets the triangles for one associated node which lie or may lie within a specific bounding box. - /** - This returns all triangles for one scene node associated with this - selector. If there is more than one scene node associated (e.g. for - an IMetaTriangleSelector) this this function may be called multiple - times to retrieve all triangles. - - Please note that unoptimized triangle selectors also may return - triangles which are not in the specified box at all. - \param triangles: Array where the resulting triangles will be written - to. - \param arraySize: Size of the target array. - \param outTriangleCount: Amount of triangles which have been written - into the array. - \param box: Only triangles which are in this axis aligned bounding box - will be written into the array. - \param transform: Pointer to matrix for transforming the triangles - before they are returned. Useful for example to scale all triangles - down into an ellipsoid space. If this pointer is null, no - transformation will be done. */ - virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, - s32& outTriangleCount, const core::aabbox3d<f32>& box, - const core::matrix4* transform=0) const = 0; - - //! Gets the triangles for one associated node which have or may have contact with a 3d line. - /** - This returns all triangles for one scene node associated with this - selector. If there is more than one scene node associated (e.g. for - an IMetaTriangleSelector) this this function may be called multiple - times to retrieve all triangles. - - Please note that unoptimized triangle selectors also may return - triangles which are not in contact at all with the 3d line. - \param triangles: Array where the resulting triangles will be written - to. - \param arraySize: Size of the target array. - \param outTriangleCount: Amount of triangles which have been written - into the array. - \param line: Only triangles which may be in contact with this 3d line - will be written into the array. - \param transform: Pointer to matrix for transforming the triangles - before they are returned. Useful for example to scale all triangles - down into an ellipsoid space. If this pointer is null, no - transformation will be done. */ - virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, - s32& outTriangleCount, const core::line3d<f32>& line, - const core::matrix4* transform=0) const = 0; - - //! Return the scene node associated with a given triangle. - /** - This allows you to find which scene node (potentially of several) is - associated with a specific triangle. - - \param triangleIndex: the index of the triangle for which you want to find - the associated scene node. - \return The scene node associated with that triangle. - */ - virtual const ISceneNode* getSceneNodeForTriangle(u32 triangleIndex) const = 0; - -}; - -} // end namespace scene -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/include/IVertexBuffer.h b/irrlicht-1.6/include/IVertexBuffer.h deleted file mode 100644 index c90a0f7e3..000000000 --- a/irrlicht-1.6/include/IVertexBuffer.h +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2008-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_VERTEX_BUFFER_H_INCLUDED__ -#define __I_VERTEX_BUFFER_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "irrArray.h" -#include "S3DVertex.h" - -namespace irr -{ -namespace scene -{ - - class IVertexBuffer : public virtual IReferenceCounted - { - public: - virtual void* getData() =0; - virtual video::E_VERTEX_TYPE getType() const =0; - virtual void setType(video::E_VERTEX_TYPE vertexType) =0; - virtual u32 stride() const =0; - virtual u32 size() const =0; - virtual void push_back(const video::S3DVertex &element) =0; - virtual video::S3DVertex& operator [](const u32 index) const =0; - virtual video::S3DVertex& getLast() =0; - virtual void set_used(u32 usedNow) =0; - virtual void reallocate(u32 new_size) =0; - virtual u32 allocated_size() const =0; - virtual video::S3DVertex* pointer() =0; - - //! get the current hardware mapping hint - virtual E_HARDWARE_MAPPING getHardwareMappingHint() const =0; - - //! set the hardware mapping hint, for driver - virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint ) =0; - - //! flags the meshbuffer as changed, reloads hardware buffers - virtual void setDirty() =0; - - //! Get the currently used ID for identification of changes. - /** This shouldn't be used for anything outside the VideoDriver. */ - virtual u32 getChangedID() const = 0; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IVideoDriver.h b/irrlicht-1.6/include/IVideoDriver.h deleted file mode 100644 index bde254e97..000000000 --- a/irrlicht-1.6/include/IVideoDriver.h +++ /dev/null @@ -1,1263 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_I_VIDEO_DRIVER_H_INCLUDED__ -#define __IRR_I_VIDEO_DRIVER_H_INCLUDED__ - -#include "rect.h" -#include "SColor.h" -#include "ITexture.h" -#include "irrArray.h" -#include "matrix4.h" -#include "plane3d.h" -#include "dimension2d.h" -#include "position2d.h" -#include "SMaterial.h" -#include "IMeshBuffer.h" -#include "triangle3d.h" -#include "EDriverTypes.h" -#include "EDriverFeatures.h" - -namespace irr -{ -namespace io -{ - class IAttributes; - class IReadFile; - class IWriteFile; -} // end namespace io -namespace scene -{ - class IMeshBuffer; - class IMeshManipulator; -} // end namespace scene - -namespace video -{ - struct S3DVertex; - struct S3DVertex2TCoords; - struct S3DVertexTangents; - struct SLight; - struct SExposedVideoData; - class IImageLoader; - class IImageWriter; - class IMaterialRenderer; - class IGPUProgrammingServices; - - //! enumeration for geometry transformation states - enum E_TRANSFORMATION_STATE - { - //! View transformation - ETS_VIEW = 0, - //! World transformation - ETS_WORLD, - //! Projection transformation - ETS_PROJECTION, - //! Texture transformation - ETS_TEXTURE_0, - //! Texture transformation - ETS_TEXTURE_1, - //! Texture transformation - ETS_TEXTURE_2, - //! Texture transformation - ETS_TEXTURE_3, -#if _IRR_MATERIAL_MAX_TEXTURES_>4 - //! Texture transformation - ETS_TEXTURE_4, -#if _IRR_MATERIAL_MAX_TEXTURES_>5 - //! Texture transformation - ETS_TEXTURE_5, -#if _IRR_MATERIAL_MAX_TEXTURES_>6 - //! Texture transformation - ETS_TEXTURE_6, -#if _IRR_MATERIAL_MAX_TEXTURES_>7 - //! Texture transformation - ETS_TEXTURE_7, -#endif -#endif -#endif -#endif - //! Not used - ETS_COUNT - }; - - //! enumeration for signalling ressources which were lost after the last render cycle - /** These values can be signalled by the driver, telling the app that some ressources - were lost and need to be recreated. Irrlicht will sometimes recreate the actual objects, - but the content needs to be recreated by the application. */ - enum E_LOST_RESSOURCE - { - //! The whole device/driver is lost - ELR_DEVICE = 1, - //! All texture are lost, rare problem - ELR_TEXTURES = 2, - //! The Render Target Textures are lost, typical problem for D3D - ELR_RTTS = 4, - //! The HW buffers are lost, will be recreated automatically, but might require some more time this frame - ELR_HW_BUFFERS = 8 - }; - - //! Special render targets, which usually map to dedicated hardware - /** These render targets (besides 0 and 1) need not be supported by gfx cards */ - enum E_RENDER_TARGET - { - //! Render target is the main color frame buffer - ERT_FRAME_BUFFER=0, - //! Render target is the main color frame buffer - ERT_STEREO_LEFT_BUFFER=0, - //! Render target is a render texture - ERT_RENDER_TEXTURE, - //! Render target is the right color buffer (left is the main buffer) - ERT_STEREO_RIGHT_BUFFER, - //! Render to both stereo buffers at once - ERT_STEREO_BOTH_BUFFERS, - //! Auxiliary buffer 0 - ERT_AUX_BUFFER0, - //! Auxiliary buffer 1 - ERT_AUX_BUFFER1, - //! Auxiliary buffer 2 - ERT_AUX_BUFFER2, - //! Auxiliary buffer 3 - ERT_AUX_BUFFER3, - //! Auxiliary buffer 4 - ERT_AUX_BUFFER4 - }; - - //! Enum for the types of fog distributions to choose from - enum E_FOG_TYPE - { - EFT_FOG_EXP=0, - EFT_FOG_LINEAR, - EFT_FOG_EXP2 - }; - - struct SOverrideMaterial - { - //! The Material values - SMaterial Material; - //! Which values are taken for override - /** OR'ed values from E_MATERIAL_FLAGS. */ - u32 EnableFlags; - //! Set in which render passes the material override is active. - /** OR'ed values from E_SCENE_NODE_RENDER_PASS. */ - u16 EnablePasses; - //! Global enable flag, overwritten by the SceneManager in each pass - /** The Scenemanager uses the EnablePass array and sets Enabled to - true if the Override material is enabled in the current pass. */ - bool Enabled; - - //! Default constructor - SOverrideMaterial() : EnableFlags(0), EnablePasses(0), Enabled(false) {} - - //! Apply the enabled overrides - void apply(SMaterial& material) - { - if (Enabled) - { - for (u32 i=0; i<32; ++i) - { - const u32 num=(1<<i); - if (EnableFlags & num) - { - switch (num) - { - case EMF_WIREFRAME: material.Wireframe = Material.Wireframe; break; - case EMF_POINTCLOUD: material.PointCloud = Material.PointCloud; break; - case EMF_GOURAUD_SHADING: material.GouraudShading = Material.GouraudShading; break; - case EMF_LIGHTING: material.Lighting = Material.Lighting; break; - case EMF_ZBUFFER: material.ZBuffer = Material.ZBuffer; break; - case EMF_ZWRITE_ENABLE: material.ZWriteEnable = Material.ZWriteEnable; break; - case EMF_BACK_FACE_CULLING: material.BackfaceCulling = Material.BackfaceCulling; break; - case EMF_FRONT_FACE_CULLING: material.FrontfaceCulling = Material.FrontfaceCulling; break; - case EMF_FOG_ENABLE: material.FogEnable = Material.FogEnable; break; - case EMF_NORMALIZE_NORMALS: material.NormalizeNormals = Material.NormalizeNormals; break; - case EMF_ANTI_ALIASING: material.AntiAliasing = Material.AntiAliasing; break; - case EMF_COLOR_MASK: material.ColorMask = Material.ColorMask; break; - case EMF_BILINEAR_FILTER: material.TextureLayer[0].BilinearFilter = Material.TextureLayer[0].BilinearFilter; break; - case EMF_TRILINEAR_FILTER: material.TextureLayer[0].TrilinearFilter = Material.TextureLayer[0].TrilinearFilter; break; - case EMF_ANISOTROPIC_FILTER: material.TextureLayer[0].AnisotropicFilter = Material.TextureLayer[0].AnisotropicFilter; break; - case EMF_TEXTURE_WRAP: material.TextureLayer[0].TextureWrap = Material.TextureLayer[0].TextureWrap; break; - } - } - } - } - } - - }; - - //! Interface to driver which is able to perform 2d and 3d graphics functions. - /** This interface is one of the most important interfaces of - the Irrlicht Engine: All rendering and texture manipulation is done with - this interface. You are able to use the Irrlicht Engine by only - invoking methods of this interface if you like to, although the - irr::scene::ISceneManager interface provides a lot of powerful classes - and methods to make the programmer's life easier. - */ - class IVideoDriver : public virtual IReferenceCounted - { - public: - - //! Applications must call this method before performing any rendering. - /** This method can clear the back- and the z-buffer. - \param backBuffer Specifies if the back buffer should be - cleared, which means that the screen is filled with the color - specified. If this parameter is false, the back buffer will - not be cleared and the color parameter is ignored. - \param zBuffer Specifies if the depth buffer (z buffer) should - be cleared. It is not nesesarry to do so if only 2d drawing is - used. - \param color The color used for back buffer clearing - \param windowId Handle of another window, if you want the - bitmap to be displayed on another window. If this is null, - everything will be displayed in the default window. - Note: This feature is not fully implemented for all devices. - \param sourceRect Pointer to a rectangle defining the source - rectangle of the area to be presented. Set to null to present - everything. Note: not implemented in all devices. - \return False if failed. */ - virtual bool beginScene(bool backBuffer=true, bool zBuffer=true, - SColor color=SColor(255,0,0,0), - void* windowId=0, - core::rect<s32>* sourceRect=0) =0; - - //! Presents the rendered image to the screen. - /** Applications must call this method after performing any - rendering. - \return False if failed and true if succeeded. */ - virtual bool endScene() =0; - - //! Queries the features of the driver. - /** Returns true if a feature is available - \param feature Feature to query. - \return True if the feature is available, false if not. */ - virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const =0; - - //! Disable a feature of the driver. - /** Can also be used to enable the features again. It is not - possible to enable unsupported features this way, though. - \param feature Feature to disable. - \param flag When true the feature is disabled, otherwise it is enabled. */ - virtual void disableFeature(E_VIDEO_DRIVER_FEATURE feature, bool flag=true) =0; - - //! Check if the driver was recently reset. - /** For d3d devices you will need to recreate the RTTs if the - driver was reset. Should be queried right after beginScene(). - */ - virtual bool checkDriverReset() =0; - - //! Sets transformation matrices. - /** \param state Transformation type to be set, e.g. view, - world, or projection. - \param mat Matrix describing the transformation. */ - virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat) =0; - - //! Returns the transformation set by setTransform - /** \param state Transformation type to query - \return Matrix describing the transformation. */ - virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) const =0; - - //! Retrieve the number of image loaders - /** \return Number of image loaders */ - virtual u32 getImageLoaderCount() const = 0; - - //! Retrieve the given image loader - /** \param n The index of the loader to retrieve. This parameter is an 0-based - array index. - \return A pointer to the specified loader, 0 if the index is uncorrect. */ - virtual IImageLoader* getImageLoader(u32 n) = 0; - - //! Retrieve the number of image writers - /** \return Number of image writers */ - virtual u32 getImageWriterCount() const = 0; - - //! Retrieve the given image writer - /** \param n The index of the writer to retrieve. This parameter is an 0-based - array index. - \return A pointer to the specified writer, 0 if the index is uncorrect. */ - virtual IImageWriter* getImageWriter(u32 n) = 0; - - //! Sets a material. - /** All 3d drawing functions will draw geometry using this material thereafter. - \param material: Material to be used from now on. */ - virtual void setMaterial(const SMaterial& material) =0; - - //! Get access to a named texture. - /** Loads the texture from disk if it is not - already loaded and generates mipmap levels if desired. - Texture loading can be influenced using the - setTextureCreationFlag() method. The texture can be in several - imageformats, such as BMP, JPG, TGA, PCX, PNG, and PSD. - \param filename Filename of the texture to be loaded. - \return Pointer to the texture, or 0 if the texture - could not be loaded. This pointer should not be dropped. See - IReferenceCounted::drop() for more information. */ - virtual ITexture* getTexture(const io::path& filename) = 0; - - //! Get access to a named texture. - /** Loads the texture from disk if it is not - already loaded and generates mipmap levels if desired. - Texture loading can be influenced using the - setTextureCreationFlag() method. The texture can be in several - imageformats, such as BMP, JPG, TGA, PCX, PNG, and PSD. - \param file Pointer to an already opened file. - \return Pointer to the texture, or 0 if the texture - could not be loaded. This pointer should not be dropped. See - IReferenceCounted::drop() for more information. */ - virtual ITexture* getTexture(io::IReadFile* file) =0; - - //! Returns a texture by index - /** \param index: Index of the texture, must be smaller than - getTextureCount() Please note that this index might change when - adding or removing textures - \return Pointer to the texture, or 0 if the texture was not - set or index is out of bounds. This pointer should not be - dropped. See IReferenceCounted::drop() for more information. */ - virtual ITexture* getTextureByIndex(u32 index) =0; - - //! Returns amount of textures currently loaded - /** \return Amount of textures currently loaded */ - virtual u32 getTextureCount() const = 0; - - //! Renames a texture - /** \param texture Pointer to the texture to rename. - \param newName New name for the texture. This should be a unique name. */ - virtual void renameTexture(ITexture* texture, const io::path& newName) = 0; - - //! Creates an empty texture of specified size. - /** \param size: Size of the texture. - \param name A name for the texture. Later calls to - getTexture() with this name will return this texture - \param format Desired color format of the texture. Please note - that the driver may choose to create the texture in another - color format. - \return Pointer to the newly created texture. This pointer - should not be dropped. See IReferenceCounted::drop() for more - information. */ - virtual ITexture* addTexture(const core::dimension2d<u32>& size, - const io::path& name, ECOLOR_FORMAT format = ECF_A8R8G8B8) = 0; - - //! Creates a texture from an IImage. - /** \param name A name for the texture. Later calls of - getTexture() with this name will return this texture - \param image Image the texture is created from. - \return Pointer to the newly created texture. This pointer - should not be dropped. See IReferenceCounted::drop() for more - information. */ - virtual ITexture* addTexture(const io::path& name, IImage* image) = 0; - - //! Adds a new render target texture to the texture cache. - /** \param size Size of the texture, in pixels. Width and - height should be a power of two (e.g. 64, 128, 256, 512, ...) - and it should not be bigger than the backbuffer, because it - shares the zbuffer with the screen buffer. - \param name An optional name for the RTT. - \param format The color format of the render target. Floating point formats are supported. - \return Pointer to the created texture or 0 if the texture - could not be created. This pointer should not be dropped. See - IReferenceCounted::drop() for more information. */ - virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size, - const io::path& name = "rt", const ECOLOR_FORMAT format = ECF_UNKNOWN) =0; - - //! Removes a texture from the texture cache and deletes it. - /** This method can free a lot of memory! - Please note that after calling this, the pointer to the - ITexture may no longer be valid, if it was not grabbed before - by other parts of the engine for storing it longer. So it is a - good idea to set all materials which are using this texture to - 0 or another texture first. - \param texture Texture to delete from the engine cache. */ - virtual void removeTexture(ITexture* texture) =0; - - //! Removes all textures from the texture cache and deletes them. - /** This method can free a lot of memory! - Please note that after calling this, the pointer to the - ITexture may no longer be valid, if it was not grabbed before - by other parts of the engine for storing it longer. So it is a - good idea to set all materials which are using this texture to - 0 or another texture first. */ - virtual void removeAllTextures() =0; - - //! Remove hardware buffer - virtual void removeHardwareBuffer(const scene::IMeshBuffer* mb) =0; - - //! Remove all hardware buffers - virtual void removeAllHardwareBuffers() =0; - - //! Sets a boolean alpha channel on the texture based on a color key. - /** This makes the texture fully transparent at the texels where - this color key can be found when using for example draw2DImage - with useAlphachannel==true. The alpha of other texels is not modified. - \param texture Texture whose alpha channel is modified. - \param color Color key color. Every texel with this color will - become fully transparent as described above. Please note that the - colors of a texture may be converted when loading it, so the - color values may not be exactly the same in the engine and for - example in picture edit programs. To avoid this problem, you - could use the makeColorKeyTexture method, which takes the - position of a pixel instead a color value. - \param \deprecated zeroTexels If set to true, then any texels that match - the color key will have their color, as well as their alpha, set to zero - (i.e. black). This behaviour matches the legacy (buggy) behaviour prior - to release 1.5 and is provided for backwards compatibility only.*/ - virtual void makeColorKeyTexture(video::ITexture* texture, - video::SColor color, - bool zeroTexels = false) const =0; - - //! Sets a boolean alpha channel on the texture based on the color at a position. - /** This makes the texture fully transparent at the texels where - the color key can be found when using for example draw2DImage - with useAlphachannel==true. The alpha of other texels is not modified. - \param texture Texture whose alpha channel is modified. - \param colorKeyPixelPos Position of a pixel with the color key - color. Every texel with this color will become fully transparent as - described above. - \param \deprecated zeroTexels If set to true, then any texels that match - the color key will have their color, as well as their alpha, set to zero - (i.e. black). This behaviour matches the legacy (buggy) behaviour prior - to release 1.5 and is provided for backwards compatibility only.*/ - virtual void makeColorKeyTexture(video::ITexture* texture, - core::position2d<s32> colorKeyPixelPos, - bool zeroTexels = false) const =0; - - //! Creates a normal map from a height map texture. - /** If the target texture has 32 bit, the height value is - stored in the alpha component of the texture as addition. This - value is used by the video::EMT_PARALLAX_MAP_SOLID material and - similar materials. - \param texture Texture whose alpha channel is modified. - \param amplitude Constant value by which the height - information is multiplied.*/ - virtual void makeNormalMapTexture(video::ITexture* texture, f32 amplitude=1.0f) const =0; - - //! Sets a new render target. - /** This will only work if the driver supports the - EVDF_RENDER_TO_TARGET feature, which can be queried with - queryFeature(). Usually, rendering to textures is done in this - way: - \code - // create render target - ITexture* target = driver->addRenderTargetTexture(core::dimension2d<u32>(128,128), "rtt1"); - - // ... - - driver->setRenderTarget(target); // set render target - // .. draw stuff here - driver->setRenderTarget(0); // set previous render target - \endcode - Please note that you cannot render 3D or 2D geometry with a - render target as texture on it when you are rendering the scene - into this render target at the same time. It is usually only - possible to render into a texture between the - IVideoDriver::beginScene() and endScene() method calls. - \param texture New render target. Must be a texture created with - IVideoDriver::addRenderTargetTexture(). If set to 0, it sets - the previous render target which was set before the last - setRenderTarget() call. - \param clearBackBuffer Clears the backbuffer of the render - target with the color parameter - \param clearZBuffer Clears the zBuffer of the rendertarget. - Note that because the frame buffer may share the zbuffer with - the rendertarget, its zbuffer might be partially cleared too - by this. - \param color The background color for the render target. - \return True if sucessful and false if not. */ - virtual bool setRenderTarget(video::ITexture* texture, - bool clearBackBuffer=true, bool clearZBuffer=true, - SColor color=video::SColor(0,0,0,0)) =0; - - //! set or reset special render targets - /** This method enables access to special color buffers such as - stereoscopic buffers or auxiliary buffers. - \param target Enum value for the render target - \param clearTarget Clears the target buffer with the color - parameter - \param clearZBuffer Clears the zBuffer of the rendertarget. - Note that because the main frame buffer may share the zbuffer with - the rendertarget, its zbuffer might be partially cleared too - by this. - \param color The background color for the render target. - \return True if sucessful and false if not. */ - virtual bool setRenderTarget(E_RENDER_TARGET target, bool clearTarget=true, - bool clearZBuffer=true, - SColor color=video::SColor(0,0,0,0)) =0; - - //! Sets a new viewport. - /** Every rendering operation is done into this new area. - \param area: Rectangle defining the new area of rendering - operations. */ - virtual void setViewPort(const core::rect<s32>& area) =0; - - //! Gets the area of the current viewport. - /** \return Rectangle of the current viewport. */ - virtual const core::rect<s32>& getViewPort() const =0; - - //! Draws a vertex primitive list - /** Note that, depending on the index type, some vertices might be not - accessible through the index list. The limit is at 65535 vertices for 16bit - indices. Please note that currently not all primitives are available for - all drivers, and some might be emulated via triangle renders. - \param vertices Pointer to array of vertices. - \param vertexCount Amount of vertices in the array. - \param indexList Pointer to array of indices. These define the vertices used - for each primitive. Depending on the pType, indices are interpreted as single - objects (for point like primitives), pairs (for lines), triplets (for - triangles), or quads. - \param primCount Amount of Primitives - \param vType Vertex type, e.g. video::EVT_STANDARD for S3DVertex. - \param pType Primitive type, e.g. scene::EPT_TRIANGLE_FAN for a triangle fan. - \param iType Index type, e.g. video::EIT_16BIT for 16bit indices. */ - virtual void drawVertexPrimitiveList(const void* vertices, u32 vertexCount, - const void* indexList, u32 primCount, - E_VERTEX_TYPE vType=EVT_STANDARD, - scene::E_PRIMITIVE_TYPE pType=scene::EPT_TRIANGLES, - E_INDEX_TYPE iType=EIT_16BIT) =0; - - //! Draws a vertex primitive list in 2d - /** Compared to the general (3d) version of this method, this - one sets up a 2d render mode, and uses only x and y of vectors. - Note that, depending on the index type, some vertices might be - not accessible through the index list. The limit is at 65535 - vertices for 16bit indices. Please note that currently not all - primitives are available for all drivers, and some might be - emulated via triangle renders. This function is not available - for the sw drivers. - \param vertices Pointer to array of vertices. - \param vertexCount Amount of vertices in the array. - \param indexList Pointer to array of indices. These define the - vertices used for each primitive. Depending on the pType, - indices are interpreted as single objects (for point like - primitives), pairs (for lines), triplets (for triangles), or - quads. - \param primCount Amount of Primitives - \param vType Vertex type, e.g. video::EVT_STANDARD for S3DVertex. - \param pType Primitive type, e.g. scene::EPT_TRIANGLE_FAN for a triangle fan. - \param iType Index type, e.g. video::EIT_16BIT for 16bit indices. */ - virtual void draw2DVertexPrimitiveList(const void* vertices, u32 vertexCount, - const void* indexList, u32 primCount, - E_VERTEX_TYPE vType=EVT_STANDARD, - scene::E_PRIMITIVE_TYPE pType=scene::EPT_TRIANGLES, - E_INDEX_TYPE iType=EIT_16BIT) =0; - - //! Draws an indexed triangle list. - /** Note that there may be at maximum 65536 vertices, because - the index list is an array of 16 bit values each with a maximum - value of 65536. If there are more than 65536 vertices in the - list, results of this operation are not defined. - \param vertices Pointer to array of vertices. - \param vertexCount Amount of vertices in the array. - \param indexList Pointer to array of indices. - \param triangleCount Amount of Triangles. Usually amount of indices / 3. */ - virtual void drawIndexedTriangleList(const S3DVertex* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount) =0; - - //! Draws an indexed triangle list. - /** Note that there may be at maximum 65536 vertices, because - the index list is an array of 16 bit values each with a maximum - value of 65536. If there are more than 65536 vertices in the - list, results of this operation are not defined. - \param vertices Pointer to array of vertices. - \param vertexCount Amount of vertices in the array. - \param indexList Pointer to array of indices. - \param triangleCount Amount of Triangles. Usually amount of indices / 3. */ - virtual void drawIndexedTriangleList(const S3DVertex2TCoords* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount) =0; - - //! Draws an indexed triangle list. - /** Note that there may be at maximum 65536 vertices, because - the index list is an array of 16 bit values each with a maximum - value of 65536. If there are more than 65536 vertices in the - list, results of this operation are not defined. - \param vertices Pointer to array of vertices. - \param vertexCount Amount of vertices in the array. - \param indexList Pointer to array of indices. - \param triangleCount Amount of Triangles. Usually amount of indices / 3. */ - virtual void drawIndexedTriangleList(const S3DVertexTangents* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount) =0; - - //! Draws an indexed triangle fan. - /** Note that there may be at maximum 65536 vertices, because - the index list is an array of 16 bit values each with a maximum - value of 65536. If there are more than 65536 vertices in the - list, results of this operation are not defined. - \param vertices Pointer to array of vertices. - \param vertexCount Amount of vertices in the array. - \param indexList Pointer to array of indices. - \param triangleCount Amount of Triangles. Usually amount of indices - 2. */ - virtual void drawIndexedTriangleFan(const S3DVertex* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount) =0; - - //! Draws an indexed triangle fan. - /** Note that there may be at maximum 65536 vertices, because - the index list is an array of 16 bit values each with a maximum - value of 65536. If there are more than 65536 vertices in the - list, results of this operation are not defined. - \param vertices Pointer to array of vertices. - \param vertexCount Amount of vertices in the array. - \param indexList Pointer to array of indices. - \param triangleCount Amount of Triangles. Usually amount of indices - 2. */ - virtual void drawIndexedTriangleFan(const S3DVertex2TCoords* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount) =0; - - //! Draws a 3d line. - /** For some implementations, this method simply calls - drawIndexedTriangles for some triangles. - Note that the line is drawn using the current transformation - matrix and material. So if you need to draw the 3D line - independently of the current transformation, use - \code - driver->setMaterial(unlitMaterial); - driver->setTransform(video::ETS_WORLD, core::matrix4()); - \endcode - for some properly set up material before drawing the line. - Some drivers support line thickness set in the material. - \param start Start of the 3d line. - \param end End of the 3d line. - \param color Color of the line. */ - virtual void draw3DLine(const core::vector3df& start, - const core::vector3df& end, SColor color = SColor(255,255,255,255)) =0; - - //! Draws a 3d triangle. - /** This method calls drawIndexedTriangles for some triangles. - This method works with all drivers because it simply calls - drawIndexedTriangleList but it is hence not very fast. - Note that the triangle is drawn using the current - transformation matrix and material. So if you need to draw it - independently of the current transformation, use - \code - driver->setMaterial(unlitMaterial); - driver->setTransform(video::ETS_WORLD, core::matrix4()); - \endcode - for some properly set up material before drawing the triangle. - \param triangle The triangle to draw. - \param color Color of the line. */ - virtual void draw3DTriangle(const core::triangle3df& triangle, - SColor color = SColor(255,255,255,255)) =0; - - //! Draws a 3d axis aligned box. - /** This method simply calls draw3DLine for the edges of the - box. Note that the box is drawn using the current transformation - matrix and material. So if you need to draw it independently of - the current transformation, use - \code - driver->setMaterial(unlitMaterial); - driver->setTransform(video::ETS_WORLD, core::matrix4()); - \endcode - for some properly set up material before drawing the box. - \param box The axis aligned box to draw - \param color Color to use while drawing the box. */ - virtual void draw3DBox(const core::aabbox3d<f32>& box, - SColor color = SColor(255,255,255,255)) =0; - - //! Draws a 2d image without any special effects - /** \param texture Pointer to texture to use. - \param destPos Upper left 2d destination position where the - image will be drawn. */ - virtual void draw2DImage(const video::ITexture* texture, - const core::position2d<s32>& destPos) =0; - - //! Draws a 2d image using a color - /** (if color is other than - Color(255,255,255,255)) and the alpha channel of the texture. - \param texture Texture to be drawn. - \param destPos Upper left 2d destination position where the - image will be drawn. - \param sourceRect Source rectangle in the image. - \param clipRect Pointer to rectangle on the screen where the - image is clipped to. - If this pointer is NULL the image is not clipped. - \param color Color with which the image is drawn. If the color - equals Color(255,255,255,255) it is ignored. Note that the - alpha component is used: If alpha is other than 255, the image - will be transparent. - \param useAlphaChannelOfTexture: If true, the alpha channel of - the texture is used to draw the image.*/ - virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos, - const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect =0, - SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false) =0; - - //! Draws a set of 2d images, using a color and the alpha channel of the texture. - /** The images are drawn beginning at pos and concatenated in - one line. All drawings are clipped against clipRect (if != 0). - The subtextures are defined by the array of sourceRects and are - chosen by the indices given. - \param texture Texture to be drawn. - \param pos Upper left 2d destination position where the image - will be drawn. - \param sourceRects Source rectangles of the image. - \param indices List of indices which choose the actual - rectangle used each time. - \param kerningWidth Offset to Position on X - \param clipRect Pointer to rectangle on the screen where the - image is clipped to. - If this pointer is 0 then the image is not clipped. - \param color Color with which the image is drawn. - Note that the alpha component is used. If alpha is other than - 255, the image will be transparent. - \param useAlphaChannelOfTexture: If true, the alpha channel of - the texture is used to draw the image. */ - virtual void draw2DImageBatch(const video::ITexture* texture, - const core::position2d<s32>& pos, - const core::array<core::rect<s32> >& sourceRects, - const core::array<s32>& indices, - s32 kerningWidth=0, - const core::rect<s32>* clipRect=0, - SColor color=SColor(255,255,255,255), - bool useAlphaChannelOfTexture=false) =0; - - //! Draws a set of 2d images, using a color and the alpha channel of the texture. - /** All drawings are clipped against clipRect (if != 0). - The subtextures are defined by the array of sourceRects and are - positioned using the array of positions. - \param texture Texture to be drawn. - \param pos Array of upper left 2d destinations where the images - will be drawn. - \param sourceRects Source rectangles of the image. - \param clipRect Pointer to rectangle on the screen where the - images are clipped to. - If this pointer is 0 then the image is not clipped. - \param color Color with which the image is drawn. - Note that the alpha component is used. If alpha is other than - 255, the image will be transparent. - \param useAlphaChannelOfTexture: If true, the alpha channel of - the texture is used to draw the image. */ - virtual void draw2DImageBatch(const video::ITexture* texture, - const core::array<core::position2d<s32> >& positions, - const core::array<core::rect<s32> >& sourceRects, - const core::rect<s32>* clipRect=0, - SColor color=SColor(255,255,255,255), - bool useAlphaChannelOfTexture=false) =0; - - //! Draws a part of the texture into the rectangle. Note that colors must be an array of 4 colors if used. - /** Suggested and first implemented by zola. - \param texture The texture to draw from - \param destRect The rectangle to draw into - \param sourceRect The rectangle denoting a part of the texture - \param clipRect Clips the destination rectangle (may be 0) - \param colors Array of 4 colors denoting the color values of - the corners of the destRect - \param useAlphaChannelOfTexture True if alpha channel will be - blended. */ - virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect, - const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect =0, - const video::SColor * const colors=0, bool useAlphaChannelOfTexture=false) =0; - - //! Draws a 2d rectangle. - /** \param color Color of the rectangle to draw. The alpha - component will not be ignored and specifies how transparent the - rectangle will be. - \param pos Position of the rectangle. - \param clip Pointer to rectangle against which the rectangle - will be clipped. If the pointer is null, no clipping will be - performed. */ - virtual void draw2DRectangle(SColor color, const core::rect<s32>& pos, - const core::rect<s32>* clip =0) =0; - - //! Draws a 2d rectangle with a gradient. - /** \param colorLeftUp Color of the upper left corner to draw. - The alpha component will not be ignored and specifies how - transparent the rectangle will be. - \param colorRightUp Color of the upper right corner to draw. - The alpha component will not be ignored and specifies how - transparent the rectangle will be. - \param colorLeftDown Color of the lower left corner to draw. - The alpha component will not be ignored and specifies how - transparent the rectangle will be. - \param colorRightDown Color of the lower right corner to draw. - The alpha component will not be ignored and specifies how - transparent the rectangle will be. - \param pos Position of the rectangle. - \param clip Pointer to rectangle against which the rectangle - will be clipped. If the pointer is null, no clipping will be - performed. */ - virtual void draw2DRectangle(const core::rect<s32>& pos, - SColor colorLeftUp, SColor colorRightUp, - SColor colorLeftDown, SColor colorRightDown, - const core::rect<s32>* clip =0) =0; - - //! Draws the outline of a 2D rectangle. - /** \param pos Position of the rectangle. - \param color Color of the rectangle to draw. The alpha component - specifies how transparent the rectangle outline will be. */ - virtual void draw2DRectangleOutline(const core::recti& pos, - SColor color=SColor(255,255,255,255)) =0; - - //! Draws a 2d line. - /** \param start Screen coordinates of the start of the line - in pixels. - \param end Screen coordinates of the start of the line in - pixels. - \param color Color of the line to draw. */ - virtual void draw2DLine(const core::position2d<s32>& start, - const core::position2d<s32>& end, - SColor color=SColor(255,255,255,255)) =0; - - //! Draws a pixel. - /** \param x The x-position of the pixel. - \param y The y-position of the pixel. - \param color Color of the pixel to draw. */ - virtual void drawPixel(u32 x, u32 y, const SColor& color) =0; - - //! Draws a non filled concyclic regular 2d polyon. - /** This method can be used to draw circles, but also - triangles, tetragons, pentagons, hexagons, heptagons, octagons, - enneagons, decagons, hendecagons, dodecagon, triskaidecagons, - etc. I think you'll got it now. And all this by simply - specifying the vertex count. Welcome to the wonders of - geometry. - \param center Position of center of circle (pixels). - \param radius Radius of circle in pixels. - \param color Color of the circle. - \param vertexCount Amount of vertices of the polygon. Specify 2 - to draw a line, 3 to draw a triangle, 4 for tetragons and a lot - (>10) for nearly a circle. */ - virtual void draw2DPolygon(core::position2d<s32> center, - f32 radius, - video::SColor color=SColor(100,255,255,255), - s32 vertexCount=10) =0; - - //! Draws a shadow volume into the stencil buffer. - /** To draw a stencil shadow, do this: First, draw all geometry. - Then use this method, to draw the shadow volume. Then, use - IVideoDriver::drawStencilShadow() to visualize the shadow. - Please note that the code for the opengl version of the method - is based on free code sent in by Philipp Dortmann, lots of - thanks go to him! - \param triangles Pointer to array of 3d vectors, specifying the - shadow volume. - \param count Amount of triangles in the array. - \param zfail If set to true, zfail method is used, otherwise - zpass. */ - virtual void drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail=true) =0; - - //! Fills the stencil shadow with color. - /** After the shadow volume has been drawn into the stencil - buffer using IVideoDriver::drawStencilShadowVolume(), use this - to draw the color of the shadow. - Please note that the code for the opengl version of the method - is based on free code sent in by Philipp Dortmann, lots of - thanks go to him! - \param clearStencilBuffer Set this to false, if you want to - draw every shadow with the same color, and only want to call - drawStencilShadow() once after all shadow volumes have been - drawn. Set this to true, if you want to paint every shadow with - its own color. - \param leftUpEdge Color of the shadow in the upper left corner - of screen. - \param rightUpEdge Color of the shadow in the upper right - corner of screen. - \param leftDownEdge Color of the shadow in the lower left - corner of screen. - \param rightDownEdge Color of the shadow in the lower right - corner of screen. */ - virtual void drawStencilShadow(bool clearStencilBuffer=false, - video::SColor leftUpEdge = video::SColor(255,0,0,0), - video::SColor rightUpEdge = video::SColor(255,0,0,0), - video::SColor leftDownEdge = video::SColor(255,0,0,0), - video::SColor rightDownEdge = video::SColor(255,0,0,0)) =0; - - //! Draws a mesh buffer - /** \param mb Buffer to draw; */ - virtual void drawMeshBuffer(const scene::IMeshBuffer* mb) =0; - - //! Sets the fog mode. - /** These are global values attached to each 3d object rendered, - which has the fog flag enabled in its material. - \param color Color of the fog - \param linearFog Set this to true for linear fog, otherwise - exponential fog is applied. - \param start Only used in linear fog mode (linearFog=true). - Specifies where fog starts. - \param end Only used in linear fog mode (linearFog=true). - Specifies where fog ends. - \param density Only used in exponential fog mode - (linearFog=false). Must be a value between 0 and 1. - \param pixelFog Set this to false for vertex fog, and true if - you want per-pixel fog. - \param rangeFog Set this to true to enable range-based vertex - fog. The distance from the viewer is used to compute the fog, - not the z-coordinate. This is better, but slower. This might not - be available with all drivers and fog settings. */ - virtual void setFog(SColor color=SColor(0,255,255,255), - E_FOG_TYPE fogType=EFT_FOG_LINEAR, - f32 start=50.0f, f32 end=100.0f, f32 density=0.01f, - bool pixelFog=false, bool rangeFog=false) =0; - - //! Get the current color format of the color buffer - /** \return Color format of the color buffer. */ - virtual ECOLOR_FORMAT getColorFormat() const =0; - - //! Get the size of the screen or render window. - /** \return Size of screen or render window. */ - virtual const core::dimension2d<u32>& getScreenSize() const =0; - - //! Get the size of the current render target - /** This method will return the screen size if the driver - doesn't support render to texture, or if the current render - target is the screen. - \return Size of render target or screen/window */ - virtual const core::dimension2d<u32>& getCurrentRenderTargetSize() const =0; - - //! Returns current frames per second value. - /** This value is updated approximately every 1.5 seconds and - is only intended to provide a rough guide to the average frame - rate. It is not suitable for use in performing timing - calculations or framerate independent movement. - \return Approximate amount of frames per second drawn. */ - virtual s32 getFPS() const =0; - - //! Returns amount of primitives (mostly triangles) which were drawn in the last frame. - /** Together with getFPS() very useful method for statistics. - \param mode Defines if the primitives drawn are accumulated or - counted per frame. - \return Amount of primitives drawn in the last frame. */ - virtual u32 getPrimitiveCountDrawn( u32 mode =0 ) const =0; - - //! Deletes all dynamic lights which were previously added with addDynamicLight(). - virtual void deleteAllDynamicLights() =0; - - //! adds a dynamic light, returning an index to the light - //! \param light: the light data to use to create the light - //! \return An index to the light, or -1 if an error occurs - virtual s32 addDynamicLight(const SLight& light) =0; - - //! Returns the maximal amount of dynamic lights the device can handle - /** \return Maximal amount of dynamic lights. */ - virtual u32 getMaximalDynamicLightAmount() const =0; - - //! Returns amount of dynamic lights currently set - /** \return Amount of dynamic lights currently set */ - virtual u32 getDynamicLightCount() const =0; - - //! Returns light data which was previously set by IVideoDriver::addDynamicLight(). - /** \param idx Zero based index of the light. Must be 0 or - greater and smaller than IVideoDriver()::getDynamicLightCount. - \return Light data. */ - virtual const SLight& getDynamicLight(u32 idx) const =0; - - //! Turns a dynamic light on or off - //! \param lightIndex: the index returned by addDynamicLight - //! \param turnOn: true to turn the light on, false to turn it off - virtual void turnLightOn(s32 lightIndex, bool turnOn) =0; - - //! Gets name of this video driver. - /** \return Returns the name of the video driver, e.g. in case - of the Direct3D8 driver, it would return "Direct3D 8.1". */ - virtual const wchar_t* getName() const =0; - - //! Adds an external image loader to the engine. - /** This is useful if the Irrlicht Engine should be able to load - textures of currently unsupported file formats (e.g. gif). The - IImageLoader only needs to be implemented for loading this file - format. A pointer to the implementation can be passed to the - engine using this method. - \param loader Pointer to the external loader created. */ - virtual void addExternalImageLoader(IImageLoader* loader) =0; - - //! Adds an external image writer to the engine. - /** This is useful if the Irrlicht Engine should be able to - write textures of currently unsupported file formats (e.g - .gif). The IImageWriter only needs to be implemented for - writing this file format. A pointer to the implementation can - be passed to the engine using this method. - \param writer: Pointer to the external writer created. */ - virtual void addExternalImageWriter(IImageWriter* writer) =0; - - //! Returns the maximum amount of primitives - /** (mostly vertices) which the device is able to render with - one drawIndexedTriangleList call. - \return Maximum amount of primitives. */ - virtual u32 getMaximalPrimitiveCount() const =0; - - //! Enables or disables a texture creation flag. - /** These flags define how textures should be created. By - changing this value, you can influence for example the speed of - rendering a lot. But please note that the video drivers take - this value only as recommendation. It could happen that you - enable the ETCF_ALWAYS_16_BIT mode, but the driver still creates - 32 bit textures. - \param flag Texture creation flag. - \param enabled Specifies if the given flag should be enabled or - disabled. */ - virtual void setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled=true) =0; - - //! Returns if a texture creation flag is enabled or disabled. - /** You can change this value using setTextureCreationMode(). - \param flag Texture creation flag. - \return The current texture creation mode. */ - virtual bool getTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag) const =0; - - //! Creates a software image from a file. - /** No hardware texture will be created for this image. This - method is useful for example if you want to read a heightmap - for a terrain renderer. - \param filename Name of the file from which the image is - created. - \return The created image. - If you no longer need the image, you should call IImage::drop(). - See IReferenceCounted::drop() for more information. */ - virtual IImage* createImageFromFile(const io::path& filename) = 0; - - //! Creates a software image from a file. - /** No hardware texture will be created for this image. This - method is useful for example if you want to read a heightmap - for a terrain renderer. - \param file File from which the image is created. - \return The created image. - If you no longer need the image, you should call IImage::drop(). - See IReferenceCounted::drop() for more information. */ - virtual IImage* createImageFromFile(io::IReadFile* file) =0; - - //! Writes the provided image to a file. - /** Requires that there is a suitable image writer registered - for writing the image. - \param image Image to write. - \param filename Name of the file to write. - \param param Control parameter for the backend (e.g. compression - level). - \return True on successful write. */ - virtual bool writeImageToFile(IImage* image, const io::path& filename, u32 param = 0) = 0; - - //! Writes the provided image to a file. - /** Requires that there is a suitable image writer registered - for writing the image. - \param image Image to write. - \param file An already open io::IWriteFile object. The name will be used to determine - the appropriate image writer to use. - \param param Control parameter for the backend (e.g. compression - level). - \return True on successful write. */ - virtual bool writeImageToFile(IImage* image, io::IWriteFile* file, u32 param =0) =0; - - //! Creates a software image from a byte array. - /** No hardware texture will be created for this image. This - method is useful for example if you want to read a heightmap - for a terrain renderer. - \param format Desired color format of the texture - \param size Desired size of the image - \param data A byte array with pixel color information - \param ownForeignMemory If true, the image will use the data - pointer directly and own it afterwards. If false, the memory - will by copied internally. - \param deleteMemory Whether the memory is deallocated upon - destruction. - \return The created image. - If you no longer need the image, you should call IImage::drop(). - See IReferenceCounted::drop() for more information. */ - virtual IImage* createImageFromData(ECOLOR_FORMAT format, - const core::dimension2d<u32>& size, void *data, - bool ownForeignMemory=false, - bool deleteMemory = true) =0; - - //! Creates an empty software image. - /** - \param format Desired color format of the image. - \param size Size of the image to create. - \return The created image. - If you no longer need the image, you should call IImage::drop(). - See IReferenceCounted::drop() for more information. */ - virtual IImage* createImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size) =0; - - //! Creates a software image by converting it to given format from another image. - /** - \param format Desired color format of the image. - \param imageToCopy Image to copy to the new image. - \return The created image. - If you no longer need the image, you should call IImage::drop(). - See IReferenceCounted::drop() for more information. */ - virtual IImage* createImage(ECOLOR_FORMAT format, IImage *imageToCopy) =0; - - //! Creates a software image from a part of another image. - /** - \param imageToCopy Image to copy to the new image in part. - \param pos Position of rectangle to copy. - \param size Extents of rectangle to copy. - \return The created image. - If you no longer need the image, you should call IImage::drop(). - See IReferenceCounted::drop() for more information. */ - virtual IImage* createImage(IImage* imageToCopy, - const core::position2d<s32>& pos, - const core::dimension2d<u32>& size) =0; - - //! Creates a software image from a part of a texture. - /** - \param texture Texture to copy to the new image in part. - \param pos Position of rectangle to copy. - \param size Extents of rectangle to copy. - \return The created image. - If you no longer need the image, you should call IImage::drop(). - See IReferenceCounted::drop() for more information. */ - virtual IImage* createImage(ITexture* texture, - const core::position2d<s32>& pos, - const core::dimension2d<u32>& size) =0; - - //! Event handler for resize events. Only used by the engine internally. - /** Used to notify the driver that the window was resized. - Usually, there is no need to call this method. */ - virtual void OnResize(const core::dimension2d<u32>& size) =0; - - //! Adds a new material renderer to the video device. - /** Use this method to extend the VideoDriver with new material - types. To extend the engine using this method do the following: - Derive a class from IMaterialRenderer and override the methods - you need. For setting the right renderstates, you can try to - get a pointer to the real rendering device using - IVideoDriver::getExposedVideoData(). Add your class with - IVideoDriver::addMaterialRenderer(). To use an object being - displayed with your new material, set the MaterialType member of - the SMaterial struct to the value returned by this method. - If you simply want to create a new material using vertex and/or - pixel shaders it would be easier to use the - video::IGPUProgrammingServices interface which you can get - using the getGPUProgrammingServices() method. - \param renderer A pointer to the new renderer. - \param name Optional name for the material renderer entry. - \return The number of the material type which can be set in - SMaterial::MaterialType to use the renderer. -1 is returned if - an error occured. For example if you tried to add an material - renderer to the software renderer or the null device, which do - not accept material renderers. */ - virtual s32 addMaterialRenderer(IMaterialRenderer* renderer, const c8* name =0) =0; - - //! Get access to a material renderer by index. - /** \param idx Id of the material renderer. Can be a value of - the E_MATERIAL_TYPE enum or a value which was returned by - addMaterialRenderer(). - \return Pointer to material renderer or null if not existing. */ - virtual IMaterialRenderer* getMaterialRenderer(u32 idx) =0; - - //! Get amount of currently available material renderers. - /** \return Amount of currently available material renderers. */ - virtual u32 getMaterialRendererCount() const =0; - - //! Get name of a material renderer - /** This string can, e.g., be used to test if a specific - renderer already has been registered/created, or use this - string to store data about materials: This returned name will - be also used when serializing materials. - \param idx Id of the material renderer. Can be a value of the - E_MATERIAL_TYPE enum or a value which was returned by - addMaterialRenderer(). - \return String with the name of the renderer, or 0 if not - exisiting */ - virtual const c8* getMaterialRendererName(u32 idx) const =0; - - //! Sets the name of a material renderer. - /** Will have no effect on built-in material renderers. - \param idx: Id of the material renderer. Can be a value of the - E_MATERIAL_TYPE enum or a value which was returned by - addMaterialRenderer(). - \param name: New name of the material renderer. */ - virtual void setMaterialRendererName(s32 idx, const c8* name) =0; - - //! Creates material attributes list from a material - /** This method is useful for serialization and more. - Please note that the video driver will use the material - renderer names from getMaterialRendererName() to write out the - material type name, so they should be set before. - \param material The material to serialize. - \return The io::IAttributes container holding the material - properties. */ - virtual io::IAttributes* createAttributesFromMaterial(const video::SMaterial& material) =0; - - //! Fills an SMaterial structure from attributes. - /** Please note that for setting material types of the - material, the video driver will need to query the material - renderers for their names, so all non built-in materials must - have been created before calling this method. - \param outMaterial The material to set the properties for. - \param attributes The attributes to read from. */ - virtual void fillMaterialStructureFromAttributes(video::SMaterial& outMaterial, io::IAttributes* attributes) =0; - - //! Returns driver and operating system specific data about the IVideoDriver. - /** This method should only be used if the engine should be - extended without having to modify the source of the engine. - \return Collection of device dependent pointers. */ - virtual const SExposedVideoData& getExposedVideoData() =0; - - //! Get type of video driver - /** \return Type of driver. */ - virtual E_DRIVER_TYPE getDriverType() const =0; - - //! Gets the IGPUProgrammingServices interface. - /** \return Pointer to the IGPUProgrammingServices. Returns 0 - if the video driver does not support this. For example the - Software driver and the Null driver will always return 0. */ - virtual IGPUProgrammingServices* getGPUProgrammingServices() =0; - - //! Returns a pointer to the mesh manipulator. - virtual scene::IMeshManipulator* getMeshManipulator() =0; - - //! Clears the ZBuffer. - /** Note that you usually need not to call this method, as it - is automatically done in IVideoDriver::beginScene() or - IVideoDriver::setRenderTarget() if you enable zBuffer. But if - you have to render some special things, you can clear the - zbuffer during the rendering process with this method any time. - */ - virtual void clearZBuffer() =0; - - //! Make a screenshot of the last rendered frame. - /** \return An image created from the last rendered frame. */ - virtual IImage* createScreenShot() =0; - - //! Check if the image is already loaded. - /** Works similar to getTexture(), but does not load the texture - if it is not currently loaded. - \param filename Name of the texture. - \return Pointer to loaded texture, or 0 if not found. */ - virtual video::ITexture* findTexture(const io::path& filename) = 0; - - //! Set or unset a clipping plane. - /** There are at least 6 clipping planes available for the user - to set at will. - \param index The plane index. Must be between 0 and - MaxUserClipPlanes. - \param plane The plane itself. - \param enable If true, enable the clipping plane else disable - it. - \return True if the clipping plane is usable. */ - virtual bool setClipPlane(u32 index, const core::plane3df& plane, bool enable=false) =0; - - //! Enable or disable a clipping plane. - /** There are at least 6 clipping planes available for the user - to set at will. - \param index The plane index. Must be between 0 and - MaxUserClipPlanes. - \param enable If true, enable the clipping plane else disable - it. */ - virtual void enableClipPlane(u32 index, bool enable) =0; - - //! Set the minimum number of vertices for which a hw buffer will be created - /** \param count Number of vertices to set as minimum. */ - virtual void setMinHardwareBufferVertexCount(u32 count) =0; - - //! Get the global Material, which might override local materials. - /** Depending on the enable flags, values from this Material - are used to override those of local materials of some - meshbuffer being rendered. - \return Reference to the Override Material. */ - virtual SOverrideMaterial& getOverrideMaterial() =0; - - //! Returns the graphics card vendor name. - virtual core::stringc getVendorInfo() =0; - - //! Only used by the engine internally. - /** The ambient color is set in the scene manager, see - scene::ISceneManager::setAmbientLight(). - \param color New color of the ambient light. */ - virtual void setAmbientLight(const SColorf& color) =0; - - //! Only used by the engine internally. - /** Passes the global material flag AllowZWriteOnTransparent. - Use the SceneManager attribute to set this value from your app. - \param flag Default behavior is to disable ZWrite, i.e. false. */ - virtual void setAllowZWriteOnTransparent(bool flag) =0; - }; - -} // end namespace video -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/include/IVideoModeList.h b/irrlicht-1.6/include/IVideoModeList.h deleted file mode 100644 index 57ba857ef..000000000 --- a/irrlicht-1.6/include/IVideoModeList.h +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_I_VIDEO_MODE_LIST_H_INCLUDED__ -#define __IRR_I_VIDEO_MODE_LIST_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "dimension2d.h" - -namespace irr -{ -namespace video -{ - - //! A list of all available video modes. - /** You can get a list via IrrlichtDevice::getVideoModeList(). If you are confused - now, because you think you have to create an Irrlicht Device with a video - mode before being able to get the video mode list, let me tell you that - there is no need to start up an Irrlicht Device with EDT_DIRECT3D8, EDT_OPENGL or - EDT_SOFTWARE: For this (and for lots of other reasons) the null device, - EDT_NULL exists.*/ - class IVideoModeList : public virtual IReferenceCounted - { - public: - - //! Gets amount of video modes in the list. - /** \return Returns amount of video modes. */ - virtual s32 getVideoModeCount() const = 0; - - //! Get the screen size of a video mode in pixels. - /** \param modeNumber: zero based index of the video mode. - \return Size of screen in pixels of the specified video mode. */ - virtual core::dimension2d<u32> getVideoModeResolution(s32 modeNumber) const = 0; - - //! Get a supported screen size with certain constraints. - /** \param minSize: Minimum dimensions required. - \param maxSize: Maximum dimensions allowed. - \return Size of screen in pixels which matches the requirements. - as good as possible. */ - virtual core::dimension2d<u32> getVideoModeResolution(const core::dimension2d<u32>& minSize, const core::dimension2d<u32>& maxSize) const = 0; - - //! Get the pixel depth of a video mode in bits. - /** \param modeNumber: zero based index of the video mode. - \return Size of each pixel of the specified video mode in bits. */ - virtual s32 getVideoModeDepth(s32 modeNumber) const = 0; - - //! Get current desktop screen resolution. - /** \return Size of screen in pixels of the current desktop video mode. */ - virtual const core::dimension2d<u32>& getDesktopResolution() const = 0; - - //! Get the pixel depth of a video mode in bits. - /** \return Size of each pixel of the current desktop video mode in bits. */ - virtual s32 getDesktopDepth() const = 0; - }; - -} // end namespace video -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/include/IVolumeLightSceneNode.h b/irrlicht-1.6/include/IVolumeLightSceneNode.h deleted file mode 100644 index 36528a3dc..000000000 --- a/irrlicht-1.6/include/IVolumeLightSceneNode.h +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h -// -// created by Dean Wadsworth aka Varmint Dec 31 2007 - -#ifndef __I_VOLUME_LIGHT_SCENE_NODE_H_INCLUDED__ -#define __I_VOLUME_LIGHT_SCENE_NODE_H_INCLUDED__ - -#include "ISceneNode.h" - -namespace irr -{ -namespace scene -{ - class IMeshBuffer; - - class IVolumeLightSceneNode : public ISceneNode - { - public: - - //! constructor - IVolumeLightSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position, - const core::vector3df& rotation, - const core::vector3df& scale) - : ISceneNode(parent, mgr, id, position, rotation, scale) {}; - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() const { return ESNT_VOLUME_LIGHT; } - - //! Sets the number of segments across the U axis - virtual void setSubDivideU(const u32 inU) =0; - - //! Sets the number of segments across the V axis - virtual void setSubDivideV(const u32 inV) =0; - - //! Returns the number of segments across the U axis - virtual u32 getSubDivideU() const =0; - - //! Returns the number of segments across the V axis - virtual u32 getSubDivideV() const =0; - - //! Sets the color of the base of the light - virtual void setFootColor(const video::SColor inColour) =0; - - //! Sets the color of the tip of the light - virtual void setTailColor(const video::SColor inColour) =0; - - //! Returns the color of the base of the light - virtual video::SColor getFootColor() const =0; - - //! Returns the color of the tip of the light - virtual video::SColor getTailColor() const =0; - }; - -} // end namespace scene -} // end namespace irr - -#endif diff --git a/irrlicht-1.6/include/IWriteFile.h b/irrlicht-1.6/include/IWriteFile.h deleted file mode 100644 index bd68f45b4..000000000 --- a/irrlicht-1.6/include/IWriteFile.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_WRITE_FILE_H_INCLUDED__ -#define __I_WRITE_FILE_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "path.h" - -namespace irr -{ -namespace io -{ - - //! Interface providing write acess to a file. - class IWriteFile : public virtual IReferenceCounted - { - public: - //! Writes an amount of bytes to the file. - /** \param buffer Pointer to buffer of bytes to write. - \param sizeToWrite Amount of bytes to write to the file. - \return How much bytes were written. */ - virtual s32 write(const void* buffer, u32 sizeToWrite) = 0; - - //! Changes position in file - /** \param finalPos Destination position in the file. - \param relativeMovement If set to true, the position in the file is - changed relative to current position. Otherwise the position is changed - from begin of file. - \return True if successful, otherwise false. */ - virtual bool seek(long finalPos, bool relativeMovement = false) = 0; - - //! Get the current position in the file. - /** \return Current position in the file in bytes. */ - virtual long getPos() const = 0; - - //! Get name of file. - /** \return File name as zero terminated character string. */ - virtual const path& getFileName() const = 0; - }; - - //! Internal function, please do not use. - IWriteFile* createWriteFile(const io::path& fileName, bool append); - -} // end namespace io -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IXMLReader.h b/irrlicht-1.6/include/IXMLReader.h deleted file mode 100644 index d0bec4984..000000000 --- a/irrlicht-1.6/include/IXMLReader.h +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_XML_READER_H_INCLUDED__ -#define __I_XML_READER_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "irrXML.h" - -namespace irr -{ -namespace io -{ - //! An xml reader for wide characters, derived from IReferenceCounted. - /** This XML Parser can read any type of text files from any source - Irrlicht can read. Just call IFileSystem::createXMLReader(). For more - informations on how to use the parser, see IIrrXMLReader */ - typedef IIrrXMLReader<wchar_t, IReferenceCounted> IXMLReader; - - //! An xml reader for ASCII or UTF-8 characters, derived from IReferenceCounted. - /** This XML Parser can read any type of text files from any source - Irrlicht can read. Just call IFileSystem::createXMLReaderUTF8(). For - more informations on how to use the parser, see IIrrXMLReader */ - typedef IIrrXMLReader<c8, IReferenceCounted> IXMLReaderUTF8; - -} // end namespace io -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IXMLWriter.h b/irrlicht-1.6/include/IXMLWriter.h deleted file mode 100644 index d75e0fdd6..000000000 --- a/irrlicht-1.6/include/IXMLWriter.h +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_XML_WRITER_H_INCLUDED__ -#define __I_XML_WRITER_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "irrArray.h" -#include "irrString.h" - -namespace irr -{ -namespace io -{ - - //! Interface providing methods for making it easier to write XML files. - /** This XML Writer writes xml files using in the platform dependent - wchar_t format and sets the xml-encoding correspondingly. */ - class IXMLWriter : public virtual IReferenceCounted - { - public: - - //! Destructor - virtual ~IXMLWriter() {} - - //! Writes an xml 1.0 header. - /** Looks like <?xml version="1.0"?>. This should always - be called before writing anything other, because also the text - file header for unicode texts is written out with this method. */ - virtual void writeXMLHeader() = 0; - - //! Writes an xml element with maximal 5 attributes like "<foo />" or - //! <foo optAttr="value" />. - /** The element can be empty or not. - \param name: Name of the element - \param empty: Specifies if the element should be empty. Like - "<foo />". If You set this to false, something like this is - written instead: "<foo>". - \param attr1Name: 1st attributes name - \param attr1Value: 1st attributes value - \param attr2Name: 2nd attributes name - \param attr2Value: 2nd attributes value - \param attr3Name: 3rd attributes name - \param attr3Value: 3rd attributes value - \param attr4Name: 4th attributes name - \param attr4Value: 4th attributes value - \param attr5Name: 5th attributes name - \param attr5Value: 5th attributes value */ - virtual void writeElement(const wchar_t* name, bool empty=false, - const wchar_t* attr1Name = 0, const wchar_t* attr1Value = 0, - const wchar_t* attr2Name = 0, const wchar_t* attr2Value = 0, - const wchar_t* attr3Name = 0, const wchar_t* attr3Value = 0, - const wchar_t* attr4Name = 0, const wchar_t* attr4Value = 0, - const wchar_t* attr5Name = 0, const wchar_t* attr5Value = 0) = 0; - - //! Writes an xml element with any number of attributes - virtual void writeElement(const wchar_t* name, bool empty, - core::array<core::stringw> &names, core::array<core::stringw> &values) = 0; - - //! Writes a comment into the xml file - virtual void writeComment(const wchar_t* comment) = 0; - - //! Writes the closing tag for an element. Like "</foo>" - virtual void writeClosingTag(const wchar_t* name) = 0; - - //! Writes a text into the file. - /** All occurrences of special characters such as - & (&), < (<), > (>), and " (") are automaticly - replaced. */ - virtual void writeText(const wchar_t* text) = 0; - - //! Writes a line break - virtual void writeLineBreak() = 0; - }; - -} // end namespace io -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/IrrCompileConfig.h b/irrlicht-1.6/include/IrrCompileConfig.h deleted file mode 100644 index c99a2678a..000000000 --- a/irrlicht-1.6/include/IrrCompileConfig.h +++ /dev/null @@ -1,485 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_COMPILE_CONFIG_H_INCLUDED__ -#define __IRR_COMPILE_CONFIG_H_INCLUDED__ - -//! Irrlicht SDK Version -#define IRRLICHT_VERSION_MAJOR 1 -#define IRRLICHT_VERSION_MINOR 6 -#define IRRLICHT_VERSION_REVISION 0 -// This flag will be defined only in SVN, the official release code will have -// it undefined -//#define IRRLICHT_VERSION_SVN -#define IRRLICHT_SDK_VERSION "1.6" - -#include <stdio.h> // TODO: Although included elsewhere this is required at least for mingw - -//! The defines for different operating system are: -//! _IRR_XBOX_PLATFORM_ for XBox -//! _IRR_WINDOWS_ for all irrlicht supported Windows versions -//! _IRR_WINDOWS_CE_PLATFORM_ for Windows CE -//! _IRR_WINDOWS_API_ for Windows or XBox -//! _IRR_LINUX_PLATFORM_ for Linux (it is defined here if no other os is defined) -//! _IRR_SOLARIS_PLATFORM_ for Solaris -//! _IRR_OSX_PLATFORM_ for Apple systems running OSX -//! _IRR_POSIX_API_ for Posix compatible systems -//! Note: PLATFORM defines the OS specific layer, API can group several platforms - -//! DEVICE is the windowing system used, several PLATFORMs support more than one DEVICE -//! Irrlicht can be compiled with more than one device -//! _IRR_COMPILE_WITH_WINDOWS_DEVICE_ for Windows API based device -//! _IRR_COMPILE_WITH_WINDOWS_CE_DEVICE_ for Windows CE API based device -//! _IRR_COMPILE_WITH_OSX_DEVICE_ for Cocoa native windowing on OSX -//! _IRR_COMPILE_WITH_X11_DEVICE_ for Linux X11 based device -//! _IRR_COMPILE_WITH_SDL_DEVICE_ for platform independent SDL framework -//! _IRR_COMPILE_WITH_CONSOLE_DEVICE_ for no windowing system, used as a fallback - - -//! Uncomment this line to compile with the SDL device -//#define _IRR_COMPILE_WITH_SDL_DEVICE_ - -//! Comment this line to compile without the fallback console device. -#define _IRR_COMPILE_WITH_CONSOLE_DEVICE_ - -//! WIN32 for Windows32 -//! WIN64 for Windows64 -// The windows platform and API support SDL and WINDOW device -#if defined(_WIN32) || defined(_WIN64) || defined(WIN32) || defined(WIN64) -#define _IRR_WINDOWS_ -#define _IRR_WINDOWS_API_ -#define _IRR_COMPILE_WITH_WINDOWS_DEVICE_ -#endif - -//! WINCE is a very restricted environment for mobile devices -#if defined(_WIN32_WCE) -#define _IRR_WINDOWS_ -#define _IRR_WINDOWS_API_ -#define _IRR_WINDOWS_CE_PLATFORM_ -#define _IRR_COMPILE_WITH_WINDOWS_CE_DEVICE_ -#endif - -#if defined(_MSC_VER) && (_MSC_VER < 1300) -# error "Only Microsoft Visual Studio 7.0 and later are supported." -#endif - -// XBox only suppots the native Window stuff -#if defined(_XBOX) - #undef _IRR_WINDOWS_ - #define _IRR_XBOX_PLATFORM_ - #define _IRR_WINDOWS_API_ - //#define _IRR_COMPILE_WITH_WINDOWS_DEVICE_ - #undef _IRR_COMPILE_WITH_WINDOWS_DEVICE_ - //#define _IRR_COMPILE_WITH_SDL_DEVICE_ - - #include <xtl.h> -#endif - -#if defined(__APPLE__) || defined(MACOSX) -#if !defined(MACOSX) -#define MACOSX // legacy support -#endif -#define _IRR_OSX_PLATFORM_ -#define _IRR_COMPILE_WITH_OSX_DEVICE_ -#endif - -#if !defined(_IRR_WINDOWS_API_) && !defined(_IRR_OSX_PLATFORM_) -#if defined(__sparc__) || defined(__sun__) -#define __BIG_ENDIAN__ -#define _IRR_SOLARIS_PLATFORM_ -#else -#define _IRR_LINUX_PLATFORM_ -#endif -#define _IRR_POSIX_API_ -#define _IRR_COMPILE_WITH_X11_DEVICE_ -#endif - -//! Define _IRR_COMPILE_WITH_JOYSTICK_SUPPORT_ if you want joystick events. -//#define _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ - -//! Maximum number of texture an SMaterial can have, up to 8 are supported by Irrlicht. -#define _IRR_MATERIAL_MAX_TEXTURES_ 4 - -//! Define _IRR_COMPILE_WITH_DIRECT3D_8_ and _IRR_COMPILE_WITH_DIRECT3D_9_ to -//! compile the Irrlicht engine with Direct3D8 and/or DIRECT3D9. -/** If you only want to use the software device or opengl this can be useful. -This switch is mostly disabled because people do not get the g++ compiler compile -directX header files, and directX is only available on windows platforms. If you -are using Dev-Cpp, and want to compile this using a DX dev pack, you can define -_IRR_COMPILE_WITH_DX9_DEV_PACK_. So you simply need to add something like this -to the compiler settings: -DIRR_COMPILE_WITH_DX9_DEV_PACK -and this to the linker settings: -ld3dx9 -ld3dx8 - -Microsoft have chosen to remove D3D8 headers from their recent DXSDKs, and -so D3D8 support is now disabled by default. If you really want to build -with D3D8 support, then you will have to source a DXSDK with the appropriate -headers, e.g. Summer 2004. This is a Microsoft issue, not an Irrlicht one. -*/ -#if defined(_IRR_WINDOWS_API_) && (!defined(__GNUC__) || defined(IRR_COMPILE_WITH_DX9_DEV_PACK)) - -//! Only define _IRR_COMPILE_WITH_DIRECT3D_8_ if you have an appropriate DXSDK, e.g. Summer 2004 -//#define _IRR_COMPILE_WITH_DIRECT3D_8_ -//#define _IRR_COMPILE_WITH_DIRECT3D_9_ - -#endif - -//! Define _IRR_COMPILE_WITH_OPENGL_ to compile the Irrlicht engine with OpenGL. -/** If you do not wish the engine to be compiled with OpenGL, comment this -define out. */ -#define _IRR_COMPILE_WITH_OPENGL_ - -//! Define _IRR_COMPILE_WITH_SOFTWARE_ to compile the Irrlicht engine with software driver -/** If you do not need the software driver, or want to use Burning's Video instead, -comment this define out */ -#define _IRR_COMPILE_WITH_SOFTWARE_ - -//! Define _IRR_COMPILE_WITH_BURNINGSVIDEO_ to compile the Irrlicht engine with Burning's video driver -/** If you do not need this software driver, you can comment this define out. */ -#define _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -//! Define _IRR_COMPILE_WITH_X11_ to compile the Irrlicht engine with X11 support. -/** If you do not wish the engine to be compiled with X11, comment this -define out. */ -// Only used in LinuxDevice. -#define _IRR_COMPILE_WITH_X11_ - -//! Define _IRR_OPENGL_USE_EXTPOINTER_ if the OpenGL renderer should use OpenGL extensions via function pointers. -/** On some systems there is no support for the dynamic extension of OpenGL - via function pointers such that this has to be undef'ed. */ -#if !defined(_IRR_OSX_PLATFORM_) && !defined(_IRR_SOLARIS_PLATFORM_) -#define _IRR_OPENGL_USE_EXTPOINTER_ -#endif - -//! On some Linux systems the XF86 vidmode extension or X11 RandR are missing. Use these flags -//! to remove the dependencies such that Irrlicht will compile on those systems, too. - -#if defined(_IRR_LINUX_PLATFORM_) && defined(_IRR_COMPILE_WITH_X11_) -//this define should be set by the CMake build system -//#define _IRR_LINUX_X11_VIDMODE_ -//#define _IRR_LINUX_X11_RANDR_ -#endif - -//! Define _IRR_COMPILE_WITH_GUI_ to compile the engine with the built-in GUI -/** Disable this if you are using an external library to draw the GUI. If you disable this then -you will not be able to use anything provided by the GUI Environment, including loading fonts. */ -#define _IRR_COMPILE_WITH_GUI_ - - -//! Define _IRR_WCHAR_FILESYSTEM to enable unicode filesystem support for the engine. -/** This enables the engine to read/write from unicode filesystem. If you -disable this feature, the engine behave as before (ansi). This is currently only supported -for Windows based systems. */ -//#define _IRR_WCHAR_FILESYSTEM - -//! Define _IRR_COMPILE_WITH_ZLIB_ to enable compiling the engine using zlib. -/** This enables the engine to read from compressed .zip archives. If you -disable this feature, the engine can still read archives, but only uncompressed -ones. */ -#define _IRR_COMPILE_WITH_ZLIB_ - -//! Define _IRR_USE_NON_SYSTEM_ZLIB_ to let irrlicht use the zlib which comes with irrlicht. -/** If this is commented out, Irrlicht will try to compile using the zlib installed in the system. - This is only used when _IRR_COMPILE_WITH_ZLIB_ is defined. */ -#define _IRR_USE_NON_SYSTEM_ZLIB_ - - -//! Define _IRR_COMPILE_WITH_JPEGLIB_ to enable compiling the engine using libjpeg. -/** This enables the engine to read jpeg images. If you comment this out, -the engine will no longer read .jpeg images. */ -#define _IRR_COMPILE_WITH_LIBJPEG_ - -//! Define _IRR_USE_NON_SYSTEM_JPEG_LIB_ to let irrlicht use the jpeglib which comes with irrlicht. -/** If this is commented out, Irrlicht will try to compile using the jpeg lib installed in the system. - This is only used when _IRR_COMPILE_WITH_LIBJPEG_ is defined. */ -#define _IRR_USE_NON_SYSTEM_JPEG_LIB_ - - -//! Define _IRR_COMPILE_WITH_LIBPNG_ to enable compiling the engine using libpng. -/** This enables the engine to read png images. If you comment this out, -the engine will no longer read .png images. */ -#define _IRR_COMPILE_WITH_LIBPNG_ - -//! Define _IRR_USE_NON_SYSTEM_LIBPNG_ to let irrlicht use the libpng which comes with irrlicht. -/** If this is commented out, Irrlicht will try to compile using the libpng installed in the system. - This is only used when _IRR_COMPILE_WITH_LIBPNG_ is defined. */ -#define _IRR_USE_NON_SYSTEM_LIB_PNG_ - - -//! Define _IRR_D3D_NO_SHADER_DEBUGGING to disable shader debugging in D3D9 -/** If _IRR_D3D_NO_SHADER_DEBUGGING is undefined in IrrCompileConfig.h, -it is possible to debug all D3D9 shaders in VisualStudio. All shaders -(which have been generated in memory or read from archives for example) will be emitted -into a temporary file at runtime for this purpose. To debug your shaders, choose -Debug->Direct3D->StartWithDirect3DDebugging in Visual Studio, and for every shader a -file named 'irr_dbg_shader_%%.vsh' or 'irr_dbg_shader_%%.psh' will be created. Drag'n'drop -the file you want to debug into visual studio. That's it. You can now set breakpoints and -watch registers, variables etc. This works with ASM, HLSL, and both with pixel and vertex shaders. -Note that the engine will run in D3D REF for this, which is a lot slower than HAL. */ -#define _IRR_D3D_NO_SHADER_DEBUGGING - -//! Define _IRR_D3D_USE_LEGACY_HLSL_COMPILER to enable the old HLSL compiler in recent DX SDKs -/** This enables support for ps_1_x shaders for recent DX SDKs. Otherwise, support -for this shader model is not available anymore in SDKs after Oct2006. You need to -distribute the OCT2006_d3dx9_31_x86.cab or OCT2006_d3dx9_31_x64.cab though, in order -to provide the user with the proper DLL. That's why it's disabled by default. */ -//#define _IRR_D3D_USE_LEGACY_HLSL_COMPILER - -//! Define _IRR_USE_NVIDIA_PERFHUD_ to opt-in to using the nVidia PerHUD tool -/** Enable, by opting-in, to use the nVidia PerfHUD performance analysis driver -tool <http://developer.nvidia.com/object/nvperfhud_home.html>. */ -#undef _IRR_USE_NVIDIA_PERFHUD_ - -//! Define one of the three setting for Burning's Video Software Rasterizer -/** So if we were marketing guys we could say Irrlicht has 4 Software-Rasterizers. - In a Nutshell: - All Burnings Rasterizers use 32 Bit Backbuffer, 32Bit Texture & 32 Bit Z or WBuffer, - 16 Bit/32 Bit can be adjusted on a global flag. - - BURNINGVIDEO_RENDERER_BEAUTIFUL - 32 Bit + Vertexcolor + Lighting + Per Pixel Perspective Correct + SubPixel/SubTexel Correct + - Bilinear Texturefiltering + WBuffer - - BURNINGVIDEO_RENDERER_FAST - 32 Bit + Per Pixel Perspective Correct + SubPixel/SubTexel Correct + WBuffer + - Bilinear Dithering TextureFiltering + WBuffer - - BURNINGVIDEO_RENDERER_ULTRA_FAST - 16Bit + SubPixel/SubTexel Correct + ZBuffer -*/ - -#define BURNINGVIDEO_RENDERER_BEAUTIFUL -//#define BURNINGVIDEO_RENDERER_FAST -//#define BURNINGVIDEO_RENDERER_ULTRA_FAST -//#define BURNINGVIDEO_RENDERER_CE - -//! Uncomment the following line if you want to ignore the deprecated warnings -//#define IGNORE_DEPRECATED_WARNING - -//! Define _IRR_COMPILE_WITH_SKINNED_MESH_SUPPORT_ if you want to use bone based -/** animated meshes. If you compile without this, you will be unable to load -B3D, MS3D or X meshes */ -#define _IRR_COMPILE_WITH_SKINNED_MESH_SUPPORT_ - -#ifdef _IRR_COMPILE_WITH_SKINNED_MESH_SUPPORT_ -//! Define _IRR_COMPILE_WITH_B3D_LOADER_ if you want to use Blitz3D files -#define _IRR_COMPILE_WITH_B3D_LOADER_ -//! Define _IRR_COMPILE_WITH_MS3D_LOADER_ if you want to Milkshape files -#define _IRR_COMPILE_WITH_MS3D_LOADER_ -//! Define _IRR_COMPILE_WITH_X_LOADER_ if you want to use Microsoft X files -#define _IRR_COMPILE_WITH_X_LOADER_ -#endif - -//! Define _IRR_COMPILE_WITH_IRR_MESH_LOADER_ if you want to load Irrlicht Engine .irrmesh files -#define _IRR_COMPILE_WITH_IRR_MESH_LOADER_ - -//! Define _IRR_COMPILE_WITH_MD2_LOADER_ if you want to load Quake 2 animated files -#define _IRR_COMPILE_WITH_MD2_LOADER_ -//! Define _IRR_COMPILE_WITH_MD3_LOADER_ if you want to load Quake 3 animated files -#define _IRR_COMPILE_WITH_MD3_LOADER_ - -//! Define _IRR_COMPILE_WITH_3DS_LOADER_ if you want to load 3D Studio Max files -#define _IRR_COMPILE_WITH_3DS_LOADER_ -//! Define _IRR_COMPILE_WITH_COLLADA_LOADER_ if you want to load Collada files -#define _IRR_COMPILE_WITH_COLLADA_LOADER_ -//! Define _IRR_COMPILE_WITH_CSM_LOADER_ if you want to load Cartography Shop files -#define _IRR_COMPILE_WITH_CSM_LOADER_ -//! Define _IRR_COMPILE_WITH_BSP_LOADER_ if you want to load Quake 3 BSP files -#define _IRR_COMPILE_WITH_BSP_LOADER_ -//! Define _IRR_COMPILE_WITH_DMF_LOADER_ if you want to load DeleD files -#define _IRR_COMPILE_WITH_DMF_LOADER_ -//! Define _IRR_COMPILE_WITH_LMTS_LOADER_ if you want to load LMTools files -#define _IRR_COMPILE_WITH_LMTS_LOADER_ -//! Define _IRR_COMPILE_WITH_MY3D_LOADER_ if you want to load MY3D files -#define _IRR_COMPILE_WITH_MY3D_LOADER_ -//! Define _IRR_COMPILE_WITH_OBJ_LOADER_ if you want to load Wavefront OBJ files -#define _IRR_COMPILE_WITH_OBJ_LOADER_ -//! Define _IRR_COMPILE_WITH_OCT_LOADER_ if you want to load FSRad OCT files -#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_LWO_LOADER_ if you want to load Lightwave3D files -#define _IRR_COMPILE_WITH_LWO_LOADER_ -//! Define _IRR_COMPILE_WITH_STL_LOADER_ if you want to load stereolithography files -#define _IRR_COMPILE_WITH_STL_LOADER_ -//! Define _IRR_COMPILE_WITH_PLY_LOADER_ if you want to load Polygon (Stanford Triangle) files -#define _IRR_COMPILE_WITH_PLY_LOADER_ - -//! Define _IRR_COMPILE_WITH_IRR_WRITER_ if you want to write static .irrMesh 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_ -//! Define _IRR_COMPILE_WITH_OBJ_WRITER_ if you want to write .obj files -#define _IRR_COMPILE_WITH_OBJ_WRITER_ -//! Define _IRR_COMPILE_WITH_PLY_WRITER_ if you want to write .ply files -#define _IRR_COMPILE_WITH_PLY_WRITER_ - -//! Define _IRR_COMPILE_WITH_BMP_LOADER_ if you want to load .bmp files -//! Disabling this loader will also disable the built-in font -#define _IRR_COMPILE_WITH_BMP_LOADER_ -//! Define _IRR_COMPILE_WITH_JPG_LOADER_ if you want to load .jpg files -#define _IRR_COMPILE_WITH_JPG_LOADER_ -//! Define _IRR_COMPILE_WITH_PCX_LOADER_ if you want to load .pcx files -#define _IRR_COMPILE_WITH_PCX_LOADER_ -//! Define _IRR_COMPILE_WITH_PNG_LOADER_ if you want to load .png files -#define _IRR_COMPILE_WITH_PNG_LOADER_ -//! Define _IRR_COMPILE_WITH_PPM_LOADER_ if you want to load .ppm/.pgm/.pbm files -#define _IRR_COMPILE_WITH_PPM_LOADER_ -//! Define _IRR_COMPILE_WITH_PSD_LOADER_ if you want to load .psd files -#define _IRR_COMPILE_WITH_PSD_LOADER_ -//! Define _IRR_COMPILE_WITH_TGA_LOADER_ if you want to load .tga files -#define _IRR_COMPILE_WITH_TGA_LOADER_ -//! Define _IRR_COMPILE_WITH_WAL_LOADER_ if you want to load .wal files -#define _IRR_COMPILE_WITH_WAL_LOADER_ -//! Define _IRR_COMPILE_WITH_RGB_LOADER_ if you want to load Silicon Graphics .rgb/.rgba/.sgi/.int/.inta/.bw files -#define _IRR_COMPILE_WITH_RGB_LOADER_ - -//! Define _IRR_COMPILE_WITH_BMP_WRITER_ if you want to write .bmp files -#define _IRR_COMPILE_WITH_BMP_WRITER_ -//! Define _IRR_COMPILE_WITH_JPG_WRITER_ if you want to write .jpg files -#define _IRR_COMPILE_WITH_JPG_WRITER_ -//! Define _IRR_COMPILE_WITH_PCX_WRITER_ if you want to write .pcx files -#define _IRR_COMPILE_WITH_PCX_WRITER_ -//! Define _IRR_COMPILE_WITH_PNG_WRITER_ if you want to write .png files -#define _IRR_COMPILE_WITH_PNG_WRITER_ -//! Define _IRR_COMPILE_WITH_PPM_WRITER_ if you want to write .ppm files -#define _IRR_COMPILE_WITH_PPM_WRITER_ -//! Define _IRR_COMPILE_WITH_PSD_WRITER_ if you want to write .psd files -#define _IRR_COMPILE_WITH_PSD_WRITER_ -//! Define _IRR_COMPILE_WITH_TGA_WRITER_ if you want to write .tga files -#define _IRR_COMPILE_WITH_TGA_WRITER_ - -//! Define __IRR_COMPILE_WITH_ZIP_ARCHIVE_LOADER_ if you want to open ZIP and GZIP archives -#define __IRR_COMPILE_WITH_ZIP_ARCHIVE_LOADER_ -//! Define __IRR_COMPILE_WITH_MOUNT_ARCHIVE_LOADER_ if you want to mount folders as archives -#define __IRR_COMPILE_WITH_MOUNT_ARCHIVE_LOADER_ -//! Define __IRR_COMPILE_WITH_PAK_ARCHIVE_LOADER_ if you want to open ID software PAK archives -#define __IRR_COMPILE_WITH_PAK_ARCHIVE_LOADER_ -//! Define __IRR_COMPILE_WITH_TAR_ARCHIVE_LOADER_ if you want to open TAR archives -#define __IRR_COMPILE_WITH_TAR_ARCHIVE_LOADER_ - -//! Set FPU settings -/** Irrlicht should use approximate float and integer fpu techniques -precision will be lower but speed higher. currently X86 only -*/ -#if !defined(_IRR_OSX_PLATFORM_) && !defined(_IRR_SOLARIS_PLATFORM_) - //#define IRRLICHT_FAST_MATH -#endif - -// Some cleanup and standard stuff - -#ifdef _IRR_WINDOWS_API_ - -// To build Irrlicht as a static library, you must define _IRR_STATIC_LIB_ in both the -// Irrlicht build, *and* in the user application, before #including <irrlicht.h> -#ifndef _IRR_STATIC_LIB_ -#ifdef IRRLICHT_EXPORTS -#define IRRLICHT_API __declspec(dllexport) -#else -#define IRRLICHT_API __declspec(dllimport) -#endif // IRRLICHT_EXPORT -#else -#define IRRLICHT_API -#endif // _IRR_STATIC_LIB_ - -// Declare the calling convention. -#if defined(_STDCALL_SUPPORTED) -#define IRRCALLCONV __stdcall -#else -#define IRRCALLCONV __cdecl -#endif // STDCALL_SUPPORTED - -#else // _IRR_WINDOWS_API_ - -// Force symbol export in shared libraries built with gcc. -#if (__GNUC__ >= 4) && !defined(_IRR_STATIC_LIB_) && defined(IRRLICHT_EXPORTS) -#define IRRLICHT_API __attribute__ ((visibility("default"))) -#else -#define IRRLICHT_API -#endif - -#define IRRCALLCONV - -#endif // _IRR_WINDOWS_API_ - -// We need to disable DIRECT3D9 support for Visual Studio 6.0 because -// those $%&$!! disabled support for it since Dec. 2004 and users are complaining -// about linker errors. Comment this out only if you are knowing what you are -// doing. (Which means you have an old DX9 SDK and VisualStudio6). -#ifdef _MSC_VER -#if (_MSC_VER < 1300 && !defined(__GNUC__)) -#undef _IRR_COMPILE_WITH_DIRECT3D_9_ -#pragma message("Compiling Irrlicht with Visual Studio 6.0, support for DX9 is disabled.") -#endif -#endif - -// XBox does not have OpenGL or DirectX9 -#if defined(_IRR_XBOX_PLATFORM_) - #undef _IRR_COMPILE_WITH_OPENGL_ - #undef _IRR_COMPILE_WITH_DIRECT3D_9_ -#endif - -//! WinCE does not have OpenGL or DirectX9. use minimal loaders -#if defined(_WIN32_WCE) - #undef _IRR_COMPILE_WITH_OPENGL_ - #undef _IRR_COMPILE_WITH_DIRECT3D_8_ - #undef _IRR_COMPILE_WITH_DIRECT3D_9_ - - #undef BURNINGVIDEO_RENDERER_BEAUTIFUL - #undef BURNINGVIDEO_RENDERER_FAST - #undef BURNINGVIDEO_RENDERER_ULTRA_FAST - #define BURNINGVIDEO_RENDERER_CE - - #undef _IRR_COMPILE_WITH_WINDOWS_DEVICE_ - #define _IRR_COMPILE_WITH_WINDOWS_CE_DEVICE_ - //#define _IRR_WCHAR_FILESYSTEM - - #undef _IRR_COMPILE_WITH_IRR_MESH_LOADER_ - //#undef _IRR_COMPILE_WITH_MD2_LOADER_ - #undef _IRR_COMPILE_WITH_MD3_LOADER_ - #undef _IRR_COMPILE_WITH_3DS_LOADER_ - #undef _IRR_COMPILE_WITH_COLLADA_LOADER_ - #undef _IRR_COMPILE_WITH_CSM_LOADER_ - #undef _IRR_COMPILE_WITH_BSP_LOADER_ - #undef _IRR_COMPILE_WITH_DMF_LOADER_ - #undef _IRR_COMPILE_WITH_LMTS_LOADER_ - #undef _IRR_COMPILE_WITH_MY3D_LOADER_ - #undef _IRR_COMPILE_WITH_OBJ_LOADER_ - #undef _IRR_COMPILE_WITH_OCT_LOADER_ - #undef _IRR_COMPILE_WITH_OGRE_LOADER_ - #undef _IRR_COMPILE_WITH_LWO_LOADER_ - #undef _IRR_COMPILE_WITH_STL_LOADER_ - #undef _IRR_COMPILE_WITH_IRR_WRITER_ - #undef _IRR_COMPILE_WITH_COLLADA_WRITER_ - #undef _IRR_COMPILE_WITH_STL_WRITER_ - #undef _IRR_COMPILE_WITH_OBJ_WRITER_ - //#undef _IRR_COMPILE_WITH_BMP_LOADER_ - //#undef _IRR_COMPILE_WITH_JPG_LOADER_ - #undef _IRR_COMPILE_WITH_PCX_LOADER_ - //#undef _IRR_COMPILE_WITH_PNG_LOADER_ - #undef _IRR_COMPILE_WITH_PPM_LOADER_ - #undef _IRR_COMPILE_WITH_PSD_LOADER_ - //#undef _IRR_COMPILE_WITH_TGA_LOADER_ - #undef _IRR_COMPILE_WITH_WAL_LOADER_ - #undef _IRR_COMPILE_WITH_BMP_WRITER_ - #undef _IRR_COMPILE_WITH_JPG_WRITER_ - #undef _IRR_COMPILE_WITH_PCX_WRITER_ - #undef _IRR_COMPILE_WITH_PNG_WRITER_ - #undef _IRR_COMPILE_WITH_PPM_WRITER_ - #undef _IRR_COMPILE_WITH_PSD_WRITER_ - #undef _IRR_COMPILE_WITH_TGA_WRITER_ - -#endif - -#ifndef _IRR_WINDOWS_API_ - #undef _IRR_WCHAR_FILESYSTEM -#endif - -#if defined(_IRR_SOLARIS_PLATFORM_) - #undef _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ -#endif - -#endif // __IRR_COMPILE_CONFIG_H_INCLUDED__ - diff --git a/irrlicht-1.6/include/IrrlichtDevice.h b/irrlicht-1.6/include/IrrlichtDevice.h deleted file mode 100644 index 7ab6f8441..000000000 --- a/irrlicht-1.6/include/IrrlichtDevice.h +++ /dev/null @@ -1,293 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_IRRLICHT_DEVICE_H_INCLUDED__ -#define __I_IRRLICHT_DEVICE_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "dimension2d.h" -#include "IVideoDriver.h" -#include "EDriverTypes.h" -#include "EDeviceTypes.h" -#include "IEventReceiver.h" -#include "ICursorControl.h" -#include "IVideoModeList.h" -#include "ITimer.h" -#include "IOSOperator.h" - -namespace irr -{ - class ILogger; - class IEventReceiver; - - namespace io { - class IFileSystem; - } // end namespace io - - namespace gui { - class IGUIEnvironment; - } // end namespace gui - - namespace scene { - class ISceneManager; - } // end namespace scene - - //! The Irrlicht device. You can create it with createDevice() or createDeviceEx(). - /** This is the most important class of the Irrlicht Engine. You can - access everything in the engine if you have a pointer to an instance of - this class. There should be only one instance of this class at any - time. - */ - class IrrlichtDevice : public virtual IReferenceCounted - { - public: - - //! Runs the device. - /** Also increments the virtual timer by calling - ITimer::tick();. You can prevent this - by calling ITimer::stop(); before and ITimer::start() after - calling IrrlichtDevice::run(). Returns false if device wants - to be deleted. Use it in this way: - \code - while(device->run()) - { - // draw everything here - } - \endcode - If you want the device to do nothing if the window is inactive - (recommended), use the slightly enhanced code shown at isWindowActive(). - - Note if you are running Irrlicht inside an external, custom - created window: Calling Device->run() will cause Irrlicht to - dispatch windows messages internally. - If you are running Irrlicht in your own custom window, you can - also simply use your own message loop using GetMessage, - DispatchMessage and whatever and simply don't use this method. - But note that Irrlicht will not be able to fetch user input - then. See irr::SIrrlichtCreationParameters::WindowId for more - informations and example code. - */ - virtual bool run() = 0; - - //! Cause the device to temporarily pause execution and let other processes run. - /** This should bring down processor usage without major - performance loss for Irrlicht */ - virtual void yield() = 0; - - //! Pause execution and let other processes to run for a specified amount of time. - /** It may not wait the full given time, as sleep may be interrupted - \param timeMs: Time to sleep for in milisecs. - \param pauseTimer: If true, pauses the device timer while sleeping - */ - virtual void sleep(u32 timeMs, bool pauseTimer=false) = 0; - - //! Provides access to the video driver for drawing 3d and 2d geometry. - /** \return Pointer the video driver. */ - virtual video::IVideoDriver* getVideoDriver() = 0; - - //! Provides access to the virtual file system. - /** \return Pointer to the file system. */ - virtual io::IFileSystem* getFileSystem() = 0; - - //! Provides access to the 2d user interface environment. - /** \return Pointer to the gui environment. */ - virtual gui::IGUIEnvironment* getGUIEnvironment() = 0; - - //! Provides access to the scene manager. - /** \return Pointer to the scene manager. */ - virtual scene::ISceneManager* getSceneManager() = 0; - - //! Provides access to the cursor control. - /** \return Pointer to the mouse cursor control interface. */ - virtual gui::ICursorControl* getCursorControl() = 0; - - //! Provides access to the message logger. - /** \return Pointer to the logger. */ - virtual ILogger* getLogger() = 0; - - //! Gets a list with all video modes available. - /** If you are confused now, because you think you have to - create an Irrlicht Device with a video mode before being able - to get the video mode list, let me tell you that there is no - need to start up an Irrlicht Device with EDT_DIRECT3D8, - EDT_OPENGL or EDT_SOFTWARE: For this (and for lots of other - reasons) the null driver, EDT_NULL exists. - \return Pointer to a list with all video modes supported - by the gfx adapter. */ - virtual video::IVideoModeList* getVideoModeList() = 0; - - //! Provides access to the operation system operator object. - /** The OS operator provides methods for - getting system specific informations and doing system - specific operations, such as exchanging data with the clipboard - or reading the operation system version. - \return Pointer to the OS operator. */ - virtual IOSOperator* getOSOperator() = 0; - - //! Provides access to the engine's timer. - /** The system time can be retrieved by it as - well as the virtual time, which also can be manipulated. - \return Pointer to the ITimer object. */ - virtual ITimer* getTimer() = 0; - - //! Sets the caption of the window. - /** \param text: New text of the window caption. */ - virtual void setWindowCaption(const wchar_t* text) = 0; - - //! Returns if the window is active. - /** If the window is inactive, - nothing needs to be drawn. So if you don't want to draw anything - when the window is inactive, create your drawing loop this way: - \code - while(device->run()) - { - if (device->isWindowActive()) - { - // draw everything here - } - else - device->yield(); - } - \endcode - \return True if window is active. */ - virtual bool isWindowActive() const = 0; - - //! Checks if the Irrlicht window has focus - /** \return True if window has focus. */ - virtual bool isWindowFocused() const = 0; - - //! Checks if the Irrlicht window is minimized - /** \return True if window is minimized. */ - virtual bool isWindowMinimized() const = 0; - - //! Checks if the Irrlicht window is running in fullscreen mode - /** \return True if window is fullscreen. */ - virtual bool isFullscreen() const = 0; - - //! Get the current color format of the window - /** \return Color format of the window. */ - virtual video::ECOLOR_FORMAT getColorFormat() const = 0; - - //! Notifies the device that it should close itself. - /** IrrlichtDevice::run() will always return false after closeDevice() was called. */ - virtual void closeDevice() = 0; - - //! Get the version of the engine. - /** The returned string - will look like this: "1.2.3" or this: "1.2". - \return String which contains the version. */ - virtual const c8* getVersion() const = 0; - - //! Sets a new user event receiver which will receive events from the engine. - /** Return true in IEventReceiver::OnEvent to prevent the event from continuing along - the chain of event receivers. The path that an event takes through the system depends - on its type. See irr::EEVENT_TYPE for details. - \param receiver New receiver to be used. */ - virtual void setEventReceiver(IEventReceiver* receiver) = 0; - - //! Provides access to the current event receiver. - /** \return Pointer to the current event receiver. Returns 0 if there is none. */ - virtual IEventReceiver* getEventReceiver() = 0; - - //! Sends a user created event to the engine. - /** Is is usually not necessary to use this. However, if you - are using an own input library for example for doing joystick - input, you can use this to post key or mouse input events to - the engine. Internally, this method only delegates the events - further to the scene manager and the GUI environment. */ - virtual bool postEventFromUser(const SEvent& event) = 0; - - //! Sets the input receiving scene manager. - /** If set to null, the main scene manager (returned by - GetSceneManager()) will receive the input - \param sceneManager New scene manager to be used. */ - virtual void setInputReceivingSceneManager(scene::ISceneManager* sceneManager) = 0; - - //! Sets if the window should be resizable in windowed mode. - /** The default is false. This method only works in windowed - mode. - \param resize Flag whether the window should be resizable. */ - virtual void setResizable(bool resize=false) = 0; - - //! Minimizes the window if possible. - virtual void minimizeWindow() =0; - - //! Maximizes the window if possible. - virtual void maximizeWindow() =0; - - //! Restore the window to normal size if possible. - virtual void restoreWindow() =0; - - //! Activate any joysticks, and generate events for them. - /** Irrlicht contains support for joysticks, but does not generate joystick events by default, - as this would consume joystick info that 3rd party libraries might rely on. Call this method to - activate joystick support in Irrlicht and to receive irr::SJoystickEvent events. - \param joystickInfo On return, this will contain an array of each joystick that was found and activated. - \return true if joysticks are supported on this device and _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ - is defined, false if joysticks are not supported or support is compiled out. - */ - virtual bool activateJoysticks(core::array<SJoystickInfo>& joystickInfo) =0; - - //! Set the current Gamma Value for the Display - virtual bool setGammaRamp(f32 red, f32 green, f32 blue, - f32 relativebrightness, f32 relativecontrast) =0; - - //! Get the current Gamma Value for the Display - virtual bool getGammaRamp(f32 &red, f32 &green, f32 &blue, - f32 &brightness, f32 &contrast) =0; - - //! Get the type of the device. - /** This allows the user to check which windowing system is currently being - used. */ - virtual E_DEVICE_TYPE getType() const = 0; - - //! Check if a driver type is supported by the engine. - /** Even if true is returned the driver may not be available - for a configuration requested when creating the device. */ - static bool isDriverSupported(video::E_DRIVER_TYPE driver) - { - switch (driver) - { - case video::EDT_NULL: - return true; - case video::EDT_SOFTWARE: -#ifdef _IRR_COMPILE_WITH_SOFTWARE_ - return true; -#else - return false; -#endif - case video::EDT_BURNINGSVIDEO: -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return true; -#else - return false; -#endif - case video::EDT_DIRECT3D8: -#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ - return true; -#else - return false; -#endif - case video::EDT_DIRECT3D9: -#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ - return true; -#else - return false; -#endif - case video::EDT_OPENGL: -#ifdef _IRR_COMPILE_WITH_OPENGL_ - return true; -#else - return false; -#endif - default: - return false; - } - } - }; - -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/Keycodes.h b/irrlicht-1.6/include/Keycodes.h deleted file mode 100644 index 2310f6d67..000000000 --- a/irrlicht-1.6/include/Keycodes.h +++ /dev/null @@ -1,163 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_KEY_CODES_H_INCLUDED__ -#define __IRR_KEY_CODES_H_INCLUDED__ - -namespace irr -{ - - enum EKEY_CODE - { - KEY_LBUTTON = 0x01, // Left mouse button - KEY_RBUTTON = 0x02, // Right mouse button - KEY_CANCEL = 0x03, // Control-break processing - KEY_MBUTTON = 0x04, // Middle mouse button (three-button mouse) - KEY_XBUTTON1 = 0x05, // Windows 2000/XP: X1 mouse button - KEY_XBUTTON2 = 0x06, // Windows 2000/XP: X2 mouse button - KEY_BACK = 0x08, // BACKSPACE key - KEY_TAB = 0x09, // TAB key - KEY_CLEAR = 0x0C, // CLEAR key - KEY_RETURN = 0x0D, // ENTER key - KEY_SHIFT = 0x10, // SHIFT key - KEY_CONTROL = 0x11, // CTRL key - KEY_MENU = 0x12, // ALT key - KEY_PAUSE = 0x13, // PAUSE key - KEY_CAPITAL = 0x14, // CAPS LOCK key - KEY_KANA = 0x15, // IME Kana mode - KEY_HANGUEL = 0x15, // IME Hanguel mode (maintained for compatibility use KEY_HANGUL) - KEY_HANGUL = 0x15, // IME Hangul mode - KEY_JUNJA = 0x17, // IME Junja mode - KEY_FINAL = 0x18, // IME final mode - KEY_HANJA = 0x19, // IME Hanja mode - KEY_KANJI = 0x19, // IME Kanji mode - KEY_ESCAPE = 0x1B, // ESC key - KEY_CONVERT = 0x1C, // IME convert - KEY_NONCONVERT = 0x1D, // IME nonconvert - KEY_ACCEPT = 0x1E, // IME accept - KEY_MODECHANGE = 0x1F, // IME mode change request - KEY_SPACE = 0x20, // SPACEBAR - KEY_PRIOR = 0x21, // PAGE UP key - KEY_NEXT = 0x22, // PAGE DOWN key - KEY_END = 0x23, // END key - KEY_HOME = 0x24, // HOME key - KEY_LEFT = 0x25, // LEFT ARROW key - KEY_UP = 0x26, // UP ARROW key - KEY_RIGHT = 0x27, // RIGHT ARROW key - KEY_DOWN = 0x28, // DOWN ARROW key - KEY_SELECT = 0x29, // SELECT key - KEY_PRINT = 0x2A, // PRINT key - KEY_EXECUT = 0x2B, // EXECUTE key - KEY_SNAPSHOT = 0x2C, // PRINT SCREEN key - KEY_INSERT = 0x2D, // INS key - KEY_DELETE = 0x2E, // DEL key - KEY_HELP = 0x2F, // HELP key - KEY_KEY_0 = 0x30, // 0 key - KEY_KEY_1 = 0x31, // 1 key - KEY_KEY_2 = 0x32, // 2 key - KEY_KEY_3 = 0x33, // 3 key - KEY_KEY_4 = 0x34, // 4 key - KEY_KEY_5 = 0x35, // 5 key - KEY_KEY_6 = 0x36, // 6 key - KEY_KEY_7 = 0x37, // 7 key - KEY_KEY_8 = 0x38, // 8 key - KEY_KEY_9 = 0x39, // 9 key - KEY_KEY_A = 0x41, // A key - KEY_KEY_B = 0x42, // B key - KEY_KEY_C = 0x43, // C key - KEY_KEY_D = 0x44, // D key - KEY_KEY_E = 0x45, // E key - KEY_KEY_F = 0x46, // F key - KEY_KEY_G = 0x47, // G key - KEY_KEY_H = 0x48, // H key - KEY_KEY_I = 0x49, // I key - KEY_KEY_J = 0x4A, // J key - KEY_KEY_K = 0x4B, // K key - KEY_KEY_L = 0x4C, // L key - KEY_KEY_M = 0x4D, // M key - KEY_KEY_N = 0x4E, // N key - KEY_KEY_O = 0x4F, // O key - KEY_KEY_P = 0x50, // P key - KEY_KEY_Q = 0x51, // Q key - KEY_KEY_R = 0x52, // R key - KEY_KEY_S = 0x53, // S key - KEY_KEY_T = 0x54, // T key - KEY_KEY_U = 0x55, // U key - KEY_KEY_V = 0x56, // V key - KEY_KEY_W = 0x57, // W key - KEY_KEY_X = 0x58, // X key - KEY_KEY_Y = 0x59, // Y key - KEY_KEY_Z = 0x5A, // Z key - KEY_LWIN = 0x5B, // Left Windows key (Microsoft Natural keyboard) - KEY_RWIN = 0x5C, // Right Windows key (Natural keyboard) - KEY_APPS = 0x5D, // Applications key (Natural keyboard) - KEY_SLEEP = 0x5F, // Computer Sleep key - KEY_NUMPAD0 = 0x60, // Numeric keypad 0 key - KEY_NUMPAD1 = 0x61, // Numeric keypad 1 key - KEY_NUMPAD2 = 0x62, // Numeric keypad 2 key - KEY_NUMPAD3 = 0x63, // Numeric keypad 3 key - KEY_NUMPAD4 = 0x64, // Numeric keypad 4 key - KEY_NUMPAD5 = 0x65, // Numeric keypad 5 key - KEY_NUMPAD6 = 0x66, // Numeric keypad 6 key - KEY_NUMPAD7 = 0x67, // Numeric keypad 7 key - KEY_NUMPAD8 = 0x68, // Numeric keypad 8 key - KEY_NUMPAD9 = 0x69, // Numeric keypad 9 key - KEY_MULTIPLY = 0x6A, // Multiply key - KEY_ADD = 0x6B, // Add key - KEY_SEPARATOR = 0x6C, // Separator key - KEY_SUBTRACT = 0x6D, // Subtract key - KEY_DECIMAL = 0x6E, // Decimal key - KEY_DIVIDE = 0x6F, // Divide key - KEY_F1 = 0x70, // F1 key - KEY_F2 = 0x71, // F2 key - KEY_F3 = 0x72, // F3 key - KEY_F4 = 0x73, // F4 key - KEY_F5 = 0x74, // F5 key - KEY_F6 = 0x75, // F6 key - KEY_F7 = 0x76, // F7 key - KEY_F8 = 0x77, // F8 key - KEY_F9 = 0x78, // F9 key - KEY_F10 = 0x79, // F10 key - KEY_F11 = 0x7A, // F11 key - KEY_F12 = 0x7B, // F12 key - KEY_F13 = 0x7C, // F13 key - KEY_F14 = 0x7D, // F14 key - KEY_F15 = 0x7E, // F15 key - KEY_F16 = 0x7F, // F16 key - KEY_F17 = 0x80, // F17 key - KEY_F18 = 0x81, // F18 key - KEY_F19 = 0x82, // F19 key - KEY_F20 = 0x83, // F20 key - KEY_F21 = 0x84, // F21 key - KEY_F22 = 0x85, // F22 key - KEY_F23 = 0x86, // F23 key - KEY_F24 = 0x87, // F24 key - KEY_NUMLOCK = 0x90, // NUM LOCK key - KEY_SCROLL = 0x91, // SCROLL LOCK key - KEY_LSHIFT = 0xA0, // Left SHIFT key - KEY_RSHIFT = 0xA1, // Right SHIFT key - KEY_LCONTROL = 0xA2, // Left CONTROL key - KEY_RCONTROL = 0xA3, // Right CONTROL key - KEY_LMENU = 0xA4, // Left MENU key - KEY_RMENU = 0xA5, // Right MENU key - KEY_PLUS = 0xBB, // Plus Key (+) - KEY_COMMA = 0xBC, // Comma Key (,) - KEY_MINUS = 0xBD, // Minus Key (-) - KEY_PERIOD = 0xBE, // Period Key (.) - KEY_ATTN = 0xF6, // Attn key - KEY_CRSEL = 0xF7, // CrSel key - KEY_EXSEL = 0xF8, // ExSel key - KEY_EREOF = 0xF9, // Erase EOF key - KEY_PLAY = 0xFA, // Play key - KEY_ZOOM = 0xFB, // Zoom key - KEY_PA1 = 0xFD, // PA1 key - KEY_OEM_CLEAR = 0xFE, // Clear key - - KEY_KEY_CODES_COUNT = 0xFF // this is not a key, but the amount of keycodes there are. - }; - -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/S3DVertex.h b/irrlicht-1.6/include/S3DVertex.h deleted file mode 100644 index 86d64fd55..000000000 --- a/irrlicht-1.6/include/S3DVertex.h +++ /dev/null @@ -1,244 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __S_3D_VERTEX_H_INCLUDED__ -#define __S_3D_VERTEX_H_INCLUDED__ - -#include "vector3d.h" -#include "vector2d.h" -#include "SColor.h" - -namespace irr -{ -namespace video -{ - -//! Enumeration for all vertex types there are. -enum E_VERTEX_TYPE -{ - //! Standard vertex type used by the Irrlicht engine, video::S3DVertex. - EVT_STANDARD = 0, - - //! Vertex with two texture coordinates, video::S3DVertex2TCoords. - /** Usually used for geometry with lightmaps or other special materials. */ - EVT_2TCOORDS, - - //! Vertex with a tangent and binormal vector, video::S3DVertexTangents. - /** Usually used for tangent space normal mapping. */ - EVT_TANGENTS -}; - -//! Array holding the built in vertex type names -const char* const sBuiltInVertexTypeNames[] = -{ - "standard", - "2tcoords", - "tangents", - 0 -}; - -//! standard vertex used by the Irrlicht engine. -struct S3DVertex -{ - //! default constructor - S3DVertex() {} - - //! constructor - S3DVertex(f32 x, f32 y, f32 z, f32 nx, f32 ny, f32 nz, SColor c, f32 tu, f32 tv) - : Pos(x,y,z), Normal(nx,ny,nz), Color(c), TCoords(tu,tv) {} - - //! constructor - S3DVertex(const core::vector3df& pos, const core::vector3df& normal, - SColor color, const core::vector2d<f32>& tcoords) - : Pos(pos), Normal(normal), Color(color), TCoords(tcoords) {} - - //! Position - core::vector3df Pos; - - //! Normal vector - core::vector3df Normal; - - //! Color - SColor Color; - - //! Texture coordinates - core::vector2d<f32> TCoords; - - bool operator==(const S3DVertex& other) const - { - return ((Pos == other.Pos) && (Normal == other.Normal) && - (Color == other.Color) && (TCoords == other.TCoords)); - } - - bool operator!=(const S3DVertex& other) const - { - return ((Pos != other.Pos) || (Normal != other.Normal) || - (Color != other.Color) || (TCoords != other.TCoords)); - } - - bool operator<(const S3DVertex& other) const - { - return ((Pos < other.Pos) || - ((Pos == other.Pos) && (Normal < other.Normal)) || - ((Pos == other.Pos) && (Normal == other.Normal) && (Color < other.Color)) || - ((Pos == other.Pos) && (Normal == other.Normal) && (Color == other.Color) && (TCoords < other.TCoords))); - } - - E_VERTEX_TYPE getType() const - { - return EVT_STANDARD; - } -}; - - -//! Vertex with two texture coordinates. -/** Usually used for geometry with lightmaps -or other special materials. -*/ -struct S3DVertex2TCoords : public S3DVertex -{ - //! default constructor - S3DVertex2TCoords() : S3DVertex() {} - - //! constructor with two different texture coords, but no normal - S3DVertex2TCoords(f32 x, f32 y, f32 z, SColor c, f32 tu, f32 tv, f32 tu2, f32 tv2) - : S3DVertex(x,y,z, 0.0f, 0.0f, 0.0f, c, tu,tv), TCoords2(tu2,tv2) {} - - //! constructor with two different texture coords, but no normal - S3DVertex2TCoords(const core::vector3df& pos, SColor color, - const core::vector2d<f32>& tcoords, const core::vector2d<f32>& tcoords2) - : S3DVertex(pos, core::vector3df(), color, tcoords), TCoords2(tcoords2) {} - - //! constructor with all values - S3DVertex2TCoords(const core::vector3df& pos, const core::vector3df& normal, const SColor& color, - const core::vector2d<f32>& tcoords, const core::vector2d<f32>& tcoords2) - : S3DVertex(pos, normal, color, tcoords), TCoords2(tcoords2) {} - - //! constructor with all values - S3DVertex2TCoords(f32 x, f32 y, f32 z, f32 nx, f32 ny, f32 nz, SColor c, f32 tu, f32 tv, f32 tu2, f32 tv2) - : S3DVertex(x,y,z, nx,ny,nz, c, tu,tv), TCoords2(tu2,tv2) {} - - //! constructor with the same texture coords and normal - S3DVertex2TCoords(f32 x, f32 y, f32 z, f32 nx, f32 ny, f32 nz, SColor c, f32 tu, f32 tv) - : S3DVertex(x,y,z, nx,ny,nz, c, tu,tv), TCoords2(tu,tv) {} - - //! constructor with the same texture coords and normal - S3DVertex2TCoords(const core::vector3df& pos, const core::vector3df& normal, - SColor color, const core::vector2d<f32>& tcoords) - : S3DVertex(pos, normal, color, tcoords), TCoords2(tcoords) {} - - //! constructor from S3DVertex - S3DVertex2TCoords(S3DVertex& o) : S3DVertex(o) {} - - //! Second set of texture coordinates - core::vector2d<f32> TCoords2; - - //! Equality operator - bool operator==(const S3DVertex2TCoords& other) const - { - return ((static_cast<S3DVertex>(*this)==other) && - (TCoords2 == other.TCoords2)); - } - - //! Inequality operator - bool operator!=(const S3DVertex2TCoords& other) const - { - return ((static_cast<S3DVertex>(*this)!=other) || - (TCoords2 != other.TCoords2)); - } - - bool operator<(const S3DVertex2TCoords& other) const - { - return ((static_cast<S3DVertex>(*this) < other) || - ((static_cast<S3DVertex>(*this) == other) && (TCoords2 < other.TCoords2))); - } - - E_VERTEX_TYPE getType() const - { - return EVT_2TCOORDS; - } -}; - - -//! Vertex with a tangent and binormal vector. -/** Usually used for tangent space normal mapping. */ -struct S3DVertexTangents : public S3DVertex -{ - //! default constructor - S3DVertexTangents() : S3DVertex() { } - - //! constructor - S3DVertexTangents(f32 x, f32 y, f32 z, f32 nx=0.0f, f32 ny=0.0f, f32 nz=0.0f, - SColor c = 0xFFFFFFFF, f32 tu=0.0f, f32 tv=0.0f, - f32 tanx=0.0f, f32 tany=0.0f, f32 tanz=0.0f, - f32 bx=0.0f, f32 by=0.0f, f32 bz=0.0f) - : S3DVertex(x,y,z, nx,ny,nz, c, tu,tv), Tangent(tanx,tany,tanz), Binormal(bx,by,bz) { } - - //! constructor - S3DVertexTangents(const core::vector3df& pos, SColor c, - const core::vector2df& tcoords) - : S3DVertex(pos, core::vector3df(), c, tcoords) { } - - //! constructor - S3DVertexTangents(const core::vector3df& pos, - const core::vector3df& normal, SColor c, - const core::vector2df& tcoords, - const core::vector3df& tangent=core::vector3df(), - const core::vector3df& binormal=core::vector3df()) - : S3DVertex(pos, normal, c, tcoords), Tangent(tangent), Binormal(binormal) { } - - //! Tangent vector along the x-axis of the texture - core::vector3df Tangent; - - //! Binormal vector (tangent x normal) - core::vector3df Binormal; - - bool operator==(const S3DVertexTangents& other) const - { - return ((static_cast<S3DVertex>(*this)==other) && - (Tangent == other.Tangent) && - (Binormal == other.Binormal)); - } - - bool operator!=(const S3DVertexTangents& other) const - { - return ((static_cast<S3DVertex>(*this)!=other) || - (Tangent != other.Tangent) || - (Binormal != other.Binormal)); - } - - bool operator<(const S3DVertexTangents& other) const - { - return ((static_cast<S3DVertex>(*this) < other) || - ((static_cast<S3DVertex>(*this) == other) && (Tangent < other.Tangent)) || - ((static_cast<S3DVertex>(*this) == other) && (Tangent == other.Tangent) && (Binormal < other.Binormal))); - } - - E_VERTEX_TYPE getType() const - { - return EVT_TANGENTS; - } -}; - - - -inline u32 getVertexPitchFromType(E_VERTEX_TYPE vertexType) -{ - switch (vertexType) - { - case video::EVT_2TCOORDS: - return sizeof(video::S3DVertex2TCoords); - case video::EVT_TANGENTS: - return sizeof(video::S3DVertexTangents); - default: - return sizeof(video::S3DVertex); - } -} - - -} // end namespace video -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/SAnimatedMesh.h b/irrlicht-1.6/include/SAnimatedMesh.h deleted file mode 100644 index 4cf427af7..000000000 --- a/irrlicht-1.6/include/SAnimatedMesh.h +++ /dev/null @@ -1,182 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __S_ANIMATED_MESH_H_INCLUDED__ -#define __S_ANIMATED_MESH_H_INCLUDED__ - -#include "IAnimatedMesh.h" -#include "IMesh.h" -#include "aabbox3d.h" -#include "irrArray.h" - -namespace irr -{ -namespace scene -{ - - //! Simple implementation of the IAnimatedMesh interface. - struct SAnimatedMesh : public IAnimatedMesh - { - //! constructor - SAnimatedMesh(scene::IMesh* mesh=0, scene::E_ANIMATED_MESH_TYPE type=scene::EAMT_UNKNOWN) : IAnimatedMesh(), Type(type) - { - #ifdef _DEBUG - setDebugName("SAnimatedMesh"); - #endif - addMesh(mesh); - recalculateBoundingBox(); - } - - - //! destructor - virtual ~SAnimatedMesh() - { - // drop meshes - for (u32 i=0; i<Meshes.size(); ++i) - Meshes[i]->drop(); - } - - - //! Gets the frame count of the animated mesh. - /** \return Amount of frames. If the amount is 1, it is a static, non animated mesh. */ - virtual u32 getFrameCount() const - { - return Meshes.size(); - } - - - //! Returns the IMesh interface for a frame. - /** \param frame: Frame number as zero based index. The maximum frame number is - getFrameCount() - 1; - \param detailLevel: Level of detail. 0 is the lowest, - 255 the highest level of detail. Most meshes will ignore the detail level. - \param startFrameLoop: start frame - \param endFrameLoop: end frame - \return The animated mesh based on a detail level. */ - virtual IMesh* getMesh(s32 frame, s32 detailLevel, s32 startFrameLoop=-1, s32 endFrameLoop=-1) - { - if (Meshes.empty()) - return 0; - - return Meshes[frame]; - } - - - //! adds a Mesh - void addMesh(IMesh* mesh) - { - if (mesh) - { - mesh->grab(); - Meshes.push_back(mesh); - } - } - - - //! Returns an axis aligned bounding box of the mesh. - /** \return A bounding box of this mesh is returned. */ - virtual const core::aabbox3d<f32>& getBoundingBox() const - { - return Box; - } - - - //! set user axis aligned bounding box - virtual void setBoundingBox(const core::aabbox3df& box) - { - Box = box; - } - - //! Recalculates the bounding box. - void recalculateBoundingBox() - { - Box.reset(0,0,0); - - if (Meshes.empty()) - return; - - Box = Meshes[0]->getBoundingBox(); - - for (u32 i=1; i<Meshes.size(); ++i) - Box.addInternalBox(Meshes[i]->getBoundingBox()); - } - - - //! Returns the type of the animated mesh. - virtual E_ANIMATED_MESH_TYPE getMeshType() const - { - return Type; - } - - - //! returns amount of mesh buffers. - virtual u32 getMeshBufferCount() const - { - if (Meshes.empty()) - return 0; - - return Meshes[0]->getMeshBufferCount(); - } - - - //! returns pointer to a mesh buffer - virtual IMeshBuffer* getMeshBuffer(u32 nr) const - { - if (Meshes.empty()) - return 0; - - return Meshes[0]->getMeshBuffer(nr); - } - - - //! Returns pointer to a mesh buffer which fits a material - /** \param material: material to search for - \return Returns the pointer to the mesh buffer or - NULL if there is no such mesh buffer. */ - virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const - { - if (Meshes.empty()) - return 0; - - return Meshes[0]->getMeshBuffer(material); - } - - - //! Set a material flag for all meshbuffers of this mesh. - virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue) - { - for (u32 i=0; i<Meshes.size(); ++i) - Meshes[i]->setMaterialFlag(flag, newvalue); - } - - //! set the hardware mapping hint, for driver - virtual void setHardwareMappingHint( E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX ) - { - for (u32 i=0; i<Meshes.size(); ++i) - Meshes[i]->setHardwareMappingHint(newMappingHint, buffer); - } - - //! flags the meshbuffer as changed, reloads hardware buffers - virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX) - { - for (u32 i=0; i<Meshes.size(); ++i) - Meshes[i]->setDirty(buffer); - } - - //! All meshes defining the animated mesh - core::array<IMesh*> Meshes; - - //! The bounding box of this mesh - core::aabbox3d<f32> Box; - - //! Tyhe type fo the mesh. - E_ANIMATED_MESH_TYPE Type; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/SColor.h b/irrlicht-1.6/include/SColor.h deleted file mode 100644 index 6fe2ae89d..000000000 --- a/irrlicht-1.6/include/SColor.h +++ /dev/null @@ -1,575 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __COLOR_H_INCLUDED__ -#define __COLOR_H_INCLUDED__ - -#include "irrTypes.h" -#include "irrMath.h" - -namespace irr -{ -namespace video -{ - //! Creates a 16 bit A1R5G5B5 color - inline u16 RGBA16(u32 r, u32 g, u32 b, u32 a=0xFF) - { - return (u16)((a & 0x80) << 8 | - (r & 0xF8) << 7 | - (g & 0xF8) << 2 | - (b & 0xF8) >> 3); - } - - - //! Creates a 16 bit A1R5G5B5 color - inline u16 RGB16(u32 r, u32 g, u32 b) - { - return RGBA16(r,g,b); - } - - - //! Creates a 16bit A1R5G5B5 color, based on 16bit input values - inline u16 RGB16from16(u16 r, u16 g, u16 b) - { - return (0x8000 | - (r & 0x1F) << 10 | - (g & 0x1F) << 5 | - (b & 0x1F)); - } - - - //! Converts a 32bit (X8R8G8B8) color to a 16bit A1R5G5B5 color - inline u16 X8R8G8B8toA1R5G5B5(u32 color) - { - return (u16)(0x8000 | - ( color & 0x00F80000) >> 9 | - ( color & 0x0000F800) >> 6 | - ( color & 0x000000F8) >> 3); - } - - - //! Converts a 32bit (A8R8G8B8) color to a 16bit A1R5G5B5 color - inline u16 A8R8G8B8toA1R5G5B5(u32 color) - { - return (u16)(( color & 0x80000000) >> 16| - ( color & 0x00F80000) >> 9 | - ( color & 0x0000F800) >> 6 | - ( color & 0x000000F8) >> 3); - } - - - //! Converts a 32bit (A8R8G8B8) color to a 16bit R5G6B5 color - inline u16 A8R8G8B8toR5G6B5(u32 color) - { - return (u16)(( color & 0x00F80000) >> 8 | - ( color & 0x0000FC00) >> 5 | - ( color & 0x000000F8) >> 3); - } - - - //! Convert A8R8G8B8 Color from A1R5G5B5 color - /** build a nicer 32bit Color by extending dest lower bits with source high bits. */ - inline u32 A1R5G5B5toA8R8G8B8(u16 color) - { - return ( (( -( (s32) color & 0x00008000 ) >> (s32) 31 ) & 0xFF000000 ) | - (( color & 0x00007C00 ) << 9) | (( color & 0x00007000 ) << 4) | - (( color & 0x000003E0 ) << 6) | (( color & 0x00000380 ) << 1) | - (( color & 0x0000001F ) << 3) | (( color & 0x0000001C ) >> 2) - ); - } - - - //! Returns A8R8G8B8 Color from R5G6B5 color - inline u32 R5G6B5toA8R8G8B8(u16 color) - { - return 0xFF000000 | - ((color & 0xF800) << 8)| - ((color & 0x07E0) << 5)| - ((color & 0x001F) << 3); - } - - - //! Returns A1R5G5B5 Color from R5G6B5 color - inline u16 R5G6B5toA1R5G5B5(u16 color) - { - return 0x8000 | (((color & 0xFFC0) >> 1) | (color & 0x1F)); - } - - - //! Returns R5G6B5 Color from A1R5G5B5 color - inline u16 A1R5G5B5toR5G6B5(u16 color) - { - return (((color & 0x7FE0) << 1) | (color & 0x1F)); - } - - - - //! Returns the alpha component from A1R5G5B5 color - /** In Irrlicht, alpha refers to opacity. - \return The alpha value of the color. 0 is transparent, 1 is opaque. */ - inline u32 getAlpha(u16 color) - { - return ((color >> 15)&0x1); - } - - - //! Returns the red component from A1R5G5B5 color. - /** Shift left by 3 to get 8 bit value. */ - inline u32 getRed(u16 color) - { - return ((color >> 10)&0x1F); - } - - - //! Returns the green component from A1R5G5B5 color - /** Shift left by 3 to get 8 bit value. */ - inline u32 getGreen(u16 color) - { - return ((color >> 5)&0x1F); - } - - - //! Returns the blue component from A1R5G5B5 color - /** Shift left by 3 to get 8 bit value. */ - inline u32 getBlue(u16 color) - { - return (color & 0x1F); - } - - - //! Returns the average from a 16 bit A1R5G5B5 color - inline s32 getAverage(s16 color) - { - return ((getRed(color)<<3) + (getGreen(color)<<3) + (getBlue(color)<<3)) / 3; - } - - - //! Class representing a 32 bit ARGB color. - /** The color values for alpha, red, green, and blue are - stored in a single u32. So all four values may be between 0 and 255. - Alpha in Irrlicht is opacity, so 0 is fully transparent, 255 is fully opaque (solid). - This class is used by most parts of the Irrlicht Engine - to specify a color. Another way is using the class SColorf, which - stores the color values in 4 floats. - This class must consist of only one u32 and must not use virtual functions. - */ - class SColor - { - public: - - //! Constructor of the Color. Does nothing. - /** The color value is not initialized to save time. */ - SColor() {} - - //! Constructs the color from 4 values representing the alpha, red, green and blue component. - /** Must be values between 0 and 255. */ - SColor (u32 a, u32 r, u32 g, u32 b) - : color(((a & 0xff)<<24) | ((r & 0xff)<<16) | ((g & 0xff)<<8) | (b & 0xff)) {} - - //! Constructs the color from a 32 bit value. Could be another color. - SColor(u32 clr) - : color(clr) {} - - //! Returns the alpha component of the color. - /** The alpha component defines how opaque a color is. - \return The alpha value of the color. 0 is fully transparent, 255 is fully opaque. */ - u32 getAlpha() const { return color>>24; } - - //! Returns the red component of the color. - /** \return Value between 0 and 255, specifying how red the color is. - 0 means no red, 255 means full red. */ - u32 getRed() const { return (color>>16) & 0xff; } - - //! Returns the green component of the color. - /** \return Value between 0 and 255, specifying how green the color is. - 0 means no green, 255 means full green. */ - u32 getGreen() const { return (color>>8) & 0xff; } - - //! Returns the blue component of the color. - /** \return Value between 0 and 255, specifying how blue the color is. - 0 means no blue, 255 means full blue. */ - u32 getBlue() const { return color & 0xff; } - - //! Returns the luminance of the color. - f32 getLuminance() const - { - return 0.3f*getRed() + 0.59f*getGreen() + 0.11f*getBlue(); - } - - //! Returns the average intensity of the color. - u32 getAverage() const - { - return ( getRed() + getGreen() + getBlue() ) / 3; - } - - //! Sets the alpha component of the Color. - /** The alpha component defines how transparent a color should be. - \param a The alpha value of the color. 0 is fully transparent, 255 is fully opaque. */ - void setAlpha(u32 a) { color = ((a & 0xff)<<24) | (color & 0x00ffffff); } - - //! Sets the red component of the Color. - /** \param r: Has to be a value between 0 and 255. - 0 means no red, 255 means full red. */ - void setRed(u32 r) { color = ((r & 0xff)<<16) | (color & 0xff00ffff); } - - //! Sets the green component of the Color. - /** \param g: Has to be a value between 0 and 255. - 0 means no green, 255 means full green. */ - void setGreen(u32 g) { color = ((g & 0xff)<<8) | (color & 0xffff00ff); } - - //! Sets the blue component of the Color. - /** \param b: Has to be a value between 0 and 255. - 0 means no blue, 255 means full blue. */ - void setBlue(u32 b) { color = (b & 0xff) | (color & 0xffffff00); } - - //! Calculates a 16 bit A1R5G5B5 value of this color. - /** \return 16 bit A1R5G5B5 value of this color. */ - u16 toA1R5G5B5() const { return A8R8G8B8toA1R5G5B5(color); } - - //! Converts color to OpenGL color format - /** From ARGB to RGBA in 4 byte components for endian aware - passing to OpenGL - \param dest: address where the 4x8 bit OpenGL color is stored. */ - void toOpenGLColor(u8* dest) const - { - *dest = (u8)getRed(); - *++dest = (u8)getGreen(); - *++dest = (u8)getBlue(); - *++dest = (u8)getAlpha(); - } - - //! Sets all four components of the color at once. - /** Constructs the color from 4 values representing the alpha, - red, green and blue components of the color. Must be values - between 0 and 255. - \param a: Alpha component of the color. The alpha component - defines how transparent a color should be. Has to be a value - between 0 and 255. 255 means not transparent (opaque), 0 means - fully transparent. - \param r: Sets the red component of the Color. Has to be a - value between 0 and 255. 0 means no red, 255 means full red. - \param g: Sets the green component of the Color. Has to be a - value between 0 and 255. 0 means no green, 255 means full - green. - \param b: Sets the blue component of the Color. Has to be a - value between 0 and 255. 0 means no blue, 255 means full blue. */ - void set(u32 a, u32 r, u32 g, u32 b) - { - color = (((a & 0xff)<<24) | ((r & 0xff)<<16) | ((g & 0xff)<<8) | (b & 0xff)); - } - void set(u32 col) { color = col; } - - //! Compares the color to another color. - /** \return True if the colors are the same, and false if not. */ - bool operator==(const SColor& other) const { return other.color == color; } - - //! Compares the color to another color. - /** \return True if the colors are different, and false if they are the same. */ - bool operator!=(const SColor& other) const { return other.color != color; } - - //! comparison operator - /** \return True if this color is smaller than the other one */ - bool operator<(const SColor& other) const { return (color < other.color); } - - //! Adds two colors, result is clamped to 0..255 values - /** \param other Color to add to this color - \return Addition of the two colors, clamped to 0..255 values */ - SColor operator+(const SColor& other) const - { - return SColor(core::min_(getAlpha() + other.getAlpha(), 255u), - core::min_(getRed() + other.getRed(), 255u), - core::min_(getGreen() + other.getGreen(), 255u), - core::min_(getBlue() + other.getBlue(), 255u)); - } - - //! Interpolates the color with a f32 value to another color - /** \param other: Other color - \param d: value between 0.0f and 1.0f - \return Interpolated color. */ - SColor getInterpolated(const SColor &other, f32 d) const - { - d = core::clamp(d, 0.f, 1.f); - const f32 inv = 1.0f - d; - return SColor((u32)(other.getAlpha()*inv + getAlpha()*d), - (u32)(other.getRed()*inv + getRed()*d), - (u32)(other.getGreen()*inv + getGreen()*d), - (u32)(other.getBlue()*inv + getBlue()*d)); - } - - //! Returns interpolated color. ( quadratic ) - /** \param c1: first color to interpolate with - \param c2: second color to interpolate with - \param d: value between 0.0f and 1.0f. */ - SColor getInterpolated_quadratic(const SColor& c1, const SColor& c2, f32 d) const - { - // this*(1-d)*(1-d) + 2 * c1 * (1-d) + c2 * d * d; - d = core::clamp(d, 0.f, 1.f); - const f32 inv = 1.f - d; - const f32 mul0 = inv * inv; - const f32 mul1 = 2.f * d * inv; - const f32 mul2 = d * d; - - return SColor( - core::clamp( core::floor32( - getAlpha() * mul0 + c1.getAlpha() * mul1 + c2.getAlpha() * mul2 ), 0, 255 ), - core::clamp( core::floor32( - getRed() * mul0 + c1.getRed() * mul1 + c2.getRed() * mul2 ), 0, 255 ), - core::clamp ( core::floor32( - getGreen() * mul0 + c1.getGreen() * mul1 + c2.getGreen() * mul2 ), 0, 255 ), - core::clamp ( core::floor32( - getBlue() * mul0 + c1.getBlue() * mul1 + c2.getBlue() * mul2 ), 0, 255 )); - } - - //! color in A8R8G8B8 Format - u32 color; - }; - - - //! Class representing a color with four floats. - /** The color values for red, green, blue - and alpha are each stored in a 32 bit floating point variable. - So all four values may be between 0.0f and 1.0f. - Another, faster way to define colors is using the class SColor, which - stores the color values in a single 32 bit integer. - */ - class SColorf - { - public: - //! Default constructor for SColorf. - /** Sets red, green and blue to 0.0f and alpha to 1.0f. */ - SColorf() : r(0.0f), g(0.0f), b(0.0f), a(1.0f) {} - - //! Constructs a color from up to four color values: red, green, blue, and alpha. - /** \param r: Red color component. Should be a value between - 0.0f meaning no red and 1.0f, meaning full red. - \param g: Green color component. Should be a value between 0.0f - meaning no green and 1.0f, meaning full green. - \param b: Blue color component. Should be a value between 0.0f - meaning no blue and 1.0f, meaning full blue. - \param a: Alpha color component of the color. The alpha - component defines how transparent a color should be. Has to be - a value between 0.0f and 1.0f, 1.0f means not transparent - (opaque), 0.0f means fully transparent. */ - SColorf(f32 r, f32 g, f32 b, f32 a = 1.0f) : r(r), g(g), b(b), a(a) {} - - //! Constructs a color from 32 bit Color. - /** \param c: 32 bit color from which this SColorf class is - constructed from. */ - SColorf(SColor c) - { - const f32 inv = 1.0f / 255.0f; - r = c.getRed() * inv; - g = c.getGreen() * inv; - b = c.getBlue() * inv; - a = c.getAlpha() * inv; - } - - //! Converts this color to a SColor without floats. - SColor toSColor() const - { - return SColor((u32)(a*255.0f), (u32)(r*255.0f), (u32)(g*255.0f), (u32)(b*255.0f)); - } - - //! Sets three color components to new values at once. - /** \param rr: Red color component. Should be a value between 0.0f meaning - no red (=black) and 1.0f, meaning full red. - \param gg: Green color component. Should be a value between 0.0f meaning - no green (=black) and 1.0f, meaning full green. - \param bb: Blue color component. Should be a value between 0.0f meaning - no blue (=black) and 1.0f, meaning full blue. */ - void set(f32 rr, f32 gg, f32 bb) {r = rr; g =gg; b = bb; } - - //! Sets all four color components to new values at once. - /** \param aa: Alpha component. Should be a value between 0.0f meaning - fully transparent and 1.0f, meaning opaque. - \param rr: Red color component. Should be a value between 0.0f meaning - no red and 1.0f, meaning full red. - \param gg: Green color component. Should be a value between 0.0f meaning - no green and 1.0f, meaning full green. - \param bb: Blue color component. Should be a value between 0.0f meaning - no blue and 1.0f, meaning full blue. */ - void set(f32 aa, f32 rr, f32 gg, f32 bb) {a = aa; r = rr; g =gg; b = bb; } - - //! Interpolates the color with a f32 value to another color - /** \param other: Other color - \param d: value between 0.0f and 1.0f - \return Interpolated color. */ - SColorf getInterpolated(const SColorf &other, f32 d) const - { - d = core::clamp(d, 0.f, 1.f); - const f32 inv = 1.0f - d; - return SColorf(other.r*inv + r*d, - other.g*inv + g*d, other.b*inv + b*d, other.a*inv + a*d); - } - - //! Returns interpolated color. ( quadratic ) - /** \param c1: first color to interpolate with - \param c2: second color to interpolate with - \param d: value between 0.0f and 1.0f. */ - inline SColorf getInterpolated_quadratic(const SColorf& c1, const SColorf& c2, - f32 d) const - { - d = core::clamp(d, 0.f, 1.f); - // this*(1-d)*(1-d) + 2 * c1 * (1-d) + c2 * d * d; - const f32 inv = 1.f - d; - const f32 mul0 = inv * inv; - const f32 mul1 = 2.f * d * inv; - const f32 mul2 = d * d; - - return SColorf (r * mul0 + c1.r * mul1 + c2.r * mul2, - g * mul0 + c1.g * mul1 + c2.g * mul2, - g * mul0 + c1.b * mul1 + c2.b * mul2, - a * mul0 + c1.a * mul1 + c2.a * mul2); - } - - - //! Sets a color component by index. R=0, G=1, B=2, A=3 - void setColorComponentValue(s32 index, f32 value) - { - switch(index) - { - case 0: r = value; break; - case 1: g = value; break; - case 2: b = value; break; - case 3: a = value; break; - } - } - - //! Returns the alpha component of the color in the range 0.0 (transparent) to 1.0 (opaque) - f32 getAlpha() const { return a; } - - //! Returns the red component of the color in the range 0.0 to 1.0 - f32 getRed() const { return r; } - - //! Returns the green component of the color in the range 0.0 to 1.0 - f32 getGreen() const { return g; } - - //! Returns the blue component of the color in the range 0.0 to 1.0 - f32 getBlue() const { return b; } - - //! red color component - f32 r; - - //! green color component - f32 g; - - //! blue component - f32 b; - - //! alpha color component - f32 a; - }; - - - //! Class representing a color in HSV format - /** The color values for hue, saturation, value - are stored in a 32 bit floating point variable. - */ - class SColorHSL - { - public: - SColorHSL ( f32 h = 0.f, f32 s = 0.f, f32 l = 0.f ) - : Hue ( h ), Saturation ( s ), Luminance ( l ) {} - - void fromRGB(const SColor &color); - void toRGB(SColor &color) const; - - f32 Hue; - f32 Saturation; - f32 Luminance; - - private: - inline u32 toRGB1(f32 rm1, f32 rm2, f32 rh) const; - - }; - - inline void SColorHSL::fromRGB(const SColor &color) - { - const f32 maxVal = (f32)core::max_(color.getRed(), color.getGreen(), color.getBlue()); - const f32 minVal = (f32)core::min_(color.getRed(), color.getGreen(), color.getBlue()); - Luminance = (maxVal/minVal)*0.5f; - if (core::equals(maxVal, minVal)) - { - Hue=0.f; - Saturation=0.f; - return; - } - - const f32 delta = maxVal-minVal; - if ( Luminance <= 0.5f ) - { - Saturation = (delta)/(maxVal+minVal); - } - else - { - Saturation = (delta)/(2-maxVal-minVal); - } - - if (maxVal==color.getRed()) - Hue = (color.getGreen()-color.getBlue())/delta; - else if (maxVal==color.getGreen()) - Hue = 2+(color.getBlue()-color.getRed())/delta; - else if (maxVal==color.getBlue()) - Hue = 4+(color.getRed()-color.getGreen())/delta; - - Hue *= (60.0f * core::DEGTORAD); - while ( Hue < 0.f ) - Hue += 2.f * core::PI; - } - - - inline void SColorHSL::toRGB(SColor &color) const - { - if (core::iszero(Saturation)) // grey - { - u8 c = (u8) ( Luminance * 255.0 ); - color.setRed(c); - color.setGreen(c); - color.setBlue(c); - return; - } - - f32 rm2; - - if ( Luminance <= 0.5f ) - { - rm2 = Luminance + Luminance * Saturation; - } - else - { - rm2 = Luminance + Saturation - Luminance * Saturation; - } - - const f32 rm1 = 2.0f * Luminance - rm2; - - color.setRed ( toRGB1(rm1, rm2, Hue + (120.0f * core::DEGTORAD )) ); - color.setGreen ( toRGB1(rm1, rm2, Hue) ); - color.setBlue ( toRGB1(rm1, rm2, Hue - (120.0f * core::DEGTORAD) ) ); - } - - - inline u32 SColorHSL::toRGB1(f32 rm1, f32 rm2, f32 rh) const - { - while ( rh > 2.f * core::PI ) - rh -= 2.f * core::PI; - - while ( rh < 0.f ) - rh += 2.f * core::PI; - - if (rh < 60.0f * core::DEGTORAD ) - rm1 = rm1 + (rm2 - rm1) * rh / (60.0f * core::DEGTORAD); - else if (rh < 180.0f * core::DEGTORAD ) - rm1 = rm2; - else if (rh < 240.0f * core::DEGTORAD ) - rm1 = rm1 + (rm2 - rm1) * ( ( 240.0f * core::DEGTORAD ) - rh) / - (60.0f * core::DEGTORAD); - - return (u32) (rm1 * 255.f); - } - -} // end namespace video -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/SExposedVideoData.h b/irrlicht-1.6/include/SExposedVideoData.h deleted file mode 100644 index 362240d55..000000000 --- a/irrlicht-1.6/include/SExposedVideoData.h +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __S_EXPOSED_VIDEO_DATA_H_INCLUDED__ -#define __S_EXPOSED_VIDEO_DATA_H_INCLUDED__ - -// forward declarations for internal pointers -struct IDirect3D9; -struct IDirect3DDevice9; -struct IDirect3D8; -struct IDirect3DDevice8; - -namespace irr -{ -namespace video -{ - -//! structure for holding data describing a driver and operating system specific data. -/** This data can be retrived by IVideoDriver::getExposedVideoData(). Use this with caution. -This only should be used to make it possible to extend the engine easily without -modification of its source. Note that this structure does not contain any valid data, if -you are using the software or the null device. -*/ -struct SExposedVideoData -{ - union - { - struct - { - //! Pointer to the IDirect3D9 interface - IDirect3D9* D3D9; - - //! Pointer to the IDirect3D9 interface - IDirect3DDevice9* D3DDev9; - - //! Window handle. - /** Get with for example HWND h = reinterpret_cast<HWND>(exposedData.D3D9.HWnd) */ - void* HWnd; - - } D3D9; - - struct - { - //! Pointer to the IDirect3D8 interface - IDirect3D8* D3D8; - - //! Pointer to the IDirect3D8 interface - IDirect3DDevice8* D3DDev8; - - //! Window handle. - /** Get with for example with: HWND h = reinterpret_cast<HWND>(exposedData.D3D8.HWnd) */ - void* HWnd; - - } D3D8; - - struct - { - //! Private GDI Device Context. - /** Get if for example with: HDC h = reinterpret_cast<HDC>(exposedData.OpenGLWin32.HDc) */ - void* HDc; - - //! Permanent Rendering Context. - /** Get if for example with: HGLRC h = reinterpret_cast<HGLRC>(exposedData.OpenGLWin32.HRc) */ - void* HRc; - - //! Window handle. - /** Get with for example with: HWND h = reinterpret_cast<HWND>(exposedData.OpenGLWin32.HWnd) */ - void* HWnd; - } OpenGLWin32; - - struct - { - // XWindow handles - void* X11Display; - void* X11Context; - unsigned long X11Window; - } OpenGLLinux; - }; -}; - -} // end namespace video -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/include/SIrrCreationParameters.h b/irrlicht-1.6/include/SIrrCreationParameters.h deleted file mode 100644 index ed34a7f02..000000000 --- a/irrlicht-1.6/include/SIrrCreationParameters.h +++ /dev/null @@ -1,241 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_IRRLICHT_CREATION_PARAMETERS_H_INCLUDED__ -#define __I_IRRLICHT_CREATION_PARAMETERS_H_INCLUDED__ - -#include "EDriverTypes.h" -#include "EDeviceTypes.h" -#include "dimension2d.h" - -namespace irr -{ - class IEventReceiver; - - //! Structure for holding Irrlicht Device creation parameters. - /** This structure is used in the createDeviceEx() function. */ - struct SIrrlichtCreationParameters - { - //! Constructs a SIrrlichtCreationParameters structure with default values. - SIrrlichtCreationParameters() : - DeviceType(EIDT_BEST), - DriverType(video::EDT_BURNINGSVIDEO), - WindowSize(core::dimension2d<u32>(800, 600)), - Bits(16), - ZBufferBits(16), - Fullscreen(false), - Stencilbuffer(false), - Vsync(false), - AntiAlias(0), - WithAlphaChannel(false), - Doublebuffer(true), - IgnoreInput(false), - Stereobuffer(false), - HighPrecisionFPU(false), - EventReceiver(0), - WindowId(0), - SDK_version_do_not_use(IRRLICHT_SDK_VERSION) - { - } - - SIrrlichtCreationParameters(const SIrrlichtCreationParameters& other) : - SDK_version_do_not_use(IRRLICHT_SDK_VERSION) - {*this = other;} - - SIrrlichtCreationParameters& operator=(const SIrrlichtCreationParameters& other) - { - DeviceType = other.DeviceType; - DriverType = other.DriverType; - WindowSize = other.WindowSize; - Bits = other.Bits; - ZBufferBits = other.ZBufferBits; - Fullscreen = other.Fullscreen; - Stencilbuffer = other.Stencilbuffer; - Vsync = other.Vsync; - AntiAlias = other.AntiAlias; - WithAlphaChannel = other.WithAlphaChannel; - Doublebuffer = other.Doublebuffer; - IgnoreInput = other.IgnoreInput; - Stereobuffer = other.Stereobuffer; - HighPrecisionFPU = other.HighPrecisionFPU; - EventReceiver = other.EventReceiver; - WindowId = other.WindowId; - return *this; - } - - //! Type of the device. - /** This setting decides the windowing system used by the device, most device types are native - to a specific operating system and so may not be available. - EIDT_WIN32 is only available on Windows desktops, - EIDT_WINCE is only available on Windows mobile devices, - EIDT_COCOA is only available on Mac OSX, - EIDT_X11 is available on Linux, Solaris, BSD and other operating systems which use X11, - EIDT_SDL is available on most systems if compiled in, - EIDT_CONSOLE is usually available but can only render to text, - EIDT_BEST will select the best available device for your operating system. - Default: EIDT_BEST. */ - E_DEVICE_TYPE DeviceType; - - //! Type of video driver used to render graphics. - /** This can currently be video::EDT_NULL, video::EDT_SOFTWARE, - video::EDT_BURNINGSVIDEO, video::EDT_DIRECT3D8, - video::EDT_DIRECT3D9, and video::EDT_OPENGL. - Default: Software. */ - video::E_DRIVER_TYPE DriverType; - - //! Size of the window or the video mode in fullscreen mode. Default: 800x600 - core::dimension2d<u32> WindowSize; - - //! Minimum Bits per pixel of the color buffer in fullscreen mode. Ignored if windowed mode. Default: 16. - u8 Bits; - - //! Minimum Bits per pixel of the depth buffer. Default: 16. - u8 ZBufferBits; - - //! Should be set to true if the device should run in fullscreen. - /** Otherwise the device runs in windowed mode. Default: false. */ - bool Fullscreen; - - //! Specifies if the stencil buffer should be enabled. - /** Set this to true, if you want the engine be able to draw - stencil buffer shadows. Note that not all drivers are able to - use the stencil buffer, hence it can be ignored during device - creation. Without the stencil buffer no shadows will be drawn. - Default: false. */ - bool Stencilbuffer; - - //! Specifies vertical syncronisation. - /** If set to true, the driver will wait for the vertical - retrace period, otherwise not. May be silently ignored. - Default: false */ - bool Vsync; - - //! Specifies if the device should use fullscreen anti aliasing - /** Makes sharp/pixelated edges softer, but requires more - performance. Also, 2D elements might look blurred with this - switched on. The resulting rendering quality also depends on - the hardware and driver you are using, your program might look - different on different hardware with this. So if you are - writing a game/application with AntiAlias switched on, it would - be a good idea to make it possible to switch this option off - again by the user. - The value is the maximal antialiasing factor requested for - the device. The cretion method will automatically try smaller - values if no window can be created with the given value. - Value one is usually the same as 0 (disabled), but might be a - special value on some platforms. On D3D devices it maps to - NONMASKABLE. - Default value: 0 - disabled */ - u8 AntiAlias; - - //! Whether the main framebuffer uses an alpha channel. - /** In some situations it might be desireable to get a color - buffer with an alpha channel, e.g. when rendering into a - transparent window or overlay. If this flag is set the device - tries to create a framebuffer with alpha channel. - If this flag is set, only color buffers with alpha channel - are considered. Otherwise, it depends on the actual hardware - if the colorbuffer has an alpha channel or not. - Default value: false */ - bool WithAlphaChannel; - - //! Whether the main framebuffer uses doublebuffering. - /** This should be usually enabled, in order to avoid render - artifacts on the visible framebuffer. However, it might be - useful to use only one buffer on very small devices. If no - doublebuffering is available, the drivers will fall back to - single buffers. Default value: true */ - bool Doublebuffer; - - //! Specifies if the device should ignore input events - /** This is only relevant when using external I/O handlers. - External windows need to take care of this themselves. - Currently only supported by X11. - Default value: false */ - bool IgnoreInput; - - //! Specifies if the device should use stereo buffers - /** Some high-end gfx cards support two framebuffers for direct - support of stereoscopic output devices. If this flag is set the - device tries to create a stereo context. - Currently only supported by OpenGL. - Default value: false */ - bool Stereobuffer; - - //! Specifies if the device should use high precision FPU setting - /** This is only relevant for DirectX Devices, which switch to - low FPU precision by default for performance reasons. However, - this may lead to problems with the other computations of the - application. In this case setting this flag to true should help - - on the expense of performance loss, though. - Default value: false */ - bool HighPrecisionFPU; - - //! A user created event receiver. - IEventReceiver* EventReceiver; - - //! Window Id. - /** If this is set to a value other than 0, the Irrlicht Engine - will be created in an already existing window. For windows, set - this to the HWND of the window you want. The windowSize and - FullScreen options will be ignored when using the WindowId - parameter. Default this is set to 0. - To make Irrlicht run inside the custom window, you still will - have to draw Irrlicht on your own. You can use this loop, as - usual: - \code - while (device->run()) - { - driver->beginScene(true, true, 0); - smgr->drawAll(); - driver->endScene(); - } - \endcode - Instead of this, you can also simply use your own message loop - using GetMessage, DispatchMessage and whatever. Calling - IrrlichtDevice::run() will cause Irrlicht to dispatch messages - internally too. You need not call Device->run() if you want to - do your own message dispatching loop, but Irrlicht will not be - able to fetch user input then and you have to do it on your own - using the window messages, DirectInput, or whatever. Also, - you'll have to increment the Irrlicht timer. - An alternative, own message dispatching loop without - device->run() would look like this: - \code - MSG msg; - while (true) - { - if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - - if (msg.message == WM_QUIT) - break; - } - - // increase virtual timer time - device->getTimer()->tick(); - - // draw engine picture - driver->beginScene(true, true, 0); - smgr->drawAll(); - driver->endScene(); - } - \endcode - However, there is no need to draw the picture this often. Just - do it how you like. */ - void* WindowId; - - //! Don't use or change this parameter. - /** Always set it to IRRLICHT_SDK_VERSION, which is done by default. - This is needed for sdk version checks. */ - const c8* const SDK_version_do_not_use; - }; - - -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/SKeyMap.h b/irrlicht-1.6/include/SKeyMap.h deleted file mode 100644 index e6dd929bd..000000000 --- a/irrlicht-1.6/include/SKeyMap.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __S_KEY_MAP_H_INCLUDED__ -#define __S_KEY_MAP_H_INCLUDED__ - -#include "Keycodes.h" - -namespace irr -{ - - //! enumeration for key actions. Used for example in the FPS Camera. - enum EKEY_ACTION - { - EKA_MOVE_FORWARD = 0, - EKA_MOVE_BACKWARD, - EKA_STRAFE_LEFT, - EKA_STRAFE_RIGHT, - EKA_JUMP_UP, - EKA_CROUCH, - EKA_COUNT, - - //! This value is not used. It only forces this enumeration to compile in 32 bit. - EKA_FORCE_32BIT = 0x7fffffff - }; - - //! Struct storing which key belongs to which action. - struct SKeyMap - { - EKEY_ACTION Action; - EKEY_CODE KeyCode; - }; - -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/SLight.h b/irrlicht-1.6/include/SLight.h deleted file mode 100644 index e5b1dfe1a..000000000 --- a/irrlicht-1.6/include/SLight.h +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __S_LIGHT_H_INCLUDED__ -#define __S_LIGHT_H_INCLUDED__ - -#include "SColor.h" - -namespace irr -{ -namespace video -{ - -//! Enumeration for different types of lights -enum E_LIGHT_TYPE -{ - //! point light, it has a position in space and radiates light in all directions - ELT_POINT, - //! spot light, it has a position in space, a direction, and a limited cone of influence - ELT_SPOT, - //! directional light, coming from a direction from an infinite distance - ELT_DIRECTIONAL -}; - -//! Names for light types -const c8* const LightTypeNames[] = -{ - "Point", - "Spot", - "Directional", - 0 -}; - -//! structure for holding data describing a dynamic point light. -/** Irrlicht supports point lights, spot lights, and directional lights. -*/ -struct SLight -{ - SLight() : AmbientColor(0.f,0.f,0.f), DiffuseColor(1.f,1.f,1.f), - SpecularColor(1.f,1.f,1.f), Attenuation(1.f,0.f,0.f), - OuterCone(45.f), InnerCone(0.f), Falloff(2.f), - Position(0.f,0.f,0.f), Direction(0.f,0.f,1.f), - Radius(100.f), Type(ELT_POINT), CastShadows(true) - {} - - //! Ambient color emitted by the light - SColorf AmbientColor; - - //! Diffuse color emitted by the light. - /** This is the primary color you want to set. */ - SColorf DiffuseColor; - - //! Specular color emitted by the light. - /** For details how to use specular highlights, see SMaterial::Shininess */ - SColorf SpecularColor; - - //! Attenuation factors (constant, linear, quadratic) - /** Changes the light strength fading over distance. - Can also be altered by setting the radius, Attenuation will change to - (0,1.f/radius,0). Can be overridden after radius was set. */ - core::vector3df Attenuation; - - //! The angle of the spot's outer cone. Ignored for other lights. - f32 OuterCone; - - //! The angle of the spot's inner cone. Ignored for other lights. - f32 InnerCone; - - //! The light strength's decrease between Outer and Inner cone. - f32 Falloff; - - //! Read-ONLY! Position of the light. - /** If Type is ELT_DIRECTIONAL, it is ignored. Changed via light scene node's position. */ - core::vector3df Position; - - //! Read-ONLY! Direction of the light. - /** If Type is ELT_POINT, it is ignored. Changed via light scene node's rotation. */ - core::vector3df Direction; - - //! Read-ONLY! Radius of light. Everything within this radius be be lighted. - f32 Radius; - - //! Read-ONLY! Type of the light. Default: ELT_POINT - E_LIGHT_TYPE Type; - - //! Read-ONLY! Does the light cast shadows? - bool CastShadows:1; -}; - -} // end namespace video -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/SMaterial.h b/irrlicht-1.6/include/SMaterial.h deleted file mode 100644 index bae0e48f5..000000000 --- a/irrlicht-1.6/include/SMaterial.h +++ /dev/null @@ -1,602 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __S_MATERIAL_H_INCLUDED__ -#define __S_MATERIAL_H_INCLUDED__ - -#include "SColor.h" -#include "matrix4.h" -#include "irrArray.h" -#include "irrMath.h" -#include "EMaterialTypes.h" -#include "EMaterialFlags.h" -#include "SMaterialLayer.h" - -namespace irr -{ -namespace video -{ - class ITexture; - - //! Flag for EMT_ONETEXTURE_BLEND, ( BlendFactor ) BlendFunc = source * sourceFactor + dest * destFactor - enum E_BLEND_FACTOR - { - EBF_ZERO = 0, //!< src & dest (0, 0, 0, 0) - EBF_ONE, //!< src & dest (1, 1, 1, 1) - EBF_DST_COLOR, //!< src (destR, destG, destB, destA) - EBF_ONE_MINUS_DST_COLOR, //!< src (1-destR, 1-destG, 1-destB, 1-destA) - EBF_SRC_COLOR, //!< dest (srcR, srcG, srcB, srcA) - EBF_ONE_MINUS_SRC_COLOR, //!< dest (1-srcR, 1-srcG, 1-srcB, 1-srcA) - EBF_SRC_ALPHA, //!< src & dest (srcA, srcA, srcA, srcA) - EBF_ONE_MINUS_SRC_ALPHA, //!< src & dest (1-srcA, 1-srcA, 1-srcA, 1-srcA) - EBF_DST_ALPHA, //!< src & dest (destA, destA, destA, destA) - EBF_ONE_MINUS_DST_ALPHA, //!< src & dest (1-destA, 1-destA, 1-destA, 1-destA) - EBF_SRC_ALPHA_SATURATE //!< src (min(srcA, 1-destA), idem, ...) - }; - - //! MaterialTypeParam: e.g. DirectX: D3DTOP_MODULATE, D3DTOP_MODULATE2X, D3DTOP_MODULATE4X - enum E_MODULATE_FUNC - { - EMFN_MODULATE_1X = 1, - EMFN_MODULATE_2X = 2, - EMFN_MODULATE_4X = 4 - }; - - //! Comparison function, e.g. for depth buffer test - enum E_COMPARISON_FUNC - { - //! Test never succeeds, this equals disable - ECFN_NEVER=0, - //! <= test, default for e.g. depth test - ECFN_LESSEQUAL=1, - //! Exact equality - ECFN_EQUAL=2, - //! exclusive less comparison, i.e. < - ECFN_LESS, - //! Succeeds almost always, except for exact equality - ECFN_NOTEQUAL, - //! >= test - ECFN_GREATEREQUAL, - //! inverse of <= - ECFN_GREATER, - //! test succeeds always - ECFN_ALWAYS - }; - - //! Enum values for enabling/disabling color planes for rendering - enum E_COLOR_PLANE - { - //! No color enabled - ECP_NONE=0, - //! Alpha enabled - ECP_ALPHA=1, - //! Red enabled - ECP_RED=2, - //! Green enabled - ECP_GREEN=4, - //! Blue enabled - ECP_BLUE=8, - //! All colors, no alpha - ECP_RGB=14, - //! All planes enabled - ECP_ALL=15 - }; - - //! Source of the alpha value to take - /** This is currently only supported in EMT_ONETEXTURE_BLEND. You can use an - or'ed combination of values. Alpha values are modulated (multiplicated). */ - enum E_ALPHA_SOURCE - { - //! Use no alpha, somewhat redundant with other settings - EAS_NONE=0, - //! Use vertex color alpha - EAS_VERTEX_COLOR, - //! Use texture alpha channel - EAS_TEXTURE - }; - - //! EMT_ONETEXTURE_BLEND: pack srcFact, dstFact, Modulate and alpha source to MaterialTypeParam - /** alpha source can be an OR'ed combination of E_ALPHA_SOURCE values. */ - inline f32 pack_texureBlendFunc ( const E_BLEND_FACTOR srcFact, const E_BLEND_FACTOR dstFact, const E_MODULATE_FUNC modulate=EMFN_MODULATE_1X, const u32 alphaSource=EAS_TEXTURE ) - { - const u32 tmp = (alphaSource << 24) | (modulate << 16) | (srcFact << 8) | dstFact; - return FR(tmp); - } - - //! EMT_ONETEXTURE_BLEND: unpack srcFact & dstFact and Modulo to MaterialTypeParam - /** The fields don't use the full byte range, so we could pack even more... */ - inline void unpack_texureBlendFunc ( E_BLEND_FACTOR &srcFact, E_BLEND_FACTOR &dstFact, - E_MODULATE_FUNC &modulo, u32& alphaSource, const f32 param ) - { - const u32 state = IR(param); - alphaSource = (state & 0xFF000000) >> 24; - modulo = E_MODULATE_FUNC( ( state & 0x00FF0000 ) >> 16 ); - srcFact = E_BLEND_FACTOR ( ( state & 0x0000FF00 ) >> 8 ); - dstFact = E_BLEND_FACTOR ( ( state & 0x000000FF ) ); - } - - //! EMT_ONETEXTURE_BLEND: has BlendFactor Alphablending - inline bool textureBlendFunc_hasAlpha ( const E_BLEND_FACTOR factor ) - { - switch ( factor ) - { - case EBF_SRC_ALPHA: - case EBF_ONE_MINUS_SRC_ALPHA: - case EBF_DST_ALPHA: - case EBF_ONE_MINUS_DST_ALPHA: - case EBF_SRC_ALPHA_SATURATE: - return true; - default: - return false; - } - } - - - //! These flags are used to specify the anti-aliasing and smoothing modes - /** Techniques supported are multisampling, geometry smoothing, and alpha - to coverage. - Some drivers don't support a per-material setting of the anti-aliasing - modes. In those cases, FSAA/multisampling is defined by the device mode - chosen upon creation via irr::SIrrCreationParameters. - */ - enum E_ANTI_ALIASING_MODE - { - //! Use to turn off anti-aliasing for this material - EAAM_OFF=0, - //! Default anti-aliasing mode - EAAM_SIMPLE=1, - //! High-quality anti-aliasing, not always supported, automatically enables SIMPLE mode - EAAM_QUALITY=3, - //! Line smoothing - EAAM_LINE_SMOOTH=4, - //! point smoothing, often in software and slow, only with OpenGL - EAAM_POINT_SMOOTH=8, - //! All typical anti-alias and smooth modes - EAAM_FULL_BASIC=15, - //! Enhanced anti-aliasing for transparent materials - /** Usually used with EMT_TRANSPARENT_ALPHA_REF and multisampling. */ - EAAM_ALPHA_TO_COVERAGE=16 - }; - - //! These flags allow to define the interpretation of vertex color when lighting is enabled - /** Without lighting being enabled the vertex color is the only value defining the fragment color. - Once lighting is enabled, the four values for diffuse, ambient, emissive, and specular take over. - With these flags it is possible to define which lighting factor shall be defined by the vertex color - instead of the lighting factor which is the same for all faces of that material. - The default is to use vertex color for the diffuse value, another pretty common value is to use - vertex color for both diffuse and ambient factor. */ - enum E_COLOR_MATERIAL - { - //! Don't use vertex color for lighting - ECM_NONE=0, - //! Use vertex color for diffuse light, this is default - ECM_DIFFUSE, - //! Use vertex color for ambient light - ECM_AMBIENT, - //! Use vertex color for emissive light - ECM_EMISSIVE, - //! Use vertex color for specular light - ECM_SPECULAR, - //! Use vertex color for both diffuse and ambient light - ECM_DIFFUSE_AND_AMBIENT - }; - - //! Maximum number of texture an SMaterial can have. - const u32 MATERIAL_MAX_TEXTURES = _IRR_MATERIAL_MAX_TEXTURES_; - - //! Struct for holding parameters for a material renderer - class SMaterial - { - public: - //! Default constructor. Creates a solid, lit material with white colors - SMaterial() - : MaterialType(EMT_SOLID), AmbientColor(255,255,255,255), DiffuseColor(255,255,255,255), - EmissiveColor(0,0,0,0), SpecularColor(255,255,255,255), - Shininess(0.0f), MaterialTypeParam(0.0f), MaterialTypeParam2(0.0f), Thickness(1.0f), - ZBuffer(ECFN_LESSEQUAL), AntiAliasing(EAAM_SIMPLE|EAAM_LINE_SMOOTH), ColorMask(ECP_ALL), - ColorMaterial(ECM_DIFFUSE), - Wireframe(false), PointCloud(false), GouraudShading(true), Lighting(true), ZWriteEnable(true), - BackfaceCulling(true), FrontfaceCulling(false), FogEnable(false), NormalizeNormals(false) - { } - - //! Copy constructor - /** \param other Material to copy from. */ - SMaterial(const SMaterial& other) - { - // These pointers are checked during assignment - for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i) - TextureLayer[i].TextureMatrix = 0; - *this = other; - } - - //! Assignment operator - /** \param other Material to copy from. */ - SMaterial& operator=(const SMaterial& other) - { - // Check for self-assignment! - if (this == &other) - return *this; - - MaterialType = other.MaterialType; - - AmbientColor = other.AmbientColor; - DiffuseColor = other.DiffuseColor; - EmissiveColor = other.EmissiveColor; - SpecularColor = other.SpecularColor; - Shininess = other.Shininess; - MaterialTypeParam = other.MaterialTypeParam; - MaterialTypeParam2 = other.MaterialTypeParam2; - Thickness = other.Thickness; - for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i) - { - TextureLayer[i] = other.TextureLayer[i]; - } - - Wireframe = other.Wireframe; - PointCloud = other.PointCloud; - GouraudShading = other.GouraudShading; - Lighting = other.Lighting; - ZWriteEnable = other.ZWriteEnable; - BackfaceCulling = other.BackfaceCulling; - FrontfaceCulling = other.FrontfaceCulling; - FogEnable = other.FogEnable; - NormalizeNormals = other.NormalizeNormals; - ZBuffer = other.ZBuffer; - AntiAliasing = other.AntiAliasing; - ColorMask = other.ColorMask; - ColorMaterial = other.ColorMaterial; - - return *this; - } - - //! Texture layer array. - SMaterialLayer TextureLayer[MATERIAL_MAX_TEXTURES]; - - //! Type of the material. Specifies how everything is blended together - E_MATERIAL_TYPE MaterialType; - - //! How much ambient light (a global light) is reflected by this material. - /** The default is full white, meaning objects are completely - globally illuminated. Reduce this if you want to see diffuse - or specular light effects. */ - SColor AmbientColor; - - //! How much diffuse light coming from a light source is reflected by this material. - /** The default is full white. */ - SColor DiffuseColor; - - //! Light emitted by this material. Default is to emit no light. - SColor EmissiveColor; - - //! How much specular light (highlights from a light) is reflected. - /** The default is to reflect white specular light. See - SMaterial::Shininess on how to enable specular lights. */ - SColor SpecularColor; - - //! Value affecting the size of specular highlights. - /** A value of 20 is common. If set to 0, no specular - highlights are being used. To activate, simply set the - shininess of a material to a value in the range [0.5;128]: - \code - sceneNode->getMaterial(0).Shininess = 20.0f; - \endcode - - You can change the color of the highlights using - \code - sceneNode->getMaterial(0).SpecularColor.set(255,255,255,255); - \endcode - - The specular color of the dynamic lights - (SLight::SpecularColor) will influence the the highlight color - too, but they are set to a useful value by default when - creating the light scene node. Here is a simple example on how - to use specular highlights: - \code - // load and display mesh - scene::IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( - smgr->getMesh("data/faerie.md2")); - node->setMaterialTexture(0, driver->getTexture("data/Faerie2.pcx")); // set diffuse texture - node->setMaterialFlag(video::EMF_LIGHTING, true); // enable dynamic lighting - node->getMaterial(0).Shininess = 20.0f; // set size of specular highlights - - // add white light - scene::ILightSceneNode* light = smgr->addLightSceneNode(0, - core::vector3df(5,5,5), video::SColorf(1.0f, 1.0f, 1.0f)); - \endcode */ - f32 Shininess; - - //! Free parameter, dependent on the material type. - /** Mostly ignored, used for example in EMT_PARALLAX_MAP_SOLID - and EMT_TRANSPARENT_ALPHA_CHANNEL. */ - f32 MaterialTypeParam; - - //! Second free parameter, dependent on the material type. - /** Mostly ignored. */ - f32 MaterialTypeParam2; - - //! Thickness of non-3dimensional elements such as lines and points. - f32 Thickness; - - //! Is the ZBuffer enabled? Default: ECFN_LESSEQUAL - /** Values are from E_COMPARISON_FUNC. */ - u8 ZBuffer; - - //! Sets the antialiasing mode - /** Values are chosen from E_ANTI_ALIASING_MODE. Default is - EAAM_SIMPLE|EAAM_LINE_SMOOTH, i.e. simple multi-sample - anti-aliasing and lime smoothing is enabled. */ - u8 AntiAliasing; - - //! Defines the enabled color planes - /** Values are defined as or'ed values of the E_COLOR_PLANE enum. - Only enabled color planes will be rendered to the current render - target. Typical use is to disable all colors when rendering only to - depth or stencil buffer, or using Red and Green for Stereo rendering. */ - u8 ColorMask:4; - - //! Defines the interpretation of vertex color in the lighting equation - /** Values should be chosen from E_COLOR_MATERIAL. - When lighting is enabled, vertex color can be used instead of the - material values for light modulation. This allows to easily change e.g. the - diffuse light behavior of each face. The default, ECM_DIFFUSE, will result in - a very similar rendering as with lighting turned off, just with light shading. */ - u8 ColorMaterial:3; - - //! Draw as wireframe or filled triangles? Default: false - /** The user can access a material flag using - \code material.Wireframe=true \endcode - or \code material.setFlag(EMF_WIREFRAME, true); \endcode */ - bool Wireframe:1; - - //! Draw as point cloud or filled triangles? Default: false - bool PointCloud:1; - - //! Flat or Gouraud shading? Default: true - bool GouraudShading:1; - - //! Will this material be lighted? Default: true - bool Lighting:1; - - //! Is the zbuffer writeable or is it read-only. Default: true. - /** This flag is forced to false if the MaterialType is a - transparent type and the scene parameter - ALLOW_ZWRITE_ON_TRANSPARENT is not set. */ - bool ZWriteEnable:1; - - //! Is backface culling enabled? Default: true - bool BackfaceCulling:1; - - //! Is frontface culling enabled? Default: false - bool FrontfaceCulling:1; - - //! Is fog enabled? Default: false - bool FogEnable:1; - - //! Should normals be normalized? - /** Always use this if the mesh lit and scaled. Default: false */ - bool NormalizeNormals:1; - - //! Gets the texture transformation matrix for level i - /** \param i The desired level. Must not be larger than MATERIAL_MAX_TEXTURES. - \return Texture matrix for texture level i. */ - core::matrix4& getTextureMatrix(u32 i) - { - return TextureLayer[i].getTextureMatrix(); - } - - //! Gets the immutable texture transformation matrix for level i - /** \param i The desired level. - \return Texture matrix for texture level i, or identity matrix for levels larger than MATERIAL_MAX_TEXTURES. */ - const core::matrix4& getTextureMatrix(u32 i) const - { - if (i<MATERIAL_MAX_TEXTURES) - return TextureLayer[i].getTextureMatrix(); - else - return core::IdentityMatrix; - } - - //! Sets the i-th texture transformation matrix - /** \param i The desired level. - \param mat Texture matrix for texture level i. */ - void setTextureMatrix(u32 i, const core::matrix4& mat) - { - if (i>=MATERIAL_MAX_TEXTURES) - return; - TextureLayer[i].setTextureMatrix(mat); - } - - //! Gets the i-th texture - /** \param i The desired level. - \return Texture for texture level i, if defined, else 0. */ - ITexture* getTexture(u32 i) const - { - return i < MATERIAL_MAX_TEXTURES ? TextureLayer[i].Texture : 0; - } - - //! Sets the i-th texture - /** If i>=MATERIAL_MAX_TEXTURES this setting will be ignored. - \param i The desired level. - \param tex Texture for texture level i. */ - void setTexture(u32 i, ITexture* tex) - { - if (i>=MATERIAL_MAX_TEXTURES) - return; - TextureLayer[i].Texture = tex; - } - - //! Sets the Material flag to the given value - /** \param flag The flag to be set. - \param value The new value for the flag. */ - void setFlag(E_MATERIAL_FLAG flag, bool value) - { - switch (flag) - { - case EMF_WIREFRAME: - Wireframe = value; break; - case EMF_POINTCLOUD: - PointCloud = value; break; - case EMF_GOURAUD_SHADING: - GouraudShading = value; break; - case EMF_LIGHTING: - Lighting = value; break; - case EMF_ZBUFFER: - ZBuffer = value; break; - case EMF_ZWRITE_ENABLE: - ZWriteEnable = value; break; - case EMF_BACK_FACE_CULLING: - BackfaceCulling = value; break; - case EMF_FRONT_FACE_CULLING: - FrontfaceCulling = value; break; - case EMF_BILINEAR_FILTER: - { - for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i) - TextureLayer[i].BilinearFilter = value; - } - break; - case EMF_TRILINEAR_FILTER: - { - for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i) - TextureLayer[i].TrilinearFilter = value; - } - break; - case EMF_ANISOTROPIC_FILTER: - { - if (value) - for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i) - TextureLayer[i].AnisotropicFilter = 0xFF; - else - for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i) - TextureLayer[i].AnisotropicFilter = 0; - } - break; - case EMF_FOG_ENABLE: - FogEnable = value; break; - case EMF_NORMALIZE_NORMALS: - NormalizeNormals = value; break; - case EMF_TEXTURE_WRAP: - { - for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i) - TextureLayer[i].TextureWrap = (E_TEXTURE_CLAMP)value; - } - break; - case EMF_ANTI_ALIASING: - AntiAliasing = value?EAAM_SIMPLE:EAAM_OFF; - break; - case EMF_COLOR_MASK: - ColorMask = value?ECP_ALL:ECP_NONE; - break; - case EMF_COLOR_MATERIAL: - ColorMaterial = value?ECM_DIFFUSE:ECM_NONE; - break; - default: - break; - } - } - - //! Gets the Material flag - /** \param flag The flag to query. - \return The current value of the flag. */ - bool getFlag(E_MATERIAL_FLAG flag) const - { - switch (flag) - { - case EMF_WIREFRAME: - return Wireframe; - case EMF_POINTCLOUD: - return PointCloud; - case EMF_GOURAUD_SHADING: - return GouraudShading; - case EMF_LIGHTING: - return Lighting; - case EMF_ZBUFFER: - return ZBuffer!=ECFN_NEVER; - case EMF_ZWRITE_ENABLE: - return ZWriteEnable; - case EMF_BACK_FACE_CULLING: - return BackfaceCulling; - case EMF_FRONT_FACE_CULLING: - return FrontfaceCulling; - case EMF_BILINEAR_FILTER: - return TextureLayer[0].BilinearFilter; - case EMF_TRILINEAR_FILTER: - return TextureLayer[0].TrilinearFilter; - case EMF_ANISOTROPIC_FILTER: - return TextureLayer[0].AnisotropicFilter!=0; - case EMF_FOG_ENABLE: - return FogEnable; - case EMF_NORMALIZE_NORMALS: - return NormalizeNormals; - case EMF_TEXTURE_WRAP: - return !(TextureLayer[0].TextureWrap || - TextureLayer[1].TextureWrap || - TextureLayer[2].TextureWrap || - TextureLayer[3].TextureWrap); - case EMF_ANTI_ALIASING: - return (AntiAliasing==1); - case EMF_COLOR_MASK: - return (ColorMask!=ECP_NONE); - case EMF_COLOR_MATERIAL: - return (ColorMaterial != ECM_NONE); - } - - return false; - } - - //! Inequality operator - /** \param b Material to compare to. - \return True if the materials differ, else false. */ - inline bool operator!=(const SMaterial& b) const - { - bool different = - MaterialType != b.MaterialType || - AmbientColor != b.AmbientColor || - DiffuseColor != b.DiffuseColor || - EmissiveColor != b.EmissiveColor || - SpecularColor != b.SpecularColor || - Shininess != b.Shininess || - MaterialTypeParam != b.MaterialTypeParam || - MaterialTypeParam2 != b.MaterialTypeParam2 || - Thickness != b.Thickness || - Wireframe != b.Wireframe || - PointCloud != b.PointCloud || - GouraudShading != b.GouraudShading || - Lighting != b.Lighting || - ZBuffer != b.ZBuffer || - ZWriteEnable != b.ZWriteEnable || - BackfaceCulling != b.BackfaceCulling || - FrontfaceCulling != b.FrontfaceCulling || - FogEnable != b.FogEnable || - NormalizeNormals != b.NormalizeNormals || - AntiAliasing != b.AntiAliasing || - ColorMask != b.ColorMask || - ColorMaterial != b.ColorMaterial; - for (u32 i=0; (i<MATERIAL_MAX_TEXTURES) && !different; ++i) - { - different |= (TextureLayer[i] != b.TextureLayer[i]); - } - return different; - } - - //! Equality operator - /** \param b Material to compare to. - \return True if the materials are equal, else false. */ - inline bool operator==(const SMaterial& b) const - { return !(b!=*this); } - - bool isTransparent() const - { - return MaterialType==EMT_TRANSPARENT_ADD_COLOR || - MaterialType==EMT_TRANSPARENT_ALPHA_CHANNEL || - MaterialType==EMT_TRANSPARENT_VERTEX_ALPHA || - MaterialType==EMT_TRANSPARENT_REFLECTION_2_LAYER; - } - }; - - //! global const identity Material - IRRLICHT_API extern SMaterial IdentityMaterial; - -} // end namespace video -} // end namespace irr - -#endif diff --git a/irrlicht-1.6/include/SMaterialLayer.h b/irrlicht-1.6/include/SMaterialLayer.h deleted file mode 100644 index 56d8f1235..000000000 --- a/irrlicht-1.6/include/SMaterialLayer.h +++ /dev/null @@ -1,214 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __S_MATERIAL_LAYER_H_INCLUDED__ -#define __S_MATERIAL_LAYER_H_INCLUDED__ - -#include "matrix4.h" -#include "irrAllocator.h" - -namespace irr -{ -namespace video -{ - class ITexture; - - //! Texture coord clamp mode outside [0.0, 1.0] - enum E_TEXTURE_CLAMP - { - //! Texture repeats - ETC_REPEAT = 0, - //! Texture is clamped to the last pixel - ETC_CLAMP, - //! Texture is clamped to the edge pixel - ETC_CLAMP_TO_EDGE, - //! Texture is clamped to the border pixel (if exists) - ETC_CLAMP_TO_BORDER, - //! Texture is alternatingly mirrored (0..1..0..1..0..) - ETC_MIRROR - }; - static const char* const aTextureClampNames[] = { - "texture_clamp_repeat", - "texture_clamp_clamp", - "texture_clamp_clamp_to_edge", - "texture_clamp_clamp_to_border", - "texture_clamp_mirror", 0}; - - //! Struct for holding material parameters which exist per texture layer - class SMaterialLayer - { - public: - //! Default constructor - SMaterialLayer() - : Texture(0), - TextureWrap(ETC_REPEAT), - BilinearFilter(true), - TrilinearFilter(false), - AnisotropicFilter(0), - LODBias(0), - TextureMatrix(0) - {} - - //! Copy constructor - /** \param other Material layer to copy from. */ - SMaterialLayer(const SMaterialLayer& other) - { - // This pointer is checked during assignment - TextureMatrix = 0; - *this = other; - } - - //! Destructor - ~SMaterialLayer() - { - MatrixAllocator.destruct(TextureMatrix); - MatrixAllocator.deallocate(TextureMatrix); - } - - //! Assignment operator - /** \param other Material layer to copy from. - \return This material layer, updated. */ - SMaterialLayer& operator=(const SMaterialLayer& other) - { - // Check for self-assignment! - if (this == &other) - return *this; - - Texture = other.Texture; - if (TextureMatrix) - { - if (other.TextureMatrix) - *TextureMatrix = *other.TextureMatrix; - else - { - MatrixAllocator.destruct(TextureMatrix); - MatrixAllocator.deallocate(TextureMatrix); - TextureMatrix = 0; - } - } - else - { - if (other.TextureMatrix) - { - TextureMatrix = MatrixAllocator.allocate(1); - MatrixAllocator.construct(TextureMatrix,*other.TextureMatrix); - } - else - TextureMatrix = 0; - } - TextureWrap = other.TextureWrap; - BilinearFilter = other.BilinearFilter; - TrilinearFilter = other.TrilinearFilter; - AnisotropicFilter = other.AnisotropicFilter; - LODBias = other.LODBias; - - return *this; - } - - //! Texture - ITexture* Texture; - - //! Texture Clamp Mode - u8 TextureWrap; - - //! Is bilinear filtering enabled? Default: true - bool BilinearFilter:1; - - //! Is trilinear filtering enabled? Default: false - /** If the trilinear filter flag is enabled, - the bilinear filtering flag is ignored. */ - bool TrilinearFilter:1; - - //! Is anisotropic filtering enabled? Default: 0, disabled - /** In Irrlicht you can use anisotropic texture filtering - in conjunction with bilinear or trilinear texture - filtering to improve rendering results. Primitives - will look less blurry with this flag switched on. The number gives - the maximal anisotropy degree, and is often in the range 2-16. - Value 1 is equivalent to 0, but should be avoided. */ - u8 AnisotropicFilter; - - //! Bias for the mipmap choosing decision. - /** This value can make the textures more or less blurry than with the - default value of 0. The value (divided by 8.f) is added to the mipmap level - chosen initially, and thus takes a smaller mipmap for a region - if the value is positive. */ - s8 LODBias; - - //! Gets the texture transformation matrix - /** \return Texture matrix of this layer. */ - core::matrix4& getTextureMatrix() - { - if (!TextureMatrix) - { - TextureMatrix = MatrixAllocator.allocate(1); - MatrixAllocator.construct(TextureMatrix,core::IdentityMatrix); - } - return *TextureMatrix; - } - - //! Gets the immutable texture transformation matrix - /** \return Texture matrix of this layer. */ - const core::matrix4& getTextureMatrix() const - { - if (TextureMatrix) - return *TextureMatrix; - else - return core::IdentityMatrix; - } - - //! Sets the texture transformation matrix to mat - /** \param mat New texture matrix for this layer. */ - void setTextureMatrix(const core::matrix4& mat) - { - if (!TextureMatrix) - { - TextureMatrix = MatrixAllocator.allocate(1); - MatrixAllocator.construct(TextureMatrix,mat); - } - else - *TextureMatrix = mat; - } - - //! Inequality operator - /** \param b Layer to compare to. - \return True if layers are different, else false. */ - inline bool operator!=(const SMaterialLayer& b) const - { - bool different = - Texture != b.Texture || - TextureWrap != b.TextureWrap || - BilinearFilter != b.BilinearFilter || - TrilinearFilter != b.TrilinearFilter || - AnisotropicFilter != b.AnisotropicFilter || - LODBias != b.LODBias; - if (different) - return true; - else - different |= (TextureMatrix != b.TextureMatrix) && - TextureMatrix && b.TextureMatrix && - (*TextureMatrix != *(b.TextureMatrix)); - return different; - } - - //! Equality operator - /** \param b Layer to compare to. - \return True if layers are equal, else false. */ - inline bool operator==(const SMaterialLayer& b) const - { return !(b!=*this); } - - private: - friend class SMaterial; - irr::core::irrAllocator<irr::core::matrix4> MatrixAllocator; - - //! Texture Matrix - /** Do not access this element directly as the internal - ressource management has to cope with Null pointers etc. */ - core::matrix4* TextureMatrix; - }; - -} // end namespace video -} // end namespace irr - -#endif // __S_MATERIAL_LAYER_H_INCLUDED__ diff --git a/irrlicht-1.6/include/SMesh.h b/irrlicht-1.6/include/SMesh.h deleted file mode 100644 index 760fa48d3..000000000 --- a/irrlicht-1.6/include/SMesh.h +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __S_MESH_H_INCLUDED__ -#define __S_MESH_H_INCLUDED__ - -#include "IMesh.h" -#include "IMeshBuffer.h" -#include "aabbox3d.h" -#include "irrArray.h" - -namespace irr -{ -namespace scene -{ - //! Simple implementation of the IMesh interface. - struct SMesh : public IMesh - { - //! constructor - SMesh() - { - #ifdef _DEBUG - setDebugName("SMesh"); - #endif - } - - //! destructor - virtual ~SMesh() - { - // drop buffers - for (u32 i=0; i<MeshBuffers.size(); ++i) - MeshBuffers[i]->drop(); - } - - //! returns amount of mesh buffers. - virtual u32 getMeshBufferCount() const - { - return MeshBuffers.size(); - } - - //! returns pointer to a mesh buffer - virtual IMeshBuffer* getMeshBuffer(u32 nr) const - { - return MeshBuffers[nr]; - } - - //! returns a meshbuffer which fits a material - /** reverse search */ - virtual IMeshBuffer* getMeshBuffer( const video::SMaterial & material) const - { - for (s32 i = (s32)MeshBuffers.size()-1; i >= 0; --i) - { - if ( material == MeshBuffers[i]->getMaterial()) - return MeshBuffers[i]; - } - - return 0; - } - - //! returns an axis aligned bounding box - virtual const core::aabbox3d<f32>& getBoundingBox() const - { - return BoundingBox; - } - - //! set user axis aligned bounding box - virtual void setBoundingBox( const core::aabbox3df& box) - { - BoundingBox = box; - } - - //! recalculates the bounding box - void recalculateBoundingBox() - { - if (MeshBuffers.size()) - { - BoundingBox = MeshBuffers[0]->getBoundingBox(); - for (u32 i=1; i<MeshBuffers.size(); ++i) - BoundingBox.addInternalBox(MeshBuffers[i]->getBoundingBox()); - } - else - BoundingBox.reset(0.0f, 0.0f, 0.0f); - } - - //! adds a MeshBuffer - void addMeshBuffer(IMeshBuffer* buf) - { - if (buf) - { - buf->grab(); - MeshBuffers.push_back(buf); - } - } - - //! sets a flag of all contained materials to a new value - virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue) - { - for (u32 i=0; i<MeshBuffers.size(); ++i) - MeshBuffers[i]->getMaterial().setFlag(flag, newvalue); - } - - //! set the hardware mapping hint, for driver - virtual void setHardwareMappingHint( E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX ) - { - for (u32 i=0; i<MeshBuffers.size(); ++i) - MeshBuffers[i]->setHardwareMappingHint(newMappingHint, buffer); - } - - //! flags the meshbuffer as changed, reloads hardware buffers - virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX) - { - for (u32 i=0; i<MeshBuffers.size(); ++i) - MeshBuffers[i]->setDirty(buffer); - } - - //! The meshbuffers of this mesh - core::array<IMeshBuffer*> MeshBuffers; - - //! The bounding box of this mesh - core::aabbox3d<f32> BoundingBox; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/SMeshBuffer.h b/irrlicht-1.6/include/SMeshBuffer.h deleted file mode 100644 index 2ae24d3f0..000000000 --- a/irrlicht-1.6/include/SMeshBuffer.h +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -// replaced by template -#include "CMeshBuffer.h" - diff --git a/irrlicht-1.6/include/SMeshBufferLightMap.h b/irrlicht-1.6/include/SMeshBufferLightMap.h deleted file mode 100644 index 2ae24d3f0..000000000 --- a/irrlicht-1.6/include/SMeshBufferLightMap.h +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -// replaced by template -#include "CMeshBuffer.h" - diff --git a/irrlicht-1.6/include/SMeshBufferTangents.h b/irrlicht-1.6/include/SMeshBufferTangents.h deleted file mode 100644 index 2ae24d3f0..000000000 --- a/irrlicht-1.6/include/SMeshBufferTangents.h +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -// replaced by template -#include "CMeshBuffer.h" - diff --git a/irrlicht-1.6/include/SParticle.h b/irrlicht-1.6/include/SParticle.h deleted file mode 100644 index f3c534d9d..000000000 --- a/irrlicht-1.6/include/SParticle.h +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __S_PARTICLE_H_INCLUDED__ -#define __S_PARTICLE_H_INCLUDED__ - -#include "vector3d.h" -#include "dimension2d.h" -#include "SColor.h" - -namespace irr -{ -namespace scene -{ - //! Struct for holding particle data - struct SParticle - { - //! Position of the particle - core::vector3df pos; - - //! Direction and speed of the particle - core::vector3df vector; - - //! Start life time of the particle - u32 startTime; - - //! End life time of the particle - u32 endTime; - - //! Current color of the particle - video::SColor color; - - //! Original color of the particle. - /** That's the color of the particle it had when it was emitted. */ - video::SColor startColor; - - //! Original direction and speed of the particle. - /** The direction and speed the particle had when it was emitted. */ - core::vector3df startVector; - - //! Scale of the particle. - /** The current scale of the particle. */ - core::dimension2df size; - - //! Original scale of the particle. - /** The scale of the particle when it was emitted. */ - core::dimension2df startSize; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/SSharedMeshBuffer.h b/irrlicht-1.6/include/SSharedMeshBuffer.h deleted file mode 100644 index 260d81a4b..000000000 --- a/irrlicht-1.6/include/SSharedMeshBuffer.h +++ /dev/null @@ -1,197 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __S_SHARED_MESH_BUFFER_H_INCLUDED__ -#define __S_SHARED_MESH_BUFFER_H_INCLUDED__ - -#include "irrArray.h" -#include "IMeshBuffer.h" - -namespace irr -{ -namespace scene -{ - //! Implementation of the IMeshBuffer interface with shared vertex list - struct SSharedMeshBuffer : public IMeshBuffer - { - //! constructor - SSharedMeshBuffer() : IMeshBuffer(), Vertices(0), ChangedID_Vertex(1), ChangedID_Index(1), MappingHintVertex(EHM_NEVER), MappingHintIndex(EHM_NEVER) - { - #ifdef _DEBUG - setDebugName("SSharedMeshBuffer"); - #endif - } - - //! constructor - SSharedMeshBuffer(core::array<video::S3DVertex> *vertices) : IMeshBuffer(), Vertices(vertices) - { - #ifdef _DEBUG - setDebugName("SSharedMeshBuffer"); - #endif - } - - //! returns the material of this meshbuffer - virtual const video::SMaterial& getMaterial() const - { - return Material; - } - - //! returns the material of this meshbuffer - virtual video::SMaterial& getMaterial() - { - return Material; - } - - //! returns pointer to vertices - virtual const void* getVertices() const - { - if (Vertices) - return Vertices->const_pointer(); - else - return 0; - } - - //! returns pointer to vertices - virtual void* getVertices() - { - if (Vertices) - return Vertices->pointer(); - else - return 0; - } - - //! returns amount of vertices - virtual u32 getVertexCount() const - { - if (Vertices) - return Vertices->size(); - else - return 0; - } - - //! returns pointer to Indices - virtual const u16* getIndices() const - { - return Indices.const_pointer(); - } - - //! returns pointer to Indices - virtual u16* getIndices() - { - return Indices.pointer(); - } - - //! returns amount of indices - virtual u32 getIndexCount() const - { - return Indices.size(); - } - - //! returns an axis aligned bounding box - virtual const core::aabbox3d<f32>& getBoundingBox() const - { - return BoundingBox; - } - - //! set user axis aligned bounding box - virtual void setBoundingBox( const core::aabbox3df& box) - { - BoundingBox = box; - } - - //! returns which type of vertex data is stored. - virtual video::E_VERTEX_TYPE getVertexType() const - { - return video::EVT_STANDARD; - } - - //! recalculates the bounding box. should be called if the mesh changed. - virtual void recalculateBoundingBox() - { - if (!Vertices || Vertices->empty() || Indices.empty()) - BoundingBox.reset(0,0,0); - else - { - BoundingBox.reset((*Vertices)[Indices[0]].Pos); - for (u32 i=1; i<Indices.size(); ++i) - BoundingBox.addInternalPoint((*Vertices)[Indices[i]].Pos); - } - } - - //! append the vertices and indices to the current buffer - virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) {} - - //! append the meshbuffer to the current buffer - virtual void append(const IMeshBuffer* const other) {} - - - //! get the current hardware mapping hint - virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const - { - return MappingHintVertex; - } - - //! get the current hardware mapping hint - virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const - { - return MappingHintIndex; - } - - //! set the hardware mapping hint, for driver - virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX ) - { - if (buffer==EBT_VERTEX_AND_INDEX || buffer==EBT_VERTEX) - MappingHintVertex=NewMappingHint; - if (buffer==EBT_VERTEX_AND_INDEX || buffer==EBT_INDEX) - MappingHintIndex=NewMappingHint; - } - - - //! flags the mesh as changed, reloads hardware buffers - virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX) - { - if (buffer==EBT_VERTEX_AND_INDEX || buffer==EBT_VERTEX) - ++ChangedID_Vertex; - if (buffer==EBT_VERTEX_AND_INDEX || buffer==EBT_INDEX) - ++ChangedID_Index; - } - - //! Get the currently used ID for identification of changes. - /** This shouldn't be used for anything outside the VideoDriver. */ - virtual u32 getChangedID_Vertex() const {return ChangedID_Vertex;} - - //! Get the currently used ID for identification of changes. - /** This shouldn't be used for anything outside the VideoDriver. */ - virtual u32 getChangedID_Index() const {return ChangedID_Index;} - - //! Material of this meshBuffer - video::SMaterial Material; - - //! Shared Array of vertices - core::array<video::S3DVertex> *Vertices; - - //! Array of Indices - core::array<u16> Indices; - - //! ID used for hardware buffer management - u32 ChangedID_Vertex; - - //! ID used for hardware buffer management - u32 ChangedID_Index; - - //! Bounding box - core::aabbox3df BoundingBox; - - //! hardware mapping hint - E_HARDWARE_MAPPING MappingHintVertex; - E_HARDWARE_MAPPING MappingHintIndex; - - }; - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/SSkinMeshBuffer.h b/irrlicht-1.6/include/SSkinMeshBuffer.h deleted file mode 100644 index b4832c9d4..000000000 --- a/irrlicht-1.6/include/SSkinMeshBuffer.h +++ /dev/null @@ -1,401 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_SKIN_MESH_BUFFER_H_INCLUDED__ -#define __I_SKIN_MESH_BUFFER_H_INCLUDED__ - -#include "IMeshBuffer.h" -#include "S3DVertex.h" - - -namespace irr -{ -namespace scene -{ - - -//! A mesh buffer able to choose between S3DVertex2TCoords, S3DVertex and S3DVertexTangents at runtime -struct SSkinMeshBuffer : public IMeshBuffer -{ - //! Default constructor - SSkinMeshBuffer(video::E_VERTEX_TYPE vt=video::EVT_STANDARD) : - ChangedID_Vertex(1), ChangedID_Index(1), VertexType(vt), - MappingHint_Vertex(EHM_NEVER), MappingHint_Index(EHM_NEVER), - BoundingBoxNeedsRecalculated(true) - { - #ifdef _DEBUG - setDebugName("SSkinMeshBuffer"); - #endif - } - - //! Get Material of this buffer. - virtual const video::SMaterial& getMaterial() const - { - return Material; - } - - //! Get Material of this buffer. - virtual video::SMaterial& getMaterial() - { - return Material; - } - - //! Get standard vertex at given index - virtual video::S3DVertex *getVertex(u32 index) - { - switch (VertexType) - { - case video::EVT_2TCOORDS: - return (video::S3DVertex*)&Vertices_2TCoords[index]; - case video::EVT_TANGENTS: - return (video::S3DVertex*)&Vertices_Tangents[index]; - default: - return &Vertices_Standard[index]; - } - } - - //! Get pointer to vertex array - virtual const void* getVertices() const - { - switch (VertexType) - { - case video::EVT_2TCOORDS: - return Vertices_2TCoords.const_pointer(); - case video::EVT_TANGENTS: - return Vertices_Tangents.const_pointer(); - default: - return Vertices_Standard.const_pointer(); - } - } - - //! Get pointer to vertex array - virtual void* getVertices() - { - switch (VertexType) - { - case video::EVT_2TCOORDS: - return Vertices_2TCoords.pointer(); - case video::EVT_TANGENTS: - return Vertices_Tangents.pointer(); - default: - return Vertices_Standard.pointer(); - } - } - - //! Get vertex count - virtual u32 getVertexCount() const - { - switch (VertexType) - { - case video::EVT_2TCOORDS: - return Vertices_2TCoords.size(); - case video::EVT_TANGENTS: - return Vertices_Tangents.size(); - default: - return Vertices_Standard.size(); - } - } - - //! Get type of index data which is stored in this meshbuffer. - /** \return Index type of this buffer. */ - virtual video::E_INDEX_TYPE getIndexType() const { return video::EIT_16BIT; } - - //! Get pointer to index array - virtual const u16* getIndices() const - { - return Indices.const_pointer(); - } - - //! Get pointer to index array - virtual u16* getIndices() - { - return Indices.pointer(); - } - - //! Get index count - virtual u32 getIndexCount() const - { - return Indices.size(); - } - - //! Get bounding box - virtual const core::aabbox3d<f32>& getBoundingBox() const - { - return BoundingBox; - } - - //! Set bounding box - virtual void setBoundingBox( const core::aabbox3df& box) - { - BoundingBox = box; - } - - //! Recalculate bounding box - virtual void recalculateBoundingBox() - { - if(!BoundingBoxNeedsRecalculated) - return; - - BoundingBoxNeedsRecalculated = false; - - switch (VertexType) - { - case video::EVT_STANDARD: - { - if (Vertices_Standard.empty()) - BoundingBox.reset(0,0,0); - else - { - BoundingBox.reset(Vertices_Standard[0].Pos); - for (u32 i=1; i<Vertices_Standard.size(); ++i) - BoundingBox.addInternalPoint(Vertices_Standard[i].Pos); - } - break; - } - case video::EVT_2TCOORDS: - { - if (Vertices_2TCoords.empty()) - BoundingBox.reset(0,0,0); - else - { - BoundingBox.reset(Vertices_2TCoords[0].Pos); - for (u32 i=1; i<Vertices_2TCoords.size(); ++i) - BoundingBox.addInternalPoint(Vertices_2TCoords[i].Pos); - } - break; - } - case video::EVT_TANGENTS: - { - if (Vertices_Tangents.empty()) - BoundingBox.reset(0,0,0); - else - { - BoundingBox.reset(Vertices_Tangents[0].Pos); - for (u32 i=1; i<Vertices_Tangents.size(); ++i) - BoundingBox.addInternalPoint(Vertices_Tangents[i].Pos); - } - break; - } - } - } - - //! Get vertex type - virtual video::E_VERTEX_TYPE getVertexType() const - { - return VertexType; - } - - //! Convert to 2tcoords vertex type - virtual void MoveTo_2TCoords() - { - if (VertexType==video::EVT_STANDARD) - { - for(u32 n=0;n<Vertices_Standard.size();++n) - { - video::S3DVertex2TCoords Vertex; - Vertex.Color=Vertices_Standard[n].Color; - Vertex.Pos=Vertices_Standard[n].Pos; - Vertex.Normal=Vertices_Standard[n].Normal; - Vertex.TCoords=Vertices_Standard[n].TCoords; - Vertices_2TCoords.push_back(Vertex); - } - Vertices_Standard.clear(); - VertexType=video::EVT_2TCOORDS; - } - } - - //! Convert to tangents vertex type - virtual void MoveTo_Tangents() - { - if (VertexType==video::EVT_STANDARD) - { - for(u32 n=0;n<Vertices_Standard.size();++n) - { - video::S3DVertexTangents Vertex; - Vertex.Color=Vertices_Standard[n].Color; - Vertex.Pos=Vertices_Standard[n].Pos; - Vertex.Normal=Vertices_Standard[n].Normal; - Vertex.TCoords=Vertices_Standard[n].TCoords; - Vertices_Tangents.push_back(Vertex); - } - Vertices_Standard.clear(); - VertexType=video::EVT_TANGENTS; - } - else if (VertexType==video::EVT_2TCOORDS) - { - for(u32 n=0;n<Vertices_2TCoords.size();++n) - { - video::S3DVertexTangents Vertex; - Vertex.Color=Vertices_2TCoords[n].Color; - Vertex.Pos=Vertices_2TCoords[n].Pos; - Vertex.Normal=Vertices_2TCoords[n].Normal; - Vertex.TCoords=Vertices_2TCoords[n].TCoords; - Vertices_Tangents.push_back(Vertex); - } - Vertices_2TCoords.clear(); - VertexType=video::EVT_TANGENTS; - } - } - - //! returns position of vertex i - virtual const core::vector3df& getPosition(u32 i) const - { - switch (VertexType) - { - case video::EVT_2TCOORDS: - return Vertices_2TCoords[i].Pos; - case video::EVT_TANGENTS: - return Vertices_Tangents[i].Pos; - default: - return Vertices_Standard[i].Pos; - } - } - - //! returns position of vertex i - virtual core::vector3df& getPosition(u32 i) - { - switch (VertexType) - { - case video::EVT_2TCOORDS: - return Vertices_2TCoords[i].Pos; - case video::EVT_TANGENTS: - return Vertices_Tangents[i].Pos; - default: - return Vertices_Standard[i].Pos; - } - } - - //! returns normal of vertex i - virtual const core::vector3df& getNormal(u32 i) const - { - switch (VertexType) - { - case video::EVT_2TCOORDS: - return Vertices_2TCoords[i].Normal; - case video::EVT_TANGENTS: - return Vertices_Tangents[i].Normal; - default: - return Vertices_Standard[i].Normal; - } - } - - //! returns normal of vertex i - virtual core::vector3df& getNormal(u32 i) - { - switch (VertexType) - { - case video::EVT_2TCOORDS: - return Vertices_2TCoords[i].Normal; - case video::EVT_TANGENTS: - return Vertices_Tangents[i].Normal; - default: - return Vertices_Standard[i].Normal; - } - } - - //! returns texture coords of vertex i - virtual const core::vector2df& getTCoords(u32 i) const - { - switch (VertexType) - { - case video::EVT_2TCOORDS: - return Vertices_2TCoords[i].TCoords; - case video::EVT_TANGENTS: - return Vertices_Tangents[i].TCoords; - default: - return Vertices_Standard[i].TCoords; - } - } - - //! returns texture coords of vertex i - virtual core::vector2df& getTCoords(u32 i) - { - switch (VertexType) - { - case video::EVT_2TCOORDS: - return Vertices_2TCoords[i].TCoords; - case video::EVT_TANGENTS: - return Vertices_Tangents[i].TCoords; - default: - return Vertices_Standard[i].TCoords; - } - } - - //! append the vertices and indices to the current buffer - virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) {} - - //! append the meshbuffer to the current buffer - virtual void append(const IMeshBuffer* const other) {} - - //! get the current hardware mapping hint for vertex buffers - virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const - { - return MappingHint_Vertex; - } - - //! get the current hardware mapping hint for index buffers - virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const - { - return MappingHint_Index; - } - - //! set the hardware mapping hint, for driver - virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint, E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX ) - { - if (Buffer==EBT_VERTEX) - MappingHint_Vertex=NewMappingHint; - else if (Buffer==EBT_INDEX) - MappingHint_Index=NewMappingHint; - else if (Buffer==EBT_VERTEX_AND_INDEX) - { - MappingHint_Vertex=NewMappingHint; - MappingHint_Index=NewMappingHint; - } - } - - //! flags the mesh as changed, reloads hardware buffers - virtual void setDirty(E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX) - { - if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_VERTEX) - ++ChangedID_Vertex; - if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_INDEX) - ++ChangedID_Index; - } - - virtual u32 getChangedID_Vertex() const {return ChangedID_Vertex;} - - virtual u32 getChangedID_Index() const {return ChangedID_Index;} - - //! Call this after changing the positions of any vertex. - void boundingBoxNeedsRecalculated(void) { BoundingBoxNeedsRecalculated = true; } - - core::array<video::S3DVertexTangents> Vertices_Tangents; - core::array<video::S3DVertex2TCoords> Vertices_2TCoords; - core::array<video::S3DVertex> Vertices_Standard; - core::array<u16> Indices; - - u32 ChangedID_Vertex; - u32 ChangedID_Index; - - //ISkinnedMesh::SJoint *AttachedJoint; - core::matrix4 Transformation; - - video::SMaterial Material; - video::E_VERTEX_TYPE VertexType; - - core::aabbox3d<f32> BoundingBox; - - // hardware mapping hint - E_HARDWARE_MAPPING MappingHint_Vertex:3; - E_HARDWARE_MAPPING MappingHint_Index:3; - - bool BoundingBoxNeedsRecalculated:1; -}; - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/SVertexIndex.h b/irrlicht-1.6/include/SVertexIndex.h deleted file mode 100644 index 425a04108..000000000 --- a/irrlicht-1.6/include/SVertexIndex.h +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (C) 2008-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __S_VERTEX_INDEX_H_INCLUDED__ -#define __S_VERTEX_INDEX_H_INCLUDED__ - -#include "irrTypes.h" - - -namespace irr -{ -namespace video -{ -enum E_INDEX_TYPE -{ - EIT_16BIT = 0, - EIT_32BIT -}; - - -/* -//! vertex index used by the Irrlicht engine. -template <class T> -struct SSpecificVertexIndex -{ - T Index; - - //! default constructor - SSpecificVertexIndex() {} - - //! constructor - SSpecificVertexIndex(u32 _index) :Index(_index) {} - - bool operator==(const SSpecificVertexIndex& other) const - { - return (Index == other.Index); - } - - bool operator!=(const SSpecificVertexIndex& other) const - { - return (Index != other.Index); - } - - bool operator<(const SSpecificVertexIndex& other) const - { - return (Index < other.Index); - } - - SSpecificVertexIndex operator+(const u32& other) const - { - return SSpecificVertexIndex(Index + other); - } - - operator const u32() const - { - return (const u32)Index; - } - - E_INDEX_TYPE getType() const - { - if (sizeof(T)==sizeof(u16)) - return video::EIT_16BIT; - return video::EIT_32BIT; - } - -}; - -//typedef SSpecificVertexIndex<u16> SVertexIndex; - -typedef u32 SVertexIndex; -*/ - - -} // end namespace video -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/SViewFrustum.h b/irrlicht-1.6/include/SViewFrustum.h deleted file mode 100644 index dc5b330c7..000000000 --- a/irrlicht-1.6/include/SViewFrustum.h +++ /dev/null @@ -1,318 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __S_VIEW_FRUSTUM_H_INCLUDED__ -#define __S_VIEW_FRUSTUM_H_INCLUDED__ - -#include "plane3d.h" -#include "vector3d.h" -#include "line3d.h" -#include "aabbox3d.h" -#include "matrix4.h" -#include "IVideoDriver.h" - -namespace irr -{ -namespace scene -{ - - //! Defines the view frustum. That's the space visible by the camera. - /** The view frustum is enclosed by 6 planes. These six planes share - four points. A bounding box around these four points is also stored in - this structure. - */ - struct SViewFrustum - { - enum VFPLANES - { - //! Far plane of the frustum. That is the plane farest away from the eye. - VF_FAR_PLANE = 0, - //! Near plane of the frustum. That is the plane nearest to the eye. - VF_NEAR_PLANE, - //! Left plane of the frustum. - VF_LEFT_PLANE, - //! Right plane of the frustum. - VF_RIGHT_PLANE, - //! Bottom plane of the frustum. - VF_BOTTOM_PLANE, - //! Top plane of the frustum. - VF_TOP_PLANE, - - //! Amount of planes enclosing the view frustum. Should be 6. - VF_PLANE_COUNT - }; - - - //! Default Constructor - SViewFrustum() {} - - //! Copy Constructor - SViewFrustum(const SViewFrustum& other); - - //! This constructor creates a view frustum based on a projection and/or view matrix. - SViewFrustum(const core::matrix4& mat); - - //! This constructor creates a view frustum based on a projection and/or view matrix. - inline void setFrom(const core::matrix4& mat); - - //! transforms the frustum by the matrix - /** \param mat: Matrix by which the view frustum is transformed.*/ - void transform(const core::matrix4& mat); - - //! returns the point which is on the far left upper corner inside the the view frustum. - core::vector3df getFarLeftUp() const; - - //! returns the point which is on the far left bottom corner inside the the view frustum. - core::vector3df getFarLeftDown() const; - - //! returns the point which is on the far right top corner inside the the view frustum. - core::vector3df getFarRightUp() const; - - //! returns the point which is on the far right bottom corner inside the the view frustum. - core::vector3df getFarRightDown() const; - - //! returns a bounding box enclosing the whole view frustum - const core::aabbox3d<f32> &getBoundingBox() const; - - //! recalculates the bounding box member based on the planes - inline void recalculateBoundingBox(); - - //! update the given state's matrix based on video::E_TRANSFORMATION_STATE - core::matrix4& getTransform( video::E_TRANSFORMATION_STATE state); - - //! get the given state's matrix based on frustum E_TRANSFORMATION_STATE_FRUSTUM - const core::matrix4& getTransform( video::E_TRANSFORMATION_STATE state) const; - - //! clips a line to the view frustum. - //! \Return: Returns true if the line was clipped, false if not - bool clipLine(core::line3d<f32>& line) const; - - //! the position of the camera - core::vector3df cameraPosition; - - //! all planes enclosing the view frustum. - core::plane3d<f32> planes[VF_PLANE_COUNT]; - - //! bounding box around the view frustum - core::aabbox3d<f32> boundingBox; - - private: - //! Hold a copy of important transform matrices - enum E_TRANSFORMATION_STATE_FRUSTUM - { - ETS_VIEW = 0, - ETS_PROJECTION = 1, - ETS_COUNT_FRUSTUM - }; - - //! Hold a copy of important transform matrices - core::matrix4 Matrices[ETS_COUNT_FRUSTUM]; - }; - - - /*! - Copy constructor ViewFrustum - */ - inline SViewFrustum::SViewFrustum(const SViewFrustum& other) - { - cameraPosition=other.cameraPosition; - boundingBox=other.boundingBox; - - u32 i; - for (i=0; i<VF_PLANE_COUNT; ++i) - planes[i]=other.planes[i]; - - for (i=0; i<ETS_COUNT_FRUSTUM; ++i) - Matrices[i]=other.Matrices[i]; - } - - inline SViewFrustum::SViewFrustum(const core::matrix4& mat) - { - setFrom ( mat ); - } - - - inline void SViewFrustum::transform(const core::matrix4& mat) - { - for (u32 i=0; i<VF_PLANE_COUNT; ++i) - mat.transformPlane(planes[i]); - - mat.transformVect(cameraPosition); - recalculateBoundingBox(); - } - - - inline core::vector3df SViewFrustum::getFarLeftUp() const - { - core::vector3df p; - planes[scene::SViewFrustum::VF_FAR_PLANE].getIntersectionWithPlanes( - planes[scene::SViewFrustum::VF_TOP_PLANE], - planes[scene::SViewFrustum::VF_LEFT_PLANE], p); - - return p; - } - - inline core::vector3df SViewFrustum::getFarLeftDown() const - { - core::vector3df p; - planes[scene::SViewFrustum::VF_FAR_PLANE].getIntersectionWithPlanes( - planes[scene::SViewFrustum::VF_BOTTOM_PLANE], - planes[scene::SViewFrustum::VF_LEFT_PLANE], p); - - return p; - } - - inline core::vector3df SViewFrustum::getFarRightUp() const - { - core::vector3df p; - planes[scene::SViewFrustum::VF_FAR_PLANE].getIntersectionWithPlanes( - planes[scene::SViewFrustum::VF_TOP_PLANE], - planes[scene::SViewFrustum::VF_RIGHT_PLANE], p); - - return p; - } - - inline core::vector3df SViewFrustum::getFarRightDown() const - { - core::vector3df p; - planes[scene::SViewFrustum::VF_FAR_PLANE].getIntersectionWithPlanes( - planes[scene::SViewFrustum::VF_BOTTOM_PLANE], - planes[scene::SViewFrustum::VF_RIGHT_PLANE], p); - - return p; - } - - inline const core::aabbox3d<f32> &SViewFrustum::getBoundingBox() const - { - return boundingBox; - } - - inline void SViewFrustum::recalculateBoundingBox() - { - boundingBox.reset ( cameraPosition ); - - boundingBox.addInternalPoint(getFarLeftUp()); - boundingBox.addInternalPoint(getFarRightUp()); - boundingBox.addInternalPoint(getFarLeftDown()); - boundingBox.addInternalPoint(getFarRightDown()); - } - - //! This constructor creates a view frustum based on a projection - //! and/or view matrix. - inline void SViewFrustum::setFrom(const core::matrix4& mat) - { - // left clipping plane - planes[VF_LEFT_PLANE].Normal.X = mat[3 ] + mat[0]; - planes[VF_LEFT_PLANE].Normal.Y = mat[7 ] + mat[4]; - planes[VF_LEFT_PLANE].Normal.Z = mat[11] + mat[8]; - planes[VF_LEFT_PLANE].D = mat[15] + mat[12]; - - // right clipping plane - planes[VF_RIGHT_PLANE].Normal.X = mat[3 ] - mat[0]; - planes[VF_RIGHT_PLANE].Normal.Y = mat[7 ] - mat[4]; - planes[VF_RIGHT_PLANE].Normal.Z = mat[11] - mat[8]; - planes[VF_RIGHT_PLANE].D = mat[15] - mat[12]; - - // top clipping plane - planes[VF_TOP_PLANE].Normal.X = mat[3 ] - mat[1]; - planes[VF_TOP_PLANE].Normal.Y = mat[7 ] - mat[5]; - planes[VF_TOP_PLANE].Normal.Z = mat[11] - mat[9]; - planes[VF_TOP_PLANE].D = mat[15] - mat[13]; - - // bottom clipping plane - planes[VF_BOTTOM_PLANE].Normal.X = mat[3 ] + mat[1]; - planes[VF_BOTTOM_PLANE].Normal.Y = mat[7 ] + mat[5]; - planes[VF_BOTTOM_PLANE].Normal.Z = mat[11] + mat[9]; - planes[VF_BOTTOM_PLANE].D = mat[15] + mat[13]; - - // far clipping plane - planes[VF_FAR_PLANE].Normal.X = mat[3 ] - mat[2]; - planes[VF_FAR_PLANE].Normal.Y = mat[7 ] - mat[6]; - planes[VF_FAR_PLANE].Normal.Z = mat[11] - mat[10]; - planes[VF_FAR_PLANE].D = mat[15] - mat[14]; - - // near clipping plane - planes[VF_NEAR_PLANE].Normal.X = mat[2]; - planes[VF_NEAR_PLANE].Normal.Y = mat[6]; - planes[VF_NEAR_PLANE].Normal.Z = mat[10]; - planes[VF_NEAR_PLANE].D = mat[14]; - - // normalize normals - u32 i; - for ( i=0; i != VF_PLANE_COUNT; ++i) - { - const f32 len = -core::reciprocal_squareroot( - planes[i].Normal.getLengthSQ()); - planes[i].Normal *= len; - planes[i].D *= len; - } - - // make bounding box - recalculateBoundingBox(); - } - - /*! - View Frustum depends on Projection & View Matrix - */ - inline core::matrix4& SViewFrustum::getTransform(video::E_TRANSFORMATION_STATE state ) - { - u32 index = 0; - switch ( state ) - { - case video::ETS_PROJECTION: - index = SViewFrustum::ETS_PROJECTION; break; - case video::ETS_VIEW: - index = SViewFrustum::ETS_VIEW; break; - default: - break; - } - return Matrices [ index ]; - } - - /*! - View Frustum depends on Projection & View Matrix - */ - inline const core::matrix4& SViewFrustum::getTransform(video::E_TRANSFORMATION_STATE state ) const - { - u32 index = 0; - switch ( state ) - { - case video::ETS_PROJECTION: - index = SViewFrustum::ETS_PROJECTION; break; - case video::ETS_VIEW: - index = SViewFrustum::ETS_VIEW; break; - default: - break; - } - return Matrices [ index ]; - } - - //! Clips a line to the frustum - inline bool SViewFrustum::clipLine(core::line3d<f32>& line) const - { - bool wasClipped = false; - for (u32 i=0; i < VF_PLANE_COUNT; ++i) - { - if (planes[i].classifyPointRelation(line.start) == core::ISREL3D_FRONT) - { - line.start = line.start.getInterpolated(line.end, - planes[i].getKnownIntersectionWithLine(line.start, line.end)); - wasClipped = true; - } - if (planes[i].classifyPointRelation(line.end) == core::ISREL3D_FRONT) - { - line.end = line.start.getInterpolated(line.end, - planes[i].getKnownIntersectionWithLine(line.start, line.end)); - wasClipped = true; - } - } - return wasClipped; - } - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/SceneParameters.h b/irrlicht-1.6/include/SceneParameters.h deleted file mode 100644 index 96088071c..000000000 --- a/irrlicht-1.6/include/SceneParameters.h +++ /dev/null @@ -1,167 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_SCENE_PARAMETERS_H_INCLUDED__ -#define __I_SCENE_PARAMETERS_H_INCLUDED__ - -/*! \file SceneParameters.h - \brief Header file containing all scene parameters for modifying mesh loading etc. - - This file includes all parameter names which can be set using ISceneManager::getParameters() - to modify the behaviour of plugins and mesh loaders. -*/ - -namespace irr -{ -namespace scene -{ - //! Name of the parameter for changing how Irrlicht handles the ZWrite flag for transparent (blending) materials - /** The default behavior in Irrlicht is to disable writing to the - z-buffer for all really transparent, i.e. blending materials. This - avoids problems with intersecting faces, but can also break renderings. - If transparent materials should use the SMaterial flag for ZWriteEnable - just as other material types use this attribute. - Use it like this: - \code - SceneManager->getParameters()->setAttribute(scene::ALLOW_ZWRITE_ON_TRANSPARENT, true); - \endcode - **/ - const c8* const ALLOW_ZWRITE_ON_TRANSPARENT = "Allow_ZWrite_On_Transparent"; - - //! Name of the parameter for changing the texture path of the built-in csm loader. - /** Use it like this: - \code - SceneManager->getParameters()->setAttribute(scene::CSM_TEXTURE_PATH, "path/to/your/textures"); - \endcode - **/ - const c8* const CSM_TEXTURE_PATH = "CSM_TexturePath"; - - //! Name of the parameter for changing the texture path of the built-in lmts loader. - /** Use it like this: - \code - SceneManager->getParameters()->setAttribute(scene::LMTS_TEXTURE_PATH, "path/to/your/textures"); - \endcode - **/ - const c8* const LMTS_TEXTURE_PATH = "LMTS_TexturePath"; - - //! Name of the parameter for changing the texture path of the built-in my3d loader. - /** Use it like this: - \code - SceneManager->getParameters()->setAttribute(scene::MY3D_TEXTURE_PATH, "path/to/your/textures"); - \endcode - **/ - const c8* const MY3D_TEXTURE_PATH = "MY3D_TexturePath"; - - //! Name of the parameter specifying the COLLADA mesh loading mode - /** - Specifies if the COLLADA loader should create instances of the models, lights and - cameras when loading COLLADA meshes. By default, this is set to false. If this is - set to true, the ISceneManager::getMesh() method will only return a pointer to a - dummy mesh and create instances of all meshes and lights and cameras in the collada - file by itself. Example: - \code - SceneManager->getParameters()->setAttribute(scene::COLLADA_CREATE_SCENE_INSTANCES, true); - \endcode - */ - const c8* const COLLADA_CREATE_SCENE_INSTANCES = "COLLADA_CreateSceneInstances"; - - //! Name of the parameter for changing the texture path of the built-in DMF loader. - /** This path is prefixed to the file names defined in the Deled file when loading - textures. This allows to alter the paths for a specific project setting. - Use it like this: - \code - SceneManager->getStringParameters()->setAttribute(scene::DMF_TEXTURE_PATH, "path/to/your/textures"); - \endcode - **/ - const c8* const DMF_TEXTURE_PATH = "DMF_TexturePath"; - - //! Name of the parameter for preserving DMF textures dir structure with built-in DMF loader. - /** If this parameter is set to true, the texture directory defined in the Deled file - is ignored, and only the texture name is used to find the proper file. Otherwise, the - texture path is also used, which allows to use a nicer media layout. - Use it like this: - \code - //this way you won't use this setting (default) - SceneManager->getParameters()->setAttribute(scene::DMF_IGNORE_MATERIALS_DIRS, false); - \endcode - \code - //this way you'll use this setting - SceneManager->getParameters()->setAttribute(scene::DMF_IGNORE_MATERIALS_DIRS, true); - \endcode - **/ - const c8* const DMF_IGNORE_MATERIALS_DIRS = "DMF_IgnoreMaterialsDir"; - - //! Name of the parameter for setting reference value of alpha in transparent materials. - /** Use it like this: - \code - //this way you'll set alpha ref to 0.1 - SceneManager->getParameters()->setAttribute(scene::DMF_ALPHA_CHANNEL_REF, 0.1); - \endcode - **/ - const c8* const DMF_ALPHA_CHANNEL_REF = "DMF_AlphaRef"; - - //! Name of the parameter for choose to flip or not tga files. - /** Use it like this: - \code - //this way you'll choose to flip alpha textures - SceneManager->getParameters()->setAttribute(scene::DMF_FLIP_ALPHA_TEXTURES, true); - \endcode - **/ - const c8* const DMF_FLIP_ALPHA_TEXTURES = "DMF_FlipAlpha"; - - - //! Flag to avoid loading group structures in .obj files - /** Use it like this: - \code - SceneManager->getParameters()->setAttribute(scene::OBJ_LOADER_IGNORE_GROUPS, true); - \endcode - **/ - const c8* const OBJ_LOADER_IGNORE_GROUPS = "OBJ_IgnoreGroups"; - - - //! Flag to avoid loading material .mtl file for .obj files - /** Use it like this: - \code - SceneManager->getParameters()->setAttribute(scene::OBJ_LOADER_IGNORE_MATERIAL_FILES, true); - \endcode - **/ - const c8* const OBJ_LOADER_IGNORE_MATERIAL_FILES = "OBJ_IgnoreMaterialFiles"; - - - //! Flag to ignore the b3d file's mipmapping flag - /** Instead Irrlicht's texture creation flag is used. Use it like this: - \code - SceneManager->getParameters()->setAttribute(scene::B3D_LOADER_IGNORE_MIPMAP_FLAG, true); - \endcode - **/ - const c8* const B3D_LOADER_IGNORE_MIPMAP_FLAG = "B3D_IgnoreMipmapFlag"; - - - //! Flag set as parameter when the scene manager is used as editor - /** In this way special animators like deletion animators can be stopped from - deleting scene nodes for example */ - const c8* const IRR_SCENE_MANAGER_IS_EDITOR = "IRR_Editor"; - - //! Name of the parameter for setting the length of debug normals. - /** Use it like this: - \code - SceneManager->getParameters()->setAttribute(scene::DEBUG_NORMAL_LENGTH, 1.5f); - \endcode - **/ - const c8* const DEBUG_NORMAL_LENGTH = "DEBUG_Normal_Length"; - - //! Name of the parameter for setting the color of debug normals. - /** Use it like this: - \code - SceneManager->getParameters()->setAttributeAsColor(scene::DEBUG_NORMAL_COLOR, video::SColor(255, 255, 255, 255)); - \endcode - **/ - const c8* const DEBUG_NORMAL_COLOR = "DEBUG_Normal_Color"; - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/aabbox3d.h b/irrlicht-1.6/include/aabbox3d.h deleted file mode 100644 index 2c72c6e81..000000000 --- a/irrlicht-1.6/include/aabbox3d.h +++ /dev/null @@ -1,333 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_AABBOX_3D_H_INCLUDED__ -#define __IRR_AABBOX_3D_H_INCLUDED__ - -#include "irrMath.h" -#include "plane3d.h" -#include "line3d.h" - -namespace irr -{ -namespace core -{ - -//! Axis aligned bounding box in 3d dimensional space. -/** Has some useful methods used with occlusion culling or clipping. -*/ -template <class T> -class aabbox3d -{ - public: - - //! Default Constructor. - aabbox3d(): MinEdge(-1,-1,-1), MaxEdge(1,1,1) {} - //! Constructor with min edge and max edge. - aabbox3d(const vector3d<T>& min, const vector3d<T>& max): MinEdge(min), MaxEdge(max) {} - //! Constructor with only one point. - aabbox3d(const vector3d<T>& init): MinEdge(init), MaxEdge(init) {} - //! Constructor with min edge and max edge as single values, not vectors. - aabbox3d(T minx, T miny, T minz, T maxx, T maxy, T maxz): MinEdge(minx, miny, minz), MaxEdge(maxx, maxy, maxz) {} - - // operators - //! Equality operator - /** \param other box to compare with. - \return True if both boxes are equal, else false. */ - inline bool operator==(const aabbox3d<T>& other) const { return (MinEdge == other.MinEdge && other.MaxEdge == MaxEdge);} - //! Inequality operator - /** \param other box to compare with. - \return True if both boxes are different, else false. */ - inline bool operator!=(const aabbox3d<T>& other) const { return !(MinEdge == other.MinEdge && other.MaxEdge == MaxEdge);} - - // functions - - //! Adds a point to the bounding box - /** The box grows bigger, if point was outside of the box. - \param p: Point to add into the box. */ - void addInternalPoint(const vector3d<T>& p) - { - addInternalPoint(p.X, p.Y, p.Z); - } - - //! Adds another bounding box - /** The box grows bigger, if the new box was outside of the box. - \param b: Other bounding box to add into this box. */ - void addInternalBox(const aabbox3d<T>& b) - { - addInternalPoint(b.MaxEdge); - addInternalPoint(b.MinEdge); - } - - //! Resets the bounding box to a one-point box. - /** \param x X coord of the point. - \param y Y coord of the point. - \param z Z coord of the point. */ - void reset(T x, T y, T z) - { - MaxEdge.set(x,y,z); - MinEdge = MaxEdge; - } - - //! Resets the bounding box. - /** \param initValue New box to set this one to. */ - void reset(const aabbox3d<T>& initValue) - { - *this = initValue; - } - - //! Resets the bounding box to a one-point box. - /** \param initValue New point. */ - void reset(const vector3d<T>& initValue) - { - MaxEdge = initValue; - MinEdge = initValue; - } - - //! Adds a point to the bounding box - /** The box grows bigger, if point is outside of the box. - \param x X coordinate of the point to add to this box. - \param y Y coordinate of the point to add to this box. - \param z Z coordinate of the point to add to this box. */ - void addInternalPoint(T x, T y, T z) - { - if (x>MaxEdge.X) MaxEdge.X = x; - if (y>MaxEdge.Y) MaxEdge.Y = y; - if (z>MaxEdge.Z) MaxEdge.Z = z; - - if (x<MinEdge.X) MinEdge.X = x; - if (y<MinEdge.Y) MinEdge.Y = y; - if (z<MinEdge.Z) MinEdge.Z = z; - } - - //! Determines if a point is within this box. - /** \param p: Point to check. - \return True if the point is within the box and false if not */ - bool isPointInside(const vector3d<T>& p) const - { - return (p.X >= MinEdge.X && p.X <= MaxEdge.X && - p.Y >= MinEdge.Y && p.Y <= MaxEdge.Y && - p.Z >= MinEdge.Z && p.Z <= MaxEdge.Z); - } - - //! Determines if a point is within this box and its borders. - /** \param p: Point to check. - \return True if the point is within the box and false if not. */ - bool isPointTotalInside(const vector3d<T>& p) const - { - return (p.X > MinEdge.X && p.X < MaxEdge.X && - p.Y > MinEdge.Y && p.Y < MaxEdge.Y && - p.Z > MinEdge.Z && p.Z < MaxEdge.Z); - } - - //! Determines if the box intersects with another box. - /** \param other: Other box to check a intersection with. - \return True if there is an intersection with the other box, - otherwise false. */ - bool intersectsWithBox(const aabbox3d<T>& other) const - { - return (MinEdge <= other.MaxEdge && MaxEdge >= other.MinEdge); - } - - //! Check if this box is completely inside the 'other' box. - /** \param other: Other box to check against. - \return True if this box is completly inside the other box, - otherwise false. */ - bool isFullInside(const aabbox3d<T>& other) const - { - return MinEdge >= other.MinEdge && MaxEdge <= other.MaxEdge; - } - - //! Tests if the box intersects with a line - /** \param line: Line to test intersection with. - \return True if there is an intersection , else false. */ - bool intersectsWithLine(const line3d<T>& line) const - { - return intersectsWithLine(line.getMiddle(), line.getVector().normalize(), - (T)(line.getLength() * 0.5)); - } - - //! Tests if the box intersects with a line - /** \param linemiddle Center of the line. - \param linevect Vector of the line. - \param halflength Half length of the line. - \return True if there is an intersection, else false. */ - bool intersectsWithLine(const vector3d<T>& linemiddle, - const vector3d<T>& linevect, - T halflength) const - { - const vector3d<T> e = getExtent() * (T)0.5; - const vector3d<T> t = getCenter() - linemiddle; - - if ((fabs(t.X) > e.X + halflength * fabs(linevect.X)) || - (fabs(t.Y) > e.Y + halflength * fabs(linevect.Y)) || - (fabs(t.Z) > e.Z + halflength * fabs(linevect.Z)) ) - return false; - - T r = e.Y * (T)fabs(linevect.Z) + e.Z * (T)fabs(linevect.Y); - if (fabs(t.Y*linevect.Z - t.Z*linevect.Y) > r ) - return false; - - r = e.X * (T)fabs(linevect.Z) + e.Z * (T)fabs(linevect.X); - if (fabs(t.Z*linevect.X - t.X*linevect.Z) > r ) - return false; - - r = e.X * (T)fabs(linevect.Y) + e.Y * (T)fabs(linevect.X); - if (fabs(t.X*linevect.Y - t.Y*linevect.X) > r) - return false; - - return true; - } - - //! Classifies a relation with a plane. - /** \param plane Plane to classify relation to. - \return Returns ISREL3D_FRONT if the box is in front of the plane, - ISREL3D_BACK if the box is behind the plane, and - ISREL3D_CLIPPED if it is on both sides of the plane. */ - EIntersectionRelation3D classifyPlaneRelation(const plane3d<T>& plane) const - { - vector3d<T> nearPoint(MaxEdge); - vector3d<T> farPoint(MinEdge); - - if (plane.Normal.X > (T)0) - { - nearPoint.X = MinEdge.X; - farPoint.X = MaxEdge.X; - } - - if (plane.Normal.Y > (T)0) - { - nearPoint.Y = MinEdge.Y; - farPoint.Y = MaxEdge.Y; - } - - if (plane.Normal.Z > (T)0) - { - nearPoint.Z = MinEdge.Z; - farPoint.Z = MaxEdge.Z; - } - - if (plane.Normal.dotProduct(nearPoint) + plane.D > (T)0) - return ISREL3D_FRONT; - - if (plane.Normal.dotProduct(farPoint) + plane.D > (T)0) - return ISREL3D_CLIPPED; - - return ISREL3D_BACK; - } - - - //! Get center of the bounding box - /** \return Center of the bounding box. */ - vector3d<T> getCenter() const - { - return (MinEdge + MaxEdge) / 2; - } - - - //! Get extent of the box - /** \return Extent of the bounding box. */ - vector3d<T> getExtent() const - { - return MaxEdge - MinEdge; - } - - - //! Stores all 8 edges of the box into an array - /** \param edges: Pointer to array of 8 edges. */ - void getEdges(vector3d<T> *edges) const - { - const core::vector3d<T> middle = getCenter(); - const core::vector3d<T> diag = middle - MaxEdge; - - /* - Edges are stored in this way: - Hey, am I an ascii artist, or what? :) niko. - /3--------/7 - / | / | - / | / | - 1---------5 | - | 2- - -| -6 - | / | / - |/ | / - 0---------4/ - */ - - edges[0].set(middle.X + diag.X, middle.Y + diag.Y, middle.Z + diag.Z); - edges[1].set(middle.X + diag.X, middle.Y - diag.Y, middle.Z + diag.Z); - edges[2].set(middle.X + diag.X, middle.Y + diag.Y, middle.Z - diag.Z); - edges[3].set(middle.X + diag.X, middle.Y - diag.Y, middle.Z - diag.Z); - edges[4].set(middle.X - diag.X, middle.Y + diag.Y, middle.Z + diag.Z); - edges[5].set(middle.X - diag.X, middle.Y - diag.Y, middle.Z + diag.Z); - edges[6].set(middle.X - diag.X, middle.Y + diag.Y, middle.Z - diag.Z); - edges[7].set(middle.X - diag.X, middle.Y - diag.Y, middle.Z - diag.Z); - } - - - //! Check if the box is empty. - /** This means that there is no space between the min and max - edge. - \return True if box is empty, else false. */ - bool isEmpty() const - { - return MinEdge.equals ( MaxEdge ); - } - - - //! Repairs the box. - /** Necessary if for example MinEdge and MaxEdge are swapped. */ - void repair() - { - T t; - - if (MinEdge.X > MaxEdge.X) - { t=MinEdge.X; MinEdge.X = MaxEdge.X; MaxEdge.X=t; } - if (MinEdge.Y > MaxEdge.Y) - { t=MinEdge.Y; MinEdge.Y = MaxEdge.Y; MaxEdge.Y=t; } - if (MinEdge.Z > MaxEdge.Z) - { t=MinEdge.Z; MinEdge.Z = MaxEdge.Z; MaxEdge.Z=t; } - } - - //! Calculates a new interpolated bounding box. - /** \param other: other box to interpolate between - \param d: value between 0.0f and 1.0f. - \return Interpolated box. */ - aabbox3d<T> getInterpolated(const aabbox3d<T>& other, f32 d) const - { - f32 inv = 1.0f - d; - return aabbox3d<T>((other.MinEdge*inv) + (MinEdge*d), - (other.MaxEdge*inv) + (MaxEdge*d)); - } - - //! Get the volume enclosed by the box in cubed units - T getVolume() const - { - const vector3d<T> e = getExtent(); - return e.X * e.Y * e.Z; - } - - //! Get the surface area of the box in squared units - T getArea() const - { - const vector3d<T> e = getExtent(); - return 2*(e.X*e.Y + e.X*e.Z + e.Y*e.Z); - } - - //! The near edge - vector3d<T> MinEdge; - - //! The far edge - vector3d<T> MaxEdge; -}; - - //! Typedef for a f32 3d bounding box. - typedef aabbox3d<f32> aabbox3df; - //! Typedef for an integer 3d bounding box. - typedef aabbox3d<s32> aabbox3di; - -} // end namespace core -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/coreutil.h b/irrlicht-1.6/include/coreutil.h deleted file mode 100644 index 96b2ff8c3..000000000 --- a/irrlicht-1.6/include/coreutil.h +++ /dev/null @@ -1,180 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_CORE_UTIL_H_INCLUDED__ -#define __IRR_CORE_UTIL_H_INCLUDED__ - -#include "irrString.h" -#include "path.h" - -namespace irr -{ -namespace core -{ - -/*! \file irrxml.h - \brief File containing useful basic utility functions -*/ - -// ----------- some basic quite often used string functions ----------------- - -//! search if a filename has a proper extension -inline s32 isFileExtension ( const io::path& filename, - const io::path& ext0, - const io::path& ext1, - const io::path& ext2) -{ - s32 extPos = filename.findLast ( '.' ); - if ( extPos < 0 ) - return 0; - - extPos += 1; - if ( filename.equals_substring_ignore_case ( ext0, extPos ) ) return 1; - if ( filename.equals_substring_ignore_case ( ext1, extPos ) ) return 2; - if ( filename.equals_substring_ignore_case ( ext2, extPos ) ) return 3; - return 0; -} - -//! search if a filename has a proper extension -inline bool hasFileExtension ( const io::path& filename, - const io::path& ext0, - const io::path& ext1 = "", - const io::path& ext2 = "") -{ - return isFileExtension ( filename, ext0, ext1, ext2 ) > 0; -} - -//! cut the filename extension from a source string and stores in the dest string -inline stringc& cutFilenameExtension ( stringc &dest, const stringc &source ) -{ - s32 endPos = source.findLast ( '.' ); - dest = source.subString ( 0, endPos < 0 ? source.size () : endPos ); - return dest; -} - -//! cut the filename extension from a source string and stores in the dest string -inline stringw& cutFilenameExtension ( stringw &dest, const stringw &source ) -{ - s32 endPos = source.findLast ( '.' ); - dest = source.subString ( 0, endPos < 0 ? source.size () : endPos ); - return dest; -} - -//! get the filename extension from a string -inline stringc& getFileNameExtension ( stringc &dest, const stringc &source ) -{ - s32 endPos = source.findLast ( '.' ); - if ( endPos < 0 ) - dest = ""; - else - dest = source.subString ( endPos, source.size () ); - return dest; -} - -//! delete path from filename -inline core::stringw& deletePathFromFilename(core::stringw& filename) -{ - // delete path from filename - const wchar_t *s = filename.c_str(); - const wchar_t* p = s + filename.size(); - - // search for path separator or beginning - while ( *p != '/' && *p != '\\' && p != s ) - p--; - - if ( p != s ) - { - ++p; - filename = p; - } - return filename; -} - -//! delete path from filename -inline core::stringc& deletePathFromFilename(core::stringc& filename) -{ - // delete path from filename - const c8 *s = filename.c_str(); - const c8* p = s + filename.size(); - - // search for path separator or beginning - while ( *p != '/' && *p != '\\' && p != s ) - p--; - - if ( p != s ) - { - ++p; - filename = p; - } - return filename; -} - -//! trim paths -inline io::path& deletePathFromPath(io::path& filename, s32 pathCount) -{ - // delete path from filename - s32 i = filename.size(); - - // search for path separator or beginning - while ( i ) - { - if ( filename[i] == '/' || filename[i] == '\\' ) - { - if ( --pathCount <= 0 ) - break; - } - i -= 1; - } - - if ( i ) - { - filename [ i + 1 ] = 0; - filename.validate(); - } - return filename; -} - -//! looks if file is in the same directory of path. returns offset of directory. -//! 0 means in same directory. 1 means file is direct child of path -inline s32 isInSameDirectory ( const io::path& path, const io::path& file ) -{ - s32 subA = 0; - s32 subB = 0; - s32 pos; - - if ( path.size() && !path.equalsn ( file, path.size() ) ) - return -1; - - pos = 0; - while ( (pos = path.findNext ( '/', pos )) >= 0 ) - { - subA += 1; - pos += 1; - } - - pos = 0; - while ( (pos = file.findNext ( '/', pos )) >= 0 ) - { - subB += 1; - pos += 1; - } - - return subB - subA; -} - - -//! some standard function ( to remove dependencies ) -#undef isdigit -#undef isspace -#undef isupper -inline s32 isdigit(s32 c) { return c >= '0' && c <= '9'; } -inline s32 isspace(s32 c) { return c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v'; } -inline s32 isupper(s32 c) { return c >= 'A' && c <= 'Z'; } - - -} // end namespace core -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/dimension2d.h b/irrlicht-1.6/include/dimension2d.h deleted file mode 100644 index 98f0ae0b3..000000000 --- a/irrlicht-1.6/include/dimension2d.h +++ /dev/null @@ -1,219 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_DIMENSION2D_H_INCLUDED__ -#define __IRR_DIMENSION2D_H_INCLUDED__ - -#include "irrTypes.h" -#include "irrMath.h" // for irr::core::equals() - -namespace irr -{ -namespace core -{ - template <class T> - class vector2d; - - //! Specifies a 2 dimensional size. - template <class T> - class dimension2d - { - public: - //! Default constructor for empty dimension - dimension2d() : Width(0), Height(0) {} - //! Constructor with width and height - dimension2d(const T& width, const T& height) - : Width(width), Height(height) {} - - dimension2d(const vector2d<T>& other); // Defined in vector2d.h - - //! Use this constructor only where you are sure that the conversion is valid. - template <class U> - explicit dimension2d(const dimension2d<U>& other) : - Width((T)other.Width), Height((T)other.Height) { } - - template <class U> - dimension2d<T>& operator=(const dimension2d<U>& other) - { - Width = (T) other.Width; - Height = (T) other.Height; - return *this; - } - - - //! Equality operator - bool operator==(const dimension2d<T>& other) const - { - return core::equals(Width, other.Width) && - core::equals(Height, other.Height); - } - - //! Inequality operator - bool operator!=(const dimension2d<T>& other) const - { - return ! (*this == other); - } - - bool operator==(const vector2d<T>& other) const; // Defined in vector2d.h - - bool operator!=(const vector2d<T>& other) const - { - return !(*this == other); - } - - //! Set to new values - dimension2d<T>& set(const T& width, const T& height) - { - Width = width; - Height = height; - return *this; - } - - //! Divide width and height by scalar - dimension2d<T>& operator/=(const T& scale) - { - Width /= scale; - Height /= scale; - return *this; - } - - //! Divide width and height by scalar - dimension2d<T> operator/(const T& scale) const - { - return dimension2d<T>(Width/scale, Height/scale); - } - - //! Multiply width and height by scalar - dimension2d<T>& operator*=(const T& scale) - { - Width *= scale; - Height *= scale; - return *this; - } - - //! Multiply width and height by scalar - dimension2d<T> operator*(const T& scale) const - { - return dimension2d<T>(Width*scale, Height*scale); - } - - //! Add another dimension to this one. - dimension2d<T>& operator+=(const dimension2d<T>& other) - { - Width += other.Width; - Height += other.Height; - return *this; - } - - //! Subtract a dimension from this one - dimension2d<T>& operator-=(const dimension2d<T>& other) - { - Width -= other.Width; - Height -= other.Height; - return *this; - } - - - //! Add two dimensions - dimension2d<T> operator+(const dimension2d<T>& other) const - { - return dimension2d<T>(Width+other.Width, Height+other.Height); - } - - //! Get area - T getArea() const - { - return Width*Height; - } - - //! Get the optimal size according to some properties - /** This is a function often used for texture dimension - calculations. The function returns the next larger or - smaller dimension which is a power-of-two dimension - (2^n,2^m) and/or square (Width=Height). - \param requirePowerOfTwo Forces the result to use only - powers of two as values. - \param requireSquare Makes width==height in the result - \param larger Choose whether the result is larger or - smaller than the current dimension. If one dimension - need not be changed it is kept with any value of larger. - \param maxValue Maximum texturesize. if value > 0 size is - clamped to maxValue - \return The optimal dimension under the given - constraints. */ - dimension2d<T> getOptimalSize( - bool requirePowerOfTwo=true, - bool requireSquare=false, - bool larger=true, - u32 maxValue = 0) const - { - u32 i=1; - u32 j=1; - if (requirePowerOfTwo) - { - while (i<(u32)Width) - i<<=1; - if (!larger && i!=1 && i!=(u32)Width) - i>>=1; - while (j<(u32)Height) - j<<=1; - if (!larger && j!=1 && j!=(u32)Height) - j>>=1; - } - else - { - i=(u32)Width; - j=(u32)Height; - } - - if (requireSquare) - { - if ((larger && (i>j)) || (!larger && (i<j))) - j=i; - else - i=j; - } - - if ( maxValue > 0 && i > maxValue) - i = maxValue; - - if ( maxValue > 0 && j > maxValue) - j = maxValue; - - return dimension2d<T>((T)i,(T)j); - } - - //! Get the interpolated dimension - /** \param other Other dimension to interpolate with. - \param d Value between 0.0f and 1.0f. - \return Interpolated dimension. */ - dimension2d<T> getInterpolated(const dimension2d<T>& other, f32 d) const - { - T inv = (T) (1.0f - d); - return dimension2d<T>(other.Width*inv + Width*d, other.Height*inv + Height*d); - } - - - //! Width of the dimension. - T Width; - //! Height of the dimension. - T Height; - }; - - //! Typedef for an f32 dimension. - typedef dimension2d<f32> dimension2df; - //! Typedef for an unsigned integer dimension. - typedef dimension2d<u32> dimension2du; - - //! Typedef for an integer dimension. - /** There are few cases where negative dimensions make sense. Please consider using - dimension2du instead. */ - typedef dimension2d<s32> dimension2di; - - -} // end namespace core -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/fast_atof.h b/irrlicht-1.6/include/fast_atof.h deleted file mode 100644 index 7920c340c..000000000 --- a/irrlicht-1.6/include/fast_atof.h +++ /dev/null @@ -1,197 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine" and the "irrXML" project. -// For conditions of distribution and use, see copyright notice in irrlicht.h and irrXML.h - -#ifndef __FAST_A_TO_F_H_INCLUDED__ -#define __FAST_A_TO_F_H_INCLUDED__ - -#include "irrMath.h" - -namespace irr -{ -namespace core -{ - -// we write [17] here instead of [] to work around a swig bug -const float fast_atof_table[17] = { - 0.f, - 0.1f, - 0.01f, - 0.001f, - 0.0001f, - 0.00001f, - 0.000001f, - 0.0000001f, - 0.00000001f, - 0.000000001f, - 0.0000000001f, - 0.00000000001f, - 0.000000000001f, - 0.0000000000001f, - 0.00000000000001f, - 0.000000000000001f, - 0.0000000000000001f -}; - -//! Convert a simple string of base 10 digits into a signed 32 bit integer. -//! \param[in] in: The string of digits to convert. Only a leading - or + followed -//! by digits 0 to 9 will be considered. Parsing stops at the -//! first non-digit. -//! \param[out] out: (optional) If provided, it will be set to point at the first -//! character not used in the calculation. -//! \return The signed integer value of the digits. If the string specifies too many -//! digits to encode in an s32 then +INT_MAX or -INT_MAX will be returned. -inline s32 strtol10(const char* in, const char** out=0) -{ - if(!in) - return 0; - - bool negative = false; - if('-' == *in) - { - negative = true; - ++in; - } - else if('+' == *in) - ++in; - - u32 unsignedValue = 0; - - while ( ( *in >= '0') && ( *in <= '9' )) - { - unsignedValue = ( unsignedValue * 10 ) + ( *in - '0' ); - ++in; - - if(unsignedValue > (u32)INT_MAX) - { - unsignedValue = (u32)INT_MAX; - break; - } - } - if (out) - *out = in; - - if(negative) - return -((s32)unsignedValue); - else - return (s32)unsignedValue; -} - -//! Converts a sequence of digits into a whole positive floating point value. -//! Only digits 0 to 9 are parsed. Parsing stops at any other character, -//! including sign characters or a decimal point. -//! \param in: the sequence of digits to convert. -//! \param out: (optional) will be set to point at the first non-converted character. -//! \return The whole positive floating point representation of the digit sequence. -inline f32 strtof10(const char* in, const char * * out = 0) -{ - if(out) - *out = in; - - if(!in) - return 0.f; - - static const u32 MAX_SAFE_U32_VALUE = UINT_MAX / 10 - 10; - f32 floatValue = 0.f; - u32 intValue = 0; - - // Use integer arithmetic for as long as possible, for speed - // and precision. - while ( ( *in >= '0') && ( *in <= '9' ) ) - { - // If it looks like we're going to overflow, bail out - // now and start using floating point. - if(intValue >= MAX_SAFE_U32_VALUE) - break; - - intValue = ( intValue * 10) + ( *in - '0' ); - ++in; - } - - floatValue = (f32)intValue; - - // If there are any digits left to parse, then we need to use - // floating point arithmetic from here. - while ( ( *in >= '0') && ( *in <= '9' ) ) - { - floatValue = ( floatValue * 10.f ) + (f32)( *in - '0' ); - ++in; - if(floatValue > FLT_MAX) // Just give up. - break; - } - - if(out) - *out = in; - - return floatValue; -} - -//! Provides a fast function for converting a string into a float. -//! This is not guaranteed to be as accurate as atof(), but is -//! approximately 6 to 8 times as fast. -//! \param[in] in: The string to convert. -//! \param[out] out: The resultant float will be written here. -//! \return A pointer to the first character in the string that wasn't -//! use to create the float value. -inline const char* fast_atof_move( const char * in, f32 & out) -{ - // Please run this regression test when making any modifications to this function: - // https://sourceforge.net/tracker/download.php?group_id=74339&atid=540676&file_id=298968&aid=1865300 - - out = 0.f; - if(!in) - return 0; - - bool negative = false; - if(*in == '-') - { - negative = true; - ++in; - } - - f32 value = strtof10 ( in, &in ); - - if (*in == '.') - { - ++in; - - const char * afterDecimal = in; - f32 decimal = strtof10 ( in, &afterDecimal ); - decimal *= fast_atof_table[afterDecimal - in]; - - value += decimal; - - in = afterDecimal; - } - - if ('e' == *in || 'E' == *in) - { - ++in; - // Assume that the exponent is a whole number. - // strtol10() will deal with both + and - signs, - // but cast to (f32) to prevent overflow at FLT_MAX - value *= (f32)pow(10.0f, (f32)strtol10(in, &in)); - } - - if(negative) - out = -value; - else - out = value; - - return in; -} - -//! Convert a string to a floating point number -//! \param floatAsString: The string to convert. -inline float fast_atof(const char* floatAsString) -{ - float ret; - fast_atof_move(floatAsString, ret); - return ret; -} - -} // end namespace core -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/heapsort.h b/irrlicht-1.6/include/heapsort.h deleted file mode 100644 index 9c2b3b7c4..000000000 --- a/irrlicht-1.6/include/heapsort.h +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_HEAPSORT_H_INCLUDED__ -#define __IRR_HEAPSORT_H_INCLUDED__ - -#include "irrTypes.h" - -namespace irr -{ -namespace core -{ - -//! Sinks an element into the heap. -template<class T> -inline void heapsink(T*array, s32 element, s32 max) -{ - while ((element<<1) < max) // there is a left child - { - s32 j = (element<<1); - - if (j+1 < max && array[j] < array[j+1]) - j = j+1; // take right child - - if (array[element] < array[j]) - { - T t = array[j]; // swap elements - array[j] = array[element]; - array[element] = t; - element = j; - } - else - return; - } -} - - -//! Sorts an array with size 'size' using heapsort. -template<class T> -inline void heapsort(T* array_, s32 size) -{ - // for heapsink we pretent this is not c++, where - // arrays start with index 0. So we decrease the array pointer, - // the maximum always +2 and the element always +1 - - T* virtualArray = array_ - 1; - s32 virtualSize = size + 2; - s32 i; - - // build heap - - for (i=((size-1)/2); i>=0; --i) - heapsink(virtualArray, i+1, virtualSize-1); - - // sort array - - for (i=size-1; i>=0; --i) - { - T t = array_[0]; - array_[0] = array_[i]; - array_[i] = t; - heapsink(virtualArray, 1, i + 1); - } -} - -} // end namespace core -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/irrAllocator.h b/irrlicht-1.6/include/irrAllocator.h deleted file mode 100644 index 203582878..000000000 --- a/irrlicht-1.6/include/irrAllocator.h +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine" and the "irrXML" project. -// For conditions of distribution and use, see copyright notice in irrlicht.h and irrXML.h - -#ifndef __IRR_ALLOCATOR_H_INCLUDED__ -#define __IRR_ALLOCATOR_H_INCLUDED__ - -#include "irrTypes.h" -#include <new> -// necessary for older compilers -#include <memory.h> - -namespace irr -{ -namespace core -{ - -#ifdef DEBUG_CLIENTBLOCK -#undef DEBUG_CLIENTBLOCK -#define DEBUG_CLIENTBLOCK new -#endif - -//! Very simple allocator implementation, containers using it can be used across dll boundaries -template<typename T> -class irrAllocator -{ -public: - - //! Destructor - virtual ~irrAllocator() {} - - //! Allocate memory for an array of objects - T* allocate(size_t cnt) - { - return (T*)internal_new(cnt* sizeof(T)); - } - - //! Deallocate memory for an array of objects - void deallocate(T* ptr) - { - internal_delete(ptr); - } - - //! Construct an element - void construct(T* ptr, const T&e) - { - new ((void*)ptr) T(e); - } - - //! Destruct an element - void destruct(T* ptr) - { - ptr->~T(); - } - -protected: - - virtual void* internal_new(size_t cnt) - { - return operator new(cnt); - } - - virtual void internal_delete(void* ptr) - { - operator delete(ptr); - } - -}; - - -//! Fast allocator, only to be used in containers inside the same memory heap. -/** Containers using it are NOT able to be used it across dll boundaries. Use this -when using in an internal class or function or when compiled into a static lib */ -template<typename T> -class irrAllocatorFast -{ -public: - - //! Allocate memory for an array of objects - T* allocate(size_t cnt) - { - return (T*)operator new(cnt* sizeof(T)); - } - - //! Deallocate memory for an array of objects - void deallocate(T* ptr) - { - operator delete(ptr); - } - - //! Construct an element - void construct(T* ptr, const T&e) - { - new ((void*)ptr) T(e); - } - - //! Destruct an element - void destruct(T* ptr) - { - ptr->~T(); - } -}; - - - -#ifdef DEBUG_CLIENTBLOCK -#undef DEBUG_CLIENTBLOCK -#define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__) -#endif - -//! defines an allocation strategy -enum eAllocStrategy -{ - ALLOC_STRATEGY_SAFE = 0, - ALLOC_STRATEGY_DOUBLE = 1, - ALLOC_STRATEGY_SQRT = 2, -}; - - -} // end namespace core -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/irrArray.h b/irrlicht-1.6/include/irrArray.h deleted file mode 100644 index aae8195f9..000000000 --- a/irrlicht-1.6/include/irrArray.h +++ /dev/null @@ -1,579 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine" and the "irrXML" project. -// For conditions of distribution and use, see copyright notice in irrlicht.h and irrXML.h - -#ifndef __IRR_ARRAY_H_INCLUDED__ -#define __IRR_ARRAY_H_INCLUDED__ - -#include "irrTypes.h" -#include "heapsort.h" -#include "irrAllocator.h" - -namespace irr -{ -namespace core -{ - -//! Self reallocating template array (like stl vector) with additional features. -/** Some features are: Heap sorting, binary search methods, easier debugging. -*/ -template <class T, typename TAlloc = irrAllocator<T> > -class array -{ - -public: - - //! Default constructor for empty array. - array() - : data(0), allocated(0), used(0), - strategy(ALLOC_STRATEGY_DOUBLE), free_when_destroyed(true), is_sorted(true) - { - } - - //! Constructs an array and allocates an initial chunk of memory. - /** \param start_count Amount of elements to pre-allocate. */ - array(u32 start_count) - : data(0), allocated(0), used(0), - strategy(ALLOC_STRATEGY_DOUBLE), free_when_destroyed(true), is_sorted(true) - { - reallocate(start_count); - } - - - //! Copy constructor - array(const array<T>& other) - : data(0) - { - *this = other; - } - - - - //! Destructor. - /** Frees allocated memory, if set_free_when_destroyed was not set to - false by the user before. */ - ~array() - { - if (free_when_destroyed) - { - for (u32 i=0; i<used; ++i) - allocator.destruct(&data[i]); - - allocator.deallocate(data); - } - } - - - //! Reallocates the array, make it bigger or smaller. - /** \param new_size New size of array. */ - void reallocate(u32 new_size) - { - T* old_data = data; - - data = allocator.allocate(new_size); //new T[new_size]; - allocated = new_size; - - // copy old data - s32 end = used < new_size ? used : new_size; - - for (s32 i=0; i<end; ++i) - { - // data[i] = old_data[i]; - allocator.construct(&data[i], old_data[i]); - } - - // destruct old data - for (u32 j=0; j<used; ++j) - allocator.destruct(&old_data[j]); - - if (allocated < used) - used = allocated; - - allocator.deallocate(old_data); //delete [] old_data; - } - - - //! set a new allocation strategy - /** if the maximum size of the array is unknown, you can define how big the - allocation should happen. - \param element: newStratgey to applay to this array. */ - void setAllocStrategy ( eAllocStrategy newStrategy = ALLOC_STRATEGY_DOUBLE ) - { - strategy = newStrategy; - } - - //! Adds an element at back of array. - /** If the array is too small to add this new element it is made bigger. - \param element: Element to add at the back of the array. */ - void push_back(const T& element) - { - if (used + 1 > allocated) - { - // this doesn't work if the element is in the same array. So - // we'll copy the element first to be sure we'll get no data - // corruption - - T e(element); - //reallocate(used * 2 +1); // increase data block - // TA: okt, 2008. it's only allowed to alloc one element, if - // default constructor has to be called - - // increase data block - u32 newAlloc; - switch ( strategy ) - { - case ALLOC_STRATEGY_DOUBLE: - newAlloc = used + 1 + (allocated < 500 ? - (allocated < 5 ? 5 : used) : used >> 2); - break; - default: - case ALLOC_STRATEGY_SAFE: - newAlloc = used + 1; - break; - } - reallocate( newAlloc); - // construct new element - // Attention!. in missing default constructors for faster alloc methods - allocator.construct(&data[used++], e); // data[used++] = e; // push_back - } - else - { - //data[used++] = element; - // instead of using this here, we copy it the safe way: - allocator.construct(&data[used++], element); - } - - is_sorted = false; - } - - - //! Adds an element at the front of the array. - /** If the array is to small to add this new element, the array is - made bigger. Please note that this is slow, because the whole array - needs to be copied for this. - \param element Element to add at the back of the array. */ - void push_front(const T& element) - { - insert(element); - } - - - //! Insert item into array at specified position. - /** Please use this only if you know what you are doing (possible - performance loss). The preferred method of adding elements should be - push_back(). - \param element: Element to be inserted - \param index: Where position to insert the new element. */ - void insert(const T& element, u32 index=0) - { - _IRR_DEBUG_BREAK_IF(index>used) // access violation - - if (used + 1 > allocated) - reallocate(used +1); - - for (u32 i=used; i>index; --i) - { - if (i<used) - allocator.destruct(&data[i]); - allocator.construct(&data[i], data[i-1]); // data[i] = data[i-1]; - } - - if (used > index) - allocator.destruct(&data[index]); - allocator.construct(&data[index], element); // data[index] = element; - is_sorted = false; - ++used; - } - - - //! Clears the array and deletes all allocated memory. - void clear() - { - for (u32 i=0; i<used; ++i) - allocator.destruct(&data[i]); - - allocator.deallocate(data); // delete [] data; - data = 0; - used = 0; - allocated = 0; - is_sorted = true; - } - - - //! Sets pointer to new array, using this as new workspace. - /** \param newPointer: Pointer to new array of elements. - \param size: Size of the new array. */ - void set_pointer(T* newPointer, u32 size) - { - for (u32 i=0; i<used; ++i) - allocator.destruct(&data[i]); - - allocator.deallocate(data); // delete [] data; - data = newPointer; - allocated = size; - used = size; - is_sorted = false; - } - - - //! Sets if the array should delete the memory it uses upon destruction. - /** \param f If true, the array frees the allocated memory in its - destructor, otherwise not. The default is true. */ - void set_free_when_destroyed(bool f) - { - free_when_destroyed = f; - } - - - //! Sets the size of the array and allocates new elements if necessary. - /** Please note: This is only secure when using it with simple types, - because no default constructor will be called for the added elements. - \param usedNow Amount of elements now used. */ - void set_used(u32 usedNow) - { - if (allocated < usedNow) - reallocate(usedNow); - - used = usedNow; - } - - - //! Assignment operator - void operator=(const array<T>& other) - { - strategy = other.strategy; - - if (data) - { - for (u32 i=0; i<used; ++i) - allocator.destruct(&data[i]); - - allocator.deallocate(data); // delete [] data; - } - - //if (allocated < other.allocated) - if (other.allocated == 0) - data = 0; - else - data = allocator.allocate(other.allocated); // new T[other.allocated]; - - used = other.used; - free_when_destroyed = other.free_when_destroyed; - is_sorted = other.is_sorted; - allocated = other.allocated; - - for (u32 i=0; i<other.used; ++i) - allocator.construct(&data[i], other.data[i]); // data[i] = other.data[i]; - } - - - //! Equality operator - bool operator == (const array<T>& other) const - { - if (used != other.used) - return false; - - for (u32 i=0; i<other.used; ++i) - if (data[i] != other[i]) - return false; - return true; - } - - //! Inequality operator - bool operator != (const array<T>& other) const - { - return !(*this==other); - } - - - //! Direct access operator - T& operator [](u32 index) - { - _IRR_DEBUG_BREAK_IF(index>=used) // access violation - - return data[index]; - } - - - //! Direct const access operator - const T& operator [](u32 index) const - { - _IRR_DEBUG_BREAK_IF(index>=used) // access violation - - return data[index]; - } - - - //! Gets last element. - T& getLast() - { - _IRR_DEBUG_BREAK_IF(!used) // access violation - - return data[used-1]; - } - - - //! Gets last element - const T& getLast() const - { - _IRR_DEBUG_BREAK_IF(!used) // access violation - - return data[used-1]; - } - - - //! Gets a pointer to the array. - /** \return Pointer to the array. */ - T* pointer() - { - return data; - } - - - //! Gets a const pointer to the array. - /** \return Pointer to the array. */ - const T* const_pointer() const - { - return data; - } - - - //! Get number of occupied elements of the array. - /** \return Size of elements in the array which are actually occupied. */ - u32 size() const - { - return used; - } - - - //! Get amount of memory allocated. - /** \return Amount of memory allocated. The amount of bytes - allocated would be allocated_size() * sizeof(ElementTypeUsed); */ - u32 allocated_size() const - { - return allocated; - } - - - //! Check if array is empty. - /** \return True if the array is empty false if not. */ - bool empty() const - { - return used == 0; - } - - - //! Sorts the array using heapsort. - /** There is no additional memory waste and the algorithm performs - O(n*log n) in worst case. */ - void sort() - { - if (is_sorted || used<2) - return; - - heapsort(data, used); - is_sorted = true; - } - - - //! Performs a binary search for an element, returns -1 if not found. - /** The array will be sorted before the binary search if it is not - already sorted. Caution is advised! Be careful not to call this on - unsorted const arrays, or the slower method will be used. - \param element Element to search for. - \return Position of the searched element if it was found, - otherwise -1 is returned. */ - s32 binary_search(const T& element) - { - sort(); - return binary_search(element, 0, used-1); - } - - - //! Performs a binary search for an element if possible, returns -1 if not found. - /** This method is for const arrays and so cannot call sort(), if the array is - not sorted then linear_search will be used instead. Potentially very slow! - \param element Element to search for. - \return Position of the searched element if it was found, - otherwise -1 is returned. */ - s32 binary_search(const T& element) const - { - if (is_sorted) - return binary_search(element, 0, used-1); - else - return linear_search(element); - } - - - //! Performs a binary search for an element, returns -1 if not found. - /** \param element: Element to search for. - \param left First left index - \param right Last right index. - \return Position of the searched element if it was found, otherwise -1 - is returned. */ - s32 binary_search(const T& element, s32 left, s32 right) const - { - if (!used) - return -1; - - s32 m; - - do - { - m = (left+right)>>1; - - if (element < data[m]) - right = m - 1; - else - left = m + 1; - - } while((element < data[m] || data[m] < element) && left<=right); - // this last line equals to: - // " while((element != array[m]) && left<=right);" - // but we only want to use the '<' operator. - // the same in next line, it is "(element == array[m])" - - - if (!(element < data[m]) && !(data[m] < element)) - return m; - - return -1; - } - - - //! Performs a binary search for an element, returns -1 if not found. - //! it is used for searching a multiset - /** The array will be sorted before the binary search if it is not - already sorted. - \param element Element to search for. - \param &last return lastIndex of equal elements - \return Position of the first searched element if it was found, - otherwise -1 is returned. */ - s32 binary_search_multi(const T& element, s32 &last) - { - sort(); - s32 index = binary_search(element, 0, used-1); - if ( index < 0 ) - return index; - - // The search can be somewhere in the middle of the set - // look linear previous and past the index - last = index; - - while ( index > 0 && !(element < data[index - 1]) && !(data[index - 1] < element) ) - { - index -= 1; - } - // look linear up - while ( last < (s32) used - 1 && !(element < data[last + 1]) && !(data[last + 1] < element) ) - { - last += 1; - } - - return index; - } - - //! Finds an element in linear time, which is very slow. - /** Use binary_search for faster finding. Only works if ==operator is - implemented. - \param element Element to search for. - \return Position of the searched element if it was found, otherwise -1 - is returned. */ - s32 linear_search(const T& element) const - { - for (u32 i=0; i<used; ++i) - if (element == data[i]) - return (s32)i; - - return -1; - } - - - //! Finds an element in linear time, which is very slow. - /** Use binary_search for faster finding. Only works if ==operator is - implemented. - \param element: Element to search for. - \return Position of the searched element if it was found, otherwise -1 - is returned. */ - s32 linear_reverse_search(const T& element) const - { - for (s32 i=used-1; i>=0; --i) - if (data[i] == element) - return i; - - return -1; - } - - - //! Erases an element from the array. - /** May be slow, because all elements following after the erased - element have to be copied. - \param index: Index of element to be erased. */ - void erase(u32 index) - { - _IRR_DEBUG_BREAK_IF(index>=used) // access violation - - for (u32 i=index+1; i<used; ++i) - { - allocator.destruct(&data[i-1]); - allocator.construct(&data[i-1], data[i]); // data[i-1] = data[i]; - } - - allocator.destruct(&data[used-1]); - - --used; - } - - - //! Erases some elements from the array. - /** May be slow, because all elements following after the erased - element have to be copied. - \param index: Index of the first element to be erased. - \param count: Amount of elements to be erased. */ - void erase(u32 index, s32 count) - { - _IRR_DEBUG_BREAK_IF(index>=used || count<1 || index+count>used) // access violation - - u32 i; - for (i=index; i<index+count; ++i) - allocator.destruct(&data[i]); - - for (i=index+count; i<used; ++i) - { - if (i > index+count) - allocator.destruct(&data[i-count]); - - allocator.construct(&data[i-count], data[i]); // data[i-count] = data[i]; - - if (i >= used-count) - allocator.destruct(&data[i]); - } - - used-= count; - } - - - //! Sets if the array is sorted - void set_sorted(bool _is_sorted) - { - is_sorted = _is_sorted; - } - - private: - - T* data; - TAlloc allocator; - u32 allocated; - u32 used; - eAllocStrategy strategy; - bool free_when_destroyed:1; - bool is_sorted:1; -}; - - -} // end namespace core -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/include/irrList.h b/irrlicht-1.6/include/irrList.h deleted file mode 100644 index 89add41b4..000000000 --- a/irrlicht-1.6/include/irrList.h +++ /dev/null @@ -1,395 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_LIST_H_INCLUDED__ -#define __IRR_LIST_H_INCLUDED__ - -#include "irrTypes.h" -#include "irrAllocator.h" - -namespace irr -{ -namespace core -{ - - -//! Doubly linked list template. -template <class T> -class list -{ -private: - - //! List element node with pointer to previous and next element in the list. - struct SKListNode - { - SKListNode(const T& e) : Next(0), Prev(0), Element(e) {} - - SKListNode* Next; - SKListNode* Prev; - T Element; - }; - -public: - class ConstIterator; - - //! List iterator. - class Iterator - { - public: - Iterator() : Current(0) {} - - Iterator& operator ++() { Current = Current->Next; return *this; } - Iterator& operator --() { Current = Current->Prev; return *this; } - Iterator operator ++(s32) { Iterator tmp = *this; Current = Current->Next; return tmp; } - Iterator operator --(s32) { Iterator tmp = *this; Current = Current->Prev; return tmp; } - - Iterator& operator +=(s32 num) - { - if(num > 0) - { - while (num-- && this->Current != 0) ++(*this); - } - else - { - while(num++ && this->Current != 0) --(*this); - } - return *this; - } - - Iterator operator + (s32 num) const { Iterator tmp = *this; return tmp += num; } - Iterator& operator -=(s32 num) const { return (*this)+=(-num); } - Iterator operator - (s32 num) const { return (*this)+ (-num); } - - bool operator ==(const Iterator& other) const { return Current == other.Current; } - bool operator !=(const Iterator& other) const { return Current != other.Current; } - bool operator ==(const ConstIterator& other) const { return Current == other.Current; } - bool operator !=(const ConstIterator& other) const { return Current != other.Current; } - - #if defined (_MSC_VER) && (_MSC_VER < 1300) - #pragma warning(disable:4284) // infix notation problem when using iterator operator -> - #endif - - T & operator * () { return Current->Element; } - T * operator ->() { return &Current->Element; } - - private: - Iterator(SKListNode* begin) : Current(begin) {} - - SKListNode* Current; - - friend class list<T>; - }; - - //! List iterator for const access. - class ConstIterator - { - public: - - ConstIterator() : Current(0) {} - - ConstIterator& operator ++() { Current = Current->Next; return *this; } - ConstIterator& operator --() { Current = Current->Prev; return *this; } - ConstIterator operator ++(s32) { ConstIterator tmp = *this; Current = Current->Next; return tmp; } - ConstIterator operator --(s32) { ConstIterator tmp = *this; Current = Current->Prev; return tmp; } - - ConstIterator& operator +=(s32 num) - { - if(num > 0) - { - while(num-- && this->Current != 0) ++(*this); - } - else - { - while(num++ && this->Current != 0) --(*this); - } - return *this; - } - - ConstIterator operator + (s32 num) const { ConstIterator tmp = *this; return tmp += num; } - ConstIterator& operator -=(s32 num) const { return (*this)+=(-num); } - ConstIterator operator - (s32 num) const { return (*this)+ (-num); } - - bool operator ==(const ConstIterator& other) const { return Current == other.Current; } - bool operator !=(const ConstIterator& other) const { return Current != other.Current; } - bool operator ==(const Iterator& other) const { return Current == other.Current; } - bool operator !=(const Iterator& other) const { return Current != other.Current; } - - const T & operator * () { return Current->Element; } - const T * operator ->() { return &Current->Element; } - - ConstIterator & operator =(const Iterator & iterator) { Current = iterator.Current; return *this; } - - private: - ConstIterator(SKListNode* begin) : Current(begin) {} - - SKListNode* Current; - - friend class Iterator; - friend class list<T>; - }; - - //! Default constructor for empty list. - list() - : First(0), Last(0), Size(0) {} - - - //! Copy constructor. - list(const list<T>& other) : First(0), Last(0), Size(0) - { - *this = other; - } - - - //! Destructor - ~list() - { - clear(); - } - - - //! Assignment operator - void operator=(const list<T>& other) - { - if(&other == this) - { - return; - } - - clear(); - - SKListNode* node = other.First; - while(node) - { - push_back(node->Element); - node = node->Next; - } - } - - - //! Returns amount of elements in list. - /** \return Amount of elements in the list. */ - u32 getSize() const - { - return Size; - } - - - //! Clears the list, deletes all elements in the list. - /** All existing iterators of this list will be invalid. */ - void clear() - { - while(First) - { - SKListNode * next = First->Next; - allocator.destruct(First); - allocator.deallocate(First); - First = next; - } - - //First = 0; handled by loop - Last = 0; - Size = 0; - } - - - //! Checks for empty list. - /** \return True if the list is empty and false if not. */ - bool empty() const - { - return (First == 0); - } - - - //! Adds an element at the end of the list. - /** \param element Element to add to the list. */ - void push_back(const T& element) - { - SKListNode* node = allocator.allocate(1); - allocator.construct(node, element); - - ++Size; - - if (First == 0) - First = node; - - node->Prev = Last; - - if (Last != 0) - Last->Next = node; - - Last = node; - } - - - //! Adds an element at the begin of the list. - /** \param element: Element to add to the list. */ - void push_front(const T& element) - { - SKListNode* node = allocator.allocate(1); - allocator.construct(node, element); - - ++Size; - - if (First == 0) - { - Last = node; - First = node; - } - else - { - node->Next = First; - First->Prev = node; - First = node; - } - } - - - //! Gets first node. - /** \return A list iterator pointing to the beginning of the list. */ - Iterator begin() - { - return Iterator(First); - } - - - //! Gets first node. - /** \return A const list iterator pointing to the beginning of the list. */ - ConstIterator begin() const - { - return ConstIterator(First); - } - - - //! Gets end node. - /** \return List iterator pointing to null. */ - Iterator end() - { - return Iterator(0); - } - - - //! Gets end node. - /** \return Const list iterator pointing to null. */ - ConstIterator end() const - { - return ConstIterator(0); - } - - - //! Gets last element. - /** \return List iterator pointing to the last element of the list. */ - Iterator getLast() - { - return Iterator(Last); - } - - - //! Gets last element. - /** \return Const list iterator pointing to the last element of the list. */ - ConstIterator getLast() const - { - return ConstIterator(Last); - } - - - //! Inserts an element after an element. - /** \param it Iterator pointing to element after which the new element - should be inserted. - \param element The new element to be inserted into the list. - */ - void insert_after(const Iterator& it, const T& element) - { - SKListNode* node = allocator.allocate(1); - allocator.construct(node, element); - - node->Next = it.Current->Next; - - if (it.Current->Next) - it.Current->Next->Prev = node; - - node->Prev = it.Current; - it.Current->Next = node; - ++Size; - - if (it.Current == Last) - Last = node; - } - - - //! Inserts an element before an element. - /** \param it Iterator pointing to element before which the new element - should be inserted. - \param element The new element to be inserted into the list. - */ - void insert_before(const Iterator& it, const T& element) - { - SKListNode* node = allocator.allocate(1); - allocator.construct(node, element); - - node->Prev = it.Current->Prev; - - if (it.Current->Prev) - it.Current->Prev->Next = node; - - node->Next = it.Current; - it.Current->Prev = node; - ++Size; - - if (it.Current == First) - First = node; - } - - - //! Erases an element. - /** \param it Iterator pointing to the element which shall be erased. - \return Iterator pointing to next element. */ - Iterator erase(Iterator& it) - { - // suggest changing this to a const Iterator& and - // working around line: it.Current = 0 (possibly with a mutable, or just let it be garbage?) - - Iterator returnIterator(it); - ++returnIterator; - - if(it.Current == First) - { - First = it.Current->Next; - } - else - { - it.Current->Prev->Next = it.Current->Next; - } - - if(it.Current == Last) - { - Last = it.Current->Prev; - } - else - { - it.Current->Next->Prev = it.Current->Prev; - } - - allocator.destruct(it.Current); - allocator.deallocate(it.Current); - it.Current = 0; - --Size; - - return returnIterator; - } - -private: - - irrAllocator<SKListNode> allocator; - SKListNode* First; - SKListNode* Last; - u32 Size; - -}; - - -} // end namespace core -}// end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/irrMap.h b/irrlicht-1.6/include/irrMap.h deleted file mode 100644 index 778814b82..000000000 --- a/irrlicht-1.6/include/irrMap.h +++ /dev/null @@ -1,945 +0,0 @@ -// Copyright (C) 2006-2009 by Kat'Oun -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_MAP_H_INCLUDED__ -#define __IRR_MAP_H_INCLUDED__ - -#include "irrTypes.h" - -namespace irr -{ -namespace core -{ - -//! map template for associative arrays using a red-black tree -template <class KeyType, class ValueType> -class map -{ - //! red/black tree for map - template <class KeyTypeRB, class ValueTypeRB> - class RBTree - { - public: - - RBTree(const KeyTypeRB& k, const ValueTypeRB& v) - : LeftChild(0), RightChild(0), Parent(0), Key(k), - Value(v), IsRed(true) {} - - void setLeftChild(RBTree* p) - { - LeftChild=p; - if (p) - p->setParent(this); - } - - void setRightChild(RBTree* p) - { - RightChild=p; - if (p) - p->setParent(this); - } - - void setParent(RBTree* p) { Parent=p; } - - void setValue(const ValueTypeRB& v) { Value = v; } - - void setRed() { IsRed = true; } - void setBlack() { IsRed = false; } - - RBTree* getLeftChild() const { return LeftChild; } - RBTree* getRightChild() const { return RightChild; } - RBTree* getParent() const { return Parent; } - - ValueTypeRB getValue() const - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return Value; - } - - KeyTypeRB getKey() const - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return Key; - } - - bool isRoot() const - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return Parent==0; - } - - bool isLeftChild() const - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return (Parent != 0) && (Parent->getLeftChild()==this); - } - - bool isRightChild() const - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return (Parent!=0) && (Parent->getRightChild()==this); - } - - bool isLeaf() const - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return (LeftChild==0) && (RightChild==0); - } - - unsigned int getLevel() const - { - if (isRoot()) - return 1; - else - return getParent()->getLevel() + 1; - } - - - bool isRed() const - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return IsRed; - } - - bool isBlack() const - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return !IsRed; - } - - private: - RBTree(); - - RBTree* LeftChild; - RBTree* RightChild; - - RBTree* Parent; - - KeyTypeRB Key; - ValueTypeRB Value; - - bool IsRed; - }; // RBTree - - public: - - typedef RBTree<KeyType,ValueType> Node; - - //! Normal Iterator - class Iterator - { - public: - - Iterator() : Root(0), Cur(0) {} - - // Constructor(Node*) - Iterator(Node* root) : Root(root) - { - reset(); - } - - // Copy constructor - Iterator(const Iterator& src) : Root(src.Root), Cur(src.Cur) {} - - void reset(bool atLowest=true) - { - if (atLowest) - Cur = getMin(Root); - else - Cur = getMax(Root); - } - - bool atEnd() const - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return Cur==0; - } - - Node* getNode() - { - return Cur; - } - - Iterator& operator=(const Iterator& src) - { - Root = src.Root; - Cur = src.Cur; - return (*this); - } - - void operator++(int) - { - inc(); - } - - void operator--(int) - { - dec(); - } - - - Node* operator -> () - { - return getNode(); - } - - Node& operator* () - { - _IRR_DEBUG_BREAK_IF(atEnd()) // access violation - - return *Cur; - } - - private: - - Node* getMin(Node* n) - { - while(n && n->getLeftChild()) - n = n->getLeftChild(); - return n; - } - - Node* getMax(Node* n) - { - while(n && n->getRightChild()) - n = n->getRightChild(); - return n; - } - - void inc() - { - // Already at end? - if (Cur==0) - return; - - if (Cur->getRightChild()) - { - // If current node has a right child, the next higher node is the - // node with lowest key beneath the right child. - Cur = getMin(Cur->getRightChild()); - } - else if (Cur->isLeftChild()) - { - // No right child? Well if current node is a left child then - // the next higher node is the parent - Cur = Cur->getParent(); - } - else - { - // Current node neither is left child nor has a right child. - // Ie it is either right child or root - // The next higher node is the parent of the first non-right - // child (ie either a left child or the root) up in the - // hierarchy. Root's parent is 0. - while(Cur->isRightChild()) - Cur = Cur->getParent(); - Cur = Cur->getParent(); - } - } - - void dec() - { - // Already at end? - if (Cur==0) - return; - - if (Cur->getLeftChild()) - { - // If current node has a left child, the next lower node is the - // node with highest key beneath the left child. - Cur = getMax(Cur->getLeftChild()); - } - else if (Cur->isRightChild()) - { - // No left child? Well if current node is a right child then - // the next lower node is the parent - Cur = Cur->getParent(); - } - else - { - // Current node neither is right child nor has a left child. - // Ie it is either left child or root - // The next higher node is the parent of the first non-left - // child (ie either a right child or the root) up in the - // hierarchy. Root's parent is 0. - - while(Cur->isLeftChild()) - Cur = Cur->getParent(); - Cur = Cur->getParent(); - } - } - - Node* Root; - Node* Cur; - }; // Iterator - - - - //! Parent First Iterator. - /** Traverses the tree from top to bottom. Typical usage is - when storing the tree structure, because when reading it - later (and inserting elements) the tree structure will - be the same. */ - class ParentFirstIterator - { - public: - - - ParentFirstIterator() : Root(0), Cur(0) - { - } - - - explicit ParentFirstIterator(Node* root) : Root(root), Cur(0) - { - reset(); - } - - void reset() - { - Cur = Root; - } - - - bool atEnd() const - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return Cur==0; - } - - Node* getNode() - { - return Cur; - } - - - ParentFirstIterator& operator=(const ParentFirstIterator& src) - { - Root = src.Root; - Cur = src.Cur; - return (*this); - } - - - void operator++(int) - { - inc(); - } - - - Node* operator -> () - { - return getNode(); - } - - Node& operator* () - { - _IRR_DEBUG_BREAK_IF(atEnd()) // access violation - - return *getNode(); - } - - private: - - void inc() - { - // Already at end? - if (Cur==0) - return; - - // First we try down to the left - if (Cur->getLeftChild()) - { - Cur = Cur->getLeftChild(); - } - else if (Cur->getRightChild()) - { - // No left child? The we go down to the right. - Cur = Cur->getRightChild(); - } - else - { - // No children? Move up in the hierarcy until - // we either reach 0 (and are finished) or - // find a right uncle. - while (Cur!=0) - { - // But if parent is left child and has a right "uncle" the parent - // has already been processed but the uncle hasn't. Move to - // the uncle. - if (Cur->isLeftChild() && Cur->getParent()->getRightChild()) - { - Cur = Cur->getParent()->getRightChild(); - return; - } - Cur = Cur->getParent(); - } - } - } - - Node* Root; - Node* Cur; - - }; // ParentFirstIterator - - - //! Parent Last Iterator - /** Traverse the tree from bottom to top. - Typical usage is when deleting all elements in the tree - because you must delete the children before you delete - their parent. */ - class ParentLastIterator - { - public: - - ParentLastIterator() : Root(0), Cur(0) {} - - explicit ParentLastIterator(Node* root) : Root(root), Cur(0) - { - reset(); - } - - void reset() - { - Cur = getMin(Root); - } - - bool atEnd() const - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return Cur==0; - } - - Node* getNode() - { - return Cur; - } - - ParentLastIterator& operator=(const ParentLastIterator& src) - { - Root = src.Root; - Cur = src.Cur; - return (*this); - } - - void operator++(int) - { - inc(); - } - - Node* operator -> () - { - return getNode(); - } - - Node& operator* () - { - _IRR_DEBUG_BREAK_IF(atEnd()) // access violation - - return *getNode(); - } - private: - - Node* getMin(Node* n) - { - while(n!=0 && (n->getLeftChild()!=0 || n->getRightChild()!=0)) - { - if (n->getLeftChild()) - n = n->getLeftChild(); - else - n = n->getRightChild(); - } - return n; - } - - void inc() - { - // Already at end? - if (Cur==0) - return; - - // Note: Starting point is the node as far down to the left as possible. - - // If current node has an uncle to the right, go to the - // node as far down to the left from the uncle as possible - // else just go up a level to the parent. - if (Cur->isLeftChild() && Cur->getParent()->getRightChild()) - { - Cur = getMin(Cur->getParent()->getRightChild()); - } - else - Cur = Cur->getParent(); - } - - Node* Root; - Node* Cur; - }; // ParentLastIterator - - - // AccessClass is a temporary class used with the [] operator. - // It makes it possible to have different behavior in situations like: - // myTree["Foo"] = 32; - // If "Foo" already exists update its value else insert a new element. - // int i = myTree["Foo"] - // If "Foo" exists return its value. - class AccessClass - { - // Let map be the only one who can instantiate this class. - friend class map<KeyType, ValueType>; - - public: - - // Assignment operator. Handles the myTree["Foo"] = 32; situation - void operator=(const ValueType& value) - { - // Just use the Set method, it handles already exist/not exist situation - Tree.set(Key,value); - } - - // ValueType operator - operator ValueType() - { - Node* node = Tree.find(Key); - - // Not found - _IRR_DEBUG_BREAK_IF(node==0) // access violation - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return node->getValue(); - } - - private: - - AccessClass(map& tree, const KeyType& key) : Tree(tree), Key(key) {} - - AccessClass(); - - map& Tree; - const KeyType& Key; - }; // AccessClass - - - // Constructor. - map() : Root(0), Size(0) {} - - // Destructor - ~map() - { - clear(); - } - - //------------------------------ - // Public Commands - //------------------------------ - - //! Inserts a new node into the tree - /** \param keyNew: the index for this value - \param v: the value to insert - \return True if successful, false if it fails (already exists) */ - bool insert(const KeyType& keyNew, const ValueType& v) - { - // First insert node the "usual" way (no fancy balance logic yet) - Node* newNode = new Node(keyNew,v); - if (!insert(newNode)) - { - delete newNode; - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; - } - - // Then attend a balancing party - while (!newNode->isRoot() && (newNode->getParent()->isRed())) - { - if (newNode->getParent()->isLeftChild()) - { - // If newNode is a left child, get its right 'uncle' - Node* newNodesUncle = newNode->getParent()->getParent()->getRightChild(); - if ( newNodesUncle!=0 && newNodesUncle->isRed()) - { - // case 1 - change the colours - newNode->getParent()->setBlack(); - newNodesUncle->setBlack(); - newNode->getParent()->getParent()->setRed(); - // Move newNode up the tree - newNode = newNode->getParent()->getParent(); - } - else - { - // newNodesUncle is a black node - if ( newNode->isRightChild()) - { - // and newNode is to the right - // case 2 - move newNode up and rotate - newNode = newNode->getParent(); - rotateLeft(newNode); - } - // case 3 - newNode->getParent()->setBlack(); - newNode->getParent()->getParent()->setRed(); - rotateRight(newNode->getParent()->getParent()); - } - } - else - { - // If newNode is a right child, get its left 'uncle' - Node* newNodesUncle = newNode->getParent()->getParent()->getLeftChild(); - if ( newNodesUncle!=0 && newNodesUncle->isRed()) - { - // case 1 - change the colours - newNode->getParent()->setBlack(); - newNodesUncle->setBlack(); - newNode->getParent()->getParent()->setRed(); - // Move newNode up the tree - newNode = newNode->getParent()->getParent(); - } - else - { - // newNodesUncle is a black node - if (newNode->isLeftChild()) - { - // and newNode is to the left - // case 2 - move newNode up and rotate - newNode = newNode->getParent(); - rotateRight(newNode); - } - // case 3 - newNode->getParent()->setBlack(); - newNode->getParent()->getParent()->setRed(); - rotateLeft(newNode->getParent()->getParent()); - } - - } - } - // Color the root black - Root->setBlack(); - return true; - } - - //! Replaces the value if the key already exists, otherwise inserts a new element. - /** \param k The index for this value - \param v The new value of */ - void set(const KeyType& k, const ValueType& v) - { - Node* p = find(k); - if (p) - p->setValue(v); - else - insert(k,v); - } - - //! Removes a node from the tree and returns it. - /** The returned node must be deleted by the user - \param k the key to remove - \return A pointer to the node, or 0 if not found */ - Node* delink(const KeyType& k) - { - Node* p = find(k); - if (p == 0) - return 0; - - // Rotate p down to the left until it has no right child, will get there - // sooner or later. - while(p->getRightChild()) - { - // "Pull up my right child and let it knock me down to the left" - rotateLeft(p); - } - // p now has no right child but might have a left child - Node* left = p->getLeftChild(); - - // Let p's parent point to p's child instead of point to p - if (p->isLeftChild()) - p->getParent()->setLeftChild(left); - - else if (p->isRightChild()) - p->getParent()->setRightChild(left); - - else - { - // p has no parent => p is the root. - // Let the left child be the new root. - setRoot(left); - } - - // p is now gone from the tree in the sense that - // no one is pointing at it, so return it. - - --Size; - return p; - } - - //! Removes a node from the tree and deletes it. - /** \return True if the node was found and deleted */ - bool remove(const KeyType& k) - { - Node* p = find(k); - if (p == 0) - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; - } - - // Rotate p down to the left until it has no right child, will get there - // sooner or later. - while(p->getRightChild()) - { - // "Pull up my right child and let it knock me down to the left" - rotateLeft(p); - } - // p now has no right child but might have a left child - Node* left = p->getLeftChild(); - - // Let p's parent point to p's child instead of point to p - if (p->isLeftChild()) - p->getParent()->setLeftChild(left); - - else if (p->isRightChild()) - p->getParent()->setRightChild(left); - - else - { - // p has no parent => p is the root. - // Let the left child be the new root. - setRoot(left); - } - - // p is now gone from the tree in the sense that - // no one is pointing at it. Let's get rid of it. - delete p; - - --Size; - return true; - } - - //! Clear the entire tree - void clear() - { - ParentLastIterator i(getParentLastIterator()); - - while(!i.atEnd()) - { - Node* p = i.getNode(); - i++; // Increment it before it is deleted - // else iterator will get quite confused. - delete p; - } - Root = 0; - Size= 0; - } - - //! Is the tree empty? - //! \return Returns true if empty, false if not - bool isEmpty() const - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return Root == 0; - } - - //! Search for a node with the specified key. - //! \param keyToFind: The key to find - //! \return Returns 0 if node couldn't be found. - Node* find(const KeyType& keyToFind) const - { - Node* pNode = Root; - - while(pNode!=0) - { - KeyType key(pNode->getKey()); - - if (keyToFind == key) - return pNode; - else if (keyToFind < key) - pNode = pNode->getLeftChild(); - else //keyToFind > key - pNode = pNode->getRightChild(); - } - - return 0; - } - - //! Gets the root element. - //! \return Returns a pointer to the root node, or - //! 0 if the tree is empty. - Node* getRoot() const - { - return Root; - } - - //! Returns the number of nodes in the tree. - u32 size() const - { - return Size; - } - - //------------------------------ - // Public Iterators - //------------------------------ - - //! Returns an iterator - Iterator getIterator() - { - Iterator it(getRoot()); - return it; - } - //! Returns a ParentFirstIterator. - //! Traverses the tree from top to bottom. Typical usage is - //! when storing the tree structure, because when reading it - //! later (and inserting elements) the tree structure will - //! be the same. - ParentFirstIterator getParentFirstIterator() - { - ParentFirstIterator it(getRoot()); - return it; - } - //! Returns a ParentLastIterator to traverse the tree from - //! bottom to top. - //! Typical usage is when deleting all elements in the tree - //! because you must delete the children before you delete - //! their parent. - ParentLastIterator getParentLastIterator() - { - ParentLastIterator it(getRoot()); - return it; - } - - //------------------------------ - // Public Operators - //------------------------------ - - //! operator [] for access to elements - /** for example myMap["key"] */ - AccessClass operator[](const KeyType& k) - { - return AccessClass(*this, k); - } - private: - - //------------------------------ - // Disabled methods - //------------------------------ - // Copy constructor and assignment operator deliberately - // defined but not implemented. The tree should never be - // copied, pass along references to it instead. - explicit map(const map& src); - map& operator = (const map& src); - - //! Set node as new root. - /** The node will be set to black, otherwise core dumps may arise - (patch provided by rogerborg). - \param newRoot Node which will be the new root - */ - void setRoot(Node* newRoot) - { - Root = newRoot; - if (Root != 0) - { - Root->setParent(0); - Root->setBlack(); - } - } - - //! Insert a node into the tree without using any fancy balancing logic. - /** \return false if that key already exist in the tree. */ - bool insert(Node* newNode) - { - bool result=true; // Assume success - - if (Root==0) - { - setRoot(newNode); - Size = 1; - } - else - { - Node* pNode = Root; - KeyType keyNew = newNode->getKey(); - while (pNode) - { - KeyType key(pNode->getKey()); - - if (keyNew == key) - { - result = false; - pNode = 0; - } - else if (keyNew < key) - { - if (pNode->getLeftChild() == 0) - { - pNode->setLeftChild(newNode); - pNode = 0; - } - else - pNode = pNode->getLeftChild(); - } - else // keyNew > key - { - if (pNode->getRightChild()==0) - { - pNode->setRightChild(newNode); - pNode = 0; - } - else - { - pNode = pNode->getRightChild(); - } - } - } - - if (result) - ++Size; - } - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return result; - } - - //! Rotate left. - //! Pull up node's right child and let it knock node down to the left - void rotateLeft(Node* p) - { - Node* right = p->getRightChild(); - - p->setRightChild(right->getLeftChild()); - - if (p->isLeftChild()) - p->getParent()->setLeftChild(right); - else if (p->isRightChild()) - p->getParent()->setRightChild(right); - else - setRoot(right); - - right->setLeftChild(p); - } - - //! Rotate right. - //! Pull up node's left child and let it knock node down to the right - void rotateRight(Node* p) - { - Node* left = p->getLeftChild(); - - p->setLeftChild(left->getRightChild()); - - if (p->isLeftChild()) - p->getParent()->setLeftChild(left); - else if (p->isRightChild()) - p->getParent()->setRightChild(left); - else - setRoot(left); - - left->setRightChild(p); - } - - //------------------------------ - // Private Members - //------------------------------ - Node* Root; // The top node. 0 if empty. - u32 Size; // Number of nodes in the tree -}; - -} // end namespace core -} // end namespace irr - -#endif // __IRR_MAP_H_INCLUDED__ - diff --git a/irrlicht-1.6/include/irrMath.h b/irrlicht-1.6/include/irrMath.h deleted file mode 100644 index de0c62b33..000000000 --- a/irrlicht-1.6/include/irrMath.h +++ /dev/null @@ -1,648 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_MATH_H_INCLUDED__ -#define __IRR_MATH_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#include "irrTypes.h" -#include <math.h> -#include <float.h> -#include <stdlib.h> // for abs() etc. -#include <limits.h> // For INT_MAX / UINT_MAX - -#if defined(_IRR_SOLARIS_PLATFORM_) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) || defined (_WIN32_WCE) - #define sqrtf(X) (f32)sqrt((f64)(X)) - #define sinf(X) (f32)sin((f64)(X)) - #define cosf(X) (f32)cos((f64)(X)) - #define asinf(X) (f32)asin((f64)(X)) - #define acosf(X) (f32)acos((f64)(X)) - #define atan2f(X,Y) (f32)atan2((f64)(X),(f64)(Y)) - #define ceilf(X) (f32)ceil((f64)(X)) - #define floorf(X) (f32)floor((f64)(X)) - #define powf(X,Y) (f32)pow((f64)(X),(f64)(Y)) - #define fmodf(X,Y) (f32)fmod((f64)(X),(f64)(Y)) - #define fabsf(X) (f32)fabs((f64)(X)) - #define logf(X) (f32)log((f64)(X)) -#endif - -#ifndef FLT_MAX -#define FLT_MAX 3.402823466E+38F -#endif - -namespace irr -{ -namespace core -{ - - //! Rounding error constant often used when comparing f32 values. - - const s32 ROUNDING_ERROR_S32 = 1; - const f32 ROUNDING_ERROR_f32 = 0.000001f; - const f64 ROUNDING_ERROR_f64 = 0.00000001; - -#ifdef PI // make sure we don't collide with a define -#undef PI -#endif - //! Constant for PI. - const f32 PI = 3.14159265359f; - - //! Constant for reciprocal of PI. - const f32 RECIPROCAL_PI = 1.0f/PI; - - //! Constant for half of PI. - const f32 HALF_PI = PI/2.0f; - -#ifdef PI64 // make sure we don't collide with a define -#undef PI64 -#endif - //! Constant for 64bit PI. - const f64 PI64 = 3.1415926535897932384626433832795028841971693993751; - - //! Constant for 64bit reciprocal of PI. - const f64 RECIPROCAL_PI64 = 1.0/PI64; - - //! 32bit Constant for converting from degrees to radians - const f32 DEGTORAD = PI / 180.0f; - - //! 32bit constant for converting from radians to degrees (formally known as GRAD_PI) - const f32 RADTODEG = 180.0f / PI; - - //! 64bit constant for converting from degrees to radians (formally known as GRAD_PI2) - const f64 DEGTORAD64 = PI64 / 180.0; - - //! 64bit constant for converting from radians to degrees - const f64 RADTODEG64 = 180.0 / PI64; - - //! Utility function to convert a radian value to degrees - /** Provided as it can be clearer to write radToDeg(X) than RADTODEG * X - \param radians The radians value to convert to degrees. - */ - inline f32 radToDeg(f32 radians) - { - return RADTODEG * radians; - } - - //! Utility function to convert a radian value to degrees - /** Provided as it can be clearer to write radToDeg(X) than RADTODEG * X - \param radians The radians value to convert to degrees. - */ - inline f64 radToDeg(f64 radians) - { - return RADTODEG64 * radians; - } - - //! Utility function to convert a degrees value to radians - /** Provided as it can be clearer to write degToRad(X) than DEGTORAD * X - \param degrees The degrees value to convert to radians. - */ - inline f32 degToRad(f32 degrees) - { - return DEGTORAD * degrees; - } - - //! Utility function to convert a degrees value to radians - /** Provided as it can be clearer to write degToRad(X) than DEGTORAD * X - \param degrees The degrees value to convert to radians. - */ - inline f64 degToRad(f64 degrees) - { - return DEGTORAD64 * degrees; - } - - //! returns minimum of two values. Own implementation to get rid of the STL (VS6 problems) - template<class T> - inline const T& min_(const T& a, const T& b) - { - return a < b ? a : b; - } - - //! returns minimum of three values. Own implementation to get rid of the STL (VS6 problems) - template<class T> - inline const T& min_(const T& a, const T& b, const T& c) - { - return a < b ? min_(a, c) : min_(b, c); - } - - //! returns maximum of two values. Own implementation to get rid of the STL (VS6 problems) - template<class T> - inline const T& max_(const T& a, const T& b) - { - return a < b ? b : a; - } - - //! returns maximum of three values. Own implementation to get rid of the STL (VS6 problems) - template<class T> - inline const T& max_(const T& a, const T& b, const T& c) - { - return a < b ? max_(b, c) : max_(a, c); - } - - //! returns abs of two values. Own implementation to get rid of STL (VS6 problems) - template<class T> - inline T abs_(const T& a) - { - return a < (T)0 ? -a : a; - } - - //! returns linear interpolation of a and b with ratio t - //! \return: a if t==0, b if t==1, and the linear interpolation else - template<class T> - inline T lerp(const T& a, const T& b, const f32 t) - { - return (T)(a*(1.f-t)) + (b*t); - } - - //! clamps a value between low and high - template <class T> - inline const T clamp (const T& value, const T& low, const T& high) - { - return min_ (max_(value,low), high); - } - - //! returns if a equals b, taking possible rounding errors into account - inline bool equals(const f64 a, const f64 b, const f64 tolerance = ROUNDING_ERROR_f64) - { - return (a + tolerance >= b) && (a - tolerance <= b); - } - - //! returns if a equals b, taking possible rounding errors into account - inline bool equals(const f32 a, const f32 b, const f32 tolerance = ROUNDING_ERROR_f32) - { - return (a + tolerance >= b) && (a - tolerance <= b); - } -#if 0 - //! returns if a equals b, not using any rounding tolerance - inline bool equals(const s32 a, const s32 b) - { - return (a == b); - } - - //! returns if a equals b, not using any rounding tolerance - inline bool equals(const u32 a, const u32 b) - { - return (a == b); - } -#endif - //! returns if a equals b, taking an explicit rounding tolerance into account - inline bool equals(const s32 a, const s32 b, const s32 tolerance = ROUNDING_ERROR_S32) - { - return (a + tolerance >= b) && (a - tolerance <= b); - } - - //! returns if a equals b, taking an explicit rounding tolerance into account - inline bool equals(const u32 a, const u32 b, const s32 tolerance = ROUNDING_ERROR_S32) - { - return (a + tolerance >= b) && (a - tolerance <= b); - } - - - //! returns if a equals zero, taking rounding errors into account - inline bool iszero(const f64 a, const f64 tolerance = ROUNDING_ERROR_f64) - { - return fabs(a) <= tolerance; - } - - //! returns if a equals zero, taking rounding errors into account - inline bool iszero(const f32 a, const f32 tolerance = ROUNDING_ERROR_f32) - { - return fabsf(a) <= tolerance; - } - - //! returns if a equals not zero, taking rounding errors into account - inline bool isnotzero(const f32 a, const f32 tolerance = ROUNDING_ERROR_f32) - { - return fabsf(a) > tolerance; - } - - //! returns if a equals zero, taking rounding errors into account - inline bool iszero(const s32 a, const s32 tolerance = 0) - { - return ( a & 0x7ffffff ) <= tolerance; - } - - //! returns if a equals zero, taking rounding errors into account - inline bool iszero(const u32 a, const u32 tolerance = 0) - { - return a <= tolerance; - } - - inline s32 s32_min(s32 a, s32 b) - { - const s32 mask = (a - b) >> 31; - return (a & mask) | (b & ~mask); - } - - inline s32 s32_max(s32 a, s32 b) - { - const s32 mask = (a - b) >> 31; - return (b & mask) | (a & ~mask); - } - - inline s32 s32_clamp (s32 value, s32 low, s32 high) - { - return s32_min(s32_max(value,low), high); - } - - /* - float IEEE-754 bit represenation - - 0 0x00000000 - 1.0 0x3f800000 - 0.5 0x3f000000 - 3 0x40400000 - +inf 0x7f800000 - -inf 0xff800000 - +NaN 0x7fc00000 or 0x7ff00000 - in general: number = (sign ? -1:1) * 2^(exponent) * 1.(mantissa bits) - */ - - typedef union { u32 u; s32 s; f32 f; } inttofloat; - - #define F32_AS_S32(f) (*((s32 *) &(f))) - #define F32_AS_U32(f) (*((u32 *) &(f))) - #define F32_AS_U32_POINTER(f) ( ((u32 *) &(f))) - - #define F32_VALUE_0 0x00000000 - #define F32_VALUE_1 0x3f800000 - #define F32_SIGN_BIT 0x80000000U - #define F32_EXPON_MANTISSA 0x7FFFFFFFU - - //! code is taken from IceFPU - //! Integer representation of a floating-point value. -#ifdef IRRLICHT_FAST_MATH - #define IR(x) ((u32&)(x)) -#else - inline u32 IR(f32 x) {inttofloat tmp; tmp.f=x; return tmp.u;} -#endif - - //! Absolute integer representation of a floating-point value - #define AIR(x) (IR(x)&0x7fffffff) - - //! Floating-point representation of an integer value. -#ifdef IRRLICHT_FAST_MATH - #define FR(x) ((f32&)(x)) -#else - inline f32 FR(u32 x) {inttofloat tmp; tmp.u=x; return tmp.f;} - inline f32 FR(s32 x) {inttofloat tmp; tmp.s=x; return tmp.f;} -#endif - - //! integer representation of 1.0 - #define IEEE_1_0 0x3f800000 - //! integer representation of 255.0 - #define IEEE_255_0 0x437f0000 - -#ifdef IRRLICHT_FAST_MATH - #define F32_LOWER_0(f) (F32_AS_U32(f) > F32_SIGN_BIT) - #define F32_LOWER_EQUAL_0(f) (F32_AS_S32(f) <= F32_VALUE_0) - #define F32_GREATER_0(f) (F32_AS_S32(f) > F32_VALUE_0) - #define F32_GREATER_EQUAL_0(f) (F32_AS_U32(f) <= F32_SIGN_BIT) - #define F32_EQUAL_1(f) (F32_AS_U32(f) == F32_VALUE_1) - #define F32_EQUAL_0(f) ( (F32_AS_U32(f) & F32_EXPON_MANTISSA ) == F32_VALUE_0) - - // only same sign - #define F32_A_GREATER_B(a,b) (F32_AS_S32((a)) > F32_AS_S32((b))) - -#else - - #define F32_LOWER_0(n) ((n) < 0.0f) - #define F32_LOWER_EQUAL_0(n) ((n) <= 0.0f) - #define F32_GREATER_0(n) ((n) > 0.0f) - #define F32_GREATER_EQUAL_0(n) ((n) >= 0.0f) - #define F32_EQUAL_1(n) ((n) == 1.0f) - #define F32_EQUAL_0(n) ((n) == 0.0f) - #define F32_A_GREATER_B(a,b) ((a) > (b)) -#endif - - -#ifndef REALINLINE - #ifdef _MSC_VER - #define REALINLINE __forceinline - #else - #define REALINLINE inline - #endif -#endif - -#if defined(__BORLANDC__) || defined (__BCPLUSPLUS__) - - // 8-bit bools in borland builder - - //! conditional set based on mask and arithmetic shift - REALINLINE u32 if_c_a_else_b ( const c8 condition, const u32 a, const u32 b ) - { - return ( ( -condition >> 7 ) & ( a ^ b ) ) ^ b; - } - - //! conditional set based on mask and arithmetic shift - REALINLINE u32 if_c_a_else_0 ( const c8 condition, const u32 a ) - { - return ( -condition >> 31 ) & a; - } -#else - - //! conditional set based on mask and arithmetic shift - REALINLINE u32 if_c_a_else_b ( const s32 condition, const u32 a, const u32 b ) - { - return ( ( -condition >> 31 ) & ( a ^ b ) ) ^ b; - } - - //! conditional set based on mask and arithmetic shift - REALINLINE u16 if_c_a_else_b ( const s16 condition, const u16 a, const u16 b ) - { - return ( ( -condition >> 15 ) & ( a ^ b ) ) ^ b; - } - - //! conditional set based on mask and arithmetic shift - REALINLINE u32 if_c_a_else_0 ( const s32 condition, const u32 a ) - { - return ( -condition >> 31 ) & a; - } -#endif - - /* - if (condition) state |= m; else state &= ~m; - */ - REALINLINE void setbit_cond ( u32 &state, s32 condition, u32 mask ) - { - // 0, or any postive to mask - //s32 conmask = -condition >> 31; - state ^= ( ( -condition >> 31 ) ^ state ) & mask; - } - - inline f32 round_( f32 x ) - { - return floorf( x + 0.5f ); - } - - REALINLINE void clearFPUException () - { -#ifdef IRRLICHT_FAST_MATH - return; -#ifdef feclearexcept - feclearexcept(FE_ALL_EXCEPT); -#elif defined(_MSC_VER) - __asm fnclex; -#elif defined(__GNUC__) && defined(__x86__) - __asm__ __volatile__ ("fclex \n\t"); -#else -# warn clearFPUException not supported. -#endif -#endif - } - - // calculate: sqrt ( x ) - REALINLINE f32 squareroot(const f32 f) - { - return sqrtf(f); - } - - // calculate: sqrt ( x ) - REALINLINE f64 squareroot(const f64 f) - { - return sqrt(f); - } - - // calculate: sqrt ( x ) - REALINLINE s32 squareroot(const s32 f) - { - return static_cast<s32>(squareroot(static_cast<f32>(f))); - } - - // calculate: 1 / sqrt ( x ) - REALINLINE f64 reciprocal_squareroot(const f64 x) - { - return 1.0 / sqrt(x); - } - - // calculate: 1 / sqrtf ( x ) - REALINLINE f32 reciprocal_squareroot(const f32 f) - { -#if defined ( IRRLICHT_FAST_MATH ) - #if defined(_MSC_VER) - // SSE reciprocal square root estimate, accurate to 12 significant - // bits of the mantissa - f32 recsqrt; - __asm rsqrtss xmm0, f // xmm0 = rsqrtss(f) - __asm movss recsqrt, xmm0 // return xmm0 - return recsqrt; - -/* - // comes from Nvidia - u32 tmp = (u32(IEEE_1_0 << 1) + IEEE_1_0 - *(u32*)&x) >> 1; - f32 y = *(f32*)&tmp; - return y * (1.47f - 0.47f * x * y * y); -*/ - #else - return 1.f / sqrtf(f); - #endif -#else // no fast math - return 1.f / sqrtf(f); -#endif - } - - // calculate: 1 / sqrtf( x ) - REALINLINE s32 reciprocal_squareroot(const s32 x) - { - return static_cast<s32>(reciprocal_squareroot(static_cast<f32>(x))); - } - - // calculate: 1 / x - REALINLINE f32 reciprocal( const f32 f ) - { -#if defined (IRRLICHT_FAST_MATH) - - // SSE Newton-Raphson reciprocal estimate, accurate to 23 significant - // bi ts of the mantissa - // One Newtown-Raphson Iteration: - // f(i+1) = 2 * rcpss(f) - f * rcpss(f) * rcpss(f) - f32 rec; - __asm rcpss xmm0, f // xmm0 = rcpss(f) - __asm movss xmm1, f // xmm1 = f - __asm mulss xmm1, xmm0 // xmm1 = f * rcpss(f) - __asm mulss xmm1, xmm0 // xmm2 = f * rcpss(f) * rcpss(f) - __asm addss xmm0, xmm0 // xmm0 = 2 * rcpss(f) - __asm subss xmm0, xmm1 // xmm0 = 2 * rcpss(f) - // - f * rcpss(f) * rcpss(f) - __asm movss rec, xmm0 // return xmm0 - return rec; - - - //! i do not divide through 0.. (fpu expection) - // instead set f to a high value to get a return value near zero.. - // -1000000000000.f.. is use minus to stay negative.. - // must test's here (plane.normal dot anything ) checks on <= 0.f - //u32 x = (-(AIR(f) != 0 ) >> 31 ) & ( IR(f) ^ 0xd368d4a5 ) ^ 0xd368d4a5; - //return 1.f / FR ( x ); - -#else // no fast math - return 1.f / f; -#endif - } - - // calculate: 1 / x - REALINLINE f64 reciprocal ( const f64 f ) - { - return 1.0 / f; - } - - - // calculate: 1 / x, low precision allowed - REALINLINE f32 reciprocal_approxim ( const f32 f ) - { -#if defined( IRRLICHT_FAST_MATH) - - // SSE Newton-Raphson reciprocal estimate, accurate to 23 significant - // bi ts of the mantissa - // One Newtown-Raphson Iteration: - // f(i+1) = 2 * rcpss(f) - f * rcpss(f) * rcpss(f) - f32 rec; - __asm rcpss xmm0, f // xmm0 = rcpss(f) - __asm movss xmm1, f // xmm1 = f - __asm mulss xmm1, xmm0 // xmm1 = f * rcpss(f) - __asm mulss xmm1, xmm0 // xmm2 = f * rcpss(f) * rcpss(f) - __asm addss xmm0, xmm0 // xmm0 = 2 * rcpss(f) - __asm subss xmm0, xmm1 // xmm0 = 2 * rcpss(f) - // - f * rcpss(f) * rcpss(f) - __asm movss rec, xmm0 // return xmm0 - return rec; - - -/* - // SSE reciprocal estimate, accurate to 12 significant bits of - f32 rec; - __asm rcpss xmm0, f // xmm0 = rcpss(f) - __asm movss rec , xmm0 // return xmm0 - return rec; -*/ -/* - register u32 x = 0x7F000000 - IR ( p ); - const f32 r = FR ( x ); - return r * (2.0f - p * r); -*/ -#else // no fast math - return 1.f / f; -#endif - } - - - REALINLINE s32 floor32(f32 x) - { -#ifdef IRRLICHT_FAST_MATH - const f32 h = 0.5f; - - s32 t; - -#if defined(_MSC_VER) - __asm - { - fld x - fsub h - fistp t - } -#elif defined(__GNUC__) - __asm__ __volatile__ ( - "fsub %2 \n\t" - "fistpl %0" - : "=m" (t) - : "t" (x), "f" (h) - : "st" - ); -#else -# warn IRRLICHT_FAST_MATH not supported. - return (s32) floorf ( x ); -#endif - return t; -#else // no fast math - return (s32) floorf ( x ); -#endif - } - - - REALINLINE s32 ceil32 ( f32 x ) - { -#ifdef IRRLICHT_FAST_MATH - const f32 h = 0.5f; - - s32 t; - -#if defined(_MSC_VER) - __asm - { - fld x - fadd h - fistp t - } -#elif defined(__GNUC__) - __asm__ __volatile__ ( - "fadd %2 \n\t" - "fistpl %0 \n\t" - : "=m"(t) - : "t"(x), "f"(h) - : "st" - ); -#else -# warn IRRLICHT_FAST_MATH not supported. - return (s32) ceilf ( x ); -#endif - return t; -#else // not fast math - return (s32) ceilf ( x ); -#endif - } - - - - REALINLINE s32 round32(f32 x) - { -#if defined(IRRLICHT_FAST_MATH) - s32 t; - -#if defined(_MSC_VER) - __asm - { - fld x - fistp t - } -#elif defined(__GNUC__) - __asm__ __volatile__ ( - "fistpl %0 \n\t" - : "=m"(t) - : "t"(x) - : "st" - ); -#else -# warn IRRLICHT_FAST_MATH not supported. - return (s32) round_(x); -#endif - return t; -#else // no fast math - return (s32) round_(x); -#endif - } - - inline f32 f32_max3(const f32 a, const f32 b, const f32 c) - { - return a > b ? (a > c ? a : c) : (b > c ? b : c); - } - - inline f32 f32_min3(const f32 a, const f32 b, const f32 c) - { - return a < b ? (a < c ? a : c) : (b < c ? b : c); - } - - inline f32 fract ( f32 x ) - { - return x - floorf ( x ); - } - -} // end namespace core -} // end namespace irr - -#ifndef IRRLICHT_FAST_MATH - using irr::core::IR; - using irr::core::FR; -#endif - -#endif - diff --git a/irrlicht-1.6/include/irrString.h b/irrlicht-1.6/include/irrString.h deleted file mode 100644 index 86c26cd9a..000000000 --- a/irrlicht-1.6/include/irrString.h +++ /dev/null @@ -1,988 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine" and the "irrXML" project. -// For conditions of distribution and use, see copyright notice in irrlicht.h and irrXML.h - -#ifndef __IRR_STRING_H_INCLUDED__ -#define __IRR_STRING_H_INCLUDED__ - -#include "irrTypes.h" -#include "irrAllocator.h" -#include "irrMath.h" -#include <stdio.h> -#include <string.h> -#include <stdlib.h> - -namespace irr -{ -namespace core -{ - -//! Very simple string class with some useful features. -/** string<c8> and string<wchar_t> both accept Unicode AND ASCII/Latin-1, -so you can assign Unicode to string<c8> and ASCII/Latin-1 to string<wchar_t> -(and the other way round) if you want to. - -However, note that the conversation between both is not done using any encoding. -This means that c8 strings are treated as ASCII/Latin-1, not UTF-8, and -are simply expanded to the equivalent wchar_t, while Unicode/wchar_t -characters are truncated to 8-bit ASCII/Latin-1 characters, discarding all -other information in the wchar_t. -*/ - -enum eLocaleID -{ - IRR_LOCALE_ANSI = 0, - IRR_LOCALE_GERMAN = 1 -}; - -static eLocaleID locale_current = IRR_LOCALE_ANSI; -static inline void locale_set ( eLocaleID id ) -{ - locale_current = id; -} - -//! Returns a character converted to lower case -static inline u32 locale_lower ( u32 x ) -{ - switch ( locale_current ) - { - case IRR_LOCALE_GERMAN: - case IRR_LOCALE_ANSI: - break; - } - // ansi - return x >= 'A' && x <= 'Z' ? x + 0x20 : x; -} - -//! Returns a character converted to upper case -static inline u32 locale_upper ( u32 x ) -{ - switch ( locale_current ) - { - case IRR_LOCALE_GERMAN: - case IRR_LOCALE_ANSI: - break; - } - - // ansi - return x >= 'a' && x <= 'z' ? x + ( 'A' - 'a' ) : x; -} - - -template <typename T, typename TAlloc = irrAllocator<T> > -class string -{ -public: - - //! Default constructor - string() - : array(0), allocated(1), used(1) - { - array = allocator.allocate(1); // new T[1]; - array[0] = 0x0; - } - - - //! Constructor - string(const string<T>& other) - : array(0), allocated(0), used(0) - { - *this = other; - } - - //! Constructor from other string types - template <class B> - string(const string<B>& other) - : array(0), allocated(0), used(0) - { - *this = other; - } - - - //! Constructs a string from a float - explicit string(const double number) - : array(0), allocated(0), used(0) - { - c8 tmpbuf[255]; - snprintf(tmpbuf, 255, "%0.6f", number); - *this = tmpbuf; - } - - - //! Constructs a string from an int - explicit string(int number) - : array(0), allocated(0), used(0) - { - // store if negative and make positive - - bool negative = false; - if (number < 0) - { - number *= -1; - negative = true; - } - - // temporary buffer for 16 numbers - - c8 tmpbuf[16]={0}; - u32 idx = 15; - - // special case '0' - - if (!number) - { - tmpbuf[14] = '0'; - *this = &tmpbuf[14]; - return; - } - - // add numbers - - while(number && idx) - { - --idx; - tmpbuf[idx] = (c8)('0' + (number % 10)); - number /= 10; - } - - // add sign - - if (negative) - { - --idx; - tmpbuf[idx] = '-'; - } - - *this = &tmpbuf[idx]; - } - - - //! Constructs a string from an unsigned int - explicit string(unsigned int number) - : array(0), allocated(0), used(0) - { - // temporary buffer for 16 numbers - - c8 tmpbuf[16]={0}; - u32 idx = 15; - - // special case '0' - - if (!number) - { - tmpbuf[14] = '0'; - *this = &tmpbuf[14]; - return; - } - - // add numbers - - while(number && idx) - { - --idx; - tmpbuf[idx] = (c8)('0' + (number % 10)); - number /= 10; - } - - *this = &tmpbuf[idx]; - } - - - //! Constructor for copying a string from a pointer with a given length - template <class B> - string(const B* const c, u32 length) - : array(0), allocated(0), used(0) - { - if (!c) - { - // correctly init the string to an empty one - *this=""; - return; - } - - allocated = used = length+1; - array = allocator.allocate(used); // new T[used]; - - for (u32 l = 0; l<length; ++l) - array[l] = (T)c[l]; - - array[length] = 0; - } - - - //! Constructor for unicode and ascii strings - template <class B> - string(const B* const c) - : array(0), allocated(0), used(0) - { - *this = c; - } - - - //! Destructor - virtual ~string() - { - allocator.deallocate(array); // delete [] array; - } - - - //! Assignment operator - string<T>& operator=(const string<T>& other) - { - if (this == &other) - return *this; - - allocator.deallocate(array); // delete [] array; - allocated = used = other.size()+1; - array = allocator.allocate(used); //new T[used]; - - const T* p = other.c_str(); - for (u32 i=0; i<used; ++i, ++p) - array[i] = *p; - - return *this; - } - - //! Assignment operator for other string types - template <class B> - string<T>& operator=(const string<B>& other) - { - *this = other.c_str(); - return *this; - } - - - //! Assignment operator for strings, ascii and unicode - template <class B> - string<T>& operator=(const B* const c) - { - if (!c) - { - if (!array) - { - array = allocator.allocate(1); //new T[1]; - allocated = 1; - } - used = 1; - array[0] = 0x0; - return *this; - } - - if ((void*)c == (void*)array) - return *this; - - u32 len = 0; - const B* p = c; - while(*p) - { - ++len; - ++p; - } - - // we'll take the old string for a while, because the new - // string could be a part of the current string. - T* oldArray = array; - - ++len; - allocated = used = len; - array = allocator.allocate(used); //new T[used]; - - for (u32 l = 0; l<len; ++l) - array[l] = (T)c[l]; - - allocator.deallocate(oldArray); // delete [] oldArray; - return *this; - } - - - //! Append operator for other strings - string<T> operator+(const string<T>& other) const - { - string<T> str(*this); - str.append(other); - - return str; - } - - - //! Append operator for strings, ascii and unicode - template <class B> - string<T> operator+(const B* const c) const - { - string<T> str(*this); - str.append(c); - - return str; - } - - - //! Direct access operator - T& operator [](const u32 index) - { - _IRR_DEBUG_BREAK_IF(index>=used) // bad index - return array[index]; - } - - - //! Direct access operator - const T& operator [](const u32 index) const - { - _IRR_DEBUG_BREAK_IF(index>=used) // bad index - return array[index]; - } - - - //! Equality operator - bool operator ==(const T* const str) const - { - if (!str) - return false; - - u32 i; - for(i=0; array[i] && str[i]; ++i) - if (array[i] != str[i]) - return false; - - return !array[i] && !str[i]; - } - - - //! Equality operator - bool operator ==(const string<T>& other) const - { - for(u32 i=0; array[i] && other.array[i]; ++i) - if (array[i] != other.array[i]) - return false; - - return used == other.used; - } - - - //! Is smaller comparator - bool operator <(const string<T>& other) const - { - for(u32 i=0; array[i] && other.array[i]; ++i) - { - s32 diff = array[i] - other.array[i]; - if ( diff ) - return diff < 0; -/* - if (array[i] != other.array[i]) - return (array[i] < other.array[i]); -*/ - } - - return used < other.used; - } - - - //! Inequality operator - bool operator !=(const T* const str) const - { - return !(*this == str); - } - - - //! Inequality operator - bool operator !=(const string<T>& other) const - { - return !(*this == other); - } - - - //! Returns length of string - /** \return Length of the string in characters. */ - u32 size() const - { - return used-1; - } - - - //! Returns character string - /** \return pointer to C-style zero terminated string. */ - const T* c_str() const - { - return array; - } - - - //! Makes the string lower case. - void make_lower() - { - for (u32 i=0; i<used; ++i) - array[i] = locale_lower ( array[i] ); - } - - - //! Makes the string upper case. - void make_upper() - { - for (u32 i=0; i<used; ++i) - array[i] = locale_upper ( array[i] ); - } - - - //! Compares the strings ignoring case. - /** \param other: Other string to compare. - \return True if the strings are equal ignoring case. */ - bool equals_ignore_case(const string<T>& other) const - { - for(u32 i=0; array[i] && other[i]; ++i) - if (locale_lower( array[i]) != locale_lower(other[i])) - return false; - - return used == other.used; - } - - //! Compares the strings ignoring case. - /** \param other: Other string to compare. - \param sourcePos: where to start to compare in the string - \return True if the strings are equal ignoring case. */ - bool equals_substring_ignore_case(const string<T>&other, const s32 sourcePos = 0 ) const - { - if ( (u32) sourcePos > used ) - return false; - - u32 i; - for( i=0; array[sourcePos + i] && other[i]; ++i) - if (locale_lower( array[sourcePos + i]) != locale_lower(other[i])) - return false; - - return array[sourcePos + i] == 0 && other[i] == 0; - } - - - //! Compares the strings ignoring case. - /** \param other: Other string to compare. - \return True if this string is smaller ignoring case. */ - bool lower_ignore_case(const string<T>& other) const - { - for(u32 i=0; array[i] && other.array[i]; ++i) - { - s32 diff = (s32) locale_lower ( array[i] ) - (s32) locale_lower ( other.array[i] ); - if ( diff ) - return diff < 0; - } - - return used < other.used; - } - - - //! compares the first n characters of the strings - /** \param other Other string to compare. - \param n Number of characters to compare - \return True if the n first characters of both strings are equal. */ - bool equalsn(const string<T>& other, u32 n) const - { - u32 i; - for(i=0; array[i] && other[i] && i < n; ++i) - if (array[i] != other[i]) - return false; - - // if one (or both) of the strings was smaller then they - // are only equal if they have the same length - return (i == n) || (used == other.used); - } - - - //! compares the first n characters of the strings - /** \param str Other string to compare. - \param n Number of characters to compare - \return True if the n first characters of both strings are equal. */ - bool equalsn(const T* const str, u32 n) const - { - if (!str) - return false; - u32 i; - for(i=0; array[i] && str[i] && i < n; ++i) - if (array[i] != str[i]) - return false; - - // if one (or both) of the strings was smaller then they - // are only equal if they have the same length - return (i == n) || (array[i] == 0 && str[i] == 0); - } - - - //! Appends a character to this string - /** \param character: Character to append. */ - void append(T character) - { - if (used + 1 > allocated) - reallocate(used + 1); - - ++used; - - array[used-2] = character; - array[used-1] = 0; - } - - - //! Appends a char string to this string - /** \param other: Char string to append. */ - void append(const T* const other) - { - if (!other) - return; - - u32 len = 0; - const T* p = other; - while(*p) - { - ++len; - ++p; - } - - if (used + len > allocated) - reallocate(used + len); - - --used; - ++len; - - for (u32 l=0; l<len; ++l) - array[l+used] = *(other+l); - - used += len; - } - - - //! Appends a string to this string - /** \param other: String to append. */ - void append(const string<T>& other) - { - --used; - u32 len = other.size()+1; - - if (used + len > allocated) - reallocate(used + len); - - for (u32 l=0; l<len; ++l) - array[used+l] = other[l]; - - used += len; - } - - - //! Appends a string of the length l to this string. - /** \param other: other String to append to this string. - \param length: How much characters of the other string to add to this one. */ - void append(const string<T>& other, u32 length) - { - if (other.size() < length) - { - append(other); - return; - } - - if (used + length > allocated) - reallocate(used + length); - - --used; - - for (u32 l=0; l<length; ++l) - array[l+used] = other[l]; - used += length; - - // ensure proper termination - array[used]=0; - ++used; - } - - - //! Reserves some memory. - /** \param count: Amount of characters to reserve. */ - void reserve(u32 count) - { - if (count < allocated) - return; - - reallocate(count); - } - - - //! finds first occurrence of character in string - /** \param c: Character to search for. - \return Position where the character has been found, - or -1 if not found. */ - s32 findFirst(T c) const - { - for (u32 i=0; i<used; ++i) - if (array[i] == c) - return i; - - return -1; - } - - //! finds first occurrence of a character of a list in string - /** \param c: List of characters to find. For example if the method - should find the first occurrence of 'a' or 'b', this parameter should be "ab". - \param count: Amount of characters in the list. Usually, - this should be strlen(c) - \return Position where one of the characters has been found, - or -1 if not found. */ - s32 findFirstChar(const T* const c, u32 count) const - { - if (!c) - return -1; - - for (u32 i=0; i<used; ++i) - for (u32 j=0; j<count; ++j) - if (array[i] == c[j]) - return i; - - return -1; - } - - - //! Finds first position of a character not in a given list. - /** \param c: List of characters not to find. For example if the method - should find the first occurrence of a character not 'a' or 'b', this parameter should be "ab". - \param count: Amount of characters in the list. Usually, - this should be strlen(c) - \return Position where the character has been found, - or -1 if not found. */ - template <class B> - s32 findFirstCharNotInList(const B* const c, u32 count) const - { - for (u32 i=0; i<used-1; ++i) - { - u32 j; - for (j=0; j<count; ++j) - if (array[i] == c[j]) - break; - - if (j==count) - return i; - } - - return -1; - } - - //! Finds last position of a character not in a given list. - /** \param c: List of characters not to find. For example if the method - should find the first occurrence of a character not 'a' or 'b', this parameter should be "ab". - \param count: Amount of characters in the list. Usually, - this should be strlen(c) - \return Position where the character has been found, - or -1 if not found. */ - template <class B> - s32 findLastCharNotInList(const B* const c, u32 count) const - { - for (s32 i=(s32)(used-2); i>=0; --i) - { - u32 j; - for (j=0; j<count; ++j) - if (array[i] == c[j]) - break; - - if (j==count) - return i; - } - - return -1; - } - - //! finds next occurrence of character in string - /** \param c: Character to search for. - \param startPos: Position in string to start searching. - \return Position where the character has been found, - or -1 if not found. */ - s32 findNext(T c, u32 startPos) const - { - for (u32 i=startPos; i<used; ++i) - if (array[i] == c) - return i; - - return -1; - } - - - //! finds last occurrence of character in string - /** \param c: Character to search for. - \param start: start to search reverse ( default = -1, on end ) - \return Position where the character has been found, - or -1 if not found. */ - s32 findLast(T c, s32 start = -1) const - { - start = core::clamp ( start < 0 ? (s32)(used) - 1 : start, 0, (s32)(used) - 1 ); - for (s32 i=start; i>=0; --i) - if (array[i] == c) - return i; - - return -1; - } - - //! finds last occurrence of a character of a list in string - /** \param c: List of strings to find. For example if the method - should find the last occurrence of 'a' or 'b', this parameter should be "ab". - \param count: Amount of characters in the list. Usually, - this should be strlen(c) - \return Position where one of the characters has been found, - or -1 if not found. */ - s32 findLastChar(const T* const c, u32 count) const - { - if (!c) - return -1; - - for (s32 i=used-1; i>=0; --i) - for (u32 j=0; j<count; ++j) - if (array[i] == c[j]) - return i; - - return -1; - } - - - //! finds another string in this string - /** \param str: Another string - \return Positions where the string has been found, - or -1 if not found. */ - template <class B> - s32 find(const B* const str) const - { - if (str && *str) - { - u32 len = 0; - - while (str[len]) - ++len; - - if (len > used-1) - return -1; - - for (u32 i=0; i<used-len; ++i) - { - u32 j=0; - - while(str[j] && array[i+j] == str[j]) - ++j; - - if (!str[j]) - return i; - } - } - - return -1; - } - - - //! Returns a substring - /** \param begin: Start of substring. - \param length: Length of substring. */ - string<T> subString(u32 begin, s32 length) const - { - // if start after string - // or no proper substring length - if ((length <= 0) || (begin>=size())) - return string<T>(""); - // clamp length to maximal value - if ((length+begin) > size()) - length = size()-begin; - - string<T> o; - o.reserve(length+1); - - for (s32 i=0; i<length; ++i) - o.array[i] = array[i+begin]; - - o.array[length] = 0; - o.used = o.allocated; - - return o; - } - - - //! Appends a character to this string - /** \param c Character to append. */ - string<T>& operator += (T c) - { - append(c); - return *this; - } - - - //! Appends a char string to this string - /** \param c Char string to append. */ - string<T>& operator += (const T* const c) - { - append(c); - return *this; - } - - - //! Appends a string to this string - /** \param other String to append. */ - string<T>& operator += (const string<T>& other) - { - append(other); - return *this; - } - - - //! Appends a string representation of a number to this string - /** \param i Number to append. */ - string<T>& operator += (const int i) - { - append(string<T>(i)); - return *this; - } - - - //! Appends a string representation of a number to this string - /** \param i Number to append. */ - string<T>& operator += (const unsigned int i) - { - append(string<T>(i)); - return *this; - } - - - //! Appends a string representation of a number to this string - /** \param i Number to append. */ - string<T>& operator += (const long i) - { - append(string<T>(i)); - return *this; - } - - - //! Appends a string representation of a number to this string - /** \param i Number to append. */ - string<T>& operator += (const unsigned long& i) - { - append(string<T>(i)); - return *this; - } - - - //! Appends a string representation of a number to this string - /** \param i Number to append. */ - string<T>& operator += (const double i) - { - append(string<T>(i)); - return *this; - } - - - //! Appends a string representation of a number to this string - /** \param i Number to append. */ - string<T>& operator += (const float i) - { - append(string<T>(i)); - return *this; - } - - - //! Replaces all characters of a special type with another one - /** \param toReplace Character to replace. - \param replaceWith Character replacing the old one. */ - void replace(T toReplace, T replaceWith) - { - for (u32 i=0; i<used; ++i) - if (array[i] == toReplace) - array[i] = replaceWith; - } - - - //! Trims the string. - /** Removes the specified characters (by default, Latin-1 whitespace) - from the begining and the end of the string. */ - string<T>& trim(const string<T> & whitespace = " \t\n\r") - { - // find start and end of the substring without the specified characters - const s32 begin = findFirstCharNotInList(whitespace.c_str(), whitespace.used); - if (begin == -1) - return (*this=""); - - const s32 end = findLastCharNotInList(whitespace.c_str(), whitespace.used); - - return (*this = subString(begin, (end +1) - begin)); - } - - - //! Erases a character from the string. - /** May be slow, because all elements - following after the erased element have to be copied. - \param index: Index of element to be erased. */ - void erase(u32 index) - { - _IRR_DEBUG_BREAK_IF(index>=used) // access violation - - for (u32 i=index+1; i<used; ++i) - array[i-1] = array[i]; - - --used; - } - - //! verify the existing string. - void validate() - { - // terminate on existing null - for (u32 i=0; i<allocated; ++i) - { - if (array[i] == 0) - { - used = i + 1; - return; - } - } - - // terminate - if ( allocated > 0 ) - { - used = allocated - 1; - array[used] = 0; - } - else - { - used = 0; - } - } - - //! gets the last char of a string or null - inline T lastChar() const - { - return used > 1 ? array[used-2] : 0; - } - -private: - - //! Reallocate the array, make it bigger or smaller - void reallocate(u32 new_size) - { - T* old_array = array; - - array = allocator.allocate(new_size); //new T[new_size]; - allocated = new_size; - - u32 amount = used < new_size ? used : new_size; - for (u32 i=0; i<amount; ++i) - array[i] = old_array[i]; - - if (allocated < used) - used = allocated; - - allocator.deallocate(old_array); // delete [] old_array; - } - - //--- member variables - - T* array; - TAlloc allocator; - u32 allocated; - u32 used; -}; - - -//! Typedef for character strings -typedef string<c8> stringc; - -//! Typedef for wide character strings -typedef string<wchar_t> stringw; - - -} // end namespace core -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/irrTypes.h b/irrlicht-1.6/include/irrTypes.h deleted file mode 100644 index fb565f4dc..000000000 --- a/irrlicht-1.6/include/irrTypes.h +++ /dev/null @@ -1,218 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_TYPES_H_INCLUDED__ -#define __IRR_TYPES_H_INCLUDED__ - -#include "IrrCompileConfig.h" - -namespace irr -{ - -//! 8 bit unsigned variable. -/** This is a typedef for unsigned char, it ensures portability of the engine. */ -#ifdef _MSC_VER -typedef unsigned __int8 u8; -#else -typedef unsigned char u8; -#endif - -//! 8 bit signed variable. -/** This is a typedef for signed char, it ensures portability of the engine. */ -#ifdef _MSC_VER -typedef __int8 s8; -#else -typedef signed char s8; -#endif - -//! 8 bit character variable. -/** This is a typedef for char, it ensures portability of the engine. */ -typedef char c8; - - - -//! 16 bit unsigned variable. -/** This is a typedef for unsigned short, it ensures portability of the engine. */ -#ifdef _MSC_VER -typedef unsigned __int16 u16; -#else -typedef unsigned short u16; -#endif - -//! 16 bit signed variable. -/** This is a typedef for signed short, it ensures portability of the engine. */ -#ifdef _MSC_VER -typedef __int16 s16; -#else -typedef signed short s16; -#endif - - - -//! 32 bit unsigned variable. -/** This is a typedef for unsigned int, it ensures portability of the engine. */ -#ifdef _MSC_VER -typedef unsigned __int32 u32; -#else -typedef unsigned int u32; -#endif - -//! 32 bit signed variable. -/** This is a typedef for signed int, it ensures portability of the engine. */ -#ifdef _MSC_VER -typedef __int32 s32; -#else -typedef signed int s32; -#endif - - - -// 64 bit signed variable. -// This is a typedef for __int64, it ensures portability of the engine. -// This type is currently not used by the engine and not supported by compilers -// other than Microsoft Compilers, so it is outcommented. -//typedef __int64 s64; - - - -//! 32 bit floating point variable. -/** This is a typedef for float, it ensures portability of the engine. */ -typedef float f32; - -//! 64 bit floating point variable. -/** This is a typedef for double, it ensures portability of the engine. */ -typedef double f64; - - -} // end namespace irr - - -#include <wchar.h> -#ifdef _IRR_WINDOWS_API_ -//! Defines for s{w,n}printf because these methods do not match the ISO C -//! standard on Windows platforms, but it does on all others. -//! These should be int snprintf(char *str, size_t size, const char *format, ...); -//! and int swprintf(wchar_t *wcs, size_t maxlen, const wchar_t *format, ...); -#if defined(_MSC_VER) && _MSC_VER > 1310 && !defined (_WIN32_WCE) -#define swprintf swprintf_s -#define snprintf sprintf_s -#else -#define swprintf _snwprintf -#define snprintf _snprintf -#endif - -// define the wchar_t type if not already built in. -#ifdef _MSC_VER -#ifndef _WCHAR_T_DEFINED -//! A 16 bit wide character type. -/** - Defines the wchar_t-type. - In VS6, its not possible to tell - the standard compiler to treat wchar_t as a built-in type, and - sometimes we just don't want to include the huge stdlib.h or wchar.h, - so we'll use this. -*/ -typedef unsigned short wchar_t; -#define _WCHAR_T_DEFINED -#endif // wchar is not defined -#endif // microsoft compiler -#endif // _IRR_WINDOWS_API_ - -namespace irr -{ - -//! Should the wide character version of the FileSystem be used -#if defined(_IRR_WCHAR_FILESYSTEM) - //! 16 bit character variable. Used for unicode Filesystem and unicode strings - typedef wchar_t fschar_t; -#else - //! 8 bit character variable. Used for ansi Filesystem and non-unicode strings - typedef char fschar_t; -#endif - -} // end namespace irr - -//! define a break macro for debugging. -#if defined(_DEBUG) -#if defined(_IRR_WINDOWS_API_) && defined(_MSC_VER) && !defined (_WIN32_WCE) - #if defined(_WIN64) // using portable common solution for x64 configuration - #include <crtdbg.h> - #define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) if (_CONDITION_) {_CrtDbgBreak();} - #else - #define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) if (_CONDITION_) {_asm int 3} - #endif -#else -#include "assert.h" -#define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) assert( !(_CONDITION_) ); -#endif -#else -#define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) -#endif - -//! Defines a deprecated macro which generates a warning at compile time -/** The usage is simple -For typedef: typedef _IRR_DEPRECATED_ int test1; -For classes/structs: class _IRR_DEPRECATED_ test2 { ... }; -For methods: class test3 { _IRR_DEPRECATED_ virtual void foo() {} }; -For functions: template<class T> _IRR_DEPRECATED_ void test4(void) {} -**/ -#if defined(IGNORE_DEPRECATED_WARNING) -#define _IRR_DEPRECATED_ -#elif _MSC_VER >= 1310 //vs 2003 or higher -#define _IRR_DEPRECATED_ __declspec(deprecated) -#elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) // all versions above 3.0 should support this feature -#define _IRR_DEPRECATED_ __attribute__ ((deprecated)) -#else -#define _IRR_DEPRECATED_ -#endif - -//! Defines a small statement to work around a microsoft compiler bug. -/** The microsoft compiler 7.0 - 7.1 has a bug: -When you call unmanaged code that returns a bool type value of false from managed code, -the return value may appear as true. See -http://support.microsoft.com/default.aspx?kbid=823071 for details. -Compiler version defines: VC6.0 : 1200, VC7.0 : 1300, VC7.1 : 1310, VC8.0 : 1400*/ -#if defined(_IRR_WINDOWS_API_) && defined(_MSC_VER) && (_MSC_VER > 1299) && (_MSC_VER < 1400) -#define _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX __asm mov eax,100 -#else -#define _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX -#endif // _IRR_MANAGED_MARSHALLING_BUGFIX - - -// memory debugging -#if defined(_DEBUG) && defined(IRRLICHT_EXPORTS) && defined(_MSC_VER) && \ - (_MSC_VER > 1299) && !defined(_IRR_DONT_DO_MEMORY_DEBUGGING_HERE) && !defined(_WIN32_WCE) - - #define CRTDBG_MAP_ALLOC - #define _CRTDBG_MAP_ALLOC - #define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__) - #include <stdlib.h> - #include <crtdbg.h> - #define new DEBUG_CLIENTBLOCK -#endif - -// disable truncated debug information warning in visual studio 6 by default -#if defined(_MSC_VER) && (_MSC_VER < 1300 ) -#pragma warning( disable: 4786) -#endif // _MSC - - -//! ignore VC8 warning deprecated -/** The microsoft compiler */ -#if defined(_IRR_WINDOWS_API_) && defined(_MSC_VER) && (_MSC_VER >= 1400) - //#pragma warning( disable: 4996) - //#define _CRT_SECURE_NO_DEPRECATE 1 - //#define _CRT_NONSTDC_NO_DEPRECATE 1 -#endif - - -//! creates four CC codes used in Irrlicht for simple ids -/** some compilers can create those by directly writing the -code like 'code', but some generate warnings so we use this macro here */ -#define MAKE_IRR_ID(c0, c1, c2, c3) \ - ((u32)(u8)(c0) | ((u32)(u8)(c1) << 8) | \ - ((u32)(u8)(c2) << 16) | ((u32)(u8)(c3) << 24 )) - -#endif // __IRR_TYPES_H_INCLUDED__ - diff --git a/irrlicht-1.6/include/irrXML.h b/irrlicht-1.6/include/irrXML.h deleted file mode 100644 index 45738d9d6..000000000 --- a/irrlicht-1.6/include/irrXML.h +++ /dev/null @@ -1,550 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine" and the "irrXML" project. -// For conditions of distribution and use, see copyright notice in irrlicht.h and/or irrXML.h - -#ifndef __IRR_XML_H_INCLUDED__ -#define __IRR_XML_H_INCLUDED__ - -#include <stdio.h> -#include "IrrCompileConfig.h" - -/** \mainpage irrXML 1.2 API documentation - <div align="center"><img src="logobig.png" ></div> - - \section intro Introduction - - Welcome to the irrXML API documentation. - Here you'll find any information you'll need to develop applications with - irrXML. If you look for a tutorial on how to start, take a look at the \ref irrxmlexample, - at the homepage of irrXML at <A HREF="http://www.ambiera.com/irrxml/">www.ambiera.com/irrxml/</A> - or into the SDK in the directory \example. - - irrXML is intended to be a high speed and easy-to-use XML Parser for C++, and - this documentation is an important part of it. If you have any questions or - suggestions, just send a email to the author of the engine, Nikolaus Gebhardt - (niko (at) irrlicht3d.org). For more informations about this parser, see \ref history. - - \section features Features - - irrXML provides forward-only, read-only - access to a stream of non validated XML data. It was fully implemented by - Nikolaus Gebhardt. Its current features are: - - - It it fast as lighting and has very low memory usage. It was - developed with the intention of being used in 3D games, as it already has been. - - irrXML is very small: It only consists of 60 KB of code and can be added easily - to your existing project. - - Of course, it is platform independent and works with lots of compilers. - - It is able to parse ASCII, UTF-8, UTF-16 and UTF-32 text files, both in - little and big endian format. - - Independent of the input file format, the parser can return all strings in ASCII, UTF-8, - UTF-16 and UTF-32 format. - - With its optional file access abstraction it has the advantage that it can read not - only from files but from any type of data (memory, network, ...). For example when - used with the Irrlicht Engine, it directly reads from compressed .zip files. - - Just like the Irrlicht Engine for which it was originally created, it is extremely easy - to use. - - It has no external dependencies, it does not even need the STL. - - Although irrXML has some strenghts, it currently also has the following limitations: - - - The input xml file is not validated and assumed to be correct. - - \section irrxmlexample Example - - The following code demonstrates the basic usage of irrXML. A simple xml - file like this is parsed: - \code - <?xml version="1.0"?> - <config> - <!-- This is a config file for the mesh viewer --> - <model file="dwarf.dea" /> - <messageText caption="Irrlicht Engine Mesh Viewer"> - Welcome to the Mesh Viewer of the "Irrlicht Engine". - </messageText> - </config> - \endcode - - The code for parsing this file would look like this: - \code - #include <irrXML.h> - using namespace irr; // irrXML is located in the namespace irr::io - using namespace io; - - #include <string> // we use STL strings to store data in this example - - void main() - { - // create the reader using one of the factory functions - - IrrXMLReader* xml = createIrrXMLReader("config.xml"); - - // strings for storing the data we want to get out of the file - std::string modelFile; - std::string messageText; - std::string caption; - - // parse the file until end reached - - while(xml && xml->read()) - { - switch(xml->getNodeType()) - { - case EXN_TEXT: - // in this xml file, the only text which occurs is the messageText - messageText = xml->getNodeData(); - break; - case EXN_ELEMENT: - { - if (!strcmp("model", xml->getNodeName())) - modelFile = xml->getAttributeValue("file"); - else - if (!strcmp("messageText", xml->getNodeName())) - caption = xml->getAttributeValue("caption"); - } - break; - } - } - - // delete the xml parser after usage - delete xml; - } - \endcode - - \section howto How to use - - Simply add the source files in the /src directory of irrXML to your project. Done. - - \section license License - - The irrXML license is based on the zlib license. Basicly, this means you can do with - irrXML whatever you want: - - Copyright (C) 2002-2009 Nikolaus Gebhardt - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source distribution. - - \section history History - - As lots of references in this documentation and the source show, this xml - parser has originally been a part of the - <A HREF="http://irrlicht.sourceforge.net" >Irrlicht Engine</A>. But because - the parser has become very useful with the latest release, people asked for a - separate version of it, to be able to use it in non Irrlicht projects. With - irrXML 1.0, this has now been done. -*/ - -namespace irr -{ -namespace io -{ - //! Enumeration of all supported source text file formats - enum ETEXT_FORMAT - { - //! ASCII, file without byte order mark, or not a text file - ETF_ASCII, - - //! UTF-8 format - ETF_UTF8, - - //! UTF-16 format, big endian - ETF_UTF16_BE, - - //! UTF-16 format, little endian - ETF_UTF16_LE, - - //! UTF-32 format, big endian - ETF_UTF32_BE, - - //! UTF-32 format, little endian - ETF_UTF32_LE - }; - - - //! Enumeration for all xml nodes which are parsed by IrrXMLReader - enum EXML_NODE - { - //! No xml node. This is usually the node if you did not read anything yet. - EXN_NONE, - - //! An xml element such as <foo> - EXN_ELEMENT, - - //! End of an xml element such as </foo> - EXN_ELEMENT_END, - - //! Text within an xml element: <foo> this is the text. <foo> - EXN_TEXT, - - //! An xml comment like <!-- I am a comment --> or a DTD definition. - EXN_COMMENT, - - //! An xml cdata section like <![CDATA[ this is some CDATA ]]> - EXN_CDATA, - - //! Unknown element. - EXN_UNKNOWN - }; - - //! Callback class for file read abstraction. - /** With this, it is possible to make the xml parser read in other - things than just files. The Irrlicht engine is using this for example to - read xml from compressed .zip files. To make the parser read in - any other data, derive a class from this interface, implement the - two methods to read your data and give a pointer to an instance of - your implementation when calling createIrrXMLReader(), - createIrrXMLReaderUTF16() or createIrrXMLReaderUTF32() */ - class IFileReadCallBack - { - public: - - //! Destructor - virtual ~IFileReadCallBack() {} - - //! Reads an amount of bytes from the file. - /** \param buffer: Pointer to buffer where to read bytes will be written to. - \param sizeToRead: Amount of bytes to read from the file. - \return Returns how much bytes were read. */ - virtual int read(void* buffer, int sizeToRead) = 0; - - //! Returns size of file in bytes - virtual long getSize() const = 0; - }; - - //! Empty class to be used as parent class for IrrXMLReader. - /** If you need another class as base class for the xml reader, you can do this by creating - the reader using for example new CXMLReaderImpl<char, YourBaseClass>(yourcallback); - The Irrlicht Engine for example needs IReferenceCounted as base class for every object to - let it automaticly reference countend, hence it replaces IXMLBase with IReferenceCounted. - See irrXML.cpp on how this can be done in detail. */ - class IXMLBase - { - }; - - //! Interface providing easy read access to a XML file. - /** You can create an instance of this reader using one of the factory functions - createIrrXMLReader(), createIrrXMLReaderUTF16() and createIrrXMLReaderUTF32(). - If using the parser from the Irrlicht Engine, please use IFileSystem::createXMLReader() - instead. - For a detailed intro how to use the parser, see \ref irrxmlexample and \ref features. - - The typical usage of this parser looks like this: - \code - #include <irrXML.h> - using namespace irr; // irrXML is located in the namespace irr::io - using namespace io; - - void main() - { - // create the reader using one of the factory functions - IrrXMLReader* xml = createIrrXMLReader("config.xml"); - - if (xml == 0) - return; // file could not be opened - - // parse the file until end reached - while(xml->read()) - { - // based on xml->getNodeType(), do something. - } - - // delete the xml parser after usage - delete xml; - } - \endcode - See \ref irrxmlexample for a more detailed example. - */ - template<class char_type, class super_class> - class IIrrXMLReader : public super_class - { - public: - - //! Destructor - virtual ~IIrrXMLReader() {} - - //! Reads forward to the next xml node. - /** \return Returns false, if there was no further node. */ - virtual bool read() = 0; - - //! Returns the type of the current XML node. - virtual EXML_NODE getNodeType() const = 0; - - //! Returns attribute count of the current XML node. - /** This is usually - non null if the current node is EXN_ELEMENT, and the element has attributes. - \return Returns amount of attributes of this xml node. */ - virtual unsigned int getAttributeCount() const = 0; - - //! Returns name of an attribute. - /** \param idx: Zero based index, should be something between 0 and getAttributeCount()-1. - \return Name of the attribute, 0 if an attribute with this index does not exist. */ - virtual const char_type* getAttributeName(int idx) const = 0; - - //! Returns the value of an attribute. - /** \param idx: Zero based index, should be something between 0 and getAttributeCount()-1. - \return Value of the attribute, 0 if an attribute with this index does not exist. */ - virtual const char_type* getAttributeValue(int idx) const = 0; - - //! Returns the value of an attribute. - /** \param name: Name of the attribute. - \return Value of the attribute, 0 if an attribute with this name does not exist. */ - virtual const char_type* getAttributeValue(const char_type* name) const = 0; - - //! Returns the value of an attribute in a safe way. - /** Like getAttributeValue(), but does not - return 0 if the attribute does not exist. An empty string ("") is returned then. - \param name: Name of the attribute. - \return Value of the attribute, and "" if an attribute with this name does not exist */ - virtual const char_type* getAttributeValueSafe(const char_type* name) const = 0; - - //! Returns the value of an attribute as integer. - /** \param name Name of the attribute. - \return Value of the attribute as integer, and 0 if an attribute with this name does not exist or - the value could not be interpreted as integer. */ - virtual int getAttributeValueAsInt(const char_type* name) const = 0; - - //! Returns the value of an attribute as integer. - /** \param idx: Zero based index, should be something between 0 and getAttributeCount()-1. - \return Value of the attribute as integer, and 0 if an attribute with this index does not exist or - the value could not be interpreted as integer. */ - virtual int getAttributeValueAsInt(int idx) const = 0; - - //! Returns the value of an attribute as float. - /** \param name: Name of the attribute. - \return Value of the attribute as float, and 0 if an attribute with this name does not exist or - the value could not be interpreted as float. */ - virtual float getAttributeValueAsFloat(const char_type* name) const = 0; - - //! Returns the value of an attribute as float. - /** \param idx: Zero based index, should be something between 0 and getAttributeCount()-1. - \return Value of the attribute as float, and 0 if an attribute with this index does not exist or - the value could not be interpreted as float. */ - virtual float getAttributeValueAsFloat(int idx) const = 0; - - //! Returns the name of the current node. - /** Only non null, if the node type is EXN_ELEMENT. - \return Name of the current node or 0 if the node has no name. */ - virtual const char_type* getNodeName() const = 0; - - //! Returns data of the current node. - /** Only non null if the node has some - data and it is of type EXN_TEXT or EXN_UNKNOWN. */ - virtual const char_type* getNodeData() const = 0; - - //! Returns if an element is an empty element, like <foo /> - virtual bool isEmptyElement() const = 0; - - //! Returns format of the source xml file. - /** It is not necessary to use - this method because the parser will convert the input file format - to the format wanted by the user when creating the parser. This - method is useful to get/display additional informations. */ - virtual ETEXT_FORMAT getSourceFormat() const = 0; - - //! Returns format of the strings returned by the parser. - /** This will be UTF8 for example when you created a parser with - IrrXMLReaderUTF8() and UTF32 when it has been created using - IrrXMLReaderUTF32. It should not be necessary to call this - method and only exists for informational purposes. */ - virtual ETEXT_FORMAT getParserFormat() const = 0; - }; - - - //! defines the utf-16 type. - /** Not using wchar_t for this because - wchar_t has 16 bit on windows and 32 bit on other operating systems. */ - typedef unsigned short char16; - - //! defines the utf-32 type. - /** Not using wchar_t for this because - wchar_t has 16 bit on windows and 32 bit on other operating systems. */ - typedef unsigned long char32; - - //! A UTF-8 or ASCII character xml parser. - /** This means that all character data will be returned in 8 bit ASCII or UTF-8 by this parser. - The file to read can be in any format, it will be converted to UTF-8 if it is not - in this format. - Create an instance of this with createIrrXMLReader(); - See IIrrXMLReader for description on how to use it. */ - typedef IIrrXMLReader<char, IXMLBase> IrrXMLReader; - - //! A UTF-16 xml parser. - /** This means that all character data will be returned in UTF-16 by this parser. - The file to read can be in any format, it will be converted to UTF-16 if it is not - in this format. - Create an instance of this with createIrrXMLReaderUTF16(); - See IIrrXMLReader for description on how to use it. */ - typedef IIrrXMLReader<char16, IXMLBase> IrrXMLReaderUTF16; - - //! A UTF-32 xml parser. - /** This means that all character data will be returned in UTF-32 by this parser. - The file to read can be in any format, it will be converted to UTF-32 if it is not - in this format. - Create an instance of this with createIrrXMLReaderUTF32(); - See IIrrXMLReader for description on how to use it. */ - typedef IIrrXMLReader<char32, IXMLBase> IrrXMLReaderUTF32; - - - //! Creates an instance of an UFT-8 or ASCII character xml parser. - /** This means that all character data will be returned in 8 bit ASCII or UTF-8. - The file to read can be in any format, it will be converted to UTF-8 if it is not in this format. - If you are using the Irrlicht Engine, it is better not to use this function but - IFileSystem::createXMLReaderUTF8() instead. - \param filename: Name of file to be opened. - \return Returns a pointer to the created xml parser. This pointer should be - deleted using 'delete' after no longer needed. Returns 0 if an error occured - and the file could not be opened. */ - IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(const char* filename); - - //! Creates an instance of an UFT-8 or ASCII character xml parser. - /** This means that all character data will be returned in 8 bit ASCII or UTF-8. The file to read can - be in any format, it will be converted to UTF-8 if it is not in this format. - If you are using the Irrlicht Engine, it is better not to use this function but - IFileSystem::createXMLReaderUTF8() instead. - \param file: Pointer to opened file, must have been opened in binary mode, e.g. - using fopen("foo.bar", "wb"); The file will not be closed after it has been read. - \return Returns a pointer to the created xml parser. This pointer should be - deleted using 'delete' after no longer needed. Returns 0 if an error occured - and the file could not be opened. */ - IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(FILE* file); - - //! Creates an instance of an UFT-8 or ASCII character xml parser. - /** This means that all character data will be returned in 8 bit ASCII or UTF-8. The file to read can - be in any format, it will be converted to UTF-8 if it is not in this format. - If you are using the Irrlicht Engine, it is better not to use this function but - IFileSystem::createXMLReaderUTF8() instead. - \param callback: Callback for file read abstraction. Implement your own - callback to make the xml parser read in other things than just files. See - IFileReadCallBack for more information about this. - \param deleteCallback: if true, the callback will be deleted after the file - has been read. Otherwise the caller si responsible for cleaning it up. - \return Returns a pointer to the created xml parser. This pointer should be - deleted using 'delete' after no longer needed. Returns 0 if an error occured - and the file could not be opened. */ - IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(IFileReadCallBack* callback, - bool deleteCallback = false); - - //! Creates an instance of an UFT-16 xml parser. - /** This means that - all character data will be returned in UTF-16. The file to read can - be in any format, it will be converted to UTF-16 if it is not in this format. - If you are using the Irrlicht Engine, it is better not to use this function but - IFileSystem::createXMLReader() instead. - \param filename: Name of file to be opened. - \return Returns a pointer to the created xml parser. This pointer should be - deleted using 'delete' after no longer needed. Returns 0 if an error occured - and the file could not be opened. */ - IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(const char* filename); - - //! Creates an instance of an UFT-16 xml parser. - /** This means that all character data will be returned in UTF-16. The file to read can - be in any format, it will be converted to UTF-16 if it is not in this format. - If you are using the Irrlicht Engine, it is better not to use this function but - IFileSystem::createXMLReader() instead. - \param file: Pointer to opened file, must have been opened in binary mode, e.g. - using fopen("foo.bar", "wb"); The file will not be closed after it has been read. - \return Returns a pointer to the created xml parser. This pointer should be - deleted using 'delete' after no longer needed. Returns 0 if an error occured - and the file could not be opened. */ - IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(FILE* file); - - //! Creates an instance of an UFT-16 xml parser. - /** This means that all character data will be returned in UTF-16. The file to read can - be in any format, it will be converted to UTF-16 if it is not in this format. - If you are using the Irrlicht Engine, it is better not to use this function but - IFileSystem::createXMLReader() instead. - \param callback: Callback for file read abstraction. Implement your own - callback to make the xml parser read in other things than just files. See - IFileReadCallBack for more information about this. - \param deleteCallback: if true, the callback will be deleted after the file - has been read. Otherwise the caller si responsible for cleaning it up. - \return Returns a pointer to the created xml parser. This pointer should be - deleted using 'delete' after no longer needed. Returns 0 if an error occured - and the file could not be opened. */ - IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(IFileReadCallBack* callback, - bool deleteCallback = false); - - - //! Creates an instance of an UFT-32 xml parser. - /** This means that all character data will be returned in UTF-32. The file to read can - be in any format, it will be converted to UTF-32 if it is not in this format. - If you are using the Irrlicht Engine, it is better not to use this function but - IFileSystem::createXMLReader() instead. - \param filename: Name of file to be opened. - \return Returns a pointer to the created xml parser. This pointer should be - deleted using 'delete' after no longer needed. Returns 0 if an error occured - and the file could not be opened. */ - IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(const char* filename); - - //! Creates an instance of an UFT-32 xml parser. - /** This means that all character data will be returned in UTF-32. The file to read can - be in any format, it will be converted to UTF-32 if it is not in this format. - if you are using the Irrlicht Engine, it is better not to use this function but - IFileSystem::createXMLReader() instead. - \param file: Pointer to opened file, must have been opened in binary mode, e.g. - using fopen("foo.bar", "wb"); The file will not be closed after it has been read. - \return Returns a pointer to the created xml parser. This pointer should be - deleted using 'delete' after no longer needed. Returns 0 if an error occured - and the file could not be opened. */ - IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(FILE* file); - - //! Creates an instance of an UFT-32 xml parser. - /** This means that - all character data will be returned in UTF-32. The file to read can - be in any format, it will be converted to UTF-32 if it is not in this format. - If you are using the Irrlicht Engine, it is better not to use this function but - IFileSystem::createXMLReader() instead. - \param callback: Callback for file read abstraction. Implement your own - callback to make the xml parser read in other things than just files. See - IFileReadCallBack for more information about this. - \param deleteCallback: if true, the callback will be deleted after the file - has been read. Otherwise the caller si responsible for cleaning it up. - \return Returns a pointer to the created xml parser. This pointer should be - deleted using 'delete' after no longer needed. Returns 0 if an error occured - and the file could not be opened. */ - IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(IFileReadCallBack* callback, - bool deleteCallback = false); - - - /*! \file irrxml.h - \brief Header file of the irrXML, the Irrlicht XML parser. - - This file includes everything needed for using irrXML, - the XML parser of the Irrlicht Engine. To use irrXML, - you only need to include this file in your project: - - \code - #include <irrXML.h> - \endcode - - It is also common to use the two namespaces in which irrXML is included, - directly after #including irrXML.h: - - \code - #include <irrXML.h> - using namespace irr; - using namespace io; - \endcode - */ - -} // end namespace io -} // end namespace irr - -#endif // __IRR_XML_H_INCLUDED__ - diff --git a/irrlicht-1.6/include/irrlicht.h b/irrlicht-1.6/include/irrlicht.h deleted file mode 100644 index cf4850d74..000000000 --- a/irrlicht-1.6/include/irrlicht.h +++ /dev/null @@ -1,394 +0,0 @@ -/* irrlicht.h -- interface of the 'Irrlicht Engine' - - Copyright (C) 2002-2009 Nikolaus Gebhardt - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Please note that the Irrlicht Engine is based in part on the work of the - Independent JPEG Group, the zlib and the libPng. This means that if you use - the Irrlicht Engine in your product, you must acknowledge somewhere in your - documentation that you've used the IJG code. It would also be nice to mention - that you use the Irrlicht Engine, the zlib and libPng. See the README files - in the jpeglib, the zlib and libPng for further informations. -*/ - -#ifndef __IRRLICHT_H_INCLUDED__ -#define __IRRLICHT_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#include "aabbox3d.h" -#include "CDynamicMeshBuffer.h" -#include "CIndexBuffer.h" -#include "CMeshBuffer.h" -#include "coreutil.h" -#include "CVertexBuffer.h" -#include "dimension2d.h" -#include "ECullingTypes.h" -#include "EDebugSceneTypes.h" -#include "EDriverFeatures.h" -#include "EDriverTypes.h" -#include "EGUIAlignment.h" -#include "EGUIElementTypes.h" -#include "EHardwareBufferFlags.h" -#include "EMaterialFlags.h" -#include "EMaterialTypes.h" -#include "EMeshWriterEnums.h" -#include "EMessageBoxFlags.h" -#include "ESceneNodeAnimatorTypes.h" -#include "ESceneNodeTypes.h" -#include "ETerrainElements.h" -#include "fast_atof.h" -#include "heapsort.h" -#include "IAnimatedMesh.h" -#include "IAnimatedMeshMD2.h" -#include "IAnimatedMeshMD3.h" -#include "IAnimatedMeshSceneNode.h" -#include "IAttributeExchangingObject.h" -#include "IAttributes.h" -#include "IBillboardSceneNode.h" -#include "IBillboardTextSceneNode.h" -#include "IBoneSceneNode.h" -#include "ICameraSceneNode.h" -#include "ICursorControl.h" -#include "IDummyTransformationSceneNode.h" -#include "IDynamicMeshBuffer.h" -#include "IEventReceiver.h" -#include "IFileList.h" -#include "IFileSystem.h" -#include "IGeometryCreator.h" -#include "IGPUProgrammingServices.h" -#include "IGUIButton.h" -#include "IGUICheckBox.h" -#include "IGUIColorSelectDialog.h" -#include "IGUIComboBox.h" -#include "IGUIContextMenu.h" -#include "IGUIEditBox.h" -#include "IGUIElement.h" -#include "IGUIElementFactory.h" -#include "IGUIEnvironment.h" -#include "IGUIFileOpenDialog.h" -#include "IGUIFont.h" -#include "IGUIFontBitmap.h" -#include "IGUIImage.h" -#include "IGUIInOutFader.h" -#include "IGUIListBox.h" -#include "IGUIMeshViewer.h" -#include "IGUIScrollBar.h" -#include "IGUISkin.h" -#include "IGUISpinBox.h" -#include "IGUISpriteBank.h" -#include "IGUIStaticText.h" -#include "IGUITabControl.h" -#include "IGUITable.h" -#include "IGUIToolbar.h" -#include "IGUIWindow.h" -#include "IGUITreeView.h" -#include "IImage.h" -#include "IImageLoader.h" -#include "IImageWriter.h" -#include "IIndexBuffer.h" -#include "ILightSceneNode.h" -#include "ILogger.h" -#include "IMaterialRenderer.h" -#include "IMaterialRendererServices.h" -#include "IMesh.h" -#include "IMeshBuffer.h" -#include "IMeshCache.h" -#include "IMeshLoader.h" -#include "IMeshManipulator.h" -#include "IMeshSceneNode.h" -#include "IMeshWriter.h" -#include "IMetaTriangleSelector.h" -#include "IOSOperator.h" -#include "IParticleSystemSceneNode.h" // also includes all emitters and attractors -#include "IQ3LevelMesh.h" -#include "IQ3Shader.h" -#include "IReadFile.h" -#include "IReferenceCounted.h" -#include "irrArray.h" -#include "IrrlichtDevice.h" -#include "irrList.h" -#include "irrMap.h" -#include "irrMath.h" -#include "irrString.h" -#include "irrTypes.h" -#include "path.h" -#include "irrXML.h" -#include "ISceneCollisionManager.h" -#include "ISceneManager.h" -#include "ISceneNode.h" -#include "ISceneNodeAnimator.h" -#include "ISceneNodeAnimatorCameraFPS.h" -#include "ISceneNodeAnimatorCameraMaya.h" -#include "ISceneNodeAnimatorCollisionResponse.h" -#include "ISceneNodeAnimatorFactory.h" -#include "ISceneNodeFactory.h" -#include "ISceneUserDataSerializer.h" -#include "IShaderConstantSetCallBack.h" -#include "IShadowVolumeSceneNode.h" -#include "ISkinnedMesh.h" -#include "ITerrainSceneNode.h" -#include "ITextSceneNode.h" -#include "ITexture.h" -#include "ITimer.h" -#include "ITriangleSelector.h" -#include "IVertexBuffer.h" -#include "IVideoDriver.h" -#include "IVideoModeList.h" -#include "IVolumeLightSceneNode.h" -#include "IWriteFile.h" -#include "IXMLReader.h" -#include "IXMLWriter.h" -#include "ILightManager.h" -#include "Keycodes.h" -#include "line2d.h" -#include "line3d.h" -#include "matrix4.h" -#include "plane3d.h" -#include "position2d.h" -#include "quaternion.h" -#include "rect.h" -#include "S3DVertex.h" -#include "SAnimatedMesh.h" -#include "SceneParameters.h" -#include "SColor.h" -#include "SExposedVideoData.h" -#include "SIrrCreationParameters.h" -#include "SKeyMap.h" -#include "SLight.h" -#include "SMaterial.h" -#include "SMesh.h" -#include "SMeshBuffer.h" -#include "SMeshBufferLightMap.h" -#include "SMeshBufferTangents.h" -#include "SParticle.h" -#include "SSharedMeshBuffer.h" -#include "SSkinMeshBuffer.h" -#include "SVertexIndex.h" -#include "SViewFrustum.h" -#include "triangle3d.h" -#include "vector2d.h" -#include "vector3d.h" - -/*! \mainpage Irrlicht Engine 1.5 API documentation - * - * <div align="center"><img src="logobig.png" ></div> - * - * \section intro Introduction - * - * Welcome to the Irrlicht Engine API documentation. - * Here you'll find any information you'll need to develop applications with - * the Irrlicht Engine. If you are looking for a tutorial on how to start, you'll - * find some on the homepage of the Irrlicht Engine at - * <A HREF="http://irrlicht.sourceforge.net" >irrlicht.sourceforge.net</A> - * or inside the SDK in the examples directory. - * - * The Irrlicht Engine is intended to be an easy-to-use 3d engine, so - * this documentation is an important part of it. If you have any questions or - * suggestions, just send a email to the author of the engine, Nikolaus Gebhardt - * (niko (at) irrlicht3d.org). - * - * - * \section links Links - * - * <A HREF="namespaces.html">Namespaces</A>: A very good place to start reading - * the documentation.<BR> - * <A HREF="annotated.html">Class list</A>: List of all classes with descriptions.<BR> - * <A HREF="functions.html">Class members</A>: Good place to find forgotten features.<BR> - * - * \section irrexample Short example - * - * A simple application, starting up the engine, loading a Quake 2 animated - * model file and the corresponding texture, animating and displaying it - * in front of a blue background and placing a user controlable 3d camera - * would look like the following code. I think this example shows the usage - * of the engine quite well: - * - * \code - * #include <irrlicht.h> - * using namespace irr; - * - * int main() - * { - * // start up the engine - * IrrlichtDevice *device = createDevice(video::EDT_DIRECT3D8, - * core::dimension2d<u32>(640,480)); - * - * video::IVideoDriver* driver = device->getVideoDriver(); - * scene::ISceneManager* scenemgr = device->getSceneManager(); - * - * device->setWindowCaption(L"Hello World!"); - * - * // load and show quake2 .md2 model - * scene::ISceneNode* node = scenemgr->addAnimatedMeshSceneNode( - * scenemgr->getMesh("quake2model.md2")); - * - * // if everything worked, add a texture and disable lighting - * if (node) - * { - * node->setMaterialTexture(0, driver->getTexture("texture.bmp")); - * node->setMaterialFlag(video::EMF_LIGHTING, false); - * } - * - * // add a first person shooter style user controlled camera - * scenemgr->addCameraSceneNodeFPS(); - * - * // draw everything - * while(device->run() && driver) - * { - * driver->beginScene(true, true, video::SColor(255,0,0,255)); - * scenemgr->drawAll(); - * driver->endScene(); - * } - * - * // delete device - * device->drop(); - * return 0; - * } - * \endcode - * - * Irrlicht can load a lot of file formats automaticly, see irr::scene::ISceneManager::getMesh() - * for a detailed list. So if you would like to replace the simple blue screen background by - * a cool Quake 3 Map, optimized by an octtree, just insert this code - * somewhere before the while loop: - * - * \code - * // add .pk3 archive to the file system - * device->getFileSystem()->addZipFileArchive("quake3map.pk3"); - * - * // load .bsp file and show it using an octtree - * scenemgr->addOctTreeSceneNode( - * scenemgr->getMesh("quake3map.bsp")); - * \endcode - * - * As you can see, the engine uses namespaces. Everything in the engine is - * placed into the namespace 'irr', but there are also 5 sub namespaces. - * You can find a list of all namespaces with descriptions at the - * <A HREF="namespaces.html"> namespaces page</A>. - * This is also a good place to start reading the documentation. If you - * don't want to write the namespace names all the time, just use all namespaces like - * this: - * \code - * using namespace core; - * using namespace scene; - * using namespace video; - * using namespace io; - * using namespace gui; - * \endcode - * - * There is a lot more the engine can do, but I hope this gave a short - * overview over the basic features of the engine. For more examples, please take - * a look into the examples directory of the SDK. - */ - -#include "SIrrCreationParameters.h" - -//! Everything in the Irrlicht Engine can be found in this namespace. -namespace irr -{ - //! Creates an Irrlicht device. The Irrlicht device is the root object for using the engine. - /** If you need more parameters to be passed to the creation of the Irrlicht Engine device, - use the createDeviceEx() function. - \param deviceType: Type of the device. This can currently be video::EDT_NULL, - video::EDT_SOFTWARE, video::EDT_BURNINGSVIDEO, video::EDT_DIRECT3D8, video::EDT_DIRECT3D9 and video::EDT_OPENGL. - \param windowSize: Size of the window or the video mode in fullscreen mode. - \param bits: Bits per pixel in fullscreen mode. Ignored if windowed mode. - \param fullscreen: Should be set to true if the device should run in fullscreen. Otherwise - the device runs in windowed mode. - \param stencilbuffer: Specifies if the stencil buffer should be enabled. Set this to true, - if you want the engine be able to draw stencil buffer shadows. Note that not all - devices are able to use the stencil buffer. If they don't no shadows will be drawn. - \param vsync: Specifies vertical syncronisation: If set to true, the driver will wait - for the vertical retrace period, otherwise not. - \param receiver: A user created event receiver. - \return Returns pointer to the created IrrlichtDevice or null if the - device could not be created. - */ - extern "C" IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDevice( - video::E_DRIVER_TYPE deviceType = video::EDT_SOFTWARE, - // parantheses are necessary for some compilers - const core::dimension2d<u32>& windowSize = (core::dimension2d<u32>(640,480)), - u32 bits = 16, - bool fullscreen = false, - bool stencilbuffer = false, - bool vsync = false, - IEventReceiver* receiver = 0); - - //! typedef for Function Pointer - typedef IrrlichtDevice* (IRRCALLCONV *funcptr_createDevice )( - video::E_DRIVER_TYPE deviceType, - const core::dimension2d<u32>& windowSize, - u32 bits, - bool fullscreen, - bool stencilbuffer, - bool vsync, - IEventReceiver* receiver); - - - //! Creates an Irrlicht device with the option to specify advanced parameters. - /** Usually you should used createDevice() for creating an Irrlicht Engine device. - Use this function only if you wish to specify advanced parameters like a window - handle in which the device should be created. - \param parameters: Structure containing advanced parameters for the creation of the device. - See irr::SIrrlichtCreationParameters for details. - \return Returns pointer to the created IrrlichtDevice or null if the - device could not be created. */ - extern "C" IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDeviceEx( - const SIrrlichtCreationParameters& parameters); - - //! typedef for Function Pointer - typedef IrrlichtDevice* (IRRCALLCONV *funcptr_createDeviceEx )( const SIrrlichtCreationParameters& parameters ); - - - // THE FOLLOWING IS AN EMPTY LIST OF ALL SUB NAMESPACES - // EXISTING ONLY FOR THE DOCUMENTATION SOFTWARE DOXYGEN. - - //! In this namespace can be found basic classes like vectors, planes, arrays, lists and so on. - namespace core - { - } - - //! The gui namespace contains useful classes for easy creation of a graphical user interface. - namespace gui - { - } - - //! This namespace provides interfaces for input/output: Reading and - //! writing files, accessing zip archives, xml files, ... - namespace io - { - } - - //! All scene management can be found in this namespace: Mesh loading, - //! special scene nodes like octrees and billboards, ... - namespace scene - { - } - - //! The video namespace contains classes for accessing the video driver. All 2d and 3d rendering is done here. - namespace video - { - } -} - -/*! \file irrlicht.h - \brief Main header file of the irrlicht, the only file needed to include. -*/ - -#endif - - diff --git a/irrlicht-1.6/include/line2d.h b/irrlicht-1.6/include/line2d.h deleted file mode 100644 index 7c10706ce..000000000 --- a/irrlicht-1.6/include/line2d.h +++ /dev/null @@ -1,198 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_LINE_2D_H_INCLUDED__ -#define __IRR_LINE_2D_H_INCLUDED__ - -#include "irrTypes.h" -#include "vector2d.h" - -namespace irr -{ -namespace core -{ - -//! 2D line between two points with intersection methods. -template <class T> -class line2d -{ - public: - //! Default constructor for line going from (0,0) to (1,1). - line2d() : start(0,0), end(1,1) {} - //! Constructor for line between the two points. - line2d(T xa, T ya, T xb, T yb) : start(xa, ya), end(xb, yb) {} - //! Constructor for line between the two points given as vectors. - line2d(const vector2d<T>& start, const vector2d<T>& end) : start(start), end(end) {} - //! Copy constructor. - line2d(const line2d<T>& other) : start(other.start), end(other.end) {} - - // operators - - line2d<T> operator+(const vector2d<T>& point) const { return line2d<T>(start + point, end + point); } - line2d<T>& operator+=(const vector2d<T>& point) { start += point; end += point; return *this; } - - line2d<T> operator-(const vector2d<T>& point) const { return line2d<T>(start - point, end - point); } - line2d<T>& operator-=(const vector2d<T>& point) { start -= point; end -= point; return *this; } - - bool operator==(const line2d<T>& other) const - { return (start==other.start && end==other.end) || (end==other.start && start==other.end);} - bool operator!=(const line2d<T>& other) const - { return !(start==other.start && end==other.end) || (end==other.start && start==other.end);} - - // functions - //! Set this line to new line going through the two points. - void setLine(const T& xa, const T& ya, const T& xb, const T& yb){start.set(xa, ya); end.set(xb, yb);} - //! Set this line to new line going through the two points. - void setLine(const vector2d<T>& nstart, const vector2d<T>& nend){start.set(nstart); end.set(nend);} - //! Set this line to new line given as parameter. - void setLine(const line2d<T>& line){start.set(line.start); end.set(line.end);} - - //! Get length of line - /** \return Length of the line. */ - f64 getLength() const { return start.getDistanceFrom(end); } - - //! Get squared length of the line - /** \return Squared length of line. */ - T getLengthSQ() const { return start.getDistanceFromSQ(end); } - - //! Get middle of the line - /** \return center of the line. */ - vector2d<T> getMiddle() const - { - return (start + end) * (T)0.5; - } - - //! Get the vector of the line. - /** \return The vector of the line. */ - vector2d<T> getVector() const { return vector2d<T>(end.X - start.X, end.Y - start.Y); } - - //! Tests if this line intersects with another line. - /** \param l: Other line to test intersection with. - \param out: If there is an intersection, the location of the - intersection will be stored in this vector. - \return True if there is an intersection, false if not. */ - bool intersectWith(const line2d<T>& l, vector2d<T>& out) const - { - // Uses the method given at: - // http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/ - const f32 commonDenominator = (l.end.Y - l.start.Y)*(end.X - start.X) - - (l.end.X - l.start.X)*(end.Y - start.Y); - - const f32 numeratorA = (l.end.X - l.start.X)*(start.Y - l.start.Y) - - (l.end.Y - l.start.Y)*(start.X -l.start.X); - - const f32 numeratorB = (end.X - start.X)*(start.Y - l.start.Y) - - (end.Y - start.Y)*(start.X -l.start.X); - - if(equals(commonDenominator, 0.f)) - { - // The lines are either coincident or parallel - if(equals(numeratorA, 0.f) && equals(numeratorB, 0.f)) - { - // Try and find a common endpoint - if(l.start == start || l.end == start) - out = start; - else if(l.end == end || l.start == end) - out = end; - else - // one line is contained in the other, so for lack of a better - // answer, pick the average of both lines - out = ((start + end + l.start + l.end) * 0.25f); - - return true; // coincident - } - - return false; // parallel - } - - // Get the point of intersection on this line, checking that - // it is within the line segment. - const f32 uA = numeratorA / commonDenominator; - if(uA < 0.f || uA > 1.f) - return false; // Outside the line segment - - const f32 uB = numeratorB / commonDenominator; - if(uB < 0.f || uB > 1.f) - return false; // Outside the line segment - - // Calculate the intersection point. - out.X = start.X + uA * (end.X - start.X); - out.Y = start.Y + uA * (end.Y - start.Y); - return true; - } - - //! Get unit vector of the line. - /** \return Unit vector of this line. */ - vector2d<T> getUnitVector() const - { - T len = (T)(1.0 / getLength()); - return vector2d<T>((end.X - start.X) * len, (end.Y - start.Y) * len); - } - - //! Get angle between this line and given line. - /** \param l Other line for test. - \return Angle in degrees. */ - f64 getAngleWith(const line2d<T>& l) const - { - vector2d<T> vect = getVector(); - vector2d<T> vect2 = l.getVector(); - return vect.getAngleWith(vect2); - } - - //! Tells us if the given point lies to the left, right, or on the line. - /** \return 0 if the point is on the line - <0 if to the left, or >0 if to the right. */ - T getPointOrientation(const vector2d<T>& point) const - { - return ( (end.X - start.X) * (point.Y - start.Y) - - (point.X - start.X) * (end.Y - start.Y) ); - } - - //! Check if the given point is a member of the line - /** \return True if point is between start and end, else false. */ - bool isPointOnLine(const vector2d<T>& point) const - { - T d = getPointOrientation(point); - return (d == 0 && point.isBetweenPoints(start, end)); - } - - //! Check if the given point is between start and end of the line. - /** Assumes that the point is already somewhere on the line. */ - bool isPointBetweenStartAndEnd(const vector2d<T>& point) const - { - return point.isBetweenPoints(start, end); - } - - //! Get the closest point on this line to a point - vector2d<T> getClosestPoint(const vector2d<T>& point) const - { - vector2d<T> c = point - start; - vector2d<T> v = end - start; - T d = (T)v.getLength(); - v /= d; - T t = v.dotProduct(c); - - if (t < (T)0.0) return start; - if (t > d) return end; - - v *= t; - return start + v; - } - - //! Start point of the line. - vector2d<T> start; - //! End point of the line. - vector2d<T> end; -}; - - //! Typedef for an f32 line. - typedef line2d<f32> line2df; - //! Typedef for an integer line. - typedef line2d<s32> line2di; - -} // end namespace core -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/line3d.h b/irrlicht-1.6/include/line3d.h deleted file mode 100644 index f8141cc80..000000000 --- a/irrlicht-1.6/include/line3d.h +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_LINE_3D_H_INCLUDED__ -#define __IRR_LINE_3D_H_INCLUDED__ - -#include "irrTypes.h" -#include "vector3d.h" - -namespace irr -{ -namespace core -{ - -//! 3D line between two points with intersection methods. -template <class T> -class line3d -{ - public: - - //! Default constructor - /** line from (0,0,0) to (1,1,1) */ - line3d() : start(0,0,0), end(1,1,1) {} - //! Constructor with two points - line3d(T xa, T ya, T za, T xb, T yb, T zb) : start(xa, ya, za), end(xb, yb, zb) {} - //! Constructor with two points as vectors - line3d(const vector3d<T>& start, const vector3d<T>& end) : start(start), end(end) {} - - // operators - - line3d<T> operator+(const vector3d<T>& point) const { return line3d<T>(start + point, end + point); } - line3d<T>& operator+=(const vector3d<T>& point) { start += point; end += point; return *this; } - - line3d<T> operator-(const vector3d<T>& point) const { return line3d<T>(start - point, end - point); } - line3d<T>& operator-=(const vector3d<T>& point) { start -= point; end -= point; return *this; } - - bool operator==(const line3d<T>& other) const - { return (start==other.start && end==other.end) || (end==other.start && start==other.end);} - bool operator!=(const line3d<T>& other) const - { return !(start==other.start && end==other.end) || (end==other.start && start==other.end);} - - // functions - //! Set this line to a new line going through the two points. - void setLine(const T& xa, const T& ya, const T& za, const T& xb, const T& yb, const T& zb) - {start.set(xa, ya, za); end.set(xb, yb, zb);} - //! Set this line to a new line going through the two points. - void setLine(const vector3d<T>& nstart, const vector3d<T>& nend) - {start.set(nstart); end.set(nend);} - //! Set this line to new line given as parameter. - void setLine(const line3d<T>& line) - {start.set(line.start); end.set(line.end);} - - //! Get length of line - /** \return Length of line. */ - T getLength() const { return start.getDistanceFrom(end); } - - //! Get squared length of line - /** \return Squared length of line. */ - T getLengthSQ() const { return start.getDistanceFromSQ(end); } - - //! Get middle of line - /** \return Center of line. */ - vector3d<T> getMiddle() const - { - return (start + end) * (T)0.5; - } - - //! Get vector of line - /** \return vector of line. */ - vector3d<T> getVector() const - { - return end - start; - } - - //! Check if the given point is between start and end of the line. - /** Assumes that the point is already somewhere on the line. - \param point The point to test. - \return True if point is on the line between start and end, else false. - */ - bool isPointBetweenStartAndEnd(const vector3d<T>& point) const - { - return point.isBetweenPoints(start, end); - } - - //! Get the closest point on this line to a point - /** \param point The point to compare to. - \return The nearest point which is part of the line. */ - vector3d<T> getClosestPoint(const vector3d<T>& point) const - { - vector3d<T> c = point - start; - vector3d<T> v = end - start; - T d = (T)v.getLength(); - v /= d; - T t = v.dotProduct(c); - - if (t < (T)0.0) - return start; - if (t > d) - return end; - - v *= t; - return start + v; - } - - //! Check if the line intersects with a shpere - /** \param sorigin: Origin of the shpere. - \param sradius: Radius of the sphere. - \param outdistance: The distance to the first intersection point. - \return True if there is an intersection. - If there is one, the distance to the first intersection point - is stored in outdistance. */ - bool getIntersectionWithSphere(vector3d<T> sorigin, T sradius, f64& outdistance) const - { - const vector3d<T> q = sorigin - start; - T c = q.getLength(); - T v = q.dotProduct(getVector().normalize()); - T d = sradius * sradius - (c*c - v*v); - - if (d < 0.0) - return false; - - outdistance = v - core::squareroot ( d ); - return true; - } - - // member variables - - //! Start point of line - vector3d<T> start; - //! End point of line - vector3d<T> end; -}; - - //! Typedef for an f32 line. - typedef line3d<f32> line3df; - //! Typedef for an integer line. - typedef line3d<s32> line3di; - -} // end namespace core -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/matrix4.h b/irrlicht-1.6/include/matrix4.h deleted file mode 100644 index d50366b08..000000000 --- a/irrlicht-1.6/include/matrix4.h +++ /dev/null @@ -1,2114 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_MATRIX_H_INCLUDED__ -#define __IRR_MATRIX_H_INCLUDED__ - -#include "irrTypes.h" -#include "vector3d.h" -#include "vector2d.h" -#include "plane3d.h" -#include "aabbox3d.h" -#include "rect.h" -#include "irrString.h" - -// enable this to keep track of changes to the matrix -// and make simpler identity check for seldomly changing matrices -// otherwise identity check will always compare the elements -//#define USE_MATRIX_TEST - -// this is only for debugging purposes -//#define USE_MATRIX_TEST_DEBUG - -#if defined( USE_MATRIX_TEST_DEBUG ) - #include <windows.h> - - struct MatrixTest - { - MatrixTest () : ID(0), Calls(0) {} - char buf[256]; - int Calls; - int ID; - }; - static MatrixTest MTest; - -#endif - -namespace irr -{ -namespace core -{ - - //! 4x4 matrix. Mostly used as transformation matrix for 3d calculations. - /** The matrix is a D3D style matrix, row major with translations in the 4th row. */ - template <class T> - class CMatrix4 - { - public: - - //! Constructor Flags - enum eConstructor - { - EM4CONST_NOTHING = 0, - EM4CONST_COPY, - EM4CONST_IDENTITY, - EM4CONST_TRANSPOSED, - EM4CONST_INVERSE, - EM4CONST_INVERSE_TRANSPOSED - }; - - //! Default constructor - /** \param constructor Choose the initialization style */ - CMatrix4( eConstructor constructor = EM4CONST_IDENTITY ); - //! Copy constructor - /** \param other Other matrix to copy from - \param constructor Choose the initialization style */ - CMatrix4( const CMatrix4<T>& other,eConstructor constructor = EM4CONST_COPY); - - //! Simple operator for directly accessing every element of the matrix. - T& operator()(const s32 row, const s32 col) - { -#if defined ( USE_MATRIX_TEST ) - definitelyIdentityMatrix=false; -#endif - return M[ row * 4 + col ]; - } - - //! Simple operator for directly accessing every element of the matrix. - const T& operator()(const s32 row, const s32 col) const { return M[row * 4 + col]; } - - //! Simple operator for linearly accessing every element of the matrix. - T& operator[](u32 index) - { -#if defined ( USE_MATRIX_TEST ) - definitelyIdentityMatrix=false; -#endif - return M[index]; - } - - //! Simple operator for linearly accessing every element of the matrix. - const T& operator[](u32 index) const { return M[index]; } - - //! Sets this matrix equal to the other matrix. - inline CMatrix4<T>& operator=(const CMatrix4<T> &other); - - //! Sets all elements of this matrix to the value. - inline CMatrix4<T>& operator=(const T& scalar); - - //! Returns pointer to internal array - const T* pointer() const { return M; } - T* pointer() - { -#if defined ( USE_MATRIX_TEST ) - definitelyIdentityMatrix=false; -#endif - return M; - } - - //! Returns true if other matrix is equal to this matrix. - bool operator==(const CMatrix4<T> &other) const; - - //! Returns true if other matrix is not equal to this matrix. - bool operator!=(const CMatrix4<T> &other) const; - - //! Add another matrix. - CMatrix4<T> operator+(const CMatrix4<T>& other) const; - - //! Add another matrix. - CMatrix4<T>& operator+=(const CMatrix4<T>& other); - - //! Subtract another matrix. - CMatrix4<T> operator-(const CMatrix4<T>& other) const; - - //! Subtract another matrix. - CMatrix4<T>& operator-=(const CMatrix4<T>& other); - - //! set this matrix to the product of two matrices - inline CMatrix4<T>& setbyproduct(const CMatrix4<T>& other_a,const CMatrix4<T>& other_b ); - - //! Set this matrix to the product of two matrices - /** no optimization used, - use it if you know you never have a identity matrix */ - CMatrix4<T>& setbyproduct_nocheck(const CMatrix4<T>& other_a,const CMatrix4<T>& other_b ); - - //! Multiply by another matrix. - CMatrix4<T> operator*(const CMatrix4<T>& other) const; - - //! Multiply by another matrix. - CMatrix4<T>& operator*=(const CMatrix4<T>& other); - - //! Multiply by scalar. - CMatrix4<T> operator*(const T& scalar) const; - - //! Multiply by scalar. - CMatrix4<T>& operator*=(const T& scalar); - - //! Set matrix to identity. - inline CMatrix4<T>& makeIdentity(); - - //! Returns true if the matrix is the identity matrix - inline bool isIdentity() const; - - //! Returns true if the matrix is orthogonal - inline bool isOrthogonal() const; - - //! Returns true if the matrix is the identity matrix - bool isIdentity_integer_base () const; - - //! Set the translation of the current matrix. Will erase any previous values. - CMatrix4<T>& setTranslation( const vector3d<T>& translation ); - - //! Gets the current translation - vector3d<T> getTranslation() const; - - //! Set the inverse translation of the current matrix. Will erase any previous values. - CMatrix4<T>& setInverseTranslation( const vector3d<T>& translation ); - - //! Make a rotation matrix from Euler angles. The 4th row and column are unmodified. - inline CMatrix4<T>& setRotationRadians( const vector3d<T>& rotation ); - - //! Make a rotation matrix from Euler angles. The 4th row and column are unmodified. - CMatrix4<T>& setRotationDegrees( const vector3d<T>& rotation ); - - //! Returns the rotation, as set by setRotation(). - /** This code was orginally written by by Chev. */ - core::vector3d<T> getRotationDegrees() const; - - //! Make an inverted rotation matrix from Euler angles. - /** The 4th row and column are unmodified. */ - inline CMatrix4<T>& setInverseRotationRadians( const vector3d<T>& rotation ); - - //! Make an inverted rotation matrix from Euler angles. - /** The 4th row and column are unmodified. */ - CMatrix4<T>& setInverseRotationDegrees( const vector3d<T>& rotation ); - - //! Set Scale - CMatrix4<T>& setScale( const vector3d<T>& scale ); - - //! Set Scale - CMatrix4<T>& setScale( const T scale ) { return setScale(core::vector3d<T>(scale,scale,scale)); } - - //! Get Scale - core::vector3d<T> getScale() const; - - //! Translate a vector by the inverse of the translation part of this matrix. - void inverseTranslateVect( vector3df& vect ) const; - - //! Rotate a vector by the inverse of the rotation part of this matrix. - void inverseRotateVect( vector3df& vect ) const; - - //! Rotate a vector by the rotation part of this matrix. - void rotateVect( vector3df& vect ) const; - - //! An alternate transform vector method, writing into a second vector - void rotateVect(core::vector3df& out, const core::vector3df& in) const; - - //! An alternate transform vector method, writing into an array of 3 floats - void rotateVect(T *out,const core::vector3df &in) const; - - //! Transforms the vector by this matrix - void transformVect( vector3df& vect) const; - - //! Transforms input vector by this matrix and stores result in output vector - void transformVect( vector3df& out, const vector3df& in ) const; - - //! An alternate transform vector method, writing into an array of 4 floats - void transformVect(T *out,const core::vector3df &in) const; - - //! Translate a vector by the translation part of this matrix. - void translateVect( vector3df& vect ) const; - - //! Transforms a plane by this matrix - void transformPlane( core::plane3d<f32> &plane) const; - - //! Transforms a plane by this matrix - void transformPlane( const core::plane3d<f32> &in, core::plane3d<f32> &out) const; - - //! Transforms a axis aligned bounding box - /** The result box of this operation may not be accurate at all. For - correct results, use transformBoxEx() */ - void transformBox(core::aabbox3d<f32>& box) const; - - //! Transforms a axis aligned bounding box - /** The result box of this operation should by accurate, but this operation - is slower than transformBox(). */ - void transformBoxEx(core::aabbox3d<f32>& box) const; - - //! Multiplies this matrix by a 1x4 matrix - void multiplyWith1x4Matrix(T* matrix) const; - - //! Calculates inverse of matrix. Slow. - /** \return Returns false if there is no inverse matrix.*/ - bool makeInverse(); - - - //! Inverts a primitive matrix which only contains a translation and a rotation - /** \param out: where result matrix is written to. */ - bool getInversePrimitive ( CMatrix4<T>& out ) const; - - //! Gets the inversed matrix of this one - /** \param out: where result matrix is written to. - \return Returns false if there is no inverse matrix. */ - bool getInverse(CMatrix4<T>& out) const; - - //! Builds a right-handed perspective projection matrix based on a field of view - CMatrix4<T>& buildProjectionMatrixPerspectiveFovRH(f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar); - - //! Builds a left-handed perspective projection matrix based on a field of view - CMatrix4<T>& buildProjectionMatrixPerspectiveFovLH(f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar); - - //! Builds a right-handed perspective projection matrix. - CMatrix4<T>& buildProjectionMatrixPerspectiveRH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar); - - //! Builds a left-handed perspective projection matrix. - CMatrix4<T>& buildProjectionMatrixPerspectiveLH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar); - - //! Builds a left-handed orthogonal projection matrix. - CMatrix4<T>& buildProjectionMatrixOrthoLH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar); - - //! Builds a right-handed orthogonal projection matrix. - CMatrix4<T>& buildProjectionMatrixOrthoRH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar); - - //! Builds a left-handed look-at matrix. - CMatrix4<T>& buildCameraLookAtMatrixLH( - const vector3df& position, - const vector3df& target, - const vector3df& upVector); - - //! Builds a right-handed look-at matrix. - CMatrix4<T>& buildCameraLookAtMatrixRH( - const vector3df& position, - const vector3df& target, - const vector3df& upVector); - - //! Builds a matrix that flattens geometry into a plane. - /** \param light: light source - \param plane: plane into which the geometry if flattened into - \param point: value between 0 and 1, describing the light source. - If this is 1, it is a point light, if it is 0, it is a directional light. */ - CMatrix4<T>& buildShadowMatrix(const core::vector3df& light, core::plane3df plane, f32 point=1.0f); - - //! Builds a matrix which transforms a normalized Device Coordinate to Device Coordinates. - /** Used to scale <-1,-1><1,1> to viewport, for example from von <-1,-1> <1,1> to the viewport <0,0><0,640> */ - CMatrix4<T>& buildNDCToDCMatrix( const core::rect<s32>& area, f32 zScale); - - //! Creates a new matrix as interpolated matrix from two other ones. - /** \param b: other matrix to interpolate with - \param time: Must be a value between 0 and 1. */ - CMatrix4<T> interpolate(const core::CMatrix4<T>& b, f32 time) const; - - //! Gets transposed matrix - CMatrix4<T> getTransposed() const; - - //! Gets transposed matrix - inline void getTransposed( CMatrix4<T>& dest ) const; - - //! Builds a matrix that rotates from one vector to another - /** \param from: vector to rotate from - \param to: vector to rotate to - */ - CMatrix4<T>& buildRotateFromTo(const core::vector3df& from, const core::vector3df& to); - - //! Builds a combined matrix which translate to a center before rotation and translate afterwards - /** \param from: vector to rotate from - \param to: vector to rotate to - */ - void setRotationCenter(const core::vector3df& center, const core::vector3df& translate); - - //! Builds a matrix which rotates a source vector to a look vector over an arbitrary axis - /** \param camPos: viewer position in world coo - \param center: object position in world-coo and rotation pivot - \param translation: object final translation from center - \param axis: axis to rotate about - \param from: source vector to rotate from - */ - void buildAxisAlignedBillboard( const core::vector3df& camPos, - const core::vector3df& center, - const core::vector3df& translation, - const core::vector3df& axis, - const core::vector3df& from - ); - - /* - construct 2D Texture transformations - rotate about center, scale, and transform. - */ - //! Set to a texture transformation matrix with the given parameters. - CMatrix4<T>& buildTextureTransform( f32 rotateRad, - const core::vector2df &rotatecenter, - const core::vector2df &translate, - const core::vector2df &scale); - - //! Set texture transformation rotation - /** Rotate about z axis, recenter at (0.5,0.5). - Doesn't clear other elements than those affected - \param radAngle Angle in radians - \return Altered matrix */ - CMatrix4<T>& setTextureRotationCenter( f32 radAngle ); - - //! Set texture transformation translation - /** Doesn't clear other elements than those affected. - \param x Offset on x axis - \param y Offset on y axis - \return Altered matrix */ - CMatrix4<T>& setTextureTranslate( f32 x, f32 y ); - - //! Set texture transformation translation, using a transposed representation - /** Doesn't clear other elements than those affected. - \param x Offset on x axis - \param y Offset on y axis - \return Altered matrix */ - CMatrix4<T>& setTextureTranslateTransposed( f32 x, f32 y ); - - //! Set texture transformation scale - /** Doesn't clear other elements than those affected. - \param sx Scale factor on x axis - \param sy Scale factor on y axis - \return Altered matrix. */ - CMatrix4<T>& setTextureScale( f32 sx, f32 sy ); - - //! Set texture transformation scale, and recenter at (0.5,0.5) - /** Doesn't clear other elements than those affected. - \param sx Scale factor on x axis - \param sy Scale factor on y axis - \return Altered matrix. */ - CMatrix4<T>& setTextureScaleCenter( f32 sx, f32 sy ); - - //! Sets all matrix data members at once - CMatrix4<T>& setM(const T* data); - - //! Sets if the matrix is definitely identity matrix - void setDefinitelyIdentityMatrix( bool isDefinitelyIdentityMatrix); - - //! Gets if the matrix is definitely identity matrix - bool getDefinitelyIdentityMatrix() const; - - private: - //! Matrix data, stored in row-major order - T M[16]; -#if defined ( USE_MATRIX_TEST ) - //! Flag is this matrix is identity matrix - mutable u32 definitelyIdentityMatrix; -#endif -#if defined ( USE_MATRIX_TEST_DEBUG ) - u32 id; - mutable u32 calls; -#endif - - }; - - // Default constructor - template <class T> - inline CMatrix4<T>::CMatrix4( eConstructor constructor ) -#if defined ( USE_MATRIX_TEST ) - : definitelyIdentityMatrix(BIT_UNTESTED) -#endif -#if defined ( USE_MATRIX_TEST_DEBUG ) - ,id ( MTest.ID++), calls ( 0 ) -#endif - { - switch ( constructor ) - { - case EM4CONST_NOTHING: - case EM4CONST_COPY: - break; - case EM4CONST_IDENTITY: - case EM4CONST_INVERSE: - default: - makeIdentity(); - break; - } - } - - // Copy constructor - template <class T> - inline CMatrix4<T>::CMatrix4( const CMatrix4<T>& other, eConstructor constructor) -#if defined ( USE_MATRIX_TEST ) - : definitelyIdentityMatrix(BIT_UNTESTED) -#endif -#if defined ( USE_MATRIX_TEST_DEBUG ) - ,id ( MTest.ID++), calls ( 0 ) -#endif - { - switch ( constructor ) - { - case EM4CONST_IDENTITY: - makeIdentity(); - break; - case EM4CONST_NOTHING: - break; - case EM4CONST_COPY: - *this = other; - break; - case EM4CONST_TRANSPOSED: - other.getTransposed(*this); - break; - case EM4CONST_INVERSE: - if (!other.getInverse(*this)) - memset(M, 0, 16*sizeof(T)); - break; - case EM4CONST_INVERSE_TRANSPOSED: - if (!other.getInverse(*this)) - memset(M, 0, 16*sizeof(T)); - else - *this=getTransposed(); - break; - } - } - - //! Add another matrix. - template <class T> - inline CMatrix4<T> CMatrix4<T>::operator+(const CMatrix4<T>& other) const - { - CMatrix4<T> temp ( EM4CONST_NOTHING ); - - temp[0] = M[0]+other[0]; - temp[1] = M[1]+other[1]; - temp[2] = M[2]+other[2]; - temp[3] = M[3]+other[3]; - temp[4] = M[4]+other[4]; - temp[5] = M[5]+other[5]; - temp[6] = M[6]+other[6]; - temp[7] = M[7]+other[7]; - temp[8] = M[8]+other[8]; - temp[9] = M[9]+other[9]; - temp[10] = M[10]+other[10]; - temp[11] = M[11]+other[11]; - temp[12] = M[12]+other[12]; - temp[13] = M[13]+other[13]; - temp[14] = M[14]+other[14]; - temp[15] = M[15]+other[15]; - - return temp; - } - - //! Add another matrix. - template <class T> - inline CMatrix4<T>& CMatrix4<T>::operator+=(const CMatrix4<T>& other) - { - M[0]+=other[0]; - M[1]+=other[1]; - M[2]+=other[2]; - M[3]+=other[3]; - M[4]+=other[4]; - M[5]+=other[5]; - M[6]+=other[6]; - M[7]+=other[7]; - M[8]+=other[8]; - M[9]+=other[9]; - M[10]+=other[10]; - M[11]+=other[11]; - M[12]+=other[12]; - M[13]+=other[13]; - M[14]+=other[14]; - M[15]+=other[15]; - - return *this; - } - - //! Subtract another matrix. - template <class T> - inline CMatrix4<T> CMatrix4<T>::operator-(const CMatrix4<T>& other) const - { - CMatrix4<T> temp ( EM4CONST_NOTHING ); - - temp[0] = M[0]-other[0]; - temp[1] = M[1]-other[1]; - temp[2] = M[2]-other[2]; - temp[3] = M[3]-other[3]; - temp[4] = M[4]-other[4]; - temp[5] = M[5]-other[5]; - temp[6] = M[6]-other[6]; - temp[7] = M[7]-other[7]; - temp[8] = M[8]-other[8]; - temp[9] = M[9]-other[9]; - temp[10] = M[10]-other[10]; - temp[11] = M[11]-other[11]; - temp[12] = M[12]-other[12]; - temp[13] = M[13]-other[13]; - temp[14] = M[14]-other[14]; - temp[15] = M[15]-other[15]; - - return temp; - } - - //! Subtract another matrix. - template <class T> - inline CMatrix4<T>& CMatrix4<T>::operator-=(const CMatrix4<T>& other) - { - M[0]-=other[0]; - M[1]-=other[1]; - M[2]-=other[2]; - M[3]-=other[3]; - M[4]-=other[4]; - M[5]-=other[5]; - M[6]-=other[6]; - M[7]-=other[7]; - M[8]-=other[8]; - M[9]-=other[9]; - M[10]-=other[10]; - M[11]-=other[11]; - M[12]-=other[12]; - M[13]-=other[13]; - M[14]-=other[14]; - M[15]-=other[15]; - - return *this; - } - - //! Multiply by scalar. - template <class T> - inline CMatrix4<T> CMatrix4<T>::operator*(const T& scalar) const - { - CMatrix4<T> temp ( EM4CONST_NOTHING ); - - temp[0] = M[0]*scalar; - temp[1] = M[1]*scalar; - temp[2] = M[2]*scalar; - temp[3] = M[3]*scalar; - temp[4] = M[4]*scalar; - temp[5] = M[5]*scalar; - temp[6] = M[6]*scalar; - temp[7] = M[7]*scalar; - temp[8] = M[8]*scalar; - temp[9] = M[9]*scalar; - temp[10] = M[10]*scalar; - temp[11] = M[11]*scalar; - temp[12] = M[12]*scalar; - temp[13] = M[13]*scalar; - temp[14] = M[14]*scalar; - temp[15] = M[15]*scalar; - - return temp; - } - - //! Multiply by scalar. - template <class T> - inline CMatrix4<T>& CMatrix4<T>::operator*=(const T& scalar) - { - M[0]*=scalar; - M[1]*=scalar; - M[2]*=scalar; - M[3]*=scalar; - M[4]*=scalar; - M[5]*=scalar; - M[6]*=scalar; - M[7]*=scalar; - M[8]*=scalar; - M[9]*=scalar; - M[10]*=scalar; - M[11]*=scalar; - M[12]*=scalar; - M[13]*=scalar; - M[14]*=scalar; - M[15]*=scalar; - - return *this; - } - - //! Multiply by another matrix. - template <class T> - inline CMatrix4<T>& CMatrix4<T>::operator*=(const CMatrix4<T>& other) - { -#if defined ( USE_MATRIX_TEST ) - // do checks on your own in order to avoid copy creation - if ( !other.isIdentity() ) - { - if ( this->isIdentity() ) - { - return (*this = other); - } - else - { - CMatrix4<T> temp ( *this ); - return setbyproduct_nocheck( temp, other ); - } - } - return *this; -#else - CMatrix4<T> temp ( *this ); - return setbyproduct_nocheck( temp, other ); -#endif - } - - //! multiply by another matrix - // set this matrix to the product of two other matrices - // goal is to reduce stack use and copy - template <class T> - inline CMatrix4<T>& CMatrix4<T>::setbyproduct_nocheck(const CMatrix4<T>& other_a,const CMatrix4<T>& other_b ) - { - const T *m1 = other_a.M; - const T *m2 = other_b.M; - - M[0] = m1[0]*m2[0] + m1[4]*m2[1] + m1[8]*m2[2] + m1[12]*m2[3]; - M[1] = m1[1]*m2[0] + m1[5]*m2[1] + m1[9]*m2[2] + m1[13]*m2[3]; - M[2] = m1[2]*m2[0] + m1[6]*m2[1] + m1[10]*m2[2] + m1[14]*m2[3]; - M[3] = m1[3]*m2[0] + m1[7]*m2[1] + m1[11]*m2[2] + m1[15]*m2[3]; - - M[4] = m1[0]*m2[4] + m1[4]*m2[5] + m1[8]*m2[6] + m1[12]*m2[7]; - M[5] = m1[1]*m2[4] + m1[5]*m2[5] + m1[9]*m2[6] + m1[13]*m2[7]; - M[6] = m1[2]*m2[4] + m1[6]*m2[5] + m1[10]*m2[6] + m1[14]*m2[7]; - M[7] = m1[3]*m2[4] + m1[7]*m2[5] + m1[11]*m2[6] + m1[15]*m2[7]; - - M[8] = m1[0]*m2[8] + m1[4]*m2[9] + m1[8]*m2[10] + m1[12]*m2[11]; - M[9] = m1[1]*m2[8] + m1[5]*m2[9] + m1[9]*m2[10] + m1[13]*m2[11]; - M[10] = m1[2]*m2[8] + m1[6]*m2[9] + m1[10]*m2[10] + m1[14]*m2[11]; - M[11] = m1[3]*m2[8] + m1[7]*m2[9] + m1[11]*m2[10] + m1[15]*m2[11]; - - M[12] = m1[0]*m2[12] + m1[4]*m2[13] + m1[8]*m2[14] + m1[12]*m2[15]; - M[13] = m1[1]*m2[12] + m1[5]*m2[13] + m1[9]*m2[14] + m1[13]*m2[15]; - M[14] = m1[2]*m2[12] + m1[6]*m2[13] + m1[10]*m2[14] + m1[14]*m2[15]; - M[15] = m1[3]*m2[12] + m1[7]*m2[13] + m1[11]*m2[14] + m1[15]*m2[15]; -#if defined ( USE_MATRIX_TEST ) - definitelyIdentityMatrix=false; -#endif - return *this; - } - - - //! multiply by another matrix - // set this matrix to the product of two other matrices - // goal is to reduce stack use and copy - template <class T> - inline CMatrix4<T>& CMatrix4<T>::setbyproduct(const CMatrix4<T>& other_a, const CMatrix4<T>& other_b ) - { -#if defined ( USE_MATRIX_TEST ) - if ( other_a.isIdentity () ) - return (*this = other_b); - else - if ( other_b.isIdentity () ) - return (*this = other_a); - else - return setbyproduct_nocheck(other_a,other_b); -#else - return setbyproduct_nocheck(other_a,other_b); -#endif - } - - //! multiply by another matrix - template <class T> - inline CMatrix4<T> CMatrix4<T>::operator*(const CMatrix4<T>& m2) const - { -#if defined ( USE_MATRIX_TEST ) - // Testing purpose.. - if ( this->isIdentity() ) - return m2; - if ( m2.isIdentity() ) - return *this; -#endif - - CMatrix4<T> m3 ( EM4CONST_NOTHING ); - - const T *m1 = M; - - m3[0] = m1[0]*m2[0] + m1[4]*m2[1] + m1[8]*m2[2] + m1[12]*m2[3]; - m3[1] = m1[1]*m2[0] + m1[5]*m2[1] + m1[9]*m2[2] + m1[13]*m2[3]; - m3[2] = m1[2]*m2[0] + m1[6]*m2[1] + m1[10]*m2[2] + m1[14]*m2[3]; - m3[3] = m1[3]*m2[0] + m1[7]*m2[1] + m1[11]*m2[2] + m1[15]*m2[3]; - - m3[4] = m1[0]*m2[4] + m1[4]*m2[5] + m1[8]*m2[6] + m1[12]*m2[7]; - m3[5] = m1[1]*m2[4] + m1[5]*m2[5] + m1[9]*m2[6] + m1[13]*m2[7]; - m3[6] = m1[2]*m2[4] + m1[6]*m2[5] + m1[10]*m2[6] + m1[14]*m2[7]; - m3[7] = m1[3]*m2[4] + m1[7]*m2[5] + m1[11]*m2[6] + m1[15]*m2[7]; - - m3[8] = m1[0]*m2[8] + m1[4]*m2[9] + m1[8]*m2[10] + m1[12]*m2[11]; - m3[9] = m1[1]*m2[8] + m1[5]*m2[9] + m1[9]*m2[10] + m1[13]*m2[11]; - m3[10] = m1[2]*m2[8] + m1[6]*m2[9] + m1[10]*m2[10] + m1[14]*m2[11]; - m3[11] = m1[3]*m2[8] + m1[7]*m2[9] + m1[11]*m2[10] + m1[15]*m2[11]; - - m3[12] = m1[0]*m2[12] + m1[4]*m2[13] + m1[8]*m2[14] + m1[12]*m2[15]; - m3[13] = m1[1]*m2[12] + m1[5]*m2[13] + m1[9]*m2[14] + m1[13]*m2[15]; - m3[14] = m1[2]*m2[12] + m1[6]*m2[13] + m1[10]*m2[14] + m1[14]*m2[15]; - m3[15] = m1[3]*m2[12] + m1[7]*m2[13] + m1[11]*m2[14] + m1[15]*m2[15]; - return m3; - } - - - - template <class T> - inline vector3d<T> CMatrix4<T>::getTranslation() const - { - return vector3d<T>(M[12], M[13], M[14]); - } - - - template <class T> - inline CMatrix4<T>& CMatrix4<T>::setTranslation( const vector3d<T>& translation ) - { - M[12] = translation.X; - M[13] = translation.Y; - M[14] = translation.Z; -#if defined ( USE_MATRIX_TEST ) - definitelyIdentityMatrix=false; -#endif - return *this; - } - - template <class T> - inline CMatrix4<T>& CMatrix4<T>::setInverseTranslation( const vector3d<T>& translation ) - { - M[12] = -translation.X; - M[13] = -translation.Y; - M[14] = -translation.Z; -#if defined ( USE_MATRIX_TEST ) - definitelyIdentityMatrix=false; -#endif - return *this; - } - - template <class T> - inline CMatrix4<T>& CMatrix4<T>::setScale( const vector3d<T>& scale ) - { - M[0] = scale.X; - M[5] = scale.Y; - M[10] = scale.Z; -#if defined ( USE_MATRIX_TEST ) - definitelyIdentityMatrix=false; -#endif - return *this; - } - - //! Returns the absolute values of the scales of the matrix. - /** - Note that this always returns the absolute (positive) values. Unfortunately it - does not appear to be possible to extract any original negative values. The best - that we could do would be to arbitrarily make one scale negative if one or three - of them were negative. - FIXME - return the original values. - */ - template <class T> - inline vector3d<T> CMatrix4<T>::getScale() const - { - // See http://www.robertblum.com/articles/2005/02/14/decomposing-matrices - - // Deal with the 0 rotation case first - // Prior to Irrlicht 1.6, we always returned this value. - if(core::iszero(M[1]) && core::iszero(M[2]) && - core::iszero(M[4]) && core::iszero(M[6]) && - core::iszero(M[8]) && core::iszero(M[9])) - return vector3d<T>(M[0], M[5], M[10]); - - // We have to do the full calculation. - return vector3d<T>(sqrtf(M[0] * M[0] + M[1] * M[1] + M[2] * M[2]), - sqrtf(M[4] * M[4] + M[5] * M[5] + M[6] * M[6]), - sqrtf(M[8] * M[8] + M[9] * M[9] + M[10] * M[10])); - } - - template <class T> - inline CMatrix4<T>& CMatrix4<T>::setRotationDegrees( const vector3d<T>& rotation ) - { - return setRotationRadians( rotation * core::DEGTORAD ); - } - - template <class T> - inline CMatrix4<T>& CMatrix4<T>::setInverseRotationDegrees( const vector3d<T>& rotation ) - { - return setInverseRotationRadians( rotation * core::DEGTORAD ); - } - - template <class T> - inline CMatrix4<T>& CMatrix4<T>::setRotationRadians( const vector3d<T>& rotation ) - { - const f64 cr = cos( rotation.X ); - const f64 sr = sin( rotation.X ); - const f64 cp = cos( rotation.Y ); - const f64 sp = sin( rotation.Y ); - const f64 cy = cos( rotation.Z ); - const f64 sy = sin( rotation.Z ); - - M[0] = (T)( cp*cy ); - M[1] = (T)( cp*sy ); - M[2] = (T)( -sp ); - - const f64 srsp = sr*sp; - const f64 crsp = cr*sp; - - M[4] = (T)( srsp*cy-cr*sy ); - M[5] = (T)( srsp*sy+cr*cy ); - M[6] = (T)( sr*cp ); - - M[8] = (T)( crsp*cy+sr*sy ); - M[9] = (T)( crsp*sy-sr*cy ); - M[10] = (T)( cr*cp ); -#if defined ( USE_MATRIX_TEST ) - definitelyIdentityMatrix=false; -#endif - return *this; - } - - - //! Returns a rotation that is equivalent to that set by setRotationDegrees(). - /** This code was sent in by Chev. Note that it does not necessarily return - the *same* Euler angles as those set by setRotationDegrees(), but the rotation will - be equivalent, i.e. will have the same result when used to rotate a vector or node. */ - template <class T> - inline core::vector3d<T> CMatrix4<T>::getRotationDegrees() const - { - const CMatrix4<T> &mat = *this; - - f64 Y = -asin(mat(0,2)); - const f64 C = cos(Y); - Y *= RADTODEG64; - - f64 rotx, roty, X, Z; - - if (fabs(C)>ROUNDING_ERROR_f64) - { - const T invC = (T)(1.0/C); - rotx = mat(2,2) * invC; - roty = mat(1,2) * invC; - X = atan2( roty, rotx ) * RADTODEG64; - rotx = mat(0,0) * invC; - roty = mat(0,1) * invC; - Z = atan2( roty, rotx ) * RADTODEG64; - } - else - { - X = 0.0; - rotx = mat(1,1); - roty = -mat(1,0); - Z = atan2( roty, rotx ) * RADTODEG64; - } - - // fix values that get below zero - // before it would set (!) values to 360 - // that where above 360: - if (X < 0.0) X += 360.0; - if (Y < 0.0) Y += 360.0; - if (Z < 0.0) Z += 360.0; - - return vector3d<T>((T)X,(T)Y,(T)Z); - } - - - template <class T> - inline CMatrix4<T>& CMatrix4<T>::setInverseRotationRadians( const vector3d<T>& rotation ) - { - f64 cr = cos( rotation.X ); - f64 sr = sin( rotation.X ); - f64 cp = cos( rotation.Y ); - f64 sp = sin( rotation.Y ); - f64 cy = cos( rotation.Z ); - f64 sy = sin( rotation.Z ); - - M[0] = (T)( cp*cy ); - M[4] = (T)( cp*sy ); - M[8] = (T)( -sp ); - - f64 srsp = sr*sp; - f64 crsp = cr*sp; - - M[1] = (T)( srsp*cy-cr*sy ); - M[5] = (T)( srsp*sy+cr*cy ); - M[9] = (T)( sr*cp ); - - M[2] = (T)( crsp*cy+sr*sy ); - M[6] = (T)( crsp*sy-sr*cy ); - M[10] = (T)( cr*cp ); -#if defined ( USE_MATRIX_TEST ) - definitelyIdentityMatrix=false; -#endif - return *this; - } - - - /*! - */ - template <class T> - inline CMatrix4<T>& CMatrix4<T>::makeIdentity() - { - memset(M, 0, 16*sizeof(T)); - M[0] = M[5] = M[10] = M[15] = (T)1; -#if defined ( USE_MATRIX_TEST ) - definitelyIdentityMatrix=true; -#endif - return *this; - } - - - /* - check identity with epsilon - solve floating range problems.. - */ - template <class T> - inline bool CMatrix4<T>::isIdentity() const - { -#if defined ( USE_MATRIX_TEST ) - if (definitelyIdentityMatrix) - return true; -#endif - if (!equals( M[ 0], (T)1 ) || - !equals( M[ 5], (T)1 ) || - !equals( M[10], (T)1 ) || - !equals( M[15], (T)1 )) - return false; - - for (s32 i=0; i<4; ++i) - for (s32 j=0; j<4; ++j) - if ((j != i) && (!iszero((*this)(i,j)))) - return false; - -#if defined ( USE_MATRIX_TEST ) - definitelyIdentityMatrix=true; -#endif - return true; - } - - - /* Check orthogonality of matrix. */ - template <class T> - inline bool CMatrix4<T>::isOrthogonal() const - { - T dp=M[0] * M[4 ] + M[1] * M[5 ] + M[2 ] * M[6 ] + M[3 ] * M[7 ]; - if (!iszero(dp)) - return false; - dp = M[0] * M[8 ] + M[1] * M[9 ] + M[2 ] * M[10] + M[3 ] * M[11]; - if (!iszero(dp)) - return false; - dp = M[0] * M[12] + M[1] * M[13] + M[2 ] * M[14] + M[3 ] * M[15]; - if (!iszero(dp)) - return false; - dp = M[4] * M[8 ] + M[5] * M[9 ] + M[6 ] * M[10] + M[7 ] * M[11]; - if (!iszero(dp)) - return false; - dp = M[4] * M[12] + M[5] * M[13] + M[6 ] * M[14] + M[7 ] * M[15]; - if (!iszero(dp)) - return false; - dp = M[8] * M[12] + M[9] * M[13] + M[10] * M[14] + M[11] * M[15]; - return (iszero(dp)); - } - - - /* - doesn't solve floating range problems.. - but takes care on +/- 0 on translation because we are changing it.. - reducing floating point branches - but it needs the floats in memory.. - */ - template <class T> - inline bool CMatrix4<T>::isIdentity_integer_base() const - { -#if defined ( USE_MATRIX_TEST ) - if (definitelyIdentityMatrix) - return true; -#endif - if(IR(M[0])!=F32_VALUE_1) return false; - if(IR(M[1])!=0) return false; - if(IR(M[2])!=0) return false; - if(IR(M[3])!=0) return false; - - if(IR(M[4])!=0) return false; - if(IR(M[5])!=F32_VALUE_1) return false; - if(IR(M[6])!=0) return false; - if(IR(M[7])!=0) return false; - - if(IR(M[8])!=0) return false; - if(IR(M[9])!=0) return false; - if(IR(M[10])!=F32_VALUE_1) return false; - if(IR(M[11])!=0) return false; - - if(IR(M[12])!=0) return false; - if(IR(M[13])!=0) return false; - if(IR(M[13])!=0) return false; - if(IR(M[15])!=F32_VALUE_1) return false; - -#if defined ( USE_MATRIX_TEST ) - definitelyIdentityMatrix=true; -#endif - return true; - } - - - template <class T> - inline void CMatrix4<T>::rotateVect( vector3df& vect ) const - { - vector3df tmp = vect; - vect.X = tmp.X*M[0] + tmp.Y*M[4] + tmp.Z*M[8]; - vect.Y = tmp.X*M[1] + tmp.Y*M[5] + tmp.Z*M[9]; - vect.Z = tmp.X*M[2] + tmp.Y*M[6] + tmp.Z*M[10]; - } - - //! An alternate transform vector method, writing into a second vector - template <class T> - inline void CMatrix4<T>::rotateVect(core::vector3df& out, const core::vector3df& in) const - { - out.X = in.X*M[0] + in.Y*M[4] + in.Z*M[8]; - out.Y = in.X*M[1] + in.Y*M[5] + in.Z*M[9]; - out.Z = in.X*M[2] + in.Y*M[6] + in.Z*M[10]; - } - - //! An alternate transform vector method, writing into an array of 3 floats - template <class T> - inline void CMatrix4<T>::rotateVect(T *out, const core::vector3df& in) const - { - out[0] = in.X*M[0] + in.Y*M[4] + in.Z*M[8]; - out[1] = in.X*M[1] + in.Y*M[5] + in.Z*M[9]; - out[2] = in.X*M[2] + in.Y*M[6] + in.Z*M[10]; - } - - template <class T> - inline void CMatrix4<T>::inverseRotateVect( vector3df& vect ) const - { - vector3df tmp = vect; - vect.X = tmp.X*M[0] + tmp.Y*M[1] + tmp.Z*M[2]; - vect.Y = tmp.X*M[4] + tmp.Y*M[5] + tmp.Z*M[6]; - vect.Z = tmp.X*M[8] + tmp.Y*M[9] + tmp.Z*M[10]; - } - - template <class T> - inline void CMatrix4<T>::transformVect( vector3df& vect) const - { - f32 vector[3]; - - vector[0] = vect.X*M[0] + vect.Y*M[4] + vect.Z*M[8] + M[12]; - vector[1] = vect.X*M[1] + vect.Y*M[5] + vect.Z*M[9] + M[13]; - vector[2] = vect.X*M[2] + vect.Y*M[6] + vect.Z*M[10] + M[14]; - - vect.X = vector[0]; - vect.Y = vector[1]; - vect.Z = vector[2]; - } - - template <class T> - inline void CMatrix4<T>::transformVect( vector3df& out, const vector3df& in) const - { - out.X = in.X*M[0] + in.Y*M[4] + in.Z*M[8] + M[12]; - out.Y = in.X*M[1] + in.Y*M[5] + in.Z*M[9] + M[13]; - out.Z = in.X*M[2] + in.Y*M[6] + in.Z*M[10] + M[14]; - } - - - template <class T> - inline void CMatrix4<T>::transformVect(T *out, const core::vector3df &in) const - { - out[0] = in.X*M[0] + in.Y*M[4] + in.Z*M[8] + M[12]; - out[1] = in.X*M[1] + in.Y*M[5] + in.Z*M[9] + M[13]; - out[2] = in.X*M[2] + in.Y*M[6] + in.Z*M[10] + M[14]; - out[3] = in.X*M[3] + in.Y*M[7] + in.Z*M[11] + M[15]; - } - - - //! Transforms a plane by this matrix - template <class T> - inline void CMatrix4<T>::transformPlane( core::plane3d<f32> &plane) const - { - vector3df member; - // Transform the plane member point, i.e. rotate, translate and scale it. - transformVect(member, plane.getMemberPoint()); - - // Transform the normal by the transposed inverse of the matrix - CMatrix4<T> transposedInverse(*this, EM4CONST_INVERSE_TRANSPOSED); - vector3df normal = plane.Normal; - transposedInverse.transformVect(normal); - - plane.setPlane(member, normal); - } - - //! Transforms a plane by this matrix - template <class T> - inline void CMatrix4<T>::transformPlane( const core::plane3d<f32> &in, core::plane3d<f32> &out) const - { - out = in; - transformPlane( out ); - } - - //! Transforms a axis aligned bounding box - template <class T> - inline void CMatrix4<T>::transformBox(core::aabbox3d<f32>& box) const - { -#if defined ( USE_MATRIX_TEST ) - if (isIdentity()) - return; -#endif - - transformVect(box.MinEdge); - transformVect(box.MaxEdge); - box.repair(); - } - - //! Transforms a axis aligned bounding box more accurately than transformBox() - template <class T> - inline void CMatrix4<T>::transformBoxEx(core::aabbox3d<f32>& box) const - { -#if defined ( USE_MATRIX_TEST ) - if (isIdentity()) - return; -#endif - - const f32 Amin[3] = {box.MinEdge.X, box.MinEdge.Y, box.MinEdge.Z}; - const f32 Amax[3] = {box.MaxEdge.X, box.MaxEdge.Y, box.MaxEdge.Z}; - - f32 Bmin[3]; - f32 Bmax[3]; - - Bmin[0] = Bmax[0] = M[12]; - Bmin[1] = Bmax[1] = M[13]; - Bmin[2] = Bmax[2] = M[14]; - - const CMatrix4<T> &m = *this; - - for (u32 i = 0; i < 3; ++i) - { - for (u32 j = 0; j < 3; ++j) - { - const f32 a = m(j,i) * Amin[j]; - const f32 b = m(j,i) * Amax[j]; - - if (a < b) - { - Bmin[i] += a; - Bmax[i] += b; - } - else - { - Bmin[i] += b; - Bmax[i] += a; - } - } - } - - box.MinEdge.X = Bmin[0]; - box.MinEdge.Y = Bmin[1]; - box.MinEdge.Z = Bmin[2]; - - box.MaxEdge.X = Bmax[0]; - box.MaxEdge.Y = Bmax[1]; - box.MaxEdge.Z = Bmax[2]; - } - - - //! Multiplies this matrix by a 1x4 matrix - template <class T> - inline void CMatrix4<T>::multiplyWith1x4Matrix(T* matrix) const - { - /* - 0 1 2 3 - 4 5 6 7 - 8 9 10 11 - 12 13 14 15 - */ - - T mat[4]; - mat[0] = matrix[0]; - mat[1] = matrix[1]; - mat[2] = matrix[2]; - mat[3] = matrix[3]; - - matrix[0] = M[0]*mat[0] + M[4]*mat[1] + M[8]*mat[2] + M[12]*mat[3]; - matrix[1] = M[1]*mat[0] + M[5]*mat[1] + M[9]*mat[2] + M[13]*mat[3]; - matrix[2] = M[2]*mat[0] + M[6]*mat[1] + M[10]*mat[2] + M[14]*mat[3]; - matrix[3] = M[3]*mat[0] + M[7]*mat[1] + M[11]*mat[2] + M[15]*mat[3]; - } - - template <class T> - inline void CMatrix4<T>::inverseTranslateVect( vector3df& vect ) const - { - vect.X = vect.X-M[12]; - vect.Y = vect.Y-M[13]; - vect.Z = vect.Z-M[14]; - } - - template <class T> - inline void CMatrix4<T>::translateVect( vector3df& vect ) const - { - vect.X = vect.X+M[12]; - vect.Y = vect.Y+M[13]; - vect.Z = vect.Z+M[14]; - } - - - template <class T> - inline bool CMatrix4<T>::getInverse(CMatrix4<T>& out) const - { - /// Calculates the inverse of this Matrix - /// The inverse is calculated using Cramers rule. - /// If no inverse exists then 'false' is returned. - -#if defined ( USE_MATRIX_TEST ) - if ( this->isIdentity() ) - { - out=*this; - return true; - } -#endif - const CMatrix4<T> &m = *this; - - f32 d = (m(0, 0) * m(1, 1) - m(0, 1) * m(1, 0)) * (m(2, 2) * m(3, 3) - m(2, 3) * m(3, 2)) - - (m(0, 0) * m(1, 2) - m(0, 2) * m(1, 0)) * (m(2, 1) * m(3, 3) - m(2, 3) * m(3, 1)) + - (m(0, 0) * m(1, 3) - m(0, 3) * m(1, 0)) * (m(2, 1) * m(3, 2) - m(2, 2) * m(3, 1)) + - (m(0, 1) * m(1, 2) - m(0, 2) * m(1, 1)) * (m(2, 0) * m(3, 3) - m(2, 3) * m(3, 0)) - - (m(0, 1) * m(1, 3) - m(0, 3) * m(1, 1)) * (m(2, 0) * m(3, 2) - m(2, 2) * m(3, 0)) + - (m(0, 2) * m(1, 3) - m(0, 3) * m(1, 2)) * (m(2, 0) * m(3, 1) - m(2, 1) * m(3, 0)); - - if( core::iszero ( d ) ) - return false; - - d = core::reciprocal ( d ); - - out(0, 0) = d * (m(1, 1) * (m(2, 2) * m(3, 3) - m(2, 3) * m(3, 2)) + - m(1, 2) * (m(2, 3) * m(3, 1) - m(2, 1) * m(3, 3)) + - m(1, 3) * (m(2, 1) * m(3, 2) - m(2, 2) * m(3, 1))); - out(0, 1) = d * (m(2, 1) * (m(0, 2) * m(3, 3) - m(0, 3) * m(3, 2)) + - m(2, 2) * (m(0, 3) * m(3, 1) - m(0, 1) * m(3, 3)) + - m(2, 3) * (m(0, 1) * m(3, 2) - m(0, 2) * m(3, 1))); - out(0, 2) = d * (m(3, 1) * (m(0, 2) * m(1, 3) - m(0, 3) * m(1, 2)) + - m(3, 2) * (m(0, 3) * m(1, 1) - m(0, 1) * m(1, 3)) + - m(3, 3) * (m(0, 1) * m(1, 2) - m(0, 2) * m(1, 1))); - out(0, 3) = d * (m(0, 1) * (m(1, 3) * m(2, 2) - m(1, 2) * m(2, 3)) + - m(0, 2) * (m(1, 1) * m(2, 3) - m(1, 3) * m(2, 1)) + - m(0, 3) * (m(1, 2) * m(2, 1) - m(1, 1) * m(2, 2))); - out(1, 0) = d * (m(1, 2) * (m(2, 0) * m(3, 3) - m(2, 3) * m(3, 0)) + - m(1, 3) * (m(2, 2) * m(3, 0) - m(2, 0) * m(3, 2)) + - m(1, 0) * (m(2, 3) * m(3, 2) - m(2, 2) * m(3, 3))); - out(1, 1) = d * (m(2, 2) * (m(0, 0) * m(3, 3) - m(0, 3) * m(3, 0)) + - m(2, 3) * (m(0, 2) * m(3, 0) - m(0, 0) * m(3, 2)) + - m(2, 0) * (m(0, 3) * m(3, 2) - m(0, 2) * m(3, 3))); - out(1, 2) = d * (m(3, 2) * (m(0, 0) * m(1, 3) - m(0, 3) * m(1, 0)) + - m(3, 3) * (m(0, 2) * m(1, 0) - m(0, 0) * m(1, 2)) + - m(3, 0) * (m(0, 3) * m(1, 2) - m(0, 2) * m(1, 3))); - out(1, 3) = d * (m(0, 2) * (m(1, 3) * m(2, 0) - m(1, 0) * m(2, 3)) + - m(0, 3) * (m(1, 0) * m(2, 2) - m(1, 2) * m(2, 0)) + - m(0, 0) * (m(1, 2) * m(2, 3) - m(1, 3) * m(2, 2))); - out(2, 0) = d * (m(1, 3) * (m(2, 0) * m(3, 1) - m(2, 1) * m(3, 0)) + - m(1, 0) * (m(2, 1) * m(3, 3) - m(2, 3) * m(3, 1)) + - m(1, 1) * (m(2, 3) * m(3, 0) - m(2, 0) * m(3, 3))); - out(2, 1) = d * (m(2, 3) * (m(0, 0) * m(3, 1) - m(0, 1) * m(3, 0)) + - m(2, 0) * (m(0, 1) * m(3, 3) - m(0, 3) * m(3, 1)) + - m(2, 1) * (m(0, 3) * m(3, 0) - m(0, 0) * m(3, 3))); - out(2, 2) = d * (m(3, 3) * (m(0, 0) * m(1, 1) - m(0, 1) * m(1, 0)) + - m(3, 0) * (m(0, 1) * m(1, 3) - m(0, 3) * m(1, 1)) + - m(3, 1) * (m(0, 3) * m(1, 0) - m(0, 0) * m(1, 3))); - out(2, 3) = d * (m(0, 3) * (m(1, 1) * m(2, 0) - m(1, 0) * m(2, 1)) + - m(0, 0) * (m(1, 3) * m(2, 1) - m(1, 1) * m(2, 3)) + - m(0, 1) * (m(1, 0) * m(2, 3) - m(1, 3) * m(2, 0))); - out(3, 0) = d * (m(1, 0) * (m(2, 2) * m(3, 1) - m(2, 1) * m(3, 2)) + - m(1, 1) * (m(2, 0) * m(3, 2) - m(2, 2) * m(3, 0)) + - m(1, 2) * (m(2, 1) * m(3, 0) - m(2, 0) * m(3, 1))); - out(3, 1) = d * (m(2, 0) * (m(0, 2) * m(3, 1) - m(0, 1) * m(3, 2)) + - m(2, 1) * (m(0, 0) * m(3, 2) - m(0, 2) * m(3, 0)) + - m(2, 2) * (m(0, 1) * m(3, 0) - m(0, 0) * m(3, 1))); - out(3, 2) = d * (m(3, 0) * (m(0, 2) * m(1, 1) - m(0, 1) * m(1, 2)) + - m(3, 1) * (m(0, 0) * m(1, 2) - m(0, 2) * m(1, 0)) + - m(3, 2) * (m(0, 1) * m(1, 0) - m(0, 0) * m(1, 1))); - out(3, 3) = d * (m(0, 0) * (m(1, 1) * m(2, 2) - m(1, 2) * m(2, 1)) + - m(0, 1) * (m(1, 2) * m(2, 0) - m(1, 0) * m(2, 2)) + - m(0, 2) * (m(1, 0) * m(2, 1) - m(1, 1) * m(2, 0))); - -#if defined ( USE_MATRIX_TEST ) - out.definitelyIdentityMatrix = definitelyIdentityMatrix; -#endif - return true; - } - - - //! Inverts a primitive matrix which only contains a translation and a rotation - //! \param out: where result matrix is written to. - template <class T> - inline bool CMatrix4<T>::getInversePrimitive ( CMatrix4<T>& out ) const - { - out.M[0 ] = M[0]; - out.M[1 ] = M[4]; - out.M[2 ] = M[8]; - out.M[3 ] = 0; - - out.M[4 ] = M[1]; - out.M[5 ] = M[5]; - out.M[6 ] = M[9]; - out.M[7 ] = 0; - - out.M[8 ] = M[2]; - out.M[9 ] = M[6]; - out.M[10] = M[10]; - out.M[11] = 0; - - out.M[12] = (T)-(M[12]*M[0] + M[13]*M[1] + M[14]*M[2]); - out.M[13] = (T)-(M[12]*M[4] + M[13]*M[5] + M[14]*M[6]); - out.M[14] = (T)-(M[12]*M[8] + M[13]*M[9] + M[14]*M[10]); - out.M[15] = 1; - -#if defined ( USE_MATRIX_TEST ) - out.definitelyIdentityMatrix = definitelyIdentityMatrix; -#endif - return true; - } - - /*! - */ - template <class T> - inline bool CMatrix4<T>::makeInverse() - { -#if defined ( USE_MATRIX_TEST ) - if (definitelyIdentityMatrix) - return true; -#endif - CMatrix4<T> temp ( EM4CONST_NOTHING ); - - if (getInverse(temp)) - { - *this = temp; - return true; - } - - return false; - } - - - template <class T> - inline CMatrix4<T>& CMatrix4<T>::operator=(const CMatrix4<T> &other) - { - if (this==&other) - return *this; - memcpy(M, other.M, 16*sizeof(T)); -#if defined ( USE_MATRIX_TEST ) - definitelyIdentityMatrix=other.definitelyIdentityMatrix; -#endif - return *this; - } - - - template <class T> - inline CMatrix4<T>& CMatrix4<T>::operator=(const T& scalar) - { - for (s32 i = 0; i < 16; ++i) - M[i]=scalar; - -#if defined ( USE_MATRIX_TEST ) - definitelyIdentityMatrix=false; -#endif - return *this; - } - - - template <class T> - inline bool CMatrix4<T>::operator==(const CMatrix4<T> &other) const - { -#if defined ( USE_MATRIX_TEST ) - if (definitelyIdentityMatrix && other.definitelyIdentityMatrix) - return true; -#endif - for (s32 i = 0; i < 16; ++i) - if (M[i] != other.M[i]) - return false; - - return true; - } - - - template <class T> - inline bool CMatrix4<T>::operator!=(const CMatrix4<T> &other) const - { - return !(*this == other); - } - - - // Builds a right-handed perspective projection matrix based on a field of view - template <class T> - inline CMatrix4<T>& CMatrix4<T>::buildProjectionMatrixPerspectiveFovRH( - f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar) - { - const f64 h = reciprocal(tan(fieldOfViewRadians*0.5)); - _IRR_DEBUG_BREAK_IF(aspectRatio==0.f); //divide by zero - const T w = h / aspectRatio; - - _IRR_DEBUG_BREAK_IF(zNear==zFar); //divide by zero - M[0] = w; - M[1] = 0; - M[2] = 0; - M[3] = 0; - - M[4] = 0; - M[5] = (T)h; - M[6] = 0; - M[7] = 0; - - M[8] = 0; - M[9] = 0; - M[10] = (T)(zFar/(zNear-zFar)); // DirectX version -// M[10] = (T)(zFar+zNear/(zNear-zFar)); // OpenGL version - M[11] = -1; - - M[12] = 0; - M[13] = 0; - M[14] = (T)(zNear*zFar/(zNear-zFar)); // DirectX version -// M[14] = (T)(2.0f*zNear*zFar/(zNear-zFar)); // OpenGL version - M[15] = 0; - -#if defined ( USE_MATRIX_TEST ) - definitelyIdentityMatrix=false; -#endif - return *this; - } - - - // Builds a left-handed perspective projection matrix based on a field of view - template <class T> - inline CMatrix4<T>& CMatrix4<T>::buildProjectionMatrixPerspectiveFovLH( - f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar) - { - const f64 h = reciprocal(tan(fieldOfViewRadians*0.5)); - _IRR_DEBUG_BREAK_IF(aspectRatio==0.f); //divide by zero - const T w = (T)(h / aspectRatio); - - _IRR_DEBUG_BREAK_IF(zNear==zFar); //divide by zero - M[0] = w; - M[1] = 0; - M[2] = 0; - M[3] = 0; - - M[4] = 0; - M[5] = (T)h; - M[6] = 0; - M[7] = 0; - - M[8] = 0; - M[9] = 0; - M[10] = (T)(zFar/(zFar-zNear)); - M[11] = 1; - - M[12] = 0; - M[13] = 0; - M[14] = (T)(-zNear*zFar/(zFar-zNear)); - M[15] = 0; - -#if defined ( USE_MATRIX_TEST ) - definitelyIdentityMatrix=false; -#endif - return *this; - } - - - // Builds a left-handed orthogonal projection matrix. - template <class T> - inline CMatrix4<T>& CMatrix4<T>::buildProjectionMatrixOrthoLH( - f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar) - { - _IRR_DEBUG_BREAK_IF(widthOfViewVolume==0.f); //divide by zero - _IRR_DEBUG_BREAK_IF(heightOfViewVolume==0.f); //divide by zero - _IRR_DEBUG_BREAK_IF(zNear==zFar); //divide by zero - M[0] = (T)(2/widthOfViewVolume); - M[1] = 0; - M[2] = 0; - M[3] = 0; - - M[4] = 0; - M[5] = (T)(2/heightOfViewVolume); - M[6] = 0; - M[7] = 0; - - M[8] = 0; - M[9] = 0; - M[10] = (T)(1/(zFar-zNear)); - M[11] = 0; - - M[12] = 0; - M[13] = 0; - M[14] = (T)(zNear/(zNear-zFar)); - M[15] = 1; - -#if defined ( USE_MATRIX_TEST ) - definitelyIdentityMatrix=false; -#endif - return *this; - } - - - // Builds a right-handed orthogonal projection matrix. - template <class T> - inline CMatrix4<T>& CMatrix4<T>::buildProjectionMatrixOrthoRH( - f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar) - { - _IRR_DEBUG_BREAK_IF(widthOfViewVolume==0.f); //divide by zero - _IRR_DEBUG_BREAK_IF(heightOfViewVolume==0.f); //divide by zero - _IRR_DEBUG_BREAK_IF(zNear==zFar); //divide by zero - M[0] = (T)(2/widthOfViewVolume); - M[1] = 0; - M[2] = 0; - M[3] = 0; - - M[4] = 0; - M[5] = (T)(2/heightOfViewVolume); - M[6] = 0; - M[7] = 0; - - M[8] = 0; - M[9] = 0; - M[10] = (T)(1/(zNear-zFar)); - M[11] = 0; - - M[12] = 0; - M[13] = 0; - M[14] = (T)(zNear/(zNear-zFar)); - M[15] = -1; - -#if defined ( USE_MATRIX_TEST ) - definitelyIdentityMatrix=false; -#endif - return *this; - } - - - // Builds a right-handed perspective projection matrix. - template <class T> - inline CMatrix4<T>& CMatrix4<T>::buildProjectionMatrixPerspectiveRH( - f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar) - { - _IRR_DEBUG_BREAK_IF(widthOfViewVolume==0.f); //divide by zero - _IRR_DEBUG_BREAK_IF(heightOfViewVolume==0.f); //divide by zero - _IRR_DEBUG_BREAK_IF(zNear==zFar); //divide by zero - M[0] = (T)(2*zNear/widthOfViewVolume); - M[1] = 0; - M[2] = 0; - M[3] = 0; - - M[4] = 0; - M[5] = (T)(2*zNear/heightOfViewVolume); - M[6] = 0; - M[7] = 0; - - M[8] = 0; - M[9] = 0; - M[10] = (T)(zFar/(zNear-zFar)); - M[11] = -1; - - M[12] = 0; - M[13] = 0; - M[14] = (T)(zNear*zFar/(zNear-zFar)); - M[15] = 0; - -#if defined ( USE_MATRIX_TEST ) - definitelyIdentityMatrix=false; -#endif - return *this; - } - - - // Builds a left-handed perspective projection matrix. - template <class T> - inline CMatrix4<T>& CMatrix4<T>::buildProjectionMatrixPerspectiveLH( - f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar) - { - _IRR_DEBUG_BREAK_IF(widthOfViewVolume==0.f); //divide by zero - _IRR_DEBUG_BREAK_IF(heightOfViewVolume==0.f); //divide by zero - _IRR_DEBUG_BREAK_IF(zNear==zFar); //divide by zero - M[0] = (T)(2*zNear/widthOfViewVolume); - M[1] = 0; - M[2] = 0; - M[3] = 0; - - M[4] = 0; - M[5] = (T)(2*zNear/heightOfViewVolume); - M[6] = 0; - M[7] = 0; - - M[8] = 0; - M[9] = 0; - M[10] = (T)(zFar/(zFar-zNear)); - M[11] = 1; - - M[12] = 0; - M[13] = 0; - M[14] = (T)(zNear*zFar/(zNear-zFar)); - M[15] = 0; -#if defined ( USE_MATRIX_TEST ) - definitelyIdentityMatrix=false; -#endif - return *this; - } - - - // Builds a matrix that flattens geometry into a plane. - template <class T> - inline CMatrix4<T>& CMatrix4<T>::buildShadowMatrix(const core::vector3df& light, core::plane3df plane, f32 point) - { - plane.Normal.normalize(); - const f32 d = plane.Normal.dotProduct(light); - - M[ 0] = (T)(-plane.Normal.X * light.X + d); - M[ 1] = (T)(-plane.Normal.X * light.Y); - M[ 2] = (T)(-plane.Normal.X * light.Z); - M[ 3] = (T)(-plane.Normal.X * point); - - M[ 4] = (T)(-plane.Normal.Y * light.X); - M[ 5] = (T)(-plane.Normal.Y * light.Y + d); - M[ 6] = (T)(-plane.Normal.Y * light.Z); - M[ 7] = (T)(-plane.Normal.Y * point); - - M[ 8] = (T)(-plane.Normal.Z * light.X); - M[ 9] = (T)(-plane.Normal.Z * light.Y); - M[10] = (T)(-plane.Normal.Z * light.Z + d); - M[11] = (T)(-plane.Normal.Z * point); - - M[12] = (T)(-plane.D * light.X); - M[13] = (T)(-plane.D * light.Y); - M[14] = (T)(-plane.D * light.Z); - M[15] = (T)(-plane.D * point + d); -#if defined ( USE_MATRIX_TEST ) - definitelyIdentityMatrix=false; -#endif - return *this; - } - - // Builds a left-handed look-at matrix. - template <class T> - inline CMatrix4<T>& CMatrix4<T>::buildCameraLookAtMatrixLH( - const vector3df& position, - const vector3df& target, - const vector3df& upVector) - { - vector3df zaxis = target - position; - zaxis.normalize(); - - vector3df xaxis = upVector.crossProduct(zaxis); - xaxis.normalize(); - - vector3df yaxis = zaxis.crossProduct(xaxis); - - M[0] = (T)xaxis.X; - M[1] = (T)yaxis.X; - M[2] = (T)zaxis.X; - M[3] = 0; - - M[4] = (T)xaxis.Y; - M[5] = (T)yaxis.Y; - M[6] = (T)zaxis.Y; - M[7] = 0; - - M[8] = (T)xaxis.Z; - M[9] = (T)yaxis.Z; - M[10] = (T)zaxis.Z; - M[11] = 0; - - M[12] = (T)-xaxis.dotProduct(position); - M[13] = (T)-yaxis.dotProduct(position); - M[14] = (T)-zaxis.dotProduct(position); - M[15] = 1; -#if defined ( USE_MATRIX_TEST ) - definitelyIdentityMatrix=false; -#endif - return *this; - } - - - // Builds a right-handed look-at matrix. - template <class T> - inline CMatrix4<T>& CMatrix4<T>::buildCameraLookAtMatrixRH( - const vector3df& position, - const vector3df& target, - const vector3df& upVector) - { - vector3df zaxis = position - target; - zaxis.normalize(); - - vector3df xaxis = upVector.crossProduct(zaxis); - xaxis.normalize(); - - vector3df yaxis = zaxis.crossProduct(xaxis); - - M[0] = (T)xaxis.X; - M[1] = (T)yaxis.X; - M[2] = (T)zaxis.X; - M[3] = 0; - - M[4] = (T)xaxis.Y; - M[5] = (T)yaxis.Y; - M[6] = (T)zaxis.Y; - M[7] = 0; - - M[8] = (T)xaxis.Z; - M[9] = (T)yaxis.Z; - M[10] = (T)zaxis.Z; - M[11] = 0; - - M[12] = (T)-xaxis.dotProduct(position); - M[13] = (T)-yaxis.dotProduct(position); - M[14] = (T)-zaxis.dotProduct(position); - M[15] = 1; -#if defined ( USE_MATRIX_TEST ) - definitelyIdentityMatrix=false; -#endif - return *this; - } - - - // creates a new matrix as interpolated matrix from this and the passed one. - template <class T> - inline CMatrix4<T> CMatrix4<T>::interpolate(const core::CMatrix4<T>& b, f32 time) const - { - CMatrix4<T> mat ( EM4CONST_NOTHING ); - - for (u32 i=0; i < 16; i += 4) - { - mat.M[i+0] = (T)(M[i+0] + ( b.M[i+0] - M[i+0] ) * time); - mat.M[i+1] = (T)(M[i+1] + ( b.M[i+1] - M[i+1] ) * time); - mat.M[i+2] = (T)(M[i+2] + ( b.M[i+2] - M[i+2] ) * time); - mat.M[i+3] = (T)(M[i+3] + ( b.M[i+3] - M[i+3] ) * time); - } - return mat; - } - - - // returns transposed matrix - template <class T> - inline CMatrix4<T> CMatrix4<T>::getTransposed() const - { - CMatrix4<T> t ( EM4CONST_NOTHING ); - getTransposed ( t ); - return t; - } - - - // returns transposed matrix - template <class T> - inline void CMatrix4<T>::getTransposed( CMatrix4<T>& o ) const - { - o[ 0] = M[ 0]; - o[ 1] = M[ 4]; - o[ 2] = M[ 8]; - o[ 3] = M[12]; - - o[ 4] = M[ 1]; - o[ 5] = M[ 5]; - o[ 6] = M[ 9]; - o[ 7] = M[13]; - - o[ 8] = M[ 2]; - o[ 9] = M[ 6]; - o[10] = M[10]; - o[11] = M[14]; - - o[12] = M[ 3]; - o[13] = M[ 7]; - o[14] = M[11]; - o[15] = M[15]; -#if defined ( USE_MATRIX_TEST ) - o.definitelyIdentityMatrix=definitelyIdentityMatrix; -#endif - } - - - // used to scale <-1,-1><1,1> to viewport - template <class T> - inline CMatrix4<T>& CMatrix4<T>::buildNDCToDCMatrix( const core::rect<s32>& viewport, f32 zScale) - { - const f32 scaleX = (viewport.getWidth() - 0.75f ) * 0.5f; - const f32 scaleY = -(viewport.getHeight() - 0.75f ) * 0.5f; - - const f32 dx = -0.5f + ( (viewport.UpperLeftCorner.X + viewport.LowerRightCorner.X ) * 0.5f ); - const f32 dy = -0.5f + ( (viewport.UpperLeftCorner.Y + viewport.LowerRightCorner.Y ) * 0.5f ); - - makeIdentity(); - M[12] = (T)dx; - M[13] = (T)dy; - return setScale(core::vector3d<T>((T)scaleX, (T)scaleY, (T)zScale)); - } - - //! Builds a matrix that rotates from one vector to another - /** \param from: vector to rotate from - \param to: vector to rotate to - - http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToMatrix/index.htm - */ - template <class T> - inline CMatrix4<T>& CMatrix4<T>::buildRotateFromTo(const core::vector3df& from, const core::vector3df& to) - { - // unit vectors - core::vector3df f ( from ); - core::vector3df t ( to ); - f.normalize (); - t.normalize (); - - // axis multiplication by sin - core::vector3df vs ( t.crossProduct ( f ) ); - - // axis of rotation - core::vector3df v ( vs ); - v.normalize(); - - // cosinus angle - T ca = f.dotProduct ( t ); - - core::vector3df vt ( v * ( (T) 1 - ca ) ); - - M[0] = vt.X * v.X + ca; - M[5] = vt.Y * v.Y + ca; - M[10] = vt.Z * v.Z + ca; - - vt.X *= v.Y; - vt.Z *= v.X; - vt.Y *= v.Z; - - M[1] = vt.X - vs.Z; - M[2] = vt.Z + vs.Y; - M[3] = (T) 0; - - M[4] = vt.X + vs.Z; - M[6] = vt.Y - vs.X; - M[7] = (T) 0; - - M[8] = vt.Z - vs.Y; - M[9] = vt.Y + vs.X; - M[11] = (T) 0; - - M[12] = (T) 0; - M[13] = (T) 0; - M[14] = (T) 0; - M[15] = (T) 1; - - return *this; - } - - //! Builds a matrix which rotates a source vector to a look vector over an arbitrary axis - /** \param camPos: viewer position in world coo - \param center: object position in world-coo and rotation pivot - \param translation: object final translation from center - \param axis: axis to rotate about - \param from: source vector to rotate from - */ - template <class T> - inline void CMatrix4<T>::buildAxisAlignedBillboard( const core::vector3df& camPos, - const core::vector3df& center, - const core::vector3df& translation, - const core::vector3df& axis, - const core::vector3df& from - ) - { - // axis of rotation - core::vector3df up = axis; - up.normalize (); - - core::vector3df forward = camPos - center; - forward.normalize(); - - core::vector3df right = up.crossProduct ( forward ); - right.normalize (); - - // correct look vector - core::vector3df look = right.crossProduct ( up ); - - // rotate from to - - // axis multiplication by sin - core::vector3df vs = look.crossProduct ( from ); - - // cosinus angle - f32 ca = from.dotProduct ( look ); - - core::vector3df vt ( up * ( 1.f - ca ) ); - - M[0] = vt.X * up.X + ca; - M[5] = vt.Y * up.Y + ca; - M[10] = vt.Z * up.Z + ca; - - vt.X *= up.Y; - vt.Z *= up.X; - vt.Y *= up.Z; - - M[1] = vt.X - vs.Z; - M[2] = vt.Z + vs.Y; - M[3] = (T) 0; - - M[4] = vt.X + vs.Z; - M[6] = vt.Y - vs.X; - M[7] = (T) 0; - - M[8] = vt.Z - vs.Y; - M[9] = vt.Y + vs.X; - M[11] = (T) 0; - - setRotationCenter ( center, translation ); - - } - - - //! Builds a combined matrix which translate to a center before rotation and translate afterwards - /** \param from: vector to rotate from - \param to: vector to rotate to - */ - template <class T> - inline void CMatrix4<T>::setRotationCenter(const core::vector3df& center, const core::vector3df& translation) - { - M[12] = -M[0]*center.X - M[4]*center.Y - M[8]*center.Z + (center.X - translation.X ); - M[13] = -M[1]*center.X - M[5]*center.Y - M[9]*center.Z + (center.Y - translation.Y ); - M[14] = -M[2]*center.X - M[6]*center.Y - M[10]*center.Z + (center.Z - translation.Z ); - M[15] = (T) 1.0; -#if defined ( USE_MATRIX_TEST ) - definitelyIdentityMatrix=false; -#endif - } - - /*! - Generate texture coordinates as linear functions so that: - u = Ux*x + Uy*y + Uz*z + Uw - v = Vx*x + Vy*y + Vz*z + Vw - The matrix M for this case is: - Ux Vx 0 0 - Uy Vy 0 0 - Uz Vz 0 0 - Uw Vw 0 0 - */ - - - template <class T> - inline CMatrix4<T>& CMatrix4<T>::buildTextureTransform( f32 rotateRad, - const core::vector2df &rotatecenter, - const core::vector2df &translate, - const core::vector2df &scale) - { - const f32 c = cosf(rotateRad); - const f32 s = sinf(rotateRad); - - M[0] = (T)(c * scale.X); - M[1] = (T)(s * scale.Y); - M[2] = 0; - M[3] = 0; - - M[4] = (T)(-s * scale.X); - M[5] = (T)(c * scale.Y); - M[6] = 0; - M[7] = 0; - - M[8] = (T)(c * scale.X * rotatecenter.X + -s * rotatecenter.Y + translate.X); - M[9] = (T)(s * scale.Y * rotatecenter.X + c * rotatecenter.Y + translate.Y); - M[10] = 1; - M[11] = 0; - - M[12] = 0; - M[13] = 0; - M[14] = 0; - M[15] = 1; -#if defined ( USE_MATRIX_TEST ) - definitelyIdentityMatrix=false; -#endif - return *this; - } - - - // rotate about z axis, center ( 0.5, 0.5 ) - template <class T> - inline CMatrix4<T>& CMatrix4<T>::setTextureRotationCenter( f32 rotateRad ) - { - const f32 c = cosf(rotateRad); - const f32 s = sinf(rotateRad); - M[0] = (T)c; - M[1] = (T)s; - - M[4] = (T)-s; - M[5] = (T)c; - - M[8] = (T)(0.5f * ( s - c) + 0.5f); - M[9] = (T)(-0.5f * ( s + c) + 0.5f); - -#if defined ( USE_MATRIX_TEST ) - definitelyIdentityMatrix = definitelyIdentityMatrix && (rotateRad==0.0f); -#endif - return *this; - } - - - template <class T> - inline CMatrix4<T>& CMatrix4<T>::setTextureTranslate ( f32 x, f32 y ) - { - M[8] = (T)x; - M[9] = (T)y; - -#if defined ( USE_MATRIX_TEST ) - definitelyIdentityMatrix = definitelyIdentityMatrix && (x==0.0f) && (y==0.0f); -#endif - return *this; - } - - - template <class T> - inline CMatrix4<T>& CMatrix4<T>::setTextureTranslateTransposed ( f32 x, f32 y ) - { - M[2] = (T)x; - M[6] = (T)y; - -#if defined ( USE_MATRIX_TEST ) - definitelyIdentityMatrix = definitelyIdentityMatrix && (x==0.0f) && (y==0.0f) ; -#endif - return *this; - } - - template <class T> - inline CMatrix4<T>& CMatrix4<T>::setTextureScale ( f32 sx, f32 sy ) - { - M[0] = (T)sx; - M[5] = (T)sy; -#if defined ( USE_MATRIX_TEST ) - definitelyIdentityMatrix = definitelyIdentityMatrix && (sx==1.0f) && (sy==1.0f); -#endif - return *this; - } - - - template <class T> - inline CMatrix4<T>& CMatrix4<T>::setTextureScaleCenter( f32 sx, f32 sy ) - { - M[0] = (T)sx; - M[5] = (T)sy; - M[8] = (T)(0.5f - 0.5f * sx); - M[9] = (T)(0.5f - 0.5f * sy); - -#if defined ( USE_MATRIX_TEST ) - definitelyIdentityMatrix = definitelyIdentityMatrix && (sx==1.0f) && (sy==1.0f); -#endif - return *this; - } - - - // sets all matrix data members at once - template <class T> - inline CMatrix4<T>& CMatrix4<T>::setM(const T* data) - { - memcpy(M,data, 16*sizeof(T)); - -#if defined ( USE_MATRIX_TEST ) - definitelyIdentityMatrix=false; -#endif - return *this; - } - - - // sets if the matrix is definitely identity matrix - template <class T> - inline void CMatrix4<T>::setDefinitelyIdentityMatrix( bool isDefinitelyIdentityMatrix) - { -#if defined ( USE_MATRIX_TEST ) - definitelyIdentityMatrix = isDefinitelyIdentityMatrix; -#endif - } - - - // gets if the matrix is definitely identity matrix - template <class T> - inline bool CMatrix4<T>::getDefinitelyIdentityMatrix() const - { -#if defined ( USE_MATRIX_TEST ) - return definitelyIdentityMatrix; -#else - return false; -#endif - } - - - // Multiply by scalar. - template <class T> - inline CMatrix4<T> operator*(const T scalar, const CMatrix4<T>& mat) - { - return mat*scalar; - } - - - //! Typedef for f32 matrix - typedef CMatrix4<f32> matrix4; - - //! global const identity matrix - IRRLICHT_API extern const matrix4 IdentityMatrix; - -} // end namespace core -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/path.h b/irrlicht-1.6/include/path.h deleted file mode 100644 index 8cb7e4fac..000000000 --- a/irrlicht-1.6/include/path.h +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine" and the "irrXML" project. -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_PATH_H_INCLUDED__ -#define __IRR_PATH_H_INCLUDED__ - -#include "irrString.h" - -namespace irr -{ -namespace io -{ - -typedef core::string<fschar_t> path; - -} // io -} // irr - -#endif // __IRR_PATH_H_INCLUDED__ diff --git a/irrlicht-1.6/include/plane3d.h b/irrlicht-1.6/include/plane3d.h deleted file mode 100644 index becf50a3c..000000000 --- a/irrlicht-1.6/include/plane3d.h +++ /dev/null @@ -1,240 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_PLANE_3D_H_INCLUDED__ -#define __IRR_PLANE_3D_H_INCLUDED__ - -#include "irrMath.h" -#include "vector3d.h" - -namespace irr -{ -namespace core -{ - -//! Enumeration for intersection relations of 3d objects -enum EIntersectionRelation3D -{ - ISREL3D_FRONT = 0, - ISREL3D_BACK, - ISREL3D_PLANAR, - ISREL3D_SPANNING, - ISREL3D_CLIPPED -}; - -//! Template plane class with some intersection testing methods. -template <class T> -class plane3d -{ - public: - - // Constructors - - plane3d(): Normal(0,1,0) { recalculateD(vector3d<T>(0,0,0)); } - - plane3d(const vector3d<T>& MPoint, const vector3d<T>& Normal) : Normal(Normal) { recalculateD(MPoint); } - - plane3d(T px, T py, T pz, T nx, T ny, T nz) : Normal(nx, ny, nz) { recalculateD(vector3d<T>(px, py, pz)); } - - plane3d(const vector3d<T>& point1, const vector3d<T>& point2, const vector3d<T>& point3) - { setPlane(point1, point2, point3); } - - plane3d(const vector3d<T> & normal, const T d) : Normal(normal), D(d) { } - - // operators - - inline bool operator==(const plane3d<T>& other) const { return (equals(D, other.D) && Normal==other.Normal);} - - inline bool operator!=(const plane3d<T>& other) const { return !(*this == other);} - - // functions - - void setPlane(const vector3d<T>& point, const vector3d<T>& nvector) - { - Normal = nvector; - recalculateD(point); - } - - void setPlane(const vector3d<T>& nvect, T d) - { - Normal = nvect; - D = d; - } - - void setPlane(const vector3d<T>& point1, const vector3d<T>& point2, const vector3d<T>& point3) - { - // creates the plane from 3 memberpoints - Normal = (point2 - point1).crossProduct(point3 - point1); - Normal.normalize(); - - recalculateD(point1); - } - - - //! Get an intersection with a 3d line. - /** \param lineVect Vector of the line to intersect with. - \param linePoint Point of the line to intersect with. - \param outIntersection Place to store the intersection point, if there is one. - \return True if there was an intersection, false if there was not. - */ - bool getIntersectionWithLine(const vector3d<T>& linePoint, - const vector3d<T>& lineVect, - vector3d<T>& outIntersection) const - { - T t2 = Normal.dotProduct(lineVect); - - if (t2 == 0) - return false; - - T t =- (Normal.dotProduct(linePoint) + D) / t2; - outIntersection = linePoint + (lineVect * t); - return true; - } - - //! Get percentage of line between two points where an intersection with this plane happens. - /** Only useful if known that there is an intersection. - \param linePoint1 Point1 of the line to intersect with. - \param linePoint2 Point2 of the line to intersect with. - \return Where on a line between two points an intersection with this plane happened. - For example, 0.5 is returned if the intersection happened exactly in the middle of the two points. - */ - f32 getKnownIntersectionWithLine(const vector3d<T>& linePoint1, - const vector3d<T>& linePoint2) const - { - vector3d<T> vect = linePoint2 - linePoint1; - T t2 = (f32)Normal.dotProduct(vect); - return (f32)-((Normal.dotProduct(linePoint1) + D) / t2); - } - - //! Get an intersection with a 3d line, limited between two 3d points. - /** \param linePoint1 Point 1 of the line. - \param linePoint2 Point 2 of the line. - \param outIntersection Place to store the intersection point, if there is one. - \return True if there was an intersection, false if there was not. - */ - bool getIntersectionWithLimitedLine( - const vector3d<T>& linePoint1, - const vector3d<T>& linePoint2, - vector3d<T>& outIntersection) const - { - return (getIntersectionWithLine(linePoint1, linePoint2 - linePoint1, outIntersection) && - outIntersection.isBetweenPoints(linePoint1, linePoint2)); - } - - //! Classifies the relation of a point to this plane. - /** \param point Point to classify its relation. - \return ISREL3D_FRONT if the point is in front of the plane, - ISREL3D_BACK if the point is behind of the plane, and - ISREL3D_PLANAR if the point is within the plane. */ - EIntersectionRelation3D classifyPointRelation(const vector3d<T>& point) const - { - const T d = Normal.dotProduct(point) + D; - - if (d < -ROUNDING_ERROR_f32) - return ISREL3D_BACK; - - if (d > ROUNDING_ERROR_f32) - return ISREL3D_FRONT; - - return ISREL3D_PLANAR; - } - - //! Recalculates the distance from origin by applying a new member point to the plane. - void recalculateD(const vector3d<T>& MPoint) - { - D = - MPoint.dotProduct(Normal); - } - - //! Gets a member point of the plane. - vector3d<T> getMemberPoint() const - { - return Normal * -D; - } - - //! Tests if there is an intersection with the other plane - /** \return True if there is a intersection. */ - bool existsIntersection(const plane3d<T>& other) const - { - vector3d<T> cross = other.Normal.crossProduct(Normal); - return cross.getLength() > core::ROUNDING_ERROR_f32; - } - - //! Intersects this plane with another. - /** \param other Other plane to intersect with. - \param outLinePoint Base point of intersection line. - \param outLineVect Vector of intersection. - \return True if there is a intersection, false if not. */ - bool getIntersectionWithPlane(const plane3d<T>& other, - vector3d<T>& outLinePoint, - vector3d<T>& outLineVect) const - { - const T fn00 = Normal.getLength(); - const T fn01 = Normal.dotProduct(other.Normal); - const T fn11 = other.Normal.getLength(); - const f64 det = fn00*fn11 - fn01*fn01; - - if (fabs(det) < ROUNDING_ERROR_f64 ) - return false; - - const f64 invdet = 1.0 / det; - const f64 fc0 = (fn11*-D + fn01*other.D) * invdet; - const f64 fc1 = (fn00*-other.D + fn01*D) * invdet; - - outLineVect = Normal.crossProduct(other.Normal); - outLinePoint = Normal*(T)fc0 + other.Normal*(T)fc1; - return true; - } - - //! Get the intersection point with two other planes if there is one. - bool getIntersectionWithPlanes(const plane3d<T>& o1, - const plane3d<T>& o2, vector3d<T>& outPoint) const - { - vector3d<T> linePoint, lineVect; - if (getIntersectionWithPlane(o1, linePoint, lineVect)) - return o2.getIntersectionWithLine(linePoint, lineVect, outPoint); - - return false; - } - - //! Test if the triangle would be front or backfacing from any point. - /** Thus, this method assumes a camera position from - which the triangle is definitely visible when looking into - the given direction. - Note that this only works if the normal is Normalized. - Do not use this method with points as it will give wrong results! - \param lookDirection: Look direction. - \return True if the plane is front facing and - false if it is backfacing. */ - bool isFrontFacing(const vector3d<T>& lookDirection) const - { - const f32 d = Normal.dotProduct(lookDirection); - return F32_LOWER_EQUAL_0 ( d ); - } - - //! Get the distance to a point. - /** Note that this only works if the normal is normalized. */ - T getDistanceTo(const vector3d<T>& point) const - { - return point.dotProduct(Normal) + D; - } - - //! Normal vector of the plane. - vector3d<T> Normal; - - //! Distance from origin. - T D; -}; - - -//! Typedef for a f32 3d plane. -typedef plane3d<f32> plane3df; - -//! Typedef for an integer 3d plane. -typedef plane3d<s32> plane3di; - -} // end namespace core -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/position2d.h b/irrlicht-1.6/include/position2d.h deleted file mode 100644 index d2854c268..000000000 --- a/irrlicht-1.6/include/position2d.h +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -//! As of Irrlicht 1.6, position2d is a synonym for vector2d. -/** You should consider position2d to be deprecated, and use vector2d by preference. */ - -#ifndef __IRR_POSITION_H_INCLUDED__ -#define __IRR_POSITION_H_INCLUDED__ - -#include "vector2d.h" - -namespace irr -{ -namespace core -{ -// Use typedefs where possible as they are more explicit... - -//! \deprecated position2d is now a synonym for vector2d, but vector2d should be used directly. -typedef vector2d<f32> position2df; - -//! \deprecated position2d is now a synonym for vector2d, but vector2d should be used directly. -typedef vector2d<s32> position2di; -}; // namespace core -}; // namespace irr - -// ...and use a #define to catch the rest, for (e.g.) position2d<f64> -#define position2d vector2d - -#endif // __IRR_POSITION_H_INCLUDED__ diff --git a/irrlicht-1.6/include/quaternion.h b/irrlicht-1.6/include/quaternion.h deleted file mode 100644 index 568db4019..000000000 --- a/irrlicht-1.6/include/quaternion.h +++ /dev/null @@ -1,617 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_QUATERNION_H_INCLUDED__ -#define __IRR_QUATERNION_H_INCLUDED__ - -#include "irrTypes.h" -#include "irrMath.h" -#include "matrix4.h" -#include "vector3d.h" - -namespace irr -{ -namespace core -{ - -//! Quaternion class for representing rotations. -/** It provides cheap combinations and avoids gimbal locks. -Also useful for interpolations. */ -class quaternion -{ - public: - - //! Default Constructor - quaternion() : X(0.0f), Y(0.0f), Z(0.0f), W(1.0f) {} - - //! Constructor - quaternion(f32 x, f32 y, f32 z, f32 w) : X(x), Y(y), Z(z), W(w) { } - - //! Constructor which converts euler angles (radians) to a quaternion - quaternion(f32 x, f32 y, f32 z); - - //! Constructor which converts euler angles (radians) to a quaternion - quaternion(const vector3df& vec); - - //! Constructor which converts a matrix to a quaternion - quaternion(const matrix4& mat); - - //! Equalilty operator - bool operator==(const quaternion& other) const; - - //! Assignment operator - inline quaternion& operator=(const quaternion& other); - - //! Matrix assignment operator - inline quaternion& operator=(const matrix4& other); - - //! Add operator - quaternion operator+(const quaternion& other) const; - - //! Multiplication operator - quaternion operator*(const quaternion& other) const; - - //! Multiplication operator with scalar - quaternion operator*(f32 s) const; - - //! Multiplication operator with scalar - quaternion& operator*=(f32 s); - - //! Multiplication operator - vector3df operator*(const vector3df& v) const; - - //! Multiplication operator - quaternion& operator*=(const quaternion& other); - - //! Calculates the dot product - inline f32 dotProduct(const quaternion& other) const; - - //! Sets new quaternion - inline quaternion& set(f32 x, f32 y, f32 z, f32 w); - - //! Sets new quaternion based on euler angles (radians) - inline quaternion& set(f32 x, f32 y, f32 z); - - //! Sets new quaternion based on euler angles (radians) - inline quaternion& set(const core::vector3df& vec); - - //! Normalizes the quaternion - inline quaternion& normalize(); - - //! Creates a matrix from this quaternion - matrix4 getMatrix() const; - - //! Creates a matrix from this quaternion - void getMatrix( matrix4 &dest, const vector3df &translation ) const; - - /*! - Creates a matrix from this quaternion - Rotate about a center point - shortcut for - core::quaternion q; - q.rotationFromTo ( vin[i].Normal, forward ); - q.getMatrixCenter ( lookat, center, newPos ); - - core::matrix4 m2; - m2.setInverseTranslation ( center ); - lookat *= m2; - - core::matrix4 m3; - m2.setTranslation ( newPos ); - lookat *= m3; - - */ - void getMatrixCenter( matrix4 &dest, const vector3df ¢er, const vector3df &translation ) const; - - //! Creates a matrix from this quaternion - inline void getMatrix_transposed( matrix4 &dest ) const; - - //! Inverts this quaternion - quaternion& makeInverse(); - - //! Set this quaternion to the result of the interpolation between two quaternions - quaternion& slerp( quaternion q1, quaternion q2, f32 interpolate ); - - //! Create quaternion from rotation angle and rotation axis. - /** Axis must be unit length. - The quaternion representing the rotation is - q = cos(A/2)+sin(A/2)*(x*i+y*j+z*k). - \param angle Rotation Angle in radians. - \param axis Rotation axis. */ - quaternion& fromAngleAxis (f32 angle, const vector3df& axis); - - //! Fills an angle (radians) around an axis (unit vector) - void toAngleAxis (f32 &angle, core::vector3df& axis) const; - - //! Output this quaternion to an euler angle (radians) - void toEuler(vector3df& euler) const; - - //! Set quaternion to identity - quaternion& makeIdentity(); - - //! Set quaternion to represent a rotation from one vector to another. - quaternion& rotationFromTo(const vector3df& from, const vector3df& to); - - //! Quaternion elements. - f32 X; // vectorial (imaginary) part - f32 Y; - f32 Z; - f32 W; // real part -}; - - -// Constructor which converts euler angles to a quaternion -inline quaternion::quaternion(f32 x, f32 y, f32 z) -{ - set(x,y,z); -} - - -// Constructor which converts euler angles to a quaternion -inline quaternion::quaternion(const vector3df& vec) -{ - set(vec.X,vec.Y,vec.Z); -} - - -// Constructor which converts a matrix to a quaternion -inline quaternion::quaternion(const matrix4& mat) -{ - (*this) = mat; -} - - -// equal operator -inline bool quaternion::operator==(const quaternion& other) const -{ - return ((X == other.X) && - (Y == other.Y) && - (Z == other.Z) && - (W == other.W)); -} - - -// assignment operator -inline quaternion& quaternion::operator=(const quaternion& other) -{ - X = other.X; - Y = other.Y; - Z = other.Z; - W = other.W; - return *this; -} - - -// matrix assignment operator -inline quaternion& quaternion::operator=(const matrix4& m) -{ - const f32 diag = m(0,0) + m(1,1) + m(2,2) + 1; - - if( diag > 0.0f ) - { - const f32 scale = sqrtf(diag) * 2.0f; // get scale from diagonal - - // TODO: speed this up - X = ( m(2,1) - m(1,2)) / scale; - Y = ( m(0,2) - m(2,0)) / scale; - Z = ( m(1,0) - m(0,1)) / scale; - W = 0.25f * scale; - } - else - { - if ( m(0,0) > m(1,1) && m(0,0) > m(2,2)) - { - // 1st element of diag is greatest value - // find scale according to 1st element, and double it - const f32 scale = sqrtf( 1.0f + m(0,0) - m(1,1) - m(2,2)) * 2.0f; - - // TODO: speed this up - X = 0.25f * scale; - Y = (m(0,1) + m(1,0)) / scale; - Z = (m(2,0) + m(0,2)) / scale; - W = (m(2,1) - m(1,2)) / scale; - } - else if ( m(1,1) > m(2,2)) - { - // 2nd element of diag is greatest value - // find scale according to 2nd element, and double it - const f32 scale = sqrtf( 1.0f + m(1,1) - m(0,0) - m(2,2)) * 2.0f; - - // TODO: speed this up - X = (m(0,1) + m(1,0) ) / scale; - Y = 0.25f * scale; - Z = (m(1,2) + m(2,1) ) / scale; - W = (m(0,2) - m(2,0) ) / scale; - } - else - { - // 3rd element of diag is greatest value - // find scale according to 3rd element, and double it - const f32 scale = sqrtf( 1.0f + m(2,2) - m(0,0) - m(1,1)) * 2.0f; - - // TODO: speed this up - X = (m(0,2) + m(2,0)) / scale; - Y = (m(1,2) + m(2,1)) / scale; - Z = 0.25f * scale; - W = (m(1,0) - m(0,1)) / scale; - } - } - - return normalize(); -} - - -// multiplication operator -inline quaternion quaternion::operator*(const quaternion& other) const -{ - quaternion tmp; - - tmp.W = (other.W * W) - (other.X * X) - (other.Y * Y) - (other.Z * Z); - tmp.X = (other.W * X) + (other.X * W) + (other.Y * Z) - (other.Z * Y); - tmp.Y = (other.W * Y) + (other.Y * W) + (other.Z * X) - (other.X * Z); - tmp.Z = (other.W * Z) + (other.Z * W) + (other.X * Y) - (other.Y * X); - - return tmp; -} - - -// multiplication operator -inline quaternion quaternion::operator*(f32 s) const -{ - return quaternion(s*X, s*Y, s*Z, s*W); -} - -// multiplication operator -inline quaternion& quaternion::operator*=(f32 s) -{ - X*=s; - Y*=s; - Z*=s; - W*=s; - return *this; -} - -// multiplication operator -inline quaternion& quaternion::operator*=(const quaternion& other) -{ - return (*this = other * (*this)); -} - -// add operator -inline quaternion quaternion::operator+(const quaternion& b) const -{ - return quaternion(X+b.X, Y+b.Y, Z+b.Z, W+b.W); -} - - -// Creates a matrix from this quaternion -inline matrix4 quaternion::getMatrix() const -{ - core::matrix4 m; - getMatrix_transposed(m); - return m; -} - - -/*! - Creates a matrix from this quaternion -*/ -inline void quaternion::getMatrix( matrix4 &dest, const core::vector3df ¢er ) const -{ - f32 * m = dest.pointer(); - - m[0] = 1.0f - 2.0f*Y*Y - 2.0f*Z*Z; - m[1] = 2.0f*X*Y + 2.0f*Z*W; - m[2] = 2.0f*X*Z - 2.0f*Y*W; - m[3] = 0.0f; - - m[4] = 2.0f*X*Y - 2.0f*Z*W; - m[5] = 1.0f - 2.0f*X*X - 2.0f*Z*Z; - m[6] = 2.0f*Z*Y + 2.0f*X*W; - m[7] = 0.0f; - - m[8] = 2.0f*X*Z + 2.0f*Y*W; - m[9] = 2.0f*Z*Y - 2.0f*X*W; - m[10] = 1.0f - 2.0f*X*X - 2.0f*Y*Y; - m[11] = 0.0f; - - m[12] = center.X; - m[13] = center.Y; - m[14] = center.Z; - m[15] = 1.f; - - //dest.setDefinitelyIdentityMatrix ( matrix4::BIT_IS_NOT_IDENTITY ); - dest.setDefinitelyIdentityMatrix ( false ); -} - - - -/*! - Creates a matrix from this quaternion - Rotate about a center point - shortcut for - core::quaternion q; - q.rotationFromTo ( vin[i].Normal, forward ); - q.getMatrix ( lookat, center ); - - core::matrix4 m2; - m2.setInverseTranslation ( center ); - lookat *= m2; -*/ -inline void quaternion::getMatrixCenter( matrix4 &dest, - const core::vector3df ¢er, - const core::vector3df &translation - ) const -{ - f32 * m = dest.pointer(); - - m[0] = 1.0f - 2.0f*Y*Y - 2.0f*Z*Z; - m[1] = 2.0f*X*Y + 2.0f*Z*W; - m[2] = 2.0f*X*Z - 2.0f*Y*W; - m[3] = 0.0f; - - m[4] = 2.0f*X*Y - 2.0f*Z*W; - m[5] = 1.0f - 2.0f*X*X - 2.0f*Z*Z; - m[6] = 2.0f*Z*Y + 2.0f*X*W; - m[7] = 0.0f; - - m[8] = 2.0f*X*Z + 2.0f*Y*W; - m[9] = 2.0f*Z*Y - 2.0f*X*W; - m[10] = 1.0f - 2.0f*X*X - 2.0f*Y*Y; - m[11] = 0.0f; - - dest.setRotationCenter ( center, translation ); -} - -// Creates a matrix from this quaternion -inline void quaternion::getMatrix_transposed( matrix4 &dest ) const -{ - dest[0] = 1.0f - 2.0f*Y*Y - 2.0f*Z*Z; - dest[4] = 2.0f*X*Y + 2.0f*Z*W; - dest[8] = 2.0f*X*Z - 2.0f*Y*W; - dest[12] = 0.0f; - - dest[1] = 2.0f*X*Y - 2.0f*Z*W; - dest[5] = 1.0f - 2.0f*X*X - 2.0f*Z*Z; - dest[9] = 2.0f*Z*Y + 2.0f*X*W; - dest[13] = 0.0f; - - dest[2] = 2.0f*X*Z + 2.0f*Y*W; - dest[6] = 2.0f*Z*Y - 2.0f*X*W; - dest[10] = 1.0f - 2.0f*X*X - 2.0f*Y*Y; - dest[14] = 0.0f; - - dest[3] = 0.f; - dest[7] = 0.f; - dest[11] = 0.f; - dest[15] = 1.f; - //dest.setDefinitelyIdentityMatrix ( matrix4::BIT_IS_NOT_IDENTITY ); - dest.setDefinitelyIdentityMatrix ( false ); -} - - - -// Inverts this quaternion -inline quaternion& quaternion::makeInverse() -{ - X = -X; Y = -Y; Z = -Z; - return *this; -} - -// sets new quaternion -inline quaternion& quaternion::set(f32 x, f32 y, f32 z, f32 w) -{ - X = x; - Y = y; - Z = z; - W = w; - return *this; -} - - -// sets new quaternion based on euler angles -inline quaternion& quaternion::set(f32 x, f32 y, f32 z) -{ - f64 angle; - - angle = x * 0.5; - const f64 sr = sin(angle); - const f64 cr = cos(angle); - - angle = y * 0.5; - const f64 sp = sin(angle); - const f64 cp = cos(angle); - - angle = z * 0.5; - const f64 sy = sin(angle); - const f64 cy = cos(angle); - - const f64 cpcy = cp * cy; - const f64 spcy = sp * cy; - const f64 cpsy = cp * sy; - const f64 spsy = sp * sy; - - X = (f32)(sr * cpcy - cr * spsy); - Y = (f32)(cr * spcy + sr * cpsy); - Z = (f32)(cr * cpsy - sr * spcy); - W = (f32)(cr * cpcy + sr * spsy); - - return normalize(); -} - -// sets new quaternion based on euler angles -inline quaternion& quaternion::set(const core::vector3df& vec) -{ - return set(vec.X, vec.Y, vec.Z); -} - -// normalizes the quaternion -inline quaternion& quaternion::normalize() -{ - const f32 n = X*X + Y*Y + Z*Z + W*W; - - if (n == 1) - return *this; - - //n = 1.0f / sqrtf(n); - return (*this *= reciprocal_squareroot ( n )); -} - - -// set this quaternion to the result of the interpolation between two quaternions -inline quaternion& quaternion::slerp(quaternion q1, quaternion q2, f32 time) -{ - f32 angle = q1.dotProduct(q2); - - if (angle < 0.0f) - { - q1 *= -1.0f; - angle *= -1.0f; - } - - f32 scale; - f32 invscale; - - if ((angle + 1.0f) > 0.05f) - { - if ((1.0f - angle) >= 0.05f) // spherical interpolation - { - const f32 theta = acosf(angle); - const f32 invsintheta = reciprocal(sinf(theta)); - scale = sinf(theta * (1.0f-time)) * invsintheta; - invscale = sinf(theta * time) * invsintheta; - } - else // linear interploation - { - scale = 1.0f - time; - invscale = time; - } - } - else - { - q2.set(-q1.Y, q1.X, -q1.W, q1.Z); - scale = sinf(PI * (0.5f - time)); - invscale = sinf(PI * time); - } - - return (*this = (q1*scale) + (q2*invscale)); -} - - -// calculates the dot product -inline f32 quaternion::dotProduct(const quaternion& q2) const -{ - return (X * q2.X) + (Y * q2.Y) + (Z * q2.Z) + (W * q2.W); -} - - -//! axis must be unit length -//! angle in radians -inline quaternion& quaternion::fromAngleAxis(f32 angle, const vector3df& axis) -{ - const f32 fHalfAngle = 0.5f*angle; - const f32 fSin = sinf(fHalfAngle); - W = cosf(fHalfAngle); - X = fSin*axis.X; - Y = fSin*axis.Y; - Z = fSin*axis.Z; - return *this; -} - - -inline void quaternion::toAngleAxis(f32 &angle, core::vector3df &axis) const -{ - const f32 scale = sqrtf(X*X + Y*Y + Z*Z); - - if (core::iszero(scale) || W > 1.0f || W < -1.0f) - { - angle = 0.0f; - axis.X = 0.0f; - axis.Y = 1.0f; - axis.Z = 0.0f; - } - else - { - const f32 invscale = reciprocal(scale); - angle = 2.0f * acosf(W); - axis.X = X * invscale; - axis.Y = Y * invscale; - axis.Z = Z * invscale; - } -} - -inline void quaternion::toEuler(vector3df& euler) const -{ - const f64 sqw = W*W; - const f64 sqx = X*X; - const f64 sqy = Y*Y; - const f64 sqz = Z*Z; - - // heading = rotation about z-axis - euler.Z = (f32) (atan2(2.0 * (X*Y +Z*W),(sqx - sqy - sqz + sqw))); - - // bank = rotation about x-axis - euler.X = (f32) (atan2(2.0 * (Y*Z +X*W),(-sqx - sqy + sqz + sqw))); - - // attitude = rotation about y-axis - euler.Y = asinf( clamp(-2.0f * (X*Z - Y*W), -1.0f, 1.0f) ); -} - - -inline vector3df quaternion::operator* (const vector3df& v) const -{ - // nVidia SDK implementation - - vector3df uv, uuv; - vector3df qvec(X, Y, Z); - uv = qvec.crossProduct(v); - uuv = qvec.crossProduct(uv); - uv *= (2.0f * W); - uuv *= 2.0f; - - return v + uv + uuv; -} - -// set quaternion to identity -inline core::quaternion& quaternion::makeIdentity() -{ - W = 1.f; - X = 0.f; - Y = 0.f; - Z = 0.f; - return *this; -} - -inline core::quaternion& quaternion::rotationFromTo(const vector3df& from, const vector3df& to) -{ - // Based on Stan Melax's article in Game Programming Gems - // Copy, since cannot modify local - vector3df v0 = from; - vector3df v1 = to; - v0.normalize(); - v1.normalize(); - - const f32 d = v0.dotProduct(v1); - if (d >= 1.0f) // If dot == 1, vectors are the same - { - return makeIdentity(); - } - - const f32 s = sqrtf( (1+d)*2 ); // optimize inv_sqrt - const f32 invs = 1.f / s; - const vector3df c = v0.crossProduct(v1)*invs; - X = c.X; - Y = c.Y; - Z = c.Z; - W = s * 0.5f; - - return *this; -} - - -} // end namespace core -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/rect.h b/irrlicht-1.6/include/rect.h deleted file mode 100644 index b268be408..000000000 --- a/irrlicht-1.6/include/rect.h +++ /dev/null @@ -1,279 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_RECT_H_INCLUDED__ -#define __IRR_RECT_H_INCLUDED__ - -#include "irrTypes.h" -#include "dimension2d.h" -#include "position2d.h" - -namespace irr -{ -namespace core -{ - - //! Rectangle template. - /** Mostly used by 2D GUI elements and for 2D drawing methods. - It has 2 positions instead of position and dimension and a fast - method for collision detection with other rectangles and points. - - Coordinates are (0,0) for top-left corner, and increasing to the right - and to the bottom. - */ - template <class T> - class rect - { - public: - - //! Default constructor creating empty rectangle at (0,0) - rect() : UpperLeftCorner(0,0), LowerRightCorner(0,0) {} - - //! Constructor with two corners - rect(T x, T y, T x2, T y2) - : UpperLeftCorner(x,y), LowerRightCorner(x2,y2) {} - - //! Constructor with two corners - rect(const position2d<T>& upperLeft, const position2d<T>& lowerRight) - : UpperLeftCorner(upperLeft), LowerRightCorner(lowerRight) {} - - //! Constructor with upper left corner and dimension - template <class U> - rect(const position2d<T>& pos, const dimension2d<U>& size) - : UpperLeftCorner(pos), LowerRightCorner(pos.X + size.Width, pos.Y + size.Height) {} - - //! move right by given numbers - rect<T> operator+(const position2d<T>& pos) const - { - rect<T> ret(*this); - return ret+=pos; - } - - //! move right by given numbers - rect<T>& operator+=(const position2d<T>& pos) - { - UpperLeftCorner += pos; - LowerRightCorner += pos; - return *this; - } - - //! move left by given numbers - rect<T> operator-(const position2d<T>& pos) const - { - rect<T> ret(*this); - return ret-=pos; - } - - //! move left by given numbers - rect<T>& operator-=(const position2d<T>& pos) - { - UpperLeftCorner -= pos; - LowerRightCorner -= pos; - return *this; - } - - //! equality operator - bool operator==(const rect<T>& other) const - { - return (UpperLeftCorner == other.UpperLeftCorner && - LowerRightCorner == other.LowerRightCorner); - } - - //! inequality operator - bool operator!=(const rect<T>& other) const - { - return (UpperLeftCorner != other.UpperLeftCorner || - LowerRightCorner != other.LowerRightCorner); - } - - //! compares size of rectangles - bool operator<(const rect<T>& other) const - { - return getArea() < other.getArea(); - } - - //! Returns size of rectangle - T getArea() const - { - return getWidth() * getHeight(); - } - - //! Returns if a 2d point is within this rectangle. - /** \param pos Position to test if it lies within this rectangle. - \return True if the position is within the rectangle, false if not. */ - bool isPointInside(const position2d<T>& pos) const - { - return (UpperLeftCorner.X <= pos.X && - UpperLeftCorner.Y <= pos.Y && - LowerRightCorner.X >= pos.X && - LowerRightCorner.Y >= pos.Y); - } - - //! Check if the rectangle collides with another rectangle. - /** \param other Rectangle to test collision with - \return True if the rectangles collide. */ - bool isRectCollided(const rect<T>& other) const - { - return (LowerRightCorner.Y > other.UpperLeftCorner.Y && - UpperLeftCorner.Y < other.LowerRightCorner.Y && - LowerRightCorner.X > other.UpperLeftCorner.X && - UpperLeftCorner.X < other.LowerRightCorner.X); - } - - //! Clips this rectangle with another one. - /** \param other Rectangle to clip with */ - void clipAgainst(const rect<T>& other) - { - if (other.LowerRightCorner.X < LowerRightCorner.X) - LowerRightCorner.X = other.LowerRightCorner.X; - if (other.LowerRightCorner.Y < LowerRightCorner.Y) - LowerRightCorner.Y = other.LowerRightCorner.Y; - - if (other.UpperLeftCorner.X > UpperLeftCorner.X) - UpperLeftCorner.X = other.UpperLeftCorner.X; - if (other.UpperLeftCorner.Y > UpperLeftCorner.Y) - UpperLeftCorner.Y = other.UpperLeftCorner.Y; - - // correct possible invalid rect resulting from clipping - if (UpperLeftCorner.Y > LowerRightCorner.Y) - UpperLeftCorner.Y = LowerRightCorner.Y; - if (UpperLeftCorner.X > LowerRightCorner.X) - UpperLeftCorner.X = LowerRightCorner.X; - } - - //! Moves this rectangle to fit inside another one. - /** \return True on success, false if not possible */ - bool constrainTo(const rect<T>& other) - { - if (other.getWidth() < getWidth() || other.getHeight() < getHeight()) - return false; - - T diff = other.LowerRightCorner.X - LowerRightCorner.X; - if (diff < 0) - { - LowerRightCorner.X += diff; - UpperLeftCorner.X += diff; - } - - diff = other.LowerRightCorner.Y - LowerRightCorner.Y; - if (diff < 0) - { - LowerRightCorner.Y += diff; - UpperLeftCorner.Y += diff; - } - - diff = UpperLeftCorner.X - other.UpperLeftCorner.X; - if (diff < 0) - { - UpperLeftCorner.X -= diff; - LowerRightCorner.X -= diff; - } - - diff = UpperLeftCorner.Y - other.UpperLeftCorner.Y; - if (diff < 0) - { - UpperLeftCorner.Y -= diff; - LowerRightCorner.Y -= diff; - } - - return true; - } - - //! Get width of rectangle. - T getWidth() const - { - return LowerRightCorner.X - UpperLeftCorner.X; - } - - //! Get height of rectangle. - T getHeight() const - { - return LowerRightCorner.Y - UpperLeftCorner.Y; - } - - //! If the lower right corner of the rect is smaller then the upper left, the points are swapped. - void repair() - { - if (LowerRightCorner.X < UpperLeftCorner.X) - { - T t = LowerRightCorner.X; - LowerRightCorner.X = UpperLeftCorner.X; - UpperLeftCorner.X = t; - } - - if (LowerRightCorner.Y < UpperLeftCorner.Y) - { - T t = LowerRightCorner.Y; - LowerRightCorner.Y = UpperLeftCorner.Y; - UpperLeftCorner.Y = t; - } - } - - //! Returns if the rect is valid to draw. - /** It would be invalid if the UpperLeftCorner is lower or more - right than the LowerRightCorner. */ - bool isValid() const - { - return ((LowerRightCorner.X >= UpperLeftCorner.X) && - (LowerRightCorner.Y >= UpperLeftCorner.Y)); - } - - //! Get the center of the rectangle - position2d<T> getCenter() const - { - return position2d<T>( - (UpperLeftCorner.X + LowerRightCorner.X) / 2, - (UpperLeftCorner.Y + LowerRightCorner.Y) / 2); - } - - //! Get the dimensions of the rectangle - dimension2d<T> getSize() const - { - return dimension2d<T>(getWidth(), getHeight()); - } - - - //! Adds a point to the rectangle - /** Causes the rectangle to grow bigger if point is outside of - the box - \param p Point to add to the box. */ - void addInternalPoint(const position2d<T>& p) - { - addInternalPoint(p.X, p.Y); - } - - //! Adds a point to the bounding rectangle - /** Causes the rectangle to grow bigger if point is outside of - the box - \param x X-Coordinate of the point to add to this box. - \param y Y-Coordinate of the point to add to this box. */ - void addInternalPoint(T x, T y) - { - if (x>LowerRightCorner.X) - LowerRightCorner.X = x; - if (y>LowerRightCorner.Y) - LowerRightCorner.Y = y; - - if (x<UpperLeftCorner.X) - UpperLeftCorner.X = x; - if (y<UpperLeftCorner.Y) - UpperLeftCorner.Y = y; - } - - //! Upper left corner - position2d<T> UpperLeftCorner; - //! Lower right corner - position2d<T> LowerRightCorner; - }; - - //! Rectangle with float values - typedef rect<f32> rectf; - //! Rectangle with int values - typedef rect<s32> recti; - -} // end namespace core -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/triangle3d.h b/irrlicht-1.6/include/triangle3d.h deleted file mode 100644 index 9fcc2535d..000000000 --- a/irrlicht-1.6/include/triangle3d.h +++ /dev/null @@ -1,232 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_TRIANGLE_3D_H_INCLUDED__ -#define __IRR_TRIANGLE_3D_H_INCLUDED__ - -#include "vector3d.h" -#include "line3d.h" -#include "plane3d.h" -#include "aabbox3d.h" - -namespace irr -{ -namespace core -{ - - //! 3d triangle template class for doing collision detection and other things. - template <class T> - class triangle3d - { - public: - - //! Constructor for an all 0 triangle - triangle3d() {} - //! Constructor for triangle with given three vertices - triangle3d(vector3d<T> v1, vector3d<T> v2, vector3d<T> v3) : pointA(v1), pointB(v2), pointC(v3) {} - - //! Equality operator - bool operator==(const triangle3d<T>& other) const - { - return other.pointA==pointA && other.pointB==pointB && other.pointC==pointC; - } - - //! Inequality operator - bool operator!=(const triangle3d<T>& other) const - { - return !(*this==other); - } - - //! Determines if the triangle is totally inside a bounding box. - /** \param box Box to check. - \return True if triangle is within the box, otherwise false. */ - bool isTotalInsideBox(const aabbox3d<T>& box) const - { - return (box.isPointInside(pointA) && - box.isPointInside(pointB) && - box.isPointInside(pointC)); - } - - //! Get the closest point on a triangle to a point on the same plane. - /** \param p Point which must be on the same plane as the triangle. - \return The closest point of the triangle */ - core::vector3d<T> closestPointOnTriangle(const core::vector3d<T>& p) const - { - const core::vector3d<T> rab = line3d<T>(pointA, pointB).getClosestPoint(p); - const core::vector3d<T> rbc = line3d<T>(pointB, pointC).getClosestPoint(p); - const core::vector3d<T> rca = line3d<T>(pointC, pointA).getClosestPoint(p); - - const T d1 = rab.getDistanceFrom(p); - const T d2 = rbc.getDistanceFrom(p); - const T d3 = rca.getDistanceFrom(p); - - if (d1 < d2) - return d1 < d3 ? rab : rca; - - return d2 < d3 ? rbc : rca; - } - - //! Check if a point is inside the triangle - /** \param p Point to test. Assumes that this point is already - on the plane of the triangle. - \return True if the point is inside the triangle, otherwise false. */ - bool isPointInside(const vector3d<T>& p) const - { - return (isOnSameSide(p, pointA, pointB, pointC) && - isOnSameSide(p, pointB, pointA, pointC) && - isOnSameSide(p, pointC, pointA, pointB)); - } - - //! Check if a point is inside the triangle. - /** This method is an implementation of the example used in a - paper by Kasper Fauerby original written by Keidy from - Mr-Gamemaker. - \param p Point to test. Assumes that this point is already - on the plane of the triangle. - \return True if point is inside the triangle, otherwise false. */ - bool isPointInsideFast(const vector3d<T>& p) const - { - const vector3d<T> f = pointB - pointA; - const vector3d<T> g = pointC - pointA; - - const f32 a = f.dotProduct(f); - const f32 b = f.dotProduct(g); - const f32 c = g.dotProduct(g); - - const vector3d<T> vp = p - pointA; - const f32 d = vp.dotProduct(f); - const f32 e = vp.dotProduct(g); - - f32 x = (d*c)-(e*b); - f32 y = (e*a)-(d*b); - const f32 ac_bb = (a*c)-(b*b); - f32 z = x+y-ac_bb; - - // return sign(z) && !(sign(x)||sign(y)) - return (( (IR(z)) & ~((IR(x))|(IR(y))) ) & 0x80000000)!=0; - } - - - //! Get an intersection with a 3d line. - /** \param line Line to intersect with. - \param outIntersection Place to store the intersection point, if there is one. - \return True if there was an intersection, false if not. */ - bool getIntersectionWithLimitedLine(const line3d<T>& line, - vector3d<T>& outIntersection) const - { - return getIntersectionWithLine(line.start, - line.getVector(), outIntersection) && - outIntersection.isBetweenPoints(line.start, line.end); - } - - - //! Get an intersection with a 3d line. - /** Please note that also points are returned as intersection which - are on the line, but not between the start and end point of the line. - If you want the returned point be between start and end - use getIntersectionWithLimitedLine(). - \param linePoint Point of the line to intersect with. - \param lineVect Vector of the line to intersect with. - \param outIntersection Place to store the intersection point, if there is one. - \return True if there was an intersection, false if there was not. */ - bool getIntersectionWithLine(const vector3d<T>& linePoint, - const vector3d<T>& lineVect, vector3d<T>& outIntersection) const - { - if (getIntersectionOfPlaneWithLine(linePoint, lineVect, outIntersection)) - return isPointInside(outIntersection); - - return false; - } - - - //! Calculates the intersection between a 3d line and the plane the triangle is on. - /** \param lineVect Vector of the line to intersect with. - \param linePoint Point of the line to intersect with. - \param outIntersection Place to store the intersection point, if there is one. - \return True if there was an intersection, else false. */ - bool getIntersectionOfPlaneWithLine(const vector3d<T>& linePoint, - const vector3d<T>& lineVect, vector3d<T>& outIntersection) const - { - const vector3d<T> normal = getNormal().normalize(); - T t2; - - if ( core::iszero ( t2 = normal.dotProduct(lineVect) ) ) - return false; - - T d = pointA.dotProduct(normal); - T t = -(normal.dotProduct(linePoint) - d) / t2; - outIntersection = linePoint + (lineVect * t); - return true; - } - - - //! Get the normal of the triangle. - /** Please note: The normal is not always normalized. */ - vector3d<T> getNormal() const - { - return (pointB - pointA).crossProduct(pointC - pointA); - } - - //! Test if the triangle would be front or backfacing from any point. - /** Thus, this method assumes a camera position from which the - triangle is definitely visible when looking at the given direction. - Do not use this method with points as it will give wrong results! - \param lookDirection Look direction. - \return True if the plane is front facing and false if it is backfacing. */ - bool isFrontFacing(const vector3d<T>& lookDirection) const - { - const vector3d<T> n = getNormal().normalize(); - const f32 d = (f32)n.dotProduct(lookDirection); - return F32_LOWER_EQUAL_0(d); - } - - //! Get the plane of this triangle. - plane3d<T> getPlane() const - { - return plane3d<T>(pointA, pointB, pointC); - } - - //! Get the area of the triangle - T getArea() const - { - return (pointB - pointA).crossProduct(pointC - pointA).getLength() * 0.5; - - } - - //! sets the triangle's points - void set(const core::vector3d<T>& a, const core::vector3d<T>& b, const core::vector3d<T>& c) - { - pointA = a; - pointB = b; - pointC = c; - } - - //! the three points of the triangle - vector3d<T> pointA; - vector3d<T> pointB; - vector3d<T> pointC; - - private: - bool isOnSameSide(const vector3d<T>& p1, const vector3d<T>& p2, - const vector3d<T>& a, const vector3d<T>& b) const - { - vector3d<T> bminusa = b - a; - vector3d<T> cp1 = bminusa.crossProduct(p1 - a); - vector3d<T> cp2 = bminusa.crossProduct(p2 - a); - return (cp1.dotProduct(cp2) >= 0.0f); - } - }; - - - //! Typedef for a f32 3d triangle. - typedef triangle3d<f32> triangle3df; - - //! Typedef for an integer 3d triangle. - typedef triangle3d<s32> triangle3di; - -} // end namespace core -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/vector2d.h b/irrlicht-1.6/include/vector2d.h deleted file mode 100644 index ec6589b7e..000000000 --- a/irrlicht-1.6/include/vector2d.h +++ /dev/null @@ -1,317 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_POINT_2D_H_INCLUDED__ -#define __IRR_POINT_2D_H_INCLUDED__ - -#include "irrMath.h" -#include "dimension2d.h" - -namespace irr -{ -namespace core -{ - - -//! 2d vector template class with lots of operators and methods. -/** As of Irrlicht 1.6, this class supercedes position2d, which should - be considered deprecated. */ -template <class T> -class vector2d -{ -public: - //! Default constructor (null vector) - vector2d() : X(0), Y(0) {} - //! Constructor with two different values - vector2d(T nx, T ny) : X(nx), Y(ny) {} - //! Constructor with the same value for both members - explicit vector2d(T n) : X(n), Y(n) {} - //! Copy constructor - vector2d(const vector2d<T>& other) : X(other.X), Y(other.Y) {} - - vector2d(const dimension2d<T>& other) : X(other.Width), Y(other.Height) {} - - // operators - - vector2d<T> operator-() const { return vector2d<T>(-X, -Y); } - - vector2d<T>& operator=(const vector2d<T>& other) { X = other.X; Y = other.Y; return *this; } - - vector2d<T>& operator=(const dimension2d<T>& other) { X = other.Width; Y = other.Height; return *this; } - - vector2d<T> operator+(const vector2d<T>& other) const { return vector2d<T>(X + other.X, Y + other.Y); } - vector2d<T> operator+(const dimension2d<T>& other) const { return vector2d<T>(X + other.Width, Y + other.Height); } - vector2d<T>& operator+=(const vector2d<T>& other) { X+=other.X; Y+=other.Y; return *this; } - vector2d<T> operator+(const T v) const { return vector2d<T>(X + v, Y + v); } - vector2d<T>& operator+=(const T v) { X+=v; Y+=v; return *this; } - vector2d<T>& operator+=(const dimension2d<T>& other) { X += other.Width; Y += other.Height; return *this; } - - vector2d<T> operator-(const vector2d<T>& other) const { return vector2d<T>(X - other.X, Y - other.Y); } - vector2d<T> operator-(const dimension2d<T>& other) const { return vector2d<T>(X - other.Width, Y - other.Height); } - vector2d<T>& operator-=(const vector2d<T>& other) { X-=other.X; Y-=other.Y; return *this; } - vector2d<T> operator-(const T v) const { return vector2d<T>(X - v, Y - v); } - vector2d<T>& operator-=(const T v) { X-=v; Y-=v; return *this; } - vector2d<T>& operator-=(const dimension2d<T>& other) { X -= other.Width; Y -= other.Height; return *this; } - - vector2d<T> operator*(const vector2d<T>& other) const { return vector2d<T>(X * other.X, Y * other.Y); } - vector2d<T>& operator*=(const vector2d<T>& other) { X*=other.X; Y*=other.Y; return *this; } - vector2d<T> operator*(const T v) const { return vector2d<T>(X * v, Y * v); } - vector2d<T>& operator*=(const T v) { X*=v; Y*=v; return *this; } - - vector2d<T> operator/(const vector2d<T>& other) const { return vector2d<T>(X / other.X, Y / other.Y); } - vector2d<T>& operator/=(const vector2d<T>& other) { X/=other.X; Y/=other.Y; return *this; } - vector2d<T> operator/(const T v) const { return vector2d<T>(X / v, Y / v); } - vector2d<T>& operator/=(const T v) { X/=v; Y/=v; return *this; } - - bool operator<=(const vector2d<T>&other) const { return X<=other.X && Y<=other.Y; } - bool operator>=(const vector2d<T>&other) const { return X>=other.X && Y>=other.Y; } - - bool operator<(const vector2d<T>&other) const { return X<other.X && Y<other.Y; } - bool operator>(const vector2d<T>&other) const { return X>other.X && Y>other.Y; } - - bool operator==(const vector2d<T>& other) const { return equals(other); } - bool operator!=(const vector2d<T>& other) const { return !equals(other); } - - // functions - - //! Checks if this vector equals the other one. - /** Takes floating point rounding errors into account. - \param other Vector to compare with. - \return True if the two vector are (almost) equal, else false. */ - bool equals(const vector2d<T>& other) const - { - return core::equals(X, other.X) && core::equals(Y, other.Y); - } - - vector2d<T>& set(T nx, T ny) {X=nx; Y=ny; return *this; } - vector2d<T>& set(const vector2d<T>& p) { X=p.X; Y=p.Y; return *this; } - - //! Gets the length of the vector. - /** \return The length of the vector. */ - T getLength() const { return core::squareroot( X*X + Y*Y ); } - - //! Get the squared length of this vector - /** This is useful because it is much faster than getLength(). - \return The squared length of the vector. */ - T getLengthSQ() const { return X*X + Y*Y; } - - //! Get the dot product of this vector with another. - /** \param other Other vector to take dot product with. - \return The dot product of the two vectors. */ - T dotProduct(const vector2d<T>& other) const - { - return X*other.X + Y*other.Y; - } - - //! Gets distance from another point. - /** Here, the vector is interpreted as a point in 2-dimensional space. - \param other Other vector to measure from. - \return Distance from other point. */ - T getDistanceFrom(const vector2d<T>& other) const - { - return vector2d<T>(X - other.X, Y - other.Y).getLength(); - } - - //! Returns squared distance from another point. - /** Here, the vector is interpreted as a point in 2-dimensional space. - \param other Other vector to measure from. - \return Squared distance from other point. */ - T getDistanceFromSQ(const vector2d<T>& other) const - { - return vector2d<T>(X - other.X, Y - other.Y).getLengthSQ(); - } - - //! rotates the point anticlockwise around a center by an amount of degrees. - /** \param degrees Amount of degrees to rotate by, anticlockwise. - \param center Rotation center. - \return This vector after transformation. */ - vector2d<T>& rotateBy(f64 degrees, const vector2d<T>& center=vector2d<T>()) - { - degrees *= DEGTORAD64; - const f64 cs = cos(degrees); - const f64 sn = sin(degrees); - - X -= center.X; - Y -= center.Y; - - set((T)(X*cs - Y*sn), (T)(X*sn + Y*cs)); - - X += center.X; - Y += center.Y; - return *this; - } - - //! Normalize the vector. - /** The null vector is left untouched. - \return Reference to this vector, after normalization. */ - vector2d<T>& normalize() - { - f32 length = (f32)(X*X + Y*Y); - if (core::equals(length, 0.f)) - return *this; - length = core::reciprocal_squareroot ( length ); - X = (T)(X * length); - Y = (T)(Y * length); - return *this; - } - - //! Calculates the angle of this vector in degrees in the trigonometric sense. - /** 0 is to the right (3 o'clock), values increase counter-clockwise. - This method has been suggested by Pr3t3nd3r. - \return Returns a value between 0 and 360. */ - f64 getAngleTrig() const - { - if (Y == 0) - return X < 0 ? 180 : 0; - else - if (X == 0) - return Y < 0 ? 270 : 90; - - if ( Y > 0) - if (X > 0) - return atan(Y/X) * RADTODEG64; - else - return 180.0-atan(Y/-X) * RADTODEG64; - else - if (X > 0) - return 360.0-atan(-Y/X) * RADTODEG64; - else - return 180.0+atan(-Y/-X) * RADTODEG64; - } - - //! Calculates the angle of this vector in degrees in the counter trigonometric sense. - /** 0 is to the right (3 o'clock), values increase clockwise. - \return Returns a value between 0 and 360. */ - inline f64 getAngle() const - { - if (Y == 0) // corrected thanks to a suggestion by Jox - return X < 0 ? 180 : 0; - else if (X == 0) - return Y < 0 ? 90 : 270; - - // don't use getLength here to avoid precision loss with s32 vectors - f64 tmp = Y / sqrt((f64)(X*X + Y*Y)); - tmp = atan( core::squareroot(1 - tmp*tmp) / tmp) * RADTODEG64; - - if (X>0 && Y>0) - return tmp + 270; - else - if (X>0 && Y<0) - return tmp + 90; - else - if (X<0 && Y<0) - return 90 - tmp; - else - if (X<0 && Y>0) - return 270 - tmp; - - return tmp; - } - - //! Calculates the angle between this vector and another one in degree. - /** \param b Other vector to test with. - \return Returns a value between 0 and 90. */ - inline f64 getAngleWith(const vector2d<T>& b) const - { - f64 tmp = X*b.X + Y*b.Y; - - if (tmp == 0.0) - return 90.0; - - tmp = tmp / core::squareroot((f64)((X*X + Y*Y) * (b.X*b.X + b.Y*b.Y))); - if (tmp < 0.0) - tmp = -tmp; - - return atan(sqrt(1 - tmp*tmp) / tmp) * RADTODEG64; - } - - //! Returns if this vector interpreted as a point is on a line between two other points. - /** It is assumed that the point is on the line. - \param begin Beginning vector to compare between. - \param end Ending vector to compare between. - \return True if this vector is between begin and end, false if not. */ - bool isBetweenPoints(const vector2d<T>& begin, const vector2d<T>& end) const - { - if (begin.X != end.X) - { - return ((begin.X <= X && X <= end.X) || - (begin.X >= X && X >= end.X)); - } - else - { - return ((begin.Y <= Y && Y <= end.Y) || - (begin.Y >= Y && Y >= end.Y)); - } - } - - //! Creates an interpolated vector between this vector and another vector. - /** \param other The other vector to interpolate with. - \param d Interpolation value between 0.0f (all the other vector) and 1.0f (all this vector). - Note that this is the opposite direction of interpolation to getInterpolated_quadratic() - \return An interpolated vector. This vector is not modified. */ - vector2d<T> getInterpolated(const vector2d<T>& other, f64 d) const - { - f64 inv = 1.0f - d; - return vector2d<T>((T)(other.X*inv + X*d), (T)(other.Y*inv + Y*d)); - } - - //! Creates a quadratically interpolated vector between this and two other vectors. - /** \param v2 Second vector to interpolate with. - \param v3 Third vector to interpolate with (maximum at 1.0f) - \param d Interpolation value between 0.0f (all this vector) and 1.0f (all the 3rd vector). - Note that this is the opposite direction of interpolation to getInterpolated() and interpolate() - \return An interpolated vector. This vector is not modified. */ - vector2d<T> getInterpolated_quadratic(const vector2d<T>& v2, const vector2d<T>& v3, f64 d) const - { - // this*(1-d)*(1-d) + 2 * v2 * (1-d) + v3 * d * d; - const f64 inv = 1.0f - d; - const f64 mul0 = inv * inv; - const f64 mul1 = 2.0f * d * inv; - const f64 mul2 = d * d; - - return vector2d<T> ( (T)(X * mul0 + v2.X * mul1 + v3.X * mul2), - (T)(Y * mul0 + v2.Y * mul1 + v3.Y * mul2)); - } - - //! Sets this vector to the linearly interpolated vector between a and b. - /** \param a first vector to interpolate with, maximum at 1.0f - \param b second vector to interpolate with, maximum at 0.0f - \param d Interpolation value between 0.0f (all vector b) and 1.0f (all vector a) - Note that this is the opposite direction of interpolation to getInterpolated_quadratic() - */ - vector2d<T>& interpolate(const vector2d<T>& a, const vector2d<T>& b, f64 d) - { - X = (T)((f64)b.X + ( ( a.X - b.X ) * d )); - Y = (T)((f64)b.Y + ( ( a.Y - b.Y ) * d )); - return *this; - } - - //! X coordinate of vector. - T X; - - //! Y coordinate of vector. - T Y; -}; - - //! Typedef for f32 2d vector. - typedef vector2d<f32> vector2df; - - //! Typedef for integer 2d vector. - typedef vector2d<s32> vector2di; - - template<class S, class T> - vector2d<T> operator*(const S scalar, const vector2d<T>& vector) { return vector*scalar; } - - // These methods are declared in dimension2d, but need definitions of vector2d - template<class T> - dimension2d<T>::dimension2d(const vector2d<T>& other) : Width(other.X), Height(other.Y) { } - - template<class T> - bool dimension2d<T>::operator==(const vector2d<T>& other) const { return Width == other.X && Height == other.Y; } - -} // end namespace core -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/include/vector3d.h b/irrlicht-1.6/include/vector3d.h deleted file mode 100644 index fdec65980..000000000 --- a/irrlicht-1.6/include/vector3d.h +++ /dev/null @@ -1,370 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_POINT_3D_H_INCLUDED__ -#define __IRR_POINT_3D_H_INCLUDED__ - -#include "irrMath.h" - -namespace irr -{ -namespace core -{ - - //! 3d vector template class with lots of operators and methods. - /** The vector3d class is used in Irrlicht for three main purposes: - 1) As a direction vector (most of the methods assume this). - 2) As a position in 3d space (which is synonymous with a direction vector from the origin to this position). - 3) To hold three Euler rotations, where X is pitch, Y is yaw and Z is roll. - */ - template <class T> - class vector3d - { - public: - //! Default constructor (null vector). - vector3d() : X(0), Y(0), Z(0) {} - //! Constructor with three different values - vector3d(T nx, T ny, T nz) : X(nx), Y(ny), Z(nz) {} - //! Constructor with the same value for all elements - explicit vector3d(T n) : X(n), Y(n), Z(n) {} - //! Copy constructor - vector3d(const vector3d<T>& other) : X(other.X), Y(other.Y), Z(other.Z) {} - - // operators - - vector3d<T> operator-() const { return vector3d<T>(-X, -Y, -Z); } - - vector3d<T>& operator=(const vector3d<T>& other) { X = other.X; Y = other.Y; Z = other.Z; return *this; } - - vector3d<T> operator+(const vector3d<T>& other) const { return vector3d<T>(X + other.X, Y + other.Y, Z + other.Z); } - vector3d<T>& operator+=(const vector3d<T>& other) { X+=other.X; Y+=other.Y; Z+=other.Z; return *this; } - vector3d<T> operator+(const T val) const { return vector3d<T>(X + val, Y + val, Z + val); } - vector3d<T>& operator+=(const T val) { X+=val; Y+=val; Z+=val; return *this; } - - vector3d<T> operator-(const vector3d<T>& other) const { return vector3d<T>(X - other.X, Y - other.Y, Z - other.Z); } - vector3d<T>& operator-=(const vector3d<T>& other) { X-=other.X; Y-=other.Y; Z-=other.Z; return *this; } - vector3d<T> operator-(const T val) const { return vector3d<T>(X - val, Y - val, Z - val); } - vector3d<T>& operator-=(const T val) { X-=val; Y-=val; Z-=val; return *this; } - - vector3d<T> operator*(const vector3d<T>& other) const { return vector3d<T>(X * other.X, Y * other.Y, Z * other.Z); } - vector3d<T>& operator*=(const vector3d<T>& other) { X*=other.X; Y*=other.Y; Z*=other.Z; return *this; } - vector3d<T> operator*(const T v) const { return vector3d<T>(X * v, Y * v, Z * v); } - vector3d<T>& operator*=(const T v) { X*=v; Y*=v; Z*=v; return *this; } - - vector3d<T> operator/(const vector3d<T>& other) const { return vector3d<T>(X / other.X, Y / other.Y, Z / other.Z); } - vector3d<T>& operator/=(const vector3d<T>& other) { X/=other.X; Y/=other.Y; Z/=other.Z; return *this; } - vector3d<T> operator/(const T v) const { T i=(T)1.0/v; return vector3d<T>(X * i, Y * i, Z * i); } - vector3d<T>& operator/=(const T v) { T i=(T)1.0/v; X*=i; Y*=i; Z*=i; return *this; } - - bool operator<=(const vector3d<T>&other) const { return X<=other.X && Y<=other.Y && Z<=other.Z;} - bool operator>=(const vector3d<T>&other) const { return X>=other.X && Y>=other.Y && Z>=other.Z;} - bool operator<(const vector3d<T>&other) const { return X<other.X && Y<other.Y && Z<other.Z;} - bool operator>(const vector3d<T>&other) const { return X>other.X && Y>other.Y && Z>other.Z;} - - //! use weak float compare - bool operator==(const vector3d<T>& other) const - { - return this->equals(other); - } - - bool operator!=(const vector3d<T>& other) const - { - return !this->equals(other); - } - - // functions - - //! returns if this vector equals the other one, taking floating point rounding errors into account - bool equals(const vector3d<T>& other, const T tolerance = (T)ROUNDING_ERROR_f32 ) const - { - return core::equals(X, other.X, tolerance) && - core::equals(Y, other.Y, tolerance) && - core::equals(Z, other.Z, tolerance); - } - - vector3d<T>& set(const T nx, const T ny, const T nz) {X=nx; Y=ny; Z=nz; return *this;} - vector3d<T>& set(const vector3d<T>& p) {X=p.X; Y=p.Y; Z=p.Z;return *this;} - - //! Get length of the vector. - T getLength() const { return core::squareroot( X*X + Y*Y + Z*Z ); } - - //! Get squared length of the vector. - /** This is useful because it is much faster than getLength(). - \return Squared length of the vector. */ - T getLengthSQ() const { return X*X + Y*Y + Z*Z; } - - //! Get the dot product with another vector. - T dotProduct(const vector3d<T>& other) const - { - return X*other.X + Y*other.Y + Z*other.Z; - } - - //! Get distance from another point. - /** Here, the vector is interpreted as point in 3 dimensional space. */ - T getDistanceFrom(const vector3d<T>& other) const - { - return vector3d<T>(X - other.X, Y - other.Y, Z - other.Z).getLength(); - } - - //! Returns squared distance from another point. - /** Here, the vector is interpreted as point in 3 dimensional space. */ - T getDistanceFromSQ(const vector3d<T>& other) const - { - return vector3d<T>(X - other.X, Y - other.Y, Z - other.Z).getLengthSQ(); - } - - //! Calculates the cross product with another vector. - /** \param p Vector to multiply with. - \return Crossproduct of this vector with p. */ - vector3d<T> crossProduct(const vector3d<T>& p) const - { - return vector3d<T>(Y * p.Z - Z * p.Y, Z * p.X - X * p.Z, X * p.Y - Y * p.X); - } - - //! Returns if this vector interpreted as a point is on a line between two other points. - /** It is assumed that the point is on the line. - \param begin Beginning vector to compare between. - \param end Ending vector to compare between. - \return True if this vector is between begin and end, false if not. */ - bool isBetweenPoints(const vector3d<T>& begin, const vector3d<T>& end) const - { - const T f = (end - begin).getLengthSQ(); - return getDistanceFromSQ(begin) <= f && - getDistanceFromSQ(end) <= f; - } - - //! Normalizes the vector. - /** In case of the 0 vector the result is still 0, otherwise - the length of the vector will be 1. - \return Reference to this vector after normalization. */ - vector3d<T>& normalize() - { - f64 length = (f32)(X*X + Y*Y + Z*Z); - if (core::equals(length, 0.0)) // this check isn't an optimization but prevents getting NAN in the sqrt. - return *this; - length = core::reciprocal_squareroot ( (f64) (X*X + Y*Y + Z*Z) ); - - X = (T)(X * length); - Y = (T)(Y * length); - Z = (T)(Z * length); - return *this; - } - - //! Sets the length of the vector to a new value - vector3d<T>& setLength(T newlength) - { - normalize(); - return (*this *= newlength); - } - - //! Inverts the vector. - vector3d<T>& invert() - { - X *= -1.0f; - Y *= -1.0f; - Z *= -1.0f; - return *this; - } - - //! Rotates the vector by a specified number of degrees around the Y axis and the specified center. - /** \param degrees Number of degrees to rotate around the Y axis. - \param center The center of the rotation. */ - void rotateXZBy(f64 degrees, const vector3d<T>& center=vector3d<T>()) - { - degrees *= DEGTORAD64; - f64 cs = cos(degrees); - f64 sn = sin(degrees); - X -= center.X; - Z -= center.Z; - set((T)(X*cs - Z*sn), Y, (T)(X*sn + Z*cs)); - X += center.X; - Z += center.Z; - } - - //! Rotates the vector by a specified number of degrees around the Z axis and the specified center. - /** \param degrees: Number of degrees to rotate around the Z axis. - \param center: The center of the rotation. */ - void rotateXYBy(f64 degrees, const vector3d<T>& center=vector3d<T>()) - { - degrees *= DEGTORAD64; - f64 cs = cos(degrees); - f64 sn = sin(degrees); - X -= center.X; - Y -= center.Y; - set((T)(X*cs - Y*sn), (T)(X*sn + Y*cs), Z); - X += center.X; - Y += center.Y; - } - - //! Rotates the vector by a specified number of degrees around the X axis and the specified center. - /** \param degrees: Number of degrees to rotate around the X axis. - \param center: The center of the rotation. */ - void rotateYZBy(f64 degrees, const vector3d<T>& center=vector3d<T>()) - { - degrees *= DEGTORAD64; - f64 cs = cos(degrees); - f64 sn = sin(degrees); - Z -= center.Z; - Y -= center.Y; - set(X, (T)(Y*cs - Z*sn), (T)(Y*sn + Z*cs)); - Z += center.Z; - Y += center.Y; - } - - //! Creates an interpolated vector between this vector and another vector. - /** \param other The other vector to interpolate with. - \param d Interpolation value between 0.0f (all the other vector) and 1.0f (all this vector). - Note that this is the opposite direction of interpolation to getInterpolated_quadratic() - \return An interpolated vector. This vector is not modified. */ - vector3d<T> getInterpolated(const vector3d<T>& other, f64 d) const - { - const f64 inv = 1.0 - d; - return vector3d<T>((T)(other.X*inv + X*d), (T)(other.Y*inv + Y*d), (T)(other.Z*inv + Z*d)); - } - - //! Creates a quadratically interpolated vector between this and two other vectors. - /** \param v2 Second vector to interpolate with. - \param v3 Third vector to interpolate with (maximum at 1.0f) - \param d Interpolation value between 0.0f (all this vector) and 1.0f (all the 3rd vector). - Note that this is the opposite direction of interpolation to getInterpolated() and interpolate() - \return An interpolated vector. This vector is not modified. */ - vector3d<T> getInterpolated_quadratic(const vector3d<T>& v2, const vector3d<T>& v3, f64 d) const - { - // this*(1-d)*(1-d) + 2 * v2 * (1-d) + v3 * d * d; - const f64 inv = (T) 1.0 - d; - const f64 mul0 = inv * inv; - const f64 mul1 = (T) 2.0 * d * inv; - const f64 mul2 = d * d; - - return vector3d<T> ((T)(X * mul0 + v2.X * mul1 + v3.X * mul2), - (T)(Y * mul0 + v2.Y * mul1 + v3.Y * mul2), - (T)(Z * mul0 + v2.Z * mul1 + v3.Z * mul2)); - } - - //! Sets this vector to the linearly interpolated vector between a and b. - /** \param a first vector to interpolate with, maximum at 1.0f - \param b second vector to interpolate with, maximum at 0.0f - \param d Interpolation value between 0.0f (all vector b) and 1.0f (all vector a) - Note that this is the opposite direction of interpolation to getInterpolated_quadratic() - */ - vector3d<T>& interpolate(const vector3d<T>& a, const vector3d<T>& b, f64 d) - { - X = (T)((f64)b.X + ( ( a.X - b.X ) * d )); - Y = (T)((f64)b.Y + ( ( a.Y - b.Y ) * d )); - Z = (T)((f64)b.Z + ( ( a.Z - b.Z ) * d )); - return *this; - } - - - //! Get the rotations that would make a (0,0,1) direction vector point in the same direction as this direction vector. - /** Thanks to Arras on the Irrlicht forums for this method. This utility method is very useful for - orienting scene nodes towards specific targets. For example, if this vector represents the difference - between two scene nodes, then applying the result of getHorizontalAngle() to one scene node will point - it at the other one. - Example code: - // Where target and seeker are of type ISceneNode* - const vector3df toTarget(target->getAbsolutePosition() - seeker->getAbsolutePosition()); - const vector3df requiredRotation = toTarget.getHorizontalAngle(); - seeker->setRotation(requiredRotation); - - \return A rotation vector containing the X (pitch) and Y (raw) rotations (in degrees) that when applied to a - +Z (e.g. 0, 0, 1) direction vector would make it point in the same direction as this vector. The Z (roll) rotation - is always 0, since two Euler rotations are sufficient to point in any given direction. */ - vector3d<T> getHorizontalAngle() const - { - vector3d<T> angle; - - angle.Y = (T)(atan2(X, Z) * (T) RADTODEG64); - - if (angle.Y < 0.0f) - angle.Y += 360.0f; - if (angle.Y >= 360.0f) - angle.Y -= 360.0f; - - const T z1 = core::squareroot(X*X + Z*Z); - - angle.X = (T)(atan2(z1, (T)Y) * (T) RADTODEG64 - (T) 90.0); - - if (angle.X < (T) 0.0) - angle.X += (T) 360.0; - if (angle.X >= (T) 360.0) - angle.X -= (T) 360.0; - - return angle; - } - - //! Builds a direction vector from (this) rotation vector. - /** This vector is assumed to be a rotation vector composed of 3 Euler angle rotations, in degrees. - The implementation performs the same calculations as using a matrix to do the rotation. - - \param[in] forwards The direction representing "forwards" which will be rotated by this vector. - If you do not provide a direction, then the +Z axis (0, 0, 1) will be assumed to be forwards. - \return A direction vector calculated by rotating the forwards direction by the 3 Euler angles - (in degrees) represented by this vector. */ - vector3d<T> rotationToDirection(const vector3d<T> & forwards = vector3d<T>(0, 0, 1)) const - { - const f64 cr = cos( core::DEGTORAD64 * X ); - const f64 sr = sin( core::DEGTORAD64 * X ); - const f64 cp = cos( core::DEGTORAD64 * Y ); - const f64 sp = sin( core::DEGTORAD64 * Y ); - const f64 cy = cos( core::DEGTORAD64 * Z ); - const f64 sy = sin( core::DEGTORAD64 * Z ); - - const f64 srsp = sr*sp; - const f64 crsp = cr*sp; - - const f64 pseudoMatrix[] = { - ( cp*cy ), ( cp*sy ), ( -sp ), - ( srsp*cy-cr*sy ), ( srsp*sy+cr*cy ), ( sr*cp ), - ( crsp*cy+sr*sy ), ( crsp*sy-sr*cy ), ( cr*cp )}; - - return vector3d<T>( - (T)(forwards.X * pseudoMatrix[0] + - forwards.Y * pseudoMatrix[3] + - forwards.Z * pseudoMatrix[6]), - (T)(forwards.X * pseudoMatrix[1] + - forwards.Y * pseudoMatrix[4] + - forwards.Z * pseudoMatrix[7]), - (T)(forwards.X * pseudoMatrix[2] + - forwards.Y * pseudoMatrix[5] + - forwards.Z * pseudoMatrix[8])); - } - - //! Fills an array of 4 values with the vector data (usually floats). - /** Useful for setting in shader constants for example. The fourth value - will always be 0. */ - void getAs4Values(T* array) const - { - array[0] = X; - array[1] = Y; - array[2] = Z; - array[3] = 0; - } - - //! X coordinate of the vector - T X; - - //! Y coordinate of the vector - T Y; - - //! Z coordinate of the vector - T Z; - }; - - - //! Typedef for a f32 3d vector. - typedef vector3d<f32> vector3df; - - //! Typedef for an integer 3d vector. - typedef vector3d<s32> vector3di; - - //! Function multiplying a scalar and a vector component-wise. - template<class S, class T> - vector3d<T> operator*(const S scalar, const vector3d<T>& vector) { return vector*scalar; } - -} // end namespace core -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/readme.txt b/irrlicht-1.6/readme.txt deleted file mode 100644 index 141c308b3..000000000 --- a/irrlicht-1.6/readme.txt +++ /dev/null @@ -1,238 +0,0 @@ -========================================================================== -The Irrlicht Engine SDK version 1.5 -========================================================================== - - Welcome the Irrlicht Engine SDK. - - Content of this file: - - 1. Directory Structure Overview - 2. How To Start - 3. Requirements - 4. Release Notes - 5. License - 6. Contact - - - -========================================================================== -1. Directory Structure Overview -========================================================================== - - You will find some directories after uncompressing the archive of the - SDK. These are: - - \bin The compiled library Irrlicht.DLL and some compiled demo - and example applications, just start them to see the - Irrlicht Engine in action. Windows only. - \doc Documentation of the Irrlicht Engine. - \examples Examples and tutorials showing how to use the engine with - C++. - \example.net Examples and tutorials showing how to use the engine with - .NET languages. - \exporters Exporters and tools for various 3D modelling packages. There - is a readme file with more details in the directory. - \include Header files to include when programming with the engine. - \lib Libs to link with your programs when using the engine. - \media Graphics and sound resources for the demo applications and - examples. - \source The source code of the Irrlicht Engine. This code is - not needed to develop applications with the engine, - but it is included to enable recompilation and - debugging, if necessary. - \tools Useful tools (with sourcecode) for the engine. - - - -========================================================================== -2. How to start -========================================================================== - - To see the engine in action in Windows, just go to the \bin\Win32-VisualStudio - directory, and start some applications. There should also be an - application named Demo.exe which should show the most - interesting features of Irrlicht. - - To start developing own applications and games with the engine take - a look at the 01.HelloWorld example in the \examples directory. - There is also a .html file with a tutorial which should be - easily comprehensible. - - The Irrlicht Engine is a static lib under linux. A precompiled version can be - generated from the sources using the Makefile in source/Irrlicht. Unzip the - file source.zip in the /source directory. Run 'make' in the newly created - subfolder source/Irrlicht. After this you should be able to 'make' all - example applications in /examples. You can run the examples directly from the - directory they are created in. - - It is also possible to use Irrlicht as shared object - (libIrrlicht.so.versionNumber). Use the proper makefile target for this by - running 'make sharedlib' in the source folder. See the Makefile for details. - - For OSX you can find an XCode project file in source/Irrlicht/MacOSX. This will - build the libIrrlicht.a library necessary to create the apps. - -========================================================================== -3. Requirements -========================================================================== - - You can use one of the following compilers/IDEs to develop applications - with Irrlicht or recompile the engine. However, other compilers/IDEs may - work as well, we simply didn't test them. - - * gcc 3.3 - * gcc 3.4 - * gcc 4.x - * Visual Studio.NET 2003 (7.1) - * Visual Studio 2005 (8.0) - * Visual Studio 2008 (9.0) - * Code::Blocks 1.0 (& gcc or visual studio toolkit) - * DevC++ 5.0 & gcc (project files included) - - If you ever want to (re)compile the engine yourself (which means you don't - want to use the precompiled version) you need the following: - - * Windows: - * Needed: PlatformSDK (which usually comes with all IDEs, download - it separately for MSVC Express 2005) - * Optional: DirectX SDK, for D3D9 support - * Optional: DirectX SDK prior to May 2006, for D3D8 support - - * Linux: - * Needed: XServer with include files - * Optional: OpenGL headers and libraries (libGL.so), for OpenGL support - * GLX + XF86VidMode or XRandr extension (X11 support libraries, - the latter two for fullscreen mode) - - * OSX: - * Needed: XCode and Cocoa framework - * Needed: OpenGL headers and libraries - -========================================================================== -4. Release Notes -========================================================================== - - Informations about changes in this new version of the engine can be - found in changes.txt. - - Please note that the textures, 3D models and levels are copyright - by their authors and not covered by the Irrlicht engine license. - -========================================================================== -5. License -========================================================================== - - The license of the Irrlicht Engine is based on the zlib/libpng license. - Even though this license does not require you to mention that you are - using the Irrlicht Engine in your product, an acknowledgement - would be highly appreciated. - - Please note that the Irrlicht Engine is based in part on the work of - the Independent JPEG Group, the zlib, and libpng. This means that if you use - the Irrlicht Engine in your product, you must acknowledge somewhere - in your documentation that you've used the IJG code and libpng. It would - also be nice to mention that you use the Irrlicht Engine and the zlib. - See the README files in the jpeglib and the zlib for - further informations. - - - The Irrlicht Engine License - =========================== - - Copyright (C) 2002-2008 Nikolaus Gebhardt - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgement in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be clearly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - -========================================================================== -6. Contact -========================================================================== - - If you have problems, questions or suggestions, please visit the - official homepage of the Irrlicht Engine: - - http://irrlicht.sourceforge.net - - You will find forums, bugtrackers, patches, tutorials, and other stuff - which will help you out. - - If want to contact the team of the engine, please send an email to - Nikolaus Gebhardt: - - irrlicht@users.sourceforge.net - - Please also not that parts of the engine have been written or contributed - by other people. Especially: (There are probably more people, sorry if I forgot one. - See http://irrlicht.sourceforge.net/author.html for more informations) - - Christian Stehno (hybrid) Contribution Coordinator/Developer - Gareth Davidson (bitplane) Developer/ Forum admin - Thomas Alten (burningwater) Wrote the burningsvideo software rasterizer - Luke P. Hoschke (luke) Wrote the b3d loader, the new animation system, VBOs and other things - Colin MacDonald (rogerborg) - Dean Wadsworth (varmint) OSX port maintainer and game developer - Alvaro F. Celis (afecelis) Lots of work in the community, for example video tutorials about Irrlicht, forum admin - John Goewert (Saigumi) Wrote some tutorials for the Irrlicht Engine and doing admin stuff - Jam Takes care of moderating the forums and keeps them clean from those evil spammers. - - Etienne Petitjean wrote the MacPort of the engine - Mark Jeacocke Wrote lots of helpful comments and ideas in the forums and per email. - Julio Gorg Created the 'Unofficial DirectX 9.0 Driver for the Irrlicht Engine' - Andy Spurgeon Wrote the Dev-Cpp tutorial. - Andr Simon Wrote the Codewarrior tutorial. - KnightToFlight Created the unoffical terrain renderer addon for the Irrlicht Engine. - Jon Pry Wrote the code to load compressed TGA files. - Matthew Couch Wrote the tokamak integration tutorial. - Max Winkel Wrote the splitscreen tutorial. - Gorgon Zola Wrote the ODE integration tutorial. - Dean P. Macri Sent in code for curved surfaces and PCX Loading. - Sirshane Made several bug fixes, sent in code for making the mouse cursor invisible in Linux. - Matthias Gall Sent in code for a spline scene node animator and reported lots of bugs. - Mario Gruber Suggested triangle fan drawing and sent in code for this. - Ariaci Spotted out a bug in the ATI driver. - Dr Andros C Bragianos Improved texture mapping in cube scene node. - Philipp Dortmann Sent in code for stencil buffer support for OpenGL. - Jerome Nichols Created the Irrlicht/Ruby interface located at irr.rubyforge.org - Vash TheStampede Sent code for missing Draw2DLine() implementations - MattyBoy XBOX support suggestions - Oliver Klems createImageFromData() method suggestion/implementation - Jox really, really a lot of bug fixes, and the LMTS file loader - Zola Quaternion method additions - Tomasz Nowakowski various bug fixes - Nicholas Bray stencil shadow bug fixes with OpenGL - REAPER mouswheel events for scrollbar - Calimero various bug fixes like vector2d operators - Haddock bugfix in the linked list - G.o.D XML parser fix - Erik Zilli Translated some of the tutorials from my stuttering english into real english. :) - Martin Piskernig Linux bugfixing and testing - Soconne Wrote the original terrain renderer were Irrlichts terrain renderer of Irrlicht is based on it. - Spintz GeoMipMap scene node, terrain renderer of Irrlicht is based on it. - Murphy McCauley OCT file loader, MIM tools - Saurav Mohapatra IrrCSM, and lots of addons, suggestions and bug reports - Zhuck Dimitry My3D Tools - Terry Welsh Allowed me to use the textures of his 'Parallax Mapping with Offset Limiting' paper for the parallax demo of Irrlicht - rt Wrote the original .png loader for Irrlicht - Salvatore Russo Wrote the original .dmf loader for Irrlicht - Vox Various bug reports and fixes - atomice Contributed code for a ms3d loader enhancement - William Finlayson OpenGL RTT, GLSL support and the reflection 2 layer material for OpenGL. - Delight Various code contributions for Irrlicht.NET (particle system, basic shader support and more) - Michael Zoech Improved GLSL support - Greg Roelofs Created the zlib and libpng - Guy Eric Schalnat, Andreas Dilger, Glenn Randers-Pehrson and others Created libpng - The Independent JPEG Group Created JPEG lib diff --git a/irrlicht-1.6/source/CMakeLists.txt b/irrlicht-1.6/source/CMakeLists.txt deleted file mode 100644 index ebdd632db..000000000 --- a/irrlicht-1.6/source/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS( Irrlicht ) diff --git a/irrlicht-1.6/source/Irrlicht/BuiltInFont.h b/irrlicht-1.6/source/Irrlicht/BuiltInFont.h deleted file mode 100644 index 9da9d0afb..000000000 --- a/irrlicht-1.6/source/Irrlicht/BuiltInFont.h +++ /dev/null @@ -1,1075 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __BUILD_IN_FONT_H_INCLUDED__ -#define __BUILD_IN_FONT_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -// header file generated by Bin2H, copyright 2002 by N.Gebhardt. -// Bin2H is Freeware. Download it freely from www.code3d.com. -// for the source bitmap, see builtInFont.bmp - -namespace irr -{ -namespace gui -{ -#ifdef _IRR_COMPILE_WITH_BMP_LOADER_ -u8 BuiltInFontData[] = -{ - 0x42, 0x4d, 0x4a, 0x20, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, 0x28, 0x00, - 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, - 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x63, 0x0b, - 0x00, 0x00, 0x63, 0x0b, 0x00, 0x00, 0x05, 0x00, - 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, - 0x18, 0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, - 0xff, 0x00, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x12, 0x22, 0x21, 0x22, - 0x22, 0x22, 0x21, 0x22, 0x22, 0x22, 0x22, 0x12, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x00, - 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x04, - 0x44, 0x44, 0x02, 0x04, 0x44, 0x44, 0x40, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x04, - 0x44, 0x44, 0x02, 0x04, 0x44, 0x44, 0x40, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x42, 0x22, 0x22, 0x22, 0x04, - 0x44, 0x44, 0x02, 0x04, 0x44, 0x44, 0x40, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x24, 0x44, 0x22, 0x44, 0x42, 0x04, - 0x44, 0x44, 0x02, 0x04, 0x44, 0x44, 0x40, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x42, 0x22, 0x22, 0x22, 0x04, - 0x40, 0x00, 0x02, 0x00, 0x44, 0x00, 0x00, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x04, - 0x40, 0x40, 0x22, 0x20, 0x00, 0x02, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x04, - 0x40, 0x02, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x00, - 0x00, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x32, 0x22, 0x23, 0x22, 0x22, 0x32, - 0x22, 0x22, 0x22, 0x32, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x12, 0x22, - 0x22, 0x22, 0x21, 0x22, 0x22, 0x22, 0x12, 0x22, - 0x22, 0x22, 0x12, 0x22, 0x22, 0x22, 0x12, 0x22, - 0x21, 0x22, 0x22, 0x12, 0x22, 0x22, 0x22, 0x12, - 0x22, 0x22, 0x12, 0x22, 0x21, 0x22, 0x22, 0x12, - 0x22, 0x22, 0x12, 0x22, 0x22, 0x22, 0x21, 0x22, - 0x22, 0x22, 0x22, 0x12, 0x22, 0x22, 0x12, 0x22, - 0x22, 0x12, 0x22, 0x22, 0x22, 0x22, 0x12, 0x22, - 0x22, 0x22, 0x44, 0x44, 0x44, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x44, 0x44, 0x44, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x24, 0x22, 0x24, 0x22, 0x24, - 0x22, 0x22, 0x24, 0x42, 0x24, 0x42, 0x22, 0x22, - 0x22, 0x22, 0x42, 0x22, 0x24, 0x22, 0x24, 0x42, - 0x22, 0x24, 0x42, 0x44, 0x44, 0x44, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x42, 0x42, 0x22, 0x22, 0x24, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x24, 0x42, 0x44, 0x22, 0x44, - 0x42, 0x22, 0x22, 0x44, 0x22, 0x44, 0x22, 0x22, - 0x22, 0x22, 0x42, 0x22, 0x24, 0x22, 0x22, 0x44, - 0x22, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x42, 0x22, 0x22, 0x24, - 0x42, 0x44, 0x22, 0x22, 0x44, 0x42, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x24, 0x42, 0x24, 0x42, 0x44, - 0x22, 0x44, 0x22, 0x22, 0x44, 0x42, 0x24, 0x42, - 0x44, 0x22, 0x22, 0x24, 0x42, 0x24, 0x22, 0x22, - 0x22, 0x22, 0x42, 0x22, 0x24, 0x44, 0x22, 0x24, - 0x44, 0x42, 0x22, 0x22, 0x22, 0x22, 0x24, 0x44, - 0x44, 0x44, 0x22, 0x24, 0x44, 0x22, 0x22, 0x44, - 0x42, 0x44, 0x42, 0x24, 0x44, 0x44, 0x22, 0x24, - 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x24, 0x42, 0x22, 0x44, 0x22, 0x44, 0x22, 0x24, - 0x42, 0x24, 0x42, 0x22, 0x24, 0x22, 0x24, 0x22, - 0x24, 0x22, 0x22, 0x22, 0x44, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x44, 0x44, 0x44, 0x24, 0x22, 0x22, - 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x44, - 0x44, 0x42, 0x22, 0x44, 0x44, 0x42, 0x24, 0x44, - 0x42, 0x44, 0x44, 0x24, 0x42, 0x44, 0x42, 0x22, - 0x22, 0x22, 0x22, 0x44, 0x42, 0x22, 0x42, 0x22, - 0x44, 0x44, 0x24, 0x42, 0x24, 0x42, 0x22, 0x22, - 0x44, 0x22, 0x44, 0x24, 0x22, 0x24, 0x22, 0x24, - 0x22, 0x22, 0x22, 0x22, 0x24, 0x42, 0x22, 0x22, - 0x22, 0x22, 0x44, 0x44, 0x44, 0x24, 0x22, 0x24, - 0x44, 0x42, 0x22, 0x22, 0x22, 0x22, 0x22, 0x24, - 0x44, 0x22, 0x24, 0x44, 0x44, 0x44, 0x22, 0x44, - 0x42, 0x44, 0x42, 0x24, 0x22, 0x24, 0x44, 0x22, - 0x24, 0x22, 0x22, 0x24, 0x22, 0x24, 0x44, 0x22, - 0x44, 0x44, 0x22, 0x44, 0x22, 0x44, 0x22, 0x24, - 0x42, 0x24, 0x42, 0x24, 0x42, 0x44, 0x22, 0x44, - 0x42, 0x22, 0x22, 0x22, 0x22, 0x44, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x42, 0x22, 0x24, 0x22, 0x44, - 0x22, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x42, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x24, - 0x42, 0x44, 0x22, 0x22, 0x22, 0x22, 0x44, 0x22, - 0x44, 0x42, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x24, 0x42, 0x22, 0x24, 0x42, 0x24, 0x42, 0x44, - 0x22, 0x44, 0x22, 0x22, 0x44, 0x42, 0x24, 0x42, - 0x44, 0x22, 0x22, 0x22, 0x22, 0x24, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x44, 0x44, 0x44, 0x24, 0x42, - 0x22, 0x24, 0x42, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x42, 0x42, 0x22, 0x22, 0x22, 0x22, 0x24, 0x24, - 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x24, 0x22, 0x24, 0x22, - 0x24, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x44, 0x44, 0x44, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x32, 0x22, 0x22, 0x22, 0x23, 0x22, - 0x22, 0x22, 0x22, 0x32, 0x22, 0x22, 0x23, 0x22, - 0x22, 0x22, 0x23, 0x22, 0x22, 0x22, 0x23, 0x22, - 0x22, 0x32, 0x22, 0x23, 0x22, 0x22, 0x22, 0x23, - 0x22, 0x22, 0x23, 0x22, 0x22, 0x32, 0x22, 0x23, - 0x22, 0x22, 0x23, 0x22, 0x22, 0x22, 0x22, 0x32, - 0x22, 0x22, 0x22, 0x23, 0x22, 0x22, 0x23, 0x22, - 0x22, 0x23, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x12, 0x22, 0x21, 0x22, - 0x12, 0x22, 0x12, 0x22, 0x12, 0x22, 0x12, 0x22, - 0x22, 0x12, 0x22, 0x21, 0x22, 0x22, 0x21, 0x22, - 0x22, 0x21, 0x22, 0x22, 0x21, 0x22, 0x22, 0x21, - 0x22, 0x22, 0x21, 0x22, 0x22, 0x12, 0x22, 0x22, - 0x12, 0x22, 0x21, 0x22, 0x22, 0x12, 0x22, 0x21, - 0x22, 0x22, 0x12, 0x22, 0x21, 0x22, 0x22, 0x12, - 0x22, 0x21, 0x22, 0x12, 0x22, 0x22, 0x22, 0x22, - 0x12, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x42, 0x22, 0x24, 0x22, 0x22, - 0x42, 0x22, 0x22, 0x24, 0x44, 0x44, 0x44, 0x44, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x24, 0x22, 0x24, 0x22, 0x22, - 0x24, 0x22, 0x22, 0x24, 0x22, 0x22, 0x22, 0x24, - 0x22, 0x22, 0x22, 0x44, 0x22, 0x24, 0x42, 0x24, - 0x22, 0x42, 0x22, 0x42, 0x22, 0x42, 0x22, 0x24, - 0x42, 0x22, 0x42, 0x42, 0x22, 0x44, 0x22, 0x22, - 0x44, 0x22, 0x22, 0x44, 0x22, 0x22, 0x44, 0x22, - 0x22, 0x44, 0x22, 0x22, 0x22, 0x22, 0x44, 0x42, - 0x22, 0x24, 0x42, 0x22, 0x44, 0x22, 0x24, 0x42, - 0x22, 0x44, 0x22, 0x24, 0x22, 0x24, 0x42, 0x22, - 0x24, 0x22, 0x24, 0x24, 0x22, 0x22, 0x22, 0x24, - 0x22, 0x22, 0x24, 0x22, 0x22, 0x42, 0x22, 0x24, - 0x22, 0x42, 0x22, 0x42, 0x22, 0x42, 0x22, 0x42, - 0x24, 0x22, 0x42, 0x42, 0x24, 0x22, 0x42, 0x24, - 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, - 0x24, 0x22, 0x42, 0x22, 0x42, 0x22, 0x44, 0x24, - 0x22, 0x42, 0x42, 0x24, 0x24, 0x22, 0x42, 0x42, - 0x24, 0x24, 0x22, 0x42, 0x42, 0x24, 0x24, 0x22, - 0x42, 0x42, 0x24, 0x24, 0x22, 0x22, 0x22, 0x24, - 0x22, 0x22, 0x24, 0x24, 0x22, 0x42, 0x42, 0x24, - 0x22, 0x42, 0x22, 0x42, 0x22, 0x42, 0x22, 0x24, - 0x42, 0x22, 0x42, 0x42, 0x24, 0x22, 0x42, 0x24, - 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, - 0x24, 0x22, 0x42, 0x24, 0x44, 0x22, 0x42, 0x44, - 0x22, 0x42, 0x42, 0x24, 0x24, 0x22, 0x42, 0x42, - 0x24, 0x24, 0x22, 0x42, 0x42, 0x24, 0x24, 0x22, - 0x42, 0x42, 0x24, 0x24, 0x22, 0x22, 0x22, 0x24, - 0x22, 0x22, 0x22, 0x42, 0x22, 0x24, 0x22, 0x24, - 0x22, 0x42, 0x22, 0x42, 0x22, 0x42, 0x22, 0x22, - 0x42, 0x22, 0x44, 0x22, 0x22, 0x44, 0x22, 0x22, - 0x44, 0x22, 0x22, 0x44, 0x22, 0x22, 0x44, 0x22, - 0x22, 0x44, 0x22, 0x22, 0x42, 0x22, 0x24, 0x44, - 0x22, 0x42, 0x42, 0x24, 0x24, 0x22, 0x42, 0x42, - 0x24, 0x24, 0x22, 0x42, 0x42, 0x24, 0x42, 0x22, - 0x42, 0x42, 0x24, 0x24, 0x22, 0x22, 0x22, 0x24, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x24, - 0x42, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x24, 0x22, 0x22, - 0x22, 0x22, 0x24, 0x24, 0x22, 0x22, 0x22, 0x24, - 0x22, 0x22, 0x24, 0x24, 0x22, 0x42, 0x42, 0x24, - 0x22, 0x42, 0x24, 0x24, 0x24, 0x24, 0x22, 0x22, - 0x22, 0x22, 0x44, 0x22, 0x22, 0x24, 0x22, 0x22, - 0x42, 0x22, 0x22, 0x42, 0x42, 0x22, 0x44, 0x22, - 0x24, 0x22, 0x42, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x42, 0x22, 0x42, 0x22, 0x42, 0x42, - 0x24, 0x24, 0x22, 0x24, 0x22, 0x22, 0x22, 0x22, - 0x42, 0x42, 0x24, 0x24, 0x44, 0x44, 0x44, 0x44, - 0x22, 0x22, 0x22, 0x42, 0x22, 0x22, 0x22, 0x42, - 0x22, 0x24, 0x22, 0x42, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x24, 0x42, 0x22, 0x42, 0x22, 0x22, - 0x24, 0x22, 0x22, 0x24, 0x22, 0x22, 0x24, 0x42, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x24, 0x22, 0x22, 0x24, 0x22, 0x24, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x42, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x24, 0x44, 0x44, 0x44, 0x44, - 0x22, 0x22, 0x32, 0x22, 0x23, 0x22, 0x22, 0x32, - 0x23, 0x22, 0x23, 0x22, 0x23, 0x22, 0x23, 0x22, - 0x22, 0x23, 0x22, 0x22, 0x32, 0x22, 0x22, 0x32, - 0x22, 0x22, 0x32, 0x22, 0x22, 0x32, 0x22, 0x22, - 0x32, 0x22, 0x22, 0x32, 0x22, 0x23, 0x22, 0x22, - 0x23, 0x22, 0x22, 0x32, 0x22, 0x23, 0x22, 0x22, - 0x32, 0x22, 0x23, 0x22, 0x22, 0x32, 0x22, 0x23, - 0x22, 0x22, 0x32, 0x23, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x12, 0x22, 0x22, - 0x21, 0x22, 0x22, 0x12, 0x22, 0x22, 0x21, 0x22, - 0x22, 0x22, 0x12, 0x22, 0x22, 0x21, 0x22, 0x22, - 0x22, 0x12, 0x22, 0x22, 0x21, 0x22, 0x22, 0x22, - 0x12, 0x22, 0x22, 0x12, 0x22, 0x22, 0x12, 0x22, - 0x21, 0x22, 0x22, 0x12, 0x22, 0x21, 0x22, 0x22, - 0x12, 0x22, 0x21, 0x22, 0x22, 0x12, 0x22, 0x22, - 0x21, 0x22, 0x22, 0x12, 0x22, 0x21, 0x22, 0x22, - 0x12, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x24, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x44, 0x42, 0x22, 0x24, 0x44, - 0x22, 0x22, 0x22, 0x22, 0x44, 0x44, 0x22, 0x22, - 0x44, 0x42, 0x22, 0x24, 0x44, 0x22, 0x22, 0x44, - 0x42, 0x22, 0x24, 0x44, 0x22, 0x22, 0x24, 0x22, - 0x22, 0x42, 0x22, 0x22, 0x42, 0x42, 0x22, 0x24, - 0x42, 0x22, 0x44, 0x22, 0x24, 0x42, 0x22, 0x44, - 0x22, 0x24, 0x42, 0x22, 0x44, 0x22, 0x44, 0x44, - 0x42, 0x22, 0x44, 0x22, 0x24, 0x42, 0x22, 0x44, - 0x22, 0x22, 0x24, 0x22, 0x24, 0x22, 0x42, 0x22, - 0x42, 0x24, 0x24, 0x22, 0x44, 0x22, 0x42, 0x24, - 0x22, 0x24, 0x22, 0x42, 0x22, 0x42, 0x24, 0x22, - 0x24, 0x22, 0x42, 0x22, 0x42, 0x22, 0x24, 0x22, - 0x22, 0x44, 0x42, 0x22, 0x42, 0x24, 0x22, 0x42, - 0x42, 0x24, 0x24, 0x22, 0x42, 0x42, 0x24, 0x24, - 0x22, 0x42, 0x42, 0x24, 0x24, 0x22, 0x42, 0x44, - 0x22, 0x24, 0x22, 0x22, 0x42, 0x22, 0x24, 0x22, - 0x22, 0x22, 0x24, 0x22, 0x24, 0x22, 0x42, 0x22, - 0x42, 0x22, 0x42, 0x22, 0x42, 0x42, 0x42, 0x24, - 0x22, 0x24, 0x22, 0x42, 0x22, 0x42, 0x24, 0x22, - 0x24, 0x22, 0x42, 0x22, 0x42, 0x22, 0x24, 0x22, - 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, 0x22, - 0x42, 0x22, 0x24, 0x22, 0x22, 0x42, 0x22, 0x24, - 0x22, 0x22, 0x42, 0x22, 0x24, 0x22, 0x22, 0x42, - 0x42, 0x24, 0x22, 0x22, 0x42, 0x42, 0x24, 0x24, - 0x22, 0x22, 0x24, 0x22, 0x24, 0x22, 0x42, 0x22, - 0x42, 0x24, 0x24, 0x22, 0x42, 0x42, 0x42, 0x24, - 0x22, 0x24, 0x22, 0x42, 0x22, 0x42, 0x24, 0x22, - 0x24, 0x22, 0x42, 0x22, 0x42, 0x22, 0x24, 0x22, - 0x22, 0x42, 0x24, 0x22, 0x44, 0x42, 0x22, 0x44, - 0x22, 0x24, 0x42, 0x22, 0x44, 0x22, 0x24, 0x42, - 0x22, 0x44, 0x22, 0x24, 0x42, 0x22, 0x44, 0x24, - 0x42, 0x22, 0x44, 0x22, 0x24, 0x22, 0x22, 0x42, - 0x22, 0x22, 0x24, 0x22, 0x24, 0x22, 0x42, 0x22, - 0x42, 0x22, 0x22, 0x22, 0x42, 0x24, 0x42, 0x24, - 0x22, 0x24, 0x22, 0x42, 0x22, 0x42, 0x24, 0x22, - 0x24, 0x22, 0x42, 0x22, 0x42, 0x22, 0x42, 0x42, - 0x22, 0x44, 0x42, 0x22, 0x42, 0x42, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x44, 0x42, 0x22, 0x24, 0x44, - 0x22, 0x22, 0x22, 0x22, 0x24, 0x44, 0x42, 0x24, - 0x22, 0x24, 0x22, 0x42, 0x22, 0x42, 0x24, 0x22, - 0x24, 0x22, 0x42, 0x22, 0x42, 0x24, 0x22, 0x24, - 0x22, 0x42, 0x22, 0x22, 0x24, 0x22, 0x22, 0x24, - 0x22, 0x22, 0x42, 0x22, 0x42, 0x42, 0x24, 0x42, - 0x22, 0x42, 0x42, 0x24, 0x42, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x42, 0x22, 0x42, - 0x22, 0x22, 0x22, 0x42, 0x42, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x24, 0x22, 0x22, 0x22, 0x42, 0x22, 0x22, 0x42, - 0x42, 0x22, 0x22, 0x22, 0x22, 0x22, 0x24, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x42, - 0x22, 0x22, 0x24, 0x22, 0x24, 0x22, 0x22, 0x44, - 0x22, 0x22, 0x22, 0x24, 0x42, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x24, 0x22, 0x22, 0x24, - 0x22, 0x22, 0x32, 0x24, 0x24, 0x23, 0x24, 0x24, - 0x22, 0x32, 0x22, 0x23, 0x22, 0x22, 0x22, 0x32, - 0x42, 0x22, 0x23, 0x22, 0x24, 0x22, 0x32, 0x24, - 0x22, 0x23, 0x24, 0x24, 0x22, 0x32, 0x22, 0x42, - 0x23, 0x22, 0x22, 0x23, 0x22, 0x22, 0x23, 0x22, - 0x22, 0x32, 0x22, 0x23, 0x22, 0x22, 0x32, 0x22, - 0x23, 0x22, 0x22, 0x32, 0x22, 0x23, 0x22, 0x22, - 0x22, 0x32, 0x22, 0x23, 0x22, 0x22, 0x32, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x12, 0x22, 0x22, - 0x21, 0x22, 0x22, 0x22, 0x12, 0x22, 0x22, 0x21, - 0x22, 0x22, 0x22, 0x12, 0x22, 0x22, 0x22, 0x21, - 0x22, 0x22, 0x21, 0x22, 0x22, 0x21, 0x22, 0x22, - 0x21, 0x22, 0x22, 0x21, 0x22, 0x22, 0x21, 0x22, - 0x12, 0x22, 0x12, 0x22, 0x12, 0x22, 0x12, 0x22, - 0x22, 0x21, 0x22, 0x22, 0x22, 0x12, 0x22, 0x22, - 0x21, 0x22, 0x22, 0x22, 0x12, 0x22, 0x22, 0x21, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x24, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x24, 0x22, 0x24, 0x22, 0x42, 0x22, - 0x42, 0x24, 0x22, 0x24, 0x22, 0x42, 0x22, 0x42, - 0x24, 0x22, 0x24, 0x22, 0x42, 0x24, 0x44, 0x42, - 0x22, 0x44, 0x22, 0x24, 0x44, 0x42, 0x24, 0x44, - 0x42, 0x24, 0x44, 0x42, 0x24, 0x44, 0x42, 0x24, - 0x22, 0x42, 0x22, 0x42, 0x22, 0x42, 0x22, 0x44, - 0x44, 0x22, 0x24, 0x22, 0x24, 0x22, 0x24, 0x44, - 0x22, 0x22, 0x44, 0x42, 0x22, 0x24, 0x44, 0x22, - 0x22, 0x22, 0x24, 0x44, 0x44, 0x22, 0x44, 0x44, - 0x42, 0x24, 0x44, 0x44, 0x22, 0x44, 0x44, 0x42, - 0x24, 0x44, 0x44, 0x22, 0x44, 0x44, 0x22, 0x22, - 0x24, 0x22, 0x42, 0x24, 0x22, 0x22, 0x24, 0x22, - 0x22, 0x24, 0x22, 0x22, 0x24, 0x22, 0x22, 0x24, - 0x22, 0x42, 0x22, 0x42, 0x22, 0x42, 0x22, 0x42, - 0x22, 0x42, 0x24, 0x22, 0x24, 0x22, 0x42, 0x22, - 0x42, 0x24, 0x22, 0x24, 0x22, 0x42, 0x22, 0x42, - 0x22, 0x22, 0x22, 0x42, 0x42, 0x22, 0x24, 0x24, - 0x22, 0x22, 0x42, 0x42, 0x22, 0x24, 0x24, 0x22, - 0x22, 0x42, 0x42, 0x22, 0x24, 0x24, 0x22, 0x22, - 0x24, 0x22, 0x22, 0x24, 0x22, 0x22, 0x24, 0x22, - 0x22, 0x24, 0x22, 0x22, 0x24, 0x22, 0x22, 0x24, - 0x22, 0x42, 0x22, 0x42, 0x22, 0x42, 0x22, 0x42, - 0x22, 0x42, 0x24, 0x22, 0x44, 0x22, 0x42, 0x22, - 0x42, 0x24, 0x22, 0x24, 0x22, 0x42, 0x22, 0x42, - 0x22, 0x22, 0x22, 0x42, 0x42, 0x22, 0x24, 0x24, - 0x22, 0x22, 0x42, 0x42, 0x22, 0x24, 0x24, 0x22, - 0x22, 0x42, 0x42, 0x22, 0x22, 0x44, 0x44, 0x42, - 0x24, 0x22, 0x22, 0x24, 0x44, 0x42, 0x24, 0x44, - 0x42, 0x24, 0x44, 0x42, 0x24, 0x44, 0x42, 0x24, - 0x22, 0x42, 0x22, 0x42, 0x22, 0x42, 0x24, 0x44, - 0x22, 0x42, 0x24, 0x24, 0x24, 0x22, 0x42, 0x22, - 0x42, 0x24, 0x22, 0x24, 0x22, 0x42, 0x22, 0x42, - 0x22, 0x22, 0x22, 0x24, 0x22, 0x22, 0x22, 0x42, - 0x22, 0x22, 0x24, 0x22, 0x22, 0x22, 0x42, 0x22, - 0x22, 0x24, 0x22, 0x22, 0x22, 0x44, 0x22, 0x22, - 0x24, 0x22, 0x42, 0x24, 0x22, 0x22, 0x24, 0x22, - 0x22, 0x24, 0x22, 0x22, 0x24, 0x22, 0x22, 0x24, - 0x22, 0x42, 0x22, 0x42, 0x22, 0x42, 0x22, 0x42, - 0x22, 0x42, 0x24, 0x42, 0x24, 0x22, 0x42, 0x22, - 0x42, 0x24, 0x22, 0x24, 0x22, 0x42, 0x22, 0x42, - 0x22, 0x22, 0x22, 0x24, 0x22, 0x22, 0x22, 0x42, - 0x22, 0x22, 0x24, 0x22, 0x22, 0x22, 0x42, 0x22, - 0x22, 0x24, 0x22, 0x22, 0x22, 0x24, 0x44, 0x42, - 0x22, 0x44, 0x22, 0x24, 0x44, 0x42, 0x24, 0x44, - 0x42, 0x24, 0x44, 0x42, 0x24, 0x44, 0x42, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x44, - 0x44, 0x22, 0x24, 0x22, 0x24, 0x22, 0x24, 0x44, - 0x22, 0x22, 0x44, 0x42, 0x22, 0x24, 0x44, 0x22, - 0x22, 0x22, 0x22, 0x24, 0x22, 0x22, 0x24, 0x24, - 0x22, 0x22, 0x42, 0x42, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x42, 0x42, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x24, 0x22, 0x22, 0x42, - 0x22, 0x22, 0x42, 0x42, 0x22, 0x22, 0x22, 0x24, - 0x22, 0x42, 0x24, 0x24, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x42, 0x42, 0x22, 0x22, 0x42, - 0x22, 0x22, 0x24, 0x22, 0x22, 0x24, 0x24, 0x22, - 0x22, 0x22, 0x32, 0x22, 0x42, 0x23, 0x22, 0x42, - 0x22, 0x32, 0x24, 0x24, 0x23, 0x24, 0x24, 0x22, - 0x32, 0x24, 0x22, 0x23, 0x22, 0x22, 0x22, 0x22, - 0x32, 0x22, 0x22, 0x32, 0x42, 0x22, 0x32, 0x24, - 0x22, 0x32, 0x24, 0x22, 0x34, 0x22, 0x42, 0x32, - 0x23, 0x24, 0x23, 0x42, 0x23, 0x24, 0x23, 0x22, - 0x22, 0x22, 0x32, 0x24, 0x24, 0x23, 0x24, 0x22, - 0x22, 0x32, 0x22, 0x42, 0x23, 0x22, 0x42, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x12, 0x22, 0x12, 0x22, - 0x22, 0x21, 0x22, 0x21, 0x22, 0x22, 0x21, 0x22, - 0x22, 0x21, 0x22, 0x12, 0x22, 0x22, 0x21, 0x22, - 0x22, 0x12, 0x21, 0x22, 0x22, 0x12, 0x21, 0x22, - 0x12, 0x21, 0x22, 0x22, 0x21, 0x22, 0x22, 0x12, - 0x21, 0x22, 0x21, 0x22, 0x12, 0x22, 0x12, 0x22, - 0x22, 0x12, 0x22, 0x22, 0x21, 0x22, 0x22, 0x22, - 0x12, 0x22, 0x22, 0x21, 0x22, 0x22, 0x12, 0x22, - 0x22, 0x21, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x24, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x24, 0x42, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x42, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x24, 0x22, 0x22, 0x22, 0x44, 0x22, - 0x22, 0x22, 0x42, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x44, 0x22, 0x22, - 0x22, 0x22, 0x24, 0x24, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x42, 0x42, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x24, 0x44, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x24, 0x42, 0x42, 0x22, 0x44, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x42, - 0x42, 0x22, 0x42, 0x22, 0x42, 0x24, 0x22, 0x44, - 0x22, 0x42, 0x22, 0x42, 0x24, 0x22, 0x22, 0x42, - 0x22, 0x42, 0x22, 0x44, 0x22, 0x22, 0x22, 0x24, - 0x44, 0x22, 0x22, 0x22, 0x24, 0x24, 0x22, 0x22, - 0x22, 0x42, 0x22, 0x22, 0x24, 0x44, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x42, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x24, 0x24, 0x22, 0x22, 0x44, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x24, - 0x24, 0x22, 0x24, 0x24, 0x42, 0x22, 0x42, 0x44, - 0x22, 0x24, 0x24, 0x42, 0x22, 0x42, 0x22, 0x44, - 0x44, 0x42, 0x24, 0x24, 0x22, 0x22, 0x22, 0x42, - 0x22, 0x42, 0x24, 0x42, 0x22, 0x42, 0x42, 0x24, - 0x44, 0x42, 0x24, 0x22, 0x42, 0x22, 0x42, 0x22, - 0x22, 0x22, 0x22, 0x24, 0x44, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x24, 0x24, 0x22, 0x24, 0x44, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x44, 0x22, 0x42, - 0x42, 0x22, 0x22, 0x42, 0x42, 0x22, 0x24, 0x22, - 0x22, 0x22, 0x42, 0x42, 0x22, 0x42, 0x22, 0x24, - 0x24, 0x22, 0x24, 0x42, 0x22, 0x22, 0x22, 0x42, - 0x42, 0x42, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x42, 0x42, 0x42, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x42, 0x22, 0x42, 0x24, - 0x22, 0x22, 0x24, 0x24, 0x22, 0x24, 0x44, 0x22, - 0x42, 0x22, 0x22, 0x24, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x24, 0x22, 0x22, 0x22, 0x42, - 0x22, 0x22, 0x24, 0x22, 0x22, 0x22, 0x22, 0x24, - 0x24, 0x22, 0x24, 0x24, 0x22, 0x22, 0x22, 0x42, - 0x22, 0x42, 0x24, 0x42, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x42, 0x22, 0x42, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x42, 0x24, - 0x24, 0x22, 0x22, 0x22, 0x22, 0x24, 0x44, 0x22, - 0x22, 0x22, 0x22, 0x24, 0x22, 0x44, 0x22, 0x22, - 0x22, 0x22, 0x24, 0x22, 0x42, 0x22, 0x42, 0x24, - 0x22, 0x44, 0x22, 0x42, 0x22, 0x42, 0x22, 0x22, - 0x42, 0x22, 0x22, 0x42, 0x24, 0x24, 0x22, 0x24, - 0x44, 0x22, 0x22, 0x42, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x24, 0x44, 0x22, 0x22, - 0x22, 0x22, 0x42, 0x22, 0x22, 0x22, 0x42, 0x24, - 0x22, 0x42, 0x22, 0x22, 0x22, 0x22, 0x44, 0x22, - 0x22, 0x22, 0x22, 0x24, 0x22, 0x44, 0x22, 0x22, - 0x22, 0x22, 0x24, 0x22, 0x22, 0x22, 0x42, 0x22, - 0x22, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x42, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x44, - 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x42, 0x22, 0x32, 0x22, 0x23, 0x22, 0x23, 0x22, - 0x22, 0x22, 0x32, 0x22, 0x32, 0x22, 0x22, 0x32, - 0x22, 0x22, 0x32, 0x23, 0x22, 0x22, 0x22, 0x32, - 0x22, 0x23, 0x22, 0x32, 0x22, 0x23, 0x22, 0x32, - 0x23, 0x22, 0x32, 0x22, 0x22, 0x32, 0x22, 0x23, - 0x22, 0x32, 0x22, 0x32, 0x23, 0x22, 0x23, 0x22, - 0x22, 0x23, 0x22, 0x22, 0x22, 0x32, 0x22, 0x22, - 0x23, 0x22, 0x22, 0x22, 0x32, 0x22, 0x23, 0x24, - 0x22, 0x22, 0x22, 0x12, 0x21, 0x22, 0x12, 0x21, - 0x22, 0x12, 0x21, 0x22, 0x12, 0x21, 0x22, 0x12, - 0x21, 0x22, 0x12, 0x21, 0x22, 0x12, 0x21, 0x22, - 0x12, 0x21, 0x22, 0x12, 0x21, 0x22, 0x12, 0x21, - 0x22, 0x12, 0x21, 0x22, 0x12, 0x21, 0x22, 0x12, - 0x21, 0x22, 0x12, 0x21, 0x22, 0x12, 0x21, 0x22, - 0x12, 0x21, 0x22, 0x12, 0x21, 0x22, 0x22, 0x12, - 0x22, 0x22, 0x12, 0x22, 0x21, 0x22, 0x22, 0x12, - 0x21, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x42, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x42, 0x22, 0x42, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x42, 0x22, 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, - 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, - 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, - 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, - 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, - 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, - 0x22, 0x42, 0x22, 0x22, 0x42, 0x22, 0x44, 0x22, - 0x24, 0x44, 0x22, 0x22, 0x22, 0x22, 0x42, 0x22, - 0x42, 0x22, 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, - 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, - 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, - 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, - 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, - 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, - 0x22, 0x42, 0x22, 0x22, 0x42, 0x24, 0x22, 0x22, - 0x24, 0x22, 0x22, 0x22, 0x22, 0x24, 0x44, 0x22, - 0x42, 0x22, 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, - 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, - 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, - 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, - 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, - 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, - 0x22, 0x42, 0x22, 0x22, 0x42, 0x24, 0x22, 0x22, - 0x44, 0x42, 0x22, 0x22, 0x22, 0x22, 0x42, 0x22, - 0x22, 0x22, 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, - 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, - 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, - 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, - 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, - 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, - 0x22, 0x42, 0x22, 0x22, 0x22, 0x22, 0x44, 0x22, - 0x24, 0x22, 0x22, 0x42, 0x42, 0x24, 0x44, 0x22, - 0x42, 0x22, 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, - 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, - 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, - 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, - 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, - 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, - 0x22, 0x42, 0x22, 0x22, 0x42, 0x22, 0x24, 0x22, - 0x24, 0x24, 0x22, 0x24, 0x22, 0x22, 0x42, 0x22, - 0x42, 0x22, 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, - 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, - 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, - 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, - 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, - 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, - 0x22, 0x42, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x42, 0x22, 0x42, 0x42, 0x24, 0x24, 0x22, - 0x42, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x32, 0x23, 0x22, 0x32, 0x23, 0x22, - 0x32, 0x23, 0x22, 0x32, 0x23, 0x22, 0x32, 0x23, - 0x22, 0x32, 0x23, 0x22, 0x32, 0x23, 0x22, 0x32, - 0x23, 0x22, 0x32, 0x23, 0x22, 0x32, 0x23, 0x22, - 0x32, 0x23, 0x22, 0x32, 0x23, 0x22, 0x32, 0x23, - 0x22, 0x32, 0x23, 0x22, 0x32, 0x23, 0x22, 0x32, - 0x23, 0x22, 0x32, 0x23, 0x22, 0x32, 0x22, 0x23, - 0x22, 0x22, 0x23, 0x22, 0x22, 0x32, 0x22, 0x23, - 0x22, 0x22, 0x22, 0x22, 0x12, 0x22, 0x12, 0x22, - 0x22, 0x12, 0x22, 0x21, 0x22, 0x12, 0x21, 0x22, - 0x22, 0x12, 0x21, 0x22, 0x22, 0x22, 0x12, 0x22, - 0x21, 0x22, 0x22, 0x21, 0x22, 0x22, 0x21, 0x22, - 0x22, 0x21, 0x22, 0x21, 0x22, 0x22, 0x12, 0x22, - 0x12, 0x22, 0x21, 0x22, 0x22, 0x12, 0x22, 0x22, - 0x21, 0x22, 0x22, 0x12, 0x22, 0x21, 0x22, 0x22, - 0x12, 0x22, 0x12, 0x21, 0x22, 0x21, 0x22, 0x22, - 0x12, 0x21, 0x22, 0x22, 0x22, 0x22, 0x22, 0x24, - 0x42, 0x22, 0x22, 0x22, 0x22, 0x22, 0x42, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x24, 0x22, 0x22, 0x22, - 0x22, 0x42, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x42, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x24, 0x22, 0x22, 0x22, 0x22, 0x22, 0x42, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x24, 0x22, 0x22, 0x22, - 0x22, 0x42, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x24, 0x22, 0x22, 0x22, - 0x22, 0x24, 0x22, 0x42, 0x24, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x44, 0x22, 0x42, 0x22, 0x24, - 0x44, 0x22, 0x42, 0x42, 0x24, 0x22, 0x42, 0x24, - 0x24, 0x22, 0x42, 0x24, 0x24, 0x24, 0x22, 0x42, - 0x42, 0x22, 0x44, 0x22, 0x24, 0x44, 0x22, 0x22, - 0x44, 0x42, 0x24, 0x22, 0x24, 0x42, 0x22, 0x24, - 0x22, 0x24, 0x42, 0x22, 0x42, 0x22, 0x24, 0x24, - 0x22, 0x24, 0x24, 0x22, 0x24, 0x22, 0x24, 0x44, - 0x22, 0x24, 0x22, 0x42, 0x24, 0x22, 0x22, 0x22, - 0x22, 0x42, 0x24, 0x22, 0x22, 0x42, 0x22, 0x42, - 0x24, 0x22, 0x42, 0x42, 0x24, 0x22, 0x42, 0x24, - 0x24, 0x22, 0x42, 0x24, 0x24, 0x24, 0x22, 0x42, - 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, - 0x22, 0x42, 0x24, 0x22, 0x22, 0x24, 0x22, 0x42, - 0x22, 0x42, 0x42, 0x22, 0x42, 0x22, 0x24, 0x24, - 0x22, 0x22, 0x42, 0x22, 0x42, 0x42, 0x24, 0x22, - 0x22, 0x24, 0x22, 0x42, 0x24, 0x22, 0x22, 0x22, - 0x22, 0x42, 0x24, 0x24, 0x22, 0x42, 0x22, 0x42, - 0x24, 0x22, 0x42, 0x42, 0x24, 0x22, 0x42, 0x24, - 0x42, 0x22, 0x42, 0x24, 0x24, 0x24, 0x22, 0x42, - 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, - 0x22, 0x42, 0x24, 0x22, 0x24, 0x22, 0x22, 0x42, - 0x22, 0x42, 0x42, 0x24, 0x24, 0x22, 0x42, 0x42, - 0x42, 0x22, 0x42, 0x22, 0x42, 0x42, 0x22, 0x24, - 0x22, 0x42, 0x22, 0x42, 0x22, 0x42, 0x22, 0x22, - 0x22, 0x42, 0x22, 0x42, 0x22, 0x44, 0x22, 0x24, - 0x44, 0x22, 0x44, 0x22, 0x24, 0x22, 0x42, 0x24, - 0x24, 0x22, 0x42, 0x24, 0x44, 0x42, 0x22, 0x44, - 0x22, 0x22, 0x44, 0x22, 0x24, 0x44, 0x22, 0x22, - 0x44, 0x42, 0x24, 0x42, 0x22, 0x44, 0x22, 0x44, - 0x22, 0x42, 0x42, 0x24, 0x24, 0x22, 0x42, 0x42, - 0x42, 0x24, 0x24, 0x22, 0x42, 0x42, 0x24, 0x44, - 0x22, 0x24, 0x22, 0x42, 0x24, 0x22, 0x22, 0x22, - 0x22, 0x42, 0x22, 0x22, 0x22, 0x42, 0x22, 0x22, - 0x22, 0x22, 0x42, 0x22, 0x22, 0x22, 0x22, 0x24, - 0x22, 0x22, 0x42, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x42, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, 0x42, - 0x22, 0x42, 0x22, 0x22, 0x22, 0x24, 0x22, 0x22, - 0x22, 0x22, 0x42, 0x22, 0x24, 0x22, 0x42, 0x24, - 0x22, 0x22, 0x42, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x24, 0x22, 0x42, 0x24, 0x22, 0x24, 0x24, - 0x22, 0x42, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x32, 0x22, 0x23, 0x22, 0x23, 0x22, - 0x22, 0x23, 0x22, 0x22, 0x32, 0x23, 0x22, 0x32, - 0x22, 0x23, 0x22, 0x32, 0x22, 0x22, 0x23, 0x22, - 0x22, 0x32, 0x22, 0x22, 0x32, 0x22, 0x22, 0x32, - 0x22, 0x22, 0x32, 0x22, 0x32, 0x22, 0x23, 0x22, - 0x23, 0x22, 0x22, 0x32, 0x22, 0x23, 0x22, 0x22, - 0x22, 0x32, 0x22, 0x23, 0x22, 0x22, 0x32, 0x22, - 0x23, 0x22, 0x23, 0x22, 0x32, 0x22, 0x32, 0x22, - 0x23, 0x22, 0x22, 0x22, 0x21, 0x22, 0x22, 0x22, - 0x12, 0x22, 0x22, 0x21, 0x22, 0x22, 0x21, 0x22, - 0x22, 0x21, 0x22, 0x22, 0x22, 0x12, 0x22, 0x22, - 0x21, 0x22, 0x22, 0x22, 0x22, 0x12, 0x22, 0x22, - 0x21, 0x22, 0x22, 0x22, 0x12, 0x22, 0x22, 0x12, - 0x22, 0x12, 0x22, 0x12, 0x22, 0x12, 0x22, 0x21, - 0x22, 0x22, 0x21, 0x22, 0x21, 0x22, 0x22, 0x12, - 0x22, 0x22, 0x12, 0x22, 0x21, 0x22, 0x22, 0x21, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x44, 0x22, 0x22, 0x22, 0x44, 0x22, 0x22, 0x22, - 0x44, 0x44, 0x42, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x24, 0x22, 0x22, 0x22, 0x44, 0x24, - 0x22, 0x42, 0x22, 0x42, 0x22, 0x44, 0x22, 0x22, - 0x42, 0x22, 0x22, 0x44, 0x42, 0x22, 0x22, 0x42, - 0x22, 0x22, 0x24, 0x24, 0x22, 0x22, 0x42, 0x22, - 0x42, 0x22, 0x24, 0x22, 0x22, 0x44, 0x44, 0x22, - 0x42, 0x22, 0x24, 0x22, 0x24, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x44, 0x22, - 0x44, 0x42, 0x22, 0x24, 0x42, 0x22, 0x44, 0x42, - 0x22, 0x22, 0x24, 0x22, 0x22, 0x24, 0x22, 0x42, - 0x22, 0x42, 0x22, 0x42, 0x24, 0x22, 0x42, 0x22, - 0x42, 0x22, 0x24, 0x22, 0x24, 0x22, 0x22, 0x42, - 0x22, 0x22, 0x24, 0x24, 0x22, 0x22, 0x24, 0x24, - 0x22, 0x22, 0x24, 0x22, 0x22, 0x42, 0x22, 0x22, - 0x42, 0x22, 0x24, 0x22, 0x24, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x24, 0x24, 0x22, - 0x42, 0x24, 0x22, 0x42, 0x22, 0x24, 0x22, 0x42, - 0x22, 0x22, 0x24, 0x44, 0x22, 0x24, 0x24, 0x24, - 0x22, 0x44, 0x44, 0x22, 0x22, 0x24, 0x22, 0x22, - 0x42, 0x22, 0x24, 0x22, 0x24, 0x22, 0x24, 0x24, - 0x22, 0x22, 0x42, 0x42, 0x42, 0x22, 0x22, 0x42, - 0x22, 0x22, 0x24, 0x22, 0x22, 0x24, 0x22, 0x22, - 0x42, 0x22, 0x24, 0x22, 0x24, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x24, 0x22, - 0x42, 0x24, 0x22, 0x42, 0x22, 0x24, 0x22, 0x42, - 0x22, 0x22, 0x24, 0x22, 0x42, 0x24, 0x22, 0x24, - 0x22, 0x42, 0x22, 0x42, 0x22, 0x42, 0x22, 0x22, - 0x42, 0x22, 0x24, 0x22, 0x24, 0x22, 0x24, 0x24, - 0x22, 0x22, 0x42, 0x42, 0x42, 0x22, 0x22, 0x42, - 0x22, 0x22, 0x24, 0x22, 0x22, 0x22, 0x42, 0x22, - 0x42, 0x22, 0x42, 0x22, 0x24, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x24, 0x42, 0x22, - 0x44, 0x42, 0x22, 0x24, 0x42, 0x22, 0x44, 0x42, - 0x22, 0x22, 0x24, 0x22, 0x42, 0x24, 0x22, 0x24, - 0x22, 0x42, 0x22, 0x42, 0x24, 0x22, 0x42, 0x22, - 0x42, 0x22, 0x24, 0x22, 0x24, 0x22, 0x42, 0x22, - 0x42, 0x24, 0x22, 0x22, 0x24, 0x22, 0x24, 0x24, - 0x22, 0x22, 0x42, 0x42, 0x22, 0x22, 0x24, 0x22, - 0x42, 0x22, 0x42, 0x22, 0x24, 0x22, 0x42, 0x42, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x42, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x42, - 0x22, 0x22, 0x24, 0x44, 0x22, 0x22, 0x44, 0x42, - 0x22, 0x44, 0x44, 0x22, 0x22, 0x44, 0x22, 0x44, - 0x44, 0x42, 0x24, 0x22, 0x24, 0x22, 0x42, 0x22, - 0x42, 0x24, 0x22, 0x22, 0x24, 0x22, 0x42, 0x22, - 0x42, 0x24, 0x22, 0x24, 0x22, 0x44, 0x44, 0x22, - 0x44, 0x22, 0x42, 0x22, 0x44, 0x22, 0x24, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x42, 0x22, 0x22, 0x22, - 0x42, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x42, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x24, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x32, 0x22, 0x22, 0x32, 0x22, 0x22, - 0x23, 0x22, 0x22, 0x22, 0x32, 0x22, 0x22, 0x32, - 0x22, 0x22, 0x32, 0x22, 0x22, 0x23, 0x22, 0x22, - 0x22, 0x32, 0x22, 0x22, 0x22, 0x23, 0x22, 0x22, - 0x22, 0x32, 0x22, 0x22, 0x23, 0x22, 0x22, 0x23, - 0x22, 0x23, 0x22, 0x23, 0x22, 0x23, 0x22, 0x22, - 0x32, 0x22, 0x22, 0x32, 0x22, 0x32, 0x22, 0x23, - 0x22, 0x22, 0x23, 0x22, 0x22, 0x32, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x12, 0x22, 0x21, 0x22, 0x22, - 0x12, 0x22, 0x21, 0x22, 0x22, 0x21, 0x22, 0x22, - 0x22, 0x22, 0x12, 0x22, 0x22, 0x21, 0x22, 0x22, - 0x22, 0x12, 0x22, 0x22, 0x21, 0x22, 0x22, 0x22, - 0x12, 0x22, 0x22, 0x12, 0x22, 0x22, 0x12, 0x22, - 0x22, 0x21, 0x22, 0x22, 0x21, 0x22, 0x12, 0x22, - 0x21, 0x22, 0x22, 0x21, 0x22, 0x22, 0x12, 0x22, - 0x22, 0x22, 0x21, 0x22, 0x22, 0x22, 0x12, 0x22, - 0x22, 0x21, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x24, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x24, - 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x24, 0x22, 0x22, 0x42, 0x22, 0x22, - 0x22, 0x42, 0x22, 0x22, 0x42, 0x22, 0x22, 0x42, - 0x22, 0x22, 0x22, 0x42, 0x22, 0x42, 0x24, 0x44, - 0x42, 0x22, 0x24, 0x44, 0x22, 0x24, 0x44, 0x42, - 0x22, 0x44, 0x44, 0x22, 0x42, 0x22, 0x22, 0x24, - 0x44, 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, 0x44, - 0x22, 0x24, 0x22, 0x42, 0x24, 0x44, 0x22, 0x42, - 0x24, 0x22, 0x42, 0x24, 0x22, 0x44, 0x22, 0x24, - 0x44, 0x22, 0x22, 0x22, 0x24, 0x22, 0x24, 0x44, - 0x22, 0x24, 0x22, 0x22, 0x22, 0x22, 0x24, 0x22, - 0x44, 0x42, 0x22, 0x42, 0x22, 0x42, 0x24, 0x22, - 0x24, 0x22, 0x42, 0x22, 0x42, 0x24, 0x22, 0x24, - 0x22, 0x42, 0x22, 0x22, 0x42, 0x22, 0x22, 0x42, - 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, - 0x42, 0x24, 0x24, 0x22, 0x24, 0x22, 0x22, 0x42, - 0x24, 0x22, 0x42, 0x24, 0x22, 0x44, 0x22, 0x42, - 0x22, 0x42, 0x22, 0x22, 0x42, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x42, 0x22, 0x42, 0x22, 0x24, 0x24, - 0x24, 0x24, 0x22, 0x24, 0x44, 0x22, 0x24, 0x22, - 0x24, 0x22, 0x42, 0x22, 0x22, 0x24, 0x22, 0x24, - 0x22, 0x42, 0x22, 0x22, 0x42, 0x22, 0x22, 0x42, - 0x24, 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, 0x22, - 0x42, 0x24, 0x42, 0x22, 0x24, 0x22, 0x22, 0x42, - 0x42, 0x42, 0x42, 0x24, 0x24, 0x24, 0x22, 0x42, - 0x22, 0x42, 0x24, 0x22, 0x24, 0x22, 0x24, 0x44, - 0x22, 0x24, 0x22, 0x22, 0x24, 0x22, 0x24, 0x22, - 0x42, 0x24, 0x22, 0x24, 0x24, 0x22, 0x24, 0x44, - 0x42, 0x22, 0x42, 0x22, 0x22, 0x24, 0x22, 0x24, - 0x22, 0x44, 0x42, 0x22, 0x44, 0x42, 0x22, 0x42, - 0x22, 0x22, 0x24, 0x44, 0x42, 0x24, 0x22, 0x22, - 0x42, 0x24, 0x42, 0x22, 0x24, 0x22, 0x22, 0x42, - 0x42, 0x42, 0x42, 0x24, 0x24, 0x24, 0x22, 0x42, - 0x22, 0x42, 0x22, 0x22, 0x22, 0x42, 0x22, 0x22, - 0x22, 0x42, 0x22, 0x24, 0x22, 0x42, 0x22, 0x42, - 0x22, 0x42, 0x22, 0x22, 0x42, 0x22, 0x24, 0x22, - 0x24, 0x22, 0x42, 0x22, 0x42, 0x24, 0x22, 0x24, - 0x22, 0x42, 0x22, 0x22, 0x42, 0x22, 0x22, 0x42, - 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, 0x22, - 0x42, 0x24, 0x24, 0x22, 0x24, 0x22, 0x22, 0x44, - 0x22, 0x24, 0x42, 0x24, 0x42, 0x24, 0x22, 0x42, - 0x22, 0x42, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x44, 0x22, 0x22, 0x24, - 0x44, 0x22, 0x22, 0x22, 0x42, 0x22, 0x24, 0x44, - 0x42, 0x22, 0x24, 0x44, 0x22, 0x24, 0x44, 0x42, - 0x22, 0x44, 0x44, 0x22, 0x44, 0x44, 0x22, 0x24, - 0x44, 0x22, 0x24, 0x22, 0x42, 0x24, 0x22, 0x22, - 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, 0x22, 0x44, - 0x22, 0x24, 0x42, 0x24, 0x42, 0x24, 0x22, 0x24, - 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x32, 0x23, 0x22, 0x22, 0x32, 0x22, - 0x23, 0x22, 0x22, 0x32, 0x22, 0x22, 0x32, 0x22, - 0x22, 0x22, 0x23, 0x22, 0x22, 0x22, 0x32, 0x22, - 0x22, 0x23, 0x22, 0x22, 0x22, 0x32, 0x22, 0x22, - 0x23, 0x22, 0x22, 0x23, 0x22, 0x22, 0x23, 0x22, - 0x22, 0x22, 0x32, 0x22, 0x22, 0x32, 0x23, 0x22, - 0x22, 0x32, 0x22, 0x22, 0x32, 0x22, 0x23, 0x22, - 0x22, 0x22, 0x22, 0x32, 0x22, 0x22, 0x23, 0x22, - 0x22, 0x22, 0x22, 0x12, 0x21, 0x22, 0x22, 0x12, - 0x22, 0x22, 0x21, 0x22, 0x22, 0x12, 0x22, 0x22, - 0x12, 0x22, 0x22, 0x12, 0x21, 0x22, 0x21, 0x22, - 0x21, 0x22, 0x21, 0x22, 0x22, 0x12, 0x21, 0x22, - 0x21, 0x22, 0x12, 0x22, 0x12, 0x22, 0x22, 0x12, - 0x22, 0x12, 0x22, 0x22, 0x12, 0x22, 0x22, 0x12, - 0x22, 0x22, 0x12, 0x22, 0x21, 0x22, 0x22, 0x21, - 0x22, 0x22, 0x12, 0x22, 0x22, 0x12, 0x22, 0x22, - 0x12, 0x21, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x42, 0x24, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x42, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x24, 0x22, 0x22, - 0x42, 0x22, 0x22, 0x22, 0x22, 0x22, 0x42, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x42, 0x22, 0x22, 0x22, - 0x24, 0x24, 0x22, 0x24, 0x44, 0x22, 0x22, 0x44, - 0x22, 0x24, 0x24, 0x22, 0x22, 0x24, 0x22, 0x22, - 0x42, 0x22, 0x22, 0x22, 0x22, 0x22, 0x42, 0x22, - 0x22, 0x24, 0x22, 0x42, 0x22, 0x24, 0x42, 0x22, - 0x24, 0x22, 0x44, 0x44, 0x22, 0x24, 0x42, 0x22, - 0x22, 0x42, 0x22, 0x44, 0x22, 0x22, 0x44, 0x22, - 0x22, 0x42, 0x22, 0x24, 0x42, 0x22, 0x24, 0x42, - 0x22, 0x42, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x44, 0x44, 0x42, 0x22, 0x44, 0x22, 0x42, 0x44, - 0x22, 0x42, 0x42, 0x22, 0x22, 0x24, 0x22, 0x22, - 0x42, 0x22, 0x22, 0x22, 0x42, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x42, 0x22, 0x42, 0x24, 0x22, - 0x24, 0x22, 0x42, 0x22, 0x22, 0x42, 0x24, 0x22, - 0x44, 0x44, 0x22, 0x22, 0x42, 0x24, 0x22, 0x42, - 0x22, 0x42, 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, - 0x22, 0x22, 0x22, 0x22, 0x42, 0x22, 0x22, 0x22, - 0x24, 0x24, 0x22, 0x22, 0x42, 0x22, 0x24, 0x22, - 0x22, 0x42, 0x44, 0x22, 0x22, 0x24, 0x22, 0x22, - 0x42, 0x22, 0x22, 0x24, 0x44, 0x22, 0x22, 0x24, - 0x42, 0x22, 0x22, 0x42, 0x22, 0x42, 0x24, 0x22, - 0x24, 0x22, 0x24, 0x42, 0x22, 0x22, 0x24, 0x22, - 0x42, 0x42, 0x22, 0x22, 0x42, 0x24, 0x22, 0x42, - 0x22, 0x42, 0x22, 0x42, 0x24, 0x22, 0x22, 0x24, - 0x22, 0x22, 0x22, 0x22, 0x42, 0x22, 0x22, 0x22, - 0x24, 0x24, 0x22, 0x24, 0x42, 0x22, 0x22, 0x42, - 0x22, 0x24, 0x22, 0x22, 0x22, 0x24, 0x22, 0x22, - 0x42, 0x22, 0x22, 0x22, 0x42, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x24, 0x22, 0x42, 0x24, 0x22, - 0x24, 0x22, 0x22, 0x24, 0x22, 0x22, 0x42, 0x22, - 0x24, 0x42, 0x22, 0x44, 0x22, 0x24, 0x44, 0x22, - 0x22, 0x42, 0x22, 0x24, 0x42, 0x22, 0x24, 0x44, - 0x22, 0x42, 0x22, 0x22, 0x42, 0x24, 0x24, 0x22, - 0x44, 0x44, 0x42, 0x24, 0x44, 0x22, 0x44, 0x24, - 0x22, 0x42, 0x42, 0x22, 0x42, 0x24, 0x22, 0x22, - 0x42, 0x24, 0x42, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x24, 0x22, 0x42, 0x24, 0x22, - 0x44, 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, 0x22, - 0x24, 0x42, 0x22, 0x42, 0x22, 0x24, 0x22, 0x22, - 0x22, 0x24, 0x22, 0x42, 0x24, 0x22, 0x42, 0x24, - 0x22, 0x22, 0x22, 0x22, 0x42, 0x24, 0x24, 0x22, - 0x24, 0x24, 0x22, 0x22, 0x42, 0x22, 0x44, 0x22, - 0x22, 0x24, 0x22, 0x22, 0x42, 0x22, 0x42, 0x24, - 0x22, 0x24, 0x42, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x24, 0x22, 0x24, 0x42, 0x22, - 0x24, 0x22, 0x24, 0x42, 0x22, 0x24, 0x42, 0x22, - 0x22, 0x42, 0x22, 0x44, 0x42, 0x22, 0x44, 0x22, - 0x24, 0x44, 0x22, 0x24, 0x42, 0x22, 0x24, 0x42, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x31, 0x23, 0x22, 0x32, 0x22, 0x23, - 0x22, 0x22, 0x22, 0x32, 0x22, 0x23, 0x22, 0x22, - 0x23, 0x22, 0x22, 0x23, 0x22, 0x32, 0x22, 0x32, - 0x22, 0x32, 0x22, 0x32, 0x22, 0x23, 0x22, 0x32, - 0x22, 0x32, 0x23, 0x22, 0x23, 0x22, 0x22, 0x23, - 0x22, 0x23, 0x22, 0x22, 0x23, 0x22, 0x22, 0x23, - 0x22, 0x22, 0x23, 0x22, 0x22, 0x32, 0x22, 0x22, - 0x32, 0x22, 0x23, 0x22, 0x22, 0x23, 0x22, 0x22, - 0x23, 0x22 -}; - - u32 BuiltInFontDataSize = sizeof(BuiltInFontData); - -#else // !defined(_IRR_COMPILE_WITH_BMP_LOADER_) - - // built-in font cannot be loaded if there is no BMP loader - - u8* BuiltInFontData=0; - - u32 BuiltInFontDataSize = 0; - -#endif -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/C3DSMeshFileLoader.cpp b/irrlicht-1.6/source/Irrlicht/C3DSMeshFileLoader.cpp deleted file mode 100644 index 7d63a020f..000000000 --- a/irrlicht-1.6/source/Irrlicht/C3DSMeshFileLoader.cpp +++ /dev/null @@ -1,1394 +0,0 @@ -// Copyright (C) 2002-2009 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_3DS_LOADER_ - -#include "C3DSMeshFileLoader.h" -#include "os.h" -#include "SMeshBuffer.h" -#include "SAnimatedMesh.h" -#include "IReadFile.h" -#include "IVideoDriver.h" -#include "IMeshManipulator.h" - -#ifdef _DEBUG -#define _IRR_DEBUG_3DS_LOADER_ -#endif - -namespace irr -{ -namespace scene -{ - - -namespace -{ -enum e3DSChunk -{ - // Primary chunk - C3DS_MAIN3DS = 0x4D4D, - - // Main Chunks - C3DS_EDIT3DS = 0x3D3D, - C3DS_KEYF3DS = 0xB000, - C3DS_VERSION = 0x0002, - C3DS_MESHVERSION = 0x3D3E, - - // sub chunks of C3DS_EDIT3DS - C3DS_EDIT_MATERIAL = 0xAFFF, - C3DS_EDIT_OBJECT = 0x4000, - - // sub chunks of C3DS_EDIT_MATERIAL - C3DS_MATNAME = 0xA000, - C3DS_MATAMBIENT = 0xA010, - C3DS_MATDIFFUSE = 0xA020, - C3DS_MATSPECULAR = 0xA030, - C3DS_MATSHININESS = 0xA040, - C3DS_MATSHIN2PCT = 0xA041, - C3DS_TRANSPARENCY = 0xA050, - C3DS_TRANSPARENCY_FALLOFF = 0xA052, - C3DS_REFL_BLUR = 0xA053, - C3DS_TWO_SIDE = 0xA081, - C3DS_WIRE = 0xA085, - C3DS_SHADING = 0xA100, - C3DS_MATTEXMAP = 0xA200, - C3DS_MATSPECMAP = 0xA204, - C3DS_MATOPACMAP = 0xA210, - C3DS_MATREFLMAP = 0xA220, - C3DS_MATBUMPMAP = 0xA230, - C3DS_MATMAPFILE = 0xA300, - C3DS_MAT_TEXTILING = 0xA351, - C3DS_MAT_USCALE = 0xA354, - C3DS_MAT_VSCALE = 0xA356, - C3DS_MAT_UOFFSET = 0xA358, - C3DS_MAT_VOFFSET = 0xA35A, - - // subs of C3DS_EDIT_OBJECT - C3DS_OBJTRIMESH = 0x4100, - - // subs of C3DS_OBJTRIMESH - C3DS_TRIVERT = 0x4110, - C3DS_POINTFLAGARRAY= 0x4111, - C3DS_TRIFACE = 0x4120, - C3DS_TRIFACEMAT = 0x4130, - C3DS_TRIUV = 0x4140, - C3DS_TRISMOOTH = 0x4150, - C3DS_TRIMATRIX = 0x4160, - C3DS_MESHCOLOR = 0x4165, - C3DS_DIRECT_LIGHT = 0x4600, - C3DS_DL_INNER_RANGE= 0x4659, - C3DS_DL_OUTER_RANGE= 0x465A, - C3DS_DL_MULTIPLIER = 0x465B, - C3DS_CAMERA = 0x4700, - C3DS_CAM_SEE_CONE = 0x4710, - C3DS_CAM_RANGES = 0x4720, - - // subs of C3DS_KEYF3DS - C3DS_KF_HDR = 0xB00A, - C3DS_AMBIENT_TAG = 0xB001, - C3DS_OBJECT_TAG = 0xB002, - C3DS_CAMERA_TAG = 0xB003, - C3DS_TARGET_TAG = 0xB004, - C3DS_LIGHTNODE_TAG = 0xB005, - C3DS_KF_SEG = 0xB008, - C3DS_KF_CURTIME = 0xB009, - C3DS_KF_NODE_HDR = 0xB010, - C3DS_PIVOTPOINT = 0xB013, - C3DS_BOUNDBOX = 0xB014, - C3DS_MORPH_SMOOTH = 0xB015, - C3DS_POS_TRACK_TAG = 0xB020, - C3DS_ROT_TRACK_TAG = 0xB021, - C3DS_SCL_TRACK_TAG = 0xB022, - C3DS_NODE_ID = 0xB030, - - // Viewport definitions - C3DS_VIEWPORT_LAYOUT = 0x7001, - C3DS_VIEWPORT_DATA = 0x7011, - C3DS_VIEWPORT_DATA_3 = 0x7012, - C3DS_VIEWPORT_SIZE = 0x7020, - - // different color chunk types - C3DS_COL_RGB = 0x0010, - C3DS_COL_TRU = 0x0011, - C3DS_COL_LIN_24 = 0x0012, - C3DS_COL_LIN_F = 0x0013, - - // percentage chunk types - C3DS_PERCENTAGE_I = 0x0030, - C3DS_PERCENTAGE_F = 0x0031, - - C3DS_CHUNK_MAX = 0xFFFF -}; -} - - -//! Constructor -C3DSMeshFileLoader::C3DSMeshFileLoader(ISceneManager* smgr, io::IFileSystem* fs) -: SceneManager(smgr), FileSystem(fs), Vertices(0), Indices(0), SmoothingGroups(0), TCoords(0), - CountVertices(0), CountFaces(0), CountTCoords(0), Mesh(0) -{ - - #ifdef _DEBUG - setDebugName("C3DSMeshFileLoader"); - #endif - - TransformationMatrix.makeIdentity(); - if (FileSystem) - FileSystem->grab(); -} - - -//! destructor -C3DSMeshFileLoader::~C3DSMeshFileLoader() -{ - cleanUp(); - - if (FileSystem) - FileSystem->drop(); - - if (Mesh) - Mesh->drop(); -} - - -//! returns true if the file maybe is able to be loaded by this class -//! based on the file extension (e.g. ".bsp") -bool C3DSMeshFileLoader::isALoadableFileExtension(const io::path& filename) const -{ - return core::hasFileExtension ( filename, "3ds" ); -} - - -//! 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* C3DSMeshFileLoader::createMesh(io::IReadFile* file) -{ - ChunkData data; - - readChunkData(file, data); - - if (data.header.id != C3DS_MAIN3DS ) - return 0; - - CurrentMaterial.clear(); - Materials.clear(); - MeshBufferNames.clear(); - cleanUp(); - - if (Mesh) - Mesh->drop(); - - Mesh = new SMesh(); - - if (readChunk(file, &data)) - { - // success - - for (u32 i=0; i<Mesh->getMeshBufferCount(); ++i) - { - SMeshBuffer* mb = ((SMeshBuffer*)Mesh->getMeshBuffer(i)); - // drop empty buffers - if (mb->getIndexCount() == 0 || mb->getVertexCount() == 0) - { - Mesh->MeshBuffers.erase(i--); - mb->drop(); - } - else - { - if (mb->Material.MaterialType == video::EMT_PARALLAX_MAP_SOLID) - { - SMesh tmp; - tmp.addMeshBuffer(mb); - mb->drop(); - IMesh* tangentMesh = SceneManager->getMeshManipulator()->createMeshWithTangents(&tmp); - Mesh->MeshBuffers[i]=tangentMesh->getMeshBuffer(0); - // we need to grab because we replace the buffer manually. - Mesh->MeshBuffers[i]->grab(); - // clean up intermediate mesh struct - tangentMesh->drop(); - } - Mesh->MeshBuffers[i]->recalculateBoundingBox(); - } - } - - Mesh->recalculateBoundingBox(); - - SAnimatedMesh* am = new SAnimatedMesh(); - am->Type = EAMT_3DS; - am->addMesh(Mesh); - am->recalculateBoundingBox(); - Mesh->drop(); - Mesh = 0; - return am; - } - - Mesh->drop(); - Mesh = 0; - - return 0; -} - - -bool C3DSMeshFileLoader::readPercentageChunk(io::IReadFile* file, - ChunkData* chunk, f32& percentage) -{ -#ifdef _IRR_DEBUG_3DS_LOADER_ - os::Printer::log("Load percentage chunk."); -#endif - - ChunkData data; - readChunkData(file, data); - - short intpercentage; - float fpercentage; - - switch(data.header.id) - { - case C3DS_PERCENTAGE_I: - { - // read short - file->read(&intpercentage, 2); -#ifdef __BIG_ENDIAN__ - intpercentage = os::Byteswap::byteswap(intpercentage); -#endif - percentage=intpercentage/100.0f; - data.read += 2; - } - break; - case C3DS_PERCENTAGE_F: - { - // read float - file->read(&fpercentage, sizeof(float)); - data.read += sizeof(float); -#ifdef __BIG_ENDIAN__ - percentage = os::Byteswap::byteswap(fpercentage); -#else - percentage = (f32)fpercentage; -#endif - } - break; - default: - { - // unknown percentage chunk - os::Printer::log("Unknown percentage chunk in 3Ds file.", ELL_WARNING); - file->seek(data.header.length - data.read, true); - data.read += data.header.length - data.read; - } - } - - chunk->read += data.read; - - return true; -} - -bool C3DSMeshFileLoader::readColorChunk(io::IReadFile* file, ChunkData* chunk, - video::SColor& out) -{ -#ifdef _IRR_DEBUG_3DS_LOADER_ - os::Printer::log("Load color chunk."); -#endif - ChunkData data; - readChunkData(file, data); - - u8 c[3]; - f32 cf[3]; - - switch(data.header.id) - { - case C3DS_COL_TRU: - case C3DS_COL_LIN_24: - { - // read 8 bit data - file->read(c, sizeof(c)); - out.set(255, c[0], c[1], c[2]); - data.read += sizeof(c); - } - break; - case C3DS_COL_RGB: - case C3DS_COL_LIN_F: - { - // read float data - file->read(cf, sizeof(cf)); -#ifdef __BIG_ENDIAN__ - cf[0] = os::Byteswap::byteswap(cf[0]); - cf[1] = os::Byteswap::byteswap(cf[1]); - cf[2] = os::Byteswap::byteswap(cf[2]); -#endif - out.set(255, (s32)(cf[0]*255.0f), (s32)(cf[1]*255.0f), (s32)(cf[2]*255.0f)); - data.read += sizeof(cf); - } - break; - default: - { - // unknown color chunk size - os::Printer::log("Unknown size of color chunk in 3Ds file.", ELL_WARNING); - file->seek(data.header.length - data.read, true); - data.read += data.header.length - data.read; - } - } - - chunk->read += data.read; - - return true; -} - - -bool C3DSMeshFileLoader::readMaterialChunk(io::IReadFile* file, ChunkData* parent) -{ -#ifdef _IRR_DEBUG_3DS_LOADER_ - os::Printer::log("Load material chunk."); -#endif - u16 matSection=0; - - while(parent->read < parent->header.length) - { - ChunkData data; - readChunkData(file, data); - - switch(data.header.id) - { - case C3DS_MATNAME: - { - c8* c = new c8[data.header.length - data.read]; - file->read(c, data.header.length - data.read); - - if (strlen(c)) - CurrentMaterial.Name = c; - - data.read += data.header.length - data.read; - delete [] c; - } - break; - case C3DS_MATAMBIENT: - readColorChunk(file, &data, CurrentMaterial.Material.AmbientColor); - break; - case C3DS_MATDIFFUSE: - readColorChunk(file, &data, CurrentMaterial.Material.DiffuseColor); - break; - case C3DS_MATSPECULAR: - readColorChunk(file, &data, CurrentMaterial.Material.SpecularColor); - break; - case C3DS_MATSHININESS: - readPercentageChunk(file, &data, CurrentMaterial.Material.Shininess); - CurrentMaterial.Material.Shininess = (1.f-CurrentMaterial.Material.Shininess)*128.f; - break; - case C3DS_TRANSPARENCY: - { - f32 percentage; - readPercentageChunk(file, &data, percentage); - if (percentage>0.0f) - { - CurrentMaterial.Material.MaterialTypeParam=percentage; - CurrentMaterial.Material.MaterialType=video::EMT_TRANSPARENT_VERTEX_ALPHA; - } - else - { - CurrentMaterial.Material.MaterialType=video::EMT_SOLID; - } - } - break; - case C3DS_WIRE: - CurrentMaterial.Material.Wireframe=true; - break; - case C3DS_TWO_SIDE: - CurrentMaterial.Material.BackfaceCulling=false; - break; - case C3DS_SHADING: - { - s16 flags; - file->read(&flags, 2); -#ifdef __BIG_ENDIAN__ - flags = os::Byteswap::byteswap(flags); -#endif - switch (flags) - { - case 0: - CurrentMaterial.Material.Wireframe=true; - break; - case 1: - CurrentMaterial.Material.Wireframe=false; - CurrentMaterial.Material.GouraudShading=false; - break; - case 2: - CurrentMaterial.Material.Wireframe=false; - CurrentMaterial.Material.GouraudShading=true; - break; - default: - // phong and metal missing - break; - } - data.read += data.header.length - data.read; - } - break; - case C3DS_MATTEXMAP: - case C3DS_MATSPECMAP: - case C3DS_MATOPACMAP: - case C3DS_MATREFLMAP: - case C3DS_MATBUMPMAP: - { - matSection=data.header.id; - // Should contain a percentage chunk, but does - // not always have it - s16 testval; - const long pos = file->getPos(); - file->read(&testval, 2); -#ifdef __BIG_ENDIAN__ - testval = os::Byteswap::byteswap(testval); -#endif - file->seek(pos, false); - if ((testval == C3DS_PERCENTAGE_I) || - (testval == C3DS_PERCENTAGE_F)) - switch (matSection) - { - case C3DS_MATTEXMAP: - readPercentageChunk(file, &data, CurrentMaterial.Strength[0]); - break; - case C3DS_MATSPECMAP: - readPercentageChunk(file, &data, CurrentMaterial.Strength[1]); - break; - case C3DS_MATOPACMAP: - readPercentageChunk(file, &data, CurrentMaterial.Strength[2]); - break; - case C3DS_MATBUMPMAP: - readPercentageChunk(file, &data, CurrentMaterial.Strength[4]); - break; - } - } - break; - case C3DS_MATMAPFILE: - { - // read texture file name - c8* c = new c8[data.header.length - data.read]; - file->read(c, data.header.length - data.read); - switch (matSection) - { - case C3DS_MATTEXMAP: - CurrentMaterial.Filename[0] = c; - break; - case C3DS_MATSPECMAP: - CurrentMaterial.Filename[1] = c; - break; - case C3DS_MATOPACMAP: - CurrentMaterial.Filename[2] = c; - break; - case C3DS_MATREFLMAP: - CurrentMaterial.Filename[3] = c; - break; - case C3DS_MATBUMPMAP: - CurrentMaterial.Filename[4] = c; - break; - } - data.read += data.header.length - data.read; - delete [] c; - } - break; - case C3DS_MAT_TEXTILING: - { - s16 flags; - file->read(&flags, 2); -#ifdef __BIG_ENDIAN__ - flags = os::Byteswap::byteswap(flags); -#endif - data.read += 2; - } - break; - case C3DS_MAT_USCALE: - case C3DS_MAT_VSCALE: - case C3DS_MAT_UOFFSET: - case C3DS_MAT_VOFFSET: - { - f32 value; - file->read(&value, 4); -#ifdef __BIG_ENDIAN__ - value = os::Byteswap::byteswap(value); -#endif - u32 i=0; - if (matSection != C3DS_MATTEXMAP) - i=1; - u32 j=0,k=0; - if (data.header.id == C3DS_MAT_VSCALE) - { - j=1; - k=1; - } - else if (data.header.id == C3DS_MAT_UOFFSET) - { - j=2; - k=0; - } - else if (data.header.id == C3DS_MAT_VOFFSET) - { - j=2; - k=1; - } - CurrentMaterial.Material.getTextureMatrix(i)(j,k)=value; - - data.read += 4; - } - break; - default: - // ignore chunk - file->seek(data.header.length - data.read, true); - data.read += data.header.length - data.read; - } - - parent->read += data.read; - } - - Materials.push_back(CurrentMaterial); - CurrentMaterial.clear(); - - return true; -} - - - -bool C3DSMeshFileLoader::readTrackChunk(io::IReadFile* file, ChunkData& data, - IMeshBuffer* mb, const core::vector3df& pivot) -{ -#ifdef _IRR_DEBUG_3DS_LOADER_ - os::Printer::log("Load track chunk."); -#endif - u16 flags; - u32 flags2; - // Track flags - file->read(&flags, 2); -#ifdef __BIG_ENDIAN__ - flags = os::Byteswap::byteswap(flags); -#endif - file->read(&flags2, 4); -#ifdef __BIG_ENDIAN__ - flags2 = os::Byteswap::byteswap(flags2); -#endif - file->read(&flags2, 4); -#ifdef __BIG_ENDIAN__ - flags2 = os::Byteswap::byteswap(flags2); -#endif - // Num keys - file->read(&flags2, 4); -#ifdef __BIG_ENDIAN__ - flags2 = os::Byteswap::byteswap(flags2); -#endif - file->read(&flags2, 4); -#ifdef __BIG_ENDIAN__ - flags2 = os::Byteswap::byteswap(flags2); -#endif - // TCB flags - file->read(&flags, 2); -#ifdef __BIG_ENDIAN__ - flags = os::Byteswap::byteswap(flags); -#endif - data.read += 20; - - f32 angle=0.0f; - if (data.header.id== C3DS_ROT_TRACK_TAG) - { - // Angle - file->read(&angle, sizeof(f32)); -#ifdef __BIG_ENDIAN__ - angle = os::Byteswap::byteswap(angle); -#endif - data.read += sizeof(f32); - } - core::vector3df vec; - file->read(&vec.X, sizeof(f32)); - file->read(&vec.Y, sizeof(f32)); - file->read(&vec.Z, sizeof(f32)); -#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 - data.read += 12; - vec-=pivot; - - // apply transformation to mesh buffer - if (false)//mb) - { - video::S3DVertex *vertices=(video::S3DVertex*)mb->getVertices(); - if (data.header.id==C3DS_POS_TRACK_TAG) - { - for (u32 i=0; i<mb->getVertexCount(); ++i) - vertices[i].Pos+=vec; - } - else if (data.header.id==C3DS_ROT_TRACK_TAG) - { - //TODO - } - else if (data.header.id==C3DS_SCL_TRACK_TAG) - { - //TODO - } - } - // skip further frames - file->seek(data.header.length - data.read, true); - data.read += data.header.length - data.read; - return true; -} - - -bool C3DSMeshFileLoader::readFrameChunk(io::IReadFile* file, ChunkData* parent) -{ -#ifdef _IRR_DEBUG_3DS_LOADER_ - os::Printer::log("Load frame chunk."); -#endif - ChunkData data; - - //KF_HDR is always at the beginning - readChunkData(file, data); - if (data.header.id != C3DS_KF_HDR) - return false; - else - { -#ifdef _IRR_DEBUG_3DS_LOADER_ - os::Printer::log("Load keyframe header."); -#endif - u16 version; - file->read(&version, 2); -#ifdef __BIG_ENDIAN__ - version = os::Byteswap::byteswap(version); -#endif - core::stringc name; - readString(file, data, name); - u32 flags; - file->read(&flags, 4); -#ifdef __BIG_ENDIAN__ - flags = os::Byteswap::byteswap(flags); -#endif - - data.read += 4; - parent->read += data.read; - } - data.read=0; - - IMeshBuffer* mb=0; - core::vector3df pivot,bboxCenter; - while(parent->read < parent->header.length) - { - readChunkData(file, data); - - switch(data.header.id) - { - case C3DS_OBJECT_TAG: - { -#ifdef _IRR_DEBUG_3DS_LOADER_ - os::Printer::log("Load object tag."); -#endif - mb=0; - pivot.set(0.0f, 0.0f, 0.0f); - } - break; - case C3DS_KF_SEG: - { -#ifdef _IRR_DEBUG_3DS_LOADER_ - os::Printer::log("Load keyframe segment."); -#endif - u32 flags; - file->read(&flags, 4); -#ifdef __BIG_ENDIAN__ - flags = os::Byteswap::byteswap(flags); -#endif - file->read(&flags, 4); -#ifdef __BIG_ENDIAN__ - flags = os::Byteswap::byteswap(flags); -#endif - data.read += 8; - } - break; - case C3DS_KF_NODE_HDR: - { -#ifdef _IRR_DEBUG_3DS_LOADER_ - os::Printer::log("Load keyframe node header."); -#endif - s16 flags; - c8* c = new c8[data.header.length - data.read-6]; - file->read(c, data.header.length - data.read-6); - - // search mesh buffer to apply these transformations to - for (u32 i=0; i<MeshBufferNames.size(); ++i) - { - if (MeshBufferNames[i]==c) - { - mb=Mesh->getMeshBuffer(i); - break; - } - } - - file->read(&flags, 2); -#ifdef __BIG_ENDIAN__ - flags = os::Byteswap::byteswap(flags); -#endif - file->read(&flags, 2); -#ifdef __BIG_ENDIAN__ - flags = os::Byteswap::byteswap(flags); -#endif - file->read(&flags, 2); -#ifdef __BIG_ENDIAN__ - flags = os::Byteswap::byteswap(flags); -#endif - data.read += data.header.length - data.read; - delete [] c; - } - break; - case C3DS_KF_CURTIME: - { -#ifdef _IRR_DEBUG_3DS_LOADER_ - os::Printer::log("Load keyframe current time."); -#endif - u32 flags; - file->read(&flags, 4); -#ifdef __BIG_ENDIAN__ - flags = os::Byteswap::byteswap(flags); -#endif - data.read += 4; - } - break; - case C3DS_NODE_ID: - { -#ifdef _IRR_DEBUG_3DS_LOADER_ - os::Printer::log("Load node ID."); -#endif - u16 flags; - file->read(&flags, 2); -#ifdef __BIG_ENDIAN__ - flags = os::Byteswap::byteswap(flags); -#endif - data.read += 2; - } - break; - case C3DS_PIVOTPOINT: - { -#ifdef _IRR_DEBUG_3DS_LOADER_ - os::Printer::log("Load pivot point."); -#endif - file->read(&pivot.X, sizeof(f32)); - file->read(&pivot.Y, sizeof(f32)); - file->read(&pivot.Z, sizeof(f32)); -#ifdef __BIG_ENDIAN__ - pivot.X = os::Byteswap::byteswap(pivot.X); - pivot.Y = os::Byteswap::byteswap(pivot.Y); - pivot.Z = os::Byteswap::byteswap(pivot.Z); -#endif - data.read += 12; - } - break; - case C3DS_BOUNDBOX: - { -#ifdef _IRR_DEBUG_3DS_LOADER_ - os::Printer::log("Load bounding box."); -#endif - core::aabbox3df bbox; - // abuse bboxCenter as temporary variable - file->read(&bboxCenter.X, sizeof(f32)); - file->read(&bboxCenter.Y, sizeof(f32)); - file->read(&bboxCenter.Z, sizeof(f32)); -#ifdef __BIG_ENDIAN__ - bboxCenter.X = os::Byteswap::byteswap(bboxCenter.X); - bboxCenter.Y = os::Byteswap::byteswap(bboxCenter.Y); - bboxCenter.Z = os::Byteswap::byteswap(bboxCenter.Z); -#endif - bbox.reset(bboxCenter); - file->read(&bboxCenter.X, sizeof(f32)); - file->read(&bboxCenter.Y, sizeof(f32)); - file->read(&bboxCenter.Z, sizeof(f32)); -#ifdef __BIG_ENDIAN__ - bboxCenter.X = os::Byteswap::byteswap(bboxCenter.X); - bboxCenter.Y = os::Byteswap::byteswap(bboxCenter.Y); - bboxCenter.Z = os::Byteswap::byteswap(bboxCenter.Z); -#endif - bbox.addInternalPoint(bboxCenter); - bboxCenter=bbox.getCenter(); - data.read += 24; - } - break; - case C3DS_MORPH_SMOOTH: - { -#ifdef _IRR_DEBUG_3DS_LOADER_ - os::Printer::log("Load morph smooth."); -#endif - f32 flag; - file->read(&flag, 4); -#ifdef __BIG_ENDIAN__ - flag = os::Byteswap::byteswap(flag); -#endif - data.read += 4; - } - break; - case C3DS_POS_TRACK_TAG: - case C3DS_ROT_TRACK_TAG: - case C3DS_SCL_TRACK_TAG: - readTrackChunk(file, data, mb, bboxCenter-pivot); - break; - default: - // ignore chunk - file->seek(data.header.length - data.read, true); - data.read += data.header.length - data.read; - } - - parent->read += data.read; - data.read=0; - } - - return true; -} - - -bool C3DSMeshFileLoader::readChunk(io::IReadFile* file, ChunkData* parent) -{ - while(parent->read < parent->header.length) - { - ChunkData data; - readChunkData(file, data); - - switch(data.header.id) - { - case C3DS_VERSION: - { - u16 version; - file->read(&version, sizeof(u16)); -#ifdef __BIG_ENDIAN__ - version = os::Byteswap::byteswap(version); -#endif - file->seek(data.header.length - data.read - 2, true); - data.read += data.header.length - data.read; - if (version != 0x03) - os::Printer::log("3ds file version is other than 3.", ELL_ERROR); - } - break; - case C3DS_EDIT_MATERIAL: - readMaterialChunk(file, &data); - break; - case C3DS_KEYF3DS: - readFrameChunk(file, &data); - break; - case C3DS_EDIT3DS: - break; - case C3DS_MESHVERSION: - case 0x01: - { - u32 version; - file->read(&version, sizeof(u32)); -#ifdef __BIG_ENDIAN__ - version = os::Byteswap::byteswap(version); -#endif - data.read += sizeof(u32); - } - break; - case C3DS_EDIT_OBJECT: - { - core::stringc name; - readString(file, data, name); - readObjectChunk(file, &data); - composeObject(file, name); - } - break; - - default: - // ignore chunk - file->seek(data.header.length - data.read, true); - data.read += data.header.length - data.read; - } - - parent->read += data.read; - } - - return true; -} - - -bool C3DSMeshFileLoader::readObjectChunk(io::IReadFile* file, ChunkData* parent) -{ -#ifdef _IRR_DEBUG_3DS_LOADER_ - os::Printer::log("Load object chunk."); -#endif - while(parent->read < parent->header.length) - { - ChunkData data; - readChunkData(file, data); - - switch(data.header.id) - { - case C3DS_OBJTRIMESH: - readObjectChunk(file, &data); - break; - - case C3DS_TRIVERT: - readVertices(file, data); - break; - - case C3DS_POINTFLAGARRAY: - { - u16 numVertex, flags; - file->read(&numVertex, sizeof(u16)); -#ifdef __BIG_ENDIAN__ - numVertex= os::Byteswap::byteswap(numVertex); -#endif - for (u16 i=0; i<numVertex; ++i) - { - file->read(&flags, sizeof(u16)); -#ifdef __BIG_ENDIAN__ - flags = os::Byteswap::byteswap(flags); -#endif - } - data.read += (numVertex+1)*sizeof(u16); - } - break; - - case C3DS_TRIFACE: - readIndices(file, data); - readObjectChunk(file, &data); // read smooth and material groups - break; - - case C3DS_TRIFACEMAT: - readMaterialGroup(file, data); - break; - - case C3DS_TRIUV: // getting texture coordinates - readTextureCoords(file, data); - break; - - case C3DS_TRIMATRIX: - { - f32 mat[4][3]; - file->read(&mat, 12*sizeof(f32)); - TransformationMatrix.makeIdentity(); - for (int i=0; i<4; ++i) - { - for (int j=0; j<3; ++j) - { -#ifdef __BIG_ENDIAN__ - TransformationMatrix(i,j)=os::Byteswap::byteswap(mat[i][j]); -#else - TransformationMatrix(i,j)=mat[i][j]; -#endif - } - } - data.read += 12*sizeof(f32); - } - break; - case C3DS_MESHCOLOR: - { - u8 flag; - file->read(&flag, sizeof(u8)); - ++data.read; - } - break; - case C3DS_TRISMOOTH: // TODO - { - SmoothingGroups = new u32[CountFaces]; - file->read(SmoothingGroups, CountFaces*sizeof(u32)); -#ifdef __BIG_ENDIAN__ - for (u16 i=0; i<CountFaces; ++i) - SmoothingGroups[i] = os::Byteswap::byteswap(SmoothingGroups[i]); -#endif - data.read += CountFaces*sizeof(u32); - } - break; - - default: - // ignore chunk - file->seek(data.header.length - data.read, true); - data.read += data.header.length - data.read; - } - - parent->read += data.read; - } - - return true; -} - - -void C3DSMeshFileLoader::composeObject(io::IReadFile* file, const core::stringc& name) -{ - if (Mesh->getMeshBufferCount() != Materials.size()) - loadMaterials(file); - - if (MaterialGroups.empty()) - { - // no material group, so add all - SMaterialGroup group; - group.faceCount = CountFaces; - group.faces = new u16[group.faceCount]; - for (u32 i=0; i<group.faceCount; ++i) - group.faces[i] = i; - MaterialGroups.push_back(group); - - // if we've got no material, add one without a texture - if (Materials.empty()) - { - SCurrentMaterial m; - Materials.push_back(m); - SMeshBuffer* mb = new scene::SMeshBuffer(); - Mesh->addMeshBuffer(mb); - mb->getMaterial() = Materials[0].Material; - mb->drop(); - // add an empty mesh buffer name - MeshBufferNames.push_back(""); - } - } - - for (u32 i=0; i<MaterialGroups.size(); ++i) - { - SMeshBuffer* mb = 0; - video::SMaterial* mat=0; - u32 mbPos; - // -3 because we add three vertices at once - u32 maxPrimitives = core::min_(SceneManager->getVideoDriver()->getMaximalPrimitiveCount(), (u32)((1<<16)-1))-3; // currently hardcoded s16 max value for index pointers - - // find mesh buffer for this group - for (mbPos=0; mbPos<Materials.size(); ++mbPos) - { - if (MaterialGroups[i].MaterialName == Materials[mbPos].Name) - { - mb = (SMeshBuffer*)Mesh->getMeshBuffer(mbPos); - mat=&Materials[mbPos].Material; - MeshBufferNames[mbPos]=name; - break; - } - } - - if (mb != 0) - { - // add geometry to the buffer. - - video::S3DVertex vtx; - core::vector3df vec; - vtx.Color=mat->DiffuseColor; - if (mat->MaterialType==video::EMT_TRANSPARENT_VERTEX_ALPHA) - { - vtx.Color.setAlpha((int)(255.0f*mat->MaterialTypeParam)); - } - vtx.Normal.set(0,0,0); - - for (s32 f=0; f<MaterialGroups[i].faceCount; ++f) - { - u32 vtxCount = mb->Vertices.size(); - if (vtxCount>maxPrimitives) - { - IMeshBuffer* tmp = mb; - mb = new SMeshBuffer(); - Mesh->addMeshBuffer(mb); - mb->drop(); - Mesh->MeshBuffers[mbPos] = Mesh->MeshBuffers.getLast(); - Mesh->MeshBuffers[Mesh->MeshBuffers.size()-1] = tmp; - mb->getMaterial() = tmp->getMaterial(); - vtxCount=0; - } - - for (s32 v=0; v<3; ++v) - { - s32 idx = Indices[MaterialGroups[i].faces[f]*4 +v]; - - if (CountVertices > idx) - { - vtx.Pos.X = Vertices[idx*3 + 0]; - vtx.Pos.Z = Vertices[idx*3 + 1]; - vtx.Pos.Y = Vertices[idx*3 + 2]; -// TransformationMatrix.transformVect(vtx.Pos); - } - - if (CountTCoords > idx) - { - vtx.TCoords.X = TCoords[idx*2 + 0]; - vtx.TCoords.Y = 1.0f -TCoords[idx*2 + 1]; - } - - mb->Vertices.push_back(vtx); - } - - // compute normal - core::plane3d<f32> pl(mb->Vertices[vtxCount].Pos, mb->Vertices[vtxCount+2].Pos, - mb->Vertices[vtxCount+1].Pos); - - mb->Vertices[vtxCount].Normal = pl.Normal; - mb->Vertices[vtxCount+1].Normal = pl.Normal; - mb->Vertices[vtxCount+2].Normal = pl.Normal; - - // add indices - - mb->Indices.push_back(vtxCount); - mb->Indices.push_back(vtxCount+2); - mb->Indices.push_back(vtxCount+1); - } - } - else - os::Printer::log("Found no matching material for Group in 3ds file.", ELL_WARNING); - } - - cleanUp(); -} - - -void C3DSMeshFileLoader::loadMaterials(io::IReadFile* file) -{ - // create a mesh buffer for every material - core::stringc modelFilename = file->getFileName(); - - if (Materials.empty()) - os::Printer::log("No materials found in 3ds file.", ELL_INFORMATION); - - MeshBufferNames.reallocate(Materials.size()); - for (u32 i=0; i<Materials.size(); ++i) - { - MeshBufferNames.push_back(""); - SMeshBuffer* m = new scene::SMeshBuffer(); - Mesh->addMeshBuffer(m); - - m->getMaterial() = Materials[i].Material; - if (Materials[i].Filename[0].size()) - { - video::ITexture* texture = 0; - if (FileSystem->existFile(Materials[i].Filename[0])) - texture = SceneManager->getVideoDriver()->getTexture(Materials[i].Filename[0]); - if (!texture) - { - const core::stringc fname = FileSystem->getFileDir(modelFilename) + "/" + FileSystem->getFileBasename(Materials[i].Filename[0]); - if (FileSystem->existFile(fname)) - texture = SceneManager->getVideoDriver()->getTexture(fname); - } - if (!texture) - os::Printer::log("Could not load a texture for entry in 3ds file", - Materials[i].Filename[0].c_str(), ELL_WARNING); - else - m->getMaterial().setTexture(0, texture); - } - - if (Materials[i].Filename[2].size()) - { - video::ITexture* texture = 0; - if (FileSystem->existFile(Materials[i].Filename[2])) - texture = SceneManager->getVideoDriver()->getTexture(Materials[i].Filename[2]); - if (!texture) - { - const core::stringc fname = FileSystem->getFileDir(modelFilename) + "/" + FileSystem->getFileBasename(Materials[i].Filename[2]); - if (FileSystem->existFile(fname)) - texture = SceneManager->getVideoDriver()->getTexture(fname); - } - if (!texture) - { - os::Printer::log("Could not load a texture for entry in 3ds file", - Materials[i].Filename[2].c_str(), ELL_WARNING); - } - else - { - m->getMaterial().setTexture(0, texture); - m->getMaterial().MaterialType = video::EMT_TRANSPARENT_ADD_COLOR; - } - } - - if (Materials[i].Filename[3].size()) - { - video::ITexture* texture = 0; - if (FileSystem->existFile(Materials[i].Filename[3])) - texture = SceneManager->getVideoDriver()->getTexture(Materials[i].Filename[3]); - if (!texture) - { - const core::stringc fname = FileSystem->getFileDir(modelFilename) + "/" + FileSystem->getFileBasename(Materials[i].Filename[3]); - if (FileSystem->existFile(fname)) - texture = SceneManager->getVideoDriver()->getTexture(fname); - } - - if (!texture) - { - os::Printer::log("Could not load a texture for entry in 3ds file", - Materials[i].Filename[3].c_str(), ELL_WARNING); - } - else - { - m->getMaterial().setTexture(1, m->getMaterial().getTexture(0)); - m->getMaterial().setTexture(0, texture); - m->getMaterial().MaterialType = video::EMT_REFLECTION_2_LAYER; - } - } - - if (Materials[i].Filename[4].size()) - { - video::ITexture* texture = 0; - if (FileSystem->existFile(Materials[i].Filename[4])) - texture = SceneManager->getVideoDriver()->getTexture(Materials[i].Filename[4]); - if (!texture) - { - const core::stringc fname = FileSystem->getFileDir(modelFilename) + "/" + FileSystem->getFileBasename(Materials[i].Filename[4]); - if (FileSystem->existFile(fname)) - texture = SceneManager->getVideoDriver()->getTexture(fname); - } - if (!texture) - os::Printer::log("Could not load a texture for entry in 3ds file", - Materials[i].Filename[4].c_str(), ELL_WARNING); - else - { - m->getMaterial().setTexture(1, texture); - SceneManager->getVideoDriver()->makeNormalMapTexture(texture, Materials[i].Strength[4]*10.f); - m->getMaterial().MaterialType=video::EMT_PARALLAX_MAP_SOLID; - m->getMaterial().MaterialTypeParam=.035f; - } - } - - m->drop(); - } -} - - -void C3DSMeshFileLoader::cleanUp() -{ - delete [] Vertices; - CountVertices = 0; - Vertices = 0; - delete [] Indices; - Indices = 0; - CountFaces = 0; - delete [] SmoothingGroups; - SmoothingGroups = 0; - delete [] TCoords; - TCoords = 0; - CountTCoords = 0; - - MaterialGroups.clear(); -} - - -void C3DSMeshFileLoader::readTextureCoords(io::IReadFile* file, ChunkData& data) -{ -#ifdef _IRR_DEBUG_3DS_LOADER_ - os::Printer::log("Load texture coords."); -#endif - file->read(&CountTCoords, sizeof(CountTCoords)); -#ifdef __BIG_ENDIAN__ - CountTCoords = os::Byteswap::byteswap(CountTCoords); -#endif - data.read += sizeof(CountTCoords); - - s32 tcoordsBufferByteSize = CountTCoords * sizeof(f32) * 2; - - if (data.header.length - data.read != tcoordsBufferByteSize) - { - os::Printer::log("Invalid size of tcoords found in 3ds file.", ELL_WARNING); - return; - } - - TCoords = new f32[CountTCoords * 3]; - file->read(TCoords, tcoordsBufferByteSize); -#ifdef __BIG_ENDIAN__ - for (int i=0;i<CountTCoords*2;i++) TCoords[i] = os::Byteswap::byteswap(TCoords[i]); -#endif - data.read += tcoordsBufferByteSize; -} - - -void C3DSMeshFileLoader::readMaterialGroup(io::IReadFile* file, ChunkData& data) -{ -#ifdef _IRR_DEBUG_3DS_LOADER_ - os::Printer::log("Load material group."); -#endif - SMaterialGroup group; - - readString(file, data, group.MaterialName); - - file->read(&group.faceCount, sizeof(group.faceCount)); -#ifdef __BIG_ENDIAN__ - group.faceCount = os::Byteswap::byteswap(group.faceCount); -#endif - data.read += sizeof(group.faceCount); - - // read faces - group.faces = new u16[group.faceCount]; - file->read(group.faces, sizeof(u16) * group.faceCount); -#ifdef __BIG_ENDIAN__ - for (u32 i=0;i<group.faceCount;++i) - group.faces[i] = os::Byteswap::byteswap(group.faces[i]); -#endif - data.read += sizeof(u16) * group.faceCount; - - MaterialGroups.push_back(group); -} - - -void C3DSMeshFileLoader::readIndices(io::IReadFile* file, ChunkData& data) -{ -#ifdef _IRR_DEBUG_3DS_LOADER_ - os::Printer::log("Load indices."); -#endif - file->read(&CountFaces, sizeof(CountFaces)); -#ifdef __BIG_ENDIAN__ - CountFaces = os::Byteswap::byteswap(CountFaces); -#endif - data.read += sizeof(CountFaces); - - s32 indexBufferByteSize = CountFaces * sizeof(u16) * 4; - - // Indices are u16s. - // After every 3 Indices in the array, there follows an edge flag. - Indices = new u16[CountFaces * 4]; - file->read(Indices, indexBufferByteSize); -#ifdef __BIG_ENDIAN__ - for (int i=0;i<CountFaces*4;++i) - Indices[i] = os::Byteswap::byteswap(Indices[i]); -#endif - data.read += indexBufferByteSize; -} - - -void C3DSMeshFileLoader::readVertices(io::IReadFile* file, ChunkData& data) -{ -#ifdef _IRR_DEBUG_3DS_LOADER_ - os::Printer::log("Load vertices."); -#endif - file->read(&CountVertices, sizeof(CountVertices)); -#ifdef __BIG_ENDIAN__ - CountVertices = os::Byteswap::byteswap(CountVertices); -#endif - data.read += sizeof(CountVertices); - - const s32 vertexBufferByteSize = CountVertices * sizeof(f32) * 3; - - if (data.header.length - data.read != vertexBufferByteSize) - { - os::Printer::log("Invalid size of vertices found in 3ds file", core::stringc(CountVertices), ELL_ERROR); - return; - } - - Vertices = new f32[CountVertices * 3]; - file->read(Vertices, vertexBufferByteSize); -#ifdef __BIG_ENDIAN__ - for (int i=0;i<CountVertices*3;i++) - Vertices[i] = os::Byteswap::byteswap(Vertices[i]); -#endif - data.read += vertexBufferByteSize; -} - - -void C3DSMeshFileLoader::readChunkData(io::IReadFile* file, ChunkData& data) -{ - file->read(&data.header, sizeof(ChunkHeader)); -#ifdef __BIG_ENDIAN__ - data.header.id = os::Byteswap::byteswap(data.header.id); - data.header.length = os::Byteswap::byteswap(data.header.length); -#endif - data.read += sizeof(ChunkHeader); -} - - -void C3DSMeshFileLoader::readString(io::IReadFile* file, ChunkData& data, core::stringc& out) -{ - c8 c = 1; - out = ""; - - while (c) - { - file->read(&c, sizeof(c8)); - if (c) - out.append(c); - } - data.read+=out.size()+1; -} - - -} // end namespace scene -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_3DS_LOADER_ - diff --git a/irrlicht-1.6/source/Irrlicht/C3DSMeshFileLoader.h b/irrlicht-1.6/source/Irrlicht/C3DSMeshFileLoader.h deleted file mode 100644 index 20028d46d..000000000 --- a/irrlicht-1.6/source/Irrlicht/C3DSMeshFileLoader.h +++ /dev/null @@ -1,179 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_3DS_MESH_FILE_LOADER_H_INCLUDED__ -#define __C_3DS_MESH_FILE_LOADER_H_INCLUDED__ - -#include "IMeshLoader.h" -#include "IFileSystem.h" -#include "ISceneManager.h" -#include "irrString.h" -#include "SMesh.h" -#include "matrix4.h" - -namespace irr -{ -namespace scene -{ - -//! Meshloader capable of loading 3ds meshes. -class C3DSMeshFileLoader : public IMeshLoader -{ -public: - - //! Constructor - C3DSMeshFileLoader(ISceneManager* smgr, io::IFileSystem* fs); - - //! destructor - virtual ~C3DSMeshFileLoader(); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".cob") - virtual bool isALoadableFileExtension(const io::path& 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: - - // byte-align structures - #if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) - # pragma pack( push, packing ) - # pragma pack( 1 ) - # define PACK_STRUCT - #elif defined( __GNUC__ ) - # define PACK_STRUCT __attribute__((packed)) - #else - # error compiler not supported - #endif - - struct ChunkHeader - { - u16 id; - s32 length; - } PACK_STRUCT; - - // Default alignment - #if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) - # pragma pack( pop, packing ) - #endif - - #undef PACK_STRUCT - - - struct ChunkData - { - ChunkData() : read(0) {} - - ChunkHeader header; - s32 read; - }; - - struct SCurrentMaterial - { - void clear() { - Material=video::SMaterial(); - Name=""; - Filename[0]=""; - Filename[1]=""; - Filename[2]=""; - Filename[3]=""; - Filename[4]=""; - Strength[0]=0.f; - Strength[1]=0.f; - Strength[2]=0.f; - Strength[3]=0.f; - Strength[4]=0.f; - } - - video::SMaterial Material; - core::stringc Name; - core::stringc Filename[5]; - f32 Strength[5]; - }; - - struct SMaterialGroup - { - SMaterialGroup() : faceCount(0), faces(0) {}; - - SMaterialGroup(const SMaterialGroup& o) - { - *this = o; - } - - ~SMaterialGroup() - { - clear(); - } - - void clear() - { - delete [] faces; - faces = 0; - faceCount = 0; - } - - void operator =(const SMaterialGroup& o) - { - MaterialName = o.MaterialName; - faceCount = o.faceCount; - faces = new u16[faceCount]; - for (u32 i=0; i<faceCount; ++i) - faces[i] = o.faces[i]; - } - - core::stringc MaterialName; - u16 faceCount; - u16* faces; - }; - - bool readChunk(io::IReadFile* file, ChunkData* parent); - bool readMaterialChunk(io::IReadFile* file, ChunkData* parent); - bool readFrameChunk(io::IReadFile* file, ChunkData* parent); - bool readTrackChunk(io::IReadFile* file, ChunkData& data, - IMeshBuffer* mb, const core::vector3df& pivot); - bool readObjectChunk(io::IReadFile* file, ChunkData* parent); - bool readPercentageChunk(io::IReadFile* file, ChunkData* chunk, f32& percentage); - bool readColorChunk(io::IReadFile* file, ChunkData* chunk, video::SColor& out); - - void readChunkData(io::IReadFile* file, ChunkData& data); - void readString(io::IReadFile* file, ChunkData& data, core::stringc& out); - void readVertices(io::IReadFile* file, ChunkData& data); - void readIndices(io::IReadFile* file, ChunkData& data); - void readMaterialGroup(io::IReadFile* file, ChunkData& data); - void readTextureCoords(io::IReadFile* file, ChunkData& data); - - void composeObject(io::IReadFile* file, const core::stringc& name); - void loadMaterials(io::IReadFile* file); - void cleanUp(); - - scene::ISceneManager* SceneManager; - io::IFileSystem* FileSystem; - - f32* Vertices; - u16* Indices; - u32* SmoothingGroups; - core::array<u16> TempIndices; - f32* TCoords; - u16 CountVertices; - u16 CountFaces; // = CountIndices/4 - u16 CountTCoords; - core::array<SMaterialGroup> MaterialGroups; - - SCurrentMaterial CurrentMaterial; - core::array<SCurrentMaterial> Materials; - core::array<core::stringc> MeshBufferNames; - core::matrix4 TransformationMatrix; - - SMesh* Mesh; -}; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CAnimatedMeshMD2.cpp b/irrlicht-1.6/source/Irrlicht/CAnimatedMeshMD2.cpp deleted file mode 100644 index 01de7b798..000000000 --- a/irrlicht-1.6/source/Irrlicht/CAnimatedMeshMD2.cpp +++ /dev/null @@ -1,472 +0,0 @@ -// Copyright (C) 2002-2009 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_MD2_LOADER_ - -#include "CAnimatedMeshMD2.h" -#include "SColor.h" -#include "irrMath.h" - -namespace irr -{ -namespace scene -{ - -const s32 MD2_FRAME_SHIFT = 2; -const f32 MD2_FRAME_SHIFT_RECIPROCAL = 1.f / ( 1 << MD2_FRAME_SHIFT ); - - -const s32 Q2_VERTEX_NORMAL_TABLE_SIZE = 162; - -static const f32 Q2_VERTEX_NORMAL_TABLE[Q2_VERTEX_NORMAL_TABLE_SIZE][3] = { - {-0.525731f, 0.000000f, 0.850651f}, - {-0.442863f, 0.238856f, 0.864188f}, - {-0.295242f, 0.000000f, 0.955423f}, - {-0.309017f, 0.500000f, 0.809017f}, - {-0.162460f, 0.262866f, 0.951056f}, - {0.000000f, 0.000000f, 1.000000f}, - {0.000000f, 0.850651f, 0.525731f}, - {-0.147621f, 0.716567f, 0.681718f}, - {0.147621f, 0.716567f, 0.681718f}, - {0.000000f, 0.525731f, 0.850651f}, - {0.309017f, 0.500000f, 0.809017f}, - {0.525731f, 0.000000f, 0.850651f}, - {0.295242f, 0.000000f, 0.955423f}, - {0.442863f, 0.238856f, 0.864188f}, - {0.162460f, 0.262866f, 0.951056f}, - {-0.681718f, 0.147621f, 0.716567f}, - {-0.809017f, 0.309017f, 0.500000f}, - {-0.587785f, 0.425325f, 0.688191f}, - {-0.850651f, 0.525731f, 0.000000f}, - {-0.864188f, 0.442863f, 0.238856f}, - {-0.716567f, 0.681718f, 0.147621f}, - {-0.688191f, 0.587785f, 0.425325f}, - {-0.500000f, 0.809017f, 0.309017f}, - {-0.238856f, 0.864188f, 0.442863f}, - {-0.425325f, 0.688191f, 0.587785f}, - {-0.716567f, 0.681718f, -0.147621f}, - {-0.500000f, 0.809017f, -0.309017f}, - {-0.525731f, 0.850651f, 0.000000f}, - {0.000000f, 0.850651f, -0.525731f}, - {-0.238856f, 0.864188f, -0.442863f}, - {0.000000f, 0.955423f, -0.295242f}, - {-0.262866f, 0.951056f, -0.162460f}, - {0.000000f, 1.000000f, 0.000000f}, - {0.000000f, 0.955423f, 0.295242f}, - {-0.262866f, 0.951056f, 0.162460f}, - {0.238856f, 0.864188f, 0.442863f}, - {0.262866f, 0.951056f, 0.162460f}, - {0.500000f, 0.809017f, 0.309017f}, - {0.238856f, 0.864188f, -0.442863f}, - {0.262866f, 0.951056f, -0.162460f}, - {0.500000f, 0.809017f, -0.309017f}, - {0.850651f, 0.525731f, 0.000000f}, - {0.716567f, 0.681718f, 0.147621f}, - {0.716567f, 0.681718f, -0.147621f}, - {0.525731f, 0.850651f, 0.000000f}, - {0.425325f, 0.688191f, 0.587785f}, - {0.864188f, 0.442863f, 0.238856f}, - {0.688191f, 0.587785f, 0.425325f}, - {0.809017f, 0.309017f, 0.500000f}, - {0.681718f, 0.147621f, 0.716567f}, - {0.587785f, 0.425325f, 0.688191f}, - {0.955423f, 0.295242f, 0.000000f}, - {1.000000f, 0.000000f, 0.000000f}, - {0.951056f, 0.162460f, 0.262866f}, - {0.850651f, -0.525731f, 0.000000f}, - {0.955423f, -0.295242f, 0.000000f}, - {0.864188f, -0.442863f, 0.238856f}, - {0.951056f, -0.162460f, 0.262866f}, - {0.809017f, -0.309017f, 0.500000f}, - {0.681718f, -0.147621f, 0.716567f}, - {0.850651f, 0.000000f, 0.525731f}, - {0.864188f, 0.442863f, -0.238856f}, - {0.809017f, 0.309017f, -0.500000f}, - {0.951056f, 0.162460f, -0.262866f}, - {0.525731f, 0.000000f, -0.850651f}, - {0.681718f, 0.147621f, -0.716567f}, - {0.681718f, -0.147621f, -0.716567f}, - {0.850651f, 0.000000f, -0.525731f}, - {0.809017f, -0.309017f, -0.500000f}, - {0.864188f, -0.442863f, -0.238856f}, - {0.951056f, -0.162460f, -0.262866f}, - {0.147621f, 0.716567f, -0.681718f}, - {0.309017f, 0.500000f, -0.809017f}, - {0.425325f, 0.688191f, -0.587785f}, - {0.442863f, 0.238856f, -0.864188f}, - {0.587785f, 0.425325f, -0.688191f}, - {0.688191f, 0.587785f, -0.425325f}, - {-0.147621f, 0.716567f, -0.681718f}, - {-0.309017f, 0.500000f, -0.809017f}, - {0.000000f, 0.525731f, -0.850651f}, - {-0.525731f, 0.000000f, -0.850651f}, - {-0.442863f, 0.238856f, -0.864188f}, - {-0.295242f, 0.000000f, -0.955423f}, - {-0.162460f, 0.262866f, -0.951056f}, - {0.000000f, 0.000000f, -1.000000f}, - {0.295242f, 0.000000f, -0.955423f}, - {0.162460f, 0.262866f, -0.951056f}, - {-0.442863f, -0.238856f, -0.864188f}, - {-0.309017f, -0.500000f, -0.809017f}, - {-0.162460f, -0.262866f, -0.951056f}, - {0.000000f, -0.850651f, -0.525731f}, - {-0.147621f, -0.716567f, -0.681718f}, - {0.147621f, -0.716567f, -0.681718f}, - {0.000000f, -0.525731f, -0.850651f}, - {0.309017f, -0.500000f, -0.809017f}, - {0.442863f, -0.238856f, -0.864188f}, - {0.162460f, -0.262866f, -0.951056f}, - {0.238856f, -0.864188f, -0.442863f}, - {0.500000f, -0.809017f, -0.309017f}, - {0.425325f, -0.688191f, -0.587785f}, - {0.716567f, -0.681718f, -0.147621f}, - {0.688191f, -0.587785f, -0.425325f}, - {0.587785f, -0.425325f, -0.688191f}, - {0.000000f, -0.955423f, -0.295242f}, - {0.000000f, -1.000000f, 0.000000f}, - {0.262866f, -0.951056f, -0.162460f}, - {0.000000f, -0.850651f, 0.525731f}, - {0.000000f, -0.955423f, 0.295242f}, - {0.238856f, -0.864188f, 0.442863f}, - {0.262866f, -0.951056f, 0.162460f}, - {0.500000f, -0.809017f, 0.309017f}, - {0.716567f, -0.681718f, 0.147621f}, - {0.525731f, -0.850651f, 0.000000f}, - {-0.238856f, -0.864188f, -0.442863f}, - {-0.500000f, -0.809017f, -0.309017f}, - {-0.262866f, -0.951056f, -0.162460f}, - {-0.850651f, -0.525731f, 0.000000f}, - {-0.716567f, -0.681718f, -0.147621f}, - {-0.716567f, -0.681718f, 0.147621f}, - {-0.525731f, -0.850651f, 0.000000f}, - {-0.500000f, -0.809017f, 0.309017f}, - {-0.238856f, -0.864188f, 0.442863f}, - {-0.262866f, -0.951056f, 0.162460f}, - {-0.864188f, -0.442863f, 0.238856f}, - {-0.809017f, -0.309017f, 0.500000f}, - {-0.688191f, -0.587785f, 0.425325f}, - {-0.681718f, -0.147621f, 0.716567f}, - {-0.442863f, -0.238856f, 0.864188f}, - {-0.587785f, -0.425325f, 0.688191f}, - {-0.309017f, -0.500000f, 0.809017f}, - {-0.147621f, -0.716567f, 0.681718f}, - {-0.425325f, -0.688191f, 0.587785f}, - {-0.162460f, -0.262866f, 0.951056f}, - {0.442863f, -0.238856f, 0.864188f}, - {0.162460f, -0.262866f, 0.951056f}, - {0.309017f, -0.500000f, 0.809017f}, - {0.147621f, -0.716567f, 0.681718f}, - {0.000000f, -0.525731f, 0.850651f}, - {0.425325f, -0.688191f, 0.587785f}, - {0.587785f, -0.425325f, 0.688191f}, - {0.688191f, -0.587785f, 0.425325f}, - {-0.955423f, 0.295242f, 0.000000f}, - {-0.951056f, 0.162460f, 0.262866f}, - {-1.000000f, 0.000000f, 0.000000f}, - {-0.850651f, 0.000000f, 0.525731f}, - {-0.955423f, -0.295242f, 0.000000f}, - {-0.951056f, -0.162460f, 0.262866f}, - {-0.864188f, 0.442863f, -0.238856f}, - {-0.951056f, 0.162460f, -0.262866f}, - {-0.809017f, 0.309017f, -0.500000f}, - {-0.864188f, -0.442863f, -0.238856f}, - {-0.951056f, -0.162460f, -0.262866f}, - {-0.809017f, -0.309017f, -0.500000f}, - {-0.681718f, 0.147621f, -0.716567f}, - {-0.681718f, -0.147621f, -0.716567f}, - {-0.850651f, 0.000000f, -0.525731f}, - {-0.688191f, 0.587785f, -0.425325f}, - {-0.587785f, 0.425325f, -0.688191f}, - {-0.425325f, 0.688191f, -0.587785f}, - {-0.425325f, -0.688191f, -0.587785f}, - {-0.587785f, -0.425325f, -0.688191f}, - {-0.688191f, -0.587785f, -0.425325f}, - }; - -struct SMD2AnimationType -{ - s32 begin; - s32 end; - s32 fps; -}; - -static const SMD2AnimationType MD2AnimationTypeList[21] = -{ - { 0, 39, 9 }, // STAND - { 40, 45, 10 }, // RUN - { 46, 53, 10 }, // ATTACK - { 54, 57, 7 }, // PAIN_A - { 58, 61, 7 }, // PAIN_B - { 62, 65, 7 }, // PAIN_C - { 66, 71, 7 }, // JUMP - { 72, 83, 7 }, // FLIP - { 84, 94, 7 }, // SALUTE - { 95, 111, 10 }, // FALLBACK - { 112, 122, 7 }, // WAVE - { 123, 134, 6 }, // POINT - { 135, 153, 10 }, // CROUCH_STAND - { 154, 159, 7 }, // CROUCH_WALK - { 160, 168, 10 }, // CROUCH_ATTACK - { 169, 172, 7 }, // CROUCH_PAIN - { 173, 177, 5 }, // CROUCH_DEATH - { 178, 183, 7 }, // DEATH_FALLBACK - { 184, 189, 7 }, // DEATH_FALLFORWARD - { 190, 197, 7 }, // DEATH_FALLBACKSLOW - { 198, 198, 5 }, // BOOM -}; - - -//! constructor -CAnimatedMeshMD2::CAnimatedMeshMD2() -: InterpolationBuffer(0), FrameList(0), FrameCount(0) -{ - #ifdef _DEBUG - IAnimatedMesh::setDebugName("CAnimatedMeshMD2 IAnimatedMesh"); - IMesh::setDebugName("CAnimatedMeshMD2 IMesh"); - #endif - InterpolationBuffer = new SMeshBuffer; -} - - -//! destructor -CAnimatedMeshMD2::~CAnimatedMeshMD2() -{ - delete [] FrameList; - if (InterpolationBuffer) - InterpolationBuffer->drop(); -} - -//! returns the amount of frames in milliseconds. If the amount is 1, it is a static (=non animated) mesh. -u32 CAnimatedMeshMD2::getFrameCount() const -{ - return FrameCount<<MD2_FRAME_SHIFT; -} - - -//! returns the animated mesh based on a detail level. 0 is the lowest, 255 the highest detail. Note, that some Meshes will ignore the detail level. -IMesh* CAnimatedMeshMD2::getMesh(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop) -{ - if ((u32)frame > getFrameCount()) - frame = (frame % getFrameCount()); - - if (startFrameLoop == -1 && endFrameLoop == -1) - { - startFrameLoop = 0; - endFrameLoop = getFrameCount(); - } - - updateInterpolationBuffer(frame, startFrameLoop, endFrameLoop); - return this; -} - - -//! returns amount of mesh buffers. MD2 meshes only have one buffer -u32 CAnimatedMeshMD2::getMeshBufferCount() const -{ - return 1; -} - - -//! returns pointer to a mesh buffer -IMeshBuffer* CAnimatedMeshMD2::getMeshBuffer(u32 nr) const -{ - if (nr == 0) - return InterpolationBuffer; - else - return 0; -} - - -//! Returns pointer to a mesh buffer which fits a material -IMeshBuffer* CAnimatedMeshMD2::getMeshBuffer(const video::SMaterial &material) const -{ - if (InterpolationBuffer->Material == material) - return InterpolationBuffer; - else - return 0; -} - - -// updates the interpolation buffer -void CAnimatedMeshMD2::updateInterpolationBuffer(s32 frame, s32 startFrameLoop, s32 endFrameLoop) -{ - u32 firstFrame, secondFrame; - f32 div; - core::vector3df* NormalTable = (core::vector3df*)&Q2_VERTEX_NORMAL_TABLE; - - // TA: resolve missing ipol in loop between end-start - - if (endFrameLoop - startFrameLoop == 0) - { - firstFrame = frame>>MD2_FRAME_SHIFT; - secondFrame = frame>>MD2_FRAME_SHIFT; - div = 1.0f; - } - else - { - // key frames - u32 s = startFrameLoop >> MD2_FRAME_SHIFT; - u32 e = endFrameLoop >> MD2_FRAME_SHIFT; - - firstFrame = frame >> MD2_FRAME_SHIFT; - secondFrame = core::if_c_a_else_b ( firstFrame + 1 > e, s, firstFrame + 1 ); - - firstFrame = core::s32_min ( FrameCount - 1, firstFrame ); - secondFrame = core::s32_min ( FrameCount - 1, secondFrame ); - - //div = (frame % (1<<MD2_FRAME_SHIFT)) / (f32)(1<<MD2_FRAME_SHIFT); - frame &= (1<<MD2_FRAME_SHIFT) - 1; - div = frame * MD2_FRAME_SHIFT_RECIPROCAL; - } - - video::S3DVertex* target = static_cast<video::S3DVertex*>(InterpolationBuffer->getVertices()); - SMD2Vert* first = FrameList[firstFrame].pointer(); - SMD2Vert* second = FrameList[secondFrame].pointer(); - - // interpolate both frames - const u32 count = FrameList[firstFrame].size(); - for (u32 i=0; i<count; ++i) - { - core::vector3df one, two; - one.X = f32(first->Pos.X) * FrameTransforms[firstFrame].scale.X + FrameTransforms[firstFrame].translate.X; - one.Y = f32(first->Pos.Y) * FrameTransforms[firstFrame].scale.Y + FrameTransforms[firstFrame].translate.Y; - one.Z = f32(first->Pos.Z) * FrameTransforms[firstFrame].scale.Z + FrameTransforms[firstFrame].translate.Z; - two.X = f32(second->Pos.X) * FrameTransforms[secondFrame].scale.X + FrameTransforms[secondFrame].translate.X; - two.Y = f32(second->Pos.Y) * FrameTransforms[secondFrame].scale.Y + FrameTransforms[secondFrame].translate.Y; - two.Z = f32(second->Pos.Z) * FrameTransforms[secondFrame].scale.Z + FrameTransforms[secondFrame].translate.Z; - target->Pos = (two - one) * div + one; - - target->Normal = (NormalTable[second->NormalIdx] - NormalTable[first->NormalIdx]) * div - + NormalTable[first->NormalIdx]; - ++target; - ++first; - ++second; - } - - //update bounding box - InterpolationBuffer->setBoundingBox(BoxList[secondFrame].getInterpolated(BoxList[firstFrame], div)); - InterpolationBuffer->setDirty(); -} - -//! calculates the bounding box -void CAnimatedMeshMD2::calculateBoundingBox() -{ - InterpolationBuffer->BoundingBox.reset(0,0,0); - - if (FrameCount) - { - u32 defaultFrame = 1; - - if (defaultFrame>=FrameCount) - defaultFrame = 0; - -// for (u32 j=0; j<FrameList[defaultFrame].size(); ++j) -// InterpolationBuffer->BoundingBox.addInternalPoint(FrameList[defaultFrame].pointer()[j].Pos); - } -} - - -//! sets a flag of all contained materials to a new value -void CAnimatedMeshMD2::setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue) -{ - InterpolationBuffer->Material.setFlag(flag, newvalue); -} - - - -//! set the hardware mapping hint, for driver -void CAnimatedMeshMD2::setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint, - E_BUFFER_TYPE buffer) -{ - InterpolationBuffer->setHardwareMappingHint(newMappingHint, buffer); -} - - -//! flags the meshbuffer as changed, reloads hardware buffers -void CAnimatedMeshMD2::setDirty(E_BUFFER_TYPE buffer) -{ - InterpolationBuffer->setDirty(buffer); -} - - -//! returns an axis aligned bounding box -const core::aabbox3d<f32>& CAnimatedMeshMD2::getBoundingBox() const -{ - return InterpolationBuffer->BoundingBox; -} - - -//! set user axis aligned bounding box -void CAnimatedMeshMD2::setBoundingBox( const core::aabbox3df& box) -{ - InterpolationBuffer->BoundingBox = box; -} - - -//! Returns the type of the animated mesh. -E_ANIMATED_MESH_TYPE CAnimatedMeshMD2::getMeshType() const -{ - return EAMT_MD2; -} - - -//! Returns frame loop data for a special MD2 animation type. -void CAnimatedMeshMD2::getFrameLoop(EMD2_ANIMATION_TYPE l, - s32& outBegin, s32& outEnd, s32& outFPS) const -{ - if (l < 0 || l >= EMAT_COUNT) - return; - - outBegin = MD2AnimationTypeList[l].begin << MD2_FRAME_SHIFT; - outEnd = MD2AnimationTypeList[l].end << MD2_FRAME_SHIFT; - - // correct to anim between last->first frame - outEnd += MD2_FRAME_SHIFT == 0 ? 1 : ( 1 << MD2_FRAME_SHIFT ) - 1; - outFPS = MD2AnimationTypeList[l].fps << MD2_FRAME_SHIFT; -} - - -//! Returns frame loop data for a special MD2 animation type. -bool CAnimatedMeshMD2::getFrameLoop(const c8* name, - s32& outBegin, s32&outEnd, s32& outFPS) const -{ - for (u32 i=0; i < AnimationData.size(); ++i) - { - if (AnimationData[i].name == name) - { - outBegin = AnimationData[i].begin << MD2_FRAME_SHIFT; - outEnd = AnimationData[i].end << MD2_FRAME_SHIFT; - outEnd += MD2_FRAME_SHIFT == 0 ? 1 : ( 1 << MD2_FRAME_SHIFT ) - 1; - outFPS = AnimationData[i].fps << MD2_FRAME_SHIFT; - return true; - } - } - - return false; -} - - -//! Returns amount of md2 animations in this file. -s32 CAnimatedMeshMD2::getAnimationCount() const -{ - return AnimationData.size(); -} - - -//! Returns name of md2 animation. -const c8* CAnimatedMeshMD2::getAnimationName(s32 nr) const -{ - if ((u32)nr >= AnimationData.size()) - return 0; - - return AnimationData[nr].name.c_str(); -} - - -} // end namespace scene -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_MD2_LOADER_ - diff --git a/irrlicht-1.6/source/Irrlicht/CAnimatedMeshMD2.h b/irrlicht-1.6/source/Irrlicht/CAnimatedMeshMD2.h deleted file mode 100644 index 663eef18d..000000000 --- a/irrlicht-1.6/source/Irrlicht/CAnimatedMeshMD2.h +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_ANIMATED_MESH_MD2_H_INCLUDED__ -#define __C_ANIMATED_MESH_MD2_H_INCLUDED__ - -#include "IAnimatedMeshMD2.h" -#include "IMesh.h" -#include "CMeshBuffer.h" -#include "IReadFile.h" -#include "S3DVertex.h" -#include "irrArray.h" -#include "irrString.h" - -namespace irr -{ -namespace scene -{ - - class CAnimatedMeshMD2 : public IAnimatedMeshMD2 - { - public: - - //! constructor - CAnimatedMeshMD2(); - - //! destructor - virtual ~CAnimatedMeshMD2(); - - //! returns the amount of frames in milliseconds. If the amount is 1, it is a static (=non animated) mesh. - virtual u32 getFrameCount() const; - - //! returns the animated mesh based on a detail level. 0 is the lowest, 255 the highest detail. Note, that some Meshes will ignore the detail level. - virtual IMesh* getMesh(s32 frame, s32 detailLevel=255, s32 startFrameLoop=-1, s32 endFrameLoop=-1); - - //! returns amount of mesh buffers. - virtual u32 getMeshBufferCount() const; - - //! returns pointer to a mesh buffer - virtual IMeshBuffer* getMeshBuffer(u32 nr) const; - - //! Returns pointer to a mesh buffer which fits a material - /** \param material: material to search for - \return Returns the pointer to the mesh buffer or - NULL if there is no such mesh buffer. */ - virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const; - - //! returns an axis aligned bounding box - virtual const core::aabbox3d<f32>& getBoundingBox() const; - - //! set user axis aligned bounding box - virtual void setBoundingBox( const core::aabbox3df& box); - - //! sets a flag of all contained materials to a new value - virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue); - - //! set the hardware mapping hint, for driver - virtual void setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX); - - //! flags the meshbuffer as changed, reloads hardware buffers - virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX); - - //! Returns the type of the animated mesh. - virtual E_ANIMATED_MESH_TYPE getMeshType() const; - - //! Returns frame loop data for a special MD2 animation type. - virtual void getFrameLoop(EMD2_ANIMATION_TYPE, - s32& outBegin, s32& outEnd, s32& outFps) const; - - //! Returns frame loop data for a special MD2 animation type. - virtual bool getFrameLoop(const c8* name, - s32& outBegin, s32& outEnd, s32& outFps) const; - - //! Returns amount of md2 animations in this file. - virtual s32 getAnimationCount() const; - - //! Returns name of md2 animation. - //! \param nr: Zero based index of animation. - virtual const c8* getAnimationName(s32 nr) const; - - - // - // exposed for loader - // - - //! the buffer that contains the most recent animation - SMeshBuffer* InterpolationBuffer; - - //! named animations - struct SAnimationData - { - core::stringc name; - s32 begin; - s32 end; - s32 fps; - }; - - //! scale and translations for keyframes - struct SKeyFrameTransform - { - core::vector3df scale; - core::vector3df translate; - }; - - //! md2 vertex data - struct SMD2Vert - { - core::vector3d<u8> Pos; - u8 NormalIdx; - }; - - //! keyframe transformations - core::array<SKeyFrameTransform> FrameTransforms; - - //! keyframe vertex data - core::array<SMD2Vert> *FrameList; - - //! bounding boxes for each keyframe - core::array<core::aabbox3d<f32> > BoxList; - - //! named animations - core::array< SAnimationData > AnimationData; - - //! calculates the bounding box - virtual void calculateBoundingBox(); - - u32 FrameCount; - - private: - - //! updates the interpolation buffer - void updateInterpolationBuffer(s32 frame, s32 startFrame, s32 endFrame); - - - }; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CAnimatedMeshMD3.cpp b/irrlicht-1.6/source/Irrlicht/CAnimatedMeshMD3.cpp deleted file mode 100644 index f3c179ed6..000000000 --- a/irrlicht-1.6/source/Irrlicht/CAnimatedMeshMD3.cpp +++ /dev/null @@ -1,451 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt / Fabio Concas / Thomas Alten -// 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_MD3_LOADER_ - -#include "CAnimatedMeshMD3.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - - -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) -# pragma pack( push, packing ) -# pragma pack( 1 ) -# define PACK_STRUCT -#elif defined( __GNUC__ ) -# define PACK_STRUCT __attribute__((packed)) -#else -# error compiler not supported -#endif - - -//! General properties of a single animation frame. -struct SMD3Frame -{ - f32 mins[3]; // bounding box per frame - f32 maxs[3]; - f32 position[3]; // position of bounding box - f32 radius; // radius of bounding sphere - c8 creator[16]; // name of frame -}; - - -//! An attachment point for another MD3 model. -struct SMD3Tag -{ - c8 Name[64]; //name of 'tag' as it's usually called in the md3 files try to see it as a sub-mesh/seperate mesh-part. - f32 position[3]; //relative position of tag - f32 rotationMatrix[9]; //3x3 rotation direction of tag -}; - -//!Shader -struct SMD3Shader -{ - c8 name[64]; // name of shader - s32 shaderIndex; -}; - - - -// Default alignment -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) -# pragma pack( pop, packing ) -#endif - -#undef PACK_STRUCT - - -//! Constructor -CAnimatedMeshMD3::CAnimatedMeshMD3() -:Mesh(0), IPolShift(0), LoopMode(0), Scaling(1.f) -{ -#ifdef _DEBUG - setDebugName("CAnimatedMeshMD3"); -#endif - - Mesh = new SMD3Mesh(); - - setInterpolationShift ( 0, 0 ); -} - - -//! Destructor -CAnimatedMeshMD3::~CAnimatedMeshMD3() -{ - if (Mesh) - Mesh->drop(); -} - - -//! Returns the amount of frames in milliseconds. If the amount is 1, it is a static (=non animated) mesh. -u32 CAnimatedMeshMD3::getFrameCount() const -{ - return Mesh->MD3Header.numFrames << IPolShift; -} - - -//! Rendering Hint -void CAnimatedMeshMD3::setInterpolationShift ( u32 shift, u32 loopMode ) -{ - IPolShift = shift; - LoopMode = loopMode; -} - - -//! set the hardware mapping hint, for driver -void CAnimatedMeshMD3::setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint, - E_BUFFER_TYPE buffer) -{ - MeshIPol.setHardwareMappingHint(newMappingHint, buffer); -} - - -//! flags the meshbuffer as changed, reloads hardware buffers -void CAnimatedMeshMD3::setDirty(E_BUFFER_TYPE buffer) -{ - MeshIPol.setDirty(buffer); -} - - -//! Returns the animated tag list based on a detail level. 0 is the lowest, 255 the highest detail. -SMD3QuaternionTagList *CAnimatedMeshMD3::getTagList(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop) -{ - if ( 0 == Mesh ) - return 0; - - getMesh ( frame, detailLevel, startFrameLoop, endFrameLoop ); - return &TagListIPol; -} - - -//! Returns the animated mesh based on a detail level. 0 is the lowest, 255 the highest detail. -IMesh* CAnimatedMeshMD3::getMesh(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop) -{ - if ( 0 == Mesh ) - return 0; - - u32 i; - - //! check if we have the mesh in our private cache - SCacheInfo candidate ( frame, startFrameLoop, endFrameLoop ); - if ( candidate == Current ) - return &MeshIPol; - - startFrameLoop = core::s32_max ( 0, startFrameLoop >> IPolShift ); - endFrameLoop = core::if_c_a_else_b ( endFrameLoop < 0, Mesh->MD3Header.numFrames - 1, endFrameLoop >> IPolShift ); - - const u32 mask = 1 << IPolShift; - - s32 frameA; - s32 frameB; - f32 iPol; - - if ( LoopMode ) - { - // correct frame to "pixel center" - frame -= mask >> 1; - - // interpolation - iPol = f32(frame & ( mask - 1 )) * core::reciprocal ( f32(mask) ); - - // wrap anim - frame >>= IPolShift; - frameA = core::if_c_a_else_b ( frame < startFrameLoop, endFrameLoop, frame ); - frameB = core::if_c_a_else_b ( frameA + 1 > endFrameLoop, startFrameLoop, frameA + 1 ); - } - else - { - // correct frame to "pixel center" - frame -= mask >> 1; - - iPol = f32(frame & ( mask - 1 )) * core::reciprocal ( f32(mask) ); - - // clamp anim - frame >>= IPolShift; - frameA = core::s32_clamp ( frame, startFrameLoop, endFrameLoop ); - frameB = core::s32_min ( frameA + 1, endFrameLoop ); - } - - // build current vertex - for ( i = 0; i!= Mesh->Buffer.size (); ++i ) - { - buildVertexArray(frameA, frameB, iPol, - Mesh->Buffer[i], - (SMeshBufferLightMap*) MeshIPol.getMeshBuffer(i) - ); - } - MeshIPol.recalculateBoundingBox(); - - // build current tags - buildTagArray( frameA, frameB, iPol ); - - Current = candidate; - return &MeshIPol; -} - - -//! create a Irrlicht MeshBuffer for a MD3 MeshBuffer -IMeshBuffer * CAnimatedMeshMD3::createMeshBuffer(const SMD3MeshBuffer* source, - io::IFileSystem* fs, video::IVideoDriver * driver) -{ - SMeshBufferLightMap * dest = new SMeshBufferLightMap(); - dest->Vertices.set_used( source->MeshHeader.numVertices ); - dest->Indices.set_used( source->Indices.size () ); - - u32 i; - - // fill in static face info - for ( i = 0; i < source->Indices.size(); i += 3 ) - { - dest->Indices[i + 0 ] = (u16) source->Indices[i + 0]; - dest->Indices[i + 1 ] = (u16) source->Indices[i + 1]; - dest->Indices[i + 2 ] = (u16) source->Indices[i + 2]; - } - - // fill in static vertex info - for ( i = 0; i!= (u32)source->MeshHeader.numVertices; ++i ) - { - video::S3DVertex2TCoords &v = dest->Vertices[i]; - v.Color = 0xFFFFFFFF; - v.TCoords.X = source->Tex[i].u; - v.TCoords.Y = source->Tex[i].v; - v.TCoords2.X = 0.f; - v.TCoords2.Y = 0.f; - } - - // load static texture - u32 pos = 0; - quake3::tTexArray textureArray; - quake3::getTextures( textureArray, source->Shader, pos, fs, driver ); - dest->Material.MaterialType = video::EMT_SOLID; - dest->Material.setTexture ( 0, textureArray[0] ); - dest->Material.Lighting = false; - - return dest; -} - - -//! build final mesh's vertices from frames frameA and frameB with linear interpolation. -void CAnimatedMeshMD3::buildVertexArray ( u32 frameA, u32 frameB, f32 interpolate, - const SMD3MeshBuffer * source, - SMeshBufferLightMap * dest - ) -{ - const u32 frameOffsetA = frameA * source->MeshHeader.numVertices; - const u32 frameOffsetB = frameB * source->MeshHeader.numVertices; - const f32 scale = ( 1.f/ 64.f ); - - for (s32 i = 0; i != source->MeshHeader.numVertices; ++i) - { - video::S3DVertex2TCoords &v = dest->Vertices [ i ]; - - const SMD3Vertex &vA = source->Vertices [ frameOffsetA + i ]; - const SMD3Vertex &vB = source->Vertices [ frameOffsetB + i ]; - - // position - v.Pos.X = scale * ( vA.position[0] + interpolate * ( vB.position[0] - vA.position[0] ) ); - v.Pos.Y = scale * ( vA.position[2] + interpolate * ( vB.position[2] - vA.position[2] ) ); - v.Pos.Z = scale * ( vA.position[1] + interpolate * ( vB.position[1] - vA.position[1] ) ); - - // normal - const core::vector3df nA( quake3::getMD3Normal ( vA.normal[0], vA.normal[1] )); - const core::vector3df nB( quake3::getMD3Normal ( vB.normal[0], vB.normal[1] )); - - v.Normal.X = nA.X + interpolate * ( nB.X - nA.X ); - v.Normal.Y = nA.Z + interpolate * ( nB.Z - nA.Z ); - v.Normal.Z = nA.Y + interpolate * ( nB.Y - nA.Y ); - } - - dest->recalculateBoundingBox (); -} - - -//! build final mesh's tag from frames frameA and frameB with linear interpolation. -void CAnimatedMeshMD3::buildTagArray ( u32 frameA, u32 frameB, f32 interpolate ) -{ - const u32 frameOffsetA = frameA * Mesh->MD3Header.numTags; - const u32 frameOffsetB = frameB * Mesh->MD3Header.numTags; - - for ( s32 i = 0; i != Mesh->MD3Header.numTags; ++i ) - { - SMD3QuaternionTag &d = TagListIPol [ i ]; - - const SMD3QuaternionTag &qA = Mesh->TagList[ frameOffsetA + i]; - const SMD3QuaternionTag &qB = Mesh->TagList[ frameOffsetB + i]; - - // rotation - d.rotation.slerp( qA.rotation, qB.rotation, interpolate ); - - // position - d.position.X = qA.position.X + interpolate * ( qB.position.X - qA.position.X ); - d.position.Y = qA.position.Y + interpolate * ( qB.position.Y - qA.position.Y ); - d.position.Z = qA.position.Z + interpolate * ( qB.position.Z - qA.position.Z ); - } -} - - -/*! - loads a model -*/ -bool CAnimatedMeshMD3::loadModelFile( u32 modelIndex, io::IReadFile* file, - io::IFileSystem* fs, video::IVideoDriver * driver) -{ - if (!file) - return false; - - //! Check MD3Header - { - file->read( &Mesh->MD3Header, sizeof(SMD3Header) ); - - if ( strncmp("IDP3", Mesh->MD3Header.headerID, 4) ) - { - os::Printer::log("MD3 Loader: invalid header"); - return false; - } - } - - //! store model name - Mesh->Name = file->getFileName(); - - u32 i; - - //! Frame Data ( ignore ) -#if 0 - SMD3Frame frameImport; - file->seek ( Mesh->MD3Header.frameStart ); - for (i = 0; i != Mesh->MD3Header.numFrames; ++i ) - { - file->read(&frameImport, sizeof(frameImport) ); - } -#endif - - //! Tag Data - const u32 totalTags = Mesh->MD3Header.numTags * Mesh->MD3Header.numFrames; - - SMD3Tag import; - - file->seek( Mesh->MD3Header.tagStart ); - Mesh->TagList.set_used ( totalTags ); - for (i = 0; i != totalTags; ++i ) - { - file->read(&import, sizeof(import) ); - - SMD3QuaternionTag &exp = Mesh->TagList[i]; - - //! tag name - exp.Name = import.Name; - - //! position - exp.position.X = import.position[0]; - exp.position.Y = import.position[2]; - exp.position.Z = import.position[1]; - - //! construct quaternion from a RH 3x3 Matrix - exp.rotation.set (import.rotationMatrix[7], - 0.f, - -import.rotationMatrix[6], - 1 + import.rotationMatrix[8]); - exp.rotation.normalize (); - } - - //! Meshes - u32 offset = Mesh->MD3Header.tagEnd; - - for (i = 0; i != (u32)Mesh->MD3Header.numMeshes; ++i ) - { - //! construct a new mesh buffer - SMD3MeshBuffer * buf = new SMD3MeshBuffer (); - - // !read mesh header info - SMD3MeshHeader &meshHeader = buf->MeshHeader; - - //! read mesh info - file->seek( offset ); - file->read( &meshHeader, sizeof(SMD3MeshHeader) ); - - //! prepare memory - buf->Vertices.set_used ( meshHeader.numVertices * Mesh->MD3Header.numFrames ); - buf->Indices.set_used ( meshHeader.numTriangles * 3 ); - buf->Tex.set_used ( meshHeader.numVertices ); - - //! read skins (shaders). should be 1 per meshbuffer - SMD3Shader skin; - file->seek( offset + buf->MeshHeader.offset_shaders ); - for ( s32 g = 0; g != buf->MeshHeader.numShader; ++g ) - { - file->read( &skin, sizeof(skin) ); - - core::stringc name; - cutFilenameExtension ( name, skin.name ); - name.replace ( '\\', '/' ); - buf->Shader = name; - } - - //! read texture coordinates - file->seek( offset + buf->MeshHeader.offset_st); - file->read( buf->Tex.pointer(), buf->MeshHeader.numVertices * sizeof(SMD3TexCoord) ); - - //! read vertices - file->seek(offset + meshHeader.vertexStart); - file->read( buf->Vertices.pointer(), Mesh->MD3Header.numFrames * meshHeader.numVertices * sizeof(SMD3Vertex) ); - - //! read indices - file->seek( offset + meshHeader.offset_triangles ); - file->read( buf->Indices.pointer(), meshHeader.numTriangles * sizeof(SMD3Face) ); - - //! store meshBuffer - Mesh->Buffer.push_back ( buf ); - - offset += meshHeader.offset_end; - } - - // Init Mesh Interpolation - for ( i = 0; i != Mesh->Buffer.size (); ++i ) - { - IMeshBuffer * buffer = createMeshBuffer ( Mesh->Buffer[i], fs, driver ); - MeshIPol.addMeshBuffer ( buffer ); - buffer->drop (); - } - MeshIPol.recalculateBoundingBox (); - - // Init Tag Interpolation - for (i = 0; i != (u32)Mesh->MD3Header.numTags; ++i ) - { - TagListIPol.push_back ( Mesh->TagList[i] ); - } - - return true; -} - - -SMD3Mesh * CAnimatedMeshMD3::getOriginalMesh () -{ - return Mesh; -} - - -//! Returns an axis aligned bounding box -const core::aabbox3d<f32>& CAnimatedMeshMD3::getBoundingBox() const -{ - return MeshIPol.BoundingBox; -} - - -//! Returns the type of the animated mesh. -E_ANIMATED_MESH_TYPE CAnimatedMeshMD3::getMeshType() const -{ - return EAMT_MD3; -} - - -} // end namespace scene -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_MD3_LOADER_ - diff --git a/irrlicht-1.6/source/Irrlicht/CAnimatedMeshMD3.h b/irrlicht-1.6/source/Irrlicht/CAnimatedMeshMD3.h deleted file mode 100644 index f5a74bd01..000000000 --- a/irrlicht-1.6/source/Irrlicht/CAnimatedMeshMD3.h +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_ANIMATED_MESH_MD3_H_INCLUDED__ -#define __C_ANIMATED_MESH_MD3_H_INCLUDED__ - -#include "IAnimatedMeshMD3.h" -#include "IReadFile.h" -#include "IFileSystem.h" -#include "irrArray.h" -#include "irrString.h" -#include "SMesh.h" -#include "SMeshBuffer.h" -#include "IQ3Shader.h" - -namespace irr -{ -namespace scene -{ - - class CAnimatedMeshMD3 : public IAnimatedMeshMD3 - { - public: - - //! constructor - CAnimatedMeshMD3( ); - - //! destructor - virtual ~CAnimatedMeshMD3(); - - //! loads a quake3 md3 file - virtual bool loadModelFile( u32 modelIndex, io::IReadFile* file, - io::IFileSystem* fs, video::IVideoDriver * driver - ); - - // IAnimatedMeshMD3 - virtual void setInterpolationShift ( u32 shift, u32 loopMode ); - virtual SMD3Mesh * getOriginalMesh (); - virtual SMD3QuaternionTagList *getTagList(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop); - - //IAnimatedMesh - virtual u32 getFrameCount() const; - virtual IMesh* getMesh(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop); - virtual const core::aabbox3d<f32>& getBoundingBox() const; - virtual E_ANIMATED_MESH_TYPE getMeshType() const; - - //! returns amount of mesh buffers. - virtual u32 getMeshBufferCount() const - { - return 0; - } - - //! returns pointer to a mesh buffer - virtual IMeshBuffer* getMeshBuffer(u32 nr) const - { - return 0; - } - - //! Returns pointer to a mesh buffer which fits a material - /** \param material: material to search for - \return Returns the pointer to the mesh buffer or - NULL if there is no such mesh buffer. */ - virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const - { - return 0; - } - - virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue) - { - return; - } - - //! set the hardware mapping hint, for driver - virtual void setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX); - - //! flags the meshbuffer as changed, reloads hardware buffers - virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX); - - //! set user axis aligned bounding box - virtual void setBoundingBox(const core::aabbox3df& box) - { - return; - } - - - private: - //! animates one frame - inline void Animate (u32 frame); - - video::SMaterial Material; - - //! hold original compressed MD3 Info - SMD3Mesh *Mesh; - - u32 IPolShift; - u32 LoopMode; - f32 Scaling; - - //! Cache Info - struct SCacheInfo - { - SCacheInfo ( s32 frame = -1, s32 start = -1, s32 end = -1 ) - : Frame ( frame ), startFrameLoop ( start ), - endFrameLoop ( end ) {} - - bool operator == ( const SCacheInfo &other ) const - { - return 0 == memcmp ( this, &other, sizeof ( SCacheInfo ) ); - } - s32 Frame; - s32 startFrameLoop; - s32 endFrameLoop; - }; - SCacheInfo Current; - - //! return a Mesh per frame - SMesh MeshIPol; - SMD3QuaternionTagList TagListIPol; - - IMeshBuffer * createMeshBuffer ( const SMD3MeshBuffer *source, io::IFileSystem* fs, video::IVideoDriver * driver ); - - void buildVertexArray ( u32 frameA, u32 frameB, f32 interpolate, - const SMD3MeshBuffer * source, - SMeshBufferLightMap * dest - ); - - void buildTagArray ( u32 frameA, u32 frameB, f32 interpolate ); - }; - - -} // end namespace scene -} // end namespace irr - -#endif diff --git a/irrlicht-1.6/source/Irrlicht/CAnimatedMeshSceneNode.cpp b/irrlicht-1.6/source/Irrlicht/CAnimatedMeshSceneNode.cpp deleted file mode 100644 index 35c9ecb04..000000000 --- a/irrlicht-1.6/source/Irrlicht/CAnimatedMeshSceneNode.cpp +++ /dev/null @@ -1,1092 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CAnimatedMeshSceneNode.h" -#include "IVideoDriver.h" -#include "ISceneManager.h" -#include "S3DVertex.h" -#include "os.h" -#include "CShadowVolumeSceneNode.h" -#include "IAnimatedMeshMD3.h" -#include "CSkinnedMesh.h" -#include "IDummyTransformationSceneNode.h" -#include "IBoneSceneNode.h" -#include "IMaterialRenderer.h" -#include "IMesh.h" -#include "IMeshCache.h" -#include "IAnimatedMesh.h" -#include "quaternion.h" - - -namespace irr -{ -namespace scene -{ - - -//! constructor -CAnimatedMeshSceneNode::CAnimatedMeshSceneNode(IAnimatedMesh* mesh, - ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position, - const core::vector3df& rotation, - const core::vector3df& scale) -: IAnimatedMeshSceneNode(parent, mgr, id, position, rotation, scale), Mesh(0), - BeginFrameTime(0), StartFrame(0), EndFrame(0), FramesPerSecond(0.f), - CurrentFrameNr(0.f), LastTimeMs(0), - TransitionTime(0), Transiting(0.f), TransitingBlend(0.f), - JointMode(EJUOR_NONE), JointsUsed(false), - Looping(true), ReadOnlyMaterials(false), RenderFromIdentity(0), - LoopCallBack(0), PassCount(0), Shadow(0), - MD3Special ( 0 ) -{ - #ifdef _DEBUG - setDebugName("CAnimatedMeshSceneNode"); - #endif - - BeginFrameTime = os::Timer::getTime(); - FramesPerSecond = 25.f/1000.f; - - setMesh(mesh); -} - - -//! destructor -CAnimatedMeshSceneNode::~CAnimatedMeshSceneNode() -{ - if (MD3Special) - MD3Special->drop (); - - if (Mesh) - Mesh->drop(); - - if (Shadow) - Shadow->drop(); - - //for (u32 i=0; i<JointChildSceneNodes.size(); ++i) - // if (JointChildSceneNodes[i]) - // JointChildSceneNodes[i]->drop(); - - if (LoopCallBack) - LoopCallBack->drop(); -} - - -//! Sets the current frame. From now on the animation is played from this frame. -void CAnimatedMeshSceneNode::setCurrentFrame(f32 frame) -{ - // if you pass an out of range value, we just clamp it - CurrentFrameNr = core::clamp ( frame, (f32)StartFrame, (f32)EndFrame ); - - BeginFrameTime = os::Timer::getTime(); - if (FramesPerSecond > 0) - BeginFrameTime += (s32)((CurrentFrameNr - StartFrame) / FramesPerSecond); - else if (FramesPerSecond < 0) - BeginFrameTime += (s32)((CurrentFrameNr - EndFrame) / -FramesPerSecond); - - beginTransition(); //transit to this frame if enabled -} - - -//! Returns the currently displayed frame number. -f32 CAnimatedMeshSceneNode::getFrameNr() const -{ - return CurrentFrameNr; -} - - -void CAnimatedMeshSceneNode::buildFrameNr(u32 timeMs) -{ - if (Transiting!=0.f) - { - TransitingBlend += (f32)(timeMs) * Transiting; - if (TransitingBlend > 1.f) - { - Transiting=0.f; - TransitingBlend=0.f; - } - } - - if ((StartFrame==EndFrame)) - { - CurrentFrameNr = (f32)StartFrame; //Support for non animated meshes - } - else if (Looping) - { - // play animation looped - CurrentFrameNr += timeMs * FramesPerSecond; - if (FramesPerSecond > 0.f) //forwards... - { - if (CurrentFrameNr > EndFrame) - CurrentFrameNr -= (EndFrame-StartFrame); - } - else //backwards... - { - if (CurrentFrameNr < StartFrame) - CurrentFrameNr += (EndFrame-StartFrame); - } - } - else - { - // play animation non looped - - CurrentFrameNr += timeMs * FramesPerSecond; - if (FramesPerSecond > 0.f) //forwards... - { - if (CurrentFrameNr > (f32)EndFrame) - { - CurrentFrameNr = (f32)EndFrame; - if (LoopCallBack) - LoopCallBack->OnAnimationEnd(this); - } - } - else //backwards... - { - if (CurrentFrameNr < (f32)StartFrame) - { - CurrentFrameNr = (f32)StartFrame; - if (LoopCallBack) - LoopCallBack->OnAnimationEnd(this); - } - } - } -} - - -void CAnimatedMeshSceneNode::OnRegisterSceneNode() -{ - if (IsVisible) - { - // because this node supports rendering of mixed mode meshes consisting of - // transparent and solid material at the same time, we need to go through all - // materials, check of what type they are and register this node for the right - // render pass according to that. - - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - - PassCount = 0; - int transparentCount = 0; - int solidCount = 0; - - // count transparent and solid materials in this scene node - for (u32 i=0; i<Materials.size(); ++i) - { - video::IMaterialRenderer* rnd = - driver->getMaterialRenderer(Materials[i].MaterialType); - - if (rnd && rnd->isTransparent()) - ++transparentCount; - else - ++solidCount; - - if (solidCount && transparentCount) - break; - } - - // register according to material types counted - - if (solidCount) - SceneManager->registerNodeForRendering(this, scene::ESNRP_SOLID); - - if (transparentCount) - SceneManager->registerNodeForRendering(this, scene::ESNRP_TRANSPARENT); - - ISceneNode::OnRegisterSceneNode(); - } -} - -IMesh * CAnimatedMeshSceneNode::getMeshForCurrentFrame(bool forceRecalcOfControlJoints) -{ - if(Mesh->getMeshType() != EAMT_SKINNED) - { - return Mesh->getMesh((s32)getFrameNr(), 255, StartFrame, EndFrame); - } - else - { - // As multiple scene nodes may be sharing the same skinned mesh, we have to - // re-animated it every frame to ensure that this node gets the mesh that it needs. - - CSkinnedMesh* skinnedMesh = reinterpret_cast<CSkinnedMesh*>(Mesh); - - if (JointMode == EJUOR_CONTROL)//write to mesh - skinnedMesh->transferJointsToMesh(JointChildSceneNodes); - else - skinnedMesh->animateMesh(getFrameNr(), 1.0f); - - // Update the skinned mesh for the current joint transforms. - skinnedMesh->skinMesh(); - - if (JointMode == EJUOR_READ)//read from mesh - { - skinnedMesh->recoverJointsFromMesh(JointChildSceneNodes); - - //---slow--- - for (u32 n=0;n<JointChildSceneNodes.size();++n) - if (JointChildSceneNodes[n]->getParent()==this) - { - JointChildSceneNodes[n]->updateAbsolutePositionOfAllChildren(); //temp, should be an option - } - } - - if(JointMode == EJUOR_CONTROL) - { - // For meshes other than EJUOR_CONTROL, this is done by calling animateMesh() - skinnedMesh->updateBoundingBox(); - } - - return skinnedMesh; - } -} - - -//! OnAnimate() is called just before rendering the whole scene. -void CAnimatedMeshSceneNode::OnAnimate(u32 timeMs) -{ - buildFrameNr(timeMs-LastTimeMs); - - if (Mesh) - { - scene::IMesh * mesh = getMeshForCurrentFrame( true ); - - if (mesh) - Box = mesh->getBoundingBox(); - } - LastTimeMs = timeMs; - - IAnimatedMeshSceneNode::OnAnimate ( timeMs ); -} - - -//! renders the node. -void CAnimatedMeshSceneNode::render() -{ - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - - if (!Mesh || !driver) - return; - - - bool isTransparentPass = - SceneManager->getSceneNodeRenderPass() == scene::ESNRP_TRANSPARENT; - - ++PassCount; - - scene::IMesh* m = getMeshForCurrentFrame( false ); - - if(m) - { - Box = m->getBoundingBox(); - } - else - { - #ifdef _DEBUG - os::Printer::log("Animated Mesh returned no mesh to render.", Mesh->getDebugName(), ELL_WARNING); - #endif - } - - driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); - - - if (Shadow && PassCount==1) - Shadow->updateShadowVolumes(); - - // for debug purposes only: - - bool renderMeshes = true; - video::SMaterial mat; - if (DebugDataVisible && PassCount==1) - { - // overwrite half transparency - if (DebugDataVisible & scene::EDS_HALF_TRANSPARENCY) - { - - for (u32 i=0; i<m->getMeshBufferCount(); ++i) - { - scene::IMeshBuffer* mb = m->getMeshBuffer(i); - mat = ReadOnlyMaterials ? mb->getMaterial() : Materials[i]; - mat.MaterialType = video::EMT_TRANSPARENT_ADD_COLOR; - if (RenderFromIdentity) - driver->setTransform(video::ETS_WORLD, core::IdentityMatrix ); - else if (Mesh->getMeshType() == EAMT_SKINNED) - driver->setTransform(video::ETS_WORLD, AbsoluteTransformation * ((SSkinMeshBuffer*)mb)->Transformation); - - driver->setMaterial(mat); - driver->drawMeshBuffer(mb); - } - renderMeshes = false; - } - } - - // render original meshes - if (renderMeshes) - { - for (u32 i=0; i<m->getMeshBufferCount(); ++i) - { - video::IMaterialRenderer* rnd = driver->getMaterialRenderer(Materials[i].MaterialType); - bool transparent = (rnd && rnd->isTransparent()); - - // only render transparent buffer if this is the transparent render pass - // and solid only in solid pass - if (transparent == isTransparentPass) - { - scene::IMeshBuffer* mb = m->getMeshBuffer(i); - const video::SMaterial& material = ReadOnlyMaterials ? mb->getMaterial() : Materials[i]; - if (RenderFromIdentity) - driver->setTransform(video::ETS_WORLD, core::IdentityMatrix ); - else if (Mesh->getMeshType() == EAMT_SKINNED) - driver->setTransform(video::ETS_WORLD, AbsoluteTransformation * ((SSkinMeshBuffer*)mb)->Transformation); - - driver->setMaterial(material); - driver->drawMeshBuffer(mb); - } - } - } - - driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); - - // for debug purposes only: - if (DebugDataVisible && PassCount==1) - { - video::SMaterial debug_mat; - debug_mat.Lighting = false; - driver->setMaterial(debug_mat); - // show normals - if (DebugDataVisible & scene::EDS_NORMALS) - { - core::vector3df normalizedNormal; - const f32 DebugNormalLength = SceneManager->getParameters()->getAttributeAsFloat(DEBUG_NORMAL_LENGTH); - const video::SColor DebugNormalColor = SceneManager->getParameters()->getAttributeAsColor(DEBUG_NORMAL_COLOR); - - // draw normals - for (u32 g=0; g < m->getMeshBufferCount(); ++g) - { - const scene::IMeshBuffer* mb = m->getMeshBuffer(g); - const u32 vSize = video::getVertexPitchFromType(mb->getVertexType()); - const video::S3DVertex* v = ( const video::S3DVertex*)mb->getVertices(); - const bool normalize = mb->getMaterial().NormalizeNormals; - - for (u32 i=0; i != mb->getVertexCount(); ++i) - { - normalizedNormal = v->Normal; - if (normalize) - normalizedNormal.normalize(); - - driver->draw3DLine(v->Pos, v->Pos + (normalizedNormal * DebugNormalLength), DebugNormalColor); - - v = (const video::S3DVertex*) ( (u8*) v+vSize ); - } - } - driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); - } - - debug_mat.ZBuffer = video::ECFN_NEVER; - debug_mat.Lighting = false; - driver->setMaterial(debug_mat); - - if (DebugDataVisible & scene::EDS_BBOX) - driver->draw3DBox(Box, video::SColor(255,255,255,255)); - - // show bounding box - if (DebugDataVisible & scene::EDS_BBOX_BUFFERS) - { - - for (u32 g=0; g< m->getMeshBufferCount(); ++g) - { - const IMeshBuffer* mb = m->getMeshBuffer(g); - - if (Mesh->getMeshType() == EAMT_SKINNED) - driver->setTransform(video::ETS_WORLD, AbsoluteTransformation * ((SSkinMeshBuffer*)mb)->Transformation); - driver->draw3DBox( mb->getBoundingBox(), - video::SColor(255,190,128,128) ); - } - } - - // show skeleton - if (DebugDataVisible & scene::EDS_SKELETON) - { - if (Mesh->getMeshType() == EAMT_SKINNED) - { - // draw skeleton - - for (u32 g=0; g < ((ISkinnedMesh*)Mesh)->getAllJoints().size(); ++g) - { - ISkinnedMesh::SJoint *joint=((ISkinnedMesh*)Mesh)->getAllJoints()[g]; - - for (u32 n=0;n<joint->Children.size();++n) - { - driver->draw3DLine(joint->GlobalAnimatedMatrix.getTranslation(), - joint->Children[n]->GlobalAnimatedMatrix.getTranslation(), - video::SColor(255,51,66,255)); - } - } - } - - // show tag for quake3 models - if (Mesh->getMeshType() == EAMT_MD3) - { - IAnimatedMesh * arrow = - SceneManager->addArrowMesh ( - "__tag_show", - 0xFF0000FF, 0xFF000088, - 4, 8, 5.f, 4.f, 0.5f, - 1.f); - if (!arrow) - { - arrow = SceneManager->getMesh ( "__tag_show" ); - } - IMesh *arrowMesh = arrow->getMesh(0); - - core::matrix4 matr; - - SMD3QuaternionTagList *taglist = ((IAnimatedMeshMD3*)Mesh)->getTagList( - (s32)getFrameNr(), 255, - getStartFrame(), getEndFrame()); - if (taglist) - { - for ( u32 ts = 0; ts != taglist->size(); ++ts ) - { - (*taglist)[ts].setto(matr); - - driver->setTransform(video::ETS_WORLD, matr ); - - for ( u32 a = 0; a != arrowMesh->getMeshBufferCount(); ++a ) - driver->drawMeshBuffer(arrowMesh->getMeshBuffer(a)); - } - } - } - } - - // show mesh - if (DebugDataVisible & scene::EDS_MESH_WIRE_OVERLAY) - { - debug_mat.Lighting = false; - debug_mat.Wireframe = true; - debug_mat.ZBuffer = video::ECFN_NEVER; - driver->setMaterial(debug_mat); - - for (u32 g=0; g<m->getMeshBufferCount(); ++g) - { - const IMeshBuffer* mb = m->getMeshBuffer(g); - if (RenderFromIdentity) - driver->setTransform(video::ETS_WORLD, core::IdentityMatrix ); - else if (Mesh->getMeshType() == EAMT_SKINNED) - driver->setTransform(video::ETS_WORLD, AbsoluteTransformation * ((SSkinMeshBuffer*)mb)->Transformation); - driver->drawMeshBuffer(mb); - } - } - } -} - - -//! Returns the current start frame number. -s32 CAnimatedMeshSceneNode::getStartFrame() const -{ - return StartFrame; -} - - -//! Returns the current start frame number. -s32 CAnimatedMeshSceneNode::getEndFrame() const -{ - return EndFrame; -} - - -//! sets the frames between the animation is looped. -//! the default is 0 - MaximalFrameCount of the mesh. -bool CAnimatedMeshSceneNode::setFrameLoop(s32 begin, s32 end) -{ - const s32 maxFrameCount = Mesh->getFrameCount() - 1; - if (end < begin) - { - StartFrame = core::s32_clamp(end, 0, maxFrameCount); - EndFrame = core::s32_clamp(begin, StartFrame, maxFrameCount); - } - else - { - StartFrame = core::s32_clamp(begin, 0, maxFrameCount); - EndFrame = core::s32_clamp(end, StartFrame, maxFrameCount); - } - if (FramesPerSecond < 0) - setCurrentFrame((f32)EndFrame); - else - setCurrentFrame((f32)StartFrame); - - return true; -} - - -//! sets the speed with witch the animation is played -void CAnimatedMeshSceneNode::setAnimationSpeed(f32 framesPerSecond) -{ - FramesPerSecond = framesPerSecond * 0.001f; -} - - -//! returns the axis aligned bounding box of this node -const core::aabbox3d<f32>& CAnimatedMeshSceneNode::getBoundingBox() const -{ - return Box; -} - - -//! returns the material based on the zero based index i. To get the amount -//! of materials used by this scene node, use getMaterialCount(). -//! This function is needed for inserting the node into the scene hirachy on a -//! optimal position for minimizing renderstate changes, but can also be used -//! to directly modify the material of a scene node. -video::SMaterial& CAnimatedMeshSceneNode::getMaterial(u32 i) -{ - if (i >= Materials.size()) - return ISceneNode::getMaterial(i); - - return Materials[i]; -} - - - -//! returns amount of materials used by this scene node. -u32 CAnimatedMeshSceneNode::getMaterialCount() const -{ - return Materials.size(); -} - - -//! Creates shadow volume scene node as child of this node -//! and returns a pointer to it. -IShadowVolumeSceneNode* CAnimatedMeshSceneNode::addShadowVolumeSceneNode(const IMesh* shadowMesh, - s32 id, bool zfailmethod, f32 infinity) -{ - if (!SceneManager->getVideoDriver()->queryFeature(video::EVDF_STENCIL_BUFFER)) - return 0; - - if (Shadow) - { - os::Printer::log("This node already has a shadow.", ELL_WARNING); - return 0; - } - - if (!shadowMesh) - shadowMesh = Mesh; // if null is given, use the mesh of node - - Shadow = new CShadowVolumeSceneNode(shadowMesh, this, SceneManager, id, zfailmethod, infinity); - return Shadow; -} - - -//! Returns a pointer to a child node, which has the same transformation as -//! the corresponding joint, if the mesh in this scene node is a skinned mesh. -IBoneSceneNode* CAnimatedMeshSceneNode::getJointNode(const c8* jointName) -{ - if (!Mesh || Mesh->getMeshType() != EAMT_SKINNED) - { - os::Printer::log("No mesh, or mesh not of skinned mesh type", ELL_WARNING); - return 0; - } - - checkJoints(); - - ISkinnedMesh *skinnedMesh=(ISkinnedMesh*)Mesh; - - const s32 number = skinnedMesh->getJointNumber(jointName); - - if (number == -1) - { - os::Printer::log("Joint with specified name not found in skinned mesh.", jointName, ELL_WARNING); - return 0; - } - - if ((s32)JointChildSceneNodes.size() <= number) - { - os::Printer::log("Joint was found in mesh, but is not loaded into node", jointName, ELL_WARNING); - return 0; - } - - return getJointNode((u32)number); -} - - -//! Returns a pointer to a child node, which has the same transformation as -//! the corresponding joint, if the mesh in this scene node is a skinned mesh. -IBoneSceneNode* CAnimatedMeshSceneNode::getJointNode(u32 jointID) -{ - if (!Mesh || Mesh->getMeshType() != EAMT_SKINNED) - { - os::Printer::log("No mesh, or mesh not of skinned mesh type", ELL_WARNING); - return 0; - } - - checkJoints(); - - if (JointChildSceneNodes.size() <= jointID) - { - os::Printer::log("Joint not loaded into node", ELL_WARNING); - return 0; - } - - return JointChildSceneNodes[jointID]; -} - -//! Gets joint count. -u32 CAnimatedMeshSceneNode::getJointCount() const -{ - if (!Mesh || Mesh->getMeshType() != EAMT_SKINNED) - return 0; - - ISkinnedMesh *skinnedMesh=(ISkinnedMesh*)Mesh; - - return skinnedMesh->getJointCount(); -} - - -//! Returns a pointer to a child node, which has the same transformation as -//! the corresponding joint, if the mesh in this scene node is a ms3d mesh. -ISceneNode* CAnimatedMeshSceneNode::getMS3DJointNode(const c8* jointName) -{ - return getJointNode(jointName); -} - - -//! Returns a pointer to a child node, which has the same transformation as -//! the corresponding joint, if the mesh in this scene node is a .x mesh. -ISceneNode* CAnimatedMeshSceneNode::getXJointNode(const c8* jointName) -{ - return getJointNode(jointName); -} - - -//! Removes a child from this scene node. -//! Implemented here, to be able to remove the shadow properly, if there is one, -//! or to remove attached childs. -bool CAnimatedMeshSceneNode::removeChild(ISceneNode* child) -{ - if (child && Shadow == child) - { - Shadow->drop(); - Shadow = 0; - } - - if (ISceneNode::removeChild(child)) - { - if (JointsUsed) //stop weird bugs caused while changing parents as the joints are being created - { - for (u32 i=0; i<JointChildSceneNodes.size(); ++i) - if (JointChildSceneNodes[i] == child) - { - JointChildSceneNodes[i] = 0; //remove link to child - return true; - } - } - return true; - } - - return false; -} - - -//! Starts a MD2 animation. -bool CAnimatedMeshSceneNode::setMD2Animation(EMD2_ANIMATION_TYPE anim) -{ - if (!Mesh || Mesh->getMeshType() != EAMT_MD2) - return false; - - IAnimatedMeshMD2* md = (IAnimatedMeshMD2*)Mesh; - - s32 begin, end, speed; - md->getFrameLoop(anim, begin, end, speed); - - setAnimationSpeed( f32(speed) ); - setFrameLoop(begin, end); - return true; -} - - -//! Starts a special MD2 animation. -bool CAnimatedMeshSceneNode::setMD2Animation(const c8* animationName) -{ - if (!Mesh || Mesh->getMeshType() != EAMT_MD2) - return false; - - IAnimatedMeshMD2* md = (IAnimatedMeshMD2*)Mesh; - - s32 begin, end, speed; - if (!md->getFrameLoop(animationName, begin, end, speed)) - return false; - - setAnimationSpeed( (f32)speed ); - setFrameLoop(begin, end); - return true; -} - - -//! Sets looping mode which is on by default. If set to false, -//! animations will not be looped. -void CAnimatedMeshSceneNode::setLoopMode(bool playAnimationLooped) -{ - Looping = playAnimationLooped; -} - - -//! Sets a callback interface which will be called if an animation -//! playback has ended. Set this to 0 to disable the callback again. -void CAnimatedMeshSceneNode::setAnimationEndCallback(IAnimationEndCallBack* callback) -{ - if (callback == LoopCallBack) - return; - - if (LoopCallBack) - LoopCallBack->drop(); - - LoopCallBack = callback; - - if (LoopCallBack) - LoopCallBack->grab(); -} - - -//! Sets if the scene node should not copy the materials of the mesh but use them in a read only style. -void CAnimatedMeshSceneNode::setReadOnlyMaterials(bool readonly) -{ - ReadOnlyMaterials = readonly; -} - - -//! Returns if the scene node should not copy the materials of the mesh but use them in a read only style -bool CAnimatedMeshSceneNode::isReadOnlyMaterials() const -{ - return ReadOnlyMaterials; -} - - -//! Writes attributes of the scene node. -void CAnimatedMeshSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const -{ - IAnimatedMeshSceneNode::serializeAttributes(out, options); - - out->addString("Mesh", SceneManager->getMeshCache()->getMeshFilename(Mesh).c_str()); - out->addBool("Looping", Looping); - out->addBool("ReadOnlyMaterials", ReadOnlyMaterials); - out->addFloat("FramesPerSecond", FramesPerSecond); - - // TODO: write animation names instead of frame begin and ends -} - - -//! Reads attributes of the scene node. -void CAnimatedMeshSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - IAnimatedMeshSceneNode::deserializeAttributes(in, options); - - io::path oldMeshStr = SceneManager->getMeshCache()->getMeshFilename(Mesh); - io::path newMeshStr = in->getAttributeAsString("Mesh"); - - Looping = in->getAttributeAsBool("Looping"); - ReadOnlyMaterials = in->getAttributeAsBool("ReadOnlyMaterials"); - FramesPerSecond = in->getAttributeAsFloat("FramesPerSecond"); - - if (newMeshStr != "" && oldMeshStr != newMeshStr) - { - IAnimatedMesh* newAnimatedMesh = SceneManager->getMesh(newMeshStr.c_str()); - - if (newAnimatedMesh) - setMesh(newAnimatedMesh); - } - - // TODO: read animation names instead of frame begin and ends -} - - -//! Sets a new mesh -void CAnimatedMeshSceneNode::setMesh(IAnimatedMesh* mesh) -{ - if (!mesh) - return; // won't set null mesh - - if (Mesh != mesh) - { - if (Mesh) - Mesh->drop(); - - Mesh = mesh; - - // grab the mesh (it's non-null!) - Mesh->grab(); - } - - // get materials and bounding box - Box = Mesh->getBoundingBox(); - - IMesh* m = Mesh->getMesh(0,0); - if (m) - { - Materials.clear(); - Materials.reallocate(m->getMeshBufferCount()); - - for (u32 i=0; i<m->getMeshBufferCount(); ++i) - { - IMeshBuffer* mb = m->getMeshBuffer(i); - if (mb) - Materials.push_back(mb->getMaterial()); - else - Materials.push_back(video::SMaterial()); - } - } - - // get start and begin time - setFrameLoop ( 0, Mesh->getFrameCount() ); -} - - -// returns the absolute transformation for a special MD3 Tag if the mesh is a md3 mesh, -// or the absolutetransformation if it's a normal scenenode -const SMD3QuaternionTag* CAnimatedMeshSceneNode::getMD3TagTransformation( const core::stringc & tagname) -{ - return MD3Special ? MD3Special->AbsoluteTagList.get ( tagname ) : 0; -} - - -//! updates the absolute position based on the relative and the parents position -void CAnimatedMeshSceneNode::updateAbsolutePosition() -{ - IAnimatedMeshSceneNode::updateAbsolutePosition(); - - if (!Mesh || Mesh->getMeshType() != EAMT_MD3) - return; - - SMD3QuaternionTagList *taglist; - taglist = ( (IAnimatedMeshMD3*) Mesh )->getTagList ( (s32)getFrameNr(),255,getStartFrame (),getEndFrame () ); - if (taglist) - { - if (!MD3Special) - { - MD3Special = new SMD3Special(); - } - - SMD3QuaternionTag parent ( MD3Special->Tagname ); - if (Parent && Parent->getType() == ESNT_ANIMATED_MESH) - { - const SMD3QuaternionTag * p = ((IAnimatedMeshSceneNode*) Parent)->getMD3TagTransformation - ( MD3Special->Tagname ); - - if (p) - parent = *p; - } - - SMD3QuaternionTag relative( RelativeTranslation, RelativeRotation ); - - MD3Special->AbsoluteTagList.set_used ( taglist->size () ); - for ( u32 i=0; i!= taglist->size (); ++i ) - { - MD3Special->AbsoluteTagList[i].position = parent.position + (*taglist)[i].position + relative.position; - MD3Special->AbsoluteTagList[i].rotation = parent.rotation * (*taglist)[i].rotation * relative.rotation; - } - } -} - - -//! Set the joint update mode (0-unused, 1-get joints only, 2-set joints only, 3-move and set) -void CAnimatedMeshSceneNode::setJointMode(E_JOINT_UPDATE_ON_RENDER mode) -{ - checkJoints(); - - //if (mode<0) mode=0; - //if (mode>3) mode=3; - - JointMode=mode; -} - - -//! Sets the transition time in seconds (note: This needs to enable joints, and setJointmode maybe set to 2) -//! you must call animateJoints(), or the mesh will not animate -void CAnimatedMeshSceneNode::setTransitionTime(f32 time) -{ - if (time != 0.0f) - { - checkJoints(); - setJointMode(EJUOR_CONTROL); - TransitionTime = (u32)core::floor32(time*1000.0f); - } -} - - -//! render mesh ignoring its transformation. Used with ragdolls. (culling is unaffected) -void CAnimatedMeshSceneNode::setRenderFromIdentity( bool On ) -{ - RenderFromIdentity=On; -} - - -//! updates the joint positions of this mesh -void CAnimatedMeshSceneNode::animateJoints(bool CalculateAbsolutePositions) -{ - checkJoints(); - - if (Mesh && Mesh->getMeshType() == EAMT_SKINNED ) - { - if (JointsUsed) - { - f32 frame = getFrameNr(); //old? - - CSkinnedMesh* skinnedMesh=reinterpret_cast<CSkinnedMesh*>(Mesh); - - skinnedMesh->transferOnlyJointsHintsToMesh( JointChildSceneNodes ); - - skinnedMesh->animateMesh(frame, 1.0f); - - skinnedMesh->recoverJointsFromMesh( JointChildSceneNodes); - - //----------------------------------------- - // Transition - //----------------------------------------- - - if (Transiting != 0.f) - { - //Check the array is big enough (not really needed) - if (PretransitingSave.size()<JointChildSceneNodes.size()) - { - for(u32 n=PretransitingSave.size(); n<JointChildSceneNodes.size(); ++n) - PretransitingSave.push_back(core::matrix4()); - } - - for (u32 n=0; n<JointChildSceneNodes.size(); ++n) - { - //------Position------ - - JointChildSceneNodes[n]->setPosition( - core::lerp( - PretransitingSave[n].getTranslation(), - JointChildSceneNodes[n]->getPosition(), - TransitingBlend)); - - //------Rotation------ - - //Code is slow, needs to be fixed up - - const core::quaternion RotationStart(PretransitingSave[n].getRotationDegrees()*core::DEGTORAD); - const core::quaternion RotationEnd(JointChildSceneNodes[n]->getRotation()*core::DEGTORAD); - - core::quaternion QRotation; - QRotation.slerp(RotationStart, RotationEnd, TransitingBlend); - - core::vector3df tmpVector; - QRotation.toEuler(tmpVector); - tmpVector*=core::RADTODEG; //convert from radians back to degrees - JointChildSceneNodes[n]->setRotation( tmpVector ); - - //------Scale------ - - //JointChildSceneNodes[n]->setScale( - // core::lerp( - // PretransitingSave[n].getScale(), - // JointChildSceneNodes[n]->getScale(), - // TransitingBlend)); - } - } - - if (CalculateAbsolutePositions) - { - //---slow--- - for (u32 n=0;n<JointChildSceneNodes.size();++n) - { - if (JointChildSceneNodes[n]->getParent()==this) - { - JointChildSceneNodes[n]->updateAbsolutePositionOfAllChildren(); //temp, should be an option - } - } - } - } - } -} - - -/*! -*/ -void CAnimatedMeshSceneNode::checkJoints() -{ - if (!Mesh || Mesh->getMeshType() != EAMT_SKINNED) - return; - - if (!JointsUsed) - { - //Create joints for SkinnedMesh - - ((CSkinnedMesh*)Mesh)->createJoints(JointChildSceneNodes, this, SceneManager); - ((CSkinnedMesh*)Mesh)->recoverJointsFromMesh(JointChildSceneNodes); - - JointsUsed=true; - JointMode=EJUOR_READ; - } -} - - -/*! -*/ -void CAnimatedMeshSceneNode::beginTransition() -{ - if (!JointsUsed) - return; - - if (TransitionTime != 0) - { - //Check the array is big enough - if (PretransitingSave.size()<JointChildSceneNodes.size()) - { - for(u32 n=PretransitingSave.size(); n<JointChildSceneNodes.size(); ++n) - PretransitingSave.push_back(core::matrix4()); - } - - - //Copy the position of joints - for (u32 n=0;n<JointChildSceneNodes.size();++n) - PretransitingSave[n]=JointChildSceneNodes[n]->getRelativeTransformation(); - - Transiting = core::reciprocal((f32)TransitionTime); - } - TransitingBlend = 0.f; -} - - -/*! -*/ -ISceneNode* CAnimatedMeshSceneNode::clone(ISceneNode* newParent, ISceneManager* newManager) -{ - if (!newParent) newParent = Parent; - if (!newManager) newManager = SceneManager; - - CAnimatedMeshSceneNode * newNode = - new CAnimatedMeshSceneNode(Mesh, newParent, newManager, ID, RelativeTranslation, - RelativeRotation, RelativeScale); - - newNode->cloneMembers(this, newManager); - - newNode->Materials = Materials; - newNode->Box = Box; - newNode->Mesh = Mesh; - newNode->BeginFrameTime = BeginFrameTime; - newNode->StartFrame = StartFrame; - newNode->EndFrame = EndFrame; - newNode->FramesPerSecond = FramesPerSecond; - newNode->CurrentFrameNr = CurrentFrameNr; - newNode->JointMode = JointMode; - newNode->JointsUsed = JointsUsed; - newNode->TransitionTime = TransitionTime; - newNode->Transiting = Transiting; - newNode->TransitingBlend = TransitingBlend; - newNode->Looping = Looping; - newNode->ReadOnlyMaterials = ReadOnlyMaterials; - newNode->LoopCallBack = LoopCallBack; - newNode->PassCount = PassCount; - newNode->Shadow = Shadow; - newNode->JointChildSceneNodes = JointChildSceneNodes; - newNode->PretransitingSave = PretransitingSave; - newNode->RenderFromIdentity = RenderFromIdentity; - newNode->MD3Special = MD3Special; - - (void)newNode->drop(); - return newNode; -} - - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CAnimatedMeshSceneNode.h b/irrlicht-1.6/source/Irrlicht/CAnimatedMeshSceneNode.h deleted file mode 100644 index ec167207f..000000000 --- a/irrlicht-1.6/source/Irrlicht/CAnimatedMeshSceneNode.h +++ /dev/null @@ -1,222 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_ANIMATED_MESH_SCENE_NODE_H_INCLUDED__ -#define __C_ANIMATED_MESH_SCENE_NODE_H_INCLUDED__ - -#include "IAnimatedMeshSceneNode.h" -#include "IAnimatedMesh.h" - -#include "matrix4.h" - - -namespace irr -{ -namespace scene -{ - class IDummyTransformationSceneNode; - - class CAnimatedMeshSceneNode : public IAnimatedMeshSceneNode - { - public: - - //! constructor - CAnimatedMeshSceneNode(IAnimatedMesh* mesh, ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); - - //! destructor - virtual ~CAnimatedMeshSceneNode(); - - //! sets the current frame. from now on the animation is played from this frame. - virtual void setCurrentFrame(f32 frame); - - //! frame - virtual void OnRegisterSceneNode(); - - //! OnAnimate() is called just before rendering the whole scene. - virtual void OnAnimate(u32 timeMs); - - //! renders the node. - virtual void render(); - - //! returns the axis aligned bounding box of this node - virtual const core::aabbox3d<f32>& getBoundingBox() const; - - //! sets the frames between the animation is looped. - //! the default is 0 - MaximalFrameCount of the mesh. - virtual bool setFrameLoop(s32 begin, s32 end); - - //! Sets looping mode which is on by default. If set to false, - //! animations will not be looped. - virtual void setLoopMode(bool playAnimationLooped); - - //! Sets a callback interface which will be called if an animation - //! playback has ended. Set this to 0 to disable the callback again. - virtual void setAnimationEndCallback(IAnimationEndCallBack* callback=0); - - //! sets the speed with witch the animation is played - virtual void setAnimationSpeed(f32 framesPerSecond); - - //! returns the material based on the zero based index i. To get the amount - //! of materials used by this scene node, use getMaterialCount(). - //! This function is needed for inserting the node into the scene hirachy on a - //! optimal position for minimizing renderstate changes, but can also be used - //! to directly modify the material of a scene node. - virtual video::SMaterial& getMaterial(u32 i); - - //! returns amount of materials used by this scene node. - virtual u32 getMaterialCount() const; - - //! Creates shadow volume scene node as child of this node - //! and returns a pointer to it. - virtual IShadowVolumeSceneNode* addShadowVolumeSceneNode(const IMesh* shadowMesh, - s32 id, bool zfailmethod=true, f32 infinity=10000.0f); - - //! Returns a pointer to a child node, which has the same transformation as - //! the corrsesponding joint, if the mesh in this scene node is a skinned mesh. - virtual IBoneSceneNode* getJointNode(const c8* jointName); - - //! same as getJointNode(const c8* jointName), but based on id - virtual IBoneSceneNode* getJointNode(u32 jointID); - - //! Gets joint count. - virtual u32 getJointCount() const; - - //! Redundant command, please use getJointNode. - virtual ISceneNode* getMS3DJointNode(const c8* jointName); - - //! Redundant command, please use getJointNode. - virtual ISceneNode* getXJointNode(const c8* jointName); - - //! Removes a child from this scene node. - //! Implemented here, to be able to remove the shadow properly, if there is one, - //! or to remove attached childs. - virtual bool removeChild(ISceneNode* child); - - //! Starts a MD2 animation. - virtual bool setMD2Animation(EMD2_ANIMATION_TYPE anim); - - //! Starts a special MD2 animation. - virtual bool setMD2Animation(const c8* animationName); - - //! Returns the current displayed frame number. - virtual f32 getFrameNr() const; - //! Returns the current start frame number. - virtual s32 getStartFrame() const; - //! Returns the current end frame number. - virtual s32 getEndFrame() const; - - //! Sets if the scene node should not copy the materials of the mesh but use them in a read only style. - /* In this way it is possible to change the materials a mesh causing all mesh scene nodes - referencing this mesh to change too. */ - virtual void setReadOnlyMaterials(bool readonly); - - //! Returns if the scene node should not copy the materials of the mesh but use them in a read only style - virtual bool isReadOnlyMaterials() const; - - //! Sets a new mesh - virtual void setMesh(IAnimatedMesh* mesh); - - //! Returns the current mesh - virtual IAnimatedMesh* getMesh(void) { return Mesh; } - - //! Writes attributes of the scene node. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const; - - //! Reads attributes of the scene node. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() const { return ESNT_ANIMATED_MESH; } - - // returns the absolute transformation for a special MD3 Tag if the mesh is a md3 mesh, - // or the absolutetransformation if it's a normal scenenode - const SMD3QuaternionTag* getMD3TagTransformation( const core::stringc & tagname); - - //! updates the absolute position based on the relative and the parents position - virtual void updateAbsolutePosition(); - - - //! Set the joint update mode (0-unused, 1-get joints only, 2-set joints only, 3-move and set) - virtual void setJointMode(E_JOINT_UPDATE_ON_RENDER mode); - - //! Sets the transition time in seconds (note: This needs to enable joints, and setJointmode maybe set to 2) - //! you must call animateJoints(), or the mesh will not animate - virtual void setTransitionTime(f32 Time); - - //! updates the joint positions of this mesh - virtual void animateJoints(bool CalculateAbsolutePositions=true); - - //! render mesh ignoring its transformation. Used with ragdolls. (culling is unaffected) - virtual void setRenderFromIdentity( bool On ); - - //! Creates a clone of this scene node and its children. - /** \param newParent An optional new parent. - \param newManager An optional new scene manager. - \return The newly created clone of this node. */ - virtual ISceneNode* clone(ISceneNode* newParent=0, ISceneManager* newManager=0); - - private: - - //! Get a static mesh for the current frame of this animated mesh - IMesh* getMeshForCurrentFrame(bool forceRecalcOfControlJoints); - - void buildFrameNr(u32 timeMs); - void checkJoints(); - void beginTransition(); - - core::array<video::SMaterial> Materials; - core::aabbox3d<f32> Box; - IAnimatedMesh* Mesh; - - u32 BeginFrameTime; - s32 StartFrame; - s32 EndFrame; - f32 FramesPerSecond; - f32 CurrentFrameNr; - - u32 LastTimeMs; - u32 TransitionTime; //Transition time in millisecs - f32 Transiting; //is mesh transiting (plus cache of TransitionTime) - f32 TransitingBlend; //0-1, calculated on buildFrameNr - - //0-unused, 1-get joints only, 2-set joints only, 3-move and set - E_JOINT_UPDATE_ON_RENDER JointMode; - bool JointsUsed; - - bool Looping; - bool ReadOnlyMaterials; - bool RenderFromIdentity; - - IAnimationEndCallBack* LoopCallBack; - s32 PassCount; - - IShadowVolumeSceneNode* Shadow; - - core::array<IBoneSceneNode* > JointChildSceneNodes; - core::array<core::matrix4> PretransitingSave; - - // Quake3 Model - struct SMD3Special : public virtual IReferenceCounted - { - core::stringc Tagname; - SMD3QuaternionTagList AbsoluteTagList; - - SMD3Special & operator = (const SMD3Special & copyMe) - { - Tagname = copyMe.Tagname; - AbsoluteTagList = copyMe.AbsoluteTagList; - return *this; - } - }; - SMD3Special *MD3Special; - }; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CAttributeImpl.h b/irrlicht-1.6/source/Irrlicht/CAttributeImpl.h deleted file mode 100644 index 53409b30a..000000000 --- a/irrlicht-1.6/source/Irrlicht/CAttributeImpl.h +++ /dev/null @@ -1,1976 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CAttributes.h" -#include "fast_atof.h" -#include "ITexture.h" -#include "IVideoDriver.h" - -namespace irr -{ -namespace io -{ - -/* - basic types -*/ - -// Attribute implemented for boolean values -class CBoolAttribute : public IAttribute -{ -public: - - CBoolAttribute(const char* name, bool value) - { - Name = name; - setBool(value); - } - - virtual s32 getInt() - { - return BoolValue ? 1 : 0; - } - - virtual f32 getFloat() - { - return BoolValue ? 1.0f : 0.0f; - } - - virtual bool getBool() - { - return BoolValue; - } - - virtual core::stringw getStringW() - { - return core::stringw( BoolValue ? L"true" : L"false" ); - } - - virtual void setInt(s32 intValue) - { - BoolValue = (intValue != 0); - } - - virtual void setFloat(f32 floatValue) - { - BoolValue = (floatValue != 0); - } - - virtual void setBool(bool boolValue) - { - BoolValue = boolValue; - } - - virtual void setString(const char* string) - { - BoolValue = strcmp(string, "true") == 0; - } - - virtual E_ATTRIBUTE_TYPE getType() const - { - return EAT_BOOL; - } - - virtual const wchar_t* getTypeString() const - { - return L"bool"; - } - - bool BoolValue; -}; - -// Attribute implemented for integers -class CIntAttribute : public IAttribute -{ -public: - - CIntAttribute(const char* name, s32 value) - { - Name = name; - setInt(value); - } - - virtual s32 getInt() - { - return Value; - } - - virtual f32 getFloat() - { - return (f32)Value; - } - - virtual bool getBool() - { - return (Value != 0); - } - - virtual core::stringw getStringW() - { - return core::stringw(Value); - } - - virtual void setInt(s32 intValue) - { - Value = intValue; - } - - virtual void setFloat(f32 floatValue) - { - Value = (s32)floatValue; - }; - - virtual void setString(const char* text) - { - Value = atoi(text); - } - - virtual E_ATTRIBUTE_TYPE getType() const - { - return EAT_INT; - } - - - virtual const wchar_t* getTypeString() const - { - return L"int"; - } - - s32 Value; -}; - -// Attribute implemented for floats -class CFloatAttribute : public IAttribute -{ -public: - - CFloatAttribute(const char* name, f32 value) - { - Name = name; - setFloat(value); - } - - virtual s32 getInt() - { - return (s32)Value; - } - - virtual f32 getFloat() - { - return Value; - } - - virtual bool getBool() - { - return (Value != 0); - } - - virtual core::stringw getStringW() - { - return core::stringw(Value); - } - - virtual void setInt(s32 intValue) - { - Value = (f32)intValue; - } - - virtual void setFloat(f32 floatValue) - { - Value = floatValue; - } - - virtual void setString(const char* text) - { - Value = core::fast_atof(text); - } - - virtual E_ATTRIBUTE_TYPE getType() const - { - return EAT_FLOAT; - } - - - virtual const wchar_t* getTypeString() const - { - return L"float"; - } - - f32 Value; -}; - - - -/* - Types which can be represented as a list of numbers -*/ - -// Base class for all attributes which are a list of numbers- -// vectors, colors, positions, triangles, etc -class CNumbersAttribute : public IAttribute -{ -public: - - CNumbersAttribute(const char* name, video::SColorf value) : - ValueI(), ValueF(), Count(4), IsFloat(true) - { - Name = name; - ValueF.push_back(value.r); - ValueF.push_back(value.g); - ValueF.push_back(value.b); - ValueF.push_back(value.a); - } - - CNumbersAttribute(const char* name, video::SColor value) : - ValueI(), ValueF(), Count(4), IsFloat(false) - { - Name = name; - ValueI.push_back(value.getRed()); - ValueI.push_back(value.getGreen()); - ValueI.push_back(value.getBlue()); - ValueI.push_back(value.getAlpha()); - } - - - CNumbersAttribute(const char* name, core::vector3df value) : - ValueI(), ValueF(), Count(3), IsFloat(true) - { - Name = name; - ValueF.push_back(value.X); - ValueF.push_back(value.Y); - ValueF.push_back(value.Z); - } - - CNumbersAttribute(const char* name, core::rect<s32> value) : - ValueI(), ValueF(), Count(4), IsFloat(false) - { - Name = name; - ValueI.push_back(value.UpperLeftCorner.X); - ValueI.push_back(value.UpperLeftCorner.Y); - ValueI.push_back(value.LowerRightCorner.X); - ValueI.push_back(value.LowerRightCorner.Y); - } - - CNumbersAttribute(const char* name, core::rect<f32> value) : - ValueI(), ValueF(), Count(4), IsFloat(true) - { - Name = name; - ValueF.push_back(value.UpperLeftCorner.X); - ValueF.push_back(value.UpperLeftCorner.Y); - ValueF.push_back(value.LowerRightCorner.X); - ValueF.push_back(value.LowerRightCorner.Y); - } - - CNumbersAttribute(const char* name, core::matrix4 value) : - ValueI(), ValueF(), Count(16), IsFloat(true) - { - Name = name; - for (s32 r=0; r<4; ++r) - for (s32 c=0; c<4; ++c) - ValueF.push_back(value(r,c)); - } - - CNumbersAttribute(const char* name, core::quaternion value) : - ValueI(), ValueF(), Count(4), IsFloat(true) - { - Name = name; - ValueF.push_back(value.X); - ValueF.push_back(value.Y); - ValueF.push_back(value.Z); - ValueF.push_back(value.W); - } - - CNumbersAttribute(const char* name, core::aabbox3d<f32> value) : - ValueI(), ValueF(), Count(6), IsFloat(true) - { - Name = name; - ValueF.push_back(value.MinEdge.X); - ValueF.push_back(value.MinEdge.Y); - ValueF.push_back(value.MinEdge.Z); - ValueF.push_back(value.MaxEdge.X); - ValueF.push_back(value.MaxEdge.Y); - ValueF.push_back(value.MaxEdge.Z); - } - - CNumbersAttribute(const char* name, core::plane3df value) : - ValueI(), ValueF(), Count(4), IsFloat(true) - { - Name = name; - ValueF.push_back(value.Normal.X); - ValueF.push_back(value.Normal.Y); - ValueF.push_back(value.Normal.Z); - ValueF.push_back(value.D); - } - - CNumbersAttribute(const char* name, core::triangle3df value) : - ValueI(), ValueF(), Count(9), IsFloat(true) - { - Name = name; - ValueF.push_back(value.pointA.X); - ValueF.push_back(value.pointA.Y); - ValueF.push_back(value.pointA.Z); - ValueF.push_back(value.pointB.X); - ValueF.push_back(value.pointB.Y); - ValueF.push_back(value.pointB.Z); - ValueF.push_back(value.pointC.X); - ValueF.push_back(value.pointC.Y); - ValueF.push_back(value.pointC.Z); - } - - CNumbersAttribute(const char* name, core::vector2df value) : - ValueI(), ValueF(), Count(2), IsFloat(true) - { - Name = name; - ValueF.push_back(value.X); - ValueF.push_back(value.Y); - } - - CNumbersAttribute(const char* name, core::vector2di value) : - ValueI(), ValueF(), Count(2), IsFloat(false) - { - Name = name; - ValueI.push_back(value.X); - ValueI.push_back(value.Y); - } - - CNumbersAttribute(const char* name, core::line2di value) : - ValueI(), ValueF(), Count(4), IsFloat(false) - { - Name = name; - ValueI.push_back(value.start.X); - ValueI.push_back(value.start.Y); - ValueI.push_back(value.end.X); - ValueI.push_back(value.end.Y); - } - - CNumbersAttribute(const char* name, core::line2df value) : - ValueI(), ValueF(), Count(4), IsFloat(true) - { - Name = name; - ValueF.push_back(value.start.X); - ValueF.push_back(value.start.Y); - ValueF.push_back(value.end.X); - ValueF.push_back(value.end.Y); - } - - CNumbersAttribute(const char* name, core::line3df value) : - ValueI(), ValueF(), Count(6), IsFloat(true) - { - Name = name; - ValueF.push_back(value.start.X); - ValueF.push_back(value.start.Y); - ValueF.push_back(value.start.Z); - ValueF.push_back(value.end.X); - ValueF.push_back(value.end.Y); - ValueF.push_back(value.end.Z); - } - - CNumbersAttribute(const char* name, core::dimension2du value) : - ValueI(), ValueF(), Count(2), IsFloat(false) - { - Name = name; - ValueI.push_back(value.Width); - ValueI.push_back(value.Height); - } - - - CNumbersAttribute(const char* name, core::dimension2df value) : - ValueI(), ValueF(), Count(2), IsFloat(true) - { - Name = name; - ValueF.push_back(value.Width); - ValueF.push_back(value.Height); - } - - - - // getting values - virtual s32 getInt() - { - if (Count==0) - return 0; - - if (IsFloat) - return (s32)ValueF[0]; - else - return ValueI[0]; - } - - virtual f32 getFloat() - { - if (Count==0) - return 0.0f; - - if (IsFloat) - return ValueF[0]; - else - return (f32)ValueI[0]; - } - - virtual bool getBool() - { - // return true if any number is nonzero - bool ret=false; - - for (u32 i=0; i < Count; ++i) - if ( IsFloat ? (ValueF[i] != 0) : (ValueI[i] != 0) ) - { - ret=true; - break; - } - - return ret; - - } - - - virtual core::stringc getString() - { - core::stringc outstr; - - for (u32 i=0; i <Count; ++i) - { - if (IsFloat) - outstr += ValueF[i]; - else - outstr += ValueI[i]; - - if (i < Count-1) - outstr += ", "; - } - return outstr; - } - virtual core::stringw getStringW() - { - core::stringw outstr; - - for (u32 i=0; i <Count; ++i) - { - if (IsFloat) - outstr += ValueF[i]; - else - outstr += ValueI[i]; - - if (i < Count-1) - outstr += L", "; - } - return outstr; - } - - virtual core::position2di getPosition() - { - core::position2di p; - - if (IsFloat) - { - p.X = (s32)(Count > 0 ? ValueF[0] : 0); - p.Y = (s32)(Count > 1 ? ValueF[1] : 0); - } - else - { - p.X = Count > 0 ? ValueI[0] : 0; - p.Y = Count > 1 ? ValueI[1] : 0; - } - - return p; - } - - virtual core::vector3df getVector() - { - core::vector3df v; - - if (IsFloat) - { - v.X = Count > 0 ? ValueF[0] : 0; - v.Y = Count > 1 ? ValueF[1] : 0; - v.Z = Count > 2 ? ValueF[2] : 0; - } - else - { - v.X = (f32)(Count > 0 ? ValueI[0] : 0); - v.Y = (f32)(Count > 1 ? ValueI[1] : 0); - v.Z = (f32)(Count > 2 ? ValueI[2] : 0); - } - - return v; - } - - virtual video::SColorf getColorf() - { - video::SColorf c; - if (IsFloat) - { - c.setColorComponentValue(0, Count > 0 ? ValueF[0] : 0); - c.setColorComponentValue(1, Count > 1 ? ValueF[1] : 0); - c.setColorComponentValue(2, Count > 2 ? ValueF[2] : 0); - c.setColorComponentValue(3, Count > 3 ? ValueF[3] : 0); - } - else - { - c.setColorComponentValue(0, Count > 0 ? (f32)(ValueI[0]) / 255.0f : 0); - c.setColorComponentValue(1, Count > 1 ? (f32)(ValueI[1]) / 255.0f : 0); - c.setColorComponentValue(2, Count > 2 ? (f32)(ValueI[2]) / 255.0f : 0); - c.setColorComponentValue(3, Count > 3 ? (f32)(ValueI[3]) / 255.0f : 0); - } - - return c; - } - - virtual video::SColor getColor() - { - return getColorf().toSColor(); - } - - - virtual core::rect<s32> getRect() - { - core::rect<s32> r; - - if (IsFloat) - { - r.UpperLeftCorner.X = (s32)(Count > 0 ? ValueF[0] : 0); - r.UpperLeftCorner.Y = (s32)(Count > 1 ? ValueF[1] : 0); - r.LowerRightCorner.X = (s32)(Count > 2 ? ValueF[2] : r.UpperLeftCorner.X); - r.LowerRightCorner.Y = (s32)(Count > 3 ? ValueF[3] : r.UpperLeftCorner.Y); - } - else - { - r.UpperLeftCorner.X = Count > 0 ? ValueI[0] : 0; - r.UpperLeftCorner.Y = Count > 1 ? ValueI[1] : 0; - r.LowerRightCorner.X = Count > 2 ? ValueI[2] : r.UpperLeftCorner.X; - r.LowerRightCorner.Y = Count > 3 ? ValueI[3] : r.UpperLeftCorner.Y; - } - return r; - } - - virtual core::matrix4 getMatrix() - { - core::matrix4 ret; - if (IsFloat) - { - for (u32 r=0; r<4; ++r) - for (u32 c=0; c<4; ++c) - if (Count > c+r*4) - ret(r,c) = ValueF[c+r*4]; - } - else - { - for (u32 r=0; r<4; ++r) - for (u32 c=0; c<4; ++c) - if (Count > c+r*4) - ret(r,c) = (f32)ValueI[c+r*4]; - } - return ret; - } - - virtual core::quaternion getQuaternion() - { - core::quaternion ret; - if (IsFloat) - { - ret.X = Count > 0 ? ValueF[0] : 0.0f; - ret.Y = Count > 1 ? ValueF[1] : 0.0f; - ret.Z = Count > 2 ? ValueF[2] : 0.0f; - ret.W = Count > 3 ? ValueF[3] : 0.0f; - } - else - { - ret.X = Count > 0 ? (f32)ValueI[0] : 0.0f; - ret.Y = Count > 1 ? (f32)ValueI[1] : 0.0f; - ret.Z = Count > 2 ? (f32)ValueI[2] : 0.0f; - ret.W = Count > 3 ? (f32)ValueI[3] : 0.0f; - } - return ret; - } - - virtual core::triangle3df getTriangle() - { - core::triangle3df ret; - - if (IsFloat) - { - ret.pointA.X = Count > 0 ? ValueF[0] : 0.0f; - ret.pointA.Y = Count > 1 ? ValueF[1] : 0.0f; - ret.pointA.Z = Count > 2 ? ValueF[2] : 0.0f; - ret.pointB.X = Count > 3 ? ValueF[3] : 0.0f; - ret.pointB.Y = Count > 4 ? ValueF[4] : 0.0f; - ret.pointB.Z = Count > 5 ? ValueF[5] : 0.0f; - ret.pointC.X = Count > 6 ? ValueF[6] : 0.0f; - ret.pointC.Y = Count > 7 ? ValueF[7] : 0.0f; - ret.pointC.Z = Count > 8 ? ValueF[8] : 0.0f; - } - else - { - ret.pointA.X = Count > 0 ? (f32)ValueI[0] : 0.0f; - ret.pointA.Y = Count > 1 ? (f32)ValueI[1] : 0.0f; - ret.pointA.Z = Count > 2 ? (f32)ValueI[2] : 0.0f; - ret.pointB.X = Count > 3 ? (f32)ValueI[3] : 0.0f; - ret.pointB.Y = Count > 4 ? (f32)ValueI[4] : 0.0f; - ret.pointB.Z = Count > 5 ? (f32)ValueI[5] : 0.0f; - ret.pointC.X = Count > 6 ? (f32)ValueI[6] : 0.0f; - ret.pointC.Y = Count > 7 ? (f32)ValueI[7] : 0.0f; - ret.pointC.Z = Count > 8 ? (f32)ValueI[8] : 0.0f; - } - - return ret; - } - - virtual core::plane3df getPlane() - { - core::plane3df ret; - - if (IsFloat) - { - ret.Normal.X = Count > 0 ? ValueF[0] : 0.0f; - ret.Normal.Y = Count > 1 ? ValueF[1] : 0.0f; - ret.Normal.Z = Count > 2 ? ValueF[2] : 0.0f; - ret.D = Count > 3 ? ValueF[3] : 0.0f; - } - else - { - ret.Normal.X = Count > 0 ? (f32)ValueI[0] : 0.0f; - ret.Normal.Y = Count > 1 ? (f32)ValueI[1] : 0.0f; - ret.Normal.Z = Count > 2 ? (f32)ValueI[2] : 0.0f; - ret.D = Count > 3 ? (f32)ValueI[3] : 0.0f; - } - - return ret; - } - - virtual core::aabbox3df getBBox() - { - core::aabbox3df ret; - if (IsFloat) - { - ret.MinEdge.X = Count > 0 ? ValueF[0] : 0.0f; - ret.MinEdge.Y = Count > 1 ? ValueF[1] : 0.0f; - ret.MinEdge.Z = Count > 2 ? ValueF[2] : 0.0f; - ret.MaxEdge.X = Count > 3 ? ValueF[3] : 0.0f; - ret.MaxEdge.Y = Count > 4 ? ValueF[4] : 0.0f; - ret.MaxEdge.Z = Count > 5 ? ValueF[5] : 0.0f; - } - else - { - ret.MinEdge.X = Count > 0 ? (f32)ValueI[0] : 0.0f; - ret.MinEdge.Y = Count > 1 ? (f32)ValueI[1] : 0.0f; - ret.MinEdge.Z = Count > 2 ? (f32)ValueI[2] : 0.0f; - ret.MaxEdge.X = Count > 3 ? (f32)ValueI[3] : 0.0f; - ret.MaxEdge.Y = Count > 4 ? (f32)ValueI[4] : 0.0f; - ret.MaxEdge.Z = Count > 5 ? (f32)ValueI[5] : 0.0f; - } - return ret; - - } - - virtual core::line2df getLine2d() - { - core::line2df ret; - if (IsFloat) - { - ret.start.X = Count > 0 ? ValueF[0] : 0.0f; - ret.start.Y = Count > 1 ? ValueF[1] : 0.0f; - ret.end.X = Count > 2 ? ValueF[2] : 0.0f; - ret.end.Y = Count > 3 ? ValueF[3] : 0.0f; - } - else - { - ret.start.X = Count > 0 ? (f32)ValueI[0] : 0.0f; - ret.start.Y = Count > 1 ? (f32)ValueI[1] : 0.0f; - ret.end.X = Count > 2 ? (f32)ValueI[2] : 0.0f; - ret.end.Y = Count > 3 ? (f32)ValueI[3] : 0.0f; - } - return ret; - } - - virtual core::line3df getLine3d() - { - core::line3df ret; - if (IsFloat) - { - ret.start.X = Count > 0 ? ValueF[0] : 0.0f; - ret.start.Y = Count > 1 ? ValueF[1] : 0.0f; - ret.start.Z = Count > 2 ? ValueF[2] : 0.0f; - ret.end.X = Count > 3 ? ValueF[3] : 0.0f; - ret.end.Y = Count > 4 ? ValueF[4] : 0.0f; - ret.end.Z = Count > 5 ? ValueF[5] : 0.0f; - } - else - { - ret.start.X = Count > 0 ? (f32)ValueI[0] : 0.0f; - ret.start.Y = Count > 1 ? (f32)ValueI[1] : 0.0f; - ret.start.Z = Count > 2 ? (f32)ValueI[2] : 0.0f; - ret.end.X = Count > 3 ? (f32)ValueI[3] : 0.0f; - ret.end.Y = Count > 4 ? (f32)ValueI[4] : 0.0f; - ret.end.Z = Count > 5 ? (f32)ValueI[5] : 0.0f; - } - return ret; - } - - //! get float array - virtual core::array<f32> getFloatArray() - { - if (!IsFloat) - { - ValueF.clear(); - for (u32 i=0; i<Count; ++i) - ValueF.push_back( (f32) ValueI[i] ); - } - return ValueF; - } - - //! get int array - virtual core::array<s32> getIntArray() - { - if (IsFloat) - { - ValueI.clear(); - for (u32 i=0; i<Count; ++i) - ValueI.push_back( (s32) ValueF[i] ); - } - return ValueI; - } - - - // setting values - virtual void setInt(s32 intValue) - { - // set all values - for (u32 i=0; i < Count; ++i) - if (IsFloat) - ValueF[i] = (f32)intValue; - else - ValueI[i] = intValue; - } - - virtual void setFloat(f32 floatValue) - { - // set all values - for (u32 i=0; i < Count; ++i) - if (IsFloat) - ValueF[i] = floatValue; - else - ValueI[i] = (s32)floatValue; - } - - virtual void setBool(bool boolValue) - { - setInt( boolValue ? 1 : 0); - } - - virtual void setString(const char* text) - { - // parse text - - const char* P = (const char*)text; - - reset(); - - u32 i=0; - - for ( i=0; i<Count && *P; ++i ) - { - while(*P && P[0]!='-' && ( P[0]==' ' || (P[0] < '0' || P[0] > '9') ) ) - ++P; - - // set value - if ( *P) - { - if (IsFloat) - { - f32 c = 0; - P = core::fast_atof_move(P, c); - ValueF[i] = c; - } - else - { - // todo: fix this to read ints properly - f32 c = 0; - P = core::fast_atof_move(P, c); - ValueI[i] = (s32)c; - - } - } - } - // todo: warning message - //if (i < Count-1) - //{ - // - //} - } - - virtual void setPosition(core::position2di v) - { - reset(); - if (IsFloat) - { - if (Count > 0) ValueF[0] = (f32)v.X; - if (Count > 1) ValueF[1] = (f32)v.Y; - } - else - { - if (Count > 0) ValueI[0] = v.X; - if (Count > 1) ValueI[1] = v.Y; - } - } - - virtual void setVector(core::vector3df v) - { - reset(); - if (IsFloat) - { - if (Count > 0) ValueF[0] = v.X; - if (Count > 1) ValueF[1] = v.Y; - if (Count > 2) ValueF[2] = v.Z; - } - else - { - if (Count > 0) ValueI[0] = (s32)v.X; - if (Count > 1) ValueI[1] = (s32)v.Y; - if (Count > 2) ValueI[2] = (s32)v.Z; - } - } - - virtual void setColor(video::SColorf color) - { - reset(); - if (IsFloat) - { - if (Count > 0) ValueF[0] = color.r; - if (Count > 1) ValueF[1] = color.g; - if (Count > 2) ValueF[2] = color.b; - if (Count > 3) ValueF[3] = color.a; - } - else - { - if (Count > 0) ValueI[0] = (s32)(color.r * 255); - if (Count > 1) ValueI[1] = (s32)(color.g * 255); - if (Count > 2) ValueI[2] = (s32)(color.b * 255); - if (Count > 3) ValueI[3] = (s32)(color.a * 255); - } - - } - - virtual void setColor(video::SColor color) - { - reset(); - if (IsFloat) - { - if (Count > 0) ValueF[0] = (f32)color.getRed() / 255.0f; - if (Count > 1) ValueF[1] = (f32)color.getGreen() / 255.0f; - if (Count > 2) ValueF[2] = (f32)color.getBlue() / 255.0f; - if (Count > 3) ValueF[3] = (f32)color.getAlpha() / 255.0f; - } - else - { - if (Count > 0) ValueI[0] = color.getRed(); - if (Count > 1) ValueI[1] = color.getGreen(); - if (Count > 2) ValueI[2] = color.getBlue(); - if (Count > 3) ValueI[3] = color.getAlpha(); - } - } - - virtual void setRect(core::rect<s32> value) - { - reset(); - if (IsFloat) - { - if (Count > 0) ValueF[0] = (f32)value.UpperLeftCorner.X; - if (Count > 1) ValueF[1] = (f32)value.UpperLeftCorner.Y; - if (Count > 2) ValueF[2] = (f32)value.LowerRightCorner.X; - if (Count > 3) ValueF[3] = (f32)value.LowerRightCorner.Y; - } - else - { - if (Count > 0) ValueI[0] = value.UpperLeftCorner.X; - if (Count > 1) ValueI[1] = value.UpperLeftCorner.Y; - if (Count > 2) ValueI[2] = value.LowerRightCorner.X; - if (Count > 3) ValueI[3] = value.LowerRightCorner.Y; - } - } - - virtual void setMatrix(core::matrix4 value) - { - reset(); - if (IsFloat) - { - for (u32 r=0; r<4; ++r) - for (u32 c=0; c<4; ++c) - if (Count > c+r*4) - ValueF[c+r*4] = value(r,c); - } - else - { - for (u32 r=0; r<4; ++r) - for (u32 c=0; c<4; ++c) - if (Count > c+r*4) - ValueI[c+r*4] = (s32)value(r,c); - } - } - - virtual void setQuaternion(core::quaternion value) - { - reset(); - if (IsFloat) - { - if (Count > 0) ValueF[0] = value.X; - if (Count > 1) ValueF[1] = value.Y; - if (Count > 2) ValueF[2] = value.Z; - if (Count > 3) ValueF[3] = value.W; - } - else - { - if (Count > 0) ValueI[0] = (s32)value.X; - if (Count > 1) ValueI[1] = (s32)value.Y; - if (Count > 2) ValueI[2] = (s32)value.Z; - if (Count > 3) ValueI[3] = (s32)value.W; - } - } - - virtual void setBoundingBox(core::aabbox3d<f32> value) - { - reset(); - if (IsFloat) - { - if (Count > 0) ValueF[0] = value.MinEdge.X; - if (Count > 1) ValueF[1] = value.MinEdge.Y; - if (Count > 2) ValueF[2] = value.MinEdge.Z; - if (Count > 3) ValueF[3] = value.MaxEdge.X; - if (Count > 4) ValueF[4] = value.MaxEdge.Y; - if (Count > 5) ValueF[5] = value.MaxEdge.Z; - } - else - { - if (Count > 0) ValueI[0] = (s32)value.MinEdge.X; - if (Count > 1) ValueI[1] = (s32)value.MinEdge.Y; - if (Count > 2) ValueI[2] = (s32)value.MinEdge.Z; - if (Count > 3) ValueI[3] = (s32)value.MaxEdge.X; - if (Count > 4) ValueI[4] = (s32)value.MaxEdge.Y; - if (Count > 5) ValueI[5] = (s32)value.MaxEdge.Z; - } - } - - virtual void setPlane(core::plane3df value) - { - reset(); - if (IsFloat) - { - if (Count > 0) ValueF[0] = value.Normal.X; - if (Count > 1) ValueF[1] = value.Normal.Y; - if (Count > 2) ValueF[2] = value.Normal.Z; - if (Count > 3) ValueF[3] = value.D; - } - else - { - if (Count > 0) ValueI[0] = (s32)value.Normal.X; - if (Count > 1) ValueI[1] = (s32)value.Normal.Y; - if (Count > 2) ValueI[2] = (s32)value.Normal.Z; - if (Count > 3) ValueI[3] = (s32)value.D; - } - } - - virtual void setTriangle3d(core::triangle3df value) - { - reset(); - if (IsFloat) - { - if (Count > 0) ValueF[0] = value.pointA.X; - if (Count > 1) ValueF[1] = value.pointA.Y; - if (Count > 2) ValueF[2] = value.pointA.Z; - if (Count > 3) ValueF[3] = value.pointB.X; - if (Count > 4) ValueF[4] = value.pointB.Y; - if (Count > 5) ValueF[5] = value.pointB.Z; - if (Count > 6) ValueF[6] = value.pointC.X; - if (Count > 7) ValueF[7] = value.pointC.Y; - if (Count > 8) ValueF[8] = value.pointC.Z; - } - else - { - if (Count > 0) ValueI[0] = (s32)value.pointA.X; - if (Count > 1) ValueI[1] = (s32)value.pointA.Y; - if (Count > 2) ValueI[2] = (s32)value.pointA.Z; - if (Count > 3) ValueI[3] = (s32)value.pointB.X; - if (Count > 4) ValueI[4] = (s32)value.pointB.Y; - if (Count > 5) ValueI[5] = (s32)value.pointB.Z; - if (Count > 6) ValueI[6] = (s32)value.pointC.X; - if (Count > 7) ValueI[7] = (s32)value.pointC.Y; - if (Count > 8) ValueI[8] = (s32)value.pointC.Z; - } - } - - virtual void setVector2d(core::vector2df v) - { - reset(); - if (IsFloat) - { - if (Count > 0) ValueF[0] = v.X; - if (Count > 1) ValueF[1] = v.Y; - } - else - { - if (Count > 0) ValueI[0] = (s32)v.X; - if (Count > 1) ValueI[1] = (s32)v.Y; - } - } - - virtual void setVector2d(core::vector2di v) - { - reset(); - if (IsFloat) - { - if (Count > 0) ValueF[0] = (f32)v.X; - if (Count > 1) ValueF[1] = (f32)v.Y; - } - else - { - if (Count > 0) ValueI[0] = v.X; - if (Count > 1) ValueI[1] = v.Y; - } - } - - virtual void setLine2d(core::line2di v) - { - reset(); - if (IsFloat) - { - if (Count > 0) ValueF[0] = (f32)v.start.X; - if (Count > 1) ValueF[1] = (f32)v.start.Y; - if (Count > 2) ValueF[2] = (f32)v.end.X; - if (Count > 3) ValueF[3] = (f32)v.end.Y; - } - else - { - if (Count > 0) ValueI[0] = v.start.X; - if (Count > 1) ValueI[1] = v.start.Y; - if (Count > 2) ValueI[2] = v.end.X; - if (Count > 3) ValueI[3] = v.end.Y; - } - } - - virtual void setLine2d(core::line2df v) - { - reset(); - if (IsFloat) - { - if (Count > 0) ValueF[0] = v.start.X; - if (Count > 1) ValueF[1] = v.start.Y; - if (Count > 2) ValueF[2] = v.end.X; - if (Count > 3) ValueF[3] = v.end.Y; - } - else - { - if (Count > 0) ValueI[0] = (s32)v.start.X; - if (Count > 1) ValueI[1] = (s32)v.start.Y; - if (Count > 2) ValueI[2] = (s32)v.end.X; - if (Count > 3) ValueI[3] = (s32)v.end.Y; - } - } - - virtual void setDimension2d(core::dimension2du v) - { - reset(); - if (IsFloat) - { - if (Count > 0) ValueF[0] = (f32)v.Width; - if (Count > 1) ValueF[1] = (f32)v.Height; - } - else - { - if (Count > 0) ValueI[0] = v.Width; - if (Count > 1) ValueI[1] = v.Height; - } - } - - //! set float array - virtual void setFloatArray(core::array<f32> &vals) - { - reset(); - - for (u32 i=0; i<vals.size() && i<Count; ++i) - { - if (IsFloat) - ValueF[i] = vals[i]; - else - ValueI[i] = (s32)vals[i]; - } - } - - //! set int array - virtual void setIntArray(core::array<s32> &vals) - { - reset(); - - for (u32 i=0; i<vals.size() && i<Count; ++i) - { - if (IsFloat) - ValueF[i] = (f32)vals[i]; - else - ValueI[i] = vals[i]; - } - } - - - //! is it a number list? - virtual bool isNumberList() - { - return true; - } - - //! is it a float list? - virtual bool isFloat() - { - return IsFloat; - } - - virtual E_ATTRIBUTE_TYPE getType() const - { - if (IsFloat) - return EAT_FLOATARRAY; - else - return EAT_INTARRAY; - } - - virtual const wchar_t* getTypeString() const - { - if (IsFloat) - return L"floatlist"; - else - return L"intlist"; - } - -protected: - - //! clear all values - void reset() - { - if (IsFloat) - for (u32 i=0; i < Count ; ++i) - ValueF[i] = 0.0f; - else - for (u32 i=0; i < Count ; ++i) - ValueI[i] = 0; - } - - core::array<s32> ValueI; - core::array<f32> ValueF; - u32 Count; - bool IsFloat; -}; - - -// Attribute implemented for floating point colors -class CColorfAttribute : public CNumbersAttribute -{ -public: - - CColorfAttribute(const char* name, video::SColorf value) : CNumbersAttribute(name, value) {} - - virtual s32 getInt() - { - return getColor().color; - } - - virtual f32 getFloat() - { - return (f32)getColor().color; - } - - virtual void setInt(s32 intValue) - { - video::SColorf c = video::SColor(intValue); - ValueF[0] = c.r; - ValueF[1] = c.g; - ValueF[2] = c.b; - ValueF[3] = c.a; - } - - virtual void setFloat(f32 floatValue) - { - setInt((s32)floatValue); - } - - virtual E_ATTRIBUTE_TYPE getType() const - { - return EAT_COLORF; - } - - virtual const wchar_t* getTypeString() const - { - return L"colorf"; - } -}; - - - -// Attribute implemented for colors -class CColorAttribute : public CNumbersAttribute -{ -public: - - CColorAttribute(const char* name, const video::SColorf& value) : CNumbersAttribute(name, value) {} - - CColorAttribute(const char* name, const video::SColor& value) : CNumbersAttribute(name, value) {} - - virtual s32 getInt() - { - return getColor().color; - } - - virtual f32 getFloat() - { - return (f32)getColor().color; - } - - virtual void setInt(s32 intValue) - { - video::SColorf c = video::SColor(intValue); - ValueF[0] = c.r; - ValueF[1] = c.g; - ValueF[2] = c.b; - ValueF[3] = c.a; - } - - virtual void setFloat(f32 floatValue) - { - setInt((s32)floatValue); - } - - virtual core::stringw getStringW() - { - char tmp[10]; - const video::SColor c = getColor(); - sprintf(tmp, "%02x%02x%02x%02x", c.getAlpha(), c.getRed(), c.getGreen(), c.getBlue()); - return core::stringw(tmp); - } - - virtual void setString(const char* text) - { - u32 c; - if (sscanf(text, "%08x", &c)!=1) - { - CNumbersAttribute::setString(text); - } - else - setColor(c); - } - - virtual E_ATTRIBUTE_TYPE getType() const - { - return EAT_COLOR; - } - - - virtual const wchar_t* getTypeString() const - { - return L"color"; - } - -}; - - -// Attribute implemented for 3d vectors -class CVector3DAttribute : public CNumbersAttribute -{ -public: - - CVector3DAttribute(const char* name, core::vector3df value) : CNumbersAttribute(name, value) {} - - virtual E_ATTRIBUTE_TYPE getType() const - { - return EAT_VECTOR3D; - } - - virtual core::matrix4 getMatrix() - { - core::matrix4 ret; - ret.makeIdentity(); - ret.setTranslation( core::vector3df(ValueF[0],ValueF[1],ValueF[2]) ); - return ret; - } - - virtual const wchar_t* getTypeString() const - { - return L"vector3d"; - } -}; - -// Attribute implemented for 2d vectors -class CPosition2DAttribute : public CNumbersAttribute -{ -public: - - CPosition2DAttribute(const char* name, core::position2di value) : CNumbersAttribute(name, value) {} - - virtual E_ATTRIBUTE_TYPE getType() const - { - return EAT_POSITION2D; - } - - virtual const wchar_t* getTypeString() const - { - return L"position"; - } -}; - - - -// Attribute implemented for rectangles -class CRectAttribute : public CNumbersAttribute -{ -public: - - CRectAttribute(const char* name, core::rect<s32> value) : CNumbersAttribute(name, value) { } - - virtual E_ATTRIBUTE_TYPE getType() const - { - return EAT_RECT; - } - - virtual const wchar_t* getTypeString() const - { - return L"rect"; - } -}; - -// Attribute implemented for matrices -class CMatrixAttribute : public CNumbersAttribute -{ -public: - - CMatrixAttribute(const char* name, core::matrix4 value) : CNumbersAttribute(name, value) { } - - virtual E_ATTRIBUTE_TYPE getType() const - { - return EAT_MATRIX; - } - - virtual core::quaternion getQuaternion() - { - return core::quaternion(getMatrix()); - } - - virtual const wchar_t* getTypeString() const - { - return L"matrix"; - } -}; - -// Attribute implemented for quaternions -class CQuaternionAttribute : public CNumbersAttribute -{ -public: - - CQuaternionAttribute(const char* name, core::quaternion value) : CNumbersAttribute(name, value) { } - - virtual E_ATTRIBUTE_TYPE getType() const - { - return EAT_QUATERNION; - } - - virtual core::matrix4 getMatrix() - { - return getQuaternion().getMatrix(); - } - - virtual const wchar_t* getTypeString() const - { - return L"quaternion"; - } -}; - - -// Attribute implemented for bounding boxes -class CBBoxAttribute : public CNumbersAttribute -{ -public: - - CBBoxAttribute(const char* name, core::aabbox3df value) : CNumbersAttribute(name, value) { } - - virtual E_ATTRIBUTE_TYPE getType() const - { - return EAT_BBOX; - } - - virtual const wchar_t* getTypeString() const - { - return L"box3d"; - } -}; - -// Attribute implemented for planes -class CPlaneAttribute : public CNumbersAttribute -{ -public: - - CPlaneAttribute(const char* name, core::plane3df value) : CNumbersAttribute(name, value) { } - - virtual E_ATTRIBUTE_TYPE getType() const - { - return EAT_PLANE; - } - - virtual const wchar_t* getTypeString() const - { - return L"plane"; - } -}; - -// Attribute implemented for triangles -class CTriangleAttribute : public CNumbersAttribute -{ -public: - - CTriangleAttribute(const char* name, core::triangle3df value) : CNumbersAttribute(name, value) { } - - virtual E_ATTRIBUTE_TYPE getType() const - { - return EAT_TRIANGLE3D; - } - - virtual core::plane3df getPlane() - { - return getTriangle().getPlane(); - } - - virtual const wchar_t* getTypeString() const - { - return L"triangle"; - } -}; - - -// Attribute implemented for 2d lines -class CLine2dAttribute : public CNumbersAttribute -{ -public: - - CLine2dAttribute(const char* name, core::line2df value) : CNumbersAttribute(name, value) { } - - virtual E_ATTRIBUTE_TYPE getType() const - { - return EAT_LINE2D; - } - - virtual const wchar_t* getTypeString() const - { - return L"line2d"; - } -}; - -// Attribute implemented for 3d lines -class CLine3dAttribute : public CNumbersAttribute -{ -public: - - CLine3dAttribute(const char* name, core::line3df value) : CNumbersAttribute(name, value) { } - - virtual E_ATTRIBUTE_TYPE getType() const - { - return EAT_LINE3D; - } - - virtual const wchar_t* getTypeString() const - { - return L"line3d"; - } -}; - - -// vector2df -// dimension2du - -/* - Special attributes -*/ - -// Attribute implemented for enumeration literals -class CEnumAttribute : public IAttribute -{ -public: - - CEnumAttribute(const char* name, const char* value, const char* const* literals) - { - Name = name; - setEnum(value, literals); - } - - virtual void setEnum(const char* enumValue, const char* const* enumerationLiterals) - { - int literalCount = 0; - - if (enumerationLiterals) - { - s32 i; - for (i=0; enumerationLiterals[i]; ++i) - ++literalCount; - - EnumLiterals.reallocate(literalCount); - for (i=0; enumerationLiterals[i]; ++i) - EnumLiterals.push_back(enumerationLiterals[i]); - } - - setString(enumValue); - } - - virtual s32 getInt() - { - for (s32 i=0; EnumLiterals.size(); ++i) - if (Value.equals_ignore_case(EnumLiterals[i])) - { - return i; - } - - return -1; - } - - virtual f32 getFloat() - { - return (f32)getInt(); - } - - virtual bool getBool() - { - return (getInt() != 0); // does not make a lot of sense, I know - } - - virtual core::stringc getString() - { - return Value; - } - - virtual core::stringw getStringW() - { - return core::stringw(Value.c_str()); - } - - virtual void setInt(s32 intValue) - { - if (intValue>=0 && intValue<(s32)EnumLiterals.size()) - Value = EnumLiterals[intValue]; - else - Value = ""; - } - - virtual void setFloat(f32 floatValue) - { - setInt((s32)floatValue); - }; - - virtual void setString(const char* text) - { - Value = text; - } - - virtual const char* getEnum() - { - return Value.c_str(); - } - - virtual E_ATTRIBUTE_TYPE getType() const - { - return EAT_ENUM; - } - - - virtual const wchar_t* getTypeString() const - { - return L"enum"; - } - - core::stringc Value; - core::array<core::stringc> EnumLiterals; -}; - - - - - -// Attribute implemented for strings -class CStringAttribute : public IAttribute -{ -public: - - CStringAttribute(const char* name, const char* value) - { - IsStringW=false; - Name = name; - setString(value); - } - - CStringAttribute(const char* name, const wchar_t* value) - { - IsStringW = true; - Name = name; - setString(value); - } - - CStringAttribute(const char* name, void* binaryData, s32 lenghtInBytes) - { - IsStringW=false; - Name = name; - setBinary(binaryData, lenghtInBytes); - } - - virtual s32 getInt() - { - if (IsStringW) - return atoi(core::stringc(ValueW.c_str()).c_str()); - else - return atoi(Value.c_str()); - } - - virtual f32 getFloat() - { - if (IsStringW) - return core::fast_atof(core::stringc(ValueW.c_str()).c_str()); - else - return core::fast_atof(Value.c_str()); - } - - virtual bool getBool() - { - if (IsStringW) - return Value.equals_ignore_case(L"true"); - else - return Value.equals_ignore_case("true"); - } - - virtual core::stringc getString() - { - if (IsStringW) - return core::stringc(ValueW.c_str()); - else - return Value; - } - virtual core::stringw getStringW() - { - if (IsStringW) - return ValueW; - else - return core::stringw(Value.c_str()); - } - - virtual void setInt(s32 intValue) - { - if (IsStringW) - ValueW = core::stringw(intValue); - else - Value = core::stringc(intValue); - } - - virtual void setFloat(f32 floatValue) - { - if (IsStringW) - { - ValueW = core::stringw(floatValue); - } - else - { - Value = core::stringc(floatValue); - } - }; - - virtual void setString(const char* text) - { - if (IsStringW) - ValueW = core::stringw(text); - else - Value = text; - } - - virtual void setString(const wchar_t* text) - { - if (IsStringW) - ValueW = text; - else - Value = core::stringc(text); - } - - virtual E_ATTRIBUTE_TYPE getType() const - { - return EAT_STRING; - } - - - virtual const wchar_t* getTypeString() const - { - return L"string"; - } - - virtual void getBinary(void* outdata, s32 maxLength) - { - s32 dataSize = maxLength; - c8* datac8 = (c8*)(outdata); - s32 p = 0; - const c8* dataString = Value.c_str(); - - for (s32 i=0; i<dataSize; ++i) - datac8[i] = 0; - - while(dataString[p] && p<dataSize) - { - s32 v = getByteFromHex((c8)dataString[p*2]) * 16; - - if (dataString[(p*2)+1]) - v += getByteFromHex((c8)dataString[(p*2)+1]); - - datac8[p] = v; - ++p; - } - }; - - virtual void setBinary(void* data, s32 maxLength) - { - s32 dataSize = maxLength; - c8* datac8 = (c8*)(data); - char tmp[3]; - tmp[2] = 0; - Value = ""; - - for (s32 b=0; b<dataSize; ++b) - { - getHexStrFromByte(datac8[b], tmp); - Value.append(tmp); - } - }; - - bool IsStringW; - core::stringc Value; - core::stringw ValueW; - -protected: - - static inline s32 getByteFromHex(c8 h) - { - if (h >= '0' && h <='9') - return h-'0'; - - if (h >= 'a' && h <='f') - return h-'a' + 10; - - return 0; - } - - static inline void getHexStrFromByte(c8 byte, c8* out) - { - s32 b = (byte & 0xf0) >> 4; - - for (s32 i=0; i<2; ++i) - { - if (b >=0 && b <= 9) - out[i] = b+'0'; - if (b >=10 && b <= 15) - out[i] = (b-10)+'a'; - - b = byte & 0x0f; - } - } -}; - -// Attribute implemented for binary data -class CBinaryAttribute : public CStringAttribute -{ -public: - - CBinaryAttribute(const char* name, void* binaryData, s32 lenghtInBytes) - : CStringAttribute(name, binaryData, lenghtInBytes) - { - - } - - virtual E_ATTRIBUTE_TYPE getType() const - { - return EAT_BINARY; - } - - - virtual const wchar_t* getTypeString() const - { - return L"binary"; - } -}; - - - -// Attribute implemented for texture references -class CTextureAttribute : public IAttribute -{ -public: - - CTextureAttribute(const char* name, video::ITexture* value, video::IVideoDriver* driver) - : Value(0), Driver(driver) - { - if (Driver) - Driver->grab(); - - Name = name; - setTexture(value); - } - - ~CTextureAttribute() - { - if (Driver) - Driver->drop(); - - if (Value) - Value->drop(); - } - - virtual video::ITexture* getTexture() - { - return Value; - } - - virtual bool getBool() - { - return (Value != 0); - } - - virtual core::stringw getStringW() - { - return core::stringw(Value ? Value->getName().c_str() : 0); - } - - virtual core::stringc getString() - { - // since texture names can be stringw we are careful with the types - return core::stringc(Value ? Value->getName().c_str() : 0); - } - - virtual void setString(const char* text) - { - if (Driver) - { - if (text && *text) - setTexture(Driver->getTexture(text)); - else - setTexture(0); - } - } - - virtual void setTexture(video::ITexture* value) - { - if (Value) - Value->drop(); - - Value = value; - - if (Value) - Value->grab(); - } - - virtual E_ATTRIBUTE_TYPE getType() const - { - return EAT_TEXTURE; - } - - - virtual const wchar_t* getTypeString() const - { - return L"texture"; - } - - video::ITexture* Value; - video::IVideoDriver* Driver; -}; - - - -// Attribute implemented for array of stringw -class CStringWArrayAttribute : public IAttribute -{ -public: - - CStringWArrayAttribute(const char* name, core::array<core::stringw> value) - { - Name = name; - setArray(value); - } - - virtual core::array<core::stringw> getArray() - { - return Value; - } - - virtual void setArray(core::array<core::stringw> value) - { - Value = value; - } - - virtual E_ATTRIBUTE_TYPE getType() const - { - return EAT_STRINGWARRAY; - } - - virtual const wchar_t* getTypeString() const - { - return L"stringwarray"; - } - - core::array<core::stringw> Value; -}; - - -// Attribute implemented for user pointers -class CUserPointerAttribute : public IAttribute -{ -public: - - CUserPointerAttribute(const char* name, void* value) - { - Name = name; - Value = value; - } - - virtual s32 getInt() - { - return *(s32*)(&Value); - } - - virtual bool getBool() - { - return (Value != 0); - } - - virtual core::stringw getStringW() - { - wchar_t buf[32]; - swprintf(buf, 32, L"0x%x", *(int*)(&Value)); - - return core::stringw(buf); - } - - virtual void setString(const char* text) - { - sscanf(text, "0x%x", (unsigned int*)(&Value)); - } - - virtual E_ATTRIBUTE_TYPE getType() const - { - return EAT_USER_POINTER; - } - - virtual void setUserPointer(void* v) - { - Value = v; - } - - virtual void* getUserPointer() - { - return Value; - } - - - virtual const wchar_t* getTypeString() const - { - return L"userPointer"; - } - - void* Value; -}; - - -// todo: CGUIFontAttribute - -} // end namespace io -} // end namespace irr diff --git a/irrlicht-1.6/source/Irrlicht/CAttributes.cpp b/irrlicht-1.6/source/Irrlicht/CAttributes.cpp deleted file mode 100644 index 260724c6d..000000000 --- a/irrlicht-1.6/source/Irrlicht/CAttributes.cpp +++ /dev/null @@ -1,1559 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CAttributes.h" -#include "CAttributeImpl.h" -#include "ITexture.h" -#include "IXMLWriter.h" -#include "IVideoDriver.h" - -namespace irr -{ -namespace io -{ - -CAttributes::CAttributes(video::IVideoDriver* driver) -: Driver(driver) -{ - #ifdef _DEBUG - setDebugName("CAttributes"); - #endif - - if (Driver) - Driver->grab(); -} - -CAttributes::~CAttributes() -{ - clear(); - - if (Driver) - Driver->drop(); -} - - -//! Removes all attributes -void CAttributes::clear() -{ - for (u32 i=0; i<Attributes.size(); ++i) - Attributes[i]->drop(); - - Attributes.clear(); -} - - -//! Sets a string attribute. -//! \param attributeName: Name for the attribute -//! \param value: Value for the attribute. Set this to 0 to delete the attribute -void CAttributes::setAttribute(const c8* attributeName, const c8* value) -{ - for (u32 i=0; i<Attributes.size(); ++i) - if (Attributes[i]->Name == attributeName) - { - if (!value) - { - Attributes[i]->drop(); - Attributes.erase(i); - } - else - Attributes[i]->setString(value); - - return; - } - - if (value) - { - Attributes.push_back(new CStringAttribute(attributeName, value)); - } -} - -//! Gets a string attribute. -//! \param attributeName: Name of the attribute to get. -//! \return Returns value of the attribute previously set by setStringAttribute() -//! or 0 if attribute is not set. -core::stringc CAttributes::getAttributeAsString(const c8* attributeName) -{ - core::stringc str; - - IAttribute* att = getAttributeP(attributeName); - if (att) - return att->getString(); - else - return str; -} - -//! Gets a string attribute. -//! \param attributeName: Name of the attribute to get. -//! \param target: Buffer where the string is copied to. -void CAttributes::getAttributeAsString(const c8* attributeName, char* target) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - { - core::stringc str = att->getString(); - strcpy(target,str.c_str()); - } - else - target[0] = 0; -} - -//! Returns string attribute value by index. -//! \param index: Index value, must be between 0 and getAttributeCount()-1. -core::stringc CAttributes::getAttributeAsString(s32 index) -{ - core::stringc str; - - if ((u32)index < Attributes.size()) - return Attributes[index]->getString(); - - return str; -} - - -//! Sets a string attribute. -//! \param attributeName: Name for the attribute -//! \param value: Value for the attribute. Set this to 0 to delete the attribute -void CAttributes::setAttribute(const c8* attributeName, const wchar_t* value) -{ - for (u32 i=0; i<Attributes.size(); ++i) - { - if (Attributes[i]->Name == attributeName) - { - if (!value) - { - Attributes[i]->drop(); - Attributes.erase(i); - } - else - Attributes[i]->setString(value); - - return; - } - } - - if (value) - { - Attributes.push_back(new CStringAttribute(attributeName, value)); - } -} - -//! Gets a string attribute. -//! \param attributeName: Name of the attribute to get. -//! \return Returns value of the attribute previously set by setStringAttribute() -//! or 0 if attribute is not set. -core::stringw CAttributes::getAttributeAsStringW(const c8* attributeName) -{ - core::stringw str; - - IAttribute* att = getAttributeP(attributeName); - if (att) - str = att->getStringW(); - - return str; -} - -//! Gets a string attribute. -//! \param attributeName: Name of the attribute to get. -//! \param target: Buffer where the string is copied to. -void CAttributes::getAttributeAsStringW(const c8* attributeName, wchar_t* target) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - { - core::stringw str = att->getStringW(); - wcscpy(target,str.c_str()); - } - else - target[0] = 0; -} - -//! Returns string attribute value by index. -//! \param index: Index value, must be between 0 and getAttributeCount()-1. -core::stringw CAttributes::getAttributeAsStringW(s32 index) -{ - - if ((u32)index < Attributes.size()) - return Attributes[index]->getStringW(); - else - return core::stringw(); -} - - -//! Adds an attribute as an array of wide strings -void CAttributes::addArray(const c8* attributeName, core::array<core::stringw> value) -{ - Attributes.push_back(new CStringWArrayAttribute(attributeName, value)); -} - -//! Sets an attribute value as an array of wide strings. -void CAttributes::setAttribute(const c8* attributeName, const core::array<core::stringw> value) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setArray(value); - else - { - Attributes.push_back(new CStringWArrayAttribute(attributeName, value)); - } -} - -//! Gets an attribute as an array of wide strings. -core::array<core::stringw> CAttributes::getAttributeAsArray(const c8* attributeName) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - return att->getArray(); - else - return core::array<core::stringw>(); -} - -//! Returns attribute value as an array of wide strings by index. -core::array<core::stringw> CAttributes::getAttributeAsArray(s32 index) -{ - core::array<core::stringw> ret; - - if (index >= 0 && index < (s32)Attributes.size()) - ret = Attributes[index]->getArray(); - - return ret; -} - -//! Sets an attribute as an array of wide strings -void CAttributes::setAttribute(s32 index, core::array<core::stringw> value) -{ - if (index >= 0 && index < (s32)Attributes.size() ) - Attributes[index]->setArray(value); -} - - - - -//! Returns attribute index from name, -1 if not found -s32 CAttributes::findAttribute(const c8* attributeName) -{ - for (u32 i=0; i<Attributes.size(); ++i) - if (Attributes[i]->Name == attributeName) - return i; - - return -1; -} - - -IAttribute* CAttributes::getAttributeP(const c8* attributeName) -{ - for (u32 i=0; i<Attributes.size(); ++i) - if (Attributes[i]->Name == attributeName) - return Attributes[i]; - - return 0; -} - - -//! Sets a attribute as boolean value -void CAttributes::setAttribute(const c8* attributeName, bool value) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setBool(value); - else - { - Attributes.push_back(new CBoolAttribute(attributeName, value)); - } -} - -//! Gets a attribute as boolean value -//! \param attributeName: Name of the attribute to get. -//! \return Returns value of the attribute previously set by setAttribute() as bool -//! or 0 if attribute is not set. -bool CAttributes::getAttributeAsBool(const c8* attributeName) -{ - bool ret = false; - - IAttribute* att = getAttributeP(attributeName); - if (att) - ret = att->getBool(); - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return ret; -} - -//! Sets a attribute as integer value -void CAttributes::setAttribute(const c8* attributeName, s32 value) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setInt(value); - else - { - Attributes.push_back(new CIntAttribute(attributeName, value)); - } -} - -//! Gets a attribute as integer value -//! \param attributeName: Name of the attribute to get. -//! \return Returns value of the attribute previously set by setAttribute() as integer -//! or 0 if attribute is not set. -s32 CAttributes::getAttributeAsInt(const c8* attributeName) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - return att->getInt(); - else - return 0; -} - -//! Sets a attribute as float value -void CAttributes::setAttribute(const c8* attributeName, f32 value) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setFloat(value); - else - Attributes.push_back(new CFloatAttribute(attributeName, value)); -} - -//! Gets a attribute as integer value -//! \param attributeName: Name of the attribute to get. -//! \return Returns value of the attribute previously set by setAttribute() as float value -//! or 0 if attribute is not set. -f32 CAttributes::getAttributeAsFloat(const c8* attributeName) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - return att->getFloat(); - - return 0.f; -} - -//! Sets a attribute as color -void CAttributes::setAttribute(const c8* attributeName, video::SColor value) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setColor(value); - else - Attributes.push_back(new CColorAttribute(attributeName, value)); -} - -//! Gets an attribute as color -//! \param attributeName: Name of the attribute to get. -//! \return Returns value of the attribute previously set by setAttribute() -video::SColor CAttributes::getAttributeAsColor(const c8* attributeName) -{ - video::SColor ret(0); - - IAttribute* att = getAttributeP(attributeName); - if (att) - ret = att->getColor(); - - return ret; -} - -//! Sets a attribute as floating point color -void CAttributes::setAttribute(const c8* attributeName, video::SColorf value) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setColor(value); - else - Attributes.push_back(new CColorfAttribute(attributeName, value)); -} - -//! Gets an attribute as floating point color -//! \param attributeName: Name of the attribute to get. -//! \return Returns value of the attribute previously set by setAttribute() -video::SColorf CAttributes::getAttributeAsColorf(const c8* attributeName) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - return att->getColorf(); - else - return video::SColorf(); -} - -//! Sets a attribute as 2d position -void CAttributes::setAttribute(const c8* attributeName, core::position2di value) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setPosition(value); - else - Attributes.push_back(new CPosition2DAttribute(attributeName, value)); -} - -//! Gets an attribute as 2d position -//! \param attributeName: Name of the attribute to get. -//! \return Returns value of the attribute previously set by setAttribute() -core::position2di CAttributes::getAttributeAsPosition2d(const c8* attributeName) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - return att->getPosition(); - else - return core::position2di(); -} - -//! Sets a attribute as rectangle -void CAttributes::setAttribute(const c8* attributeName, core::rect<s32> value) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setRect(value); - else - Attributes.push_back(new CRectAttribute(attributeName, value)); -} - -//! Gets an attribute as rectangle -//! \param attributeName: Name of the attribute to get. -//! \return Returns value of the attribute previously set by setAttribute() -core::rect<s32> CAttributes::getAttributeAsRect(const c8* attributeName) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - return att->getRect(); - else - return core::rect<s32>(); -} - -//! Sets a attribute as vector -void CAttributes::setAttribute(const c8* attributeName, core::vector3df value) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setVector(value); - else - Attributes.push_back(new CVector3DAttribute(attributeName, value)); -} - -//! Gets an attribute as vector -//! \param attributeName: Name of the attribute to get. -//! \return Returns value of the attribute previously set by setAttribute() -core::vector3df CAttributes::getAttributeAsVector3d(const c8* attributeName) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - return att->getVector(); - else - return core::vector3df(); -} - -//! Sets an attribute as binary data -void CAttributes::setAttribute(const c8* attributeName, void* data, s32 dataSizeInBytes ) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setBinary(data, dataSizeInBytes); - else - Attributes.push_back(new CBinaryAttribute(attributeName, data, dataSizeInBytes)); -} - -//! Gets an attribute as binary data -//! \param attributeName: Name of the attribute to get. -void CAttributes::getAttributeAsBinaryData(const c8* attributeName, void* outData, s32 maxSizeInBytes) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->getBinary(outData, maxSizeInBytes); -} - -//! Sets an attribute as enumeration -void CAttributes::setAttribute(const c8* attributeName, const char* enumValue, const char* const* enumerationLiterals) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setEnum(enumValue, enumerationLiterals); - else - Attributes.push_back(new CEnumAttribute(attributeName, enumValue, enumerationLiterals)); -} - -//! Gets an attribute as enumeration -//! \param attributeName: Name of the attribute to get. -//! \return Returns value of the attribute previously set by setAttribute() -const char* CAttributes::getAttributeAsEnumeration(const c8* attributeName) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - return att->getEnum(); - else - return 0; -} - -//! Gets an attribute as enumeration -s32 CAttributes::getAttributeAsEnumeration(const c8* attributeName, const char* const* enumerationLiteralsToUse) -{ - IAttribute* att = getAttributeP(attributeName); - - if (enumerationLiteralsToUse && att) - { - const char* value = att->getEnum(); - if (value) - { - for (s32 i=0; enumerationLiteralsToUse[i]; ++i) - if (!strcmp(value, enumerationLiteralsToUse[i])) - return i; - } - } - - return -1; -} - -//! Gets the list of enumeration literals of an enumeration attribute -//! \param attributeName: Name of the attribute to get. -void CAttributes::getAttributeEnumerationLiteralsOfEnumeration(const c8* attributeName, core::array<core::stringc>& outLiterals) -{ - IAttribute* att = getAttributeP(attributeName); - - if (att && att->getType() == EAT_ENUM) - outLiterals = ((CEnumAttribute*)att)->EnumLiterals; -} - -//! Sets an attribute as texture reference -void CAttributes::setAttribute(const c8* attributeName, video::ITexture* value ) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setTexture(value); - else - Attributes.push_back(new CTextureAttribute(attributeName, value, Driver)); -} - - -//! Gets an attribute as texture reference -//! \param attributeName: Name of the attribute to get. -video::ITexture* CAttributes::getAttributeAsTexture(const c8* attributeName) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - return att->getTexture(); - else - return 0; -} - -//! Gets an attribute as texture reference -//! \param index: Index value, must be between 0 and getAttributeCount()-1. -video::ITexture* CAttributes::getAttributeAsTexture(s32 index) -{ - if ((u32)index < Attributes.size()) - return Attributes[index]->getTexture(); - else - return 0; -} - - -//! Returns amount of string attributes set in this scene manager. -u32 CAttributes::getAttributeCount() const -{ - return Attributes.size(); -} - -//! Returns string attribute name by index. -//! \param index: Index value, must be between 0 and getStringAttributeCount()-1. -const c8* CAttributes::getAttributeName(s32 index) -{ - if ((u32)index >= Attributes.size()) - return 0; - - return Attributes[index]->Name.c_str(); -} - -//! Returns the type of an attribute -E_ATTRIBUTE_TYPE CAttributes::getAttributeType(const c8* attributeName) -{ - E_ATTRIBUTE_TYPE ret = EAT_UNKNOWN; - - IAttribute* att = getAttributeP(attributeName); - if (att) - ret = att->getType(); - - return ret; -} - -//! Returns attribute type by index. -//! \param index: Index value, must be between 0 and getAttributeCount()-1. -E_ATTRIBUTE_TYPE CAttributes::getAttributeType(s32 index) -{ - if ((u32)index >= Attributes.size()) - return EAT_UNKNOWN; - - return Attributes[index]->getType(); -} - -//! Returns the type of an attribute -const wchar_t* CAttributes::getAttributeTypeString(const c8* attributeName) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - return att->getTypeString(); - else - return L"unknown"; -} - -//! Returns attribute type string by index. -//! \param index: Index value, must be between 0 and getAttributeCount()-1. -const wchar_t* CAttributes::getAttributeTypeString(s32 index) -{ - if ((u32)index >= Attributes.size()) - return L"unknown"; - - return Attributes[index]->getTypeString(); -} - -//! Gets an attribute as boolean value -//! \param index: Index value, must be between 0 and getAttributeCount()-1. -bool CAttributes::getAttributeAsBool(s32 index) -{ - bool ret = false; - - if ((u32)index < Attributes.size()) - ret = Attributes[index]->getBool(); - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return ret; -} - -//! Gets an attribute as integer value -//! \param index: Index value, must be between 0 and getAttributeCount()-1. -s32 CAttributes::getAttributeAsInt(s32 index) -{ - if ((u32)index < Attributes.size()) - return Attributes[index]->getInt(); - else - return 0; -} - -//! Gets an attribute as float value -//! \param index: Index value, must be between 0 and getAttributeCount()-1. -f32 CAttributes::getAttributeAsFloat(s32 index) -{ - if ((u32)index < Attributes.size()) - return Attributes[index]->getFloat(); - else - return 0.f; -} - -//! Gets an attribute as color -//! \param index: Index value, must be between 0 and getAttributeCount()-1. -video::SColor CAttributes::getAttributeAsColor(s32 index) -{ - video::SColor ret(0); - - if ((u32)index < Attributes.size()) - ret = Attributes[index]->getColor(); - - return ret; -} - -//! Gets an attribute as floating point color -//! \param index: Index value, must be between 0 and getAttributeCount()-1. -video::SColorf CAttributes::getAttributeAsColorf(s32 index) -{ - if ((u32)index < Attributes.size()) - return Attributes[index]->getColorf(); - - return video::SColorf(); -} - -//! Gets an attribute as 3d vector -//! \param index: Index value, must be between 0 and getAttributeCount()-1. -core::vector3df CAttributes::getAttributeAsVector3d(s32 index) -{ - if ((u32)index < Attributes.size()) - return Attributes[index]->getVector(); - else - return core::vector3df(); -} - -//! Gets an attribute as rectangle -//! \param index: Index value, must be between 0 and getAttributeCount()-1. -core::position2di CAttributes::getAttributeAsPosition2d(s32 index) -{ - if ((u32)index < Attributes.size()) - return Attributes[index]->getPosition(); - else - return core::position2di(); -} - -//! Gets an attribute as rectangle -//! \param index: Index value, must be between 0 and getAttributeCount()-1. -core::rect<s32> CAttributes::getAttributeAsRect(s32 index) -{ - if ((u32)index < Attributes.size()) - return Attributes[index]->getRect(); - else - return core::rect<s32>(); -} - - -//! Gets an attribute as binary data -///! \param index: Index value, must be between 0 and getAttributeCount()-1. -void CAttributes::getAttributeAsBinaryData(s32 index, void* outData, s32 maxSizeInBytes) -{ - if ((u32)index < Attributes.size()) - Attributes[index]->getBinary(outData, maxSizeInBytes); -} - - -//! Gets an attribute as enumeration -//! \param index: Index value, must be between 0 and getAttributeCount()-1. -const char* CAttributes::getAttributeAsEnumeration(s32 index) -{ - if ((u32)index < Attributes.size()) - return Attributes[index]->getEnum(); - else - return 0; -} - - -//! Gets an attribute as enumeration -//! \param index: Index value, must be between 0 and getAttributeCount()-1. -s32 CAttributes::getAttributeAsEnumeration(s32 index, const char* const* enumerationLiteralsToUse) -{ - if ((u32)index < Attributes.size()) - { - IAttribute* att = Attributes[index]; - - if (enumerationLiteralsToUse && att) - { - const char* value = att->getEnum(); - if (value) - { - for (s32 i=0; enumerationLiteralsToUse[i]; ++i) - if (!strcmp(value, enumerationLiteralsToUse[i])) - return i; - } - } - } - - return -1; -} - -//! Gets the list of enumeration literals of an enumeration attribute -//! \param index: Index value, must be between 0 and getAttributeCount()-1. -void CAttributes::getAttributeEnumerationLiteralsOfEnumeration(s32 index, core::array<core::stringc>& outLiterals) -{ - if ((u32)index < Attributes.size() && - Attributes[index]->getType() == EAT_ENUM) - outLiterals = ((CEnumAttribute*)Attributes[index])->EnumLiterals; -} - - -//! Adds an attribute as integer -void CAttributes::addInt(const c8* attributeName, s32 value) -{ - Attributes.push_back(new CIntAttribute(attributeName, value)); -} - -//! Adds an attribute as float -void CAttributes::addFloat(const c8* attributeName, f32 value) -{ - Attributes.push_back(new CFloatAttribute(attributeName, value)); -} - -//! Adds an attribute as string -void CAttributes::addString(const c8* attributeName, const char* value) -{ - Attributes.push_back(new CStringAttribute(attributeName, value)); -} - -//! Adds an attribute as wchar string -void CAttributes::addString(const c8* attributeName, const wchar_t* value) -{ - Attributes.push_back(new CStringAttribute(attributeName, value)); -} - -//! Adds an attribute as bool -void CAttributes::addBool(const c8* attributeName, bool value) -{ - Attributes.push_back(new CBoolAttribute(attributeName, value)); -} - -//! Adds an attribute as enum -void CAttributes::addEnum(const c8* attributeName, const char* enumValue, const char* const* enumerationLiterals) -{ - Attributes.push_back(new CEnumAttribute(attributeName, enumValue, enumerationLiterals)); -} - -//! Adds an attribute as enum -void CAttributes::addEnum(const c8* attributeName, s32 enumValue, const char* const* enumerationLiterals) -{ - addEnum(attributeName, "", enumerationLiterals); - Attributes.getLast()->setInt(enumValue); -} - -//! Adds an attribute as color -void CAttributes::addColor(const c8* attributeName, video::SColor value) -{ - Attributes.push_back(new CColorAttribute(attributeName, value)); -} - -//! Adds an attribute as floating point color -void CAttributes::addColorf(const c8* attributeName, video::SColorf value) -{ - Attributes.push_back(new CColorfAttribute(attributeName, value)); -} - -//! Adds an attribute as 3d vector -void CAttributes::addVector3d(const c8* attributeName, core::vector3df value) -{ - Attributes.push_back(new CVector3DAttribute(attributeName, value)); -} - -//! Adds an attribute as 2d position -void CAttributes::addPosition2d(const c8* attributeName, core::position2di value) -{ - Attributes.push_back(new CPosition2DAttribute(attributeName, value)); -} - -//! Adds an attribute as rectangle -void CAttributes::addRect(const c8* attributeName, core::rect<s32> value) -{ - Attributes.push_back(new CRectAttribute(attributeName, value)); -} - -//! Adds an attribute as binary data -void CAttributes::addBinary(const c8* attributeName, void* data, s32 dataSizeInBytes) -{ - Attributes.push_back(new CBinaryAttribute(attributeName, data, dataSizeInBytes)); -} - -//! Adds an attribute as texture reference -void CAttributes::addTexture(const c8* attributeName, video::ITexture* texture) -{ - Attributes.push_back(new CTextureAttribute(attributeName, texture, Driver)); -} - -//! Returns if an attribute with a name exists -bool CAttributes::existsAttribute(const c8* attributeName) -{ - return getAttributeP(attributeName) != 0; -} - -//! Sets an attribute value as string. -//! \param attributeName: Name for the attribute -void CAttributes::setAttribute(s32 index, const c8* value) -{ - if ((u32)index < Attributes.size()) - Attributes[index]->setString(value); -} - -//! Sets an attribute value as string. -//! \param attributeName: Name for the attribute -void CAttributes::setAttribute(s32 index, const wchar_t* value) -{ - if ((u32)index < Attributes.size()) - Attributes[index]->setString(value); -} - -//! Sets an attribute as boolean value -void CAttributes::setAttribute(s32 index, bool value) -{ - if ((u32)index < Attributes.size()) - Attributes[index]->setBool(value); -} - -//! Sets an attribute as integer value -void CAttributes::setAttribute(s32 index, s32 value) -{ - if ((u32)index < Attributes.size()) - Attributes[index]->setInt(value); -} - -//! Sets a attribute as float value -void CAttributes::setAttribute(s32 index, f32 value) -{ - if ((u32)index < Attributes.size()) - Attributes[index]->setFloat(value); -} - -//! Sets a attribute as color -void CAttributes::setAttribute(s32 index, video::SColor color) -{ - if ((u32)index < Attributes.size()) - Attributes[index]->setColor(color); -} - -//! Sets a attribute as floating point color -void CAttributes::setAttribute(s32 index, video::SColorf color) -{ - if ((u32)index < Attributes.size()) - Attributes[index]->setColor(color); -} - -//! Sets a attribute as vector -void CAttributes::setAttribute(s32 index, core::vector3df v) -{ - if ((u32)index < Attributes.size()) - Attributes[index]->setVector(v); -} - -//! Sets a attribute as position -void CAttributes::setAttribute(s32 index, core::position2di v) -{ - if ((u32)index < Attributes.size()) - Attributes[index]->setPosition(v); -} - -//! Sets a attribute as rectangle -void CAttributes::setAttribute(s32 index, core::rect<s32> v) -{ - if ((u32)index < Attributes.size()) - Attributes[index]->setRect(v); -} - -//! Sets an attribute as binary data -void CAttributes::setAttribute(s32 index, void* data, s32 dataSizeInBytes ) -{ - if ((u32)index < Attributes.size()) - Attributes[index]->setBinary(data, dataSizeInBytes); -} - - -//! Sets an attribute as enumeration -void CAttributes::setAttribute(s32 index, const char* enumValue, const char* const* enumerationLiterals) -{ - if ((u32)index < Attributes.size()) - Attributes[index]->setEnum(enumValue, enumerationLiterals); -} - - -//! Sets an attribute as texture reference -void CAttributes::setAttribute(s32 index, video::ITexture* texture) -{ - if ((u32)index < Attributes.size()) - Attributes[index]->setTexture(texture); -} - - -//! Adds an attribute as matrix -void CAttributes::addMatrix(const c8* attributeName, const core::matrix4& v) -{ - Attributes.push_back(new CMatrixAttribute(attributeName, v)); -} - - -//! Sets an attribute as matrix -void CAttributes::setAttribute(const c8* attributeName, const core::matrix4& v) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setMatrix(v); - else - Attributes.push_back(new CMatrixAttribute(attributeName, v)); -} - -//! Gets an attribute as a matrix4 -core::matrix4 CAttributes::getAttributeAsMatrix(const c8* attributeName) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - return att->getMatrix(); - else - return core::matrix4(); - -} - -//! Gets an attribute as matrix -core::matrix4 CAttributes::getAttributeAsMatrix(s32 index) -{ - if ((u32)index < Attributes.size()) - return Attributes[index]->getMatrix(); - else - return core::matrix4(); -} - -//! Sets an attribute as matrix -void CAttributes::setAttribute(s32 index, const core::matrix4& v) -{ - if ((u32)index < Attributes.size()) - Attributes[index]->setMatrix(v); -} - - -//! Adds an attribute as quaternion -void CAttributes::addQuaternion(const c8* attributeName, core::quaternion v) -{ - Attributes.push_back(new CQuaternionAttribute(attributeName, v)); -} - - -//! Sets an attribute as quaternion -void CAttributes::setAttribute(const c8* attributeName, core::quaternion v) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setQuaternion(v); - else - { - Attributes.push_back(new CQuaternionAttribute(attributeName, v)); - } -} - -//! Gets an attribute as a quaternion -core::quaternion CAttributes::getAttributeAsQuaternion(const c8* attributeName) -{ - core::quaternion ret(0,1,0, 0); - - IAttribute* att = getAttributeP(attributeName); - if (att) - ret = att->getQuaternion(); - - return ret; -} - -//! Gets an attribute as quaternion -core::quaternion CAttributes::getAttributeAsQuaternion(s32 index) -{ - core::quaternion ret(0,1,0, 0); - - if (index >= 0 && index < (s32)Attributes.size()) - ret = Attributes[index]->getQuaternion(); - - return ret; -} - -//! Sets an attribute as quaternion -void CAttributes::setAttribute(s32 index, core::quaternion v) -{ -if (index >= 0 && index < (s32)Attributes.size() ) - Attributes[index]->setQuaternion(v); -} - -//! Adds an attribute as axis aligned bounding box -void CAttributes::addBox3d(const c8* attributeName, core::aabbox3df v) -{ - Attributes.push_back(new CBBoxAttribute(attributeName, v)); -} - -//! Sets an attribute as axis aligned bounding box -void CAttributes::setAttribute(const c8* attributeName, core::aabbox3df v) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setBBox(v); - else - { - Attributes.push_back(new CBBoxAttribute(attributeName, v)); - } -} - -//! Gets an attribute as a axis aligned bounding box -core::aabbox3df CAttributes::getAttributeAsBox3d(const c8* attributeName) -{ - core::aabbox3df ret(0,0,0, 0,0,0); - - IAttribute* att = getAttributeP(attributeName); - if (att) - ret = att->getBBox(); - - return ret; -} - -//! Gets an attribute as axis aligned bounding box -core::aabbox3df CAttributes::getAttributeAsBox3d(s32 index) -{ - core::aabbox3df ret(0,0,0, 0,0,0); - - if (index >= 0 && index < (s32)Attributes.size()) - ret = Attributes[index]->getBBox(); - - return ret; -} - -//! Sets an attribute as axis aligned bounding box -void CAttributes::setAttribute(s32 index, core::aabbox3df v) -{ -if (index >= 0 && index < (s32)Attributes.size() ) - Attributes[index]->setBBox(v); -} - -//! Adds an attribute as 3d plane -void CAttributes::addPlane3d(const c8* attributeName, core::plane3df v) -{ - Attributes.push_back(new CPlaneAttribute(attributeName, v)); -} - -//! Sets an attribute as 3d plane -void CAttributes::setAttribute(const c8* attributeName, core::plane3df v) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setPlane(v); - else - { - Attributes.push_back(new CPlaneAttribute(attributeName, v)); - } -} - -//! Gets an attribute as a 3d plane -core::plane3df CAttributes::getAttributeAsPlane3d(const c8* attributeName) -{ - core::plane3df ret(0,0,0, 0,1,0); - - IAttribute* att = getAttributeP(attributeName); - if (att) - ret = att->getPlane(); - - return ret; -} - -//! Gets an attribute as 3d plane -core::plane3df CAttributes::getAttributeAsPlane3d(s32 index) -{ - core::plane3df ret(0,0,0, 0,1,0); - - if (index >= 0 && index < (s32)Attributes.size()) - ret = Attributes[index]->getPlane(); - - return ret; -} - -//! Sets an attribute as 3d plane -void CAttributes::setAttribute(s32 index, core::plane3df v) -{ - if (index >= 0 && index < (s32)Attributes.size() ) - Attributes[index]->setPlane(v); -} - -//! Adds an attribute as 3d triangle -void CAttributes::addTriangle3d(const c8* attributeName, core::triangle3df v) -{ - Attributes.push_back(new CTriangleAttribute(attributeName, v)); -} - -//! Sets an attribute as 3d triangle -void CAttributes::setAttribute(const c8* attributeName, core::triangle3df v) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setTriangle(v); - else - { - Attributes.push_back(new CTriangleAttribute(attributeName, v)); - } -} - -//! Gets an attribute as a 3d triangle -core::triangle3df CAttributes::getAttributeAsTriangle3d(const c8* attributeName) -{ - core::triangle3df ret; - ret.pointA = ret.pointB = ret.pointC = core::vector3df(0,0,0); - - IAttribute* att = getAttributeP(attributeName); - if (att) - ret = att->getTriangle(); - - return ret; -} - -//! Gets an attribute as 3d triangle -core::triangle3df CAttributes::getAttributeAsTriangle3d(s32 index) -{ - core::triangle3df ret; - ret.pointA = ret.pointB = ret.pointC = core::vector3df(0,0,0); - - if (index >= 0 && index < (s32)Attributes.size()) - ret = Attributes[index]->getTriangle(); - - return ret; -} - -//! Sets an attribute as 3d triangle -void CAttributes::setAttribute(s32 index, core::triangle3df v) -{ - if (index >= 0 && index < (s32)Attributes.size() ) - Attributes[index]->setTriangle(v); -} - -//! Adds an attribute as a 2d line -void CAttributes::addLine2d(const c8* attributeName, core::line2df v) -{ - Attributes.push_back(new CLine2dAttribute(attributeName, v)); -} - -//! Sets an attribute as a 2d line -void CAttributes::setAttribute(const c8* attributeName, core::line2df v) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setLine2d(v); - else - { - Attributes.push_back(new CLine2dAttribute(attributeName, v)); - } -} - -//! Gets an attribute as a 2d line -core::line2df CAttributes::getAttributeAsLine2d(const c8* attributeName) -{ - core::line2df ret(0,0, 0,0); - - IAttribute* att = getAttributeP(attributeName); - if (att) - ret = att->getLine2d(); - - return ret; -} - -//! Gets an attribute as a 2d line -core::line2df CAttributes::getAttributeAsLine2d(s32 index) -{ - core::line2df ret(0,0, 0,0); - - if (index >= 0 && index < (s32)Attributes.size()) - ret = Attributes[index]->getLine2d(); - - return ret; -} - -//! Sets an attribute as a 2d line -void CAttributes::setAttribute(s32 index, core::line2df v) -{ - if (index >= 0 && index < (s32)Attributes.size() ) - Attributes[index]->setLine2d(v); -} - -//! Adds an attribute as a 3d line -void CAttributes::addLine3d(const c8* attributeName, core::line3df v) -{ - Attributes.push_back(new CLine3dAttribute(attributeName, v)); -} - -//! Sets an attribute as a 3d line -void CAttributes::setAttribute(const c8* attributeName, core::line3df v) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setLine3d(v); - else - { - Attributes.push_back(new CLine3dAttribute(attributeName, v)); - } -} - -//! Gets an attribute as a 3d line -core::line3df CAttributes::getAttributeAsLine3d(const c8* attributeName) -{ - core::line3df ret(0,0,0, 0,0,0); - - IAttribute* att = getAttributeP(attributeName); - if (att) - ret = att->getLine3d(); - - return ret; -} - -//! Gets an attribute as a 3d line -core::line3df CAttributes::getAttributeAsLine3d(s32 index) -{ - core::line3df ret(0,0,0, 0,0,0); - - if (index >= 0 && index < (s32)Attributes.size()) - ret = Attributes[index]->getLine3d(); - - return ret; -} - -//! Sets an attribute as a 3d line -void CAttributes::setAttribute(s32 index, core::line3df v) -{ - if (index >= 0 && index < (s32)Attributes.size() ) - Attributes[index]->setLine3d(v); - -} - - -//! Adds an attribute as user pointner -void CAttributes::addUserPointer(const c8* attributeName, void* userPointer) -{ - Attributes.push_back(new CUserPointerAttribute(attributeName, userPointer)); -} - -//! Sets an attribute as user pointer -void CAttributes::setAttribute(const c8* attributeName, void* userPointer) -{ - IAttribute* att = getAttributeP(attributeName); - if (att) - att->setUserPointer(userPointer); - else - { - Attributes.push_back(new CUserPointerAttribute(attributeName, userPointer)); - } -} - -//! Gets an attribute as user pointer -//! \param attributeName: Name of the attribute to get. -void* CAttributes::getAttributeAsUserPointer(const c8* attributeName) -{ - void* value = 0; - - IAttribute* att = getAttributeP(attributeName); - if (att) - value = att->getUserPointer(); - - return value; -} - -//! Gets an attribute as user pointer -//! \param index: Index value, must be between 0 and getAttributeCount()-1. -void* CAttributes::getAttributeAsUserPointer(s32 index) -{ - void* value = 0; - - if (index >= 0 && index < (s32)Attributes.size()) - value = Attributes[index]->getUserPointer(); - - return value; -} - -//! Sets an attribute as user pointer -void CAttributes::setAttribute(s32 index, void* userPointer) -{ - if (index >= 0 && index < (s32)Attributes.size() ) - Attributes[index]->setUserPointer(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(io::IXMLReader* reader, bool readCurrentElementOnly, - const wchar_t* nonDefaultElementName) -{ - if (!reader) - return false; - - clear(); - - core::stringw elementName = L"attributes"; - if (nonDefaultElementName) - elementName = nonDefaultElementName; - - if (readCurrentElementOnly) - { - if (elementName != reader->getNodeName()) - return false; - } - - while(reader->read()) - { - switch(reader->getNodeType()) - { - case io::EXN_ELEMENT: - readAttributeFromXML(reader); - break; - case io::EXN_ELEMENT_END: - if (elementName == reader->getNodeName()) - return true; - break; - default: - break; - } - } - - return true; -} - - -void CAttributes::readAttributeFromXML(io::IXMLReader* reader) -{ - core::stringw element = reader->getNodeName(); - core::stringc name = reader->getAttributeValue(L"name"); - - if (element == L"enum") - { - addEnum(name.c_str(), 0, 0); - Attributes.getLast()->setString(reader->getAttributeValue(L"value")); - } - else - if (element == L"binary") - { - addBinary(name.c_str(), 0, 0); - Attributes.getLast()->setString(reader->getAttributeValue(L"value")); - } - else - if (element == L"color") - { - addColor(name.c_str(), video::SColor()); - Attributes.getLast()->setString(reader->getAttributeValue(L"value")); - } - else - if (element == L"colorf") - { - addColorf(name.c_str(), video::SColorf()); - Attributes.getLast()->setString(reader->getAttributeValue(L"value")); - } - else - if (element == L"float") - { - addFloat(name.c_str(), 0); - Attributes.getLast()->setString(reader->getAttributeValue(L"value")); - } - else - if (element == L"int") - { - addInt(name.c_str(), 0); - Attributes.getLast()->setString(reader->getAttributeValue(L"value")); - } - else - if (element == L"bool") - { - addBool(name.c_str(), 0); - Attributes.getLast()->setString(reader->getAttributeValue(L"value")); - } - else - if (element == L"string") - { - addString(name.c_str(), L""); - Attributes.getLast()->setString(reader->getAttributeValue(L"value")); - } - else - if (element == L"texture") - { - addTexture(name.c_str(), 0); - Attributes.getLast()->setString(reader->getAttributeValue(L"value")); - } - else - if (element == L"vector3d") - { - addVector3d(name.c_str(), core::vector3df()); - Attributes.getLast()->setString(reader->getAttributeValue(L"value")); - } - else - if (element == L"position") - { - addPosition2d(name.c_str(), core::position2di()); - Attributes.getLast()->setString(reader->getAttributeValue(L"value")); - } - else - if (element == L"rect") - { - addRect(name.c_str(), core::rect<s32>()); - Attributes.getLast()->setString(reader->getAttributeValue(L"value")); - } - else - if (element == L"matrix") - { - addMatrix(name.c_str(), core::matrix4()); - Attributes.getLast()->setString(reader->getAttributeValue(L"value")); - } - else - if (element == L"quaternion") - { - addQuaternion(name.c_str(), core::quaternion()); - Attributes.getLast()->setString(reader->getAttributeValue(L"value")); - } - else - if (element == L"box3d") - { - addBox3d(name.c_str(), core::aabbox3df()); - Attributes.getLast()->setString(reader->getAttributeValue(L"value")); - } - else - if (element == L"plane") - { - addPlane3d(name.c_str(), core::plane3df()); - Attributes.getLast()->setString(reader->getAttributeValue(L"value")); - } - else - if (element == L"triangle") - { - addTriangle3d(name.c_str(), core::triangle3df()); - Attributes.getLast()->setString(reader->getAttributeValue(L"value")); - } - else - if (element == L"line2d") - { - addLine2d(name.c_str(), core::line2df()); - Attributes.getLast()->setString(reader->getAttributeValue(L"value")); - } - else - if (element == L"line3d") - { - addLine3d(name.c_str(), core::line3df()); - Attributes.getLast()->setString(reader->getAttributeValue(L"value")); - } - else - if (element == L"stringwarray") - { - core::array<core::stringw> tmpArray; - - s32 count = reader->getAttributeValueAsInt(L"count"); - s32 n=0; - const core::stringw tmpName(L"value"); - for (; n<count; ++n) - { - tmpArray.push_back(reader->getAttributeValue((tmpName+core::stringw(n)).c_str())); - } - addArray(name.c_str(),tmpArray); - } -} - -//! Write these attributes into a xml file -bool CAttributes::write(io::IXMLWriter* writer, bool writeXMLHeader, - const wchar_t* nonDefaultElementName) -{ - if (!writer) - return false; - - if (writeXMLHeader) - writer->writeXMLHeader(); - - core::stringw elementName = L"attributes"; - if (nonDefaultElementName) - elementName = nonDefaultElementName; - - writer->writeElement(elementName.c_str(), false); - writer->writeLineBreak(); - - s32 i=0; - for (; i<(s32)Attributes.size(); ++i) - { - if ( Attributes[i]->getType() == EAT_STRINGWARRAY ) - { - core::array<core::stringw> arraynames, arrayvalues; - core::array<core::stringw> arrayinput = Attributes[i]->getArray(); - - // build arrays - - // name - arraynames.push_back(core::stringw(L"name")); - arrayvalues.push_back(core::stringw(Attributes[i]->Name.c_str()) ); - - // count - arraynames.push_back(core::stringw(L"count")); - arrayvalues.push_back(core::stringw((s32)arrayinput.size())); - - // array... - u32 n=0; - const core::stringw tmpName(L"value"); - for (; n < arrayinput.size(); ++n) - { - arraynames.push_back((tmpName+core::stringw(n)).c_str()); - arrayvalues.push_back(arrayinput[n]); - } - - // write them - writer->writeElement( Attributes[i]->getTypeString(), true, arraynames, arrayvalues); - } - else - { - writer->writeElement( - Attributes[i]->getTypeString(), true, - L"name", core::stringw(Attributes[i]->Name.c_str()).c_str(), - L"value", Attributes[i]->getStringW().c_str() ); - } - - writer->writeLineBreak(); - } - - writer->writeClosingTag(elementName.c_str()); - writer->writeLineBreak(); - - return true; -} - - -} // end namespace io -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CAttributes.h b/irrlicht-1.6/source/Irrlicht/CAttributes.h deleted file mode 100644 index c08d1ee26..000000000 --- a/irrlicht-1.6/source/Irrlicht/CAttributes.h +++ /dev/null @@ -1,732 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_ATTRIBUTES_H_INCLUDED__ -#define __C_ATTRIBUTES_H_INCLUDED__ - -#include "IAttributes.h" - -namespace irr -{ -namespace video -{ - class ITexture; - class IVideoDriver; -} -namespace io -{ - -class IAttribute; - -//! Implementation of the IAttributes interface -class CAttributes : public IAttributes -{ -public: - - CAttributes(video::IVideoDriver* driver=0); - ~CAttributes(); - - //! Returns amount of attributes in this collection of attributes. - virtual u32 getAttributeCount() const; - - //! Returns attribute name by index. - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual const c8* getAttributeName(s32 index); - - //! Returns the type of an attribute - //! \param attributeName: Name for the attribute - virtual E_ATTRIBUTE_TYPE getAttributeType(const c8* attributeName); - - //! Returns attribute type by index. - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual E_ATTRIBUTE_TYPE getAttributeType(s32 index); - - //! Returns the type string of the attribute - //! \param attributeName: String for the attribute type - virtual const wchar_t* getAttributeTypeString(const c8* attributeName); - - //! Returns the type string of the attribute by index. - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual const wchar_t* getAttributeTypeString(s32 index); - - //! Returns if an attribute with a name exists - virtual bool existsAttribute(const c8* attributeName); - - //! Returns attribute index from name, -1 if not found - virtual s32 findAttribute(const c8* attributeName); - - //! Removes all attributes - virtual void clear(); - - //! 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(io::IXMLReader* reader, bool readCurrentElementOnly=false, - const wchar_t* nonDefaultElementName = 0); - - //! Write these attributes into a xml file - virtual bool write(io::IXMLWriter* writer, bool writeXMLHeader=false, const wchar_t* nonDefaultElementName=0); - - - /* - - Integer Attribute - - */ - - //! Adds an attribute as integer - virtual void addInt(const c8* attributeName, s32 value); - - //! Sets an attribute as integer value - virtual void setAttribute(const c8* attributeName, s32 value); - - //! Gets an attribute as integer value - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual s32 getAttributeAsInt(const c8* attributeName); - - //! Gets an attribute as integer value - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual s32 getAttributeAsInt(s32 index); - - //! Sets an attribute as integer value - virtual void setAttribute(s32 index, s32 value); - - /* - - Float Attribute - - */ - - //! Adds an attribute as float - virtual void addFloat(const c8* attributeName, f32 value); - - //! Sets a attribute as float value - virtual void setAttribute(const c8* attributeName, f32 value); - - //! Gets an attribute as float value - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual f32 getAttributeAsFloat(const c8* attributeName); - - //! Gets an attribute as float value - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual f32 getAttributeAsFloat(s32 index); - - //! Sets an attribute as float value - virtual void setAttribute(s32 index, f32 value); - - /* - - String Attribute - - */ - - //! Adds an attribute as string - virtual void addString(const c8* attributeName, const c8* value); - - //! Sets an attribute value as string. - //! \param attributeName: Name for the attribute - //! \param value: Value for the attribute. Set this to 0 to delete the attribute - virtual void setAttribute(const c8* attributeName, const c8* value); - - //! Gets an attribute as string. - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - //! or 0 if attribute is not set. - virtual core::stringc getAttributeAsString(const c8* attributeName); - - //! Gets an attribute as string. - //! \param attributeName: Name of the attribute to get. - //! \param target: Buffer where the string is copied to. - virtual void getAttributeAsString(const c8* attributeName, c8* target); - - //! Returns attribute value as string by index. - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::stringc getAttributeAsString(s32 index); - - //! Sets an attribute value as string. - //! \param attributeName: Name for the attribute - virtual void setAttribute(s32 index, const c8* value); - - // wide strings - - //! Adds an attribute as string - virtual void addString(const c8* attributeName, const wchar_t* value); - - //! Sets an attribute value as string. - //! \param attributeName: Name for the attribute - //! \param value: Value for the attribute. Set this to 0 to delete the attribute - virtual void setAttribute(const c8* attributeName, const wchar_t* value); - - //! Gets an attribute as string. - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - //! or 0 if attribute is not set. - virtual core::stringw getAttributeAsStringW(const c8* attributeName); - - //! Gets an attribute as string. - //! \param attributeName: Name of the attribute to get. - //! \param target: Buffer where the string is copied to. - virtual void getAttributeAsStringW(const c8* attributeName, wchar_t* target); - - //! Returns attribute value as string by index. - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::stringw getAttributeAsStringW(s32 index); - - //! Sets an attribute value as string. - //! \param attributeName: Name for the attribute - virtual void setAttribute(s32 index, const wchar_t* value); - - /* - - Binary Data Attribute - - */ - - //! Adds an attribute as binary data - virtual void addBinary(const c8* attributeName, void* data, s32 dataSizeInBytes); - - //! Sets an attribute as binary data - virtual void setAttribute(const c8* attributeName, void* data, s32 dataSizeInBytes); - - //! Gets an attribute as binary data - //! \param attributeName: Name of the attribute to get. - virtual void getAttributeAsBinaryData(const c8* attributeName, void* outData, s32 maxSizeInBytes); - - //! Gets an attribute as binary data - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual void getAttributeAsBinaryData(s32 index, void* outData, s32 maxSizeInBytes); - - //! Sets an attribute as binary data - virtual void setAttribute(s32 index, void* data, s32 dataSizeInBytes); - - - /* - - Array Attribute - - */ - - //! Adds an attribute as wide string array - virtual void addArray(const c8* attributeName, core::array<core::stringw> value); - - //! Sets an attribute value as a wide string array. - //! \param attributeName: Name for the attribute - //! \param value: Value for the attribute. Set this to 0 to delete the attribute - virtual void setAttribute(const c8* attributeName, const core::array<core::stringw> value); - - //! Gets an attribute as an array of wide strings. - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - //! or 0 if attribute is not set. - virtual core::array<core::stringw> getAttributeAsArray(const c8* attributeName); - - //! Returns attribute value as an array of wide strings by index. - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::array<core::stringw> getAttributeAsArray(s32 index); - - //! Sets an attribute as an array of wide strings - virtual void setAttribute(s32 index, core::array<core::stringw> value); - - /* - - Bool Attribute - - */ - - //! Adds an attribute as bool - virtual void addBool(const c8* attributeName, bool value); - - //! Sets an attribute as boolean value - virtual void setAttribute(const c8* attributeName, bool value); - - //! Gets an attribute as boolean value - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual bool getAttributeAsBool(const c8* attributeName); - - //! Gets an attribute as boolean value - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual bool getAttributeAsBool(s32 index); - - //! Sets an attribute as boolean value - virtual void setAttribute(s32 index, bool value); - - /* - - Enumeration Attribute - - */ - - //! Adds an attribute as enum - virtual void addEnum(const c8* attributeName, const c8* enumValue, const c8* const* enumerationLiterals); - - //! Adds an attribute as enum - virtual void addEnum(const c8* attributeName, s32 enumValue, const c8* const* enumerationLiterals); - - //! Sets an attribute as enumeration - virtual void setAttribute(const c8* attributeName, const c8* enumValue, const c8* const* enumerationLiterals); - - //! Gets an attribute as enumeration - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual const c8* getAttributeAsEnumeration(const c8* attributeName); - - //! Gets an attribute as enumeration - //! \param attributeName: Name of the attribute to get. - //! \param enumerationLiteralsToUse: Use these enumeration literals to get the index value instead of the set ones. - //! This is useful when the attribute list maybe was read from an xml file, and only contains the enumeration string, but - //! no information about its index. - //! \return Returns value of the attribute previously set by setAttribute() - virtual s32 getAttributeAsEnumeration(const c8* attributeName, const c8* const* enumerationLiteralsToUse); - - //! Gets an attribute as enumeration - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual s32 getAttributeAsEnumeration(s32 index, const c8* const* enumerationLiteralsToUse); - - //! Gets an attribute as enumeration - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual const c8* getAttributeAsEnumeration(s32 index); - - //! Gets the list of enumeration literals of an enumeration attribute - //! \param attributeName: Name of the attribute to get. - virtual void getAttributeEnumerationLiteralsOfEnumeration(const c8* attributeName, core::array<core::stringc>& outLiterals); - - //! Gets the list of enumeration literals of an enumeration attribute - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual void getAttributeEnumerationLiteralsOfEnumeration(s32 index, core::array<core::stringc>& outLiterals); - - //! Sets an attribute as enumeration - virtual void setAttribute(s32 index, const c8* enumValue, const c8* const* enumerationLiterals); - - - /* - - SColor Attribute - - */ - - //! Adds an attribute as color - virtual void addColor(const c8* attributeName, video::SColor value); - - //! Sets a attribute as color - virtual void setAttribute(const c8* attributeName, video::SColor color); - - //! Gets an attribute as color - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual video::SColor getAttributeAsColor(const c8* attributeName); - - //! Gets an attribute as color - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual video::SColor getAttributeAsColor(s32 index); - - //! Sets an attribute as color - virtual void setAttribute(s32 index, video::SColor color); - - /* - - SColorf Attribute - - */ - - //! Adds an attribute as floating point color - virtual void addColorf(const c8* attributeName, video::SColorf value); - - //! Sets a attribute as floating point color - virtual void setAttribute(const c8* attributeName, video::SColorf color); - - //! Gets an attribute as floating point color - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual video::SColorf getAttributeAsColorf(const c8* attributeName); - - //! Gets an attribute as floating point color - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual video::SColorf getAttributeAsColorf(s32 index); - - //! Sets an attribute as floating point color - virtual void setAttribute(s32 index, video::SColorf color); - - - /* - - Vector3d Attribute - - */ - - //! Adds an attribute as 3d vector - virtual void addVector3d(const c8* attributeName, core::vector3df value); - - //! Sets a attribute as 3d vector - virtual void setAttribute(const c8* attributeName, core::vector3df v); - - //! Gets an attribute as 3d vector - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::vector3df getAttributeAsVector3d(const c8* attributeName); - - //! Gets an attribute as 3d vector - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::vector3df getAttributeAsVector3d(s32 index); - - //! Sets an attribute as vector - virtual void setAttribute(s32 index, core::vector3df v); - - /* - - Position2d Attribute - - */ - - //! Adds an attribute as 2d position - virtual void addPosition2d(const c8* attributeName, core::position2di value); - - //! Sets a attribute as 2d position - virtual void setAttribute(const c8* attributeName, core::position2di v); - - //! Gets an attribute as position - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::position2di getAttributeAsPosition2d(const c8* attributeName); - - //! Gets an attribute as position - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::position2di getAttributeAsPosition2d(s32 index); - - //! Sets an attribute as 2d position - virtual void setAttribute(s32 index, core::position2di v); - - /* - - Rectangle Attribute - - */ - - //! Adds an attribute as rectangle - virtual void addRect(const c8* attributeName, core::rect<s32> value); - - //! Sets an attribute as rectangle - virtual void setAttribute(const c8* attributeName, core::rect<s32> v); - - //! Gets an attribute as rectangle - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::rect<s32> getAttributeAsRect(const c8* attributeName); - - //! Gets an attribute as rectangle - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::rect<s32> getAttributeAsRect(s32 index); - - //! Sets an attribute as rectangle - virtual void setAttribute(s32 index, core::rect<s32> v); - - - /* - - matrix attribute - - */ - - //! Adds an attribute as matrix - virtual void addMatrix(const c8* attributeName, const core::matrix4& v); - - //! Sets an attribute as matrix - virtual void setAttribute(const c8* attributeName, const core::matrix4& v); - - //! Gets an attribute as a matrix4 - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::matrix4 getAttributeAsMatrix(const c8* attributeName); - - //! Gets an attribute as matrix - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::matrix4 getAttributeAsMatrix(s32 index); - - //! Sets an attribute as matrix - virtual void setAttribute(s32 index, const core::matrix4& v); - - /* - quaternion attribute - - */ - - //! Adds an attribute as quaternion - virtual void addQuaternion(const c8* attributeName, core::quaternion v); - - //! Sets an attribute as quaternion - virtual void setAttribute(const c8* attributeName, core::quaternion v); - - //! Gets an attribute as a quaternion - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::quaternion getAttributeAsQuaternion(const c8* attributeName); - - //! Gets an attribute as quaternion - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::quaternion getAttributeAsQuaternion(s32 index); - - //! Sets an attribute as quaternion - virtual void setAttribute(s32 index, core::quaternion v); - - /* - - 3d bounding box - - */ - - //! Adds an attribute as axis aligned bounding box - virtual void addBox3d(const c8* attributeName, core::aabbox3df v); - - //! Sets an attribute as axis aligned bounding box - virtual void setAttribute(const c8* attributeName, core::aabbox3df v); - - //! Gets an attribute as a axis aligned bounding box - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::aabbox3df getAttributeAsBox3d(const c8* attributeName); - - //! Gets an attribute as axis aligned bounding box - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::aabbox3df getAttributeAsBox3d(s32 index); - - //! Sets an attribute as axis aligned bounding box - virtual void setAttribute(s32 index, core::aabbox3df v); - - /* - - plane - - */ - - //! Adds an attribute as 3d plane - virtual void addPlane3d(const c8* attributeName, core::plane3df v); - - //! Sets an attribute as 3d plane - virtual void setAttribute(const c8* attributeName, core::plane3df v); - - //! Gets an attribute as a 3d plane - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::plane3df getAttributeAsPlane3d(const c8* attributeName); - - //! Gets an attribute as 3d plane - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::plane3df getAttributeAsPlane3d(s32 index); - - //! Sets an attribute as 3d plane - virtual void setAttribute(s32 index, core::plane3df v); - - - /* - - 3d triangle - - */ - - //! Adds an attribute as 3d triangle - virtual void addTriangle3d(const c8* attributeName, core::triangle3df v); - - //! Sets an attribute as 3d trianle - virtual void setAttribute(const c8* attributeName, core::triangle3df v); - - //! Gets an attribute as a 3d triangle - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::triangle3df getAttributeAsTriangle3d(const c8* attributeName); - - //! Gets an attribute as 3d triangle - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::triangle3df getAttributeAsTriangle3d(s32 index); - - //! Sets an attribute as 3d triangle - virtual void setAttribute(s32 index, core::triangle3df v); - - - /* - - line 2d - - */ - - //! Adds an attribute as a 2d line - virtual void addLine2d(const c8* attributeName, core::line2df v); - - //! Sets an attribute as a 2d line - virtual void setAttribute(const c8* attributeName, core::line2df v); - - //! Gets an attribute as a 2d line - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::line2df getAttributeAsLine2d(const c8* attributeName); - - //! Gets an attribute as a 2d line - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::line2df getAttributeAsLine2d(s32 index); - - //! Sets an attribute as a 2d line - virtual void setAttribute(s32 index, core::line2df v); - - - /* - - line 3d - - */ - - //! Adds an attribute as a 3d line - virtual void addLine3d(const c8* attributeName, core::line3df v); - - //! Sets an attribute as a 3d line - virtual void setAttribute(const c8* attributeName, core::line3df v); - - //! Gets an attribute as a 3d line - //! \param attributeName: Name of the attribute to get. - //! \return Returns value of the attribute previously set by setAttribute() - virtual core::line3df getAttributeAsLine3d(const c8* attributeName); - - //! Gets an attribute as a 3d line - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::line3df getAttributeAsLine3d(s32 index); - - //! Sets an attribute as a 3d line - virtual void setAttribute(s32 index, core::line3df v); - - - /* - - Texture Attribute - - */ - - //! Adds an attribute as texture reference - virtual void addTexture(const c8* attributeName, video::ITexture* texture); - - //! Sets an attribute as texture reference - virtual void setAttribute(const c8* attributeName, video::ITexture* texture ); - - //! Gets an attribute as texture reference - //! \param attributeName: Name of the attribute to get. - virtual video::ITexture* getAttributeAsTexture(const c8* attributeName); - - //! Gets an attribute as texture reference - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual video::ITexture* getAttributeAsTexture(s32 index); - - //! Sets an attribute as texture reference - virtual void setAttribute(s32 index, video::ITexture* texture); - - - - /* - - User Pointer Attribute - - */ - - //! Adds an attribute as user pointner - virtual void addUserPointer(const c8* attributeName, void* userPointer); - - //! Sets an attribute as user pointer - virtual void setAttribute(const c8* attributeName, void* userPointer); - - //! Gets an attribute as user pointer - //! \param attributeName: Name of the attribute to get. - virtual void* getAttributeAsUserPointer(const c8* attributeName); - - //! Gets an attribute as user pointer - //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual void* getAttributeAsUserPointer(s32 index); - - //! Sets an attribute as user pointer - virtual void setAttribute(s32 index, void* userPointer); - -protected: - - void readAttributeFromXML(io::IXMLReader* reader); - - core::array<IAttribute*> Attributes; - - IAttribute* getAttributeP(const c8* attributeName); - - video::IVideoDriver* Driver; -}; - - -class IAttribute : public virtual IReferenceCounted -{ -public: - - virtual ~IAttribute() {}; - - virtual s32 getInt() { return 0; } - virtual f32 getFloat() { return 0; } - virtual video::SColorf getColorf() { return video::SColorf(1.0f,1.0f,1.0f,1.0f); } - virtual video::SColor getColor() { return video::SColor(255,255,255,255); } - virtual core::stringc getString() { return core::stringc(getStringW().c_str()); } - virtual core::stringw getStringW() { return core::stringw(); } - virtual core::array<core::stringw> getArray() { return core::array<core::stringw>(); }; - virtual bool getBool() { return false; } - virtual void getBinary(void* outdata, s32 maxLength) {}; - virtual core::vector3df getVector() { return core::vector3df(); } - virtual core::position2di getPosition() { return core::position2di(); } - virtual core::rect<s32> getRect() { return core::rect<s32>(); } - virtual core::quaternion getQuaternion(){ return core::quaternion(); } - virtual core::matrix4 getMatrix() { return core::matrix4(); } - virtual core::triangle3df getTriangle() { return core::triangle3df(); } - virtual core::vector2df getVector2d() { return core::vector2df(); } - virtual core::vector2di getVector2di() { return core::vector2di(); } - virtual core::line2df getLine2d() { return core::line2df(); } - virtual core::line2di getLine2di() { return core::line2di(); } - virtual core::line3df getLine3d() { return core::line3df(); } - virtual core::line3di getLine3di() { return core::line3di(); } - virtual core::dimension2du getDimension2d() { return core::dimension2du(); } - virtual core::aabbox3d<f32> getBBox() { return core::aabbox3d<f32>(); } - virtual core::plane3df getPlane() { return core::plane3df(); } - - virtual video::ITexture* getTexture() { return 0; } - virtual const char* getEnum() { return 0; } - virtual void* getUserPointer() { return 0; } - - virtual void setInt(s32 intValue) {}; - virtual void setFloat(f32 floatValue) {}; - virtual void setString(const char* text) {}; - virtual void setString(const wchar_t* text){ setString(core::stringc(text).c_str()); }; - virtual void setArray( core::array<core::stringw> arr ) {}; - virtual void setColor(video::SColorf color) {}; - virtual void setColor(video::SColor color) {}; - virtual void setBool(bool boolValue) {}; - virtual void setBinary(void* data, s32 maxLenght) {}; - virtual void setVector(core::vector3df v) {}; - virtual void setPosition(core::position2di v) {}; - virtual void setRect(core::rect<s32> v) {}; - virtual void setQuaternion(core::quaternion v) {}; - virtual void setMatrix(core::matrix4 v) {}; - virtual void setTriangle(core::triangle3df v) {}; - virtual void setVector2d(core::vector2df v) {}; - virtual void setVector2d(core::vector2di v) {}; - virtual void setLine2d(core::line2df v) {}; - virtual void setLine2d(core::line2di v) {}; - virtual void setLine3d(core::line3df v) {}; - virtual void setLine3d(core::line3di v) {}; - virtual void setDimension2d(core::dimension2du v) {}; - virtual void setBBox(core::aabbox3d<f32> v) {}; - virtual void setPlane(core::plane3df v) {}; - virtual void setUserPointer(void* v) {}; - - virtual void setEnum(const char* enumValue, const char* const* enumerationLiterals) {}; - virtual void setTexture(video::ITexture*) {}; - - core::stringc Name; - - virtual E_ATTRIBUTE_TYPE getType() const = 0; - virtual const wchar_t* getTypeString() const = 0; -}; - -} // end namespace io -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CB3DMeshFileLoader.cpp b/irrlicht-1.6/source/Irrlicht/CB3DMeshFileLoader.cpp deleted file mode 100644 index 9e04f2de6..000000000 --- a/irrlicht-1.6/source/Irrlicht/CB3DMeshFileLoader.cpp +++ /dev/null @@ -1,964 +0,0 @@ -// Copyright (C) 2006-2009 Luke Hoschke -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -// B3D Mesh loader -// File format designed by Mark Sibly for the Blitz3D engine and has been -// declared public domain - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_B3D_LOADER_ - -#include "CB3DMeshFileLoader.h" - -#include "IVideoDriver.h" -#include "IFileSystem.h" -#include "os.h" - -#ifdef _DEBUG -#define _B3D_READER_DEBUG -#endif - -namespace irr -{ -namespace scene -{ - -//! Constructor -CB3DMeshFileLoader::CB3DMeshFileLoader(scene::ISceneManager* smgr) -: SceneManager(smgr), AnimatedMesh(0), B3DFile(0), NormalsInFile(false), - ShowWarning(true) -{ - #ifdef _DEBUG - setDebugName("CB3DMeshFileLoader"); - #endif -} - - -//! returns true if the file maybe is able to be loaded by this class -//! based on the file extension (e.g. ".bsp") -bool CB3DMeshFileLoader::isALoadableFileExtension(const io::path& filename) const -{ - return core::hasFileExtension ( filename, "b3d" ); -} - - -//! 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* CB3DMeshFileLoader::createMesh(io::IReadFile* f) -{ - if (!f) - return 0; - - B3DFile = f; - AnimatedMesh = new scene::CSkinnedMesh(); - ShowWarning = true; // If true a warning is issued if too many textures are used - - Buffers = &AnimatedMesh->getMeshBuffers(); - AllJoints = &AnimatedMesh->getAllJoints(); - - if ( load() ) - { - AnimatedMesh->finalize(); - } - else - { - AnimatedMesh->drop(); - AnimatedMesh = 0; - } - - return AnimatedMesh; -} - - -bool CB3DMeshFileLoader::load() -{ - B3dStack.clear(); - - NormalsInFile=false; - - //------ Get header ------ - - SB3dChunkHeader header; - B3DFile->read(&header, sizeof(header)); -#ifdef __BIG_ENDIAN__ - header.size = os::Byteswap::byteswap(header.size); -#endif - - if ( strncmp( header.name, "BB3D", 4 ) != 0 ) - { - os::Printer::log("File is not a b3d file. Loading failed (No header found)", B3DFile->getFileName(), ELL_ERROR); - return false; - } - - // Add main chunk... - B3dStack.push_back(SB3dChunk(header, B3DFile->getPos()-8)); - - // Get file version, but ignore it, as it's not important with b3d files... - s32 fileVersion; - B3DFile->read(&fileVersion, sizeof(fileVersion)); -#ifdef __BIG_ENDIAN__ - fileVersion = os::Byteswap::byteswap(fileVersion); -#endif - - //------ Read main chunk ------ - - while ( (B3dStack.getLast().startposition + B3dStack.getLast().length) > B3DFile->getPos() ) - { - B3DFile->read(&header, sizeof(header)); -#ifdef __BIG_ENDIAN__ - header.size = os::Byteswap::byteswap(header.size); -#endif - B3dStack.push_back(SB3dChunk(header, B3DFile->getPos()-8)); - - if ( strncmp( B3dStack.getLast().name, "TEXS", 4 ) == 0 ) - { - if (!readChunkTEXS()) - return false; - } - else if ( strncmp( B3dStack.getLast().name, "BRUS", 4 ) == 0 ) - { - if (!readChunkBRUS()) - return false; - } - else if ( strncmp( B3dStack.getLast().name, "NODE", 4 ) == 0 ) - { - if (!readChunkNODE((CSkinnedMesh::SJoint*)0) ) - return false; - } - else - { - os::Printer::log("Unknown chunk found in mesh base - skipping"); - B3DFile->seek(B3dStack.getLast().startposition + B3dStack.getLast().length); - B3dStack.erase(B3dStack.size()-1); - } - } - - B3dStack.clear(); - - BaseVertices.clear(); - AnimatedVertices_VertexID.clear(); - AnimatedVertices_BufferID.clear(); - - Materials.clear(); - Textures.clear(); - - Buffers=0; - AllJoints=0; - - return true; -} - - -bool CB3DMeshFileLoader::readChunkNODE(CSkinnedMesh::SJoint *inJoint) -{ - CSkinnedMesh::SJoint *joint = AnimatedMesh->addJoint(inJoint); - readString(joint->Name); - -#ifdef _B3D_READER_DEBUG - os::Printer::log("read ChunkNODE", joint->Name.c_str()); -#endif - - f32 position[3], scale[3], rotation[4]; - - readFloats(position, 3); - readFloats(scale, 3); - readFloats(rotation, 4); - - joint->Animatedposition = core::vector3df(position[0],position[1],position[2]) ; - joint->Animatedscale = core::vector3df(scale[0],scale[1],scale[2]); - joint->Animatedrotation = core::quaternion(rotation[1], rotation[2], rotation[3], rotation[0]); - - //Build LocalMatrix: - - 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; - - if (inJoint) - joint->GlobalMatrix = inJoint->GlobalMatrix * joint->LocalMatrix; - else - joint->GlobalMatrix = joint->LocalMatrix; - - while(B3dStack.getLast().startposition + B3dStack.getLast().length > B3DFile->getPos()) // this chunk repeats - { - SB3dChunkHeader header; - B3DFile->read(&header, sizeof(header)); -#ifdef __BIG_ENDIAN__ - header.size = os::Byteswap::byteswap(header.size); -#endif - - B3dStack.push_back(SB3dChunk(header, B3DFile->getPos()-8)); - - if ( strncmp( B3dStack.getLast().name, "NODE", 4 ) == 0 ) - { - if (!readChunkNODE(joint)) - return false; - } - else if ( strncmp( B3dStack.getLast().name, "MESH", 4 ) == 0 ) - { - if (!readChunkMESH(joint)) - return false; - } - else if ( strncmp( B3dStack.getLast().name, "BONE", 4 ) == 0 ) - { - if (!readChunkBONE(joint)) - return false; - } - else if ( strncmp( B3dStack.getLast().name, "KEYS", 4 ) == 0 ) - { - if(!readChunkKEYS(joint)) - return false; - } - else if ( strncmp( B3dStack.getLast().name, "ANIM", 4 ) == 0 ) - { - if (!readChunkANIM()) - return false; - } - else - { - os::Printer::log("Unknown chunk found in node chunk - skipping"); - B3DFile->seek(B3dStack.getLast().startposition + B3dStack.getLast().length); - B3dStack.erase(B3dStack.size()-1); - } - } - - B3dStack.erase(B3dStack.size()-1); - - return true; -} - - -bool CB3DMeshFileLoader::readChunkMESH(CSkinnedMesh::SJoint *inJoint) -{ -#ifdef _B3D_READER_DEBUG - os::Printer::log("read ChunkMESH"); -#endif - - const s32 vertices_Start=BaseVertices.size(); //B3Ds have Vertex ID's local within the mesh I don't want this - - s32 brush_id; - B3DFile->read(&brush_id, sizeof(brush_id)); -#ifdef __BIG_ENDIAN__ - brush_id = os::Byteswap::byteswap(brush_id); -#endif - - NormalsInFile=false; - - while((B3dStack.getLast().startposition + B3dStack.getLast().length) > B3DFile->getPos()) //this chunk repeats - { - SB3dChunkHeader header; - B3DFile->read(&header, sizeof(header)); -#ifdef __BIG_ENDIAN__ - header.size = os::Byteswap::byteswap(header.size); -#endif - - B3dStack.push_back(SB3dChunk(header, B3DFile->getPos()-8)); - - if ( strncmp( B3dStack.getLast().name, "VRTS", 4 ) == 0 ) - { - if (!readChunkVRTS(inJoint)) - return false; - } - else if ( strncmp( B3dStack.getLast().name, "TRIS", 4 ) == 0 ) - { - scene::SSkinMeshBuffer *meshBuffer = AnimatedMesh->addMeshBuffer(); - - if (brush_id!=-1) - { - loadTextures(Materials[brush_id]); - meshBuffer->Material=Materials[brush_id].Material; - } - - if(readChunkTRIS(meshBuffer,AnimatedMesh->getMeshBuffers().size()-1, vertices_Start)==false) - return false; - - if (!NormalsInFile) - { - s32 i; - - for ( i=0; i<(s32)meshBuffer->Indices.size(); i+=3) - { - core::plane3df p(meshBuffer->getVertex(meshBuffer->Indices[i+0])->Pos, - meshBuffer->getVertex(meshBuffer->Indices[i+1])->Pos, - meshBuffer->getVertex(meshBuffer->Indices[i+2])->Pos); - - meshBuffer->getVertex(meshBuffer->Indices[i+0])->Normal += p.Normal; - meshBuffer->getVertex(meshBuffer->Indices[i+1])->Normal += p.Normal; - meshBuffer->getVertex(meshBuffer->Indices[i+2])->Normal += p.Normal; - } - - for ( i = 0; i<(s32)meshBuffer->getVertexCount(); ++i ) - { - meshBuffer->getVertex(i)->Normal.normalize(); - BaseVertices[vertices_Start+i].Normal=meshBuffer->getVertex(i)->Normal; - } - } - } - else - { - os::Printer::log("Unknown chunk found in mesh - skipping"); - B3DFile->seek(B3dStack.getLast().startposition + B3dStack.getLast().length); - B3dStack.erase(B3dStack.size()-1); - } - } - - B3dStack.erase(B3dStack.size()-1); - - return true; -} - - -/* -VRTS: - int flags ;1=normal values present, 2=rgba values present - int tex_coord_sets ;texture coords per vertex (eg: 1 for simple U/V) max=8 - but we only support 3 - int tex_coord_set_size ;components per set (eg: 2 for simple U/V) max=4 - { - float x,y,z ;always present - float nx,ny,nz ;vertex normal: present if (flags&1) - float red,green,blue,alpha ;vertex color: present if (flags&2) - float tex_coords[tex_coord_sets][tex_coord_set_size] ;tex coords - } -*/ -bool CB3DMeshFileLoader::readChunkVRTS(CSkinnedMesh::SJoint *inJoint) -{ -#ifdef _B3D_READER_DEBUG - os::Printer::log("read ChunkVRTS"); -#endif - - const s32 max_tex_coords = 3; - s32 flags, tex_coord_sets, tex_coord_set_size; - - B3DFile->read(&flags, sizeof(flags)); - B3DFile->read(&tex_coord_sets, sizeof(tex_coord_sets)); - B3DFile->read(&tex_coord_set_size, sizeof(tex_coord_set_size)); -#ifdef __BIG_ENDIAN__ - flags = os::Byteswap::byteswap(flags); - tex_coord_sets = os::Byteswap::byteswap(tex_coord_sets); - tex_coord_set_size = os::Byteswap::byteswap(tex_coord_set_size); -#endif - - if (tex_coord_sets >= max_tex_coords || tex_coord_set_size >= 4) // Something is wrong - { - os::Printer::log("tex_coord_sets or tex_coord_set_size too big", B3DFile->getFileName(), ELL_ERROR); - return false; - } - - //------ Allocate Memory, for speed -----------// - - s32 NumberOfReads = 3; - - if (flags & 1) - NumberOfReads += 3; - if (flags & 2) - NumberOfReads += 4; - - NumberOfReads += tex_coord_sets*tex_coord_set_size; - - const s32 memoryNeeded = (B3dStack.getLast().length / sizeof(f32)) / NumberOfReads; - - BaseVertices.reallocate(memoryNeeded + BaseVertices.size() + 1); - AnimatedVertices_VertexID.reallocate(memoryNeeded + AnimatedVertices_VertexID.size() + 1); - - //--------------------------------------------// - - while( (B3dStack.getLast().startposition + B3dStack.getLast().length) > B3DFile->getPos()) // this chunk repeats - { - f32 position[3]; - f32 normal[3]={0.f, 0.f, 0.f}; - f32 color[4]={1.0f, 1.0f, 1.0f, 1.0f}; - f32 tex_coords[max_tex_coords][4]; - - readFloats(position, 3); - - if (flags & 1) - { - NormalsInFile = true; - readFloats(normal, 3); - } - - if (flags & 2) - readFloats(color, 4); - - for (s32 i=0; i<tex_coord_sets; ++i) - readFloats(tex_coords[i], tex_coord_set_size); - - f32 tu=0.0f, tv=0.0f; - if (tex_coord_sets >= 1 && tex_coord_set_size >= 2) - { - tu=tex_coords[0][0]; - tv=tex_coords[0][1]; - } - - f32 tu2=0.0f, tv2=0.0f; - if (tex_coord_sets>1 && tex_coord_set_size>1) - { - tu2=tex_coords[1][0]; - tv2=tex_coords[1][1]; - } - - // Create Vertex... - video::S3DVertex2TCoords Vertex(position[0], position[1], position[2], - normal[0], normal[1], normal[2], - video::SColorf(color[0], color[1], color[2], color[3]).toSColor(), - tu, tv, tu2, tv2); - - // Transform the Vertex position by nested node... - inJoint->GlobalMatrix.transformVect(Vertex.Pos); - inJoint->GlobalMatrix.rotateVect(Vertex.Normal); - - //Add it... - BaseVertices.push_back(Vertex); - - AnimatedVertices_VertexID.push_back(-1); - AnimatedVertices_BufferID.push_back(-1); - } - - B3dStack.erase(B3dStack.size()-1); - - return true; -} - - -bool CB3DMeshFileLoader::readChunkTRIS(scene::SSkinMeshBuffer *meshBuffer, u32 meshBufferID, s32 vertices_Start) -{ -#ifdef _B3D_READER_DEBUG - os::Printer::log("read ChunkTRIS"); -#endif - - bool showVertexWarning=false; - - s32 triangle_brush_id; // Note: Irrlicht can't have different brushes for each triangle (using a workaround) - B3DFile->read(&triangle_brush_id, sizeof(triangle_brush_id)); -#ifdef __BIG_ENDIAN__ - triangle_brush_id = os::Byteswap::byteswap(triangle_brush_id); -#endif - - SB3dMaterial *B3dMaterial; - - if (triangle_brush_id != -1) - { - loadTextures(Materials[triangle_brush_id]); - B3dMaterial = &Materials[triangle_brush_id]; - meshBuffer->Material = B3dMaterial->Material; - } - else - B3dMaterial = 0; - - const s32 memoryNeeded = B3dStack.getLast().length / sizeof(s32); - meshBuffer->Indices.reallocate(memoryNeeded + meshBuffer->Indices.size() + 1); - - while((B3dStack.getLast().startposition + B3dStack.getLast().length) > B3DFile->getPos()) // this chunk repeats - { - s32 vertex_id[3]; - - B3DFile->read(vertex_id, 3*sizeof(s32)); -#ifdef __BIG_ENDIAN__ - vertex_id[0] = os::Byteswap::byteswap(vertex_id[0]); - vertex_id[1] = os::Byteswap::byteswap(vertex_id[1]); - vertex_id[2] = os::Byteswap::byteswap(vertex_id[2]); -#endif - - //Make Ids global: - vertex_id[0] += vertices_Start; - vertex_id[1] += vertices_Start; - vertex_id[2] += vertices_Start; - - for(s32 i=0; i<3; ++i) - { - if ((u32)vertex_id[i] >= AnimatedVertices_VertexID.size()) - { - os::Printer::log("Illegal vertex index found", B3DFile->getFileName(), ELL_ERROR); - return false; - } - - if (AnimatedVertices_VertexID[ vertex_id[i] ] != -1) - { - if ( AnimatedVertices_BufferID[ vertex_id[i] ] != (s32)meshBufferID ) //If this vertex is linked in a different meshbuffer - { - AnimatedVertices_VertexID[ vertex_id[i] ] = -1; - AnimatedVertices_BufferID[ vertex_id[i] ] = -1; - showVertexWarning=true; - } - } - if (AnimatedVertices_VertexID[ vertex_id[i] ] == -1) //If this vertex is not in the meshbuffer - { - //Check for lightmapping: - if (BaseVertices[ vertex_id[i] ].TCoords2 != core::vector2df(0.f,0.f)) - meshBuffer->MoveTo_2TCoords(); //Will only affect the meshbuffer the first time this is called - - //Add the vertex to the meshbuffer: - if (meshBuffer->VertexType == video::EVT_STANDARD) - meshBuffer->Vertices_Standard.push_back( BaseVertices[ vertex_id[i] ] ); - else - meshBuffer->Vertices_2TCoords.push_back(BaseVertices[ vertex_id[i] ] ); - - //create vertex id to meshbuffer index link: - AnimatedVertices_VertexID[ vertex_id[i] ] = meshBuffer->getVertexCount()-1; - AnimatedVertices_BufferID[ vertex_id[i] ] = meshBufferID; - - if (B3dMaterial) - { - // Apply Material/Color/etc... - video::S3DVertex *Vertex=meshBuffer->getVertex(meshBuffer->getVertexCount()-1); - - if (Vertex->Color.getAlpha() == 255) - Vertex->Color.setAlpha( (s32)(B3dMaterial->alpha * 255.0f) ); - - // Use texture's scale - if (B3dMaterial->Textures[0]) - { - Vertex->TCoords.X *= B3dMaterial->Textures[0]->Xscale; - Vertex->TCoords.Y *= B3dMaterial->Textures[0]->Yscale; - } - /* - if (B3dMaterial->Textures[1]) - { - Vertex->TCoords2.X *=B3dMaterial->Textures[1]->Xscale; - Vertex->TCoords2.Y *=B3dMaterial->Textures[1]->Yscale; - } - */ - } - } - } - - meshBuffer->Indices.push_back( AnimatedVertices_VertexID[ vertex_id[0] ] ); - meshBuffer->Indices.push_back( AnimatedVertices_VertexID[ vertex_id[1] ] ); - meshBuffer->Indices.push_back( AnimatedVertices_VertexID[ vertex_id[2] ] ); - } - - B3dStack.erase(B3dStack.size()-1); - - if (showVertexWarning) - os::Printer::log("B3dMeshLoader: Warning, different meshbuffers linking to the same vertex, this will cause problems with animated meshes"); - - return true; -} - - -bool CB3DMeshFileLoader::readChunkBONE(CSkinnedMesh::SJoint *inJoint) -{ -#ifdef _B3D_READER_DEBUG - os::Printer::log("read ChunkBONE"); -#endif - - if (B3dStack.getLast().length > 8) - { - while((B3dStack.getLast().startposition + B3dStack.getLast().length) > B3DFile->getPos()) // this chunk repeats - { - CSkinnedMesh::SWeight *weight=AnimatedMesh->addWeight(inJoint); - - u32 globalVertexID; - - B3DFile->read(&globalVertexID, sizeof(globalVertexID)); - B3DFile->read(&weight->strength, sizeof(weight->strength)); -#ifdef __BIG_ENDIAN__ - globalVertexID = os::Byteswap::byteswap(globalVertexID); - weight->strength = os::Byteswap::byteswap(weight->strength); -#endif - - if (AnimatedVertices_VertexID[globalVertexID]==-1) - { - os::Printer::log("B3dMeshLoader: Weight has bad vertex id (no link to meshbuffer index found)"); - weight->vertex_id = weight->buffer_id = 0; - } - else - { - //Find the meshbuffer and Vertex index from the Global Vertex ID: - weight->vertex_id = AnimatedVertices_VertexID[globalVertexID]; - weight->buffer_id = AnimatedVertices_BufferID[globalVertexID]; - } - } - } - - B3dStack.erase(B3dStack.size()-1); - return true; -} - - -bool CB3DMeshFileLoader::readChunkKEYS(CSkinnedMesh::SJoint *inJoint) -{ -#ifdef _B3D_READER_DEBUG -// os::Printer::log("read ChunkKEYS"); -#endif - - s32 flags; - B3DFile->read(&flags, sizeof(flags)); -#ifdef __BIG_ENDIAN__ - flags = os::Byteswap::byteswap(flags); -#endif - - while((B3dStack.getLast().startposition + B3dStack.getLast().length) > B3DFile->getPos()) //this chunk repeats - { - s32 frame; - - B3DFile->read(&frame, sizeof(frame)); - #ifdef __BIG_ENDIAN__ - frame = os::Byteswap::byteswap(frame); - #endif - - // Add key frames, frames in Irrlicht are zero-based - f32 data[4]; - if (flags & 1) - { - readFloats(data, 3); - CSkinnedMesh::SPositionKey *Key=AnimatedMesh->addPositionKey(inJoint); - Key->frame = (f32)frame-1; - Key->position.set(data[0], data[1], data[2]); - } - if (flags & 2) - { - readFloats(data, 3); - CSkinnedMesh::SScaleKey *Key=AnimatedMesh->addScaleKey(inJoint); - Key->frame = (f32)frame-1; - Key->scale.set(data[0], data[1], data[2]); - } - if (flags & 4) - { - readFloats(data, 4); - CSkinnedMesh::SRotationKey *Key=AnimatedMesh->addRotationKey(inJoint); - Key->frame = (f32)frame-1; - // meant to be in this order since b3d stores W first - Key->rotation.set(data[1], data[2], data[3], data[0]); - } - } - - B3dStack.erase(B3dStack.size()-1); - return true; -} - - -bool CB3DMeshFileLoader::readChunkANIM() -{ -#ifdef _B3D_READER_DEBUG - os::Printer::log("read ChunkANIM"); -#endif - - s32 animFlags; //not stored\used - s32 animFrames;//not stored\used - f32 animFPS; //not stored\used - - B3DFile->read(&animFlags, sizeof(s32)); - B3DFile->read(&animFrames, sizeof(s32)); - readFloats(&animFPS, 1); - - #ifdef __BIG_ENDIAN__ - animFlags = os::Byteswap::byteswap(animFlags); - animFrames = os::Byteswap::byteswap(animFrames); - #endif - - B3dStack.erase(B3dStack.size()-1); - return true; -} - - -bool CB3DMeshFileLoader::readChunkTEXS() -{ -#ifdef _B3D_READER_DEBUG - os::Printer::log("read ChunkTEXS"); -#endif - - while((B3dStack.getLast().startposition + B3dStack.getLast().length) > B3DFile->getPos()) //this chunk repeats - { - Textures.push_back(SB3dTexture()); - SB3dTexture& B3dTexture = Textures.getLast(); - - readString(B3dTexture.TextureName); - B3dTexture.TextureName.replace('\\','/'); -#ifdef _B3D_READER_DEBUG - os::Printer::log("read Texture", B3dTexture.TextureName.c_str()); -#endif - - B3DFile->read(&B3dTexture.Flags, sizeof(s32)); - B3DFile->read(&B3dTexture.Blend, sizeof(s32)); -#ifdef __BIG_ENDIAN__ - B3dTexture.Flags = os::Byteswap::byteswap(B3dTexture.Flags); - B3dTexture.Blend = os::Byteswap::byteswap(B3dTexture.Blend); -#endif -#ifdef _B3D_READER_DEBUG - os::Printer::log("Flags", core::stringc(B3dTexture.Flags).c_str()); - os::Printer::log("Blend", core::stringc(B3dTexture.Blend).c_str()); -#endif - readFloats(&B3dTexture.Xpos, 1); - readFloats(&B3dTexture.Ypos, 1); - readFloats(&B3dTexture.Xscale, 1); - readFloats(&B3dTexture.Yscale, 1); - readFloats(&B3dTexture.Angle, 1); - } - - B3dStack.erase(B3dStack.size()-1); - - return true; -} - - -bool CB3DMeshFileLoader::readChunkBRUS() -{ -#ifdef _B3D_READER_DEBUG - os::Printer::log("read ChunkBRUS"); -#endif - - u32 n_texs; - B3DFile->read(&n_texs, sizeof(u32)); -#ifdef __BIG_ENDIAN__ - n_texs = os::Byteswap::byteswap(n_texs); -#endif - - // number of texture ids read for Irrlicht - const u32 num_textures = core::min_(n_texs, video::MATERIAL_MAX_TEXTURES); - // number of bytes to skip (for ignored texture ids) - const u32 n_texs_offset = (num_textures<n_texs)?(n_texs-num_textures):0; - - while((B3dStack.getLast().startposition + B3dStack.getLast().length) > B3DFile->getPos()) //this chunk repeats - { - // This is what blitz basic calls a brush, like a Irrlicht Material - - core::stringc name; - readString(name); -#ifdef _B3D_READER_DEBUG - os::Printer::log("read Material"); -#endif - Materials.push_back(SB3dMaterial()); - SB3dMaterial& B3dMaterial=Materials.getLast(); - - readFloats(&B3dMaterial.red, 1); - readFloats(&B3dMaterial.green, 1); - readFloats(&B3dMaterial.blue, 1); - readFloats(&B3dMaterial.alpha, 1); - readFloats(&B3dMaterial.shininess, 1); - - B3DFile->read(&B3dMaterial.blend, sizeof(B3dMaterial.blend)); - B3DFile->read(&B3dMaterial.fx, sizeof(B3dMaterial.fx)); -#ifdef __BIG_ENDIAN__ - B3dMaterial.blend = os::Byteswap::byteswap(B3dMaterial.blend); - B3dMaterial.fx = os::Byteswap::byteswap(B3dMaterial.fx); -#endif -#ifdef _B3D_READER_DEBUG - os::Printer::log("Blend", core::stringc(B3dMaterial.blend).c_str()); - os::Printer::log("FX", core::stringc(B3dMaterial.fx).c_str()); -#endif - - u32 i; - for (i=0; i<num_textures; ++i) - { - s32 texture_id=-1; - B3DFile->read(&texture_id, sizeof(s32)); -#ifdef __BIG_ENDIAN__ - texture_id = os::Byteswap::byteswap(texture_id); -#endif - //--- Get pointers to the texture, based on the IDs --- - if ((u32)texture_id < Textures.size()) - { - B3dMaterial.Textures[i]=&Textures[texture_id]; -#ifdef _B3D_READER_DEBUG - os::Printer::log("Layer", core::stringc(i).c_str()); - os::Printer::log("using texture", Textures[texture_id].TextureName.c_str()); -#endif - } - else - B3dMaterial.Textures[i]=0; - } - // skip other texture ids - for (i=0; i<n_texs_offset; ++i) - { - s32 texture_id=-1; - B3DFile->read(&texture_id, sizeof(s32)); -#ifdef __BIG_ENDIAN__ - texture_id = os::Byteswap::byteswap(texture_id); -#endif - if (ShowWarning && (texture_id != -1) && (n_texs>video::MATERIAL_MAX_TEXTURES)) - { - os::Printer::log("Too many textures used in one material", B3DFile->getFileName(), ELL_WARNING); - ShowWarning = false; - } - } - - //Fixes problems when the lightmap is on the first texture: - if (B3dMaterial.Textures[0] != 0) - { - if (B3dMaterial.Textures[0]->Flags & 65536) // 65536 = secondary UV - { - SB3dTexture *TmpTexture; - TmpTexture = B3dMaterial.Textures[1]; - B3dMaterial.Textures[1] = B3dMaterial.Textures[0]; - B3dMaterial.Textures[0] = TmpTexture; - } - } - - //If a preceeding texture slot is empty move the others down: - for (i=num_textures; i>0; --i) - { - for (u32 j=i-1; j<num_textures-1; ++j) - { - if (B3dMaterial.Textures[j+1] != 0 && B3dMaterial.Textures[j] == 0) - { - B3dMaterial.Textures[j] = B3dMaterial.Textures[j+1]; - B3dMaterial.Textures[j+1] = 0; - } - } - } - - //------ Convert blitz flags/blend to irrlicht ------- - - //Two textures: - if (B3dMaterial.Textures[1]) - { - if (B3dMaterial.alpha==1.f) - { - if (B3dMaterial.Textures[1]->Blend == 5) //(Multiply 2) - B3dMaterial.Material.MaterialType = video::EMT_LIGHTMAP_M2; - else - B3dMaterial.Material.MaterialType = video::EMT_LIGHTMAP; - B3dMaterial.Material.Lighting = false; - } - else - { - B3dMaterial.Material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA; - B3dMaterial.Material.ZWriteEnable = false; - } - } - else if (B3dMaterial.Textures[0]) //One texture: - { - // Flags & 0x1 is usual SOLID, 0x8 is mipmap (handled before) - if (B3dMaterial.Textures[0]->Flags & 0x2) //(Alpha mapped) - { - B3dMaterial.Material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; - B3dMaterial.Material.ZWriteEnable = false; - } - else if (B3dMaterial.Textures[0]->Flags & 0x4) //(Masked) - B3dMaterial.Material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; // TODO: create color key texture - else if (B3dMaterial.Textures[0]->Flags & 0x40) - B3dMaterial.Material.MaterialType = video::EMT_SPHERE_MAP; - else if (B3dMaterial.Textures[0]->Flags & 0x80) - B3dMaterial.Material.MaterialType = video::EMT_SPHERE_MAP; // TODO: Should be cube map - else if (B3dMaterial.alpha == 1.f) - B3dMaterial.Material.MaterialType = video::EMT_SOLID; - else - { - B3dMaterial.Material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA; - B3dMaterial.Material.ZWriteEnable = false; - } - } - else //No texture: - { - if (B3dMaterial.alpha == 1.f) - B3dMaterial.Material.MaterialType = video::EMT_SOLID; - else - { - B3dMaterial.Material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA; - B3dMaterial.Material.ZWriteEnable = false; - } - } - - B3dMaterial.Material.DiffuseColor = video::SColorf(B3dMaterial.red, B3dMaterial.green, B3dMaterial.blue, B3dMaterial.alpha).toSColor(); - - //------ Material fx ------ - - if (B3dMaterial.fx & 1) //full-bright - { - B3dMaterial.Material.AmbientColor = video::SColor(255, 255, 255, 255); - B3dMaterial.Material.Lighting = false; - } - else - B3dMaterial.Material.AmbientColor = B3dMaterial.Material.DiffuseColor; - - //if (B3dMaterial.fx & 2) //use vertex colors instead of brush color - - if (B3dMaterial.fx & 4) //flatshaded - B3dMaterial.Material.GouraudShading = false; - - if (B3dMaterial.fx & 16) //disable backface culling - B3dMaterial.Material.BackfaceCulling = false; - - if (B3dMaterial.fx & 32) //force vertex alpha-blending - { - B3dMaterial.Material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA; - B3dMaterial.Material.ZWriteEnable = false; - } - - B3dMaterial.Material.Shininess = B3dMaterial.shininess; - } - - B3dStack.erase(B3dStack.size()-1); - - return true; -} - - -void CB3DMeshFileLoader::loadTextures(SB3dMaterial& material) const -{ - const bool previous32BitTextureFlag = SceneManager->getVideoDriver()->getTextureCreationFlag(video::ETCF_ALWAYS_32_BIT); - SceneManager->getVideoDriver()->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true); - - // read texture from disk - // note that mipmaps might be disabled by Flags & 0x8 - const bool doMipMaps = SceneManager->getVideoDriver()->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS); - - for (u32 i=0; i<video::MATERIAL_MAX_TEXTURES; ++i) - { - SB3dTexture* B3dTexture = material.Textures[i]; - if (B3dTexture && B3dTexture->TextureName.size() && !material.Material.getTexture(i)) - { - if (!SceneManager->getParameters()->getAttributeAsBool(B3D_LOADER_IGNORE_MIPMAP_FLAG)) - SceneManager->getVideoDriver()->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, (B3dTexture->Flags & 0x8) ? true:false); - { - video::ITexture* tex = 0; - io::IFileSystem* fs = SceneManager->getFileSystem(); - if (fs->existFile(B3dTexture->TextureName)) - tex = SceneManager->getVideoDriver()->getTexture(B3dTexture->TextureName); - else if (fs->existFile(fs->getFileDir(B3DFile->getFileName()) +"/"+ fs->getFileBasename(B3dTexture->TextureName))) - tex = SceneManager->getVideoDriver()->getTexture(fs->getFileDir(B3DFile->getFileName()) +"/"+ fs->getFileBasename(B3dTexture->TextureName)); - else - tex = SceneManager->getVideoDriver()->getTexture(fs->getFileBasename(B3dTexture->TextureName)); - - material.Material.setTexture(i, tex); - } - if (material.Textures[i]->Flags & 0x10) // Clamp U - material.Material.TextureLayer[i].TextureWrap=video::ETC_CLAMP; - if (material.Textures[i]->Flags & 0x20) // Clamp V - material.Material.TextureLayer[i].TextureWrap=video::ETC_CLAMP; - } - } - - SceneManager->getVideoDriver()->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, doMipMaps); - SceneManager->getVideoDriver()->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, previous32BitTextureFlag); -} - - -void CB3DMeshFileLoader::readString(core::stringc& newstring) -{ - newstring=""; - while (B3DFile->getPos() <= B3DFile->getSize()) - { - c8 character; - B3DFile->read(&character, sizeof(character)); - if (character==0) - return; - newstring.append(character); - } -} - - -void CB3DMeshFileLoader::readFloats(f32* vec, u32 count) -{ - B3DFile->read(vec, count*sizeof(f32)); - #ifdef __BIG_ENDIAN__ - for (u32 n=0; n<count; ++n) - vec[n] = os::Byteswap::byteswap(vec[n]); - #endif -} - -} // end namespace scene -} // end namespace irr - - -#endif // _IRR_COMPILE_WITH_B3D_LOADER_ - diff --git a/irrlicht-1.6/source/Irrlicht/CB3DMeshFileLoader.h b/irrlicht-1.6/source/Irrlicht/CB3DMeshFileLoader.h deleted file mode 100644 index ba7da8577..000000000 --- a/irrlicht-1.6/source/Irrlicht/CB3DMeshFileLoader.h +++ /dev/null @@ -1,138 +0,0 @@ -// Copyright (C) 2006-2009 Luke Hoschke -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -// B3D Mesh loader -// File format designed by Mark Sibly for the Blitz3D engine and has been -// declared public domain - -#include "IrrCompileConfig.h" - -#ifndef __C_B3D_MESH_LOADER_H_INCLUDED__ -#define __C_B3D_MESH_LOADER_H_INCLUDED__ - -#include "IMeshLoader.h" -#include "ISceneManager.h" -#include "CSkinnedMesh.h" -#include "IReadFile.h" - -namespace irr -{ - -namespace scene -{ - -//! Meshloader for B3D format -class CB3DMeshFileLoader : public IMeshLoader -{ -public: - - //! Constructor - CB3DMeshFileLoader(scene::ISceneManager* smgr); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".bsp") - virtual bool isALoadableFileExtension(const io::path& 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: - - struct SB3dChunkHeader - { - c8 name[4]; - s32 size; - }; - - struct SB3dChunk - { - SB3dChunk(const SB3dChunkHeader& header, long sp) - : length(header.size+8), startposition(sp) - { - name[0]=header.name[0]; - name[1]=header.name[1]; - name[2]=header.name[2]; - name[3]=header.name[3]; - } - - c8 name[4]; - s32 length; - long startposition; - }; - - struct SB3dTexture - { - core::stringc TextureName; - s32 Flags; - s32 Blend; - f32 Xpos; - f32 Ypos; - f32 Xscale; - f32 Yscale; - f32 Angle; - }; - - struct SB3dMaterial - { - SB3dMaterial() : red(1.0f), green(1.0f), - blue(1.0f), alpha(1.0f), shininess(0.0f), blend(1), - fx(0) - { - for (u32 i=0; i<video::MATERIAL_MAX_TEXTURES; ++i) - Textures[i]=0; - } - video::SMaterial Material; - f32 red, green, blue, alpha; - f32 shininess; - s32 blend,fx; - SB3dTexture *Textures[video::MATERIAL_MAX_TEXTURES]; - }; - - bool load(); - bool readChunkNODE(CSkinnedMesh::SJoint* InJoint); - bool readChunkMESH(CSkinnedMesh::SJoint* InJoint); - bool readChunkVRTS(CSkinnedMesh::SJoint* InJoint); - bool readChunkTRIS(scene::SSkinMeshBuffer *MeshBuffer, u32 MeshBufferID, s32 Vertices_Start); - bool readChunkBONE(CSkinnedMesh::SJoint* InJoint); - bool readChunkKEYS(CSkinnedMesh::SJoint* InJoint); - bool readChunkANIM(); - bool readChunkTEXS(); - bool readChunkBRUS(); - - void loadTextures(SB3dMaterial& material) const; - - void readString(core::stringc& newstring); - void readFloats(f32* vec, u32 count); - - core::array<SB3dChunk> B3dStack; - - core::array<SB3dMaterial> Materials; - core::array<SB3dTexture> Textures; - - core::array<s32> AnimatedVertices_VertexID; - - core::array<s32> AnimatedVertices_BufferID; - - core::array<video::S3DVertex2TCoords> BaseVertices; - - core::array<scene::SSkinMeshBuffer*> *Buffers; - core::array<CSkinnedMesh::SJoint*> *AllJoints; - - ISceneManager* SceneManager; - CSkinnedMesh* AnimatedMesh; - io::IReadFile* B3DFile; - - bool NormalsInFile; - bool ShowWarning; -}; - - -} // end namespace scene -} // end namespace irr - -#endif // __C_B3D_MESH_LOADER_H_INCLUDED__ - diff --git a/irrlicht-1.6/source/Irrlicht/CBSPMeshFileLoader.cpp b/irrlicht-1.6/source/Irrlicht/CBSPMeshFileLoader.cpp deleted file mode 100644 index 21196ec6f..000000000 --- a/irrlicht-1.6/source/Irrlicht/CBSPMeshFileLoader.cpp +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright (C) 2002-2009 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_BSP_LOADER_ - -#include "CBSPMeshFileLoader.h" -#include "CQ3LevelMesh.h" - -namespace irr -{ -namespace scene -{ - -//! Constructor -CBSPMeshFileLoader::CBSPMeshFileLoader(scene::ISceneManager* smgr, - io::IFileSystem* fs) -: FileSystem(fs), SceneManager(smgr) -{ - - #ifdef _DEBUG - setDebugName("CBSPMeshFileLoader"); - #endif - - if (FileSystem) - FileSystem->grab(); -} - - -//! destructor -CBSPMeshFileLoader::~CBSPMeshFileLoader() -{ - if (FileSystem) - FileSystem->drop(); -} - - -//! returns true if the file maybe is able to be loaded by this class -//! based on the file extension (e.g. ".bsp") -bool CBSPMeshFileLoader::isALoadableFileExtension(const io::path& filename) const -{ - return core::hasFileExtension ( filename, "bsp", "shader", "cfg" ); -} - - -//! 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* CBSPMeshFileLoader::createMesh(io::IReadFile* file) -{ - s32 type = core::isFileExtension ( file->getFileName(), "bsp", "shader", "cfg" ); - CQ3LevelMesh* q = 0; - - switch ( type ) - { - case 1: - q = new CQ3LevelMesh(FileSystem, SceneManager, LoadParam); - - // determine real shaders in LoadParam - if ( 0 == LoadParam.loadAllShaders ) - { - q->getShader("scripts/common.shader"); - q->getShader("scripts/sfx.shader"); - q->getShader("scripts/gfx.shader"); - q->getShader("scripts/liquid.shader"); - q->getShader("scripts/models.shader"); - q->getShader("scripts/walls.shader"); - //q->getShader("scripts/sky.shader"); - } - - if ( q->loadFile(file) ) - return q; - - q->drop(); - break; - - case 2: - q = new CQ3LevelMesh(FileSystem, SceneManager,LoadParam); - q->getShader( file ); - return q; - break; - - case 3: - // load quake 3 loading parameter - if ( file->getFileName() == "levelparameter.cfg" ) - { - file->read ( &LoadParam, sizeof ( LoadParam ) ); - } - else - { - q = new CQ3LevelMesh(FileSystem, SceneManager,LoadParam); - q->getConfiguration( file ); - return q; - } - break; - } - - return 0; -} - -} // end namespace scene -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BSP_LOADER_ - diff --git a/irrlicht-1.6/source/Irrlicht/CBSPMeshFileLoader.h b/irrlicht-1.6/source/Irrlicht/CBSPMeshFileLoader.h deleted file mode 100644 index 42c44bf00..000000000 --- a/irrlicht-1.6/source/Irrlicht/CBSPMeshFileLoader.h +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_BSP_MESH_FILE_LOADER_H_INCLUDED__ -#define __C_BSP_MESH_FILE_LOADER_H_INCLUDED__ - -#include "IMeshLoader.h" -#include "IFileSystem.h" -#include "IVideoDriver.h" -#include "ISceneManager.h" -#include "IQ3Shader.h" - -namespace irr -{ -namespace scene -{ - -//! Meshloader capable of loading Quake 3 BSP files and shaders -class CBSPMeshFileLoader : public IMeshLoader -{ -public: - - //! Constructor - CBSPMeshFileLoader(scene::ISceneManager* smgr, io::IFileSystem* fs); - - //! destructor - virtual ~CBSPMeshFileLoader(); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".bsp") - virtual bool isALoadableFileExtension(const io::path& 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: - - io::IFileSystem* FileSystem; - scene::ISceneManager* SceneManager; - - quake3::Q3LevelLoadParameter LoadParam; -}; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CBillboardSceneNode.cpp b/irrlicht-1.6/source/Irrlicht/CBillboardSceneNode.cpp deleted file mode 100644 index 2e0798966..000000000 --- a/irrlicht-1.6/source/Irrlicht/CBillboardSceneNode.cpp +++ /dev/null @@ -1,241 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CBillboardSceneNode.h" -#include "IVideoDriver.h" -#include "ISceneManager.h" -#include "ICameraSceneNode.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CBillboardSceneNode::CBillboardSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position, const core::dimension2d<f32>& size, - video::SColor colorTop, video::SColor colorBottom) - : IBillboardSceneNode(parent, mgr, id, position) -{ - #ifdef _DEBUG - setDebugName("CBillboardSceneNode"); - #endif - - setSize(size); - - indices[0] = 0; - indices[1] = 2; - indices[2] = 1; - indices[3] = 0; - indices[4] = 3; - indices[5] = 2; - - vertices[0].TCoords.set(1.0f, 1.0f); - vertices[0].Color = colorBottom; - - vertices[1].TCoords.set(1.0f, 0.0f); - vertices[1].Color = colorTop; - - vertices[2].TCoords.set(0.0f, 0.0f); - vertices[2].Color = colorTop; - - vertices[3].TCoords.set(0.0f, 1.0f); - vertices[3].Color = colorBottom; -} - - -//! pre render event -void CBillboardSceneNode::OnRegisterSceneNode() -{ - if (IsVisible) - SceneManager->registerNodeForRendering(this); - - ISceneNode::OnRegisterSceneNode(); -} - - -//! render -void CBillboardSceneNode::render() -{ - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - ICameraSceneNode* camera = SceneManager->getActiveCamera(); - - if (!camera || !driver) - return; - - // make billboard look to camera - - core::vector3df pos = getAbsolutePosition(); - - core::vector3df campos = camera->getAbsolutePosition(); - core::vector3df target = camera->getTarget(); - core::vector3df up = camera->getUpVector(); - core::vector3df view = target - campos; - view.normalize(); - - core::vector3df horizontal = up.crossProduct(view); - if ( horizontal.getLength() == 0 ) - { - horizontal.set(up.Y,up.X,up.Z); - } - horizontal.normalize(); - horizontal *= 0.5f * Size.Width; - - core::vector3df vertical = horizontal.crossProduct(view); - vertical.normalize(); - vertical *= 0.5f * Size.Height; - - view *= -1.0f; - - for (s32 i=0; i<4; ++i) - vertices[i].Normal = view; - - vertices[0].Pos = pos + horizontal + vertical; - vertices[1].Pos = pos + horizontal - vertical; - vertices[2].Pos = pos - horizontal - vertical; - vertices[3].Pos = pos - horizontal + vertical; - - // draw - - if ( DebugDataVisible & scene::EDS_BBOX ) - { - driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); - video::SMaterial m; - m.Lighting = false; - driver->setMaterial(m); - driver->draw3DBox(BBox, video::SColor(0,208,195,152)); - } - - driver->setTransform(video::ETS_WORLD, core::IdentityMatrix); - - driver->setMaterial(Material); - - driver->drawIndexedTriangleList(vertices, 4, indices, 2); -} - - -//! returns the axis aligned bounding box of this node -const core::aabbox3d<f32>& CBillboardSceneNode::getBoundingBox() const -{ - return BBox; -} - - -//! sets the size of the billboard -void CBillboardSceneNode::setSize(const core::dimension2d<f32>& size) -{ - Size = size; - - if (Size.Width == 0.0f) - Size.Width = 1.0f; - - if (Size.Height == 0.0f ) - Size.Height = 1.0f; - - f32 avg = (size.Width + size.Height)/6; - BBox.MinEdge.set(-avg,-avg,-avg); - BBox.MaxEdge.set(avg,avg,avg); -} - - -video::SMaterial& CBillboardSceneNode::getMaterial(u32 i) -{ - return Material; -} - - -//! returns amount of materials used by this scene node. -u32 CBillboardSceneNode::getMaterialCount() const -{ - return 1; -} - - -//! gets the size of the billboard -const core::dimension2d<f32>& CBillboardSceneNode::getSize() const -{ - return Size; -} - - -//! Writes attributes of the scene node. -void CBillboardSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const -{ - IBillboardSceneNode::serializeAttributes(out, options); - - out->addFloat("Width", Size.Width); - out->addFloat("Height", Size.Height); - out->addColor ("Shade_Top", vertices[1].Color ); - out->addColor ("Shade_Down", vertices[0].Color ); -} - - -//! Reads attributes of the scene node. -void CBillboardSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - IBillboardSceneNode::deserializeAttributes(in, options); - - Size.Width = in->getAttributeAsFloat("Width"); - Size.Height = in->getAttributeAsFloat("Height"); - vertices[1].Color = in->getAttributeAsColor ( "Shade_Top" ); - vertices[0].Color = in->getAttributeAsColor ( "Shade_Down" ); - - setSize(Size); -} - - -//! Set the color of all vertices of the billboard -//! \param overallColor: the color to set -void CBillboardSceneNode::setColor(const video::SColor & overallColor) -{ - for(u32 vertex = 0; vertex < 4; ++vertex) - vertices[vertex].Color = overallColor; -} - - -//! Set the color of the top and bottom vertices of the billboard -//! \param topColor: the color to set the top vertices -//! \param bottomColor: the color to set the bottom vertices -void CBillboardSceneNode::setColor(const video::SColor & topColor, const video::SColor & bottomColor) -{ - vertices[0].Color = bottomColor; - vertices[1].Color = topColor; - vertices[2].Color = topColor; - vertices[3].Color = bottomColor; -} - - -//! Gets the color of the top and bottom vertices of the billboard -//! \param[out] topColor: stores the color of the top vertices -//! \param[out] bottomColor: stores the color of the bottom vertices -void CBillboardSceneNode::getColor(video::SColor & topColor, video::SColor & bottomColor) const -{ - bottomColor = vertices[0].Color; - topColor = vertices[1].Color; -} - - -//! Creates a clone of this scene node and its children. -ISceneNode* CBillboardSceneNode::clone(ISceneNode* newParent, ISceneManager* newManager) -{ - if (!newParent) - newParent = Parent; - if (!newManager) - newManager = SceneManager; - - CBillboardSceneNode* nb = new CBillboardSceneNode(newParent, - newManager, ID, RelativeTranslation, Size); - - nb->cloneMembers(this, newManager); - nb->Material = Material; - - nb->drop(); - return nb; -} - - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CBillboardSceneNode.h b/irrlicht-1.6/source/Irrlicht/CBillboardSceneNode.h deleted file mode 100644 index ae705269e..000000000 --- a/irrlicht-1.6/source/Irrlicht/CBillboardSceneNode.h +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_BILLBOARD_SCENE_NODE_H_INCLUDED__ -#define __C_BILLBOARD_SCENE_NODE_H_INCLUDED__ - -#include "IBillboardSceneNode.h" -#include "S3DVertex.h" - -namespace irr -{ -namespace scene -{ - -//! Scene node which is a billboard. A billboard is like a 3d sprite: A 2d element, -//! which always looks to the camera. -class CBillboardSceneNode : virtual public IBillboardSceneNode -{ -public: - - //! constructor - CBillboardSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position, const core::dimension2d<f32>& size, - video::SColor colorTop=video::SColor(0xFFFFFFFF),video::SColor colorBottom=video::SColor(0xFFFFFFFF)); - - //! pre render event - virtual void OnRegisterSceneNode(); - - //! render - virtual void render(); - - //! returns the axis aligned bounding box of this node - virtual const core::aabbox3d<f32>& getBoundingBox() const; - - //! sets the size of the billboard - virtual void setSize(const core::dimension2d<f32>& size); - - //! gets the size of the billboard - virtual const core::dimension2d<f32>& getSize() const; - - virtual video::SMaterial& getMaterial(u32 i); - - //! returns amount of materials used by this scene node. - virtual u32 getMaterialCount() const; - - //! Set the color of all vertices of the billboard - //! \param overallColor: the color to set - virtual void setColor(const video::SColor & overallColor); - - //! Set the color of the top and bottom vertices of the billboard - //! \param topColor: the color to set the top vertices - //! \param bottomColor: the color to set the bottom vertices - virtual void setColor(const video::SColor & topColor, const video::SColor & bottomColor); - - //! Gets the color of the top and bottom vertices of the billboard - //! \param[out] topColor: stores the color of the top vertices - //! \param[out] bottomColor: stores the color of the bottom vertices - virtual void getColor(video::SColor& topColor, video::SColor& bottomColor) const; - - //! Writes attributes of the scene node. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const; - - //! Reads attributes of the scene node. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() const { return ESNT_BILLBOARD; } - - //! Creates a clone of this scene node and its children. - virtual ISceneNode* clone(ISceneNode* newParent=0, ISceneManager* newManager=0); - -private: - - core::dimension2d<f32> Size; - core::aabbox3d<f32> BBox; - video::SMaterial Material; - - video::S3DVertex vertices[4]; - u16 indices[6]; -}; - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CBlit.h b/irrlicht-1.6/source/Irrlicht/CBlit.h deleted file mode 100644 index d65b83e1e..000000000 --- a/irrlicht-1.6/source/Irrlicht/CBlit.h +++ /dev/null @@ -1,969 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef _C_BLIT_H_INCLUDED_ -#define _C_BLIT_H_INCLUDED_ - -#include "SoftwareDriver2_helper.h" - -namespace irr -{ - - struct SBlitJob - { - AbsRectangle Dest; - AbsRectangle Source; - - u32 argb; - - void * src; - void * dst; - - s32 width; - s32 height; - - u32 srcPitch; - u32 dstPitch; - - u32 srcPixelMul; - u32 dstPixelMul; - }; - - - // Bitfields Cohen Sutherland - enum eClipCode - { - CLIPCODE_EMPTY = 0, - CLIPCODE_BOTTOM = 1, - CLIPCODE_TOP = 2, - CLIPCODE_LEFT = 4, - CLIPCODE_RIGHT = 8 - }; - -inline u32 GetClipCode( const AbsRectangle &r, const core::position2d<s32> &p ) -{ - u32 code = CLIPCODE_EMPTY; - - if ( p.X < r.x0 ) - code = CLIPCODE_LEFT; - else - if ( p.X > r.x1 ) - code = CLIPCODE_RIGHT; - - if ( p.Y < r.y0 ) - code |= CLIPCODE_TOP; - else - if ( p.Y > r.y1 ) - code |= CLIPCODE_BOTTOM; - - return code; -} - - -/*! - Cohen Sutherland clipping - @return: 1 if valid -*/ - -static int ClipLine(const AbsRectangle &clipping, - core::position2d<s32> &p0, - core::position2d<s32> &p1, - const core::position2d<s32>& p0_in, - const core::position2d<s32>& p1_in) -{ - u32 code0; - u32 code1; - u32 code; - - p0 = p0_in; - p1 = p1_in; - - code0 = GetClipCode( clipping, p0 ); - code1 = GetClipCode( clipping, p1 ); - - // trivial accepted - while ( code0 | code1 ) - { - s32 x=0; - s32 y=0; - - // trivial reject - if ( code0 & code1 ) - return 0; - - if ( code0 ) - { - // clip first point - code = code0; - } - else - { - // clip last point - code = code1; - } - - if ( (code & CLIPCODE_BOTTOM) == CLIPCODE_BOTTOM ) - { - // clip bottom viewport - y = clipping.y1; - x = p0.X + ( p1.X - p0.X ) * ( y - p0.Y ) / ( p1.Y - p0.Y ); - } - else - if ( (code & CLIPCODE_TOP) == CLIPCODE_TOP ) - { - // clip to viewport - y = clipping.y0; - x = p0.X + ( p1.X - p0.X ) * ( y - p0.Y ) / ( p1.Y - p0.Y ); - } - else - if ( (code & CLIPCODE_RIGHT) == CLIPCODE_RIGHT ) - { - // clip right viewport - x = clipping.x1; - y = p0.Y + ( p1.Y - p0.Y ) * ( x - p0.X ) / ( p1.X - p0.X ); - } - else - if ( (code & CLIPCODE_LEFT) == CLIPCODE_LEFT ) - { - // clip left viewport - x = clipping.x0; - y = p0.Y + ( p1.Y - p0.Y ) * ( x - p0.X ) / ( p1.X - p0.X ); - } - - if ( code == code0 ) - { - // modify first point - p0.X = x; - p0.Y = y; - code0 = GetClipCode( clipping, p0 ); - } - else - { - // modify second point - p1.X = x; - p1.Y = y; - code1 = GetClipCode( clipping, p1 ); - } - } - - return 1; -} - -/* -*/ -inline void GetClip(AbsRectangle &clipping, video::IImage * t) -{ - clipping.x0 = 0; - clipping.y0 = 0; - clipping.x1 = t->getDimension().Width - 1; - clipping.y1 = t->getDimension().Height - 1; -} - -/* - return alpha in [0;256] Granularity from 32-Bit ARGB - add highbit alpha ( alpha > 127 ? + 1 ) -*/ -static inline u32 extractAlpha ( const u32 c ) -{ - return ( c >> 24 ) + ( c >> 31 ); -} - -/* - return alpha in [0;255] Granularity and 32-Bit ARGB - add highbit alpha ( alpha > 127 ? + 1 ) -*/ -static inline u32 packAlpha ( const u32 c ) -{ - return (c > 127 ? c - 1 : c) << 24; -} - - -/*! - Scale Color by (1/value) - value 0 - 256 ( alpha ) -*/ -inline u32 PixelLerp32 ( const u32 source, const u32 value ) -{ - u32 srcRB = source & 0x00FF00FF; - u32 srcXG = (source & 0xFF00FF00) >> 8; - - srcRB *= value; - srcXG *= value; - - srcRB >>= 8; - //srcXG >>= 8; - - srcXG &= 0xFF00FF00; - srcRB &= 0x00FF00FF; - - return srcRB | srcXG; -} - - -/* -*/ -static void RenderLine32_Decal(video::IImage *t, - const core::position2d<s32> &p0, - const core::position2d<s32> &p1, - u32 argb ) -{ - s32 dx = p1.X - p0.X; - s32 dy = p1.Y - p0.Y; - - s32 c; - s32 m; - s32 d = 0; - s32 run; - - s32 xInc = 4; - s32 yInc = (s32) t->getPitch(); - - if ( dx < 0 ) - { - xInc = -xInc; - dx = -dx; - } - - if ( dy < 0 ) - { - yInc = -yInc; - dy = -dy; - } - - u32 *dst; - dst = (u32*) ( (u8*) t->lock() + ( p0.Y * t->getPitch() ) + ( p0.X << 2 ) ); - - if ( dy > dx ) - { - s32 tmp; - tmp = dx; - dx = dy; - dy = tmp; - tmp = xInc; - xInc = yInc; - yInc = tmp; - } - - c = dx << 1; - m = dy << 1; - - run = dx; - while ( run ) - { - *dst = argb; - - dst = (u32*) ( (u8*) dst + xInc ); // x += xInc - d += m; - if ( d > dx ) - { - dst = (u32*) ( (u8*) dst + yInc ); // y += yInc - d -= c; - } - run -= 1; - } - - t->unlock(); -} - - -/* -*/ -static void RenderLine32_Blend(video::IImage *t, - const core::position2d<s32> &p0, - const core::position2d<s32> &p1, - u32 argb, u32 alpha) -{ - s32 dx = p1.X - p0.X; - s32 dy = p1.Y - p0.Y; - - s32 c; - s32 m; - s32 d = 0; - s32 run; - - s32 xInc = 4; - s32 yInc = (s32) t->getPitch(); - - if ( dx < 0 ) - { - xInc = -xInc; - dx = -dx; - } - - if ( dy < 0 ) - { - yInc = -yInc; - dy = -dy; - } - - u32 *dst; - dst = (u32*) ( (u8*) t->lock() + ( p0.Y * t->getPitch() ) + ( p0.X << 2 ) ); - - if ( dy > dx ) - { - s32 tmp; - tmp = dx; - dx = dy; - dy = tmp; - tmp = xInc; - xInc = yInc; - yInc = tmp; - } - - c = dx << 1; - m = dy << 1; - - run = dx; - const u32 packA = packAlpha ( alpha ); - while ( run ) - { - *dst = packA | PixelBlend32( *dst, argb, alpha ); - - dst = (u32*) ( (u8*) dst + xInc ); // x += xInc - d += m; - if ( d > dx ) - { - dst = (u32*) ( (u8*) dst + yInc ); // y += yInc - d -= c; - } - run -= 1; - } - - t->unlock(); -} - -/* -*/ -static void RenderLine16_Decal(video::IImage *t, - const core::position2d<s32> &p0, - const core::position2d<s32> &p1, - u32 argb ) -{ - s32 dx = p1.X - p0.X; - s32 dy = p1.Y - p0.Y; - - s32 c; - s32 m; - s32 d = 0; - s32 run; - - s32 xInc = 2; - s32 yInc = (s32) t->getPitch(); - - if ( dx < 0 ) - { - xInc = -xInc; - dx = -dx; - } - - if ( dy < 0 ) - { - yInc = -yInc; - dy = -dy; - } - - u16 *dst; - dst = (u16*) ( (u8*) t->lock() + ( p0.Y * t->getPitch() ) + ( p0.X << 1 ) ); - - if ( dy > dx ) - { - s32 tmp; - tmp = dx; - dx = dy; - dy = tmp; - tmp = xInc; - xInc = yInc; - yInc = tmp; - } - - c = dx << 1; - m = dy << 1; - - run = dx; - while ( run ) - { - *dst = (u16)argb; - - dst = (u16*) ( (u8*) dst + xInc ); // x += xInc - d += m; - if ( d > dx ) - { - dst = (u16*) ( (u8*) dst + yInc ); // y += yInc - d -= c; - } - run -= 1; - } - - t->unlock(); -} - -/* -*/ -static void RenderLine16_Blend(video::IImage *t, - const core::position2d<s32> &p0, - const core::position2d<s32> &p1, - u16 argb, - u16 alpha) -{ - s32 dx = p1.X - p0.X; - s32 dy = p1.Y - p0.Y; - - s32 c; - s32 m; - s32 d = 0; - s32 run; - - s32 xInc = 2; - s32 yInc = (s32) t->getPitch(); - - if ( dx < 0 ) - { - xInc = -xInc; - dx = -dx; - } - - if ( dy < 0 ) - { - yInc = -yInc; - dy = -dy; - } - - u16 *dst; - dst = (u16*) ( (u8*) t->lock() + ( p0.Y * t->getPitch() ) + ( p0.X << 1 ) ); - - if ( dy > dx ) - { - s32 tmp; - tmp = dx; - dx = dy; - dy = tmp; - tmp = xInc; - xInc = yInc; - yInc = tmp; - } - - c = dx << 1; - m = dy << 1; - - run = dx; - const u16 packA = alpha ? 0x8000 : 0; - while ( run ) - { - *dst = packA | PixelBlend16( *dst, argb, alpha ); - - dst = (u16*) ( (u8*) dst + xInc ); // x += xInc - d += m; - if ( d > dx ) - { - dst = (u16*) ( (u8*) dst + yInc ); // y += yInc - d -= c; - } - run -= 1; - } - - t->unlock(); -} - - -/*! -*/ -static void executeBlit_TextureCopy_x_to_x( const SBlitJob * job ) -{ - const void *src = (void*) job->src; - void *dst = (void*) job->dst; - - const u32 widthPitch = job->width * job->dstPixelMul; - for ( s32 dy = 0; dy != job->height; ++dy ) - { - memcpy( dst, src, widthPitch ); - - src = (void*) ( (u8*) (src) + job->srcPitch ); - dst = (void*) ( (u8*) (dst) + job->dstPitch ); - } -} - - -/*! -*/ -static void executeBlit_TextureCopy_32_to_16( const SBlitJob * job ) -{ - const u32 *src = static_cast<const u32*>(job->src); - u16 *dst = static_cast<u16*>(job->dst); - - for ( s32 dy = 0; dy != job->height; ++dy ) - { - for ( s32 dx = 0; dx != job->width; ++dx ) - { - //16 bit Blitter depends on pre-multiplied color - const u32 s = PixelLerp32( src[dx] | 0xFF000000, extractAlpha( src[dx] ) ); - dst[dx] = video::A8R8G8B8toA1R5G5B5( s ); - } - - src = (u32*) ( (u8*) (src) + job->srcPitch ); - dst = (u16*) ( (u8*) (dst) + job->dstPitch ); - } -} - -/*! -*/ -static void executeBlit_TextureCopy_24_to_16( const SBlitJob * job ) -{ - const void *src = (void*) job->src; - u16 *dst = (u16*) job->dst; - - for ( s32 dy = 0; dy != job->height; ++dy ) - { - u8 * s = (u8*) src; - - for ( s32 dx = 0; dx != job->width; ++dx ) - { - dst[dx] = video::RGBA16(s[0], s[1], s[2]); - s += 3; - } - - src = (void*) ( (u8*) (src) + job->srcPitch ); - dst = (u16*) ( (u8*) (dst) + job->dstPitch ); - } -} - - -/*! -*/ -static void executeBlit_TextureCopy_16_to_32( const SBlitJob * job ) -{ - const u16 *src = (u16*) job->src; - u32 *dst = (u32*) job->dst; - - for ( s32 dy = 0; dy != job->height; ++dy ) - { - for ( s32 dx = 0; dx != job->width; ++dx ) - { - dst[dx] = video::A1R5G5B5toA8R8G8B8( src[dx] ); - } - - src = (u16*) ( (u8*) (src) + job->srcPitch ); - dst = (u32*) ( (u8*) (dst) + job->dstPitch ); - } -} - -static void executeBlit_TextureCopy_16_to_24( const SBlitJob * job ) -{ - const u16 *src = (u16*) job->src; - u8 *dst = (u8*) job->dst; - - for ( s32 dy = 0; dy != job->height; ++dy ) - { - for ( s32 dx = 0; dx != job->width; ++dx ) - { - u32 colour = video::A1R5G5B5toA8R8G8B8( src[dx] ); - u8 * writeTo = &dst[dx * 3]; - *writeTo++ = (colour >> 16)& 0xFF; - *writeTo++ = (colour >> 8) & 0xFF; - *writeTo++ = colour & 0xFF; - } - - src = (u16*) ( (u8*) (src) + job->srcPitch ); - dst += job->dstPitch; - } -} - - -/*! -*/ -static void executeBlit_TextureCopy_24_to_32( const SBlitJob * job ) -{ - void *src = (void*) job->src; - u32 *dst = (u32*) job->dst; - - for ( s32 dy = 0; dy != job->height; ++dy ) - { - u8 * s = (u8*) src; - - for ( s32 dx = 0; dx != job->width; ++dx ) - { - dst[dx] = 0xFF000000 | s[0] << 16 | s[1] << 8 | s[2]; - s += 3; - } - - src = (void*) ( (u8*) (src) + job->srcPitch ); - dst = (u32*) ( (u8*) (dst) + job->dstPitch ); - } -} - -static void executeBlit_TextureCopy_32_to_24( const SBlitJob * job ) -{ - const u32 * src = (u32*) job->src; - u8 * dst = (u8*) job->dst; - - for ( s32 dy = 0; dy != job->height; ++dy ) - { - for ( s32 dx = 0; dx != job->width; ++dx ) - { - u8 * writeTo = &dst[dx * 3]; - *writeTo++ = (src[dx] >> 16)& 0xFF; - *writeTo++ = (src[dx] >> 8) & 0xFF; - *writeTo++ = src[dx] & 0xFF; - } - - src = (u32*) ( (u8*) (src) + job->srcPitch ); - dst += job->dstPitch ; - } - -} - - -/*! -*/ -static void executeBlit_TextureBlend_16_to_16( const SBlitJob * job ) -{ - u32 dx; - s32 dy; - - u32 *src = (u32*) job->src; - u32 *dst = (u32*) job->dst; - - - const u32 rdx = job->width >> 1; - const u32 off = core::if_c_a_else_b( job->width & 1 ,job->width - 1, 0 ); - - - for ( dy = 0; dy != job->height; ++dy ) - { - for ( dx = 0; dx != rdx; ++dx ) - { - dst[dx] = PixelBlend16_simd( dst[dx], src[dx] ); - } - - if ( off ) - { - ((u16*) dst)[off] = PixelBlend16( ((u16*) dst)[off], ((u16*) src)[off] ); - } - - src = (u32*) ( (u8*) (src) + job->srcPitch ); - dst = (u32*) ( (u8*) (dst) + job->dstPitch ); - } -} - -/*! -*/ -static void executeBlit_TextureBlend_32_to_32( const SBlitJob * job ) -{ - u32 *src = (u32*) job->src; - u32 *dst = (u32*) job->dst; - - for ( s32 dy = 0; dy != job->height; ++dy ) - { - for ( s32 dx = 0; dx != job->width; ++dx ) - { - dst[dx] = PixelBlend32( dst[dx], src[dx] ); - } - src = (u32*) ( (u8*) (src) + job->srcPitch ); - dst = (u32*) ( (u8*) (dst) + job->dstPitch ); - } -} - -/*! -*/ -static void executeBlit_TextureBlendColor_16_to_16( const SBlitJob * job ) -{ - u16 *src = (u16*) job->src; - u16 *dst = (u16*) job->dst; - - u16 blend = video::A8R8G8B8toA1R5G5B5 ( job->argb ); - for ( s32 dy = 0; dy != job->height; ++dy ) - { - for ( s32 dx = 0; dx != job->width; ++dx ) - { - if ( 0 == (src[dx] & 0x8000) ) - continue; - - dst[dx] = PixelMul16_2( src[dx], blend ); - } - src = (u16*) ( (u8*) (src) + job->srcPitch ); - dst = (u16*) ( (u8*) (dst) + job->dstPitch ); - } -} - - -/*! -*/ -static void executeBlit_TextureBlendColor_32_to_32( const SBlitJob * job ) -{ - u32 *src = (u32*) job->src; - u32 *dst = (u32*) job->dst; - - for ( s32 dy = 0; dy != job->height; ++dy ) - { - for ( s32 dx = 0; dx != job->width; ++dx ) - { - dst[dx] = PixelBlend32( dst[dx], PixelMul32_2( src[dx], job->argb ) ); - } - src = (u32*) ( (u8*) (src) + job->srcPitch ); - dst = (u32*) ( (u8*) (dst) + job->dstPitch ); - } -} - -/*! -*/ -static void executeBlit_Color_16_to_16( const SBlitJob * job ) -{ - u16 *dst = (u16*) job->dst; - - u16 c0 = video::A8R8G8B8toA1R5G5B5( job->argb ); - u32 c = c0 | c0 << 16; - - if ( 0 == (job->srcPitch & 3 ) ) - { - for ( s32 dy = 0; dy != job->height; ++dy ) - { - memset32( dst, c, job->srcPitch ); - dst = (u16*) ( (u8*) (dst) + job->dstPitch ); - } - } - else - { - s32 dx = job->width - 1; - - for ( s32 dy = 0; dy != job->height; ++dy ) - { - memset32( dst, c, job->srcPitch ); - dst[dx] = c0; - dst = (u16*) ( (u8*) (dst) + job->dstPitch ); - } - - } -} - -/*! -*/ -static void executeBlit_Color_32_to_32( const SBlitJob * job ) -{ - u32 *dst = (u32*) job->dst; - - for ( s32 dy = 0; dy != job->height; ++dy ) - { - memset32( dst, job->argb, job->srcPitch ); - dst = (u32*) ( (u8*) (dst) + job->dstPitch ); - } -} - -/*! -*/ -static void executeBlit_ColorAlpha_16_to_16( const SBlitJob * job ) -{ - u16 *dst = (u16*) job->dst; - - const u16 alpha = extractAlpha( job->argb ) >> 3; - if ( 0 == alpha ) - return; - const u32 src = video::A8R8G8B8toA1R5G5B5( job->argb ); - - for ( s32 dy = 0; dy != job->height; ++dy ) - { - for ( s32 dx = 0; dx != job->width; ++dx ) - { - dst[dx] = 0x8000 | PixelBlend16( dst[dx], src, alpha ); - } - dst = (u16*) ( (u8*) (dst) + job->dstPitch ); - } -} - -/*! -*/ -static void executeBlit_ColorAlpha_32_to_32( const SBlitJob * job ) -{ - u32 *dst = (u32*) job->dst; - - const u32 alpha = extractAlpha( job->argb ); - const u32 src = job->argb; - - for ( s32 dy = 0; dy != job->height; ++dy ) - { - for ( s32 dx = 0; dx != job->width; ++dx ) - { - dst[dx] = (job->argb & 0xFF000000 ) | PixelBlend32( dst[dx], src, alpha ); - } - dst = (u32*) ( (u8*) (dst) + job->dstPitch ); - } -} - -// Blitter Operation -enum eBlitter -{ - BLITTER_INVALID = 0, - BLITTER_COLOR, - BLITTER_COLOR_ALPHA, - BLITTER_TEXTURE, - BLITTER_TEXTURE_ALPHA_BLEND, - BLITTER_TEXTURE_ALPHA_COLOR_BLEND -}; - -typedef void (*tExecuteBlit) ( const SBlitJob * job ); - - -/*! -*/ -struct blitterTable -{ - eBlitter operation; - s32 destFormat; - s32 sourceFormat; - tExecuteBlit func; -}; - -static const blitterTable blitTable[] = -{ - { BLITTER_TEXTURE, -2, -2, executeBlit_TextureCopy_x_to_x }, - { BLITTER_TEXTURE, video::ECF_A1R5G5B5, video::ECF_A8R8G8B8, executeBlit_TextureCopy_32_to_16 }, - { BLITTER_TEXTURE, video::ECF_A1R5G5B5, video::ECF_R8G8B8, executeBlit_TextureCopy_24_to_16 }, - { BLITTER_TEXTURE, video::ECF_A8R8G8B8, video::ECF_A1R5G5B5, executeBlit_TextureCopy_16_to_32 }, - { BLITTER_TEXTURE, video::ECF_A8R8G8B8, video::ECF_R8G8B8, executeBlit_TextureCopy_24_to_32 }, - { BLITTER_TEXTURE, video::ECF_R8G8B8, video::ECF_A1R5G5B5, executeBlit_TextureCopy_16_to_24 }, - { BLITTER_TEXTURE, video::ECF_R8G8B8, video::ECF_A8R8G8B8, executeBlit_TextureCopy_32_to_24 }, - { BLITTER_TEXTURE_ALPHA_BLEND, video::ECF_A1R5G5B5, video::ECF_A1R5G5B5, executeBlit_TextureBlend_16_to_16 }, - { BLITTER_TEXTURE_ALPHA_BLEND, video::ECF_A8R8G8B8, video::ECF_A8R8G8B8, executeBlit_TextureBlend_32_to_32 }, - { BLITTER_TEXTURE_ALPHA_COLOR_BLEND, video::ECF_A1R5G5B5, video::ECF_A1R5G5B5, executeBlit_TextureBlendColor_16_to_16 }, - { BLITTER_TEXTURE_ALPHA_COLOR_BLEND, video::ECF_A8R8G8B8, video::ECF_A8R8G8B8, executeBlit_TextureBlendColor_32_to_32 }, - { BLITTER_COLOR, video::ECF_A1R5G5B5, -1, executeBlit_Color_16_to_16 }, - { BLITTER_COLOR, video::ECF_A8R8G8B8, -1, executeBlit_Color_32_to_32 }, - { BLITTER_COLOR_ALPHA, video::ECF_A1R5G5B5, -1, executeBlit_ColorAlpha_16_to_16 }, - { BLITTER_COLOR_ALPHA, video::ECF_A8R8G8B8, -1, executeBlit_ColorAlpha_32_to_32 }, - { BLITTER_INVALID, -1, -1, 0 } -}; - - -static inline tExecuteBlit getBlitter2( eBlitter operation,const video::IImage * dest,const video::IImage * source ) -{ - video::ECOLOR_FORMAT sourceFormat = (video::ECOLOR_FORMAT) ( source ? source->getColorFormat() : -1 ); - video::ECOLOR_FORMAT destFormat = (video::ECOLOR_FORMAT) ( dest ? dest->getColorFormat() : -1 ); - - const blitterTable * b = blitTable; - - while ( b->operation != BLITTER_INVALID ) - { - if ( b->operation == operation ) - { - if (( b->destFormat == -1 || b->destFormat == destFormat ) && - ( b->sourceFormat == -1 || b->sourceFormat == sourceFormat ) ) - return b->func; - else - if ( b->destFormat == -2 && ( sourceFormat == destFormat ) ) - return b->func; - } - b += 1; - } - return 0; -} - - -// bounce clipping to texture -inline void setClip ( AbsRectangle &out, const core::rect<s32> *clip, - const video::IImage * tex, s32 passnative ) -{ - if ( clip && 0 == tex && passnative ) - { - out.x0 = clip->UpperLeftCorner.X; - out.x1 = clip->LowerRightCorner.X; - out.y0 = clip->UpperLeftCorner.Y; - out.y1 = clip->LowerRightCorner.Y; - return; - } - - const s32 w = tex ? tex->getDimension().Width : 0; - const s32 h = tex ? tex->getDimension().Height : 0; - if ( clip ) - { - out.x0 = core::s32_clamp ( clip->UpperLeftCorner.X, 0, w ); - out.x1 = core::s32_clamp ( clip->LowerRightCorner.X, out.x0, w ); - out.y0 = core::s32_clamp ( clip->UpperLeftCorner.Y, 0, h ); - out.y1 = core::s32_clamp ( clip->LowerRightCorner.Y, out.y0, h ); - } - else - { - out.x0 = 0; - out.y0 = 0; - out.x1 = w; - out.y1 = h; - } - -} - -/*! - a generic 2D Blitter -*/ -static s32 Blit(eBlitter operation, - video::IImage * dest, - const core::rect<s32> *destClipping, - const core::position2d<s32> *destPos, - video::IImage * const source, - const core::rect<s32> *sourceClipping, - u32 argb) -{ - tExecuteBlit blitter = getBlitter2( operation, dest, source ); - if ( 0 == blitter ) - { - return 0; - } - - // Clipping - AbsRectangle sourceClip; - AbsRectangle destClip; - AbsRectangle v; - - SBlitJob job; - - setClip ( sourceClip, sourceClipping, source, 1 ); - setClip ( destClip, destClipping, dest, 0 ); - - v.x0 = destPos ? destPos->X : 0; - v.y0 = destPos ? destPos->Y : 0; - v.x1 = v.x0 + ( sourceClip.x1 - sourceClip.x0 ); - v.y1 = v.y0 + ( sourceClip.y1 - sourceClip.y0 ); - - if ( !intersect( job.Dest, destClip, v ) ) - return 0; - - job.width = job.Dest.x1 - job.Dest.x0; - job.height = job.Dest.y1 - job.Dest.y0; - - - job.Source.x0 = sourceClip.x0 + ( job.Dest.x0 - v.x0 ); - job.Source.x1 = job.Source.x0 + job.width; - - job.Source.y0 = sourceClip.y0 + ( job.Dest.y0 - v.y0 ); - job.Source.y1 = job.Source.y0 + job.height; - - job.argb = argb; - - if ( source ) - { - job.srcPitch = source->getPitch(); - job.srcPixelMul = source->getBytesPerPixel(); - job.src = (void*) ( (u8*) source->lock() + ( job.Source.y0 * job.srcPitch ) + ( job.Source.x0 * job.srcPixelMul ) ); - } - else - { - // use srcPitch for color operation on dest - job.srcPitch = job.width * dest->getBytesPerPixel(); - } - - job.dstPitch = dest->getPitch(); - job.dstPixelMul = dest->getBytesPerPixel(); - job.dst = (void*) ( (u8*) dest->lock() + ( job.Dest.y0 * job.dstPitch ) + ( job.Dest.x0 * job.dstPixelMul ) ); - - blitter( &job ); - - if ( source ) - source->unlock(); - - if ( dest ) - dest->unlock(); - - return 1; -} - -} - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CBoneSceneNode.cpp b/irrlicht-1.6/source/Irrlicht/CBoneSceneNode.cpp deleted file mode 100644 index 3363cd2f0..000000000 --- a/irrlicht-1.6/source/Irrlicht/CBoneSceneNode.cpp +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright (C) 2002-2009 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_SKINNED_MESH_SUPPORT_ - -#include "CBoneSceneNode.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CBoneSceneNode::CBoneSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - u32 boneIndex, const c8* boneName) -: IBoneSceneNode(parent, mgr, id), BoneIndex(boneIndex), - AnimationMode(EBAM_AUTOMATIC), SkinningSpace(EBSS_LOCAL) -{ - #ifdef _DEBUG - setDebugName("CBoneSceneNode"); - #endif - setName(boneName); -} - - -//! Returns the index of the bone -u32 CBoneSceneNode::getBoneIndex() const -{ - return BoneIndex; -} - - -//! Sets the animation mode of the bone. Returns true if successful. -bool CBoneSceneNode::setAnimationMode(E_BONE_ANIMATION_MODE mode) -{ - AnimationMode = mode; - return true; -} - - -//! Gets the current animation mode of the bone -E_BONE_ANIMATION_MODE CBoneSceneNode::getAnimationMode() const -{ - return AnimationMode; -} - - -//! returns the axis aligned bounding box of this node -const core::aabbox3d<f32>& CBoneSceneNode::getBoundingBox() const -{ - return Box; -} - - -/* -//! Returns the relative transformation of the scene node. -core::matrix4 CBoneSceneNode::getRelativeTransformation() const -{ - return core::matrix4(); // RelativeTransformation; -} -*/ - - -void CBoneSceneNode::OnAnimate(u32 timeMs) -{ - if (IsVisible) - { - // animate this node with all animators - - core::list<ISceneNodeAnimator*>::Iterator ait = Animators.begin(); - for (; ait != Animators.end(); ++ait) - (*ait)->animateNode(this, timeMs); - - // update absolute position - //updateAbsolutePosition(); - - // perform the post render process on all children - core::list<ISceneNode*>::Iterator it = Children.begin(); - for (; it != Children.end(); ++it) - (*it)->OnAnimate(timeMs); - } -} - - -void CBoneSceneNode::helper_updateAbsolutePositionOfAllChildren(ISceneNode *Node) -{ - Node->updateAbsolutePosition(); - - core::list<ISceneNode*>::ConstIterator it = Node->getChildren().begin(); - for (; it != Node->getChildren().end(); ++it) - { - helper_updateAbsolutePositionOfAllChildren( (*it) ); - } -} - - -void CBoneSceneNode::updateAbsolutePositionOfAllChildren() -{ - helper_updateAbsolutePositionOfAllChildren( this ); -} - - -void CBoneSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const -{ - IBoneSceneNode::serializeAttributes(out, options); - out->addInt("BoneIndex", BoneIndex); - out->addEnum("AnimationMode", AnimationMode, BoneAnimationModeNames); -} - - -void CBoneSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - BoneIndex = in->getAttributeAsInt("BoneIndex"); - AnimationMode = (E_BONE_ANIMATION_MODE)in->getAttributeAsEnumeration("AnimationMode", BoneAnimationModeNames); - // for legacy files (before 1.5) - const core::stringc boneName = in->getAttributeAsString("BoneName"); - setName(boneName); - IBoneSceneNode::deserializeAttributes(in, options); - // TODO: add/replace bone in parent with bone from mesh -} - - -} // namespace scene -} // namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CBoneSceneNode.h b/irrlicht-1.6/source/Irrlicht/CBoneSceneNode.h deleted file mode 100644 index f6528e70d..000000000 --- a/irrlicht-1.6/source/Irrlicht/CBoneSceneNode.h +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_BONE_SCENE_NODE_H_INCLUDED__ -#define __C_BONE_SCENE_NODE_H_INCLUDED__ - -// Used with SkinnedMesh and IAnimatedMeshSceneNode, for boned meshes - -#include "IBoneSceneNode.h" - -namespace irr -{ -namespace scene -{ - - class CBoneSceneNode : public IBoneSceneNode - { - public: - - //! constructor - CBoneSceneNode(ISceneNode* parent, ISceneManager* mgr, - s32 id=-1, u32 boneIndex=0, const c8* boneName=0); - - //! Returns the index of the bone - virtual u32 getBoneIndex() const; - - //! Sets the animation mode of the bone. Returns true if successful. - virtual bool setAnimationMode(E_BONE_ANIMATION_MODE mode); - - //! Gets the current animation mode of the bone - virtual E_BONE_ANIMATION_MODE getAnimationMode() const; - - //! returns the axis aligned bounding box of this node - virtual const core::aabbox3d<f32>& getBoundingBox() const; - - /* - //! Returns the relative transformation of the scene node. - //virtual core::matrix4 getRelativeTransformation() const; - */ - - virtual void OnAnimate(u32 timeMs); - - virtual void updateAbsolutePositionOfAllChildren(); - - //! Writes attributes of the scene node. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const; - - //! Reads attributes of the scene node. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - //! How the relative transformation of the bone is used - virtual void setSkinningSpace( E_BONE_SKINNING_SPACE space ) - { - SkinningSpace=space; - } - - virtual E_BONE_SKINNING_SPACE getSkinningSpace() const - { - return SkinningSpace; - } - - private: - void helper_updateAbsolutePositionOfAllChildren(ISceneNode *Node); - - u32 BoneIndex; - - core::aabbox3d<f32> Box; - - E_BONE_ANIMATION_MODE AnimationMode; - E_BONE_SKINNING_SPACE SkinningSpace; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CBurningShader_Raster_Reference.cpp b/irrlicht-1.6/source/Irrlicht/CBurningShader_Raster_Reference.cpp deleted file mode 100644 index a336d8b94..000000000 --- a/irrlicht-1.6/source/Irrlicht/CBurningShader_Raster_Reference.cpp +++ /dev/null @@ -1,1143 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "IBurningShader.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - - -namespace irr -{ - -namespace video -{ - - /*! Render states define set-up states for all kinds of vertex and pixel processing. - Some render states set up vertex processing, and some set up pixel processing (see Render States). - Render states can be saved and restored using stateblocks (see State Blocks Save and Restore State). - */ - enum BD3DRENDERSTATETYPE - { - /*! BD3DRS_ZENABLE - Depth-buffering state as one member of the BD3DZBUFFERTYPE enumerated type. - Set this state to D3DZB_TRUE to enable z-buffering, - D3DZB_USEW to enable w-buffering, or D3DZB_FALSE to disable depth buffering. - The default value for this render state is D3DZB_TRUE if a depth stencil was created - along with the swap chain by setting the EnableAutoDepthStencil member of the - D3DPRESENT_PARAMETERS structure to TRUE, and D3DZB_FALSE otherwise. - */ - BD3DRS_ZENABLE, - - /*! BD3DRS_FILLMODE - One or more members of the D3DFILLMODE enumerated type. The default value is D3DFILL_SOLID. - */ - BD3DRS_FILLMODE, - - /*! BD3DRS_SHADEMODE - One or more members of the D3DSHADEMODE enumerated type. The default value is D3DSHADE_GOURAUD. - */ - BD3DRS_SHADEMODE, - - /*! BD3DRS_ZWRITEENABLE - TRUE to enable the application to write to the depth buffer. The default value is TRUE. - This member enables an application to prevent the system from updating the depth buffer with - new depth values. If FALSE, depth comparisons are still made according to the render state - D3DRS_ZFUNC, assuming that depth buffering is taking place, but depth values are not written - to the buffer. - */ - BD3DRS_ZWRITEENABLE, - - /*! BD3DRS_ALPHATESTENABLE - TRUE to enable per pixel alpha testing. If the test passes, the pixel is processed by the frame - buffer. Otherwise, all frame-buffer processing is skipped for the pixel. The test is done by - comparing the incoming alpha value with the reference alpha value, using the comparison function - provided by the D3DRS_ALPHAFUNC render state. The reference alpha value is determined by the value - set for D3DRS_ALPHAREF. For more information, see Alpha Testing State. - The default value of this parameter is FALSE. - */ - BD3DRS_ALPHATESTENABLE, - - /*! BD3DRS_SRCBLEND - One member of the BD3DBLEND enumerated type. The default value is BD3DBLEND_ONE. - */ - BD3DRS_SRCBLEND, - - /*! BD3DRS_DESTBLEND - One member of the BD3DBLEND enumerated type. The default value is BD3DBLEND_ZERO. - */ - BD3DRS_DESTBLEND, - - /*! BD3DRS_CULLMODE - Specifies how back-facing triangles are culled, if at all. This can be set to one - member of the BD3DCULL enumerated type. The default value is BD3DCULL_CCW. - */ - BD3DRS_CULLMODE, - - /*! BD3DRS_ZFUNC - One member of the BD3DCMPFUNC enumerated type. The default value is BD3DCMP_LESSEQUAL. - This member enables an application to accept or reject a pixel, based on its distance from - the camera. The depth value of the pixel is compared with the depth-buffer value. If the depth - value of the pixel passes the comparison function, the pixel is written. - - The depth value is written to the depth buffer only if the render state is TRUE. - Software rasterizers and many hardware accelerators work faster if the depth test fails, - because there is no need to filter and modulate the texture if the pixel is not going to be - rendered. - */ - BD3DRS_ZFUNC, - - /*! BD3DRS_ALPHAREF - Value that specifies a reference alpha value against which pixels are tested when alpha testing - is enabled. This is an 8-bit value placed in the low 8 bits of the DWORD render-state value. - Values can range from 0x00000000 through 0x000000FF. The default value is 0. - */ - BD3DRS_ALPHAREF, - - /*! BD3DRS_ALPHAFUNC - One member of the BD3DCMPFUNC enumerated type. The default value is BD3DCMP_ALWAYS. - This member enables an application to accept or reject a pixel, based on its alpha value. - */ - BD3DRS_ALPHAFUNC, - - /*! BD3DRS_DITHERENABLE - TRUE to enable dithering. The default value is FALSE. - */ - BD3DRS_DITHERENABLE, - - /*! BD3DRS_ALPHABLENDENABLE - TRUE to enable alpha-blended transparency. The default value is FALSE. - The type of alpha blending is determined by the BD3DRS_SRCBLEND and BD3DRS_DESTBLEND render states. - */ - BD3DRS_ALPHABLENDENABLE, - - /*! BD3DRS_FOGENABLE - TRUE to enable fog blending. The default value is FALSE. For more information about using fog - blending, see Fog. - */ - BD3DRS_FOGENABLE, - - /*! BD3DRS_SPECULARENABLE - TRUE to enable specular highlights. The default value is FALSE. - Specular highlights are calculated as though every vertex in the object being lit is at the - object's origin. This gives the expected results as long as the object is modeled around the - origin and the distance from the light to the object is relatively large. In other cases, the - results as undefined. - When this member is set to TRUE, the specular color is added to the base color after the - texture cascade but before alpha blending. - */ - BD3DRS_SPECULARENABLE, - - /*! BD3DRS_FOGCOLOR - Value whose type is D3DCOLOR. The default value is 0. For more information about fog color, - see Fog Color. - */ - BD3DRS_FOGCOLOR, - - /*! BD3DRS_FOGTABLEMODE - The fog formula to be used for pixel fog. Set to one of the members of the D3DFOGMODE - enumerated type. The default value is D3DFOG_NONE. For more information about pixel fog, - see Pixel Fog. - */ - BD3DRS_FOGTABLEMODE, - - /*! BD3DRS_FOGSTART - Depth at which pixel or vertex fog effects begin for linear fog mode. The default value is 0.0f. - Depth is specified in world space for vertex fog and either device space [0.0, 1.0] or world - space for pixel fog. For pixel fog, these values are in device space when the system uses z for - fog calculations and world-world space when the system is using eye-relative fog (w-fog). For - more information, see Fog Parameters and Eye-Relative vs. Z-based Depth. - Values for the this render state are floating-point values. - Because the IDirect3DDevice9::SetRenderState method accepts DWORD values, your - application must cast a variable that contains the value, as shown in the following code example. - pDevice9->SetRenderState( BD3DRS_FOGSTART, *((DWORD*) (&fFogStart))); - */ - BD3DRS_FOGSTART, - - /*! BD3DRS_FOGEND - Depth at which pixel or vertex fog effects end for linear fog mode. The default value is 1.0f. - Depth is specified in world space for vertex fog and either device space [0.0, 1.0] or world space - for pixel fog. For pixel fog, these values are in device space when the system uses z for fog - calculations and in world space when the system is using eye-relative fog (w-fog). For more - information, see Fog Parameters and Eye-Relative vs. Z-based Depth. - Values for this render state are floating-point values. - */ - BD3DRS_FOGEND, - - /*! BD3DRS_FOGDENSITY - Fog density for pixel or vertex fog used in the exponential fog modes (D3DFOG_EXP and D3DFOG_EXP2). - Valid density values range from 0.0 through 1.0. The default value is 1.0. For more information, - see Fog Parameters. - Values for this render state are floating-point values. - */ - BD3DRS_FOGDENSITY, - - - /*! BD3DRS_RANGEFOGENABLE - TRUE to enable range-based vertex fog. The default value is FALSE, in which case the system - uses depth-based fog. In range-based fog, the distance of an object from the viewer is used - to compute fog effects, not the depth of the object (that is, the z-coordinate) in the scene. - In range-based fog, all fog methods work as usual, except that they use range instead of depth - in the computations. - Range is the correct factor to use for fog computations, but depth is commonly used instead - because range is time-consuming to compute and depth is generally already available. Using depth - to calculate fog has the undesirable effect of having the fogginess of peripheral objects change - as the viewer's eye moves - in this case, the depth changes and the range remains constant. - - Because no hardware currently supports per-pixel range-based fog, range correction is offered - only for vertex fog. - For more information, see Vertex Fog. - */ - BD3DRS_RANGEFOGENABLE = 48, - - /*! BD3DRS_STENCILENABLE - TRUE to enable stenciling, or FALSE to disable stenciling. The default value is FALSE. - For more information, see Stencil Buffer Techniques. - */ - BD3DRS_STENCILENABLE = 52, - - /*! BD3DRS_STENCILFAIL - Stencil operation to perform if the stencil test fails. Values are from the D3DSTENCILOP - enumerated type. The default value is D3DSTENCILOP_KEEP. - */ - BD3DRS_STENCILFAIL = 53, - - /*! BD3DRS_STENCILZFAIL - Stencil operation to perform if the stencil test passes and the depth test (z-test) fails. - Values are from the D3DSTENCILOP enumerated type. The default value is D3DSTENCILOP_KEEP. - */ - BD3DRS_STENCILZFAIL = 54, - - /*! BD3DRS_STENCILPASS - Stencil operation to perform if both the stencil and the depth (z) tests pass. Values are - from the D3DSTENCILOP enumerated type. The default value is D3DSTENCILOP_KEEP. - */ - BD3DRS_STENCILPASS = 55, - - /*! BD3DRS_STENCILFUNC - Comparison function for the stencil test. Values are from the D3DCMPFUNC enumerated type. - The default value is D3DCMP_ALWAYS. - The comparison function is used to compare the reference value to a stencil buffer entry. - This comparison applies only to the bits in the reference value and stencil buffer entry that - are set in the stencil mask (set by the D3DRS_STENCILMASK render state). If TRUE, the stencil - test passes. - */ - BD3DRS_STENCILFUNC = 56, - - /*! BD3DRS_STENCILREF - An int reference value for the stencil test. The default value is 0. - */ - BD3DRS_STENCILREF = 57, - - /*! BD3DRS_STENCILMASK - Mask applied to the reference value and each stencil buffer entry to determine the significant - bits for the stencil test. The default mask is 0xFFFFFFFF. - */ - BD3DRS_STENCILMASK = 58, - - /*! BD3DRS_STENCILWRITEMASK - Write mask applied to values written into the stencil buffer. The default mask is 0xFFFFFFFF. - */ - BD3DRS_STENCILWRITEMASK = 59, - - /*! BD3DRS_TEXTUREFACTOR - Color used for multiple-texture blending with the D3DTA_TFACTOR texture-blending argument or the - D3DTOP_BLENDFACTORALPHA texture-blending operation. The associated value is a D3DCOLOR variable. - The default value is opaque white (0xFFFFFFFF). - */ - BD3DRS_TEXTUREFACTOR = 60, - - /*! BD3DRS_WRAP0 - Texture-wrapping behavior for multiple sets of texture coordinates. Valid values for this - render state can be any combination of the D3DWRAPCOORD_0 (or D3DWRAP_U), D3DWRAPCOORD_1 - (or D3DWRAP_V), D3DWRAPCOORD_2 (or D3DWRAP_W), and D3DWRAPCOORD_3 flags. These cause the system - to wrap in the direction of the first, second, third, and fourth dimensions, sometimes referred - to as the s, t, r, and q directions, for a given texture. The default value for this render state - is 0 (wrapping disabled in all directions). - */ - BD3DRS_WRAP0 = 128, - BD3DRS_WRAP1 = 129, - BD3DRS_WRAP2 = 130, - BD3DRS_WRAP3 = 131, - BD3DRS_WRAP4 = 132, - BD3DRS_WRAP5 = 133, - BD3DRS_WRAP6 = 134, - BD3DRS_WRAP7 = 135, - - /*! BD3DRS_CLIPPING - TRUE to enable primitive clipping by Direct3D, or FALSE to disable it. The default value is TRUE. - */ - BD3DRS_CLIPPING = 136, - - /*! BD3DRS_LIGHTING - TRUE to enable Direct3D lighting, or FALSE to disable it. The default value is TRUE. Only - vertices that include a vertex normal are properly lit; vertices that do not contain a normal - employ a dot product of 0 in all lighting calculations. - */ - BD3DRS_LIGHTING = 137, - - /*! D3DRS_AMBIENT - Ambient light color. This value is of type D3DCOLOR. The default value is 0. - */ - BD3DRS_AMBIENT = 139, - - /*! BD3DRS_FOGVERTEXMODE - Fog formula to be used for vertex fog. Set to one member of the BD3DFOGMODE enumerated type. - The default value is D3DFOG_NONE. - */ - BD3DRS_FOGVERTEXMODE = 140, - - /*! BD3DRS_COLORVERTEX - TRUE to enable per-vertex color or FALSE to disable it. The default value is TRUE. Enabling - per-vertex color allows the system to include the color defined for individual vertices in its - lighting calculations. - For more information, see the following render states: - BD3DRS_DIFFUSEMATERIALSOURCE - BD3DRS_SPECULARMATERIALSOURCE - BD3DRS_AMBIENTMATERIALSOURCE - BD3DRS_EMISSIVEMATERIALSOURCE - */ - BD3DRS_COLORVERTEX = 141, - - /*! BD3DRS_LOCALVIEWER - TRUE to enable camera-relative specular highlights, or FALSE to use orthogonal specular - highlights. The default value is TRUE. Applications that use orthogonal projection should - specify false. - */ - BD3DRS_LOCALVIEWER = 142, - - /*! BD3DRS_NORMALIZENORMALS - TRUE to enable automatic normalization of vertex normals, or FALSE to disable it. The default - value is FALSE. Enabling this feature causes the system to normalize the vertex normals for - vertices after transforming them to camera space, which can be computationally time-consuming. - */ - BD3DRS_NORMALIZENORMALS = 143, - - /*! BD3DRS_DIFFUSEMATERIALSOURCE - Diffuse color source for lighting calculations. Valid values are members of the - D3DMATERIALCOLORSOURCE enumerated type. The default value is D3DMCS_COLOR1. The value for this - render state is used only if the D3DRS_COLORVERTEX render state is set to TRUE. - */ - BD3DRS_DIFFUSEMATERIALSOURCE = 145, - - /*! BD3DRS_SPECULARMATERIALSOURCE - Specular color source for lighting calculations. Valid values are members of the - D3DMATERIALCOLORSOURCE enumerated type. The default value is D3DMCS_COLOR2. - */ - BD3DRS_SPECULARMATERIALSOURCE = 146, - - /*! D3DRS_AMBIENTMATERIALSOURCE - Ambient color source for lighting calculations. Valid values are members of the - D3DMATERIALCOLORSOURCE enumerated type. The default value is D3DMCS_MATERIAL. - */ - BD3DRS_AMBIENTMATERIALSOURCE = 147, - - /*! D3DRS_EMISSIVEMATERIALSOURCE - Emissive color source for lighting calculations. Valid values are members of the - D3DMATERIALCOLORSOURCE enumerated type. The default value is D3DMCS_MATERIAL. - */ - BD3DRS_EMISSIVEMATERIALSOURCE = 148, - - /*! D3DRS_VERTEXBLEND - Number of matrices to use to perform geometry blending, if any. Valid values are members - of the D3DVERTEXBLENDFLAGS enumerated type. The default value is D3DVBF_DISABLE. - */ - BD3DRS_VERTEXBLEND = 151, - - /* D3DRS_CLIPPLANEENABLE - Enables or disables user-defined clipping planes. Valid values are any DWORD in which the - status of each bit (set or not set) toggles the activation state of a corresponding user-defined - clipping plane. The least significant bit (bit 0) controls the first clipping plane at index 0, - and subsequent bits control the activation of clipping planes at higher indexes. If a bit is set, - the system applies the appropriate clipping plane during scene rendering. The default value is 0. - The D3DCLIPPLANEn macros are defined to provide a convenient way to enable clipping planes. - */ - BD3DRS_CLIPPLANEENABLE = 152, - BD3DRS_POINTSIZE = 154, - BD3DRS_POINTSIZE_MIN = 155, - BD3DRS_POINTSPRITEENABLE = 156, - BD3DRS_POINTSCALEENABLE = 157, - BD3DRS_POINTSCALE_A = 158, - BD3DRS_POINTSCALE_B = 159, - BD3DRS_POINTSCALE_C = 160, - BD3DRS_MULTISAMPLEANTIALIAS = 161, - BD3DRS_MULTISAMPLEMASK = 162, - BD3DRS_PATCHEDGESTYLE = 163, - BD3DRS_DEBUGMONITORTOKEN = 165, - BD3DRS_POINTSIZE_MAX = 166, - BD3DRS_INDEXEDVERTEXBLENDENABLE = 167, - BD3DRS_COLORWRITEENABLE = 168, - BD3DRS_TWEENFACTOR = 170, - BD3DRS_BLENDOP = 171, - BD3DRS_POSITIONDEGREE = 172, - BD3DRS_NORMALDEGREE = 173, - BD3DRS_SCISSORTESTENABLE = 174, - BD3DRS_SLOPESCALEDEPTHBIAS = 175, - BD3DRS_ANTIALIASEDLINEENABLE = 176, - BD3DRS_MINTESSELLATIONLEVEL = 178, - BD3DRS_MAXTESSELLATIONLEVEL = 179, - BD3DRS_ADAPTIVETESS_X = 180, - BD3DRS_ADAPTIVETESS_Y = 181, - BD3DRS_ADAPTIVETESS_Z = 182, - BD3DRS_ADAPTIVETESS_W = 183, - BD3DRS_ENABLEADAPTIVETESSELLATION = 184, - BD3DRS_TWOSIDEDSTENCILMODE = 185, - BD3DRS_CCW_STENCILFAIL = 186, - BD3DRS_CCW_STENCILZFAIL = 187, - BD3DRS_CCW_STENCILPASS = 188, - BD3DRS_CCW_STENCILFUNC = 189, - BD3DRS_COLORWRITEENABLE1 = 190, - BD3DRS_COLORWRITEENABLE2 = 191, - BD3DRS_COLORWRITEENABLE3 = 192, - BD3DRS_BLENDFACTOR = 193, - BD3DRS_SRGBWRITEENABLE = 194, - BD3DRS_DEPTHBIAS = 195, - BD3DRS_WRAP8 = 198, - BD3DRS_WRAP9 = 199, - BD3DRS_WRAP10 = 200, - BD3DRS_WRAP11 = 201, - BD3DRS_WRAP12 = 202, - BD3DRS_WRAP13 = 203, - BD3DRS_WRAP14 = 204, - BD3DRS_WRAP15 = 205, - BD3DRS_SEPARATEALPHABLENDENABLE = 206, - BD3DRS_SRCBLENDALPHA = 207, - BD3DRS_DESTBLENDALPHA = 208, - BD3DRS_BLENDOPALPHA = 209, - - BD3DRS_MAX_TYPE - }; - - - - /*! Defines constants that describe depth-buffer formats - Members of this enumerated type are used with the D3DRS_ZENABLE render state. - */ - enum BD3DZBUFFERTYPE - { - BD3DZB_FALSE = 0, // Disable depth buffering - BD3DZB_TRUE = 1, // Enable z-buffering - BD3DZB_USEW = 2 //Enable w-buffering. - }; - - //! Defines the supported compare functions. - enum BD3DCMPFUNC - { - BD3DCMP_NEVER = 1,// Always fail the test. - BD3DCMP_LESS, // Accept the new pixel if its value is less than the value of the current pixel. - BD3DCMP_EQUAL, // Accept the new pixel if its value equals the value of the current pixel. - BD3DCMP_LESSEQUAL, // Accept the new pixel if its value is less than or equal to the value of the current pixel. - BD3DCMP_GREATER, // Accept the new pixel if its value is greater than the value of the current pixel. - BD3DCMP_NOTEQUAL, // Accept the new pixel if its value does not equal the value of the current pixel. - BD3DCMP_GREATEREQUAL,// Accept the new pixel if its value is greater than or equal to the value of the current pixel. - BD3DCMP_ALWAYS // Always pass the test. - }; - - enum BD3DMATERIALCOLORSOURCE - { - BD3DMCS_MATERIAL = 0, // Use the color from the current material. - BD3DMCS_COLOR1 = 1, // Use the diffuse vertex color. - BD3DMCS_COLOR2 = 2 // Use the specular vertex color. - }; - - - //! Defines constants that describe the supported shading modes. - enum BD3DSHADEMODE - { - /*! BD3DSHADE_FLAT - Flat shading mode. The color and specular component of the first vertex in the triangle - are used to determine the color and specular component of the face. These colors remain - constant across the triangle; that is, they are not interpolated. The specular alpha is - interpolated. - */ - BD3DSHADE_FLAT = 1, - - /*! BD3DSHADE_GOURAUD - Gouraud shading mode. The color and specular components of the face are determined by a - linear interpolation between all three of the triangle's vertices. - */ - BD3DSHADE_GOURAUD = 2, - - /*! BD3DSHADE_PHONG - Not supported. - */ - BD3DSHADE_PHONG = 3 - }; - - /*! Defines constants describing the fill mode - The values in this enumerated type are used by the BD3DRS_FILLMODE render state - */ - enum BD3DFILLMODE - { - BD3DFILL_POINT = 1, // Fill points. - BD3DFILL_WIREFRAME = 2, // Fill wireframes. - BD3DFILL_SOLID = 3 // Fill solids. - }; - - - - /*! Defines the supported culling modes. - The values in this enumerated type are used by the B3DRS_CULLMODE render state. - The culling modes define how back faces are culled when rendering a geometry. - */ - enum BD3DCULL - { - BD3DCULL_NONE = 1, // Do not cull back faces. - BD3DCULL_CW = 2, // Cull back faces with clockwise vertices. - BD3DCULL_CCW = 3 // Cull back faces with counterclockwise vertices. - }; - - struct SShaderParam - { - u32 ColorUnits; - u32 TextureUnits; - - u32 RenderState [ BD3DRS_MAX_TYPE ]; - void SetRenderState ( BD3DRENDERSTATETYPE state, u32 value ); - }; - - void SShaderParam::SetRenderState ( BD3DRENDERSTATETYPE state, u32 value ) - { - RenderState [ state ] = value; - } - - - -class CBurningShader_Raster_Reference : public IBurningShader -{ -public: - - //! constructor - CBurningShader_Raster_Reference(IDepthBuffer* depthBuffer); - - //! draws an indexed triangle list - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - - virtual void setMaterial ( const SBurningShaderMaterial &material ); - - -private: - void scanline (); - void scanline2 (); - - sScanLineData line; - sPixelShaderData pShader; - - void pShader_1 (); - void pShader_EMT_LIGHTMAP_M4 (); - - SShaderParam ShaderParam; - - REALINLINE u32 depthFunc (); - REALINLINE void depthWrite (); - - -}; - -//! constructor -CBurningShader_Raster_Reference::CBurningShader_Raster_Reference(IDepthBuffer* depthBuffer) -: IBurningShader(depthBuffer) -{ - #ifdef _DEBUG - setDebugName("CBurningShader_Raster_Reference"); - #endif -} - - -/*! -*/ -void CBurningShader_Raster_Reference::pShader_EMT_LIGHTMAP_M4 () -{ - tFixPoint r0, g0, b0; - tFixPoint r1, g1, b1; - - f32 inversew = fix_inverse32 ( line.w[0] ); - - getSample_texture ( r0, g0, b0, &IT[0], tofix ( line.t[0][0].x,inversew), tofix ( line.t[0][0].y,inversew) ); - getSample_texture ( r1, g1, b1, &IT[1], tofix ( line.t[1][0].x,inversew), tofix ( line.t[1][0].y,inversew) ); - - - pShader.dst[pShader.i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex2 ( r0, r1 ) ), - clampfix_maxcolor ( imulFix_tex2 ( g0, g1 ) ), - clampfix_maxcolor ( imulFix_tex2 ( b0, b1 ) ) - ); - -} - -/*! -*/ -void CBurningShader_Raster_Reference::pShader_1 () -{ - tFixPoint r0, g0, b0; - tFixPoint tx0, ty0; - - const f32 inversew = fix_inverse32 ( line.w[0] ); - - tx0 = tofix ( line.t[0][0].x, inversew ); - ty0 = tofix ( line.t[0][0].y, inversew ); - - getSample_texture ( r0, g0, b0, &IT[0], tx0, ty0 ); - pShader.dst[pShader.i] = fix_to_color ( r0, g0, b0 ); - -} - - -/*! -*/ -void CBurningShader_Raster_Reference::setMaterial ( const SBurningShaderMaterial &material ) -{ - const video::SMaterial &m = material.org; - - u32 i; - u32 enable; - - ShaderParam.ColorUnits = 0; - ShaderParam.TextureUnits = 0; - for ( i = 0; i != BURNING_MATERIAL_MAX_TEXTURES; ++i ) - { - if ( m.getTexture( i ) ) - ShaderParam.TextureUnits = i; - } - - // shademode - ShaderParam.SetRenderState( BD3DRS_SHADEMODE, - m.GouraudShading ? BD3DSHADE_GOURAUD : BD3DSHADE_FLAT - ); - - // fillmode - ShaderParam.SetRenderState( BD3DRS_FILLMODE, - m.Wireframe ? BD3DFILL_WIREFRAME : m.PointCloud ? BD3DFILL_POINT : BD3DFILL_SOLID - ); - - // back face culling - ShaderParam.SetRenderState( BD3DRS_CULLMODE, - m.BackfaceCulling ? BD3DCULL_CCW : BD3DCULL_NONE - ); - - // lighting - ShaderParam.SetRenderState( BD3DRS_LIGHTING, m.Lighting ); - - // specular highlights - enable = F32_LOWER_EQUAL_0 ( m.Shininess ); - ShaderParam.SetRenderState( BD3DRS_SPECULARENABLE, enable); - ShaderParam.SetRenderState( BD3DRS_NORMALIZENORMALS, enable); - ShaderParam.SetRenderState( BD3DRS_SPECULARMATERIALSOURCE, (m.ColorMaterial==ECM_SPECULAR)?BD3DMCS_COLOR1:BD3DMCS_MATERIAL); - - // depth buffer enable and compare - ShaderParam.SetRenderState( BD3DRS_ZENABLE, (material.org.ZBuffer==video::ECFN_NEVER) ? BD3DZB_FALSE : BD3DZB_USEW); - switch (material.org.ZBuffer) - { - case ECFN_NEVER: - ShaderParam.SetRenderState(BD3DRS_ZFUNC, BD3DCMP_NEVER); - break; - case ECFN_LESSEQUAL: - ShaderParam.SetRenderState(BD3DRS_ZFUNC, BD3DCMP_LESSEQUAL); - break; - case ECFN_EQUAL: - ShaderParam.SetRenderState(BD3DRS_ZFUNC, BD3DCMP_EQUAL); - break; - case ECFN_LESS: - ShaderParam.SetRenderState(BD3DRS_ZFUNC, BD3DCMP_LESSEQUAL); - break; - case ECFN_NOTEQUAL: - ShaderParam.SetRenderState(BD3DRS_ZFUNC, BD3DCMP_NOTEQUAL); - break; - case ECFN_GREATEREQUAL: - ShaderParam.SetRenderState(BD3DRS_ZFUNC, BD3DCMP_GREATEREQUAL); - break; - case ECFN_GREATER: - ShaderParam.SetRenderState(BD3DRS_ZFUNC, BD3DCMP_GREATER); - break; - case ECFN_ALWAYS: - ShaderParam.SetRenderState(BD3DRS_ZFUNC, BD3DCMP_ALWAYS); - break; - } - - // depth buffer write - ShaderParam.SetRenderState( BD3DRS_ZWRITEENABLE, m.ZWriteEnable ); -} - -/*! -*/ -REALINLINE u32 CBurningShader_Raster_Reference::depthFunc () -{ - if ( ShaderParam.RenderState [ BD3DRS_ZENABLE ] ) - { - switch ( ShaderParam.RenderState [ BD3DRS_ZFUNC ] ) - { - case BD3DCMP_LESSEQUAL: - return line.w[0] >= pShader.z[ pShader.i]; - case BD3DCMP_EQUAL: - return line.w[0] == pShader.z[ pShader.i]; - } - } - return 1; -} - -/*! -*/ -REALINLINE void CBurningShader_Raster_Reference::depthWrite () -{ - if ( ShaderParam.RenderState [ BD3DRS_ZWRITEENABLE ] ) - { - pShader.z[pShader.i] = line.w[0]; - } -} - -/*! -*/ -REALINLINE void CBurningShader_Raster_Reference::scanline2() -{ - // apply top-left fill-convention, left - pShader.xStart = core::ceil32( line.x[0] ); - pShader.xEnd = core::ceil32( line.x[1] ) - 1; - - pShader.dx = pShader.xEnd - pShader.xStart; - if ( pShader.dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal ( line.x[1] - line.x[0] ); - const f32 subPixel = ( (f32) pShader.xStart ) - line.x[0]; - - // store slopes in endpoint, and correct first pixel - - line.w[0] += (line.w[1] = (line.w[1] - line.w[0]) * invDeltaX) * subPixel; - - u32 i; - -#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - for ( i = 0; i != ShaderParam.ColorUnits; ++i ) - { - line.c[i][1] = (line.c[i][1] - line.c[i][0]) * invDeltaX; - line.c[i][0] += line.c[i][1] * subPixel; - } -#endif - - for ( i = 0; i != ShaderParam.TextureUnits; ++i ) - { - line.t[i][1] = (line.t[i][1] - line.t[i][0]) * invDeltaX; - line.t[i][0] += line.t[i][1] * subPixel; - } - - pShader.dst = (tVideoSample*) ( (u8*) RenderTarget->lock() + ( line.y * RenderTarget->getPitch() ) + ( pShader.xStart << VIDEO_SAMPLE_GRANULARITY ) ); - pShader.z = (fp24*) ( (u8*) DepthBuffer->lock() + ( line.y * DepthBuffer->getPitch() ) + ( pShader.xStart << VIDEO_SAMPLE_GRANULARITY ) ); - - for ( pShader.i = 0; pShader.i <= pShader.dx; ++pShader.i ) - { - if ( depthFunc() ) - { - depthWrite (); - } - - // advance next pixel - line.w[0] += line.w[1]; - -#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - for ( i = 0; i != ShaderParam.ColorUnits; ++i ) - { - line.c[i][0] += line.c[i][1]; - } -#endif - for ( i = 0; i != ShaderParam.TextureUnits; ++i ) - { - line.t[i][0] += line.t[i][1]; - } - } -} - - -/*! -*/ -REALINLINE void CBurningShader_Raster_Reference::scanline () -{ - u32 i; - - // apply top-left fill-convention, left - pShader.xStart = core::ceil32( line.x[0] ); - pShader.xEnd = core::ceil32( line.x[1] ) - 1; - - pShader.dx = pShader.xEnd - pShader.xStart; - if ( pShader.dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal ( line.x[1] - line.x[0] ); - - // search z-buffer for first not occulled pixel - pShader.z = (fp24*) ( (u8*) DepthBuffer->lock() + ( line.y * DepthBuffer->getPitch() ) + ( pShader.xStart << VIDEO_SAMPLE_GRANULARITY ) ); - - // subTexel - const f32 subPixel = ( (f32) pShader.xStart ) - line.x[0]; - - const f32 b = (line.w[1] - line.w[0]) * invDeltaX; - f32 a = line.w[0] + ( b * subPixel ); - - pShader.i = 0; - - if ( ShaderParam.RenderState [ BD3DRS_ZENABLE ] ) - { - u32 condition; - switch ( ShaderParam.RenderState [ BD3DRS_ZFUNC ] ) - { - case BD3DCMP_LESSEQUAL: - condition = a < pShader.z[pShader.i]; - break; - case BD3DCMP_EQUAL: - condition = a != pShader.z[pShader.i]; - break; - } - while ( a < pShader.z[pShader.i] ) - { - a += b; - - pShader.i += 1; - if ( pShader.i > pShader.dx ) - return; - - } - } - - // lazy setup rest of scanline - - line.w[0] = a; - line.w[1] = b; - - pShader.dst = (tVideoSample*) ( (u8*) RenderTarget->lock() + ( line.y * RenderTarget->getPitch() ) + ( pShader.xStart << VIDEO_SAMPLE_GRANULARITY ) ); - - a = (f32) pShader.i + subPixel; - -#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - for ( i = 0; i != ShaderParam.ColorUnits; ++i ) - { - line.c[i][1] = (line.c[i][1] - line.c[i][0]) * invDeltaX; - line.c[i][0] += line.c[i][1] * a; - } -#endif - - for ( i = 0; i != ShaderParam.TextureUnits; ++i ) - { - line.t[i][1] = (line.t[i][1] - line.t[i][0]) * invDeltaX; - line.t[i][0] += line.t[i][1] * a; - } - - for ( ; pShader.i <= pShader.dx; ++pShader.i ) - { - if ( line.w[0] >= pShader.z[pShader.i] ) - { - pShader.z[pShader.i] = line.w[0]; - - pShader_EMT_LIGHTMAP_M4 (); - } - - line.w[0] += line.w[1]; - -#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - for ( i = 0; i != ShaderParam.ColorUnits; ++i ) - { - line.c[i][0] += line.c[i][1]; - } -#endif - for ( i = 0; i != ShaderParam.TextureUnits; ++i ) - { - line.t[i][0] += line.t[i][1]; - } - } - -} - - - -void CBurningShader_Raster_Reference::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - sScanConvertData scan; - u32 i; - - // sort on height, y - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - - - // calculate delta y of the edges - scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y ); - scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y ); - scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y ); - - if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) - return; - - - // find if the major edge is left or right aligned - f32 temp[4]; - - temp[0] = a->Pos.x - c->Pos.x; - temp[1] = a->Pos.y - c->Pos.y; - temp[2] = b->Pos.x - a->Pos.x; - temp[3] = b->Pos.y - a->Pos.y; - - scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1; - scan.right = 1 - scan.left; - - // calculate slopes for the major edge - scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; - scan.x[0] = a->Pos.x; - - scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; - scan.w[0] = a->Pos.w; - -#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - for ( i = 0; i != ShaderParam.ColorUnits; ++i ) - { - scan.c[i][0] = a->Color[i]; - scan.slopeC[i][0] = (c->Color[i] - a->Color[i]) * scan.invDeltaY[0]; - } -#endif - - for ( i = 0; i != ShaderParam.TextureUnits; ++i ) - { - scan.t[i][0] = a->Tex[i]; - scan.slopeT[i][0] = (c->Tex[i] - a->Tex[i]) * scan.invDeltaY[0]; - } - - // top left fill convention y run - s32 yStart; - s32 yEnd; - - f32 subPixel; - - // rasterize upper sub-triangle - if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) - { - // calculate slopes for top edge - scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; - scan.x[1] = a->Pos.x; - - scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; - scan.w[1] = a->Pos.w; - -#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - for ( i = 0; i != ShaderParam.ColorUnits; ++i ) - { - scan.c[i][1] = a->Color[i]; - scan.slopeC[i][1] = (b->Color[i] - a->Color[i]) * scan.invDeltaY[1]; - } -#endif - for ( i = 0; i != ShaderParam.TextureUnits; ++i ) - { - scan.t[i][1] = a->Tex[i]; - scan.slopeT[i][1] = (b->Tex[i] - a->Tex[i]) * scan.invDeltaY[1]; - } - - // apply top-left fill convention, top part - yStart = core::ceil32( a->Pos.y ); - yEnd = core::ceil32( b->Pos.y ) - 1; - - subPixel = ( (f32) yStart ) - a->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; - - for ( i = 0; i != ShaderParam.ColorUnits; ++i ) - { - scan.c[i][0] += scan.slopeC[i][0] * subPixel; - scan.c[i][1] += scan.slopeC[i][1] * subPixel; - } - - for ( i = 0; i != ShaderParam.TextureUnits; ++i ) - { - scan.t[i][0] += scan.slopeT[i][0] * subPixel; - scan.t[i][1] += scan.slopeT[i][1] * subPixel; - } - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.w[scan.left] = scan.w[0]; - - line.x[scan.right] = scan.x[1]; - line.w[scan.right] = scan.w[1]; - -#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - for ( i = 0; i != ShaderParam.ColorUnits; ++i ) - { - line.c[i][scan.left] = scan.c[i][0]; - line.c[i][scan.right] = scan.c[i][1]; - } -#endif - for ( i = 0; i != ShaderParam.TextureUnits; ++i ) - { - line.t[i][scan.left] = scan.t[i][0]; - line.t[i][scan.right] = scan.t[i][1]; - } - - // render a scanline - scanline (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; - - for ( i = 0; i != ShaderParam.ColorUnits; ++i ) - { - scan.c[i][0] += scan.slopeC[i][0]; - scan.c[i][1] += scan.slopeC[i][1]; - } - - for ( i = 0; i != ShaderParam.TextureUnits; ++i ) - { - scan.t[i][0] += scan.slopeT[i][0]; - scan.t[i][1] += scan.slopeT[i][1]; - } - - } - } - - // rasterize lower sub-triangle - if ( F32_GREATER_0 ( scan.invDeltaY[2] ) ) - { - // advance to middle point - if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) - { - temp[0] = b->Pos.y - a->Pos.y; // dy - - scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; - scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; - -#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - for ( i = 0; i != ShaderParam.ColorUnits; ++i ) - { - scan.c[i][0] = a->Color[i] + scan.slopeC[i][0] * temp[0]; - } -#endif - for ( i = 0; i != ShaderParam.TextureUnits; ++i ) - { - scan.t[i][0] = a->Tex[i] + scan.slopeT[i][0] * temp[0]; - } - } - - // calculate slopes for bottom edge - scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; - scan.x[1] = b->Pos.x; - - scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; - scan.w[1] = b->Pos.w; - -#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - for ( i = 0; i != ShaderParam.ColorUnits; ++i ) - { - scan.c[i][1] = b->Color[i]; - scan.slopeC[i][1] = (c->Color[i] - b->Color[i]) * scan.invDeltaY[2]; - } -#endif - for ( i = 0; i != ShaderParam.TextureUnits; ++i ) - { - scan.t[i][1] = b->Tex[i]; - scan.slopeT[i][1] = (c->Tex[i] - b->Tex[i]) * scan.invDeltaY[2]; - } - - // apply top-left fill convention, top part - yStart = core::ceil32( b->Pos.y ); - yEnd = core::ceil32( c->Pos.y ) - 1; - - - subPixel = ( (f32) yStart ) - b->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; - - for ( i = 0; i != ShaderParam.ColorUnits; ++i ) - { - scan.c[i][0] += scan.slopeC[i][0] * subPixel; - scan.c[i][1] += scan.slopeC[i][1] * subPixel; - } - - for ( i = 0; i != ShaderParam.TextureUnits; ++i ) - { - scan.t[i][0] += scan.slopeT[i][0] * subPixel; - scan.t[i][1] += scan.slopeT[i][1] * subPixel; - } - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.w[scan.left] = scan.w[0]; - - line.x[scan.right] = scan.x[1]; - line.w[scan.right] = scan.w[1]; - -#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - for ( i = 0; i != ShaderParam.ColorUnits; ++i ) - { - line.c[i][scan.left] = scan.c[i][0]; - line.c[i][scan.right] = scan.c[i][1]; - } -#endif - for ( i = 0; i != ShaderParam.TextureUnits; ++i ) - { - line.t[i][scan.left] = scan.t[i][0]; - line.t[i][scan.right] = scan.t[i][1]; - } - - // render a scanline - scanline (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; - - for ( i = 0; i != ShaderParam.TextureUnits; ++i ) - { - scan.c[i][0] += scan.slopeC[i][0]; - scan.c[i][1] += scan.slopeC[i][1]; - } - - for ( i = 0; i != ShaderParam.TextureUnits; ++i ) - { - scan.t[i][0] += scan.slopeT[i][0]; - scan.t[i][1] += scan.slopeT[i][1]; - } - } - } -} - - -} // end namespace video -} // end namespace irr - - -namespace irr -{ -namespace video -{ - - - -//! creates a flat triangle renderer -IBurningShader* createTriangleRendererReference(IDepthBuffer* depthBuffer) -{ - return new CBurningShader_Raster_Reference(depthBuffer); -} - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - - diff --git a/irrlicht-1.6/source/Irrlicht/CCSMLoader.cpp b/irrlicht-1.6/source/Irrlicht/CCSMLoader.cpp deleted file mode 100644 index c9f373ebf..000000000 --- a/irrlicht-1.6/source/Irrlicht/CCSMLoader.cpp +++ /dev/null @@ -1,872 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h -// -// This file was written by Saurav Mohapatra and modified by Nikolaus Gebhardt. -// See CCSMLoader.h for details. - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_CSM_LOADER_ - -#include "CCSMLoader.h" -#include "os.h" -#include "IFileSystem.h" -#include "IReadFile.h" -#include "ISceneManager.h" -#include "IAttributes.h" -#include "SMesh.h" -#include "IVideoDriver.h" -#include "SAnimatedMesh.h" -#include "SMeshBufferLightMap.h" - -#ifdef _DEBUG -#define _IRR_DEBUG_CSM_LOADER_ -#endif - -namespace irr -{ -namespace scene -{ - // - // the CSM data types - // - struct color_rgb_t - { - s32 red; - s32 green; - s32 blue; - - color_rgb_t() : red(0), green(0), blue(0) {} - void clear() { red=0; green=0; blue=0; } - video::SColor toSColor() const { return video::SColor(255, red, green, blue); } - }; - - - // - // A Binary File Reader - // - struct BinaryFileReader - { - BinaryFileReader(io::IReadFile* pFile) : file(pFile) { } - - s32 readBuffer(void* buffer, s32 len) - { - return file->read(buffer,len); - } - - s32 readLong(); - f32 readFloat(); - - void readString(core::stringc &str); - void readVec3f(core::vector3df* v); - void readVec2f(core::vector2df* v); - void readColorRGB(color_rgb_t* color); - - io::IReadFile *file; - }; - - // - // The file header - // - class Header - { - public: - - enum E_CSM_VERSION - { - VERSION_4 = 4, - VERSION_4_1 = 5 - }; - - Header(){ clear(); } - - s32 getVersion() const { return version; } - void clear(){ version = 0; } - void load(BinaryFileReader* pReader) - { - version = pReader->readLong(); - } - - private: - - s32 version; - }; - - - // - // The groups - // - class Group - { - public: - - Group(){ clear(); } - ~Group(){ clear(); } - - void clear(); - void load(BinaryFileReader* pReader); - - s32 getFlags() const { return flags; } - s32 getParentGroupID() const { return parentGroup; } - const core::stringc& getProperties() const { return props; } - video::SColor getColor() const { return color.toSColor(); } - - private: - - s32 flags; - s32 parentGroup; - core::stringc props; - color_rgb_t color; - }; - - - // - // The visgroups - // - class VisGroup - { - public: - - VisGroup(){ clear(); } - ~VisGroup(){ clear(); } - void clear(); - void load(BinaryFileReader* pReader); - - s32 getFlags() const{ return flags; } - const core::stringc& getName() const{ return name; } - video::SColor getColor() const{ return color.toSColor(); } - - private: - - core::stringc name; - s32 flags; - color_rgb_t color; - }; - - - // - // Lightmaps - // - class LightMap - { - public: - - LightMap() : pixelData(0){ clear(); } - ~LightMap(){ clear(); } - void clear(); - void load(BinaryFileReader* pReader); - s32 getWidth() const{ return width; } - s32 getHeight() const{ return height; } - s32* getPixelData() const{ return pixelData; } - - private: - - s32 width; - s32 height; - s32* pixelData; - }; - - struct Triangle - { - s32 a,b,c; - }; - - - struct Line - { - s32 a,b; - }; - - - class Vertex - { - public: - - Vertex(){ clear(); } - ~Vertex(){ clear(); } - void clear(); - void load(BinaryFileReader* pReader); - - const core::vector3df& getPosition() const { return position; } - const core::vector3df& getNormal() const { return normal; } - video::SColor getColor() const { return color.toSColor(); } - const core::vector3df& getTextureCoordinates() const { return texCoords; } - const core::vector3df& getLightMapCoordinates() const { return lmapCoords; } - - private: - - core::vector3df position; - core::vector3df normal; - color_rgb_t color; - core::vector3df texCoords; - core::vector3df lmapCoords; - }; - - - class Surface - { - public: - - Surface() { clear(); } - ~Surface(){ clear(); } - - void clear(); - void load(BinaryFileReader *pReader); - - s32 getFlags() const{ return flags; } - const core::stringc& getTextureName() const{ return textureName; } - s32 getLightMapId() const{ return lightMapId; } - const core::vector2df* getUVOffset() const{ return &uvOffset; } - const core::vector2df* getUVScale() const{ return &uvScale; } - f32 getUVRotation() const{ return uvRotation; } - - u32 getVertexCount() const{ return vertices.size(); } - const Vertex& getVertexAt(const s32 index) const{ return vertices[index]; } - - u32 getTriangleCount() const{ return triangles.size(); } - const Triangle& getTriangleAt(const s32 index) const{ return triangles[index]; } - - private: - - s32 flags; - core::stringc textureName; - s32 lightMapId; - core::vector2df uvOffset; - core::vector2df uvScale; - f32 uvRotation; - core::array<Vertex> vertices; - core::array<Triangle> triangles; - core::array<Line> lines; - }; - - class Mesh - { - public: - - Mesh(){ clear(); } - ~Mesh(){ clear(); } - - void clear(); - void load(BinaryFileReader* pReader, bool bReadVisGroups); - - s32 getFlags() const { return flags; } - s32 getGroupID() const { return groupId; } - const core::stringc& getProperties() const { return props; } - video::SColor getColor() const { return color.toSColor(); } - const core::vector3df* getPosition() const { return &position; } - s32 getVisgroupID() const { return visgroupId; } - s32 getSurfaceCount() const { return surfaces.size(); } - const Surface* getSurfaceAt(const s32 index) const { return surfaces[index]; } - - private: - - s32 flags; - s32 groupId; - core::stringc props; - color_rgb_t color; - core::vector3df position; - s32 visgroupId; - - core::array<Surface*> surfaces; - }; - - class Entity - { - public: - - Entity() { clear(); } - ~Entity() { clear(); } - - void clear(); - void load(BinaryFileReader* pReader); - s32 getVisgroupID() const { return visgroupId; } - s32 getGroupID() const { return groupId; } - const core::stringc& getProperties() const { return props; } - const core::vector3df* getPosition() const { return &position; } - - private: - - s32 visgroupId; - s32 groupId; - core::stringc props; - core::vector3df position; - }; - - - class CameraData - { - public: - - CameraData(){ clear(); } - ~CameraData(){ clear(); } - - void clear(); - void load(BinaryFileReader* pReader); - - const core::vector3df* getPosition(){ return &position; } - f32 getPitch(){ return pitch; } - f32 getYaw(){ return yaw; } - - private: - - core::vector3df position; - f32 pitch; - f32 yaw; - }; - - // - // A CSM File - // - class CSMFile - { - public: - - CSMFile(){ clear(); } - ~CSMFile(){ clear(); } - void clear(); - void load(BinaryFileReader* pReader); - - const Header* getHeader() const{ return &header; } - - u32 getGroupCount() const{ return groups.size(); } - const Group* getGroupAt(const s32 index) const{ return groups[index]; } - - u32 getVisGroupCount() const{ return visgroups.size(); } - const VisGroup* getVisGroupAt(const s32 index) const{ return visgroups[index]; } - - u32 getLightMapCount() const{ return lightmaps.size(); } - const LightMap* getLightMapAt(const s32 index) const { return lightmaps[index]; } - - u32 getMeshCount() const{ return meshes.size(); } - const Mesh* getMeshAt(const s32 index) const{ return meshes[index]; } - - u32 getEntityCount() const{ return entities.size(); } - const Entity* getEntityAt(const s32 index) const{ return entities[index]; } - - const CameraData* getCameraData() const{ return &cameraData; } - - private: - - Header header; - core::array<Group*> groups; - core::array<VisGroup*> visgroups; - core::array<LightMap*> lightmaps; - core::array<Mesh*> meshes; - core::array<Entity*> entities; - CameraData cameraData; - }; - - CCSMLoader::CCSMLoader(scene::ISceneManager* manager, io::IFileSystem* fs) - : FileSystem(fs), SceneManager(manager) - { - - #ifdef _DEBUG - setDebugName("CCSMLoader"); - #endif - } - - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".bsp") - bool CCSMLoader::isALoadableFileExtension(const io::path& filename) const - { - return core::hasFileExtension ( filename, "csm" ); - } - - - //! creates/loads an animated mesh from the file. - IAnimatedMesh* CCSMLoader::createMesh(io::IReadFile* file) - { - scene::IMesh* m = createCSMMesh(file); - - if (!m) - return 0; - - SAnimatedMesh* am = new SAnimatedMesh(); - am->Type = EAMT_CSM; - am->addMesh(m); - m->drop(); - - am->recalculateBoundingBox(); - return am; - } - - scene::IMesh* CCSMLoader::createCSMMesh(io::IReadFile* file) - { - if (!file) - return 0; - - BinaryFileReader reader(file); - CSMFile csmFile; - csmFile.load(&reader); - - return createIrrlichtMesh(&csmFile, - SceneManager->getParameters()->getAttributeAsString(CSM_TEXTURE_PATH), - file->getFileName()); - } - - - scene::IMesh* CCSMLoader::createIrrlichtMesh(const CSMFile* csmFile, - const core::stringc& textureRoot, const io::path& lmprefix) - { - scene::SMesh *pMesh = new scene::SMesh(); - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - - for(u32 l = 0; l<csmFile->getLightMapCount(); l++) - { - const LightMap* lmap = csmFile->getLightMapAt(l); - - io::path lmapName = lmprefix; - lmapName += "LMAP_"; - lmapName += io::path(l+1); - os::Printer::log("CCSMLoader loading light map", lmapName.c_str()); - - video::IImage* lmapImg = driver->createImageFromData( - video::ECF_A8R8G8B8, - core::dimension2d<u32>(lmap->getWidth(),lmap->getHeight()), - lmap->getPixelData()); - - driver->addTexture(lmapName.c_str(), lmapImg); - lmapImg->drop(); - } - - for(u32 m = 0; m<csmFile->getMeshCount(); m++) - { - const Mesh* mshPtr = csmFile->getMeshAt(m); - - for(s32 s = 0; s < mshPtr->getSurfaceCount(); s++) - { - const Surface* surface = mshPtr->getSurfaceAt(s); - - core::stringc texName; - if (textureRoot.size()) - { - texName += textureRoot; - texName += "/"; - } - texName+= surface->getTextureName(); - - video::ITexture* texture = 0; - if (texName.size()) - { - if (FileSystem->existFile(texName)) - texture = driver->getTexture(texName); - else if (FileSystem->existFile(surface->getTextureName())) - texture = driver->getTexture(surface->getTextureName()); - else if (FileSystem->existFile(FileSystem->getFileBasename(surface->getTextureName()))) - texture = driver->getTexture(FileSystem->getFileBasename(surface->getTextureName())); - else if (FileSystem->existFile(FileSystem->getFileDir(lmprefix)+"/"+surface->getTextureName())) - texture = driver->getTexture(FileSystem->getFileDir(lmprefix)+"/"+surface->getTextureName()); - else - texture = driver->getTexture(FileSystem->getFileDir(lmprefix)+"/"+FileSystem->getFileBasename(surface->getTextureName())); - } - - //material - io::path lmapName = lmprefix; - lmapName += "LMAP_"; - lmapName += io::path(surface->getLightMapId()); - - scene::SMeshBufferLightMap *buffer = new scene::SMeshBufferLightMap(); - buffer->Material.setTexture(0, texture); - if (surface->getLightMapId()) - { - buffer->Material.setTexture(1, driver->getTexture(lmapName)); - buffer->Material.Lighting = false; - buffer->Material.MaterialType = video::EMT_LIGHTMAP_ADD; - } - - buffer->Vertices.reallocate(surface->getVertexCount()); - for(u32 v = 0; v < surface->getVertexCount(); ++v) - { - const Vertex& vtxPtr = surface->getVertexAt(v); - video::S3DVertex2TCoords vtx; - vtx.Pos = vtxPtr.getPosition(); - vtx.Normal = vtxPtr.getPosition(); - vtx.Color=vtxPtr.getColor(); - vtx.TCoords.set(vtxPtr.getTextureCoordinates().X, 1.f-vtxPtr.getTextureCoordinates().Y); - vtx.TCoords2.set(vtxPtr.getLightMapCoordinates().X, 1.f-vtxPtr.getLightMapCoordinates().Y); - - buffer->Vertices.push_back(vtx); - } - - buffer->Indices.reallocate(surface->getTriangleCount()*3); - for(u32 t = 0; t < surface->getTriangleCount(); ++t) - { - const Triangle& tri = surface->getTriangleAt(t); - buffer->Indices.push_back(tri.c); - buffer->Indices.push_back(tri.b); - buffer->Indices.push_back(tri.a); - } - - buffer->recalculateBoundingBox(); - pMesh->addMeshBuffer(buffer); - buffer->drop(); - } - } - - pMesh->recalculateBoundingBox(); - return pMesh; - } - - void Group::clear() - { - color.clear(); - flags = 0; - parentGroup = 0; - props = ""; - } - - void Group::load(BinaryFileReader* pReader) - { - flags = pReader->readLong(); - parentGroup = pReader->readLong(); - pReader->readString(props); - pReader->readColorRGB(&color); - } - - void VisGroup::clear() - { - color.clear(); - flags = 0; - name = ""; - } - - void VisGroup::load(BinaryFileReader* pReader) - { - pReader->readString(name); - flags = pReader->readLong(); - pReader->readColorRGB(&color); - } - - void LightMap::clear() - { - delete[] pixelData; - pixelData = 0; - width = height = 0; - } - - void LightMap::load(BinaryFileReader* pReader) - { - width = pReader->readLong(); - height = pReader->readLong(); - pixelData = new s32[width * height]; - pReader->readBuffer(pixelData, width * height * sizeof(s32)); - } - - void Mesh::clear() - { - flags = 0; - groupId = 0; - visgroupId = 0; - props = ""; - color.clear(); - position.set(0,0,0); - - for(u32 s = 0; s < surfaces.size(); s++) - { - delete surfaces[s]; - } - surfaces.clear(); - } - - void Mesh::load(BinaryFileReader* pReader, bool bReadVisGroups) - { - flags = pReader->readLong(); - groupId = pReader->readLong(); - pReader->readString(props); - pReader->readColorRGB(&color); - pReader->readVec3f(&position); - if(bReadVisGroups) - visgroupId = pReader->readLong(); - else - visgroupId = 0; - - s32 count = pReader->readLong(); - - for(s32 i = 0; i < count; i++) - { - Surface* surf = new Surface(); - surf->load(pReader); - surfaces.push_back(surf); - } - } - - void Surface::clear() - { - flags = 0; - lightMapId = 0; - textureName = ""; - uvOffset.set(0.0f,0.0f); - uvScale.set(0.0f,0.0f); - uvRotation = 0.0f; - triangles.clear(); - lines.clear(); - vertices.clear(); - } - - void Surface::load(BinaryFileReader* pReader) - { - flags = pReader->readLong(); - pReader->readString(textureName); - textureName.replace('\\', '/'); - - lightMapId = pReader->readLong(); - pReader->readVec2f(&uvOffset); - pReader->readVec2f(&uvScale); - uvRotation = pReader->readFloat(); - s32 vtxCount = pReader->readLong(); - s32 triCount = pReader->readLong(); - s32 lineCount = pReader->readLong(); - - for(s32 v = 0; v < vtxCount; v++) - { - vertices.push_back(Vertex()); - vertices.getLast().load(pReader); - } - - for(s32 t = 0; t < triCount; t++) - { - Triangle tri; - pReader->readBuffer(&tri, sizeof(tri)); - triangles.push_back(tri); - } - - for(s32 l = 0; l < lineCount; l++) - { - Line line; - pReader->readBuffer(&line,sizeof(line)); - lines.push_back(line); - - } - - } - - void Vertex::clear() - { - position.set(0,0,0); - normal.set(0,0,0); - color.clear(); - texCoords.set(0,0,0); - lmapCoords.set(0,0,0); - } - - void Vertex::load(BinaryFileReader* pReader) - { - pReader->readVec3f(&position); - pReader->readVec3f(&normal); - pReader->readColorRGB(&color); - pReader->readVec3f(&texCoords); - pReader->readVec3f(&lmapCoords); - } - - void Entity::clear() - { - visgroupId = groupId = 0; - props = ""; - position.set(0,0,0); - } - - void Entity::load(BinaryFileReader* pReader) - { - visgroupId = pReader->readLong(); - groupId = pReader->readLong(); - pReader->readString(props); - pReader->readVec3f(&position); - } - - void CameraData::clear() - { - position.set(0,0,0); - pitch = 0; - yaw = 0; - } - - void CameraData::load(BinaryFileReader* pReader) - { - pReader->readVec3f(&position); - pitch = pReader->readFloat(); - yaw = pReader->readFloat(); - } - - void CSMFile::clear() - { - header.clear(); - cameraData.clear(); - - u32 x =0; - for( x= 0; x < groups.size(); x++) - delete groups[x]; - - groups.clear(); - - for(x= 0; x < visgroups.size(); x++) - delete visgroups[x]; - - visgroups.clear(); - - for(x= 0; x < lightmaps.size(); x++) - delete lightmaps[x]; - - lightmaps.clear(); - - for(x= 0; x < meshes.size(); x++) - delete meshes[x]; - - meshes.clear(); - - for(x= 0; x < entities.size(); x++) - delete entities[x]; - - entities.clear(); - } - - void CSMFile::load(BinaryFileReader* pReader) - { - clear(); - - header.load(pReader); - - //groups - { - const s32 count = pReader->readLong(); -#ifdef _IRR_DEBUG_CSM_LOADER_ - os::Printer::log("CSM Version", core::stringc(header.getVersion()).c_str()); - os::Printer::log("Loading groups. Count", core::stringc(count)); -#endif - - groups.reallocate(count); - for (s32 i = 0; i < count; i++) - { - Group* grp = new Group(); - grp->load(pReader); - groups.push_back(grp); - } - } - const bool bHasVGroups = (header.getVersion() == Header::VERSION_4_1); - - if (bHasVGroups) - { - //visgroups - const s32 count = pReader->readLong(); -#ifdef _IRR_DEBUG_CSM_LOADER_ - os::Printer::log("Loading visgroups. Count", core::stringc(count)); -#endif - - visgroups.reallocate(count); - for (s32 i = 0; i < count; i++) - { - VisGroup* grp = new VisGroup(); - grp->load(pReader); - visgroups.push_back(grp); - } - } - - //lightmaps - { - const s32 count = pReader->readLong(); -#ifdef _IRR_DEBUG_CSM_LOADER_ - os::Printer::log("Loading lightmaps. Count", core::stringc(count)); -#endif - - lightmaps.reallocate(count); - for(s32 i = 0; i < count; i++) - { - LightMap* lm = new LightMap(); - lm->load(pReader); - lightmaps.push_back(lm); - } - } - - //meshes - { - const s32 count = pReader->readLong(); -#ifdef _IRR_DEBUG_CSM_LOADER_ - os::Printer::log("Loading meshes. Count", core::stringc(count)); -#endif - - meshes.reallocate(count); - for(s32 i = 0; i < count; i++) - { - Mesh* mesh = new Mesh(); - mesh->load(pReader,bHasVGroups); - meshes.push_back(mesh); - } - } - - //entities - { - const s32 count = pReader->readLong(); -#ifdef _IRR_DEBUG_CSM_LOADER_ - os::Printer::log("Loading entitites. Count", core::stringc(count)); -#endif - - entities.reallocate(count); - for(s32 i = 0; i < count; i++) - { - Entity* ent = new Entity(); - ent->load(pReader); - entities.push_back(ent); - } - } - - //camera data -#ifdef _IRR_DEBUG_CSM_LOADER_ - os::Printer::log("Loading camera data."); -#endif - cameraData.load(pReader); - } - - s32 BinaryFileReader::readLong() - { - int ret = 0; - readBuffer(&ret,sizeof(int)); -#ifdef __BIG_ENDIAN__ - ret = os::Byteswap::byteswap(ret); -#endif - return ret; - } - - f32 BinaryFileReader::readFloat() - { - float ret = 0; - readBuffer(&ret,sizeof(float)); -#ifdef __BIG_ENDIAN__ - ret = os::Byteswap::byteswap(ret); -#endif - return ret; - } - - void BinaryFileReader::readString(core::stringc &str) - { - str = ""; - c8 c; - readBuffer(&c,sizeof(char)); - while(c != 0) - { - str += c; - readBuffer(&c,sizeof(char)); - } - } - - void BinaryFileReader::readVec3f(core::vector3df* v) - { - v->X = readFloat(); - v->Y = readFloat(); - v->Z = readFloat(); - } - - void BinaryFileReader::readVec2f(core::vector2df* v) - { - v->X = readFloat(); - v->Y = readFloat(); - } - - void BinaryFileReader::readColorRGB(color_rgb_t* color) - { - readBuffer(color,sizeof(color_rgb_t)); - } - -} // end namespace -} // end namespace - -#endif // _IRR_COMPILE_WITH_CSM_LOADER_ diff --git a/irrlicht-1.6/source/Irrlicht/CCSMLoader.h b/irrlicht-1.6/source/Irrlicht/CCSMLoader.h deleted file mode 100644 index 190108b0e..000000000 --- a/irrlicht-1.6/source/Irrlicht/CCSMLoader.h +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h -// -// This Loader has been originally written by Saurav Mohapatra. I (Nikolaus Gebhardt) -// modified some minor things and integrated it into Irrlicht 0.9. Thanks a lot -// to Saurav Mohapatra for his work on this and that he gave me his permission to -// add it into Irrlicht. -// I did some changes to Saurav Mohapatra's loader, so I'm writing this down here: -// - Replaced all dependencies to STL and stdio with irr:: methods/constructs. -// - Moved everything into namespace irr::scene -// - Replaced logging with Irrlicht's internal logger. -// - Removed dependency to IrrlichtDevice -// - Moved all internal structures into CCSMLoader.cpp -// - Made the texture root parameter dependent on a ISceneManager string parameter -// - removed exceptions -// - Implemented CCCSMLoader as IMeshLoader -// - Fixed some problems with memory leaks -// - Fixed bounding box calculation -// -// The original readme of this file looks like this: -// -// This component provides a loader for the Cartography shop 4.x .csm maps for Irrlicht Engine. -// This is a part of the M_TRIX Project. -// This is licensed under the ZLib/LibPNG license -// The IrrCSM library is written by Saurav Mohapatra. -// -// Features -// -// The IrrCSM library features the following capabilities -// -// * Loads the .csm 4.0 and 4.1 files transparently -// * Presents the loaded file as irr::scene::IAnimatedMesh for easy creation of IOctTreeSceneNode -// * Loads the textures given the correct texture root. hence map and textures can be in separate directories -// -// For more informations go to http://www.geocities.com/standard_template/irrcsm/downloads.html - -#ifndef __CSM_LOADER_H_INCLUDED__ -#define __CSM_LOADER_H_INCLUDED__ - -#include "irrArray.h" -#include "IMesh.h" -#include "irrString.h" -#include "IFileSystem.h" -#include "IMeshLoader.h" - -namespace irr -{ -namespace scene -{ - class CSMFile; - class ISceneManager; - - class CCSMLoader : public scene::IMeshLoader - { - public: - - CCSMLoader(ISceneManager* manager, io::IFileSystem* fs); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".bsp") - virtual bool isALoadableFileExtension(const io::path& filename) const; - - //! creates/loads an animated mesh from the file. - virtual IAnimatedMesh* createMesh(io::IReadFile* file); - - private: - - scene::IMesh* createCSMMesh(io::IReadFile* file); - - scene::IMesh* createIrrlichtMesh(const CSMFile* csmFile, - const core::stringc& textureRoot, const io::path& lmprefix); - - io::IFileSystem* FileSystem; - scene::ISceneManager* SceneManager; - }; - -} // end namespace -} // end namespace - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CCameraSceneNode.cpp b/irrlicht-1.6/source/Irrlicht/CCameraSceneNode.cpp deleted file mode 100644 index 5dbf11c75..000000000 --- a/irrlicht-1.6/source/Irrlicht/CCameraSceneNode.cpp +++ /dev/null @@ -1,350 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CCameraSceneNode.h" -#include "ISceneManager.h" -#include "IVideoDriver.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - - -//! constructor -CCameraSceneNode::CCameraSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position, const core::vector3df& lookat) - : ICameraSceneNode(parent, mgr, id, position), - Target(lookat), UpVector(0.0f, 1.0f, 0.0f), ZNear(1.0f), ZFar(3000.0f), - InputReceiverEnabled(true), TargetAndRotationAreBound(false) -{ - #ifdef _DEBUG - setDebugName("CCameraSceneNode"); - #endif - - // set default projection - Fovy = core::PI / 2.5f; // Field of view, in radians. - - const video::IVideoDriver* const d = mgr?mgr->getVideoDriver():0; - if (d) - Aspect = (f32)d->getCurrentRenderTargetSize().Width / - (f32)d->getCurrentRenderTargetSize().Height; - else - Aspect = 4.0f / 3.0f; // Aspect ratio. - - recalculateProjectionMatrix(); - recalculateViewArea(); -} - - -//! Disables or enables the camera to get key or mouse inputs. -void CCameraSceneNode::setInputReceiverEnabled(bool enabled) -{ - InputReceiverEnabled = enabled; -} - - -//! Returns if the input receiver of the camera is currently enabled. -bool CCameraSceneNode::isInputReceiverEnabled() const -{ - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return InputReceiverEnabled; -} - - -//! Sets the projection matrix of the camera. -/** The core::matrix4 class has some methods -to build a projection matrix. e.g: core::matrix4::buildProjectionMatrixPerspectiveFovLH -\param projection: The new projection matrix of the camera. */ -void CCameraSceneNode::setProjectionMatrix(const core::matrix4& projection, bool isOrthogonal) -{ - IsOrthogonal = isOrthogonal; - ViewArea.getTransform ( video::ETS_PROJECTION ) = projection; -} - - -//! Gets the current projection matrix of the camera -//! \return Returns the current projection matrix of the camera. -const core::matrix4& CCameraSceneNode::getProjectionMatrix() const -{ - return ViewArea.getTransform ( video::ETS_PROJECTION ); -} - - -//! Gets the current view matrix of the camera -//! \return Returns the current view matrix of the camera. -const core::matrix4& CCameraSceneNode::getViewMatrix() const -{ - return ViewArea.getTransform ( video::ETS_VIEW ); -} - - -//! Sets a custom view matrix affector. The matrix passed here, will be -//! multiplied with the view matrix when it gets updated. -//! This allows for custom camera setups like, for example, a reflection camera. -/** \param affector: The affector matrix. */ -void CCameraSceneNode::setViewMatrixAffector(const core::matrix4& affector) -{ - Affector = affector; -} - - -//! Gets the custom view matrix affector. -const core::matrix4& CCameraSceneNode::getViewMatrixAffector() const -{ - return Affector; -} - - -//! It is possible to send mouse and key events to the camera. Most cameras -//! may ignore this input, but camera scene nodes which are created for -//! example with scene::ISceneManager::addMayaCameraSceneNode or -//! scene::ISceneManager::addFPSCameraSceneNode, may want to get this input -//! for changing their position, look at target or whatever. -bool CCameraSceneNode::OnEvent(const SEvent& event) -{ - if (!InputReceiverEnabled) - return false; - - // send events to event receiving animators - - core::list<ISceneNodeAnimator*>::Iterator ait = Animators.begin(); - - for (; ait != Animators.end(); ++ait) - if ((*ait)->isEventReceiverEnabled() && (*ait)->OnEvent(event)) - return true; - - // if nobody processed the event, return false - return false; -} - - -//! sets the look at target of the camera -//! \param pos: Look at target of the camera. -void CCameraSceneNode::setTarget(const core::vector3df& pos) -{ - Target = pos; - - if(TargetAndRotationAreBound) - { - const core::vector3df toTarget = Target - getAbsolutePosition(); - ISceneNode::setRotation(toTarget.getHorizontalAngle()); - } -} - - -//! Sets the rotation of the node. -/** This only modifies the relative rotation of the node. -If the camera's target and rotation are bound ( @see bindTargetAndRotation() ) -then calling this will also change the camera's target to match the rotation. -\param rotation New rotation of the node in degrees. */ -void CCameraSceneNode::setRotation(const core::vector3df& rotation) -{ - if(TargetAndRotationAreBound) - Target = getAbsolutePosition() + rotation.rotationToDirection(); - - ISceneNode::setRotation(rotation); -} - - -//! Gets the current look at target of the camera -//! \return Returns the current look at target of the camera -const core::vector3df& CCameraSceneNode::getTarget() const -{ - return Target; -} - - -//! sets the up vector of the camera -//! \param pos: New upvector of the camera. -void CCameraSceneNode::setUpVector(const core::vector3df& pos) -{ - UpVector = pos; -} - - -//! Gets the up vector of the camera. -//! \return Returns the up vector of the camera. -const core::vector3df& CCameraSceneNode::getUpVector() const -{ - return UpVector; -} - - -f32 CCameraSceneNode::getNearValue() const -{ - return ZNear; -} - - -f32 CCameraSceneNode::getFarValue() const -{ - return ZFar; -} - - -f32 CCameraSceneNode::getAspectRatio() const -{ - return Aspect; -} - - -f32 CCameraSceneNode::getFOV() const -{ - return Fovy; -} - - -void CCameraSceneNode::setNearValue(f32 f) -{ - ZNear = f; - recalculateProjectionMatrix(); -} - - -void CCameraSceneNode::setFarValue(f32 f) -{ - ZFar = f; - recalculateProjectionMatrix(); -} - - -void CCameraSceneNode::setAspectRatio(f32 f) -{ - Aspect = f; - recalculateProjectionMatrix(); -} - - -void CCameraSceneNode::setFOV(f32 f) -{ - Fovy = f; - recalculateProjectionMatrix(); -} - - -void CCameraSceneNode::recalculateProjectionMatrix() -{ - ViewArea.getTransform ( video::ETS_PROJECTION ).buildProjectionMatrixPerspectiveFovLH(Fovy, Aspect, ZNear, ZFar); -} - - -//! prerender -void CCameraSceneNode::OnRegisterSceneNode() -{ - core::vector3df pos = getAbsolutePosition(); - core::vector3df tgtv = Target - pos; - tgtv.normalize(); - - // if upvector and vector to the target are the same, we have a - // problem. so solve this problem: - core::vector3df up = UpVector; - up.normalize(); - - f32 dp = tgtv.dotProduct(up); - - if ( core::equals(fabsf(dp), 1.f) ) - { - up.X += 0.5f; - } - - ViewArea.getTransform(video::ETS_VIEW).buildCameraLookAtMatrixLH(pos, Target, up); - ViewArea.getTransform(video::ETS_VIEW) *= Affector; - recalculateViewArea(); - - if ( SceneManager->getActiveCamera () == this ) - SceneManager->registerNodeForRendering(this, ESNRP_CAMERA); - - ISceneNode::OnRegisterSceneNode(); -} - - -//! render -void CCameraSceneNode::render() -{ - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - if ( driver) - { - driver->setTransform(video::ETS_PROJECTION, ViewArea.getTransform ( video::ETS_PROJECTION) ); - driver->setTransform(video::ETS_VIEW, ViewArea.getTransform ( video::ETS_VIEW) ); - } -} - - -//! returns the axis aligned bounding box of this node -const core::aabbox3d<f32>& CCameraSceneNode::getBoundingBox() const -{ - return ViewArea.getBoundingBox(); -} - - -//! returns the view frustum. needed sometimes by bsp or lod render nodes. -const SViewFrustum* CCameraSceneNode::getViewFrustum() const -{ - return &ViewArea; -} - - -void CCameraSceneNode::recalculateViewArea() -{ - ViewArea.cameraPosition = getAbsolutePosition(); - - core::matrix4 m(core::matrix4::EM4CONST_NOTHING); - m.setbyproduct_nocheck(ViewArea.getTransform(video::ETS_PROJECTION), - ViewArea.getTransform(video::ETS_VIEW)); - ViewArea.setFrom(m); -} - - -//! Writes attributes of the scene node. -void CCameraSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const -{ - ISceneNode::serializeAttributes(out, options); - - out->addVector3d("Target", Target); - out->addVector3d("UpVector", UpVector); - out->addFloat("Fovy", Fovy); - out->addFloat("Aspect", Aspect); - out->addFloat("ZNear", ZNear); - out->addFloat("ZFar", ZFar); - out->addBool("Binding", TargetAndRotationAreBound); -} - - -//! Reads attributes of the scene node. -void CCameraSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - ISceneNode::deserializeAttributes(in, options); - - Target = in->getAttributeAsVector3d("Target"); - UpVector = in->getAttributeAsVector3d("UpVector"); - Fovy = in->getAttributeAsFloat("Fovy"); - Aspect = in->getAttributeAsFloat("Aspect"); - ZNear = in->getAttributeAsFloat("ZNear"); - ZFar = in->getAttributeAsFloat("ZFar"); - TargetAndRotationAreBound = in->getAttributeAsBool("Binding"); - - recalculateProjectionMatrix(); - recalculateViewArea(); -} - - -//! Set the binding between the camera's rotation adn target. -void CCameraSceneNode::bindTargetAndRotation(bool bound) -{ - TargetAndRotationAreBound = bound; -} - - -//! Gets the binding between the camera's rotation and target. -bool CCameraSceneNode::getTargetAndRotationBinding(void) const -{ - return TargetAndRotationAreBound; -} - - -} // end namespace -} // end namespace - diff --git a/irrlicht-1.6/source/Irrlicht/CCameraSceneNode.h b/irrlicht-1.6/source/Irrlicht/CCameraSceneNode.h deleted file mode 100644 index 0071bba76..000000000 --- a/irrlicht-1.6/source/Irrlicht/CCameraSceneNode.h +++ /dev/null @@ -1,169 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_CAMERA_SCENE_NODE_H_INCLUDED__ -#define __C_CAMERA_SCENE_NODE_H_INCLUDED__ - -#include "ICameraSceneNode.h" -#include "SViewFrustum.h" - -namespace irr -{ -namespace scene -{ - - class CCameraSceneNode : public ICameraSceneNode - { - public: - - //! constructor - CCameraSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& lookat = core::vector3df(0,0,100)); - - //! Sets the projection matrix of the camera. - /** The core::matrix4 class has some methods - to build a projection matrix. e.g: core::matrix4::buildProjectionMatrixPerspectiveFovLH. - Note that the matrix will only stay as set by this method until one of - the following Methods are called: setNearValue, setFarValue, setAspectRatio, setFOV. - \param projection The new projection matrix of the camera. - \param isOrthogonal Set this to true if the matrix is an orthogonal one (e.g. - from matrix4::buildProjectionMatrixOrthoLH(). */ - virtual void setProjectionMatrix(const core::matrix4& projection, bool isOrthogonal = false); - - //! Gets the current projection matrix of the camera - //! \return Returns the current projection matrix of the camera. - virtual const core::matrix4& getProjectionMatrix() const; - - //! Gets the current view matrix of the camera - //! \return Returns the current view matrix of the camera. - virtual const core::matrix4& getViewMatrix() const; - - //! Sets a custom view matrix affector. - /** \param affector: The affector matrix. */ - virtual void setViewMatrixAffector(const core::matrix4& affector); - - //! Gets the custom view matrix affector. - virtual const core::matrix4& getViewMatrixAffector() const; - - //! It is possible to send mouse and key events to the camera. Most cameras - //! may ignore this input, but camera scene nodes which are created for - //! example with scene::ISceneManager::addMayaCameraSceneNode or - //! scene::ISceneManager::addMeshViewerCameraSceneNode, may want to get this input - //! for changing their position, look at target or whatever. - virtual bool OnEvent(const SEvent& event); - - //! Sets the look at target of the camera - /** If the camera's target and rotation are bound ( @see bindTargetAndRotation() ) - then calling this will also change the camera's scene node rotation to match the target. - \param pos: Look at target of the camera. */ - virtual void setTarget(const core::vector3df& pos); - - //! Sets the rotation of the node. - /** This only modifies the relative rotation of the node. - If the camera's target and rotation are bound ( @see bindTargetAndRotation() ) - then calling this will also change the camera's target to match the rotation. - \param rotation New rotation of the node in degrees. */ - virtual void setRotation(const core::vector3df& rotation); - - //! Gets the current look at target of the camera - /** \return The current look at target of the camera */ - virtual const core::vector3df& getTarget() const; - - //! Sets the up vector of the camera. - //! \param pos: New upvector of the camera. - virtual void setUpVector(const core::vector3df& pos); - - //! Gets the up vector of the camera. - //! \return Returns the up vector of the camera. - virtual const core::vector3df& getUpVector() const; - - //! Gets distance from the camera to the near plane. - //! \return Value of the near plane of the camera. - virtual f32 getNearValue() const; - - //! Gets the distance from the camera to the far plane. - //! \return Value of the far plane of the camera. - virtual f32 getFarValue() const; - - //! Get the aspect ratio of the camera. - //! \return The aspect ratio of the camera. - virtual f32 getAspectRatio() const; - - //! Gets the field of view of the camera. - //! \return Field of view of the camera - virtual f32 getFOV() const; - - //! Sets the value of the near clipping plane. (default: 1.0f) - virtual void setNearValue(f32 zn); - - //! Sets the value of the far clipping plane (default: 2000.0f) - virtual void setFarValue(f32 zf); - - //! Sets the aspect ratio (default: 4.0f / 3.0f) - virtual void setAspectRatio(f32 aspect); - - //! Sets the field of view (Default: PI / 3.5f) - virtual void setFOV(f32 fovy); - - //! PreRender event - virtual void OnRegisterSceneNode(); - - //! Render - virtual void render(); - - //! Returns the axis aligned bounding box of this node - virtual const core::aabbox3d<f32>& getBoundingBox() const; - - //! Returns the view area. Sometimes needed by bsp or lod render nodes. - virtual const SViewFrustum* getViewFrustum() const; - - //! Disables or enables the camera to get key or mouse inputs. - //! If this is set to true, the camera will respond to key inputs - //! otherwise not. - virtual void setInputReceiverEnabled(bool enabled); - - //! Returns if the input receiver of the camera is currently enabled. - virtual bool isInputReceiverEnabled() const; - - //! Writes attributes of the scene node. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const; - - //! Reads attributes of the scene node. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() const { return ESNT_CAMERA; } - - //! Binds the camera scene node's rotation to its target position and vice vera, or unbinds them. - virtual void bindTargetAndRotation(bool bound); - - //! Queries if the camera scene node's rotation and its target position are bound together. - virtual bool getTargetAndRotationBinding(void) const; - - protected: - - void recalculateProjectionMatrix(); - void recalculateViewArea(); - - core::vector3df Target; - core::vector3df UpVector; - - f32 Fovy; // Field of view, in radians. - f32 Aspect; // Aspect ratio. - f32 ZNear; // value of the near view-plane. - f32 ZFar; // Z-value of the far view-plane. - - SViewFrustum ViewArea; - core::matrix4 Affector; - - bool InputReceiverEnabled; - bool TargetAndRotationAreBound; - }; - -} // end namespace -} // end namespace - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CColladaFileLoader.cpp b/irrlicht-1.6/source/Irrlicht/CColladaFileLoader.cpp deleted file mode 100644 index 0d0c893ea..000000000 --- a/irrlicht-1.6/source/Irrlicht/CColladaFileLoader.cpp +++ /dev/null @@ -1,2878 +0,0 @@ -// Copyright (C) 2002-2009 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_COLLADA_LOADER_ - -#include "CColladaFileLoader.h" -#include "os.h" -#include "IXMLReader.h" -#include "IDummyTransformationSceneNode.h" -#include "SAnimatedMesh.h" -#include "fast_atof.h" -#include "quaternion.h" -#include "ILightSceneNode.h" -#include "ICameraSceneNode.h" -#include "IMeshManipulator.h" -#include "IReadFile.h" -#include "IAttributes.h" -#include "IMeshCache.h" -#include "IMeshSceneNode.h" -#include "SMeshBufferLightMap.h" -#include "irrMap.h" - -#ifdef _DEBUG -#define COLLADA_READER_DEBUG -#endif -namespace irr -{ -namespace scene -{ -namespace -{ - // currently supported COLLADA tag names - const core::stringc colladaSectionName = "COLLADA"; - const core::stringc librarySectionName = "library"; - const core::stringc libraryNodesSectionName = "library_nodes"; - const core::stringc libraryGeometriesSectionName = "library_geometries"; - const core::stringc libraryMaterialsSectionName = "library_materials"; - const core::stringc libraryImagesSectionName = "library_images"; - const core::stringc libraryVisualScenesSectionName = "library_visual_scenes"; - const core::stringc libraryCamerasSectionName = "library_cameras"; - const core::stringc libraryLightsSectionName = "library_lights"; - const core::stringc libraryEffectsSectionName = "library_effects"; - const core::stringc assetSectionName = "asset"; - const core::stringc sceneSectionName = "scene"; - const core::stringc visualSceneSectionName = "visual_scene"; - - const core::stringc lightPrefabName = "light"; - const core::stringc cameraPrefabName = "camera"; - const core::stringc materialSectionName = "material"; - const core::stringc geometrySectionName = "geometry"; - const core::stringc imageSectionName = "image"; - const core::stringc textureSectionName = "texture"; - const core::stringc effectSectionName = "effect"; - - const core::stringc pointSectionName = "point"; - const core::stringc directionalSectionName ="directional"; - const core::stringc spotSectionName = "spot"; - const core::stringc ambientSectionName = "ambient"; - const core::stringc meshSectionName = "mesh"; - const core::stringc sourceSectionName = "source"; - const core::stringc arraySectionName = "array"; - const core::stringc floatArraySectionName ="float_array"; - const core::stringc intArraySectionName = "int_array"; - const core::stringc techniqueCommonSectionName = "technique_common"; - const core::stringc accessorSectionName = "accessor"; - const core::stringc verticesSectionName = "vertices"; - const core::stringc inputTagName = "input"; - const core::stringc polylistSectionName = "polylist"; - const core::stringc trianglesSectionName = "triangles"; - const core::stringc polygonsSectionName = "polygons"; - const core::stringc primitivesName = "p"; - const core::stringc vcountName = "vcount"; - - const core::stringc upAxisNodeName = "up_axis"; - const core::stringc nodeSectionName = "node"; - const core::stringc lookatNodeName = "lookat"; - const core::stringc matrixNodeName = "matrix"; - const core::stringc perspectiveNodeName = "perspective"; - const core::stringc rotateNodeName = "rotate"; - const core::stringc scaleNodeName = "scale"; - const core::stringc translateNodeName = "translate"; - const core::stringc skewNodeName = "skew"; - const core::stringc bboxNodeName = "boundingbox"; - const core::stringc minNodeName = "min"; - const core::stringc maxNodeName = "max"; - const core::stringc instanceName = "instance"; - const core::stringc instanceGeometryName = "instance_geometry"; - const core::stringc instanceSceneName = "instance_visual_scene"; - const core::stringc instanceEffectName = "instance_effect"; - const core::stringc instanceMaterialName = "instance_material"; - const core::stringc instanceLightName = "instance_light"; - const core::stringc instanceNodeName = "instance_node"; - const core::stringc bindMaterialName = "bind_material"; - const core::stringc extraNodeName = "extra"; - const core::stringc techniqueNodeName = "technique"; - const core::stringc colorNodeName = "color"; - const core::stringc floatNodeName = "float"; - const core::stringc float2NodeName = "float2"; - const core::stringc float3NodeName = "float3"; - - const core::stringc newParamName = "newparam"; - const core::stringc paramTagName = "param"; - const core::stringc initFromName = "init_from"; - const core::stringc dataName = "data"; - const core::stringc wrapsName = "wrap_s"; - const core::stringc wraptName = "wrap_t"; - const core::stringc minfilterName = "minfilter"; - const core::stringc magfilterName = "magfilter"; - const core::stringc mipfilterName = "mipfilter"; - - const core::stringc textureNodeName = "texture"; - const core::stringc doubleSidedNodeName = "double_sided"; - const core::stringc constantAttenuationNodeName = "constant_attenuation"; - const core::stringc linearAttenuationNodeName = "linear_attenuation"; - const core::stringc quadraticAttenuationNodeName = "quadratic_attenuation"; - const core::stringc falloffAngleNodeName = "falloff_angle"; - const core::stringc falloffExponentNodeName = "falloff_exponent"; - - const core::stringc profileCOMMONSectionName = "profile_COMMON"; - const core::stringc profileCOMMONAttributeName = "COMMON"; - - const char* const inputSemanticNames[] = {"POSITION", "VERTEX", "NORMAL", "TEXCOORD", - "UV", "TANGENT", "IMAGE", "TEXTURE", 0}; -} - - //! following class is for holding and creating instances of library - //! objects, named prefabs in this loader. - class CPrefab : public IColladaPrefab - { - public: - - CPrefab(const core::stringc& id) : Id(id) - { - } - - //! creates an instance of this prefab - virtual scene::ISceneNode* addInstance(scene::ISceneNode* parent, - scene::ISceneManager* mgr) - { - // empty implementation - return 0; - } - - //! returns id of this prefab - virtual const core::stringc& getId() - { - return Id; - } - - protected: - - core::stringc Id; - }; - - - //! prefab for a light scene node - class CLightPrefab : public CPrefab - { - public: - - CLightPrefab(const core::stringc& id) : CPrefab(id) - { - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA: loaded light prefab", Id.c_str()); - #endif - } - - video::SLight LightData; // publically accessible - - //! creates an instance of this prefab - virtual scene::ISceneNode* addInstance(scene::ISceneNode* parent, - scene::ISceneManager* mgr) - { - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA: Constructing light instance", Id.c_str()); - #endif - - scene::ILightSceneNode* l = mgr->addLightSceneNode(parent); - if (l) - { - l->setLightData ( LightData ); - l->setName(getId()); - } - return l; - } - }; - - - //! prefab for a mesh scene node - class CGeometryPrefab : public CPrefab - { - public: - - CGeometryPrefab(const core::stringc& id) : CPrefab(id) - { - } - - scene::IMesh* Mesh; - - //! creates an instance of this prefab - virtual scene::ISceneNode* addInstance(scene::ISceneNode* parent, - scene::ISceneManager* mgr) - { - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA: Constructing mesh instance", Id.c_str()); - #endif - - scene::ISceneNode* m = mgr->addMeshSceneNode(Mesh, parent); - if (m) - { - m->setName(getId()); -// m->setDebugDataVisible(scene::EDS_FULL); - } - return m; - } - }; - - - //! prefab for a camera scene node - class CCameraPrefab : public CPrefab - { - public: - - CCameraPrefab(const core::stringc& id) - : CPrefab(id), YFov(core::PI / 2.5f), ZNear(1.0f), ZFar(3000.0f) - { - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA: loaded camera prefab", Id.c_str()); - #endif - } - - // publicly accessible data - f32 YFov; - f32 ZNear; - f32 ZFar; - - //! creates an instance of this prefab - virtual scene::ISceneNode* addInstance(scene::ISceneNode* parent, - scene::ISceneManager* mgr) - { - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA: Constructing camera instance", Id.c_str()); - #endif - - scene::ICameraSceneNode* c = mgr->addCameraSceneNode(parent); - if (c) - { - c->setFOV(YFov); - c->setNearValue(ZNear); - c->setFarValue(ZFar); - c->setName(getId()); - } - return c; - } - }; - - - //! prefab for a container scene node - //! Collects other prefabs and instantiates them upon instantiation - //! Uses a dummy scene node to return the childs as one scene node - class CScenePrefab : public CPrefab - { - public: - CScenePrefab(const core::stringc& id) : CPrefab(id) - { - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA: loaded scene prefab", Id.c_str()); - #endif - } - - //! creates an instance of this prefab - virtual scene::ISceneNode* addInstance(scene::ISceneNode* parent, - scene::ISceneManager* mgr) - { - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA: Constructing scene instance", Id.c_str()); - #endif - - if (Childs.size()==0) - return 0; - - scene::IDummyTransformationSceneNode* s = mgr->addDummyTransformationSceneNode(parent); - if (s) - { - s->setName(getId()); - s->getRelativeTransformationMatrix() = Transformation; - core::stringc t; - for (u32 i=0; i<16; ++i) - { - t+=core::stringc(Transformation[i]); - t+=" "; - } -os::Printer::log("COLLADA: Transformation", t.c_str()); - - for (u32 i=0; i<Childs.size(); ++i) - Childs[i]->addInstance(s, mgr); - } - - return s; - } - - core::array<IColladaPrefab*> Childs; - core::matrix4 Transformation; - }; - - -//! Constructor -CColladaFileLoader::CColladaFileLoader(scene::ISceneManager* smgr, - io::IFileSystem* fs) -: SceneManager(smgr), FileSystem(fs), DummyMesh(0), - FirstLoadedMesh(0), LoadedMeshCount(0), CreateInstances(false) -{ - #ifdef _DEBUG - setDebugName("CColladaFileLoader"); - #endif -} - - -//! destructor -CColladaFileLoader::~CColladaFileLoader() -{ - if (DummyMesh) - DummyMesh->drop(); - - if (FirstLoadedMesh) - FirstLoadedMesh->drop(); -} - - -//! Returns true if the file maybe is able to be loaded by this class. -/** This decision should be based only on the file extension (e.g. ".cob") */ -bool CColladaFileLoader::isALoadableFileExtension(const io::path& filename) const -{ - return core::hasFileExtension ( filename, "xml", "dae" ); -} - - -//! 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* CColladaFileLoader::createMesh(io::IReadFile* file) -{ - io::IXMLReaderUTF8* reader = FileSystem->createXMLReaderUTF8(file); - if (!reader) - return 0; - - CurrentlyLoadingMesh = file->getFileName(); - CreateInstances = SceneManager->getParameters()->getAttributeAsBool( - scene::COLLADA_CREATE_SCENE_INSTANCES); - Version = 0; - FlipAxis = false; - - // read until COLLADA section, skip other parts - - while(reader->read()) - { - if (reader->getNodeType() == io::EXN_ELEMENT) - { - if (colladaSectionName == reader->getNodeName()) - readColladaSection(reader); - else - skipSection(reader, true); // unknown section - } - } - - reader->drop(); - if (!Version) - return 0; - - // because this loader loads and creates a complete scene instead of - // a single mesh, return an empty dummy mesh to make the scene manager - // know that everything went well. - if (!DummyMesh) - DummyMesh = new SAnimatedMesh(); - scene::IAnimatedMesh* returnMesh = DummyMesh; - - if (Version < 10400) - instantiateNode(SceneManager->getRootSceneNode()); - - // add the first loaded mesh into the mesh cache too, if more than one - // meshes have been loaded from the file - if (LoadedMeshCount>1 && FirstLoadedMesh) - { - os::Printer::log("Added COLLADA mesh", FirstLoadedMeshName.c_str()); - SceneManager->getMeshCache()->addMesh(FirstLoadedMeshName.c_str(), FirstLoadedMesh); - } - - // clean up temporary loaded data - clearData(); - - returnMesh->grab(); // store until this loader is destroyed - - DummyMesh->drop(); - DummyMesh = 0; - - if (FirstLoadedMesh) - FirstLoadedMesh->drop(); - FirstLoadedMesh = 0; - LoadedMeshCount = 0; - - return returnMesh; -} - - -//! skips an (unknown) section in the collada document -void CColladaFileLoader::skipSection(io::IXMLReaderUTF8* reader, bool reportSkipping) -{ - #ifndef COLLADA_READER_DEBUG - if (reportSkipping) // always report in COLLADA_READER_DEBUG mode - #endif - os::Printer::log("COLLADA skipping section", core::stringc(reader->getNodeName()).c_str()); - - // skip if this element is empty anyway. - if (reader->isEmptyElement()) - return; - - // read until we've reached the last element in this section - u32 tagCounter = 1; - - while(tagCounter && reader->read()) - { - if (reader->getNodeType() == io::EXN_ELEMENT && - !reader->isEmptyElement()) - { - #ifdef COLLADA_READER_DEBUG - if (reportSkipping) - os::Printer::log("Skipping COLLADA unknown element", core::stringc(reader->getNodeName()).c_str()); - #endif // COLLADA_READER_DEBUG - - ++tagCounter; - } - else - if (reader->getNodeType() == io::EXN_ELEMENT_END) - --tagCounter; - } -} - - -//! reads the <COLLADA> section and its content -void CColladaFileLoader::readColladaSection(io::IXMLReaderUTF8* reader) -{ - if (reader->isEmptyElement()) - return; - - const f32 version = core::fast_atof(core::stringc(reader->getAttributeValue("version")).c_str()); - Version = core::floor32(version)*10000+core::round32(core::fract(version)*1000.0f); - // Version 1.4 can be checked for by if (Version >= 10400) - - while(reader->read()) - if (reader->getNodeType() == io::EXN_ELEMENT) - { - if (assetSectionName == reader->getNodeName()) - readAssetSection(reader); - else - if (librarySectionName == reader->getNodeName()) - readLibrarySection(reader); - else - if (libraryNodesSectionName == reader->getNodeName()) - readLibrarySection(reader); - else - if (libraryGeometriesSectionName == reader->getNodeName()) - readLibrarySection(reader); - else - if (libraryMaterialsSectionName == reader->getNodeName()) - readLibrarySection(reader); - else - if (libraryEffectsSectionName == reader->getNodeName()) - readLibrarySection(reader); - else - if (libraryImagesSectionName == reader->getNodeName()) - readLibrarySection(reader); - else - if (libraryCamerasSectionName == reader->getNodeName()) - readLibrarySection(reader); - else - if (libraryLightsSectionName == reader->getNodeName()) - readLibrarySection(reader); - else - if (libraryVisualScenesSectionName == reader->getNodeName()) - readVisualSceneLibrary(reader); - else - if (assetSectionName == reader->getNodeName()) - readAssetSection(reader); - else - if (sceneSectionName == reader->getNodeName()) - readSceneSection(reader); - else - { - os::Printer::log("COLLADA loader warning: Wrong tag usage found", reader->getNodeName(), ELL_WARNING); - skipSection(reader, true); // unknown section - } - } -} - - -//! reads a <library> section and its content -void CColladaFileLoader::readLibrarySection(io::IXMLReaderUTF8* reader) -{ - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA reading library"); - #endif - - if (reader->isEmptyElement()) - return; - - while(reader->read()) - { - if (reader->getNodeType() == io::EXN_ELEMENT) - { - // animation section tbd - if (cameraPrefabName == reader->getNodeName()) - readCameraPrefab(reader); - else - // code section tbd - // controller section tbd - if (geometrySectionName == reader->getNodeName()) - readGeometry(reader); - else - if (imageSectionName == reader->getNodeName()) - readImage(reader); - else - if (lightPrefabName == reader->getNodeName()) - readLightPrefab(reader); - else - if (materialSectionName == reader->getNodeName()) - readMaterial(reader); - else - if (nodeSectionName == reader->getNodeName()) - { - CScenePrefab p(""); - - readNodeSection(reader, SceneManager->getRootSceneNode(), &p); - } - else - if (effectSectionName == reader->getNodeName()) - readEffect(reader); - else - // program section tbd - if (textureSectionName == reader->getNodeName()) - readTexture(reader); - else - skipSection(reader, true); // unknown section, not all allowed supported yet - } - else - if (reader->getNodeType() == io::EXN_ELEMENT_END) - { - if (librarySectionName == reader->getNodeName()) - break; // end reading. - if (libraryNodesSectionName == reader->getNodeName()) - break; // end reading. - if (libraryGeometriesSectionName == reader->getNodeName()) - break; // end reading. - if (libraryMaterialsSectionName == reader->getNodeName()) - break; // end reading. - if (libraryEffectsSectionName == reader->getNodeName()) - break; // end reading. - if (libraryImagesSectionName == reader->getNodeName()) - break; // end reading. - if (libraryLightsSectionName == reader->getNodeName()) - break; // end reading. - if (libraryCamerasSectionName == reader->getNodeName()) - break; // end reading. - } - } -} - - -//! reads a <visual_scene> element and stores it as a prefab -void CColladaFileLoader::readVisualSceneLibrary(io::IXMLReaderUTF8* reader) -{ - CScenePrefab* p = 0; - while(reader->read()) - { - if (reader->getNodeType() == io::EXN_ELEMENT) - { - if (visualSceneSectionName == reader->getNodeName()) - p = new CScenePrefab(readId(reader)); - else - if (p && nodeSectionName == reader->getNodeName()) // as a child of visual_scene - readNodeSection(reader, SceneManager->getRootSceneNode(), p); - else - if (assetSectionName == reader->getNodeName()) - readAssetSection(reader); - else - if (extraNodeName == reader->getNodeName()) - skipSection(reader, false); // ignore all other sections - else - { - os::Printer::log("COLLADA loader warning: Wrong tag usage found", reader->getNodeName(), ELL_WARNING); - skipSection(reader, true); // ignore all other sections - } - } - else - if (reader->getNodeType() == io::EXN_ELEMENT_END) - { - if (libraryVisualScenesSectionName == reader->getNodeName()) - return; - else - if ((visualSceneSectionName == reader->getNodeName()) && p) - { - Prefabs.push_back(p); - p = 0; - } - } - } -} - - -//! reads a <scene> section and its content -void CColladaFileLoader::readSceneSection(io::IXMLReaderUTF8* reader) -{ - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA reading scene"); - #endif - - if (reader->isEmptyElement()) - return; - - // read the scene - - core::matrix4 transform; // transformation of this node - core::aabbox3df bbox; - scene::IDummyTransformationSceneNode* node = 0; - - while(reader->read()) - { - if (reader->getNodeType() == io::EXN_ELEMENT) - { - if (lookatNodeName == reader->getNodeName()) - transform *= readLookAtNode(reader); - else - if (matrixNodeName == reader->getNodeName()) - transform *= readMatrixNode(reader); - else - if (perspectiveNodeName == reader->getNodeName()) - transform *= readPerspectiveNode(reader); - else - if (rotateNodeName == reader->getNodeName()) - transform *= readRotateNode(reader); - else - if (scaleNodeName == reader->getNodeName()) - transform *= readScaleNode(reader); - else - if (skewNodeName == reader->getNodeName()) - transform *= readSkewNode(reader); - else - if (translateNodeName == reader->getNodeName()) - transform *= readTranslateNode(reader); - else - if (bboxNodeName == reader->getNodeName()) - readBboxNode(reader, bbox); - else - if (nodeSectionName == reader->getNodeName()) - { - // create dummy node if there is none yet. - if (!node) - node = SceneManager->addDummyTransformationSceneNode(SceneManager->getRootSceneNode()); - - readNodeSection(reader, node); - } - else - if ((instanceSceneName == reader->getNodeName())) - readInstanceNode(reader, SceneManager->getRootSceneNode(), 0); - else - if (extraNodeName == reader->getNodeName()) - skipSection(reader, false); - else - { - os::Printer::log("COLLADA loader warning: Wrong tag usage found", reader->getNodeName(), ELL_WARNING); - skipSection(reader, true); // ignore all other sections - } - } - else - if ((reader->getNodeType() == io::EXN_ELEMENT_END) && - (sceneSectionName == reader->getNodeName())) - return; - } - if (node) - node->getRelativeTransformationMatrix() = transform; -} - - -//! reads a <asset> section and its content -void CColladaFileLoader::readAssetSection(io::IXMLReaderUTF8* reader) -{ - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA reading asset"); - #endif - - if (reader->isEmptyElement()) - return; - - while(reader->read()) - { - if (reader->getNodeType() == io::EXN_ELEMENT) - { - if (upAxisNodeName == reader->getNodeName()) - { - reader->read(); - FlipAxis = (core::stringc("Z_UP") == reader->getNodeData()); - } - } - else - if ((reader->getNodeType() == io::EXN_ELEMENT_END) && - (assetSectionName == reader->getNodeName())) - return; - } -} - - -//! reads a <node> section and its content -void CColladaFileLoader::readNodeSection(io::IXMLReaderUTF8* reader, scene::ISceneNode* parent, CScenePrefab* p) -{ - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA reading node"); - #endif - - if (reader->isEmptyElement()) - return; - - core::stringc name = readId(reader); - - core::matrix4 transform; // transformation of this node - core::aabbox3df bbox; - scene::ISceneNode* node = 0; // instance - CScenePrefab* nodeprefab = 0; // prefab for library_nodes usage - - if (p) - { - nodeprefab = new CScenePrefab(readId(reader)); - p->Childs.push_back(nodeprefab); - Prefabs.push_back(nodeprefab); // in order to delete them later on - } - - // read the node - - while(reader->read()) - { - if (reader->getNodeType() == io::EXN_ELEMENT) - { - if (assetSectionName == reader->getNodeName()) - readAssetSection(reader); - else - if (lookatNodeName == reader->getNodeName()) - transform *= readLookAtNode(reader); - else - if (matrixNodeName == reader->getNodeName()) - transform *= readMatrixNode(reader); - else - if (perspectiveNodeName == reader->getNodeName()) - transform *= readPerspectiveNode(reader); - else - if (rotateNodeName == reader->getNodeName()) - transform *= readRotateNode(reader); - else - if (scaleNodeName == reader->getNodeName()) - transform *= readScaleNode(reader); - else - if (skewNodeName == reader->getNodeName()) - transform *= readSkewNode(reader); - else - if (translateNodeName == reader->getNodeName()) - transform *= readTranslateNode(reader); - else - if (bboxNodeName == reader->getNodeName()) - readBboxNode(reader, bbox); - else - if ((instanceName == reader->getNodeName()) || - (instanceNodeName == reader->getNodeName()) || - (instanceGeometryName == reader->getNodeName()) || - (instanceLightName == reader->getNodeName())) - { - scene::ISceneNode* newnode = 0; - readInstanceNode(reader, parent, &newnode, nodeprefab); - - if (node && newnode) - { - // move children from dummy to new node - core::list<ISceneNode*>::ConstIterator it = node->getChildren().begin(); - for (; it != node->getChildren().end(); it = node->getChildren().begin()) - (*it)->setParent(newnode); - - // remove previous dummy node - node->remove(); - node = newnode; - } - } - else - if (nodeSectionName == reader->getNodeName()) - { - // create dummy node if there is none yet. - if (CreateInstances && !node) - { - scene::IDummyTransformationSceneNode* dummy = - SceneManager->addDummyTransformationSceneNode(parent); - dummy->getRelativeTransformationMatrix() = transform; - node = dummy; - } - else - node = parent; - - // read and add child - readNodeSection(reader, node, nodeprefab); - } - else - if (extraNodeName == reader->getNodeName()) - skipSection(reader, false); - else - skipSection(reader, true); // ignore all other sections - - } // end if node - else - if (reader->getNodeType() == io::EXN_ELEMENT_END) - { - if (nodeSectionName == reader->getNodeName()) - break; - } - } - - if (nodeprefab) - nodeprefab->Transformation = transform; - else - if (node) - { - // set transformation correctly into node. - node->setPosition(transform.getTranslation()); - node->setRotation(transform.getRotationDegrees()); - node->setScale(transform.getScale()); - node->updateAbsolutePosition(); - - node->setName(name); - } -} - - -//! reads a <lookat> element and its content and creates a matrix from it -core::matrix4 CColladaFileLoader::readLookAtNode(io::IXMLReaderUTF8* reader) -{ - core::matrix4 mat; - if (reader->isEmptyElement()) - return mat; - - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA reading look at node"); - #endif - - f32 floats[9]; - readFloatsInsideElement(reader, floats, 9); - - mat.buildCameraLookAtMatrixLH( - core::vector3df(floats[0], floats[1], floats[2]), - core::vector3df(floats[3], floats[4], floats[5]), - core::vector3df(floats[6], floats[7], floats[8])); - - return mat; -} - - -//! reads a <skew> element and its content and creates a matrix from it -core::matrix4 CColladaFileLoader::readSkewNode(io::IXMLReaderUTF8* reader) -{ - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA reading skew node"); - #endif - - core::matrix4 mat; - if (reader->isEmptyElement()) - return mat; - - f32 floats[7]; // angle rotation-axis translation-axis - readFloatsInsideElement(reader, floats, 7); - - // build skew matrix from these 7 floats - core::quaternion q; - q.fromAngleAxis(floats[0]*core::DEGTORAD, core::vector3df(floats[1], floats[2], floats[3])); - mat = q.getMatrix(); - - if (floats[4]==1.f) // along x-axis - { - mat[4]=0.f; - mat[6]=0.f; - mat[8]=0.f; - mat[9]=0.f; - } - else - if (floats[5]==1.f) // along y-axis - { - mat[1]=0.f; - mat[2]=0.f; - mat[8]=0.f; - mat[9]=0.f; - } - else - if (floats[6]==1.f) // along z-axis - { - mat[1]=0.f; - mat[2]=0.f; - mat[4]=0.f; - mat[6]=0.f; - } - - return mat; -} - - -//! reads a <boundingbox> element and its content and stores it in bbox -void CColladaFileLoader::readBboxNode(io::IXMLReaderUTF8* reader, - core::aabbox3df& bbox) -{ - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA reading boundingbox node"); - #endif - - bbox.reset(core::aabbox3df()); - - if (reader->isEmptyElement()) - return; - - f32 floats[3]; - - while(reader->read()) - { - if (reader->getNodeType() == io::EXN_ELEMENT) - { - if (minNodeName == reader->getNodeName()) - { - readFloatsInsideElement(reader, floats, 3); - bbox.MinEdge.set(floats[0], floats[1], floats[2]); - } - else - if (maxNodeName == reader->getNodeName()) - { - readFloatsInsideElement(reader, floats, 3); - bbox.MaxEdge.set(floats[0], floats[1], floats[2]); - } - else - skipSection(reader, true); // ignore all other sections - } - else - if (reader->getNodeType() == io::EXN_ELEMENT_END) - { - if (bboxNodeName == reader->getNodeName()) - break; - } - } -} - - -//! reads a <matrix> element and its content and creates a matrix from it -core::matrix4 CColladaFileLoader::readMatrixNode(io::IXMLReaderUTF8* reader) -{ - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA reading matrix node"); - #endif - - core::matrix4 mat; - if (reader->isEmptyElement()) - return mat; - - readFloatsInsideElement(reader, mat.pointer(), 16); - // put translation into the correct place - if (FlipAxis) - { - core::matrix4 mat2(mat, core::matrix4::EM4CONST_TRANSPOSED); - mat2[1]=mat[8]; - mat2[2]=mat[4]; - mat2[4]=mat[2]; - mat2[5]=mat[10]; - mat2[6]=mat[6]; - mat2[8]=mat[1]; - mat2[9]=mat[9]; - mat2[10]=mat[5]; - mat2[12]=mat[3]; - mat2[13]=mat[11]; - mat2[14]=mat[7]; - return mat2; - } - else - return core::matrix4(mat, core::matrix4::EM4CONST_TRANSPOSED); -} - - -//! reads a <perspective> element and its content and creates a matrix from it -core::matrix4 CColladaFileLoader::readPerspectiveNode(io::IXMLReaderUTF8* reader) -{ - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA reading perspective node"); - #endif - - core::matrix4 mat; - if (reader->isEmptyElement()) - return mat; - - f32 floats[1]; - readFloatsInsideElement(reader, floats, 1); - - // TODO: build perspecitve matrix from this float - - os::Printer::log("COLLADA loader warning: <perspective> not implemented yet.", ELL_WARNING); - - return mat; -} - - -//! reads a <rotate> element and its content and creates a matrix from it -core::matrix4 CColladaFileLoader::readRotateNode(io::IXMLReaderUTF8* reader) -{ - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA reading rotate node"); - #endif - - core::matrix4 mat; - if (reader->isEmptyElement()) - return mat; - - f32 floats[4]; - readFloatsInsideElement(reader, floats, 4); - - if (!core::iszero(floats[3])) - { - core::quaternion q; - if (FlipAxis) - q.fromAngleAxis(floats[3]*core::DEGTORAD, core::vector3df(floats[0], floats[2], floats[1])); - else - q.fromAngleAxis(floats[3]*core::DEGTORAD, core::vector3df(floats[0], floats[1], floats[2])); - return q.getMatrix(); - } - else - return core::IdentityMatrix; -} - - -//! reads a <scale> element and its content and creates a matrix from it -core::matrix4 CColladaFileLoader::readScaleNode(io::IXMLReaderUTF8* reader) -{ - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA reading scale node"); - #endif - - core::matrix4 mat; - if (reader->isEmptyElement()) - return mat; - - f32 floats[3]; - readFloatsInsideElement(reader, floats, 3); - - if (FlipAxis) - mat.setScale(core::vector3df(floats[0], floats[2], floats[1])); - else - mat.setScale(core::vector3df(floats[0], floats[1], floats[2])); - - return mat; -} - - -//! reads a <translate> element and its content and creates a matrix from it -core::matrix4 CColladaFileLoader::readTranslateNode(io::IXMLReaderUTF8* reader) -{ - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA reading translate node"); - #endif - - core::matrix4 mat; - if (reader->isEmptyElement()) - return mat; - - f32 floats[3]; - readFloatsInsideElement(reader, floats, 3); - - if (FlipAxis) - mat.setTranslation(core::vector3df(floats[0], floats[2], floats[1])); - else - mat.setTranslation(core::vector3df(floats[0], floats[1], floats[2])); - - return mat; -} - - -//! reads any kind of <instance*> node -void CColladaFileLoader::readInstanceNode(io::IXMLReaderUTF8* reader, - scene::ISceneNode* parent, scene::ISceneNode** outNode, CScenePrefab* p) -{ - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA reading instance"); - #endif - - // find prefab of the specified id - core::stringc url = reader->getAttributeValue("url"); - uriToId(url); - - if (!reader->isEmptyElement()) - { - while(reader->read()) - { - if (reader->getNodeType() == io::EXN_ELEMENT) - { - if (bindMaterialName == reader->getNodeName()) - readBindMaterialSection(reader,url); - else - if (extraNodeName == reader->getNodeName()) - skipSection(reader, false); - } - else - if (reader->getNodeType() == io::EXN_ELEMENT_END) - break; - } - } - instantiateNode(parent, outNode, p, url); -} - - -void CColladaFileLoader::instantiateNode(scene::ISceneNode* parent, - scene::ISceneNode** outNode, CScenePrefab* p, const core::stringc& url) -{ - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA instantiate node"); - #endif - - for (u32 i=0; i<Prefabs.size(); ++i) - { - if (url == "" || url == Prefabs[i]->getId()) - { - if (p) - p->Childs.push_back(Prefabs[i]); - else - if (CreateInstances) - { - scene::ISceneNode * newNode - = Prefabs[i]->addInstance(parent, SceneManager); - if (outNode) - { - *outNode = newNode; - if (*outNode) - (*outNode)->setName(url); - } - } - return; - } - } -} - - -//! reads a <camera> element and stores it as prefab -void CColladaFileLoader::readCameraPrefab(io::IXMLReaderUTF8* reader) -{ - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA reading camera prefab"); - #endif - - CCameraPrefab* prefab = new CCameraPrefab(readId(reader)); - - if (!reader->isEmptyElement()) - { - // read techniques optics and imager (the latter is completely ignored, though) - readColladaParameters(reader, cameraPrefabName); - - SColladaParam* p; - - // XFOV not yet supported - p = getColladaParameter(ECPN_YFOV); - if (p && p->Type == ECPT_FLOAT) - prefab->YFov = p->Floats[0]; - - p = getColladaParameter(ECPN_ZNEAR); - if (p && p->Type == ECPT_FLOAT) - prefab->ZNear = p->Floats[0]; - - p = getColladaParameter(ECPN_ZFAR); - if (p && p->Type == ECPT_FLOAT) - prefab->ZFar = p->Floats[0]; - // orthographic camera uses LEFT, RIGHT, TOP, and BOTTOM - } - - Prefabs.push_back(prefab); -} - - -//! reads a <image> element and stores it in the image section -void CColladaFileLoader::readImage(io::IXMLReaderUTF8* reader) -{ - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA reading image"); - #endif - - // add image to list of loaded images. - Images.push_back(SColladaImage()); - SColladaImage& image=Images.getLast(); - - image.Id = readId(reader); - image.Dimension.Height = (u32)reader->getAttributeValueAsInt("height"); - image.Dimension.Width = (u32)reader->getAttributeValueAsInt("width"); - - if (Version >= 10400) // start with 1.4 - { - while(reader->read()) - { - if (reader->getNodeType() == io::EXN_ELEMENT) - { - if (assetSectionName == reader->getNodeName()) - skipSection(reader, false); - else - if (initFromName == reader->getNodeName()) - { - reader->read(); - image.Source = reader->getNodeData(); - image.Source.trim(); - image.SourceIsFilename=true; - } - else - if (dataName == reader->getNodeName()) - { - reader->read(); - image.Source = reader->getNodeData(); - image.Source.trim(); - image.SourceIsFilename=false; - } - else - if (extraNodeName == reader->getNodeName()) - skipSection(reader, false); - } - else - if (reader->getNodeType() == io::EXN_ELEMENT_END) - { - if (initFromName == reader->getNodeName()) - return; - } - } - } - else - { - image.Source = reader->getAttributeValue("source"); - image.Source.trim(); - image.SourceIsFilename=false; - } -} - - -//! reads a <texture> element and stores it in the texture section -void CColladaFileLoader::readTexture(io::IXMLReaderUTF8* reader) -{ - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA reading texture"); - #endif - - // add texture to list of loaded textures. - Textures.push_back(SColladaTexture()); - SColladaTexture& texture=Textures.getLast(); - - texture.Id = readId(reader); - - if (!reader->isEmptyElement()) - { - readColladaInputs(reader, textureSectionName); - SColladaInput* input = getColladaInput(ECIS_IMAGE); - if (input) - { - const core::stringc imageName = input->Source; - texture.Texture = getTextureFromImage(imageName); - } - } -} - - -//! reads a <material> element and stores it in the material section -void CColladaFileLoader::readMaterial(io::IXMLReaderUTF8* reader) -{ - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA reading material"); - #endif - - // add material to list of loaded materials. - Materials.push_back(SColladaMaterial()); - - SColladaMaterial& material = Materials.getLast(); - material.Id = readId(reader); - - if (Version >= 10400) - { - while(reader->read()) - { - if (reader->getNodeType() == io::EXN_ELEMENT && - instanceEffectName == reader->getNodeName()) - { - material.InstanceEffectId = reader->getAttributeValue("url"); - uriToId(material.InstanceEffectId); - } - else - if (reader->getNodeType() == io::EXN_ELEMENT_END && - materialSectionName == reader->getNodeName()) - { - break; - } - } // end while reader->read(); - } - else - { - if (!reader->isEmptyElement()) - { - readColladaInputs(reader, materialSectionName); - SColladaInput* input = getColladaInput(ECIS_TEXTURE); - if (input) - { - core::stringc textureName = input->Source; - uriToId(textureName); - for (u32 i=0; i<Textures.size(); ++i) - if (textureName == Textures[i].Id) - { - material.Mat.setTexture(0, Textures[i].Texture); - break; - } - } - - //does not work because the wrong start node is chosen due to reading of inputs before -#if 0 - readColladaParameters(reader, materialSectionName); - - SColladaParam* p; - - p = getColladaParameter(ECPN_AMBIENT); - if (p && p->Type == ECPT_FLOAT3) - material.Mat.AmbientColor = video::SColorf(p->Floats[0],p->Floats[1],p->Floats[2]).toSColor(); - p = getColladaParameter(ECPN_DIFFUSE); - if (p && p->Type == ECPT_FLOAT3) - material.Mat.DiffuseColor = video::SColorf(p->Floats[0],p->Floats[1],p->Floats[2]).toSColor(); - p = getColladaParameter(ECPN_SPECULAR); - if (p && p->Type == ECPT_FLOAT3) - material.Mat.DiffuseColor = video::SColorf(p->Floats[0],p->Floats[1],p->Floats[2]).toSColor(); - p = getColladaParameter(ECPN_SHININESS); - if (p && p->Type == ECPT_FLOAT) - material.Mat.Shininess = p->Floats[0]; -#endif - } - } -} - -void CColladaFileLoader::readEffect(io::IXMLReaderUTF8* reader, SColladaEffect * effect) -{ - #ifdef COLLADA_READER_DEBUG - if (!effect) os::Printer::log("COLLADA reading effect"); - #endif - - static const core::stringc constantNode("constant"); - static const core::stringc lambertNode("lambert"); - static const core::stringc phongNode("phong"); - static const core::stringc blinnNode("blinn"); - static const core::stringc emissionNode("emission"); - static const core::stringc ambientNode("ambient"); - static const core::stringc diffuseNode("diffuse"); - static const core::stringc specularNode("specular"); - static const core::stringc shininessNode("shininess"); - static const core::stringc reflectiveNode("reflective"); - static const core::stringc reflectivityNode("reflectivity"); - static const core::stringc transparentNode("transparent"); - static const core::stringc transparencyNode("transparency"); - static const core::stringc indexOfRefractionNode("index_of_refraction"); - - if (!effect) - { - Effects.push_back(SColladaEffect()); - effect = &Effects.getLast(); - effect->Id = readId(reader); - effect->Transparency = 1.f; - effect->Mat.Lighting=true; - effect->Mat.NormalizeNormals=true; - } - while(reader->read()) - { - if (reader->getNodeType() == io::EXN_ELEMENT) - { - // first come the tags we descend, but ignore the top-levels - if (!reader->isEmptyElement() && ((profileCOMMONSectionName == reader->getNodeName()) || - (techniqueNodeName == reader->getNodeName()))) - readEffect(reader,effect); - else - if (newParamName == reader->getNodeName()) - readParameter(reader); - else - // these are the actual materials inside technique - if (constantNode == reader->getNodeName() || - lambertNode == reader->getNodeName() || - phongNode == reader->getNodeName() || - blinnNode == reader->getNodeName()) - { - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA reading effect part", reader->getNodeName()); - #endif - effect->Mat.setFlag(irr::video::EMF_GOURAUD_SHADING, - phongNode == reader->getNodeName() || - blinnNode == reader->getNodeName()); - while(reader->read()) - { - if (reader->getNodeType() == io::EXN_ELEMENT) - { - const core::stringc node = reader->getNodeName(); - if (emissionNode == node || ambientNode == node || - diffuseNode == node || specularNode == node || - reflectiveNode == node || transparentNode == node ) - { - // color or texture types - while(reader->read()) - { - if (reader->getNodeType() == io::EXN_ELEMENT && - colorNodeName == reader->getNodeName()) - { - const video::SColorf colorf = readColorNode(reader); - const video::SColor color = colorf.toSColor(); - if (emissionNode == node) - effect->Mat.EmissiveColor = color; - else - if (ambientNode == node) - effect->Mat.AmbientColor = color; - else - if (diffuseNode == node) - effect->Mat.DiffuseColor = color; - else - if (specularNode == node) - effect->Mat.SpecularColor = color; - else - if (transparentNode == node) - effect->Transparency = colorf.getAlpha(); - } - else - if (reader->getNodeType() == io::EXN_ELEMENT && - textureNodeName == reader->getNodeName()) - { - const core::stringc tname = reader->getAttributeValue("texture"); - effect->Mat.setTexture(0, getTextureFromImage(tname)); - break; - } - else - if (reader->getNodeType() == io::EXN_ELEMENT) - skipSection(reader, false); - else - if (reader->getNodeType() == io::EXN_ELEMENT_END && - node == reader->getNodeName()) - break; - } - } - else - if (shininessNode == node || reflectivityNode == node || - transparencyNode == node || indexOfRefractionNode == node ) - { - // float or param types - while(reader->read()) - { - if (reader->getNodeType() == io::EXN_ELEMENT && - floatNodeName == reader->getNodeName()) - { - f32 f = readFloatNode(reader); - if (shininessNode == node) - effect->Mat.Shininess = f; - else - if (transparencyNode == node) - effect->Transparency *= f; - } - else - if (reader->getNodeType() == io::EXN_ELEMENT) - skipSection(reader, false); - else - if (reader->getNodeType() == io::EXN_ELEMENT_END && - node == reader->getNodeName()) - break; - } - } - else - skipSection(reader, true); // ignore all other nodes - } - else - if (reader->getNodeType() == io::EXN_ELEMENT_END && ( - constantNode == reader->getNodeName() || - lambertNode == reader->getNodeName() || - phongNode == reader->getNodeName() || - blinnNode == reader->getNodeName() - )) - break; - } - } - else - if (!reader->isEmptyElement() && (extraNodeName == reader->getNodeName())) - readEffect(reader,effect); - else - if (doubleSidedNodeName == reader->getNodeName()) - { - // read the GoogleEarth extra flag for double sided polys - s32 doubleSided = 0; - readIntsInsideElement(reader,&doubleSided,1); - if (doubleSided) - { - #ifdef COLLADA_READER_DEBUG - os::Printer::log("Setting double sided flag for effect."); - #endif - - effect->Mat.setFlag(irr::video::EMF_BACK_FACE_CULLING,false); - } - } - else - skipSection(reader, true); // ignore all other sections - } - else - if (reader->getNodeType() == io::EXN_ELEMENT_END) - { - if (effectSectionName == reader->getNodeName()) - break; - else - if (profileCOMMONSectionName == reader->getNodeName()) - break; - else - if (techniqueNodeName == reader->getNodeName()) - break; - else - if (extraNodeName == reader->getNodeName()) - break; - } - } - - if (effect->Mat.AmbientColor == video::SColor(0) && - effect->Mat.DiffuseColor != video::SColor(0)) - effect->Mat.AmbientColor = effect->Mat.DiffuseColor; - if (effect->Mat.DiffuseColor == video::SColor(0) && - effect->Mat.AmbientColor != video::SColor(0)) - effect->Mat.DiffuseColor = effect->Mat.AmbientColor; - if ((effect->Transparency != 0.0f) && (effect->Transparency != 1.0f)) - { - effect->Mat.MaterialType = irr::video::EMT_TRANSPARENT_VERTEX_ALPHA; - effect->Mat.ZWriteEnable = false; - } - effect->Mat.setFlag(video::EMF_TEXTURE_WRAP, !Parameters.getAttributeAsBool("wrap_s")); - effect->Mat.setFlag(video::EMF_BILINEAR_FILTER, Parameters.getAttributeAsBool("bilinear")); - effect->Mat.setFlag(video::EMF_TRILINEAR_FILTER, Parameters.getAttributeAsBool("trilinear")); - effect->Mat.setFlag(video::EMF_ANISOTROPIC_FILTER, Parameters.getAttributeAsBool("anisotropic")); -} - - -const SColladaMaterial* CColladaFileLoader::findMaterial(const core::stringc& materialName) -{ - // do a quick lookup in the materials - SColladaMaterial matToFind; - matToFind.Id = materialName; - s32 mat = Materials.binary_search(matToFind); - if (mat == -1) - return 0; - // instantiate the material effect if needed - if (Materials[mat].InstanceEffectId.size() != 0) - { - // do a quick lookup in the effects - SColladaEffect effectToFind; - effectToFind.Id = Materials[mat].InstanceEffectId; - s32 effect = Effects.binary_search(effectToFind); - if (effect != -1) - { - // found the effect, instantiate by copying into the material - Materials[mat].Mat = Effects[effect].Mat; - Materials[mat].Transparency = Effects[effect].Transparency; - // and indicate the material is instantiated by removing the effect ref - Materials[mat].InstanceEffectId = ""; - } - else - return 0; - } - return &Materials[mat]; -} - - -void CColladaFileLoader::readBindMaterialSection(io::IXMLReaderUTF8* reader, const core::stringc & id) -{ - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA reading bind material"); - #endif - - while(reader->read()) - { - if (reader->getNodeType() == io::EXN_ELEMENT) - { - if (instanceMaterialName == reader->getNodeName()) - { - // the symbol to retarget, and the target material - core::stringc meshbufferReference = reader->getAttributeValue("symbol"); - if (meshbufferReference.size()==0) - continue; - core::stringc target = reader->getAttributeValue("target"); - uriToId(target); - if (target.size()==0) - continue; - const SColladaMaterial * material = findMaterial(target); - if (!material) - continue; - // bind any pending materials for this node - meshbufferReference = id+"/"+meshbufferReference; -#ifdef COLLADA_READER_DEBUG - os::Printer::log((core::stringc("Material binding: ")+meshbufferReference+" "+target).c_str()); -#endif - if (MaterialsToBind.find(meshbufferReference)) - { - core::array<irr::scene::IMeshBuffer*> & toBind - = MeshesToBind[MaterialsToBind[meshbufferReference]]; -#ifdef COLLADA_READER_DEBUG - os::Printer::log("Material binding now ",material->Id.c_str()); - os::Printer::log("#meshbuffers",core::stringc(toBind.size()).c_str()); -#endif - SMesh tmpmesh; - for (u32 i = 0; i < toBind.size(); ++i) - { - toBind[i]->getMaterial() = material->Mat; - tmpmesh.addMeshBuffer(toBind[i]); - - if ((material->Transparency!=0.0f) && (material->Transparency!=1.0f)) - { - toBind[i]->getMaterial().MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA; - toBind[i]->getMaterial().ZWriteEnable = false; - } - } - SceneManager->getMeshManipulator()->setVertexColors(&tmpmesh,material->Mat.DiffuseColor); - if ((material->Transparency!=0.0f) && (material->Transparency!=1.0f)) - { - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA found transparency material", core::stringc(material->Transparency).c_str()); - #endif - SceneManager->getMeshManipulator()->setVertexColorAlpha(&tmpmesh, core::floor32(material->Transparency*255.0f)); - } - } - } - } - else - if (reader->getNodeType() == io::EXN_ELEMENT_END && - bindMaterialName == reader->getNodeName()) - break; - } -} - - -//! reads a <geometry> element and stores it as mesh if possible -void CColladaFileLoader::readGeometry(io::IXMLReaderUTF8* reader) -{ - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA reading geometry"); - #endif - - core::stringc id = readId(reader); - - core::stringc VertexPositionSource; // each mesh has exactly one <vertex> member, containing - // a POSITION input. This string stores the source of this input. - core::array<SSource> sources; - bool okToReadArray = false; - - SAnimatedMesh* amesh = new SAnimatedMesh(); - scene::SMesh* mesh = new SMesh(); - amesh->addMesh(mesh); - - // handles geometry node and the mesh childs in this loop - // read sources with arrays and accessor for each mesh - if (!reader->isEmptyElement()) - while(reader->read()) - { - if (reader->getNodeType() == io::EXN_ELEMENT) - { - const char* nodeName = reader->getNodeName(); - if (meshSectionName == nodeName) - { - // inside a mesh section. Don't have to do anything here. - } - else - if (sourceSectionName == nodeName) - { - // create a new source - sources.push_back(SSource()); - sources.getLast().Id = readId(reader); - - #ifdef COLLADA_READER_DEBUG - os::Printer::log("Reading source", sources.getLast().Id.c_str()); - #endif - } - else - if (arraySectionName == nodeName || floatArraySectionName == nodeName || intArraySectionName == nodeName) - { - // create a new array and read it. - if (!sources.empty()) - { - sources.getLast().Array.Name = readId(reader); - - int count = reader->getAttributeValueAsInt("count"); - sources.getLast().Array.Data.set_used(count); // pre allocate - - // check if type of array is ok - const char* type = reader->getAttributeValue("type"); - okToReadArray = (type && (!strcmp("float", type) || !strcmp("int", type))) || floatArraySectionName == nodeName || intArraySectionName == nodeName; - - #ifdef COLLADA_READER_DEBUG - os::Printer::log("Read array", sources.getLast().Array.Name.c_str()); - #endif - } - #ifdef COLLADA_READER_DEBUG - else - os::Printer::log("Warning, array outside source found", - readId(reader).c_str()); - #endif - - } - else - if (accessorSectionName == nodeName) // child of source (below a technique tag) - { - #ifdef COLLADA_READER_DEBUG - os::Printer::log("Reading accessor"); - #endif - SAccessor accessor; - accessor.Count = reader->getAttributeValueAsInt("count"); - accessor.Offset = reader->getAttributeValueAsInt("offset"); - accessor.Stride = reader->getAttributeValueAsInt("stride"); - if (accessor.Stride == 0) - accessor.Stride = 1; - - // the accessor contains some information on how to access (boi!) the array, - // the info is stored in collada style parameters, so just read them. - readColladaParameters(reader, accessorSectionName); - if (!sources.empty()) - { - sources.getLast().Accessors.push_back(accessor); - sources.getLast().Accessors.getLast().Parameters = ColladaParameters; - } - } - else - if (verticesSectionName == nodeName) - { - #ifdef COLLADA_READER_DEBUG - os::Printer::log("Reading vertices"); - #endif - // read vertex input position source - readColladaInputs(reader, verticesSectionName); - SColladaInput* input = getColladaInput(ECIS_POSITION); - if (input) - VertexPositionSource = input->Source; - } - else - // lines and linestrips missing - if (polygonsSectionName == nodeName || - polylistSectionName == nodeName || - trianglesSectionName == nodeName) - { - // read polygons section - readPolygonSection(reader, VertexPositionSource, sources, mesh, id); - } - else - // trifans, and tristrips missing - if (doubleSidedNodeName == reader->getNodeName()) - { - // read the extra flag for double sided polys - s32 doubleSided = 0; - readIntsInsideElement(reader,&doubleSided,1); - if (doubleSided) - { - #ifdef COLLADA_READER_DEBUG - os::Printer::log("Setting double sided flag for mesh."); - #endif - amesh->setMaterialFlag(irr::video::EMF_BACK_FACE_CULLING,false); - } - } - else - // techniqueCommon or 'technique profile=common' must not be skipped - if ((techniqueCommonSectionName != nodeName) // Collada 1.2/1.3 - && (techniqueNodeName != nodeName) // Collada 1.4+ - && (extraNodeName != nodeName)) - { - os::Printer::log("COLLADA loader warning: Wrong tag usage found in geometry", reader->getNodeName(), ELL_WARNING); - skipSection(reader, true); // ignore all other sections - } - } // end if node type is element - else - if (reader->getNodeType() == io::EXN_TEXT) - { - // read array data - if (okToReadArray && !sources.empty()) - { - core::array<f32>& a = sources.getLast().Array.Data; - core::stringc data = reader->getNodeData(); - data.trim(); - const c8* p = &data[0]; - - for (u32 i=0; i<a.size(); ++i) - { - findNextNoneWhiteSpace(&p); - if (*p) - a[i] = readFloat(&p); - else - a[i] = 0.0f; - } - } // end reading array - - okToReadArray = false; - - } // end if node type is text - else - if (reader->getNodeType() == io::EXN_ELEMENT_END) - { - if (geometrySectionName == reader->getNodeName()) - { - // end of geometry section reached, cancel out - break; - } - } - } // end while reader->read(); - - // add mesh as geometry - - mesh->recalculateBoundingBox(); - amesh->recalculateBoundingBox(); - - // create virtual file name - io::path filename = CurrentlyLoadingMesh; - filename += '#'; - filename += id; - - // add to scene manager - if (LoadedMeshCount) - { - SceneManager->getMeshCache()->addMesh(filename.c_str(), amesh); - os::Printer::log("Added COLLADA mesh", filename.c_str()); - } - else - { - FirstLoadedMeshName = filename; - FirstLoadedMesh = amesh; - FirstLoadedMesh->grab(); - } - - ++LoadedMeshCount; - mesh->drop(); - amesh->drop(); - - // create geometry prefab - CGeometryPrefab* prefab = new CGeometryPrefab(id.c_str()); - prefab->Mesh = mesh; - Prefabs.push_back(prefab); - - // store as dummy mesh if no instances will be created - if (!CreateInstances && !DummyMesh) - { - DummyMesh = amesh; - DummyMesh->grab(); - } -} - - -struct SPolygon -{ - core::array<s32> Indices; -}; - -//! reads a polygons section and creates a mesh from it -void CColladaFileLoader::readPolygonSection(io::IXMLReaderUTF8* reader, - const core::stringc& vertexPositionSource, core::array<SSource>& sources, - scene::SMesh* mesh, const core::stringc& geometryId) -{ - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA reading polygon section"); - #endif - - core::stringc materialName = reader->getAttributeValue("material"); - - core::stringc polygonType = reader->getNodeName(); - const int polygonCount = reader->getAttributeValueAsInt("count"); // Not useful because it only determines the number of primitives, which have arbitrary vertices in case of polygon - core::array<SPolygon> polygons; - if (polygonType == polygonsSectionName) - polygons.reallocate(polygonCount); - core::array<int> vCounts; - bool parsePolygonOK = false; - bool parseVcountOK = false; - u32 inputSemanticCount = 0; - bool unresolvedInput=false; - u32 maxOffset = 0; - Inputs.clear(); - - // read all <input> and primitives - if (!reader->isEmptyElement()) - while(reader->read()) - { - const char* nodeName = reader->getNodeName(); - - if (reader->getNodeType() == io::EXN_ELEMENT) - { - // polygon node may contain params - if (inputTagName == nodeName) - { - // read input tag - readColladaInput(reader); - - // resolve input source - SColladaInput& inp = Inputs.getLast(); - core::stringc sourceArrayURI; - - // get input source array id, if it is a vertex input, take - // the <vertex><input>-source attribute. - if (inp.Semantic == ECIS_VERTEX) - sourceArrayURI = vertexPositionSource; - else - sourceArrayURI = inp.Source; - - uriToId(sourceArrayURI); - - // find source array (we'll ignore accessors for this implementation) - u32 s; - for (s=0; s<sources.size(); ++s) - { - if (sources[s].Id == sourceArrayURI) - { - // slot found - inp.Data = sources[s].Array.Data.pointer(); - inp.Stride = sources[s].Accessors[0].Stride; - break; - } - } - - if (s == sources.size()) - { - os::Printer::log("COLLADA Warning, polygon input source not found", - sourceArrayURI.c_str()); - unresolvedInput=true; - } - else - { - #ifdef COLLADA_READER_DEBUG - // print slot - core::stringc tmp = "Added slot "; - tmp += inputSemanticNames[inp.Semantic]; - tmp += " sourceArray:"; - tmp += sourceArrayURI; - os::Printer::log(tmp.c_str()); - #endif - } - - maxOffset = core::max_(maxOffset,inp.Offset); - ++inputSemanticCount; - } - else - if (primitivesName == nodeName) - { - parsePolygonOK = true; - polygons.push_back(SPolygon()); - } - else - if (vcountName == nodeName) - { - parseVcountOK = true; - } // end is polygon node - } // end is element node - else - if (reader->getNodeType() == io::EXN_ELEMENT_END) - { - if (primitivesName == nodeName) - parsePolygonOK = false; // end parsing a polygon - else - if (vcountName == nodeName) - parseVcountOK = false; // end parsing vcounts - else - if (polygonType == nodeName) - break; // cancel out and create mesh - - } // end is element end - else - if (reader->getNodeType() == io::EXN_TEXT) - { - if (parseVcountOK) - { - core::stringc data = reader->getNodeData(); - data.trim(); - const c8* p = &data[0]; - while(*p) - { - findNextNoneWhiteSpace(&p); - if (*p) - vCounts.push_back(readInt(&p)); - } - parseVcountOK = false; - } - else - if (parsePolygonOK && polygons.size()) - { - core::stringc data = reader->getNodeData(); - data.trim(); - const c8* p = &data[0]; - SPolygon& poly = polygons.getLast(); - if (polygonType == polygonsSectionName) - poly.Indices.reallocate((maxOffset+1)*3); - else - poly.Indices.reallocate(polygonCount*(maxOffset+1)*3); - - if (vCounts.empty()) - { - while(*p) - { - findNextNoneWhiteSpace(&p); - poly.Indices.push_back(readInt(&p)); - } - } - else - { - for (u32 i = 0; i < vCounts.size(); i++) - { - const int polyVCount = vCounts[i]; - - core::array<int> polyCorners; - - for (u32 j = 0; j < polyVCount * inputSemanticCount; j++) - { - if (!*p) - break; - findNextNoneWhiteSpace(&p); - polyCorners.push_back(readInt(&p)); - } - - while (polyCorners.size() >= 3 * inputSemanticCount) - { - // add one triangle's worth of indices - for (u32 k = 0; k < inputSemanticCount * 3; ++k) - { - poly.Indices.push_back(polyCorners[k]); - } - - // remove one corner from our poly - polyCorners.erase(inputSemanticCount,inputSemanticCount); - } - polyCorners.clear(); - } - vCounts.clear(); - } - parsePolygonOK = false; - } - } - } // end while reader->read() - - if (inputSemanticCount == 0 || unresolvedInput) - return; // we cannot create the mesh if one of the input semantics wasn't found. - - if (!polygons.size()) - return; // cancel if there are no polygons anyway. - - // analyze content of Inputs to create a fitting mesh buffer - - u32 u; - u32 textureCoordSetCount = 0; - bool normalSlotCount = false; - u32 secondTexCoordSetIndex = 0xFFFFFFFF; - - for (u=0; u<Inputs.size(); ++u) - { - if (Inputs[u].Semantic == ECIS_TEXCOORD || Inputs[u].Semantic == ECIS_UV ) - { - ++textureCoordSetCount; - - if (textureCoordSetCount==2) - secondTexCoordSetIndex = u; - } - else - if (Inputs[u].Semantic == ECIS_NORMAL) - normalSlotCount=true; - } - - // if there is more than one texture coordinate set, create a lightmap mesh buffer, - // otherwise use a standard mesh buffer - - scene::IMeshBuffer* buffer = 0; - ++maxOffset; // +1 to jump to the next value - - if ( textureCoordSetCount < 2 ) - { - // standard mesh buffer - - scene::SMeshBuffer* mbuffer = new SMeshBuffer(); - buffer = mbuffer; - - core::map<video::S3DVertex, int> vertMap; - - for (u32 i=0; i<polygons.size(); ++i) - { - core::array<u16> indices; - const u32 vertexCount = polygons[i].Indices.size() / maxOffset; - mbuffer->Vertices.reallocate(mbuffer->Vertices.size()+vertexCount); - - // for all index/semantic groups - for (u32 v=0; v<polygons[i].Indices.size(); v+=maxOffset) - { - video::S3DVertex vtx; - vtx.Color.set(255,255,255,255); - - // for all input semantics - for (u32 k=0; k<Inputs.size(); ++k) - { - if (!Inputs[k].Data) - continue; - // build vertex from input semantics. - - const u32 idx = Inputs[k].Stride*polygons[i].Indices[v+Inputs[k].Offset]; - - switch(Inputs[k].Semantic) - { - case ECIS_POSITION: - case ECIS_VERTEX: - vtx.Pos.X = Inputs[k].Data[idx+0]; - if (FlipAxis) - { - vtx.Pos.Z = Inputs[k].Data[idx+1]; - vtx.Pos.Y = Inputs[k].Data[idx+2]; - } - else - { - vtx.Pos.Y = Inputs[k].Data[idx+1]; - vtx.Pos.Z = Inputs[k].Data[idx+2]; - } - break; - case ECIS_NORMAL: - vtx.Normal.X = Inputs[k].Data[idx+0]; - if (FlipAxis) - { - vtx.Normal.Z = Inputs[k].Data[idx+1]; - vtx.Normal.Y = Inputs[k].Data[idx+2]; - } - else - { - vtx.Normal.Y = Inputs[k].Data[idx+1]; - vtx.Normal.Z = Inputs[k].Data[idx+2]; - } - break; - case ECIS_TEXCOORD: - case ECIS_UV: - vtx.TCoords.X = Inputs[k].Data[idx+0]; - vtx.TCoords.Y = 1-Inputs[k].Data[idx+1]; - break; - case ECIS_TANGENT: - break; - default: - break; - } - } - - //first, try to find this vertex in the mesh - core::map<video::S3DVertex, int>::Node* n = vertMap.find(vtx); - if (n) - { - indices.push_back(n->getValue()); - } - else - { - indices.push_back(mbuffer->getVertexCount()); - mbuffer->Vertices.push_back(vtx); - vertMap.insert(vtx, mbuffer->getVertexCount()-1); - } - } // end for all vertices - - if (polygonsSectionName == polygonType && - indices.size() > 3) - { - // need to tesselate for polygons of 4 or more vertices - // for now we naively turn interpret it as a triangle fan - // as full tesselation is problematic - if (FlipAxis) - { - for (u32 ind = indices.size()-3; ind>0 ; --ind) - { - mbuffer->Indices.push_back(indices[0]); - mbuffer->Indices.push_back(indices[ind+2]); - mbuffer->Indices.push_back(indices[ind+1]); - } - } - else - { - for (u32 ind = 0; i+2 < indices.size(); ++ind) - { - mbuffer->Indices.push_back(indices[0]); - mbuffer->Indices.push_back(indices[ind+1]); - mbuffer->Indices.push_back(indices[ind+2]); - } - } - } - else - { - // it's just triangles - for (u32 ind = 0; ind < indices.size(); ind+=3) - { - if (FlipAxis) - { - mbuffer->Indices.push_back(indices[ind+2]); - mbuffer->Indices.push_back(indices[ind+1]); - mbuffer->Indices.push_back(indices[ind+0]); - } - else - { - mbuffer->Indices.push_back(indices[ind+0]); - mbuffer->Indices.push_back(indices[ind+1]); - mbuffer->Indices.push_back(indices[ind+2]); - } - } - } - - } // end for all polygons - } - else - { - // lightmap mesh buffer - - scene::SMeshBufferLightMap* mbuffer = new SMeshBufferLightMap(); - buffer = mbuffer; - - for (u32 i=0; i<polygons.size(); ++i) - { - const u32 vertexCount = polygons[i].Indices.size() / maxOffset; - mbuffer->Vertices.reallocate(mbuffer->Vertices.size()+vertexCount); - // for all vertices in array - for (u32 v=0; v<polygons[i].Indices.size(); v+=maxOffset) - { - video::S3DVertex2TCoords vtx; - vtx.Color.set(100,255,255,255); - - // for all input semantics - for (u32 k=0; k<Inputs.size(); ++k) - { - // build vertex from input semantics. - - const u32 idx = Inputs[k].Stride*polygons[i].Indices[v+Inputs[k].Offset]; - - switch(Inputs[k].Semantic) - { - case ECIS_POSITION: - case ECIS_VERTEX: - vtx.Pos.X = Inputs[k].Data[idx+0]; - if (FlipAxis) - { - vtx.Pos.Z = Inputs[k].Data[idx+1]; - vtx.Pos.Y = Inputs[k].Data[idx+2]; - } - else - { - vtx.Pos.Y = Inputs[k].Data[idx+1]; - vtx.Pos.Z = Inputs[k].Data[idx+2]; - } - break; - case ECIS_NORMAL: - vtx.Normal.X = Inputs[k].Data[idx+0]; - if (FlipAxis) - { - vtx.Normal.Z = Inputs[k].Data[idx+1]; - vtx.Normal.Y = Inputs[k].Data[idx+2]; - } - else - { - vtx.Normal.Y = Inputs[k].Data[idx+1]; - vtx.Normal.Z = Inputs[k].Data[idx+2]; - } - break; - case ECIS_TEXCOORD: - case ECIS_UV: - if (k==secondTexCoordSetIndex) - { - vtx.TCoords2.X = Inputs[k].Data[idx+0]; - vtx.TCoords2.Y = 1-Inputs[k].Data[idx+1]; - } - else - { - vtx.TCoords.X = Inputs[k].Data[idx+0]; - vtx.TCoords.Y = 1-Inputs[k].Data[idx+1]; - } - break; - case ECIS_TANGENT: - break; - default: - break; - } - } - - mbuffer->Vertices.push_back(vtx); - - } // end for all vertices - - // add vertex indices - const u32 oldVertexCount = mbuffer->Vertices.size() - vertexCount; - for (u32 face=0; face<vertexCount-2; ++face) - { - mbuffer->Indices.push_back(oldVertexCount + 0); - mbuffer->Indices.push_back(oldVertexCount + 1 + face); - mbuffer->Indices.push_back(oldVertexCount + 2 + face); - } - - } // end for all polygons - } - - const SColladaMaterial* m = findMaterial(materialName); - if (m) - { - buffer->getMaterial() = m->Mat; - SMesh tmpmesh; - tmpmesh.addMeshBuffer(buffer); - SceneManager->getMeshManipulator()->setVertexColors(&tmpmesh,m->Mat.DiffuseColor); - if (m->Transparency != 1.0f) - SceneManager->getMeshManipulator()->setVertexColorAlpha(&tmpmesh,core::floor32(m->Transparency*255.0f)); - } - // add future bind reference for the material - core::stringc meshbufferReference = geometryId+"/"+materialName; - if (!MaterialsToBind.find(meshbufferReference)) - { - MaterialsToBind[meshbufferReference] = MeshesToBind.size(); - MeshesToBind.push_back(core::array<irr::scene::IMeshBuffer*>()); - } - MeshesToBind[MaterialsToBind[meshbufferReference]].push_back(buffer); - - // calculate normals if there is no slot for it - - if (!normalSlotCount) - SceneManager->getMeshManipulator()->recalculateNormals(buffer, true); - - // recalculate bounding box - buffer->recalculateBoundingBox(); - - // add mesh buffer - mesh->addMeshBuffer(buffer); - - buffer->drop(); -} - - -//! reads a <light> element and stores it as prefab -void CColladaFileLoader::readLightPrefab(io::IXMLReaderUTF8* reader) -{ - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA reading light prefab"); - #endif - - CLightPrefab* prefab = new CLightPrefab(readId(reader)); - - if (!reader->isEmptyElement()) - { - if (Version >= 10400) // start with 1.4 - { - while(reader->read()) - { - if (reader->getNodeType() == io::EXN_ELEMENT) - { - if (pointSectionName == reader->getNodeName()) - prefab->LightData.Type=video::ELT_POINT; - else - if (directionalSectionName == reader->getNodeName()) - prefab->LightData.Type=video::ELT_DIRECTIONAL; - else - if (spotSectionName == reader->getNodeName()) - prefab->LightData.Type=video::ELT_SPOT; - else - if (ambientSectionName == reader->getNodeName()) - prefab->LightData.Type=video::ELT_POINT; // TODO: This needs some change - else - if (colorNodeName == reader->getNodeName()) - prefab->LightData.DiffuseColor=readColorNode(reader); - else - if (constantAttenuationNodeName == reader->getNodeName()) - readFloatsInsideElement(reader,&prefab->LightData.Attenuation.X,1); - else - if (linearAttenuationNodeName == reader->getNodeName()) - readFloatsInsideElement(reader,&prefab->LightData.Attenuation.Y,1); - else - if (quadraticAttenuationNodeName == reader->getNodeName()) - readFloatsInsideElement(reader,&prefab->LightData.Attenuation.Z,1); - else - if (falloffAngleNodeName == reader->getNodeName()) - { - readFloatsInsideElement(reader,&prefab->LightData.OuterCone,1); - prefab->LightData.OuterCone *= core::DEGTORAD; - } - else - if (falloffExponentNodeName == reader->getNodeName()) - readFloatsInsideElement(reader,&prefab->LightData.Falloff,1); - } - else - if (reader->getNodeType() == io::EXN_ELEMENT_END) - { - if ((pointSectionName == reader->getNodeName()) || - (directionalSectionName == reader->getNodeName()) || - (spotSectionName == reader->getNodeName()) || - (ambientSectionName == reader->getNodeName())) - break; - } - } - } - else - { - readColladaParameters(reader, lightPrefabName); - - SColladaParam* p = getColladaParameter(ECPN_COLOR); - if (p && p->Type == ECPT_FLOAT3) - prefab->LightData.DiffuseColor.set(p->Floats[0], p->Floats[1], p->Floats[2]); - } - } - - Prefabs.push_back(prefab); -} - - -//! returns a collada parameter or none if not found -SColladaParam* CColladaFileLoader::getColladaParameter(ECOLLADA_PARAM_NAME name) -{ - for (u32 i=0; i<ColladaParameters.size(); ++i) - if (ColladaParameters[i].Name == name) - return &ColladaParameters[i]; - - return 0; -} - -//! returns a collada input or none if not found -SColladaInput* CColladaFileLoader::getColladaInput(ECOLLADA_INPUT_SEMANTIC input) -{ - for (u32 i=0; i<Inputs.size(); ++i) - if (Inputs[i].Semantic == input) - return &Inputs[i]; - - return 0; -} - - -//! reads a collada input tag and adds it to the input parameter -void CColladaFileLoader::readColladaInput(io::IXMLReaderUTF8* reader) -{ - // parse param - SColladaInput p; - - // get type - core::stringc semanticName = reader->getAttributeValue("semantic"); - for (u32 i=0; inputSemanticNames[i]; ++i) - { - if (semanticName == inputSemanticNames[i]) - { - p.Semantic = (ECOLLADA_INPUT_SEMANTIC)i; - break; - } - } - - // get source - p.Source = reader->getAttributeValue("source"); - if (reader->getAttributeValue("offset")) // Collada 1.4+ - p.Offset = (u32)reader->getAttributeValueAsInt("offset"); - else // Collada 1.2/1.3 - p.Offset = (u32)reader->getAttributeValueAsInt("idx"); - p.Set = (u32)reader->getAttributeValueAsInt("set"); - - // add input - Inputs.push_back(p); -} - -//! parses all collada inputs inside an element and stores them in Inputs -void CColladaFileLoader::readColladaInputs(io::IXMLReaderUTF8* reader, const core::stringc& parentName) -{ - Inputs.clear(); - - while(reader->read()) - { - if (reader->getNodeType() == io::EXN_ELEMENT && - inputTagName == reader->getNodeName()) - { - readColladaInput(reader); - } - else - if (reader->getNodeType() == io::EXN_ELEMENT_END) - { - if (parentName == reader->getNodeName()) - return; // end of parent reached - } - - } // end while reader->read(); -} - -//! parses all collada parameters inside an element and stores them in Parameters -void CColladaFileLoader::readColladaParameters(io::IXMLReaderUTF8* reader, - const core::stringc& parentName) -{ - ColladaParameters.clear(); - - const char* const paramNames[] = {"COLOR", "AMBIENT", "DIFFUSE", - "SPECULAR", "SHININESS", "YFOV", "ZNEAR", "ZFAR", 0}; - - const char* const typeNames[] = {"float", "float2", "float3", 0}; - - while(reader->read()) - { - const char* nodeName = reader->getNodeName(); - if (reader->getNodeType() == io::EXN_ELEMENT && - paramTagName == nodeName) - { - // parse param - SColladaParam p; - - // get type - u32 i; - core::stringc typeName = reader->getAttributeValue("type"); - for (i=0; typeNames[i]; ++i) - if (typeName == typeNames[i]) - { - p.Type = (ECOLLADA_PARAM_TYPE)i; - break; - } - - // get name - core::stringc nameName = reader->getAttributeValue("name"); - for (i=0; typeNames[i]; ++i) - if (nameName == paramNames[i]) - { - p.Name = (ECOLLADA_PARAM_NAME)i; - break; - } - - // read parameter data inside parameter tags - switch(p.Type) - { - case ECPT_FLOAT: - case ECPT_FLOAT2: - case ECPT_FLOAT3: - case ECPT_FLOAT4: - readFloatsInsideElement(reader, p.Floats, p.Type - ECPT_FLOAT + 1); - break; - - // TODO: other types of data (ints, bools or whatever) - default: - break; - } - - // add param - ColladaParameters.push_back(p); - } - else - if (reader->getNodeType() == io::EXN_ELEMENT_END) - { - if (parentName == reader->getNodeName()) - return; // end of parent reached - } - - } // end while reader->read(); -} - - -//! parses a float from a char pointer and moves the pointer -//! to the end of the parsed float -inline f32 CColladaFileLoader::readFloat(const c8** p) -{ - f32 ftmp; - *p = core::fast_atof_move(*p, ftmp); - return ftmp; -} - - -//! parses an int from a char pointer and moves the pointer to -//! the end of the parsed float -inline s32 CColladaFileLoader::readInt(const c8** p) -{ - return (s32)readFloat(p); -} - - -//! places pointer to next begin of a token -void CColladaFileLoader::findNextNoneWhiteSpace(const c8** start) -{ - const c8* p = *start; - - while(*p && (*p==' ' || *p=='\n' || *p=='\r' || *p=='\t')) - ++p; - - // TODO: skip comments <!-- --> - - *start = p; -} - - -//! reads floats from inside of xml element until end of xml element -void CColladaFileLoader::readFloatsInsideElement(io::IXMLReaderUTF8* reader, f32* floats, u32 count) -{ - if (reader->isEmptyElement()) - return; - - while(reader->read()) - { - // TODO: check for comments inside the element - // and ignore them. - - if (reader->getNodeType() == io::EXN_TEXT) - { - // parse float data - core::stringc data = reader->getNodeData(); - data.trim(); - const c8* p = &data[0]; - - for (u32 i=0; i<count; ++i) - { - findNextNoneWhiteSpace(&p); - if (*p) - floats[i] = readFloat(&p); - else - floats[i] = 0.0f; - } - } - else - if (reader->getNodeType() == io::EXN_ELEMENT_END) - break; // end parsing text - } -} - - -//! reads ints from inside of xml element until end of xml element -void CColladaFileLoader::readIntsInsideElement(io::IXMLReaderUTF8* reader, s32* ints, u32 count) -{ - if (reader->isEmptyElement()) - return; - - while(reader->read()) - { - // TODO: check for comments inside the element - // and ignore them. - - if (reader->getNodeType() == io::EXN_TEXT) - { - // parse float data - core::stringc data = reader->getNodeData(); - data.trim(); - const c8* p = &data[0]; - - for (u32 i=0; i<count; ++i) - { - findNextNoneWhiteSpace(&p); - if (*p) - ints[i] = readInt(&p); - else - ints[i] = 0; - } - } - else - if (reader->getNodeType() == io::EXN_ELEMENT_END) - break; // end parsing text - } -} - - -video::SColorf CColladaFileLoader::readColorNode(io::IXMLReaderUTF8* reader) -{ - if (reader->getNodeType() == io::EXN_ELEMENT && - colorNodeName == reader->getNodeName()) - { - f32 color[4]; - readFloatsInsideElement(reader,color,4); - return video::SColorf(color[0], color[1], color[2], color[3]); - } - - return video::SColorf(); -} - - -f32 CColladaFileLoader::readFloatNode(io::IXMLReaderUTF8* reader) -{ - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA reading <float>"); - #endif - - f32 result = 0.0f; - if (reader->getNodeType() == io::EXN_ELEMENT && - floatNodeName == reader->getNodeName()) - { - readFloatsInsideElement(reader,&result,1); - } - - return result; -} - - -//! clears all loaded data -void CColladaFileLoader::clearData() -{ - // delete all prefabs - - for (u32 i=0; i<Prefabs.size(); ++i) - Prefabs[i]->drop(); - - Prefabs.clear(); - - // clear all parameters - ColladaParameters.clear(); - - // clear all materials - Images.clear(); - - // clear all materials - Textures.clear(); - - // clear all materials - Materials.clear(); - - // clear all inputs - Inputs.clear(); - - // clear all effects - Effects.clear(); - - // clear all the materials to bind - MaterialsToBind.clear(); - MeshesToBind.clear(); -} - - -//! changes the XML URI into an internal id -void CColladaFileLoader::uriToId(core::stringc& str) -{ - // currently, we only remove the # from the begin if there - // because we simply don't support referencing other files. - if (!str.size()) - return; - - if (str[0] == '#') - str.erase(0); -} - - -//! read Collada Id, uses id or name if id is missing -core::stringc CColladaFileLoader::readId(io::IXMLReaderUTF8* reader) -{ - core::stringc id = reader->getAttributeValue("id"); - if (id.size()==0) - id = reader->getAttributeValue("name"); - return id; -} - - -//! create an Irrlicht texture from the reference -video::ITexture* CColladaFileLoader::getTextureFromImage(core::stringc uri) -{ - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA searching texture", uri.c_str()); - #endif - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - for (;;) - { - uriToId(uri); - for (u32 i=0; i<Images.size(); ++i) - { - if (uri == Images[i].Id) - { - if (Images[i].Source.size() && Images[i].SourceIsFilename) - { - if (FileSystem->existFile(Images[i].Source)) - return driver->getTexture(Images[i].Source); - return driver->getTexture((FileSystem->getFileDir(CurrentlyLoadingMesh)+"/"+Images[i].Source)); - } - else - if (Images[i].Source.size()) - { - //const u32 size = Images[i].Dimension.getArea(); - const u32 size = Images[i].Dimension.Width * Images[i].Dimension.Height;; - u32* data = new u32[size]; // we assume RGBA - u32* ptrdest = data; - const c8* ptrsrc = Images[i].Source.c_str(); - for (u32 j=0; j<size; ++j) - { - sscanf(ptrsrc, "%x", ptrdest); - ++ptrdest; - ptrsrc += 4; - } - video::IImage* img = driver->createImageFromData(video::ECF_A8R8G8B8, Images[i].Dimension, data, true, true); - video::ITexture* tex = driver->addTexture((CurrentlyLoadingMesh+"#"+Images[i].Id).c_str(), img); - img->drop(); - return tex; - } - break; - } - } - if (Parameters.getAttributeType(uri.c_str())==io::EAT_STRING) - { - uri = Parameters.getAttributeAsString(uri.c_str()); -#ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA now searching texture", uri.c_str()); -#endif - } - else - break; - } - return 0; -} - - -//! read a parameter and value -void CColladaFileLoader::readParameter(io::IXMLReaderUTF8* reader) -{ - #ifdef COLLADA_READER_DEBUG - os::Printer::log("COLLADA reading parameter"); - #endif - - const core::stringc name = reader->getAttributeValue("sid"); - if (!reader->isEmptyElement()) - { - while(reader->read()) - { - if (reader->getNodeType() == io::EXN_ELEMENT) - { - if (floatNodeName == reader->getNodeName()) - { - const f32 f = readFloatNode(reader); - Parameters.addFloat(name.c_str(), f); - } - else - if (float2NodeName == reader->getNodeName()) - { - f32 f[2]; - readFloatsInsideElement(reader, f, 2); -// Parameters.addVector2d(name.c_str(), core::vector2df(f[0],f[1])); - } - else - if (float3NodeName == reader->getNodeName()) - { - f32 f[3]; - readFloatsInsideElement(reader, f, 3); - Parameters.addVector3d(name.c_str(), core::vector3df(f[0],f[1],f[2])); - } - else - if ((initFromName == reader->getNodeName()) || - (sourceSectionName == reader->getNodeName())) - { - reader->read(); - Parameters.addString(name.c_str(), reader->getNodeData()); - } - else - if (wrapsName == reader->getNodeName()) - { - reader->read(); - const core::stringc val = reader->getNodeData(); - if (val == "WRAP") - Parameters.addBool("wrap_s", true); - } - else - if (wraptName == reader->getNodeName()) - { - reader->read(); - const core::stringc val = reader->getNodeData(); - if (val == "WRAP") - Parameters.addBool("wrap_t", true); - } - else - if (minfilterName == reader->getNodeName()) - { - reader->read(); - const core::stringc val = reader->getNodeData(); - if (val == "LINEAR_MIPMAP_LINEAR") - Parameters.addBool("trilinear", true); - else - if (val == "LINEAR_MIPMAP_NEAREST") - Parameters.addBool("bilinear", true); - } - else - if (magfilterName == reader->getNodeName()) - { - reader->read(); - const core::stringc val = reader->getNodeData(); - if (val != "LINEAR") - { - Parameters.addBool("bilinear", false); - Parameters.addBool("trilinear", false); - } - } - else - if (mipfilterName == reader->getNodeName()) - { - Parameters.addBool("anisotropic", true); - } - } - else - if(reader->getNodeType() == io::EXN_ELEMENT_END) - { - if (newParamName == reader->getNodeName()) - break; - } - } - } -} - - -} // end namespace scene -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_COLLADA_LOADER_ - diff --git a/irrlicht-1.6/source/Irrlicht/CColladaFileLoader.h b/irrlicht-1.6/source/Irrlicht/CColladaFileLoader.h deleted file mode 100644 index f4f12c91a..000000000 --- a/irrlicht-1.6/source/Irrlicht/CColladaFileLoader.h +++ /dev/null @@ -1,383 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_COLLADA_MESH_FILE_LOADER_H_INCLUDED__ -#define __C_COLLADA_MESH_FILE_LOADER_H_INCLUDED__ - -#include "IMeshLoader.h" -#include "IFileSystem.h" -#include "IVideoDriver.h" -#include "irrString.h" -#include "SMesh.h" -#include "SMeshBuffer.h" -#include "ISceneManager.h" -#include "irrMap.h" -#include "CAttributes.h" - -namespace irr -{ -namespace scene -{ - -#ifdef _DEBUG -//#define COLLADA_READER_DEBUG -#endif - -class IColladaPrefab; - -enum ECOLLADA_PARAM_NAME -{ - ECPN_COLOR = 0, - ECPN_AMBIENT, - ECPN_DIFFUSE, - ECPN_SPECULAR, - ECPN_SHININESS, - ECPN_TRANSPARENCY, - ECPN_YFOV, - ECPN_ZNEAR, - ECPN_ZFAR, - - ECPN_COUNT -}; - -enum ECOLLADA_PARAM_TYPE -{ - ECPT_FLOAT = 0, - ECPT_FLOAT2, - ECPT_FLOAT3, - ECPT_FLOAT4, - - ECPT_COUNT -}; - -//! Collada Parameter -struct SColladaParam -{ - SColladaParam() - : Name(ECPN_COUNT), Type(ECPT_COUNT) - { - for (int i=0; i<4; ++i) Floats[i] = 0; - } - - ECOLLADA_PARAM_NAME Name; - ECOLLADA_PARAM_TYPE Type; - - f32 Floats[4]; -}; - -enum ECOLLADA_INPUT_SEMANTIC -{ - ECIS_POSITION = 0, - ECIS_VERTEX, - ECIS_NORMAL, - ECIS_TEXCOORD, - ECIS_UV, - ECIS_TANGENT, - ECIS_IMAGE, - ECIS_TEXTURE, - - ECIS_COUNT -}; - -//! Collada Input -struct SColladaInput -{ - SColladaInput() - : Semantic(ECIS_COUNT), Data(0), Offset(0), Set(0), Stride(1) - { - } - - ECOLLADA_INPUT_SEMANTIC Semantic; - core::stringc Source; - f32* Data; - u32 Offset; - u32 Set; - u32 Stride; -}; - -//! Collada images -struct SColladaImage -{ - core::stringc Id; - core::stringc Source; - core::dimension2du Dimension; - bool SourceIsFilename; -}; - - -//! Collada texture -struct SColladaTexture -{ - video::ITexture* Texture; - core::stringc Id; -}; - - -//! Collada material -struct SColladaMaterial -{ - video::SMaterial Mat; - core::stringc Id; - core::stringc InstanceEffectId; - f32 Transparency; - - inline bool operator< (const SColladaMaterial & other) const - { - return Id < other.Id; - } -}; - -//! Collada effect (materials, shaders, and programs) -struct SColladaEffect -{ - video::SMaterial Mat; - core::stringc Id; - f32 Transparency; - - inline bool operator< (const SColladaEffect & other) const - { - return Id < other.Id; - } -}; - - -struct SNumberArray // for storing float and int arrays -{ - core::stringc Name; - core::array<f32> Data; -}; - -struct SAccessor -{ - SAccessor() - : Count(0), Offset(0), Stride(1) {} - // I don't store the source of the accessor here because I assume - // it to use the array of the source this accessor is located in. - - int Count; - int Offset; - int Stride; - - core::array<SColladaParam> Parameters; // parameters defining the accessor -}; - -struct SSource -{ - core::stringc Id; - SNumberArray Array; - core::array<SAccessor> Accessors; -}; - -class CScenePrefab; - -//! Meshloader capable of loading COLLADA meshes and scene descriptions into Irrlicht. -class CColladaFileLoader : public IMeshLoader -{ -public: - - //! Constructor - CColladaFileLoader(scene::ISceneManager* smgr, io::IFileSystem* fs); - - //! destructor - virtual ~CColladaFileLoader(); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".cob") - virtual bool isALoadableFileExtension(const io::path& 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 an (unknown) section in the collada document - void skipSection(io::IXMLReaderUTF8* reader, bool reportSkipping); - - //! reads the <COLLADA> section and its content - void readColladaSection(io::IXMLReaderUTF8* reader); - - //! reads a <library> section and its content - void readLibrarySection(io::IXMLReaderUTF8* reader); - - //! reads a <visual_scene> element and stores it as a prefab - void readVisualSceneLibrary(io::IXMLReaderUTF8* reader); - - //! reads a <scene> section and its content - void readSceneSection(io::IXMLReaderUTF8* reader); - - //! reads a <asset> section and its content - void readAssetSection(io::IXMLReaderUTF8* reader); - - //! reads a <node> section and its content - //! if a prefab pointer is passed the nodes are created as scene prefabs childs of that prefab - void readNodeSection(io::IXMLReaderUTF8* reader, scene::ISceneNode* parent, CScenePrefab* p=0); - - //! reads a <lookat> element and its content and creates a matrix from it - core::matrix4 readLookAtNode(io::IXMLReaderUTF8* reader); - - //! reads a <matrix> element and its content and creates a matrix from it - core::matrix4 readMatrixNode(io::IXMLReaderUTF8* reader); - - //! reads a <perspective> element and its content and creates a matrix from it - core::matrix4 readPerspectiveNode(io::IXMLReaderUTF8* reader); - - //! reads a <rotate> element and its content and creates a matrix from it - core::matrix4 readRotateNode(io::IXMLReaderUTF8* reader); - - //! reads a <skew> element and its content and creates a matrix from it - core::matrix4 readSkewNode(io::IXMLReaderUTF8* reader); - - //! reads a <boundingbox> element and its content and stores it in bbox - void readBboxNode(io::IXMLReaderUTF8* reader, core::aabbox3df& bbox); - - //! reads a <scale> element and its content and creates a matrix from it - core::matrix4 readScaleNode(io::IXMLReaderUTF8* reader); - - //! reads a <translate> element and its content and creates a matrix from it - core::matrix4 readTranslateNode(io::IXMLReaderUTF8* reader); - - //! reads a <color> element - video::SColorf readColorNode(io::IXMLReaderUTF8* reader); - - //! reads a <float> element - f32 readFloatNode(io::IXMLReaderUTF8* reader); - - //! reads a <instance> node - void readInstanceNode(io::IXMLReaderUTF8* reader, scene::ISceneNode* parent, - scene::ISceneNode** outNode, CScenePrefab* p=0); - - //! creates a scene node from Prefabs (with name given in 'url') - void instantiateNode(scene::ISceneNode* parent, scene::ISceneNode** outNode=0, - CScenePrefab* p=0, const core::stringc& url=""); - - //! reads a <light> element and stores it as prefab - void readLightPrefab(io::IXMLReaderUTF8* reader); - - //! reads a <camera> element and stores it as prefab - void readCameraPrefab(io::IXMLReaderUTF8* reader); - - //! reads a <image> element and stores it in the image section - void readImage(io::IXMLReaderUTF8* reader); - - //! reads a <texture> element and stores it in the texture section - void readTexture(io::IXMLReaderUTF8* reader); - - //! reads a <material> element and stores it in the material section - void readMaterial(io::IXMLReaderUTF8* reader); - - //! reads a <effect> element and stores it in the effects section - void readEffect(io::IXMLReaderUTF8* reader, SColladaEffect * effect = 0); - - //! reads a <geometry> element and stores it as mesh if possible - void readGeometry(io::IXMLReaderUTF8* reader); - - //! parses a float from a char pointer and moves the pointer to - //! the end of the parsed float - inline f32 readFloat(const c8** p); - - //! parses an int from a char pointer and moves the pointer to - //! the end of the parsed float - inline s32 readInt(const c8** p); - - //! places pointer to next begin of a token - void findNextNoneWhiteSpace(const c8** p); - - //! reads floats from inside of xml element until end of xml element - void readFloatsInsideElement(io::IXMLReaderUTF8* reader, f32* floats, u32 count); - - //! reads ints from inside of xml element until end of xml element - void readIntsInsideElement(io::IXMLReaderUTF8* reader, s32* ints, u32 count); - - //! clears all loaded data - void clearData(); - - //! parses all collada parameters inside an element and stores them in Parameters - void readColladaParameters(io::IXMLReaderUTF8* reader, const core::stringc& parentName); - - //! returns a collada parameter or none if not found - SColladaParam* getColladaParameter(ECOLLADA_PARAM_NAME name); - - //! parses all collada inputs inside an element and stores them in Inputs. Reads - //! until first tag which is not an input tag or the end of the parent is reached - void readColladaInputs(io::IXMLReaderUTF8* reader, const core::stringc& parentName); - - //! reads a collada input tag and adds it to the input parameter - void readColladaInput(io::IXMLReaderUTF8* reader); - - //! returns a collada input or none if not found - SColladaInput* getColladaInput(ECOLLADA_INPUT_SEMANTIC input); - - //! read Collada Id, uses id or name if id is missing - core::stringc readId(io::IXMLReaderUTF8* reader); - - //! changes the XML URI into an internal id - void uriToId(core::stringc& str); - - //! reads a polygons section and creates a mesh from it - void readPolygonSection(io::IXMLReaderUTF8* reader, - const core::stringc& vertexPositionSource, core::array<SSource>& sources, - scene::SMesh* mesh, const core::stringc& geometryId); - - //! finds a material, possible instancing it - const SColladaMaterial * findMaterial(const core::stringc & materialName); - - //! reads and bind materials as given by the symbol->target bind mapping - void readBindMaterialSection(io::IXMLReaderUTF8* reader, const core::stringc & id); - - //! create an Irrlicht texture from the SColladaImage - video::ITexture* getTextureFromImage(core::stringc uri); - - //! read a parameter and value - void readParameter(io::IXMLReaderUTF8* reader); - - scene::ISceneManager* SceneManager; - io::IFileSystem* FileSystem; - - scene::IAnimatedMesh* DummyMesh; - core::stringc CurrentlyLoadingMesh; - - scene::IAnimatedMesh* FirstLoadedMesh; - io::path FirstLoadedMeshName; - s32 LoadedMeshCount; - u32 Version; - bool FlipAxis; - - core::array<IColladaPrefab*> Prefabs; - core::array<SColladaParam> ColladaParameters; - core::array<SColladaImage> Images; - core::array<SColladaTexture> Textures; - core::array<SColladaMaterial> Materials; - core::array<SColladaInput> Inputs; - core::array<SColladaEffect> Effects; - core::map<core::stringc,u32> MaterialsToBind; - core::array< core::array<irr::scene::IMeshBuffer*> > MeshesToBind; - io::CAttributes Parameters; - - bool CreateInstances; -}; - - - -//! following class is for holding and createing instances of library objects, -//! named prefabs in this loader. -class IColladaPrefab : public virtual IReferenceCounted -{ -public: - //! creates an instance of this prefab - virtual scene::ISceneNode* addInstance(scene::ISceneNode* parent, - scene::ISceneManager* mgr) = 0; - - //! returns id of this prefab - virtual const core::stringc& getId() = 0; -}; - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CColladaMeshWriter.cpp b/irrlicht-1.6/source/Irrlicht/CColladaMeshWriter.cpp deleted file mode 100644 index 0e3ba009c..000000000 --- a/irrlicht-1.6/source/Irrlicht/CColladaMeshWriter.cpp +++ /dev/null @@ -1,831 +0,0 @@ -// Copyright (C) 2002-2009 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_COLLADA_WRITER_ - -#include "CColladaMeshWriter.h" -#include "os.h" -#include "IFileSystem.h" -#include "IWriteFile.h" -#include "IXMLWriter.h" -#include "IMesh.h" -#include "IAttributes.h" - -namespace irr -{ -namespace scene -{ - - -CColladaMeshWriter::CColladaMeshWriter(video::IVideoDriver* driver, - io::IFileSystem* fs) - : FileSystem(fs), VideoDriver(driver), Writer(0) -{ - - #ifdef _DEBUG - setDebugName("CColladaMeshWriter"); - #endif - - if (VideoDriver) - VideoDriver->grab(); - - if (FileSystem) - FileSystem->grab(); -} - - -CColladaMeshWriter::~CColladaMeshWriter() -{ - if (VideoDriver) - VideoDriver->drop(); - - if (FileSystem) - FileSystem->drop(); -} - - -//! Returns the type of the mesh writer -EMESH_WRITER_TYPE CColladaMeshWriter::getType() const -{ - return EMWT_COLLADA; -} - - -//! writes a mesh -bool CColladaMeshWriter::writeMesh(io::IWriteFile* file, scene::IMesh* mesh, s32 flags) -{ - if (!file) - return false; - - Writer = FileSystem->createXMLWriter(file); - - if (!Writer) - { - os::Printer::log("Could not write file", file->getFileName()); - return false; - } - - os::Printer::log("Writing mesh", file->getFileName()); - - // write COLLADA header - - Writer->writeXMLHeader(); - - Writer->writeElement(L"COLLADA", false, - L"xmlns", L"http://www.collada.org/2005/11/COLLADASchema", - L"version", L"1.4.1"); - Writer->writeLineBreak(); - - // write asset data - - Writer->writeElement(L"asset", false); - Writer->writeLineBreak(); - - Writer->writeElement(L"contributor", false); - Writer->writeLineBreak(); - Writer->writeElement(L"authoring_tool", false); - Writer->writeText(L"Irrlicht Engine / irrEdit"); // this code has originated from irrEdit 0.7 - Writer->writeClosingTag(L"authoring_tool"); - Writer->writeLineBreak(); - Writer->writeClosingTag(L"contributor"); - Writer->writeLineBreak(); - - // The next two are required - Writer->writeElement(L"created", false); - Writer->writeText(L"2008-01-31T00:00:00Z"); - Writer->writeClosingTag(L"created"); - Writer->writeLineBreak(); - - Writer->writeElement(L"modified", false); - Writer->writeText(L"2008-01-31T00:00:00Z"); - Writer->writeClosingTag(L"modified"); - Writer->writeLineBreak(); - - Writer->writeElement(L"revision", false); - Writer->writeText(L"1.0"); - Writer->writeClosingTag(L"revision"); - Writer->writeLineBreak(); - - Writer->writeClosingTag(L"asset"); - Writer->writeLineBreak(); - - // write all materials - - Writer->writeElement(L"library_materials", false); - Writer->writeLineBreak(); - - u32 i; - for (i=0; i<mesh->getMeshBufferCount(); ++i) - { - core::stringw strMat = "mat"; - strMat += i; - - Writer->writeElement(L"material", false, - L"id", strMat.c_str(), - L"name", strMat.c_str()); - Writer->writeLineBreak(); - - strMat += L"-fx"; - Writer->writeElement(L"instance_effect", true, - L"url", (core::stringw(L"#") + strMat).c_str()); - Writer->writeLineBreak(); - - Writer->writeClosingTag(L"material"); - Writer->writeLineBreak(); - } - - Writer->writeClosingTag(L"library_materials"); - Writer->writeLineBreak(); - - Writer->writeElement(L"library_effects", false); - Writer->writeLineBreak(); - - for (i=0; i<mesh->getMeshBufferCount(); ++i) - { - core::stringw strMat = "mat"; - strMat += i; - strMat += L"-fx"; - - Writer->writeElement(L"effect", false, - L"id", strMat.c_str(), - L"name", strMat.c_str()); - Writer->writeLineBreak(); - Writer->writeElement(L"profile_COMMON", false); - Writer->writeLineBreak(); - Writer->writeElement(L"technique", false, L"sid", L"common"); - Writer->writeLineBreak(); - Writer->writeElement(L"blinn", false); - Writer->writeLineBreak(); - - // write all interesting material parameters as parameter - - io::IAttributes* attributes = VideoDriver->createAttributesFromMaterial( - mesh->getMeshBuffer(i)->getMaterial()); - - u32 count = attributes->getAttributeCount(); - for (u32 attridx=0; attridx<count; ++attridx) - { - core::stringc str = attributes->getAttributeName(attridx); - if (str=="Emissive") - { - Writer->writeElement(L"emission", false); - Writer->writeLineBreak(); - Writer->writeElement(L"color", false); - Writer->writeLineBreak(); - - str = attributes->getAttributeAsString(attridx); - str.replace(',',' '); - Writer->writeText(core::stringw(str.c_str()).c_str()); - - Writer->writeClosingTag(L"color"); - Writer->writeLineBreak(); - Writer->writeClosingTag(L"emission"); - Writer->writeLineBreak(); - } - else - if (str=="Ambient") - { - Writer->writeElement(L"ambient", false); - Writer->writeLineBreak(); - Writer->writeElement(L"color", false); - Writer->writeLineBreak(); - - str = attributes->getAttributeAsString(attridx); - str.replace(',',' '); - Writer->writeText(core::stringw(str.c_str()).c_str()); - - Writer->writeClosingTag(L"color"); - Writer->writeLineBreak(); - Writer->writeClosingTag(L"ambient"); - Writer->writeLineBreak(); - } - else - if (str=="Diffuse") - { - Writer->writeElement(L"diffuse", false); - Writer->writeLineBreak(); - Writer->writeElement(L"color", false); - Writer->writeLineBreak(); - - str = attributes->getAttributeAsString(attridx); - str.replace(',',' '); - Writer->writeText(core::stringw(str.c_str()).c_str()); - - Writer->writeClosingTag(L"color"); - Writer->writeLineBreak(); - Writer->writeClosingTag(L"diffuse"); - Writer->writeLineBreak(); - } - else - if (str=="Specular") - { - Writer->writeElement(L"specular", false); - Writer->writeLineBreak(); - Writer->writeElement(L"color", false); - Writer->writeLineBreak(); - - str = attributes->getAttributeAsString(attridx); - str.replace(',',' '); - Writer->writeText(core::stringw(str.c_str()).c_str()); - - Writer->writeClosingTag(L"color"); - Writer->writeLineBreak(); - Writer->writeClosingTag(L"specular"); - Writer->writeLineBreak(); - } - else - if (str=="Shininess") - { - Writer->writeElement(L"shininess", false); - Writer->writeLineBreak(); - Writer->writeElement(L"float", false); - Writer->writeLineBreak(); - - Writer->writeText(core::stringw(attributes->getAttributeAsString(attridx).c_str()).c_str()); - - Writer->writeClosingTag(L"float"); - Writer->writeLineBreak(); - Writer->writeClosingTag(L"shininess"); - Writer->writeLineBreak(); - } - } - - attributes->drop(); - - Writer->writeClosingTag(L"blinn"); - Writer->writeLineBreak(); - Writer->writeClosingTag(L"technique"); - Writer->writeLineBreak(); - Writer->writeClosingTag(L"profile_COMMON"); - Writer->writeLineBreak(); - Writer->writeClosingTag(L"effect"); - Writer->writeLineBreak(); - } - - Writer->writeClosingTag(L"library_effects"); - Writer->writeLineBreak(); - - // write mesh - - Writer->writeElement(L"library_geometries", false); - Writer->writeLineBreak(); - - Writer->writeElement(L"geometry", false, L"id", L"mesh", L"name", L"mesh"); - Writer->writeLineBreak(); - Writer->writeElement(L"mesh"); - Writer->writeLineBreak(); - - // do some statistics for the mesh to know which stuff needs to be saved into - // the file: - // - count vertices - // - check for the need of a second texture coordinate - // - count amount of second texture coordinates - // - check for the need of tangents (TODO) - - u32 totalVertexCount = 0; - u32 totalTCoords2Count = 0; - bool needsTangents = false; // TODO: tangents not supported here yet - - for (i=0; i<mesh->getMeshBufferCount(); ++i) - { - totalVertexCount += mesh->getMeshBuffer(i)->getVertexCount(); - - if (hasSecondTextureCoordinates(mesh->getMeshBuffer(i)->getVertexType())) - totalTCoords2Count += mesh->getMeshBuffer(i)->getVertexCount(); - - if (!needsTangents) - needsTangents = mesh->getMeshBuffer(i)->getVertexType() == video::EVT_TANGENTS; - } - - SComponentGlobalStartPos* globalIndices = new SComponentGlobalStartPos[mesh->getMeshBufferCount()]; - - // write positions - - Writer->writeElement(L"source", false, L"id", L"mesh-Pos"); - Writer->writeLineBreak(); - - core::stringw vertexCountStr(totalVertexCount*3); - Writer->writeElement(L"float_array", false, L"id", L"mesh-Pos-array", - L"count", vertexCountStr.c_str()); - Writer->writeLineBreak(); - - for (i=0; i<mesh->getMeshBufferCount(); ++i) - { - scene::IMeshBuffer* buffer = mesh->getMeshBuffer(i); - video::E_VERTEX_TYPE vtxType = buffer->getVertexType(); - u32 vertexCount = buffer->getVertexCount(); - - globalIndices[i].PosStartIndex = 0; - - if (i!=0) - globalIndices[i].PosStartIndex = globalIndices[i-1].PosLastIndex + 1; - - globalIndices[i].PosLastIndex = globalIndices[i].PosStartIndex + vertexCount - 1; - - switch(vtxType) - { - case video::EVT_STANDARD: - { - video::S3DVertex* vtx = (video::S3DVertex*)buffer->getVertices(); - for (u32 j=0; j<vertexCount; ++j) - { - core::stringw str; - str += vtx[j].Pos.X; - str += " "; - str += vtx[j].Pos.Y; - str += " "; - str += vtx[j].Pos.Z; - - Writer->writeText(str.c_str()); - Writer->writeLineBreak(); - } - } - break; - case video::EVT_2TCOORDS: - { - video::S3DVertex2TCoords* vtx = (video::S3DVertex2TCoords*)buffer->getVertices(); - for (u32 j=0; j<vertexCount; ++j) - { - core::stringw str; - str += vtx[j].Pos.X; - str += " "; - str += vtx[j].Pos.Y; - str += " "; - str += vtx[j].Pos.Z; - - Writer->writeText(str.c_str()); - Writer->writeLineBreak(); - } - } - break; - case video::EVT_TANGENTS: - { - video::S3DVertexTangents* vtx = (video::S3DVertexTangents*)buffer->getVertices(); - for (u32 j=0; j<vertexCount; ++j) - { - core::stringw str; - str += vtx[j].Pos.X; - str += " "; - str += vtx[j].Pos.Y; - str += " "; - str += vtx[j].Pos.Z; - - Writer->writeText(str.c_str()); - Writer->writeLineBreak(); - } - } - break; - } - } - - Writer->writeClosingTag(L"float_array"); - Writer->writeLineBreak(); - - Writer->writeElement(L"technique_common", false); - Writer->writeLineBreak(); - - vertexCountStr = core::stringw(totalVertexCount); - - Writer->writeElement(L"accessor", false, L"source", L"#mesh-Pos-array", - L"count", vertexCountStr.c_str(), L"stride", L"3"); - Writer->writeLineBreak(); - - Writer->writeElement(L"param", true, L"name", L"X", L"type", L"float"); - Writer->writeLineBreak(); - Writer->writeElement(L"param", true, L"name", L"Y", L"type", L"float"); - Writer->writeLineBreak(); - Writer->writeElement(L"param", true, L"name", L"Z", L"type", L"float"); - Writer->writeLineBreak(); - - Writer->writeClosingTag(L"accessor"); - Writer->writeLineBreak(); - - Writer->writeClosingTag(L"technique_common"); - Writer->writeLineBreak(); - - Writer->writeClosingTag(L"source"); - Writer->writeLineBreak(); - - // write texture coordinates - - Writer->writeElement(L"source", false, L"id", L"mesh-TexCoord0"); - Writer->writeLineBreak(); - - vertexCountStr = core::stringw(totalVertexCount*2); - Writer->writeElement(L"float_array", false, L"id", L"mesh-TexCoord0-array", - L"count", vertexCountStr.c_str()); - Writer->writeLineBreak(); - - for (i=0; i<mesh->getMeshBufferCount(); ++i) - { - scene::IMeshBuffer* buffer = mesh->getMeshBuffer(i); - video::E_VERTEX_TYPE vtxType = buffer->getVertexType(); - u32 vertexCount = buffer->getVertexCount(); - - globalIndices[i].TCoord0StartIndex = 0; - - if (i!=0) - globalIndices[i].TCoord0StartIndex = globalIndices[i-1].TCoord0LastIndex + 1; - - globalIndices[i].TCoord0LastIndex = globalIndices[i].TCoord0StartIndex + vertexCount - 1; - - switch(vtxType) - { - case video::EVT_STANDARD: - { - video::S3DVertex* vtx = (video::S3DVertex*)buffer->getVertices(); - for (u32 j=0; j<vertexCount; ++j) - { - core::stringw str; - str += vtx[j].TCoords.X; - str += " "; - str += vtx[j].TCoords.Y; - - Writer->writeText(str.c_str()); - Writer->writeLineBreak(); - } - } - break; - case video::EVT_2TCOORDS: - { - video::S3DVertex2TCoords* vtx = (video::S3DVertex2TCoords*)buffer->getVertices(); - for (u32 j=0; j<vertexCount; ++j) - { - core::stringw str; - str += vtx[j].TCoords.X; - str += " "; - str += vtx[j].TCoords.Y; - - Writer->writeText(str.c_str()); - Writer->writeLineBreak(); - } - } - break; - case video::EVT_TANGENTS: - { - video::S3DVertexTangents* vtx = (video::S3DVertexTangents*)buffer->getVertices(); - for (u32 j=0; j<vertexCount; ++j) - { - core::stringw str; - str += vtx[j].TCoords.X; - str += " "; - str += vtx[j].TCoords.Y; - - Writer->writeText(str.c_str()); - Writer->writeLineBreak(); - } - } - break; - } - } - - Writer->writeClosingTag(L"float_array"); - Writer->writeLineBreak(); - - Writer->writeElement(L"technique_common", false); - Writer->writeLineBreak(); - - vertexCountStr = core::stringw(totalVertexCount); - - Writer->writeElement(L"accessor", false, L"source", L"#mesh-TexCoord0-array", - L"count", vertexCountStr.c_str(), L"stride", L"2"); - Writer->writeLineBreak(); - - Writer->writeElement(L"param", true, L"name", L"U", L"type", L"float", L"flow", L"OUT"); - Writer->writeLineBreak(); - Writer->writeElement(L"param", true, L"name", L"V", L"type", L"float", L"flow", L"OUT"); - Writer->writeLineBreak(); - - Writer->writeClosingTag(L"accessor"); - Writer->writeLineBreak(); - - Writer->writeClosingTag(L"technique_common"); - Writer->writeLineBreak(); - - Writer->writeClosingTag(L"source"); - Writer->writeLineBreak(); - - // write normals - - Writer->writeElement(L"source", false, L"id", L"mesh-Normal"); - Writer->writeLineBreak(); - - vertexCountStr = core::stringw(totalVertexCount*3); - Writer->writeElement(L"float_array", false, L"id", L"mesh-Normal-array", - L"count", vertexCountStr.c_str()); - Writer->writeLineBreak(); - - for (i=0; i<mesh->getMeshBufferCount(); ++i) - { - scene::IMeshBuffer* buffer = mesh->getMeshBuffer(i); - video::E_VERTEX_TYPE vtxType = buffer->getVertexType(); - u32 vertexCount = buffer->getVertexCount(); - - globalIndices[i].NormalStartIndex = 0; - - if (i!=0) - globalIndices[i].NormalStartIndex = globalIndices[i-1].NormalLastIndex + 1; - - globalIndices[i].NormalLastIndex = globalIndices[i].NormalStartIndex + vertexCount - 1; - - switch(vtxType) - { - case video::EVT_STANDARD: - { - video::S3DVertex* vtx = (video::S3DVertex*)buffer->getVertices(); - for (u32 j=0; j<vertexCount; ++j) - { - core::stringw str; - str += vtx[j].Normal.X; - str += " "; - str += vtx[j].Normal.Y; - str += " "; - str += vtx[j].Normal.Z; - - Writer->writeText(str.c_str()); - Writer->writeLineBreak(); - } - } - break; - case video::EVT_2TCOORDS: - { - video::S3DVertex2TCoords* vtx = (video::S3DVertex2TCoords*)buffer->getVertices(); - for (u32 j=0; j<vertexCount; ++j) - { - core::stringw str; - str += vtx[j].Normal.X; - str += " "; - str += vtx[j].Normal.Y; - str += " "; - str += vtx[j].Normal.Z; - - Writer->writeText(str.c_str()); - Writer->writeLineBreak(); - } - } - break; - case video::EVT_TANGENTS: - { - video::S3DVertexTangents* vtx = (video::S3DVertexTangents*)buffer->getVertices(); - for (u32 j=0; j<vertexCount; ++j) - { - core::stringw str; - str += vtx[j].Normal.X; - str += " "; - str += vtx[j].Normal.Y; - str += " "; - str += vtx[j].Normal.Z; - - Writer->writeText(str.c_str()); - Writer->writeLineBreak(); - } - } - break; - } - } - - Writer->writeClosingTag(L"float_array"); - Writer->writeLineBreak(); - - Writer->writeElement(L"technique_common", false); - Writer->writeLineBreak(); - - vertexCountStr = core::stringw(totalVertexCount); - - Writer->writeElement(L"accessor", false, L"source", L"#mesh-Normal-array", - L"count", vertexCountStr.c_str(), L"stride", L"3"); - Writer->writeLineBreak(); - - Writer->writeElement(L"param", true, L"name", L"X", L"type", L"float", L"flow", L"OUT"); - Writer->writeLineBreak(); - Writer->writeElement(L"param", true, L"name", L"Y", L"type", L"float", L"flow", L"OUT"); - Writer->writeLineBreak(); - Writer->writeElement(L"param", true, L"name", L"Z", L"type", L"float", L"flow", L"OUT"); - Writer->writeLineBreak(); - - Writer->writeClosingTag(L"accessor"); - Writer->writeLineBreak(); - - Writer->writeClosingTag(L"technique_common"); - Writer->writeLineBreak(); - - Writer->writeClosingTag(L"source"); - Writer->writeLineBreak(); - - // write second set of texture coordinates - - if (totalTCoords2Count) - { - Writer->writeElement(L"source", false, L"id", L"mesh-TexCoord1"); - Writer->writeLineBreak(); - - vertexCountStr = core::stringw(totalTCoords2Count*2); - Writer->writeElement(L"float_array", false, L"id", L"mesh-TexCoord1-array", - L"count", vertexCountStr.c_str()); - Writer->writeLineBreak(); - - for (i=0; i<mesh->getMeshBufferCount(); ++i) - { - scene::IMeshBuffer* buffer = mesh->getMeshBuffer(i); - video::E_VERTEX_TYPE vtxType = buffer->getVertexType(); - u32 vertexCount = buffer->getVertexCount(); - - if (hasSecondTextureCoordinates(vtxType)) - { - globalIndices[i].TCoord1StartIndex = 0; - - if (i!=0 && globalIndices[i-1].TCoord1LastIndex != -1) - globalIndices[i].TCoord1StartIndex = globalIndices[i-1].TCoord1LastIndex + 1; - - globalIndices[i].TCoord1LastIndex = globalIndices[i].TCoord1StartIndex + vertexCount - 1; - - switch(vtxType) - { - case video::EVT_2TCOORDS: - { - video::S3DVertex2TCoords* vtx = (video::S3DVertex2TCoords*)buffer->getVertices(); - for (u32 j=0; j<vertexCount; ++j) - { - core::stringw str; - str += vtx[j].TCoords2.X; - str += " "; - str += vtx[j].TCoords2.Y; - - Writer->writeText(str.c_str()); - Writer->writeLineBreak(); - } - } - break; - default: - break; - } - } // end this buffer has 2 texture coordinates - } - - Writer->writeClosingTag(L"float_array"); - Writer->writeLineBreak(); - - Writer->writeElement(L"technique_common", false); - Writer->writeLineBreak(); - - vertexCountStr = core::stringw(totalTCoords2Count); - - Writer->writeElement(L"accessor", false, L"source", L"#mesh-TexCoord1-array", - L"count", vertexCountStr.c_str(), L"stride", L"2"); - Writer->writeLineBreak(); - - Writer->writeElement(L"param", true, L"name", L"U", L"type", L"float", L"flow", L"OUT"); - Writer->writeLineBreak(); - Writer->writeElement(L"param", true, L"name", L"V", L"type", L"float", L"flow", L"OUT"); - Writer->writeLineBreak(); - - Writer->writeClosingTag(L"accessor"); - Writer->writeLineBreak(); - - Writer->writeClosingTag(L"technique_common"); - Writer->writeLineBreak(); - - Writer->writeClosingTag(L"source"); - Writer->writeLineBreak(); - } - - // write tangents - - // TODO - - // write vertices - - Writer->writeElement(L"vertices", false, L"id", L"mesh-Vtx"); - Writer->writeLineBreak(); - - Writer->writeElement(L"input", true, L"semantic", L"POSITION", L"source", L"#mesh-Pos"); - Writer->writeLineBreak(); - - Writer->writeClosingTag(L"vertices"); - Writer->writeLineBreak(); - - // write polygons - - for (i=0; i<mesh->getMeshBufferCount(); ++i) - { - scene::IMeshBuffer* buffer = mesh->getMeshBuffer(i); - - const u32 polyCount = buffer->getIndexCount() / 3; - core::stringw strPolyCount(polyCount); - core::stringw strMat = "#mat"; - strMat += i; - - Writer->writeElement(L"triangles", false, L"count", strPolyCount.c_str(), - L"material", strMat.c_str()); - Writer->writeLineBreak(); - - Writer->writeElement(L"input", true, L"semantic", L"VERTEX", L"source", L"#mesh-Vtx", L"idx", L"0"); - Writer->writeLineBreak(); - Writer->writeElement(L"input", true, L"semantic", L"TEXCOORD", L"source", L"#mesh-TexCoord0", L"idx", L"1"); - Writer->writeLineBreak(); - Writer->writeElement(L"input", true, L"semantic", L"NORMAL", L"source", L"#mesh-Normal", L"idx", L"2"); - Writer->writeLineBreak(); - - bool has2ndTexCoords = hasSecondTextureCoordinates(buffer->getVertexType()); - if (has2ndTexCoords) - { - Writer->writeElement(L"input", true, L"semantic", L"TEXCOORD", L"source", L"#mesh-TexCoord1", L"idx", L"3"); - Writer->writeLineBreak(); - } - - // write indices now - - s32 posIdx = globalIndices[i].PosStartIndex; - s32 tCoordIdx = globalIndices[i].TCoord0StartIndex; - s32 normalIdx = globalIndices[i].NormalStartIndex; - s32 tCoord2Idx = globalIndices[i].TCoord1StartIndex; - - Writer->writeElement(L"p", false); - - for (u32 p=0; p<polyCount; ++p) - { - core::stringw strP; - - strP += buffer->getIndices()[(p*3) + 0] + posIdx; - strP += " "; - strP += buffer->getIndices()[(p*3) + 0] + tCoordIdx; - strP += " "; - strP += buffer->getIndices()[(p*3) + 0] + normalIdx; - strP += " "; - if (has2ndTexCoords) - { - strP += buffer->getIndices()[(p*3) + 0] + tCoord2Idx; - strP += " "; - } - - strP += buffer->getIndices()[(p*3) + 1] + posIdx; - strP += " "; - strP += buffer->getIndices()[(p*3) + 1] + tCoordIdx; - strP += " "; - strP += buffer->getIndices()[(p*3) + 1] + normalIdx; - strP += " "; - if (has2ndTexCoords) - { - strP += buffer->getIndices()[(p*3) + 1] + tCoord2Idx; - strP += " "; - } - - strP += buffer->getIndices()[(p*3) + 2] + posIdx; - strP += " "; - strP += buffer->getIndices()[(p*3) + 2] + tCoordIdx; - strP += " "; - strP += buffer->getIndices()[(p*3) + 2] + normalIdx; - if (has2ndTexCoords) - { - strP += " "; - strP += buffer->getIndices()[(p*3) + 2] + tCoord2Idx; - } - strP += " "; - - Writer->writeText(strP.c_str()); - } - - Writer->writeClosingTag(L"p"); - Writer->writeLineBreak(); - - // close index buffer section - - Writer->writeClosingTag(L"triangles"); - Writer->writeLineBreak(); - } - - // close mesh and geometry - - Writer->writeClosingTag(L"mesh"); - Writer->writeLineBreak(); - Writer->writeClosingTag(L"geometry"); - Writer->writeLineBreak(); - - Writer->writeClosingTag(L"library_geometries"); - Writer->writeLineBreak(); - - // close everything - - Writer->writeClosingTag(L"COLLADA"); - Writer->drop(); - - delete [] globalIndices; - - return true; -} - - -bool CColladaMeshWriter::hasSecondTextureCoordinates(video::E_VERTEX_TYPE type) const -{ - return type == video::EVT_2TCOORDS; -} - - -} // end namespace -} // end namespace - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CColladaMeshWriter.h b/irrlicht-1.6/source/Irrlicht/CColladaMeshWriter.h deleted file mode 100644 index 694c73e44..000000000 --- a/irrlicht-1.6/source/Irrlicht/CColladaMeshWriter.h +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_C_COLLADA_MESH_WRITER_H_INCLUDED__ -#define __IRR_C_COLLADA_MESH_WRITER_H_INCLUDED__ - -#include "IMeshWriter.h" -#include "S3DVertex.h" -#include "IVideoDriver.h" - -namespace irr -{ -namespace io -{ - class IXMLWriter; - class IFileSystem; -} -namespace scene -{ - -//! class to write meshes, implementing a COLLADA (.dae, .xml) writer -/** This writer implementation has been originally developed for irrEdit and then -merged out to the Irrlicht Engine */ -class CColladaMeshWriter : public IMeshWriter -{ -public: - - CColladaMeshWriter(video::IVideoDriver* driver, io::IFileSystem* fs); - virtual ~CColladaMeshWriter(); - - //! 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: - - bool hasSecondTextureCoordinates(video::E_VERTEX_TYPE type) const; - - struct SComponentGlobalStartPos - { - SComponentGlobalStartPos() : PosStartIndex(-1), PosLastIndex(-1), - NormalStartIndex(-1), NormalLastIndex(-1), - TCoord0StartIndex(-1), TCoord0LastIndex(-1), - TCoord1StartIndex(-1), TCoord1LastIndex(-1) - { } - - s32 PosStartIndex; - s32 PosLastIndex; - - s32 NormalStartIndex; - s32 NormalLastIndex; - - s32 TCoord0StartIndex; - s32 TCoord0LastIndex; - - s32 TCoord1StartIndex; - s32 TCoord1LastIndex; - }; - - io::IFileSystem* FileSystem; - video::IVideoDriver* VideoDriver; - io::IXMLWriter* Writer; -}; - - -} // end namespace -} // end namespace - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CColorConverter.cpp b/irrlicht-1.6/source/Irrlicht/CColorConverter.cpp deleted file mode 100644 index 4adddb81e..000000000 --- a/irrlicht-1.6/source/Irrlicht/CColorConverter.cpp +++ /dev/null @@ -1,603 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CColorConverter.h" -#include "SColor.h" -#include "os.h" -#include "irrString.h" - -namespace irr -{ -namespace video -{ - -//! converts a monochrome bitmap to A1R5G5B5 data -void CColorConverter::convert1BitTo16Bit(const u8* in, s16* out, s32 width, s32 height, s32 linepad, bool flip) -{ - if (!in || !out) - return; - - if (flip) - out += width * height; - - for (s32 y=0; y<height; ++y) - { - s32 shift = 7; - if (flip) - out -= width; - - for (s32 x=0; x<width; ++x) - { - out[x] = *in>>shift & 0x01 ? (s16)0xffff : (s16)0x8000; - - if ((--shift)<0) // 8 pixel done - { - shift=7; - ++in; - } - } - - if (shift != 7) // width did not fill last byte - ++in; - - if (!flip) - out += width; - in += linepad; - } -} - - - -//! converts a 4 bit palettized image to A1R5G5B5 -void CColorConverter::convert4BitTo16Bit(const u8* in, s16* out, s32 width, s32 height, const s32* palette, s32 linepad, bool flip) -{ - if (!in || !out || !palette) - return; - - if (flip) - out += width*height; - - for (s32 y=0; y<height; ++y) - { - s32 shift = 4; - if (flip) - out -= width; - - for (s32 x=0; x<width; ++x) - { - out[x] = X8R8G8B8toA1R5G5B5(palette[(u8)((*in >> shift) & 0xf)]); - - if (shift==0) - { - shift = 4; - ++in; - } - else - shift = 0; - } - - if (shift == 0) // odd width - ++in; - - if (!flip) - out += width; - in += linepad; - } -} - - - -//! converts a 8 bit palettized image into A1R5G5B5 -void CColorConverter::convert8BitTo16Bit(const u8* in, s16* out, s32 width, s32 height, const s32* palette, s32 linepad, bool flip) -{ - if (!in || !out || !palette) - return; - - if (flip) - out += width * height; - - for (s32 y=0; y<height; ++y) - { - if (flip) - out -= width; // one line back - for (s32 x=0; x<width; ++x) - { - out[x] = X8R8G8B8toA1R5G5B5(palette[(u8)(*in)]); - ++in; - } - if (!flip) - out += width; - in += linepad; - } -} - - - -//! converts 16bit data to 16bit data -void CColorConverter::convert16BitTo16Bit(const s16* in, s16* out, s32 width, s32 height, s32 linepad, bool flip) -{ - if (!in || !out) - return; - - if (flip) - out += width * height; - - for (s32 y=0; y<height; ++y) - { - if (flip) - out -= width; -#ifdef __BIG_ENDIAN__ - for (s32 x=0; x<width; ++x) - out[x]=os::Byteswap::byteswap(in[x]); -#else - memcpy(out, in, width*sizeof(s16)); -#endif - if (!flip) - out += width; - in += width; - in += linepad; - } -} - - - -//! copies R8G8B8 24bit data to 24bit data -void CColorConverter::convert24BitTo24Bit(const u8* in, u8* out, s32 width, s32 height, s32 linepad, bool flip, bool bgr) -{ - if (!in || !out) - return; - - const s32 lineWidth = 3 * width; - if (flip) - out += lineWidth * height; - - for (s32 y=0; y<height; ++y) - { - if (flip) - out -= lineWidth; - if (bgr) - { - for (s32 x=0; x<lineWidth; x+=3) - { - out[x+0] = in[x+2]; - out[x+1] = in[x+1]; - out[x+2] = in[x+0]; - } - } - else - { - memcpy(out,in,lineWidth); - } - if (!flip) - out += lineWidth; - in += lineWidth; - in += linepad; - } -} - - - -//! Resizes the surface to a new size and converts it at the same time -//! to an A8R8G8B8 format, returning the pointer to the new buffer. -void CColorConverter::convert16bitToA8R8G8B8andResize(const s16* in, s32* out, s32 newWidth, s32 newHeight, s32 currentWidth, s32 currentHeight) -{ - if (!newWidth || !newHeight) - return; - - // note: this is very very slow. (i didn't want to write a fast version. - // but hopefully, nobody wants to convert surfaces every frame. - - f32 sourceXStep = (f32)currentWidth / (f32)newWidth; - f32 sourceYStep = (f32)currentHeight / (f32)newHeight; - f32 sy; - s32 t; - - for (s32 x=0; x<newWidth; ++x) - { - sy = 0.0f; - - for (s32 y=0; y<newHeight; ++y) - { - t = in[(s32)(((s32)sy)*currentWidth + x*sourceXStep)]; - t = (((t >> 15)&0x1)<<31) | (((t >> 10)&0x1F)<<19) | - (((t >> 5)&0x1F)<<11) | (t&0x1F)<<3; - out[(s32)(y*newWidth + x)] = t; - - sy+=sourceYStep; - } - } -} - - - -//! copies X8R8G8B8 32 bit data -void CColorConverter::convert32BitTo32Bit(const s32* in, s32* out, s32 width, s32 height, s32 linepad, bool flip) -{ - if (!in || !out) - return; - - if (flip) - out += width * height; - - for (s32 y=0; y<height; ++y) - { - if (flip) - out -= width; -#ifdef __BIG_ENDIAN__ - for (s32 x=0; x<width; ++x) - out[x]=os::Byteswap::byteswap(in[x]); -#else - memcpy(out, in, width*sizeof(s32)); -#endif - if (!flip) - out += width; - in += width; - in += linepad; - } -} - - - -void CColorConverter::convert_A1R5G5B5toR8G8B8(const void* sP, s32 sN, void* dP) -{ - u16* sB = (u16*)sP; - u8 * dB = (u8 *)dP; - - for (s32 x = 0; x < sN; ++x) - { - dB[2] = (*sB & 0x7c00) >> 7; - dB[1] = (*sB & 0x03e0) >> 2; - dB[0] = (*sB & 0x1f) << 3; - - sB += 1; - dB += 3; - } -} - -void CColorConverter::convert_A1R5G5B5toB8G8R8(const void* sP, s32 sN, void* dP) -{ - u16* sB = (u16*)sP; - u8 * dB = (u8 *)dP; - - for (s32 x = 0; x < sN; ++x) - { - dB[0] = (*sB & 0x7c00) >> 7; - dB[1] = (*sB & 0x03e0) >> 2; - dB[2] = (*sB & 0x1f) << 3; - - sB += 1; - dB += 3; - } -} - -void CColorConverter::convert_A1R5G5B5toA8R8G8B8(const void* sP, s32 sN, void* dP) -{ - u16* sB = (u16*)sP; - u32* dB = (u32*)dP; - - for (s32 x = 0; x < sN; ++x) - *dB++ = A1R5G5B5toA8R8G8B8(*sB++); -} - -void CColorConverter::convert_A1R5G5B5toA1R5G5B5(const void* sP, s32 sN, void* dP) -{ - memcpy(dP, sP, sN * 2); -} - -void CColorConverter::convert_A1R5G5B5toR5G6B5(const void* sP, s32 sN, void* dP) -{ - u16* sB = (u16*)sP; - u16* dB = (u16*)dP; - - for (s32 x = 0; x < sN; ++x) - *dB++ = A1R5G5B5toR5G6B5(*sB++); -} - -void CColorConverter::convert_A8R8G8B8toR8G8B8(const void* sP, s32 sN, void* dP) -{ - u8* sB = (u8*)sP; - u8* dB = (u8*)dP; - - for (s32 x = 0; x < sN; ++x) - { - // sB[3] is alpha - dB[0] = sB[2]; - dB[1] = sB[1]; - dB[2] = sB[0]; - - sB += 4; - dB += 3; - } -} - -void CColorConverter::convert_A8R8G8B8toB8G8R8(const void* sP, s32 sN, void* dP) -{ - u8* sB = (u8*)sP; - u8* dB = (u8*)dP; - - for (s32 x = 0; x < sN; ++x) - { - // sB[3] is alpha - dB[0] = sB[0]; - dB[1] = sB[1]; - dB[2] = sB[2]; - - sB += 4; - dB += 3; - } -} - -void CColorConverter::convert_A8R8G8B8toA8R8G8B8(const void* sP, s32 sN, void* dP) -{ - memcpy(dP, sP, sN * 4); -} - -void CColorConverter::convert_A8R8G8B8toA1R5G5B5(const void* sP, s32 sN, void* dP) -{ - u32* sB = (u32*)sP; - u16* dB = (u16*)dP; - - for (s32 x = 0; x < sN; ++x) - *dB++ = A8R8G8B8toA1R5G5B5(*sB++); -} - -void CColorConverter::convert_A8R8G8B8toR5G6B5(const void* sP, s32 sN, void* dP) -{ - u8 * sB = (u8 *)sP; - u16* dB = (u16*)dP; - - for (s32 x = 0; x < sN; ++x) - { - s32 r = sB[2] >> 3; - s32 g = sB[1] >> 2; - s32 b = sB[0] >> 3; - - dB[0] = (r << 11) | (g << 5) | (b); - - sB += 4; - dB += 1; - } -} - -void CColorConverter::convert_A8R8G8B8toR3G3B2(const void* sP, s32 sN, void* dP) -{ - u8* sB = (u8*)sP; - u8* dB = (u8*)dP; - - for (s32 x = 0; x < sN; ++x) - { - u8 r = sB[2] & 0xe0; - u8 g = (sB[1] & 0xe0) >> 3; - u8 b = (sB[0] & 0xc0) >> 6; - - dB[0] = (r | g | b); - - sB += 4; - dB += 1; - } -} - -void CColorConverter::convert_R8G8B8toR8G8B8(const void* sP, s32 sN, void* dP) -{ - memcpy(dP, sP, sN * 3); -} - -void CColorConverter::convert_R8G8B8toA8R8G8B8(const void* sP, s32 sN, void* dP) -{ - u8* sB = (u8* )sP; - u32* dB = (u32*)dP; - - for (s32 x = 0; x < sN; ++x) - { - *dB = 0xff000000 | (sB[0]<<16) | (sB[1]<<8) | sB[2]; - - sB += 3; - ++dB; - } -} - -void CColorConverter::convert_R8G8B8toA1R5G5B5(const void* sP, s32 sN, void* dP) -{ - u8 * sB = (u8 *)sP; - u16* dB = (u16*)dP; - - for (s32 x = 0; x < sN; ++x) - { - s32 r = sB[0] >> 3; - s32 g = sB[1] >> 3; - s32 b = sB[2] >> 3; - - dB[0] = (0x8000) | (r << 10) | (g << 5) | (b); - - sB += 3; - dB += 1; - } -} - -void CColorConverter::convert_B8G8R8toA8R8G8B8(const void* sP, s32 sN, void* dP) -{ - u8* sB = (u8* )sP; - u32* dB = (u32*)dP; - - for (s32 x = 0; x < sN; ++x) - { - *dB = 0xff000000 | (sB[2]<<16) | (sB[1]<<8) | sB[0]; - - sB += 3; - ++dB; - } -} - -void CColorConverter::convert_B8G8R8A8toA8R8G8B8(const void* sP, s32 sN, void* dP) -{ - u8* sB = (u8*)sP; - u8* dB = (u8*)dP; - - for (s32 x = 0; x < sN; ++x) - { - dB[0] = sB[3]; - dB[1] = sB[2]; - dB[2] = sB[1]; - dB[3] = sB[0]; - - sB += 4; - dB += 4; - } - -} - -void CColorConverter::convert_R8G8B8toR5G6B5(const void* sP, s32 sN, void* dP) -{ - u8 * sB = (u8 *)sP; - u16* dB = (u16*)dP; - - for (s32 x = 0; x < sN; ++x) - { - s32 r = sB[0] >> 3; - s32 g = sB[1] >> 2; - s32 b = sB[2] >> 3; - - dB[0] = (r << 11) | (g << 5) | (b); - - sB += 3; - dB += 1; - } -} - -void CColorConverter::convert_R5G6B5toR5G6B5(const void* sP, s32 sN, void* dP) -{ - memcpy(dP, sP, sN * 2); -} - -void CColorConverter::convert_R5G6B5toR8G8B8(const void* sP, s32 sN, void* dP) -{ - u16* sB = (u16*)sP; - u8 * dB = (u8 *)dP; - - for (s32 x = 0; x < sN; ++x) - { - dB[0] = (*sB & 0xf800) << 8; - dB[1] = (*sB & 0x07e0) << 2; - dB[2] = (*sB & 0x001f) << 3; - - sB += 4; - dB += 3; - } -} - -void CColorConverter::convert_R5G6B5toB8G8R8(const void* sP, s32 sN, void* dP) -{ - u16* sB = (u16*)sP; - u8 * dB = (u8 *)dP; - - for (s32 x = 0; x < sN; ++x) - { - dB[2] = (*sB & 0xf800) << 8; - dB[1] = (*sB & 0x07e0) << 2; - dB[0] = (*sB & 0x001f) << 3; - - sB += 4; - dB += 3; - } -} - -void CColorConverter::convert_R5G6B5toA8R8G8B8(const void* sP, s32 sN, void* dP) -{ - u16* sB = (u16*)sP; - u32* dB = (u32*)dP; - - for (s32 x = 0; x < sN; ++x) - *dB++ = R5G6B5toA8R8G8B8(*sB++); -} - -void CColorConverter::convert_R5G6B5toA1R5G5B5(const void* sP, s32 sN, void* dP) -{ - u16* sB = (u16*)sP; - u16* dB = (u16*)dP; - - for (s32 x = 0; x < sN; ++x) - *dB++ = R5G6B5toA1R5G5B5(*sB++); -} - - -void CColorConverter::convert_viaFormat(const void* sP, ECOLOR_FORMAT sF, s32 sN, - void* dP, ECOLOR_FORMAT dF) -{ - switch (sF) - { - case ECF_A1R5G5B5: - switch (dF) - { - case ECF_A1R5G5B5: - convert_A1R5G5B5toA1R5G5B5(sP, sN, dP); - break; - case ECF_R5G6B5: - convert_A1R5G5B5toR5G6B5(sP, sN, dP); - break; - case ECF_A8R8G8B8: - convert_A1R5G5B5toA8R8G8B8(sP, sN, dP); - break; - case ECF_R8G8B8: - convert_A1R5G5B5toR8G8B8(sP, sN, dP); - break; - } - break; - case ECF_R5G6B5: - switch (dF) - { - case ECF_A1R5G5B5: - convert_R5G6B5toA1R5G5B5(sP, sN, dP); - break; - case ECF_R5G6B5: - convert_R5G6B5toR5G6B5(sP, sN, dP); - break; - case ECF_A8R8G8B8: - convert_R5G6B5toA8R8G8B8(sP, sN, dP); - break; - case ECF_R8G8B8: - convert_R5G6B5toR8G8B8(sP, sN, dP); - break; - } - break; - case ECF_A8R8G8B8: - switch (dF) - { - case ECF_A1R5G5B5: - convert_A8R8G8B8toA1R5G5B5(sP, sN, dP); - break; - case ECF_R5G6B5: - convert_A8R8G8B8toR5G6B5(sP, sN, dP); - break; - case ECF_A8R8G8B8: - convert_A8R8G8B8toA8R8G8B8(sP, sN, dP); - break; - case ECF_R8G8B8: - convert_A8R8G8B8toR8G8B8(sP, sN, dP); - break; - } - break; - case ECF_R8G8B8: - switch (dF) - { - case ECF_A1R5G5B5: - convert_R8G8B8toA1R5G5B5(sP, sN, dP); - break; - case ECF_R5G6B5: - convert_R8G8B8toR5G6B5(sP, sN, dP); - break; - case ECF_A8R8G8B8: - convert_R8G8B8toA8R8G8B8(sP, sN, dP); - break; - case ECF_R8G8B8: - convert_R8G8B8toR8G8B8(sP, sN, dP); - break; - } - break; - } -} - - -} // end namespace video -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CColorConverter.h b/irrlicht-1.6/source/Irrlicht/CColorConverter.h deleted file mode 100644 index e678c598e..000000000 --- a/irrlicht-1.6/source/Irrlicht/CColorConverter.h +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_COLOR_CONVERTER_H_INCLUDED__ -#define __C_COLOR_CONVERTER_H_INCLUDED__ - -#include "irrTypes.h" -#include "IImage.h" - -namespace irr -{ -namespace video -{ - -class CColorConverter -{ -public: - - //! converts a monochrome bitmap to A1R5G5B5 - static void convert1BitTo16Bit(const u8* in, s16* out, s32 width, s32 height, s32 linepad=0, bool flip=false); - - //! converts a 4 bit palettized image to A1R5G5B5 - static void convert4BitTo16Bit(const u8* in, s16* out, s32 width, s32 height, const s32* palette, s32 linepad=0, bool flip=false); - - //! converts a 8 bit palettized image to A1R5G5B5 - static void convert8BitTo16Bit(const u8* in, s16* out, s32 width, s32 height, const s32* palette, s32 linepad=0, bool flip=false); - - //! converts R8G8B8 16 bit data to A1R5G5B5 data - static void convert16BitTo16Bit(const s16* in, s16* out, s32 width, s32 height, s32 linepad=0, bool flip=false); - - //! copies R8G8B8 24 bit data to 24 data, and flips and - //! mirrors the image during the process. - static void convert24BitTo24Bit(const u8* in, u8* out, s32 width, s32 height, s32 linepad=0, bool flip=false, bool bgr=false); - - //! Resizes the surface to a new size and converts it at the same time - //! to an A8R8G8B8 format, returning the pointer to the new buffer. - static void convert16bitToA8R8G8B8andResize(const s16* in, s32* out, s32 newWidth, s32 newHeight, s32 currentWidth, s32 currentHeight); - - //! copies X8R8G8B8 32 bit data, and flips and - //! mirrors the image during the process. - static void convert32BitTo32Bit(const s32* in, s32* out, s32 width, s32 height, s32 linepad, bool flip=false); - - - //! functions for converting one image format to another efficiently - //! and hopefully correctly. - //! - //! \param sP pointer to source pixel data - //! \param sN number of source pixels to copy - //! \param dP pointer to destination data buffer. must be big enough - //! to hold sN pixels in the output format. - static void convert_A1R5G5B5toR8G8B8(const void* sP, s32 sN, void* dP); - static void convert_A1R5G5B5toB8G8R8(const void* sP, s32 sN, void* dP); - static void convert_A1R5G5B5toA8R8G8B8(const void* sP, s32 sN, void* dP); - static void convert_A1R5G5B5toA1R5G5B5(const void* sP, s32 sN, void* dP); - static void convert_A1R5G5B5toR5G6B5(const void* sP, s32 sN, void* dP); - - static void convert_A8R8G8B8toR8G8B8(const void* sP, s32 sN, void* dP); - static void convert_A8R8G8B8toB8G8R8(const void* sP, s32 sN, void* dP); - static void convert_A8R8G8B8toA8R8G8B8(const void* sP, s32 sN, void* dP); - static void convert_A8R8G8B8toA1R5G5B5(const void* sP, s32 sN, void* dP); - static void convert_A8R8G8B8toR5G6B5(const void* sP, s32 sN, void* dP); - - static void convert_A8R8G8B8toR3G3B2(const void* sP, s32 sN, void* dP); - static void convert_R8G8B8toR8G8B8(const void* sP, s32 sN, void* dP); - static void convert_R8G8B8toA8R8G8B8(const void* sP, s32 sN, void* dP); - static void convert_R8G8B8toA1R5G5B5(const void* sP, s32 sN, void* dP); - static void convert_R8G8B8toR5G6B5(const void* sP, s32 sN, void* dP); - static void convert_B8G8R8toA8R8G8B8(const void* sP, s32 sN, void* dP); - static void convert_B8G8R8A8toA8R8G8B8(const void* sP, s32 sN, void* dP); - - static void convert_R5G6B5toR5G6B5(const void* sP, s32 sN, void* dP); - static void convert_R5G6B5toR8G8B8(const void* sP, s32 sN, void* dP); - static void convert_R5G6B5toB8G8R8(const void* sP, s32 sN, void* dP); - static void convert_R5G6B5toA8R8G8B8(const void* sP, s32 sN, void* dP); - static void convert_R5G6B5toA1R5G5B5(const void* sP, s32 sN, void* dP); - static void convert_viaFormat(const void* sP, ECOLOR_FORMAT sF, s32 sN, - void* dP, ECOLOR_FORMAT dF); -}; - - -} // end namespace video -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CCubeSceneNode.cpp b/irrlicht-1.6/source/Irrlicht/CCubeSceneNode.cpp deleted file mode 100644 index f697f8dcc..000000000 --- a/irrlicht-1.6/source/Irrlicht/CCubeSceneNode.cpp +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CCubeSceneNode.h" -#include "IVideoDriver.h" -#include "ISceneManager.h" -#include "S3DVertex.h" -#include "SMeshBuffer.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - - /* - 011 111 - /6,8------/5 y - / | / | ^ z - / | / | | / - 010 3,9-------2 | |/ - | 7- - -10,4 101 *---->x - | / | / - |/ | / - 0------11,1/ - 000 100 - */ - -//! constructor -CCubeSceneNode::CCubeSceneNode(f32 size, ISceneNode* parent, ISceneManager* mgr, - s32 id, const core::vector3df& position, - const core::vector3df& rotation, const core::vector3df& scale) - : IMeshSceneNode(parent, mgr, id, position, rotation, scale), - Mesh(0), Size(size) -{ - #ifdef _DEBUG - setDebugName("CCubeSceneNode"); - #endif - - setSize(); -} - - -CCubeSceneNode::~CCubeSceneNode() -{ - if (Mesh) - Mesh->drop(); -} - - -void CCubeSceneNode::setSize() -{ - if (Mesh) - Mesh->drop(); - Mesh = SceneManager->getGeometryCreator()->createCubeMesh(core::vector3df(Size)); -} - - -//! renders the node. -void CCubeSceneNode::render() -{ - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - driver->setMaterial(Mesh->getMeshBuffer(0)->getMaterial()); - driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); - driver->drawMeshBuffer(Mesh->getMeshBuffer(0)); -} - - -//! returns the axis aligned bounding box of this node -const core::aabbox3d<f32>& CCubeSceneNode::getBoundingBox() const -{ - return Mesh->getMeshBuffer(0)->getBoundingBox(); -} - - -void CCubeSceneNode::OnRegisterSceneNode() -{ - if (IsVisible) - SceneManager->registerNodeForRendering(this); - ISceneNode::OnRegisterSceneNode(); -} - - -//! returns the material based on the zero based index i. -video::SMaterial& CCubeSceneNode::getMaterial(u32 i) -{ - return Mesh->getMeshBuffer(0)->getMaterial(); -} - - -//! returns amount of materials used by this scene node. -u32 CCubeSceneNode::getMaterialCount() const -{ - return 1; -} - - -//! Writes attributes of the scene node. -void CCubeSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const -{ - ISceneNode::serializeAttributes(out, options); - - out->addFloat("Size", Size); -} - - -//! Reads attributes of the scene node. -void CCubeSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - f32 newSize = in->getAttributeAsFloat("Size"); - newSize = core::max_(newSize, 0.0001f); - if (newSize != Size) - { - Size = newSize; - setSize(); - } - - ISceneNode::deserializeAttributes(in, options); -} - - -//! Creates a clone of this scene node and its children. -ISceneNode* CCubeSceneNode::clone(ISceneNode* newParent, ISceneManager* newManager) -{ - if (!newParent) - newParent = Parent; - if (!newManager) - newManager = SceneManager; - - CCubeSceneNode* nb = new CCubeSceneNode(Size, newParent, - newManager, ID, RelativeTranslation); - - nb->cloneMembers(this, newManager); - nb->getMaterial(0) = getMaterial(0); - - nb->drop(); - return nb; -} - - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CCubeSceneNode.h b/irrlicht-1.6/source/Irrlicht/CCubeSceneNode.h deleted file mode 100644 index 33aa15ffb..000000000 --- a/irrlicht-1.6/source/Irrlicht/CCubeSceneNode.h +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_CUBE_SCENE_NODE_H_INCLUDED__ -#define __C_CUBE_SCENE_NODE_H_INCLUDED__ - -#include "IMeshSceneNode.h" -#include "SMesh.h" - -namespace irr -{ -namespace scene -{ - class CCubeSceneNode : public IMeshSceneNode - { - public: - - //! constructor - CCubeSceneNode(f32 size, ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); - - virtual ~CCubeSceneNode(); - - virtual void OnRegisterSceneNode(); - - //! renders the node. - virtual void render(); - - //! returns the axis aligned bounding box of this node - virtual const core::aabbox3d<f32>& getBoundingBox() const; - - //! returns the material based on the zero based index i. To get the amount - //! of materials used by this scene node, use getMaterialCount(). - //! This function is needed for inserting the node into the scene hirachy on a - //! optimal position for minimizing renderstate changes, but can also be used - //! to directly modify the material of a scene node. - virtual video::SMaterial& getMaterial(u32 i); - - //! returns amount of materials used by this scene node. - virtual u32 getMaterialCount() const; - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() const { return ESNT_CUBE; } - - //! Writes attributes of the scene node. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const; - - //! Reads attributes of the scene node. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - //! Creates a clone of this scene node and its children. - virtual ISceneNode* clone(ISceneNode* newParent=0, ISceneManager* newManager=0); - - //! Sets a new mesh to display - virtual void setMesh(IMesh* mesh) {} - - //! Returns the current mesh - virtual IMesh* getMesh(void) { return Mesh; } - - //! Sets if the scene node should not copy the materials of the mesh but use them in a read only style. - /* In this way it is possible to change the materials a mesh causing all mesh scene nodes - referencing this mesh to change too. */ - virtual void setReadOnlyMaterials(bool readonly) {} - - //! Returns if the scene node should not copy the materials of the mesh but use them in a read only style - virtual bool isReadOnlyMaterials() const { return false; } - - private: - void setSize(); - - IMesh* Mesh; - f32 Size; - }; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CD3D8Driver.cpp b/irrlicht-1.6/source/Irrlicht/CD3D8Driver.cpp deleted file mode 100644 index e3dd6a28f..000000000 --- a/irrlicht-1.6/source/Irrlicht/CD3D8Driver.cpp +++ /dev/null @@ -1,2332 +0,0 @@ -// Copyright (C) 2002-2009 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" - -#define _IRR_DONT_DO_MEMORY_DEBUGGING_HERE -#include "CD3D8Driver.h" - -#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ - -#include "os.h" -#include "S3DVertex.h" -#include "CD3D8Texture.h" -#include "CImage.h" -#include "CD3D8MaterialRenderer.h" -#include "CD3D8ShaderMaterialRenderer.h" -#include "CD3D8NormalMapRenderer.h" -#include "CD3D8ParallaxMapRenderer.h" - -namespace irr -{ -namespace video -{ - - -//! constructor -CD3D8Driver::CD3D8Driver(const core::dimension2d<u32>& screenSize, HWND window, - bool fullscreen, bool stencilbuffer, - io::IFileSystem* io, bool pureSoftware, bool vsync) -: CNullDriver(io, screenSize), CurrentRenderMode(ERM_NONE), - ResetRenderStates(true), Transformation3DChanged(false), StencilBuffer(stencilbuffer), - D3DLibrary(0), pID3D(0), pID3DDevice(0), PrevRenderTarget(0), - WindowId(0), SceneSourceRect(0), - LastVertexType((video::E_VERTEX_TYPE)-1), MaxTextureUnits(0), MaxUserClipPlanes(0), - MaxLightDistance(0), LastSetLight(-1), DeviceLost(false), - DriverWasReset(true) -{ - #ifdef _DEBUG - setDebugName("CD3D8Driver"); - #endif - - printVersion(); - - for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i) - CurrentTexture[i] = 0; - MaxLightDistance=sqrtf(FLT_MAX); - // create sphere map matrix - - SphereMapMatrixD3D8._11 = 0.5f; SphereMapMatrixD3D8._12 = 0.0f; - SphereMapMatrixD3D8._13 = 0.0f; SphereMapMatrixD3D8._14 = 0.0f; - SphereMapMatrixD3D8._21 = 0.0f; SphereMapMatrixD3D8._22 =-0.5f; - SphereMapMatrixD3D8._23 = 0.0f; SphereMapMatrixD3D8._24 = 0.0f; - SphereMapMatrixD3D8._31 = 0.0f; SphereMapMatrixD3D8._32 = 0.0f; - SphereMapMatrixD3D8._33 = 1.0f; SphereMapMatrixD3D8._34 = 0.0f; - SphereMapMatrixD3D8._41 = 0.5f; SphereMapMatrixD3D8._42 = 0.5f; - SphereMapMatrixD3D8._43 = 0.0f; SphereMapMatrixD3D8._44 = 1.0f; - - UnitMatrixD3D8 = *(D3DMATRIX*)((void*)core::IdentityMatrix.pointer()); - - // init direct 3d is done in the factory function -} - - -//! destructor -CD3D8Driver::~CD3D8Driver() -{ - deleteMaterialRenders(); - - // drop d3d8 - - if (pID3DDevice) - pID3DDevice->Release(); - - if (pID3D) - pID3D->Release(); -} - - -void CD3D8Driver::createMaterialRenderers() -{ - // create D3D8 material renderers - - addAndDropMaterialRenderer(new CD3D8MaterialRenderer_SOLID(pID3DDevice, this)); - addAndDropMaterialRenderer(new CD3D8MaterialRenderer_SOLID_2_LAYER(pID3DDevice, this)); - - // add the same renderer for all lightmap types - CD3D8MaterialRenderer_LIGHTMAP* lmr = new CD3D8MaterialRenderer_LIGHTMAP(pID3DDevice, this); - addMaterialRenderer(lmr); // for EMT_LIGHTMAP: - addMaterialRenderer(lmr); // for EMT_LIGHTMAP_ADD: - addMaterialRenderer(lmr); // for EMT_LIGHTMAP_M2: - addMaterialRenderer(lmr); // for EMT_LIGHTMAP_M4: - addMaterialRenderer(lmr); // for EMT_LIGHTMAP_LIGHTING: - addMaterialRenderer(lmr); // for EMT_LIGHTMAP_LIGHTING_M2: - addMaterialRenderer(lmr); // for EMT_LIGHTMAP_LIGHTING_M4: - lmr->drop(); - - // add remaining material renderers - addAndDropMaterialRenderer(new CD3D8MaterialRenderer_DETAIL_MAP(pID3DDevice, this)); - addAndDropMaterialRenderer(new CD3D8MaterialRenderer_SPHERE_MAP(pID3DDevice, this)); - addAndDropMaterialRenderer(new CD3D8MaterialRenderer_REFLECTION_2_LAYER(pID3DDevice, this)); - addAndDropMaterialRenderer(new CD3D8MaterialRenderer_TRANSPARENT_ADD_COLOR(pID3DDevice, this)); - addAndDropMaterialRenderer(new CD3D8MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL(pID3DDevice, this)); - addAndDropMaterialRenderer(new CD3D8MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF(pID3DDevice, this)); - addAndDropMaterialRenderer(new CD3D8MaterialRenderer_TRANSPARENT_VERTEX_ALPHA(pID3DDevice, this)); - addAndDropMaterialRenderer(new CD3D8MaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER(pID3DDevice, this)); - - // add normal map renderers - s32 tmp = 0; - video::IMaterialRenderer* renderer = 0; - - renderer = new CD3D8NormalMapRenderer(pID3DDevice, this, tmp, - MaterialRenderers[EMT_SOLID].Renderer); - renderer->drop(); - - renderer = new CD3D8NormalMapRenderer(pID3DDevice, this, tmp, - MaterialRenderers[EMT_TRANSPARENT_ADD_COLOR].Renderer); - renderer->drop(); - - renderer = new CD3D8NormalMapRenderer(pID3DDevice, this, tmp, - MaterialRenderers[EMT_TRANSPARENT_VERTEX_ALPHA].Renderer); - renderer->drop(); - - // add parallax map renderers - - renderer = new CD3D8ParallaxMapRenderer(pID3DDevice, this, tmp, - MaterialRenderers[EMT_SOLID].Renderer); - renderer->drop(); - - renderer = new CD3D8ParallaxMapRenderer(pID3DDevice, this, tmp, - MaterialRenderers[EMT_TRANSPARENT_ADD_COLOR].Renderer); - renderer->drop(); - - renderer = new CD3D8ParallaxMapRenderer(pID3DDevice, this, tmp, - MaterialRenderers[EMT_TRANSPARENT_VERTEX_ALPHA].Renderer); - renderer->drop(); - - // add basic 1 texture blending - addAndDropMaterialRenderer(new CD3D8MaterialRenderer_ONETEXTURE_BLEND(pID3DDevice, this)); -} - - -//! initialises the Direct3D API -bool CD3D8Driver::initDriver(const core::dimension2d<u32>& screenSize, - HWND hwnd, u32 bits, bool fullScreen, bool pureSoftware, - bool highPrecisionFPU, bool vsync, u8 antiAlias) -{ - HRESULT hr; - typedef IDirect3D8 * (__stdcall *D3DCREATETYPE)(UINT); - -#if defined( _IRR_XBOX_PLATFORM_) - D3DCREATETYPE d3dCreate = (D3DCREATETYPE) &Direct3DCreate8; -#else - D3DLibrary = LoadLibrary( "d3d8.dll" ); - - if (!D3DLibrary) - { - os::Printer::log("Error, could not load d3d8.dll.", ELL_ERROR); - return false; - } - - D3DCREATETYPE d3dCreate = (D3DCREATETYPE) GetProcAddress(D3DLibrary, "Direct3DCreate8"); - - if (!d3dCreate) - { - os::Printer::log("Error, could not get proc adress of Direct3DCreate8.", ELL_ERROR); - return false; - } -#endif - - //just like pID3D = Direct3DCreate8(D3D_SDK_VERSION); - pID3D = (*d3dCreate)(D3D_SDK_VERSION); - - if (!pID3D) - { - os::Printer::log("Error initializing D3D.", ELL_ERROR); - return false; - } - - // print device information - D3DADAPTER_IDENTIFIER8 dai; - if (!FAILED(pID3D->GetAdapterIdentifier(D3DADAPTER_DEFAULT, D3DENUM_NO_WHQL_LEVEL, &dai))) - { - char tmp[512]; - - s32 Product = HIWORD(dai.DriverVersion.HighPart); - s32 Version = LOWORD(dai.DriverVersion.HighPart); - s32 SubVersion = HIWORD(dai.DriverVersion.LowPart); - s32 Build = LOWORD(dai.DriverVersion.LowPart); - - sprintf(tmp, "%s %s %d.%d.%d.%d", dai.Description, dai.Driver, Product, Version, - SubVersion, Build); - os::Printer::log(tmp, ELL_INFORMATION); - } - - D3DDISPLAYMODE d3ddm; - hr = pID3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm); - if (FAILED(hr)) - { - os::Printer::log("Error: Could not get Adapter Display mode.", ELL_ERROR); - return false; - } - - ZeroMemory(&present, sizeof(present)); - - present.SwapEffect = D3DSWAPEFFECT_DISCARD; - present.Windowed = TRUE; - present.BackBufferFormat = d3ddm.Format; - present.EnableAutoDepthStencil = TRUE; - - if (fullScreen) - { - present.SwapEffect = D3DSWAPEFFECT_FLIP; - present.Windowed = FALSE; - present.BackBufferWidth = screenSize.Width; - present.BackBufferHeight = screenSize.Height; - present.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; - present.FullScreen_PresentationInterval = vsync ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE; - - if (bits == 32) - present.BackBufferFormat = D3DFMT_X8R8G8B8; - else - present.BackBufferFormat = D3DFMT_R5G6B5; - } - - D3DDEVTYPE devtype = D3DDEVTYPE_HAL; - #ifndef _IRR_D3D_NO_SHADER_DEBUGGING - devtype = D3DDEVTYPE_REF; - #endif - - // enable anti alias if possible and whished - if (antiAlias > 0) - { - if(antiAlias > 16) - antiAlias = 16; - - while(antiAlias > 0) - { - if(!FAILED(pID3D->CheckDeviceMultiSampleType(D3DADAPTER_DEFAULT, - devtype , present.BackBufferFormat, !fullScreen, - (D3DMULTISAMPLE_TYPE)antiAlias))) - { - present.MultiSampleType = (D3DMULTISAMPLE_TYPE)antiAlias; - present.SwapEffect = D3DSWAPEFFECT_DISCARD; - break; - } - --antiAlias; - } - - if(antiAlias==0) - os::Printer::log("Anti aliasing disabled because hardware/driver lacks necessary caps.", ELL_WARNING); - } - - // check stencil buffer compatibility - if (StencilBuffer) - { - present.AutoDepthStencilFormat = D3DFMT_D24S8; - if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype, - present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, - D3DRTYPE_SURFACE, present.AutoDepthStencilFormat))) - { -#if !defined( _IRR_XBOX_PLATFORM_) - present.AutoDepthStencilFormat = D3DFMT_D24X4S4; - if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype, - present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, - D3DRTYPE_SURFACE, present.AutoDepthStencilFormat))) - { - present.AutoDepthStencilFormat = D3DFMT_D15S1; - if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype, - present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, - D3DRTYPE_SURFACE, present.AutoDepthStencilFormat))) - { - os::Printer::log("Device does not support stencilbuffer, disabling stencil buffer.", ELL_WARNING); - StencilBuffer = false; - } - } -#endif - } - else - if(FAILED(pID3D->CheckDepthStencilMatch(D3DADAPTER_DEFAULT, devtype, - present.BackBufferFormat, present.BackBufferFormat, present.AutoDepthStencilFormat))) - { - os::Printer::log("Depth-stencil format is not compatible with display format, disabling stencil buffer.", ELL_WARNING); - StencilBuffer = false; - } - } - // do not use else here to cope with flag change in previous block - if (!StencilBuffer) - { -#if !defined( _IRR_XBOX_PLATFORM_) - present.AutoDepthStencilFormat = D3DFMT_D32; - if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype, - present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, - D3DRTYPE_SURFACE, present.AutoDepthStencilFormat))) - { - present.AutoDepthStencilFormat = D3DFMT_D24X8; - if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype, - present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, - D3DRTYPE_SURFACE, present.AutoDepthStencilFormat))) - { - present.AutoDepthStencilFormat = D3DFMT_D16; - if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype, - present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, - D3DRTYPE_SURFACE, present.AutoDepthStencilFormat))) - { - os::Printer::log("Device does not support required depth buffer.", ELL_WARNING); - return false; - } - } - } -#else - present.AutoDepthStencilFormat = D3DFMT_D16; - if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype, - present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, - D3DRTYPE_SURFACE, present.AutoDepthStencilFormat))) - { - os::Printer::log("Device does not support required depth buffer.", ELL_WARNING); - return false; - } -#endif - } - - // create device -#if defined( _IRR_XBOX_PLATFORM_) - DWORD fpuPrecision = 0; -#else - DWORD fpuPrecision = highPrecisionFPU ? D3DCREATE_FPU_PRESERVE : 0; -#endif - if (pureSoftware) - { - hr = pID3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_REF, hwnd, - fpuPrecision | D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present, &pID3DDevice); - - if (FAILED(hr)) - os::Printer::log("Was not able to create Direct3D8 software device.", ELL_ERROR); - } - else - { - hr = pID3D->CreateDevice(D3DADAPTER_DEFAULT, devtype, hwnd, - fpuPrecision | D3DCREATE_HARDWARE_VERTEXPROCESSING, &present, &pID3DDevice); - - if(FAILED(hr)) - hr = pID3D->CreateDevice(D3DADAPTER_DEFAULT, devtype, hwnd, - fpuPrecision | D3DCREATE_MIXED_VERTEXPROCESSING , &present, &pID3DDevice); - if(FAILED(hr)) - hr = pID3D->CreateDevice(D3DADAPTER_DEFAULT, devtype, hwnd, - fpuPrecision | D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present, &pID3DDevice); - if (FAILED(hr)) - os::Printer::log("Was not able to create Direct3D8 device.", ELL_ERROR); - } - - if (!pID3DDevice) - { - os::Printer::log("Was not able to create Direct3D8 device.", ELL_ERROR); - return false; - } - - // get caps - pID3DDevice->GetDeviceCaps(&Caps); - - if (StencilBuffer && - (!(Caps.StencilCaps & D3DSTENCILCAPS_DECRSAT) || - !(Caps.StencilCaps & D3DSTENCILCAPS_INCRSAT) || - !(Caps.StencilCaps & D3DSTENCILCAPS_KEEP))) - { - os::Printer::log("Device not able to use stencil buffer, disabling stencil buffer.", ELL_WARNING); - StencilBuffer = false; - } - - // set default vertex shader - setVertexShader(EVT_STANDARD); - - // enable antialiasing - if (antiAlias>0) - pID3DDevice->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, TRUE); - - // set fog mode - setFog(FogColor, FogType, FogStart, FogEnd, FogDensity, PixelFog, RangeFog); - - // set exposed data - ExposedData.D3D8.D3D8 = pID3D; - ExposedData.D3D8.D3DDev8 = pID3DDevice; - ExposedData.D3D8.HWnd = hwnd; - - ResetRenderStates = true; - - // create materials - createMaterialRenderers(); - - MaxTextureUnits = core::min_((u32)Caps.MaxSimultaneousTextures, MATERIAL_MAX_TEXTURES); - MaxUserClipPlanes = (u32)Caps.MaxUserClipPlanes; - - // set the renderstates - setRenderStates3DMode(); - - // so far so good. - return true; -} - - -//! applications must call this method before performing any rendering. returns false if failed. -bool CD3D8Driver::beginScene(bool backBuffer, bool zBuffer, SColor color, - void* windowId, core::rect<s32>* sourceRect) -{ - CNullDriver::beginScene(backBuffer, zBuffer, color, windowId, sourceRect); - WindowId = windowId; - SceneSourceRect = sourceRect; - - if (!pID3DDevice) - return false; - - HRESULT hr; - if (DeviceLost) - { -#if defined( _IRR_XBOX_PLATFORM_) -#else - if(FAILED(hr = pID3DDevice->TestCooperativeLevel())) - { - if (hr == D3DERR_DEVICELOST) - { - Sleep(100); - hr = pID3DDevice->TestCooperativeLevel(); - if (hr == D3DERR_DEVICELOST) - return false; - } - - if ((hr == D3DERR_DEVICENOTRESET) && !reset()) - return false; - } -#endif - } - - DWORD flags = 0; - - if (backBuffer) - flags |= D3DCLEAR_TARGET; - - if (zBuffer) - flags |= D3DCLEAR_ZBUFFER; - - if (StencilBuffer) - flags |= D3DCLEAR_STENCIL; - - hr = pID3DDevice->Clear( 0, NULL, flags, color.color, 1.0, 0); - if (FAILED(hr)) - os::Printer::log("Direct3D8 clear failed.", ELL_WARNING); - - hr = pID3DDevice->BeginScene(); - if (FAILED(hr)) - { - os::Printer::log("Direct3D8 begin scene failed.", ELL_WARNING); - return false; - } - - return true; -} - - -//! applications must call this method after performing any rendering. returns false if failed. -bool CD3D8Driver::endScene() -{ - CNullDriver::endScene(); - DriverWasReset=false; - - HRESULT hr = pID3DDevice->EndScene(); - if (FAILED(hr)) - { - os::Printer::log("DIRECT3D8 end scene failed.", ELL_WARNING); - return false; - } - - RECT* srcRct = 0; - RECT sourceRectData; - if ( SceneSourceRect) - { - srcRct = &sourceRectData; - sourceRectData.left = SceneSourceRect->UpperLeftCorner.X; - sourceRectData.top = SceneSourceRect->UpperLeftCorner.Y; - sourceRectData.right = SceneSourceRect->LowerRightCorner.X; - sourceRectData.bottom = SceneSourceRect->LowerRightCorner.Y; - } - - hr = pID3DDevice->Present(srcRct, NULL, (HWND)WindowId, NULL); - - if (SUCCEEDED(hr)) - return true; - - if (hr == D3DERR_DEVICELOST) - { - DeviceLost = true; - os::Printer::log("DIRECT3D8 device lost.", ELL_WARNING); - } - else - os::Printer::log("DIRECT3D8 present failed.", ELL_WARNING); - return false; -} - - -//! resets the device -bool CD3D8Driver::reset() -{ - u32 i; - os::Printer::log("Resetting D3D8 device.", ELL_INFORMATION); - - for (i=0; i<Textures.size(); ++i) - { - if (Textures[i].Surface->isRenderTarget()) - { - IDirect3DTexture8* tex = ((CD3D8Texture*)(Textures[i].Surface))->getDX8Texture(); - if (tex) - tex->Release(); - } - } - DriverWasReset=true; - - HRESULT hr = pID3DDevice->Reset(&present); - - for (i=0; i<Textures.size(); ++i) - { - if (Textures[i].Surface->isRenderTarget()) - ((CD3D8Texture*)(Textures[i].Surface))->createRenderTarget(); - } - - if (FAILED(hr)) - { - if (hr == D3DERR_DEVICELOST) - { - DeviceLost = true; - os::Printer::log("Resetting failed due to device lost.", ELL_WARNING); - } - else - os::Printer::log("Resetting failed.", ELL_WARNING); - return false; - } - - DeviceLost = false; - ResetRenderStates = true; - LastVertexType = (E_VERTEX_TYPE)-1; - - for (i=0; i<MATERIAL_MAX_TEXTURES; ++i) - CurrentTexture[i] = 0; - - setVertexShader(EVT_STANDARD); - setRenderStates3DMode(); - setFog(FogColor, FogType, FogStart, FogEnd, FogDensity, PixelFog, RangeFog); - setAmbientLight(AmbientLight); - - return true; -} - - -//! queries the features of the driver, returns true if feature is available -bool CD3D8Driver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const -{ - if (!FeatureEnabled[feature]) - return false; - - switch (feature) - { - case EVDF_RENDER_TO_TARGET: - case EVDF_MULTITEXTURE: - case EVDF_BILINEAR_FILTER: - return true; - case EVDF_HARDWARE_TL: - return (Caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) != 0; - case EVDF_MIP_MAP: - return (Caps.TextureCaps & D3DPTEXTURECAPS_MIPMAP) != 0; - case EVDF_STENCIL_BUFFER: - return StencilBuffer && Caps.StencilCaps; - case EVDF_VERTEX_SHADER_1_1: - return Caps.VertexShaderVersion >= D3DVS_VERSION(1,1); - case EVDF_VERTEX_SHADER_2_0: - return Caps.VertexShaderVersion >= D3DVS_VERSION(2,0); - case EVDF_VERTEX_SHADER_3_0: - return Caps.VertexShaderVersion >= D3DVS_VERSION(3,0); - case EVDF_PIXEL_SHADER_1_1: - return Caps.PixelShaderVersion >= D3DPS_VERSION(1,1); - case EVDF_PIXEL_SHADER_1_2: - return Caps.PixelShaderVersion >= D3DPS_VERSION(1,2); - case EVDF_PIXEL_SHADER_1_3: - return Caps.PixelShaderVersion >= D3DPS_VERSION(1,3); - case EVDF_PIXEL_SHADER_1_4: - return Caps.PixelShaderVersion >= D3DPS_VERSION(1,4); - case EVDF_PIXEL_SHADER_2_0: - return Caps.PixelShaderVersion >= D3DPS_VERSION(2,0); - case EVDF_PIXEL_SHADER_3_0: - return Caps.PixelShaderVersion >= D3DPS_VERSION(3,0); - case EVDF_TEXTURE_NSQUARE: - return (Caps.TextureCaps & D3DPTEXTURECAPS_SQUAREONLY) == 0; - case EVDF_TEXTURE_NPOT: - return (Caps.TextureCaps & D3DPTEXTURECAPS_POW2) == 0; - case EVDF_COLOR_MASK: - return (Caps.PrimitiveMiscCaps & D3DPMISCCAPS_COLORWRITEENABLE) != 0; - default: - return false; - }; -} - - -//! sets transformation -void CD3D8Driver::setTransform(E_TRANSFORMATION_STATE state, - const core::matrix4& mat) -{ - switch(state) - { - case ETS_VIEW: - pID3DDevice->SetTransform(D3DTS_VIEW, (D3DMATRIX*)((void*)mat.pointer())); - Transformation3DChanged = true; - break; - case ETS_WORLD: - pID3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX*)((void*)mat.pointer())); - Transformation3DChanged = true; - break; - case ETS_PROJECTION: - pID3DDevice->SetTransform( D3DTS_PROJECTION, (D3DMATRIX*)((void*)mat.pointer())); - Transformation3DChanged = true; - break; - case ETS_COUNT: - return; - default: - if (state-ETS_TEXTURE_0 < MATERIAL_MAX_TEXTURES) - { - pID3DDevice->SetTextureStageState( state - ETS_TEXTURE_0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 ); - pID3DDevice->SetTransform((D3DTRANSFORMSTATETYPE)(D3DTS_TEXTURE0+ ( state - ETS_TEXTURE_0 )), - (D3DMATRIX*)((void*)mat.pointer())); - } - break; - } - - Matrices[state] = mat; -} - - -//! sets the current Texture -bool CD3D8Driver::setActiveTexture(u32 stage, const video::ITexture* texture) -{ - if (CurrentTexture[stage] == texture) - return true; - - if (texture && (texture->getDriverType() != EDT_DIRECT3D8)) - { - os::Printer::log("Fatal Error: Tried to set a texture not owned by this driver.", ELL_ERROR); - return false; - } - - CurrentTexture[stage] = texture; - - if (!texture) - { - pID3DDevice->SetTexture(stage, 0); - pID3DDevice->SetTextureStageState( stage, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE ); - } - else - { - pID3DDevice->SetTexture(stage, ((const CD3D8Texture*)texture)->getDX8Texture()); - } - return true; -} - - -//! sets a material -void CD3D8Driver::setMaterial(const SMaterial& material) -{ - Material = material; - OverrideMaterial.apply(Material); - - for (u32 i=0; i<MaxTextureUnits; ++i) - { - setActiveTexture(i, Material.getTexture(i)); - setTransform((E_TRANSFORMATION_STATE) ( ETS_TEXTURE_0 + i ), - material.getTextureMatrix(i)); - } -} - - -//! returns a device dependent texture from a software surface (IImage) -video::ITexture* CD3D8Driver::createDeviceDependentTexture(IImage* surface,const io::path& name) -{ - return new CD3D8Texture(surface, this, TextureCreationFlags, name); -} - - -//! Enables or disables a texture creation flag. -void CD3D8Driver::setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, - bool enabled) -{ - if (flag == video::ETCF_CREATE_MIP_MAPS && !queryFeature(EVDF_MIP_MAP)) - enabled = false; - - CNullDriver::setTextureCreationFlag(flag, enabled); -} - - -//! sets a render target -bool CD3D8Driver::setRenderTarget(video::ITexture* texture, - bool clearBackBuffer, bool clearZBuffer, SColor color) -{ - // check for right driver type - - if (texture && texture->getDriverType() != EDT_DIRECT3D8) - { - os::Printer::log("Fatal Error: Tried to set a texture not owned by this driver.", ELL_ERROR); - return false; - } - - // check for valid render target - - CD3D8Texture* tex = (CD3D8Texture*)texture; - - if (texture && !tex->isRenderTarget()) - { - os::Printer::log("Fatal Error: Tried to set a non render target texture as render target.", ELL_ERROR); - return false; - } - - if (texture && (tex->getSize().Width > ScreenSize.Width || - tex->getSize().Height > ScreenSize.Height )) - { - os::Printer::log("Error: Tried to set a render target texture which is bigger than the screen.", ELL_ERROR); - return false; - } - - // check if we should set the previous RT back - - bool ret = true; - - if (tex == 0) - { - if (PrevRenderTarget) - { - IDirect3DSurface8* dss = 0; - pID3DDevice->GetDepthStencilSurface(&dss); - - if (FAILED(pID3DDevice->SetRenderTarget(PrevRenderTarget, dss))) - { - os::Printer::log("Error: Could not set back to previous render target.", ELL_ERROR); - ret = false; - } - - if (dss) - dss->Release(); - - CurrentRendertargetSize = core::dimension2d<u32>(0,0); - PrevRenderTarget->Release(); - PrevRenderTarget = 0; - } - } - else - { - // we want to set a new target. so do this. - - // store previous target - - if (!PrevRenderTarget && (FAILED(pID3DDevice->GetRenderTarget(&PrevRenderTarget)))) - { - os::Printer::log("Could not get previous render target.", ELL_ERROR); - return false; - } - - // set new render target - - IDirect3DSurface8* dss = 0; - pID3DDevice->GetDepthStencilSurface(&dss); - - if (FAILED(pID3DDevice->SetRenderTarget(tex->getRenderTargetSurface(), dss))) - { - os::Printer::log("Error: Could not set render target.", ELL_ERROR); - ret = false; - } - - if (dss) - dss->Release(); - - CurrentRendertargetSize = tex->getSize(); - } - - if (clearBackBuffer || clearZBuffer) - { - DWORD flags = 0; - - if (clearBackBuffer) - flags |= D3DCLEAR_TARGET; - - if (clearZBuffer) - flags |= D3DCLEAR_ZBUFFER; - - pID3DDevice->Clear(0, NULL, flags, color.color, 1.0f, 0); - } - - return ret; -} - - -//! Creates a render target texture. -ITexture* CD3D8Driver::addRenderTargetTexture(const core::dimension2d<u32>& size, - const io::path& name, - const ECOLOR_FORMAT format) -{ - ITexture* tex = new CD3D8Texture(this, size, name); - addTexture(tex); - tex->drop(); - return tex; -} - - -//! sets a viewport -void CD3D8Driver::setViewPort(const core::rect<s32>& area) -{ - core::rect<s32> vp(area); - core::rect<s32> rendert(0,0, ScreenSize.Width, ScreenSize.Height); - vp.clipAgainst(rendert); - - D3DVIEWPORT8 viewPort; - viewPort.X = vp.UpperLeftCorner.X; - viewPort.Y = vp.UpperLeftCorner.Y; - viewPort.Width = vp.getWidth(); - viewPort.Height = vp.getHeight(); - viewPort.MinZ = 0.0f; - viewPort.MaxZ = 1.0f; - - HRESULT hr = D3DERR_INVALIDCALL; - if (vp.getHeight()>0 && vp.getWidth()>0) - hr = pID3DDevice->SetViewport(&viewPort); - - if (FAILED(hr)) - os::Printer::log("Failed setting the viewport.", ELL_WARNING); - - ViewPort = vp; -} - - -//! gets the area of the current viewport -const core::rect<s32>& CD3D8Driver::getViewPort() const -{ - return ViewPort; -} - - -//! draws a vertex primitive list -void CD3D8Driver::drawVertexPrimitiveList(const void* vertices, - u32 vertexCount, const void* indexList, u32 primitiveCount, - E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, - E_INDEX_TYPE iType) -{ - if (!checkPrimitiveCount(primitiveCount)) - return; - - CNullDriver::drawVertexPrimitiveList(vertices, vertexCount, indexList, primitiveCount, vType, pType,iType); - - if (!vertexCount || !primitiveCount) - return; - - draw2D3DVertexPrimitiveList(vertices, vertexCount, indexList, primitiveCount, - vType, pType, iType, true); -} - - -//! draws a vertex primitive list in 2d -void CD3D8Driver::draw2DVertexPrimitiveList(const void* vertices, - u32 vertexCount, const void* indexList, u32 primitiveCount, - E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, - E_INDEX_TYPE iType) -{ - if (!checkPrimitiveCount(primitiveCount)) - return; - - CNullDriver::draw2DVertexPrimitiveList(vertices, vertexCount, indexList, primitiveCount, vType, pType,iType); - - if (!vertexCount || !primitiveCount) - return; - - draw2D3DVertexPrimitiveList(vertices, vertexCount, indexList, primitiveCount, - vType, pType, iType, false); -} - - -void CD3D8Driver::draw2D3DVertexPrimitiveList(const void* vertices, - u32 vertexCount, const void* indexList, u32 primitiveCount, - E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, - E_INDEX_TYPE iType, bool is3D) -{ - setVertexShader(vType); - - const u32 stride = getVertexPitchFromType(vType); - - D3DFORMAT indexType=D3DFMT_UNKNOWN; - switch (iType) - { - case (EIT_16BIT): - { - indexType=D3DFMT_INDEX16; - break; - } - case (EIT_32BIT): - { - indexType=D3DFMT_INDEX32; - break; - } - } - - if (is3D) - { - if (!setRenderStates3DMode()) - return; - } - else - setRenderStates2DMode(true, (Material.getTexture(0) != 0), true); - - switch (pType) - { - case scene::EPT_POINT_SPRITES: - case scene::EPT_POINTS: - { - f32 tmp=Material.Thickness/getScreenSize().Height; - if (pType==scene::EPT_POINT_SPRITES) - pID3DDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_POINTSCALEENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_POINTSIZE, *(DWORD*)(&tmp)); - tmp=1.0f; - pID3DDevice->SetRenderState(D3DRS_POINTSCALE_A, *(DWORD*)(&tmp)); - pID3DDevice->SetRenderState(D3DRS_POINTSCALE_B, *(DWORD*)(&tmp)); - pID3DDevice->SetRenderState(D3DRS_POINTSIZE_MIN, *(DWORD*)(&tmp)); - tmp=0.0f; - pID3DDevice->SetRenderState(D3DRS_POINTSCALE_C, *(DWORD*)(&tmp)); - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_POINTLIST, 0, vertexCount, - primitiveCount, indexList, indexType, vertices, stride); - pID3DDevice->SetRenderState(D3DRS_POINTSCALEENABLE, FALSE); - if (pType==scene::EPT_POINT_SPRITES) - pID3DDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, FALSE); - } - break; - case scene::EPT_LINE_STRIP: - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINESTRIP, 0, vertexCount, - primitiveCount, indexList, indexType, vertices, stride); - break; - case scene::EPT_LINE_LOOP: - { - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINESTRIP, 0, vertexCount, - primitiveCount, indexList, indexType, vertices, stride); - u16 tmpIndices[] = {0, primitiveCount}; - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINELIST, 0, vertexCount, - 1, tmpIndices, indexType, vertices, stride); - } - break; - case scene::EPT_LINES: - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINELIST, 0, vertexCount, - primitiveCount, indexList, indexType, vertices, stride); - break; - case scene::EPT_TRIANGLE_STRIP: - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLESTRIP, 0, vertexCount, - primitiveCount, indexList, indexType, vertices, stride); - break; - case scene::EPT_TRIANGLE_FAN: - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLEFAN, 0, vertexCount, - primitiveCount, indexList, indexType, vertices, stride); - break; - case scene::EPT_TRIANGLES: - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, vertexCount, - primitiveCount, indexList, indexType, vertices, stride); - break; - } -} - - -//! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. -void CD3D8Driver::draw2DImage(const video::ITexture* texture, - const core::position2d<s32>& pos, - const core::rect<s32>& sourceRect, - const core::rect<s32>* clipRect, SColor color, - bool useAlphaChannelOfTexture) -{ - if (!texture) - return; - - if (!sourceRect.isValid()) - return; - - if (!setActiveTexture(0, texture)) - return; - - core::position2d<s32> targetPos = pos; - core::position2d<s32> sourcePos = sourceRect.UpperLeftCorner; - // This needs to be signed as it may go negative. - core::dimension2d<s32> sourceSize(sourceRect.getSize()); - const core::dimension2d<u32>& renderTargetSize = getCurrentRenderTargetSize(); - - if (clipRect) - { - if (targetPos.X < clipRect->UpperLeftCorner.X) - { - sourceSize.Width += targetPos.X - clipRect->UpperLeftCorner.X; - if (sourceSize.Width <= 0) - return; - - sourcePos.X -= targetPos.X - clipRect->UpperLeftCorner.X; - targetPos.X = clipRect->UpperLeftCorner.X; - } - - if (targetPos.X + (s32)sourceSize.Width > clipRect->LowerRightCorner.X) - { - sourceSize.Width -= (targetPos.X + sourceSize.Width) - clipRect->LowerRightCorner.X; - if (sourceSize.Width <= 0) - return; - } - - if (targetPos.Y < clipRect->UpperLeftCorner.Y) - { - sourceSize.Height += targetPos.Y - clipRect->UpperLeftCorner.Y; - if (sourceSize.Height <= 0) - return; - - sourcePos.Y -= targetPos.Y - clipRect->UpperLeftCorner.Y; - targetPos.Y = clipRect->UpperLeftCorner.Y; - } - - if (targetPos.Y + (s32)sourceSize.Height > clipRect->LowerRightCorner.Y) - { - sourceSize.Height -= (targetPos.Y + sourceSize.Height) - clipRect->LowerRightCorner.Y; - if (sourceSize.Height <= 0) - return; - } - } - - // clip these coordinates - - if (targetPos.X<0) - { - sourceSize.Width += targetPos.X; - if (sourceSize.Width <= 0) - return; - - sourcePos.X -= targetPos.X; - targetPos.X = 0; - } - - if (targetPos.X + sourceSize.Width > (s32)renderTargetSize.Width) - { - sourceSize.Width -= (targetPos.X + sourceSize.Width) - renderTargetSize.Width; - if (sourceSize.Width <= 0) - return; - } - - if (targetPos.Y<0) - { - sourceSize.Height += targetPos.Y; - if (sourceSize.Height <= 0) - return; - - sourcePos.Y -= targetPos.Y; - targetPos.Y = 0; - } - - if (targetPos.Y + sourceSize.Height > (s32)renderTargetSize.Height) - { - sourceSize.Height -= (targetPos.Y + sourceSize.Height) - renderTargetSize.Height; - if (sourceSize.Height <= 0) - return; - } - - // ok, we've clipped everything. - // now draw it. - - core::rect<f32> tcoords; - tcoords.UpperLeftCorner.X = (f32)sourcePos.X / texture->getOriginalSize().Width ; - tcoords.UpperLeftCorner.Y = (f32)sourcePos.Y / texture->getOriginalSize().Height; - tcoords.LowerRightCorner.X = tcoords.UpperLeftCorner.X + (f32)sourceSize.Width / texture->getOriginalSize().Width; - tcoords.LowerRightCorner.Y = tcoords.UpperLeftCorner.Y + (f32)sourceSize.Height / texture->getOriginalSize().Height; - - const core::rect<s32> poss(targetPos, sourceSize); - - setRenderStates2DMode(color.getAlpha()<255, true, useAlphaChannelOfTexture); - - S3DVertex vtx[4]; - vtx[0] = S3DVertex((f32)poss.UpperLeftCorner.X, - (f32)poss.UpperLeftCorner.Y, 0.0f, - 0.0f, 0.0f, 0.0f, color, - tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y); - vtx[1] = S3DVertex((f32)poss.LowerRightCorner.X, - (f32)poss.UpperLeftCorner.Y, 0.0f, - 0.0f, 0.0f, 0.0f, color, - tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y); - vtx[2] = S3DVertex((f32)poss.LowerRightCorner.X, - (f32)poss.LowerRightCorner.Y, 0.0f, - 0.0f, 0.0f, 0.0f, color, - tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y); - vtx[3] = S3DVertex((f32)poss.UpperLeftCorner.X, - (f32)poss.LowerRightCorner.Y, 0.0f, - 0.0f, 0.0f, 0.0f, color, - tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y); - - const s16 indices[6] = {0,1,2,0,2,3}; - - setVertexShader(EVT_STANDARD); - - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, &indices[0], - D3DFMT_INDEX16, &vtx[0], sizeof(S3DVertex)); -} - - -void CD3D8Driver::draw2DImage(const video::ITexture* texture, - const core::rect<s32>& destRect, - const core::rect<s32>& sourceRect, - const core::rect<s32>* clipRect, - const video::SColor* const colors, - bool useAlphaChannelOfTexture) -{ - if(!texture) - return; - - const core::dimension2d<u32>& ss = texture->getOriginalSize(); - core::rect<f32> tcoords; - tcoords.UpperLeftCorner.X = (f32)sourceRect.UpperLeftCorner.X / (f32)ss.Width; - tcoords.UpperLeftCorner.Y = (f32)sourceRect.UpperLeftCorner.Y / (f32)ss.Height; - tcoords.LowerRightCorner.X = (f32)sourceRect.LowerRightCorner.X / (f32)ss.Width; - tcoords.LowerRightCorner.Y = (f32)sourceRect.LowerRightCorner.Y / (f32)ss.Height; - - core::rect<s32> clippedRect(destRect); - if (clipRect) - { - clippedRect.clipAgainst(*clipRect); - - //tcoords must be clipped by the same factors - const f32 tcWidth = tcoords.getWidth(); - const f32 tcHeight = tcoords.getHeight(); - - const f32 invDestRectWidth = 1.f / (f32)(destRect.getWidth()); - f32 scale = (f32)(clippedRect.UpperLeftCorner.X - destRect.UpperLeftCorner.X) * invDestRectWidth; - tcoords.UpperLeftCorner.X += scale * tcWidth; - scale = (f32)(destRect.LowerRightCorner.X - clippedRect.LowerRightCorner.X) * invDestRectWidth; - tcoords.LowerRightCorner.X -= scale * tcWidth; - - const f32 invDestRectHeight = 1.f / (f32)(destRect.getHeight()); - scale = (f32)(clippedRect.UpperLeftCorner.Y - destRect.UpperLeftCorner.Y) * invDestRectHeight; - tcoords.UpperLeftCorner.Y += scale * tcHeight; - scale = (f32)(destRect.LowerRightCorner.Y - clippedRect.LowerRightCorner.Y) * invDestRectHeight; - tcoords.LowerRightCorner.Y -= scale * tcHeight; - } - - const video::SColor temp[4] = - { - 0xFFFFFFFF, - 0xFFFFFFFF, - 0xFFFFFFFF, - 0xFFFFFFFF - }; - - const video::SColor* const useColor = colors ? colors : temp; - - S3DVertex vtx[4]; // clock wise - vtx[0] = S3DVertex((f32)clippedRect.UpperLeftCorner.X, (f32)clippedRect.UpperLeftCorner.Y, 0.0f, - 0.0f, 0.0f, 0.0f, useColor[0], - tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y); - vtx[1] = S3DVertex((f32)clippedRect.LowerRightCorner.X, (f32)clippedRect.UpperLeftCorner.Y, 0.0f, - 0.0f, 0.0f, 0.0f, useColor[3], - tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y); - vtx[2] = S3DVertex((f32)clippedRect.LowerRightCorner.X, (f32)clippedRect.LowerRightCorner.Y, 0.0f, - 0.0f, 0.0f, 0.0f, useColor[2], - tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y); - vtx[3] = S3DVertex((f32)clippedRect.UpperLeftCorner.X, (f32)clippedRect.LowerRightCorner.Y, 0.0f, - 0.0f, 0.0f, 0.0f, useColor[1], - tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y); - - const s16 indices[6] = {0,1,2,0,2,3}; - - setRenderStates2DMode(useColor[0].getAlpha()<255 || useColor[1].getAlpha()<255 || - useColor[2].getAlpha()<255 || useColor[3].getAlpha()<255, - true, useAlphaChannelOfTexture); - - setActiveTexture(0, texture); - - setVertexShader(EVT_STANDARD); - - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, &indices[0], - D3DFMT_INDEX16, &vtx[0], sizeof(S3DVertex)); -} - - -//!Draws an 2d rectangle with a gradient. -void CD3D8Driver::draw2DRectangle(const core::rect<s32>& position, - SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, - SColor colorRightDown, const core::rect<s32>* clip) -{ - core::rect<s32> pos(position); - - if (clip) - pos.clipAgainst(*clip); - - if (!pos.isValid()) - return; - - S3DVertex vtx[4]; - vtx[0] = S3DVertex((f32)pos.UpperLeftCorner.X, (f32)pos.UpperLeftCorner.Y, 0.0f, - 0.0f, 0.0f, 0.0f, colorLeftUp, 0.0f, 0.0f); - vtx[1] = S3DVertex((f32)pos.LowerRightCorner.X, (f32)pos.UpperLeftCorner.Y, 0.0f, - 0.0f, 0.0f, 0.0f, colorRightUp, 0.0f, 1.0f); - vtx[2] = S3DVertex((f32)pos.LowerRightCorner.X, (f32)pos.LowerRightCorner.Y, 0.0f, - 0.0f, 0.0f, 0.0f, colorRightDown, 1.0f, 0.0f); - vtx[3] = S3DVertex((f32)pos.UpperLeftCorner.X, (f32)pos.LowerRightCorner.Y, 0.0f, - 0.0f, 0.0f, 0.0f, colorLeftDown, 1.0f, 1.0f); - - const s16 indices[6] = {0,1,2,0,2,3}; - - setRenderStates2DMode( - colorLeftUp.getAlpha() < 255 || - colorRightUp.getAlpha() < 255 || - colorLeftDown.getAlpha() < 255 || - colorRightDown.getAlpha() < 255, false, false); - - setActiveTexture(0,0); - - setVertexShader(EVT_STANDARD); - - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, &indices[0], - D3DFMT_INDEX16, &vtx[0], sizeof(S3DVertex)); -} - - -//! Draws a 2d line. -void CD3D8Driver::draw2DLine(const core::position2d<s32>& start, - const core::position2d<s32>& end, - SColor color) -{ - // thanks to Vash TheStampede who sent in his implementation - S3DVertex vtx[2]; - vtx[0] = S3DVertex((f32)start.X, (f32)start.Y, 0.0f, - 0.0f, 0.0f, 0.0f, // normal - color, 0.0f, 0.0f); // texture - - vtx[1] = S3DVertex((f32)end.X, (f32)end.Y, 0.0f, - 0.0f, 0.0f, 0.0f, - color, 0.0f, 0.0f); - - setRenderStates2DMode(color.getAlpha() < 255, false, false); - setActiveTexture(0,0); - - setVertexShader(EVT_STANDARD); - - pID3DDevice->DrawPrimitiveUP(D3DPT_LINELIST, 1, &vtx[0], sizeof(S3DVertex)); -} - - -//! Draws a pixel -void CD3D8Driver::drawPixel(u32 x, u32 y, const SColor & color) -{ - const core::dimension2d<u32>& renderTargetSize = getCurrentRenderTargetSize(); - if (x > (u32)renderTargetSize.Width || y > (u32)renderTargetSize.Height) - return; - - setRenderStates2DMode(color.getAlpha() < 255, false, false); - setActiveTexture(0,0); - - setVertexShader(EVT_STANDARD); - - S3DVertex vertex((f32)x, (f32)y, 0.f, 0.f, 0.f, 0.f, color, 0.f, 0.f); - - pID3DDevice->DrawPrimitiveUP(D3DPT_POINTLIST, 1, &vertex, sizeof(vertex)); -} - - -//! sets right vertex shader -void CD3D8Driver::setVertexShader(E_VERTEX_TYPE newType) -{ - // Because we don't know if a vertex shader was set in a material instead of a - // fvf, this call cannot be prevented in D3D8. - //if (newType != LastVertexType) - { - LastVertexType = newType; - HRESULT hr = 0; - - switch(newType) - { - case EVT_STANDARD: - hr = pID3DDevice->SetVertexShader(D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX1); - break; - case EVT_2TCOORDS: - hr = pID3DDevice->SetVertexShader(D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX2); - break; - case EVT_TANGENTS: - hr = pID3DDevice->SetVertexShader(D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX3 | - D3DFVF_TEXCOORDSIZE2(0) | // real texture coord - D3DFVF_TEXCOORDSIZE3(1) | // misuse texture coord 2 for tangent - D3DFVF_TEXCOORDSIZE3(2) // misuse texture coord 3 for binormal - ); - break; - } - - if (FAILED(hr)) - { - os::Printer::log("Could not set vertex Shader.", ELL_ERROR); - return; - } - } -} - - -//! sets the needed renderstates -bool CD3D8Driver::setRenderStates3DMode() -{ - if (!pID3DDevice) - return false; - - if (CurrentRenderMode != ERM_3D) - { - // switch back the matrices - pID3DDevice->SetTransform(D3DTS_VIEW, (D3DMATRIX*)((void*)&Matrices[ETS_VIEW])); - pID3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX*)((void*)&Matrices[ETS_WORLD])); - pID3DDevice->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)((void*)&Matrices[ETS_PROJECTION])); - - pID3DDevice->SetRenderState(D3DRS_STENCILENABLE, FALSE); - - ResetRenderStates = true; - } - - if (ResetRenderStates || LastMaterial != Material) - { - // unset old material - - if (CurrentRenderMode == ERM_3D && - LastMaterial.MaterialType != Material.MaterialType && - LastMaterial.MaterialType >= 0 && LastMaterial.MaterialType < (s32)MaterialRenderers.size()) - MaterialRenderers[LastMaterial.MaterialType].Renderer->OnUnsetMaterial(); - - // set new material. - - if (Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) - MaterialRenderers[Material.MaterialType].Renderer->OnSetMaterial( - Material, LastMaterial, ResetRenderStates, this); - } - - bool shaderOK = true; - - if (Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) - shaderOK = MaterialRenderers[Material.MaterialType].Renderer->OnRender(this, LastVertexType); - - LastMaterial = Material; - - ResetRenderStates = false; - - CurrentRenderMode = ERM_3D; - - return shaderOK; -} - - -//! Can be called by an IMaterialRenderer to make its work easier. -void CD3D8Driver::setBasicRenderStates(const SMaterial& material, const SMaterial& lastmaterial, - bool resetAllRenderstates) -{ - if (resetAllRenderstates || - lastmaterial.AmbientColor != material.AmbientColor || - lastmaterial.DiffuseColor != material.DiffuseColor || - lastmaterial.SpecularColor != material.SpecularColor || - lastmaterial.EmissiveColor != material.EmissiveColor || - lastmaterial.Shininess != material.Shininess) - { - D3DMATERIAL8 mat; - mat.Diffuse = colorToD3D(material.DiffuseColor); - mat.Ambient = colorToD3D(material.AmbientColor); - mat.Specular = colorToD3D(material.SpecularColor); - mat.Emissive = colorToD3D(material.EmissiveColor); - mat.Power = material.Shininess; - pID3DDevice->SetMaterial(&mat); - } - - if (lastmaterial.ColorMaterial != material.ColorMaterial) - { - pID3DDevice->SetRenderState(D3DRS_COLORVERTEX, (material.ColorMaterial != ECM_NONE)); - pID3DDevice->SetRenderState(D3DRS_DIFFUSEMATERIALSOURCE, - ((material.ColorMaterial == ECM_DIFFUSE)|| - (material.ColorMaterial == ECM_DIFFUSE_AND_AMBIENT))?D3DMCS_COLOR1:D3DMCS_MATERIAL); - pID3DDevice->SetRenderState(D3DRS_AMBIENTMATERIALSOURCE, - ((material.ColorMaterial == ECM_AMBIENT)|| - (material.ColorMaterial == ECM_DIFFUSE_AND_AMBIENT))?D3DMCS_COLOR1:D3DMCS_MATERIAL); - pID3DDevice->SetRenderState(D3DRS_EMISSIVEMATERIALSOURCE, - (material.ColorMaterial == ECM_EMISSIVE)?D3DMCS_COLOR1:D3DMCS_MATERIAL); - pID3DDevice->SetRenderState(D3DRS_SPECULARMATERIALSOURCE, - (material.ColorMaterial == ECM_SPECULAR)?D3DMCS_COLOR1:D3DMCS_MATERIAL); - } - - // fillmode - if (resetAllRenderstates || lastmaterial.Wireframe != material.Wireframe || lastmaterial.PointCloud != material.PointCloud) - { - if (material.Wireframe) - pID3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME); - else - if (material.PointCloud) - pID3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_POINT); - else - pID3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); - } - - // shademode - if (resetAllRenderstates || lastmaterial.GouraudShading != material.GouraudShading) - { - if (material.GouraudShading) - pID3DDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD); - else - pID3DDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_FLAT); - } - - // lighting - if (resetAllRenderstates || lastmaterial.Lighting != material.Lighting) - { - if (material.Lighting) - pID3DDevice->SetRenderState(D3DRS_LIGHTING, TRUE); - else - pID3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE); - } - - // zbuffer - if (resetAllRenderstates || lastmaterial.ZBuffer != material.ZBuffer) - { - switch (material.ZBuffer) - { - case ECFN_NEVER: - pID3DDevice->SetRenderState(D3DRS_ZENABLE, FALSE); - break; - case ECFN_LESSEQUAL: - pID3DDevice->SetRenderState(D3DRS_ZENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL); - break; - case ECFN_EQUAL: - pID3DDevice->SetRenderState(D3DRS_ZENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_EQUAL); - break; - case ECFN_LESS: - pID3DDevice->SetRenderState(D3DRS_ZENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESS); - break; - case ECFN_NOTEQUAL: - pID3DDevice->SetRenderState(D3DRS_ZENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_NOTEQUAL); - break; - case ECFN_GREATEREQUAL: - pID3DDevice->SetRenderState(D3DRS_ZENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_GREATEREQUAL); - break; - case ECFN_GREATER: - pID3DDevice->SetRenderState(D3DRS_ZENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_GREATER); - break; - case ECFN_ALWAYS: - pID3DDevice->SetRenderState(D3DRS_ZENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_ALWAYS); - break; - } - } - - // zwrite -// if (resetAllRenderstates || lastmaterial.ZWriteEnable != material.ZWriteEnable) - { - if (material.ZWriteEnable && (AllowZWriteOnTransparent || !material.isTransparent())) - pID3DDevice->SetRenderState( D3DRS_ZWRITEENABLE, TRUE); - else - pID3DDevice->SetRenderState( D3DRS_ZWRITEENABLE, FALSE); - } - - // back face culling - if (resetAllRenderstates || (lastmaterial.FrontfaceCulling != material.FrontfaceCulling) || (lastmaterial.BackfaceCulling != material.BackfaceCulling)) - { -// if (material.FrontfaceCulling && material.BackfaceCulling) -// pID3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW|D3DCULL_CCW); -// else - if (material.FrontfaceCulling) - pID3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW); - else - if (material.BackfaceCulling) - pID3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW); - else - pID3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); - } - - // fog - if (resetAllRenderstates || lastmaterial.FogEnable != material.FogEnable) - { - pID3DDevice->SetRenderState(D3DRS_FOGENABLE, material.FogEnable); - } - - // specular highlights - if (resetAllRenderstates || !core::equals(lastmaterial.Shininess, material.Shininess)) - { - bool enable = (material.Shininess!=0); - pID3DDevice->SetRenderState(D3DRS_SPECULARENABLE, enable); - pID3DDevice->SetRenderState(D3DRS_NORMALIZENORMALS, enable); - pID3DDevice->SetRenderState(D3DRS_SPECULARMATERIALSOURCE, D3DMCS_MATERIAL); - } - - // normalization - if (resetAllRenderstates || lastmaterial.NormalizeNormals != material.NormalizeNormals) - { - pID3DDevice->SetRenderState(D3DRS_NORMALIZENORMALS, material.NormalizeNormals); - } - - // Color Mask - if (queryFeature(EVDF_COLOR_MASK) && - (resetAllRenderstates || lastmaterial.ColorMask != material.ColorMask)) - { - const DWORD flag = - ((material.ColorMask & ECP_RED)?D3DCOLORWRITEENABLE_RED:0) | - ((material.ColorMask & ECP_GREEN)?D3DCOLORWRITEENABLE_GREEN:0) | - ((material.ColorMask & ECP_BLUE)?D3DCOLORWRITEENABLE_BLUE:0) | - ((material.ColorMask & ECP_ALPHA)?D3DCOLORWRITEENABLE_ALPHA:0); - pID3DDevice->SetRenderState(D3DRS_COLORWRITEENABLE, flag); - } - - // thickness - if (resetAllRenderstates || lastmaterial.Thickness != material.Thickness) - { - pID3DDevice->SetRenderState(D3DRS_POINTSIZE, *((DWORD*)&material.Thickness)); - } - - // texture address mode - for (u32 st=0; st<MaxTextureUnits; ++st) - { - if (resetAllRenderstates || lastmaterial.TextureLayer[st].LODBias != material.TextureLayer[st].LODBias) - { - const float tmp = material.TextureLayer[st].LODBias * 0.125f; - pID3DDevice->SetTextureStageState(st, D3DTSS_MIPMAPLODBIAS, *(DWORD*)(&tmp)); - } - - if (resetAllRenderstates || lastmaterial.TextureLayer[st].TextureWrap != material.TextureLayer[st].TextureWrap) - { - u32 mode = D3DTADDRESS_WRAP; - switch (material.TextureLayer[st].TextureWrap) - { - case ETC_REPEAT: - mode=D3DTADDRESS_WRAP; - break; - case ETC_CLAMP: - case ETC_CLAMP_TO_EDGE: - mode=D3DTADDRESS_CLAMP; - break; - case ETC_MIRROR: - mode=D3DTADDRESS_MIRROR; - break; - case ETC_CLAMP_TO_BORDER: - mode=D3DTADDRESS_BORDER; - break; - } - - pID3DDevice->SetTextureStageState(st, D3DTSS_ADDRESSU, mode ); - pID3DDevice->SetTextureStageState(st, D3DTSS_ADDRESSV, mode ); - } - - // Bilinear and/or trilinear - if (resetAllRenderstates || - lastmaterial.TextureLayer[st].BilinearFilter != material.TextureLayer[st].BilinearFilter || - lastmaterial.TextureLayer[st].TrilinearFilter != material.TextureLayer[st].TrilinearFilter || - lastmaterial.TextureLayer[st].AnisotropicFilter != material.TextureLayer[st].AnisotropicFilter ) - { - if (material.TextureLayer[st].BilinearFilter || material.TextureLayer[st].TrilinearFilter || material.TextureLayer[st].AnisotropicFilter>1) - { - const D3DTEXTUREFILTERTYPE tftMag = ((Caps.TextureFilterCaps & D3DPTFILTERCAPS_MAGFANISOTROPIC) && - material.TextureLayer[st].AnisotropicFilter) ? D3DTEXF_ANISOTROPIC : D3DTEXF_LINEAR; - const D3DTEXTUREFILTERTYPE tftMin = ((Caps.TextureFilterCaps & D3DPTFILTERCAPS_MINFANISOTROPIC) && - material.TextureLayer[st].AnisotropicFilter) ? D3DTEXF_ANISOTROPIC : D3DTEXF_LINEAR; - const D3DTEXTUREFILTERTYPE tftMip = material.TextureLayer[st].TrilinearFilter ? D3DTEXF_LINEAR : D3DTEXF_POINT; - - if (tftMag==D3DTEXF_ANISOTROPIC || tftMin == D3DTEXF_ANISOTROPIC) - pID3DDevice->SetTextureStageState(st, D3DTSS_MAXANISOTROPY, core::min_((DWORD)material.TextureLayer[st].AnisotropicFilter, Caps.MaxAnisotropy)); - pID3DDevice->SetTextureStageState(st, D3DTSS_MAGFILTER, tftMag); - pID3DDevice->SetTextureStageState(st, D3DTSS_MINFILTER, tftMin); - pID3DDevice->SetTextureStageState(st, D3DTSS_MIPFILTER, tftMip); - } - else - { - pID3DDevice->SetTextureStageState(st, D3DTSS_MINFILTER, D3DTEXF_POINT); - pID3DDevice->SetTextureStageState(st, D3DTSS_MIPFILTER, D3DTEXF_NONE); - pID3DDevice->SetTextureStageState(st, D3DTSS_MAGFILTER, D3DTEXF_POINT); - } - } - } -} - - -//! sets the needed renderstates -void CD3D8Driver::setRenderStatesStencilShadowMode(bool zfail) -{ - if ((CurrentRenderMode != ERM_SHADOW_VOLUME_ZFAIL && - CurrentRenderMode != ERM_SHADOW_VOLUME_ZPASS) || - Transformation3DChanged) - { - // switch back the matrices - pID3DDevice->SetTransform(D3DTS_VIEW, (D3DMATRIX*)((void*)&Matrices[ETS_VIEW])); - pID3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX*)((void*)&Matrices[ETS_WORLD])); - pID3DDevice->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)((void*)&Matrices[ETS_PROJECTION])); - - Transformation3DChanged = false; - - setActiveTexture(0,0); - setActiveTexture(1,0); - setActiveTexture(2,0); - setActiveTexture(3,0); - - pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(3, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(3, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetVertexShader(D3DFVF_XYZ); - LastVertexType = (video::E_VERTEX_TYPE)(-1); - - pID3DDevice->SetRenderState( D3DRS_ZWRITEENABLE, FALSE ); - pID3DDevice->SetRenderState( D3DRS_STENCILENABLE, TRUE ); - pID3DDevice->SetRenderState( D3DRS_SHADEMODE, D3DSHADE_FLAT); - - //pID3DDevice->SetRenderState(D3DRS_FOGENABLE, FALSE); - //pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE); - - // unset last 3d material - if (CurrentRenderMode == ERM_3D && - Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) - MaterialRenderers[Material.MaterialType].Renderer->OnUnsetMaterial(); - } - - if (CurrentRenderMode != ERM_SHADOW_VOLUME_ZPASS && !zfail) - { - // USE THE ZPASS METHOD - - pID3DDevice->SetRenderState( D3DRS_STENCILFUNC, D3DCMP_ALWAYS ); - pID3DDevice->SetRenderState( D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP ); - pID3DDevice->SetRenderState( D3DRS_STENCILFAIL, D3DSTENCILOP_KEEP ); - - pID3DDevice->SetRenderState( D3DRS_STENCILREF, 0x1 ); - pID3DDevice->SetRenderState( D3DRS_STENCILMASK, 0xffffffff ); - pID3DDevice->SetRenderState( D3DRS_STENCILWRITEMASK, 0xffffffff ); - - pID3DDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ZERO ); - pID3DDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE ); - } - else - if (CurrentRenderMode != ERM_SHADOW_VOLUME_ZFAIL && zfail) - { - // USE THE ZFAIL METHOD - - pID3DDevice->SetRenderState( D3DRS_STENCILFUNC, D3DCMP_ALWAYS ); - pID3DDevice->SetRenderState( D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP ); - pID3DDevice->SetRenderState( D3DRS_STENCILFAIL, D3DSTENCILOP_KEEP ); - pID3DDevice->SetRenderState( D3DRS_STENCILPASS, D3DSTENCILOP_KEEP ); - - pID3DDevice->SetRenderState( D3DRS_STENCILREF, 0x0 ); - pID3DDevice->SetRenderState( D3DRS_STENCILMASK, 0xffffffff ); - pID3DDevice->SetRenderState( D3DRS_STENCILWRITEMASK, 0xffffffff ); - - pID3DDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE ); - pID3DDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ZERO ); - pID3DDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE ); - } - - CurrentRenderMode = zfail ? ERM_SHADOW_VOLUME_ZFAIL : ERM_SHADOW_VOLUME_ZPASS; -} - - -//! sets the needed renderstates -void CD3D8Driver::setRenderStatesStencilFillMode(bool alpha) -{ - if (CurrentRenderMode != ERM_STENCIL_FILL || Transformation3DChanged) - { - pID3DDevice->SetTransform(D3DTS_VIEW, &UnitMatrixD3D8); - pID3DDevice->SetTransform(D3DTS_WORLD, &UnitMatrixD3D8); - pID3DDevice->SetTransform(D3DTS_PROJECTION, &UnitMatrixD3D8); - - pID3DDevice->SetRenderState(D3DRS_ZENABLE, FALSE); - pID3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE); - pID3DDevice->SetRenderState(D3DRS_FOGENABLE, FALSE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(3, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(3, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetRenderState(D3DRS_STENCILREF, 0x1 ); - pID3DDevice->SetRenderState(D3DRS_STENCILFUNC, D3DCMP_LESSEQUAL); - //pID3DDevice->SetRenderState(D3DRS_STENCILFUNC, D3DCMP_GREATEREQUAL); - pID3DDevice->SetRenderState(D3DRS_STENCILPASS, D3DSTENCILOP_KEEP ); - pID3DDevice->SetRenderState( D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP ); - pID3DDevice->SetRenderState( D3DRS_STENCILMASK, 0xffffffff ); - pID3DDevice->SetRenderState( D3DRS_STENCILWRITEMASK, 0xffffffff ); - - pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW); - - Transformation3DChanged = false; - - if (alpha) - { - pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); - pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE ); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); - pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); - } - else - { - pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - } - } - - CurrentRenderMode = ERM_STENCIL_FILL; -} - - -//! sets the needed renderstates -void CD3D8Driver::setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel) -{ - if (!pID3DDevice) - return; - - if (CurrentRenderMode != ERM_2D || Transformation3DChanged) - { - // unset last 3d material - if (CurrentRenderMode == ERM_3D) - { - if (static_cast<u32>(LastMaterial.MaterialType) < MaterialRenderers.size()) - MaterialRenderers[LastMaterial.MaterialType].Renderer->OnUnsetMaterial(); - - SMaterial mat; - mat.ZBuffer=ECFN_NEVER; - mat.Lighting=false; - mat.AntiAliasing=video::EAAM_OFF; - mat.TextureLayer[0].BilinearFilter=false; - setBasicRenderStates(mat, mat, true); - // fix everything that is wrongly set by SMaterial default - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); - pID3DDevice->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); - pID3DDevice->SetTextureStageState(3, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(3, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); - - pID3DDevice->SetRenderState( D3DRS_STENCILENABLE, FALSE ); - - setTransform(ETS_TEXTURE_0, core::IdentityMatrix); - pID3DDevice->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0); - } - pID3DDevice->SetTransform(D3DTS_WORLD, &UnitMatrixD3D8); - - core::matrix4 m; - m.setTranslation(core::vector3df(-0.5f,-0.5f,0)); - pID3DDevice->SetTransform(D3DTS_VIEW, (D3DMATRIX*)((void*)m.pointer())); - - const core::dimension2d<u32>& renderTargetSize = getCurrentRenderTargetSize(); - m.buildProjectionMatrixOrthoLH(f32(renderTargetSize.Width), f32(-(s32)(renderTargetSize.Height)), -1.0, 1.0); - m.setTranslation(core::vector3df(-1,1,0)); - pID3DDevice->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)((void*)m.pointer())); - - Transformation3DChanged = false; - } - - if (texture) - { - if (alphaChannel) - { - pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); - - if (alpha) - { - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE ); - } - else - { - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ); - } - - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); - pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); - } - else - { - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); - if (alpha) - { - pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG2); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); - pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); - } - else - { - pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - } - } - } - else - { - pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); - if (alpha) - { - pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); - pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE ); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); - pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); - } - else - { - pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - } - } - - CurrentRenderMode = ERM_2D; -} - - -//! deletes all dynamic lights there are -void CD3D8Driver::deleteAllDynamicLights() -{ - for (s32 i=0; i<LastSetLight+1; ++i) - pID3DDevice->LightEnable(i, false); - - LastSetLight = -1; - - CNullDriver::deleteAllDynamicLights(); -} - - -//! adds a dynamic light -s32 CD3D8Driver::addDynamicLight(const SLight& dl) -{ - CNullDriver::addDynamicLight(dl); - - D3DLIGHT8 light; - - switch (dl.Type) - { - case ELT_POINT: - light.Type = D3DLIGHT_POINT; - break; - case ELT_SPOT: - light.Type = D3DLIGHT_SPOT; - break; - case ELT_DIRECTIONAL: - light.Type = D3DLIGHT_DIRECTIONAL; - break; - } - - light.Position = *(D3DVECTOR*)((void*)(&dl.Position)); - light.Direction = *(D3DVECTOR*)((void*)(&dl.Direction)); - - light.Range = core::min_(dl.Radius, MaxLightDistance); - light.Falloff = dl.Falloff; - - light.Diffuse = *(D3DCOLORVALUE*)((void*)(&dl.DiffuseColor)); - light.Specular = *(D3DCOLORVALUE*)((void*)(&dl.SpecularColor)); - light.Ambient = *(D3DCOLORVALUE*)((void*)(&dl.AmbientColor)); - - light.Attenuation0 = dl.Attenuation.X; - light.Attenuation1 = dl.Attenuation.Y; - light.Attenuation2 = dl.Attenuation.Z; - - light.Theta = dl.InnerCone * 2.0f * core::DEGTORAD; - light.Phi = dl.OuterCone * 2.0f * core::DEGTORAD; - - ++LastSetLight; - - if(D3D_OK == pID3DDevice->SetLight(LastSetLight, &light)) - { - // I don't care if this succeeds - (void)pID3DDevice->LightEnable(LastSetLight, true); - return LastSetLight; - } - - return -1; -} - - -void CD3D8Driver::turnLightOn(s32 lightIndex, bool turnOn) -{ - if(lightIndex < 0 || lightIndex > LastSetLight) - return; - - (void)pID3DDevice->LightEnable(lightIndex, turnOn); -} - - -//! returns the maximal amount of dynamic lights the device can handle -u32 CD3D8Driver::getMaximalDynamicLightAmount() const -{ - return Caps.MaxActiveLights; -} - - -//! Sets the dynamic ambient light color. The default color is -//! (0,0,0,0) which means it is dark. -//! \param color: New color of the ambient light. -void CD3D8Driver::setAmbientLight(const SColorf& color) -{ - if (!pID3DDevice) - return; - - AmbientLight = color; - D3DCOLOR col = color.toSColor().color; - pID3DDevice->SetRenderState(D3DRS_AMBIENT, col); -} - - -//! \return Returns the name of the video driver. Example: In case of the DIRECT3D8 -//! driver, it would return "Direct3D8.1". -const wchar_t* CD3D8Driver::getName() const -{ - return L"Direct3D 8.1"; -} - - -//! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do -//! this: Frist, draw all geometry. Then use this method, to draw the shadow -//! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow. -void CD3D8Driver::drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail) -{ - if (!StencilBuffer || !count) - return; - - setRenderStatesStencilShadowMode(zfail); - - if (!zfail) - { - // ZPASS Method - - // Draw front-side of shadow volume in stencil/z only - pID3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW ); - pID3DDevice->SetRenderState(D3DRS_STENCILPASS, D3DSTENCILOP_INCRSAT); - pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df)); - - // Now reverse cull order so front sides of shadow volume are written. - pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CW ); - pID3DDevice->SetRenderState( D3DRS_STENCILPASS, D3DSTENCILOP_DECRSAT); - pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df)); - } - else - { - // ZFAIL Method - - // Draw front-side of shadow volume in stencil/z only - pID3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW ); - pID3DDevice->SetRenderState(D3DRS_STENCILZFAIL, D3DSTENCILOP_INCRSAT ); - pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df)); - - // Now reverse cull order so front sides of shadow volume are written. - pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW ); - pID3DDevice->SetRenderState( D3DRS_STENCILZFAIL, D3DSTENCILOP_DECRSAT ); - pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df)); - } -} - - -//! Fills the stencil shadow with color. After the shadow volume has been drawn -//! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this -//! to draw the color of the shadow. -void CD3D8Driver::drawStencilShadow(bool clearStencilBuffer, video::SColor leftUpEdge, - video::SColor rightUpEdge, video::SColor leftDownEdge, video::SColor rightDownEdge) -{ - if (!StencilBuffer) - return; - - S3DVertex vtx[4]; - vtx[0] = S3DVertex(1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, leftUpEdge, 0.0f, 0.0f); - vtx[1] = S3DVertex(1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, rightUpEdge, 0.0f, 1.0f); - vtx[2] = S3DVertex(-1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, leftDownEdge, 1.0f, 0.0f); - vtx[3] = S3DVertex(-1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, rightDownEdge, 1.0f, 1.0f); - - const s16 indices[6] = {0,1,2,1,3,2}; - - setRenderStatesStencilFillMode( - leftUpEdge.getAlpha() < 255 || - rightUpEdge.getAlpha() < 255 || - leftDownEdge.getAlpha() < 255 || - rightDownEdge.getAlpha() < 255); - - setActiveTexture(0,0); - - setVertexShader(EVT_STANDARD); - - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, &indices[0], - D3DFMT_INDEX16, &vtx[0], sizeof(S3DVertex)); - - if (clearStencilBuffer) - pID3DDevice->Clear(0, NULL, D3DCLEAR_STENCIL,0, 1.0, 0); -} - - -//! Returns the maximum amount of primitives (mostly vertices) which -//! the device is able to render with one drawIndexedTriangleList -//! call. -u32 CD3D8Driver::getMaximalPrimitiveCount() const -{ - return Caps.MaxPrimitiveCount; -} - - -//! Sets the fog mode. -void CD3D8Driver::setFog(SColor color, E_FOG_TYPE fogType, f32 start, - f32 end, f32 density, bool pixelFog, bool rangeFog) -{ - CNullDriver::setFog(color, fogType, start, end, density, pixelFog, rangeFog); - - if (!pID3DDevice) - return; - - pID3DDevice->SetRenderState(D3DRS_FOGCOLOR, color.color); - - pID3DDevice->SetRenderState( -#if defined( _IRR_XBOX_PLATFORM_) - D3DRS_FOGTABLEMODE, -#else - pixelFog ? D3DRS_FOGTABLEMODE : D3DRS_FOGVERTEXMODE, -#endif - (fogType==EFT_FOG_LINEAR)? D3DFOG_LINEAR : (fogType==EFT_FOG_EXP)?D3DFOG_EXP:D3DFOG_EXP2); - - if (fogType==EFT_FOG_LINEAR) - { - pID3DDevice->SetRenderState(D3DRS_FOGSTART, *(DWORD*)(&start)); - pID3DDevice->SetRenderState(D3DRS_FOGEND, *(DWORD*)(&end)); - } - else - pID3DDevice->SetRenderState(D3DRS_FOGDENSITY, *(DWORD*)(&density)); - - if(!pixelFog) - pID3DDevice->SetRenderState(D3DRS_RANGEFOGENABLE, rangeFog); -} - - -//! Draws a 3d line. -void CD3D8Driver::draw3DLine(const core::vector3df& start, - const core::vector3df& end, SColor color) -{ - setVertexShader(EVT_STANDARD); - setRenderStates3DMode(); - video::S3DVertex v[2]; - v[0].Color = color; - v[1].Color = color; - v[0].Pos = start; - v[1].Pos = end; - - pID3DDevice->DrawPrimitiveUP(D3DPT_LINELIST, 1, v, sizeof(S3DVertex)); -} - - -void CD3D8Driver::OnResize(const core::dimension2d<u32>& size) -{ - if (!pID3DDevice) - return; - - CNullDriver::OnResize(size); - reset(); -} - - -//! Returns type of video driver -E_DRIVER_TYPE CD3D8Driver::getDriverType() const -{ - return EDT_DIRECT3D8; -} - - -//! Returns the transformation set by setTransform -const core::matrix4& CD3D8Driver::getTransform(E_TRANSFORMATION_STATE state) const -{ - return Matrices[state]; -} - - -//! Sets a vertex shader constant. -void CD3D8Driver::setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount) -{ - if (data) - pID3DDevice->SetVertexShaderConstant(startRegister, data, constantAmount); -} - - -//! Sets a pixel shader constant. -void CD3D8Driver::setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount) -{ - if (data) - pID3DDevice->SetPixelShaderConstant(startRegister, data, constantAmount); -} - - -//! Sets a constant for the vertex shader based on a name. -bool CD3D8Driver::setVertexShaderConstant(const c8* name, const f32* floats, int count) -{ - os::Printer::log("Cannot set constant, no HLSL supported in D3D8"); - return false; -} - - -//! Sets a constant for the pixel shader based on a name. -bool CD3D8Driver::setPixelShaderConstant(const c8* name, const f32* floats, int count) -{ - os::Printer::log("Cannot set constant, no HLSL supported in D3D8"); - return false; -} - - -//! Returns pointer to the IGPUProgrammingServices interface. -IGPUProgrammingServices* CD3D8Driver::getGPUProgrammingServices() -{ - return this; -} - - -//! Adds a new material renderer to the VideoDriver, using pixel and/or -//! vertex shaders to render geometry. -s32 CD3D8Driver::addShaderMaterial(const c8* vertexShaderProgram, - const c8* pixelShaderProgram, - IShaderConstantSetCallBack* callback, - E_MATERIAL_TYPE baseMaterial, s32 userData) -{ - s32 nr = -1; - CD3D8ShaderMaterialRenderer* r = new CD3D8ShaderMaterialRenderer( - pID3DDevice, this, nr, vertexShaderProgram, pixelShaderProgram, - callback, getMaterialRenderer(baseMaterial), userData); - - r->drop(); - return nr; -} - - -//! Returns a pointer to the IVideoDriver interface. (Implementation for -//! IMaterialRendererServices) -IVideoDriver* CD3D8Driver::getVideoDriver() -{ - return this; -} - - -//! Clears the ZBuffer. -void CD3D8Driver::clearZBuffer() -{ - const HRESULT hr = pID3DDevice->Clear( 0, NULL, D3DCLEAR_ZBUFFER, 0, 1.0, 0); - - if (FAILED(hr)) - os::Printer::log("CD3D8Driver clearZBuffer() failed.", ELL_WARNING); -} - - -//! Returns an image created from the last rendered frame. -IImage* CD3D8Driver::createScreenShot() -{ -#if defined( _IRR_XBOX_PLATFORM_) - return 0; -#else - HRESULT hr; - - // query the screen dimensions of the current adapter - D3DDISPLAYMODE displayMode; - pID3DDevice->GetDisplayMode(&displayMode); - - // create the image surface to store the front buffer image [always A8R8G8B8] - LPDIRECT3DSURFACE8 lpSurface; - if (FAILED(hr = pID3DDevice->CreateImageSurface(displayMode.Width, displayMode.Height, D3DFMT_A8R8G8B8, &lpSurface))) - return 0; - - // read the front buffer into the image surface - if (FAILED(hr = pID3DDevice->GetFrontBuffer(lpSurface))) - { - lpSurface->Release(); - return 0; - } - - RECT clientRect; - { - POINT clientPoint; - clientPoint.x = 0; - clientPoint.y = 0; - - ClientToScreen( (HWND)getExposedVideoData().D3D8.HWnd, &clientPoint ); - - clientRect.left = clientPoint.x; - clientRect.top = clientPoint.y; - clientRect.right = clientRect.left + ScreenSize.Width; - clientRect.bottom = clientRect.top + ScreenSize.Height; - } - - // lock our area of the surface - D3DLOCKED_RECT lockedRect; - if (FAILED(lpSurface->LockRect(&lockedRect, &clientRect, D3DLOCK_READONLY))) - { - lpSurface->Release(); - return 0; - } - - // this could throw, but we aren't going to worry about that case very much - IImage* newImage = new CImage(ECF_A8R8G8B8, ScreenSize); - - // d3d pads the image, so we need to copy the correct number of bytes - u32* dP = (u32*)newImage->lock(); - u8 * sP = (u8 *)lockedRect.pBits; - - // If the display mode format doesn't promise anything about the Alpha value - // and it appears that it's not presenting 255, then we should manually - // set each pixel alpha value to 255. - if(D3DFMT_X8R8G8B8 == displayMode.Format && (0xFF000000 != (*dP & 0xFF000000))) - { - for (u32 y = 0; y < ScreenSize.Height; ++y) - { - for(u32 x = 0; x < ScreenSize.Width; ++x) - { - *dP = *((u32*)sP) | 0xFF000000; - dP++; - sP += 4; - } - - sP += lockedRect.Pitch - (4 * ScreenSize.Width); - } - } - else - { - for (u32 y = 0; y < ScreenSize.Height; ++y) - { - memcpy(dP, sP, ScreenSize.Width * 4); - - sP += lockedRect.Pitch; - dP += ScreenSize.Width; - } - } - - newImage->unlock(); - - // we can unlock and release the surface - lpSurface->UnlockRect(); - - // release the image surface - lpSurface->Release(); - - // return status of save operation to caller - return newImage; -#endif -} - - -// returns the current size of the screen or rendertarget -const core::dimension2d<u32>& CD3D8Driver::getCurrentRenderTargetSize() const -{ - if ( CurrentRendertargetSize.Width == 0 ) - return ScreenSize; - else - return CurrentRendertargetSize; -} - - -// Set/unset a clipping plane. -bool CD3D8Driver::setClipPlane(u32 index, const core::plane3df& plane, bool enable) -{ -#if defined( _IRR_XBOX_PLATFORM_) - return false; -#else - if (index >= MaxUserClipPlanes) - return false; - pID3DDevice->SetClipPlane(index, (const float*)&plane); - enableClipPlane(index, enable); - return true; -#endif -} - - -// Enable/disable a clipping plane. -void CD3D8Driver::enableClipPlane(u32 index, bool enable) -{ -#if defined( _IRR_XBOX_PLATFORM_) - return; -#else - if (index >= MaxUserClipPlanes) - return; - DWORD renderstate; - pID3DDevice->GetRenderState(D3DRS_CLIPPLANEENABLE, &renderstate); - if (enable) - renderstate |= (1 << index); - else - renderstate &= ~(1 << index); - pID3DDevice->SetRenderState(D3DRS_CLIPPLANEENABLE, renderstate); -#endif -} - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_DIRECT3D_8_ - - -namespace irr -{ -namespace video -{ - -#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ -//! creates a video driver -IVideoDriver* createDirectX8Driver(const core::dimension2d<u32>& screenSize, - HWND window, u32 bits, bool fullscreen, bool stencilbuffer, - io::IFileSystem* io, bool pureSoftware, bool highPrecisionFPU, - bool vsync, u8 antiAlias) -{ - CD3D8Driver* dx8 = new CD3D8Driver(screenSize, window, fullscreen, - stencilbuffer, io, pureSoftware); - - if (!dx8->initDriver(screenSize, window, bits, fullscreen, - pureSoftware, highPrecisionFPU, vsync, antiAlias)) - { - dx8->drop(); - dx8 = 0; - } - - return dx8; -} -#endif // _IRR_COMPILE_WITH_DIRECT3D_8_ - -} // end namespace video -} // end namespace irr diff --git a/irrlicht-1.6/source/Irrlicht/CD3D8Driver.h b/irrlicht-1.6/source/Irrlicht/CD3D8Driver.h deleted file mode 100644 index 04a9e1ae3..000000000 --- a/irrlicht-1.6/source/Irrlicht/CD3D8Driver.h +++ /dev/null @@ -1,328 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_VIDEO_DIRECTX_8_H_INCLUDED__ -#define __C_VIDEO_DIRECTX_8_H_INCLUDED__ - -#include "IrrCompileConfig.h" - -#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ - -#ifdef _IRR_WINDOWS_ - #define WIN32_LEAN_AND_MEAN - #include <windows.h> -#endif - -// always included for static createDriver function -#include "CNullDriver.h" -#include "IMaterialRendererServices.h" - -#include <d3d8.h> - -namespace irr -{ -namespace video -{ - class CD3D8Driver : public CNullDriver, IMaterialRendererServices - { - friend class CD3D8Texture; - - public: - - //! constructor - CD3D8Driver(const core::dimension2d<u32>& screenSize, HWND window, bool fullscreen, - bool stencibuffer, io::IFileSystem* io, bool pureSoftware=false, bool vsync=false); - - //! destructor - virtual ~CD3D8Driver(); - - //! applications must call this method before performing any rendering. returns false if failed. - virtual bool beginScene(bool backBuffer=true, bool zBuffer=true, - SColor color=SColor(255,0,0,0), - void* windowId=0, - core::rect<s32>* sourceRect=0); - - //! applications must call this method after performing any rendering. returns false if failed. - virtual bool endScene(); - - //! queries the features of the driver, returns true if feature is available - virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const; - - //! sets transformation - virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat); - - //! sets a material - virtual void setMaterial(const SMaterial& material); - - //! sets a render target - virtual bool setRenderTarget(video::ITexture* texture, - bool clearBackBuffer=false, bool clearZBuffer=false, - SColor color=video::SColor(0,0,0,0)); - - //! sets a viewport - virtual void setViewPort(const core::rect<s32>& area); - - //! gets the area of the current viewport - virtual const core::rect<s32>& getViewPort() const; - - //! draws a vertex primitive list - virtual void drawVertexPrimitiveList(const void* vertices, u32 vertexCount, - const void* indexList, u32 primitiveCount, - E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, - E_INDEX_TYPE iType); - - //! draws a vertex primitive list in 2d - virtual void draw2DVertexPrimitiveList(const void* vertices, u32 vertexCount, - const void* indexList, u32 primitiveCount, - E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, - E_INDEX_TYPE iType); - - //! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. - virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos, - const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0, - SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false); - - //! Draws a part of the texture into the rectangle. - virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect, - const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0, - const video::SColor* const colors=0, bool useAlphaChannelOfTexture=false); - - //!Draws an 2d rectangle with a gradient. - virtual void draw2DRectangle(const core::rect<s32>& pos, - SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, - const core::rect<s32>* clip = 0); - - //! Draws a 2d line. - virtual void draw2DLine(const core::position2d<s32>& start, - const core::position2d<s32>& end, - SColor color=SColor(255,255,255,255)); - - //! Draws a pixel. - virtual void drawPixel(u32 x, u32 y, const SColor & color); - - //! Draws a 3d line. - virtual void draw3DLine(const core::vector3df& start, - const core::vector3df& end, SColor color = SColor(255,255,255,255)); - - //! initialises the Direct3D API - bool initDriver(const core::dimension2d<u32>& screenSize, HWND hwnd, - u32 bits, bool fullScreen, bool pureSoftware, - bool highPrecisionFPU, bool vsync, u8 antiAlias); - - //! \return Returns the name of the video driver. Example: In case of the DIRECT3D8 - //! driver, it would return "Direct3D8.1". - virtual const wchar_t* getName() const; - - //! deletes all dynamic lights there are - virtual void deleteAllDynamicLights(); - - //! adds a dynamic light, returning an index to the light - //! \param light: the light data to use to create the light - //! \return An index to the light, or -1 if an error occurs - virtual s32 addDynamicLight(const SLight& light); - - //! Turns a dynamic light on or off - //! \param lightIndex: the index returned by addDynamicLight - //! \param turnOn: true to turn the light on, false to turn it off - virtual void turnLightOn(s32 lightIndex, bool turnOn); - - //! returns the maximal amount of dynamic lights the device can handle - virtual u32 getMaximalDynamicLightAmount() const; - - //! Sets the dynamic ambient light color. The default color is - //! (0,0,0,0) which means it is dark. - //! \param color: New color of the ambient light. - virtual void setAmbientLight(const SColorf& color); - - //! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do - //! this: Frist, draw all geometry. Then use this method, to draw the shadow - //! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow. - virtual void drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail); - - //! Fills the stencil shadow with color. After the shadow volume has been drawn - //! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this - //! to draw the color of the shadow. - virtual void drawStencilShadow(bool clearStencilBuffer=false, - video::SColor leftUpEdge = video::SColor(0,0,0,0), - video::SColor rightUpEdge = video::SColor(0,0,0,0), - video::SColor leftDownEdge = video::SColor(0,0,0,0), - video::SColor rightDownEdge = video::SColor(0,0,0,0)); - - //! Returns the maximum amount of primitives (mostly vertices) which - //! the device is able to render with one drawIndexedTriangleList - //! call. - virtual u32 getMaximalPrimitiveCount() const; - - //! Enables or disables a texture creation flag. - virtual void setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled); - - //! Sets the fog mode. - virtual void setFog(SColor color, E_FOG_TYPE fogType, f32 start, - f32 end, f32 density, bool pixelFog, bool rangeFog); - - //! Only used by the internal engine. Used to notify the driver that - //! the window was resized. - virtual void OnResize(const core::dimension2d<u32>& size); - - //! Returns type of video driver - virtual E_DRIVER_TYPE getDriverType() const; - - //! Returns the transformation set by setTransform - virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) const; - - //! Can be called by an IMaterialRenderer to make its work easier. - virtual void setBasicRenderStates(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates); - - //! Sets a vertex shader constant. - virtual void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1); - - //! Sets a pixel shader constant. - virtual void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1); - - //! Sets a constant for the vertex shader based on a name. - virtual bool setVertexShaderConstant(const c8* name, const f32* floats, int count); - - //! Sets a constant for the pixel shader based on a name. - virtual bool setPixelShaderConstant(const c8* name, const f32* floats, int count); - - //! Returns pointer to the IGPUProgrammingServices interface. - virtual IGPUProgrammingServices* getGPUProgrammingServices(); - - //! Returns a pointer to the IVideoDriver interface. (Implementation for - //! IMaterialRendererServices) - virtual IVideoDriver* getVideoDriver(); - - //! Creates a render target texture. - virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size, - const io::path& name, const ECOLOR_FORMAT format = ECF_UNKNOWN); - - //! Clears the ZBuffer. - virtual void clearZBuffer(); - - //! Returns an image created from the last rendered frame. - virtual IImage* createScreenShot(); - - //! Set/unset a clipping plane. - //! There are at least 6 clipping planes available for the user to set at will. - //! \param index: The plane index. Must be between 0 and MaxUserClipPlanes. - //! \param plane: The plane itself. - //! \param enable: If true, enable the clipping plane else disable it. - virtual bool setClipPlane(u32 index, const core::plane3df& plane, bool enable=false); - - //! Enable/disable a clipping plane. - //! There are at least 6 clipping planes available for the user to set at will. - //! \param index: The plane index. Must be between 0 and MaxUserClipPlanes. - //! \param enable: If true, enable the clipping plane else disable it. - virtual void enableClipPlane(u32 index, bool enable); - - virtual bool checkDriverReset() {return DriverWasReset;} - private: - - // enumeration for rendering modes such as 2d and 3d for minizing the switching of renderStates. - enum E_RENDER_MODE - { - ERM_NONE = 0, // no render state has been set yet. - ERM_2D, // 2d drawing rendermode - ERM_3D, // 3d rendering mode - ERM_STENCIL_FILL, // stencil fill mode - ERM_SHADOW_VOLUME_ZFAIL, // stencil volume draw mode - ERM_SHADOW_VOLUME_ZPASS // stencil volume draw mode - }; - - //! sets right vertex shader - void setVertexShader(video::E_VERTEX_TYPE newType); - - //! sets the needed renderstates - bool setRenderStates3DMode(); - - //! sets the needed renderstates - void setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel); - - //! sets the needed renderstates - void setRenderStatesStencilFillMode(bool alpha); - - //! sets the needed renderstates - void setRenderStatesStencilShadowMode(bool zfail); - - //! sets the current Texture - bool setActiveTexture(u32 stage, const video::ITexture* texture); - - //! resets the device - bool reset(); - - //! returns a device dependent texture from a software surface (IImage) - //! THIS METHOD HAS TO BE OVERRIDDEN BY DERIVED DRIVERS WITH OWN TEXTURES - virtual video::ITexture* createDeviceDependentTexture(IImage* surface, const io::path& name); - - // returns the current size of the screen or rendertarget - virtual const core::dimension2d<u32>& getCurrentRenderTargetSize() const; - - //! Adds a new material renderer to the VideoDriver, using pixel and/or - //! vertex shaders to render geometry. - s32 addShaderMaterial(const c8* vertexShaderProgram, const c8* pixelShaderProgram, - IShaderConstantSetCallBack* callback, - E_MATERIAL_TYPE baseMaterial, s32 userData); - - void createMaterialRenderers(); - - void draw2D3DVertexPrimitiveList(const void* vertices, - u32 vertexCount, const void* indexList, u32 primitiveCount, - E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, - E_INDEX_TYPE iType, bool is3D); - - inline D3DCOLORVALUE colorToD3D(const SColor& col) - { - const f32 f = 1.0f / 255.0f; - D3DCOLORVALUE v; - v.r = col.getRed() * f; - v.g = col.getGreen() * f; - v.b = col.getBlue() * f; - v.a = col.getAlpha() * f; - return v; - } - - E_RENDER_MODE CurrentRenderMode; - D3DPRESENT_PARAMETERS present; - - SMaterial Material, LastMaterial; - bool ResetRenderStates; // bool to make all renderstates be reseted if set. - bool Transformation3DChanged; - bool StencilBuffer; - const ITexture* CurrentTexture[MATERIAL_MAX_TEXTURES]; - core::matrix4 Matrices[ETS_COUNT]; // matrices of the 3d mode we need to restore when we switch back from the 2d mode. - - HINSTANCE D3DLibrary; - IDirect3D8* pID3D; - IDirect3DDevice8* pID3DDevice; - - IDirect3DSurface8* PrevRenderTarget; - core::dimension2d<u32> CurrentRendertargetSize; - - void* WindowId; - core::rect<s32>* SceneSourceRect; - - D3DCAPS8 Caps; - - E_VERTEX_TYPE LastVertexType; - - D3DMATRIX UnitMatrix; - - u32 MaxTextureUnits; - u32 MaxUserClipPlanes; - f32 MaxLightDistance; - s32 LastSetLight; - bool DeviceLost; - bool DriverWasReset; - - SColorf AmbientLight; - }; - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_DIRECT3D_8_ - -#endif // __C_VIDEO_DIRECTX_8_H_INCLUDED__ - diff --git a/irrlicht-1.6/source/Irrlicht/CD3D8MaterialRenderer.h b/irrlicht-1.6/source/Irrlicht/CD3D8MaterialRenderer.h deleted file mode 100644 index 66ae92e32..000000000 --- a/irrlicht-1.6/source/Irrlicht/CD3D8MaterialRenderer.h +++ /dev/null @@ -1,588 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_D3D8_MATERIAL_RENDERER_H_INCLUDED__ -#define __C_D3D8_MATERIAL_RENDERER_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_WINDOWS_API_ - -#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ -#include <d3d8.h> - -#include "IMaterialRenderer.h" - -namespace irr -{ -namespace video -{ - -D3DMATRIX UnitMatrixD3D8; -D3DMATRIX SphereMapMatrixD3D8; - -//! Base class for all internal D3D8 material renderers -class CD3D8MaterialRenderer : public IMaterialRenderer -{ -public: - - //! Constructor - CD3D8MaterialRenderer(IDirect3DDevice8* d3ddev, video::IVideoDriver* driver) - : pID3DDevice(d3ddev), Driver(driver) - { - } - -protected: - - IDirect3DDevice8* pID3DDevice; - video::IVideoDriver* Driver; -}; - - -//! Solid material renderer -class CD3D8MaterialRenderer_SOLID : public CD3D8MaterialRenderer -{ -public: - - CD3D8MaterialRenderer_SOLID(IDirect3DDevice8* p, video::IVideoDriver* d) - : CD3D8MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - } - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } -}; - -//! Generic Texture Blend -class CD3D8MaterialRenderer_ONETEXTURE_BLEND : public CD3D8MaterialRenderer -{ -public: - - CD3D8MaterialRenderer_ONETEXTURE_BLEND(IDirect3DDevice8* p, video::IVideoDriver* d) - : CD3D8MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || - material.MaterialTypeParam != lastMaterial.MaterialTypeParam || - resetAllRenderstates) - { - - E_BLEND_FACTOR srcFact,dstFact; - E_MODULATE_FUNC modulate; - u32 alphaSource; - unpack_texureBlendFunc ( srcFact, dstFact, modulate, alphaSource, material.MaterialTypeParam ); - - if (srcFact == EBF_SRC_COLOR && dstFact == EBF_ZERO) - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - else - { - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_SRCBLEND, getD3DBlend ( srcFact ) ); - pID3DDevice->SetRenderState(D3DRS_DESTBLEND, getD3DBlend ( dstFact ) ); - } - - pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, getD3DModulate ( modulate ) ); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - - if ( alphaSource && (textureBlendFunc_hasAlpha ( srcFact ) || textureBlendFunc_hasAlpha ( dstFact ) )) - { - if (alphaSource==EAS_VERTEX_COLOR) - { - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE ); - } - else if (alphaSource==EAS_TEXTURE) - { - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); - } - else - { - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE ); - } - } - else - { - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); - } - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); - - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - - } - - //! Returns if the material is transparent. - virtual bool isTransparent() const - { - return true; - } - - private: - - u32 getD3DBlend ( E_BLEND_FACTOR factor ) const - { - u32 r = 0; - switch ( factor ) - { - case EBF_ZERO: r = D3DBLEND_ZERO; break; - case EBF_ONE: r = D3DBLEND_ONE; break; - case EBF_DST_COLOR: r = D3DBLEND_DESTCOLOR; break; - case EBF_ONE_MINUS_DST_COLOR: r = D3DBLEND_INVDESTCOLOR; break; - case EBF_SRC_COLOR: r = D3DBLEND_SRCCOLOR; break; - case EBF_ONE_MINUS_SRC_COLOR: r = D3DBLEND_INVSRCCOLOR; break; - case EBF_SRC_ALPHA: r = D3DBLEND_SRCALPHA; break; - case EBF_ONE_MINUS_SRC_ALPHA: r = D3DBLEND_INVSRCALPHA; break; - case EBF_DST_ALPHA: r = D3DBLEND_DESTALPHA; break; - case EBF_ONE_MINUS_DST_ALPHA: r = D3DBLEND_INVDESTALPHA; break; - case EBF_SRC_ALPHA_SATURATE: r = D3DBLEND_SRCALPHASAT; break; - } - return r; - } - - u32 getD3DModulate ( E_MODULATE_FUNC func ) const - { - u32 r = D3DTOP_MODULATE; - switch ( func ) - { - case EMFN_MODULATE_1X: r = D3DTOP_MODULATE; break; - case EMFN_MODULATE_2X: r = D3DTOP_MODULATE2X; break; - case EMFN_MODULATE_4X: r = D3DTOP_MODULATE4X; break; - } - return r; - } - -}; - - -//! Solid 2 layer material renderer -class CD3D8MaterialRenderer_SOLID_2_LAYER : public CD3D8MaterialRenderer -{ -public: - - CD3D8MaterialRenderer_SOLID_2_LAYER(IDirect3DDevice8* p, video::IVideoDriver* d) - : CD3D8MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 0); - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_BLENDDIFFUSEALPHA); - - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } -}; - - -//! Transparent add color material renderer -class CD3D8MaterialRenderer_TRANSPARENT_ADD_COLOR : public CD3D8MaterialRenderer -{ -public: - - CD3D8MaterialRenderer_TRANSPARENT_ADD_COLOR(IDirect3DDevice8* p, video::IVideoDriver* d) - : CD3D8MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); - pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCCOLOR); - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } - - //! Returns if the material is transparent. - virtual bool isTransparent() const - { - return true; - } -}; - - -//! Transparent vertex alpha material renderer -class CD3D8MaterialRenderer_TRANSPARENT_VERTEX_ALPHA : public CD3D8MaterialRenderer -{ -public: - - CD3D8MaterialRenderer_TRANSPARENT_VERTEX_ALPHA(IDirect3DDevice8* p, video::IVideoDriver* d) - : CD3D8MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); - pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } - - //! Returns if the material is transparent. - virtual bool isTransparent() const - { - return true; - } -}; - - -//! Transparent alpha channel material renderer -class CD3D8MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL : public CD3D8MaterialRenderer -{ -public: - - CD3D8MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL(IDirect3DDevice8* p, video::IVideoDriver* d) - : CD3D8MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates - || material.MaterialTypeParam != lastMaterial.MaterialTypeParam ) - { - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_CURRENT ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); - - pID3DDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE ); - pID3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); - - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); - pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); - - pID3DDevice->SetRenderState(D3DRS_ALPHAREF, core::floor32(material.MaterialTypeParam * 255.f)); - pID3DDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL); - pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE); - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } - - virtual void OnUnsetMaterial() - { - pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE); - } - - //! Returns if the material is transparent. - virtual bool isTransparent() const - { - return true; - } -}; - - -//! Transparent alpha channel material renderer -class CD3D8MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF : public CD3D8MaterialRenderer -{ -public: - - CD3D8MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF(IDirect3DDevice8* p, video::IVideoDriver* d) - : CD3D8MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_CURRENT ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); - - pID3DDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE ); - pID3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); - - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - - // 127 is required by EMT_TRANSPARENT_ALPHA_CHANNEL_REF - pID3DDevice->SetRenderState(D3DRS_ALPHAREF, 127); - pID3DDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL); - pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE); - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } - - virtual void OnUnsetMaterial() - { - pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE); - } - - //! Returns if the material is transparent. The scene managment needs to know this - //! for being able to sort the materials by opaque and transparent. - virtual bool isTransparent() const - { - return false; // this material is not really transparent because it does no blending. - } -}; - - - -//! material renderer for all kinds of linghtmaps -class CD3D8MaterialRenderer_LIGHTMAP : public CD3D8MaterialRenderer -{ -public: - - CD3D8MaterialRenderer_LIGHTMAP(IDirect3DDevice8* p, video::IVideoDriver* d) - : CD3D8MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - if (material.MaterialType >= EMT_LIGHTMAP_LIGHTING) - { - // with lighting - pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - } - else - { - pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - } - - pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1); - - if (material.MaterialType == EMT_LIGHTMAP_ADD) - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_ADD); - else - if (material.MaterialType == EMT_LIGHTMAP_M4) - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE4X); - else - if (material.MaterialType == EMT_LIGHTMAP_M2) - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE2X); - else - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT); - pID3DDevice->SetTextureStageState (1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } -}; - -//! material renderer for detail maps -class CD3D8MaterialRenderer_DETAIL_MAP : public CD3D8MaterialRenderer -{ -public: - - CD3D8MaterialRenderer_DETAIL_MAP(IDirect3DDevice8* p, video::IVideoDriver* d) - : CD3D8MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetTextureStageState (1, D3DTSS_COLOROP, D3DTOP_ADDSIGNED); - pID3DDevice->SetTextureStageState (1, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState (1, D3DTSS_COLORARG2, D3DTA_CURRENT); - pID3DDevice->SetTextureStageState (1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } -}; - - -//! sphere map material renderer -class CD3D8MaterialRenderer_SPHERE_MAP : public CD3D8MaterialRenderer -{ -public: - - CD3D8MaterialRenderer_SPHERE_MAP(IDirect3DDevice8* p, video::IVideoDriver* d) - : CD3D8MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - - pID3DDevice->SetTransform( D3DTS_TEXTURE0, &SphereMapMatrixD3D8 ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACENORMAL ); - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } - - virtual void OnUnsetMaterial() - { - pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0); - pID3DDevice->SetTransform( D3DTS_TEXTURE0, &UnitMatrixD3D8 ); - } -}; - - -//! reflection 2 layer material renderer -class CD3D8MaterialRenderer_REFLECTION_2_LAYER : public CD3D8MaterialRenderer -{ -public: - - CD3D8MaterialRenderer_REFLECTION_2_LAYER(IDirect3DDevice8* p, video::IVideoDriver* d) - : CD3D8MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT); - - pID3DDevice->SetTransform( D3DTS_TEXTURE1, &SphereMapMatrixD3D8 ); - pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 ); - pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } - - virtual void OnUnsetMaterial() - { - pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE ); - pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 1); - pID3DDevice->SetTransform( D3DTS_TEXTURE1, &UnitMatrixD3D8 ); - } -}; - - -//! reflection 2 layer material renderer -class CD3D8MaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER : public CD3D8MaterialRenderer -{ -public: - - CD3D8MaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER(IDirect3DDevice8* p, video::IVideoDriver* d) - : CD3D8MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT); - - pID3DDevice->SetTransform( D3DTS_TEXTURE1, &SphereMapMatrixD3D8 ); - pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 ); - pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); - pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } - - virtual void OnUnsetMaterial() - { - pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE ); - pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 1); - pID3DDevice->SetTransform( D3DTS_TEXTURE1, &UnitMatrixD3D8 ); - } - - //! Returns if the material is transparent. - virtual bool isTransparent() const - { - return true; - } -}; - -} // end namespace video -} // end namespace irr - -#endif -#endif -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CD3D8NormalMapRenderer.cpp b/irrlicht-1.6/source/Irrlicht/CD3D8NormalMapRenderer.cpp deleted file mode 100644 index 5f03131c2..000000000 --- a/irrlicht-1.6/source/Irrlicht/CD3D8NormalMapRenderer.cpp +++ /dev/null @@ -1,248 +0,0 @@ -// Copyright (C) 2002-2009 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_DIRECT3D_8_ - -#include "CD3D8NormalMapRenderer.h" -#include "IMaterialRendererServices.h" -#include "IVideoDriver.h" -#include "os.h" -#include "SLight.h" - -namespace irr -{ -namespace video -{ - - // 1.1 Shaders with two lights and vertex based attenuation - - // Irrlicht Engine D3D8 render path normal map vertex shader - const char D3D8_NORMAL_MAP_VSH[] = - ";Irrlicht Engine 0.8 D3D8 render path normal map vertex shader\n"\ - "; c0-3: Transposed world matrix \n"\ - "; c8-11: Transposed worldViewProj matrix (Projection * View * World) \n"\ - "; c12: Light01 position \n"\ - "; c13: x,y,z: Light01 color; .w: 1/LightRadius \n"\ - "; c14: Light02 position \n"\ - "; c15: x,y,z: Light02 color; .w: 1/LightRadius \n"\ - "\n"\ - "; v0 - position \n"\ - "; v1 - normal \n"\ - "; v2 - color \n"\ - "; v3 - texture coord \n"\ - "; v4 - tangent \n"\ - "; v5 - binormal \n"\ - "\n"\ - "vs.1.1\n"\ - "\n"\ - "m4x4 oPos, v0, c8 ; transform position to clip space with worldViewProj matrix\n"\ - "\n"\ - "m3x3 r5, v4, c0 ; transform tangent U\n"\ - "m3x3 r7, v1, c0 ; transform normal W\n"\ - "m3x3 r6, v5, c0 ; transform binormal V\n"\ - "\n"\ - "m4x4 r4, v0, c0 ; vertex into world position\n"\ - "add r2, c12, -r4 ; vtxpos - lightpos1\n"\ - "add r3, c14, -r4 ; vtxpos - lightpos2\n"\ - "\n"\ - "dp3 r8.x, r5, r2 ; transform the light vector 1 with U, V, W\n"\ - "dp3 r8.y, r6, r2 \n"\ - "dp3 r8.z, r7, r2 \n"\ - "dp3 r9.x, r5, r3 ; transform the light vector 2 with U, V, W\n"\ - "dp3 r9.y, r6, r3 \n"\ - "dp3 r9.z, r7, r3 \n"\ - "\n"\ - "dp3 r8.w, r8, r8 ; normalize light vector 1 (r8)\n"\ - "rsq r8.w, r8.w \n"\ - "mul r8, r8, r8.w \n"\ - "dp3 r9.w, r9, r9 ; normalize light vector 2 (r9)\n"\ - "rsq r9.w, r9.w \n"\ - "mul r9, r9, r9.w \n"\ - "\n"\ - "mad oT2.xyz, r8.xyz, c95, c95 ; move light vector 1 from -1..1 into 0..1 \n"\ - "mad oT3.xyz, r9.xyz, c95, c95 ; move light vector 2 from -1..1 into 0..1 \n"\ - "\n"\ - " ; calculate attenuation of light 1 \n"\ - "dp3 r2.x, r2.xyz, r2.xyz ; r2.x = r2.x + r2.y + r2.z \n"\ - "mul r2.x, r2.x, c13.w ; r2.x * attenutation \n"\ - "rsq r2, r2.x ; r2.xyzw = 1/sqrt(r2.x * attenutation)\n"\ - "mul oD0, r2, c13 ; resulting light color = lightcolor * attenuation \n"\ - "\n"\ - " ; calculate attenuation of light 2 \n"\ - "dp3 r3.x, r3.xyz, r3.xyz ; r3.x = r3.x + r3.y + r3.z \n"\ - "mul r3.x, r3.x, c15.w ; r2.x * attenutation \n"\ - "rsq r3, r3.x ; r2.xyzw = 1/sqrt(r2.x * attenutation)\n"\ - "mul oD1, r3, c15 ; resulting light color = lightcolor * attenuation \n"\ - "\n"\ - "mov oT0.xy, v3.xy ; move out texture coordinates 1\n"\ - "mov oT1.xy, v3.xy ; move out texture coordinates 2\n"\ - "mov oD0.a, v2.a ; move out original alpha value \n"\ - "\n"; - - // Irrlicht Engine D3D8 render path normal map pixel shader - const char D3D8_NORMAL_MAP_PSH[] = - ";Irrlicht Engine 0.8 D3D8 render path normal map pixel shader\n"\ - ";Input: \n"\ - ";t0: color map texture coord \n"\ - ";t1: normal map texture coords \n"\ - ";t2: light 1 vector in tangent space \n"\ - ";v0: light 1 color \n"\ - ";t3: light 2 vector in tangent space \n"\ - ";v1: light 2 color \n"\ - ";v0.a: vertex alpha value \n"\ - "ps.1.1 \n"\ - "tex t0 ; sample color map \n"\ - "tex t1 ; sample normal map\n"\ - "texcoord t2 ; fetch light vector 1\n"\ - "texcoord t3 ; fetch light vector 2\n"\ - "\n"\ - "dp3_sat r0, t1_bx2, t2_bx2 ; normal dot light 1 (_bx2 because moved into 0..1)\n"\ - "mul r0, r0, v0 ; luminance1 * light color 1 \n"\ - "\n"\ - "dp3_sat r1, t1_bx2, t3_bx2 ; normal dot light 2 (_bx2 because moved into 0..1)\n"\ - "mad r0, r1, v1, r0 ; (luminance2 * light color 2) + luminance 1 \n"\ - "\n"\ - "mul r0, t0, r0 ; total luminance * base color\n"\ - "mov r0.a, v0.a ; write interpolated vertex alpha value \n"\ - "\n"\ - ""; - - CD3D8NormalMapRenderer::CD3D8NormalMapRenderer( - IDirect3DDevice8* d3ddev, video::IVideoDriver* driver, - s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial) - : CD3D8ShaderMaterialRenderer(d3ddev, driver, 0, baseMaterial), - CompiledShaders(true) - { - - #ifdef _DEBUG - setDebugName("CD3D8NormalMapRenderer"); - #endif - - // set this as callback. We could have done this in - // the initialization list, but some compilers don't like it. - - CallBack = this; - - // basicly, this thing simply compiles these hardcoded shaders if the - // hardware is able to do them, otherwise it maps to the base material - - if (!driver->queryFeature(video::EVDF_PIXEL_SHADER_1_1) || - !driver->queryFeature(video::EVDF_VERTEX_SHADER_1_1)) - { - // this hardware is not able to do shaders. Fall back to - // base material. - outMaterialTypeNr = driver->addMaterialRenderer(this); - return; - } - - // check if already compiled normal map shaders are there. - - video::IMaterialRenderer* renderer = driver->getMaterialRenderer(EMT_NORMAL_MAP_SOLID); - if (renderer) - { - // use the already compiled shaders - video::CD3D8NormalMapRenderer* nmr = (video::CD3D8NormalMapRenderer*)renderer; - CompiledShaders = false; - - VertexShader = nmr->VertexShader; - PixelShader = nmr->PixelShader; - - outMaterialTypeNr = driver->addMaterialRenderer(this); - } - else - { - // compile shaders on our own - init(outMaterialTypeNr, D3D8_NORMAL_MAP_VSH, D3D8_NORMAL_MAP_PSH, EVT_TANGENTS); - } - // something failed, use base material - if (-1==outMaterialTypeNr) - driver->addMaterialRenderer(this); - } - - - CD3D8NormalMapRenderer::~CD3D8NormalMapRenderer() - { - if (CallBack == this) - CallBack = 0; - - if (!CompiledShaders) - { - // prevent this from deleting shaders we did not create - VertexShader = 0; - PixelShader = 0; - } - } - - - bool CD3D8NormalMapRenderer::OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype) - { - if (vtxtype != video::EVT_TANGENTS) - { - os::Printer::log("Error: Normal map renderer only supports vertices of type EVT_TANGENTS", ELL_ERROR); - return false; - } - - return CD3D8ShaderMaterialRenderer::OnRender(service, vtxtype); - } - - //! Returns the render capability of the material. - s32 CD3D8NormalMapRenderer::getRenderCapability() const - { - if (Driver->queryFeature(video::EVDF_PIXEL_SHADER_1_1) && - Driver->queryFeature(video::EVDF_VERTEX_SHADER_1_1)) - return 0; - - return 1; - } - - - //! Called by the engine when the vertex and/or pixel shader constants for an - //! material renderer should be set. - void CD3D8NormalMapRenderer::OnSetConstants(IMaterialRendererServices* services, s32 userData) - { - video::IVideoDriver* driver = services->getVideoDriver(); - - // set transposed world matrix - services->setVertexShaderConstant(driver->getTransform(video::ETS_WORLD).getTransposed().pointer(), 0, 4); - - // set transposed worldViewProj matrix - core::matrix4 worldViewProj(driver->getTransform(video::ETS_PROJECTION)); - worldViewProj *= driver->getTransform(video::ETS_VIEW); - worldViewProj *= driver->getTransform(video::ETS_WORLD); - services->setVertexShaderConstant(worldViewProj.getTransposed().pointer(), 8, 4); - - // here we've got to fetch the fixed function lights from the - // driver and set them as constants - - u32 cnt = driver->getDynamicLightCount(); - - for (u32 i=0; i<2; ++i) - { - SLight light; - - if (i<cnt) - light = driver->getDynamicLight(i); - else - { - light.DiffuseColor.set(0,0,0); // make light dark - light.Radius = 1.0f; - } - - light.DiffuseColor.a = 1.0f/(light.Radius*light.Radius); // set attenuation - - services->setVertexShaderConstant(reinterpret_cast<const f32*>(&light.Position), 12+(i*2), 1); - services->setVertexShaderConstant(reinterpret_cast<const f32*>(&light.DiffuseColor), 13+(i*2), 1); - } - - f32 c95[] = {0.5f, 0.5f, 0.5f, 0.5f}; - services->setVertexShaderConstant(c95, 95, 1); - } - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_DIRECT3D_8_ - diff --git a/irrlicht-1.6/source/Irrlicht/CD3D8NormalMapRenderer.h b/irrlicht-1.6/source/Irrlicht/CD3D8NormalMapRenderer.h deleted file mode 100644 index c4eb52651..000000000 --- a/irrlicht-1.6/source/Irrlicht/CD3D8NormalMapRenderer.h +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_D3D8_NORMAL_MAPMATERIAL_RENDERER_H_INCLUDED__ -#define __C_D3D8_NORMAL_MAPMATERIAL_RENDERER_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_WINDOWS_API_ - -#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ -#include <d3d8.h> - -#include "CD3D8ShaderMaterialRenderer.h" -#include "IShaderConstantSetCallBack.h" - -namespace irr -{ -namespace video -{ - -//! Renderer for normal maps -class CD3D8NormalMapRenderer : public CD3D8ShaderMaterialRenderer, IShaderConstantSetCallBack -{ -public: - - CD3D8NormalMapRenderer( - IDirect3DDevice8* d3ddev, video::IVideoDriver* driver, - s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial); - ~CD3D8NormalMapRenderer(); - - //! Called by the engine when the vertex and/or pixel shader constants for an - //! material renderer should be set. - virtual void OnSetConstants(IMaterialRendererServices* services, s32 userData); - - bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype); - - //! Returns the render capability of the material. - virtual s32 getRenderCapability() const; - -private: - - //! stores if this shader compiled the shaders and is - //! allowed to delete them again. D3D8 lacks reference counting - //! support for shaders. - bool CompiledShaders; - -}; - -} // end namespace video -} // end namespace irr - -#endif -#endif -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CD3D8ParallaxMapRenderer.cpp b/irrlicht-1.6/source/Irrlicht/CD3D8ParallaxMapRenderer.cpp deleted file mode 100644 index abe64a7e8..000000000 --- a/irrlicht-1.6/source/Irrlicht/CD3D8ParallaxMapRenderer.cpp +++ /dev/null @@ -1,318 +0,0 @@ -// Copyright (C) 2002-2009 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_DIRECT3D_8_ - -#include "CD3D8ParallaxMapRenderer.h" -#include "IMaterialRendererServices.h" -#include "IVideoDriver.h" -#include "os.h" -#include "SLight.h" - -namespace irr -{ -namespace video -{ - // 1.1/1.4 Shaders with two lights and vertex based attenuation - - // Irrlicht Engine D3D8 render path normal map vertex shader - const char D3D8_PARALLAX_MAP_VSH[] = - ";Irrlicht Engine 0.10 D3D8 render path parallax mapping vertex shader\n"\ - "; c0-3: Transposed world matrix \n"\ - "; c4: Eye position \n"\ - "; c8-11: Transposed worldViewProj matrix (Projection * View * World) \n"\ - "; c12: Light01 position \n"\ - "; c13: x,y,z: Light01 color; .w: 1/LightRadius \n"\ - "; c14: Light02 position \n"\ - "; c15: x,y,z: Light02 color; .w: 1/LightRadius \n"\ - "vs.1.1\n"\ - "; v0 ; position \n"\ - "; v1 ; normal \n"\ - "; v2 ; color \n"\ - "; v3 ; texture coord \n"\ - "; v4 ; tangent \n"\ - "; v5 ; binormal \n"\ - "\n"\ - "def c95, 0.5, 0.5, 0.5, 0.5 ; used for moving light vector to ps \n"\ - "def c96, -1, 1, 1, 1 ; somewhere I've got a bug. flipping the vectors with this fixes it. \n"\ - "\n"\ - "m4x4 oPos, v0, c8 ; transform position to clip space with worldViewProj matrix\n"\ - "\n"\ - "m3x3 r5, v4, c0 ; transform tangent U\n"\ - "m3x3 r7, v1, c0 ; transform normal W\n"\ - "m3x3 r6, v5, c0 ; transform binormal V\n"\ - "\n"\ - "m4x4 r4, v0, c0 ; vertex into world position\n"\ - "add r2, c12, -r4 ; vtxpos - light1 pos\n"\ - "add r3, c14, -r4 ; vtxpos - light2 pos\n"\ - "add r1, -c4, r4 ; eye - vtxpos \n"\ - "\n"\ - "dp3 r8.x, r5, r2 ; transform the light1 vector with U, V, W\n"\ - "dp3 r8.y, r6, r2 \n"\ - "dp3 r8.z, r7, r2 \n"\ - "dp3 r9.x, r5, r3 ; transform the light2 vector with U, V, W\n"\ - "dp3 r9.y, r6, r3 \n"\ - "dp3 r9.z, r7, r3 \n"\ - "dp3 r10.x, r5, r1 ; transform the eye vector with U, V, W\n"\ - "dp3 r10.y, r6, r1 \n"\ - "dp3 r10.z, r7, r1 \n"\ - "\n"\ - "dp3 r8.w, r8, r8 ; normalize light vector 1 (r8)\n"\ - "rsq r8.w, r8.w \n"\ - "mul r8, r8, r8.w \n"\ - ";mul r8, r8, c96 \n"\ - "dp3 r9.w, r9, r9 ; normalize light vector 2 (r9)\n"\ - "rsq r9.w, r9.w \n"\ - "mul r9, r9, r9.w \n"\ - ";mul r9, r9, c96 \n"\ - "dp3 r10.w, r10, r10 ; normalize eye vector (r10)\n"\ - "rsq r10.w, r10.w \n"\ - "mul r10, r10, r10.w \n"\ - "mul r10, r10, c96 \n"\ - "\n"\ - "\n"\ - "mad oT2.xyz, r8.xyz, c95, c95 ; move light vector 1 from -1..1 into 0..1 \n"\ - "mad oT3.xyz, r9.xyz, c95, c95 ; move light vector 2 from -1..1 into 0..1 \n"\ - "mad oT4.xyz, r10.xyz, c95, c95 ; move eye vector from -1..1 into 0..1 \n"\ - "\n"\ - " ; calculate attenuation of light 1 \n"\ - "dp3 r2.x, r2.xyz, r2.xyz ; r2.x = r2.x + r2.y + r2.z \n"\ - "mul r2.x, r2.x, c13.w ; r2.x * attenutation \n"\ - "rsq r2, r2.x ; r2.xyzw = 1/sqrt(r2.x * attenutation)\n"\ - "mul oD0, r2, c13 ; resulting light color = lightcolor * attenuation \n"\ - "\n"\ - " ; calculate attenuation of light 2 \n"\ - "dp3 r3.x, r3.xyz, r3.xyz ; r3.x = r3.x + r3.y + r3.z \n"\ - "mul r3.x, r3.x, c15.w ; r2.x * attenutation \n"\ - "rsq r3, r3.x ; r2.xyzw = 1/sqrt(r2.x * attenutation)\n"\ - "mul oD1, r3, c15 ; resulting light color = lightcolor * attenuation \n"\ - "\n"\ - "mov oT0.xy, v3.xy ; move out texture coordinates 1\n"\ - "mov oT1.xy, v3.xy ; move out texture coordinates 2\n"\ - "mov oD0.a, v2.a ; move out original alpha value \n"\ - "\n"; - - - // Irrlicht Engine D3D8 render path normal map pixel shader version 1.4 - const char D3D8_PARALLAX_MAP_PSH[] = - ";Irrlicht Engine 0.10 D3D8 render path parallax mapping pixel shader \n"\ - ";Input: \n"\ - ";t0: color map texture coord \n"\ - ";t1: normal map texture coords \n"\ - ";t2: light 1 vector in tangent space \n"\ - ";t4: eye vector in tangent space \n"\ - ";v0: light 1 color \n"\ - ";t3: light 2 vector in tangent space \n"\ - ";v1: light 2 color \n"\ - ";v0.a: vertex alpha value \n"\ - " \n"\ - "ps.1.4 \n"\ - " \n"\ - ";def c6, 0.02f, 0.02f, 0.02f, 0.0f ; scale factor, now set in callback \n"\ - " \n"\ - "texld r1, t1 ; sample (normal.x, normal.y, normal.z, height) \n"\ - "texcrd r4.xyz, t4 ; fetch eye vector \n"\ - "texcrd r0.xyz, t0 ; color map \n"\ - " \n"\ - "; original parallax mapping: \n"\ - ";mul r3, r1_bx2.wwww, c6; ; r3 = (height, height, height) * scale \n"\ - ";mad r2.xyz, r3, r4_bx2, r0 ; newTexCoord = height * eye + oldTexCoord \n"\ - " \n"\ - "; modified parallax mapping to reduce swimming effect: \n"\ - "mul r3, r1_bx2.wwww, r1_bx2.zzzz ; (nh,nh,nh,nh) = (h,h,h,h) * (n.z,n.z,n.z,n.z,) \n"\ - "mul r3, r3, c6; ; r3 = (nh, nh, nh) * scale \n"\ - "mad r2.xyz, r3, r4_bx2, r0 ; newTexCoord = height * eye + oldTexCoord \n"\ - " \n"\ - "phase \n"\ - " \n"\ - "texld r0, r2 ; load diffuse texture with new tex coord \n"\ - "texld r1, r2 ; sample normal map \n"\ - "texcrd r2.xyz, t2 ; fetch light vector 1 \n"\ - "texcrd r3.xyz, t3 ; fetch light vector 2 \n"\ - " \n"\ - "dp3_sat r2, r1_bx2, r2_bx2 ; normal dot light 1 (_bx2 because moved into 0..1) \n"\ - "mul r2, r2, v0 ; luminance1 * light color 1 \n"\ - " \n"\ - "dp3_sat r3, r1_bx2, r3_bx2 ; normal dot light 2 (_bx2 because moved into 0..1) \n"\ - "mad r3, r3, v1, r2 ; (luminance2 * light color 2) + luminance1 \n"\ - " \n"\ - "mul r0.xyz, r0, r3 ; total luminance * base color \n"\ - "+mov r0.a, v0.a ; write original alpha value \n"\ - "\n"; - - - CD3D8ParallaxMapRenderer::CD3D8ParallaxMapRenderer( - IDirect3DDevice8* d3ddev, video::IVideoDriver* driver, - s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial) - : CD3D8ShaderMaterialRenderer(d3ddev, driver, 0, baseMaterial), - CompiledShaders(true), CurrentScale(0.0f) - { - - #ifdef _DEBUG - setDebugName("CD3D8ParallaxMapRenderer"); - #endif - - // set this as callback. We could have done this in - // the initialization list, but some compilers don't like it. - - CallBack = this; - - // basicly, this thing simply compiles these hardcoded shaders if the - // hardware is able to do them, otherwise it maps to the base material - - if (!driver->queryFeature(video::EVDF_PIXEL_SHADER_1_4) || - !driver->queryFeature(video::EVDF_VERTEX_SHADER_1_1)) - { - // this hardware is not able to do shaders. Fall back to - // base material. - outMaterialTypeNr = driver->addMaterialRenderer(this); - return; - } - - // check if already compiled parallax map shaders are there. - - video::IMaterialRenderer* renderer = driver->getMaterialRenderer(EMT_PARALLAX_MAP_SOLID); - if (renderer) - { - // use the already compiled shaders - video::CD3D8ParallaxMapRenderer* nmr = (video::CD3D8ParallaxMapRenderer*)renderer; - CompiledShaders = false; - - VertexShader = nmr->VertexShader; - PixelShader = nmr->PixelShader; - - outMaterialTypeNr = driver->addMaterialRenderer(this); - } - else - { - // compile shaders on our own - init(outMaterialTypeNr, D3D8_PARALLAX_MAP_VSH, D3D8_PARALLAX_MAP_PSH, EVT_TANGENTS); - } - // something failed, use base material - if (-1==outMaterialTypeNr) - driver->addMaterialRenderer(this); - } - - - CD3D8ParallaxMapRenderer::~CD3D8ParallaxMapRenderer() - { - if (CallBack == this) - CallBack = 0; - - if (!CompiledShaders) - { - // prevent this from deleting shaders we did not create - VertexShader = 0; - PixelShader = 0; - } - } - - - bool CD3D8ParallaxMapRenderer::OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype) - { - if (vtxtype != video::EVT_TANGENTS) - { - os::Printer::log("Error: Normal map renderer only supports vertices of type EVT_TANGENTS", ELL_ERROR); - return false; - } - - return CD3D8ShaderMaterialRenderer::OnRender(service, vtxtype); - } - - - void CD3D8ParallaxMapRenderer::OnSetMaterial(const video::SMaterial& material, - const video::SMaterial& lastMaterial, - bool resetAllRenderstates, video::IMaterialRendererServices* services) - { - CD3D8ShaderMaterialRenderer::OnSetMaterial(material, lastMaterial, - resetAllRenderstates, services); - - CurrentScale = material.MaterialTypeParam; - } - - - //! Returns the render capability of the material. - s32 CD3D8ParallaxMapRenderer::getRenderCapability() const - { - if (Driver->queryFeature(video::EVDF_PIXEL_SHADER_1_4) && - Driver->queryFeature(video::EVDF_VERTEX_SHADER_1_1)) - return 0; - - return 1; - } - - - //! Called by the engine when the vertex and/or pixel shader constants - //! for an material renderer should be set. - void CD3D8ParallaxMapRenderer::OnSetConstants(IMaterialRendererServices* services, s32 userData) - { - video::IVideoDriver* driver = services->getVideoDriver(); - - // set transposed world matrix - services->setVertexShaderConstant(driver->getTransform(video::ETS_WORLD).getTransposed().pointer(), 0, 4); - - // set eye position - - // The viewpoint is at (0., 0., 0.) in eye space. - // Turning this into a vector [0 0 0 1] and multiply it by - // the inverse of the view matrix, the resulting vector is the - // object space location of the camera. - - f32 floats[4] = {0,0,0,1}; - core::matrix4 minv(driver->getTransform(video::ETS_VIEW)); - minv.makeInverse(); - minv.multiplyWith1x4Matrix(floats); - services->setVertexShaderConstant(floats, 4, 1); - - // set transposed worldViewProj matrix - core::matrix4 worldViewProj(driver->getTransform(video::ETS_PROJECTION)); - worldViewProj *= driver->getTransform(video::ETS_VIEW); - worldViewProj *= driver->getTransform(video::ETS_WORLD); - services->setVertexShaderConstant(worldViewProj.getTransposed().pointer(), 8, 4); - - // here we've got to fetch the fixed function lights from the driver - // and set them as constants - - const u32 cnt = driver->getDynamicLightCount(); - - for (u32 i=0; i<2; ++i) - { - SLight light; - - if (i<cnt) - light = driver->getDynamicLight(i); - else - { - light.DiffuseColor.set(0,0,0); // make light dark - light.Radius = 1.0f; - } - - light.DiffuseColor.a = 1.0f/(light.Radius*light.Radius); // set attenuation - - services->setVertexShaderConstant(reinterpret_cast<const f32*>(&light.Position), 12+(i*2), 1); - services->setVertexShaderConstant(reinterpret_cast<const f32*>(&light.DiffuseColor), 13+(i*2), 1); - } - - // this is not really necessary in d3d9 (used a def instruction), but to be sure: - f32 c95[] = {0.5f, 0.5f, 0.5f, 0.5f}; - services->setVertexShaderConstant(c95, 95, 1); - f32 c96[] = {-1, 1, 1, 1}; - services->setVertexShaderConstant(c96, 96, 1); - - // set scale factor - f32 factor = 0.02f; // default value - if (CurrentScale != 0) - factor = CurrentScale; - - f32 c6[] = {factor, factor, factor, 0}; - services->setPixelShaderConstant(c6, 6, 1); - } - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_DIRECT3D_8_ - diff --git a/irrlicht-1.6/source/Irrlicht/CD3D8ParallaxMapRenderer.h b/irrlicht-1.6/source/Irrlicht/CD3D8ParallaxMapRenderer.h deleted file mode 100644 index 38f8f52dc..000000000 --- a/irrlicht-1.6/source/Irrlicht/CD3D8ParallaxMapRenderer.h +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_D3D8_PARALLAX_MAPMATERIAL_RENDERER_H_INCLUDED__ -#define __C_D3D8_PARALLAX_MAPMATERIAL_RENDERER_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_WINDOWS_API_ - -#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ -#include <d3d8.h> - -#include "CD3D8ShaderMaterialRenderer.h" -#include "IShaderConstantSetCallBack.h" - -namespace irr -{ -namespace video -{ - -//! Renderer for parallax maps -class CD3D8ParallaxMapRenderer : public CD3D8ShaderMaterialRenderer, IShaderConstantSetCallBack -{ -public: - - CD3D8ParallaxMapRenderer( - IDirect3DDevice8* d3ddev, video::IVideoDriver* driver, - s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial); - ~CD3D8ParallaxMapRenderer(); - - //! Called by the engine when the vertex and/or pixel shader constants for an - //! material renderer should be set. - virtual void OnSetConstants(IMaterialRendererServices* services, s32 userData); - - virtual bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype); - - virtual void OnSetMaterial(const SMaterial& material) { } - virtual void OnSetMaterial(const video::SMaterial& material, - const video::SMaterial& lastMaterial, - bool resetAllRenderstates, video::IMaterialRendererServices* services); - - //! Returns the render capability of the material. - virtual s32 getRenderCapability() const; - -private: - - //! stores if this shader compiled the shaders and is - //! allowed to delete them again. D3D8 lacks reference counting - //! support for shaders. - bool CompiledShaders; - - f32 CurrentScale; -}; - -} // end namespace video -} // end namespace irr - -#endif -#endif -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CD3D8ShaderMaterialRenderer.cpp b/irrlicht-1.6/source/Irrlicht/CD3D8ShaderMaterialRenderer.cpp deleted file mode 100644 index 00d34b37d..000000000 --- a/irrlicht-1.6/source/Irrlicht/CD3D8ShaderMaterialRenderer.cpp +++ /dev/null @@ -1,332 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CD3D8ShaderMaterialRenderer.h" - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ -#include <d3d8.h> -#include <d3dx8core.h> -#pragma comment (lib, "d3dx8.lib") - -#include "IShaderConstantSetCallBack.h" -#include "IMaterialRendererServices.h" -#include "IVideoDriver.h" -#include "os.h" - -#ifndef _IRR_D3D_NO_SHADER_DEBUGGING -#include <stdio.h> -#endif - -namespace irr -{ -namespace video -{ - -//! Public constructor -CD3D8ShaderMaterialRenderer::CD3D8ShaderMaterialRenderer(IDirect3DDevice8* d3ddev, video::IVideoDriver* driver, - s32& outMaterialTypeNr, const c8* vertexShaderProgram, const c8* pixelShaderProgram, - IShaderConstantSetCallBack* callback, IMaterialRenderer* baseMaterial, s32 userData) -: pID3DDevice(d3ddev), Driver(driver), CallBack(callback), BaseMaterial(baseMaterial), - VertexShader(0), OldVertexShader(0), PixelShader(0), UserData(userData) -{ - - #ifdef _DEBUG - setDebugName("CD3D8ShaderMaterialRenderer"); - #endif - - if (BaseMaterial) - BaseMaterial->grab(); - - if (CallBack) - CallBack->grab(); - - init(outMaterialTypeNr, vertexShaderProgram, pixelShaderProgram, EVT_STANDARD); -} - -//! constructor only for use by derived classes who want to -//! create a fall back material for example. -CD3D8ShaderMaterialRenderer::CD3D8ShaderMaterialRenderer(IDirect3DDevice8* d3ddev, - video::IVideoDriver* driver, - IShaderConstantSetCallBack* callback, - IMaterialRenderer* baseMaterial, - s32 userData) -: pID3DDevice(d3ddev), Driver(driver), BaseMaterial(baseMaterial), CallBack(callback), - VertexShader(0), PixelShader(0), UserData(userData) -{ - if (BaseMaterial) - BaseMaterial->grab(); - - if (CallBack) - CallBack->grab(); -} - - - -//! Destructor -CD3D8ShaderMaterialRenderer::~CD3D8ShaderMaterialRenderer() -{ - if (CallBack) - CallBack->drop(); - - if (VertexShader) - pID3DDevice->DeleteVertexShader(VertexShader); - - if (PixelShader) - pID3DDevice->DeletePixelShader(PixelShader); - - if (BaseMaterial) - BaseMaterial->drop (); -} - - -void CD3D8ShaderMaterialRenderer::init(s32& outMaterialTypeNr, const c8* vertexShaderProgram, - const c8* pixelShaderProgram, E_VERTEX_TYPE type) -{ - outMaterialTypeNr = -1; - - // create vertex shader - if (!createVertexShader(vertexShaderProgram, type)) - return; - - // create pixel shader - if (!createPixelShader(pixelShaderProgram)) - return; - - // register myself as new material - outMaterialTypeNr = Driver->addMaterialRenderer(this); -} - - -bool CD3D8ShaderMaterialRenderer::OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype) -{ - // call callback to set shader constants - if (CallBack && (VertexShader || PixelShader)) - CallBack->OnSetConstants(service, UserData); - - return true; -} - - -void CD3D8ShaderMaterialRenderer::OnSetMaterial(const video::SMaterial& material, const video::SMaterial& lastMaterial, - bool resetAllRenderstates, video::IMaterialRendererServices* services) -{ - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - if (VertexShader) - { - // We do not need to save and reset the old vertex shader, because - // in D3D8, this is mixed up with the fvf, and this is set by the driver - // every time. - //pID3DDevice->GetVertexShader(&OldVertexShader); - - // set new vertex shader - if (FAILED(pID3DDevice->SetVertexShader(VertexShader))) - os::Printer::log("Could not set vertex shader.", ELL_ERROR); - } - - // set new pixel shader - if (PixelShader) - { - if (FAILED(pID3DDevice->SetPixelShader(PixelShader))) - os::Printer::log("Could not set pixel shader.", ELL_ERROR); - } - - if (BaseMaterial) - BaseMaterial->OnSetMaterial(material, material, true, services); - } - - //let callback know used material - if (CallBack) - CallBack->OnSetMaterial(material); - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); -} - -void CD3D8ShaderMaterialRenderer::OnUnsetMaterial() -{ - // We do not need to save and reset the old vertex shader, because - // in D3D8, this is mixed up with the fvf, and this is set by the driver - // every time. - // if (VertexShader) - // pID3DDevice->SetVertexShader(OldVertexShader); - - if (PixelShader) - pID3DDevice->SetPixelShader(0); - - if (BaseMaterial) - BaseMaterial->OnUnsetMaterial(); -} - - -//! Returns if the material is transparent. The scene managment needs to know this -//! for being able to sort the materials by opaque and transparent. -bool CD3D8ShaderMaterialRenderer::isTransparent() const -{ - return BaseMaterial ? BaseMaterial->isTransparent() : false; -} - -bool CD3D8ShaderMaterialRenderer::createPixelShader(const c8* pxsh) -{ - if (!pxsh) - return true; - -#if defined( _IRR_XBOX_PLATFORM_) - return false; -#else - // compile shader - - LPD3DXBUFFER code = 0; - LPD3DXBUFFER errors = 0; - - #ifdef _IRR_D3D_NO_SHADER_DEBUGGING - - // compile shader without debug info - D3DXAssembleShader(pxsh, (UINT)strlen(pxsh), 0, 0, &code, &errors); - - #else - - // compile shader and emitt some debug informations to - // make it possible to debug the shader in visual studio - - static int irr_dbg_file_nr = 0; - ++irr_dbg_file_nr; - char tmp[32]; - sprintf(tmp, "irr_d3d8_dbg_shader_%d.psh", irr_dbg_file_nr); - - FILE* f = fopen(tmp, "wb"); - fwrite(pxsh, strlen(pxsh), 1, f); - fflush(f); - fclose(f); - - D3DXAssembleShaderFromFile(tmp, D3DXASM_DEBUG, 0, &code, &errors); - #endif - if (errors) - { - // print out compilation errors. - os::Printer::log("Pixel shader compilation failed:", ELL_ERROR); - os::Printer::log((c8*)errors->GetBufferPointer(), ELL_ERROR); - - if (code) - code->Release(); - - errors->Release(); - return false; - } - - if (FAILED(pID3DDevice->CreatePixelShader((DWORD*)code->GetBufferPointer(), &PixelShader))) - { - os::Printer::log("Could not create pixel shader.", ELL_ERROR); - code->Release(); - return false; - } - - code->Release(); - return true; -#endif - -} - - - -bool CD3D8ShaderMaterialRenderer::createVertexShader(const char* vtxsh, E_VERTEX_TYPE type) -{ - if (!vtxsh) - return true; - - // compile shader -#if defined( _IRR_XBOX_PLATFORM_) - return false; -#else - - LPD3DXBUFFER code = 0; - LPD3DXBUFFER errors = 0; - - #ifdef _IRR_D3D_NO_SHADER_DEBUGGING - - // compile shader without debug info - D3DXAssembleShader(vtxsh, (UINT)strlen(vtxsh), 0, 0, &code, &errors); - - #else - - // compile shader and emitt some debug informations to - // make it possible to debug the shader in visual studio - static int irr_dbg_file_nr = 0; - ++irr_dbg_file_nr; - char tmp[32]; - sprintf(tmp, "irr_d3d8_dbg_shader_%d.vsh", irr_dbg_file_nr); - - FILE* f = fopen(tmp, "wb"); - fwrite(vtxsh, strlen(vtxsh), 1, f); - fflush(f); - fclose(f); - - D3DXAssembleShaderFromFile(tmp, D3DXASM_DEBUG, 0, &code, &errors); - - #endif - - - if (errors) - { - // print out compilation errors. - os::Printer::log("Vertex shader compilation failed:", ELL_ERROR); - os::Printer::log((c8*)errors->GetBufferPointer(), ELL_ERROR); - - if (code) - code->Release(); - - errors->Release(); - return false; - } - - DWORD* decl = 0; - - DWORD dwStdDecl[] = - { - D3DVSD_STREAM(0), - D3DVSD_REG(0, D3DVSDT_FLOAT3), // position 0 - D3DVSD_REG(1, D3DVSDT_FLOAT3), // normal 1 - D3DVSD_REG(2, D3DVSDT_D3DCOLOR ),// color 2 - D3DVSD_REG(3, D3DVSDT_FLOAT2 ), // tex1 3 - D3DVSD_REG(4, D3DVSDT_FLOAT2 ), // tex2 4 - D3DVSD_END() - }; - - DWORD dwTngtDecl[] = - { - D3DVSD_STREAM(0), - D3DVSD_REG(0 , D3DVSDT_FLOAT3), // position 0 - D3DVSD_REG(1 , D3DVSDT_FLOAT3), // normal 1 - D3DVSD_REG(2 , D3DVSDT_D3DCOLOR ),// color 2 - D3DVSD_REG(3 , D3DVSDT_FLOAT2 ), // tex1 3 - D3DVSD_REG(4, D3DVSDT_FLOAT3 ), // tangent 4 - D3DVSD_REG(5, D3DVSDT_FLOAT3 ), // binormal 5 - D3DVSD_END() - }; - - if (type == EVT_TANGENTS) - decl = dwTngtDecl; - else - decl = dwStdDecl; - - if (FAILED(pID3DDevice->CreateVertexShader(decl, - (DWORD*)code->GetBufferPointer(), &VertexShader, 0))) - { - os::Printer::log("Could not create vertex shader.", ELL_ERROR); - code->Release(); - return false; - } - - code->Release(); - return true; -#endif -} - - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_DIRECT3D_8_ - diff --git a/irrlicht-1.6/source/Irrlicht/CD3D8ShaderMaterialRenderer.h b/irrlicht-1.6/source/Irrlicht/CD3D8ShaderMaterialRenderer.h deleted file mode 100644 index a50573d3e..000000000 --- a/irrlicht-1.6/source/Irrlicht/CD3D8ShaderMaterialRenderer.h +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_D3D8_SHADER_MATERIAL_RENDERER_H_INCLUDED__ -#define __C_D3D8_SHADER_MATERIAL_RENDERER_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_WINDOWS_API_ - -#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ -#include <d3d8.h> -#include <d3dx8core.h> - -#include "IMaterialRenderer.h" -#include "S3DVertex.h" - -namespace irr -{ -namespace video -{ - -class IVideoDriver; -class IShaderConstantSetCallBack; -class IMaterialRenderer; - -//! Class for using vertex and pixel shaders with D3D8 -class CD3D8ShaderMaterialRenderer : public IMaterialRenderer -{ -public: - - //! Public constructor - CD3D8ShaderMaterialRenderer(IDirect3DDevice8* d3ddev, video::IVideoDriver* driver, - s32& outMaterialTypeNr, const c8* vertexShaderProgram, const c8* pixelShaderProgram, - IShaderConstantSetCallBack* callback, IMaterialRenderer* baseMaterial, s32 userData); - - //! Destructor - ~CD3D8ShaderMaterialRenderer(); - - virtual void OnSetMaterial(const video::SMaterial& material, const video::SMaterial& lastMaterial, - bool resetAllRenderstates, video::IMaterialRendererServices* services); - - virtual void OnUnsetMaterial(); - - virtual bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype); - - //! Returns if the material is transparent. - virtual bool isTransparent() const; - -protected: - - //! constructor only for use by derived classes who want to - //! create a fall back material for example. - CD3D8ShaderMaterialRenderer(IDirect3DDevice8* d3ddev, - video::IVideoDriver* driver, - IShaderConstantSetCallBack* callback, - IMaterialRenderer* baseMaterial, s32 userData=0); - - void init(s32& outMaterialTypeNr, const c8* vertexShaderProgram, const c8* pixelShaderProgram, - E_VERTEX_TYPE type); - bool createPixelShader(const c8* pxsh); - bool createVertexShader(const char* vtxsh, E_VERTEX_TYPE type); - - IDirect3DDevice8* pID3DDevice; - video::IVideoDriver* Driver; - IShaderConstantSetCallBack* CallBack; - IMaterialRenderer* BaseMaterial; - - DWORD VertexShader; - DWORD OldVertexShader; - DWORD PixelShader; - s32 UserData; -}; - - -} // end namespace video -} // end namespace irr - -#endif -#endif -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CD3D8Texture.cpp b/irrlicht-1.6/source/Irrlicht/CD3D8Texture.cpp deleted file mode 100644 index 34ea33b22..000000000 --- a/irrlicht-1.6/source/Irrlicht/CD3D8Texture.cpp +++ /dev/null @@ -1,625 +0,0 @@ -// Copyright (C) 2002-2009 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_DIRECT3D_8_ - -#define _IRR_DONT_DO_MEMORY_DEBUGGING_HERE -#include "CD3D8Texture.h" -#include "CD3D8Driver.h" -#include "os.h" - - -#ifndef _IRR_COMPILE_WITH_DIRECT3D_9_ -// The D3DXFilterTexture function seems to get linked wrong when -// compiling with both D3D8 and 9, causing it not to work in the D3D9 device. -// So mipmapgeneration is replaced with my own bad generation in d3d 8 when -// compiling with both D3D 8 and 9. -//#define _IRR_USE_D3DXFilterTexture_ -#endif // _IRR_COMPILE_WITH_DIRECT3D_9_ - -#include <d3dx8tex.h> - -#ifdef _IRR_USE_D3DXFilterTexture_ -#pragma comment (lib, "d3dx8.lib") -#endif // _IRR_USE_D3DXFilterTexture_ - -namespace irr -{ -namespace video -{ - -//! rendertarget constructor -CD3D8Texture::CD3D8Texture(CD3D8Driver* driver, const core::dimension2d<u32>& size, const io::path& name) -: ITexture(name), Texture(0), RTTSurface(0), Driver(driver), - TextureSize(size), ImageSize(size), Pitch(0), - HasMipMaps(false), IsRenderTarget(true) -{ - #ifdef _DEBUG - setDebugName("CD3D8Texture"); - #endif - - Device=driver->getExposedVideoData().D3D8.D3DDev8; - if (Device) - Device->AddRef(); - - createRenderTarget(); -} - - -//! constructor -CD3D8Texture::CD3D8Texture(IImage* image, CD3D8Driver* driver, - u32 flags, const io::path& name) -: ITexture(name), Texture(0), RTTSurface(0), Driver(driver), -TextureSize(0,0), ImageSize(0,0), Pitch(0), -HasMipMaps(false), IsRenderTarget(false) -{ - #ifdef _DEBUG - setDebugName("CD3D8Texture"); - #endif - - const bool generateMipLevels = Driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS); - - Device=driver->getExposedVideoData().D3D8.D3DDev8; - if (Device) - Device->AddRef(); - - if (image) - { - if (createTexture(image, flags)) - { - if (copyTexture(image) && generateMipLevels) - { - // create mip maps. - - #ifndef _IRR_USE_D3DXFilterTexture_ - // The D3DXFilterTexture function seems to get linked wrong when - // compiling with both D3D8 and 9, causing it not to work in the D3D9 device. - // So mipmapgeneration is replaced with my own bad generation in d3d 8 when - // compiling with both D3D 8 and 9. - HRESULT hr = D3DXFilterTexture(Texture, NULL, D3DX_DEFAULT , D3DX_DEFAULT ); - if (FAILED(hr)) - os::Printer::log("Could not create direct3d mip map levels.", ELL_WARNING); - else - HasMipMaps = true; - #else - createMipMaps(); - HasMipMaps = true; - #endif - } - } - else - os::Printer::log("Could not create DIRECT3D8 Texture.", ELL_WARNING); - } -} - - -//! destructor -CD3D8Texture::~CD3D8Texture() -{ - if (Texture) - Texture->Release(); - - if (RTTSurface) - RTTSurface->Release(); - - if (Device) - Device->Release(); -} - - -//! creates the hardware texture -bool CD3D8Texture::createTexture(video::IImage* image, u32 flags) -{ - ImageSize = image->getDimension(); - - core::dimension2d<u32> optSize = ImageSize.getOptimalSize(!Driver->queryFeature(EVDF_TEXTURE_NPOT), !Driver->queryFeature(EVDF_TEXTURE_NSQUARE), true, Driver->Caps.MaxTextureWidth); - - D3DFORMAT format = D3DFMT_A1R5G5B5; - switch(getTextureFormatFromFlags(flags)) - { - case ETCF_ALWAYS_16_BIT: - format = D3DFMT_A1R5G5B5; break; - case ETCF_ALWAYS_32_BIT: - format = D3DFMT_A8R8G8B8; break; - case ETCF_OPTIMIZED_FOR_QUALITY: - { - switch(image->getColorFormat()) - { - case ECF_R8G8B8: - case ECF_A8R8G8B8: - format = D3DFMT_A8R8G8B8; break; - case ECF_A1R5G5B5: - case ECF_R5G6B5: - format = D3DFMT_A1R5G5B5; break; - } - } - break; - case ETCF_OPTIMIZED_FOR_SPEED: - format = D3DFMT_A1R5G5B5; break; - } - - if (Driver->getTextureCreationFlag(video::ETCF_NO_ALPHA_CHANNEL)) - { - if (format == D3DFMT_A8R8G8B8) - -#ifdef _IRR_XBOX_PLATFORM_ - format = D3DFMT_X8R8G8B8; -#else - format = D3DFMT_R8G8B8; -#endif - - else if (format == D3DFMT_A1R5G5B5) - format = D3DFMT_R5G6B5; - } - - const bool mipmaps = Driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS); - - HRESULT hr = Device->CreateTexture(optSize.Width, optSize.Height, - mipmaps ? 0 : 1, // number of mipmaplevels (0 = automatic all) - 0, format, D3DPOOL_MANAGED, &Texture); - - if (FAILED(hr)) - { - // try brute force 16 bit - if (format == D3DFMT_A8R8G8B8) - format = D3DFMT_A1R5G5B5; -#ifdef _IRR_XBOX_PLATFORM_ - else if (format == D3DFMT_X8R8G8B8) - format = D3DFMT_R5G6B5; -#else - else if (format == D3DFMT_R8G8B8) - format = D3DFMT_R5G6B5; -#endif - else - return false; - - hr = Device->CreateTexture(optSize.Width, optSize.Height, - mipmaps ? 0 : 1, // number of mipmaplevels (0 = automatic all) - 0, format, D3DPOOL_MANAGED, &Texture); - } - - ColorFormat = getColorFormatFromD3DFormat(format); - return (SUCCEEDED(hr)); -} - - -//! copies the image to the texture -bool CD3D8Texture::copyTexture(video::IImage* image) -{ - if (Texture && image) - { - D3DSURFACE_DESC desc; - Texture->GetLevelDesc(0, &desc); - - TextureSize.Width = desc.Width; - TextureSize.Height = desc.Height; - - D3DLOCKED_RECT rect; - HRESULT hr = Texture->LockRect(0, &rect, 0, 0); - if (FAILED(hr)) - { - os::Printer::log("Could not lock D3D8 Texture.", ELL_ERROR); - return false; - } - - Pitch = rect.Pitch; - image->copyToScaling(rect.pBits, TextureSize.Width, TextureSize.Height, ColorFormat, Pitch); - - hr = Texture->UnlockRect(0); - if (FAILED(hr)) - { - os::Printer::log("Could not unlock D3D8 Texture.", ELL_ERROR); - return false; - } - } - - return true; -} - - -//! lock function -void* CD3D8Texture::lock(bool readOnly) -{ - if (!Texture) - return 0; - - HRESULT hr; - D3DLOCKED_RECT rect; - if(!IsRenderTarget) - { - hr = Texture->LockRect(0, &rect, 0, readOnly?D3DLOCK_READONLY:0); - } - else - { - D3DSURFACE_DESC desc; - Texture->GetLevelDesc(0, &desc); - if (!RTTSurface) - { - hr = Device->CreateImageSurface(desc.Width, desc.Height, desc.Format, &RTTSurface); - if (FAILED(hr)) - { - os::Printer::log("Could not lock DIRECT3D8 Texture.", ELL_ERROR); - return 0; - } - } - - IDirect3DSurface8 *surface = 0; - hr = Texture->GetSurfaceLevel(0, &surface); - if (FAILED(hr)) - { - os::Printer::log("Could not lock DIRECT3D8 Texture.", ELL_ERROR); - return 0; - } - hr = Device->CopyRects(surface, 0, 0, RTTSurface, 0); - surface->Release(); - if(FAILED(hr)) - { - os::Printer::log("Could not lock DIRECT3D8 Texture.", ELL_ERROR); - return 0; - } - hr = RTTSurface->LockRect(&rect, 0, readOnly?D3DLOCK_READONLY:0); - if(FAILED(hr)) - { - os::Printer::log("Could not lock DIRECT3D8 Texture.", ELL_ERROR); - return 0; - } - return rect.pBits; - } - if (FAILED(hr)) - { - os::Printer::log("Could not lock DIRECT3D8 Texture.", ELL_ERROR); - return 0; - } - - return rect.pBits; -} - - -//! unlock function -void CD3D8Texture::unlock() -{ - if (!Texture) - return; - - if (!IsRenderTarget) - Texture->UnlockRect(0); - else if (RTTSurface) - RTTSurface->UnlockRect(); -} - - -//! Returns original size of the texture. -const core::dimension2d<u32>& CD3D8Texture::getOriginalSize() const -{ - return ImageSize; -} - - -//! Returns (=size) of the texture. -const core::dimension2d<u32>& CD3D8Texture::getSize() const -{ - return TextureSize; -} - - -//! returns driver type of texture (=the driver, who created the texture) -E_DRIVER_TYPE CD3D8Texture::getDriverType() const -{ - return EDT_DIRECT3D8; -} - - -//! returns color format of texture -ECOLOR_FORMAT CD3D8Texture::getColorFormat() const -{ - return ColorFormat; -} - - -//! returns pitch of texture (in bytes) -u32 CD3D8Texture::getPitch() const -{ - return Pitch; -} - - -//! returns the DIRECT3D8 Texture -IDirect3DTexture8* CD3D8Texture::getDX8Texture() const -{ - return Texture; -} - - -//! returns if texture has mipmap levels -bool CD3D8Texture::hasMipMaps() const -{ - return HasMipMaps; -} - - -// The D3DXFilterTexture function seems to get linked wrong when -// compiling with both D3D8 and 9, causing it not to work in the D3D9 device. -// So mipmapgeneration is replaced with my own bad generation in d3d 8 when -// compiling with both D3D 8 and 9. -bool CD3D8Texture::createMipMaps(u32 level) -{ - if (level==0) - return true; - - IDirect3DSurface8* upperSurface = 0; - IDirect3DSurface8* lowerSurface = 0; - - // get upper level - HRESULT hr = Texture->GetSurfaceLevel(level-1, &upperSurface); - if (FAILED(hr) || !upperSurface) - { - os::Printer::log("Could not get upper surface level for mip map generation", ELL_WARNING); - return false; - } - - // get lower level - hr = Texture->GetSurfaceLevel(level, &lowerSurface); - if (FAILED(hr) || !lowerSurface) - { - os::Printer::log("Could not get lower surface level for mip map generation", ELL_WARNING); - upperSurface->Release(); - return false; - } - - D3DSURFACE_DESC upperDesc, lowerDesc; - upperSurface->GetDesc(&upperDesc); - lowerSurface->GetDesc(&lowerDesc); - - D3DLOCKED_RECT upperlr; - D3DLOCKED_RECT lowerlr; - - // lock upper surface - if (FAILED(upperSurface->LockRect(&upperlr, NULL, 0))) - { - os::Printer::log("Could not lock upper texture for mip map generation", ELL_WARNING); - upperSurface->Release(); - lowerSurface->Release(); - return false; - } - - // lock lower surface - if (FAILED(lowerSurface->LockRect(&lowerlr, NULL, 0))) - { - os::Printer::log("Could not lock lower texture for mip map generation", ELL_WARNING); - upperSurface->UnlockRect(); - upperSurface->Release(); - lowerSurface->Release(); - return false; - } - - if (upperDesc.Format != lowerDesc.Format) - { - os::Printer::log("Cannot copy mip maps with different formats.", ELL_WARNING); - } - else - { - if (upperDesc.Format == D3DFMT_A1R5G5B5) - copy16BitMipMap((char*)upperlr.pBits, (char*)lowerlr.pBits, - lowerDesc.Width, lowerDesc.Height, - upperlr.Pitch, lowerlr.Pitch); - else - if (upperDesc.Format == D3DFMT_A8R8G8B8) - copy32BitMipMap((char*)upperlr.pBits, (char*)lowerlr.pBits, - lowerDesc.Width, lowerDesc.Height, - upperlr.Pitch, lowerlr.Pitch); - else - os::Printer::log("Unsupported mipmap format, cannot copy.", ELL_WARNING); - } - - bool result=true; - // unlock - if (FAILED(upperSurface->UnlockRect())) - result=false; - if (FAILED(lowerSurface->UnlockRect())) - result=false; - - // release - upperSurface->Release(); - lowerSurface->Release(); - - if (!result || upperDesc.Width < 3 || upperDesc.Height < 3) - return result; // stop generating levels - - // generate next level - return createMipMaps(level+1); -} - - -ECOLOR_FORMAT CD3D8Texture::getColorFormatFromD3DFormat(D3DFORMAT format) -{ - switch(format) - { - case D3DFMT_X1R5G5B5: - case D3DFMT_A1R5G5B5: - Pitch = TextureSize.Width * 2; - return ECF_A1R5G5B5; - break; - case D3DFMT_A8R8G8B8: - case D3DFMT_X8R8G8B8: - Pitch = TextureSize.Width * 4; - return ECF_A8R8G8B8; - break; - case D3DFMT_R5G6B5: - Pitch = TextureSize.Width * 2; - return ECF_R5G6B5; - break; - default: - return (ECOLOR_FORMAT)0; - }; -} - - - -void CD3D8Texture::copy16BitMipMap(char* src, char* tgt, - s32 width, s32 height, - s32 pitchsrc, s32 pitchtgt) const -{ - u16 c; - - for (int x=0; x<width; ++x) - { - for (int y=0; y<height; ++y) - { - s32 a=0, r=0, g=0, b=0; - - for (int dx=0; dx<2; ++dx) - { - for (int dy=0; dy<2; ++dy) - { - int tgx = (x*2)+dx; - int tgy = (y*2)+dy; - - c = *(u16*)((void*)&src[(tgx*2)+(tgy*pitchsrc)]); - - a += getAlpha(c); - r += getRed(c); - g += getGreen(c); - b += getBlue(c); - } - } - - a /= 4; - r /= 4; - g /= 4; - b /= 4; - - c = ((a & 0x1) <<15) | ((r & 0x1F)<<10) | ((g & 0x1F)<<5) | (b & 0x1F); - *(u16*)((void*)&tgt[(x*2)+(y*pitchtgt)]) = c; - } - } -} - - -void CD3D8Texture::copy32BitMipMap(char* src, char* tgt, - s32 width, s32 height, - s32 pitchsrc, s32 pitchtgt) const -{ - SColor c; - - for (int x=0; x<width; ++x) - { - for (int y=0; y<height; ++y) - { - s32 a=0, r=0, g=0, b=0; - - for (int dx=0; dx<2; ++dx) - { - for (int dy=0; dy<2; ++dy) - { - int tgx = (x*2)+dx; - int tgy = (y*2)+dy; - - c = *(u32*)((void*)&src[(tgx<<2)+(tgy*pitchsrc)]); - - a += c.getAlpha(); - r += c.getRed(); - g += c.getGreen(); - b += c.getBlue(); - } - } - - a >>= 2; - r >>= 2; - g >>= 2; - b >>= 2; - - c = ((a & 0xff)<<24) | ((r & 0xff)<<16) | ((g & 0xff)<<8) | (b & 0xff); - *(u32*)((void*)&tgt[(x*4)+(y*pitchtgt)]) = c.color; - } - } -} - - -void CD3D8Texture::createRenderTarget() -{ - TextureSize = TextureSize.getOptimalSize(!Driver->queryFeature(EVDF_TEXTURE_NPOT), !Driver->queryFeature(EVDF_TEXTURE_NSQUARE), true, Driver->Caps.MaxTextureWidth); - - // get backbuffer format to create the render target in the - // same format - - IDirect3DSurface8* bb; - D3DFORMAT d3DFormat = D3DFMT_A8R8G8B8; - - if (!FAILED(Device->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &bb))) - { - D3DSURFACE_DESC desc; - bb->GetDesc(&desc); - d3DFormat = desc.Format; - - if (d3DFormat == D3DFMT_X8R8G8B8) - d3DFormat = D3DFMT_A8R8G8B8; - - bb->Release(); - } - else - { - os::Printer::log("Could not create RenderTarget texture: could not get BackBuffer.", - ELL_WARNING); - return; - } - - // create texture - HRESULT hr; - - hr = Device->CreateTexture( - TextureSize.Width, - TextureSize.Height, - 1, // mip map level count, we don't want mipmaps here - D3DUSAGE_RENDERTARGET, - d3DFormat, - D3DPOOL_DEFAULT, - &Texture); - - // get irrlicht format from D3D format - ColorFormat = getColorFormatFromD3DFormat(d3DFormat); - - if (FAILED(hr)) - os::Printer::log("Could not create render target texture"); -} - - -//! Regenerates the mip map levels of the texture. Useful after locking and -//! modifying the texture -void CD3D8Texture::regenerateMipMapLevels() -{ - if (HasMipMaps) - createMipMaps(); -} - - -//! returns if it is a render target -bool CD3D8Texture::isRenderTarget() const -{ - return IsRenderTarget; -} - - -//! Returns pointer to the render target surface -IDirect3DSurface8* CD3D8Texture::getRenderTargetSurface() -{ - if (!IsRenderTarget) - return 0; - - IDirect3DSurface8 *pRTTSurface = 0; - if (Texture) - Texture->GetSurfaceLevel(0, &pRTTSurface); - - if (pRTTSurface) - pRTTSurface->Release(); - - return pRTTSurface; -} - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_DIRECT3D_8_ - diff --git a/irrlicht-1.6/source/Irrlicht/CD3D8Texture.h b/irrlicht-1.6/source/Irrlicht/CD3D8Texture.h deleted file mode 100644 index f1b3751c0..000000000 --- a/irrlicht-1.6/source/Irrlicht/CD3D8Texture.h +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_DIRECTX8_TEXTURE_H_INCLUDED__ -#define __C_DIRECTX8_TEXTURE_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ - -#include "ITexture.h" -#include "IImage.h" - -#include <d3d8.h> - -namespace irr -{ -namespace video -{ - -class CD3D8Driver; - -/*! - interface for a Video Driver dependent Texture. -*/ -class CD3D8Texture : public ITexture -{ -public: - - //! constructor - CD3D8Texture(IImage* image, CD3D8Driver* driver, - u32 flags, const io::path& name); - - //! rendertarget constructor - CD3D8Texture(CD3D8Driver* driver, const core::dimension2d<u32>& size, const io::path& name); - - //! destructor - virtual ~CD3D8Texture(); - - //! lock function - virtual void* lock(bool readOnly = false); - - //! unlock function - virtual void unlock(); - - //! Returns original size of the texture. - virtual const core::dimension2d<u32>& getOriginalSize() const; - - //! Returns (=size) of the texture. - virtual const core::dimension2d<u32>& getSize() const; - - //! returns driver type of texture (=the driver, who created the texture) - virtual E_DRIVER_TYPE getDriverType() const; - - //! returns color format of texture - virtual ECOLOR_FORMAT getColorFormat() const; - - //! returns pitch of texture (in bytes) - virtual u32 getPitch() const; - - //! returns the DIRECT3D8 Texture - IDirect3DTexture8* getDX8Texture() const; - - //! returns if texture has mipmap levels - bool hasMipMaps() const; - - //! Regenerates the mip map levels of the texture. Useful after locking and - //! modifying the texture - virtual void regenerateMipMapLevels(); - - //! returns if it is a render target - virtual bool isRenderTarget() const; - - //! Returns pointer to the render target surface - IDirect3DSurface8* getRenderTargetSurface(); - -private: - friend class CD3D8Driver; - - void createRenderTarget(); - - //! creates the hardware texture - bool createTexture(IImage* Image, u32 flags); - - //! copies the image to the texture - bool copyTexture(IImage* Image); - - //! convert color formats - ECOLOR_FORMAT getColorFormatFromD3DFormat(D3DFORMAT format); - - bool createMipMaps(u32 level=1); - - void copy16BitMipMap(char* src, char* tgt, - s32 width, s32 height, s32 pitchsrc, s32 pitchtgt) const; - - void copy32BitMipMap(char* src, char* tgt, - s32 width, s32 height, s32 pitchsrc, s32 pitchtgt) const; - - IDirect3DDevice8* Device; - IDirect3DTexture8* Texture; - IDirect3DSurface8* RTTSurface; - CD3D8Driver* Driver; - core::dimension2d<u32> TextureSize; - core::dimension2d<u32> ImageSize; - s32 Pitch; - ECOLOR_FORMAT ColorFormat; - bool HasMipMaps; - bool IsRenderTarget; -}; - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_DIRECT3D_8_ - -#endif // __C_DIRECTX8_TEXTURE_H_INCLUDED__ - diff --git a/irrlicht-1.6/source/Irrlicht/CD3D9Driver.cpp b/irrlicht-1.6/source/Irrlicht/CD3D9Driver.cpp deleted file mode 100644 index 090a85ea3..000000000 --- a/irrlicht-1.6/source/Irrlicht/CD3D9Driver.cpp +++ /dev/null @@ -1,3146 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#define _IRR_DONT_DO_MEMORY_DEBUGGING_HERE -#include "CD3D9Driver.h" - -#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ - -#include "os.h" -#include "S3DVertex.h" -#include "CD3D9Texture.h" -#include "CImage.h" -#include "CD3D9MaterialRenderer.h" -#include "CD3D9ShaderMaterialRenderer.h" -#include "CD3D9NormalMapRenderer.h" -#include "CD3D9ParallaxMapRenderer.h" -#include "CD3D9HLSLMaterialRenderer.h" - -namespace irr -{ -namespace video -{ - -//! constructor -CD3D9Driver::CD3D9Driver(const core::dimension2d<u32>& screenSize, HWND window, - bool fullscreen, bool stencilbuffer, - io::IFileSystem* io, bool pureSoftware) -: CNullDriver(io, screenSize), CurrentRenderMode(ERM_NONE), - ResetRenderStates(true), Transformation3DChanged(false), - StencilBuffer(stencilbuffer), AntiAliasing(0), - D3DLibrary(0), pID3D(0), pID3DDevice(0), PrevRenderTarget(0), - WindowId(0), SceneSourceRect(0), - LastVertexType((video::E_VERTEX_TYPE)-1), VendorID(0), - MaxTextureUnits(0), MaxUserClipPlanes(0), - MaxLightDistance(0.f), LastSetLight(-1), Cached2DModeSignature(0), - ColorFormat(ECF_A8R8G8B8), DeviceLost(false), - Fullscreen(fullscreen), DriverWasReset(true), AlphaToCoverageSupport(false) -{ - #ifdef _DEBUG - setDebugName("CD3D9Driver"); - #endif - - printVersion(); - - for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i) - { - CurrentTexture[i] = 0; - LastTextureMipMapsAvailable[i] = false; - } - MaxLightDistance = sqrtf(FLT_MAX); - // create sphere map matrix - - SphereMapMatrixD3D9._11 = 0.5f; SphereMapMatrixD3D9._12 = 0.0f; - SphereMapMatrixD3D9._13 = 0.0f; SphereMapMatrixD3D9._14 = 0.0f; - SphereMapMatrixD3D9._21 = 0.0f; SphereMapMatrixD3D9._22 =-0.5f; - SphereMapMatrixD3D9._23 = 0.0f; SphereMapMatrixD3D9._24 = 0.0f; - SphereMapMatrixD3D9._31 = 0.0f; SphereMapMatrixD3D9._32 = 0.0f; - SphereMapMatrixD3D9._33 = 1.0f; SphereMapMatrixD3D9._34 = 0.0f; - SphereMapMatrixD3D9._41 = 0.5f; SphereMapMatrixD3D9._42 = 0.5f; - SphereMapMatrixD3D9._43 = 0.0f; SphereMapMatrixD3D9._44 = 1.0f; - - core::matrix4 mat; - UnitMatrixD3D9 = *(D3DMATRIX*)((void*)mat.pointer()); - - // init direct 3d is done in the factory function -} - - -//! destructor -CD3D9Driver::~CD3D9Driver() -{ - deleteMaterialRenders(); - deleteAllTextures(); - - // drop the main depth buffer - DepthBuffers[0]->drop(); - - // drop d3d9 - - if (pID3DDevice) - pID3DDevice->Release(); - - if (pID3D) - pID3D->Release(); -} - - -void CD3D9Driver::createMaterialRenderers() -{ - // create D3D9 material renderers - - addAndDropMaterialRenderer(new CD3D9MaterialRenderer_SOLID(pID3DDevice, this)); - addAndDropMaterialRenderer(new CD3D9MaterialRenderer_SOLID_2_LAYER(pID3DDevice, this)); - - // add the same renderer for all lightmap types - - CD3D9MaterialRenderer_LIGHTMAP* lmr = new CD3D9MaterialRenderer_LIGHTMAP(pID3DDevice, this); - addMaterialRenderer(lmr); // for EMT_LIGHTMAP: - addMaterialRenderer(lmr); // for EMT_LIGHTMAP_ADD: - addMaterialRenderer(lmr); // for EMT_LIGHTMAP_M2: - addMaterialRenderer(lmr); // for EMT_LIGHTMAP_M4: - addMaterialRenderer(lmr); // for EMT_LIGHTMAP_LIGHTING: - addMaterialRenderer(lmr); // for EMT_LIGHTMAP_LIGHTING_M2: - addMaterialRenderer(lmr); // for EMT_LIGHTMAP_LIGHTING_M4: - lmr->drop(); - - // add remaining fixed function pipeline material renderers - - addAndDropMaterialRenderer(new CD3D9MaterialRenderer_DETAIL_MAP(pID3DDevice, this)); - addAndDropMaterialRenderer(new CD3D9MaterialRenderer_SPHERE_MAP(pID3DDevice, this)); - addAndDropMaterialRenderer(new CD3D9MaterialRenderer_REFLECTION_2_LAYER(pID3DDevice, this)); - addAndDropMaterialRenderer(new CD3D9MaterialRenderer_TRANSPARENT_ADD_COLOR(pID3DDevice, this)); - addAndDropMaterialRenderer(new CD3D9MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL(pID3DDevice, this)); - addAndDropMaterialRenderer(new CD3D9MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF(pID3DDevice, this)); - addAndDropMaterialRenderer(new CD3D9MaterialRenderer_TRANSPARENT_VERTEX_ALPHA(pID3DDevice, this)); - addAndDropMaterialRenderer(new CD3D9MaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER(pID3DDevice, this)); - - // add normal map renderers - - s32 tmp = 0; - video::IMaterialRenderer* renderer = 0; - - renderer = new CD3D9NormalMapRenderer(pID3DDevice, this, tmp, - MaterialRenderers[EMT_SOLID].Renderer); - renderer->drop(); - - renderer = new CD3D9NormalMapRenderer(pID3DDevice, this, tmp, - MaterialRenderers[EMT_TRANSPARENT_ADD_COLOR].Renderer); - renderer->drop(); - - renderer = new CD3D9NormalMapRenderer(pID3DDevice, this, tmp, - MaterialRenderers[EMT_TRANSPARENT_VERTEX_ALPHA].Renderer); - renderer->drop(); - - // add parallax map renderers - - renderer = new CD3D9ParallaxMapRenderer(pID3DDevice, this, tmp, - MaterialRenderers[EMT_SOLID].Renderer); - renderer->drop(); - - renderer = new CD3D9ParallaxMapRenderer(pID3DDevice, this, tmp, - MaterialRenderers[EMT_TRANSPARENT_ADD_COLOR].Renderer); - renderer->drop(); - - renderer = new CD3D9ParallaxMapRenderer(pID3DDevice, this, tmp, - MaterialRenderers[EMT_TRANSPARENT_VERTEX_ALPHA].Renderer); - renderer->drop(); - - // add basic 1 texture blending - addAndDropMaterialRenderer(new CD3D9MaterialRenderer_ONETEXTURE_BLEND(pID3DDevice, this)); -} - - -//! initialises the Direct3D API -bool CD3D9Driver::initDriver(const core::dimension2d<u32>& screenSize, - HWND hwnd, u32 bits, bool fullScreen, bool pureSoftware, - bool highPrecisionFPU, bool vsync, u8 antiAlias) -{ - HRESULT hr; - Fullscreen = fullScreen; - CurrentDepthBufferSize = screenSize; - - if (!pID3D) - { - D3DLibrary = LoadLibrary( "d3d9.dll" ); - - if (!D3DLibrary) - { - os::Printer::log("Error, could not load d3d9.dll.", ELL_ERROR); - return false; - } - - typedef IDirect3D9 * (__stdcall *D3DCREATETYPE)(UINT); - D3DCREATETYPE d3dCreate = (D3DCREATETYPE) GetProcAddress(D3DLibrary, "Direct3DCreate9"); - - if (!d3dCreate) - { - os::Printer::log("Error, could not get proc adress of Direct3DCreate9.", ELL_ERROR); - return false; - } - - //just like pID3D = Direct3DCreate9(D3D_SDK_VERSION); - pID3D = (*d3dCreate)(D3D_SDK_VERSION); - - if (!pID3D) - { - os::Printer::log("Error initializing D3D.", ELL_ERROR); - return false; - } - } - - // print device information - D3DADAPTER_IDENTIFIER9 dai; - if (!FAILED(pID3D->GetAdapterIdentifier(D3DADAPTER_DEFAULT, 0, &dai))) - { - char tmp[512]; - - s32 Product = HIWORD(dai.DriverVersion.HighPart); - s32 Version = LOWORD(dai.DriverVersion.HighPart); - s32 SubVersion = HIWORD(dai.DriverVersion.LowPart); - s32 Build = LOWORD(dai.DriverVersion.LowPart); - - sprintf(tmp, "%s %s %d.%d.%d.%d", dai.Description, dai.Driver, Product, Version, - SubVersion, Build); - os::Printer::log(tmp, ELL_INFORMATION); - - // Assign vendor name based on vendor id. - VendorID= static_cast<u16>(dai.VendorId); - switch(dai.VendorId) - { - case 0x1002 : VendorName = "ATI Technologies Inc."; break; - case 0x10DE : VendorName = "NVIDIA Corporation"; break; - case 0x102B : VendorName = "Matrox Electronic Systems Ltd."; break; - case 0x121A : VendorName = "3dfx Interactive Inc"; break; - case 0x5333 : VendorName = "S3 Graphics Co., Ltd."; break; - case 0x8086 : VendorName = "Intel Corporation"; break; - default: VendorName = "Unknown VendorId: ";VendorName += (u32)dai.VendorId; break; - } - } - - D3DDISPLAYMODE d3ddm; - hr = pID3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm); - if (FAILED(hr)) - { - os::Printer::log("Error: Could not get Adapter Display mode.", ELL_ERROR); - return false; - } - - ZeroMemory(&present, sizeof(present)); - - present.BackBufferCount = 1; - present.EnableAutoDepthStencil = TRUE; - if (vsync) - present.PresentationInterval = D3DPRESENT_INTERVAL_ONE; - else - present.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; - - if (fullScreen) - { - present.BackBufferWidth = screenSize.Width; - present.BackBufferHeight = screenSize.Height; - // request 32bit mode if user specified 32 bit, added by Thomas Stuefe - if (bits == 32) - present.BackBufferFormat = D3DFMT_X8R8G8B8; - else - present.BackBufferFormat = D3DFMT_R5G6B5; - present.SwapEffect = D3DSWAPEFFECT_FLIP; - present.Windowed = FALSE; - present.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; - } - else - { - present.BackBufferFormat = d3ddm.Format; - present.SwapEffect = D3DSWAPEFFECT_DISCARD; - present.Windowed = TRUE; - } - - UINT adapter = D3DADAPTER_DEFAULT; - D3DDEVTYPE devtype = D3DDEVTYPE_HAL; - #ifndef _IRR_D3D_NO_SHADER_DEBUGGING - devtype = D3DDEVTYPE_REF; - #elif defined(_IRR_USE_NVIDIA_PERFHUD_) - for (UINT adapter_i = 0; adapter_i < pID3D->GetAdapterCount(); ++adapter_i) - { - D3DADAPTER_IDENTIFIER9 identifier; - pID3D->GetAdapterIdentifier(adapter_i,0,&identifier); - if (strstr(identifier.Description,"PerfHUD") != 0) - { - adapter = adapter_i; - devtype = D3DDEVTYPE_REF; - break; - } - } - #endif - - // enable anti alias if possible and desired - if (antiAlias > 0) - { - if(antiAlias > 16) - antiAlias = 16; - - DWORD qualityLevels = 0; - - while(antiAlias > 0) - { - if(SUCCEEDED(pID3D->CheckDeviceMultiSampleType(adapter, - devtype, present.BackBufferFormat, !fullScreen, - (D3DMULTISAMPLE_TYPE)antiAlias, &qualityLevels))) - { - present.MultiSampleType = (D3DMULTISAMPLE_TYPE)antiAlias; - present.MultiSampleQuality = qualityLevels-1; - present.SwapEffect = D3DSWAPEFFECT_DISCARD; - break; - } - --antiAlias; - } - - if(antiAlias==0) - { - os::Printer::log("Anti aliasing disabled because hardware/driver lacks necessary caps.", ELL_WARNING); - } - } - AntiAliasing = antiAlias; - - // check stencil buffer compatibility - if (StencilBuffer) - { - present.AutoDepthStencilFormat = D3DFMT_D24S8; - if(FAILED(pID3D->CheckDeviceFormat(adapter, devtype, - present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, - D3DRTYPE_SURFACE, present.AutoDepthStencilFormat))) - { - present.AutoDepthStencilFormat = D3DFMT_D24X4S4; - if(FAILED(pID3D->CheckDeviceFormat(adapter, devtype, - present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, - D3DRTYPE_SURFACE, present.AutoDepthStencilFormat))) - { - present.AutoDepthStencilFormat = D3DFMT_D15S1; - if(FAILED(pID3D->CheckDeviceFormat(adapter, devtype, - present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, - D3DRTYPE_SURFACE, present.AutoDepthStencilFormat))) - { - os::Printer::log("Device does not support stencilbuffer, disabling stencil buffer.", ELL_WARNING); - StencilBuffer = false; - } - } - } - else - if(FAILED(pID3D->CheckDepthStencilMatch(adapter, devtype, - present.BackBufferFormat, present.BackBufferFormat, present.AutoDepthStencilFormat))) - { - os::Printer::log("Depth-stencil format is not compatible with display format, disabling stencil buffer.", ELL_WARNING); - StencilBuffer = false; - } - } - // do not use else here to cope with flag change in previous block - if (!StencilBuffer) - { - present.AutoDepthStencilFormat = D3DFMT_D32; - if(FAILED(pID3D->CheckDeviceFormat(adapter, devtype, - present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, - D3DRTYPE_SURFACE, present.AutoDepthStencilFormat))) - { - present.AutoDepthStencilFormat = D3DFMT_D24X8; - if(FAILED(pID3D->CheckDeviceFormat(adapter, devtype, - present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, - D3DRTYPE_SURFACE, present.AutoDepthStencilFormat))) - { - present.AutoDepthStencilFormat = D3DFMT_D16; - if(FAILED(pID3D->CheckDeviceFormat(adapter, devtype, - present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL, - D3DRTYPE_SURFACE, present.AutoDepthStencilFormat))) - { - os::Printer::log("Device does not support required depth buffer.", ELL_WARNING); - return false; - } - } - } - } - - // create device - - DWORD fpuPrecision = highPrecisionFPU ? D3DCREATE_FPU_PRESERVE : 0; - if (pureSoftware) - { - hr = pID3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_REF, hwnd, - fpuPrecision | D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present, &pID3DDevice); - - if (FAILED(hr)) - os::Printer::log("Was not able to create Direct3D9 software device.", ELL_ERROR); - } - else - { - hr = pID3D->CreateDevice(adapter, devtype, hwnd, - fpuPrecision | D3DCREATE_HARDWARE_VERTEXPROCESSING, &present, &pID3DDevice); - - if(FAILED(hr)) - hr = pID3D->CreateDevice(adapter, devtype, hwnd, - fpuPrecision | D3DCREATE_MIXED_VERTEXPROCESSING , &present, &pID3DDevice); - - if(FAILED(hr)) - hr = pID3D->CreateDevice(adapter, devtype, hwnd, - fpuPrecision | D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present, &pID3DDevice); - - if (FAILED(hr)) - os::Printer::log("Was not able to create Direct3D9 device.", ELL_ERROR); - } - - if (!pID3DDevice) - { - os::Printer::log("Was not able to create DIRECT3D9 device.", ELL_ERROR); - return false; - } - - // get caps - pID3DDevice->GetDeviceCaps(&Caps); - - // disable stencilbuffer if necessary - if (StencilBuffer && - (!(Caps.StencilCaps & D3DSTENCILCAPS_DECRSAT) || - !(Caps.StencilCaps & D3DSTENCILCAPS_INCRSAT) || - !(Caps.StencilCaps & D3DSTENCILCAPS_KEEP))) - { - os::Printer::log("Device not able to use stencil buffer, disabling stencil buffer.", ELL_WARNING); - StencilBuffer = false; - } - - // set default vertex shader - setVertexShader(EVT_STANDARD); - - // set fog mode - setFog(FogColor, FogType, FogStart, FogEnd, FogDensity, PixelFog, RangeFog); - - // set exposed data - ExposedData.D3D9.D3D9 = pID3D; - ExposedData.D3D9.D3DDev9 = pID3DDevice; - ExposedData.D3D9.HWnd = hwnd; - - ResetRenderStates = true; - - // create materials - createMaterialRenderers(); - - MaxTextureUnits = core::min_((u32)Caps.MaxSimultaneousTextures, MATERIAL_MAX_TEXTURES); - MaxUserClipPlanes = (u32)Caps.MaxUserClipPlanes; - - if (VendorID==0x10DE)//NVidia - AlphaToCoverageSupport = (pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, - D3DFMT_X8R8G8B8, 0,D3DRTYPE_SURFACE, - (D3DFORMAT)MAKEFOURCC('A', 'T', 'O', 'C')) == S_OK); - else if (VendorID==0x1002)//ATI - AlphaToCoverageSupport = true; // TODO: Check unknown -#if 0 - AlphaToCoverageSupport = (pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, - D3DFMT_X8R8G8B8, 0,D3DRTYPE_SURFACE, - (D3DFORMAT)MAKEFOURCC('A','2','M','1')) == S_OK); -#endif - // set the renderstates - setRenderStates3DMode(); - - // store the screen's depth buffer - DepthBuffers.push_back(new SDepthSurface()); - if (SUCCEEDED(pID3DDevice->GetDepthStencilSurface(&(DepthBuffers[0]->Surface)))) - { - D3DSURFACE_DESC desc; - DepthBuffers[0]->Surface->GetDesc(&desc); - DepthBuffers[0]->Size.set(desc.Width, desc.Height); - } - else - { - os::Printer::log("Was not able to get main depth buffer.", ELL_ERROR); - return false; - } - - D3DColorFormat = D3DFMT_A8R8G8B8; - IDirect3DSurface9* bb=0; - if (SUCCEEDED(pID3DDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &bb))) - { - D3DSURFACE_DESC desc; - bb->GetDesc(&desc); - D3DColorFormat = desc.Format; - - if (D3DColorFormat == D3DFMT_X8R8G8B8) - D3DColorFormat = D3DFMT_A8R8G8B8; - - bb->Release(); - } - ColorFormat = getColorFormatFromD3DFormat(D3DColorFormat); - - // so far so good. - return true; -} - - -//! applications must call this method before performing any rendering. returns false if failed. -bool CD3D9Driver::beginScene(bool backBuffer, bool zBuffer, SColor color, - void* windowId, core::rect<s32>* sourceRect) -{ - CNullDriver::beginScene(backBuffer, zBuffer, color, windowId, sourceRect); - WindowId = windowId; - SceneSourceRect = sourceRect; - - if (!pID3DDevice) - return false; - - HRESULT hr; - if (DeviceLost) - { - if (FAILED(hr = pID3DDevice->TestCooperativeLevel())) - { - if (hr == D3DERR_DEVICELOST) - { - Sleep(100); - hr = pID3DDevice->TestCooperativeLevel(); - if (hr == D3DERR_DEVICELOST) - return false; - } - - if ((hr == D3DERR_DEVICENOTRESET) && !reset()) - return false; - } - } - - DWORD flags = 0; - - if (backBuffer) - flags |= D3DCLEAR_TARGET; - - if (zBuffer) - flags |= D3DCLEAR_ZBUFFER; - - if (StencilBuffer) - flags |= D3DCLEAR_STENCIL; - - hr = pID3DDevice->Clear( 0, NULL, flags, color.color, 1.0, 0); - if (FAILED(hr)) - os::Printer::log("DIRECT3D9 clear failed.", ELL_WARNING); - - hr = pID3DDevice->BeginScene(); - if (FAILED(hr)) - { - os::Printer::log("DIRECT3D9 begin scene failed.", ELL_WARNING); - return false; - } - - return true; -} - - -//! applications must call this method after performing any rendering. returns false if failed. -bool CD3D9Driver::endScene() -{ - CNullDriver::endScene(); - DriverWasReset=false; - - HRESULT hr = pID3DDevice->EndScene(); - if (FAILED(hr)) - { - os::Printer::log("DIRECT3D9 end scene failed.", ELL_WARNING); - return false; - } - - RECT* srcRct = 0; - RECT sourceRectData; - if ( SceneSourceRect ) - { - srcRct = &sourceRectData; - sourceRectData.left = SceneSourceRect->UpperLeftCorner.X; - sourceRectData.top = SceneSourceRect->UpperLeftCorner.Y; - sourceRectData.right = SceneSourceRect->LowerRightCorner.X; - sourceRectData.bottom = SceneSourceRect->LowerRightCorner.Y; - } - - hr = pID3DDevice->Present(srcRct, NULL, (HWND)WindowId, NULL); - - if (SUCCEEDED(hr)) - return true; - - if (hr == D3DERR_DEVICELOST) - { - DeviceLost = true; - os::Printer::log("Present failed", "DIRECT3D9 device lost.", ELL_WARNING); - } -#ifdef D3DERR_DEVICEREMOVED - else if (hr == D3DERR_DEVICEREMOVED) - { - os::Printer::log("Present failed", "Device removed.", ELL_WARNING); - } -#endif - else if (hr == D3DERR_INVALIDCALL) - { - os::Printer::log("Present failed", "Invalid Call", ELL_WARNING); - } - else - os::Printer::log("DIRECT3D9 present failed.", ELL_WARNING); - return false; -} - - -//! queries the features of the driver, returns true if feature is available -bool CD3D9Driver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const -{ - if (!FeatureEnabled[feature]) - return false; - - switch (feature) - { - case EVDF_MULTITEXTURE: - case EVDF_BILINEAR_FILTER: - return true; - case EVDF_RENDER_TO_TARGET: - return Caps.NumSimultaneousRTs > 0; - case EVDF_HARDWARE_TL: - return (Caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) != 0; - case EVDF_MIP_MAP: - return (Caps.TextureCaps & D3DPTEXTURECAPS_MIPMAP) != 0; - case EVDF_MIP_MAP_AUTO_UPDATE: - // always return false because a lot of drivers claim they do - // this but actually don't do this at all. - return false; //(Caps.Caps2 & D3DCAPS2_CANAUTOGENMIPMAP) != 0; - case EVDF_STENCIL_BUFFER: - return StencilBuffer && Caps.StencilCaps; - case EVDF_VERTEX_SHADER_1_1: - return Caps.VertexShaderVersion >= D3DVS_VERSION(1,1); - case EVDF_VERTEX_SHADER_2_0: - return Caps.VertexShaderVersion >= D3DVS_VERSION(2,0); - case EVDF_VERTEX_SHADER_3_0: - return Caps.VertexShaderVersion >= D3DVS_VERSION(3,0); - case EVDF_PIXEL_SHADER_1_1: - return Caps.PixelShaderVersion >= D3DPS_VERSION(1,1); - case EVDF_PIXEL_SHADER_1_2: - return Caps.PixelShaderVersion >= D3DPS_VERSION(1,2); - case EVDF_PIXEL_SHADER_1_3: - return Caps.PixelShaderVersion >= D3DPS_VERSION(1,3); - case EVDF_PIXEL_SHADER_1_4: - return Caps.PixelShaderVersion >= D3DPS_VERSION(1,4); - case EVDF_PIXEL_SHADER_2_0: - return Caps.PixelShaderVersion >= D3DPS_VERSION(2,0); - case EVDF_PIXEL_SHADER_3_0: - return Caps.PixelShaderVersion >= D3DPS_VERSION(3,0); - case EVDF_HLSL: - return Caps.VertexShaderVersion >= D3DVS_VERSION(1,1); - case EVDF_TEXTURE_NSQUARE: - return (Caps.TextureCaps & D3DPTEXTURECAPS_SQUAREONLY) == 0; - case EVDF_TEXTURE_NPOT: - return (Caps.TextureCaps & D3DPTEXTURECAPS_POW2) == 0; - case EVDF_COLOR_MASK: - return (Caps.PrimitiveMiscCaps & D3DPMISCCAPS_COLORWRITEENABLE) != 0; - default: - return false; - }; -} - - -//! sets transformation -void CD3D9Driver::setTransform(E_TRANSFORMATION_STATE state, - const core::matrix4& mat) -{ - Transformation3DChanged = true; - - switch(state) - { - case ETS_VIEW: - pID3DDevice->SetTransform(D3DTS_VIEW, (D3DMATRIX*)((void*)mat.pointer())); - break; - case ETS_WORLD: - pID3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX*)((void*)mat.pointer())); - break; - case ETS_PROJECTION: - pID3DDevice->SetTransform( D3DTS_PROJECTION, (D3DMATRIX*)((void*)mat.pointer())); - break; - case ETS_COUNT: - return; - default: - if (state-ETS_TEXTURE_0 < MATERIAL_MAX_TEXTURES) - { - if (mat.isIdentity()) - pID3DDevice->SetTextureStageState( state - ETS_TEXTURE_0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE ); - else - { - pID3DDevice->SetTextureStageState( state - ETS_TEXTURE_0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 ); - pID3DDevice->SetTransform((D3DTRANSFORMSTATETYPE)(D3DTS_TEXTURE0+ ( state - ETS_TEXTURE_0 )), - (D3DMATRIX*)((void*)mat.pointer())); - } - } - break; - } - - Matrices[state] = mat; -} - - -//! sets the current Texture -bool CD3D9Driver::setActiveTexture(u32 stage, const video::ITexture* texture) -{ - if (CurrentTexture[stage] == texture) - return true; - - if (texture && texture->getDriverType() != EDT_DIRECT3D9) - { - os::Printer::log("Fatal Error: Tried to set a texture not owned by this driver.", ELL_ERROR); - return false; - } - - CurrentTexture[stage] = texture; - - if (!texture) - { - pID3DDevice->SetTexture(stage, 0); - pID3DDevice->SetTextureStageState( stage, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE ); - } - else - { - pID3DDevice->SetTexture(stage, ((const CD3D9Texture*)texture)->getDX9Texture()); - } - return true; -} - - -//! sets a material -void CD3D9Driver::setMaterial(const SMaterial& material) -{ - Material = material; - OverrideMaterial.apply(Material); - - for (u32 i=0; i<MaxTextureUnits; ++i) - { - setActiveTexture(i, Material.getTexture(i)); - setTransform((E_TRANSFORMATION_STATE) ( ETS_TEXTURE_0 + i ), - material.getTextureMatrix(i)); - } -} - - -//! returns a device dependent texture from a software surface (IImage) -video::ITexture* CD3D9Driver::createDeviceDependentTexture(IImage* surface,const io::path& name) -{ - return new CD3D9Texture(surface, this, TextureCreationFlags, name); -} - - -//! Enables or disables a texture creation flag. -void CD3D9Driver::setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, - bool enabled) -{ - if (flag == video::ETCF_CREATE_MIP_MAPS && !queryFeature(EVDF_MIP_MAP)) - enabled = false; - - CNullDriver::setTextureCreationFlag(flag, enabled); -} - - -//! sets a render target -bool CD3D9Driver::setRenderTarget(video::ITexture* texture, - bool clearBackBuffer, bool clearZBuffer, SColor color) -{ - // check for right driver type - - if (texture && texture->getDriverType() != EDT_DIRECT3D9) - { - os::Printer::log("Fatal Error: Tried to set a texture not owned by this driver.", ELL_ERROR); - return false; - } - - // check for valid render target - - if (texture && !texture->isRenderTarget()) - { - os::Printer::log("Fatal Error: Tried to set a non render target texture as render target.", ELL_ERROR); - return false; - } - - CD3D9Texture* tex = static_cast<CD3D9Texture*>(texture); - - // check if we should set the previous RT back - - bool ret = true; - - if (tex == 0) - { - if (PrevRenderTarget) - { - if (FAILED(pID3DDevice->SetRenderTarget(0, PrevRenderTarget))) - { - os::Printer::log("Error: Could not set back to previous render target.", ELL_ERROR); - ret = false; - } - if (FAILED(pID3DDevice->SetDepthStencilSurface(DepthBuffers[0]->Surface))) - { - os::Printer::log("Error: Could not set main depth buffer.", ELL_ERROR); - } - - CurrentRendertargetSize = core::dimension2d<u32>(0,0); - PrevRenderTarget->Release(); - PrevRenderTarget = 0; - } - } - else - { - // we want to set a new target. so do this. - - // store previous target - - if (!PrevRenderTarget) - { - if (FAILED(pID3DDevice->GetRenderTarget(0, &PrevRenderTarget))) - { - os::Printer::log("Could not get previous render target.", ELL_ERROR); - return false; - } - } - - // set new render target - - if (FAILED(pID3DDevice->SetRenderTarget(0, tex->getRenderTargetSurface()))) - { - os::Printer::log("Error: Could not set render target.", ELL_ERROR); - return false; - } - CurrentRendertargetSize = tex->getSize(); - - if (FAILED(pID3DDevice->SetDepthStencilSurface(tex->DepthSurface->Surface))) - { - os::Printer::log("Error: Could not set new depth buffer.", ELL_ERROR); - } - } - - if (clearBackBuffer || clearZBuffer) - { - DWORD flags = 0; - - if (clearBackBuffer) - flags |= D3DCLEAR_TARGET; - - if (clearZBuffer) - flags |= D3DCLEAR_ZBUFFER; - - pID3DDevice->Clear(0, NULL, flags, color.color, 1.0f, 0); - } - - return ret; -} - - -//! sets a viewport -void CD3D9Driver::setViewPort(const core::rect<s32>& area) -{ - core::rect<s32> vp = area; - core::rect<s32> rendert(0,0, getCurrentRenderTargetSize().Width, getCurrentRenderTargetSize().Height); - vp.clipAgainst(rendert); - - D3DVIEWPORT9 viewPort; - viewPort.X = vp.UpperLeftCorner.X; - viewPort.Y = vp.UpperLeftCorner.Y; - viewPort.Width = vp.getWidth(); - viewPort.Height = vp.getHeight(); - viewPort.MinZ = 0.0f; - viewPort.MaxZ = 1.0f; - - HRESULT hr = D3DERR_INVALIDCALL; - if (vp.getHeight()>0 && vp.getWidth()>0) - hr = pID3DDevice->SetViewport(&viewPort); - - if (FAILED(hr)) - os::Printer::log("Failed setting the viewport.", ELL_WARNING); - - ViewPort = vp; -} - - -//! gets the area of the current viewport -const core::rect<s32>& CD3D9Driver::getViewPort() const -{ - return ViewPort; -} - - -bool CD3D9Driver::updateVertexHardwareBuffer(SHWBufferLink_d3d9 *hwBuffer) -{ - if (!hwBuffer) - return false; - - const scene::IMeshBuffer* mb = hwBuffer->MeshBuffer; - const void* vertices=mb->getVertices(); - const u32 vertexCount=mb->getVertexCount(); - const E_VERTEX_TYPE vType=mb->getVertexType(); - const u32 vertexSize = getVertexPitchFromType(vType); - - void* pLockedBuffer = 0; - - if (!hwBuffer->vertexBuffer || vertexSize * vertexCount > hwBuffer->vertexBufferSize) - { - DWORD flags = 0; - - u32 vertexSize; - DWORD FVF; - - // Get the vertex sizes and cvf - switch (vType) - { - case EVT_STANDARD: - vertexSize = sizeof(S3DVertex); - FVF = D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX1; - break; - case EVT_2TCOORDS: - vertexSize = sizeof(S3DVertex2TCoords); - FVF = D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX2; - break; - case EVT_TANGENTS: - vertexSize = sizeof(S3DVertexTangents); - FVF = D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX3; - break; - default: - return false; - } - - flags = D3DUSAGE_WRITEONLY; // SIO2: Default to D3DUSAGE_WRITEONLY - if(hwBuffer->Mapped_Vertex != scene::EHM_STATIC) - flags |= D3DUSAGE_DYNAMIC; - - pID3DDevice->CreateVertexBuffer(vertexCount * vertexSize, flags, FVF, D3DPOOL_DEFAULT, &hwBuffer->vertexBuffer, NULL); - - if(!hwBuffer->vertexBuffer) - return false; - - flags = 0; // SIO2: Reset flags before Lock - if(hwBuffer->Mapped_Vertex != scene::EHM_STATIC) - flags = D3DLOCK_DISCARD; - - hwBuffer->vertexBuffer->Lock(0, vertexCount * vertexSize, (void**)&pLockedBuffer, flags); - memcpy(pLockedBuffer, vertices, vertexCount * vertexSize); - hwBuffer->vertexBuffer->Unlock(); - - hwBuffer->vertexBufferSize = vertexCount * vertexSize; - } - else - { - hwBuffer->vertexBuffer->Lock(0, vertexCount * vertexSize, (void**)&pLockedBuffer, D3DLOCK_DISCARD); - memcpy(pLockedBuffer, vertices, vertexCount * vertexSize); - hwBuffer->vertexBuffer->Unlock(); - } - - return true; -} - - -bool CD3D9Driver::updateIndexHardwareBuffer(SHWBufferLink_d3d9 *hwBuffer) -{ - if (!hwBuffer) - return false; - - const scene::IMeshBuffer* mb = hwBuffer->MeshBuffer; - const u16* indices=mb->getIndices(); - const u32 indexCount=mb->getIndexCount(); - u32 indexSize = 2; - D3DFORMAT indexType=D3DFMT_UNKNOWN; - switch (mb->getIndexType()) - { - case (EIT_16BIT): - { - indexType=D3DFMT_INDEX16; - indexSize = 2; - break; - } - case (EIT_32BIT): - { - indexType=D3DFMT_INDEX32; - indexSize = 4; - break; - } - } - - if (!hwBuffer->indexBuffer || indexSize * indexCount > hwBuffer->indexBufferSize) - { - DWORD flags = 0; - - flags = D3DUSAGE_WRITEONLY; // SIO2: Default to D3DUSAGE_WRITEONLY - if(hwBuffer->Mapped_Index != scene::EHM_STATIC) - flags |= D3DUSAGE_DYNAMIC; // SIO2: Add DYNAMIC flag for dynamic buffer data - - if(FAILED(pID3DDevice->CreateIndexBuffer( indexCount * indexSize, flags, indexType, D3DPOOL_DEFAULT, &hwBuffer->indexBuffer, NULL))) - return false; - - void* pIndices = 0; - - flags = 0; // SIO2: Reset flags before Lock - if(hwBuffer->Mapped_Index != scene::EHM_STATIC) - flags = D3DLOCK_DISCARD; - - if(FAILED(hwBuffer->indexBuffer->Lock( 0, 0, (void**)&pIndices, flags))) - return false; - - memcpy(pIndices, indices, indexCount * indexSize); - hwBuffer->indexBuffer->Unlock(); - - hwBuffer->indexBufferSize = indexCount * indexSize; - } - else - { - void* pIndices = 0; - if( SUCCEEDED(hwBuffer->indexBuffer->Lock( 0, 0, (void**)&pIndices, D3DLOCK_DISCARD))) - { - memcpy(pIndices, indices, indexCount * indexSize); - hwBuffer->indexBuffer->Unlock(); - } - } - - return true; -} - - -//! updates hardware buffer if needed -bool CD3D9Driver::updateHardwareBuffer(SHWBufferLink *hwBuffer) -{ - if (!hwBuffer) - return false; - - if (hwBuffer->Mapped_Vertex!=scene::EHM_NEVER) - { - if (hwBuffer->ChangedID_Vertex != hwBuffer->MeshBuffer->getChangedID_Vertex() - || !((SHWBufferLink_d3d9*)hwBuffer)->vertexBuffer) - { - - hwBuffer->ChangedID_Vertex = hwBuffer->MeshBuffer->getChangedID_Vertex(); - - if (!updateVertexHardwareBuffer((SHWBufferLink_d3d9*)hwBuffer)) - return false; - } - } - - if (hwBuffer->Mapped_Index!=scene::EHM_NEVER) - { - if (hwBuffer->ChangedID_Index != hwBuffer->MeshBuffer->getChangedID_Index() - || !((SHWBufferLink_d3d9*)hwBuffer)->indexBuffer) - { - - hwBuffer->ChangedID_Index = hwBuffer->MeshBuffer->getChangedID_Index(); - - if (!updateIndexHardwareBuffer((SHWBufferLink_d3d9*)hwBuffer)) - return false; - } - } - - return true; -} - - -//! Create hardware buffer from meshbuffer -CD3D9Driver::SHWBufferLink *CD3D9Driver::createHardwareBuffer(const scene::IMeshBuffer* mb) -{ - if (!mb || (mb->getHardwareMappingHint_Index()==scene::EHM_NEVER && mb->getHardwareMappingHint_Vertex()==scene::EHM_NEVER)) - return 0; - - SHWBufferLink_d3d9 *hwBuffer=new SHWBufferLink_d3d9(mb); - - //add to map - HWBufferMap.insert(hwBuffer->MeshBuffer, hwBuffer); - - hwBuffer->ChangedID_Vertex=hwBuffer->MeshBuffer->getChangedID_Vertex(); - hwBuffer->ChangedID_Index=hwBuffer->MeshBuffer->getChangedID_Index(); - hwBuffer->Mapped_Vertex=mb->getHardwareMappingHint_Vertex(); - hwBuffer->Mapped_Index=mb->getHardwareMappingHint_Index(); - hwBuffer->LastUsed=0; - hwBuffer->vertexBuffer=0; - hwBuffer->indexBuffer=0; - hwBuffer->vertexBufferSize=0; - hwBuffer->indexBufferSize=0; - - if (!updateHardwareBuffer(hwBuffer)) - { - deleteHardwareBuffer(hwBuffer); - return 0; - } - - return hwBuffer; -} - - -void CD3D9Driver::deleteHardwareBuffer(SHWBufferLink *_HWBuffer) -{ - if (!_HWBuffer) return; - - SHWBufferLink_d3d9 *HWBuffer=(SHWBufferLink_d3d9*)_HWBuffer; - if (HWBuffer->indexBuffer) - { - HWBuffer->indexBuffer->Release(); - HWBuffer->indexBuffer = 0; - } - - if (HWBuffer->vertexBuffer) - { - HWBuffer->vertexBuffer->Release(); - HWBuffer->vertexBuffer = 0; - } - - CNullDriver::deleteHardwareBuffer(_HWBuffer); -} - - -//! Draw hardware buffer -void CD3D9Driver::drawHardwareBuffer(SHWBufferLink *_HWBuffer) -{ - if (!_HWBuffer) - return; - - SHWBufferLink_d3d9 *HWBuffer=(SHWBufferLink_d3d9*)_HWBuffer; - - updateHardwareBuffer(HWBuffer); //check if update is needed - - HWBuffer->LastUsed=0;//reset count - - const scene::IMeshBuffer* mb = HWBuffer->MeshBuffer; - const E_VERTEX_TYPE vType = mb->getVertexType(); - const u32 stride = getVertexPitchFromType(vType); - if (HWBuffer->vertexBuffer) pID3DDevice->SetStreamSource(0, HWBuffer->vertexBuffer, 0, stride); - if (HWBuffer->indexBuffer) pID3DDevice->SetIndices(HWBuffer->indexBuffer); - - drawVertexPrimitiveList(0, mb->getVertexCount(), 0, mb->getIndexCount()/3, mb->getVertexType(), scene::EPT_TRIANGLES, mb->getIndexType()); - - if (HWBuffer->vertexBuffer) - pID3DDevice->SetStreamSource(0, 0, 0, 0); - if (HWBuffer->indexBuffer) - pID3DDevice->SetIndices(0); -} - - -//! draws a vertex primitive list -void CD3D9Driver::drawVertexPrimitiveList(const void* vertices, - u32 vertexCount, const void* indexList, u32 primitiveCount, - E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, - E_INDEX_TYPE iType) -{ - if (!checkPrimitiveCount(primitiveCount)) - return; - - CNullDriver::drawVertexPrimitiveList(vertices, vertexCount, indexList, primitiveCount, vType, pType,iType); - - if (!vertexCount || !primitiveCount) - return; - - draw2D3DVertexPrimitiveList(vertices, vertexCount, indexList, primitiveCount, - vType, pType, iType, true); -} - - -//! draws a vertex primitive list -void CD3D9Driver::draw2DVertexPrimitiveList(const void* vertices, - u32 vertexCount, const void* indexList, u32 primitiveCount, - E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, - E_INDEX_TYPE iType) -{ - if (!checkPrimitiveCount(primitiveCount)) - return; - - CNullDriver::draw2DVertexPrimitiveList(vertices, vertexCount, indexList, primitiveCount, vType, pType,iType); - - if (!vertexCount || !primitiveCount) - return; - - draw2D3DVertexPrimitiveList(vertices, vertexCount, indexList, primitiveCount, - vType, pType, iType, false); -} - - -void CD3D9Driver::draw2D3DVertexPrimitiveList(const void* vertices, - u32 vertexCount, const void* indexList, u32 primitiveCount, - E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, - E_INDEX_TYPE iType, bool is3D) -{ - setVertexShader(vType); - - const u32 stride = getVertexPitchFromType(vType); - - D3DFORMAT indexType=D3DFMT_UNKNOWN; - switch (iType) - { - case (EIT_16BIT): - { - indexType=D3DFMT_INDEX16; - break; - } - case (EIT_32BIT): - { - indexType=D3DFMT_INDEX32; - break; - } - } - - if (is3D) - { - if (!setRenderStates3DMode()) - return; - } - else - setRenderStates2DMode(true, (Material.getTexture(0) != 0), true); - - switch (pType) - { - case scene::EPT_POINT_SPRITES: - case scene::EPT_POINTS: - { - f32 tmp=Material.Thickness/getScreenSize().Height; - if (pType==scene::EPT_POINT_SPRITES) - pID3DDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_POINTSCALEENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_POINTSIZE, *(DWORD*)(&tmp)); - tmp=1.0f; - pID3DDevice->SetRenderState(D3DRS_POINTSCALE_A, *(DWORD*)(&tmp)); - pID3DDevice->SetRenderState(D3DRS_POINTSCALE_B, *(DWORD*)(&tmp)); - pID3DDevice->SetRenderState(D3DRS_POINTSIZE_MIN, *(DWORD*)(&tmp)); - tmp=0.0f; - pID3DDevice->SetRenderState(D3DRS_POINTSCALE_C, *(DWORD*)(&tmp)); - - if (!vertices) - { - pID3DDevice->DrawIndexedPrimitive(D3DPT_POINTLIST, 0, 0, vertexCount, 0, primitiveCount); - } - else - { - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_POINTLIST, 0, vertexCount, - primitiveCount, indexList, indexType, vertices, stride); - } - - pID3DDevice->SetRenderState(D3DRS_POINTSCALEENABLE, FALSE); - if (pType==scene::EPT_POINT_SPRITES) - pID3DDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, FALSE); - } - break; - case scene::EPT_LINE_STRIP: - if(!vertices) - pID3DDevice->DrawIndexedPrimitive(D3DPT_LINESTRIP, 0, 0, vertexCount, 0, primitiveCount); - else - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINESTRIP, 0, vertexCount, - primitiveCount, indexList, indexType, vertices, stride); - break; - case scene::EPT_LINE_LOOP: - if(!vertices) - { - // TODO: Implement proper hardware support for this primitive type. - // (No looping occurs currently because this would require a way to - // draw the hardware buffer with a custom set of indices. We may even - // need to create a new mini index buffer specifically for this - // primitive type.) - pID3DDevice->DrawIndexedPrimitive(D3DPT_LINELIST, 0, 0, vertexCount, 0, primitiveCount); - } - else - { - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINESTRIP, 0, vertexCount, - primitiveCount, indexList, indexType, vertices, stride); - - u16 tmpIndices[] = {0, primitiveCount}; - - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINELIST, 0, vertexCount, - 1, tmpIndices, indexType, vertices, stride); - } - break; - case scene::EPT_LINES: - if(!vertices) - pID3DDevice->DrawIndexedPrimitive(D3DPT_LINELIST, 0, 0, vertexCount, 0, primitiveCount); - else - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINELIST, 0, vertexCount, - primitiveCount, indexList, indexType, vertices, stride); - break; - case scene::EPT_TRIANGLE_STRIP: - if(!vertices) - pID3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLESTRIP, 0, 0, vertexCount, 0, primitiveCount); - else - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLESTRIP, 0, vertexCount, primitiveCount, - indexList, indexType, vertices, stride); - break; - case scene::EPT_TRIANGLE_FAN: - if(!vertices) - pID3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLEFAN, 0, 0, vertexCount, 0, primitiveCount); - else - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLEFAN, 0, vertexCount, primitiveCount, - indexList, indexType, vertices, stride); - break; - case scene::EPT_TRIANGLES: - if(!vertices) - { - pID3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, vertexCount, 0, primitiveCount); - } - else - { - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, vertexCount, - primitiveCount, indexList, indexType, vertices, stride); - } - break; - } -} - - -void CD3D9Driver::draw2DImage(const video::ITexture* texture, - const core::rect<s32>& destRect, - const core::rect<s32>& sourceRect, - const core::rect<s32>* clipRect, - const video::SColor* const colors, - bool useAlphaChannelOfTexture) -{ - if(!texture) - return; - - const core::dimension2d<u32>& ss = texture->getOriginalSize(); - core::rect<f32> tcoords; - tcoords.UpperLeftCorner.X = (f32)sourceRect.UpperLeftCorner.X / (f32)ss.Width; - tcoords.UpperLeftCorner.Y = (f32)sourceRect.UpperLeftCorner.Y / (f32)ss.Height; - tcoords.LowerRightCorner.X = (f32)sourceRect.LowerRightCorner.X / (f32)ss.Width; - tcoords.LowerRightCorner.Y = (f32)sourceRect.LowerRightCorner.Y / (f32)ss.Height; - - const core::dimension2d<u32>& renderTargetSize = getCurrentRenderTargetSize(); - - const video::SColor temp[4] = - { - 0xFFFFFFFF, - 0xFFFFFFFF, - 0xFFFFFFFF, - 0xFFFFFFFF - }; - - const video::SColor* const useColor = colors ? colors : temp; - - S3DVertex vtx[4]; // clock wise - vtx[0] = S3DVertex((f32)destRect.UpperLeftCorner.X, (f32)destRect.UpperLeftCorner.Y, 0.0f, - 0.0f, 0.0f, 0.0f, useColor[0], - tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y); - vtx[1] = S3DVertex((f32)destRect.LowerRightCorner.X, (f32)destRect.UpperLeftCorner.Y, 0.0f, - 0.0f, 0.0f, 0.0f, useColor[3], - tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y); - vtx[2] = S3DVertex((f32)destRect.LowerRightCorner.X, (f32)destRect.LowerRightCorner.Y, 0.0f, - 0.0f, 0.0f, 0.0f, useColor[2], - tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y); - vtx[3] = S3DVertex((f32)destRect.UpperLeftCorner.X, (f32)destRect.LowerRightCorner.Y, 0.0f, - 0.0f, 0.0f, 0.0f, useColor[1], - tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y); - - s16 indices[6] = {0,1,2,0,2,3}; - - setRenderStates2DMode(useColor[0].getAlpha()<255 || useColor[1].getAlpha()<255 || - useColor[2].getAlpha()<255 || useColor[3].getAlpha()<255, - true, useAlphaChannelOfTexture); - - setActiveTexture(0, const_cast<video::ITexture*>(texture)); - - setVertexShader(EVT_STANDARD); - - if (clipRect) - { - pID3DDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE); - RECT scissor; - scissor.left = clipRect->UpperLeftCorner.X; - scissor.top = clipRect->UpperLeftCorner.Y; - scissor.right = clipRect->LowerRightCorner.X; - scissor.bottom = clipRect->LowerRightCorner.Y; - pID3DDevice->SetScissorRect(&scissor); - } - - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, &indices[0], - D3DFMT_INDEX16,&vtx[0], sizeof(S3DVertex)); - - if (clipRect) - pID3DDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE); -} - - -void CD3D9Driver::draw2DImageBatch(const video::ITexture* texture, - const core::array<core::position2d<s32> >& positions, - const core::array<core::rect<s32> >& sourceRects, - const core::rect<s32>* clipRect, - SColor color, - bool useAlphaChannelOfTexture) -{ - if (!texture) - return; - - if (!setActiveTexture(0, const_cast<video::ITexture*>(texture))) - return; - - const irr::u32 drawCount = core::min_<u32>(positions.size(), sourceRects.size()); - - core::array<S3DVertex> vtx(drawCount * 4); - core::array<u16> indices(drawCount * 6); - - for(u32 i = 0;i < drawCount;i++) - { - core::position2d<s32> targetPos = positions[i]; - core::position2d<s32> sourcePos = sourceRects[i].UpperLeftCorner; - // This needs to be signed as it may go negative. - core::dimension2d<s32> sourceSize(sourceRects[i].getSize()); - - if (clipRect) - { - if (targetPos.X < clipRect->UpperLeftCorner.X) - { - sourceSize.Width += targetPos.X - clipRect->UpperLeftCorner.X; - if (sourceSize.Width <= 0) - continue; - - sourcePos.X -= targetPos.X - clipRect->UpperLeftCorner.X; - targetPos.X = clipRect->UpperLeftCorner.X; - } - - if (targetPos.X + (s32)sourceSize.Width > clipRect->LowerRightCorner.X) - { - sourceSize.Width -= (targetPos.X + sourceSize.Width) - clipRect->LowerRightCorner.X; - if (sourceSize.Width <= 0) - continue; - } - - if (targetPos.Y < clipRect->UpperLeftCorner.Y) - { - sourceSize.Height += targetPos.Y - clipRect->UpperLeftCorner.Y; - if (sourceSize.Height <= 0) - continue; - - sourcePos.Y -= targetPos.Y - clipRect->UpperLeftCorner.Y; - targetPos.Y = clipRect->UpperLeftCorner.Y; - } - - if (targetPos.Y + (s32)sourceSize.Height > clipRect->LowerRightCorner.Y) - { - sourceSize.Height -= (targetPos.Y + sourceSize.Height) - clipRect->LowerRightCorner.Y; - if (sourceSize.Height <= 0) - continue; - } - } - - // clip these coordinates - - if (targetPos.X<0) - { - sourceSize.Width += targetPos.X; - if (sourceSize.Width <= 0) - continue; - - sourcePos.X -= targetPos.X; - targetPos.X = 0; - } - - const core::dimension2d<u32>& renderTargetSize = getCurrentRenderTargetSize(); - - if (targetPos.X + sourceSize.Width > (s32)renderTargetSize.Width) - { - sourceSize.Width -= (targetPos.X + sourceSize.Width) - renderTargetSize.Width; - if (sourceSize.Width <= 0) - continue; - } - - if (targetPos.Y<0) - { - sourceSize.Height += targetPos.Y; - if (sourceSize.Height <= 0) - continue; - - sourcePos.Y -= targetPos.Y; - targetPos.Y = 0; - } - - if (targetPos.Y + sourceSize.Height > (s32)renderTargetSize.Height) - { - sourceSize.Height -= (targetPos.Y + sourceSize.Height) - renderTargetSize.Height; - if (sourceSize.Height <= 0) - continue; - } - - // ok, we've clipped everything. - // now draw it. - - core::rect<f32> tcoords; - tcoords.UpperLeftCorner.X = (((f32)sourcePos.X)) / texture->getOriginalSize().Width ; - tcoords.UpperLeftCorner.Y = (((f32)sourcePos.Y)) / texture->getOriginalSize().Height; - tcoords.LowerRightCorner.X = tcoords.UpperLeftCorner.X + ((f32)(sourceSize.Width) / texture->getOriginalSize().Width); - tcoords.LowerRightCorner.Y = tcoords.UpperLeftCorner.Y + ((f32)(sourceSize.Height) / texture->getOriginalSize().Height); - - const core::rect<s32> poss(targetPos, sourceSize); - - setRenderStates2DMode(color.getAlpha()<255, true, useAlphaChannelOfTexture); - - vtx.push_back(S3DVertex((f32)poss.UpperLeftCorner.X, (f32)poss.UpperLeftCorner.Y, 0.0f, - 0.0f, 0.0f, 0.0f, color, - tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y)); - vtx.push_back(S3DVertex((f32)poss.LowerRightCorner.X, (f32)poss.UpperLeftCorner.Y, 0.0f, - 0.0f, 0.0f, 0.0f, color, - tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y)); - vtx.push_back(S3DVertex((f32)poss.LowerRightCorner.X, (f32)poss.LowerRightCorner.Y, 0.0f, - 0.0f, 0.0f, 0.0f, color, - tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y)); - vtx.push_back(S3DVertex((f32)poss.UpperLeftCorner.X, (f32)poss.LowerRightCorner.Y, 0.0f, - 0.0f, 0.0f, 0.0f, color, - tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y)); - - const u32 curPos = vtx.size()-4; - indices.push_back(0+curPos); - indices.push_back(1+curPos); - indices.push_back(2+curPos); - - indices.push_back(0+curPos); - indices.push_back(2+curPos); - indices.push_back(3+curPos); - } - - if (vtx.size()) - { - setVertexShader(EVT_STANDARD); - - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, vtx.size(), indices.size() / 3, indices.pointer(), - D3DFMT_INDEX16,vtx.pointer(), sizeof(S3DVertex)); - } -} - - -//! draws a 2d image, using a color and the alpha channel of the texture if -//! desired. The image is drawn at pos and clipped against clipRect (if != 0). -void CD3D9Driver::draw2DImage(const video::ITexture* texture, - const core::position2d<s32>& pos, - const core::rect<s32>& sourceRect, - const core::rect<s32>* clipRect, SColor color, - bool useAlphaChannelOfTexture) -{ - if (!texture) - return; - - if (!sourceRect.isValid()) - return; - - if (!setActiveTexture(0, const_cast<video::ITexture*>(texture))) - return; - - core::position2d<s32> targetPos = pos; - core::position2d<s32> sourcePos = sourceRect.UpperLeftCorner; - // This needs to be signed as it may go negative. - core::dimension2d<s32> sourceSize(sourceRect.getSize()); - - if (clipRect) - { - if (targetPos.X < clipRect->UpperLeftCorner.X) - { - sourceSize.Width += targetPos.X - clipRect->UpperLeftCorner.X; - if (sourceSize.Width <= 0) - return; - - sourcePos.X -= targetPos.X - clipRect->UpperLeftCorner.X; - targetPos.X = clipRect->UpperLeftCorner.X; - } - - if (targetPos.X + (s32)sourceSize.Width > clipRect->LowerRightCorner.X) - { - sourceSize.Width -= (targetPos.X + sourceSize.Width) - clipRect->LowerRightCorner.X; - if (sourceSize.Width <= 0) - return; - } - - if (targetPos.Y < clipRect->UpperLeftCorner.Y) - { - sourceSize.Height += targetPos.Y - clipRect->UpperLeftCorner.Y; - if (sourceSize.Height <= 0) - return; - - sourcePos.Y -= targetPos.Y - clipRect->UpperLeftCorner.Y; - targetPos.Y = clipRect->UpperLeftCorner.Y; - } - - if (targetPos.Y + (s32)sourceSize.Height > clipRect->LowerRightCorner.Y) - { - sourceSize.Height -= (targetPos.Y + sourceSize.Height) - clipRect->LowerRightCorner.Y; - if (sourceSize.Height <= 0) - return; - } - } - - // clip these coordinates - - if (targetPos.X<0) - { - sourceSize.Width += targetPos.X; - if (sourceSize.Width <= 0) - return; - - sourcePos.X -= targetPos.X; - targetPos.X = 0; - } - - const core::dimension2d<u32>& renderTargetSize = getCurrentRenderTargetSize(); - - if (targetPos.X + sourceSize.Width > (s32)renderTargetSize.Width) - { - sourceSize.Width -= (targetPos.X + sourceSize.Width) - renderTargetSize.Width; - if (sourceSize.Width <= 0) - return; - } - - if (targetPos.Y<0) - { - sourceSize.Height += targetPos.Y; - if (sourceSize.Height <= 0) - return; - - sourcePos.Y -= targetPos.Y; - targetPos.Y = 0; - } - - if (targetPos.Y + sourceSize.Height > (s32)renderTargetSize.Height) - { - sourceSize.Height -= (targetPos.Y + sourceSize.Height) - renderTargetSize.Height; - if (sourceSize.Height <= 0) - return; - } - - // ok, we've clipped everything. - // now draw it. - - core::rect<f32> tcoords; - tcoords.UpperLeftCorner.X = (((f32)sourcePos.X)) / texture->getOriginalSize().Width ; - tcoords.UpperLeftCorner.Y = (((f32)sourcePos.Y)) / texture->getOriginalSize().Height; - tcoords.LowerRightCorner.X = tcoords.UpperLeftCorner.X + ((f32)(sourceSize.Width) / texture->getOriginalSize().Width); - tcoords.LowerRightCorner.Y = tcoords.UpperLeftCorner.Y + ((f32)(sourceSize.Height) / texture->getOriginalSize().Height); - - const core::rect<s32> poss(targetPos, sourceSize); - - setRenderStates2DMode(color.getAlpha()<255, true, useAlphaChannelOfTexture); - - S3DVertex vtx[4]; - vtx[0] = S3DVertex((f32)poss.UpperLeftCorner.X, (f32)poss.UpperLeftCorner.Y, 0.0f, - 0.0f, 0.0f, 0.0f, color, - tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y); - vtx[1] = S3DVertex((f32)poss.LowerRightCorner.X, (f32)poss.UpperLeftCorner.Y, 0.0f, - 0.0f, 0.0f, 0.0f, color, - tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y); - vtx[2] = S3DVertex((f32)poss.LowerRightCorner.X, (f32)poss.LowerRightCorner.Y, 0.0f, - 0.0f, 0.0f, 0.0f, color, - tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y); - vtx[3] = S3DVertex((f32)poss.UpperLeftCorner.X, (f32)poss.LowerRightCorner.Y, 0.0f, - 0.0f, 0.0f, 0.0f, color, - tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y); - - s16 indices[6] = {0,1,2,0,2,3}; - - setVertexShader(EVT_STANDARD); - - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, &indices[0], - D3DFMT_INDEX16,&vtx[0], sizeof(S3DVertex)); -} - - -//!Draws a 2d rectangle with a gradient. -void CD3D9Driver::draw2DRectangle(const core::rect<s32>& position, - SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, - const core::rect<s32>* clip) -{ - core::rect<s32> pos(position); - - if (clip) - pos.clipAgainst(*clip); - - if (!pos.isValid()) - return; - - S3DVertex vtx[4]; - vtx[0] = S3DVertex((f32)pos.UpperLeftCorner.X, (f32)pos.UpperLeftCorner.Y, 0.0f, - 0.0f, 0.0f, 0.0f, colorLeftUp, 0.0f, 0.0f); - vtx[1] = S3DVertex((f32)pos.LowerRightCorner.X, (f32)pos.UpperLeftCorner.Y, 0.0f, - 0.0f, 0.0f, 0.0f, colorRightUp, 0.0f, 1.0f); - vtx[2] = S3DVertex((f32)pos.LowerRightCorner.X, (f32)pos.LowerRightCorner.Y, 0.0f, - 0.0f, 0.0f, 0.0f, colorRightDown, 1.0f, 0.0f); - vtx[3] = S3DVertex((f32)pos.UpperLeftCorner.X, (f32)pos.LowerRightCorner.Y, 0.0f, - 0.0f, 0.0f, 0.0f, colorLeftDown, 1.0f, 1.0f); - - s16 indices[6] = {0,1,2,0,2,3}; - - setRenderStates2DMode( - colorLeftUp.getAlpha() < 255 || - colorRightUp.getAlpha() < 255 || - colorLeftDown.getAlpha() < 255 || - colorRightDown.getAlpha() < 255, false, false); - - setActiveTexture(0,0); - - setVertexShader(EVT_STANDARD); - - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, &indices[0], - D3DFMT_INDEX16, &vtx[0], sizeof(S3DVertex)); -} - - -//! Draws a 2d line. -void CD3D9Driver::draw2DLine(const core::position2d<s32>& start, - const core::position2d<s32>& end, - SColor color) -{ - // thanks to Vash TheStampede who sent in his implementation - S3DVertex vtx[2]; - vtx[0] = S3DVertex((f32)start.X, (f32)start.Y, 0.0f, - 0.0f, 0.0f, 0.0f, // normal - color, 0.0f, 0.0f); // texture - - vtx[1] = S3DVertex((f32)end.X, (f32)end.Y, 0.0f, - 0.0f, 0.0f, 0.0f, - color, 0.0f, 0.0f); - - setRenderStates2DMode(color.getAlpha() < 255, false, false); - setActiveTexture(0,0); - - setVertexShader(EVT_STANDARD); - - pID3DDevice->DrawPrimitiveUP(D3DPT_LINELIST, 1, - &vtx[0], sizeof(S3DVertex) ); -} - - -//! Draws a pixel -void CD3D9Driver::drawPixel(u32 x, u32 y, const SColor & color) -{ - const core::dimension2d<u32>& renderTargetSize = getCurrentRenderTargetSize(); - if(x > (u32)renderTargetSize.Width || y > (u32)renderTargetSize.Height) - return; - - setRenderStates2DMode(color.getAlpha() < 255, false, false); - setActiveTexture(0,0); - - setVertexShader(EVT_STANDARD); - - S3DVertex vertex((f32)x, (f32)y, 0.f, 0.f, 0.f, 0.f, color, 0.f, 0.f); - - pID3DDevice->DrawPrimitiveUP(D3DPT_POINTLIST, 1, &vertex, sizeof(vertex)); -} - - -//! sets right vertex shader -void CD3D9Driver::setVertexShader(E_VERTEX_TYPE newType) -{ - if (newType != LastVertexType) - { - LastVertexType = newType; - HRESULT hr = 0; - - switch(newType) - { - case EVT_STANDARD: - hr = pID3DDevice->SetFVF(D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX1); - break; - case EVT_2TCOORDS: - hr = pID3DDevice->SetFVF(D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX2); - break; - case EVT_TANGENTS: - hr = pID3DDevice->SetFVF(D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX3 | - D3DFVF_TEXCOORDSIZE2(0) | // real texture coord - D3DFVF_TEXCOORDSIZE3(1) | // misuse texture coord 2 for tangent - D3DFVF_TEXCOORDSIZE3(2) // misuse texture coord 3 for binormal - ); - break; - } - - if (FAILED(hr)) - { - os::Printer::log("Could not set vertex Shader.", ELL_ERROR); - return; - } - } -} - - -//! sets the needed renderstates -bool CD3D9Driver::setRenderStates3DMode() -{ - if (!pID3DDevice) - return false; - - if (CurrentRenderMode != ERM_3D) - { - // switch back the matrices - pID3DDevice->SetTransform(D3DTS_VIEW, (D3DMATRIX*)((void*)&Matrices[ETS_VIEW])); - pID3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX*)((void*)&Matrices[ETS_WORLD])); - pID3DDevice->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)((void*)&Matrices[ETS_PROJECTION])); - - pID3DDevice->SetRenderState(D3DRS_STENCILENABLE, FALSE); - - ResetRenderStates = true; - } - - if (ResetRenderStates || LastMaterial != Material) - { - // unset old material - - if (CurrentRenderMode == ERM_3D && - LastMaterial.MaterialType != Material.MaterialType && - LastMaterial.MaterialType >= 0 && LastMaterial.MaterialType < (s32)MaterialRenderers.size()) - MaterialRenderers[LastMaterial.MaterialType].Renderer->OnUnsetMaterial(); - - // set new material. - - if (Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) - MaterialRenderers[Material.MaterialType].Renderer->OnSetMaterial( - Material, LastMaterial, ResetRenderStates, this); - } - - bool shaderOK = true; - if (Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) - shaderOK = MaterialRenderers[Material.MaterialType].Renderer->OnRender(this, LastVertexType); - - LastMaterial = Material; - - ResetRenderStates = false; - - CurrentRenderMode = ERM_3D; - - return shaderOK; -} - - -//! Can be called by an IMaterialRenderer to make its work easier. -void CD3D9Driver::setBasicRenderStates(const SMaterial& material, const SMaterial& lastmaterial, - bool resetAllRenderstates) -{ - if (resetAllRenderstates || - lastmaterial.AmbientColor != material.AmbientColor || - lastmaterial.DiffuseColor != material.DiffuseColor || - lastmaterial.SpecularColor != material.SpecularColor || - lastmaterial.EmissiveColor != material.EmissiveColor || - lastmaterial.Shininess != material.Shininess) - { - D3DMATERIAL9 mat; - mat.Diffuse = colorToD3D(material.DiffuseColor); - mat.Ambient = colorToD3D(material.AmbientColor); - mat.Specular = colorToD3D(material.SpecularColor); - mat.Emissive = colorToD3D(material.EmissiveColor); - mat.Power = material.Shininess; - pID3DDevice->SetMaterial(&mat); - } - - if (lastmaterial.ColorMaterial != material.ColorMaterial) - { - pID3DDevice->SetRenderState(D3DRS_COLORVERTEX, (material.ColorMaterial != ECM_NONE)); - pID3DDevice->SetRenderState(D3DRS_DIFFUSEMATERIALSOURCE, - ((material.ColorMaterial == ECM_DIFFUSE)|| - (material.ColorMaterial == ECM_DIFFUSE_AND_AMBIENT))?D3DMCS_COLOR1:D3DMCS_MATERIAL); - pID3DDevice->SetRenderState(D3DRS_AMBIENTMATERIALSOURCE, - ((material.ColorMaterial == ECM_AMBIENT)|| - (material.ColorMaterial == ECM_DIFFUSE_AND_AMBIENT))?D3DMCS_COLOR1:D3DMCS_MATERIAL); - pID3DDevice->SetRenderState(D3DRS_EMISSIVEMATERIALSOURCE, - (material.ColorMaterial == ECM_EMISSIVE)?D3DMCS_COLOR1:D3DMCS_MATERIAL); - pID3DDevice->SetRenderState(D3DRS_SPECULARMATERIALSOURCE, - (material.ColorMaterial == ECM_SPECULAR)?D3DMCS_COLOR1:D3DMCS_MATERIAL); - } - - // fillmode - if (resetAllRenderstates || lastmaterial.Wireframe != material.Wireframe || lastmaterial.PointCloud != material.PointCloud) - { - if (material.Wireframe) - pID3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME); - else - if (material.PointCloud) - pID3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_POINT); - else - pID3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); - } - - // shademode - - if (resetAllRenderstates || lastmaterial.GouraudShading != material.GouraudShading) - { - if (material.GouraudShading) - pID3DDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD); - else - pID3DDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_FLAT); - } - - // lighting - - if (resetAllRenderstates || lastmaterial.Lighting != material.Lighting) - { - if (material.Lighting) - pID3DDevice->SetRenderState(D3DRS_LIGHTING, TRUE); - else - pID3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE); - } - - // zbuffer - - if (resetAllRenderstates || lastmaterial.ZBuffer != material.ZBuffer) - { - switch (material.ZBuffer) - { - case ECFN_NEVER: - pID3DDevice->SetRenderState(D3DRS_ZENABLE, FALSE); - break; - case ECFN_LESSEQUAL: - pID3DDevice->SetRenderState(D3DRS_ZENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL); - break; - case ECFN_EQUAL: - pID3DDevice->SetRenderState(D3DRS_ZENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_EQUAL); - break; - case ECFN_LESS: - pID3DDevice->SetRenderState(D3DRS_ZENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESS); - break; - case ECFN_NOTEQUAL: - pID3DDevice->SetRenderState(D3DRS_ZENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_NOTEQUAL); - break; - case ECFN_GREATEREQUAL: - pID3DDevice->SetRenderState(D3DRS_ZENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_GREATEREQUAL); - break; - case ECFN_GREATER: - pID3DDevice->SetRenderState(D3DRS_ZENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_GREATER); - break; - case ECFN_ALWAYS: - pID3DDevice->SetRenderState(D3DRS_ZENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_ALWAYS); - break; - } - } - - // zwrite -// if (resetAllRenderstates || (lastmaterial.ZWriteEnable != material.ZWriteEnable)) - { - if ( material.ZWriteEnable && (AllowZWriteOnTransparent || !material.isTransparent())) - pID3DDevice->SetRenderState( D3DRS_ZWRITEENABLE, TRUE); - else - pID3DDevice->SetRenderState( D3DRS_ZWRITEENABLE, FALSE); - } - - // back face culling - - if (resetAllRenderstates || (lastmaterial.FrontfaceCulling != material.FrontfaceCulling) || (lastmaterial.BackfaceCulling != material.BackfaceCulling)) - { -// if (material.FrontfaceCulling && material.BackfaceCulling) -// pID3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW|D3DCULL_CCW); -// else - if (material.FrontfaceCulling) - pID3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW); - else - if (material.BackfaceCulling) - pID3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW); - else - pID3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); - } - - // fog - if (resetAllRenderstates || lastmaterial.FogEnable != material.FogEnable) - { - pID3DDevice->SetRenderState(D3DRS_FOGENABLE, material.FogEnable); - } - - // specular highlights - if (resetAllRenderstates || !core::equals(lastmaterial.Shininess,material.Shininess)) - { - const bool enable = (material.Shininess!=0.0f); - pID3DDevice->SetRenderState(D3DRS_SPECULARENABLE, enable); - pID3DDevice->SetRenderState(D3DRS_SPECULARMATERIALSOURCE, D3DMCS_MATERIAL); - } - - // normalization - if (resetAllRenderstates || lastmaterial.NormalizeNormals != material.NormalizeNormals) - { - pID3DDevice->SetRenderState(D3DRS_NORMALIZENORMALS, material.NormalizeNormals); - } - - // Color Mask - if (queryFeature(EVDF_COLOR_MASK) && - (resetAllRenderstates || lastmaterial.ColorMask != material.ColorMask)) - { - const DWORD flag = - ((material.ColorMask & ECP_RED)?D3DCOLORWRITEENABLE_RED:0) | - ((material.ColorMask & ECP_GREEN)?D3DCOLORWRITEENABLE_GREEN:0) | - ((material.ColorMask & ECP_BLUE)?D3DCOLORWRITEENABLE_BLUE:0) | - ((material.ColorMask & ECP_ALPHA)?D3DCOLORWRITEENABLE_ALPHA:0); - pID3DDevice->SetRenderState(D3DRS_COLORWRITEENABLE, flag); - } - - // Anti Aliasing - if (resetAllRenderstates || lastmaterial.AntiAliasing != material.AntiAliasing) - { - if (AlphaToCoverageSupport && (material.AntiAliasing & EAAM_ALPHA_TO_COVERAGE)) - { - if (VendorID==0x10DE)//NVidia - pID3DDevice->SetRenderState(D3DRS_ADAPTIVETESS_Y, MAKEFOURCC('A','T','O','C')); - // SSAA could give better results on NVidia cards - else if (VendorID==0x1002)//ATI - pID3DDevice->SetRenderState(D3DRS_POINTSIZE, MAKEFOURCC('A','2','M','1')); - } - else if (AlphaToCoverageSupport && (lastmaterial.AntiAliasing & EAAM_ALPHA_TO_COVERAGE)) - { - if (VendorID==0x10DE) - pID3DDevice->SetRenderState(D3DRS_ADAPTIVETESS_Y, D3DFMT_UNKNOWN); - else if (VendorID==0x1002) - pID3DDevice->SetRenderState(D3DRS_POINTSIZE, MAKEFOURCC('A','2','M','0')); - } - - // enable antialiasing - if (AntiAliasing) - { - if (material.AntiAliasing & (EAAM_SIMPLE|EAAM_QUALITY)) - pID3DDevice->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, TRUE); - else if (lastmaterial.AntiAliasing & (EAAM_SIMPLE|EAAM_QUALITY)) - pID3DDevice->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, FALSE); - if (material.AntiAliasing & (EAAM_LINE_SMOOTH)) - pID3DDevice->SetRenderState(D3DRS_ANTIALIASEDLINEENABLE, TRUE); - else if (lastmaterial.AntiAliasing & (EAAM_LINE_SMOOTH)) - pID3DDevice->SetRenderState(D3DRS_ANTIALIASEDLINEENABLE, FALSE); - } - } - - // thickness - if (resetAllRenderstates || lastmaterial.Thickness != material.Thickness) - { - pID3DDevice->SetRenderState(D3DRS_POINTSIZE, *((DWORD*)&material.Thickness)); - } - - // texture address mode - for (u32 st=0; st<MaxTextureUnits; ++st) - { - if (resetAllRenderstates || lastmaterial.TextureLayer[st].LODBias != material.TextureLayer[st].LODBias) - { - const float tmp = material.TextureLayer[st].LODBias * 0.125f; - pID3DDevice->SetSamplerState(st, D3DSAMP_MIPMAPLODBIAS, *(DWORD*)(&tmp)); - } - - if (resetAllRenderstates || lastmaterial.TextureLayer[st].TextureWrap != material.TextureLayer[st].TextureWrap) - { - u32 mode = D3DTADDRESS_WRAP; - switch (material.TextureLayer[st].TextureWrap) - { - case ETC_REPEAT: - mode=D3DTADDRESS_WRAP; - break; - case ETC_CLAMP: - case ETC_CLAMP_TO_EDGE: - mode=D3DTADDRESS_CLAMP; - break; - case ETC_MIRROR: - mode=D3DTADDRESS_MIRROR; - break; - case ETC_CLAMP_TO_BORDER: - mode=D3DTADDRESS_BORDER; - break; - } - - pID3DDevice->SetSamplerState(st, D3DSAMP_ADDRESSU, mode ); - pID3DDevice->SetSamplerState(st, D3DSAMP_ADDRESSV, mode ); - } - - // Bilinear, trilinear, and anisotropic filter - if (resetAllRenderstates || - lastmaterial.TextureLayer[st].BilinearFilter != material.TextureLayer[st].BilinearFilter || - lastmaterial.TextureLayer[st].TrilinearFilter != material.TextureLayer[st].TrilinearFilter || - lastmaterial.TextureLayer[st].AnisotropicFilter != material.TextureLayer[st].AnisotropicFilter) - { - if (material.TextureLayer[st].BilinearFilter || material.TextureLayer[st].TrilinearFilter || material.TextureLayer[st].AnisotropicFilter) - { - D3DTEXTUREFILTERTYPE tftMag = ((Caps.TextureFilterCaps & D3DPTFILTERCAPS_MAGFANISOTROPIC) && - material.TextureLayer[st].AnisotropicFilter) ? D3DTEXF_ANISOTROPIC : D3DTEXF_LINEAR; - D3DTEXTUREFILTERTYPE tftMin = ((Caps.TextureFilterCaps & D3DPTFILTERCAPS_MINFANISOTROPIC) && - material.TextureLayer[st].AnisotropicFilter) ? D3DTEXF_ANISOTROPIC : D3DTEXF_LINEAR; - D3DTEXTUREFILTERTYPE tftMip = material.TextureLayer[st].TrilinearFilter ? D3DTEXF_LINEAR : D3DTEXF_POINT; - - if (tftMag==D3DTEXF_ANISOTROPIC || tftMin == D3DTEXF_ANISOTROPIC) - pID3DDevice->SetSamplerState(st, D3DSAMP_MAXANISOTROPY, core::min_((DWORD)material.TextureLayer[st].AnisotropicFilter, Caps.MaxAnisotropy)); - pID3DDevice->SetSamplerState(st, D3DSAMP_MAGFILTER, tftMag); - pID3DDevice->SetSamplerState(st, D3DSAMP_MINFILTER, tftMin); - pID3DDevice->SetSamplerState(st, D3DSAMP_MIPFILTER, tftMip); - } - else - { - pID3DDevice->SetSamplerState(st, D3DSAMP_MINFILTER, D3DTEXF_POINT); - pID3DDevice->SetSamplerState(st, D3DSAMP_MIPFILTER, D3DTEXF_NONE); - pID3DDevice->SetSamplerState(st, D3DSAMP_MAGFILTER, D3DTEXF_POINT); - } - } - } -} - - -//! sets the needed renderstates -void CD3D9Driver::setRenderStatesStencilShadowMode(bool zfail) -{ - if ((CurrentRenderMode != ERM_SHADOW_VOLUME_ZFAIL && - CurrentRenderMode != ERM_SHADOW_VOLUME_ZPASS) || - Transformation3DChanged) - { - // switch back the matrices - pID3DDevice->SetTransform(D3DTS_VIEW, (D3DMATRIX*)((void*)&Matrices[ETS_VIEW])); - pID3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX*)((void*)&Matrices[ETS_WORLD])); - pID3DDevice->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)((void*)&Matrices[ETS_PROJECTION])); - - Transformation3DChanged = false; - - setActiveTexture(0,0); - setActiveTexture(1,0); - setActiveTexture(2,0); - setActiveTexture(3,0); - - pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(3, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(3, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetFVF(D3DFVF_XYZ); - LastVertexType = (video::E_VERTEX_TYPE)(-1); - - pID3DDevice->SetRenderState( D3DRS_ZWRITEENABLE, FALSE ); - pID3DDevice->SetRenderState( D3DRS_STENCILENABLE, TRUE ); - pID3DDevice->SetRenderState( D3DRS_SHADEMODE, D3DSHADE_FLAT); - - // unset last 3d material - if (CurrentRenderMode == ERM_3D && - Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) - MaterialRenderers[Material.MaterialType].Renderer->OnUnsetMaterial(); - - //pID3DDevice->SetRenderState(D3DRS_FOGENABLE, FALSE); - //pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE); - } - - if (CurrentRenderMode != ERM_SHADOW_VOLUME_ZPASS && !zfail) - { - // USE THE ZPASS METHOD - - pID3DDevice->SetRenderState( D3DRS_STENCILFUNC, D3DCMP_ALWAYS ); - pID3DDevice->SetRenderState( D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP ); - pID3DDevice->SetRenderState( D3DRS_STENCILFAIL, D3DSTENCILOP_KEEP ); - - pID3DDevice->SetRenderState( D3DRS_STENCILREF, 0x1 ); - pID3DDevice->SetRenderState( D3DRS_STENCILMASK, 0xffffffff ); - pID3DDevice->SetRenderState( D3DRS_STENCILWRITEMASK, 0xffffffff ); - - pID3DDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ZERO ); - pID3DDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE ); - } - else - if (CurrentRenderMode != ERM_SHADOW_VOLUME_ZFAIL && zfail) - { - // USE THE ZFAIL METHOD - - pID3DDevice->SetRenderState( D3DRS_STENCILFUNC, D3DCMP_ALWAYS ); - pID3DDevice->SetRenderState( D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP ); - pID3DDevice->SetRenderState( D3DRS_STENCILFAIL, D3DSTENCILOP_KEEP ); - pID3DDevice->SetRenderState( D3DRS_STENCILPASS, D3DSTENCILOP_KEEP ); - - pID3DDevice->SetRenderState( D3DRS_STENCILREF, 0x0 ); - pID3DDevice->SetRenderState( D3DRS_STENCILMASK, 0xffffffff ); - pID3DDevice->SetRenderState( D3DRS_STENCILWRITEMASK, 0xffffffff ); - - pID3DDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE ); - pID3DDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ZERO ); - pID3DDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE ); - } - - CurrentRenderMode = zfail ? ERM_SHADOW_VOLUME_ZFAIL : ERM_SHADOW_VOLUME_ZPASS; -} - - -//! sets the needed renderstates -void CD3D9Driver::setRenderStatesStencilFillMode(bool alpha) -{ - if (CurrentRenderMode != ERM_STENCIL_FILL || Transformation3DChanged) - { - core::matrix4 mat; - pID3DDevice->SetTransform(D3DTS_VIEW, &UnitMatrixD3D9); - pID3DDevice->SetTransform(D3DTS_WORLD, &UnitMatrixD3D9); - pID3DDevice->SetTransform(D3DTS_PROJECTION, &UnitMatrixD3D9); - - pID3DDevice->SetRenderState(D3DRS_ZENABLE, FALSE); - pID3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE); - pID3DDevice->SetRenderState(D3DRS_FOGENABLE, FALSE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(3, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(3, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetRenderState(D3DRS_STENCILREF, 0x1); - pID3DDevice->SetRenderState(D3DRS_STENCILFUNC, D3DCMP_LESSEQUAL); - //pID3DDevice->SetRenderState(D3DRS_STENCILFUNC, D3DCMP_GREATEREQUAL); - pID3DDevice->SetRenderState(D3DRS_STENCILPASS, D3DSTENCILOP_KEEP ); - pID3DDevice->SetRenderState(D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP ); - pID3DDevice->SetRenderState(D3DRS_STENCILMASK, 0xffffffff ); - pID3DDevice->SetRenderState(D3DRS_STENCILWRITEMASK, 0xffffffff ); - - pID3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW); - - Transformation3DChanged = false; - - if (alpha) - { - pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); - pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE ); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); - pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); - } - else - { - pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); - pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - } - } - - CurrentRenderMode = ERM_STENCIL_FILL; -} - - -//! sets the needed renderstates -void CD3D9Driver::setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel) -{ - if (!pID3DDevice) - return; - - if (CurrentRenderMode != ERM_2D || Transformation3DChanged) - { - // unset last 3d material - if (CurrentRenderMode != ERM_2D) - { - if (static_cast<u32>(LastMaterial.MaterialType) < MaterialRenderers.size()) - MaterialRenderers[LastMaterial.MaterialType].Renderer->OnUnsetMaterial(); - SMaterial mat; - mat.ZBuffer=ECFN_NEVER; - mat.Lighting=false; - mat.AntiAliasing=video::EAAM_OFF; - mat.TextureLayer[0].BilinearFilter=false; - setBasicRenderStates(mat, mat, true); - // fix everything that is wrongly set by SMaterial default - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(3, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(3, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetRenderState( D3DRS_STENCILENABLE, FALSE ); - - setTransform(ETS_TEXTURE_0, core::IdentityMatrix); - pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0); - } - - pID3DDevice->SetTransform(D3DTS_WORLD, &UnitMatrixD3D9); - - core::matrix4 m; - m.setTranslation(core::vector3df(-0.5f,-0.5f,0)); - pID3DDevice->SetTransform(D3DTS_VIEW, (D3DMATRIX*)((void*)m.pointer())); - - const core::dimension2d<u32>& renderTargetSize = getCurrentRenderTargetSize(); - m.buildProjectionMatrixOrthoLH(f32(renderTargetSize.Width), f32(-(s32)(renderTargetSize.Height)), -1.0, 1.0); - m.setTranslation(core::vector3df(-1,1,0)); - pID3DDevice->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)((void*)m.pointer())); - - Transformation3DChanged = false; - } - - u32 current2DSignature = 0; - current2DSignature |= alpha ? EC2D_ALPHA : 0; - current2DSignature |= texture ? EC2D_TEXTURE : 0; - current2DSignature |= alphaChannel ? EC2D_ALPHA_CHANNEL : 0; - - if(CurrentRenderMode != ERM_2D || current2DSignature != Cached2DModeSignature) - { - if (texture) - { - if (alphaChannel) - { - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); - - if (alpha) - { - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE ); - } - else - { - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ); - } - - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); - pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); - } - else - { - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); - if (alpha) - { - pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG2); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); - pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); - } - else - { - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - } - } - } - else - { - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); - if (alpha) - { - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE ); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); - pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); - } - else - { - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - } - } - } - - CurrentRenderMode = ERM_2D; - Cached2DModeSignature = current2DSignature; -} - - -//! deletes all dynamic lights there are -void CD3D9Driver::deleteAllDynamicLights() -{ - for (s32 i=0; i<LastSetLight+1; ++i) - pID3DDevice->LightEnable(i, false); - - LastSetLight = -1; - - CNullDriver::deleteAllDynamicLights(); -} - - -//! adds a dynamic light -s32 CD3D9Driver::addDynamicLight(const SLight& dl) -{ - CNullDriver::addDynamicLight(dl); - - D3DLIGHT9 light; - - switch (dl.Type) - { - case ELT_POINT: - light.Type = D3DLIGHT_POINT; - break; - case ELT_SPOT: - light.Type = D3DLIGHT_SPOT; - break; - case ELT_DIRECTIONAL: - light.Type = D3DLIGHT_DIRECTIONAL; - break; - } - - light.Position = *(D3DVECTOR*)((void*)(&dl.Position)); - light.Direction = *(D3DVECTOR*)((void*)(&dl.Direction)); - - light.Range = core::min_(dl.Radius, MaxLightDistance); - light.Falloff = dl.Falloff; - - light.Diffuse = *(D3DCOLORVALUE*)((void*)(&dl.DiffuseColor)); - light.Specular = *(D3DCOLORVALUE*)((void*)(&dl.SpecularColor)); - light.Ambient = *(D3DCOLORVALUE*)((void*)(&dl.AmbientColor)); - - light.Attenuation0 = dl.Attenuation.X; - light.Attenuation1 = dl.Attenuation.Y; - light.Attenuation2 = dl.Attenuation.Z; - - light.Theta = dl.InnerCone * 2.0f * core::DEGTORAD; - light.Phi = dl.OuterCone * 2.0f * core::DEGTORAD; - - ++LastSetLight; - - if(D3D_OK == pID3DDevice->SetLight(LastSetLight, &light)) - { - // I don't care if this succeeds - (void)pID3DDevice->LightEnable(LastSetLight, true); - return LastSetLight; - } - - return -1; -} - -//! Turns a dynamic light on or off -//! \param lightIndex: the index returned by addDynamicLight -//! \param turnOn: true to turn the light on, false to turn it off -void CD3D9Driver::turnLightOn(s32 lightIndex, bool turnOn) -{ - if(lightIndex < 0 || lightIndex > LastSetLight) - return; - - (void)pID3DDevice->LightEnable(lightIndex, turnOn); -} - - -//! returns the maximal amount of dynamic lights the device can handle -u32 CD3D9Driver::getMaximalDynamicLightAmount() const -{ - return Caps.MaxActiveLights; -} - - -//! Sets the dynamic ambient light color. The default color is -//! (0,0,0,0) which means it is dark. -//! \param color: New color of the ambient light. -void CD3D9Driver::setAmbientLight(const SColorf& color) -{ - if (!pID3DDevice) - return; - - AmbientLight = color; - D3DCOLOR col = color.toSColor().color; - pID3DDevice->SetRenderState(D3DRS_AMBIENT, col); -} - - -//! \return Returns the name of the video driver. Example: In case of the DIRECT3D9 -//! driver, it would return "Direct3D9.0". -const wchar_t* CD3D9Driver::getName() const -{ - return L"Direct3D 9.0"; -} - - -//! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do -//! this: Frist, draw all geometry. Then use this method, to draw the shadow -//! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow. -void CD3D9Driver::drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail) -{ - if (!StencilBuffer || !count) - return; - - setRenderStatesStencilShadowMode(zfail); - - if (!zfail) - { - // ZPASS Method - - // Draw front-side of shadow volume in stencil/z only - pID3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW ); - pID3DDevice->SetRenderState(D3DRS_STENCILPASS, D3DSTENCILOP_INCRSAT); - pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df)); - - // Now reverse cull order so front sides of shadow volume are written. - pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CW ); - pID3DDevice->SetRenderState( D3DRS_STENCILPASS, D3DSTENCILOP_DECRSAT); - pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df)); - } - else - { - // ZFAIL Method - - // Draw front-side of shadow volume in stencil/z only - pID3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW ); - pID3DDevice->SetRenderState(D3DRS_STENCILZFAIL, D3DSTENCILOP_INCRSAT ); - pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df)); - - // Now reverse cull order so front sides of shadow volume are written. - pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW ); - pID3DDevice->SetRenderState( D3DRS_STENCILZFAIL, D3DSTENCILOP_DECRSAT ); - pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df)); - } -} - - -//! Fills the stencil shadow with color. After the shadow volume has been drawn -//! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this -//! to draw the color of the shadow. -void CD3D9Driver::drawStencilShadow(bool clearStencilBuffer, video::SColor leftUpEdge, - video::SColor rightUpEdge, video::SColor leftDownEdge, video::SColor rightDownEdge) -{ - if (!StencilBuffer) - return; - - S3DVertex vtx[4]; - vtx[0] = S3DVertex(1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, leftUpEdge, 0.0f, 0.0f); - vtx[1] = S3DVertex(1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, rightUpEdge, 0.0f, 1.0f); - vtx[2] = S3DVertex(-1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, leftDownEdge, 1.0f, 0.0f); - vtx[3] = S3DVertex(-1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, rightDownEdge, 1.0f, 1.0f); - - s16 indices[6] = {0,1,2,1,3,2}; - - setRenderStatesStencilFillMode( - leftUpEdge.getAlpha() < 255 || - rightUpEdge.getAlpha() < 255 || - leftDownEdge.getAlpha() < 255 || - rightDownEdge.getAlpha() < 255); - - setActiveTexture(0,0); - - setVertexShader(EVT_STANDARD); - - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, &indices[0], - D3DFMT_INDEX16, &vtx[0], sizeof(S3DVertex)); - - if (clearStencilBuffer) - pID3DDevice->Clear( 0, NULL, D3DCLEAR_STENCIL,0, 1.0, 0); -} - - -//! Returns the maximum amount of primitives (mostly vertices) which -//! the device is able to render with one drawIndexedTriangleList -//! call. -u32 CD3D9Driver::getMaximalPrimitiveCount() const -{ - return Caps.MaxPrimitiveCount; -} - - -//! Sets the fog mode. -void CD3D9Driver::setFog(SColor color, E_FOG_TYPE fogType, f32 start, - f32 end, f32 density, bool pixelFog, bool rangeFog) -{ - CNullDriver::setFog(color, fogType, start, end, density, pixelFog, rangeFog); - - if (!pID3DDevice) - return; - - pID3DDevice->SetRenderState(D3DRS_FOGCOLOR, color.color); - - pID3DDevice->SetRenderState( - pixelFog ? D3DRS_FOGTABLEMODE : D3DRS_FOGVERTEXMODE, - (fogType==EFT_FOG_LINEAR)? D3DFOG_LINEAR : (fogType==EFT_FOG_EXP)?D3DFOG_EXP:D3DFOG_EXP2); - - if (fogType==EFT_FOG_LINEAR) - { - pID3DDevice->SetRenderState(D3DRS_FOGSTART, *(DWORD*)(&start)); - pID3DDevice->SetRenderState(D3DRS_FOGEND, *(DWORD*)(&end)); - } - else - pID3DDevice->SetRenderState(D3DRS_FOGDENSITY, *(DWORD*)(&density)); - - if(!pixelFog) - pID3DDevice->SetRenderState(D3DRS_RANGEFOGENABLE, rangeFog); -} - - -//! Draws a 3d line. -void CD3D9Driver::draw3DLine(const core::vector3df& start, - const core::vector3df& end, SColor color) -{ - setVertexShader(EVT_STANDARD); - setRenderStates3DMode(); - video::S3DVertex v[2]; - v[0].Color = color; - v[1].Color = color; - v[0].Pos = start; - v[1].Pos = end; - - pID3DDevice->DrawPrimitiveUP(D3DPT_LINELIST, 1, v, sizeof(S3DVertex)); -} - - -//! resets the device -bool CD3D9Driver::reset() -{ - u32 i; - os::Printer::log("Resetting D3D9 device.", ELL_INFORMATION); - - for (i=0; i<Textures.size(); ++i) - { - if (Textures[i].Surface->isRenderTarget()) - { - IDirect3DBaseTexture9* tex = ((CD3D9Texture*)(Textures[i].Surface))->getDX9Texture(); - if (tex) - tex->Release(); - } - } - for (i=0; i<DepthBuffers.size(); ++i) - { - if(DepthBuffers[i]->Surface) - DepthBuffers[i]->Surface->Release(); - } - // this does not require a restore in the reset method, it's updated - // automatically in the next render cycle. - removeAllHardwareBuffers(); - - DriverWasReset=true; - - HRESULT hr = pID3DDevice->Reset(&present); - - // restore RTTs - for (i=0; i<Textures.size(); ++i) - { - if (Textures[i].Surface->isRenderTarget()) - ((CD3D9Texture*)(Textures[i].Surface))->createRenderTarget(); - } - - // restore screen depthbuffer - pID3DDevice->GetDepthStencilSurface(&(DepthBuffers[0]->Surface)); - D3DSURFACE_DESC desc; - // restore other depth buffers - // dpeth format is taken from main depth buffer - DepthBuffers[0]->Surface->GetDesc(&desc); - // multisampling is taken from rendertarget - D3DSURFACE_DESC desc2; - for (i=1; i<DepthBuffers.size(); ++i) - { - for (u32 j=0; j<Textures.size(); ++j) - { - // all textures sharing this depth buffer must have the same setting - // so take first one - if (((CD3D9Texture*)(Textures[j].Surface))->DepthSurface==DepthBuffers[i]) - { - ((CD3D9Texture*)(Textures[j].Surface))->Texture->GetLevelDesc(0,&desc2); - break; - } - } - - pID3DDevice->CreateDepthStencilSurface(DepthBuffers[i]->Size.Width, - DepthBuffers[i]->Size.Height, - desc.Format, - desc2.MultiSampleType, - desc2.MultiSampleQuality, - TRUE, - &(DepthBuffers[i]->Surface), - NULL); - } - - if (FAILED(hr)) - { - if (hr == D3DERR_DEVICELOST) - { - DeviceLost = true; - os::Printer::log("Resetting failed due to device lost.", ELL_WARNING); - } -#ifdef D3DERR_DEVICEREMOVED - else if (hr == D3DERR_DEVICEREMOVED) - { - os::Printer::log("Resetting failed due to device removed.", ELL_WARNING); - } -#endif - else if (hr == D3DERR_DRIVERINTERNALERROR) - { - os::Printer::log("Resetting failed due to internal error.", ELL_WARNING); - } - else if (hr == D3DERR_OUTOFVIDEOMEMORY) - { - os::Printer::log("Resetting failed due to out of memory.", ELL_WARNING); - } - else if (hr == D3DERR_DEVICENOTRESET) - { - os::Printer::log("Resetting failed due to not reset.", ELL_WARNING); - } - else if (hr == D3DERR_INVALIDCALL) - { - os::Printer::log("Resetting failed due to invalid call", "You need to release some more surfaces.", ELL_WARNING); - } - else - { - os::Printer::log("Resetting failed due to unknown reason.", core::stringc((int)hr).c_str(), ELL_WARNING); - } - return false; - } - - DeviceLost = false; - ResetRenderStates = true; - LastVertexType = (E_VERTEX_TYPE)-1; - - for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i) - CurrentTexture[i] = 0; - - setVertexShader(EVT_STANDARD); - setRenderStates3DMode(); - setFog(FogColor, FogType, FogStart, FogEnd, FogDensity, PixelFog, RangeFog); - setAmbientLight(AmbientLight); - - return true; -} - - -void CD3D9Driver::OnResize(const core::dimension2d<u32>& size) -{ - if (!pID3DDevice) - return; - - CNullDriver::OnResize(size); - present.BackBufferWidth = size.Width; - present.BackBufferHeight = size.Height; - - reset(); -} - - -//! Returns type of video driver -E_DRIVER_TYPE CD3D9Driver::getDriverType() const -{ - return EDT_DIRECT3D9; -} - - -//! Returns the transformation set by setTransform -const core::matrix4& CD3D9Driver::getTransform(E_TRANSFORMATION_STATE state) const -{ - return Matrices[state]; -} - - -//! Sets a vertex shader constant. -void CD3D9Driver::setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount) -{ - if (data) - pID3DDevice->SetVertexShaderConstantF(startRegister, data, constantAmount); -} - - -//! Sets a pixel shader constant. -void CD3D9Driver::setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount) -{ - if (data) - pID3DDevice->SetPixelShaderConstantF(startRegister, data, constantAmount); -} - - -//! Sets a constant for the vertex shader based on a name. -bool CD3D9Driver::setVertexShaderConstant(const c8* name, const f32* floats, int count) -{ - if (Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) - { - CD3D9MaterialRenderer* r = (CD3D9MaterialRenderer*)MaterialRenderers[Material.MaterialType].Renderer; - return r->setVariable(true, name, floats, count); - } - - return false; -} - - -//! Sets a constant for the pixel shader based on a name. -bool CD3D9Driver::setPixelShaderConstant(const c8* name, const f32* floats, int count) -{ - if (Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) - { - CD3D9MaterialRenderer* r = (CD3D9MaterialRenderer*)MaterialRenderers[Material.MaterialType].Renderer; - return r->setVariable(false, name, floats, count); - } - - return false; -} - - -//! Returns pointer to the IGPUProgrammingServices interface. -IGPUProgrammingServices* CD3D9Driver::getGPUProgrammingServices() -{ - return this; -} - - -//! Adds a new material renderer to the VideoDriver, using pixel and/or -//! vertex shaders to render geometry. -s32 CD3D9Driver::addShaderMaterial(const c8* vertexShaderProgram, - const c8* pixelShaderProgram, - IShaderConstantSetCallBack* callback, - E_MATERIAL_TYPE baseMaterial, s32 userData) -{ - s32 nr = -1; - CD3D9ShaderMaterialRenderer* r = new CD3D9ShaderMaterialRenderer( - pID3DDevice, this, nr, vertexShaderProgram, pixelShaderProgram, - callback, getMaterialRenderer(baseMaterial), userData); - - r->drop(); - return nr; -} - - -//! Adds a new material renderer to the VideoDriver, based on a high level shading -//! language. -s32 CD3D9Driver::addHighLevelShaderMaterial( - const c8* vertexShaderProgram, - const c8* vertexShaderEntryPointName, - E_VERTEX_SHADER_TYPE vsCompileTarget, - const c8* pixelShaderProgram, - const c8* pixelShaderEntryPointName, - E_PIXEL_SHADER_TYPE psCompileTarget, - IShaderConstantSetCallBack* callback, - E_MATERIAL_TYPE baseMaterial, s32 userData) -{ - s32 nr = -1; - - CD3D9HLSLMaterialRenderer* hlsl = new CD3D9HLSLMaterialRenderer( - pID3DDevice, this, nr, - vertexShaderProgram, - vertexShaderEntryPointName, - vsCompileTarget, - pixelShaderProgram, - pixelShaderEntryPointName, - psCompileTarget, - callback, - getMaterialRenderer(baseMaterial), - userData); - - hlsl->drop(); - return nr; -} - - -//! Returns a pointer to the IVideoDriver interface. (Implementation for -//! IMaterialRendererServices) -IVideoDriver* CD3D9Driver::getVideoDriver() -{ - return this; -} - - -//! Creates a render target texture. -ITexture* CD3D9Driver::addRenderTargetTexture(const core::dimension2d<u32>& size, - const io::path& name, - const ECOLOR_FORMAT format) -{ - ITexture* tex = new CD3D9Texture(this, size, name, format); - if (tex) - { - checkDepthBuffer(tex); - addTexture(tex); - tex->drop(); - } - return tex; -} - - -//! Clears the ZBuffer. -void CD3D9Driver::clearZBuffer() -{ - HRESULT hr = pID3DDevice->Clear( 0, NULL, D3DCLEAR_ZBUFFER, 0, 1.0, 0); - - if (FAILED(hr)) - os::Printer::log("CD3D9Driver clearZBuffer() failed.", ELL_WARNING); -} - - -//! Returns an image created from the last rendered frame. -IImage* CD3D9Driver::createScreenShot() -{ - HRESULT hr; - - // query the screen dimensions of the current adapter - D3DDISPLAYMODE displayMode; - pID3DDevice->GetDisplayMode(0, &displayMode); - - // create the image surface to store the front buffer image [always A8R8G8B8] - LPDIRECT3DSURFACE9 lpSurface; - if (FAILED(hr = pID3DDevice->CreateOffscreenPlainSurface(displayMode.Width, displayMode.Height, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &lpSurface, 0))) - return 0; - - // read the front buffer into the image surface - if (FAILED(hr = pID3DDevice->GetFrontBufferData(0, lpSurface))) - { - lpSurface->Release(); - return 0; - } - - RECT clientRect; - { - POINT clientPoint; - clientPoint.x = 0; - clientPoint.y = 0; - - ClientToScreen((HWND)getExposedVideoData().D3D9.HWnd, &clientPoint); - - clientRect.left = clientPoint.x; - clientRect.top = clientPoint.y; - clientRect.right = clientRect.left + ScreenSize.Width; - clientRect.bottom = clientRect.top + ScreenSize.Height; - } - - // lock our area of the surface - D3DLOCKED_RECT lockedRect; - if (FAILED(lpSurface->LockRect(&lockedRect, &clientRect, D3DLOCK_READONLY))) - { - lpSurface->Release(); - return 0; - } - - // this could throw, but we aren't going to worry about that case very much - IImage* newImage = new CImage(ECF_A8R8G8B8, ScreenSize); - - // d3d pads the image, so we need to copy the correct number of bytes - u32* dP = (u32*)newImage->lock(); - u8 * sP = (u8 *)lockedRect.pBits; - - // If the display mode format doesn't promise anything about the Alpha value - // and it appears that it's not presenting 255, then we should manually - // set each pixel alpha value to 255. - if(D3DFMT_X8R8G8B8 == displayMode.Format && (0xFF000000 != (*dP & 0xFF000000))) - { - for (u32 y = 0; y < ScreenSize.Height; ++y) - { - for(u32 x = 0; x < ScreenSize.Width; ++x) - { - *dP = *((u32*)sP) | 0xFF000000; - dP++; - sP += 4; - } - - sP += lockedRect.Pitch - (4 * ScreenSize.Width); - } - } - else - { - for (u32 y = 0; y < ScreenSize.Height; ++y) - { - memcpy(dP, sP, ScreenSize.Width * 4); - - sP += lockedRect.Pitch; - dP += ScreenSize.Width; - } - } - - newImage->unlock(); - - // we can unlock and release the surface - lpSurface->UnlockRect(); - - // release the image surface - lpSurface->Release(); - - // return status of save operation to caller - return newImage; -} - - -//! returns color format -ECOLOR_FORMAT CD3D9Driver::getColorFormat() const -{ - return ColorFormat; -} - - -//! returns color format -D3DFORMAT CD3D9Driver::getD3DColorFormat() const -{ - return D3DColorFormat; -} - - -// returns the current size of the screen or rendertarget -const core::dimension2d<u32>& CD3D9Driver::getCurrentRenderTargetSize() const -{ - if ( CurrentRendertargetSize.Width == 0 ) - return ScreenSize; - else - return CurrentRendertargetSize; -} - - -// Set/unset a clipping plane. -bool CD3D9Driver::setClipPlane(u32 index, const core::plane3df& plane, bool enable) -{ - if (index >= MaxUserClipPlanes) - return false; - - pID3DDevice->SetClipPlane(index, (const float*)&plane); - enableClipPlane(index, enable); - return true; -} - - -// Enable/disable a clipping plane. -void CD3D9Driver::enableClipPlane(u32 index, bool enable) -{ - if (index >= MaxUserClipPlanes) - return; - DWORD renderstate; - pID3DDevice->GetRenderState(D3DRS_CLIPPLANEENABLE, &renderstate); - if (enable) - renderstate |= (1 << index); - else - renderstate &= ~(1 << index); - pID3DDevice->SetRenderState(D3DRS_CLIPPLANEENABLE, renderstate); -} - - -D3DFORMAT CD3D9Driver::getD3DFormatFromColorFormat(ECOLOR_FORMAT format) const -{ - switch(format) - { - case ECF_A1R5G5B5: - return D3DFMT_A1R5G5B5; - case ECF_R5G6B5: - return D3DFMT_R5G6B5; - case ECF_R8G8B8: - return D3DFMT_R8G8B8; - case ECF_A8R8G8B8: - return D3DFMT_A8R8G8B8; - - // Floating Point formats. Thanks to Patryk "Nadro" Nadrowski. - case ECF_R16F: - return D3DFMT_R16F; - case ECF_G16R16F: - return D3DFMT_G16R16F; - case ECF_A16B16G16R16F: - return D3DFMT_A16B16G16R16F; - case ECF_R32F: - return D3DFMT_R32F; - case ECF_G32R32F: - return D3DFMT_G32R32F; - case ECF_A32B32G32R32F: - return D3DFMT_A32B32G32R32F; - } - return D3DFMT_UNKNOWN; -} - - -ECOLOR_FORMAT CD3D9Driver::getColorFormatFromD3DFormat(D3DFORMAT format) const -{ - switch(format) - { - case D3DFMT_X1R5G5B5: - case D3DFMT_A1R5G5B5: - return ECF_A1R5G5B5; - case D3DFMT_A8B8G8R8: - case D3DFMT_A8R8G8B8: - case D3DFMT_X8R8G8B8: - return ECF_A8R8G8B8; - case D3DFMT_R5G6B5: - return ECF_R5G6B5; - case D3DFMT_R8G8B8: - return ECF_R8G8B8; - - // Floating Point formats. Thanks to Patryk "Nadro" Nadrowski. - case D3DFMT_R16F: - return ECF_R16F; - case D3DFMT_G16R16F: - return ECF_G16R16F; - case D3DFMT_A16B16G16R16F: - return ECF_A16B16G16R16F; - case D3DFMT_R32F: - return ECF_R32F; - case D3DFMT_G32R32F: - return ECF_G32R32F; - case D3DFMT_A32B32G32R32F: - return ECF_A32B32G32R32F; - default: - return (ECOLOR_FORMAT)0; - }; -} - - -void CD3D9Driver::checkDepthBuffer(ITexture* tex) -{ - if (!tex) - return; - const core::dimension2du optSize = tex->getSize().getOptimalSize( - !queryFeature(EVDF_TEXTURE_NPOT), - !queryFeature(EVDF_TEXTURE_NSQUARE), true); - SDepthSurface* depth=0; - core::dimension2du destSize(0x7fffffff, 0x7fffffff); - for (u32 i=0; i<DepthBuffers.size(); ++i) - { - if ((DepthBuffers[i]->Size.Width>=optSize.Width) && - (DepthBuffers[i]->Size.Height>=optSize.Height)) - { - if ((DepthBuffers[i]->Size.Width<destSize.Width) && - (DepthBuffers[i]->Size.Height<destSize.Height)) - { - depth = DepthBuffers[i]; - destSize=DepthBuffers[i]->Size; - } - } - } - if (!depth) - { - D3DSURFACE_DESC desc; - DepthBuffers[0]->Surface->GetDesc(&desc); - // the multisampling needs to match the RTT - D3DSURFACE_DESC desc2; - ((CD3D9Texture*)tex)->Texture->GetLevelDesc(0,&desc2); - DepthBuffers.push_back(new SDepthSurface()); - HRESULT hr=pID3DDevice->CreateDepthStencilSurface(optSize.Width, - optSize.Height, - desc.Format, - desc2.MultiSampleType, - desc2.MultiSampleQuality, - TRUE, - &(DepthBuffers.getLast()->Surface), - NULL); - if (SUCCEEDED(hr)) - { - depth=DepthBuffers.getLast(); - depth->Surface->GetDesc(&desc); - depth->Size.set(desc.Width, desc.Height); - } - else - { - if (hr == D3DERR_OUTOFVIDEOMEMORY) - os::Printer::log("Could not create DepthBuffer","out of video memory",ELL_ERROR); - else if( hr == E_OUTOFMEMORY ) - os::Printer::log("Could not create DepthBuffer","out of memory",ELL_ERROR); - else - { - char buffer[128]; - sprintf(buffer,"Could not create DepthBuffer of %ix%i",optSize.Width,optSize.Height); - os::Printer::log(buffer,ELL_ERROR); - } - DepthBuffers.erase(DepthBuffers.size()-1); - } - } - else - depth->grab(); - - static_cast<CD3D9Texture*>(tex)->DepthSurface=depth; -} - - -void CD3D9Driver::removeDepthSurface(SDepthSurface* depth) -{ - for (u32 i=0; i<DepthBuffers.size(); ++i) - { - if (DepthBuffers[i]==depth) - { - DepthBuffers.erase(i); - return; - } - } -} - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_DIRECT3D_9_ - - - -namespace irr -{ -namespace video -{ - -#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ -//! creates a video driver -IVideoDriver* createDirectX9Driver(const core::dimension2d<u32>& screenSize, - HWND window, u32 bits, bool fullscreen, bool stencilbuffer, - io::IFileSystem* io, bool pureSoftware, bool highPrecisionFPU, - bool vsync, u8 antiAlias) -{ - CD3D9Driver* dx9 = new CD3D9Driver(screenSize, window, fullscreen, stencilbuffer, io, pureSoftware); - if (!dx9->initDriver(screenSize, window, bits, fullscreen, pureSoftware, highPrecisionFPU, vsync, antiAlias)) - { - dx9->drop(); - dx9 = 0; - } - - return dx9; -} -#endif // _IRR_COMPILE_WITH_DIRECT3D_9_ - -} // end namespace video -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CD3D9Driver.h b/irrlicht-1.6/source/Irrlicht/CD3D9Driver.h deleted file mode 100644 index 4ff672e1a..000000000 --- a/irrlicht-1.6/source/Irrlicht/CD3D9Driver.h +++ /dev/null @@ -1,429 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_VIDEO_DIRECTX_9_H_INCLUDED__ -#define __C_VIDEO_DIRECTX_9_H_INCLUDED__ - -#include "IrrCompileConfig.h" - -#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ - -#ifdef _IRR_WINDOWS_ -#define WIN32_LEAN_AND_MEAN -#include <windows.h> -#endif - -#include "CNullDriver.h" -#include "IMaterialRendererServices.h" -#include <d3d9.h> - -namespace irr -{ -namespace video -{ - struct SDepthSurface : public IReferenceCounted - { - SDepthSurface() : Surface(0) - { - #ifdef _DEBUG - setDebugName("SDepthSurface"); - #endif - } - virtual ~SDepthSurface() - { - if (Surface) - Surface->Release(); - } - - IDirect3DSurface9* Surface; - core::dimension2du Size; - }; - - class CD3D9Driver : public CNullDriver, IMaterialRendererServices - { - public: - - friend class CD3D9Texture; - - //! constructor - CD3D9Driver(const core::dimension2d<u32>& screenSize, HWND window, bool fullscreen, - bool stencibuffer, io::IFileSystem* io, bool pureSoftware=false); - - //! destructor - virtual ~CD3D9Driver(); - - //! applications must call this method before performing any rendering. returns false if failed. - virtual bool beginScene(bool backBuffer=true, bool zBuffer=true, - SColor color=SColor(255,0,0,0), - void* windowId=0, - core::rect<s32>* sourceRect=0); - - //! applications must call this method after performing any rendering. returns false if failed. - virtual bool endScene(); - - //! queries the features of the driver, returns true if feature is available - virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const; - - //! sets transformation - virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat); - - //! sets a material - virtual void setMaterial(const SMaterial& material); - - //! sets a render target - virtual bool setRenderTarget(video::ITexture* texture, - bool clearBackBuffer=false, bool clearZBuffer=false, - SColor color=video::SColor(0,0,0,0)); - - //! sets a viewport - virtual void setViewPort(const core::rect<s32>& area); - - //! gets the area of the current viewport - virtual const core::rect<s32>& getViewPort() const; - - struct SHWBufferLink_d3d9 : public SHWBufferLink - { - SHWBufferLink_d3d9(const scene::IMeshBuffer *_MeshBuffer): - SHWBufferLink(_MeshBuffer), - vertexBuffer(0), indexBuffer(0), - vertexBufferSize(0), indexBufferSize(0) {} - - IDirect3DVertexBuffer9* vertexBuffer; - IDirect3DIndexBuffer9* indexBuffer; - - u32 vertexBufferSize; - u32 indexBufferSize; - }; - - bool updateVertexHardwareBuffer(SHWBufferLink_d3d9 *HWBuffer); - bool updateIndexHardwareBuffer(SHWBufferLink_d3d9 *HWBuffer); - - //! updates hardware buffer if needed - virtual bool updateHardwareBuffer(SHWBufferLink *HWBuffer); - - //! Create hardware buffer from mesh - virtual SHWBufferLink *createHardwareBuffer(const scene::IMeshBuffer* mb); - - //! Delete hardware buffer (only some drivers can) - virtual void deleteHardwareBuffer(SHWBufferLink *HWBuffer); - - //! Draw hardware buffer - virtual void drawHardwareBuffer(SHWBufferLink *HWBuffer); - - //! draws a vertex primitive list - virtual void drawVertexPrimitiveList(const void* vertices, u32 vertexCount, - const void* indexList, u32 primitiveCount, - E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, - E_INDEX_TYPE iType); - - //! draws a vertex primitive list in 2d - virtual void draw2DVertexPrimitiveList(const void* vertices, u32 vertexCount, - const void* indexList, u32 primitiveCount, - E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, - E_INDEX_TYPE iType); - - //! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. - virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos, - const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0, - SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false); - - //! Draws a part of the texture into the rectangle. - virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect, - const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0, - const video::SColor* const colors=0, bool useAlphaChannelOfTexture=false); - - //! Draws a set of 2d images, using a color and the alpha channel of the texture. - virtual void draw2DImageBatch(const video::ITexture* texture, - const core::array<core::position2d<s32> >& positions, - const core::array<core::rect<s32> >& sourceRects, - const core::rect<s32>* clipRect=0, - SColor color=SColor(255,255,255,255), - bool useAlphaChannelOfTexture=false); - - //!Draws an 2d rectangle with a gradient. - virtual void draw2DRectangle(const core::rect<s32>& pos, - SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, - const core::rect<s32>* clip); - - //! Draws a 2d line. - virtual void draw2DLine(const core::position2d<s32>& start, - const core::position2d<s32>& end, - SColor color=SColor(255,255,255,255)); - - //! Draws a pixel. - virtual void drawPixel(u32 x, u32 y, const SColor & color); - - //! Draws a 3d line. - virtual void draw3DLine(const core::vector3df& start, - const core::vector3df& end, SColor color = SColor(255,255,255,255)); - - //! initialises the Direct3D API - bool initDriver(const core::dimension2d<u32>& screenSize, HWND hwnd, - u32 bits, bool fullScreen, bool pureSoftware, - bool highPrecisionFPU, bool vsync, u8 antiAlias); - - //! \return Returns the name of the video driver. Example: In case of the DIRECT3D8 - //! driver, it would return "Direct3D8.1". - virtual const wchar_t* getName() const; - - //! deletes all dynamic lights there are - virtual void deleteAllDynamicLights(); - - //! adds a dynamic light, returning an index to the light - //! \param light: the light data to use to create the light - //! \return An index to the light, or -1 if an error occurs - virtual s32 addDynamicLight(const SLight& light); - - //! Turns a dynamic light on or off - //! \param lightIndex: the index returned by addDynamicLight - //! \param turnOn: true to turn the light on, false to turn it off - virtual void turnLightOn(s32 lightIndex, bool turnOn); - - //! returns the maximal amount of dynamic lights the device can handle - virtual u32 getMaximalDynamicLightAmount() const; - - //! Sets the dynamic ambient light color. The default color is - //! (0,0,0,0) which means it is dark. - //! \param color: New color of the ambient light. - virtual void setAmbientLight(const SColorf& color); - - //! Draws a shadow volume into the stencil buffer. - virtual void drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail); - - //! Fills the stencil shadow with color. - virtual void drawStencilShadow(bool clearStencilBuffer=false, - video::SColor leftUpEdge = video::SColor(0,0,0,0), - video::SColor rightUpEdge = video::SColor(0,0,0,0), - video::SColor leftDownEdge = video::SColor(0,0,0,0), - video::SColor rightDownEdge = video::SColor(0,0,0,0)); - - //! Returns the maximum amount of primitives (mostly vertices) which - //! the device is able to render with one drawIndexedTriangleList - //! call. - virtual u32 getMaximalPrimitiveCount() const; - - //! Enables or disables a texture creation flag. - virtual void setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled); - - //! Sets the fog mode. - virtual void setFog(SColor color, E_FOG_TYPE fogType, f32 start, - f32 end, f32 density, bool pixelFog, bool rangeFog); - - //! Only used by the internal engine. Used to notify the driver that - //! the window was resized. - virtual void OnResize(const core::dimension2d<u32>& size); - - //! Can be called by an IMaterialRenderer to make its work easier. - virtual void setBasicRenderStates(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates); - - //! Returns type of video driver - virtual E_DRIVER_TYPE getDriverType() const; - - //! Returns the transformation set by setTransform - virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) const; - - //! Sets a vertex shader constant. - virtual void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1); - - //! Sets a pixel shader constant. - virtual void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1); - - //! Sets a constant for the vertex shader based on a name. - virtual bool setVertexShaderConstant(const c8* name, const f32* floats, int count); - - //! Sets a constant for the pixel shader based on a name. - virtual bool setPixelShaderConstant(const c8* name, const f32* floats, int count); - - //! Returns pointer to the IGPUProgrammingServices interface. - virtual IGPUProgrammingServices* getGPUProgrammingServices(); - - //! Returns a pointer to the IVideoDriver interface. (Implementation for - //! IMaterialRendererServices) - virtual IVideoDriver* getVideoDriver(); - - //! Creates a render target texture. - virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size, - const io::path& name, const ECOLOR_FORMAT format = ECF_UNKNOWN); - - //! Clears the ZBuffer. - virtual void clearZBuffer(); - - //! Returns an image created from the last rendered frame. - virtual IImage* createScreenShot(); - - //! Set/unset a clipping plane. - virtual bool setClipPlane(u32 index, const core::plane3df& plane, bool enable=false); - - //! Enable/disable a clipping plane. - virtual void enableClipPlane(u32 index, bool enable); - - //! Returns the graphics card vendor name. - virtual core::stringc getVendorInfo() {return VendorName;} - - //! Check if the driver was recently reset. - virtual bool checkDriverReset() {return DriverWasReset;} - - // removes the depth struct from the DepthSurface array - void removeDepthSurface(SDepthSurface* depth); - - //! Get the current color format of the color buffer - /** \return Color format of the color buffer. */ - virtual ECOLOR_FORMAT getColorFormat() const; - - //! Get the current color format of the color buffer - /** \return Color format of the color buffer as D3D color value. */ - D3DFORMAT getD3DColorFormat() const; - - //! Get D3D color format from Irrlicht color format. - D3DFORMAT getD3DFormatFromColorFormat(ECOLOR_FORMAT format) const; - - //! Get Irrlicht color format from D3D color format. - ECOLOR_FORMAT getColorFormatFromD3DFormat(D3DFORMAT format) const; - - private: - - //! enumeration for rendering modes such as 2d and 3d for minizing the switching of renderStates. - enum E_RENDER_MODE - { - ERM_NONE = 0, // no render state has been set yet. - ERM_2D, // 2d drawing rendermode - ERM_3D, // 3d rendering mode - ERM_STENCIL_FILL, // stencil fill mode - ERM_SHADOW_VOLUME_ZFAIL, // stencil volume draw mode - ERM_SHADOW_VOLUME_ZPASS // stencil volume draw mode - }; - - //! sets right vertex shader - void setVertexShader(video::E_VERTEX_TYPE newType); - - //! sets the needed renderstates - bool setRenderStates3DMode(); - - //! sets the needed renderstates - void setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel); - - //! sets the needed renderstates - void setRenderStatesStencilFillMode(bool alpha); - - //! sets the needed renderstates - void setRenderStatesStencilShadowMode(bool zfail); - - //! sets the current Texture - bool setActiveTexture(u32 stage, const video::ITexture* texture); - - //! resets the device - bool reset(); - - //! returns a device dependent texture from a software surface (IImage) - //! THIS METHOD HAS TO BE OVERRIDDEN BY DERIVED DRIVERS WITH OWN TEXTURES - virtual video::ITexture* createDeviceDependentTexture(IImage* surface, const io::path& name); - - //! returns the current size of the screen or rendertarget - virtual const core::dimension2d<u32>& getCurrentRenderTargetSize() const; - - //! Check if a proper depth buffer for the RTT is available, otherwise create it. - void checkDepthBuffer(ITexture* tex); - - //! Adds a new material renderer to the VideoDriver, using pixel and/or - //! vertex shaders to render geometry. - s32 addShaderMaterial(const c8* vertexShaderProgram, const c8* pixelShaderProgram, - IShaderConstantSetCallBack* callback, - E_MATERIAL_TYPE baseMaterial, s32 userData); - - //! Adds a new material renderer to the VideoDriver, based on a high level shading - //! language. - virtual s32 addHighLevelShaderMaterial( - const c8* vertexShaderProgram, - const c8* vertexShaderEntryPointName = "main", - E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1, - const c8* pixelShaderProgram = 0, - const c8* pixelShaderEntryPointName = "main", - E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1, - IShaderConstantSetCallBack* callback = 0, - E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, - s32 userData=0); - - void createMaterialRenderers(); - - void draw2D3DVertexPrimitiveList(const void* vertices, - u32 vertexCount, const void* indexList, u32 primitiveCount, - E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, - E_INDEX_TYPE iType, bool is3D); - - inline D3DCOLORVALUE colorToD3D(const SColor& col) - { - const f32 f = 1.0f / 255.0f; - D3DCOLORVALUE v; - v.r = col.getRed() * f; - v.g = col.getGreen() * f; - v.b = col.getBlue() * f; - v.a = col.getAlpha() * f; - return v; - } - - E_RENDER_MODE CurrentRenderMode; - D3DPRESENT_PARAMETERS present; - - SMaterial Material, LastMaterial; - bool ResetRenderStates; // bool to make all renderstates be reseted if set. - bool Transformation3DChanged; - bool StencilBuffer; - u8 AntiAliasing; - const ITexture* CurrentTexture[MATERIAL_MAX_TEXTURES]; - bool LastTextureMipMapsAvailable[MATERIAL_MAX_TEXTURES]; - core::matrix4 Matrices[ETS_COUNT]; // matrizes of the 3d mode we need to restore when we switch back from the 2d mode. - - HINSTANCE D3DLibrary; - IDirect3D9* pID3D; - IDirect3DDevice9* pID3DDevice; - - IDirect3DSurface9* PrevRenderTarget; - core::dimension2d<u32> CurrentRendertargetSize; - core::dimension2d<u32> CurrentDepthBufferSize; - - void* WindowId; - core::rect<s32>* SceneSourceRect; - - D3DCAPS9 Caps; - - E_VERTEX_TYPE LastVertexType; - - SColorf AmbientLight; - - core::stringc VendorName; - u16 VendorID; - - core::array<SDepthSurface*> DepthBuffers; - - u32 MaxTextureUnits; - u32 MaxUserClipPlanes; - f32 MaxLightDistance; - s32 LastSetLight; - - enum E_CACHE_2D_ATTRIBUTES - { - EC2D_ALPHA = 0x1, - EC2D_TEXTURE = 0x2, - EC2D_ALPHA_CHANNEL = 0x4 - }; - - u32 Cached2DModeSignature; - - ECOLOR_FORMAT ColorFormat; - D3DFORMAT D3DColorFormat; - bool DeviceLost; - bool Fullscreen; - bool DriverWasReset; - bool AlphaToCoverageSupport; - }; - - -} // end namespace video -} // end namespace irr - - -#endif // _IRR_COMPILE_WITH_DIRECT3D_9_ -#endif // __C_VIDEO_DIRECTX_9_H_INCLUDED__ - diff --git a/irrlicht-1.6/source/Irrlicht/CD3D9HLSLMaterialRenderer.cpp b/irrlicht-1.6/source/Irrlicht/CD3D9HLSLMaterialRenderer.cpp deleted file mode 100644 index a55c1b652..000000000 --- a/irrlicht-1.6/source/Irrlicht/CD3D9HLSLMaterialRenderer.cpp +++ /dev/null @@ -1,344 +0,0 @@ -// Copyright (C) 2002-2009 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_DIRECT3D_9_ - -#include "CD3D9HLSLMaterialRenderer.h" -#include "IShaderConstantSetCallBack.h" -#include "IVideoDriver.h" -#include "os.h" -#include "irrString.h" - -#ifndef _IRR_D3D_NO_SHADER_DEBUGGING -#include <stdio.h> -#endif - - -namespace irr -{ -namespace video -{ - - -//! Public constructor -CD3D9HLSLMaterialRenderer::CD3D9HLSLMaterialRenderer(IDirect3DDevice9* d3ddev, - video::IVideoDriver* driver, s32& outMaterialTypeNr, - const c8* vertexShaderProgram, - const c8* vertexShaderEntryPointName, - E_VERTEX_SHADER_TYPE vsCompileTarget, - const c8* pixelShaderProgram, - const c8* pixelShaderEntryPointName, - E_PIXEL_SHADER_TYPE psCompileTarget, - IShaderConstantSetCallBack* callback, - IMaterialRenderer* baseMaterial, - s32 userData) - : CD3D9ShaderMaterialRenderer(d3ddev, driver, callback, baseMaterial, userData), - VSConstantsTable(0), PSConstantsTable(0) -{ - - #ifdef _DEBUG - setDebugName("CD3D9HLSLMaterialRenderer"); - #endif - - outMaterialTypeNr = -1; - - // now create shaders - - if (vsCompileTarget < 0 || vsCompileTarget > EVST_COUNT) - { - os::Printer::log("Invalid HLSL vertex shader compilation target", ELL_ERROR); - return; - } - - if (!createHLSLVertexShader(vertexShaderProgram, - vertexShaderEntryPointName, VERTEX_SHADER_TYPE_NAMES[vsCompileTarget])) - return; - - if (!createHLSLPixelShader(pixelShaderProgram, - pixelShaderEntryPointName, PIXEL_SHADER_TYPE_NAMES[psCompileTarget])) - return; - - // register myself as new material - outMaterialTypeNr = Driver->addMaterialRenderer(this); -} - - -//! Destructor -CD3D9HLSLMaterialRenderer::~CD3D9HLSLMaterialRenderer() -{ - if (VSConstantsTable) - VSConstantsTable->Release(); - - if (PSConstantsTable) - PSConstantsTable->Release(); -} - - -bool CD3D9HLSLMaterialRenderer::createHLSLVertexShader(const char* vertexShaderProgram, - const char* shaderEntryPointName, - const char* shaderTargetName) -{ - if (!vertexShaderProgram) - return true; - - LPD3DXBUFFER buffer = 0; - LPD3DXBUFFER errors = 0; - -#ifdef _IRR_D3D_NO_SHADER_DEBUGGING - - // compile without debug info - HRESULT h = stubD3DXCompileShader( - vertexShaderProgram, - strlen(vertexShaderProgram), - 0, // macros - 0, // no includes - shaderEntryPointName, - shaderTargetName, - 0, // no flags - &buffer, - &errors, - &VSConstantsTable); - -#else - - // compile shader and emitt some debug informations to - // make it possible to debug the shader in visual studio - - static int irr_dbg_hlsl_file_nr = 0; - ++irr_dbg_hlsl_file_nr; - char tmp[32]; - sprintf(tmp, "irr_d3d9_dbg_hlsl_%d.vsh", irr_dbg_hlsl_file_nr); - - FILE* f = fopen(tmp, "wb"); - fwrite(vertexShaderProgram, strlen(vertexShaderProgram), 1, f); - fflush(f); - fclose(f); - - HRESULT h = stubD3DXCompileShaderFromFile( - tmp, - 0, // macros - 0, // no includes - shaderEntryPointName, - shaderTargetName, - D3DXSHADER_DEBUG | D3DXSHADER_SKIPOPTIMIZATION, - &buffer, - &errors, - &VSConstantsTable); - -#endif - - if (FAILED(h)) - { - os::Printer::log("HLSL vertex shader compilation failed:", ELL_ERROR); - if (errors) - { - os::Printer::log((c8*)errors->GetBufferPointer(), ELL_ERROR); - errors->Release(); - if (buffer) - buffer->Release(); - } - return false; - } - - if (errors) - errors->Release(); - - if (buffer) - { - if (FAILED(pID3DDevice->CreateVertexShader((DWORD*)buffer->GetBufferPointer(), - &VertexShader))) - { - os::Printer::log("Could not create hlsl vertex shader.", ELL_ERROR); - buffer->Release(); - return false; - } - - buffer->Release(); - return true; - } - - return false; -} - - -bool CD3D9HLSLMaterialRenderer::createHLSLPixelShader(const char* pixelShaderProgram, - const char* shaderEntryPointName, - const char* shaderTargetName) -{ - if (!pixelShaderProgram) - return true; - - LPD3DXBUFFER buffer = 0; - LPD3DXBUFFER errors = 0; - - DWORD flags = 0; - -#ifdef D3DXSHADER_ENABLE_BACKWARDS_COMPATIBILITY - if (Driver->queryFeature(video::EVDF_VERTEX_SHADER_2_0) || Driver->queryFeature(video::EVDF_VERTEX_SHADER_3_0)) - // this one's for newer DX SDKs which don't support ps_1_x anymore - // instead they'll siliently compile 1_x as 2_x when using this flag - flags |= D3DXSHADER_ENABLE_BACKWARDS_COMPATIBILITY; -#endif -#if defined(_IRR_D3D_USE_LEGACY_HLSL_COMPILER) && defined(D3DXSHADER_USE_LEGACY_D3DX9_31_DLL) -#ifdef D3DXSHADER_ENABLE_BACKWARDS_COMPATIBILITY - else -#endif - flags |= D3DXSHADER_USE_LEGACY_D3DX9_31_DLL; -#endif - -#ifdef _IRR_D3D_NO_SHADER_DEBUGGING - - // compile without debug info - HRESULT h = stubD3DXCompileShader( - pixelShaderProgram, - strlen(pixelShaderProgram), - 0, // macros - 0, // no includes - shaderEntryPointName, - shaderTargetName, - flags, - &buffer, - &errors, - &PSConstantsTable); - -#else - - // compile shader and emitt some debug informations to - // make it possible to debug the shader in visual studio - - static int irr_dbg_hlsl_file_nr = 0; - ++irr_dbg_hlsl_file_nr; - char tmp[32]; - sprintf(tmp, "irr_d3d9_dbg_hlsl_%d.psh", irr_dbg_hlsl_file_nr); - - FILE* f = fopen(tmp, "wb"); - fwrite(pixelShaderProgram, strlen(pixelShaderProgram), 1, f); - fflush(f); - fclose(f); - - HRESULT h = stubD3DXCompileShaderFromFile( - tmp, - 0, // macros - 0, // no includes - shaderEntryPointName, - shaderTargetName, - flags | D3DXSHADER_DEBUG | D3DXSHADER_SKIPOPTIMIZATION, - &buffer, - &errors, - &PSConstantsTable); - -#endif - - if (FAILED(h)) - { - os::Printer::log("HLSL pixel shader compilation failed:", ELL_ERROR); - if (errors) - { - os::Printer::log((c8*)errors->GetBufferPointer(), ELL_ERROR); - errors->Release(); - if (buffer) - buffer->Release(); - } - return false; - } - - if (errors) - errors->Release(); - - if (buffer) - { - if (FAILED(pID3DDevice->CreatePixelShader((DWORD*)buffer->GetBufferPointer(), - &PixelShader))) - { - os::Printer::log("Could not create hlsl pixel shader.", ELL_ERROR); - buffer->Release(); - return false; - } - - buffer->Release(); - return true; - } - - return false; -} - - -bool CD3D9HLSLMaterialRenderer::setVariable(bool vertexShader, const c8* name, - const f32* floats, int count) -{ - LPD3DXCONSTANTTABLE tbl = vertexShader ? VSConstantsTable : PSConstantsTable; - if (!tbl) - return false; - - // currently we only support top level parameters. - // Should be enough for the beginning. (TODO) - - D3DXHANDLE hndl = tbl->GetConstantByName(NULL, name); - if (!hndl) - { - core::stringc s = "HLSL Variable to set not found: '"; - s += name; - s += "'. Available variables are:"; - os::Printer::log(s.c_str(), ELL_WARNING); - printHLSLVariables(tbl); - return false; - } - - HRESULT hr = tbl->SetFloatArray(pID3DDevice, hndl, floats, count); - if (FAILED(hr)) - { - os::Printer::log("Error setting float array for HLSL variable", ELL_WARNING); - return false; - } - - return true; -} - - -bool CD3D9HLSLMaterialRenderer::OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype) -{ - if (VSConstantsTable) - VSConstantsTable->SetDefaults(pID3DDevice); - - return CD3D9ShaderMaterialRenderer::OnRender(service, vtxtype); -} - - -void CD3D9HLSLMaterialRenderer::printHLSLVariables(LPD3DXCONSTANTTABLE table) -{ - // currently we only support top level parameters. - // Should be enough for the beginning. (TODO) - - // print out constant names - D3DXCONSTANTTABLE_DESC tblDesc; - HRESULT hr = table->GetDesc(&tblDesc); - if (!FAILED(hr)) - { - for (int i=0; i<(int)tblDesc.Constants; ++i) - { - D3DXCONSTANT_DESC d; - UINT n = 1; - D3DXHANDLE cHndl = table->GetConstant(NULL, i); - if (!FAILED(table->GetConstantDesc(cHndl, &d, &n))) - { - core::stringc s = " '"; - s += d.Name; - s += "' Registers:[begin:"; - s += (int)d.RegisterIndex; - s += ", count:"; - s += (int)d.RegisterCount; - s += "]"; - os::Printer::log(s.c_str()); - } - } - } -} - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_DIRECT3D_9_ - diff --git a/irrlicht-1.6/source/Irrlicht/CD3D9HLSLMaterialRenderer.h b/irrlicht-1.6/source/Irrlicht/CD3D9HLSLMaterialRenderer.h deleted file mode 100644 index 917447396..000000000 --- a/irrlicht-1.6/source/Irrlicht/CD3D9HLSLMaterialRenderer.h +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_D3D9_HLSL_MATERIAL_RENDERER_H_INCLUDED__ -#define __C_D3D9_HLSL_MATERIAL_RENDERER_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_WINDOWS_ - -#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ - -#include "CD3D9ShaderMaterialRenderer.h" -#include "IGPUProgrammingServices.h" - -namespace irr -{ -namespace video -{ - -class IVideoDriver; -class IShaderConstantSetCallBack; -class IMaterialRenderer; - -//! Class for using vertex and pixel shaders via HLSL with D3D9 -class CD3D9HLSLMaterialRenderer : public CD3D9ShaderMaterialRenderer -{ -public: - - //! Public constructor - CD3D9HLSLMaterialRenderer(IDirect3DDevice9* d3ddev, video::IVideoDriver* driver, - s32& outMaterialTypeNr, - const c8* vertexShaderProgram, - const c8* vertexShaderEntryPointName, - E_VERTEX_SHADER_TYPE vsCompileTarget, - const c8* pixelShaderProgram, - const c8* pixelShaderEntryPointName, - E_PIXEL_SHADER_TYPE psCompileTarget, - IShaderConstantSetCallBack* callback, - IMaterialRenderer* baseMaterial, - s32 userData); - - //! Destructor - ~CD3D9HLSLMaterialRenderer(); - - //! sets a variable in the shader. - //! \param vertexShader: True if this should be set in the vertex shader, false if - //! in the pixel shader. - //! \param name: Name of the variable - //! \param floats: Pointer to array of floats - //! \param count: Amount of floats in array. - virtual bool setVariable(bool vertexShader, const c8* name, const f32* floats, int count); - - bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype); - -protected: - - bool createHLSLVertexShader(const char* vertexShaderProgram, - const char* shaderEntryPointName, - const char* shaderTargetName); - - bool createHLSLPixelShader(const char* pixelShaderProgram, - const char* shaderEntryPointName, - const char* shaderTargetName); - - void printHLSLVariables(LPD3DXCONSTANTTABLE table); - - LPD3DXCONSTANTTABLE VSConstantsTable; - LPD3DXCONSTANTTABLE PSConstantsTable; -}; - - -} // end namespace video -} // end namespace irr - -#endif -#endif -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CD3D9MaterialRenderer.h b/irrlicht-1.6/source/Irrlicht/CD3D9MaterialRenderer.h deleted file mode 100644 index f38e99194..000000000 --- a/irrlicht-1.6/source/Irrlicht/CD3D9MaterialRenderer.h +++ /dev/null @@ -1,621 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_D3D9_MATERIAL_RENDERER_H_INCLUDED__ -#define __C_D3D9_MATERIAL_RENDERER_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_WINDOWS_ - -#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ -#include <d3d9.h> - -#include "IMaterialRenderer.h" - -namespace irr -{ -namespace video -{ - -D3DMATRIX UnitMatrixD3D9; -D3DMATRIX SphereMapMatrixD3D9; - -//! Base class for all internal D3D9 material renderers -class CD3D9MaterialRenderer : public IMaterialRenderer -{ -public: - - //! Constructor - CD3D9MaterialRenderer(IDirect3DDevice9* d3ddev, video::IVideoDriver* driver) - : pID3DDevice(d3ddev), Driver(driver) - { - } - - ~CD3D9MaterialRenderer() - { - } - - //! sets a variable in the shader. - //! \param vertexShader: True if this should be set in the vertex shader, false if - //! in the pixel shader. - //! \param name: Name of the variable - //! \param floats: Pointer to array of floats - //! \param count: Amount of floats in array. - virtual bool setVariable(bool vertexShader, const c8* name, const f32* floats, int count) - { - os::Printer::log("Invalid material to set variable in."); - return false; - } - -protected: - - IDirect3DDevice9* pID3DDevice; - video::IVideoDriver* Driver; -}; - - -//! Solid material renderer -class CD3D9MaterialRenderer_SOLID : public CD3D9MaterialRenderer -{ -public: - - CD3D9MaterialRenderer_SOLID(IDirect3DDevice9* p, video::IVideoDriver* d) - : CD3D9MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - } - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } -}; - -//! Generic Texture Blend -class CD3D9MaterialRenderer_ONETEXTURE_BLEND : public CD3D9MaterialRenderer -{ -public: - - CD3D9MaterialRenderer_ONETEXTURE_BLEND(IDirect3DDevice9* p, video::IVideoDriver* d) - : CD3D9MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || - material.MaterialTypeParam != lastMaterial.MaterialTypeParam || - resetAllRenderstates) - { - - E_BLEND_FACTOR srcFact,dstFact; - E_MODULATE_FUNC modulate; - u32 alphaSource; - unpack_texureBlendFunc ( srcFact, dstFact, modulate, alphaSource, material.MaterialTypeParam ); - - if (srcFact == EBF_SRC_COLOR && dstFact == EBF_ZERO) - { - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - } - else - { - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_SRCBLEND, getD3DBlend ( srcFact ) ); - pID3DDevice->SetRenderState(D3DRS_DESTBLEND, getD3DBlend ( dstFact ) ); - } - - pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, getD3DModulate ( modulate ) ); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - - if ( textureBlendFunc_hasAlpha ( srcFact ) || textureBlendFunc_hasAlpha ( dstFact ) ) - { - if (alphaSource==EAS_VERTEX_COLOR) - { - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE ); - } - else if (alphaSource==EAS_TEXTURE) - { - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); - } - else - { - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE ); - } - } - else - { - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); - } - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); - - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - - } - - //! Returns if the material is transparent. - /** The scene management needs to know this for being able to sort the - materials by opaque and transparent. - The return value could be optimized, but we'd need to know the - MaterialTypeParam for it. */ - virtual bool isTransparent() const - { - return true; - } - - private: - - u32 getD3DBlend ( E_BLEND_FACTOR factor ) const - { - u32 r = 0; - switch ( factor ) - { - case EBF_ZERO: r = D3DBLEND_ZERO; break; - case EBF_ONE: r = D3DBLEND_ONE; break; - case EBF_DST_COLOR: r = D3DBLEND_DESTCOLOR; break; - case EBF_ONE_MINUS_DST_COLOR: r = D3DBLEND_INVDESTCOLOR; break; - case EBF_SRC_COLOR: r = D3DBLEND_SRCCOLOR; break; - case EBF_ONE_MINUS_SRC_COLOR: r = D3DBLEND_INVSRCCOLOR; break; - case EBF_SRC_ALPHA: r = D3DBLEND_SRCALPHA; break; - case EBF_ONE_MINUS_SRC_ALPHA: r = D3DBLEND_INVSRCALPHA; break; - case EBF_DST_ALPHA: r = D3DBLEND_DESTALPHA; break; - case EBF_ONE_MINUS_DST_ALPHA: r = D3DBLEND_INVDESTALPHA; break; - case EBF_SRC_ALPHA_SATURATE: r = D3DBLEND_SRCALPHASAT; break; - } - return r; - } - - u32 getD3DModulate ( E_MODULATE_FUNC func ) const - { - u32 r = D3DTOP_MODULATE; - switch ( func ) - { - case EMFN_MODULATE_1X: r = D3DTOP_MODULATE; break; - case EMFN_MODULATE_2X: r = D3DTOP_MODULATE2X; break; - case EMFN_MODULATE_4X: r = D3DTOP_MODULATE4X; break; - } - return r; - } - - bool transparent; - -}; - - - -//! Solid 2 layer material renderer -class CD3D9MaterialRenderer_SOLID_2_LAYER : public CD3D9MaterialRenderer -{ -public: - - CD3D9MaterialRenderer_SOLID_2_LAYER(IDirect3DDevice9* p, video::IVideoDriver* d) - : CD3D9MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 0); - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_BLENDDIFFUSEALPHA); - - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } -}; - - -//! Transparent add color material renderer -class CD3D9MaterialRenderer_TRANSPARENT_ADD_COLOR : public CD3D9MaterialRenderer -{ -public: - - CD3D9MaterialRenderer_TRANSPARENT_ADD_COLOR(IDirect3DDevice9* p, video::IVideoDriver* d) - : CD3D9MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); - pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCCOLOR); - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } - - //! Returns if the material is transparent. The scene management needs to know this - //! for being able to sort the materials by opaque and transparent. - virtual bool isTransparent() const - { - return true; - } -}; - - -//! Transparent vertex alpha material renderer -class CD3D9MaterialRenderer_TRANSPARENT_VERTEX_ALPHA : public CD3D9MaterialRenderer -{ -public: - - CD3D9MaterialRenderer_TRANSPARENT_VERTEX_ALPHA(IDirect3DDevice9* p, video::IVideoDriver* d) - : CD3D9MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); - pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } - - //! Returns if the material is transparent. The scene managment needs to know this - //! for being able to sort the materials by opaque and transparent. - virtual bool isTransparent() const - { - return true; - } -}; - - -//! Transparent alpha channel material renderer -class CD3D9MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL : public CD3D9MaterialRenderer -{ -public: - - CD3D9MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL(IDirect3DDevice9* p, video::IVideoDriver* d) - : CD3D9MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates - || material.MaterialTypeParam != lastMaterial.MaterialTypeParam ) - { - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_CURRENT ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); - - pID3DDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE ); - pID3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); - - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); - pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); - - pID3DDevice->SetRenderState(D3DRS_ALPHAREF, core::floor32(material.MaterialTypeParam * 255.f)); - pID3DDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL); - pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE); - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } - - virtual void OnUnsetMaterial() - { - pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE); - } - - //! Returns if the material is transparent. The scene managment needs to know this - //! for being able to sort the materials by opaque and transparent. - virtual bool isTransparent() const - { - return true; - } -}; - - - -//! Transparent alpha channel material renderer -class CD3D9MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF : public CD3D9MaterialRenderer -{ -public: - - CD3D9MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF(IDirect3DDevice9* p, video::IVideoDriver* d) - : CD3D9MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_CURRENT ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); - - pID3DDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE ); - pID3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); - - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - - // 127 is required by EMT_TRANSPARENT_ALPHA_CHANNEL_REF - pID3DDevice->SetRenderState(D3DRS_ALPHAREF, 127); - pID3DDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL); - pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE); - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } - - virtual void OnUnsetMaterial() - { - pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE); - } - - //! Returns if the material is transparent. The scene managment needs to know this - //! for being able to sort the materials by opaque and transparent. - virtual bool isTransparent() const - { - return false; // this material is not really transparent because it does no blending. - } -}; - - -//! material renderer for all kinds of lightmaps -class CD3D9MaterialRenderer_LIGHTMAP : public CD3D9MaterialRenderer -{ -public: - - CD3D9MaterialRenderer_LIGHTMAP(IDirect3DDevice9* p, video::IVideoDriver* d) - : CD3D9MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - if (material.MaterialType >= EMT_LIGHTMAP_LIGHTING) - { - // with lighting - pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - } - else - { - pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1); - pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - } - - pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1); - - if (material.MaterialType == EMT_LIGHTMAP_ADD) - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_ADD); - else - if (material.MaterialType == EMT_LIGHTMAP_M4) - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE4X); - else - if (material.MaterialType == EMT_LIGHTMAP_M2) - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE2X); - else - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT); - pID3DDevice->SetTextureStageState (1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } -}; - - - -//! material renderer for detail maps -class CD3D9MaterialRenderer_DETAIL_MAP : public CD3D9MaterialRenderer -{ -public: - - CD3D9MaterialRenderer_DETAIL_MAP(IDirect3DDevice9* p, video::IVideoDriver* d) - : CD3D9MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetTextureStageState (1, D3DTSS_COLOROP, D3DTOP_ADDSIGNED); - pID3DDevice->SetTextureStageState (1, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState (1, D3DTSS_COLORARG2, D3DTA_CURRENT); - pID3DDevice->SetTextureStageState (1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } -}; - - -//! sphere map material renderer -class CD3D9MaterialRenderer_SPHERE_MAP : public CD3D9MaterialRenderer -{ -public: - - CD3D9MaterialRenderer_SPHERE_MAP(IDirect3DDevice9* p, video::IVideoDriver* d) - : CD3D9MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - - pID3DDevice->SetTransform( D3DTS_TEXTURE0, &SphereMapMatrixD3D9 ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACENORMAL ); - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } - - virtual void OnUnsetMaterial() - { - pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0); - pID3DDevice->SetTransform( D3DTS_TEXTURE0, &UnitMatrixD3D9 ); - } -}; - - -//! reflection 2 layer material renderer -class CD3D9MaterialRenderer_REFLECTION_2_LAYER : public CD3D9MaterialRenderer -{ -public: - - CD3D9MaterialRenderer_REFLECTION_2_LAYER(IDirect3DDevice9* p, video::IVideoDriver* d) - : CD3D9MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT); - - pID3DDevice->SetTransform( D3DTS_TEXTURE1, &SphereMapMatrixD3D9 ); - pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 ); - pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } - - virtual void OnUnsetMaterial() - { - pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE ); - pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 1); - pID3DDevice->SetTransform( D3DTS_TEXTURE1, &UnitMatrixD3D9 ); - } -}; - - -//! reflection 2 layer material renderer -class CD3D9MaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER : public CD3D9MaterialRenderer -{ -public: - - CD3D9MaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER(IDirect3DDevice9* p, video::IVideoDriver* d) - : CD3D9MaterialRenderer(p, d) {} - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE); - pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE); - pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT); - - pID3DDevice->SetTransform( D3DTS_TEXTURE1, &SphereMapMatrixD3D9 ); - pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 ); - pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR); - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - - pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); - pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); - } - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - } - - virtual void OnUnsetMaterial() - { - pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE ); - pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 1); - pID3DDevice->SetTransform( D3DTS_TEXTURE1, &UnitMatrixD3D9 ); - } - - //! Returns if the material is transparent. The scene managment needs to know this - //! for being able to sort the materials by opaque and transparent. - virtual bool isTransparent() const - { - return true; - } -}; - -} // end namespace video -} // end namespace irr - -#endif -#endif -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CD3D9NormalMapRenderer.cpp b/irrlicht-1.6/source/Irrlicht/CD3D9NormalMapRenderer.cpp deleted file mode 100644 index c175d9310..000000000 --- a/irrlicht-1.6/source/Irrlicht/CD3D9NormalMapRenderer.cpp +++ /dev/null @@ -1,306 +0,0 @@ -// Copyright (C) 2002-2009 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_DIRECT3D_9_ - -#include "CD3D9NormalMapRenderer.h" -#include "IVideoDriver.h" -#include "IMaterialRendererServices.h" -#include "os.h" -#include "SLight.h" - -namespace irr -{ -namespace video -{ - - // 1.1 Shaders with two lights and vertex based attenuation - - // Irrlicht Engine D3D9 render path normal map vertex shader - const char D3D9_NORMAL_MAP_VSH[] = - ";Irrlicht Engine 0.8 D3D9 render path normal map vertex shader\n"\ - "; c0-3: Transposed world matrix \n"\ - "; c8-11: Transposed worldViewProj matrix (Projection * View * World) \n"\ - "; c12: Light01 position \n"\ - "; c13: x,y,z: Light01 color; .w: 1/LightRadius \n"\ - "; c14: Light02 position \n"\ - "; c15: x,y,z: Light02 color; .w: 1/LightRadius \n"\ - "vs.1.1\n"\ - "dcl_position v0 ; position \n"\ - "dcl_normal v1 ; normal \n"\ - "dcl_color v2 ; color \n"\ - "dcl_texcoord0 v3 ; texture coord \n"\ - "dcl_texcoord1 v4 ; tangent \n"\ - "dcl_texcoord2 v5 ; binormal \n"\ - "\n"\ - "def c95, 0.5, 0.5, 0.5, 0.5 ; used for moving light vector to ps \n"\ - "\n"\ - "m4x4 oPos, v0, c8 ; transform position to clip space with worldViewProj matrix\n"\ - "\n"\ - "m3x3 r5, v4, c0 ; transform tangent U\n"\ - "m3x3 r7, v1, c0 ; transform normal W\n"\ - "m3x3 r6, v5, c0 ; transform binormal V\n"\ - "\n"\ - "m4x4 r4, v0, c0 ; vertex into world position\n"\ - "add r2, c12, -r4 ; vtxpos - lightpos1\n"\ - "add r3, c14, -r4 ; vtxpos - lightpos2\n"\ - "\n"\ - "dp3 r8.x, r5, r2 ; transform the light vector 1 with U, V, W\n"\ - "dp3 r8.y, r6, r2 \n"\ - "dp3 r8.z, r7, r2 \n"\ - "dp3 r9.x, r5, r3 ; transform the light vector 2 with U, V, W\n"\ - "dp3 r9.y, r6, r3 \n"\ - "dp3 r9.z, r7, r3 \n"\ - "\n"\ - "dp3 r8.w, r8, r8 ; normalize light vector 1 (r8)\n"\ - "rsq r8.w, r8.w \n"\ - "mul r8, r8, r8.w \n"\ - "dp3 r9.w, r9, r9 ; normalize light vector 2 (r9)\n"\ - "rsq r9.w, r9.w \n"\ - "mul r9, r9, r9.w \n"\ - "\n"\ - "mad oT2.xyz, r8.xyz, c95, c95 ; move light vector 1 from -1..1 into 0..1 \n"\ - "mad oT3.xyz, r9.xyz, c95, c95 ; move light vector 2 from -1..1 into 0..1 \n"\ - "\n"\ - " ; calculate attenuation of light 1 \n"\ - "dp3 r2.x, r2.xyz, r2.xyz ; r2.x = r2.x + r2.y + r2.z \n"\ - "mul r2.x, r2.x, c13.w ; r2.x * attenutation \n"\ - "rsq r2, r2.x ; r2.xyzw = 1/sqrt(r2.x * attenutation)\n"\ - "mul oD0, r2, c13 ; resulting light color = lightcolor * attenuation \n"\ - "\n"\ - " ; calculate attenuation of light 2 \n"\ - "dp3 r3.x, r3.xyz, r3.xyz ; r3.x = r3.x + r3.y + r3.z \n"\ - "mul r3.x, r3.x, c15.w ; r2.x * attenutation \n"\ - "rsq r3, r3.x ; r2.xyzw = 1/sqrt(r2.x * attenutation)\n"\ - "mul oD1, r3, c15 ; resulting light color = lightcolor * attenuation \n"\ - "\n"\ - "mov oT0.xy, v3.xy ; move out texture coordinates 1\n"\ - "mov oT1.xy, v3.xy ; move out texture coordinates 2\n"\ - "mov oD0.a, v2.a ; move out original alpha value \n"\ - "\n"; - - // Irrlicht Engine D3D9 render path normal map pixel shader - const char D3D9_NORMAL_MAP_PSH_1_1[] = - ";Irrlicht Engine 0.8 D3D9 render path normal map pixel shader\n"\ - ";Input: \n"\ - ";t0: color map texture coord \n"\ - ";t1: normal map texture coords \n"\ - ";t2: light 1 vector in tangent space \n"\ - ";v0: light 1 color \n"\ - ";t3: light 2 vector in tangent space \n"\ - ";v1: light 2 color \n"\ - ";v0.a: vertex alpha value \n"\ - "ps.1.1 \n"\ - "tex t0 ; sample color map \n"\ - "tex t1 ; sample normal map\n"\ - "texcoord t2 ; fetch light vector 1\n"\ - "texcoord t3 ; fetch light vector 2\n"\ - "\n"\ - "dp3_sat r0, t1_bx2, t2_bx2 ; normal dot light 1 (_bx2 because moved into 0..1)\n"\ - "mul r0, r0, v0 ; luminance1 * light color 1 \n"\ - "\n"\ - "dp3_sat r1, t1_bx2, t3_bx2 ; normal dot light 2 (_bx2 because moved into 0..1)\n"\ - "mad r0, r1, v1, r0 ; (luminance2 * light color 2) + luminance 1 \n"\ - "\n"\ - "mul r0.xyz, t0, r0 ; total luminance * base color\n"\ - "+mov r0.a, v0.a ; write interpolated vertex alpha value \n"\ - "\n"\ - ""; - - // Higher-quality normal map pixel shader (requires PS 2.0) - // uses per-pixel normalization for improved accuracy - const char D3D9_NORMAL_MAP_PSH_2_0[] = - ";Irrlicht Engine 0.8 D3D9 render path normal map pixel shader\n"\ - ";Input: \n"\ - ";t0: color map texture coord \n"\ - ";t1: normal map texture coords \n"\ - ";t2: light 1 vector in tangent space \n"\ - ";v0: light 1 color \n"\ - ";t3: light 2 vector in tangent space \n"\ - ";v1: light 2 color \n"\ - ";v0.a: vertex alpha value \n"\ - - "ps_2_0 \n"\ - "def c0, 0, 0, 0, 0\n"\ - "def c1, 1.0, 1.0, 1.0, 1.0\n"\ - "def c2, 2.0, 2.0, 2.0, 2.0\n"\ - "def c3, -.5, -.5, -.5, -.5\n"\ - "dcl t0\n"\ - "dcl t1\n"\ - "dcl t2\n"\ - "dcl t3\n"\ - "dcl v1\n"\ - "dcl v0\n"\ - "dcl_2d s0\n"\ - "dcl_2d s1\n"\ - - "texld r0, t0, s0 ; sample color map into r0 \n"\ - "texld r4, t0, s1 ; sample normal map into r4\n"\ - "add r4, r4, c3 ; bias the normal vector\n"\ - "add r5, t2, c3 ; bias the light 1 vector into r5\n"\ - "add r6, t3, c3 ; bias the light 2 vector into r6\n"\ - - "nrm r1, r4 ; normalize the normal vector into r1\n"\ - "nrm r2, r5 ; normalize the light1 vector into r2\n"\ - "nrm r3, r6 ; normalize the light2 vector into r3\n"\ - - "dp3 r2, r2, r1 ; let r2 = normal DOT light 1 vector\n"\ - "max r2, r2, c0 ; clamp result to positive numbers\n"\ - "mul r2, r2, v0 ; let r2 = luminance1 * light color 1 \n"\ - - "dp3 r3, r3, r1 ; let r3 = normal DOT light 2 vector\n"\ - "max r3, r3, c0 ; clamp result to positive numbers\n"\ - - "mad r2, r3, v1, r2 ; let r2 = (luminance2 * light color 2) + (luminance2 * light color 1) \n"\ - - "mul r2, r2, r0 ; let r2 = total luminance * base color\n"\ - "mov r2.w, v0.w ; write interpolated vertex alpha value \n"\ - - "mov oC0, r2 ; copy r2 to the output register \n"\ - - "\n"\ - ""; - - CD3D9NormalMapRenderer::CD3D9NormalMapRenderer( - IDirect3DDevice9* d3ddev, video::IVideoDriver* driver, - s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial) - : CD3D9ShaderMaterialRenderer(d3ddev, driver, 0, baseMaterial) - { - #ifdef _DEBUG - setDebugName("CD3D9NormalMapRenderer"); - #endif - - // set this as callback. We could have done this in - // the initialization list, but some compilers don't like it. - - CallBack = this; - - // basically, this thing simply compiles the hardcoded shaders - // if the hardware is able to do them, otherwise it maps to the - // base material - - if (!driver->queryFeature(video::EVDF_PIXEL_SHADER_1_1) || - !driver->queryFeature(video::EVDF_VERTEX_SHADER_1_1)) - { - // this hardware is not able to do shaders. Fall back to - // base material. - outMaterialTypeNr = driver->addMaterialRenderer(this); - return; - } - - // check if already compiled normal map shaders are there. - - video::IMaterialRenderer* renderer = driver->getMaterialRenderer(EMT_NORMAL_MAP_SOLID); - if (renderer) - { - // use the already compiled shaders - video::CD3D9NormalMapRenderer* nmr = (video::CD3D9NormalMapRenderer*)renderer; - VertexShader = nmr->VertexShader; - if (VertexShader) - VertexShader->AddRef(); - - PixelShader = nmr->PixelShader; - if (PixelShader) - PixelShader->AddRef(); - - outMaterialTypeNr = driver->addMaterialRenderer(this); - } - else - { - // compile shaders on our own - if (driver->queryFeature(video::EVDF_PIXEL_SHADER_2_0)) - { - init(outMaterialTypeNr, D3D9_NORMAL_MAP_VSH, D3D9_NORMAL_MAP_PSH_2_0); - } - else - { - init(outMaterialTypeNr, D3D9_NORMAL_MAP_VSH, D3D9_NORMAL_MAP_PSH_1_1); - } - } - // something failed, use base material - if (-1==outMaterialTypeNr) - driver->addMaterialRenderer(this); - } - - - CD3D9NormalMapRenderer::~CD3D9NormalMapRenderer() - { - if (CallBack == this) - CallBack = 0; - } - - - bool CD3D9NormalMapRenderer::OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype) - { - if (vtxtype != video::EVT_TANGENTS) - { - os::Printer::log("Error: Normal map renderer only supports vertices of type EVT_TANGENTS", ELL_ERROR); - return false; - } - - return CD3D9ShaderMaterialRenderer::OnRender(service, vtxtype); - } - - - //! Returns the render capability of the material. - s32 CD3D9NormalMapRenderer::getRenderCapability() const - { - if (Driver->queryFeature(video::EVDF_PIXEL_SHADER_1_1) && - Driver->queryFeature(video::EVDF_VERTEX_SHADER_1_1)) - return 0; - - return 1; - } - - - //! Called by the engine when the vertex and/or pixel shader constants - //! for an material renderer should be set. - void CD3D9NormalMapRenderer::OnSetConstants(IMaterialRendererServices* services, s32 userData) - { - video::IVideoDriver* driver = services->getVideoDriver(); - - // set transposed world matrix - services->setVertexShaderConstant(driver->getTransform(video::ETS_WORLD).getTransposed().pointer(), 0, 4); - - // set transposed worldViewProj matrix - core::matrix4 worldViewProj(driver->getTransform(video::ETS_PROJECTION)); - worldViewProj *= driver->getTransform(video::ETS_VIEW); - worldViewProj *= driver->getTransform(video::ETS_WORLD); - services->setVertexShaderConstant(worldViewProj.getTransposed().pointer(), 8, 4); - - // here we've got to fetch the fixed function lights from the - // driver and set them as constants - - u32 cnt = driver->getDynamicLightCount(); - - for (u32 i=0; i<2; ++i) - { - SLight light; - - if (i<cnt) - light = driver->getDynamicLight(i); - else - { - light.DiffuseColor.set(0,0,0); // make light dark - light.Radius = 1.0f; - } - - light.DiffuseColor.a = 1.0f/(light.Radius*light.Radius); // set attenuation - - services->setVertexShaderConstant(reinterpret_cast<const f32*>(&light.Position), 12+(i*2), 1); - services->setVertexShaderConstant(reinterpret_cast<const f32*>(&light.DiffuseColor), 13+(i*2), 1); - } - - // this is not really necessary in d3d9 (used a def instruction), but to be sure: - f32 c95[] = {0.5f, 0.5f, 0.5f, 0.5f}; - services->setVertexShaderConstant(c95, 95, 1); - } - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_DIRECT3D_9_ - diff --git a/irrlicht-1.6/source/Irrlicht/CD3D9NormalMapRenderer.h b/irrlicht-1.6/source/Irrlicht/CD3D9NormalMapRenderer.h deleted file mode 100644 index 7f9f88b84..000000000 --- a/irrlicht-1.6/source/Irrlicht/CD3D9NormalMapRenderer.h +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_D3D9_NORMAL_MAPMATERIAL_RENDERER_H_INCLUDED__ -#define __C_D3D9_NORMAL_MAPMATERIAL_RENDERER_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_WINDOWS_ - -#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ -#include <d3d9.h> - -#include "CD3D9ShaderMaterialRenderer.h" -#include "IShaderConstantSetCallBack.h" - -namespace irr -{ -namespace video -{ - -//! Renderer for normal maps -class CD3D9NormalMapRenderer : - public CD3D9ShaderMaterialRenderer, IShaderConstantSetCallBack -{ -public: - - CD3D9NormalMapRenderer( - IDirect3DDevice9* d3ddev, video::IVideoDriver* driver, - s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial); - - ~CD3D9NormalMapRenderer(); - - //! Called by the engine when the vertex and/or pixel shader constants for an - //! material renderer should be set. - virtual void OnSetConstants(IMaterialRendererServices* services, s32 userData); - - virtual bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype); - - //! Returns the render capability of the material. - virtual s32 getRenderCapability() const; - -private: - -}; - -} // end namespace video -} // end namespace irr - -#endif -#endif -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CD3D9ParallaxMapRenderer.cpp b/irrlicht-1.6/source/Irrlicht/CD3D9ParallaxMapRenderer.cpp deleted file mode 100644 index 5ca4b6221..000000000 --- a/irrlicht-1.6/source/Irrlicht/CD3D9ParallaxMapRenderer.cpp +++ /dev/null @@ -1,410 +0,0 @@ -// Copyright (C) 2002-2009 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_DIRECT3D_9_ - -#include "CD3D9ParallaxMapRenderer.h" -#include "IMaterialRendererServices.h" -#include "IVideoDriver.h" -#include "os.h" -#include "SLight.h" - -//#define SHADER_EXTERNAL_DEBUG - -#ifdef SHADER_EXTERNAL_DEBUG -#include "CReadFile.h" -#endif - -namespace irr -{ -namespace video -{ - // 1.1/1.4 Shaders with two lights and vertex based attenuation - - // Irrlicht Engine D3D9 render path normal map vertex shader - const char D3D9_PARALLAX_MAP_VSH[] = - ";Irrlicht Engine 0.10 D3D9 render path parallax mapping vertex shader\n"\ - "; c0-3: Transposed world matrix \n"\ - "; c4: Eye position \n"\ - "; c8-11: Transposed worldViewProj matrix (Projection * View * World) \n"\ - "; c12: Light01 position \n"\ - "; c13: x,y,z: Light01 color; .w: 1/LightRadius \n"\ - "; c14: Light02 position \n"\ - "; c15: x,y,z: Light02 color; .w: 1/LightRadius \n"\ - "vs.1.1\n"\ - "dcl_position v0 ; position \n"\ - "dcl_normal v1 ; normal \n"\ - "dcl_color v2 ; color \n"\ - "dcl_texcoord0 v3 ; texture coord \n"\ - "dcl_texcoord1 v4 ; tangent \n"\ - "dcl_texcoord2 v5 ; binormal \n"\ - "\n"\ - "def c95, 0.5, 0.5, 0.5, 0.5 ; used for moving light vector to ps \n"\ - "def c96, -1, 1, 1, 1 ; somewhere I've got a bug. flipping the vectors with this fixes it. \n"\ - "\n"\ - "m4x4 oPos, v0, c8 ; transform position to clip space with worldViewProj matrix\n"\ - "\n"\ - "m3x3 r5, v4, c0 ; transform tangent U\n"\ - "m3x3 r7, v1, c0 ; transform normal W\n"\ - "m3x3 r6, v5, c0 ; transform binormal V\n"\ - "\n"\ - "m4x4 r4, v0, c0 ; vertex into world position\n"\ - "add r2, c12, -r4 ; vtxpos - light1 pos\n"\ - "add r3, c14, -r4 ; vtxpos - light2 pos\n"\ - "add r1, -c4, r4 ; eye - vtxpos \n"\ - "\n"\ - "dp3 r8.x, r5, r2 ; transform the light1 vector with U, V, W\n"\ - "dp3 r8.y, r6, r2 \n"\ - "dp3 r8.z, r7, r2 \n"\ - "dp3 r9.x, r5, r3 ; transform the light2 vector with U, V, W\n"\ - "dp3 r9.y, r6, r3 \n"\ - "dp3 r9.z, r7, r3 \n"\ - "dp3 r10.x, r5, r1 ; transform the eye vector with U, V, W\n"\ - "dp3 r10.y, r6, r1 \n"\ - "dp3 r10.z, r7, r1 \n"\ - "\n"\ - "dp3 r8.w, r8, r8 ; normalize light vector 1 (r8)\n"\ - "rsq r8.w, r8.w \n"\ - "mul r8, r8, r8.w \n"\ - ";mul r8, r8, c96 \n"\ - "dp3 r9.w, r9, r9 ; normalize light vector 2 (r9)\n"\ - "rsq r9.w, r9.w \n"\ - "mul r9, r9, r9.w \n"\ - ";mul r9, r9, c96 \n"\ - "dp3 r10.w, r10, r10 ; normalize eye vector (r10)\n"\ - "rsq r10.w, r10.w \n"\ - "mul r10, r10, r10.w \n"\ - "mul r10, r10, c96 \n"\ - "\n"\ - "\n"\ - "mad oT2.xyz, r8.xyz, c95, c95 ; move light vector 1 from -1..1 into 0..1 \n"\ - "mad oT3.xyz, r9.xyz, c95, c95 ; move light vector 2 from -1..1 into 0..1 \n"\ - "mad oT4.xyz, r10.xyz, c95, c95 ; move eye vector from -1..1 into 0..1 \n"\ - "\n"\ - " ; calculate attenuation of light 1 \n"\ - "dp3 r2.x, r2.xyz, r2.xyz ; r2.x = r2.x + r2.y + r2.z \n"\ - "mul r2.x, r2.x, c13.w ; r2.x * attenutation \n"\ - "rsq r2, r2.x ; r2.xyzw = 1/sqrt(r2.x * attenutation)\n"\ - "mul oD0, r2, c13 ; resulting light color = lightcolor * attenuation \n"\ - "\n"\ - " ; calculate attenuation of light 2 \n"\ - "dp3 r3.x, r3.xyz, r3.xyz ; r3.x = r3.x + r3.y + r3.z \n"\ - "mul r3.x, r3.x, c15.w ; r2.x * attenutation \n"\ - "rsq r3, r3.x ; r2.xyzw = 1/sqrt(r2.x * attenutation)\n"\ - "mul oD1, r3, c15 ; resulting light color = lightcolor * attenuation \n"\ - "\n"\ - "mov oT0.xy, v3.xy ; move out texture coordinates 1\n"\ - "mov oT1.xy, v3.xy ; move out texture coordinates 2\n"\ - "mov oD0.a, v2.a ; move out original alpha value \n"\ - "\n"; - - - // Irrlicht Engine D3D9 render path normal map pixel shader version 1.4 - const char D3D9_PARALLAX_MAP_PSH[] = - ";Irrlicht Engine 0.10 D3D9 render path parallax mapping pixel shader \n"\ - ";Input: \n"\ - ";t0: color map texture coord \n"\ - ";t1: normal map texture coords \n"\ - ";t2: light 1 vector in tangent space \n"\ - ";t4: eye vector in tangent space \n"\ - ";v0: light 1 color \n"\ - ";t3: light 2 vector in tangent space \n"\ - ";v1: light 2 color \n"\ - ";v0.a: vertex alpha value \n"\ - " \n"\ - "ps.1.4 \n"\ - " \n"\ - ";def c6, 0.02f, 0.02f, 0.02f, 0.0f ; scale factor, now set in callback \n"\ - "def c5, 0.5f, 0.5f, 0.5f, 0.0f ; for specular division \n"\ - " \n"\ - "texld r1, t1 ; sample (normal.x, normal.y, normal.z, height) \n"\ - "texcrd r4.xyz, t4 ; fetch eye vector \n"\ - "texcrd r0.xyz, t0 ; color map \n"\ - " \n"\ - "; original parallax mapping: \n"\ - ";mul r3, r1_bx2.wwww, c6; ; r3 = (height, height, height) * scale \n"\ - ";mad r2.xyz, r3, r4_bx2, r0 ; newTexCoord = height * eye + oldTexCoord \n"\ - " \n"\ - "; modified parallax mapping to reduce swimming effect: \n"\ - "mul r3, r1_bx2.wwww, r1_bx2.zzzz ; (nh,nh,nh,nh) = (h,h,h,h) * (n.z,n.z,n.z,n.z,) \n"\ - "mul r3, r3, c6; ; r3 = (nh, nh, nh) * scale \n"\ - "mad r2.xyz, r3, r4_bx2, r0 ; newTexCoord = height * eye + oldTexCoord \n"\ - " \n"\ - "phase \n"\ - " \n"\ - "texld r0, r2 ; load diffuse texture with new tex coord \n"\ - "texld r1, r2 ; sample normal map \n"\ - "texcrd r2.xyz, t2 ; fetch light vector 1 \n"\ - "texcrd r3.xyz, t3 ; fetch light vector 2 \n"\ - " \n"\ - "dp3_sat r5, r1_bx2, r2_bx2 ; normal dot light 1 (_bx2 because moved into 0..1) \n"\ - "mul r5, r5, v0 ; luminance1 * light color 1 \n"\ - " \n"\ - "dp3_sat r3, r1_bx2, r3_bx2 ; normal dot light 2 (_bx2 because moved into 0..1) \n"\ - "mad r3, r3, v1, r5 ; (luminance2 * light color 2) + luminance1 \n"\ - " \n"\ - "mul r0.xyz, r0, r3 ; total luminance * base color \n"\ - "+mov r0.a, v0.a ; write original alpha value \n"\ - "\n"; - - // Irrlicht Engine D3D9 render path normal map pixel shader version 2.0 - const char D3D9_PARALLAX_MAP_PSH_20[] = - ";Irrlicht Engine D3D9 render path parallax mapping pixel shader \n"\ - ";Input: \n"\ - " \n"\ - ";t0: color map texture coord \n"\ - ";t1: normal map texture coords \n"\ - ";t2: light 1 vector in tangent space \n"\ - ";t4: eye vector in tangent space \n"\ - ";v0: light 1 color \n"\ - ";t3: light 2 vector in tangent space \n"\ - ";v1: light 2 color \n"\ - ";v0.a: vertex alpha value \n"\ - " \n"\ - "ps.2.0 \n"\ - " \n"\ - "dcl_2d s0 ; Declare the s0 register to be the sampler for stage 0 \n"\ - "dcl t0.xy ; Declare t0 to have 2D texture coordinates from stage 0 \n"\ - "dcl t1.xy ; Declare t0 to have 2D texture coordinates from stage 0 \n"\ - "dcl_2d s1 ; Declare the s1 register to be the sampler for stage 1 \n"\ - " \n"\ - "dcl t2.xyz ; \n"\ - "dcl t3.xyz ; \n"\ - "dcl t4.xyz ; \n"\ - "dcl v0.xyzw; \n"\ - "dcl v1.xyzw; \n"\ - " \n"\ - "def c0, -1.0f, -1.0f, -1.0f, -1.0f ; for _bx2 emulation \n"\ - "def c1, 2.0f, 2.0f, 2.0f, 2.0f ; for _bx2 emulation \n"\ - "mov r11, c1; \n"\ - " \n"\ - "texld r1, t1, s1 ; sample (normal.x, normal.y, normal.z, height) \n"\ - "mov r4.xyz, t4 ; fetch eye vector \n"\ - "mov r0.xy, t0 ; color map \n"\ - " \n"\ - "; original parallax mapping: \n"\ - "; emulate ps1x _bx2, so substract 0.5f and multiply by 2 \n"\ - "mad r1.xyz, r1, r11, c0; \n"\ - " \n"\ - "mul r3, r1.wwww, c6; ; r3 = (height, height, height) * scale \n"\ - " \n"\ - "; emulate ps1x _bx2, so substract 0.5f and multiply by 2 \n"\ - "mad r4.xyz, r4, r11, c0; \n"\ - " \n"\ - "mad r2.xy, r3, r4, r0 ; newTexCoord = height * eye + oldTexCoord \n"\ - " \n"\ - "; modified parallax mapping to avoid swimming: \n"\ - ";mul r3, r1_bx2.wwww, r1_bx2.zzzz ; r3 = (h,h,h,h) * (n.z, n.z, n.z, n.z,) \n"\ - ";mul r3, r3, c6; ; r3 = (nh, nh, nh) * scale \n"\ - ";mad r2.xyz, r3, r4_bx2, r0 ; newTexCoord = height * eye + oldTexCoord \n"\ - " \n"\ - "texld r0, r2, s0 ; load diffuse texture with new tex coord \n"\ - "texld r1, r2, s1 ; sample normal map \n"\ - "mov r2.xyz, t2 ; fetch light vector 1 \n"\ - "mov r3.xyz, t3 ; fetch light vector 2 \n"\ - " \n"\ - "; emulate ps1x _bx2, so substract 0.5f and multiply by 2 \n"\ - "mad r1.xyz, r1, r11, c0; \n"\ - "mad r2.xyz, r2, r11, c0; \n"\ - "mad r3.xyz, r3, r11, c0; \n"\ - " \n"\ - "dp3_sat r2, r1, r2 ; normal dot light 1 (_bx2 because moved into 0..1) \n"\ - "mul r2, r2, v0 ; luminance1 * light color 1 \n"\ - " \n"\ - "dp3_sat r3, r1, r3 ; normal dot light 2 (_bx2 because moved into 0..1) \n"\ - "mad r3, r3, v1, r2 ; (luminance2 * light color 2) + luminance1 \n"\ - " \n"\ - "mul r0.xyz, r0, r3 ; total luminance * base color \n"\ - "mov r0.a, v0.a ; write original alpha value \n"\ - "mov oC0, r0; \n"\ - "\n"; - - CD3D9ParallaxMapRenderer::CD3D9ParallaxMapRenderer( - IDirect3DDevice9* d3ddev, video::IVideoDriver* driver, - s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial) - : CD3D9ShaderMaterialRenderer(d3ddev, driver, 0, baseMaterial), - CurrentScale(0.0f) - { - - #ifdef _DEBUG - setDebugName("CD3D9ParallaxMapRenderer"); - #endif - - // set this as callback. We could have done this in - // the initialization list, but some compilers don't like it. - - CallBack = this; - - // basicly, this thing simply compiles these hardcoded shaders if the - // hardware is able to do them, otherwise it maps to the base material - - if (!driver->queryFeature(video::EVDF_PIXEL_SHADER_1_4) || - !driver->queryFeature(video::EVDF_VERTEX_SHADER_1_1)) - { - // this hardware is not able to do shaders. Fall back to - // base material. - outMaterialTypeNr = driver->addMaterialRenderer(this); - return; - } - - // check if already compiled parallax map shaders are there. - - video::IMaterialRenderer* renderer = driver->getMaterialRenderer(EMT_PARALLAX_MAP_SOLID); - if (renderer) - { - // use the already compiled shaders - video::CD3D9ParallaxMapRenderer* nmr = (video::CD3D9ParallaxMapRenderer*)renderer; - VertexShader = nmr->VertexShader; - if (VertexShader) - VertexShader->AddRef(); - - PixelShader = nmr->PixelShader; - if (PixelShader) - PixelShader->AddRef(); - - outMaterialTypeNr = driver->addMaterialRenderer(this); - } - else - { - #ifdef SHADER_EXTERNAL_DEBUG - - // quickly load shader from external file - io::CReadFile* file = new io::CReadFile("parallax.psh"); - s32 sz = file->getSize(); - char* s = new char[sz+1]; - file->read(s, sz); - s[sz] = 0; - - init(outMaterialTypeNr, D3D9_PARALLAX_MAP_VSH, s); - - delete [] s; - file->drop(); - - #else - - // compile shaders on our own - init(outMaterialTypeNr, D3D9_PARALLAX_MAP_VSH, D3D9_PARALLAX_MAP_PSH); - - #endif // SHADER_EXTERNAL_DEBUG - } - // something failed, use base material - if (-1==outMaterialTypeNr) - driver->addMaterialRenderer(this); - } - - - CD3D9ParallaxMapRenderer::~CD3D9ParallaxMapRenderer() - { - if (CallBack == this) - CallBack = 0; - } - - bool CD3D9ParallaxMapRenderer::OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype) - { - if (vtxtype != video::EVT_TANGENTS) - { - os::Printer::log("Error: Parallax map renderer only supports vertices of type EVT_TANGENTS", ELL_ERROR); - return false; - } - - return CD3D9ShaderMaterialRenderer::OnRender(service, vtxtype); - } - - - void CD3D9ParallaxMapRenderer::OnSetMaterial(const video::SMaterial& material, - const video::SMaterial& lastMaterial, - bool resetAllRenderstates, video::IMaterialRendererServices* services) - { - CD3D9ShaderMaterialRenderer::OnSetMaterial(material, lastMaterial, - resetAllRenderstates, services); - - CurrentScale = material.MaterialTypeParam; - } - - - //! Returns the render capability of the material. - s32 CD3D9ParallaxMapRenderer::getRenderCapability() const - { - if (Driver->queryFeature(video::EVDF_PIXEL_SHADER_1_4) && - Driver->queryFeature(video::EVDF_VERTEX_SHADER_1_1)) - return 0; - - return 1; - } - - - //! Called by the engine when the vertex and/or pixel shader constants - //! for an material renderer should be set. - void CD3D9ParallaxMapRenderer::OnSetConstants(IMaterialRendererServices* services, s32 userData) - { - video::IVideoDriver* driver = services->getVideoDriver(); - - // set transposed world matrix - services->setVertexShaderConstant(driver->getTransform(video::ETS_WORLD).getTransposed().pointer(), 0, 4); - - // set eye position - - // The viewpoint is at (0., 0., 0.) in eye space. - // Turning this into a vector [0 0 0 1] and multiply it by - // the inverse of the view matrix, the resulting vector is the - // object space location of the camera. - - f32 floats[4] = {0,0,0,1}; - core::matrix4 minv = driver->getTransform(video::ETS_VIEW); - minv.makeInverse(); - minv.multiplyWith1x4Matrix(floats); - services->setVertexShaderConstant(floats, 4, 1); - - // set transposed worldViewProj matrix - core::matrix4 worldViewProj; - worldViewProj = driver->getTransform(video::ETS_PROJECTION); - worldViewProj *= driver->getTransform(video::ETS_VIEW); - worldViewProj *= driver->getTransform(video::ETS_WORLD); - services->setVertexShaderConstant(worldViewProj.getTransposed().pointer(), 8, 4); - - // here we've got to fetch the fixed function lights from the - // driver and set them as constants - - const u32 cnt = driver->getDynamicLightCount(); - - for (u32 i=0; i<2; ++i) - { - SLight light; - - if (i<cnt) - light = driver->getDynamicLight(i); - else - { - light.DiffuseColor.set(0,0,0); // make light dark - light.Radius = 1.0f; - } - - light.DiffuseColor.a = 1.0f/(light.Radius*light.Radius); // set attenuation - - services->setVertexShaderConstant(reinterpret_cast<const f32*>(&light.Position), 12+(i*2), 1); - services->setVertexShaderConstant(reinterpret_cast<const f32*>(&light.DiffuseColor), 13+(i*2), 1); - } - - // this is not really necessary in d3d9 (used a def instruction), but to be sure: - f32 c95[] = {0.5f, 0.5f, 0.5f, 0.5f}; - services->setVertexShaderConstant(c95, 95, 1); - f32 c96[] = {-1, 1, 1, 1}; - services->setVertexShaderConstant(c96, 96, 1); - - // set scale factor - f32 factor = 0.02f; // default value - if (CurrentScale != 0) - factor = CurrentScale; - - f32 c6[] = {factor, factor, factor, 0}; - services->setPixelShaderConstant(c6, 6, 1); - } - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_DIRECT3D_9_ - diff --git a/irrlicht-1.6/source/Irrlicht/CD3D9ParallaxMapRenderer.h b/irrlicht-1.6/source/Irrlicht/CD3D9ParallaxMapRenderer.h deleted file mode 100644 index f57a09f37..000000000 --- a/irrlicht-1.6/source/Irrlicht/CD3D9ParallaxMapRenderer.h +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_D3D9_PARALLAX_MAPMATERIAL_RENDERER_H_INCLUDED__ -#define __C_D3D9_PARALLAX_MAPMATERIAL_RENDERER_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_WINDOWS_ - -#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ -#include <d3d9.h> - -#include "CD3D9ShaderMaterialRenderer.h" -#include "IShaderConstantSetCallBack.h" - -namespace irr -{ -namespace video -{ - -//! Renderer for normal maps using parallax mapping -class CD3D9ParallaxMapRenderer : - public CD3D9ShaderMaterialRenderer, IShaderConstantSetCallBack -{ -public: - - CD3D9ParallaxMapRenderer( - IDirect3DDevice9* d3ddev, video::IVideoDriver* driver, - s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial); - - ~CD3D9ParallaxMapRenderer(); - - //! Called by the engine when the vertex and/or pixel shader constants for an - //! material renderer should be set. - virtual void OnSetConstants(IMaterialRendererServices* services, s32 userData); - - virtual bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype); - - //! Returns the render capability of the material. - virtual s32 getRenderCapability() const; - - virtual void OnSetMaterial(const SMaterial& material) { } - virtual void OnSetMaterial(const video::SMaterial& material, - const video::SMaterial& lastMaterial, - bool resetAllRenderstates, video::IMaterialRendererServices* services); - -private: - - f32 CurrentScale; - -}; - -} // end namespace video -} // end namespace irr - -#endif -#endif -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CD3D9ShaderMaterialRenderer.cpp b/irrlicht-1.6/source/Irrlicht/CD3D9ShaderMaterialRenderer.cpp deleted file mode 100644 index f0cf45ec4..000000000 --- a/irrlicht-1.6/source/Irrlicht/CD3D9ShaderMaterialRenderer.cpp +++ /dev/null @@ -1,540 +0,0 @@ -// Copyright (C) 2002-2009 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_DIRECT3D_9_ - -#include "CD3D9ShaderMaterialRenderer.h" -#include "IShaderConstantSetCallBack.h" -#include "IMaterialRendererServices.h" -#include "IVideoDriver.h" -#include "os.h" -#include "irrString.h" - -#ifndef _IRR_D3D_NO_SHADER_DEBUGGING -#include <stdio.h> -#endif - - -namespace irr -{ -namespace video -{ - -//! Public constructor -CD3D9ShaderMaterialRenderer::CD3D9ShaderMaterialRenderer(IDirect3DDevice9* d3ddev, video::IVideoDriver* driver, - s32& outMaterialTypeNr, const c8* vertexShaderProgram, const c8* pixelShaderProgram, - IShaderConstantSetCallBack* callback, IMaterialRenderer* baseMaterial, s32 userData) -: pID3DDevice(d3ddev), Driver(driver), CallBack(callback), BaseMaterial(baseMaterial), - VertexShader(0), OldVertexShader(0), PixelShader(0), UserData(userData) -{ - #ifdef _DEBUG - setDebugName("CD3D9ShaderMaterialRenderer"); - #endif - - if (BaseMaterial) - BaseMaterial->grab(); - - if (CallBack) - CallBack->grab(); - - init(outMaterialTypeNr, vertexShaderProgram, pixelShaderProgram); -} - - -//! constructor only for use by derived classes who want to -//! create a fall back material for example. -CD3D9ShaderMaterialRenderer::CD3D9ShaderMaterialRenderer(IDirect3DDevice9* d3ddev, - video::IVideoDriver* driver, - IShaderConstantSetCallBack* callback, - IMaterialRenderer* baseMaterial, s32 userData) -: pID3DDevice(d3ddev), Driver(driver), CallBack(callback), BaseMaterial(baseMaterial), - VertexShader(0), OldVertexShader(0), PixelShader(0), UserData(userData) -{ - #ifdef _DEBUG - setDebugName("CD3D9ShaderMaterialRenderer"); - #endif - - if (BaseMaterial) - BaseMaterial->grab(); - - if (CallBack) - CallBack->grab(); -} - - -void CD3D9ShaderMaterialRenderer::init(s32& outMaterialTypeNr, - const c8* vertexShaderProgram, const c8* pixelShaderProgram) -{ - outMaterialTypeNr = -1; - - // create vertex shader - if (!createVertexShader(vertexShaderProgram)) - return; - - // create pixel shader - if (!createPixelShader(pixelShaderProgram)) - return; - - // register myself as new material - outMaterialTypeNr = Driver->addMaterialRenderer(this); -} - - -//! Destructor -CD3D9ShaderMaterialRenderer::~CD3D9ShaderMaterialRenderer() -{ - if (CallBack) - CallBack->drop(); - - if (VertexShader) - VertexShader->Release(); - - if (PixelShader) - PixelShader->Release(); - - if (BaseMaterial) - BaseMaterial->drop(); -} - - -bool CD3D9ShaderMaterialRenderer::OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype) -{ - // call callback to set shader constants - if (CallBack && (VertexShader || PixelShader)) - CallBack->OnSetConstants(service, UserData); - - return true; -} - - -void CD3D9ShaderMaterialRenderer::OnSetMaterial(const video::SMaterial& material, const video::SMaterial& lastMaterial, - bool resetAllRenderstates, video::IMaterialRendererServices* services) -{ - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - if (VertexShader) - { - // save old vertex shader - pID3DDevice->GetVertexShader(&OldVertexShader); - - // set new vertex shader - if (FAILED(pID3DDevice->SetVertexShader(VertexShader))) - os::Printer::log("Could not set vertex shader.", ELL_WARNING); - } - - // set new pixel shader - if (PixelShader) - { - if (FAILED(pID3DDevice->SetPixelShader(PixelShader))) - os::Printer::log("Could not set pixel shader.", ELL_WARNING); - } - - if (BaseMaterial) - BaseMaterial->OnSetMaterial(material, material, true, services); - } - - //let callback know used material - if (CallBack) - CallBack->OnSetMaterial(material); - - services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); -} - - -void CD3D9ShaderMaterialRenderer::OnUnsetMaterial() -{ - if (VertexShader) - pID3DDevice->SetVertexShader(OldVertexShader); - - if (PixelShader) - pID3DDevice->SetPixelShader(0); - - if (BaseMaterial) - BaseMaterial->OnUnsetMaterial(); -} - - -//! Returns if the material is transparent. The scene managment needs to know this -//! for being able to sort the materials by opaque and transparent. -bool CD3D9ShaderMaterialRenderer::isTransparent() const -{ - return BaseMaterial ? BaseMaterial->isTransparent() : false; -} - - -bool CD3D9ShaderMaterialRenderer::createPixelShader(const c8* pxsh) -{ - if (!pxsh) - return true; - - // compile shader - - LPD3DXBUFFER code = 0; - LPD3DXBUFFER errors = 0; - - #ifdef _IRR_D3D_NO_SHADER_DEBUGGING - - // compile shader without debug info - stubD3DXAssembleShader(pxsh, (UINT)strlen(pxsh), 0, 0, 0, &code, &errors); - #else - - // compile shader and emitt some debug informations to - // make it possible to debug the shader in visual studio - - static int irr_dbg_file_nr = 0; - ++irr_dbg_file_nr; - char tmp[32]; - sprintf(tmp, "irr_d3d9_dbg_shader_%d.psh", irr_dbg_file_nr); - - FILE* f = fopen(tmp, "wb"); - fwrite(pxsh, strlen(pxsh), 1, f); - fflush(f); - fclose(f); - - stubD3DXAssembleShaderFromFile(tmp, 0, 0, D3DXSHADER_DEBUG, &code, &errors); - - #endif - - - if (errors) - { - // print out compilation errors. - os::Printer::log("Pixel shader compilation failed:", ELL_ERROR); - os::Printer::log((c8*)errors->GetBufferPointer(), ELL_ERROR); - - if (code) - code->Release(); - - errors->Release(); - return false; - } - - if (FAILED(pID3DDevice->CreatePixelShader((DWORD*)code->GetBufferPointer(), &PixelShader))) - { - os::Printer::log("Could not create pixel shader.", ELL_ERROR); - code->Release(); - return false; - } - - code->Release(); - return true; -} - - -bool CD3D9ShaderMaterialRenderer::createVertexShader(const char* vtxsh) -{ - if (!vtxsh) - return true; - - // compile shader - - LPD3DXBUFFER code = 0; - LPD3DXBUFFER errors = 0; - - #ifdef _IRR_D3D_NO_SHADER_DEBUGGING - - // compile shader without debug info - stubD3DXAssembleShader(vtxsh, (UINT)strlen(vtxsh), 0, 0, 0, &code, &errors); - - #else - - // compile shader and emitt some debug informations to - // make it possible to debug the shader in visual studio - - static int irr_dbg_file_nr = 0; - ++irr_dbg_file_nr; - char tmp[32]; - sprintf(tmp, "irr_d3d9_dbg_shader_%d.vsh", irr_dbg_file_nr); - - FILE* f = fopen(tmp, "wb"); - fwrite(vtxsh, strlen(vtxsh), 1, f); - fflush(f); - fclose(f); - - stubD3DXAssembleShaderFromFile(tmp, 0, 0, D3DXSHADER_DEBUG, &code, &errors); - - #endif - - if (errors) - { - // print out compilation errors. - os::Printer::log("Vertex shader compilation failed:", ELL_ERROR); - os::Printer::log((c8*)errors->GetBufferPointer(), ELL_ERROR); - - if (code) - code->Release(); - - errors->Release(); - return false; - } - - if (!code || FAILED(pID3DDevice->CreateVertexShader((DWORD*)code->GetBufferPointer(), &VertexShader))) - { - os::Printer::log("Could not create vertex shader.", ELL_ERROR); - if (code) - code->Release(); - return false; - } - - code->Release(); - return true; -} - - -HRESULT CD3D9ShaderMaterialRenderer::stubD3DXAssembleShader(LPCSTR pSrcData, - UINT SrcDataLen, CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, DWORD Flags, LPD3DXBUFFER* ppShader, - LPD3DXBUFFER* ppErrorMsgs) -{ - // Because Irrlicht needs to be able to start up even without installed d3d dlls, it - // needs to load external d3d dlls manually. examples for the dlls are: - // SDK dll name D3DX_SDK_VERSION - // Summer 2004: no dll 22 - // February 2005: d3dx9_24.dll 24 - // April 2005: d3dx9_25.dll 25 - // June 2005: d3dx9_26.dll 26 - // August 2005: d3dx9_27.dll 27 - // October 2005, - // December 2005: d3dx9_28.dll 28 - - #if ( D3DX_SDK_VERSION < 24 ) - // directly link functions, old d3d sdks didn't try to load external dlls - // when linking to the d3dx9.lib - #ifdef _MSC_VER - #pragma comment (lib, "d3dx9.lib") - #endif - - // invoke static linked function - return D3DXAssembleShader(pSrcData, SrcDataLen, pDefines, pInclude, - Flags, ppShader, ppErrorMsgs); - #else - { - // try to load shader functions from the dll and print error if failed. - - // D3DXAssembleShader signature - typedef HRESULT (WINAPI *AssembleShaderFunction)(LPCSTR pSrcData, UINT SrcDataLen, - CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, - DWORD Flags, LPD3DXBUFFER* ppShader, - LPD3DXBUFFER* ppErrorMsgs); - - static bool LoadFailed = false; - static AssembleShaderFunction pFn = 0; - - if (!pFn && !LoadFailed) - { - // try to load dll - core::stringc strDllName = "d3dx9_"; - strDllName += (int)D3DX_SDK_VERSION; - strDllName += ".dll"; - - HMODULE hMod = LoadLibrary(strDllName.c_str()); - if (hMod) - pFn = (AssembleShaderFunction)GetProcAddress(hMod, "D3DXAssembleShader"); - - if (!pFn) - { - LoadFailed = true; - os::Printer::log("Could not load shader function D3DXAssembleShader from dll, shaders disabled", - strDllName.c_str(), ELL_ERROR); - } - } - - if (pFn) - { - // call already loaded function - return (*pFn)(pSrcData, SrcDataLen, pDefines, pInclude, Flags, ppShader, ppErrorMsgs); - } - } - #endif // D3DX_SDK_VERSION < 24 - - return 0; -} - - -HRESULT CD3D9ShaderMaterialRenderer::stubD3DXAssembleShaderFromFile(LPCSTR pSrcFile, - CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, DWORD Flags, - LPD3DXBUFFER* ppShader, LPD3DXBUFFER* ppErrorMsgs) -{ - // wondering what I'm doing here? - // see comment in CD3D9ShaderMaterialRenderer::stubD3DXAssembleShader() - - #if ( D3DX_SDK_VERSION < 24 ) - // directly link functions, old d3d sdks didn't try to load external dlls - // when linking to the d3dx9.lib - #ifdef _MSC_VER - #pragma comment (lib, "d3dx9.lib") - #endif - - // invoke static linked function - return D3DXAssembleShaderFromFile(pSrcFile, pDefines, pInclude, Flags, - ppShader, ppErrorMsgs); - #else - { - // try to load shader functions from the dll and print error if failed. - - // D3DXAssembleShaderFromFileA signature - typedef HRESULT (WINAPI *AssembleShaderFromFileFunction)(LPCSTR pSrcFile, - CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, DWORD Flags, - LPD3DXBUFFER* ppShader, LPD3DXBUFFER* ppErrorMsgs); - - static bool LoadFailed = false; - static AssembleShaderFromFileFunction pFn = 0; - - if (!pFn && !LoadFailed) - { - // try to load dll - core::stringc strDllName = "d3dx9_"; - strDllName += (int)D3DX_SDK_VERSION; - strDllName += ".dll"; - - HMODULE hMod = LoadLibrary(strDllName.c_str()); - if (hMod) - pFn = (AssembleShaderFromFileFunction)GetProcAddress(hMod, "D3DXAssembleShaderFromFileA"); - - if (!pFn) - { - LoadFailed = true; - os::Printer::log("Could not load shader function D3DXAssembleShaderFromFileA from dll, shaders disabled", - strDllName.c_str(), ELL_ERROR); - } - } - - if (pFn) - { - // call already loaded function - return (*pFn)(pSrcFile, pDefines, pInclude, Flags, ppShader, ppErrorMsgs); - } - } - #endif // D3DX_SDK_VERSION < 24 - - return 0; -} - - -HRESULT CD3D9ShaderMaterialRenderer::stubD3DXCompileShader(LPCSTR pSrcData, UINT SrcDataLen, CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, LPCSTR pFunctionName, - LPCSTR pProfile, DWORD Flags, LPD3DXBUFFER* ppShader, - LPD3DXBUFFER* ppErrorMsgs, LPD3DXCONSTANTTABLE* ppConstantTable) -{ - // wondering what I'm doing here? - // see comment in CD3D9ShaderMaterialRenderer::stubD3DXAssembleShader() - - #if ( D3DX_SDK_VERSION < 24 ) - // directly link functions, old d3d sdks didn't try to load external dlls - // when linking to the d3dx9.lib - #ifdef _MSC_VER - #pragma comment (lib, "d3dx9.lib") - #endif - - // invoke static linked function - return D3DXCompileShader(pSrcData, SrcDataLen, pDefines, pInclude, pFunctionName, pProfile, Flags, ppShader, ppErrorMsgs, ppConstantTable); - #else - { - // try to load shader functions from the dll and print error if failed. - - // D3DXCompileShader - typedef HRESULT (WINAPI *D3DXCompileShaderFunction)(LPCSTR pSrcData, UINT SrcDataLen, CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, LPCSTR pFunctionName, - LPCSTR pProfile, DWORD Flags, LPD3DXBUFFER* ppShader, - LPD3DXBUFFER* ppErrorMsgs, LPD3DXCONSTANTTABLE* ppConstantTable); - - static bool LoadFailed = false; - static D3DXCompileShaderFunction pFn = 0; - - if (!pFn && !LoadFailed) - { - // try to load dll - core::stringc strDllName = "d3dx9_"; - strDllName += (int)D3DX_SDK_VERSION; - strDllName += ".dll"; - - HMODULE hMod = LoadLibrary(strDllName.c_str()); - if (hMod) - pFn = (D3DXCompileShaderFunction)GetProcAddress(hMod, "D3DXCompileShader"); - - if (!pFn) - { - LoadFailed = true; - os::Printer::log("Could not load shader function D3DXCompileShader from dll, shaders disabled", - strDllName.c_str(), ELL_ERROR); - } - } - - if (pFn) - { - // call already loaded function - return (*pFn)(pSrcData, SrcDataLen, pDefines, pInclude, pFunctionName, pProfile, Flags, ppShader, ppErrorMsgs, ppConstantTable); - } - } - #endif // D3DX_SDK_VERSION < 24 - - return 0; -} - -HRESULT CD3D9ShaderMaterialRenderer::stubD3DXCompileShaderFromFile(LPCSTR pSrcFile, CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, LPCSTR pFunctionName, - LPCSTR pProfile, DWORD Flags, LPD3DXBUFFER* ppShader, LPD3DXBUFFER* ppErrorMsgs, - LPD3DXCONSTANTTABLE* ppConstantTable) -{ - // wondering what I'm doing here? - // see comment in CD3D9ShaderMaterialRenderer::stubD3DXAssembleShader() - - #if ( D3DX_SDK_VERSION < 24 ) - // directly link functions, old d3d sdks didn't try to load external dlls - // when linking to the d3dx9.lib - #ifdef _MSC_VER - #pragma comment (lib, "d3dx9.lib") - #endif - - // invoke static linked function - return D3DXCompileShaderFromFile(pSrcFile, pDefines, pInclude, pFunctionName, pProfile, Flags, ppShader, ppErrorMsgs, ppConstantTable); - #else - { - // try to load shader functions from the dll and print error if failed. - - // D3DXCompileShaderFromFileA - typedef HRESULT (WINAPI *D3DXCompileShaderFromFileFunction)(LPCSTR pSrcFile, - CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, LPCSTR pFunctionName, - LPCSTR pProfile, DWORD Flags, LPD3DXBUFFER* ppShader, LPD3DXBUFFER* ppErrorMsgs, - LPD3DXCONSTANTTABLE* ppConstantTable); - - static bool LoadFailed = false; - static D3DXCompileShaderFromFileFunction pFn = 0; - - if (!pFn && !LoadFailed) - { - // try to load dll - core::stringc strDllName = "d3dx9_"; - strDllName += (int)D3DX_SDK_VERSION; - strDllName += ".dll"; - - HMODULE hMod = LoadLibrary(strDllName.c_str()); - if (hMod) - pFn = (D3DXCompileShaderFromFileFunction)GetProcAddress(hMod, "D3DXCompileShaderFromFileA"); - - if (!pFn) - { - LoadFailed = true; - os::Printer::log("Could not load shader function D3DXCompileShaderFromFileA from dll, shaders disabled", - strDllName.c_str(), ELL_ERROR); - } - } - - if (pFn) - { - // call already loaded function - return (*pFn)(pSrcFile, pDefines, pInclude, pFunctionName, pProfile, Flags, ppShader, ppErrorMsgs, ppConstantTable); - } - } - #endif // D3DX_SDK_VERSION < 24 - - return 0; -} - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_DIRECT3D_9_ diff --git a/irrlicht-1.6/source/Irrlicht/CD3D9ShaderMaterialRenderer.h b/irrlicht-1.6/source/Irrlicht/CD3D9ShaderMaterialRenderer.h deleted file mode 100644 index b035eb648..000000000 --- a/irrlicht-1.6/source/Irrlicht/CD3D9ShaderMaterialRenderer.h +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_D3D9_SHADER_MATERIAL_RENDERER_H_INCLUDED__ -#define __C_D3D9_SHADER_MATERIAL_RENDERER_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_WINDOWS_ - -#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ -#include <d3d9.h> -#include <d3dx9shader.h> - -#include "IMaterialRenderer.h" - -namespace irr -{ -namespace video -{ - -class IVideoDriver; -class IShaderConstantSetCallBack; -class IMaterialRenderer; - -//! Class for using vertex and pixel shaders with D3D9 -class CD3D9ShaderMaterialRenderer : public IMaterialRenderer -{ -public: - - //! Public constructor - CD3D9ShaderMaterialRenderer(IDirect3DDevice9* d3ddev, video::IVideoDriver* driver, - s32& outMaterialTypeNr, const c8* vertexShaderProgram, const c8* pixelShaderProgram, - IShaderConstantSetCallBack* callback, IMaterialRenderer* baseMaterial, s32 userData); - - //! Destructor - ~CD3D9ShaderMaterialRenderer(); - - virtual void OnSetMaterial(const video::SMaterial& material, const video::SMaterial& lastMaterial, - bool resetAllRenderstates, video::IMaterialRendererServices* services); - - virtual void OnUnsetMaterial(); - - virtual bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype); - - //! Returns if the material is transparent. - virtual bool isTransparent() const; - -protected: - - //! constructor only for use by derived classes who want to - //! create a fall back material for example. - CD3D9ShaderMaterialRenderer(IDirect3DDevice9* d3ddev, - video::IVideoDriver* driver, - IShaderConstantSetCallBack* callback, - IMaterialRenderer* baseMaterial, - s32 userData=0); - - void init(s32& outMaterialTypeNr, const c8* vertexShaderProgram, const c8* pixelShaderProgram); - bool createPixelShader(const c8* pxsh); - bool createVertexShader(const char* vtxsh); - - HRESULT stubD3DXAssembleShader(LPCSTR pSrcData, UINT SrcDataLen, - CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, - DWORD Flags, LPD3DXBUFFER* ppShader, - LPD3DXBUFFER* ppErrorMsgs); - - HRESULT stubD3DXAssembleShaderFromFile(LPCSTR pSrcFile, - CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, DWORD Flags, - LPD3DXBUFFER* ppShader, LPD3DXBUFFER* ppErrorMsgs); - - HRESULT stubD3DXCompileShader(LPCSTR pSrcData, UINT SrcDataLen, CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, LPCSTR pFunctionName, - LPCSTR pProfile, DWORD Flags, LPD3DXBUFFER* ppShader, - LPD3DXBUFFER* ppErrorMsgs, LPD3DXCONSTANTTABLE* ppConstantTable); - - HRESULT stubD3DXCompileShaderFromFile(LPCSTR pSrcFile, CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, LPCSTR pFunctionName, - LPCSTR pProfile, DWORD Flags, LPD3DXBUFFER* ppShader, LPD3DXBUFFER* ppErrorMsgs, - LPD3DXCONSTANTTABLE* ppConstantTable); - - IDirect3DDevice9* pID3DDevice; - video::IVideoDriver* Driver; - IShaderConstantSetCallBack* CallBack; - IMaterialRenderer* BaseMaterial; - - IDirect3DVertexShader9* VertexShader; - IDirect3DVertexShader9* OldVertexShader; - IDirect3DPixelShader9* PixelShader; - s32 UserData; -}; - - -} // end namespace video -} // end namespace irr - -#endif -#endif -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CD3D9Texture.cpp b/irrlicht-1.6/source/Irrlicht/CD3D9Texture.cpp deleted file mode 100644 index d6debc367..000000000 --- a/irrlicht-1.6/source/Irrlicht/CD3D9Texture.cpp +++ /dev/null @@ -1,666 +0,0 @@ -// Copyright (C) 2002-2009 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_DIRECT3D_9_ - -#define _IRR_DONT_DO_MEMORY_DEBUGGING_HERE -#include "CD3D9Texture.h" -#include "CD3D9Driver.h" -#include "os.h" - -#include <d3dx9tex.h> - -#ifndef _IRR_COMPILE_WITH_DIRECT3D_8_ -// The D3DXFilterTexture function seems to get linked wrong when -// compiling with both D3D8 and 9, causing it not to work in the D3D9 device. -// So mipmapgeneration is replaced with my own bad generation in d3d 8 when -// compiling with both D3D 8 and 9. -// #define _IRR_USE_D3DXFilterTexture_ -#endif // _IRR_COMPILE_WITH_DIRECT3D_8_ - -#ifdef _IRR_USE_D3DXFilterTexture_ -#pragma comment(lib, "d3dx9.lib") -#endif - -namespace irr -{ -namespace video -{ - -//! rendertarget constructor -CD3D9Texture::CD3D9Texture(CD3D9Driver* driver, const core::dimension2d<u32>& size, - const io::path& name, const ECOLOR_FORMAT format) -: ITexture(name), Texture(0), RTTSurface(0), Driver(driver), DepthSurface(0), - TextureSize(size), ImageSize(size), Pitch(0), ColorFormat(ECF_UNKNOWN), - HasMipMaps(false), HardwareMipMaps(false), IsRenderTarget(true) -{ - #ifdef _DEBUG - setDebugName("CD3D9Texture"); - #endif - - Device=driver->getExposedVideoData().D3D9.D3DDev9; - if (Device) - Device->AddRef(); - - createRenderTarget(format); -} - - -//! constructor -CD3D9Texture::CD3D9Texture(IImage* image, CD3D9Driver* driver, - u32 flags, const io::path& name) -: ITexture(name), Texture(0), RTTSurface(0), Driver(driver), DepthSurface(0), - TextureSize(0,0), ImageSize(0,0), Pitch(0), ColorFormat(ECF_UNKNOWN), - HasMipMaps(false), HardwareMipMaps(false), IsRenderTarget(false) -{ - #ifdef _DEBUG - setDebugName("CD3D9Texture"); - #endif - - const bool generateMipLevels = Driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS); - - Device=driver->getExposedVideoData().D3D9.D3DDev9; - if (Device) - Device->AddRef(); - - if (image) - { - if (createTexture(flags, image)) - { - if (copyTexture(image) && generateMipLevels) - { - // create mip maps. - #ifdef _IRR_USE_D3DXFilterTexture_ - // The D3DXFilterTexture function seems to get linked wrong when - // compiling with both D3D8 and 9, causing it not to work in the D3D9 device. - // So mipmapgeneration is replaced with my own bad generation - HRESULT hr = D3DXFilterTexture(Texture, NULL, D3DX_DEFAULT, D3DX_DEFAULT); - if (FAILED(hr)) - os::Printer::log("Could not create direct3d mip map levels.", ELL_WARNING); - else - HasMipMaps = true; - #else - createMipMaps(); - HasMipMaps = true; - #endif - } - } - else - os::Printer::log("Could not create DIRECT3D9 Texture.", ELL_WARNING); - } -} - - -//! destructor -CD3D9Texture::~CD3D9Texture() -{ - if (Texture) - Texture->Release(); - - if (RTTSurface) - RTTSurface->Release(); - - // if this texture was the last one using the depth buffer - // we can release the surface. We only use the value of the pointer - // hence it is safe to use the dropped pointer... - if (DepthSurface) - { - if (DepthSurface->drop()) - Driver->removeDepthSurface(DepthSurface); - } - - if (Device) - Device->Release(); -} - - -void CD3D9Texture::createRenderTarget(const ECOLOR_FORMAT format) -{ - // are texture size restrictions there ? - if(!Driver->queryFeature(EVDF_TEXTURE_NPOT)) - { - if (TextureSize != ImageSize) - os::Printer::log("RenderTarget size has to be a power of two", ELL_INFORMATION); - } - TextureSize = TextureSize.getOptimalSize(!Driver->queryFeature(EVDF_TEXTURE_NPOT), !Driver->queryFeature(EVDF_TEXTURE_NSQUARE), true, Driver->Caps.MaxTextureWidth); - - D3DFORMAT d3dformat = Driver->getD3DColorFormat(); - - if(ColorFormat == ECF_UNKNOWN) - { - // get irrlicht format from backbuffer - // (This will get overwritten by the custom format if it is provided, else kept.) - ColorFormat = Driver->getColorFormat(); - setPitch(d3dformat); - - // Use color format if provided. - if(format != ECF_UNKNOWN) - { - ColorFormat = format; - d3dformat = Driver->getD3DFormatFromColorFormat(format); - setPitch(d3dformat); // This will likely set pitch to 0 for now. - } - } - else - { - d3dformat = Driver->getD3DFormatFromColorFormat(ColorFormat); - } - - // create texture - HRESULT hr; - - hr = Device->CreateTexture( - TextureSize.Width, - TextureSize.Height, - 1, // mip map level count, we don't want mipmaps here - D3DUSAGE_RENDERTARGET, - d3dformat, - D3DPOOL_DEFAULT, - &Texture, - NULL); - - if (FAILED(hr)) - { - if (D3DERR_INVALIDCALL == hr) - os::Printer::log("Could not create render target texture", "Invalid Call"); - else - if (D3DERR_OUTOFVIDEOMEMORY == hr) - os::Printer::log("Could not create render target texture", "Out of Video Memory"); - else - if (E_OUTOFMEMORY == hr) - os::Printer::log("Could not create render target texture", "Out of Memory"); - else - os::Printer::log("Could not create render target texture"); - } -} - - -bool CD3D9Texture::createMipMaps(u32 level) -{ - if (level==0) - return true; - - if (HardwareMipMaps && Texture) - { - // generate mipmaps in hardware - Texture->GenerateMipSubLevels(); - return true; - } - // os::Printer::log("manual mipmap"); - - IDirect3DSurface9* upperSurface = 0; - IDirect3DSurface9* lowerSurface = 0; - - // get upper level - HRESULT hr = Texture->GetSurfaceLevel(level-1, &upperSurface); - if (FAILED(hr) || !upperSurface) - { - os::Printer::log("Could not get upper surface level for mip map generation", ELL_WARNING); - return false; - } - - // get lower level - hr = Texture->GetSurfaceLevel(level, &lowerSurface); - if (FAILED(hr) || !lowerSurface) - { - os::Printer::log("Could not get lower surface level for mip map generation", ELL_WARNING); - upperSurface->Release(); - return false; - } - - D3DSURFACE_DESC upperDesc, lowerDesc; - upperSurface->GetDesc(&upperDesc); - lowerSurface->GetDesc(&lowerDesc); - - D3DLOCKED_RECT upperlr; - D3DLOCKED_RECT lowerlr; - - // lock upper surface - if (FAILED(upperSurface->LockRect(&upperlr, NULL, 0))) - { - upperSurface->Release(); - lowerSurface->Release(); - os::Printer::log("Could not lock upper texture for mip map generation", ELL_WARNING); - return false; - } - - // lock lower surface - if (FAILED(lowerSurface->LockRect(&lowerlr, NULL, 0))) - { - upperSurface->UnlockRect(); - upperSurface->Release(); - lowerSurface->Release(); - os::Printer::log("Could not lock lower texture for mip map generation", ELL_WARNING); - return false; - } - - if (upperDesc.Format != lowerDesc.Format) - { - os::Printer::log("Cannot copy mip maps with different formats.", ELL_WARNING); - } - else - { - if ((upperDesc.Format == D3DFMT_A1R5G5B5) || (upperDesc.Format == D3DFMT_R5G6B5)) - copy16BitMipMap((char*)upperlr.pBits, (char*)lowerlr.pBits, - lowerDesc.Width, lowerDesc.Height, - upperlr.Pitch, lowerlr.Pitch); - else - if (upperDesc.Format == D3DFMT_A8R8G8B8) - copy32BitMipMap((char*)upperlr.pBits, (char*)lowerlr.pBits, - lowerDesc.Width, lowerDesc.Height, - upperlr.Pitch, lowerlr.Pitch); - else - os::Printer::log("Unsupported mipmap format, cannot copy.", ELL_WARNING); - } - - bool result=true; - // unlock - if (FAILED(upperSurface->UnlockRect())) - result=false; - if (FAILED(lowerSurface->UnlockRect())) - result=false; - - // release - upperSurface->Release(); - lowerSurface->Release(); - - if (!result || (upperDesc.Width <= 3 && upperDesc.Height <= 3)) - return result; // stop generating levels - - // generate next level - return createMipMaps(level+1); -} - - -//! creates the hardware texture -bool CD3D9Texture::createTexture(u32 flags, IImage * image) -{ - ImageSize = image->getDimension(); - - core::dimension2d<u32> optSize = ImageSize.getOptimalSize(!Driver->queryFeature(EVDF_TEXTURE_NPOT), !Driver->queryFeature(EVDF_TEXTURE_NSQUARE), true, Driver->Caps.MaxTextureWidth); - - D3DFORMAT format = D3DFMT_A1R5G5B5; - - switch(getTextureFormatFromFlags(flags)) - { - case ETCF_ALWAYS_16_BIT: - format = D3DFMT_A1R5G5B5; break; - case ETCF_ALWAYS_32_BIT: - format = D3DFMT_A8R8G8B8; break; - case ETCF_OPTIMIZED_FOR_QUALITY: - { - switch(image->getColorFormat()) - { - case ECF_R8G8B8: - case ECF_A8R8G8B8: - format = D3DFMT_A8R8G8B8; break; - case ECF_A1R5G5B5: - case ECF_R5G6B5: - format = D3DFMT_A1R5G5B5; break; - } - } - break; - case ETCF_OPTIMIZED_FOR_SPEED: - format = D3DFMT_A1R5G5B5; - break; - default: - break; - } - if (Driver->getTextureCreationFlag(video::ETCF_NO_ALPHA_CHANNEL)) - { - if (format == D3DFMT_A8R8G8B8) - format = D3DFMT_R8G8B8; - else if (format == D3DFMT_A1R5G5B5) - format = D3DFMT_R5G6B5; - } - - const bool mipmaps = Driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS); - - DWORD usage = 0; - - // This enables hardware mip map generation. - if (mipmaps && Driver->queryFeature(EVDF_MIP_MAP_AUTO_UPDATE)) - { - LPDIRECT3D9 intf = Driver->getExposedVideoData().D3D9.D3D9; - D3DDISPLAYMODE d3ddm; - intf->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm); - - if (D3D_OK==intf->CheckDeviceFormat(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,d3ddm.Format,D3DUSAGE_AUTOGENMIPMAP,D3DRTYPE_TEXTURE,format)) - { - usage = D3DUSAGE_AUTOGENMIPMAP; - HardwareMipMaps = true; - } - } - - HRESULT hr = Device->CreateTexture(optSize.Width, optSize.Height, - mipmaps ? 0 : 1, // number of mipmaplevels (0 = automatic all) - usage, // usage - format, D3DPOOL_MANAGED , &Texture, NULL); - - if (FAILED(hr)) - { - // try brute force 16 bit - HardwareMipMaps = false; - if (format == D3DFMT_A8R8G8B8) - format = D3DFMT_A1R5G5B5; - else if (format == D3DFMT_R8G8B8) - format = D3DFMT_R5G6B5; - else - return false; - - hr = Device->CreateTexture(optSize.Width, optSize.Height, - mipmaps ? 0 : 1, // number of mipmaplevels (0 = automatic all) - 0, format, D3DPOOL_MANAGED, &Texture, NULL); - } - - ColorFormat = Driver->getColorFormatFromD3DFormat(format); - setPitch(format); - return (SUCCEEDED(hr)); -} - - -//! copies the image to the texture -bool CD3D9Texture::copyTexture(IImage * image) -{ - if (Texture && image) - { - D3DSURFACE_DESC desc; - Texture->GetLevelDesc(0, &desc); - - TextureSize.Width = desc.Width; - TextureSize.Height = desc.Height; - - D3DLOCKED_RECT rect; - HRESULT hr = Texture->LockRect(0, &rect, 0, 0); - if (FAILED(hr)) - { - os::Printer::log("Texture data not copied", "Could not LockRect D3D9 Texture.", ELL_ERROR); - return false; - } - - Pitch = rect.Pitch; - image->copyToScaling(rect.pBits, TextureSize.Width, TextureSize.Height, ColorFormat, Pitch); - - hr = Texture->UnlockRect(0); - if (FAILED(hr)) - { - os::Printer::log("Texture data not copied", "Could not UnlockRect D3D9 Texture.", ELL_ERROR); - return false; - } - } - - return true; -} - - -//! lock function -void* CD3D9Texture::lock(bool readOnly) -{ - if (!Texture) - return 0; - - HRESULT hr; - D3DLOCKED_RECT rect; - if(!IsRenderTarget) - { - hr = Texture->LockRect(0, &rect, 0, readOnly?D3DLOCK_READONLY:0); - if (FAILED(hr)) - { - os::Printer::log("Could not lock DIRECT3D9 Texture.", ELL_ERROR); - return 0; - } - - return rect.pBits; - } - else - { - D3DSURFACE_DESC desc; - Texture->GetLevelDesc(0, &desc); - if (!RTTSurface) - { - hr = Device->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &RTTSurface, 0); - if (FAILED(hr)) - { - os::Printer::log("Could not lock DIRECT3D9 Texture", "Offscreen surface creation failed.", ELL_ERROR); - return 0; - } - } - - IDirect3DSurface9 *surface = 0; - hr = Texture->GetSurfaceLevel(0, &surface); - if (FAILED(hr)) - { - os::Printer::log("Could not lock DIRECT3D9 Texture", "Could not get surface.", ELL_ERROR); - return 0; - } - hr = Device->GetRenderTargetData(surface, RTTSurface); - surface->Release(); - if(FAILED(hr)) - { - os::Printer::log("Could not lock DIRECT3D9 Texture", "Data copy failed.", ELL_ERROR); - return 0; - } - hr = RTTSurface->LockRect(&rect, 0, readOnly?D3DLOCK_READONLY:0); - if(FAILED(hr)) - { - os::Printer::log("Could not lock DIRECT3D9 Texture", "LockRect failed.", ELL_ERROR); - return 0; - } - return rect.pBits; - } -} - - -//! unlock function -void CD3D9Texture::unlock() -{ - if (!Texture) - return; - - if (!IsRenderTarget) - Texture->UnlockRect(0); - else if (RTTSurface) - RTTSurface->UnlockRect(); -} - - -//! Returns original size of the texture. -const core::dimension2d<u32>& CD3D9Texture::getOriginalSize() const -{ - return ImageSize; -} - - -//! Returns (=size) of the texture. -const core::dimension2d<u32>& CD3D9Texture::getSize() const -{ - return TextureSize; -} - - -//! returns driver type of texture (=the driver, who created the texture) -E_DRIVER_TYPE CD3D9Texture::getDriverType() const -{ - return EDT_DIRECT3D9; -} - - -//! returns color format of texture -ECOLOR_FORMAT CD3D9Texture::getColorFormat() const -{ - return ColorFormat; -} - - -//! returns pitch of texture (in bytes) -u32 CD3D9Texture::getPitch() const -{ - return Pitch; -} - - -//! returns the DIRECT3D9 Texture -IDirect3DBaseTexture9* CD3D9Texture::getDX9Texture() const -{ - return Texture; -} - - -//! returns if texture has mipmap levels -bool CD3D9Texture::hasMipMaps() const -{ - return HasMipMaps; -} - - -void CD3D9Texture::copy16BitMipMap(char* src, char* tgt, - s32 width, s32 height, - s32 pitchsrc, s32 pitchtgt) const -{ - for (s32 y=0; y<height; ++y) - { - for (s32 x=0; x<width; ++x) - { - u32 a=0, r=0, g=0, b=0; - - for (s32 dy=0; dy<2; ++dy) - { - const s32 tgy = (y*2)+dy; - for (s32 dx=0; dx<2; ++dx) - { - const s32 tgx = (x*2)+dx; - - SColor c; - if (ColorFormat == ECF_A1R5G5B5) - c = A1R5G5B5toA8R8G8B8(*(u16*)(&src[(tgx*2)+(tgy*pitchsrc)])); - else - c = R5G6B5toA8R8G8B8(*(u16*)(&src[(tgx*2)+(tgy*pitchsrc)])); - - a += c.getAlpha(); - r += c.getRed(); - g += c.getGreen(); - b += c.getBlue(); - } - } - - a /= 4; - r /= 4; - g /= 4; - b /= 4; - - u16 c; - if (ColorFormat == ECF_A1R5G5B5) - c = RGBA16(r,g,b,a); - else - c = A8R8G8B8toR5G6B5(SColor(a,r,g,b).color); - *(u16*)(&tgt[(x*2)+(y*pitchtgt)]) = c; - } - } -} - - -void CD3D9Texture::copy32BitMipMap(char* src, char* tgt, - s32 width, s32 height, - s32 pitchsrc, s32 pitchtgt) const -{ - for (s32 y=0; y<height; ++y) - { - for (s32 x=0; x<width; ++x) - { - u32 a=0, r=0, g=0, b=0; - SColor c; - - for (s32 dy=0; dy<2; ++dy) - { - const s32 tgy = (y*2)+dy; - for (s32 dx=0; dx<2; ++dx) - { - const s32 tgx = (x*2)+dx; - - c = *(u32*)(&src[(tgx*4)+(tgy*pitchsrc)]); - - a += c.getAlpha(); - r += c.getRed(); - g += c.getGreen(); - b += c.getBlue(); - } - } - - a /= 4; - r /= 4; - g /= 4; - b /= 4; - - c.set(a, r, g, b); - *(u32*)(&tgt[(x*4)+(y*pitchtgt)]) = c.color; - } - } -} - - -//! Regenerates the mip map levels of the texture. Useful after locking and -//! modifying the texture -void CD3D9Texture::regenerateMipMapLevels() -{ - if (HasMipMaps) - createMipMaps(); -} - - -//! returns if it is a render target -bool CD3D9Texture::isRenderTarget() const -{ - return IsRenderTarget; -} - - -//! Returns pointer to the render target surface -IDirect3DSurface9* CD3D9Texture::getRenderTargetSurface() -{ - if (!IsRenderTarget) - return 0; - - IDirect3DSurface9 *pRTTSurface = 0; - if (Texture) - Texture->GetSurfaceLevel(0, &pRTTSurface); - - if (pRTTSurface) - pRTTSurface->Release(); - - return pRTTSurface; -} - - -void CD3D9Texture::setPitch(D3DFORMAT d3dformat) -{ - switch(d3dformat) - { - case D3DFMT_X1R5G5B5: - case D3DFMT_A1R5G5B5: - Pitch = TextureSize.Width * 2; - break; - case D3DFMT_A8B8G8R8: - case D3DFMT_A8R8G8B8: - case D3DFMT_X8R8G8B8: - Pitch = TextureSize.Width * 4; - break; - case D3DFMT_R5G6B5: - Pitch = TextureSize.Width * 2; - break; - case D3DFMT_R8G8B8: - Pitch = TextureSize.Width * 3; - break; - default: - Pitch = 0; - }; -} - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_DIRECT3D_9_ - - diff --git a/irrlicht-1.6/source/Irrlicht/CD3D9Texture.h b/irrlicht-1.6/source/Irrlicht/CD3D9Texture.h deleted file mode 100644 index a9588907c..000000000 --- a/irrlicht-1.6/source/Irrlicht/CD3D9Texture.h +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_DIRECTX9_TEXTURE_H_INCLUDED__ -#define __C_DIRECTX9_TEXTURE_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ - -#include "ITexture.h" -#include "IImage.h" -#include <d3d9.h> - -namespace irr -{ -namespace video -{ - -class CD3D9Driver; -// forward declaration for RTT depth buffer handling -struct SDepthSurface; -/*! - interface for a Video Driver dependent Texture. -*/ -class CD3D9Texture : public ITexture -{ -public: - - //! constructor - CD3D9Texture(IImage* image, CD3D9Driver* driver, - u32 flags, const io::path& name); - - //! rendertarget constructor - CD3D9Texture(CD3D9Driver* driver, const core::dimension2d<u32>& size, const io::path& name, - const ECOLOR_FORMAT format = ECF_UNKNOWN); - - //! destructor - virtual ~CD3D9Texture(); - - //! lock function - virtual void* lock(bool readOnly = false); - - //! unlock function - virtual void unlock(); - - //! Returns original size of the texture. - virtual const core::dimension2d<u32>& getOriginalSize() const; - - //! Returns (=size) of the texture. - virtual const core::dimension2d<u32>& getSize() const; - - //! returns driver type of texture (=the driver, who created the texture) - virtual E_DRIVER_TYPE getDriverType() const; - - //! returns color format of texture - virtual ECOLOR_FORMAT getColorFormat() const; - - //! returns pitch of texture (in bytes) - virtual u32 getPitch() const; - - //! returns the DIRECT3D9 Texture - IDirect3DBaseTexture9* getDX9Texture() const; - - //! returns if texture has mipmap levels - bool hasMipMaps() const; - - //! Regenerates the mip map levels of the texture. Useful after locking and - //! modifying the texture - virtual void regenerateMipMapLevels(); - - //! returns if it is a render target - virtual bool isRenderTarget() const; - - //! Returns pointer to the render target surface - IDirect3DSurface9* getRenderTargetSurface(); - -private: - friend class CD3D9Driver; - - void createRenderTarget(const ECOLOR_FORMAT format = ECF_UNKNOWN); - - //! creates the hardware texture - bool createTexture(u32 flags, IImage * image); - - //! copies the image to the texture - bool copyTexture(IImage * image); - - //! Helper function for mipmap generation. - bool createMipMaps(u32 level=1); - - //! Helper function for mipmap generation. - void copy16BitMipMap(char* src, char* tgt, - s32 width, s32 height, s32 pitchsrc, s32 pitchtgt) const; - - //! Helper function for mipmap generation. - void copy32BitMipMap(char* src, char* tgt, - s32 width, s32 height, s32 pitchsrc, s32 pitchtgt) const; - - //! set Pitch based on the d3d format - void setPitch(D3DFORMAT d3dformat); - - IDirect3DDevice9* Device; - IDirect3DTexture9* Texture; - IDirect3DSurface9* RTTSurface; - CD3D9Driver* Driver; - SDepthSurface* DepthSurface; - core::dimension2d<u32> TextureSize; - core::dimension2d<u32> ImageSize; - s32 Pitch; - ECOLOR_FORMAT ColorFormat; - - bool HasMipMaps; - bool HardwareMipMaps; - bool IsRenderTarget; -}; - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_DIRECT3D_9_ - -#endif // __C_DIRECTX9_TEXTURE_H_INCLUDED__ - - diff --git a/irrlicht-1.6/source/Irrlicht/CDMFLoader.cpp b/irrlicht-1.6/source/Irrlicht/CDMFLoader.cpp deleted file mode 100644 index d35e6b805..000000000 --- a/irrlicht-1.6/source/Irrlicht/CDMFLoader.cpp +++ /dev/null @@ -1,427 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h -// -// This file was originally written by Salvatore Russo. -// I (Nikolaus Gebhardt) did some minor modifications and changes to it and -// integrated it into Irrlicht. -// Thanks a lot to Salvatore for his work on this and that he gave me -// his permission to add it into Irrlicht using the zlib license. -/* - CDMFLoader by Salvatore Russo (September 2005) - - See the header file for additional information including use and distribution rights. -*/ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_DMF_LOADER_ - -#ifdef _DEBUG -#define _IRR_DMF_DEBUG_ -#include "os.h" -#endif - -#include "CDMFLoader.h" -#include "ISceneManager.h" -#include "IAttributes.h" -#include "SAnimatedMesh.h" -#include "SSkinMeshBuffer.h" -#include "irrString.h" -#include "irrMath.h" -#include "dmfsupport.h" -#include "CImage.h" - -namespace irr -{ -namespace scene -{ - -/** Constructor*/ -CDMFLoader::CDMFLoader(ISceneManager* smgr, io::IFileSystem* filesys) -: SceneMgr(smgr), FileSystem(filesys) -{ - #ifdef _DEBUG - IReferenceCounted::setDebugName("CDMFLoader"); - #endif -} - - -/**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* CDMFLoader::createMesh(io::IReadFile* file) -{ - if (!file) - return 0; - video::IVideoDriver* driver = SceneMgr->getVideoDriver(); - - //Load stringlist - StringList dmfRawFile(file); - - if (dmfRawFile.size()==0) - return 0; - - SMesh * mesh = new SMesh(); - - u32 i; - - dmfHeader header; - - //load header - if (GetDMFHeader(dmfRawFile, header)) - { - //let's set ambient light - SceneMgr->setAmbientLight(header.dmfAmbient); - - //let's create the correct number of materials, vertices and faces - core::array<dmfMaterial> materiali; - dmfVert *verts=new dmfVert[header.numVertices]; - dmfFace *faces=new dmfFace[header.numFaces]; - - //let's get the materials -#ifdef _IRR_DMF_DEBUG_ - os::Printer::log("Loading materials", core::stringc(header.numMaterials).c_str()); -#endif - GetDMFMaterials(dmfRawFile, materiali, header.numMaterials); - - //let's get vertices and faces -#ifdef _IRR_DMF_DEBUG_ - os::Printer::log("Loading geometry"); -#endif - GetDMFVerticesFaces(dmfRawFile, verts, faces); - - //create a meshbuffer for each material, then we'll remove empty ones -#ifdef _IRR_DMF_DEBUG_ - os::Printer::log("Creating meshbuffers."); -#endif - for (i=0; i<header.numMaterials; i++) - { - //create a new SMeshBufferLightMap for each material - SSkinMeshBuffer* buffer = new SSkinMeshBuffer(); - buffer->Material.MaterialType = video::EMT_LIGHTMAP_LIGHTING; - buffer->Material.Wireframe = false; - buffer->Material.Lighting = true; - mesh->addMeshBuffer(buffer); - buffer->drop(); - } - - // Build the mesh buffers -#ifdef _IRR_DMF_DEBUG_ - os::Printer::log("Adding geometry to mesh."); -#endif - for (i = 0; i < header.numFaces; i++) - { -#ifdef _IRR_DMF_DEBUG_ -// os::Printer::log("Polygon with #vertices", core::stringc(faces[i].numVerts).c_str()); -#endif - if (faces[i].numVerts < 3) - continue; - - const core::vector3df normal = - core::triangle3df(verts[faces[i].firstVert].pos, - verts[faces[i].firstVert+1].pos, - verts[faces[i].firstVert+2].pos).getNormal().normalize(); - - SSkinMeshBuffer* meshBuffer = (SSkinMeshBuffer*)mesh->getMeshBuffer( - faces[i].materialID); - - const bool use2TCoords = meshBuffer->Vertices_2TCoords.size() || - materiali[faces[i].materialID].lightmapName.size(); - if (use2TCoords && meshBuffer->Vertices_Standard.size()) - meshBuffer->MoveTo_2TCoords(); - const u32 base = meshBuffer->Vertices_2TCoords.size()?meshBuffer->Vertices_2TCoords.size():meshBuffer->Vertices_Standard.size(); - - // Add this face's verts - if (use2TCoords) - { - for (u32 v = 0; v < faces[i].numVerts; v++) - { - const dmfVert& vv = verts[faces[i].firstVert + v]; - video::S3DVertex2TCoords vert(vv.pos, - normal, video::SColor(255,255,255,255), vv.tc, vv.lc); - if (materiali[faces[i].materialID].textureBlend==4 && - SceneMgr->getParameters()->getAttributeAsBool(DMF_FLIP_ALPHA_TEXTURES)) - { - vert.TCoords.set(vv.tc.X,-vv.tc.Y); - } - meshBuffer->Vertices_2TCoords.push_back(vert); - } - } - else - { - for (u32 v = 0; v < faces[i].numVerts; v++) - { - const dmfVert& vv = verts[faces[i].firstVert + v]; - video::S3DVertex vert(vv.pos, - normal, video::SColor(255,255,255,255), vv.tc); - if (materiali[faces[i].materialID].textureBlend==4 && - SceneMgr->getParameters()->getAttributeAsBool(DMF_FLIP_ALPHA_TEXTURES)) - { - vert.TCoords.set(vv.tc.X,-vv.tc.Y); - } - meshBuffer->Vertices_Standard.push_back(vert); - } - } - - // Now add the indices - // This weird loop turns convex polygons into triangle strips. - // I do it this way instead of a simple fan because it usually - // looks a lot better in wireframe, for example. - u32 h = faces[i].numVerts - 1, l = 0, c; // High, Low, Center - for (u32 v = 0; v < faces[i].numVerts - 2; v++) - { - if (v & 1) // odd - c = h - 1; - else // even - c = l + 1; - - meshBuffer->Indices.push_back(base + h); - meshBuffer->Indices.push_back(base + l); - meshBuffer->Indices.push_back(base + c); - - if (v & 1) // odd - h--; - else // even - l++; - } - } - - //load textures and lightmaps in materials. - //don't worry if you receive a could not load texture, cause if you don't need - //a particular material in your scene it will be loaded and then destroyed. -#ifdef _IRR_DMF_DEBUG_ - os::Printer::log("Loading textures."); -#endif - const bool use_mat_dirs=!SceneMgr->getParameters()->getAttributeAsBool(DMF_IGNORE_MATERIALS_DIRS); - - core::stringc path; - if ( SceneMgr->getParameters()->existsAttribute(DMF_TEXTURE_PATH) ) - path = SceneMgr->getParameters()->getAttributeAsString(DMF_TEXTURE_PATH); - else - path = FileSystem->getFileDir(file->getFileName()); - path += ('/'); - - for (i=0; i<header.numMaterials; i++) - { - //texture and lightmap - video::ITexture *tex = 0; - video::ITexture *lig = 0; - - //current buffer to apply material - video::SMaterial& mat = mesh->getMeshBuffer(i)->getMaterial(); - - //Primary texture is normal - if (materiali[i].textureFlag==0) - { - if (materiali[i].textureBlend==4) - driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT,true); - // path + texpath + full name - if (use_mat_dirs && FileSystem->existFile(path+materiali[i].pathName+materiali[i].textureName)) - tex = driver->getTexture((path+materiali[i].pathName+materiali[i].textureName)); - // path + full name - else if (FileSystem->existFile(path+materiali[i].textureName)) - tex = driver->getTexture((path+materiali[i].textureName)); - // path + texpath + base name - else if (use_mat_dirs && FileSystem->existFile(path+materiali[i].pathName+FileSystem->getFileBasename(materiali[i].textureName))) - tex = driver->getTexture((path+materiali[i].pathName+FileSystem->getFileBasename(materiali[i].textureName))); - // path + base name - else if (FileSystem->existFile(path+FileSystem->getFileBasename(materiali[i].textureName))) - tex = driver->getTexture((path+FileSystem->getFileBasename(materiali[i].textureName))); - // texpath + full name - else if (use_mat_dirs && FileSystem->existFile(materiali[i].pathName+materiali[i].textureName)) - tex = driver->getTexture(materiali[i].pathName+materiali[i].textureName.c_str()); - // full name - else if (FileSystem->existFile(materiali[i].textureName)) - tex = driver->getTexture(materiali[i].textureName.c_str()); - // texpath + base name - else if (use_mat_dirs && FileSystem->existFile(materiali[i].pathName+FileSystem->getFileBasename(materiali[i].textureName))) - tex = driver->getTexture(materiali[i].pathName+FileSystem->getFileBasename(materiali[i].textureName)); - // base name - else if (FileSystem->existFile(FileSystem->getFileBasename(materiali[i].textureName))) - tex = driver->getTexture(FileSystem->getFileBasename(materiali[i].textureName)); -#ifdef _IRR_DMF_DEBUG_ - else - os::Printer::log("Could not load texture", materiali[i].textureName); -#endif // _IRR_DMF_DEBUG_ - } - //Primary texture is just a colour - else if(materiali[i].textureFlag==1) - { - video::SColor color(axtoi(materiali[i].textureName.c_str())); - - //just for compatibility with older Irrlicht versions - //to support transparent materials - if (color.getAlpha()!=255 && materiali[i].textureBlend==4) - driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT,true); - - video::CImage *immagine= new video::CImage(video::ECF_A8R8G8B8, - core::dimension2d<u32>(8,8)); - immagine->fill(color); - tex = driver->addTexture("", immagine); - immagine->drop(); - - //to support transparent materials - if(color.getAlpha()!=255 && materiali[i].textureBlend==4) - { - mat.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; - mat.MaterialTypeParam =(((f32) (color.getAlpha()-1))/255.0f); - } - } - - //Lightmap is present - if (materiali[i].lightmapFlag == 0) - lig = driver->getTexture((path+materiali[i].lightmapName)); - else //no lightmap - { - mat.MaterialType = video::EMT_SOLID; - const f32 mult = 100.0f - header.dmfShadow; - mat.AmbientColor=header.dmfAmbient.getInterpolated(video::SColor(255,0,0,0),mult/100.f); - } - - if (materiali[i].textureBlend==4) - { - mat.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; - mat.MaterialTypeParam = - SceneMgr->getParameters()->getAttributeAsFloat(DMF_ALPHA_CHANNEL_REF); - } - - //if texture is present mirror vertically owing to DeleD representation - if (tex && header.dmfVersion<1.1) - { - const core::dimension2d<u32> texsize = tex->getSize(); - void* pp = tex->lock(); - if (pp) - { - const video::ECOLOR_FORMAT format = tex->getColorFormat(); - if (format == video::ECF_A1R5G5B5) - { - s16* p = (s16*)pp; - s16 tmp=0; - for (u32 x=0; x<texsize.Width; x++) - for (u32 y=0; y<texsize.Height/2; y++) - { - tmp=p[y*texsize.Width + x]; - p[y*texsize.Width + x] = p[(texsize.Height-y-1)*texsize.Width + x]; - p[(texsize.Height-y-1)*texsize.Width + x]=tmp; - } - } - else - if (format == video::ECF_A8R8G8B8) - { - s32* p = (s32*)pp; - s32 tmp=0; - for (u32 x=0; x<texsize.Width; x++) - for (u32 y=0; y<texsize.Height/2; y++) - { - tmp=p[y*texsize.Width + x]; - p[y*texsize.Width + x] = p[(texsize.Height-y-1)*texsize.Width + x]; - p[(texsize.Height-y-1)*texsize.Width + x]=tmp; - } - } - } - tex->unlock(); - tex->regenerateMipMapLevels(); - } - - //if lightmap is present mirror vertically owing to DeleD rapresentation - if (lig && header.dmfVersion<1.1) - { - const core::dimension2d<u32> ligsize=lig->getSize(); - void* pp = lig->lock(); - if (pp) - { - video::ECOLOR_FORMAT format = lig->getColorFormat(); - if (format == video::ECF_A1R5G5B5) - { - s16* p = (s16*)pp; - s16 tmp=0; - for (u32 x=0; x<ligsize.Width; x++) - { - for (u32 y=0; y<ligsize.Height/2; y++) - { - tmp=p[y*ligsize.Width + x]; - p[y*ligsize.Width + x] = p[(ligsize.Height-y-1)*ligsize.Width + x]; - p[(ligsize.Height-y-1)*ligsize.Width + x]=tmp; - } - } - } - else if (format == video::ECF_A8R8G8B8) - { - s32* p = (s32*)pp; - s32 tmp=0; - for (u32 x=0; x<ligsize.Width; x++) - { - for (u32 y=0; y<ligsize.Height/2; y++) - { - tmp=p[y*ligsize.Width + x]; - p[y*ligsize.Width + x] = p[(ligsize.Height-y-1)*ligsize.Width + x]; - p[(ligsize.Height-y-1)*ligsize.Width + x]=tmp; - } - } - } - } - lig->unlock(); - lig->regenerateMipMapLevels(); - } - - mat.setTexture(0, tex); - mat.setTexture(1, lig); - } - - delete verts; - delete faces; - } - - // delete all buffers without geometry in it. -#ifdef _IRR_DMF_DEBUG_ - os::Printer::log("Cleaning meshbuffers."); -#endif - i = 0; - while(i < mesh->MeshBuffers.size()) - { - if (mesh->MeshBuffers[i]->getVertexCount() == 0 || - mesh->MeshBuffers[i]->getIndexCount() == 0) - { - // Meshbuffer is empty -- drop it - mesh->MeshBuffers[i]->drop(); - mesh->MeshBuffers.erase(i); - } - else - { - i++; - } - } - - // create bounding box - for (i = 0; i < mesh->MeshBuffers.size(); ++i) - { - mesh->MeshBuffers[i]->recalculateBoundingBox(); - } - mesh->recalculateBoundingBox(); - - // Set up an animated mesh to hold the mesh - SAnimatedMesh* AMesh = new SAnimatedMesh(); - AMesh->Type = EAMT_UNKNOWN; - AMesh->addMesh(mesh); - AMesh->recalculateBoundingBox(); - mesh->drop(); - - return AMesh; -} - - -/** \brief Tell us if this file is able to be loaded by this class - based on the file extension (e.g. ".bsp") - \return true if file is loadable.*/ -bool CDMFLoader::isALoadableFileExtension(const io::path& filename) const -{ - return core::hasFileExtension ( filename, "dmf" ); -} - - -} // end namespace scene -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_DMF_LOADER_ - diff --git a/irrlicht-1.6/source/Irrlicht/CDMFLoader.h b/irrlicht-1.6/source/Irrlicht/CDMFLoader.h deleted file mode 100644 index 9c828f764..000000000 --- a/irrlicht-1.6/source/Irrlicht/CDMFLoader.h +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h -// -// This file was originally written by Salvatore Russo. -// I (Nikolaus Gebhardt) did some minor modifications changes to it and integrated -// it into Irrlicht: -// - removed STL dependency -// - removed log file and replaced it with irrlicht logging -// - adapted code formatting a bit to Irrlicht style -// - removed memory leaks -// Thanks a lot to Salvatore for his work on this and that he gave me -// his permission to add it into Irrlicht. - -/* - CDMFLoader by Salvatore Russo - Version 1.3 - - This loader is used to load DMF files in Irrlicht. - Look at the documentation for a sample application. - - Parts of this code are from Murphy McCauley COCTLoader just like - GetFaceNormal() or indexes creation routines and a routine to add faces. So - please refer to COCTLoader.h to know more about rights granted. - - You can use this software as you wish but you must not remove these notes about license nor - credits to others for parts of this code. -*/ - -#ifndef __C_DMF_LOADER_H_INCLUDED__ -#define __C_DMF_LOADER_H_INCLUDED__ - -#include "IMeshLoader.h" -#include "IReadFile.h" -#include "IFileSystem.h" -#include "SMesh.h" -#include "IVideoDriver.h" -#include "ISceneManager.h" -#include "SAnimatedMesh.h" - -namespace irr -{ -namespace scene -{ - /** A class to load DeleD mesh files.*/ - class CDMFLoader : public IMeshLoader - { - public: - - /** constructor*/ - CDMFLoader(ISceneManager* smgr, io::IFileSystem* filesys); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".cob") - virtual bool isALoadableFileExtension(const io::path& 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); - - /** 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, ISceneManager* smgr, - ISceneNode* parent = 0, s32 base_id = 1000); - - /** loads water plains present in this scene. - Note that loaded water plains from DeleD must have the suffix \b water_ and must be \b rectangle (with just 1 rectangular face). - 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, - ISceneManager* smgr, - ISceneNode * parent = 0, - s32 base_id = 2000, - bool mode = true); - - private: - ISceneManager* SceneMgr; - io::IFileSystem* FileSystem; - }; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CDefaultGUIElementFactory.cpp b/irrlicht-1.6/source/Irrlicht/CDefaultGUIElementFactory.cpp deleted file mode 100644 index 07cc11d3c..000000000 --- a/irrlicht-1.6/source/Irrlicht/CDefaultGUIElementFactory.cpp +++ /dev/null @@ -1,164 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CDefaultGUIElementFactory.h" - -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUIEnvironment.h" - -#include "IGUIButton.h" -#include "IGUICheckBox.h" -#include "IGUIColorSelectDialog.h" -#include "IGUIComboBox.h" -#include "IGUIContextMenu.h" -#include "IGUIEditBox.h" -#include "IGUIFileOpenDialog.h" -#include "IGUIInOutFader.h" -#include "IGUIImage.h" -#include "IGUIListBox.h" -#include "IGUIMeshViewer.h" -#include "IGUIScrollBar.h" -#include "IGUISpinBox.h" -#include "IGUIStaticText.h" -#include "IGUITabControl.h" -#include "IGUITable.h" -#include "IGUIToolbar.h" -#include "IGUIWindow.h" -#include "IGUITreeView.h" - -namespace irr -{ -namespace gui -{ - -CDefaultGUIElementFactory::CDefaultGUIElementFactory(IGUIEnvironment* env) -: Environment(env) -{ - - #ifdef _DEBUG - setDebugName("CDefaultGUIElementFactory"); - #endif - - // don't grab the gui environment here to prevent cyclic references -} - - -//! adds an element to the env based on its type id -IGUIElement* CDefaultGUIElementFactory::addGUIElement(EGUI_ELEMENT_TYPE type, IGUIElement* parent) -{ - switch(type) - { - case EGUIET_BUTTON: - return Environment->addButton(core::rect<s32>(0,0,100,100),parent); - case EGUIET_CHECK_BOX: - return Environment->addCheckBox(false, core::rect<s32>(0,0,100,100), parent); - case EGUIET_COLOR_SELECT_DIALOG: - return Environment->addColorSelectDialog(0,true,parent); - case EGUIET_COMBO_BOX: - return Environment->addComboBox(core::rect<s32>(0,0,100,100),parent); - case EGUIET_CONTEXT_MENU: - return Environment->addContextMenu(core::rect<s32>(0,0,100,100),parent); - case EGUIET_MENU: - return Environment->addMenu(parent); - case EGUIET_EDIT_BOX: - return Environment->addEditBox(0,core::rect<s32>(0,0,100,100),true, parent); - case EGUIET_FILE_OPEN_DIALOG: - return Environment->addFileOpenDialog(0,true,parent); - case EGUIET_IMAGE: - return Environment->addImage(0,core::position2di(0,0), true, parent); - case EGUIET_IN_OUT_FADER: - return Environment->addInOutFader(0,parent); - case EGUIET_LIST_BOX: - return Environment->addListBox(core::rect<s32>(0,0,100,100),parent); - case EGUIET_MESH_VIEWER: - return Environment->addMeshViewer(core::rect<s32>(0,0,100,100),parent); - case EGUIET_MODAL_SCREEN: - return Environment->addModalScreen(parent); - case EGUIET_MESSAGE_BOX: - return Environment->addMessageBox(0,0,false,0,parent); - case EGUIET_SCROLL_BAR: - return Environment->addScrollBar(false,core::rect<s32>(0,0,100,100),parent); - case EGUIET_STATIC_TEXT: - return Environment->addStaticText(0,core::rect<s32>(0,0,100,100),false,true,parent); - case EGUIET_TAB: - return Environment->addTab(core::rect<s32>(0,0,100,100),parent); - case EGUIET_TAB_CONTROL: - return Environment->addTabControl(core::rect<s32>(0,0,100,100),parent); - case EGUIET_TABLE: - return Environment->addTable(core::rect<s32>(0,0,100,100), parent); - case EGUIET_TOOL_BAR: - return Environment->addToolBar(parent); - case EGUIET_WINDOW: - return Environment->addWindow(core::rect<s32>(0,0,100,100),false,0,parent); - case EGUIET_SPIN_BOX: - return Environment->addSpinBox(L"0.0", core::rect<s32>(0,0,100,100), true, parent); - case EGUIET_TREE_VIEW: - return Environment->addTreeView(core::rect<s32>(0,0,100,100),parent); - default: - return 0; - } -} - - -//! adds an element to the environment based on its type name -IGUIElement* CDefaultGUIElementFactory::addGUIElement(const c8* typeName, IGUIElement* parent) -{ - return addGUIElement( getTypeFromName(typeName), parent ); -} - - -//! Returns the amount of element types this factory is able to create. -s32 CDefaultGUIElementFactory::getCreatableGUIElementTypeCount() const -{ - return EGUIET_COUNT; -} - - -//! Returns the type of a createable element type. -EGUI_ELEMENT_TYPE CDefaultGUIElementFactory::getCreateableGUIElementType(s32 idx) const -{ - if (idx>=0 && idx<EGUIET_COUNT) - return (EGUI_ELEMENT_TYPE)idx; - - return EGUIET_ELEMENT; -} - - -//! Returns the type name of a createable element type. -const c8* CDefaultGUIElementFactory::getCreateableGUIElementTypeName(s32 idx) const -{ - if (idx>=0 && idx<EGUIET_COUNT) - return GUIElementTypeNames[idx]; - - return 0; -} - - -//! Returns the type name of a createable element type. -const c8* CDefaultGUIElementFactory::getCreateableGUIElementTypeName(EGUI_ELEMENT_TYPE type) const -{ - // for this factory, type == index - - if (type>=0 && type<EGUIET_COUNT) - return GUIElementTypeNames[type]; - - return 0; -} - -EGUI_ELEMENT_TYPE CDefaultGUIElementFactory::getTypeFromName(const c8* name) const -{ - for ( u32 i=0; GUIElementTypeNames[i]; ++i) - if (!strcmp(name, GUIElementTypeNames[i]) ) - return (EGUI_ELEMENT_TYPE)i; - - return EGUIET_ELEMENT; -} - - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - diff --git a/irrlicht-1.6/source/Irrlicht/CDefaultGUIElementFactory.h b/irrlicht-1.6/source/Irrlicht/CDefaultGUIElementFactory.h deleted file mode 100644 index 5a8b1423e..000000000 --- a/irrlicht-1.6/source/Irrlicht/CDefaultGUIElementFactory.h +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_DEFAULT_GUI_ELEMENT_FACTORY_H_INCLUDED__ -#define __C_DEFAULT_GUI_ELEMENT_FACTORY_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUIElementFactory.h" - -namespace irr -{ -namespace gui -{ - class IGUIElement; - class IGUIEnvironment; - - //! This interface makes it possible to dynamically create gui elements. - class CDefaultGUIElementFactory : public IGUIElementFactory - { - public: - - CDefaultGUIElementFactory(IGUIEnvironment* env); - - //! Adds an element to the gui environment based on its type id. - /** \param type: Type of the element to add. - \param parent: Parent scene node of the new element. A value of 0 adds it to the root. - \return Returns pointer to the new element or 0 if unsuccessful. */ - virtual IGUIElement* addGUIElement(EGUI_ELEMENT_TYPE type, IGUIElement* parent=0); - - //! Adds a GUI element to the GUI Environment based on its type name. - /** \param typeName: Type name of the element to add. Taken from the GUIElementTypeNames c8* array. - \param parent: Parent scene node of the new element. A value of 0 adds it to the root. - \return Returns pointer to the new element or 0 if unsuccessful. */ - virtual IGUIElement* addGUIElement(const c8* typeName, IGUIElement* parent=0); - - //! Returns the amount of GUI element types this factory is able to create. - virtual s32 getCreatableGUIElementTypeCount() const; - - //! Returns the type of a createable GUI element type based on the index. - /** \param idx: Index of the element type in this factory. The value must be equal or greater than 0 - and lower than getCreatableGUIElementTypeCount(). */ - virtual EGUI_ELEMENT_TYPE getCreateableGUIElementType(s32 idx) const; - - //! Returns the type name of a createable GUI element type based on the index. - /** \param idx: Index of the element type in this factory. The value must be equal or greater than 0 - and lower than getCreatableGUIElementTypeCount(). */ - virtual const c8* getCreateableGUIElementTypeName(s32 idx) const; - - //! Returns the type name of a createable GUI element based on its type. - /** \param type: Type of the GUI element. - \return: Returns the name of the type if this factory can create it, otherwise it returns 0. */ - virtual const c8* getCreateableGUIElementTypeName(EGUI_ELEMENT_TYPE type) const; - - private: - - EGUI_ELEMENT_TYPE getTypeFromName(const c8* name) const; - - IGUIEnvironment* Environment; - }; - - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - -#endif // __C_DEFAULT_GUI_ELEMENT_FACTORY_H_INCLUDED__ diff --git a/irrlicht-1.6/source/Irrlicht/CDefaultSceneNodeAnimatorFactory.cpp b/irrlicht-1.6/source/Irrlicht/CDefaultSceneNodeAnimatorFactory.cpp deleted file mode 100644 index ef913f6ac..000000000 --- a/irrlicht-1.6/source/Irrlicht/CDefaultSceneNodeAnimatorFactory.cpp +++ /dev/null @@ -1,160 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CDefaultSceneNodeAnimatorFactory.h" -#include "CSceneNodeAnimatorCameraFPS.h" -#include "CSceneNodeAnimatorCameraMaya.h" -#include "ICursorControl.h" -#include "ISceneNodeAnimatorCollisionResponse.h" -#include "ISceneManager.h" - -namespace irr -{ -namespace scene -{ - -//! Names for scene node types -const c8* const SceneNodeAnimatorTypeNames[] = -{ - "flyCircle", - "flyStraight", - "followSpline", - "rotation", - "texture", - "deletion", - "collisionResponse", - "cameraFPS", - "cameraMaya", - 0 -}; - - -CDefaultSceneNodeAnimatorFactory::CDefaultSceneNodeAnimatorFactory(ISceneManager* mgr, gui::ICursorControl* crs) -: Manager(mgr), CursorControl(crs) -{ - #ifdef _DEBUG - setDebugName("CDefaultSceneNodeAnimatorFactory"); - #endif - - // don't grab the scene manager here to prevent cyclic references - if (CursorControl) - CursorControl->grab(); -} - -CDefaultSceneNodeAnimatorFactory::~CDefaultSceneNodeAnimatorFactory() -{ - if (CursorControl) - CursorControl->drop(); -} - -//! creates a scene node animator based on its type id -ISceneNodeAnimator* CDefaultSceneNodeAnimatorFactory::createSceneNodeAnimator(ESCENE_NODE_ANIMATOR_TYPE type, ISceneNode* target) -{ - scene::ISceneNodeAnimator* anim = 0; - - switch(type) - { - case ESNAT_FLY_CIRCLE: - anim = Manager->createFlyCircleAnimator(core::vector3df(0,0,0), 10); - break; - case ESNAT_FLY_STRAIGHT: - anim = Manager->createFlyStraightAnimator(core::vector3df(0,0,0), core::vector3df(100,100,100), 10000, true ); - break; - case ESNAT_FOLLOW_SPLINE: - { - core::array<core::vector3df> points; - points.push_back(core::vector3df(0,0,0)); - points.push_back(core::vector3df(10,5,10)); - anim = Manager->createFollowSplineAnimator(0, points); - } - break; - case ESNAT_ROTATION: - anim = Manager->createRotationAnimator(core::vector3df(0.3f,0,0)); - break; - case ESNAT_TEXTURE: - { - core::array<video::ITexture*> textures; - anim = Manager->createTextureAnimator(textures, 250); - } - break; - case ESNAT_DELETION: - anim = Manager->createDeleteAnimator(5000); - break; - case ESNAT_COLLISION_RESPONSE: - anim = Manager->createCollisionResponseAnimator(0, target); - break; - case ESNAT_CAMERA_FPS: - anim = new CSceneNodeAnimatorCameraFPS(CursorControl); - break; - case ESNAT_CAMERA_MAYA: - anim = new CSceneNodeAnimatorCameraMaya(CursorControl); - break; - default: - break; - } - - if (anim && target) - target->addAnimator(anim); - - return anim; -} - - -//! creates a scene node animator based on its type name -ISceneNodeAnimator* CDefaultSceneNodeAnimatorFactory::createSceneNodeAnimator(const c8* typeName, ISceneNode* target) -{ - return createSceneNodeAnimator( getTypeFromName(typeName), target ); -} - - -//! returns amount of scene node animator types this factory is able to create -u32 CDefaultSceneNodeAnimatorFactory::getCreatableSceneNodeAnimatorTypeCount() const -{ - return ESNAT_COUNT; -} - - -//! returns type of a createable scene node animator type -ESCENE_NODE_ANIMATOR_TYPE CDefaultSceneNodeAnimatorFactory::getCreateableSceneNodeAnimatorType(u32 idx) const -{ - if (idx<ESNAT_COUNT) - return (ESCENE_NODE_ANIMATOR_TYPE)idx; - else - return ESNAT_UNKNOWN; -} - - -//! returns type name of a createable scene node animator type -const c8* CDefaultSceneNodeAnimatorFactory::getCreateableSceneNodeAnimatorTypeName(u32 idx) const -{ - if (idx<ESNAT_COUNT) - return SceneNodeAnimatorTypeNames[idx]; - else - return 0; -} - -//! returns type name of a createable scene node animator type -const c8* CDefaultSceneNodeAnimatorFactory::getCreateableSceneNodeAnimatorTypeName(ESCENE_NODE_ANIMATOR_TYPE type) const -{ - // for this factory: index == type - - if (type<ESNAT_COUNT) - return SceneNodeAnimatorTypeNames[type]; - else - return 0; -} - -ESCENE_NODE_ANIMATOR_TYPE CDefaultSceneNodeAnimatorFactory::getTypeFromName(const c8* name) const -{ - for ( u32 i=0; SceneNodeAnimatorTypeNames[i]; ++i) - if (!strcmp(name, SceneNodeAnimatorTypeNames[i]) ) - return (ESCENE_NODE_ANIMATOR_TYPE)i; - - return ESNAT_UNKNOWN; -} - - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CDefaultSceneNodeAnimatorFactory.h b/irrlicht-1.6/source/Irrlicht/CDefaultSceneNodeAnimatorFactory.h deleted file mode 100644 index d9f59c1d6..000000000 --- a/irrlicht-1.6/source/Irrlicht/CDefaultSceneNodeAnimatorFactory.h +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_DEFAULT_SCENE_NODE_ANIMATOR_FACTORY_H_INCLUDED__ -#define __C_DEFAULT_SCENE_NODE_ANIMATOR_FACTORY_H_INCLUDED__ - -#include "ISceneNodeAnimatorFactory.h" - -namespace irr -{ -namespace gui -{ - class ICursorControl; -} -namespace scene -{ - class ISceneNodeAnimator; - class ISceneManager; - - //! Interface making it possible to dynamicly create scene nodes animators - class CDefaultSceneNodeAnimatorFactory : public ISceneNodeAnimatorFactory - { - public: - - CDefaultSceneNodeAnimatorFactory(ISceneManager* mgr, gui::ICursorControl* crs); - - virtual ~CDefaultSceneNodeAnimatorFactory(); - - //! creates a scene node animator based on its type id - /** \param type: Type of the scene node animator to add. - \param target: Target scene node of the new animator. - \return Returns pointer to the new scene node animator or null if not successful. You need to - drop this pointer after calling this, see IReferenceCounted::drop() for details. */ - virtual ISceneNodeAnimator* createSceneNodeAnimator(ESCENE_NODE_ANIMATOR_TYPE type, ISceneNode* target); - - //! creates a scene node animator based on its type name - /** \param typeName: Type of the scene node animator to add. - \param target: Target scene node of the new animator. - \return Returns pointer to the new scene node animator or null if not successful. You need to - drop this pointer after calling this, see IReferenceCounted::drop() for details. */ - virtual ISceneNodeAnimator* createSceneNodeAnimator(const char* typeName, ISceneNode* target); - - //! returns amount of scene node animator types this factory is able to create - virtual u32 getCreatableSceneNodeAnimatorTypeCount() const; - - //! returns type of a createable scene node animator type - /** \param idx: Index of scene node animator type in this factory. Must be a value between 0 and - getCreatableSceneNodeTypeCount() */ - virtual ESCENE_NODE_ANIMATOR_TYPE getCreateableSceneNodeAnimatorType(u32 idx) const; - - //! returns type name of a createable scene node animator type - /** \param idx: Index of scene node animator type in this factory. Must be a value between 0 and - getCreatableSceneNodeAnimatorTypeCount() */ - virtual const c8* getCreateableSceneNodeAnimatorTypeName(u32 idx) const; - - //! returns type name of a createable scene node animator type - /** \param type: Type of scene node animator. - \return: Returns name of scene node animator type if this factory can create the type, otherwise 0. */ - virtual const c8* getCreateableSceneNodeAnimatorTypeName(ESCENE_NODE_ANIMATOR_TYPE type) const; - - private: - - ESCENE_NODE_ANIMATOR_TYPE getTypeFromName(const c8* name) const; - - ISceneManager* Manager; - gui::ICursorControl* CursorControl; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CDefaultSceneNodeFactory.cpp b/irrlicht-1.6/source/Irrlicht/CDefaultSceneNodeFactory.cpp deleted file mode 100644 index c4b943ec2..000000000 --- a/irrlicht-1.6/source/Irrlicht/CDefaultSceneNodeFactory.cpp +++ /dev/null @@ -1,174 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CDefaultSceneNodeFactory.h" -#include "ISceneManager.h" -#include "ITextSceneNode.h" -#include "ITerrainSceneNode.h" -#include "IDummyTransformationSceneNode.h" -#include "ICameraSceneNode.h" -#include "IBillboardSceneNode.h" -#include "IAnimatedMeshSceneNode.h" -#include "IParticleSystemSceneNode.h" -#include "ILightSceneNode.h" -#include "IMeshSceneNode.h" - -namespace irr -{ -namespace scene -{ - - -CDefaultSceneNodeFactory::CDefaultSceneNodeFactory(ISceneManager* mgr) -: Manager(mgr) -{ - - #ifdef _DEBUG - setDebugName("CDefaultSceneNodeFactory"); - #endif - - // don't grab the scene manager here to prevent cyclic references - - SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_CUBE, "cube")); - SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_SPHERE, "sphere")); - SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_TEXT, "text")); - SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_WATER_SURFACE, "waterSurface")); - SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_TERRAIN, "terrain")); - SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_SKY_BOX, "skyBox")); - SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_SKY_DOME, "skyDome")); - SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_SHADOW_VOLUME, "shadowVolume")); - SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_OCT_TREE, "octTree")); - SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_MESH, "mesh")); - SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_LIGHT, "light")); - SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_EMPTY, "empty")); - SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_DUMMY_TRANSFORMATION, "dummyTransformation")); - SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_CAMERA, "camera")); - SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_BILLBOARD, "billBoard")); - SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_ANIMATED_MESH, "animatedMesh")); - SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_PARTICLE_SYSTEM, "particleSystem")); - // SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_MD3_SCENE_NODE, "md3")); - - // legacy, for version <= 1.4.x irr files - SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_CAMERA_MAYA, "cameraMaya")); - SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_CAMERA_FPS, "cameraFPS")); - SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_Q3SHADER_SCENE_NODE, "quake3Shader")); -} - - -//! adds a scene node to the scene graph based on its type id -ISceneNode* CDefaultSceneNodeFactory::addSceneNode(ESCENE_NODE_TYPE type, ISceneNode* parent) -{ - switch(type) - { - case ESNT_CUBE: - return Manager->addCubeSceneNode(10, parent); - case ESNT_SPHERE: - return Manager->addSphereSceneNode(5, 16, parent); - case ESNT_TEXT: - return Manager->addTextSceneNode(0, L"example"); - case ESNT_WATER_SURFACE: - return Manager->addWaterSurfaceSceneNode(0, 2.0f, 300.0f, 10.0f, parent); - case ESNT_TERRAIN: - return Manager->addTerrainSceneNode("", parent, -1, - core::vector3df(0.0f,0.0f,0.0f), - core::vector3df(0.0f,0.0f,0.0f), - core::vector3df(1.0f,1.0f,1.0f), - video::SColor(255,255,255,255), - 4, ETPS_17, 0, true); - case ESNT_SKY_BOX: - return Manager->addSkyBoxSceneNode(0,0,0,0,0,0, parent); - case ESNT_SKY_DOME: - return Manager->addSkyDomeSceneNode(0, 16, 8, 0.9f, 2.0f, 1000.0f, parent); - case ESNT_SHADOW_VOLUME: - return 0; - case ESNT_OCT_TREE: - return Manager->addOctTreeSceneNode((IMesh*)0, parent, -1, 128, true); - case ESNT_MESH: - return Manager->addMeshSceneNode(0, parent, -1, core::vector3df(), - core::vector3df(), core::vector3df(1,1,1), true); - case ESNT_LIGHT: - return Manager->addLightSceneNode(parent); - case ESNT_EMPTY: - return Manager->addEmptySceneNode(parent); - case ESNT_DUMMY_TRANSFORMATION: - return Manager->addDummyTransformationSceneNode(parent); - case ESNT_CAMERA: - return Manager->addCameraSceneNode(parent); - case ESNT_CAMERA_MAYA: - return Manager->addCameraSceneNodeMaya(parent); - case ESNT_CAMERA_FPS: - return Manager->addCameraSceneNodeFPS(parent); - case ESNT_BILLBOARD: - return Manager->addBillboardSceneNode(parent); - case ESNT_ANIMATED_MESH: - return Manager->addAnimatedMeshSceneNode(0, parent, -1, core::vector3df(), - core::vector3df(), core::vector3df(1,1,1), true); - case ESNT_PARTICLE_SYSTEM: - return Manager->addParticleSystemSceneNode(true, parent); - default: - break; - } - - return 0; -} - - -//! adds a scene node to the scene graph based on its type name -ISceneNode* CDefaultSceneNodeFactory::addSceneNode(const c8* typeName, ISceneNode* parent) -{ - return addSceneNode( getTypeFromName(typeName), parent ); -} - - -//! returns amount of scene node types this factory is able to create -u32 CDefaultSceneNodeFactory::getCreatableSceneNodeTypeCount() const -{ - return SupportedSceneNodeTypes.size(); -} - - -//! returns type of a createable scene node type -ESCENE_NODE_TYPE CDefaultSceneNodeFactory::getCreateableSceneNodeType(u32 idx) const -{ - if (idx<SupportedSceneNodeTypes.size()) - return SupportedSceneNodeTypes[idx].Type; - else - return ESNT_UNKNOWN; -} - - -//! returns type name of a createable scene node type -const c8* CDefaultSceneNodeFactory::getCreateableSceneNodeTypeName(u32 idx) const -{ - if (idx<SupportedSceneNodeTypes.size()) - return SupportedSceneNodeTypes[idx].TypeName.c_str(); - else - return 0; -} - - -//! returns type name of a createable scene node type -const c8* CDefaultSceneNodeFactory::getCreateableSceneNodeTypeName(ESCENE_NODE_TYPE type) const -{ - for (u32 i=0; i<SupportedSceneNodeTypes.size(); ++i) - if (SupportedSceneNodeTypes[i].Type == type) - return SupportedSceneNodeTypes[i].TypeName.c_str(); - - return 0; -} - - -ESCENE_NODE_TYPE CDefaultSceneNodeFactory::getTypeFromName(const c8* name) const -{ - for (u32 i=0; i<SupportedSceneNodeTypes.size(); ++i) - if (SupportedSceneNodeTypes[i].TypeName == name) - return SupportedSceneNodeTypes[i].Type; - - return ESNT_UNKNOWN; -} - - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CDefaultSceneNodeFactory.h b/irrlicht-1.6/source/Irrlicht/CDefaultSceneNodeFactory.h deleted file mode 100644 index a3bad9c06..000000000 --- a/irrlicht-1.6/source/Irrlicht/CDefaultSceneNodeFactory.h +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_DEFAULT_SCENE_NODE_FACTORY_H_INCLUDED__ -#define __C_DEFAULT_SCENE_NODE_FACTORY_H_INCLUDED__ - -#include "ISceneNodeFactory.h" -#include "irrArray.h" -#include "irrString.h" - -namespace irr -{ -namespace scene -{ - class ISceneNode; - class ISceneManager; - - //! Interface making it possible to dynamicly create scene nodes and animators - class CDefaultSceneNodeFactory : public ISceneNodeFactory - { - public: - - CDefaultSceneNodeFactory(ISceneManager* mgr); - - //! adds a scene node to the scene graph based on its type id - /** \param type: Type of the scene node to add. - \param parent: Parent scene node of the new node, can be null to add the scene node to the root. - \return Returns pointer to the new scene node or null if not successful. */ - virtual ISceneNode* addSceneNode(ESCENE_NODE_TYPE type, ISceneNode* parent=0); - - //! adds a scene node to the scene graph based on its type name - /** \param typeName: Type name of the scene node to add. - \param parent: Parent scene node of the new node, can be null to add the scene node to the root. - \return Returns pointer to the new scene node or null if not successful. */ - virtual ISceneNode* addSceneNode(const c8* typeName, ISceneNode* parent=0); - - //! returns amount of scene node types this factory is able to create - virtual u32 getCreatableSceneNodeTypeCount() const; - - //! returns type name of a createable scene node type by index - /** \param idx: Index of scene node type in this factory. Must be a value between 0 and - uetCreatableSceneNodeTypeCount() */ - virtual const c8* getCreateableSceneNodeTypeName(u32 idx) const; - - //! returns type of a createable scene node type - /** \param idx: Index of scene node type in this factory. Must be a value between 0 and - getCreatableSceneNodeTypeCount() */ - virtual ESCENE_NODE_TYPE getCreateableSceneNodeType(u32 idx) const; - - //! returns type name of a createable scene node type - /** \param idx: Type of scene node. - \return: Returns name of scene node type if this factory can create the type, otherwise 0. */ - virtual const c8* getCreateableSceneNodeTypeName(ESCENE_NODE_TYPE type) const; - - private: - - ESCENE_NODE_TYPE getTypeFromName(const c8* name) const; - - struct SSceneNodeTypePair - { - SSceneNodeTypePair(ESCENE_NODE_TYPE type, const c8* name) - : Type(type), TypeName(name) - {} - - ESCENE_NODE_TYPE Type; - core::stringc TypeName; - }; - - core::array<SSceneNodeTypePair> SupportedSceneNodeTypes; - - ISceneManager* Manager; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CDepthBuffer.cpp b/irrlicht-1.6/source/Irrlicht/CDepthBuffer.cpp deleted file mode 100644 index 52fd03427..000000000 --- a/irrlicht-1.6/source/Irrlicht/CDepthBuffer.cpp +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "SoftwareDriver2_compile_config.h" -#include "CDepthBuffer.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - - -//! constructor -CDepthBuffer::CDepthBuffer(const core::dimension2d<u32>& size) -: Buffer(0), Size(0,0) -{ - #ifdef _DEBUG - setDebugName("CDepthBuffer"); - #endif - - setSize(size); -} - - - -//! destructor -CDepthBuffer::~CDepthBuffer() -{ - if (Buffer) - delete [] Buffer; -} - - - -//! clears the zbuffer -void CDepthBuffer::clear() -{ - -#ifdef SOFTWARE_DRIVER_2_USE_WBUFFER - f32 zMax = 0.f; -#else - f32 zMax = 1.f; -#endif - - u32 zMaxValue; - zMaxValue = *(u32*) &zMax; - - memset32 ( Buffer, zMaxValue, TotalSize ); -} - - - -//! sets the new size of the zbuffer -void CDepthBuffer::setSize(const core::dimension2d<u32>& size) -{ - if (size == Size) - return; - - Size = size; - - if (Buffer) - delete [] Buffer; - - Pitch = size.Width * sizeof ( fp24 ); - TotalSize = Pitch * size.Height; - Buffer = new u8[TotalSize]; -} - - - -//! returns the size of the zbuffer -const core::dimension2d<u32>& CDepthBuffer::getSize() const -{ - return Size; -} - - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - -//! creates a ZBuffer -IDepthBuffer* createDepthBuffer(const core::dimension2d<u32>& size) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CDepthBuffer(size); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - -} // end namespace video -} // end namespace irr - - - diff --git a/irrlicht-1.6/source/Irrlicht/CDepthBuffer.h b/irrlicht-1.6/source/Irrlicht/CDepthBuffer.h deleted file mode 100644 index 258a61c23..000000000 --- a/irrlicht-1.6/source/Irrlicht/CDepthBuffer.h +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_Z_BUFFER_H_INCLUDED__ -#define __C_Z_BUFFER_H_INCLUDED__ - -#include "IDepthBuffer.h" - -namespace irr -{ -namespace video -{ - - class CDepthBuffer : public IDepthBuffer - { - public: - - //! constructor - CDepthBuffer(const core::dimension2d<u32>& size); - - //! destructor - virtual ~CDepthBuffer(); - - //! clears the zbuffer - virtual void clear(); - - //! sets the new size of the zbuffer - virtual void setSize(const core::dimension2d<u32>& size); - - //! returns the size of the zbuffer - virtual const core::dimension2d<u32>& getSize() const; - - //! locks the zbuffer - virtual void* lock() - { - return (void*) Buffer; - } - - //! unlocks the zbuffer - virtual void unlock() - { - } - - //! returns pitch of depthbuffer (in bytes) - virtual u32 getPitch() const - { - return Pitch; - } - - - private: - - u8* Buffer; - core::dimension2d<u32> Size; - u32 TotalSize; - u32 Pitch; - }; - -} // end namespace video -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CDummyTransformationSceneNode.cpp b/irrlicht-1.6/source/Irrlicht/CDummyTransformationSceneNode.cpp deleted file mode 100644 index dc0207205..000000000 --- a/irrlicht-1.6/source/Irrlicht/CDummyTransformationSceneNode.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CDummyTransformationSceneNode.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CDummyTransformationSceneNode::CDummyTransformationSceneNode( - ISceneNode* parent, ISceneManager* mgr, s32 id) - : IDummyTransformationSceneNode(parent, mgr, id) -{ - #ifdef _DEBUG - setDebugName("CDummyTransformationSceneNode"); - #endif - - setAutomaticCulling(scene::EAC_OFF); -} - - -//! returns the axis aligned bounding box of this node -const core::aabbox3d<f32>& CDummyTransformationSceneNode::getBoundingBox() const -{ - return Box; -} - - -//! Returns a reference to the current relative transformation matrix. -//! This is the matrix, this scene node uses instead of scale, translation -//! and rotation. -core::matrix4& CDummyTransformationSceneNode::getRelativeTransformationMatrix() -{ - return RelativeTransformationMatrix; -} - - -//! Returns the relative transformation of the scene node. -core::matrix4 CDummyTransformationSceneNode::getRelativeTransformation() const -{ - return RelativeTransformationMatrix; -} - - -} // end namespace scene -} // end namespace irr diff --git a/irrlicht-1.6/source/Irrlicht/CDummyTransformationSceneNode.h b/irrlicht-1.6/source/Irrlicht/CDummyTransformationSceneNode.h deleted file mode 100644 index 379a4857c..000000000 --- a/irrlicht-1.6/source/Irrlicht/CDummyTransformationSceneNode.h +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_DUMMY_TRANSFORMATION_SCENE_NODE_H_INCLUDED__ -#define __C_DUMMY_TRANSFORMATION_SCENE_NODE_H_INCLUDED__ - -#include "IDummyTransformationSceneNode.h" - -namespace irr -{ -namespace scene -{ - - class CDummyTransformationSceneNode : public IDummyTransformationSceneNode - { - public: - - //! constructor - CDummyTransformationSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id); - - //! returns the axis aligned bounding box of this node - virtual const core::aabbox3d<f32>& getBoundingBox() const; - - //! Returns a reference to the current relative transformation matrix. - //! This is the matrix, this scene node uses instead of scale, translation - //! and rotation. - virtual core::matrix4& getRelativeTransformationMatrix(); - - //! Returns the relative transformation of the scene node. - virtual core::matrix4 getRelativeTransformation() const; - - //! does nothing. - virtual void render() {} - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() const { return ESNT_DUMMY_TRANSFORMATION; } - - private: - - core::matrix4 RelativeTransformationMatrix; - core::aabbox3d<f32> Box; - }; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CEmptySceneNode.cpp b/irrlicht-1.6/source/Irrlicht/CEmptySceneNode.cpp deleted file mode 100644 index 40f44dc1c..000000000 --- a/irrlicht-1.6/source/Irrlicht/CEmptySceneNode.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CEmptySceneNode.h" -#include "ISceneManager.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CEmptySceneNode::CEmptySceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id) -: ISceneNode(parent, mgr, id) -{ - #ifdef _DEBUG - setDebugName("CEmptySceneNode"); - #endif - - setAutomaticCulling(scene::EAC_OFF); -} - - -//! pre render event -void CEmptySceneNode::OnRegisterSceneNode() -{ - if (IsVisible) - SceneManager->registerNodeForRendering(this); - - ISceneNode::OnRegisterSceneNode(); -} - - -//! render -void CEmptySceneNode::render() -{ - // do nothing -} - - -//! returns the axis aligned bounding box of this node -const core::aabbox3d<f32>& CEmptySceneNode::getBoundingBox() const -{ - return Box; -} - - -//! Creates a clone of this scene node and its children. -ISceneNode* CEmptySceneNode::clone(ISceneNode* newParent, ISceneManager* newManager) -{ - if (!newParent) - newParent = Parent; - if (!newManager) - newManager = SceneManager; - - CEmptySceneNode* nb = new CEmptySceneNode(newParent, - newManager, ID); - - nb->cloneMembers(this, newManager); - nb->Box = Box; - - nb->drop(); - return nb; -} - - -} // end namespace scene -} // end namespace irr diff --git a/irrlicht-1.6/source/Irrlicht/CEmptySceneNode.h b/irrlicht-1.6/source/Irrlicht/CEmptySceneNode.h deleted file mode 100644 index 9f5c33b0f..000000000 --- a/irrlicht-1.6/source/Irrlicht/CEmptySceneNode.h +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_EMPTY_SCENE_NODE_H_INCLUDED__ -#define __C_EMPTY_SCENE_NODE_H_INCLUDED__ - -#include "ISceneNode.h" - -namespace irr -{ -namespace scene -{ - - class CEmptySceneNode : public ISceneNode - { - public: - - //! constructor - CEmptySceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id); - - //! returns the axis aligned bounding box of this node - virtual const core::aabbox3d<f32>& getBoundingBox() const; - - //! This method is called just before the rendering process of the whole scene. - virtual void OnRegisterSceneNode(); - - //! does nothing. - virtual void render(); - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() const { return ESNT_EMPTY; } - - //! Creates a clone of this scene node and its children. - virtual ISceneNode* clone(ISceneNode* newParent=0, ISceneManager* newManager=0); - - private: - - core::aabbox3d<f32> Box; - }; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CFPSCounter.cpp b/irrlicht-1.6/source/Irrlicht/CFPSCounter.cpp deleted file mode 100644 index 2466f75ce..000000000 --- a/irrlicht-1.6/source/Irrlicht/CFPSCounter.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CFPSCounter.h" -#include "irrMath.h" - -namespace irr -{ -namespace video -{ - - -CFPSCounter::CFPSCounter() -: FPS(60), Primitive(0), StartTime(0), FramesCounted(0), - PrimitivesCounted(0), PrimitiveAverage(0), PrimitiveTotal(0) -{ - -} - - -//! returns current fps -s32 CFPSCounter::getFPS() const -{ - return FPS; -} - - -//! returns current primitive count -u32 CFPSCounter::getPrimitive() const -{ - return Primitive; -} - - -//! returns average primitive count of last period -u32 CFPSCounter::getPrimitiveAverage() const -{ - return PrimitiveAverage; -} - - -//! returns accumulated primitive count since start -u32 CFPSCounter::getPrimitiveTotal() const -{ - return PrimitiveTotal; -} - - -//! to be called every frame -void CFPSCounter::registerFrame(u32 now, u32 primitivesDrawn) -{ - ++FramesCounted; - PrimitiveTotal += primitivesDrawn; - PrimitivesCounted += primitivesDrawn; - Primitive = primitivesDrawn; - - const u32 milliseconds = now - StartTime; - - if (milliseconds >= 1500 ) - { - const f32 invMilli = core::reciprocal ( (f32) milliseconds ); - - FPS = core::ceil32 ( ( 1000 * FramesCounted ) * invMilli ); - PrimitiveAverage = core::ceil32 ( ( 1000 * PrimitivesCounted ) * invMilli ); - - FramesCounted = 0; - PrimitivesCounted = 0; - StartTime = now; - } -} - - -} // end namespace video -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CFPSCounter.h b/irrlicht-1.6/source/Irrlicht/CFPSCounter.h deleted file mode 100644 index 358ee6dfb..000000000 --- a/irrlicht-1.6/source/Irrlicht/CFPSCounter.h +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_FPSCOUNTER_H_INCLUDED__ -#define __C_FPSCOUNTER_H_INCLUDED__ - -#include "irrTypes.h" - -namespace irr -{ -namespace video -{ - - -class CFPSCounter -{ -public: - CFPSCounter(); - - //! returns current fps - s32 getFPS() const; - - //! returns primitive count - u32 getPrimitive() const; - - //! returns average primitive count of last period - u32 getPrimitiveAverage() const; - - //! returns accumulated primitive count since start - u32 getPrimitiveTotal() const; - - //! to be called every frame - void registerFrame(u32 now, u32 primitive); - -private: - - s32 FPS; - u32 Primitive; - u32 StartTime; - - u32 FramesCounted; - u32 PrimitivesCounted; - u32 PrimitiveAverage; - u32 PrimitiveTotal; -}; - - -} // end namespace video -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CFileList.cpp b/irrlicht-1.6/source/Irrlicht/CFileList.cpp deleted file mode 100644 index 4a041cec6..000000000 --- a/irrlicht-1.6/source/Irrlicht/CFileList.cpp +++ /dev/null @@ -1,149 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CFileList.h" -#include "IrrCompileConfig.h" -#include "irrArray.h" -#include "coreutil.h" - -#include "os.h" - -namespace irr -{ -namespace io -{ - -static const io::path emptyFileListEntry; - -CFileList::CFileList(const io::path& path, bool ignoreCase, bool ignorePaths) - : IgnorePaths(ignorePaths), IgnoreCase(ignoreCase), Path(path) -{ - #ifdef _DEBUG - setDebugName("CFileList"); - #endif - - Path.replace('\\', '/'); -} - -CFileList::~CFileList() -{ - Files.clear(); -} - -u32 CFileList::getFileCount() const -{ - return Files.size(); -} - -void CFileList::sort() -{ - Files.sort(); -} - -const io::path& CFileList::getFileName(u32 index) const -{ - if (index >= Files.size()) - return emptyFileListEntry; - - return Files[index].Name; -} - - -//! Gets the full name of a file in the list, path included, based on an index. -const io::path& CFileList::getFullFileName(u32 index) const -{ - if (index >= Files.size()) - return emptyFileListEntry; - - return Files[index].FullName; -} - -//! adds a file or folder -u32 CFileList::addItem(const io::path& fullPath, u32 size, bool isDirectory, u32 id) -{ - SFileListEntry entry; - entry.Size = size; - entry.ID = id; - entry.Name = fullPath; - entry.Name.replace('\\', '/'); - entry.IsDirectory = isDirectory; - - // remove trailing slash - if (entry.Name.lastChar() == '/') - { - entry.IsDirectory = true; - entry.Name[entry.Name.size()-1] = 0; - entry.Name.validate(); - } - - if (IgnoreCase) - entry.Name.make_lower(); - - entry.FullName = entry.Name; - - core::deletePathFromFilename(entry.Name); - - if (IgnorePaths) - entry.FullName = entry.Name; - - //os::Printer::log(Path.c_str(), entry.FullName); - - Files.push_back(entry); - - return Files.size() - 1; -} - -bool CFileList::isDirectory(u32 index) const -{ - bool ret = false; - if (index < Files.size()) - ret = Files[index].IsDirectory; - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return ret; -} - -//! Returns the size of a file -u32 CFileList::getFileSize(u32 index) const -{ - return index < Files.size() ? Files[index].IsDirectory : 0; -} - - -//! Searches for a file or folder within the list, returns the index -s32 CFileList::findFile(const io::path& filename, bool isDirectory = false) const -{ - SFileListEntry entry; - entry.FullName = filename; - entry.IsDirectory = isDirectory; - - // swap - entry.FullName.replace('\\', '/'); - - // remove trailing slash - if (entry.Name.lastChar() == '/') - { - entry.IsDirectory = true; - entry.Name[ entry.Name.size()-1] = 0; - entry.Name.validate(); - } - - if (IgnoreCase) - entry.FullName.make_lower(); - - if (IgnorePaths) - core::deletePathFromFilename(entry.FullName); - - return Files.binary_search(entry); -} - -//! Returns the base path of the file list -const io::path& CFileList::getPath() const -{ - return Path; -} - -} // end namespace irr -} // end namespace io - diff --git a/irrlicht-1.6/source/Irrlicht/CFileList.h b/irrlicht-1.6/source/Irrlicht/CFileList.h deleted file mode 100644 index 72007b46d..000000000 --- a/irrlicht-1.6/source/Irrlicht/CFileList.h +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_FILE_LIST_H_INCLUDED__ -#define __C_FILE_LIST_H_INCLUDED__ - -#include "IFileList.h" -#include "irrString.h" -#include "irrArray.h" - - -namespace irr -{ -namespace io -{ - -//! An entry in a list of files, can be a folder or a file. -struct SFileListEntry -{ - //! The name of the file - /** If this is a file or folder in the virtual filesystem and the archive - was created with the ignoreCase flag then the file name will be lower case. */ - io::path Name; - - //! The name of the file including the path - /** If this is a file or folder in the virtual filesystem and the archive was - created with the ignoreDirs flag then it will be the same as Name. */ - io::path FullName; - - //! The size of the file in bytes - u32 Size; - - //! The ID of the file in an archive - /** This is used to link the FileList entry to extra info held about this - file in an archive, which can hold things like data offset and CRC. */ - u32 ID; - - //! True if this is a folder, false if not. - bool IsDirectory; - - //! The == operator is provided so that CFileList can slowly search the list! - bool operator ==(const struct SFileListEntry& other) const - { - if (IsDirectory != other.IsDirectory) - return false; - - return FullName.equals_ignore_case(other.FullName); - } - - //! The < operator is provided so that CFileList can sort and quickly search the list. - bool operator <(const struct SFileListEntry& other) const - { - if (IsDirectory != other.IsDirectory) - return IsDirectory; - - return FullName.lower_ignore_case(other.FullName); - } -}; - - -//! Implementation of a file list -class CFileList : public IFileList -{ -public: - - // CFileList methods - - //! Constructor - /** \param path The path of this file archive */ - CFileList(const io::path& path, bool ignoreCase, bool ignorePaths); - - //! Destructor - virtual ~CFileList(); - - //! Add as a file or folder to the list - /** \param fullPath The file name including path, up to the root of the file list. - \param isDirectory True if this is a directory rather than a file. - \param size The size of the file in bytes. - \param id The ID of the file in the archive which owns it */ - virtual u32 addItem(const io::path& fullPath, u32 size, bool isDirectory, u32 id=0); - - //! Sorts the file list - void sort(); - - // IFileList methods - - //! Returns the amount of files in the filelist. - virtual u32 getFileCount() const; - - //! Gets the name of a file in the list, based on an index. - virtual const io::path& getFileName(u32 index) const; - - //! Gets the full name of a file in the list, path included, based on an index. - virtual const io::path& getFullFileName(u32 index) const; - - //! Returns true if the file is a directory - virtual bool isDirectory(u32 index) const; - - //! Returns the size of a file - virtual u32 getFileSize(u32 index) const; - - //! Searches for a file or folder within the list, returns the index - virtual s32 findFile(const io::path& filename, bool isFolder) const; - - //! Returns the base path of the file list - virtual const io::path& getPath() const; - -protected: - - //! Ignore paths when adding or searching for files - bool IgnorePaths; - - //! Ignore case when adding or searching for files - bool IgnoreCase; - - //! Path to the file list - io::path Path; - - //! List of files - core::array<SFileListEntry> Files; -}; - - -} // end namespace irr -} // end namespace io - - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CFileSystem.cpp b/irrlicht-1.6/source/Irrlicht/CFileSystem.cpp deleted file mode 100644 index 04d246364..000000000 --- a/irrlicht-1.6/source/Irrlicht/CFileSystem.cpp +++ /dev/null @@ -1,790 +0,0 @@ -// Copyright (C) 2002-2009 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" - -#include "CFileSystem.h" -#include "IReadFile.h" -#include "IWriteFile.h" -#include "CZipReader.h" -#include "CMountPointReader.h" -#include "CPakReader.h" -#include "CTarReader.h" -#include "CFileList.h" -#include "CXMLReader.h" -#include "CXMLWriter.h" -#include "stdio.h" -#include "os.h" -#include "CAttributes.h" -#include "CMemoryFile.h" -#include "CLimitReadFile.h" - - -#if defined (_IRR_WINDOWS_API_) - #if !defined ( _WIN32_WCE ) - #include <direct.h> // for _chdir - #endif - #include <io.h> // for _access -#else - #if (defined(_IRR_POSIX_API_) || defined(_IRR_OSX_PLATFORM_)) - #include <stdio.h> - #include <stdlib.h> - #include <string.h> - #include <limits.h> - #include <sys/types.h> - #include <dirent.h> - #include <sys/stat.h> - #include <unistd.h> - #endif -#endif - -namespace irr -{ -namespace io -{ - -//! constructor -CFileSystem::CFileSystem() -{ - #ifdef _DEBUG - setDebugName("CFileSystem"); - #endif - - setFileListSystem(FILESYSTEM_NATIVE); - //! reset current working directory - getWorkingDirectory(); - -#ifdef __IRR_COMPILE_WITH_ZIP_ARCHIVE_LOADER_ - ArchiveLoader.push_back(new CArchiveLoaderZIP(this)); -#endif - -#ifdef __IRR_COMPILE_WITH_MOUNT_ARCHIVE_LOADER_ - ArchiveLoader.push_back(new CArchiveLoaderMount(this)); -#endif - -#ifdef __IRR_COMPILE_WITH_PAK_ARCHIVE_LOADER_ - ArchiveLoader.push_back(new CArchiveLoaderPAK(this)); -#endif - -#ifdef __IRR_COMPILE_WITH_TAR_ARCHIVE_LOADER_ - ArchiveLoader.push_back(new CArchiveLoaderTAR(this)); -#endif -} - - -//! destructor -CFileSystem::~CFileSystem() -{ - u32 i; - - for ( i=0; i < FileArchives.size(); ++i) - { - FileArchives[i]->drop(); - } - - for ( i=0; i < ArchiveLoader.size(); ++i) - { - ArchiveLoader[i]->drop(); - } -} - - -//! opens a file for read access -IReadFile* CFileSystem::createAndOpenFile(const io::path& filename) -{ - IReadFile* file = 0; - u32 i; - - for (i=0; i< FileArchives.size(); ++i) - { - file = FileArchives[i]->createAndOpenFile(filename); - if (file) - return file; - } - - // Create the file using an absolute path so that it matches - // the scheme used by CNullDriver::getTexture(). - return createReadFile(getAbsolutePath(filename)); -} - - -//! Creates an IReadFile interface for treating memory like a file. -IReadFile* CFileSystem::createMemoryReadFile(void* memory, s32 len, - const io::path& fileName, bool deleteMemoryWhenDropped) -{ - if (!memory) - return 0; - else - return new CMemoryFile(memory, len, fileName, deleteMemoryWhenDropped); -} - - -//! Creates an IReadFile interface for reading files inside files -IReadFile* CFileSystem::createLimitReadFile(const io::path& fileName, - IReadFile* alreadyOpenedFile, long pos, long areaSize) -{ - if (!alreadyOpenedFile) - return 0; - else - return new CLimitReadFile(alreadyOpenedFile, pos, areaSize, fileName); -} - - -//! Creates an IReadFile interface for treating memory like a file. -IWriteFile* CFileSystem::createMemoryWriteFile(void* memory, s32 len, - const io::path& fileName, bool deleteMemoryWhenDropped) -{ - if (!memory) - return 0; - else - return new CMemoryFile(memory, len, fileName, deleteMemoryWhenDropped); -} - - -//! Opens a file for write access. -IWriteFile* CFileSystem::createAndWriteFile(const io::path& filename, bool append) -{ - return createWriteFile(filename, append); -} - - -//! Adds an external archive loader to the engine. -void CFileSystem::addArchiveLoader(IArchiveLoader* loader) -{ - if (!loader) - return; - - loader->grab(); - ArchiveLoader.push_back(loader); -} - - -//! move the hirarchy of the filesystem. moves sourceIndex relative up or down -bool CFileSystem::moveFileArchive(u32 sourceIndex, s32 relative) -{ - bool r = false; - const s32 dest = (s32) sourceIndex + relative; - const s32 dir = relative < 0 ? -1 : 1; - const s32 sourceEnd = ((s32) FileArchives.size() ) - 1; - IFileArchive *t; - - for (s32 s = (s32) sourceIndex;s != dest; s += dir) - { - if (s < 0 || s > sourceEnd || s + dir < 0 || s + dir > sourceEnd) - continue; - - t = FileArchives[s + dir]; - FileArchives[s + dir] = FileArchives[s]; - FileArchives[s] = t; - r = true; - } - return r; -} - - -//! Adds an archive to the file system. -bool CFileSystem::addFileArchive(const io::path& filename, bool ignoreCase, - bool ignorePaths, E_FILE_ARCHIVE_TYPE archiveType) -{ - IFileArchive* archive = 0; - bool ret = false; - u32 i; - - // check if the archive was already loaded - for (i = 0; i < FileArchives.size(); ++i) - { - if (filename == FileArchives[i]->getFileList()->getPath()) - return true; - } - - // do we know what type it should be? - if (archiveType == EFAT_UNKNOWN || archiveType == EFAT_FOLDER) - { - // try to load archive based on file name - for (i = 0; i < ArchiveLoader.size(); ++i) - { - if (ArchiveLoader[i]->isALoadableFileFormat(filename)) - { - archive = ArchiveLoader[i]->createArchive(filename, ignoreCase, ignorePaths); - if (archive) - break; - } - } - - // try to load archive based on content - if (!archive) - { - io::IReadFile* file = createAndOpenFile(filename); - if (file) - { - for (i = 0; i < ArchiveLoader.size(); ++i) - { - file->seek(0); - if (ArchiveLoader[i]->isALoadableFileFormat(file)) - { - file->seek(0); - archive = ArchiveLoader[i]->createArchive(file, ignoreCase, ignorePaths); - if (archive) - break; - } - } - file->drop(); - } - } - } - else - { - // try to open archive based on archive loader type - - io::IReadFile* file = 0; - - for (i = 0; i < ArchiveLoader.size(); ++i) - { - if (ArchiveLoader[i]->isALoadableFileFormat(archiveType)) - { - // attempt to open file - if (!file) - file = createAndOpenFile(filename); - - // is the file open? - if (file) - { - // attempt to open archive - file->seek(0); - if (ArchiveLoader[i]->isALoadableFileFormat(file)) - { - file->seek(0); - archive = ArchiveLoader[i]->createArchive(file, ignoreCase, ignorePaths); - if (archive) - break; - } - } - else - { - // couldn't open file - break; - } - } - } - - // if open, close the file - if (file) - file->drop(); - } - - if (archive) - { - FileArchives.push_back(archive); - ret = true; - } - else - { - os::Printer::log("Could not create archive for", filename, ELL_ERROR); - } - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return ret; -} - - -//! removes an archive from the file system. -bool CFileSystem::removeFileArchive(u32 index) -{ - bool ret = false; - if (index < FileArchives.size()) - { - FileArchives[index]->drop(); - FileArchives.erase(index); - ret = true; - } - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return ret; -} - - -//! removes an archive from the file system. -bool CFileSystem::removeFileArchive(const io::path& filename) -{ - for (u32 i=0; i < FileArchives.size(); ++i) - { - if (filename == FileArchives[i]->getFileList()->getPath()) - return removeFileArchive(i); - } - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; -} - - -//! gets an archive -u32 CFileSystem::getFileArchiveCount() const -{ - return FileArchives.size(); -} - - -IFileArchive* CFileSystem::getFileArchive(u32 index) -{ - return index < getFileArchiveCount() ? FileArchives[index] : 0; -} - - -//! Returns the string of the current working directory -const io::path& CFileSystem::getWorkingDirectory() -{ - EFileSystemType type = FileSystemType; - - if (type != FILESYSTEM_NATIVE) - { - type = FILESYSTEM_VIRTUAL; - } - else - { - #if defined(_IRR_WINDOWS_CE_PLATFORM_) - - #elif defined(_IRR_WINDOWS_API_) - #if defined(_IRR_WCHAR_FILESYSTEM ) - wchar_t tmp[_MAX_PATH]; - _wgetcwd(tmp, _MAX_PATH); - #else - c8 tmp[_MAX_PATH]; - _getcwd(tmp, _MAX_PATH); - #endif - WorkingDirectory[FILESYSTEM_NATIVE] = tmp; - #endif - - #if (defined(_IRR_POSIX_API_) || defined(_IRR_OSX_PLATFORM_)) - - //! getting the CWD is rather complex as we do not know the size - //! so try it until the call was successful - //! Note that neither the first nor the second parameter may be 0 according to POSIX - - #if defined(_IRR_WCHAR_FILESYSTEM ) - u32 pathSize=256; - wchar_t *tmpPath = new wchar_t[pathSize]; - while ((pathSize < (1<<16)) && !(wgetcwd(tmpPath,pathSize))) - { - delete [] tmpPath; - pathSize *= 2; - tmpPath = new char[pathSize]; - } - if (tmpPath) - { - WorkingDirectory[FILESYSTEM_NATIVE] = tmpPath; - delete [] tmpPath; - } - #else - u32 pathSize=256; - char *tmpPath = new char[pathSize]; - while ((pathSize < (1<<16)) && !(getcwd(tmpPath,pathSize))) - { - delete [] tmpPath; - pathSize *= 2; - tmpPath = new char[pathSize]; - } - if (tmpPath) - { - WorkingDirectory[FILESYSTEM_NATIVE] = tmpPath; - delete [] tmpPath; - } - #endif - #endif - - WorkingDirectory[type].validate(); - } - - return WorkingDirectory[type]; -} - - -//! Changes the current Working Directory to the given string. -bool CFileSystem::changeWorkingDirectoryTo(const io::path& newDirectory) -{ - bool success=false; - - if (FileSystemType != FILESYSTEM_NATIVE) - { - WorkingDirectory[FILESYSTEM_VIRTUAL].append(newDirectory); - flattenFilename(WorkingDirectory[FILESYSTEM_VIRTUAL], ""); - success = 1; - } - else - { - WorkingDirectory[FILESYSTEM_NATIVE] = newDirectory; - -#if defined(_IRR_WINDOWS_CE_PLATFORM_) - success = true; -#elif defined(_MSC_VER) - #if defined(_IRR_WCHAR_FILESYSTEM) - success=(_wchdir(newDirectory.c_str()) == 0); - #else - success=(_chdir(newDirectory.c_str()) == 0); - #endif -#else - success=(chdir(newDirectory.c_str()) == 0); -#endif - } - - return success; -} - - -io::path CFileSystem::getAbsolutePath(const io::path& filename) const -{ - fschar_t *p=0; - -#if defined(_IRR_WINDOWS_CE_PLATFORM_) - return filename; -#elif defined(_IRR_WINDOWS_API_) - - #if defined(_IRR_WCHAR_FILESYSTEM ) - c16 fpath[_MAX_PATH]; - p = _wfullpath(fpath, filename.c_str(), _MAX_PATH); - #else - c8 fpath[_MAX_PATH]; - p = _fullpath(fpath, filename.c_str(), _MAX_PATH); - #endif - -#elif (defined(_IRR_POSIX_API_) || defined(_IRR_OSX_PLATFORM_)) - c8 fpath[4096]; - fpath[0]=0; - p = realpath(filename.c_str(), fpath); - if (!p) - { - // content in fpath is undefined at this point - if (!fpath[0]) // seems like fpath wasn't altered - { - // at least remove a ./ prefix - if ('.'==filename[0] && '/'==filename[1]) - return filename.subString(2, filename.size()-2); - else - return filename; - } - else - return io::path(fpath); - } - -#endif - - return io::path(p); -} - - -//! returns the directory part of a filename, i.e. all until the first -//! slash or backslash, excluding it. If no directory path is prefixed, a '.' -//! is returned. -io::path CFileSystem::getFileDir(const io::path& filename) const -{ - // find last forward or backslash - s32 lastSlash = filename.findLast('/'); - const s32 lastBackSlash = filename.findLast('\\'); - lastSlash = lastSlash > lastBackSlash ? lastSlash : lastBackSlash; - - if ((u32)lastSlash < filename.size()) - return filename.subString(0, lastSlash); - else - return "."; -} - - -//! returns the base part of a filename, i.e. all except for the directory -//! part. If no directory path is prefixed, the full name is returned. -io::path CFileSystem::getFileBasename(const io::path& filename, bool keepExtension) const -{ - // find last forward or backslash - s32 lastSlash = filename.findLast('/'); - const s32 lastBackSlash = filename.findLast('\\'); - lastSlash = core::max_(lastSlash, lastBackSlash); - - // get number of chars after last dot - s32 end = 0; - if (!keepExtension) - { - // take care to search only after last slash to check only for - // dots in the filename - end = filename.findLast('.'); - if (end == -1 || end < lastSlash) - end=0; - else - end = filename.size()-end; - } - - if ((u32)lastSlash < filename.size()) - return filename.subString(lastSlash+1, filename.size()-lastSlash-1-end); - else if (end != 0) - return filename.subString(0, filename.size()-end); - else - return filename; -} - - -//! flaten a path and file name for example: "/you/me/../." becomes "/you" -io::path& CFileSystem::flattenFilename(io::path& directory, const io::path& root) const -{ - directory.replace('\\', '/'); - if (directory.lastChar() != '/') - directory.append('/'); - - io::path dir; - io::path subdir; - - s32 lastpos = 0; - s32 pos = 0; - - while ((pos = directory.findNext('/', lastpos)) >= 0) - { - subdir = directory.subString(lastpos, pos - lastpos + 1); - - if (subdir == "../") - { - deletePathFromPath(dir, 2); - } - else if (subdir == "/") - { - dir = root; - } - else if (subdir != "./" ) - { - dir.append(subdir); - } - - lastpos = pos + 1; - } - directory = dir; - return directory; -} - - -//! Creates a list of files and directories in the current working directory -EFileSystemType CFileSystem::setFileListSystem(EFileSystemType listType) -{ - EFileSystemType current = FileSystemType; - FileSystemType = listType; - return current; -} - - -//! Creates a list of files and directories in the current working directory -IFileList* CFileSystem::createFileList() -{ - CFileList* r = 0; - io::path Path = getWorkingDirectory(); - Path.replace('\\', '/'); - if (Path.lastChar() != '/') - Path.append('/'); - - //! Construct from native filesystem - if (FileSystemType == FILESYSTEM_NATIVE) - { - io::path fullPath; - // -------------------------------------------- - //! Windows version - #ifdef _IRR_WINDOWS_API_ - #if !defined ( _WIN32_WCE ) - - r = new CFileList(Path, true, false); - - struct _finddata_t c_file; - long hFile; - - if( (hFile = _findfirst( "*", &c_file )) != -1L ) - { - do - { - fullPath = Path + c_file.name; - - r->addItem(fullPath, c_file.size, (_A_SUBDIR & c_file.attrib) != 0, 0); - } - while( _findnext( hFile, &c_file ) == 0 ); - - _findclose( hFile ); - } - #endif - - //TODO add drives - //entry.Name = "E:\\"; - //entry.isDirectory = true; - //Files.push_back(entry); - #endif - - // -------------------------------------------- - //! Linux version - #if (defined(_IRR_POSIX_API_) || defined(_IRR_OSX_PLATFORM_)) - - - r = new CFileList(Path, false, false); - - r->addItem(Path + "..", 0, true, 0); - - //! We use the POSIX compliant methods instead of scandir - DIR* dirHandle=opendir(Path.c_str()); - if (dirHandle) - { - struct dirent *dirEntry; - while ((dirEntry=readdir(dirHandle))) - { - u32 size = 0; - bool isDirectory = false; - fullPath = Path + dirEntry->d_name; - - if((strcmp(dirEntry->d_name, ".")==0) || - (strcmp(dirEntry->d_name, "..")==0)) - { - continue; - } - struct stat buf; - if (stat(dirEntry->d_name, &buf)==0) - { - size = buf.st_size; - isDirectory = S_ISDIR(buf.st_mode); - } - #if !defined(_IRR_SOLARIS_PLATFORM_) && !defined(__CYGWIN__) - // only available on some systems - else - { - isDirectory = dirEntry->d_type == DT_DIR; - } - #endif - - r->addItem(fullPath, size, isDirectory, 0); - } - closedir(dirHandle); - } - #endif - } - else - { - //! create file list for the virtual filesystem - r = new CFileList(Path, false, false); - - //! add relative navigation - SFileListEntry e2; - SFileListEntry e3; - - //! PWD - r->addItem(Path + ".", 0, true, 0); - - //! parent - r->addItem(Path + "..", 0, true, 0); - - //! merge archives - for (u32 i=0; i < FileArchives.size(); ++i) - { - const IFileList *merge = FileArchives[i]->getFileList(); - - for (u32 j=0; j < merge->getFileCount(); ++j) - { - if (core::isInSameDirectory(Path, merge->getFullFileName(j)) == 0) - { - io::path fullPath = merge->getFullFileName(j); - r->addItem(fullPath, merge->getFileSize(j), merge->isDirectory(j), 0); - } - } - } - - } - - if (r) - r->sort(); - return r; -} - -//! determines if a file exists and would be able to be opened. -bool CFileSystem::existFile(const io::path& filename) const -{ - for (u32 i=0; i < FileArchives.size(); ++i) - if (FileArchives[i]->getFileList()->findFile(filename)!=-1) - return true; - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; -#if defined(_IRR_WCHAR_FILESYSTEM) - return (_waccess(filename.c_str(), 0) != -1); -#elif defined(_MSC_VER) - return (_access(filename.c_str(), 0) != -1); -#else - return (access(filename.c_str(), F_OK) != -1); -#endif -} - - -//! Creates a XML Reader from a file. -IXMLReader* CFileSystem::createXMLReader(const io::path& filename) -{ - IReadFile* file = createAndOpenFile(filename); - if (!file) - return 0; - - IXMLReader* reader = createXMLReader(file); - file->drop(); - return reader; -} - - -//! Creates a XML Reader from a file. -IXMLReader* CFileSystem::createXMLReader(IReadFile* file) -{ - if (!file) - return 0; - - return createIXMLReader(file); -} - - -//! Creates a XML Reader from a file. -IXMLReaderUTF8* CFileSystem::createXMLReaderUTF8(const io::path& filename) -{ - IReadFile* file = createAndOpenFile(filename); - if (!file) - return 0; - - IXMLReaderUTF8* reader = createIXMLReaderUTF8(file); - file->drop(); - return reader; -} - - -//! Creates a XML Reader from a file. -IXMLReaderUTF8* CFileSystem::createXMLReaderUTF8(IReadFile* file) -{ - if (!file) - return 0; - - return createIXMLReaderUTF8(file); -} - - -//! Creates a XML Writer from a file. -IXMLWriter* CFileSystem::createXMLWriter(const io::path& filename) -{ - IWriteFile* file = createAndWriteFile(filename); - IXMLWriter* writer = createXMLWriter(file); - file->drop(); - return writer; -} - - -//! Creates a XML Writer from a file. -IXMLWriter* CFileSystem::createXMLWriter(IWriteFile* file) -{ - return new CXMLWriter(file); -} - - -//! creates a filesystem which is able to open files from the ordinary file system, -//! and out of zipfiles, which are able to be added to the filesystem. -IFileSystem* createFileSystem() -{ - return new CFileSystem(); -} - - -//! Creates a new empty collection of attributes, usable for serialization and more. -IAttributes* CFileSystem::createEmptyAttributes(video::IVideoDriver* driver) -{ - return new CAttributes(driver); -} - - -} // end namespace irr -} // end namespace io - diff --git a/irrlicht-1.6/source/Irrlicht/CFileSystem.h b/irrlicht-1.6/source/Irrlicht/CFileSystem.h deleted file mode 100644 index 48f8e15f1..000000000 --- a/irrlicht-1.6/source/Irrlicht/CFileSystem.h +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_FILE_SYSTEM_H_INCLUDED__ -#define __C_FILE_SYSTEM_H_INCLUDED__ - -#include "IFileSystem.h" -#include "irrArray.h" - -namespace irr -{ -namespace io -{ - - class CZipReader; - class CPakReader; - class CMountPointReader; - -/*! - FileSystem which uses normal files and one zipfile -*/ -class CFileSystem : public IFileSystem -{ -public: - - //! constructor - CFileSystem(); - - //! destructor - virtual ~CFileSystem(); - - //! opens a file for read access - virtual IReadFile* createAndOpenFile(const io::path& filename); - - //! Creates an IReadFile interface for accessing memory like a file. - virtual IReadFile* createMemoryReadFile(void* memory, s32 len, const io::path& fileName, bool deleteMemoryWhenDropped = false); - - //! Creates an IReadFile interface for accessing files inside files - virtual IReadFile* createLimitReadFile(const io::path& fileName, IReadFile* alreadyOpenedFile, long pos, long areaSize); - - //! Creates an IWriteFile interface for accessing memory like a file. - virtual IWriteFile* createMemoryWriteFile(void* memory, s32 len, const io::path& fileName, bool deleteMemoryWhenDropped=false); - - //! Opens a file for write access. - virtual IWriteFile* createAndWriteFile(const io::path& filename, bool append=false); - - //! Adds an archive to the file system. - virtual bool addFileArchive(const io::path& filename, bool ignoreCase = true, - bool ignorePaths = true, E_FILE_ARCHIVE_TYPE archiveType = EFAT_UNKNOWN); - - //! move the hirarchy of the filesystem. moves sourceIndex relative up or down - virtual bool moveFileArchive( u32 sourceIndex, s32 relative ); - - //! Adds an external archive loader to the engine. - virtual void addArchiveLoader(IArchiveLoader* loader); - - //! gets the file archive count - virtual u32 getFileArchiveCount() const; - - //! gets an archive - virtual IFileArchive* getFileArchive(u32 index); - - //! removes an archive from the file system. - virtual bool removeFileArchive(u32 index); - - //! removes an archive from the file system. - virtual bool removeFileArchive(const io::path& filename); - - //! Returns the string of the current working directory - virtual const io::path& getWorkingDirectory(); - - //! Changes the current Working Directory to the string given. - //! The string is operating system dependent. Under Windows it will look - //! like this: "drive:\directory\sudirectory\" - virtual bool changeWorkingDirectoryTo(const io::path& newDirectory); - - //! Converts a relative path to an absolute (unique) path, resolving symbolic links - virtual io::path getAbsolutePath(const io::path& filename) const; - - //! Returns the directory a file is located in. - /** \param filename: The file to get the directory from */ - virtual io::path getFileDir(const io::path& filename) const; - - //! Returns the base part of a filename, i.e. the name without the directory - //! part. If no directory is prefixed, the full name is returned. - /** \param filename: The file to get the basename from */ - virtual io::path getFileBasename(const io::path& filename, bool keepExtension=true) const; - - //! flatten a path and file name for example: "/you/me/../." becomes "/you" - virtual io::path& flattenFilename( io::path& directory, const io::path& root = "/" ) const; - - virtual EFileSystemType setFileListSystem(EFileSystemType listType); - - //! Creates a list of files and directories in the current working directory - //! and returns it. - virtual IFileList* createFileList(); - - //! determines if a file exists and would be able to be opened. - virtual bool existFile(const io::path& filename) const; - - //! Creates a XML Reader from a file. - virtual IXMLReader* createXMLReader(const io::path& filename); - - //! Creates a XML Reader from a file. - virtual IXMLReader* createXMLReader(IReadFile* file); - - //! Creates a XML Reader from a file. - virtual IXMLReaderUTF8* createXMLReaderUTF8(const io::path& filename); - - //! Creates a XML Reader from a file. - virtual IXMLReaderUTF8* createXMLReaderUTF8(IReadFile* file); - - //! Creates a XML Writer from a file. - virtual IXMLWriter* createXMLWriter(const io::path& filename); - - //! Creates a XML Writer from a file. - virtual IXMLWriter* createXMLWriter(IWriteFile* file); - - //! Creates a new empty collection of attributes, usable for serialization and more. - virtual IAttributes* createEmptyAttributes(video::IVideoDriver* driver); - -private: - - //! Currently used FileSystemType - EFileSystemType FileSystemType; - //! WorkingDirectory for Native and Virtual filesystems - io::path WorkingDirectory [2]; - //! currently attached ArchiveLoaders - core::array<IArchiveLoader*> ArchiveLoader; - //! currently attached Archives - core::array<IFileArchive*> FileArchives; -}; - - -} // end namespace irr -} // end namespace io - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CGUIButton.cpp b/irrlicht-1.6/source/Irrlicht/CGUIButton.cpp deleted file mode 100644 index b1c0912f2..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIButton.cpp +++ /dev/null @@ -1,486 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUIButton.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUISkin.h" -#include "IGUIEnvironment.h" -#include "IVideoDriver.h" -#include "IGUIFont.h" -#include "os.h" - -namespace irr -{ -namespace gui -{ - -//! constructor -CGUIButton::CGUIButton(IGUIEnvironment* environment, IGUIElement* parent, - s32 id, core::rect<s32> rectangle, bool noclip) -: IGUIButton(environment, parent, id, rectangle), - SpriteBank(0), OverrideFont(0), Image(0), PressedImage(0), - ClickTime(0), IsPushButton(false), Pressed(false), - UseAlphaChannel(false), DrawBorder(true), ScaleImage(false) -{ - #ifdef _DEBUG - setDebugName("CGUIButton"); - #endif - setNotClipped(noclip); - - // Initialize the sprites. - for (u32 i=0; i<EGBS_COUNT; ++i) - ButtonSprites[i].Index = -1; - - // This element can be tabbed. - setTabStop(true); - setTabOrder(-1); -} - - -//! destructor -CGUIButton::~CGUIButton() -{ - if (OverrideFont) - OverrideFont->drop(); - - if (Image) - Image->drop(); - - if (PressedImage) - PressedImage->drop(); - - if (SpriteBank) - SpriteBank->drop(); -} - - -//! Sets if the images should be scaled to fit the button -void CGUIButton::setScaleImage(bool scaleImage) -{ - ScaleImage = scaleImage; -} - - -//! Returns whether the button scale the used images -bool CGUIButton::isScalingImage() const -{ - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return ScaleImage; -} - - -//! Sets if the button should use the skin to draw its border -void CGUIButton::setDrawBorder(bool border) -{ - DrawBorder = border; -} - - -void CGUIButton::setSpriteBank(IGUISpriteBank* sprites) -{ - if (sprites) - sprites->grab(); - - if (SpriteBank) - SpriteBank->drop(); - - SpriteBank = sprites; -} - - -void CGUIButton::setSprite(EGUI_BUTTON_STATE state, s32 index, video::SColor color, bool loop) -{ - if (SpriteBank) - { - ButtonSprites[(u32)state].Index = index; - ButtonSprites[(u32)state].Color = color; - ButtonSprites[(u32)state].Loop = loop; - } - else - { - ButtonSprites[(u32)state].Index = -1; - } -} - - -//! called if an event happened. -bool CGUIButton::OnEvent(const SEvent& event) -{ - if (!IsEnabled) - return IGUIElement::OnEvent(event); - - switch(event.EventType) - { - case EET_KEY_INPUT_EVENT: - if (event.KeyInput.PressedDown && - (event.KeyInput.Key == KEY_RETURN || event.KeyInput.Key == KEY_SPACE)) - { - if (!IsPushButton) - setPressed(true); - else - setPressed(!Pressed); - - return true; - } - if (Pressed && !IsPushButton && event.KeyInput.PressedDown && event.KeyInput.Key == KEY_ESCAPE) - { - setPressed(false); - return true; - } - else - if (!event.KeyInput.PressedDown && Pressed && - (event.KeyInput.Key == KEY_RETURN || event.KeyInput.Key == KEY_SPACE)) - { - //Environment->removeFocus(this); - - if (!IsPushButton) - setPressed(false); - - if (Parent) - { - SEvent newEvent; - newEvent.EventType = EET_GUI_EVENT; - newEvent.GUIEvent.Caller = this; - newEvent.GUIEvent.Element = 0; - newEvent.GUIEvent.EventType = EGET_BUTTON_CLICKED; - Parent->OnEvent(newEvent); - } - return true; - } - break; - case EET_GUI_EVENT: - if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST) - { - if (event.GUIEvent.Caller == this && !IsPushButton) - setPressed(false); - } - break; - case EET_MOUSE_INPUT_EVENT: - if (event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN) - { - if (Environment->hasFocus(this) && - !AbsoluteClippingRect.isPointInside(core::position2d<s32>(event.MouseInput.X, event.MouseInput.Y))) - { - Environment->removeFocus(this); - return false; - } - - if (!IsPushButton) - setPressed(true); - - Environment->setFocus(this); - return true; - } - else - if (event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP) - { - bool wasPressed = Pressed; - //Environment->removeFocus(this); - - if ( !AbsoluteClippingRect.isPointInside( core::position2d<s32>(event.MouseInput.X, event.MouseInput.Y ) ) ) - { - if (!IsPushButton) - setPressed(false); - return true; - } - - if (!IsPushButton) - setPressed(false); - else - { - setPressed(!Pressed); - } - - if ((!IsPushButton && wasPressed && Parent) || - (IsPushButton && wasPressed != Pressed)) - { - SEvent newEvent; - newEvent.EventType = EET_GUI_EVENT; - newEvent.GUIEvent.Caller = this; - newEvent.GUIEvent.Element = 0; - newEvent.GUIEvent.EventType = EGET_BUTTON_CLICKED; - Parent->OnEvent(newEvent); - } - - return true; - } - break; - default: - break; - } - - return Parent ? Parent->OnEvent(event) : false; -} - - -//! draws the element and its children -void CGUIButton::draw() -{ - if (!IsVisible) - return; - - IGUISkin* skin = Environment->getSkin(); - video::IVideoDriver* driver = Environment->getVideoDriver(); - - // todo: move sprite up and text down if the pressed state has a sprite - // draw sprites for focused and mouse-over - const core::position2di spritePos = AbsoluteRect.getCenter(); - - if (!Pressed) - { - if (DrawBorder) - skin->draw3DButtonPaneStandard(this, AbsoluteRect, &AbsoluteClippingRect); - - if (Image) - { - core::position2d<s32> pos = spritePos; - pos.X -= ImageRect.getWidth() / 2; - pos.Y -= ImageRect.getHeight() / 2; - - driver->draw2DImage(Image, - ScaleImage? AbsoluteRect : - core::recti(pos, ImageRect.getSize()), - ImageRect, &AbsoluteClippingRect, - 0, UseAlphaChannel); - } - if (SpriteBank && ButtonSprites[EGBS_BUTTON_UP].Index != -1) - { - // draw pressed sprite - SpriteBank->draw2DSprite(ButtonSprites[EGBS_BUTTON_UP].Index, spritePos, - &AbsoluteClippingRect, ButtonSprites[EGBS_BUTTON_UP].Color, ClickTime, os::Timer::getTime(), - ButtonSprites[EGBS_BUTTON_UP].Loop, true); - } - } - else - { - if (DrawBorder) - skin->draw3DButtonPanePressed(this, AbsoluteRect, &AbsoluteClippingRect); - - if (PressedImage) - { - core::position2d<s32> pos = spritePos; - pos.X -= PressedImageRect.getWidth() / 2; - pos.Y -= PressedImageRect.getHeight() / 2; - // patch by Alan Tyndall/Jonas Petersen - if (Image == PressedImage && PressedImageRect == ImageRect) - { - pos.X += 1; - pos.Y += 1; - } - driver->draw2DImage(PressedImage, - ScaleImage? AbsoluteRect : - core::recti(pos, PressedImageRect.getSize()), - PressedImageRect, &AbsoluteClippingRect, - 0, UseAlphaChannel); - } - - if (SpriteBank && ButtonSprites[EGBS_BUTTON_DOWN].Index != -1) - { - // draw sprite - SpriteBank->draw2DSprite(ButtonSprites[EGBS_BUTTON_DOWN].Index, spritePos, - &AbsoluteClippingRect, ButtonSprites[EGBS_BUTTON_DOWN].Color, ClickTime, os::Timer::getTime(), - ButtonSprites[EGBS_BUTTON_DOWN].Loop, true); - } - } - - if (Text.size()) - { - IGUIFont* font = OverrideFont; - if (!OverrideFont) - font = skin->getFont(EGDF_BUTTON); - - core::rect<s32> rect = AbsoluteRect; - if (Pressed) - rect.UpperLeftCorner.Y += 2; - - if (font) - font->draw(Text.c_str(), rect, - skin->getColor(IsEnabled ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT), - true, true, &AbsoluteClippingRect); - } - - IGUIElement::draw(); -} - - -//! sets another skin independent font. if this is set to zero, the button uses the font of the skin. -void CGUIButton::setOverrideFont(IGUIFont* font) -{ - if (OverrideFont == font) - return; - - if (OverrideFont) - OverrideFont->drop(); - - OverrideFont = font; - - if (OverrideFont) - OverrideFont->grab(); -} - - -//! Sets an image which should be displayed on the button when it is in normal state. -void CGUIButton::setImage(video::ITexture* image) -{ - if (image) - image->grab(); - if (Image) - Image->drop(); - - Image = image; - if (image) - ImageRect = core::rect<s32>(core::position2d<s32>(0,0), image->getOriginalSize()); - - if (!PressedImage) - setPressedImage(Image); -} - - -//! Sets the image which should be displayed on the button when it is in its normal state. -void CGUIButton::setImage(video::ITexture* image, const core::rect<s32>& pos) -{ - setImage(image); - ImageRect = pos; -} - - -//! Sets an image which should be displayed on the button when it is in pressed state. -void CGUIButton::setPressedImage(video::ITexture* image) -{ - if (image) - image->grab(); - - if (PressedImage) - PressedImage->drop(); - - PressedImage = image; - if (image) - PressedImageRect = core::rect<s32>(core::position2d<s32>(0,0), image->getOriginalSize()); -} - - -//! Sets the image which should be displayed on the button when it is in its pressed state. -void CGUIButton::setPressedImage(video::ITexture* image, const core::rect<s32>& pos) -{ - setPressedImage(image); - PressedImageRect = pos; -} - - -//! Sets if the button should behave like a push button. Which means it -//! can be in two states: Normal or Pressed. With a click on the button, -//! the user can change the state of the button. -void CGUIButton::setIsPushButton(bool isPushButton) -{ - IsPushButton = isPushButton; -} - - -//! Returns if the button is currently pressed -bool CGUIButton::isPressed() const -{ - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return Pressed; -} - - -//! Sets the pressed state of the button if this is a pushbutton -void CGUIButton::setPressed(bool pressed) -{ - if (Pressed != pressed) - { - ClickTime = os::Timer::getTime(); - Pressed = pressed; - } -} - - -//! Returns whether the button is a push button -bool CGUIButton::isPushButton() const -{ - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return IsPushButton; -} - - -//! Sets if the alpha channel should be used for drawing images on the button (default is false) -void CGUIButton::setUseAlphaChannel(bool useAlphaChannel) -{ - UseAlphaChannel = useAlphaChannel; -} - - -//! Returns if the alpha channel should be used for drawing images on the button -bool CGUIButton::isAlphaChannelUsed() const -{ - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return UseAlphaChannel; -} - - -bool CGUIButton::isDrawingBorder() const -{ - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return DrawBorder; -} - - -//! Writes attributes of the element. -void CGUIButton::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const -{ - IGUIButton::serializeAttributes(out,options); - - out->addBool ("PushButton", IsPushButton ); - if (IsPushButton) - out->addBool("Pressed", Pressed); - - out->addTexture ("Image", Image); - out->addRect ("ImageRect", ImageRect); - out->addTexture ("PressedImage", PressedImage); - out->addRect ("PressedImageRect", PressedImageRect); - - out->addBool ("UseAlphaChannel", isAlphaChannelUsed()); - out->addBool ("Border", isDrawingBorder()); - out->addBool ("ScaleImage", isScalingImage()); - - // out->addString ("OverrideFont", OverrideFont); -} - - -//! Reads attributes of the element -void CGUIButton::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) -{ - IGUIButton::deserializeAttributes(in,options); - - IsPushButton = in->getAttributeAsBool("PushButton"); - Pressed = IsPushButton ? in->getAttributeAsBool("Pressed") : false; - - core::rect<s32> rec = in->getAttributeAsRect("ImageRect"); - if (rec.isValid()) - setImage( in->getAttributeAsTexture("Image"), rec); - else - setImage( in->getAttributeAsTexture("Image") ); - - rec = in->getAttributeAsRect("PressedImageRect"); - if (rec.isValid()) - setPressedImage( in->getAttributeAsTexture("PressedImage"), rec); - else - setPressedImage( in->getAttributeAsTexture("PressedImage") ); - - setDrawBorder(in->getAttributeAsBool("Border")); - setUseAlphaChannel(in->getAttributeAsBool("UseAlphaChannel")); - setScaleImage(in->getAttributeAsBool("ScaleImage")); - - // setOverrideFont(in->getAttributeAsString("OverrideFont")); - - updateAbsolutePosition(); -} - - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - diff --git a/irrlicht-1.6/source/Irrlicht/CGUIButton.h b/irrlicht-1.6/source/Irrlicht/CGUIButton.h deleted file mode 100644 index 2a1119cf2..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIButton.h +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_BUTTON_H_INCLUDED__ -#define __C_GUI_BUTTON_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUIButton.h" -#include "IGUISpriteBank.h" -#include "SColor.h" - -namespace irr -{ -namespace gui -{ - - class CGUIButton : public IGUIButton - { - public: - - //! constructor - CGUIButton(IGUIEnvironment* environment, IGUIElement* parent, - s32 id, core::rect<s32> rectangle, bool noclip=false); - - //! destructor - virtual ~CGUIButton(); - - //! called if an event happened. - virtual bool OnEvent(const SEvent& event); - - //! draws the element and its children - virtual void draw(); - - //! sets another skin independent font. if this is set to zero, the button uses the font of the skin. - virtual void setOverrideFont(IGUIFont* font=0); - - //! Sets an image which should be displayed on the button when it is in normal state. - virtual void setImage(video::ITexture* image=0); - - //! Sets an image which should be displayed on the button when it is in normal state. - virtual void setImage(video::ITexture* image, const core::rect<s32>& pos); - - //! Sets an image which should be displayed on the button when it is in pressed state. - virtual void setPressedImage(video::ITexture* image=0); - - //! Sets an image which should be displayed on the button when it is in pressed state. - virtual void setPressedImage(video::ITexture* image, const core::rect<s32>& pos); - - //! Sets the sprite bank used by the button - virtual void setSpriteBank(IGUISpriteBank* bank=0); - - //! Sets the animated sprite for a specific button state - /** \param index: Number of the sprite within the sprite bank, use -1 for no sprite - \param state: State of the button to set the sprite for - \param index: The sprite number from the current sprite bank - \param color: The color of the sprite - */ - virtual void setSprite(EGUI_BUTTON_STATE state, s32 index, - video::SColor color=video::SColor(255,255,255,255), bool loop=false); - - //! Sets if the button should behave like a push button. Which means it - //! can be in two states: Normal or Pressed. With a click on the button, - //! the user can change the state of the button. - virtual void setIsPushButton(bool isPushButton=true); - - //! Checks whether the button is a push button - virtual bool isPushButton() const; - - //! Sets the pressed state of the button if this is a pushbutton - virtual void setPressed(bool pressed=true); - - //! Returns if the button is currently pressed - virtual bool isPressed() const; - - //! Sets if the button should use the skin to draw its border - virtual void setDrawBorder(bool border=true); - - //! Checks if the button face and border are being drawn - virtual bool isDrawingBorder() const; - - //! Sets if the alpha channel should be used for drawing images on the button (default is false) - virtual void setUseAlphaChannel(bool useAlphaChannel=true); - - //! Checks if the alpha channel should be used for drawing images on the button - virtual bool isAlphaChannelUsed() const; - - //! Sets if the button should scale the button images to fit - virtual void setScaleImage(bool scaleImage=true); - - //! Checks whether the button scales the used images - virtual bool isScalingImage() const; - - //! Writes attributes of the element. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; - - //! Reads attributes of the element - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - - private: - - struct ButtonSprite - { - s32 Index; - video::SColor Color; - bool Loop; - }; - - ButtonSprite ButtonSprites[EGBS_COUNT]; - - IGUISpriteBank* SpriteBank; - IGUIFont* OverrideFont; - - video::ITexture* Image; - video::ITexture* PressedImage; - - core::rect<s32> ImageRect; - core::rect<s32> PressedImageRect; - - u32 ClickTime; - - bool IsPushButton; - bool Pressed; - bool UseAlphaChannel; - bool DrawBorder; - bool ScaleImage; - }; - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - -#endif // __C_GUI_BUTTON_H_INCLUDED__ - diff --git a/irrlicht-1.6/source/Irrlicht/CGUICheckBox.cpp b/irrlicht-1.6/source/Irrlicht/CGUICheckBox.cpp deleted file mode 100644 index f1791ccce..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUICheckBox.cpp +++ /dev/null @@ -1,200 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUICheckBox.h" - -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUISkin.h" -#include "IGUIEnvironment.h" -#include "IVideoDriver.h" -#include "IGUIFont.h" -#include "os.h" - -namespace irr -{ -namespace gui -{ - -//! constructor -CGUICheckBox::CGUICheckBox(bool checked, IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle) -: IGUICheckBox(environment, parent, id, rectangle), checkTime(0), Pressed(false), Checked(checked) -{ - #ifdef _DEBUG - setDebugName("CGUICheckBox"); - #endif - - // this element can be tabbed into - setTabStop(true); - setTabOrder(-1); -} - - -//! called if an event happened. -bool CGUICheckBox::OnEvent(const SEvent& event) -{ - if (IsEnabled) - { - switch(event.EventType) - { - case EET_KEY_INPUT_EVENT: - if (event.KeyInput.PressedDown && - (event.KeyInput.Key == KEY_RETURN || event.KeyInput.Key == KEY_SPACE)) - { - Pressed = true; - return true; - } - else - if (Pressed && event.KeyInput.PressedDown && event.KeyInput.Key == KEY_ESCAPE) - { - Pressed = false; - return true; - } - else - if (!event.KeyInput.PressedDown && Pressed && - (event.KeyInput.Key == KEY_RETURN || event.KeyInput.Key == KEY_SPACE)) - { - Pressed = false; - if (Parent) - { - SEvent newEvent; - newEvent.EventType = EET_GUI_EVENT; - newEvent.GUIEvent.Caller = this; - newEvent.GUIEvent.Element = 0; - Checked = !Checked; - newEvent.GUIEvent.EventType = EGET_CHECKBOX_CHANGED; - Parent->OnEvent(newEvent); - } - return true; - } - break; - case EET_GUI_EVENT: - if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST) - { - if (event.GUIEvent.Caller == this) - Pressed = false; - } - break; - case EET_MOUSE_INPUT_EVENT: - if (event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN) - { - Pressed = true; - checkTime = os::Timer::getTime(); - Environment->setFocus(this); - return true; - } - else - if (event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP) - { - bool wasPressed = Pressed; - Environment->removeFocus(this); - Pressed = false; - - if (wasPressed && Parent) - { - if ( !AbsoluteClippingRect.isPointInside( core::position2d<s32>(event.MouseInput.X, event.MouseInput.Y) ) ) - { - Pressed = false; - return true; - } - - SEvent newEvent; - newEvent.EventType = EET_GUI_EVENT; - newEvent.GUIEvent.Caller = this; - newEvent.GUIEvent.Element = 0; - Checked = !Checked; - newEvent.GUIEvent.EventType = EGET_CHECKBOX_CHANGED; - Parent->OnEvent(newEvent); - } - - return true; - } - break; - default: - break; - } - } - - return IGUIElement::OnEvent(event); -} - - -//! draws the element and its children -void CGUICheckBox::draw() -{ - if (!IsVisible) - return; - - IGUISkin* skin = Environment->getSkin(); - - core::rect<s32> rect = AbsoluteRect; - - s32 height = skin->getSize(EGDS_CHECK_BOX_WIDTH); - - core::rect<s32> checkRect(AbsoluteRect.UpperLeftCorner.X, - ((AbsoluteRect.getHeight() - height) / 2) + AbsoluteRect.UpperLeftCorner.Y, - 0, 0); - - checkRect.LowerRightCorner.X = checkRect.UpperLeftCorner.X + height; - checkRect.LowerRightCorner.Y = checkRect.UpperLeftCorner.Y + height; - - skin->draw3DSunkenPane(this, skin->getColor(Pressed || !IsEnabled ? EGDC_3D_FACE : EGDC_ACTIVE_CAPTION), - false, true, checkRect, &AbsoluteClippingRect); - - if (Checked && Environment->getSkin()) - Environment->getSkin()->drawIcon(this, EGDI_CHECK_BOX_CHECKED, checkRect.getCenter(), - checkTime, os::Timer::getTime(), false, &AbsoluteClippingRect); - - if (Text.size()) - { - checkRect = AbsoluteRect; - checkRect.UpperLeftCorner.X += height + 5; - - IGUIFont* font = skin->getFont(); - if (font) - font->draw(Text.c_str(), checkRect, - skin->getColor(EGDC_BUTTON_TEXT), false, true, &AbsoluteClippingRect); - } - - IGUIElement::draw(); -} - - -//! set if box is checked -void CGUICheckBox::setChecked(bool checked) -{ - Checked = checked; -} - - -//! returns if box is checked -bool CGUICheckBox::isChecked() const -{ - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return Checked; -} - - -//! Writes attributes of the element. -void CGUICheckBox::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const -{ - IGUICheckBox::serializeAttributes(out,options); - out->addBool("Checked", Checked); -} - - -//! Reads attributes of the element -void CGUICheckBox::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) -{ - Checked = in->getAttributeAsBool ("Checked"); - - IGUICheckBox::deserializeAttributes(in,options); -} - - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - diff --git a/irrlicht-1.6/source/Irrlicht/CGUICheckBox.h b/irrlicht-1.6/source/Irrlicht/CGUICheckBox.h deleted file mode 100644 index ced97bf03..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUICheckBox.h +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_CHECKBOX_H_INCLUDED__ -#define __C_GUI_CHECKBOX_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUICheckBox.h" - -namespace irr -{ -namespace gui -{ - - class CGUICheckBox : public IGUICheckBox - { - public: - - //! constructor - CGUICheckBox(bool checked, IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle); - - //! set if box is checked - virtual void setChecked(bool checked); - - //! returns if box is checked - virtual bool isChecked() const; - - //! called if an event happened. - virtual bool OnEvent(const SEvent& event); - - //! draws the element and its children - virtual void draw(); - - //! Writes attributes of the element. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; - - //! Reads attributes of the element - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - - private: - - u32 checkTime; - bool Pressed; - bool Checked; - }; - -} // end namespace gui -} // end namespace irr - -#endif // __C_GUI_CHECKBOX_H_INCLUDED__ - -#endif // _IRR_COMPILE_WITH_GUI_ diff --git a/irrlicht-1.6/source/Irrlicht/CGUIColorSelectDialog.cpp b/irrlicht-1.6/source/Irrlicht/CGUIColorSelectDialog.cpp deleted file mode 100644 index 96904fa7b..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIColorSelectDialog.cpp +++ /dev/null @@ -1,459 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUIColorSelectDialog.h" - -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUISkin.h" -#include "IGUIEnvironment.h" -#include "IVideoDriver.h" -#include "IGUIButton.h" -#include "IGUIStaticText.h" -#include "IGUIFont.h" -#include "IGUISpriteBank.h" -#include "IFileList.h" -#include "os.h" -#include "SoftwareDriver2_helper.h" -#include "CImage.h" - -namespace irr -{ -namespace gui -{ - -const s32 CSD_WIDTH = 350; -const s32 CSD_HEIGHT = 300; - -struct sTemplate -{ - const wchar_t *pre; - const wchar_t *init; - const wchar_t *pos; - int x, y; - int range_down ,range_up; -}; - -static const sTemplate Template [] = -{ - { L"A:", L"0", 0,20,165, 0, 255 }, - { L"R:", L"0", 0,20,205, 0, 255 }, - { L"G:", L"0", 0,20,230, 0, 255 }, - { L"B:", L"0", 0,20,255, 0, 255 }, - { L"H:", L"0", L"°",180,205, 0, 360 }, - { L"S:", L"0", L"%",180,230, 0, 100 }, - { L"L:", L"0", L"%",180,255, 0, 100 }, -}; - - -//! constructor -CGUIColorSelectDialog::CGUIColorSelectDialog(const wchar_t* title, IGUIEnvironment* environment, IGUIElement* parent, s32 id) - : IGUIColorSelectDialog(environment, parent, id, - core::rect<s32>((parent->getAbsolutePosition().getWidth()-CSD_WIDTH)/2, - (parent->getAbsolutePosition().getHeight()-CSD_HEIGHT)/2, - (parent->getAbsolutePosition().getWidth()-CSD_WIDTH)/2+CSD_WIDTH, - (parent->getAbsolutePosition().getHeight()-CSD_HEIGHT)/2+CSD_HEIGHT)), - Dragging(false) -{ - #ifdef _DEBUG - IGUIElement::setDebugName("CGUIColorSelectDialog"); - #endif - - Text = title; - - IGUISkin* skin = Environment->getSkin(); - - const s32 buttonw = environment->getSkin()->getSize(EGDS_WINDOW_BUTTON_WIDTH); - const s32 posx = RelativeRect.getWidth() - buttonw - 4; - - CloseButton = Environment->addButton(core::rect<s32>(posx, 3, posx + buttonw, 3 + buttonw), - this, -1, L"", skin ? skin->getDefaultText(EGDT_WINDOW_CLOSE) : L"Close"); - if (skin && skin->getSpriteBank()) - { - CloseButton->setSpriteBank(skin->getSpriteBank()); - CloseButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_CLOSE), skin->getColor(EGDC_WINDOW_SYMBOL)); - CloseButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_CLOSE), skin->getColor(EGDC_WINDOW_SYMBOL)); - } - CloseButton->setSubElement(true); - CloseButton->setTabStop(false); - CloseButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - CloseButton->grab(); - - OKButton = Environment->addButton( - core::rect<s32>(RelativeRect.getWidth()-80, 30, RelativeRect.getWidth()-10, 50), - this, -1, skin ? skin->getDefaultText(EGDT_MSG_BOX_OK) : L"OK"); - OKButton->setSubElement(true); - OKButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - OKButton->grab(); - - CancelButton = Environment->addButton( - core::rect<s32>(RelativeRect.getWidth()-80, 55, RelativeRect.getWidth()-10, 75), - this, -1, skin ? skin->getDefaultText(EGDT_MSG_BOX_CANCEL) : L"Cancel"); - CancelButton->setSubElement(true); - CancelButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - CancelButton->grab(); - - video::IVideoDriver* driver = Environment->getVideoDriver(); - ColorRing.Texture = driver->getTexture ( "#colorring" ); - if ( 0 == ColorRing.Texture ) - { - buildColorRing(core::dimension2d<u32>(128, 128), 1, - Environment->getSkin()->getColor(EGDC_3D_SHADOW)); - } - - core::rect<s32> r(20,20, 0,0); - - ColorRing.Control = Environment->addImage(ColorRing.Texture, r.UpperLeftCorner, true, this); - ColorRing.Control->setSubElement(true); - ColorRing.Control->grab(); - - for ( u32 i = 0; i != sizeof (Template) / sizeof ( sTemplate ); ++i ) - { - if ( Template[i].pre ) - { - r.UpperLeftCorner.X = Template[i].x; - r.UpperLeftCorner.Y = Template[i].y; - r.LowerRightCorner.X = r.UpperLeftCorner.X + 15; - r.LowerRightCorner.Y = r.UpperLeftCorner.Y + 20; - IGUIElement *t = Environment->addStaticText(Template[i].pre, r, false, false, this); - t->setSubElement(true); - } - - if ( Template[i].pos ) - { - r.UpperLeftCorner.X = Template[i].x + 52; - r.UpperLeftCorner.Y = Template[i].y; - r.LowerRightCorner.X = r.UpperLeftCorner.X + 15; - r.LowerRightCorner.Y = r.UpperLeftCorner.Y + 20; - IGUIElement *t = Environment->addStaticText( Template[i].pos, r, false, false, this); - t->setSubElement(true); - } - - SBatteryItem item; - - r.UpperLeftCorner.X = Template[i].x + 15; - r.UpperLeftCorner.Y = Template[i].y; - r.LowerRightCorner.X = r.UpperLeftCorner.X + 35; - r.LowerRightCorner.Y = r.UpperLeftCorner.Y + 20; - - item.Edit = Environment->addEditBox( Template[i].init, r, true, this); - item.Edit->setSubElement(true); - item.Edit->grab(); - - r.UpperLeftCorner.X = Template[i].x + 70; - r.UpperLeftCorner.Y = Template[i].y + 4; - r.LowerRightCorner.X = r.UpperLeftCorner.X + 60; - r.LowerRightCorner.Y = r.UpperLeftCorner.Y + 12; - - item.Scrollbar = Environment->addScrollBar(true, r, this); - item.Scrollbar->grab (); - item.Scrollbar->setSubElement(true); - item.Scrollbar->setMax ( Template[i].range_up - Template[i].range_down ); - item.Scrollbar->setSmallStep ( 1 ); - - Battery.push_back ( item ); - } - - bringToFront(CancelButton); - bringToFront(OKButton); -} - - -//! destructor -CGUIColorSelectDialog::~CGUIColorSelectDialog() -{ - if (CloseButton) - CloseButton->drop(); - - if (OKButton) - OKButton->drop(); - - if (CancelButton) - CancelButton->drop(); - - for ( u32 i = 0; i != Battery.size ();++i ) - { - Battery[i].Edit->drop(); - Battery[i].Scrollbar->drop(); - } - - if (ColorRing.Control) - ColorRing.Control->drop(); -} - - -//! renders a antialiased, colored ring -void CGUIColorSelectDialog::buildColorRing( const core::dimension2d<u32> & dim, s32 supersample, const video::SColor& borderColor ) -{ - const core::dimension2d<u32> d(dim.Width * supersample, dim.Height * supersample); - video::CImage *RawTexture = new video::CImage(video::ECF_A8R8G8B8, d); - - RawTexture->fill ( 0x00808080 ); - - const s32 radiusOut = ( d.Width / 2 ) - 4; - const s32 fullR2 = radiusOut * radiusOut; - - video::SColor rgb(0xFF000000); - video::SColorHSL hsl; - hsl.Luminance = 0.5f; - hsl.Saturation = 1.f; - - core::position2d<s32> p; - for ( p.Y = -radiusOut; p.Y <= radiusOut; p.Y += 1 ) - { - s32 y2 = p.Y * p.Y; - - for (p.X = -radiusOut; p.X <= radiusOut; p.X += 1) - { - s32 r2 = y2 + ( p.X * p.X ); - - // test point in circle - s32 testa = r2 - fullR2; - - if ( testa < 0 ) - { - // dotproduct u ( x,y ) * v ( 1, 0 ) = cosinus(a) - - const f32 r = sqrtf((f32) r2); - - // normalize, dotproduct = xnorm - const f32 xn = -p.X * core::reciprocal(r); - - hsl.Hue = acosf(xn); - if ( p.Y > 0 ) - hsl.Hue = (2.f * core::PI ) - hsl.Hue; - - hsl.Hue -= core::PI / 2.f; - - const f32 rTest = r / radiusOut; -/* - if ( rTest < 0.25f ) - { - hsl.Luminance = rTest / 0.25f; - hsl.Saturation = 0.f; - hsl.toRGB ( rgb ); - *dst = rgb.color; - } - else - if ( rTest < 0.4f ) - { - hsl.Saturation = ( rTest - 0.25f ) / 0.15f; - hsl.Luminance = 1.f - ( hsl.Saturation / 2.4f ); - hsl.Luminance = 0.5f; - hsl.toRGB ( rgb ); - // *dst = rgb.color; - } - else - if ( rTest < 0.75f ) - { - hsl.Luminance = 0.5f; - hsl.Saturation = 1.f; - hsl.toRGB ( rgb ); - *dst = rgb.color; - } - else - if ( rTest < 0.98f ) - { - hsl.Luminance = 0.5f - ( ( rTest - 0.75f ) / 0.75f ); - hsl.Saturation = 1.f; - hsl.toRGB ( rgb ); - *dst = rgb.color; - } -*/ - - if ( rTest >= 0.5f ) - { - hsl.Luminance = 0.5f; - hsl.Saturation = 1.f; - hsl.toRGB(rgb); - - if ( rTest <= 0.55f ) - { - const u32 alpha = (u32) ( (rTest - 0.5f ) * ( 255.f / 0.05f ) ); - rgb.setAlpha(alpha); - } - else if ( rTest >= 0.95f ) - { - const u32 alpha = (u32) ( (rTest - 0.95f ) * ( 255.f / 0.05f ) ); - rgb.setAlpha(255-alpha); - } - else - rgb.setAlpha(255); - RawTexture->setPixel(4+p.X+radiusOut, 4+p.Y+radiusOut, rgb); - } - } - } - } - - RawTexture->unlock (); - - if ( supersample > 1 ) - { - video::CImage * filter = new video::CImage(video::ECF_A8R8G8B8, dim ); - RawTexture->copyToScalingBoxFilter(filter); - RawTexture->drop(); - RawTexture = filter; - } - - video::IVideoDriver* driver = Environment->getVideoDriver(); - - bool generateMipLevels = driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS); - driver->setTextureCreationFlag( video::ETCF_CREATE_MIP_MAPS, false); - - ColorRing.Texture = driver->addTexture ( L"#colorring", RawTexture); - RawTexture->drop(); - - driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, generateMipLevels); -} - - -//! called if an event happened. -bool CGUIColorSelectDialog::OnEvent(const SEvent& event) -{ - if (IsEnabled) - { - switch(event.EventType) - { - case EET_GUI_EVENT: - switch(event.GUIEvent.EventType) - { - case EGET_SCROLL_BAR_CHANGED: - { - for ( u32 i = 0; i!= Battery.size (); ++i ) - { - if ( event.GUIEvent.Caller == Battery[i].Scrollbar ) - { - const s32 value = Template[i].range_down + Battery[i].Scrollbar->getPos(); - Battery[i].Edit->setText(core::stringw(value).c_str()); - } - } - return true; - } - - case EGET_ELEMENT_FOCUS_LOST: - Dragging = false; - break; - case EGET_BUTTON_CLICKED: - if (event.GUIEvent.Caller == CloseButton || - event.GUIEvent.Caller == CancelButton) - { - sendCancelEvent(); - remove(); - return true; - } - else - if (event.GUIEvent.Caller == OKButton) - { - sendSelectedEvent(); - remove(); - return true; - } - break; - - case EGET_LISTBOX_CHANGED: - case EGET_LISTBOX_SELECTED_AGAIN: - default: - break; - } - break; - case EET_MOUSE_INPUT_EVENT: - switch(event.MouseInput.Event) - { - case EMIE_LMOUSE_PRESSED_DOWN: - DragStart.X = event.MouseInput.X; - DragStart.Y = event.MouseInput.Y; - Dragging = true; - Environment->setFocus(this); - return true; - case EMIE_LMOUSE_LEFT_UP: - Dragging = false; - Environment->removeFocus(this); - return true; - case EMIE_MOUSE_MOVED: - if (Dragging) - { - // gui window should not be dragged outside its parent - if (Parent) - if (event.MouseInput.X < Parent->getAbsolutePosition().UpperLeftCorner.X +1 || - event.MouseInput.Y < Parent->getAbsolutePosition().UpperLeftCorner.Y +1 || - event.MouseInput.X > Parent->getAbsolutePosition().LowerRightCorner.X -1 || - event.MouseInput.Y > Parent->getAbsolutePosition().LowerRightCorner.Y -1) - - return true; - - move(core::position2d<s32>(event.MouseInput.X - DragStart.X, event.MouseInput.Y - DragStart.Y)); - DragStart.X = event.MouseInput.X; - DragStart.Y = event.MouseInput.Y; - return true; - } - default: - break; - } - default: - break; - } - } - - return IGUIElement::OnEvent(event); -} - - -//! draws the element and its children -void CGUIColorSelectDialog::draw() -{ - if (!IsVisible) - return; - - IGUISkin* skin = Environment->getSkin(); - core::rect<s32> rect = skin->draw3DWindowBackground(this, true, skin->getColor(EGDC_ACTIVE_BORDER), - AbsoluteRect, &AbsoluteClippingRect); - - if (Text.size()) - { - rect.UpperLeftCorner.X += 2; - rect.LowerRightCorner.X -= skin->getSize(EGDS_WINDOW_BUTTON_WIDTH) + 5; - - IGUIFont* font = skin->getFont(EGDF_WINDOW); - if (font) - font->draw(Text.c_str(), rect, skin->getColor(EGDC_ACTIVE_CAPTION), false, true, - &AbsoluteClippingRect); - } - IGUIFont* font = Environment->getBuiltInFont(); - if (font) - font->draw(L"+", core::rect<s32>(20,20,50,50), video::SColor(), false, false, - &AbsoluteClippingRect); - - IGUIElement::draw(); -} - - -//! sends the event that the file has been selected. -void CGUIColorSelectDialog::sendSelectedEvent() -{ - SEvent event; - event.EventType = EET_GUI_EVENT; - event.GUIEvent.Caller = this; - event.GUIEvent.Element = 0; - event.GUIEvent.EventType = EGET_FILE_SELECTED; - Parent->OnEvent(event); -} - - -//! sends the event that the file choose process has been canceld -void CGUIColorSelectDialog::sendCancelEvent() -{ - SEvent event; - event.EventType = EET_GUI_EVENT; - event.GUIEvent.Caller = this; - event.GUIEvent.Element = 0; - event.GUIEvent.EventType = EGET_FILE_CHOOSE_DIALOG_CANCELLED; - Parent->OnEvent(event); -} - - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - diff --git a/irrlicht-1.6/source/Irrlicht/CGUIColorSelectDialog.h b/irrlicht-1.6/source/Irrlicht/CGUIColorSelectDialog.h deleted file mode 100644 index 4920eb648..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIColorSelectDialog.h +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_COLOR_SELECT_DIALOG_H_INCLUDED__ -#define __C_GUI_COLOR_SELECT_DIALOG_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUIColorSelectDialog.h" -#include "IGUIButton.h" -#include "IGUIEditBox.h" -#include "IGUIScrollBar.h" -#include "IGUIImage.h" -#include "irrArray.h" - - -namespace irr -{ -namespace gui -{ - - class CGUIColorSelectDialog : public IGUIColorSelectDialog - { - public: - - //! constructor - CGUIColorSelectDialog(const wchar_t* title, IGUIEnvironment* environment, IGUIElement* parent, s32 id); - - //! destructor - virtual ~CGUIColorSelectDialog(); - - //! called if an event happened. - virtual bool OnEvent(const SEvent& event); - - //! draws the element and its children - virtual void draw(); - - private: - - //! sends the event that the file has been selected. - void sendSelectedEvent(); - - //! sends the event that the file choose process has been canceld - void sendCancelEvent(); - - core::position2d<s32> DragStart; - bool Dragging; - IGUIButton* CloseButton; - IGUIButton* OKButton; - IGUIButton* CancelButton; - - struct SBatteryItem - { - f32 Incoming; - f32 Outgoing; - IGUIEditBox * Edit; - IGUIScrollBar *Scrollbar; - }; - core::array< SBatteryItem > Battery; - - struct SColorCircle - { - IGUIImage * Control; - video::ITexture * Texture; - }; - SColorCircle ColorRing; - - void buildColorRing( const core::dimension2d<u32> & dim, s32 supersample, const video::SColor& borderColor ); - }; - - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - -#endif // __C_GUI_COLOR_SELECT_DIALOG_H_INCLUDED__ - diff --git a/irrlicht-1.6/source/Irrlicht/CGUIComboBox.cpp b/irrlicht-1.6/source/Irrlicht/CGUIComboBox.cpp deleted file mode 100644 index c57228f54..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIComboBox.cpp +++ /dev/null @@ -1,489 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUIComboBox.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUIEnvironment.h" -#include "IVideoDriver.h" -#include "IGUISkin.h" -#include "IGUIEnvironment.h" -#include "IGUIFont.h" -#include "IGUIButton.h" -#include "CGUIListBox.h" -#include "os.h" - -namespace irr -{ -namespace gui -{ - -//! constructor -CGUIComboBox::CGUIComboBox(IGUIEnvironment* environment, IGUIElement* parent, - s32 id, core::rect<s32> rectangle) - : IGUIComboBox(environment, parent, id, rectangle), - ListButton(0), SelectedText(0), ListBox(0), LastFocus(0), - Selected(-1), HAlign(EGUIA_UPPERLEFT), VAlign(EGUIA_CENTER), HasFocus(false) -{ - #ifdef _DEBUG - setDebugName("CGUIComboBox"); - #endif - - IGUISkin* skin = Environment->getSkin(); - - s32 width = 15; - if (skin) - width = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH); - - core::rect<s32> r; - r.UpperLeftCorner.X = rectangle.getWidth() - width - 2; - r.LowerRightCorner.X = rectangle.getWidth() - 2; - - r.UpperLeftCorner.Y = 2; - r.LowerRightCorner.Y = rectangle.getHeight() - 2; - - ListButton = Environment->addButton(r, this, -1, L""); - if (skin && skin->getSpriteBank()) - { - ListButton->setSpriteBank(skin->getSpriteBank()); - ListButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_DOWN), skin->getColor(EGDC_WINDOW_SYMBOL)); - ListButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_DOWN), skin->getColor(EGDC_WINDOW_SYMBOL)); - } - ListButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); - ListButton->setSubElement(true); - ListButton->setTabStop(false); - - r.UpperLeftCorner.X = 2; - r.UpperLeftCorner.Y = 2; - r.LowerRightCorner.X = RelativeRect.getWidth() - (ListButton->getAbsolutePosition().getWidth() + 2); - r.LowerRightCorner.Y = RelativeRect.getHeight() - 2; - - SelectedText = Environment->addStaticText(L"", r, false, false, this, -1, false); - SelectedText->setSubElement(true); - SelectedText->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); - SelectedText->setTextAlignment(EGUIA_UPPERLEFT, EGUIA_CENTER); - if (skin) - SelectedText->setOverrideColor(skin->getColor(EGDC_BUTTON_TEXT)); - SelectedText->enableOverrideColor(true); - - // this element can be tabbed to - setTabStop(true); - setTabOrder(-1); -} - - -void CGUIComboBox::setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical) -{ - HAlign = horizontal; - VAlign = vertical; - SelectedText->setTextAlignment(horizontal, vertical); -} - - -//! Returns amount of items in box -u32 CGUIComboBox::getItemCount() const -{ - return Items.size(); -} - - -//! returns string of an item. the idx may be a value from 0 to itemCount-1 -const wchar_t* CGUIComboBox::getItem(u32 idx) const -{ - if (idx >= Items.size()) - return 0; - - return Items[idx].Name.c_str(); -} - -//! returns string of an item. the idx may be a value from 0 to itemCount-1 -u32 CGUIComboBox::getItemData(u32 idx) const -{ - if (idx >= Items.size()) - return 0; - - return Items[idx].Data; -} - -//! Returns index based on item data -s32 CGUIComboBox::getIndexForItemData(u32 data ) const -{ - for ( u32 i = 0; i < Items.size (); ++i ) - { - if ( Items[i].Data == data ) - return i; - } - return -1; -} - - -//! Removes an item from the combo box. -void CGUIComboBox::removeItem(u32 idx) -{ - if (idx >= Items.size()) - return; - - if (Selected == (s32)idx) - setSelected(-1); - - Items.erase(idx); -} - - -//! Returns caption of this element. -const wchar_t* CGUIComboBox::getText() const -{ - return getItem(Selected); -} - - -//! adds an item and returns the index of it -u32 CGUIComboBox::addItem(const wchar_t* text, u32 data) -{ - Items.push_back( SComboData ( text, data ) ); - - if (Selected == -1) - setSelected(0); - - return Items.size() - 1; -} - - -//! deletes all items in the combo box -void CGUIComboBox::clear() -{ - Items.clear(); - setSelected(-1); -} - - -//! returns id of selected item. returns -1 if no item is selected. -s32 CGUIComboBox::getSelected() const -{ - return Selected; -} - - -//! sets the selected item. Set this to -1 if no item should be selected -void CGUIComboBox::setSelected(s32 idx) -{ - if (idx < -1 || idx >= (s32)Items.size()) - return; - - Selected = idx; - if (Selected == -1) - SelectedText->setText(L""); - else - SelectedText->setText(Items[Selected].Name.c_str()); -} - - -//! called if an event happened. -bool CGUIComboBox::OnEvent(const SEvent& event) -{ - if (IsEnabled) - { - switch(event.EventType) - { - - case EET_KEY_INPUT_EVENT: - if (ListBox && event.KeyInput.PressedDown && event.KeyInput.Key == KEY_ESCAPE) - { - // hide list box - openCloseMenu(); - return true; - } - else - if (event.KeyInput.Key == KEY_RETURN || event.KeyInput.Key == KEY_SPACE) - { - if (!event.KeyInput.PressedDown) - openCloseMenu(); - - ListButton->setPressed(ListBox == 0); - - return true; - } - else - if (event.KeyInput.PressedDown) - { - s32 oldSelected = Selected; - bool absorb = true; - switch (event.KeyInput.Key) - { - case KEY_DOWN: - setSelected(Selected+1); - break; - case KEY_UP: - setSelected(Selected-1); - break; - case KEY_HOME: - case KEY_PRIOR: - setSelected(0); - break; - case KEY_END: - case KEY_NEXT: - setSelected((s32)Items.size()-1); - break; - default: - absorb = false; - } - - if (Selected <0) - setSelected(0); - - if (Selected >= (s32)Items.size()) - setSelected((s32)Items.size() -1); - - if (Selected != oldSelected) - sendSelectionChangedEvent(); - - if (absorb) - return true; - } - break; - - case EET_GUI_EVENT: - - switch(event.GUIEvent.EventType) - { - case EGET_ELEMENT_FOCUS_LOST: - if (ListBox && - (Environment->hasFocus(ListBox) || ListBox->isMyChild(event.GUIEvent.Caller) ) && - event.GUIEvent.Element != this && - event.GUIEvent.Element != ListButton && - event.GUIEvent.Element != ListBox && - !ListBox->isMyChild(event.GUIEvent.Element)) - { - openCloseMenu(); - } - break; - case EGET_BUTTON_CLICKED: - if (event.GUIEvent.Caller == ListButton) - { - openCloseMenu(); - return true; - } - break; - case EGET_LISTBOX_SELECTED_AGAIN: - case EGET_LISTBOX_CHANGED: - if (event.GUIEvent.Caller == ListBox) - { - setSelected(ListBox->getSelected()); - if (Selected <0 || Selected >= (s32)Items.size()) - setSelected(-1); - openCloseMenu(); - - sendSelectionChangedEvent(); - } - return true; - default: - break; - } - break; - case EET_MOUSE_INPUT_EVENT: - - switch(event.MouseInput.Event) - { - case EMIE_LMOUSE_PRESSED_DOWN: - { - core::position2d<s32> p(event.MouseInput.X, event.MouseInput.Y); - - // send to list box - if (ListBox && ListBox->isPointInside(p) && ListBox->OnEvent(event)) - return true; - - return true; - } - case EMIE_LMOUSE_LEFT_UP: - { - core::position2d<s32> p(event.MouseInput.X, event.MouseInput.Y); - - // send to list box - if (!(ListBox && - ListBox->getAbsolutePosition().isPointInside(p) && - ListBox->OnEvent(event))) - openCloseMenu(); - return true; - } - case EMIE_MOUSE_WHEEL: - { - s32 oldSelected = Selected; - setSelected( Selected + ((event.MouseInput.Wheel < 0) ? 1 : -1)); - - if (Selected <0) - setSelected(0); - - if (Selected >= (s32)Items.size()) - setSelected((s32)Items.size() -1); - - if (Selected != oldSelected) - sendSelectionChangedEvent(); - } - default: - break; - } - break; - default: - break; - } - } - - return IGUIElement::OnEvent(event); -} - - -void CGUIComboBox::sendSelectionChangedEvent() -{ - if (Parent) - { - SEvent event; - - event.EventType = EET_GUI_EVENT; - event.GUIEvent.Caller = this; - event.GUIEvent.Element = 0; - event.GUIEvent.EventType = EGET_COMBO_BOX_CHANGED; - Parent->OnEvent(event); - } -} - - -//! draws the element and its children -void CGUIComboBox::draw() -{ - if (!IsVisible) - return; - - IGUISkin* skin = Environment->getSkin(); - IGUIElement *currentFocus = Environment->getFocus(); - if (currentFocus != LastFocus) - { - HasFocus = currentFocus == this || isMyChild(currentFocus); - LastFocus = currentFocus; - - SelectedText->setBackgroundColor(skin->getColor(EGDC_HIGH_LIGHT)); - - if(isEnabled()) - { - SelectedText->setDrawBackground(HasFocus); - SelectedText->setOverrideColor(skin->getColor(HasFocus ? EGDC_HIGH_LIGHT_TEXT : EGDC_BUTTON_TEXT)); - } - else - { - SelectedText->setDrawBackground(false); - SelectedText->setOverrideColor(skin->getColor(EGDC_GRAY_TEXT)); - } - } - - core::rect<s32> frameRect(AbsoluteRect); - - // draw the border - - skin->draw3DSunkenPane(this, skin->getColor(EGDC_3D_HIGH_LIGHT), - true, true, frameRect, &AbsoluteClippingRect); - - // draw children - IGUIElement::draw(); -} - - -void CGUIComboBox::openCloseMenu() -{ - if (ListBox) - { - // close list box - Environment->setFocus(this); - ListBox->remove(); - ListBox = 0; - } - else - { - if (Parent) - Parent->bringToFront(this); - - IGUISkin* skin = Environment->getSkin(); - s32 h = Items.size(); - - if (h > 5) - h = 5; - if (h == 0) - h = 1; - - IGUIFont* font = skin->getFont(); - if (font) - h *= (font->getDimension(L"A").Height + 4); - - // open list box - core::rect<s32> r(0, AbsoluteRect.getHeight(), - AbsoluteRect.getWidth(), AbsoluteRect.getHeight() + h); - - ListBox = new CGUIListBox(Environment, this, -1, r, false, true, true); - ListBox->setSubElement(true); - ListBox->setNotClipped(true); - ListBox->drop(); - - // ensure that list box is always completely visible - if (ListBox->getAbsolutePosition().LowerRightCorner.Y > Environment->getRootGUIElement()->getAbsolutePosition().getHeight()) - ListBox->setRelativePosition( core::rect<s32>(0, -ListBox->getAbsolutePosition().getHeight(), AbsoluteRect.getWidth(), 0) ); - - for (s32 i=0; i<(s32)Items.size(); ++i) - ListBox->addItem(Items[i].Name.c_str()); - - ListBox->setSelected(Selected); - - // set focus - Environment->setFocus(ListBox); - } -} - - -//! Writes attributes of the element. -void CGUIComboBox::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const -{ - IGUIComboBox::serializeAttributes(out,options); - - out->addEnum ("HTextAlign", HAlign, GUIAlignmentNames); - out->addEnum ("VTextAlign", VAlign, GUIAlignmentNames); - - out->addInt ("Selected", Selected ); - out->addInt ("ItemCount", Items.size()); - for (u32 i=0; i < Items.size(); ++i) - { - core::stringc s = "Item"; - s += i; - s += "Text"; - out->addString(s.c_str(), Items[i].Name.c_str()); - } -} - - -//! Reads attributes of the element -void CGUIComboBox::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) -{ - IGUIComboBox::deserializeAttributes(in,options); - - setTextAlignment( (EGUI_ALIGNMENT) in->getAttributeAsEnumeration("HTextAlign", GUIAlignmentNames), - (EGUI_ALIGNMENT) in->getAttributeAsEnumeration("VTextAlign", GUIAlignmentNames)); - - // clear the list - clear(); - // get item count - u32 c = in->getAttributeAsInt("ItemCount"); - // add items - for (u32 i=0; i < c; ++i) - { - core::stringc s = "Item"; - s += i; - s += "Text"; - addItem(in->getAttributeAsStringW(s.c_str()).c_str(), 0); - } - - setSelected(in->getAttributeAsInt("Selected")); -} - -} // end namespace gui -} // end namespace irr - - -#endif // _IRR_COMPILE_WITH_GUI_ - diff --git a/irrlicht-1.6/source/Irrlicht/CGUIComboBox.h b/irrlicht-1.6/source/Irrlicht/CGUIComboBox.h deleted file mode 100644 index f56c552fc..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIComboBox.h +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_COMBO_BOX_H_INCLUDED__ -#define __C_GUI_COMBO_BOX_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUIComboBox.h" -#include "IGUIStaticText.h" -#include "irrString.h" -#include "irrArray.h" - -namespace irr -{ -namespace gui -{ - class IGUIButton; - class IGUIListBox; - - //! Single line edit box for editing simple text. - class CGUIComboBox : public IGUIComboBox - { - public: - - //! constructor - CGUIComboBox(IGUIEnvironment* environment, IGUIElement* parent, - s32 id, core::rect<s32> rectangle); - - //! Returns amount of items in box - virtual u32 getItemCount() const; - - //! returns string of an item. the idx may be a value from 0 to itemCount-1 - virtual const wchar_t* getItem(u32 idx) const; - - //! Returns item data of an item. the idx may be a value from 0 to itemCount-1 - virtual u32 getItemData(u32 idx) const; - - //! Returns index based on item data - virtual s32 getIndexForItemData( u32 data ) const; - - //! adds an item and returns the index of it - virtual u32 addItem(const wchar_t* text, u32 data); - - //! Removes an item from the combo box. - virtual void removeItem(u32 id); - - //! deletes all items in the combo box - virtual void clear(); - - //! returns the text of the currently selected item - virtual const wchar_t* getText() const; - - //! returns id of selected item. returns -1 if no item is selected. - virtual s32 getSelected() const; - - //! sets the selected item. Set this to -1 if no item should be selected - virtual void setSelected(s32 idx); - - //! sets the text alignment of the text part - virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical); - - //! called if an event happened. - virtual bool OnEvent(const SEvent& event); - - //! draws the element and its children - virtual void draw(); - - //! Writes attributes of the element. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; - - //! Reads attributes of the element - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - - private: - - void openCloseMenu(); - void sendSelectionChangedEvent(); - - IGUIButton* ListButton; - IGUIStaticText* SelectedText; - IGUIListBox* ListBox; - IGUIElement *LastFocus; - - - struct SComboData - { - SComboData ( const wchar_t * text, u32 data ) - : Name (text), Data ( data ) {} - - core::stringw Name; - u32 Data; - }; - core::array< SComboData > Items; - - s32 Selected; - EGUI_ALIGNMENT HAlign, VAlign; - bool HasFocus; - }; - - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - -#endif // __C_GUI_COMBO_BOX_H_INCLUDED__ - diff --git a/irrlicht-1.6/source/Irrlicht/CGUIContextMenu.cpp b/irrlicht-1.6/source/Irrlicht/CGUIContextMenu.cpp deleted file mode 100644 index 36323c08c..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIContextMenu.cpp +++ /dev/null @@ -1,755 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUIContextMenu.h" - -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUISkin.h" -#include "IGUIEnvironment.h" -#include "IVideoDriver.h" -#include "IGUIFont.h" -#include "IGUISpriteBank.h" -#include "os.h" - -namespace irr -{ -namespace gui -{ - - -//! constructor -CGUIContextMenu::CGUIContextMenu(IGUIEnvironment* environment, - IGUIElement* parent, s32 id, - core::rect<s32> rectangle, bool getFocus, bool allowFocus) - : IGUIContextMenu(environment, parent, id, rectangle), EventParent(0), LastFont(0), - HighLighted(-1), ChangeTime(0), AllowFocus(allowFocus) -{ - #ifdef _DEBUG - setDebugName("CGUIContextMenu"); - #endif - - Pos = rectangle.UpperLeftCorner; - recalculateSize(); - - if (getFocus) - Environment->setFocus(this); - - setNotClipped(true); -} - - -//! destructor -CGUIContextMenu::~CGUIContextMenu() -{ - for (u32 i=0; i<Items.size(); ++i) - if (Items[i].SubMenu) - Items[i].SubMenu->drop(); - - if (LastFont) - LastFont->drop(); -} - - -//! Returns amount of menu items -u32 CGUIContextMenu::getItemCount() const -{ - return Items.size(); -} - - -//! Adds a menu item. -u32 CGUIContextMenu::addItem(const wchar_t* text, s32 id, bool enabled, bool hasSubMenu, bool checked) -{ - SItem s; - s.Enabled = enabled; - s.Checked = checked; - s.Text = text; - s.IsSeparator = (text == 0); - s.SubMenu = 0; - s.CommandId = id; - - if (hasSubMenu) - { - s.SubMenu = new CGUIContextMenu(Environment, this, id, - core::rect<s32>(0,0,100,100), false, false); - s.SubMenu->setVisible(false); - } - - Items.push_back(s); - - recalculateSize(); - return Items.size() - 1; -} - - -//! Adds a sub menu from an element that already exists. -void CGUIContextMenu::setSubMenu(u32 index, CGUIContextMenu* menu) -{ - if (index >= Items.size()) - return; - - if (menu) - menu->grab(); - if (Items[index].SubMenu) - Items[index].SubMenu->drop(); - - Items[index].SubMenu = menu; - menu->setVisible(false); - - if (Items[index].SubMenu) - { - menu->AllowFocus = false; - if ( Environment->getFocus() == menu ) - { - Environment->setFocus( this ); - } - } - - recalculateSize(); -} - - -//! Adds a separator item to the menu -void CGUIContextMenu::addSeparator() -{ - addItem(0, -1, true, false, false); -} - - -//! Returns text of the menu item. -const wchar_t* CGUIContextMenu::getItemText(u32 idx) const -{ - if (idx >= Items.size()) - return 0; - - return Items[idx].Text.c_str(); -} - - -//! Sets text of the menu item. -void CGUIContextMenu::setItemText(u32 idx, const wchar_t* text) -{ - if (idx >= Items.size()) - return; - - Items[idx].Text = text; - recalculateSize(); -} - - -//! Returns if a menu item is enabled -bool CGUIContextMenu::isItemEnabled(u32 idx) const -{ - if (idx >= Items.size()) - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; - } - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return Items[idx].Enabled; -} - - -//! Returns if a menu item is checked -bool CGUIContextMenu::isItemChecked(u32 idx) const -{ - if (idx >= Items.size()) - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; - } - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return Items[idx].Checked; -} - - -//! Sets if the menu item should be enabled. -void CGUIContextMenu::setItemEnabled(u32 idx, bool enabled) -{ - if (idx >= Items.size()) - return; - - Items[idx].Enabled = enabled; -} - - -//! Sets if the menu item should be checked. -void CGUIContextMenu::setItemChecked(u32 idx, bool checked ) -{ - if (idx >= Items.size()) - return; - - Items[idx].Checked = checked; -} - - -//! Removes a menu item -void CGUIContextMenu::removeItem(u32 idx) -{ - if (idx >= Items.size()) - return; - - if (Items[idx].SubMenu) - { - Items[idx].SubMenu->drop(); - Items[idx].SubMenu = 0; - } - - Items.erase(idx); - recalculateSize(); -} - - -//! Removes all menu items -void CGUIContextMenu::removeAllItems() -{ - for (u32 i=0; i<Items.size(); ++i) - if (Items[i].SubMenu) - Items[i].SubMenu->drop(); - - Items.clear(); - recalculateSize(); -} - - -//! called if an event happened. -bool CGUIContextMenu::OnEvent(const SEvent& event) -{ - if (IsEnabled) - { - - switch(event.EventType) - { - case EET_GUI_EVENT: - switch(event.GUIEvent.EventType) - { - case EGET_ELEMENT_FOCUS_LOST: - if (event.GUIEvent.Caller == this && !isMyChild(event.GUIEvent.Element) && AllowFocus) - { - // set event parent of submenus - setEventParent(Parent); - remove(); - return false; - } - break; - case EGET_ELEMENT_FOCUSED: - if (event.GUIEvent.Caller == this && !AllowFocus) - { - return true; - } - break; - default: - break; - } - break; - case EET_MOUSE_INPUT_EVENT: - switch(event.MouseInput.Event) - { - case EMIE_LMOUSE_LEFT_UP: - { - // menu might be removed if it loses focus in sendClick, so grab a reference - grab(); - const u32 t = sendClick(core::position2d<s32>(event.MouseInput.X, event.MouseInput.Y)); - if ((t==0 || t==1) && Environment->hasFocus(this)) - Environment->removeFocus(this); - drop(); - } - return true; - case EMIE_LMOUSE_PRESSED_DOWN: - return true; - case EMIE_MOUSE_MOVED: - if (Environment->hasFocus(this)) - highlight(core::position2d<s32>(event.MouseInput.X, event.MouseInput.Y), true); - return true; - default: - break; - } - break; - default: - break; - } - } - - return IGUIElement::OnEvent(event); -} - - -//! Sets the visible state of this element. -void CGUIContextMenu::setVisible(bool visible) -{ - HighLighted = -1; - ChangeTime = os::Timer::getTime(); - for (u32 j=0; j<Items.size(); ++j) - if (Items[j].SubMenu) - Items[j].SubMenu->setVisible(false); - - IGUIElement::setVisible(visible); -} - - -//! sends a click Returns: -//! 0 if click went outside of the element, -//! 1 if a valid button was clicked, -//! 2 if a nonclickable element was clicked -u32 CGUIContextMenu::sendClick(const core::position2d<s32>& p) -{ - u32 t = 0; - - // get number of open submenu - s32 openmenu = -1; - s32 j; - for (j=0; j<(s32)Items.size(); ++j) - if (Items[j].SubMenu && Items[j].SubMenu->isVisible()) - { - openmenu = j; - break; - } - - // delegate click operation to submenu - if (openmenu != -1) - { - t = Items[j].SubMenu->sendClick(p); - if (t != 0) - return t; // clicked something - } - - // check click on myself - if (isPointInside(p) && - (u32)HighLighted < Items.size()) - { - if (!Items[HighLighted].Enabled || - Items[HighLighted].IsSeparator || - Items[HighLighted].SubMenu) - return 2; - - SEvent event; - event.EventType = EET_GUI_EVENT; - event.GUIEvent.Caller = this; - event.GUIEvent.Element = 0; - event.GUIEvent.EventType = EGET_MENU_ITEM_SELECTED; - if (Parent) - Parent->OnEvent(event); - else - if (EventParent) - EventParent->OnEvent(event); - - return 1; - } - - return 0; -} - - -//! returns true, if an element was highligted -bool CGUIContextMenu::highlight(const core::position2d<s32>& p, bool canOpenSubMenu) -{ - // get number of open submenu - s32 openmenu = -1; - s32 i; - for (i=0; i<(s32)Items.size(); ++i) - if (Items[i].SubMenu && Items[i].SubMenu->isVisible()) - { - openmenu = i; - break; - } - - // delegate highlight operation to submenu - if (openmenu != -1) - { - if (Items[openmenu].SubMenu->highlight(p, canOpenSubMenu)) - { - HighLighted = openmenu; - ChangeTime = os::Timer::getTime(); - return true; - } - } - - // highlight myself - for (i=0; i<(s32)Items.size(); ++i) - if (getHRect(Items[i], AbsoluteRect).isPointInside(p)) - { - HighLighted = i; - ChangeTime = os::Timer::getTime(); - - // make submenus visible/invisible - for (s32 j=0; j<(s32)Items.size(); ++j) - if (Items[j].SubMenu) - { - if ( j == i && canOpenSubMenu && Items[j].Enabled ) - Items[j].SubMenu->setVisible(true); - else if ( j != i ) - Items[j].SubMenu->setVisible(false); - } - return true; - } - - HighLighted = openmenu; - return false; -} - - -//! returns the item highlight-area -core::rect<s32> CGUIContextMenu::getHRect(const SItem& i, const core::rect<s32>& absolute) const -{ - core::rect<s32> r = absolute; - r.UpperLeftCorner.Y += i.PosY; - r.LowerRightCorner.Y = r.UpperLeftCorner.Y + i.Dim.Height; - return r; -} - - -//! Gets drawing rect of Item -core::rect<s32> CGUIContextMenu::getRect(const SItem& i, const core::rect<s32>& absolute) const -{ - core::rect<s32> r = absolute; - r.UpperLeftCorner.Y += i.PosY; - r.LowerRightCorner.Y = r.UpperLeftCorner.Y + i.Dim.Height; - r.UpperLeftCorner.X += 20; - return r; -} - - -//! draws the element and its children -void CGUIContextMenu::draw() -{ - if (!IsVisible) - return; - - IGUISkin* skin = Environment->getSkin(); - - if (!skin) - return; - - IGUIFont* font = skin->getFont(EGDF_MENU); - if (font != LastFont) - { - if (LastFont) - LastFont->drop(); - LastFont = font; - if (LastFont) - LastFont->grab(); - - recalculateSize(); - } - - IGUISpriteBank* sprites = skin->getSpriteBank(); - - core::rect<s32> rect = AbsoluteRect; - core::rect<s32>* clip = 0; - - // draw frame - skin->draw3DMenuPane(this, AbsoluteRect, clip); - - // loop through all menu items - - rect = AbsoluteRect; - s32 y = AbsoluteRect.UpperLeftCorner.Y; - - for (s32 i=0; i<(s32)Items.size(); ++i) - { - if (Items[i].IsSeparator) - { - // draw separator - rect = AbsoluteRect; - rect.UpperLeftCorner.Y += Items[i].PosY + 3; - rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + 1; - rect.UpperLeftCorner.X += 5; - rect.LowerRightCorner.X -= 5; - skin->draw2DRectangle(this, skin->getColor(EGDC_3D_SHADOW), rect, clip); - - rect.LowerRightCorner.Y += 1; - rect.UpperLeftCorner.Y += 1; - skin->draw2DRectangle(this, skin->getColor(EGDC_3D_HIGH_LIGHT), rect, clip); - - y += 10; - } - else - { - rect = getRect(Items[i], AbsoluteRect); - - // draw highlighted - - if (i == HighLighted && Items[i].Enabled) - { - core::rect<s32> r = AbsoluteRect; - r.LowerRightCorner.Y = rect.LowerRightCorner.Y; - r.UpperLeftCorner.Y = rect.UpperLeftCorner.Y; - r.LowerRightCorner.X -= 5; - r.UpperLeftCorner.X += 5; - skin->draw2DRectangle(this, skin->getColor(EGDC_HIGH_LIGHT), r, clip); - } - - // draw text - - EGUI_DEFAULT_COLOR c = EGDC_BUTTON_TEXT; - - if (i == HighLighted) - c = EGDC_HIGH_LIGHT_TEXT; - - if (!Items[i].Enabled) - c = EGDC_GRAY_TEXT; - - if (font) - font->draw(Items[i].Text.c_str(), rect, - skin->getColor(c), false, true, clip); - - // draw submenu symbol - if (Items[i].SubMenu && sprites) - { - core::rect<s32> r = rect; - r.UpperLeftCorner.X = r.LowerRightCorner.X - 15; - - sprites->draw2DSprite(skin->getIcon(EGDI_CURSOR_RIGHT), - r.getCenter(), clip, skin->getColor(c), - (i == HighLighted) ? ChangeTime : 0, - (i == HighLighted) ? os::Timer::getTime() : 0, - (i == HighLighted), true); - } - - // draw checked symbol - if (Items[i].Checked && sprites) - { - core::rect<s32> r = rect; - r.LowerRightCorner.X = r.UpperLeftCorner.X - 15; - r.UpperLeftCorner.X = r.LowerRightCorner.X + 15; - sprites->draw2DSprite(skin->getIcon(EGDI_CHECK_BOX_CHECKED), - r.getCenter(), clip, skin->getColor(c), - (i == HighLighted) ? ChangeTime : 0, - (i == HighLighted) ? os::Timer::getTime() : 0, - (i == HighLighted), true); - } - } - } - - IGUIElement::draw(); -} - - -void CGUIContextMenu::recalculateSize() -{ - IGUIFont* font = Environment->getSkin()->getFont(EGDF_MENU); - - if (!font) - return; - - core::rect<s32> rect; - rect.UpperLeftCorner = RelativeRect.UpperLeftCorner; - u32 width = 100; - u32 height = 3; - - u32 i; - for (i=0; i<Items.size(); ++i) - { - if (Items[i].IsSeparator) - { - Items[i].Dim.Width = 100; - Items[i].Dim.Height = 10; - } - else - { - Items[i].Dim = font->getDimension(Items[i].Text.c_str()); - Items[i].Dim.Width += 40; - - if (Items[i].Dim.Width > width) - width = Items[i].Dim.Width; - } - - Items[i].PosY = height; - height += Items[i].Dim.Height; - } - - height += 5; - - if (height < 10) - height = 10; - - rect.LowerRightCorner.X = RelativeRect.UpperLeftCorner.X + width; - rect.LowerRightCorner.Y = RelativeRect.UpperLeftCorner.Y + height; - - setRelativePosition(rect); - - // recalculate submenus - for (i=0; i<Items.size(); ++i) - { - if (Items[i].SubMenu) - { - // move submenu - const s32 w = Items[i].SubMenu->getAbsolutePosition().getWidth(); - const s32 h = Items[i].SubMenu->getAbsolutePosition().getHeight(); - - Items[i].SubMenu->setRelativePosition( - core::rect<s32>(width-5, Items[i].PosY, - width+w-5, Items[i].PosY+h)); - } - } -} - - -//! Returns the selected item in the menu -s32 CGUIContextMenu::getSelectedItem() const -{ - return HighLighted; -} - - -//! \return Returns a pointer to the submenu of an item. -IGUIContextMenu* CGUIContextMenu::getSubMenu(u32 idx) const -{ - if (idx >= Items.size()) - return 0; - - return Items[idx].SubMenu; -} - - -//! Returns command id of a menu item -s32 CGUIContextMenu::getItemCommandId(u32 idx) const -{ - if (idx >= Items.size()) - return -1; - - return Items[idx].CommandId; -} - - -//! Sets the command id of a menu item -void CGUIContextMenu::setItemCommandId(u32 idx, s32 id) -{ - if (idx >= Items.size()) - return; - - Items[idx].CommandId = id; -} - - -//! Writes attributes of the element. -void CGUIContextMenu::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const -{ - IGUIElement::serializeAttributes(out,options); - out->addPosition2d("Position", Pos); - - if (Parent->getType() == EGUIET_CONTEXT_MENU || Parent->getType() == EGUIET_MENU ) - { - const IGUIContextMenu* const ptr = (const IGUIContextMenu*)Parent; - // find the position of this item in its parent's list - u32 i; - // VC6 needs the cast for this - for (i=0; (i<ptr->getItemCount()) && (ptr->getSubMenu(i) != (const IGUIContextMenu*)this); ++i) - ; // do nothing - - out->addInt("ParentItem", i); - } - - // write out the item list - out->addInt("ItemCount", Items.size()); - - core::stringc tmp; - - for (u32 i=0; i < Items.size(); ++i) - { - tmp = "IsSeparator"; tmp += i; - out->addBool(tmp.c_str(), Items[i].IsSeparator); - - if (!Items[i].IsSeparator) - { - tmp = "Text"; tmp += i; - out->addString(tmp.c_str(), Items[i].Text.c_str()); - tmp = "CommandID"; tmp += i; - out->addInt(tmp.c_str(), Items[i].CommandId); - tmp = "Enabled"; tmp += i; - out->addBool(tmp.c_str(), Items[i].Enabled); - } - } -} - - -//! Reads attributes of the element -void CGUIContextMenu::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) -{ - IGUIElement::deserializeAttributes(in,options); - - Pos = in->getAttributeAsPosition2d("Position"); - - // link to this item's parent - if (Parent && ( Parent->getType() == EGUIET_CONTEXT_MENU || Parent->getType() == EGUIET_MENU ) ) - ((CGUIContextMenu*)Parent)->setSubMenu(in->getAttributeAsInt("ParentItem"),this); - - - removeAllItems(); - - // read the item list - const s32 count = in->getAttributeAsInt("ItemCount"); - - for (s32 i=0; i<count; ++i) - { - core::stringc tmp; - core::stringw txt; - s32 commandid; - bool enabled; - bool checked; - - tmp = "IsSeparator"; tmp += i; - if ( in->getAttributeAsBool(tmp.c_str()) ) - addSeparator(); - else - { - tmp = "Text"; tmp += i; - txt = in->getAttributeAsStringW(tmp.c_str()); - - tmp = "CommandID"; tmp += i; - commandid = in->getAttributeAsInt(tmp.c_str()); - - tmp = "Enabled"; tmp += i; - enabled = in->getAttributeAsBool(tmp.c_str()); - - tmp = "Checked"; tmp += i; - checked = in->getAttributeAsBool(tmp.c_str()); - - addItem(core::stringw(txt.c_str()).c_str(), commandid, enabled, false, checked); - } - } - - recalculateSize(); -} - - -// because sometimes the element has no parent at click time -void CGUIContextMenu::setEventParent(IGUIElement *parent) -{ - EventParent = parent; - - for (u32 i=0; i<Items.size(); ++i) - if (Items[i].SubMenu) - Items[i].SubMenu->setEventParent(parent); -} - - -bool CGUIContextMenu::hasOpenSubMenu() const -{ - for (u32 i=0; i<Items.size(); ++i) - if (Items[i].SubMenu && Items[i].SubMenu->isVisible()) - return true; - - return false; -} - - -void CGUIContextMenu::closeAllSubMenus() -{ - for (u32 i=0; i<Items.size(); ++i) - if (Items[i].SubMenu) - Items[i].SubMenu->setVisible(false); - - //HighLighted = -1; -} - - -} // end namespace -} // end namespace - -#endif // _IRR_COMPILE_WITH_GUI_ - diff --git a/irrlicht-1.6/source/Irrlicht/CGUIContextMenu.h b/irrlicht-1.6/source/Irrlicht/CGUIContextMenu.h deleted file mode 100644 index a71dc12d0..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIContextMenu.h +++ /dev/null @@ -1,151 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_CONTEXT_MENU_H_INCLUDED__ -#define __C_GUI_CONTEXT_MENU_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUIContextMenu.h" -#include "irrString.h" -#include "irrArray.h" -#include "IGUIFont.h" - -namespace irr -{ -namespace gui -{ - - //! GUI Context menu interface. - class CGUIContextMenu : public IGUIContextMenu - { - public: - - //! constructor - CGUIContextMenu(IGUIEnvironment* environment, - IGUIElement* parent, s32 id, core::rect<s32> rectangle, - bool getFocus = true, bool allowFocus = true); - - //! destructor - virtual ~CGUIContextMenu(); - - //! Returns amount of menu items - virtual u32 getItemCount() const; - - //! Adds a menu item. - virtual u32 addItem(const wchar_t* text, s32 commandid, - bool enabled, bool hasSubMenu, bool checked); - - //! Adds a separator item to the menu - virtual void addSeparator(); - - //! Returns text of the menu item. - virtual const wchar_t* getItemText(u32 idx) const; - - //! Sets text of the menu item. - virtual void setItemText(u32 idx, const wchar_t* text); - - //! Returns if a menu item is enabled - virtual bool isItemEnabled(u32 idx) const; - - //! Sets if the menu item should be enabled. - virtual void setItemEnabled(u32 idx, bool enabled); - - //! Returns if a menu item is checked - virtual bool isItemChecked(u32 idx) const; - - //! Sets if the menu item should be checked. - virtual void setItemChecked(u32 idx, bool enabled); - - //! Removes a menu item - virtual void removeItem(u32 idx); - - //! Removes all menu items - virtual void removeAllItems(); - - //! called if an event happened. - virtual bool OnEvent(const SEvent& event); - - //! draws the element and its children - virtual void draw(); - - //! Returns the selected item in the menu - virtual s32 getSelectedItem() const; - - //! Returns a pointer to the submenu of an item. - //! \return Pointer to the submenu of an item. - virtual IGUIContextMenu* getSubMenu(u32 idx) const; - - //! Sets the visible state of this element. - virtual void setVisible(bool visible); - - //! Returns command id of a menu item - virtual s32 getItemCommandId(u32 idx) const; - - //! Sets the command id of a menu item - virtual void setItemCommandId(u32 idx, s32 id); - - //! Adds a sub menu from an element that already exists. - virtual void setSubMenu(u32 index, CGUIContextMenu* menu); - - //! Writes attributes of the element. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; - - //! Reads attributes of the element - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - - protected: - - void closeAllSubMenus(); - bool hasOpenSubMenu() const; - - struct SItem - { - core::stringw Text; - bool IsSeparator; - bool Enabled; - bool Checked; - core::dimension2d<u32> Dim; - s32 PosY; - CGUIContextMenu* SubMenu; - s32 CommandId; - }; - - virtual void recalculateSize(); - - //! returns true, if an element was highlighted - virtual bool highlight(const core::position2d<s32>& p, bool canOpenSubMenu); - - //! sends a click Returns: - //! 0 if click went outside of the element, - //! 1 if a valid button was clicked, - //! 2 if a nonclickable element was clicked - virtual u32 sendClick(const core::position2d<s32>& p); - - //! returns the item highlight-area - virtual core::rect<s32> getHRect(const SItem& i, const core::rect<s32>& absolute) const; - - //! Gets drawing rect of Item - virtual core::rect<s32> getRect(const SItem& i, const core::rect<s32>& absolute) const; - - void setEventParent(IGUIElement *parent); - - core::array<SItem> Items; - core::position2d<s32> Pos; - IGUIElement* EventParent; - IGUIFont *LastFont; - s32 HighLighted; - u32 ChangeTime; - bool AllowFocus; - }; - - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - -#endif // __C_GUI_CONTEXT_MENU_H_INCLUDED__ - diff --git a/irrlicht-1.6/source/Irrlicht/CGUIEditBox.cpp b/irrlicht-1.6/source/Irrlicht/CGUIEditBox.cpp deleted file mode 100644 index 4976df26e..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIEditBox.cpp +++ /dev/null @@ -1,1430 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUIEditBox.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUISkin.h" -#include "IGUIEnvironment.h" -#include "IGUIFont.h" -#include "IVideoDriver.h" -#include "rect.h" -#include "os.h" -#include "Keycodes.h" - -/* - todo: - optional scrollbars - ctrl+left/right to select word - double click/ctrl click: word select + drag to select whole words, triple click to select line - optional? dragging selected text - numerical -*/ - -namespace irr -{ -namespace gui -{ - -//! constructor -CGUIEditBox::CGUIEditBox(const wchar_t* text, bool border, - IGUIEnvironment* environment, IGUIElement* parent, s32 id, - const core::rect<s32>& rectangle) - : IGUIEditBox(environment, parent, id, rectangle), MouseMarking(false), - Border(border), OverrideColorEnabled(false), MarkBegin(0), MarkEnd(0), - OverrideColor(video::SColor(101,255,255,255)), OverrideFont(0), LastBreakFont(0), - Operator(0), BlinkStartTime(0), CursorPos(0), HScrollPos(0), VScrollPos(0), Max(0), - WordWrap(false), MultiLine(false), AutoScroll(true), PasswordBox(false), - PasswordChar(L'*'), HAlign(EGUIA_UPPERLEFT), VAlign(EGUIA_CENTER), - CurrentTextRect(0,0,1,1), FrameRect(rectangle) -{ - #ifdef _DEBUG - setDebugName("CGUIEditBox"); - #endif - - Text = text; - - if (Environment) - Operator = Environment->getOSOperator(); - - if (Operator) - Operator->grab(); - - // this element can be tabbed to - setTabStop(true); - setTabOrder(-1); - - IGUISkin *skin = 0; - if (Environment) - skin = Environment->getSkin(); - if (Border && skin) - { - FrameRect.UpperLeftCorner.X += skin->getSize(EGDS_TEXT_DISTANCE_X)+1; - FrameRect.UpperLeftCorner.Y += skin->getSize(EGDS_TEXT_DISTANCE_Y)+1; - FrameRect.LowerRightCorner.X -= skin->getSize(EGDS_TEXT_DISTANCE_X)+1; - FrameRect.LowerRightCorner.Y -= skin->getSize(EGDS_TEXT_DISTANCE_Y)+1; - } - - breakText(); - - calculateScrollPos(); -} - - -//! destructor -CGUIEditBox::~CGUIEditBox() -{ - if (OverrideFont) - OverrideFont->drop(); - - if (Operator) - Operator->drop(); -} - - -//! Sets another skin independent font. -void CGUIEditBox::setOverrideFont(IGUIFont* font) -{ - if (OverrideFont == font) - return; - - if (OverrideFont) - OverrideFont->drop(); - - OverrideFont = font; - - if (OverrideFont) - OverrideFont->grab(); - - breakText(); -} - - -//! Sets another color for the text. -void CGUIEditBox::setOverrideColor(video::SColor color) -{ - OverrideColor = color; - OverrideColorEnabled = true; -} - - -//! Turns the border on or off -void CGUIEditBox::setDrawBorder(bool border) -{ - Border = border; -} - - -//! Sets if the text should use the overide color or the color in the gui skin. -void CGUIEditBox::enableOverrideColor(bool enable) -{ - OverrideColorEnabled = enable; -} - - -//! Enables or disables word wrap -void CGUIEditBox::setWordWrap(bool enable) -{ - WordWrap = enable; - breakText(); -} - - -void CGUIEditBox::updateAbsolutePosition() -{ - core::rect<s32> oldAbsoluteRect(AbsoluteRect); - IGUIElement::updateAbsolutePosition(); - if ( oldAbsoluteRect != AbsoluteRect ) - { - breakText(); - } -} - - -//! Checks if word wrap is enabled -bool CGUIEditBox::isWordWrapEnabled() const -{ - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return WordWrap; -} - - -//! Enables or disables newlines. -void CGUIEditBox::setMultiLine(bool enable) -{ - MultiLine = enable; -} - - -//! Checks if multi line editing is enabled -bool CGUIEditBox::isMultiLineEnabled() const -{ - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return MultiLine; -} - - -void CGUIEditBox::setPasswordBox(bool passwordBox, wchar_t passwordChar) -{ - PasswordBox = passwordBox; - if (PasswordBox) - { - PasswordChar = passwordChar; - setMultiLine(false); - setWordWrap(false); - BrokenText.clear(); - } -} - - -bool CGUIEditBox::isPasswordBox() const -{ - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return PasswordBox; -} - - -//! Sets text justification -void CGUIEditBox::setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical) -{ - HAlign = horizontal; - VAlign = vertical; -} - - -//! called if an event happened. -bool CGUIEditBox::OnEvent(const SEvent& event) -{ - if (IsEnabled) - { - - switch(event.EventType) - { - case EET_GUI_EVENT: - if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST) - { - if (event.GUIEvent.Caller == this) - { - MouseMarking = false; - setTextMarkers(0,0); - } - } - break; - case EET_KEY_INPUT_EVENT: - if (processKey(event)) - return true; - break; - case EET_MOUSE_INPUT_EVENT: - if (processMouse(event)) - return true; - break; - default: - break; - } - } - - return IGUIElement::OnEvent(event); -} - - -bool CGUIEditBox::processKey(const SEvent& event) -{ - if (!event.KeyInput.PressedDown) - return false; - - bool textChanged = false; - s32 newMarkBegin = MarkBegin; - s32 newMarkEnd = MarkEnd; - - // control shortcut handling - - if (event.KeyInput.Control) - { - // german backlash '\' entered with control + '?' - if ( event.KeyInput.Char == '\\' ) - { - inputChar(event.KeyInput.Char); - return true; - } - - switch(event.KeyInput.Key) - { - case KEY_KEY_A: - // select all - newMarkBegin = 0; - newMarkEnd = Text.size(); - break; - case KEY_KEY_C: - // copy to clipboard - if (!PasswordBox && Operator && MarkBegin != MarkEnd) - { - const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; - const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; - - core::stringc s; - s = Text.subString(realmbgn, realmend - realmbgn).c_str(); - Operator->copyToClipboard(s.c_str()); - } - break; - case KEY_KEY_X: - // cut to the clipboard - if (!PasswordBox && Operator && MarkBegin != MarkEnd) - { - const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; - const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; - - // copy - core::stringc sc; - sc = Text.subString(realmbgn, realmend - realmbgn).c_str(); - Operator->copyToClipboard(sc.c_str()); - - if (IsEnabled) - { - // delete - core::stringw s; - s = Text.subString(0, realmbgn); - s.append( Text.subString(realmend, Text.size()-realmend) ); - Text = s; - - CursorPos = realmbgn; - newMarkBegin = 0; - newMarkEnd = 0; - textChanged = true; - } - } - break; - case KEY_KEY_V: - if ( !IsEnabled ) - break; - - // paste from the clipboard - if (Operator) - { - const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; - const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; - - // add new character - const c8* p = Operator->getTextFromClipboard(); - if (p) - { - if (MarkBegin == MarkEnd) - { - // insert text - core::stringw s = Text.subString(0, CursorPos); - s.append(p); - s.append( Text.subString(CursorPos, Text.size()-CursorPos) ); - - if (!Max || s.size()<=Max) // thx to Fish FH for fix - { - Text = s; - s = p; - CursorPos += s.size(); - } - } - else - { - // replace text - - core::stringw s = Text.subString(0, realmbgn); - s.append(p); - s.append( Text.subString(realmend, Text.size()-realmend) ); - - if (!Max || s.size()<=Max) // thx to Fish FH for fix - { - Text = s; - s = p; - CursorPos = realmbgn + s.size(); - } - } - } - - newMarkBegin = 0; - newMarkEnd = 0; - textChanged = true; - } - break; - case KEY_HOME: - // move/highlight to start of text - if (event.KeyInput.Shift) - { - newMarkEnd = CursorPos; - newMarkBegin = 0; - CursorPos = 0; - } - else - { - CursorPos = 0; - newMarkBegin = 0; - newMarkEnd = 0; - } - break; - case KEY_END: - // move/highlight to end of text - if (event.KeyInput.Shift) - { - newMarkBegin = CursorPos; - newMarkEnd = Text.size(); - CursorPos = 0; - } - else - { - CursorPos = Text.size(); - newMarkBegin = 0; - newMarkEnd = 0; - } - break; - default: - return false; - } - } - // default keyboard handling - else - switch(event.KeyInput.Key) - { - case KEY_END: - { - s32 p = Text.size(); - if (WordWrap || MultiLine) - { - p = getLineFromPos(CursorPos); - p = BrokenTextPositions[p] + (s32)BrokenText[p].size(); - if (p > 0 && (Text[p-1] == L'\r' || Text[p-1] == L'\n' )) - p-=1; - } - - if (event.KeyInput.Shift) - { - if (MarkBegin == MarkEnd) - newMarkBegin = CursorPos; - - newMarkEnd = p; - } - else - { - newMarkBegin = 0; - newMarkEnd = 0; - } - CursorPos = p; - BlinkStartTime = os::Timer::getTime(); - } - break; - case KEY_HOME: - { - - s32 p = 0; - if (WordWrap || MultiLine) - { - p = getLineFromPos(CursorPos); - p = BrokenTextPositions[p]; - } - - if (event.KeyInput.Shift) - { - if (MarkBegin == MarkEnd) - newMarkBegin = CursorPos; - newMarkEnd = p; - } - else - { - newMarkBegin = 0; - newMarkEnd = 0; - } - CursorPos = p; - BlinkStartTime = os::Timer::getTime(); - } - break; - case KEY_RETURN: - if (MultiLine) - { - inputChar(L'\n'); - return true; - } - else - { - sendGuiEvent( EGET_EDITBOX_ENTER ); - } - break; - case KEY_LEFT: - - if (event.KeyInput.Shift) - { - if (CursorPos > 0) - { - if (MarkBegin == MarkEnd) - newMarkBegin = CursorPos; - - newMarkEnd = CursorPos-1; - } - } - else - { - newMarkBegin = 0; - newMarkEnd = 0; - } - - if (CursorPos > 0) CursorPos--; - BlinkStartTime = os::Timer::getTime(); - break; - - case KEY_RIGHT: - if (event.KeyInput.Shift) - { - if (Text.size() > (u32)CursorPos) - { - if (MarkBegin == MarkEnd) - newMarkBegin = CursorPos; - - newMarkEnd = CursorPos+1; - } - } - else - { - newMarkBegin = 0; - newMarkEnd = 0; - } - - if (Text.size() > (u32)CursorPos) CursorPos++; - BlinkStartTime = os::Timer::getTime(); - break; - case KEY_UP: - if (MultiLine || (WordWrap && BrokenText.size() > 1) ) - { - s32 lineNo = getLineFromPos(CursorPos); - s32 mb = (MarkBegin == MarkEnd) ? CursorPos : (MarkBegin > MarkEnd ? MarkBegin : MarkEnd); - if (lineNo > 0) - { - s32 cp = CursorPos - BrokenTextPositions[lineNo]; - if ((s32)BrokenText[lineNo-1].size() < cp) - CursorPos = BrokenTextPositions[lineNo-1] + (s32)BrokenText[lineNo-1].size()-1; - else - CursorPos = BrokenTextPositions[lineNo-1] + cp; - } - - if (event.KeyInput.Shift) - { - newMarkBegin = mb; - newMarkEnd = CursorPos; - } - else - { - newMarkBegin = 0; - newMarkEnd = 0; - } - - } - else - { - return false; - } - break; - case KEY_DOWN: - if (MultiLine || (WordWrap && BrokenText.size() > 1) ) - { - s32 lineNo = getLineFromPos(CursorPos); - s32 mb = (MarkBegin == MarkEnd) ? CursorPos : (MarkBegin < MarkEnd ? MarkBegin : MarkEnd); - if (lineNo < (s32)BrokenText.size()-1) - { - s32 cp = CursorPos - BrokenTextPositions[lineNo]; - if ((s32)BrokenText[lineNo+1].size() < cp) - CursorPos = BrokenTextPositions[lineNo+1] + BrokenText[lineNo+1].size()-1; - else - CursorPos = BrokenTextPositions[lineNo+1] + cp; - } - - if (event.KeyInput.Shift) - { - newMarkBegin = mb; - newMarkEnd = CursorPos; - } - else - { - newMarkBegin = 0; - newMarkEnd = 0; - } - - } - else - { - return false; - } - break; - - case KEY_BACK: - if ( !this->IsEnabled ) - break; - - if (Text.size()) - { - core::stringw s; - - if (MarkBegin != MarkEnd) - { - // delete marked text - const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; - const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; - - s = Text.subString(0, realmbgn); - s.append( Text.subString(realmend, Text.size()-realmend) ); - Text = s; - - CursorPos = realmbgn; - } - else - { - // delete text behind cursor - if (CursorPos>0) - s = Text.subString(0, CursorPos-1); - else - s = L""; - s.append( Text.subString(CursorPos, Text.size()-CursorPos) ); - Text = s; - --CursorPos; - } - - if (CursorPos < 0) - CursorPos = 0; - BlinkStartTime = os::Timer::getTime(); - newMarkBegin = 0; - newMarkEnd = 0; - textChanged = true; - } - break; - case KEY_DELETE: - if ( !this->IsEnabled ) - break; - - if (Text.size() != 0) - { - core::stringw s; - - if (MarkBegin != MarkEnd) - { - // delete marked text - const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; - const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; - - s = Text.subString(0, realmbgn); - s.append( Text.subString(realmend, Text.size()-realmend) ); - Text = s; - - CursorPos = realmbgn; - } - else - { - // delete text before cursor - s = Text.subString(0, CursorPos); - s.append( Text.subString(CursorPos+1, Text.size()-CursorPos-1) ); - Text = s; - } - - if (CursorPos > (s32)Text.size()) - CursorPos = (s32)Text.size(); - - BlinkStartTime = os::Timer::getTime(); - newMarkBegin = 0; - newMarkEnd = 0; - textChanged = true; - } - break; - - case KEY_ESCAPE: - case KEY_TAB: - case KEY_SHIFT: - case KEY_F1: - case KEY_F2: - case KEY_F3: - case KEY_F4: - case KEY_F5: - case KEY_F6: - case KEY_F7: - case KEY_F8: - case KEY_F9: - case KEY_F10: - case KEY_F11: - case KEY_F12: - case KEY_F13: - case KEY_F14: - case KEY_F15: - case KEY_F16: - case KEY_F17: - case KEY_F18: - case KEY_F19: - case KEY_F20: - case KEY_F21: - case KEY_F22: - case KEY_F23: - case KEY_F24: - // ignore these keys - return false; - - default: - inputChar(event.KeyInput.Char); - return true; - } - - // Set new text markers - setTextMarkers( newMarkBegin, newMarkEnd ); - - // break the text if it has changed - if (textChanged) - { - breakText(); - sendGuiEvent(EGET_EDITBOX_CHANGED); - } - - calculateScrollPos(); - - return true; -} - - -//! draws the element and its children -void CGUIEditBox::draw() -{ - if (!IsVisible) - return; - - const bool focus = Environment->hasFocus(this); - - IGUISkin* skin = Environment->getSkin(); - if (!skin) - return; - - FrameRect = AbsoluteRect; - - // draw the border - - if (Border) - { - skin->draw3DSunkenPane(this, skin->getColor(EGDC_WINDOW), - false, true, FrameRect, &AbsoluteClippingRect); - - FrameRect.UpperLeftCorner.X += skin->getSize(EGDS_TEXT_DISTANCE_X)+1; - FrameRect.UpperLeftCorner.Y += skin->getSize(EGDS_TEXT_DISTANCE_Y)+1; - FrameRect.LowerRightCorner.X -= skin->getSize(EGDS_TEXT_DISTANCE_X)+1; - FrameRect.LowerRightCorner.Y -= skin->getSize(EGDS_TEXT_DISTANCE_Y)+1; - } - core::rect<s32> localClipRect = FrameRect; - localClipRect.clipAgainst(AbsoluteClippingRect); - - // draw the text - - IGUIFont* font = OverrideFont; - if (!OverrideFont) - font = skin->getFont(); - - s32 cursorLine = 0; - s32 charcursorpos = 0; - - if (font) - { - if (LastBreakFont != font) - { - breakText(); - } - - // calculate cursor pos - - core::stringw *txtLine = &Text; - s32 startPos = 0; - - core::stringw s, s2; - - // get mark position - const bool ml = (!PasswordBox && (WordWrap || MultiLine)); - const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; - const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; - const s32 hlineStart = ml ? getLineFromPos(realmbgn) : 0; - const s32 hlineCount = ml ? getLineFromPos(realmend) - hlineStart + 1 : 1; - const s32 lineCount = ml ? BrokenText.size() : 1; - - // Save the override color information. - // Then, alter it if the edit box is disabled. - const bool prevOver = OverrideColorEnabled; - const video::SColor prevColor = OverrideColor; - - if (Text.size()) - { - if (!IsEnabled && !OverrideColorEnabled) - { - OverrideColorEnabled = true; - OverrideColor = skin->getColor(EGDC_GRAY_TEXT); - } - - for (s32 i=0; i < lineCount; ++i) - { - setTextRect(i); - - // clipping test - don't draw anything outside the visible area - core::rect<s32> c = localClipRect; - c.clipAgainst(CurrentTextRect); - if (!c.isValid()) - continue; - - // get current line - if (PasswordBox) - { - if (BrokenText.size() != 1) - { - BrokenText.clear(); - BrokenText.push_back(core::stringw()); - } - if (BrokenText[0].size() != Text.size()) - { - BrokenText[0] = Text; - for (u32 q = 0; q < Text.size(); ++q) - { - BrokenText[0] [q] = PasswordChar; - } - } - txtLine = &BrokenText[0]; - startPos = 0; - } - else - { - txtLine = ml ? &BrokenText[i] : &Text; - startPos = ml ? BrokenTextPositions[i] : 0; - } - - - // draw normal text - font->draw(txtLine->c_str(), CurrentTextRect, - OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_BUTTON_TEXT), - false, true, &localClipRect); - - // draw mark and marked text - if (focus && MarkBegin != MarkEnd && i >= hlineStart && i < hlineStart + hlineCount) - { - - s32 mbegin = 0, mend = 0; - s32 lineStartPos = 0, lineEndPos = txtLine->size(); - - if (i == hlineStart) - { - // highlight start is on this line - s = txtLine->subString(0, realmbgn - startPos); - mbegin = font->getDimension(s.c_str()).Width; - - // deal with kerning - mbegin += font->getKerningWidth( - &((*txtLine)[realmbgn - startPos]), - realmbgn - startPos > 0 ? &((*txtLine)[realmbgn - startPos - 1]) : 0); - - lineStartPos = realmbgn - startPos; - } - if (i == hlineStart + hlineCount - 1) - { - // highlight end is on this line - s2 = txtLine->subString(0, realmend - startPos); - mend = font->getDimension(s2.c_str()).Width; - lineEndPos = (s32)s2.size(); - } - else - mend = font->getDimension(txtLine->c_str()).Width; - - CurrentTextRect.UpperLeftCorner.X += mbegin; - CurrentTextRect.LowerRightCorner.X = CurrentTextRect.UpperLeftCorner.X + mend - mbegin; - - // draw mark - skin->draw2DRectangle(this, skin->getColor(EGDC_HIGH_LIGHT), CurrentTextRect, &localClipRect); - - // draw marked text - s = txtLine->subString(lineStartPos, lineEndPos - lineStartPos); - - if (s.size()) - font->draw(s.c_str(), CurrentTextRect, - OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_HIGH_LIGHT_TEXT), - false, true, &localClipRect); - - } - } - - // Return the override color information to its previous settings. - OverrideColorEnabled = prevOver; - OverrideColor = prevColor; - } - - // draw cursor - - if (WordWrap || MultiLine) - { - cursorLine = getLineFromPos(CursorPos); - txtLine = &BrokenText[cursorLine]; - startPos = BrokenTextPositions[cursorLine]; - } - s = txtLine->subString(0,CursorPos-startPos); - charcursorpos = font->getDimension(s.c_str()).Width + - font->getKerningWidth(L"_", CursorPos-startPos > 0 ? &((*txtLine)[CursorPos-startPos-1]) : 0); - - if (focus && (os::Timer::getTime() - BlinkStartTime) % 700 < 350) - { - setTextRect(cursorLine); - CurrentTextRect.UpperLeftCorner.X += charcursorpos; - - font->draw(L"_", CurrentTextRect, - OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_BUTTON_TEXT), - false, true, &localClipRect); - } - } - - // draw children - IGUIElement::draw(); -} - - -//! Sets the new caption of this element. -void CGUIEditBox::setText(const wchar_t* text) -{ - Text = text; - CursorPos = 0; - HScrollPos = 0; - breakText(); -} - - -//! Enables or disables automatic scrolling with cursor position -//! \param enable: If set to true, the text will move around with the cursor position -void CGUIEditBox::setAutoScroll(bool enable) -{ - AutoScroll = enable; -} - - -//! Checks to see if automatic scrolling is enabled -//! \return true if automatic scrolling is enabled, false if not -bool CGUIEditBox::isAutoScrollEnabled() const -{ - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return AutoScroll; -} - - -//! Gets the area of the text in the edit box -//! \return Returns the size in pixels of the text -core::dimension2du CGUIEditBox::getTextDimension() -{ - core::rect<s32> ret; - - setTextRect(0); - ret = CurrentTextRect; - - for (u32 i=1; i < BrokenText.size(); ++i) - { - setTextRect(i); - ret.addInternalPoint(CurrentTextRect.UpperLeftCorner); - ret.addInternalPoint(CurrentTextRect.LowerRightCorner); - } - - return core::dimension2du(ret.getSize()); -} - - -//! Sets the maximum amount of characters which may be entered in the box. -//! \param max: Maximum amount of characters. If 0, the character amount is -//! infinity. -void CGUIEditBox::setMax(u32 max) -{ - Max = max; - - if (Text.size() > Max && Max != 0) - Text = Text.subString(0, Max); -} - - -//! Returns maximum amount of characters, previously set by setMax(); -u32 CGUIEditBox::getMax() const -{ - return Max; -} - - -bool CGUIEditBox::processMouse(const SEvent& event) -{ - switch(event.MouseInput.Event) - { - case irr::EMIE_LMOUSE_LEFT_UP: - if (Environment->hasFocus(this)) - { - CursorPos = getCursorPos(event.MouseInput.X, event.MouseInput.Y); - if (MouseMarking) - { - setTextMarkers( MarkBegin, CursorPos ); - } - MouseMarking = false; - calculateScrollPos(); - return true; - } - break; - case irr::EMIE_MOUSE_MOVED: - { - if (MouseMarking) - { - CursorPos = getCursorPos(event.MouseInput.X, event.MouseInput.Y); - setTextMarkers( MarkBegin, CursorPos ); - calculateScrollPos(); - return true; - } - } - break; - case EMIE_LMOUSE_PRESSED_DOWN: - if (!Environment->hasFocus(this)) - { - BlinkStartTime = os::Timer::getTime(); - MouseMarking = true; - CursorPos = getCursorPos(event.MouseInput.X, event.MouseInput.Y); - setTextMarkers(CursorPos, CursorPos ); - calculateScrollPos(); - return true; - } - else - { - if (!AbsoluteClippingRect.isPointInside( - core::position2d<s32>(event.MouseInput.X, event.MouseInput.Y))) - { - return false; - } - else - { - // move cursor - CursorPos = getCursorPos(event.MouseInput.X, event.MouseInput.Y); - - s32 newMarkBegin = MarkBegin; - if (!MouseMarking) - newMarkBegin = CursorPos; - - MouseMarking = true; - setTextMarkers( newMarkBegin, CursorPos); - calculateScrollPos(); - return true; - } - } - default: - break; - } - - return false; -} - - -s32 CGUIEditBox::getCursorPos(s32 x, s32 y) -{ - IGUIFont* font = OverrideFont; - IGUISkin* skin = Environment->getSkin(); - if (!OverrideFont) - font = skin->getFont(); - - const u32 lineCount = (WordWrap || MultiLine) ? BrokenText.size() : 1; - - core::stringw *txtLine=0; - s32 startPos=0; - x+=3; - - for (u32 i=0; i < lineCount; ++i) - { - setTextRect(i); - if (i == 0 && y < CurrentTextRect.UpperLeftCorner.Y) - y = CurrentTextRect.UpperLeftCorner.Y; - if (i == lineCount - 1 && y > CurrentTextRect.LowerRightCorner.Y ) - y = CurrentTextRect.LowerRightCorner.Y; - - // is it inside this region? - if (y >= CurrentTextRect.UpperLeftCorner.Y && y <= CurrentTextRect.LowerRightCorner.Y) - { - // we've found the clicked line - txtLine = (WordWrap || MultiLine) ? &BrokenText[i] : &Text; - startPos = (WordWrap || MultiLine) ? BrokenTextPositions[i] : 0; - break; - } - } - - if (x < CurrentTextRect.UpperLeftCorner.X) - x = CurrentTextRect.UpperLeftCorner.X; - - s32 idx = font->getCharacterFromPos(Text.c_str(), x - CurrentTextRect.UpperLeftCorner.X); - - // click was on or left of the line - if (idx != -1) - return idx + startPos; - - // click was off the right edge of the line, go to end. - return txtLine->size() + startPos; -} - - -//! Breaks the single text line. -void CGUIEditBox::breakText() -{ - IGUISkin* skin = Environment->getSkin(); - - if ((!WordWrap && !MultiLine) || !skin) - return; - - BrokenText.clear(); // need to reallocate :/ - BrokenTextPositions.set_used(0); - - IGUIFont* font = OverrideFont; - if (!OverrideFont) - font = skin->getFont(); - - if (!font) - return; - - LastBreakFont = font; - - core::stringw line; - core::stringw word; - core::stringw whitespace; - s32 lastLineStart = 0; - s32 size = Text.size(); - s32 length = 0; - s32 elWidth = RelativeRect.getWidth() - 6; - wchar_t c; - - for (s32 i=0; i<size; ++i) - { - c = Text[i]; - bool lineBreak = false; - - if (c == L'\r') // Mac or Windows breaks - { - lineBreak = true; - c = ' '; - if (Text[i+1] == L'\n') // Windows breaks - { - Text.erase(i+1); - --size; - } - } - else if (c == L'\n') // Unix breaks - { - lineBreak = true; - c = ' '; - } - - // don't break if we're not a multi-line edit box - if (!MultiLine) - lineBreak = false; - - if (c == L' ' || c == 0 || i == (size-1)) - { - if (word.size()) - { - // here comes the next whitespace, look if - // we can break the last word to the next line. - s32 whitelgth = font->getDimension(whitespace.c_str()).Width; - s32 worldlgth = font->getDimension(word.c_str()).Width; - - if (WordWrap && length + worldlgth + whitelgth > elWidth) - { - // break to next line - length = worldlgth; - BrokenText.push_back(line); - BrokenTextPositions.push_back(lastLineStart); - lastLineStart = i - (s32)word.size(); - line = word; - } - else - { - // add word to line - line += whitespace; - line += word; - length += whitelgth + worldlgth; - } - - word = L""; - whitespace = L""; - } - - whitespace += c; - - // compute line break - if (lineBreak) - { - line += whitespace; - line += word; - BrokenText.push_back(line); - BrokenTextPositions.push_back(lastLineStart); - lastLineStart = i+1; - line = L""; - word = L""; - whitespace = L""; - length = 0; - } - } - else - { - // yippee this is a word.. - word += c; - } - } - - line += whitespace; - line += word; - BrokenText.push_back(line); - BrokenTextPositions.push_back(lastLineStart); -} - - -void CGUIEditBox::setTextRect(s32 line) -{ - core::dimension2du d; - - IGUISkin* skin = Environment->getSkin(); - if (!skin) - return; - - IGUIFont* font = OverrideFont ? OverrideFont : skin->getFont(); - - if (!font) - return; - - // get text dimension - const u32 lineCount = (WordWrap || MultiLine) ? BrokenText.size() : 1; - if (WordWrap || MultiLine) - { - d = font->getDimension(BrokenText[line].c_str()); - } - else - { - d = font->getDimension(Text.c_str()); - d.Height = AbsoluteRect.getHeight(); - } - d.Height += font->getKerningHeight(); - - // justification - switch (HAlign) - { - case EGUIA_CENTER: - // align to h centre - CurrentTextRect.UpperLeftCorner.X = (FrameRect.getWidth()/2) - (d.Width/2); - CurrentTextRect.LowerRightCorner.X = (FrameRect.getWidth()/2) + (d.Width/2); - break; - case EGUIA_LOWERRIGHT: - // align to right edge - CurrentTextRect.UpperLeftCorner.X = FrameRect.getWidth() - d.Width; - CurrentTextRect.LowerRightCorner.X = FrameRect.getWidth(); - break; - default: - // align to left edge - CurrentTextRect.UpperLeftCorner.X = 0; - CurrentTextRect.LowerRightCorner.X = d.Width; - - } - - switch (VAlign) - { - case EGUIA_CENTER: - // align to v centre - CurrentTextRect.UpperLeftCorner.Y = - (FrameRect.getHeight()/2) - (lineCount*d.Height)/2 + d.Height*line; - break; - case EGUIA_LOWERRIGHT: - // align to bottom edge - CurrentTextRect.UpperLeftCorner.Y = - FrameRect.getHeight() - lineCount*d.Height + d.Height*line; - break; - default: - // align to top edge - CurrentTextRect.UpperLeftCorner.Y = d.Height*line; - break; - } - - CurrentTextRect.UpperLeftCorner.X -= HScrollPos; - CurrentTextRect.LowerRightCorner.X -= HScrollPos; - CurrentTextRect.UpperLeftCorner.Y -= VScrollPos; - CurrentTextRect.LowerRightCorner.Y = CurrentTextRect.UpperLeftCorner.Y + d.Height; - - CurrentTextRect += FrameRect.UpperLeftCorner; - -} - - -s32 CGUIEditBox::getLineFromPos(s32 pos) -{ - if (!WordWrap && !MultiLine) - return 0; - - s32 i=0; - while (i < (s32)BrokenTextPositions.size()) - { - if (BrokenTextPositions[i] > pos) - return i-1; - ++i; - } - return (s32)BrokenTextPositions.size() - 1; -} - - -void CGUIEditBox::inputChar(wchar_t c) -{ - if (!IsEnabled) - return; - - if (c != 0) - { - if (Text.size() < Max || Max == 0) - { - core::stringw s; - - if (MarkBegin != MarkEnd) - { - // replace marked text - const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; - const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; - - s = Text.subString(0, realmbgn); - s.append(c); - s.append( Text.subString(realmend, Text.size()-realmend) ); - Text = s; - CursorPos = realmbgn+1; - } - else - { - // add new character - s = Text.subString(0, CursorPos); - s.append(c); - s.append( Text.subString(CursorPos, Text.size()-CursorPos) ); - Text = s; - ++CursorPos; - } - - BlinkStartTime = os::Timer::getTime(); - setTextMarkers(0, 0); - } - } - breakText(); - sendGuiEvent(EGET_EDITBOX_CHANGED); - calculateScrollPos(); -} - - -void CGUIEditBox::calculateScrollPos() -{ - if (!AutoScroll) - return; - - // calculate horizontal scroll position - s32 cursLine = getLineFromPos(CursorPos); - setTextRect(cursLine); - - // don't do horizontal scrolling when wordwrap is enabled. - if (!WordWrap) - { - // get cursor position - IGUISkin* skin = Environment->getSkin(); - if (!skin) - return; - IGUIFont* font = OverrideFont ? OverrideFont : skin->getFont(); - if (!font) - return; - - core::stringw *txtLine = MultiLine ? &BrokenText[cursLine] : &Text; - s32 cPos = MultiLine ? CursorPos - BrokenTextPositions[cursLine] : CursorPos; - - s32 cStart = CurrentTextRect.UpperLeftCorner.X + HScrollPos + - font->getDimension(txtLine->subString(0, cPos).c_str()).Width; - - s32 cEnd = cStart + font->getDimension(L"_ ").Width; - - if (FrameRect.LowerRightCorner.X < cEnd) - HScrollPos = cEnd - FrameRect.LowerRightCorner.X; - else if (FrameRect.UpperLeftCorner.X > cStart) - HScrollPos = cStart - FrameRect.UpperLeftCorner.X; - else - HScrollPos = 0; - - // todo: adjust scrollbar - } - - // vertical scroll position - if (FrameRect.LowerRightCorner.Y < CurrentTextRect.LowerRightCorner.Y + VScrollPos) - VScrollPos = CurrentTextRect.LowerRightCorner.Y - FrameRect.LowerRightCorner.Y + VScrollPos; - - else if (FrameRect.UpperLeftCorner.Y > CurrentTextRect.UpperLeftCorner.Y + VScrollPos) - VScrollPos = CurrentTextRect.UpperLeftCorner.Y - FrameRect.UpperLeftCorner.Y + VScrollPos; - else - VScrollPos = 0; - - // todo: adjust scrollbar -} - -//! set text markers -void CGUIEditBox::setTextMarkers(s32 begin, s32 end) -{ - if ( begin != MarkBegin || end != MarkEnd ) - { - MarkBegin = begin; - MarkEnd = end; - sendGuiEvent(EGET_EDITBOX_MARKING_CHANGED); - } -} - -//! send some gui event to parent -void CGUIEditBox::sendGuiEvent(EGUI_EVENT_TYPE type) -{ - if ( Parent ) - { - SEvent e; - e.EventType = EET_GUI_EVENT; - e.GUIEvent.Caller = this; - e.GUIEvent.Element = 0; - e.GUIEvent.EventType = type; - - Parent->OnEvent(e); - } -} - -//! Writes attributes of the element. -void CGUIEditBox::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const -{ - // IGUIEditBox::serializeAttributes(out,options); - - out->addBool ("OverrideColorEnabled",OverrideColorEnabled ); - out->addColor ("OverrideColor", OverrideColor); - // out->addFont("OverrideFont",OverrideFont); - out->addInt ("MaxChars", Max); - out->addBool ("WordWrap", WordWrap); - out->addBool ("MultiLine", MultiLine); - out->addBool ("AutoScroll", AutoScroll); - out->addBool ("PasswordBox", PasswordBox); - core::stringw ch = L" "; - ch[0] = PasswordChar; - out->addString("PasswordChar", ch.c_str()); - out->addEnum ("HTextAlign", HAlign, GUIAlignmentNames); - out->addEnum ("VTextAlign", VAlign, GUIAlignmentNames); - - IGUIEditBox::serializeAttributes(out,options); -} - - -//! Reads attributes of the element -void CGUIEditBox::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) -{ - IGUIEditBox::deserializeAttributes(in,options); - - setOverrideColor(in->getAttributeAsColor("OverrideColor")); - enableOverrideColor(in->getAttributeAsBool("OverrideColorEnabled")); - setMax(in->getAttributeAsInt("MaxChars")); - setWordWrap(in->getAttributeAsBool("WordWrap")); - setMultiLine(in->getAttributeAsBool("MultiLine")); - setAutoScroll(in->getAttributeAsBool("AutoScroll")); - core::stringw ch = in->getAttributeAsStringW("PasswordChar"); - - if (!ch.size()) - setPasswordBox(in->getAttributeAsBool("PasswordBox")); - else - setPasswordBox(in->getAttributeAsBool("PasswordBox"), ch[0]); - - setTextAlignment( (EGUI_ALIGNMENT) in->getAttributeAsEnumeration("HTextAlign", GUIAlignmentNames), - (EGUI_ALIGNMENT) in->getAttributeAsEnumeration("VTextAlign", GUIAlignmentNames)); - - // setOverrideFont(in->getAttributeAsFont("OverrideFont")); -} - - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - diff --git a/irrlicht-1.6/source/Irrlicht/CGUIEditBox.h b/irrlicht-1.6/source/Irrlicht/CGUIEditBox.h deleted file mode 100644 index cd558efb0..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIEditBox.h +++ /dev/null @@ -1,160 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_EDIT_BOX_H_INCLUDED__ -#define __C_GUI_EDIT_BOX_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUIEditBox.h" -#include "irrArray.h" -#include "IOSOperator.h" - -namespace irr -{ -namespace gui -{ - class CGUIEditBox : public IGUIEditBox - { - public: - - //! constructor - CGUIEditBox(const wchar_t* text, bool border, IGUIEnvironment* environment, - IGUIElement* parent, s32 id, const core::rect<s32>& rectangle); - - //! destructor - virtual ~CGUIEditBox(); - - //! Sets another skin independent font. - virtual void setOverrideFont(IGUIFont* font=0); - - //! Sets another color for the text. - virtual void setOverrideColor(video::SColor color); - - //! Sets if the text should use the overide color or the - //! color in the gui skin. - virtual void enableOverrideColor(bool enable); - - //! Turns the border on or off - virtual void setDrawBorder(bool border); - - //! Enables or disables word wrap for using the edit box as multiline text editor. - virtual void setWordWrap(bool enable); - - //! Checks if word wrap is enabled - //! \return true if word wrap is enabled, false otherwise - virtual bool isWordWrapEnabled() const; - - //! Enables or disables newlines. - /** \param enable: If set to true, the EGET_EDITBOX_ENTER event will not be fired, - instead a newline character will be inserted. */ - virtual void setMultiLine(bool enable); - - //! Checks if multi line editing is enabled - //! \return true if mult-line is enabled, false otherwise - virtual bool isMultiLineEnabled() const; - - //! Enables or disables automatic scrolling with cursor position - //! \param enable: If set to true, the text will move around with the cursor position - virtual void setAutoScroll(bool enable); - - //! Checks to see if automatic scrolling is enabled - //! \return true if automatic scrolling is enabled, false if not - virtual bool isAutoScrollEnabled() const; - - //! Gets the size area of the text in the edit box - //! \return Returns the size in pixels of the text - virtual core::dimension2du getTextDimension(); - - //! Sets text justification - virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical); - - //! called if an event happened. - virtual bool OnEvent(const SEvent& event); - - //! draws the element and its children - virtual void draw(); - - //! Sets the new caption of this element. - virtual void setText(const wchar_t* text); - - //! Sets the maximum amount of characters which may be entered in the box. - //! \param max: Maximum amount of characters. If 0, the character amount is - //! infinity. - virtual void setMax(u32 max); - - //! Returns maximum amount of characters, previously set by setMax(); - virtual u32 getMax() const; - - //! Sets whether the edit box is a password box. Setting this to true will - /** disable MultiLine, WordWrap and the ability to copy with ctrl+c or ctrl+x - \param passwordBox: true to enable password, false to disable - \param passwordChar: the character that is displayed instead of letters */ - virtual void setPasswordBox(bool passwordBox, wchar_t passwordChar = L'*'); - - //! Returns true if the edit box is currently a password box. - virtual bool isPasswordBox() const; - - //! Updates the absolute position, splits text if required - virtual void updateAbsolutePosition(); - - //! Writes attributes of the element. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; - - //! Reads attributes of the element - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - - protected: - //! Breaks the single text line. - void breakText(); - //! sets the area of the given line - void setTextRect(s32 line); - //! returns the line number that the cursor is on - s32 getLineFromPos(s32 pos); - //! adds a letter to the edit box - void inputChar(wchar_t c); - //! calculates the current scroll position - void calculateScrollPos(); - //! send some gui event to parent - void sendGuiEvent(EGUI_EVENT_TYPE type); - //! set text markers - void setTextMarkers(s32 begin, s32 end); - - bool processKey(const SEvent& event); - bool processMouse(const SEvent& event); - s32 getCursorPos(s32 x, s32 y); - - bool MouseMarking; - bool Border; - bool OverrideColorEnabled; - s32 MarkBegin; - s32 MarkEnd; - - video::SColor OverrideColor; - gui::IGUIFont *OverrideFont, *LastBreakFont; - IOSOperator* Operator; - - u32 BlinkStartTime; - s32 CursorPos; - s32 HScrollPos, VScrollPos; // scroll position in characters - u32 Max; - - bool WordWrap, MultiLine, AutoScroll, PasswordBox; - wchar_t PasswordChar; - EGUI_ALIGNMENT HAlign, VAlign; - - core::array< core::stringw > BrokenText; - core::array< s32 > BrokenTextPositions; - - core::rect<s32> CurrentTextRect, FrameRect; // temporary values - }; - - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ -#endif // __C_GUI_EDIT_BOX_H_INCLUDED__ - diff --git a/irrlicht-1.6/source/Irrlicht/CGUIEnvironment.cpp b/irrlicht-1.6/source/Irrlicht/CGUIEnvironment.cpp deleted file mode 100644 index 1d61e4a0f..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIEnvironment.cpp +++ /dev/null @@ -1,1551 +0,0 @@ - -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUIEnvironment.h" - -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IVideoDriver.h" - -#include "CGUISkin.h" -#include "CGUIButton.h" -#include "CGUIWindow.h" -#include "CGUIScrollBar.h" -#include "CGUIFont.h" -#include "CGUISpriteBank.h" -#include "CGUIImage.h" -#include "CGUIMeshViewer.h" -#include "CGUICheckBox.h" -#include "CGUIListBox.h" -#include "CGUITreeView.h" -#include "CGUIImageList.h" -#include "CGUIFileOpenDialog.h" -#include "CGUIColorSelectDialog.h" -#include "CGUIStaticText.h" -#include "CGUIEditBox.h" -#include "CGUISpinBox.h" -#include "CGUIInOutFader.h" -#include "CGUIMessageBox.h" -#include "CGUIModalScreen.h" -#include "CGUITabControl.h" -#include "CGUIContextMenu.h" -#include "CGUIComboBox.h" -#include "CGUIMenu.h" -#include "CGUIToolBar.h" -#include "CGUITable.h" - -#include "CDefaultGUIElementFactory.h" -#include "IWriteFile.h" -#include "IXMLWriter.h" - -#include "BuiltInFont.h" -#include "os.h" - -namespace irr -{ -namespace gui -{ - -const wchar_t* IRR_XML_FORMAT_GUI_ENV = L"irr_gui"; -const wchar_t* IRR_XML_FORMAT_GUI_ELEMENT = L"element"; -const wchar_t* IRR_XML_FORMAT_GUI_ELEMENT_ATTR_TYPE = L"type"; - -//! constructor -CGUIEnvironment::CGUIEnvironment(io::IFileSystem* fs, video::IVideoDriver* driver, IOSOperator* op) -: IGUIElement(EGUIET_ELEMENT, 0, 0, 0, core::rect<s32>(core::position2d<s32>(0,0), driver ? core::dimension2d<s32>(driver->getScreenSize()) : core::dimension2d<s32>(0,0))), - Driver(driver), Hovered(0), Focus(0), LastHoveredMousePos(0,0), CurrentSkin(0), - FileSystem(fs), UserReceiver(0), Operator(op) -{ - if (Driver) - Driver->grab(); - - if (FileSystem) - FileSystem->grab(); - - if (Operator) - Operator->grab(); - - #ifdef _DEBUG - IGUIEnvironment::setDebugName("CGUIEnvironment"); - #endif - - // gui factory - IGUIElementFactory* factory = new CDefaultGUIElementFactory(this); - registerGUIElementFactory(factory); - factory->drop(); - - loadBuiltInFont(); - - IGUISkin* skin = createSkin( gui::EGST_WINDOWS_METALLIC ); - setSkin(skin); - skin->drop(); - - //set tooltip default - ToolTip.LastTime = 0; - ToolTip.LaunchTime = 1000; - ToolTip.Element = 0; - - // environment is root tab group - Environment = this; - setTabGroup(true); -} - - -//! destructor -CGUIEnvironment::~CGUIEnvironment() -{ - if (Hovered && Hovered != this) - { - Hovered->drop(); - Hovered = 0; - } - - if (Driver) - { - Driver->drop(); - Driver = 0; - } - - if (Focus) - { - Focus->drop(); - Focus = 0; - } - - if (ToolTip.Element) - { - ToolTip.Element->drop(); - ToolTip.Element = 0; - } - - if (FileSystem) - { - FileSystem->drop(); - FileSystem = 0; - } - - if (Operator) - { - Operator->drop(); - Operator = 0; - } - - // drop skin - if (CurrentSkin) - { - CurrentSkin->drop(); - CurrentSkin = 0; - } - - u32 i; - - // delete all sprite banks - for (i=0; i<Banks.size(); ++i) - if (Banks[i].Bank) - Banks[i].Bank->drop(); - - // delete all fonts - for (i=0; i<Fonts.size(); ++i) - Fonts[i].Font->drop(); - - // remove all factories - for (i=0; i<GUIElementFactoryList.size(); ++i) - GUIElementFactoryList[i]->drop(); -} - - -void CGUIEnvironment::loadBuiltInFont() -{ - io::path filename = "#DefaultFont"; - - io::IReadFile* file = io::createMemoryReadFile(BuiltInFontData, BuiltInFontDataSize, filename, false); - - CGUIFont* font = new CGUIFont(this, filename ); - if (!font->load(file)) - { - os::Printer::log("Error: Could not load built-in Font. Did you compile without the BMP loader?", ELL_ERROR); - font->drop(); - file->drop(); - return; - } - - SFont f; - f.Filename = filename; - f.Font = font; - Fonts.push_back(f); - - file->drop(); -} - - -//! draws all gui elements -void CGUIEnvironment::drawAll() -{ - if (Driver) - { - core::dimension2d<s32> dim(Driver->getScreenSize()); - if (AbsoluteRect.LowerRightCorner.X != dim.Width || - AbsoluteRect.LowerRightCorner.Y != dim.Height) - { - // resize gui environment - DesiredRect.LowerRightCorner = dim; - AbsoluteClippingRect = DesiredRect; - AbsoluteRect = DesiredRect; - updateAbsolutePosition(); - } - } - - // make sure tooltip is always on top - if (ToolTip.Element) - bringToFront(ToolTip.Element); - - draw(); - OnPostRender ( os::Timer::getTime () ); -} - - -//! sets the focus to an element -bool CGUIEnvironment::setFocus(IGUIElement* element) -{ - if (Focus == element) - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; - } - - // GUI Environment should not get the focus - if (element == this) - element = 0; - - // stop element from being deleted - if (element) - element->grab(); - - // focus may change or be removed in this call - IGUIElement *currentFocus = 0; - if (Focus) - { - currentFocus = Focus; - currentFocus->grab(); - SEvent e; - e.EventType = EET_GUI_EVENT; - e.GUIEvent.Caller = Focus; - e.GUIEvent.Element = element; - e.GUIEvent.EventType = EGET_ELEMENT_FOCUS_LOST; - if (Focus->OnEvent(e)) - { - if (element) - element->drop(); - currentFocus->drop(); - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; - } - currentFocus->drop(); - currentFocus = 0; - } - - if (element) - { - currentFocus = Focus; - if (currentFocus) - currentFocus->grab(); - - // send focused event - SEvent e; - e.EventType = EET_GUI_EVENT; - e.GUIEvent.Caller = element; - e.GUIEvent.Element = Focus; - e.GUIEvent.EventType = EGET_ELEMENT_FOCUSED; - if (element->OnEvent(e)) - { - if (element) - element->drop(); - if (currentFocus) - currentFocus->drop(); - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; - } - } - - if (currentFocus) - currentFocus->drop(); - - if (Focus) - Focus->drop(); - - // element is the new focus so it doesn't have to be dropped - Focus = element; - - return true; -} - - -//! returns the element with the focus -IGUIElement* CGUIEnvironment::getFocus() const -{ - return Focus; -} - - -//! removes the focus from an element -bool CGUIEnvironment::removeFocus(IGUIElement* element) -{ - if (Focus && Focus==element) - { - SEvent e; - e.EventType = EET_GUI_EVENT; - e.GUIEvent.Caller = Focus; - e.GUIEvent.Element = 0; - e.GUIEvent.EventType = EGET_ELEMENT_FOCUS_LOST; - if (Focus->OnEvent(e)) - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; - } - } - if (Focus) - { - Focus->drop(); - Focus = 0; - } - - return true; -} - - -//! Returns if the element has focus -bool CGUIEnvironment::hasFocus(IGUIElement* element) const -{ - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return (element == Focus); -} - - -//! returns the current video driver -video::IVideoDriver* CGUIEnvironment::getVideoDriver() const -{ - return Driver; -} - - -//! returns the current file system -io::IFileSystem* CGUIEnvironment::getFileSystem() const -{ - return FileSystem; -} - - -//! returns the current file system -IOSOperator* CGUIEnvironment::getOSOperator() const -{ - return Operator; -} - - -//! clear all GUI elements -void CGUIEnvironment::clear() -{ - // Remove the focus - if (Focus) - { - Focus->drop(); - Focus = 0; - } - - if (Hovered && Hovered != this) - { - Hovered->drop(); - Hovered = 0; - } - - // get the root's children in case the root changes in future - const core::list<IGUIElement*>& children = getRootGUIElement()->getChildren(); - - while (!children.empty()) - (*children.getLast())->remove(); -} - - -//! called by ui if an event happened. -bool CGUIEnvironment::OnEvent(const SEvent& event) -{ - bool ret = false; - if (UserReceiver - && (event.EventType != EET_MOUSE_INPUT_EVENT) - && (event.EventType != EET_KEY_INPUT_EVENT) - && (event.EventType != EET_GUI_EVENT || event.GUIEvent.Caller != this)) - { - ret = UserReceiver->OnEvent(event); - } - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return ret; -} - - -// -void CGUIEnvironment::OnPostRender( u32 time ) -{ - // check tooltip - - // launch tooltip - if ( time - ToolTip.LastTime >= ToolTip.LaunchTime && - Hovered && Hovered != this && - ToolTip.Element == 0 && - Hovered != ToolTip.Element && - Hovered->getToolTipText().size() && - getSkin() && - getSkin()->getFont(EGDF_TOOLTIP) - ) - { - core::rect<s32> pos; - - pos.UpperLeftCorner = LastHoveredMousePos; - core::dimension2du dim = getSkin()->getFont(EGDF_TOOLTIP)->getDimension(Hovered->getToolTipText().c_str()); - dim.Width += getSkin()->getSize(EGDS_TEXT_DISTANCE_X)*2; - dim.Height += getSkin()->getSize(EGDS_TEXT_DISTANCE_Y)*2; - - pos.UpperLeftCorner.Y -= dim.Height+1; - pos.LowerRightCorner.Y = pos.UpperLeftCorner.Y + dim.Height-1; - pos.LowerRightCorner.X = pos.UpperLeftCorner.X + dim.Width; - - pos.constrainTo(getAbsolutePosition()); - - ToolTip.Element = addStaticText(Hovered->getToolTipText().c_str(), pos, true, true, this, -1, true); - ToolTip.Element->setOverrideColor(getSkin()->getColor(EGDC_TOOLTIP)); - ToolTip.Element->setBackgroundColor(getSkin()->getColor(EGDC_TOOLTIP_BACKGROUND)); - ToolTip.Element->setOverrideFont(getSkin()->getFont(EGDF_TOOLTIP)); - ToolTip.Element->setSubElement(true); - ToolTip.Element->grab(); - - s32 textHeight = ToolTip.Element->getTextHeight(); - pos = ToolTip.Element->getRelativePosition(); - pos.LowerRightCorner.Y = pos.UpperLeftCorner.Y + textHeight; - ToolTip.Element->setRelativePosition(pos); - - } - - IGUIElement::OnPostRender ( time ); -} - - -// -void CGUIEnvironment::updateHoveredElement(core::position2d<s32> mousePos) -{ - IGUIElement* lastHovered = Hovered; - LastHoveredMousePos = mousePos; - - Hovered = getElementFromPoint(mousePos); - - if (Hovered) - { - u32 now = os::Timer::getTime (); - - if (Hovered != this) - Hovered->grab(); - - if (Hovered != lastHovered) - { - SEvent event; - event.EventType = EET_GUI_EVENT; - - if (lastHovered) - { - event.GUIEvent.Caller = lastHovered; - event.GUIEvent.EventType = EGET_ELEMENT_LEFT; - lastHovered->OnEvent(event); - } - - if ( ToolTip.Element ) - { - ToolTip.Element->remove(); - ToolTip.Element->drop(); - ToolTip.Element = 0; - ToolTip.LastTime += 500; - } - else - { - // boost tooltip generation for relaunch - if ( now - ToolTip.LastTime < ToolTip.LastTime ) - { - ToolTip.LastTime += 500; - } - else - { - ToolTip.LastTime = now; - } - } - - - event.GUIEvent.Caller = Hovered; - event.GUIEvent.EventType = EGET_ELEMENT_HOVERED; - Hovered->OnEvent(event); - } - } - - if (lastHovered && lastHovered != this) - lastHovered->drop(); -} - - -//! This sets a new event receiver for gui events. Usually you do not have to -//! use this method, it is used by the internal engine. -void CGUIEnvironment::setUserEventReceiver(IEventReceiver* evr) -{ - UserReceiver = evr; -} - - -//! posts an input event to the environment -bool CGUIEnvironment::postEventFromUser(const SEvent& event) -{ - switch(event.EventType) - { - case EET_GUI_EVENT: - // hey, why is the user sending gui events..? - break; - case EET_MOUSE_INPUT_EVENT: - - updateHoveredElement(core::position2d<s32>(event.MouseInput.X, event.MouseInput.Y)); - - if (event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN) - if ( (Hovered && Hovered != Focus) || !Focus ) - { - setFocus(Hovered); - } - - // sending input to focus - if (Focus && Focus->OnEvent(event)) - return true; - - // focus could have died in last call - if (!Focus && Hovered) - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return Hovered->OnEvent(event); - } - - break; - case EET_KEY_INPUT_EVENT: - { - // send focus changing event - if (event.EventType == EET_KEY_INPUT_EVENT && - event.KeyInput.PressedDown && - event.KeyInput.Key == KEY_TAB) - { - IGUIElement *next = getNextElement(event.KeyInput.Shift, event.KeyInput.Control); - if (next && next != Focus) - { - if (setFocus(next)) - return true; - } - } - if (Focus) - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return Focus->OnEvent(event); - } - } - break; - default: - break; - } // end switch - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; -} - - -//! returns the current gui skin -IGUISkin* CGUIEnvironment::getSkin() const -{ - return CurrentSkin; -} - - -//! Sets a new GUI Skin -void CGUIEnvironment::setSkin(IGUISkin* skin) -{ - if (CurrentSkin==skin) - return; - - if (CurrentSkin) - CurrentSkin->drop(); - - CurrentSkin = skin; - - if (CurrentSkin) - CurrentSkin->grab(); -} - - -//! Creates a new GUI Skin based on a template. -/** \return Returns a pointer to the created skin. -If you no longer need the skin, you should call IGUISkin::drop(). -See IReferenceCounted::drop() for more information. */ -IGUISkin* CGUIEnvironment::createSkin(EGUI_SKIN_TYPE type) -{ - IGUISkin* skin = new CGUISkin(type, Driver); - - IGUIFont* builtinfont = getBuiltInFont(); - IGUIFontBitmap* bitfont = 0; - if (builtinfont && builtinfont->getType() == EGFT_BITMAP) - bitfont = (IGUIFontBitmap*)builtinfont; - - IGUISpriteBank* bank = 0; - skin->setFont(builtinfont); - - if (bitfont) - bank = bitfont->getSpriteBank(); - - skin->setSpriteBank(bank); - - return skin; -} - - -//! Returns the default element factory which can create all built in elements -IGUIElementFactory* CGUIEnvironment::getDefaultGUIElementFactory() const -{ - return getGUIElementFactory(0); -} - - -//! Adds an element factory to the gui environment. -/** Use this to extend the gui environment with new element types which it should be -able to create automaticly, for example when loading data from xml files. */ -void CGUIEnvironment::registerGUIElementFactory(IGUIElementFactory* factoryToAdd) -{ - if (factoryToAdd) - { - factoryToAdd->grab(); - GUIElementFactoryList.push_back(factoryToAdd); - } -} - - -//! Returns amount of registered scene node factories. -u32 CGUIEnvironment::getRegisteredGUIElementFactoryCount() const -{ - return GUIElementFactoryList.size(); -} - - -//! Returns a scene node factory by index -IGUIElementFactory* CGUIEnvironment::getGUIElementFactory(u32 index) const -{ - if (index < GUIElementFactoryList.size()) - return GUIElementFactoryList[index]; - else - return 0; -} - - -//! adds a GUI Element using its name -IGUIElement* CGUIEnvironment::addGUIElement(const c8* elementName, IGUIElement* parent) -{ - IGUIElement* node=0; - - if (!parent) - parent = this; - - for (u32 i=0; i<GUIElementFactoryList.size() && !node; ++i) - node = GUIElementFactoryList[i]->addGUIElement(elementName, parent); - - return node; -} - - -//! Saves the current gui into a file. -//! \param filename: Name of the file . -bool CGUIEnvironment::saveGUI(const io::path& filename, IGUIElement* start) -{ - io::IWriteFile* file = FileSystem->createAndWriteFile(filename); - if (!file) - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; - } - - bool ret = saveGUI(file, start); - file->drop(); - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return ret; -} - - -//! Saves the current gui into a file. -bool CGUIEnvironment::saveGUI(io::IWriteFile* file, IGUIElement* start) -{ - if (!file) - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; - } - - io::IXMLWriter* writer = FileSystem->createXMLWriter(file); - if (!writer) - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; - } - - writer->writeXMLHeader(); - writeGUIElement(writer, start ? start : this); - writer->drop(); - - return true; -} - - -//! Loads the gui. Note that the current gui is not cleared before. -//! \param filename: Name of the file. -bool CGUIEnvironment::loadGUI(const io::path& filename, IGUIElement* parent) -{ - io::IReadFile* read = FileSystem->createAndOpenFile(filename); - if (!read) - { - os::Printer::log("Unable to open gui file", filename, ELL_ERROR); - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; - } - - bool ret = loadGUI(read, parent); - read->drop(); - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return ret; -} - - -//! Loads the gui. Note that the current gui is not cleared before. -bool CGUIEnvironment::loadGUI(io::IReadFile* file, IGUIElement* parent) -{ - if (!file) - { - os::Printer::log("Unable to open GUI file", ELL_ERROR); - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; - } - - io::IXMLReader* reader = FileSystem->createXMLReader(file); - if (!reader) - { - os::Printer::log("GUI is not a valid XML file", file->getFileName(), ELL_ERROR); - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; - } - - // read file - while(reader->read()) - { - readGUIElement(reader, parent); - } - - // finish up - - reader->drop(); - return true; -} - - -//! reads an element -void CGUIEnvironment::readGUIElement(io::IXMLReader* reader, IGUIElement* node) -{ - if (!reader) - return; - - io::EXML_NODE nodeType = reader->getNodeType(); - - if (nodeType == io::EXN_NONE || nodeType == io::EXN_UNKNOWN || nodeType == io::EXN_ELEMENT_END) - return; - - if (!wcscmp(IRR_XML_FORMAT_GUI_ENV, reader->getNodeName())) - { - if (!node) - node = this; // root - } - else if (!wcscmp(IRR_XML_FORMAT_GUI_ELEMENT, reader->getNodeName())) - { - // find node type and create it - const core::stringc attrName = reader->getAttributeValue(IRR_XML_FORMAT_GUI_ELEMENT_ATTR_TYPE); - - node = addGUIElement(attrName.c_str(), node); - - if (!node) - os::Printer::log("Could not create GUI element of unknown type", attrName.c_str()); - } - - // read attributes - - while(reader->read()) - { - bool endreached = false; - - switch (reader->getNodeType()) - { - case io::EXN_ELEMENT_END: - if (!wcscmp(IRR_XML_FORMAT_GUI_ELEMENT, reader->getNodeName()) || - !wcscmp(IRR_XML_FORMAT_GUI_ENV, reader->getNodeName())) - { - endreached = true; - } - break; - case io::EXN_ELEMENT: - if (!wcscmp(L"attributes", reader->getNodeName())) - { - // read attributes - io::IAttributes* attr = FileSystem->createEmptyAttributes(Driver); - attr->read(reader, true); - - if (node) - node->deserializeAttributes(attr); - - attr->drop(); - } - else - if (!wcscmp(IRR_XML_FORMAT_GUI_ELEMENT, reader->getNodeName()) || - !wcscmp(IRR_XML_FORMAT_GUI_ENV, reader->getNodeName())) - { - readGUIElement(reader, node); - } - else - { - os::Printer::log("Found unknown element in irrlicht GUI file", - core::stringc(reader->getNodeName()).c_str()); - } - - break; - default: - break; - } - - if (endreached) - break; - } -} - - -//! writes an element -void CGUIEnvironment::writeGUIElement(io::IXMLWriter* writer, IGUIElement* node) -{ - if (!writer || !node ) - return; - - const wchar_t* name = 0; - - // write properties - - io::IAttributes* attr = FileSystem->createEmptyAttributes(); - node->serializeAttributes(attr); - - // all gui elements must have at least one attribute - // if they have nothing then we ignore them. - if (attr->getAttributeCount() != 0) - { - if (node == this) - { - name = IRR_XML_FORMAT_GUI_ENV; - writer->writeElement(name, false); - } - else - { - name = IRR_XML_FORMAT_GUI_ELEMENT; - writer->writeElement(name, false, IRR_XML_FORMAT_GUI_ELEMENT_ATTR_TYPE, - core::stringw(node->getTypeName()).c_str()); - } - - writer->writeLineBreak(); - writer->writeLineBreak(); - - attr->write(writer); - writer->writeLineBreak(); - } - - // write children - - core::list<IGUIElement*>::ConstIterator it = node->getChildren().begin(); - for (; it != node->getChildren().end(); ++it) - { - if (!(*it)->isSubElement()) - writeGUIElement(writer, (*it)); - } - - // write closing brace if required - if (attr->getAttributeCount() != 0) - { - writer->writeClosingTag(name); - writer->writeLineBreak(); - writer->writeLineBreak(); - } - - attr->drop(); -} - - -//! Writes attributes of the environment -void CGUIEnvironment::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const -{ - IGUISkin* skin = getSkin(); - - if (skin) - { - out->addEnum("Skin", getSkin()->getType(), GUISkinTypeNames); - skin->serializeAttributes(out, options); - } -} - - -//! Reads attributes of the environment -void CGUIEnvironment::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - if (in->existsAttribute("Skin")) - { - IGUISkin *skin = getSkin(); - - EGUI_SKIN_TYPE t = (EGUI_SKIN_TYPE) in->getAttributeAsEnumeration("Skin",GUISkinTypeNames); - if ( !skin || t != skin->getType()) - { - skin = createSkin(t); - setSkin(skin); - skin->drop(); - } - - skin = getSkin(); - - if (skin) - { - skin->deserializeAttributes(in, options); - } - - } - - RelativeRect = AbsoluteRect = - core::rect<s32>(core::position2d<s32>(0,0), - Driver ? core::dimension2di(Driver->getScreenSize()) : core::dimension2d<s32>(0,0)); -} - - -//! adds a button. The returned pointer must not be dropped. -IGUIButton* CGUIEnvironment::addButton(const core::rect<s32>& rectangle, IGUIElement* parent, s32 id, const wchar_t* text, const wchar_t *tooltiptext) -{ - IGUIButton* button = new CGUIButton(this, parent ? parent : this, id, rectangle); - if (text) - button->setText(text); - - if ( tooltiptext ) - button->setToolTipText ( tooltiptext ); - - button->drop(); - return button; -} - - -//! adds a window. The returned pointer must not be dropped. -IGUIWindow* CGUIEnvironment::addWindow(const core::rect<s32>& rectangle, bool modal, - const wchar_t* text, IGUIElement* parent, s32 id) -{ - parent = parent ? parent : this; - - if (modal) - { - parent = new CGUIModalScreen(this, parent, -1); - parent->drop(); - } - - IGUIWindow* win = new CGUIWindow(this, parent, id, rectangle); - if (text) - win->setText(text); - win->drop(); - - return win; -} - - -//! adds a modal screen. The returned pointer must not be dropped. -IGUIElement* CGUIEnvironment::addModalScreen(IGUIElement* parent) -{ - parent = parent ? parent : this; - - IGUIElement *win = new CGUIModalScreen(this, parent, -1); - win->drop(); - - return win; -} - - -//! Adds a message box. -IGUIWindow* CGUIEnvironment::addMessageBox(const wchar_t* caption, const wchar_t* text, - bool modal, s32 flag, IGUIElement* parent, s32 id) -{ - if (!CurrentSkin) - return 0; - - parent = parent ? parent : this; - - core::rect<s32> rect; - core::dimension2d<u32> screenDim, msgBoxDim; - - screenDim.Width = parent->getAbsolutePosition().getWidth(); - screenDim.Height = parent->getAbsolutePosition().getHeight(); - msgBoxDim.Width = CurrentSkin->getSize(gui::EGDS_MESSAGE_BOX_WIDTH); - msgBoxDim.Height = CurrentSkin->getSize(gui::EGDS_MESSAGE_BOX_HEIGHT); - - rect.UpperLeftCorner.X = (screenDim.Width - msgBoxDim.Width) / 2; - rect.UpperLeftCorner.Y = (screenDim.Height - msgBoxDim.Height) / 2; - rect.LowerRightCorner.X = rect.UpperLeftCorner.X + msgBoxDim.Width; - rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + msgBoxDim.Height; - - if (modal) - { - parent = new CGUIModalScreen(this, parent, -1); - parent->drop(); - } - - IGUIWindow* win = new CGUIMessageBox(this, caption, text, flag, - parent, id, rect); - - win->drop(); - return win; -} - - -//! adds a scrollbar. The returned pointer must not be dropped. -IGUIScrollBar* CGUIEnvironment::addScrollBar(bool horizontal, const core::rect<s32>& rectangle, IGUIElement* parent, s32 id) -{ - IGUIScrollBar* bar = new CGUIScrollBar(horizontal, this, parent ? parent : this, id, rectangle); - bar->drop(); - return bar; -} - -//! Adds a table to the environment -IGUITable* CGUIEnvironment::addTable(const core::rect<s32>& rectangle, IGUIElement* parent, s32 id, bool drawBackground) -{ - CGUITable* b = new CGUITable(this, parent ? parent : this, id, rectangle, true, drawBackground, false); - b->drop(); - return b; -} - - -//! Adds an image element. -IGUIImage* CGUIEnvironment::addImage(video::ITexture* image, core::position2d<s32> pos, - bool useAlphaChannel, IGUIElement* parent, s32 id, const wchar_t* text) -{ - core::dimension2d<s32> sz(0,0); - if (image) - sz = core::dimension2d<s32>(image->getOriginalSize()); - - IGUIImage* img = new CGUIImage(this, parent ? parent : this, - id, core::rect<s32>(pos, sz)); - - if (text) - img->setText(text); - - if (useAlphaChannel) - img->setUseAlphaChannel(true); - - if (image) - img->setImage(image); - - img->drop(); - return img; -} - - -//! adds an image. The returned pointer must not be dropped. -IGUIImage* CGUIEnvironment::addImage(const core::rect<s32>& rectangle, IGUIElement* parent, s32 id, const wchar_t* text) -{ - IGUIImage* img = new CGUIImage(this, parent ? parent : this, - id, rectangle); - - if (text) - img->setText(text); - - img->drop(); - return img; -} - - -//! adds an mesh viewer. The returned pointer must not be dropped. -IGUIMeshViewer* CGUIEnvironment::addMeshViewer(const core::rect<s32>& rectangle, IGUIElement* parent, s32 id, const wchar_t* text) -{ - IGUIMeshViewer* v = new CGUIMeshViewer(this, parent ? parent : this, - id, rectangle); - - if (text) - v->setText(text); - - v->drop(); - return v; -} - - -//! adds a checkbox -IGUICheckBox* CGUIEnvironment::addCheckBox(bool checked, const core::rect<s32>& rectangle, IGUIElement* parent, s32 id, const wchar_t* text) -{ - IGUICheckBox* b = new CGUICheckBox(checked, this, - parent ? parent : this , id , rectangle); - - if (text) - b->setText(text); - - b->drop(); - return b; -} - - -//! adds a list box -IGUIListBox* CGUIEnvironment::addListBox(const core::rect<s32>& rectangle, - IGUIElement* parent, s32 id, bool drawBackground) -{ - IGUIListBox* b = new CGUIListBox(this, parent ? parent : this, id, rectangle, - true, drawBackground, false); - - if (CurrentSkin && CurrentSkin->getSpriteBank()) - { - b->setSpriteBank(CurrentSkin->getSpriteBank()); - } - else if (getBuiltInFont() && getBuiltInFont()->getType() == EGFT_BITMAP) - { - b->setSpriteBank( ((IGUIFontBitmap*)getBuiltInFont())->getSpriteBank()); - } - - b->drop(); - return b; -} - -//! adds a tree view -IGUITreeView* CGUIEnvironment::addTreeView(const core::rect<s32>& rectangle, - IGUIElement* parent, s32 id, - bool drawBackground, - bool scrollBarVertical, bool scrollBarHorizontal) -{ - IGUITreeView* b = new CGUITreeView(this, parent ? parent : this, id, rectangle, - true, drawBackground, scrollBarVertical, scrollBarHorizontal); - - b->setIconFont ( getBuiltInFont () ); - b->drop(); - return b; -} - -//! adds a file open dialog. The returned pointer must not be dropped. -IGUIFileOpenDialog* CGUIEnvironment::addFileOpenDialog(const wchar_t* title, - bool modal, IGUIElement* parent, s32 id) -{ - parent = parent ? parent : this; - - if (modal) - { - parent = new CGUIModalScreen(this, parent, -1); - parent->drop(); - } - - IGUIFileOpenDialog* d = new CGUIFileOpenDialog(title, this, parent, id); - - d->drop(); - return d; -} - - -//! adds a color select dialog. The returned pointer must not be dropped. -IGUIColorSelectDialog* CGUIEnvironment::addColorSelectDialog(const wchar_t* title, - bool modal, IGUIElement* parent, s32 id) -{ - parent = parent ? parent : this; - - if (modal) - { - parent = new CGUIModalScreen(this, parent, -1); - parent->drop(); - } - - IGUIColorSelectDialog* d = new CGUIColorSelectDialog( title, - this, parent, id); - - d->drop(); - return d; -} - - -//! adds a static text. The returned pointer must not be dropped. -IGUIStaticText* CGUIEnvironment::addStaticText(const wchar_t* text, - const core::rect<s32>& rectangle, - bool border, bool wordWrap, - IGUIElement* parent, s32 id, bool background) -{ - IGUIStaticText* d = new CGUIStaticText(text, border, this, - parent ? parent : this, id, rectangle, background); - - d->setWordWrap(wordWrap); - d->drop(); - - return d; -} - - -//! Adds an edit box. The returned pointer must not be dropped. -IGUIEditBox* CGUIEnvironment::addEditBox(const wchar_t* text, - const core::rect<s32>& rectangle, bool border, - IGUIElement* parent, s32 id) -{ - IGUIEditBox* d = new CGUIEditBox(text, border, this, - parent ? parent : this, id, rectangle); - - d->drop(); - return d; -} - - -//! Adds a spin box to the environment -IGUISpinBox* CGUIEnvironment::addSpinBox(const wchar_t* text, - const core::rect<s32> &rectangle, - bool border,IGUIElement* parent, s32 id) -{ - IGUISpinBox* d = new CGUISpinBox(text, border,this, - parent ? parent : this, id, rectangle); - - d->drop(); - return d; -} - - -//! Adds a tab control to the environment. -IGUITabControl* CGUIEnvironment::addTabControl(const core::rect<s32>& rectangle, - IGUIElement* parent, bool fillbackground, bool border, s32 id) -{ - IGUITabControl* t = new CGUITabControl(this, parent ? parent : this, - rectangle, fillbackground, border, id); - t->drop(); - return t; -} - - -//! Adds tab to the environment. -IGUITab* CGUIEnvironment::addTab(const core::rect<s32>& rectangle, - IGUIElement* parent, s32 id) -{ - IGUITab* t = new CGUITab(-1, this, parent ? parent : this, - rectangle, id); - t->drop(); - return t; -} - - -//! Adds a context menu to the environment. -IGUIContextMenu* CGUIEnvironment::addContextMenu(const core::rect<s32>& rectangle, - IGUIElement* parent, s32 id) -{ - IGUIContextMenu* c = new CGUIContextMenu(this, - parent ? parent : this, id, rectangle, true); - c->drop(); - return c; -} - - -//! Adds a menu to the environment. -IGUIContextMenu* CGUIEnvironment::addMenu(IGUIElement* parent, s32 id) -{ - if (!parent) - parent = this; - - IGUIContextMenu* c = new CGUIMenu(this, - parent, id, core::rect<s32>(0,0, - parent->getAbsolutePosition().getWidth(), - parent->getAbsolutePosition().getHeight())); - - c->drop(); - return c; -} - - -//! Adds a toolbar to the environment. It is like a menu is always placed on top -//! in its parent, and contains buttons. -IGUIToolBar* CGUIEnvironment::addToolBar(IGUIElement* parent, s32 id) -{ - if (!parent) - parent = this; - - IGUIToolBar* b = new CGUIToolBar(this, parent, id, core::rect<s32>(0,0,10,10)); - b->drop(); - return b; -} - - -//! Adds an element for fading in or out. -IGUIInOutFader* CGUIEnvironment::addInOutFader(const core::rect<s32>* rectangle, IGUIElement* parent, s32 id) -{ - core::rect<s32> rect; - - if (rectangle) - rect = *rectangle; - else if (Driver) - rect = core::rect<s32>(core::position2d<s32>(0,0), core::dimension2di(Driver->getScreenSize())); - - if (!parent) - parent = this; - - IGUIInOutFader* fader = new CGUIInOutFader(this, parent, id, rect); - fader->drop(); - return fader; -} - - -//! Adds a combo box to the environment. -IGUIComboBox* CGUIEnvironment::addComboBox(const core::rect<s32>& rectangle, - IGUIElement* parent, s32 id) -{ - IGUIComboBox* t = new CGUIComboBox(this, parent ? parent : this, - id, rectangle); - t->drop(); - return t; -} - - - -//! returns the font -IGUIFont* CGUIEnvironment::getFont(const io::path& filename) -{ - // search existing font - - SFont f; - IGUIFont* ifont=0; - f.Filename = filename; - - f.Filename.make_lower(); - - s32 index = Fonts.binary_search(f); - if (index != -1) - return Fonts[index].Font; - - // font doesn't exist, attempt to load it - - // does the file exist? - - if (!FileSystem->existFile(filename)) - { - os::Printer::log("Could not load font because the file does not exist", f.Filename, ELL_ERROR); - return 0; - } - - io::IXMLReader *xml = FileSystem->createXMLReader(filename ); - if (xml) - { - // this is an XML font, but we need to know what type - EGUI_FONT_TYPE t = EGFT_CUSTOM; - - bool found=false; - while(xml->read() && !found) - { - if (xml->getNodeType() == io::EXN_ELEMENT) - { - if (core::stringw(L"font") == xml->getNodeName()) - { - if (core::stringw(L"vector") == xml->getAttributeValue(L"type")) - { - t = EGFT_VECTOR; - found=true; - } - else if (core::stringw(L"bitmap") == xml->getAttributeValue(L"type")) - { - t = EGFT_BITMAP; - found=true; - } - else found=true; - } - } - } - - if (t==EGFT_BITMAP) - { - CGUIFont* font = new CGUIFont(this, filename); - ifont = (IGUIFont*)font; - // change working directory, for loading textures - io::path workingDir = FileSystem->getWorkingDirectory(); - FileSystem->changeWorkingDirectoryTo(FileSystem->getFileDir(f.Filename)); - - // load the font - if (!font->load(xml)) - { - font->drop(); - font = 0; - ifont = 0; - } - // change working dir back again - FileSystem->changeWorkingDirectoryTo( workingDir ); - } - else if (t==EGFT_VECTOR) - { - // todo: vector fonts - os::Printer::log("Unable to load font, XML vector fonts are not supported yet", f.Filename.c_str(), ELL_ERROR); - - //CGUIFontVector* font = new CGUIFontVector(Driver); - //ifont = (IGUIFont*)font; - //if (!font->load(xml)) - } - xml->drop(); - } - - - if (!ifont) - { - - CGUIFont* font = new CGUIFont(this, f.Filename ); - ifont = (IGUIFont*)font; - if (!font->load(f.Filename)) - { - font->drop(); - return 0; - } - } - - // add to fonts. - - f.Font = ifont; - Fonts.push_back(f); - - return ifont; -} - - -IGUISpriteBank* CGUIEnvironment::getSpriteBank(const io::path& filename) -{ - // search for the file name - - SSpriteBank b; - b.Filename = filename; - b.Filename.make_lower(); - - s32 index = Banks.binary_search(b); - if (index != -1) - return Banks[index].Bank; - - // we don't have this sprite bank, we should load it - - if (!FileSystem->existFile(b.Filename)) - { - os::Printer::log("Could not load sprite bank because the file does not exist", filename, ELL_ERROR); - return 0; - } - - // todo: load it! - - return 0; -} - - -IGUISpriteBank* CGUIEnvironment::addEmptySpriteBank(const io::path& name) -{ - // no duplicate names allowed - - SSpriteBank b; - b.Filename = name; - b.Filename.make_lower(); - - const s32 index = Banks.binary_search(b); - if (index != -1) - return 0; - - // create a new sprite bank - - b.Bank = new CGUISpriteBank(this); - Banks.push_back(b); - - return b.Bank; -} - - -//! returns default font -IGUIFont* CGUIEnvironment::getBuiltInFont() const -{ - if (Fonts.empty()) - return 0; - - return Fonts[0].Font; -} - -//! Creates the image list from the given texture. -IGUIImageList* CGUIEnvironment::createImageList( video::ITexture* texture, - core::dimension2d<s32> imageSize, bool useAlphaChannel ) -{ - CGUIImageList* imageList = new CGUIImageList( Driver ); - if( !imageList->createImageList( texture, imageSize, useAlphaChannel ) ) - { - imageList->drop(); - return 0; - } - - return imageList; -} - -//! Returns the root gui element. -IGUIElement* CGUIEnvironment::getRootGUIElement() -{ - return this; -} - - -//! Returns the next element in the tab group starting at the focused element -IGUIElement* CGUIEnvironment::getNextElement(bool reverse, bool group) -{ - // start the search at the root of the current tab group - IGUIElement *startPos = Focus ? Focus->getTabGroup() : 0; - s32 startOrder = -1; - - // if we're searching for a group - if (group && startPos) - { - startOrder = startPos->getTabOrder(); - } - else - if (!group && Focus && !Focus->isTabGroup()) - { - startOrder = Focus->getTabOrder(); - if (startOrder == -1) - { - // this element is not part of the tab cycle, - // but its parent might be... - IGUIElement *el = Focus; - while (el && el->getParent() && startOrder == -1) - { - el = el->getParent(); - startOrder = el->getTabOrder(); - } - - } - } - - if (group || !startPos) - startPos = this; // start at the root - - // find the element - IGUIElement *closest = 0; - IGUIElement *first = 0; - startPos->getNextElement(startOrder, reverse, group, first, closest); - - if (closest) - return closest; // we found an element - else if (first) - return first; // go to the end or the start - else if (group) - return this; // no group found? root group - else - return 0; -} - - -//! creates an GUI Environment -IGUIEnvironment* createGUIEnvironment(io::IFileSystem* fs, - video::IVideoDriver* Driver, - IOSOperator* op) -{ - return new CGUIEnvironment(fs, Driver, op); -} - - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - diff --git a/irrlicht-1.6/source/Irrlicht/CGUIEnvironment.h b/irrlicht-1.6/source/Irrlicht/CGUIEnvironment.h deleted file mode 100644 index ba0deab4d..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIEnvironment.h +++ /dev/null @@ -1,309 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_ENVIRONMENT_H_INCLUDED__ -#define __C_GUI_ENVIRONMENT_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUIEnvironment.h" -#include "IGUIElement.h" -#include "irrArray.h" -#include "IFileSystem.h" -#include "IOSOperator.h" - -namespace irr -{ -namespace io -{ - class IXMLWriter; -} -namespace gui -{ - -class CGUIEnvironment : public IGUIEnvironment, public IGUIElement -{ -public: - - //! constructor - CGUIEnvironment(io::IFileSystem* fs, video::IVideoDriver* driver, IOSOperator* op); - - //! destructor - virtual ~CGUIEnvironment(); - - //! draws all gui elements - virtual void drawAll(); - - //! returns the current video driver - virtual video::IVideoDriver* getVideoDriver() const; - - //! returns pointer to the filesystem - virtual io::IFileSystem* getFileSystem() const; - - //! returns a pointer to the OS operator - virtual IOSOperator* getOSOperator() const; - - //! posts an input event to the environment - virtual bool postEventFromUser(const SEvent& event); - - //! This sets a new event receiver for gui events. Usually you do not have to - //! use this method, it is used by the internal engine. - virtual void setUserEventReceiver(IEventReceiver* evr); - - //! removes all elements from the environment - virtual void clear(); - - //! called if an event happened. - virtual bool OnEvent(const SEvent& event); - - //! returns the current gui skin - virtual IGUISkin* getSkin() const; - - //! Sets a new GUI Skin - virtual void setSkin(IGUISkin* skin); - - //! Creates a new GUI Skin based on a template. - /** \return Returns a pointer to the created skin. - If you no longer need the skin, you should call IGUISkin::drop(). - See IReferenceCounted::drop() for more information. */ - virtual IGUISkin* createSkin(EGUI_SKIN_TYPE type); - - //! Creates the image list from the given texture. - virtual IGUIImageList* createImageList( video::ITexture* texture, - core::dimension2d<s32> imageSize, bool useAlphaChannel ); - - //! returns the font - virtual IGUIFont* getFont(const io::path& filename); - - - //! returns the sprite bank - virtual IGUISpriteBank* getSpriteBank(const io::path& filename); - - //! returns the sprite bank - virtual IGUISpriteBank* addEmptySpriteBank(const io::path& name); - - //! adds an button. The returned pointer must not be dropped. - virtual IGUIButton* addButton(const core::rect<s32>& rectangle, IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0,const wchar_t* tooltiptext = 0); - - //! adds a window. The returned pointer must not be dropped. - virtual IGUIWindow* addWindow(const core::rect<s32>& rectangle, bool modal = false, - const wchar_t* text=0, IGUIElement* parent=0, s32 id=-1); - - //! adds a modal screen. The returned pointer must not be dropped. - virtual IGUIElement* addModalScreen(IGUIElement* parent); - - //! Adds a message box. - virtual IGUIWindow* addMessageBox(const wchar_t* caption, const wchar_t* text=0, - bool modal = true, s32 flag = EMBF_OK, IGUIElement* parent=0, s32 id=-1); - - //! adds a scrollbar. The returned pointer must not be dropped. - virtual IGUIScrollBar* addScrollBar(bool horizontal, const core::rect<s32>& rectangle, - IGUIElement* parent=0, s32 id=-1); - - //! Adds an image element. - virtual IGUIImage* addImage(video::ITexture* image, core::position2d<s32> pos, - bool useAlphaChannel=true, IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0); - - //! adds an image. The returned pointer must not be dropped. - virtual IGUIImage* addImage(const core::rect<s32>& rectangle, - IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0); - - //! adds a checkbox - virtual IGUICheckBox* addCheckBox(bool checked, const core::rect<s32>& rectangle, IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0); - - //! adds a list box - virtual IGUIListBox* addListBox(const core::rect<s32>& rectangle, - IGUIElement* parent=0, s32 id=-1, bool drawBackground=false); - - //! adds a tree view - virtual IGUITreeView* addTreeView(const core::rect<s32>& rectangle, - IGUIElement* parent=0, s32 id=-1, bool drawBackground=false, - bool scrollBarVertical = true, bool scrollBarHorizontal = false); - - //! adds an mesh viewer. The returned pointer must not be dropped. - virtual IGUIMeshViewer* addMeshViewer(const core::rect<s32>& rectangle, IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0); - - //! Adds a file open dialog. - virtual IGUIFileOpenDialog* addFileOpenDialog(const wchar_t* title = 0, bool modal=true, IGUIElement* parent=0, s32 id=-1); - - //! Adds a color select dialog. - virtual IGUIColorSelectDialog* addColorSelectDialog(const wchar_t* title = 0, bool modal=true, IGUIElement* parent=0, s32 id=-1); - - //! adds a static text. The returned pointer must not be dropped. - virtual IGUIStaticText* addStaticText(const wchar_t* text, const core::rect<s32>& rectangle, - bool border=false, bool wordWrap=true, IGUIElement* parent=0, s32 id=-1, bool drawBackground = false); - - //! Adds an edit box. The returned pointer must not be dropped. - virtual IGUIEditBox* addEditBox(const wchar_t* text, const core::rect<s32>& rectangle, - bool border=false, IGUIElement* parent=0, s32 id=-1); - - //! Adds a spin box to the environment - virtual IGUISpinBox* addSpinBox(const wchar_t* text, const core::rect<s32>& rectangle, - bool border=false,IGUIElement* parent=0, s32 id=-1); - - //! Adds a tab control to the environment. - virtual IGUITabControl* addTabControl(const core::rect<s32>& rectangle, - IGUIElement* parent=0, bool fillbackground=false, bool border=true, s32 id=-1); - - //! Adds tab to the environment. - virtual IGUITab* addTab(const core::rect<s32>& rectangle, - IGUIElement* parent=0, s32 id=-1); - - //! Adds a context menu to the environment. - virtual IGUIContextMenu* addContextMenu(const core::rect<s32>& rectangle, - IGUIElement* parent=0, s32 id=-1); - - //! Adds a menu to the environment. - virtual IGUIContextMenu* addMenu(IGUIElement* parent=0, s32 id=-1); - - //! Adds a toolbar to the environment. It is like a menu is always placed on top - //! in its parent, and contains buttons. - virtual IGUIToolBar* addToolBar(IGUIElement* parent=0, s32 id=-1); - - //! Adds a combo box to the environment. - virtual IGUIComboBox* addComboBox(const core::rect<s32>& rectangle, - IGUIElement* parent=0, s32 id=-1); - - //! Adds a table element. - virtual IGUITable* addTable(const core::rect<s32>& rectangle, - IGUIElement* parent=0, s32 id=-1, bool drawBackground=false); - - //! sets the focus to an element - virtual bool setFocus(IGUIElement* element); - - //! removes the focus from an element - virtual bool removeFocus(IGUIElement* element); - - //! Returns if the element has focus - virtual bool hasFocus(IGUIElement* element) const; - - //! Returns the element with the focus - virtual IGUIElement* getFocus() const; - - //! returns default font - virtual IGUIFont* getBuiltInFont() const; - - //! Adds an element for fading in or out. - virtual IGUIInOutFader* addInOutFader(const core::rect<s32>* rectangle=0, IGUIElement* parent=0, s32 id=-1); - - //! Returns the root gui element. - virtual IGUIElement* getRootGUIElement(); - - virtual void OnPostRender( u32 time ); - - //! Returns the default element factory which can create all built in elements - virtual IGUIElementFactory* getDefaultGUIElementFactory() const; - - //! Adds an element factory to the gui environment. - /** Use this to extend the gui environment with new element types which it should be - able to create automaticly, for example when loading data from xml files. */ - virtual void registerGUIElementFactory(IGUIElementFactory* factoryToAdd); - - //! Returns amount of registered scene node factories. - virtual u32 getRegisteredGUIElementFactoryCount() const; - - //! Returns a scene node factory by index - virtual IGUIElementFactory* getGUIElementFactory(u32 index) const; - - //! Adds a GUI Element by its name - virtual IGUIElement* addGUIElement(const c8* elementName, IGUIElement* parent=0); - - //! Saves the current gui into a file. - /** \param filename: Name of the file. - \param start: The element to start saving from. - if not specified, the root element will be used */ - virtual bool saveGUI( const io::path& filename, IGUIElement* start=0); - - //! Saves the current gui into a file. - /** \param file: The file to save the GUI to. - \param start: The element to start saving from. - if not specified, the root element will be used */ - virtual bool saveGUI(io::IWriteFile* file, IGUIElement* start=0); - - //! Loads the gui. Note that the current gui is not cleared before. - /** \param filename: Name of the file. - \param parent: The parent of all loaded GUI elements, - if not specified, the root element will be used */ - virtual bool loadGUI(const io::path& filename, IGUIElement* parent=0); - - //! Loads the gui. Note that the current gui is not cleared before. - /** \param file: IReadFile to load the GUI from - \param parent: The parent of all loaded GUI elements, - if not specified, the root element will be used */ - virtual bool loadGUI(io::IReadFile* file, IGUIElement* parent=0); - - //! Writes attributes of the environment - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const; - - //! Reads attributes of the environment. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - //! writes an element - virtual void writeGUIElement(io::IXMLWriter* writer, IGUIElement* node); - - //! reads an element - virtual void readGUIElement(io::IXMLReader* reader, IGUIElement* node); - -private: - - IGUIElement* getNextElement(bool reverse=false, bool group=false); - - void updateHoveredElement(core::position2d<s32> mousePos); - - void loadBuiltInFont(); - - struct SFont - { - io::path Filename; - IGUIFont* Font; - - bool operator < (const SFont& other) const - { - return (Filename < other.Filename); - } - }; - - struct SSpriteBank - { - core::stringc Filename; - IGUISpriteBank* Bank; - - bool operator < (const SSpriteBank& other) const - { - return (Filename < other.Filename); - } - }; - - struct SToolTip - { - IGUIStaticText* Element; - u32 LastTime; - u32 LaunchTime; - }; - - SToolTip ToolTip; - - core::array<IGUIElementFactory*> GUIElementFactoryList; - - core::array<SFont> Fonts; - core::array<SSpriteBank> Banks; - video::IVideoDriver* Driver; - IGUIElement* Hovered; - IGUIElement* Focus; - core::position2d<s32> LastHoveredMousePos; - IGUISkin* CurrentSkin; - io::IFileSystem* FileSystem; - IEventReceiver* UserReceiver; - IOSOperator* Operator; -}; - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - -#endif // __C_GUI_ENVIRONMENT_H_INCLUDED__ - - diff --git a/irrlicht-1.6/source/Irrlicht/CGUIFileOpenDialog.cpp b/irrlicht-1.6/source/Irrlicht/CGUIFileOpenDialog.cpp deleted file mode 100644 index c426d9211..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIFileOpenDialog.cpp +++ /dev/null @@ -1,396 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUIFileOpenDialog.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include <locale.h> - -#include "IGUISkin.h" -#include "IGUIEnvironment.h" -#include "IVideoDriver.h" -#include "IGUIButton.h" -#include "IGUIStaticText.h" -#include "IGUIFont.h" -#include "IGUIFontBitmap.h" -#include "IFileList.h" -#include "os.h" - -namespace irr -{ -namespace gui -{ - -const s32 FOD_WIDTH = 350; -const s32 FOD_HEIGHT = 250; - - -//! constructor -CGUIFileOpenDialog::CGUIFileOpenDialog(const wchar_t* title, - IGUIEnvironment* environment, IGUIElement* parent, s32 id) -: IGUIFileOpenDialog(environment, parent, id, - core::rect<s32>((parent->getAbsolutePosition().getWidth()-FOD_WIDTH)/2, - (parent->getAbsolutePosition().getHeight()-FOD_HEIGHT)/2, - (parent->getAbsolutePosition().getWidth()-FOD_WIDTH)/2+FOD_WIDTH, - (parent->getAbsolutePosition().getHeight()-FOD_HEIGHT)/2+FOD_HEIGHT)), - FileNameText(0), FileList(0), Dragging(false) -{ - #ifdef _DEBUG - IGUIElement::setDebugName("CGUIFileOpenDialog"); - #endif - - Text = title; - - IGUISkin* skin = Environment->getSkin(); - IGUISpriteBank* sprites = 0; - video::SColor color(255,255,255,255); - if (skin) - { - sprites = skin->getSpriteBank(); - color = skin->getColor(EGDC_WINDOW_SYMBOL); - } - - const s32 buttonw = environment->getSkin()->getSize(EGDS_WINDOW_BUTTON_WIDTH); - const s32 posx = RelativeRect.getWidth() - buttonw - 4; - - CloseButton = Environment->addButton(core::rect<s32>(posx, 3, posx + buttonw, 3 + buttonw), this, -1, - L"", skin ? skin->getDefaultText(EGDT_WINDOW_CLOSE) : L"Close"); - CloseButton->setSubElement(true); - CloseButton->setTabStop(false); - if (sprites) - { - CloseButton->setSpriteBank(sprites); - CloseButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_CLOSE), color); - CloseButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_CLOSE), color); - } - CloseButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - CloseButton->grab(); - - OKButton = Environment->addButton( - core::rect<s32>(RelativeRect.getWidth()-80, 30, RelativeRect.getWidth()-10, 50), - this, -1, skin ? skin->getDefaultText(EGDT_MSG_BOX_OK) : L"OK"); - OKButton->setSubElement(true); - OKButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - OKButton->grab(); - - CancelButton = Environment->addButton( - core::rect<s32>(RelativeRect.getWidth()-80, 55, RelativeRect.getWidth()-10, 75), - this, -1, skin ? skin->getDefaultText(EGDT_MSG_BOX_CANCEL) : L"Cancel"); - CancelButton->setSubElement(true); - CancelButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - CancelButton->grab(); - - FileBox = Environment->addListBox(core::rect<s32>(10, 55, RelativeRect.getWidth()-90, 230), this, -1, true); - FileBox->setSubElement(true); - FileBox->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); - FileBox->grab(); - - FileNameText = Environment->addEditBox(0, core::rect<s32>(10, 30, RelativeRect.getWidth()-90, 50), true, this); - FileNameText->setSubElement(true); - FileNameText->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - FileNameText->grab(); - - FileSystem = Environment->getFileSystem(); - - if (FileSystem) - FileSystem->grab(); - - setTabGroup(true); - - fillListBox(); -} - - -//! destructor -CGUIFileOpenDialog::~CGUIFileOpenDialog() -{ - if (CloseButton) - CloseButton->drop(); - - if (OKButton) - OKButton->drop(); - - if (CancelButton) - CancelButton->drop(); - - if (FileBox) - FileBox->drop(); - - if (FileNameText) - FileNameText->drop(); - - if (FileSystem) - FileSystem->drop(); - - if (FileList) - FileList->drop(); -} - - -//! returns the filename of the selected file. Returns NULL, if no file was selected. -const wchar_t* CGUIFileOpenDialog::getFileName() const -{ - return FileName.c_str(); -} - -//! Returns the directory of the selected file. Returns NULL, if no directory was selected. -const io::path& CGUIFileOpenDialog::getDirectoryName() -{ - FileSystem->flattenFilename ( FileDirectory ); - return FileDirectory; -} - - -//! called if an event happened. -bool CGUIFileOpenDialog::OnEvent(const SEvent& event) -{ - if (IsEnabled) - { - switch(event.EventType) - { - case EET_GUI_EVENT: - switch(event.GUIEvent.EventType) - { - case EGET_ELEMENT_FOCUS_LOST: - Dragging = false; - break; - case EGET_BUTTON_CLICKED: - if (event.GUIEvent.Caller == CloseButton || - event.GUIEvent.Caller == CancelButton) - { - sendCancelEvent(); - remove(); - return true; - } - else - if (event.GUIEvent.Caller == OKButton ) - { - if ( FileDirectory != L"" ) - { - sendSelectedEvent( EGET_DIRECTORY_SELECTED ); - } - if ( FileName != L"" ) - { - sendSelectedEvent( EGET_FILE_SELECTED ); - remove(); - return true; - } - } - break; - - case EGET_LISTBOX_CHANGED: - { - s32 selected = FileBox->getSelected(); - if (FileList && FileSystem) - { - if (FileList->isDirectory(selected)) - { - FileName = L""; - FileDirectory = FileList->getFullFileName(selected); - } - else - { - FileDirectory = L""; - FileName = FileList->getFullFileName(selected); - } - } - } - break; - - case EGET_LISTBOX_SELECTED_AGAIN: - { - const s32 selected = FileBox->getSelected(); - if (FileList && FileSystem) - { - if (FileList->isDirectory(selected)) - { - FileDirectory = FileList->getFullFileName(selected); - FileSystem->changeWorkingDirectoryTo(FileList->getFileName(selected)); - fillListBox(); - FileName = ""; - } - else - { - FileName = FileList->getFullFileName(selected); - return true; - } - } - } - break; - case EGET_EDITBOX_ENTER: - if (event.GUIEvent.Caller == FileNameText) - { - io::path dir( FileNameText->getText () ); - if ( FileSystem->changeWorkingDirectoryTo( dir ) ) - { - fillListBox(); - FileName = L""; - } - return true; - } - break; - default: - break; - } - break; - case EET_MOUSE_INPUT_EVENT: - switch(event.MouseInput.Event) - { - case EMIE_MOUSE_WHEEL: - return FileBox->OnEvent(event); - case EMIE_LMOUSE_PRESSED_DOWN: - DragStart.X = event.MouseInput.X; - DragStart.Y = event.MouseInput.Y; - Dragging = true; - Environment->setFocus(this); - return true; - case EMIE_LMOUSE_LEFT_UP: - Dragging = false; - return true; - case EMIE_MOUSE_MOVED: - - if ( !event.MouseInput.isLeftPressed () ) - Dragging = false; - - if (Dragging) - { - // gui window should not be dragged outside its parent - if (Parent) - if (event.MouseInput.X < Parent->getAbsolutePosition().UpperLeftCorner.X +1 || - event.MouseInput.Y < Parent->getAbsolutePosition().UpperLeftCorner.Y +1 || - event.MouseInput.X > Parent->getAbsolutePosition().LowerRightCorner.X -1 || - event.MouseInput.Y > Parent->getAbsolutePosition().LowerRightCorner.Y -1) - - return true; - - move(core::position2d<s32>(event.MouseInput.X - DragStart.X, event.MouseInput.Y - DragStart.Y)); - DragStart.X = event.MouseInput.X; - DragStart.Y = event.MouseInput.Y; - return true; - } - break; - default: - break; - } - default: - break; - } - } - - return IGUIElement::OnEvent(event); -} - - -//! draws the element and its children -void CGUIFileOpenDialog::draw() -{ - if (!IsVisible) - return; - - IGUISkin* skin = Environment->getSkin(); - - core::rect<s32> rect = AbsoluteRect; - - rect = skin->draw3DWindowBackground(this, true, skin->getColor(EGDC_ACTIVE_BORDER), - rect, &AbsoluteClippingRect); - - if (Text.size()) - { - rect.UpperLeftCorner.X += 2; - rect.LowerRightCorner.X -= skin->getSize(EGDS_WINDOW_BUTTON_WIDTH) + 5; - - IGUIFont* font = skin->getFont(EGDF_WINDOW); - if (font) - font->draw(Text.c_str(), rect, - skin->getColor(EGDC_ACTIVE_CAPTION), - false, true, &AbsoluteClippingRect); - } - - IGUIElement::draw(); -} - - -//! fills the listbox with files. -void CGUIFileOpenDialog::fillListBox() -{ - IGUISkin *skin = Environment->getSkin(); - - if (!FileSystem || !FileBox || !skin) - return; - - if (FileList) - FileList->drop(); - - FileBox->clear(); - - FileList = FileSystem->createFileList(); - core::stringw s; - - setlocale(LC_ALL,""); - - if (FileList) - { - for (u32 i=0; i < FileList->getFileCount(); ++i) - { - #ifndef _IRR_WCHAR_FILESYSTEM - const c8 *cs = (const c8 *)FileList->getFileName(i).c_str(); - wchar_t *ws = new wchar_t[strlen(cs) + 1]; - int len = mbstowcs(ws,cs,strlen(cs)); - ws[len] = 0; - s = ws; - delete [] ws; - #else - s = FileList->getFileName(i).c_str(); - #endif - FileBox->addItem(s.c_str(), skin->getIcon(FileList->isDirectory(i) ? EGDI_DIRECTORY : EGDI_FILE)); - } - } - - if (FileNameText) - { - #ifndef _IRR_WCHAR_FILESYSTEM - const c8 *cs = (const c8 *)FileSystem->getWorkingDirectory().c_str(); - wchar_t *ws = new wchar_t[strlen(cs) + 1]; - int len = mbstowcs(ws,cs,strlen(cs)); - ws[len] = 0; - s = ws; - delete ws; - #else - s = FileSystem->getWorkingDirectory(); - #endif - - FileDirectory = s; - FileNameText->setText(s.c_str()); - } -} - - -//! sends the event that the file has been selected. -void CGUIFileOpenDialog::sendSelectedEvent( EGUI_EVENT_TYPE type) -{ - SEvent event; - event.EventType = EET_GUI_EVENT; - event.GUIEvent.Caller = this; - event.GUIEvent.Element = 0; - event.GUIEvent.EventType = type; - Parent->OnEvent(event); -} - - -//! sends the event that the file choose process has been canceld -void CGUIFileOpenDialog::sendCancelEvent() -{ - SEvent event; - event.EventType = EET_GUI_EVENT; - event.GUIEvent.Caller = this; - event.GUIEvent.Element = 0; - event.GUIEvent.EventType = EGET_FILE_CHOOSE_DIALOG_CANCELLED; - Parent->OnEvent(event); -} - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - diff --git a/irrlicht-1.6/source/Irrlicht/CGUIFileOpenDialog.h b/irrlicht-1.6/source/Irrlicht/CGUIFileOpenDialog.h deleted file mode 100644 index 8aa4c7c20..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIFileOpenDialog.h +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_FILE_OPEN_DIALOG_H_INCLUDED__ -#define __C_GUI_FILE_OPEN_DIALOG_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUIFileOpenDialog.h" -#include "IGUIButton.h" -#include "IGUIListBox.h" -#include "IGUIEditBox.h" -#include "IFileSystem.h" - -namespace irr -{ -namespace gui -{ - - class CGUIFileOpenDialog : public IGUIFileOpenDialog - { - public: - - //! constructor - CGUIFileOpenDialog(const wchar_t* title, IGUIEnvironment* environment, IGUIElement* parent, s32 id); - - //! destructor - virtual ~CGUIFileOpenDialog(); - - //! returns the filename of the selected file. Returns NULL, if no file was selected. - virtual const wchar_t* getFileName() const; - - //! Returns the directory of the selected file. Returns NULL, if no directory was selected. - virtual const io::path& getDirectoryName(); - - //! called if an event happened. - virtual bool OnEvent(const SEvent& event); - - //! draws the element and its children - virtual void draw(); - - protected: - - //! fills the listbox with files. - void fillListBox(); - - //! sends the event that the file has been selected. - void sendSelectedEvent( EGUI_EVENT_TYPE type ); - - //! sends the event that the file choose process has been canceld - void sendCancelEvent(); - - core::position2d<s32> DragStart; - core::stringw FileName; - io::path FileDirectory; - - IGUIButton* CloseButton; - IGUIButton* OKButton; - IGUIButton* CancelButton; - IGUIListBox* FileBox; - IGUIEditBox* FileNameText; - IGUIElement* EventParent; - io::IFileSystem* FileSystem; - io::IFileList* FileList; - bool Dragging; - }; - - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - -#endif // __C_GUI_FILE_OPEN_DIALOG_H_INCLUDED__ - diff --git a/irrlicht-1.6/source/Irrlicht/CGUIFont.cpp b/irrlicht-1.6/source/Irrlicht/CGUIFont.cpp deleted file mode 100644 index 6a279f153..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIFont.cpp +++ /dev/null @@ -1,570 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUIFont.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "os.h" -#include "IGUIEnvironment.h" -#include "IXMLReader.h" -#include "IReadFile.h" -#include "IVideoDriver.h" -#include "IGUISpriteBank.h" -#include "CImage.h" - -namespace irr -{ -namespace gui -{ - -//! constructor -CGUIFont::CGUIFont(IGUIEnvironment *env, const io::path& filename) -: Driver(0), SpriteBank(0), Environment(env), WrongCharacter(0), - MaxHeight(0), GlobalKerningWidth(0), GlobalKerningHeight(0) -{ - #ifdef _DEBUG - setDebugName("CGUIFont"); - #endif - - if (Environment) - { - // don't grab environment, to avoid circular references - Driver = Environment->getVideoDriver(); - - SpriteBank = Environment->addEmptySpriteBank(filename); - if (SpriteBank) - SpriteBank->grab(); - } - - if (Driver) - Driver->grab(); - - setInvisibleCharacters ( L" " ); -} - - -//! destructor -CGUIFont::~CGUIFont() -{ - if (Driver) - Driver->drop(); - - if (SpriteBank) - SpriteBank->drop(); -} - - -//! loads a font file from xml -bool CGUIFont::load(io::IXMLReader* xml) -{ - if (!SpriteBank) - return false; - - while (xml->read()) - { - if (io::EXN_ELEMENT == xml->getNodeType()) - { - if (core::stringw(L"Texture") == xml->getNodeName()) - { - // add a texture - core::stringc fn = xml->getAttributeValue(L"filename"); - u32 i = (u32)xml->getAttributeValueAsInt(L"index"); - core::stringw alpha = xml->getAttributeValue(L"hasAlpha"); - - while (i+1 > SpriteBank->getTextureCount()) - SpriteBank->addTexture(0); - - // disable mipmaps+filtering - bool mipmap = Driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS); - Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false); - - // load texture - SpriteBank->setTexture(i, Driver->getTexture(fn)); - - // set previous mip-map+filter state - Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, mipmap); - - // couldn't load texture, abort. - if (!SpriteBank->getTexture(i)) - { - os::Printer::log("Unable to load all textures in the font, aborting", ELL_ERROR); - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; - } - else - { - // colorkey texture rather than alpha channel? - if (alpha == core::stringw("false")) - Driver->makeColorKeyTexture(SpriteBank->getTexture(i), core::position2di(0,0)); - } - } - else if (core::stringw(L"c") == xml->getNodeName()) - { - // adding a character to this font - SFontArea a; - SGUISpriteFrame f; - SGUISprite s; - core::rect<s32> rectangle; - - a.underhang = xml->getAttributeValueAsInt(L"u"); - a.overhang = xml->getAttributeValueAsInt(L"o"); - a.spriteno = SpriteBank->getSprites().size(); - s32 texno = xml->getAttributeValueAsInt(L"i"); - - // parse rectangle - core::stringc rectstr = xml->getAttributeValue(L"r"); - wchar_t ch = xml->getAttributeValue(L"c")[0]; - - const c8 *c = rectstr.c_str(); - s32 val; - val = 0; - while (*c >= '0' && *c <= '9') - { - val *= 10; - val += *c - '0'; - c++; - } - rectangle.UpperLeftCorner.X = val; - while (*c == L' ' || *c == L',') c++; - - val = 0; - while (*c >= '0' && *c <= '9') - { - val *= 10; - val += *c - '0'; - c++; - } - rectangle.UpperLeftCorner.Y = val; - while (*c == L' ' || *c == L',') c++; - - val = 0; - while (*c >= '0' && *c <= '9') - { - val *= 10; - val += *c - '0'; - c++; - } - rectangle.LowerRightCorner.X = val; - while (*c == L' ' || *c == L',') c++; - - val = 0; - while (*c >= '0' && *c <= '9') - { - val *= 10; - val += *c - '0'; - c++; - } - rectangle.LowerRightCorner.Y = val; - - CharacterMap.insert(ch,Areas.size()); - - // make frame - f.rectNumber = SpriteBank->getPositions().size(); - f.textureNumber = texno; - - // add frame to sprite - s.Frames.push_back(f); - s.frameTime = 0; - - // add rectangle to sprite bank - SpriteBank->getPositions().push_back(rectangle); - a.width = rectangle.getWidth(); - - // add sprite to sprite bank - SpriteBank->getSprites().push_back(s); - - // add character to font - Areas.push_back(a); - } - } - } - - // set bad character - WrongCharacter = getAreaFromCharacter(L' '); - - setMaxHeight(); - - return true; -} - - -void CGUIFont::setMaxHeight() -{ - MaxHeight = 0; - s32 t; - - core::array< core::rect<s32> >& p = SpriteBank->getPositions(); - - for (u32 i=0; i<p.size(); ++i) - { - t = p[i].getHeight(); - if (t>MaxHeight) - MaxHeight = t; - } - -} - - -//! loads a font file, native file needed, for texture parsing -bool CGUIFont::load(io::IReadFile* file) -{ - if (!Driver) - return false; - - return loadTexture(Driver->createImageFromFile(file), - file->getFileName()); -} - - -//! loads a font file, native file needed, for texture parsing -bool CGUIFont::load(const io::path& filename) -{ - if (!Driver) - return false; - - return loadTexture(Driver->createImageFromFile( filename ), - filename); -} - - -//! load & prepare font from ITexture -bool CGUIFont::loadTexture(video::IImage* image, const io::path& name) -{ - if (!image) - return false; - - s32 lowerRightPositions = 0; - - video::IImage* tmpImage=image; - bool deleteTmpImage=false; - switch(image->getColorFormat()) - { - case video::ECF_R5G6B5: - tmpImage = new video::CImage(video::ECF_A1R5G5B5,image); - deleteTmpImage=true; - break; - case video::ECF_A1R5G5B5: - case video::ECF_A8R8G8B8: - break; - case video::ECF_R8G8B8: - tmpImage = new video::CImage(video::ECF_A8R8G8B8,image); - deleteTmpImage=true; - break; - } - readPositions(tmpImage, lowerRightPositions); - - WrongCharacter = getAreaFromCharacter(L' '); - - // output warnings - if (!lowerRightPositions || !SpriteBank->getSprites().size()) - os::Printer::log("Either no upper or lower corner pixels in the font file. If this font was made using the new font tool, please load the XML file instead. If not, the font may be corrupted.", ELL_ERROR); - else - if (lowerRightPositions != (s32)SpriteBank->getPositions().size()) - os::Printer::log("The amount of upper corner pixels and the lower corner pixels is not equal, font file may be corrupted.", ELL_ERROR); - - bool ret = ( !SpriteBank->getSprites().empty() && lowerRightPositions ); - - if ( ret ) - { - bool flag[2]; - flag[0] = Driver->getTextureCreationFlag ( video::ETCF_ALLOW_NON_POWER_2 ); - flag[1] = Driver->getTextureCreationFlag ( video::ETCF_CREATE_MIP_MAPS ); - - Driver->setTextureCreationFlag(video::ETCF_ALLOW_NON_POWER_2, true); - Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false ); - - SpriteBank->addTexture(Driver->addTexture(name, tmpImage)); - - Driver->setTextureCreationFlag(video::ETCF_ALLOW_NON_POWER_2, flag[0] ); - Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, flag[1] ); - } - if (deleteTmpImage) - tmpImage->drop(); - image->drop(); - - setMaxHeight(); - - return ret; -} - - -void CGUIFont::readPositions(video::IImage* image, s32& lowerRightPositions) -{ - const core::dimension2d<u32> size = image->getDimension(); - - video::SColor colorTopLeft = image->getPixel(0,0); - colorTopLeft.setAlpha(255); - image->setPixel(0,0,colorTopLeft); - video::SColor colorLowerRight = image->getPixel(1,0); - video::SColor colorBackGround = image->getPixel(2,0); - video::SColor colorBackGroundTransparent = 0; - - image->setPixel(1,0,colorBackGround); - - // start parsing - - core::position2d<s32> pos(0,0); - for (pos.Y=0; pos.Y<(s32)size.Height; ++pos.Y) - { - for (pos.X=0; pos.X<(s32)size.Width; ++pos.X) - { - const video::SColor c = image->getPixel(pos.X, pos.Y); - if (c == colorTopLeft) - { - image->setPixel(pos.X, pos.Y, colorBackGroundTransparent); - SpriteBank->getPositions().push_back(core::rect<s32>(pos, pos)); - } - else - if (c == colorLowerRight) - { - // too many lower right points - if (SpriteBank->getPositions().size()<=(u32)lowerRightPositions) - { - lowerRightPositions = 0; - return; - } - - image->setPixel(pos.X, pos.Y, colorBackGroundTransparent); - SpriteBank->getPositions()[lowerRightPositions].LowerRightCorner = pos; - // add frame to sprite bank - SGUISpriteFrame f; - f.rectNumber = lowerRightPositions; - f.textureNumber = 0; - SGUISprite s; - s.Frames.push_back(f); - s.frameTime = 0; - SpriteBank->getSprites().push_back(s); - // add character to font - SFontArea a; - a.overhang = 0; - a.underhang = 0; - a.spriteno = lowerRightPositions; - a.width = SpriteBank->getPositions()[lowerRightPositions].getWidth(); - Areas.push_back(a); - // map letter to character - wchar_t ch = (wchar_t)(lowerRightPositions + 32); - CharacterMap.set(ch, lowerRightPositions); - - ++lowerRightPositions; - } - else - if (c == colorBackGround) - image->setPixel(pos.X, pos.Y, colorBackGroundTransparent); - } - } -} - - -//! set an Pixel Offset on Drawing ( scale position on width ) -void CGUIFont::setKerningWidth(s32 kerning) -{ - GlobalKerningWidth = kerning; -} - - -//! set an Pixel Offset on Drawing ( scale position on width ) -s32 CGUIFont::getKerningWidth(const wchar_t* thisLetter, const wchar_t* previousLetter) const -{ - s32 ret = GlobalKerningWidth; - - if (thisLetter) - { - ret += Areas[getAreaFromCharacter(*thisLetter)].overhang; - - if (previousLetter) - { - ret += Areas[getAreaFromCharacter(*previousLetter)].underhang; - } - } - - return ret; -} - - -//! set an Pixel Offset on Drawing ( scale position on height ) -void CGUIFont::setKerningHeight(s32 kerning) -{ - GlobalKerningHeight = kerning; -} - - -//! set an Pixel Offset on Drawing ( scale position on height ) -s32 CGUIFont::getKerningHeight () const -{ - return GlobalKerningHeight; -} - - -//! returns the sprite number from a given character -u32 CGUIFont::getSpriteNoFromChar(const wchar_t *c) const -{ - return Areas[getAreaFromCharacter(*c)].spriteno; -} - - -s32 CGUIFont::getAreaFromCharacter(const wchar_t c) const -{ - core::map<wchar_t, s32>::Node* n = CharacterMap.find(c); - if (n) - return n->getValue(); - else - return WrongCharacter; -} - -void CGUIFont::setInvisibleCharacters( const wchar_t *s ) -{ - Invisible = s; -} - - -//! returns the dimension of text -core::dimension2d<u32> CGUIFont::getDimension(const wchar_t* text) const -{ - core::dimension2d<u32> dim(0, 0); - core::dimension2d<u32> thisLine(0, MaxHeight); - - for (const wchar_t* p = text; *p; ++p) - { - bool lineBreak=false; - if (*p == L'\r') // Mac or Windows breaks - { - lineBreak = true; - if (p[1] == L'\n') // Windows breaks - ++p; - } - else if (*p == L'\n') // Unix breaks - { - lineBreak = true; - } - if (lineBreak) - { - dim.Height += thisLine.Height; - if (dim.Width < thisLine.Width) - dim.Width = thisLine.Width; - thisLine.Width = 0; - continue; - } - - const SFontArea &area = Areas[getAreaFromCharacter(*p)]; - - thisLine.Width += area.underhang; - thisLine.Width += area.width + area.overhang + GlobalKerningWidth; - } - - dim.Height += thisLine.Height; - if (dim.Width < thisLine.Width) - dim.Width = thisLine.Width; - - return dim; -} - -//! draws some text and clips it to the specified rectangle if wanted -void CGUIFont::draw(const core::stringw& text, const core::rect<s32>& position, - video::SColor color, - bool hcenter, bool vcenter, const core::rect<s32>* clip - ) -{ - if (!Driver) - return; - - core::dimension2d<s32> textDimension; - core::position2d<s32> offset = position.UpperLeftCorner; - - if (hcenter || vcenter || clip) - textDimension = getDimension(text.c_str()); - - if (hcenter) - offset.X += (position.getWidth() - textDimension.Width) >> 1; - - if (vcenter) - offset.Y += (position.getHeight() - textDimension.Height) >> 1; - - if (clip) - { - core::rect<s32> clippedRect(offset, textDimension); - clippedRect.clipAgainst(*clip); - if (!clippedRect.isValid()) - return; - } - - core::array<u32> indices(text.size()); - core::array<core::position2di> offsets(text.size()); - - for(u32 i = 0;i < text.size();i++) - { - wchar_t c = text[i]; - - bool lineBreak=false; - if ( c == L'\r') // Mac or Windows breaks - { - lineBreak = true; - if ( text[i + 1] == L'\n') // Windows breaks - c = text[++i]; - } - else if ( c == L'\n') // Unix breaks - { - lineBreak = true; - } - - if (lineBreak) - { - offset.Y += MaxHeight; - offset.X = position.UpperLeftCorner.X; - - if ( hcenter ) - { - core::dimension2d<u32> lineDim = getDimension(text.c_str()); - offset.X += (position.getWidth() - lineDim.Width) >> 1; - } - continue; - } - - SFontArea& area = Areas[getAreaFromCharacter(c)]; - - offset.X += area.underhang; - if ( Invisible.findFirst ( c ) < 0 ) - { - indices.push_back(area.spriteno); - offsets.push_back(offset); - } - - offset.X += area.width + area.overhang + GlobalKerningWidth; - } - - SpriteBank->draw2DSpriteBatch(indices, offsets, clip, color); -} - - -//! Calculates the index of the character in the text which is on a specific position. -s32 CGUIFont::getCharacterFromPos(const wchar_t* text, s32 pixel_x) const -{ - s32 x = 0; - s32 idx = 0; - - while (text[idx]) - { - const SFontArea& a = Areas[getAreaFromCharacter(text[idx])]; - - x += a.width + a.overhang + a.underhang + GlobalKerningWidth; - - if (x >= pixel_x) - return idx; - - ++idx; - } - - return -1; -} - - -IGUISpriteBank* CGUIFont::getSpriteBank() const -{ - return SpriteBank; -} - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - diff --git a/irrlicht-1.6/source/Irrlicht/CGUIFont.h b/irrlicht-1.6/source/Irrlicht/CGUIFont.h deleted file mode 100644 index e9a8d30ee..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIFont.h +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_FONT_H_INCLUDED__ -#define __C_GUI_FONT_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUIFontBitmap.h" -#include "irrString.h" -#include "irrMap.h" -#include "IXMLReader.h" -#include "IReadFile.h" -#include "irrArray.h" - -namespace irr -{ - -namespace video -{ - class IVideoDriver; - class IImage; -} - -namespace gui -{ - - class IGUIEnvironment; - -class CGUIFont : public IGUIFontBitmap -{ -public: - - //! constructor - CGUIFont(IGUIEnvironment* env, const io::path& filename); - - //! destructor - virtual ~CGUIFont(); - - //! loads a font from a texture file - bool load(const io::path& filename); - - //! loads a font from a texture file - bool load(io::IReadFile* file); - - //! loads a font from an XML file - bool load(io::IXMLReader* xml); - - //! draws an text and clips it to the specified rectangle if wanted - virtual void draw(const core::stringw& text, const core::rect<s32>& position, - video::SColor color, bool hcenter=false, - bool vcenter=false, const core::rect<s32>* clip=0); - - //! returns the dimension of a text - virtual core::dimension2d<u32> getDimension(const wchar_t* text) const; - - //! Calculates the index of the character in the text which is on a specific position. - virtual s32 getCharacterFromPos(const wchar_t* text, s32 pixel_x) const; - - //! Returns the type of this font - virtual EGUI_FONT_TYPE getType() const { return EGFT_BITMAP; } - - //! set an Pixel Offset on Drawing ( scale position on width ) - virtual void setKerningWidth (s32 kerning); - virtual void setKerningHeight (s32 kerning); - - //! set an Pixel Offset on Drawing ( scale position on width ) - virtual s32 getKerningWidth(const wchar_t* thisLetter=0, const wchar_t* previousLetter=0) const; - virtual s32 getKerningHeight() const; - - //! gets the sprite bank - virtual IGUISpriteBank* getSpriteBank() const; - - //! returns the sprite number from a given character - virtual u32 getSpriteNoFromChar(const wchar_t *c) const; - - virtual void setInvisibleCharacters( const wchar_t *s ); - -private: - - struct SFontArea - { - SFontArea() : underhang(0), overhang(0), width(0), spriteno(0) {} - s32 underhang; - s32 overhang; - s32 width; - u32 spriteno; - }; - - //! load & prepare font from ITexture - bool loadTexture(video::IImage * image, const io::path& name); - - void readPositions(video::IImage* texture, s32& lowerRightPositions); - - s32 getAreaFromCharacter (const wchar_t c) const; - void setMaxHeight(); - - core::array<SFontArea> Areas; - core::map<wchar_t, s32> CharacterMap; - video::IVideoDriver* Driver; - IGUISpriteBank* SpriteBank; - IGUIEnvironment* Environment; - u32 WrongCharacter; - s32 MaxHeight; - s32 GlobalKerningWidth, GlobalKerningHeight; - - core::stringw Invisible; -}; - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - -#endif // __C_GUI_FONT_H_INCLUDED__ - diff --git a/irrlicht-1.6/source/Irrlicht/CGUIImage.cpp b/irrlicht-1.6/source/Irrlicht/CGUIImage.cpp deleted file mode 100644 index 0bf3dd89f..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIImage.cpp +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUIImage.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUISkin.h" -#include "IGUIEnvironment.h" -#include "IVideoDriver.h" - -namespace irr -{ -namespace gui -{ - - -//! constructor -CGUIImage::CGUIImage(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle) -: IGUIImage(environment, parent, id, rectangle), Texture(0), Color(255,255,255,255), - UseAlphaChannel(false), ScaleImage(false) -{ - #ifdef _DEBUG - setDebugName("CGUIImage"); - #endif -} - - -//! destructor -CGUIImage::~CGUIImage() -{ - if (Texture) - Texture->drop(); -} - - -//! sets an image -void CGUIImage::setImage(video::ITexture* image) -{ - if (image == Texture) - return; - - if (Texture) - Texture->drop(); - - Texture = image; - - if (Texture) - Texture->grab(); -} - - -//! sets the color of the image -void CGUIImage::setColor(video::SColor color) -{ - Color = color; -} - - -//! draws the element and its children -void CGUIImage::draw() -{ - if (!IsVisible) - return; - - IGUISkin* skin = Environment->getSkin(); - video::IVideoDriver* driver = Environment->getVideoDriver(); - - core::rect<s32> rect = AbsoluteRect; - - if (Texture) - { - if (ScaleImage) - { - const video::SColor Colors[] = {Color,Color,Color,Color}; - - driver->draw2DImage(Texture, AbsoluteRect, - core::rect<s32>(core::position2d<s32>(0,0), core::dimension2di(Texture->getOriginalSize())), - &AbsoluteClippingRect, Colors, UseAlphaChannel); - } - else - { - driver->draw2DImage(Texture, AbsoluteRect.UpperLeftCorner, - core::rect<s32>(core::position2d<s32>(0,0), core::dimension2di(Texture->getOriginalSize())), - &AbsoluteClippingRect, Color, UseAlphaChannel); - } - } - else - { - skin->draw2DRectangle(this, skin->getColor(EGDC_3D_DARK_SHADOW), AbsoluteRect, &AbsoluteClippingRect); - } - - IGUIElement::draw(); -} - - -//! sets if the image should use its alpha channel to draw itself -void CGUIImage::setUseAlphaChannel(bool use) -{ - UseAlphaChannel = use; -} - - -//! sets if the image should use its alpha channel to draw itself -void CGUIImage::setScaleImage(bool scale) -{ - ScaleImage = scale; -} - - -//! Returns true if the image is scaled to fit, false if not -bool CGUIImage::isImageScaled() const -{ - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return ScaleImage; -} - -//! Returns true if the image is using the alpha channel, false if not -bool CGUIImage::isAlphaChannelUsed() const -{ - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return UseAlphaChannel; -} - - -//! Writes attributes of the element. -void CGUIImage::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const -{ - IGUIImage::serializeAttributes(out,options); - - out->addTexture ("Texture", Texture); - out->addBool ("UseAlphaChannel", UseAlphaChannel); - out->addColor ("Color", Color); - out->addBool ("ScaleImage", ScaleImage); - -} - - -//! Reads attributes of the element -void CGUIImage::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) -{ - IGUIImage::deserializeAttributes(in,options); - - setImage(in->getAttributeAsTexture("Texture")); - setUseAlphaChannel(in->getAttributeAsBool("UseAlphaChannel")); - setColor(in->getAttributeAsColor("Color")); - setScaleImage(in->getAttributeAsBool("ScaleImage")); -} - - -} // end namespace gui -} // end namespace irr - - -#endif // _IRR_COMPILE_WITH_GUI_ - diff --git a/irrlicht-1.6/source/Irrlicht/CGUIImage.h b/irrlicht-1.6/source/Irrlicht/CGUIImage.h deleted file mode 100644 index f0a9d6999..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIImage.h +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_IMAGE_H_INCLUDED__ -#define __C_GUI_IMAGE_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUIImage.h" - -namespace irr -{ -namespace gui -{ - - class CGUIImage : public IGUIImage - { - public: - - //! constructor - CGUIImage(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle); - - //! destructor - virtual ~CGUIImage(); - - //! sets an image - virtual void setImage(video::ITexture* image); - - //! sets the color of the image - virtual void setColor(video::SColor color); - - //! sets if the image should scale to fit the element - virtual void setScaleImage(bool scale); - - //! draws the element and its children - virtual void draw(); - - //! sets if the image should use its alpha channel to draw itself - virtual void setUseAlphaChannel(bool use); - - //! Returns true if the image is scaled to fit, false if not - virtual bool isImageScaled() const; - - //! Returns true if the image is using the alpha channel, false if not - virtual bool isAlphaChannelUsed() const; - - //! Writes attributes of the element. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; - - //! Reads attributes of the element - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - - private: - video::ITexture* Texture; - video::SColor Color; - bool UseAlphaChannel; - bool ScaleImage; - - }; - - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - -#endif // __C_GUI_IMAGE_H_INCLUDED__ diff --git a/irrlicht-1.6/source/Irrlicht/CGUIImageList.cpp b/irrlicht-1.6/source/Irrlicht/CGUIImageList.cpp deleted file mode 100644 index e02030d59..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIImageList.cpp +++ /dev/null @@ -1,93 +0,0 @@ -// This file is part of the "Irrlicht Engine". -// written by Reinhard Ostermeier, reinhard@nospam.r-ostermeier.de -// modified by Thomas Alten - -#include "CGUIImageList.h" - - -namespace irr -{ -namespace gui -{ - -//! constructor -CGUIImageList::CGUIImageList( video::IVideoDriver* driver ) - : Driver( driver ), - Texture( 0 ), - ImageCount( 0 ), - ImageSize( 0, 0 ), - ImagesPerRow( 0 ), - UseAlphaChannel( false ) -{ - #ifdef _DEBUG - setDebugName( "CGUIImageList" ); - #endif - - if( Driver ) - { - Driver->grab(); - } -} - - - -//! destructor -CGUIImageList::~CGUIImageList() -{ - if( Driver ) - { - Driver->drop(); - } - - if( Texture ) - { - Texture->drop(); - } -} - - -//! Creates the image list from texture. -bool CGUIImageList::createImageList(video::ITexture* texture, - core::dimension2d<s32> imageSize, - bool useAlphaChannel) -{ - if( !texture ) - { - return false; - } - - Texture = texture; - Texture->grab(); - - ImageSize = imageSize; - - ImagesPerRow = Texture->getSize().Width / ImageSize.Width; - ImageCount = ImagesPerRow * Texture->getSize().Height / ImageSize.Height; - - UseAlphaChannel = useAlphaChannel; - - return true; -} - -//! Draws an image and clips it to the specified rectangle if wanted -void CGUIImageList::draw( s32 index, const core::position2d<s32>& destPos, - const core::rect<s32>* clip /*= 0*/ ) -{ - core::rect<s32> sourceRect; - - if( !Driver || index < 0 || index >= ImageCount ) - { - return; - } - - sourceRect.UpperLeftCorner.X = ( index % ImagesPerRow ) * ImageSize.Width; - sourceRect.UpperLeftCorner.Y = ( index / ImagesPerRow ) * ImageSize.Height; - sourceRect.LowerRightCorner.X = sourceRect.UpperLeftCorner.X + ImageSize.Width; - sourceRect.LowerRightCorner.Y = sourceRect.UpperLeftCorner.Y + ImageSize.Height; - - Driver->draw2DImage( Texture, destPos, sourceRect, clip, - video::SColor( 255, 255, 255, 255 ), UseAlphaChannel ); -} - -} // end namespace gui -} // end namespace irr diff --git a/irrlicht-1.6/source/Irrlicht/CGUIImageList.h b/irrlicht-1.6/source/Irrlicht/CGUIImageList.h deleted file mode 100644 index 18221c8e3..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIImageList.h +++ /dev/null @@ -1,68 +0,0 @@ -// This file is part of the "Irrlicht Engine". -// written by Reinhard Ostermeier, reinhard@nospam.r-ostermeier.de - -#ifndef __C_GUI_IMAGE_LIST_H_INCLUDED__ -#define __C_GUI_IMAGE_LIST_H_INCLUDED__ - -#include "IGUIImageList.h" -#include "IVideoDriver.h" - -namespace irr -{ -namespace gui -{ - -class CGUIImageList : public IGUIImageList -{ -public: - - //! constructor - CGUIImageList( video::IVideoDriver* Driver ); - - //! destructor - virtual ~CGUIImageList(); - - //! Creates the image list from texture. - //! \param texture: The texture to use - //! \param imageSize: Size of a single image - //! \param useAlphaChannel: true if the alpha channel from the texture should be used - //! \return - //! true if the image list was created - bool createImageList( - video::ITexture* texture, - core::dimension2d<s32> imageSize, - bool useAlphaChannel ); - - //! Draws an image and clips it to the specified rectangle if wanted - //! \param index: Index of the image - //! \param destPos: Position of the image to draw - //! \param clip: Optional pointer to a rectalgle against which the text will be clipped. - //! If the pointer is null, no clipping will be done. - virtual void draw( s32 index, const core::position2d<s32>& destPos, - const core::rect<s32>* clip = 0 ); - - //! Returns the count of Images in the list. - //! \return Returns the count of Images in the list. - virtual s32 getImageCount() const - { return ImageCount; } - - //! Returns the size of the images in the list. - //! \return Returns the size of the images in the list. - virtual core::dimension2d<s32> getImageSize() const - { return ImageSize; } - -private: - - video::IVideoDriver* Driver; - video::ITexture* Texture; - s32 ImageCount; - core::dimension2d<s32> ImageSize; - s32 ImagesPerRow; - bool UseAlphaChannel; -}; - -} // end namespace gui -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CGUIInOutFader.cpp b/irrlicht-1.6/source/Irrlicht/CGUIInOutFader.cpp deleted file mode 100644 index bf513ad2c..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIInOutFader.cpp +++ /dev/null @@ -1,179 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUIInOutFader.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUIEnvironment.h" -#include "IVideoDriver.h" -#include "os.h" - -namespace irr -{ -namespace gui -{ - - -//! constructor -CGUIInOutFader::CGUIInOutFader(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle) -: IGUIInOutFader(environment, parent, id, rectangle) -{ - #ifdef _DEBUG - setDebugName("CGUIInOutFader"); - #endif - - Action = EFA_NOTHING; - StartTime = 0; - EndTime = 0; - - setColor(video::SColor(0,0,0,0)); -} - - -//! draws the element and its children -void CGUIInOutFader::draw() -{ - if (!IsVisible || !Action) - return; - - u32 now = os::Timer::getTime(); - if (now > EndTime && Action == EFA_FADE_IN) - { - Action = EFA_NOTHING; - return; - } - - video::IVideoDriver* driver = Environment->getVideoDriver(); - - if (driver) - { - f32 d; - - if (now > EndTime) - d = 0.0f; - else - d = (EndTime - now) / (f32)(EndTime - StartTime); - - video::SColor newCol = FullColor.getInterpolated(TransColor, d); - driver->draw2DRectangle(newCol, AbsoluteRect, &AbsoluteClippingRect); - } - - IGUIElement::draw(); -} - - -//! Gets the color to fade out to or to fade in from. -video::SColor CGUIInOutFader::getColor() const -{ - return Color[1]; -} - - -//! Sets the color to fade out to or to fade in from. -void CGUIInOutFader::setColor(video::SColor color) -{ - video::SColor s = color; - video::SColor d = color; - - s.setAlpha ( 255 ); - d.setAlpha ( 0 ); - setColor ( s,d ); - -/* - Color[0] = color; - - FullColor = Color[0]; - TransColor = Color[0]; - - if (Action == EFA_FADE_OUT) - { - FullColor.setAlpha(0); - TransColor.setAlpha(255); - } - else - if (Action == EFA_FADE_IN) - { - FullColor.setAlpha(255); - TransColor.setAlpha(0); - } -*/ -} - - -void CGUIInOutFader::setColor(video::SColor source, video::SColor dest) -{ - Color[0] = source; - Color[1] = dest; - - if (Action == EFA_FADE_OUT) - { - FullColor = Color[1]; - TransColor = Color[0]; - } - else - if (Action == EFA_FADE_IN) - { - FullColor = Color[0]; - TransColor = Color[1]; - } - -} - - -//! Returns if the fade in or out process is done. -bool CGUIInOutFader::isReady() const -{ - u32 now = os::Timer::getTime(); - bool ret = (now > EndTime); - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return ret; -} - - -//! Starts the fade in process. -void CGUIInOutFader::fadeIn(u32 time) -{ - StartTime = os::Timer::getTime(); - EndTime = StartTime + time; - Action = EFA_FADE_IN; - setColor(Color[0],Color[1]); -} - - -//! Starts the fade out process. -void CGUIInOutFader::fadeOut(u32 time) -{ - StartTime = os::Timer::getTime(); - EndTime = StartTime + time; - Action = EFA_FADE_OUT; - setColor(Color[0],Color[1]); -} - - -//! Writes attributes of the element. -void CGUIInOutFader::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const -{ - IGUIInOutFader::serializeAttributes(out,options); - - out->addColor ("FullColor", FullColor); - out->addColor ("TransColor", TransColor); - -} - - -//! Reads attributes of the element -void CGUIInOutFader::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) -{ - IGUIInOutFader::deserializeAttributes(in,options); - - FullColor = in->getAttributeAsColor("FullColor"); - TransColor = in->getAttributeAsColor("TransColor"); -} - - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - diff --git a/irrlicht-1.6/source/Irrlicht/CGUIInOutFader.h b/irrlicht-1.6/source/Irrlicht/CGUIInOutFader.h deleted file mode 100644 index 6e9ba3e86..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIInOutFader.h +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_IN_OUT_FADER_H_INCLUDED__ -#define __C_GUI_IN_OUT_FADER_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUIInOutFader.h" - -namespace irr -{ -namespace gui -{ - - class CGUIInOutFader : public IGUIInOutFader - { - public: - - //! constructor - CGUIInOutFader(IGUIEnvironment* environment, IGUIElement* parent, - s32 id, core::rect<s32> rectangle); - - //! draws the element and its children - virtual void draw(); - - //! Gets the color to fade out to or to fade in from. - virtual video::SColor getColor() const; - - //! Sets the color to fade out to or to fade in from. - virtual void setColor(video::SColor color ); - virtual void setColor(video::SColor source, video::SColor dest); - - //! Starts the fade in process. - virtual void fadeIn(u32 time); - - //! Starts the fade out process. - virtual void fadeOut(u32 time); - - //! Returns if the fade in or out process is done. - virtual bool isReady() const; - - //! Writes attributes of the element. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; - - //! Reads attributes of the element - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - - private: - - enum EFadeAction - { - EFA_NOTHING = 0, - EFA_FADE_IN, - EFA_FADE_OUT - }; - - u32 StartTime; - u32 EndTime; - EFadeAction Action; - - video::SColor Color[2]; - video::SColor FullColor; - video::SColor TransColor; - }; - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - -#endif // __C_GUI_IN_OUT_FADER_H_INCLUDED__ - diff --git a/irrlicht-1.6/source/Irrlicht/CGUIListBox.cpp b/irrlicht-1.6/source/Irrlicht/CGUIListBox.cpp deleted file mode 100644 index d3bbec786..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIListBox.cpp +++ /dev/null @@ -1,900 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUIListBox.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "CGUIListBox.h" -#include "IGUISkin.h" -#include "IGUIEnvironment.h" -#include "IVideoDriver.h" -#include "IGUIFont.h" -#include "IGUISpriteBank.h" -#include "CGUIScrollBar.h" -#include "os.h" - -namespace irr -{ -namespace gui -{ - -//! constructor -CGUIListBox::CGUIListBox(IGUIEnvironment* environment, IGUIElement* parent, - s32 id, core::rect<s32> rectangle, bool clip, - bool drawBack, bool moveOverSelect) -: IGUIListBox(environment, parent, id, rectangle), Selected(-1), - ItemHeight(0),ItemHeightOverride(0), - TotalItemHeight(0), ItemsIconWidth(0), Font(0), IconBank(0), - ScrollBar(0), selectTime(0), LastKeyTime(0), Selecting(false), DrawBack(drawBack), - MoveOverSelect(moveOverSelect), AutoScroll(true), HighlightWhenNotFocused(true) -{ - #ifdef _DEBUG - setDebugName("CGUIListBox"); - #endif - - IGUISkin* skin = Environment->getSkin(); - const s32 s = skin->getSize(EGDS_SCROLLBAR_SIZE); - - ScrollBar = new CGUIScrollBar(false, Environment, this, 0, - core::rect<s32>(RelativeRect.getWidth() - s, 0, RelativeRect.getWidth(), RelativeRect.getHeight()), - !clip); - ScrollBar->setSubElement(true); - ScrollBar->setTabStop(false); - ScrollBar->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); - ScrollBar->setVisible(false); - ScrollBar->drop(); - - ScrollBar->setPos(0); - ScrollBar->grab(); - - setNotClipped(!clip); - - // this element can be tabbed to - setTabStop(true); - setTabOrder(-1); - - updateAbsolutePosition(); -} - - -//! destructor -CGUIListBox::~CGUIListBox() -{ - if (ScrollBar) - ScrollBar->drop(); - - if (Font) - Font->drop(); - - if (IconBank) - IconBank->drop(); -} - - -//! returns amount of list items -u32 CGUIListBox::getItemCount() const -{ - return Items.size(); -} - - -//! returns string of a list item. the may be a value from 0 to itemCount-1 -const wchar_t* CGUIListBox::getListItem(u32 id) const -{ - if (id>=Items.size()) - return 0; - - return Items[id].text.c_str(); -} - - -//! Returns the icon of an item -s32 CGUIListBox::getIcon(u32 id) const -{ - if (id>=Items.size()) - return -1; - - return Items[id].icon; -} - - -//! adds a list item, returns id of item -u32 CGUIListBox::addItem(const wchar_t* text) -{ - return addItem(text, -1); -} - - -//! adds a list item, returns id of item -void CGUIListBox::removeItem(u32 id) -{ - if (id >= Items.size()) - return; - - if ((u32)Selected==id) - { - Selected = -1; - } - else if ((u32)Selected > id) - { - Selected -= 1; - selectTime = os::Timer::getTime(); - } - - Items.erase(id); - - recalculateItemHeight(); -} - - -//! clears the list -void CGUIListBox::clear() -{ - Items.clear(); - ItemsIconWidth = 0; - Selected = -1; - - if (ScrollBar) - ScrollBar->setPos(0); - - recalculateItemHeight(); -} - - -void CGUIListBox::recalculateItemHeight() -{ - IGUISkin* skin = Environment->getSkin(); - - if (Font != skin->getFont()) - { - if (Font) - Font->drop(); - - Font = skin->getFont(); - if ( 0 == ItemHeightOverride ) - ItemHeight = 0; - - if (Font) - { - if ( 0 == ItemHeightOverride ) - ItemHeight = Font->getDimension(L"A").Height + 4; - - Font->grab(); - } - } - - TotalItemHeight = ItemHeight * Items.size(); - ScrollBar->setMax(TotalItemHeight - AbsoluteRect.getHeight()); - ScrollBar->setSmallStep ( 1 ); - ScrollBar->setLargeStep ( ItemHeight ); - - if ( TotalItemHeight <= AbsoluteRect.getHeight() ) - ScrollBar->setVisible(false); - else - ScrollBar->setVisible(true); -} - - -//! returns id of selected item. returns -1 if no item is selected. -s32 CGUIListBox::getSelected() const -{ - return Selected; -} - - -//! sets the selected item. Set this to -1 if no item should be selected -void CGUIListBox::setSelected(s32 id) -{ - if ((u32)id>=Items.size()) - Selected = -1; - else - Selected = id; - - selectTime = os::Timer::getTime(); - - recalculateScrollPos(); -} - -//! sets the selected item. Set this to -1 if no item should be selected -void CGUIListBox::setSelected(const wchar_t *item) -{ - s32 index = -1; - - if ( item ) - { - for ( index = 0; index < (s32) Items.size(); ++index ) - { - if ( Items[index].text == item ) - break; - } - } - setSelected ( index ); -} - -//! called if an event happened. -bool CGUIListBox::OnEvent(const SEvent& event) -{ - if (IsEnabled) - { - switch(event.EventType) - { - case EET_KEY_INPUT_EVENT: - if (event.KeyInput.PressedDown && - (event.KeyInput.Key == KEY_DOWN || - event.KeyInput.Key == KEY_UP || - event.KeyInput.Key == KEY_HOME || - event.KeyInput.Key == KEY_END || - event.KeyInput.Key == KEY_NEXT || - event.KeyInput.Key == KEY_PRIOR ) ) - { - s32 oldSelected = Selected; - switch (event.KeyInput.Key) - { - case KEY_DOWN: - Selected += 1; - break; - case KEY_UP: - Selected -= 1; - break; - case KEY_HOME: - Selected = 0; - break; - case KEY_END: - Selected = (s32)Items.size()-1; - break; - case KEY_NEXT: - Selected += AbsoluteRect.getHeight() / ItemHeight; - break; - case KEY_PRIOR: - Selected -= AbsoluteRect.getHeight() / ItemHeight; - break; - default: - break; - } - if (Selected >= (s32)Items.size()) - Selected = Items.size() - 1; - else - if (Selected<0) - Selected = 0; - - recalculateScrollPos(); - - // post the news - - if (oldSelected != Selected && Parent && !Selecting && !MoveOverSelect) - { - SEvent e; - e.EventType = EET_GUI_EVENT; - e.GUIEvent.Caller = this; - e.GUIEvent.Element = 0; - e.GUIEvent.EventType = EGET_LISTBOX_CHANGED; - Parent->OnEvent(e); - } - - return true; - } - else - if (!event.KeyInput.PressedDown && ( event.KeyInput.Key == KEY_RETURN || event.KeyInput.Key == KEY_SPACE ) ) - { - if (Parent) - { - SEvent e; - e.EventType = EET_GUI_EVENT; - e.GUIEvent.Caller = this; - e.GUIEvent.Element = 0; - e.GUIEvent.EventType = EGET_LISTBOX_SELECTED_AGAIN; - Parent->OnEvent(e); - } - return true; - } - else if (event.KeyInput.PressedDown && event.KeyInput.Char) - { - // change selection based on text as it is typed. - u32 now = os::Timer::getTime(); - - if (now - LastKeyTime < 500) - { - // add to key buffer if it isn't a key repeat - if (!(KeyBuffer.size() == 1 && KeyBuffer[0] == event.KeyInput.Char)) - { - KeyBuffer += L" "; - KeyBuffer[KeyBuffer.size()-1] = event.KeyInput.Char; - } - } - else - { - KeyBuffer = L" "; - KeyBuffer[0] = event.KeyInput.Char; - } - LastKeyTime = now; - - // find the selected item, starting at the current selection - s32 start = Selected; - // dont change selection if the key buffer matches the current item - if (Selected > -1 && KeyBuffer.size() > 1) - { - if (Items[Selected].text.size() >= KeyBuffer.size() && - KeyBuffer.equals_ignore_case(Items[Selected].text.subString(0,KeyBuffer.size()))) - return true; - } - - s32 current; - for (current = start+1; current < (s32)Items.size(); ++current) - { - if (Items[current].text.size() >= KeyBuffer.size()) - { - if (KeyBuffer.equals_ignore_case(Items[current].text.subString(0,KeyBuffer.size()))) - { - if (Parent && Selected != current && !Selecting && !MoveOverSelect) - { - SEvent e; - e.EventType = EET_GUI_EVENT; - e.GUIEvent.Caller = this; - e.GUIEvent.Element = 0; - e.GUIEvent.EventType = EGET_LISTBOX_CHANGED; - Parent->OnEvent(e); - } - setSelected(current); - return true; - } - } - } - for (current = 0; current <= start; ++current) - { - if (Items[current].text.size() >= KeyBuffer.size()) - { - if (KeyBuffer.equals_ignore_case(Items[current].text.subString(0,KeyBuffer.size()))) - { - if (Parent && Selected != current && !Selecting && !MoveOverSelect) - { - Selected = current; - SEvent e; - e.EventType = EET_GUI_EVENT; - e.GUIEvent.Caller = this; - e.GUIEvent.Element = 0; - e.GUIEvent.EventType = EGET_LISTBOX_CHANGED; - Parent->OnEvent(e); - } - setSelected(current); - return true; - } - } - } - - return true; - } - break; - - case EET_GUI_EVENT: - switch(event.GUIEvent.EventType) - { - case gui::EGET_SCROLL_BAR_CHANGED: - if (event.GUIEvent.Caller == ScrollBar) - return true; - break; - case gui::EGET_ELEMENT_FOCUS_LOST: - { - if (event.GUIEvent.Caller == this) - Selecting = false; - } - default: - break; - } - break; - - case EET_MOUSE_INPUT_EVENT: - { - core::position2d<s32> p(event.MouseInput.X, event.MouseInput.Y); - - switch(event.MouseInput.Event) - { - case EMIE_MOUSE_WHEEL: - ScrollBar->setPos(ScrollBar->getPos() + (s32)event.MouseInput.Wheel*-10); - return true; - - case EMIE_LMOUSE_PRESSED_DOWN: - { - Selecting = true; - return true; - } - - case EMIE_LMOUSE_LEFT_UP: - { - Selecting = false; - - if (isPointInside(p)) - selectNew(event.MouseInput.Y); - - return true; - } - - case EMIE_MOUSE_MOVED: - if (Selecting || MoveOverSelect) - { - if (isPointInside(p)) - { - selectNew(event.MouseInput.Y, true); - return true; - } - } - default: - break; - } - } - break; - case EET_LOG_TEXT_EVENT: - case EET_USER_EVENT: - case EET_JOYSTICK_INPUT_EVENT: - case EGUIET_FORCE_32_BIT: - break; - } - } - - return IGUIElement::OnEvent(event); -} - - -void CGUIListBox::selectNew(s32 ypos, bool onlyHover) -{ - u32 now = os::Timer::getTime(); - s32 oldSelected = Selected; - - // find new selected item. - if (ItemHeight!=0) - Selected = ((ypos - AbsoluteRect.UpperLeftCorner.Y - 1) + ScrollBar->getPos()) / ItemHeight; - - if (Selected<0) - Selected = 0; - else - if ((u32)Selected >= Items.size()) - Selected = Items.size() - 1; - - recalculateScrollPos(); - - // post the news - if (Parent && !onlyHover) - { - SEvent event; - event.EventType = EET_GUI_EVENT; - event.GUIEvent.Caller = this; - event.GUIEvent.Element = 0; - event.GUIEvent.EventType = (Selected == oldSelected && now < selectTime + 500) ? EGET_LISTBOX_SELECTED_AGAIN : EGET_LISTBOX_CHANGED; - Parent->OnEvent(event); - } - selectTime = now; -} - - -//! Update the position and size of the listbox, and update the scrollbar -void CGUIListBox::updateAbsolutePosition() -{ - IGUIElement::updateAbsolutePosition(); - - recalculateItemHeight(); -} - - -//! draws the element and its children -void CGUIListBox::draw() -{ - if (!IsVisible) - return; - - recalculateItemHeight(); // if the font changed - - IGUISkin* skin = Environment->getSkin(); - - core::rect<s32>* clipRect = 0; - - // draw background - core::rect<s32> frameRect(AbsoluteRect); - - // draw items - - core::rect<s32> clientClip(AbsoluteRect); - clientClip.UpperLeftCorner.Y += 1; - clientClip.UpperLeftCorner.X += 1; - if (ScrollBar->isVisible()) - clientClip.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X - skin->getSize(EGDS_SCROLLBAR_SIZE); - clientClip.LowerRightCorner.Y -= 1; - clientClip.clipAgainst(AbsoluteClippingRect); - - skin->draw3DSunkenPane(this, skin->getColor(EGDC_3D_HIGH_LIGHT), true, - DrawBack, frameRect, &clientClip); - - if (clipRect) - clientClip.clipAgainst(*clipRect); - - frameRect = AbsoluteRect; - frameRect.UpperLeftCorner.X += 1; - if (ScrollBar->isVisible()) - frameRect.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X - skin->getSize(EGDS_SCROLLBAR_SIZE); - - frameRect.LowerRightCorner.Y = AbsoluteRect.UpperLeftCorner.Y + ItemHeight; - - frameRect.UpperLeftCorner.Y -= ScrollBar->getPos(); - frameRect.LowerRightCorner.Y -= ScrollBar->getPos(); - - bool hl = (HighlightWhenNotFocused || Environment->hasFocus(this) || Environment->hasFocus(ScrollBar)); - - for (s32 i=0; i<(s32)Items.size(); ++i) - { - if (frameRect.LowerRightCorner.Y >= AbsoluteRect.UpperLeftCorner.Y && - frameRect.UpperLeftCorner.Y <= AbsoluteRect.LowerRightCorner.Y) - { - if (i == Selected && hl) - skin->draw2DRectangle(this, skin->getColor(EGDC_HIGH_LIGHT), frameRect, &clientClip); - - core::rect<s32> textRect = frameRect; - textRect.UpperLeftCorner.X += 3; - - if (Font) - { - if (IconBank && (Items[i].icon > -1)) - { - core::position2di iconPos = textRect.UpperLeftCorner; - iconPos.Y += textRect.getHeight() / 2; - iconPos.X += ItemsIconWidth/2; - - if ( i==Selected && hl ) - { - IconBank->draw2DSprite( (u32)Items[i].icon, iconPos, &clientClip, - hasItemOverrideColor(i, EGUI_LBC_ICON_HIGHLIGHT) ? - getItemOverrideColor(i, EGUI_LBC_ICON_HIGHLIGHT) : getItemDefaultColor(EGUI_LBC_ICON_HIGHLIGHT), - selectTime, os::Timer::getTime(), false, true); - } - else - { - IconBank->draw2DSprite( (u32)Items[i].icon, iconPos, &clientClip, - hasItemOverrideColor(i, EGUI_LBC_ICON) ? getItemOverrideColor(i, EGUI_LBC_ICON) : getItemDefaultColor(EGUI_LBC_ICON), - 0 , (i==Selected) ? os::Timer::getTime() : 0, false, true); - } - } - - textRect.UpperLeftCorner.X += ItemsIconWidth+3; - - if ( i==Selected && hl ) - { - Font->draw(Items[i].text.c_str(), textRect, - hasItemOverrideColor(i, EGUI_LBC_TEXT_HIGHLIGHT) ? - getItemOverrideColor(i, EGUI_LBC_TEXT_HIGHLIGHT) : getItemDefaultColor(EGUI_LBC_TEXT_HIGHLIGHT), - false, true, &clientClip); - } - else - { - Font->draw(Items[i].text.c_str(), textRect, - hasItemOverrideColor(i, EGUI_LBC_TEXT) ? getItemOverrideColor(i, EGUI_LBC_TEXT) : getItemDefaultColor(EGUI_LBC_TEXT), - false, true, &clientClip); - } - - textRect.UpperLeftCorner.X -= ItemsIconWidth+3; - } - } - - frameRect.UpperLeftCorner.Y += ItemHeight; - frameRect.LowerRightCorner.Y += ItemHeight; - } - - IGUIElement::draw(); -} - - -//! adds an list item with an icon -u32 CGUIListBox::addItem(const wchar_t* text, s32 icon) -{ - ListItem i; - i.text = text; - i.icon = icon; - - Items.push_back(i); - recalculateItemHeight(); - recalculateItemWidth(icon); - - return Items.size() - 1; -} - - -void CGUIListBox::setSpriteBank(IGUISpriteBank* bank) -{ - if ( bank == IconBank ) - return; - if (IconBank) - IconBank->drop(); - - IconBank = bank; - if (IconBank) - IconBank->grab(); -} - - -void CGUIListBox::recalculateScrollPos() -{ - if (!AutoScroll) - return; - - const s32 selPos = (Selected == -1 ? TotalItemHeight : Selected * ItemHeight) - ScrollBar->getPos(); - - if (selPos < 0) - { - ScrollBar->setPos(ScrollBar->getPos() + selPos); - } - else - if (selPos > AbsoluteRect.getHeight() - ItemHeight) - { - ScrollBar->setPos(ScrollBar->getPos() + selPos - AbsoluteRect.getHeight() + ItemHeight); - } -} - - -void CGUIListBox::setAutoScrollEnabled(bool scroll) -{ - AutoScroll = scroll; -} - - -bool CGUIListBox::isAutoScrollEnabled() const -{ - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return AutoScroll; -} - - -bool CGUIListBox::getSerializationLabels(EGUI_LISTBOX_COLOR colorType, core::stringc & useColorLabel, core::stringc & colorLabel) const -{ - switch ( colorType ) - { - case EGUI_LBC_TEXT: - useColorLabel = "UseColText"; - colorLabel = "ColText"; - break; - case EGUI_LBC_TEXT_HIGHLIGHT: - useColorLabel = "UseColTextHl"; - colorLabel = "ColTextHl"; - break; - case EGUI_LBC_ICON: - useColorLabel = "UseColIcon"; - colorLabel = "ColIcon"; - break; - case EGUI_LBC_ICON_HIGHLIGHT: - useColorLabel = "UseColIconHl"; - colorLabel = "ColIconHl"; - break; - default: - return false; - } - return true; -} - - -//! Writes attributes of the element. -void CGUIListBox::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const -{ - IGUIListBox::serializeAttributes(out,options); - - // todo: out->addString ("IconBank", IconBank->getName?); - out->addBool ("DrawBack", DrawBack); - out->addBool ("MoveOverSelect", MoveOverSelect); - out->addBool ("AutoScroll", AutoScroll); - - out->addInt("ItemCount", Items.size()); - for (u32 i=0;i<Items.size(); ++i) - { - core::stringc label("text"); - label += i; - out->addString(label.c_str(), Items[i].text.c_str() ); - - for ( s32 c=0; c < (s32)EGUI_LBC_COUNT; ++c ) - { - core::stringc useColorLabel, colorLabel; - if ( !getSerializationLabels((EGUI_LISTBOX_COLOR)c, useColorLabel, colorLabel) ) - return; - label = useColorLabel; label += i; - if ( Items[i].OverrideColors[c].Use ) - { - out->addBool(label.c_str(), true ); - label = colorLabel; label += i; - out->addColor(label.c_str(), Items[i].OverrideColors[c].Color); - } - else - { - out->addBool(label.c_str(), false ); - } - } - } -} - - -//! Reads attributes of the element -void CGUIListBox::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) -{ - clear(); - - DrawBack = in->getAttributeAsBool("DrawBack"); - MoveOverSelect = in->getAttributeAsBool("MoveOverSelect"); - AutoScroll = in->getAttributeAsBool("AutoScroll"); - - IGUIListBox::deserializeAttributes(in,options); - - const s32 count = in->getAttributeAsInt("ItemCount"); - for (s32 i=0; i<count; ++i) - { - core::stringc label("text"); - ListItem item; - - label += i; - item.text = in->getAttributeAsStringW(label.c_str()); - - addItem(item.text.c_str(), item.icon); - - for ( u32 c=0; c < EGUI_LBC_COUNT; ++c ) - { - core::stringc useColorLabel, colorLabel; - if ( !getSerializationLabels((EGUI_LISTBOX_COLOR)c, useColorLabel, colorLabel) ) - return; - label = useColorLabel; label += i; - Items[i].OverrideColors[c].Use = in->getAttributeAsBool(label.c_str()); - if ( Items[i].OverrideColors[c].Use ) - { - label = colorLabel; label += i; - Items[i].OverrideColors[c].Color = in->getAttributeAsColor(label.c_str()); - } - } - } -} - - -void CGUIListBox::recalculateItemWidth(s32 icon) -{ - if (IconBank && icon > -1 && - IconBank->getSprites().size() > (u32)icon && - IconBank->getSprites()[(u32)icon].Frames.size()) - { - u32 rno = IconBank->getSprites()[(u32)icon].Frames[0].rectNumber; - if (IconBank->getPositions().size() > rno) - { - const s32 w = IconBank->getPositions()[rno].getWidth(); - if (w > ItemsIconWidth) - ItemsIconWidth = w; - } - } -} - - -void CGUIListBox::setItem(u32 index, const wchar_t* text, s32 icon) -{ - if ( index >= Items.size() ) - return; - - Items[index].text = text; - Items[index].icon = icon; - - recalculateItemHeight(); - recalculateItemWidth(icon); -} - - -//! Insert the item at the given index -//! Return the index on success or -1 on failure. -s32 CGUIListBox::insertItem(u32 index, const wchar_t* text, s32 icon) -{ - ListItem i; - i.text = text; - i.icon = icon; - - Items.insert(i, index); - recalculateItemHeight(); - recalculateItemWidth(icon); - - return index; -} - - -void CGUIListBox::swapItems(u32 index1, u32 index2) -{ - if ( index1 >= Items.size() || index2 >= Items.size() ) - return; - - ListItem dummmy = Items[index1]; - Items[index1] = Items[index2]; - Items[index2] = dummmy; -} - - -void CGUIListBox::setItemOverrideColor(u32 index, const video::SColor &color) -{ - for ( u32 c=0; c < EGUI_LBC_COUNT; ++c ) - { - Items[index].OverrideColors[c].Use = true; - Items[index].OverrideColors[c].Color = color; - } -} - - -void CGUIListBox::setItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType, const video::SColor &color) -{ - if ( index >= Items.size() || colorType < 0 || colorType >= EGUI_LBC_COUNT ) - return; - - Items[index].OverrideColors[colorType].Use = true; - Items[index].OverrideColors[colorType].Color = color; -} - - -void CGUIListBox::clearItemOverrideColor(u32 index) -{ - for (u32 c=0; c < (u32)EGUI_LBC_COUNT; ++c ) - { - Items[index].OverrideColors[c].Use = false; - } -} - - -void CGUIListBox::clearItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType) -{ - if ( index >= Items.size() || colorType < 0 || colorType >= EGUI_LBC_COUNT ) - return; - - Items[index].OverrideColors[colorType].Use = false; -} - - -bool CGUIListBox::hasItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType) const -{ - if ( index >= Items.size() || colorType < 0 || colorType >= EGUI_LBC_COUNT ) - return false; - - return Items[index].OverrideColors[colorType].Use; -} - - -video::SColor CGUIListBox::getItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType) const -{ - if ( (u32)index >= Items.size() || colorType < 0 || colorType >= EGUI_LBC_COUNT ) - return video::SColor(); - - return Items[index].OverrideColors[colorType].Color; -} - - -video::SColor CGUIListBox::getItemDefaultColor(EGUI_LISTBOX_COLOR colorType) const -{ - IGUISkin* skin = Environment->getSkin(); - if ( !skin ) - return video::SColor(); - - switch ( colorType ) - { - case EGUI_LBC_TEXT: - return skin->getColor(EGDC_BUTTON_TEXT); - case EGUI_LBC_TEXT_HIGHLIGHT: - return skin->getColor(EGDC_HIGH_LIGHT_TEXT); - case EGUI_LBC_ICON: - return skin->getColor(EGDC_ICON); - case EGUI_LBC_ICON_HIGHLIGHT: - return skin->getColor(EGDC_ICON_HIGH_LIGHT); - default: - return video::SColor(); - } -} - -//! set global itemHeight -void CGUIListBox::setItemHeight( s32 height ) -{ - ItemHeight = height; - ItemHeightOverride = 1; -} - - -//! Sets whether to draw the background -void CGUIListBox::setDrawBackground(bool draw) -{ - DrawBack = draw; -} - - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - diff --git a/irrlicht-1.6/source/Irrlicht/CGUIListBox.h b/irrlicht-1.6/source/Irrlicht/CGUIListBox.h deleted file mode 100644 index 43c6b374c..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIListBox.h +++ /dev/null @@ -1,187 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_LIST_BOX_H_INCLUDED__ -#define __C_GUI_LIST_BOX_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUIListBox.h" -#include "irrArray.h" - -namespace irr -{ -namespace gui -{ - - class IGUIFont; - class IGUIScrollBar; - - class CGUIListBox : public IGUIListBox - { - public: - //! constructor - CGUIListBox(IGUIEnvironment* environment, IGUIElement* parent, - s32 id, core::rect<s32> rectangle, bool clip=true, - bool drawBack=false, bool moveOverSelect=false); - - //! destructor - virtual ~CGUIListBox(); - - //! returns amount of list items - virtual u32 getItemCount() const; - - //! returns string of a list item. the id may be a value from 0 to itemCount-1 - virtual const wchar_t* getListItem(u32 id) const; - - //! adds an list item, returns id of item - virtual u32 addItem(const wchar_t* text); - - //! clears the list - virtual void clear(); - - //! returns id of selected item. returns -1 if no item is selected. - virtual s32 getSelected() const; - - //! sets the selected item. Set this to -1 if no item should be selected - virtual void setSelected(s32 id); - - //! sets the selected item. Set this to -1 if no item should be selected - virtual void setSelected(const wchar_t *item); - - //! called if an event happened. - virtual bool OnEvent(const SEvent& event); - - //! draws the element and its children - virtual void draw(); - - //! adds an list item with an icon - //! \param text Text of list entry - //! \param icon Sprite index of the Icon within the current sprite bank. Set it to -1 if you want no icon - //! \return - //! returns the id of the new created item - virtual u32 addItem(const wchar_t* text, s32 icon); - - //! Returns the icon of an item - virtual s32 getIcon(u32 id) const; - - //! removes an item from the list - virtual void removeItem(u32 id); - - //! Sets the sprite bank which should be used to draw list icons. This font is set to the sprite bank of - //! the built-in-font by default. A sprite can be displayed in front of every list item. - //! An icon is an index within the icon sprite bank. Several default icons are available in the - //! skin through getIcon - virtual void setSpriteBank(IGUISpriteBank* bank); - - //! sets if automatic scrolling is enabled or not. Default is true. - virtual void setAutoScrollEnabled(bool scroll); - - //! returns true if automatic scrolling is enabled, false if not. - virtual bool isAutoScrollEnabled() const; - - //! Update the position and size of the listbox, and update the scrollbar - virtual void updateAbsolutePosition(); - - //! Writes attributes of the element. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; - - //! Reads attributes of the element - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - - //! set all item colors at given index to color - virtual void setItemOverrideColor(u32 index, const video::SColor &color); - - //! set all item colors of specified type at given index to color - virtual void setItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType, const video::SColor &color); - - //! clear all item colors at index - virtual void clearItemOverrideColor(u32 index); - - //! clear item color at index for given colortype - virtual void clearItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType); - - //! has the item at index its color overwritten? - virtual bool hasItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType) const; - - //! return the overwrite color at given item index. - virtual video::SColor getItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType) const; - - //! return the default color which is used for the given colorType - virtual video::SColor getItemDefaultColor(EGUI_LISTBOX_COLOR colorType) const; - - //! set the item at the given index - virtual void setItem(u32 index, const wchar_t* text, s32 icon); - - //! Insert the item at the given index - //! Return the index on success or -1 on failure. - virtual s32 insertItem(u32 index, const wchar_t* text, s32 icon); - - //! Swap the items at the given indices - virtual void swapItems(u32 index1, u32 index2); - - //! set global itemHeight - virtual void setItemHeight( s32 height ); - - //! Sets whether to draw the background - virtual void setDrawBackground(bool draw); - - - private: - - struct ListItem - { - ListItem() : icon(-1) - {} - - core::stringw text; - s32 icon; - - // A multicolor extension - struct ListItemOverrideColor - { - ListItemOverrideColor() : Use(false) {} - bool Use; - video::SColor Color; - }; - ListItemOverrideColor OverrideColors[EGUI_LBC_COUNT]; - }; - - void recalculateItemHeight(); - void selectNew(s32 ypos, bool onlyHover=false); - void recalculateScrollPos(); - - // extracted that function to avoid copy&paste code - void recalculateItemWidth(s32 icon); - - // get labels used for serialization - bool getSerializationLabels(EGUI_LISTBOX_COLOR colorType, core::stringc & useColorLabel, core::stringc & colorLabel) const; - - core::array< ListItem > Items; - s32 Selected; - s32 ItemHeight; - s32 ItemHeightOverride; - s32 TotalItemHeight; - s32 ItemsIconWidth; - gui::IGUIFont* Font; - gui::IGUISpriteBank* IconBank; - gui::IGUIScrollBar* ScrollBar; - u32 selectTime; - u32 LastKeyTime; - core::stringw KeyBuffer; - bool Selecting; - bool DrawBack; - bool MoveOverSelect; - bool AutoScroll; - bool HighlightWhenNotFocused; - }; - - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - -#endif diff --git a/irrlicht-1.6/source/Irrlicht/CGUIMenu.cpp b/irrlicht-1.6/source/Irrlicht/CGUIMenu.cpp deleted file mode 100644 index 8533b6d2c..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIMenu.cpp +++ /dev/null @@ -1,281 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUIMenu.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUISkin.h" -#include "IGUIEnvironment.h" -#include "IVideoDriver.h" -#include "IGUIFont.h" - -#include "os.h" - -namespace irr -{ -namespace gui -{ - -//! constructor -CGUIMenu::CGUIMenu(IGUIEnvironment* environment, IGUIElement* parent, - s32 id, core::rect<s32> rectangle) - : CGUIContextMenu(environment, parent, id, rectangle, false, true) -{ - #ifdef _DEBUG - setDebugName("CGUIMenu"); - #endif - - Type = EGUIET_MENU; - - setNotClipped(false); - - recalculateSize(); -} - - -//! draws the element and its children -void CGUIMenu::draw() -{ - if (!IsVisible) - return; - - IGUISkin* skin = Environment->getSkin(); - IGUIFont* font = skin->getFont(EGDF_MENU); - - if (font != LastFont) - { - if (LastFont) - LastFont->drop(); - LastFont = font; - if (LastFont) - LastFont->grab(); - - recalculateSize(); - } - - core::rect<s32> rect = AbsoluteRect; - - // draw frame - - skin->draw3DToolBar(this, rect, &AbsoluteClippingRect); - - // loop through all menu items - - rect = AbsoluteRect; - - for (s32 i=0; i<(s32)Items.size(); ++i) - { - if (!Items[i].IsSeparator) - { - rect = getRect(Items[i], AbsoluteRect); - - // draw highlighted - if (i == HighLighted && Items[i].Enabled) - { - skin->draw3DSunkenPane(this, skin->getColor(EGDC_3D_DARK_SHADOW), - true, true, rect, &AbsoluteClippingRect); - } - // draw text - - EGUI_DEFAULT_COLOR c = EGDC_BUTTON_TEXT; - - if (i == HighLighted) - c = EGDC_HIGH_LIGHT_TEXT; - - if (!Items[i].Enabled) - c = EGDC_GRAY_TEXT; - - if (font) - font->draw(Items[i].Text.c_str(), rect, - skin->getColor(c), true, true, &AbsoluteClippingRect); - } - } - - IGUIElement::draw(); -} - - -//! called if an event happened. -bool CGUIMenu::OnEvent(const SEvent& event) -{ - if (IsEnabled) - { - - switch(event.EventType) - { - case EET_GUI_EVENT: - switch(event.GUIEvent.EventType) - { - case gui::EGET_ELEMENT_FOCUS_LOST: - if (event.GUIEvent.Caller == this && !isMyChild(event.GUIEvent.Element)) - { - closeAllSubMenus(); - HighLighted = -1; - } - break; - case gui::EGET_ELEMENT_FOCUSED: - if (event.GUIEvent.Caller == this && Parent) - { - Parent->bringToFront(this); - } - break; - default: - break; - } - break; - case EET_MOUSE_INPUT_EVENT: - switch(event.MouseInput.Event) - { - case EMIE_LMOUSE_PRESSED_DOWN: - { - if (!Environment->hasFocus(this)) - { - Environment->setFocus(this); - } - - if (Parent) - Parent->bringToFront(this); - - core::position2d<s32> p(event.MouseInput.X, event.MouseInput.Y); - bool shouldCloseSubMenu = hasOpenSubMenu(); - if (!AbsoluteClippingRect.isPointInside(p)) - { - shouldCloseSubMenu = false; - } - highlight(core::position2d<s32>(event.MouseInput.X, event.MouseInput.Y), true); - if ( shouldCloseSubMenu ) - { - Environment->removeFocus(this); - } - - return true; - } - case EMIE_LMOUSE_LEFT_UP: - { - core::position2d<s32> p(event.MouseInput.X, event.MouseInput.Y); - if (!AbsoluteClippingRect.isPointInside(p)) - { - s32 t = sendClick(p); - if ((t==0 || t==1) && Environment->hasFocus(this)) - Environment->removeFocus(this); - } - - return true; - } - case EMIE_MOUSE_MOVED: - if (Environment->hasFocus(this) && HighLighted >= 0) - { - s32 oldHighLighted = HighLighted; - highlight(core::position2d<s32>(event.MouseInput.X, event.MouseInput.Y), true); - if ( HighLighted < 0 ) - HighLighted = oldHighLighted; // keep last hightlight active when moving outside the area - } - return true; - default: - break; - } - break; - default: - break; - } - } - - return IGUIElement::OnEvent(event); -} - - -void CGUIMenu::recalculateSize() -{ - IGUISkin* skin = Environment->getSkin(); - IGUIFont* font = skin->getFont(EGDF_MENU); - - if (!font) - { - if (Parent && skin) - RelativeRect = core::rect<s32>(0,0, - Parent->getAbsolutePosition().LowerRightCorner.X, - skin->getSize(EGDS_MENU_HEIGHT)); - return; - } - - core::rect<s32> rect; - rect.UpperLeftCorner.X = 0; - rect.UpperLeftCorner.Y = 0; - s32 height = font->getDimension(L"A").Height + 5; - //if (skin && height < skin->getSize ( EGDS_MENU_HEIGHT )) - // height = skin->getSize(EGDS_MENU_HEIGHT); - s32 width = 0; - s32 i; - - for (i=0; i<(s32)Items.size(); ++i) - { - if (Items[i].IsSeparator) - { - Items[i].Dim.Width = 0; - Items[i].Dim.Height = height; - } - else - { - Items[i].Dim = font->getDimension(Items[i].Text.c_str()); - Items[i].Dim.Width += 20; - } - - Items[i].PosY = width; - width += Items[i].Dim.Width; - } - - if (Parent) - width = Parent->getAbsolutePosition().getWidth(); - - rect.LowerRightCorner.X = width; - rect.LowerRightCorner.Y = height; - - setRelativePosition(rect); - - // recalculate submenus - for (i=0; i<(s32)Items.size(); ++i) - if (Items[i].SubMenu) - { - // move submenu - s32 w = Items[i].SubMenu->getAbsolutePosition().getWidth(); - s32 h = Items[i].SubMenu->getAbsolutePosition().getHeight(); - - Items[i].SubMenu->setRelativePosition( - core::rect<s32>(Items[i].PosY, height , - Items[i].PosY+w-5, height+h)); - } -} - - -//! returns the item highlight-area -core::rect<s32> CGUIMenu::getHRect(const SItem& i, const core::rect<s32>& absolute) const -{ - core::rect<s32> r = absolute; - r.UpperLeftCorner.X += i.PosY; - r.LowerRightCorner.X = r.UpperLeftCorner.X + i.Dim.Width; - return r; -} - - -//! Gets drawing rect of Item -core::rect<s32> CGUIMenu::getRect(const SItem& i, const core::rect<s32>& absolute) const -{ - return getHRect(i, absolute); -} - - -void CGUIMenu::updateAbsolutePosition() -{ - if (Parent) - DesiredRect.LowerRightCorner.X = Parent->getAbsolutePosition().getWidth(); - - IGUIElement::updateAbsolutePosition(); -} - - -} // end namespace -} // end namespace - -#endif // _IRR_COMPILE_WITH_GUI_ - diff --git a/irrlicht-1.6/source/Irrlicht/CGUIMenu.h b/irrlicht-1.6/source/Irrlicht/CGUIMenu.h deleted file mode 100644 index c7168f763..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIMenu.h +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_MENU_H_INCLUDED__ -#define __C_GUI_MENU_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "CGUIContextMenu.h" - -namespace irr -{ -namespace gui -{ - - //! GUI menu interface. - class CGUIMenu : public CGUIContextMenu - { - public: - - //! constructor - CGUIMenu(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle); - - //! draws the element and its children - virtual void draw(); - - //! called if an event happened. - virtual bool OnEvent(const SEvent& event); - - //! Updates the absolute position. - virtual void updateAbsolutePosition(); - - protected: - - virtual void recalculateSize(); - - //! returns the item highlight-area - virtual core::rect<s32> getHRect(const SItem& i, const core::rect<s32>& absolute) const; - - //! Gets drawing rect of Item - virtual core::rect<s32> getRect(const SItem& i, const core::rect<s32>& absolute) const; - }; - -} // end namespace gui -} // end namespace irr - - -#endif // __C_GUI_MENU_H_INCLUDED__ -#endif // _IRR_COMPILE_WITH_GUI_ - diff --git a/irrlicht-1.6/source/Irrlicht/CGUIMeshViewer.cpp b/irrlicht-1.6/source/Irrlicht/CGUIMeshViewer.cpp deleted file mode 100644 index b7f11919d..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIMeshViewer.cpp +++ /dev/null @@ -1,172 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUIMeshViewer.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUIEnvironment.h" -#include "IVideoDriver.h" -#include "IAnimatedMesh.h" -#include "IMesh.h" -#include "os.h" -#include "IGUISkin.h" - -namespace irr -{ - -namespace gui -{ - - -//! constructor -CGUIMeshViewer::CGUIMeshViewer(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle) -: IGUIMeshViewer(environment, parent, id, rectangle), Mesh(0) -{ - #ifdef _DEBUG - setDebugName("CGUIMeshViewer"); - #endif -} - - -//! destructor -CGUIMeshViewer::~CGUIMeshViewer() -{ - if (Mesh) - Mesh->drop(); -} - - -//! sets the mesh to be shown -void CGUIMeshViewer::setMesh(scene::IAnimatedMesh* mesh) -{ - if (mesh) - mesh->grab(); - if (Mesh) - Mesh->drop(); - - Mesh = mesh; - - /* This might be used for proper transformation etc. - core::vector3df center(0.0f,0.0f,0.0f); - core::aabbox3d<f32> box; - - box = Mesh->getMesh(0)->getBoundingBox(); - center = (box.MaxEdge + box.MinEdge) / 2; - */ -} - - -//! Gets the displayed mesh -scene::IAnimatedMesh* CGUIMeshViewer::getMesh() const -{ - return Mesh; -} - - -//! sets the material -void CGUIMeshViewer::setMaterial(const video::SMaterial& material) -{ - Material = material; -} - - -//! gets the material -const video::SMaterial& CGUIMeshViewer::getMaterial() const -{ - return Material; -} - - -//! called if an event happened. -bool CGUIMeshViewer::OnEvent(const SEvent& event) -{ - return IGUIElement::OnEvent(event); -} - - -//! draws the element and its children -void CGUIMeshViewer::draw() -{ - if (!IsVisible) - return; - - IGUISkin* skin = Environment->getSkin(); - video::IVideoDriver* driver = Environment->getVideoDriver(); - core::rect<s32> viewPort = AbsoluteRect; - viewPort.LowerRightCorner.X -= 1; - viewPort.LowerRightCorner.Y -= 1; - viewPort.UpperLeftCorner.X += 1; - viewPort.UpperLeftCorner.Y += 1; - - viewPort.clipAgainst(AbsoluteClippingRect); - - // draw the frame - - core::rect<s32> frameRect(AbsoluteRect); - frameRect.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y + 1; - skin->draw2DRectangle(this, skin->getColor(EGDC_3D_SHADOW), frameRect, &AbsoluteClippingRect); - - frameRect.LowerRightCorner.Y = AbsoluteRect.LowerRightCorner.Y; - frameRect.LowerRightCorner.X = frameRect.UpperLeftCorner.X + 1; - skin->draw2DRectangle(this, skin->getColor(EGDC_3D_SHADOW), frameRect, &AbsoluteClippingRect); - - frameRect = AbsoluteRect; - frameRect.UpperLeftCorner.X = frameRect.LowerRightCorner.X - 1; - skin->draw2DRectangle(this, skin->getColor(EGDC_3D_HIGH_LIGHT), frameRect, &AbsoluteClippingRect); - - frameRect = AbsoluteRect; - frameRect.UpperLeftCorner.Y = AbsoluteRect.LowerRightCorner.Y - 1; - frameRect.LowerRightCorner.Y = AbsoluteRect.LowerRightCorner.Y; - skin->draw2DRectangle(this, skin->getColor(EGDC_3D_HIGH_LIGHT), frameRect, &AbsoluteClippingRect); - - // draw the mesh - - if (Mesh) - { - //TODO: if outside of screen, dont draw. - // - why is the absolute clipping rect not already the screen? - - core::rect<s32> oldViewPort = driver->getViewPort(); - - driver->setViewPort(viewPort); - - core::matrix4 mat; - - //CameraControl->calculateProjectionMatrix(mat); - //driver->setTransform(video::TS_PROJECTION, mat); - - mat.makeIdentity(); - mat.setTranslation(core::vector3df(0,0,0)); - driver->setTransform(video::ETS_WORLD, mat); - - //CameraControl->calculateViewMatrix(mat); - //driver->setTransform(video::TS_VIEW, mat); - - driver->setMaterial(Material); - - u32 frame = 0; - if(Mesh->getFrameCount()) - frame = (os::Timer::getTime()/20)%Mesh->getFrameCount(); - const scene::IMesh* const m = Mesh->getMesh(frame); - for (u32 i=0; i<m->getMeshBufferCount(); ++i) - { - scene::IMeshBuffer* mb = m->getMeshBuffer(i); - driver->drawVertexPrimitiveList(mb->getVertices(), - mb->getVertexCount(), mb->getIndices(), - mb->getIndexCount()/ 3, mb->getVertexType(), - scene::EPT_TRIANGLES, mb->getIndexType()); - } - - driver->setViewPort(oldViewPort); - } - - IGUIElement::draw(); -} - - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - diff --git a/irrlicht-1.6/source/Irrlicht/CGUIMeshViewer.h b/irrlicht-1.6/source/Irrlicht/CGUIMeshViewer.h deleted file mode 100644 index cf6d148ce..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIMeshViewer.h +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_MESH_VIEWER_H_INCLUDED__ -#define __C_GUI_MESH_VIEWER_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUIMeshViewer.h" -#include "SMaterial.h" - -namespace irr -{ - -namespace gui -{ - - class CGUIMeshViewer : public IGUIMeshViewer - { - public: - - //! constructor - CGUIMeshViewer(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle); - - //! destructor - virtual ~CGUIMeshViewer(); - - //! sets the mesh to be shown - virtual void setMesh(scene::IAnimatedMesh* mesh); - - //! Gets the displayed mesh - virtual scene::IAnimatedMesh* getMesh() const; - - //! sets the material - virtual void setMaterial(const video::SMaterial& material); - - //! gets the material - virtual const video::SMaterial& getMaterial() const; - - //! called if an event happened. - virtual bool OnEvent(const SEvent& event); - - //! draws the element and its children - virtual void draw(); - - private: - - video::SMaterial Material; - scene::IAnimatedMesh* Mesh; - }; - - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - -#endif // __C_GUI_MESH_VIEWER_H_INCLUDED__ - diff --git a/irrlicht-1.6/source/Irrlicht/CGUIMessageBox.cpp b/irrlicht-1.6/source/Irrlicht/CGUIMessageBox.cpp deleted file mode 100644 index 4f76a26ae..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIMessageBox.cpp +++ /dev/null @@ -1,439 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUIMessageBox.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUISkin.h" -#include "IGUIEnvironment.h" -#include "IGUIButton.h" -#include "IGUIFont.h" - -namespace irr -{ -namespace gui -{ - -//! constructor -CGUIMessageBox::CGUIMessageBox(IGUIEnvironment* environment, const wchar_t* caption, - const wchar_t* text, s32 flags, - IGUIElement* parent, s32 id, core::rect<s32> rectangle) -: CGUIWindow(environment, parent, id, rectangle), - OkButton(0), CancelButton(0), YesButton(0), NoButton(0), StaticText(0), - Flags(flags), MessageText(text), Pressed(false) -{ - #ifdef _DEBUG - setDebugName("CGUIMessageBox"); - #endif - - // set element type - Type = EGUIET_MESSAGE_BOX; - - // remove focus - Environment->setFocus(0); - - // remove buttons - - getMaximizeButton()->remove(); - getMinimizeButton()->remove(); - - if (caption) - setText(caption); - - Environment->setFocus(this); - - refreshControls(); -} - - -//! destructor -CGUIMessageBox::~CGUIMessageBox() -{ - if (StaticText) - StaticText->drop(); - - if (OkButton) - OkButton->drop(); - - if (CancelButton) - CancelButton->drop(); - - if (YesButton) - YesButton->drop(); - - if (NoButton) - NoButton->drop(); -} - - -void CGUIMessageBox::refreshControls() -{ - const IGUISkin* skin = Environment->getSkin(); - IGUIElement* focusMe = 0; - - const s32 buttonHeight = skin->getSize(EGDS_BUTTON_HEIGHT); - const s32 buttonWidth = skin->getSize(EGDS_BUTTON_WIDTH); - const s32 titleHeight = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH)+2; - const s32 buttonDistance = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH); - - // add static multiline text - - core::dimension2d<s32> dim(AbsoluteClippingRect.getWidth() - buttonWidth, - AbsoluteClippingRect.getHeight() - (buttonHeight * 2)); - const core::position2d<s32> pos((AbsoluteClippingRect.getWidth() - dim.Width) / 2, - buttonHeight / 2 + titleHeight); - - if (!StaticText) - { - StaticText = Environment->addStaticText(MessageText.c_str(), - core::rect<s32>(pos, dim), false, false, this); - StaticText->setWordWrap(true); - StaticText->setSubElement(true); - StaticText->grab(); - } - else - { - StaticText->setRelativePosition(core::rect<s32>(pos, dim)); - StaticText->setText(MessageText.c_str()); - } - - // adjust static text height - - const s32 textHeight = StaticText->getTextHeight(); - core::rect<s32> tmp = StaticText->getRelativePosition(); - tmp.LowerRightCorner.Y = tmp.UpperLeftCorner.Y + textHeight; - StaticText->setRelativePosition(tmp); - dim.Height = dim.Height - buttonHeight < tmp.getHeight() ? tmp.getHeight() : dim.Height - buttonHeight; - - // adjust message box height if required - - tmp = getRelativePosition(); - s32 msgBoxHeight = textHeight + core::floor32(2.5f * buttonHeight) + titleHeight; - msgBoxHeight = tmp.getHeight() < msgBoxHeight ? msgBoxHeight : tmp.getHeight(); - - // adjust message box position - - tmp.UpperLeftCorner.Y = (Parent->getAbsolutePosition().getHeight() - msgBoxHeight) / 2; - tmp.LowerRightCorner.Y = tmp.UpperLeftCorner.Y + msgBoxHeight; - setRelativePosition(tmp); - - // add buttons - - s32 countButtons = 0; - if (Flags & EMBF_OK) - ++countButtons; - if (Flags & EMBF_CANCEL) - ++countButtons; - if (Flags & EMBF_YES) - ++countButtons; - if (Flags & EMBF_NO) - ++countButtons; - - core::rect<s32> btnRect; - btnRect.UpperLeftCorner.Y = pos.Y + dim.Height + buttonHeight / 2; - btnRect.LowerRightCorner.Y = btnRect.UpperLeftCorner.Y + buttonHeight; - btnRect.UpperLeftCorner.X = (AbsoluteClippingRect.getWidth() - - (buttonWidth*countButtons + (buttonDistance*countButtons+1))) / 2 + - buttonDistance / 2; - btnRect.LowerRightCorner.X = btnRect.UpperLeftCorner.X + buttonWidth; - - // add/remove ok button - if (Flags & EMBF_OK) - { - if (!OkButton) - { - OkButton = Environment->addButton(btnRect, this); - OkButton->setSubElement(true); - OkButton->grab(); - } - else - OkButton->setRelativePosition(btnRect); - - OkButton->setText(skin->getDefaultText(EGDT_MSG_BOX_OK)); - - btnRect.LowerRightCorner.X += buttonWidth + buttonDistance; - btnRect.UpperLeftCorner.X += buttonWidth + buttonDistance; - - focusMe = OkButton; - } - else if (OkButton) - { - OkButton->drop(); - OkButton->remove(); - OkButton = 0; - } - - // add cancel button - if (Flags & EMBF_CANCEL) - { - if (!CancelButton) - { - CancelButton = Environment->addButton(btnRect, this); - CancelButton->setSubElement(true); - CancelButton->grab(); - } - else - CancelButton->setRelativePosition(btnRect); - - CancelButton->setText(skin->getDefaultText(EGDT_MSG_BOX_CANCEL)); - - btnRect.LowerRightCorner.X += buttonWidth + buttonDistance; - btnRect.UpperLeftCorner.X += buttonWidth + buttonDistance; - - if (!focusMe) - focusMe = CancelButton; - - } - else if (CancelButton) - { - CancelButton->drop(); - CancelButton->remove(); - CancelButton = 0; - } - - - // add/remove yes button - if (Flags & EMBF_YES) - { - if (!YesButton) - { - YesButton = Environment->addButton(btnRect, this); - YesButton->setSubElement(true); - YesButton->grab(); - } - else - YesButton->setRelativePosition(btnRect); - - YesButton->setText(skin->getDefaultText(EGDT_MSG_BOX_YES)); - - btnRect.LowerRightCorner.X += buttonWidth + buttonDistance; - btnRect.UpperLeftCorner.X += buttonWidth + buttonDistance; - - if (!focusMe) - focusMe = YesButton; - } - else if (YesButton) - { - YesButton->drop(); - YesButton->remove(); - YesButton = 0; - } - - // add no button - if (Flags & EMBF_NO) - { - if (!NoButton) - { - NoButton = Environment->addButton(btnRect, this); - NoButton->setSubElement(true); - NoButton->grab(); - } - else - NoButton->setRelativePosition(btnRect); - - NoButton->setText(skin->getDefaultText(EGDT_MSG_BOX_NO)); - - btnRect.LowerRightCorner.X += buttonWidth + buttonDistance; - btnRect.UpperLeftCorner.X += buttonWidth + buttonDistance; - - if (!focusMe) - focusMe = NoButton; - - } - else if (NoButton) - { - NoButton->drop(); - NoButton->remove(); - NoButton = 0; - } - - if (Environment->hasFocus(this) && focusMe) - Environment->setFocus(focusMe); -} - - -//! called if an event happened. -bool CGUIMessageBox::OnEvent(const SEvent& event) -{ - if (IsEnabled) - { - SEvent outevent; - outevent.EventType = EET_GUI_EVENT; - outevent.GUIEvent.Caller = this; - outevent.GUIEvent.Element = 0; - - switch(event.EventType) - { - case EET_KEY_INPUT_EVENT: - - if (event.KeyInput.PressedDown) - { - switch (event.KeyInput.Key) - { - case KEY_RETURN: - if (OkButton) - { - OkButton->setPressed(true); - Pressed = true; - } - break; - case KEY_KEY_Y: - if (YesButton) - { - YesButton->setPressed(true); - Pressed = true; - } - break; - case KEY_KEY_N: - if (NoButton) - { - NoButton->setPressed(true); - Pressed = true; - } - break; - case KEY_ESCAPE: - if (Pressed) - { - // cancel press - if (OkButton) OkButton->setPressed(false); - if (YesButton) YesButton->setPressed(false); - if (NoButton) NoButton->setPressed(false); - Pressed = false; - } - else - if (CancelButton) - { - CancelButton->setPressed(true); - Pressed = true; - } - else - if (CloseButton && CloseButton->isVisible()) - { - CloseButton->setPressed(true); - Pressed = true; - } - break; - default: // no other key is handled here - break; - } - } - else - if (Pressed) - { - if (OkButton && event.KeyInput.Key == KEY_RETURN) - { - outevent.GUIEvent.EventType = EGET_MESSAGEBOX_OK; - Parent->OnEvent(outevent); - remove(); - return true; - } - else - if ((CancelButton || CloseButton) && event.KeyInput.Key == KEY_ESCAPE) - { - outevent.GUIEvent.EventType = EGET_MESSAGEBOX_CANCEL; - Parent->OnEvent(outevent); - remove(); - return true; - } - else - if (YesButton && event.KeyInput.Key == KEY_KEY_Y) - { - outevent.GUIEvent.EventType = EGET_MESSAGEBOX_YES; - Parent->OnEvent(outevent); - remove(); - return true; - } - else - if (NoButton && event.KeyInput.Key == KEY_KEY_N) - { - outevent.GUIEvent.EventType = EGET_MESSAGEBOX_NO; - Parent->OnEvent(outevent); - remove(); - return true; - } - } - break; - case EET_GUI_EVENT: - if (event.GUIEvent.EventType == EGET_BUTTON_CLICKED) - { - if (event.GUIEvent.Caller == OkButton) - { - outevent.GUIEvent.EventType = EGET_MESSAGEBOX_OK; - Parent->OnEvent(outevent); - remove(); - return true; - } - else - if (event.GUIEvent.Caller == CancelButton || - event.GUIEvent.Caller == CloseButton) - { - outevent.GUIEvent.EventType = EGET_MESSAGEBOX_CANCEL; - Parent->OnEvent(outevent); - remove(); - return true; - } - else - if (event.GUIEvent.Caller == YesButton) - { - outevent.GUIEvent.EventType = EGET_MESSAGEBOX_YES; - Parent->OnEvent(outevent); - remove(); - return true; - } - else - if (event.GUIEvent.Caller == NoButton) - { - outevent.GUIEvent.EventType = EGET_MESSAGEBOX_NO; - Parent->OnEvent(outevent); - remove(); - return true; - } - } - break; - default: - break; - } - } - - return CGUIWindow::OnEvent(event); -} - - -//! Writes attributes of the element. -void CGUIMessageBox::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const -{ - CGUIWindow::serializeAttributes(out,options); - - out->addBool ("OkayButton", (Flags & EMBF_OK) != 0 ); - out->addBool ("CancelButton", (Flags & EMBF_CANCEL) != 0 ); - out->addBool ("YesButton", (Flags & EMBF_YES) != 0 ); - out->addBool ("NoButton", (Flags & EMBF_NO) != 0 ); - - out->addString ("MessageText", MessageText.c_str()); -} - - -//! Reads attributes of the element -void CGUIMessageBox::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) -{ - Flags = 0; - - Flags = in->getAttributeAsBool("OkayButton") ? EMBF_OK : 0; - Flags |= in->getAttributeAsBool("CancelButton")? EMBF_CANCEL : 0; - Flags |= in->getAttributeAsBool("YesButton") ? EMBF_YES : 0; - Flags |= in->getAttributeAsBool("NoButton") ? EMBF_NO : 0; - - MessageText = in->getAttributeAsStringW("MessageText").c_str(); - - CGUIWindow::deserializeAttributes(in,options); - - refreshControls(); -} - - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - diff --git a/irrlicht-1.6/source/Irrlicht/CGUIMessageBox.h b/irrlicht-1.6/source/Irrlicht/CGUIMessageBox.h deleted file mode 100644 index 5686e0286..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIMessageBox.h +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_MESSAGE_BOX_H_INCLUDED__ -#define __C_GUI_MESSAGE_BOX_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "CGUIWindow.h" -#include "IGUIStaticText.h" -#include "irrArray.h" - -namespace irr -{ -namespace gui -{ - class CGUIMessageBox : public CGUIWindow - { - public: - - //! constructor - CGUIMessageBox(IGUIEnvironment* environment, const wchar_t* caption, - const wchar_t* text, s32 flag, - IGUIElement* parent, s32 id, core::rect<s32> rectangle); - - //! destructor - virtual ~CGUIMessageBox(); - - //! called if an event happened. - virtual bool OnEvent(const SEvent& event); - - //! Writes attributes of the element. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; - - //! Reads attributes of the element - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - - private: - - void refreshControls(); - - IGUIButton* OkButton; - IGUIButton* CancelButton; - IGUIButton* YesButton; - IGUIButton* NoButton; - IGUIStaticText* StaticText; - - s32 Flags; - core::stringw MessageText; - bool Pressed; - }; - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - -#endif diff --git a/irrlicht-1.6/source/Irrlicht/CGUIModalScreen.cpp b/irrlicht-1.6/source/Irrlicht/CGUIModalScreen.cpp deleted file mode 100644 index cc1cece2e..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIModalScreen.cpp +++ /dev/null @@ -1,214 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUIModalScreen.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUIEnvironment.h" -#include "os.h" -#include "IVideoDriver.h" -#include "IGUISkin.h" - -namespace irr -{ -namespace gui -{ - -//! constructor -CGUIModalScreen::CGUIModalScreen(IGUIEnvironment* environment, IGUIElement* parent, s32 id) -: IGUIElement(EGUIET_MODAL_SCREEN, environment, parent, id, parent->getAbsolutePosition()), - MouseDownTime(0) -{ - #ifdef _DEBUG - setDebugName("CGUIModalScreen"); - #endif - setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); - - // this element is a tab group - setTabGroup(true); -} - -bool CGUIModalScreen::canTakeFocus(IGUIElement* target) const -{ - return (target && (target == this // this element can take it - || isMyChild(target) // own childs also - || (target->getType() == EGUIET_MODAL_SCREEN )// other modals also fine - || (target->getParent() && target->getParent()->getType() == EGUIET_MODAL_SCREEN ))) // childs of other modals will do - ; -} - -bool CGUIModalScreen::isVisible() const -{ - // any parent invisible? - IGUIElement * parentElement = getParent(); - while ( parentElement ) - { - if ( !parentElement->isVisible() ) - return false; - parentElement = parentElement->getParent(); - } - - // if we have no children then the modal is probably abused as a way to block input - if ( Children.empty() ) - { - return IGUIElement::isVisible(); - } - - // any child visible? - bool visible = false; - core::list<IGUIElement*>::ConstIterator it = Children.begin(); - for (; it != Children.end(); ++it) - { - if ( (*it)->isVisible() ) - { - visible = true; - break; - } - } - return visible; -} - -bool CGUIModalScreen::isPointInside(const core::position2d<s32>& point) const -{ - return true; -} - -//! called if an event happened. -bool CGUIModalScreen::OnEvent(const SEvent& event) -{ - if (!IsEnabled || !isVisible() ) - return IGUIElement::OnEvent(event); - - switch(event.EventType) - { - case EET_GUI_EVENT: - switch(event.GUIEvent.EventType) - { - case EGET_ELEMENT_FOCUSED: - if ( !canTakeFocus(event.GUIEvent.Caller)) - { - Environment->setFocus(this); - } - return false; - case EGET_ELEMENT_FOCUS_LOST: - if ( !canTakeFocus(event.GUIEvent.Element)) - { - MouseDownTime = os::Timer::getTime(); - return true; - } - else - { - return IGUIElement::OnEvent(event); - } - case EGET_ELEMENT_CLOSED: - // do not interfere with children being removed - return IGUIElement::OnEvent(event); - default: - break; - } - break; - case EET_MOUSE_INPUT_EVENT: - if (event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN) - { - MouseDownTime = os::Timer::getTime(); - } - default: - break; - } - - IGUIElement::OnEvent(event); - - return true; // absorb everything else -} - - -//! draws the element and its children -void CGUIModalScreen::draw() -{ - IGUISkin *skin = Environment->getSkin(); - - if (!skin) - return; - - u32 now = os::Timer::getTime(); - if (now - MouseDownTime < 300 && (now / 70)%2) - { - core::list<IGUIElement*>::Iterator it = Children.begin(); - core::rect<s32> r; - video::SColor c = Environment->getSkin()->getColor(gui::EGDC_3D_HIGH_LIGHT); - - for (; it != Children.end(); ++it) - { - if ((*it)->isVisible()) - { - r = (*it)->getAbsolutePosition(); - r.LowerRightCorner.X += 1; - r.LowerRightCorner.Y += 1; - r.UpperLeftCorner.X -= 1; - r.UpperLeftCorner.Y -= 1; - - skin->draw2DRectangle(this, c, r, &AbsoluteClippingRect); - } - } - } - - IGUIElement::draw(); -} - - -//! Removes a child. -void CGUIModalScreen::removeChild(IGUIElement* child) -{ - IGUIElement::removeChild(child); - - if (Children.empty()) - { - remove(); - } -} - - -//! adds a child -void CGUIModalScreen::addChild(IGUIElement* child) -{ - IGUIElement::addChild(child); - Environment->setFocus(child); -} - - -void CGUIModalScreen::updateAbsolutePosition() -{ - core::rect<s32> parentRect(0,0,0,0); - - if (Parent) - { - parentRect = Parent->getAbsolutePosition(); - RelativeRect.UpperLeftCorner.X = 0; - RelativeRect.UpperLeftCorner.Y = 0; - RelativeRect.LowerRightCorner.X = parentRect.getWidth(); - RelativeRect.LowerRightCorner.Y = parentRect.getHeight(); - } - - IGUIElement::updateAbsolutePosition(); -} - - -//! Writes attributes of the element. -void CGUIModalScreen::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const -{ - IGUIElement::serializeAttributes(out,options); -} - -//! Reads attributes of the element -void CGUIModalScreen::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) -{ - IGUIElement::deserializeAttributes(in, options); -} - - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - diff --git a/irrlicht-1.6/source/Irrlicht/CGUIModalScreen.h b/irrlicht-1.6/source/Irrlicht/CGUIModalScreen.h deleted file mode 100644 index cac27d6c6..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIModalScreen.h +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_MODAL_SCREEN_H_INCLUDED__ -#define __C_GUI_MODAL_SCREEN_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUIElement.h" - -namespace irr -{ -namespace gui -{ - - class CGUIModalScreen : public IGUIElement - { - public: - - //! constructor - CGUIModalScreen(IGUIEnvironment* environment, IGUIElement* parent, s32 id); - - //! called if an event happened. - virtual bool OnEvent(const SEvent& event); - - //! Removes a child. - virtual void removeChild(IGUIElement* child); - - //! Adds a child - virtual void addChild(IGUIElement* child); - - - //! draws the element and its children - virtual void draw(); - - //! Updates the absolute position. - virtual void updateAbsolutePosition(); - - //! Modalscreen is not a typical element, but rather acts like a state for it's children. - //! isVisible is overriden to give this a useful behaviour, so that a modal will no longer - //! be active when its parent is invisible or all its children are invisible. - virtual bool isVisible() const; - - //! Modals are infinite so every point is inside - virtual bool isPointInside(const core::position2d<s32>& point) const; - - //! Writes attributes of the element. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; - - //! Reads attributes of the element - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - - protected: - virtual bool canTakeFocus(IGUIElement* target) const; - - private: - - u32 MouseDownTime; - }; - - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CGUIScrollBar.cpp b/irrlicht-1.6/source/Irrlicht/CGUIScrollBar.cpp deleted file mode 100644 index 0f023b2e2..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIScrollBar.cpp +++ /dev/null @@ -1,551 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUIScrollBar.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUISkin.h" -#include "IGUIEnvironment.h" -#include "IVideoDriver.h" -#include "CGUIButton.h" -#include "IGUIFont.h" -#include "IGUIFontBitmap.h" -#include "os.h" - -namespace irr -{ -namespace gui -{ - - -//! constructor -CGUIScrollBar::CGUIScrollBar(bool horizontal, IGUIEnvironment* environment, - IGUIElement* parent, s32 id, - core::rect<s32> rectangle, bool noclip) - : IGUIScrollBar(environment, parent, id, rectangle), UpButton(0), - DownButton(0), Dragging(false), Horizontal(horizontal), - DraggedBySlider(false), TrayClick(false), Pos(0), DrawPos(0), - DrawHeight(0), Min(0), Max(100), SmallStep(10), LargeStep(50), DesiredPos(0), - LastChange(0) -{ - #ifdef _DEBUG - setDebugName("CGUIScrollBar"); - #endif - - refreshControls(); - - setNotClipped(noclip); - - // this element can be tabbed to - setTabStop(true); - setTabOrder(-1); - - setPos(0); -} - - -//! destructor -CGUIScrollBar::~CGUIScrollBar() -{ - if (UpButton) - UpButton->drop(); - - if (DownButton) - DownButton->drop(); -} - - -//! called if an event happened. -bool CGUIScrollBar::OnEvent(const SEvent& event) -{ - if (IsEnabled) - { - - switch(event.EventType) - { - case EET_KEY_INPUT_EVENT: - if (event.KeyInput.PressedDown) - { - const s32 oldPos = Pos; - bool absorb = true; - switch (event.KeyInput.Key) - { - case KEY_LEFT: - case KEY_UP: - setPos(Pos-SmallStep); - break; - case KEY_RIGHT: - case KEY_DOWN: - setPos(Pos+SmallStep); - break; - case KEY_HOME: - setPos(Min); - break; - case KEY_PRIOR: - setPos(Pos-LargeStep); - break; - case KEY_END: - setPos(Max); - break; - case KEY_NEXT: - setPos(Pos+LargeStep); - break; - default: - absorb = false; - } - - if (Pos != oldPos) - { - SEvent newEvent; - newEvent.EventType = EET_GUI_EVENT; - newEvent.GUIEvent.Caller = this; - newEvent.GUIEvent.Element = 0; - newEvent.GUIEvent.EventType = EGET_SCROLL_BAR_CHANGED; - Parent->OnEvent(newEvent); - } - if (absorb) - return true; - } - break; - case EET_GUI_EVENT: - if (event.GUIEvent.EventType == EGET_BUTTON_CLICKED) - { - if (event.GUIEvent.Caller == UpButton) - setPos(Pos-SmallStep); - else - if (event.GUIEvent.Caller == DownButton) - setPos(Pos+SmallStep); - - SEvent newEvent; - newEvent.EventType = EET_GUI_EVENT; - newEvent.GUIEvent.Caller = this; - newEvent.GUIEvent.Element = 0; - newEvent.GUIEvent.EventType = EGET_SCROLL_BAR_CHANGED; - Parent->OnEvent(newEvent); - - return true; - } - else - if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST) - { - if (event.GUIEvent.Caller == this) - Dragging = false; - } - break; - case EET_MOUSE_INPUT_EVENT: - { - const core::position2di p(event.MouseInput.X, event.MouseInput.Y); - bool isInside = isPointInside ( p ); - switch(event.MouseInput.Event) - { - case EMIE_MOUSE_WHEEL: - if (Environment->hasFocus(this)) - { - // thanks to a bug report by REAPER - // thanks to tommi by tommi for another bugfix - // everybody needs a little thanking. hallo niko!;-) - setPos( getPos() + - ( (s32)event.MouseInput.Wheel * SmallStep * (Horizontal ? 1 : -1 ) ) - ); - - SEvent newEvent; - newEvent.EventType = EET_GUI_EVENT; - newEvent.GUIEvent.Caller = this; - newEvent.GUIEvent.Element = 0; - newEvent.GUIEvent.EventType = EGET_SCROLL_BAR_CHANGED; - Parent->OnEvent(newEvent); - return true; - } - break; - case EMIE_LMOUSE_PRESSED_DOWN: - { - if (isInside) - { - Dragging = true; - DraggedBySlider = SliderRect.isPointInside(p); - TrayClick = !DraggedBySlider; - DesiredPos = getPosFromMousePos(p); - Environment->setFocus ( this ); - return true; - } - break; - } - case EMIE_LMOUSE_LEFT_UP: - case EMIE_MOUSE_MOVED: - { - if ( !event.MouseInput.isLeftPressed () ) - Dragging = false; - - if ( !Dragging ) - return isInside; - - if ( event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP ) - Dragging = false; - - const s32 newPos = getPosFromMousePos(p); - const s32 oldPos = Pos; - - if (!DraggedBySlider) - { - if ( isInside ) - { - DraggedBySlider = SliderRect.isPointInside(p); - TrayClick = !DraggedBySlider; - } - - if (DraggedBySlider) - { - setPos(newPos); - } - else - { - TrayClick = false; - if (event.MouseInput.Event == EMIE_MOUSE_MOVED) - return isInside; - } - } - - if (DraggedBySlider) - { - setPos(newPos); - } - else - { - DesiredPos = newPos; - } - - if (Pos != oldPos && Parent) - { - SEvent newEvent; - newEvent.EventType = EET_GUI_EVENT; - newEvent.GUIEvent.Caller = this; - newEvent.GUIEvent.Element = 0; - newEvent.GUIEvent.EventType = EGET_SCROLL_BAR_CHANGED; - Parent->OnEvent(newEvent); - } - return isInside; - } break; - - default: - break; - } - } break; - default: - break; - } - } - - return IGUIElement::OnEvent(event); -} - -void CGUIScrollBar::OnPostRender(u32 timeMs) -{ - if (Dragging && !DraggedBySlider && TrayClick && timeMs > LastChange + 200) - { - LastChange = timeMs; - - const s32 oldPos = Pos; - - if (DesiredPos >= Pos + LargeStep) - setPos(Pos + LargeStep); - else - if (DesiredPos <= Pos - LargeStep) - setPos(Pos - LargeStep); - else - if (DesiredPos >= Pos - LargeStep && DesiredPos <= Pos + LargeStep) - setPos(DesiredPos); - - if (Pos != oldPos && Parent) - { - SEvent newEvent; - newEvent.EventType = EET_GUI_EVENT; - newEvent.GUIEvent.Caller = this; - newEvent.GUIEvent.Element = 0; - newEvent.GUIEvent.EventType = EGET_SCROLL_BAR_CHANGED; - Parent->OnEvent(newEvent); - } - } - -} - -//! draws the element and its children -void CGUIScrollBar::draw() -{ - if (!IsVisible) - return; - - IGUISkin* skin = Environment->getSkin(); - if (!skin) - return; - - - SliderRect = AbsoluteRect; - - // draws the background - skin->draw2DRectangle(this, skin->getColor(EGDC_SCROLLBAR), SliderRect, &AbsoluteClippingRect); - - if ( core::isnotzero ( range() ) ) - { - // recalculate slider rectangle - if (Horizontal) - { - SliderRect.UpperLeftCorner.X = AbsoluteRect.UpperLeftCorner.X + DrawPos + RelativeRect.getHeight() - DrawHeight/2; - SliderRect.LowerRightCorner.X = SliderRect.UpperLeftCorner.X + DrawHeight; - } - else - { - SliderRect.UpperLeftCorner.Y = AbsoluteRect.UpperLeftCorner.Y + DrawPos + RelativeRect.getWidth() - DrawHeight/2; - SliderRect.LowerRightCorner.Y = SliderRect.UpperLeftCorner.Y + DrawHeight; - } - - skin->draw3DButtonPaneStandard(this, SliderRect, &AbsoluteClippingRect); - } - - // draw buttons - IGUIElement::draw(); -} - - -void CGUIScrollBar::updateAbsolutePosition() -{ - IGUIElement::updateAbsolutePosition(); - // todo: properly resize - refreshControls(); - setPos ( Pos ); -} - -//! -s32 CGUIScrollBar::getPosFromMousePos(const core::position2di &pos) const -{ - f32 w, p; - if (Horizontal) - { - w = RelativeRect.getWidth() - f32(RelativeRect.getHeight())*3.0f; - p = pos.X - AbsoluteRect.UpperLeftCorner.X - RelativeRect.getHeight()*1.5f; - } - else - { - w = RelativeRect.getHeight() - f32(RelativeRect.getWidth())*3.0f; - p = pos.Y - AbsoluteRect.UpperLeftCorner.Y - RelativeRect.getWidth()*1.5f; - } - return (s32) ( p/w * range() ) + Min; -} - - -//! sets the position of the scrollbar -void CGUIScrollBar::setPos(s32 pos) -{ - Pos = core::s32_clamp ( pos, Min, Max ); - - if (Horizontal) - { - f32 f = (RelativeRect.getWidth() - ((f32)RelativeRect.getHeight()*3.0f)) / range(); - DrawPos = (s32)( ( ( Pos - Min ) * f) + ((f32)RelativeRect.getHeight() * 0.5f)); - DrawHeight = RelativeRect.getHeight(); - } - else - { - f32 f = (RelativeRect.getHeight() - ((f32)RelativeRect.getWidth()*3.0f)) / range(); - - DrawPos = (s32)( ( ( Pos - Min ) * f) + ((f32)RelativeRect.getWidth() * 0.5f)); - DrawHeight = RelativeRect.getWidth(); - } - -} - - -//! gets the small step value -s32 CGUIScrollBar::getSmallStep() const -{ - return SmallStep; -} - - -//! sets the small step value -void CGUIScrollBar::setSmallStep(s32 step) -{ - if (step > 0) - SmallStep = step; - else - SmallStep = 10; -} - - -//! gets the small step value -s32 CGUIScrollBar::getLargeStep() const -{ - return LargeStep; -} - - -//! sets the small step value -void CGUIScrollBar::setLargeStep(s32 step) -{ - if (step > 0) - LargeStep = step; - else - LargeStep = 50; -} - - -//! gets the maximum value of the scrollbar. -s32 CGUIScrollBar::getMax() const -{ - return Max; -} - - -//! sets the maximum value of the scrollbar. -void CGUIScrollBar::setMax(s32 max) -{ - Max = core::max_ ( max, Min ); - - bool enable = core::isnotzero ( range() ); - UpButton->setEnabled(enable); - DownButton->setEnabled(enable); - setPos(Pos); -} - -//! gets the maximum value of the scrollbar. -s32 CGUIScrollBar::getMin() const -{ - return Min; -} - - -//! sets the minimum value of the scrollbar. -void CGUIScrollBar::setMin(s32 min) -{ - Min = core::min_ ( min, Max ); - - bool enable = core::isnotzero ( range() ); - UpButton->setEnabled(enable); - DownButton->setEnabled(enable); - setPos(Pos); -} - - -//! gets the current position of the scrollbar -s32 CGUIScrollBar::getPos() const -{ - return Pos; -} - - -//! refreshes the position and text on child buttons -void CGUIScrollBar::refreshControls() -{ - video::SColor color(255,255,255,255); - - IGUISkin* skin = Environment->getSkin(); - IGUISpriteBank* sprites = 0; - - if (skin) - { - sprites = skin->getSpriteBank(); - color = skin->getColor(EGDC_WINDOW_SYMBOL); - } - - if (Horizontal) - { - s32 h = RelativeRect.getHeight(); - if (!UpButton) - { - UpButton = new CGUIButton(Environment, this, -1, core::rect<s32>(0,0, h, h), NoClip); - UpButton->setSubElement(true); - UpButton->setTabStop(false); - } - if (sprites) - { - UpButton->setSpriteBank(sprites); - UpButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_LEFT), color); - UpButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_LEFT), color); - } - UpButton->setRelativePosition(core::rect<s32>(0,0, h, h)); - UpButton->setAlignment(EGUIA_UPPERLEFT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); - if (!DownButton) - { - DownButton = new CGUIButton(Environment, this, -1, core::rect<s32>(RelativeRect.getWidth()-h, 0, RelativeRect.getWidth(), h), NoClip); - DownButton->setSubElement(true); - DownButton->setTabStop(false); - } - if (sprites) - { - DownButton->setSpriteBank(sprites); - DownButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_RIGHT), color); - DownButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_RIGHT), color); - } - DownButton->setRelativePosition(core::rect<s32>(RelativeRect.getWidth()-h, 0, RelativeRect.getWidth(), h)); - DownButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); - } - else - { - s32 w = RelativeRect.getWidth(); - if (!UpButton) - { - UpButton = new CGUIButton(Environment, this, -1, core::rect<s32>(0,0, w, w), NoClip); - UpButton->setSubElement(true); - UpButton->setTabStop(false); - } - if (sprites) - { - UpButton->setSpriteBank(sprites); - UpButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_UP), color); - UpButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_UP), color); - } - UpButton->setRelativePosition(core::rect<s32>(0,0, w, w)); - UpButton->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - if (!DownButton) - { - DownButton = new CGUIButton(Environment, this, -1, core::rect<s32>(0,RelativeRect.getHeight()-w, w, RelativeRect.getHeight()), NoClip); - DownButton->setSubElement(true); - DownButton->setTabStop(false); - } - if (sprites) - { - DownButton->setSpriteBank(sprites); - DownButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_DOWN), color); - DownButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_DOWN), color); - } - DownButton->setRelativePosition(core::rect<s32>(0,RelativeRect.getHeight()-w, w, RelativeRect.getHeight())); - DownButton->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT); - } -} - - -//! Writes attributes of the element. -void CGUIScrollBar::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const -{ - IGUIScrollBar::serializeAttributes(out,options); - - out->addBool("Horizontal", Horizontal); - out->addInt ("Value", Pos); - out->addInt ("Min", Min); - out->addInt ("Max", Max); - out->addInt ("SmallStep", SmallStep); - out->addInt ("LargeStep", LargeStep); -} - - -//! Reads attributes of the element -void CGUIScrollBar::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) -{ - IGUIScrollBar::deserializeAttributes(in,options); - - Horizontal = in->getAttributeAsBool("Horizontal"); - setMin(in->getAttributeAsInt("Min")); - setMax(in->getAttributeAsInt("Max")); - setPos(in->getAttributeAsInt("Value")); - setSmallStep(in->getAttributeAsInt("SmallStep")); - setLargeStep(in->getAttributeAsInt("LargeStep")); - - refreshControls(); -} - - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - diff --git a/irrlicht-1.6/source/Irrlicht/CGUIScrollBar.h b/irrlicht-1.6/source/Irrlicht/CGUIScrollBar.h deleted file mode 100644 index 6077e981a..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIScrollBar.h +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_SCROLL_BAR_H_INCLUDED__ -#define __C_GUI_SCROLL_BAR_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUIScrollBar.h" -#include "IGUIButton.h" - -namespace irr -{ -namespace gui -{ - - class CGUIScrollBar : public IGUIScrollBar - { - public: - - //! constructor - CGUIScrollBar(bool horizontal, IGUIEnvironment* environment, - IGUIElement* parent, s32 id, core::rect<s32> rectangle, - bool noclip=false); - - //! destructor - virtual ~CGUIScrollBar(); - - //! called if an event happened. - virtual bool OnEvent(const SEvent& event); - - //! draws the element and its children - virtual void draw(); - - virtual void OnPostRender(u32 timeMs); - - - //! gets the maximum value of the scrollbar. - virtual s32 getMax() const; - - //! sets the maximum value of the scrollbar. - virtual void setMax(s32 max); - - //! gets the minimum value of the scrollbar. - virtual s32 getMin() const; - - //! sets the minimum value of the scrollbar. - virtual void setMin(s32 max); - - //! gets the small step value - virtual s32 getSmallStep() const; - - //! sets the small step value - virtual void setSmallStep(s32 step); - - //! gets the large step value - virtual s32 getLargeStep() const; - - //! sets the large step value - virtual void setLargeStep(s32 step); - - //! gets the current position of the scrollbar - virtual s32 getPos() const; - - //! sets the position of the scrollbar - virtual void setPos(s32 pos); - - //! updates the rectangle - virtual void updateAbsolutePosition(); - - //! Writes attributes of the element. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; - - //! Reads attributes of the element - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - - private: - - void refreshControls(); - s32 getPosFromMousePos(const core::position2di &p) const; - - IGUIButton* UpButton; - IGUIButton* DownButton; - - core::rect<s32> SliderRect; - - bool Dragging; - bool Horizontal; - bool DraggedBySlider; - bool TrayClick; - s32 Pos; - s32 DrawPos; - s32 DrawHeight; - s32 Min; - s32 Max; - s32 SmallStep; - s32 LargeStep; - s32 DesiredPos; - u32 LastChange; - - f32 range () const { return (f32) ( Max - Min ); } - }; - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CGUISkin.cpp b/irrlicht-1.6/source/Irrlicht/CGUISkin.cpp deleted file mode 100644 index 0a700db46..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUISkin.cpp +++ /dev/null @@ -1,933 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUISkin.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUIFont.h" -#include "IGUISpriteBank.h" -#include "IVideoDriver.h" -#include "IAttributes.h" -#include "SoftwareDriver2_helper.h" - -namespace irr -{ -namespace gui -{ - -CGUISkin::CGUISkin(EGUI_SKIN_TYPE type, video::IVideoDriver* driver) -: SpriteBank(0), Driver(driver), Type(type) -{ - #ifdef _DEBUG - setDebugName("CGUISkin"); - #endif - - if ((Type == EGST_WINDOWS_CLASSIC) || (Type == EGST_WINDOWS_METALLIC)) - { - Colors[EGDC_3D_DARK_SHADOW] = video::SColor(101,50,50,50); - Colors[EGDC_3D_SHADOW] = video::SColor(101,130,130,130); - Colors[EGDC_3D_FACE] = video::SColor(101,210,210,210); - Colors[EGDC_3D_HIGH_LIGHT] = video::SColor(101,255,255,255); - Colors[EGDC_3D_LIGHT] = video::SColor(101,210,210,210); - Colors[EGDC_ACTIVE_BORDER] = video::SColor(101,16,14,115); - Colors[EGDC_ACTIVE_CAPTION] = video::SColor(200,255,255,255); - Colors[EGDC_APP_WORKSPACE] = video::SColor(101,100,100,100); - Colors[EGDC_BUTTON_TEXT] = video::SColor(240,10,10,10); - Colors[EGDC_GRAY_TEXT] = video::SColor(240,130,130,130); - Colors[EGDC_HIGH_LIGHT] = video::SColor(101,8,36,107); - Colors[EGDC_HIGH_LIGHT_TEXT] = video::SColor(240,255,255,255); - Colors[EGDC_INACTIVE_BORDER] = video::SColor(101,165,165,165); - Colors[EGDC_INACTIVE_CAPTION] = video::SColor(101,210,210,210); - Colors[EGDC_TOOLTIP] = video::SColor(200,0,0,0); - Colors[EGDC_TOOLTIP_BACKGROUND]= video::SColor(200,255,255,225); - Colors[EGDC_SCROLLBAR] = video::SColor(101,230,230,230); - Colors[EGDC_WINDOW] = video::SColor(101,255,255,255); - Colors[EGDC_WINDOW_SYMBOL] = video::SColor(200,10,10,10); - Colors[EGDC_ICON] = video::SColor(200,255,255,255); - Colors[EGDC_ICON_HIGH_LIGHT] = video::SColor(200,8,36,107); - - Sizes[EGDS_SCROLLBAR_SIZE] = 14; - Sizes[EGDS_MENU_HEIGHT] = 30; - Sizes[EGDS_WINDOW_BUTTON_WIDTH] = 15; - Sizes[EGDS_CHECK_BOX_WIDTH] = 18; - Sizes[EGDS_MESSAGE_BOX_WIDTH] = 500; - Sizes[EGDS_MESSAGE_BOX_HEIGHT] = 200; - Sizes[EGDS_BUTTON_WIDTH] = 80; - Sizes[EGDS_BUTTON_HEIGHT] = 30; - - Sizes[EGDS_TEXT_DISTANCE_X] = 2; - Sizes[EGDS_TEXT_DISTANCE_Y] = 0; - - Sizes[EGDS_TITLEBARTEXT_DISTANCE_X] = 2; - Sizes[EGDS_TITLEBARTEXT_DISTANCE_Y] = 0; - } - else - { - //0x80a6a8af - Colors[EGDC_3D_DARK_SHADOW] = 0x60767982; - //Colors[EGDC_3D_FACE] = 0xc0c9ccd4; // tab background - Colors[EGDC_3D_FACE] = 0xc0cbd2d9; // tab background - Colors[EGDC_3D_SHADOW] = 0x50e4e8f1; // tab background, and left-top highlight - Colors[EGDC_3D_HIGH_LIGHT] = 0x40c7ccdc; - Colors[EGDC_3D_LIGHT] = 0x802e313a; - Colors[EGDC_ACTIVE_BORDER] = 0x80404040; // window title - Colors[EGDC_ACTIVE_CAPTION] = 0xf0d0d0d0; - Colors[EGDC_APP_WORKSPACE] = 0xc0646464; // unused - Colors[EGDC_BUTTON_TEXT] = 0xd0161616; - Colors[EGDC_GRAY_TEXT] = 0x3c141414; - Colors[EGDC_HIGH_LIGHT] = 0x6c606060; - Colors[EGDC_HIGH_LIGHT_TEXT]= 0xd0e0e0e0; - Colors[EGDC_INACTIVE_BORDER]= 0xf0a5a5a5; - Colors[EGDC_INACTIVE_CAPTION]= 0xf0d2d2d2; - Colors[EGDC_TOOLTIP] = 0xf00f2033; - Colors[EGDC_TOOLTIP_BACKGROUND]=0xc0cbd2d9; - Colors[EGDC_SCROLLBAR] = 0xf0e0e0e0; - Colors[EGDC_WINDOW] = 0xf0f0f0f0; - Colors[EGDC_WINDOW_SYMBOL] = 0xd0161616; - Colors[EGDC_ICON] = 0xd0161616; - Colors[EGDC_ICON_HIGH_LIGHT]= 0xd0606060; - - Sizes[EGDS_SCROLLBAR_SIZE] = 14; - Sizes[EGDS_MENU_HEIGHT] = 48; - Sizes[EGDS_WINDOW_BUTTON_WIDTH] = 15; - Sizes[EGDS_CHECK_BOX_WIDTH] = 18; - Sizes[EGDS_MESSAGE_BOX_WIDTH] = 500; - Sizes[EGDS_MESSAGE_BOX_HEIGHT] = 200; - Sizes[EGDS_BUTTON_WIDTH] = 80; - Sizes[EGDS_BUTTON_HEIGHT] = 30; - - Sizes[EGDS_TEXT_DISTANCE_X] = 3; - Sizes[EGDS_TEXT_DISTANCE_Y] = 2; - - Sizes[EGDS_TITLEBARTEXT_DISTANCE_X] = 3; - Sizes[EGDS_TITLEBARTEXT_DISTANCE_Y] = 2; - } - - Texts[EGDT_MSG_BOX_OK] = L"OK"; - Texts[EGDT_MSG_BOX_CANCEL] = L"Cancel"; - Texts[EGDT_MSG_BOX_YES] = L"Yes"; - Texts[EGDT_MSG_BOX_NO] = L"No"; - Texts[EGDT_WINDOW_CLOSE] = L"Close"; - Texts[EGDT_WINDOW_RESTORE] = L"Restore"; - Texts[EGDT_WINDOW_MINIMIZE] = L"Minimize"; - Texts[EGDT_WINDOW_MAXIMIZE] = L"Maximize"; - - Icons[EGDI_WINDOW_MAXIMIZE] = 225; - Icons[EGDI_WINDOW_RESTORE] = 226; - Icons[EGDI_WINDOW_CLOSE] = 227; - Icons[EGDI_WINDOW_MINIMIZE] = 228; - Icons[EGDI_CURSOR_UP] = 229; - Icons[EGDI_CURSOR_DOWN] = 230; - Icons[EGDI_CURSOR_LEFT] = 231; - Icons[EGDI_CURSOR_RIGHT] = 232; - Icons[EGDI_MENU_MORE] = 232; - Icons[EGDI_CHECK_BOX_CHECKED] = 233; - Icons[EGDI_DROP_DOWN] = 234; - Icons[EGDI_SMALL_CURSOR_UP] = 235; - Icons[EGDI_SMALL_CURSOR_DOWN] = 236; - Icons[EGDI_RADIO_BUTTON_CHECKED] = 237; - Icons[EGDI_MORE_LEFT] = 238; - Icons[EGDI_MORE_RIGHT] = 239; - Icons[EGDI_MORE_UP] = 240; - Icons[EGDI_MORE_DOWN] = 241; - Icons[EGDI_WINDOW_RESIZE] = 242; - Icons[EGDI_EXPAND] = 243; - Icons[EGDI_COLLAPSE] = 244; - - Icons[EGDI_FILE] = 245; - Icons[EGDI_DIRECTORY] = 246; - - for (u32 i=0; i<EGDF_COUNT; ++i) - Fonts[i] = 0; - - UseGradient = (Type == EGST_WINDOWS_METALLIC) || (Type == EGST_BURNING_SKIN) ; -} - - -//! destructor -CGUISkin::~CGUISkin() -{ - for (u32 i=0; i<EGDF_COUNT; ++i) - { - if (Fonts[i]) - Fonts[i]->drop(); - } - - if (SpriteBank) - SpriteBank->drop(); -} - - -//! returns default color -video::SColor CGUISkin::getColor(EGUI_DEFAULT_COLOR color) const -{ - if ((u32)color < EGDC_COUNT) - return Colors[color]; - else - return video::SColor(); -} - - -//! sets a default color -void CGUISkin::setColor(EGUI_DEFAULT_COLOR which, video::SColor newColor) -{ - if ((u32)which < EGDC_COUNT) - Colors[which] = newColor; -} - - -//! returns size for the given size type -s32 CGUISkin::getSize(EGUI_DEFAULT_SIZE size) const -{ - if ((u32)size < EGDS_COUNT) - return Sizes[size]; - else - return 0; -} - - -//! sets a default size -void CGUISkin::setSize(EGUI_DEFAULT_SIZE which, s32 size) -{ - if ((u32)which < EGDS_COUNT) - Sizes[which] = size; -} - - -//! returns the default font -IGUIFont* CGUISkin::getFont(EGUI_DEFAULT_FONT which) const -{ - if (((u32)which < EGDS_COUNT) && Fonts[which]) - return Fonts[which]; - else - return Fonts[EGDF_DEFAULT]; -} - - -//! sets a default font -void CGUISkin::setFont(IGUIFont* font, EGUI_DEFAULT_FONT which) -{ - if ((u32)which >= EGDS_COUNT) - return; - - if (font) - { - font->grab(); - if (Fonts[which]) - Fonts[which]->drop(); - - Fonts[which] = font; - } -} - - -//! gets the sprite bank stored -IGUISpriteBank* CGUISkin::getSpriteBank() const -{ - return SpriteBank; -} - - -//! set a new sprite bank or remove one by passing 0 -void CGUISkin::setSpriteBank(IGUISpriteBank* bank) -{ - if (bank) - bank->grab(); - - if (SpriteBank) - SpriteBank->drop(); - - SpriteBank = bank; -} - - -//! Returns a default icon -u32 CGUISkin::getIcon(EGUI_DEFAULT_ICON icon) const -{ - if ((u32)icon < EGDI_COUNT) - return Icons[icon]; - else - return 0; -} - - -//! Sets a default icon -void CGUISkin::setIcon(EGUI_DEFAULT_ICON icon, u32 index) -{ - if ((u32)icon < EGDI_COUNT) - Icons[icon] = index; -} - - -//! Returns a default text. For example for Message box button captions: -//! "OK", "Cancel", "Yes", "No" and so on. -const wchar_t* CGUISkin::getDefaultText(EGUI_DEFAULT_TEXT text) const -{ - if ((u32)text < EGDT_COUNT) - return Texts[text].c_str(); - else - return Texts[0].c_str(); -} - - -//! Sets a default text. For example for Message box button captions: -//! "OK", "Cancel", "Yes", "No" and so on. -void CGUISkin::setDefaultText(EGUI_DEFAULT_TEXT which, const wchar_t* newText) -{ - if ((u32)which < EGDT_COUNT) - Texts[which] = newText; -} - - -//! draws a standard 3d button pane -/** Used for drawing for example buttons in normal state. -It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and -EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details. -\param rect: Defining area where to draw. -\param clip: Clip area. -\param element: Pointer to the element which wishes to draw this. This parameter -is usually not used by ISkin, but can be used for example by more complex -implementations to find out how to draw the part exactly. */ -void CGUISkin::draw3DButtonPaneStandard(IGUIElement* element, - const core::rect<s32>& r, - const core::rect<s32>* clip) -{ - if (!Driver) - return; - - core::rect<s32> rect = r; - - if ( Type == EGST_BURNING_SKIN ) - { - rect.UpperLeftCorner.X -= 1; - rect.UpperLeftCorner.Y -= 1; - rect.LowerRightCorner.X += 1; - rect.LowerRightCorner.Y += 1; - draw3DSunkenPane(element, - getColor( EGDC_WINDOW ).getInterpolated( 0xFFFFFFFF, 0.9f ) - ,false, true, rect, clip); - return; - } - - Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip); - - rect.LowerRightCorner.X -= 1; - rect.LowerRightCorner.Y -= 1; - Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); - - rect.UpperLeftCorner.X += 1; - rect.UpperLeftCorner.Y += 1; - Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); - - rect.LowerRightCorner.X -= 1; - rect.LowerRightCorner.Y -= 1; - - if (!UseGradient) - { - Driver->draw2DRectangle(getColor(EGDC_3D_FACE), rect, clip); - } - else - { - const video::SColor c1 = getColor(EGDC_3D_FACE); - const video::SColor c2 = c1.getInterpolated(getColor(EGDC_3D_DARK_SHADOW), 0.4f); - Driver->draw2DRectangle(rect, c1, c1, c2, c2, clip); - } -} - - -//! draws a pressed 3d button pane -/** Used for drawing for example buttons in pressed state. -It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and -EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details. -\param rect: Defining area where to draw. -\param clip: Clip area. -\param element: Pointer to the element which wishes to draw this. This parameter -is usually not used by ISkin, but can be used for example by more complex -implementations to find out how to draw the part exactly. */ -void CGUISkin::draw3DButtonPanePressed(IGUIElement* element, - const core::rect<s32>& r, - const core::rect<s32>* clip) -{ - if (!Driver) - return; - - core::rect<s32> rect = r; - Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); - - rect.LowerRightCorner.X -= 1; - rect.LowerRightCorner.Y -= 1; - Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip); - - rect.UpperLeftCorner.X += 1; - rect.UpperLeftCorner.Y += 1; - Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); - - rect.UpperLeftCorner.X += 1; - rect.UpperLeftCorner.Y += 1; - - if (!UseGradient) - { - Driver->draw2DRectangle(getColor(EGDC_3D_FACE), rect, clip); - } - else - { - const video::SColor c1 = getColor(EGDC_3D_FACE); - const video::SColor c2 = c1.getInterpolated(getColor(EGDC_3D_DARK_SHADOW), 0.4f); - Driver->draw2DRectangle(rect, c1, c1, c2, c2, clip); - } -} - - -//! draws a sunken 3d pane -/** Used for drawing the background of edit, combo or check boxes. -\param element: Pointer to the element which wishes to draw this. This parameter -is usually not used by ISkin, but can be used for example by more complex -implementations to find out how to draw the part exactly. -\param bgcolor: Background color. -\param flat: Specifies if the sunken pane should be flat or displayed as sunken -deep into the ground. -\param rect: Defining area where to draw. -\param clip: Clip area. */ -void CGUISkin::draw3DSunkenPane(IGUIElement* element, video::SColor bgcolor, - bool flat, bool fillBackGround, - const core::rect<s32>& r, - const core::rect<s32>* clip) -{ - if (!Driver) - return; - - core::rect<s32> rect = r; - - if (flat) - { - // draw flat sunken pane - if (fillBackGround) - Driver->draw2DRectangle(bgcolor, rect, clip); - - rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + 1; - Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); - - rect.LowerRightCorner.Y = r.LowerRightCorner.Y; - rect.LowerRightCorner.X = rect.UpperLeftCorner.X + 1; - Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); - - rect = r; - rect.UpperLeftCorner.X = rect.LowerRightCorner.X - 1; - Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); - - rect = r; - rect.UpperLeftCorner.Y = r.LowerRightCorner.Y - 1; - rect.LowerRightCorner.Y = r.LowerRightCorner.Y; - Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); - } - else - { - // draw deep sunken pane - if (fillBackGround) - Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); - - rect.LowerRightCorner.X -= 1; - rect.LowerRightCorner.Y -= 1; - Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); - - rect.UpperLeftCorner.X += 1; - rect.UpperLeftCorner.Y += 1; - Driver->draw2DRectangle(getColor(EGDC_3D_LIGHT), rect, clip); - - rect.LowerRightCorner.X -= 1; - rect.LowerRightCorner.Y -= 1; - Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip); - - rect.UpperLeftCorner.X += 1; - rect.UpperLeftCorner.Y += 1; - Driver->draw2DRectangle(bgcolor, rect, clip); - } -} - - -//! draws a window background -/** Used for drawing the background of dialogs and windows. -\param element: Pointer to the element which wishes to draw this. This parameter -is usually not used by ISkin, but can be used for example by more complex -implementations to find out how to draw the part exactly. -\param titleBarColor: Title color. -\param drawTitleBar: True to enable title drawing. -\param rect: Defining area where to draw. -\param clip: Clip area. -\return Returns rect where to draw title bar text. */ -core::rect<s32> CGUISkin::draw3DWindowBackground(IGUIElement* element, - bool drawTitleBar, video::SColor titleBarColor, - const core::rect<s32>& r, - const core::rect<s32>* cl) -{ - if (!Driver) - return r; - - core::rect<s32> rect = r; - - rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + 1; - Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, cl); - - rect.LowerRightCorner.Y = r.LowerRightCorner.Y; - rect.LowerRightCorner.X = rect.UpperLeftCorner.X + 1; - Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, cl); - - rect.UpperLeftCorner.X = r.LowerRightCorner.X - 1; - rect.LowerRightCorner.X = r.LowerRightCorner.X; - rect.UpperLeftCorner.Y = r.UpperLeftCorner.Y; - rect.LowerRightCorner.Y = r.LowerRightCorner.Y; - Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, cl); - - rect.UpperLeftCorner.X -= 1; - rect.LowerRightCorner.X -= 1; - rect.UpperLeftCorner.Y += 1; - rect.LowerRightCorner.Y -= 1; - Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, cl); - - rect.UpperLeftCorner.X = r.UpperLeftCorner.X; - rect.UpperLeftCorner.Y = r.LowerRightCorner.Y - 1; - rect.LowerRightCorner.Y = r.LowerRightCorner.Y; - rect.LowerRightCorner.X = r.LowerRightCorner.X; - Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, cl); - - rect.UpperLeftCorner.X += 1; - rect.LowerRightCorner.X -= 1; - rect.UpperLeftCorner.Y -= 1; - rect.LowerRightCorner.Y -= 1; - Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, cl); - - rect = r; - rect.UpperLeftCorner.X +=1; - rect.UpperLeftCorner.Y +=1; - rect.LowerRightCorner.X -= 2; - rect.LowerRightCorner.Y -= 2; - - if (!UseGradient) - { - Driver->draw2DRectangle(getColor(EGDC_3D_FACE), rect, cl); - } - else - if ( Type == EGST_BURNING_SKIN ) - { - const video::SColor c1 = getColor(EGDC_WINDOW).getInterpolated ( 0xFFFFFFFF, 0.9f ); - const video::SColor c2 = getColor(EGDC_WINDOW).getInterpolated ( 0xFFFFFFFF, 0.8f ); - - Driver->draw2DRectangle(rect, c1, c1, c2, c2, cl); - } - else - { - const video::SColor c2 = getColor(EGDC_3D_SHADOW); - const video::SColor c1 = getColor(EGDC_3D_FACE); - Driver->draw2DRectangle(rect, c1, c1, c1, c2, cl); - } - - rect = r; - rect.UpperLeftCorner.X += 2; - rect.UpperLeftCorner.Y += 2; - rect.LowerRightCorner.X -= 2; - rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + getSize(EGDS_WINDOW_BUTTON_WIDTH) + 2; - - if (drawTitleBar) - { - // draw title bar - //if (!UseGradient) - // Driver->draw2DRectangle(titleBarColor, rect, cl); - //else - if ( Type == EGST_BURNING_SKIN ) - { - const video::SColor c = titleBarColor.getInterpolated( 0xffffffff, 0.8f); - Driver->draw2DRectangle(rect, titleBarColor, titleBarColor, c, c, cl); - } - else - { - const video::SColor c = titleBarColor.getInterpolated(video::SColor(255,0,0,0), 0.2f); - Driver->draw2DRectangle(rect, titleBarColor, c, titleBarColor, c, cl); - } - } - - return rect; -} - - -//! draws a standard 3d menu pane -/** Used for drawing for menus and context menus. -It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and -EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details. -\param element: Pointer to the element which wishes to draw this. This parameter -is usually not used by ISkin, but can be used for example by more complex -implementations to find out how to draw the part exactly. -\param rect: Defining area where to draw. -\param clip: Clip area. */ -void CGUISkin::draw3DMenuPane(IGUIElement* element, - const core::rect<s32>& r, const core::rect<s32>* clip) -{ - if (!Driver) - return; - - core::rect<s32> rect = r; - - if ( Type == EGST_BURNING_SKIN ) - { - rect.UpperLeftCorner.Y -= 3; - draw3DButtonPaneStandard(element, rect, clip); - return; - } - - // in this skin, this is exactly what non pressed buttons look like, - // so we could simply call - // draw3DButtonPaneStandard(element, rect, clip); - // here. - // but if the skin is transparent, this doesn't look that nice. So - // We draw it a little bit better, with some more draw2DRectangle calls, - // but there aren't that much menus visible anyway. - - rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + 1; - Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); - - rect.LowerRightCorner.Y = r.LowerRightCorner.Y; - rect.LowerRightCorner.X = rect.UpperLeftCorner.X + 1; - Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); - - rect.UpperLeftCorner.X = r.LowerRightCorner.X - 1; - rect.LowerRightCorner.X = r.LowerRightCorner.X; - rect.UpperLeftCorner.Y = r.UpperLeftCorner.Y; - rect.LowerRightCorner.Y = r.LowerRightCorner.Y; - Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip); - - rect.UpperLeftCorner.X -= 1; - rect.LowerRightCorner.X -= 1; - rect.UpperLeftCorner.Y += 1; - rect.LowerRightCorner.Y -= 1; - Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); - - rect.UpperLeftCorner.X = r.UpperLeftCorner.X; - rect.UpperLeftCorner.Y = r.LowerRightCorner.Y - 1; - rect.LowerRightCorner.Y = r.LowerRightCorner.Y; - rect.LowerRightCorner.X = r.LowerRightCorner.X; - Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip); - - rect.UpperLeftCorner.X += 1; - rect.LowerRightCorner.X -= 1; - rect.UpperLeftCorner.Y -= 1; - rect.LowerRightCorner.Y -= 1; - Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); - - rect = r; - rect.UpperLeftCorner.X +=1; - rect.UpperLeftCorner.Y +=1; - rect.LowerRightCorner.X -= 2; - rect.LowerRightCorner.Y -= 2; - - if (!UseGradient) - Driver->draw2DRectangle(getColor(EGDC_3D_FACE), rect, clip); - else - { - const video::SColor c1 = getColor(EGDC_3D_FACE); - const video::SColor c2 = getColor(EGDC_3D_SHADOW); - Driver->draw2DRectangle(rect, c1, c1, c2, c2, clip); - } -} - - -//! draws a standard 3d tool bar -/** Used for drawing for toolbars and menus. -\param element: Pointer to the element which wishes to draw this. This parameter -is usually not used by ISkin, but can be used for example by more complex -implementations to find out how to draw the part exactly. -\param rect: Defining area where to draw. -\param clip: Clip area. */ -void CGUISkin::draw3DToolBar(IGUIElement* element, - const core::rect<s32>& r, - const core::rect<s32>* clip) -{ - if (!Driver) - return; - - core::rect<s32> rect = r; - - rect.UpperLeftCorner.X = r.UpperLeftCorner.X; - rect.UpperLeftCorner.Y = r.LowerRightCorner.Y - 1; - rect.LowerRightCorner.Y = r.LowerRightCorner.Y; - rect.LowerRightCorner.X = r.LowerRightCorner.X; - Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); - - rect = r; - rect.LowerRightCorner.Y -= 1; - - if (!UseGradient) - { - Driver->draw2DRectangle(getColor(EGDC_3D_FACE), rect, clip); - } - else - if ( Type == EGST_BURNING_SKIN ) - { - const video::SColor c1 = 0xF0000000 | getColor(EGDC_3D_FACE).color; - const video::SColor c2 = 0xF0000000 | getColor(EGDC_3D_SHADOW).color; - - rect.LowerRightCorner.Y += 1; - Driver->draw2DRectangle(rect, c1, c2, c1, c2, clip); - } - else - { - const video::SColor c1 = getColor(EGDC_3D_FACE); - const video::SColor c2 = getColor(EGDC_3D_SHADOW); - Driver->draw2DRectangle(rect, c1, c1, c2, c2, clip); - } -} - - -//! draws a tab button -/** Used for drawing for tab buttons on top of tabs. -\param element: Pointer to the element which wishes to draw this. This parameter -is usually not used by ISkin, but can be used for example by more complex -implementations to find out how to draw the part exactly. -\param active: Specifies if the tab is currently active. -\param rect: Defining area where to draw. -\param clip: Clip area. */ -void CGUISkin::draw3DTabButton(IGUIElement* element, bool active, - const core::rect<s32>& frameRect, const core::rect<s32>* clip, EGUI_ALIGNMENT alignment) -{ - if (!Driver) - return; - - core::rect<s32> tr = frameRect; - - if ( alignment == EGUIA_UPPERLEFT ) - { - tr.LowerRightCorner.X -= 2; - tr.LowerRightCorner.Y = tr.UpperLeftCorner.Y + 1; - tr.UpperLeftCorner.X += 1; - Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip); - - // draw left highlight - tr = frameRect; - tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1; - tr.UpperLeftCorner.Y += 1; - Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip); - - // draw grey background - tr = frameRect; - tr.UpperLeftCorner.X += 1; - tr.UpperLeftCorner.Y += 1; - tr.LowerRightCorner.X -= 2; - Driver->draw2DRectangle(getColor(EGDC_3D_FACE), tr, clip); - - // draw right middle gray shadow - tr.LowerRightCorner.X += 1; - tr.UpperLeftCorner.X = tr.LowerRightCorner.X - 1; - Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip); - - tr.LowerRightCorner.X += 1; - tr.UpperLeftCorner.X += 1; - tr.UpperLeftCorner.Y += 1; - Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), tr, clip); - } - else - { - tr.LowerRightCorner.X -= 2; - tr.UpperLeftCorner.Y = tr.LowerRightCorner.Y - 1; - tr.UpperLeftCorner.X += 1; - Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip); - - // draw left highlight - tr = frameRect; - tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1; - tr.LowerRightCorner.Y -= 1; - Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip); - - // draw grey background - tr = frameRect; - tr.UpperLeftCorner.X += 1; - tr.UpperLeftCorner.Y -= 1; - tr.LowerRightCorner.X -= 2; - tr.LowerRightCorner.Y -= 1; - Driver->draw2DRectangle(getColor(EGDC_3D_FACE), tr, clip); - - // draw right middle gray shadow - tr.LowerRightCorner.X += 1; - tr.UpperLeftCorner.X = tr.LowerRightCorner.X - 1; - //tr.LowerRightCorner.Y -= 1; - Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip); - - tr.LowerRightCorner.X += 1; - tr.UpperLeftCorner.X += 1; - tr.LowerRightCorner.Y -= 1; - Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), tr, clip); - } -} - - -//! draws a tab control body -/** \param element: Pointer to the element which wishes to draw this. This parameter -is usually not used by ISkin, but can be used for example by more complex -implementations to find out how to draw the part exactly. -\param border: Specifies if the border should be drawn. -\param background: Specifies if the background should be drawn. -\param rect: Defining area where to draw. -\param clip: Clip area. */ -void CGUISkin::draw3DTabBody(IGUIElement* element, bool border, bool background, - const core::rect<s32>& rect, const core::rect<s32>* clip, s32 tabHeight, EGUI_ALIGNMENT alignment) -{ - if (!Driver) - return; - - core::rect<s32> tr = rect; - - if ( tabHeight == -1 ) - tabHeight = getSize(gui::EGDS_BUTTON_HEIGHT); - - // draw border. - if (border) - { - if ( alignment == EGUIA_UPPERLEFT ) - { - // draw left hightlight - tr.UpperLeftCorner.Y += tabHeight + 2; - tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1; - Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip); - - // draw right shadow - tr.UpperLeftCorner.X = rect.LowerRightCorner.X - 1; - tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1; - Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip); - - // draw lower shadow - tr = rect; - tr.UpperLeftCorner.Y = tr.LowerRightCorner.Y - 1; - Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip); - } - else - { - // draw left hightlight - tr.LowerRightCorner.Y -= tabHeight + 2; - tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1; - Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip); - - // draw right shadow - tr.UpperLeftCorner.X = rect.LowerRightCorner.X - 1; - tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1; - Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip); - - // draw lower shadow - tr = rect; - tr.LowerRightCorner.Y = tr.UpperLeftCorner.Y + 1; - Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip); - } - } - - if (background) - { - if ( alignment == EGUIA_UPPERLEFT ) - { - tr = rect; - tr.UpperLeftCorner.Y += tabHeight + 2; - tr.LowerRightCorner.X -= 1; - tr.UpperLeftCorner.X += 1; - tr.LowerRightCorner.Y -= 1; - } - else - { - tr = rect; - tr.UpperLeftCorner.X += 1; - tr.UpperLeftCorner.Y -= 1; - tr.LowerRightCorner.X -= 1; - tr.LowerRightCorner.Y -= tabHeight + 2; - //tr.UpperLeftCorner.X += 1; - } - - if (!UseGradient) - Driver->draw2DRectangle(getColor(EGDC_3D_FACE), tr, clip); - else - { - video::SColor c1 = getColor(EGDC_3D_FACE); - video::SColor c2 = getColor(EGDC_3D_SHADOW); - Driver->draw2DRectangle(tr, c1, c1, c2, c2, clip); - } - } -} - - -//! draws an icon, usually from the skin's sprite bank -/** \param parent: Pointer to the element which wishes to draw this icon. -This parameter is usually not used by IGUISkin, but can be used for example -by more complex implementations to find out how to draw the part exactly. -\param icon: Specifies the icon to be drawn. -\param position: The position to draw the icon -\param starttime: The time at the start of the animation -\param currenttime: The present time, used to calculate the frame number -\param loop: Whether the animation should loop or not -\param clip: Clip area. */ -void CGUISkin::drawIcon(IGUIElement* element, EGUI_DEFAULT_ICON icon, - const core::position2di position, - u32 starttime, u32 currenttime, - bool loop, const core::rect<s32>* clip) -{ - if (!SpriteBank) - return; - - SpriteBank->draw2DSprite(Icons[icon], position, clip, - video::SColor(255,0,0,0), starttime, currenttime, loop, true); -} - - -EGUI_SKIN_TYPE CGUISkin::getType() const -{ - return Type; -} - - -//! draws a 2d rectangle. -void CGUISkin::draw2DRectangle(IGUIElement* element, - const video::SColor &color, const core::rect<s32>& pos, - const core::rect<s32>* clip) -{ - Driver->draw2DRectangle(color, pos, clip); -} - - -//! Writes attributes of the object. -//! Implement this to expose the attributes of your scene node animator for -//! scripting languages, editors, debuggers or xml serialization purposes. -void CGUISkin::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const -{ - u32 i; - for (i=0; i<EGDC_COUNT; ++i) - out->addColor(GUISkinColorNames[i], Colors[i]); - - for (i=0; i<EGDS_COUNT; ++i) - out->addInt(GUISkinSizeNames[i], Sizes[i]); - - for (i=0; i<EGDT_COUNT; ++i) - out->addString(GUISkinTextNames[i], Texts[i].c_str()); - - for (i=0; i<EGDI_COUNT; ++i) - out->addInt(GUISkinIconNames[i], Icons[i]); -} - - -//! Reads attributes of the object. -//! Implement this to set the attributes of your scene node animator for -//! scripting languages, editors, debuggers or xml deserialization purposes. -void CGUISkin::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - u32 i; - for (i=0; i<EGDC_COUNT; ++i) - Colors[i] = in->getAttributeAsColor(GUISkinColorNames[i]); - - for (i=0; i<EGDS_COUNT; ++i) - Sizes[i] = in->getAttributeAsInt(GUISkinSizeNames[i]); - - for (i=0; i<EGDT_COUNT; ++i) - Texts[i] = in->getAttributeAsStringW(GUISkinTextNames[i]); - - for (i=0; i<EGDI_COUNT; ++i) - Icons[i] = in->getAttributeAsInt(GUISkinIconNames[i]); -} - - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - diff --git a/irrlicht-1.6/source/Irrlicht/CGUISkin.h b/irrlicht-1.6/source/Irrlicht/CGUISkin.h deleted file mode 100644 index 8ac2c2086..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUISkin.h +++ /dev/null @@ -1,244 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_SKIN_H_INCLUDED__ -#define __C_GUI_SKIN_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUISkin.h" -#include "irrString.h" - -namespace irr -{ -namespace video -{ - class IVideoDriver; -} -namespace gui -{ - - class CGUISkin : public IGUISkin - { - public: - - CGUISkin(EGUI_SKIN_TYPE type, video::IVideoDriver* driver); - - //! destructor - virtual ~CGUISkin(); - - //! returns default color - virtual video::SColor getColor(EGUI_DEFAULT_COLOR color) const; - - //! sets a default color - virtual void setColor(EGUI_DEFAULT_COLOR which, video::SColor newColor); - - //! returns size for the given size type - virtual s32 getSize(EGUI_DEFAULT_SIZE size) const; - - //! sets a default size - virtual void setSize(EGUI_DEFAULT_SIZE which, s32 size); - - //! returns the default font - virtual IGUIFont* getFont(EGUI_DEFAULT_FONT which=EGDF_DEFAULT) const; - - //! sets a default font - virtual void setFont(IGUIFont* font, EGUI_DEFAULT_FONT which=EGDF_DEFAULT); - - //! sets the sprite bank used for drawing icons - virtual void setSpriteBank(IGUISpriteBank* bank); - - //! gets the sprite bank used for drawing icons - virtual IGUISpriteBank* getSpriteBank() const; - - //! Returns a default icon - /** Returns the sprite index within the sprite bank */ - virtual u32 getIcon(EGUI_DEFAULT_ICON icon) const; - - //! Sets a default icon - /** Sets the sprite index used for drawing icons like arrows, - close buttons and ticks in checkboxes - \param icon: Enum specifying which icon to change - \param index: The sprite index used to draw this icon */ - virtual void setIcon(EGUI_DEFAULT_ICON icon, u32 index); - - //! Returns a default text. - /** For example for Message box button captions: - "OK", "Cancel", "Yes", "No" and so on. */ - virtual const wchar_t* getDefaultText(EGUI_DEFAULT_TEXT text) const; - - //! Sets a default text. - /** For example for Message box button captions: - "OK", "Cancel", "Yes", "No" and so on. */ - virtual void setDefaultText(EGUI_DEFAULT_TEXT which, const wchar_t* newText); - - //! draws a standard 3d button pane - /** Used for drawing for example buttons in normal state. - It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and - EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details. - \param rect: Defining area where to draw. - \param clip: Clip area. - \param element: Pointer to the element which wishes to draw this. This parameter - is usually not used by ISkin, but can be used for example by more complex - implementations to find out how to draw the part exactly. */ - virtual void draw3DButtonPaneStandard(IGUIElement* element, - const core::rect<s32>& rect, - const core::rect<s32>* clip=0); - - //! draws a pressed 3d button pane - /** Used for drawing for example buttons in pressed state. - It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and - EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details. - \param rect: Defining area where to draw. - \param clip: Clip area. - \param element: Pointer to the element which wishes to draw this. This parameter - is usually not used by ISkin, but can be used for example by more complex - implementations to find out how to draw the part exactly. */ - virtual void draw3DButtonPanePressed(IGUIElement* element, - const core::rect<s32>& rect, - const core::rect<s32>* clip=0); - - //! draws a sunken 3d pane - /** Used for drawing the background of edit, combo or check boxes. - \param element: Pointer to the element which wishes to draw this. This parameter - is usually not used by ISkin, but can be used for example by more complex - implementations to find out how to draw the part exactly. - \param bgcolor: Background color. - \param flat: Specifies if the sunken pane should be flat or displayed as sunken - deep into the ground. - \param rect: Defining area where to draw. - \param clip: Clip area. */ - virtual void draw3DSunkenPane(IGUIElement* element, - video::SColor bgcolor, bool flat, - bool fillBackGround, - const core::rect<s32>& rect, - const core::rect<s32>* clip=0); - - //! draws a window background - /** Used for drawing the background of dialogs and windows. - \param element: Pointer to the element which wishes to draw this. This parameter - is usually not used by ISkin, but can be used for example by more complex - implementations to find out how to draw the part exactly. - \param titleBarColor: Title color. - \param drawTitleBar: True to enable title drawing. - \param rect: Defining area where to draw. - \param clip: Clip area. - \return Returns rect where to draw title bar text. */ - virtual core::rect<s32> draw3DWindowBackground(IGUIElement* element, - bool drawTitleBar, video::SColor titleBarColor, - const core::rect<s32>& rect, - const core::rect<s32>* clip=0); - - //! draws a standard 3d menu pane - /** Used for drawing for menus and context menus. - It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and - EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details. - \param element: Pointer to the element which wishes to draw this. This parameter - is usually not used by ISkin, but can be used for example by more complex - implementations to find out how to draw the part exactly. - \param rect: Defining area where to draw. - \param clip: Clip area. */ - virtual void draw3DMenuPane(IGUIElement* element, - const core::rect<s32>& rect, - const core::rect<s32>* clip=0); - - //! draws a standard 3d tool bar - /** Used for drawing for toolbars and menus. - \param element: Pointer to the element which wishes to draw this. This parameter - is usually not used by ISkin, but can be used for example by more complex - implementations to find out how to draw the part exactly. - \param rect: Defining area where to draw. - \param clip: Clip area. */ - virtual void draw3DToolBar(IGUIElement* element, - const core::rect<s32>& rect, - const core::rect<s32>* clip=0); - - //! draws a tab button - /** Used for drawing for tab buttons on top of tabs. - \param element: Pointer to the element which wishes to draw this. This parameter - is usually not used by ISkin, but can be used for example by more complex - implementations to find out how to draw the part exactly. - \param active: Specifies if the tab is currently active. - \param rect: Defining area where to draw. - \param clip: Clip area. */ - virtual void draw3DTabButton(IGUIElement* element, bool active, - const core::rect<s32>& rect, const core::rect<s32>* clip=0, EGUI_ALIGNMENT alignment=EGUIA_UPPERLEFT); - - //! draws a tab control body - /** \param element: Pointer to the element which wishes to draw this. This parameter - is usually not used by ISkin, but can be used for example by more complex - implementations to find out how to draw the part exactly. - \param border: Specifies if the border should be drawn. - \param background: Specifies if the background should be drawn. - \param rect: Defining area where to draw. - \param clip: Clip area. */ - virtual void draw3DTabBody(IGUIElement* element, bool border, bool background, - const core::rect<s32>& rect, const core::rect<s32>* clip=0, s32 tabHeight=-1, EGUI_ALIGNMENT alignment=EGUIA_UPPERLEFT); - - //! draws an icon, usually from the skin's sprite bank - /** \param element: Pointer to the element which wishes to draw this icon. - This parameter is usually not used by IGUISkin, but can be used for example - by more complex implementations to find out how to draw the part exactly. - \param icon: Specifies the icon to be drawn. - \param position: The position to draw the icon - \param starttime: The time at the start of the animation - \param currenttime: The present time, used to calculate the frame number - \param loop: Whether the animation should loop or not - \param clip: Clip area. */ - virtual void drawIcon(IGUIElement* element, EGUI_DEFAULT_ICON icon, - const core::position2di position, - u32 starttime=0, u32 currenttime=0, - bool loop=false, const core::rect<s32>* clip=0); - - - //! draws a 2d rectangle. - /** \param element: Pointer to the element which wishes to draw this icon. - This parameter is usually not used by IGUISkin, but can be used for example - by more complex implementations to find out how to draw the part exactly. - \param color: Color of the rectangle to draw. The alpha component specifies how - transparent the rectangle will be. - \param pos: Position of the rectangle. - \param clip: Pointer to rectangle against which the rectangle will be clipped. - If the pointer is null, no clipping will be performed. */ - virtual void draw2DRectangle(IGUIElement* element, const video::SColor &color, - const core::rect<s32>& pos, const core::rect<s32>* clip = 0); - - - //! get the type of this skin - virtual EGUI_SKIN_TYPE getType() const; - - //! Writes attributes of the object. - //! Implement this to expose the attributes of your scene node animator for - //! scripting languages, editors, debuggers or xml serialization purposes. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const; - - //! Reads attributes of the object. - //! Implement this to set the attributes of your scene node animator for - //! scripting languages, editors, debuggers or xml deserialization purposes. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - private: - - video::SColor Colors[EGDC_COUNT]; - s32 Sizes[EGDS_COUNT]; - u32 Icons[EGDI_COUNT]; - IGUIFont* Fonts[EGDF_COUNT]; - IGUISpriteBank* SpriteBank; - core::stringw Texts[EGDT_COUNT]; - video::IVideoDriver* Driver; - bool UseGradient; - - EGUI_SKIN_TYPE Type; - }; - - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - -#endif - - diff --git a/irrlicht-1.6/source/Irrlicht/CGUISpinBox.cpp b/irrlicht-1.6/source/Irrlicht/CGUISpinBox.cpp deleted file mode 100644 index 866ea1e2a..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUISpinBox.cpp +++ /dev/null @@ -1,291 +0,0 @@ -// Copyright (C) 2006-2009 Michael Zeilfelder -// This file uses the licence of the Irrlicht Engine. - -#include "CGUISpinBox.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "CGUIEditBox.h" -#include "CGUIButton.h" -#include "IGUIEnvironment.h" -#include "IEventReceiver.h" -#include "fast_atof.h" -#include <wchar.h> - - -namespace irr -{ -namespace gui -{ - -//! constructor -CGUISpinBox::CGUISpinBox(const wchar_t* text, bool border,IGUIEnvironment* environment, - IGUIElement* parent, s32 id, const core::rect<s32>& rectangle) -: IGUISpinBox(environment, parent, id, rectangle), - EditBox(0), ButtonSpinUp(0), ButtonSpinDown(0), StepSize(1.f), - RangeMin(-FLT_MAX), RangeMax(FLT_MAX), FormatString(L"%f"), - DecimalPlaces(-1) -{ - #ifdef _DEBUG - setDebugName("CGUISpinBox"); - #endif - - s32 ButtonWidth = 16; - IGUISpriteBank *sb = 0; - if (environment && environment->getSkin()) - { - ButtonWidth = environment->getSkin()->getSize(EGDS_SCROLLBAR_SIZE); - sb = environment->getSkin()->getSpriteBank(); - } - - ButtonSpinDown = Environment->addButton( - core::rect<s32>(rectangle.getWidth() - ButtonWidth, rectangle.getHeight()/2 +1, - rectangle.getWidth(), rectangle.getHeight()), this); - ButtonSpinDown->grab(); - ButtonSpinDown->setSubElement(true); - ButtonSpinDown->setTabStop(false); - ButtonSpinDown->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_CENTER, EGUIA_LOWERRIGHT); - - ButtonSpinUp = Environment->addButton( - core::rect<s32>(rectangle.getWidth() - ButtonWidth, 0, - rectangle.getWidth(), rectangle.getHeight()/2), this); - ButtonSpinUp->grab(); - ButtonSpinUp->setSubElement(true); - ButtonSpinUp->setTabStop(false); - ButtonSpinUp->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_CENTER); - if (sb) - { - IGUISkin *skin = environment->getSkin(); - ButtonSpinDown->setSpriteBank(sb); - ButtonSpinDown->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_SMALL_CURSOR_DOWN), skin->getColor(EGDC_WINDOW_SYMBOL)); - ButtonSpinDown->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_SMALL_CURSOR_DOWN), skin->getColor(EGDC_WINDOW_SYMBOL)); - ButtonSpinUp->setSpriteBank(sb); - ButtonSpinUp->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_SMALL_CURSOR_UP), skin->getColor(EGDC_WINDOW_SYMBOL)); - ButtonSpinUp->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_SMALL_CURSOR_UP), skin->getColor(EGDC_WINDOW_SYMBOL)); - } - else - { - ButtonSpinDown->setText(L"-"); - ButtonSpinUp->setText(L"+"); - } - - const core::rect<s32> rectEdit(0, 0, rectangle.getWidth() - ButtonWidth - 1, rectangle.getHeight()); - EditBox = Environment->addEditBox(text, rectEdit, border, this, -1); - EditBox->grab(); - EditBox->setSubElement(true); - EditBox->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); -} - - -//! destructor -CGUISpinBox::~CGUISpinBox() -{ - if (ButtonSpinUp) - ButtonSpinUp->drop(); - if (ButtonSpinDown) - ButtonSpinDown->drop(); - if (EditBox) - EditBox->drop(); -} - - -IGUIEditBox* CGUISpinBox::getEditBox() const -{ - return EditBox; -} - - -void CGUISpinBox::setValue(f32 val) -{ - wchar_t str[100]; - - swprintf(str, 99, FormatString.c_str(), val); - EditBox->setText(str); - verifyValueRange(); -} - - -f32 CGUISpinBox::getValue() const -{ - const wchar_t* val = EditBox->getText(); - if ( !val ) - return 0.f; - core::stringc tmp(val); - return core::fast_atof(tmp.c_str()); -} - - -void CGUISpinBox::setRange(f32 min, f32 max) -{ - RangeMin = min; - RangeMax = max; - verifyValueRange(); -} - - -f32 CGUISpinBox::getMin() const -{ - return RangeMin; -} - - -f32 CGUISpinBox::getMax() const -{ - return RangeMax; -} - - -f32 CGUISpinBox::getStepSize() const -{ - return StepSize; -} - - -void CGUISpinBox::setStepSize(f32 step) -{ - StepSize = step; -} - - -//! Sets the number of decimal places to display. -void CGUISpinBox::setDecimalPlaces(s32 places) -{ - DecimalPlaces = places; - if (places == -1) - FormatString = "%f"; - else - { - FormatString = "%."; - FormatString += places; - FormatString += "f"; - } - setValue(getValue()); -} - - -bool CGUISpinBox::OnEvent(const SEvent& event) -{ - if (IsEnabled) - { - bool changeEvent = false; - switch(event.EventType) - { - case EET_MOUSE_INPUT_EVENT: - switch(event.MouseInput.Event) - { - case EMIE_MOUSE_WHEEL: - { - f32 val = getValue() + (StepSize * event.MouseInput.Wheel); - setValue(val); - changeEvent = true; - } - break; - default: - break; - } - break; - - case EET_GUI_EVENT: - if (event.GUIEvent.EventType == EGET_BUTTON_CLICKED) - { - if (event.GUIEvent.Caller == ButtonSpinUp) - { - f32 val = getValue(); - val += StepSize; - setValue(val); - changeEvent = true; - } - else if ( event.GUIEvent.Caller == ButtonSpinDown) - { - f32 val = getValue(); - val -= StepSize; - setValue(val); - changeEvent = true; - } - } - if ( event.GUIEvent.EventType == EGET_EDITBOX_CHANGED ) - { - if (event.GUIEvent.Caller == EditBox) - { - verifyValueRange(); - changeEvent = true; - } - } - break; - default: - break; - } - - if ( changeEvent ) - { - SEvent e; - e.EventType = EET_GUI_EVENT; - e.GUIEvent.Caller = this; - e.GUIEvent.Element = 0; - - e.GUIEvent.EventType = EGET_SPINBOX_CHANGED; - if ( Parent ) - Parent->OnEvent(e); - return true; - } - } - - return IGUIElement::OnEvent(event); -} - - -void CGUISpinBox::verifyValueRange() -{ - f32 val = getValue(); - if ( val < RangeMin ) - val = RangeMin; - else if ( val > RangeMax ) - val = RangeMax; - else - return; - - setValue(val); -} - - -//! Sets the new caption of the element -void CGUISpinBox::setText(const wchar_t* text) -{ - EditBox->setText(text); - setValue(getValue()); - verifyValueRange(); -} - - -//! Returns caption of this element. -const wchar_t* CGUISpinBox::getText() const -{ - return EditBox->getText(); -} - - -//! Writes attributes of the element. -void CGUISpinBox::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const -{ - IGUIElement::serializeAttributes(out, options); - out->addFloat("Min", getMin()); - out->addFloat("Max", getMax()); - out->addFloat("Step", getStepSize()); - out->addInt("DecimalPlaces", DecimalPlaces); -} - - -//! Reads attributes of the element -void CGUISpinBox::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - IGUIElement::deserializeAttributes(in, options); - setRange(in->getAttributeAsFloat("Min"), in->getAttributeAsFloat("Max")); - setStepSize(in->getAttributeAsFloat("Step")); - setDecimalPlaces(in->getAttributeAsInt("DecimalPlaces")); -} - - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - diff --git a/irrlicht-1.6/source/Irrlicht/CGUISpinBox.h b/irrlicht-1.6/source/Irrlicht/CGUISpinBox.h deleted file mode 100644 index c2e328efb..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUISpinBox.h +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (C) 2006-2009 Michael Zeilfelder -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_SPIN_BOX_H_INCLUDED__ -#define __C_GUI_SPIN_BOX_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUISpinBox.h" - -namespace irr -{ -namespace gui -{ - class IGUIEditBox; - class IGUIButton; - - class CGUISpinBox : public IGUISpinBox - { - public: - - //! constructor - CGUISpinBox(const wchar_t* text, bool border, IGUIEnvironment* environment, - IGUIElement* parent, s32 id, const core::rect<s32>& rectangle); - - //! destructor - virtual ~CGUISpinBox(); - - //! Access the edit box used in the spin control - /** \param enable: If set to true, the override color, which can be set - with IGUIEditBox::setOverrideColor is used, otherwise the - EGDC_BUTTON_TEXT color of the skin. */ - virtual IGUIEditBox* getEditBox() const; - - //! set the current value of the spinbox - /** \param val: value to be set in the spinbox */ - virtual void setValue(f32 val); - - //! Get the current value of the spinbox - virtual f32 getValue() const; - - //! set the range of values which can be used in the spinbox - /** \param min: minimum value - \param max: maximum value */ - virtual void setRange(f32 min, f32 max); - - //! get the minimum value which can be used in the spinbox - virtual f32 getMin() const; - - //! get the maximum value which can be used in the spinbox - virtual f32 getMax() const; - - //! step size by which values are changed when pressing the spin buttons - /** \param step: stepsize used for value changes when pressing spin buttons */ - virtual void setStepSize(f32 step=1.f); - - //! returns the step size - virtual f32 getStepSize() const; - - //! called if an event happened. - virtual bool OnEvent(const SEvent& event); - - //! Sets the new caption of the element - virtual void setText(const wchar_t* text); - - //! Returns caption of this element. - virtual const wchar_t* getText() const; - - //! Sets the number of decimal places to display. - /** \param places: The number of decimal places to display, use -1 to reset */ - virtual void setDecimalPlaces(s32 places); - - //! Writes attributes of the element. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; - - //! Reads attributes of the element - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - - protected: - virtual void verifyValueRange(); - - IGUIEditBox * EditBox; - IGUIButton * ButtonSpinUp; - IGUIButton * ButtonSpinDown; - f32 StepSize; - f32 RangeMin; - f32 RangeMax; - - core::stringw FormatString; - s32 DecimalPlaces; - }; - - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - -#endif // __C_GUI_SPIN_BOX_H_INCLUDED__ - diff --git a/irrlicht-1.6/source/Irrlicht/CGUISpriteBank.cpp b/irrlicht-1.6/source/Irrlicht/CGUISpriteBank.cpp deleted file mode 100644 index 713e1a88b..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUISpriteBank.cpp +++ /dev/null @@ -1,211 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUISpriteBank.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUIEnvironment.h" -#include "IVideoDriver.h" -#include "ITexture.h" - -namespace irr -{ -namespace gui -{ - -CGUISpriteBank::CGUISpriteBank(IGUIEnvironment* env) : - Environment(env), Driver(0) -{ - #ifdef _DEBUG - setDebugName("CGUISpriteBank"); - #endif - - if (Environment) - { - Driver = Environment->getVideoDriver(); - if (Driver) - Driver->grab(); - } -} - - -CGUISpriteBank::~CGUISpriteBank() -{ - // drop textures - for (u32 i=0; i<Textures.size(); ++i) - if (Textures[i]) - Textures[i]->drop(); - - // drop video driver - if (Driver) - Driver->drop(); -} - - -core::array< core::rect<s32> >& CGUISpriteBank::getPositions() -{ - return Rectangles; -} - - -core::array< SGUISprite >& CGUISpriteBank::getSprites() -{ - return Sprites; -} - - -u32 CGUISpriteBank::getTextureCount() const -{ - return Textures.size(); -} - - -video::ITexture* CGUISpriteBank::getTexture(u32 index) const -{ - if (index < Textures.size()) - return Textures[index]; - else - return 0; -} - - -void CGUISpriteBank::addTexture(video::ITexture* texture) -{ - if (texture) - texture->grab(); - - Textures.push_back(texture); -} - - -void CGUISpriteBank::setTexture(u32 index, video::ITexture* texture) -{ - while (index >= Textures.size()) - Textures.push_back(0); - - if (texture) - texture->grab(); - - if (Textures[index]) - Textures[index]->drop(); - - Textures[index] = texture; -} - - -//! draws a sprite in 2d with scale and color -void CGUISpriteBank::draw2DSprite(u32 index, const core::position2di& pos, - const core::rect<s32>* clip, const video::SColor& color, - u32 starttime, u32 currenttime, bool loop, bool center) -{ - if (index >= Sprites.size() || Sprites[index].Frames.empty() ) - return; - - // work out frame number - u32 frame = 0; - if (Sprites[index].frameTime) - { - u32 f = ((currenttime - starttime) / Sprites[index].frameTime); - if (loop) - frame = f % Sprites[index].Frames.size(); - else - frame = (f >= Sprites[index].Frames.size()) ? Sprites[index].Frames.size()-1 : f; - } - - const video::ITexture* tex = Textures[Sprites[index].Frames[frame].textureNumber]; - if (!tex) - return; - - const u32 rn = Sprites[index].Frames[frame].rectNumber; - if (rn >= Rectangles.size()) - return; - - const core::rect<s32>& r = Rectangles[rn]; - - if (center) - { - core::position2di p = pos; - p -= r.getSize() / 2; - Driver->draw2DImage(tex, p, r, clip, color, true); - } - else - { - Driver->draw2DImage(tex, pos, r, clip, color, true); - } -} - - -void CGUISpriteBank::draw2DSpriteBatch( const core::array<u32>& indices, - const core::array<core::position2di>& pos, - const core::rect<s32>* clip, - const video::SColor& color, - u32 starttime, u32 currenttime, - bool loop, bool center) -{ - const irr::u32 drawCount = core::min_<u32>(indices.size(), pos.size()); - - core::array<SDrawBatch> drawBatches(Textures.size()); - for(u32 i = 0;i < Textures.size();i++) - { - drawBatches.push_back(SDrawBatch()); - drawBatches[i].positions.reallocate(drawCount); - drawBatches[i].sourceRects.reallocate(drawCount); - } - - for(u32 i = 0;i < drawCount;i++) - { - const u32 index = indices[i]; - - if (index >= Sprites.size() || Sprites[index].Frames.empty() ) - continue; - - // work out frame number - u32 frame = 0; - if (Sprites[index].frameTime) - { - u32 f = ((currenttime - starttime) / Sprites[index].frameTime); - if (loop) - frame = f % Sprites[index].Frames.size(); - else - frame = (f >= Sprites[index].Frames.size()) ? Sprites[index].Frames.size()-1 : f; - } - - const u32 texNum = Sprites[index].Frames[frame].textureNumber; - - SDrawBatch& currentBatch = drawBatches[texNum]; - - const u32 rn = Sprites[index].Frames[frame].rectNumber; - if (rn >= Rectangles.size()) - return; - - const core::rect<s32>& r = Rectangles[rn]; - - if (center) - { - core::position2di p = pos[i]; - p -= r.getSize() / 2; - - currentBatch.positions.push_back(p); - currentBatch.sourceRects.push_back(r); - } - else - { - currentBatch.positions.push_back(pos[i]); - currentBatch.sourceRects.push_back(r); - } - } - - for(u32 i = 0;i < drawBatches.size();i++) - { - if(!drawBatches[i].positions.empty() && !drawBatches[i].sourceRects.empty()) - Driver->draw2DImageBatch(Textures[i], drawBatches[i].positions, - drawBatches[i].sourceRects, clip, color, true); - } -} - -} // namespace gui -} // namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - diff --git a/irrlicht-1.6/source/Irrlicht/CGUISpriteBank.h b/irrlicht-1.6/source/Irrlicht/CGUISpriteBank.h deleted file mode 100644 index 30253b0fd..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUISpriteBank.h +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_SPRITE_BANK_H_INCLUDED__ -#define __C_GUI_SPRITE_BANK_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUISpriteBank.h" - -namespace irr -{ - -namespace video -{ - class IVideoDriver; - class ITexture; -} - -namespace gui -{ - - class IGUIEnvironment; - -//! Sprite bank interface. -class CGUISpriteBank : public IGUISpriteBank -{ -public: - - CGUISpriteBank(IGUIEnvironment* env); - virtual ~CGUISpriteBank(); - - virtual core::array< core::rect<s32> >& getPositions(); - virtual core::array< SGUISprite >& getSprites(); - - virtual u32 getTextureCount() const; - virtual video::ITexture* getTexture(u32 index) const; - virtual void addTexture(video::ITexture* texture); - virtual void setTexture(u32 index, video::ITexture* texture); - - //! Draws a sprite in 2d with position and color - virtual void draw2DSprite(u32 index, const core::position2di& pos, const core::rect<s32>* clip=0, - const video::SColor& color= video::SColor(255,255,255,255), - u32 starttime=0, u32 currenttime=0, bool loop=true, bool center=false); - - //! Draws a sprite batch in 2d using an array of positions and a color - virtual void draw2DSpriteBatch(const core::array<u32>& indices, const core::array<core::position2di>& pos, - const core::rect<s32>* clip=0, - const video::SColor& color= video::SColor(255,255,255,255), - u32 starttime=0, u32 currenttime=0, - bool loop=true, bool center=false); - -protected: - - struct SDrawBatch - { - core::array<core::position2di> positions; - core::array<core::recti> sourceRects; - u32 textureNumber; - }; - - core::array<SGUISprite> Sprites; - core::array< core::rect<s32> > Rectangles; - core::array<video::ITexture*> Textures; - IGUIEnvironment* Environment; - video::IVideoDriver* Driver; - -}; - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - -#endif // __C_GUI_SPRITE_BANK_H_INCLUDED__ - diff --git a/irrlicht-1.6/source/Irrlicht/CGUIStaticText.cpp b/irrlicht-1.6/source/Irrlicht/CGUIStaticText.cpp deleted file mode 100644 index e0f52a1bf..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIStaticText.cpp +++ /dev/null @@ -1,461 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUIStaticText.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUISkin.h" -#include "IGUIEnvironment.h" -#include "IGUIFont.h" -#include "IVideoDriver.h" -#include "rect.h" - -namespace irr -{ -namespace gui -{ - -//! constructor -CGUIStaticText::CGUIStaticText(const wchar_t* text, bool border, - IGUIEnvironment* environment, IGUIElement* parent, - s32 id, const core::rect<s32>& rectangle, - bool background) -: IGUIStaticText(environment, parent, id, rectangle), - HAlign(EGUIA_UPPERLEFT), VAlign(EGUIA_UPPERLEFT), - Border(border), OverrideColorEnabled(false), WordWrap(false), Background(background), - OverrideColor(video::SColor(101,255,255,255)), BGColor(video::SColor(101,210,210,210)), - OverrideFont(0), LastBreakFont(0) -{ - #ifdef _DEBUG - setDebugName("CGUIStaticText"); - #endif - - Text = text; - if (environment && environment->getSkin()) - { - BGColor = environment->getSkin()->getColor(gui::EGDC_3D_FACE); - } -} - - -//! destructor -CGUIStaticText::~CGUIStaticText() -{ - if (OverrideFont) - OverrideFont->drop(); -} - - -//! draws the element and its children -void CGUIStaticText::draw() -{ - if (!IsVisible) - return; - - IGUISkin* skin = Environment->getSkin(); - if (!skin) - return; - video::IVideoDriver* driver = Environment->getVideoDriver(); - - core::rect<s32> frameRect(AbsoluteRect); - - // draw background - - if (Background) - { - driver->draw2DRectangle(BGColor, frameRect, &AbsoluteClippingRect); - } - - // draw the border - - if (Border) - { - skin->draw3DSunkenPane(this, 0, true, false, frameRect, &AbsoluteClippingRect); - frameRect.UpperLeftCorner.X += skin->getSize(EGDS_TEXT_DISTANCE_X); - } - - // draw the text - if (Text.size()) - { - IGUIFont* font = OverrideFont; - if (!OverrideFont) - font = skin->getFont(); - - if (font) - { - if (!WordWrap) - { - if (VAlign == EGUIA_LOWERRIGHT) - { - frameRect.UpperLeftCorner.Y = frameRect.LowerRightCorner.Y - - font->getDimension(L"A").Height - font->getKerningHeight(); - } - if (HAlign == EGUIA_LOWERRIGHT) - { - frameRect.UpperLeftCorner.X = frameRect.LowerRightCorner.X - - font->getDimension(Text.c_str()).Width; - } - - font->draw(Text.c_str(), frameRect, - OverrideColorEnabled ? OverrideColor : skin->getColor(IsEnabled ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT), - HAlign == EGUIA_CENTER, VAlign == EGUIA_CENTER, &AbsoluteClippingRect); - } - else - { - if (font != LastBreakFont) - breakText(); - - core::rect<s32> r = frameRect; - s32 height = font->getDimension(L"A").Height + font->getKerningHeight(); - s32 totalHeight = height * BrokenText.size(); - if (VAlign == EGUIA_CENTER) - { - r.UpperLeftCorner.Y = r.getCenter().Y - (totalHeight / 2); - } - else if (VAlign == EGUIA_LOWERRIGHT) - { - r.UpperLeftCorner.Y = r.LowerRightCorner.Y - totalHeight; - } - - for (u32 i=0; i<BrokenText.size(); ++i) - { - if (HAlign == EGUIA_LOWERRIGHT) - { - r.UpperLeftCorner.X = frameRect.LowerRightCorner.X - - font->getDimension(BrokenText[i].c_str()).Width; - } - - font->draw(BrokenText[i].c_str(), r, - OverrideColorEnabled ? OverrideColor : skin->getColor(IsEnabled ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT), - HAlign == EGUIA_CENTER, false, &AbsoluteClippingRect); - - r.LowerRightCorner.Y += height; - r.UpperLeftCorner.Y += height; - } - } - } - } - - IGUIElement::draw(); -} - - -//! Sets another skin independent font. -void CGUIStaticText::setOverrideFont(IGUIFont* font) -{ - if (OverrideFont == font) - return; - - if (OverrideFont) - OverrideFont->drop(); - - OverrideFont = font; - - if (OverrideFont) - OverrideFont->grab(); - - breakText(); -} - - -IGUIFont * CGUIStaticText::getOverrideFont() const -{ - return OverrideFont; -} - - -//! Sets another color for the text. -void CGUIStaticText::setOverrideColor(video::SColor color) -{ - OverrideColor = color; - OverrideColorEnabled = true; -} - - -//! Sets another color for the text. -void CGUIStaticText::setBackgroundColor(video::SColor color) -{ - BGColor = color; - Background = true; -} - - -//! Sets whether to draw the background -void CGUIStaticText::setDrawBackground(bool draw) -{ - Background = draw; -} - - -//! Sets whether to draw the border -void CGUIStaticText::setDrawBorder(bool draw) -{ - Border = draw; -} - - -void CGUIStaticText::setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical) -{ - HAlign = horizontal; - VAlign = vertical; -} - - -video::SColor const& CGUIStaticText::getOverrideColor() const -{ - return OverrideColor; -} - - -//! Sets if the static text should use the overide color or the -//! color in the gui skin. -void CGUIStaticText::enableOverrideColor(bool enable) -{ - OverrideColorEnabled = enable; -} - - -bool CGUIStaticText::isOverrideColorEnabled() const -{ - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return OverrideColorEnabled; -} - - -//! Enables or disables word wrap for using the static text as -//! multiline text control. -void CGUIStaticText::setWordWrap(bool enable) -{ - WordWrap = enable; - breakText(); -} - - -bool CGUIStaticText::isWordWrapEnabled() const -{ - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return WordWrap; -} - - -//! Breaks the single text line. -void CGUIStaticText::breakText() -{ - IGUISkin* skin = Environment->getSkin(); - - if (!WordWrap || !skin) - return; - - BrokenText.clear(); - - IGUIFont* font = OverrideFont; - if (!OverrideFont) - font = skin->getFont(); - - if (!font) - return; - - LastBreakFont = font; - - core::stringw line; - core::stringw word; - core::stringw whitespace; - s32 size = Text.size(); - s32 length = 0; - s32 elWidth = RelativeRect.getWidth() - 6; - wchar_t c; - - for (s32 i=0; i<size; ++i) - { - c = Text[i]; - bool lineBreak = false; - - if (c == L'\r') // Mac or Windows breaks - { - lineBreak = true; - if (Text[i+1] == L'\n') // Windows breaks - { - Text.erase(i+1); - --size; - } - c = '\0'; - } - else if (c == L'\n') // Unix breaks - { - lineBreak = true; - c = '\0'; - } - - if (c == L' ' || c == 0 || i == (size-1)) - { - if (word.size()) - { - // here comes the next whitespace, look if - // we can break the last word to the next line. - s32 whitelgth = font->getDimension(whitespace.c_str()).Width; - s32 worldlgth = font->getDimension(word.c_str()).Width; - - if (length + worldlgth + whitelgth > elWidth) - { - // break to next line - length = worldlgth; - BrokenText.push_back(line); - line = word; - } - else - { - // add word to line - line += whitespace; - line += word; - length += whitelgth + worldlgth; - } - - word = L""; - whitespace = L""; - } - - whitespace += c; - - // compute line break - if (lineBreak) - { - line += whitespace; - line += word; - BrokenText.push_back(line); - line = L""; - word = L""; - whitespace = L""; - length = 0; - } - } - else - { - // yippee this is a word.. - word += c; - } - } - - line += whitespace; - line += word; - BrokenText.push_back(line); -} - - -//! Sets the new caption of this element. -void CGUIStaticText::setText(const wchar_t* text) -{ - IGUIElement::setText(text); - breakText(); -} - - -void CGUIStaticText::updateAbsolutePosition() -{ - IGUIElement::updateAbsolutePosition(); - breakText(); -} - - -//! Returns the height of the text in pixels when it is drawn. -s32 CGUIStaticText::getTextHeight() const -{ - IGUISkin* skin = Environment->getSkin(); - - if (!skin) - return 0; - - IGUIFont* font = OverrideFont; - if (!OverrideFont) - font = skin->getFont(); - - if (!font) - return 0; - - s32 height = font->getDimension(L"A").Height + font->getKerningHeight(); - - if (WordWrap) - height *= BrokenText.size(); - - return height; -} - - -s32 CGUIStaticText::getTextWidth() const -{ - IGUIFont * font = OverrideFont; - - if(!OverrideFont) - { - IGUISkin * skin = Environment->getSkin(); - if(skin) - font = skin->getFont(); - } - - if(!font) - return 0; - - if(WordWrap) - { - s32 widest = 0; - - for(u32 line = 0; line < BrokenText.size(); ++line) - { - s32 width = font->getDimension(BrokenText[line].c_str()).Width; - - if(width > widest) - widest = width; - } - - return widest; - } - else - { - return font->getDimension(Text.c_str()).Width; - } -} - - -//! Writes attributes of the element. -//! Implement this to expose the attributes of your element for -//! scripting languages, editors, debuggers or xml serialization purposes. -void CGUIStaticText::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const -{ - IGUIStaticText::serializeAttributes(out,options); - - out->addBool ("Border", Border); - out->addBool ("OverrideColorEnabled",OverrideColorEnabled); - out->addBool ("WordWrap", WordWrap); - out->addBool ("Background", Background); - out->addColor ("OverrideColor", OverrideColor); - out->addEnum ("HTextAlign", HAlign, GUIAlignmentNames); - out->addEnum ("VTextAlign", VAlign, GUIAlignmentNames); - - // out->addFont ("OverrideFont", OverrideFont); -} - - -//! Reads attributes of the element -void CGUIStaticText::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) -{ - IGUIStaticText::deserializeAttributes(in,options); - - Border = in->getAttributeAsBool("Border"); - OverrideColor = in->getAttributeAsColor("OverrideColor"); - - enableOverrideColor(in->getAttributeAsBool("OverrideColorEnabled")); - setWordWrap(in->getAttributeAsBool("WordWrap")); - Background = in->getAttributeAsBool("Background"); - - setTextAlignment( (EGUI_ALIGNMENT) in->getAttributeAsEnumeration("HTextAlign", GUIAlignmentNames), - (EGUI_ALIGNMENT) in->getAttributeAsEnumeration("VTextAlign", GUIAlignmentNames)); - - // OverrideFont = in->getAttributeAsFont("OverrideFont"); -} - - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - diff --git a/irrlicht-1.6/source/Irrlicht/CGUIStaticText.h b/irrlicht-1.6/source/Irrlicht/CGUIStaticText.h deleted file mode 100644 index ec37fa295..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIStaticText.h +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_STATIC_TEXT_H_INCLUDED__ -#define __C_GUI_STATIC_TEXT_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUIStaticText.h" -#include "irrArray.h" - -namespace irr -{ -namespace gui -{ - class CGUIStaticText : public IGUIStaticText - { - public: - - //! constructor - CGUIStaticText(const wchar_t* text, bool border, IGUIEnvironment* environment, - IGUIElement* parent, s32 id, const core::rect<s32>& rectangle, - bool background = false); - - //! destructor - virtual ~CGUIStaticText(); - - //! draws the element and its children - virtual void draw(); - - //! Sets another skin independent font. - virtual void setOverrideFont(IGUIFont* font=0); - - //! Gets the override font (if any) - virtual IGUIFont * getOverrideFont() const; - - //! Sets another color for the text. - virtual void setOverrideColor(video::SColor color); - - //! Sets another color for the background. - virtual void setBackgroundColor(video::SColor color); - - //! Sets whether to draw the background - virtual void setDrawBackground(bool draw); - - //! Sets whether to draw the border - virtual void setDrawBorder(bool draw); - - //! Sets alignment mode for text - virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical); - - //! Gets the override color - virtual video::SColor const & getOverrideColor() const; - - //! Sets if the static text should use the overide color or the - //! color in the gui skin. - virtual void enableOverrideColor(bool enable); - - //! Checks if an override color is enabled - virtual bool isOverrideColorEnabled() const; - - //! Enables or disables word wrap for using the static text as - //! multiline text control. - virtual void setWordWrap(bool enable); - - //! Checks if word wrap is enabled - virtual bool isWordWrapEnabled() const; - - //! Sets the new caption of this element. - virtual void setText(const wchar_t* text); - - //! Returns the height of the text in pixels when it is drawn. - virtual s32 getTextHeight() const; - - //! Returns the width of the current text, in the current font - virtual s32 getTextWidth() const; - - //! Updates the absolute position, splits text if word wrap is enabled - virtual void updateAbsolutePosition(); - - //! Writes attributes of the element. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; - - //! Reads attributes of the element - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - - private: - - //! Breaks the single text line. - void breakText(); - - EGUI_ALIGNMENT HAlign, VAlign; - bool Border; - bool OverrideColorEnabled; - bool WordWrap; - bool Background; - - video::SColor OverrideColor, BGColor; - gui::IGUIFont* OverrideFont; - gui::IGUIFont* LastBreakFont; // stored because: if skin changes, line break must be recalculated. - - core::array< core::stringw > BrokenText; - }; - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CGUITabControl.cpp b/irrlicht-1.6/source/Irrlicht/CGUITabControl.cpp deleted file mode 100644 index ae2c1966b..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUITabControl.cpp +++ /dev/null @@ -1,923 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUITabControl.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "CGUIButton.h" -#include "IGUISkin.h" -#include "IGUIEnvironment.h" -#include "IGUIFont.h" -#include "IVideoDriver.h" -#include "rect.h" -#include "os.h" - -namespace irr -{ -namespace gui -{ - -// ------------------------------------------------------------------ -// Tab -// ------------------------------------------------------------------ - -//! constructor -CGUITab::CGUITab(s32 number, IGUIEnvironment* environment, - IGUIElement* parent, const core::rect<s32>& rectangle, - s32 id) - : IGUITab(environment, parent, id, rectangle), Number(number), - BackColor(0,0,0,0), TextColor(255,0,0,0), - DrawBackground(false) -{ - #ifdef _DEBUG - setDebugName("CGUITab"); - #endif - - const IGUISkin* const skin = environment->getSkin(); - if (skin) - TextColor = skin->getColor(EGDC_BUTTON_TEXT); -} - - -//! Returns number of tab in tabcontrol. Can be accessed -//! later IGUITabControl::getTab() by this number. -s32 CGUITab::getNumber() const -{ - return Number; -} - - -//! Sets the number -void CGUITab::setNumber(s32 n) -{ - Number = n; -} - - -//! draws the element and its children -void CGUITab::draw() -{ - if (!IsVisible) - return; - - IGUISkin *skin = Environment->getSkin(); - - if (skin && DrawBackground) - skin->draw2DRectangle(this, BackColor, AbsoluteRect, &AbsoluteClippingRect); - - IGUIElement::draw(); -} - - -//! sets if the tab should draw its background -void CGUITab::setDrawBackground(bool draw) -{ - DrawBackground = draw; -} - - -//! sets the color of the background, if it should be drawn. -void CGUITab::setBackgroundColor(video::SColor c) -{ - BackColor = c; -} - - -//! sets the color of the text -void CGUITab::setTextColor(video::SColor c) -{ - TextColor = c; -} - - -video::SColor CGUITab::getTextColor() const -{ - return TextColor; -} - - -//! returns true if the tab is drawing its background, false if not -bool CGUITab::isDrawingBackground() const -{ - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return DrawBackground; -} - - -//! returns the color of the background -video::SColor CGUITab::getBackgroundColor() const -{ - return BackColor; -} - - -//! Writes attributes of the element. -void CGUITab::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const -{ - IGUITab::serializeAttributes(out,options); - - out->addInt ("TabNumber", Number); - out->addBool ("DrawBackground", DrawBackground); - out->addColor ("BackColor", BackColor); - out->addColor ("TextColor", TextColor); - -} - - -//! Reads attributes of the element -void CGUITab::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) -{ - IGUITab::deserializeAttributes(in,options); - - setNumber(in->getAttributeAsInt("TabNumber")); - setDrawBackground(in->getAttributeAsBool("DrawBackground")); - setBackgroundColor(in->getAttributeAsColor("BackColor")); - setTextColor(in->getAttributeAsColor("TextColor")); - - if (Parent && Parent->getType() == EGUIET_TAB_CONTROL) - { - ((CGUITabControl*)Parent)->addTab(this); - if (isVisible()) - ((CGUITabControl*)Parent)->setActiveTab(this); - } -} - - -// ------------------------------------------------------------------ -// Tabcontrol -// ------------------------------------------------------------------ - -//! constructor -CGUITabControl::CGUITabControl(IGUIEnvironment* environment, - IGUIElement* parent, const core::rect<s32>& rectangle, - bool fillbackground, bool border, s32 id) - : IGUITabControl(environment, parent, id, rectangle), ActiveTab(-1), - Border(border), FillBackground(fillbackground), ScrollControl(false), TabHeight(0), VerticalAlignment(EGUIA_UPPERLEFT), - UpButton(0), DownButton(0), TabMaxWidth(0), CurrentScrollTabIndex(0), TabExtraWidth(20) -{ - #ifdef _DEBUG - setDebugName("CGUITabControl"); - #endif - - video::SColor color(255,255,255,255); - IGUISkin* skin = Environment->getSkin(); - IGUISpriteBank* sprites = 0; - - TabHeight = 32; - - if (skin) - { - sprites = skin->getSpriteBank(); - color = skin->getColor(EGDC_WINDOW_SYMBOL); - TabHeight = skin->getSize(gui::EGDS_BUTTON_HEIGHT) + 2; - } - - UpButton = Environment->addButton(core::rect<s32>(0,0,10,10), this); - - if (UpButton) - { - UpButton->setSpriteBank(sprites); - UpButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_LEFT), color); - UpButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_LEFT), color); - UpButton->setVisible(false); - UpButton->setSubElement(true); - UpButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - UpButton->setOverrideFont(Environment->getBuiltInFont()); - UpButton->grab(); - } - - DownButton = Environment->addButton(core::rect<s32>(0,0,10,10), this); - - if (DownButton) - { - DownButton->setSpriteBank(sprites); - DownButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_RIGHT), color); - DownButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_RIGHT), color); - DownButton->setVisible(false); - DownButton->setSubElement(true); - DownButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - DownButton->setOverrideFont(Environment->getBuiltInFont()); - DownButton->grab(); - } - - setTabVerticalAlignment(EGUIA_UPPERLEFT); -} - - -//! destructor -CGUITabControl::~CGUITabControl() -{ - for (u32 i=0; i<Tabs.size(); ++i) - { - if (Tabs[i]) - Tabs[i]->drop(); - } - - if (UpButton) - UpButton->drop(); - - if (DownButton) - DownButton->drop(); -} - - -//! Adds a tab -IGUITab* CGUITabControl::addTab(const wchar_t* caption, s32 id) -{ - IGUISkin* skin = Environment->getSkin(); - if (!skin) - return 0; - - core::rect<s32> r; - if ( VerticalAlignment == EGUIA_UPPERLEFT ) - { - r.UpperLeftCorner.X = 1; - r.UpperLeftCorner.Y = TabHeight; - - r.LowerRightCorner.X = AbsoluteRect.getWidth()-1; - r.LowerRightCorner.Y = AbsoluteRect.getHeight()-1; - } - else - { - r.UpperLeftCorner.X = 1; - r.UpperLeftCorner.Y = 1; - - r.LowerRightCorner.X = AbsoluteRect.getWidth()-1; - r.LowerRightCorner.Y = AbsoluteRect.getHeight()-TabHeight; - } - - CGUITab* tab = new CGUITab(Tabs.size(), Environment, this, r, id); - - tab->setText(caption); - tab->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); - tab->setVisible(false); - Tabs.push_back(tab); - - if (ActiveTab == -1) - { - ActiveTab = 0; - tab->setVisible(true); - } - - recalculateScrollBar(); - - return tab; -} - - -//! adds a tab which has been created elsewhere -void CGUITabControl::addTab(CGUITab* tab) -{ - if (!tab) - return; - - // check if its already added - for (u32 i=0; i < Tabs.size(); ++i) - { - if (Tabs[i] == tab) - return; - } - - tab->grab(); - - if (tab->getNumber() == -1) - tab->setNumber((s32)Tabs.size()); - - while (tab->getNumber() >= (s32)Tabs.size()) - Tabs.push_back(0); - - if (Tabs[tab->getNumber()]) - { - Tabs.push_back(Tabs[tab->getNumber()]); - Tabs[Tabs.size()-1]->setNumber(Tabs.size()); - } - Tabs[tab->getNumber()] = tab; - - if (ActiveTab == -1) - ActiveTab = tab->getNumber(); - - - if (tab->getNumber() == ActiveTab) - { - setActiveTab(ActiveTab); - } -} - - -//! Returns amount of tabs in the tabcontrol -s32 CGUITabControl::getTabCount() const -{ - return Tabs.size(); -} - - -//! Returns a tab based on zero based index -IGUITab* CGUITabControl::getTab(s32 idx) const -{ - if ((u32)idx >= Tabs.size()) - return 0; - - return Tabs[idx]; -} - - -//! called if an event happened. -bool CGUITabControl::OnEvent(const SEvent& event) -{ - if (IsEnabled) - { - - switch(event.EventType) - { - case EET_GUI_EVENT: - switch(event.GUIEvent.EventType) - { - case EGET_BUTTON_CLICKED: - if (event.GUIEvent.Caller == UpButton) - { - scrollLeft(); - return true; - } - else if (event.GUIEvent.Caller == DownButton) - { - scrollRight(); - return true; - } - - break; - default: - break; - } - break; - case EET_MOUSE_INPUT_EVENT: - switch(event.MouseInput.Event) - { - case EMIE_LMOUSE_PRESSED_DOWN: - // todo: dragging tabs around - return true; - case EMIE_LMOUSE_LEFT_UP: - if (selectTab(core::position2d<s32>(event.MouseInput.X, event.MouseInput.Y))) - return true; - break; - default: - break; - } - break; - default: - break; - } - } - - return IGUIElement::OnEvent(event); -} - - -void CGUITabControl::scrollLeft() -{ - if ( CurrentScrollTabIndex > 0 ) - --CurrentScrollTabIndex; - recalculateScrollBar(); -} - - -void CGUITabControl::scrollRight() -{ - if ( CurrentScrollTabIndex < (s32)(Tabs.size()) - 1 ) - { - if ( needScrollControl(CurrentScrollTabIndex, true) ) - ++CurrentScrollTabIndex; - } - recalculateScrollBar(); -} - -s32 CGUITabControl::calcTabWidth(s32 pos, IGUIFont* font, const wchar_t* text, bool withScrollControl) -{ - if ( !font ) - return 0; - - s32 len = font->getDimension(text).Width + TabExtraWidth; - if ( TabMaxWidth > 0 && len > TabMaxWidth ) - len = TabMaxWidth; - - // check if we miss the place to draw the tab-button - if ( withScrollControl && ScrollControl && pos+len > UpButton->getAbsolutePosition().UpperLeftCorner.X - 2 ) - { - s32 tabMinWidth = font->getDimension(L"A").Width; - if ( TabExtraWidth > 0 && TabExtraWidth > tabMinWidth ) - tabMinWidth = TabExtraWidth; - - if ( ScrollControl && pos+tabMinWidth <= UpButton->getAbsolutePosition().UpperLeftCorner.X - 2 ) - { - len = UpButton->getAbsolutePosition().UpperLeftCorner.X - 2 - pos; - } - } - return len; -} - -bool CGUITabControl::needScrollControl(s32 startIndex, bool withScrollControl) -{ - if ( startIndex >= (s32)Tabs.size() ) - startIndex -= 1; - - if ( startIndex < 0 ) - startIndex = 0; - - IGUISkin* skin = Environment->getSkin(); - if (!skin) - return false; - - IGUIFont* font = skin->getFont(); - - core::rect<s32> frameRect(AbsoluteRect); - - if (Tabs.empty()) - return false; - - if (!font) - return false; - - s32 pos = frameRect.UpperLeftCorner.X + 2; - - for (s32 i=startIndex; i<(s32)Tabs.size(); ++i) - { - // get Text - const wchar_t* text = 0; - if (Tabs[i]) - text = Tabs[i]->getText(); - - // get text length - s32 len = calcTabWidth(pos, font, text, false); // always without withScrollControl here or len would be shortened - - frameRect.LowerRightCorner.X += len; - - frameRect.UpperLeftCorner.X = pos; - frameRect.LowerRightCorner.X = frameRect.UpperLeftCorner.X + len; - pos += len; - - if ( withScrollControl && pos > UpButton->getAbsolutePosition().UpperLeftCorner.X - 2) - return true; - - if ( !withScrollControl && pos > AbsoluteRect.LowerRightCorner.X ) - return true; - } - - return false; -} - - -bool CGUITabControl::selectTab(core::position2d<s32> p) -{ - IGUISkin* skin = Environment->getSkin(); - IGUIFont* font = skin->getFont(); - - core::rect<s32> frameRect(AbsoluteRect); - - if ( VerticalAlignment == EGUIA_UPPERLEFT ) - { - frameRect.UpperLeftCorner.Y += 2; - frameRect.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y + TabHeight; - } - else - { - frameRect.UpperLeftCorner.Y = frameRect.LowerRightCorner.Y - TabHeight; - } - - s32 pos = frameRect.UpperLeftCorner.X + 2; - - if (!frameRect.isPointInside(p)) - return false; - - for (s32 i=CurrentScrollTabIndex; i<(s32)Tabs.size(); ++i) - { - // get Text - const wchar_t* text = 0; - if (Tabs[i]) - text = Tabs[i]->getText(); - - // get text length - s32 len = calcTabWidth(pos, font, text, true); - if ( ScrollControl && pos+len > UpButton->getAbsolutePosition().UpperLeftCorner.X - 2 ) - return false; - - frameRect.UpperLeftCorner.X = pos; - frameRect.LowerRightCorner.X = frameRect.UpperLeftCorner.X + len; - - pos += len; - - if (frameRect.isPointInside(p)) - { - setActiveTab(i); - return true; - } - } - return false; -} - - -//! draws the element and its children -void CGUITabControl::draw() -{ - if (!IsVisible) - return; - - IGUISkin* skin = Environment->getSkin(); - if (!skin) - return; - - IGUIFont* font = skin->getFont(); - video::IVideoDriver* driver = Environment->getVideoDriver(); - - core::rect<s32> frameRect(AbsoluteRect); - - if (Tabs.empty()) - driver->draw2DRectangle(skin->getColor(EGDC_3D_HIGH_LIGHT), frameRect, &AbsoluteClippingRect); - - if (!font) - return; - - if ( VerticalAlignment == EGUIA_UPPERLEFT ) - { - frameRect.UpperLeftCorner.Y += 2; - frameRect.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y + TabHeight; - } - else - { - frameRect.UpperLeftCorner.Y = frameRect.LowerRightCorner.Y - TabHeight - 1; - frameRect.LowerRightCorner.Y -= 2; - } - - core::rect<s32> tr; - s32 pos = frameRect.UpperLeftCorner.X + 2; - - bool needLeftScroll = CurrentScrollTabIndex > 0; - bool needRightScroll = false; - - // left and right pos of the active tab - s32 left = 0; - s32 right = 0; - - //const wchar_t* activetext = 0; - CGUITab *activeTab = 0; - - for (u32 i=CurrentScrollTabIndex; i<Tabs.size(); ++i) - { - // get Text - const wchar_t* text = 0; - if (Tabs[i]) - text = Tabs[i]->getText(); - - // get text length - s32 len = calcTabWidth(pos, font, text, true); - if ( ScrollControl && pos+len > UpButton->getAbsolutePosition().UpperLeftCorner.X - 2 ) - { - needRightScroll = true; - break; - } - - frameRect.LowerRightCorner.X += len; - frameRect.UpperLeftCorner.X = pos; - frameRect.LowerRightCorner.X = frameRect.UpperLeftCorner.X + len; - - pos += len; - - if ((s32)i == ActiveTab) - { - left = frameRect.UpperLeftCorner.X; - right = frameRect.LowerRightCorner.X; - //activetext = text; - activeTab = Tabs[i]; - } - else - { - skin->draw3DTabButton(this, false, frameRect, &AbsoluteClippingRect, VerticalAlignment); - - // draw text - font->draw(text, frameRect, Tabs[i]->getTextColor(), - true, true, &frameRect); - } - } - - // draw active tab - if (left != 0 && right != 0 && activeTab != 0) - { - // draw upper highlight frame - if ( VerticalAlignment == EGUIA_UPPERLEFT ) - { - frameRect.UpperLeftCorner.X = left-2; - frameRect.LowerRightCorner.X = right+2; - frameRect.UpperLeftCorner.Y -= 2; - - skin->draw3DTabButton(this, true, frameRect, &AbsoluteClippingRect, VerticalAlignment); - - // draw text - font->draw(activeTab->getText(), frameRect, activeTab->getTextColor(), - true, true, &frameRect); - - tr.UpperLeftCorner.X = AbsoluteRect.UpperLeftCorner.X; - tr.LowerRightCorner.X = left - 1; - tr.UpperLeftCorner.Y = frameRect.LowerRightCorner.Y - 1; - tr.LowerRightCorner.Y = frameRect.LowerRightCorner.Y; - driver->draw2DRectangle(skin->getColor(EGDC_3D_HIGH_LIGHT), tr, &AbsoluteClippingRect); - - tr.UpperLeftCorner.X = right; - tr.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X; - driver->draw2DRectangle(skin->getColor(EGDC_3D_HIGH_LIGHT), tr, &AbsoluteClippingRect); - } - else - { - - frameRect.UpperLeftCorner.X = left-2; - frameRect.LowerRightCorner.X = right+2; - frameRect.LowerRightCorner.Y += 2; - - skin->draw3DTabButton(this, true, frameRect, &AbsoluteClippingRect, VerticalAlignment); - - // draw text - font->draw(activeTab->getText(), frameRect, activeTab->getTextColor(), - true, true, &frameRect); - - tr.UpperLeftCorner.X = AbsoluteRect.UpperLeftCorner.X; - tr.LowerRightCorner.X = left - 1; - tr.UpperLeftCorner.Y = frameRect.UpperLeftCorner.Y - 1; - tr.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y; - driver->draw2DRectangle(skin->getColor(EGDC_3D_DARK_SHADOW), tr, &AbsoluteClippingRect); - - tr.UpperLeftCorner.X = right; - tr.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X; - driver->draw2DRectangle(skin->getColor(EGDC_3D_DARK_SHADOW), tr, &AbsoluteClippingRect); - } - } - else - { - if ( VerticalAlignment == EGUIA_UPPERLEFT ) - { - tr.UpperLeftCorner.X = AbsoluteRect.UpperLeftCorner.X; - tr.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X; - tr.UpperLeftCorner.Y = frameRect.LowerRightCorner.Y - 1; - tr.LowerRightCorner.Y = frameRect.LowerRightCorner.Y; - driver->draw2DRectangle(skin->getColor(EGDC_3D_HIGH_LIGHT), tr, &AbsoluteClippingRect); - } - else - { - tr.UpperLeftCorner.X = AbsoluteRect.UpperLeftCorner.X; - tr.LowerRightCorner.X = 1000; - tr.UpperLeftCorner.Y = frameRect.UpperLeftCorner.Y - 1; - tr.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y; - driver->draw2DRectangle(skin->getColor(EGDC_3D_DARK_SHADOW), tr, &AbsoluteClippingRect); - } - } - - skin->draw3DTabBody(this, Border, FillBackground, AbsoluteRect, &AbsoluteClippingRect, TabHeight, VerticalAlignment); - - // enable scrollcontrols on need - if ( UpButton ) - UpButton->setEnabled(needLeftScroll); - if ( DownButton ) - DownButton->setEnabled(needRightScroll); - - IGUIElement::draw(); -} - - -//! Set the height of the tabs -void CGUITabControl::setTabHeight( s32 height ) -{ - if ( height < 0 ) - height = 0; - - TabHeight = height; - - recalculateScrollBar(); -} - - -//! Get the height of the tabs -s32 CGUITabControl::getTabHeight() const -{ - return TabHeight; -} - -//! set the maximal width of a tab. Per default width is 0 which means "no width restriction". -void CGUITabControl::setTabMaxWidth(s32 width ) -{ - TabMaxWidth = width; -} - -//! get the maximal width of a tab -s32 CGUITabControl::getTabMaxWidth() const -{ - return TabMaxWidth; -} - - -//! Set the extra width added to tabs on each side of the text -void CGUITabControl::setTabExtraWidth( s32 extraWidth ) -{ - if ( extraWidth < 0 ) - extraWidth = 0; - - TabExtraWidth = extraWidth; - - recalculateScrollBar(); -} - - -//! Get the extra width added to tabs on each side of the text -s32 CGUITabControl::getTabExtraWidth() const -{ - return TabExtraWidth; -} - - -void CGUITabControl::recalculateScrollBar() -{ - if (!UpButton || !DownButton) - return; - - ScrollControl = needScrollControl() || CurrentScrollTabIndex > 0; - - if (ScrollControl) - { - UpButton->setVisible( true ); - DownButton->setVisible( true ); - } - else - { - UpButton->setVisible( false ); - DownButton->setVisible( false ); - } - - bringToFront( UpButton ); - bringToFront( DownButton ); -} - - -//! Set the alignment of the tabs -void CGUITabControl::setTabVerticalAlignment( EGUI_ALIGNMENT alignment ) -{ - VerticalAlignment = alignment; - - IGUISkin* skin = Environment->getSkin(); - s32 ButtonSize = 16; - if (skin) - { - ButtonSize = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH); - if (ButtonSize > TabHeight) - ButtonSize = TabHeight; - } - - s32 ButtonX = RelativeRect.getWidth() - (s32)(2.5f*(f32)ButtonSize) - 1; - s32 ButtonY = 0; - - if (VerticalAlignment == EGUIA_UPPERLEFT) - { - ButtonY = (TabHeight / 2) - (ButtonSize / 2); - UpButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - DownButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - } - else - { - ButtonY = RelativeRect.getHeight() - (TabHeight / 2) - (ButtonSize / 2); - UpButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT); - DownButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT); - } - - UpButton->setRelativePosition(core::rect<s32>(ButtonX, ButtonY, ButtonX+ButtonSize, ButtonY+ButtonSize)); - ButtonX += ButtonSize + 1; - DownButton->setRelativePosition(core::rect<s32>(ButtonX, ButtonY, ButtonX+ButtonSize, ButtonY+ButtonSize)); - - recalculateScrollBar(); -} - - -//! Get the alignment of the tabs -EGUI_ALIGNMENT CGUITabControl::getTabVerticalAlignment() const -{ - return VerticalAlignment; -} - - -//! Returns which tab is currently active -s32 CGUITabControl::getActiveTab() const -{ - return ActiveTab; -} - - -//! Brings a tab to front. -bool CGUITabControl::setActiveTab(s32 idx) -{ - if ((u32)idx >= Tabs.size()) - return false; - - bool changed = (ActiveTab != idx); - - ActiveTab = idx; - - for (s32 i=0; i<(s32)Tabs.size(); ++i) - if (Tabs[i]) - Tabs[i]->setVisible( i == ActiveTab ); - - if (changed) - { - SEvent event; - event.EventType = EET_GUI_EVENT; - event.GUIEvent.Caller = this; - event.GUIEvent.Element = 0; - event.GUIEvent.EventType = EGET_TAB_CHANGED; - Parent->OnEvent(event); - } - - return true; -} - - -bool CGUITabControl::setActiveTab(IGUIElement *tab) -{ - for (s32 i=0; i<(s32)Tabs.size(); ++i) - if (Tabs[i] == tab) - return setActiveTab(i); - return false; -} - - -//! Removes a child. -void CGUITabControl::removeChild(IGUIElement* child) -{ - bool isTab = false; - - u32 i=0; - // check if it is a tab - while (i<Tabs.size()) - { - if (Tabs[i] == child) - { - Tabs[i]->drop(); - Tabs.erase(i); - isTab = true; - } - else - ++i; - } - - // reassign numbers - if (isTab) - { - for (i=0; i<Tabs.size(); ++i) - if (Tabs[i]) - Tabs[i]->setNumber(i); - } - - // remove real element - IGUIElement::removeChild(child); - - recalculateScrollBar(); -} - - -//! Update the position of the element, decides scroll button status -void CGUITabControl::updateAbsolutePosition() -{ - IGUIElement::updateAbsolutePosition(); - recalculateScrollBar(); -} - - -//! Writes attributes of the element. -void CGUITabControl::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const -{ - IGUITabControl::serializeAttributes(out,options); - - out->addInt ("ActiveTab", ActiveTab); - out->addBool("Border", Border); - out->addBool("FillBackground", FillBackground); - out->addInt ("TabHeight", TabHeight); - out->addInt ("TabMaxWidth", TabMaxWidth); - out->addEnum("TabVerticalAlignment", s32(VerticalAlignment), GUIAlignmentNames); -} - - -//! Reads attributes of the element -void CGUITabControl::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) -{ - Border = in->getAttributeAsBool("Border"); - FillBackground = in->getAttributeAsBool("FillBackground"); - - ActiveTab = -1; - - setTabHeight(in->getAttributeAsInt("TabHeight")); - TabMaxWidth = in->getAttributeAsInt("TabMaxWidth"); - - IGUITabControl::deserializeAttributes(in,options); - - setActiveTab(in->getAttributeAsInt("ActiveTab")); - setTabVerticalAlignment( static_cast<EGUI_ALIGNMENT>(in->getAttributeAsEnumeration("TabVerticalAlignment" , GUIAlignmentNames)) ); -} - - -} // end namespace irr -} // end namespace gui - -#endif // _IRR_COMPILE_WITH_GUI_ - diff --git a/irrlicht-1.6/source/Irrlicht/CGUITabControl.h b/irrlicht-1.6/source/Irrlicht/CGUITabControl.h deleted file mode 100644 index 5e24cc9a1..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUITabControl.h +++ /dev/null @@ -1,185 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_TAB_CONTROL_H_INCLUDED__ -#define __C_GUI_TAB_CONTROL_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUITabControl.h" -#include "irrArray.h" -#include "IGUISkin.h" - -namespace irr -{ -namespace gui -{ - class CGUITabControl; - class IGUIButton; - - // A tab, onto which other gui elements could be added. - class CGUITab : public IGUITab - { - public: - - //! constructor - CGUITab(s32 number, IGUIEnvironment* environment, - IGUIElement* parent, const core::rect<s32>& rectangle, - s32 id); - - //! destructor - //virtual ~CGUITab(); - - //! Returns number of this tab in tabcontrol. Can be accessed - //! later IGUITabControl::getTab() by this number. - virtual s32 getNumber() const; - - //! Sets the number - virtual void setNumber(s32 n); - - //! draws the element and its children - virtual void draw(); - - //! sets if the tab should draw its background - virtual void setDrawBackground(bool draw=true); - - //! sets the color of the background, if it should be drawn. - virtual void setBackgroundColor(video::SColor c); - - //! sets the color of the text - virtual void setTextColor(video::SColor c); - - //! returns true if the tab is drawing its background, false if not - virtual bool isDrawingBackground() const; - - //! returns the color of the background - virtual video::SColor getBackgroundColor() const; - - virtual video::SColor getTextColor() const; - - //! Writes attributes of the element. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; - - //! Reads attributes of the element - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - - - private: - - s32 Number; - video::SColor BackColor; - video::SColor TextColor; - bool DrawBackground; - }; - - - //! A standard tab control - class CGUITabControl : public IGUITabControl - { - public: - - //! destructor - CGUITabControl(IGUIEnvironment* environment, - IGUIElement* parent, const core::rect<s32>& rectangle, - bool fillbackground=true, bool border=true, s32 id=-1); - - //! destructor - virtual ~CGUITabControl(); - - //! Adds a tab - virtual IGUITab* addTab(const wchar_t* caption, s32 id=-1); - - //! Adds a tab that has already been created - virtual void addTab(CGUITab* tab); - - //! Returns amount of tabs in the tabcontrol - virtual s32 getTabCount() const; - - //! Returns a tab based on zero based index - virtual IGUITab* getTab(s32 idx) const; - - //! Brings a tab to front. - virtual bool setActiveTab(s32 idx); - - //! Brings a tab to front. - virtual bool setActiveTab(IGUIElement *tab); - - //! Returns which tab is currently active - virtual s32 getActiveTab() const; - - //! called if an event happened. - virtual bool OnEvent(const SEvent& event); - - //! draws the element and its children - virtual void draw(); - - //! Removes a child. - virtual void removeChild(IGUIElement* child); - - //! Writes attributes of the element. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; - //! Set the height of the tabs - virtual void setTabHeight( s32 height ); - - //! Reads attributes of the element - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - - //! Get the height of the tabs - virtual s32 getTabHeight() const; - - //! set the maximal width of a tab. Per default width is 0 which means "no width restriction". - virtual void setTabMaxWidth(s32 width ); - - //! get the maximal width of a tab - virtual s32 getTabMaxWidth() const; - - //! Set the alignment of the tabs - //! note: EGUIA_CENTER is not an option - virtual void setTabVerticalAlignment( gui::EGUI_ALIGNMENT alignment ); - - //! Get the alignment of the tabs - virtual gui::EGUI_ALIGNMENT getTabVerticalAlignment() const; - - //! Set the extra width added to tabs on each side of the text - virtual void setTabExtraWidth( s32 extraWidth ); - - //! Get the extra width added to tabs on each side of the text - virtual s32 getTabExtraWidth() const; - - //! Update the position of the element, decides scroll button status - virtual void updateAbsolutePosition(); - - private: - - bool selectTab(core::position2d<s32> p); - void scrollLeft(); - void scrollRight(); - bool needScrollControl( s32 startIndex=0, bool withScrollControl=false ); - s32 calcTabWidth(s32 pos, IGUIFont* font, const wchar_t* text, bool withScrollControl ); - - void recalculateScrollBar(); - - core::array<CGUITab*> Tabs; - s32 ActiveTab; - bool Border; - bool FillBackground; - bool ScrollControl; - s32 TabHeight; - gui::EGUI_ALIGNMENT VerticalAlignment; - IGUIButton* UpButton; - IGUIButton* DownButton; - s32 TabMaxWidth; - s32 CurrentScrollTabIndex; - s32 TabExtraWidth; - }; - - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CGUITable.cpp b/irrlicht-1.6/source/Irrlicht/CGUITable.cpp deleted file mode 100644 index 30f6be964..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUITable.cpp +++ /dev/null @@ -1,1246 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -// 07.10.2005 - Multicolor-Listbox added by A. Buschhueter (Acki) -// A_Buschhueter@gmx.de - -#include "CGUITable.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUISkin.h" -#include "IGUIEnvironment.h" -#include "IVideoDriver.h" -#include "IGUIFont.h" -#include "CGUIScrollBar.h" -#include "os.h" - -#define ARROW_PAD 15 - -namespace irr -{ -namespace gui -{ - -//! constructor -CGUITable::CGUITable(IGUIEnvironment* environment, IGUIElement* parent, - s32 id, const core::rect<s32>& rectangle, bool clip, - bool drawBack, bool moveOverSelect) -: IGUITable(environment, parent, id, rectangle), Font(0), - VerticalScrollBar(0), HorizontalScrollBar(0), - Clip(clip), DrawBack(drawBack), MoveOverSelect(moveOverSelect), - Selecting(false), CurrentResizedColumn(-1), ResizeStart(0), ResizableColumns(true), - ItemHeight(0), TotalItemHeight(0), TotalItemWidth(0), Selected(-1), - CellHeightPadding(2), CellWidthPadding(5), ActiveTab(-1), - CurrentOrdering(EGOM_NONE), DrawFlags(EGTDF_ROWS | EGTDF_COLUMNS | EGTDF_ACTIVE_ROW ) -{ - #ifdef _DEBUG - setDebugName("CGUITable"); - #endif - - VerticalScrollBar = Environment->addScrollBar(false, core::rect<s32>(0, 0, 100, 100), this, -1); - if (VerticalScrollBar) - { - VerticalScrollBar->grab(); - VerticalScrollBar->setNotClipped(false); - VerticalScrollBar->setSubElement(true); - } - - HorizontalScrollBar = Environment->addScrollBar(true, core::rect<s32>(0, 0, 100, 100), this, -1); - if ( HorizontalScrollBar ) - { - HorizontalScrollBar->grab(); - HorizontalScrollBar->setNotClipped(false); - HorizontalScrollBar->setSubElement(true); - } - - refreshControls(); -} - - -//! destructor -CGUITable::~CGUITable() -{ - if (VerticalScrollBar) - VerticalScrollBar->drop(); - if ( HorizontalScrollBar ) - HorizontalScrollBar->drop(); - - if (Font) - Font->drop(); -} - - -void CGUITable::addColumn(const wchar_t* caption, s32 columnIndex) -{ - Column tabHeader; - tabHeader.Name = caption; - tabHeader.Width = Font->getDimension(caption).Width + (CellWidthPadding * 2) + ARROW_PAD; - tabHeader.OrderingMode = EGCO_NONE; - - IGUISkin* skin = Environment->getSkin(); - if (skin) - { - tabHeader.TextColor = skin->getColor(EGDC_BUTTON_TEXT); - } - - if ( columnIndex < 0 || columnIndex >= (s32)Columns.size() ) - { - Columns.push_back(tabHeader); - for ( u32 i=0; i < Rows.size(); ++i ) - { - Cell cell; - Rows[i].Items.push_back(cell); - } - } - else - { - Columns.insert(tabHeader, columnIndex); - for ( u32 i=0; i < Rows.size(); ++i ) - { - Cell cell; - Rows[i].Items.insert(cell, columnIndex); - } - } - - if (ActiveTab == -1) - ActiveTab = 0; - - recalculateWidths(); -} - - -//! remove a column from the table -void CGUITable::removeColumn(u32 columnIndex) -{ - if ( columnIndex < Columns.size() ) - { - Columns.erase(columnIndex); - for ( u32 i=0; i < Rows.size(); ++i ) - { - Rows[i].Items.erase(columnIndex); - } - } - if ( (s32)columnIndex <= ActiveTab ) - ActiveTab = Columns.size() ? 0 : -1; - - recalculateWidths(); -} - - -s32 CGUITable::getColumnCount() const -{ - return Columns.size(); -} - - -s32 CGUITable::getRowCount() const -{ - return Rows.size(); -} - - -bool CGUITable::setActiveColumn(s32 idx, bool doOrder ) -{ - if (idx < 0 || idx >= (s32)Columns.size()) - return false; - - bool changed = (ActiveTab != idx); - - ActiveTab = idx; - if ( ActiveTab < 0 ) - return false; - - if ( doOrder ) - { - switch ( Columns[idx].OrderingMode ) - { - case EGCO_NONE: - CurrentOrdering = EGOM_NONE; - break; - - case EGCO_CUSTOM: - CurrentOrdering = EGOM_NONE; - if (Parent) - { - SEvent event; - event.EventType = EET_GUI_EVENT; - event.GUIEvent.Caller = this; - event.GUIEvent.EventType = EGET_TABLE_HEADER_CHANGED; - Parent->OnEvent(event); - } - - break; - - case EGCO_ASCENDING: - CurrentOrdering = EGOM_ASCENDING; - break; - - case EGCO_DESCENDING: - CurrentOrdering = EGOM_DESCENDING; - break; - - case EGCO_FLIP_ASCENDING_DESCENDING: - CurrentOrdering = EGOM_ASCENDING == CurrentOrdering ? EGOM_DESCENDING : EGOM_ASCENDING; - break; - default: - CurrentOrdering = EGOM_NONE; - } - - orderRows(getActiveColumn(), CurrentOrdering); - } - - if (changed) - { - SEvent event; - event.EventType = EET_GUI_EVENT; - event.GUIEvent.Caller = this; - event.GUIEvent.EventType = EGET_TABLE_HEADER_CHANGED; - Parent->OnEvent(event); - } - - return true; -} - - -s32 CGUITable::getActiveColumn() const -{ - return ActiveTab; -} - - -EGUI_ORDERING_MODE CGUITable::getActiveColumnOrdering() const -{ - return CurrentOrdering; -} - - -void CGUITable::setColumnWidth(u32 columnIndex, u32 width) -{ - if ( columnIndex < Columns.size() ) - { - const u32 MIN_WIDTH = Font->getDimension(Columns[columnIndex].Name.c_str() ).Width + (CellWidthPadding * 2); - if ( width < MIN_WIDTH ) - width = MIN_WIDTH; - - Columns[columnIndex].Width = width; - - for ( u32 i=0; i < Rows.size(); ++i ) - { - breakText( Rows[i].Items[columnIndex].Text, Rows[i].Items[columnIndex].BrokenText, Columns[columnIndex].Width ); - } - } - recalculateWidths(); -} - - -void CGUITable::setResizableColumns(bool resizable) -{ - ResizableColumns = resizable; -} - - -bool CGUITable::hasResizableColumns() const -{ - return ResizableColumns; -} - - -u32 CGUITable::addRow(u32 rowIndex) -{ - if ( rowIndex > Rows.size() ) - { - rowIndex = Rows.size(); - } - - Row row; - - if ( rowIndex == Rows.size() ) - Rows.push_back(row); - else - Rows.insert(row, rowIndex); - - Rows[rowIndex].Items.reallocate(Columns.size()); - for ( u32 i = 0 ; i < Columns.size() ; ++i ) - { - Rows[rowIndex].Items.push_back(Cell()); - } - - recalculateHeights(); - return rowIndex; -} - - -void CGUITable::removeRow(u32 rowIndex) -{ - if ( rowIndex > Rows.size() ) - return; - - Rows.erase( rowIndex ); - - if ( !(Selected < s32(Rows.size())) ) - Selected = Rows.size() - 1; - - recalculateHeights(); -} - - -//! adds an list item, returns id of item -void CGUITable::setCellText(u32 rowIndex, u32 columnIndex, const core::stringw& text) -{ - if ( rowIndex < Rows.size() && columnIndex < Columns.size() ) - { - Rows[rowIndex].Items[columnIndex].Text = text; - breakText( Rows[rowIndex].Items[columnIndex].Text, Rows[rowIndex].Items[columnIndex].BrokenText, Columns[columnIndex].Width ); - - IGUISkin* skin = Environment->getSkin(); - if ( skin ) - Rows[rowIndex].Items[columnIndex].Color = skin->getColor(EGDC_BUTTON_TEXT); - } -} - -void CGUITable::setCellText(u32 rowIndex, u32 columnIndex, const core::stringw& text, video::SColor color) -{ - if ( rowIndex < Rows.size() && columnIndex < Columns.size() ) - { - Rows[rowIndex].Items[columnIndex].Text = text; - breakText( Rows[rowIndex].Items[columnIndex].Text, Rows[rowIndex].Items[columnIndex].BrokenText, Columns[columnIndex].Width ); - Rows[rowIndex].Items[columnIndex].Color = color; - } -} - - -void CGUITable::setCellColor(u32 rowIndex, u32 columnIndex, video::SColor color) -{ - if ( rowIndex < Rows.size() && columnIndex < Columns.size() ) - { - Rows[rowIndex].Items[columnIndex].Color = color; - } -} - - -void CGUITable::setCellData(u32 rowIndex, u32 columnIndex, void *data) -{ - if ( rowIndex < Rows.size() && columnIndex < Columns.size() ) - { - Rows[rowIndex].Items[columnIndex].Data = data; - } -} - - -const wchar_t* CGUITable::getCellText(u32 rowIndex, u32 columnIndex ) const -{ - if ( rowIndex < Rows.size() && columnIndex < Columns.size() ) - { - return Rows[rowIndex].Items[columnIndex].Text.c_str(); - } - - return 0; -} - - -void* CGUITable::getCellData(u32 rowIndex, u32 columnIndex ) const -{ - if ( rowIndex < Rows.size() && columnIndex < Columns.size() ) - { - return Rows[rowIndex].Items[columnIndex].Data; - } - - return 0; -} - - -//! clears the list -void CGUITable::clear() -{ - Selected = -1; - Rows.clear(); - Columns.clear(); - - if (VerticalScrollBar) - VerticalScrollBar->setPos(0); - if ( HorizontalScrollBar ) - HorizontalScrollBar->setPos(0); - - recalculateHeights(); - recalculateWidths(); -} - - -void CGUITable::clearRows() -{ - Selected = -1; - Rows.clear(); - - if (VerticalScrollBar) - VerticalScrollBar->setPos(0); - - recalculateHeights(); -} - - -/*! -*/ -s32 CGUITable::getSelected() const -{ - return Selected; -} - -//! set wich row is currently selected -void CGUITable::setSelected( s32 index ) -{ - Selected = -1; - if ( index >= 0 && index < (s32) Rows.size() ) - Selected = index; -} - - -void CGUITable::recalculateWidths() -{ - TotalItemWidth=0; - for ( u32 i=0; i < Columns.size(); ++i ) - { - TotalItemWidth += Columns[i].Width; - } - checkScrollbars(); -} - - -void CGUITable::recalculateHeights() -{ - TotalItemHeight = 0; - IGUISkin* skin = Environment->getSkin(); - if (Font != skin->getFont()) - { - if (Font) - Font->drop(); - - Font = skin->getFont(); - - ItemHeight = 0; - - if(Font) - { - ItemHeight = Font->getDimension(L"A").Height + (CellHeightPadding * 2); - Font->grab(); - } - } - TotalItemHeight = ItemHeight * Rows.size(); // header is not counted, because we only want items - checkScrollbars(); -} - - -// automatic enabled/disabling and resizing of scrollbars -void CGUITable::checkScrollbars() -{ - IGUISkin* skin = Environment->getSkin(); - if ( !HorizontalScrollBar || !VerticalScrollBar || !skin) - return; - - s32 scrollBarSize = skin->getSize(EGDS_SCROLLBAR_SIZE); - bool wasHorizontalScrollBarVisible = HorizontalScrollBar->isVisible(); - bool wasVerticalScrollBarVisible = VerticalScrollBar->isVisible(); - HorizontalScrollBar->setVisible(false); - VerticalScrollBar->setVisible(false); - - // CAREFUL: near identical calculations for tableRect and clientClip are also done in draw - // area of table used for drawing without scrollbars - core::rect<s32> tableRect(AbsoluteRect); - tableRect.UpperLeftCorner.X += 1; - tableRect.UpperLeftCorner.Y += 1; - s32 headerBottom = tableRect.UpperLeftCorner.Y + ItemHeight; - - // area of for the items (without header and without scrollbars) - core::rect<s32> clientClip(tableRect); - clientClip.UpperLeftCorner.Y = headerBottom + 1; - - // needs horizontal scroll be visible? - if( TotalItemWidth > clientClip.getWidth() ) - { - clientClip.LowerRightCorner.Y -= scrollBarSize; - HorizontalScrollBar->setVisible(true); - HorizontalScrollBar->setMax(TotalItemWidth - clientClip.getWidth()); - } - - // needs vertical scroll be visible? - if( TotalItemHeight > clientClip.getHeight() ) - { - clientClip.LowerRightCorner.X -= scrollBarSize; - VerticalScrollBar->setVisible(true); - VerticalScrollBar->setMax(TotalItemHeight - clientClip.getHeight()); - - // check horizontal again because we have now smaller clientClip - if ( !HorizontalScrollBar->isVisible() ) - { - if( TotalItemWidth > clientClip.getWidth() ) - { - clientClip.LowerRightCorner.Y -= scrollBarSize; - HorizontalScrollBar->setVisible(true); - HorizontalScrollBar->setMax(TotalItemWidth - clientClip.getWidth()); - } - } - } - - // find the correct size for the vertical scrollbar - if ( VerticalScrollBar->isVisible() ) - { - if (!wasVerticalScrollBarVisible ) - VerticalScrollBar->setPos(0); - - if ( HorizontalScrollBar->isVisible() ) - { - VerticalScrollBar->setRelativePosition( - core::rect<s32>(RelativeRect.getWidth() - scrollBarSize, 1, - RelativeRect.getWidth()-1, RelativeRect.getHeight()-(1+scrollBarSize) ) ); - } - else - { - VerticalScrollBar->setRelativePosition( - core::rect<s32>(RelativeRect.getWidth() - scrollBarSize, 1, - RelativeRect.getWidth()-1, RelativeRect.getHeight()-1) ); - } - } - - // find the correct size for the horizontal scrollbar - if ( HorizontalScrollBar->isVisible() ) - { - if ( !wasHorizontalScrollBarVisible ) - HorizontalScrollBar->setPos(0); - - if ( VerticalScrollBar->isVisible() ) - { - HorizontalScrollBar->setRelativePosition( core::rect<s32>(1, RelativeRect.getHeight() - scrollBarSize, RelativeRect.getWidth()-(1+scrollBarSize), RelativeRect.getHeight()-1) ); - } - else - { - HorizontalScrollBar->setRelativePosition( core::rect<s32>(1, RelativeRect.getHeight() - scrollBarSize, RelativeRect.getWidth()-1, RelativeRect.getHeight()-1) ); - } - } -} - - -void CGUITable::refreshControls() -{ - updateAbsolutePosition(); - - if ( VerticalScrollBar ) - VerticalScrollBar->setVisible(false); - - if ( HorizontalScrollBar ) - HorizontalScrollBar->setVisible(false); - - recalculateHeights(); - recalculateWidths(); -} - - -//! called if an event happened. -bool CGUITable::OnEvent(const SEvent &event) -{ - if (IsEnabled) - { - - switch(event.EventType) - { - case EET_GUI_EVENT: - switch(event.GUIEvent.EventType) - { - case gui::EGET_SCROLL_BAR_CHANGED: - if (event.GUIEvent.Caller == VerticalScrollBar) - { - // current position will get read out in draw - return true; - } - if (event.GUIEvent.Caller == HorizontalScrollBar) - { - // current position will get read out in draw - return true; - } - break; - case gui::EGET_ELEMENT_FOCUS_LOST: - { - CurrentResizedColumn = -1; - Selecting = false; - } - break; - default: - break; - } - break; - case EET_MOUSE_INPUT_EVENT: - { - if ( !IsEnabled ) - return false; - - core::position2d<s32> p(event.MouseInput.X, event.MouseInput.Y); - - switch(event.MouseInput.Event) - { - case EMIE_MOUSE_WHEEL: - VerticalScrollBar->setPos(VerticalScrollBar->getPos() + (s32)event.MouseInput.Wheel*-10); - return true; - - case EMIE_LMOUSE_PRESSED_DOWN: - - if (Environment->hasFocus(this) && - VerticalScrollBar->isVisible() && - VerticalScrollBar->getAbsolutePosition().isPointInside(p) && - VerticalScrollBar->OnEvent(event)) - return true; - - if (Environment->hasFocus(this) && - HorizontalScrollBar->isVisible() && - HorizontalScrollBar->getAbsolutePosition().isPointInside(p) && - HorizontalScrollBar->OnEvent(event)) - return true; - - if ( dragColumnStart( event.MouseInput.X, event.MouseInput.Y ) ) - { - Environment->setFocus(this); - return true; - } - - if ( selectColumnHeader( event.MouseInput.X, event.MouseInput.Y ) ) - return true; - - Selecting = true; - Environment->setFocus(this); - return true; - - case EMIE_LMOUSE_LEFT_UP: - - CurrentResizedColumn = -1; - Selecting = false; - if (!getAbsolutePosition().isPointInside(p)) - { - Environment->removeFocus(this); - } - - if (Environment->hasFocus(this) && - VerticalScrollBar->isVisible() && - VerticalScrollBar->getAbsolutePosition().isPointInside(p) && - VerticalScrollBar->OnEvent(event)) - { - return true; - } - - if (Environment->hasFocus(this) && - HorizontalScrollBar->isVisible() && - HorizontalScrollBar->getAbsolutePosition().isPointInside(p) && - HorizontalScrollBar->OnEvent(event)) - { - return true; - } - - selectNew(event.MouseInput.Y); - return true; - - case EMIE_MOUSE_MOVED: - if ( CurrentResizedColumn >= 0 ) - { - if ( dragColumnUpdate(event.MouseInput.X) ) - { - return true; - } - } - if (Selecting || MoveOverSelect) - { - if (getAbsolutePosition().isPointInside(p)) - { - selectNew(event.MouseInput.Y); - return true; - } - } - break; - default: - break; - } - } - break; - default: - break; - } - } - - return IGUIElement::OnEvent(event); -} - - -void CGUITable::setColumnOrdering(u32 columnIndex, EGUI_COLUMN_ORDERING mode) -{ - if ( columnIndex < Columns.size() ) - Columns[columnIndex].OrderingMode = mode; -} - - -void CGUITable::swapRows(u32 rowIndexA, u32 rowIndexB) -{ - if ( rowIndexA >= Rows.size() ) - return; - - if ( rowIndexB >= Rows.size() ) - return; - - Row swap = Rows[rowIndexA]; - Rows[rowIndexA] = Rows[rowIndexB]; - Rows[rowIndexB] = swap; - - if ( Selected == s32(rowIndexA) ) - Selected = rowIndexB; - else if( Selected == s32(rowIndexB) ) - Selected = rowIndexA; - -} - - -bool CGUITable::dragColumnStart(s32 xpos, s32 ypos) -{ - if ( !ResizableColumns ) - return false; - - if ( ypos > ( AbsoluteRect.UpperLeftCorner.Y + ItemHeight ) ) - return false; - - const s32 CLICK_AREA = 12; // to left and right of line which can be dragged - s32 pos = AbsoluteRect.UpperLeftCorner.X+1; - - if ( HorizontalScrollBar && HorizontalScrollBar->isVisible() ) - pos -= HorizontalScrollBar->getPos(); - - pos += TotalItemWidth; - - // have to search from the right as otherwise lines could no longer be resized when a column width is 0 - for ( s32 i = (s32)Columns.size()-1; i >= 0 ; --i ) - { - u32 colWidth = Columns[i].Width; - - if ( xpos >= (pos - CLICK_AREA) && xpos < ( pos + CLICK_AREA ) ) - { - CurrentResizedColumn = i; - ResizeStart = xpos; - return true; - } - - pos -= colWidth; - } - - return false; -} - - -bool CGUITable::dragColumnUpdate(s32 xpos) -{ - if ( !ResizableColumns || CurrentResizedColumn < 0 || CurrentResizedColumn >= s32(Columns.size()) ) - { - CurrentResizedColumn = -1; - return false; - } - - s32 width = s32(Columns[CurrentResizedColumn].Width) + (xpos-ResizeStart); - if ( width < 0 ) - width = 0; - setColumnWidth(CurrentResizedColumn, u32(width)); - ResizeStart = xpos; - - return false; -} - - -bool CGUITable::selectColumnHeader(s32 xpos, s32 ypos) -{ - if ( ypos > ( AbsoluteRect.UpperLeftCorner.Y + ItemHeight ) ) - return false; - - s32 pos = AbsoluteRect.UpperLeftCorner.X+1; - - if ( HorizontalScrollBar && HorizontalScrollBar->isVisible() ) - pos -= HorizontalScrollBar->getPos(); - - for ( u32 i = 0 ; i < Columns.size() ; ++i ) - { - u32 colWidth = Columns[i].Width; - - if ( xpos >= pos && xpos < ( pos + s32(colWidth) ) ) - { - setActiveColumn( i, true ); - - return true; - } - - pos += colWidth; - } - - return false; -} - - -void CGUITable::orderRows(s32 columnIndex, EGUI_ORDERING_MODE mode) -{ - Row swap; - - if ( columnIndex == -1 ) - columnIndex = getActiveColumn(); - if ( columnIndex < 0 ) - return; - - if ( mode == EGOM_ASCENDING ) - { - for ( s32 i = 0 ; i < s32(Rows.size()) - 1 ; ++i ) - { - for ( s32 j = 0 ; j < s32(Rows.size()) - i - 1 ; ++j ) - { - if ( Rows[j+1].Items[columnIndex].Text < Rows[j].Items[columnIndex].Text ) - { - swap = Rows[j]; - Rows[j] = Rows[j+1]; - Rows[j+1] = swap; - - if ( Selected == j ) - Selected = j+1; - else if( Selected == j+1 ) - Selected = j; - } - } - } - } - else if ( mode == EGOM_DESCENDING ) - { - for ( s32 i = 0 ; i < s32(Rows.size()) - 1 ; ++i ) - { - for ( s32 j = 0 ; j < s32(Rows.size()) - i - 1 ; ++j ) - { - if ( Rows[j].Items[columnIndex].Text < Rows[j+1].Items[columnIndex].Text) - { - swap = Rows[j]; - Rows[j] = Rows[j+1]; - Rows[j+1] = swap; - - if ( Selected == j ) - Selected = j+1; - else if( Selected == j+1 ) - Selected = j; - } - } - } - } -} - - -void CGUITable::selectNew(s32 ypos, bool onlyHover) -{ - IGUISkin* skin = Environment->getSkin(); - if (!skin) - return; - - s32 oldSelected = Selected; - - if ( ypos < ( AbsoluteRect.UpperLeftCorner.Y + ItemHeight ) ) - return; - - // find new selected item. - if (ItemHeight!=0) - Selected = ((ypos - AbsoluteRect.UpperLeftCorner.Y - ItemHeight - 1) + VerticalScrollBar->getPos()) / ItemHeight; - - if (Selected >= (s32)Rows.size()) - Selected = Rows.size() - 1; - else if (Selected<0) - Selected = 0; - - // post the news - if (Parent && !onlyHover) - { - SEvent event; - event.EventType = EET_GUI_EVENT; - event.GUIEvent.Caller = this; - event.GUIEvent.EventType = (Selected != oldSelected) ? EGET_TABLE_CHANGED : EGET_TABLE_SELECTED_AGAIN; - Parent->OnEvent(event); - } -} - - -//! draws the element and its children -void CGUITable::draw() -{ - if (!IsVisible) - return; - - irr::video::IVideoDriver* driver = Environment->getVideoDriver(); - - IGUISkin* skin = Environment->getSkin(); - if (!skin) - return; - - IGUIFont* font = skin->getFont(); - if (!font) - return; - - // CAREFUL: near identical calculations for tableRect and clientClip are also done in checkScrollbars and selectColumnHeader - // Area of table used for drawing without scrollbars - core::rect<s32> tableRect(AbsoluteRect); - tableRect.UpperLeftCorner.X += 1; - tableRect.UpperLeftCorner.Y += 1; - if ( VerticalScrollBar && VerticalScrollBar->isVisible() ) - tableRect.LowerRightCorner.X -= skin->getSize(EGDS_SCROLLBAR_SIZE); - if ( HorizontalScrollBar && HorizontalScrollBar->isVisible() ) - tableRect.LowerRightCorner.Y -= skin->getSize(EGDS_SCROLLBAR_SIZE); - - s32 headerBottom = tableRect.UpperLeftCorner.Y + ItemHeight; - - // area of for the items (without header and without scrollbars) - core::rect<s32> clientClip(tableRect); - clientClip.UpperLeftCorner.Y = headerBottom + 1; - - core::rect<s32>* clipRect = 0; - if (Clip) - clipRect = &AbsoluteClippingRect; - - // draw background for whole element - skin->draw3DSunkenPane(this, skin->getColor(EGDC_3D_HIGH_LIGHT), true, DrawBack, AbsoluteRect, clipRect); - - // scrolledTableClient is the area where the table items would be if it could be drawn completely - core::rect<s32> scrolledTableClient(tableRect); - scrolledTableClient.UpperLeftCorner.Y = headerBottom + 1; - scrolledTableClient.LowerRightCorner.Y = scrolledTableClient.UpperLeftCorner.Y + TotalItemHeight; - scrolledTableClient.LowerRightCorner.X = scrolledTableClient.UpperLeftCorner.X + TotalItemWidth; - if ( VerticalScrollBar && VerticalScrollBar->isVisible() ) - { - scrolledTableClient.UpperLeftCorner.Y -= VerticalScrollBar->getPos(); - scrolledTableClient.LowerRightCorner.Y -= VerticalScrollBar->getPos(); - } - if ( HorizontalScrollBar && HorizontalScrollBar->isVisible() ) - { - scrolledTableClient.UpperLeftCorner.X -= HorizontalScrollBar->getPos(); - scrolledTableClient.LowerRightCorner.X -= HorizontalScrollBar->getPos(); - } - - // rowRect is around the scrolled row - core::rect<s32> rowRect(scrolledTableClient); - rowRect.LowerRightCorner.Y = rowRect.UpperLeftCorner.Y + ItemHeight; - - u32 pos; - for ( u32 i = 0 ; i < Rows.size() ; ++i ) - { - if (rowRect.LowerRightCorner.Y >= AbsoluteRect.UpperLeftCorner.Y && - rowRect.UpperLeftCorner.Y <= AbsoluteRect.LowerRightCorner.Y) - { - // draw row seperator - if ( DrawFlags & EGTDF_ROWS ) - { - core::rect<s32> lineRect(rowRect); - lineRect.UpperLeftCorner.Y = lineRect.LowerRightCorner.Y - 1; - driver->draw2DRectangle(skin->getColor(EGDC_3D_SHADOW), lineRect, &clientClip); - } - - core::rect<s32> textRect(rowRect); - pos = rowRect.UpperLeftCorner.X; - - // draw selected row background highlighted - if ((s32)i == Selected && DrawFlags & EGTDF_ACTIVE_ROW ) - driver->draw2DRectangle(skin->getColor(EGDC_HIGH_LIGHT), rowRect, &clientClip); - - for ( u32 j = 0 ; j < Columns.size() ; ++j ) - { - textRect.UpperLeftCorner.X = pos + CellWidthPadding; - textRect.LowerRightCorner.X = pos + Columns[j].Width - CellWidthPadding; - - // draw item text - if ((s32)i == Selected) - { - font->draw(Rows[i].Items[j].BrokenText.c_str(), textRect, skin->getColor(IsEnabled ? EGDC_HIGH_LIGHT_TEXT : EGDC_GRAY_TEXT), false, true, &clientClip); - } - else - { - font->draw(Rows[i].Items[j].BrokenText.c_str(), textRect, IsEnabled ? Rows[i].Items[j].Color : skin->getColor(EGDC_GRAY_TEXT), false, true, &clientClip); - } - - pos += Columns[j].Width; - } - } - - rowRect.UpperLeftCorner.Y += ItemHeight; - rowRect.LowerRightCorner.Y += ItemHeight; - } - - core::rect<s32> columnSeparator(clientClip); - pos = scrolledTableClient.UpperLeftCorner.X; - - for (u32 i = 0 ; i < Columns.size() ; ++i ) - { - const wchar_t* text = Columns[i].Name.c_str(); - u32 colWidth = Columns[i].Width; - - //core::dimension2d<s32 > dim = font->getDimension(text); - - core::rect<s32> columnrect(pos, tableRect.UpperLeftCorner.Y, pos + colWidth, headerBottom); - - // draw column background - skin->draw3DButtonPaneStandard(this, columnrect, &tableRect); - - // draw column seperator - if ( DrawFlags & EGTDF_COLUMNS ) - { - columnSeparator.UpperLeftCorner.X = pos; - columnSeparator.LowerRightCorner.X = pos + 1; - driver->draw2DRectangle(skin->getColor(EGDC_3D_SHADOW), columnSeparator, &tableRect); - } - - // draw header column text - columnrect.UpperLeftCorner.X += CellWidthPadding; - font->draw(text, columnrect, skin->getColor( IsEnabled ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT), false, true, &tableRect); - - // draw icon for active column tab - if ( (s32)i == ActiveTab ) - { - if ( CurrentOrdering == EGOM_ASCENDING ) - { - columnrect.UpperLeftCorner.X = columnrect.LowerRightCorner.X - CellWidthPadding - ARROW_PAD / 2 + 2; - columnrect.UpperLeftCorner.Y += 7; - skin->drawIcon(this,EGDI_CURSOR_UP,columnrect.UpperLeftCorner,0,0,false,&tableRect); - } - else - { - columnrect.UpperLeftCorner.X = columnrect.LowerRightCorner.X - CellWidthPadding - ARROW_PAD / 2 + 2; - columnrect.UpperLeftCorner.Y += 7; - skin->drawIcon(this,EGDI_CURSOR_DOWN,columnrect.UpperLeftCorner,0,0,false,&tableRect); - } - } - - pos += colWidth; - } - - // fill up header background up to the right side - core::rect<s32> columnrect(pos, tableRect.UpperLeftCorner.Y, tableRect.LowerRightCorner.X , headerBottom); - skin->draw3DButtonPaneStandard(this, columnrect, &tableRect); - - IGUIElement::draw(); -} - - -void CGUITable::breakText(const core::stringw& text, core::stringw& brokenText, u32 cellWidth) -{ - IGUISkin* skin = Environment->getSkin(); - - if (!skin) - return; - - if (!Font) - return; - - IGUIFont* font = skin->getFont(); - if (!font) - return; - - core::stringw line, lineDots; - wchar_t c[2]; - c[1] = L'\0'; - - const u32 maxLength = cellWidth - (CellWidthPadding * 2); - const u32 maxLengthDots = cellWidth - (CellWidthPadding * 2) - font->getDimension(L"...").Width; - const u32 size = text.size(); - u32 pos = 0; - - u32 i; - - for (i=0; i<size; ++i) - { - c[0] = text[i]; - - if (c[0] == L'\n') - break; - - pos += font->getDimension(c).Width; - if ( pos > maxLength ) - break; - - if ( font->getDimension( (line + c).c_str() ).Width > maxLengthDots ) - lineDots = line; - - line += c[0]; - } - - if ( i < size ) - brokenText = lineDots + L"..."; - else - brokenText = line; -} - - -//! Set some flags influencing the layout of the table -void CGUITable::setDrawFlags(s32 flags) -{ - DrawFlags = flags; -} - - -//! Get the flags which influence the layout of the table -s32 CGUITable::getDrawFlags() const -{ - return DrawFlags; -} - - -//! Writes attributes of the element. -void CGUITable::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const -{ - IGUITable::serializeAttributes(out, options); - - out->addInt("ColumnCount", Columns.size()); - u32 i; - for (i=0;i<Columns.size(); ++i) - { - core::stringc label; - - label = "Column"; label += i; label += "name"; - out->addString(label.c_str(), Columns[i].Name.c_str() ); - label = "Column"; label += i; label += "color"; - out->addColor(label.c_str(), Columns[i].TextColor ); - label = "Column"; label += i; label += "width"; - out->addInt(label.c_str(), Columns[i].Width ); - label = "Column"; label += i; label += "OrderingMode"; - out->addEnum(label.c_str(), Columns[i].OrderingMode, GUIColumnOrderingNames); - } - - out->addInt("RowCount", Rows.size()); - for (i=0;i<Rows.size(); ++i) - { - core::stringc label; - - // Height currently not used and could be recalculated anyway - //label = "Row"; label += i; label += "height"; - //out->addInt(label.c_str(), Rows[i].Height ); - - //label = "Row"; label += i; label += "ItemCount"; - //out->addInt(label.c_str(), Rows[i].Items.size()); - u32 c; - for ( c=0; c < Rows[i].Items.size(); ++c ) - { - label = "Row"; label += i; label += "cell"; label += c; label += "text"; - out->addString(label.c_str(), Rows[i].Items[c].Text.c_str() ); - // core::stringw BrokenText; // can be recalculated - label = "Row"; label += i; label += "cell"; label += c; label += "color"; - out->addColor(label.c_str(), Rows[i].Items[c].Color ); - // void *data; // can't be serialized - } - } - - // s32 ItemHeight; // can be calculated - // TotalItemHeight // calculated - // TotalItemWidth // calculated - // gui::IGUIFont* Font; // font is just the current font from environment - // gui::IGUIScrollBar* VerticalScrollBar; // not serialized - // gui::IGUIScrollBar* HorizontalScrollBar; // not serialized - - out->addBool ("Clip", Clip); - out->addBool ("DrawBack", DrawBack); - out->addBool ("MoveOverSelect", MoveOverSelect); - - // s32 CurrentResizedColumn; // runtime info - depends on user action - out->addBool ("ResizableColumns", ResizableColumns); - - // s32 Selected; // runtime info - depends on user action - out->addInt("CellWidthPadding", CellWidthPadding ); - out->addInt("CellHeightPadding", CellHeightPadding ); - // s32 ActiveTab; // runtime info - depends on user action - // bool Selecting; // runtime info - depends on user action - out->addEnum("CurrentOrdering", CurrentOrdering, GUIOrderingModeNames); - out->addInt("DrawFlags", DrawFlags); -} - - -//! Reads attributes of the element -void CGUITable::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - IGUITable::deserializeAttributes(in, options); - - Columns.clear(); - u32 columnCount = in->getAttributeAsInt("ColumnCount"); - u32 i; - for (i=0;i<columnCount; ++i) - { - core::stringc label; - Column column; - - label = "Column"; label += i; label += "name"; - column.Name = core::stringw(in->getAttributeAsString(label.c_str()).c_str()); - label = "Column"; label += i; label += "color"; - column.TextColor = in->getAttributeAsColor(label.c_str()); - label = "Column"; label += i; label += "width"; - column.Width = in->getAttributeAsInt(label.c_str()); - label = "Column"; label += i; label += "OrderingMode"; - - column.OrderingMode = EGCO_NONE; - s32 co = in->getAttributeAsEnumeration(label.c_str(), GUIColumnOrderingNames); - if (co > 0) - column.OrderingMode = EGUI_COLUMN_ORDERING(co); - - Columns.push_back(column); - } - - Rows.clear(); - u32 rowCount = in->getAttributeAsInt("RowCount"); - for (i=0; i<rowCount; ++i) - { - core::stringc label; - - Row row; - - // Height currently not used and could be recalculated anyway - //label = "Row"; label += i; label += "height"; - //row.Height = in->getAttributeAsInt(label.c_str() ); - - Rows.push_back(row); - - //label = "Row"; label += i; label += "ItemCount"; - //u32 itemCount = in->getAttributeAsInt(label.c_str()); - u32 c; - for ( c=0; c < columnCount; ++c ) - { - Cell cell; - - label = "Row"; label += i; label += "cell"; label += c; label += "text"; - cell.Text = core::stringw(in->getAttributeAsString(label.c_str()).c_str()); - breakText( cell.Text, cell.BrokenText, Columns[c].Width ); - label = "Row"; label += i; label += "cell"; label += c; label += "color"; - cell.Color = in->getAttributeAsColor(label.c_str()); - cell.Data = NULL; - - Rows[Rows.size()-1].Items.push_back(cell); - } - } - - ItemHeight = 0; // calculated - TotalItemHeight = 0; // calculated - TotalItemWidth = 0; // calculated - - // force font recalculation - if ( Font ) - { - Font->drop(); - Font = 0; - } - - Clip = in->getAttributeAsBool("Clip"); - DrawBack = in->getAttributeAsBool("DrawBack"); - MoveOverSelect = in->getAttributeAsBool("MoveOverSelect"); - - CurrentResizedColumn = -1; - ResizeStart = 0; - ResizableColumns = in->getAttributeAsBool("ResizableColumns"); - - Selected = -1; - CellWidthPadding = in->getAttributeAsInt("CellWidthPadding"); - CellHeightPadding = in->getAttributeAsInt("CellHeightPadding"); - ActiveTab = -1; - Selecting = false; - - CurrentOrdering = (EGUI_ORDERING_MODE) in->getAttributeAsEnumeration("CurrentOrdering", GUIOrderingModeNames); - DrawFlags = in->getAttributeAsInt("DrawFlags"); - - refreshControls(); -} - -} // end namespace gui -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CGUITable.h b/irrlicht-1.6/source/Irrlicht/CGUITable.h deleted file mode 100644 index 361f41246..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUITable.h +++ /dev/null @@ -1,221 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -// 07.10.2005 - Multicolor-Listbox addet by A. Buschhueter (Acki) -// A_Buschhueter@gmx.de - -#ifndef __C_GUI_TABLE_BAR_H_INCLUDED__ -#define __C_GUI_TABLE_BAR_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUITable.h" -#include "irrArray.h" - -namespace irr -{ -namespace gui -{ - - class IGUIFont; - class IGUIScrollBar; - - class CGUITable : public IGUITable - { - public: - //! constructor - CGUITable(IGUIEnvironment* environment, IGUIElement* parent, - s32 id, const core::rect<s32>& rectangle, bool clip=true, - bool drawBack=false, bool moveOverSelect=true); - - //! destructor - ~CGUITable(); - - //! Adds a column - //! If columnIndex is outside the current range, do push new colum at the end - virtual void addColumn(const wchar_t* caption, s32 columnIndex=-1); - - //! remove a column from the table - virtual void removeColumn(u32 columnIndex); - - //! Returns the number of columns in the table control - virtual s32 getColumnCount() const; - - //! Makes a column active. This will trigger an ordering process. - /** \param idx: The id of the column to make active. - \return True if successful. */ - virtual bool setActiveColumn(s32 columnIndex, bool doOrder=false); - - //! Returns which header is currently active - virtual s32 getActiveColumn() const; - - //! Returns the ordering used by the currently active column - virtual EGUI_ORDERING_MODE getActiveColumnOrdering() const; - - //! set a column width - virtual void setColumnWidth(u32 columnIndex, u32 width); - - //! columns can be resized by drag 'n drop - virtual void setResizableColumns(bool resizable); - - //! can columns be resized by dran 'n drop? - virtual bool hasResizableColumns() const; - - //! This tells the table control which ordering mode should be used when - //! a column header is clicked. - /** \param columnIndex: The index of the column header. - \param state: If true, a EGET_TABLE_HEADER_CHANGED message will be sent and you can order the table data as you whish.*/ - //! \param mode: One of the modes defined in EGUI_COLUMN_ORDERING - virtual void setColumnOrdering(u32 columnIndex, EGUI_COLUMN_ORDERING mode); - - //! Returns which row is currently selected - virtual s32 getSelected() const; - - //! set wich row is currently selected - virtual void setSelected( s32 index ); - - //! Returns amount of rows in the tabcontrol - virtual s32 getRowCount() const; - - //! adds a row to the table - /** \param rowIndex: zero based index of rows. The row will be - inserted at this position. If a row already exists - there, it will be placed after it. If the row is larger - than the actual number of rows by more than one, it - won't be created. Note that if you create a row that is - not at the end, there might be performance issues*/ - virtual u32 addRow(u32 rowIndex); - - //! Remove a row from the table - virtual void removeRow(u32 rowIndex); - - //! clear the table rows, but keep the columns intact - virtual void clearRows(); - - //! Swap two row positions. This is useful for a custom ordering algo. - virtual void swapRows(u32 rowIndexA, u32 rowIndexB); - - //! This tells the table to start ordering all the rows. You - //! need to explicitly tell the table to reorder the rows when - //! a new row is added or the cells data is changed. This makes - //! the system more flexible and doesn't make you pay the cost - //! of ordering when adding a lot of rows. - //! \param columnIndex: When set to -1 the active column is used. - virtual void orderRows(s32 columnIndex=-1, EGUI_ORDERING_MODE mode=EGOM_NONE); - - - //! Set the text of a cell - virtual void setCellText(u32 rowIndex, u32 columnIndex, const core::stringw& text); - - //! Set the text of a cell, and set a color of this cell. - virtual void setCellText(u32 rowIndex, u32 columnIndex, const core::stringw& text, video::SColor color); - - //! Set the data of a cell - //! data will not be serialized. - virtual void setCellData(u32 rowIndex, u32 columnIndex, void *data); - - //! Set the color of a cell text - virtual void setCellColor(u32 rowIndex, u32 columnIndex, video::SColor color); - - //! Get the text of a cell - virtual const wchar_t* getCellText(u32 rowIndex, u32 columnIndex ) const; - - //! Get the data of a cell - virtual void* getCellData(u32 rowIndex, u32 columnIndex ) const; - - //! clears the table, deletes all items in the table - virtual void clear(); - - //! called if an event happened. - virtual bool OnEvent(const SEvent &event); - - //! draws the element and its children - virtual void draw(); - - //! Set flags, as defined in EGUI_TABLE_DRAW_FLAGS, which influence the layout - virtual void setDrawFlags(s32 flags); - - //! Get the flags, as defined in EGUI_TABLE_DRAW_FLAGS, which influence the layout - virtual s32 getDrawFlags() const; - - //! Writes attributes of the object. - //! Implement this to expose the attributes of your scene node animator for - //! scripting languages, editors, debuggers or xml serialization purposes. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const; - - //! Reads attributes of the object. - //! Implement this to set the attributes of your scene node animator for - //! scripting languages, editors, debuggers or xml deserialization purposes. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - protected: - virtual void refreshControls(); - virtual void checkScrollbars(); - - private: - - struct Cell - { - Cell() : Data(0) {} - core::stringw Text; - core::stringw BrokenText; - video::SColor Color; - void *Data; - }; - - struct Row - { - Row() {} - core::array<Cell> Items; - }; - - struct Column - { - Column() : Width(0), OrderingMode(EGCO_NONE) {} - core::stringw Name; - video::SColor TextColor; - u32 Width; - EGUI_COLUMN_ORDERING OrderingMode; - }; - - void breakText(const core::stringw &text, core::stringw & brokenText, u32 cellWidth); - void selectNew(s32 ypos, bool onlyHover=false); - bool selectColumnHeader(s32 xpos, s32 ypos); - bool dragColumnStart(s32 xpos, s32 ypos); - bool dragColumnUpdate(s32 xpos); - void recalculateHeights(); - void recalculateWidths(); - - core::array< Column > Columns; - core::array< Row > Rows; - gui::IGUIFont* Font; - gui::IGUIScrollBar* VerticalScrollBar; - gui::IGUIScrollBar* HorizontalScrollBar; - bool Clip; - bool DrawBack; - bool MoveOverSelect; - bool Selecting; - s32 CurrentResizedColumn; - s32 ResizeStart; - bool ResizableColumns; - - s32 ItemHeight; - s32 TotalItemHeight; - s32 TotalItemWidth; - s32 Selected; - s32 CellHeightPadding; - s32 CellWidthPadding; - s32 ActiveTab; - EGUI_ORDERING_MODE CurrentOrdering; - s32 DrawFlags; - }; - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CGUIToolBar.cpp b/irrlicht-1.6/source/Irrlicht/CGUIToolBar.cpp deleted file mode 100644 index 9c7c4e1a6..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIToolBar.cpp +++ /dev/null @@ -1,162 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUIToolBar.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUISkin.h" -#include "IGUIEnvironment.h" -#include "IVideoDriver.h" -#include "IGUIButton.h" -#include "IGUIFont.h" -#include "CGUIButton.h" - -namespace irr -{ -namespace gui -{ - -//! constructor -CGUIToolBar::CGUIToolBar(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle) -:IGUIToolBar(environment, parent, id, rectangle), ButtonX(5) -{ - #ifdef _DEBUG - setDebugName("CGUIToolBar"); - #endif - - // calculate position and find other menubars - s32 y = 0; - s32 parentwidth = 100; - - if (parent) - { - parentwidth = Parent->getAbsolutePosition().getWidth(); - - const core::list<IGUIElement*>& children = parent->getChildren(); - core::list<IGUIElement*>::ConstIterator it = children.begin(); - for (; it != children.end(); ++it) - { - core::rect<s32> r = (*it)->getAbsolutePosition(); - if (r.UpperLeftCorner.X == 0 && r.UpperLeftCorner.Y <= y && - r.LowerRightCorner.X == parentwidth) - y = r.LowerRightCorner.Y; - } - } - - core::rect<s32> rr; - rr.UpperLeftCorner.X = 0; - rr.UpperLeftCorner.Y = y; - s32 height = Environment->getSkin()->getSize ( EGDS_MENU_HEIGHT ); - - /*IGUISkin* skin = Environment->getSkin(); - IGUIFont* font = skin->getFont(); - if (font) - { - s32 t = font->getDimension(L"A").Height + 5; - if (t > height) - height = t; - }*/ - - rr.LowerRightCorner.X = parentwidth; - rr.LowerRightCorner.Y = rr.UpperLeftCorner.Y + height; - setRelativePosition(rr); -} - - -//! called if an event happened. -bool CGUIToolBar::OnEvent(const SEvent& event) -{ - if (IsEnabled) - { - if (event.EventType == EET_MOUSE_INPUT_EVENT && - event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN) - { - if (AbsoluteClippingRect.isPointInside(core::position2di(event.MouseInput.X, event.MouseInput.Y))) - return true; - } - } - - return IGUIElement::OnEvent(event); -} - - -//! draws the element and its children -void CGUIToolBar::draw() -{ - if (!IsVisible) - return; - - IGUISkin* skin = Environment->getSkin(); - if (!skin) - return; - - core::rect<s32> rect = AbsoluteRect; - core::rect<s32>* clip = &AbsoluteClippingRect; - - // draw frame - skin->draw3DToolBar(this, rect, clip); - - IGUIElement::draw(); -} - - -//! Updates the absolute position. -void CGUIToolBar::updateAbsolutePosition() -{ - if (Parent) - { - DesiredRect.UpperLeftCorner.X = 0; - DesiredRect.LowerRightCorner.X = Parent->getAbsolutePosition().getWidth(); - } - - IGUIElement::updateAbsolutePosition(); -} - - -//! Adds a button to the tool bar -IGUIButton* CGUIToolBar::addButton(s32 id, const wchar_t* text,const wchar_t* tooltiptext, - video::ITexture* img, video::ITexture* pressed, bool isPushButton, - bool useAlphaChannel) -{ - ButtonX += 3; - - core::rect<s32> rectangle(ButtonX,2,0,0); - if ( img ) - { - const core::dimension2du &size = img->getOriginalSize(); - rectangle.LowerRightCorner.X = rectangle.UpperLeftCorner.X + size.Width + 8; - rectangle.LowerRightCorner.Y = rectangle.UpperLeftCorner.Y + size.Height + 6; - } - - ButtonX += rectangle.getWidth(); - - IGUIButton* button = new CGUIButton(Environment, this, id, rectangle); - button->drop(); - - if (text) - button->setText(text); - - if (tooltiptext) - button->setToolTipText(tooltiptext); - - if (img) - button->setImage(img); - - if (pressed) - button->setPressedImage(pressed); - - if (isPushButton) - button->setIsPushButton(isPushButton); - - if (useAlphaChannel) - button->setUseAlphaChannel(useAlphaChannel); - - return button; -} - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - diff --git a/irrlicht-1.6/source/Irrlicht/CGUIToolBar.h b/irrlicht-1.6/source/Irrlicht/CGUIToolBar.h deleted file mode 100644 index 3f6eaf964..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIToolBar.h +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_TOOL_BAR_H_INCLUDED__ -#define __C_GUI_TOOL_BAR_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUIToolbar.h" - -namespace irr -{ -namespace gui -{ - - //! Stays at the top of its parent like the menu bar and contains tool buttons - class CGUIToolBar : public IGUIToolBar - { - public: - - //! constructor - CGUIToolBar(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle); - - //! called if an event happened. - virtual bool OnEvent(const SEvent& event); - - //! draws the element and its children - virtual void draw(); - - //! Updates the absolute position. - virtual void updateAbsolutePosition(); - - //! Adds a button to the tool bar - virtual IGUIButton* addButton(s32 id=-1, const wchar_t* text=0,const wchar_t* tooltiptext=0, - video::ITexture* img=0, video::ITexture* pressed=0, - bool isPushButton=false, bool useAlphaChannel=false); - - private: - - s32 ButtonX; - }; - - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CGUITreeView.cpp b/irrlicht-1.6/source/Irrlicht/CGUITreeView.cpp deleted file mode 100644 index fe41ae107..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUITreeView.cpp +++ /dev/null @@ -1,1092 +0,0 @@ -// This file is part of the "Irrlicht Engine". -// written by Reinhard Ostermeier, reinhard@nospam.r-ostermeier.de -// expaned by burningwater - -#include "CGUITreeView.h" - -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUISkin.h" -#include "IGUIEnvironment.h" -#include "IVideoDriver.h" -#include "IGUIFont.h" -#include "CGUIScrollBar.h" -#include "os.h" - -namespace irr -{ -namespace gui -{ - -CGUITreeViewNode::CGUITreeViewNode( CGUITreeView* owner, CGUITreeViewNode* parent ) - : Owner(owner), Parent(parent), ImageIndex(-1), SelectedImageIndex(-1), - Data(0), Data2(0), Expanded(false) -{ -#ifdef _DEBUG - setDebugName( "CGUITreeView" ); -#endif -} - -CGUITreeViewNode::~CGUITreeViewNode() -{ - if( Owner && this == Owner->getSelected() ) - { - setSelected( false ); - } - - clearChilds(); - - if( Data2 ) - { - Data2->drop(); - } -} - -IGUITreeView* CGUITreeViewNode::getOwner() const -{ - return Owner; -} - -IGUITreeViewNode* CGUITreeViewNode::getParent() const -{ - return Parent; -} - -void CGUITreeViewNode::setText( const wchar_t* text ) -{ - Text = text; -} - -void CGUITreeViewNode::setIcon( const wchar_t* icon ) -{ - Icon = icon; -} - -void CGUITreeViewNode::clearChilds() -{ - core::list<CGUITreeViewNode*>::Iterator it; - - for( it = Childs.begin(); it != Childs.end(); it++ ) - { - ( *it )->drop(); - } - Childs.clear(); -} - -IGUITreeViewNode* CGUITreeViewNode::addChildBack( - const wchar_t* text, - const wchar_t* icon /*= 0*/, - s32 imageIndex /*= -1*/, - s32 selectedImageIndex /*= -1*/, - void* data /*= 0*/, - IReferenceCounted* data2 /*= 0*/ ) -{ - CGUITreeViewNode* newChild = new CGUITreeViewNode( Owner, this ); - - Childs.push_back( newChild ); - newChild->Text = text; - newChild->Icon = icon; - newChild->ImageIndex = imageIndex; - newChild->SelectedImageIndex = selectedImageIndex; - newChild->Data = data; - newChild->Data2 = data2; - if( data2 ) - { - data2->grab(); - } - return newChild; -} - -IGUITreeViewNode* CGUITreeViewNode::addChildFront( - const wchar_t* text, - const wchar_t* icon /*= 0*/, - s32 imageIndex /*= -1*/, - s32 selectedImageIndex /*= -1*/, - void* data /*= 0*/, - IReferenceCounted* data2 /*= 0*/ ) -{ - CGUITreeViewNode* newChild = new CGUITreeViewNode( Owner, this ); - - Childs.push_front( newChild ); - newChild->Text = text; - newChild->Icon = icon; - newChild->ImageIndex = imageIndex; - newChild->SelectedImageIndex = selectedImageIndex; - newChild->Data = data; - newChild->Data2 = data2; - if( data2 ) - { - data2->grab(); - } - return newChild; -} - -IGUITreeViewNode* CGUITreeViewNode::insertChildAfter( - IGUITreeViewNode* other, - const wchar_t* text, - const wchar_t* icon /*= 0*/, - s32 imageIndex /*= -1*/, - s32 selectedImageIndex /*= -1*/, - void* data /*= 0*/, - IReferenceCounted* data2/* = 0*/ ) -{ - core::list<CGUITreeViewNode*>::Iterator itOther; - CGUITreeViewNode* newChild = 0; - - for( itOther = Childs.begin(); itOther != Childs.end(); itOther++ ) - { - if( other == *itOther ) - { - newChild = new CGUITreeViewNode( Owner, this ); - newChild->Text = text; - newChild->Icon = icon; - newChild->ImageIndex = imageIndex; - newChild->SelectedImageIndex = selectedImageIndex; - newChild->Data = data; - newChild->Data2 = data2; - if( data2 ) - { - data2->grab(); - } - Childs.insert_after( itOther, newChild ); - break; - } - } - return newChild; -} - -IGUITreeViewNode* CGUITreeViewNode::insertChildBefore( - IGUITreeViewNode* other, - const wchar_t* text, - const wchar_t* icon /*= 0*/, - s32 imageIndex /*= -1*/, - s32 selectedImageIndex /*= -1*/, - void* data /*= 0*/, - IReferenceCounted* data2/* = 0*/ ) -{ - core::list<CGUITreeViewNode*>::Iterator itOther; - CGUITreeViewNode* newChild = 0; - - for( itOther = Childs.begin(); itOther != Childs.end(); itOther++ ) - { - if( other == *itOther ) - { - newChild = new CGUITreeViewNode( Owner, this ); - newChild->Text = text; - newChild->Icon = icon; - newChild->ImageIndex = imageIndex; - newChild->SelectedImageIndex = selectedImageIndex; - newChild->Data = data; - newChild->Data2 = data2; - if( data2 ) - { - data2->grab(); - } - Childs.insert_before( itOther, newChild ); - break; - } - } - return newChild; -} - -IGUITreeViewNode* CGUITreeViewNode::getFirstChild() const -{ - if( Childs.empty() ) - { - return 0; - } - else - { - return *( Childs.begin() ); - } -} - -IGUITreeViewNode* CGUITreeViewNode::getLastChild() const -{ - if( Childs.empty() ) - { - return 0; - } - else - { - return *( Childs.getLast() ); - } -} - -IGUITreeViewNode* CGUITreeViewNode::getPrevSibling() const -{ - core::list<CGUITreeViewNode*>::Iterator itThis; - core::list<CGUITreeViewNode*>::Iterator itOther; - CGUITreeViewNode* other = 0; - - if( Parent ) - { - for( itThis = Parent->Childs.begin(); itThis != Parent->Childs.end(); itThis++ ) - { - if( this == *itThis ) - { - if( itThis != Parent->Childs.begin() ) - { - other = *itOther; - } - break; - } - itOther = itThis; - } - } - return other; -} - -IGUITreeViewNode* CGUITreeViewNode::getNextSibling() const -{ - core::list<CGUITreeViewNode*>::Iterator itThis; - CGUITreeViewNode* other = 0; - - if( Parent ) - { - for( itThis = Parent->Childs.begin(); itThis != Parent->Childs.end(); itThis++ ) - { - if( this == *itThis ) - { - if( itThis != Parent->Childs.getLast() ) - { - other = *( ++itThis ); - } - break; - } - } - } - return other; -} - -IGUITreeViewNode* CGUITreeViewNode::getNextVisible() const -{ - IGUITreeViewNode* next = 0; - IGUITreeViewNode* node = 0; - - node = const_cast<CGUITreeViewNode*>( this ); - - if( node->getExpanded() && node->hasChilds() ) - { - next = node->getFirstChild(); - } - else - { - next = node->getNextSibling(); - } - while( !next && node->getParent() ) - { - next = node->getParent()->getNextSibling(); - if( !next ) - { - node = node->getParent(); - } - } - - return next; -} - -bool CGUITreeViewNode::deleteChild( IGUITreeViewNode* child ) -{ - core::list<CGUITreeViewNode*>::Iterator itChild; - bool deleted = false; - - for( itChild = Childs.begin(); itChild != Childs.end(); itChild++ ) - { - if( child == *itChild ) - { - child->drop(); - Childs.erase( itChild ); - deleted = true; - break; - } - } - return deleted; -} - -bool CGUITreeViewNode::moveChildUp( IGUITreeViewNode* child ) -{ - core::list<CGUITreeViewNode*>::Iterator itChild; - core::list<CGUITreeViewNode*>::Iterator itOther; - CGUITreeViewNode* nodeTmp; - bool moved = false; - - for( itChild = Childs.begin(); itChild != Childs.end(); itChild++ ) - { - if( child == *itChild ) - { - if( itChild != Childs.begin() ) - { - nodeTmp = *itChild; - *itChild = *itOther; - *itOther = nodeTmp; - moved = true; - } - break; - } - itOther = itChild; - } - return moved; -} - -bool CGUITreeViewNode::moveChildDown( IGUITreeViewNode* child ) -{ - core::list<CGUITreeViewNode*>::Iterator itChild; - core::list<CGUITreeViewNode*>::Iterator itOther; - CGUITreeViewNode* nodeTmp; - bool moved = false; - - for( itChild = Childs.begin(); itChild != Childs.end(); itChild++ ) - { - if( child == *itChild ) - { - if( itChild != Childs.getLast() ) - { - itOther = itChild; - ++itOther; - nodeTmp = *itChild; - *itChild = *itOther; - *itOther = nodeTmp; - moved = true; - } - break; - } - } - return moved; -} - -void CGUITreeViewNode::setExpanded( bool expanded ) -{ - Expanded = expanded; -} - -void CGUITreeViewNode::setSelected( bool selected ) -{ - if( Owner ) - { - if( selected ) - { - Owner->Selected = this; - } - else - { - if( Owner->Selected == this ) - { - Owner->Selected = 0; - } - } - } -} - -bool CGUITreeViewNode::getSelected() const -{ - if( Owner ) - { - return Owner->Selected == (IGUITreeViewNode*)this; - } - else - { - return false; - } -} - -bool CGUITreeViewNode::isRoot() const -{ - return ( Owner && ( this == Owner->Root ) ); -} - -s32 CGUITreeViewNode::getLevel() const -{ - if( Parent ) - { - return Parent->getLevel() + 1; - } - else - { - return 0; - } -} - -bool CGUITreeViewNode::isVisible() const -{ - if( Parent ) - { - return Parent->getExpanded() && Parent->isVisible(); - } - else - { - return true; - } -} - - -//! constructor -CGUITreeView::CGUITreeView(IGUIEnvironment* environment, IGUIElement* parent, - s32 id, core::rect<s32> rectangle, bool clip, - bool drawBack,bool scrollBarVertical, bool scrollBarHorizontal) - : IGUITreeView( environment, parent, id, rectangle ), - Root(0), Selected(0), - ItemHeight( 0 ), - IndentWidth( 0 ), - TotalItemHeight( 0 ), - TotalItemWidth ( 0 ), - Font( 0 ), - IconFont( 0 ), - ScrollBarH( 0 ), - ScrollBarV( 0 ), - ImageList( 0 ), - LastEventNode( 0 ), - LinesVisible( true ), - Selecting( false ), - Clip( clip ), - DrawBack( drawBack ), - ImageLeftOfIcon( true ) -{ -#ifdef _DEBUG - setDebugName( "CGUITreeView" ); -#endif - - IGUISkin* skin = Environment->getSkin(); - s32 s = skin->getSize( EGDS_SCROLLBAR_SIZE ); - - if ( scrollBarVertical ) - { - ScrollBarV = new CGUIScrollBar( false, Environment, this, 0, - core::rect<s32>( RelativeRect.getWidth() - s, - 0, - RelativeRect.getWidth(), - RelativeRect.getHeight() - (scrollBarHorizontal ? s : 0 ) - ), - !clip ); - ScrollBarV->drop(); - - ScrollBarV->setPos( 0 ); - ScrollBarV->grab(); - } - - if ( scrollBarHorizontal ) - { - ScrollBarH = new CGUIScrollBar( true, Environment, this, 1, - core::rect<s32>( 0, RelativeRect.getHeight() - s, RelativeRect.getWidth() - s, RelativeRect.getHeight() ), - !clip ); - ScrollBarH->drop(); - - ScrollBarH->setPos( 0 ); - ScrollBarH->grab(); - } - - Root = new CGUITreeViewNode( this, 0 ); - Root->Expanded = true; - - recalculateItemHeight(); -} - - -//! destructor -CGUITreeView::~CGUITreeView() -{ - if( ScrollBarV ) - { - ScrollBarV->drop(); - } - - if( ScrollBarH ) - { - ScrollBarH->drop(); - } - - if( Font ) - { - Font->drop(); - } - - if( IconFont ) - { - IconFont->drop(); - } - - if( ImageList ) - { - ImageList->drop(); - } - - if( Root ) - { - Root->drop(); - } -} - -void CGUITreeView::recalculateItemHeight() -{ - IGUISkin* skin = Environment->getSkin(); - IGUITreeViewNode* node; - - if( Font != skin->getFont() ) - { - if( Font ) - { - Font->drop(); - } - - Font = skin->getFont(); - ItemHeight = 0; - - if( Font ) - { - ItemHeight = Font->getDimension( L"A" ).Height + 4; - Font->grab(); - } - - if( IconFont ) - { - s32 height = IconFont->getDimension( L" " ).Height; - if( height > ItemHeight ) - { - ItemHeight = height; - } - } - if( ImageList ) - { - if( ImageList->getImageSize().Height + 1 > ItemHeight ) - { - ItemHeight = ImageList->getImageSize().Height + 1; - } - } - } - - IndentWidth = ItemHeight; - if( IndentWidth < 9 ) - { - IndentWidth = 9; - } - else if( IndentWidth > 15 ) - { - IndentWidth = 15; - } - else - { - if( ( ( IndentWidth >> 1 ) << 1 ) - IndentWidth == 0 ) - { - --IndentWidth; - } - } - - TotalItemHeight = 0; - TotalItemWidth = AbsoluteRect.getWidth() * 2; - node = Root->getFirstChild(); - while( node ) - { - TotalItemHeight += ItemHeight; - node = node->getNextVisible(); - } - - if ( ScrollBarV ) - ScrollBarV->setMax( TotalItemHeight - AbsoluteRect.getHeight() ); - - if ( ScrollBarH ) - ScrollBarH->setMax( TotalItemWidth - AbsoluteRect.getWidth() ); - -} - -//! called if an event happened. -bool CGUITreeView::OnEvent( const SEvent &event ) -{ - switch( event.EventType ) - { - case EET_GUI_EVENT: - switch( event.GUIEvent.EventType ) - { - case gui::EGET_SCROLL_BAR_CHANGED: - if( event.GUIEvent.Caller == ScrollBarV || event.GUIEvent.Caller == ScrollBarH ) - { - //s32 pos = ( ( gui::IGUIScrollBar* )event.GUIEvent.Caller )->getPos(); - return true; - } - break; - case gui::EGET_ELEMENT_FOCUS_LOST: - { - Selecting = false; - return false; - } - break; - default: - break; - } - break; - case EET_MOUSE_INPUT_EVENT: - { - core::position2d<s32> p( event.MouseInput.X, event.MouseInput.Y ); - - switch( event.MouseInput.Event ) - { - case EMIE_MOUSE_WHEEL: - if ( ScrollBarV ) - ScrollBarV->setPos( ScrollBarV->getPos() + (s32)event.MouseInput.Wheel * -10 ); - return true; - break; - - case EMIE_LMOUSE_PRESSED_DOWN: - - if (Environment->hasFocus(this) && !AbsoluteClippingRect.isPointInside(p) ) - { - Environment->removeFocus(this); - return false; - } - - if( Environment->hasFocus( this ) && - ( ( ScrollBarV && ScrollBarV->getAbsolutePosition().isPointInside( p ) && ScrollBarV->OnEvent( event ) ) || - ( ScrollBarH && ScrollBarH->getAbsolutePosition().isPointInside( p ) && ScrollBarH->OnEvent( event ) ) - ) - ) - { - return true; - } - - Selecting = true; - Environment->setFocus( this ); - return true; - break; - - case EMIE_LMOUSE_LEFT_UP: - if( Environment->hasFocus( this ) && - ( ( ScrollBarV && ScrollBarV->getAbsolutePosition().isPointInside( p ) && ScrollBarV->OnEvent( event ) ) || - ( ScrollBarH && ScrollBarH->getAbsolutePosition().isPointInside( p ) && ScrollBarH->OnEvent( event ) ) - ) - ) - { - return true; - } - - Selecting = false; - Environment->removeFocus( this ); - mouseAction( event.MouseInput.X, event.MouseInput.Y ); - return true; - break; - - case EMIE_MOUSE_MOVED: - if( Selecting ) - { - if( getAbsolutePosition().isPointInside( p ) ) - { - mouseAction( event.MouseInput.X, event.MouseInput.Y, true ); - return true; - } - } - break; - default: - break; - } - } - break; - default: - break; - } - - - return Parent ? Parent->OnEvent( event ) : false; -} - -/*! -*/ -void CGUITreeView::mouseAction( s32 xpos, s32 ypos, bool onlyHover /*= false*/ ) -{ - IGUITreeViewNode* oldSelected = Selected; - IGUITreeViewNode* hitNode = 0; - s32 selIdx; - s32 n; - IGUITreeViewNode* node; - SEvent event; - - event.EventType = EET_GUI_EVENT; - event.GUIEvent.Caller = this; - - xpos -= AbsoluteRect.UpperLeftCorner.X; - ypos -= AbsoluteRect.UpperLeftCorner.Y; - - // find new selected item. - if( ItemHeight != 0 && ScrollBarV ) - { - selIdx = ( ( ypos - 1 ) + ScrollBarV->getPos() ) / ItemHeight; - } - - hitNode = 0; - node = Root->getFirstChild(); - n = 0; - while( node ) - { - if( selIdx == n ) - { - hitNode = node; - break; - } - node = node->getNextVisible(); - ++n; - } - - if( hitNode && xpos > hitNode->getLevel() * IndentWidth ) - { - Selected = hitNode; - } - - if( hitNode && !onlyHover - && xpos < hitNode->getLevel() * IndentWidth - && xpos > ( hitNode->getLevel() - 1 ) * IndentWidth - && hitNode->hasChilds() ) - { - hitNode->setExpanded( !hitNode->getExpanded() ); - - // post expand/collaps news - if( hitNode->getExpanded() ) - { - event.GUIEvent.EventType = EGET_TREEVIEW_NODE_EXPAND; - } - else - { - event.GUIEvent.EventType = EGET_TREEVIEW_NODE_COLLAPS; - } - LastEventNode = hitNode; - Parent->OnEvent( event ); - LastEventNode = 0; - } - - if( Selected && !Selected->isVisible() ) - { - Selected = 0; - } - - // post selection news - - if( Parent && !onlyHover && Selected != oldSelected ) - { - if( oldSelected ) - { - event.GUIEvent.EventType = EGET_TREEVIEW_NODE_DESELECT; - LastEventNode = oldSelected; - Parent->OnEvent( event ); - LastEventNode = 0; - } - if( Selected ) - { - event.GUIEvent.EventType = EGET_TREEVIEW_NODE_SELECT; - LastEventNode = Selected; - Parent->OnEvent( event ); - LastEventNode = 0; - } - } -} - - -//! draws the element and its children -void CGUITreeView::draw() -{ - if( !IsVisible ) - { - return; - } - - recalculateItemHeight(); // if the font changed - - IGUISkin* skin = Environment->getSkin(); - irr::video::IVideoDriver* driver = Environment->getVideoDriver(); - - core::rect<s32>* clipRect = 0; - if( Clip ) - { - clipRect = &AbsoluteClippingRect; - } - - // draw background - core::rect<s32> frameRect( AbsoluteRect ); - - if( DrawBack ) - { - driver->draw2DRectangle( skin->getColor( EGDC_3D_HIGH_LIGHT ), frameRect, - clipRect ); - } - - // draw the border - frameRect.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y + 1; - driver->draw2DRectangle( skin->getColor( EGDC_3D_SHADOW ), frameRect, - clipRect ); - - frameRect.LowerRightCorner.Y = AbsoluteRect.LowerRightCorner.Y; - frameRect.LowerRightCorner.X = frameRect.UpperLeftCorner.X + 1; - driver->draw2DRectangle( skin->getColor( EGDC_3D_SHADOW ), frameRect, - clipRect ); - - frameRect = AbsoluteRect; - frameRect.UpperLeftCorner.X = frameRect.LowerRightCorner.X - 1; - driver->draw2DRectangle( skin->getColor( EGDC_3D_HIGH_LIGHT ), frameRect, - clipRect ); - - frameRect = AbsoluteRect; - frameRect.UpperLeftCorner.Y = AbsoluteRect.LowerRightCorner.Y - 1; - frameRect.LowerRightCorner.Y = AbsoluteRect.LowerRightCorner.Y; - driver->draw2DRectangle( skin->getColor( EGDC_3D_HIGH_LIGHT ), frameRect, - clipRect ); - - - // draw items - - core::rect<s32> clientClip( AbsoluteRect ); - clientClip.UpperLeftCorner.Y += 1; - clientClip.UpperLeftCorner.X += 1; - clientClip.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X; - clientClip.LowerRightCorner.Y -= 1; - - if ( ScrollBarV ) - clientClip.LowerRightCorner.X -= skin->getSize( EGDS_SCROLLBAR_SIZE ); - if ( ScrollBarH ) - clientClip.LowerRightCorner.Y -= skin->getSize( EGDS_SCROLLBAR_SIZE ); - - if( clipRect ) - { - clientClip.clipAgainst( *clipRect ); - } - - frameRect = AbsoluteRect; - frameRect.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X - skin->getSize( EGDS_SCROLLBAR_SIZE ); - frameRect.LowerRightCorner.Y = AbsoluteRect.UpperLeftCorner.Y + ItemHeight; - - if ( ScrollBarV ) - { - frameRect.UpperLeftCorner.Y -= ScrollBarV->getPos(); - frameRect.LowerRightCorner.Y -= ScrollBarV->getPos(); - } - - if ( ScrollBarH ) - { - frameRect.UpperLeftCorner.X -= ScrollBarH->getPos(); - frameRect.LowerRightCorner.X -= ScrollBarH->getPos(); - } - - IGUITreeViewNode* node = Root->getFirstChild(); - while( node ) - { - frameRect.UpperLeftCorner.X = AbsoluteRect.UpperLeftCorner.X + 1 + node->getLevel() * IndentWidth; - - if( frameRect.LowerRightCorner.Y >= AbsoluteRect.UpperLeftCorner.Y - && frameRect.UpperLeftCorner.Y <= AbsoluteRect.LowerRightCorner.Y ) - { - if( node == Selected ) - { - driver->draw2DRectangle( skin->getColor( EGDC_HIGH_LIGHT ), frameRect, &clientClip ); - } - - if( node->hasChilds() ) - { - core::rect<s32> rc; - core::rect<s32> expanderRect; - - expanderRect.UpperLeftCorner.X = frameRect.UpperLeftCorner.X - IndentWidth + 2; - expanderRect.UpperLeftCorner.Y = frameRect.UpperLeftCorner.Y + ( ( frameRect.getHeight() - ( IndentWidth - 4 ) ) >> 1 ); - expanderRect.LowerRightCorner.X = expanderRect.UpperLeftCorner.X + IndentWidth - 4; - expanderRect.LowerRightCorner.Y = expanderRect.UpperLeftCorner.Y + IndentWidth - 4; - - // box upper line - rc.UpperLeftCorner.X = expanderRect.UpperLeftCorner.X; - rc.UpperLeftCorner.Y = expanderRect.UpperLeftCorner.Y; - rc.LowerRightCorner.X = expanderRect.LowerRightCorner.X; - rc.LowerRightCorner.Y = rc.UpperLeftCorner.Y + 1; - driver->draw2DRectangle( skin->getColor( EGDC_3D_SHADOW ), rc, - clipRect ); - - // box left line - rc.UpperLeftCorner.X = expanderRect.UpperLeftCorner.X; - rc.UpperLeftCorner.Y = expanderRect.UpperLeftCorner.Y; - rc.LowerRightCorner.X = rc.UpperLeftCorner.X + 1; - rc.LowerRightCorner.Y = expanderRect.LowerRightCorner.Y; - driver->draw2DRectangle( skin->getColor( EGDC_3D_SHADOW ), rc, - clipRect ); - - // box right line - rc.UpperLeftCorner.X = expanderRect.LowerRightCorner.X - 1; - rc.UpperLeftCorner.Y = expanderRect.UpperLeftCorner.Y; - rc.LowerRightCorner.X = rc.UpperLeftCorner.X + 1; - rc.LowerRightCorner.Y = expanderRect.LowerRightCorner.Y; - driver->draw2DRectangle( skin->getColor( EGDC_3D_SHADOW ), rc, - clipRect ); - - // box bottom line - rc.UpperLeftCorner.X = expanderRect.UpperLeftCorner.X; - rc.UpperLeftCorner.Y = expanderRect.LowerRightCorner.Y - 1; - rc.LowerRightCorner.X = expanderRect.LowerRightCorner.X; - rc.LowerRightCorner.Y = rc.UpperLeftCorner.Y + 1; - driver->draw2DRectangle( skin->getColor( EGDC_3D_SHADOW ), rc, - clipRect ); - - // horizontal '-' line - rc.UpperLeftCorner.X = expanderRect.UpperLeftCorner.X + 2; - rc.UpperLeftCorner.Y = expanderRect.UpperLeftCorner.Y + ( expanderRect.getHeight() >> 1 ); - rc.LowerRightCorner.X = rc.UpperLeftCorner.X + expanderRect.getWidth() - 4; - rc.LowerRightCorner.Y = rc.UpperLeftCorner.Y + 1; - driver->draw2DRectangle( skin->getColor( EGDC_BUTTON_TEXT ), rc, - clipRect ); - - if( !node->getExpanded() ) - { - // vertical '+' line - rc.UpperLeftCorner.X = expanderRect.UpperLeftCorner.X + ( expanderRect.getWidth() >> 1 ); - rc.UpperLeftCorner.Y = expanderRect.UpperLeftCorner.Y + 2; - rc.LowerRightCorner.X = rc.UpperLeftCorner.X + 1; - rc.LowerRightCorner.Y = rc.UpperLeftCorner.Y + expanderRect.getHeight() - 4; - driver->draw2DRectangle( skin->getColor( EGDC_BUTTON_TEXT ), rc, - clipRect ); - } - } - - core::rect<s32> textRect = frameRect; - - if( Font ) - { - s32 iconWidth = 0; - for( s32 n = 0; n < 2; ++n ) - { - s32 index = node->getImageIndex(); - if( ( ImageList && index >= 0 ) - && ( ( ImageLeftOfIcon && n == 0 ) - || ( !ImageLeftOfIcon && n == 1 ) ) ) - { - index = node->getSelectedImageIndex(); - if( node != Selected || index < 0 ) - { - index = node->getImageIndex(); - } - ImageList->draw( - index, - core::position2d<s32>( - textRect.UpperLeftCorner.X, - textRect.UpperLeftCorner.Y + ( ( textRect.getHeight() - ImageList->getImageSize().Height ) >> 1 ) ), - &clientClip ); - iconWidth += ImageList->getImageSize().Width + 3; - textRect.UpperLeftCorner.X += ImageList->getImageSize().Width + 3; - } - else if( ( IconFont && reinterpret_cast<CGUITreeViewNode*>( node )->Icon.size() ) - && ( ( ImageLeftOfIcon && n == 1 ) - || ( !ImageLeftOfIcon && n == 0 ) ) ) - { - IconFont->draw( node->getIcon(), textRect, skin->getColor( ( node == Selected ) ? EGDC_HIGH_LIGHT_TEXT : EGDC_BUTTON_TEXT ), false, true, &clientClip ); - iconWidth += IconFont->getDimension( node->getIcon() ).Width + 3; - textRect.UpperLeftCorner.X += IconFont->getDimension( node->getIcon() ).Width + 3; - } - } - - Font->draw( node->getText(), textRect, skin->getColor( ( node == Selected ) ? EGDC_HIGH_LIGHT_TEXT : EGDC_BUTTON_TEXT ), false, true, &clientClip ); - - textRect.UpperLeftCorner.X -= iconWidth; - } - - // draw the lines if neccessary - if( LinesVisible ) - { - core::rect<s32> rc; - - // horizontal line - rc.UpperLeftCorner.X = frameRect.UpperLeftCorner.X - IndentWidth - ( IndentWidth >> 1 ) - 1; - rc.UpperLeftCorner.Y = frameRect.UpperLeftCorner.Y + ( ( frameRect.getHeight() ) >> 1 ); - if( node->hasChilds() ) - { - rc.LowerRightCorner.X = frameRect.UpperLeftCorner.X - IndentWidth; - } - else - { - rc.LowerRightCorner.X = frameRect.UpperLeftCorner.X - 2; - } - rc.LowerRightCorner.Y = rc.UpperLeftCorner.Y + 1; - driver->draw2DRectangle( skin->getColor( EGDC_3D_SHADOW ), rc, - clipRect ); - - if( node->getParent() != Root ) - { - // vertical line - if( node == node->getParent()->getFirstChild() ) - { - rc.UpperLeftCorner.Y = frameRect.UpperLeftCorner.Y - ( ( frameRect.getHeight() - IndentWidth ) >> 1 ); - } - else - { - rc.UpperLeftCorner.Y = frameRect.UpperLeftCorner.Y - ( frameRect.getHeight() >> 1 ); - } - rc.LowerRightCorner.X = rc.UpperLeftCorner.X + 1; - driver->draw2DRectangle( skin->getColor( EGDC_3D_SHADOW ), rc, - clipRect ); - - // the vertical lines of all parents - IGUITreeViewNode* nodeTmp = node->getParent(); - rc.UpperLeftCorner.Y = frameRect.UpperLeftCorner.Y - ( frameRect.getHeight() >> 1 ); - for( s32 n = 0; n < node->getLevel() - 2; ++n ) - { - rc.UpperLeftCorner.X -= IndentWidth; - rc.LowerRightCorner.X -= IndentWidth; - if( nodeTmp != nodeTmp->getParent()->getLastChild() ) - { - driver->draw2DRectangle( skin->getColor( EGDC_3D_SHADOW ), rc, - clipRect ); - } - nodeTmp = nodeTmp->getParent(); - } - } - } - } - - frameRect.UpperLeftCorner.Y += ItemHeight; - frameRect.LowerRightCorner.Y += ItemHeight; - - node = node->getNextVisible(); - } - - IGUIElement::draw(); -} - -//! Sets the font which should be used as icon font. This font is set to the Irrlicht engine -//! built-in-font by default. Icons can be displayed in front of every list item. -//! An icon is a string, displayed with the icon font. When using the build-in-font of the -//! Irrlicht engine as icon font, the icon strings defined in GUIIcons.h can be used. -void CGUITreeView::setIconFont( IGUIFont* font ) -{ - s32 height; - - if ( font ) - font->grab(); - if ( IconFont ) - { - IconFont->drop(); - } - - IconFont = font; - if( IconFont ) - { - height = IconFont->getDimension( L" " ).Height; - if( height > ItemHeight ) - { - ItemHeight = height; - } - } -} - -//! Sets the image list which should be used for the image and selected image of every node. -//! The default is 0 (no images). -void CGUITreeView::setImageList( IGUIImageList* imageList ) -{ - if (imageList ) - imageList->grab(); - if( ImageList ) - { - ImageList->drop(); - } - - ImageList = imageList; - if( ImageList ) - { - if( ImageList->getImageSize().Height + 1 > ItemHeight ) - { - ItemHeight = ImageList->getImageSize().Height + 1; - } - } -} - -} // end namespace gui -} // end namespace irr - - -#endif // _IRR_COMPILE_WITH_GUI_ diff --git a/irrlicht-1.6/source/Irrlicht/CGUITreeView.h b/irrlicht-1.6/source/Irrlicht/CGUITreeView.h deleted file mode 100644 index 782d0431a..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUITreeView.h +++ /dev/null @@ -1,331 +0,0 @@ -// This file is part of the "Irrlicht Engine". -// written by Reinhard Ostermeier, reinhard@nospam.r-ostermeier.de - -#ifndef __C_GUI_TREE_VIEW_H_INCLUDED__ -#define __C_GUI_TREE_VIEW_H_INCLUDED__ - -#include "IGUITreeView.h" -#include "irrList.h" - - -namespace irr -{ -namespace gui -{ - // forward declarations - class IGUIFont; - class IGUIScrollBar; - class CGUITreeView; - - //! Node for gui tree view - class CGUITreeViewNode : public IGUITreeViewNode - { - friend class CGUITreeView; - - public: - //! constructor - CGUITreeViewNode( CGUITreeView* owner, CGUITreeViewNode* parent ); - - //! destructor - ~CGUITreeViewNode(); - - //! returns the owner (tree view) of this node - virtual IGUITreeView* getOwner() const; - - //! Returns the parent node of this node. - virtual IGUITreeViewNode* getParent() const; - - //! returns the text of the node - virtual const wchar_t* getText() const - { return Text.c_str(); } - - //! sets the text of the node - virtual void setText( const wchar_t* text ); - - //! returns the icon text of the node - virtual const wchar_t* getIcon() const - { return Icon.c_str(); } - - //! sets the icon text of the node - virtual void setIcon( const wchar_t* icon ); - - //! returns the image index of the node - virtual u32 getImageIndex() const - { return ImageIndex; } - - //! sets the image index of the node - virtual void setImageIndex( u32 imageIndex ) - { ImageIndex = imageIndex; } - - //! returns the image index of the node - virtual u32 getSelectedImageIndex() const - { return SelectedImageIndex; } - - //! sets the image index of the node - virtual void setSelectedImageIndex( u32 imageIndex ) - { SelectedImageIndex = imageIndex; } - - //! returns the user data (void*) of this node - virtual void* getData() const - { return Data; } - - //! sets the user data (void*) of this node - virtual void setData( void* data ) - { Data = data; } - - //! returns the user data2 (IReferenceCounted) of this node - virtual IReferenceCounted* getData2() const - { return Data2; } - - //! sets the user data2 (IReferenceCounted) of this node - virtual void setData2( IReferenceCounted* data ) - { - if( Data2 ) - { - Data2->drop(); - } - Data2 = data; - if( Data2 ) - { - Data2->grab(); - } - } - - //! returns the child item count - virtual u32 getChildCount() const - { return Childs.getSize(); } - - //! removes all childs (recursive) from this node - virtual void clearChilds(); - - //! returns true if this node has child nodes - virtual bool hasChilds() const - { return !Childs.empty(); } - - //! Adds a new node behind the last child node. - //! \param text text of the new node - //! \param icon icon text of the new node - //! \param imageIndex index of the image for the new node (-1 = none) - //! \param selectedImageIndex index of the selected image for the new node (-1 = same as imageIndex) - //! \param data user data (void*) of the new node - //! \param data2 user data2 (IReferenceCounted*) of the new node - //! \return - //! returns the new node - virtual IGUITreeViewNode* addChildBack( - const wchar_t* text, - const wchar_t* icon = 0, - s32 imageIndex = -1, - s32 selectedImageIndex = -1, - void* data = 0, - IReferenceCounted* data2 = 0); - - //! Adds a new node before the first child node. - //! \param text text of the new node - //! \param icon icon text of the new node - //! \param imageIndex index of the image for the new node (-1 = none) - //! \param selectedImageIndex index of the selected image for the new node (-1 = same as imageIndex) - //! \param data user data (void*) of the new node - //! \param data2 user data2 (IReferenceCounted*) of the new node - //! \return - //! returns the new node - virtual IGUITreeViewNode* addChildFront( - const wchar_t* text, - const wchar_t* icon = 0, - s32 imageIndex = -1, - s32 selectedImageIndex = -1, - void* data = 0, - IReferenceCounted* data2 = 0 ); - - //! Adds a new node behind the other node. - //! The other node has also te be a child node from this node. - //! \param text text of the new node - //! \param icon icon text of the new node - //! \param imageIndex index of the image for the new node (-1 = none) - //! \param selectedImageIndex index of the selected image for the new node (-1 = same as imageIndex) - //! \param data user data (void*) of the new node - //! \param data2 user data2 (IReferenceCounted*) of the new node - //! \return - //! returns the new node or 0 if other is no child node from this - virtual IGUITreeViewNode* insertChildAfter( - IGUITreeViewNode* other, - const wchar_t* text, - const wchar_t* icon = 0, - s32 imageIndex = -1, - s32 selectedImageIndex = -1, - void* data = 0, - IReferenceCounted* data2 = 0 ); - - //! Adds a new node before the other node. - //! The other node has also te be a child node from this node. - //! \param text text of the new node - //! \param icon icon text of the new node - //! \param imageIndex index of the image for the new node (-1 = none) - //! \param selectedImageIndex index of the selected image for the new node (-1 = same as imageIndex) - //! \param data user data (void*) of the new node - //! \param data2 user data2 (IReferenceCounted*) of the new node - //! \return - //! returns the new node or 0 if other is no child node from this - virtual IGUITreeViewNode* insertChildBefore( - IGUITreeViewNode* other, - const wchar_t* text, - const wchar_t* icon = 0, - s32 imageIndex = -1, - s32 selectedImageIndex = -1, - void* data = 0, - IReferenceCounted* data2 = 0 ); - - //! Return the first child note from this node. - virtual IGUITreeViewNode* getFirstChild() const; - - //! Return the last child note from this node. - virtual IGUITreeViewNode* getLastChild() const; - - //! Returns the preverse sibling node from this node. - virtual IGUITreeViewNode* getPrevSibling() const; - - //! Returns the next sibling node from this node. - virtual IGUITreeViewNode* getNextSibling() const; - - //! Returns the next visible (expanded, may be out of scrolling) node from this node. - virtual IGUITreeViewNode* getNextVisible() const; - - //! Deletes a child node. - virtual bool deleteChild( IGUITreeViewNode* child ); - - //! Moves a child node one position up. - virtual bool moveChildUp( IGUITreeViewNode* child ); - - //! Moves a child node one position down. - virtual bool moveChildDown( IGUITreeViewNode* child ); - - //! Returns true if the node is expanded (childs are visible). - virtual bool getExpanded() const - { return Expanded; } - - //! Sets if the node is expanded. - virtual void setExpanded( bool expanded ); - - //! Returns true if the node is currently selected. - virtual bool getSelected() const; - - //! Sets this node as selected. - virtual void setSelected( bool selected ); - - //! Returns true if this node is the root node. - virtual bool isRoot() const; - - //! Returns the level of this node. - virtual s32 getLevel() const; - - //! Returns true if this node is visible (all parents are expanded). - virtual bool isVisible() const; - - private: - - CGUITreeView* Owner; - CGUITreeViewNode* Parent; - core::stringw Text; - core::stringw Icon; - s32 ImageIndex; - s32 SelectedImageIndex; - void* Data; - IReferenceCounted* Data2; - bool Expanded; - core::list<CGUITreeViewNode*> Childs; - }; - - - //! Default tree view GUI element. - class CGUITreeView : public IGUITreeView - { - friend class CGUITreeViewNode; - - public: - //! constructor - CGUITreeView( IGUIEnvironment* environment, IGUIElement* parent, - s32 id, core::rect<s32> rectangle, bool clip = true, - bool drawBack = false, bool scrollBarVertical = true, bool scrollBarHorizontal = true ); - - //! destructor - virtual ~CGUITreeView(); - - //! returns the root node (not visible) from the tree. - virtual IGUITreeViewNode* getRoot() const - { return Root; } - - //! returns the selected node of the tree or 0 if none is selected - virtual IGUITreeViewNode* getSelected() const - { return Selected; } - - //! returns true if the tree lines are visible - virtual bool getLinesVisible() const - { return LinesVisible; } - - //! sets if the tree lines are visible - virtual void setLinesVisible( bool visible ) - { LinesVisible = visible; } - - //! called if an event happened. - virtual bool OnEvent( const SEvent &event ); - - //! draws the element and its children - virtual void draw(); - - //! Sets the font which should be used as icon font. This font is set to the Irrlicht engine - //! built-in-font by default. Icons can be displayed in front of every list item. - //! An icon is a string, displayed with the icon font. When using the build-in-font of the - //! Irrlicht engine as icon font, the icon strings defined in GUIIcons.h can be used. - virtual void setIconFont( IGUIFont* font ); - - //! Sets the image list which should be used for the image and selected image of every node. - //! The default is 0 (no images). - virtual void setImageList( IGUIImageList* imageList ); - - //! Returns the image list which is used for the nodes. - virtual IGUIImageList* getImageList() const - { return ImageList; } - - //! Sets if the image is left of the icon. Default is true. - virtual void setImageLeftOfIcon( bool bLeftOf ) - { ImageLeftOfIcon = bLeftOf; } - - //! Returns if the Image is left of the icon. Default is true. - virtual bool getImageLeftOfIcon() const - { return ImageLeftOfIcon; } - - //! Returns the node which is associated to the last event. - virtual IGUITreeViewNode* getLastEventNode() const - { return LastEventNode; } - - private: - //! calculates the heigth of an node and of all visible nodes. - void recalculateItemHeight(); - - //! executes an mouse action (like selectNew of CGUIListBox) - void mouseAction( s32 xpos, s32 ypos, bool onlyHover = false ); - - CGUITreeViewNode* Root; - IGUITreeViewNode* Selected; - s32 ItemHeight; - s32 IndentWidth; - s32 TotalItemHeight; - s32 TotalItemWidth; - IGUIFont* Font; - IGUIFont* IconFont; - IGUIScrollBar* ScrollBarH; - IGUIScrollBar* ScrollBarV; - IGUIImageList* ImageList; - IGUITreeViewNode* LastEventNode; - bool LinesVisible; - bool Selecting; - bool Clip; - bool DrawBack; - bool ImageLeftOfIcon; - }; - - -} // end namespace gui -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CGUIWindow.cpp b/irrlicht-1.6/source/Irrlicht/CGUIWindow.cpp deleted file mode 100644 index 982a83336..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIWindow.cpp +++ /dev/null @@ -1,343 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUIWindow.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUISkin.h" -#include "IGUIEnvironment.h" -#include "IVideoDriver.h" -#include "IGUIButton.h" -#include "IGUIFont.h" -#include "IGUIFontBitmap.h" - -namespace irr -{ -namespace gui -{ - -//! constructor -CGUIWindow::CGUIWindow(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle) -: IGUIWindow(environment, parent, id, rectangle), Dragging(false), IsDraggable(true), DrawBackground(true), DrawTitlebar(true) -{ - #ifdef _DEBUG - setDebugName("CGUIWindow"); - #endif - - IGUISkin* skin = 0; - if (environment) - skin = environment->getSkin(); - - IGUISpriteBank* sprites = 0; - video::SColor color(255,255,255,255); - - s32 buttonw = 15; - if (skin) - { - buttonw = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH); - sprites = skin->getSpriteBank(); - color = skin->getColor(EGDC_WINDOW_SYMBOL); - } - s32 posx = RelativeRect.getWidth() - buttonw - 4; - - CloseButton = Environment->addButton(core::rect<s32>(posx, 3, posx + buttonw, 3 + buttonw), this, -1, - L"", skin ? skin->getDefaultText(EGDT_WINDOW_CLOSE) : L"Close" ); - CloseButton->setSubElement(true); - CloseButton->setTabStop(false); - CloseButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - if (sprites) - { - CloseButton->setSpriteBank(sprites); - CloseButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_CLOSE), color); - CloseButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_CLOSE), color); - } - posx -= buttonw + 2; - - RestoreButton = Environment->addButton(core::rect<s32>(posx, 3, posx + buttonw, 3 + buttonw), this, -1, - L"", skin ? skin->getDefaultText(EGDT_WINDOW_RESTORE) : L"Restore" ); - RestoreButton->setVisible(false); - RestoreButton->setSubElement(true); - RestoreButton->setTabStop(false); - RestoreButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - if (sprites) - { - RestoreButton->setSpriteBank(sprites); - RestoreButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_RESTORE), color); - RestoreButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_RESTORE), color); - } - posx -= buttonw + 2; - - MinButton = Environment->addButton(core::rect<s32>(posx, 3, posx + buttonw, 3 + buttonw), this, -1, - L"", skin ? skin->getDefaultText(EGDT_WINDOW_MINIMIZE) : L"Minimize" ); - MinButton->setVisible(false); - MinButton->setSubElement(true); - MinButton->setTabStop(false); - MinButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - if (sprites) - { - MinButton->setSpriteBank(sprites); - MinButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_MINIMIZE), color); - MinButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_MINIMIZE), color); - } - - MinButton->grab(); - RestoreButton->grab(); - CloseButton->grab(); - - // this element is a tab group - setTabGroup(true); - setTabStop(true); - setTabOrder(-1); -} - - -//! destructor -CGUIWindow::~CGUIWindow() -{ - if (MinButton) - MinButton->drop(); - - if (RestoreButton) - RestoreButton->drop(); - - if (CloseButton) - CloseButton->drop(); -} - - -//! called if an event happened. -bool CGUIWindow::OnEvent(const SEvent& event) -{ - if (IsEnabled) - { - - switch(event.EventType) - { - case EET_GUI_EVENT: - if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST) - { - Dragging = false; - } - else - if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUSED) - { - if (Parent && ((event.GUIEvent.Caller == this) || isMyChild(event.GUIEvent.Caller))) - Parent->bringToFront(this); - } - else - if (event.GUIEvent.EventType == EGET_BUTTON_CLICKED) - { - if (event.GUIEvent.Caller == CloseButton) - { - if (Parent) - { - // send close event to parent - SEvent e; - e.EventType = EET_GUI_EVENT; - e.GUIEvent.Caller = this; - e.GUIEvent.Element = 0; - e.GUIEvent.EventType = EGET_ELEMENT_CLOSED; - - // if the event was not absorbed - if (!Parent->OnEvent(e)) - remove(); - - return true; - - } - else - { - remove(); - return true; - } - } - } - break; - case EET_MOUSE_INPUT_EVENT: - switch(event.MouseInput.Event) - { - case EMIE_LMOUSE_PRESSED_DOWN: - DragStart.X = event.MouseInput.X; - DragStart.Y = event.MouseInput.Y; - Dragging = IsDraggable; - if (Parent) - Parent->bringToFront(this); - return true; - case EMIE_LMOUSE_LEFT_UP: - Dragging = false; - return true; - case EMIE_MOUSE_MOVED: - if ( !event.MouseInput.isLeftPressed() ) - Dragging = false; - - if (Dragging) - { - // gui window should not be dragged outside its parent - if (Parent && - (event.MouseInput.X < Parent->getAbsolutePosition().UpperLeftCorner.X +1 || - event.MouseInput.Y < Parent->getAbsolutePosition().UpperLeftCorner.Y +1 || - event.MouseInput.X > Parent->getAbsolutePosition().LowerRightCorner.X -1 || - event.MouseInput.Y > Parent->getAbsolutePosition().LowerRightCorner.Y -1)) - return true; - - move(core::position2d<s32>(event.MouseInput.X - DragStart.X, event.MouseInput.Y - DragStart.Y)); - DragStart.X = event.MouseInput.X; - DragStart.Y = event.MouseInput.Y; - return true; - } - break; - default: - break; - } - default: - break; - } - } - - return IGUIElement::OnEvent(event); -} - - -//! Updates the absolute position. -void CGUIWindow::updateAbsolutePosition() -{ - IGUIElement::updateAbsolutePosition(); -} - - -//! draws the element and its children -void CGUIWindow::draw() -{ - if ( IsVisible ) - { - IGUISkin* skin = Environment->getSkin(); - - core::rect<s32> rect = AbsoluteRect; - - // draw body fast - if ( DrawBackground ) - { - rect = skin->draw3DWindowBackground(this, DrawTitlebar, skin->getColor(EGDC_ACTIVE_BORDER), - AbsoluteRect, &AbsoluteClippingRect); - - if (DrawTitlebar && Text.size()) - { - rect.UpperLeftCorner.X += skin->getSize(EGDS_TITLEBARTEXT_DISTANCE_X); - rect.UpperLeftCorner.Y += skin->getSize(EGDS_TITLEBARTEXT_DISTANCE_Y); - rect.LowerRightCorner.X -= skin->getSize(EGDS_WINDOW_BUTTON_WIDTH) + 5; - - IGUIFont* font = skin->getFont(EGDF_WINDOW); - if (font) - { - font->draw(Text.c_str(), rect, - skin->getColor(EGDC_ACTIVE_CAPTION), false, true, &AbsoluteClippingRect); - } - } - } - } - - IGUIElement::draw(); -} - - -//! Returns pointer to the close button -IGUIButton* CGUIWindow::getCloseButton() const -{ - return CloseButton; -} - - -//! Returns pointer to the minimize button -IGUIButton* CGUIWindow::getMinimizeButton() const -{ - return MinButton; -} - - -//! Returns pointer to the maximize button -IGUIButton* CGUIWindow::getMaximizeButton() const -{ - return RestoreButton; -} - -//! Returns true if the window is draggable, false if not -bool CGUIWindow::isDraggable() const -{ - return IsDraggable; -} - -//! Sets whether the window is draggable -void CGUIWindow::setDraggable(bool draggable) -{ - IsDraggable = draggable; - - if (Dragging && !IsDraggable) - Dragging = false; -} - -//! Set if the window background will be drawn -void CGUIWindow::setDrawBackground(bool draw) -{ - DrawBackground = draw; -} - -//! Get if the window background will be drawn -bool CGUIWindow::getDrawBackground() const -{ - return DrawBackground; -} - -//! Set if the window titlebar will be drawn -void CGUIWindow::setDrawTitlebar(bool draw) -{ - DrawTitlebar = draw; -} - -//! Get if the window titlebar will be drawn -bool CGUIWindow::getDrawTitlebar() const -{ - return DrawTitlebar; -} - -//! Writes attributes of the element. -void CGUIWindow::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const -{ - IGUIWindow::serializeAttributes(out,options); - - out->addBool("IsDraggable", IsDraggable); - out->addBool("DrawBackground", DrawBackground); - out->addBool("DrawTitlebar", DrawTitlebar); - - // Currently we can't just serialize attributes of sub-elements. - // To do this we either - // a) allow further serialization after attribute serialiation (second function, callback or event) - // b) add an IGUIElement attribute - // c) extend the attribute system to allow attributes to have sub-attributes - // We just serialize the most important info for now until we can do one of the above solutions. - out->addBool("IsCloseVisible", CloseButton->isVisible()); - out->addBool("IsMinVisible", MinButton->isVisible()); - out->addBool("IsRestoreVisible", RestoreButton->isVisible()); -} - - -//! Reads attributes of the element -void CGUIWindow::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) -{ - IGUIWindow::deserializeAttributes(in,options); - - Dragging = false; - IsDraggable = in->getAttributeAsBool("IsDraggable"); - DrawBackground = in->getAttributeAsBool("DrawBackground"); - DrawTitlebar = in->getAttributeAsBool("DrawTitlebar"); - - CloseButton->setVisible( in->getAttributeAsBool("IsCloseVisible") ); - MinButton->setVisible( in->getAttributeAsBool("IsMinVisible") ); - RestoreButton->setVisible( in->getAttributeAsBool("IsRestoreVisible") ); -} - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - diff --git a/irrlicht-1.6/source/Irrlicht/CGUIWindow.h b/irrlicht-1.6/source/Irrlicht/CGUIWindow.h deleted file mode 100644 index 608c5fd33..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGUIWindow.h +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_WINDOW_H_INCLUDED__ -#define __C_GUI_WINDOW_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_GUI_ - -#include "IGUIWindow.h" - -namespace irr -{ -namespace gui -{ - class IGUIButton; - - class CGUIWindow : public IGUIWindow - { - public: - - //! constructor - CGUIWindow(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle); - - //! destructor - virtual ~CGUIWindow(); - - //! called if an event happened. - virtual bool OnEvent(const SEvent& event); - - //! update absolute position - virtual void updateAbsolutePosition(); - - //! draws the element and its children - virtual void draw(); - - //! Returns pointer to the close button - virtual IGUIButton* getCloseButton() const; - - //! Returns pointer to the minimize button - virtual IGUIButton* getMinimizeButton() const; - - //! Returns pointer to the maximize button - virtual IGUIButton* getMaximizeButton() const; - - //! Returns true if the window is draggable, false if not - virtual bool isDraggable() const; - - //! Sets whether the window is draggable - virtual void setDraggable(bool draggable); - - //! Set if the window background will be drawn - virtual void setDrawBackground(bool draw); - - //! Get if the window background will be drawn - virtual bool getDrawBackground() const; - - //! Set if the window titlebar will be drawn - //! Note: If the background is not drawn, then the titlebar is automatically also not drawn - virtual void setDrawTitlebar(bool draw); - - //! Get if the window titlebar will be drawn - virtual bool getDrawTitlebar() const; - - //! Writes attributes of the element. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; - - //! Reads attributes of the element - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - - protected: - - IGUIButton* CloseButton; - IGUIButton* MinButton; - IGUIButton* RestoreButton; - - core::position2d<s32> DragStart; - bool Dragging, IsDraggable; - bool DrawBackground; - bool DrawTitlebar; - }; - -} // end namespace gui -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_GUI_ - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CGeometryCreator.cpp b/irrlicht-1.6/source/Irrlicht/CGeometryCreator.cpp deleted file mode 100644 index d3210fa71..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGeometryCreator.cpp +++ /dev/null @@ -1,889 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGeometryCreator.h" -#include "SAnimatedMesh.h" -#include "SMeshBuffer.h" -#include "SMesh.h" -#include "IMesh.h" -#include "IVideoDriver.h" -#include "CImage.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - -IMesh* CGeometryCreator::createCubeMesh(const core::vector3df& size) const -{ - SMeshBuffer* buffer = new SMeshBuffer(); - - // Create indices - const u16 u[36] = { 0,2,1, 0,3,2, 1,5,4, 1,2,5, 4,6,7, 4,5,6, - 7,3,0, 7,6,3, 9,5,2, 9,8,5, 0,11,10, 0,10,7}; - - buffer->Indices.set_used(36); - - for (u32 i=0; i<36; ++i) - buffer->Indices[i] = u[i]; - - - // Create vertices - video::SColor clr(255,255,255,255); - - buffer->Vertices.reallocate(12); - - buffer->Vertices.push_back(video::S3DVertex(0,0,0, -1,-1,-1, clr, 0, 1)); - buffer->Vertices.push_back(video::S3DVertex(1,0,0, 1,-1,-1, clr, 1, 1)); - buffer->Vertices.push_back(video::S3DVertex(1,1,0, 1, 1,-1, clr, 1, 0)); - buffer->Vertices.push_back(video::S3DVertex(0,1,0, -1, 1,-1, clr, 0, 0)); - buffer->Vertices.push_back(video::S3DVertex(1,0,1, 1,-1, 1, clr, 0, 1)); - buffer->Vertices.push_back(video::S3DVertex(1,1,1, 1, 1, 1, clr, 0, 0)); - buffer->Vertices.push_back(video::S3DVertex(0,1,1, -1, 1, 1, clr, 1, 0)); - buffer->Vertices.push_back(video::S3DVertex(0,0,1, -1,-1, 1, clr, 1, 1)); - buffer->Vertices.push_back(video::S3DVertex(0,1,1, -1, 1, 1, clr, 0, 1)); - buffer->Vertices.push_back(video::S3DVertex(0,1,0, -1, 1,-1, clr, 1, 1)); - buffer->Vertices.push_back(video::S3DVertex(1,0,1, 1,-1, 1, clr, 1, 0)); - buffer->Vertices.push_back(video::S3DVertex(1,0,0, 1,-1,-1, clr, 0, 0)); - - // Recalculate bounding box - buffer->BoundingBox.reset(0,0,0); - - for (u32 i=0; i<12; ++i) - { - buffer->Vertices[i].Pos -= core::vector3df(0.5f, 0.5f, 0.5f); - buffer->Vertices[i].Pos *= size; - buffer->BoundingBox.addInternalPoint(buffer->Vertices[i].Pos); - } - - SMesh* mesh = new SMesh; - mesh->addMeshBuffer(buffer); - buffer->drop(); - - mesh->recalculateBoundingBox(); - return mesh; -} - - -// creates a hill plane -IMesh* CGeometryCreator::createHillPlaneMesh( - const core::dimension2d<f32>& tileSize, - const core::dimension2d<u32>& tc, video::SMaterial* material, - f32 hillHeight, const core::dimension2d<f32>& ch, - const core::dimension2d<f32>& textureRepeatCount) const -{ - core::dimension2d<u32> tileCount = tc; - core::dimension2d<f32> countHills = ch; - - if (countHills.Width < 0.01f) - countHills.Width = 1.f; - if (countHills.Height < 0.01f) - countHills.Height = 1.f; - - // center - const core::position2d<f32> center((tileSize.Width * tileCount.Width) * 0.5f, (tileSize.Height * tileCount.Height) * 0.5f); - - // texture coord step - const core::dimension2d<f32> tx( - textureRepeatCount.Width / tileCount.Width, - textureRepeatCount.Height / tileCount.Height); - - // add one more point in each direction for proper tile count - ++tileCount.Height; - ++tileCount.Width; - - SMeshBuffer* buffer = new SMeshBuffer(); - video::S3DVertex vtx; - vtx.Color.set(255,255,255,255); - - // create vertices from left-front to right-back - u32 x; - - f32 sx=0.f, tsx=0.f; - for (x=0; x<tileCount.Width; ++x) - { - f32 sy=0.f, tsy=0.f; - for (u32 y=0; y<tileCount.Height; ++y) - { - vtx.Pos.set(sx - center.X, 0, sy - center.Y); - vtx.TCoords.set(tsx, 1.0f - tsy); - - if (hillHeight != 0.0f) - vtx.Pos.Y = sinf(vtx.Pos.X * countHills.Width * core::PI / center.X) * - cosf(vtx.Pos.Z * countHills.Height * core::PI / center.Y) * - hillHeight; - - buffer->Vertices.push_back(vtx); - sy += tileSize.Height; - tsy += tx.Height; - } - sx += tileSize.Width; - tsx += tx.Width; - } - - // create indices - - for (x=0; x<tileCount.Width-1; ++x) - { - for (u32 y=0; y<tileCount.Height-1; ++y) - { - const s32 current = x*tileCount.Height + y; - - buffer->Indices.push_back(current); - buffer->Indices.push_back(current + 1); - buffer->Indices.push_back(current + tileCount.Height); - - buffer->Indices.push_back(current + 1); - buffer->Indices.push_back(current + 1 + tileCount.Height); - buffer->Indices.push_back(current + tileCount.Height); - } - } - - // recalculate normals - for (u32 i=0; i<buffer->Indices.size(); i+=3) - { - const core::vector3df normal = core::plane3d<f32>( - buffer->Vertices[buffer->Indices[i+0]].Pos, - buffer->Vertices[buffer->Indices[i+1]].Pos, - buffer->Vertices[buffer->Indices[i+2]].Pos).Normal; - - buffer->Vertices[buffer->Indices[i+0]].Normal = normal; - buffer->Vertices[buffer->Indices[i+1]].Normal = normal; - buffer->Vertices[buffer->Indices[i+2]].Normal = normal; - } - - if (material) - buffer->Material = *material; - - buffer->recalculateBoundingBox(); - - SMesh* mesh = new SMesh(); - mesh->addMeshBuffer(buffer); - mesh->recalculateBoundingBox(); - buffer->drop(); - return mesh; -} - - -IMesh* CGeometryCreator::createTerrainMesh(video::IImage* texture, - video::IImage* heightmap, const core::dimension2d<f32>& stretchSize, - f32 maxHeight, video::IVideoDriver* driver, - const core::dimension2d<u32>& maxVtxBlockSize, - bool debugBorders) const -{ - if (!texture || !heightmap) - return 0; - - // debug border - const s32 borderSkip = debugBorders ? 0 : 1; - - video::S3DVertex vtx; - vtx.Color.set(255,255,255,255); - - SMesh* mesh = new SMesh(); - - const u32 tm = os::Timer::getRealTime()/1000; - const core::dimension2d<u32> hMapSize= heightmap->getDimension(); - const core::dimension2d<u32> tMapSize= texture->getDimension(); - const core::position2d<f32> thRel(static_cast<f32>(tMapSize.Width) / hMapSize.Width, static_cast<f32>(tMapSize.Height) / hMapSize.Height); - maxHeight /= 255.0f; // height step per color value - - core::position2d<u32> processed(0,0); - while (processed.Y<hMapSize.Height) - { - while(processed.X<hMapSize.Width) - { - core::dimension2d<u32> blockSize = maxVtxBlockSize; - if (processed.X + blockSize.Width > hMapSize.Width) - blockSize.Width = hMapSize.Width - processed.X; - if (processed.Y + blockSize.Height > hMapSize.Height) - blockSize.Height = hMapSize.Height - processed.Y; - - SMeshBuffer* buffer = new SMeshBuffer(); - buffer->setHardwareMappingHint(scene::EHM_STATIC); - buffer->Vertices.reallocate(blockSize.getArea()); - // add vertices of vertex block - u32 y; - core::vector2df pos(0.f, processed.Y*stretchSize.Height); - const core::vector2df bs(1.f/blockSize.Width, 1.f/blockSize.Height); - core::vector2df tc(0.f, 0.5f*bs.Y); - for (y=0; y<blockSize.Height; ++y) - { - pos.X=processed.X*stretchSize.Width; - tc.X=0.5f*bs.X; - for (u32 x=0; x<blockSize.Width; ++x) - { - const f32 height = heightmap->getPixel(x+processed.X, y+processed.Y).getAverage() * maxHeight; - - vtx.Pos.set(pos.X, height, pos.Y); - vtx.TCoords.set(tc); - buffer->Vertices.push_back(vtx); - pos.X += stretchSize.Width; - tc.X += bs.X; - } - pos.Y += stretchSize.Height; - tc.Y += bs.Y; - } - - buffer->Indices.reallocate((blockSize.Height-1)*(blockSize.Width-1)*6); - // add indices of vertex block - s32 c1 = 0; - for (y=0; y<blockSize.Height-1; ++y) - { - for (u32 x=0; x<blockSize.Width-1; ++x) - { - const s32 c = c1 + x; - - buffer->Indices.push_back(c); - buffer->Indices.push_back(c + blockSize.Width); - buffer->Indices.push_back(c + 1); - - buffer->Indices.push_back(c + 1); - buffer->Indices.push_back(c + blockSize.Width); - buffer->Indices.push_back(c + 1 + blockSize.Width); - } - c1 += blockSize.Width; - } - - // recalculate normals - for (u32 i=0; i<buffer->Indices.size(); i+=3) - { - const core::vector3df normal = core::plane3d<f32>( - buffer->Vertices[buffer->Indices[i+0]].Pos, - buffer->Vertices[buffer->Indices[i+1]].Pos, - buffer->Vertices[buffer->Indices[i+2]].Pos).Normal; - - buffer->Vertices[buffer->Indices[i+0]].Normal = normal; - buffer->Vertices[buffer->Indices[i+1]].Normal = normal; - buffer->Vertices[buffer->Indices[i+2]].Normal = normal; - } - - if (buffer->Vertices.size()) - { - c8 textureName[64]; - // create texture for this block - video::IImage* img = new video::CImage(texture, - core::position2d<s32>(core::floor32(processed.X*thRel.X), core::floor32(processed.Y*thRel.Y)), - core::dimension2d<u32>(core::floor32(blockSize.Width*thRel.X), core::floor32(blockSize.Height*thRel.Y))); - - sprintf(textureName, "terrain%u_%u", tm, mesh->getMeshBufferCount()); - - buffer->Material.setTexture(0, driver->addTexture(textureName, img)); - - if (buffer->Material.getTexture(0)) - { - c8 tmp[255]; - sprintf(tmp, "Generated terrain texture (%dx%d): %s", - buffer->Material.getTexture(0)->getSize().Width, - buffer->Material.getTexture(0)->getSize().Height, - textureName); - os::Printer::log(tmp); - } - else - os::Printer::log("Could not create terrain texture.", textureName, ELL_ERROR); - - img->drop(); - } - - buffer->recalculateBoundingBox(); - mesh->addMeshBuffer(buffer); - buffer->drop(); - - // keep on processing - processed.X += maxVtxBlockSize.Width - borderSkip; - } - - // keep on processing - processed.X = 0; - processed.Y += maxVtxBlockSize.Height - borderSkip; - } - - mesh->recalculateBoundingBox(); - return mesh; -} - - -/* - a cylinder, a cone and a cross - point up on (0,1.f, 0.f ) -*/ -IMesh* CGeometryCreator::createArrowMesh(const u32 tesselationCylinder, - const u32 tesselationCone, - const f32 height, - const f32 cylinderHeight, - const f32 width0, - const f32 width1, - const video::SColor vtxColor0, - const video::SColor vtxColor1) const -{ - SMesh* mesh = (SMesh*)createCylinderMesh(width0, cylinderHeight, tesselationCylinder, vtxColor0, false); - - IMesh* mesh2 = createConeMesh(width1, height-cylinderHeight, tesselationCone, vtxColor1, vtxColor0); - for (u32 i=0; i<mesh2->getMeshBufferCount(); ++i) - { - scene::IMeshBuffer* buffer = mesh2->getMeshBuffer(i); - for (u32 j=0; j<buffer->getVertexCount(); ++j) - buffer->getPosition(j).Y += cylinderHeight; - mesh->addMeshBuffer(buffer); - } - mesh2->drop(); - - return mesh; -} - - -/* A sphere with proper normals and texture coords */ -IMesh* CGeometryCreator::createSphereMesh(f32 radius, u32 polyCountX, u32 polyCountY) const -{ - SMeshBuffer* buffer = new SMeshBuffer(); - - // thanks to Alfaz93 who made his code available for Irrlicht on which - // this one is based! - - // we are creating the sphere mesh here. - - if (polyCountX < 2) - polyCountX = 2; - if (polyCountY < 2) - polyCountY = 2; - if (polyCountX * polyCountY > 32767) // prevent u16 overflow - { - if (polyCountX > polyCountY) // prevent u16 overflow - polyCountX = 32767/polyCountY-1; - else - polyCountY = 32767/(polyCountX+1); - } - - u32 polyCountXPitch = polyCountX+1; // get to same vertex on next level - buffer->Vertices.set_used((polyCountXPitch * polyCountY) + 2); - buffer->Indices.set_used((polyCountX * polyCountY) * 6); - - const video::SColor clr(100, 255,255,255); - - u32 i=0; - u32 level = 0; - - for (u32 p1 = 0; p1 < polyCountY-1; ++p1) - { - //main quads, top to bottom - for (u32 p2 = 0; p2 < polyCountX - 1; ++p2) - { - const u32 curr = level + p2; - buffer->Indices[i] = curr + polyCountXPitch; - buffer->Indices[++i] = curr; - buffer->Indices[++i] = curr + 1; - buffer->Indices[++i] = curr + polyCountXPitch; - buffer->Indices[++i] = curr+1; - buffer->Indices[++i] = curr + 1 + polyCountXPitch; - ++i; - } - - // the connectors from front to end - buffer->Indices[i] = level + polyCountX - 1 + polyCountXPitch; - buffer->Indices[++i] = level + polyCountX - 1; - buffer->Indices[++i] = level + polyCountX; - ++i; - - buffer->Indices[i] = level + polyCountX - 1 + polyCountXPitch; - buffer->Indices[++i] = level + polyCountX; - buffer->Indices[++i] = level + polyCountX + polyCountXPitch; - ++i; - level += polyCountXPitch; - } - - const u32 polyCountSq = polyCountXPitch * polyCountY; // top point - const u32 polyCountSq1 = polyCountSq + 1; // bottom point - const u32 polyCountSqM1 = (polyCountY - 1) * polyCountXPitch; // last row's first vertex - - for (u32 p2 = 0; p2 < polyCountX - 1; ++p2) - { - // create triangles which are at the top of the sphere - - buffer->Indices[i] = polyCountSq; - buffer->Indices[++i] = p2 + 1; - buffer->Indices[++i] = p2; - ++i; - - // create triangles which are at the bottom of the sphere - - buffer->Indices[i] = polyCountSqM1 + p2; - buffer->Indices[++i] = polyCountSqM1 + p2 + 1; - buffer->Indices[++i] = polyCountSq1; - ++i; - } - - // create final triangle which is at the top of the sphere - - buffer->Indices[i] = polyCountSq; - buffer->Indices[++i] = polyCountX; - buffer->Indices[++i] = polyCountX-1; - ++i; - - // create final triangle which is at the bottom of the sphere - - buffer->Indices[i] = polyCountSqM1 + polyCountX - 1; - buffer->Indices[++i] = polyCountSqM1; - buffer->Indices[++i] = polyCountSq1; - - // calculate the angle which separates all points in a circle - const f64 AngleX = 2 * core::PI / polyCountX; - const f64 AngleY = core::PI / polyCountY; - - i = 0; - f64 axz; - - // we don't start at 0. - - f64 ay = 0;//AngleY / 2; - - for (u32 y = 0; y < polyCountY; ++y) - { - ay += AngleY; - const f64 sinay = sin(ay); - axz = 0; - - // calculate the necessary vertices without the doubled one - for (u32 xz = 0;xz < polyCountX; ++xz) - { - // calculate points position - - const core::vector3df pos(static_cast<f32>(radius * cos(axz) * sinay), - static_cast<f32>(radius * cos(ay)), - static_cast<f32>(radius * sin(axz) * sinay)); - // for spheres the normal is the position - core::vector3df normal(pos); - normal.normalize(); - - // calculate texture coordinates via sphere mapping - // tu is the same on each level, so only calculate once - f32 tu = 0.5f; - if (y==0) - { - if (normal.Y != -1.0f && normal.Y != 1.0f) - tu = static_cast<f32>(acos(core::clamp(normal.X/sinay, -1.0, 1.0)) * 0.5 *core::RECIPROCAL_PI64); - if (normal.Z < 0.0f) - tu=1-tu; - } - else - tu = buffer->Vertices[i-polyCountXPitch].TCoords.X; - buffer->Vertices[i] = video::S3DVertex(pos.X, pos.Y, pos.Z, - normal.X, normal.Y, normal.Z, - clr, tu, - static_cast<f32>(ay*core::RECIPROCAL_PI64)); - ++i; - axz += AngleX; - } - // This is the doubled vertex on the initial position - buffer->Vertices[i] = video::S3DVertex(buffer->Vertices[i-polyCountX]); - buffer->Vertices[i].TCoords.X=1.0f; - ++i; - } - - // the vertex at the top of the sphere - buffer->Vertices[i] = video::S3DVertex(0.0f,radius,0.0f, 0.0f,1.0f,0.0f, clr, 0.5f, 0.0f); - - // the vertex at the bottom of the sphere - ++i; - buffer->Vertices[i] = video::S3DVertex(0.0f,-radius,0.0f, 0.0f,-1.0f,0.0f, clr, 0.5f, 1.0f); - - // recalculate bounding box - - buffer->BoundingBox.reset(buffer->Vertices[i].Pos); - buffer->BoundingBox.addInternalPoint(buffer->Vertices[i-1].Pos); - buffer->BoundingBox.addInternalPoint(radius,0.0f,0.0f); - buffer->BoundingBox.addInternalPoint(-radius,0.0f,0.0f); - buffer->BoundingBox.addInternalPoint(0.0f,0.0f,radius); - buffer->BoundingBox.addInternalPoint(0.0f,0.0f,-radius); - - SMesh* mesh = new SMesh(); - mesh->addMeshBuffer(buffer); - buffer->drop(); - - mesh->recalculateBoundingBox(); - return mesh; -} - - -/* A cylinder with proper normals and texture coords */ -IMesh* CGeometryCreator::createCylinderMesh(f32 radius, f32 length, - u32 tesselation, const video::SColor& color, - bool closeTop, f32 oblique) const -{ - SMeshBuffer* buffer = new SMeshBuffer(); - - const f32 recTesselation = core::reciprocal((f32)tesselation); - const f32 recTesselationHalf = recTesselation * 0.5f; - const f32 angleStep = (core::PI * 2.f ) * recTesselation; - const f32 angleStepHalf = angleStep*0.5f; - - u32 i; - video::S3DVertex v; - v.Color = color; - buffer->Vertices.reallocate(tesselation*4+(closeTop?2:1)); - buffer->Indices.reallocate((tesselation*2)*(closeTop?12:9)); - f32 tcx = 0.f; - for ( i = 0; i != tesselation; ++i ) - { - const f32 angle = angleStep * i; - v.Pos.X = radius * cosf(angle); - v.Pos.Y = 0.f; - v.Pos.Z = radius * sinf(angle); - v.Normal = v.Pos; - v.Normal.normalize(); - v.TCoords.X=tcx; - v.TCoords.Y=0.f; - buffer->Vertices.push_back(v); - - v.Pos.X += oblique; - v.Pos.Y = length; - v.Normal = v.Pos; - v.Normal.normalize(); - v.TCoords.Y=1.f; - buffer->Vertices.push_back(v); - - v.Pos.X = radius * cosf(angle + angleStepHalf); - v.Pos.Y = 0.f; - v.Pos.Z = radius * sinf(angle + angleStepHalf); - v.Normal = v.Pos; - v.Normal.normalize(); - v.TCoords.X=tcx+recTesselationHalf; - v.TCoords.Y=0.f; - buffer->Vertices.push_back(v); - - v.Pos.X += oblique; - v.Pos.Y = length; - v.Normal = v.Pos; - v.Normal.normalize(); - v.TCoords.Y=1.f; - buffer->Vertices.push_back(v); - tcx += recTesselation; - } - - const u32 nonWrappedSize = ( tesselation* 4 ) - 2; - for ( i = 0; i != nonWrappedSize; i += 2 ) - { - buffer->Indices.push_back(i + 2); - buffer->Indices.push_back(i + 0); - buffer->Indices.push_back(i + 1); - - buffer->Indices.push_back(i + 2); - buffer->Indices.push_back(i + 1); - buffer->Indices.push_back(i + 3); - } - - buffer->Indices.push_back(0); - buffer->Indices.push_back(i + 0); - buffer->Indices.push_back(i + 1); - - buffer->Indices.push_back(0); - buffer->Indices.push_back(i + 1); - buffer->Indices.push_back(1); - - // close down - v.Pos.X = 0.f; - v.Pos.Y = 0.f; - v.Pos.Z = 0.f; - v.Normal.X = 0.f; - v.Normal.Y = -1.f; - v.Normal.Z = 0.f; - v.TCoords.X = 1.f; - v.TCoords.Y = 1.f; - buffer->Vertices.push_back(v); - - u32 index = buffer->Vertices.size() - 1; - - for ( i = 0; i != nonWrappedSize; i += 2 ) - { - buffer->Indices.push_back(index); - buffer->Indices.push_back(i + 0); - buffer->Indices.push_back(i + 2); - } - - buffer->Indices.push_back(index); - buffer->Indices.push_back(i + 0); - buffer->Indices.push_back(0); - - if (closeTop) - { - // close top - v.Pos.X = oblique; - v.Pos.Y = length; - v.Pos.Z = 0.f; - v.Normal.X = 0.f; - v.Normal.Y = 1.f; - v.Normal.Z = 0.f; - v.TCoords.X = 0.f; - v.TCoords.Y = 0.f; - buffer->Vertices.push_back(v); - - index = buffer->Vertices.size() - 1; - - for ( i = 0; i != nonWrappedSize; i += 2 ) - { - buffer->Indices.push_back(i + 1); - buffer->Indices.push_back(index); - buffer->Indices.push_back(i + 3); - } - - buffer->Indices.push_back(i + 1); - buffer->Indices.push_back(index); - buffer->Indices.push_back(1); - } - - buffer->recalculateBoundingBox(); - SMesh* mesh = new SMesh(); - mesh->addMeshBuffer(buffer); - mesh->recalculateBoundingBox(); - buffer->drop(); - return mesh; -} - - -/* A cone with proper normals and texture coords */ -IMesh* CGeometryCreator::createConeMesh(f32 radius, f32 length, u32 tesselation, - const video::SColor& colorTop, - const video::SColor& colorBottom, f32 oblique) const -{ - SMeshBuffer* buffer = new SMeshBuffer(); - - const f32 angleStep = (core::PI * 2.f ) / tesselation; - const f32 angleStepHalf = angleStep*0.5f; - - video::S3DVertex v; - u32 i; - - v.Color = colorTop; - for ( i = 0; i != tesselation; ++i ) - { - f32 angle = angleStep * f32(i); - - v.Pos.X = radius * cosf(angle); - v.Pos.Y = 0.f; - v.Pos.Z = radius * sinf(angle); - v.Normal = v.Pos; - v.Normal.normalize(); - buffer->Vertices.push_back(v); - - angle += angleStepHalf; - v.Pos.X = radius * cosf(angle); - v.Pos.Y = 0.f; - v.Pos.Z = radius * sinf(angle); - v.Normal = v.Pos; - v.Normal.normalize(); - buffer->Vertices.push_back(v); - } - const u32 nonWrappedSize = buffer->Vertices.size() - 1; - - // close top - v.Pos.X = oblique; - v.Pos.Y = length; - v.Pos.Z = 0.f; - v.Normal.X = 0.f; - v.Normal.Y = 1.f; - v.Normal.Z = 0.f; - buffer->Vertices.push_back(v); - - u32 index = buffer->Vertices.size() - 1; - - for ( i = 0; i != nonWrappedSize; i += 1 ) - { - buffer->Indices.push_back(i + 0); - buffer->Indices.push_back(index); - buffer->Indices.push_back(i + 1); - } - - buffer->Indices.push_back(i + 0); - buffer->Indices.push_back(index); - buffer->Indices.push_back(0); - - // close down - v.Color = colorBottom; - v.Pos.X = 0.f; - v.Pos.Y = 0.f; - v.Pos.Z = 0.f; - v.Normal.X = 0.f; - v.Normal.Y = -1.f; - v.Normal.Z = 0.f; - buffer->Vertices.push_back(v); - - index = buffer->Vertices.size() - 1; - - for ( i = 0; i != nonWrappedSize; i += 1 ) - { - buffer->Indices.push_back(index); - buffer->Indices.push_back(i + 0); - buffer->Indices.push_back(i + 1); - } - - buffer->Indices.push_back(index); - buffer->Indices.push_back(i + 0); - buffer->Indices.push_back(0); - - buffer->recalculateBoundingBox(); - SMesh* mesh = new SMesh(); - mesh->addMeshBuffer(buffer); - buffer->drop(); - - mesh->recalculateBoundingBox(); - return mesh; -} - - -void CGeometryCreator::addToBuffer(const video::S3DVertex& v, SMeshBuffer* Buffer) const -{ - const s32 tnidx = Buffer->Vertices.linear_reverse_search(v); - const bool alreadyIn = (tnidx != -1); - u16 nidx = (u16)tnidx; - if (!alreadyIn) - { - nidx = (u16)Buffer->Vertices.size(); - Buffer->Indices.push_back(nidx); - Buffer->Vertices.push_back(v); - } - else - Buffer->Indices.push_back(nidx); -} - - -IMesh* CGeometryCreator::createVolumeLightMesh( - const u32 subdivideU, const u32 subdivideV, - const video::SColor footColor, const video::SColor tailColor, - const f32 lpDistance, const core::vector3df& lightDim) const -{ - SMeshBuffer* Buffer = new SMeshBuffer(); - Buffer->setHardwareMappingHint(EHM_STATIC); - - const core::vector3df lightPoint(0, -(lpDistance*lightDim.Y), 0); - const f32 ax = lightDim.X * 0.5f; // X Axis - const f32 az = lightDim.Z * 0.5f; // Z Axis - - Buffer->Vertices.clear(); - Buffer->Vertices.reallocate(6+12*(subdivideU+subdivideV)); - Buffer->Indices.clear(); - Buffer->Indices.reallocate(6+12*(subdivideU+subdivideV)); - //draw the bottom foot.. the glowing region - addToBuffer(video::S3DVertex(-ax, 0, az, 0,0,0, footColor, 0, 1),Buffer); - addToBuffer(video::S3DVertex( ax, 0, az, 0,0,0, footColor, 1, 1),Buffer); - addToBuffer(video::S3DVertex( ax, 0,-az, 0,0,0, footColor, 1, 0),Buffer); - - addToBuffer(video::S3DVertex( ax, 0,-az, 0,0,0, footColor, 1, 0),Buffer); - addToBuffer(video::S3DVertex(-ax, 0,-az, 0,0,0, footColor, 0, 0),Buffer); - addToBuffer(video::S3DVertex(-ax, 0, az, 0,0,0, footColor, 0, 1),Buffer); - - f32 tu = 0.f; - const f32 tuStep = 1.f/subdivideU; - f32 bx = -ax; - const f32 bxStep = lightDim.X * tuStep; - // Slices in X/U space - for (u32 i = 0; i <= subdivideU; ++i) - { - // These are the two endpoints for a slice at the foot - core::vector3df end1(bx, 0.0f, -az); - core::vector3df end2(bx, 0.0f, az); - - end1 -= lightPoint; // get a vector from point to lightsource - end1.normalize(); // normalize vector - end1 *= lightDim.Y; // multiply it out by shootlength - - end1.X += bx; // Add the original point location to the vector - end1.Z -= az; - - // Do it again for the other point. - end2 -= lightPoint; - end2.normalize(); - end2 *= lightDim.Y; - - end2.X += bx; - end2.Z += az; - - addToBuffer(video::S3DVertex(bx , 0, az, 0,0,0, footColor, tu, 1),Buffer); - addToBuffer(video::S3DVertex(bx , 0, -az, 0,0,0, footColor, tu, 0),Buffer); - addToBuffer(video::S3DVertex(end2.X , end2.Y, end2.Z, 0,0,0, tailColor, tu, 1),Buffer); - - addToBuffer(video::S3DVertex(bx , 0, -az, 0,0,0, footColor, tu, 0),Buffer); - addToBuffer(video::S3DVertex(end1.X , end1.Y, end1.Z, 0,0,0, tailColor, tu, 0),Buffer); - addToBuffer(video::S3DVertex(end2.X , end2.Y, end2.Z, 0,0,0, tailColor, tu, 1),Buffer); - - //back side - addToBuffer(video::S3DVertex(-end2.X , end2.Y, -end2.Z, 0,0,0, tailColor, tu, 1),Buffer); - addToBuffer(video::S3DVertex(-bx , 0, -az, 0,0,0, footColor, tu, 1),Buffer); - addToBuffer(video::S3DVertex(-bx , 0, az, 0,0,0, footColor, tu, 0),Buffer); - - addToBuffer(video::S3DVertex(-bx , 0, az, 0,0,0, footColor, tu, 0),Buffer); - addToBuffer(video::S3DVertex(-end1.X , end1.Y, -end1.Z, 0,0,0, tailColor, tu, 0),Buffer); - addToBuffer(video::S3DVertex(-end2.X , end2.Y, -end2.Z, 0,0,0, tailColor, tu, 1),Buffer); - tu += tuStep; - bx += bxStep; - } - - f32 tv = 0.f; - const f32 tvStep = 1.f/subdivideV; - f32 bz = -az; - const f32 bzStep = lightDim.Z * tvStep; - // Slices in Z/V space - for(u32 i = 0; i <= subdivideV; ++i) - { - // These are the two endpoints for a slice at the foot - core::vector3df end1(-ax, 0.0f, bz); - core::vector3df end2(ax, 0.0f, bz); - - end1 -= lightPoint; // get a vector from point to lightsource - end1.normalize(); // normalize vector - end1 *= lightDim.Y; // multiply it out by shootlength - - end1.X -= ax; // Add the original point location to the vector - end1.Z += bz; - - // Do it again for the other point. - end2 -= lightPoint; - end2.normalize(); - end2 *= lightDim.Y; - - end2.X += ax; - end2.Z += bz; - - addToBuffer(video::S3DVertex(-ax , 0, bz, 0,0,0, footColor, 0, tv),Buffer); - addToBuffer(video::S3DVertex(ax , 0, bz, 0,0,0, footColor, 1, tv),Buffer); - addToBuffer(video::S3DVertex(end2.X , end2.Y, end2.Z, 0,0,0, tailColor, 1, tv),Buffer); - - addToBuffer(video::S3DVertex(end2.X , end2.Y, end2.Z, 0,0,0, tailColor, 1, tv),Buffer); - addToBuffer(video::S3DVertex(end1.X , end1.Y, end1.Z, 0,0,0, tailColor, 0, tv),Buffer); - addToBuffer(video::S3DVertex(-ax , 0, bz, 0,0,0, footColor, 0, tv),Buffer); - - //back side - addToBuffer(video::S3DVertex(ax , 0, -bz, 0,0,0, footColor, 0, tv),Buffer); - addToBuffer(video::S3DVertex(-ax , 0, -bz, 0,0,0, footColor, 1, tv),Buffer); - addToBuffer(video::S3DVertex(-end2.X , end2.Y, -end2.Z, 0,0,0, tailColor, 1, tv),Buffer); - - addToBuffer(video::S3DVertex(-end2.X , end2.Y, -end2.Z, 0,0,0, tailColor, 1, tv),Buffer); - addToBuffer(video::S3DVertex(-end1.X , end1.Y, -end1.Z, 0,0,0, tailColor, 0, tv),Buffer); - addToBuffer(video::S3DVertex(ax , 0, -bz, 0,0,0, footColor, 0, tv),Buffer); - tv += tvStep; - bz += bzStep; - } - - Buffer->recalculateBoundingBox(); - - Buffer->Material.MaterialType = video::EMT_ONETEXTURE_BLEND; - Buffer->Material.MaterialTypeParam = pack_texureBlendFunc( video::EBF_SRC_COLOR, video::EBF_SRC_ALPHA, video::EMFN_MODULATE_1X ); - - Buffer->Material.Lighting = false; - Buffer->Material.ZWriteEnable = false; - - Buffer->setDirty(EBT_VERTEX_AND_INDEX); - - Buffer->recalculateBoundingBox(); - SMesh* mesh = new SMesh(); - mesh->addMeshBuffer(Buffer); - Buffer->drop(); - - mesh->recalculateBoundingBox(); - return mesh; -} - - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CGeometryCreator.h b/irrlicht-1.6/source/Irrlicht/CGeometryCreator.h deleted file mode 100644 index fd648414c..000000000 --- a/irrlicht-1.6/source/Irrlicht/CGeometryCreator.h +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GEOMETRY_CREATOR_H_INCLUDED__ -#define __C_GEOMETRY_CREATOR_H_INCLUDED__ - -#include "IGeometryCreator.h" -#include "SMeshBuffer.h" - -namespace irr -{ - -namespace scene -{ - -//! class for creating geometry on the fly -class CGeometryCreator : public IGeometryCreator -{ - void addToBuffer(const video::S3DVertex& v, SMeshBuffer* Buffer) const; -public: - IMesh* createCubeMesh(const core::vector3df& size) const; - - IMesh* createHillPlaneMesh( - const core::dimension2d<f32>& tileSize, const core::dimension2d<u32>& tileCount, - video::SMaterial* material, f32 hillHeight, const core::dimension2d<f32>& countHills, - const core::dimension2d<f32>& textureRepeatCount) const; - - IMesh* createTerrainMesh(video::IImage* texture, - video::IImage* heightmap, const core::dimension2d<f32>& stretchSize, - f32 maxHeight, video::IVideoDriver* driver, - const core::dimension2d<u32>& defaultVertexBlockSize, - bool debugBorders=false) const; - - IMesh* createArrowMesh(const u32 tesselationCylinder, - const u32 tesselationCone, const f32 height, - const f32 cylinderHeight, const f32 width0, - const f32 width1, const video::SColor vtxColor0, - const video::SColor vtxColor1) const; - - IMesh* createSphereMesh(f32 radius, u32 polyCountX, u32 polyCountY) const; - - IMesh* createCylinderMesh(f32 radius, f32 length, u32 tesselation, - const video::SColor& color=0xffffffff, - bool closeTop=true, f32 oblique=0.f) const; - - IMesh* createConeMesh(f32 radius, f32 length, u32 tesselation, - const video::SColor& colorTop=0xffffffff, - const video::SColor& colorBottom=0xffffffff, - f32 oblique=0.f) const; - - IMesh* createVolumeLightMesh( - const u32 subdivideU=32, const u32 subdivideV=32, - const video::SColor footColor=0xffffffff, - const video::SColor tailColor=0xffffffff, - const f32 lpDistance = 8.f, - const core::vector3df& lightDim = core::vector3df(1.f,1.2f,1.f)) const; -}; - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CImage.cpp b/irrlicht-1.6/source/Irrlicht/CImage.cpp deleted file mode 100644 index 761bf5be9..000000000 --- a/irrlicht-1.6/source/Irrlicht/CImage.cpp +++ /dev/null @@ -1,535 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CImage.h" -#include "irrString.h" -#include "CColorConverter.h" -#include "CBlit.h" - -namespace irr -{ -namespace video -{ - -//! Constructor of empty image -CImage::CImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size) -:Data(0), Size(size), Format(format), DeleteMemory(true) -{ - #ifdef _DEBUG - setDebugName("CImage"); - #endif - initData(); -} - - -//! Constructor from raw data -CImage::CImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size, void* data, - bool ownForeignMemory, bool deleteForeignMemory) -: Data(0), Size(size), Format(format), DeleteMemory(deleteForeignMemory) -{ - if (ownForeignMemory) - { - Data = (u8*)0xbadf00d; - initData(); - Data = (u8*)data; - } - else - { - Data = 0; - initData(); - memcpy(Data, data, Size.Height * Pitch); - } -} - - -//! Constructor from other image, with color conversion -CImage::CImage(ECOLOR_FORMAT format, IImage* imageToCopy) -: Data(0), Format(format), DeleteMemory(true) -{ - if (!imageToCopy) - return; - - Size = imageToCopy->getDimension(); - initData(); - - // now copy data from other image - Blit ( BLITTER_TEXTURE, this, 0, 0, imageToCopy, 0,0 ); -} - - -//! Constructor from other image, partially -CImage::CImage(IImage* imageToCopy, const core::position2d<s32>& pos, - const core::dimension2d<u32>& size) - : Data(0), Size(0,0), DeleteMemory(true) -{ - if (!imageToCopy) - return; - - Format = imageToCopy->getColorFormat(); - Size = size; - - initData(); - - core::rect<s32> sClip( pos.X, pos.Y, pos.X + size.Width,pos.Y + size.Height ); - Blit (BLITTER_TEXTURE, this, 0, 0, imageToCopy, &sClip, 0); -} - - -//! assumes format and size has been set and creates the rest -void CImage::initData() -{ - BytesPerPixel = getBitsPerPixelFromFormat(Format) / 8; - - // Pitch should be aligned... - Pitch = BytesPerPixel * Size.Width; - - if (!Data) - Data = new u8[Size.Height * Pitch]; -} - - -//! destructor -CImage::~CImage() -{ - if ( DeleteMemory ) - delete [] Data; -} - - -//! Returns width and height of image data. -const core::dimension2d<u32>& CImage::getDimension() const -{ - return Size; -} - - -//! Returns bits per pixel. -u32 CImage::getBitsPerPixel() const -{ - return getBitsPerPixelFromFormat(Format); -} - - -//! Returns bytes per pixel -u32 CImage::getBytesPerPixel() const -{ - return BytesPerPixel; -} - - -//! Returns image data size in bytes -u32 CImage::getImageDataSizeInBytes() const -{ - return Pitch * Size.Height; -} - - -//! Returns image data size in pixels -u32 CImage::getImageDataSizeInPixels() const -{ - return Size.Width * Size.Height; -} - - -//! returns mask for red value of a pixel -u32 CImage::getRedMask() const -{ - switch(Format) - { - case ECF_A1R5G5B5: - return 0x1F<<10; - case ECF_R5G6B5: - return 0x1F<<11; - case ECF_R8G8B8: - return 0x00FF0000; - case ECF_A8R8G8B8: - return 0x00FF0000; - default: - return 0x0; - } -} - - -//! returns mask for green value of a pixel -u32 CImage::getGreenMask() const -{ - switch(Format) - { - case ECF_A1R5G5B5: - return 0x1F<<5; - case ECF_R5G6B5: - return 0x3F<<5; - case ECF_R8G8B8: - return 0x0000FF00; - case ECF_A8R8G8B8: - return 0x0000FF00; - default: - return 0x0; - } -} - - -//! returns mask for blue value of a pixel -u32 CImage::getBlueMask() const -{ - switch(Format) - { - case ECF_A1R5G5B5: - return 0x1F; - case ECF_R5G6B5: - return 0x1F; - case ECF_R8G8B8: - return 0x000000FF; - case ECF_A8R8G8B8: - return 0x000000FF; - default: - return 0x0; - } -} - - -//! returns mask for alpha value of a pixel -u32 CImage::getAlphaMask() const -{ - switch(Format) - { - case ECF_A1R5G5B5: - return 0x1<<15; - case ECF_R5G6B5: - return 0x0; - case ECF_R8G8B8: - return 0x0; - case ECF_A8R8G8B8: - return 0xFF000000; - default: - return 0x0; - } -} - - -//! sets a pixel -void CImage::setPixel(u32 x, u32 y, const SColor &color, bool blend) -{ - if (x >= Size.Width || y >= Size.Height) - return; - - switch(Format) - { - case ECF_A1R5G5B5: - { - u16 * dest = (u16*) (Data + ( y * Pitch ) + ( x << 1 )); - *dest = video::A8R8G8B8toA1R5G5B5( color.color ); - } break; - - case ECF_R5G6B5: - { - u16 * dest = (u16*) (Data + ( y * Pitch ) + ( x << 1 )); - *dest = video::A8R8G8B8toR5G6B5( color.color ); - } break; - - case ECF_R8G8B8: - { - u8* dest = Data + ( y * Pitch ) + ( x * 3 ); - dest[0] = (u8)color.getRed(); - dest[1] = (u8)color.getGreen(); - dest[2] = (u8)color.getBlue(); - } break; - - case ECF_A8R8G8B8: - { - u32 * dest = (u32*) (Data + ( y * Pitch ) + ( x << 2 )); - *dest = blend ? PixelBlend32 ( *dest, color.color ) : color.color; - } break; - } -} - - -//! returns a pixel -SColor CImage::getPixel(u32 x, u32 y) const -{ - if (x >= Size.Width || y >= Size.Height) - return SColor(0); - - switch(Format) - { - case ECF_A1R5G5B5: - return A1R5G5B5toA8R8G8B8(((u16*)Data)[y*Size.Width + x]); - case ECF_R5G6B5: - return R5G6B5toA8R8G8B8(((u16*)Data)[y*Size.Width + x]); - case ECF_A8R8G8B8: - return ((u32*)Data)[y*Size.Width + x]; - case ECF_R8G8B8: - { - u8* p = Data+(y*3)*Size.Width + (x*3); - return SColor(255,p[0],p[1],p[2]); - } - } - - return SColor(0); -} - - -//! returns the color format -ECOLOR_FORMAT CImage::getColorFormat() const -{ - return Format; -} - - -//! copies this surface into another at given position -void CImage::copyTo(IImage* target, const core::position2d<s32>& pos) -{ - Blit(BLITTER_TEXTURE, target, 0, &pos, this, 0, 0); -} - - -//! copies this surface partially into another at given position -void CImage::copyTo(IImage* target, const core::position2d<s32>& pos, const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect) -{ - Blit(BLITTER_TEXTURE, target, clipRect, &pos, this, &sourceRect, 0); -} - - -//! copies this surface into another, using the alpha mask, a cliprect and a color to add with -void CImage::copyToWithAlpha(IImage* target, const core::position2d<s32>& pos, const core::rect<s32>& sourceRect, const SColor &color, const core::rect<s32>* clipRect) -{ - // color blend only necessary on not full spectrum aka. color.color != 0xFFFFFFFF - Blit(color.color == 0xFFFFFFFF ? BLITTER_TEXTURE_ALPHA_BLEND: BLITTER_TEXTURE_ALPHA_COLOR_BLEND, - target, clipRect, &pos, this, &sourceRect, color.color); -} - - -//! copies this surface into another, scaling it to the target image size -// note: this is very very slow. -void CImage::copyToScaling(void* target, u32 width, u32 height, ECOLOR_FORMAT format, u32 pitch) -{ - if (!target || !width || !height) - return; - - const u32 bpp=getBitsPerPixelFromFormat(format)/8; - if (0==pitch) - pitch = width*bpp; - - if (Format==format && Size.Width==width && Size.Height==height) - { - if (pitch==Pitch) - { - memcpy(target, Data, height*pitch); - return; - } - else - { - u8* tgtpos = (u8*) target; - u8* srcpos = Data; - const u32 bwidth = width*bpp; - const u32 rest = pitch-bwidth; - for (u32 y=0; y<height; ++y) - { - // copy scanline - memcpy(tgtpos, srcpos, bwidth); - // clear pitch - memset(tgtpos+bwidth, 0, rest); - tgtpos += pitch; - srcpos += Pitch; - } - return; - } - } - - const f32 sourceXStep = (f32)Size.Width / (f32)width; - const f32 sourceYStep = (f32)Size.Height / (f32)height; - s32 yval=0, syval=0; - f32 sy = 0.0f; - for (u32 y=0; y<height; ++y) - { - f32 sx = 0.0f; - for (u32 x=0; x<width; ++x) - { - CColorConverter::convert_viaFormat(Data+ syval + ((s32)sx)*BytesPerPixel, Format, 1, ((u8*)target)+ yval + (x*bpp), format); - sx+=sourceXStep; - } - sy+=sourceYStep; - syval=((s32)sy)*Pitch; - yval+=pitch; - } -} - - -//! copies this surface into another, scaling it to the target image size -// note: this is very very slow. -void CImage::copyToScaling(IImage* target) -{ - if (!target) - return; - - const core::dimension2d<u32>& targetSize = target->getDimension(); - - if (targetSize==Size) - { - copyTo(target); - return; - } - - copyToScaling(target->lock(), targetSize.Width, targetSize.Height, target->getColorFormat()); - target->unlock(); -} - - -//! copies this surface into another, scaling it to fit it. -void CImage::copyToScalingBoxFilter(IImage* target, s32 bias, bool blend) -{ - const core::dimension2d<u32> destSize = target->getDimension(); - - const f32 sourceXStep = (f32) Size.Width / (f32) destSize.Width; - const f32 sourceYStep = (f32) Size.Height / (f32) destSize.Height; - - target->lock(); - - s32 fx = core::ceil32( sourceXStep ); - s32 fy = core::ceil32( sourceYStep ); - f32 sx; - f32 sy; - - sy = 0.f; - for ( u32 y = 0; y != destSize.Height; ++y ) - { - sx = 0.f; - for ( u32 x = 0; x != destSize.Width; ++x ) - { - target->setPixel( x, y, - getPixelBox( core::floor32(sx), core::floor32(sy), fx, fy, bias ), blend ); - sx += sourceXStep; - } - sy += sourceYStep; - } - - target->unlock(); -} - - -//! fills the surface with given color -void CImage::fill(const SColor &color) -{ - u32 c; - - switch ( Format ) - { - case ECF_A1R5G5B5: - c = color.toA1R5G5B5(); - c |= c << 16; - break; - case ECF_R5G6B5: - c = video::A8R8G8B8toR5G6B5( color.color ); - c |= c << 16; - break; - case ECF_A8R8G8B8: - c = color.color; - break; - case ECF_R8G8B8: - { - u8 rgb[3]; - CColorConverter::convert_A8R8G8B8toR8G8B8(&color, 1, rgb); - const u32 size = getImageDataSizeInBytes(); - for (u32 i=0; i<size; i+=3) - { - memcpy(Data+i, rgb, 3); - } - return; - } - break; - } - if (Format != ECF_A1R5G5B5 && Format != ECF_R5G6B5 && - Format != ECF_A8R8G8B8) - return; - - memset32( Data, c, getImageDataSizeInBytes() ); -} - - -//! get a filtered pixel -inline SColor CImage::getPixelBox( s32 x, s32 y, s32 fx, s32 fy, s32 bias ) const -{ - SColor c; - s32 a = 0, r = 0, g = 0, b = 0; - - for ( s32 dx = 0; dx != fx; ++dx ) - { - for ( s32 dy = 0; dy != fy; ++dy ) - { - c = getPixel( core::s32_min ( x + dx, Size.Width - 1 ) , - core::s32_min ( y + dy, Size.Height - 1 ) - ); - - a += c.getAlpha(); - r += c.getRed(); - g += c.getGreen(); - b += c.getBlue(); - } - - } - - s32 sdiv = s32_log2_s32(fx * fy); - - a = core::s32_clamp( ( a >> sdiv ) + bias, 0, 255 ); - r = core::s32_clamp( ( r >> sdiv ) + bias, 0, 255 ); - g = core::s32_clamp( ( g >> sdiv ) + bias, 0, 255 ); - b = core::s32_clamp( ( b >> sdiv ) + bias, 0, 255 ); - - c.set( a, r, g, b ); - return c; -} - - -// Methods for Software drivers, non-virtual and not necessary to copy into other image classes -//! draws a rectangle -void CImage::drawRectangle(const core::rect<s32>& rect, const SColor &color) -{ - Blit(color.getAlpha() == 0xFF ? BLITTER_COLOR : BLITTER_COLOR_ALPHA, - this, 0, &rect.UpperLeftCorner, 0, &rect, color.color); -} - - -//! draws a line from to with color -void CImage::drawLine(const core::position2d<s32>& from, const core::position2d<s32>& to, const SColor &color) -{ - AbsRectangle clip; - GetClip( clip, this ); - - core::position2d<s32> p[2]; - - if ( ClipLine( clip, p[0], p[1], from, to ) ) - { - u32 alpha = extractAlpha( color.color ); - - switch ( Format ) - { - case ECF_A1R5G5B5: - if ( alpha == 256 ) - { - RenderLine16_Decal( this, p[0], p[1], video::A8R8G8B8toA1R5G5B5( color.color ) ); - } - else - { - RenderLine16_Blend( this, p[0], p[1], video::A8R8G8B8toA1R5G5B5( color.color ), alpha >> 3 ); - } - break; - case ECF_A8R8G8B8: - if ( alpha == 256 ) - { - RenderLine32_Decal( this, p[0], p[1], color.color ); - } - else - { - RenderLine32_Blend( this, p[0], p[1], color.color, alpha ); - } - break; - default: - break; - } - } -} - - -} // end namespace video -} // end namespace irr diff --git a/irrlicht-1.6/source/Irrlicht/CImage.h b/irrlicht-1.6/source/Irrlicht/CImage.h deleted file mode 100644 index f611e1fe7..000000000 --- a/irrlicht-1.6/source/Irrlicht/CImage.h +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_IMAGE_H_INCLUDED__ -#define __C_IMAGE_H_INCLUDED__ - -#include "IImage.h" -#include "rect.h" - -namespace irr -{ -namespace video -{ - -//! IImage implementation with a lot of special image operations for -//! 16 bit A1R5G5B5/32 Bit A8R8G8B8 images, which are used by the SoftwareDevice. -class CImage : public IImage -{ -public: - - //! constructor from another image with format change - CImage(ECOLOR_FORMAT format, IImage* imageToCopy); - - //! constructor from raw image data - //! \param useForeignMemory: If true, the image will use the data pointer - //! directly and own it from now on, which means it will also try to delete [] the - //! data when the image will be destructed. If false, the memory will by copied. - CImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size, - void* data, bool ownForeignMemory=true, bool deleteMemory = true); - - //! constructor for empty image - CImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size); - - //! constructor using a part from another image - CImage(IImage* imageToCopy, - const core::position2d<s32>& pos, const core::dimension2d<u32>& size); - - //! destructor - virtual ~CImage(); - - //! Lock function. - virtual void* lock() - { - return Data; - } - - //! Unlock function. - virtual void unlock() {} - - //! Returns width and height of image data. - virtual const core::dimension2d<u32>& getDimension() const; - - //! Returns bits per pixel. - virtual u32 getBitsPerPixel() const; - - //! Returns bytes per pixel - virtual u32 getBytesPerPixel() const; - - //! Returns image data size in bytes - virtual u32 getImageDataSizeInBytes() const; - - //! Returns image data size in pixels - virtual u32 getImageDataSizeInPixels() const; - - //! returns mask for red value of a pixel - virtual u32 getRedMask() const; - - //! returns mask for green value of a pixel - virtual u32 getGreenMask() const; - - //! returns mask for blue value of a pixel - virtual u32 getBlueMask() const; - - //! returns mask for alpha value of a pixel - virtual u32 getAlphaMask() const; - - //! returns a pixel - virtual SColor getPixel(u32 x, u32 y) const; - - //! sets a pixel - virtual void setPixel(u32 x, u32 y, const SColor &color, bool blend = false ); - - //! returns the color format - virtual ECOLOR_FORMAT getColorFormat() const; - - //! returns pitch of image - virtual u32 getPitch() const { return Pitch; } - - //! copies this surface into another, scaling it to fit. - virtual void copyToScaling(void* target, u32 width, u32 height, ECOLOR_FORMAT format, u32 pitch=0); - - //! copies this surface into another, scaling it to fit. - virtual void copyToScaling(IImage* target); - - //! copies this surface into another - virtual void copyTo(IImage* target, const core::position2d<s32>& pos=core::position2d<s32>(0,0)); - - //! copies this surface into another - virtual void copyTo(IImage* target, const core::position2d<s32>& pos, const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect=0); - - //! copies this surface into another, using the alpha mask, an cliprect and a color to add with - virtual void copyToWithAlpha(IImage* target, const core::position2d<s32>& pos, - const core::rect<s32>& sourceRect, const SColor &color, - const core::rect<s32>* clipRect = 0); - - //! copies this surface into another, scaling it to fit, appyling a box filter - virtual void copyToScalingBoxFilter(IImage* target, s32 bias = 0, bool blend = false); - - //! fills the surface with black or white - virtual void fill(const SColor &color); - - //! draws a rectangle - void drawRectangle(const core::rect<s32>& rect, const SColor &color); - - //! draws a line from to - void drawLine(const core::position2d<s32>& from, const core::position2d<s32>& to, const SColor &color); - -private: - - //! assumes format and size has been set and creates the rest - void initData(); - - inline SColor getPixelBox ( s32 x, s32 y, s32 fx, s32 fy, s32 bias ) const; - - u8* Data; - core::dimension2d<u32> Size; - u32 BytesPerPixel; - u32 Pitch; - ECOLOR_FORMAT Format; - - bool DeleteMemory; -}; - -} // end namespace video -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CImageLoaderBMP.cpp b/irrlicht-1.6/source/Irrlicht/CImageLoaderBMP.cpp deleted file mode 100644 index b12cdc05b..000000000 --- a/irrlicht-1.6/source/Irrlicht/CImageLoaderBMP.cpp +++ /dev/null @@ -1,372 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CImageLoaderBMP.h" - -#ifdef _IRR_COMPILE_WITH_BMP_LOADER_ - -#include "IReadFile.h" -#include "SColor.h" -#include "CColorConverter.h" -#include "CImage.h" -#include "os.h" -#include "irrString.h" - -namespace irr -{ -namespace video -{ - - -//! constructor -CImageLoaderBMP::CImageLoaderBMP() -{ - #ifdef _DEBUG - setDebugName("CImageLoaderBMP"); - #endif -} - - -//! returns true if the file maybe is able to be loaded by this class -//! based on the file extension (e.g. ".tga") -bool CImageLoaderBMP::isALoadableFileExtension(const io::path& filename) const -{ - return core::hasFileExtension ( filename, "bmp" ); -} - - -//! returns true if the file maybe is able to be loaded by this class -bool CImageLoaderBMP::isALoadableFileFormat(io::IReadFile* file) const -{ - u16 headerID; - file->read(&headerID, sizeof(u16)); -#ifdef __BIG_ENDIAN__ - headerID = os::Byteswap::byteswap(headerID); -#endif - return headerID == 0x4d42; -} - - -void CImageLoaderBMP::decompress8BitRLE(u8*& bmpData, s32 size, s32 width, s32 height, s32 pitch) const -{ - u8* p = bmpData; - u8* newBmp = new u8[(width+pitch)*height]; - u8* d = newBmp; - u8* destEnd = newBmp + (width+pitch)*height; - s32 line = 0; - - while (bmpData - p < size && d < destEnd) - { - if (*p == 0) - { - ++p; - - switch(*p) - { - case 0: // end of line - ++p; - ++line; - d = newBmp + (line*(width+pitch)); - break; - case 1: // end of bmp - delete [] bmpData; - bmpData = newBmp; - return; - case 2: - ++p; d +=(u8)*p; // delta - ++p; d += ((u8)*p)*(width+pitch); - ++p; - break; - default: - { - // absolute mode - s32 count = (u8)*p; ++p; - s32 readAdditional = ((2-(count%2))%2); - s32 i; - - for (i=0; i<count; ++i) - { - *d = *p; - ++p; - ++d; - } - - for (i=0; i<readAdditional; ++i) - ++p; - } - } - } - else - { - s32 count = (u8)*p; ++p; - u8 color = *p; ++p; - for (s32 i=0; i<count; ++i) - { - *d = color; - ++d; - } - } - } - - delete [] bmpData; - bmpData = newBmp; -} - - -void CImageLoaderBMP::decompress4BitRLE(u8*& bmpData, s32 size, s32 width, s32 height, s32 pitch) const -{ - s32 lineWidth = (width+1)/2+pitch; - u8* p = bmpData; - u8* newBmp = new u8[lineWidth*height]; - u8* d = newBmp; - u8* destEnd = newBmp + lineWidth*height; - s32 line = 0; - s32 shift = 4; - - while (bmpData - p < size && d < destEnd) - { - if (*p == 0) - { - ++p; - - switch(*p) - { - case 0: // end of line - ++p; - ++line; - d = newBmp + (line*lineWidth); - shift = 4; - break; - case 1: // end of bmp - delete [] bmpData; - bmpData = newBmp; - return; - case 2: - { - ++p; - s32 x = (u8)*p; ++p; - s32 y = (u8)*p; ++p; - d += x/2 + y*lineWidth; - shift = x%2==0 ? 4 : 0; - } - break; - default: - { - // absolute mode - s32 count = (u8)*p; ++p; - s32 readAdditional = ((2-((count)%2))%2); - s32 readShift = 4; - s32 i; - - for (i=0; i<count; ++i) - { - s32 color = (((u8)*p) >> readShift) & 0x0f; - readShift -= 4; - if (readShift < 0) - { - ++*p; - readShift = 4; - } - - u8 mask = 0x0f << shift; - *d = (*d & (~mask)) | ((color << shift) & mask); - - shift -= 4; - if (shift < 0) - { - shift = 4; - ++d; - } - - } - - for (i=0; i<readAdditional; ++i) - ++p; - } - } - } - else - { - s32 count = (u8)*p; ++p; - s32 color1 = (u8)*p; color1 = color1 & 0x0f; - s32 color2 = (u8)*p; color2 = (color2 >> 4) & 0x0f; - ++p; - - for (s32 i=0; i<count; ++i) - { - u8 mask = 0x0f << shift; - u8 toSet = (shift==0 ? color1 : color2) << shift; - *d = (*d & (~mask)) | (toSet & mask); - - shift -= 4; - if (shift < 0) - { - shift = 4; - ++d; - } - } - } - } - - delete [] bmpData; - bmpData = newBmp; -} - - - -//! creates a surface from the file -IImage* CImageLoaderBMP::loadImage(io::IReadFile* file) const -{ - SBMPHeader header; - - file->read(&header, sizeof(header)); - -#ifdef __BIG_ENDIAN__ - header.Id = os::Byteswap::byteswap(header.Id); - header.FileSize = os::Byteswap::byteswap(header.FileSize); - header.BitmapDataOffset = os::Byteswap::byteswap(header.BitmapDataOffset); - header.BitmapHeaderSize = os::Byteswap::byteswap(header.BitmapHeaderSize); - header.Width = os::Byteswap::byteswap(header.Width); - header.Height = os::Byteswap::byteswap(header.Height); - header.Planes = os::Byteswap::byteswap(header.Planes); - header.BPP = os::Byteswap::byteswap(header.BPP); - header.Compression = os::Byteswap::byteswap(header.Compression); - header.BitmapDataSize = os::Byteswap::byteswap(header.BitmapDataSize); - header.PixelPerMeterX = os::Byteswap::byteswap(header.PixelPerMeterX); - header.PixelPerMeterY = os::Byteswap::byteswap(header.PixelPerMeterY); - header.Colors = os::Byteswap::byteswap(header.Colors); - header.ImportantColors = os::Byteswap::byteswap(header.ImportantColors); -#endif - - s32 pitch = 0; - - //! return if the header is false - - if (header.Id != 0x4d42) - return 0; - - if (header.Compression > 2) // we'll only handle RLE-Compression - { - os::Printer::log("Compression mode not supported.", ELL_ERROR); - return 0; - } - - // adjust bitmap data size to dword boundary - header.BitmapDataSize += (4-(header.BitmapDataSize%4))%4; - - // read palette - - long pos = file->getPos(); - s32 paletteSize = (header.BitmapDataOffset - pos) / 4; - - s32* paletteData = 0; - if (paletteSize) - { - paletteData = new s32[paletteSize]; - file->read(paletteData, paletteSize * sizeof(s32)); -#ifdef __BIG_ENDIAN__ - for (s32 i=0; i<paletteSize; ++i) - paletteData[i] = os::Byteswap::byteswap(paletteData[i]); -#endif - } - - // read image data - - if (!header.BitmapDataSize) - { - // okay, lets guess the size - // some tools simply don't set it - header.BitmapDataSize = static_cast<u32>(file->getSize()) - header.BitmapDataOffset; - } - - file->seek(header.BitmapDataOffset); - - f32 t = (header.Width) * (header.BPP / 8.0f); - s32 widthInBytes = (s32)t; - t -= widthInBytes; - if (t!=0.0f) - ++widthInBytes; - - s32 lineData = widthInBytes + ((4-(widthInBytes%4)))%4; - pitch = lineData - widthInBytes; - - u8* bmpData = new u8[header.BitmapDataSize]; - file->read(bmpData, header.BitmapDataSize); - - // decompress data if needed - switch(header.Compression) - { - case 1: // 8 bit rle - decompress8BitRLE(bmpData, header.BitmapDataSize, header.Width, header.Height, pitch); - break; - case 2: // 4 bit rle - decompress4BitRLE(bmpData, header.BitmapDataSize, header.Width, header.Height, pitch); - break; - } - - // create surface - - // no default constructor from packed area! ARM problem! - core::dimension2d<u32> dim; - dim.Width = header.Width; - dim.Height = header.Height; - - IImage* image = 0; - switch(header.BPP) - { - case 1: - image = new CImage(ECF_A1R5G5B5, dim); - if (image) - CColorConverter::convert1BitTo16Bit(bmpData, (s16*)image->lock(), header.Width, header.Height, pitch, true); - break; - case 4: - image = new CImage(ECF_A1R5G5B5, dim); - if (image) - CColorConverter::convert4BitTo16Bit(bmpData, (s16*)image->lock(), header.Width, header.Height, paletteData, pitch, true); - break; - case 8: - image = new CImage(ECF_A1R5G5B5, dim); - if (image) - CColorConverter::convert8BitTo16Bit(bmpData, (s16*)image->lock(), header.Width, header.Height, paletteData, pitch, true); - break; - case 16: - image = new CImage(ECF_A1R5G5B5, dim); - if (image) - CColorConverter::convert16BitTo16Bit((s16*)bmpData, (s16*)image->lock(), header.Width, header.Height, pitch, true); - break; - case 24: - image = new CImage(ECF_R8G8B8, dim); - if (image) - CColorConverter::convert24BitTo24Bit(bmpData, (u8*)image->lock(), header.Width, header.Height, pitch, true, true); - break; - case 32: // thx to Reinhard Ostermeier - image = new CImage(ECF_A8R8G8B8, dim); - if (image) - CColorConverter::convert32BitTo32Bit((s32*)bmpData, (s32*)image->lock(), header.Width, header.Height, pitch, true); - break; - }; - if (image) - image->unlock(); - - // clean up - - delete [] paletteData; - delete [] bmpData; - - return image; -} - - -//! creates a loader which is able to load windows bitmaps -IImageLoader* createImageLoaderBMP() -{ - return new CImageLoaderBMP; -} - - -} // end namespace video -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CImageLoaderBMP.h b/irrlicht-1.6/source/Irrlicht/CImageLoaderBMP.h deleted file mode 100644 index b1d34835e..000000000 --- a/irrlicht-1.6/source/Irrlicht/CImageLoaderBMP.h +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_IMAGE_LOADER_BMP_H_INCLUDED__ -#define __C_IMAGE_LOADER_BMP_H_INCLUDED__ - -#include "IrrCompileConfig.h" - -#include "IImageLoader.h" - - -namespace irr -{ -namespace video -{ - -#if defined(_IRR_COMPILE_WITH_BMP_LOADER_) || defined(_IRR_COMPILE_WITH_BMP_WRITER_) - - - // byte-align structures -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) -# pragma pack( push, packing ) -# pragma pack( 1 ) -# define PACK_STRUCT -#elif defined( __GNUC__ ) -# define PACK_STRUCT __attribute__((packed)) -#else -# error compiler not supported -#endif - - struct SBMPHeader - { - u16 Id; // BM - Windows 3.1x, 95, NT, 98, 2000, ME, XP - // BA - OS/2 Bitmap Array - // CI - OS/2 Color Icon - // CP - OS/2 Color Pointer - // IC - OS/2 Icon - // PT - OS/2 Pointer - u32 FileSize; - u32 Reserved; - u32 BitmapDataOffset; - u32 BitmapHeaderSize; // should be 28h for windows bitmaps or - // 0Ch for OS/2 1.x or F0h for OS/2 2.x - u32 Width; - u32 Height; - u16 Planes; - u16 BPP; // 1: Monochrome bitmap - // 4: 16 color bitmap - // 8: 256 color bitmap - // 16: 16bit (high color) bitmap - // 24: 24bit (true color) bitmap - // 32: 32bit (true color) bitmap - - u32 Compression; // 0: none (Also identified by BI_RGB) - // 1: RLE 8-bit / pixel (Also identified by BI_RLE4) - // 2: RLE 4-bit / pixel (Also identified by BI_RLE8) - // 3: Bitfields (Also identified by BI_BITFIELDS) - - u32 BitmapDataSize; // Size of the bitmap data in bytes. This number must be rounded to the next 4 byte boundary. - u32 PixelPerMeterX; - u32 PixelPerMeterY; - u32 Colors; - u32 ImportantColors; - } PACK_STRUCT; - - -// Default alignment -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) -# pragma pack( pop, packing ) -#endif - -#undef PACK_STRUCT - -#endif // defined with loader or writer - -#ifdef _IRR_COMPILE_WITH_BMP_LOADER_ - -/*! - Surface Loader for Windows bitmaps -*/ -class CImageLoaderBMP : public IImageLoader -{ -public: - - //! constructor - CImageLoaderBMP(); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".tga") - virtual bool isALoadableFileExtension(const io::path& filename) const; - - //! returns true if the file maybe is able to be loaded by this class - virtual bool isALoadableFileFormat(io::IReadFile* file) const; - - //! creates a surface from the file - virtual IImage* loadImage(io::IReadFile* file) const; - -private: - - void decompress8BitRLE(u8*& BmpData, s32 size, s32 width, s32 height, s32 pitch) const; - - void decompress4BitRLE(u8*& BmpData, s32 size, s32 width, s32 height, s32 pitch) const; -}; - - -#endif // compiled with loader - -} // end namespace video -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CImageLoaderJPG.cpp b/irrlicht-1.6/source/Irrlicht/CImageLoaderJPG.cpp deleted file mode 100644 index cf4eda151..000000000 --- a/irrlicht-1.6/source/Irrlicht/CImageLoaderJPG.cpp +++ /dev/null @@ -1,260 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CImageLoaderJPG.h" - -#ifdef _IRR_COMPILE_WITH_JPG_LOADER_ - -#include "IReadFile.h" -#include "CImage.h" -#include "os.h" -#include "irrString.h" - -namespace irr -{ -namespace video -{ - -//! constructor -CImageLoaderJPG::CImageLoaderJPG() -{ - #ifdef _DEBUG - setDebugName("CImageLoaderJPG"); - #endif -} - - - -//! destructor -CImageLoaderJPG::~CImageLoaderJPG() -{ -} - - - -//! returns true if the file maybe is able to be loaded by this class -//! based on the file extension (e.g. ".tga") -bool CImageLoaderJPG::isALoadableFileExtension(const io::path& filename) const -{ - return core::hasFileExtension ( filename, "jpg", "jpeg" ); -} - - -#ifdef _IRR_COMPILE_WITH_LIBJPEG_ - - // struct for handling jpeg errors - struct irr_jpeg_error_mgr - { - // public jpeg error fields - struct jpeg_error_mgr pub; - - // for longjmp, to return to caller on a fatal error - jmp_buf setjmp_buffer; - }; - -void CImageLoaderJPG::init_source (j_decompress_ptr cinfo) -{ - // DO NOTHING -} - - - -boolean CImageLoaderJPG::fill_input_buffer (j_decompress_ptr cinfo) -{ - // DO NOTHING - return 1; -} - - - -void CImageLoaderJPG::skip_input_data (j_decompress_ptr cinfo, long count) -{ - jpeg_source_mgr * src = cinfo->src; - if(count > 0) - { - src->bytes_in_buffer -= count; - src->next_input_byte += count; - } -} - - - -void CImageLoaderJPG::term_source (j_decompress_ptr cinfo) -{ - // DO NOTHING -} - - -void CImageLoaderJPG::error_exit (j_common_ptr cinfo) -{ - // unfortunately we need to use a goto rather than throwing an exception - // as gcc crashes under linux crashes when using throw from within - // extern c code - - // Always display the message - (*cinfo->err->output_message) (cinfo); - - // cinfo->err really points to a irr_error_mgr struct - irr_jpeg_error_mgr *myerr = (irr_jpeg_error_mgr*) cinfo->err; - - longjmp(myerr->setjmp_buffer, 1); -} - - -void CImageLoaderJPG::output_message(j_common_ptr cinfo) -{ - // display the error message. - c8 temp1[JMSG_LENGTH_MAX]; - (*cinfo->err->format_message)(cinfo, temp1); - os::Printer::log("JPEG FATAL ERROR",temp1, ELL_ERROR); -} -#endif // _IRR_COMPILE_WITH_LIBJPEG_ - -//! returns true if the file maybe is able to be loaded by this class -bool CImageLoaderJPG::isALoadableFileFormat(io::IReadFile* file) const -{ - #ifndef _IRR_COMPILE_WITH_LIBJPEG_ - return false; - #else - - if (!file) - return false; - - s32 jfif = 0; - file->seek(6); - file->read(&jfif, sizeof(s32)); - return (jfif == 0x4a464946 || jfif == 0x4649464a); - - #endif -} - -//! creates a surface from the file -IImage* CImageLoaderJPG::loadImage(io::IReadFile* file) const -{ - #ifndef _IRR_COMPILE_WITH_LIBJPEG_ - return 0; - #else - - u8 **rowPtr=0; - u8* input = new u8[file->getSize()]; - file->read(input, file->getSize()); - - // allocate and initialize JPEG decompression object - struct jpeg_decompress_struct cinfo; - struct irr_jpeg_error_mgr jerr; - - //We have to set up the error handler first, in case the initialization - //step fails. (Unlikely, but it could happen if you are out of memory.) - //This routine fills in the contents of struct jerr, and returns jerr's - //address which we place into the link field in cinfo. - - cinfo.err = jpeg_std_error(&jerr.pub); - cinfo.err->error_exit = error_exit; - cinfo.err->output_message = output_message; - - // compatibility fudge: - // we need to use setjmp/longjmp for error handling as gcc-linux - // crashes when throwing within external c code - if (setjmp(jerr.setjmp_buffer)) - { - // If we get here, the JPEG code has signaled an error. - // We need to clean up the JPEG object and return. - - jpeg_destroy_decompress(&cinfo); - - delete [] input; - // if the row pointer was created, we delete it. - if (rowPtr) - delete [] rowPtr; - - // return null pointer - return 0; - } - - // Now we can initialize the JPEG decompression object. - jpeg_create_decompress(&cinfo); - - // specify data source - jpeg_source_mgr jsrc; - - // Set up data pointer - jsrc.bytes_in_buffer = file->getSize(); - jsrc.next_input_byte = (JOCTET*)input; - cinfo.src = &jsrc; - - jsrc.init_source = init_source; - jsrc.fill_input_buffer = fill_input_buffer; - jsrc.skip_input_data = skip_input_data; - jsrc.resync_to_restart = jpeg_resync_to_restart; - jsrc.term_source = term_source; - - // Decodes JPG input from whatever source - // Does everything AFTER jpeg_create_decompress - // and BEFORE jpeg_destroy_decompress - // Caller is responsible for arranging these + setting up cinfo - - // read file parameters with jpeg_read_header() - jpeg_read_header(&cinfo, TRUE); - - cinfo.out_color_space=JCS_RGB; - cinfo.out_color_components=3; - cinfo.do_fancy_upsampling=FALSE; - - // Start decompressor - jpeg_start_decompress(&cinfo); - - // Get image data - u16 rowspan = cinfo.image_width * cinfo.out_color_components; - u32 width = cinfo.image_width; - u32 height = cinfo.image_height; - - // Allocate memory for buffer - u8* output = new u8[rowspan * height]; - - // Here we use the library's state variable cinfo.output_scanline as the - // loop counter, so that we don't have to keep track ourselves. - // Create array of row pointers for lib - rowPtr = new u8* [height]; - - for( u32 i = 0; i < height; i++ ) - rowPtr[i] = &output[ i * rowspan ]; - - u32 rowsRead = 0; - - while( cinfo.output_scanline < cinfo.output_height ) - rowsRead += jpeg_read_scanlines( &cinfo, &rowPtr[rowsRead], cinfo.output_height - rowsRead ); - - delete [] rowPtr; - // Finish decompression - - jpeg_finish_decompress(&cinfo); - - // Release JPEG decompression object - // This is an important step since it will release a good deal of memory. - jpeg_destroy_decompress(&cinfo); - - // convert image - IImage* image = new CImage(ECF_R8G8B8, - core::dimension2d<u32>(width, height), output); - - delete [] input; - - return image; - - #endif -} - - - -//! creates a loader which is able to load jpeg images -IImageLoader* createImageLoaderJPG() -{ - return new CImageLoaderJPG(); -} - -} // end namespace video -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CImageLoaderJPG.h b/irrlicht-1.6/source/Irrlicht/CImageLoaderJPG.h deleted file mode 100644 index f15d173ef..000000000 --- a/irrlicht-1.6/source/Irrlicht/CImageLoaderJPG.h +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_IMAGE_LOADER_JPG_H_INCLUDED__ -#define __C_IMAGE_LOADER_JPG_H_INCLUDED__ - -#include "IrrCompileConfig.h" - -#ifdef _IRR_COMPILE_WITH_JPG_LOADER_ - -#include "IImageLoader.h" - -#include <stdio.h> // required for jpeglib.h -#ifdef _IRR_COMPILE_WITH_LIBJPEG_ -extern "C" { - #ifndef _IRR_USE_NON_SYSTEM_JPEG_LIB_ - #include <jpeglib.h> // use system lib - #else - #include "jpeglib/jpeglib.h" // use irrlicht jpeglib - #endif - #include <setjmp.h> -} -#endif // _IRR_COMPILE_WITH_LIBJPEG_ - - -namespace irr -{ -namespace video -{ - - -//! Surface Loader for JPG images -class CImageLoaderJPG : public IImageLoader -{ -public: - - //! constructor - CImageLoaderJPG(); - - //! destructor - virtual ~CImageLoaderJPG(); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".tga") - virtual bool isALoadableFileExtension(const io::path& filename) const; - - //! returns true if the file maybe is able to be loaded by this class - virtual bool isALoadableFileFormat(io::IReadFile* file) const; - - //! creates a surface from the file - virtual IImage* loadImage(io::IReadFile* file) const; - -private: - - #ifdef _IRR_COMPILE_WITH_LIBJPEG_ - // several methods used via function pointers by jpeglib - - /* Receives control for a fatal error. Information sufficient to - generate the error message has been stored in cinfo->err; call - output_message to display it. Control must NOT return to the caller; - generally this routine will exit() or longjmp() somewhere. - Typically you would override this routine to get rid of the exit() - default behavior. Note that if you continue processing, you should - clean up the JPEG object with jpeg_abort() or jpeg_destroy(). - */ - static void error_exit (j_common_ptr cinfo); - - /* output error messages via Irrlicht logger. */ - static void output_message(j_common_ptr cinfo); - - /* Initialize source. This is called by jpeg_read_header() before any - data is actually read. Unlike init_destination(), it may leave - bytes_in_buffer set to 0 (in which case a fill_input_buffer() call - will occur immediately). */ - static void init_source (j_decompress_ptr cinfo); - - /* This is called whenever bytes_in_buffer has reached zero and more - data is wanted. In typical applications, it should read fresh data - into the buffer (ignoring the current state of next_input_byte and - bytes_in_buffer), reset the pointer & count to the start of the - buffer, and return TRUE indicating that the buffer has been reloaded. - It is not necessary to fill the buffer entirely, only to obtain at - least one more byte. bytes_in_buffer MUST be set to a positive value - if TRUE is returned. A FALSE return should only be used when I/O - suspension is desired (this mode is discussed in the next section). */ - static boolean fill_input_buffer (j_decompress_ptr cinfo); - - /* Skip num_bytes worth of data. The buffer pointer and count should - be advanced over num_bytes input bytes, refilling the buffer as - needed. This is used to skip over a potentially large amount of - uninteresting data (such as an APPn marker). In some applications - it may be possible to optimize away the reading of the skipped data, - but it's not clear that being smart is worth much trouble; large - skips are uncommon. bytes_in_buffer may be zero on return. - A zero or negative skip count should be treated as a no-op. */ - static void skip_input_data (j_decompress_ptr cinfo, long num_bytes); - - /* Terminate source --- called by jpeg_finish_decompress() after all - data has been read. Often a no-op. */ - static void term_source (j_decompress_ptr cinfo); - - #endif // _IRR_COMPILE_WITH_LIBJPEG_ -}; - - -} // end namespace video -} // end namespace irr - - -#endif -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CImageLoaderPCX.cpp b/irrlicht-1.6/source/Irrlicht/CImageLoaderPCX.cpp deleted file mode 100644 index 1ebf54e61..000000000 --- a/irrlicht-1.6/source/Irrlicht/CImageLoaderPCX.cpp +++ /dev/null @@ -1,231 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CImageLoaderPCX.h" - -#ifdef _IRR_COMPILE_WITH_PCX_LOADER_ - -#include "IReadFile.h" -#include "SColor.h" -#include "CColorConverter.h" -#include "CImage.h" -#include "os.h" -#include "irrString.h" - - -namespace irr -{ -namespace video -{ - - -//! constructor -CImageLoaderPCX::CImageLoaderPCX() -{ - #ifdef _DEBUG - setDebugName("CImageLoaderPCX"); - #endif -} - - -//! returns true if the file maybe is able to be loaded by this class -//! based on the file extension (e.g. ".tga") -bool CImageLoaderPCX::isALoadableFileExtension(const io::path& filename) const -{ - return core::hasFileExtension ( filename, "pcx" ); -} - - - -//! returns true if the file maybe is able to be loaded by this class -bool CImageLoaderPCX::isALoadableFileFormat(io::IReadFile* file) const -{ - u8 headerID; - file->read(&headerID, sizeof(headerID)); - return headerID == 0x0a; -} - - -//! creates a image from the file -IImage* CImageLoaderPCX::loadImage(io::IReadFile* file) const -{ - SPCXHeader header; - s32* paletteData = 0; - - file->read(&header, sizeof(header)); - #ifdef __BIG_ENDIAN__ - header.XMin = os::Byteswap::byteswap(header.XMin); - header.YMin = os::Byteswap::byteswap(header.YMin); - header.XMax = os::Byteswap::byteswap(header.XMax); - header.YMax = os::Byteswap::byteswap(header.YMax); - header.HorizDPI = os::Byteswap::byteswap(header.HorizDPI); - header.VertDPI = os::Byteswap::byteswap(header.VertDPI); - header.BytesPerLine = os::Byteswap::byteswap(header.BytesPerLine); - header.PaletteType = os::Byteswap::byteswap(header.PaletteType); - header.HScrSize = os::Byteswap::byteswap(header.HScrSize); - header.VScrSize = os::Byteswap::byteswap(header.VScrSize); - #endif - - //! return if the header is wrong - if (header.Manufacturer != 0x0a && header.Encoding != 0x01) - return 0; - - // return if this isn't a supported type - if ((header.BitsPerPixel != 8) && (header.BitsPerPixel != 4) && (header.BitsPerPixel != 1)) - { - os::Printer::log("Unsupported bits per pixel in PCX file.", - file->getFileName(), irr::ELL_WARNING); - return 0; - } - - // read palette - if( (header.BitsPerPixel == 8) && (header.Planes == 1) ) - { - // the palette indicator (usually a 0x0c is found infront of the actual palette data) - // is ignored because some exporters seem to forget to write it. This would result in - // no image loaded before, now only wrong colors will be set. - const long pos = file->getPos(); - file->seek( file->getSize()-256*3, false ); - - u8 *tempPalette = new u8[768]; - paletteData = new s32[256]; - memset(paletteData, 0xFF, 256*sizeof(s32)); - file->read( tempPalette, 768 ); - - for( s32 i=0; i<256; i++ ) - { - paletteData[i] = (tempPalette[i*3+0] << 16) | - (tempPalette[i*3+1] << 8) | - (tempPalette[i*3+2] ); - } - - delete [] tempPalette; - - file->seek(pos); - } - else if( header.BitsPerPixel == 4 ) - { - paletteData = new s32[16]; - memset(paletteData, 0, 16*sizeof(s32)); - for( s32 i=0; i<256; i++ ) - { - paletteData[i] = (header.Palette[i*3+0] << 16) | - (header.Palette[i*3+1] << 8) | - (header.Palette[i*3+2]); - } - } - - // read image data - const s32 width = header.XMax - header.XMin + 1; - const s32 height = header.YMax - header.YMin + 1; - const s32 imagebytes = header.BytesPerLine * header.Planes * header.BitsPerPixel * height / 8; - u8* PCXData = new u8[imagebytes]; - - u8 cnt, value; - s32 lineoffset=0, linestart=0, nextmode=1; - for(s32 offset = 0; offset < imagebytes; offset += cnt) - { - file->read(&cnt, 1); - if( !((cnt & 0xc0) == 0xc0) ) - { - value = cnt; - cnt = 1; - } - else - { - cnt &= 0x3f; - file->read(&value, 1); - } - if (header.Planes==1) - memset(PCXData+offset, value, cnt); - else - { - for (u32 i=0; i<cnt; ++i) - { - PCXData[linestart+lineoffset]=value; - lineoffset += 3; - if (lineoffset>=3*header.BytesPerLine) - { - lineoffset=nextmode; - if (++nextmode==3) - nextmode=0; - if (lineoffset==0) - linestart += 3*header.BytesPerLine; - } - } - } - } - - // create image - video::IImage* image = 0; - s32 pad = (header.BytesPerLine - width * header.BitsPerPixel / 8) * header.Planes; - - if (pad < 0) - pad = -pad; - - if (header.BitsPerPixel==8) - { - switch(header.Planes) // TODO: Other formats - { - case 1: - image = new CImage(ECF_A1R5G5B5, core::dimension2d<u32>(width, height)); - if (image) - CColorConverter::convert8BitTo16Bit(PCXData, (s16*)image->lock(), width, height, paletteData, pad); - break; - case 3: - image = new CImage(ECF_R8G8B8, core::dimension2d<u32>(width, height)); - if (image) - CColorConverter::convert24BitTo24Bit(PCXData, (u8*)image->lock(), width, height, pad); - break; - } - } - else if (header.BitsPerPixel==4) - { - if (header.Planes==1) - { - image = new CImage(ECF_A1R5G5B5, core::dimension2d<u32>(width, height)); - if (image) - CColorConverter::convert4BitTo16Bit(PCXData, (s16*)image->lock(), width, height, paletteData, pad); - } - } - else if (header.BitsPerPixel==1) - { - if (header.Planes==4) - { - image = new CImage(ECF_A1R5G5B5, core::dimension2d<u32>(width, height)); - if (image) - CColorConverter::convert4BitTo16Bit(PCXData, (s16*)image->lock(), width, height, paletteData, pad); - } - else if (header.Planes==1) - { - image = new CImage(ECF_A1R5G5B5, core::dimension2d<u32>(width, height)); - if (image) - CColorConverter::convert1BitTo16Bit(PCXData, (s16*)image->lock(), width, height, pad); - } - } - if (image) - image->unlock(); - - // clean up - - delete [] paletteData; - delete [] PCXData; - - return image; -} - - -//! creates a loader which is able to load pcx images -IImageLoader* createImageLoaderPCX() -{ - return new CImageLoaderPCX(); -} - - - -} // end namespace video -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CImageLoaderPCX.h b/irrlicht-1.6/source/Irrlicht/CImageLoaderPCX.h deleted file mode 100644 index 985e49018..000000000 --- a/irrlicht-1.6/source/Irrlicht/CImageLoaderPCX.h +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_IMAGE_LOADER_PCX_H_INCLUDED__ -#define __C_IMAGE_LOADER_PCX_H_INCLUDED__ - -#include "IrrCompileConfig.h" - -#include "IImageLoader.h" - -namespace irr -{ -namespace video -{ - -#if defined(_IRR_COMPILE_WITH_PCX_LOADER_) || defined(_IRR_COMPILE_WITH_PCX_WRITER_) - -// byte-align structures -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) -# pragma pack( push, packing ) -# pragma pack( 1 ) -# define PACK_STRUCT -#elif defined( __GNUC__ ) -# define PACK_STRUCT __attribute__((packed)) -#else -# error compiler not supported -#endif - - struct SPCXHeader - { - u8 Manufacturer; - u8 Version; - u8 Encoding; - u8 BitsPerPixel; - u16 XMin; - u16 YMin; - u16 XMax; - u16 YMax; - u16 HorizDPI; - u16 VertDPI; - u8 Palette[48]; - u8 Reserved; - u8 Planes; - u16 BytesPerLine; - u16 PaletteType; - u16 HScrSize; - u16 VScrSize; - u8 Filler[54]; - } PACK_STRUCT; - - -// Default alignment -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) -# pragma pack( pop, packing ) -#endif - -#undef PACK_STRUCT - -#endif // compile with loader or writer - -#ifdef _IRR_COMPILE_WITH_PCX_LOADER_ - -/*! - Image Loader for Windows PCX bitmaps. - This loader was written and sent in by Dean P. Macri. I modified - only some small bits of it. -*/ -class CImageLoaderPCX : public IImageLoader -{ -public: - - //! constructor - CImageLoaderPCX(); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".tga") - virtual bool isALoadableFileExtension(const io::path& filename) const; - - //! returns true if the file maybe is able to be loaded by this class - virtual bool isALoadableFileFormat(io::IReadFile* file) const; - - //! creates a surface from the file - virtual IImage* loadImage(io::IReadFile* file) const; - -}; - -#endif // compile with loader - -} // end namespace video -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CImageLoaderPNG.cpp b/irrlicht-1.6/source/Irrlicht/CImageLoaderPNG.cpp deleted file mode 100644 index 4dcbc1cd8..000000000 --- a/irrlicht-1.6/source/Irrlicht/CImageLoaderPNG.cpp +++ /dev/null @@ -1,282 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CImageLoaderPNG.h" - -#ifdef _IRR_COMPILE_WITH_PNG_LOADER_ - -#ifdef _IRR_COMPILE_WITH_LIBPNG_ - #ifndef _IRR_USE_NON_SYSTEM_LIB_PNG_ - #include <png.h> // use system lib png - #else // _IRR_USE_NON_SYSTEM_LIB_PNG_ - #include "libpng/png.h" // use irrlicht included lib png - #endif // _IRR_USE_NON_SYSTEM_LIB_PNG_ -#endif // _IRR_COMPILE_WITH_LIBPNG_ - -#include "CImage.h" -#include "CReadFile.h" -#include "os.h" - -namespace irr -{ -namespace video -{ - -#ifdef _IRR_COMPILE_WITH_LIBPNG_ -// PNG function for error handling -static void png_cpexcept_error(png_structp png_ptr, png_const_charp msg) -{ - os::Printer::log("PNG FATAL ERROR", msg, ELL_ERROR); - longjmp(png_ptr->jmpbuf, 1); -} - -// PNG function for file reading -void PNGAPI user_read_data_fcn(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_size_t check; - - // changed by zola { - io::IReadFile* file=(io::IReadFile*)png_ptr->io_ptr; - check=(png_size_t) file->read((void*)data,(u32)length); - // } - - if (check != length) - png_error(png_ptr, "Read Error"); -} -#endif // _IRR_COMPILE_WITH_LIBPNG_ - - -//! returns true if the file maybe is able to be loaded by this class -//! based on the file extension (e.g. ".tga") -bool CImageLoaderPng::isALoadableFileExtension(const io::path& filename) const -{ -#ifdef _IRR_COMPILE_WITH_LIBPNG_ - return core::hasFileExtension ( filename, "png" ); -#else - return false; -#endif // _IRR_COMPILE_WITH_LIBPNG_ -} - - -//! returns true if the file maybe is able to be loaded by this class -bool CImageLoaderPng::isALoadableFileFormat(io::IReadFile* file) const -{ -#ifdef _IRR_COMPILE_WITH_LIBPNG_ - if (!file) - return false; - - png_byte buffer[8]; - // Read the first few bytes of the PNG file - if (file->read(buffer, 8) != 8) - return false; - - // Check if it really is a PNG file - return !png_sig_cmp(buffer, 0, 8); -#else - return false; -#endif // _IRR_COMPILE_WITH_LIBPNG_ -} - - -// load in the image data -IImage* CImageLoaderPng::loadImage(io::IReadFile* file) const -{ -#ifdef _IRR_COMPILE_WITH_LIBPNG_ - if (!file) - return 0; - - video::IImage* image = 0; - //Used to point to image rows - u8** RowPointers = 0; - - png_byte buffer[8]; - // Read the first few bytes of the PNG file - if( file->read(buffer, 8) != 8 ) - { - os::Printer::log("LOAD PNG: can't read file\n", file->getFileName(), ELL_ERROR); - return 0; - } - - // Check if it really is a PNG file - if( png_sig_cmp(buffer, 0, 8) ) - { - os::Printer::log("LOAD PNG: not really a png\n", file->getFileName(), ELL_ERROR); - return 0; - } - - // Allocate the png read struct - png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, - NULL, (png_error_ptr)png_cpexcept_error, NULL); - if (!png_ptr) - { - os::Printer::log("LOAD PNG: Internal PNG create read struct failure\n", file->getFileName(), ELL_ERROR); - return 0; - } - - // Allocate the png info struct - png_infop info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - os::Printer::log("LOAD PNG: Internal PNG create info struct failure\n", file->getFileName(), ELL_ERROR); - png_destroy_read_struct(&png_ptr, NULL, NULL); - return 0; - } - - // for proper error handling - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - if (RowPointers) - delete [] RowPointers; - return 0; - } - - // changed by zola so we don't need to have public FILE pointers - png_set_read_fn(png_ptr, file, user_read_data_fcn); - - png_set_sig_bytes(png_ptr, 8); // Tell png that we read the signature - - png_read_info(png_ptr, info_ptr); // Read the info section of the png file - - u32 Width; - u32 Height; - s32 BitDepth; - s32 ColorType; - { - // Use temporary variables to avoid passing casted pointers - png_uint_32 w,h; - // Extract info - png_get_IHDR(png_ptr, info_ptr, - &w, &h, - &BitDepth, &ColorType, NULL, NULL, NULL); - Width=w; - Height=h; - } - - // Convert palette color to true color - if (ColorType==PNG_COLOR_TYPE_PALETTE) - png_set_palette_to_rgb(png_ptr); - - // Convert low bit colors to 8 bit colors - if (BitDepth < 8) - { - if (ColorType==PNG_COLOR_TYPE_GRAY || ColorType==PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_gray_1_2_4_to_8(png_ptr); - else - png_set_packing(png_ptr); - } - - if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) - png_set_tRNS_to_alpha(png_ptr); - - // Convert high bit colors to 8 bit colors - if (BitDepth == 16) - png_set_strip_16(png_ptr); - - // Convert gray color to true color - if (ColorType==PNG_COLOR_TYPE_GRAY || ColorType==PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_gray_to_rgb(png_ptr); - - // Update the changes - png_read_update_info(png_ptr, info_ptr); - { - // Use temporary variables to avoid passing casted pointers - png_uint_32 w,h; - // Extract info - png_get_IHDR(png_ptr, info_ptr, - &w, &h, - &BitDepth, &ColorType, NULL, NULL, NULL); - Width=w; - Height=h; - } - - // Convert RGBA to BGRA - if (ColorType==PNG_COLOR_TYPE_RGB_ALPHA) - { -#ifdef __BIG_ENDIAN__ - png_set_swap_alpha(png_ptr); -#else - png_set_bgr(png_ptr); -#endif - } - - // Update the changes - { - // Use temporary variables to avoid passing casted pointers - png_uint_32 w,h; - // Extract info - png_get_IHDR(png_ptr, info_ptr, - &w, &h, - &BitDepth, &ColorType, NULL, NULL, NULL); - Width=w; - Height=h; - } - - // Create the image structure to be filled by png data - if (ColorType==PNG_COLOR_TYPE_RGB_ALPHA) - image = new CImage(ECF_A8R8G8B8, core::dimension2d<u32>(Width, Height)); - else - image = new CImage(ECF_R8G8B8, core::dimension2d<u32>(Width, Height)); - if (!image) - { - os::Printer::log("LOAD PNG: Internal PNG create image struct failure\n", file->getFileName(), ELL_ERROR); - png_destroy_read_struct(&png_ptr, NULL, NULL); - return 0; - } - - // Create array of pointers to rows in image data - RowPointers = new png_bytep[Height]; - if (!RowPointers) - { - os::Printer::log("LOAD PNG: Internal PNG create row pointers failure\n", file->getFileName(), ELL_ERROR); - png_destroy_read_struct(&png_ptr, NULL, NULL); - delete image; - return 0; - } - - // Fill array of pointers to rows in image data - unsigned char* data = (unsigned char*)image->lock(); - for (u32 i=0; i<Height; ++i) - { - RowPointers[i]=data; - data += image->getPitch(); - } - - // for proper error handling - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - delete [] RowPointers; - image->unlock(); - delete [] image; - return 0; - } - - // Read data using the library function that handles all transformations including interlacing - png_read_image(png_ptr, RowPointers); - - png_read_end(png_ptr, NULL); - delete [] RowPointers; - image->unlock(); - png_destroy_read_struct(&png_ptr,&info_ptr, 0); // Clean up memory - - return image; -#else - return 0; -#endif // _IRR_COMPILE_WITH_LIBPNG_ -} - - - -IImageLoader* createImageLoaderPNG() -{ - return new CImageLoaderPng(); -} - - -}// end namespace irr -}//end namespace video - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CImageLoaderPNG.h b/irrlicht-1.6/source/Irrlicht/CImageLoaderPNG.h deleted file mode 100644 index da3c54f85..000000000 --- a/irrlicht-1.6/source/Irrlicht/CImageLoaderPNG.h +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -// this file was created by rt (www.tomkorp.com), based on ttk's png-reader -// i wanted to be able to read in PNG images with irrlicht :) -// why? lossless compression with 8-bit alpha channel! - -#ifndef __C_IMAGE_LOADER_PNG_H_INCLUDED__ -#define __C_IMAGE_LOADER_PNG_H_INCLUDED__ - -#include "IrrCompileConfig.h" - -#ifdef _IRR_COMPILE_WITH_PNG_LOADER_ - -#include "IImageLoader.h" - -namespace irr -{ -namespace video -{ - -//! Surface Loader for PNG files -class CImageLoaderPng : public IImageLoader -{ -public: - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".png") - virtual bool isALoadableFileExtension(const io::path& filename) const; - - //! returns true if the file maybe is able to be loaded by this class - virtual bool isALoadableFileFormat(io::IReadFile* file) const; - - //! creates a surface from the file - virtual IImage* loadImage(io::IReadFile* file) const; -}; - - -} // end namespace video -} // end namespace irr - -#endif -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CImageLoaderPPM.cpp b/irrlicht-1.6/source/Irrlicht/CImageLoaderPPM.cpp deleted file mode 100644 index a5d12745d..000000000 --- a/irrlicht-1.6/source/Irrlicht/CImageLoaderPPM.cpp +++ /dev/null @@ -1,277 +0,0 @@ -// Copyright (C) 2007-2009 Christian Stehno -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CImageLoaderPPM.h" - -#ifdef _IRR_COMPILE_WITH_PPM_LOADER_ - -#include "IReadFile.h" -#include "CColorConverter.h" -#include "CImage.h" -#include "os.h" -#include "fast_atof.h" -#include "coreutil.h" - -namespace irr -{ -namespace video -{ - - -//! constructor -CImageLoaderPPM::CImageLoaderPPM() -{ - #ifdef _DEBUG - setDebugName("CImageLoaderPPM"); - #endif -} - - -//! returns true if the file maybe is able to be loaded by this class -//! based on the file extension (e.g. ".tga") -bool CImageLoaderPPM::isALoadableFileExtension(const io::path& filename) const -{ - return core::hasFileExtension ( filename, "ppm", "pgm", "pbm" ); -} - - -//! returns true if the file maybe is able to be loaded by this class -bool CImageLoaderPPM::isALoadableFileFormat(io::IReadFile* file) const -{ - c8 id[2]={0}; - file->read(&id, 2); - return (id[0]=='P' && id[1]>'0' && id[1]<'7'); -} - - -//! creates a surface from the file -IImage* CImageLoaderPPM::loadImage(io::IReadFile* file) const -{ - IImage* image; - - if (file->getSize() < 12) - return 0; - - c8 id[2]; - file->read(&id, 2); - - if (id[0]!='P' || id[1]<'1' || id[1]>'6') - return 0; - - const u8 format = id[1] - '0'; - const bool binary = format>3; - - core::stringc token; - getNextToken(file, token); - const u32 width = core::strtol10(token.c_str()); - - getNextToken(file, token); - const u32 height = core::strtol10(token.c_str()); - - u8* data = 0; - const u32 size = width*height; - if (format==1 || format==4) - { - skipToNextToken(file); // go to start of data - - const u32 bytesize = size/8+(size & 3)?1:0; - if (binary) - { - if (file->getSize()-file->getPos() < (long)bytesize) - return 0; - data = new u8[bytesize]; - file->read(data, bytesize); - } - else - { - if (file->getSize()-file->getPos() < (long)(2*size)) // optimistic test - return 0; - data = new u8[bytesize]; - memset(data, 0, bytesize); - u32 shift=0; - for (u32 i=0; i<size; ++i) - { - getNextToken(file, token); - if (token == "1") - data[i/8] |= (0x01 << shift); - if (++shift == 8) - shift=0; - } - } - image = new CImage(ECF_A1R5G5B5, core::dimension2d<u32>(width, height)); - if (image) - CColorConverter::convert1BitTo16Bit(data, (s16*)image->lock(), width, height); - } - else - { - getNextToken(file, token); - const u32 maxDepth = core::strtol10(token.c_str()); - if (maxDepth > 255) // no double bytes yet - return 0; - - skipToNextToken(file); // go to start of data - - if (format==2 || format==5) - { - if (binary) - { - if (file->getSize()-file->getPos() < (long)size) - return 0; - data = new u8[size]; - file->read(data, size); - image = new CImage(ECF_A8R8G8B8, core::dimension2d<u32>(width, height)); - if (image) - { - u8* ptr = (u8*)image->lock(); - for (u32 i=0; i<size; ++i) - { - *ptr++ = data[i]; - *ptr++ = data[i]; - *ptr++ = data[i]; - *ptr++ = 255; - } - } - } - else - { - if (file->getSize()-file->getPos() < (long)(2*size)) // optimistic test - return 0; - image = new CImage(ECF_A8R8G8B8, core::dimension2d<u32>(width, height)); - if (image) - { - u8* ptr = (u8*)image->lock(); - for (u32 i=0; i<size; ++i) - { - getNextToken(file, token); - const u8 num = (u8)core::strtol10(token.c_str()); - *ptr++ = num; - *ptr++ = num; - *ptr++ = num; - *ptr++ = 255; - } - } - } - } - else - { - const u32 bytesize = 3*size; - if (binary) - { - if (file->getSize()-file->getPos() < (long)bytesize) - return 0; - data = new u8[bytesize]; - file->read(data, bytesize); - image = new CImage(ECF_A8R8G8B8, core::dimension2d<u32>(width, height)); - if (image) - { - u8* ptr = (u8*)image->lock(); - for (u32 i=0; i<size; ++i) - { - *ptr++ = data[3*i]; - *ptr++ = data[3*i+1]; - *ptr++ = data[3*i+2]; - *ptr++ = 255; - } - } - } - else - { - if (file->getSize()-file->getPos() < (long)(2*bytesize)) // optimistic test - return 0; - image = new CImage(ECF_A8R8G8B8, core::dimension2d<u32>(width, height)); - if (image) - { - u8* ptr = (u8*)image->lock(); - for (u32 i=0; i<size; ++i) - { - getNextToken(file, token); - *ptr++ = (u8)core::strtol10(token.c_str()); - getNextToken(file, token); - *ptr++ = (u8)core::strtol10(token.c_str()); - getNextToken(file, token); - *ptr++ = (u8)core::strtol10(token.c_str()); - *ptr++ = 255; - } - } - } - } - } - - if (image) - image->unlock(); - - delete [] data; - - return image; -} - - -//! read the next token from file -void CImageLoaderPPM::getNextToken(io::IReadFile* file, core::stringc& token) const -{ - token = ""; - c8 c; - while(file->getPos()<file->getSize()) - { - file->read(&c, 1); - if (c=='#') - { - while (c!='\n' && c!='\r' && (file->getPos()<file->getSize())) - file->read(&c, 1); - } - else if (!core::isspace(c)) - { - token.append(c); - break; - } - } - while(file->getPos()<file->getSize()) - { - file->read(&c, 1); - if (c=='#') - { - while (c!='\n' && c!='\r' && (file->getPos()<file->getSize())) - file->read(&c, 1); - } - else if (!core::isspace(c)) - token.append(c); - else - break; - } -} - - -//! skip to next token (skip whitespace) -void CImageLoaderPPM::skipToNextToken(io::IReadFile* file) const -{ - c8 c; - while(file->getPos()<file->getSize()) - { - file->read(&c, 1); - if (c=='#') - { - while (c!='\n' && c!='\r' && (file->getPos()<file->getSize())) - file->read(&c, 1); - } - else if (!core::isspace(c)) - { - file->seek(-1, true); // put back - break; - } - } -} - - -//! creates a loader which is able to load windows bitmaps -IImageLoader* createImageLoaderPPM() -{ - return new CImageLoaderPPM; -} - - -} // end namespace video -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CImageLoaderPPM.h b/irrlicht-1.6/source/Irrlicht/CImageLoaderPPM.h deleted file mode 100644 index 1086be08c..000000000 --- a/irrlicht-1.6/source/Irrlicht/CImageLoaderPPM.h +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2007-2009 Christian Stehno -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_IMAGE_LOADER_PPM_H_INCLUDED__ -#define __C_IMAGE_LOADER_PPM_H_INCLUDED__ - -#include "IrrCompileConfig.h" - -#ifdef _IRR_COMPILE_WITH_PPM_LOADER_ - -#include "IImageLoader.h" -#include "irrString.h" - - -namespace irr -{ -namespace video -{ - - -/*! - Surface Loader for SUN Pixmaps -*/ -class CImageLoaderPPM : public IImageLoader -{ -public: - - //! constructor - CImageLoaderPPM(); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".tga") - virtual bool isALoadableFileExtension(const io::path& filename) const; - - //! returns true if the file maybe is able to be loaded by this class - virtual bool isALoadableFileFormat(io::IReadFile* file) const; - - //! creates a surface from the file - virtual IImage* loadImage(io::IReadFile* file) const; - -private: - //! read the next token from file - void getNextToken(io::IReadFile* file, core::stringc& token) const; - //! skip to next token (skip whitespace) - void skipToNextToken(io::IReadFile* file) const; -}; - -} // end namespace video -} // end namespace irr - - -#endif -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CImageLoaderPSD.cpp b/irrlicht-1.6/source/Irrlicht/CImageLoaderPSD.cpp deleted file mode 100644 index feb5680cc..000000000 --- a/irrlicht-1.6/source/Irrlicht/CImageLoaderPSD.cpp +++ /dev/null @@ -1,375 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CImageLoaderPSD.h" - -#ifdef _IRR_COMPILE_WITH_PSD_LOADER_ - -#include "IReadFile.h" -#include "os.h" -#include "CImage.h" -#include "irrString.h" - - -namespace irr -{ -namespace video -{ - - -//! constructor -CImageLoaderPSD::CImageLoaderPSD() -{ - #ifdef _DEBUG - setDebugName("CImageLoaderPSD"); - #endif -} - - -//! returns true if the file maybe is able to be loaded by this class -//! based on the file extension (e.g. ".tga") -bool CImageLoaderPSD::isALoadableFileExtension(const io::path& filename) const -{ - return core::hasFileExtension ( filename, "psd" ); -} - - - -//! returns true if the file maybe is able to be loaded by this class -bool CImageLoaderPSD::isALoadableFileFormat(io::IReadFile* file) const -{ - if (!file) - return false; - - u8 type[3]; - file->read(&type, sizeof(u8)*3); - return (type[2]==2); // we currently only handle tgas of type 2. -} - - - -//! creates a surface from the file -IImage* CImageLoaderPSD::loadImage(io::IReadFile* file) const -{ - u32* imageData = 0; - - PsdHeader header; - file->read(&header, sizeof(PsdHeader)); - -#ifndef __BIG_ENDIAN__ - header.version = os::Byteswap::byteswap(header.version); - header.channels = os::Byteswap::byteswap(header.channels); - header.height = os::Byteswap::byteswap(header.height); - header.width = os::Byteswap::byteswap(header.width); - header.depth = os::Byteswap::byteswap(header.depth); - header.mode = os::Byteswap::byteswap(header.mode); -#endif - - if (header.signature[0] != '8' || - header.signature[1] != 'B' || - header.signature[2] != 'P' || - header.signature[3] != 'S') - return 0; - - if (header.version != 1) - { - os::Printer::log("Unsupported PSD file version", file->getFileName(), ELL_ERROR); - return 0; - } - - if (header.mode != 3 || header.depth != 8) - { - os::Printer::log("Unsupported PSD color mode or depth.\n", file->getFileName(), ELL_ERROR); - return 0; - } - - // skip color mode data - - u32 l; - file->read(&l, sizeof(u32)); -#ifndef __BIG_ENDIAN__ - l = os::Byteswap::byteswap(l); -#endif - if (!file->seek(l, true)) - { - os::Printer::log("Error seeking file pos to image resources.\n", file->getFileName(), ELL_ERROR); - return 0; - } - - // skip image resources - - file->read(&l, sizeof(u32)); -#ifndef __BIG_ENDIAN__ - l = os::Byteswap::byteswap(l); -#endif - if (!file->seek(l, true)) - { - os::Printer::log("Error seeking file pos to layer and mask.\n", file->getFileName(), ELL_ERROR); - return 0; - } - - // skip layer & mask - - file->read(&l, sizeof(u32)); -#ifndef __BIG_ENDIAN__ - l = os::Byteswap::byteswap(l); -#endif - if (!file->seek(l, true)) - { - os::Printer::log("Error seeking file pos to image data section.\n", file->getFileName(), ELL_ERROR); - return 0; - } - - // read image data - - u16 compressionType; - file->read(&compressionType, sizeof(u16)); -#ifndef __BIG_ENDIAN__ - compressionType = os::Byteswap::byteswap(compressionType); -#endif - - if (compressionType != 1 && compressionType != 0) - { - os::Printer::log("Unsupported psd compression mode.\n", file->getFileName(), ELL_ERROR); - return 0; - } - - // create image data block - - imageData = new u32[header.width * header.height]; - - bool res = false; - - if (compressionType == 0) - res = readRawImageData(file, header, imageData); // RAW image data - else - res = readRLEImageData(file, header, imageData); // RLE compressed data - - video::IImage* image = 0; - - if (res) - { - // create surface - image = new CImage(ECF_A8R8G8B8, - core::dimension2d<u32>(header.width, header.height), imageData); - } - - if (!image) - delete [] imageData; - imageData = 0; - - return image; -} - - -bool CImageLoaderPSD::readRawImageData(io::IReadFile* file, const PsdHeader& header, u32* imageData) const -{ - u8* tmpData = new u8[header.width * header.height]; - - for (s32 channel=0; channel<header.channels && channel < 3; ++channel) - { - if (!file->read(tmpData, sizeof(c8) * header.width * header.height)) - { - os::Printer::log("Error reading color channel\n", file->getFileName(), ELL_ERROR); - break; - } - - s16 shift = getShiftFromChannel((c8)channel, header); - if (shift != -1) - { - u32 mask = 0xff << shift; - - for (u32 x=0; x<header.width; ++x) - { - for (u32 y=0; y<header.height; ++y) - { - s32 index = x + y*header.width; - imageData[index] = ~(~imageData[index] | mask); - imageData[index] |= tmpData[index] << shift; - } - } - } - - } - - delete [] tmpData; - return true; -} - - -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 - (LayerBottom LayerTop), with each count stored as a two - byte value. The RLE compressed data follows, with each scan line - compressed separately. The RLE compression is the same compres-sion - algorithm used by the Macintosh ROM routine PackBits, and - the TIFF standard. - If the Layer's Size, and therefore the data, is odd, a pad byte will - be inserted at the end of the row. - */ - - /* - A pseudo code fragment to unpack might look like this: - - Loop until you get the number of unpacked bytes you are expecting: - Read the next source byte into n. - If n is between 0 and 127 inclusive, copy the next n+1 bytes literally. - Else if n is between -127 and -1 inclusive, copy the next byte -n+1 - times. - Else if n is -128, noop. - Endloop - - In the inverse routine, it is best to encode a 2-byte repeat run as a replicate run - except when preceded and followed by a literal run. In that case, it is best to merge - the three runs into one literal run. Always encode 3-byte repeats as replicate runs. - That is the essence of the algorithm. Here are some additional rules: - - Pack each row separately. Do not compress across row boundaries. - - The number of uncompressed bytes per row is defined to be (ImageWidth + 7) - / 8. If the uncompressed bitmap is required to have an even number of bytes per - row, decompress into word-aligned buffers. - - If a run is larger than 128 bytes, encode the remainder of the run as one or more - additional replicate runs. - When PackBits data is decompressed, the result should be interpreted as per com-pression - type 1 (no compression). - */ - - u8* tmpData = new u8[header.width * header.height]; - u16 *rleCount= new u16 [header.height * header.channels]; - - s32 size=0; - - for (u32 y=0; y<header.height * header.channels; ++y) - { - if (!file->read(&rleCount[y], sizeof(u16))) - { - delete [] tmpData; - delete [] rleCount; - os::Printer::log("Error reading rle rows\n", file->getFileName(), ELL_ERROR); - return false; - } - -#ifndef __BIG_ENDIAN__ - rleCount[y] = os::Byteswap::byteswap(rleCount[y]); -#endif - size += rleCount[y]; - } - - s8 *buf = new s8[size]; - if (!file->read(buf, size)) - { - delete [] rleCount; - delete [] buf; - delete [] tmpData; - os::Printer::log("Error reading rle rows\n", file->getFileName(), ELL_ERROR); - return false; - } - - u16 *rcount=rleCount; - - s8 rh; - u16 bytesRead; - u8 *dest; - s8 *pBuf = buf; - - // decompress packbit rle - - for (s32 channel=0; channel<header.channels; channel++) - { - for (u32 y=0; y<header.height; ++y, ++rcount) - { - bytesRead=0; - dest = &tmpData[y*header.width]; - - while (bytesRead < *rcount) - { - rh = *pBuf++; - ++bytesRead; - - if (rh >= 0) - { - ++rh; - - while (rh--) - { - *dest = *pBuf++; - ++bytesRead; - ++dest; - } - } - else - if (rh > -128) - { - rh = -rh +1; - - while (rh--) - { - *dest = *pBuf; - ++dest; - } - - ++pBuf; - ++bytesRead; - } - } - } - - s16 shift = getShiftFromChannel((c8)channel, header); - - if (shift != -1) - { - u32 mask = 0xff << shift; - - for (u32 x=0; x<header.width; ++x) - for (u32 y=0; y<header.height; ++y) - { - s32 index = x + y*header.width; - imageData[index] = ~(~imageData[index] | mask); - imageData[index] |= tmpData[index] << shift; - } - } - } - - delete [] rleCount; - delete [] buf; - delete [] tmpData; - - return true; -} - - -s16 CImageLoaderPSD::getShiftFromChannel(c8 channelNr, const PsdHeader& header) const -{ - switch(channelNr) - { - case 0: - return 16; // red - case 1: - return 8; // green - case 2: - return 0; // blue - case 3: - return header.channels == 4 ? 24 : -1; // ? - case 4: - return 24; // alpha - default: - return -1; - } -} - - - -//! creates a loader which is able to load tgas -IImageLoader* createImageLoaderPSD() -{ - return new CImageLoaderPSD(); -} - - -} // end namespace video -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CImageLoaderPSD.h b/irrlicht-1.6/source/Irrlicht/CImageLoaderPSD.h deleted file mode 100644 index 31ee679bc..000000000 --- a/irrlicht-1.6/source/Irrlicht/CImageLoaderPSD.h +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_IMAGE_LOADER_PSD_H_INCLUDED__ -#define __C_IMAGE_LOADER_PSD_H_INCLUDED__ - -#include "IrrCompileConfig.h" - -#ifdef _IRR_COMPILE_WITH_PSD_LOADER_ - -#include "IImageLoader.h" - -namespace irr -{ -namespace video -{ - - -// byte-align structures -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) -# pragma pack( push, packing ) -# pragma pack( 1 ) -# define PACK_STRUCT -#elif defined( __GNUC__ ) -# define PACK_STRUCT __attribute__((packed)) -#else -# error compiler not supported -#endif - - struct PsdHeader - { - c8 signature [4]; // Always equal to 8BPS. - u16 version; // Always equal to 1 - c8 reserved [6]; // Must be zero - u16 channels; // Number of any channels inc. alphas - u32 height; // Rows Height of image in pixel - u32 width; // Colums Width of image in pixel - u16 depth; // Bits/channel - u16 mode; // Color mode of the file (Bitmap/Grayscale..) - } PACK_STRUCT; - - -// Default alignment -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) -# pragma pack( pop, packing ) -#endif - -#undef PACK_STRUCT - -/*! - Surface Loader for psd images -*/ -class CImageLoaderPSD : public IImageLoader -{ -public: - - //! constructor - CImageLoaderPSD(); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".tga") - virtual bool isALoadableFileExtension(const io::path& filename) const; - - //! returns true if the file maybe is able to be loaded by this class - virtual bool isALoadableFileFormat(io::IReadFile* file) const; - - //! creates a surface from the file - virtual IImage* loadImage(io::IReadFile* file) const; - -private: - - 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; -}; - - -} // end namespace video -} // end namespace irr - -#endif -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CImageLoaderRGB.cpp b/irrlicht-1.6/source/Irrlicht/CImageLoaderRGB.cpp deleted file mode 100644 index 1462c5aab..000000000 --- a/irrlicht-1.6/source/Irrlicht/CImageLoaderRGB.cpp +++ /dev/null @@ -1,651 +0,0 @@ -//! Copyright (C) 2009 Gary Conway -//! This file is part of the "Irrlicht Engine". -//! For conditions of distribution and use, see copyright notice in irrlicht.h - -/* - Author: Gary Conway (Viper) - co-author of the ZIP file format, Feb 1989, - see the story at http://www.idcnet.us/ziphistory.html - Website: http://idcnet.us - Email: codeslinger@vipergc.com - Created: March 1, 2009 - Version: 1.0 - Updated: - - This module will load SGI .rgb files (along with the other extensions). The module complies - with version 1.0 of the SGI Image File Format by Paul Haeberli of Silicon Graphics Computer Systems - The module handles BW, RGB and RGBA images. - - RGB images are stored with either 8 bits per COLOR VALUE, one each for red,green,blue (24bpp) - or 16 bits per COLOR VALUE, again one each for red,green,blue (48 bpp), not including the alpha channel - - - OPTIONS NOT SUPPORTED - - 1. 16 bit COLOR VALUES (48bpp modes) - 2. COLORMAP = DITHERED mode - - - -For non- run length encoded files, this is the structure - - The Header - The Image Data - -If the image is run length encoded, this is the structure: - The Header - The Offset Tables - The Image Data - -The Header consists of the following: - - Size | Type | Name | Description - - 2 bytes | short | MAGIC | IRIS image file magic number - 1 byte | char | STORAGE | Storage format - 1 byte | char | BPC | Number of bytes per pixel channel - 2 bytes | ushort | DIMENSION | Number of dimensions - 2 bytes | ushort | XSIZE | X size in pixels - 2 bytes | ushort | YSIZE | Y size in pixels - 2 bytes | ushort | ZSIZE | Number of channels - 4 bytes | long | PIXMIN | Minimum pixel value - 4 bytes | long | PIXMAX | Maximum pixel value - 4 bytes | char | DUMMY | Ignored - 80 bytes | char | IMAGENAME | Image name - 4 bytes | long | COLORMAP | Colormap ID - 404 bytes | char | DUMMY | Ignored - -Here is a description of each field in the image file Header: - -MAGIC - This is the decimal value 474 saved as a short. This identifies the file as an SGI image file. - -STORAGE - specifies whether the image is stored using run length encoding (RLE) or not (VERBATIM). - If RLE is used, the value of this byte will be 1. Otherwise the value of this byte will - be 0. The only allowed values for this field are 0 or 1. - -BPC - describes the precision that is used to store each channel of an image. This is the number of - bytes per pixel component. The majority of SGI image files use 1 byte per pixel component, - giving 256 levels. Some SGI image files use 2 bytes per component. The only allowed values - for this field are 1 or 2. - -DIMENSION - described the number of dimensions in the data stored in the image file. - The only allowed values are 1, 2, or 3. If this value is 1, the image file - consists of only 1 channel and only 1 scanline (row). The length of this - scanline is given by the value of XSIZE below. If this value is 2, the file - consists of a single channel with a number of scanlines. The width and height - of the image are given by the values of XSIZE and YSIZE below. - If this value is 3, the file consists of a number of channels. - The width and height of the image are given by the values of XSIZE and YSIZE below. - The number of channels is given by the value of ZSIZE below. - -XSIZE - The width of the image in pixels - -YSIZE - The height of the image in pixels - -ZSIZE - The number of channels in the image. B/W (greyscale) images are stored as 2 dimensional - images with a ZSIZE of 1. RGB color images are stored as 3 dimensional images with a - ZSIZE of 3. An RGB image with an ALPHA channel is stored as a 3 dimensional image with - a ZSIZE of 4. There are no inherent limitations in the SGI image file format that would - preclude the creation of image files with more than 4 channels. - -PINMIN - The minimum pixel value in the image. The value of 0 may be used if no pixel has a value - that is smaller than 0. - -PINMAX - The maximum pixel value in the image. The value of 255 may be used if no pixel has a - value that is greater than 255. This is the value that is considered to be full - brightness in the image. - -DUMMY - This 4 bytes of data should be set to 0. - -IMAGENAME - An null terminated ascii string of up to 79 characters terminated by a null may be - included here. This is not commonly used. - -COLORMAP - This controls how the pixel values in the file should be interpreted. It can have one - of these four values: - -0: NORMAL - The data in the channels represent B/W values for images with 1 channel, RGB values - for images with 3 channels, and RGBA values for images with 4 channels. Almost all - the SGI image files are of this type. - -1: DITHERED - The image will have only 1 channel of data. For each pixel, RGB data is packed - into one 8 bit value. 3 bits are used for red and green, while blue uses 2 bits. - Red data is found in bits[2..0], green data in bits[5..3], and blue data in - bits[7..6]. This format is obsolete. - -2: SCREEN - The image will have only 1 channel of data. This format was used to store - color-indexed pixels. To convert the pixel values into RGB values a colormap - must be used. The appropriate color map varies from image to image. This format is obsolete. - -3: COLORMAP - The image is used to store a color map from an SGI machine. In this case the - image is not displayable in the conventional sense. - -DUMMY - This 404 bytes of data should be set to 0. This makes the Header exactly 512 bytes. -*/ - -#include "CImageLoaderRGB.h" - -#ifdef _IRR_COMPILE_WITH_RGB_LOADER_ - -#include "IReadFile.h" -#include "SColor.h" -#include "CColorConverter.h" -#include "CImage.h" -#include "os.h" -#include "irrString.h" - - -namespace irr -{ -namespace video -{ - -//! constructor -CImageLoaderRGB::CImageLoaderRGB() -{ - #ifdef _DEBUG - setDebugName("CImageLoaderRGB"); - #endif -} - - -//! returns true if the file maybe is able to be loaded by this class -//! based on the file extensions listed here -bool CImageLoaderRGB::isALoadableFileExtension(const io::path& filename) const -{ - return core::hasFileExtension( filename, "rgb", "rgba", "sgi" ) || - core::hasFileExtension( filename, "int", "inta", "bw" ); -} - - -//! returns true if the file maybe is able to be loaded by this class -bool CImageLoaderRGB::isALoadableFileFormat(io::IReadFile* file) const -{ - rgbStruct rgb; - return checkFormat(file, rgb); -} - - -/** The main entry point, read and format the image file. -\return Pointer to the image data on success - null pointer on fail */ -IImage* CImageLoaderRGB::loadImage(io::IReadFile* file) const -{ - IImage* image = 0; - s32* paletteData = 0; - - rgbStruct rgb; // construct our structure for holding data - - // read Header information - if (checkFormat(file, rgb)) - { - // 16 bits per COLOR VALUE, not supported, this is 48bpp mode - if (rgb.Header.BPC != 1) - { - os::Printer::log("Only one byte per pixel RGB files are supported", file->getFileName(), ELL_ERROR); - } - else if (rgb.Header.Colormap != 0) - { - os::Printer::log("Dithered, Screen and Colormap RGB files are not supported", file->getFileName(), ELL_ERROR); - } - else if (rgb.Header.Storage == 1 && !readOffsetTables(file, rgb)) - { - os::Printer::log("Failed to read RLE table in RGB file", file->getFileName(), ELL_ERROR); - } - else if (!rgb.allocateTemps()) - { - os::Printer::log("Out of memory in RGB file loader", file->getFileName(), ELL_ERROR); - } - else - { - // read and process the file to rgbData - processFile(file, rgb); - -/* - ZSIZE Description - 1 BW (grayscale) image - 3 RGB image - 4 RGBa image with one alpha channel - - When the Alpha channel is present, I am not sure with RGB files if - it's a precomputed RGB color or it needs to be completely calculated. My guess - would be that it's not precomputed for two reasons. - - 1. the loss of precision when calculating the fraction, then storing the result as an int - 2. the loss of the original color data when the image might be composited with another. Yes - the original color data could be computed, however, not without another loss in precision - - Also, I don't know where to find the background color - Pixmin and Pixmax are apparently the min and max alpha blend values (0-100%) - - Complete Alpha blending computation - The actual resulting merged color is computed this way: - (image color ◊ alpha) + (background color ◊ (100% - alpha)). - - Using precomputed blending - (image color) + (background color ◊ (100% - alpha)). - - Alternatively, the RGB files could use another blending technique entirely -*/ - - switch (rgb.Header.Zsize) - { - case 1: - // BW (grayscale) image - paletteData = new s32[256]; - for (int n=0; n<256; n++) - paletteData[n] = n; - - image = new CImage(ECF_A1R5G5B5, core::dimension2d<u32>(rgb.Header.Xsize, rgb.Header.Ysize)); - if (image) - CColorConverter::convert8BitTo16Bit(rgb.rgbData, (s16*)image->lock(), rgb.Header.Xsize, rgb.Header.Ysize, paletteData, 0, true); - break; - case 3: - // RGB image - // one byte per COLOR VALUE, eg, 24bpp - image = new CImage(ECF_R8G8B8, core::dimension2d<u32>(rgb.Header.Xsize, rgb.Header.Ysize)); - if (image) - CColorConverter::convert24BitTo24Bit(rgb.rgbData, (u8*)image->lock(), rgb.Header.Xsize, rgb.Header.Ysize, 0, true, false); - break; - case 4: - // RGBa image with one alpha channel (32bpp) - // image is stored in rgbData as RGBA - - converttoARGB(reinterpret_cast<u32*>(rgb.rgbData), rgb.Header.Ysize * rgb.Header.Xsize); - - image = new CImage(ECF_A8R8G8B8, core::dimension2d<u32>(rgb.Header.Xsize, rgb.Header.Ysize)); - if (image) - CColorConverter::convert32BitTo32Bit((s32*)rgb.rgbData, (s32*)image->lock(), rgb.Header.Xsize, rgb.Header.Ysize, 0, true); - - break; - default: - // Format unknown - os::Printer::log("Unsupported pixel format in RGB file", file->getFileName(), ELL_ERROR); - } - - if (image) - image->unlock(); - } - } - - // and tidy up allocated memory - delete [] paletteData; - - return image; -} - -// returns true on success -bool CImageLoaderRGB::readHeader(io::IReadFile* file, rgbStruct& rgb) const -{ - if ( file->read(&rgb.Header, sizeof(rgb.Header)) < s32(sizeof(rgb.Header)) ) - return false; - - // test for INTEL or BIG ENDIAN processor - // if INTEL, then swap the byte order on 16 bit INT's to make them BIG ENDIAN - // because that is the native format for the .rgb file -#ifndef __BIG_ENDIAN__ - rgb.Header.Magic = os::Byteswap::byteswap(rgb.Header.Magic); - rgb.Header.Storage = os::Byteswap::byteswap(rgb.Header.Storage); - rgb.Header.Dimension = os::Byteswap::byteswap(rgb.Header.Dimension); - rgb.Header.Xsize = os::Byteswap::byteswap(rgb.Header.Xsize); - rgb.Header.Ysize = os::Byteswap::byteswap(rgb.Header.Ysize); - rgb.Header.Zsize = os::Byteswap::byteswap(rgb.Header.Zsize); - rgb.Header.Pixmin = os::Byteswap::byteswap(rgb.Header.Pixmin); - rgb.Header.Pixmax = os::Byteswap::byteswap(rgb.Header.Pixmax); - rgb.Header.Colormap = os::Byteswap::byteswap(rgb.Header.Colormap); -#endif - - // calculate the size of the buffer needed: XSIZE * YSIZE * ZSIZE * BPC - rgb.ImageSize = (rgb.Header.Xsize)*(rgb.Header.Ysize)*(rgb.Header.Zsize)*(rgb.Header.BPC); - - return true; -} - - -bool CImageLoaderRGB::checkFormat(io::IReadFile* file, rgbStruct& rgb) const -{ - if (!readHeader(file, rgb)) - return false; - - return (rgb.Header.Magic == 0x1DA); -} - -/* -If the image is stored using run length encoding, offset tables follow the Header that -describe what the file offsets are to the RLE for each scanline. This information only -applies if the value for STORAGE above is 1. - - Size | Type | Name | Description - - tablen longs | long | STARTTAB | Start table - tablen longs | long | LENGTHTAB | Length table - -One entry in each table is needed for each scanline of RLE data. The total number of scanlines in the image (tablen) is determined by the product of the YSIZE and ZSIZE. There are two tables of longs that are written. Each consists of tablen longs of data. The first table has the file offsets to the RLE data for each scanline in the image. In a file with more than 1 channel (ZSIZE > 1) this table first has all the offsets for the scanlines in the first channel, followed be offsets for the scanlines in the second channel, etc. The second table has the RLE data length for each scanline in the image. In a file with more than 1 channel (ZSIZE > 1) this table first has all the RLE data lengths for the scanlines in the first channel, followed be RLE data lengths for the scanlines in the second channel, etc. - -To find the the file offset, and the number of bytes in the RLE data for a particular scanline, these -two arrays may be read in and indexed as follows: - -To read in the tables: - - unsigned long *starttab, *lengthtab; - - tablen = YSIZE*ZSIZE*sizeof(long); - starttab = (unsigned long *)mymalloc(tablen); - lengthtab = (unsigned long *)mymalloc(tablen); - fseek(rgb->inf,512,SEEK_SET); - readlongtab(rgb->inf,starttab); - readlongtab(rgb->inf,lengthtab); - -To find the file offset and RLE data length for a scanline: - -rowno is an integer in the range 0 to YSIZE-1 channo is an integer in the range 0 to ZSIZE-1 - - rleoffset = starttab[rowno+channo*YSIZE] - rlelength = lengthtab[rowno+channo*YSIZE] - -It is possible for two identical rows (scanlines) to share compressed data. A completely -white image could be written as a single compressed row and having all table entries point -to that row. Another little hack that should work is if you are writing out a RGB RLE file, -and a particular scanline is achromatic (greyscale), you could just make the r, g and b rows -point to the same data!! - - RETURNS: on success true, else returns false -*/ - -bool CImageLoaderRGB::readOffsetTables(io::IReadFile* file, rgbStruct& rgb) const -{ - rgb.TableLen = rgb.Header.Ysize * rgb.Header.Zsize ; // calc size of tables - - // return error if unable to allocate tables - if ( !(rgb.StartTable = new u32[rgb.TableLen]) ) - return false; - if ( !(rgb.LengthTable = new u32[rgb.TableLen]) ) - return false; - - file->seek(512); - file->read(rgb.StartTable, rgb.TableLen* sizeof(u32)); - file->read(rgb.LengthTable, rgb.TableLen* sizeof(u32)); - - // if we are on an INTEL platform, swap the bytes -#ifndef __BIG_ENDIAN__ - const u32 length = rgb.TableLen; - for (u32 i=0; i<length; ++i) - { - rgb.StartTable[i] = os::Byteswap::byteswap(rgb.StartTable[i]); - rgb.LengthTable[i] = os::Byteswap::byteswap(rgb.LengthTable[i]); - } -#endif - - return true; -} - - -/* - The Header has already been read into rgb structure - The Tables have been read if necessary - Now process the actual data -*/ -void CImageLoaderRGB::processFile(io::IReadFile* file, rgbStruct& rgb) const -{ - u16 *tempShort; - - // calculate the size of the buffer needed: XSIZE * YSIZE * ZSIZE * BPC - rgb.rgbData = new u8 [(rgb.Header.Xsize)*(rgb.Header.Ysize)*(rgb.Header.Zsize)*(rgb.Header.BPC)]; - u8 *ptr = rgb.rgbData; - - // cycle through all scanlines - -#ifdef _IRR_RGB_FILE_INVERTED_IMAGE_ - // preserve the image as stored, eg, inverted - for (u32 i = 0; i < rgb.Header.Ysize; ++i) -#else - // invert the image to make it upright - for (s32 i = (s32)(rgb.Header.Ysize)-1; i>=0; --i) -#endif - { - // check the number of channels and read a row of data - if (rgb.Header.Zsize >= 1) - readRGBrow( rgb.tmpR, i, 0, file, rgb); - if (rgb.Header.Zsize >= 2) - readRGBrow( rgb.tmpG, i, 1, file, rgb); - if (rgb.Header.Zsize >= 3) - readRGBrow( rgb.tmpB, i, 2, file, rgb); - if (rgb.Header.Zsize >= 4) - readRGBrow( rgb.tmpA, i, 3, file, rgb); - - // cycle thru all values for this row - for (u32 j = 0; j < rgb.Header.Xsize; ++j) - { - if(rgb.Header.BPC == 1) - { - // ONE byte per color - if (rgb.Header.Zsize >= 1) - *ptr++ = rgb.tmpR[j]; - if (rgb.Header.Zsize >= 2) - *ptr++ = rgb.tmpG[j]; - if (rgb.Header.Zsize >= 3) - *ptr++ = rgb.tmpB[j]; - if (rgb.Header.Zsize >= 4) - *ptr++ = rgb.tmpA[j]; - } - else - { - // TWO bytes per color - if( rgb.Header.Zsize >= 1 ) - { - // two bytes of color data - tempShort = (u16 *) (ptr); - *tempShort = *( (u16 *) (rgb.tmpR) + j); - tempShort++; - ptr = ( u8 *)(tempShort); - } - if( rgb.Header.Zsize >= 2 ) - { - tempShort = ( u16 *) (ptr); - *tempShort = *( ( u16 *) (rgb.tmpG) + j); - tempShort++; - ptr = ( u8 *) (tempShort); - } - if( rgb.Header.Zsize >= 3 ) - { - tempShort = ( u16 *) (ptr); - *tempShort = *( ( u16 *) (rgb.tmpB) + j); - tempShort++; - ptr = ( u8 *)(tempShort); - } - if( rgb.Header.Zsize >= 4 ) - { - tempShort = ( u16 *) (ptr); - *tempShort = *( ( u16 *) (rgb.tmpA) + j); - tempShort++; - ptr = ( u8 *)(tempShort); - } - } // end if(rgb.Header.BPC == 1) - } // end for - } // end for -} - - -/* - This information only applies if the value for STORAGE is 1. If the image is - stored using run length encoding, the image data follows the offset/length tables. - The RLE data is not in any particular order. The offset tables are used to - locate the rle data for any scanline. - - The RLE data must be read in from the file and expanded into pixel data in the following manner: - - If BPC is 1, then there is one byte per pixel. In this case the RLE data should be - read into an array of chars. To expand data, the low order seven bits of the first - byte: bits[6..0] are used to form a count. If the high order bit of the first byte - is 1: bit[7], then the count is used to specify how many bytes to copy from the RLE - data buffer to the destination. Otherwise, if the high order bit of the first byte - is 0: bit[7], then the count is used to specify how many times to repeat the value - of the following byte, in the destination. This process continues until a count - of 0 is found. This should decompress exactly XSIZE pixels. - - - One entry in each table is needed for each scanline of RLE data. The total number of - scanlines in the image (tablen) is determined by the product of the YSIZE and ZSIZE. - There are two tables of longs that are written. Each consists of tablen longs of data. - The first table has the file offsets to the RLE data for each scanline in the image. In - a file with more than 1 channel (ZSIZE > 1) this table first has all the offsets for the - scanlines in the first channel, followed be offsets for the scanlines in the second - channel, etc. The second table has the RLE data length for each scanline in the image. - In a file with more than 1 channel (ZSIZE > 1) this table first has all the RLE data - lengths for the scanlines in the first channel, followed be RLE data lengths for the - scanlines in the second channel, etc. - - Return a row of data, expanding RLE compression if necessary -*/ -void CImageLoaderRGB::readRGBrow(u8 *buf, int y, int z, io::IReadFile* file, rgbStruct& rgb) const -{ - if (rgb.Header.Storage != 1) - { - // stored VERBATIM - - file->seek(512+(y*rgb.Header.Xsize * rgb.Header.BPC)+(z* rgb.Header.Xsize * rgb.Header.Ysize * rgb.Header.BPC)); - file->read(buf, rgb.Header.Xsize * rgb.Header.BPC); - -#ifndef __BIG_ENDIAN__ - if (rgb.Header.BPC != 1) - { - u16* tmpbuf = reinterpret_cast<u16*>(buf); - for (u32 i=0; i<rgb.Header.Xsize; ++i) - tmpbuf[i] = os::Byteswap::byteswap(tmpbuf[i]); - } -#endif - return; - } - - // the file is stored as Run Length Encoding (RLE) - // each sequence is stored as 0x80 NumRepeats ByteToRepeat - - // get the file offset from StartTable and SEEK - // then read the data - - file->seek((long) rgb.StartTable[y+z * rgb.Header.Ysize]); - file->read(rgb.tmp, rgb.LengthTable[y+z * rgb.Header.Ysize]); - - // rgb.tmp has the data - - u16 pixel; - u16 *tempShort; - u8* iPtr = rgb.tmp; - u8* oPtr = buf; - while (true) - { - // if BPC = 1, then one byte per pixel - if (rgb.Header.BPC == 1) - { - pixel = *iPtr++; - } - else - { - // BPC = 2, so two bytes per pixel - tempShort = (u16 *) iPtr; - pixel = *tempShort; - tempShort++; - iPtr = (u8 *) tempShort; - } - -#ifndef __BIG_ENDIAN__ - if (rgb.Header.BPC != 1) - pixel = os::Byteswap::byteswap(pixel); -#endif - - s32 count = (s32)(pixel & 0x7F); - - // limit the count value to the remaining row size - if (oPtr + count*rgb.Header.BPC > buf + rgb.Header.Xsize * rgb.Header.BPC) - { - count = ( (buf + rgb.Header.Xsize * rgb.Header.BPC) - oPtr ) / rgb.Header.BPC; - } - - if (count<=0) - break; - else if (pixel & 0x80) - { - // repeat the byte pointed to by iPtr, count times - while (count--) - { - if(rgb.Header.BPC == 1) - { - *oPtr++ = *iPtr++; - } - else - { - // write pixel from iPtr to oPtr, move both two bytes ahead - tempShort = (u16 *) (iPtr); - pixel = *tempShort; - tempShort++; - iPtr = (u8 *) (tempShort); -#ifndef __BIG_ENDIAN__ - pixel = os::Byteswap::byteswap(pixel); -#endif - tempShort = (u16 *) (oPtr); - *tempShort = pixel; - tempShort++; - oPtr = (u8 *) (tempShort); - } - } - } - else - { - if (rgb.Header.BPC == 1) - { - pixel = *iPtr++; - } - else - { - tempShort = (u16 *) (iPtr); - pixel = *tempShort; - tempShort++; - iPtr = (u8 *) (tempShort); - } - -#ifndef __BIG_ENDIAN__ - if (rgb.Header.BPC != 1) - pixel = os::Byteswap::byteswap(pixel); -#endif - - while (count--) - { - if(rgb.Header.BPC == 1) - { - *oPtr++ = (u8) pixel; - } - else - { - tempShort = (u16 *) (oPtr); - *tempShort = pixel; - tempShort++; - oPtr = (u8 *) (tempShort); - } - } - } // else if (pixel & 0x80) - } // while (true) -} - - -// we have 1 byte per COLOR VALUE, eg 24bpp and 1 alpha channel -// color values are stored as RGBA, convert to ARGB -// todo: replace with CColorConverter method -void CImageLoaderRGB::converttoARGB(u32* in, const u32 size) const -{ - for (u32 x=0; x < size; ++x) - { - *in=(*in>>8)|(*in<<24); - ++in; - } -} - - -//! creates a loader which is able to load SGI RGB images -IImageLoader* createImageLoaderRGB() -{ - return new CImageLoaderRGB; -} - - -} // end namespace video -} // end namespace irr - -#endif diff --git a/irrlicht-1.6/source/Irrlicht/CImageLoaderRGB.h b/irrlicht-1.6/source/Irrlicht/CImageLoaderRGB.h deleted file mode 100644 index aca38d5dd..000000000 --- a/irrlicht-1.6/source/Irrlicht/CImageLoaderRGB.h +++ /dev/null @@ -1,172 +0,0 @@ -// Copyright (C) 2009 Gary Conway -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - - -/* - Author: Gary Conway (Viper) - co-author of the ZIP file format, Feb 1989, - see the story at http://www.idcnet.us/ziphistory.html - Website: http://idcnet.us - Email: codeslinger@vipergc.com - Created: March 1, 2009 - Version: 1.0 - Updated: -*/ - -#ifndef __C_IMAGE_LOADER_RGB_H_INCLUDED__ -#define __C_IMAGE_LOADER_RGB_H_INCLUDED__ - -// define _IRR_RGB_FILE_INVERTED_IMAGE_ to preserve the inverted format of the RGB file -// commenting this out will invert the inverted image,resulting in the image being upright -#define _IRR_RGB_FILE_INVERTED_IMAGE_ - -#include "IrrCompileConfig.h" - -#ifdef _IRR_COMPILE_WITH_RGB_LOADER_ - -#include "IImageLoader.h" - -namespace irr -{ -namespace video -{ - -// byte-align structures -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) -# pragma pack( push, packing ) -# pragma pack( 1 ) -# define PACK_STRUCT -#elif defined( __GNUC__ ) -# define PACK_STRUCT __attribute__((packed)) -#else -# error compiler not supported -#endif - - // the RGB image file header structure - - struct SRGBHeader - { - u16 Magic; // IRIS image file magic number - u8 Storage; // Storage format - u8 BPC; // Number of bytes per pixel channel - u16 Dimension; // Number of dimensions - u16 Xsize; // X size in pixels - u16 Ysize; // Y size in pixels - u16 Zsize; // Z size in pixels - u32 Pixmin; // Minimum pixel value - u32 Pixmax; // Maximum pixel value - u32 Dummy1; // ignored - char Imagename[80]; // Image name - u32 Colormap; // Colormap ID -// char Dummy2[404]; // Ignored - } PACK_STRUCT; - -// Default alignment -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) -# pragma pack( pop, packing ) -#endif - -#undef PACK_STRUCT - - // this structure holds context specific data about the file being loaded. - - typedef struct _RGBdata - { - u8 *tmp, - *tmpR, - *tmpG, - *tmpB, - *tmpA; - - - u32 *StartTable; // compressed data table, holds file offsets - u32 *LengthTable; // length for the above data, hold lengths for above - u32 TableLen; // len of above tables - - SRGBHeader Header; // define the .rgb file header - u32 ImageSize; - u8 *rgbData; - - public: - _RGBdata() : tmp(0), tmpR(0), tmpG(0), tmpB(0), tmpA(0), - StartTable(0), LengthTable(0), TableLen(0), ImageSize(0), rgbData(0) - { - } - - ~_RGBdata() - { - delete [] tmp; - delete [] tmpR; - delete [] tmpG; - delete [] tmpB; - delete [] tmpA; - delete [] StartTable; - delete [] LengthTable; - delete [] rgbData; - } - - bool allocateTemps() - { - tmp = tmpR = tmpG = tmpB = tmpA = 0; - tmp = new u8 [Header.Xsize * 256 * Header.BPC]; - if (!tmp) - return false; - - if (Header.Zsize >= 1) - { - if ( !(tmpR = new u8 [Header.Xsize * Header.BPC]) ) - return false; - } - if (Header.Zsize >= 2) - { - if ( !(tmpG = new u8 [Header.Xsize * Header.BPC]) ) - return false; - } - if (Header.Zsize >= 3) - { - if ( !(tmpB = new u8 [Header.Xsize * Header.BPC]) ) - return false; - } - if (Header.Zsize >= 4) - { - if ( !(tmpA = new u8 [Header.Xsize * Header.BPC]) ) - return false; - } - return true; - } - } rgbStruct; - - -//! Surface Loader for Silicon Graphics RGB files -class CImageLoaderRGB : public IImageLoader -{ -public: - - //! constructor - CImageLoaderRGB(); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".tga") - virtual bool isALoadableFileExtension(const io::path& filename) const; - - //! returns true if the file maybe is able to be loaded by this class - virtual bool isALoadableFileFormat(io::IReadFile* file) const; - - //! creates a surface from the file - virtual IImage* loadImage(io::IReadFile* file) const; - -private: - - bool readHeader(io::IReadFile* file, rgbStruct& rgb) const; - void readRGBrow(u8 *buf, int y, int z, io::IReadFile* file, rgbStruct& rgb) const; - void processFile(io::IReadFile *file, rgbStruct& rgb) const; - bool checkFormat(io::IReadFile *file, rgbStruct& rgb) const; - bool readOffsetTables(io::IReadFile* file, rgbStruct& rgb) const; - void converttoARGB(u32* in, const u32 size) const; -}; - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_RGB_LOADER_ -#endif // __C_IMAGE_LOADER_RGB_H_INCLUDED__ diff --git a/irrlicht-1.6/source/Irrlicht/CImageLoaderTGA.cpp b/irrlicht-1.6/source/Irrlicht/CImageLoaderTGA.cpp deleted file mode 100644 index 3b4304de3..000000000 --- a/irrlicht-1.6/source/Irrlicht/CImageLoaderTGA.cpp +++ /dev/null @@ -1,225 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CImageLoaderTGA.h" - -#ifdef _IRR_COMPILE_WITH_TGA_LOADER_ - -#include "IReadFile.h" -#include "os.h" -#include "CColorConverter.h" -#include "CImage.h" -#include "irrString.h" - - -namespace irr -{ -namespace video -{ - - -//! returns true if the file maybe is able to be loaded by this class -//! based on the file extension (e.g. ".tga") -bool CImageLoaderTGA::isALoadableFileExtension(const io::path& filename) const -{ - return core::hasFileExtension ( filename, "tga" ); -} - - -//! loads a compressed tga. -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. - - s32 bytesPerPixel = header.PixelDepth/8; - s32 imageSize = header.ImageHeight * header.ImageWidth * bytesPerPixel; - u8* data = new u8[imageSize]; - s32 currentByte = 0; - - while(currentByte < imageSize) - { - u8 chunkheader = 0; - file->read(&chunkheader, sizeof(u8)); // Read The Chunk's Header - - if(chunkheader < 128) // If The Chunk Is A 'RAW' Chunk - { - chunkheader++; // Add 1 To The Value To Get Total Number Of Raw Pixels - - file->read(&data[currentByte], bytesPerPixel * chunkheader); - currentByte += bytesPerPixel * chunkheader; - } - else - { - // thnx to neojzs for some fixes with this code - - // If It's An RLE Header - chunkheader -= 127; // Subtract 127 To Get Rid Of The ID Bit - - s32 dataOffset = currentByte; - file->read(&data[dataOffset], bytesPerPixel); - - currentByte += bytesPerPixel; - - for(s32 counter = 1; counter < chunkheader; counter++) - { - for(s32 elementCounter=0; elementCounter < bytesPerPixel; elementCounter++) - data[currentByte + elementCounter] = data[dataOffset + elementCounter]; - - currentByte += bytesPerPixel; - } - } - } - - return data; -} - - - -//! returns true if the file maybe is able to be loaded by this class -bool CImageLoaderTGA::isALoadableFileFormat(io::IReadFile* file) const -{ - if (!file) - return false; - - STGAFooter footer; - memset(&footer, 0, sizeof(STGAFooter)); - file->seek(file->getSize()-sizeof(STGAFooter)); - file->read(&footer, sizeof(STGAFooter)); - return (!strcmp(footer.Signature,"TRUEVISION-XFILE.")); // very old tgas are refused. -} - - - -//! creates a surface from the file -IImage* CImageLoaderTGA::loadImage(io::IReadFile* file) const -{ - STGAHeader header; - u32 *palette = 0; - - file->read(&header, sizeof(STGAHeader)); - -#ifdef __BIG_ENDIAN__ - header.ColorMapLength = os::Byteswap::byteswap(header.ColorMapLength); - header.ImageWidth = os::Byteswap::byteswap(header.ImageWidth); - header.ImageHeight = os::Byteswap::byteswap(header.ImageHeight); -#endif - - // skip image identification field - if (header.IdLength) - file->seek(header.IdLength, true); - - if (header.ColorMapType) - { - // create 32 bit palette - palette = new u32[ header.ColorMapLength]; - - // read color map - u8 * colorMap = new u8[header.ColorMapEntrySize/8 * header.ColorMapLength]; - file->read(colorMap,header.ColorMapEntrySize/8 * header.ColorMapLength); - - // convert to 32-bit palette - switch ( header.ColorMapEntrySize ) - { - case 16: - CColorConverter::convert_A1R5G5B5toA8R8G8B8(colorMap, header.ColorMapLength, palette); - break; - case 24: - CColorConverter::convert_B8G8R8toA8R8G8B8(colorMap, header.ColorMapLength, palette); - break; - case 32: - CColorConverter::convert_B8G8R8A8toA8R8G8B8(colorMap, header.ColorMapLength, palette); - break; - } - delete [] colorMap; - } - - // read image - - u8* data = 0; - - if ( header.ImageType == 1 || // Uncompressed, color-mapped images. - header.ImageType == 2 || // Uncompressed, RGB images - header.ImageType == 3 // Uncompressed, black and white images - ) - { - const s32 imageSize = header.ImageHeight * header.ImageWidth * header.PixelDepth/8; - data = new u8[imageSize]; - file->read(data, imageSize); - } - else - if(header.ImageType == 10) - { - // Runlength encoded RGB images - data = loadCompressedImage(file, header); - } - else - { - os::Printer::log("Unsupported TGA file type", file->getFileName(), ELL_ERROR); - delete [] palette; - return 0; - } - - IImage* image = 0; - - switch(header.PixelDepth) - { - case 8: - image = new CImage(ECF_A1R5G5B5, - core::dimension2d<u32>(header.ImageWidth, header.ImageHeight)); - if (image) - CColorConverter::convert8BitTo16Bit((u8*)data, - (s16*)image->lock(), - header.ImageWidth,header.ImageHeight, - header.ImageType == 3 ? 0 : (s32*) palette, - 0, - (header.ImageDescriptor&0x20)==0); - break; - case 16: - image = new CImage(ECF_A1R5G5B5, - core::dimension2d<u32>(header.ImageWidth, header.ImageHeight)); - if (image) - CColorConverter::convert16BitTo16Bit((s16*)data, - (s16*)image->lock(), header.ImageWidth, header.ImageHeight, 0, (header.ImageDescriptor&0x20)==0); - break; - case 24: - image = new CImage(ECF_R8G8B8, - core::dimension2d<u32>(header.ImageWidth, header.ImageHeight)); - if (image) - CColorConverter::convert24BitTo24Bit( - (u8*)data, (u8*)image->lock(), header.ImageWidth, header.ImageHeight, 0, (header.ImageDescriptor&0x20)==0, true); - break; - case 32: - image = new CImage(ECF_A8R8G8B8, - core::dimension2d<u32>(header.ImageWidth, header.ImageHeight)); - if (image) - CColorConverter::convert32BitTo32Bit((s32*)data, - (s32*)image->lock(), header.ImageWidth, header.ImageHeight, 0, (header.ImageDescriptor&0x20)==0); - break; - default: - os::Printer::log("Unsupported TGA format", file->getFileName(), ELL_ERROR); - break; - } - if (image) - image->unlock(); - - delete [] data; - delete [] palette; - - return image; -} - - -//! creates a loader which is able to load tgas -IImageLoader* createImageLoaderTGA() -{ - return new CImageLoaderTGA(); -} - - -} // end namespace video -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CImageLoaderTGA.h b/irrlicht-1.6/source/Irrlicht/CImageLoaderTGA.h deleted file mode 100644 index 02700a5ed..000000000 --- a/irrlicht-1.6/source/Irrlicht/CImageLoaderTGA.h +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_IMAGE_LOADER_TGA_H_INCLUDED__ -#define __C_IMAGE_LOADER_TGA_H_INCLUDED__ - -#include "IrrCompileConfig.h" - -#include "IImageLoader.h" - - -namespace irr -{ -namespace video -{ - -#if defined(_IRR_COMPILE_WITH_TGA_LOADER_) || defined(_IRR_COMPILE_WITH_TGA_WRITER_) - -// byte-align structures -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) -# pragma pack( push, packing ) -# pragma pack( 1 ) -# define PACK_STRUCT -#elif defined( __GNUC__ ) -# define PACK_STRUCT __attribute__((packed)) -#else -# define PACK_STRUCT -#endif - - // these structs are also used in the TGA writer - struct STGAHeader{ - u8 IdLength; - u8 ColorMapType; - u8 ImageType; - u8 FirstEntryIndex[2]; - u16 ColorMapLength; - u8 ColorMapEntrySize; - u8 XOrigin[2]; - u8 YOrigin[2]; - u16 ImageWidth; - u16 ImageHeight; - u8 PixelDepth; - u8 ImageDescriptor; - } PACK_STRUCT; - - struct STGAFooter - { - u32 ExtensionOffset; - u32 DeveloperOffset; - c8 Signature[18]; - } PACK_STRUCT; - -// Default alignment -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) -# pragma pack( pop, packing ) -#endif - -#undef PACK_STRUCT - -#endif // compiled with loader or reader - -#ifdef _IRR_COMPILE_WITH_TGA_LOADER_ - -/*! - Surface Loader for targa images -*/ -class CImageLoaderTGA : public IImageLoader -{ -public: - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".tga") - virtual bool isALoadableFileExtension(const io::path& filename) const; - - //! returns true if the file maybe is able to be loaded by this class - virtual bool isALoadableFileFormat(io::IReadFile* file) const; - - //! creates a surface from the file - 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(io::IReadFile *file, const STGAHeader& header) const; -}; - -#endif // compiled with loader - -} // end namespace video -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CImageLoaderWAL.cpp b/irrlicht-1.6/source/Irrlicht/CImageLoaderWAL.cpp deleted file mode 100644 index a2f1d1afe..000000000 --- a/irrlicht-1.6/source/Irrlicht/CImageLoaderWAL.cpp +++ /dev/null @@ -1,148 +0,0 @@ -// Copyright (C) 2004 Murphy McCauley -// Copyright (C) 2007-2009 Christian Stehno -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CImageLoaderWAL.h" -#include "CColorConverter.h" -#include "CImage.h" -#include "os.h" -#include "dimension2d.h" -#include "IVideoDriver.h" -#include "IFileSystem.h" -#include "IReadFile.h" -#include "irrString.h" - -namespace irr -{ -namespace video -{ - -// May or may not be fully implemented -#define TRY_LOADING_PALETTE_FROM_FILE 0 - -// Default palette for Q2 WALs. - -s32 CImageLoaderWAL::DefaultPaletteQ2[256] = { -0x000000L,0x0F0F0FL,0x1F1F1FL,0x2F2F2FL,0x3F3F3FL,0x4B4B4BL,0x5B5B5BL,0x6B6B6BL,0x7B7B7BL,0x8B8B8BL,0x9B9B9BL, -0xABABABL,0xBBBBBBL,0xCBCBCBL,0xDBDBDBL,0xEBEBEBL,0x634B23L,0x5B431FL,0x533F1FL,0x4F3B1BL,0x47371BL,0x3F2F17L, -0x3B2B17L,0x332713L,0x2F2313L,0x2B1F13L,0x271B0FL,0x23170FL,0x1B130BL,0x170F0BL,0x130F07L,0x0F0B07L,0x5F5F6FL, -0x5B5B67L,0x5B535FL,0x574F5BL,0x534B53L,0x4F474BL,0x473F43L,0x3F3B3BL,0x3B3737L,0x332F2FL,0x2F2B2BL,0x272727L, -0x232323L,0x1B1B1BL,0x171717L,0x131313L,0x8F7753L,0x7B6343L,0x735B3BL,0x674F2FL,0xCF974BL,0xA77B3BL,0x8B672FL, -0x6F5327L,0xEB9F27L,0xCB8B23L,0xAF771FL,0x93631BL,0x774F17L,0x5B3B0FL,0x3F270BL,0x231707L,0xA73B2BL,0x9F2F23L, -0x972B1BL,0x8B2713L,0x7F1F0FL,0x73170BL,0x671707L,0x571300L,0x4B0F00L,0x430F00L,0x3B0F00L,0x330B00L,0x2B0B00L, -0x230B00L,0x1B0700L,0x130700L,0x7B5F4BL,0x735743L,0x6B533FL,0x674F3BL,0x5F4737L,0x574333L,0x533F2FL,0x4B372BL, -0x433327L,0x3F2F23L,0x37271BL,0x2F2317L,0x271B13L,0x1F170FL,0x170F0BL,0x0F0B07L,0x6F3B17L,0x5F3717L,0x532F17L, -0x432B17L,0x372313L,0x271B0FL,0x1B130BL,0x0F0B07L,0xB35B4FL,0xBF7B6FL,0xCB9B93L,0xD7BBB7L,0xCBD7DFL,0xB3C7D3L, -0x9FB7C3L,0x87A7B7L,0x7397A7L,0x5B879BL,0x47778BL,0x2F677FL,0x17536FL,0x134B67L,0x0F435BL,0x0B3F53L,0x07374BL, -0x072F3FL,0x072733L,0x001F2BL,0x00171FL,0x000F13L,0x00070BL,0x000000L,0x8B5757L,0x834F4FL,0x7B4747L,0x734343L, -0x6B3B3BL,0x633333L,0x5B2F2FL,0x572B2BL,0x4B2323L,0x3F1F1FL,0x331B1BL,0x2B1313L,0x1F0F0FL,0x130B0BL,0x0B0707L, -0x000000L,0x979F7BL,0x8F9773L,0x878B6BL,0x7F8363L,0x777B5FL,0x737357L,0x6B6B4FL,0x636347L,0x5B5B43L,0x4F4F3BL, -0x434333L,0x37372BL,0x2F2F23L,0x23231BL,0x171713L,0x0F0F0BL,0x9F4B3FL,0x934337L,0x8B3B2FL,0x7F3727L,0x772F23L, -0x6B2B1BL,0x632317L,0x571F13L,0x4F1B0FL,0x43170BL,0x37130BL,0x2B0F07L,0x1F0B07L,0x170700L,0x0B0000L,0x000000L, -0x777BCFL,0x6F73C3L,0x676BB7L,0x6363A7L,0x5B5B9BL,0x53578FL,0x4B4F7FL,0x474773L,0x3F3F67L,0x373757L,0x2F2F4BL, -0x27273FL,0x231F2FL,0x1B1723L,0x130F17L,0x0B0707L,0x9BAB7BL,0x8F9F6FL,0x879763L,0x7B8B57L,0x73834BL,0x677743L, -0x5F6F3BL,0x576733L,0x4B5B27L,0x3F4F1BL,0x374313L,0x2F3B0BL,0x232F07L,0x1B2300L,0x131700L,0x0B0F00L,0x00FF00L, -0x23E70FL,0x3FD31BL,0x53BB27L,0x5FA72FL,0x5F8F33L,0x5F7B33L,0xFFFFFFL,0xFFFFD3L,0xFFFFA7L,0xFFFF7FL,0xFFFF53L, -0xFFFF27L,0xFFEB1FL,0xFFD717L,0xFFBF0FL,0xFFAB07L,0xFF9300L,0xEF7F00L,0xE36B00L,0xD35700L,0xC74700L,0xB73B00L, -0xAB2B00L,0x9B1F00L,0x8F1700L,0x7F0F00L,0x730700L,0x5F0000L,0x470000L,0x2F0000L,0x1B0000L,0xEF0000L,0x3737FFL, -0xFF0000L,0x0000FFL,0x2B2B23L,0x1B1B17L,0x13130FL,0xEB977FL,0xC37353L,0x9F5733L,0x7B3F1BL,0xEBD3C7L,0xC7AB9BL, -0xA78B77L,0x876B57L,0x9F5B53L -}; - - -bool CImageLoaderWAL::isALoadableFileExtension(const io::path& filename) const -{ - return core::hasFileExtension ( filename, "wal" ); -} - - -bool CImageLoaderWAL::isALoadableFileFormat(irr::io::IReadFile* file) const -{ - return (false); // no recognition possible, use a proper file ending -} - - -IImage* CImageLoaderWAL::loadImage(irr::io::IReadFile* file) const -{ - // Try to get the color palette from elsewhere (usually in a pak along with the WAL). - // If this fails we use the DefaultPaletteQ2. - static s32 * palette = 0; -#if TRY_LOADING_PALETTE_FROM_FILE - s32 loadedPalette[256]; -#endif - if (!palette) - { -#if TRY_LOADING_PALETTE_FROM_FILE - IImage * paletteImage; - // Look in a couple different places... - paletteImage = createImageFromFile("pics/colormap.pcx"); - if (!paletteImage) - paletteImage = createImageFromFile("pics/colormap.tga"); - if (!paletteImage) - paletteImage = createImageFromFile("colormap.pcx"); - if (!paletteImage) - paletteImage = createImageFromFile("colormap.tga"); - if (paletteImage && (paletteImage->getDimension().Width == 256) ) { - palette = &loadedPalette; - for (u32 i = 0; i < 256; ++i) { - palette[i] = paletteImage->getPixel(i, 0).color; - } - } else { - //FIXME: try reading a simple palette from "wal.pal" - palette = DefaultPaletteQ2; - } - if (paletteImage) - paletteImage->drop(); -#endif - } - else - { - palette = DefaultPaletteQ2; - } - - SWALHeader header; - - file->seek(0); - if (file->read(&header, sizeof(SWALHeader)) != sizeof(SWALHeader) ) - return 0; - - if (file->getSize() < header.MipmapOffset[0]) - return 0; - file->seek(header.MipmapOffset[0]); - - // read image - - const u32 imageSize = header.ImageHeight * header.ImageWidth; - if (file->getSize() < (long)(imageSize + header.MipmapOffset[0])) - return 0; - - u8* data = new u8[imageSize]; - file->read(data, imageSize); - - IImage* image = 0; - - image = new CImage(ECF_A1R5G5B5, - core::dimension2d<u32>(header.ImageWidth, header.ImageHeight)); - - // I wrote an 8 to 32 converter, but this works with released Irrlicht code. - CColorConverter::convert8BitTo16Bit(data, - (s16*)image->lock(), header.ImageWidth, header.ImageHeight, palette); - image->unlock(); - - delete [] data; - - return image; -} - - -IImageLoader* createImageLoaderWAL() -{ - return new irr::video::CImageLoaderWAL(); -} - - -} -} - - diff --git a/irrlicht-1.6/source/Irrlicht/CImageLoaderWAL.h b/irrlicht-1.6/source/Irrlicht/CImageLoaderWAL.h deleted file mode 100644 index 94d7bf281..000000000 --- a/irrlicht-1.6/source/Irrlicht/CImageLoaderWAL.h +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (C) 2004 Murphy McCauley -// Copyright (C) 2007-2009 Christian Stehno -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h -/* - Thanks to: - Max McGuire for his Flipcode article about WAL textures - Nikolaus Gebhardt for the Irrlicht 3D engine -*/ - -#ifndef __C_IMAGE_LOADER_WAL_H_INCLUDED__ -#define __C_IMAGE_LOADER_WAL_H_INCLUDED__ - -#include "IImageLoader.h" - -namespace irr -{ -namespace video -{ - -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) -# pragma pack( push, packing ) -# pragma pack( 1 ) -# define PACK_STRUCT -#elif defined( __GNUC__ ) -# define PACK_STRUCT __attribute__((packed)) -#else -# error compiler not supported -#endif - - struct SWALHeader { - char FrameName[32]; - - u32 ImageWidth; - u32 ImageHeight; - - s32 MipmapOffset[4]; - - char NextFrameName[32]; - - u32 Flags; // surface properties, i.e. slick, sky, nodraw - u32 Contents; // i.e. solid, clip, area portal - u32 Value; // light - } PACK_STRUCT; - -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) -# pragma pack( pop, packing ) -#endif -#undef PACK_STRUCT - -//! An Irrlicht image loader for Quake engine WAL textures -class CImageLoaderWAL : public irr::video::IImageLoader -{ -public: - virtual bool isALoadableFileExtension(const io::path& filename) const; - - virtual bool isALoadableFileFormat(irr::io::IReadFile* file) const; - - virtual irr::video::IImage* loadImage(irr::io::IReadFile* file) const; - -private: - static s32 DefaultPaletteQ2[256]; -}; - -} -} - -#endif diff --git a/irrlicht-1.6/source/Irrlicht/CImageWriterBMP.cpp b/irrlicht-1.6/source/Irrlicht/CImageWriterBMP.cpp deleted file mode 100644 index 730809f34..000000000 --- a/irrlicht-1.6/source/Irrlicht/CImageWriterBMP.cpp +++ /dev/null @@ -1,136 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CImageWriterBMP.h" - -#ifdef _IRR_COMPILE_WITH_BMP_WRITER_ - -#include "CImageLoaderBMP.h" -#include "IWriteFile.h" -#include "CColorConverter.h" -#include "irrString.h" - -namespace irr -{ -namespace video -{ - -IImageWriter* createImageWriterBMP() -{ - return new CImageWriterBMP; -} - -CImageWriterBMP::CImageWriterBMP() -{ -#ifdef _DEBUG - setDebugName("CImageWriterBMP"); -#endif -} - -bool CImageWriterBMP::isAWriteableFileExtension(const io::path& filename) const -{ - return core::hasFileExtension ( filename, "bmp" ); -} - -bool CImageWriterBMP::writeImage(io::IWriteFile* file, IImage* image, u32 param) const -{ - // we always write 24-bit color because nothing really reads 32-bit - - SBMPHeader imageHeader; - imageHeader.Id = 0x4d42; - imageHeader.Reserved = 0; - imageHeader.BitmapDataOffset = sizeof(imageHeader); - imageHeader.BitmapHeaderSize = 0x28; - imageHeader.Width = image->getDimension().Width; - imageHeader.Height = image->getDimension().Height; - imageHeader.Planes = 1; - imageHeader.BPP = 24; - imageHeader.Compression = 0; - imageHeader.PixelPerMeterX = 0; - imageHeader.PixelPerMeterY = 0; - imageHeader.Colors = 0; - imageHeader.ImportantColors = 0; - - // data size is rounded up to next larger 4 bytes boundary - imageHeader.BitmapDataSize = imageHeader.Width * imageHeader.BPP / 8; - imageHeader.BitmapDataSize = (imageHeader.BitmapDataSize + 3) & ~3; - imageHeader.BitmapDataSize *= imageHeader.Height; - - // file size is data size plus offset to data - imageHeader.FileSize = imageHeader.BitmapDataOffset + imageHeader.BitmapDataSize; - - // bitmaps are stored upside down and padded so we always do this - void (*CColorConverter_convertFORMATtoFORMAT)(const void*, s32, void*) = 0; - switch(image->getColorFormat()) - { - case ECF_R8G8B8: - CColorConverter_convertFORMATtoFORMAT - = CColorConverter::convert_R8G8B8toR8G8B8; - break; - case ECF_A8R8G8B8: - CColorConverter_convertFORMATtoFORMAT - = CColorConverter::convert_A8R8G8B8toB8G8R8; - break; - case ECF_A1R5G5B5: - CColorConverter_convertFORMATtoFORMAT - = CColorConverter::convert_A1R5G5B5toR8G8B8; - break; - case ECF_R5G6B5: - CColorConverter_convertFORMATtoFORMAT - = CColorConverter::convert_R5G6B5toR8G8B8; - break; - } - - // couldn't find a color converter - if (!CColorConverter_convertFORMATtoFORMAT) - return false; - - // write the bitmap header - if (file->write(&imageHeader, sizeof(imageHeader)) != sizeof(imageHeader)) - return false; - - u8* scan_lines = (u8*)image->lock(); - if (!scan_lines) - return false; - - // size of one pixel in bytes - u32 pixel_size = image->getBytesPerPixel(); - - // length of one row of the source image in bytes - u32 row_stride = (pixel_size * imageHeader.Width); - - // length of one row in bytes, rounded up to nearest 4-byte boundary - s32 row_size = ((3 * imageHeader.Width) + 3) & ~3; - - // allocate and clear memory for our scan line - u8* row_pointer = new u8[row_size]; - memset(row_pointer, 0, row_size); - - // convert the image to 24-bit BGR and flip it over - s32 y; - for (y = imageHeader.Height - 1; 0 <= y; --y) - { - if (image->getColorFormat()==ECF_R8G8B8) - CColorConverter::convert24BitTo24Bit(&scan_lines[y * row_stride], row_pointer, imageHeader.Width, 1, 0, false, true); - else - // source, length [pixels], destination - CColorConverter_convertFORMATtoFORMAT(&scan_lines[y * row_stride], imageHeader.Width, row_pointer); - if (file->write(row_pointer, row_size) < row_size) - break; - } - - // clean up our scratch area - delete [] row_pointer; - - // give back image handle - image->unlock(); - - return y < 0; -} - -} // namespace video -} // namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CImageWriterBMP.h b/irrlicht-1.6/source/Irrlicht/CImageWriterBMP.h deleted file mode 100644 index 9a5a79fb2..000000000 --- a/irrlicht-1.6/source/Irrlicht/CImageWriterBMP.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef _C_IMAGE_WRITER_BMP_H_INCLUDED__ -#define _C_IMAGE_WRITER_BMP_H_INCLUDED__ - -#include "IrrCompileConfig.h" - -#ifdef _IRR_COMPILE_WITH_BMP_WRITER_ - -#include "IImageWriter.h" - -namespace irr -{ -namespace video -{ - -class CImageWriterBMP : public IImageWriter -{ -public: - //! constructor - CImageWriterBMP(); - - //! return true if this writer can write a file with the given extension - virtual bool isAWriteableFileExtension(const io::path& filename) const; - - //! write image to file - virtual bool writeImage(io::IWriteFile *file, IImage *image, u32 param) const; -}; - -} // namespace video -} // namespace irr - -#endif -#endif // _C_IMAGE_WRITER_BMP_H_INCLUDED__ - diff --git a/irrlicht-1.6/source/Irrlicht/CImageWriterJPG.cpp b/irrlicht-1.6/source/Irrlicht/CImageWriterJPG.cpp deleted file mode 100644 index 2c94641b3..000000000 --- a/irrlicht-1.6/source/Irrlicht/CImageWriterJPG.cpp +++ /dev/null @@ -1,225 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CImageWriterJPG.h" - -#ifdef _IRR_COMPILE_WITH_JPG_WRITER_ - -#include "CColorConverter.h" -#include "IWriteFile.h" -#include "CImage.h" -#include "irrString.h" - -#ifdef _IRR_COMPILE_WITH_LIBJPEG_ -#include <stdio.h> // required for jpeglib.h -extern "C" -{ -#ifndef _IRR_USE_NON_SYSTEM_JPEG_LIB_ - #include <jpeglib.h> - #include <jerror.h> -#else - #include "jpeglib/jpeglib.h" - #include "jpeglib/jerror.h" -#endif -} - - -namespace irr -{ -namespace video -{ - -// The writer uses a 4k buffer and flushes to disk each time it's filled -#define OUTPUT_BUF_SIZE 4096 -typedef struct -{ - struct jpeg_destination_mgr pub;/* public fields */ - - io::IWriteFile* file; /* target file */ - JOCTET buffer[OUTPUT_BUF_SIZE]; /* image buffer */ -} mem_destination_mgr; - - -typedef mem_destination_mgr * mem_dest_ptr; - - -// init -static void jpeg_init_destination(j_compress_ptr cinfo) -{ - mem_dest_ptr dest = (mem_dest_ptr) cinfo->dest; - dest->pub.next_output_byte = dest->buffer; - dest->pub.free_in_buffer = OUTPUT_BUF_SIZE; -} - - -// flush to disk and reset buffer -static boolean jpeg_empty_output_buffer(j_compress_ptr cinfo) -{ - mem_dest_ptr dest = (mem_dest_ptr) cinfo->dest; - - // for now just exit upon file error - if (dest->file->write(dest->buffer, OUTPUT_BUF_SIZE) != OUTPUT_BUF_SIZE) - ERREXIT (cinfo, JERR_FILE_WRITE); - - dest->pub.next_output_byte = dest->buffer; - dest->pub.free_in_buffer = OUTPUT_BUF_SIZE; - - return TRUE; -} - - -static void jpeg_term_destination(j_compress_ptr cinfo) -{ - mem_dest_ptr dest = (mem_dest_ptr) cinfo->dest; - const s32 datacount = (s32)(OUTPUT_BUF_SIZE - dest->pub.free_in_buffer); - // for now just exit upon file error - if (dest->file->write(dest->buffer, datacount) != datacount) - ERREXIT (cinfo, JERR_FILE_WRITE); -} - - -// set up buffer data -static void jpeg_file_dest(j_compress_ptr cinfo, io::IWriteFile* file) -{ - if (cinfo->dest == NULL) - { /* first time for this JPEG object? */ - cinfo->dest = (struct jpeg_destination_mgr *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, - JPOOL_PERMANENT, - sizeof(mem_destination_mgr)); - } - - mem_dest_ptr dest = (mem_dest_ptr) cinfo->dest; /* for casting */ - - /* Initialize method pointers */ - dest->pub.init_destination = jpeg_init_destination; - dest->pub.empty_output_buffer = jpeg_empty_output_buffer; - dest->pub.term_destination = jpeg_term_destination; - - /* Initialize private member */ - dest->file = file; -} - - -/* write_JPEG_memory: store JPEG compressed image into memory. -*/ -static bool writeJPEGFile(io::IWriteFile* file, IImage* image, u32 quality) -{ - void (*format)(const void*, s32, void*) = 0; - switch( image->getColorFormat () ) - { - case ECF_R8G8B8: - format = CColorConverter::convert_R8G8B8toR8G8B8; - break; - case ECF_A8R8G8B8: - format = CColorConverter::convert_A8R8G8B8toR8G8B8; - break; - case ECF_A1R5G5B5: - format = CColorConverter::convert_A1R5G5B5toB8G8R8; - break; - case ECF_R5G6B5: - format = CColorConverter::convert_R5G6B5toR8G8B8; - break; - } - - // couldn't find a color converter - if ( 0 == format ) - return false; - - const core::dimension2du dim = image->getDimension(); - - struct jpeg_compress_struct cinfo; - struct jpeg_error_mgr jerr; - cinfo.err = jpeg_std_error(&jerr); - - jpeg_create_compress(&cinfo); - jpeg_file_dest(&cinfo, file); - cinfo.image_width = dim.Width; - cinfo.image_height = dim.Height; - cinfo.input_components = 3; - cinfo.in_color_space = JCS_RGB; - - jpeg_set_defaults(&cinfo); - - if ( 0 == quality ) - quality = 75; - - jpeg_set_quality(&cinfo, quality, TRUE); - jpeg_start_compress(&cinfo, TRUE); - - u8 * dest = new u8[dim.Width*3]; - - if (dest) - { - const u32 pitch = image->getPitch(); - JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */ - row_pointer[0] = dest; - - u8* src = (u8*)image->lock(); - - while (cinfo.next_scanline < cinfo.image_height) - { - // convert next line - format( src, dim.Width, dest ); - src += pitch; - jpeg_write_scanlines(&cinfo, row_pointer, 1); - } - image->unlock(); - - delete [] dest; - - /* Step 6: Finish compression */ - jpeg_finish_compress(&cinfo); - } - - /* Step 7: Destroy */ - jpeg_destroy_compress(&cinfo); - - return (dest != 0); -} - - -} // namespace video -} // namespace irr - -#endif // _IRR_COMPILE_WITH_LIBJPEG_ - -namespace irr -{ -namespace video -{ - -IImageWriter* createImageWriterJPG() -{ - return new CImageWriterJPG; -} - -CImageWriterJPG::CImageWriterJPG() -{ -#ifdef _DEBUG - setDebugName("CImageWriterJPG"); -#endif -} - - -bool CImageWriterJPG::isAWriteableFileExtension(const io::path& filename) const -{ - return core::hasFileExtension ( filename, "jpg", "jpeg" ); -} - - -bool CImageWriterJPG::writeImage(io::IWriteFile *file, IImage *image, u32 quality) const -{ -#ifndef _IRR_COMPILE_WITH_LIBJPEG_ - return false; -#else - return writeJPEGFile(file, image, quality); -#endif -} - -} // namespace video -} // namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CImageWriterJPG.h b/irrlicht-1.6/source/Irrlicht/CImageWriterJPG.h deleted file mode 100644 index ec6e2fac7..000000000 --- a/irrlicht-1.6/source/Irrlicht/CImageWriterJPG.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef _C_IMAGE_WRITER_JPG_H_INCLUDED__ -#define _C_IMAGE_WRITER_JPG_H_INCLUDED__ - -#include "IrrCompileConfig.h" - -#ifdef _IRR_COMPILE_WITH_JPG_WRITER_ - -#include "IImageWriter.h" - -namespace irr -{ -namespace video -{ - -class CImageWriterJPG : public IImageWriter -{ -public: - //! constructor - CImageWriterJPG(); - - //! return true if this writer can write a file with the given extension - virtual bool isAWriteableFileExtension(const io::path& filename) const; - - //! write image to file - virtual bool writeImage(io::IWriteFile *file, IImage *image, u32 param) const; -}; - -} -} - -#endif // _C_IMAGE_WRITER_JPG_H_INCLUDED__ -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CImageWriterPCX.cpp b/irrlicht-1.6/source/Irrlicht/CImageWriterPCX.cpp deleted file mode 100644 index 57f731397..000000000 --- a/irrlicht-1.6/source/Irrlicht/CImageWriterPCX.cpp +++ /dev/null @@ -1,162 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CImageWriterPCX.h" - -#ifdef _IRR_COMPILE_WITH_PCX_WRITER_ - -#include "CImageLoaderPCX.h" -#include "IWriteFile.h" -#include "os.h" // for logging -#include "irrString.h" - -namespace irr -{ -namespace video -{ - -IImageWriter* createImageWriterPCX() -{ - return new CImageWriterPCX; -} - -CImageWriterPCX::CImageWriterPCX() -{ -#ifdef _DEBUG - setDebugName("CImageWriterPCX"); -#endif -} - -bool CImageWriterPCX::isAWriteableFileExtension(const io::path& filename) const -{ - return core::hasFileExtension ( filename, "pcx" ); -} - -bool CImageWriterPCX::writeImage(io::IWriteFile *file, IImage *image,u32 param) const -{ - if (!file || !image) - return false; - - u8 d1; - u16 d2; - u32 i; - - d1 = 10; // Manufacturer - file->write(&d1, 1); - d1 = 5; // Version - file->write(&d1, 1); - d1 = 1; // Encoding - file->write(&d1, 1); - d1 = 8; // Bits per Pixel - file->write(&d1, 1); - d2 = 0; // pixel origin - file->write(&d2, 2); - file->write(&d2, 2); - d2 = image->getDimension().Width-1; // width -#ifdef __BIG_ENDIAN__ - d2 = os::Byteswap::byteswap(d2); -#endif - file->write(&d2, 2); - d2 = image->getDimension().Height-1; // height -#ifdef __BIG_ENDIAN__ - d2 = os::Byteswap::byteswap(d2); -#endif - file->write(&d2, 2); - d2 = 300; // dpi -#ifdef __BIG_ENDIAN__ - d2 = os::Byteswap::byteswap(d2); -#endif - file->write(&d2, 2); - file->write(&d2, 2); - d2 = 0; // palette (not used) - for (i=0; i<24; ++i) - { - file->write(&d2, 2); - } - d1 = 0; // reserved - file->write(&d1, 1); - d1 = 3; // planes - file->write(&d1, 1); - d2 = image->getDimension().Width; // pitch - if (d2&0x0001) // must be even - ++d2; -#ifdef __BIG_ENDIAN__ - d2 = os::Byteswap::byteswap(d2); -#endif - file->write(&d2, 2); - d2 = 1; // color mode -#ifdef __BIG_ENDIAN__ - d2 = os::Byteswap::byteswap(d2); -#endif - file->write(&d2, 2); - d2 = 800; // screen width -#ifdef __BIG_ENDIAN__ - d2 = os::Byteswap::byteswap(d2); -#endif - file->write(&d2, 2); - d2 = 600; // screen height -#ifdef __BIG_ENDIAN__ - d2 = os::Byteswap::byteswap(d2); -#endif - file->write(&d2, 2); - d2 = 0; // filler (not used) - for (i=0; i<27; ++i) - { - file->write(&d2, 2); - } - - u8 cnt, value; - for (i=0; i<image->getDimension().Height; ++i) - { - cnt = 0; - value = 0; - for (u32 j=0; j<3; ++j) // color planes - { - for (u32 k=0; k<image->getDimension().Width; ++k) - { - const SColor pix = image->getPixel(k,i); - if ((cnt!=0) && (cnt<63) && - (((j==0) && (value==pix.getRed())) || - ((j==1) && (value==pix.getGreen())) || - ((j==2) && (value==pix.getBlue())))) - { - ++cnt; - } - else - { - if (cnt!=0) - { - if ((cnt>1) || ((value&0xc0)==0xc0)) - { - cnt |= 0xc0; - file->write(&cnt, 1); - } - file->write(&value, 1); - } - cnt=1; - if (j==0) - value=(u8)pix.getRed(); - else if (j==1) - value=(u8)pix.getGreen(); - else if (j==2) - value=(u8)pix.getBlue(); - } - } - } - if ((cnt>1) || ((value&0xc0)==0xc0)) - { - cnt |= 0xc0; - file->write(&cnt, 1); - } - file->write(&value, 1); - } - - return true; -} - -} // namespace video -} // namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CImageWriterPCX.h b/irrlicht-1.6/source/Irrlicht/CImageWriterPCX.h deleted file mode 100644 index 632332109..000000000 --- a/irrlicht-1.6/source/Irrlicht/CImageWriterPCX.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef _C_IMAGE_WRITER_PCX_H_INCLUDED__ -#define _C_IMAGE_WRITER_PCX_H_INCLUDED__ - -#include "IrrCompileConfig.h" - -#ifdef _IRR_COMPILE_WITH_PCX_WRITER_ - -#include "IImageWriter.h" - -namespace irr -{ -namespace video -{ - -class CImageWriterPCX : public IImageWriter -{ -public: - //! constructor - CImageWriterPCX(); - - //! return true if this writer can write a file with the given extension - virtual bool isAWriteableFileExtension(const io::path& filename) const; - - //! write image to file - virtual bool writeImage(io::IWriteFile *file, IImage *image, u32 param) const; -}; - -} // namespace video -} // namespace irr - -#endif -#endif // _C_IMAGE_WRITER_PCX_H_INCLUDED__ - diff --git a/irrlicht-1.6/source/Irrlicht/CImageWriterPNG.cpp b/irrlicht-1.6/source/Irrlicht/CImageWriterPNG.cpp deleted file mode 100644 index 8edaded11..000000000 --- a/irrlicht-1.6/source/Irrlicht/CImageWriterPNG.cpp +++ /dev/null @@ -1,208 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CImageWriterPNG.h" - -#ifdef _IRR_COMPILE_WITH_PNG_WRITER_ - -#include "CImageLoaderPNG.h" -#include "CColorConverter.h" -#include "IWriteFile.h" -#include "irrString.h" -#include "os.h" // for logging - -#ifdef _IRR_COMPILE_WITH_LIBPNG_ -#ifndef _IRR_USE_NON_SYSTEM_LIB_PNG_ - #include <png.h> // use system lib png -#else // _IRR_USE_NON_SYSTEM_LIB_PNG_ - #include "libpng/png.h" // use irrlicht included lib png -#endif // _IRR_USE_NON_SYSTEM_LIB_PNG_ -#endif // _IRR_COMPILE_WITH_LIBPNG_ - -namespace irr -{ -namespace video -{ - -IImageWriter* createImageWriterPNG() -{ - return new CImageWriterPNG; -} - -#ifdef _IRR_COMPILE_WITH_LIBPNG_ -// PNG function for error handling -static void png_cpexcept_error(png_structp png_ptr, png_const_charp msg) -{ - os::Printer::log("PNG FATAL ERROR", msg, ELL_ERROR); - longjmp(png_ptr->jmpbuf, 1); -} - -// PNG function for file writing -void PNGAPI user_write_data_fcn(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_size_t check; - - io::IWriteFile* file=(io::IWriteFile*)png_ptr->io_ptr; - check=(png_size_t) file->write((const void*)data,(u32)length); - - if (check != length) - png_error(png_ptr, "Write Error"); -} -#endif // _IRR_COMPILE_WITH_LIBPNG_ - -CImageWriterPNG::CImageWriterPNG() -{ -#ifdef _DEBUG - setDebugName("CImageWriterPNG"); -#endif -} - -bool CImageWriterPNG::isAWriteableFileExtension(const io::path& filename) const -{ -#ifdef _IRR_COMPILE_WITH_LIBPNG_ - return core::hasFileExtension ( filename, "png" ); -#else - return false; -#endif -} - -bool CImageWriterPNG::writeImage(io::IWriteFile* file, IImage* image,u32 param) const -{ -#ifdef _IRR_COMPILE_WITH_LIBPNG_ - if (!file || !image) - return false; - - // Allocate the png write struct - png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, - NULL, (png_error_ptr)png_cpexcept_error, NULL); - if (!png_ptr) - { - os::Printer::log("PNGWriter: Internal PNG create write struct failure\n", file->getFileName(), ELL_ERROR); - return false; - } - - // Allocate the png info struct - png_infop info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - os::Printer::log("PNGWriter: Internal PNG create info struct failure\n", file->getFileName(), ELL_ERROR); - png_destroy_write_struct(&png_ptr, NULL); - return false; - } - - // for proper error handling - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_write_struct(&png_ptr, &info_ptr); - return false; - } - - png_set_write_fn(png_ptr, file, user_write_data_fcn, NULL); - - // Set info - switch(image->getColorFormat()) - { - case ECF_A8R8G8B8: - case ECF_A1R5G5B5: - png_set_IHDR(png_ptr, info_ptr, - image->getDimension().Width, image->getDimension().Height, - 8, PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE, - PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); - break; - 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; - switch(image->getColorFormat()) - { - case ECF_R8G8B8: - case ECF_R5G6B5: - lineWidth*=3; - break; - case ECF_A8R8G8B8: - case ECF_A1R5G5B5: - lineWidth*=4; - break; - } - u8* tmpImage = new u8[image->getDimension().Height*lineWidth]; - if (!tmpImage) - { - os::Printer::log("PNGWriter: Internal PNG create image failure\n", file->getFileName(), ELL_ERROR); - png_destroy_write_struct(&png_ptr, &info_ptr); - return false; - } - - u8* data = (u8*)image->lock(); - switch(image->getColorFormat()) - { - case ECF_R8G8B8: - CColorConverter::convert_R8G8B8toR8G8B8(data,image->getDimension().Height*image->getDimension().Width,tmpImage); - break; - case ECF_A8R8G8B8: - CColorConverter::convert_A8R8G8B8toA8R8G8B8(data,image->getDimension().Height*image->getDimension().Width,tmpImage); - break; - case ECF_R5G6B5: - CColorConverter::convert_R5G6B5toR8G8B8(data,image->getDimension().Height*image->getDimension().Width,tmpImage); - break; - case ECF_A1R5G5B5: - CColorConverter::convert_A1R5G5B5toA8R8G8B8(data,image->getDimension().Height*image->getDimension().Width,tmpImage); - break; - } - image->unlock(); - - // Create array of pointers to rows in image data - - //Used to point to image rows - u8** RowPointers = new png_bytep[image->getDimension().Height]; - if (!RowPointers) - { - os::Printer::log("PNGWriter: Internal PNG create row pointers failure\n", file->getFileName(), ELL_ERROR); - png_destroy_write_struct(&png_ptr, &info_ptr); - delete [] tmpImage; - return false; - } - - data=tmpImage; - // Fill array of pointers to rows in image data - for (u32 i=0; i<image->getDimension().Height; ++i) - { - RowPointers[i]=data; - data += lineWidth; - } - // for proper error handling - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_write_struct(&png_ptr, &info_ptr); - delete [] RowPointers; - delete [] tmpImage; - return false; - } - - png_set_rows(png_ptr, info_ptr, RowPointers); - - if (image->getColorFormat()==ECF_A8R8G8B8 || image->getColorFormat()==ECF_A1R5G5B5) - png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_BGR, NULL); - else - { - png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL); - } - - delete [] RowPointers; - delete [] tmpImage; - png_destroy_write_struct(&png_ptr, &info_ptr); - return true; -#else - return false; -#endif -} - -} // namespace video -} // namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CImageWriterPNG.h b/irrlicht-1.6/source/Irrlicht/CImageWriterPNG.h deleted file mode 100644 index a0e9766a4..000000000 --- a/irrlicht-1.6/source/Irrlicht/CImageWriterPNG.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef _C_IMAGE_WRITER_PNG_H_INCLUDED__ -#define _C_IMAGE_WRITER_PNG_H_INCLUDED__ - -#include "IrrCompileConfig.h" - -#ifdef _IRR_COMPILE_WITH_PNG_WRITER_ - -#include "IImageWriter.h" - -namespace irr -{ -namespace video -{ - -class CImageWriterPNG : public IImageWriter -{ -public: - //! constructor - CImageWriterPNG(); - - //! return true if this writer can write a file with the given extension - virtual bool isAWriteableFileExtension(const io::path& filename) const; - - //! write image to file - virtual bool writeImage(io::IWriteFile *file, IImage *image, u32 param) const; -}; - -} // namespace video -} // namespace irr - -#endif // _C_IMAGE_WRITER_PNG_H_INCLUDED__ -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CImageWriterPPM.cpp b/irrlicht-1.6/source/Irrlicht/CImageWriterPPM.cpp deleted file mode 100644 index 7aeb57f0d..000000000 --- a/irrlicht-1.6/source/Irrlicht/CImageWriterPPM.cpp +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CImageWriterPPM.h" - -#ifdef _IRR_COMPILE_WITH_PPM_WRITER_ - -#include "IWriteFile.h" -#include "IImage.h" -#include "dimension2d.h" -#include "irrString.h" - -namespace irr -{ -namespace video -{ - - -IImageWriter* createImageWriterPPM() -{ - return new CImageWriterPPM; -} - - -CImageWriterPPM::CImageWriterPPM() -{ -#ifdef _DEBUG - setDebugName("CImageWriterPPM"); -#endif -} - - -bool CImageWriterPPM::isAWriteableFileExtension(const io::path& filename) const -{ - return core::hasFileExtension ( filename, "ppm" ); -} - - -bool CImageWriterPPM::writeImage(io::IWriteFile *file, IImage *image, u32 param) const -{ - char cache[70]; - int size; - - const core::dimension2d<u32>& imageSize = image->getDimension(); - - const bool binary = false; - - if (binary) - size = snprintf(cache, 70, "P6\n"); - else - size = snprintf(cache, 70, "P3\n"); - - if (file->write(cache, size) != size) - return false; - - size = snprintf(cache, 70, "%d %d\n", imageSize.Width, imageSize.Height); - if (file->write(cache, size) != size) - return false; - - size = snprintf(cache, 70, "255\n"); - if (file->write(cache, size) != size) - return false; - - if (binary) - { - for (u32 h = 0; h < imageSize.Height; ++h) - { - for (u32 c = 0; c < imageSize.Width; ++c) - { - const video::SColor& pixel = image->getPixel(c, h); - const u8 r = (u8)(pixel.getRed() & 0xff); - const u8 g = (u8)(pixel.getGreen() & 0xff); - const u8 b = (u8)(pixel.getBlue() & 0xff); - file->write(&r, 1); - file->write(&g, 1); - file->write(&b, 1); - } - } - } - else - { - s32 n = 0; - - for (u32 h = 0; h < imageSize.Height; ++h) - { - for (u32 c = 0; c < imageSize.Width; ++c, ++n) - { - const video::SColor& pixel = image->getPixel(c, h); - size = snprintf(cache, 70, "%.3u %.3u %.3u%s", pixel.getRed(), pixel.getGreen(), pixel.getBlue(), n % 5 == 4 ? "\n" : " "); - if (file->write(cache, size) != size) - return false; - } - } - } - - return true; -} - - -} // namespace video -} // namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CImageWriterPPM.h b/irrlicht-1.6/source/Irrlicht/CImageWriterPPM.h deleted file mode 100644 index 03b4804e2..000000000 --- a/irrlicht-1.6/source/Irrlicht/CImageWriterPPM.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef _C_IMAGE_WRITER_PPM_H_INCLUDED__ -#define _C_IMAGE_WRITER_PPM_H_INCLUDED__ - -#include "IrrCompileConfig.h" - -#ifdef _IRR_COMPILE_WITH_PPM_WRITER_ - -#include "IImageWriter.h" - -namespace irr -{ -namespace video -{ - -class CImageWriterPPM : public IImageWriter -{ -public: - //! constructor - CImageWriterPPM(); - - //! return true if this writer can write a file with the given extension - virtual bool isAWriteableFileExtension(const io::path& filename) const; - - //! write image to file - virtual bool writeImage(io::IWriteFile *file, IImage *image, u32 param) const; -}; - -} // namespace video -} // namespace irr - -#endif // _C_IMAGE_WRITER_PPM_H_INCLUDED__ -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CImageWriterPSD.cpp b/irrlicht-1.6/source/Irrlicht/CImageWriterPSD.cpp deleted file mode 100644 index 43ecb918a..000000000 --- a/irrlicht-1.6/source/Irrlicht/CImageWriterPSD.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CImageWriterPSD.h" - -#ifdef _IRR_COMPILE_WITH_PSD_WRITER_ - -#include "CImageLoaderPSD.h" -#include "IWriteFile.h" -#include "os.h" // for logging -#include "irrString.h" - -namespace irr -{ -namespace video -{ - -IImageWriter* createImageWriterPSD() -{ - return new CImageWriterPSD; -} - -CImageWriterPSD::CImageWriterPSD() -{ -#ifdef _DEBUG - setDebugName("CImageWriterPSD"); -#endif -} - -bool CImageWriterPSD::isAWriteableFileExtension(const io::path& filename) const -{ - return core::hasFileExtension ( filename, "psd" ); -} - -bool CImageWriterPSD::writeImage(io::IWriteFile *file, IImage *image,u32 param) const -{ - os::Printer::log("PSD writer not yet implemented. Image not written.", ELL_WARNING); - return false; -} - -} // namespace video -} // namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CImageWriterPSD.h b/irrlicht-1.6/source/Irrlicht/CImageWriterPSD.h deleted file mode 100644 index 5943e5feb..000000000 --- a/irrlicht-1.6/source/Irrlicht/CImageWriterPSD.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef _C_IMAGE_WRITER_PSD_H_INCLUDED__ -#define _C_IMAGE_WRITER_PSD_H_INCLUDED__ - -#include "IrrCompileConfig.h" - -#ifdef _IRR_COMPILE_WITH_PSD_WRITER_ - -#include "IImageWriter.h" - -namespace irr -{ -namespace video -{ - -class CImageWriterPSD : public IImageWriter -{ -public: - //! constructor - CImageWriterPSD(); - - //! return true if this writer can write a file with the given extension - virtual bool isAWriteableFileExtension(const io::path& filename) const; - - //! write image to file - virtual bool writeImage(io::IWriteFile *file, IImage *image,u32 param) const; -}; - -} // namespace video -} // namespace irr - -#endif // _I_IMAGE_WRITER_PSD_H_INCLUDED__ -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CImageWriterTGA.cpp b/irrlicht-1.6/source/Irrlicht/CImageWriterTGA.cpp deleted file mode 100644 index 4f4cae63e..000000000 --- a/irrlicht-1.6/source/Irrlicht/CImageWriterTGA.cpp +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CImageWriterTGA.h" - -#ifdef _IRR_COMPILE_WITH_TGA_WRITER_ - -#include "CImageLoaderTGA.h" -#include "IWriteFile.h" -#include "CColorConverter.h" -#include "irrString.h" - -namespace irr -{ -namespace video -{ - -IImageWriter* createImageWriterTGA() -{ - return new CImageWriterTGA; -} - -CImageWriterTGA::CImageWriterTGA() -{ -#ifdef _DEBUG - setDebugName("CImageWriterTGA"); -#endif -} - -bool CImageWriterTGA::isAWriteableFileExtension(const io::path& filename) const -{ - return core::hasFileExtension ( filename, "tga" ); -} - -bool CImageWriterTGA::writeImage(io::IWriteFile *file, IImage *image,u32 param) const -{ - STGAHeader imageHeader; - imageHeader.IdLength = 0; - imageHeader.ColorMapType = 0; - imageHeader.ImageType = 2; - imageHeader.FirstEntryIndex[0] = 0; - imageHeader.FirstEntryIndex[1] = 0; - imageHeader.ColorMapLength = 0; - imageHeader.ColorMapEntrySize = 0; - imageHeader.XOrigin[0] = 0; - imageHeader.XOrigin[1] = 0; - imageHeader.YOrigin[0] = 0; - imageHeader.YOrigin[1] = 0; - imageHeader.ImageWidth = image->getDimension().Width; - imageHeader.ImageHeight = image->getDimension().Height; - - // top left of image is the top. the image loader needs to - // be fixed to only swap/flip - imageHeader.ImageDescriptor = (1 << 5); - - // chances are good we'll need to swizzle data, so i'm going - // to convert and write one scan line at a time. it's also - // a bit cleaner this way - void (*CColorConverter_convertFORMATtoFORMAT)(const void*, s32, void*) = 0; - switch(image->getColorFormat()) - { - case ECF_A8R8G8B8: - CColorConverter_convertFORMATtoFORMAT - = CColorConverter::convert_A8R8G8B8toA8R8G8B8; - imageHeader.PixelDepth = 32; - imageHeader.ImageDescriptor |= 8; - break; - case ECF_A1R5G5B5: - CColorConverter_convertFORMATtoFORMAT - = CColorConverter::convert_A1R5G5B5toA1R5G5B5; - imageHeader.PixelDepth = 16; - imageHeader.ImageDescriptor |= 1; - break; - case ECF_R5G6B5: - CColorConverter_convertFORMATtoFORMAT - = CColorConverter::convert_R5G6B5toA1R5G5B5; - imageHeader.PixelDepth = 16; - imageHeader.ImageDescriptor |= 1; - break; - case ECF_R8G8B8: - CColorConverter_convertFORMATtoFORMAT - = CColorConverter::convert_R8G8B8toR8G8B8; - imageHeader.PixelDepth = 24; - imageHeader.ImageDescriptor |= 0; - break; - } - - // couldn't find a color converter - if (!CColorConverter_convertFORMATtoFORMAT) - return false; - - if (file->write(&imageHeader, sizeof(imageHeader)) != sizeof(imageHeader)) - return false; - - u8* scan_lines = (u8*)image->lock(); - if (!scan_lines) - return false; - - // size of one pixel in bytes - u32 pixel_size = image->getBytesPerPixel(); - - // length of one row of the source image in bytes - u32 row_stride = (pixel_size * imageHeader.ImageWidth); - - // length of one output row in bytes - s32 row_size = ((imageHeader.PixelDepth / 8) * imageHeader.ImageWidth); - - // allocate a row do translate data into - u8* row_pointer = new u8[row_size]; - - u32 y; - for (y = 0; y < imageHeader.ImageHeight; ++y) - { - // source, length [pixels], destination - if (image->getColorFormat()==ECF_R8G8B8) - CColorConverter::convert24BitTo24Bit(&scan_lines[y * row_stride], row_pointer, imageHeader.ImageWidth, 1, 0, 0, true); - else - CColorConverter_convertFORMATtoFORMAT(&scan_lines[y * row_stride], imageHeader.ImageWidth, row_pointer); - if (file->write(row_pointer, row_size) != row_size) - break; - } - - delete [] row_pointer; - - image->unlock(); - - STGAFooter imageFooter; - imageFooter.ExtensionOffset = 0; - imageFooter.DeveloperOffset = 0; - strncpy(imageFooter.Signature, "TRUEVISION-XFILE.", 18); - - if (file->write(&imageFooter, sizeof(imageFooter)) < (s32)sizeof(imageFooter)) - return false; - - return imageHeader.ImageHeight < y; -} - -} // namespace video -} // namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CImageWriterTGA.h b/irrlicht-1.6/source/Irrlicht/CImageWriterTGA.h deleted file mode 100644 index 924c7da92..000000000 --- a/irrlicht-1.6/source/Irrlicht/CImageWriterTGA.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef _C_IMAGE_WRITER_TGA_H_INCLUDED__ -#define _C_IMAGE_WRITER_TGA_H_INCLUDED__ - -#include "IrrCompileConfig.h" - -#ifdef _IRR_COMPILE_WITH_TGA_WRITER_ - -#include "IImageWriter.h" - -namespace irr -{ -namespace video -{ - -class CImageWriterTGA : public IImageWriter -{ -public: - //! constructor - CImageWriterTGA(); - - //! return true if this writer can write a file with the given extension - virtual bool isAWriteableFileExtension(const io::path& filename) const; - - //! write image to file - virtual bool writeImage(io::IWriteFile *file, IImage *image,u32 param) const; -}; - -} // namespace video -} // namespace irr - -#endif // _C_IMAGE_WRITER_TGA_H_INCLUDED__ -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CIrrDeviceConsole.cpp b/irrlicht-1.6/source/Irrlicht/CIrrDeviceConsole.cpp deleted file mode 100644 index 4e817fa16..000000000 --- a/irrlicht-1.6/source/Irrlicht/CIrrDeviceConsole.cpp +++ /dev/null @@ -1,475 +0,0 @@ -// Copyright (C) 2009 Gaz Davidson -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CIrrDeviceConsole.h" - -#ifdef _IRR_COMPILE_WITH_CONSOLE_DEVICE_ - -#include "os.h" -#include "IGUISkin.h" -#include "IGUIEnvironment.h" - -// to close the device on terminate signal -irr::CIrrDeviceConsole *DeviceToClose; - -#ifdef _IRR_WINDOWS_NT_CONSOLE_ -// Callback for Windows -BOOL WINAPI ConsoleHandler(DWORD CEvent) -{ - switch(CEvent) - { - case CTRL_C_EVENT: - irr::os::Printer::log("Closing console device", "CTRL+C"); - break; - case CTRL_BREAK_EVENT: - irr::os::Printer::log("Closing console device", "CTRL+Break"); - break; - case CTRL_CLOSE_EVENT: - irr::os::Printer::log("Closing console device", "User closed console"); - break; - case CTRL_LOGOFF_EVENT: - irr::os::Printer::log("Closing console device", "User is logging off"); - break; - case CTRL_SHUTDOWN_EVENT: - irr::os::Printer::log("Closing console device", "Computer shutting down"); - break; - } - DeviceToClose->closeDevice(); - return TRUE; -} -#else -// sigterm handler -#include <signal.h> - -void sighandler(int sig) -{ - irr::core::stringc code = "Signal "; - code += sig; - code += " received"; - irr::os::Printer::log("Closing console device", code.c_str()); - - DeviceToClose->closeDevice(); -} -#endif - -namespace irr -{ - -const c8 ASCIIArtChars[] = " .,'~:;!+>=icopjtJY56SB8XDQKHNWM"; //MWNHKQDX8BS65YJtjpoci=+>!;:~',. "; -const u16 ASCIIArtCharsCount = 32; - -//const c8 ASCIIArtChars[] = " \xb0\xb1\xf9\xb2\xdb"; -//const u16 ASCIIArtCharsCount = 5; - -//! constructor -CIrrDeviceConsole::CIrrDeviceConsole(const SIrrlichtCreationParameters& params) - : CIrrDeviceStub(params), IsDeviceRunning(true), IsWindowFocused(true), ConsoleFont(0), OutFile(stdout) -{ - DeviceToClose = this; - -#ifdef _IRR_WINDOWS_NT_CONSOLE_ - MouseButtonStates = 0; - - WindowsSTDIn = GetStdHandle(STD_INPUT_HANDLE); - WindowsSTDOut = GetStdHandle(STD_OUTPUT_HANDLE); - PCOORD Dimensions = 0; - - if (CreationParams.Fullscreen) - { - if (SetConsoleDisplayMode(WindowsSTDOut, CONSOLE_FULLSCREEN_MODE, Dimensions)) - { - CreationParams.WindowSize.Width = Dimensions->X; - CreationParams.WindowSize.Width = Dimensions->Y; - } - } - else - { - COORD ConsoleSize; - ConsoleSize.X = CreationParams.WindowSize.Width; - ConsoleSize.X = CreationParams.WindowSize.Height; - SetConsoleScreenBufferSize(WindowsSTDOut, ConsoleSize); - } - - // catch windows close/break signals - SetConsoleCtrlHandler((PHANDLER_ROUTINE)ConsoleHandler, TRUE); - -#else - // catch other signals - signal(SIGABRT, &sighandler); - signal(SIGTERM, &sighandler); - signal(SIGINT, &sighandler); - - // set output stream - if (params.WindowId) - OutFile = (FILE*)(params.WindowId); -#endif - -#ifdef _IRR_VT100_CONSOLE_ - // reset terminal - fprintf(OutFile, "%cc", 27); - // disable line wrapping - fprintf(OutFile, "%c[7l", 27); -#endif - - switch (params.DriverType) - { - case video::EDT_SOFTWARE: - #ifdef _IRR_COMPILE_WITH_SOFTWARE_ - VideoDriver = video::createSoftwareDriver(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this); - #else - os::Printer::log("Software driver was not compiled in.", ELL_ERROR); - #endif - break; - - case video::EDT_BURNINGSVIDEO: - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - VideoDriver = video::createSoftwareDriver2(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this); - #else - os::Printer::log("Burning's Video driver was not compiled in.", ELL_ERROR); - #endif - break; - - case video::EDT_DIRECT3D8: - case video::EDT_DIRECT3D9: - case video::EDT_OPENGL: - os::Printer::log("The console device cannot use hardware drivers yet.", ELL_ERROR); - break; - case video::EDT_NULL: - VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize); - break; - default: - break; - } - - // set up output buffer - for (u32 y=0; y<CreationParams.WindowSize.Height; ++y) - { - core::stringc str; - str.reserve(CreationParams.WindowSize.Width); - for (u32 x=0; x<CreationParams.WindowSize.Width; ++x) - str += " "; - OutputBuffer.push_back(str); - } - - -#ifdef _IRR_WINDOWS_NT_CONSOLE_ - CursorControl = new CCursorControl(CreationParams.WindowSize); -#endif - - if (VideoDriver) - { - createGUIAndScene(); -#ifdef _IRR_USE_CONSOLE_FONT_ - if (GUIEnvironment) - { - ConsoleFont = new gui::CGUIConsoleFont(this); - gui::IGUISkin *skin = GUIEnvironment->getSkin(); - if (skin) - { - for (u32 i=0; i < gui::EGDF_COUNT; ++i) - skin->setFont(ConsoleFont, gui::EGUI_DEFAULT_FONT(i)); - } - } -#endif - } -} - -//! destructor -CIrrDeviceConsole::~CIrrDeviceConsole() -{ - // GUI and scene are dropped in the stub - if (CursorControl) - { - CursorControl->drop(); - CursorControl = 0; - } - if (ConsoleFont) - { - ConsoleFont->drop(); - ConsoleFont = 0; - } -#ifdef _IRR_VT100_CONSOLE_ - // reset terminal - fprintf(OutFile, "%cc", 27); -#endif -} - -//! runs the device. Returns false if device wants to be deleted -bool CIrrDeviceConsole::run() -{ - // increment timer - os::Timer::tick(); - - // process Windows console input -#ifdef _IRR_WINDOWS_NT_CONSOLE_ - - INPUT_RECORD in; - DWORD oldMode; - DWORD count, waste; - - // get old input mode - GetConsoleMode(WindowsSTDIn, &oldMode); - SetConsoleMode(WindowsSTDIn, ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT); - - GetNumberOfConsoleInputEvents(WindowsSTDIn, &count); - - // read keyboard and mouse input - while (count) - { - ReadConsoleInput(WindowsSTDIn, &in, 1, &waste ); - switch(in.EventType) - { - case KEY_EVENT: - { - SEvent e; - e.EventType = EET_KEY_INPUT_EVENT; - e.KeyInput.PressedDown = (in.Event.KeyEvent.bKeyDown == TRUE); - e.KeyInput.Control = (in.Event.KeyEvent.dwControlKeyState & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) != 0; - e.KeyInput.Shift = (in.Event.KeyEvent.dwControlKeyState & SHIFT_PRESSED) != 0; - e.KeyInput.Key = EKEY_CODE(in.Event.KeyEvent.wVirtualKeyCode); - e.KeyInput.Char = in.Event.KeyEvent.uChar.UnicodeChar; - postEventFromUser(e); - break; - } - case MOUSE_EVENT: - { - SEvent e; - e.EventType = EET_MOUSE_INPUT_EVENT; - e.MouseInput.X = in.Event.MouseEvent.dwMousePosition.X; - e.MouseInput.Y = in.Event.MouseEvent.dwMousePosition.Y; - e.MouseInput.Wheel = 0.f; - e.MouseInput.ButtonStates = - ( (in.Event.MouseEvent.dwButtonState & FROM_LEFT_1ST_BUTTON_PRESSED) ? EMBSM_LEFT : 0 ) | - ( (in.Event.MouseEvent.dwButtonState & RIGHTMOST_BUTTON_PRESSED) ? EMBSM_RIGHT : 0 ) | - ( (in.Event.MouseEvent.dwButtonState & FROM_LEFT_2ND_BUTTON_PRESSED) ? EMBSM_MIDDLE : 0 ) | - ( (in.Event.MouseEvent.dwButtonState & FROM_LEFT_3RD_BUTTON_PRESSED) ? EMBSM_EXTRA1 : 0 ) | - ( (in.Event.MouseEvent.dwButtonState & FROM_LEFT_4TH_BUTTON_PRESSED) ? EMBSM_EXTRA2 : 0 ); - - if (in.Event.MouseEvent.dwEventFlags & MOUSE_MOVED) - { - CursorControl->setPosition(core::position2di(e.MouseInput.X, e.MouseInput.Y)); - - // create mouse moved event - e.MouseInput.Event = EMIE_MOUSE_MOVED; - postEventFromUser(e); - } - - if (in.Event.MouseEvent.dwEventFlags & MOUSE_WHEELED) - { - e.MouseInput.Event = EMIE_MOUSE_WHEEL; - e.MouseInput.Wheel = (in.Event.MouseEvent.dwButtonState & 0xFF000000) ? -1.0f : 1.0f; - postEventFromUser(e); - } - - if ( (MouseButtonStates & EMBSM_LEFT) != (e.MouseInput.ButtonStates & EMBSM_LEFT) ) - { - e.MouseInput.Event = (e.MouseInput.ButtonStates & EMBSM_LEFT) ? EMIE_LMOUSE_PRESSED_DOWN : EMIE_LMOUSE_LEFT_UP; - postEventFromUser(e); - } - - if ( (MouseButtonStates & EMBSM_RIGHT) != (e.MouseInput.ButtonStates & EMBSM_RIGHT) ) - { - e.MouseInput.Event = (e.MouseInput.ButtonStates & EMBSM_RIGHT) ? EMIE_RMOUSE_PRESSED_DOWN : EMIE_RMOUSE_LEFT_UP; - postEventFromUser(e); - } - - if ( (MouseButtonStates & EMBSM_MIDDLE) != (e.MouseInput.ButtonStates & EMBSM_MIDDLE) ) - { - e.MouseInput.Event = (e.MouseInput.ButtonStates & EMBSM_MIDDLE) ? EMIE_MMOUSE_PRESSED_DOWN : EMIE_MMOUSE_LEFT_UP; - postEventFromUser(e); - } - - // save current button states - MouseButtonStates = e.MouseInput.ButtonStates; - - break; - } - case WINDOW_BUFFER_SIZE_EVENT: - VideoDriver->OnResize( - core::dimension2d<u32>(in.Event.WindowBufferSizeEvent.dwSize.X, - in.Event.WindowBufferSizeEvent.dwSize.Y)); - break; - case FOCUS_EVENT: - IsWindowFocused = (in.Event.FocusEvent.bSetFocus == TRUE); - break; - default: - break; - } - GetNumberOfConsoleInputEvents(WindowsSTDIn, &count); - } - - // set input mode - SetConsoleMode(WindowsSTDIn, oldMode); -#else - // todo: keyboard input from terminal in raw mode -#endif - - return IsDeviceRunning; -} - -//! Cause the device to temporarily pause execution and let other processes to run -// This should bring down processor usage without major performance loss for Irrlicht -void CIrrDeviceConsole::yield() -{ -#ifdef _IRR_WINDOWS_API_ - Sleep(1); -#else - struct timespec ts = {0,0}; - nanosleep(&ts, NULL); -#endif -} - -//! Pause execution and let other processes to run for a specified amount of time. -void CIrrDeviceConsole::sleep(u32 timeMs, bool pauseTimer) -{ - const bool wasStopped = Timer ? Timer->isStopped() : true; - -#ifdef _IRR_WINDOWS_API_ - Sleep(timeMs); -#else - struct timespec ts; - ts.tv_sec = (time_t) (timeMs / 1000); - ts.tv_nsec = (long) (timeMs % 1000) * 1000000; - - if (pauseTimer && !wasStopped) - Timer->stop(); - - nanosleep(&ts, NULL); -#endif - - if (pauseTimer && !wasStopped) - Timer->start(); -} - -//! sets the caption of the window -void CIrrDeviceConsole::setWindowCaption(const wchar_t* text) -{ -#ifdef _IRR_WINDOWS_NT_CONSOLE_ - core::stringc txt(text); - SetConsoleTitle(txt.c_str()); -#endif -} - -//! returns if window is active. if not, nothing need to be drawn -bool CIrrDeviceConsole::isWindowActive() const -{ - // there is no window, but we always assume it is active - return true; -} - -//! returns if window has focus -bool CIrrDeviceConsole::isWindowFocused() const -{ - return IsWindowFocused; -} - -//! returns if window is minimized -bool CIrrDeviceConsole::isWindowMinimized() const -{ - return false; -} - -//! presents a surface in the client area -bool CIrrDeviceConsole::present(video::IImage* surface, void* windowId, core::rect<s32>* src) -{ - - if (surface) - { - for (u32 y=0; y < surface->getDimension().Height; ++y) - { - for (u32 x=0; x< surface->getDimension().Width; ++x) - { - // get average pixel - u32 avg = surface->getPixel(x,y).getAverage() * (ASCIIArtCharsCount-1); - avg /= 255; - OutputBuffer[y] [x] = ASCIIArtChars[avg]; - } - } - } -#ifdef _IRR_USE_CONSOLE_FONT_ - for (u32 i=0; i< Text.size(); ++i) - { - s32 y = Text[i].Pos.Y; - - if ( y < (s32)OutputBuffer.size() && y > 0) - for (u32 c=0; c < Text[i].Text.size() && c + Text[i].Pos.X < OutputBuffer[y].size(); ++c) - //if (Text[i].Text[c] != ' ') - OutputBuffer[y] [c+Text[i].Pos.X] = Text[i].Text[c]; - } - Text.clear(); -#endif - - // draw output - for (u32 y=0; y<OutputBuffer.size(); ++y) - { - setTextCursorPos(0,y); - fprintf(OutFile, "%s", OutputBuffer[y].c_str()); - } - return surface != 0; -} - -//! notifies the device that it should close itself -void CIrrDeviceConsole::closeDevice() -{ - // return false next time we run() - IsDeviceRunning = false; -} - - -//! Sets if the window should be resizable in windowed mode. -void CIrrDeviceConsole::setResizable(bool resize) -{ - // do nothing -} - - -//! Minimize the window. -void CIrrDeviceConsole::minimizeWindow() -{ - // do nothing -} - - -//! Maximize window -void CIrrDeviceConsole::maximizeWindow() -{ - // do nothing -} - - -//! Restore original window size -void CIrrDeviceConsole::restoreWindow() -{ - // do nothing -} - - -void CIrrDeviceConsole::setTextCursorPos(s16 x, s16 y) -{ -#ifdef _IRR_WINDOWS_NT_CONSOLE_ - // move WinNT cursor - COORD Position; - Position.X = x; - Position.Y = y; - SetConsoleCursorPosition(WindowsSTDOut, Position); -#elif defined(_IRR_VT100_CONSOLE_) - // send escape code - fprintf(OutFile, "%c[%d;%dH", 27, y, x); -#else - // not implemented -#endif -} - -void CIrrDeviceConsole::addPostPresentText(s16 X, s16 Y, const wchar_t *text) -{ - SPostPresentText p; - p.Text = text; - p.Pos.X = X; - p.Pos.Y = Y; - Text.push_back(p); -} - -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_CONSOLE_DEVICE_ diff --git a/irrlicht-1.6/source/Irrlicht/CIrrDeviceConsole.h b/irrlicht-1.6/source/Irrlicht/CIrrDeviceConsole.h deleted file mode 100644 index 557800ce9..000000000 --- a/irrlicht-1.6/source/Irrlicht/CIrrDeviceConsole.h +++ /dev/null @@ -1,330 +0,0 @@ -// Copyright (C) 2009 Gaz Davidson -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_IRR_DEVICE_CONSOLE_H_INCLUDED__ -#define __C_IRR_DEVICE_CONSOLE_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_CONSOLE_DEVICE_ - -//#define _IRR_USE_CONSOLE_FONT_ - -#include "SIrrCreationParameters.h" -#include "CIrrDeviceStub.h" -#include "IImagePresenter.h" -// for console font -#include "IGUIFont.h" - -#ifdef _IRR_WINDOWS_API_ -#define WIN32_LEAN_AND_MEAN -#if !defined(_IRR_XBOX_PLATFORM_) - #include <windows.h> -#endif -#if(_WIN32_WINNT >= 0x0500) -#define _IRR_WINDOWS_NT_CONSOLE_ -#endif -#else -#include <time.h> -#endif - -// for now we assume all other terminal types are VT100 -#ifndef _IRR_WINDOWS_NT_CONSOLE_ -#define _IRR_VT100_CONSOLE_ -#endif - -namespace irr -{ - - class CIrrDeviceConsole : public CIrrDeviceStub, video::IImagePresenter - { - public: - - //! constructor - CIrrDeviceConsole(const SIrrlichtCreationParameters& params); - - //! destructor - virtual ~CIrrDeviceConsole(); - - //! runs the device. Returns false if device wants to be deleted - virtual bool run(); - - //! Cause the device to temporarily pause execution and let other processes to run - // This should bring down processor usage without major performance loss for Irrlicht - virtual void yield(); - - //! Pause execution and let other processes to run for a specified amount of time. - virtual void sleep(u32 timeMs, bool pauseTimer); - - //! sets the caption of the window - virtual void setWindowCaption(const wchar_t* text); - - //! returns if window is active. if not, nothing need to be drawn - virtual bool isWindowActive() const; - - //! returns if window has focus - virtual bool isWindowFocused() const; - - //! returns if window is minimized - virtual bool isWindowMinimized() const; - - //! presents a surface in the client area - virtual bool present(video::IImage* surface, void* windowId=0, core::rect<s32>* src=0); - - //! notifies the device that it should close itself - virtual void closeDevice(); - - //! Sets if the window should be resizable in windowed mode. - virtual void setResizable(bool resize=false); - - //! Minimizes the window. - virtual void minimizeWindow(); - - //! Maximizes the window. - virtual void maximizeWindow(); - - //! Restores the window size. - virtual void restoreWindow(); - - //! Get the device type - virtual E_DEVICE_TYPE getType() const - { - return EIDT_CONSOLE; - } - - void addPostPresentText(s16 X, s16 Y, const wchar_t *text); - - //! Implementation of the win32 console mouse cursor - class CCursorControl : public gui::ICursorControl - { - public: - - CCursorControl(const core::dimension2d<u32>& wsize) - : WindowSize(wsize), InvWindowSize(0.0f, 0.0f), IsVisible(true), UseReferenceRect(false) - { - if (WindowSize.Width!=0) - InvWindowSize.Width = 1.0f / WindowSize.Width; - - if (WindowSize.Height!=0) - InvWindowSize.Height = 1.0f / WindowSize.Height; - } - - //! Changes the visible state of the mouse cursor. - virtual void setVisible(bool visible) - { - if(visible != IsVisible) - { - IsVisible = visible; - setPosition(CursorPos.X, CursorPos.Y); - } - } - - //! Returns if the cursor is currently visible. - virtual bool isVisible() const - { - return IsVisible; - } - - //! Sets the new position of the cursor. - virtual void setPosition(const core::position2d<f32> &pos) - { - setPosition(pos.X, pos.Y); - } - - //! Sets the new position of the cursor. - virtual void setPosition(f32 x, f32 y) - { - if (!UseReferenceRect) - setPosition((s32)(x*WindowSize.Width), (s32)(y*WindowSize.Height)); - else - setPosition((s32)(x*ReferenceRect.getWidth()), (s32)(y*ReferenceRect.getHeight())); - } - - //! Sets the new position of the cursor. - virtual void setPosition(const core::position2d<s32> &pos) - { - setPosition(pos.X, pos.Y); - } - - //! Sets the new position of the cursor. - virtual void setPosition(s32 x, s32 y) - { - setInternalCursorPosition(core::position2di(x,y)); - } - - //! Returns the current position of the mouse cursor. - virtual core::position2d<s32> getPosition() - { - return CursorPos; - } - - //! Returns the current position of the mouse cursor. - virtual core::position2d<f32> getRelativePosition() - { - if (!UseReferenceRect) - { - return core::position2d<f32>(CursorPos.X * InvWindowSize.Width, - CursorPos.Y * InvWindowSize.Height); - } - - return core::position2d<f32>(CursorPos.X / (f32)ReferenceRect.getWidth(), - CursorPos.Y / (f32)ReferenceRect.getHeight()); - } - - //! Sets an absolute reference rect for calculating the cursor position. - virtual void setReferenceRect(core::rect<s32>* rect=0) - { - if (rect) - { - ReferenceRect = *rect; - UseReferenceRect = true; - - // prevent division through zero and uneven sizes - - if (!ReferenceRect.getHeight() || ReferenceRect.getHeight()%2) - ReferenceRect.LowerRightCorner.Y += 1; - - if (!ReferenceRect.getWidth() || ReferenceRect.getWidth()%2) - ReferenceRect.LowerRightCorner.X += 1; - } - else - UseReferenceRect = false; - } - - - //! Updates the internal cursor position - void setInternalCursorPosition(const core::position2di &pos) - { - CursorPos = pos; - - if (UseReferenceRect) - CursorPos -= ReferenceRect.UpperLeftCorner; - } - - private: - - core::position2d<s32> CursorPos; - core::dimension2d<u32> WindowSize; - core::dimension2d<f32> InvWindowSize; - bool IsVisible, - UseReferenceRect; - core::rect<s32> ReferenceRect; - }; - - private: - - //! Set the position of the text caret - void setTextCursorPos(s16 x, s16 y); - - // text to be added after drawing the screen - struct SPostPresentText - { - core::position2d<s16> Pos; - core::stringc Text; - }; - - bool IsDeviceRunning, - IsWindowFocused; - - core::array<core::stringc> OutputBuffer; - gui::IGUIFont *ConsoleFont; - core::array<SPostPresentText> Text; - - FILE *OutFile; - -#ifdef _IRR_WINDOWS_NT_CONSOLE_ - HANDLE WindowsSTDIn, WindowsSTDOut; - u32 MouseButtonStates; -#endif - }; - -#ifdef _IRR_USE_CONSOLE_FONT_ - -namespace gui -{ - class CGUIConsoleFont : public IGUIFont - { - public: - - CGUIConsoleFont(CIrrDeviceConsole* device) : Device(device) { } - - //! Draws some text and clips it to the specified rectangle if wanted. - virtual void draw(const wchar_t* text, const core::rect<s32>& position, - video::SColor color, bool hcenter=false, bool vcenter=false, - const core::rect<s32>* clip=0) - { - core::rect<s32> Area = clip ? *clip : position; - - if (Area.UpperLeftCorner.X < 0) - Area.UpperLeftCorner.X = 0; - - if (Area.UpperLeftCorner.Y < 0) - Area.UpperLeftCorner.Y = 0; - - core::position2d<s16> pos; - - // centre vertically - pos.Y = vcenter ? (position.UpperLeftCorner.Y + position.LowerRightCorner.Y) / 2 : position.UpperLeftCorner.Y; - - // nothing to display? - if (pos.Y < Area.UpperLeftCorner.Y || pos.Y > Area.LowerRightCorner.Y) - return; - - tempText = text; - - // centre horizontally - pos.X = hcenter ? position.getCenter().X - ( tempText.size() / 2) : position.UpperLeftCorner.X; - - // clip - u32 xlclip = 0, - xrclip = 0; - - // get right clip - if (pos.X + (s32)tempText.size() > Area.LowerRightCorner.X) - xrclip = Area.LowerRightCorner.X - pos.X; - - // get left clip - if (pos.X < Area.UpperLeftCorner.X) - xlclip = Area.UpperLeftCorner.X - pos.X; - - // totally clipped? - if ((s32)tempText.size() - xlclip - xrclip < 0) - return; - - // null terminate the string - if (xrclip > 0) - tempText[xrclip] = L'\0'; - - Device->addPostPresentText(pos.X + xlclip, pos.Y, &(tempText.c_str()[xlclip])); - } - - //! Calculates the dimension of some text. - virtual core::dimension2d<u32> getDimension(const wchar_t* text) const - { - return core::dimension2d<u32>(wcslen(text),1); - } - - //! Calculates the index of the character in the text which is on a specific position. - virtual s32 getCharacterFromPos(const wchar_t* text, s32 pixel_x) const { return pixel_x; }; - - //! No kerning - virtual void setKerningWidth (s32 kerning) { } - virtual void setKerningHeight (s32 kerning) { } - virtual s32 getKerningWidth(const wchar_t* thisLetter=0, const wchar_t* previousLetter=0) const {return 0;} - virtual s32 getKerningHeight() const { return 0;} - virtual void setInvisibleCharacters( const wchar_t *s ) { } - // I guess this is an OS specific font - virtual EGUI_FONT_TYPE getType() const { return EGFT_OS; } - private: - CIrrDeviceConsole* Device; - core::stringw tempText; - }; - -} // end namespace gui - -#endif // _IRR_USE_CONSOLE_FONT_ - -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_CONSOLE_DEVICE_ -#endif // __C_IRR_DEVICE_CONSOLE_H_INCLUDED__ diff --git a/irrlicht-1.6/source/Irrlicht/CIrrDeviceLinux.cpp b/irrlicht-1.6/source/Irrlicht/CIrrDeviceLinux.cpp deleted file mode 100644 index 5afa49ece..000000000 --- a/irrlicht-1.6/source/Irrlicht/CIrrDeviceLinux.cpp +++ /dev/null @@ -1,1797 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CIrrDeviceLinux.h" - -#ifdef _IRR_COMPILE_WITH_X11_DEVICE_ - -#include <stdio.h> -#include <stdlib.h> -#include <sys/utsname.h> -#include <time.h> -#include "IEventReceiver.h" -#include "os.h" -#include "CTimer.h" -#include "irrString.h" -#include "Keycodes.h" -#include "COSOperator.h" -#include "CColorConverter.h" -#include "SIrrCreationParameters.h" -#include <X11/XKBlib.h> -#include <X11/Xatom.h> - -#if defined _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ -#include <fcntl.h> -#include <unistd.h> - -// linux/joystick.h includes linux/input.h, which #defines values for various KEY_FOO keys. -// These override the irr::KEY_FOO equivalents, which stops key handling from working. -// As a workaround, defining _INPUT_H stops linux/input.h from being included; it -// doesn't actually seem to be necessary except to pull in sys/ioctl.h. -#define _INPUT_H -#include <sys/ioctl.h> // Would normally be included in linux/input.h -#include <linux/joystick.h> -#undef _INPUT_H -#endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ - -namespace irr -{ - namespace video - { - IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params, - io::IFileSystem* io, CIrrDeviceLinux* device); - } -} // end namespace irr - -namespace -{ - Atom X_ATOM_CLIPBOARD; - Atom X_ATOM_TARGETS; - Atom X_ATOM_UTF8_STRING; - Atom X_ATOM_TEXT; -}; - -namespace irr -{ - -const char* wmDeleteWindow = "WM_DELETE_WINDOW"; - -//! constructor -CIrrDeviceLinux::CIrrDeviceLinux(const SIrrlichtCreationParameters& param) - : CIrrDeviceStub(param), -#ifdef _IRR_COMPILE_WITH_X11_ - display(0), visual(0), screennr(0), window(0), StdHints(0), SoftwareImage(0), -#ifdef _IRR_COMPILE_WITH_OPENGL_ - glxWin(0), - Context(0), -#endif -#endif - Width(param.WindowSize.Width), Height(param.WindowSize.Height), - Close(false), WindowHasFocus(false), WindowMinimized(false), - UseXVidMode(false), UseXRandR(false), UseGLXWindow(false), - ExternalWindow(false), AutorepeatSupport(0) -{ - #ifdef _DEBUG - setDebugName("CIrrDeviceLinux"); - #endif - - // print version, distribution etc. - // thx to LynxLuna for pointing me to the uname function - core::stringc linuxversion; - struct utsname LinuxInfo; - uname(&LinuxInfo); - - linuxversion += LinuxInfo.sysname; - linuxversion += " "; - linuxversion += LinuxInfo.release; - linuxversion += " "; - linuxversion += LinuxInfo.version; - linuxversion += " "; - linuxversion += LinuxInfo.machine; - - Operator = new COSOperator(linuxversion.c_str(), this); - os::Printer::log(linuxversion.c_str(), ELL_INFORMATION); - - // create keymap - createKeyMap(); - - // create window - if (CreationParams.DriverType != video::EDT_NULL) - { - // create the window, only if we do not use the null device - if (!createWindow()) - return; - } - - // create cursor control - CursorControl = new CCursorControl(this, CreationParams.DriverType == video::EDT_NULL); - - // create driver - createDriver(); - - if (!VideoDriver) - return; - - createGUIAndScene(); -} - - -//! destructor -CIrrDeviceLinux::~CIrrDeviceLinux() -{ -#ifdef _IRR_COMPILE_WITH_X11_ - if (StdHints) - XFree(StdHints); - if (display) - { - #ifdef _IRR_COMPILE_WITH_OPENGL_ - if (Context) - { - if (glxWin) - { - if (!glXMakeContextCurrent(display, None, None, NULL)) - os::Printer::log("Could not release glx context.", ELL_WARNING); - } - else - { - if (!glXMakeCurrent(display, None, NULL)) - os::Printer::log("Could not release glx context.", ELL_WARNING); - } - glXDestroyContext(display, Context); - if (glxWin) - glXDestroyWindow(display, glxWin); - } - #endif // #ifdef _IRR_COMPILE_WITH_OPENGL_ - - #ifdef _IRR_LINUX_X11_VIDMODE_ - if (UseXVidMode && CreationParams.Fullscreen) - { - XF86VidModeSwitchToMode(display, screennr, &oldVideoMode); - XF86VidModeSetViewPort(display, screennr, 0, 0); - } - #endif - #ifdef _IRR_LINUX_X11_RANDR_ - if (UseXRandR && CreationParams.Fullscreen) - { - XRRScreenConfiguration *config=XRRGetScreenInfo(display,DefaultRootWindow(display)); - XRRSetScreenConfig(display,config,DefaultRootWindow(display),oldRandrMode,oldRandrRotation,CurrentTime); - XRRFreeScreenConfigInfo(config); - } - #endif - - if (SoftwareImage) - XDestroyImage(SoftwareImage); - - if (!ExternalWindow) - { - XDestroyWindow(display,window); - XCloseDisplay(display); - } - } - if (visual) - XFree(visual); - -#endif // #ifdef _IRR_COMPILE_WITH_X11_ - -#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) - for(u32 joystick = 0; joystick < ActiveJoysticks.size(); ++joystick) - { - if(ActiveJoysticks[joystick].fd >= 0) - { - close(ActiveJoysticks[joystick].fd); - } - } -#endif -} - - -#if defined(_IRR_COMPILE_WITH_X11_) && defined(_DEBUG) -int IrrPrintXError(Display *display, XErrorEvent *event) -{ - char msg[256]; - char msg2[256]; - - snprintf(msg, 256, "%d", event->request_code); - XGetErrorDatabaseText(display, "XRequest", msg, "unknown", msg2, 256); - XGetErrorText(display, event->error_code, msg, 256); - os::Printer::log("X Error", msg, ELL_WARNING); - os::Printer::log("From call ", msg2, ELL_WARNING); - return 0; -} -#endif - - -bool CIrrDeviceLinux::createWindow() -{ -#ifdef _IRR_COMPILE_WITH_X11_ -#ifdef _DEBUG - os::Printer::log("Creating X window...", ELL_INFORMATION); - XSetErrorHandler(IrrPrintXError); -#endif - - display = XOpenDisplay(0); - if (!display) - { - os::Printer::log("Error: Need running XServer to start Irrlicht Engine.", ELL_ERROR); - if (XDisplayName(0)[0]) - os::Printer::log("Could not open display", XDisplayName(0), ELL_ERROR); - else - os::Printer::log("Could not open display, set DISPLAY variable", ELL_ERROR); - return false; - } - - screennr = DefaultScreen(display); - - // query extension - - if (CreationParams.Fullscreen) - { - getVideoModeList(); - #if defined(_IRR_LINUX_X11_VIDMODE_) || defined(_IRR_LINUX_X11_RANDR_) - s32 eventbase, errorbase; - s32 bestMode = -1; - #endif - - #ifdef _IRR_LINUX_X11_VIDMODE_ - if (XF86VidModeQueryExtension(display, &eventbase, &errorbase)) - { - // enumerate video modes - s32 modeCount; - XF86VidModeModeInfo** modes; - - XF86VidModeGetAllModeLines(display, screennr, &modeCount, &modes); - - // find fitting mode - for (s32 i = 0; i<modeCount; ++i) - { - if (bestMode==-1 && modes[i]->hdisplay >= Width && modes[i]->vdisplay >= Height) - bestMode = i; - else if (bestMode!=-1 && - modes[i]->hdisplay >= Width && - modes[i]->vdisplay >= Height && - modes[i]->hdisplay < modes[bestMode]->hdisplay && - modes[i]->vdisplay < modes[bestMode]->vdisplay) - bestMode = i; - } - if (bestMode != -1) - { - os::Printer::log("Starting fullscreen mode...", ELL_INFORMATION); - XF86VidModeSwitchToMode(display, screennr, modes[bestMode]); - XF86VidModeSetViewPort(display, screennr, 0, 0); - UseXVidMode=true; - } - else - { - os::Printer::log("Could not find specified video mode, running windowed.", ELL_WARNING); - CreationParams.Fullscreen = false; - } - - XFree(modes); - } - else - #endif - #ifdef _IRR_LINUX_X11_RANDR_ - if (XRRQueryExtension(display, &eventbase, &errorbase)) - { - s32 modeCount; - XRRScreenConfiguration *config=XRRGetScreenInfo(display,DefaultRootWindow(display)); - XRRScreenSize *modes=XRRConfigSizes(config,&modeCount); - for (s32 i = 0; i<modeCount; ++i) - { - if (bestMode==-1 && (u32)modes[i].width >= Width && (u32)modes[i].height >= Height) - bestMode = i; - else if (bestMode!=-1 && - (u32)modes[i].width >= Width && - (u32)modes[i].height >= Height && - modes[i].width < modes[bestMode].width && - modes[i].height < modes[bestMode].height) - bestMode = i; - } - if (bestMode != -1) - { - XRRSetScreenConfig(display,config,DefaultRootWindow(display),bestMode,oldRandrRotation,CurrentTime); - UseXRandR=true; - } - XRRFreeScreenConfigInfo(config); - } - else - #endif - { - os::Printer::log("VidMode or RandR extension must be installed to allow Irrlicht " - "to switch to fullscreen mode. Running in windowed mode instead.", ELL_WARNING); - CreationParams.Fullscreen = false; - } - } - -#ifdef _IRR_COMPILE_WITH_OPENGL_ - - GLXFBConfig glxFBConfig; - int major, minor; - bool isAvailableGLX=false; - if (CreationParams.DriverType==video::EDT_OPENGL) - { - isAvailableGLX=glXQueryExtension(display,&major,&minor); - if (isAvailableGLX && glXQueryVersion(display, &major, &minor)) - { -#ifdef GLX_VERSION_1_3 - typedef GLXFBConfig * ( * PFNGLXCHOOSEFBCONFIGPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements); - -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - PFNGLXCHOOSEFBCONFIGPROC glxChooseFBConfig = (PFNGLXCHOOSEFBCONFIGPROC)glXGetProcAddress(reinterpret_cast<const GLubyte*>("glXChooseFBConfig")); -#else - PFNGLXCHOOSEFBCONFIGPROC glxChooseFBConfig=glXChooseFBConfig; -#endif - if (major==1 && minor>2 && glxChooseFBConfig) - { - // attribute array for the draw buffer - int visualAttrBuffer[] = - { - GLX_RENDER_TYPE, GLX_RGBA_BIT, - GLX_RED_SIZE, 4, - GLX_GREEN_SIZE, 4, - GLX_BLUE_SIZE, 4, - GLX_ALPHA_SIZE, CreationParams.WithAlphaChannel?1:0, - GLX_DEPTH_SIZE, CreationParams.ZBufferBits, //10,11 - GLX_DOUBLEBUFFER, CreationParams.Doublebuffer?True:False, - GLX_STENCIL_SIZE, CreationParams.Stencilbuffer?1:0, -#if defined(GLX_VERSION_1_4) && defined(GLX_SAMPLE_BUFFERS) // we need to check the extension string! - GLX_SAMPLE_BUFFERS, 1, - GLX_SAMPLES, CreationParams.AntiAlias, // 18,19 -#elif defined(GLX_ARB_multisample) - GLX_SAMPLE_BUFFERS_ARB, 1, - GLX_SAMPLES_ARB, CreationParams.AntiAlias, // 18,19 -#elif defined(GLX_SGIS_multisample) - GLX_SAMPLE_BUFFERS_SGIS, 1, - GLX_SAMPLES_SGIS, CreationParams.AntiAlias, // 18,19 -#endif - GLX_STEREO, CreationParams.Stereobuffer?True:False, - None - }; - - GLXFBConfig *configList=0; - int nitems=0; - if (CreationParams.AntiAlias<2) - { - visualAttrBuffer[17] = 0; - visualAttrBuffer[19] = 0; - } - // first round with unchanged values - { - configList=glxChooseFBConfig(display, screennr, visualAttrBuffer,&nitems); - if (!configList && CreationParams.AntiAlias) - { - while (!configList && (visualAttrBuffer[19]>1)) - { - visualAttrBuffer[19] -= 1; - configList=glxChooseFBConfig(display, screennr, visualAttrBuffer,&nitems); - } - if (!configList) - { - visualAttrBuffer[17] = 0; - visualAttrBuffer[19] = 0; - configList=glxChooseFBConfig(display, screennr, visualAttrBuffer,&nitems); - if (configList) - { - os::Printer::log("No FSAA available.", ELL_WARNING); - CreationParams.AntiAlias=0; - } - else - { - //reenable multisampling - visualAttrBuffer[17] = 1; - visualAttrBuffer[19] = CreationParams.AntiAlias; - } - } - } - } - // Next try with flipped stencil buffer value - // If the first round was with stencil flag it's now without - // Other way round also makes sense because some configs - // only have depth buffer combined with stencil buffer - if (!configList) - { - if (CreationParams.Stencilbuffer) - os::Printer::log("No stencilbuffer available, disabling stencil shadows.", ELL_WARNING); - CreationParams.Stencilbuffer = !CreationParams.Stencilbuffer; - visualAttrBuffer[15]=CreationParams.Stencilbuffer?1:0; - - configList=glxChooseFBConfig(display, screennr, visualAttrBuffer,&nitems); - if (!configList && CreationParams.AntiAlias) - { - while (!configList && (visualAttrBuffer[19]>1)) - { - visualAttrBuffer[19] -= 1; - configList=glxChooseFBConfig(display, screennr, visualAttrBuffer,&nitems); - } - if (!configList) - { - visualAttrBuffer[17] = 0; - visualAttrBuffer[19] = 0; - configList=glxChooseFBConfig(display, screennr, visualAttrBuffer,&nitems); - if (configList) - { - os::Printer::log("No FSAA available.", ELL_WARNING); - CreationParams.AntiAlias=0; - } - else - { - //reenable multisampling - visualAttrBuffer[17] = 1; - visualAttrBuffer[19] = CreationParams.AntiAlias; - } - } - } - } - // Next try without double buffer - if (!configList && CreationParams.Doublebuffer) - { - os::Printer::log("No doublebuffering available.", ELL_WARNING); - CreationParams.Doublebuffer=false; - visualAttrBuffer[13] = GLX_DONT_CARE; - CreationParams.Stencilbuffer = false; - visualAttrBuffer[15]=0; - configList=glxChooseFBConfig(display, screennr, visualAttrBuffer,&nitems); - if (!configList && CreationParams.AntiAlias) - { - while (!configList && (visualAttrBuffer[19]>1)) - { - visualAttrBuffer[19] -= 1; - configList=glxChooseFBConfig(display, screennr, visualAttrBuffer,&nitems); - } - if (!configList) - { - visualAttrBuffer[17] = 0; - visualAttrBuffer[19] = 0; - configList=glxChooseFBConfig(display, screennr, visualAttrBuffer,&nitems); - if (configList) - { - os::Printer::log("No FSAA available.", ELL_WARNING); - CreationParams.AntiAlias=0; - } - else - { - //reenable multisampling - visualAttrBuffer[17] = 1; - visualAttrBuffer[19] = CreationParams.AntiAlias; - } - } - } - } - if (configList) - { - glxFBConfig=configList[0]; - XFree(configList); - UseGLXWindow=true; -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - typedef XVisualInfo * ( * PFNGLXGETVISUALFROMFBCONFIGPROC) (Display *dpy, GLXFBConfig config); - PFNGLXGETVISUALFROMFBCONFIGPROC glxGetVisualFromFBConfig= (PFNGLXGETVISUALFROMFBCONFIGPROC)glXGetProcAddress(reinterpret_cast<const GLubyte*>("glXGetVisualFromFBConfig")); - if (glxGetVisualFromFBConfig) - visual = glxGetVisualFromFBConfig(display,glxFBConfig); -#else - visual = glXGetVisualFromFBConfig(display,glxFBConfig); -#endif - } - } - else -#endif - { - // attribute array for the draw buffer - int visualAttrBuffer[] = - { - GLX_RGBA, GL_TRUE, - GLX_RED_SIZE, 4, - GLX_GREEN_SIZE, 4, - GLX_BLUE_SIZE, 4, - GLX_ALPHA_SIZE, CreationParams.WithAlphaChannel?1:0, - GLX_DEPTH_SIZE, CreationParams.ZBufferBits, - GLX_STENCIL_SIZE, CreationParams.Stencilbuffer?1:0, // 12,13 - // The following attributes have no flags, but are - // either present or not. As a no-op we use - // GLX_USE_GL, which is silently ignored by glXChooseVisual - CreationParams.Doublebuffer?GLX_DOUBLEBUFFER:GLX_USE_GL, // 14 - CreationParams.Stereobuffer?GLX_STEREO:GLX_USE_GL, // 15 - None - }; - - visual=glXChooseVisual(display, screennr, visualAttrBuffer); - if (!visual) - { - if (CreationParams.Stencilbuffer) - os::Printer::log("No stencilbuffer available, disabling.", ELL_WARNING); - CreationParams.Stencilbuffer = !CreationParams.Stencilbuffer; - visualAttrBuffer[13]=CreationParams.Stencilbuffer?1:0; - - visual=glXChooseVisual(display, screennr, visualAttrBuffer); - if (!visual && CreationParams.Doublebuffer) - { - os::Printer::log("No doublebuffering available.", ELL_WARNING); - CreationParams.Doublebuffer=false; - visualAttrBuffer[14] = GLX_USE_GL; - visual=glXChooseVisual(display, screennr, visualAttrBuffer); - } - } - } - } - else - os::Printer::log("No GLX support available. OpenGL driver will not work.", ELL_WARNING); - } - // don't use the XVisual with OpenGL, because it ignores all requested - // properties of the CreationParams - else if (!visual) -#endif // _IRR_COMPILE_WITH_OPENGL_ - - // create visual with standard X methods - { - os::Printer::log("Using plain X visual"); - XVisualInfo visTempl; //Template to hold requested values - int visNumber; // Return value of available visuals - - visTempl.screen = screennr; - // ARGB visuals should be avoided for usual applications - visTempl.depth = CreationParams.WithAlphaChannel?32:24; - while ((!visual) && (visTempl.depth>=16)) - { - visual = XGetVisualInfo(display, VisualScreenMask|VisualDepthMask, - &visTempl, &visNumber); - visTempl.depth -= 8; - } - } - - if (!visual) - { - os::Printer::log("Fatal error, could not get visual.", ELL_ERROR); - XCloseDisplay(display); - display=0; - return false; - } -#ifdef _DEBUG - else - os::Printer::log("Visual chosen: ", core::stringc(static_cast<u32>(visual->visualid)).c_str(), ELL_INFORMATION); -#endif - - // create color map - Colormap colormap; - colormap = XCreateColormap(display, - RootWindow(display, visual->screen), - visual->visual, AllocNone); - - attributes.colormap = colormap; - attributes.border_pixel = 0; - attributes.event_mask = StructureNotifyMask | FocusChangeMask; - if (!CreationParams.IgnoreInput) - attributes.event_mask |= PointerMotionMask | - ButtonPressMask | KeyPressMask | - ButtonReleaseMask | KeyReleaseMask; - - if (!CreationParams.WindowId) - { - // create Window, either for Fullscreen or windowed mode - if (CreationParams.Fullscreen) - { - attributes.override_redirect = True; - - window = XCreateWindow(display, - RootWindow(display, visual->screen), - 0, 0, Width, Height, 0, visual->depth, - InputOutput, visual->visual, - CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect, - &attributes); - CreationParams.WindowId = (void*)window; - - XWarpPointer(display, None, window, 0, 0, 0, 0, 0, 0); - XMapRaised(display, window); - XGrabKeyboard(display, window, True, GrabModeAsync, - GrabModeAsync, CurrentTime); - XGrabPointer(display, window, True, ButtonPressMask, - GrabModeAsync, GrabModeAsync, window, None, CurrentTime); - } - else - { // we want windowed mode - attributes.event_mask |= ExposureMask; - attributes.event_mask |= FocusChangeMask; - - window = XCreateWindow(display, - RootWindow(display, visual->screen), - 0, 0, Width, Height, 0, visual->depth, - InputOutput, visual->visual, - CWBorderPixel | CWColormap | CWEventMask, - &attributes); - - CreationParams.WindowId = (void*)window; - - Atom wmDelete; - wmDelete = XInternAtom(display, wmDeleteWindow, True); - XSetWMProtocols(display, window, &wmDelete, 1); - XMapRaised(display, window); - } - } - else - { - // attach external window - window = (Window)CreationParams.WindowId; - if (!CreationParams.IgnoreInput) - { - XCreateWindow(display, - window, - 0, 0, Width, Height, 0, visual->depth, - InputOutput, visual->visual, - CWBorderPixel | CWColormap | CWEventMask, - &attributes); - } - XWindowAttributes wa; - XGetWindowAttributes(display, window, &wa); - CreationParams.WindowSize.Width = wa.width; - CreationParams.WindowSize.Height = wa.height; - CreationParams.Fullscreen = false; - ExternalWindow = true; - } - - WindowMinimized=false; - // Currently broken in X, see Bug ID 2795321 - // XkbSetDetectableAutoRepeat(display, True, &AutorepeatSupport); - -#ifdef _IRR_COMPILE_WITH_OPENGL_ - - // connect glx context to window - Context=0; - if (isAvailableGLX && CreationParams.DriverType==video::EDT_OPENGL) - { - if (UseGLXWindow) - { - glxWin=glXCreateWindow(display,glxFBConfig,window,NULL); - if (glxWin) - { - // create glx context - Context = glXCreateNewContext(display, glxFBConfig, GLX_RGBA_TYPE, NULL, True); - if (Context) - { - if (!glXMakeContextCurrent(display, glxWin, glxWin, Context)) - { - os::Printer::log("Could not make context current.", ELL_WARNING); - glXDestroyContext(display, Context); - } - } - else - { - os::Printer::log("Could not create GLX rendering context.", ELL_WARNING); - } - } - else - { - os::Printer::log("Could not create GLX window.", ELL_WARNING); - } - } - else - { - Context = glXCreateContext(display, visual, NULL, True); - if (Context) - { - if (!glXMakeCurrent(display, window, Context)) - { - os::Printer::log("Could not make context current.", ELL_WARNING); - glXDestroyContext(display, Context); - } - } - else - { - os::Printer::log("Could not create GLX rendering context.", ELL_WARNING); - } - } - } -#endif // _IRR_COMPILE_WITH_OPENGL_ - - Window tmp; - u32 borderWidth; - int x,y; - unsigned int bits; - - XGetGeometry(display, window, &tmp, &x, &y, &Width, &Height, &borderWidth, &bits); - CreationParams.Bits = bits; - StdHints = XAllocSizeHints(); - long num; - XGetWMNormalHints(display, window, StdHints, &num); - - // create an XImage for the software renderer - //(thx to Nadav for some clues on how to do that!) - - if (CreationParams.DriverType == video::EDT_SOFTWARE || CreationParams.DriverType == video::EDT_BURNINGSVIDEO) - { - SoftwareImage = XCreateImage(display, - visual->visual, visual->depth, - ZPixmap, 0, 0, Width, Height, - BitmapPad(display), 0); - - // use malloc because X will free it later on - if (SoftwareImage) - SoftwareImage->data = (char*) malloc(SoftwareImage->bytes_per_line * SoftwareImage->height * sizeof(char)); - } - - initXAtoms(); - -#endif // #ifdef _IRR_COMPILE_WITH_X11_ - return true; -} - - -//! create the driver -void CIrrDeviceLinux::createDriver() -{ - switch(CreationParams.DriverType) - { -#ifdef _IRR_COMPILE_WITH_X11_ - - case video::EDT_SOFTWARE: - #ifdef _IRR_COMPILE_WITH_SOFTWARE_ - VideoDriver = video::createSoftwareDriver(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this); - #else - os::Printer::log("No Software driver support compiled in.", ELL_ERROR); - #endif - break; - - case video::EDT_BURNINGSVIDEO: - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - VideoDriver = video::createSoftwareDriver2(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this); - #else - os::Printer::log("Burning's video driver was not compiled in.", ELL_ERROR); - #endif - break; - - case video::EDT_OPENGL: - #ifdef _IRR_COMPILE_WITH_OPENGL_ - if (Context) - VideoDriver = video::createOpenGLDriver(CreationParams, FileSystem, this); - #else - os::Printer::log("No OpenGL support compiled in.", ELL_ERROR); - #endif - break; - - case video::EDT_DIRECT3D8: - case video::EDT_DIRECT3D9: - os::Printer::log("This driver is not available in Linux. Try OpenGL or Software renderer.", - ELL_ERROR); - break; - - case video::EDT_NULL: - VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize); - break; - - default: - os::Printer::log("Unable to create video driver of unknown type.", ELL_ERROR); - break; -#else - case video::EDT_NULL: - VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize); - break; - default: - os::Printer::log("No X11 support compiled in. Only Null driver available.", ELL_ERROR); - break; -#endif - } -} - - -//! runs the device. Returns false if device wants to be deleted -bool CIrrDeviceLinux::run() -{ - os::Timer::tick(); - -#ifdef _IRR_COMPILE_WITH_X11_ - if ((CreationParams.DriverType != video::EDT_NULL) && display) - { - SEvent irrevent; - irrevent.MouseInput.ButtonStates = 0xffffffff; - - while (XPending(display) > 0 && !Close) - { - XEvent event; - XNextEvent(display, &event); - - switch (event.type) - { - case ConfigureNotify: - // check for changed window size - if ((event.xconfigure.width != (int) Width) || - (event.xconfigure.height != (int) Height)) - { - Width = event.xconfigure.width; - Height = event.xconfigure.height; - - // resize image data - if (SoftwareImage) - { - XDestroyImage(SoftwareImage); - - SoftwareImage = XCreateImage(display, - visual->visual, visual->depth, - ZPixmap, 0, 0, Width, Height, - BitmapPad(display), 0); - - // use malloc because X will free it later on - if (SoftwareImage) - SoftwareImage->data = (char*) malloc(SoftwareImage->bytes_per_line * SoftwareImage->height * sizeof(char)); - } - - if (VideoDriver) - VideoDriver->OnResize(core::dimension2d<u32>(Width, Height)); - } - break; - - case MapNotify: - WindowMinimized=false; - break; - - case UnmapNotify: - WindowMinimized=true; - break; - - case FocusIn: - WindowHasFocus=true; - break; - - case FocusOut: - WindowHasFocus=false; - break; - - case MotionNotify: - irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT; - irrevent.MouseInput.Event = irr::EMIE_MOUSE_MOVED; - irrevent.MouseInput.X = event.xbutton.x; - irrevent.MouseInput.Y = event.xbutton.y; - irrevent.MouseInput.Control = (event.xkey.state & ControlMask) != 0; - irrevent.MouseInput.Shift = (event.xkey.state & ShiftMask) != 0; - - // mouse button states - irrevent.MouseInput.ButtonStates = (event.xbutton.state & Button1Mask) ? irr::EMBSM_LEFT : 0; - irrevent.MouseInput.ButtonStates |= (event.xbutton.state & Button3Mask) ? irr::EMBSM_RIGHT : 0; - irrevent.MouseInput.ButtonStates |= (event.xbutton.state & Button2Mask) ? irr::EMBSM_MIDDLE : 0; - - postEventFromUser(irrevent); - break; - - case ButtonPress: - case ButtonRelease: - - irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT; - irrevent.MouseInput.X = event.xbutton.x; - irrevent.MouseInput.Y = event.xbutton.y; - irrevent.MouseInput.Control = (event.xkey.state & ControlMask) != 0; - irrevent.MouseInput.Shift = (event.xkey.state & ShiftMask) != 0; - - // mouse button states - // This sets the state which the buttons had _prior_ to the event. - // So unlike on Windows the button which just got changed has still the old state here. - // We handle that below by flipping the corresponding bit later. - irrevent.MouseInput.ButtonStates = (event.xbutton.state & Button1Mask) ? irr::EMBSM_LEFT : 0; - irrevent.MouseInput.ButtonStates |= (event.xbutton.state & Button3Mask) ? irr::EMBSM_RIGHT : 0; - irrevent.MouseInput.ButtonStates |= (event.xbutton.state & Button2Mask) ? irr::EMBSM_MIDDLE : 0; - - irrevent.MouseInput.Event = irr::EMIE_COUNT; - - switch(event.xbutton.button) - { - case Button1: - irrevent.MouseInput.Event = - (event.type == ButtonPress) ? irr::EMIE_LMOUSE_PRESSED_DOWN : irr::EMIE_LMOUSE_LEFT_UP; - irrevent.MouseInput.ButtonStates ^= irr::EMBSM_LEFT; - break; - - case Button3: - irrevent.MouseInput.Event = - (event.type == ButtonPress) ? irr::EMIE_RMOUSE_PRESSED_DOWN : irr::EMIE_RMOUSE_LEFT_UP; - irrevent.MouseInput.ButtonStates ^= irr::EMBSM_RIGHT; - break; - - case Button2: - irrevent.MouseInput.Event = - (event.type == ButtonPress) ? irr::EMIE_MMOUSE_PRESSED_DOWN : irr::EMIE_MMOUSE_LEFT_UP; - irrevent.MouseInput.ButtonStates ^= irr::EMBSM_MIDDLE; - break; - - case Button4: - irrevent.MouseInput.Event = EMIE_MOUSE_WHEEL; - irrevent.MouseInput.Wheel = 1.0f; - break; - - case Button5: - irrevent.MouseInput.Event = EMIE_MOUSE_WHEEL; - irrevent.MouseInput.Wheel = -1.0f; - break; - } - - if (irrevent.MouseInput.Event != irr::EMIE_COUNT) - { - postEventFromUser(irrevent); - - if ( irrevent.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN ) - { - u32 clicks = checkSuccessiveClicks(irrevent.MouseInput.X, irrevent.MouseInput.Y); - if ( clicks == 2 ) - { - irrevent.MouseInput.Event = EMIE_MOUSE_DOUBLE_CLICK; - postEventFromUser(irrevent); - } - else if ( clicks == 3 ) - { - irrevent.MouseInput.Event = EMIE_MOUSE_TRIPLE_CLICK; - postEventFromUser(irrevent); - } - } - } - break; - - case MappingNotify: - XRefreshKeyboardMapping (&event.xmapping) ; - break; - - case KeyRelease: - if (0 == AutorepeatSupport && (XPending( display ) > 0) ) - { - // check for Autorepeat manually - // We'll do the same as Windows does: Only send KeyPressed - // So every KeyRelease is a real release - XEvent next_event; - XPeekEvent (event.xkey.display, &next_event); - if ((next_event.type == KeyPress) && - (next_event.xkey.keycode == event.xkey.keycode) && - (next_event.xkey.time - event.xkey.time) < 2) // usually same time, but on some systems a difference of 1 is possible - { - /* Ignore the key release event */ - break; - } - } - // fall-through in case the release should be handled - case KeyPress: - { - SKeyMap mp; - char buf[8]={0}; - XLookupString(&event.xkey, buf, sizeof(buf), &mp.X11Key, NULL); - - const s32 idx = KeyMap.binary_search(mp); - - if (idx != -1) - irrevent.KeyInput.Key = (EKEY_CODE)KeyMap[idx].Win32Key; - else - { - irrevent.KeyInput.Key = (EKEY_CODE)0; - os::Printer::log("Could not find win32 key for x11 key.", ELL_WARNING); - } - irrevent.EventType = irr::EET_KEY_INPUT_EVENT; - irrevent.KeyInput.PressedDown = (event.type == KeyPress); -// mbtowc(&irrevent.KeyInput.Char, buf, sizeof(buf)); - irrevent.KeyInput.Char = ((wchar_t*)(buf))[0]; - irrevent.KeyInput.Control = (event.xkey.state & ControlMask) != 0; - irrevent.KeyInput.Shift = (event.xkey.state & ShiftMask) != 0; - postEventFromUser(irrevent); - } - break; - - case ClientMessage: - { - char *atom = XGetAtomName(display, event.xclient.message_type); - if (*atom == *wmDeleteWindow) - { - os::Printer::log("Quit message received.", ELL_INFORMATION); - Close = true; - } - else - { - // we assume it's a user message - irrevent.EventType = irr::EET_USER_EVENT; - irrevent.UserEvent.UserData1 = (s32)event.xclient.data.l[0]; - irrevent.UserEvent.UserData2 = (s32)event.xclient.data.l[1]; - postEventFromUser(irrevent); - } - XFree(atom); - } - break; - - case SelectionRequest: - { - XEvent respond; - XSelectionRequestEvent *req = &(event.xselectionrequest); - if ( req->target == XA_STRING) - { - XChangeProperty (display, - req->requestor, - req->property, req->target, - 8, // format - PropModeReplace, - (unsigned char*) Clipboard.c_str(), - Clipboard.size()); - respond.xselection.property = req->property; - } - else if ( req->target == X_ATOM_TARGETS ) - { - long data[2]; - - data[0] = X_ATOM_TEXT; - data[1] = XA_STRING; - - XChangeProperty (display, req->requestor, - req->property, req->target, - 8, PropModeReplace, - (unsigned char *) &data, - sizeof (data)); - respond.xselection.property = req->property; - } - else - { - respond.xselection.property= None; - } - respond.xselection.type= SelectionNotify; - respond.xselection.display= req->display; - respond.xselection.requestor= req->requestor; - respond.xselection.selection=req->selection; - respond.xselection.target= req->target; - respond.xselection.time = req->time; - XSendEvent (display, req->requestor,0,0,&respond); - XFlush (display); - } - break; - - default: - break; - } // end switch - - } // end while - } -#endif //_IRR_COMPILE_WITH_X11_ - - if(!Close) - pollJoysticks(); - - return !Close; -} - - -//! Pause the current process for the minimum time allowed only to allow other processes to execute -void CIrrDeviceLinux::yield() -{ - struct timespec ts = {0,0}; - nanosleep(&ts, NULL); -} - - -//! Pause execution and let other processes to run for a specified amount of time. -void CIrrDeviceLinux::sleep(u32 timeMs, bool pauseTimer=false) -{ - const bool wasStopped = Timer ? Timer->isStopped() : true; - - struct timespec ts; - ts.tv_sec = (time_t) (timeMs / 1000); - ts.tv_nsec = (long) (timeMs % 1000) * 1000000; - - if (pauseTimer && !wasStopped) - Timer->stop(); - - nanosleep(&ts, NULL); - - if (pauseTimer && !wasStopped) - Timer->start(); -} - - -//! sets the caption of the window -void CIrrDeviceLinux::setWindowCaption(const wchar_t* text) -{ -#ifdef _IRR_COMPILE_WITH_X11_ - if (CreationParams.DriverType == video::EDT_NULL) - return; - - XTextProperty txt; - XwcTextListToTextProperty(display, const_cast<wchar_t**>(&text), 1, XStdICCTextStyle, &txt); - XSetWMName(display, window, &txt); - XSetWMIconName(display, window, &txt); - XFree(txt.value); -#endif -} - - -//! presents a surface in the client area -bool CIrrDeviceLinux::present(video::IImage* image, void* windowId, core::rect<s32>* srcRect) -{ -#ifdef _IRR_COMPILE_WITH_X11_ - // this is only necessary for software drivers. - if (!SoftwareImage) - return true; - - // thx to Nadav, who send me some clues of how to display the image - // to the X Server. - - const u32 destwidth = SoftwareImage->width; - const u32 minWidth = core::min_(image->getDimension().Width, destwidth); - const u32 destPitch = SoftwareImage->bytes_per_line; - - video::ECOLOR_FORMAT destColor; - switch (SoftwareImage->bits_per_pixel) - { - case 16: - if (SoftwareImage->depth==16) - destColor = video::ECF_R5G6B5; - else - destColor = video::ECF_A1R5G5B5; - break; - case 24: destColor = video::ECF_R8G8B8; break; - case 32: destColor = video::ECF_A8R8G8B8; break; - default: - os::Printer::log("Unsupported screen depth."); - return false; - } - - u8* srcdata = reinterpret_cast<u8*>(image->lock()); - u8* destData = reinterpret_cast<u8*>(SoftwareImage->data); - - const u32 destheight = SoftwareImage->height; - const u32 srcheight = core::min_(image->getDimension().Height, destheight); - const u32 srcPitch = image->getPitch(); - for (u32 y=0; y!=srcheight; ++y) - { - video::CColorConverter::convert_viaFormat(srcdata,image->getColorFormat(), minWidth, destData, destColor); - srcdata+=srcPitch; - destData+=destPitch; - } - image->unlock(); - - GC gc = DefaultGC(display, DefaultScreen(display)); - Window myWindow=window; - if (windowId) - myWindow = reinterpret_cast<Window>(windowId); - XPutImage(display, myWindow, gc, SoftwareImage, 0, 0, 0, 0, destwidth, destheight); -#endif - return true; -} - - -//! notifies the device that it should close itself -void CIrrDeviceLinux::closeDevice() -{ - Close = true; -} - - -//! returns if window is active. if not, nothing need to be drawn -bool CIrrDeviceLinux::isWindowActive() const -{ - return (WindowHasFocus && !WindowMinimized); -} - - -//! returns if window has focus. -bool CIrrDeviceLinux::isWindowFocused() const -{ - return WindowHasFocus; -} - - -//! returns if window is minimized. -bool CIrrDeviceLinux::isWindowMinimized() const -{ - return WindowMinimized; -} - - -//! returns color format of the window. -video::ECOLOR_FORMAT CIrrDeviceLinux::getColorFormat() const -{ -#ifdef _IRR_COMPILE_WITH_X11_ - if (visual && (visual->depth != 16)) - return video::ECF_R8G8B8; - else -#endif - return video::ECF_R5G6B5; -} - - -//! Sets if the window should be resizable in windowed mode. -void CIrrDeviceLinux::setResizable(bool resize) -{ -#ifdef _IRR_COMPILE_WITH_X11_ - if (CreationParams.DriverType == video::EDT_NULL) - return; - - XUnmapWindow(display, window); - if ( !resize ) - { - // Must be heap memory because data size depends on X Server - XSizeHints *hints = XAllocSizeHints(); - hints->flags=PSize|PMinSize|PMaxSize; - hints->min_width=hints->max_width=hints->base_width=Width; - hints->min_height=hints->max_height=hints->base_height=Height; - XSetWMNormalHints(display, window, hints); - XFree(hints); - } - else - { - XSetWMNormalHints(display, window, StdHints); - } - XMapWindow(display, window); - XFlush(display); -#endif // #ifdef _IRR_COMPILE_WITH_X11_ -} - - -//! Return pointer to a list with all video modes supported by the gfx adapter. -video::IVideoModeList* CIrrDeviceLinux::getVideoModeList() -{ -#ifdef _IRR_COMPILE_WITH_X11_ - if (!VideoModeList.getVideoModeCount()) - { - bool temporaryDisplay = false; - - if (!display) - { - display = XOpenDisplay(0); - temporaryDisplay=true; - } - if (display) - { - #if defined(_IRR_LINUX_X11_VIDMODE_) || defined(_IRR_LINUX_X11_RANDR_) - s32 eventbase, errorbase; - s32 defaultDepth=DefaultDepth(display,screennr); - #endif - - #ifdef _IRR_LINUX_X11_VIDMODE_ - if (XF86VidModeQueryExtension(display, &eventbase, &errorbase)) - { - // enumerate video modes - int modeCount; - XF86VidModeModeInfo** modes; - - XF86VidModeGetAllModeLines(display, screennr, &modeCount, &modes); - - // save current video mode - oldVideoMode = *modes[0]; - - // find fitting mode - - VideoModeList.setDesktop(defaultDepth, core::dimension2d<u32>( - modes[0]->hdisplay, modes[0]->vdisplay)); - for (int i = 0; i<modeCount; ++i) - { - VideoModeList.addMode(core::dimension2d<u32>( - modes[i]->hdisplay, modes[i]->vdisplay), defaultDepth); - } - XFree(modes); - } - else - #endif - #ifdef _IRR_LINUX_X11_RANDR_ - if (XRRQueryExtension(display, &eventbase, &errorbase)) - { - int modeCount; - XRRScreenConfiguration *config=XRRGetScreenInfo(display,DefaultRootWindow(display)); - oldRandrMode=XRRConfigCurrentConfiguration(config,&oldRandrRotation); - XRRScreenSize *modes=XRRConfigSizes(config,&modeCount); - VideoModeList.setDesktop(defaultDepth, core::dimension2d<u32>( - modes[oldRandrMode].width, modes[oldRandrMode].height)); - for (int i = 0; i<modeCount; ++i) - { - VideoModeList.addMode(core::dimension2d<u32>( - modes[i].width, modes[i].height), defaultDepth); - } - XRRFreeScreenConfigInfo(config); - } - else - #endif - { - os::Printer::log("VidMode or RandR X11 extension requireed for VideoModeList." , ELL_WARNING); - } - } - if (display && temporaryDisplay) - { - XCloseDisplay(display); - display=0; - } - } -#endif - - return &VideoModeList; -} - - -//! Minimize window -void CIrrDeviceLinux::minimizeWindow() -{ -#ifdef _IRR_COMPILE_WITH_X11_ - XIconifyWindow(display, window, screennr); -#endif -} - - -//! Maximize window -void CIrrDeviceLinux::maximizeWindow() -{ -#ifdef _IRR_COMPILE_WITH_X11_ - XMapWindow(display, window); -#endif -} - - -//! Restore original window size -void CIrrDeviceLinux::restoreWindow() -{ -#ifdef _IRR_COMPILE_WITH_X11_ - XMapWindow(display, window); -#endif -} - - -void CIrrDeviceLinux::createKeyMap() -{ - // I don't know if this is the best method to create - // the lookuptable, but I'll leave it like that until - // I find a better version. - -#ifdef _IRR_COMPILE_WITH_X11_ - KeyMap.reallocate(84); - KeyMap.push_back(SKeyMap(XK_BackSpace, KEY_BACK)); - KeyMap.push_back(SKeyMap(XK_Tab, KEY_TAB)); - KeyMap.push_back(SKeyMap(XK_Linefeed, 0)); // ??? - KeyMap.push_back(SKeyMap(XK_Clear, KEY_CLEAR)); - KeyMap.push_back(SKeyMap(XK_Return, KEY_RETURN)); - KeyMap.push_back(SKeyMap(XK_Pause, KEY_PAUSE)); - KeyMap.push_back(SKeyMap(XK_Scroll_Lock, KEY_SCROLL)); - KeyMap.push_back(SKeyMap(XK_Sys_Req, 0)); // ??? - KeyMap.push_back(SKeyMap(XK_Escape, KEY_ESCAPE)); - KeyMap.push_back(SKeyMap(XK_Insert, KEY_INSERT)); - KeyMap.push_back(SKeyMap(XK_Delete, KEY_DELETE)); - KeyMap.push_back(SKeyMap(XK_Home, KEY_HOME)); - KeyMap.push_back(SKeyMap(XK_Left, KEY_LEFT)); - KeyMap.push_back(SKeyMap(XK_Up, KEY_UP)); - KeyMap.push_back(SKeyMap(XK_Right, KEY_RIGHT)); - KeyMap.push_back(SKeyMap(XK_Down, KEY_DOWN)); - KeyMap.push_back(SKeyMap(XK_Prior, KEY_PRIOR)); - KeyMap.push_back(SKeyMap(XK_Page_Up, KEY_PRIOR)); - KeyMap.push_back(SKeyMap(XK_Next, KEY_NEXT)); - KeyMap.push_back(SKeyMap(XK_Page_Down, KEY_NEXT)); - KeyMap.push_back(SKeyMap(XK_End, KEY_END)); - KeyMap.push_back(SKeyMap(XK_Begin, KEY_HOME)); - KeyMap.push_back(SKeyMap(XK_KP_Space, KEY_SPACE)); - KeyMap.push_back(SKeyMap(XK_KP_Tab, KEY_TAB)); - KeyMap.push_back(SKeyMap(XK_KP_Enter, KEY_RETURN)); - KeyMap.push_back(SKeyMap(XK_KP_F1, KEY_F1)); - KeyMap.push_back(SKeyMap(XK_KP_F2, KEY_F2)); - KeyMap.push_back(SKeyMap(XK_KP_F3, KEY_F3)); - KeyMap.push_back(SKeyMap(XK_KP_F4, KEY_F4)); - KeyMap.push_back(SKeyMap(XK_KP_Left, KEY_LEFT)); - KeyMap.push_back(SKeyMap(XK_KP_Up, KEY_UP)); - KeyMap.push_back(SKeyMap(XK_KP_Right, KEY_RIGHT)); - KeyMap.push_back(SKeyMap(XK_KP_Down, KEY_DOWN)); - KeyMap.push_back(SKeyMap(XK_KP_Prior, KEY_PRIOR)); - KeyMap.push_back(SKeyMap(XK_KP_Page_Up, KEY_PRIOR)); - KeyMap.push_back(SKeyMap(XK_KP_Next, KEY_NEXT)); - KeyMap.push_back(SKeyMap(XK_KP_Page_Down, KEY_NEXT)); - KeyMap.push_back(SKeyMap(XK_KP_End, KEY_END)); - KeyMap.push_back(SKeyMap(XK_KP_Begin, KEY_HOME)); - KeyMap.push_back(SKeyMap(XK_KP_Insert, KEY_INSERT)); - KeyMap.push_back(SKeyMap(XK_KP_Delete, KEY_DELETE)); - KeyMap.push_back(SKeyMap(XK_KP_Equal, 0)); // ??? - KeyMap.push_back(SKeyMap(XK_KP_Multiply, KEY_MULTIPLY)); - KeyMap.push_back(SKeyMap(XK_KP_Add, KEY_ADD)); - KeyMap.push_back(SKeyMap(XK_KP_Separator, KEY_SEPARATOR)); - KeyMap.push_back(SKeyMap(XK_KP_Subtract, KEY_SUBTRACT)); - KeyMap.push_back(SKeyMap(XK_KP_Decimal, KEY_DECIMAL)); - KeyMap.push_back(SKeyMap(XK_KP_Divide, KEY_DIVIDE)); - KeyMap.push_back(SKeyMap(XK_KP_0, KEY_KEY_0)); - KeyMap.push_back(SKeyMap(XK_KP_1, KEY_KEY_1)); - KeyMap.push_back(SKeyMap(XK_KP_2, KEY_KEY_2)); - KeyMap.push_back(SKeyMap(XK_KP_3, KEY_KEY_3)); - KeyMap.push_back(SKeyMap(XK_KP_4, KEY_KEY_4)); - KeyMap.push_back(SKeyMap(XK_KP_5, KEY_KEY_5)); - KeyMap.push_back(SKeyMap(XK_KP_6, KEY_KEY_6)); - KeyMap.push_back(SKeyMap(XK_KP_7, KEY_KEY_7)); - KeyMap.push_back(SKeyMap(XK_KP_8, KEY_KEY_8)); - KeyMap.push_back(SKeyMap(XK_KP_9, KEY_KEY_9)); - KeyMap.push_back(SKeyMap(XK_F1, KEY_F1)); - KeyMap.push_back(SKeyMap(XK_F2, KEY_F2)); - KeyMap.push_back(SKeyMap(XK_F3, KEY_F3)); - KeyMap.push_back(SKeyMap(XK_F4, KEY_F4)); - KeyMap.push_back(SKeyMap(XK_F5, KEY_F5)); - KeyMap.push_back(SKeyMap(XK_F6, KEY_F6)); - KeyMap.push_back(SKeyMap(XK_F7, KEY_F7)); - KeyMap.push_back(SKeyMap(XK_F8, KEY_F8)); - KeyMap.push_back(SKeyMap(XK_F9, KEY_F9)); - KeyMap.push_back(SKeyMap(XK_F10, KEY_F10)); - KeyMap.push_back(SKeyMap(XK_F11, KEY_F11)); - KeyMap.push_back(SKeyMap(XK_F12, KEY_F12)); - KeyMap.push_back(SKeyMap(XK_Shift_L, KEY_LSHIFT)); - KeyMap.push_back(SKeyMap(XK_Shift_R, KEY_RSHIFT)); - KeyMap.push_back(SKeyMap(XK_Control_L, KEY_LCONTROL)); - KeyMap.push_back(SKeyMap(XK_Control_R, KEY_RCONTROL)); - KeyMap.push_back(SKeyMap(XK_Caps_Lock, KEY_CAPITAL)); - KeyMap.push_back(SKeyMap(XK_Shift_Lock, KEY_CAPITAL)); - KeyMap.push_back(SKeyMap(XK_Meta_L, KEY_LWIN)); - KeyMap.push_back(SKeyMap(XK_Meta_R, KEY_RWIN)); - KeyMap.push_back(SKeyMap(XK_Alt_L, KEY_LMENU)); - KeyMap.push_back(SKeyMap(XK_Alt_R, KEY_RMENU)); - KeyMap.push_back(SKeyMap(XK_ISO_Level3_Shift, KEY_RMENU)); - KeyMap.push_back(SKeyMap(XK_Menu, KEY_MENU)); - KeyMap.push_back(SKeyMap(XK_space, KEY_SPACE)); - KeyMap.push_back(SKeyMap(XK_exclam, 0)); //? - KeyMap.push_back(SKeyMap(XK_quotedbl, 0)); //? - KeyMap.push_back(SKeyMap(XK_section, 0)); //? - KeyMap.push_back(SKeyMap(XK_numbersign, 0)); //? - KeyMap.push_back(SKeyMap(XK_dollar, 0)); //? - KeyMap.push_back(SKeyMap(XK_percent, 0)); //? - KeyMap.push_back(SKeyMap(XK_ampersand, 0)); //? - KeyMap.push_back(SKeyMap(XK_apostrophe, 0)); //? - KeyMap.push_back(SKeyMap(XK_parenleft, 0)); //? - KeyMap.push_back(SKeyMap(XK_parenright, 0)); //? - KeyMap.push_back(SKeyMap(XK_asterisk, 0)); //? - KeyMap.push_back(SKeyMap(XK_plus, KEY_PLUS)); //? - KeyMap.push_back(SKeyMap(XK_comma, KEY_COMMA)); //? - KeyMap.push_back(SKeyMap(XK_minus, KEY_MINUS)); //? - KeyMap.push_back(SKeyMap(XK_period, KEY_PERIOD)); //? - KeyMap.push_back(SKeyMap(XK_slash, 0)); //? - KeyMap.push_back(SKeyMap(XK_0, KEY_KEY_0)); - KeyMap.push_back(SKeyMap(XK_1, KEY_KEY_1)); - KeyMap.push_back(SKeyMap(XK_2, KEY_KEY_2)); - KeyMap.push_back(SKeyMap(XK_3, KEY_KEY_3)); - KeyMap.push_back(SKeyMap(XK_4, KEY_KEY_4)); - KeyMap.push_back(SKeyMap(XK_5, KEY_KEY_5)); - KeyMap.push_back(SKeyMap(XK_6, KEY_KEY_6)); - KeyMap.push_back(SKeyMap(XK_7, KEY_KEY_7)); - KeyMap.push_back(SKeyMap(XK_8, KEY_KEY_8)); - KeyMap.push_back(SKeyMap(XK_9, KEY_KEY_9)); - KeyMap.push_back(SKeyMap(XK_colon, 0)); //? - KeyMap.push_back(SKeyMap(XK_semicolon, 0)); //? - KeyMap.push_back(SKeyMap(XK_less, 0)); //? - KeyMap.push_back(SKeyMap(XK_equal, 0)); //? - KeyMap.push_back(SKeyMap(XK_greater, 0)); //? - KeyMap.push_back(SKeyMap(XK_question, 0)); //? - KeyMap.push_back(SKeyMap(XK_at, 0)); //? - KeyMap.push_back(SKeyMap(XK_mu, 0)); //? - KeyMap.push_back(SKeyMap(XK_EuroSign, 0)); //? - KeyMap.push_back(SKeyMap(XK_A, KEY_KEY_A)); - KeyMap.push_back(SKeyMap(XK_B, KEY_KEY_B)); - KeyMap.push_back(SKeyMap(XK_C, KEY_KEY_C)); - KeyMap.push_back(SKeyMap(XK_D, KEY_KEY_D)); - KeyMap.push_back(SKeyMap(XK_E, KEY_KEY_E)); - KeyMap.push_back(SKeyMap(XK_F, KEY_KEY_F)); - KeyMap.push_back(SKeyMap(XK_G, KEY_KEY_G)); - KeyMap.push_back(SKeyMap(XK_H, KEY_KEY_H)); - KeyMap.push_back(SKeyMap(XK_I, KEY_KEY_I)); - KeyMap.push_back(SKeyMap(XK_J, KEY_KEY_J)); - KeyMap.push_back(SKeyMap(XK_K, KEY_KEY_K)); - KeyMap.push_back(SKeyMap(XK_L, KEY_KEY_L)); - KeyMap.push_back(SKeyMap(XK_M, KEY_KEY_M)); - KeyMap.push_back(SKeyMap(XK_N, KEY_KEY_N)); - KeyMap.push_back(SKeyMap(XK_O, KEY_KEY_O)); - KeyMap.push_back(SKeyMap(XK_P, KEY_KEY_P)); - KeyMap.push_back(SKeyMap(XK_Q, KEY_KEY_Q)); - KeyMap.push_back(SKeyMap(XK_R, KEY_KEY_R)); - KeyMap.push_back(SKeyMap(XK_S, KEY_KEY_S)); - KeyMap.push_back(SKeyMap(XK_T, KEY_KEY_T)); - KeyMap.push_back(SKeyMap(XK_U, KEY_KEY_U)); - KeyMap.push_back(SKeyMap(XK_V, KEY_KEY_V)); - KeyMap.push_back(SKeyMap(XK_W, KEY_KEY_W)); - KeyMap.push_back(SKeyMap(XK_X, KEY_KEY_X)); - KeyMap.push_back(SKeyMap(XK_Y, KEY_KEY_Y)); - KeyMap.push_back(SKeyMap(XK_Z, KEY_KEY_Z)); - KeyMap.push_back(SKeyMap(XK_Adiaeresis, 0)); //? - KeyMap.push_back(SKeyMap(XK_Odiaeresis, 0)); //? - KeyMap.push_back(SKeyMap(XK_Udiaeresis, 0)); //? - KeyMap.push_back(SKeyMap(XK_bracketleft, 0)); //? - KeyMap.push_back(SKeyMap(XK_backslash, 0)); //? - KeyMap.push_back(SKeyMap(XK_bracketright, 0)); //? - KeyMap.push_back(SKeyMap(XK_asciicircum, 0)); //? - KeyMap.push_back(SKeyMap(XK_degree, 0)); //? - KeyMap.push_back(SKeyMap(XK_underscore, 0)); //? - KeyMap.push_back(SKeyMap(XK_grave, 0)); //? - KeyMap.push_back(SKeyMap(XK_acute, 0)); //? - KeyMap.push_back(SKeyMap(XK_quoteleft, 0)); //? - KeyMap.push_back(SKeyMap(XK_a, KEY_KEY_A)); - KeyMap.push_back(SKeyMap(XK_b, KEY_KEY_B)); - KeyMap.push_back(SKeyMap(XK_c, KEY_KEY_C)); - KeyMap.push_back(SKeyMap(XK_d, KEY_KEY_D)); - KeyMap.push_back(SKeyMap(XK_e, KEY_KEY_E)); - KeyMap.push_back(SKeyMap(XK_f, KEY_KEY_F)); - KeyMap.push_back(SKeyMap(XK_g, KEY_KEY_G)); - KeyMap.push_back(SKeyMap(XK_h, KEY_KEY_H)); - KeyMap.push_back(SKeyMap(XK_i, KEY_KEY_I)); - KeyMap.push_back(SKeyMap(XK_j, KEY_KEY_J)); - KeyMap.push_back(SKeyMap(XK_k, KEY_KEY_K)); - KeyMap.push_back(SKeyMap(XK_l, KEY_KEY_L)); - KeyMap.push_back(SKeyMap(XK_m, KEY_KEY_M)); - KeyMap.push_back(SKeyMap(XK_n, KEY_KEY_N)); - KeyMap.push_back(SKeyMap(XK_o, KEY_KEY_O)); - KeyMap.push_back(SKeyMap(XK_p, KEY_KEY_P)); - KeyMap.push_back(SKeyMap(XK_q, KEY_KEY_Q)); - KeyMap.push_back(SKeyMap(XK_r, KEY_KEY_R)); - KeyMap.push_back(SKeyMap(XK_s, KEY_KEY_S)); - KeyMap.push_back(SKeyMap(XK_t, KEY_KEY_T)); - KeyMap.push_back(SKeyMap(XK_u, KEY_KEY_U)); - KeyMap.push_back(SKeyMap(XK_v, KEY_KEY_V)); - KeyMap.push_back(SKeyMap(XK_w, KEY_KEY_W)); - KeyMap.push_back(SKeyMap(XK_x, KEY_KEY_X)); - KeyMap.push_back(SKeyMap(XK_y, KEY_KEY_Y)); - KeyMap.push_back(SKeyMap(XK_z, KEY_KEY_Z)); - KeyMap.push_back(SKeyMap(XK_ssharp, 0)); //? - KeyMap.push_back(SKeyMap(XK_adiaeresis, 0)); //? - KeyMap.push_back(SKeyMap(XK_odiaeresis, 0)); //? - KeyMap.push_back(SKeyMap(XK_udiaeresis, 0)); //? - - KeyMap.sort(); -#endif -} - -bool CIrrDeviceLinux::activateJoysticks(core::array<SJoystickInfo> & joystickInfo) -{ -#if defined (_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) - - joystickInfo.clear(); - - u32 joystick; - for(joystick = 0; joystick < 32; ++joystick) - { - // The joystick device could be here... - core::stringc devName = "/dev/js"; - devName += joystick; - - SJoystickInfo returnInfo; - JoystickInfo info; - - info.fd = open(devName.c_str(), O_RDONLY); - if(-1 == info.fd) - { - // ...but Ubuntu and possibly other distros - // create the devices in /dev/input - devName = "/dev/input/js"; - devName += joystick; - info.fd = open(devName.c_str(), O_RDONLY); - } - - if(-1 == info.fd) - continue; - - ioctl( info.fd, JSIOCGAXES, &(info.axes) ); - ioctl( info.fd, JSIOCGBUTTONS, &(info.buttons) ); - - fcntl( info.fd, F_SETFL, O_NONBLOCK ); - - (void)memset(&info.persistentData, 0, sizeof(info.persistentData)); - info.persistentData.EventType = irr::EET_JOYSTICK_INPUT_EVENT; - info.persistentData.JoystickEvent.Joystick = ActiveJoysticks.size(); - - // There's no obvious way to determine which (if any) axes represent a POV - // hat, so we'll just set it to "not used" and forget about it. - info.persistentData.JoystickEvent.POV = 65535; - - ActiveJoysticks.push_back(info); - - returnInfo.Joystick = joystick; - returnInfo.PovHat = SJoystickInfo::POV_HAT_UNKNOWN; - returnInfo.Axes = info.axes; - returnInfo.Buttons = info.buttons; - - char name[80]; - ioctl( info.fd, JSIOCGNAME(80), name); - returnInfo.Name = name; - - joystickInfo.push_back(returnInfo); - } - - for(joystick = 0; joystick < joystickInfo.size(); ++joystick) - { - char logString[256]; - (void)sprintf(logString, "Found joystick %u, %u axes, %u buttons '%s'", - joystick, joystickInfo[joystick].Axes, - joystickInfo[joystick].Buttons, joystickInfo[joystick].Name.c_str()); - os::Printer::log(logString, ELL_INFORMATION); - } - - return true; -#else - return false; -#endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ -} - - -void CIrrDeviceLinux::pollJoysticks() -{ -#if defined (_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) - if(0 == ActiveJoysticks.size()) - return; - - u32 joystick; - for(joystick = 0; joystick < ActiveJoysticks.size(); ++joystick) - { - JoystickInfo & info = ActiveJoysticks[joystick]; - - struct js_event event; - while(sizeof(event) == read(info.fd, &event, sizeof(event))) - { - switch(event.type & ~JS_EVENT_INIT) - { - case JS_EVENT_BUTTON: - if (event.value) - info.persistentData.JoystickEvent.ButtonStates |= (1 << event.number); - else - info.persistentData.JoystickEvent.ButtonStates &= ~(1 << event.number); - break; - - case JS_EVENT_AXIS: - info.persistentData.JoystickEvent.Axis[event.number] = event.value; - break; - - default: - break; - } - } - - // Send an irrlicht joystick event once per ::run() even if no new data were received. - (void)postEventFromUser(info.persistentData); - } -#endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ -} - - -//! Set the current Gamma Value for the Display -bool CIrrDeviceLinux::setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast ) -{ - #if defined(_IRR_LINUX_X11_VIDMODE_) || defined(_IRR_LINUX_X11_RANDR_) - s32 eventbase, errorbase; - #ifdef _IRR_LINUX_X11_VIDMODE_ - if (XF86VidModeQueryExtension(display, &eventbase, &errorbase)) - { - XF86VidModeGamma gamma; - gamma.red=red; - gamma.green=green; - gamma.blue=blue; - XF86VidModeSetGamma(display, screennr, &gamma); - return true; - } - #endif - #if defined(_IRR_LINUX_X11_VIDMODE_) && defined(_IRR_LINUX_X11_RANDR_) - else - #endif - #ifdef _IRR_LINUX_X11_RANDR_ - if (XRRQueryExtension(display, &eventbase, &errorbase)) - { - XRRQueryVersion(display, &eventbase, &errorbase); // major, minor - if (eventbase>=1 && errorbase>1) - { - #if (RANDR_MAJOR>1 || RANDR_MINOR>1) - XRRCrtcGamma *gamma = XRRGetCrtcGamma(display, screennr); - if (gamma) - { - *gamma->red=red; - *gamma->green=green; - *gamma->blue=blue; - XRRSetCrtcGamma(display, screennr, gamma); - XRRFreeGamma(gamma); - return true; - } - #endif - } - } - #endif - #endif - return false; -} - - -//! Get the current Gamma Value for the Display -bool CIrrDeviceLinux::getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast ) -{ - brightness = 0.f; - contrast = 0.f; - #if defined(_IRR_LINUX_X11_VIDMODE_) || defined(_IRR_LINUX_X11_RANDR_) - s32 eventbase, errorbase; - #ifdef _IRR_LINUX_X11_VIDMODE_ - if (XF86VidModeQueryExtension(display, &eventbase, &errorbase)) - { - XF86VidModeGamma gamma; - XF86VidModeGetGamma(display, screennr, &gamma); - red = gamma.red; - green = gamma.green; - blue = gamma.blue; - return true; - } - #endif - #if defined(_IRR_LINUX_X11_VIDMODE_) && defined(_IRR_LINUX_X11_RANDR_) - else - #endif - #ifdef _IRR_LINUX_X11_RANDR_ - if (XRRQueryExtension(display, &eventbase, &errorbase)) - { - XRRQueryVersion(display, &eventbase, &errorbase); // major, minor - if (eventbase>=1 && errorbase>1) - { - #if (RANDR_MAJOR>1 || RANDR_MINOR>1) - XRRCrtcGamma *gamma = XRRGetCrtcGamma(display, screennr); - if (gamma) - { - red = *gamma->red; - green = *gamma->green; - blue= *gamma->blue; - XRRFreeGamma(gamma); - return true; - } - #endif - } - } - #endif - #endif - return false; -} - - -//! gets text from the clipboard -//! \return Returns 0 if no string is in there. -const c8* CIrrDeviceLinux::getTextFromClipboard() const -{ -#if defined(_IRR_COMPILE_WITH_X11_) - Window ownerWindow = XGetSelectionOwner (display, X_ATOM_CLIPBOARD); - if ( ownerWindow == window ) - { - return Clipboard.c_str(); - } - Clipboard = ""; - if (ownerWindow != None ) - { - XConvertSelection (display, X_ATOM_CLIPBOARD, XA_STRING, None, ownerWindow, CurrentTime); - XFlush (display); - - // check for data - Atom type; - int format; - unsigned long numItems, bytesLeft, dummy; - unsigned char *data; - XGetWindowProperty (display, ownerWindow, - XA_STRING, // property name - 0, // offset - 0, // length (we only check for data, so 0) - 0, // Delete 0==false - AnyPropertyType, // AnyPropertyType or property identifier - &type, // return type - &format, // return format - &numItems, // number items - &bytesLeft, // remaining bytes for partial reads - &data); // data - if ( bytesLeft > 0 ) - { - // there is some data to get - int result = XGetWindowProperty (display, ownerWindow, XA_STRING, 0, - bytesLeft, 0, AnyPropertyType, &type, &format, - &numItems, &dummy, &data); - if (result == Success) - Clipboard = (irr::c8*)data; - XFree (data); - } - } - - return Clipboard.c_str(); - -#else - return 0; -#endif -} - -//! copies text to the clipboard -void CIrrDeviceLinux::copyToClipboard(const c8* text) const -{ -#if defined(_IRR_COMPILE_WITH_X11_) - // Actually there is no clipboard on X but applications just say they own the clipboard and return text when asked. - // Which btw. also means that on X you lose clipboard content when closing applications. - Clipboard = text; - XSetSelectionOwner (display, X_ATOM_CLIPBOARD, window, CurrentTime); - XFlush (display); -#endif -} - -void CIrrDeviceLinux::initXAtoms() -{ -#ifdef _IRR_COMPILE_WITH_X11_ - X_ATOM_CLIPBOARD = XInternAtom(display, "CLIPBOARD", False); - X_ATOM_TARGETS = XInternAtom(display, "TARGETS", False); - X_ATOM_UTF8_STRING = XInternAtom (display, "UTF8_STRING", False); - X_ATOM_TEXT = XInternAtom (display, "TEXT", False); -#endif -} - -} // end namespace - -#endif // _IRR_COMPILE_WITH_X11_DEVICE_ - diff --git a/irrlicht-1.6/source/Irrlicht/CIrrDeviceLinux.h b/irrlicht-1.6/source/Irrlicht/CIrrDeviceLinux.h deleted file mode 100644 index c1973ae7a..000000000 --- a/irrlicht-1.6/source/Irrlicht/CIrrDeviceLinux.h +++ /dev/null @@ -1,405 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_IRR_DEVICE_LINUX_H_INCLUDED__ -#define __C_IRR_DEVICE_LINUX_H_INCLUDED__ - -#include "IrrCompileConfig.h" - -#ifdef _IRR_COMPILE_WITH_X11_DEVICE_ - -#include "CIrrDeviceStub.h" -#include "IrrlichtDevice.h" -#include "IImagePresenter.h" -#include "ICursorControl.h" - -#ifdef _IRR_COMPILE_WITH_X11_ - -#ifdef _IRR_COMPILE_WITH_OPENGL_ -#include <GL/gl.h> -#define GLX_GLXEXT_LEGACY 1 -#include <GL/glx.h> -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ -#include "glxext.h" -#endif -#endif - -#include <X11/Xlib.h> -#include <X11/Xutil.h> -#ifdef _IRR_LINUX_X11_VIDMODE_ -#include <X11/extensions/xf86vmode.h> -#endif -#ifdef _IRR_LINUX_X11_RANDR_ -#include <X11/extensions/Xrandr.h> -#endif -#include <X11/keysym.h> - -#else -#define KeySym s32 -#endif - -namespace irr -{ - - class CIrrDeviceLinux : public CIrrDeviceStub, public video::IImagePresenter - { - public: - - //! constructor - CIrrDeviceLinux(const SIrrlichtCreationParameters& param); - - //! destructor - virtual ~CIrrDeviceLinux(); - - //! runs the device. Returns false if device wants to be deleted - virtual bool run(); - - //! Cause the device to temporarily pause execution and let other processes to run - // This should bring down processor usage without major performance loss for Irrlicht - virtual void yield(); - - //! Pause execution and let other processes to run for a specified amount of time. - virtual void sleep(u32 timeMs, bool pauseTimer); - - //! sets the caption of the window - virtual void setWindowCaption(const wchar_t* text); - - //! returns if window is active. if not, nothing need to be drawn - virtual bool isWindowActive() const; - - //! returns if window has focus. - virtual bool isWindowFocused() const; - - //! returns if window is minimized. - virtual bool isWindowMinimized() const; - - //! returns color format of the window. - virtual video::ECOLOR_FORMAT getColorFormat() const; - - //! presents a surface in the client area - virtual bool present(video::IImage* surface, void* windowId=0, core::rect<s32>* src=0 ); - - //! notifies the device that it should close itself - virtual void closeDevice(); - - //! \return Returns a pointer to a list with all video modes - //! supported by the gfx adapter. - video::IVideoModeList* getVideoModeList(); - - //! Sets if the window should be resizable in windowed mode. - virtual void setResizable(bool resize=false); - - //! Minimizes the window. - virtual void minimizeWindow(); - - //! Maximizes the window. - virtual void maximizeWindow(); - - //! Restores the window size. - virtual void restoreWindow(); - - //! Activate any joysticks, and generate events for them. - virtual bool activateJoysticks(core::array<SJoystickInfo> & joystickInfo); - - //! Set the current Gamma Value for the Display - virtual bool setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast ); - - //! Get the current Gamma Value for the Display - virtual bool getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast ); - - //! gets text from the clipboard - //! \return Returns 0 if no string is in there. - virtual const c8* getTextFromClipboard() const; - - //! copies text to the clipboard - //! This sets the clipboard selection and _not_ the primary selection which you have on X on the middle mouse button. - virtual void copyToClipboard(const c8* text) const; - - //! Get the device type - virtual E_DEVICE_TYPE getType() const - { - return EIDT_X11; - } - - private: - - //! create the driver - void createDriver(); - - bool createWindow(); - - void createKeyMap(); - - void pollJoysticks(); - - void initXAtoms(); - - //! Implementation of the linux cursor control - class CCursorControl : public gui::ICursorControl - { - public: - - CCursorControl(CIrrDeviceLinux* dev, bool null) - : Device(dev), IsVisible(true), Null(null), UseReferenceRect(false) - { -#ifdef _IRR_COMPILE_WITH_X11_ - if (!Null) - { - XGCValues values; - unsigned long valuemask = 0; - - XColor fg, bg; - - // this code, for making the cursor invisible was sent in by - // Sirshane, thank your very much! - - - Pixmap invisBitmap = XCreatePixmap(Device->display, Device->window, 32, 32, 1); - Pixmap maskBitmap = XCreatePixmap(Device->display, Device->window, 32, 32, 1); - Colormap screen_colormap = DefaultColormap( Device->display, DefaultScreen( Device->display ) ); - XAllocNamedColor( Device->display, screen_colormap, "black", &fg, &fg ); - XAllocNamedColor( Device->display, screen_colormap, "white", &bg, &bg ); - - GC gc = XCreateGC( Device->display, invisBitmap, valuemask, &values ); - - XSetForeground( Device->display, gc, BlackPixel( Device->display, DefaultScreen( Device->display ) ) ); - XFillRectangle( Device->display, invisBitmap, gc, 0, 0, 32, 32 ); - XFillRectangle( Device->display, maskBitmap, gc, 0, 0, 32, 32 ); - - invisCursor = XCreatePixmapCursor( Device->display, invisBitmap, maskBitmap, &fg, &bg, 1, 1 ); - XFreeGC(Device->display, gc); - XFreePixmap(Device->display, invisBitmap); - XFreePixmap(Device->display, maskBitmap); - } -#endif - } - - //! Changes the visible state of the mouse cursor. - virtual void setVisible(bool visible) - { - if (visible==IsVisible) - return; - IsVisible = visible; -#ifdef _IRR_COMPILE_WITH_X11_ - if (!Null) - { - if ( !IsVisible ) - XDefineCursor( Device->display, Device->window, invisCursor ); - else - XUndefineCursor( Device->display, Device->window ); - } -#endif - } - - //! Returns if the cursor is currently visible. - virtual bool isVisible() const - { - return IsVisible; - } - - //! Sets the new position of the cursor. - virtual void setPosition(const core::position2d<f32> &pos) - { - setPosition(pos.X, pos.Y); - } - - //! Sets the new position of the cursor. - virtual void setPosition(f32 x, f32 y) - { - setPosition((s32)(x*Device->Width), (s32)(y*Device->Height)); - } - - //! Sets the new position of the cursor. - virtual void setPosition(const core::position2d<s32> &pos) - { - setPosition(pos.X, pos.Y); - } - - //! Sets the new position of the cursor. - virtual void setPosition(s32 x, s32 y) - { -#ifdef _IRR_COMPILE_WITH_X11_ - - if (!Null) - { - if (UseReferenceRect) - { - XWarpPointer(Device->display, - None, - Device->window, 0, 0, - Device->Width, - Device->Height, - ReferenceRect.UpperLeftCorner.X + x, - ReferenceRect.UpperLeftCorner.Y + y); - - } - else - { - XWarpPointer(Device->display, - None, - Device->window, 0, 0, - Device->Width, - Device->Height, x, y); - } - XFlush(Device->display); - } -#endif - CursorPos.X = x; - CursorPos.Y = y; - } - - //! Returns the current position of the mouse cursor. - virtual core::position2d<s32> getPosition() - { - updateCursorPos(); - return CursorPos; - } - - //! Returns the current position of the mouse cursor. - virtual core::position2d<f32> getRelativePosition() - { - updateCursorPos(); - - if (!UseReferenceRect) - { - return core::position2d<f32>(CursorPos.X / (f32)Device->Width, - CursorPos.Y / (f32)Device->Height); - } - - return core::position2d<f32>(CursorPos.X / (f32)ReferenceRect.getWidth(), - CursorPos.Y / (f32)ReferenceRect.getHeight()); - } - - virtual void setReferenceRect(core::rect<s32>* rect=0) - { - if (rect) - { - ReferenceRect = *rect; - UseReferenceRect = true; - - // prevent division through zero and uneven sizes - - if (!ReferenceRect.getHeight() || ReferenceRect.getHeight()%2) - ReferenceRect.LowerRightCorner.Y += 1; - - if (!ReferenceRect.getWidth() || ReferenceRect.getWidth()%2) - ReferenceRect.LowerRightCorner.X += 1; - } - else - UseReferenceRect = false; - } - - private: - - void updateCursorPos() - { -#ifdef _IRR_COMPILE_WITH_X11_ - if (Null) - return; - - Window tmp; - int itmp1, itmp2; - unsigned int maskreturn; - XQueryPointer(Device->display, Device->window, - &tmp, &tmp, - &itmp1, &itmp2, - &CursorPos.X, &CursorPos.Y, &maskreturn); - - if (CursorPos.X < 0) - CursorPos.X = 0; - if (CursorPos.X > (s32) Device->Width) - CursorPos.X = Device->Width; - if (CursorPos.Y < 0) - CursorPos.Y = 0; - if (CursorPos.Y > (s32) Device->Height) - CursorPos.Y = Device->Height; -#endif - } - - CIrrDeviceLinux* Device; - core::position2d<s32> CursorPos; - core::rect<s32> ReferenceRect; -#ifdef _IRR_COMPILE_WITH_X11_ - Cursor invisCursor; -#endif - bool IsVisible; - bool Null; - bool UseReferenceRect; - }; - - friend class CCursorControl; - -#ifdef _IRR_COMPILE_WITH_X11_ - friend class COpenGLDriver; - - Display *display; - XVisualInfo* visual; - int screennr; - Window window; - XSetWindowAttributes attributes; - XSizeHints* StdHints; - XImage* SoftwareImage; - mutable core::stringc Clipboard; - #ifdef _IRR_LINUX_X11_VIDMODE_ - XF86VidModeModeInfo oldVideoMode; - #endif - #ifdef _IRR_LINUX_X11_RANDR_ - SizeID oldRandrMode; - Rotation oldRandrRotation; - #endif - #ifdef _IRR_COMPILE_WITH_OPENGL_ - GLXWindow glxWin; - GLXContext Context; - #endif -#endif - u32 Width, Height; - bool Close; - bool WindowHasFocus; - bool WindowMinimized; - bool UseXVidMode; - bool UseXRandR; - bool UseGLXWindow; - bool ExternalWindow; - int AutorepeatSupport; - - struct SKeyMap - { - SKeyMap() {} - SKeyMap(s32 x11, s32 win32) - : X11Key(x11), Win32Key(win32) - { - } - - KeySym X11Key; - s32 Win32Key; - - bool operator<(const SKeyMap& o) const - { - return X11Key<o.X11Key; - } - }; - - core::array<SKeyMap> KeyMap; - -#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) - struct JoystickInfo - { - int fd; - int axes; - int buttons; - - SEvent persistentData; - - JoystickInfo() : fd(-1), axes(0), buttons(0) { } - }; - core::array<JoystickInfo> ActiveJoysticks; -#endif - }; - - -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_X11_DEVICE_ -#endif // __C_IRR_DEVICE_LINUX_H_INCLUDED__ - diff --git a/irrlicht-1.6/source/Irrlicht/CIrrDeviceSDL.cpp b/irrlicht-1.6/source/Irrlicht/CIrrDeviceSDL.cpp deleted file mode 100644 index 14690f0b0..000000000 --- a/irrlicht-1.6/source/Irrlicht/CIrrDeviceSDL.cpp +++ /dev/null @@ -1,984 +0,0 @@ -// Copyright (C) 2002-2009 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_SDL_DEVICE_ - -#include "CIrrDeviceSDL.h" -#include "IEventReceiver.h" -#include "irrList.h" -#include "os.h" -#include "CTimer.h" -#include "irrString.h" -#include "Keycodes.h" -#include "COSOperator.h" -#include <stdio.h> -#include <stdlib.h> -#include "SIrrCreationParameters.h" -#include <SDL/SDL_syswm.h> -#include <SDL/SDL_video.h> - -#ifdef _MSC_VER -#pragma comment(lib, "SDL.lib") -#endif // _MSC_VER - -namespace irr -{ - namespace video - { - - #ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ - IVideoDriver* createDirectX8Driver(const core::dimension2d<u32>& screenSize, HWND window, - u32 bits, bool fullscreen, bool stencilbuffer, io::IFileSystem* io, - bool pureSoftware, bool highPrecisionFPU, bool vsync, u8 antiAlias); - #endif - - #ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ - IVideoDriver* createDirectX9Driver(const core::dimension2d<u32>& screenSize, HWND window, - u32 bits, bool fullscreen, bool stencilbuffer, io::IFileSystem* io, - bool pureSoftware, bool highPrecisionFPU, bool vsync, u8 antiAlias); - #endif - - #ifdef _IRR_COMPILE_WITH_OPENGL_ - IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params, - io::IFileSystem* io, CIrrDeviceSDL* device); - #endif - } // end namespace video - -} // end namespace irr - - -namespace irr -{ - -//! constructor -CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param) - : CIrrDeviceStub(param), - Screen((SDL_Surface*)param.WindowId), SDL_Flags(SDL_ANYFORMAT), - MouseX(0), MouseY(0), MouseButtonStates(0), - Width(param.WindowSize.Width), Height(param.WindowSize.Height), - Close(0), Resizable(false), - WindowHasFocus(false), WindowMinimized(false) -{ - #ifdef _DEBUG - setDebugName("CIrrDeviceSDL"); - #endif - - // Initialize SDL... Timer for sleep, video for the obvious, and - // noparachute prevents SDL from catching fatal errors. - if (SDL_Init( SDL_INIT_TIMER|SDL_INIT_VIDEO| -#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) - SDL_INIT_JOYSTICK| -#endif - SDL_INIT_NOPARACHUTE ) < 0) - { - os::Printer::log( "Unable to initialize SDL!", SDL_GetError()); - Close = 1; - } - -#if defined(_IRR_WINDOWS_) - SDL_putenv("SDL_VIDEODRIVER=directx"); -#elif defined(_IRR_OSX_PLATFORM_) - SDL_putenv("SDL_VIDEODRIVER=Quartz"); -#else - SDL_putenv("SDL_VIDEODRIVER=x11"); -#endif -// SDL_putenv("SDL_WINDOWID="); - - SDL_VERSION(&Info.version); - - SDL_GetWMInfo(&Info); - core::stringc sdlversion = "SDL Version "; - sdlversion += Info.version.major; - sdlversion += "."; - sdlversion += Info.version.minor; - sdlversion += "."; - sdlversion += Info.version.patch; - - Operator = new COSOperator(sdlversion.c_str()); - os::Printer::log(sdlversion.c_str(), ELL_INFORMATION); - - // create keymap - createKeyMap(); - // enable key to character translation - SDL_EnableUNICODE(1); - - (void)SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); - - if ( CreationParams.Fullscreen ) - SDL_Flags |= SDL_FULLSCREEN; - if (CreationParams.DriverType == video::EDT_OPENGL) - SDL_Flags |= SDL_OPENGL; - else if (CreationParams.Doublebuffer) - SDL_Flags |= SDL_DOUBLEBUF; - // create window - if (CreationParams.DriverType != video::EDT_NULL) - { - // create the window, only if we do not use the null device - createWindow(); - } - - // create cursor control - CursorControl = new CCursorControl(this); - - // create driver - createDriver(); - - if (VideoDriver) - createGUIAndScene(); -} - - -//! destructor -CIrrDeviceSDL::~CIrrDeviceSDL() -{ -#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) - const u32 numJoysticks = Joysticks.size(); - for (u32 i=0; i<numJoysticks; ++i) - SDL_JoystickClose(Joysticks[i]); -#endif - SDL_Quit(); -} - - -bool CIrrDeviceSDL::createWindow() -{ - if ( Close ) - return false; - - if (CreationParams.DriverType == video::EDT_OPENGL) - { - if (CreationParams.Bits==16) - { - SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 4 ); - SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 4 ); - SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 4 ); - SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, CreationParams.WithAlphaChannel?1:0 ); - } - else - { - SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 ); - SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 ); - SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 ); - SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, CreationParams.WithAlphaChannel?8:0 ); - } - SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, CreationParams.ZBufferBits); - if (CreationParams.Doublebuffer) - SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); - if (CreationParams.Stereobuffer) - SDL_GL_SetAttribute( SDL_GL_STEREO, 1 ); - if (CreationParams.AntiAlias>1) - { - SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 ); - SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, CreationParams.AntiAlias ); - } - if ( !Screen ) - Screen = SDL_SetVideoMode( Width, Height, CreationParams.Bits, SDL_Flags ); - if ( !Screen && CreationParams.AntiAlias>1) - { - while (--CreationParams.AntiAlias>1) - { - SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, CreationParams.AntiAlias ); - Screen = SDL_SetVideoMode( Width, Height, CreationParams.Bits, SDL_Flags ); - if (Screen) - break; - } - if ( !Screen ) - { - SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 0 ); - SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, 0 ); - Screen = SDL_SetVideoMode( Width, Height, CreationParams.Bits, SDL_Flags ); - if (Screen) - os::Printer::log("AntiAliasing disabled due to lack of support!" ); - } - } - } - else if ( !Screen ) - Screen = SDL_SetVideoMode( Width, Height, CreationParams.Bits, SDL_Flags ); - - if ( !Screen && CreationParams.Doublebuffer) - { - // Try single buffer - if (CreationParams.DriverType == video::EDT_OPENGL) - SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); - SDL_Flags &= ~SDL_DOUBLEBUF; - Screen = SDL_SetVideoMode( Width, Height, CreationParams.Bits, SDL_Flags ); - } - if ( !Screen ) - { - os::Printer::log( "Could not initialize display!" ); - return false; - } - - return true; -} - - -//! create the driver -void CIrrDeviceSDL::createDriver() -{ - switch(CreationParams.DriverType) - { - case video::EDT_DIRECT3D8: - #ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ - - VideoDriver = video::createDirectX8Driver(CreationParams.WindowSize, Info.window, - CreationParams.Bits, CreationParams.Fullscreen, CreationParams.Stencilbuffer, - FileSystem, false, CreationParams.HighPrecisionFPU, CreationParams.Vsync, - CreationParams.AntiAlias); - - if (!VideoDriver) - { - os::Printer::log("Could not create DIRECT3D8 Driver.", ELL_ERROR); - } - #else - os::Printer::log("DIRECT3D8 Driver was not compiled into this dll. Try another one.", ELL_ERROR); - #endif // _IRR_COMPILE_WITH_DIRECT3D_8_ - - break; - - case video::EDT_DIRECT3D9: - #ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ - - VideoDriver = video::createDirectX9Driver(CreationParams.WindowSize, Info.window, - CreationParams.Bits, CreationParams.Fullscreen, CreationParams.Stencilbuffer, - FileSystem, false, CreationParams.HighPrecisionFPU, CreationParams.Vsync, - CreationParams.AntiAlias); - - if (!VideoDriver) - { - os::Printer::log("Could not create DIRECT3D9 Driver.", ELL_ERROR); - } - #else - os::Printer::log("DIRECT3D9 Driver was not compiled into this dll. Try another one.", ELL_ERROR); - #endif // _IRR_COMPILE_WITH_DIRECT3D_9_ - - break; - - case video::EDT_SOFTWARE: - #ifdef _IRR_COMPILE_WITH_SOFTWARE_ - VideoDriver = video::createSoftwareDriver(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this); - #else - os::Printer::log("No Software driver support compiled in.", ELL_ERROR); - #endif - break; - - case video::EDT_BURNINGSVIDEO: - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - VideoDriver = video::createSoftwareDriver2(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this); - #else - os::Printer::log("Burning's video driver was not compiled in.", ELL_ERROR); - #endif - break; - - case video::EDT_OPENGL: - #ifdef _IRR_COMPILE_WITH_OPENGL_ - VideoDriver = video::createOpenGLDriver(CreationParams, FileSystem, this); - #else - os::Printer::log("No OpenGL support compiled in.", ELL_ERROR); - #endif - break; - - case video::EDT_NULL: - VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize); - break; - - default: - os::Printer::log("Unable to create video driver of unknown type.", ELL_ERROR); - break; - } -} - - -//! runs the device. Returns false if device wants to be deleted -bool CIrrDeviceSDL::run() -{ - os::Timer::tick(); - - SEvent irrevent; - SDL_Event SDL_event; - - while ( !Close && SDL_PollEvent( &SDL_event ) ) - { - switch ( SDL_event.type ) - { - case SDL_MOUSEMOTION: - irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT; - irrevent.MouseInput.Event = irr::EMIE_MOUSE_MOVED; - MouseX = irrevent.MouseInput.X = SDL_event.motion.x; - MouseY = irrevent.MouseInput.Y = SDL_event.motion.y; - irrevent.MouseInput.ButtonStates = MouseButtonStates; - - postEventFromUser(irrevent); - break; - - case SDL_MOUSEBUTTONDOWN: - case SDL_MOUSEBUTTONUP: - - irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT; - irrevent.MouseInput.X = SDL_event.button.x; - irrevent.MouseInput.Y = SDL_event.button.y; - - irrevent.MouseInput.Event = irr::EMIE_MOUSE_MOVED; - - switch(SDL_event.button.button) - { - case SDL_BUTTON_LEFT: - if (SDL_event.type == SDL_MOUSEBUTTONDOWN) - { - irrevent.MouseInput.Event = irr::EMIE_LMOUSE_PRESSED_DOWN; - MouseButtonStates |= irr::EMBSM_LEFT; - } - else - { - irrevent.MouseInput.Event = irr::EMIE_LMOUSE_LEFT_UP; - MouseButtonStates &= !irr::EMBSM_LEFT; - } - break; - - case SDL_BUTTON_RIGHT: - if (SDL_event.type == SDL_MOUSEBUTTONDOWN) - { - irrevent.MouseInput.Event = irr::EMIE_RMOUSE_PRESSED_DOWN; - MouseButtonStates |= irr::EMBSM_RIGHT; - } - else - { - irrevent.MouseInput.Event = irr::EMIE_RMOUSE_LEFT_UP; - MouseButtonStates &= !irr::EMBSM_RIGHT; - } - break; - - case SDL_BUTTON_MIDDLE: - if (SDL_event.type == SDL_MOUSEBUTTONDOWN) - { - irrevent.MouseInput.Event = irr::EMIE_MMOUSE_PRESSED_DOWN; - MouseButtonStates |= irr::EMBSM_MIDDLE; - } - else - { - irrevent.MouseInput.Event = irr::EMIE_MMOUSE_LEFT_UP; - MouseButtonStates &= !irr::EMBSM_MIDDLE; - } - break; - - case SDL_BUTTON_WHEELUP: - irrevent.MouseInput.Event = irr::EMIE_MOUSE_WHEEL; - irrevent.MouseInput.Wheel = 1.0f; - break; - - case SDL_BUTTON_WHEELDOWN: - irrevent.MouseInput.Event = irr::EMIE_MOUSE_WHEEL; - irrevent.MouseInput.Wheel = -1.0f; - break; - } - - irrevent.MouseInput.ButtonStates = MouseButtonStates; - - if (irrevent.MouseInput.Event != irr::EMIE_MOUSE_MOVED) - { - postEventFromUser(irrevent); - - if ( irrevent.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN ) - { - u32 clicks = checkSuccessiveClicks(irrevent.MouseInput.X, irrevent.MouseInput.Y); - if ( clicks == 2 ) - { - irrevent.MouseInput.Event = EMIE_MOUSE_DOUBLE_CLICK; - postEventFromUser(irrevent); - } - else if ( clicks == 3 ) - { - irrevent.MouseInput.Event = EMIE_MOUSE_TRIPLE_CLICK; - postEventFromUser(irrevent); - } - } - } - break; - - case SDL_KEYDOWN: - case SDL_KEYUP: - { - SKeyMap mp; - mp.SDLKey = SDL_event.key.keysym.sym; - s32 idx = KeyMap.binary_search(mp); - - EKEY_CODE key; - if (idx == -1) - key = (EKEY_CODE)0; - else - key = (EKEY_CODE)KeyMap[idx].Win32Key; - -#ifdef _IRR_WINDOWS_API_ - // handle alt+f4 in Windows, because SDL seems not to - if ( (SDL_event.key.keysym.mod & KMOD_LALT) && key == KEY_F4) - { - Close = true; - break; - } -#endif - irrevent.EventType = irr::EET_KEY_INPUT_EVENT; - irrevent.KeyInput.Char = SDL_event.key.keysym.unicode; - irrevent.KeyInput.Key = key; - irrevent.KeyInput.PressedDown = (SDL_event.type == SDL_KEYDOWN); - irrevent.KeyInput.Shift = (SDL_event.key.keysym.mod & KMOD_SHIFT) != 0; - irrevent.KeyInput.Control = (SDL_event.key.keysym.mod & KMOD_CTRL ) != 0; - postEventFromUser(irrevent); - } - break; - - case SDL_QUIT: - Close = true; - break; - - case SDL_ACTIVEEVENT: - if ((SDL_event.active.state == SDL_APPMOUSEFOCUS) || - (SDL_event.active.state == SDL_APPINPUTFOCUS)) - WindowHasFocus = (SDL_event.active.gain==1); - else - if (SDL_event.active.state == SDL_APPACTIVE) - WindowMinimized = (SDL_event.active.gain!=1); - break; - - case SDL_VIDEORESIZE: - if ((SDL_event.resize.w != (int)Width) || (SDL_event.resize.h != (int)Height)) - { - Width = SDL_event.resize.w; - Height = SDL_event.resize.h; - Screen = SDL_SetVideoMode( Width, Height, 0, SDL_Flags ); - if (VideoDriver) - VideoDriver->OnResize(core::dimension2d<u32>(Width, Height)); - } - break; - - case SDL_USEREVENT: - irrevent.EventType = irr::EET_USER_EVENT; - irrevent.UserEvent.UserData1 = *(reinterpret_cast<s32*>(&SDL_event.user.data1)); - irrevent.UserEvent.UserData2 = *(reinterpret_cast<s32*>(&SDL_event.user.data2)); - - postEventFromUser(irrevent); - break; - - default: - break; - } // end switch - - } // end while - -#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) - // TODO: Check if the multiple open/close calls are too expensive, then - // open/close in the constructor/destructor instead - - // update joystick states manually - SDL_JoystickUpdate(); - // we'll always send joystick input events... - SEvent joyevent; - joyevent.EventType = EET_JOYSTICK_INPUT_EVENT; - for (u32 i=0; i<Joysticks.size(); ++i) - { - SDL_Joystick* joystick = Joysticks[i]; - if (joystick) - { - int j; - // query all buttons - const int numButtons = core::min_(SDL_JoystickNumButtons(joystick), 32); - joyevent.JoystickEvent.ButtonStates=0; - for (j=0; j<numButtons; ++j) - joyevent.JoystickEvent.ButtonStates |= (SDL_JoystickGetButton(joystick, j)<<j); - - // query all axes, already in correct range - const int numAxes = core::min_(SDL_JoystickNumAxes(joystick), 6); - joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_X]=0; - joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_Y]=0; - joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_Z]=0; - joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_R]=0; - joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_U]=0; - joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_V]=0; - for (j=0; j<numAxes; ++j) - joyevent.JoystickEvent.Axis[j] = SDL_JoystickGetAxis(joystick, j); - - // we can only query one hat, SDL only supports 8 directions - if (SDL_JoystickNumHats(joystick)>0) - { - switch (SDL_JoystickGetHat(joystick, 0)) - { - case SDL_HAT_UP: - joyevent.JoystickEvent.POV=0; - break; - case SDL_HAT_RIGHTUP: - joyevent.JoystickEvent.POV=4500; - break; - case SDL_HAT_RIGHT: - joyevent.JoystickEvent.POV=9000; - break; - case SDL_HAT_RIGHTDOWN: - joyevent.JoystickEvent.POV=13500; - break; - case SDL_HAT_DOWN: - joyevent.JoystickEvent.POV=18000; - break; - case SDL_HAT_LEFTDOWN: - joyevent.JoystickEvent.POV=22500; - break; - case SDL_HAT_LEFT: - joyevent.JoystickEvent.POV=27000; - break; - case SDL_HAT_LEFTUP: - joyevent.JoystickEvent.POV=31500; - break; - case SDL_HAT_CENTERED: - default: - joyevent.JoystickEvent.POV=65535; - break; - } - } - else - { - joyevent.JoystickEvent.POV=65535; - } - - // we map the number directly - joyevent.JoystickEvent.Joystick=static_cast<u8>(i); - // now post the event - postEventFromUser(joyevent); - // and close the joystick - } - } -#endif - return !Close; -} - -//! Activate any joysticks, and generate events for them. -bool CIrrDeviceSDL::activateJoysticks(core::array<SJoystickInfo> & joystickInfo) -{ -#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) - joystickInfo.clear(); - - // we can name up to 256 different joysticks - const int numJoysticks = core::min_(SDL_NumJoysticks(), 256); - Joysticks.reallocate(numJoysticks); - joystickInfo.reallocate(numJoysticks); - - int joystick = 0; - for (; joystick<numJoysticks; ++joystick) - { - Joysticks.push_back(SDL_JoystickOpen(joystick)); - SJoystickInfo info; - - info.Joystick = joystick; - info.Axes = SDL_JoystickNumAxes(Joysticks[joystick]); - info.Buttons = SDL_JoystickNumButtons(Joysticks[joystick]); - info.Name = SDL_JoystickName(joystick); - info.PovHat = (SDL_JoystickNumHats(Joysticks[joystick]) > 0) - ? SJoystickInfo::POV_HAT_PRESENT : SJoystickInfo::POV_HAT_ABSENT; - - joystickInfo.push_back(info); - } - - for(joystick = 0; joystick < (int)joystickInfo.size(); ++joystick) - { - char logString[256]; - (void)sprintf(logString, "Found joystick %d, %d axes, %d buttons '%s'", - joystick, joystickInfo[joystick].Axes, - joystickInfo[joystick].Buttons, joystickInfo[joystick].Name.c_str()); - os::Printer::log(logString, ELL_INFORMATION); - } - - return true; - -#endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ - - return false; -} - - - -//! pause execution temporarily -void CIrrDeviceSDL::yield() -{ - SDL_Delay(0); -} - - -//! pause execution for a specified time -void CIrrDeviceSDL::sleep(u32 timeMs, bool pauseTimer) -{ - const bool wasStopped = Timer ? Timer->isStopped() : true; - if (pauseTimer && !wasStopped) - Timer->stop(); - - SDL_Delay(timeMs); - - if (pauseTimer && !wasStopped) - Timer->start(); -} - - -//! sets the caption of the window -void CIrrDeviceSDL::setWindowCaption(const wchar_t* text) -{ - core::stringc textc = text; - SDL_WM_SetCaption( textc.c_str( ), textc.c_str( ) ); -} - - -//! presents a surface in the client area -bool CIrrDeviceSDL::present(video::IImage* surface, void* windowId, core::rect<s32>* srcClip) -{ - SDL_Surface *sdlSurface = SDL_CreateRGBSurfaceFrom( - surface->lock(), surface->getDimension().Width, surface->getDimension().Height, - surface->getBitsPerPixel(), surface->getPitch(), - surface->getRedMask(), surface->getGreenMask(), surface->getBlueMask(), surface->getAlphaMask()); - if (!sdlSurface) - return false; - SDL_SetAlpha(sdlSurface, 0, 0); - SDL_SetColorKey(sdlSurface, 0, 0); - sdlSurface->format->BitsPerPixel=surface->getBitsPerPixel(); - sdlSurface->format->BytesPerPixel=surface->getBytesPerPixel(); - if ((surface->getColorFormat()==video::ECF_R8G8B8) || - (surface->getColorFormat()==video::ECF_A8R8G8B8)) - { - sdlSurface->format->Rloss=0; - sdlSurface->format->Gloss=0; - sdlSurface->format->Bloss=0; - sdlSurface->format->Rshift=16; - sdlSurface->format->Gshift=8; - sdlSurface->format->Bshift=0; - if (surface->getColorFormat()==video::ECF_R8G8B8) - { - sdlSurface->format->Aloss=8; - sdlSurface->format->Ashift=32; - } - else - { - sdlSurface->format->Aloss=0; - sdlSurface->format->Ashift=24; - } - } - else if (surface->getColorFormat()==video::ECF_R5G6B5) - { - sdlSurface->format->Rloss=3; - sdlSurface->format->Gloss=2; - sdlSurface->format->Bloss=3; - sdlSurface->format->Aloss=8; - sdlSurface->format->Rshift=11; - sdlSurface->format->Gshift=5; - sdlSurface->format->Bshift=0; - sdlSurface->format->Ashift=16; - } - else if (surface->getColorFormat()==video::ECF_A1R5G5B5) - { - sdlSurface->format->Rloss=3; - sdlSurface->format->Gloss=3; - sdlSurface->format->Bloss=3; - sdlSurface->format->Aloss=7; - sdlSurface->format->Rshift=10; - sdlSurface->format->Gshift=5; - sdlSurface->format->Bshift=0; - sdlSurface->format->Ashift=15; - } - - SDL_Surface* scr = (SDL_Surface* )windowId; - if (!scr) - scr = Screen; - if (scr) - { - if (srcClip) - { - SDL_Rect sdlsrcClip; - sdlsrcClip.x = srcClip->UpperLeftCorner.X; - sdlsrcClip.y = srcClip->UpperLeftCorner.Y; - sdlsrcClip.w = srcClip->getWidth(); - sdlsrcClip.h = srcClip->getHeight(); - SDL_BlitSurface(sdlSurface, &sdlsrcClip, scr, NULL); - } - else - SDL_BlitSurface(sdlSurface, NULL, scr, NULL); - SDL_Flip(scr); - } - - SDL_FreeSurface(sdlSurface); - surface->unlock(); - return (scr != 0); -} - - -//! notifies the device that it should close itself -void CIrrDeviceSDL::closeDevice() -{ - Close = true; -} - - -//! \return Pointer to a list with all video modes supported -video::IVideoModeList* CIrrDeviceSDL::getVideoModeList() -{ - if (!VideoModeList.getVideoModeCount()) - { - // enumerate video modes. - const SDL_VideoInfo *vi = SDL_GetVideoInfo(); - SDL_Rect **modes = SDL_ListModes(vi->vfmt, SDL_Flags); - if (modes != 0) - { - if (modes == (SDL_Rect **)-1) - os::Printer::log("All modes available.\n"); - else - { - for (u32 i=0; modes[i]; ++i) - VideoModeList.addMode(core::dimension2d<u32>(modes[i]->w, modes[i]->h), vi->vfmt->BitsPerPixel); - } - } - } - - return &VideoModeList; -} - - -//! Sets if the window should be resizable in windowed mode. -void CIrrDeviceSDL::setResizable(bool resize) -{ - if (resize != Resizable) - { - if (resize) - SDL_Flags |= SDL_RESIZABLE; - else - SDL_Flags &= ~SDL_RESIZABLE; - Screen = SDL_SetVideoMode( 0, 0, 0, SDL_Flags ); - Resizable = resize; - } -} - - -//! Minimizes window if possible -void CIrrDeviceSDL::minimizeWindow() -{ - SDL_WM_IconifyWindow(); -} - - -//! Maximize window -void CIrrDeviceSDL::maximizeWindow() -{ - // do nothing -} - - -//! Restore original window size -void CIrrDeviceSDL::restoreWindow() -{ - // do nothing -} - - -//! returns if window is active. if not, nothing need to be drawn -bool CIrrDeviceSDL::isWindowActive() const -{ - return (WindowHasFocus && !WindowMinimized); -} - - -//! returns if window has focus. -bool CIrrDeviceSDL::isWindowFocused() const -{ - return WindowHasFocus; -} - - -//! returns if window is minimized. -bool CIrrDeviceSDL::isWindowMinimized() const -{ - return WindowMinimized; -} - - -//! Set the current Gamma Value for the Display -bool CIrrDeviceSDL::setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast ) -{ - /* - // todo: Gamma in SDL takes ints, what does Irrlicht use? - return (SDL_SetGamma(red, green, blue) != -1); - */ - return false; -} - -//! Get the current Gamma Value for the Display -bool CIrrDeviceSDL::getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast ) -{ -/* brightness = 0.f; - contrast = 0.f; - return (SDL_GetGamma(&red, &green, &blue) != -1);*/ - return false; -} - -//! returns color format of the window. -video::ECOLOR_FORMAT CIrrDeviceSDL::getColorFormat() const -{ - if (Screen) - { - if (Screen->format->BitsPerPixel==16) - { - if (Screen->format->Amask != 0) - return video::ECF_A1R5G5B5; - else - return video::ECF_R5G6B5; - } - else - { - if (Screen->format->Amask != 0) - return video::ECF_A8R8G8B8; - else - return video::ECF_R8G8B8; - } - } - else - return CIrrDeviceStub::getColorFormat(); -} - - -void CIrrDeviceSDL::createKeyMap() -{ - // I don't know if this is the best method to create - // the lookuptable, but I'll leave it like that until - // I find a better version. - - KeyMap.reallocate(105); - - // buttons missing - - KeyMap.push_back(SKeyMap(SDLK_BACKSPACE, KEY_BACK)); - KeyMap.push_back(SKeyMap(SDLK_TAB, KEY_TAB)); - KeyMap.push_back(SKeyMap(SDLK_CLEAR, KEY_CLEAR)); - KeyMap.push_back(SKeyMap(SDLK_RETURN, KEY_RETURN)); - - // combined modifiers missing - - KeyMap.push_back(SKeyMap(SDLK_PAUSE, KEY_PAUSE)); - KeyMap.push_back(SKeyMap(SDLK_CAPSLOCK, KEY_CAPITAL)); - - // asian letter keys missing - - KeyMap.push_back(SKeyMap(SDLK_ESCAPE, KEY_ESCAPE)); - - // asian letter keys missing - - KeyMap.push_back(SKeyMap(SDLK_SPACE, KEY_SPACE)); - KeyMap.push_back(SKeyMap(SDLK_PAGEUP, KEY_PRIOR)); - KeyMap.push_back(SKeyMap(SDLK_PAGEDOWN, KEY_NEXT)); - KeyMap.push_back(SKeyMap(SDLK_END, KEY_END)); - KeyMap.push_back(SKeyMap(SDLK_HOME, KEY_HOME)); - KeyMap.push_back(SKeyMap(SDLK_LEFT, KEY_LEFT)); - KeyMap.push_back(SKeyMap(SDLK_UP, KEY_UP)); - KeyMap.push_back(SKeyMap(SDLK_RIGHT, KEY_RIGHT)); - KeyMap.push_back(SKeyMap(SDLK_DOWN, KEY_DOWN)); - - // select missing - KeyMap.push_back(SKeyMap(SDLK_PRINT, KEY_PRINT)); - // execute missing - KeyMap.push_back(SKeyMap(SDLK_PRINT, KEY_SNAPSHOT)); - - KeyMap.push_back(SKeyMap(SDLK_INSERT, KEY_INSERT)); - KeyMap.push_back(SKeyMap(SDLK_DELETE, KEY_DELETE)); - KeyMap.push_back(SKeyMap(SDLK_HELP, KEY_HELP)); - - KeyMap.push_back(SKeyMap(SDLK_0, KEY_KEY_0)); - KeyMap.push_back(SKeyMap(SDLK_1, KEY_KEY_1)); - KeyMap.push_back(SKeyMap(SDLK_2, KEY_KEY_2)); - KeyMap.push_back(SKeyMap(SDLK_3, KEY_KEY_3)); - KeyMap.push_back(SKeyMap(SDLK_4, KEY_KEY_4)); - KeyMap.push_back(SKeyMap(SDLK_5, KEY_KEY_5)); - KeyMap.push_back(SKeyMap(SDLK_6, KEY_KEY_6)); - KeyMap.push_back(SKeyMap(SDLK_7, KEY_KEY_7)); - KeyMap.push_back(SKeyMap(SDLK_8, KEY_KEY_8)); - KeyMap.push_back(SKeyMap(SDLK_9, KEY_KEY_9)); - - KeyMap.push_back(SKeyMap(SDLK_a, KEY_KEY_A)); - KeyMap.push_back(SKeyMap(SDLK_b, KEY_KEY_B)); - KeyMap.push_back(SKeyMap(SDLK_c, KEY_KEY_C)); - KeyMap.push_back(SKeyMap(SDLK_d, KEY_KEY_D)); - KeyMap.push_back(SKeyMap(SDLK_e, KEY_KEY_E)); - KeyMap.push_back(SKeyMap(SDLK_f, KEY_KEY_F)); - KeyMap.push_back(SKeyMap(SDLK_g, KEY_KEY_G)); - KeyMap.push_back(SKeyMap(SDLK_h, KEY_KEY_H)); - KeyMap.push_back(SKeyMap(SDLK_i, KEY_KEY_I)); - KeyMap.push_back(SKeyMap(SDLK_j, KEY_KEY_J)); - KeyMap.push_back(SKeyMap(SDLK_k, KEY_KEY_K)); - KeyMap.push_back(SKeyMap(SDLK_l, KEY_KEY_L)); - KeyMap.push_back(SKeyMap(SDLK_m, KEY_KEY_M)); - KeyMap.push_back(SKeyMap(SDLK_n, KEY_KEY_N)); - KeyMap.push_back(SKeyMap(SDLK_o, KEY_KEY_O)); - KeyMap.push_back(SKeyMap(SDLK_p, KEY_KEY_P)); - KeyMap.push_back(SKeyMap(SDLK_q, KEY_KEY_Q)); - KeyMap.push_back(SKeyMap(SDLK_r, KEY_KEY_R)); - KeyMap.push_back(SKeyMap(SDLK_s, KEY_KEY_S)); - KeyMap.push_back(SKeyMap(SDLK_t, KEY_KEY_T)); - KeyMap.push_back(SKeyMap(SDLK_u, KEY_KEY_U)); - KeyMap.push_back(SKeyMap(SDLK_v, KEY_KEY_V)); - KeyMap.push_back(SKeyMap(SDLK_w, KEY_KEY_W)); - KeyMap.push_back(SKeyMap(SDLK_x, KEY_KEY_X)); - KeyMap.push_back(SKeyMap(SDLK_y, KEY_KEY_Y)); - KeyMap.push_back(SKeyMap(SDLK_z, KEY_KEY_Z)); - - KeyMap.push_back(SKeyMap(SDLK_LSUPER, KEY_LWIN)); - KeyMap.push_back(SKeyMap(SDLK_RSUPER, KEY_RWIN)); - // apps missing - KeyMap.push_back(SKeyMap(SDLK_POWER, KEY_SLEEP)); //?? - - KeyMap.push_back(SKeyMap(SDLK_KP0, KEY_NUMPAD0)); - KeyMap.push_back(SKeyMap(SDLK_KP1, KEY_NUMPAD1)); - KeyMap.push_back(SKeyMap(SDLK_KP2, KEY_NUMPAD2)); - KeyMap.push_back(SKeyMap(SDLK_KP3, KEY_NUMPAD3)); - KeyMap.push_back(SKeyMap(SDLK_KP4, KEY_NUMPAD4)); - KeyMap.push_back(SKeyMap(SDLK_KP5, KEY_NUMPAD5)); - KeyMap.push_back(SKeyMap(SDLK_KP6, KEY_NUMPAD6)); - KeyMap.push_back(SKeyMap(SDLK_KP7, KEY_NUMPAD7)); - KeyMap.push_back(SKeyMap(SDLK_KP8, KEY_NUMPAD8)); - KeyMap.push_back(SKeyMap(SDLK_KP9, KEY_NUMPAD9)); - KeyMap.push_back(SKeyMap(SDLK_KP_MULTIPLY, KEY_MULTIPLY)); - KeyMap.push_back(SKeyMap(SDLK_KP_PLUS, KEY_ADD)); -// KeyMap.push_back(SKeyMap(SDLK_KP_, KEY_SEPARATOR)); - KeyMap.push_back(SKeyMap(SDLK_KP_MINUS, KEY_SUBTRACT)); - KeyMap.push_back(SKeyMap(SDLK_KP_PERIOD, KEY_DECIMAL)); - KeyMap.push_back(SKeyMap(SDLK_KP_DIVIDE, KEY_DIVIDE)); - - KeyMap.push_back(SKeyMap(SDLK_F1, KEY_F1)); - KeyMap.push_back(SKeyMap(SDLK_F2, KEY_F2)); - KeyMap.push_back(SKeyMap(SDLK_F3, KEY_F3)); - KeyMap.push_back(SKeyMap(SDLK_F4, KEY_F4)); - KeyMap.push_back(SKeyMap(SDLK_F5, KEY_F5)); - KeyMap.push_back(SKeyMap(SDLK_F6, KEY_F6)); - KeyMap.push_back(SKeyMap(SDLK_F7, KEY_F7)); - KeyMap.push_back(SKeyMap(SDLK_F8, KEY_F8)); - KeyMap.push_back(SKeyMap(SDLK_F9, KEY_F9)); - KeyMap.push_back(SKeyMap(SDLK_F10, KEY_F10)); - KeyMap.push_back(SKeyMap(SDLK_F11, KEY_F11)); - KeyMap.push_back(SKeyMap(SDLK_F12, KEY_F12)); - KeyMap.push_back(SKeyMap(SDLK_F13, KEY_F13)); - KeyMap.push_back(SKeyMap(SDLK_F14, KEY_F14)); - KeyMap.push_back(SKeyMap(SDLK_F15, KEY_F15)); - // no higher F-keys - - KeyMap.push_back(SKeyMap(SDLK_NUMLOCK, KEY_NUMLOCK)); - KeyMap.push_back(SKeyMap(SDLK_SCROLLOCK, KEY_SCROLL)); - KeyMap.push_back(SKeyMap(SDLK_LSHIFT, KEY_LSHIFT)); - KeyMap.push_back(SKeyMap(SDLK_RSHIFT, KEY_RSHIFT)); - KeyMap.push_back(SKeyMap(SDLK_LCTRL, KEY_LCONTROL)); - KeyMap.push_back(SKeyMap(SDLK_RCTRL, KEY_RCONTROL)); - KeyMap.push_back(SKeyMap(SDLK_LALT, KEY_LMENU)); - KeyMap.push_back(SKeyMap(SDLK_RALT, KEY_RMENU)); - - KeyMap.push_back(SKeyMap(SDLK_PLUS, KEY_PLUS)); - KeyMap.push_back(SKeyMap(SDLK_COMMA, KEY_COMMA)); - KeyMap.push_back(SKeyMap(SDLK_MINUS, KEY_MINUS)); - KeyMap.push_back(SKeyMap(SDLK_PERIOD, KEY_PERIOD)); - - // some special keys missing - - KeyMap.sort(); -} - -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_SDL_DEVICE_ - diff --git a/irrlicht-1.6/source/Irrlicht/CIrrDeviceSDL.h b/irrlicht-1.6/source/Irrlicht/CIrrDeviceSDL.h deleted file mode 100644 index 94dd5dca6..000000000 --- a/irrlicht-1.6/source/Irrlicht/CIrrDeviceSDL.h +++ /dev/null @@ -1,236 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h -// This device code is based on the original SDL device implementation -// contributed by Shane Parker (sirshane). - -#ifndef __C_IRR_DEVICE_SDL_H_INCLUDED__ -#define __C_IRR_DEVICE_SDL_H_INCLUDED__ - -#include "IrrCompileConfig.h" - -#ifdef _IRR_COMPILE_WITH_SDL_DEVICE_ - -#include "IrrlichtDevice.h" -#include "CIrrDeviceStub.h" -#include "IImagePresenter.h" -#include "ICursorControl.h" - -#include <SDL/SDL.h> -#include <SDL/SDL_syswm.h> - -namespace irr -{ - - class CIrrDeviceSDL : public CIrrDeviceStub, video::IImagePresenter - { - public: - - //! constructor - CIrrDeviceSDL(const SIrrlichtCreationParameters& param); - - //! destructor - virtual ~CIrrDeviceSDL(); - - //! runs the device. Returns false if device wants to be deleted - virtual bool run(); - - //! pause execution temporarily - virtual void yield(); - - //! pause execution for a specified time - virtual void sleep(u32 timeMs, bool pauseTimer); - - //! sets the caption of the window - virtual void setWindowCaption(const wchar_t* text); - - //! returns if window is active. if not, nothing need to be drawn - virtual bool isWindowActive() const; - - //! returns if window has focus. - bool isWindowFocused() const; - - //! returns if window is minimized. - bool isWindowMinimized() const; - - //! returns color format of the window. - video::ECOLOR_FORMAT getColorFormat() const; - - //! presents a surface in the client area - virtual bool present(video::IImage* surface, void* windowId=0, core::rect<s32>* src=0); - - //! notifies the device that it should close itself - virtual void closeDevice(); - - //! \return Returns a pointer to a list with all video modes supported - video::IVideoModeList* getVideoModeList(); - - //! Sets if the window should be resizable in windowed mode. - virtual void setResizable(bool resize=false); - - //! Minimizes the window. - virtual void minimizeWindow(); - - //! Maximizes the window. - virtual void maximizeWindow(); - - //! Restores the window size. - virtual void restoreWindow(); - - //! Activate any joysticks, and generate events for them. - virtual bool activateJoysticks(core::array<SJoystickInfo> & joystickInfo); - - //! Set the current Gamma Value for the Display - virtual bool setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast ); - - //! Get the current Gamma Value for the Display - virtual bool getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast ); - - //! Get the device type - virtual E_DEVICE_TYPE getType() const - { - return EIDT_SDL; - } - - //! Implementation of the linux cursor control - class CCursorControl : public gui::ICursorControl - { - public: - - CCursorControl(CIrrDeviceSDL* dev) - : Device(dev), IsVisible(true) - { - } - - //! Changes the visible state of the mouse cursor. - virtual void setVisible(bool visible) - { - IsVisible = visible; - if ( visible ) - SDL_ShowCursor( SDL_ENABLE ); - else - SDL_ShowCursor( SDL_DISABLE ); - } - - //! Returns if the cursor is currently visible. - virtual bool isVisible() const - { - return IsVisible; - } - - //! Sets the new position of the cursor. - virtual void setPosition(const core::position2d<f32> &pos) - { - setPosition(pos.X, pos.Y); - } - - //! Sets the new position of the cursor. - virtual void setPosition(f32 x, f32 y) - { - setPosition((s32)(x*Device->Width), (s32)(y*Device->Height)); - } - - //! Sets the new position of the cursor. - virtual void setPosition(const core::position2d<s32> &pos) - { - setPosition(pos.X, pos.Y); - } - - //! Sets the new position of the cursor. - virtual void setPosition(s32 x, s32 y) - { - SDL_WarpMouse( x, y ); - } - - //! Returns the current position of the mouse cursor. - virtual core::position2d<s32> getPosition() - { - updateCursorPos(); - return CursorPos; - } - - //! Returns the current position of the mouse cursor. - virtual core::position2d<f32> getRelativePosition() - { - updateCursorPos(); - return core::position2d<f32>(CursorPos.X / (f32)Device->Width, - CursorPos.Y / (f32)Device->Height); - } - - virtual void setReferenceRect(core::rect<s32>* rect=0) - { - } - - private: - - void updateCursorPos() - { - CursorPos.X = Device->MouseX; - CursorPos.Y = Device->MouseY; - - if (CursorPos.X < 0) - CursorPos.X = 0; - if (CursorPos.X > (s32)Device->Width) - CursorPos.X = Device->Width; - if (CursorPos.Y < 0) - CursorPos.Y = 0; - if (CursorPos.Y > (s32)Device->Height) - CursorPos.Y = Device->Height; - } - - CIrrDeviceSDL* Device; - core::position2d<s32> CursorPos; - bool IsVisible; - }; - - private: - - //! create the driver - void createDriver(); - - bool createWindow(); - - void createKeyMap(); - - SDL_Surface* Screen; - int SDL_Flags; -#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) - core::array<SDL_Joystick*> Joysticks; -#endif - - s32 MouseX, MouseY; - u32 MouseButtonStates; - - u32 Width, Height; - - bool Close; - bool Resizable; - bool WindowHasFocus; - bool WindowMinimized; - - struct SKeyMap - { - SKeyMap() {} - SKeyMap(s32 x11, s32 win32) - : SDLKey(x11), Win32Key(win32) - { - } - - s32 SDLKey; - s32 Win32Key; - - bool operator<(const SKeyMap& o) const - { - return SDLKey<o.SDLKey; - } - }; - - core::array<SKeyMap> KeyMap; - SDL_SysWMinfo Info; - }; - -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_SDL_DEVICE_ -#endif // __C_IRR_DEVICE_SDL_H_INCLUDED__ - diff --git a/irrlicht-1.6/source/Irrlicht/CIrrDeviceStub.cpp b/irrlicht-1.6/source/Irrlicht/CIrrDeviceStub.cpp deleted file mode 100644 index f79b34bda..000000000 --- a/irrlicht-1.6/source/Irrlicht/CIrrDeviceStub.cpp +++ /dev/null @@ -1,353 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CIrrDeviceStub.h" -#include "ISceneManager.h" -#include "IEventReceiver.h" -#include "IFileSystem.h" -#include "IGUIEnvironment.h" -#include "os.h" -#include "IrrCompileConfig.h" -#include "CTimer.h" -#include "CLogger.h" -#include "irrString.h" - -namespace irr -{ -//! constructor -CIrrDeviceStub::CIrrDeviceStub(const SIrrlichtCreationParameters& params) -: IrrlichtDevice(), VideoDriver(0), GUIEnvironment(0), SceneManager(0), - Timer(0), CursorControl(0), UserReceiver(params.EventReceiver), Logger(0), Operator(0), - FileSystem(0), InputReceivingSceneManager(0), CreationParams(params) -{ - Timer = new CTimer(); - if (os::Printer::Logger) - { - os::Printer::Logger->grab(); - Logger = (CLogger*)os::Printer::Logger; - Logger->setReceiver(UserReceiver); - } - else - { - Logger = new CLogger(UserReceiver); - os::Printer::Logger = Logger; - } - - os::Printer::Logger = Logger; - - FileSystem = io::createFileSystem(); - core::stringc s = "Irrlicht Engine version "; - s.append(getVersion()); - os::Printer::log(s.c_str(), ELL_INFORMATION); - - checkVersion(params.SDK_version_do_not_use); -} - - -CIrrDeviceStub::~CIrrDeviceStub() -{ - FileSystem->drop(); - - if (GUIEnvironment) - GUIEnvironment->drop(); - - if (VideoDriver) - VideoDriver->drop(); - - if (SceneManager) - SceneManager->drop(); - - if (InputReceivingSceneManager) - InputReceivingSceneManager->drop(); - - if (CursorControl) - CursorControl->drop(); - - if (Operator) - Operator->drop(); - - CursorControl = 0; - - Timer->drop(); - - if (Logger->drop()) - os::Printer::Logger = 0; -} - - -void CIrrDeviceStub::createGUIAndScene() -{ - #ifdef _IRR_COMPILE_WITH_GUI_ - // create gui environment - GUIEnvironment = gui::createGUIEnvironment(FileSystem, VideoDriver, Operator); - #endif - - // create Scene manager - SceneManager = scene::createSceneManager(VideoDriver, FileSystem, CursorControl, GUIEnvironment); - - setEventReceiver(UserReceiver); -} - - -//! returns the video driver -video::IVideoDriver* CIrrDeviceStub::getVideoDriver() -{ - return VideoDriver; -} - - - -//! return file system -io::IFileSystem* CIrrDeviceStub::getFileSystem() -{ - return FileSystem; -} - - - -//! returns the gui environment -gui::IGUIEnvironment* CIrrDeviceStub::getGUIEnvironment() -{ - return GUIEnvironment; -} - - - -//! returns the scene manager -scene::ISceneManager* CIrrDeviceStub::getSceneManager() -{ - return SceneManager; -} - - -//! \return Returns a pointer to the ITimer object. With it the -//! current Time can be received. -ITimer* CIrrDeviceStub::getTimer() -{ - return Timer; -} - - -//! Returns the version of the engine. -const char* CIrrDeviceStub::getVersion() const -{ - return IRRLICHT_SDK_VERSION; -} - -//! \return Returns a pointer to the mouse cursor control interface. -gui::ICursorControl* CIrrDeviceStub::getCursorControl() -{ - return CursorControl; -} - - -//! \return Returns a pointer to a list with all video modes supported -//! by the gfx adapter. -video::IVideoModeList* CIrrDeviceStub::getVideoModeList() -{ - return &VideoModeList; -} - - -//! checks version of sdk and prints warning if there might be a problem -bool CIrrDeviceStub::checkVersion(const char* version) -{ - if (strcmp(getVersion(), version)) - { - core::stringc w; - w = "Warning: The library version of the Irrlicht Engine ("; - w += getVersion(); - w += ") does not match the version the application was compiled with ("; - w += version; - w += "). This may cause problems."; - os::Printer::log(w.c_str(), ELL_WARNING); - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; - } - - return true; -} - - -//! Compares to the last call of this function to return double and triple clicks. -u32 CIrrDeviceStub::checkSuccessiveClicks(s32 mouseX, s32 mouseY) -{ - const s32 MAX_MOUSEMOVE = 3; - - irr::u32 clickTime = getTimer()->getRealTime(); - - if ( (clickTime-MouseMultiClicks.LastClickTime) < MouseMultiClicks.DoubleClickTime - && core::abs_(MouseMultiClicks.LastClick.X - mouseX ) <= MAX_MOUSEMOVE - && core::abs_(MouseMultiClicks.LastClick.Y - mouseY ) <= MAX_MOUSEMOVE - && MouseMultiClicks.CountSuccessiveClicks < 3 ) - { - ++MouseMultiClicks.CountSuccessiveClicks; - } - else - { - MouseMultiClicks.CountSuccessiveClicks = 1; - } - - MouseMultiClicks.LastClickTime = clickTime; - MouseMultiClicks.LastClick.X = mouseX; - MouseMultiClicks.LastClick.Y = mouseY; - - return MouseMultiClicks.CountSuccessiveClicks; -} - - -//! send the event to the right receiver -bool CIrrDeviceStub::postEventFromUser(const SEvent& event) -{ - bool absorbed = false; - - if (UserReceiver) - absorbed = UserReceiver->OnEvent(event); - - if (!absorbed && GUIEnvironment) - absorbed = GUIEnvironment->postEventFromUser(event); - - scene::ISceneManager* inputReceiver = InputReceivingSceneManager; - if (!inputReceiver) - inputReceiver = SceneManager; - - if (!absorbed && inputReceiver) - absorbed = inputReceiver->postEventFromUser(event); - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return absorbed; -} - - -//! Sets a new event receiver to receive events -void CIrrDeviceStub::setEventReceiver(IEventReceiver* receiver) -{ - UserReceiver = receiver; - Logger->setReceiver(receiver); - if (GUIEnvironment) - GUIEnvironment->setUserEventReceiver(receiver); -} - - -//! Returns poinhter to the current event receiver. Returns 0 if there is none. -IEventReceiver* CIrrDeviceStub::getEventReceiver() -{ - return UserReceiver; -} - - -//! \return Returns a pointer to the logger. -ILogger* CIrrDeviceStub::getLogger() -{ - return Logger; -} - - -//! Returns the operation system opertator object. -IOSOperator* CIrrDeviceStub::getOSOperator() -{ - return Operator; -} - - -//! Sets the input receiving scene manager. -void CIrrDeviceStub::setInputReceivingSceneManager(scene::ISceneManager* sceneManager) -{ - if (sceneManager) - sceneManager->grab(); - if (InputReceivingSceneManager) - InputReceivingSceneManager->drop(); - - InputReceivingSceneManager = sceneManager; -} - - -//! Checks if the window is running in fullscreen mode -bool CIrrDeviceStub::isFullscreen() const -{ - return CreationParams.Fullscreen; -} - - -//! returns color format -video::ECOLOR_FORMAT CIrrDeviceStub::getColorFormat() const -{ - return video::ECF_R5G6B5; -} - -//! No-op in this implementation -bool CIrrDeviceStub::activateJoysticks(core::array<SJoystickInfo> & joystickInfo) -{ - return false; -} - -/*! -*/ -void CIrrDeviceStub::calculateGammaRamp ( u16 *ramp, f32 gamma, f32 relativebrightness, f32 relativecontrast ) -{ - s32 i; - s32 value; - s32 rbright = (s32) ( relativebrightness * (65535.f / 4 ) ); - f32 rcontrast = 1.f / (255.f - ( relativecontrast * 127.5f ) ); - - gamma = gamma > 0.f ? 1.0f / gamma : 0.f; - - for ( i = 0; i < 256; ++i ) - { - value = (s32)(pow( rcontrast * i, gamma)*65535.f + 0.5f ); - ramp[i] = (u16) core::s32_clamp ( value + rbright, 0, 65535 ); - } - -} - -void CIrrDeviceStub::calculateGammaFromRamp ( f32 &gamma, const u16 *ramp ) -{ - /* The following is adapted from a post by Garrett Bass on OpenGL - Gamedev list, March 4, 2000. - */ - f32 sum = 0.0; - s32 i, count = 0; - - gamma = 1.0; - for ( i = 1; i < 256; ++i ) { - if ( (ramp[i] != 0) && (ramp[i] != 65535) ) { - f32 B = (f32)i / 256.f; - f32 A = ramp[i] / 65535.f; - sum += (f32) ( logf(A) / logf(B) ); - count++; - } - } - if ( count && sum ) { - gamma = 1.0f / (sum / count); - } - -} - -//! Set the current Gamma Value for the Display -bool CIrrDeviceStub::setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast ) -{ - return false; -} - -//! Get the current Gamma Value for the Display -bool CIrrDeviceStub::getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast ) -{ - return false; -} - -//! Set the maximal elapsed time between 2 clicks to generate doubleclicks for the mouse. It also affects tripleclick behaviour. -void CIrrDeviceStub::setDoubleClickTime( u32 timeMs ) -{ - MouseMultiClicks.DoubleClickTime = timeMs; -} - -//! Get the maximal elapsed time between 2 clicks to generate double- and tripleclicks for the mouse. -u32 CIrrDeviceStub::getDoubleClickTime() const -{ - return MouseMultiClicks.DoubleClickTime; -} - - -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CIrrDeviceStub.h b/irrlicht-1.6/source/Irrlicht/CIrrDeviceStub.h deleted file mode 100644 index 261097274..000000000 --- a/irrlicht-1.6/source/Irrlicht/CIrrDeviceStub.h +++ /dev/null @@ -1,170 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_IRR_DEVICE_STUB_H_INCLUDED__ -#define __C_IRR_DEVICE_STUB_H_INCLUDED__ - -#include "IrrlichtDevice.h" -#include "IImagePresenter.h" -#include "SIrrCreationParameters.h" -#include "CVideoModeList.h" - -namespace irr -{ - // lots of prototypes: - class ILogger; - class CLogger; - - namespace gui - { - class IGUIEnvironment; - IGUIEnvironment* createGUIEnvironment(io::IFileSystem* fs, - video::IVideoDriver* Driver, IOSOperator* op); - } - - namespace scene - { - ISceneManager* createSceneManager(video::IVideoDriver* driver, - io::IFileSystem* fs, gui::ICursorControl* cc, gui::IGUIEnvironment *gui); - } - - namespace io - { - IFileSystem* createFileSystem(); - } - - namespace video - { - IVideoDriver* createSoftwareDriver(const core::dimension2d<u32>& windowSize, - bool fullscreen, io::IFileSystem* io, - video::IImagePresenter* presenter); - IVideoDriver* createSoftwareDriver2(const core::dimension2d<u32>& windowSize, - bool fullscreen, io::IFileSystem* io, - video::IImagePresenter* presenter); - IVideoDriver* createNullDriver(io::IFileSystem* io, const core::dimension2d<u32>& screenSize); - } - - - - //! Stub for an Irrlicht Device implementation - class CIrrDeviceStub : public IrrlichtDevice - { - public: - - //! constructor - CIrrDeviceStub(const SIrrlichtCreationParameters& param); - - //! destructor - virtual ~CIrrDeviceStub(); - - //! returns the video driver - virtual video::IVideoDriver* getVideoDriver(); - - //! return file system - virtual io::IFileSystem* getFileSystem(); - - //! returns the gui environment - virtual gui::IGUIEnvironment* getGUIEnvironment(); - - //! returns the scene manager - virtual scene::ISceneManager* getSceneManager(); - - //! \return Returns a pointer to the mouse cursor control interface. - virtual gui::ICursorControl* getCursorControl(); - - //! Returns a pointer to a list with all video modes supported by the gfx adapter. - virtual video::IVideoModeList* getVideoModeList(); - - //! Returns a pointer to the ITimer object. With it the current Time can be received. - virtual ITimer* getTimer(); - - //! Returns the version of the engine. - virtual const char* getVersion() const; - - //! send the event to the right receiver - virtual bool postEventFromUser(const SEvent& event); - - //! Sets a new event receiver to receive events - virtual void setEventReceiver(IEventReceiver* receiver); - - //! Returns pointer to the current event receiver. Returns 0 if there is none. - virtual IEventReceiver* getEventReceiver(); - - //! Sets the input receiving scene manager. - /** If set to null, the main scene manager (returned by GetSceneManager()) will receive the input */ - virtual void setInputReceivingSceneManager(scene::ISceneManager* sceneManager); - - //! Returns a pointer to the logger. - virtual ILogger* getLogger(); - - //! Returns the operation system opertator object. - virtual IOSOperator* getOSOperator(); - - //! Checks if the window is running in fullscreen mode. - virtual bool isFullscreen() const; - - //! get color format of the current window - virtual video::ECOLOR_FORMAT getColorFormat() const; - - //! Activate any joysticks, and generate events for them. - virtual bool activateJoysticks(core::array<SJoystickInfo> & joystickInfo); - - //! Set the current Gamma Value for the Display - virtual bool setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast ); - - //! Get the current Gamma Value for the Display - virtual bool getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast ); - - //! Set the maximal elapsed time between 2 clicks to generate doubleclicks for the mouse. It also affects tripleclick behaviour. - //! When set to 0 no double- and tripleclicks will be generated. - virtual void setDoubleClickTime( u32 timeMs ); - - //! Get the maximal elapsed time between 2 clicks to generate double- and tripleclicks for the mouse. - virtual u32 getDoubleClickTime() const; - - protected: - - void createGUIAndScene(); - - //! checks version of SDK and prints warning if there might be a problem - bool checkVersion(const char* version); - - //! Compares to the last call of this function to return double and triple clicks. - //! \return Returns only 1,2 or 3. A 4th click will start with 1 again. - virtual u32 checkSuccessiveClicks(s32 mouseX, s32 mouseY); - - void calculateGammaRamp ( u16 *ramp, f32 gamma, f32 relativebrightness, f32 relativecontrast ); - void calculateGammaFromRamp ( f32 &gamma, const u16 *ramp ); - - video::IVideoDriver* VideoDriver; - gui::IGUIEnvironment* GUIEnvironment; - scene::ISceneManager* SceneManager; - ITimer* Timer; - gui::ICursorControl* CursorControl; - IEventReceiver* UserReceiver; - CLogger* Logger; - IOSOperator* Operator; - io::IFileSystem* FileSystem; - scene::ISceneManager* InputReceivingSceneManager; - video::CVideoModeList VideoModeList; - SIrrlichtCreationParameters CreationParams; - - struct SMouseMultiClicks - { - SMouseMultiClicks() - : DoubleClickTime(500), CountSuccessiveClicks(0), LastClickTime(0) - {} - - u32 DoubleClickTime; - u32 CountSuccessiveClicks; - u32 LastClickTime; - core::position2di LastClick; - }; - SMouseMultiClicks MouseMultiClicks; - }; - -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CIrrDeviceWin32.cpp b/irrlicht-1.6/source/Irrlicht/CIrrDeviceWin32.cpp deleted file mode 100644 index 230441b7c..000000000 --- a/irrlicht-1.6/source/Irrlicht/CIrrDeviceWin32.cpp +++ /dev/null @@ -1,1160 +0,0 @@ -// Copyright (C) 2002-2009 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_WINDOWS_DEVICE_ - -#include "CIrrDeviceWin32.h" -#include "IEventReceiver.h" -#include "irrList.h" -#include "os.h" - -#include "CTimer.h" -#include "irrString.h" -#include "COSOperator.h" -#include "dimension2d.h" -#include <winuser.h> - -namespace irr -{ - namespace video - { - #ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ - IVideoDriver* createDirectX8Driver(const core::dimension2d<u32>& screenSize, HWND window, - u32 bits, bool fullscreen, bool stencilbuffer, io::IFileSystem* io, - bool pureSoftware, bool highPrecisionFPU, bool vsync, u8 antiAlias); - #endif - - #ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ - IVideoDriver* createDirectX9Driver(const core::dimension2d<u32>& screenSize, HWND window, - u32 bits, bool fullscreen, bool stencilbuffer, io::IFileSystem* io, - bool pureSoftware, bool highPrecisionFPU, bool vsync, u8 antiAlias); - #endif - - #ifdef _IRR_COMPILE_WITH_OPENGL_ - IVideoDriver* createOpenGLDriver(const irr::SIrrlichtCreationParameters& params, - io::IFileSystem* io, CIrrDeviceWin32* device); - #endif - } -} // end namespace irr - - -struct SEnvMapper -{ - HWND hWnd; - irr::CIrrDeviceWin32* irrDev; -}; - -irr::core::list<SEnvMapper> EnvMap; - -SEnvMapper* getEnvMapperFromHWnd(HWND hWnd) -{ - irr::core::list<SEnvMapper>::Iterator it = EnvMap.begin(); - for (; it!= EnvMap.end(); ++it) - if ((*it).hWnd == hWnd) - return &(*it); - - return 0; -} - - -irr::CIrrDeviceWin32* getDeviceFromHWnd(HWND hWnd) -{ - irr::core::list<SEnvMapper>::Iterator it = EnvMap.begin(); - for (; it!= EnvMap.end(); ++it) - if ((*it).hWnd == hWnd) - return (*it).irrDev; - - return 0; -} - - -LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - #ifndef WM_MOUSEWHEEL - #define WM_MOUSEWHEEL 0x020A - #endif - #ifndef WHEEL_DELTA - #define WHEEL_DELTA 120 - #endif - - irr::CIrrDeviceWin32* dev = 0; - irr::SEvent event; - - static irr::s32 ClickCount=0; - if (GetCapture() != hWnd && ClickCount > 0) - ClickCount = 0; - - - struct messageMap - { - irr::s32 group; - UINT winMessage; - irr::s32 irrMessage; - }; - - static messageMap mouseMap[] = - { - {0, WM_LBUTTONDOWN, irr::EMIE_LMOUSE_PRESSED_DOWN}, - {1, WM_LBUTTONUP, irr::EMIE_LMOUSE_LEFT_UP}, - {0, WM_RBUTTONDOWN, irr::EMIE_RMOUSE_PRESSED_DOWN}, - {1, WM_RBUTTONUP, irr::EMIE_RMOUSE_LEFT_UP}, - {0, WM_MBUTTONDOWN, irr::EMIE_MMOUSE_PRESSED_DOWN}, - {1, WM_MBUTTONUP, irr::EMIE_MMOUSE_LEFT_UP}, - {2, WM_MOUSEMOVE, irr::EMIE_MOUSE_MOVED}, - {3, WM_MOUSEWHEEL, irr::EMIE_MOUSE_WHEEL}, - {-1, 0, 0} - }; - - // handle grouped events - messageMap * m = mouseMap; - while ( m->group >=0 && m->winMessage != message ) - m += 1; - - if ( m->group >= 0 ) - { - if ( m->group == 0 ) // down - { - ClickCount++; - SetCapture(hWnd); - } - else - if ( m->group == 1 ) // up - { - ClickCount--; - if (ClickCount<1) - { - ClickCount=0; - ReleaseCapture(); - } - } - - event.EventType = irr::EET_MOUSE_INPUT_EVENT; - event.MouseInput.Event = (irr::EMOUSE_INPUT_EVENT) m->irrMessage; - event.MouseInput.X = (short)LOWORD(lParam); - event.MouseInput.Y = (short)HIWORD(lParam); - event.MouseInput.Shift = ((LOWORD(wParam) & MK_SHIFT) != 0); - event.MouseInput.Control = ((LOWORD(wParam) & MK_CONTROL) != 0); - // left and right mouse buttons - event.MouseInput.ButtonStates = wParam & ( MK_LBUTTON | MK_RBUTTON); - // middle and extra buttons - if (wParam & MK_MBUTTON) - event.MouseInput.ButtonStates |= irr::EMBSM_MIDDLE; -#if(_WIN32_WINNT >= 0x0500) - if (wParam & MK_XBUTTON1) - event.MouseInput.ButtonStates |= irr::EMBSM_EXTRA1; - if (wParam & MK_XBUTTON2) - event.MouseInput.ButtonStates |= irr::EMBSM_EXTRA2; -#endif - event.MouseInput.Wheel = 0.f; - - // wheel - if ( m->group == 3 ) - { - POINT p; // fixed by jox - p.x = 0; p.y = 0; - ClientToScreen(hWnd, &p); - event.MouseInput.X -= p.x; - event.MouseInput.Y -= p.y; - event.MouseInput.Wheel = ((irr::f32)((short)HIWORD(wParam))) / (irr::f32)WHEEL_DELTA; - } - - dev = getDeviceFromHWnd(hWnd); - if (dev) - { - dev->postEventFromUser(event); - - if ( event.MouseInput.Event == irr::EMIE_LMOUSE_PRESSED_DOWN ) - { - irr::u32 clicks = dev->checkSuccessiveClicks(event.MouseInput.X, event.MouseInput.Y); - if ( clicks == 2 ) - { - event.MouseInput.Event = irr::EMIE_MOUSE_DOUBLE_CLICK; - dev->postEventFromUser(event); - } - else if ( clicks == 3 ) - { - event.MouseInput.Event = irr::EMIE_MOUSE_TRIPLE_CLICK; - dev->postEventFromUser(event); - } - } - } - return 0; - } - - switch (message) - { - case WM_PAINT: - { - PAINTSTRUCT ps; - BeginPaint(hWnd, &ps); - EndPaint(hWnd, &ps); - } - return 0; - - case WM_ERASEBKGND: - return 0; - - case WM_SYSKEYDOWN: - case WM_SYSKEYUP: - case WM_KEYDOWN: - case WM_KEYUP: - { - BYTE allKeys[256]; - - event.EventType = irr::EET_KEY_INPUT_EVENT; - event.KeyInput.Key = (irr::EKEY_CODE)wParam; - event.KeyInput.PressedDown = (message==WM_KEYDOWN || message == WM_SYSKEYDOWN); - - WORD KeyAsc=0; - GetKeyboardState(allKeys); - ToAscii((UINT)wParam,(UINT)lParam,allKeys,&KeyAsc,0); - - if (event.KeyInput.Key==irr::KEY_SHIFT) - { - if ((allKeys[VK_LSHIFT] & 0x80)!=0) - event.KeyInput.Key=irr::KEY_LSHIFT; - else if ((allKeys[VK_RSHIFT] & 0x80)!=0) - event.KeyInput.Key=irr::KEY_RSHIFT; - } - event.KeyInput.Shift = ((allKeys[VK_SHIFT] & 0x80)!=0); - event.KeyInput.Control = ((allKeys[VK_CONTROL] & 0x80)!=0); - event.KeyInput.Char = (KeyAsc & 0x00ff); //KeyAsc >= 0 ? KeyAsc : 0; - - dev = getDeviceFromHWnd(hWnd); - if (dev) - dev->postEventFromUser(event); - - if (message == WM_SYSKEYDOWN || message == WM_SYSKEYUP) - return DefWindowProc(hWnd, message, wParam, lParam); - else - return 0; - } - - case WM_SIZE: - { - // resize - dev = getDeviceFromHWnd(hWnd); - if (dev) - dev->OnResized(); - } - return 0; - - case WM_DESTROY: - PostQuitMessage(0); - return 0; - - case WM_SYSCOMMAND: - // prevent screensaver or monitor powersave mode from starting - if ((wParam & 0xFFF0) == SC_SCREENSAVE || - (wParam & 0xFFF0) == SC_MONITORPOWER) - return 0; - break; - - case WM_USER: - event.EventType = irr::EET_USER_EVENT; - event.UserEvent.UserData1 = (irr::s32)wParam; - event.UserEvent.UserData2 = (irr::s32)lParam; - dev = getDeviceFromHWnd(hWnd); - - if (dev) - dev->postEventFromUser(event); - - return 0; - } - return DefWindowProc(hWnd, message, wParam, lParam); -} - - -namespace irr -{ - -//! constructor -CIrrDeviceWin32::CIrrDeviceWin32(const SIrrlichtCreationParameters& params) -: CIrrDeviceStub(params), HWnd(0), ChangedToFullScreen(false), - IsNonNTWindows(false), Resized(false), - ExternalWindow(false), Win32CursorControl(0) -{ - #ifdef _DEBUG - setDebugName("CIrrDeviceWin32"); - #endif - - // get windows version and create OS operator - core::stringc winversion; - getWindowsVersion(winversion); - Operator = new COSOperator(winversion.c_str()); - os::Printer::log(winversion.c_str(), ELL_INFORMATION); - - // get handle to exe file - HINSTANCE hInstance = GetModuleHandle(0); - - // create the window if we need to and we do not use the null device - if (!CreationParams.WindowId && CreationParams.DriverType != video::EDT_NULL) - { - const c8* ClassName = "CIrrDeviceWin32"; - - // Register Class - WNDCLASSEX wcex; - wcex.cbSize = sizeof(WNDCLASSEX); - wcex.style = CS_HREDRAW | CS_VREDRAW; - wcex.lpfnWndProc = WndProc; - wcex.cbClsExtra = 0; - wcex.cbWndExtra = 0; - wcex.hInstance = hInstance; - wcex.hIcon = NULL; - wcex.hCursor = LoadCursor(NULL, IDC_ARROW); - wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); - wcex.lpszMenuName = 0; - wcex.lpszClassName = ClassName; - wcex.hIconSm = 0; - - // if there is an icon, load it - wcex.hIcon = (HICON)LoadImage(hInstance, "irrlicht.ico", IMAGE_ICON, 0,0, LR_LOADFROMFILE); - - RegisterClassEx(&wcex); - - // calculate client size - - RECT clientSize; - clientSize.top = 0; - clientSize.left = 0; - clientSize.right = CreationParams.WindowSize.Width; - clientSize.bottom = CreationParams.WindowSize.Height; - - DWORD style = WS_POPUP; - - if (!CreationParams.Fullscreen) - style = WS_SYSMENU | WS_BORDER | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; - - AdjustWindowRect(&clientSize, style, FALSE); - - const s32 realWidth = clientSize.right - clientSize.left; - const s32 realHeight = clientSize.bottom - clientSize.top; - - s32 windowLeft = (GetSystemMetrics(SM_CXSCREEN) - realWidth) / 2; - s32 windowTop = (GetSystemMetrics(SM_CYSCREEN) - realHeight) / 2; - - if (CreationParams.Fullscreen) - { - windowLeft = 0; - windowTop = 0; - } - - // create window - - HWnd = CreateWindow( ClassName, "", style, windowLeft, windowTop, - realWidth, realHeight, NULL, NULL, hInstance, NULL); - CreationParams.WindowId = HWnd; - - ShowWindow(HWnd, SW_SHOW); - UpdateWindow(HWnd); - - // fix ugly ATI driver bugs. Thanks to ariaci - MoveWindow(HWnd, windowLeft, windowTop, realWidth, realHeight, TRUE); - } - else if (CreationParams.WindowId) - { - // attach external window - HWnd = static_cast<HWND>(CreationParams.WindowId); - RECT r; - GetWindowRect(HWnd, &r); - CreationParams.WindowSize.Width = r.right - r.left; - CreationParams.WindowSize.Height = r.bottom - r.top; - CreationParams.Fullscreen = false; - ExternalWindow = true; - } - - // create cursor control - - Win32CursorControl = new CCursorControl(CreationParams.WindowSize, HWnd, CreationParams.Fullscreen); - CursorControl = Win32CursorControl; - - // initialize doubleclicks with system values - MouseMultiClicks.DoubleClickTime = GetDoubleClickTime(); - - // create driver - - createDriver(); - - if (VideoDriver) - createGUIAndScene(); - - // register environment - - SEnvMapper em; - em.irrDev = this; - em.hWnd = HWnd; - EnvMap.push_back(em); - - // set this as active window - SetActiveWindow(HWnd); - SetForegroundWindow(HWnd); -} - - -//! destructor -CIrrDeviceWin32::~CIrrDeviceWin32() -{ - // unregister environment - - irr::core::list<SEnvMapper>::Iterator it = EnvMap.begin(); - for (; it!= EnvMap.end(); ++it) - { - if ((*it).hWnd == HWnd) - { - EnvMap.erase(it); - break; - } - } - - if (ChangedToFullScreen) - ChangeDisplaySettings(NULL,0); -} - - -//! create the driver -void CIrrDeviceWin32::createDriver() -{ - switch(CreationParams.DriverType) - { - case video::EDT_DIRECT3D8: - #ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ - - VideoDriver = video::createDirectX8Driver(CreationParams.WindowSize, HWnd, - CreationParams.Bits, CreationParams.Fullscreen, CreationParams.Stencilbuffer, - FileSystem, false, CreationParams.HighPrecisionFPU, CreationParams.Vsync, - CreationParams.AntiAlias); - - if (!VideoDriver) - { - os::Printer::log("Could not create DIRECT3D8 Driver.", ELL_ERROR); - } - #else - os::Printer::log("DIRECT3D8 Driver was not compiled into this dll. Try another one.", ELL_ERROR); - #endif // _IRR_COMPILE_WITH_DIRECT3D_8_ - - break; - - case video::EDT_DIRECT3D9: - #ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ - - VideoDriver = video::createDirectX9Driver(CreationParams.WindowSize, HWnd, - CreationParams.Bits, CreationParams.Fullscreen, CreationParams.Stencilbuffer, - FileSystem, false, CreationParams.HighPrecisionFPU, CreationParams.Vsync, - CreationParams.AntiAlias); - - if (!VideoDriver) - { - os::Printer::log("Could not create DIRECT3D9 Driver.", ELL_ERROR); - } - #else - os::Printer::log("DIRECT3D9 Driver was not compiled into this dll. Try another one.", ELL_ERROR); - #endif // _IRR_COMPILE_WITH_DIRECT3D_9_ - - break; - - case video::EDT_OPENGL: - - #ifdef _IRR_COMPILE_WITH_OPENGL_ - - if (CreationParams.Fullscreen) - switchToFullScreen(CreationParams.WindowSize.Width, CreationParams.WindowSize.Height, CreationParams.Bits); - - VideoDriver = video::createOpenGLDriver(CreationParams, FileSystem, this); - if (!VideoDriver) - { - os::Printer::log("Could not create OpenGL driver.", ELL_ERROR); - } - #else - os::Printer::log("OpenGL driver was not compiled in.", ELL_ERROR); - #endif - break; - - case video::EDT_SOFTWARE: - - #ifdef _IRR_COMPILE_WITH_SOFTWARE_ - if (CreationParams.Fullscreen) - switchToFullScreen(CreationParams.WindowSize.Width, CreationParams.WindowSize.Height, CreationParams.Bits); - - VideoDriver = video::createSoftwareDriver(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this); - #else - os::Printer::log("Software driver was not compiled in.", ELL_ERROR); - #endif - - break; - - case video::EDT_BURNINGSVIDEO: - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - if (CreationParams.Fullscreen) - switchToFullScreen(CreationParams.WindowSize.Width, CreationParams.WindowSize.Height, CreationParams.Bits); - - VideoDriver = video::createSoftwareDriver2(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this); - #else - os::Printer::log("Burning's Video driver was not compiled in.", ELL_ERROR); - #endif - break; - - case video::EDT_NULL: - // create null driver - VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize); - break; - - default: - os::Printer::log("Unable to create video driver of unknown type.", ELL_ERROR); - break; - } -} - - -//! runs the device. Returns false if device wants to be deleted -bool CIrrDeviceWin32::run() -{ - os::Timer::tick(); - - MSG msg; - - bool quit = false; - - while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) - { - TranslateMessage(&msg); - - if (ExternalWindow && msg.hwnd == HWnd) - WndProc(HWnd, msg.message, msg.wParam, msg.lParam); - else - DispatchMessage(&msg); - - if (msg.message == WM_QUIT) - quit = true; - } - - if (!quit) - resizeIfNecessary(); - - if(!quit) - pollJoysticks(); - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return !quit; -} - - -//! Pause the current process for the minimum time allowed only to allow other processes to execute -void CIrrDeviceWin32::yield() -{ - Sleep(1); -} - -//! Pause execution and let other processes to run for a specified amount of time. -void CIrrDeviceWin32::sleep(u32 timeMs, bool pauseTimer) -{ - const bool wasStopped = Timer ? Timer->isStopped() : true; - if (pauseTimer && !wasStopped) - Timer->stop(); - - Sleep(timeMs); - - if (pauseTimer && !wasStopped) - Timer->start(); -} - - -void CIrrDeviceWin32::resizeIfNecessary() -{ - if (!Resized) - return; - - RECT r; - GetClientRect(HWnd, &r); - - char tmp[255]; - - if (r.right < 2 || r.bottom < 2) - { - sprintf(tmp, "Ignoring resize operation to (%ld %ld)", r.right, r.bottom); - os::Printer::log(tmp); - } - else - { - sprintf(tmp, "Resizing window (%ld %ld)", r.right, r.bottom); - os::Printer::log(tmp); - - getVideoDriver()->OnResize(irr::core::dimension2du((u32)r.right, (u32)r.bottom)); - getWin32CursorControl()->OnResize(getVideoDriver()->getScreenSize()); - } - - Resized = false; -} - - -//! sets the caption of the window -void CIrrDeviceWin32::setWindowCaption(const wchar_t* text) -{ - DWORD dwResult; - if (IsNonNTWindows) - { - const core::stringc s = text; -#ifdef _WIN64 - SetWindowTextA(HWnd, s.c_str()); -#else - SendMessageTimeout(HWnd, WM_SETTEXT, 0, - reinterpret_cast<LPARAM>(s.c_str()), - SMTO_ABORTIFHUNG, 2000, &dwResult); -#endif - } - else - { -#ifdef _WIN64 - SetWindowTextW(HWnd, text); -#else - SendMessageTimeoutW(HWnd, WM_SETTEXT, 0, - reinterpret_cast<LPARAM>(text), - SMTO_ABORTIFHUNG, 2000, &dwResult); -#endif - } -} - - -//! presents a surface in the client area -bool CIrrDeviceWin32::present(video::IImage* image, void* windowId, core::rect<s32>* src) -{ - HWND hwnd = HWnd; - if ( windowId ) - hwnd = reinterpret_cast<HWND>(windowId); - - HDC dc = GetDC(hwnd); - - if ( dc ) - { - RECT rect; - GetClientRect(hwnd, &rect); - const void* memory = (const void *)image->lock(); - - BITMAPV4HEADER bi; - ZeroMemory (&bi, sizeof(bi)); - bi.bV4Size = sizeof(BITMAPINFOHEADER); - bi.bV4BitCount = (WORD)image->getBitsPerPixel(); - bi.bV4Planes = 1; - bi.bV4Width = image->getDimension().Width; - bi.bV4Height = -((s32)image->getDimension().Height); - bi.bV4V4Compression = BI_BITFIELDS; - bi.bV4AlphaMask = image->getAlphaMask(); - bi.bV4RedMask = image->getRedMask(); - bi.bV4GreenMask = image->getGreenMask(); - bi.bV4BlueMask = image->getBlueMask(); - - if ( src ) - { - StretchDIBits(dc, 0,0, rect.right, rect.bottom, - src->UpperLeftCorner.X, src->UpperLeftCorner.Y, - src->getWidth(), src->getHeight(), - memory, (const BITMAPINFO*)(&bi), DIB_RGB_COLORS, SRCCOPY); - } - else - { - StretchDIBits(dc, 0,0, rect.right, rect.bottom, - 0, 0, image->getDimension().Width, image->getDimension().Height, - memory, (const BITMAPINFO*)(&bi), DIB_RGB_COLORS, SRCCOPY); - } - - image->unlock(); - - ReleaseDC(hwnd, dc); - } - return true; -} - - -//! notifies the device that it should close itself -void CIrrDeviceWin32::closeDevice() -{ - MSG msg; - PeekMessage(&msg, NULL, WM_QUIT, WM_QUIT, PM_REMOVE); - PostQuitMessage(0); - PeekMessage(&msg, NULL, WM_QUIT, WM_QUIT, PM_REMOVE); - DestroyWindow(HWnd); -} - - -//! returns if window is active. if not, nothing needs to be drawn -bool CIrrDeviceWin32::isWindowActive() const -{ - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return (GetActiveWindow() == HWnd); -} - - -//! returns if window has focus -bool CIrrDeviceWin32::isWindowFocused() const -{ - bool ret = (GetFocus() == HWnd); - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return ret; -} - - -//! returns if window is minimized -bool CIrrDeviceWin32::isWindowMinimized() const -{ - WINDOWPLACEMENT plc; - plc.length=sizeof(WINDOWPLACEMENT); - bool ret=false; - if (GetWindowPlacement(HWnd,&plc)) - ret=(plc.showCmd & SW_SHOWMINIMIZED)!=0; - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return ret; -} - - -//! switches to fullscreen -bool CIrrDeviceWin32::switchToFullScreen(s32 width, s32 height, s32 bits) -{ - DEVMODE dm; - memset(&dm, 0, sizeof(dm)); - dm.dmSize = sizeof(dm); - // use default values from current setting - EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm); - dm.dmPelsWidth = width; - dm.dmPelsHeight = height; - dm.dmBitsPerPel = bits; - dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY; - - LONG res = ChangeDisplaySettings(&dm, CDS_FULLSCREEN); - if (res != DISP_CHANGE_SUCCESSFUL) - { // try again without forcing display frequency - dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; - res = ChangeDisplaySettings(&dm, CDS_FULLSCREEN); - } - - bool ret = false; - switch(res) - { - case DISP_CHANGE_SUCCESSFUL: - ChangedToFullScreen = true; - ret = true; - break; - case DISP_CHANGE_RESTART: - os::Printer::log("Switch to fullscreen: The computer must be restarted in order for the graphics mode to work.", ELL_ERROR); - break; - case DISP_CHANGE_BADFLAGS: - os::Printer::log("Switch to fullscreen: An invalid set of flags was passed in.", ELL_ERROR); - break; - case DISP_CHANGE_BADPARAM: - os::Printer::log("Switch to fullscreen: An invalid parameter was passed in. This can include an invalid flag or combination of flags.", ELL_ERROR); - break; - case DISP_CHANGE_FAILED: - os::Printer::log("Switch to fullscreen: The display driver failed the specified graphics mode.", ELL_ERROR); - break; - case DISP_CHANGE_BADMODE: - os::Printer::log("Switch to fullscreen: The graphics mode is not supported.", ELL_ERROR); - break; - default: - os::Printer::log("An unknown error occured while changing to fullscreen.", ELL_ERROR); - break; - } - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return ret; -} - - -//! returns the win32 cursor control -CIrrDeviceWin32::CCursorControl* CIrrDeviceWin32::getWin32CursorControl() -{ - return Win32CursorControl; -} - - -//! \return Returns a pointer to a list with all video modes supported -//! by the gfx adapter. -video::IVideoModeList* CIrrDeviceWin32::getVideoModeList() -{ - if (!VideoModeList.getVideoModeCount()) - { - // enumerate video modes. - DWORD i=0; - DEVMODE mode; - memset(&mode, 0, sizeof(mode)); - mode.dmSize = sizeof(mode); - - while (EnumDisplaySettings(NULL, i, &mode)) - { - VideoModeList.addMode(core::dimension2d<u32>(mode.dmPelsWidth, mode.dmPelsHeight), - mode.dmBitsPerPel); - - ++i; - } - - if (EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &mode)) - VideoModeList.setDesktop(mode.dmBitsPerPel, core::dimension2d<u32>(mode.dmPelsWidth, mode.dmPelsHeight)); - } - - return &VideoModeList; -} - - -void CIrrDeviceWin32::getWindowsVersion(core::stringc& out) -{ - OSVERSIONINFOEX osvi; - BOOL bOsVersionInfoEx; - - ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); - - bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO*) &osvi); - if (!bOsVersionInfoEx) - { - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - if (! GetVersionEx((OSVERSIONINFO *) &osvi)) - return; - } - - switch (osvi.dwPlatformId) - { - case VER_PLATFORM_WIN32_NT: - if (osvi.dwMajorVersion <= 4) - out.append("Microsoft Windows NT "); - else - if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0) - out.append("Microsoft Windows 2000 "); - else - if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1) - out.append("Microsoft Windows XP "); - else - if (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0) - out.append("Microsoft Windows Vista "); - - if (bOsVersionInfoEx) - { - #ifdef VER_SUITE_ENTERPRISE - if (osvi.wProductType == VER_NT_WORKSTATION) - { -#ifndef __BORLANDC__ - if( osvi.wSuiteMask & VER_SUITE_PERSONAL ) - out.append("Personal "); - else - out.append("Professional "); -#endif - } - else if (osvi.wProductType == VER_NT_SERVER) - { - if( osvi.wSuiteMask & VER_SUITE_DATACENTER ) - out.append("DataCenter Server "); - else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE ) - out.append("Advanced Server "); - else - out.append("Server "); - } - #endif - } - else - { - HKEY hKey; - char szProductType[80]; - DWORD dwBufLen; - - RegOpenKeyEx( HKEY_LOCAL_MACHINE, - "SYSTEM\\CurrentControlSet\\Control\\ProductOptions", - 0, KEY_QUERY_VALUE, &hKey ); - RegQueryValueEx( hKey, "ProductType", NULL, NULL, - (LPBYTE) szProductType, &dwBufLen); - RegCloseKey( hKey ); - - if (lstrcmpi( "WINNT", szProductType) == 0 ) - out.append("Professional "); - if (lstrcmpi( "LANMANNT", szProductType) == 0) - out.append("Server "); - if (lstrcmpi( "SERVERNT", szProductType) == 0) - out.append("Advanced Server "); - } - - // Display version, service pack (if any), and build number. - - char tmp[255]; - - if (osvi.dwMajorVersion <= 4 ) - { - sprintf(tmp, "version %ld.%ld %s (Build %ld)", - osvi.dwMajorVersion, - osvi.dwMinorVersion, - osvi.szCSDVersion, - osvi.dwBuildNumber & 0xFFFF); - } - else - { - sprintf(tmp, "%s (Build %ld)", osvi.szCSDVersion, - osvi.dwBuildNumber & 0xFFFF); - } - - out.append(tmp); - break; - - case VER_PLATFORM_WIN32_WINDOWS: - - IsNonNTWindows = true; - - if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0) - { - out.append("Microsoft Windows 95 "); - if ( osvi.szCSDVersion[1] == 'C' || osvi.szCSDVersion[1] == 'B' ) - out.append("OSR2 " ); - } - - if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10) - { - out.append("Microsoft Windows 98 "); - if ( osvi.szCSDVersion[1] == 'A' ) - out.append( "SE " ); - } - - if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90) - out.append("Microsoft Windows Me "); - - break; - - case VER_PLATFORM_WIN32s: - - IsNonNTWindows = true; - out.append("Microsoft Win32s "); - break; - } -} - -//! Notifies the device, that it has been resized -void CIrrDeviceWin32::OnResized() -{ - Resized = true; -} - -//! Sets if the window should be resizable in windowed mode. -void CIrrDeviceWin32::setResizable(bool resize) -{ - if (ExternalWindow || !getVideoDriver() || CreationParams.Fullscreen) - return; - - LONG_PTR style = WS_POPUP; - - if (!resize) - style = WS_SYSMENU | WS_BORDER | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; - else - style = WS_THICKFRAME | WS_SYSMENU | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_MINIMIZEBOX | WS_MAXIMIZEBOX; - - if (!SetWindowLongPtr(HWnd, GWL_STYLE, style)) - os::Printer::log("Could not change window style."); - - RECT clientSize; - clientSize.top = 0; - clientSize.left = 0; - clientSize.right = getVideoDriver()->getScreenSize().Width; - clientSize.bottom = getVideoDriver()->getScreenSize().Height; - - AdjustWindowRect(&clientSize, style, FALSE); - - const s32 realWidth = clientSize.right - clientSize.left; - const s32 realHeight = clientSize.bottom - clientSize.top; - - const s32 windowLeft = (GetSystemMetrics(SM_CXSCREEN) - realWidth) / 2; - const s32 windowTop = (GetSystemMetrics(SM_CYSCREEN) - realHeight) / 2; - - SetWindowPos(HWnd, HWND_TOP, windowLeft, windowTop, realWidth, realHeight, - SWP_FRAMECHANGED | SWP_NOMOVE | SWP_SHOWWINDOW); -} - - -//! Minimizes the window. -void CIrrDeviceWin32::minimizeWindow() -{ - WINDOWPLACEMENT wndpl; - wndpl.length = sizeof(WINDOWPLACEMENT); - GetWindowPlacement(HWnd, &wndpl); - wndpl.showCmd = SW_SHOWMINNOACTIVE; - SetWindowPlacement(HWnd, &wndpl); -} - - -//! Maximizes the window. -void CIrrDeviceWin32::maximizeWindow() -{ - WINDOWPLACEMENT wndpl; - wndpl.length = sizeof(WINDOWPLACEMENT); - GetWindowPlacement(HWnd, &wndpl); - wndpl.showCmd = SW_SHOWMAXIMIZED; - SetWindowPlacement(HWnd, &wndpl); -} - - -//! Restores the window to its original size. -void CIrrDeviceWin32::restoreWindow() -{ - WINDOWPLACEMENT wndpl; - wndpl.length = sizeof(WINDOWPLACEMENT); - GetWindowPlacement(HWnd, &wndpl); - wndpl.showCmd = SW_SHOWNORMAL; - SetWindowPlacement(HWnd, &wndpl); -} - - -bool CIrrDeviceWin32::activateJoysticks(core::array<SJoystickInfo> & joystickInfo) -{ -#if defined _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ - joystickInfo.clear(); - ActiveJoysticks.clear(); - - const u32 numberOfJoysticks = ::joyGetNumDevs(); - JOYINFOEX info; - info.dwSize = sizeof(info); - info.dwFlags = JOY_RETURNALL; - - JoystickInfo activeJoystick; - SJoystickInfo returnInfo; - - joystickInfo.reallocate(numberOfJoysticks); - ActiveJoysticks.reallocate(numberOfJoysticks); - - u32 joystick = 0; - for(; joystick < numberOfJoysticks; ++joystick) - { - if(JOYERR_NOERROR == joyGetPosEx(joystick, &info) - && - JOYERR_NOERROR == joyGetDevCaps(joystick, - &activeJoystick.Caps, - sizeof(activeJoystick.Caps))) - { - activeJoystick.Index = joystick; - ActiveJoysticks.push_back(activeJoystick); - - returnInfo.Joystick = (u8)joystick; - returnInfo.Axes = activeJoystick.Caps.wNumAxes; - returnInfo.Buttons = activeJoystick.Caps.wNumButtons; - returnInfo.Name = activeJoystick.Caps.szPname; - returnInfo.PovHat = ((activeJoystick.Caps.wCaps & JOYCAPS_HASPOV) == JOYCAPS_HASPOV) - ? SJoystickInfo::POV_HAT_PRESENT : SJoystickInfo::POV_HAT_ABSENT; - - joystickInfo.push_back(returnInfo); - } - } - - for(joystick = 0; joystick < joystickInfo.size(); ++joystick) - { - char logString[256]; - (void)sprintf(logString, "Found joystick %d, %d axes, %d buttons '%s'", - joystick, joystickInfo[joystick].Axes, - joystickInfo[joystick].Buttons, joystickInfo[joystick].Name.c_str()); - os::Printer::log(logString, ELL_INFORMATION); - } - - return true; -#else - return false; -#endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ -} - -void CIrrDeviceWin32::pollJoysticks() -{ -#if defined _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ - if(0 == ActiveJoysticks.size()) - return; - - u32 joystick; - JOYINFOEX info; - info.dwSize = sizeof(info); - info.dwFlags = JOY_RETURNALL; - - for(joystick = 0; joystick < ActiveJoysticks.size(); ++joystick) - { - if(JOYERR_NOERROR == joyGetPosEx(ActiveJoysticks[joystick].Index, &info)) - { - SEvent event; - const JOYCAPS & caps = ActiveJoysticks[joystick].Caps; - - event.EventType = irr::EET_JOYSTICK_INPUT_EVENT; - event.JoystickEvent.Joystick = (u8)joystick; - - event.JoystickEvent.POV = (u16)info.dwPOV; - if(event.JoystickEvent.POV > 35900) - event.JoystickEvent.POV = 65535; - - for(int axis = 0; axis < SEvent::SJoystickEvent::NUMBER_OF_AXES; ++axis) - event.JoystickEvent.Axis[axis] = 0; - - switch(caps.wNumAxes) - { - default: - case 6: - event.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_V] = - (s16)((65535 * (info.dwVpos - caps.wVmin)) / (caps.wVmax - caps.wVmin) - 32768); - - case 5: - event.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_U] = - (s16)((65535 * (info.dwUpos - caps.wUmin)) / (caps.wUmax - caps.wUmin) - 32768); - - case 4: - event.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_R] = - (s16)((65535 * (info.dwRpos - caps.wRmin)) / (caps.wRmax - caps.wRmin) - 32768); - - case 3: - event.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_Z] = - (s16)((65535 * (info.dwZpos - caps.wZmin)) / (caps.wZmax - caps.wZmin) - 32768); - - case 2: - event.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_Y] = - (s16)((65535 * (info.dwYpos - caps.wYmin)) / (caps.wYmax - caps.wYmin) - 32768); - - case 1: - event.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_X] = - (s16)((65535 * (info.dwXpos - caps.wXmin)) / (caps.wXmax - caps.wXmin) - 32768); - } - - event.JoystickEvent.ButtonStates = info.dwButtons; - - (void)postEventFromUser(event); - } - } -#endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ -} - -//! Set the current Gamma Value for the Display -bool CIrrDeviceWin32::setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast ) -{ - bool r; - u16 ramp[3][256]; - - calculateGammaRamp( ramp[0], red, brightness, contrast ); - calculateGammaRamp( ramp[1], green, brightness, contrast ); - calculateGammaRamp( ramp[2], blue, brightness, contrast ); - - HDC dc = GetDC(0); - r = SetDeviceGammaRamp ( dc, ramp ) == TRUE; - ReleaseDC(HWnd, dc); - return r; -} - -//! Get the current Gamma Value for the Display -bool CIrrDeviceWin32::getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast ) -{ - bool r; - u16 ramp[3][256]; - - HDC dc = GetDC(0); - r = GetDeviceGammaRamp ( dc, ramp ) == TRUE; - ReleaseDC(HWnd, dc); - - if ( r ) - { - calculateGammaFromRamp(red, ramp[0]); - calculateGammaFromRamp(green, ramp[1]); - calculateGammaFromRamp(blue, ramp[2]); - } - - brightness = 0.f; - contrast = 0.f; - - return r; - -} - -} // end namespace - -#endif // _IRR_COMPILE_WITH_WINDOWS_DEVICE_ - diff --git a/irrlicht-1.6/source/Irrlicht/CIrrDeviceWin32.h b/irrlicht-1.6/source/Irrlicht/CIrrDeviceWin32.h deleted file mode 100644 index cb6861c20..000000000 --- a/irrlicht-1.6/source/Irrlicht/CIrrDeviceWin32.h +++ /dev/null @@ -1,347 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_IRR_DEVICE_WIN32_H_INCLUDED__ -#define __C_IRR_DEVICE_WIN32_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_ - -#include "CIrrDeviceStub.h" -#include "IrrlichtDevice.h" -#include "IImagePresenter.h" - -#define WIN32_LEAN_AND_MEAN -#if !defined(_IRR_XBOX_PLATFORM_) - #include <windows.h> - #include <mmsystem.h> // For JOYCAPS - #include <Windowsx.h> -#endif - -namespace irr -{ - class CIrrDeviceWin32 : public CIrrDeviceStub, video::IImagePresenter - { - public: - - //! constructor - CIrrDeviceWin32(const SIrrlichtCreationParameters& params); - - //! destructor - virtual ~CIrrDeviceWin32(); - - //! runs the device. Returns false if device wants to be deleted - virtual bool run(); - - //! Cause the device to temporarily pause execution and let other processes to run - // This should bring down processor usage without major performance loss for Irrlicht - virtual void yield(); - - //! Pause execution and let other processes to run for a specified amount of time. - virtual void sleep(u32 timeMs, bool pauseTimer); - - //! sets the caption of the window - virtual void setWindowCaption(const wchar_t* text); - - //! returns if window is active. if not, nothing need to be drawn - virtual bool isWindowActive() const; - - //! returns if window has focus - virtual bool isWindowFocused() const; - - //! returns if window is minimized - virtual bool isWindowMinimized() const; - - //! presents a surface in the client area - virtual bool present(video::IImage* surface, void* windowId=0, core::rect<s32>* src=0); - - //! notifies the device that it should close itself - virtual void closeDevice(); - - //! \return Returns a pointer to a list with all video modes - //! supported by the gfx adapter. - video::IVideoModeList* getVideoModeList(); - - //! Notifies the device, that it has been resized - void OnResized(); - - //! Sets if the window should be resizable in windowed mode. - virtual void setResizable(bool resize=false); - - //! Minimizes the window. - virtual void minimizeWindow(); - - //! Maximizes the window. - virtual void maximizeWindow(); - - //! Restores the window size. - virtual void restoreWindow(); - - //! Activate any joysticks, and generate events for them. - virtual bool activateJoysticks(core::array<SJoystickInfo> & joystickInfo); - - //! Set the current Gamma Value for the Display - virtual bool setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast ); - - //! Get the current Gamma Value for the Display - virtual bool getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast ); - - //! Get the device type - virtual E_DEVICE_TYPE getType() const - { - return EIDT_WIN32; - } - - //! Compares to the last call of this function to return double and triple clicks. - //! \return Returns only 1,2 or 3. A 4th click will start with 1 again. - virtual u32 checkSuccessiveClicks(s32 mouseX, s32 mouseY) - { - // we just have to make it public - return CIrrDeviceStub::checkSuccessiveClicks(mouseX, mouseY); - } - - //! Implementation of the win32 cursor control - class CCursorControl : public gui::ICursorControl - { - public: - - CCursorControl(const core::dimension2d<u32>& wsize, HWND hwnd, bool fullscreen) - : WindowSize(wsize), InvWindowSize(0.0f, 0.0f), IsVisible(true), - HWnd(hwnd), BorderX(0), BorderY(0), UseReferenceRect(false) - { - if (WindowSize.Width!=0) - InvWindowSize.Width = 1.0f / WindowSize.Width; - - if (WindowSize.Height!=0) - InvWindowSize.Height = 1.0f / WindowSize.Height; - - if (!fullscreen) - { - BorderX = GetSystemMetrics(SM_CXDLGFRAME); - BorderY = GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYDLGFRAME); - } - } - - //! Changes the visible state of the mouse cursor. - virtual void setVisible(bool visible) - { - CURSORINFO info; - info.cbSize = sizeof(CURSORINFO); - - if ( visible ) - { - while ( GetCursorInfo(&info) ) - { - if ( info.flags == CURSOR_SHOWING ) - { - IsVisible = visible; - break; - } - ShowCursor(true); // this only increases an internal display counter in windows, so it might have to be called some more - } - } - else - { - while ( GetCursorInfo(&info) ) - { - if ( info.flags == 0 ) // cursor hidden - { - IsVisible = visible; - break; - } - ShowCursor(false); // this only decreases an internal display counter in windows, so it might have to be called some more - } - } - } - - //! Returns if the cursor is currently visible. - virtual bool isVisible() const - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return IsVisible; - } - - //! Sets the new position of the cursor. - virtual void setPosition(const core::position2d<f32> &pos) - { - setPosition(pos.X, pos.Y); - } - - //! Sets the new position of the cursor. - virtual void setPosition(f32 x, f32 y) - { - if (!UseReferenceRect) - setPosition((s32)(x*WindowSize.Width), (s32)(y*WindowSize.Height)); - else - setPosition((s32)(x*ReferenceRect.getWidth()), (s32)(y*ReferenceRect.getHeight())); - } - - //! Sets the new position of the cursor. - virtual void setPosition(const core::position2d<s32> &pos) - { - setPosition(pos.X, pos.Y); - } - - //! Sets the new position of the cursor. - virtual void setPosition(s32 x, s32 y) - { - if (UseReferenceRect) - { - SetCursorPos(ReferenceRect.UpperLeftCorner.X + x, - ReferenceRect.UpperLeftCorner.Y + y); - } - else - { - RECT rect; - if (GetWindowRect(HWnd, &rect)) - SetCursorPos(x + rect.left + BorderX, y + rect.top + BorderY); - } - - CursorPos.X = x; - CursorPos.Y = y; - } - - //! Returns the current position of the mouse cursor. - virtual core::position2d<s32> getPosition() - { - updateInternalCursorPosition(); - return CursorPos; - } - - //! Returns the current position of the mouse cursor. - virtual core::position2d<f32> getRelativePosition() - { - updateInternalCursorPosition(); - - if (!UseReferenceRect) - { - return core::position2d<f32>(CursorPos.X * InvWindowSize.Width, - CursorPos.Y * InvWindowSize.Height); - } - - return core::position2d<f32>(CursorPos.X / (f32)ReferenceRect.getWidth(), - CursorPos.Y / (f32)ReferenceRect.getHeight()); - } - - //! Sets an absolute reference rect for calculating the cursor position. - virtual void setReferenceRect(core::rect<s32>* rect=0) - { - if (rect) - { - ReferenceRect = *rect; - UseReferenceRect = true; - - // prevent division through zero and uneven sizes - - if (!ReferenceRect.getHeight() || ReferenceRect.getHeight()%2) - ReferenceRect.LowerRightCorner.Y += 1; - - if (!ReferenceRect.getWidth() || ReferenceRect.getWidth()%2) - ReferenceRect.LowerRightCorner.X += 1; - } - else - UseReferenceRect = false; - } - - /** Used to notify the cursor that the window was resized. */ - virtual void OnResize(const core::dimension2d<u32>& size) - { - if (size.Width!=0) - InvWindowSize.Width = 1.0f / size.Width; - else - InvWindowSize.Width = 0.f; - - if (size.Height!=0) - InvWindowSize.Height = 1.0f / size.Height; - else - InvWindowSize.Height = 0.f; - } - - private: - - //! Updates the internal cursor position - void updateInternalCursorPosition() - { - POINT p; - if (!GetCursorPos(&p)) - { - DWORD xy = GetMessagePos(); - p.x = GET_X_LPARAM(xy); - p.y = GET_Y_LPARAM(xy); - } - - if (UseReferenceRect) - { - CursorPos.X = p.x - ReferenceRect.UpperLeftCorner.X; - CursorPos.Y = p.y - ReferenceRect.UpperLeftCorner.Y; - } - else - { - RECT rect; - if (GetWindowRect(HWnd, &rect)) - { - CursorPos.X = p.x-rect.left-BorderX; - CursorPos.Y = p.y-rect.top-BorderY; - } - else - { - // window seems not to be existent, so set cursor to - // a negative value - CursorPos.X = -1; - CursorPos.Y = -1; - } - } - } - - core::position2d<s32> CursorPos; - core::dimension2d<u32> WindowSize; - core::dimension2d<f32> InvWindowSize; - bool IsVisible; - HWND HWnd; - - s32 BorderX, BorderY; - bool UseReferenceRect; - core::rect<s32> ReferenceRect; - }; - - //! returns the win32 cursor control - CCursorControl* getWin32CursorControl(); - - private: - - //! create the driver - void createDriver(); - - //! switchs to fullscreen - bool switchToFullScreen(s32 width, s32 height, s32 bits); - - void getWindowsVersion(core::stringc& version); - - void resizeIfNecessary(); - - void pollJoysticks(); - - HWND HWnd; - - bool ChangedToFullScreen; - bool IsNonNTWindows; - bool Resized; - bool ExternalWindow; - CCursorControl* Win32CursorControl; - -#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) - struct JoystickInfo - { - u32 Index; - JOYCAPS Caps; - }; - core::array<JoystickInfo> ActiveJoysticks; -#endif - }; - -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_WINDOWS_DEVICE_ -#endif // __C_IRR_DEVICE_WIN32_H_INCLUDED__ - diff --git a/irrlicht-1.6/source/Irrlicht/CIrrDeviceWinCE.cpp b/irrlicht-1.6/source/Irrlicht/CIrrDeviceWinCE.cpp deleted file mode 100644 index dbfb7a498..000000000 --- a/irrlicht-1.6/source/Irrlicht/CIrrDeviceWinCE.cpp +++ /dev/null @@ -1,867 +0,0 @@ -// Copyright (C) 2002-2009 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_WINDOWS_CE_DEVICE_ - -#include "CIrrDeviceWinCE.h" -#include "IEventReceiver.h" -#include "irrList.h" -#include "os.h" - -#include "CTimer.h" -#include "irrString.h" -#include "COSOperator.h" -#include "dimension2d.h" -#include <winuser.h> -#include "irrlicht.h" - -#ifdef _MSC_VER - #pragma comment (lib, "aygshell.lib") -#endif - - -namespace irr -{ - namespace video - { - #ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ - IVideoDriver* createDirectX8Driver(const core::dimension2d<s32>& screenSize, HWND window, - u32 bits, bool fullscreen, bool stencilbuffer, io::IFileSystem* io, - bool pureSoftware, bool highPrecisionFPU, bool vsync, bool antiAlias); - #endif - - #ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ - IVideoDriver* createDirectX9Driver(const core::dimension2d<s32>& screenSize, HWND window, - u32 bits, bool fullscreen, bool stencilbuffer, io::IFileSystem* io, - bool pureSoftware, bool highPrecisionFPU, bool vsync, bool antiAlias); - #endif - - #ifdef _IRR_COMPILE_WITH_OPENGL_ - IVideoDriver* createOpenGLDriver(const irr::SIrrlichtCreationParameters& params, io::IFileSystem* io, this); - #endif - } -} // end namespace irr - - - -struct SEnvMapper -{ - HWND hWnd; - irr::CIrrDeviceWinCE* irrDev; -}; - -irr::core::list<SEnvMapper> EnvMap; - -SEnvMapper* getEnvMapperFromHWnd(HWND hWnd) -{ - irr::core::list<SEnvMapper>::Iterator it = EnvMap.begin(); - for (; it!= EnvMap.end(); ++it) - if ((*it).hWnd == hWnd) - return &(*it); - - return 0; -} - -irr::CIrrDeviceWinCE* getDeviceFromHWnd(HWND hWnd) -{ - irr::core::list<SEnvMapper>::Iterator it = EnvMap.begin(); - for (; it!= EnvMap.end(); ++it) - if ((*it).hWnd == hWnd) - return (*it).irrDev; - - return 0; -} - - -LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - #ifndef WM_MOUSEWHEEL - #define WM_MOUSEWHEEL 0x020A - #endif - #ifndef WHEEL_DELTA - #define WHEEL_DELTA 120 - #endif - - irr::CIrrDeviceWinCE* dev = 0; - irr::SEvent event; - SEnvMapper* envm = 0; - - //BYTE allKeys[256]; - - static irr::s32 ClickCount=0; - if (GetCapture() != hWnd && ClickCount > 0) - ClickCount = 0; - - switch (message) - { - case WM_PAINT: - { - PAINTSTRUCT ps; - BeginPaint(hWnd, &ps); - EndPaint(hWnd, &ps); - } - return 0; - - case WM_ERASEBKGND: - return 0; - - case WM_SETCURSOR: - envm = getEnvMapperFromHWnd(hWnd); - if (envm && !envm->irrDev->getWin32CursorControl()->isVisible()) - { - SetCursor(NULL); - return 0; - } - break; - - case WM_MOUSEWHEEL: - event.EventType = irr::EET_MOUSE_INPUT_EVENT; - event.MouseInput.Wheel = ((irr::f32)((short)HIWORD(wParam))) / (irr::f32)WHEEL_DELTA; - event.MouseInput.Event = irr::EMIE_MOUSE_WHEEL; - - POINT p; // fixed by jox - p.x = 0; p.y = 0; - ClientToScreen(hWnd, &p); - event.MouseInput.X = LOWORD(lParam) - p.x; - event.MouseInput.Y = HIWORD(lParam) - p.y; - event.MouseInput.Shift = ((LOWORD(wParam) & MK_SHIFT) != 0); - event.MouseInput.Control = ((LOWORD(wParam) & MK_CONTROL) != 0); - // left and right mouse buttons - event.MouseInput.ButtonStates = wParam & ( MK_LBUTTON | MK_RBUTTON); - // middle and extra buttons - if (wParam & MK_MBUTTON) - event.MouseInput.ButtonStates |= irr::EMBSM_MIDDLE; - - dev = getDeviceFromHWnd(hWnd); - if (dev) - dev->postEventFromUser(event); - break; - - case WM_LBUTTONDOWN: - ClickCount++; - SetCapture(hWnd); - event.EventType = irr::EET_MOUSE_INPUT_EVENT; - event.MouseInput.Event = irr::EMIE_LMOUSE_PRESSED_DOWN; - event.MouseInput.X = (short)LOWORD(lParam); - event.MouseInput.Y = (short)HIWORD(lParam); - event.MouseInput.Shift = ((LOWORD(wParam) & MK_SHIFT) != 0); - event.MouseInput.Control = ((LOWORD(wParam) & MK_CONTROL) != 0); - // left and right mouse buttons - event.MouseInput.ButtonStates = wParam & ( MK_LBUTTON | MK_RBUTTON); - // middle and extra buttons - if (wParam & MK_MBUTTON) - event.MouseInput.ButtonStates |= irr::EMBSM_MIDDLE; - - dev = getDeviceFromHWnd(hWnd); - if (dev) - dev->postEventFromUser(event); - return 0; - - case WM_LBUTTONUP: - ClickCount--; - if (ClickCount<1) - { - ClickCount=0; - ReleaseCapture(); - } - event.EventType = irr::EET_MOUSE_INPUT_EVENT; - event.MouseInput.Event = irr::EMIE_LMOUSE_LEFT_UP; - event.MouseInput.X = (short)LOWORD(lParam); - event.MouseInput.Y = (short)HIWORD(lParam); - event.MouseInput.Shift = ((LOWORD(wParam) & MK_SHIFT) != 0); - event.MouseInput.Control = ((LOWORD(wParam) & MK_CONTROL) != 0); - // left and right mouse buttons - event.MouseInput.ButtonStates = wParam & ( MK_LBUTTON | MK_RBUTTON); - // middle and extra buttons - if (wParam & MK_MBUTTON) - event.MouseInput.ButtonStates |= irr::EMBSM_MIDDLE; - - dev = getDeviceFromHWnd(hWnd); - if (dev) - dev->postEventFromUser(event); - return 0; - - case WM_RBUTTONDOWN: - ClickCount++; - SetCapture(hWnd); - event.EventType = irr::EET_MOUSE_INPUT_EVENT; - event.MouseInput.Event = irr::EMIE_RMOUSE_PRESSED_DOWN; - event.MouseInput.X = (short)LOWORD(lParam); - event.MouseInput.Y = (short)HIWORD(lParam); - event.MouseInput.Shift = ((LOWORD(wParam) & MK_SHIFT) != 0); - event.MouseInput.Control = ((LOWORD(wParam) & MK_CONTROL) != 0); - // left and right mouse buttons - event.MouseInput.ButtonStates = wParam & ( MK_LBUTTON | MK_RBUTTON); - // middle and extra buttons - if (wParam & MK_MBUTTON) - event.MouseInput.ButtonStates |= irr::EMBSM_MIDDLE; - - dev = getDeviceFromHWnd(hWnd); - if (dev) - dev->postEventFromUser(event); - return 0; - - case WM_RBUTTONUP: - ClickCount--; - if (ClickCount<1) - { - ClickCount=0; - ReleaseCapture(); - } - event.EventType = irr::EET_MOUSE_INPUT_EVENT; - event.MouseInput.Event = irr::EMIE_RMOUSE_LEFT_UP; - event.MouseInput.X = (short)LOWORD(lParam); - event.MouseInput.Y = (short)HIWORD(lParam); - event.MouseInput.Shift = ((LOWORD(wParam) & MK_SHIFT) != 0); - event.MouseInput.Control = ((LOWORD(wParam) & MK_CONTROL) != 0); - // left and right mouse buttons - event.MouseInput.ButtonStates = wParam & ( MK_LBUTTON | MK_RBUTTON); - // middle and extra buttons - if (wParam & MK_MBUTTON) - event.MouseInput.ButtonStates |= irr::EMBSM_MIDDLE; - - dev = getDeviceFromHWnd(hWnd); - if (dev) - dev->postEventFromUser(event); - return 0; - - case WM_MBUTTONDOWN: - ClickCount++; - SetCapture(hWnd); - event.EventType = irr::EET_MOUSE_INPUT_EVENT; - event.MouseInput.Event = irr::EMIE_MMOUSE_PRESSED_DOWN; - event.MouseInput.X = (short)LOWORD(lParam); - event.MouseInput.Y = (short)HIWORD(lParam); - event.MouseInput.Shift = ((LOWORD(wParam) & MK_SHIFT) != 0); - event.MouseInput.Control = ((LOWORD(wParam) & MK_CONTROL) != 0); - // left and right mouse buttons - event.MouseInput.ButtonStates = wParam & ( MK_LBUTTON | MK_RBUTTON); - // middle and extra buttons - if (wParam & MK_MBUTTON) - event.MouseInput.ButtonStates |= irr::EMBSM_MIDDLE; - - dev = getDeviceFromHWnd(hWnd); - if (dev) - dev->postEventFromUser(event); - return 0; - - case WM_MBUTTONUP: - ClickCount--; - if (ClickCount<1) - { - ClickCount=0; - ReleaseCapture(); - } - event.EventType = irr::EET_MOUSE_INPUT_EVENT; - event.MouseInput.Event = irr::EMIE_MMOUSE_LEFT_UP; - event.MouseInput.X = (short)LOWORD(lParam); - event.MouseInput.Y = (short)HIWORD(lParam); - event.MouseInput.Shift = ((LOWORD(wParam) & MK_SHIFT) != 0); - event.MouseInput.Control = ((LOWORD(wParam) & MK_CONTROL) != 0); - // left and right mouse buttons - event.MouseInput.ButtonStates = wParam & ( MK_LBUTTON | MK_RBUTTON); - // middle and extra buttons - if (wParam & MK_MBUTTON) - event.MouseInput.ButtonStates |= irr::EMBSM_MIDDLE; - - dev = getDeviceFromHWnd(hWnd); - if (dev) - dev->postEventFromUser(event); - return 0; - - case WM_MOUSEMOVE: - event.EventType = irr::EET_MOUSE_INPUT_EVENT; - event.MouseInput.Event = irr::EMIE_MOUSE_MOVED; - event.MouseInput.X = (short)LOWORD(lParam); - event.MouseInput.Y = (short)HIWORD(lParam); - event.MouseInput.Shift = ((LOWORD(wParam) & MK_SHIFT) != 0); - event.MouseInput.Control = ((LOWORD(wParam) & MK_CONTROL) != 0); - // left and right mouse buttons - event.MouseInput.ButtonStates = wParam & ( MK_LBUTTON | MK_RBUTTON); - // middle and extra buttons - if (wParam & MK_MBUTTON) - event.MouseInput.ButtonStates |= irr::EMBSM_MIDDLE; - - dev = getDeviceFromHWnd(hWnd); - if (dev) - dev->postEventFromUser(event); - - return 0; - - case WM_SYSKEYDOWN: - case WM_SYSKEYUP: - case WM_KEYDOWN: - case WM_KEYUP: - { - event.EventType = irr::EET_KEY_INPUT_EVENT; - event.KeyInput.Key = (irr::EKEY_CODE)wParam; - event.KeyInput.PressedDown = (message==WM_KEYDOWN || message == WM_SYSKEYDOWN); - dev = getDeviceFromHWnd(hWnd); -/* - WORD KeyAsc=0; - GetKeyboardState(allKeys); - ToAscii(wParam,lParam,allKeys,&KeyAsc,0); -*/ -// event.KeyInput.Shift = ((allKeys[VK_SHIFT] & 0x80)!=0); -// event.KeyInput.Control = ((allKeys[VK_CONTROL] & 0x80)!=0); -// event.KeyInput.Char = (KeyAsc & 0x00ff); //KeyAsc >= 0 ? KeyAsc : 0; - - if (dev) - dev->postEventFromUser(event); - - return 0; - } - - case WM_SIZE: - { - // resize - dev = getDeviceFromHWnd(hWnd); - if (dev) - dev->OnResized(); - } - return 0; - - case WM_DESTROY: - PostQuitMessage(0); - return 0; - - } - - return DefWindowProc(hWnd, message, wParam, lParam); -} - -namespace irr -{ - -//! constructor -CIrrDeviceWinCE::CIrrDeviceWinCE(const SIrrlichtCreationParameters& params) -: CIrrDeviceStub(params), HWnd(0), - Win32CursorControl(0), ChangedToFullScreen(false), Resized(false), - ExternalWindow(false) -{ - #ifdef _DEBUG - setDebugName("CIrrDeviceWinCE"); - #endif - - core::stringc winversion; - getWindowsVersion(winversion); - Operator = new COSOperator(winversion.c_str()); - os::Printer::log(winversion.c_str(), ELL_INFORMATION); - - HINSTANCE hInstance = GetModuleHandle(0); - - // create the window only if we do not use the null device - if (!CreationParams.WindowId && (CreationParams.DriverType != video::EDT_NULL)) - { - const wchar_t* ClassName = L"CIrrDeviceWinCE"; - - // Register Class - WNDCLASS wc; - wc.style = CS_HREDRAW | CS_VREDRAW; - wc.lpfnWndProc = WndProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = hInstance; - wc.hIcon = NULL; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); - wc.lpszMenuName = 0; - wc.lpszClassName = ClassName; - - // if there is an icon, load it - wc.hIcon = (HICON)LoadImageW(hInstance, L"irrlicht.ico", IMAGE_ICON, 0,0, 0); - - RegisterClass(&wc); - - // calculate client size - - RECT clientSize; - clientSize.top = 0; - clientSize.left = 0; - clientSize.right = CreationParams.WindowSize.Width; - clientSize.bottom = CreationParams.WindowSize.Height; - - DWORD style = WS_POPUP; - - if (!CreationParams.Fullscreen) - style = WS_SYSMENU | WS_BORDER | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; - - AdjustWindowRectEx(&clientSize, style, FALSE, 0); - - const s32 realWidth = clientSize.right - clientSize.left; - const s32 realHeight = clientSize.bottom - clientSize.top; - - const s32 windowLeft = core::s32_max ( 0, (GetSystemMetrics(SM_CXSCREEN) - realWidth) >> 1 ); - const s32 windowTop = core::s32_max ( 0, (GetSystemMetrics(SM_CYSCREEN) - realHeight) >> 1 ); - - // create window - - HWnd = CreateWindowW( ClassName, L"", style, windowLeft, windowTop, - realWidth, realHeight, NULL, NULL, hInstance, NULL); - - ShowWindow(HWnd , SW_SHOW); - UpdateWindow(HWnd); - - // fix ugly ATI driver bugs. Thanks to ariaci - MoveWindow(HWnd, windowLeft, windowTop, realWidth, realHeight, TRUE); - } - else if (CreationParams.WindowId) - { - // attach external window - HWnd = static_cast<HWND>(CreationParams.WindowId); - RECT r; - GetWindowRect(HWnd, &r); - CreationParams.WindowSize.Width = r.right - r.left; - CreationParams.WindowSize.Height = r.bottom - r.top; - CreationParams.Fullscreen = false; - ExternalWindow = true; - } - - // create cursor control - - Win32CursorControl = new CCursorControl(CreationParams.WindowSize, HWnd, CreationParams.Fullscreen); - CursorControl = Win32CursorControl; - - // create driver - - createDriver(); - - if (VideoDriver) - createGUIAndScene(); - - // register environment - - SEnvMapper em; - em.irrDev = this; - em.hWnd = HWnd; - EnvMap.push_back(em); - - // set this as active window - SetActiveWindow(HWnd); - SetForegroundWindow(HWnd); -} - - -//! destructor -CIrrDeviceWinCE::~CIrrDeviceWinCE() -{ - // unregister environment - - if (ChangedToFullScreen) - SHFullScreen(HWnd, SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON | SHFS_SHOWSIPBUTTON); - - irr::core::list<SEnvMapper>::Iterator it = EnvMap.begin(); - for (; it!= EnvMap.end(); ++it) - if ((*it).hWnd == HWnd) - { - EnvMap.erase(it); - break; - } -} - - -//! create the driver -void CIrrDeviceWinCE::createDriver() -{ - switch(CreationParams.DriverType) - { - case video::EDT_DIRECT3D8: - #ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ - VideoDriver = video::createDirectX8Driver(CreationParams.WindowSize, HWnd, CreationParams.Bits, CreationParams.Fullscreen, - CreationParams.Stencilbuffer, FileSystem, false, CreationParams.HighPrecisionFPU, CreationParams.Vsync, CreationParams.AntiAlias); - if (!VideoDriver) - { - os::Printer::log("Could not create DIRECT3D8 Driver.", ELL_ERROR); - } - #else - os::Printer::log("DIRECT3D8 Driver was not compiled into this dll. Try another one.", ELL_ERROR); - #endif // _IRR_COMPILE_WITH_DIRECT3D_8_ - - break; - - case video::EDT_DIRECT3D9: - #ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ - VideoDriver = video::createDirectX9Driver(CreationParams.WindowSize, HWnd, CreationParams.Bits, CreationParams.Fullscreen, - CreationParams.Stencilbuffer, FileSystem, false, CreationParams.HighPrecisionFPU, CreationParams.Vsync, CreationParams.AntiAlias); - if (!VideoDriver) - { - os::Printer::log("Could not create DIRECT3D9 Driver.", ELL_ERROR); - } - #else - os::Printer::log("DIRECT3D9 Driver was not compiled into this dll. Try another one.", ELL_ERROR); - #endif // _IRR_COMPILE_WITH_DIRECT3D_9_ - - break; - - case video::EDT_OPENGL: - - #ifdef _IRR_COMPILE_WITH_OPENGL_ - if (CreationParams.Fullscreen) - switchToFullScreen(); - VideoDriver = video::createOpenGLDriver(CreationParams, FileSystem); - if (!VideoDriver) - { - os::Printer::log("Could not create OpenGL driver.", ELL_ERROR); - } - #else - os::Printer::log("OpenGL driver was not compiled in.", ELL_ERROR); - #endif - break; - - case video::EDT_SOFTWARE: - - #ifdef _IRR_COMPILE_WITH_SOFTWARE_ - if (CreationParams.Fullscreen) - switchToFullScreen(); - VideoDriver = video::createSoftwareDriver(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this); - #else - os::Printer::log("Software driver was not compiled in.", ELL_ERROR); - #endif - - break; - - case video::EDT_BURNINGSVIDEO: - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - if (CreationParams.Fullscreen) - switchToFullScreen(); - VideoDriver = video::createSoftwareDriver2(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this); - #else - os::Printer::log("Burning's Video driver was not compiled in.", ELL_ERROR); - #endif - break; - - case video::EDT_NULL: - // create null driver - VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize); - break; - - default: - os::Printer::log("Unable to create video driver of unknown type.", ELL_ERROR); - break; - } -} - - -//! runs the device. Returns false if device wants to be deleted -bool CIrrDeviceWinCE::run() -{ - os::Timer::tick(); - - MSG msg; - - bool quit = false; - - while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) - { - TranslateMessage(&msg); - - if (ExternalWindow && msg.hwnd == HWnd) - WndProc(HWnd, msg.message, msg.wParam, msg.lParam); - else - DispatchMessage(&msg); - - if (msg.message == WM_QUIT) - quit = true; - } - - if (!quit) - resizeIfNecessary(); - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return !quit; -} - - -//! Pause the current process for the minimum time allowed only to allow other processes to execute -void CIrrDeviceWinCE::yield() -{ - Sleep(1); -} - - -//! Pause execution and let other processes to run for a specified amount of time. -void CIrrDeviceWinCE::sleep(u32 timeMs, bool pauseTimer) -{ - const bool wasStopped = Timer ? Timer->isStopped() : true; - if (pauseTimer && !wasStopped) - Timer->stop(); - - Sleep(timeMs); - - if (pauseTimer && !wasStopped) - Timer->start(); -} - - -void CIrrDeviceWinCE::resizeIfNecessary() -{ - if (!Resized) - return; - - RECT r; - GetClientRect(HWnd, &r); - - char tmp[255]; - - if (r.right < 2 || r.bottom < 2) - { - sprintf(tmp, "Ignoring resize operation to (%ld %ld)", r.right, r.bottom); - os::Printer::log(tmp); - } - else - { - sprintf(tmp, "Resizing window (%ld %ld)", r.right, r.bottom); - os::Printer::log(tmp); - - getVideoDriver()->OnResize(irr::core::dimension2d<irr::u32>(r.right, r.bottom)); - getWin32CursorControl()->OnResize(getVideoDriver()->getScreenSize()); - } - - Resized = false; -} - - -//! sets the caption of the window -void CIrrDeviceWinCE::setWindowCaption(const wchar_t* text) -{ - SetWindowTextW(HWnd, text); -} - - -#if !defined(BITMAPV4HEADER) -typedef struct { - DWORD bV4Size; - LONG bV4Width; - LONG bV4Height; - WORD bV4Planes; - WORD bV4BitCount; - DWORD bV4V4Compression; - DWORD bV4SizeImage; - LONG bV4XPelsPerMeter; - LONG bV4YPelsPerMeter; - DWORD bV4ClrUsed; - DWORD bV4ClrImportant; - DWORD bV4RedMask; - DWORD bV4GreenMask; - DWORD bV4BlueMask; - DWORD bV4AlphaMask; - DWORD bV4CSType; - DWORD un[9]; -} BITMAPV4HEADER, *PBITMAPV4HEADER; -#endif - - -//! presents a surface in the client area -bool CIrrDeviceWinCE::present(video::IImage* image, void* windowId, core::rect<s32>* src) -{ - HWND hwnd = HWnd; - if ( windowId ) - hwnd = (HWND)windowId; - - HDC dc = GetDC(hwnd); - - if ( dc ) - { - RECT rect; - GetClientRect(hwnd, &rect); - const void* memory = (const void *)image->lock(); - - BITMAPV4HEADER bi; - memset (&bi, 0, sizeof(bi)); - bi.bV4Size = sizeof(BITMAPINFOHEADER); - bi.bV4BitCount = image->getBitsPerPixel(); - bi.bV4Planes = 1; - bi.bV4Width = image->getDimension().Width; - bi.bV4Height = 0 - image->getDimension().Height; - bi.bV4V4Compression = BI_BITFIELDS; - bi.bV4AlphaMask = image->getAlphaMask (); - bi.bV4RedMask = image->getRedMask (); - bi.bV4GreenMask = image->getGreenMask(); - bi.bV4BlueMask = image->getBlueMask(); - - int r = 0; - if ( src ) - { - r = StretchDIBits(dc, 0,0, rect.right, rect.bottom, - src->UpperLeftCorner.X, src->UpperLeftCorner.Y, - src->getWidth(), src->getHeight(), - memory, (const BITMAPINFO*)(&bi), DIB_RGB_COLORS, SRCCOPY); - } - else - { - r = StretchDIBits(dc, 0,0, rect.right, rect.bottom, - 0, 0, image->getDimension().Width, image->getDimension().Height, - memory, (const BITMAPINFO*)(&bi), DIB_RGB_COLORS, SRCCOPY); - } - - image->unlock(); - - ReleaseDC(hwnd, dc); - } - return true; -} - - -//! notifies the device that it should close itself -void CIrrDeviceWinCE::closeDevice() -{ - MSG msg; - PeekMessage(&msg, NULL, WM_QUIT, WM_QUIT, PM_REMOVE); - PostQuitMessage(0); - PeekMessage(&msg, NULL, WM_QUIT, WM_QUIT, PM_REMOVE); - DestroyWindow(HWnd); -} - - -//! returns if window is active. if not, nothing need to be drawn -bool CIrrDeviceWinCE::isWindowActive() const -{ - bool ret = (GetActiveWindow() == HWnd); - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return ret; -} - - -//! returns if window has focus -bool CIrrDeviceWinCE::isWindowFocused() const -{ - bool ret = (GetFocus() == HWnd); - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return ret; -} - - -//! returns if window is minimized -bool CIrrDeviceWinCE::isWindowMinimized() const -{ -#if 0 - WINDOWPLACEMENT plc; - plc.length=sizeof(WINDOWPLACEMENT); - bool ret=false; - if (GetWindowPlacement(HWnd,&plc)) - ret=(plc.showCmd & SW_SHOWMINIMIZED); - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return ret; -#endif - return false; -} - - -//! switches to fullscreen -bool CIrrDeviceWinCE::switchToFullScreen() -{ - ChangedToFullScreen = SHFullScreen(HWnd, SHFS_HIDESIPBUTTON | SHFS_HIDETASKBAR) != 0; - return ChangedToFullScreen; -} - - -//! returns the win32 cursor control -CIrrDeviceWinCE::CCursorControl* CIrrDeviceWinCE::getWin32CursorControl() -{ - return Win32CursorControl; -} - - -//! Return pointer to a list with all video modes supported by the gfx adapter. -/** \return Pointer to video modes list */ -video::IVideoModeList* CIrrDeviceWinCE::getVideoModeList() -{ - if (!VideoModeList.getVideoModeCount()) - { - // enumerate video modes. - DWORD i=0; - DEVMODE mode; - memset(&mode, 0, sizeof(mode)); - mode.dmSize = sizeof(mode); - - while (EnumDisplaySettings(NULL, i, &mode)) - { - VideoModeList.addMode(core::dimension2d<u32>(mode.dmPelsWidth, mode.dmPelsHeight), - mode.dmBitsPerPel); - - ++i; - } - - if (EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &mode)) - VideoModeList.setDesktop(mode.dmBitsPerPel, core::dimension2d<u32>(mode.dmPelsWidth, mode.dmPelsHeight)); - } - - return &VideoModeList; -} - - -void CIrrDeviceWinCE::getWindowsVersion(core::stringc& out) -{ - out = "WinCE"; -} - - -//! Notifies the device, that it has been resized -void CIrrDeviceWinCE::OnResized() -{ - Resized = true; -} - - -//! Sets if the window should be resizable in windowed mode. -void CIrrDeviceWinCE::setResizable(bool resize) -{ - if (ExternalWindow || !getVideoDriver() || CreationParams.Fullscreen) - return; - - LONG style = WS_POPUP; - - if (!resize) - style = WS_SYSMENU | WS_BORDER | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; - else - style = WS_THICKFRAME | WS_SYSMENU | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_MAXIMIZEBOX; - - if (!SetWindowLong(HWnd, GWL_STYLE, style)) - os::Printer::log("Could not change window style."); - - RECT clientSize; - clientSize.top = 0; - clientSize.left = 0; - clientSize.right = getVideoDriver()->getScreenSize().Width; - clientSize.bottom = getVideoDriver()->getScreenSize().Height; - - AdjustWindowRectEx(&clientSize, style, FALSE, 0); - - const s32 realWidth = clientSize.right - clientSize.left; - const s32 realHeight = clientSize.bottom - clientSize.top; - - const s32 windowLeft = (GetSystemMetrics(SM_CXSCREEN) - realWidth) / 2; - const s32 windowTop = (GetSystemMetrics(SM_CYSCREEN) - realHeight) / 2; - - SetWindowPos(HWnd, HWND_TOP, windowLeft, windowTop, realWidth, realHeight, - SWP_FRAMECHANGED | SWP_NOMOVE | SWP_SHOWWINDOW); -} - - -//! Minimizes the window. -void CIrrDeviceWinCE::minimizeWindow() -{ - // do nothing -} - -//! Maximize window -void CIrrDeviceWinCE::maximizeWindow() -{ - // do nothing -} - - -//! Restore original window size -void CIrrDeviceWinCE::restoreWindow() -{ - // do nothing -} - - -} // end namespace - -#endif // _IRR_COMPILE_WITH_WINDOWS_CE_DEVICE_ - diff --git a/irrlicht-1.6/source/Irrlicht/CIrrDeviceWinCE.h b/irrlicht-1.6/source/Irrlicht/CIrrDeviceWinCE.h deleted file mode 100644 index fcb349e8f..000000000 --- a/irrlicht-1.6/source/Irrlicht/CIrrDeviceWinCE.h +++ /dev/null @@ -1,294 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_IRR_DEVICE_WINCE_H_INCLUDED__ -#define __C_IRR_DEVICE_WINCE_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_WINDOWS_CE_DEVICE_ - -#include "CIrrDeviceStub.h" -#include "IrrlichtDevice.h" -#include "IImagePresenter.h" - -#include <windows.h> -#include <windowsx.h> -#include <commctrl.h> -#include <aygshell.h> -#include <sipapi.h> -#include <gx.h> - -namespace irr -{ - class CIrrDeviceWinCE : public CIrrDeviceStub, video::IImagePresenter - { - public: - - //! constructor - CIrrDeviceWinCE( const SIrrlichtCreationParameters& params); - - //! destructor - virtual ~CIrrDeviceWinCE(); - - //! runs the device. Returns false if device wants to be deleted - virtual bool run(); - - //! Cause the device to temporarily pause execution and let other processes to run - // This should bring down processor usage without major performance loss for Irrlicht - virtual void yield(); - - //! Pause execution and let other processes to run for a specified amount of time. - virtual void sleep(u32 timeMs, bool pauseTimer); - - //! sets the caption of the window - virtual void setWindowCaption(const wchar_t* text); - - //! returns if window is active. if not, nothing need to be drawn - virtual bool isWindowActive() const; - - //! returns if window has focus - virtual bool isWindowFocused() const; - - //! returns if window is minimized - virtual bool isWindowMinimized() const; - - //! presents a surface in the client area - virtual bool present(video::IImage* surface, void* windowId = 0, core::rect<s32>* src=0 ); - - //! notifies the device that it should close itself - virtual void closeDevice(); - - //! \return Returns a pointer to a list with all video modes - //! supported by the gfx adapter. - video::IVideoModeList* getVideoModeList(); - - //! Notifies the device, that it has been resized - void OnResized(); - - //! Sets if the window should be resizable in windowed mode. - virtual void setResizable(bool resize=false); - - //! Minimizes the window. - virtual void minimizeWindow(); - - //! Maximizes the window. - virtual void maximizeWindow(); - - //! Restores the window size. - virtual void restoreWindow(); - - //! Get the device type - virtual E_DEVICE_TYPE getType() const - { - return EIDT_WINCE; - } - - //! Implementation of the win32 cursor control - class CCursorControl : public gui::ICursorControl - { - public: - - CCursorControl(const core::dimension2d<u32>& wsize, HWND hwnd, bool fullscreen) - : WindowSize(wsize), InvWindowSize(0.0f, 0.0f), IsVisible(true), - HWnd(hwnd), BorderX(0), BorderY(0), UseReferenceRect(false) - { - if (WindowSize.Width!=0) - InvWindowSize.Width = 1.0f / WindowSize.Width; - - if (WindowSize.Height!=0) - InvWindowSize.Height = 1.0f / WindowSize.Height; - - if (!fullscreen) - { - BorderX = GetSystemMetrics(SM_CXDLGFRAME); - BorderY = GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYDLGFRAME); - } - } - - //! Changes the visible state of the mouse cursor. - virtual void setVisible(bool visible) - { - IsVisible = visible; - } - - //! Returns if the cursor is currently visible. - virtual bool isVisible() const - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return IsVisible; - } - - //! Sets the new position of the cursor. - virtual void setPosition(const core::position2d<f32> &pos) - { - setPosition(pos.X, pos.Y); - } - - //! Sets the new position of the cursor. - virtual void setPosition(f32 x, f32 y) - { - if (!UseReferenceRect) - setPosition((s32)(x*WindowSize.Width), (s32)(y*WindowSize.Height)); - else - setPosition((s32)(x*ReferenceRect.getWidth()), (s32)(y*ReferenceRect.getHeight())); - } - - //! Sets the new position of the cursor. - virtual void setPosition(const core::position2d<s32> &pos) - { - setPosition(pos.X, pos.Y); - } - - //! Sets the new position of the cursor. - virtual void setPosition(s32 x, s32 y) - { - RECT rect; - - if (UseReferenceRect) - { - SetCursorPos(ReferenceRect.UpperLeftCorner.X + x, - ReferenceRect.UpperLeftCorner.Y + y); - } - else - { - if (GetWindowRect(HWnd, &rect)) - SetCursorPos(x + rect.left + BorderX, y + rect.top + BorderY); - } - - CursorPos.X = x; - CursorPos.Y = y; - } - - //! Returns the current position of the mouse cursor. - virtual core::position2d<s32> getPosition() - { - updateInternalCursorPosition(); - return CursorPos; - } - - //! Returns the current position of the mouse cursor. - virtual core::position2d<f32> getRelativePosition() - { - updateInternalCursorPosition(); - - if (!UseReferenceRect) - { - return core::position2d<f32>(CursorPos.X * InvWindowSize.Width, - CursorPos.Y * InvWindowSize.Height); - } - - return core::position2d<f32>(CursorPos.X / (f32)ReferenceRect.getWidth(), - CursorPos.Y / (f32)ReferenceRect.getHeight()); - } - - //! Sets an absolute reference rect for calculating the cursor position. - virtual void setReferenceRect(core::rect<s32>* rect=0) - { - if (rect) - { - ReferenceRect = *rect; - UseReferenceRect = true; - - // prevent division through zero and uneven sizes - - if (!ReferenceRect.getHeight() || ReferenceRect.getHeight()%2) - ReferenceRect.LowerRightCorner.Y += 1; - - if (!ReferenceRect.getWidth() || ReferenceRect.getWidth()%2) - ReferenceRect.LowerRightCorner.X += 1; - } - else - UseReferenceRect = false; - } - - /** Used to notify the cursor that the window was resized. */ - virtual void OnResize(const core::dimension2d<u32>& size) - { - if (size.Width!=0) - InvWindowSize.Width = 1.0f / size.Width; - else - InvWindowSize.Width = 0.f; - - if (size.Height!=0) - InvWindowSize.Height = 1.0f / size.Height; - else - InvWindowSize.Height = 0.f; - } - - private: - - //! Updates the internal cursor position - void updateInternalCursorPosition() - { - POINT p; - if (!GetCursorPos(&p)) - { - DWORD xy = GetMessagePos(); - p.x = GET_X_LPARAM(xy); - p.y = GET_Y_LPARAM(xy); - } - - if (UseReferenceRect) - { - CursorPos.X = p.x - ReferenceRect.UpperLeftCorner.X; - CursorPos.Y = p.y - ReferenceRect.UpperLeftCorner.Y; - } - else - { - RECT rect; - if (GetWindowRect(HWnd, &rect)) - { - CursorPos.X = p.x-rect.left-BorderX; - CursorPos.Y = p.y-rect.top-BorderY; - } - else - { - // window seems not to be existent, so set cursor to - // a negative value - CursorPos.X = -1; - CursorPos.Y = -1; - } - } - } - - core::position2d<s32> CursorPos; - core::dimension2d<s32> WindowSize; - core::dimension2d<f32> InvWindowSize; - bool IsVisible; - HWND HWnd; - - s32 BorderX, BorderY; - bool UseReferenceRect; - core::rect<s32> ReferenceRect; - }; - - - //! returns the win32 cursor control - CCursorControl* getWin32CursorControl(); - - private: - - //! create the driver - void createDriver(); - - //! switchs to fullscreen - bool switchToFullScreen(); - - void getWindowsVersion(core::stringc& version); - - void resizeIfNecessary(); - - HWND HWnd; - CCursorControl* Win32CursorControl; - - bool ChangedToFullScreen; - bool Resized; - bool ExternalWindow; - }; - - -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_WINDOWS_CE_DEVICE_ -#endif // __C_IRR_DEVICE_WINCE_H_INCLUDED__ diff --git a/irrlicht-1.6/source/Irrlicht/CIrrMeshFileLoader.cpp b/irrlicht-1.6/source/Irrlicht/CIrrMeshFileLoader.cpp deleted file mode 100644 index db88ccfe3..000000000 --- a/irrlicht-1.6/source/Irrlicht/CIrrMeshFileLoader.cpp +++ /dev/null @@ -1,554 +0,0 @@ -// Copyright (C) 2002-2009 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_IRR_MESH_LOADER_ - -#include "CIrrMeshFileLoader.h" -#include "os.h" -#include "IXMLReader.h" -#include "SAnimatedMesh.h" -#include "fast_atof.h" -#include "IReadFile.h" -#include "IAttributes.h" -#include "IMeshSceneNode.h" -#include "CDynamicMeshBuffer.h" -#include "SMeshBufferLightMap.h" - -namespace irr -{ -namespace scene -{ - - -//! Constructor -CIrrMeshFileLoader::CIrrMeshFileLoader(scene::ISceneManager* smgr, - io::IFileSystem* fs) - : SceneManager(smgr), FileSystem(fs) -{ - - #ifdef _DEBUG - setDebugName("CIrrMeshFileLoader"); - #endif - -} - - -//! Returns true if the file maybe is able to be loaded by this class. -/** This decision should be based only on the file extension (e.g. ".cob") */ -bool CIrrMeshFileLoader::isALoadableFileExtension(const io::path& filename) const -{ - return core::hasFileExtension ( filename, "xml", "irrmesh" ); -} - - -//! 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* CIrrMeshFileLoader::createMesh(io::IReadFile* file) -{ - io::IXMLReader* reader = FileSystem->createXMLReader(file); - if (!reader) - return 0; - - // read until mesh section, skip other parts - - const core::stringc meshTagName = "mesh"; - IAnimatedMesh* mesh = 0; - - while(reader->read()) - { - if (reader->getNodeType() == io::EXN_ELEMENT) - { - if (meshTagName == reader->getNodeName()) - { - mesh = readMesh(reader); - break; - } - else - skipSection(reader, true); // unknown section - } - } - - reader->drop(); - - return mesh; -} - - -//! reads a mesh sections and creates a mesh from it -IAnimatedMesh* CIrrMeshFileLoader::readMesh(io::IXMLReader* reader) -{ - SAnimatedMesh* animatedmesh = new SAnimatedMesh(); - SMesh* mesh = new SMesh(); - - animatedmesh->addMesh(mesh); - mesh->drop(); - - core::stringc bbSectionName = "boundingBox"; - core::stringc bufferSectionName = "buffer"; - core::stringc meshSectionName = "mesh"; - - if (!reader->isEmptyElement()) - while(reader->read()) - { - if (reader->getNodeType() == io::EXN_ELEMENT) - { - const wchar_t* nodeName = reader->getNodeName(); - if (bbSectionName == nodeName) - { - // inside a bounding box, ignore it for now because - // we are calculating this anyway ourselves later. - } - else - if (bufferSectionName == nodeName) - { - // we've got a mesh buffer - - IMeshBuffer* buffer = readMeshBuffer(reader); - if (buffer) - { - mesh->addMeshBuffer(buffer); - buffer->drop(); - } - } - else - skipSection(reader, true); // unknown section - - } // end if node type is element - else - if (reader->getNodeType() == io::EXN_ELEMENT_END) - { - if (meshSectionName == reader->getNodeName()) - { - // end of mesh section reached, cancel out - break; - } - } - } // end while reader->read(); - - mesh->recalculateBoundingBox(); - animatedmesh->recalculateBoundingBox(); - - return animatedmesh; -} - - -//! reads a mesh sections and creates a mesh buffer from it -IMeshBuffer* CIrrMeshFileLoader::readMeshBuffer(io::IXMLReader* reader) -{ - CDynamicMeshBuffer* buffer = 0; - - core::stringc verticesSectionName = "vertices"; - core::stringc bbSectionName = "boundingBox"; - core::stringc materialSectionName = "material"; - core::stringc indicesSectionName = "indices"; - core::stringc bufferSectionName = "buffer"; - - bool insideVertexSection = false; - bool insideIndexSection = false; - - int vertexCount = 0; - int indexCount = 0; - - video::SMaterial material; - - if (!reader->isEmptyElement()) - while(reader->read()) - { - if (reader->getNodeType() == io::EXN_ELEMENT) - { - const wchar_t* nodeName = reader->getNodeName(); - if (bbSectionName == nodeName) - { - // inside a bounding box, ignore it for now because - // we are calculating this anyway ourselves later. - } - else - if (materialSectionName == nodeName) - { - //we've got a material - - io::IAttributes* attributes = FileSystem->createEmptyAttributes(SceneManager->getVideoDriver()); - attributes->read(reader, true, L"material"); - - SceneManager->getVideoDriver()->fillMaterialStructureFromAttributes(material, attributes); - attributes->drop(); - } - else - if (verticesSectionName == nodeName) - { - // vertices section - - const core::stringc vertexTypeName1 = "standard"; - const core::stringc vertexTypeName2 = "2tcoords"; - const core::stringc vertexTypeName3 = "tangents"; - - const wchar_t* vertexType = reader->getAttributeValue(L"type"); - vertexCount = reader->getAttributeValueAsInt(L"vertexCount"); - - insideVertexSection = true; - - video::E_INDEX_TYPE itype = (vertexCount > 65536)?irr::video::EIT_32BIT:irr::video::EIT_16BIT; - if (vertexTypeName1 == vertexType) - { - buffer = new CDynamicMeshBuffer(irr::video::EVT_STANDARD, itype); - - } - else - if (vertexTypeName2 == vertexType) - { - buffer = new CDynamicMeshBuffer(irr::video::EVT_2TCOORDS, itype); - } - else - if (vertexTypeName3 == vertexType) - { - buffer = new CDynamicMeshBuffer(irr::video::EVT_TANGENTS, itype); - } - buffer->getVertexBuffer().reallocate(vertexCount); - buffer->Material = material; - } - else - if (indicesSectionName == nodeName) - { - // indices section - - indexCount = reader->getAttributeValueAsInt(L"indexCount"); - insideIndexSection = true; - } - - } // end if node type is element - else - if (reader->getNodeType() == io::EXN_TEXT) - { - // read vertex data - if (insideVertexSection) - { - readMeshBuffer(reader, vertexCount, buffer); - insideVertexSection = false; - - } // end reading vertex array - else - if (insideIndexSection) - { - readIndices(reader, indexCount, buffer->getIndexBuffer()); - insideIndexSection = false; - } - - } // end if node type is text - else - if (reader->getNodeType() == io::EXN_ELEMENT_END) - { - if (bufferSectionName == reader->getNodeName()) - { - // end of buffer section reached, cancel out - break; - } - } - } // end while reader->read(); - - if (buffer) - buffer->recalculateBoundingBox(); - - return buffer; -} - - -//! read indices -void CIrrMeshFileLoader::readIndices(io::IXMLReader* reader, int indexCount, IIndexBuffer& indices) -{ - indices.reallocate(indexCount); - - core::stringc data = reader->getNodeData(); - const c8* p = &data[0]; - - for (int i=0; i<indexCount && *p; ++i) - { - findNextNoneWhiteSpace(&p); - indices.push_back(readInt(&p)); - } -} - - -void CIrrMeshFileLoader::readMeshBuffer(io::IXMLReader* reader, int vertexCount, CDynamicMeshBuffer* sbuffer) -{ - core::stringc data = reader->getNodeData(); - const c8* p = &data[0]; - scene::IVertexBuffer& Vertices = sbuffer->getVertexBuffer(); - video::E_VERTEX_TYPE vType = Vertices.getType(); - - if (sbuffer) - { - for (int i=0; i<vertexCount && *p; ++i) - { - switch(vType) - { - case video::EVT_STANDARD: - { - video::S3DVertex vtx; - // position - - findNextNoneWhiteSpace(&p); - vtx.Pos.X = readFloat(&p); - findNextNoneWhiteSpace(&p); - vtx.Pos.Y = readFloat(&p); - findNextNoneWhiteSpace(&p); - vtx.Pos.Z = readFloat(&p); - - // normal - - findNextNoneWhiteSpace(&p); - vtx.Normal.X = readFloat(&p); - findNextNoneWhiteSpace(&p); - vtx.Normal.Y = readFloat(&p); - findNextNoneWhiteSpace(&p); - vtx.Normal.Z = readFloat(&p); - - // color - - u32 col; - findNextNoneWhiteSpace(&p); - sscanf(p, "%08x", &col); - vtx.Color.set(col); - skipCurrentNoneWhiteSpace(&p); - - // tcoord1 - - findNextNoneWhiteSpace(&p); - vtx.TCoords.X = readFloat(&p); - findNextNoneWhiteSpace(&p); - vtx.TCoords.Y = readFloat(&p); - - Vertices.push_back(vtx); - } - break; - case video::EVT_2TCOORDS: - { - video::S3DVertex2TCoords vtx; - // position - - findNextNoneWhiteSpace(&p); - vtx.Pos.X = readFloat(&p); - findNextNoneWhiteSpace(&p); - vtx.Pos.Y = readFloat(&p); - findNextNoneWhiteSpace(&p); - vtx.Pos.Z = readFloat(&p); - - // normal - - findNextNoneWhiteSpace(&p); - vtx.Normal.X = readFloat(&p); - findNextNoneWhiteSpace(&p); - vtx.Normal.Y = readFloat(&p); - findNextNoneWhiteSpace(&p); - vtx.Normal.Z = readFloat(&p); - - // color - - u32 col; - findNextNoneWhiteSpace(&p); - sscanf(p, "%08x", &col); - vtx.Color.set(col); - skipCurrentNoneWhiteSpace(&p); - - // tcoord1 - - findNextNoneWhiteSpace(&p); - vtx.TCoords.X = readFloat(&p); - findNextNoneWhiteSpace(&p); - vtx.TCoords.Y = readFloat(&p); - - // tcoord2 - - findNextNoneWhiteSpace(&p); - vtx.TCoords2.X = readFloat(&p); - findNextNoneWhiteSpace(&p); - vtx.TCoords2.Y = readFloat(&p); - - Vertices.push_back(vtx); - } - break; - - case video::EVT_TANGENTS: - { - video::S3DVertexTangents vtx; - // position - - findNextNoneWhiteSpace(&p); - vtx.Pos.X = readFloat(&p); - findNextNoneWhiteSpace(&p); - vtx.Pos.Y = readFloat(&p); - findNextNoneWhiteSpace(&p); - vtx.Pos.Z = readFloat(&p); - - // normal - - findNextNoneWhiteSpace(&p); - vtx.Normal.X = readFloat(&p); - findNextNoneWhiteSpace(&p); - vtx.Normal.Y = readFloat(&p); - findNextNoneWhiteSpace(&p); - vtx.Normal.Z = readFloat(&p); - - // color - - u32 col; - findNextNoneWhiteSpace(&p); - sscanf(p, "%08x", &col); - vtx.Color.set(col); - skipCurrentNoneWhiteSpace(&p); - - // tcoord1 - - findNextNoneWhiteSpace(&p); - vtx.TCoords.X = readFloat(&p); - findNextNoneWhiteSpace(&p); - vtx.TCoords.Y = readFloat(&p); - - // tangent - - findNextNoneWhiteSpace(&p); - vtx.Tangent.X = readFloat(&p); - findNextNoneWhiteSpace(&p); - vtx.Tangent.Y = readFloat(&p); - findNextNoneWhiteSpace(&p); - vtx.Tangent.Z = readFloat(&p); - - // binormal - - findNextNoneWhiteSpace(&p); - vtx.Binormal.X = readFloat(&p); - findNextNoneWhiteSpace(&p); - vtx.Binormal.Y = readFloat(&p); - findNextNoneWhiteSpace(&p); - vtx.Binormal.Z = readFloat(&p); - - Vertices.push_back(vtx); - } - break; - }; - - } - } -} - - -//! skips an (unknown) section in the irrmesh document -void CIrrMeshFileLoader::skipSection(io::IXMLReader* reader, bool reportSkipping) -{ -#ifdef _DEBUG - os::Printer::log("irrMesh skipping section", core::stringc(reader->getNodeName()).c_str()); -#endif - - // skip if this element is empty anyway. - if (reader->isEmptyElement()) - return; - - // read until we've reached the last element in this section - u32 tagCounter = 1; - - while(tagCounter && reader->read()) - { - if (reader->getNodeType() == io::EXN_ELEMENT && - !reader->isEmptyElement()) - { - #ifdef _DEBUG - if (reportSkipping) - os::Printer::log("irrMesh unknown element:", core::stringc(reader->getNodeName()).c_str()); - #endif - - ++tagCounter; - } - else - if (reader->getNodeType() == io::EXN_ELEMENT_END) - --tagCounter; - } -} - - -//! parses a float from a char pointer and moves the pointer -//! to the end of the parsed float -inline f32 CIrrMeshFileLoader::readFloat(const c8** p) -{ - f32 ftmp; - *p = core::fast_atof_move(*p, ftmp); - return ftmp; -} - - -//! parses an int from a char pointer and moves the pointer to -//! the end of the parsed float -inline s32 CIrrMeshFileLoader::readInt(const c8** p) -{ - return (s32)readFloat(p); -} - - -//! places pointer to next begin of a token -void CIrrMeshFileLoader::skipCurrentNoneWhiteSpace(const c8** start) -{ - const c8* p = *start; - - while(*p && !(*p==' ' || *p=='\n' || *p=='\r' || *p=='\t')) - ++p; - - // TODO: skip comments <!-- --> - - *start = p; -} - -//! places pointer to next begin of a token -void CIrrMeshFileLoader::findNextNoneWhiteSpace(const c8** start) -{ - const c8* p = *start; - - while(*p && (*p==' ' || *p=='\n' || *p=='\r' || *p=='\t')) - ++p; - - // TODO: skip comments <!-- --> - - *start = p; -} - - -//! reads floats from inside of xml element until end of xml element -void CIrrMeshFileLoader::readFloatsInsideElement(io::IXMLReader* reader, f32* floats, u32 count) -{ - if (reader->isEmptyElement()) - return; - - while(reader->read()) - { - // TODO: check for comments inside the element - // and ignore them. - - if (reader->getNodeType() == io::EXN_TEXT) - { - // parse float data - core::stringc data = reader->getNodeData(); - const c8* p = &data[0]; - - for (u32 i=0; i<count; ++i) - { - findNextNoneWhiteSpace(&p); - if (*p) - floats[i] = readFloat(&p); - else - floats[i] = 0.0f; - } - } - else - if (reader->getNodeType() == io::EXN_ELEMENT_END) - break; // end parsing text - } -} - - - - -} // end namespace scene -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_IRR_MESH_LOADER_ diff --git a/irrlicht-1.6/source/Irrlicht/CIrrMeshFileLoader.h b/irrlicht-1.6/source/Irrlicht/CIrrMeshFileLoader.h deleted file mode 100644 index 82c29f783..000000000 --- a/irrlicht-1.6/source/Irrlicht/CIrrMeshFileLoader.h +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_IRR_MESH_FILE_LOADER_H_INCLUDED__ -#define __C_IRR_MESH_FILE_LOADER_H_INCLUDED__ - -#include "IMeshLoader.h" -#include "IFileSystem.h" -#include "IVideoDriver.h" -#include "irrString.h" -#include "SMesh.h" -#include "SMeshBuffer.h" -#include "CDynamicMeshBuffer.h" -#include "ISceneManager.h" - -namespace irr -{ -namespace scene -{ - - -//! Meshloader capable of loading .irrmesh meshes, the Irrlicht Engine mesh format for static meshes -class CIrrMeshFileLoader : public IMeshLoader -{ -public: - - //! Constructor - CIrrMeshFileLoader(scene::ISceneManager* smgr, io::IFileSystem* fs); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".cob") - virtual bool isALoadableFileExtension(const io::path& 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: - - //! reads a mesh sections and creates a mesh from it - IAnimatedMesh* readMesh(io::IXMLReader* reader); - - //! reads a mesh sections and creates a mesh buffer from it - IMeshBuffer* readMeshBuffer(io::IXMLReader* reader); - - //! skips an (unknown) section in the irrmesh file - void skipSection(io::IXMLReader* reader, bool reportSkipping); - - //! reads a <material> element and stores it in the material section - void readMaterial(io::IXMLReader* reader); - - //! parses a float from a char pointer and moves the pointer to - //! the end of the parsed float - inline f32 readFloat(const c8** p); - - //! parses an int from a char pointer and moves the pointer to - //! the end of the parsed float - inline s32 readInt(const c8** p); - - //! places pointer to next begin of a token - void findNextNoneWhiteSpace(const c8** p); - - //! places pointer to next begin of a token - void skipCurrentNoneWhiteSpace(const c8** p); - - //! reads floats from inside of xml element until end of xml element - void readFloatsInsideElement(io::IXMLReader* reader, f32* floats, u32 count); - - //! read the mesh buffers - void readMeshBuffer(io::IXMLReader* reader, int vertexCount, CDynamicMeshBuffer* sbuffer); - - //! read indices - void readIndices(io::IXMLReader* reader, int indexCount, IIndexBuffer& indices); - - - // member variables - - scene::ISceneManager* SceneManager; - io::IFileSystem* FileSystem; -}; - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CIrrMeshWriter.cpp b/irrlicht-1.6/source/Irrlicht/CIrrMeshWriter.cpp deleted file mode 100644 index f6b2d94ec..000000000 --- a/irrlicht-1.6/source/Irrlicht/CIrrMeshWriter.cpp +++ /dev/null @@ -1,315 +0,0 @@ -// Copyright (C) 2002-2009 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_IRR_WRITER_ - -#include "CIrrMeshWriter.h" -#include "os.h" -#include "IWriteFile.h" -#include "IXMLWriter.h" -#include "IMesh.h" -#include "IAttributes.h" - -namespace irr -{ -namespace scene -{ - - -CIrrMeshWriter::CIrrMeshWriter(video::IVideoDriver* driver, - io::IFileSystem* fs) - : FileSystem(fs), VideoDriver(driver), Writer(0) -{ - #ifdef _DEBUG - setDebugName("CIrrMeshWriter"); - #endif - - if (VideoDriver) - VideoDriver->grab(); - - if (FileSystem) - FileSystem->grab(); -} - - -CIrrMeshWriter::~CIrrMeshWriter() -{ - if (VideoDriver) - VideoDriver->drop(); - - if (FileSystem) - FileSystem->drop(); -} - - -//! Returns the type of the mesh writer -EMESH_WRITER_TYPE CIrrMeshWriter::getType() const -{ - return EMWT_IRR_MESH; -} - - -//! writes a mesh -bool CIrrMeshWriter::writeMesh(io::IWriteFile* file, scene::IMesh* mesh, s32 flags) -{ - if (!file) - return false; - - Writer = FileSystem->createXMLWriter(file); - - if (!Writer) - { - os::Printer::log("Could not write file", file->getFileName()); - return false; - } - - os::Printer::log("Writing mesh", file->getFileName()); - - // write IRR MESH header - - Writer->writeXMLHeader(); - - Writer->writeElement(L"mesh", false, - L"xmlns", L"http://irrlicht.sourceforge.net/IRRMESH_09_2007", - L"version", L"1.0"); - Writer->writeLineBreak(); - - // add some informational comment. Add a space after and before the comment - // tags so that some braindead xml parsers (AS anyone?) are able to parse this too. - - core::stringw infoComment = L" This file contains a static mesh in the Irrlicht Engine format with "; - infoComment += core::stringw(mesh->getMeshBufferCount()); - infoComment += L" materials."; - - Writer->writeComment(infoComment.c_str()); - Writer->writeLineBreak(); - - // write mesh bounding box - - writeBoundingBox(mesh->getBoundingBox()); - Writer->writeLineBreak(); - - // write mesh buffers - - for (int i=0; i<(int)mesh->getMeshBufferCount(); ++i) - { - scene::IMeshBuffer* buffer = mesh->getMeshBuffer(i); - if (buffer) - { - writeMeshBuffer(buffer); - Writer->writeLineBreak(); - } - } - - Writer->writeClosingTag(L"mesh"); - - Writer->drop(); - return true; -} - - -void CIrrMeshWriter::writeBoundingBox(const core::aabbox3df& box) -{ - Writer->writeElement(L"boundingBox", true, - L"minEdge", getVectorAsStringLine(box.MinEdge).c_str(), - L"maxEdge", getVectorAsStringLine(box.MaxEdge).c_str()); -} - - -core::stringw CIrrMeshWriter::getVectorAsStringLine(const core::vector3df& v) const -{ - core::stringw str; - - str = core::stringw(v.X); - str += L" "; - str += core::stringw(v.Y); - str += L" "; - str += core::stringw(v.Z); - - return str; -} - - -core::stringw CIrrMeshWriter::getVectorAsStringLine(const core::vector2df& v) const -{ - core::stringw str; - - str = core::stringw(v.X); - str += L" "; - str += core::stringw(v.Y); - - return str; -} - - -void CIrrMeshWriter::writeMeshBuffer(const scene::IMeshBuffer* buffer) -{ - Writer->writeElement(L"buffer", false); - Writer->writeLineBreak(); - - // write bounding box - - writeBoundingBox(buffer->getBoundingBox()); - Writer->writeLineBreak(); - - // write material - - writeMaterial(buffer->getMaterial()); - - // write vertices - - const core::stringw vertexTypeStr = video::sBuiltInVertexTypeNames[buffer->getVertexType()]; - - Writer->writeElement(L"vertices", false, - L"type", vertexTypeStr.c_str(), - L"vertexCount", core::stringw(buffer->getVertexCount()).c_str()); - - Writer->writeLineBreak(); - - u32 vertexCount = buffer->getVertexCount(); - - switch(buffer->getVertexType()) - { - case video::EVT_STANDARD: - { - video::S3DVertex* vtx = (video::S3DVertex*)buffer->getVertices(); - for (u32 j=0; j<vertexCount; ++j) - { - core::stringw str = getVectorAsStringLine(vtx[j].Pos); - str += L" "; - str += getVectorAsStringLine(vtx[j].Normal); - - char tmp[12]; - sprintf(tmp, " %02x%02x%02x%02x ", vtx[j].Color.getAlpha(), vtx[j].Color.getRed(), vtx[j].Color.getBlue(), vtx[j].Color.getGreen()); - str += tmp; - - str += getVectorAsStringLine(vtx[j].TCoords); - - Writer->writeText(str.c_str()); - Writer->writeLineBreak(); - } - } - break; - case video::EVT_2TCOORDS: - { - video::S3DVertex2TCoords* vtx = (video::S3DVertex2TCoords*)buffer->getVertices(); - for (u32 j=0; j<vertexCount; ++j) - { - core::stringw str = getVectorAsStringLine(vtx[j].Pos); - str += L" "; - str += getVectorAsStringLine(vtx[j].Normal); - - char tmp[12]; - sprintf(tmp, " %02x%02x%02x%02x ", vtx[j].Color.getAlpha(), vtx[j].Color.getRed(), vtx[j].Color.getBlue(), vtx[j].Color.getGreen()); - str += tmp; - - str += getVectorAsStringLine(vtx[j].TCoords); - str += L" "; - str += getVectorAsStringLine(vtx[j].TCoords2); - - Writer->writeText(str.c_str()); - Writer->writeLineBreak(); - } - } - break; - case video::EVT_TANGENTS: - { - video::S3DVertexTangents* vtx = (video::S3DVertexTangents*)buffer->getVertices(); - for (u32 j=0; j<vertexCount; ++j) - { - core::stringw str = getVectorAsStringLine(vtx[j].Pos); - str += L" "; - str += getVectorAsStringLine(vtx[j].Normal); - - char tmp[12]; - sprintf(tmp, " %02x%02x%02x%02x ", vtx[j].Color.getAlpha(), vtx[j].Color.getRed(), vtx[j].Color.getBlue(), vtx[j].Color.getGreen()); - str += tmp; - - str += getVectorAsStringLine(vtx[j].TCoords); - str += L" "; - str += getVectorAsStringLine(vtx[j].Tangent); - str += L" "; - str += getVectorAsStringLine(vtx[j].Binormal); - - Writer->writeText(str.c_str()); - Writer->writeLineBreak(); - } - } - break; - } - - Writer->writeClosingTag(L"vertices"); - Writer->writeLineBreak(); - - // write indices - - Writer->writeElement(L"indices", false, - L"indexCount", core::stringw(buffer->getIndexCount()).c_str()); - - Writer->writeLineBreak(); - - int indexCount = (int)buffer->getIndexCount(); - - video::E_INDEX_TYPE iType = buffer->getIndexType(); - - const u16* idx16 = buffer->getIndices(); - const u32* idx32 = (u32*) buffer->getIndices(); - const int maxIndicesPerLine = 25; - - for (int i=0; i<indexCount; ++i) - { - if(iType == video::EIT_16BIT) - { - core::stringw str((int)idx16[i]); - Writer->writeText(str.c_str()); - } - else - { - core::stringw str((int)idx32[i]); - Writer->writeText(str.c_str()); - } - - if (i % maxIndicesPerLine != maxIndicesPerLine) - { - if (i % maxIndicesPerLine == maxIndicesPerLine-1) - Writer->writeLineBreak(); - else - Writer->writeText(L" "); - } - } - - if ((indexCount-1) % maxIndicesPerLine != maxIndicesPerLine-1) - Writer->writeLineBreak(); - - Writer->writeClosingTag(L"indices"); - Writer->writeLineBreak(); - - // close buffer tag - - Writer->writeClosingTag(L"buffer"); -} - - -void CIrrMeshWriter::writeMaterial(const video::SMaterial& material) -{ - // simply use irrlichts built-in attribute serialization capabilities here: - - io::IAttributes* attributes = - VideoDriver->createAttributesFromMaterial(material); - - if (attributes) - { - attributes->write(Writer, false, L"material"); - attributes->drop(); - } -} - - -} // end namespace -} // end namespace - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CIrrMeshWriter.h b/irrlicht-1.6/source/Irrlicht/CIrrMeshWriter.h deleted file mode 100644 index 94cf6f369..000000000 --- a/irrlicht-1.6/source/Irrlicht/CIrrMeshWriter.h +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_IRR_MESH_WRITER_H_INCLUDED__ -#define __IRR_IRR_MESH_WRITER_H_INCLUDED__ - -#include "IMeshWriter.h" -#include "S3DVertex.h" -#include "IVideoDriver.h" -#include "IFileSystem.h" - -namespace irr -{ -namespace io -{ - class IXMLWriter; -} -namespace scene -{ - class IMeshBuffer; - - - //! class to write meshes, implementing a IrrMesh (.irrmesh, .xml) writer - /** This writer implementation has been originally developed for irrEdit and then - merged out to the Irrlicht Engine */ - class CIrrMeshWriter : public IMeshWriter - { - public: - - CIrrMeshWriter(video::IVideoDriver* driver, io::IFileSystem* fs); - virtual ~CIrrMeshWriter(); - - //! 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: - - void writeBoundingBox(const core::aabbox3df& box); - - void writeMeshBuffer(const scene::IMeshBuffer* buffer); - - void writeMaterial(const video::SMaterial& material); - - core::stringw getVectorAsStringLine(const core::vector3df& v) const; - - core::stringw getVectorAsStringLine(const core::vector2df& v) const; - - // member variables: - - io::IFileSystem* FileSystem; - video::IVideoDriver* VideoDriver; - io::IXMLWriter* Writer; - }; - -} // end namespace -} // end namespace - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CLMTSMeshFileLoader.cpp b/irrlicht-1.6/source/Irrlicht/CLMTSMeshFileLoader.cpp deleted file mode 100644 index fe1c3ee11..000000000 --- a/irrlicht-1.6/source/Irrlicht/CLMTSMeshFileLoader.cpp +++ /dev/null @@ -1,373 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h -// This file was written by Jonas Petersen and modified by Nikolaus Gebhardt. -// See CLMTSMeshFileLoder.h for details. -/* - -CLMTSMeshFileLoader.cpp - -LMTSMeshFileLoader -Written by Jonas Petersen (a.k.a. jox) - -Version 1.5 - 15 March 2005 - -Get the latest version here: http://development.mindfloaters.de/ - -This class allows loading meshes with lightmaps (*.lmts + *.tga files) that were created -using Pulsar LMTools by Lord Trancos (http://www.geocities.com/dxlab/index_en.html) - -Notes: -- This version does not support user data in the *.lmts files, but still loads those files (by skipping the extra data). - -License: --------- - -It's free. You are encouraged to give me credit if you use it in your software. - -Version History: ----------------- - -Version 1.5 - 15 March 2005 -- Did a better cleanup. No memory leaks in case of an loading error. -- Added "#include <stdio.h>" for sprintf. - -Version 1.4 - 12 March 2005 -- Fixed bug in texture and subset loading code that would possibly cause crash. -- Fixed memory cleanup to avoid leak when loading more then one mesh -- Used the irrlicht Logger instead of cerr to output warnings and errors. - For this I had to change the constructor - from: - CLMTSMeshFileLoader(io::IFileSystem* fs, video::IVideoDriver* driver) - to: - CLMTSMeshFileLoader(IrrlichtDevice* device) - -Version 1.3 - 15 February 2005 -- Fixed bug that prevented loading more than one different lmts files. -- Removed unnecessary "#include <os.h>". -- Added "std::" in front of "cerr". This was necessary for Visual Studio .NET, - I hope it's not disturbing other compilers. -- Added warning message when a texture can not be loaded. -- Changed the documentation a bit (minor). - -Version 1.2 -- To avoid confusion I skipped version 1.2 because the website was offering -version 1.2 even though it was only version 1.1. Sorry about that. - -Version 1.1 - 29 July 2004 -- Added setTexturePath() function -- Minor improvements - -Version 1.0 - 29 July 2004 -- Initial release - - -*/ -////////////////////////////////////////////////////////////////////// - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_LMTS_LOADER_ - -#include "SMeshBufferLightMap.h" -#include "SAnimatedMesh.h" -#include "SMeshBuffer.h" -#include "irrString.h" -#include "IReadFile.h" -#include "IAttributes.h" -#include "ISceneManager.h" -#include "CLMTSMeshFileLoader.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - -CLMTSMeshFileLoader::CLMTSMeshFileLoader(io::IFileSystem* fs, - video::IVideoDriver* driver, io::IAttributes* parameters) - : Textures(0), Subsets(0), Triangles(0), - Parameters(parameters), Driver(driver), FileSystem(fs), FlipEndianess(false) -{ - #ifdef _DEBUG - setDebugName("CLMTSMeshFileLoader"); - #endif - - if (Driver) - Driver->grab(); - - if (FileSystem) - FileSystem->grab(); -} - - -CLMTSMeshFileLoader::~CLMTSMeshFileLoader() -{ - cleanup(); - - if (Driver) - Driver->drop(); - - if (FileSystem) - FileSystem->drop(); -} - - -void CLMTSMeshFileLoader::cleanup() -{ - delete [] Textures; - Textures = 0; - delete [] Subsets; - Subsets = 0; - delete [] Triangles; - Triangles = 0; -} - - -bool CLMTSMeshFileLoader::isALoadableFileExtension(const io::path& filename) const -{ - return core::hasFileExtension ( filename, "lmts" ); -} - - -IAnimatedMesh* CLMTSMeshFileLoader::createMesh(io::IReadFile* file) -{ - u32 i; - u32 id; - - // HEADER - - file->read(&Header, sizeof(SLMTSHeader)); - if (Header.MagicID == 0x4C4D5354) - { - FlipEndianess = true; - Header.MagicID = os::Byteswap::byteswap(Header.MagicID); - Header.Version = os::Byteswap::byteswap(Header.Version); - Header.HeaderSize = os::Byteswap::byteswap(Header.HeaderSize); - Header.TextureCount = os::Byteswap::byteswap(Header.TextureCount); - Header.SubsetCount = os::Byteswap::byteswap(Header.SubsetCount); - Header.TriangleCount = os::Byteswap::byteswap(Header.TriangleCount); - Header.SubsetSize = os::Byteswap::byteswap(Header.SubsetSize); - Header.VertexSize = os::Byteswap::byteswap(Header.VertexSize); - } - if (Header.MagicID != 0x53544D4C) { // "LMTS" - os::Printer::log("LMTS ERROR: wrong header magic id!", ELL_ERROR); - return 0; - } - - //Skip any User Data (arbitrary app specific data) - - const s32 userSize = Header.HeaderSize - sizeof(SLMTSHeader); - if (userSize>0) - file->seek(userSize,true); - - // TEXTURES - - file->read(&id, sizeof(u32)); - if (FlipEndianess) - id = os::Byteswap::byteswap(id); - if (id != 0x54584554) { // "TEXT" - os::Printer::log("LMTS ERROR: wrong texture magic id!", ELL_ERROR); - return 0; - } - - Textures = new SLMTSTextureInfoEntry[Header.TextureCount]; - - file->read(Textures, sizeof(SLMTSTextureInfoEntry)*Header.TextureCount); - if (FlipEndianess) - { - for (i=0; i<Header.TextureCount; ++i) - Textures[i].Flags = os::Byteswap::byteswap(Textures[i].Flags); - } - - // SUBSETS - - file->read(&id, sizeof(u32)); - if (FlipEndianess) - id = os::Byteswap::byteswap(id); - if (id != 0x53425553) // "SUBS" - { - os::Printer::log("LMTS ERROR: wrong subset magic id!", ELL_ERROR); - cleanup(); - return 0; - } - - Subsets = new SLMTSSubsetInfoEntry[Header.SubsetCount]; - const s32 subsetUserSize = Header.SubsetSize - sizeof(SLMTSSubsetInfoEntry); - - for (i=0; i<Header.SubsetCount; ++i) - { - file->read(&Subsets[i], sizeof(SLMTSSubsetInfoEntry)); - if (FlipEndianess) - { - Subsets[i].Offset = os::Byteswap::byteswap(Subsets[i].Offset); - Subsets[i].Count = os::Byteswap::byteswap(Subsets[i].Count); - Subsets[i].TextID1 = os::Byteswap::byteswap(Subsets[i].TextID1); - Subsets[i].TextID2 = os::Byteswap::byteswap(Subsets[i].TextID2); - } - if (subsetUserSize>0) - file->seek(subsetUserSize,true); - } - - // TRIANGLES - - file->read(&id, sizeof(u32)); - if (FlipEndianess) - id = os::Byteswap::byteswap(id); - if (id != 0x53495254) // "TRIS" - { - os::Printer::log("LMTS ERROR: wrong triangle magic id!", ELL_ERROR); - cleanup(); - return 0; - } - - Triangles = new SLMTSTriangleDataEntry[(Header.TriangleCount*3)]; - const s32 triUserSize = Header.VertexSize - sizeof(SLMTSTriangleDataEntry); - - for (i=0; i<(Header.TriangleCount*3); ++i) - { - file->read(&Triangles[i], sizeof(SLMTSTriangleDataEntry)); - if (FlipEndianess) - { - Triangles[i].X = os::Byteswap::byteswap(Triangles[i].X); - Triangles[i].Y = os::Byteswap::byteswap(Triangles[i].Y); - Triangles[i].Z = os::Byteswap::byteswap(Triangles[i].Z); - Triangles[i].U1 = os::Byteswap::byteswap(Triangles[i].U1); - Triangles[i].V1 = os::Byteswap::byteswap(Triangles[i].U2); - Triangles[i].U2 = os::Byteswap::byteswap(Triangles[i].V1); - Triangles[i].V2 = os::Byteswap::byteswap(Triangles[i].V2); - } - if (triUserSize>0) - file->seek(triUserSize,true); - } - - ///////////////////////////////////////////////////////////////// - - SMesh* mesh = new SMesh(); - - constructMesh(mesh); - - loadTextures(mesh); - - cleanup(); - - SAnimatedMesh* am = new SAnimatedMesh(); - am->Type = EAMT_LMTS; // not unknown to irrlicht anymore - - am->addMesh(mesh); - am->recalculateBoundingBox(); - mesh->drop(); - return am; -} - - -void CLMTSMeshFileLoader::constructMesh(SMesh* mesh) -{ - for (s32 i=0; i<Header.SubsetCount; ++i) - { - scene::SMeshBufferLightMap* meshBuffer = new scene::SMeshBufferLightMap(); - - // EMT_LIGHTMAP_M2/EMT_LIGHTMAP_M4 also possible - meshBuffer->Material.MaterialType = video::EMT_LIGHTMAP; - meshBuffer->Material.Wireframe = false; - meshBuffer->Material.Lighting = false; - - mesh->addMeshBuffer(meshBuffer); - - const u32 offs = Subsets[i].Offset * 3; - - for (u32 sc=0; sc<Subsets[i].Count; sc++) - { - const u32 idx = meshBuffer->getVertexCount(); - - for (u32 vu=0; vu<3; ++vu) - { - const SLMTSTriangleDataEntry& v = Triangles[offs+(3*sc)+vu]; - meshBuffer->Vertices.push_back( - video::S3DVertex2TCoords( - v.X, v.Y, v.Z, - video::SColor(255,255,255,255), - v.U1, v.V1, v.U2, v.V2)); - } - const core::vector3df normal = core::plane3df( - meshBuffer->Vertices[idx].Pos, - meshBuffer->Vertices[idx+1].Pos, - meshBuffer->Vertices[idx+2].Pos).Normal; - - meshBuffer->Vertices[idx].Normal = normal; - meshBuffer->Vertices[idx+1].Normal = normal; - meshBuffer->Vertices[idx+2].Normal = normal; - - meshBuffer->Indices.push_back(idx); - meshBuffer->Indices.push_back(idx+1); - meshBuffer->Indices.push_back(idx+2); - } - meshBuffer->drop(); - } - - for (u32 j=0; j<mesh->MeshBuffers.size(); ++j) - mesh->MeshBuffers[j]->recalculateBoundingBox(); - - mesh->recalculateBoundingBox(); -} - - -void CLMTSMeshFileLoader::loadTextures(SMesh* mesh) -{ - if (!Driver || !FileSystem) - return; - - // load textures - - // a little too much space, but won't matter here - core::array<video::ITexture*> tex; - tex.reallocate(Header.TextureCount); - core::array<video::ITexture*> lig; - lig.reallocate(Header.TextureCount); - core::array<u32> id2id; - id2id.reallocate(Header.TextureCount); - - const core::stringc Path = Parameters->getAttributeAsString(LMTS_TEXTURE_PATH); - - core::stringc s; - for (u32 t=0; t<Header.TextureCount; ++t) - { - video::ITexture* tmptex = 0; - s = Path; - s.append(Textures[t].Filename); - - if (FileSystem->existFile(s)) - tmptex = Driver->getTexture(s); - else - os::Printer::log("LMTS WARNING: Texture does not exist", s.c_str(), ELL_WARNING); - - if (Textures[t].Flags & 0x01) - { - id2id.push_back(lig.size()); - lig.push_back(tmptex); - } - else - { - id2id.push_back(tex.size()); - tex.push_back(tmptex); - } - } - - // attach textures to materials. - - for (u32 i=0; i<Header.SubsetCount; ++i) - { - if (Subsets[i].TextID1 < Header.TextureCount && id2id[Subsets[i].TextID1] < tex.size()) - mesh->getMeshBuffer(i)->getMaterial().setTexture(0, tex[id2id[Subsets[i].TextID1]]); - if (Subsets[i].TextID2 < Header.TextureCount && id2id[Subsets[i].TextID2] < lig.size()) - mesh->getMeshBuffer(i)->getMaterial().setTexture(1, lig[id2id[Subsets[i].TextID2]]); - - if (!mesh->getMeshBuffer(i)->getMaterial().getTexture(1)) - mesh->getMeshBuffer(i)->getMaterial().MaterialType = video::EMT_SOLID; - } -} - - -} // end namespace scene -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_LMTS_LOADER_ diff --git a/irrlicht-1.6/source/Irrlicht/CLMTSMeshFileLoader.h b/irrlicht-1.6/source/Irrlicht/CLMTSMeshFileLoader.h deleted file mode 100644 index e2373cc8c..000000000 --- a/irrlicht-1.6/source/Irrlicht/CLMTSMeshFileLoader.h +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h -// -// I (Nikolaus Gebhardt) did some few changes to Jonas Petersen's original loader: -// - removed setTexturePath() and replaced with the ISceneManager::getStringParameter()-stuff. -// - added EAMT_LMTS enumeration value -// Thanks a lot to Jonas Petersen for his work -// on this and that he gave me his permission to add it into Irrlicht. -/* - -CLMTSMeshFileLoader.h - -LMTSMeshFileLoader -Written by Jonas Petersen (a.k.a. jox) - -Version 1.5 - 15 March 2005 - -*/ - -#if !defined(__C_LMTS_MESH_FILE_LOADER_H_INCLUDED__) -#define __C_LMTS_MESH_FILE_LOADER_H_INCLUDED__ - -#include "IMeshLoader.h" -#include "SMesh.h" -#include "IFileSystem.h" -#include "IVideoDriver.h" - -namespace irr -{ -namespace scene -{ - -class CLMTSMeshFileLoader : public IMeshLoader -{ -public: - - CLMTSMeshFileLoader(io::IFileSystem* fs, - video::IVideoDriver* driver, io::IAttributes* parameters); - - virtual ~CLMTSMeshFileLoader(); - - virtual bool isALoadableFileExtension(const io::path& filename) const; - - virtual IAnimatedMesh* createMesh(io::IReadFile* file); - -private: - void constructMesh(SMesh* mesh); - void loadTextures(SMesh* mesh); - void cleanup(); - -// byte-align structures -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) -# pragma pack( push, packing ) -# pragma pack( 1 ) -# define PACK_STRUCT -#elif defined( __GNUC__ ) -# define PACK_STRUCT __attribute__((packed)) -#else -# error compiler not supported -#endif - - struct SLMTSHeader - { - u32 MagicID; - u32 Version; - u32 HeaderSize; - u16 TextureCount; - u16 SubsetCount; - u32 TriangleCount; - u16 SubsetSize; - u16 VertexSize; - } PACK_STRUCT; - - struct SLMTSTextureInfoEntry - { - c8 Filename[256]; - u16 Flags; - } PACK_STRUCT; - - struct SLMTSSubsetInfoEntry - { - u32 Offset; - u32 Count; - u16 TextID1; - u16 TextID2; - } PACK_STRUCT; - - struct SLMTSTriangleDataEntry - { - f32 X; - f32 Y; - f32 Z; - f32 U1; - f32 V1; - f32 U2; - f32 V2; - } PACK_STRUCT; - -// Default alignment -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) -# pragma pack( pop, packing ) -#endif - -#undef PACK_STRUCT - - SLMTSHeader Header; - SLMTSTextureInfoEntry* Textures; - SLMTSSubsetInfoEntry* Subsets; - SLMTSTriangleDataEntry* Triangles; - - io::IAttributes* Parameters; - video::IVideoDriver* Driver; - io::IFileSystem* FileSystem; - bool FlipEndianess; -}; - -} // end namespace scene -} // end namespace irr - -#endif // !defined(__C_LMTS_MESH_FILE_LOADER_H_INCLUDED__) diff --git a/irrlicht-1.6/source/Irrlicht/CLWOMeshFileLoader.cpp b/irrlicht-1.6/source/Irrlicht/CLWOMeshFileLoader.cpp deleted file mode 100644 index f7c515dc8..000000000 --- a/irrlicht-1.6/source/Irrlicht/CLWOMeshFileLoader.cpp +++ /dev/null @@ -1,2112 +0,0 @@ -// Copyright (C) 2007-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CLWOMeshFileLoader.h" -#include "os.h" -#include "SAnimatedMesh.h" -#include "SMesh.h" -#include "IReadFile.h" -#include "ISceneManager.h" -#include "IFileSystem.h" -#include "IVideoDriver.h" -#include "IMeshManipulator.h" - -namespace irr -{ -namespace scene -{ - -#ifdef _DEBUG -#define LWO_READER_DEBUG -#endif - -#define charsToUIntD(a, b, c, d) ((a << 24) | (b << 16) | (c << 8) | d) -inline unsigned int charsToUInt(const char *str) -{ - return (str[0] << 24) | (str[1] << 16) | (str[2] << 8) | str[3]; -} - - -struct tLWOTextureInfo -{ - tLWOTextureInfo() : UVTag(0), DUVTag(0), Flags(0), WidthWrap(2), - HeightWrap(2), OpacType(0), Color(0xffffffff), - Value(0.0f), AntiAliasing(1.0f), Opacity(1.0f), - Axis(255), Projection(0), Active(false) {} - core::stringc Type; - core::stringc Map; - core::stringc AlphaMap; - core::stringc UVname; - u16 UVTag; - u16 DUVTag; - u16 Flags; - u16 WidthWrap; - u16 HeightWrap; - u16 OpacType; - u16 IParam[3]; - core::vector3df Size; - core::vector3df Center; - core::vector3df Falloff; - core::vector3df Velocity; - video::SColor Color; - f32 Value; - f32 AntiAliasing; - f32 Opacity; - f32 FParam[3]; - u8 Axis; - u8 Projection; - bool Active; -}; - -struct CLWOMeshFileLoader::tLWOMaterial -{ - tLWOMaterial() : Meshbuffer(0), TagType(0), Flags(0), ReflMode(3), TranspMode(3), - Glow(0), AlphaMode(2), Luminance(0.0f), Diffuse(1.0f), Specular(0.0f), - Reflection(0.0f), Transparency(0.0f), Translucency(0.0f), - Sharpness(0.0f), ReflSeamAngle(0.0f), ReflBlur(0.0f), - RefrIndex(1.0f), TranspBlur(0.0f), SmoothingAngle(0.0f), - EdgeTransparency(0.0f), HighlightColor(0.0f), ColorFilter(0.0f), - AdditiveTransparency(0.0f), GlowIntensity(0.0f), GlowSize(0.0f), - AlphaValue(0.0f), VertexColorIntensity(0.0f), VertexColor() {} - - core::stringc Name; - scene::SMeshBuffer *Meshbuffer; - core::stringc ReflMap; - u16 TagType; - u16 Flags; - u16 ReflMode; - u16 TranspMode; - u16 Glow; - u16 AlphaMode; - f32 Luminance; - f32 Diffuse; - f32 Specular; - f32 Reflection; - f32 Transparency; - f32 Translucency; - f32 Sharpness; - f32 ReflSeamAngle; - f32 ReflBlur; - f32 RefrIndex; - f32 TranspBlur; - f32 SmoothingAngle; - f32 EdgeTransparency; - f32 HighlightColor; - f32 ColorFilter; - f32 AdditiveTransparency; - f32 GlowIntensity; - f32 GlowSize; - f32 AlphaValue; - f32 VertexColorIntensity; - video::SColorf VertexColor; - u32 Envelope[23]; - tLWOTextureInfo Texture[7]; -}; - -struct tLWOLayerInfo -{ - u16 Number; - u16 Parent; - u16 Flags; - bool Active; - core::stringc Name; - core::vector3df Pivot; -}; - - -//! Constructor -CLWOMeshFileLoader::CLWOMeshFileLoader(scene::ISceneManager* smgr, - io::IFileSystem* fs) -: SceneManager(smgr), FileSystem(fs), File(0), Mesh(0) -{ - #ifdef _DEBUG - setDebugName("CLWOMeshFileLoader"); - #endif -} - - -//! destructor -CLWOMeshFileLoader::~CLWOMeshFileLoader() -{ - if (Mesh) - Mesh->drop(); -} - - -//! returns true if the file maybe is able to be loaded by this class -//! based on the file extension (e.g. ".bsp") -bool CLWOMeshFileLoader::isALoadableFileExtension(const io::path& filename) const -{ - return core::hasFileExtension(filename, "lwo"); -} - - -//! creates/loads an animated mesh from the file. -IAnimatedMesh* CLWOMeshFileLoader::createMesh(io::IReadFile* file) -{ - File = file; - - if (Mesh) - Mesh->drop(); - - Mesh = new SMesh(); - - if (!readFileHeader()) - return 0; - - if (!readChunks()) - return 0; - -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: Creating geometry."); - os::Printer::log("LWO loader: Assigning UV maps."); -#endif - u32 i; - for (i=0; i<Materials.size(); ++i) - { - u16 uvTag; - for (u32 j=0; j<2; ++j) // max 2 texture coords - { - if (Materials[i]->Texture[j].UVname.size()) - { - for (uvTag=0; uvTag<UvName.size(); ++uvTag) - { - if (Materials[i]->Texture[j].UVname == UvName[uvTag]) - { - Materials[i]->Texture[j].UVTag=uvTag; - break; - } - } - for (uvTag=0; uvTag<DUvName.size(); ++uvTag) - { - if (Materials[i]->Texture[j].UVname == DUvName[uvTag]) - { - Materials[i]->Texture[j].DUVTag=uvTag; - break; - } - } - } - } - } -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: Creating polys."); -#endif - // create actual geometry for lwo2 - if (FormatVersion==2) - { - core::array<u32>vertexCount; - vertexCount.reallocate(Materials.size()); - for (i=0; i<Materials.size(); ++i) - vertexCount.push_back(0); - for (u32 polyIndex=0; polyIndex<Indices.size(); ++polyIndex) - vertexCount[MaterialMapping[polyIndex]] += Indices[polyIndex].size(); - for (i=0; i<Materials.size(); ++i) - { - Materials[i]->Meshbuffer->Vertices.reallocate(vertexCount[i]); - Materials[i]->Meshbuffer->Indices.reallocate(vertexCount[i]); - } - } - // create actual geometry for lwo2 - for (u32 polyIndex=0; polyIndex<Indices.size(); ++polyIndex) - { - const u16 tag = MaterialMapping[polyIndex]; - scene::SMeshBuffer *mb=Materials[tag]->Meshbuffer; - const core::array<u32>& poly = Indices[polyIndex]; - const u32 polySize=poly.size(); - const u16 uvTag = Materials[tag]->Texture[0].UVTag; - const u16 duvTag = Materials[tag]->Texture[0].DUVTag; - video::S3DVertex vertex; - const u32 vertCount=mb->Vertices.size(); - for (u32 i=0; i<polySize; ++i) - { - const u32 j=poly[i]; - vertex.Pos=Points[j]; - if (uvTag<UvIndex.size()) - { - for (u32 uvsearch=0; uvsearch < UvIndex[uvTag].size(); ++uvsearch) - { - if(j==UvIndex[uvTag][uvsearch]) - { - vertex.TCoords=TCoords[uvTag][uvsearch]; - break; - } - } - if (duvTag<DUvName.size()) - { - for (u32 polysearch = 0; polysearch < VmPolyPointsIndex[duvTag].size(); polysearch += 2) - { - if (polyIndex==VmPolyPointsIndex[duvTag][polysearch] && j==VmPolyPointsIndex[duvTag][polysearch+1]) - { - vertex.TCoords=VmCoordsIndex[duvTag][polysearch/2]; - break; - } - } - } - } - mb->Vertices.push_back(vertex); - } - // triangulate as trifan - if (polySize>2) - { - for (u32 i=1; i<polySize-1; ++i) - { - mb->Indices.push_back(vertCount); - mb->Indices.push_back(vertCount+i); - mb->Indices.push_back(vertCount+i+1); - } - } - } -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: Fixing meshbuffers."); -#endif - for (u32 i=0; i<Materials.size(); ++i) - { -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: Material name", Materials[i]->Name); - os::Printer::log("LWO loader: Vertex count", core::stringc(Materials[i]->Meshbuffer->Vertices.size())); -#endif - if (!Materials[i]->Meshbuffer->Vertices.size()) - { - Materials[i]->Meshbuffer->drop(); - delete Materials[i]; - continue; - } - for (u32 j=0; j<Materials[i]->Meshbuffer->Vertices.size(); ++j) - Materials[i]->Meshbuffer->Vertices[j].Color=Materials[i]->Meshbuffer->Material.DiffuseColor; - Materials[i]->Meshbuffer->recalculateBoundingBox(); - - // load textures - video::SMaterial& irrMat=Materials[i]->Meshbuffer->Material; - if (Materials[i]->Texture[0].Map != "") // diffuse - irrMat.setTexture(0,loadTexture(Materials[i]->Texture[0].Map)); - if (Materials[i]->Texture[3].Map != "") // reflection - { -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading reflection texture."); -#endif - video::ITexture* reflTexture = loadTexture(Materials[i]->Texture[3].Map); - if (reflTexture && irrMat.getTexture(0)) - irrMat.setTexture(1, irrMat.getTexture(0)); - irrMat.setTexture(0, reflTexture); - irrMat.MaterialType=video::EMT_REFLECTION_2_LAYER; - } - if (Materials[i]->Texture[4].Map != "") // transparency - { -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading transparency texture."); -#endif - video::ITexture* transTexture = loadTexture(Materials[i]->Texture[4].Map); - if (transTexture && irrMat.getTexture(0)) - irrMat.setTexture(1, irrMat.getTexture(0)); - irrMat.setTexture(0, transTexture); - irrMat.MaterialType=video::EMT_TRANSPARENT_ADD_COLOR; - } - if (Materials[i]->Texture[6].Map != "") // bump - { -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading bump texture."); -#endif - const u8 pos = irrMat.getTexture(0)?1:0; - irrMat.setTexture(pos, loadTexture(Materials[i]->Texture[6].Map)); - if (irrMat.getTexture(pos)) - { - // SceneManager->getVideoDriver()->makeNormalMapTexture(irrMat.getTexture(1)); - // irrMat.MaterialType=video::EMT_NORMAL_MAP_SOLID; - } - } - - // cope with planar mapping texture coords - if (Materials[i]->Texture[0].Projection != 5) - { - if (FormatVersion!=2) - { - if (Materials[i]->Texture[0].Flags&1) - Materials[i]->Texture[0].Axis=0; - else if (Materials[i]->Texture[0].Flags&2) - Materials[i]->Texture[0].Axis=1; - else if (Materials[i]->Texture[0].Flags&4) - Materials[i]->Texture[0].Axis=2; - } - // if no axis given choose the dominant one - else if (Materials[i]->Texture[0].Axis>2) - { - if (Materials[i]->Meshbuffer->getBoundingBox().getExtent().Y<Materials[i]->Meshbuffer->getBoundingBox().getExtent().X) - { - if (Materials[i]->Meshbuffer->getBoundingBox().getExtent().Y<Materials[i]->Meshbuffer->getBoundingBox().getExtent().Z) - Materials[i]->Texture[0].Axis=1; - else - Materials[i]->Texture[0].Axis=2; - } - else - { - if (Materials[i]->Meshbuffer->getBoundingBox().getExtent().X<Materials[i]->Meshbuffer->getBoundingBox().getExtent().Z) - Materials[i]->Texture[0].Axis=0; - else - Materials[i]->Texture[0].Axis=2; - } - } - // get the resolution for this axis - f32 resolutionS = core::reciprocal(Materials[i]->Texture[0].Size.Z); - f32 resolutionT = core::reciprocal(Materials[i]->Texture[0].Size.Y); - if (Materials[i]->Texture[0].Axis==1) - { - resolutionS = core::reciprocal(Materials[i]->Texture[0].Size.X); - resolutionT = core::reciprocal(Materials[i]->Texture[0].Size.Z); - } - else if (Materials[i]->Texture[0].Axis==2) - { - resolutionS = core::reciprocal(Materials[i]->Texture[0].Size.X); - resolutionT = core::reciprocal(Materials[i]->Texture[0].Size.Y); - } - // use the two-way planar mapping - SceneManager->getMeshManipulator()->makePlanarTextureMapping(Materials[i]->Meshbuffer, resolutionS, resolutionT, Materials[i]->Texture[0].Axis, Materials[i]->Texture[0].Center); - } - - // add bump maps - if (Materials[i]->Meshbuffer->Material.MaterialType==video::EMT_NORMAL_MAP_SOLID) - { - SMesh* tmpmesh = new SMesh(); - tmpmesh->addMeshBuffer(Materials[i]->Meshbuffer); - SceneManager->getMeshManipulator()->createMeshWithTangents(tmpmesh, true, true); - Mesh->addMeshBuffer(tmpmesh->getMeshBuffer(0)); - tmpmesh->getMeshBuffer(0)->drop(); - tmpmesh->drop(); - } - else - { - SceneManager->getMeshManipulator()->recalculateNormals(Materials[i]->Meshbuffer); - Mesh->addMeshBuffer(Materials[i]->Meshbuffer); - } - Materials[i]->Meshbuffer->drop(); - // clear the material array elements - delete Materials[i]; - } - Mesh->recalculateBoundingBox(); - - SAnimatedMesh* am = new SAnimatedMesh(); - am->Type = EAMT_3DS; - am->addMesh(Mesh); - am->recalculateBoundingBox(); - Mesh->drop(); - Mesh = 0; - - Points.clear(); - Indices.clear(); - MaterialMapping.clear(); - TCoords.clear(); - Materials.clear(); - Images.clear(); - VmPolyPointsIndex.clear(); - VmCoordsIndex.clear(); - UvIndex.clear(); - UvName.clear(); - - return am; -} - - -bool CLWOMeshFileLoader::readChunks() -{ - s32 lastPos; - u32 size; - unsigned int uiType; - char type[5]; - type[4]=0; - tLWOLayerInfo layer; - - while(File->getPos()<File->getSize()) - { - File->read(&type, 4); - //Convert 4-char string to 4-byte integer - //Makes it possible to do a switch statement - uiType = charsToUInt(type); - File->read(&size, 4); -#ifndef __BIG_ENDIAN__ - size=os::Byteswap::byteswap(size); -#endif - lastPos=File->getPos(); - - switch(uiType) - { - case charsToUIntD('L','A','Y','R'): - { -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading layer."); -#endif - u16 tmp16; - File->read(&tmp16, 2); // number - File->read(&tmp16, 2); // flags - size -= 4; -#ifndef __BIG_ENDIAN__ - tmp16=os::Byteswap::byteswap(tmp16); -#endif - if (((FormatVersion==1)&&(tmp16!=1)) || - ((FormatVersion==2)&&(tmp16&1))) - layer.Active=false; - else - layer.Active=true; - if (FormatVersion==2) - size -= readVec(layer.Pivot); - size -= readString(layer.Name); - if (size) - { - File->read(&tmp16, 2); -#ifndef __BIG_ENDIAN__ - tmp16=os::Byteswap::byteswap(tmp16); -#endif - layer.Parent = tmp16; - } - } - break; - case charsToUIntD('P','N','T','S'): - { -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading points."); -#endif - core::vector3df vec; - Points.clear(); - const u32 tmpsize = size/12; - Points.reallocate(tmpsize); - for (u32 i=0; i<tmpsize; ++i) - { - readVec(vec); - Points.push_back(vec); - } - } - break; - case charsToUIntD('V','M','A','P'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading Vertex mapping."); -#endif - readVertexMapping(size); - break; - case charsToUIntD('P','O','L','S'): - case charsToUIntD('P','T','C','H'): // TODO: should be a subdivison mesh -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading polygons."); -#endif - if (FormatVersion!=2) - readObj1(size); - else - readObj2(size); -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: Done loading polygons."); -#endif - break; - case charsToUIntD('T','A','G','S'): - case charsToUIntD('S','R','F','S'): - { -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading surface names."); -#endif - while (size!=0) - { - tLWOMaterial *mat=new tLWOMaterial(); - mat->Name=""; - mat->Meshbuffer=new scene::SMeshBuffer(); - size -= readString(mat->Name); - if (FormatVersion!=2) - mat->TagType = 1; // format 2 has more types - Materials.push_back(mat); - } - } - break; - case charsToUIntD('P','T','A','G'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading tag mapping."); -#endif - readTagMapping(size); - break; - case charsToUIntD('V','M','A','D'): // discontinuous vertex mapping, i.e. additional texcoords -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading Vertex mapping VMAD."); -#endif - readDiscVertexMapping(size); -// case charsToUIntD('V','M','P','A'): -// case charsToUIntD('E','N','V','L'): - break; - case charsToUIntD('C','L','I','P'): - { -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading clips."); -#endif - u32 index; - u16 subsize; - File->read(&index, 4); -#ifndef __BIG_ENDIAN__ - index=os::Byteswap::byteswap(index); -#endif - size -= 4; - while (size != 0) - { - File->read(&type, 4); - File->read(&subsize, 2); -#ifndef __BIG_ENDIAN__ - subsize=os::Byteswap::byteswap(subsize); -#endif - size -= 6; - if (strncmp(type, "STIL", 4)) - { - File->seek(subsize, true); - size -= subsize; - continue; - } - core::stringc path; - size -= readString(path, subsize); - #ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loaded clip", path.c_str()); - #endif - Images.push_back(path); - } - } - break; - case charsToUIntD('S','U','R','F'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading material."); -#endif - readMat(size); - break; - case charsToUIntD('B','B','O','X'): - { -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading bbox."); -#endif - // not stored - core::vector3df vec; - for (u32 i=0; i<2; ++i) - readVec(vec); - size -= 24; - } - break; - case charsToUIntD('D','E','S','C'): - case charsToUIntD('T','E','X','T'): - { - core::stringc text; - size -= readString(text, size); -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader text", text); -#endif - } - break; - // not needed - case charsToUIntD('I','C','O','N'): - // not yet supported - case charsToUIntD('P','C','H','S'): - case charsToUIntD('C','R','V','S'): - default: -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: skipping ", type); -#endif - //Go to next chunk - File->seek(lastPos + size, false); - break; - } - } - return true; -} - - -void CLWOMeshFileLoader::readObj1(u32 size) -{ - u32 pos; - u16 numVerts, vertIndex; - s16 material; - video::S3DVertex vertex; - - while (size!=0) - { - File->read(&numVerts, 2); -#ifndef __BIG_ENDIAN__ - numVerts=os::Byteswap::byteswap(numVerts); -#endif - pos=File->getPos(); - // skip forward to material number - File->seek(2*numVerts, true); - File->read(&material, 2); -#ifndef __BIG_ENDIAN__ - material=os::Byteswap::byteswap(material); -#endif - size -=2*numVerts+4; - // detail meshes ? - scene::SMeshBuffer *mb; - if (material<0) - mb=Materials[-material-1]->Meshbuffer; - else - mb=Materials[material-1]->Meshbuffer; - // back to vertex list start - File->seek(pos, false); - - const u16 vertCount=mb->Vertices.size(); - for (u16 i=0; i<numVerts; ++i) - { - File->read(&vertIndex, 2); -#ifndef __BIG_ENDIAN__ - vertIndex=os::Byteswap::byteswap(vertIndex); -#endif - vertex.Pos=Points[vertIndex]; - mb->Vertices.push_back(vertex); - } - for (u16 i=1; i<numVerts-1; ++i) - { - mb->Indices.push_back(vertCount); - mb->Indices.push_back(vertCount+i); - mb->Indices.push_back(vertCount+i+1); - } - // skip material number and detail surface count - // detail surface can be read just as a normal one now - if (material<0) - File->read(&material, 2); - File->read(&material, 2); - } -} - - -void CLWOMeshFileLoader::readVertexMapping(u32 size) -{ - char type[5]={0}; - u16 dimension; - core::stringc name; - File->read(&type, 4); -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: Vertex map type", type); -#endif - File->read(&dimension,2); -#ifndef __BIG_ENDIAN__ - dimension=os::Byteswap::byteswap(dimension); -#endif - size -= 6; - size -= readString(name); -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: Vertex map", name.c_str()); -#endif - if (strncmp(type, "TXUV", 4)) // also support RGB, RGBA, WGHT, ... - { - File->seek(size, true); - return; - } - UvName.push_back(name); - - TCoords.push_back(core::array<core::vector2df>()); - core::array<core::vector2df>& UvCoords=TCoords.getLast(); - UvCoords.reallocate(Points.size()); - UvIndex.push_back(core::array<u32>()); - core::array<u32>& UvPointsArray=UvIndex.getLast(); - UvPointsArray.reallocate(Points.size()); - - u32 index; - core::vector2df tcoord; - while (size) - { - size -= readVX(index); - File->read(&tcoord.X, 4); - File->read(&tcoord.Y, 4); - size -= 8; -#ifndef __BIG_ENDIAN__ - index=os::Byteswap::byteswap(index); - tcoord.X=os::Byteswap::byteswap(tcoord.X); - tcoord.Y=os::Byteswap::byteswap(tcoord.Y); -#endif - UvCoords.push_back(tcoord); - UvPointsArray.push_back(index); - } -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: UvCoords", core::stringc(UvCoords.size())); -#endif -} - - -void CLWOMeshFileLoader::readDiscVertexMapping(u32 size) -{ - char type[5]={0}; - u16 dimension; - core::stringc name; - File->read(&type, 4); -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: Discontinuous vertex map type", type); -#endif - File->read(&dimension,2); -#ifndef __BIG_ENDIAN__ - dimension=os::Byteswap::byteswap(dimension); -#endif - size -= 6; - size -= readString(name); -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: Discontinuous vertex map", name.c_str()); -#endif - if (strncmp(type, "TXUV", 4)) - { - File->seek(size, true); - return; - } - DUvName.push_back(name); - VmPolyPointsIndex.push_back(core::array<u32>()); - core::array<u32>& VmPolyPoints=VmPolyPointsIndex.getLast(); - - VmCoordsIndex.push_back(core::array<core::vector2df>()); - core::array<core::vector2df>& VmCoords=VmCoordsIndex.getLast(); - - u32 vmpolys; - u32 vmpoints; - core::vector2df vmcoords; - while (size) - { - size-=readVX(vmpoints); - size-=readVX(vmpolys); - File->read(&vmcoords.X, 4); - File->read(&vmcoords.Y, 4); - size -= 8; -#ifndef __BIG_ENDIAN__ - vmpoints=os::Byteswap::byteswap(vmpoints); - vmpolys=os::Byteswap::byteswap(vmpolys); - vmcoords.X=os::Byteswap::byteswap(vmcoords.X); - vmcoords.Y=os::Byteswap::byteswap(vmcoords.Y); -#endif - VmCoords.push_back(vmcoords); - VmPolyPoints.push_back(vmpolys); - VmPolyPoints.push_back(vmpoints); - } -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: VmCoords", core::stringc(VmCoords.size())); -#endif -} - - -void CLWOMeshFileLoader::readTagMapping(u32 size) -{ - char type[5]; - type[4]=0; - File->read(&type, 4); - size -= 4; - if ((strncmp(type, "SURF", 4))||(Indices.size()==0)) - { - File->seek(size, true); - return; - } - - while (size!=0) - { - u16 tag; - u32 polyIndex; - size-=readVX(polyIndex); - File->read(&tag, 2); -#ifndef __BIG_ENDIAN__ - tag=os::Byteswap::byteswap(tag); -#endif - size -= 2; - MaterialMapping[polyIndex]=tag; - Materials[tag]->TagType=1; - } -} - - -void CLWOMeshFileLoader::readObj2(u32 size) -{ - char type[5]; - type[4]=0; - File->read(&type, 4); - size -= 4; - Indices.clear(); - if (strncmp(type, "FACE", 4)) // also possible are splines, subdivision patches, metaballs, and bones - { - File->seek(size, true); - return; - } - u16 numVerts=0; - while (size!=0) - { - File->read(&numVerts, 2); -#ifndef __BIG_ENDIAN__ - numVerts=os::Byteswap::byteswap(numVerts); -#endif - // mask out flags - numVerts &= 0x03FF; - - size -= 2; - Indices.push_back(core::array<u32>()); - u32 vertIndex; - core::array<u32>& polyArray = Indices.getLast(); - polyArray.reallocate(numVerts); - for (u16 i=0; i<numVerts; ++i) - { - size -= readVX(vertIndex); - polyArray.push_back(vertIndex); - } - } - MaterialMapping.reallocate(Indices.size()); - for (u32 j=0; j<Indices.size(); ++j) - MaterialMapping.push_back(0); -} - - -void CLWOMeshFileLoader::readMat(u32 size) -{ - core::stringc name; - - tLWOMaterial* mat=0; - size -= readString(name); -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: material name", name.c_str()); -#endif - for (u32 i=0; i<Materials.size(); ++i) - { - if ((Materials[i]->TagType==1) && (Materials[i]->Name==name)) - { - mat=Materials[i]; - break; - } - } - if (!mat) - { - File->seek(size, true); - return; - } - if (FormatVersion==2) - size -= readString(name); - - video::SMaterial& irrMat=mat->Meshbuffer->Material; - - u8 currTexture=0; - while (size!=0) - { - char type[5]; - type[4]=0; - u32 uiType; - u32 tmp32; - u16 subsize, tmp16; - f32 tmpf32; - File->read(&type, 4); - //Convert 4-char string to 4-byte integer - //Makes it possible to do a switch statement - uiType = charsToUInt(type); - File->read(&subsize, 2); -#ifndef __BIG_ENDIAN__ - subsize=os::Byteswap::byteswap(subsize); -#endif - size -= 6; - switch (uiType) - { - case charsToUIntD('C','O','L','R'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading Ambient color."); -#endif - { - s32 colSize = readColor(irrMat.DiffuseColor); - irrMat.AmbientColor=irrMat.DiffuseColor; - size -= colSize; - subsize -= colSize; - if (FormatVersion==2) - size -= readVX(mat->Envelope[0]); - } - break; - case charsToUIntD('D','I','F','F'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading Diffuse color."); -#endif - { - if (FormatVersion==2) - { - File->read(&mat->Diffuse, 4); -#ifndef __BIG_ENDIAN__ - mat->Diffuse=os::Byteswap::byteswap(mat->Diffuse); -#endif - size -= 4; - subsize -= 4; - size -= readVX(mat->Envelope[1]); - } - else - { - File->read(&tmp16, 2); -#ifndef __BIG_ENDIAN__ - tmp16=os::Byteswap::byteswap(tmp16); -#endif - mat->Diffuse=tmp16/256.0f; - size -= 2; - subsize -= 2; - } - } - break; - case charsToUIntD('V','D','I','F'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading Diffuse color."); -#endif - { - File->read(&mat->Diffuse, 4); -#ifndef __BIG_ENDIAN__ - mat->Diffuse=os::Byteswap::byteswap(mat->Diffuse); -#endif - size -= 4; - } - break; - case charsToUIntD('L','U','M','I'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading luminance."); -#endif - { - if (FormatVersion==2) - { - File->read(&mat->Luminance, 4); -#ifndef __BIG_ENDIAN__ - mat->Luminance=os::Byteswap::byteswap(mat->Luminance); -#endif - size -= 4; - subsize -= 4; - size -= readVX(mat->Envelope[2]); - } - else - { - File->read(&tmp16, 2); -#ifndef __BIG_ENDIAN__ - tmp16=os::Byteswap::byteswap(tmp16); -#endif - mat->Luminance=tmp16/256.0f; - size -= 2; - subsize -= 2; - } } - break; - case charsToUIntD('V','L','U','M'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading luminance."); -#endif - { - File->read(&mat->Luminance, 4); -#ifndef __BIG_ENDIAN__ - mat->Luminance=os::Byteswap::byteswap(mat->Luminance); -#endif - size -= 4; - } - break; - case charsToUIntD('S','P','E','C'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading specular."); -#endif - { - if (FormatVersion==2) - { - File->read(&mat->Specular, 4); -#ifndef __BIG_ENDIAN__ - mat->Specular=os::Byteswap::byteswap(mat->Specular); -#endif - size -= 4; - subsize -= 4; - size -= readVX(mat->Envelope[3]); - } - else - { - File->read(&tmp16, 2); -#ifndef __BIG_ENDIAN__ - tmp16=os::Byteswap::byteswap(tmp16); -#endif - mat->Specular=tmp16/256.0f;; - size -= 2; - subsize -= 2; - } - } - break; - case charsToUIntD('V','S','P','C'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading specular."); -#endif - { - File->read(&mat->Specular, 4); -#ifndef __BIG_ENDIAN__ - mat->Specular=os::Byteswap::byteswap(mat->Specular); -#endif - size -= 4; - } - break; - case charsToUIntD('R','E','F','L'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading reflection."); -#endif - { - if (FormatVersion==2) - { - File->read(&mat->Reflection, 4); -#ifndef __BIG_ENDIAN__ - mat->Reflection=os::Byteswap::byteswap(mat->Reflection); -#endif - size -= 4; - subsize -= 4; - size -= readVX(mat->Envelope[4]); - } - else - { - File->read(&tmp16, 2); -#ifndef __BIG_ENDIAN__ - tmp16=os::Byteswap::byteswap(tmp16); -#endif - mat->Reflection=tmp16/256.0f; - size -= 2; - subsize -= 2; - } - } - break; - case charsToUIntD('V','R','F','L'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading reflection."); -#endif - { - File->read(&mat->Reflection, 4); -#ifndef __BIG_ENDIAN__ - mat->Reflection=os::Byteswap::byteswap(mat->Reflection); -#endif - size -= 4; - } - break; - case charsToUIntD('T','R','A','N'): - { - if (FormatVersion==2) - { - File->read(&mat->Transparency, 4); -#ifndef __BIG_ENDIAN__ - mat->Transparency=os::Byteswap::byteswap(mat->Transparency); -#endif - size -= 4; - subsize -= 4; - size -= readVX(mat->Envelope[5]); - } - else - { - File->read(&tmp16, 2); -#ifndef __BIG_ENDIAN__ - tmp16=os::Byteswap::byteswap(tmp16); -#endif - mat->Transparency=tmp16/256.0f; - size -= 2; - subsize -= 2; - } -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading transparency", core::stringc(mat->Transparency).c_str()); -#endif - } - break; - case charsToUIntD('V','T','R','N'): - { - File->read(&mat->Transparency, 4); -#ifndef __BIG_ENDIAN__ - mat->Transparency=os::Byteswap::byteswap(mat->Transparency); -#endif - size -= 4; - } -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading transparency", core::stringc(mat->Transparency).c_str()); -#endif - break; - case charsToUIntD('T','R','N','L'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading translucency."); -#endif - { - File->read(&mat->Translucency, 4); -#ifndef __BIG_ENDIAN__ - mat->Translucency=os::Byteswap::byteswap(mat->Translucency); -#endif - size -= 4; - subsize -= 4; - if (FormatVersion==2) - size -= readVX(mat->Envelope[6]); - } - break; - case charsToUIntD('G','L','O','S'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading glossy."); -#endif - { - if (FormatVersion == 2) - { - File->read(&irrMat.Shininess, 4); -#ifndef __BIG_ENDIAN__ - irrMat.Shininess=os::Byteswap::byteswap(irrMat.Shininess); -#endif - size -= 4; - subsize -= 4; - size -= readVX(mat->Envelope[7]); - } - else - { - File->read(&tmp16, 2); -#ifndef __BIG_ENDIAN__ - tmp16=os::Byteswap::byteswap(tmp16); -#endif - irrMat.Shininess=tmp16/16.f; - size -= 2; - subsize -= 2; - } - } - break; - case charsToUIntD('S','H','R','P'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading sharpness."); -#endif - { - File->read(&mat->Sharpness, 4); -#ifndef __BIG_ENDIAN__ - mat->Sharpness=os::Byteswap::byteswap(mat->Sharpness); -#endif - size -= 4; - subsize -= 4; - if (FormatVersion==2) - size -= readVX(mat->Envelope[8]); - } - break; - case charsToUIntD('B','U','M','P'): - case charsToUIntD('T','A','M','P'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading bumpiness."); -#endif - { - File->read(&tmpf32, 4); -#ifndef __BIG_ENDIAN__ - tmpf32=os::Byteswap::byteswap(tmpf32); -#endif - if (currTexture==6) - irrMat.MaterialTypeParam=tmpf32; - size -= 4; - subsize -= 4; - if (FormatVersion==2) - size -= readVX(mat->Envelope[9]); - } - break; - case charsToUIntD('S','I','D','E'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading backface culled."); -#endif - { - File->read(&tmp16, 2); -#ifndef __BIG_ENDIAN__ - tmp16=os::Byteswap::byteswap(tmp16); -#endif - if (tmp16==1) - irrMat.BackfaceCulling=true; - else if (tmp16==3) - irrMat.BackfaceCulling=false; - size -= 2; - } - break; - case charsToUIntD('S','M','A','N'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading smoothing angle."); -#endif - { - File->read(&mat->SmoothingAngle, 4); -#ifndef __BIG_ENDIAN__ - mat->SmoothingAngle=os::Byteswap::byteswap(mat->SmoothingAngle); -#endif - size -= 4; - } - break; - case charsToUIntD('R','F','O','P'): - case charsToUIntD('R','F','L','T'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading reflection mode."); -#endif - { - File->read(&mat->ReflMode, 2); -#ifndef __BIG_ENDIAN__ - mat->ReflMode=os::Byteswap::byteswap(mat->ReflMode); -#endif - size -= 2; - } - break; - case charsToUIntD('R','I','M','G'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading reflection map."); -#endif - { - if (FormatVersion==2) - { - size -= readVX(tmp32); - if (tmp32) - mat->ReflMap=Images[tmp32-1]; - } - else - size -= readString(mat->ReflMap, size); - } - break; - case charsToUIntD('R','S','A','N'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading reflection seam angle."); -#endif - { - File->read(&mat->ReflSeamAngle, 4); -#ifndef __BIG_ENDIAN__ - mat->ReflSeamAngle=os::Byteswap::byteswap(mat->ReflSeamAngle); -#endif - size -= 4; - if (FormatVersion==2) - size -= readVX(mat->Envelope[10]); - } - break; - case charsToUIntD('R','B','L','R'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading reflection blur."); -#endif - { - File->read(&mat->ReflBlur, 4); -#ifndef __BIG_ENDIAN__ - mat->ReflBlur=os::Byteswap::byteswap(mat->ReflBlur); -#endif - size -= 4; - if (FormatVersion==2) - size -= readVX(mat->Envelope[11]); - } - break; - case charsToUIntD('R','I','N','D'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading refraction index."); -#endif - { - File->read(&mat->RefrIndex, 4); -#ifndef __BIG_ENDIAN__ - mat->RefrIndex=os::Byteswap::byteswap(mat->RefrIndex); -#endif - size -= 4; - subsize -= 4; - if (FormatVersion==2) - size -= readVX(mat->Envelope[12]); - } - break; - case charsToUIntD('T','R','O','P'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading refraction options."); -#endif - { - File->read(&mat->TranspMode, 2); -#ifndef __BIG_ENDIAN__ - mat->TranspMode=os::Byteswap::byteswap(mat->TranspMode); -#endif - size -= 2; - } - break; - case charsToUIntD('T','I','M','G'): - { - if (FormatVersion==2) - { -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading refraction map."); -#endif - size -= readVX(tmp32); -#ifndef __BIG_ENDIAN__ - tmp32=os::Byteswap::byteswap(tmp32); -#endif - if (tmp32) - mat->Texture[currTexture].Map=Images[tmp32-1]; - } - else - { - size -= readString(mat->Texture[currTexture].Map, size); -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading image", mat->Texture[currTexture].Map.c_str()); -#endif - } - } - break; - case charsToUIntD('T','B','L','R'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading transparency blur."); -#endif - { - File->read(&mat->TranspBlur, 4); -#ifndef __BIG_ENDIAN__ - mat->TranspBlur=os::Byteswap::byteswap(mat->TranspBlur); -#endif - size -= 4; - if (FormatVersion==2) - size -= readVX(mat->Envelope[13]); - } - break; - case charsToUIntD('C','L','R','H'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading highlight color."); -#endif - { - File->read(&mat->HighlightColor, 4); -#ifndef __BIG_ENDIAN__ - mat->HighlightColor=os::Byteswap::byteswap(mat->HighlightColor); -#endif - size -= 4; - if (FormatVersion==2) - size -= readVX(mat->Envelope[14]); - } - break; - case charsToUIntD('C','L','R','F'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading color filter."); -#endif - { - File->read(&mat->ColorFilter, 4); -#ifndef __BIG_ENDIAN__ - mat->ColorFilter=os::Byteswap::byteswap(mat->ColorFilter); -#endif - size -= 4; - if (FormatVersion==2) - size -= readVX(mat->Envelope[15]); - } - break; - case charsToUIntD('A','D','T','R'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading additive transparency."); -#endif - { - File->read(&mat->AdditiveTransparency, 4); -#ifndef __BIG_ENDIAN__ - mat->AdditiveTransparency=os::Byteswap::byteswap(mat->AdditiveTransparency); -#endif - size -= 4; - if (FormatVersion==2) - size -= readVX(mat->Envelope[16]); - } - break; - case charsToUIntD('G','L','O','W'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading glow."); -#endif - { - if (FormatVersion==0) - { - File->read(&mat->GlowIntensity, 4); -#ifndef __BIG_ENDIAN__ - mat->GlowIntensity=os::Byteswap::byteswap(mat->GlowIntensity); -#endif - size -= 4; - } - else - { - File->read(&mat->Glow, 2); -#ifndef __BIG_ENDIAN__ - mat->Glow=os::Byteswap::byteswap(mat->Glow); -#endif - size -= 2; - File->read(&mat->GlowIntensity, 4); -#ifndef __BIG_ENDIAN__ - mat->GlowIntensity=os::Byteswap::byteswap(mat->GlowIntensity); -#endif - size -= 4; - if (FormatVersion==2) - size -= readVX(mat->Envelope[17]); - File->read(&mat->GlowSize, 4); -#ifndef __BIG_ENDIAN__ - mat->GlowSize=os::Byteswap::byteswap(mat->GlowSize); -#endif - size -= 4; - if (FormatVersion==2) - size -= readVX(mat->Envelope[18]); - } - } - break; - case charsToUIntD('G','V','A','L'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading glow intensity."); -#endif - { - File->read(&mat->GlowIntensity, 4); -#ifndef __BIG_ENDIAN__ - mat->GlowIntensity=os::Byteswap::byteswap(mat->GlowIntensity); -#endif - size -= 4; - if (FormatVersion==2) - size -= readVX(mat->Envelope[17]); - } - break; - case charsToUIntD('L','I','N','E'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading isWireframe."); -#endif - { - File->read(&tmp16, 2); -#ifndef __BIG_ENDIAN__ - tmp16=os::Byteswap::byteswap(tmp16); -#endif - if (tmp16&1) - irrMat.Wireframe=true; - size -= 2; - if (size!=0) - { - File->read(&irrMat.Thickness, 4); -#ifndef __BIG_ENDIAN__ - irrMat.Thickness=os::Byteswap::byteswap(irrMat.Thickness); -#endif - size -= 4; - if (FormatVersion==2) - size -= readVX(mat->Envelope[19]); - } - if (size!=0) - { - video::SColor lineColor; - size -= readColor(lineColor); - if (FormatVersion==2) - size -= readVX(mat->Envelope[20]); - } - } - break; - case charsToUIntD('A','L','P','H'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading alpha mode."); -#endif - { - File->read(&mat->AlphaMode, 2); -#ifndef __BIG_ENDIAN__ - mat->AlphaMode=os::Byteswap::byteswap(mat->AlphaMode); -#endif - size -= 2; - File->read(&mat->AlphaValue, 4); -#ifndef __BIG_ENDIAN__ - mat->AlphaValue=os::Byteswap::byteswap(mat->AlphaValue); -#endif - size -= 4; - } - break; - case charsToUIntD('V','C','O','L'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading vertex color."); -#endif - { - File->read(&mat->VertexColorIntensity, 4); -#ifndef __BIG_ENDIAN__ - mat->VertexColorIntensity=os::Byteswap::byteswap(mat->VertexColorIntensity); -#endif - size -= 4; - if (FormatVersion==2) - size -= readVX(mat->Envelope[21]); - File->read(&tmp32, 4); // skip type - size -= 4; - core::stringc tmpname; - size -= readString(tmpname, size); -// mat->VertexColor = getColorVMAP(tmpname); - } - break; - case charsToUIntD('F','L','A','G'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading flag."); -#endif - { - File->read(&mat->Flags, 2); -#ifndef __BIG_ENDIAN__ - mat->Flags=os::Byteswap::byteswap(mat->Flags); -#endif - if (mat->Flags&1) - mat->Luminance=1.0f; - if (mat->Flags&256) - irrMat.BackfaceCulling=false; - size -= 2; - } - break; - case charsToUIntD('E','D','G','E'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading edge."); -#endif - { - File->read(&mat->EdgeTransparency, 4); -#ifndef __BIG_ENDIAN__ - mat->EdgeTransparency=os::Byteswap::byteswap(mat->EdgeTransparency); -#endif - size -= 4; - } - break; - case charsToUIntD('C','T','E','X'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading ctex."); -#endif - currTexture=0; - size -= readString(mat->Texture[currTexture].Type, size); - break; - case charsToUIntD('D','T','E','X'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading dtex."); -#endif - currTexture=1; - size -= readString(mat->Texture[currTexture].Type, size); - break; - case charsToUIntD('S','T','E','X'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading stex."); -#endif - currTexture=2; - size -= readString(mat->Texture[currTexture].Type, size); - break; - case charsToUIntD('R','T','E','X'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading rtex."); -#endif - currTexture=3; - size -= readString(mat->Texture[currTexture].Type, size); - break; - case charsToUIntD('T','T','E','X'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading ttex."); -#endif - currTexture=4; - size -= readString(mat->Texture[currTexture].Type, size); - break; - case charsToUIntD('L','T','E','X'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading ltex."); -#endif - currTexture=5; - size -= readString(mat->Texture[currTexture].Type, size); - break; - case charsToUIntD('B','T','E','X'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading btex."); -#endif - currTexture=6; - size -= readString(mat->Texture[currTexture].Type, size); - break; - case charsToUIntD('T','A','L','P'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading alpha map."); -#endif - size -= readString(mat->Texture[currTexture].AlphaMap, size); - break; - case charsToUIntD('T','F','L','G'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading texture flag."); -#endif - { - File->read(&mat->Texture[currTexture].Flags, 2); -#ifndef __BIG_ENDIAN__ - mat->Texture[currTexture].Flags=os::Byteswap::byteswap(mat->Texture[currTexture].Flags); -#endif - size -= 2; - } - break; - case charsToUIntD('E','N','A','B'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading isEnabled."); -#endif - { - File->read(&tmp16, 2); -#ifndef __BIG_ENDIAN__ - tmp16=os::Byteswap::byteswap(tmp16); -#endif - mat->Texture[currTexture].Active=(tmp16!=0); - size -= 2; - } - break; - case charsToUIntD('W','R','A','P'): - case charsToUIntD('T','W','R','P'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading texture wrap."); -#endif - { - File->read(&mat->Texture[currTexture].WidthWrap, 2); -#ifndef __BIG_ENDIAN__ - mat->Texture[currTexture].WidthWrap=os::Byteswap::byteswap(mat->Texture[currTexture].WidthWrap); -#endif - File->read(&mat->Texture[currTexture].HeightWrap, 2); -#ifndef __BIG_ENDIAN__ - mat->Texture[currTexture].HeightWrap=os::Byteswap::byteswap(mat->Texture[currTexture].HeightWrap); -#endif - size -= 4; - } - break; - case charsToUIntD('T','V','E','L'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading texture velocity."); -#endif - size -= readVec(mat->Texture[currTexture].Velocity); - break; - case charsToUIntD('T','C','L','R'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading texture color."); -#endif - size -= readColor(mat->Texture[currTexture].Color); - break; - case charsToUIntD('A','A','S','T'): - case charsToUIntD('T','A','A','S'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading texture antialias."); -#endif - { - tmp16=0; - if (FormatVersion==2) - { - File->read(&tmp16, 2); -#ifndef __BIG_ENDIAN__ - tmp16=os::Byteswap::byteswap(tmp16); -#endif - size -= 2; - } - File->read(&mat->Texture[currTexture].AntiAliasing, 4); -#ifndef __BIG_ENDIAN__ - mat->Texture[currTexture].AntiAliasing=os::Byteswap::byteswap(mat->Texture[currTexture].AntiAliasing); -#endif - if (tmp16 & ~0x01) - mat->Texture[currTexture].AntiAliasing=0.0f; // disabled - size -= 4; - } - break; - case charsToUIntD('T','O','P','C'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading texture opacity."); -#endif - { - File->read(&mat->Texture[currTexture].Opacity, 4); -#ifndef __BIG_ENDIAN__ - mat->Texture[currTexture].Opacity=os::Byteswap::byteswap(mat->Texture[currTexture].Opacity); -#endif - size -= 4; - } - break; - case charsToUIntD('O','P','A','C'): - { -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading texture opacity and type."); -#endif - File->read(&mat->Texture[currTexture].OpacType, 2); -#ifndef __BIG_ENDIAN__ - mat->Texture[currTexture].OpacType=os::Byteswap::byteswap(mat->Texture[currTexture].OpacType); -#endif - File->read(&mat->Texture[currTexture].Opacity, 4); -#ifndef __BIG_ENDIAN__ - mat->Texture[currTexture].Opacity=os::Byteswap::byteswap(mat->Texture[currTexture].Opacity); -#endif - size -= 6; - subsize -= 6; - if (FormatVersion==2) - size -= readVX(mat->Envelope[22]); - } - break; - case charsToUIntD('A','X','I','S'): - { - File->read(&tmp16, 2); -#ifndef __BIG_ENDIAN__ - tmp16=os::Byteswap::byteswap(tmp16); -#endif - mat->Texture[currTexture].Axis=(u8)tmp16; - size -= 2; -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading axis value", core::stringc(tmp16).c_str()); -#endif - } - break; - case charsToUIntD('T','M','A','P'): // empty separation chunk - break; - case charsToUIntD('T','C','T','R'): - case charsToUIntD('C','N','T','R'): - { - core::vector3df& center=mat->Texture[currTexture].Center; - size -= readVec(center); - if (FormatVersion==2) - size -= readVX(mat->Envelope[22]); -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading texture center", (core::stringc(center.X)+" "+core::stringc(center.Y)+" "+core::stringc(center.Z)).c_str()); -#endif - } - break; - case charsToUIntD('T','S','I','Z'): - case charsToUIntD('S','I','Z','E'): - { - core::vector3df& tsize=mat->Texture[currTexture].Size; - size -= readVec(tsize); - if (FormatVersion==2) - size -= readVX(mat->Envelope[22]); -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading texture size", (core::stringc(tsize.X)+" "+core::stringc(tsize.Y)+" "+core::stringc(tsize.Z)).c_str()); -#endif - } - break; - case charsToUIntD('R','O','T','A'): - { - core::vector3df rotation; - size -= readVec(rotation); - if (FormatVersion==2) - size -= readVX(mat->Envelope[22]); -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading texture rotation", (core::stringc(rotation.X)+" "+core::stringc(rotation.Y)+" "+core::stringc(rotation.Z)).c_str()); -#endif - } - break; - case charsToUIntD('O','R','E','F'): - { - core::stringc tmpname; - size -= readString(tmpname); -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: texture reference object", tmpname.c_str()); -#endif - } - break; - case charsToUIntD('T','F','A','L'): - case charsToUIntD('F','A','L','L'): - { - if (FormatVersion==2) - { - u16 tmp16; - File->read(&tmp16, 2); - size -= 2; -#ifndef __BIG_ENDIAN__ - tmp16=os::Byteswap::byteswap(tmp16); -#endif - } - - core::vector3df& falloff=mat->Texture[currTexture].Falloff; - size -= readVec(falloff); - if (FormatVersion==2) - size -= readVX(mat->Envelope[22]); -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading texture falloff"); -#endif - } - break; - case charsToUIntD('C','S','Y','S'): - { - u16 tmp16; - File->read(&tmp16, 2); - size -= 2; -#ifndef __BIG_ENDIAN__ - tmp16=os::Byteswap::byteswap(tmp16); -#endif -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: texture coordinate system", tmp16==0?"object coords":"world coords"); -#endif - } - break; - case charsToUIntD('T','V','A','L'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading texture value."); -#endif - { - File->read(&tmp16, 2); -#ifndef __BIG_ENDIAN__ - tmp16=os::Byteswap::byteswap(tmp16); -#endif - mat->Texture[currTexture].Value=tmp16/256.0f; - size -= 2; - } - break; - case charsToUIntD('T','F','P','0'): - case charsToUIntD('T','S','P','0'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading texture param 0."); -#endif - { - File->read(&mat->Texture[currTexture].FParam[0], 4); -#ifndef __BIG_ENDIAN__ - mat->Texture[currTexture].FParam[0]=os::Byteswap::byteswap(mat->Texture[currTexture].FParam[0]); -#endif - size -= 4; - } - break; - case charsToUIntD('T','F','P','1'): - case charsToUIntD('T','S','P','1'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading texture param 1."); -#endif - { - File->read(&mat->Texture[currTexture].FParam[1], 4); -#ifndef __BIG_ENDIAN__ - mat->Texture[currTexture].FParam[1]=os::Byteswap::byteswap(mat->Texture[currTexture].FParam[1]); -#endif - size -= 4; - } - break; - case charsToUIntD('T','F','P','2'): - case charsToUIntD('T','S','P','2'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading texture param 2."); -#endif - { - File->read(&mat->Texture[currTexture].FParam[2], 4); -#ifndef __BIG_ENDIAN__ - mat->Texture[currTexture].FParam[2]=os::Byteswap::byteswap(mat->Texture[currTexture].FParam[2]); -#endif - size -= 4; - } - break; - case charsToUIntD('T','F','R','Q'): - case charsToUIntD('T','I','P','0'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading texture iparam 0."); -#endif - { - File->read(&mat->Texture[currTexture].IParam[0], 2); -#ifndef __BIG_ENDIAN__ - mat->Texture[currTexture].IParam[0]=os::Byteswap::byteswap(mat->Texture[currTexture].IParam[0]); -#endif - size -= 2; - } - break; - case charsToUIntD('T','I','P','1'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading texture param 1."); -#endif - { - File->read(&mat->Texture[currTexture].IParam[1], 2); -#ifndef __BIG_ENDIAN__ - mat->Texture[currTexture].IParam[1]=os::Byteswap::byteswap(mat->Texture[currTexture].IParam[1]); -#endif - size -= 2; - } - break; - case charsToUIntD('T','I','P','2'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading texture param 2."); -#endif - { - File->read(&mat->Texture[currTexture].IParam[2], 2); -#ifndef __BIG_ENDIAN__ - mat->Texture[currTexture].IParam[2]=os::Byteswap::byteswap(mat->Texture[currTexture].IParam[2]); -#endif - size -= 2; - } - break; - case charsToUIntD('V','M','A','P'): - { - size -= readString(mat->Texture[currTexture].UVname); -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading material vmap binding",mat->Texture[currTexture].UVname.c_str()); -#endif - } - break; - case charsToUIntD('B','L','O','K'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading blok."); -#endif - { - core::stringc ordinal; - File->read(&type, 4); - File->read(&subsize, 2); -#ifndef __BIG_ENDIAN__ - subsize=os::Byteswap::byteswap(subsize); -#endif - size -= 6; - size -= readString(ordinal, size); - } - break; - case charsToUIntD('C','H','A','N'): - { - File->read(&type, 4); - size -= 4; - if (!strncmp(type, "COLR", 4)) - currTexture=0; - else if (!strncmp(type, "DIFF", 4)) - currTexture=1; - else if (!strncmp(type, "LUMI", 4)) - currTexture=5; - else if (!strncmp(type, "SPEC", 4)) - currTexture=2; - else if (!strncmp(type, "REFL", 4)) - currTexture=3; - else if (!strncmp(type, "TRAN", 4)) - currTexture=4; - else if (!strncmp(type, "BUMP", 4)) - currTexture=6; - } -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading channel ", type); -#endif - break; - case charsToUIntD('I','M','A','G'): -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading channel map."); -#endif - { - u16 index; - File->read(&index, 2); -#ifndef __BIG_ENDIAN__ - index=os::Byteswap::byteswap(index); -#endif - size -= 2; - if (index) - mat->Texture[currTexture].Map=Images[index-1]; - } - break; - case charsToUIntD('P','R','O','J'): // define the projection type -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: loading channel projection type."); -#endif - { - u16 index; - File->read(&index, 2); -#ifndef __BIG_ENDIAN__ - index=os::Byteswap::byteswap(index); -#endif - size -= 2; -#ifdef LWO_READER_DEBUG - if (index != 5) - os::Printer::log("LWO loader: wrong channel projection type", core::stringc(index).c_str()); -#endif - mat->Texture[currTexture].Projection=(u8)index; - } - break; - case charsToUIntD('W','R','P','W'): // for cylindrical and spherical projections - case charsToUIntD('W','R','P','H'): // for cylindrical and spherical projections - default: - { -#ifdef LWO_READER_DEBUG - os::Printer::log("LWO loader: skipping ", core::stringc((char*)&uiType, 4)); -#endif - File->seek(subsize, true); - size -= subsize; - } - } - } - - if (mat->Transparency != 0.f) - { - irrMat.MaterialType=video::EMT_TRANSPARENT_ADD_COLOR; - } -} - - -u32 CLWOMeshFileLoader::readColor(video::SColor& color) -{ - if (FormatVersion!=2) - { - u8 colorComponent; - File->read(&colorComponent, 1); - color.setRed(colorComponent); - File->read(&colorComponent, 1); - color.setGreen(colorComponent); - File->read(&colorComponent, 1); - color.setBlue(colorComponent); - // unknown value - File->read(&colorComponent, 1); - return 4; - } - else - { - video::SColorf col; - File->read(&col.r, 4); -#ifndef __BIG_ENDIAN__ - col.r=os::Byteswap::byteswap(col.r); -#endif - File->read(&col.g, 4); -#ifndef __BIG_ENDIAN__ - col.g=os::Byteswap::byteswap(col.g); -#endif - File->read(&col.b, 4); -#ifndef __BIG_ENDIAN__ - col.b=os::Byteswap::byteswap(col.b); -#endif - color=col.toSColor(); - return 12; - } -} - -u32 CLWOMeshFileLoader::readString(core::stringc& name, u32 size) -{ - c8 c; - - name=""; - if (size) - name.reserve(size); - File->read(&c, 1); - while (c) - { - name.append(c); - File->read(&c, 1); - } - // read extra 0 upon odd file position - if (File->getPos() & 0x1) - { - File->read(&c, 1); - return (name.size()+2); - } - return (name.size()+1); -} - - -u32 CLWOMeshFileLoader::readVec(core::vector3df& vec) -{ - File->read(&vec.X, 4); -#ifndef __BIG_ENDIAN__ - vec.X=os::Byteswap::byteswap(vec.X); -#endif - File->read(&vec.Y, 4); -#ifndef __BIG_ENDIAN__ - vec.Y=os::Byteswap::byteswap(vec.Y); -#endif - File->read(&vec.Z, 4); -#ifndef __BIG_ENDIAN__ - vec.Z=os::Byteswap::byteswap(vec.Z); -#endif - return 12; -} - - -u32 CLWOMeshFileLoader::readVX(u32& num) -{ - u16 tmpIndex; - - File->read(&tmpIndex, 2); -#ifndef __BIG_ENDIAN__ - tmpIndex=os::Byteswap::byteswap(tmpIndex); -#endif - num=tmpIndex; - if (num >= 0xFF00) - { - File->read(&tmpIndex, 2); -#ifndef __BIG_ENDIAN__ - tmpIndex=os::Byteswap::byteswap(tmpIndex); -#endif - num=((num << 16)|tmpIndex) & ~0xFF000000; - return 4; - } - return 2; -} - - -bool CLWOMeshFileLoader::readFileHeader() -{ - u32 Id; - - File->read(&Id, 4); -#ifndef __BIG_ENDIAN__ - Id=os::Byteswap::byteswap(Id); -#endif - if (Id != 0x464f524d) // FORM - return false; - - //skip the file length - File->read(&Id, 4); - - File->read(&Id, 4); -#ifndef __BIG_ENDIAN__ - Id=os::Byteswap::byteswap(Id); -#endif - // Currently supported: LWOB, LWLO, LWO2 - switch (Id) - { - case 0x4c574f42: - FormatVersion = 0; // LWOB - break; - case 0x4c574c4f: - FormatVersion = 1; // LWLO - break; - case 0x4c574f32: - FormatVersion = 2; // LWO2 - break; - default: - return false; // unsupported - } - - return true; -} - - -video::ITexture* CLWOMeshFileLoader::loadTexture(const core::stringc& file) -{ - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - - if (FileSystem->existFile(file)) - return driver->getTexture(file); - - core::stringc strippedName=FileSystem->getFileBasename(file); - if (FileSystem->existFile(strippedName)) - return driver->getTexture(strippedName); - core::stringc newpath = FileSystem->getFileDir(File->getFileName()); - newpath.append("/"); - newpath.append(strippedName); - if (FileSystem->existFile(newpath)) - return driver->getTexture(newpath); - os::Printer::log("Could not load texture", file.c_str(), ELL_WARNING); - - return 0; -} - - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CLWOMeshFileLoader.h b/irrlicht-1.6/source/Irrlicht/CLWOMeshFileLoader.h deleted file mode 100644 index 9f8c99bbc..000000000 --- a/irrlicht-1.6/source/Irrlicht/CLWOMeshFileLoader.h +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_LWO_MESH_FILE_LOADER_H_INCLUDED__ -#define __C_LWO_MESH_FILE_LOADER_H_INCLUDED__ - -#include "IMeshLoader.h" -#include "SMeshBuffer.h" -#include "irrString.h" - -namespace irr -{ -namespace io -{ - class IReadFile; - class IFileSystem; -} // end namespace io -namespace scene -{ - - struct SMesh; - class ISceneManager; - -//! Meshloader capable of loading Lightwave 3D meshes. -class CLWOMeshFileLoader : public IMeshLoader -{ -public: - - //! Constructor - CLWOMeshFileLoader(scene::ISceneManager* smgr, io::IFileSystem* fs); - - //! destructor - virtual ~CLWOMeshFileLoader(); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".bsp") - virtual bool isALoadableFileExtension(const io::path& 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 IUnknown::drop() for more information. - virtual IAnimatedMesh* createMesh(io::IReadFile* file); - -private: - - struct tLWOMaterial; - - bool readFileHeader(); - bool readChunks(); - void readObj1(u32 size); - void readTagMapping(u32 size); - void readVertexMapping(u32 size); - void readDiscVertexMapping (u32 size); - void readObj2(u32 size); - void readMat(u32 size); - u32 readString(core::stringc& name, u32 size=0); - u32 readVec(core::vector3df& vec); - u32 readVX(u32& num); - u32 readColor(video::SColor& color); - video::ITexture* loadTexture(const core::stringc& file); - - scene::ISceneManager* SceneManager; - io::IFileSystem* FileSystem; - io::IReadFile* File; - SMesh* Mesh; - - core::array<core::vector3df> Points; - core::array<core::array<u32> > Indices; - core::array<core::stringc> UvName; - core::array<core::array<u32> > UvIndex; - core::array<core::stringc> DUvName; - core::array<core::array<u32> > VmPolyPointsIndex; - core::array<core::array<core::vector2df> > VmCoordsIndex; - - core::array<u16> MaterialMapping; - core::array<core::array<core::vector2df> > TCoords; - core::array<tLWOMaterial*> Materials; - core::array<core::stringc> Images; - u8 FormatVersion; -}; - -} // end namespace scene -} // end namespace irr - -#endif diff --git a/irrlicht-1.6/source/Irrlicht/CLightSceneNode.cpp b/irrlicht-1.6/source/Irrlicht/CLightSceneNode.cpp deleted file mode 100644 index abb565048..000000000 --- a/irrlicht-1.6/source/Irrlicht/CLightSceneNode.cpp +++ /dev/null @@ -1,271 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CLightSceneNode.h" -#include "IVideoDriver.h" -#include "ISceneManager.h" -#include "ICameraSceneNode.h" - -#include "os.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CLightSceneNode::CLightSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position, video::SColorf color, f32 radius) -: ILightSceneNode(parent, mgr, id, position), DriverLightIndex(-1), LightIsOn(true) -{ - #ifdef _DEBUG - setDebugName("CLightSceneNode"); - #endif - - LightData.DiffuseColor = color; - // set some useful specular color - LightData.SpecularColor = color.getInterpolated(video::SColor(255,255,255,255),0.7f); - - setRadius(radius); -} - - -//! pre render event -void CLightSceneNode::OnRegisterSceneNode() -{ - doLightRecalc(); - - if (IsVisible) - SceneManager->registerNodeForRendering(this, ESNRP_LIGHT); - - ISceneNode::OnRegisterSceneNode(); -} - - -//! render -void CLightSceneNode::render() -{ - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - if (!driver) - return; - - if ( DebugDataVisible & scene::EDS_BBOX ) - { - driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); - video::SMaterial m; - m.Lighting = false; - driver->setMaterial(m); - - switch ( LightData.Type ) - { - case video::ELT_POINT: - case video::ELT_SPOT: - driver->draw3DBox(BBox, LightData.DiffuseColor.toSColor()); - break; - - case video::ELT_DIRECTIONAL: - driver->draw3DLine(core::vector3df(0.f, 0.f, 0.f), - LightData.Direction * LightData.Radius, - LightData.DiffuseColor.toSColor()); - break; - } - } - - DriverLightIndex = driver->addDynamicLight(LightData); - setVisible(LightIsOn); -} - - -//! sets the light data -void CLightSceneNode::setLightData(const video::SLight& light) -{ - LightData = light; -} - - -//! \return Returns the light data. -const video::SLight& CLightSceneNode::getLightData() const -{ - return LightData; -} - - -//! \return Returns the light data. -video::SLight& CLightSceneNode::getLightData() -{ - return LightData; -} - -void CLightSceneNode::setVisible(bool isVisible) -{ - ISceneNode::setVisible(isVisible); - - if(DriverLightIndex < 0) - return; - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - if (!driver) - return; - - LightIsOn = isVisible; - driver->turnLightOn((u32)DriverLightIndex, LightIsOn); -} - -//! returns the axis aligned bounding box of this node -const core::aabbox3d<f32>& CLightSceneNode::getBoundingBox() const -{ - return BBox; -} - - -//! Sets the light's radius of influence. -/** Outside this radius the light won't lighten geometry and cast no -shadows. Setting the radius will also influence the attenuation, setting -it to (0,1/radius,0). If you want to override this behavior, set the -attenuation after the radius. -\param radius The new radius. */ -void CLightSceneNode::setRadius(f32 radius) -{ - LightData.Radius=radius; - LightData.Attenuation.set(0.f, 1.f/radius, 0.f); - doLightRecalc(); -} - - -//! Gets the light's radius of influence. -/** \return The current radius. */ -f32 CLightSceneNode::getRadius() const -{ - return LightData.Radius; -} - - -//! Sets the light type. -/** \param type The new type. */ -void CLightSceneNode::setLightType(video::E_LIGHT_TYPE type) -{ - LightData.Type=type; -} - - -//! Gets the light type. -/** \return The current light type. */ -video::E_LIGHT_TYPE CLightSceneNode::getLightType() const -{ - return LightData.Type; -} - - -//! Sets whether this light casts shadows. -/** Enabling this flag won't automatically cast shadows, the meshes -will still need shadow scene nodes attached. But one can enable or -disable distinct lights for shadow casting for performance reasons. -\param shadow True if this light shall cast shadows. */ -void CLightSceneNode::enableCastShadow(bool shadow) -{ - LightData.CastShadows=shadow; -} - - -//! Check whether this light casts shadows. -/** \return True if light would cast shadows, else false. */ -bool CLightSceneNode::getCastShadow() const -{ - return LightData.CastShadows; -} - - -void CLightSceneNode::doLightRecalc() -{ - if ((LightData.Type == video::ELT_SPOT) || (LightData.Type == video::ELT_DIRECTIONAL)) - { - LightData.Direction = core::vector3df(.0f,.0f,1.0f); - getAbsoluteTransformation().rotateVect(LightData.Direction); - LightData.Direction.normalize(); - } - if ((LightData.Type == video::ELT_SPOT) || (LightData.Type == video::ELT_POINT)) - { - const f32 r = LightData.Radius * LightData.Radius * 0.5f; - BBox.MaxEdge.set( r, r, r ); - BBox.MinEdge.set( -r, -r, -r ); - setAutomaticCulling( scene::EAC_BOX ); - LightData.Position = getAbsolutePosition(); - } - if (LightData.Type == video::ELT_DIRECTIONAL) - { - BBox.reset( 0, 0, 0 ); - setAutomaticCulling( scene::EAC_OFF ); - } -} - - -//! Writes attributes of the scene node. -void CLightSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const -{ - ILightSceneNode::serializeAttributes(out, options); - - out->addColorf ("AmbientColor", LightData.AmbientColor); - out->addColorf ("DiffuseColor", LightData.DiffuseColor); - out->addColorf ("SpecularColor", LightData.SpecularColor); - out->addVector3d("Attenuation", LightData.Attenuation); - out->addFloat ("Radius", LightData.Radius); - out->addFloat ("OuterCone", LightData.OuterCone); - out->addFloat ("InnerCone", LightData.InnerCone); - out->addFloat ("Falloff", LightData.Falloff); - out->addBool ("CastShadows", LightData.CastShadows); - out->addEnum ("LightType", LightData.Type, video::LightTypeNames); -} - -//! Reads attributes of the scene node. -void CLightSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - LightData.AmbientColor = in->getAttributeAsColorf("AmbientColor"); - LightData.DiffuseColor = in->getAttributeAsColorf("DiffuseColor"); - LightData.SpecularColor = in->getAttributeAsColorf("SpecularColor"); - - //TODO: clearify Radius and Linear Attenuation -#if 0 - setRadius ( in->getAttributeAsFloat("Radius") ); -#else - LightData.Radius = in->getAttributeAsFloat("Radius"); -#endif - - if (in->existsAttribute("Attenuation")) // might not exist in older files - LightData.Attenuation = in->getAttributeAsVector3d("Attenuation"); - - if (in->existsAttribute("OuterCone")) // might not exist in older files - LightData.OuterCone = in->getAttributeAsFloat("OuterCone"); - if (in->existsAttribute("InnerCone")) // might not exist in older files - LightData.InnerCone = in->getAttributeAsFloat("InnerCone"); - if (in->existsAttribute("Falloff")) // might not exist in older files - LightData.Falloff = in->getAttributeAsFloat("Falloff"); - LightData.CastShadows = in->getAttributeAsBool("CastShadows"); - LightData.Type = (video::E_LIGHT_TYPE)in->getAttributeAsEnumeration("LightType", video::LightTypeNames); - - doLightRecalc (); - - ILightSceneNode::deserializeAttributes(in, options); -} - -//! Creates a clone of this scene node and its children. -ISceneNode* CLightSceneNode::clone(ISceneNode* newParent, ISceneManager* newManager) -{ - if (!newParent) - newParent = Parent; - if (!newManager) - newManager = SceneManager; - - CLightSceneNode* nb = new CLightSceneNode(newParent, - newManager, ID, RelativeTranslation, LightData.DiffuseColor, LightData.Radius); - - nb->cloneMembers(this, newManager); - nb->LightData = LightData; - nb->BBox = BBox; - - nb->drop(); - return nb; -} - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CLightSceneNode.h b/irrlicht-1.6/source/Irrlicht/CLightSceneNode.h deleted file mode 100644 index 1db890a1d..000000000 --- a/irrlicht-1.6/source/Irrlicht/CLightSceneNode.h +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_LIGHT_SCENE_NODE_H_INCLUDED__ -#define __C_LIGHT_SCENE_NODE_H_INCLUDED__ - -#include "ILightSceneNode.h" - -namespace irr -{ -namespace scene -{ - -//! Scene node which is a dynamic light. You can switch the light on and off by -//! making it visible or not, and let it be animated by ordinary scene node animators. -class CLightSceneNode : public ILightSceneNode -{ -public: - - //! constructor - CLightSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position, video::SColorf color, f32 range); - - virtual ~CLightSceneNode() { } - - //! pre render event - virtual void OnRegisterSceneNode(); - - //! render - virtual void render(); - - //! set node light data from light info - virtual void setLightData(const video::SLight& light); - - //! \return Returns the light data. - virtual const video::SLight& getLightData() const; - - //! \return Returns the light data. - virtual video::SLight& getLightData(); - - //! Sets if the node should be visible or not. - /** All children of this node won't be visible either, when set - to true. - \param isVisible If the node shall be visible. */ - virtual void setVisible(bool isVisible); - - //! returns the axis aligned bounding box of this node - virtual const core::aabbox3d<f32>& getBoundingBox() const; - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() const { return ESNT_LIGHT; } - - //! Writes attributes of the scene node. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const; - - //! Reads attributes of the scene node. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - //! Creates a clone of this scene node and its children. - virtual ISceneNode* clone(ISceneNode* newParent=0, ISceneManager* newManager=0); - - - //! Sets the light's radius of influence. - /** Outside this radius the light won't lighten geometry and cast no - shadows. Setting the radius will also influence the attenuation, setting - it to (0,1/radius,0). If you want to override this behavior, set the - attenuation after the radius. - \param radius The new radius. */ - virtual void setRadius(f32 radius); - - //! Gets the light's radius of influence. - /** \return The current radius. */ - virtual f32 getRadius() const; - - //! Sets the light type. - /** \param type The new type. */ - virtual void setLightType(video::E_LIGHT_TYPE type); - - //! Gets the light type. - /** \return The current light type. */ - virtual video::E_LIGHT_TYPE getLightType() const; - - //! Sets whether this light casts shadows. - /** Enabling this flag won't automatically cast shadows, the meshes - will still need shadow scene nodes attached. But one can enable or - disable distinct lights for shadow casting for performance reasons. - \param shadow True if this light shall cast shadows. */ - virtual void enableCastShadow(bool shadow=true); - - //! Check whether this light casts shadows. - /** \return True if light would cast shadows, else false. */ - virtual bool getCastShadow() const; -private: - - video::SLight LightData; - core::aabbox3d<f32> BBox; - s32 DriverLightIndex; - bool LightIsOn; - void doLightRecalc(); -}; - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CLimitReadFile.cpp b/irrlicht-1.6/source/Irrlicht/CLimitReadFile.cpp deleted file mode 100644 index 7a309c5a8..000000000 --- a/irrlicht-1.6/source/Irrlicht/CLimitReadFile.cpp +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CLimitReadFile.h" -#include "irrString.h" - -namespace irr -{ -namespace io -{ - - -CLimitReadFile::CLimitReadFile(IReadFile* alreadyOpenedFile, long pos, - long areaSize, const io::path& name) - : Filename(name), AreaStart(0), AreaEnd(0), Pos(0), - File(alreadyOpenedFile) -{ - #ifdef _DEBUG - setDebugName("CLimitReadFile"); - #endif - - if (File) - { - File->grab(); - AreaStart = pos; - AreaEnd = AreaStart + areaSize; - } -} - - -CLimitReadFile::~CLimitReadFile() -{ - if (File) - File->drop(); -} - - -//! returns how much was read -s32 CLimitReadFile::read(void* buffer, u32 sizeToRead) -{ -#if 1 - if (0 == File) - return 0; - - s32 r = AreaStart + Pos; - s32 toRead = core::s32_min(AreaEnd, r + sizeToRead) - core::s32_max(AreaStart, r); - if (toRead < 0) - return 0; - File->seek(r); - r = File->read(buffer, toRead); - Pos += r; - return r; -#else - const long pos = File->getPos(); - - if (pos >= AreaEnd) - return 0; - - if (pos + (long)sizeToRead >= AreaEnd) - sizeToRead = AreaEnd - pos; - - return File->read(buffer, sizeToRead); -#endif -} - - -//! changes position in file, returns true if successful -bool CLimitReadFile::seek(long finalPos, bool relativeMovement) -{ -#if 1 - Pos = core::s32_clamp(finalPos + (relativeMovement ? Pos : 0 ), 0, AreaEnd - AreaStart); - return true; -#else - const long pos = File->getPos(); - - if (relativeMovement) - { - if (pos + finalPos > AreaEnd) - finalPos = AreaEnd - pos; - } - else - { - finalPos += AreaStart; - if (finalPos > AreaEnd) - return false; - } - - return File->seek(finalPos, relativeMovement); -#endif -} - - -//! returns size of file -long CLimitReadFile::getSize() const -{ - return AreaEnd - AreaStart; -} - - -//! returns where in the file we are. -long CLimitReadFile::getPos() const -{ -#if 1 - return Pos; -#else - return File->getPos() - AreaStart; -#endif -} - - -//! returns name of file -const io::path& CLimitReadFile::getFileName() const -{ - return Filename; -} - - -IReadFile* createLimitReadFile(const io::path& fileName, IReadFile* alreadyOpenedFile, long pos, long areaSize) -{ - return new CLimitReadFile(alreadyOpenedFile, pos, areaSize, fileName); -} - - -} // end namespace io -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CLimitReadFile.h b/irrlicht-1.6/source/Irrlicht/CLimitReadFile.h deleted file mode 100644 index 42f596fcc..000000000 --- a/irrlicht-1.6/source/Irrlicht/CLimitReadFile.h +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_LIMIT_READ_FILE_H_INCLUDED__ -#define __C_LIMIT_READ_FILE_H_INCLUDED__ - -#include "IReadFile.h" -#include "irrString.h" - -namespace irr -{ - class CUnicodeConverter; - -namespace io -{ - - /*! this is a read file, which is limited to some boundaries, - so that it may only start from a certain file position - and may only read until a certain file position. - This can be useful, for example for reading uncompressed files - in an archive (zip, tar). - !*/ - class CLimitReadFile : public IReadFile - { - public: - - CLimitReadFile(IReadFile* alreadyOpenedFile, long pos, long areaSize, const io::path& name); - - virtual ~CLimitReadFile(); - - //! returns how much was read - virtual s32 read(void* buffer, u32 sizeToRead); - - //! changes position in file, returns true if successful - //! if relativeMovement==true, the pos is changed relative to current pos, - //! otherwise from begin of file - virtual bool seek(long finalPos, bool relativeMovement = false); - - //! returns size of file - virtual long getSize() const; - - //! returns where in the file we are. - virtual long getPos() const; - - //! returns name of file - virtual const io::path& getFileName() const; - - private: - - io::path Filename; - long AreaStart; - long AreaEnd; - long Pos; - IReadFile* File; - }; - -} // end namespace io -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CLogger.cpp b/irrlicht-1.6/source/Irrlicht/CLogger.cpp deleted file mode 100644 index d9f6cfc0f..000000000 --- a/irrlicht-1.6/source/Irrlicht/CLogger.cpp +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CLogger.h" - -namespace irr -{ - - CLogger::CLogger(IEventReceiver* r) - : LogLevel(ELL_INFORMATION), Receiver(r) - { - #ifdef _DEBUG - setDebugName("CLogger"); - #endif - } - - //! Returns the current set log level. - ELOG_LEVEL CLogger::getLogLevel() const - { - return LogLevel; - } - - //! Sets a new log level. - void CLogger::setLogLevel(ELOG_LEVEL ll) - { - LogLevel = ll; - } - - //! Prints out a text into the log - void CLogger::log(const c8* text, ELOG_LEVEL ll) - { - if (ll < LogLevel) - return; - - if (Receiver) - { - SEvent event; - event.EventType = EET_LOG_TEXT_EVENT; - event.LogEvent.Text = text; - event.LogEvent.Level = ll; - if (Receiver->OnEvent(event)) - return; - } - - os::Printer::print(text); - } - - - //! Prints out a text into the log - void CLogger::log(const c8* text, const c8* hint, ELOG_LEVEL ll) - { - if (ll < LogLevel) - return; - - core::stringc s = text; - s += ": "; - s += hint; - log (s.c_str(), ll); - } - - //! Prints out a text into the log - void CLogger::log(const wchar_t* text, ELOG_LEVEL ll) - { - if (ll < LogLevel) - return; - - core::stringc s = text; - log(s.c_str(), ll); - } - - - //! Prints out a text into the log - void CLogger::log(const wchar_t* text, const wchar_t* hint, ELOG_LEVEL ll) - { - if (ll < LogLevel) - return; - - core::stringc s1 = text; - core::stringc s2 = hint; - log(s1.c_str(), s2.c_str(), ll); - } - - //! Prints out a text into the log - void CLogger::log(const c8* text, const wchar_t* hint, ELOG_LEVEL ll) - { - if (ll < LogLevel) - return; - - core::stringc s2 = hint; - log( text, s2.c_str(), ll); - } - - //! Sets a new event receiver - void CLogger::setReceiver(IEventReceiver* r) - { - Receiver = r; - } - - -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CLogger.h b/irrlicht-1.6/source/Irrlicht/CLogger.h deleted file mode 100644 index 9dc29604f..000000000 --- a/irrlicht-1.6/source/Irrlicht/CLogger.h +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_LOGGER_H_INCLUDED__ -#define __C_LOGGER_H_INCLUDED__ - -#include "ILogger.h" -#include "os.h" -#include "irrString.h" -#include "IEventReceiver.h" - -namespace irr -{ - -//! Class for logging messages, warnings and errors to stdout -class CLogger : public ILogger -{ -public: - - CLogger(IEventReceiver* r); - - //! Returns the current set log level. - virtual ELOG_LEVEL getLogLevel() const; - - //! Sets a new log level. virtual void setLogLevel(ELOG_LEVEL ll); - virtual void setLogLevel(ELOG_LEVEL ll); - - //! Prints out a text into the log - virtual void log(const c8* text, ELOG_LEVEL ll=ELL_INFORMATION); - - //! Prints out a text into the log - virtual void log(const wchar_t* text, ELOG_LEVEL ll=ELL_INFORMATION); - - //! Prints out a text into the log - virtual void log(const c8* text, const c8* hint, ELOG_LEVEL ll=ELL_INFORMATION); - - //! Prints out a text into the log - virtual void log(const c8* text, const wchar_t* hint, ELOG_LEVEL ll=ELL_INFORMATION); - - //! Prints out a text into the log - virtual void log(const wchar_t* text, const wchar_t* hint, ELOG_LEVEL ll=ELL_INFORMATION); - - //! Sets a new event receiver - void setReceiver(IEventReceiver* r); - -private: - - ELOG_LEVEL LogLevel; - IEventReceiver* Receiver; -}; - -} // end namespace - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CMD2MeshFileLoader.cpp b/irrlicht-1.6/source/Irrlicht/CMD2MeshFileLoader.cpp deleted file mode 100644 index 486bac55a..000000000 --- a/irrlicht-1.6/source/Irrlicht/CMD2MeshFileLoader.cpp +++ /dev/null @@ -1,374 +0,0 @@ -// Copyright (C) 2002-2009 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_MD2_LOADER_ - -#include "CMD2MeshFileLoader.h" -#include "CAnimatedMeshMD2.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - - -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) -# pragma pack( push, packing ) -# pragma pack( 1 ) -# define PACK_STRUCT -#elif defined( __GNUC__ ) -# define PACK_STRUCT __attribute__((packed)) -#else -# error compiler not supported -#endif - - // structs needed to load the md2-format - - const s32 MD2_MAGIC_NUMBER = 844121161; - const s32 MD2_VERSION = 8; - const s32 MD2_MAX_VERTS = 2048; - - struct SMD2Header - { - s32 magic; // four character code "IDP2" - s32 version; // must be 8 - s32 skinWidth; // width of the texture - s32 skinHeight; // height of the texture - s32 frameSize; // size in bytes of an animation frame - s32 numSkins; // number of textures - s32 numVertices; // total number of vertices - s32 numTexcoords; // number of vertices with texture coords - s32 numTriangles; // number of triangles - s32 numGlCommands; // number of opengl commands (triangle strip or triangle fan) - s32 numFrames; // animation keyframe count - s32 offsetSkins; // offset in bytes to 64 character skin names - s32 offsetTexcoords; // offset in bytes to texture coordinate list - s32 offsetTriangles; // offset in bytes to triangle list - s32 offsetFrames; // offset in bytes to frame list - s32 offsetGlCommands;// offset in bytes to opengl commands - s32 offsetEnd; // offset in bytes to end of file - } PACK_STRUCT; - - struct SMD2Vertex - { - u8 vertex[3]; // [0] = X, [1] = Z, [2] = Y - u8 lightNormalIndex; // index in the normal table - } PACK_STRUCT; - - struct SMD2Frame - { - f32 scale[3]; // first scale the vertex position - f32 translate[3]; // then translate the position - c8 name[16]; // the name of the animation that this key belongs to - SMD2Vertex vertices[1]; // vertex 1 of SMD2Header.numVertices - } PACK_STRUCT; - - struct SMD2Triangle - { - u16 vertexIndices[3]; - u16 textureIndices[3]; - } PACK_STRUCT; - - struct SMD2TextureCoordinate - { - s16 s; - s16 t; - } PACK_STRUCT; - - struct SMD2GLCommand - { - f32 s, t; - s32 vertexIndex; - } PACK_STRUCT; - -// Default alignment -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) -# pragma pack( pop, packing ) -#endif - -#undef PACK_STRUCT - -//! Constructor -CMD2MeshFileLoader::CMD2MeshFileLoader() -{ - #ifdef _DEBUG - setDebugName("CMD2MeshFileLoader"); - #endif -} - - -//! returns true if the file maybe is able to be loaded by this class -//! based on the file extension (e.g. ".bsp") -bool CMD2MeshFileLoader::isALoadableFileExtension(const io::path& filename) const -{ - return core::hasFileExtension ( filename, "md2" ); -} - - -//! 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* CMD2MeshFileLoader::createMesh(io::IReadFile* file) -{ - IAnimatedMesh* msh = new CAnimatedMeshMD2(); - if (msh) - { - if (loadFile(file, (CAnimatedMeshMD2*)msh) ) - return msh; - - msh->drop(); - } - - return 0; -} - -//! loads an md2 file -bool CMD2MeshFileLoader::loadFile(io::IReadFile* file, CAnimatedMeshMD2* mesh) -{ - if (!file) - return false; - - SMD2Header header; - - file->read(&header, sizeof(SMD2Header)); - -#ifdef __BIG_ENDIAN__ - header.magic = os::Byteswap::byteswap(header.magic); - header.version = os::Byteswap::byteswap(header.version); - header.skinWidth = os::Byteswap::byteswap(header.skinWidth); - header.skinHeight = os::Byteswap::byteswap(header.skinHeight); - header.frameSize = os::Byteswap::byteswap(header.frameSize); - header.numSkins = os::Byteswap::byteswap(header.numSkins); - header.numVertices = os::Byteswap::byteswap(header.numVertices); - header.numTexcoords = os::Byteswap::byteswap(header.numTexcoords); - header.numTriangles = os::Byteswap::byteswap(header.numTriangles); - header.numGlCommands = os::Byteswap::byteswap(header.numGlCommands); - header.numFrames = os::Byteswap::byteswap(header.numFrames); - header.offsetSkins = os::Byteswap::byteswap(header.offsetSkins); - header.offsetTexcoords = os::Byteswap::byteswap(header.offsetTexcoords); - header.offsetTriangles = os::Byteswap::byteswap(header.offsetTriangles); - header.offsetFrames = os::Byteswap::byteswap(header.offsetFrames); - header.offsetGlCommands = os::Byteswap::byteswap(header.offsetGlCommands); - header.offsetEnd = os::Byteswap::byteswap(header.offsetEnd); -#endif - - if (header.magic != MD2_MAGIC_NUMBER || header.version != MD2_VERSION) - { - os::Printer::log("MD2 Loader: Wrong file header", file->getFileName(), ELL_WARNING); - return false; - } - - // - // prepare mesh and allocate memory - // - - mesh->FrameCount = header.numFrames; - - // create keyframes - mesh->FrameTransforms.set_used(header.numFrames); - - // create vertex arrays for each keyframe - if (mesh->FrameList) - delete [] mesh->FrameList; - mesh->FrameList = new core::array<CAnimatedMeshMD2::SMD2Vert>[header.numFrames]; - - // allocate space in vertex arrays - s32 i; - for (i=0; i<header.numFrames; ++i) - mesh->FrameList[i].reallocate(header.numVertices); - - // allocate interpolation buffer vertices - mesh->InterpolationBuffer->Vertices.set_used(header.numTriangles*3); - - // populate triangles - mesh->InterpolationBuffer->Indices.reallocate(header.numTriangles*3); - const s32 count = header.numTriangles*3; - for (i=0; i<count; i+=3) - { - mesh->InterpolationBuffer->Indices.push_back(i); - mesh->InterpolationBuffer->Indices.push_back(i+1); - mesh->InterpolationBuffer->Indices.push_back(i+2); - } - - // - // read texture coordinates - // - - file->seek(header.offsetTexcoords); - SMD2TextureCoordinate* textureCoords = new SMD2TextureCoordinate[header.numTexcoords]; - - if (!file->read(textureCoords, sizeof(SMD2TextureCoordinate)*header.numTexcoords)) - { - os::Printer::log("MD2 Loader: Error reading TextureCoords.", file->getFileName(), ELL_ERROR); - return false; - } - -#ifdef __BIG_ENDIAN__ - for (i=0; i<header.numTexcoords; ++i) - { - textureCoords[i].s = os::Byteswap::byteswap(textureCoords[i].s); - textureCoords[i].t = os::Byteswap::byteswap(textureCoords[i].t); - } -#endif - - // read Triangles - - file->seek(header.offsetTriangles); - - SMD2Triangle *triangles = new SMD2Triangle[header.numTriangles]; - if (!file->read(triangles, header.numTriangles *sizeof(SMD2Triangle))) - { - os::Printer::log("MD2 Loader: Error reading triangles.", file->getFileName(), ELL_ERROR); - return false; - } - -#ifdef __BIG_ENDIAN__ - for (i=0; i<header.numTriangles; ++i) - { - triangles[i].vertexIndices[0] = os::Byteswap::byteswap(triangles[i].vertexIndices[0]); - triangles[i].vertexIndices[1] = os::Byteswap::byteswap(triangles[i].vertexIndices[1]); - triangles[i].vertexIndices[2] = os::Byteswap::byteswap(triangles[i].vertexIndices[2]); - triangles[i].textureIndices[0] = os::Byteswap::byteswap(triangles[i].textureIndices[0]); - triangles[i].textureIndices[1] = os::Byteswap::byteswap(triangles[i].textureIndices[1]); - triangles[i].textureIndices[2] = os::Byteswap::byteswap(triangles[i].textureIndices[2]); - } -#endif - - // read Vertices - - u8 buffer[MD2_MAX_VERTS*4+128]; - SMD2Frame* frame = (SMD2Frame*)buffer; - - file->seek(header.offsetFrames); - - for (i = 0; i<header.numFrames; ++i) - { - // read vertices - - file->read(frame, header.frameSize); - -#ifdef __BIG_ENDIAN__ - frame->scale[0] = os::Byteswap::byteswap(frame->scale[0]); - frame->scale[1] = os::Byteswap::byteswap(frame->scale[1]); - frame->scale[2] = os::Byteswap::byteswap(frame->scale[2]); - frame->translate[0] = os::Byteswap::byteswap(frame->translate[0]); - frame->translate[1] = os::Byteswap::byteswap(frame->translate[1]); - frame->translate[2] = os::Byteswap::byteswap(frame->translate[2]); -#endif - // - // store frame data - // - - CAnimatedMeshMD2::SAnimationData adata; - adata.begin = i; - adata.end = i; - adata.fps = 7; - - // Add new named animation if necessary - if (frame->name[0]) - { - // get animation name - for (s32 s = 0; s < 16 && frame->name[s]!=0 && (frame->name[s] < '0' || frame->name[s] > '9'); ++s) - { - adata.name += frame->name[s]; - } - - // Does this keyframe have the same animation name as the current animation? - if (!mesh->AnimationData.empty() && mesh->AnimationData[mesh->AnimationData.size()-1].name == adata.name) - { - // Increase the length of the animation - ++mesh->AnimationData[mesh->AnimationData.size() - 1].end; - } - else - { - // Add the new animation - mesh->AnimationData.push_back(adata); - } - } - - // save keyframe scale and translation - - mesh->FrameTransforms[i].scale.X = frame->scale[0]; - mesh->FrameTransforms[i].scale.Z = frame->scale[1]; - mesh->FrameTransforms[i].scale.Y = frame->scale[2]; - mesh->FrameTransforms[i].translate.X = frame->translate[0]; - mesh->FrameTransforms[i].translate.Z = frame->translate[1]; - mesh->FrameTransforms[i].translate.Y = frame->translate[2]; - - // add vertices - for (s32 j=0; j<header.numTriangles; ++j) - { - for (u32 ti=0; ti<3; ++ti) - { - CAnimatedMeshMD2::SMD2Vert v; - u32 num = triangles[j].vertexIndices[ti]; - v.Pos.X = frame->vertices[num].vertex[0]; - v.Pos.Z = frame->vertices[num].vertex[1]; - v.Pos.Y = frame->vertices[num].vertex[2]; - v.NormalIdx = frame->vertices[num].lightNormalIndex; - - mesh->FrameList[i].push_back(v); - } - } - - // calculate bounding boxes - if (header.numVertices) - { - core::aabbox3d<f32> box; - core::vector3df pos; - pos.X = f32(mesh->FrameList[i] [0].Pos.X) * mesh->FrameTransforms[i].scale.X + mesh->FrameTransforms[i].translate.X; - pos.Y = f32(mesh->FrameList[i] [0].Pos.Y) * mesh->FrameTransforms[i].scale.Y + mesh->FrameTransforms[i].translate.Y; - pos.Z = f32(mesh->FrameList[i] [0].Pos.Z) * mesh->FrameTransforms[i].scale.Z + mesh->FrameTransforms[i].translate.Z; - - box.reset(pos); - - for (s32 j=1; j<header.numTriangles*3; ++j) - { - pos.X = f32(mesh->FrameList[i] [j].Pos.X) * mesh->FrameTransforms[i].scale.X + mesh->FrameTransforms[i].translate.X; - pos.Y = f32(mesh->FrameList[i] [j].Pos.Y) * mesh->FrameTransforms[i].scale.Y + mesh->FrameTransforms[i].translate.Y; - pos.Z = f32(mesh->FrameList[i] [j].Pos.Z) * mesh->FrameTransforms[i].scale.Z + mesh->FrameTransforms[i].translate.Z; - - box.addInternalPoint(pos); - } - mesh->BoxList.push_back(box); - } - } - - // populate interpolation buffer with texture coordinates and colours - if (header.numFrames) - { - f32 dmaxs = 1.0f/(header.skinWidth); - f32 dmaxt = 1.0f/(header.skinHeight); - - for (s32 t=0; t<header.numTriangles; ++t) - { - for (s32 n=0; n<3; ++n) - { - mesh->InterpolationBuffer->Vertices[t*3 + n].TCoords.X = (textureCoords[triangles[t].textureIndices[n]].s + 0.5f) * dmaxs; - mesh->InterpolationBuffer->Vertices[t*3 + n].TCoords.Y = (textureCoords[triangles[t].textureIndices[n]].t + 0.5f) * dmaxt; - mesh->InterpolationBuffer->Vertices[t*3 + n].Color = video::SColor(255,255,255,255); - } - } - } - - // clean up - delete [] triangles; - delete [] textureCoords; - - // return - - mesh->calculateBoundingBox(); - - return true; -} - -} // end namespace scene -} // end namespace irr - - -#endif // _IRR_COMPILE_WITH_MD2_LOADER_ - diff --git a/irrlicht-1.6/source/Irrlicht/CMD2MeshFileLoader.h b/irrlicht-1.6/source/Irrlicht/CMD2MeshFileLoader.h deleted file mode 100644 index da345b826..000000000 --- a/irrlicht-1.6/source/Irrlicht/CMD2MeshFileLoader.h +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_MD2_MESH_FILE_LOADER_H_INCLUDED__ -#define __C_MD2_MESH_FILE_LOADER_H_INCLUDED__ - -#include "IMeshLoader.h" - -namespace irr -{ -namespace scene -{ - -class CAnimatedMeshMD2; - -//! Meshloader capable of loading MD2 files -class CMD2MeshFileLoader : public IMeshLoader -{ -public: - - //! Constructor - CMD2MeshFileLoader(); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".bsp") - virtual bool isALoadableFileExtension(const io::path& 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: - //! Loads the file data into the mesh - bool loadFile(io::IReadFile* file, CAnimatedMeshMD2* mesh); - -}; - -} // end namespace scene -} // end namespace irr - -#endif // __C_MD2_MESH_LOADER_H_INCLUDED__ - diff --git a/irrlicht-1.6/source/Irrlicht/CMD3MeshFileLoader.cpp b/irrlicht-1.6/source/Irrlicht/CMD3MeshFileLoader.cpp deleted file mode 100644 index 959baab06..000000000 --- a/irrlicht-1.6/source/Irrlicht/CMD3MeshFileLoader.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2002-2009 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_MD3_LOADER_ - -#include "CMD3MeshFileLoader.h" -#include "CAnimatedMeshMD3.h" -#include "irrString.h" - -namespace irr -{ -namespace scene -{ - -//! Constructor -CMD3MeshFileLoader::CMD3MeshFileLoader( scene::ISceneManager* smgr) -: SceneManager(smgr) -{ -} - - -//! destructor -CMD3MeshFileLoader::~CMD3MeshFileLoader() -{ -} - - -//! returns true if the file maybe is able to be loaded by this class -//! based on the file extension (e.g. ".bsp") -bool CMD3MeshFileLoader::isALoadableFileExtension(const io::path& filename) const -{ - return core::hasFileExtension ( filename, "md3" ); -} - - -IAnimatedMesh* CMD3MeshFileLoader::createMesh(io::IReadFile* file) -{ - CAnimatedMeshMD3 * mesh = new CAnimatedMeshMD3(); - - if ( mesh->loadModelFile ( 0, file, SceneManager->getFileSystem(), SceneManager->getVideoDriver() ) ) - return mesh; - - mesh->drop (); - return 0; -} - - -} // end namespace scene -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_MD3_LOADER_ diff --git a/irrlicht-1.6/source/Irrlicht/CMD3MeshFileLoader.h b/irrlicht-1.6/source/Irrlicht/CMD3MeshFileLoader.h deleted file mode 100644 index fe96c03e0..000000000 --- a/irrlicht-1.6/source/Irrlicht/CMD3MeshFileLoader.h +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_MD3_MESH_FILE_LOADER_H_INCLUDED__ -#define __C_MD3_MESH_FILE_LOADER_H_INCLUDED__ - -#include "IMeshLoader.h" -#include "IFileSystem.h" -#include "IVideoDriver.h" -#include "ISceneManager.h" -#include "IQ3Shader.h" - -namespace irr -{ -namespace scene -{ - -//! Meshloader capable of loading md3 files. -class CMD3MeshFileLoader : public IMeshLoader -{ -public: - - //! Constructor - CMD3MeshFileLoader( scene::ISceneManager* smgr ); - - //! destructor - virtual ~CMD3MeshFileLoader(); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".bsp") - virtual bool isALoadableFileExtension(const io::path& 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: - scene::ISceneManager* SceneManager; - -}; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CMS3DMeshFileLoader.cpp b/irrlicht-1.6/source/Irrlicht/CMS3DMeshFileLoader.cpp deleted file mode 100644 index 57b271bd2..000000000 --- a/irrlicht-1.6/source/Irrlicht/CMS3DMeshFileLoader.cpp +++ /dev/null @@ -1,821 +0,0 @@ -// Copyright (C) 2002-2009 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_MS3D_LOADER_ - -#include "IReadFile.h" -#include "os.h" -#include "CMS3DMeshFileLoader.h" -#include "CSkinnedMesh.h" - - -namespace irr -{ -namespace scene -{ - -#ifdef _DEBUG -#define _IRR_DEBUG_MS3D_LOADER_ -#endif - -// byte-align structures -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) -# pragma pack( push, packing ) -# pragma pack( 1 ) -# define PACK_STRUCT -#elif defined( __GNUC__ ) -# define PACK_STRUCT __attribute__((packed)) -#else -# error compiler not supported -#endif - -// File header -struct MS3DHeader -{ - char ID[10]; - int Version; -} PACK_STRUCT; - -// Vertex information -struct MS3DVertex -{ - u8 Flags; - float Vertex[3]; - char BoneID; - u8 RefCount; -} PACK_STRUCT; - -// Triangle information -struct MS3DTriangle -{ - u16 Flags; - u16 VertexIndices[3]; - float VertexNormals[3][3]; - float S[3], T[3]; - u8 SmoothingGroup; - u8 GroupIndex; -} PACK_STRUCT; - -// Material information -struct MS3DMaterial -{ - char Name[32]; - float Ambient[4]; - float Diffuse[4]; - float Specular[4]; - float Emissive[4]; - float Shininess; // 0.0f - 128.0f - float Transparency; // 0.0f - 1.0f - u8 Mode; // 0, 1, 2 is unused now - char Texture[128]; - char Alphamap[128]; -} PACK_STRUCT; - -// Joint information -struct MS3DJoint -{ - u8 Flags; - char Name[32]; - char ParentName[32]; - float Rotation[3]; - float Translation[3]; - u16 NumRotationKeyframes; - u16 NumTranslationKeyframes; -} PACK_STRUCT; - -// Keyframe data -struct MS3DKeyframe -{ - float Time; - float Parameter[3]; -} PACK_STRUCT; - -// vertex weights in 1.8.x -struct MS3DVertexWeights -{ - char boneIds[3]; - u8 weights[3]; -} PACK_STRUCT; - -// Default alignment -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) -# pragma pack( pop, packing ) -#endif - -#undef PACK_STRUCT - -struct SGroup -{ - core::stringc Name; - core::array<u16> VertexIds; - u16 MaterialIdx; -}; - -//! Constructor -CMS3DMeshFileLoader::CMS3DMeshFileLoader(video::IVideoDriver *driver) -: Driver(driver), AnimatedMesh(0) -{ - #ifdef _DEBUG - setDebugName("CMS3DMeshFileLoader"); - #endif -} - - -//! returns true if the file maybe is able to be loaded by this class -//! based on the file extension (e.g. ".bsp") -bool CMS3DMeshFileLoader::isALoadableFileExtension(const io::path& filename) const -{ - return core::hasFileExtension ( filename, "ms3d" ); -} - - -//! 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* CMS3DMeshFileLoader::createMesh(io::IReadFile* file) -{ - if (!file) - return 0; - - AnimatedMesh = new CSkinnedMesh(); - - if ( load(file) ) - { - AnimatedMesh->finalize(); - } - else - { - AnimatedMesh->drop(); - AnimatedMesh = 0; - } - - return AnimatedMesh; -} - - -//! loads a milkshape file -bool CMS3DMeshFileLoader::load(io::IReadFile* file) -{ - if (!file) - return false; - - // find file size - const long fileSize = file->getSize(); - - // read whole file - - u8* buffer = new u8[fileSize]; - s32 read = file->read(buffer, fileSize); - if (read != fileSize) - { - delete [] buffer; - os::Printer::log("Could not read full file. Loading failed", file->getFileName(), ELL_ERROR); - return false; - } - - // read header - - const u8 *pPtr = (u8*)((void*)buffer); - MS3DHeader *pHeader = (MS3DHeader*)pPtr; - pPtr += sizeof(MS3DHeader); - - if ( strncmp( pHeader->ID, "MS3D000000", 10 ) != 0 ) - { - delete [] buffer; - os::Printer::log("Not a valid Milkshape3D Model File. Loading failed", file->getFileName(), ELL_ERROR); - return false; - } - -#ifdef __BIG_ENDIAN__ - pHeader->Version = os::Byteswap::byteswap(pHeader->Version); -#endif - if ( pHeader->Version < 3 || pHeader->Version > 4 ) - { - delete [] buffer; - os::Printer::log("Only Milkshape3D version 3 and 4 (1.3 to 1.8) is supported. Loading failed", file->getFileName(), ELL_ERROR); - return false; - } -#ifdef _IRR_DEBUG_MS3D_LOADER_ - os::Printer::log("Loaded header version", core::stringc(pHeader->Version).c_str()); -#endif - - // get pointers to data - - // vertices - u16 numVertices = *(u16*)pPtr; -#ifdef __BIG_ENDIAN__ - numVertices = os::Byteswap::byteswap(numVertices); -#endif -#ifdef _IRR_DEBUG_MS3D_LOADER_ - os::Printer::log("Load vertices", core::stringc(numVertices).c_str()); -#endif - pPtr += sizeof(u16); - MS3DVertex *vertices = (MS3DVertex*)pPtr; - pPtr += sizeof(MS3DVertex) * numVertices; - if (pPtr > buffer+fileSize) - { - delete [] buffer; - os::Printer::log("Loading failed. Corrupted data found.", file->getFileName(), ELL_ERROR); - return false; - } - for (u16 tmp=0; tmp<numVertices; ++tmp) - { -#ifdef __BIG_ENDIAN__ - vertices[tmp].Vertex[0] = os::Byteswap::byteswap(vertices[tmp].Vertex[0]); - vertices[tmp].Vertex[1] = os::Byteswap::byteswap(vertices[tmp].Vertex[1]); - vertices[tmp].Vertex[2] = -os::Byteswap::byteswap(vertices[tmp].Vertex[2]); -#else - vertices[tmp].Vertex[2] = -vertices[tmp].Vertex[2]; -#endif - } - - // triangles - u16 numTriangles = *(u16*)pPtr; -#ifdef __BIG_ENDIAN__ - numTriangles = os::Byteswap::byteswap(numTriangles); -#endif -#ifdef _IRR_DEBUG_MS3D_LOADER_ - os::Printer::log("Load Triangles", core::stringc(numTriangles).c_str()); -#endif - pPtr += sizeof(u16); - MS3DTriangle *triangles = (MS3DTriangle*)pPtr; - pPtr += sizeof(MS3DTriangle) * numTriangles; - if (pPtr > buffer+fileSize) - { - delete [] buffer; - os::Printer::log("Loading failed. Corrupted data found.", file->getFileName(), ELL_ERROR); - return false; - } - for (u16 tmp=0; tmp<numTriangles; ++tmp) - { -#ifdef __BIG_ENDIAN__ - triangles[tmp].Flags = os::Byteswap::byteswap(triangles[tmp].Flags); - for (u16 j=0; j<3; ++j) - { - triangles[tmp].VertexIndices[j] = os::Byteswap::byteswap(triangles[tmp].VertexIndices[j]); - triangles[tmp].VertexNormals[j][0] = os::Byteswap::byteswap(triangles[tmp].VertexNormals[j][0]); - triangles[tmp].VertexNormals[j][1] = os::Byteswap::byteswap(triangles[tmp].VertexNormals[j][1]); - triangles[tmp].VertexNormals[j][2] = -os::Byteswap::byteswap(triangles[tmp].VertexNormals[j][2]); - triangles[tmp].S[j] = os::Byteswap::byteswap(triangles[tmp].S[j]); - triangles[tmp].T[j] = os::Byteswap::byteswap(triangles[tmp].T[j]); - } -#else - triangles[tmp].VertexNormals[0][2] = -triangles[tmp].VertexNormals[0][2]; - triangles[tmp].VertexNormals[1][2] = -triangles[tmp].VertexNormals[1][2]; - triangles[tmp].VertexNormals[2][2] = -triangles[tmp].VertexNormals[2][2]; -#endif - } - - // groups - u16 numGroups = *(u16*)pPtr; -#ifdef __BIG_ENDIAN__ - numGroups = os::Byteswap::byteswap(numGroups); -#endif -#ifdef _IRR_DEBUG_MS3D_LOADER_ - os::Printer::log("Load Groups", core::stringc(numGroups).c_str()); -#endif - pPtr += sizeof(u16); - - core::array<SGroup> groups; - groups.reallocate(numGroups); - - //store groups - u32 i; - for (i=0; i<numGroups; ++i) - { - groups.push_back(SGroup()); - SGroup& grp = groups.getLast(); - - // The byte flag is before the name, so add 1 - grp.Name = ((const c8*) pPtr) + 1; - - pPtr += 33; // name and 1 byte flags - u16 triangleCount = *(u16*)pPtr; -#ifdef __BIG_ENDIAN__ - triangleCount = os::Byteswap::byteswap(triangleCount); -#endif - pPtr += sizeof(u16); - grp.VertexIds.reallocate(triangleCount); - - //pPtr += sizeof(u16) * triangleCount; // triangle indices - for (u16 j=0; j<triangleCount; ++j) - { -#ifdef __BIG_ENDIAN__ - grp.VertexIds.push_back(os::Byteswap::byteswap(*(u16*)pPtr)); -#else - grp.VertexIds.push_back(*(u16*)pPtr); -#endif - pPtr += sizeof (u16); - } - - grp.MaterialIdx = *(u8*)pPtr; - if (grp.MaterialIdx == 255) - grp.MaterialIdx = 0; - - pPtr += sizeof(c8); // material index - if (pPtr > buffer+fileSize) - { - delete [] buffer; - os::Printer::log("Loading failed. Corrupted data found.", file->getFileName(), ELL_ERROR); - return false; - } - } - - // skip materials - u16 numMaterials = *(u16*)pPtr; -#ifdef __BIG_ENDIAN__ - numMaterials = os::Byteswap::byteswap(numMaterials); -#endif -#ifdef _IRR_DEBUG_MS3D_LOADER_ - os::Printer::log("Load Materials", core::stringc(numMaterials).c_str()); -#endif - pPtr += sizeof(u16); - - // MS3DMaterial *materials = (MS3DMaterial*)pPtr; - // pPtr += sizeof(MS3DMaterial) * numMaterials; - - if(numMaterials == 0) - { - // if there are no materials, add at least one buffer - AnimatedMesh->addMeshBuffer(); - } - - for (i=0; i<numMaterials; ++i) - { - MS3DMaterial *material = (MS3DMaterial*)pPtr; -#ifdef __BIG_ENDIAN__ - for (u16 j=0; j<4; ++j) - material->Ambient[j] = os::Byteswap::byteswap(material->Ambient[j]); - for (u16 j=0; j<4; ++j) - material->Diffuse[j] = os::Byteswap::byteswap(material->Diffuse[j]); - for (u16 j=0; j<4; ++j) - material->Specular[j] = os::Byteswap::byteswap(material->Specular[j]); - for (u16 j=0; j<4; ++j) - material->Emissive[j] = os::Byteswap::byteswap(material->Emissive[j]); - material->Shininess = os::Byteswap::byteswap(material->Shininess); - material->Transparency = os::Byteswap::byteswap(material->Transparency); -#endif - pPtr += sizeof(MS3DMaterial); - if (pPtr > buffer+fileSize) - { - delete [] buffer; - os::Printer::log("Loading failed. Corrupted data found.", file->getFileName(), ELL_ERROR); - return false; - } - - scene::SSkinMeshBuffer *tmpBuffer = AnimatedMesh->addMeshBuffer(); - - tmpBuffer->Material.MaterialType = video::EMT_SOLID; - - tmpBuffer->Material.AmbientColor = video::SColorf(material->Ambient[0], material->Ambient[1], material->Ambient[2], material->Ambient[3]).toSColor (); - tmpBuffer->Material.DiffuseColor = video::SColorf(material->Diffuse[0], material->Diffuse[1], material->Diffuse[2], material->Diffuse[3]).toSColor (); - tmpBuffer->Material.EmissiveColor = video::SColorf(material->Emissive[0], material->Emissive[1], material->Emissive[2], material->Emissive[3]).toSColor (); - tmpBuffer->Material.SpecularColor = video::SColorf(material->Specular[0], material->Specular[1], material->Specular[2], material->Specular[3]).toSColor (); - tmpBuffer->Material.Shininess = material->Shininess; - - core::stringc TexturePath(material->Texture); - if (TexturePath.trim()!="") - { - TexturePath=stripPathFromString(file->getFileName(),true) + stripPathFromString(TexturePath,false); - tmpBuffer->Material.setTexture(0, Driver->getTexture(TexturePath) ); - } - - core::stringc AlphamapPath=(const c8*)material->Alphamap; - if (AlphamapPath.trim()!="") - { - AlphamapPath=stripPathFromString(file->getFileName(),true) + stripPathFromString(AlphamapPath,false); - tmpBuffer->Material.setTexture(2, Driver->getTexture(AlphamapPath) ); - } - - } - - // animation time - f32 framesPerSecond = *(float*)pPtr; -#ifdef __BIG_ENDIAN__ - framesPerSecond = os::Byteswap::byteswap(framesPerSecond); -#endif -#ifdef _IRR_DEBUG_MS3D_LOADER_ - os::Printer::log("FPS", core::stringc(framesPerSecond).c_str()); -#endif - pPtr += sizeof(float) * 2; // fps and current time - - if (framesPerSecond<1.f) - framesPerSecond=1.f; - -// calculated inside SkinnedMesh -// s32 frameCount = *(int*)pPtr; -#ifdef __BIG_ENDIAN__ -// frameCount = os::Byteswap::byteswap(frameCount); -#endif - pPtr += sizeof(int); - - u16 jointCount = *(u16*)pPtr; -#ifdef __BIG_ENDIAN__ - jointCount = os::Byteswap::byteswap(jointCount); -#endif -#ifdef _IRR_DEBUG_MS3D_LOADER_ - os::Printer::log("Joints", core::stringc(jointCount).c_str()); -#endif - pPtr += sizeof(u16); - if (pPtr > buffer+fileSize) - { - delete [] buffer; - os::Printer::log("Loading failed. Corrupted data found.", file->getFileName(), ELL_ERROR); - return false; - } - - core::array<core::stringc> parentNames; - parentNames.reallocate(jointCount); - - // load joints - for (i=0; i<jointCount; ++i) - { - u32 j; - MS3DJoint *pJoint = (MS3DJoint*)pPtr; -#ifdef __BIG_ENDIAN__ - for (j=0; j<3; ++j) - pJoint->Rotation[j] = os::Byteswap::byteswap(pJoint->Rotation[j]); - for (j=0; j<3; ++j) - pJoint->Translation[j] = os::Byteswap::byteswap(pJoint->Translation[j]); - pJoint->NumRotationKeyframes= os::Byteswap::byteswap(pJoint->NumRotationKeyframes); - pJoint->NumTranslationKeyframes = os::Byteswap::byteswap(pJoint->NumTranslationKeyframes); -#endif - pPtr += sizeof(MS3DJoint); - if (pPtr > buffer+fileSize) - { - delete [] buffer; - os::Printer::log("Loading failed. Corrupted data found.", file->getFileName(), ELL_ERROR); - return false; - } - - ISkinnedMesh::SJoint *jnt = AnimatedMesh->addJoint(); - - jnt->Name = pJoint->Name; -#ifdef _IRR_DEBUG_MS3D_LOADER_ - os::Printer::log("Joint", jnt->Name.c_str()); - os::Printer::log("Rotation keyframes", core::stringc(pJoint->NumRotationKeyframes).c_str()); - os::Printer::log("Translation keyframes", core::stringc(pJoint->NumTranslationKeyframes).c_str()); -#endif - jnt->LocalMatrix.makeIdentity(); - jnt->LocalMatrix.setRotationRadians( - core::vector3df(pJoint->Rotation[0], pJoint->Rotation[1], pJoint->Rotation[2]) ); - // convert right-handed to left-handed - jnt->LocalMatrix[2]=-jnt->LocalMatrix[2]; - jnt->LocalMatrix[6]=-jnt->LocalMatrix[6]; - jnt->LocalMatrix[8]=-jnt->LocalMatrix[8]; - jnt->LocalMatrix[9]=-jnt->LocalMatrix[9]; - - jnt->LocalMatrix.setTranslation( - core::vector3df(pJoint->Translation[0], pJoint->Translation[1], -pJoint->Translation[2]) ); - - parentNames.push_back( (c8*)pJoint->ParentName ); - - /*if (pJoint->NumRotationKeyframes || - pJoint->NumTranslationKeyframes) - HasAnimation = true; - */ - - // get rotation keyframes - const u16 numRotationKeyframes = pJoint->NumRotationKeyframes; - for (j=0; j < numRotationKeyframes; ++j) - { - MS3DKeyframe* kf = (MS3DKeyframe*)pPtr; -#ifdef __BIG_ENDIAN__ - kf->Time = os::Byteswap::byteswap(kf->Time); - for (u32 l=0; l<3; ++l) - kf->Parameter[l] = os::Byteswap::byteswap(kf->Parameter[l]); -#endif - pPtr += sizeof(MS3DKeyframe); - if (pPtr > buffer+fileSize) - { - delete [] buffer; - os::Printer::log("Loading failed. Corrupted data found.", file->getFileName(), ELL_ERROR); - return false; - } - - ISkinnedMesh::SRotationKey *k=AnimatedMesh->addRotationKey(jnt); - k->frame = kf->Time * framesPerSecond-1; - - core::matrix4 tmpMatrix; - - tmpMatrix.setRotationRadians( - core::vector3df(kf->Parameter[0], kf->Parameter[1], kf->Parameter[2]) ); - // convert right-handed to left-handed - tmpMatrix[2]=-tmpMatrix[2]; - tmpMatrix[6]=-tmpMatrix[6]; - tmpMatrix[8]=-tmpMatrix[8]; - tmpMatrix[9]=-tmpMatrix[9]; - - tmpMatrix=jnt->LocalMatrix*tmpMatrix; - - k->rotation = core::quaternion(tmpMatrix); - } - - // get translation keyframes - const u16 numTranslationKeyframes = pJoint->NumTranslationKeyframes; - for (j=0; j<numTranslationKeyframes; ++j) - { - MS3DKeyframe* kf = (MS3DKeyframe*)pPtr; -#ifdef __BIG_ENDIAN__ - kf->Time = os::Byteswap::byteswap(kf->Time); - for (u32 l=0; l<3; ++l) - kf->Parameter[l] = os::Byteswap::byteswap(kf->Parameter[l]); -#endif - pPtr += sizeof(MS3DKeyframe); - if (pPtr > buffer+fileSize) - { - delete [] buffer; - os::Printer::log("Loading failed. Corrupted data found.", file->getFileName(), ELL_ERROR); - return false; - } - - ISkinnedMesh::SPositionKey *k=AnimatedMesh->addPositionKey(jnt); - k->frame = kf->Time * framesPerSecond-1; - - k->position = core::vector3df - (kf->Parameter[0]+pJoint->Translation[0], - kf->Parameter[1]+pJoint->Translation[1], - -kf->Parameter[2]-pJoint->Translation[2]); - } - } - - core::array<MS3DVertexWeights> vertexWeights; - - if ((pHeader->Version == 4) && (pPtr < buffer+fileSize)) - { - s32 subVersion = *(s32*)pPtr; // comment subVersion, always 1 -#ifdef __BIG_ENDIAN__ - subVersion = os::Byteswap::byteswap(subVersion); -#endif - pPtr += sizeof(s32); - - for (u32 j=0; j<4; ++j) // four comment groups - { -#ifdef _IRR_DEBUG_MS3D_LOADER_ - os::Printer::log("Skipping comment group", core::stringc(j+1).c_str()); -#endif - u32 numComments = *(u32*)pPtr; -#ifdef __BIG_ENDIAN__ - numComments = os::Byteswap::byteswap(numComments); -#endif - pPtr += sizeof(u32); - for (i=0; i<numComments; ++i) - { - // according to scorpiomidget this field does - // not exist for model comments. So avoid to - // read it - if (j!=3) - pPtr += sizeof(s32); // index - s32 commentLength = *(s32*)pPtr; -#ifdef __BIG_ENDIAN__ - commentLength = os::Byteswap::byteswap(commentLength); -#endif - pPtr += sizeof(s32); - pPtr += commentLength; - } - - if (pPtr > buffer+fileSize) - { - delete [] buffer; - os::Printer::log("Loading failed. Corrupted data found.", file->getFileName(), ELL_ERROR); - return false; - } - } - - if (pPtr < buffer+fileSize) - { - subVersion = *(s32*)pPtr; // vertex subVersion, 1 or 2 -#ifdef __BIG_ENDIAN__ - subVersion = os::Byteswap::byteswap(subVersion); -#endif - pPtr += sizeof(s32); - -#ifdef _IRR_DEBUG_MS3D_LOADER_ - os::Printer::log("Reading vertex weights"); -#endif - // read vertex weights, ignoring data 'extra' from 1.8.2 - vertexWeights.reallocate(numVertices); - const char offset = (subVersion==1)?6:10; - for (i=0; i<numVertices; ++i) - { - vertexWeights.push_back(*(MS3DVertexWeights*)pPtr); - pPtr += offset; - } - - if (pPtr > buffer+fileSize) - { - delete [] buffer; - os::Printer::log("Loading failed. Corrupted data found.", file->getFileName(), ELL_ERROR); - return false; - } - } - - if (pPtr < buffer+fileSize) - { - subVersion = *(s32*)pPtr; // joint subVersion, 1 or 2 -#ifdef __BIG_ENDIAN__ - subVersion = os::Byteswap::byteswap(subVersion); -#endif - pPtr += sizeof(s32); - // skip joint colors -#ifdef _IRR_DEBUG_MS3D_LOADER_ - os::Printer::log("Skip joint color"); -#endif - pPtr += 3*sizeof(float)*jointCount; - - if (pPtr > buffer+fileSize) - { - delete [] buffer; - os::Printer::log("Loading failed. Corrupted data found", file->getFileName(), ELL_ERROR); - return false; - } - } - - if (pPtr < buffer+fileSize) - { - subVersion = *(s32*)pPtr; // model subVersion, 1 or 2 -#ifdef __BIG_ENDIAN__ - subVersion = os::Byteswap::byteswap(subVersion); -#endif - pPtr += sizeof(s32); -#ifdef _IRR_DEBUG_MS3D_LOADER_ - os::Printer::log("Skip model extra information"); -#endif - // now the model extra information would follow - // we also skip this for now - } - } - - //find parent of every joint - for (u32 jointnum=0; jointnum<AnimatedMesh->getAllJoints().size(); ++jointnum) - { - for (u32 j2=0; j2<AnimatedMesh->getAllJoints().size(); ++j2) - { - if (jointnum != j2 && parentNames[jointnum] == AnimatedMesh->getAllJoints()[j2]->Name ) - { - AnimatedMesh->getAllJoints()[j2]->Children.push_back(AnimatedMesh->getAllJoints()[jointnum]); - break; - } - } - } - - // create vertices and indices, attach them to the joints. - video::S3DVertex v; - core::array<video::S3DVertex> *Vertices; - core::array<u16> Indices; - - for (i=0; i<numTriangles; ++i) - { - u32 tmp = groups[triangles[i].GroupIndex].MaterialIdx; - Vertices = &AnimatedMesh->getMeshBuffers()[tmp]->Vertices_Standard; - - for (s32 j = 2; j!=-1; --j) - { - const u32 vertidx = triangles[i].VertexIndices[j]; - - v.TCoords.X = triangles[i].S[j]; - v.TCoords.Y = triangles[i].T[j]; - - v.Normal.X = triangles[i].VertexNormals[j][0]; - v.Normal.Y = triangles[i].VertexNormals[j][1]; - v.Normal.Z = triangles[i].VertexNormals[j][2]; - - if(triangles[i].GroupIndex < groups.size() && - groups[triangles[i].GroupIndex].MaterialIdx < AnimatedMesh->getMeshBuffers().size()) - v.Color = AnimatedMesh->getMeshBuffers()[groups[triangles[i].GroupIndex].MaterialIdx]->Material.DiffuseColor; - else - v.Color.set(255,255,255,255); - - v.Pos.X = vertices[vertidx].Vertex[0]; - v.Pos.Y = vertices[vertidx].Vertex[1]; - v.Pos.Z = vertices[vertidx].Vertex[2]; - - // check if we already have this vertex in our vertex array - s32 index = -1; - for (u32 iV = 0; iV < Vertices->size(); ++iV) - { - if (v == (*Vertices)[iV]) - { - index = (s32)iV; - break; - } - } - - if (index == -1) - { - index = Vertices->size(); - const u32 matidx = groups[triangles[i].GroupIndex].MaterialIdx; - if (vertexWeights.size()==0) - { - const s32 boneid = vertices[vertidx].BoneID; - if ((u32)boneid < AnimatedMesh->getAllJoints().size()) - { - ISkinnedMesh::SWeight *w=AnimatedMesh->addWeight(AnimatedMesh->getAllJoints()[boneid]); - w->buffer_id = matidx; - w->strength = 1.0f; - w->vertex_id = index; - } - } - else // new weights from 1.8.x - { - f32 sum = 1.0f; - s32 boneid = vertices[vertidx].BoneID; - if (((u32)boneid < AnimatedMesh->getAllJoints().size()) && (vertexWeights[vertidx].weights[0] != 0)) - { - ISkinnedMesh::SWeight *w=AnimatedMesh->addWeight(AnimatedMesh->getAllJoints()[boneid]); - w->buffer_id = matidx; - sum -= (w->strength = vertexWeights[vertidx].weights[0]/100.f); - w->vertex_id = index; - } - boneid = vertexWeights[vertidx].boneIds[0]; - if (((u32)boneid < AnimatedMesh->getAllJoints().size()) && (vertexWeights[vertidx].weights[1] != 0)) - { - ISkinnedMesh::SWeight *w=AnimatedMesh->addWeight(AnimatedMesh->getAllJoints()[boneid]); - w->buffer_id = matidx; - sum -= (w->strength = vertexWeights[vertidx].weights[1]/100.f); - w->vertex_id = index; - } - boneid = vertexWeights[vertidx].boneIds[1]; - if (((u32)boneid < AnimatedMesh->getAllJoints().size()) && (vertexWeights[vertidx].weights[2] != 0)) - { - ISkinnedMesh::SWeight *w=AnimatedMesh->addWeight(AnimatedMesh->getAllJoints()[boneid]); - w->buffer_id = matidx; - sum -= (w->strength = vertexWeights[vertidx].weights[2]/100.f); - w->vertex_id = index; - } - boneid = vertexWeights[vertidx].boneIds[2]; - if (((u32)boneid < AnimatedMesh->getAllJoints().size()) && (sum > 0.f)) - { - ISkinnedMesh::SWeight *w=AnimatedMesh->addWeight(AnimatedMesh->getAllJoints()[boneid]); - w->buffer_id = matidx; - w->strength = sum; - w->vertex_id = index; - } - // fallback, if no bone chosen. Seems to be an error in the specs - boneid = vertices[vertidx].BoneID; - if ((sum == 1.f) && ((u32)boneid < AnimatedMesh->getAllJoints().size())) - { - ISkinnedMesh::SWeight *w=AnimatedMesh->addWeight(AnimatedMesh->getAllJoints()[boneid]); - w->buffer_id = matidx; - w->strength = 1.f; - w->vertex_id = index; - } - } - - Vertices->push_back(v); - } - Indices.push_back(index); - } - } - - //create groups - s32 iIndex = -1; - for (i=0; i<groups.size(); ++i) - { - SGroup& grp = groups[i]; - - if (grp.MaterialIdx >= AnimatedMesh->getMeshBuffers().size()) - grp.MaterialIdx = 0; - - core::array<u16>& indices = AnimatedMesh->getMeshBuffers()[grp.MaterialIdx]->Indices; - - for (u32 k=0; k < grp.VertexIds.size(); ++k) - for (u32 l=0; l<3; ++l) - indices.push_back(Indices[++iIndex]); - } - - delete [] buffer; - - return true; -} - - -core::stringc CMS3DMeshFileLoader::stripPathFromString(const core::stringc& inString, bool returnPath) const -{ - s32 slashIndex=inString.findLast('/'); // forward slash - s32 backSlash=inString.findLast('\\'); // back slash - - if (backSlash>slashIndex) slashIndex=backSlash; - - if (slashIndex==-1)//no slashes found - { - if (returnPath) - return core::stringc(); //no path to return - else - return inString; - } - - if (returnPath) - return inString.subString(0, slashIndex + 1); - else - return inString.subString(slashIndex+1, inString.size() - (slashIndex+1)); -} - - -} // end namespace scene -} // end namespace irr - -#endif diff --git a/irrlicht-1.6/source/Irrlicht/CMS3DMeshFileLoader.h b/irrlicht-1.6/source/Irrlicht/CMS3DMeshFileLoader.h deleted file mode 100644 index e86434585..000000000 --- a/irrlicht-1.6/source/Irrlicht/CMS3DMeshFileLoader.h +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_MS3D_MESH_FILE_LOADER_H_INCLUDED__ -#define __C_MS3D_MESH_FILE_LOADER_H_INCLUDED__ - -#include "IMeshLoader.h" -#include "IVideoDriver.h" -#include "CSkinnedMesh.h" - -namespace irr -{ -namespace scene -{ - -//! Meshloader capable of loading Milkshape 3D files -class CMS3DMeshFileLoader : public IMeshLoader -{ -public: - - //! Constructor - CMS3DMeshFileLoader(video::IVideoDriver* driver); - - //! returns true if the file might be loadable by this class - //! based on the file extension (e.g. ".bsp") - virtual bool isALoadableFileExtension(const io::path& 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: - - core::stringc stripPathFromString(const core::stringc& inString, bool returnPath) const; - - bool load(io::IReadFile* file); - video::IVideoDriver* Driver; - CSkinnedMesh* AnimatedMesh; -}; - -} // end namespace scene -} // end namespace irr - -#endif - - diff --git a/irrlicht-1.6/source/Irrlicht/CMY3DHelper.h b/irrlicht-1.6/source/Irrlicht/CMY3DHelper.h deleted file mode 100644 index dcbb8c638..000000000 --- a/irrlicht-1.6/source/Irrlicht/CMY3DHelper.h +++ /dev/null @@ -1,459 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h -// -// This file was originally written by ZDimitor. - -//---------------------------------------------------------------------- -// somefuncs.h - part of the My3D Tools -// -// This tool was created by Zhuck Dmitry (ZDimitor). -// Everyone can use it as wants ( i'll be happy if it helps to someone :) ). -//---------------------------------------------------------------------- - -//********************************************************************** -// some useful functions -//********************************************************************** - -#ifndef __C_MY3D_HELPER_H_INCLUDED__ -#define __C_MY3D_HELPER_H_INCLUDED__ - -#include <irrTypes.h> - -namespace irr -{ -namespace scene -{ - -//********************************************************************** -// MY3D stuff -//********************************************************************** - -//-------------------------------------------------------------------- -// byte-align structures -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) -# pragma pack( push, packing ) -# pragma pack( 1 ) -# define PACK_STRUCT -#elif defined( __GNUC__ ) -# define PACK_STRUCT __attribute__((packed)) -#else -# error compiler not supported -#endif -//---------------------------------------------------------------------- - -struct SMyVector3 -{ SMyVector3 () {;} - SMyVector3 (f32 __X, f32 __Y, f32 __Z) - : X(__X), Y(__Y), Z(__Z) {} - f32 X, Y, Z; -} PACK_STRUCT; - -struct SMyVector2 -{ SMyVector2 () {;} - SMyVector2(f32 __X, f32 __Y) - : X(__X), Y(__Y) {} - f32 X, Y; -} PACK_STRUCT; - -struct SMyVertex -{ SMyVertex () {;} - SMyVertex (SMyVector3 _Coord, SMyColor _Color, SMyVector3 _Normal) - :Coord(_Coord), Color(_Color), Normal(_Normal) {;} - SMyVector3 Coord; - SMyColor Color; - SMyVector3 Normal; -} PACK_STRUCT; - -struct SMyTVertex -{ SMyTVertex () {;} - SMyTVertex (SMyVector2 _TCoord) - : TCoord(_TCoord) {;} - SMyVector2 TCoord; -} PACK_STRUCT; - -struct SMyFace -{ SMyFace() {;} - SMyFace(u32 __A, u32 __B, u32 __C) - : A(__A), B(__B), C(__C) {} - u32 A, B, C; -} PACK_STRUCT; - -// file header (6 bytes) -struct SMyFileHeader -{ u32 MyId; // MY3D - u16 Ver; // Version -} PACK_STRUCT; - -// scene header -struct SMySceneHeader -{ SMyColor BackgrColor; // background color - SMyColor AmbientColor; // ambient color - s32 MaterialCount; // material count - s32 MeshCount; // mesh count -} PACK_STRUCT; - -// mesh header -struct SMyMeshHeader -{ c8 Name[256]; // material name - u32 MatIndex; // index of the mesh material - u32 TChannelCnt; // mesh mapping channels count -} PACK_STRUCT; - -// texture data header -struct SMyTexDataHeader -{ c8 Name[256]; // texture name - u32 ComprMode; //compression mode - u32 PixelFormat; - u32 Width; // image width - u32 Height; // image height -} PACK_STRUCT; - -// pixel color 24bit (R8G8B8) -struct SMyPixelColor24 -{ SMyPixelColor24() {;} - SMyPixelColor24(u8 __r, u8 __g, u8 __b) - : r(__r), g(__g), b(__b) {} - u8 r, g, b; -} PACK_STRUCT; - -// pixel color 16bit (A1R5G5B5) -struct SMyPixelColor16 -{ SMyPixelColor16() {;} - SMyPixelColor16(s16 _argb): argb(_argb) {;} - SMyPixelColor16(u8 r, u8 g, u8 b) - { argb = ((r&0x1F)<<10) | ((g&0x1F)<<5) | (b&0x1F); - } - s16 argb; -} PACK_STRUCT; - -// RLE Header -struct SMyRLEHeader -{ SMyRLEHeader() {} - u32 nEncodedBytes; - u32 nDecodedBytes; -} PACK_STRUCT; - -// Default alignment -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) -# pragma pack( pop, packing ) -#endif - -} // end namespace -} // end namespace - -//----------------------------------------------------------------------------- -namespace irr -{ -namespace core -{ - -//-----------------RLE stuff----------------------------------------- - -int rle_encode ( - unsigned char *in_buf, int in_buf_size, - unsigned char *out_buf, int out_buf_size - ); -unsigned long process_comp( - unsigned char *buf, int buf_size, - unsigned char *out_buf, int out_buf_size - ); -void process_uncomp( - unsigned char, unsigned char *out_buf, int out_buf_size - ); -void flush_outbuf( - unsigned char *out_buf, int out_buf_size - ); -unsigned long get_byte ( - unsigned char *ch, - unsigned char *in_buf, int in_buf_size, - unsigned char *out_buf, int out_buf_size - ); -void put_byte( - unsigned char ch, unsigned char *out_buf, int out_buf_size - ); -//----------------------------------------------------------- -const unsigned long LIMIT = 1; // was #define LIMIT 1 -const unsigned long NON_MATCH = 2; // was: #define NON_MATCH 2 -const unsigned long EOD_FOUND = 3; // was: #define EOD_FOUND 3 -const unsigned long EOD = 0x00454f44; // was: #define EOD 'EOD' -//----------------------------------------------------------- -// number of decoded bytes -static int nDecodedBytes=0; -// number of coded bytes -static int nCodedBytes=0; -// number of read bytes -static int nReadedBytes=0; -// table used to look for sequences of repeating bytes -static unsigned char tmpbuf[4]; // we use subscripts 1 - 3 -static int tmpbuf_cnt; -// output buffer for non-compressed output data -static unsigned char outbuf[128]; -static int outbuf_cnt; - - -//----------------------------------------------------------- -int rle_encode ( - unsigned char *in_buf, int in_buf_size, - unsigned char *out_buf, int out_buf_size - ) -{ - unsigned long ret_code; - - unsigned char ch; - - nCodedBytes=0; - nReadedBytes=0; - - tmpbuf_cnt = 0; // no. of char's in tmpbuf - outbuf_cnt = 0; // no. of char's in outbuf - while (1) - { - if (get_byte(&ch, in_buf, in_buf_size, - out_buf, out_buf_size) == (int)EOD) // read next byte into ch - break; - - tmpbuf[++tmpbuf_cnt] = (unsigned char) ch; - if (tmpbuf_cnt == 3) - { - // see if all 3 match each other - if ((tmpbuf[1] == tmpbuf[2]) && (tmpbuf[2] == tmpbuf[3])) - { - // they do - add compression - // this will process all bytes in input file until - // a non-match occurs, or 128 bytes are processed, - // or we find eod */ - ret_code = process_comp(in_buf, in_buf_size, out_buf, out_buf_size); - if (ret_code == (int)EOD_FOUND) - break; // stop compressing - if (ret_code == (int)NON_MATCH) - tmpbuf_cnt=1; /* save the char that didn't match */ - else - // we just compressed the max. of 128 bytes - tmpbuf_cnt=0; /* start over for next chunk */ - } - else - { - // we know the first byte doesn't match 2 or more - // others, so just send it out as uncompressed. */ - process_uncomp(tmpbuf[1], out_buf, out_buf_size); - - // see if the last 2 bytes in the buffer match - if (tmpbuf[2] == tmpbuf[3]) - { - // move byte 3 to position 1 and pretend we just - // have 2 bytes -- note that the first byte was - // already sent to output */ - tmpbuf[1]=tmpbuf[3]; - tmpbuf_cnt=2; - } - else - { - // send byte 2 and keep byte 3 - it may match the - // next byte. Move byte 3 to position 1 and set - // count to 1. Note that the first byte was - // already sent to output - process_uncomp(tmpbuf[2], out_buf, out_buf_size); - tmpbuf[1]=tmpbuf[3]; - tmpbuf_cnt=1; - } - } - } - } // end while - flush_outbuf(out_buf, out_buf_size); - - return nCodedBytes; -} - - -//------------------------------------------------------------------ -// This flushes any non-compressed data not yet sent, then it processes -// repeating bytes until > 128, or EOD, or non-match. -// return values: LIMIT, EOD_FOUND, NON_MATCH -// Prior to ANY return, it writes out the 2 byte compressed code. -// If a NON_MATCH was found, this returns with the non-matching char -// residing in tmpbuf[0]. -// Inputs: tmpbuf[0], input file -// Outputs: tmpbuf[0] (sometimes), output file, and return code -//------------------------------------------------------------------ -unsigned long process_comp( - unsigned char *buf, int buf_size, - unsigned char *out_buf, int out_buf_size) -{ - // we start out with 3 repeating bytes - register int len = 3; - - unsigned char ch; - - // we're starting a repeating chunk - end the non-repeaters - flush_outbuf(out_buf, out_buf_size); - - while (get_byte(&ch, buf, buf_size, out_buf, out_buf_size) != (int)EOD) - { - if (ch != tmpbuf[1]) - { - // send no. of repeated bytes to be encoded - put_byte((unsigned char)((--len) | 0x80), out_buf, out_buf_size); - // send the byte's value being repeated - put_byte((unsigned char)tmpbuf[1], out_buf, out_buf_size); - /* save the non-matching character just read */ - tmpbuf[1]=(unsigned char) ch; - return NON_MATCH; - } - /* we know the new byte is part of the repeating seq */ - len++; - if (len == 128) - { - // send no. of repeated bytes to be encoded - put_byte((unsigned char)((--len) | 0x80), out_buf, out_buf_size); - // send the byte's value being repeated - put_byte((unsigned char)tmpbuf[1], out_buf, out_buf_size); - return LIMIT; - } - } // end while - - // if flow comes here, we just read an EOD - // send no. of repeated bytes to be encoded - put_byte((unsigned char)((--len) | 0x80), out_buf, out_buf_size); - // send the byte's value being repeated - put_byte((unsigned char)tmpbuf[1], out_buf, out_buf_size); - return EOD_FOUND; -} - - -//---------------------------------------------------------------- -// This adds 1 non-repeating byte to outbuf. If outbuf becomes full -// with 128 bytes, it flushes outbuf. -// There are no return codes and no bytes are read from the input. -//---------------------------------------------------------------- -void process_uncomp( - unsigned char char1, unsigned char *out_buf, int out_buf_size - ) -{ - outbuf[outbuf_cnt++] = char1; - if (outbuf_cnt == 128) - flush_outbuf(out_buf, out_buf_size); -} -//----------------------------------------------------------- -// This flushes any non-compressed data not yet sent. -// On exit, outbuf_cnt will equal zero. -//----------------------------------------------------------- -void flush_outbuf(unsigned char *out_buf, int out_buf_size) -{ - register int pos=0; - - if(!outbuf_cnt) - return; // nothing to do */ - - // send no. of unencoded bytes to be sent - put_byte((unsigned char)(outbuf_cnt - 1), out_buf, out_buf_size); - - for ( ; outbuf_cnt; outbuf_cnt--) - put_byte((unsigned char)outbuf[pos++], out_buf, out_buf_size); -} -//--------------------------------------------------- -void put_byte(unsigned char ch, unsigned char *out_buf, int out_buf_size) -{ - if (nCodedBytes<=(out_buf_size-1)) - { out_buf[nCodedBytes++]=ch; - out_buf[nCodedBytes]=0; - } -} -//--------------------------------------------------- -// This reads the next byte into ch. It returns EOD -// at end-of-data -//--------------------------------------------------- -unsigned long get_byte( - unsigned char *ch, - unsigned char *in_buf, int in_buf_size, - unsigned char *out_buf, int out_buf_size - ) -{ - if (nReadedBytes>=in_buf_size) - { - // there are either 0, 1, or 2 char's to write before we quit - if (tmpbuf_cnt == 1) - process_uncomp(tmpbuf[1], out_buf, out_buf_size); - else - { - if (tmpbuf_cnt == 2) - { - process_uncomp(tmpbuf[1], out_buf, out_buf_size); - process_uncomp(tmpbuf[2], out_buf, out_buf_size); - } - } - nReadedBytes =0; - - return EOD; - } - - (*ch) = (unsigned char)in_buf[nReadedBytes++]; - - return 0; -} -//----------------------------------------------------------- -int rle_decode ( - unsigned char *in_buf, int in_buf_size, - unsigned char *out_buf, int out_buf_size - ) -{ - nDecodedBytes=0; - nReadedBytes=0; - - int ch, i; - while (1) - { - - if (nReadedBytes>=in_buf_size) - break; - else - ch=in_buf[nReadedBytes]; - nReadedBytes++; - - if (ch > 127) - { - i = ch - 127; // i is the number of repetitions - // get the byte to be repeated - if (nReadedBytes>=in_buf_size) - break; - else - ch=in_buf[nReadedBytes]; - nReadedBytes++; - - // uncompress a chunk - for ( ; i ; i--) - { - if (nDecodedBytes<out_buf_size) - out_buf[nDecodedBytes] = ch; - nDecodedBytes++; - } - } - else - { - // copy out some uncompressed bytes - i = ch + 1; // i is the no. of bytes - // uncompress a chunk - for ( ; i ; i--) - { - if (nReadedBytes>=in_buf_size) - break; - else - ch=in_buf[nReadedBytes]; - nReadedBytes++; - - if (nDecodedBytes<out_buf_size) - out_buf[nDecodedBytes] = ch; - nDecodedBytes++; - } - } - } // end while - - return nDecodedBytes; -} - -} //end namespace core -} //end namespace irr - - -#endif // __C_MY3D_HELPER_H_INCLUDED__ - diff --git a/irrlicht-1.6/source/Irrlicht/CMY3DMeshFileLoader.cpp b/irrlicht-1.6/source/Irrlicht/CMY3DMeshFileLoader.cpp deleted file mode 100644 index 26b58dc39..000000000 --- a/irrlicht-1.6/source/Irrlicht/CMY3DMeshFileLoader.cpp +++ /dev/null @@ -1,885 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h -// -// This file was originally written by ZDimitor. - -//----------------------------------------------------------------------------- -// This tool created by ZDimitor everyone can use it as wants -//----------------------------------------------------------------------------- - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_MY3D_LOADER_ - -#include "CMY3DMeshFileLoader.h" - -#include "SAnimatedMesh.h" -#include "SMeshBuffer.h" -#include "IReadFile.h" -#include "IAttributes.h" -#include "CImage.h" -#include "CColorConverter.h" - -#include "CMY3DHelper.h" -#include "os.h" - -// v3.15 - May 16, 2005 - -namespace irr -{ -namespace scene -{ - -static const u32 MY3D_ID = 0x4d593344; -static const u16 MY3D_VER = 0x0003; -static const u16 MY3D_SCENE_HEADER_ID = 0x1000; -static const u16 MY3D_MAT_LIST_ID = 0x2000; -static const u16 MY3D_MAT_HEADER_ID = 0x2100; -static const u16 MY3D_TEX_FNAME_ID = 0x2101; -static const u16 MY3D_TEXDATA_HEADER_ID = 0x2501; -static const u16 MY3D_TEXDATA_RLE_HEADER_ID = 0x2502; -static const u16 MY3D_MESH_LIST_ID = 0x3000; -static const u16 MY3D_MESH_HEADER_ID = 0x3100; -static const u16 MY3D_VERTS_ID = 0x3101; -static const u16 MY3D_FACES_ID = 0x3102; -static const u16 MY3D_TVERTS_ID = 0x3103; -static const u16 MY3D_TFACES_ID = 0x3104; -static const u16 MY3D_FILE_END_ID = 0xFFFF; - -static const unsigned long MY3D_TEXDATA_COMPR_NONE_ID = 0x4e4f4e45; -static const unsigned long MY3D_TEXDATA_COMPR_SIMPLE_ID = 0x53494d50; -static const unsigned long MY3D_TEXDATA_COMPR_RLE_ID = 0x20524c45; - -static const unsigned long MY3D_PIXEL_FORMAT_24 = 0x5f32345f; -static const unsigned long MY3D_PIXEL_FORMAT_16 = 0x5f31365f; - -CMY3DMeshFileLoader::CMY3DMeshFileLoader(ISceneManager* scmgr, io::IFileSystem* fs) - : SceneManager(scmgr), FileSystem(fs) -{ - #ifdef _DEBUG - setDebugName("CMY3DMeshFileLoader"); - #endif - - if (FileSystem) - FileSystem->grab(); -} - - -CMY3DMeshFileLoader::~CMY3DMeshFileLoader() -{ - if (FileSystem) - FileSystem->drop(); -} - - -bool CMY3DMeshFileLoader::isALoadableFileExtension(const io::path& filename) const -{ - return core::hasFileExtension ( filename, "my3d" ); -} - - -IAnimatedMesh* CMY3DMeshFileLoader::createMesh(io::IReadFile* file) -{ - MaterialEntry.clear(); - MeshBufferEntry.clear(); - ChildNodes.clear(); - - // working directory (from which we load the scene) - core::stringc filepath = FileSystem->getFileDir(file->getFileName()); - if (filepath==".") - filepath=""; - else - filepath.append("/"); - - // read file into memory - SMyFileHeader fileHeader; - file->read(&fileHeader, sizeof(SMyFileHeader)); -#ifdef __BIG_ENDIAN__ - fileHeader.MyId = os::Byteswap::byteswap(fileHeader.MyId); - fileHeader.Ver = os::Byteswap::byteswap(fileHeader.Ver); -#endif - - if (fileHeader.MyId!=MY3D_ID || fileHeader.Ver!=MY3D_VER) - { - os::Printer::log("Bad MY3D file header, loading failed!", ELL_ERROR); - return 0; - } - - u16 id; - - file->read(&id, sizeof(id)); -#ifdef __BIG_ENDIAN__ - id = os::Byteswap::byteswap(id); -#endif - - if (id!=MY3D_SCENE_HEADER_ID) - { - os::Printer::log("Cannot find MY3D_SCENE_HEADER_ID, loading failed!", ELL_ERROR); - return 0; - } - - SMySceneHeader sceneHeader; - file->read(&sceneHeader, sizeof(SMySceneHeader)); -#ifdef __BIG_ENDIAN__ - sceneHeader.MaterialCount = os::Byteswap::byteswap(sceneHeader.MaterialCount); - sceneHeader.MeshCount = os::Byteswap::byteswap(sceneHeader.MeshCount); -#endif - - file->read(&id, sizeof(id)); -#ifdef __BIG_ENDIAN__ - id = os::Byteswap::byteswap(id); -#endif - - if (id!=MY3D_MAT_LIST_ID) - { - os::Printer::log("Can not find MY3D_MAT_LIST_ID, loading failed!", ELL_ERROR); - return 0; - } - - core::stringc texturePath = - SceneManager->getParameters()->getAttributeAsString(MY3D_TEXTURE_PATH); - - file->read(&id, sizeof(id)); -#ifdef __BIG_ENDIAN__ - id = os::Byteswap::byteswap(id); -#endif - - c8 namebuf[256]; - for (s32 m=0; m<sceneHeader.MaterialCount; ++m) - { - if (id != MY3D_MAT_HEADER_ID) - { - os::Printer::log("Cannot find MY3D_MAT_HEADER_ID, loading failed!", ELL_ERROR); - return 0; - } - - // read material header - MaterialEntry.push_back(SMyMaterialEntry()); - SMyMaterialEntry& me=MaterialEntry.getLast(); - file->read(&(me.Header), sizeof(SMyMaterialHeader)); - - // read next identificator - file->read(&id, sizeof(id)); -#ifdef __BIG_ENDIAN__ - id = os::Byteswap::byteswap(id); -#endif - - bool gotLightMap=false, gotMainMap=false; - - for (u32 t=0; t<me.Header.TextureCount; ++t) - { - if (id==MY3D_TEX_FNAME_ID) - file->read(namebuf, 256); - else - { - me.Texture2 = readEmbeddedLightmap(file, namebuf); - if (!me.Texture2) - return 0; - gotLightMap = true; - } - - const core::stringc name = namebuf; - const s32 pos = name.findLast('.'); - const core::stringc LightingMapStr = "LightingMap"; - const s32 ls = LightingMapStr.size(); - const bool isSubString = (LightingMapStr == name.subString(core::max_(0, (pos - ls)), ls)); - if ((isSubString || (name[pos-1]=='m' && - name[pos-2]=='l' && name[pos-3]=='_')) && - !gotLightMap) - { - const bool oldMipMapState = SceneManager->getVideoDriver()->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS); - SceneManager->getVideoDriver()->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false); - - me.Texture2FileName = texturePath.size() ? texturePath : filepath; - me.Texture2FileName.append("Lightmaps/"); - me.Texture2FileName.append(name); - - if (name.size()) - me.Texture2 = SceneManager->getVideoDriver()->getTexture(me.Texture2FileName); - - me.MaterialType = video::EMT_LIGHTMAP_M2; - gotLightMap = true; - - SceneManager->getVideoDriver()->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, oldMipMapState); - } - else - if (!gotLightMap && gotMainMap) - { - me.Texture2FileName = texturePath.size() ? texturePath : filepath; - me.Texture2FileName.append(name); - - if (name.size()) - me.Texture2 = SceneManager->getVideoDriver()->getTexture(me.Texture2FileName); - - me.MaterialType = video::EMT_REFLECTION_2_LAYER; - } - else - if (!gotMainMap && !gotLightMap) - { - me.Texture1FileName = filepath; - me.Texture1FileName.append(name); - if (name.size()) - me.Texture1 = SceneManager->getVideoDriver()->getTexture(me.Texture1FileName); - - gotMainMap = true; - me.MaterialType = video::EMT_SOLID; - } - else - if (gotLightMap) - { - me.MaterialType = video::EMT_LIGHTMAP_M2; - } - - file->read(&id, sizeof(id)); -#ifdef __BIG_ENDIAN__ - id = os::Byteswap::byteswap(id); -#endif - } - - // override material types based on their names - if (!strncmp(me.Header.Name, "AlphaChannel-", 13)) - me.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; - else - if (!strncmp(me.Header.Name, "SphereMap-", 10)) - me.MaterialType = video::EMT_SPHERE_MAP; - } - - // loading meshes - - SMesh* mesh = new SMesh(); - - if (id!=MY3D_MESH_LIST_ID) - { - os::Printer::log("Can not find MY3D_MESH_LIST_ID, loading failed!", ELL_ERROR); - return 0; - } - - file->read(&id, sizeof(id)); -#ifdef __BIG_ENDIAN__ - id = os::Byteswap::byteswap(id); -#endif - - for (s32 mesh_id=0; mesh_id<sceneHeader.MeshCount; mesh_id++) - { - // Warning!!! In some cases MY3D exporter uncorrectly calculates - // MeshCount (it's a problem, has to be solved) thats why - // i added this code line - if (id!=MY3D_MESH_HEADER_ID) - break; - - if (id!=MY3D_MESH_HEADER_ID) - { - os::Printer::log("Can not find MY3D_MESH_HEADER_ID, loading failed!", ELL_ERROR); - return 0; - } - - SMyMeshHeader meshHeader; - file->read(&meshHeader, sizeof(SMyMeshHeader)); - - core::array <SMyVertex> Vertex; - core::array <SMyFace> Face; - core::array <SMyTVertex> TVertex1, TVertex2; - core::array <SMyFace> TFace1, TFace2; - - s32 vertsNum=0; - s32 facesNum=0; - - // vertices - file->read(&id, sizeof(id)); -#ifdef __BIG_ENDIAN__ - id = os::Byteswap::byteswap(id); -#endif - if (id!=MY3D_VERTS_ID) - { - os::Printer::log("Can not find MY3D_VERTS_ID, loading failed!", ELL_ERROR); - return 0; - } - - file->read(&vertsNum, sizeof(vertsNum)); - Vertex.set_used(vertsNum); - file->read(Vertex.pointer(), sizeof(SMyVertex)*vertsNum); - - // faces - file->read(&id, sizeof(id)); -#ifdef __BIG_ENDIAN__ - id = os::Byteswap::byteswap(id); -#endif - if (id!=MY3D_FACES_ID) - { - os::Printer::log("Can not find MY3D_FACES_ID, loading failed!", ELL_ERROR); - return 0; - } - - file->read(&facesNum, sizeof(facesNum)); - Face.set_used(facesNum); - file->read(Face.pointer(), sizeof(SMyFace)*facesNum); - - // reading texture channels - for (s32 tex=0; tex<(s32)meshHeader.TChannelCnt; tex++) - { - // Max 2 texture channels allowed (but in format .my3d can be more) - s32 tVertsNum=0, tFacesNum=0; - - // reading texture coords - file->read(&id, sizeof(id)); -#ifdef __BIG_ENDIAN__ - id = os::Byteswap::byteswap(id); -#endif - - if (id!=MY3D_TVERTS_ID) - { - core::stringc msg="Can not find MY3D_TVERTS_ID ("; - msg.append(core::stringc(tex)); - msg.append("texture channel), loading failed!"); - os::Printer::log(msg.c_str(), ELL_ERROR); - return 0; - } - - file->read(&tVertsNum, sizeof(tVertsNum)); - - if (tex==0) - { - // 1st texture channel - TVertex1.set_used(tVertsNum); - file->read(TVertex1.pointer(), sizeof(SMyTVertex)*tVertsNum); - } - else - if (tex==1) - { - // 2nd texture channel - TVertex2.set_used(tVertsNum); - file->read(TVertex2.pointer(), sizeof(SMyTVertex)*tVertsNum); - } - else - { - // skip other texture channels - file->seek(file->getPos()+sizeof(SMyTVertex)*tVertsNum); - } - - // reading texture faces - file->read(&id, sizeof(id)); -#ifdef __BIG_ENDIAN__ - id = os::Byteswap::byteswap(id); -#endif - - if (id!=MY3D_TFACES_ID) - { - core::stringc msg="Can not find MY3D_TFACES_ID ("; - msg.append(core::stringc(tex)); - msg.append("texture channel), loading failed!"); - os::Printer::log(msg.c_str(), ELL_ERROR); - return 0; - } - - file->read(&tFacesNum, sizeof(tFacesNum)); - - if (tex==0) - { - // 1st texture channel - TFace1.set_used(tFacesNum); - file->read(TFace1.pointer(), sizeof(SMyFace)*tFacesNum); - } - else if (tex==1) - { - // 2nd texture channel - TFace2.set_used(tFacesNum); - file->read(TFace2.pointer(), sizeof(SMyFace)*tFacesNum); - } - else - { - // skip other texture channels - file->seek(file->getPos()+sizeof(SMyFace)*tFacesNum); - } - } - - // trying to find material - - SMyMaterialEntry* matEnt = getMaterialEntryByIndex(meshHeader.MatIndex); - - // creating geometry for the mesh - - // trying to find mesh buffer for this material - SMeshBufferLightMap* buffer = getMeshBufferByMaterialIndex(meshHeader.MatIndex); - - if (!buffer || - (buffer->Vertices.size()+vertsNum) > SceneManager->getVideoDriver()->getMaximalPrimitiveCount()) - { - // creating new mesh buffer for this material - buffer = new scene::SMeshBufferLightMap(); - - buffer->Material.MaterialType = video::EMT_LIGHTMAP_M2; // EMT_LIGHTMAP_M4 also possible - buffer->Material.Wireframe = false; - buffer->Material.Lighting = false; - - if (matEnt) - { - buffer->Material.MaterialType = matEnt->MaterialType; - - if (buffer->Material.MaterialType == video::EMT_REFLECTION_2_LAYER) - { - buffer->Material.Lighting = true; - buffer->Material.setTexture(1, matEnt->Texture1); - buffer->Material.setTexture(0, matEnt->Texture2); - } - else - { - buffer->Material.setTexture(0, matEnt->Texture1); - buffer->Material.setTexture(1, matEnt->Texture2); - } - - if (buffer->Material.MaterialType == video::EMT_TRANSPARENT_ALPHA_CHANNEL) - { - buffer->Material.BackfaceCulling = true; - buffer->Material.Lighting = true; - } - else - if (buffer->Material.MaterialType == video::EMT_SPHERE_MAP) - { - buffer->Material.Lighting = true; - } - - buffer->Material.AmbientColor = video::SColor( - matEnt->Header.AmbientColor.A, matEnt->Header.AmbientColor.R, - matEnt->Header.AmbientColor.G, matEnt->Header.AmbientColor.B - ); - buffer->Material.DiffuseColor = video::SColor( - matEnt->Header.DiffuseColor.A, matEnt->Header.DiffuseColor.R, - matEnt->Header.DiffuseColor.G, matEnt->Header.DiffuseColor.B - ); - buffer->Material.EmissiveColor = video::SColor( - matEnt->Header.EmissiveColor.A, matEnt->Header.EmissiveColor.R, - matEnt->Header.EmissiveColor.G, matEnt->Header.EmissiveColor.B - ); - buffer->Material.SpecularColor = video::SColor( - matEnt->Header.SpecularColor.A, matEnt->Header.SpecularColor.R, - matEnt->Header.SpecularColor.G, matEnt->Header.SpecularColor.B - ); - } - else - { - buffer->Material.setTexture(0, 0); - buffer->Material.setTexture(1, 0); - - buffer->Material.AmbientColor = video::SColor(255, 255, 255, 255); - buffer->Material.DiffuseColor = video::SColor(255, 255, 255, 255); - buffer->Material.EmissiveColor = video::SColor(0, 0, 0, 0); - buffer->Material.SpecularColor = video::SColor(0, 0, 0, 0); - } - - if (matEnt && matEnt->Header.Transparency!=0) - { - if (buffer->Material.MaterialType == video::EMT_REFLECTION_2_LAYER ) - { - buffer->Material.MaterialType = video::EMT_TRANSPARENT_REFLECTION_2_LAYER; - buffer->Material.Lighting = true; - buffer->Material.BackfaceCulling = true; - } - else - { - buffer->Material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA; - buffer->Material.Lighting = false; - buffer->Material.BackfaceCulling = false; - } - } - else if ( - !buffer->Material.getTexture(1) && - buffer->Material.MaterialType != video::EMT_TRANSPARENT_ALPHA_CHANNEL && - buffer->Material.MaterialType != video::EMT_SPHERE_MAP) - { - buffer->Material.MaterialType = video::EMT_SOLID; - buffer->Material.Lighting = true; - } - - MeshBufferEntry.push_back( - SMyMeshBufferEntry(meshHeader.MatIndex, buffer)); - } - - video::S3DVertex2TCoords VertexA, VertexB, VertexC; - - // vertices (A, B, C) color - video::SColor vert_color; - if (matEnt && - (buffer->Material.MaterialType == video::EMT_TRANSPARENT_VERTEX_ALPHA || - buffer->Material.MaterialType == video::EMT_TRANSPARENT_REFLECTION_2_LAYER)) - { - video::SColor color( - matEnt->Header.DiffuseColor.A, matEnt->Header.DiffuseColor.R, - matEnt->Header.DiffuseColor.G, matEnt->Header.DiffuseColor.B); - - vert_color = color.getInterpolated(video::SColor(0,0,0,0), - 1-matEnt->Header.Transparency); - } - else - { - vert_color = buffer->Material.DiffuseColor; - } - - VertexA.Color = VertexB.Color = VertexC.Color = vert_color; - - if (buffer->Material.MaterialType == video::EMT_TRANSPARENT_ALPHA_CHANNEL) - { - buffer->Indices.reallocate(buffer->Indices.size()+6*facesNum); - buffer->Vertices.reallocate(buffer->Vertices.size()+6*facesNum); - } - else - { - buffer->Indices.reallocate(buffer->Indices.size()+3*facesNum); - buffer->Vertices.reallocate(buffer->Vertices.size()+3*facesNum); - } - for (int f=0; f<facesNum; f++) - { - // vertex A - - VertexA.Pos.X = Vertex[Face[f].C].Coord.X; - VertexA.Pos.Y = Vertex[Face[f].C].Coord.Y; - VertexA.Pos.Z = Vertex[Face[f].C].Coord.Z; - - VertexA.Normal.X = Vertex[Face[f].C].Normal.X; - VertexA.Normal.Y = Vertex[Face[f].C].Normal.Y; - VertexA.Normal.Z = Vertex[Face[f].C].Normal.Z; - - if (meshHeader.TChannelCnt>0) - { - VertexA.TCoords.X = TVertex1[TFace1[f].C].TCoord.X; - VertexA.TCoords.Y = TVertex1[TFace1[f].C].TCoord.Y; - } - - if (meshHeader.TChannelCnt>1) - { - VertexA.TCoords2.X = TVertex2[TFace2[f].C].TCoord.X; - VertexA.TCoords2.Y = TVertex2[TFace2[f].C].TCoord.Y; - } - - // vertex B - - VertexB.Pos.X = Vertex[Face[f].B].Coord.X; - VertexB.Pos.Y = Vertex[Face[f].B].Coord.Y; - VertexB.Pos.Z = Vertex[Face[f].B].Coord.Z; - - VertexB.Normal.X = Vertex[Face[f].B].Normal.X; - VertexB.Normal.Y = Vertex[Face[f].B].Normal.Y; - VertexB.Normal.Z = Vertex[Face[f].B].Normal.Z; - - if (meshHeader.TChannelCnt>0) - { - VertexB.TCoords.X = TVertex1[TFace1[f].B].TCoord.X; - VertexB.TCoords.Y = TVertex1[TFace1[f].B].TCoord.Y; - } - - if (meshHeader.TChannelCnt>1) - { - VertexB.TCoords2.X = TVertex2[TFace2[f].B].TCoord.X; - VertexB.TCoords2.Y = TVertex2[TFace2[f].B].TCoord.Y; - } - - // vertex C - - VertexC.Pos.X = Vertex[Face[f].A].Coord.X; - VertexC.Pos.Y = Vertex[Face[f].A].Coord.Y; - VertexC.Pos.Z = Vertex[Face[f].A].Coord.Z; - - VertexC.Normal.X = Vertex[Face[f].A].Normal.X; - VertexC.Normal.Y = Vertex[Face[f].A].Normal.Y; - VertexC.Normal.Z = Vertex[Face[f].A].Normal.Z; - - if (meshHeader.TChannelCnt>0) - { - VertexC.TCoords.X = TVertex1[TFace1[f].A].TCoord.X; - VertexC.TCoords.Y = TVertex1[TFace1[f].A].TCoord.Y; - } - if (meshHeader.TChannelCnt>1) - { - VertexC.TCoords2.X = TVertex2[TFace2[f].A].TCoord.X; - VertexC.TCoords2.Y = TVertex2[TFace2[f].A].TCoord.Y; - } - - // store 3d data in mesh buffer - - buffer->Indices.push_back(buffer->Vertices.size()); - buffer->Vertices.push_back(VertexA); - - buffer->Indices.push_back(buffer->Vertices.size()); - buffer->Vertices.push_back(VertexB); - - buffer->Indices.push_back(buffer->Vertices.size()); - buffer->Vertices.push_back(VertexC); - - //***************************************************************** - // !!!!!! W A R N I N G !!!!!!! - //***************************************************************** - // For materials with alpha channel we duplicate all faces. - // This has be done for proper lighting calculation of the back faces. - // So you must remember this while you creating your models !!!!! - //***************************************************************** - // !!!!!! W A R N I N G !!!!!!! - //***************************************************************** - - if (buffer->Material.MaterialType == video::EMT_TRANSPARENT_ALPHA_CHANNEL) - { - VertexA.Normal = core::vector3df(-VertexA.Normal.X, -VertexA.Normal.Y, -VertexA.Normal.Z); - VertexB.Normal = core::vector3df(-VertexB.Normal.X, -VertexB.Normal.Y, -VertexB.Normal.Z); - VertexC.Normal = core::vector3df(-VertexC.Normal.X, -VertexC.Normal.Y, -VertexC.Normal.Z); - - buffer->Indices.push_back(buffer->Vertices.size()); - buffer->Vertices.push_back(VertexC); - - buffer->Indices.push_back(buffer->Vertices.size()); - buffer->Vertices.push_back(VertexB); - - buffer->Indices.push_back(buffer->Vertices.size()); - buffer->Vertices.push_back(VertexA); - } - } - file->read(&id, sizeof(id)); -#ifdef __BIG_ENDIAN__ - id = os::Byteswap::byteswap(id); -#endif - } - - // creating mesh - - for (u32 num=0; num<MeshBufferEntry.size(); ++num) - { - SMeshBufferLightMap* buffer = MeshBufferEntry[num].MeshBuffer; - - if (!buffer) - continue; - - mesh->addMeshBuffer(buffer); - - buffer->recalculateBoundingBox(); - buffer->drop(); - } - - mesh->recalculateBoundingBox(); - - if (id != MY3D_FILE_END_ID) - os::Printer::log("Loading finished, but can not find MY3D_FILE_END_ID token.", ELL_WARNING); - - SAnimatedMesh* am = new SAnimatedMesh(); - - am->addMesh(mesh); - mesh->drop(); - am->recalculateBoundingBox(); - - return am; -} - - -video::ITexture* CMY3DMeshFileLoader::readEmbeddedLightmap(io::IReadFile* file, char* namebuf) -{ - static int LightMapIndex=0; - u16 id; - file->read(&id, sizeof(id)); -#ifdef __BIG_ENDIAN__ - id = os::Byteswap::byteswap(id); -#endif - if (id!=MY3D_TEXDATA_HEADER_ID) - { - os::Printer::log("Can not find MY3D_TEXDATA_HEADER_ID, loading failed!", ELL_ERROR); - return 0; - } - - SMyTexDataHeader texDataHeader; - - file->read(&texDataHeader, sizeof(SMyTexDataHeader)); - - strcpy(texDataHeader.Name, namebuf); - - char LightMapName[255]; - sprintf(LightMapName,"My3D.Lightmap.%d",++LightMapIndex); - - core::stringc pixFormatStr; - if (texDataHeader.PixelFormat == MY3D_PIXEL_FORMAT_24) - pixFormatStr = "24bit,"; - else - if (texDataHeader.PixelFormat == MY3D_PIXEL_FORMAT_16) - pixFormatStr = "16bit,"; - else - { - core::stringc msg="Unknown format of image data ("; - msg.append(LightMapName); - msg.append("), loading failed!"); - os::Printer::log(msg.c_str(), ELL_ERROR); - return 0; - } - - if (texDataHeader.ComprMode != MY3D_TEXDATA_COMPR_NONE_ID && - texDataHeader.ComprMode != MY3D_TEXDATA_COMPR_RLE_ID && - texDataHeader.ComprMode != MY3D_TEXDATA_COMPR_SIMPLE_ID ) - { - os::Printer::log("Unknown method of compression image data, loading failed!", ELL_ERROR); - return 0; - } - - const u32 num_pixels = texDataHeader.Width*texDataHeader.Height; - - void* data = 0; - - if (texDataHeader.ComprMode==MY3D_TEXDATA_COMPR_NONE_ID) - { - // none compressed image data - if (texDataHeader.PixelFormat == MY3D_PIXEL_FORMAT_24) - { - data = (void*) new SMyPixelColor24[num_pixels]; - file->read(data, sizeof(SMyPixelColor24)*num_pixels); - } - else - { - data = (void*) new SMyPixelColor16[num_pixels]; - file->read(data, sizeof(SMyPixelColor16)*num_pixels); - } - } - else - if (texDataHeader.ComprMode==MY3D_TEXDATA_COMPR_RLE_ID) - { - // read RLE header identificator - file->read(&id, sizeof(id)); -#ifdef __BIG_ENDIAN__ - id = os::Byteswap::byteswap(id); -#endif - if (id!=MY3D_TEXDATA_RLE_HEADER_ID) - { - os::Printer::log("Can not find MY3D_TEXDATA_RLE_HEADER_ID, loading failed!", ELL_ERROR); - return 0; - } - - // read RLE header - SMyRLEHeader rleHeader; - file->read(&rleHeader, sizeof(SMyRLEHeader)); - - //allocate memory for input and output buffers - void *input_buffer = (void*) new unsigned char[rleHeader.nEncodedBytes]; - void *output_buffer = (void*) new unsigned char[rleHeader.nDecodedBytes]; - - // read encoded data - file->read(input_buffer, rleHeader.nEncodedBytes); - - // decode data - data = 0;//(void*) new unsigned char[rleHeader.nDecodedBytes]; - s32 decodedBytes = core::rle_decode( - (unsigned char*)input_buffer, rleHeader.nEncodedBytes, - (unsigned char*)output_buffer, rleHeader.nDecodedBytes); - - if (decodedBytes!=(s32)rleHeader.nDecodedBytes) - { - os::Printer::log("Error extracting data from RLE compression, loading failed!", ELL_ERROR); - return 0; - } - - // free input buffer - delete [] (unsigned char*)input_buffer; - - // here decoded data - data = output_buffer; - } - else if (texDataHeader.ComprMode==MY3D_TEXDATA_COMPR_SIMPLE_ID) - { - // simple compressed image data - if (texDataHeader.PixelFormat == MY3D_PIXEL_FORMAT_24) - data = (void*) new SMyPixelColor24[num_pixels]; - else - data = (void*) new SMyPixelColor16[num_pixels]; - - u32 nReadedPixels=0, nToRead=0; - while (true) - { - file->read(&nToRead, sizeof(nToRead)); - - if ((nReadedPixels+nToRead) > num_pixels) - break; - - if (texDataHeader.PixelFormat == MY3D_PIXEL_FORMAT_24) - { - SMyPixelColor24 col24; - file->read(&col24, sizeof(SMyPixelColor24)); - for (u32 p=0; p<nToRead; p++) - { - ((SMyPixelColor24*)data)[nReadedPixels+p] = - SMyPixelColor24(col24.r, col24.g, col24.b); - } - } - else - { - SMyPixelColor16 col16; - file->read(&col16, sizeof(SMyPixelColor16)); - for (u32 p=0; p<nToRead; p++) - ((SMyPixelColor16*)data)[nReadedPixels+p].argb = col16.argb; - } - - nReadedPixels+=nToRead; - - if (nReadedPixels >= num_pixels) - break; - } - - if (nReadedPixels != num_pixels) - { - os::Printer::log("Image data seems to be corrupted, loading failed!", ELL_ERROR); - return 0; - } - } - - //! Creates a software image from a byte array. - video::IImage* light_img = 0; - - if (texDataHeader.PixelFormat == MY3D_PIXEL_FORMAT_24) - { - // 24 bit lightmap format - light_img = SceneManager->getVideoDriver()->createImageFromData( - video::ECF_R8G8B8, - core::dimension2d<u32>(texDataHeader.Width, texDataHeader.Height), - data, true); - } - else - { - // 16 bit lightmap format - light_img = SceneManager->getVideoDriver()->createImageFromData( - video::ECF_A1R5G5B5, - core::dimension2d<u32>(texDataHeader.Width, texDataHeader.Height), - data, true); - } - - const bool oldMipMapState = SceneManager->getVideoDriver()->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS); - SceneManager->getVideoDriver()->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false); - video::ITexture* lmtex = SceneManager->getVideoDriver()->addTexture(LightMapName, light_img); - SceneManager->getVideoDriver()->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, oldMipMapState); - - light_img->drop(); - return lmtex; -} - - -CMY3DMeshFileLoader::SMyMaterialEntry* CMY3DMeshFileLoader::getMaterialEntryByIndex(u32 matInd) -{ - for (u32 m=0; m<MaterialEntry.size(); ++m) - if (MaterialEntry[m].Header.Index == matInd) - return &MaterialEntry[m]; - - return 0; -} - - - -SMeshBufferLightMap* CMY3DMeshFileLoader::getMeshBufferByMaterialIndex(u32 matInd) -{ - for (u32 m=0; m<MeshBufferEntry.size(); ++m) - { - if (MeshBufferEntry[m].MaterialIndex == (s32)matInd) - return MeshBufferEntry[m].MeshBuffer; - } - return 0; -} - - -const core::array<ISceneNode*>& CMY3DMeshFileLoader::getChildNodes() const -{ - return ChildNodes; -} - - -} // end namespace scnene -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_MY3D_LOADER_ - diff --git a/irrlicht-1.6/source/Irrlicht/CMY3DMeshFileLoader.h b/irrlicht-1.6/source/Irrlicht/CMY3DMeshFileLoader.h deleted file mode 100644 index d255b2e65..000000000 --- a/irrlicht-1.6/source/Irrlicht/CMY3DMeshFileLoader.h +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h -// -// This file was originally written by ZDimitor. -// I (Nikolaus Gebhardt) did some few changes to this: -// - replaced logging calls to their os:: counterparts -// - removed some logging calls -// - enabled image dropping of CImage again, because that bug has been fixed now -// - removed setTexture path and replaced it with the directory of the mesh -// - added EAMT_MY3D file type -// - fixed a memory leak when decompressing RLE data. -// - cleaned multi character constant problems with gcc -// - removed octree child scene node generation because irrlicht is now able to draw -// scene nodes with transparent and sold materials in them at the same time. (see changes.txt) -// Thanks a lot to ZDimitor for his work on this and that he gave me -// his permission to add it into Irrlicht. - -//-------------------------------------------------------------------------------- -// This tool created by ZDimitor everyone can use it as wants -//-------------------------------------------------------------------------------- - -#ifndef __CMY3D_MESH_FILE_LOADER_H_INCLUDED__ -#define __CMY3D_MESH_FILE_LOADER_H_INCLUDED__ - - -#ifdef _MSC_VER -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -#endif - - -#include "IMeshLoader.h" -#include "SMesh.h" -#include "SMeshBufferLightMap.h" -#include "IFileSystem.h" -#include "IVideoDriver.h" -#include "irrString.h" -#include "ISceneManager.h" - -namespace irr -{ -namespace scene -{ - -//-------------------------------------------------------------------- -// byte-align structures -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) -# pragma pack( push, packing ) -# pragma pack( 1 ) -# define PACK_STRUCT -#elif defined( __GNUC__ ) -# define PACK_STRUCT __attribute__((packed)) -#else -# error compiler not supported -#endif -//---------------------------------------------------------------------- -struct SMyColor -{ SMyColor () {;} - SMyColor (s32 __R, s32 __G, s32 __B, s32 __A) - : R(__R), G(__G), B(__B), A(__A) {} - s32 R, G, B, A; -} PACK_STRUCT; - -// material header -struct SMyMaterialHeader -{ c8 Name[256]; // material name - u32 Index; - SMyColor AmbientColor; - SMyColor DiffuseColor; - SMyColor EmissiveColor; - SMyColor SpecularColor; - f32 Shininess; - f32 Transparency; - u32 TextureCount; // texture count -} PACK_STRUCT; - -// Default alignment -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) -# pragma pack( pop, packing ) -#endif - -class CMY3DMeshFileLoader : public IMeshLoader -{ -public: - CMY3DMeshFileLoader(ISceneManager *scmgr, io::IFileSystem* fs); - virtual ~CMY3DMeshFileLoader(); - - virtual bool isALoadableFileExtension(const io::path& filename) const; - - virtual IAnimatedMesh* createMesh(io::IReadFile* file); - - //! getting access to the nodes (with transparent material), creating - //! while loading .my3d file - const core::array<ISceneNode*>& getChildNodes() const; - -private: - - video::ITexture* readEmbeddedLightmap(io::IReadFile* file, char* namebuf); - - scene::ISceneManager* SceneManager; - io::IFileSystem* FileSystem; - - struct SMyMaterialEntry - { - SMyMaterialEntry () - : Texture1FileName("null"), Texture2FileName("null"), - Texture1(0), Texture2(0), MaterialType(video::EMT_SOLID) {} - - SMyMaterialHeader Header; - core::stringc Texture1FileName; - core::stringc Texture2FileName; - video::ITexture *Texture1; - video::ITexture *Texture2; - video::E_MATERIAL_TYPE MaterialType; - }; - - struct SMyMeshBufferEntry - { - SMyMeshBufferEntry() : MaterialIndex(-1), MeshBuffer(0) {} - SMyMeshBufferEntry(s32 mi, SMeshBufferLightMap* mb) - : MaterialIndex(mi), MeshBuffer(mb) {} - - s32 MaterialIndex; - SMeshBufferLightMap* MeshBuffer; - }; - - SMyMaterialEntry* getMaterialEntryByIndex (u32 matInd); - SMeshBufferLightMap* getMeshBufferByMaterialIndex(u32 matInd); - - core::array<SMyMaterialEntry> MaterialEntry; - core::array<SMyMeshBufferEntry> MeshBufferEntry; - - core::array<ISceneNode*> ChildNodes; -}; - - -} // end namespace scene -} // end namespace irr - - -#endif // __CMY3D_MESH_FILE_LOADER_H_INCLUDED__ diff --git a/irrlicht-1.6/source/Irrlicht/CMakeLists.txt b/irrlicht-1.6/source/Irrlicht/CMakeLists.txt deleted file mode 100644 index 2c78a2c5c..000000000 --- a/irrlicht-1.6/source/Irrlicht/CMakeLists.txt +++ /dev/null @@ -1,550 +0,0 @@ -INCLUDE_DIRECTORIES( ${IRRLICHT_SOURCE_DIR}/include ${IRRLICHT_SOURCE_DIR}/source/Irrlicht/zlib ${IRRLICHT_SOURCE_DIR}/source/Irrlicht ${IRRLICHT_SOURCE_DIR}/source/Irrlicht/MacOSX ) - -#ADD_DEFINITIONS(-D_IRR_STATIC_LIB_) - -IF (WIN32) -#ADD_DEFINITIONS(-DJPEG_CJPEG_DJPEG) -ELSE (WIN32) - - -ENDIF (WIN32) - - -SET( Irrlicht_SRCS -CDefaultGUIElementFactory.cpp -CDefaultGUIElementFactory.h -CGUIButton.cpp -CGUIButton.h -CGUICheckBox.cpp -CGUICheckBox.h -CGUIColorSelectDialog.cpp -CGUIColorSelectDialog.h -CGUIComboBox.cpp -CGUIComboBox.h -CGUIContextMenu.cpp -CGUIContextMenu.h -CGUIEditBox.cpp -CGUIEditBox.h -CGUIEnvironment.cpp -CGUIEnvironment.h -CGUIFileOpenDialog.cpp -CGUIFileOpenDialog.h -CGUIFont.cpp -CGUIFont.h -CGUIImage.cpp -CGUIImage.h -CGUIInOutFader.cpp -CGUIInOutFader.h -CGUIListBox.cpp -CGUIListBox.h -CGUIMenu.cpp -CGUIMenu.h -CGUIMeshViewer.cpp -CGUIMeshViewer.h -CGUIMessageBox.cpp -CGUIMessageBox.h -CGUIModalScreen.cpp -CGUIModalScreen.h -CGUIScrollBar.cpp -CGUIScrollBar.h -CGUISkin.cpp -CGUISkin.h -CGUISpinBox.cpp -CGUISpinBox.h -CGUISpriteBank.cpp -CGUISpriteBank.h -CGUIStaticText.cpp -CGUIStaticText.h -CGUITabControl.cpp -CGUITabControl.h -CGUIToolBar.cpp -CGUIToolBar.h -CGUIWindow.cpp -CGUIWindow.h -CVideoModeList.cpp -CVideoModeList.h -CSoftwareDriver.cpp -CSoftwareDriver.h -CSoftwareTexture.cpp -CSoftwareTexture.h -CTRFlat.cpp -CTRFlatWire.cpp -CTRGouraud.cpp -CTRGouraudWire.cpp -CTRTextureFlat.cpp -CTRTextureFlatWire.cpp -CTRTextureGouraud.cpp -CTRTextureGouraud.h -CTRTextureGouraudAdd.cpp -CTRTextureGouraudNoZ.cpp -CTRTextureGouraudWire.cpp -CZBuffer.cpp -CZBuffer.h -ITriangleRenderer.h -IZBuffer.h -S2DVertex.h -COpenGLDriver.cpp -COpenGLDriver.h -COpenGLExtensionHandler.cpp -COpenGLExtensionHandler.h -COpenGLMaterialRenderer.h -COpenGLNormalMapRenderer.cpp -COpenGLNormalMapRenderer.h -COpenGLParallaxMapRenderer.cpp -COpenGLParallaxMapRenderer.h -COpenGLShaderMaterialRenderer.cpp -COpenGLShaderMaterialRenderer.h -COpenGLSLMaterialRenderer.cpp -COpenGLSLMaterialRenderer.h -COpenGLTexture.cpp -COpenGLTexture.h -glext.h -CD3D8Driver.cpp -CD3D8Driver.h -CD3D8MaterialRenderer.h -CD3D8NormalMapRenderer.cpp -CD3D8NormalMapRenderer.h -CD3D8ParallaxMapRenderer.cpp -CD3D8ParallaxMapRenderer.h -CD3D8ShaderMaterialRenderer.cpp -CD3D8ShaderMaterialRenderer.h -CD3D8Texture.cpp -CD3D8Texture.h -CColorConverter.cpp -CColorConverter.h -CFPSCounter.cpp -CFPSCounter.h -CImage.cpp -CImage.h -CImageLoaderBMP.cpp -CImageLoaderBMP.h -CImageLoaderJPG.cpp -CImageLoaderJPG.h -CImageLoaderPCX.cpp -CImageLoaderPCX.h -CImageLoaderPNG.cpp -CImageLoaderPNG.h -CImageLoaderPPM.cpp -CImageLoaderPPM.h -CImageLoaderPSD.cpp -CImageLoaderPSD.h -CImageLoaderRGB.cpp -CImageLoaderRGB.h -CImageLoaderTGA.cpp -CImageLoaderTGA.h -CNullDriver.cpp -CNullDriver.h -IImagePresenter.h -CImageWriterBMP.cpp -CImageWriterBMP.h -CImageWriterJPG.cpp -CImageWriterJPG.h -CImageWriterPCX.cpp -CImageWriterPCX.h -CImageWriterPNG.cpp -CImageWriterPNG.h -CImageWriterPPM.cpp -CImageWriterPPM.h -CImageWriterPSD.cpp -CImageWriterPSD.h -CImageWriterTGA.cpp -CImageWriterTGA.h -CD3D9Driver.cpp -CD3D9Driver.h -CD3D9HLSLMaterialRenderer.cpp -CD3D9HLSLMaterialRenderer.h -CD3D9MaterialRenderer.h -CD3D9NormalMapRenderer.cpp -CD3D9NormalMapRenderer.h -CD3D9ParallaxMapRenderer.cpp -CD3D9ParallaxMapRenderer.h -CD3D9ShaderMaterialRenderer.cpp -CD3D9ShaderMaterialRenderer.h -CD3D9Texture.cpp -CD3D9Texture.h -CDepthBuffer.cpp -CDepthBuffer.h -CSoftware2MaterialRenderer.h -CSoftwareDriver2.cpp -CSoftwareDriver2.h -CSoftwareTexture2.cpp -CSoftwareTexture2.h -CTRGouraud2.cpp -CTRGouraudAlpha2.cpp -CTRGouraudAlphaNoZ2.cpp -CTRTextureBlend.cpp -CTRTextureDetailMap2.cpp -CTRTextureGouraud2.cpp -CTRTextureGouraudAdd2.cpp -CTRTextureGouraudAddNoZ2.cpp -CTRTextureGouraudAlpha.cpp -CTRTextureGouraudAlphaNoZ.cpp -CTRTextureGouraudNoZ2.cpp -CTRTextureGouraudVertexAlpha2.cpp -CTRTextureLightMap2_Add.cpp -CTRTextureLightMap2_M1.cpp -CTRTextureLightMap2_M2.cpp -CTRTextureLightMap2_M4.cpp -CTRTextureLightMapGouraud2_M4.cpp -CTRTextureWire2.cpp -IBurningShader.cpp -IBurningShader.h -IDepthBuffer.h -S4DVertex.h -SoftwareDriver2_compile_config.h -SoftwareDriver2_helper.h -CDefaultSceneNodeAnimatorFactory.cpp -CDefaultSceneNodeAnimatorFactory.h -CDefaultSceneNodeFactory.cpp -CDefaultSceneNodeFactory.h -CGeometryCreator.cpp -CGeometryCreator.h -CMeshCache.cpp -CMeshCache.h -CMeshManipulator.cpp -CMeshManipulator.h -CSceneManager.cpp -CSceneManager.h -OctTree.h -C3DSMeshFileLoader.cpp -C3DSMeshFileLoader.h -CAnimatedMeshMD2.cpp -CAnimatedMeshMD2.h -CAnimatedMeshMD3.cpp -CAnimatedMeshMD3.h -CB3DMeshFileLoader.cpp -CB3DMeshFileLoader.h -CBSPMeshFileLoader.cpp -CBSPMeshFileLoader.h -CColladaFileLoader.cpp -CColladaFileLoader.h -CCSMLoader.cpp -CCSMLoader.h -CDMFLoader.cpp -CDMFLoader.h -CIrrMeshFileLoader.cpp -CIrrMeshFileLoader.h -CLMTSMeshFileLoader.cpp -CLMTSMeshFileLoader.h -CMD2MeshFileLoader.cpp -CMD2MeshFileLoader.h -CMD3MeshFileLoader.cpp -CMD3MeshFileLoader.h -CMS3DMeshFileLoader.cpp -CMS3DMeshFileLoader.h -CMY3DHelper.h -CMY3DMeshFileLoader.cpp -CMY3DMeshFileLoader.h -COBJMeshFileLoader.cpp -COBJMeshFileLoader.h -COCTLoader.cpp -COCTLoader.h -COgreMeshFileLoader.cpp -COgreMeshFileLoader.h -CQ3LevelMesh.cpp -CQ3LevelMesh.h -CSkinnedMesh.cpp -CSkinnedMesh.h -CSTLMeshFileLoader.cpp -CSTLMeshFileLoader.h -CXMeshFileLoader.cpp -CXMeshFileLoader.h -dmfsupport.h -CAnimatedMeshSceneNode.cpp -CAnimatedMeshSceneNode.h -CBillboardSceneNode.cpp -CBillboardSceneNode.h -CBlit.h -CBoneSceneNode.cpp -CBoneSceneNode.h -CCameraSceneNode.cpp -CCameraSceneNode.h -CCubeSceneNode.cpp -CCubeSceneNode.h -CDummyTransformationSceneNode.cpp -CDummyTransformationSceneNode.h -CEmptySceneNode.cpp -CEmptySceneNode.h -CIrrDeviceConsole.cpp -CIrrDeviceConsole.h -CLightSceneNode.cpp -CLightSceneNode.h -CMeshSceneNode.cpp -CMeshSceneNode.h -COctTreeSceneNode.cpp -COctTreeSceneNode.h -CQuake3ShaderSceneNode.cpp -CQuake3ShaderSceneNode.h -CShadowVolumeSceneNode.cpp -CShadowVolumeSceneNode.h -CSkyBoxSceneNode.cpp -CSkyBoxSceneNode.h -CSkyDomeSceneNode.cpp -CSkyDomeSceneNode.h -CSphereSceneNode.cpp -CSphereSceneNode.h -CTerrainSceneNode.cpp -CTerrainSceneNode.h -CTextSceneNode.cpp -CTextSceneNode.h -CWaterSurfaceSceneNode.cpp -CWaterSurfaceSceneNode.h -CParticleAnimatedMeshSceneNodeEmitter.cpp -CParticleAttractionAffector.cpp -CParticleBoxEmitter.cpp -CParticleBoxEmitter.h -CParticleCylinderEmitter.cpp -CParticleFadeOutAffector.cpp -CParticleFadeOutAffector.h -CParticleGravityAffector.cpp -CParticleGravityAffector.h -CParticleMeshEmitter.cpp -CParticlePointEmitter.cpp -CParticlePointEmitter.h -CParticleRingEmitter.cpp -CParticleRotationAffector.cpp -CParticleSphereEmitter.cpp -CParticleSystemSceneNode.cpp -CParticleSystemSceneNode.h -CPLYMeshWriter.cpp -CPLYMeshWriter.h -CMetaTriangleSelector.cpp -CMetaTriangleSelector.h -CMountPointReader.cpp -CMountPointReader.h -CPLYMeshFileLoader.cpp -CPLYMeshFileLoader.h -COctTreeTriangleSelector.cpp -COctTreeTriangleSelector.h -CSceneCollisionManager.cpp -CSceneCollisionManager.h -CTarReader.cpp -CTarReader.h -CTerrainTriangleSelector.cpp -CTerrainTriangleSelector.h -CTriangleBBSelector.cpp -CTriangleBBSelector.h -CTriangleSelector.cpp -CTriangleSelector.h -CSceneNodeAnimatorCollisionResponse.cpp -CSceneNodeAnimatorCollisionResponse.h -CSceneNodeAnimatorDelete.cpp -CSceneNodeAnimatorDelete.h -CSceneNodeAnimatorFlyCircle.cpp -CSceneNodeAnimatorFlyCircle.h -CSceneNodeAnimatorFlyStraight.cpp -CSceneNodeAnimatorFlyStraight.h -CSceneNodeAnimatorFollowSpline.cpp -CSceneNodeAnimatorFollowSpline.h -CSceneNodeAnimatorRotation.cpp -CSceneNodeAnimatorRotation.h -CSceneNodeAnimatorTexture.cpp -CSceneNodeAnimatorTexture.h -CColladaMeshWriter.cpp -CColladaMeshWriter.h -CIrrMeshWriter.cpp -CIrrMeshWriter.h -CSTLMeshWriter.cpp -CSTLMeshWriter.h -CAttributeImpl.h -CAttributes.cpp -CAttributes.h -CFileList.cpp -CFileList.h -CFileSystem.cpp -CFileSystem.h -CLimitReadFile.cpp -CLimitReadFile.h -CMemoryFile.cpp -CMemoryFile.h -CPakReader.cpp -CPakReader.h -CReadFile.cpp -CReadFile.h -CWriteFile.cpp -CWriteFile.h -CXMLReader.cpp -CXMLReader.h -CXMLReaderImpl.h -CXMLWriter.cpp -CXMLWriter.h -CZipReader.cpp -CZipReader.h -irrXML.cpp -CIrrDeviceLinux.cpp -CIrrDeviceLinux.h -CIrrDeviceSDL.cpp -CIrrDeviceSDL.h -CIrrDeviceStub.cpp -CIrrDeviceStub.h -CIrrDeviceWin32.cpp -CIrrDeviceWin32.h -CLogger.cpp -CLogger.h -COSOperator.cpp -COSOperator.h -CTimer.h -Irrlicht.cpp -os.cpp -os.h -CBurningShader_Raster_Reference.cpp -CGUITable.cpp -CGUITreeView.cpp -CGUITreeView.h -CGUIImageList.cpp -CGUIImageList.h -CImageLoaderWAL.cpp -CIrrDeviceWinCE.cpp -CLWOMeshFileLoader.cpp -COBJMeshWriter.cpp -CParticleScaleAffector.cpp -CSceneNodeAnimatorCameraFPS.cpp -CSceneNodeAnimatorCameraMaya.cpp -CVolumeLightSceneNode.cpp -CGUITable.h -CImageLoaderWAL.h -CIrrDeviceWinCE.h -CLWOMeshFileLoader.h -COBJMeshWriter.h -CParticleScaleAffector.h -CSceneNodeAnimatorCameraFPS.h -CSceneNodeAnimatorCameraMaya.h -CVolumeLightSceneNode.h -wglext.h -) - -SET(zlib_SRCS -zlib/adler32.c -zlib/compress.c -zlib/crc32.c -zlib/crc32.h -zlib/deflate.c -zlib/deflate.h -zlib/inffast.c -zlib/inffast.h -zlib/inffixed.h -zlib/inflate.c -zlib/inftrees.c -zlib/inftrees.h -zlib/trees.c -zlib/trees.h -zlib/uncompr.c -zlib/zconf.h -zlib/zlib.h -zlib/zutil.c -zlib/zutil.h -) - -SET(jpeg_SRCS -jpeglib/cderror.h -jpeglib/cdjpeg.c -jpeglib/cdjpeg.h -jpeglib/jcapimin.c -jpeglib/jcapistd.c -jpeglib/jccoefct.c -jpeglib/jccolor.c -jpeglib/jcdctmgr.c -jpeglib/jchuff.c -jpeglib/jchuff.h -jpeglib/jcinit.c -jpeglib/jcmainct.c -jpeglib/jcmarker.c -jpeglib/jcmaster.c -jpeglib/jcomapi.c -jpeglib/jconfig.h -jpeglib/jcparam.c -jpeglib/jcphuff.c -jpeglib/jcprepct.c -jpeglib/jcsample.c -jpeglib/jctrans.c -jpeglib/jdapimin.c -jpeglib/jdapistd.c -jpeglib/jdatadst.c -jpeglib/jdatasrc.c -jpeglib/jdcoefct.c -jpeglib/jdcolor.c -jpeglib/jdct.h -jpeglib/jddctmgr.c -jpeglib/jdhuff.c -jpeglib/jdhuff.h -jpeglib/jdinput.c -jpeglib/jdmainct.c -jpeglib/jdmarker.c -jpeglib/jdmaster.c -jpeglib/jdmerge.c -jpeglib/jdphuff.c -jpeglib/jdpostct.c -jpeglib/jdsample.c -jpeglib/jdtrans.c -jpeglib/jerror.c -jpeglib/jerror.h -jpeglib/jfdctflt.c -jpeglib/jfdctfst.c -jpeglib/jfdctint.c -jpeglib/jidctflt.c -jpeglib/jidctfst.c -jpeglib/jidctint.c -jpeglib/jidctred.c -jpeglib/jinclude.h -jpeglib/jmemmgr.c -jpeglib/jmemnobs.c -jpeglib/jmemsys.h -jpeglib/jmorecfg.h -jpeglib/jpegint.h -jpeglib/jpeglib.h -jpeglib/jquant1.c -jpeglib/jquant2.c -jpeglib/jutils.c -jpeglib/jversion.h -) -IF (APPLE) -SET(libpng_SRCS -libpng_osx/png.c -libpng_osx/png.h -libpng_osx/pngconf.h -libpng_osx/pngerror.c -libpng_osx/pngget.c -libpng_osx/pngmem.c -libpng_osx/pngpread.c -libpng_osx/pngread.c -libpng_osx/pngrio.c -libpng_osx/pngrtran.c -libpng_osx/pngrutil.c -libpng_osx/pngset.c -libpng_osx/pngtrans.c -libpng_osx/pngwio.c -libpng_osx/pngwrite.c -libpng_osx/pngwtran.c -libpng_osx/pngwutil.c -) -ELSE (APPLE) -SET(libpng_SRCS -libpng/png.c -libpng/png.h -libpng/pngconf.h -libpng/pngerror.c -libpng/pngget.c -libpng/pngmem.c -libpng/pngpread.c -libpng/pngread.c -libpng/pngrio.c -libpng/pngrtran.c -libpng/pngrutil.c -libpng/pngset.c -libpng/pngtrans.c -libpng/pngwio.c -libpng/pngwrite.c -libpng/pngwtran.c -libpng/pngwutil.c -) - -ENDIF (APPLE) - - - -IF (APPLE) -ADD_LIBRARY(Irrlicht MacOSX/CIrrDeviceMacOSX.mm MacOSX/OSXClipboard.mm MacOSX/AppDelegate.mm ${Irrlicht_SRCS} ${jpeg_SRCS} ${libpng_SRCS} ${zlib_SRCS} ) -ELSE (APPLE) -ADD_LIBRARY(Irrlicht ${Irrlicht_SRCS} ${jpeg_SRCS} ${libpng_SRCS} ${zlib_SRCS} ) -ENDIF (APPLE) - diff --git a/irrlicht-1.6/source/Irrlicht/CMemoryFile.cpp b/irrlicht-1.6/source/Irrlicht/CMemoryFile.cpp deleted file mode 100644 index 0196d301d..000000000 --- a/irrlicht-1.6/source/Irrlicht/CMemoryFile.cpp +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright (C) 2002-2008 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CMemoryFile.h" -#include "irrString.h" - -namespace irr -{ -namespace io -{ - - -CMemoryFile::CMemoryFile(void* memory, long len, const io::path& fileName, bool d) -: Buffer(memory), Len(len), Pos(0), Filename(fileName), deleteMemoryWhenDropped(d) -{ - #ifdef _DEBUG - setDebugName("CMemoryFile"); - #endif -} - - -CMemoryFile::~CMemoryFile() -{ - if (deleteMemoryWhenDropped) - delete [] (c8*)Buffer; -} - - -//! returns how much was read -s32 CMemoryFile::read(void* buffer, u32 sizeToRead) -{ - s32 amount = static_cast<s32>(sizeToRead); - if (Pos + amount > Len) - amount -= Pos + amount - Len; - - if (amount <= 0) - return 0; - - c8* p = (c8*)Buffer; - memcpy(buffer, p + Pos, amount); - - Pos += amount; - - return amount; -} - -//! returns how much was written -s32 CMemoryFile::write(const void* buffer, u32 sizeToWrite) -{ - s32 amount = static_cast<s32>(sizeToWrite); - if (Pos + amount > Len) - amount -= Pos + amount - Len; - - if (amount <= 0) - return 0; - - c8* p = (c8*)Buffer; - memcpy(p + Pos, buffer, amount); - - Pos += amount; - - return amount; -} - - - -//! changes position in file, returns true if successful -//! if relativeMovement==true, the pos is changed relative to current pos, -//! otherwise from begin of file -bool CMemoryFile::seek(long finalPos, bool relativeMovement) -{ - if (relativeMovement) - { - if (Pos + finalPos > Len) - return false; - - Pos += finalPos; - } - else - { - if (finalPos > Len) - return false; - - Pos = finalPos; - } - - return true; -} - - -//! returns size of file -long CMemoryFile::getSize() const -{ - return Len; -} - - -//! returns where in the file we are. -long CMemoryFile::getPos() const -{ - return Pos; -} - - -//! returns name of file -const io::path& CMemoryFile::getFileName() const -{ - return Filename; -} - - -IReadFile* createMemoryReadFile(void* memory, long size, const io::path& fileName, bool deleteMemoryWhenDropped) -{ - CMemoryFile* file = new CMemoryFile(memory, size, fileName, deleteMemoryWhenDropped); - return file; -} - - -} // end namespace io -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CMemoryFile.h b/irrlicht-1.6/source/Irrlicht/CMemoryFile.h deleted file mode 100644 index 91098ab59..000000000 --- a/irrlicht-1.6/source/Irrlicht/CMemoryFile.h +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (C) 2002-2008 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_MEMORY_READ_FILE_H_INCLUDED__ -#define __C_MEMORY_READ_FILE_H_INCLUDED__ - -#include "IReadFile.h" -#include "IWriteFile.h" -#include "irrString.h" - -namespace irr -{ - -namespace io -{ - - /*! - Class for reading and writing from memory. - */ - class CMemoryFile : public IReadFile, public IWriteFile - { - public: - - //! Constructor - CMemoryFile(void* memory, long len, const io::path& fileName, bool deleteMemoryWhenDropped); - - //! Destructor - virtual ~CMemoryFile(); - - //! returns how much was read - virtual s32 read(void* buffer, u32 sizeToRead); - - //! returns how much was written - virtual s32 write(const void* buffer, u32 sizeToWrite); - - //! changes position in file, returns true if successful - virtual bool seek(long finalPos, bool relativeMovement = false); - - //! returns size of file - virtual long getSize() const; - - //! returns where in the file we are. - virtual long getPos() const; - - //! returns name of file - virtual const io::path& getFileName() const; - - private: - - void *Buffer; - long Len; - long Pos; - io::path Filename; - bool deleteMemoryWhenDropped; - }; - -} // end namespace io -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CMeshCache.cpp b/irrlicht-1.6/source/Irrlicht/CMeshCache.cpp deleted file mode 100644 index fca2d5dc9..000000000 --- a/irrlicht-1.6/source/Irrlicht/CMeshCache.cpp +++ /dev/null @@ -1,245 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CMeshCache.h" -#include "IAnimatedMesh.h" -#include "IMesh.h" - -namespace irr -{ -namespace scene -{ - -static const io::path emptyPath = ""; - - -CMeshCache::~CMeshCache() -{ - clear(); -} - - -//! adds a mesh to the list -void CMeshCache::addMesh(const io::path& filename, IAnimatedMesh* mesh) -{ - mesh->grab(); - - MeshEntry e ( filename ); - e.Mesh = mesh; - - Meshes.push_back(e); -} - - -//! Removes a mesh from the cache. -void CMeshCache::removeMesh(const IAnimatedMesh* const mesh) -{ - if ( !mesh ) - return; - for (u32 i=0; i<Meshes.size(); ++i) - { - if (Meshes[i].Mesh == mesh) - { - Meshes[i].Mesh->drop(); - Meshes.erase(i); - return; - } - } -} - - -//! Removes a mesh from the cache. -void CMeshCache::removeMesh(const IMesh* const mesh) -{ - if ( !mesh ) - return; - for (u32 i=0; i<Meshes.size(); ++i) - { - if (Meshes[i].Mesh && Meshes[i].Mesh->getMesh(0) == mesh) - { - Meshes[i].Mesh->drop(); - Meshes.erase(i); - return; - } - } -} - - -//! Returns amount of loaded meshes -u32 CMeshCache::getMeshCount() const -{ - return Meshes.size(); -} - - -//! Returns current number of the mesh -s32 CMeshCache::getMeshIndex(const IAnimatedMesh* const mesh) const -{ - for (u32 i=0; i<Meshes.size(); ++i) - if (Meshes[i].Mesh == mesh) - return (s32)i; - - return -1; -} - - - -//! Returns current index number of the mesh, and -1 if it is not in the cache. -s32 CMeshCache::getMeshIndex(const IMesh* const mesh) const -{ - for (u32 i=0; i<Meshes.size(); ++i) - { - if (Meshes[i].Mesh && Meshes[i].Mesh->getMesh(0) == mesh) - return (s32)i; - } - - return -1; -} - - -//! Returns a mesh based on its index number -IAnimatedMesh* CMeshCache::getMeshByIndex(u32 number) -{ - if (number >= Meshes.size()) - return 0; - - return Meshes[number].Mesh; -} - - -//! Returns a mesh based on its file name. -IAnimatedMesh* CMeshCache::getMeshByFilename(const io::path& filename) -{ - MeshEntry e ( filename ); - s32 id = Meshes.binary_search(e); - return (id != -1) ? Meshes[id].Mesh : 0; -} - - -//! Returns name of a mesh based on its index number -const io::path& CMeshCache::getMeshFilename(u32 number) const -{ - if (number >= Meshes.size()) - return emptyPath; - - return Meshes[number].Name; -} - - - -//! Returns the filename of a loaded mesh, if there is any. -const io::path& CMeshCache::getMeshFilename(const IAnimatedMesh* const mesh) const -{ - if(!mesh) - return emptyPath; - - for (u32 i=0; i<Meshes.size(); ++i) - { - if (Meshes[i].Mesh == mesh) - return Meshes[i].Name; - } - - return emptyPath; -} - - -//! Returns the filename of a loaded mesh, if there is any. Returns 0 if there is none. -const io::path& CMeshCache::getMeshFilename(const IMesh* const mesh) const -{ - if (!mesh) - return emptyPath; - - for (u32 i=0; i<Meshes.size(); ++i) - { - // IMesh may actually be an IAnimatedMesh, so do a direct comparison - // as well as getting an IMesh from our stored IAnimatedMeshes - if (Meshes[i].Mesh && (Meshes[i].Mesh == mesh || Meshes[i].Mesh->getMesh(0) == mesh)) - return Meshes[i].Name; - } - - return emptyPath; -} - - - -//! Renames a loaded mesh, if possible. -bool CMeshCache::setMeshFilename(u32 index, const io::path& filename) -{ - if (index >= Meshes.size()) - return false; - - Meshes[index].Name = filename; - Meshes.sort(); - return true; -} - - -//! Renames a loaded mesh, if possible. -bool CMeshCache::setMeshFilename(const IAnimatedMesh* const mesh, const io::path& filename) -{ - for (u32 i=0; i<Meshes.size(); ++i) - { - if (Meshes[i].Mesh == mesh) - { - Meshes[i].Name = filename; - Meshes.sort(); - return true; - } - } - - return false; -} - - -//! Renames a loaded mesh, if possible. -bool CMeshCache::setMeshFilename(const IMesh* const mesh, const io::path& filename) -{ - for (u32 i=0; i<Meshes.size(); ++i) - { - if (Meshes[i].Mesh && Meshes[i].Mesh->getMesh(0) == mesh) - { - Meshes[i].Name = filename; - Meshes.sort(); - return true; - } - } - - return false; -} - - -//! returns if a mesh already was loaded -bool CMeshCache::isMeshLoaded(const io::path& filename) -{ - return getMeshByFilename(filename) != 0; -} - - -//! Clears the whole mesh cache, removing all meshes. -void CMeshCache::clear() -{ - for (u32 i=0; i<Meshes.size(); ++i) - Meshes[i].Mesh->drop(); - - Meshes.clear(); -} - -//! Clears all meshes that are held in the mesh cache but not used anywhere else. -void CMeshCache::clearUnusedMeshes() -{ - for (u32 i=0; i<Meshes.size(); ++i) - { - if (Meshes[i].Mesh->getReferenceCount() == 1) - { - Meshes[i].Mesh->drop(); - Meshes.erase(i); - --i; - } - } -} - - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CMeshCache.h b/irrlicht-1.6/source/Irrlicht/CMeshCache.h deleted file mode 100644 index f95ccbbee..000000000 --- a/irrlicht-1.6/source/Irrlicht/CMeshCache.h +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_MESH_CACHE_H_INCLUDED__ -#define __C_MESH_CACHE_H_INCLUDED__ - -#include "IMeshCache.h" -#include "irrArray.h" - -namespace irr -{ - -namespace scene -{ - class CMeshCache : public IMeshCache - { - public: - - virtual ~CMeshCache(); - - //! Adds a mesh to the internal list of loaded meshes. - /** Usually, ISceneManager::getMesh() is called to load a mesh from file. - That method searches the list of loaded meshes if a mesh has already been loaded and - returns a pointer to if it is in that list and already in memory. Otherwise it loads - the mesh. With IMeshCache::addMesh(), it is possible to pretend that a mesh already - has been loaded. This method can be used for example by mesh loaders who need to - load more than one mesh with one call. They can add additional meshes with this - method to the scene manager. The COLLADA loader for example uses this method. - \param filename: Filename of the mesh. When called ISceneManager::getMesh() with this - parameter, the method will return the mesh parameter given with this method. - \param mesh: Pointer to a mesh which will now be referenced by this name. */ - virtual void addMesh(const io::path& filename, IAnimatedMesh* mesh); - - //! Removes a mesh from the cache. - /** After loading a mesh with getMesh(), the mesh can be removed from the cache - using this method, freeing a lot of memory. */ - virtual void removeMesh(const IAnimatedMesh* const mesh); - - //! Removes a mesh from the cache. - /** After loading a mesh with getMesh(), the mesh can be removed from the cache - using this method, freeing a lot of memory. */ - virtual void removeMesh(const IMesh* const mesh); - - //! Returns amount of loaded meshes in the cache. - /** You can load new meshes into the cache using getMesh() and addMesh(). - If you ever need to access the internal mesh cache, you can do this using - removeMesh(), getMeshNumber(), getMeshByIndex() and getMeshFilename() */ - virtual u32 getMeshCount() const; - - //! Returns current index number of the mesh, and -1 if it is not in the cache. - virtual s32 getMeshIndex(const IAnimatedMesh* const mesh) const; - - //! Returns current index number of the mesh, and -1 if it is not in the cache. - virtual s32 getMeshIndex(const IMesh* const mesh) const; - - //! Returns a mesh based on its index number. - /** \param index: Index of the mesh, number between 0 and getMeshCount()-1. - Note that this number is only valid until a new mesh is loaded or removed * - \return Returns pointer to the mesh or 0 if there is none with this number. */ - virtual IAnimatedMesh* getMeshByIndex(u32 index); - - //! Returns a mesh based on its file name. - /** \return Returns pointer to the mesh or 0 if there is none with this number. */ - virtual IAnimatedMesh* getMeshByFilename(const io::path& filename); - - //! Returns name of a mesh based on its index number. - /** \param index: Index of the mesh, number between 0 and getMeshCount()-1. - Note that this is only valid until a new mesh is loaded */ - virtual const io::path& getMeshFilename(u32 index) const; - - //! Returns the filename of a loaded mesh, if there is any. - /** Returns an empty path if there is none. */ - virtual const io::path& getMeshFilename(const IAnimatedMesh* const mesh) const; - - //! Returns the filename of a loaded mesh, if there is any. - /** Returns an empty path if there is none.*/ - virtual const io::path& getMeshFilename(const IMesh* const mesh) const; - - //! Renames a loaded mesh, if possible. - virtual bool setMeshFilename(u32 index, const io::path& filename); - - //! Renames a loaded mesh, if possible. - virtual bool setMeshFilename(const IAnimatedMesh* const mesh, const io::path& filename); - - //! Renames a loaded mesh, if possible. - virtual bool setMeshFilename(const IMesh* const mesh, const io::path& filename); - - //! returns if a mesh already was loaded - virtual bool isMeshLoaded(const io::path& filename); - - //! Clears the whole mesh cache, removing all meshes. - virtual void clear(); - - //! Clears all meshes that are held in the mesh cache but not used anywhere else. - virtual void clearUnusedMeshes(); - - protected: - - struct MeshEntry - { - MeshEntry ( const io::path name ) - : Name ( name ) - { - Name.make_lower (); - } - io::path Name; - IAnimatedMesh* Mesh; - - bool operator < (const MeshEntry& other) const - { - return (Name < other.Name); - } - }; - - //! loaded meshes - core::array<MeshEntry> Meshes; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CMeshManipulator.cpp b/irrlicht-1.6/source/Irrlicht/CMeshManipulator.cpp deleted file mode 100644 index e5e2794c1..000000000 --- a/irrlicht-1.6/source/Irrlicht/CMeshManipulator.cpp +++ /dev/null @@ -1,1301 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CMeshManipulator.h" -#include "SMesh.h" -#include "CMeshBuffer.h" -#include "SAnimatedMesh.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - -static inline core::vector3df getAngleWeight(const core::vector3df& v1, - const core::vector3df& v2, - const core::vector3df& v3) -{ - // Calculate this triangle's weight for each of its three vertices - // start by calculating the lengths of its sides - const f32 a = v2.getDistanceFromSQ(v3); - const f32 asqrt = sqrtf(a); - const f32 b = v1.getDistanceFromSQ(v3); - const f32 bsqrt = sqrtf(b); - const f32 c = v1.getDistanceFromSQ(v2); - const f32 csqrt = sqrtf(c); - - // use them to find the angle at each vertex - return core::vector3df( - acosf((b + c - a) / (2.f * bsqrt * csqrt)), - acosf((-b + c + a) / (2.f * asqrt * csqrt)), - acosf((b - c + a) / (2.f * bsqrt * asqrt))); -} - - -//! Flips the direction of surfaces. Changes backfacing triangles to frontfacing -//! triangles and vice versa. -//! \param mesh: Mesh on which the operation is performed. -void CMeshManipulator::flipSurfaces(scene::IMesh* mesh) const -{ - if (!mesh) - return; - - const u32 bcount = mesh->getMeshBufferCount(); - for (u32 b=0; b<bcount; ++b) - { - IMeshBuffer* buffer = mesh->getMeshBuffer(b); - const u32 idxcnt = buffer->getIndexCount(); - u16* idx = buffer->getIndices(); - s32 tmp; - - for (u32 i=0; i<idxcnt; i+=3) - { - tmp = idx[i+1]; - idx[i+1] = idx[i+2]; - idx[i+2] = tmp; - } - } -} - - -//! Sets the alpha vertex color value of the whole mesh to a new value -//! \param mesh: Mesh on which the operation is performed. -void CMeshManipulator::setVertexColorAlpha(scene::IMesh* mesh, s32 alpha) const -{ - if (!mesh) - return; - - u32 i; - - const u32 bcount = mesh->getMeshBufferCount(); - for ( u32 b=0; b<bcount; ++b) - { - IMeshBuffer* buffer = mesh->getMeshBuffer(b); - void* v = buffer->getVertices(); - u32 vtxcnt = buffer->getVertexCount(); - - switch(buffer->getVertexType()) - { - case video::EVT_STANDARD: - { - for ( i=0; i<vtxcnt; ++i) - ((video::S3DVertex*)v)[i].Color.setAlpha(alpha); - } - break; - case video::EVT_2TCOORDS: - { - for ( i=0; i<vtxcnt; ++i) - ((video::S3DVertex2TCoords*)v)[i].Color.setAlpha(alpha); - } - break; - case video::EVT_TANGENTS: - { - for ( i=0; i<vtxcnt; ++i) - ((video::S3DVertexTangents*)v)[i].Color.setAlpha(alpha); - } - break; - } - } -} - - -//! Sets the colors of all vertices to one color -void CMeshManipulator::setVertexColors(IMesh* mesh, video::SColor color) const -{ - if (!mesh) - return; - - const u32 bcount = mesh->getMeshBufferCount(); - for (u32 b=0; b<bcount; ++b) - { - IMeshBuffer* buffer = mesh->getMeshBuffer(b); - void* v = buffer->getVertices(); - const u32 vtxcnt = buffer->getVertexCount(); - u32 i; - - switch(buffer->getVertexType()) - { - case video::EVT_STANDARD: - { - for ( i=0; i<vtxcnt; ++i) - ((video::S3DVertex*)v)[i].Color = color; - } - break; - case video::EVT_2TCOORDS: - { - for ( i=0; i<vtxcnt; ++i) - ((video::S3DVertex2TCoords*)v)[i].Color = color; - } - break; - case video::EVT_TANGENTS: - { - for ( i=0; i<vtxcnt; ++i) - ((video::S3DVertexTangents*)v)[i].Color = color; - } - break; - } - } -} - - -//! Recalculates all normals of the mesh buffer. -/** \param buffer: Mesh buffer on which the operation is performed. */ -void CMeshManipulator::recalculateNormals(IMeshBuffer* buffer, bool smooth, bool angleWeighted) const -{ - if (!buffer) - return; - - const u32 vtxcnt = buffer->getVertexCount(); - const u32 idxcnt = buffer->getIndexCount(); - const u16* idx = buffer->getIndices(); - - if (!smooth) - { - for (u32 i=0; i<idxcnt; i+=3) - { - const core::vector3df& v1 = buffer->getPosition(idx[i+0]); - const core::vector3df& v2 = buffer->getPosition(idx[i+1]); - const core::vector3df& v3 = buffer->getPosition(idx[i+2]); - const core::vector3df normal = core::plane3d<f32>(v1, v2, v3).Normal; - buffer->getNormal(idx[i+0]) = normal; - buffer->getNormal(idx[i+1]) = normal; - buffer->getNormal(idx[i+2]) = normal; - } - } - else - { - u32 i; - - for ( i = 0; i!= vtxcnt; ++i ) - buffer->getNormal(i).set( 0.f, 0.f, 0.f ); - - for ( i=0; i<idxcnt; i+=3) - { - const core::vector3df& v1 = buffer->getPosition(idx[i+0]); - const core::vector3df& v2 = buffer->getPosition(idx[i+1]); - const core::vector3df& v3 = buffer->getPosition(idx[i+2]); - core::vector3df normal = core::plane3d<f32>(v1, v2, v3).Normal; - - if (angleWeighted) - normal *= getAngleWeight(v1,v2,v3); - - buffer->getNormal(idx[i+0]) += normal; - buffer->getNormal(idx[i+1]) += normal; - buffer->getNormal(idx[i+2]) += normal; - } - - for ( i = 0; i!= vtxcnt; ++i ) - buffer->getNormal(i).normalize(); - } -} - - -//! Recalculates all normals of the mesh. -//! \param mesh: Mesh on which the operation is performed. -void CMeshManipulator::recalculateNormals(scene::IMesh* mesh, bool smooth, bool angleWeighted) const -{ - if (!mesh) - return; - - const u32 bcount = mesh->getMeshBufferCount(); - for ( u32 b=0; b<bcount; ++b) - recalculateNormals(mesh->getMeshBuffer(b), smooth, angleWeighted); -} - - -//! Applies a transformation -/** \param buffer: Meshbuffer on which the operation is performed. - \param m: matrix. */ -void CMeshManipulator::transform(scene::IMeshBuffer* buffer, const core::matrix4& m) const -{ - const u32 vtxcnt = buffer->getVertexCount(); - if (!vtxcnt) - return; - - core::aabbox3df bufferbox; - // first transform - { - m.transformVect(buffer->getPosition(0)); - m.rotateVect(buffer->getNormal(0)); - buffer->getNormal(0).normalize(); - - bufferbox.reset(buffer->getPosition(0)); - } - - for ( u32 i=1 ;i < vtxcnt; ++i) - { - m.transformVect(buffer->getPosition(i)); - m.rotateVect(buffer->getNormal(i)); - buffer->getNormal(i).normalize(); - - bufferbox.addInternalPoint(buffer->getPosition(i)); - } - - buffer->setBoundingBox(bufferbox); -} - - -//! Applies a transformation -/** \param mesh: Mesh on which the operation is performed. - \param m: matrix. */ -void CMeshManipulator::transform(scene::IMesh* mesh, const core::matrix4& m) const -{ - if (!mesh) - return; - - core::aabbox3df meshbox; - - const u32 bcount = mesh->getMeshBufferCount(); - for ( u32 b=0; b<bcount; ++b) - { - IMeshBuffer* buffer = mesh->getMeshBuffer(b); - transform(buffer, m); - - if (b == 0) - meshbox.reset(buffer->getBoundingBox()); - else - meshbox.addInternalBox(buffer->getBoundingBox()); - } - - mesh->setBoundingBox( meshbox ); -} - - -//! Scales the actual mesh, not a scene node. -void CMeshManipulator::scale(scene::IMesh* mesh, const core::vector3df& factor) const -{ - if (!mesh) - return; - - core::aabbox3df meshbox; - - const u32 bcount = mesh->getMeshBufferCount(); - for ( u32 b=0; b<bcount; ++b) - { - IMeshBuffer* buffer = mesh->getMeshBuffer(b); - scale(buffer, factor); - - if (b == 0) - meshbox.reset(buffer->getBoundingBox()); - else - meshbox.addInternalBox(buffer->getBoundingBox()); - } - - mesh->setBoundingBox( meshbox ); -} - - -//! Scales the actual meshbuffer, not a scene node. -void CMeshManipulator::scale(scene::IMeshBuffer* buffer, const core::vector3df& factor) const -{ - if (!buffer) - return; - - const u32 vtxcnt = buffer->getVertexCount(); - core::aabbox3df bufferbox; - - if (vtxcnt != 0) - bufferbox.reset(buffer->getPosition(0) * factor); - - for (u32 i=0; i<vtxcnt; ++i) - { - buffer->getPosition(i) *= factor; - bufferbox.addInternalPoint(buffer->getPosition(i)); - } - - buffer->setBoundingBox(bufferbox); -} - - -//! Scale the texture coords of a mesh. -void CMeshManipulator::scaleTCoords(scene::IMesh* mesh, const core::vector2df& factor, u32 layer) const -{ - if (!mesh) - return; - - const u32 bcount = mesh->getMeshBufferCount(); - for (u32 b=0; b<bcount; ++b) - scaleTCoords(mesh->getMeshBuffer(b), factor, layer); -} - - -//! Scale the level-th texture coords of a meshbuffer. -void CMeshManipulator::scaleTCoords(scene::IMeshBuffer* buffer, const core::vector2df& factor, u32 level) const -{ - if (!buffer || ((level>1) && (buffer->getVertexType() != video::EVT_2TCOORDS))) - return; - - const u32 vtxcnt = buffer->getVertexCount(); - - if (level==1) - { - for (u32 i=0; i<vtxcnt; ++i) - buffer->getTCoords(i) *= factor; - } - else - { - for (u32 i=0; i<vtxcnt; ++i) - ((SMeshBufferLightMap*)buffer)->Vertices[i].TCoords2 *= factor; - } -} - - -//! Clones a static IMesh into a modifyable SMesh. -SMesh* CMeshManipulator::createMeshCopy(scene::IMesh* mesh) const -{ - if (!mesh) - return 0; - - SMesh* clone = new SMesh(); - - const u32 meshBufferCount = mesh->getMeshBufferCount(); - - for ( u32 b=0; b<meshBufferCount; ++b) - { - switch(mesh->getMeshBuffer(b)->getVertexType()) - { - case video::EVT_STANDARD: - { - SMeshBuffer* buffer = new SMeshBuffer(); - const u32 vcount = mesh->getMeshBuffer(b)->getVertexCount(); - buffer->Vertices.reallocate(vcount); - video::S3DVertex* vertices = (video::S3DVertex*)mesh->getMeshBuffer(b)->getVertices(); - for (u32 i=0; i < vcount; ++i) - buffer->Vertices.push_back(vertices[i]); - const u32 icount = mesh->getMeshBuffer(b)->getIndexCount(); - buffer->Indices.reallocate(icount); - u16* indices = mesh->getMeshBuffer(b)->getIndices(); - for (u32 i=0; i < icount; ++i) - buffer->Indices.push_back(indices[i]); - clone->addMeshBuffer(buffer); - buffer->drop(); - } - break; - case video::EVT_2TCOORDS: - { - SMeshBufferLightMap* buffer = new SMeshBufferLightMap(); - const u32 vcount = mesh->getMeshBuffer(b)->getVertexCount(); - buffer->Vertices.reallocate(vcount); - video::S3DVertex2TCoords* vertices = (video::S3DVertex2TCoords*)mesh->getMeshBuffer(b)->getVertices(); - for (u32 i=0; i < vcount; ++i) - buffer->Vertices.push_back(vertices[i]); - const u32 icount = mesh->getMeshBuffer(b)->getIndexCount(); - buffer->Indices.reallocate(icount); - u16* indices = mesh->getMeshBuffer(b)->getIndices(); - for (u32 i=0; i < icount; ++i) - buffer->Indices.push_back(indices[i]); - clone->addMeshBuffer(buffer); - buffer->drop(); - } - break; - case video::EVT_TANGENTS: - { - SMeshBufferTangents* buffer = new SMeshBufferTangents(); - const u32 vcount = mesh->getMeshBuffer(b)->getVertexCount(); - buffer->Vertices.reallocate(vcount); - video::S3DVertexTangents* vertices = (video::S3DVertexTangents*)mesh->getMeshBuffer(b)->getVertices(); - for (u32 i=0; i < vcount; ++i) - buffer->Vertices.push_back(vertices[i]); - const u32 icount = mesh->getMeshBuffer(b)->getIndexCount(); - buffer->Indices.reallocate(icount); - u16* indices = mesh->getMeshBuffer(b)->getIndices(); - for (u32 i=0; i < icount; ++i) - buffer->Indices.push_back(indices[i]); - clone->addMeshBuffer(buffer); - buffer->drop(); - } - break; - }// end switch - - }// end for all mesh buffers - - clone->BoundingBox = mesh->getBoundingBox(); - return clone; -} - - -//! Creates a planar texture mapping on the mesh -void CMeshManipulator::makePlanarTextureMapping(scene::IMesh* mesh, f32 resolution=0.01f) const -{ - if (!mesh) - return; - - const u32 bcount = mesh->getMeshBufferCount(); - for ( u32 b=0; b<bcount; ++b) - { - makePlanarTextureMapping(mesh->getMeshBuffer(b), resolution); - } -} - - -//! Creates a planar texture mapping on the meshbuffer -void CMeshManipulator::makePlanarTextureMapping(scene::IMeshBuffer* buffer, f32 resolution) const -{ - u32 idxcnt = buffer->getIndexCount(); - u16* idx = buffer->getIndices(); - - for (u32 i=0; i<idxcnt; i+=3) - { - core::plane3df p(buffer->getPosition(idx[i+0]), buffer->getPosition(idx[i+1]), buffer->getPosition(idx[i+2])); - p.Normal.X = fabsf(p.Normal.X); - p.Normal.Y = fabsf(p.Normal.Y); - p.Normal.Z = fabsf(p.Normal.Z); - // calculate planar mapping worldspace coordinates - - if (p.Normal.X > p.Normal.Y && p.Normal.X > p.Normal.Z) - { - for (u32 o=0; o!=3; ++o) - { - buffer->getTCoords(idx[i+o]).X = buffer->getPosition(idx[i+o]).Y * resolution; - buffer->getTCoords(idx[i+o]).Y = buffer->getPosition(idx[i+o]).Z * resolution; - } - } - else - if (p.Normal.Y > p.Normal.X && p.Normal.Y > p.Normal.Z) - { - for (u32 o=0; o!=3; ++o) - { - buffer->getTCoords(idx[i+o]).X = buffer->getPosition(idx[i+o]).X * resolution; - buffer->getTCoords(idx[i+o]).Y = buffer->getPosition(idx[i+o]).Z * resolution; - } - } - else - { - for (u32 o=0; o!=3; ++o) - { - buffer->getTCoords(idx[i+o]).X = buffer->getPosition(idx[i+o]).X * resolution; - buffer->getTCoords(idx[i+o]).Y = buffer->getPosition(idx[i+o]).Y * resolution; - } - } - } -} - - -//! Creates a planar texture mapping on the meshbuffer -void CMeshManipulator::makePlanarTextureMapping(scene::IMeshBuffer* buffer, f32 resolutionS, f32 resolutionT, u8 axis, const core::vector3df& offset) const -{ - u32 idxcnt = buffer->getIndexCount(); - u16* idx = buffer->getIndices(); - - for (u32 i=0; i<idxcnt; i+=3) - { - // calculate planar mapping worldspace coordinates - if (axis==0) - { - for (u32 o=0; o!=3; ++o) - { - buffer->getTCoords(idx[i+o]).X = 0.5f+(buffer->getPosition(idx[i+o]).Z + offset.Z) * resolutionS; - buffer->getTCoords(idx[i+o]).Y = 0.5f-(buffer->getPosition(idx[i+o]).Y + offset.Y) * resolutionT; - } - } - else if (axis==1) - { - for (u32 o=0; o!=3; ++o) - { - buffer->getTCoords(idx[i+o]).X = 0.5f+(buffer->getPosition(idx[i+o]).X + offset.X) * resolutionS; - buffer->getTCoords(idx[i+o]).Y = 1.f-(buffer->getPosition(idx[i+o]).Z + offset.Z) * resolutionT; - } - } - else if (axis==2) - { - for (u32 o=0; o!=3; ++o) - { - buffer->getTCoords(idx[i+o]).X = 0.5f+(buffer->getPosition(idx[i+o]).X + offset.X) * resolutionS; - buffer->getTCoords(idx[i+o]).Y = 0.5f-(buffer->getPosition(idx[i+o]).Y + offset.Y) * resolutionT; - } - } - } -} - - -//! Creates a copy of the mesh, which will only consist of unique primitives -IMesh* CMeshManipulator::createMeshUniquePrimitives(IMesh* mesh) const -{ - if (!mesh) - return 0; - - SMesh* clone = new SMesh(); - - const u32 meshBufferCount = mesh->getMeshBufferCount(); - - for ( u32 b=0; b<meshBufferCount; ++b) - { - const s32 idxCnt = mesh->getMeshBuffer(b)->getIndexCount(); - const u16* idx = mesh->getMeshBuffer(b)->getIndices(); - - switch(mesh->getMeshBuffer(b)->getVertexType()) - { - case video::EVT_STANDARD: - { - SMeshBuffer* buffer = new SMeshBuffer(); - buffer->Material = mesh->getMeshBuffer(b)->getMaterial(); - - video::S3DVertex* v = - (video::S3DVertex*)mesh->getMeshBuffer(b)->getVertices(); - - buffer->Vertices.reallocate(idxCnt); - buffer->Indices.reallocate(idxCnt); - for (s32 i=0; i<idxCnt; i += 3) - { - buffer->Vertices.push_back( v[idx[i + 0 ]] ); - buffer->Vertices.push_back( v[idx[i + 1 ]] ); - buffer->Vertices.push_back( v[idx[i + 2 ]] ); - - buffer->Indices.push_back( i + 0 ); - buffer->Indices.push_back( i + 1 ); - buffer->Indices.push_back( i + 2 ); - } - - buffer->setBoundingBox(mesh->getMeshBuffer(b)->getBoundingBox()); - clone->addMeshBuffer(buffer); - buffer->drop(); - } - break; - case video::EVT_2TCOORDS: - { - SMeshBufferLightMap* buffer = new SMeshBufferLightMap(); - buffer->Material = mesh->getMeshBuffer(b)->getMaterial(); - - video::S3DVertex2TCoords* v = - (video::S3DVertex2TCoords*)mesh->getMeshBuffer(b)->getVertices(); - - buffer->Vertices.reallocate(idxCnt); - buffer->Indices.reallocate(idxCnt); - for (s32 i=0; i<idxCnt; i += 3) - { - buffer->Vertices.push_back( v[idx[i + 0 ]] ); - buffer->Vertices.push_back( v[idx[i + 1 ]] ); - buffer->Vertices.push_back( v[idx[i + 2 ]] ); - - buffer->Indices.push_back( i + 0 ); - buffer->Indices.push_back( i + 1 ); - buffer->Indices.push_back( i + 2 ); - } - buffer->setBoundingBox(mesh->getMeshBuffer(b)->getBoundingBox()); - clone->addMeshBuffer(buffer); - buffer->drop(); - } - break; - case video::EVT_TANGENTS: - { - SMeshBufferTangents* buffer = new SMeshBufferTangents(); - buffer->Material = mesh->getMeshBuffer(b)->getMaterial(); - - video::S3DVertexTangents* v = - (video::S3DVertexTangents*)mesh->getMeshBuffer(b)->getVertices(); - - buffer->Vertices.reallocate(idxCnt); - buffer->Indices.reallocate(idxCnt); - for (s32 i=0; i<idxCnt; i += 3) - { - buffer->Vertices.push_back( v[idx[i + 0 ]] ); - buffer->Vertices.push_back( v[idx[i + 1 ]] ); - buffer->Vertices.push_back( v[idx[i + 2 ]] ); - - buffer->Indices.push_back( i + 0 ); - buffer->Indices.push_back( i + 1 ); - buffer->Indices.push_back( i + 2 ); - } - - buffer->setBoundingBox(mesh->getMeshBuffer(b)->getBoundingBox()); - clone->addMeshBuffer(buffer); - buffer->drop(); - } - break; - }// end switch - - }// end for all mesh buffers - - clone->BoundingBox = mesh->getBoundingBox(); - return clone; -} - -//! Creates a copy of a mesh, which will have identical vertices welded together -IMesh* CMeshManipulator::createMeshWelded(IMesh *mesh, f32 tolerance) const -{ - SMesh* clone = new SMesh(); - clone->BoundingBox = mesh->getBoundingBox(); - - core::array<u16> redirects; - - for (u32 b=0; b<mesh->getMeshBufferCount(); ++b) - { - // reset redirect list - redirects.set_used(mesh->getMeshBuffer(b)->getVertexCount()); - - u16* indices = 0; - u32 indexCount = 0; - core::array<u16>* outIdx = 0; - - switch(mesh->getMeshBuffer(b)->getVertexType()) - { - case video::EVT_STANDARD: - { - SMeshBuffer* buffer = new SMeshBuffer(); - buffer->BoundingBox = mesh->getMeshBuffer(b)->getBoundingBox(); - buffer->Material = mesh->getMeshBuffer(b)->getMaterial(); - clone->addMeshBuffer(buffer); - buffer->drop(); - - video::S3DVertex* v = - (video::S3DVertex*)mesh->getMeshBuffer(b)->getVertices(); - - u32 vertexCount = mesh->getMeshBuffer(b)->getVertexCount(); - - indices = mesh->getMeshBuffer(b)->getIndices(); - indexCount = mesh->getMeshBuffer(b)->getIndexCount(); - outIdx = &buffer->Indices; - - buffer->Vertices.reallocate(vertexCount); - - for (u32 i=0; i < vertexCount; ++i) - { - bool found = false; - for (u32 j=0; j < i; ++j) - { - if ( v[i].Pos.equals( v[j].Pos, tolerance) && - v[i].Normal.equals( v[j].Normal, tolerance) && - v[i].TCoords.equals( v[j].TCoords ) && - (v[i].Color == v[j].Color) ) - { - redirects[i] = redirects[j]; - found = true; - break; - } - } - if (!found) - { - redirects[i] = buffer->Vertices.size(); - buffer->Vertices.push_back(v[i]); - } - } - - break; - } - case video::EVT_2TCOORDS: - { - SMeshBufferLightMap* buffer = new SMeshBufferLightMap(); - buffer->BoundingBox = mesh->getMeshBuffer(b)->getBoundingBox(); - buffer->Material = mesh->getMeshBuffer(b)->getMaterial(); - clone->addMeshBuffer(buffer); - buffer->drop(); - - video::S3DVertex2TCoords* v = - (video::S3DVertex2TCoords*)mesh->getMeshBuffer(b)->getVertices(); - - u32 vertexCount = mesh->getMeshBuffer(b)->getVertexCount(); - - indices = mesh->getMeshBuffer(b)->getIndices(); - indexCount = mesh->getMeshBuffer(b)->getIndexCount(); - outIdx = &buffer->Indices; - - buffer->Vertices.reallocate(vertexCount); - - for (u32 i=0; i < vertexCount; ++i) - { - bool found = false; - for (u32 j=0; j < i; ++j) - { - if ( v[i].Pos.equals( v[j].Pos, tolerance) && - v[i].Normal.equals( v[j].Normal, tolerance) && - v[i].TCoords.equals( v[j].TCoords ) && - v[i].TCoords2.equals( v[j].TCoords2 ) && - (v[i].Color == v[j].Color) ) - { - redirects[i] = redirects[j]; - found = true; - break; - } - } - if (!found) - { - redirects[i] = buffer->Vertices.size(); - buffer->Vertices.push_back(v[i]); - } - } - break; - } - case video::EVT_TANGENTS: - { - SMeshBufferTangents* buffer = new SMeshBufferTangents(); - buffer->BoundingBox = mesh->getMeshBuffer(b)->getBoundingBox(); - buffer->Material = mesh->getMeshBuffer(b)->getMaterial(); - clone->addMeshBuffer(buffer); - buffer->drop(); - - video::S3DVertexTangents* v = - (video::S3DVertexTangents*)mesh->getMeshBuffer(b)->getVertices(); - - u32 vertexCount = mesh->getMeshBuffer(b)->getVertexCount(); - - indices = mesh->getMeshBuffer(b)->getIndices(); - indexCount = mesh->getMeshBuffer(b)->getIndexCount(); - outIdx = &buffer->Indices; - - buffer->Vertices.reallocate(vertexCount); - - for (u32 i=0; i < vertexCount; ++i) - { - bool found = false; - for (u32 j=0; j < i; ++j) - { - if ( v[i].Pos.equals( v[j].Pos, tolerance) && - v[i].Normal.equals( v[j].Normal, tolerance) && - v[i].TCoords.equals( v[j].TCoords ) && - v[i].Tangent.equals( v[j].Tangent, tolerance ) && - v[i].Binormal.equals( v[j].Binormal, tolerance ) && - (v[i].Color == v[j].Color) ) - { - redirects[i] = redirects[j]; - found = true; - break; - } - } - if (!found) - { - redirects[i] = buffer->Vertices.size(); - buffer->Vertices.push_back(v[i]); - } - } - break; - } - default: - os::Printer::log("Cannot create welded mesh, vertex type unsupported", ELL_ERROR); - break; - } - - // write the buffer's index list - core::array<u16> &Indices = *outIdx; - - Indices.set_used(indexCount); - for (u32 i=0; i<indexCount; ++i) - { - Indices[i] = redirects[ indices[i] ]; - } - } - return clone; -} - - -//! Creates a copy of the mesh, which will only consist of S3DVertexTangents vertices. -IMesh* CMeshManipulator::createMeshWithTangents(IMesh* mesh, bool recalculateNormals, bool smooth, bool angleWeighted) const -{ - if (!mesh) - return 0; - - // copy mesh and fill data into SMeshBufferTangents - - SMesh* clone = new SMesh(); - const u32 meshBufferCount = mesh->getMeshBufferCount(); - u32 b; - - for (b=0; b<meshBufferCount; ++b) - { - const u32 idxCnt = mesh->getMeshBuffer(b)->getIndexCount(); - const u16* idx = mesh->getMeshBuffer(b)->getIndices(); - - SMeshBufferTangents* buffer = new SMeshBufferTangents(); - buffer->Material = mesh->getMeshBuffer(b)->getMaterial(); - - // copy vertices - - buffer->Vertices.reallocate(idxCnt); - switch(mesh->getMeshBuffer(b)->getVertexType()) - { - case video::EVT_STANDARD: - { - video::S3DVertex* v = - (video::S3DVertex*)mesh->getMeshBuffer(b)->getVertices(); - - for (u32 i=0; i<idxCnt; ++i) - buffer->Vertices.push_back( - video::S3DVertexTangents( - v[idx[i]].Pos, v[idx[i]].Normal, v[idx[i]].Color, v[idx[i]].TCoords)); - } - break; - case video::EVT_2TCOORDS: - { - video::S3DVertex2TCoords* v = - (video::S3DVertex2TCoords*)mesh->getMeshBuffer(b)->getVertices(); - - for (u32 i=0; i<idxCnt; ++i) - buffer->Vertices.push_back(video::S3DVertexTangents( - v[idx[i]].Pos, v[idx[i]].Normal, v[idx[i]].Color, v[idx[i]].TCoords)); - } - break; - case video::EVT_TANGENTS: - { - video::S3DVertexTangents* v = - (video::S3DVertexTangents*)mesh->getMeshBuffer(b)->getVertices(); - - for (u32 i=0; i<idxCnt; ++i) - buffer->Vertices.push_back(v[idx[i]]); - } - break; - } - - // create new indices - - buffer->Indices.set_used(idxCnt); - for (u32 i=0; i<idxCnt; ++i) - buffer->Indices[i] = i; - - //buffer->setBoundingBox(mesh->getMeshBuffer(b)->getBoundingBox()); - buffer->recalculateBoundingBox (); - - // add new buffer - clone->addMeshBuffer(buffer); - buffer->drop(); - } - - clone->recalculateBoundingBox (); - //clone->BoundingBox = mesh->getBoundingBox(); - - // now calculate tangents - for (b=0; b<meshBufferCount; ++b) - { - const u32 vtxCnt = mesh->getMeshBuffer(b)->getVertexCount(); - const u32 idxCnt = clone->getMeshBuffer(b)->getIndexCount(); - - u16* idx = clone->getMeshBuffer(b)->getIndices(); - video::S3DVertexTangents* v = - (video::S3DVertexTangents*)clone->getMeshBuffer(b)->getVertices(); - - if (smooth) - { - u32 i; - - for ( i = 0; i!= vtxCnt; ++i ) - { - if (recalculateNormals) - v[i].Normal.set( 0.f, 0.f, 0.f ); - v[i].Tangent.set( 0.f, 0.f, 0.f ); - v[i].Binormal.set( 0.f, 0.f, 0.f ); - } - - //Each vertex gets the sum of the tangents and binormals from the faces around it - for ( i=0; i<idxCnt; i+=3) - { - // if this triangle is degenerate, skip it! - if (v[idx[i+0]].Pos == v[idx[i+1]].Pos || - v[idx[i+0]].Pos == v[idx[i+2]].Pos || - v[idx[i+1]].Pos == v[idx[i+2]].Pos - /*|| - v[idx[i+0]].TCoords == v[idx[i+1]].TCoords || - v[idx[i+0]].TCoords == v[idx[i+2]].TCoords || - v[idx[i+1]].TCoords == v[idx[i+2]].TCoords */ - ) - continue; - - //Angle-weighted normals look better, but are slightly more CPU intensive to calculate - core::vector3df weight(1.f,1.f,1.f); - if (angleWeighted) - weight = getAngleWeight(v[i+0].Pos,v[i+1].Pos,v[i+2].Pos); - core::vector3df localNormal; - core::vector3df localTangent; - core::vector3df localBinormal; - - calculateTangents( - localNormal, - localTangent, - localBinormal, - v[idx[i+0]].Pos, - v[idx[i+1]].Pos, - v[idx[i+2]].Pos, - v[idx[i+0]].TCoords, - v[idx[i+1]].TCoords, - v[idx[i+2]].TCoords); - - if (recalculateNormals) - v[idx[i+0]].Tangent += localTangent * weight.X; - v[idx[i+0]].Binormal += localBinormal * weight.X; - v[idx[i+0]].Normal += localNormal * weight.X; - - calculateTangents( - localNormal, - localTangent, - localBinormal, - v[idx[i+1]].Pos, - v[idx[i+2]].Pos, - v[idx[i+0]].Pos, - v[idx[i+1]].TCoords, - v[idx[i+2]].TCoords, - v[idx[i+0]].TCoords); - - if (recalculateNormals) - v[idx[i+1]].Tangent += localTangent * weight.Y; - v[idx[i+1]].Binormal += localBinormal * weight.Y; - v[idx[i+1]].Normal += localNormal * weight.Y; - - calculateTangents( - localNormal, - localTangent, - localBinormal, - v[idx[i+2]].Pos, - v[idx[i+0]].Pos, - v[idx[i+1]].Pos, - v[idx[i+2]].TCoords, - v[idx[i+0]].TCoords, - v[idx[i+1]].TCoords); - - if (recalculateNormals) - v[idx[i+2]].Tangent += localTangent * weight.Z; - v[idx[i+2]].Binormal += localBinormal * weight.Z; - v[idx[i+2]].Normal += localNormal * weight.Z; - } - - // Normalize the tangents and binormals - if (recalculateNormals) - { - for ( i = 0; i!= vtxCnt; ++i ) - v[i].Normal.normalize(); - } - for ( i = 0; i!= vtxCnt; ++i ) - { - v[i].Tangent.normalize(); - v[i].Binormal.normalize(); - } - } - else - { - core::vector3df localNormal; - for (u32 i=0; i<idxCnt; i+=3) - { - calculateTangents( - localNormal, - v[idx[i+0]].Tangent, - v[idx[i+0]].Binormal, - v[idx[i+0]].Pos, - v[idx[i+1]].Pos, - v[idx[i+2]].Pos, - v[idx[i+0]].TCoords, - v[idx[i+1]].TCoords, - v[idx[i+2]].TCoords); - if (recalculateNormals) - v[idx[i+0]].Normal=localNormal; - - calculateTangents( - localNormal, - v[idx[i+1]].Tangent, - v[idx[i+1]].Binormal, - v[idx[i+1]].Pos, - v[idx[i+2]].Pos, - v[idx[i+0]].Pos, - v[idx[i+1]].TCoords, - v[idx[i+2]].TCoords, - v[idx[i+0]].TCoords); - if (recalculateNormals) - v[idx[i+1]].Normal=localNormal; - - calculateTangents( - localNormal, - v[idx[i+2]].Tangent, - v[idx[i+2]].Binormal, - v[idx[i+2]].Pos, - v[idx[i+0]].Pos, - v[idx[i+1]].Pos, - v[idx[i+2]].TCoords, - v[idx[i+0]].TCoords, - v[idx[i+1]].TCoords); - if (recalculateNormals) - v[idx[i+2]].Normal=localNormal; - } - } - } - - return clone; -} - - -//! Creates a copy of the mesh, which will only consist of S3DVertex2TCoords vertices. -IMesh* CMeshManipulator::createMeshWith2TCoords(IMesh* mesh) const -{ - if (!mesh) - return 0; - - // copy mesh and fill data into SMeshBufferLightMap - - SMesh* clone = new SMesh(); - const u32 meshBufferCount = mesh->getMeshBufferCount(); - u32 b; - - for (b=0; b<meshBufferCount; ++b) - { - const u32 idxCnt = mesh->getMeshBuffer(b)->getIndexCount(); - const u16* idx = mesh->getMeshBuffer(b)->getIndices(); - - SMeshBufferLightMap* buffer = new SMeshBufferLightMap(); - buffer->Material = mesh->getMeshBuffer(b)->getMaterial(); - - // copy vertices - - buffer->Vertices.reallocate(idxCnt); - switch(mesh->getMeshBuffer(b)->getVertexType()) - { - case video::EVT_STANDARD: - { - video::S3DVertex* v = - (video::S3DVertex*)mesh->getMeshBuffer(b)->getVertices(); - - for (u32 i=0; i<idxCnt; ++i) - buffer->Vertices.push_back( - video::S3DVertex2TCoords( - v[idx[i]].Pos, v[idx[i]].Normal, v[idx[i]].Color, v[idx[i]].TCoords, v[idx[i]].TCoords)); - } - break; - case video::EVT_2TCOORDS: - { - video::S3DVertex2TCoords* v = - (video::S3DVertex2TCoords*)mesh->getMeshBuffer(b)->getVertices(); - - for (u32 i=0; i<idxCnt; ++i) - buffer->Vertices.push_back(v[idx[i]]); - } - break; - case video::EVT_TANGENTS: - { - video::S3DVertexTangents* v = - (video::S3DVertexTangents*)mesh->getMeshBuffer(b)->getVertices(); - - for (u32 i=0; i<idxCnt; ++i) - buffer->Vertices.push_back(video::S3DVertex2TCoords( - v[idx[i]].Pos, v[idx[i]].Normal, v[idx[i]].Color, v[idx[i]].TCoords, v[idx[i]].TCoords)); - } - break; - } - - // create new indices - - buffer->Indices.set_used(idxCnt); - for (u32 i=0; i<idxCnt; ++i) - buffer->Indices[i] = i; - - //buffer->setBoundingBox(mesh->getMeshBuffer(b)->getBoundingBox()); - buffer->recalculateBoundingBox (); - - // add new buffer - clone->addMeshBuffer(buffer); - buffer->drop(); - } - - clone->recalculateBoundingBox (); - //clone->BoundingBox = mesh->getBoundingBox(); - - return clone; -} - -//! Creates a copy of the mesh, which will only consist of S3DVertex vertices. -IMesh* CMeshManipulator::createMeshWith1TCoords(IMesh* mesh) const -{ - if (!mesh) - return 0; - - // copy mesh and fill data into SMeshBuffer - SMesh* clone = new SMesh(); - const u32 meshBufferCount = mesh->getMeshBufferCount(); - u32 b; - - for (b=0; b<meshBufferCount; ++b) - { - const u32 idxCnt = mesh->getMeshBuffer(b)->getIndexCount(); - const u16* idx = mesh->getMeshBuffer(b)->getIndices(); - - SMeshBuffer* buffer = new SMeshBuffer(); - buffer->Material = mesh->getMeshBuffer(b)->getMaterial(); - buffer->Material.MaterialType = video::EMT_SOLID; - - // copy vertices - - buffer->Vertices.reallocate(idxCnt); - switch(mesh->getMeshBuffer(b)->getVertexType()) - { - case video::EVT_STANDARD: - { - video::S3DVertex* v = - (video::S3DVertex*)mesh->getMeshBuffer(b)->getVertices(); - - for (u32 i=0; i<idxCnt; ++i) - buffer->Vertices.push_back(v[idx[i]]); - - } - break; - case video::EVT_2TCOORDS: - { - video::S3DVertex2TCoords* v = - (video::S3DVertex2TCoords*)mesh->getMeshBuffer(b)->getVertices(); - - for (u32 i=0; i<idxCnt; ++i) - buffer->Vertices.push_back( - video::S3DVertex( - v[idx[i]].Pos, v[idx[i]].Normal, v[idx[i]].Color, v[idx[i]].TCoords)); - - } - break; - case video::EVT_TANGENTS: - { - video::S3DVertexTangents* v = - (video::S3DVertexTangents*)mesh->getMeshBuffer(b)->getVertices(); - - for (u32 i=0; i<idxCnt; ++i) - buffer->Vertices.push_back( - video::S3DVertex( - v[idx[i]].Pos, v[idx[i]].Normal, v[idx[i]].Color, v[idx[i]].TCoords)); - } - break; - } - - // create new indices - - buffer->Indices.set_used(idxCnt); - for (u32 i=0; i<idxCnt; ++i) - buffer->Indices[i] = i; - - //buffer->setBoundingBox(mesh->getMeshBuffer(b)->getBoundingBox()); - buffer->recalculateBoundingBox (); - - // add new buffer - clone->addMeshBuffer(buffer); - buffer->drop(); - } - - clone->recalculateBoundingBox (); - //clone->BoundingBox = mesh->getBoundingBox(); - - return clone; -} - - -void CMeshManipulator::calculateTangents( - core::vector3df& normal, - core::vector3df& tangent, - core::vector3df& binormal, - const core::vector3df& vt1, const core::vector3df& vt2, const core::vector3df& vt3, // vertices - const core::vector2df& tc1, const core::vector2df& tc2, const core::vector2df& tc3) // texture coords -{ - // choose one of them: - //#define USE_NVIDIA_GLH_VERSION // use version used by nvidia in glh headers - #define USE_IRR_VERSION - -#ifdef USE_IRR_VERSION - - core::vector3df v1 = vt1 - vt2; - core::vector3df v2 = vt3 - vt1; - normal = v2.crossProduct(v1); - normal.normalize(); - - // binormal - - f32 deltaX1 = tc1.X - tc2.X; - f32 deltaX2 = tc3.X - tc1.X; - binormal = (v1 * deltaX2) - (v2 * deltaX1); - binormal.normalize(); - - // tangent - - f32 deltaY1 = tc1.Y - tc2.Y; - f32 deltaY2 = tc3.Y - tc1.Y; - tangent = (v1 * deltaY2) - (v2 * deltaY1); - tangent.normalize(); - - // adjust - - core::vector3df txb = tangent.crossProduct(binormal); - if (txb.dotProduct(normal) < 0.0f) - { - tangent *= -1.0f; - binormal *= -1.0f; - } - -#endif // USE_IRR_VERSION - -#ifdef USE_NVIDIA_GLH_VERSION - - tangent.set(0,0,0); - binormal.set(0,0,0); - - core::vector3df v1(vt2.X - vt1.X, tc2.X - tc1.X, tc2.Y - tc1.Y); - core::vector3df v2(vt3.X - vt1.X, tc3.X - tc1.X, tc3.Y - tc1.Y); - - core::vector3df txb = v1.crossProduct(v2); - if ( !core::iszero ( txb.X ) ) - { - tangent.X = -txb.Y / txb.X; - binormal.X = -txb.Z / txb.X; - } - - v1.X = vt2.Y - vt1.Y; - v2.X = vt3.Y - vt1.Y; - txb = v1.crossProduct(v2); - - if ( !core::iszero ( txb.X ) ) - { - tangent.Y = -txb.Y / txb.X; - binormal.Y = -txb.Z / txb.X; - } - - v1.X = vt2.Z - vt1.Z; - v2.X = vt3.Z - vt1.Z; - txb = v1.crossProduct(v2); - - if ( !core::iszero ( txb.X ) ) - { - tangent.Z = -txb.Y / txb.X; - binormal.Z = -txb.Z / txb.X; - } - - tangent.normalize(); - binormal.normalize(); - - normal = tangent.crossProduct(binormal); - normal.normalize(); - - binormal = tangent.crossProduct(normal); - binormal.normalize(); - - core::plane3d<f32> pl(vt1, vt2, vt3); - - if(normal.dotProduct(pl.Normal) < 0.0f ) - normal *= -1.0f; - -#endif // USE_NVIDIA_GLH_VERSION -} - - - -//! Returns amount of polygons in mesh. -s32 CMeshManipulator::getPolyCount(scene::IMesh* mesh) const -{ - if (!mesh) - return 0; - - s32 trianglecount = 0; - - for (u32 g=0; g<mesh->getMeshBufferCount(); ++g) - trianglecount += mesh->getMeshBuffer(g)->getIndexCount() / 3; - - return trianglecount; -} - - -//! Returns amount of polygons in mesh. -s32 CMeshManipulator::getPolyCount(scene::IAnimatedMesh* mesh) const -{ - if (mesh && mesh->getFrameCount() != 0) - return getPolyCount(mesh->getMesh(0)); - - return 0; -} - - -//! create a new AnimatedMesh and adds the mesh to it -IAnimatedMesh * CMeshManipulator::createAnimatedMesh(scene::IMesh* mesh, scene::E_ANIMATED_MESH_TYPE type) const -{ - return new SAnimatedMesh(mesh, type); -} - - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CMeshManipulator.h b/irrlicht-1.6/source/Irrlicht/CMeshManipulator.h deleted file mode 100644 index f0f6761e0..000000000 --- a/irrlicht-1.6/source/Irrlicht/CMeshManipulator.h +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_MESH_MANIPULATOR_H_INCLUDED__ -#define __C_MESH_MANIPULATOR_H_INCLUDED__ - -#include "IMeshManipulator.h" - -namespace irr -{ -namespace scene -{ - -//! An interface for easy manipulation of meshes. -/** 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 modifications and/or animations during runtime. -*/ -class CMeshManipulator : public IMeshManipulator -{ -public: - //! Flips the direction of surfaces. - /** Changes backfacing triangles to frontfacing triangles and vice versa. - \param mesh: Mesh on which the operation is performed. */ - virtual void flipSurfaces(scene::IMesh* mesh) const; - - //! Sets the alpha vertex color value of the whole mesh to a new value - /** \param mesh: Mesh on which the operation is performed. - \param alpha: New alpha for the vertex color. */ - virtual void setVertexColorAlpha(scene::IMesh* mesh, s32 alpha) const; - - //! Sets the colors of all vertices to one color - virtual void setVertexColors(IMesh* mesh, video::SColor color) const; - - //! Recalculates all normals of the mesh. - /** \param mesh: Mesh on which the operation is performed. - \param smooth: Whether to use smoothed normals. */ - virtual void recalculateNormals(scene::IMesh* mesh, bool smooth = false, bool angleWeighted = false) const; - - //! Recalculates all normals of the mesh buffer. - /** \param buffer: Mesh buffer on which the operation is performed. - \param smooth: Whether to use smoothed normals. */ - virtual void recalculateNormals(IMeshBuffer* buffer, bool smooth = false, bool angleWeighted = false) const; - - //! Scales the actual mesh, not the scene node. - /** \param mesh Mesh on which the operation is performed. - \param factor Vector which defines the scale for each axis. */ - virtual void scale(scene::IMesh* mesh, const core::vector3df& factor) const; - - //! Scales the actual meshbuffer, not the scene node. - /** \param buffer MeshBuffer on which the operation is performed. - \param factor Vector which defines the scale for each axis. */ - virtual void scale(scene::IMeshBuffer* buffer, const core::vector3df& factor) const; - - //! Scale the texture coords of a mesh. - /** \param mesh Mesh on which the operation is performed. - \param factor Vector which defines the scale for each axis. - \param level Number of texture coord, starting from 1. Support for level 2 exists for LightMap buffers. */ - virtual void scaleTCoords(scene::IMesh* mesh, const core::vector2df& factor, u32 layer=1) const; - - //! Scale the texture coords of a meshbuffer. - /** \param mesh Mesh on which the operation is performed. - \param factor Vector which defines the scale for each axis. - \param level Number of texture coord, starting from 1. Support for level 2 exists for LightMap buffers. */ - virtual void scaleTCoords(scene::IMeshBuffer* buffer, const core::vector2df& factor, u32 level=1) const; - - //! Applies a transformation to a meshbuffer - /** \param buffer: Meshbuffer on which the operation is performed. - \param m: matrix. */ - void transform(scene::IMeshBuffer* buffer, const core::matrix4& m) const; - - //! Applies a transformation to a mesh - /** \param mesh: Mesh on which the operation is performed. - \param m: transformation matrix. */ - virtual void transform(scene::IMesh* mesh, const core::matrix4& m) const; - - //! Clones a static IMesh into a modifiable SMesh. - virtual SMesh* createMeshCopy(scene::IMesh* mesh) const; - - //! Creates a planar texture mapping on the mesh - /** \param mesh: Mesh on which the operation is performed. - \param resolution: resolution of the planar mapping. This is the value - specifying which is the relation between world space and - texture coordinate space. */ - virtual void makePlanarTextureMapping(scene::IMesh* mesh, f32 resolution) const; - - //! Creates a planar texture mapping on the meshbuffer - virtual void makePlanarTextureMapping(scene::IMeshBuffer* meshbuffer, f32 resolution=0.001f) const; - - //! Creates a planar texture mapping on the meshbuffer - void makePlanarTextureMapping(scene::IMeshBuffer* buffer, f32 resolutionS, f32 resolutionT, u8 axis, const core::vector3df& offset) const; - - //! Creates a copy of the mesh, which will only consist of S3DVertexTangents vertices. - virtual IMesh* createMeshWithTangents(IMesh* mesh, bool recalculateNormals=false, bool smooth=false, bool angleWeighted=false) const; - - //! Creates a copy of the mesh, which will only consist of S3D2TCoords vertices. - virtual IMesh* createMeshWith2TCoords(IMesh* mesh) const; - - //! Creates a copy of the mesh, which will only consist of S3DVertex vertices. - virtual IMesh* createMeshWith1TCoords(IMesh* mesh) const; - - //! Creates a copy of the mesh, which will only consist of unique triangles, i.e. no vertices are shared. - virtual IMesh* createMeshUniquePrimitives(IMesh* mesh) const; - - //! Creates a copy of the mesh, which will have all duplicated vertices removed, i.e. maximal amount of vertices are shared via indexing. - virtual IMesh* createMeshWelded(IMesh *mesh, f32 tolerance=core::ROUNDING_ERROR_f32) const; - - //! Returns amount of polygons in mesh. - virtual s32 getPolyCount(scene::IMesh* mesh) const; - - //! Returns amount of polygons in mesh. - virtual s32 getPolyCount(scene::IAnimatedMesh* mesh) const; - - //! create a new AnimatedMesh and adds the mesh to it - virtual IAnimatedMesh * createAnimatedMesh(scene::IMesh* mesh,scene::E_ANIMATED_MESH_TYPE type) const; - -private: - - static void calculateTangents(core::vector3df& normal, - core::vector3df& tangent, - core::vector3df& binormal, - const core::vector3df& vt1, const core::vector3df& vt2, const core::vector3df& vt3, - const core::vector2df& tc1, const core::vector2df& tc2, const core::vector2df& tc3); -}; - -} // end namespace scene -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CMeshSceneNode.cpp b/irrlicht-1.6/source/Irrlicht/CMeshSceneNode.cpp deleted file mode 100644 index 841beb102..000000000 --- a/irrlicht-1.6/source/Irrlicht/CMeshSceneNode.cpp +++ /dev/null @@ -1,382 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CMeshSceneNode.h" -#include "IVideoDriver.h" -#include "ISceneManager.h" -#include "S3DVertex.h" -#include "ICameraSceneNode.h" -#include "IMeshCache.h" -#include "IAnimatedMesh.h" -#include "IMaterialRenderer.h" - -namespace irr -{ -namespace scene -{ - - - -//! constructor -CMeshSceneNode::CMeshSceneNode(IMesh* mesh, ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position, const core::vector3df& rotation, - const core::vector3df& scale) -: IMeshSceneNode(parent, mgr, id, position, rotation, scale), Mesh(0), PassCount(0), - ReadOnlyMaterials(false) -{ - #ifdef _DEBUG - setDebugName("CMeshSceneNode"); - #endif - - setMesh(mesh); -} - - - -//! destructor -CMeshSceneNode::~CMeshSceneNode() -{ - if (Mesh) - Mesh->drop(); -} - - - -//! frame -void CMeshSceneNode::OnRegisterSceneNode() -{ - if (IsVisible) - { - // because this node supports rendering of mixed mode meshes consisting of - // transparent and solid material at the same time, we need to go through all - // materials, check of what type they are and register this node for the right - // render pass according to that. - - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - - PassCount = 0; - int transparentCount = 0; - int solidCount = 0; - - // count transparent and solid materials in this scene node - if (ReadOnlyMaterials && Mesh) - { - // count mesh materials - - for (u32 i=0; i<Mesh->getMeshBufferCount(); ++i) - { - scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i); - video::IMaterialRenderer* rnd = mb ? driver->getMaterialRenderer(mb->getMaterial().MaterialType) : 0; - - if (rnd && rnd->isTransparent()) - ++transparentCount; - else - ++solidCount; - - if (solidCount && transparentCount) - break; - } - } - else - { - // count copied materials - - for (u32 i=0; i<Materials.size(); ++i) - { - video::IMaterialRenderer* rnd = - driver->getMaterialRenderer(Materials[i].MaterialType); - - if (rnd && rnd->isTransparent()) - ++transparentCount; - else - ++solidCount; - - if (solidCount && transparentCount) - break; - } - } - - // register according to material types counted - - if (solidCount) - SceneManager->registerNodeForRendering(this, scene::ESNRP_SOLID); - - if (transparentCount) - SceneManager->registerNodeForRendering(this, scene::ESNRP_TRANSPARENT); - - ISceneNode::OnRegisterSceneNode(); - } -} - - - -//! renders the node. -void CMeshSceneNode::render() -{ - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - - if (!Mesh || !driver) - return; - - bool isTransparentPass = - SceneManager->getSceneNodeRenderPass() == scene::ESNRP_TRANSPARENT; - - ++PassCount; - - driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); - Box = Mesh->getBoundingBox(); - - // for debug purposes only: - - bool renderMeshes = true; - video::SMaterial mat; - if (DebugDataVisible && PassCount==1) - { - // overwrite half transparency - if (DebugDataVisible & scene::EDS_HALF_TRANSPARENCY) - { - for (u32 g=0; g<Mesh->getMeshBufferCount(); ++g) - { - mat = Materials[g]; - mat.MaterialType = video::EMT_TRANSPARENT_ADD_COLOR; - driver->setMaterial(mat); - driver->drawMeshBuffer(Mesh->getMeshBuffer(g)); - } - renderMeshes = false; - } - } - - // render original meshes - if (renderMeshes) - { - for (u32 i=0; i<Mesh->getMeshBufferCount(); ++i) - { - scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i); - if (mb) - { - const video::SMaterial& material = ReadOnlyMaterials ? mb->getMaterial() : Materials[i]; - - video::IMaterialRenderer* rnd = driver->getMaterialRenderer(material.MaterialType); - bool transparent = (rnd && rnd->isTransparent()); - - // only render transparent buffer if this is the transparent render pass - // and solid only in solid pass - if (transparent == isTransparentPass) - { - driver->setMaterial(material); - driver->drawMeshBuffer(mb); - } - } - } - } - - driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); - - // for debug purposes only: - if (DebugDataVisible && PassCount==1) - { - video::SMaterial m; - m.Lighting = false; - driver->setMaterial(m); - - if (DebugDataVisible & scene::EDS_BBOX) - { - driver->draw3DBox(Box, video::SColor(255,255,255,255)); - } - if (DebugDataVisible & scene::EDS_BBOX_BUFFERS) - { - for (u32 g=0; g<Mesh->getMeshBufferCount(); ++g) - { - driver->draw3DBox( - Mesh->getMeshBuffer(g)->getBoundingBox(), - video::SColor(255,190,128,128)); - } - } - - if (DebugDataVisible & scene::EDS_NORMALS) - { - - // draw normals - core::vector3df normalizedNormal; - const f32 DebugNormalLength = SceneManager->getParameters()->getAttributeAsFloat(DEBUG_NORMAL_LENGTH); - const video::SColor DebugNormalColor = SceneManager->getParameters()->getAttributeAsColor(DEBUG_NORMAL_COLOR); - - for (u32 g=0; g<Mesh->getMeshBufferCount(); ++g) - { - const scene::IMeshBuffer* mb = Mesh->getMeshBuffer(g); - const u32 vSize = video::getVertexPitchFromType(mb->getVertexType()); - const video::S3DVertex* v = ( const video::S3DVertex*)mb->getVertices(); - const bool normalize = mb->getMaterial().NormalizeNormals; - - for (u32 i=0; i != mb->getVertexCount(); ++i) - { - normalizedNormal = v->Normal; - if (normalize) - normalizedNormal.normalize(); - - driver->draw3DLine(v->Pos, v->Pos + (normalizedNormal * DebugNormalLength), DebugNormalColor); - - v = (const video::S3DVertex*) ( (u8*) v+vSize ); - } - } - driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); - } - - // show mesh - if (DebugDataVisible & scene::EDS_MESH_WIRE_OVERLAY) - { - m.Wireframe = true; - driver->setMaterial(m); - - for (u32 g=0; g<Mesh->getMeshBufferCount(); ++g) - { - driver->drawMeshBuffer( Mesh->getMeshBuffer(g) ); - } - } - } -} - - -//! returns the axis aligned bounding box of this node -const core::aabbox3d<f32>& CMeshSceneNode::getBoundingBox() const -{ - return Mesh ? Mesh->getBoundingBox() : Box; -} - - -//! returns the material based on the zero based index i. To get the amount -//! of materials used by this scene node, use getMaterialCount(). -//! This function is needed for inserting the node into the scene hierarchy on a -//! optimal position for minimizing renderstate changes, but can also be used -//! to directly modify the material of a scene node. -video::SMaterial& CMeshSceneNode::getMaterial(u32 i) -{ - if (Mesh && ReadOnlyMaterials && i<Mesh->getMeshBufferCount()) - { - tmpReadOnlyMaterial = Mesh->getMeshBuffer(i)->getMaterial(); - return tmpReadOnlyMaterial; - } - - if (i >= Materials.size()) - return ISceneNode::getMaterial(i); - - return Materials[i]; -} - - - -//! returns amount of materials used by this scene node. -u32 CMeshSceneNode::getMaterialCount() const -{ - if (Mesh && ReadOnlyMaterials) - return Mesh->getMeshBufferCount(); - - return Materials.size(); -} - - - -//! Sets a new mesh -void CMeshSceneNode::setMesh(IMesh* mesh) -{ - if (!mesh) - return; // won't set null mesh - - mesh->grab(); - if (Mesh) - Mesh->drop(); - - Mesh = mesh; - copyMaterials(); -} - - -void CMeshSceneNode::copyMaterials() -{ - Materials.clear(); - - if (Mesh) - { - video::SMaterial mat; - - for (u32 i=0; i<Mesh->getMeshBufferCount(); ++i) - { - IMeshBuffer* mb = Mesh->getMeshBuffer(i); - if (mb) - mat = mb->getMaterial(); - - Materials.push_back(mat); - } - } -} - - -//! Writes attributes of the scene node. -void CMeshSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const -{ - IMeshSceneNode::serializeAttributes(out, options); - - out->addString("Mesh", SceneManager->getMeshCache()->getMeshFilename(Mesh).c_str()); - out->addBool("ReadOnlyMaterials", ReadOnlyMaterials); -} - -//! Reads attributes of the scene node. -void CMeshSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - io::path oldMeshStr = SceneManager->getMeshCache()->getMeshFilename(Mesh); - io::path newMeshStr = in->getAttributeAsString("Mesh"); - ReadOnlyMaterials = in->getAttributeAsBool("ReadOnlyMaterials"); - - if (newMeshStr != "" && oldMeshStr != newMeshStr) - { - IMesh* newMesh = 0; - IAnimatedMesh* newAnimatedMesh = SceneManager->getMesh(newMeshStr.c_str()); - - if (newAnimatedMesh) - newMesh = newAnimatedMesh->getMesh(0); - - if (newMesh) - setMesh(newMesh); - } - - IMeshSceneNode::deserializeAttributes(in, options); -} - -//! Sets if the scene node should not copy the materials of the mesh but use them in a read only style. -/* In this way it is possible to change the materials a mesh causing all mesh scene nodes -referencing this mesh to change too. */ -void CMeshSceneNode::setReadOnlyMaterials(bool readonly) -{ - ReadOnlyMaterials = readonly; -} - -//! Returns if the scene node should not copy the materials of the mesh but use them in a read only style -bool CMeshSceneNode::isReadOnlyMaterials() const -{ - return ReadOnlyMaterials; -} - - -//! Creates a clone of this scene node and its children. -ISceneNode* CMeshSceneNode::clone(ISceneNode* newParent, ISceneManager* newManager) -{ - if (!newParent) newParent = Parent; - if (!newManager) newManager = SceneManager; - - CMeshSceneNode* nb = new CMeshSceneNode(Mesh, newParent, - newManager, ID, RelativeTranslation, RelativeRotation, RelativeScale); - - nb->cloneMembers(this, newManager); - nb->ReadOnlyMaterials = ReadOnlyMaterials; - nb->Materials = Materials; - - nb->drop(); - return nb; -} - - - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CMeshSceneNode.h b/irrlicht-1.6/source/Irrlicht/CMeshSceneNode.h deleted file mode 100644 index f96ecb1a2..000000000 --- a/irrlicht-1.6/source/Irrlicht/CMeshSceneNode.h +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_MESH_SCENE_NODE_H_INCLUDED__ -#define __C_MESH_SCENE_NODE_H_INCLUDED__ - -#include "IMeshSceneNode.h" -#include "IMesh.h" - -namespace irr -{ -namespace scene -{ - - class CMeshSceneNode : public IMeshSceneNode - { - public: - - //! constructor - CMeshSceneNode(IMesh* mesh, ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); - - //! destructor - virtual ~CMeshSceneNode(); - - //! frame - virtual void OnRegisterSceneNode(); - - //! renders the node. - virtual void render(); - - //! returns the axis aligned bounding box of this node - virtual const core::aabbox3d<f32>& getBoundingBox() const; - - //! returns the material based on the zero based index i. To get the amount - //! of materials used by this scene node, use getMaterialCount(). - //! This function is needed for inserting the node into the scene hirachy on a - //! optimal position for minimizing renderstate changes, but can also be used - //! to directly modify the material of a scene node. - virtual video::SMaterial& getMaterial(u32 i); - - //! returns amount of materials used by this scene node. - virtual u32 getMaterialCount() const; - - //! Writes attributes of the scene node. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const; - - //! Reads attributes of the scene node. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() const { return ESNT_MESH; } - - //! Sets a new mesh - virtual void setMesh(IMesh* mesh); - - //! Returns the current mesh - virtual IMesh* getMesh(void) { return Mesh; } - - //! Sets if the scene node should not copy the materials of the mesh but use them in a read only style. - /* In this way it is possible to change the materials a mesh causing all mesh scene nodes - referencing this mesh to change too. */ - virtual void setReadOnlyMaterials(bool readonly); - - //! Returns if the scene node should not copy the materials of the mesh but use them in a read only style - virtual bool isReadOnlyMaterials() const; - - //! Creates a clone of this scene node and its children. - virtual ISceneNode* clone(ISceneNode* newParent=0, ISceneManager* newManager=0); - - protected: - - void copyMaterials(); - - core::array<video::SMaterial> Materials; - core::aabbox3d<f32> Box; - video::SMaterial tmpReadOnlyMaterial; - - IMesh* Mesh; - - s32 PassCount; - bool ReadOnlyMaterials; - }; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CMetaTriangleSelector.cpp b/irrlicht-1.6/source/Irrlicht/CMetaTriangleSelector.cpp deleted file mode 100644 index a74a85630..000000000 --- a/irrlicht-1.6/source/Irrlicht/CMetaTriangleSelector.cpp +++ /dev/null @@ -1,154 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CMetaTriangleSelector.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CMetaTriangleSelector::CMetaTriangleSelector() -{ - #ifdef _DEBUG - setDebugName("CMetaTriangleSelector"); - #endif -} - - -//! destructor -CMetaTriangleSelector::~CMetaTriangleSelector() -{ - removeAllTriangleSelectors(); -} - - -//! Returns amount of all available triangles in this selector -s32 CMetaTriangleSelector::getTriangleCount() const -{ - s32 count = 0; - for (u32 i=0; i<TriangleSelectors.size(); ++i) - count += TriangleSelectors[i]->getTriangleCount(); - - return count; -} - - -//! Gets all triangles. -void CMetaTriangleSelector::getTriangles(core::triangle3df* triangles, s32 arraySize, - s32& outTriangleCount, const core::matrix4* transform) const -{ - s32 outWritten = 0; - for (u32 i=0; i<TriangleSelectors.size(); ++i) - { - s32 t = 0; - TriangleSelectors[i]->getTriangles(triangles + outWritten, - arraySize - outWritten, t, - transform); - outWritten += t; - } - - outTriangleCount = outWritten; -} - - -//! Gets all triangles which lie within a specific bounding box. -void CMetaTriangleSelector::getTriangles(core::triangle3df* triangles, s32 arraySize, - s32& outTriangleCount, const core::aabbox3d<f32>& box, - const core::matrix4* transform) const -{ - s32 outWritten = 0; - for (u32 i=0; i<TriangleSelectors.size(); ++i) - { - s32 t = 0; - TriangleSelectors[i]->getTriangles(triangles + outWritten, - arraySize - outWritten, t, - box, transform); - outWritten += t; - } - - outTriangleCount = outWritten; -} - - -//! Gets all triangles which have or may have contact with a 3d line. -void CMetaTriangleSelector::getTriangles(core::triangle3df* triangles, s32 arraySize, - s32& outTriangleCount, const core::line3d<f32>& line, - const core::matrix4* transform) const -{ - s32 outWritten = 0; - for (u32 i=0; i<TriangleSelectors.size(); ++i) - { - s32 t = 0; - TriangleSelectors[i]->getTriangles(triangles + outWritten, - arraySize - outWritten, t, - line, transform); - outWritten += t; - } - - outTriangleCount = outWritten; -} - - -//! Adds a triangle selector to the collection of triangle selectors -//! in this metaTriangleSelector. -void CMetaTriangleSelector::addTriangleSelector(ITriangleSelector* toAdd) -{ - if (!toAdd) - return; - - TriangleSelectors.push_back(toAdd); - toAdd->grab(); -} - - -//! Removes a specific triangle selector which was added before from the collection. -bool CMetaTriangleSelector::removeTriangleSelector(ITriangleSelector* toRemove) -{ - for (u32 i=0; i<TriangleSelectors.size(); ++i) - { - if (toRemove == TriangleSelectors[i]) - { - TriangleSelectors[i]->drop(); - TriangleSelectors.erase(i); - return true; - } - } - - return false; -} - - -//! Removes all triangle selectors from the collection. -void CMetaTriangleSelector::removeAllTriangleSelectors() -{ - for (u32 i=0; i<TriangleSelectors.size(); ++i) - TriangleSelectors[i]->drop(); - - TriangleSelectors.clear(); -} - -//! Return the scene node associated with a given triangle. -const ISceneNode* CMetaTriangleSelector::getSceneNodeForTriangle(u32 triangleIndex) const -{ - u32 totalTriangles = 0; - - for (u32 i=0; i<TriangleSelectors.size(); ++i) - { - totalTriangles += TriangleSelectors[i]->getTriangleCount(); - - if(totalTriangles > triangleIndex) - return TriangleSelectors[i]->getSceneNodeForTriangle(0); - } - - // For lack of anything more sensible, return the first selector. - return TriangleSelectors[0]->getSceneNodeForTriangle(0); -} - - - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CMetaTriangleSelector.h b/irrlicht-1.6/source/Irrlicht/CMetaTriangleSelector.h deleted file mode 100644 index 04cb85580..000000000 --- a/irrlicht-1.6/source/Irrlicht/CMetaTriangleSelector.h +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_META_TRIANGLE_SELECTOR_H_INCLUDED__ -#define __C_META_TRIANGLE_SELECTOR_H_INCLUDED__ - -#include "IMetaTriangleSelector.h" -#include "irrArray.h" - -namespace irr -{ -namespace scene -{ - -//! Interface for making multiple triangle selectors work as one big selector. -class CMetaTriangleSelector : public IMetaTriangleSelector -{ -public: - - //! constructor - CMetaTriangleSelector(); - - //! destructor - virtual ~CMetaTriangleSelector(); - - //! Returns amount of all available triangles in this selector - virtual s32 getTriangleCount() const; - - //! Gets all triangles. - virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, - s32& outTriangleCount, const core::matrix4* transform=0) const; - - //! Gets all triangles which lie within a specific bounding box. - virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, - s32& outTriangleCount, const core::aabbox3d<f32>& box, - const core::matrix4* transform=0) const; - - //! Gets all triangles which have or may have contact with a 3d line. - virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, - s32& outTriangleCount, const core::line3d<f32>& line, - const core::matrix4* transform=0) const; - - //! Adds a triangle selector to the collection of triangle selectors - //! in this metaTriangleSelector. - virtual void addTriangleSelector(ITriangleSelector* toAdd); - - //! Removes a specific triangle selector which was added before from the collection. - virtual bool removeTriangleSelector(ITriangleSelector* toRemove); - - //! Removes all triangle selectors from the collection. - virtual void removeAllTriangleSelectors(); - - //! Return the scene node associated with a given triangle. - virtual const ISceneNode* getSceneNodeForTriangle(u32 triangleIndex) const; - -private: - - core::array<ITriangleSelector*> TriangleSelectors; -}; - -} // end namespace scene -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CMountPointReader.cpp b/irrlicht-1.6/source/Irrlicht/CMountPointReader.cpp deleted file mode 100644 index bb0213066..000000000 --- a/irrlicht-1.6/source/Irrlicht/CMountPointReader.cpp +++ /dev/null @@ -1,177 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CMountPointReader.h" - -#ifdef __IRR_COMPILE_WITH_MOUNT_ARCHIVE_LOADER_ - -#include "CReadFile.h" -#include "os.h" - -namespace irr -{ -namespace io -{ - -//! Constructor -CArchiveLoaderMount::CArchiveLoaderMount( io::IFileSystem* fs) -: FileSystem(fs) -{ - #ifdef _DEBUG - setDebugName("CArchiveLoaderMount"); - #endif -} - - -//! destructor -CArchiveLoaderMount::~CArchiveLoaderMount() -{ -} - - -//! returns true if the file maybe is able to be loaded by this class -bool CArchiveLoaderMount::isALoadableFileFormat(const io::path& filename) const -{ - bool ret = false; - io::path fname(filename); - deletePathFromFilename(fname); - - if (!fname.size()) - { - ret = true; - } - - return ret; -} - -//! Check to see if the loader can create archives of this type. -bool CArchiveLoaderMount::isALoadableFileFormat(E_FILE_ARCHIVE_TYPE fileType) const -{ - return fileType == EFAT_FOLDER; -} - -//! Check if the file might be loaded by this class -bool CArchiveLoaderMount::isALoadableFileFormat(io::IReadFile* file) const -{ - return false; -} - -//! Creates an archive from the filename -IFileArchive* CArchiveLoaderMount::createArchive(const io::path& filename, bool ignoreCase, bool ignorePaths) const -{ - IFileArchive *archive = 0; - - EFileSystemType current = FileSystem->setFileListSystem(FILESYSTEM_NATIVE); - - io::path save = FileSystem->getWorkingDirectory(); - io::path fullPath = FileSystem->getAbsolutePath(filename); - FileSystem->flattenFilename(fullPath); - - if ( FileSystem->changeWorkingDirectoryTo ( fullPath ) ) - { - archive = new CMountPointReader(FileSystem, fullPath, ignoreCase, ignorePaths); - } - - FileSystem->changeWorkingDirectoryTo(save); - FileSystem->setFileListSystem(current); - - return archive; -} - -//! creates/loads an archive from the file. -//! \return Pointer to the created archive. Returns 0 if loading failed. -IFileArchive* CArchiveLoaderMount::createArchive(io::IReadFile* file, bool ignoreCase, bool ignorePaths) const -{ - return 0; -} - -//! compatible Folder Archticture -// -CMountPointReader::CMountPointReader(IFileSystem * parent, const io::path& basename, bool ignoreCase, bool ignorePaths) - : CFileList(basename, ignoreCase, ignorePaths), Parent(parent) -{ - //! ensure CFileList path ends in a slash - if (Path.lastChar() != '/' ) - Path.append ('/'); - - io::path work = Parent->getWorkingDirectory(); - - Parent->changeWorkingDirectoryTo(basename); - buildDirectory(); - Parent->changeWorkingDirectoryTo(work); - - sort(); -} - -CMountPointReader::~CMountPointReader() -{ - -} - -//! returns the list of files -const IFileList* CMountPointReader::getFileList() const -{ - return this; -} - -void CMountPointReader::buildDirectory() -{ - IFileList * list = Parent->createFileList(); - - const u32 size = list->getFileCount(); - for (u32 i=0; i < size; ++i) - { - io::path full = list->getFullFileName(i); - full = full.subString(Path.size(), full.size() - Path.size()); - - if (!list->isDirectory(i)) - { - addItem(full, list->getFileSize(i), false, RealFileNames.size()); - RealFileNames.push_back(list->getFullFileName(i)); - } - else - { - const io::path rel = list->getFileName(i); - io::path pwd = Parent->getWorkingDirectory(); - if (pwd.lastChar() != '/') - pwd.append('/'); - pwd.append(rel); - - if ( rel != "." && rel != ".." ) - { - addItem(full, 0, true, 0); - Parent->changeWorkingDirectoryTo(pwd); - buildDirectory (); - Parent->changeWorkingDirectoryTo(".."); - } - } - } - - list->drop(); -} - -//! opens a file by index -IReadFile* CMountPointReader::createAndOpenFile(u32 index) -{ - if (index >= Files.size()) - return 0; - - return createReadFile(RealFileNames[Files[index].ID]); -} - -//! opens a file by file name -IReadFile* CMountPointReader::createAndOpenFile(const io::path& filename) -{ - s32 index = findFile(filename, false); - if (index != -1) - return createAndOpenFile(index); - else - return 0; -} - - -} // io -} // irr - -#endif // __IRR_COMPILE_WITH_MOUNT_ARCHIVE_LOADER_ diff --git a/irrlicht-1.6/source/Irrlicht/CMountPointReader.h b/irrlicht-1.6/source/Irrlicht/CMountPointReader.h deleted file mode 100644 index 299dc0d1d..000000000 --- a/irrlicht-1.6/source/Irrlicht/CMountPointReader.h +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_MOUNT_READER_H_INCLUDED__ -#define __C_MOUNT_READER_H_INCLUDED__ - -#include "IrrCompileConfig.h" - -#ifdef __IRR_COMPILE_WITH_MOUNT_ARCHIVE_LOADER_ - -#include "IFileSystem.h" -#include "CFileList.h" - -namespace irr -{ -namespace io -{ - - //! Archiveloader capable of loading MountPoint Archives - class CArchiveLoaderMount : public IArchiveLoader - { - public: - - //! Constructor - CArchiveLoaderMount(io::IFileSystem* fs); - - //! destructor - virtual ~CArchiveLoaderMount(); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".zip") - virtual bool isALoadableFileFormat(const io::path& filename) const; - - //! Check if the file might be loaded by this class - /** Check might look into the file. - \param file File handle to check. - \return True if file seems to be loadable. */ - virtual bool isALoadableFileFormat(io::IReadFile* file) const; - - //! Check to see if the loader can create archives of this type. - /** Check based on the archive type. - \param fileType The archive type to check. - \return True if the archile loader supports this type, false if not */ - virtual bool isALoadableFileFormat(E_FILE_ARCHIVE_TYPE fileType) const; - - //! Creates an archive from the filename - /** \param file File handle to check. - \return Pointer to newly created archive, or 0 upon error. */ - virtual IFileArchive* createArchive(const io::path& filename, bool ignoreCase, bool ignorePaths) const; - - //! creates/loads an archive from the file. - //! \return Pointer to the created archive. Returns 0 if loading failed. - virtual IFileArchive* createArchive(io::IReadFile* file, bool ignoreCase, bool ignorePaths) const; - - private: - io::IFileSystem* FileSystem; - }; - - //! A File Archive which uses a mountpoint - class CMountPointReader : public virtual IFileArchive, virtual CFileList - { - public: - - //! Constructor - CMountPointReader(IFileSystem *parent, const io::path& basename, - bool ignoreCase, bool ignorePaths); - - //! Destructor - virtual ~CMountPointReader(); - - //! opens a file by index - virtual IReadFile* createAndOpenFile(u32 index); - - //! opens a file by file name - virtual IReadFile* createAndOpenFile(const io::path& filename); - - //! returns the list of files - virtual const IFileList* getFileList() const; - - //! get the class Type - virtual E_FILE_ARCHIVE_TYPE getType() const { return EFAT_FOLDER; } - - private: - - core::array<io::path> RealFileNames; - - IFileSystem *Parent; - void buildDirectory(); - }; -} // io -} // irr - -#endif // __IRR_COMPILE_WITH_MOUNT_ARCHIVE_LOADER_ -#endif // __C_MOUNT_READER_H_INCLUDED__ diff --git a/irrlicht-1.6/source/Irrlicht/CNullDriver.cpp b/irrlicht-1.6/source/Irrlicht/CNullDriver.cpp deleted file mode 100644 index 7987e2653..000000000 --- a/irrlicht-1.6/source/Irrlicht/CNullDriver.cpp +++ /dev/null @@ -1,2105 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CNullDriver.h" -#include "os.h" -#include "CImage.h" -#include "CAttributes.h" -#include "IReadFile.h" -#include "IWriteFile.h" -#include "IImageLoader.h" -#include "IImageWriter.h" -#include "IMaterialRenderer.h" -#include "CMeshManipulator.h" -#include "CColorConverter.h" - - -namespace irr -{ -namespace video -{ - -//! creates a loader which is able to load windows bitmaps -IImageLoader* createImageLoaderBMP(); - -//! creates a loader which is able to load jpeg images -IImageLoader* createImageLoaderJPG(); - -//! creates a loader which is able to load targa images -IImageLoader* createImageLoaderTGA(); - -//! creates a loader which is able to load psd images -IImageLoader* createImageLoaderPSD(); - -//! creates a loader which is able to load pcx images -IImageLoader* createImageLoaderPCX(); - -//! creates a loader which is able to load png images -IImageLoader* createImageLoaderPNG(); - -//! creates a loader which is able to load WAL images -IImageLoader* createImageLoaderWAL(); - -//! creates a loader which is able to load ppm/pgm/pbm images -IImageLoader* createImageLoaderPPM(); - -//! creates a loader which is able to load rgb images -IImageLoader* createImageLoaderRGB(); - - -//! creates a writer which is able to save bmp images -IImageWriter* createImageWriterBMP(); - -//! creates a writer which is able to save jpg images -IImageWriter* createImageWriterJPG(); - -//! creates a writer which is able to save tga images -IImageWriter* createImageWriterTGA(); - -//! creates a writer which is able to save psd images -IImageWriter* createImageWriterPSD(); - -//! creates a writer which is able to save pcx images -IImageWriter* createImageWriterPCX(); - -//! creates a writer which is able to save png images -IImageWriter* createImageWriterPNG(); - -//! creates a writer which is able to save ppm images -IImageWriter* createImageWriterPPM(); - - -//! constructor -CNullDriver::CNullDriver(io::IFileSystem* io, const core::dimension2d<u32>& screenSize) -: FileSystem(io), MeshManipulator(0), ViewPort(0,0,0,0), ScreenSize(screenSize), - PrimitivesDrawn(0), MinVertexCountForVBO(500), TextureCreationFlags(0), - AllowZWriteOnTransparent(false) -{ - #ifdef _DEBUG - setDebugName("CNullDriver"); - #endif - - setFog(); - - setTextureCreationFlag(ETCF_ALWAYS_32_BIT, true); - setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, true); - - ViewPort = core::rect<s32>(core::position2d<s32>(0,0), core::dimension2di(screenSize)); - - // create manipulator - MeshManipulator = new scene::CMeshManipulator(); - - if (FileSystem) - FileSystem->grab(); - - // create surface loader - -#ifdef _IRR_COMPILE_WITH_BMP_LOADER_ - SurfaceLoader.push_back(video::createImageLoaderBMP()); -#endif -#ifdef _IRR_COMPILE_WITH_JPG_LOADER_ - SurfaceLoader.push_back(video::createImageLoaderJPG()); -#endif -#ifdef _IRR_COMPILE_WITH_TGA_LOADER_ - SurfaceLoader.push_back(video::createImageLoaderTGA()); -#endif -#ifdef _IRR_COMPILE_WITH_PSD_LOADER_ - SurfaceLoader.push_back(video::createImageLoaderPSD()); -#endif -#ifdef _IRR_COMPILE_WITH_PCX_LOADER_ - SurfaceLoader.push_back(video::createImageLoaderPCX()); -#endif -#ifdef _IRR_COMPILE_WITH_PNG_LOADER_ - SurfaceLoader.push_back(video::createImageLoaderPNG()); -#endif -#ifdef _IRR_COMPILE_WITH_WAL_LOADER_ - SurfaceLoader.push_back(video::createImageLoaderWAL()); -#endif -#ifdef _IRR_COMPILE_WITH_PPM_LOADER_ - SurfaceLoader.push_back(video::createImageLoaderPPM()); -#endif -#ifdef _IRR_COMPILE_WITH_RGB_LOADER_ - SurfaceLoader.push_back(video::createImageLoaderRGB()); -#endif - - -#ifdef _IRR_COMPILE_WITH_BMP_WRITER_ - SurfaceWriter.push_back(video::createImageWriterBMP()); -#endif -#ifdef _IRR_COMPILE_WITH_JPG_WRITER_ - SurfaceWriter.push_back(video::createImageWriterJPG()); -#endif -#ifdef _IRR_COMPILE_WITH_TGA_WRITER_ - SurfaceWriter.push_back(video::createImageWriterTGA()); -#endif -#ifdef _IRR_COMPILE_WITH_PSD_WRITER_ - SurfaceWriter.push_back(video::createImageWriterPSD()); -#endif -#ifdef _IRR_COMPILE_WITH_PCX_WRITER_ - SurfaceWriter.push_back(video::createImageWriterPCX()); -#endif -#ifdef _IRR_COMPILE_WITH_PNG_WRITER_ - SurfaceWriter.push_back(video::createImageWriterPNG()); -#endif -#ifdef _IRR_COMPILE_WITH_PPM_WRITER_ - SurfaceWriter.push_back(video::createImageWriterPPM()); -#endif - - // set ExposedData to 0 - memset(&ExposedData, 0, sizeof(ExposedData)); - for (u32 i=0; i<video::EVDF_COUNT; ++i) - FeatureEnabled[i]=true; -} - - -//! destructor -CNullDriver::~CNullDriver() -{ - if (FileSystem) - FileSystem->drop(); - - if (MeshManipulator) - MeshManipulator->drop(); - deleteAllTextures(); - - u32 i; - for (i=0; i<SurfaceLoader.size(); ++i) - SurfaceLoader[i]->drop(); - - for (i=0; i<SurfaceWriter.size(); ++i) - SurfaceWriter[i]->drop(); - - // delete material renderers - deleteMaterialRenders(); - - // delete hardware mesh buffers - removeAllHardwareBuffers(); -} - - -//! Adds an external surface loader to the engine. -void CNullDriver::addExternalImageLoader(IImageLoader* loader) -{ - if (!loader) - return; - - loader->grab(); - SurfaceLoader.push_back(loader); -} - - -//! Adds an external surface writer to the engine. -void CNullDriver::addExternalImageWriter(IImageWriter* writer) -{ - if (!writer) - return; - - writer->grab(); - SurfaceWriter.push_back(writer); -} - - -//! Retrieve the number of image loaders -u32 CNullDriver::getImageLoaderCount() const -{ - return SurfaceLoader.size(); -} - - -//! Retrieve the given image loader -IImageLoader* CNullDriver::getImageLoader(u32 n) -{ - if(n < SurfaceLoader.size()) - return SurfaceLoader[n]; - return 0; -} - - -//! Retrieve the number of image writers -u32 CNullDriver::getImageWriterCount() const -{ - return SurfaceWriter.size(); -} - - -//! Retrieve the given image writer -IImageWriter* CNullDriver::getImageWriter(u32 n) -{ - if(n < SurfaceWriter.size()) - return SurfaceWriter[n]; - return 0; -} - - -//! deletes all textures -void CNullDriver::deleteAllTextures() -{ - // we need to remove previously set textures which might otherwise be kept in the - // last set material member. Could be optimized to reduce state changes. - setMaterial(SMaterial()); - - for (u32 i=0; i<Textures.size(); ++i) - Textures[i].Surface->drop(); - - Textures.clear(); -} - - - -//! applications must call this method before performing any rendering. returns false if failed. -bool CNullDriver::beginScene(bool backBuffer, bool zBuffer, SColor color, - void* windowId, core::rect<s32>* sourceRect) -{ - core::clearFPUException(); - PrimitivesDrawn = 0; - return true; -} - - -//! applications must call this method after performing any rendering. returns false if failed. -bool CNullDriver::endScene() -{ - FPSCounter.registerFrame(os::Timer::getRealTime(), PrimitivesDrawn); - updateAllHardwareBuffers(); - return true; -} - - -//! Disable a feature of the driver. -void CNullDriver::disableFeature(E_VIDEO_DRIVER_FEATURE feature, bool flag) -{ - FeatureEnabled[feature]=!flag; -} - - -//! queries the features of the driver, returns true if feature is available -bool CNullDriver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const -{ - return false; -} - - -//! sets transformation -void CNullDriver::setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat) -{ -} - - -//! Returns the transformation set by setTransform -const core::matrix4& CNullDriver::getTransform(E_TRANSFORMATION_STATE state) const -{ - return TransformationMatrix; -} - - -//! sets a material -void CNullDriver::setMaterial(const SMaterial& material) -{ -} - - -//! Removes a texture from the texture cache and deletes it, freeing lot of -//! memory. -void CNullDriver::removeTexture(ITexture* texture) -{ - if (!texture) - return; - - for (u32 i=0; i<Textures.size(); ++i) - { - if (Textures[i].Surface == texture) - { - texture->drop(); - Textures.erase(i); - } - } -} - - -//! Removes all texture from the texture cache and deletes them, freeing lot of -//! memory. -void CNullDriver::removeAllTextures() -{ - setMaterial ( SMaterial() ); - deleteAllTextures(); -} - - -//! Returns a texture by index -ITexture* CNullDriver::getTextureByIndex(u32 i) -{ - if ( i < Textures.size() ) - return Textures[i].Surface; - - return 0; -} - - -//! Returns amount of textures currently loaded -u32 CNullDriver::getTextureCount() const -{ - return Textures.size(); -} - - -//! Renames a texture -void CNullDriver::renameTexture(ITexture* texture, const io::path& newName) -{ - // we can do a const_cast here safely, the name of the ITexture interface - // is just readonly to prevent the user changing the texture name without invoking - // this method, because the textures will need resorting afterwards - - io::path& name = const_cast<io::path&>(texture->getName()); - name = newName; - - Textures.sort(); -} - - -//! loads a Texture -ITexture* CNullDriver::getTexture(const io::path& filename) -{ - // Identify textures by their absolute filenames if possible. - const io::path absolutePath = FileSystem->getAbsolutePath(filename); - - ITexture* texture = findTexture(absolutePath); - if (texture) - return texture; - - // Then try the raw filename, which might be in an Archive - texture = findTexture(filename); - if (texture) - return texture; - - // Now try to open the file using the complete path. - io::IReadFile* file = FileSystem->createAndOpenFile(absolutePath); - - if(!file) - { - // Try to open it using the raw filename. - file = FileSystem->createAndOpenFile(filename); - } - - if (file) - { - texture = loadTextureFromFile(file); - file->drop(); - - if (texture) - { - addTexture(texture); - texture->drop(); // drop it because we created it, one grab too much - } - else - os::Printer::log("Could not load texture", filename, ELL_ERROR); - return texture; - } - else - { - os::Printer::log("Could not open file of texture", filename, ELL_WARNING); - return 0; - } -} - - -//! loads a Texture -ITexture* CNullDriver::getTexture(io::IReadFile* file) -{ - ITexture* texture = 0; - - if (file) - { - texture = findTexture(file->getFileName()); - - if (texture) - return texture; - - texture = loadTextureFromFile(file); - - if (texture) - { - addTexture(texture); - texture->drop(); // drop it because we created it, one grab too much - } - } - - if (!texture) - os::Printer::log("Could not load texture", file->getFileName(), ELL_WARNING); - - return texture; -} - - -//! opens the file and loads it into the surface -video::ITexture* CNullDriver::loadTextureFromFile(io::IReadFile* file, const io::path& hashName ) -{ - ITexture* texture = 0; - IImage* image = createImageFromFile(file); - - if (image) - { - // create texture from surface - texture = createDeviceDependentTexture(image, hashName.size() ? hashName : file->getFileName() ); - os::Printer::log("Loaded texture", file->getFileName()); - image->drop(); - } - - return texture; -} - - -//! adds a surface, not loaded or created by the Irrlicht Engine -void CNullDriver::addTexture(video::ITexture* texture) -{ - if (texture) - { - SSurface s; - s.Surface = texture; - texture->grab(); - - Textures.push_back(s); - - // the new texture is now at the end of the texture list. when searching for - // the next new texture, the texture array will be sorted and the index of this texture - // will be changed. to let the order be more consistent to the user, sort - // the textures now already although this isn't necessary: - - Textures.sort(); - } -} - - -//! looks if the image is already loaded -video::ITexture* CNullDriver::findTexture(const io::path& filename) -{ - SSurface s; - SDummyTexture dummy(filename); - s.Surface = &dummy; - - s32 index = Textures.binary_search(s); - if (index != -1) - return Textures[index].Surface; - - return 0; -} - - -//! Creates a texture from a loaded IImage. -ITexture* CNullDriver::addTexture(const io::path& name, IImage* image) -{ - if ( 0 == name.size() || !image) - return 0; - - ITexture* t = createDeviceDependentTexture(image, name); - if (t) - { - addTexture(t); - t->drop(); - } - return t; -} - - -//! creates a Texture -ITexture* CNullDriver::addTexture(const core::dimension2d<u32>& size, - const io::path& name, ECOLOR_FORMAT format) -{ - if(IImage::isRenderTargetOnlyFormat(format)) - { - os::Printer::log("Could not create ITexture, format only supported for render target textures.", ELL_WARNING); - return 0; - } - - if ( 0 == name.size () ) - return 0; - - IImage* image = new CImage(format, size); - ITexture* t = createDeviceDependentTexture(image, name); - image->drop(); - addTexture(t); - - if (t) - t->drop(); - - return t; -} - - - -//! returns a device dependent texture from a software surface (IImage) -//! THIS METHOD HAS TO BE OVERRIDDEN BY DERIVED DRIVERS WITH OWN TEXTURES -ITexture* CNullDriver::createDeviceDependentTexture(IImage* surface, const io::path& name) -{ - return new SDummyTexture(name); -} - - -//! set or reset special render targets -bool CNullDriver::setRenderTarget(video::E_RENDER_TARGET target, bool clearTarget, - bool clearZBuffer, SColor color) -{ - if (ERT_FRAME_BUFFER==target) - return setRenderTarget(0,clearTarget, clearZBuffer, color); - else - return false; -} - - -//! sets a render target -bool CNullDriver::setRenderTarget(video::ITexture* texture, bool clearBackBuffer, - bool clearZBuffer, SColor color) -{ - return false; -} - - -//! sets a viewport -void CNullDriver::setViewPort(const core::rect<s32>& area) -{ -} - - -//! gets the area of the current viewport -const core::rect<s32>& CNullDriver::getViewPort() const -{ - return ViewPort; -} - - -//! draws a vertex primitive list -void CNullDriver::drawVertexPrimitiveList(const void* vertices, u32 vertexCount, const void* indexList, u32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType) -{ - if ((iType==EIT_16BIT) && (vertexCount>65536)) - os::Printer::log("Too many vertices for 16bit index type, render artifacts may occur."); - PrimitivesDrawn += primitiveCount; -} - - -//! draws a vertex primitive list in 2d -void CNullDriver::draw2DVertexPrimitiveList(const void* vertices, u32 vertexCount, const void* indexList, u32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType) -{ - if ((iType==EIT_16BIT) && (vertexCount>65536)) - os::Printer::log("Too many vertices for 16bit index type, render artifacts may occur."); - PrimitivesDrawn += primitiveCount; -} - - -//! draws an indexed triangle list -void CNullDriver::drawIndexedTriangleList(const S3DVertex* vertices, u32 vertexCount, const u16* indexList, u32 triangleCount) -{ - drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_STANDARD, scene::EPT_TRIANGLES, EIT_16BIT); -} - - -//! draws an indexed triangle list -void CNullDriver::drawIndexedTriangleList(const S3DVertex2TCoords* vertices, u32 vertexCount, const u16* indexList, u32 triangleCount) -{ - drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_2TCOORDS, scene::EPT_TRIANGLES, EIT_16BIT); -} - - -//! Draws an indexed triangle list. -void CNullDriver::drawIndexedTriangleList(const S3DVertexTangents* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount) -{ - drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_TANGENTS, scene::EPT_TRIANGLES, EIT_16BIT); -} - - - -//! Draws an indexed triangle fan. -void CNullDriver::drawIndexedTriangleFan(const S3DVertex* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount) -{ - drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_STANDARD, scene::EPT_TRIANGLE_FAN, EIT_16BIT); -} - - - -//! Draws an indexed triangle fan. -void CNullDriver::drawIndexedTriangleFan(const S3DVertex2TCoords* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount) -{ - drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_2TCOORDS, scene::EPT_TRIANGLE_FAN, EIT_16BIT); -} - - - -//! Draws an indexed triangle fan. -void CNullDriver::drawIndexedTriangleFan(const S3DVertexTangents* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount) -{ - drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_TANGENTS, scene::EPT_TRIANGLE_FAN, EIT_16BIT); -} - - - -//! Draws a 3d line. -void CNullDriver::draw3DLine(const core::vector3df& start, - const core::vector3df& end, SColor color) -{ -} - - - -//! Draws a 3d triangle. -void CNullDriver::draw3DTriangle(const core::triangle3df& triangle, SColor color) -{ - draw3DLine(triangle.pointA, triangle.pointB, color); - draw3DLine(triangle.pointB, triangle.pointC, color); - draw3DLine(triangle.pointC, triangle.pointA, color); -} - - - -//! Draws a 3d axis aligned box. -void CNullDriver::draw3DBox(const core::aabbox3d<f32>& box, SColor color) -{ - core::vector3df edges[8]; - box.getEdges(edges); - - // TODO: optimize into one big drawIndexPrimitive call. - - draw3DLine(edges[5], edges[1], color); - draw3DLine(edges[1], edges[3], color); - draw3DLine(edges[3], edges[7], color); - draw3DLine(edges[7], edges[5], color); - draw3DLine(edges[0], edges[2], color); - draw3DLine(edges[2], edges[6], color); - draw3DLine(edges[6], edges[4], color); - draw3DLine(edges[4], edges[0], color); - draw3DLine(edges[1], edges[0], color); - draw3DLine(edges[3], edges[2], color); - draw3DLine(edges[7], edges[6], color); - draw3DLine(edges[5], edges[4], color); -} - - - -//! draws an 2d image -void CNullDriver::draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos) -{ - if (!texture) - return; - - draw2DImage(texture,destPos, core::rect<s32>(core::position2d<s32>(0,0), - core::dimension2di(texture->getOriginalSize()))); -} - - - -//! draws a set of 2d images, using a color and the alpha channel of the -//! texture if desired. The images are drawn beginning at pos and concatenated -//! in one line. All drawings are clipped against clipRect (if != 0). -//! The subtextures are defined by the array of sourceRects and are chosen -//! by the indices given. -void CNullDriver::draw2DImageBatch(const video::ITexture* texture, - const core::position2d<s32>& pos, - const core::array<core::rect<s32> >& sourceRects, - const core::array<s32>& indices, - s32 kerningWidth, - const core::rect<s32>* clipRect, SColor color, - bool useAlphaChannelOfTexture) -{ - core::position2d<s32> target(pos); - - for (u32 i=0; i<indices.size(); ++i) - { - draw2DImage(texture, target, sourceRects[indices[i]], - clipRect, color, useAlphaChannelOfTexture); - target.X += sourceRects[indices[i]].getWidth(); - target.X += kerningWidth; - } -} - -//! draws a set of 2d images, using a color and the alpha channel of the -//! texture if desired. -void CNullDriver::draw2DImageBatch(const video::ITexture* texture, - const core::array<core::position2d<s32> >& positions, - const core::array<core::rect<s32> >& sourceRects, - const core::rect<s32>* clipRect, - SColor color, - bool useAlphaChannelOfTexture) -{ - const irr::u32 drawCount = core::min_<u32>(positions.size(), sourceRects.size()); - - for (u32 i=0; i<drawCount; ++i) - { - draw2DImage(texture, positions[i], sourceRects[i], - clipRect, color, useAlphaChannelOfTexture); - } -} - - -//! Draws a part of the texture into the rectangle. -void CNullDriver::draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect, - const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect, - const video::SColor* const colors, bool useAlphaChannelOfTexture) -{ -} - - -//! Draws a 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. -void CNullDriver::draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos, - const core::rect<s32>& sourceRect, - const core::rect<s32>* clipRect, SColor color, - bool useAlphaChannelOfTexture) -{ -} - - -//! Draws the outline of a 2d rectangle -void CNullDriver::draw2DRectangleOutline(const core::recti& pos, SColor color) -{ - draw2DLine(pos.UpperLeftCorner, core::position2di(pos.LowerRightCorner.X, pos.UpperLeftCorner.Y), color); - draw2DLine(core::position2di(pos.LowerRightCorner.X, pos.UpperLeftCorner.Y), pos.LowerRightCorner, color); - draw2DLine(pos.LowerRightCorner, core::position2di(pos.UpperLeftCorner.X, pos.LowerRightCorner.Y), color); - draw2DLine(core::position2di(pos.UpperLeftCorner.X, pos.LowerRightCorner.Y), pos.UpperLeftCorner, color); -} - - -//! Draw a 2d rectangle -void CNullDriver::draw2DRectangle(SColor color, const core::rect<s32>& pos, const core::rect<s32>* clip) -{ - draw2DRectangle(pos, color, color, color, color, clip); -} - - - -//! Draws a 2d rectangle with a gradient. -void CNullDriver::draw2DRectangle(const core::rect<s32>& pos, - SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, - const core::rect<s32>* clip) -{ -} - - - -//! Draws a 2d line. -void CNullDriver::draw2DLine(const core::position2d<s32>& start, - const core::position2d<s32>& end, SColor color) -{ -} - -//! Draws a pixel -void CNullDriver::drawPixel(u32 x, u32 y, const SColor & color) -{ -} - - -//! Draws a non filled concyclic regular 2d polyon. -void CNullDriver::draw2DPolygon(core::position2d<s32> center, - f32 radius, video::SColor color, s32 count) -{ - if (count < 2) - return; - - core::position2d<s32> first; - core::position2d<s32> a,b; - - for (s32 j=0; j<count; ++j) - { - b = a; - - f32 p = j / (f32)count * (core::PI*2); - a = center + core::position2d<s32>((s32)(sin(p)*radius), (s32)(cos(p)*radius)); - - if (j==0) - first = a; - else - draw2DLine(a, b, color); - } - - draw2DLine(a, first, color); -} - - -//! returns color format -ECOLOR_FORMAT CNullDriver::getColorFormat() const -{ - return ECF_R5G6B5; -} - - -//! returns screen size -const core::dimension2d<u32>& CNullDriver::getScreenSize() const -{ - return ScreenSize; -} - - -//! returns the current render target size, -//! or the screen size if render targets are not implemented -const core::dimension2d<u32>& CNullDriver::getCurrentRenderTargetSize() const -{ - return ScreenSize; -} - - -// returns current frames per second value -s32 CNullDriver::getFPS() const -{ - return FPSCounter.getFPS(); -} - - - -//! returns amount of primitives (mostly triangles) were drawn in the last frame. -//! very useful method for statistics. -u32 CNullDriver::getPrimitiveCountDrawn( u32 param ) const -{ - return (0 == param) ? FPSCounter.getPrimitive() : (1 == param) ? FPSCounter.getPrimitiveAverage() : FPSCounter.getPrimitiveTotal(); -} - - - -//! Sets the dynamic ambient light color. The default color is -//! (0,0,0,0) which means it is dark. -//! \param color: New color of the ambient light. -void CNullDriver::setAmbientLight(const SColorf& color) -{ -} - - - -//! \return Returns the name of the video driver. Example: In case of the DIRECT3D8 -//! driver, it would return "Direct3D8". -const wchar_t* CNullDriver::getName() const -{ - return L"Irrlicht NullDevice"; -} - - - -//! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do -//! this: Frist, draw all geometry. Then use this method, to draw the shadow -//! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow. -void CNullDriver::drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail) -{ -} - - -//! Fills the stencil shadow with color. After the shadow volume has been drawn -//! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this -//! to draw the color of the shadow. -void CNullDriver::drawStencilShadow(bool clearStencilBuffer, - video::SColor leftUpEdge, video::SColor rightUpEdge, - video::SColor leftDownEdge, video::SColor rightDownEdge) -{ -} - - -//! deletes all dynamic lights there are -void CNullDriver::deleteAllDynamicLights() -{ - Lights.set_used(0); -} - - -//! adds a dynamic light -s32 CNullDriver::addDynamicLight(const SLight& light) -{ - Lights.push_back(light); - return Lights.size() - 1; -} - -//! Turns a dynamic light on or off -//! \param lightIndex: the index returned by addDynamicLight -//! \param turnOn: true to turn the light on, false to turn it off -void CNullDriver::turnLightOn(s32 lightIndex, bool turnOn) -{ - // Do nothing -} - - -//! returns the maximal amount of dynamic lights the device can handle -u32 CNullDriver::getMaximalDynamicLightAmount() const -{ - return 0; -} - - -//! Returns current amount of dynamic lights set -//! \return Current amount of dynamic lights set -u32 CNullDriver::getDynamicLightCount() const -{ - return Lights.size(); -} - - -//! Returns light data which was previously set by IVideoDriver::addDynamicLight(). -//! \param idx: Zero based index of the light. Must be greater than 0 and smaller -//! than IVideoDriver()::getDynamicLightCount. -//! \return Light data. -const SLight& CNullDriver::getDynamicLight(u32 idx) const -{ - if ( idx < Lights.size() ) - return Lights[idx]; - else - return *((SLight*)0); -} - - -//! Creates a boolean alpha channel of the texture based of an color key. -void CNullDriver::makeColorKeyTexture(video::ITexture* texture, - video::SColor color, - bool zeroTexels) const -{ - if (!texture) - return; - - if (texture->getColorFormat() != ECF_A1R5G5B5 && - texture->getColorFormat() != ECF_A8R8G8B8 ) - { - os::Printer::log("Error: Unsupported texture color format for making color key channel.", ELL_ERROR); - return; - } - - if (texture->getColorFormat() == ECF_A1R5G5B5) - { - u16 *p = (u16*)texture->lock(); - - if (!p) - { - os::Printer::log("Could not lock texture for making color key channel.", ELL_ERROR); - return; - } - - const core::dimension2d<u32> dim = texture->getSize(); - const u32 pitch = texture->getPitch() / 2; - - // color with alpha disabled (i.e. fully transparent) - const u16 refZeroAlpha = (0x7fff & color.toA1R5G5B5()); - - const u32 pixels = pitch * dim.Height; - - for (u32 pixel = 0; pixel < pixels; ++ pixel) - { - // If the colour matches the reference colour, ignoring alphas, - // set the alpha to zero. - if(((*p) & 0x7fff) == refZeroAlpha) - { - if(zeroTexels) - (*p) = 0; - else - (*p) = refZeroAlpha; - } - - ++p; - } - - texture->unlock(); - } - else - { - u32 *p = (u32*)texture->lock(); - - if (!p) - { - os::Printer::log("Could not lock texture for making color key channel.", ELL_ERROR); - return; - } - - core::dimension2d<u32> dim = texture->getSize(); - u32 pitch = texture->getPitch() / 4; - - // color with alpha disabled (fully transparent) - const u32 refZeroAlpha = 0x00ffffff & color.color; - - const u32 pixels = pitch * dim.Height; - for (u32 pixel = 0; pixel < pixels; ++ pixel) - { - // If the colour matches the reference colour, ignoring alphas, - // set the alpha to zero. - if(((*p) & 0x00ffffff) == refZeroAlpha) - { - if(zeroTexels) - (*p) = 0; - else - (*p) = refZeroAlpha; - } - - ++p; - } - - texture->unlock(); - } -} - - - -//! Creates an boolean alpha channel of the texture based of an color key position. -void CNullDriver::makeColorKeyTexture(video::ITexture* texture, - core::position2d<s32> colorKeyPixelPos, - bool zeroTexels) const -{ - if (!texture) - return; - - if (texture->getColorFormat() != ECF_A1R5G5B5 && - texture->getColorFormat() != ECF_A8R8G8B8 ) - { - os::Printer::log("Error: Unsupported texture color format for making color key channel.", ELL_ERROR); - return; - } - - SColor colorKey; - - if (texture->getColorFormat() == ECF_A1R5G5B5) - { - u16 *p = (u16*)texture->lock(true); - - if (!p) - { - os::Printer::log("Could not lock texture for making color key channel.", ELL_ERROR); - return; - } - - u32 pitch = texture->getPitch() / 2; - - const u16 key16Bit = 0x7fff & p[colorKeyPixelPos.Y*pitch + colorKeyPixelPos.X]; - - colorKey = video::A1R5G5B5toA8R8G8B8(key16Bit); - } - else - { - u32 *p = (u32*)texture->lock(true); - - if (!p) - { - os::Printer::log("Could not lock texture for making color key channel.", ELL_ERROR); - return; - } - - u32 pitch = texture->getPitch() / 4; - colorKey = 0x00ffffff & p[colorKeyPixelPos.Y*pitch + colorKeyPixelPos.X]; - } - - texture->unlock(); - makeColorKeyTexture(texture, colorKey, zeroTexels); -} - - - -//! Creates a normal map from a height map texture. -//! \param amplitude: Constant value by which the height information is multiplied. -void CNullDriver::makeNormalMapTexture(video::ITexture* texture, f32 amplitude) const -{ - if (!texture) - return; - - if (texture->getColorFormat() != ECF_A1R5G5B5 && - texture->getColorFormat() != ECF_A8R8G8B8 ) - { - os::Printer::log("Error: Unsupported texture color format for making normal map.", ELL_ERROR); - return; - } - - core::dimension2d<u32> dim = texture->getSize(); - amplitude = amplitude / 255.0f; - f32 vh = dim.Height / (f32)dim.Width; - f32 hh = dim.Width / (f32)dim.Height; - - if (texture->getColorFormat() == ECF_A8R8G8B8) - { - // ECF_A8R8G8B8 version - - s32 *p = (s32*)texture->lock(); - - if (!p) - { - os::Printer::log("Could not lock texture for making normal map.", ELL_ERROR); - return; - } - - // copy texture - - u32 pitch = texture->getPitch() / 4; - - s32* in = new s32[dim.Height * pitch]; - memcpy(in, p, dim.Height * pitch * 4); - - for (s32 x=0; x < s32(pitch); ++x) - for (s32 y=0; y < s32(dim.Height); ++y) - { - // TODO: this could be optimized really a lot - - core::vector3df h1((x-1)*hh, nml32(x-1, y, pitch, dim.Height, in)*amplitude, y*vh); - core::vector3df h2((x+1)*hh, nml32(x+1, y, pitch, dim.Height, in)*amplitude, y*vh); - //core::vector3df v1(x*hh, nml32(x, y-1, pitch, dim.Height, in)*amplitude, (y-1)*vh); - //core::vector3df v2(x*hh, nml32(x, y+1, pitch, dim.Height, in)*amplitude, (y+1)*vh); - core::vector3df v1(x*hh, nml32(x, y+1, pitch, dim.Height, in)*amplitude, (y-1)*vh); - core::vector3df v2(x*hh, nml32(x, y-1, pitch, dim.Height, in)*amplitude, (y+1)*vh); - - core::vector3df v = v1-v2; - core::vector3df h = h1-h2; - - core::vector3df n = v.crossProduct(h); - n.normalize(); - n *= 0.5f; - n += core::vector3df(0.5f,0.5f,0.5f); // now between 0 and 1 - n *= 255.0f; - - s32 height = (s32)nml32(x, y, pitch, dim.Height, in); - p[y*pitch + x] = video::SColor( - height, // store height in alpha - (s32)n.X, (s32)n.Z, (s32)n.Y).color; - } - - delete [] in; - texture->unlock(); - } - else - { - // ECF_A1R5G5B5 version - - s16 *p = (s16*)texture->lock(); - - if (!p) - { - os::Printer::log("Could not lock texture for making normal map.", ELL_ERROR); - return; - } - - u32 pitch = texture->getPitch() / 2; - - // copy texture - - s16* in = new s16[dim.Height * pitch]; - memcpy(in, p, dim.Height * pitch * 2); - - for (s32 x=0; x < s32(pitch); ++x) - for (s32 y=0; y < s32(dim.Height); ++y) - { - // TODO: this could be optimized really a lot - - core::vector3df h1((x-1)*hh, nml16(x-1, y, pitch, dim.Height, in)*amplitude, y*vh); - core::vector3df h2((x+1)*hh, nml16(x+1, y, pitch, dim.Height, in)*amplitude, y*vh); - core::vector3df v1(x*hh, nml16(x, y-1, pitch, dim.Height, in)*amplitude, (y-1)*vh); - core::vector3df v2(x*hh, nml16(x, y+1, pitch, dim.Height, in)*amplitude, (y+1)*vh); - - core::vector3df v = v1-v2; - core::vector3df h = h1-h2; - - core::vector3df n = v.crossProduct(h); - n.normalize(); - n *= 0.5f; - n += core::vector3df(0.5f,0.5f,0.5f); // now between 0 and 1 - n *= 255.0f; - - p[y*pitch + x] = video::RGBA16((u32)n.X, (u32)n.Z, (u32)n.Y); - } - - delete [] in; - texture->unlock(); - } - - texture->regenerateMipMapLevels(); -} - - -//! Returns the maximum amount of primitives (mostly vertices) which -//! the device is able to render with one drawIndexedTriangleList -//! call. -u32 CNullDriver::getMaximalPrimitiveCount() const -{ - return 0xFFFFFFFF; -} - - -//! checks triangle count and print warning if wrong -bool CNullDriver::checkPrimitiveCount(u32 prmCount) const -{ - const u32 m = getMaximalPrimitiveCount(); - - if (prmCount > m) - { - char tmp[1024]; - sprintf(tmp,"Could not draw triangles, too many primitives(%u), maxium is %u.", prmCount, m); - os::Printer::log(tmp, ELL_ERROR); - return false; - } - - return true; -} - -//! Enables or disables a texture creation flag. -void CNullDriver::setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled) -{ - if (enabled && ((flag == ETCF_ALWAYS_16_BIT) || (flag == ETCF_ALWAYS_32_BIT) - || (flag == ETCF_OPTIMIZED_FOR_QUALITY) || (flag == ETCF_OPTIMIZED_FOR_SPEED))) - { - // disable other formats - setTextureCreationFlag(ETCF_ALWAYS_16_BIT, false); - setTextureCreationFlag(ETCF_ALWAYS_32_BIT, false); - setTextureCreationFlag(ETCF_OPTIMIZED_FOR_QUALITY, false); - setTextureCreationFlag(ETCF_OPTIMIZED_FOR_SPEED, false); - } - - // set flag - TextureCreationFlags = (TextureCreationFlags & (~flag)) | - ((((u32)!enabled)-1) & flag); -} - - -//! Returns if a texture creation flag is enabled or disabled. -bool CNullDriver::getTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag) const -{ - return (TextureCreationFlags & flag)!=0; -} - - -//! Creates a software image from a file. -IImage* CNullDriver::createImageFromFile(const io::path& filename) -{ - if (!filename.size()) - return 0; - - IImage* image = 0; - io::IReadFile* file = FileSystem->createAndOpenFile(filename); - - if (file) - { - image = createImageFromFile(file); - file->drop(); - } - else - os::Printer::log("Could not open file of image", filename, ELL_WARNING); - - return image; -} - - -//! Creates a software image from a file. -IImage* CNullDriver::createImageFromFile(io::IReadFile* file) -{ - if (!file) - return 0; - - IImage* image = 0; - - u32 i; - - // try to load file based on file extension - for (i=0; i<SurfaceLoader.size(); ++i) - { - if (SurfaceLoader[i]->isALoadableFileExtension(file->getFileName())) - { - // reset file position which might have changed due to previous loadImage calls - file->seek(0); - image = SurfaceLoader[i]->loadImage(file); - if (image) - return image; - } - } - - // try to load file based on what is in it - for (i=0; i<SurfaceLoader.size(); ++i) - { - // dito - file->seek(0); - if (SurfaceLoader[i]->isALoadableFileFormat(file)) - { - file->seek(0); - image = SurfaceLoader[i]->loadImage(file); - if (image) - return image; - } - } - - return 0; // failed to load -} - - -//! Writes the provided image to disk file -bool CNullDriver::writeImageToFile(IImage* image, const io::path& filename,u32 param) -{ - io::IWriteFile* file = FileSystem->createAndWriteFile(filename); - if(!file) - return false; - - bool result = writeImageToFile(image, file, param); - file->drop(); - - return result; -} - -//! Writes the provided image to a file. -bool CNullDriver::writeImageToFile(IImage* image, io::IWriteFile * file, u32 param) -{ - if(!file) - return false; - - for (u32 i=0; i<SurfaceWriter.size(); ++i) - { - if (SurfaceWriter[i]->isAWriteableFileExtension(file->getFileName())) - { - bool written = SurfaceWriter[i]->writeImage(file, image, param); - if (written) - return true; - } - } - return false; // failed to write -} - - -//! Creates a software image from a byte array. -IImage* CNullDriver::createImageFromData(ECOLOR_FORMAT format, - const core::dimension2d<u32>& size, - void *data, bool ownForeignMemory, - bool deleteMemory) -{ - if(IImage::isRenderTargetOnlyFormat(format)) - { - os::Printer::log("Could not create IImage, format only supported for render target textures.", ELL_WARNING); - return 0; - } - - return new CImage(format, size, data, ownForeignMemory, deleteMemory); -} - - -//! Creates an empty software image. -IImage* CNullDriver::createImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size) -{ - if(IImage::isRenderTargetOnlyFormat(format)) - { - os::Printer::log("Could not create IImage, format only supported for render target textures.", ELL_WARNING); - return 0; - } - - return new CImage(format, size); -} - - -//! Creates a software image from another image. -IImage* CNullDriver::createImage(ECOLOR_FORMAT format, IImage *imageToCopy) -{ - if(IImage::isRenderTargetOnlyFormat(format)) - { - os::Printer::log("Could not create IImage, format only supported for render target textures.", ELL_WARNING); - return 0; - } - - return new CImage(format, imageToCopy); -} - - -//! Creates a software image from part of another image. -IImage* CNullDriver::createImage(IImage* imageToCopy, const core::position2d<s32>& pos, const core::dimension2d<u32>& size) -{ - return new CImage(imageToCopy, pos, size); -} - - -//! Creates a software image from part of a texture. -IImage* CNullDriver::createImage(ITexture* texture, const core::position2d<s32>& pos, const core::dimension2d<u32>& size) -{ - if (pos==core::position2di(0,0) && size == texture->getSize()) - { - IImage* image = new CImage(texture->getColorFormat(), size, texture->lock(true), false); - texture->unlock(); - return image; - } - else - { - // make sure to avoid buffer overruns - // make the vector a separate variable for g++ 3.x - const core::vector2d<u32> leftUpper(core::clamp(static_cast<u32>(pos.X), 0u, texture->getSize().Width), - core::clamp(static_cast<u32>(pos.Y), 0u, texture->getSize().Height)); - const core::rect<u32> clamped(leftUpper, - core::dimension2du(core::clamp(static_cast<u32>(size.Width), 0u, texture->getSize().Width), - core::clamp(static_cast<u32>(size.Height), 0u, texture->getSize().Height))); - if (!clamped.isValid()) - return 0; - void* src = texture->lock(true); - if (!src) - return 0; - IImage* image = new CImage(texture->getColorFormat(), clamped.getSize()); - void* dst = image->lock(); - for (u32 i=clamped.UpperLeftCorner.X; i<clamped.getHeight(); ++i) - { - video::CColorConverter::convert_viaFormat(src, texture->getColorFormat(), clamped.getWidth(), dst, image->getColorFormat()); - } - image->unlock(); - texture->unlock(); - return image; - } -} - - -//! Sets the fog mode. -void CNullDriver::setFog(SColor color, E_FOG_TYPE fogType, f32 start, f32 end, - f32 density, bool pixelFog, bool rangeFog) -{ - FogColor = color; - FogType = fogType; - FogStart = start; - FogEnd = end; - FogDensity = density; - PixelFog = pixelFog; - RangeFog = rangeFog; -} - - -//! Draws a mesh buffer -void CNullDriver::drawMeshBuffer(const scene::IMeshBuffer* mb) -{ - if (!mb) - return; - - //IVertexBuffer and IIndexBuffer later - SHWBufferLink *HWBuffer=getBufferLink(mb); - - if (HWBuffer) - drawHardwareBuffer(HWBuffer); - else - drawVertexPrimitiveList(mb->getVertices(), mb->getVertexCount(), mb->getIndices(), mb->getIndexCount()/3, mb->getVertexType(), scene::EPT_TRIANGLES, mb->getIndexType()); -} - - -CNullDriver::SHWBufferLink *CNullDriver::getBufferLink(const scene::IMeshBuffer* mb) -{ - if (!mb || !isHardwareBufferRecommend(mb)) - return 0; - - //search for hardware links - core::map< const scene::IMeshBuffer*,SHWBufferLink* >::Node* node = HWBufferMap.find(mb); - if (node) - return node->getValue(); - - return createHardwareBuffer(mb); //no hardware links, and mesh wants one, create it -} - - -//! Update all hardware buffers, remove unused ones -void CNullDriver::updateAllHardwareBuffers() -{ - core::map<const scene::IMeshBuffer*,SHWBufferLink*>::ParentFirstIterator Iterator=HWBufferMap.getParentFirstIterator(); - - for (;!Iterator.atEnd();Iterator++) - { - SHWBufferLink *Link=Iterator.getNode()->getValue(); - - Link->LastUsed++; - if (Link->LastUsed>20000) - { - deleteHardwareBuffer(Link); - - // todo: needs better fix - Iterator = HWBufferMap.getParentFirstIterator(); - } - } -} - - -void CNullDriver::deleteHardwareBuffer(SHWBufferLink *HWBuffer) -{ - if (!HWBuffer) - return; - HWBufferMap.remove(HWBuffer->MeshBuffer); - delete HWBuffer; -} - - -//! Remove hardware buffer -void CNullDriver::removeHardwareBuffer(const scene::IMeshBuffer* mb) -{ - core::map<const scene::IMeshBuffer*,SHWBufferLink*>::Node* node = HWBufferMap.find(mb); - if (node) - deleteHardwareBuffer(node->getValue()); -} - - -//! Remove all hardware buffers -void CNullDriver::removeAllHardwareBuffers() -{ - while (HWBufferMap.size()) - deleteHardwareBuffer(HWBufferMap.getRoot()->getValue()); -} - - -bool CNullDriver::isHardwareBufferRecommend(const scene::IMeshBuffer* mb) -{ - if (!mb || (mb->getHardwareMappingHint_Index()==scene::EHM_NEVER && mb->getHardwareMappingHint_Vertex()==scene::EHM_NEVER)) - return false; - - if (mb->getVertexCount()<MinVertexCountForVBO) - return false; - - return true; -} - - -//! Only used by the internal engine. Used to notify the driver that -//! the window was resized. -void CNullDriver::OnResize(const core::dimension2d<u32>& size) -{ - if (ViewPort.getWidth() == (s32)ScreenSize.Width && - ViewPort.getHeight() == (s32)ScreenSize.Height) - ViewPort = core::rect<s32>(core::position2d<s32>(0,0), - core::dimension2di(size)); - - ScreenSize = size; -} - - -// adds a material renderer and drops it afterwards. To be used for internal creation -s32 CNullDriver::addAndDropMaterialRenderer(IMaterialRenderer* m) -{ - s32 i = addMaterialRenderer(m); - - if (m) - m->drop(); - - return i; -} - - -//! Adds a new material renderer to the video device. -s32 CNullDriver::addMaterialRenderer(IMaterialRenderer* renderer, const char* name) -{ - if (!renderer) - return -1; - - SMaterialRenderer r; - r.Renderer = renderer; - r.Name = name; - - if (name == 0 && (MaterialRenderers.size() < (sizeof(sBuiltInMaterialTypeNames) / sizeof(char*))-1 )) - { - // set name of built in renderer so that we don't have to implement name - // setting in all available renderers. - r.Name = sBuiltInMaterialTypeNames[MaterialRenderers.size()]; - } - - MaterialRenderers.push_back(r); - renderer->grab(); - - return MaterialRenderers.size()-1; -} - - -//! Sets the name of a material renderer. -void CNullDriver::setMaterialRendererName(s32 idx, const char* name) -{ - if (idx < s32(sizeof(sBuiltInMaterialTypeNames) / sizeof(char*))-1 || - idx >= (s32)MaterialRenderers.size()) - return; - - MaterialRenderers[idx].Name = name; -} - - -//! Creates material attributes list from a material, usable for serialization and more. -io::IAttributes* CNullDriver::createAttributesFromMaterial(const video::SMaterial& material) -{ - io::CAttributes* attr = new io::CAttributes(this); - - attr->addEnum("Type", material.MaterialType, sBuiltInMaterialTypeNames); - - attr->addColor("Ambient", material.AmbientColor); - attr->addColor("Diffuse", material.DiffuseColor); - attr->addColor("Emissive", material.EmissiveColor); - attr->addColor("Specular", material.SpecularColor); - - attr->addFloat("Shininess", material.Shininess); - attr->addFloat("Param1", material.MaterialTypeParam); - attr->addFloat("Param2", material.MaterialTypeParam2); - - core::stringc prefix="Texture"; - u32 i; - for (i=0; i<MATERIAL_MAX_TEXTURES; ++i) - attr->addTexture((prefix+core::stringc(i+1)).c_str(), material.getTexture(i)); - - attr->addBool("Wireframe", material.Wireframe); - attr->addBool("GouraudShading", material.GouraudShading); - attr->addBool("Lighting", material.Lighting); - attr->addBool("ZWriteEnable", material.ZWriteEnable); - attr->addInt("ZBuffer", material.ZBuffer); - attr->addBool("BackfaceCulling", material.BackfaceCulling); - attr->addBool("FrontfaceCulling", material.FrontfaceCulling); - attr->addBool("FogEnable", material.FogEnable); - attr->addBool("NormalizeNormals", material.NormalizeNormals); - attr->addInt("AntiAliasing", material.AntiAliasing); - attr->addInt("ColorMask", material.ColorMask); - - prefix = "BilinearFilter"; - for (i=0; i<MATERIAL_MAX_TEXTURES; ++i) - attr->addBool((prefix+core::stringc(i+1)).c_str(), material.TextureLayer[i].BilinearFilter); - prefix = "TrilinearFilter"; - for (i=0; i<MATERIAL_MAX_TEXTURES; ++i) - attr->addBool((prefix+core::stringc(i+1)).c_str(), material.TextureLayer[i].TrilinearFilter); - prefix = "AnisotropicFilter"; - for (i=0; i<MATERIAL_MAX_TEXTURES; ++i) - attr->addInt((prefix+core::stringc(i+1)).c_str(), material.TextureLayer[i].AnisotropicFilter); - prefix="TextureWrap"; - for (i=0; i<MATERIAL_MAX_TEXTURES; ++i) - attr->addEnum((prefix+core::stringc(i+1)).c_str(), material.TextureLayer[i].TextureWrap, aTextureClampNames); - prefix="LODBias"; - for (i=0; i<MATERIAL_MAX_TEXTURES; ++i) - attr->addInt((prefix+core::stringc(i+1)).c_str(), material.TextureLayer[i].LODBias); - - return attr; -} - - -//! Fills an SMaterial structure from attributes. -void CNullDriver::fillMaterialStructureFromAttributes(video::SMaterial& outMaterial, io::IAttributes* attr) -{ - outMaterial.MaterialType = video::EMT_SOLID; - - core::stringc name = attr->getAttributeAsString("Type"); - - u32 i; - - for ( i=0; i < MaterialRenderers.size(); ++i) - if ( name == MaterialRenderers[i].Name ) - { - outMaterial.MaterialType = (video::E_MATERIAL_TYPE)i; - break; - } - - outMaterial.AmbientColor = attr->getAttributeAsColor("Ambient"); - outMaterial.DiffuseColor = attr->getAttributeAsColor("Diffuse"); - outMaterial.EmissiveColor = attr->getAttributeAsColor("Emissive"); - outMaterial.SpecularColor = attr->getAttributeAsColor("Specular"); - - outMaterial.Shininess = attr->getAttributeAsFloat("Shininess"); - outMaterial.MaterialTypeParam = attr->getAttributeAsFloat("Param1"); - outMaterial.MaterialTypeParam2 = attr->getAttributeAsFloat("Param2"); - - core::stringc prefix="Texture"; - for (i=0; i<MATERIAL_MAX_TEXTURES; ++i) - outMaterial.setTexture(i, attr->getAttributeAsTexture((prefix+core::stringc(i+1)).c_str())); - - outMaterial.Wireframe = attr->getAttributeAsBool("Wireframe"); - outMaterial.GouraudShading = attr->getAttributeAsBool("GouraudShading"); - outMaterial.Lighting = attr->getAttributeAsBool("Lighting"); - outMaterial.ZWriteEnable = attr->getAttributeAsBool("ZWriteEnable"); - outMaterial.ZBuffer = (u8)attr->getAttributeAsInt("ZBuffer"); - outMaterial.BackfaceCulling = attr->getAttributeAsBool("BackfaceCulling"); - outMaterial.FrontfaceCulling = attr->getAttributeAsBool("FrontfaceCulling"); - outMaterial.FogEnable = attr->getAttributeAsBool("FogEnable"); - outMaterial.NormalizeNormals = attr->getAttributeAsBool("NormalizeNormals"); - // default 0 is ok - outMaterial.AntiAliasing = attr->getAttributeAsInt("AntiAliasing"); - if (attr->existsAttribute("ColorMask")) - outMaterial.ColorMask = attr->getAttributeAsInt("ColorMask"); - prefix = "BilinearFilter"; - if (attr->existsAttribute(prefix.c_str())) // legacy - outMaterial.setFlag(EMF_BILINEAR_FILTER, attr->getAttributeAsBool(prefix.c_str())); - else - for (i=0; i<MATERIAL_MAX_TEXTURES; ++i) - outMaterial.TextureLayer[i].BilinearFilter = attr->getAttributeAsBool((prefix+core::stringc(i+1)).c_str()); - - prefix = "TrilinearFilter"; - if (attr->existsAttribute(prefix.c_str())) // legacy - outMaterial.setFlag(EMF_TRILINEAR_FILTER, attr->getAttributeAsBool(prefix.c_str())); - else - for (i=0; i<MATERIAL_MAX_TEXTURES; ++i) - outMaterial.TextureLayer[i].TrilinearFilter = attr->getAttributeAsBool((prefix+core::stringc(i+1)).c_str()); - - prefix = "AnisotropicFilter"; - if (attr->existsAttribute(prefix.c_str())) // legacy - outMaterial.setFlag(EMF_ANISOTROPIC_FILTER, attr->getAttributeAsBool(prefix.c_str())); - else - for (i=0; i<MATERIAL_MAX_TEXTURES; ++i) - outMaterial.TextureLayer[i].AnisotropicFilter = attr->getAttributeAsInt((prefix+core::stringc(i+1)).c_str()); - - prefix = "TextureWrap"; - for (i=0; i<MATERIAL_MAX_TEXTURES; ++i) - outMaterial.TextureLayer[i].TextureWrap = (E_TEXTURE_CLAMP)attr->getAttributeAsEnumeration((prefix+core::stringc(i+1)).c_str(), aTextureClampNames); - - // default 0 is ok - prefix="LODBias"; - for (i=0; i<MATERIAL_MAX_TEXTURES; ++i) - outMaterial.TextureLayer[i].LODBias = attr->getAttributeAsInt((prefix+core::stringc(i+1)).c_str()); -} - - -//! Returns driver and operating system specific data about the IVideoDriver. -const SExposedVideoData& CNullDriver::getExposedVideoData() -{ - return ExposedData; -} - - -//! Returns type of video driver -E_DRIVER_TYPE CNullDriver::getDriverType() const -{ - return EDT_NULL; -} - - -//! deletes all material renderers -void CNullDriver::deleteMaterialRenders() -{ - // delete material renderers - for (u32 i=0; i<MaterialRenderers.size(); ++i) - if (MaterialRenderers[i].Renderer) - MaterialRenderers[i].Renderer->drop(); - - MaterialRenderers.clear(); -} - - -//! Returns pointer to material renderer or null -IMaterialRenderer* CNullDriver::getMaterialRenderer(u32 idx) -{ - if ( idx < MaterialRenderers.size() ) - return MaterialRenderers[idx].Renderer; - else - return 0; -} - - -//! Returns amount of currently available material renderers. -u32 CNullDriver::getMaterialRendererCount() const -{ - return MaterialRenderers.size(); -} - - -//! Returns name of the material renderer -const char* CNullDriver::getMaterialRendererName(u32 idx) const -{ - if ( idx < MaterialRenderers.size() ) - return MaterialRenderers[idx].Name.c_str(); - - return 0; -} - - -//! Returns pointer to the IGPUProgrammingServices interface. -IGPUProgrammingServices* CNullDriver::getGPUProgrammingServices() -{ - return 0; -} - - -//! Adds a new material renderer to the VideoDriver, based on a high level shading -//! language. Currently only HLSL in D3D9 is supported. -s32 CNullDriver::addHighLevelShaderMaterial( - const c8* vertexShaderProgram, - const c8* vertexShaderEntryPointName, - E_VERTEX_SHADER_TYPE vsCompileTarget, - const c8* pixelShaderProgram, - const c8* pixelShaderEntryPointName, - E_PIXEL_SHADER_TYPE psCompileTarget, - IShaderConstantSetCallBack* callback, - E_MATERIAL_TYPE baseMaterial, - s32 userData) -{ - os::Printer::log("High level shader materials not available (yet) in this driver, sorry"); - return -1; -} - - -//! Like IGPUProgrammingServices::addShaderMaterial() (look there for a detailed description), -//! but tries to load the programs from files. -s32 CNullDriver::addHighLevelShaderMaterialFromFiles( - const io::path& vertexShaderProgram, - const c8* vertexShaderEntryPointName, - E_VERTEX_SHADER_TYPE vsCompileTarget, - const io::path& pixelShaderProgram, - const c8* pixelShaderEntryPointName, - E_PIXEL_SHADER_TYPE psCompileTarget, - IShaderConstantSetCallBack* callback, - E_MATERIAL_TYPE baseMaterial, - s32 userData) -{ - io::IReadFile* vsfile = 0; - io::IReadFile* psfile = 0; - - if (vertexShaderProgram.size() ) - { - vsfile = FileSystem->createAndOpenFile(vertexShaderProgram); - if (!vsfile) - { - os::Printer::log("Could not open vertex shader program file", - vertexShaderProgram, ELL_WARNING); - return -1; - } - } - - if (pixelShaderProgram.size() ) - { - psfile = FileSystem->createAndOpenFile(pixelShaderProgram); - if (!psfile) - { - os::Printer::log("Could not open pixel shader program file", - pixelShaderProgram, ELL_WARNING); - if (vsfile) - vsfile->drop(); - return -1; - } - } - - s32 result = addHighLevelShaderMaterialFromFiles( - vsfile, vertexShaderEntryPointName, vsCompileTarget, - psfile, pixelShaderEntryPointName, psCompileTarget, - callback, baseMaterial, userData); - - if (psfile) - psfile->drop(); - - if (vsfile) - vsfile->drop(); - - return result; -} - - -//! Like IGPUProgrammingServices::addShaderMaterial() (look there for a detailed description), -//! but tries to load the programs from files. -s32 CNullDriver::addHighLevelShaderMaterialFromFiles( - io::IReadFile* vertexShaderProgram, - const c8* vertexShaderEntryPointName, - E_VERTEX_SHADER_TYPE vsCompileTarget, - io::IReadFile* pixelShaderProgram, - const c8* pixelShaderEntryPointName, - E_PIXEL_SHADER_TYPE psCompileTarget, - IShaderConstantSetCallBack* callback, - E_MATERIAL_TYPE baseMaterial, - s32 userData) -{ - c8* vs = 0; - c8* ps = 0; - - if (vertexShaderProgram) - { - const long size = vertexShaderProgram->getSize(); - if (size) - { - vs = new c8[size+1]; - vertexShaderProgram->read(vs, size); - vs[size] = 0; - } - } - - if (pixelShaderProgram) - { - const long size = pixelShaderProgram->getSize(); - if (size) - { - // if both handles are the same we must reset the file - if (pixelShaderProgram==vertexShaderProgram) - pixelShaderProgram->seek(0); - ps = new c8[size+1]; - pixelShaderProgram->read(ps, size); - ps[size] = 0; - } - } - - s32 result = this->addHighLevelShaderMaterial( - vs, vertexShaderEntryPointName, vsCompileTarget, - ps, pixelShaderEntryPointName, psCompileTarget, - callback, baseMaterial, userData); - - delete [] vs; - delete [] ps; - - return result; -} - - -//! Adds a new material renderer to the VideoDriver, using pixel and/or -//! vertex shaders to render geometry. -s32 CNullDriver::addShaderMaterial(const c8* vertexShaderProgram, - const c8* pixelShaderProgram, - IShaderConstantSetCallBack* callback, - E_MATERIAL_TYPE baseMaterial, - s32 userData) -{ - os::Printer::log("Shader materials not implemented yet in this driver, sorry."); - return -1; -} - - -//! Like IGPUProgrammingServices::addShaderMaterial(), but tries to load the -//! programs from files. -s32 CNullDriver::addShaderMaterialFromFiles(io::IReadFile* vertexShaderProgram, - io::IReadFile* pixelShaderProgram, - IShaderConstantSetCallBack* callback, - E_MATERIAL_TYPE baseMaterial, - s32 userData) -{ - c8* vs = 0; - c8* ps = 0; - - if (vertexShaderProgram) - { - const long size = vertexShaderProgram->getSize(); - if (size) - { - vs = new c8[size+1]; - vertexShaderProgram->read(vs, size); - vs[size] = 0; - } - } - - if (pixelShaderProgram) - { - const long size = pixelShaderProgram->getSize(); - if (size) - { - ps = new c8[size+1]; - pixelShaderProgram->read(ps, size); - ps[size] = 0; - } - } - - s32 result = addShaderMaterial(vs, ps, callback, baseMaterial, userData); - - delete [] vs; - delete [] ps; - - return result; -} - - -//! Like IGPUProgrammingServices::addShaderMaterial(), but tries to load the -//! programs from files. -s32 CNullDriver::addShaderMaterialFromFiles(const io::path& vertexShaderProgramFileName, - const io::path& pixelShaderProgramFileName, - IShaderConstantSetCallBack* callback, - E_MATERIAL_TYPE baseMaterial, - s32 userData) -{ - io::IReadFile* vsfile = 0; - io::IReadFile* psfile = 0; - - if (vertexShaderProgramFileName.size()) - { - vsfile = FileSystem->createAndOpenFile(vertexShaderProgramFileName); - if (!vsfile) - { - os::Printer::log("Could not open vertex shader program file", - vertexShaderProgramFileName, ELL_WARNING); - return -1; - } - } - - if (pixelShaderProgramFileName.size()) - { - psfile = FileSystem->createAndOpenFile(pixelShaderProgramFileName); - if (!psfile) - { - os::Printer::log("Could not open pixel shader program file", - pixelShaderProgramFileName, ELL_WARNING); - if (vsfile) - vsfile->drop(); - return -1; - } - } - - s32 result = addShaderMaterialFromFiles(vsfile, psfile, callback, - baseMaterial, userData); - - if (psfile) - psfile->drop(); - - if (vsfile) - vsfile->drop(); - - return result; -} - - -//! Creates a render target texture. -ITexture* CNullDriver::addRenderTargetTexture(const core::dimension2d<u32>& size, - const io::path&name, const ECOLOR_FORMAT format) -{ - return 0; -} - - -//! Clears the ZBuffer. -void CNullDriver::clearZBuffer() -{ -} - - -//! Returns a pointer to the mesh manipulator. -scene::IMeshManipulator* CNullDriver::getMeshManipulator() -{ - return MeshManipulator; -} - - -//! Returns an image created from the last rendered frame. -IImage* CNullDriver::createScreenShot() -{ - return 0; -} - - -// prints renderer version -void CNullDriver::printVersion() -{ - core::stringw namePrint = L"Using renderer: "; - namePrint += getName(); - os::Printer::log(namePrint.c_str(), ELL_INFORMATION); -} - - -//! creates a video driver -IVideoDriver* createNullDriver(io::IFileSystem* io, const core::dimension2d<u32>& screenSize) -{ - CNullDriver* nullDriver = new CNullDriver(io, screenSize); - - // create empty material renderers - for(u32 i=0; sBuiltInMaterialTypeNames[i]; ++i) - { - IMaterialRenderer* imr = new IMaterialRenderer(); - nullDriver->addMaterialRenderer(imr); - imr->drop(); - } - - return nullDriver; -} - - -//! Set/unset a clipping plane. -//! There are at least 6 clipping planes available for the user to set at will. -//! \param index: The plane index. Must be between 0 and MaxUserClipPlanes. -//! \param plane: The plane itself. -//! \param enable: If true, enable the clipping plane else disable it. -bool CNullDriver::setClipPlane(u32 index, const core::plane3df& plane, bool enable) -{ - return false; -} - - -//! Enable/disable a clipping plane. -void CNullDriver::enableClipPlane(u32 index, bool enable) -{ - // not necessary -} - - -ITexture* CNullDriver::createRenderTargetTexture(const core::dimension2d<u32>& size, - const c8* name) -{ - os::Printer::log("createRenderTargetTexture is deprecated, use addRenderTargetTexture instead"); - ITexture* tex = addRenderTargetTexture(size, name); - tex->grab(); - return tex; -} - - -void CNullDriver::setMinHardwareBufferVertexCount(u32 count) -{ - MinVertexCountForVBO = count; -} - - -SOverrideMaterial& CNullDriver::getOverrideMaterial() -{ - return OverrideMaterial; -} - -} // end namespace -} // end namespace diff --git a/irrlicht-1.6/source/Irrlicht/CNullDriver.h b/irrlicht-1.6/source/Irrlicht/CNullDriver.h deleted file mode 100644 index 3d9c198f7..000000000 --- a/irrlicht-1.6/source/Irrlicht/CNullDriver.h +++ /dev/null @@ -1,715 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_VIDEO_NULL_H_INCLUDED__ -#define __C_VIDEO_NULL_H_INCLUDED__ - -#include "IVideoDriver.h" -#include "IFileSystem.h" -#include "IImagePresenter.h" -#include "IGPUProgrammingServices.h" -#include "irrArray.h" -#include "irrString.h" -#include "irrMap.h" -#include "IAttributes.h" -#include "IMeshBuffer.h" -#include "CFPSCounter.h" -#include "S3DVertex.h" -#include "SVertexIndex.h" -#include "SLight.h" -#include "SExposedVideoData.h" - -namespace irr -{ -namespace io -{ - class IWriteFile; - class IReadFile; -} // end namespace io -namespace video -{ - class IImageLoader; - class IImageWriter; - - class CNullDriver : public IVideoDriver, public IGPUProgrammingServices - { - public: - - //! constructor - CNullDriver(io::IFileSystem* io, const core::dimension2d<u32>& screenSize); - - //! destructor - virtual ~CNullDriver(); - - virtual bool beginScene(bool backBuffer=true, bool zBuffer=true, - SColor color=SColor(255,0,0,0), void* windowId=0, - core::rect<s32>* sourceRect=0); - - virtual bool endScene(); - - //! Disable a feature of the driver. - virtual void disableFeature(E_VIDEO_DRIVER_FEATURE feature, bool flag=true); - - //! queries the features of the driver, returns true if feature is available - virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const; - - //! sets transformation - virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat); - - //! Retrieve the number of image loaders - virtual u32 getImageLoaderCount() const; - - //! Retrieve the given image loader - virtual IImageLoader* getImageLoader(u32 n); - - //! Retrieve the number of image writers - virtual u32 getImageWriterCount() const; - - //! Retrieve the given image writer - virtual IImageWriter* getImageWriter(u32 n); - - //! sets a material - virtual void setMaterial(const SMaterial& material); - - //! loads a Texture - virtual ITexture* getTexture(const io::path& filename); - - //! loads a Texture - virtual ITexture* getTexture(io::IReadFile* file); - - //! Returns a texture by index - virtual ITexture* getTextureByIndex(u32 index); - - //! Returns amount of textures currently loaded - virtual u32 getTextureCount() const; - - //! Renames a texture - virtual void renameTexture(ITexture* texture, const io::path& newName); - - //! creates a Texture - virtual ITexture* addTexture(const core::dimension2d<u32>& size, const io::path& name, ECOLOR_FORMAT format = ECF_A8R8G8B8); - - //! sets a render target - virtual bool setRenderTarget(video::ITexture* texture, bool clearBackBuffer, - bool clearZBuffer, SColor color); - - //! set or reset special render targets - virtual bool setRenderTarget(video::E_RENDER_TARGET target, bool clearTarget, - bool clearZBuffer, SColor color); - - //! sets a viewport - virtual void setViewPort(const core::rect<s32>& area); - - //! gets the area of the current viewport - virtual const core::rect<s32>& getViewPort() const; - - //! draws a vertex primitive list - virtual void drawVertexPrimitiveList(const void* vertices, u32 vertexCount, - const void* indexList, u32 primitiveCount, - E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType); - - //! draws a vertex primitive list in 2d - virtual void draw2DVertexPrimitiveList(const void* vertices, u32 vertexCount, - const void* indexList, u32 primitiveCount, - E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType); - - //! draws an indexed triangle list - virtual void drawIndexedTriangleList(const S3DVertex* vertices, u32 vertexCount, const u16* indexList, u32 triangleCount); - - //! draws an indexed triangle list - virtual void drawIndexedTriangleList(const S3DVertex2TCoords* vertices, u32 vertexCount, const u16* indexList, u32 triangleCount); - - //! Draws an indexed triangle list. - virtual void drawIndexedTriangleList(const S3DVertexTangents* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount); - - //! Draws an indexed triangle fan. - virtual void drawIndexedTriangleFan(const S3DVertex* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount); - - //! Draws an indexed triangle list. - virtual void drawIndexedTriangleFan(const S3DVertex2TCoords* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount); - - //! Draws an indexed triangle fan. - virtual void drawIndexedTriangleFan(const S3DVertexTangents* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount); - - //! Draws a 3d line. - virtual void draw3DLine(const core::vector3df& start, - const core::vector3df& end, SColor color = SColor(255,255,255,255)); - - //! Draws a 3d triangle. - virtual void draw3DTriangle(const core::triangle3df& triangle, - SColor color = SColor(255,255,255,255)); - - //! Draws a 3d axis aligned box. - virtual void draw3DBox(const core::aabbox3d<f32>& box, - SColor color = SColor(255,255,255,255)); - - //! draws an 2d image - virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos); - - //! draws a set of 2d images, using a color and the alpha - /** channel of the texture if desired. The images are drawn - beginning at pos and concatenated in one line. All drawings - are clipped against clipRect (if != 0). - The subtextures are defined by the array of sourceRects - and are chosen by the indices given. - \param texture: Texture to be drawn. - \param pos: Upper left 2d destination position where the image will be drawn. - \param sourceRects: Source rectangles of the image. - \param indices: List of indices which choose the actual rectangle used each time. - \param kerningWidth: offset on position - \param clipRect: Pointer to rectangle on the screen where the image is clipped to. - This pointer can be 0. Then the image is not clipped. - \param color: Color with which the image is colored. - Note that the alpha component is used: If alpha is other than 255, the image will be transparent. - \param useAlphaChannelOfTexture: If true, the alpha channel of the texture is - used to draw the image. */ - virtual void draw2DImageBatch(const video::ITexture* texture, - const core::position2d<s32>& pos, - const core::array<core::rect<s32> >& sourceRects, - const core::array<s32>& indices, - s32 kerningWidth = 0, - const core::rect<s32>* clipRect = 0, - SColor color=SColor(255,255,255,255), - bool useAlphaChannelOfTexture=false); - - //! Draws a set of 2d images, using a color and the alpha channel of the texture. - /** All drawings are clipped against clipRect (if != 0). - The subtextures are defined by the array of sourceRects and are - positioned using the array of positions. - \param texture Texture to be drawn. - \param pos Array of upper left 2d destinations where the images - will be drawn. - \param sourceRects Source rectangles of the image. - \param clipRect Pointer to rectangle on the screen where the - images are clipped to. - If this pointer is 0 then the image is not clipped. - \param color Color with which the image is drawn. - Note that the alpha component is used. If alpha is other than - 255, the image will be transparent. - \param useAlphaChannelOfTexture: If true, the alpha channel of - the texture is used to draw the image. */ - virtual void draw2DImageBatch(const video::ITexture* texture, - const core::array<core::position2d<s32> >& positions, - const core::array<core::rect<s32> >& sourceRects, - const core::rect<s32>* clipRect=0, - SColor color=SColor(255,255,255,255), - bool useAlphaChannelOfTexture=false); - - //! Draws a 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. - virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos, - const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0, - SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false); - - //! Draws a part of the texture into the rectangle. - virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect, - const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0, - const video::SColor* const colors=0, bool useAlphaChannelOfTexture=false); - - //! Draws a 2d rectangle - virtual void draw2DRectangle(SColor color, const core::rect<s32>& pos, const core::rect<s32>* clip = 0); - - //! Draws a 2d rectangle with a gradient. - virtual void draw2DRectangle(const core::rect<s32>& pos, - SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, - const core::rect<s32>* clip = 0); - - //! Draws the outline of a 2d rectangle - virtual void draw2DRectangleOutline(const core::recti& pos, SColor color=SColor(255,255,255,255)); - - //! Draws a 2d line. - virtual void draw2DLine(const core::position2d<s32>& start, - const core::position2d<s32>& end, - SColor color=SColor(255,255,255,255)); - - //! Draws a pixel - virtual void drawPixel(u32 x, u32 y, const SColor & color); - - //! Draws a non filled concyclic reqular 2d polyon. - virtual void draw2DPolygon(core::position2d<s32> center, - f32 radius, video::SColor Color, s32 vertexCount); - - virtual void setFog(SColor color=SColor(0,255,255,255), - E_FOG_TYPE fogType=EFT_FOG_LINEAR, - f32 start=50.0f, f32 end=100.0f, f32 density=0.01f, - bool pixelFog=false, bool rangeFog=false); - - //! get color format of the current color buffer - virtual ECOLOR_FORMAT getColorFormat() const; - - //! get screen size - virtual const core::dimension2d<u32>& getScreenSize() const; - - //! get render target size - virtual const core::dimension2d<u32>& getCurrentRenderTargetSize() const; - - // get current frames per second value - virtual s32 getFPS() const; - - //! returns amount of primitives (mostly triangles) were drawn in the last frame. - //! very useful method for statistics. - virtual u32 getPrimitiveCountDrawn( u32 param = 0 ) const; - - //! deletes all dynamic lights there are - virtual void deleteAllDynamicLights(); - - //! adds a dynamic light, returning an index to the light - //! \param light: the light data to use to create the light - //! \return An index to the light, or -1 if an error occurs - virtual s32 addDynamicLight(const SLight& light); - - //! Turns a dynamic light on or off - //! \param lightIndex: the index returned by addDynamicLight - //! \param turnOn: true to turn the light on, false to turn it off - virtual void turnLightOn(s32 lightIndex, bool turnOn); - - //! returns the maximal amount of dynamic lights the device can handle - virtual u32 getMaximalDynamicLightAmount() const; - - //! \return Returns the name of the video driver. Example: In case of the DIRECT3D8 - //! driver, it would return "Direct3D8.1". - virtual const wchar_t* getName() const; - - //! Sets the dynamic ambient light color. The default color is - //! (0,0,0,0) which means it is dark. - //! \param color: New color of the ambient light. - virtual void setAmbientLight(const SColorf& color); - - //! Adds an external image loader to the engine. - virtual void addExternalImageLoader(IImageLoader* loader); - - //! Adds an external image writer to the engine. - virtual void addExternalImageWriter(IImageWriter* writer); - - //! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do - //! this: Frist, draw all geometry. Then use this method, to draw the shadow - //! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow. - virtual void drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail=true); - - //! Fills the stencil shadow with color. After the shadow volume has been drawn - //! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this - //! to draw the color of the shadow. - virtual void drawStencilShadow(bool clearStencilBuffer=false, - video::SColor leftUpEdge = video::SColor(0,0,0,0), - video::SColor rightUpEdge = video::SColor(0,0,0,0), - video::SColor leftDownEdge = video::SColor(0,0,0,0), - video::SColor rightDownEdge = video::SColor(0,0,0,0)); - - //! Returns current amount of dynamic lights set - //! \return Current amount of dynamic lights set - virtual u32 getDynamicLightCount() const; - - //! Returns light data which was previously set with IVideDriver::addDynamicLight(). - //! \param idx: Zero based index of the light. Must be greater than 0 and smaller - //! than IVideoDriver()::getDynamicLightCount. - //! \return Light data. - virtual const SLight& getDynamicLight(u32 idx) const; - - //! Removes a texture from the texture cache and deletes it, freeing lot of - //! memory. - virtual void removeTexture(ITexture* texture); - - //! Removes all texture from the texture cache and deletes them, freeing lot of - //! memory. - virtual void removeAllTextures(); - - //! Creates a render target texture. - virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size, - const io::path& name, const ECOLOR_FORMAT format = ECF_UNKNOWN); - - //! Creates an 1bit alpha channel of the texture based of an color key. - virtual void makeColorKeyTexture(video::ITexture* texture, video::SColor color, bool zeroTexels) const; - - //! Creates an 1bit alpha channel of the texture based of an color key position. - virtual void makeColorKeyTexture(video::ITexture* texture, core::position2d<s32> colorKeyPixelPos, bool zeroTexels) const; - - //! Creates a normal map from a height map texture. - //! \param amplitude: Constant value by which the height information is multiplied. - virtual void makeNormalMapTexture(video::ITexture* texture, f32 amplitude=1.0f) const; - - //! Returns the maximum amount of primitives (mostly vertices) which - //! the device is able to render with one drawIndexedTriangleList - //! call. - virtual u32 getMaximalPrimitiveCount() const; - - //! Enables or disables a texture creation flag. - virtual void setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled); - - //! Returns if a texture creation flag is enabled or disabled. - virtual bool getTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag) const; - - //! Creates a software image from a file. - virtual IImage* createImageFromFile(const io::path& filename); - - //! Creates a software image from a file. - virtual IImage* createImageFromFile(io::IReadFile* file); - - //! Creates a software image from a byte array. - /** \param useForeignMemory: If true, the image will use the data pointer - directly and own it from now on, which means it will also try to delete [] the - data when the image will be destructed. If false, the memory will by copied. */ - virtual IImage* createImageFromData(ECOLOR_FORMAT format, - const core::dimension2d<u32>& size, void *data, - bool ownForeignMemory=true, bool deleteForeignMemory = true); - - //! Creates an empty software image. - virtual IImage* createImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size); - - - //! Creates a software image from another image. - virtual IImage* createImage(ECOLOR_FORMAT format, IImage *imageToCopy); - - //! Creates a software image from part of another image. - virtual IImage* createImage(IImage* imageToCopy, - const core::position2d<s32>& pos, - const core::dimension2d<u32>& size); - - //! Creates a software image from part of a texture. - virtual IImage* createImage(ITexture* texture, - const core::position2d<s32>& pos, - const core::dimension2d<u32>& size); - - //! Draws a mesh buffer - virtual void drawMeshBuffer(const scene::IMeshBuffer* mb); - - protected: - struct SHWBufferLink - { - SHWBufferLink(const scene::IMeshBuffer *_MeshBuffer) - :MeshBuffer(_MeshBuffer), - ChangedID_Vertex(0),ChangedID_Index(0),LastUsed(0), - Mapped_Vertex(scene::EHM_NEVER),Mapped_Index(scene::EHM_NEVER) - { - if (MeshBuffer) - MeshBuffer->grab(); - } - - virtual ~SHWBufferLink() - { - if (MeshBuffer) - MeshBuffer->drop(); - } - - const scene::IMeshBuffer *MeshBuffer; - u32 ChangedID_Vertex; - u32 ChangedID_Index; - u32 LastUsed; - scene::E_HARDWARE_MAPPING Mapped_Vertex; - scene::E_HARDWARE_MAPPING Mapped_Index; - }; - - //! Gets hardware buffer link from a meshbuffer (may create or update buffer) - virtual SHWBufferLink *getBufferLink(const scene::IMeshBuffer* mb); - - //! updates hardware buffer if needed (only some drivers can) - virtual bool updateHardwareBuffer(SHWBufferLink *HWBuffer) {return false;} - - //! Create hardware buffer from mesh (only some drivers can) - virtual SHWBufferLink *createHardwareBuffer(const scene::IMeshBuffer* mb) {return 0;} - - //! Draw hardware buffer (only some drivers can) - virtual void drawHardwareBuffer(SHWBufferLink *HWBuffer) {} - - //! Update all hardware buffers, remove unused ones - virtual void updateAllHardwareBuffers(); - - //! Delete hardware buffer - virtual void deleteHardwareBuffer(SHWBufferLink *HWBuffer); - - //! Remove hardware buffer - virtual void removeHardwareBuffer(const scene::IMeshBuffer* mb); - - //! Remove all hardware buffers - virtual void removeAllHardwareBuffers(); - - //! is vbo recommended on this mesh? - virtual bool isHardwareBufferRecommend(const scene::IMeshBuffer* mb); - - public: - //! Only used by the engine internally. - /** Used to notify the driver that the window was resized. */ - virtual void OnResize(const core::dimension2d<u32>& size); - - //! Adds a new material renderer to the video device. - virtual s32 addMaterialRenderer(IMaterialRenderer* renderer, - const char* name = 0); - - //! Returns driver and operating system specific data about the IVideoDriver. - virtual const SExposedVideoData& getExposedVideoData(); - - //! Returns type of video driver - virtual E_DRIVER_TYPE getDriverType() const; - - //! Returns the transformation set by setTransform - virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) const; - - //! Returns pointer to the IGPUProgrammingServices interface. - virtual IGPUProgrammingServices* getGPUProgrammingServices(); - - //! Adds a new material renderer to the VideoDriver, using pixel and/or - //! vertex shaders to render geometry. - virtual s32 addShaderMaterial(const c8* vertexShaderProgram = 0, - const c8* pixelShaderProgram = 0, - IShaderConstantSetCallBack* callback = 0, - E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, - s32 userData=0); - - //! Like IGPUProgrammingServices::addShaderMaterial(), but tries to load the - //! programs from files. - virtual s32 addShaderMaterialFromFiles(io::IReadFile* vertexShaderProgram = 0, - io::IReadFile* pixelShaderProgram = 0, - IShaderConstantSetCallBack* callback = 0, - E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, - s32 userData=0); - - //! Like IGPUProgrammingServices::addShaderMaterial(), but tries to load the - //! programs from files. - virtual s32 addShaderMaterialFromFiles(const io::path& vertexShaderProgramFileName, - const io::path& pixelShaderProgramFileName, - IShaderConstantSetCallBack* callback = 0, - E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, - s32 userData=0); - - //! Returns pointer to material renderer or null - virtual IMaterialRenderer* getMaterialRenderer(u32 idx); - - //! Returns amount of currently available material renderers. - virtual u32 getMaterialRendererCount() const; - - //! Returns name of the material renderer - virtual const char* getMaterialRendererName(u32 idx) const; - - //! Adds a new material renderer to the VideoDriver, based on a high level shading - //! language. Currently only HLSL in D3D9 is supported. - virtual s32 addHighLevelShaderMaterial( - const c8* vertexShaderProgram, - const c8* vertexShaderEntryPointName = 0, - E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1, - const c8* pixelShaderProgram = 0, - const c8* pixelShaderEntryPointName = 0, - E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1, - IShaderConstantSetCallBack* callback = 0, - E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, - s32 userData=0); - - //! Like IGPUProgrammingServices::addShaderMaterial() (look there for a detailed description), - //! but tries to load the programs from files. - virtual s32 addHighLevelShaderMaterialFromFiles( - const io::path& vertexShaderProgramFile, - const c8* vertexShaderEntryPointName = "main", - E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1, - const io::path& pixelShaderProgramFile = "", - const c8* pixelShaderEntryPointName = "main", - E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1, - IShaderConstantSetCallBack* callback = 0, - E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, - s32 userData=0); - - //! Like IGPUProgrammingServices::addShaderMaterial() (look there for a detailed description), - //! but tries to load the programs from files. - virtual s32 addHighLevelShaderMaterialFromFiles( - io::IReadFile* vertexShaderProgram, - const c8* vertexShaderEntryPointName = "main", - E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1, - io::IReadFile* pixelShaderProgram = 0, - const c8* pixelShaderEntryPointName = "main", - E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1, - IShaderConstantSetCallBack* callback = 0, - E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, - s32 userData=0); - - //! Returns a pointer to the mesh manipulator. - virtual scene::IMeshManipulator* getMeshManipulator(); - - //! Clears the ZBuffer. - virtual void clearZBuffer(); - - //! Returns an image created from the last rendered frame. - virtual IImage* createScreenShot(); - - //! Writes the provided image to disk file - virtual bool writeImageToFile(IImage* image, const io::path& filename, u32 param = 0); - - //! Writes the provided image to a file. - virtual bool writeImageToFile(IImage* image, io::IWriteFile * file, u32 param = 0); - - //! Sets the name of a material renderer. - virtual void setMaterialRendererName(s32 idx, const char* name); - - //! Creates material attributes list from a material, usable for serialization and more. - virtual io::IAttributes* createAttributesFromMaterial(const video::SMaterial& material); - - //! Fills an SMaterial structure from attributes. - virtual void fillMaterialStructureFromAttributes(video::SMaterial& outMaterial, io::IAttributes* attributes); - - //! looks if the image is already loaded - virtual video::ITexture* findTexture(const io::path& filename); - - //! Set/unset a clipping plane. - //! There are at least 6 clipping planes available for the user to set at will. - //! \param index: The plane index. Must be between 0 and MaxUserClipPlanes. - //! \param plane: The plane itself. - //! \param enable: If true, enable the clipping plane else disable it. - virtual bool setClipPlane(u32 index, const core::plane3df& plane, bool enable=false); - - //! Enable/disable a clipping plane. - //! There are at least 6 clipping planes available for the user to set at will. - //! \param index: The plane index. Must be between 0 and MaxUserClipPlanes. - //! \param enable: If true, enable the clipping plane else disable it. - virtual void enableClipPlane(u32 index, bool enable); - - //! Returns the graphics card vendor name. - virtual core::stringc getVendorInfo() {return "Not available on this driver.";} - - //! Set the minimum number of vertices for which a hw buffer will be created - /** \param count Number of vertices to set as minimum. */ - virtual void setMinHardwareBufferVertexCount(u32 count); - - //! Get the global Material, which might override local materials. - /** Depending on the enable flags, values from this Material - are used to override those of local materials of some - meshbuffer being rendered. */ - virtual SOverrideMaterial& getOverrideMaterial(); - - //! Only used by the engine internally. - virtual void setAllowZWriteOnTransparent(bool flag) - { AllowZWriteOnTransparent=flag; } - - //! deprecated method - virtual ITexture* createRenderTargetTexture(const core::dimension2d<u32>& size, - const c8* name=0); - - virtual bool checkDriverReset() {return false;} - protected: - - //! deletes all textures - void deleteAllTextures(); - - //! opens the file and loads it into the surface - video::ITexture* loadTextureFromFile(io::IReadFile* file, const io::path& hashName = ""); - - //! adds a surface, not loaded or created by the Irrlicht Engine - void addTexture(video::ITexture* surface); - - //! Creates a texture from a loaded IImage. - virtual ITexture* addTexture(const io::path& name, IImage* image); - - //! returns a device dependent texture from a software surface (IImage) - //! THIS METHOD HAS TO BE OVERRIDDEN BY DERIVED DRIVERS WITH OWN TEXTURES - virtual video::ITexture* createDeviceDependentTexture(IImage* surface, const io::path& name); - - //! checks triangle count and print warning if wrong - bool checkPrimitiveCount(u32 prmcnt) const; - - // adds a material renderer and drops it afterwards. To be used for internal creation - s32 addAndDropMaterialRenderer(IMaterialRenderer* m); - - //! deletes all material renderers - void deleteMaterialRenders(); - - // prints renderer version - void printVersion(); - - //! normal map lookup 32 bit version - inline f32 nml32(int x, int y, int pitch, int height, s32 *p) const - { - if (x < 0) x = pitch-1; if (x >= pitch) x = 0; - if (y < 0) y = height-1; if (y >= height) y = 0; - return (f32)(((p[(y * pitch) + x])>>16) & 0xff); - } - - //! normal map lookup 16 bit version - inline f32 nml16(int x, int y, int pitch, int height, s16 *p) const - { - if (x < 0) x = pitch-1; if (x >= pitch) x = 0; - if (y < 0) y = height-1; if (y >= height) y = 0; - - return (f32) getAverage ( p[(y * pitch) + x] ); - } - - struct SSurface - { - video::ITexture* Surface; - - bool operator < (const SSurface& other) const - { - return Surface->getName() < other.Surface->getName(); - } - }; - - struct SMaterialRenderer - { - core::stringc Name; - IMaterialRenderer* Renderer; - }; - - struct SDummyTexture : public ITexture - { - SDummyTexture(const io::path& name) : ITexture(name), size(0,0) {}; - - virtual void* lock(bool readOnly = false) { return 0; }; - virtual void unlock(){} - virtual const core::dimension2d<u32>& getOriginalSize() const { return size; } - virtual const core::dimension2d<u32>& getSize() const { return size; } - virtual E_DRIVER_TYPE getDriverType() const { return video::EDT_NULL; } - virtual ECOLOR_FORMAT getColorFormat() const { return video::ECF_A1R5G5B5; }; - virtual u32 getPitch() const { return 0; } - virtual void regenerateMipMapLevels() {}; - core::dimension2d<u32> size; - }; - - - - core::array<SSurface> Textures; - core::array<video::IImageLoader*> SurfaceLoader; - core::array<video::IImageWriter*> SurfaceWriter; - core::array<SLight> Lights; - core::array<SMaterialRenderer> MaterialRenderers; - - //core::array<SHWBufferLink*> HWBufferLinks; - core::map< const scene::IMeshBuffer* , SHWBufferLink* > HWBufferMap; - - io::IFileSystem* FileSystem; - - //! mesh manipulator - scene::IMeshManipulator* MeshManipulator; - - core::rect<s32> ViewPort; - core::dimension2d<u32> ScreenSize; - core::matrix4 TransformationMatrix; - - CFPSCounter FPSCounter; - - u32 PrimitivesDrawn; - u32 MinVertexCountForVBO; - - u32 TextureCreationFlags; - - f32 FogStart; - f32 FogEnd; - f32 FogDensity; - SColor FogColor; - SExposedVideoData ExposedData; - - SOverrideMaterial OverrideMaterial; - - E_FOG_TYPE FogType; - bool PixelFog; - bool RangeFog; - bool AllowZWriteOnTransparent; - - bool FeatureEnabled[video::EVDF_COUNT]; - }; - -} // end namespace video -} // end namespace irr - - -#endif - - - diff --git a/irrlicht-1.6/source/Irrlicht/COBJMeshFileLoader.cpp b/irrlicht-1.6/source/Irrlicht/COBJMeshFileLoader.cpp deleted file mode 100644 index 033b2ee08..000000000 --- a/irrlicht-1.6/source/Irrlicht/COBJMeshFileLoader.cpp +++ /dev/null @@ -1,920 +0,0 @@ -// Copyright (C) 2002-2009 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_OBJ_LOADER_ - -#include "COBJMeshFileLoader.h" -#include "IMeshManipulator.h" -#include "IVideoDriver.h" -#include "SMesh.h" -#include "SMeshBuffer.h" -#include "SAnimatedMesh.h" -#include "IReadFile.h" -#include "IAttributes.h" -#include "fast_atof.h" -#include "coreutil.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - -#ifdef _DEBUG -#define _IRR_DEBUG_OBJ_LOADER_ -#endif - -static const u32 WORD_BUFFER_LENGTH = 512; - -//! Constructor -COBJMeshFileLoader::COBJMeshFileLoader(scene::ISceneManager* smgr, io::IFileSystem* fs) -: SceneManager(smgr), FileSystem(fs) -{ - #ifdef _DEBUG - setDebugName("COBJMeshFileLoader"); - #endif - - if (FileSystem) - FileSystem->grab(); -} - - -//! destructor -COBJMeshFileLoader::~COBJMeshFileLoader() -{ - if (FileSystem) - FileSystem->drop(); -} - - -//! returns true if the file maybe is able to be loaded by this class -//! based on the file extension (e.g. ".bsp") -bool COBJMeshFileLoader::isALoadableFileExtension(const io::path& filename) const -{ - return core::hasFileExtension ( filename, "obj" ); -} - - -//! 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* COBJMeshFileLoader::createMesh(io::IReadFile* file) -{ - const long filesize = file->getSize(); - if (!filesize) - return 0; - - const u32 WORD_BUFFER_LENGTH = 512; - - core::array<core::vector3df> vertexBuffer; - core::array<core::vector3df> normalsBuffer; - core::array<core::vector2df> textureCoordBuffer; - - SObjMtl * currMtl = new SObjMtl(); - Materials.push_back(currMtl); - u32 smoothingGroup=0; - - const io::path fullName = file->getFileName(); - const io::path relPath = FileSystem->getFileDir(fullName)+"/"; - - c8* buf = new c8[filesize]; - memset(buf, 0, filesize); - file->read((void*)buf, filesize); - const c8* const bufEnd = buf+filesize; - - // Process obj information - const c8* bufPtr = buf; - core::stringc grpName, mtlName; - bool mtlChanged=false; - bool useGroups = !SceneManager->getParameters()->getAttributeAsBool(OBJ_LOADER_IGNORE_GROUPS); - bool useMaterials = !SceneManager->getParameters()->getAttributeAsBool(OBJ_LOADER_IGNORE_MATERIAL_FILES); - while(bufPtr != bufEnd) - { - switch(bufPtr[0]) - { - case 'm': // mtllib (material) - { - if (useMaterials) - { - c8 name[WORD_BUFFER_LENGTH]; - bufPtr = goAndCopyNextWord(name, bufPtr, WORD_BUFFER_LENGTH, bufEnd); -#ifdef _IRR_DEBUG_OBJ_LOADER_ - os::Printer::log("Reading material file",name); -#endif - readMTL(name, relPath); - } - } - break; - - case 'v': // v, vn, vt - switch(bufPtr[1]) - { - case ' ': // vertex - { - core::vector3df vec; - bufPtr = readVec3(bufPtr, vec, bufEnd); - vertexBuffer.push_back(vec); - } - break; - - case 'n': // normal - { - core::vector3df vec; - bufPtr = readVec3(bufPtr, vec, bufEnd); - normalsBuffer.push_back(vec); - } - break; - - case 't': // texcoord - { - core::vector2df vec; - bufPtr = readUV(bufPtr, vec, bufEnd); - textureCoordBuffer.push_back(vec); - } - break; - } - break; - - case 'g': // group name - { - c8 grp[WORD_BUFFER_LENGTH]; - bufPtr = goAndCopyNextWord(grp, bufPtr, WORD_BUFFER_LENGTH, bufEnd); -#ifdef _IRR_DEBUG_OBJ_LOADER_ - os::Printer::log("Loaded group start",grp); -#endif - if (useGroups) - { - if (0 != grp[0]) - grpName = grp; - else - grpName = "default"; - } - mtlChanged=true; - } - break; - - case 's': // smoothing can be a group or off (equiv. to 0) - { - c8 smooth[WORD_BUFFER_LENGTH]; - bufPtr = goAndCopyNextWord(smooth, bufPtr, WORD_BUFFER_LENGTH, bufEnd); -#ifdef _IRR_DEBUG_OBJ_LOADER_ - os::Printer::log("Loaded smoothing group start",smooth); -#endif - if (core::stringc("off")==smooth) - smoothingGroup=0; - else - smoothingGroup=core::strtol10(smooth, 0); - } - break; - - case 'u': // usemtl - // get name of material - { - c8 matName[WORD_BUFFER_LENGTH]; - bufPtr = goAndCopyNextWord(matName, bufPtr, WORD_BUFFER_LENGTH, bufEnd); -#ifdef _IRR_DEBUG_OBJ_LOADER_ - os::Printer::log("Loaded material start",matName); -#endif - mtlName=matName; - mtlChanged=true; - } - break; - - case 'f': // face - { - c8 vertexWord[WORD_BUFFER_LENGTH]; // for retrieving vertex data - video::S3DVertex v; - // Assign vertex color from currently active material's diffuse colour - if (mtlChanged) - { - // retrieve the material - SObjMtl *useMtl = findMtl(mtlName, grpName); - // only change material if we found it - if (useMtl) - currMtl = useMtl; - mtlChanged=false; - } - 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(bufPtr, bufEnd); - const c8* linePtr = wordBuffer.c_str(); - const c8* const endPtr = linePtr+wordBuffer.size(); - - core::array<int> faceCorners; - faceCorners.reallocate(32); // should be large enough - - // read in all vertices - linePtr = goNextWord(linePtr, endPtr); - while (0 != linePtr[0]) - { - // Array to communicate with retrieveVertexIndices() - // sends the buffer sizes and gets the actual indices - // if index not set returns -1 - s32 Idx[3]; - Idx[1] = Idx[2] = -1; - - // read in next vertex's data - u32 wlength = copyWord(vertexWord, linePtr, WORD_BUFFER_LENGTH, bufEnd); - // 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]]; - if ( -1 != Idx[1] ) - v.TCoords = textureCoordBuffer[Idx[1]]; - else - v.TCoords.set(0.0f,0.0f); - if ( -1 != Idx[2] ) - v.Normal = normalsBuffer[Idx[2]]; - else - { - v.Normal.set(0.0f,0.0f,0.0f); - currMtl->RecalculateNormals=true; - } - - int vertLocation; - core::map<video::S3DVertex, int>::Node* n = currMtl->VertMap.find(v); - if (n) - { - vertLocation = n->getValue(); - } - else - { - currMtl->Meshbuffer->Vertices.push_back(v); - vertLocation = currMtl->Meshbuffer->Vertices.size() -1; - currMtl->VertMap.insert(v, vertLocation); - } - - faceCorners.push_back(vertLocation); - - // go to next vertex - linePtr = goNextWord(linePtr, endPtr); - } - - // triangulate the face - for ( u32 i = 1; i < faceCorners.size() - 1; ++i ) - { - // Add a triangle - currMtl->Meshbuffer->Indices.push_back( faceCorners[i+1] ); - currMtl->Meshbuffer->Indices.push_back( faceCorners[i] ); - currMtl->Meshbuffer->Indices.push_back( faceCorners[0] ); - } - faceCorners.set_used(0); // fast clear - faceCorners.reallocate(32); - } - break; - - case '#': // comment - default: - break; - } // end switch(bufPtr[0]) - // eat up rest of line - bufPtr = goNextLine(bufPtr, bufEnd); - } // end while(bufPtr && (bufPtr-buf<filesize)) - - SMesh* mesh = new SMesh(); - - // Combine all the groups (meshbuffers) into the mesh - for ( u32 m = 0; m < Materials.size(); ++m ) - { - if ( Materials[m]->Meshbuffer->getIndexCount() > 0 ) - { - Materials[m]->Meshbuffer->recalculateBoundingBox(); - if (Materials[m]->RecalculateNormals) - SceneManager->getMeshManipulator()->recalculateNormals(Materials[m]->Meshbuffer); - if (Materials[m]->Meshbuffer->Material.MaterialType == video::EMT_PARALLAX_MAP_SOLID) - { - SMesh tmp; - tmp.addMeshBuffer(Materials[m]->Meshbuffer); - IMesh* tangentMesh = SceneManager->getMeshManipulator()->createMeshWithTangents(&tmp); - mesh->addMeshBuffer(tangentMesh->getMeshBuffer(0)); - tangentMesh->drop(); - } - else - mesh->addMeshBuffer( Materials[m]->Meshbuffer ); - } - } - - // Create the Animated mesh if there's anything in the mesh - SAnimatedMesh* animMesh = 0; - if ( 0 != mesh->getMeshBufferCount() ) - { - mesh->recalculateBoundingBox(); - animMesh = new SAnimatedMesh(); - animMesh->Type = EAMT_OBJ; - animMesh->addMesh(mesh); - animMesh->recalculateBoundingBox(); - } - - // Clean up the allocate obj file contents - delete [] buf; - // more cleaning up - cleanUp(); - mesh->drop(); - - return animMesh; -} - - -const c8* COBJMeshFileLoader::readTextures(const c8* bufPtr, const c8* const bufEnd, SObjMtl* currMaterial, const io::path& relPath) -{ - u8 type=0; // map_Kd - diffuse color texture map - // map_Ks - specular color texture map - // map_Ka - ambient color texture map - // map_Ns - shininess texture map - if ((!strncmp(bufPtr,"map_bump",8)) || (!strncmp(bufPtr,"bump",4))) - type=1; // normal map - else if ((!strncmp(bufPtr,"map_d",5)) || (!strncmp(bufPtr,"map_opacity",11))) - type=2; // opacity map - else if (!strncmp(bufPtr,"map_refl",8)) - type=3; // reflection map - // extract new material's name - c8 textureNameBuf[WORD_BUFFER_LENGTH]; - bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, bufEnd); - - f32 bumpiness = 6.0f; - bool clamp = false; - // handle options - while (textureNameBuf[0]=='-') - { - if (!strncmp(bufPtr,"-bm",3)) - { - bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, bufEnd); - currMaterial->Meshbuffer->Material.MaterialTypeParam=core::fast_atof(textureNameBuf); - bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, bufEnd); - continue; - } - else - if (!strncmp(bufPtr,"-blendu",7)) - bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, bufEnd); - else - if (!strncmp(bufPtr,"-blendv",7)) - bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, bufEnd); - else - if (!strncmp(bufPtr,"-cc",3)) - bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, bufEnd); - else - if (!strncmp(bufPtr,"-clamp",6)) - bufPtr = readBool(bufPtr, clamp, bufEnd); - else - if (!strncmp(bufPtr,"-texres",7)) - bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, bufEnd); - else - if (!strncmp(bufPtr,"-type",5)) - bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, bufEnd); - else - if (!strncmp(bufPtr,"-mm",3)) - { - bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, bufEnd); - bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, bufEnd); - } - else - if (!strncmp(bufPtr,"-o",2)) // texture coord translation - { - bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, bufEnd); - // next parameters are optional, so skip rest of loop if no number is found - bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, bufEnd); - if (!core::isdigit(textureNameBuf[0])) - continue; - bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, bufEnd); - if (!core::isdigit(textureNameBuf[0])) - continue; - } - else - if (!strncmp(bufPtr,"-s",2)) // texture coord scale - { - bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, bufEnd); - // next parameters are optional, so skip rest of loop if no number is found - bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, bufEnd); - if (!core::isdigit(textureNameBuf[0])) - continue; - bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, bufEnd); - if (!core::isdigit(textureNameBuf[0])) - continue; - } - else - if (!strncmp(bufPtr,"-t",2)) - { - bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, bufEnd); - // next parameters are optional, so skip rest of loop if no number is found - bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, bufEnd); - if (!core::isdigit(textureNameBuf[0])) - continue; - bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, bufEnd); - if (!core::isdigit(textureNameBuf[0])) - continue; - } - // get next word - bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, bufEnd); - } - - if ((type==1) && (core::isdigit(textureNameBuf[0]))) - { - currMaterial->Meshbuffer->Material.MaterialTypeParam=core::fast_atof(textureNameBuf); - bufPtr = goAndCopyNextWord(textureNameBuf, bufPtr, WORD_BUFFER_LENGTH, bufEnd); - } - if (clamp) - currMaterial->Meshbuffer->Material.setFlag(video::EMF_TEXTURE_WRAP, video::ETC_CLAMP); - - io::path texname(textureNameBuf); - texname.replace('\\', '/'); - - video::ITexture * texture = 0; - if (texname.size()) - { - if (FileSystem->existFile(texname)) - texture = SceneManager->getVideoDriver()->getTexture(texname); - else - // try to read in the relative path, the .obj is loaded from - texture = SceneManager->getVideoDriver()->getTexture( relPath + texname ); - } - if ( texture ) - { - if (type==0) - currMaterial->Meshbuffer->Material.setTexture(0, texture); - else if (type==1) - { - SceneManager->getVideoDriver()->makeNormalMapTexture(texture, bumpiness); - currMaterial->Meshbuffer->Material.setTexture(1, texture); - currMaterial->Meshbuffer->Material.MaterialType=video::EMT_PARALLAX_MAP_SOLID; - currMaterial->Meshbuffer->Material.MaterialTypeParam=0.035f; - } - else if (type==2) - { - currMaterial->Meshbuffer->Material.setTexture(0, texture); - currMaterial->Meshbuffer->Material.MaterialType=video::EMT_TRANSPARENT_ADD_COLOR; - } - else if (type==3) - { -// currMaterial->Meshbuffer->Material.Textures[1] = texture; -// currMaterial->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? - currMaterial->Meshbuffer->Material.DiffuseColor.set( - currMaterial->Meshbuffer->Material.DiffuseColor.getAlpha(), 255, 255, 255 ); - } - return bufPtr; -} - - -void COBJMeshFileLoader::readMTL(const c8* fileName, const io::path& relPath) -{ - const io::path realFile(fileName); - io::IReadFile * mtlReader; - - if (FileSystem->existFile(realFile)) - mtlReader = FileSystem->createAndOpenFile(realFile); - else if (FileSystem->existFile(relPath + realFile)) - { - mtlReader = FileSystem->createAndOpenFile(relPath + realFile); - } - else if (FileSystem->existFile(FileSystem->getFileBasename(realFile))) - { - mtlReader = FileSystem->createAndOpenFile(FileSystem->getFileBasename(realFile)); - } - else - { - mtlReader = FileSystem->createAndOpenFile(relPath + FileSystem->getFileBasename(realFile)); - } - if (!mtlReader) // fail to open and read file - { - os::Printer::log("Could not open material file", realFile, ELL_WARNING); - return; - } - - const long filesize = mtlReader->getSize(); - if (!filesize) - { - os::Printer::log("Skipping empty material file", realFile, ELL_WARNING); - return; - } - - c8* buf = new c8[filesize]; - mtlReader->read((void*)buf, filesize); - const c8* bufEnd = buf+filesize; - - SObjMtl* currMaterial = 0; - - const c8* bufPtr = buf; - while(bufPtr != bufEnd) - { - switch(*bufPtr) - { - case 'n': // newmtl - { - // if there's an existing material, store it first - if ( currMaterial ) - Materials.push_back( currMaterial ); - - // extract new material's name - c8 mtlNameBuf[WORD_BUFFER_LENGTH]; - bufPtr = goAndCopyNextWord(mtlNameBuf, bufPtr, WORD_BUFFER_LENGTH, bufEnd); - - currMaterial = new SObjMtl; - currMaterial->Name = mtlNameBuf; - } - break; - case 'i': // illum - illumination - if ( currMaterial ) - { - const u32 COLOR_BUFFER_LENGTH = 16; - c8 illumStr[COLOR_BUFFER_LENGTH]; - - bufPtr = goAndCopyNextWord(illumStr, bufPtr, COLOR_BUFFER_LENGTH, bufEnd); - currMaterial->Illumination = (c8)atol(illumStr); - } - break; - case 'N': - if ( currMaterial ) - { - switch(bufPtr[1]) - { - case 's': // Ns - shininess - { - const u32 COLOR_BUFFER_LENGTH = 16; - c8 nsStr[COLOR_BUFFER_LENGTH]; - - bufPtr = goAndCopyNextWord(nsStr, bufPtr, COLOR_BUFFER_LENGTH, bufEnd); - f32 shininessValue = core::fast_atof(nsStr); - - // wavefront shininess is from [0, 1000], so scale for OpenGL - shininessValue *= 0.128f; - currMaterial->Meshbuffer->Material.Shininess = shininessValue; - } - break; - case 'i': // Ni - refraction index - { - c8 tmpbuf[WORD_BUFFER_LENGTH]; - bufPtr = goAndCopyNextWord(tmpbuf, bufPtr, WORD_BUFFER_LENGTH, bufEnd); - } - break; - } - } - break; - case 'K': - if ( currMaterial ) - { - switch(bufPtr[1]) - { - case 'd': // Kd = diffuse - { - bufPtr = readColor(bufPtr, currMaterial->Meshbuffer->Material.DiffuseColor, bufEnd); - - } - break; - - case 's': // Ks = specular - { - bufPtr = readColor(bufPtr, currMaterial->Meshbuffer->Material.SpecularColor, bufEnd); - } - break; - - case 'a': // Ka = ambience - { - bufPtr=readColor(bufPtr, currMaterial->Meshbuffer->Material.AmbientColor, bufEnd); - } - break; - case 'e': // Ke = emissive - { - bufPtr=readColor(bufPtr, currMaterial->Meshbuffer->Material.EmissiveColor, bufEnd); - } - break; - } // end switch(bufPtr[1]) - } // end case 'K': if ( 0 != currMaterial )... - break; - case 'b': // bump - case 'm': // texture maps - if (currMaterial) - { - bufPtr=readTextures(bufPtr, bufEnd, currMaterial, relPath); - } - break; - case 'd': // d - transparency - if ( currMaterial ) - { - const u32 COLOR_BUFFER_LENGTH = 16; - c8 dStr[COLOR_BUFFER_LENGTH]; - - bufPtr = goAndCopyNextWord(dStr, bufPtr, COLOR_BUFFER_LENGTH, bufEnd); - f32 dValue = core::fast_atof(dStr); - - currMaterial->Meshbuffer->Material.DiffuseColor.setAlpha( (s32)(dValue * 255) ); - if (dValue<1.0f) - currMaterial->Meshbuffer->Material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA; - } - break; - case 'T': - if ( currMaterial ) - { - switch ( bufPtr[1] ) - { - case 'f': // Tf - Transmitivity - const u32 COLOR_BUFFER_LENGTH = 16; - c8 redStr[COLOR_BUFFER_LENGTH]; - c8 greenStr[COLOR_BUFFER_LENGTH]; - c8 blueStr[COLOR_BUFFER_LENGTH]; - - bufPtr = goAndCopyNextWord(redStr, bufPtr, COLOR_BUFFER_LENGTH, bufEnd); - bufPtr = goAndCopyNextWord(greenStr, bufPtr, COLOR_BUFFER_LENGTH, bufEnd); - bufPtr = goAndCopyNextWord(blueStr, bufPtr, COLOR_BUFFER_LENGTH, bufEnd); - - f32 transparency = ( core::fast_atof(redStr) + core::fast_atof(greenStr) + core::fast_atof(blueStr) ) / 3; - - currMaterial->Meshbuffer->Material.DiffuseColor.setAlpha( (s32)(transparency * 255) ); - if (transparency < 1.0f) - currMaterial->Meshbuffer->Material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA; - } - } - break; - default: // comments or not recognised - break; - } // end switch(bufPtr[0]) - // go to next line - bufPtr = goNextLine(bufPtr, bufEnd); - } // end while (bufPtr) - - // end of file. if there's an existing material, store it - if ( currMaterial ) - Materials.push_back( currMaterial ); - - delete [] buf; - mtlReader->drop(); -} - - -//! Read RGB color -const c8* COBJMeshFileLoader::readColor(const c8* bufPtr, video::SColor& color, const c8* const bufEnd) -{ - const u32 COLOR_BUFFER_LENGTH = 16; - c8 colStr[COLOR_BUFFER_LENGTH]; - - color.setAlpha(255); - bufPtr = goAndCopyNextWord(colStr, bufPtr, COLOR_BUFFER_LENGTH, bufEnd); - color.setRed((s32)(core::fast_atof(colStr) * 255.0f)); - bufPtr = goAndCopyNextWord(colStr, bufPtr, COLOR_BUFFER_LENGTH, bufEnd); - color.setGreen((s32)(core::fast_atof(colStr) * 255.0f)); - bufPtr = goAndCopyNextWord(colStr, bufPtr, COLOR_BUFFER_LENGTH, bufEnd); - color.setBlue((s32)(core::fast_atof(colStr) * 255.0f)); - return bufPtr; -} - - -//! Read 3d vector of floats -const c8* COBJMeshFileLoader::readVec3(const c8* bufPtr, core::vector3df& vec, const c8* const bufEnd) -{ - const u32 WORD_BUFFER_LENGTH = 256; - c8 wordBuffer[WORD_BUFFER_LENGTH]; - - bufPtr = goAndCopyNextWord(wordBuffer, bufPtr, WORD_BUFFER_LENGTH, bufEnd); - vec.X=-core::fast_atof(wordBuffer); // change handedness - bufPtr = goAndCopyNextWord(wordBuffer, bufPtr, WORD_BUFFER_LENGTH, bufEnd); - vec.Y=core::fast_atof(wordBuffer); - bufPtr = goAndCopyNextWord(wordBuffer, bufPtr, WORD_BUFFER_LENGTH, bufEnd); - vec.Z=core::fast_atof(wordBuffer); - return bufPtr; -} - - -//! Read 2d vector of floats -const c8* COBJMeshFileLoader::readUV(const c8* bufPtr, core::vector2df& vec, const c8* const bufEnd) -{ - const u32 WORD_BUFFER_LENGTH = 256; - c8 wordBuffer[WORD_BUFFER_LENGTH]; - - bufPtr = goAndCopyNextWord(wordBuffer, bufPtr, WORD_BUFFER_LENGTH, bufEnd); - vec.X=core::fast_atof(wordBuffer); - bufPtr = goAndCopyNextWord(wordBuffer, bufPtr, WORD_BUFFER_LENGTH, bufEnd); - vec.Y=1-core::fast_atof(wordBuffer); // change handedness - return bufPtr; -} - - -//! Read boolean value represented as 'on' or 'off' -const c8* COBJMeshFileLoader::readBool(const c8* bufPtr, bool& tf, const c8* const bufEnd) -{ - const u32 BUFFER_LENGTH = 8; - c8 tfStr[BUFFER_LENGTH]; - - bufPtr = goAndCopyNextWord(tfStr, bufPtr, BUFFER_LENGTH, bufEnd); - tf = strcmp(tfStr, "off") != 0; - return bufPtr; -} - - -COBJMeshFileLoader::SObjMtl* COBJMeshFileLoader::findMtl(const core::stringc& mtlName, const core::stringc& grpName) -{ - COBJMeshFileLoader::SObjMtl* defMaterial = 0; - // search existing Materials for best match - // exact match does return immediately, only name match means a new group - for (u32 i = 0; i < Materials.size(); ++i) - { - if ( Materials[i]->Name == mtlName ) - { - if ( Materials[i]->Group == grpName ) - return Materials[i]; - else - defMaterial = Materials[i]; - } - } - // we found a partial match - if (defMaterial) - { - Materials.push_back(new SObjMtl(*defMaterial)); - Materials.getLast()->Group = grpName; - return Materials.getLast(); - } - // we found a new group for a non-existant material - else if (grpName.size()) - { - Materials.push_back(new SObjMtl(*Materials[0])); - Materials.getLast()->Group = grpName; - return Materials.getLast(); - } - return 0; -} - - -//! skip space characters and stop on first non-space -const c8* COBJMeshFileLoader::goFirstWord(const c8* buf, const c8* const bufEnd, bool acrossNewlines) -{ - // skip space characters - if (acrossNewlines) - while((buf != bufEnd) && core::isspace(*buf)) - ++buf; - else - while((buf != bufEnd) && core::isspace(*buf) && (*buf != '\n')) - ++buf; - - return buf; -} - - -//! skip current word and stop at beginning of next one -const c8* COBJMeshFileLoader::goNextWord(const c8* buf, const c8* const bufEnd, bool acrossNewlines) -{ - // skip current word - while(( buf != bufEnd ) && !core::isspace(*buf)) - ++buf; - - return goFirstWord(buf, bufEnd, acrossNewlines); -} - - -//! Read until line break is reached and stop at the next non-space character -const c8* COBJMeshFileLoader::goNextLine(const c8* buf, const c8* const bufEnd) -{ - // look for newline characters - while(buf != bufEnd) - { - // found it, so leave - if (*buf=='\n' || *buf=='\r') - break; - ++buf; - } - return goFirstWord(buf, bufEnd); -} - - -u32 COBJMeshFileLoader::copyWord(c8* outBuf, const c8* const inBuf, u32 outBufLength, const c8* const bufEnd) -{ - if (!outBufLength) - return 0; - if (!inBuf) - { - *outBuf = 0; - return 0; - } - - u32 i = 0; - while(inBuf[i]) - { - if (core::isspace(inBuf[i]) || &(inBuf[i]) == bufEnd) - break; - ++i; - } - - u32 length = core::min_(i, outBufLength-1); - for (u32 j=0; j<length; ++j) - outBuf[j] = inBuf[j]; - - outBuf[i] = 0; - return length; -} - - -core::stringc COBJMeshFileLoader::copyLine(const c8* inBuf, const c8* bufEnd) -{ - if (!inBuf) - return core::stringc(); - - const c8* ptr = inBuf; - while (ptr<bufEnd) - { - if (*ptr=='\n' || *ptr=='\r') - break; - ++ptr; - } - return core::stringc(inBuf, (u32)(ptr-inBuf+1)); -} - - -const c8* COBJMeshFileLoader::goAndCopyNextWord(c8* outBuf, const c8* inBuf, u32 outBufLength, const c8* bufEnd) -{ - inBuf = goNextWord(inBuf, bufEnd, false); - copyWord(outBuf, inBuf, outBufLength, bufEnd); - return inBuf; -} - - -bool COBJMeshFileLoader::retrieveVertexIndices(c8* vertexData, s32* idx, const c8* bufEnd, u32 vbsize, u32 vtsize, u32 vnsize) -{ - c8 word[16] = ""; - const c8* p = goFirstWord(vertexData, bufEnd); - u32 idxType = 0; // 0 = posIdx, 1 = texcoordIdx, 2 = normalIdx - - u32 i = 0; - while ( p != bufEnd ) - { - if ( ( core::isdigit(*p)) || (*p == '-') ) - { - // build up the number - word[i++] = *p; - } - else if ( *p == '/' || *p == ' ' || *p == '\0' ) - { - // number is completed. Convert and store it - word[i] = '\0'; - // if no number was found index will become 0 and later on -1 by decrement - if (word[0]=='-') - { - idx[idxType] = core::strtol10(word+1,0); - idx[idxType] *= -1; - switch (idxType) - { - case 0: - idx[idxType] += vbsize; - break; - case 1: - idx[idxType] += vtsize; - break; - case 2: - idx[idxType] += vnsize; - break; - } - } - else - idx[idxType] = core::strtol10(word,0)-1; - - // reset the word - word[0] = '\0'; - i = 0; - - // go to the next kind of index type - if (*p == '/') - { - if ( ++idxType > 2 ) - { - // error checking, shouldn't reach here unless file is wrong - idxType = 0; - } - } - else - { - // set all missing values to disable (=-1) - while (++idxType < 3) - idx[idxType]=-1; - ++p; - break; // while - } - } - - // go to the next char - ++p; - } - - return true; -} - - -void COBJMeshFileLoader::cleanUp() -{ - for (u32 i=0; i < Materials.size(); ++i ) - { - Materials[i]->Meshbuffer->drop(); - delete Materials[i]; - } - - Materials.clear(); -} - - -} // end namespace scene -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_OBJ_LOADER_ - diff --git a/irrlicht-1.6/source/Irrlicht/COBJMeshFileLoader.h b/irrlicht-1.6/source/Irrlicht/COBJMeshFileLoader.h deleted file mode 100644 index 56ba00245..000000000 --- a/irrlicht-1.6/source/Irrlicht/COBJMeshFileLoader.h +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_OBJ_MESH_FILE_LOADER_H_INCLUDED__ -#define __C_OBJ_MESH_FILE_LOADER_H_INCLUDED__ - -#include "IMeshLoader.h" -#include "IFileSystem.h" -#include "ISceneManager.h" -#include "irrString.h" -#include "SMeshBuffer.h" -#include "irrMap.h" - -namespace irr -{ -namespace scene -{ - -//! Meshloader capable of loading obj meshes. -class COBJMeshFileLoader : public IMeshLoader -{ -public: - - //! Constructor - COBJMeshFileLoader(scene::ISceneManager* smgr, io::IFileSystem* fs); - - //! destructor - virtual ~COBJMeshFileLoader(); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".obj") - virtual bool isALoadableFileExtension(const io::path& 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: - - struct SObjMtl - { - SObjMtl() : Meshbuffer(0), Bumpiness (1.0f), Illumination(0), - RecalculateNormals(false) - { - 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(); - } - - SObjMtl(const SObjMtl& o) - : Name(o.Name), Group(o.Group), - Bumpiness(o.Bumpiness), Illumination(o.Illumination), - RecalculateNormals(false) - { - Meshbuffer = new SMeshBuffer(); - Meshbuffer->Material = o.Meshbuffer->Material; - } - - core::map<video::S3DVertex, int> VertMap; - scene::SMeshBuffer *Meshbuffer; - core::stringc Name; - core::stringc Group; - f32 Bumpiness; - c8 Illumination; - bool RecalculateNormals; - }; - - // helper method for material reading - const c8* readTextures(const c8* bufPtr, const c8* const bufEnd, SObjMtl* currMaterial, const io::path& relPath); - - // returns a pointer to the first printable character available in the buffer - const c8* goFirstWord(const c8* buf, const c8* const bufEnd, bool acrossNewlines=true); - // returns a pointer to the first printable character after the first non-printable - const c8* goNextWord(const c8* buf, const c8* const bufEnd, bool acrossNewlines=true); - // returns a pointer to the next printable character after the first line break - const c8* goNextLine(const c8* buf, const c8* const bufEnd); - // copies the current word from the inBuf to the outBuf - u32 copyWord(c8* outBuf, const c8* inBuf, u32 outBufLength, const c8* const pBufEnd); - // copies the current line from the inBuf to the outBuf - core::stringc copyLine(const c8* inBuf, const c8* const bufEnd); - - // combination of goNextWord followed by copyWord - const c8* goAndCopyNextWord(c8* outBuf, const c8* inBuf, u32 outBufLength, const c8* const pBufEnd); - - //! Read the material from the given file - void readMTL(const c8* fileName, const io::path& relPath); - - //! Find and return the material with the given name - SObjMtl* findMtl(const core::stringc& mtlName, const core::stringc& grpName); - - //! Read RGB color - const c8* readColor(const c8* bufPtr, video::SColor& color, const c8* const pBufEnd); - //! Read 3d vector of floats - const c8* readVec3(const c8* bufPtr, core::vector3df& vec, const c8* const pBufEnd); - //! Read 2d vector of floats - const c8* readUV(const c8* bufPtr, core::vector2df& vec, const c8* const pBufEnd); - //! Read boolean value represented as 'on' or 'off' - const c8* readBool(const c8* bufPtr, bool& tf, const c8* const bufEnd); - - // reads and convert to integer the vertex indices in a line of obj file's face statement - // -1 for the index if it doesn't exist - // indices are changed to 0-based index instead of 1-based from the obj file - bool retrieveVertexIndices(c8* vertexData, s32* idx, const c8* bufEnd, u32 vbsize, u32 vtsize, u32 vnsize); - - void cleanUp(); - - scene::ISceneManager* SceneManager; - io::IFileSystem* FileSystem; - - core::array<SObjMtl*> Materials; -}; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/COBJMeshWriter.cpp b/irrlicht-1.6/source/Irrlicht/COBJMeshWriter.cpp deleted file mode 100644 index 3df96f953..000000000 --- a/irrlicht-1.6/source/Irrlicht/COBJMeshWriter.cpp +++ /dev/null @@ -1,243 +0,0 @@ -// Copyright (C) 2008-2009 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_OBJ_WRITER_ - -#include "COBJMeshWriter.h" -#include "os.h" -#include "IMesh.h" -#include "IMeshBuffer.h" -#include "IAttributes.h" -#include "ISceneManager.h" -#include "IMeshCache.h" -#include "IWriteFile.h" -#include "IFileSystem.h" -#include "ITexture.h" - -namespace irr -{ -namespace scene -{ - -COBJMeshWriter::COBJMeshWriter(scene::ISceneManager* smgr, io::IFileSystem* fs) - : SceneManager(smgr), FileSystem(fs) -{ - #ifdef _DEBUG - setDebugName("COBJMeshWriter"); - #endif - - if (SceneManager) - SceneManager->grab(); - - if (FileSystem) - FileSystem->grab(); -} - - -COBJMeshWriter::~COBJMeshWriter() -{ - if (SceneManager) - SceneManager->drop(); - - if (FileSystem) - FileSystem->drop(); -} - - -//! Returns the type of the mesh writer -EMESH_WRITER_TYPE COBJMeshWriter::getType() const -{ - return EMWT_OBJ; -} - - -//! writes a mesh -bool COBJMeshWriter::writeMesh(io::IWriteFile* file, scene::IMesh* mesh, s32 flags) -{ - if (!file) - return false; - - os::Printer::log("Writing mesh", file->getFileName()); - - // write OBJ MESH header - - const core::stringc name(FileSystem->getFileBasename(SceneManager->getMeshCache()->getMeshFilename(mesh), false)+".mtl"); - file->write("# exported by Irrlicht\n",23); - file->write("mtllib ",7); - file->write(name.c_str(),name.size()); - file->write("\n\n",2); - - // write mesh buffers - - core::array<video::SMaterial*> mat; - - u32 allVertexCount=1; // count vertices over the whole file - for (u32 i=0; i<mesh->getMeshBufferCount(); ++i) - { - core::stringc num(i+1); - IMeshBuffer* buffer = mesh->getMeshBuffer(i); - if (buffer && buffer->getVertexCount()) - { - file->write("g grp", 5); - file->write(num.c_str(), num.size()); - file->write("\n",1); - - u32 j; - const u32 vertexCount = buffer->getVertexCount(); - for (j=0; j<vertexCount; ++j) - { - file->write("v ",2); - getVectorAsStringLine(buffer->getPosition(j), num); - file->write(num.c_str(), num.size()); - } - - for (j=0; j<vertexCount; ++j) - { - file->write("vt ",3); - getVectorAsStringLine(buffer->getTCoords(j), num); - file->write(num.c_str(), num.size()); - } - - for (j=0; j<vertexCount; ++j) - { - file->write("vn ",3); - getVectorAsStringLine(buffer->getNormal(j), num); - file->write(num.c_str(), num.size()); - } - - file->write("usemtl mat",10); - num = ""; - for (j=0; j<mat.size(); ++j) - { - if (*mat[j]==buffer->getMaterial()) - { - num = core::stringc(j); - break; - } - } - if (num == "") - { - num = core::stringc(mat.size()); - mat.push_back(&buffer->getMaterial()); - } - file->write(num.c_str(), num.size()); - file->write("\n",1); - - const u32 indexCount = buffer->getIndexCount(); - for (j=0; j<indexCount; j+=3) - { - file->write("f ",2); - num = core::stringc(buffer->getIndices()[j+2]+allVertexCount); - file->write(num.c_str(), num.size()); - file->write("/",1); - file->write(num.c_str(), num.size()); - file->write("/",1); - file->write(num.c_str(), num.size()); - file->write(" ",1); - - num = core::stringc(buffer->getIndices()[j+1]+allVertexCount); - file->write(num.c_str(), num.size()); - file->write("/",1); - file->write(num.c_str(), num.size()); - file->write("/",1); - file->write(num.c_str(), num.size()); - file->write(" ",1); - - num = core::stringc(buffer->getIndices()[j+0]+allVertexCount); - file->write(num.c_str(), num.size()); - file->write("/",1); - file->write(num.c_str(), num.size()); - file->write("/",1); - file->write(num.c_str(), num.size()); - file->write(" ",1); - - file->write("\n",1); - } - file->write("\n",1); - allVertexCount += vertexCount; - } - } - - if (mat.size() == 0) - return true; - - file = FileSystem->createAndWriteFile( name ); - if (file) - { - os::Printer::log("Writing material", file->getFileName()); - - file->write("# exported by Irrlicht\n\n",24); - for (u32 i=0; i<mat.size(); ++i) - { - core::stringc num(i); - file->write("newmtl mat",10); - file->write(num.c_str(),num.size()); - file->write("\n",1); - - getColorAsStringLine(mat[i]->AmbientColor, "Ka", num); - file->write(num.c_str(),num.size()); - getColorAsStringLine(mat[i]->DiffuseColor, "Kd", num); - file->write(num.c_str(),num.size()); - getColorAsStringLine(mat[i]->SpecularColor, "Ks", num); - file->write(num.c_str(),num.size()); - getColorAsStringLine(mat[i]->EmissiveColor, "Ke", num); - file->write(num.c_str(),num.size()); - num = core::stringc(mat[i]->Shininess/0.128f); - file->write("Ns ", 3); - file->write(num.c_str(),num.size()); - file->write("\n", 1); - if (mat[i]->getTexture(0)) - { - file->write("map_Kd ", 7); - file->write(mat[i]->getTexture(0)->getName().c_str(), mat[i]->getTexture(0)->getName().size()); - file->write("\n",1); - } - file->write("\n",1); - } - file->drop(); - } - return true; -} - - -void COBJMeshWriter::getVectorAsStringLine(const core::vector3df& v, core::stringc& s) const -{ - s = core::stringc(-v.X); - s += " "; - s += core::stringc(v.Y); - s += " "; - s += core::stringc(v.Z); - s += "\n"; -} - - -void COBJMeshWriter::getVectorAsStringLine(const core::vector2df& v, core::stringc& s) const -{ - s = core::stringc(v.X); - s += " "; - s += core::stringc(-v.Y); - s += "\n"; -} - - -void COBJMeshWriter::getColorAsStringLine(const video::SColor& color, const c8* const prefix, core::stringc& s) const -{ - s = prefix; - s += " "; - s += core::stringc(color.getRed()/255.f); - s += " "; - s += core::stringc(color.getGreen()/255.f); - s += " "; - s += core::stringc(color.getBlue()/255.f); - s += "\n"; -} - - -} // end namespace -} // end namespace - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/COBJMeshWriter.h b/irrlicht-1.6/source/Irrlicht/COBJMeshWriter.h deleted file mode 100644 index e4bf5870d..000000000 --- a/irrlicht-1.6/source/Irrlicht/COBJMeshWriter.h +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2008-2009 Christian Stehno -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_OBJ_MESH_WRITER_H_INCLUDED__ -#define __IRR_OBJ_MESH_WRITER_H_INCLUDED__ - -#include "IMeshWriter.h" -#include "S3DVertex.h" -#include "irrString.h" - -namespace irr -{ -namespace io -{ - class IFileSystem; -} // end namespace io -namespace scene -{ - class IMeshBuffer; - class ISceneManager; - - //! class to write meshes, implementing a OBJ writer - class COBJMeshWriter : public IMeshWriter - { - public: - - COBJMeshWriter(scene::ISceneManager* smgr, io::IFileSystem* fs); - virtual ~COBJMeshWriter(); - - //! 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: - // create vector output with line end into string - void getVectorAsStringLine(const core::vector3df& v, - core::stringc& s) const; - - // create vector output with line end into string - void getVectorAsStringLine(const core::vector2df& v, - core::stringc& s) const; - - // create color output with line end into string - void getColorAsStringLine(const video::SColor& color, - const c8* const prefix, core::stringc& s) const; - - scene::ISceneManager* SceneManager; - io::IFileSystem* FileSystem; - }; - -} // end namespace -} // end namespace - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/COCTLoader.cpp b/irrlicht-1.6/source/Irrlicht/COCTLoader.cpp deleted file mode 100644 index 149adf78c..000000000 --- a/irrlicht-1.6/source/Irrlicht/COCTLoader.cpp +++ /dev/null @@ -1,336 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h -// -// originally written by Murphy McCauley, see COCTLoader.h for details. -// -// COCTLoader by Murphy McCauley (February 2005) -// An Irrlicht loader for OCT files -// -// See the header file for additional information including use and distribution rights. - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_OCT_LOADER_ - -#include "COCTLoader.h" -#include "IVideoDriver.h" -#include "IFileSystem.h" -#include "os.h" -#include "SAnimatedMesh.h" -#include "SMeshBufferLightMap.h" -#include "irrString.h" -#include "CImage.h" -#include "ISceneManager.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -COCTLoader::COCTLoader(ISceneManager* smgr, io::IFileSystem* fs) - : SceneManager(smgr), FileSystem(fs) -{ - #ifdef _DEBUG - setDebugName("COCTLoader"); - #endif - if (FileSystem) - FileSystem->grab(); -} - - -//! destructor -COCTLoader::~COCTLoader() -{ - if (FileSystem) - FileSystem->drop(); -} - - -// Doesn't really belong here, but it's jammed in for now. -void COCTLoader::OCTLoadLights(io::IReadFile* file, scene::ISceneNode * parent, f32 radius, f32 intensityScale, bool rewind) -{ - if (rewind) - file->seek(0); - - octHeader header; - file->read(&header, sizeof(octHeader)); - - file->seek(sizeof(octVert)*header.numVerts, true); - file->seek(sizeof(octFace)*header.numFaces, true); - file->seek(sizeof(octTexture)*header.numTextures, true); - file->seek(sizeof(octLightmap)*header.numLightmaps, true); - - octLight * lights = new octLight[header.numLights]; - file->read(lights, header.numLights * sizeof(octLight)); - - //TODO: Skip past my extended data just for good form - - for (u32 i = 0; i < header.numLights; i++) - { - const f32 intensity = lights[i].intensity * intensityScale; - - SceneManager->addLightSceneNode(parent, core::vector3df(lights[i].pos[0], lights[i].pos[2], lights[i].pos[1]), - video::SColorf(lights[i].color[0] * intensity, lights[i].color[1] * intensity, lights[i].color[2] * intensity, 1.0f), - radius); - } -} - - -//! 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* COCTLoader::createMesh(io::IReadFile* file) -{ - if (!file) - return 0; - - octHeader header; - file->read(&header, sizeof(octHeader)); - - octVert * verts = new octVert[header.numVerts]; - octFace * faces = new octFace[header.numFaces]; - octTexture * textures = new octTexture[header.numTextures]; - octLightmap * lightmaps = new octLightmap[header.numLightmaps]; - octLight * lights = new octLight[header.numLights]; - - file->read(verts, sizeof(octVert) * header.numVerts); - file->read(faces, sizeof(octFace) * header.numFaces); - //TODO: Make sure id is in the legal range for Textures and Lightmaps - - u32 i; - for (i = 0; i < header.numTextures; i++) { - octTexture t; - file->read(&t, sizeof(octTexture)); - textures[t.id] = t; - } - for (i = 0; i < header.numLightmaps; i++) { - octLightmap t; - file->read(&t, sizeof(octLightmap)); - lightmaps[t.id] = t; - } - file->read(lights, sizeof(octLight) * header.numLights); - - //TODO: Now read in my extended OCT header (flexible lightmaps and vertex normals) - - - // This is the method Nikolaus Gebhardt used in the Q3 loader -- create a - // meshbuffer for every possible combination of lightmap and texture including - // a "null" texture and "null" lightmap. Ones that end up with nothing in them - // will be removed later. - - SMesh * Mesh = new SMesh(); - for (i=0; i<(header.numTextures+1) * (header.numLightmaps+1); ++i) - { - scene::SMeshBufferLightMap* buffer = new scene::SMeshBufferLightMap(); - - buffer->Material.MaterialType = video::EMT_LIGHTMAP; - buffer->Material.Lighting = false; - Mesh->addMeshBuffer(buffer); - buffer->drop(); - } - - - // Build the mesh buffers - for (i = 0; i < header.numFaces; i++) - { - if (faces[i].numVerts < 3) - continue; - - const f32* const a = verts[faces[i].firstVert].pos; - const f32* const b = verts[faces[i].firstVert+1].pos; - const f32* const c = verts[faces[i].firstVert+2].pos; - const core::vector3df normal = - core::plane3df(core::vector3df(a[0],a[1],a[2]), core::vector3df(b[0],c[1],c[2]), core::vector3df(c[0],c[1],c[2])).Normal; - - const u32 textureID = core::min_(s32(faces[i].textureID), s32(header.numTextures - 1)) + 1; - const u32 lightmapID = core::min_(s32(faces[i].lightmapID),s32(header.numLightmaps - 1)) + 1; - SMeshBufferLightMap * meshBuffer = (SMeshBufferLightMap*)Mesh->getMeshBuffer(lightmapID * (header.numTextures + 1) + textureID); - const u32 base = meshBuffer->Vertices.size(); - - // Add this face's verts - u32 v; - for (v = 0; v < faces[i].numVerts; ++v) - { - octVert * vv = &verts[faces[i].firstVert + v]; - video::S3DVertex2TCoords vert; - vert.Pos.set(vv->pos[0], vv->pos[1], vv->pos[2]); - vert.Color = video::SColor(0,255,255,255); - vert.Normal.set(normal); - - if (textureID == 0) - { - // No texture -- just a lightmap. Thus, use lightmap coords for texture 1. - // (the actual texture will be swapped later) - vert.TCoords.set(vv->lc[0], vv->lc[1]); - } - else - { - vert.TCoords.set(vv->tc[0], vv->tc[1]); - vert.TCoords2.set(vv->lc[0], vv->lc[1]); - } - - meshBuffer->Vertices.push_back(vert); - } - - // Now add the indices - // This weird loop turns convex polygons into triangle strips. - // I do it this way instead of a simple fan because it usually looks a lot better in wireframe, for example. - // High, Low - u32 h = faces[i].numVerts - 1; - u32 l = 0; - for (v = 0; v < faces[i].numVerts - 2; ++v) - { - const u32 center = (v & 1)? h - 1: l + 1; - - meshBuffer->Indices.push_back(base + h); - meshBuffer->Indices.push_back(base + l); - meshBuffer->Indices.push_back(base + center); - - if (v & 1) - --h; - else - ++l; - } - } - - // load textures - core::array<video::ITexture*> tex; - tex.reallocate(header.numTextures + 1); - tex.push_back(0); - - const core::stringc relpath = FileSystem->getFileDir(file->getFileName())+"/"; - for (i = 1; i < (header.numTextures + 1); i++) - { - core::stringc path(textures[i-1].fileName); - path.replace('\\','/'); - if (FileSystem->existFile(path)) - tex.push_back(SceneManager->getVideoDriver()->getTexture(path)); - else - // try to read in the relative path of the OCT file - tex.push_back(SceneManager->getVideoDriver()->getTexture( (relpath + path) )); - } - - // prepare lightmaps - core::array<video::ITexture*> lig; - lig.set_used(header.numLightmaps + 1); - lig[0] = 0; - - const u32 lightmapWidth = 128; - const u32 lightmapHeight = 128; - const core::dimension2d<u32> lmapsize(lightmapWidth, lightmapHeight); - - bool oldMipMapState = SceneManager->getVideoDriver()->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS); - SceneManager->getVideoDriver()->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false); - - video::CImage tmpImage(video::ECF_R8G8B8, lmapsize); - for (i = 1; i < (header.numLightmaps + 1); ++i) - { - core::stringc lightmapname = file->getFileName(); - lightmapname += ".lightmap."; - lightmapname += (int)i; - - const octLightmap* lm = &lightmaps[i-1]; - - for (u32 x=0; x<lightmapWidth; ++x) - { - for (u32 y=0; y<lightmapHeight; ++y) - { - tmpImage.setPixel(x, y, - video::SColor(255, - lm->data[x][y][2], - lm->data[x][y][1], - lm->data[x][y][0])); - } - } - - lig[i] = SceneManager->getVideoDriver()->addTexture(lightmapname.c_str(), &tmpImage); - } - SceneManager->getVideoDriver()->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, oldMipMapState); - - // Free stuff - delete [] verts; - delete [] faces; - delete [] textures; - delete [] lightmaps; - delete [] lights; - - // attach materials - for (i = 0; i < header.numLightmaps + 1; i++) - { - for (u32 j = 0; j < header.numTextures + 1; j++) - { - u32 mb = i * (header.numTextures + 1) + j; - SMeshBufferLightMap * meshBuffer = (SMeshBufferLightMap*)Mesh->getMeshBuffer(mb); - meshBuffer->Material.setTexture(0, tex[j]); - meshBuffer->Material.setTexture(1, lig[i]); - - if (meshBuffer->Material.getTexture(0) == 0) - { - // This material has no texture, so we'll just show the lightmap if there is one. - // We swapped the texture coordinates earlier. - meshBuffer->Material.setTexture(0, meshBuffer->Material.getTexture(1)); - meshBuffer->Material.setTexture(1, 0); - } - if (meshBuffer->Material.getTexture(1) == 0) - { - // If there is only one texture, it should be solid and lit. - // Among other things, this way you can preview OCT lights. - meshBuffer->Material.MaterialType = video::EMT_SOLID; - meshBuffer->Material.Lighting = true; - } - } - } - - // delete all buffers without geometry in it. - i = 0; - while(i < Mesh->MeshBuffers.size()) - { - if (Mesh->MeshBuffers[i]->getVertexCount() == 0 || - Mesh->MeshBuffers[i]->getIndexCount() == 0 || - Mesh->MeshBuffers[i]->getMaterial().getTexture(0) == 0) - { - // Meshbuffer is empty -- drop it - Mesh->MeshBuffers[i]->drop(); - Mesh->MeshBuffers.erase(i); - } - else - { - ++i; - } - } - - - // create bounding box - for (i = 0; i < Mesh->MeshBuffers.size(); ++i) - { - Mesh->MeshBuffers[i]->recalculateBoundingBox(); - } - Mesh->recalculateBoundingBox(); - - - // Set up an animated mesh to hold the mesh - SAnimatedMesh* AMesh = new SAnimatedMesh(); - AMesh->Type = EAMT_OCT; - AMesh->addMesh(Mesh); - AMesh->recalculateBoundingBox(); - Mesh->drop(); - - return AMesh; -} - - -//! returns true if the file maybe is able to be loaded by this class -//! based on the file extension (e.g. ".bsp") -bool COCTLoader::isALoadableFileExtension(const io::path& filename) const -{ - return core::hasFileExtension ( filename, "oct" ); -} - - -} // end namespace scene -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_OCT_LOADER_ - diff --git a/irrlicht-1.6/source/Irrlicht/COCTLoader.h b/irrlicht-1.6/source/Irrlicht/COCTLoader.h deleted file mode 100644 index d5c38033b..000000000 --- a/irrlicht-1.6/source/Irrlicht/COCTLoader.h +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h -// -// Because I (Nikolaus Gebhardt) did some changes to Murphy McCauley's loader, -// I'm writing this down here: -// - Replaced all dependencies to STL and stdio with irr:: methods/constructs -// - Disabled logging define -// - Changed some minor things (Don't remember what exactly.) -// Thanks a lot to Murphy McCauley for writing this loader. - -// -// COCTLoader by Murphy McCauley (February 2005) -// An Irrlicht loader for OCT files -// -// OCT file format information comes from the sourcecode of the Fluid Studios -// Radiosity Processor by Paul Nettle. You can get that sourcecode from -// http://www.fluidstudios.com . -// -// Parts of this code are from Irrlicht's CQ3LevelMesh and C3DSMeshFileLoader, -// and are Copyright (C) 2002-2004 Nikolaus Gebhardt. -// -// Use of this code is subject to the following: -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// 3. This notice may not be removed or altered from any source distribution. -// 4. You may not use this software to directly or indirectly cause harm to others. - - -#ifndef __C_OCT_LOADER_H_INCLUDED__ -#define __C_OCT_LOADER_H_INCLUDED__ - -#include "IMeshLoader.h" -#include "IReadFile.h" -#include "SMesh.h" -#include "irrString.h" - -namespace irr -{ -namespace io -{ - class IFileSystem; -} // end namespace io -namespace scene -{ - class ISceneManager; - class ISceneNode; - - class COCTLoader : public IMeshLoader - { - public: - //! constructor - COCTLoader(ISceneManager* smgr, io::IFileSystem* fs); - - //! destructor - virtual ~COCTLoader(); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".cob") - virtual bool isALoadableFileExtension(const io::path& 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); - - void OCTLoadLights(io::IReadFile* file, - ISceneNode * parent = 0, f32 radius = 500.0f, - f32 intensityScale = 0.0000001f*2.5, - bool rewind = true); - - private: - struct octHeader { - u32 numVerts; - u32 numFaces; - u32 numTextures; - u32 numLightmaps; - u32 numLights; - }; - - struct octHeaderEx { - u32 magic; // 'OCTX' - 0x4F435458L - u32 numLightmaps; - u32 lightmapWidth; - u32 lightmapHeight; - u32 containsVertexNormals; - }; - - struct octFace { - u32 firstVert; - u32 numVerts; - u32 textureID; - u32 lightmapID; - f32 plane[4]; - }; - - struct octVert { - f32 tc[2]; - f32 lc[2]; - f32 pos[3]; - }; - - struct octTexture { - u32 id; - char fileName[64]; - }; - - struct octLightmap { - u32 id; - u8 data[128][128][3]; - }; - - struct octLight { - f32 pos[3]; - f32 color[3]; - u32 intensity; - }; - - ISceneManager* SceneManager; - io::IFileSystem* FileSystem; - }; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/COSOperator.cpp b/irrlicht-1.6/source/Irrlicht/COSOperator.cpp deleted file mode 100644 index 5c14a26a3..000000000 --- a/irrlicht-1.6/source/Irrlicht/COSOperator.cpp +++ /dev/null @@ -1,213 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "COSOperator.h" - -#ifdef _IRR_WINDOWS_API_ -#ifdef _IRR_XBOX_PLATFORM_ -#else -#include <windows.h> -#endif -#else -#include <string.h> -#include <unistd.h> -#ifdef _IRR_COMPILE_WITH_OSX_DEVICE_ -#include "MacOSX/OSXClipboard.h" -#endif -#ifdef _IRR_OSX_PLATFORM_ -#include <sys/types.h> -#include <sys/sysctl.h> -#endif -#endif - -#if defined(_IRR_COMPILE_WITH_X11_DEVICE_) -#include "CIrrDeviceLinux.h" -#endif - -namespace irr -{ - -#if defined(_IRR_COMPILE_WITH_X11_DEVICE_) -// constructor linux -COSOperator::COSOperator(const c8* osversion, CIrrDeviceLinux* device) -: IrrDeviceLinux(device) -{ -} -#endif - -// constructor -COSOperator::COSOperator(const c8* osVersion) : OperatingSystem(osVersion) -{ - #ifdef _DEBUG - setDebugName("COSOperator"); - #endif -} - - -//! returns the current operating system version as string. -const wchar_t* COSOperator::getOperationSystemVersion() const -{ - return OperatingSystem.c_str(); -} - - -//! copies text to the clipboard -void COSOperator::copyToClipboard(const c8* text) const -{ - if (strlen(text)==0) - return; - -// Windows version -#if defined(_IRR_XBOX_PLATFORM_) -#elif defined(_IRR_WINDOWS_API_) - if (!OpenClipboard(NULL) || text == 0) - return; - - EmptyClipboard(); - - HGLOBAL clipbuffer; - char * buffer; - - clipbuffer = GlobalAlloc(GMEM_DDESHARE, strlen(text)+1); - buffer = (char*)GlobalLock(clipbuffer); - - strcpy(buffer, text); - - GlobalUnlock(clipbuffer); - SetClipboardData(CF_TEXT, clipbuffer); - CloseClipboard(); - -// MacOSX version -#elif defined(_IRR_COMPILE_WITH_OSX_DEVICE_) - - OSXCopyToClipboard(text); - -#elif defined(_IRR_COMPILE_WITH_X11_DEVICE_) - if ( IrrDeviceLinux ) - IrrDeviceLinux->copyToClipboard(text); -#else - -#endif -} - - -//! gets text from the clipboard -//! \return Returns 0 if no string is in there. -const c8* COSOperator::getTextFromClipboard() const -{ -#if defined(_IRR_XBOX_PLATFORM_) - return 0; -#elif defined(_IRR_WINDOWS_API_) - if (!OpenClipboard(NULL)) - return 0; - - char * buffer = 0; - - HANDLE hData = GetClipboardData( CF_TEXT ); - buffer = (char*)GlobalLock( hData ); - GlobalUnlock( hData ); - CloseClipboard(); - return buffer; - -#elif defined(_IRR_COMPILE_WITH_OSX_DEVICE_) - return (OSXCopyFromClipboard()); - -#elif defined(_IRR_COMPILE_WITH_X11_DEVICE_) - if ( IrrDeviceLinux ) - return IrrDeviceLinux->getTextFromClipboard(); - return 0; - -#else - - return 0; -#endif -} - - -bool COSOperator::getProcessorSpeedMHz(u32* MHz) const -{ -#if defined(_IRR_WINDOWS_API_) && !defined(_WIN32_WCE ) && !defined (_IRR_XBOX_PLATFORM_) - LONG Error; - - HKEY Key; - Error = RegOpenKeyEx(HKEY_LOCAL_MACHINE, - "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", - 0, KEY_READ, &Key); - - if(Error != ERROR_SUCCESS) - return false; - - DWORD Speed = 0; - DWORD Size = sizeof(Speed); - Error = RegQueryValueEx(Key, "~MHz", NULL, NULL, (LPBYTE)&Speed, &Size); - - RegCloseKey(Key); - - if (Error != ERROR_SUCCESS) - return false; - else if (MHz) - *MHz = Speed; - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return true; - -#elif defined(_IRR_OSX_PLATFORM_) - struct clockinfo CpuClock; - size_t Size = sizeof(clockinfo); - - if (!sysctlbyname("kern.clockrate", &CpuClock, &Size, NULL, 0)) - return false; - else if (MHz) - *MHz = CpuClock.hz; - return true; -#else - // could probably be read from "/proc/cpuinfo" or "/proc/cpufreq" - - return false; -#endif -} - -bool COSOperator::getSystemMemory(u32* Total, u32* Avail) const -{ -#if defined(_IRR_WINDOWS_API_) && !defined (_IRR_XBOX_PLATFORM_) - MEMORYSTATUS MemoryStatus; - MemoryStatus.dwLength = sizeof(MEMORYSTATUS); - - // cannot fail - GlobalMemoryStatus(&MemoryStatus); - - if (Total) - *Total = (u32)(MemoryStatus.dwTotalPhys>>10); - if (Avail) - *Avail = (u32)(MemoryStatus.dwAvailPhys>>10); - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return true; - -#elif defined(_IRR_POSIX_API_) -#if defined(_SC_PHYS_PAGES) && defined(_SC_AVPHYS_PAGES) - long ps = sysconf(_SC_PAGESIZE); - long pp = sysconf(_SC_PHYS_PAGES); - long ap = sysconf(_SC_AVPHYS_PAGES); - - if ((ps==-1)||(pp==-1)||(ap==-1)) - return false; - - if (Total) - *Total = (u32)((ps*(long long)pp)>>10); - if (Avail) - *Avail = (u32)((ps*(long long)ap)>>10); - return true; -#else - // TODO: implement for non-availablity of symbols/features - return false; -#endif -#else - // TODO: implement for OSX - return false; -#endif -} - - -} // end namespace - diff --git a/irrlicht-1.6/source/Irrlicht/COSOperator.h b/irrlicht-1.6/source/Irrlicht/COSOperator.h deleted file mode 100644 index e82012752..000000000 --- a/irrlicht-1.6/source/Irrlicht/COSOperator.h +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_OS_OPERATOR_H_INCLUDED__ -#define __C_OS_OPERATOR_H_INCLUDED__ - -#include "IOSOperator.h" -#include "irrString.h" -#include "IrrCompileConfig.h" - -namespace irr -{ - -class CIrrDeviceLinux; - -//! The Operating system operator provides operation system specific methods and informations. -class COSOperator : public IOSOperator -{ -public: - - // constructor -#if defined(_IRR_COMPILE_WITH_X11_DEVICE_) - COSOperator(const c8* osversion, CIrrDeviceLinux* device); -#endif - COSOperator(const c8* osversion); - - //! returns the current operation system version as string. - virtual const wchar_t* getOperationSystemVersion() const; - - //! copies text to the clipboard - virtual void copyToClipboard(const c8* text) const; - - //! gets text from the clipboard - //! \return Returns 0 if no string is in there. - virtual const c8* getTextFromClipboard() const; - - //! gets the processor speed in megahertz - //! \param Mhz: - //! \return Returns true if successful, false if not - 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(u32* Total, u32* Avail) const; - -private: - - core::stringw OperatingSystem; - -#if defined(_IRR_COMPILE_WITH_X11_DEVICE_) - CIrrDeviceLinux * IrrDeviceLinux; -#endif - -}; - -} // end namespace - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/COctTreeSceneNode.cpp b/irrlicht-1.6/source/Irrlicht/COctTreeSceneNode.cpp deleted file mode 100644 index e77800b56..000000000 --- a/irrlicht-1.6/source/Irrlicht/COctTreeSceneNode.cpp +++ /dev/null @@ -1,529 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "COctTreeSceneNode.h" -#include "OctTree.h" -#include "ISceneManager.h" -#include "IVideoDriver.h" -#include "ICameraSceneNode.h" -#include "IMeshCache.h" -#include "IAnimatedMesh.h" -#include "IMaterialRenderer.h" - -#include "os.h" - -namespace irr -{ -namespace scene -{ - - -//! constructor -COctTreeSceneNode::COctTreeSceneNode(ISceneNode* parent, ISceneManager* mgr, - s32 id, s32 minimalPolysPerNode) -: IMeshSceneNode(parent, mgr, id), StdOctTree(0), LightMapOctTree(0), TangentsOctTree(0), - MinimalPolysPerNode(minimalPolysPerNode), Mesh(0) -{ -#ifdef _DEBUG - setDebugName("COctTreeSceneNode"); -#endif - - vertexType = (video::E_VERTEX_TYPE)-1; -} - - -//! destructor -COctTreeSceneNode::~COctTreeSceneNode() -{ - deleteTree(); -} - - -void COctTreeSceneNode::OnRegisterSceneNode() -{ - if (IsVisible) - { - // because this node supports rendering of mixed mode meshes consisting of - // transparent and solid material at the same time, we need to go through all - // materials, check of what type they are and register this node for the right - // render pass according to that. - - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - - PassCount = 0; - u32 transparentCount = 0; - u32 solidCount = 0; - - // count transparent and solid materials in this scene node - for (u32 i=0; i<Materials.size(); ++i) - { - const video::IMaterialRenderer* const rnd = - driver->getMaterialRenderer(Materials[i].MaterialType); - - if (rnd && rnd->isTransparent()) - ++transparentCount; - else - ++solidCount; - - if (solidCount && transparentCount) - break; - } - - // register according to material types counted - - if (solidCount) - SceneManager->registerNodeForRendering(this, scene::ESNRP_SOLID); - - if (transparentCount) - SceneManager->registerNodeForRendering(this, scene::ESNRP_TRANSPARENT); - - ISceneNode::OnRegisterSceneNode(); - } -} - - -//! renders the node. -void COctTreeSceneNode::render() -{ - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - - if (vertexType == -1 || !driver) - return; - - ICameraSceneNode* camera = SceneManager->getActiveCamera(); - if (!camera) - return; - - bool isTransparentPass = - SceneManager->getSceneNodeRenderPass() == scene::ESNRP_TRANSPARENT; - ++PassCount; - - driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); - - SViewFrustum frust = *camera->getViewFrustum(); - - //transform the frustum to the current absolute transformation - if ( !AbsoluteTransformation.isIdentity() ) - { - core::matrix4 invTrans(AbsoluteTransformation, core::matrix4::EM4CONST_INVERSE); - frust.transform(invTrans); - } - -#if defined ( OCTTREE_BOX_BASED ) - const core::aabbox3d<float> &box = frust.getBoundingBox(); -#endif - - switch(vertexType) - { - case video::EVT_STANDARD: - { -#if defined ( OCTTREE_BOX_BASED ) - StdOctTree->calculatePolys(box); -#else - StdOctTree->calculatePolys(frust); -#endif - - const OctTree<video::S3DVertex>::SIndexData* d = StdOctTree->getIndexData(); - - for (u32 i=0; i<Materials.size(); ++i) - { - if ( 0 == d[i].CurrentSize ) - continue; - - const video::IMaterialRenderer* const rnd = driver->getMaterialRenderer(Materials[i].MaterialType); - const bool transparent = (rnd && rnd->isTransparent()); - - // only render transparent buffer if this is the transparent render pass - // and solid only in solid pass - if (transparent == isTransparentPass) - { - driver->setMaterial(Materials[i]); - driver->drawIndexedTriangleList( - &StdMeshes[i].Vertices[0], StdMeshes[i].Vertices.size(), - d[i].Indices, d[i].CurrentSize / 3); - } - } - - // for debug purposes only - if (DebugDataVisible && !Materials.empty() && PassCount==1) - { - const core::aabbox3df& box = frust.getBoundingBox(); - core::array< const core::aabbox3d<f32>* > boxes; - video::SMaterial m; - m.Lighting = false; - driver->setMaterial(m); - if ( DebugDataVisible & scene::EDS_BBOX_BUFFERS ) - { - StdOctTree->getBoundingBoxes(box, boxes); - for (u32 b=0; b!=boxes.size(); ++b) - driver->draw3DBox(*boxes[b]); - } - - if ( DebugDataVisible & scene::EDS_BBOX ) - driver->draw3DBox(Box,video::SColor(0,255,0,0)); - } - } - break; - case video::EVT_2TCOORDS: - { -#if defined ( OCTTREE_BOX_BASED ) - LightMapOctTree->calculatePolys(box); -#else - LightMapOctTree->calculatePolys(frust); -#endif - const OctTree<video::S3DVertex2TCoords>::SIndexData* d = LightMapOctTree->getIndexData(); - - for (u32 i=0; i<Materials.size(); ++i) - { - if ( 0 == d[i].CurrentSize ) - continue; - - const video::IMaterialRenderer* const rnd = driver->getMaterialRenderer(Materials[i].MaterialType); - const bool transparent = (rnd && rnd->isTransparent()); - - // only render transparent buffer if this is the transparent render pass - // and solid only in solid pass - if (transparent == isTransparentPass) - { - driver->setMaterial(Materials[i]); -#if defined (OCTTREE_USE_HARDWARE) - driver->drawMeshBuffer ( &LightMapMeshes[i] ); - -#else - driver->drawIndexedTriangleList( - &LightMapMeshes[i].Vertices[0], LightMapMeshes[i].Vertices.size(), - d[i].Indices, d[i].CurrentSize / 3); -#endif - } - } - - // for debug purposes only - if (DebugDataVisible && !Materials.empty() && PassCount==1) - { - const core::aabbox3d<float> &box = frust.getBoundingBox(); - core::array< const core::aabbox3d<f32>* > boxes; - video::SMaterial m; - m.Lighting = false; - driver->setMaterial(m); - if ( DebugDataVisible & scene::EDS_BBOX_BUFFERS ) - { - LightMapOctTree->getBoundingBoxes(box, boxes); - for (u32 b=0; b<boxes.size(); ++b) - driver->draw3DBox(*boxes[b]); - } - - if ( DebugDataVisible & scene::EDS_BBOX ) - driver->draw3DBox(Box,video::SColor(0,255,0,0)); - } - } - break; - case video::EVT_TANGENTS: - { -#if defined ( OCTTREE_BOX_BASED ) - TangentsOctTree->calculatePolys(box); -#else - TangentsOctTree->calculatePolys(frust); -#endif - - const OctTree<video::S3DVertexTangents>::SIndexData* d = TangentsOctTree->getIndexData(); - - for (u32 i=0; i<Materials.size(); ++i) - { - if ( 0 == d[i].CurrentSize ) - continue; - - const video::IMaterialRenderer* const rnd = driver->getMaterialRenderer(Materials[i].MaterialType); - const bool transparent = (rnd && rnd->isTransparent()); - - // only render transparent buffer if this is the transparent render pass - // and solid only in solid pass - if (transparent == isTransparentPass) - { - driver->setMaterial(Materials[i]); - driver->drawIndexedTriangleList( - &TangentsMeshes[i].Vertices[0], TangentsMeshes[i].Vertices.size(), - d[i].Indices, d[i].CurrentSize / 3); - } - } - - // for debug purposes only - if (DebugDataVisible && !Materials.empty() && PassCount==1) - { - const core::aabbox3d<float> &box = frust.getBoundingBox(); - core::array< const core::aabbox3d<f32>* > boxes; - video::SMaterial m; - m.Lighting = false; - driver->setMaterial(m); - if ( DebugDataVisible & scene::EDS_BBOX_BUFFERS ) - { - TangentsOctTree->getBoundingBoxes(box, boxes); - for (u32 b=0; b<boxes.size(); ++b) - driver->draw3DBox(*boxes[b]); - } - - if ( DebugDataVisible & scene::EDS_BBOX ) - driver->draw3DBox(Box,video::SColor(0,255,0,0)); - } - } - break; - } -} - - -//! returns the axis aligned bounding box of this node -const core::aabbox3d<f32>& COctTreeSceneNode::getBoundingBox() const -{ - return Box; -} - - -//! creates the tree -bool COctTreeSceneNode::createTree(IMesh* mesh) -{ - if (!mesh) - return false; - - MeshName = SceneManager->getMeshCache()->getMeshFilename( mesh ); - - mesh->grab(); - deleteTree(); - - Mesh = mesh; - - u32 beginTime = os::Timer::getRealTime(); - - u32 nodeCount = 0; - u32 polyCount = 0; - u32 i; - - Box = mesh->getBoundingBox(); - - if (mesh->getMeshBufferCount()) - { - vertexType = mesh->getMeshBuffer(0)->getVertexType(); - - switch(vertexType) - { - case video::EVT_STANDARD: - { - for (i=0; i<mesh->getMeshBufferCount(); ++i) - { - IMeshBuffer* b = mesh->getMeshBuffer(i); - - if (b->getVertexCount() && b->getIndexCount()) - { - Materials.push_back(b->getMaterial()); - - StdMeshes.push_back(OctTree<video::S3DVertex>::SMeshChunk()); - OctTree<video::S3DVertex>::SMeshChunk &nchunk = StdMeshes.getLast(); - nchunk.MaterialId = Materials.size() - 1; - - u32 v; - nchunk.Vertices.reallocate(b->getVertexCount()); - for (v=0; v<b->getVertexCount(); ++v) - nchunk.Vertices.push_back(((video::S3DVertex*)b->getVertices())[v]); - - polyCount += b->getIndexCount(); - - nchunk.Indices.reallocate(b->getIndexCount()); - for (v=0; v<b->getIndexCount(); ++v) - nchunk.Indices.push_back(b->getIndices()[v]); - } - } - - StdOctTree = new OctTree<video::S3DVertex>(StdMeshes, MinimalPolysPerNode); - nodeCount = StdOctTree->getNodeCount(); - } - break; - case video::EVT_2TCOORDS: - { - IMeshBuffer* b; - u32 meshReserve = 0; - for ( i=0; i < mesh->getMeshBufferCount(); ++i) - { - b = mesh->getMeshBuffer(i); - if (b->getVertexCount() && b->getIndexCount()) - { - meshReserve += 1; - } - - } - LightMapMeshes.reallocate ( LightMapMeshes.size() + meshReserve ); - - for ( i=0; i < mesh->getMeshBufferCount(); ++i) - { - b = mesh->getMeshBuffer(i); - - if (b->getVertexCount() && b->getIndexCount()) - { - Materials.push_back(b->getMaterial()); - LightMapMeshes.push_back(OctTree<video::S3DVertex2TCoords>::SMeshChunk()); - OctTree<video::S3DVertex2TCoords>::SMeshChunk& nchunk = LightMapMeshes.getLast(); - nchunk.MaterialId = Materials.size() - 1; - -#if defined (OCTTREE_USE_HARDWARE) - nchunk.setHardwareMappingHint ( b->getHardwareMappingHint_Vertex() ); -#endif - - u32 v; - nchunk.Vertices.reallocate(b->getVertexCount()); - for (v=0; v<b->getVertexCount(); ++v) - nchunk.Vertices.push_back(((video::S3DVertex2TCoords*)b->getVertices())[v]); - - polyCount += b->getIndexCount(); - nchunk.Indices.reallocate(b->getIndexCount()); - for (v=0; v<b->getIndexCount(); ++v) - nchunk.Indices.push_back(b->getIndices()[v]); - } - } - - LightMapOctTree = new OctTree<video::S3DVertex2TCoords>(LightMapMeshes, MinimalPolysPerNode); - nodeCount = LightMapOctTree->getNodeCount(); - } - break; - case video::EVT_TANGENTS: - { - for (u32 i=0; i<mesh->getMeshBufferCount(); ++i) - { - IMeshBuffer* b = mesh->getMeshBuffer(i); - - if (b->getVertexCount() && b->getIndexCount()) - { - Materials.push_back(b->getMaterial()); - TangentsMeshes.push_back(OctTree<video::S3DVertexTangents>::SMeshChunk()); - OctTree<video::S3DVertexTangents>::SMeshChunk& nchunk = TangentsMeshes.getLast(); - nchunk.MaterialId = Materials.size() - 1; - - u32 v; - nchunk.Vertices.reallocate(b->getVertexCount()); - for (v=0; v<b->getVertexCount(); ++v) - nchunk.Vertices.push_back(((video::S3DVertexTangents*)b->getVertices())[v]); - - polyCount += b->getIndexCount(); - nchunk.Indices.reallocate(b->getIndexCount()); - for (v=0; v<b->getIndexCount(); ++v) - nchunk.Indices.push_back(b->getIndices()[v]); - } - } - - TangentsOctTree = new OctTree<video::S3DVertexTangents>(TangentsMeshes, MinimalPolysPerNode); - nodeCount = TangentsOctTree->getNodeCount(); - } - break; - } - } - - u32 endTime = os::Timer::getRealTime(); - c8 tmp[255]; - sprintf(tmp, "Needed %ums to create OctTree SceneNode.(%u nodes, %u polys)", - endTime - beginTime, nodeCount, polyCount/3); - os::Printer::log(tmp, ELL_INFORMATION); - - return true; -} - - -//! returns the material based on the zero based index i. To get the amount -//! of materials used by this scene node, use getMaterialCount(). -//! This function is needed for inserting the node into the scene hirachy on a -//! optimal position for minimizing renderstate changes, but can also be used -//! to directly modify the material of a scene node. -video::SMaterial& COctTreeSceneNode::getMaterial(u32 i) -{ - if ( i >= Materials.size() ) - return ISceneNode::getMaterial(i); - - return Materials[i]; -} - - -//! returns amount of materials used by this scene node. -u32 COctTreeSceneNode::getMaterialCount() const -{ - return Materials.size(); -} - - -//! Writes attributes of the scene node. -void COctTreeSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const -{ - ISceneNode::serializeAttributes(out, options); - - out->addInt("MinimalPolysPerNode", MinimalPolysPerNode); - out->addString("Mesh", MeshName.c_str()); -} - - -//! Reads attributes of the scene node. -void COctTreeSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - const s32 oldMinimal = MinimalPolysPerNode; - - MinimalPolysPerNode = in->getAttributeAsInt("MinimalPolysPerNode"); - io::path newMeshStr = in->getAttributeAsString("Mesh"); - - IMesh* newMesh = 0; - - if (newMeshStr == "") - newMeshStr = MeshName; - - IAnimatedMesh* newAnimatedMesh = SceneManager->getMesh(newMeshStr.c_str()); - - if (newAnimatedMesh) - newMesh = newAnimatedMesh->getMesh(0); - - if (newMesh && ((MeshName != newMeshStr) || (MinimalPolysPerNode != oldMinimal))) - { - // recalculate tree - createTree(newMesh); - } - - ISceneNode::deserializeAttributes(in, options); -} - - -void COctTreeSceneNode::deleteTree() -{ - delete StdOctTree; - StdOctTree = 0; - StdMeshes.clear(); - - delete LightMapOctTree; - LightMapOctTree = 0; - LightMapMeshes.clear(); - - delete TangentsOctTree; - TangentsOctTree = 0; - TangentsMeshes.clear(); - - Materials.clear(); - - if(Mesh) - Mesh->drop(); -} - -void COctTreeSceneNode::setMesh(IMesh* mesh) -{ - createTree(mesh); -} - -IMesh* COctTreeSceneNode::getMesh(void) -{ - return Mesh; -} - -void COctTreeSceneNode::setReadOnlyMaterials(bool readonly) -{ - // Do nothing -} - -bool COctTreeSceneNode::isReadOnlyMaterials() const -{ - return false; -} - - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/COctTreeSceneNode.h b/irrlicht-1.6/source/Irrlicht/COctTreeSceneNode.h deleted file mode 100644 index 076a617e8..000000000 --- a/irrlicht-1.6/source/Irrlicht/COctTreeSceneNode.h +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_OCT_TREE_SCENE_NODE_H_INCLUDED__ -#define __C_OCT_TREE_SCENE_NODE_H_INCLUDED__ - -#include "IMeshSceneNode.h" -#include "OctTree.h" - -namespace irr -{ -namespace scene -{ - //! implementation of the IBspTreeSceneNode - class COctTreeSceneNode : public IMeshSceneNode - { - public: - - //! constructor - COctTreeSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - s32 minimalPolysPerNode=512); - - //! destructor - virtual ~COctTreeSceneNode(); - - virtual void OnRegisterSceneNode(); - - //! renders the node. - virtual void render(); - - //! returns the axis aligned bounding box of this node - virtual const core::aabbox3d<f32>& getBoundingBox() const; - - //! creates the tree - bool createTree(IMesh* mesh); - - //! returns the material based on the zero based index i. To get the amount - //! of materials used by this scene node, use getMaterialCount(). - //! This function is needed for inserting the node into the scene hirachy on a - //! optimal position for minimizing renderstate changes, but can also be used - //! to directly modify the material of a scene node. - virtual video::SMaterial& getMaterial(u32 i); - - //! returns amount of materials used by this scene node. - virtual u32 getMaterialCount() const; - - //! Writes attributes of the scene node. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const; - - //! Reads attributes of the scene node. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() const { return ESNT_OCT_TREE; } - - //! Sets a new mesh to display - virtual void setMesh(IMesh* mesh); - - //! Get the currently defined mesh for display. - virtual IMesh* getMesh(void); - - //! Sets if the scene node should not copy the materials of the mesh but use them in a read only style. - virtual void setReadOnlyMaterials(bool readonly); - - //! Check if the scene node should not copy the materials of the mesh but use them in a read only style - virtual bool isReadOnlyMaterials() const; - - private: - - void deleteTree(); - - core::aabbox3d<f32> Box; - - OctTree<video::S3DVertex>* StdOctTree; - core::array< OctTree<video::S3DVertex>::SMeshChunk > StdMeshes; - - OctTree<video::S3DVertex2TCoords>* LightMapOctTree; - core::array< OctTree<video::S3DVertex2TCoords>::SMeshChunk > LightMapMeshes; - - OctTree<video::S3DVertexTangents>* TangentsOctTree; - core::array< OctTree<video::S3DVertexTangents>::SMeshChunk > TangentsMeshes; - - video::E_VERTEX_TYPE vertexType; - core::array< video::SMaterial > Materials; - - core::stringc MeshName; - s32 MinimalPolysPerNode; - s32 PassCount; - - IMesh * Mesh; - }; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/COctTreeTriangleSelector.cpp b/irrlicht-1.6/source/Irrlicht/COctTreeTriangleSelector.cpp deleted file mode 100644 index 342a9daa7..000000000 --- a/irrlicht-1.6/source/Irrlicht/COctTreeTriangleSelector.cpp +++ /dev/null @@ -1,263 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "COctTreeTriangleSelector.h" -#include "ISceneNode.h" - -#include "os.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -COctTreeTriangleSelector::COctTreeTriangleSelector(const IMesh* mesh, - const ISceneNode* node, s32 minimalPolysPerNode) - : CTriangleSelector(mesh, node), Root(0), NodeCount(0), - MinimalPolysPerNode(minimalPolysPerNode) -{ - #ifdef _DEBUG - setDebugName("COctTreeTriangleSelector"); - #endif - - if (!Triangles.empty()) - { - const u32 start = os::Timer::getRealTime(); - - // create the triangle octtree - Root = new SOctTreeNode(); - Root->Triangles = Triangles; - constructOctTree(Root); - - c8 tmp[256]; - sprintf(tmp, "Needed %ums to create OctTreeTriangleSelector.(%d nodes, %u polys)", - os::Timer::getRealTime() - start, NodeCount, Triangles.size()); - os::Printer::log(tmp, ELL_INFORMATION); - } -} - - -//! destructor -COctTreeTriangleSelector::~COctTreeTriangleSelector() -{ - delete Root; -} - - -void COctTreeTriangleSelector::constructOctTree(SOctTreeNode* node) -{ - ++NodeCount; - - node->Box.reset(node->Triangles[0].pointA); - - // get bounding box - const u32 cnt = node->Triangles.size(); - for (u32 i=0; i<cnt; ++i) - { - node->Box.addInternalPoint(node->Triangles[i].pointA); - node->Box.addInternalPoint(node->Triangles[i].pointB); - node->Box.addInternalPoint(node->Triangles[i].pointC); - } - - const core::vector3df& middle = node->Box.getCenter(); - core::vector3df edges[8]; - node->Box.getEdges(edges); - - core::aabbox3d<f32> box; - core::array<core::triangle3df> keepTriangles; - - // calculate children - - if (!node->Box.isEmpty() && (s32)node->Triangles.size() > MinimalPolysPerNode) - for (s32 ch=0; ch<8; ++ch) - { - box.reset(middle); - box.addInternalPoint(edges[ch]); - node->Child[ch] = new SOctTreeNode(); - - for (s32 i=0; i<(s32)node->Triangles.size(); ++i) - { - if (node->Triangles[i].isTotalInsideBox(box)) - { - node->Child[ch]->Triangles.push_back(node->Triangles[i]); - //node->Triangles.erase(i); - //--i; - } - else - { - keepTriangles.push_back(node->Triangles[i]); - } - } - memcpy(node->Triangles.pointer(), keepTriangles.pointer(), - sizeof(core::triangle3df)*keepTriangles.size()); - - node->Triangles.set_used(keepTriangles.size()); - keepTriangles.set_used(0); - - if (node->Child[ch]->Triangles.empty()) - { - delete node->Child[ch]; - node->Child[ch] = 0; - } - else - constructOctTree(node->Child[ch]); - } -} - - -//! Gets all triangles which lie within a specific bounding box. -void COctTreeTriangleSelector::getTriangles(core::triangle3df* triangles, - s32 arraySize, s32& outTriangleCount, - const core::aabbox3d<f32>& box, - const core::matrix4* transform) const -{ - core::matrix4 mat ( core::matrix4::EM4CONST_NOTHING ); - core::aabbox3d<f32> invbox = box; - - if (SceneNode) - { - SceneNode->getAbsoluteTransformation().getInverse ( mat ); - mat.transformBoxEx(invbox); - } - - if (transform) - { - mat = *transform; - } - else - { - mat.makeIdentity(); - } - - - if (SceneNode) - mat *= SceneNode->getAbsoluteTransformation(); - - s32 trianglesWritten = 0; - - if (Root) - getTrianglesFromOctTree(Root, trianglesWritten, - arraySize, invbox, &mat, triangles); - - outTriangleCount = trianglesWritten; -} - - -void COctTreeTriangleSelector::getTrianglesFromOctTree( - SOctTreeNode* node, s32& trianglesWritten, - s32 maximumSize, const core::aabbox3d<f32>& box, - const core::matrix4* mat, core::triangle3df* triangles) const -{ - if (!box.intersectsWithBox(node->Box)) - return; - - s32 cnt = node->Triangles.size(); - if (cnt + trianglesWritten > maximumSize) - cnt -= cnt + trianglesWritten - maximumSize; - - s32 i; - - for (i=0; i<cnt; ++i) - { - mat->transformVect(triangles[trianglesWritten].pointA, node->Triangles[i].pointA ); - mat->transformVect(triangles[trianglesWritten].pointB, node->Triangles[i].pointB ); - mat->transformVect(triangles[trianglesWritten].pointC, node->Triangles[i].pointC ); - ++trianglesWritten; - } - - for (i=0; i<8; ++i) - if (node->Child[i]) - getTrianglesFromOctTree(node->Child[i], trianglesWritten, - maximumSize, box, mat, triangles); -} - - -//! Gets all triangles which have or may have contact with a 3d line. -// new version: from user Piraaate -void COctTreeTriangleSelector::getTriangles(core::triangle3df* triangles, s32 arraySize, - s32& outTriangleCount, const core::line3d<f32>& line, - const core::matrix4* transform) const -{ -#if 0 - core::aabbox3d<f32> box(line.start); - box.addInternalPoint(line.end); - - // TODO: Could be optimized for line a little bit more. - COctTreeTriangleSelector::getTriangles(triangles, arraySize, outTriangleCount, - box, transform); -#else - - core::matrix4 mat ( core::matrix4::EM4CONST_NOTHING ); - - core::vector3df vectStartInv ( line.start ), vectEndInv ( line.end ); - if (SceneNode) - { - mat = SceneNode->getAbsoluteTransformation(); - mat.makeInverse(); - mat.transformVect(vectStartInv, line.start); - mat.transformVect(vectEndInv, line.end); - } - core::line3d<f32> invline(vectStartInv, vectEndInv); - - mat.makeIdentity(); - - if (transform) - mat = (*transform); - - if (SceneNode) - mat *= SceneNode->getAbsoluteTransformation(); - - s32 trianglesWritten = 0; - - if (Root) - getTrianglesFromOctTree(Root, trianglesWritten, arraySize, invline, &mat, triangles); - - outTriangleCount = trianglesWritten; -#endif -} - -void COctTreeTriangleSelector::getTrianglesFromOctTree(SOctTreeNode* node, - s32& trianglesWritten, s32 maximumSize, const core::line3d<f32>& line, - const core::matrix4* transform, core::triangle3df* triangles) const -{ - if (!node->Box.intersectsWithLine(line)) - return; - - s32 cnt = node->Triangles.size(); - if (cnt + trianglesWritten > maximumSize) - cnt -= cnt + trianglesWritten - maximumSize; - - s32 i; - - if ( transform->isIdentity() ) - { - for (i=0; i<cnt; ++i) - { - triangles[trianglesWritten] = node->Triangles[i]; - ++trianglesWritten; - } - } - else - { - for (i=0; i<cnt; ++i) - { - triangles[trianglesWritten] = node->Triangles[i]; - transform->transformVect(triangles[trianglesWritten].pointA); - transform->transformVect(triangles[trianglesWritten].pointB); - transform->transformVect(triangles[trianglesWritten].pointC); - ++trianglesWritten; - } - } - - for (i=0; i<8; ++i) - if (node->Child[i]) - getTrianglesFromOctTree(node->Child[i], trianglesWritten, - maximumSize, line, transform, triangles); -} - - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/COctTreeTriangleSelector.h b/irrlicht-1.6/source/Irrlicht/COctTreeTriangleSelector.h deleted file mode 100644 index dea7b7e46..000000000 --- a/irrlicht-1.6/source/Irrlicht/COctTreeTriangleSelector.h +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_OCT_TREE_TRIANGLE_SELECTOR_H_INCLUDED__ -#define __C_OCT_TREE_TRIANGLE_SELECTOR_H_INCLUDED__ - -#include "CTriangleSelector.h" - -namespace irr -{ -namespace scene -{ - -class ISceneNode; - -//! Stupid triangle selector without optimization -class COctTreeTriangleSelector : public CTriangleSelector -{ -public: - - //! Constructs a selector based on a mesh - COctTreeTriangleSelector(const IMesh* mesh, const ISceneNode* node, s32 minimalPolysPerNode); - - virtual ~COctTreeTriangleSelector(); - - //! Gets all triangles which lie within a specific bounding box. - virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount, - const core::aabbox3d<f32>& box, const core::matrix4* transform=0) const; - - //! Gets all triangles which have or may have contact with a 3d line. - virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, - s32& outTriangleCount, const core::line3d<f32>& line, - const core::matrix4* transform=0) const; - -private: - - struct SOctTreeNode - { - SOctTreeNode() - { - for (u32 i=0; i!=8; ++i) - Child[i] = 0; - } - - ~SOctTreeNode() - { - for (u32 i=0; i!=8; ++i) - delete Child[i]; - } - - core::array<core::triangle3df> Triangles; - SOctTreeNode* Child[8]; - core::aabbox3d<f32> Box; - }; - - - void constructOctTree(SOctTreeNode* node); - void deleteEmptyNodes(SOctTreeNode* node); - void getTrianglesFromOctTree(SOctTreeNode* node, s32& trianglesWritten, - s32 maximumSize, const core::aabbox3d<f32>& box, - const core::matrix4* transform, - core::triangle3df* triangles) const; - - void getTrianglesFromOctTree(SOctTreeNode* node, s32& trianglesWritten, - s32 maximumSize, const core::line3d<f32>& line, - const core::matrix4* transform, - core::triangle3df* triangles) const; - - SOctTreeNode* Root; - s32 NodeCount; - s32 MinimalPolysPerNode; -}; - -} // end namespace scene -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/COgreMeshFileLoader.cpp b/irrlicht-1.6/source/Irrlicht/COgreMeshFileLoader.cpp deleted file mode 100644 index 54c851595..000000000 --- a/irrlicht-1.6/source/Irrlicht/COgreMeshFileLoader.cpp +++ /dev/null @@ -1,1204 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h -// orginally written by Christian Stehno, modified by Nikolaus Gebhardt - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_OGRE_LOADER_ - -#include "COgreMeshFileLoader.h" -#include "os.h" -#include "SMeshBuffer.h" -#include "SAnimatedMesh.h" -#include "IReadFile.h" -#include "fast_atof.h" -#include "coreutil.h" - -#ifdef _DEBUG -#define IRR_OGRE_LOADER_DEBUG -#endif - -namespace irr -{ -namespace scene -{ - - enum OGRE_CHUNKS - { - // Main Chunks - COGRE_HEADER= 0x1000, - COGRE_MESH= 0x3000, - - // sub chunks of COGRE_MESH - COGRE_SUBMESH= 0x4000, - COGRE_GEOMETRY= 0x5000, - COGRE_SKELETON_LINK= 0x6000, - COGRE_BONE_ASSIGNMENT= 0x7000, - COGRE_MESH_LOD= 0x8000, - COGRE_MESH_BOUNDS= 0x9000, - COGRE_MESH_SUBMESH_NAME_TABLE= 0xA000, - COGRE_MESH_EDGE_LISTS= 0xB000, - - // sub chunks of COGRE_SUBMESH - COGRE_SUBMESH_OPERATION= 0x4010, - COGRE_SUBMESH_BONE_ASSIGNMENT= 0x4100, - COGRE_SUBMESH_TEXTURE_ALIAS= 0x4200, - - // sub chunks of COGRE_GEOMETRY - COGRE_GEOMETRY_VERTEX_DECLARATION= 0x5100, - COGRE_GEOMETRY_VERTEX_ELEMENT= 0x5110, - COGRE_GEOMETRY_VERTEX_BUFFER= 0x5200, - COGRE_GEOMETRY_VERTEX_BUFFER_DATA= 0x5210 - }; - -//! Constructor -COgreMeshFileLoader::COgreMeshFileLoader(io::IFileSystem* fs, video::IVideoDriver* driver) -: FileSystem(fs), Driver(driver), SwapEndian(false), Mesh(0), NumUV(0) -{ - - #ifdef _DEBUG - setDebugName("COgreMeshFileLoader"); - #endif - - if (FileSystem) - FileSystem->grab(); - - if (Driver) - Driver->grab(); -} - - -//! destructor -COgreMeshFileLoader::~COgreMeshFileLoader() -{ - clearMeshes(); - - if (FileSystem) - FileSystem->drop(); - - if (Driver) - Driver->drop(); - - if (Mesh) - Mesh->drop(); -} - - -//! returns true if the file maybe is able to be loaded by this class -//! based on the file extension (e.g. ".bsp") -bool COgreMeshFileLoader::isALoadableFileExtension(const io::path& filename) const -{ - return core::hasFileExtension ( filename, "mesh" ); -} - - -//! 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* COgreMeshFileLoader::createMesh(io::IReadFile* file) -{ - s16 id; - - file->read(&id, 2); - - if (id == COGRE_HEADER) - SwapEndian=false; - else if (id == 0x0010) - SwapEndian=true; - else - return 0; - ChunkData data; - readString(file, data, Version); - if ((Version != "[MeshSerializer_v1.30]") && (Version != "[MeshSerializer_v1.40]")) - return 0; - - clearMeshes(); - if (Mesh) - Mesh->drop(); - - CurrentlyLoadingFromPath = FileSystem->getFileDir(file->getFileName()); - loadMaterials(file); - - Mesh = new SMesh(); - if (readChunk(file)) - { - // success - SAnimatedMesh* am = new SAnimatedMesh(); - am->Type = EAMT_3DS; - - for (u32 i=0; i<Mesh->getMeshBufferCount(); ++i) - ((SMeshBuffer*)Mesh->getMeshBuffer(i))->recalculateBoundingBox(); - - Mesh->recalculateBoundingBox(); - - am->addMesh(Mesh); - am->recalculateBoundingBox(); - Mesh->drop(); - Mesh = 0; - return am; - } - - Mesh->drop(); - Mesh = 0; - - return 0; -} - - -bool COgreMeshFileLoader::readChunk(io::IReadFile* file) -{ - while(file->getPos() < file->getSize()) - { - ChunkData data; - readChunkData(file, data); - - switch(data.header.id) - { - case COGRE_MESH: - { - Meshes.push_back(OgreMesh()); - readObjectChunk(file, data, Meshes.getLast()); - composeObject(); - } - break; - default: - return true; - } - } - - return true; -} - - -bool COgreMeshFileLoader::readObjectChunk(io::IReadFile* file, ChunkData& parent, OgreMesh& mesh) -{ -#ifdef IRR_OGRE_LOADER_DEBUG - os::Printer::log("Read Object Chunk"); -#endif - readBool(file, parent, mesh.SkeletalAnimation); - while ((parent.read < parent.header.length)&&(file->getPos() < file->getSize())) - { - ChunkData data; - readChunkData(file, data); - - switch(data.header.id) - { - case COGRE_GEOMETRY: - { - readGeometry(file, data, mesh.Geometry); - } - break; - case COGRE_SUBMESH: - mesh.SubMeshes.push_back(OgreSubMesh()); - readSubMesh(file, data, mesh.SubMeshes.getLast()); - break; - case COGRE_MESH_BOUNDS: - { - readVector(file, data, mesh.BBoxMinEdge); - readVector(file, data, mesh.BBoxMaxEdge); - readFloat(file, data, &mesh.BBoxRadius); - } - break; - case COGRE_SKELETON_LINK: - case COGRE_BONE_ASSIGNMENT: - case COGRE_MESH_LOD: - case COGRE_MESH_SUBMESH_NAME_TABLE: - case COGRE_MESH_EDGE_LISTS: - // ignore chunk - file->seek(data.header.length-data.read, true); - data.read += data.header.length-data.read; - break; - default: - parent.read=parent.header.length; - file->seek(-(long)sizeof(ChunkHeader), true); - return true; - } - parent.read += data.read; - } - return true; -} - - -bool COgreMeshFileLoader::readGeometry(io::IReadFile* file, ChunkData& parent, OgreGeometry& geometry) -{ -#ifdef IRR_OGRE_LOADER_DEBUG - os::Printer::log("Read Geometry"); -#endif - readInt(file, parent, &geometry.NumVertex); - while(parent.read < parent.header.length) - { - ChunkData data; - readChunkData(file, data); - - switch(data.header.id) - { - case COGRE_GEOMETRY_VERTEX_DECLARATION: - readVertexDeclaration(file, data, geometry); - break; - case COGRE_GEOMETRY_VERTEX_BUFFER: - readVertexBuffer(file, data, geometry); - break; - default: - // ignore chunk - file->seek(data.header.length-data.read, true); - data.read += data.header.length-data.read; - } - parent.read += data.read; - } - return true; -} - - -bool COgreMeshFileLoader::readVertexDeclaration(io::IReadFile* file, ChunkData& parent, OgreGeometry& geometry) -{ -#ifdef IRR_OGRE_LOADER_DEBUG - os::Printer::log("Read Vertex Declaration"); -#endif - NumUV = 0; - while(parent.read < parent.header.length) - { - ChunkData data; - readChunkData(file, data); - - switch(data.header.id) - { - case COGRE_GEOMETRY_VERTEX_ELEMENT: - { - geometry.Elements.push_back(OgreVertexElement()); - OgreVertexElement& elem = geometry.Elements.getLast(); - readShort(file, data, &elem.Source); - readShort(file, data, &elem.Type); - readShort(file, data, &elem.Semantic); - if (elem.Semantic == 7) //Tex coords - { - ++NumUV; - } - readShort(file, data, &elem.Offset); - elem.Offset /= sizeof(f32); - readShort(file, data, &elem.Index); - } - break; - default: - // ignore chunk - file->seek(data.header.length-data.read, true); - data.read += data.header.length-data.read; - } - parent.read += data.read; - } - return true; -} - - -bool COgreMeshFileLoader::readVertexBuffer(io::IReadFile* file, ChunkData& parent, OgreGeometry& geometry) -{ -#ifdef IRR_OGRE_LOADER_DEBUG - os::Printer::log("Read Vertex Buffer"); -#endif - OgreVertexBuffer buf; - readShort(file, parent, &buf.BindIndex); - readShort(file, parent, &buf.VertexSize); - buf.VertexSize /= sizeof(f32); - ChunkData data; - readChunkData(file, data); - - if (data.header.id == COGRE_GEOMETRY_VERTEX_BUFFER_DATA) - { - buf.Data.set_used(geometry.NumVertex*buf.VertexSize); - readFloat(file, data, buf.Data.pointer(), geometry.NumVertex*buf.VertexSize); - } - - geometry.Buffers.push_back(buf); - parent.read += data.read; - return true; -} - - -bool COgreMeshFileLoader::readSubMesh(io::IReadFile* file, ChunkData& parent, OgreSubMesh& subMesh) -{ -#ifdef IRR_OGRE_LOADER_DEBUG - os::Printer::log("Read Submesh"); -#endif - readString(file, parent, subMesh.Material); - readBool(file, parent, subMesh.SharedVertices); - - s32 numIndices; - readInt(file, parent, &numIndices); - subMesh.Indices.set_used(numIndices); - - readBool(file, parent, subMesh.Indices32Bit); - - if (subMesh.Indices32Bit) - readInt(file, parent, subMesh.Indices.pointer(), numIndices); - else - for (s32 i=0; i<numIndices; ++i) - { - u16 num; - readShort(file, parent, &num); - subMesh.Indices[i]=num; - } - - if (!subMesh.SharedVertices) - { - ChunkData data; - readChunkData(file, data); - - if (data.header.id==COGRE_GEOMETRY) - { - readGeometry(file, data, subMesh.Geometry); - } - parent.read += data.read; - } - - while(parent.read < parent.header.length) - { - ChunkData data; - readChunkData(file, data); - - switch(data.header.id) - { - case COGRE_SUBMESH_OPERATION: - readShort(file, data, &subMesh.Operation); - break; - case COGRE_SUBMESH_TEXTURE_ALIAS: - { - core::stringc texture, alias; - readString(file, data, texture); - readString(file, data, alias); - subMesh.TextureAliases.push_back(OgreTextureAlias(texture,alias)); - } - break; - case COGRE_SUBMESH_BONE_ASSIGNMENT: - // currently ignore chunk - file->seek(data.header.length-data.read, true); - data.read += data.header.length-data.read; - break; - default: - parent.read=parent.header.length; - file->seek(-(long)sizeof(ChunkHeader), true); - return true; - } - parent.read += data.read; - } - return true; -} - - -void COgreMeshFileLoader::composeMeshBufferMaterial(scene::IMeshBuffer* mb, const core::stringc& materialName) -{ - video::SMaterial& material=mb->getMaterial(); - for (u32 k=0; k<Materials.size(); ++k) - { - if ((materialName==Materials[k].Name)&&(Materials[k].Techniques.size())&&(Materials[k].Techniques[0].Passes.size())) - { - material=Materials[k].Techniques[0].Passes[0].Material; - if (Materials[k].Techniques[0].Passes[0].Texture.Filename.size()) - { - material.setTexture(0, Driver->getTexture(Materials[k].Techniques[0].Passes[0].Texture.Filename)); - if (!material.getTexture(0)) - { - // retry with relative path - core::stringc relative = Materials[k].Techniques[0].Passes[0].Texture.Filename; - s32 idx = relative.findLast('\\'); - if (idx != -1) - relative = relative.subString(idx+1, relative.size()-idx-1); - idx = relative.findLast('/'); - if (idx != -1) - relative = relative.subString(idx+1, relative.size()-idx-1); - material.setTexture(0, Driver->getTexture((CurrentlyLoadingFromPath+"/"+relative))); - } - } - break; - } - } -} - - -scene::SMeshBuffer* COgreMeshFileLoader::composeMeshBuffer(const core::array<s32>& indices, const OgreGeometry& geom) -{ - scene::SMeshBuffer *mb=new scene::SMeshBuffer(); - - u32 i; - mb->Indices.set_used(indices.size()); - for (i=0; i<indices.size(); ++i) - mb->Indices[i]=indices[i]; - - mb->Vertices.set_used(geom.NumVertex); - for (i=0; i<geom.Elements.size(); ++i) - { - if (geom.Elements[i].Semantic==1) //Pos - { - for (u32 j=0; j<geom.Buffers.size(); ++j) - { - if (geom.Elements[i].Source==geom.Buffers[j].BindIndex) - { - u32 eSize=geom.Buffers[j].VertexSize; - u32 ePos=geom.Elements[i].Offset; - for (s32 k=0; k<geom.NumVertex; ++k) - { - mb->Vertices[k].Color=mb->Material.DiffuseColor; - mb->Vertices[k].Pos.set(geom.Buffers[j].Data[ePos],geom.Buffers[j].Data[ePos+1],geom.Buffers[j].Data[ePos+2]); - ePos += eSize; - } - } - } - } - - if (geom.Elements[i].Semantic==4) //Normal - { - for (u32 j=0; j<geom.Buffers.size(); ++j) - { - if (geom.Elements[i].Source==geom.Buffers[j].BindIndex) - { - u32 eSize=geom.Buffers[j].VertexSize; - u32 ePos=geom.Elements[i].Offset; - for (s32 k=0; k<geom.NumVertex; ++k) - { - mb->Vertices[k].Normal.set(geom.Buffers[j].Data[ePos],geom.Buffers[j].Data[ePos+1],geom.Buffers[j].Data[ePos+2]); - ePos += eSize; - } - } - } - } - - if (geom.Elements[i].Semantic==7) //TexCoord - { - for (u32 j=0; j<geom.Buffers.size(); ++j) - { - if (geom.Elements[i].Source==geom.Buffers[j].BindIndex) - { - u32 eSize=geom.Buffers[j].VertexSize; - u32 ePos=geom.Elements[i].Offset; - for (s32 k=0; k<geom.NumVertex; ++k) - { - mb->Vertices[k].TCoords.set(geom.Buffers[j].Data[ePos],geom.Buffers[j].Data[ePos+1]); - ePos += eSize; - } - } - } - } - } - return mb; -} - - -scene::SMeshBufferLightMap* COgreMeshFileLoader::composeMeshBufferLightMap(const core::array<s32>& indices, const OgreGeometry& geom) -{ - scene::SMeshBufferLightMap *mb=new scene::SMeshBufferLightMap(); - - u32 i; - mb->Indices.set_used(indices.size()); - for (i=0; i<indices.size(); ++i) - mb->Indices[i]=indices[i]; - - mb->Vertices.set_used(geom.NumVertex); - - for (i=0; i<geom.Elements.size(); ++i) - { - if (geom.Elements[i].Semantic==1) //Pos - { - for (u32 j=0; j<geom.Buffers.size(); ++j) - { - if (geom.Elements[i].Source==geom.Buffers[j].BindIndex) - { - u32 eSize=geom.Buffers[j].VertexSize; - u32 ePos=geom.Elements[i].Offset; - for (s32 k=0; k<geom.NumVertex; ++k) - { - mb->Vertices[k].Color=mb->Material.DiffuseColor; - mb->Vertices[k].Pos.set(geom.Buffers[j].Data[ePos],geom.Buffers[j].Data[ePos+1],geom.Buffers[j].Data[ePos+2]); - ePos += eSize; - } - } - } - } - - if (geom.Elements[i].Semantic==4) //Normal - { - for (u32 j=0; j<geom.Buffers.size(); ++j) - { - if (geom.Elements[i].Source==geom.Buffers[j].BindIndex) - { - u32 eSize=geom.Buffers[j].VertexSize; - u32 ePos=geom.Elements[i].Offset; - for (s32 k=0; k<geom.NumVertex; ++k) - { - mb->Vertices[k].Normal.set(geom.Buffers[j].Data[ePos],geom.Buffers[j].Data[ePos+1],geom.Buffers[j].Data[ePos+2]); - ePos += eSize; - } - } - } - } - - if (geom.Elements[i].Semantic==7) //TexCoord - { - for (u32 j=0; j<geom.Buffers.size(); ++j) - { - if (geom.Elements[i].Source==geom.Buffers[j].BindIndex) - { - u32 eSize=geom.Buffers[j].VertexSize; - u32 ePos=geom.Elements[i].Offset; - for (s32 k=0; k<geom.NumVertex; ++k) - { - mb->Vertices[k].TCoords.set(geom.Buffers[j].Data[ePos], geom.Buffers[j].Data[ePos+1]); - mb->Vertices[k].TCoords2.set(geom.Buffers[j].Data[ePos+2], geom.Buffers[j].Data[ePos+3]); - - ePos += eSize; - } - } - } - } - } - - return mb; -} - - -void COgreMeshFileLoader::composeObject(void) -{ - for (u32 i=0; i<Meshes.size(); ++i) - { - for (u32 j=0; j<Meshes[i].SubMeshes.size(); ++j) - { - IMeshBuffer* mb; - if (Meshes[i].SubMeshes[j].SharedVertices) - { - if (NumUV < 2) - { - mb = composeMeshBuffer(Meshes[i].SubMeshes[j].Indices, Meshes[i].Geometry); - } - else - { - mb = composeMeshBufferLightMap(Meshes[i].SubMeshes[j].Indices, Meshes[i].Geometry); - } - } - else - { - if (NumUV < 2) - { - mb = composeMeshBuffer(Meshes[i].SubMeshes[j].Indices, Meshes[i].SubMeshes[j].Geometry); - } - else - { - mb = composeMeshBufferLightMap(Meshes[i].SubMeshes[j].Indices, Meshes[i].SubMeshes[j].Geometry); - } - } - - if (mb != 0) - { - composeMeshBufferMaterial(mb, Meshes[i].SubMeshes[j].Material); - Mesh->addMeshBuffer(mb); - mb->drop(); - } - } - } -} - - -core::stringc COgreMeshFileLoader::getTextureFileName(const core::stringc& texture, - core::stringc& model) -{ - s32 idx = -1; - idx = model.findLast('/'); - - if (idx == -1) - idx = model.findLast('\\'); - - if (idx == -1) - return core::stringc(); - - core::stringc p = model.subString(0, idx+1); - p.append(texture); - return p; -} - - -void COgreMeshFileLoader::getMaterialToken(io::IReadFile* file, core::stringc& token, bool noNewLine) -{ - bool parseString=false; - c8 c=0; - token = ""; - - if (file->getPos() >= file->getSize()) - return; - - file->read(&c, sizeof(c8)); - // search for word beginning - while ( core::isspace(c) && (file->getPos() < file->getSize())) - { - if (noNewLine && c=='\n') - { - file->seek(-1, true); - return; - } - file->read(&c, sizeof(c8)); - } - // check if we read a string - if (c=='"') - { - parseString = true; - file->read(&c, sizeof(c8)); - } - do - { - if (c=='/') - { - file->read(&c, sizeof(c8)); - // check for comments, cannot be part of strings - if (!parseString && (c=='/')) - { - // skip comments - while(c!='\n') - file->read(&c, sizeof(c8)); - if (!token.size()) - { - // if we start with a comment we need to skip - // following whitespaces, so restart - getMaterialToken(file, token, noNewLine); - return; - } - else - { - // else continue with next character - file->read(&c, sizeof(c8)); - continue; - } - } - else - { - // else append first slash and check if second char - // ends this token - token.append('/'); - if ((!parseString && core::isspace(c)) || - (parseString && (c=='"'))) - return; - } - } - token.append(c); - file->read(&c, sizeof(c8)); - // read until a token delimiter is found - } - while (((!parseString && !core::isspace(c)) || (parseString && (c!='"'))) && - (file->getPos() < file->getSize())); - // we want to skip the last quotes of a string , but other chars might be the next - // token already. - if (!parseString) - file->seek(-1, true); -} - - -bool COgreMeshFileLoader::readColor(io::IReadFile* file, video::SColor& col) -{ - core::stringc token; - - getMaterialToken(file, token); - if (token!="vertexcolour") - { - video::SColorf col_f; - col_f.r=core::fast_atof(token.c_str()); - getMaterialToken(file, token); - col_f.g=core::fast_atof(token.c_str()); - getMaterialToken(file, token); - col_f.b=core::fast_atof(token.c_str()); - getMaterialToken(file, token, true); - if (token.size()) - col_f.a=core::fast_atof(token.c_str()); - else - col_f.a=1.0f; - if ((col_f.r==0.0f)&&(col_f.g==0.0f)&&(col_f.b==0.0f)) - col.set(255,255,255,255); - else - col=col_f.toSColor(); - return false; - } - return true; -} - - -void COgreMeshFileLoader::readPass(io::IReadFile* file, OgreTechnique& technique) -{ -#ifdef IRR_OGRE_LOADER_DEBUG - os::Printer::log("Read Pass"); -#endif - core::stringc token; - technique.Passes.push_back(OgrePass()); - OgrePass& pass=technique.Passes.getLast(); - - getMaterialToken(file, token); //open brace or name - if (token != "{") - getMaterialToken(file, token); //open brace - - getMaterialToken(file, token); - u32 inBlocks=1; - u32 textureUnit=0; - while(inBlocks) - { - if (token=="ambient") - pass.AmbientTokenColor=readColor(file, pass.Material.AmbientColor); - else if (token=="diffuse") - pass.DiffuseTokenColor=readColor(file, pass.Material.DiffuseColor); - else if (token=="specular") - { - pass.SpecularTokenColor=readColor(file, pass.Material.SpecularColor); - getMaterialToken(file, token); - pass.Material.Shininess=core::fast_atof(token.c_str()); - } - else if (token=="emissive") - pass.EmissiveTokenColor=readColor(file, pass.Material.EmissiveColor); - else if (token=="scene_blend") - { // TODO: Choose correct values - getMaterialToken(file, token); - if (token=="add") - pass.Material.MaterialType=video::EMT_TRANSPARENT_ADD_COLOR; - else if (token=="modulate") - pass.Material.MaterialType=video::EMT_SOLID; - else if (token=="alpha_blend") - pass.Material.MaterialType=video::EMT_TRANSPARENT_ALPHA_CHANNEL; - else if (token=="colour_blend") - pass.Material.MaterialType=video::EMT_TRANSPARENT_VERTEX_ALPHA; - else - getMaterialToken(file, token); - } - else if (token=="depth_check") - { - getMaterialToken(file, token); - if (token!="on") - pass.Material.ZBuffer=video::ECFN_NEVER; - } - else if (token=="depth_write") - { - getMaterialToken(file, token); - pass.Material.ZWriteEnable=(token=="on"); - } - else if (token=="depth_func") - { - getMaterialToken(file, token); // Function name - if (token=="always_fail") - pass.Material.ZBuffer=video::ECFN_NEVER; - else if (token=="always_pass") - pass.Material.ZBuffer=video::ECFN_ALWAYS; - else if (token=="equal") - pass.Material.ZBuffer=video::ECFN_EQUAL; - else if (token=="greater") - pass.Material.ZBuffer=video::ECFN_GREATER; - else if (token=="greater_equal") - pass.Material.ZBuffer=video::ECFN_GREATEREQUAL; - else if (token=="less") - pass.Material.ZBuffer=video::ECFN_LESS; - else if (token=="less_equal") - pass.Material.ZBuffer=video::ECFN_LESSEQUAL; - else if (token=="not_equal") - pass.Material.ZBuffer=video::ECFN_NOTEQUAL; - } - else if (token=="normalise_normals") - { - getMaterialToken(file, token); - pass.Material.NormalizeNormals=(token=="on"); - } - else if (token=="depth_bias") - { - getMaterialToken(file, token); // bias value - } - else if (token=="alpha_rejection") - { - getMaterialToken(file, token); // function name - getMaterialToken(file, token); // value - pass.Material.MaterialTypeParam=core::fast_atof(token.c_str()); - } - else if (token=="alpha_to_coverage") - { - getMaterialToken(file, token); - if (token=="on") - pass.Material.AntiAliasing |= video::EAAM_ALPHA_TO_COVERAGE; - } - else if (token=="colour_write") - { - getMaterialToken(file, token); - pass.Material.ColorMask = (token=="on")?video::ECP_ALL:video::ECP_NONE; - } - else if (token=="cull_hardware") - { - getMaterialToken(file, token); // rotation name - } - else if (token=="cull_software") - { - getMaterialToken(file, token); // culling side - } - else if (token=="lighting") - { - getMaterialToken(file, token); - pass.Material.Lighting=(token=="on"); - } - else if (token=="shading") - { - getMaterialToken(file, token); - // We take phong as gouraud - pass.Material.GouraudShading=(token!="flat"); - } - else if (token=="polygon_mode") - { - getMaterialToken(file, token); - pass.Material.Wireframe=(token=="wireframe"); - pass.Material.PointCloud=(token=="points"); - } - else if (token=="max_lights") - { - getMaterialToken(file, token); - pass.MaxLights=strtol(token.c_str(),NULL,10); - } - else if (token=="point_size") - { - getMaterialToken(file, token); - pass.PointSize=core::fast_atof(token.c_str()); - } - else if (token=="point_sprites") - { - getMaterialToken(file, token); - pass.PointSprites=(token=="on"); - } - else if (token=="point_size_min") - { - getMaterialToken(file, token); - pass.PointSizeMin=strtol(token.c_str(),NULL,10); - } - else if (token=="point_size_max") - { - getMaterialToken(file, token); - pass.PointSizeMax=strtol(token.c_str(),NULL,10); - } - else if (token=="texture_unit") - { -#ifdef IRR_OGRE_LOADER_DEBUG - os::Printer::log("Read Texture unit"); -#endif - getMaterialToken(file, token); //open brace - getMaterialToken(file, token); - while(token != "}") - { - if (token=="texture") - { - getMaterialToken(file, pass.Texture.Filename); -#ifdef IRR_OGRE_LOADER_DEBUG - os::Printer::log("Read Texture", pass.Texture.Filename.c_str()); -#endif - getMaterialToken(file, pass.Texture.CoordsType, true); - getMaterialToken(file, pass.Texture.MipMaps, true); - getMaterialToken(file, pass.Texture.Alpha, true); - } - else if (token=="filtering") - { - getMaterialToken(file, token); - pass.Material.TextureLayer[textureUnit].AnisotropicFilter=0; - if (token=="point") - { - pass.Material.TextureLayer[textureUnit].BilinearFilter=false; - pass.Material.TextureLayer[textureUnit].TrilinearFilter=false; - getMaterialToken(file, token); - getMaterialToken(file, token); - } - else if (token=="linear") - { - getMaterialToken(file, token); - if (token=="point") - { - pass.Material.TextureLayer[textureUnit].BilinearFilter=false; - pass.Material.TextureLayer[textureUnit].TrilinearFilter=false; - getMaterialToken(file, token); - } - else - { - pass.Material.TextureLayer[textureUnit].BilinearFilter=true; - getMaterialToken(file, token); - pass.Material.TextureLayer[textureUnit].TrilinearFilter=(token=="linear"); - } - } - else - { - pass.Material.TextureLayer[textureUnit].BilinearFilter=(token=="bilinear"); - pass.Material.TextureLayer[textureUnit].TrilinearFilter=(token=="trilinear"); - pass.Material.TextureLayer[textureUnit].AnisotropicFilter=(token=="anisotropic")?2:1; - } - } - else if (token=="max_anisotropy") - { - getMaterialToken(file, token); - pass.Material.TextureLayer[textureUnit].AnisotropicFilter=(u8)core::strtol10(token.c_str()); - } - else if (token=="texture_alias") - { - getMaterialToken(file, pass.Texture.Alias); - } - else if (token=="mipmap_bias") - { - getMaterialToken(file, token); - pass.Material.TextureLayer[textureUnit].LODBias=(s8)core::fast_atof(token.c_str()); - } - else if (token=="colour_op") - { // TODO: Choose correct values - getMaterialToken(file, token); - if (token=="add") - pass.Material.MaterialType=video::EMT_TRANSPARENT_ADD_COLOR; - else if (token=="modulate") - pass.Material.MaterialType=video::EMT_SOLID; - else if (token=="alpha_blend") - pass.Material.MaterialType=video::EMT_TRANSPARENT_ALPHA_CHANNEL; - else if (token=="colour_blend") - pass.Material.MaterialType=video::EMT_TRANSPARENT_VERTEX_ALPHA; - else - getMaterialToken(file, token); - } - getMaterialToken(file, token); - } - ++textureUnit; - } - else if (token=="shadow_caster_program_ref") - { - do - { - getMaterialToken(file, token); - } while (token != "}"); - getMaterialToken(file, token); - } - else if (token=="vertex_program_ref") - { - do - { - getMaterialToken(file, token); - } while (token != "}"); - getMaterialToken(file, token); - } - //fog_override, iteration, point_size_attenuation - //not considered yet! - getMaterialToken(file, token); - if (token=="{") - ++inBlocks; - else if (token=="}") - --inBlocks; - } -} - - -void COgreMeshFileLoader::readTechnique(io::IReadFile* file, OgreMaterial& mat) -{ -#ifdef IRR_OGRE_LOADER_DEBUG - os::Printer::log("Read Technique"); -#endif - core::stringc token; - mat.Techniques.push_back(OgreTechnique()); - OgreTechnique& technique=mat.Techniques.getLast(); - - getMaterialToken(file, technique.Name); //open brace or name - if (technique.Name != "{") - getMaterialToken(file, token); //open brace - else - technique.Name=core::stringc((int)mat.Techniques.size()); - - getMaterialToken(file, token); - while (token != "}") - { - if (token == "pass") - readPass(file, technique); - else if (token == "scheme") - getMaterialToken(file, token); - else if (token == "lod_index") - getMaterialToken(file, token); - getMaterialToken(file, token); - } -} - - - -void COgreMeshFileLoader::loadMaterials(io::IReadFile* meshFile) -{ -#ifdef IRR_OGRE_LOADER_DEBUG - os::Printer::log("Load Materials"); -#endif - core::stringc token = meshFile->getFileName(); - io::path filename = token.subString(0, token.size()-4) + L"material"; - io::IReadFile* file = FileSystem->createAndOpenFile(filename.c_str()); - - if (!file) - { - os::Printer::log("Could not load OGRE material", filename.c_str()); - return; - } - - getMaterialToken(file, token); - - while (file->getPos() < file->getSize()) - { - if ((token == "fragment_program") || (token == "vertex_program")) - { - // skip whole block - u32 blocks=1; - do - { - getMaterialToken(file, token); - } while (token != "{"); - do - { - getMaterialToken(file, token); - if (token == "{") - ++blocks; - else if (token == "}") - --blocks; - } while (blocks); - getMaterialToken(file, token); - continue; - } - if (token != "material") - { - if (token.trim().size()) - os::Printer::log("Unknown material group", token.c_str()); - break; - } - - Materials.push_back(OgreMaterial()); - OgreMaterial& mat = Materials.getLast(); - - getMaterialToken(file, mat.Name); -#ifdef IRR_OGRE_LOADER_DEBUG - os::Printer::log("Load Material", mat.Name.c_str()); -#endif - getMaterialToken(file, token); //open brace - getMaterialToken(file, token); - while(token != "}") - { - if (token=="lod_distances") // can have several items - getMaterialToken(file, token); - else if (token=="receive_shadows") - { - getMaterialToken(file, token); - mat.ReceiveShadows=(token=="on"); - } - else if (token=="transparency_casts_shadows") - { - getMaterialToken(file, token); - mat.TransparencyCastsShadows=(token=="on"); - } - else if (token=="set_texture_alias") - { - getMaterialToken(file, token); - getMaterialToken(file, token); - } - else if (token=="technique") - readTechnique(file, mat); - getMaterialToken(file, token); - } - getMaterialToken(file, token); - } - - file->drop(); -#ifdef IRR_OGRE_LOADER_DEBUG - os::Printer::log("Finished loading Materials"); -#endif -} - - -void COgreMeshFileLoader::readChunkData(io::IReadFile* file, ChunkData& data) -{ - file->read(&data.header, sizeof(ChunkHeader)); - if (SwapEndian) - { - data.header.id = os::Byteswap::byteswap(data.header.id); - data.header.length = os::Byteswap::byteswap(data.header.length); - } - data.read += sizeof(ChunkHeader); -} - - -void COgreMeshFileLoader::readString(io::IReadFile* file, ChunkData& data, core::stringc& out) -{ - c8 c = 0; - out = ""; - - while (c!='\n') - { - file->read(&c, sizeof(c8)); - if (c!='\n') - out.append(c); - - } - data.read+=out.size()+1; -} - - -void COgreMeshFileLoader::readBool(io::IReadFile* file, ChunkData& data, bool& out) -{ - // normal C type because we read a bit string - char c = 0; - file->read(&c, sizeof(char)); - out=(c!=0); - ++data.read; -} - - -void COgreMeshFileLoader::readInt(io::IReadFile* file, ChunkData& data, s32* out, u32 num) -{ - // normal C type because we read a bit string - file->read(out, sizeof(int)); - if (SwapEndian) - { - for (u32 i=0; i<num; ++i) - out[i] = os::Byteswap::byteswap(out[i]); - } - data.read+=sizeof(int)*num; -} - - -void COgreMeshFileLoader::readShort(io::IReadFile* file, ChunkData& data, u16* out, u32 num) -{ - // normal C type because we read a bit string - file->read(out, sizeof(short)*num); - if (SwapEndian) - { - for (u32 i=0; i<num; ++i) - out[i] = os::Byteswap::byteswap(out[i]); - } - data.read+=sizeof(short)*num; -} - - -void COgreMeshFileLoader::readFloat(io::IReadFile* file, ChunkData& data, f32* out, u32 num) -{ - // normal C type because we read a bit string - file->read(out, sizeof(float)*num); - if (SwapEndian) - { - for (u32 i=0; i<num; ++i) - out[i] = os::Byteswap::byteswap(out[i]); - } - data.read+=sizeof(float)*num; -} - - -void COgreMeshFileLoader::readVector(io::IReadFile* file, ChunkData& data, core::vector3df& out) -{ - readFloat(file, data, &out.X); - readFloat(file, data, &out.Y); - readFloat(file, data, &out.Z); -} - - -void COgreMeshFileLoader::clearMeshes() -{ - for (u32 i=0; i<Meshes.size(); ++i) - { - for (int k=0; k<(int)Meshes[i].Geometry.Buffers.size(); ++k) - Meshes[i].Geometry.Buffers[k].Data.clear(); - - for (u32 j=0; j<Meshes[i].SubMeshes.size(); ++j) - { - for (int h=0; h<(int)Meshes[i].SubMeshes[j].Geometry.Buffers.size(); ++h) - Meshes[i].SubMeshes[j].Geometry.Buffers[h].Data.clear(); - } - } - - Meshes.clear(); -} - - -} // end namespace scene -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_OGRE_LOADER_ diff --git a/irrlicht-1.6/source/Irrlicht/COgreMeshFileLoader.h b/irrlicht-1.6/source/Irrlicht/COgreMeshFileLoader.h deleted file mode 100644 index 699b82d67..000000000 --- a/irrlicht-1.6/source/Irrlicht/COgreMeshFileLoader.h +++ /dev/null @@ -1,237 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h -// orginally written by Christian Stehno, modified by Nikolaus Gebhardt - -#ifndef __C_OGRE_MESH_FILE_LOADER_H_INCLUDED__ -#define __C_OGRE_MESH_FILE_LOADER_H_INCLUDED__ - -#include "IMeshLoader.h" -#include "IFileSystem.h" -#include "IVideoDriver.h" -#include "irrString.h" -#include "SMesh.h" -#include "SMeshBuffer.h" -#include "SMeshBufferLightMap.h" -#include "IMeshManipulator.h" -#include "matrix4.h" - -namespace irr -{ -namespace scene -{ - -//! Meshloader capable of loading ogre meshes. -class COgreMeshFileLoader : public IMeshLoader -{ -public: - - //! Constructor - COgreMeshFileLoader(io::IFileSystem* fs, video::IVideoDriver* driver); - - //! destructor - virtual ~COgreMeshFileLoader(); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".cob") - virtual bool isALoadableFileExtension(const io::path& 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: - - // byte-align structures - #if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) - # pragma pack( push, packing ) - # pragma pack( 1 ) - # define PACK_STRUCT - #elif defined( __GNUC__ ) - # define PACK_STRUCT __attribute__((packed)) - #else - # error compiler not supported - #endif - - struct ChunkHeader - { - u16 id; - u32 length; - } PACK_STRUCT; - - // Default alignment - #if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) - # pragma pack( pop, packing ) - #endif - - #undef PACK_STRUCT - - - struct ChunkData - { - ChunkData() : read(0) {} - - ChunkHeader header; - u32 read; - }; - - struct OgreTexture - { - OgreTexture() : Filename("") {} - - core::stringc Filename; - core::stringc Alias; - core::stringc CoordsType; - core::stringc MipMaps; - core::stringc Alpha; - }; - - struct OgrePass - { - OgrePass() : AmbientTokenColor(false), - DiffuseTokenColor(false), SpecularTokenColor(false), - EmissiveTokenColor(false), - MaxLights(8), PointSize(1.0f), PointSprites(false), - PointSizeMin(0), PointSizeMax(0) {} - - video::SMaterial Material; - OgreTexture Texture; - bool AmbientTokenColor; - bool DiffuseTokenColor; - bool SpecularTokenColor; - bool EmissiveTokenColor; - u32 MaxLights; - f32 PointSize; - bool PointSprites; - u32 PointSizeMin; - u32 PointSizeMax; - }; - - struct OgreTechnique - { - OgreTechnique() : Name(""), LODIndex(0) {} - - core::stringc Name; - core::stringc Scheme; - u16 LODIndex; - core::array<OgrePass> Passes; - }; - - struct OgreMaterial - { - OgreMaterial() : Name(""), ReceiveShadows(true), - TransparencyCastsShadows(false) {} - - core::stringc Name; - bool ReceiveShadows; - bool TransparencyCastsShadows; - core::array<f32> LODDistances; - core::array<OgreTechnique> Techniques; - }; - - struct OgreVertexBuffer - { - OgreVertexBuffer() : BindIndex(0), VertexSize(0), Data(0) {} - - u16 BindIndex; - u16 VertexSize; - core::array<f32> Data; - }; - - struct OgreVertexElement - { - u16 Source, - Type, - Semantic, - Offset, - Index; - }; - - struct OgreGeometry - { - s32 NumVertex; - core::array<OgreVertexElement> Elements; - core::array<OgreVertexBuffer> Buffers; - core::array<core::vector3df> Vertices; - core::array<core::vector3df> Normals; - core::array<s32> Colors; - core::array<core::vector2df> TexCoords; - }; - - struct OgreTextureAlias - { - OgreTextureAlias() {}; - OgreTextureAlias(const core::stringc& a, const core::stringc& b) : Texture(a), Alias(b) {}; - core::stringc Texture; - core::stringc Alias; - }; - - struct OgreSubMesh - { - core::stringc Material; - bool SharedVertices; - core::array<s32> Indices; - OgreGeometry Geometry; - u16 Operation; - core::array<OgreTextureAlias> TextureAliases; - bool Indices32Bit; - }; - - struct OgreMesh - { - bool SkeletalAnimation; - OgreGeometry Geometry; - core::array<OgreSubMesh> SubMeshes; - core::vector3df BBoxMinEdge; - core::vector3df BBoxMaxEdge; - f32 BBoxRadius; - }; - - bool readChunk(io::IReadFile* file); - bool readObjectChunk(io::IReadFile* file, ChunkData& parent, OgreMesh& mesh); - bool readGeometry(io::IReadFile* file, ChunkData& parent, OgreGeometry& geometry); - bool readVertexDeclaration(io::IReadFile* file, ChunkData& parent, OgreGeometry& geometry); - bool readVertexBuffer(io::IReadFile* file, ChunkData& parent, OgreGeometry& geometry); - bool readSubMesh(io::IReadFile* file, ChunkData& parent, OgreSubMesh& subMesh); - - void readChunkData(io::IReadFile* file, ChunkData& data); - void readString(io::IReadFile* file, ChunkData& data, core::stringc& out); - void readBool(io::IReadFile* file, ChunkData& data, bool& out); - void readInt(io::IReadFile* file, ChunkData& data, s32* out, u32 num=1); - void readShort(io::IReadFile* file, ChunkData& data, u16* out, u32 num=1); - void readFloat(io::IReadFile* file, ChunkData& data, f32* out, u32 num=1); - void readVector(io::IReadFile* file, ChunkData& data, core::vector3df& out); - - void composeMeshBufferMaterial(scene::IMeshBuffer* mb, const core::stringc& materialName); - scene::SMeshBuffer* composeMeshBuffer(const core::array<s32>& indices, const OgreGeometry& geom); - scene::SMeshBufferLightMap* composeMeshBufferLightMap(const core::array<s32>& indices, const OgreGeometry& geom); - void composeObject(void); - bool readColor(io::IReadFile* meshFile, video::SColor& col); - void getMaterialToken(io::IReadFile* file, core::stringc& token, bool noNewLine=false); - void readTechnique(io::IReadFile* meshFile, OgreMaterial& mat); - void readPass(io::IReadFile* file, OgreTechnique& technique); - void loadMaterials(io::IReadFile* file); - core::stringc getTextureFileName(const core::stringc& texture, core::stringc& model); - void clearMeshes(); - - io::IFileSystem* FileSystem; - video::IVideoDriver* Driver; - - core::stringc Version; - bool SwapEndian; - core::array<OgreMesh> Meshes; - io::path CurrentlyLoadingFromPath; - - core::array<OgreMaterial> Materials; - - SMesh* Mesh; - u32 NumUV; -}; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/COpenGLDriver.cpp b/irrlicht-1.6/source/Irrlicht/COpenGLDriver.cpp deleted file mode 100644 index 71c479642..000000000 --- a/irrlicht-1.6/source/Irrlicht/COpenGLDriver.cpp +++ /dev/null @@ -1,3590 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "COpenGLDriver.h" -// needed here also because of the create methods' parameters -#include "CNullDriver.h" - -#ifdef _IRR_COMPILE_WITH_OPENGL_ - -#include "COpenGLTexture.h" -#include "COpenGLMaterialRenderer.h" -#include "COpenGLShaderMaterialRenderer.h" -#include "COpenGLSLMaterialRenderer.h" -#include "COpenGLNormalMapRenderer.h" -#include "COpenGLParallaxMapRenderer.h" -#include "CImage.h" -#include "os.h" - -#ifdef _IRR_COMPILE_WITH_SDL_DEVICE_ -#include <SDL/SDL.h> -#endif - -namespace irr -{ -namespace video -{ - -// ----------------------------------------------------------------------- -// WINDOWS CONSTRUCTOR -// ----------------------------------------------------------------------- -#ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_ -//! Windows constructor and init code -COpenGLDriver::COpenGLDriver(const irr::SIrrlichtCreationParameters& params, - io::IFileSystem* io, CIrrDeviceWin32* device) -: CNullDriver(io, params.WindowSize), COpenGLExtensionHandler(), - CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true), - AntiAlias(params.AntiAlias), RenderTargetTexture(0), - CurrentRendertargetSize(0,0), ColorFormat(ECF_R8G8B8), - CurrentTarget(ERT_FRAME_BUFFER), - Doublebuffer(params.Doublebuffer), Stereo(params.Stereobuffer), - HDc(0), Window(static_cast<HWND>(params.WindowId)), HRc(0), DeviceType(EIDT_WIN32) -{ - #ifdef _DEBUG - setDebugName("COpenGLDriver"); - #endif -} - -//! inits the open gl driver -bool COpenGLDriver::initDriver(irr::SIrrlichtCreationParameters params, CIrrDeviceWin32* device) -{ - // Set up pixel format descriptor with desired parameters - PIXELFORMATDESCRIPTOR pfd = { - sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor - 1, // Version Number - PFD_DRAW_TO_WINDOW | // Format Must Support Window - PFD_SUPPORT_OPENGL | // Format Must Support OpenGL - (params.Doublebuffer?PFD_DOUBLEBUFFER:0) | // Must Support Double Buffering - (params.Stereobuffer?PFD_STEREO:0), // Must Support Stereo Buffer - PFD_TYPE_RGBA, // Request An RGBA Format - params.Bits, // Select Our Color Depth - 0, 0, 0, 0, 0, 0, // Color Bits Ignored - 0, // No Alpha Buffer - 0, // Shift Bit Ignored - 0, // No Accumulation Buffer - 0, 0, 0, 0, // Accumulation Bits Ignored - params.ZBufferBits, // Z-Buffer (Depth Buffer) - params.Stencilbuffer ? 1 : 0, // Stencil Buffer Depth - 0, // No Auxiliary Buffer - PFD_MAIN_PLANE, // Main Drawing Layer - 0, // Reserved - 0, 0, 0 // Layer Masks Ignored - }; - - GLuint PixelFormat; - - if (AntiAlias > 1) - { - // Create a window to test antialiasing support - const c8* ClassName = "GLCIrrDeviceWin32"; - HINSTANCE lhInstance = GetModuleHandle(0); - - // Register Class - WNDCLASSEX wcex; - wcex.cbSize = sizeof(WNDCLASSEX); - wcex.style = CS_HREDRAW | CS_VREDRAW; - wcex.lpfnWndProc = (WNDPROC)DefWindowProc; - wcex.cbClsExtra = 0; - wcex.cbWndExtra = 0; - wcex.hInstance = lhInstance; - wcex.hIcon = NULL; - wcex.hCursor = LoadCursor(NULL, IDC_ARROW); - wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); - wcex.lpszMenuName = 0; - wcex.lpszClassName = ClassName; - wcex.hIconSm = 0; - wcex.hIcon = 0; - - RegisterClassEx(&wcex); - RECT clientSize; - clientSize.top = 0; - clientSize.left = 0; - clientSize.right = params.WindowSize.Width; - clientSize.bottom = params.WindowSize.Height; - - DWORD style = WS_POPUP; - - if (!params.Fullscreen) - style = WS_SYSMENU | WS_BORDER | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; - - AdjustWindowRect(&clientSize, style, FALSE); - - const s32 realWidth = clientSize.right - clientSize.left; - const s32 realHeight = clientSize.bottom - clientSize.top; - - const s32 windowLeft = (GetSystemMetrics(SM_CXSCREEN) - realWidth) / 2; - const s32 windowTop = (GetSystemMetrics(SM_CYSCREEN) - realHeight) / 2; - - HWND temporary_wnd=CreateWindow(ClassName, "", style, windowLeft, windowTop, - realWidth, realHeight, NULL, NULL, lhInstance, NULL); - - if (!temporary_wnd) - { - os::Printer::log("Cannot create a temporary window.", ELL_ERROR); - return false; - } - - HDc = GetDC(temporary_wnd); - for (u32 i=0; i<5; ++i) - { - if (i == 1) - { - if (params.Stencilbuffer) - { - os::Printer::log("Cannot create a GL device with stencil buffer, disabling stencil shadows.", ELL_WARNING); - params.Stencilbuffer = false; - pfd.cStencilBits = 0; - } - else - continue; - } - else - if (i == 2) - { - pfd.cDepthBits = 24; - } - if (i == 3) - { - if (params.Bits!=16) - pfd.cDepthBits = 16; - else - continue; - } - else - if (i == 4) - { - // try single buffer - if (params.Doublebuffer) - pfd.dwFlags &= ~PFD_DOUBLEBUFFER; - else - continue; - } - else - if (i == 5) - { - os::Printer::log("Cannot create a GL device context", "No suitable format for temporary window.", ELL_ERROR); - ReleaseDC(temporary_wnd, HDc); - DestroyWindow(temporary_wnd); - return false; - } - - // choose pixelformat - PixelFormat = ChoosePixelFormat(HDc, &pfd); - if (PixelFormat) - break; - } - - SetPixelFormat(HDc, PixelFormat, &pfd); - HRc=wglCreateContext(HDc); - if (!HRc) - { - os::Printer::log("Cannot create a temporary GL rendering context.", ELL_ERROR); - ReleaseDC(temporary_wnd, HDc); - DestroyWindow(temporary_wnd); - return false; - } - - if (!wglMakeCurrent(HDc, HRc)) - { - os::Printer::log("Cannot activate a temporary GL rendering context.", ELL_ERROR); - wglDeleteContext(HRc); - ReleaseDC(temporary_wnd, HDc); - DestroyWindow(temporary_wnd); - return false; - } - -#ifdef WGL_ARB_pixel_format - PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormat_ARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB"); - if (wglChoosePixelFormat_ARB) - { - // This value determines the number of samples used for antialiasing - // My experience is that 8 does not show a big - // improvement over 4, but 4 shows a big improvement - // over 2. - - if(AntiAlias > 32) - AntiAlias = 32; - - f32 fAttributes[] = {0.0, 0.0}; - s32 iAttributes[] = - { - WGL_DRAW_TO_WINDOW_ARB,GL_TRUE, - WGL_SUPPORT_OPENGL_ARB,GL_TRUE, - WGL_ACCELERATION_ARB,WGL_FULL_ACCELERATION_ARB, - WGL_COLOR_BITS_ARB,(params.Bits==32) ? 24 : 15, - WGL_ALPHA_BITS_ARB,(params.Bits==32) ? 8 : 1, - WGL_DEPTH_BITS_ARB,params.ZBufferBits, // 10,11 - WGL_STENCIL_BITS_ARB,(params.Stencilbuffer) ? 1 : 0, - WGL_DOUBLE_BUFFER_ARB,(params.Doublebuffer) ? GL_TRUE : GL_FALSE, - WGL_STEREO_ARB,(params.Stereobuffer) ? GL_TRUE : GL_FALSE, -#ifdef WGL_ARB_multisample - WGL_SAMPLE_BUFFERS_ARB, 1, - WGL_SAMPLES_ARB,AntiAlias, // 20,21 -#elif defined(WGL_EXT_multisample) - WGL_SAMPLE_BUFFERS_EXT, 1, - WGL_SAMPLES_EXT,AntiAlias, // 20,21 -#elif defined(WGL_3DFX_multisample) - WGL_SAMPLE_BUFFERS_3DFX, 1, - WGL_SAMPLES_3DFX,AntiAlias, // 20,21 -#endif - WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB, - // other possible values: - // WGL_ARB_pixel_format_float: WGL_TYPE_RGBA_FLOAT_ARB - // WGL_EXT_pixel_format_packed_float: WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT -#if 0 -#ifdef WGL_EXT_framebuffer_sRGB - WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT, GL_FALSE, -#endif -#endif - 0,0 - }; - - s32 rv=0; - // Try to get an acceptable pixel format - while(rv==0 && iAttributes[21]>1) - { - s32 pixelFormat=0; - u32 numFormats=0; - const s32 valid = wglChoosePixelFormat_ARB(HDc,iAttributes,fAttributes,1,&pixelFormat,&numFormats); - - if (valid && numFormats>0) - rv = pixelFormat; - else - iAttributes[21] -= 1; - } - if (rv) - { - PixelFormat=rv; - AntiAlias=iAttributes[21]; - } - } - else -#endif - AntiAlias=0; - - wglMakeCurrent(HDc, NULL); - wglDeleteContext(HRc); - ReleaseDC(temporary_wnd, HDc); - DestroyWindow(temporary_wnd); - } - - // get hdc - HDc=GetDC(Window); - if (!HDc) - { - os::Printer::log("Cannot create a GL device context.", ELL_ERROR); - return false; - } - - // search for pixel format the simple way - if (AntiAlias < 2) - { - for (u32 i=0; i<5; ++i) - { - if (i == 1) - { - if (params.Stencilbuffer) - { - os::Printer::log("Cannot create a GL device with stencil buffer, disabling stencil shadows.", ELL_WARNING); - params.Stencilbuffer = false; - pfd.cStencilBits = 0; - } - else - continue; - } - else - if (i == 2) - { - pfd.cDepthBits = 24; - } - if (i == 3) - { - if (params.Bits!=16) - pfd.cDepthBits = 16; - else - continue; - } - else - if (i == 4) - { - os::Printer::log("Cannot create a GL device context", "No suitable format.", ELL_ERROR); - return false; - } - - // choose pixelformat - PixelFormat = ChoosePixelFormat(HDc, &pfd); - if (PixelFormat) - break; - } - } - - // set pixel format - if (!SetPixelFormat(HDc, PixelFormat, &pfd)) - { - os::Printer::log("Cannot set the pixel format.", ELL_ERROR); - return false; - } - - // create rendering context -#ifdef WGL_ARB_create_context - PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs_ARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB"); - if (wglCreateContextAttribs_ARB) - HRc=wglCreateContextAttribs_ARB(HDc, 0, NULL); - else -#endif - HRc=wglCreateContext(HDc); - - if (!HRc) - { - os::Printer::log("Cannot create a GL rendering context.", ELL_ERROR); - return false; - } - - // activate rendering context - if (!wglMakeCurrent(HDc, HRc)) - { - os::Printer::log("Cannot activate GL rendering context", ELL_ERROR); - wglDeleteContext(HRc); - return false; - } - - int pf = GetPixelFormat(HDc); - DescribePixelFormat(HDc, pf, sizeof(PIXELFORMATDESCRIPTOR), &pfd); - if (pfd.cAlphaBits != 0) - { - if (pfd.cRedBits == 8) - ColorFormat = ECF_A8R8G8B8; - else - ColorFormat = ECF_A1R5G5B5; - } - else - { - if (pfd.cRedBits == 8) - ColorFormat = ECF_R8G8B8; - else - ColorFormat = ECF_R5G6B5; - } - - genericDriverInit(params.WindowSize, params.Stencilbuffer); - -#ifdef WGL_EXT_swap_control - PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT; - // vsync extension - wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT"); - // set vsync - if (wglSwapIntervalEXT) - wglSwapIntervalEXT(params.Vsync ? 1 : 0); -#endif - - // set exposed data - ExposedData.OpenGLWin32.HDc = HDc; - ExposedData.OpenGLWin32.HRc = HRc; - ExposedData.OpenGLWin32.HWnd = Window; - - return true; -} - -#endif // _IRR_COMPILE_WITH_WINDOWS_DEVICE_ - -// ----------------------------------------------------------------------- -// MacOSX CONSTRUCTOR -// ----------------------------------------------------------------------- -#ifdef _IRR_COMPILE_WITH_OSX_DEVICE_ -//! Windows constructor and init code -COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params, - io::IFileSystem* io, CIrrDeviceMacOSX *device) -: CNullDriver(io, params.WindowSize), COpenGLExtensionHandler(), - CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true), - AntiAlias(params.AntiAlias), RenderTargetTexture(0), - CurrentRendertargetSize(0,0), ColorFormat(ECF_R8G8B8), - CurrentTarget(ERT_FRAME_BUFFER), - Doublebuffer(params.Doublebuffer), Stereo(params.Stereobuffer), - _device(device), DeviceType(EIDT_OSX) -{ - #ifdef _DEBUG - setDebugName("COpenGLDriver"); - #endif - genericDriverInit(params.WindowSize, params.Stencilbuffer); -} - -#endif - -// ----------------------------------------------------------------------- -// LINUX CONSTRUCTOR -// ----------------------------------------------------------------------- -#ifdef _IRR_COMPILE_WITH_X11_DEVICE_ -//! Linux constructor and init code -COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params, - io::IFileSystem* io, CIrrDeviceLinux* device) -: CNullDriver(io, params.WindowSize), COpenGLExtensionHandler(), - CurrentRenderMode(ERM_NONE), ResetRenderStates(true), - Transformation3DChanged(true), AntiAlias(params.AntiAlias), - RenderTargetTexture(0), CurrentRendertargetSize(0,0), ColorFormat(ECF_R8G8B8), - CurrentTarget(ERT_FRAME_BUFFER), - Doublebuffer(params.Doublebuffer), Stereo(params.Stereobuffer), DeviceType(EIDT_X11) -{ - #ifdef _DEBUG - setDebugName("COpenGLDriver"); - #endif -} - -//! inits the open gl driver -bool COpenGLDriver::initDriver(irr::SIrrlichtCreationParameters params, CIrrDeviceLinux* device) -{ - ExposedData.OpenGLLinux.X11Context = glXGetCurrentContext(); - ExposedData.OpenGLLinux.X11Display = glXGetCurrentDisplay(); - ExposedData.OpenGLLinux.X11Window = (unsigned long)params.WindowId; - Drawable = glXGetCurrentDrawable(); - - genericDriverInit(params.WindowSize, params.Stencilbuffer); - - // set vsync -#ifdef GLX_SGI_swap_control -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (params.Vsync && glxSwapIntervalSGI) - glxSwapIntervalSGI(1); -#else - if (params.Vsync) - glXSwapIntervalSGI(1); -#endif -#endif - return true; -} - -#endif // _IRR_COMPILE_WITH_X11_DEVICE_ - - -// ----------------------------------------------------------------------- -// SDL CONSTRUCTOR -// ----------------------------------------------------------------------- -#ifdef _IRR_COMPILE_WITH_SDL_DEVICE_ -//! SDL constructor and init code -COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params, - io::IFileSystem* io, CIrrDeviceSDL* device) -: CNullDriver(io, params.WindowSize), COpenGLExtensionHandler(), - CurrentRenderMode(ERM_NONE), ResetRenderStates(true), - Transformation3DChanged(true), AntiAlias(params.AntiAlias), - RenderTargetTexture(0), CurrentRendertargetSize(0,0), ColorFormat(ECF_R8G8B8), - CurrentTarget(ERT_FRAME_BUFFER), - Doublebuffer(params.Doublebuffer), Stereo(params.Stereobuffer), DeviceType(EIDT_SDL) -{ - #ifdef _DEBUG - setDebugName("COpenGLDriver"); - #endif - - genericDriverInit(params.WindowSize, params.Stencilbuffer); -} - -#endif // _IRR_COMPILE_WITH_SDL_DEVICE_ - - -//! destructor -COpenGLDriver::~COpenGLDriver() -{ - RequestedLights.clear(); - - deleteMaterialRenders(); - - // I get a blue screen on my laptop, when I do not delete the - // textures manually before releasing the dc. Oh how I love this. - - deleteAllTextures(); - -#ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_ - if (DeviceType == EIDT_WIN32) - { - - if (HRc) - { - if (!wglMakeCurrent(0, 0)) - os::Printer::log("Release of dc and rc failed.", ELL_WARNING); - - if (!wglDeleteContext(HRc)) - os::Printer::log("Release of rendering context failed.", ELL_WARNING); - } - - if (HDc) - ReleaseDC(Window, HDc); - } -#endif -} - -// ----------------------------------------------------------------------- -// METHODS -// ----------------------------------------------------------------------- - -bool COpenGLDriver::genericDriverInit(const core::dimension2d<u32>& screenSize, bool stencilBuffer) -{ - Name=L"OpenGL "; - Name.append(glGetString(GL_VERSION)); - s32 pos=Name.findNext(L' ', 7); - if (pos != -1) - Name=Name.subString(0, pos); - printVersion(); - - // print renderer information - const GLubyte* renderer = glGetString(GL_RENDERER); - const GLubyte* vendor = glGetString(GL_VENDOR); - if (renderer && vendor) - { - os::Printer::log(reinterpret_cast<const c8*>(renderer), reinterpret_cast<const c8*>(vendor), ELL_INFORMATION); - vendorName = reinterpret_cast<const c8*>(vendor); - } - - u32 i; - for (i=0; i<MATERIAL_MAX_TEXTURES; ++i) - CurrentTexture[i]=0; - // load extensions - initExtensions(stencilBuffer); - if (queryFeature(EVDF_ARB_GLSL)) - { - char buf[32]; - const u32 maj = ShaderLanguageVersion/100; - snprintf(buf, 32, "%u.%u", maj, ShaderLanguageVersion-maj*100); - os::Printer::log("GLSL version", buf, ELL_INFORMATION); - } - else - os::Printer::log("GLSL not available.", ELL_INFORMATION); - - glPixelStorei(GL_PACK_ALIGNMENT, 1); - - // Reset The Current Viewport - glViewport(0, 0, screenSize.Width, screenSize.Height); - - setAmbientLight(SColorf(0.0f,0.0f,0.0f,0.0f)); -#ifdef GL_EXT_separate_specular_color - if (FeatureAvailable[IRR_EXT_separate_specular_color]) - glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); -#endif - glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1); - -// This is a fast replacement for NORMALIZE_NORMALS -// if ((Version>101) || FeatureAvailable[IRR_EXT_rescale_normal]) -// glEnable(GL_RESCALE_NORMAL_EXT); - - glClearDepth(1.0); - glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); - glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); - glHint(GL_POINT_SMOOTH_HINT, GL_FASTEST); - glDepthFunc(GL_LEQUAL); - glFrontFace(GL_CW); - // adjust flat coloring scheme to DirectX version -#if defined(GL_ARB_provoking_vertex) || defined(GL_EXT_provoking_vertex) - extGlProvokingVertex(GL_FIRST_VERTEX_CONVENTION_EXT); -#endif - - UserClipPlane.reallocate(MaxUserClipPlanes); - UserClipPlaneEnabled.reallocate(MaxUserClipPlanes); - for (i=0; i<MaxUserClipPlanes; ++i) - { - UserClipPlane.push_back(core::plane3df()); - UserClipPlaneEnabled.push_back(false); - } - - // create material renderers - createMaterialRenderers(); - - // set the renderstates - setRenderStates3DMode(); - - glAlphaFunc(GL_GREATER, 0.f); - - // set fog mode - setFog(FogColor, FogType, FogStart, FogEnd, FogDensity, PixelFog, RangeFog); - - // create matrix for flipping textures - TextureFlipMatrix.buildTextureTransform(0.0f, core::vector2df(0,0), core::vector2df(0,1.0f), core::vector2df(1.0f,-1.0f)); - - // We need to reset once more at the beginning of the first rendering. - // This fixes problems with intermediate changes to the material during texture load. - ResetRenderStates = true; - - return true; -} - - -void COpenGLDriver::createMaterialRenderers() -{ - // create OpenGL material renderers - - addAndDropMaterialRenderer(new COpenGLMaterialRenderer_SOLID(this)); - addAndDropMaterialRenderer(new COpenGLMaterialRenderer_SOLID_2_LAYER(this)); - - // add the same renderer for all lightmap types - COpenGLMaterialRenderer_LIGHTMAP* lmr = new COpenGLMaterialRenderer_LIGHTMAP(this); - addMaterialRenderer(lmr); // for EMT_LIGHTMAP: - addMaterialRenderer(lmr); // for EMT_LIGHTMAP_ADD: - addMaterialRenderer(lmr); // for EMT_LIGHTMAP_M2: - addMaterialRenderer(lmr); // for EMT_LIGHTMAP_M4: - addMaterialRenderer(lmr); // for EMT_LIGHTMAP_LIGHTING: - addMaterialRenderer(lmr); // for EMT_LIGHTMAP_LIGHTING_M2: - addMaterialRenderer(lmr); // for EMT_LIGHTMAP_LIGHTING_M4: - lmr->drop(); - - // add remaining material renderer - addAndDropMaterialRenderer(new COpenGLMaterialRenderer_DETAIL_MAP(this)); - addAndDropMaterialRenderer(new COpenGLMaterialRenderer_SPHERE_MAP(this)); - addAndDropMaterialRenderer(new COpenGLMaterialRenderer_REFLECTION_2_LAYER(this)); - addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_ADD_COLOR(this)); - addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL(this)); - addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF(this)); - addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_VERTEX_ALPHA(this)); - addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER(this)); - - // add normal map renderers - s32 tmp = 0; - video::IMaterialRenderer* renderer = 0; - renderer = new COpenGLNormalMapRenderer(this, tmp, MaterialRenderers[EMT_SOLID].Renderer); - renderer->drop(); - renderer = new COpenGLNormalMapRenderer(this, tmp, MaterialRenderers[EMT_TRANSPARENT_ADD_COLOR].Renderer); - renderer->drop(); - renderer = new COpenGLNormalMapRenderer(this, tmp, MaterialRenderers[EMT_TRANSPARENT_VERTEX_ALPHA].Renderer); - renderer->drop(); - - // add parallax map renderers - renderer = new COpenGLParallaxMapRenderer(this, tmp, MaterialRenderers[EMT_SOLID].Renderer); - renderer->drop(); - renderer = new COpenGLParallaxMapRenderer(this, tmp, MaterialRenderers[EMT_TRANSPARENT_ADD_COLOR].Renderer); - renderer->drop(); - renderer = new COpenGLParallaxMapRenderer(this, tmp, MaterialRenderers[EMT_TRANSPARENT_VERTEX_ALPHA].Renderer); - renderer->drop(); - - // add basic 1 texture blending - addAndDropMaterialRenderer(new COpenGLMaterialRenderer_ONETEXTURE_BLEND(this)); -} - - -//! presents the rendered scene on the screen, returns false if failed -bool COpenGLDriver::endScene() -{ - CNullDriver::endScene(); - - glFlush(); - -#ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_ - if (DeviceType == EIDT_WIN32) - return SwapBuffers(HDc) == TRUE; -#endif - -#ifdef _IRR_COMPILE_WITH_X11_DEVICE_ - if (DeviceType == EIDT_X11) - { - glXSwapBuffers((Display*)ExposedData.OpenGLLinux.X11Display, Drawable); - return true; - } -#endif - -#ifdef _IRR_COMPILE_WITH_OSX_DEVICE_ - if (DeviceType == EIDT_OSX) - { - _device->flush(); - return true; - } -#endif - -#ifdef _IRR_COMPILE_WITH_SDL_DEVICE_ - if (DeviceType == EIDT_SDL) - { - SDL_GL_SwapBuffers(); - return true; - } -#endif - - // todo: console device present - - return false; -} - - -//! clears the zbuffer and color buffer -void COpenGLDriver::clearBuffers(bool backBuffer, bool zBuffer, bool stencilBuffer, SColor color) -{ - GLbitfield mask = 0; - if (backBuffer) - { - const f32 inv = 1.0f / 255.0f; - glClearColor(color.getRed() * inv, color.getGreen() * inv, - color.getBlue() * inv, color.getAlpha() * inv); - - mask |= GL_COLOR_BUFFER_BIT; - } - - if (zBuffer) - { - glDepthMask(GL_TRUE); - LastMaterial.ZWriteEnable=true; - mask |= GL_DEPTH_BUFFER_BIT; - } - - if (stencilBuffer) - mask |= GL_STENCIL_BUFFER_BIT; - - glClear(mask); -} - - -//! init call for rendering start -bool COpenGLDriver::beginScene(bool backBuffer, bool zBuffer, SColor color, - void* windowId, core::rect<s32>* sourceRect) -{ - CNullDriver::beginScene(backBuffer, zBuffer, color, windowId, sourceRect); - -#if defined(_IRR_COMPILE_WITH_SDL_DEVICE_) - if (DeviceType == EIDT_SDL) - { - // todo: SDL sets glFrontFace(GL_CCW) after driver creation, - // it would be better if this was fixed elsewhere. - glFrontFace(GL_CW); - } -#endif - - clearBuffers(backBuffer, zBuffer, false, color); - return true; -} - - -//! Returns the transformation set by setTransform -const core::matrix4& COpenGLDriver::getTransform(E_TRANSFORMATION_STATE state) const -{ - return Matrices[state]; -} - - -//! sets transformation -void COpenGLDriver::setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat) -{ - Matrices[state] = mat; - Transformation3DChanged = true; - - switch (state) - { - case ETS_VIEW: - case ETS_WORLD: - { - // OpenGL only has a model matrix, view and world is not existent. so lets fake these two. - glMatrixMode(GL_MODELVIEW); - glLoadMatrixf((Matrices[ETS_VIEW] * Matrices[ETS_WORLD]).pointer()); - // we have to update the clip planes to the latest view matrix - for (u32 i=0; i<MaxUserClipPlanes; ++i) - if (UserClipPlaneEnabled[i]) - uploadClipPlane(i); - } - break; - case ETS_PROJECTION: - { - GLfloat glmat[16]; - createGLMatrix(glmat, mat); - // flip z to compensate OpenGLs right-hand coordinate system - glmat[12] *= -1.0f; - glMatrixMode(GL_PROJECTION); - glLoadMatrixf(glmat); - } - break; - case ETS_COUNT: - return; - default: - { - const u32 i = state - ETS_TEXTURE_0; - if (i >= MATERIAL_MAX_TEXTURES) - break; - - const bool isRTT = Material.getTexture(i) && Material.getTexture(i)->isRenderTarget(); - - if (MultiTextureExtension) - extGlActiveTexture(GL_TEXTURE0_ARB + i); - - glMatrixMode(GL_TEXTURE); - if (!isRTT && mat.isIdentity() ) - glLoadIdentity(); - else - { - GLfloat glmat[16]; - if (isRTT) - createGLTextureMatrix(glmat, mat * TextureFlipMatrix); - else - createGLTextureMatrix(glmat, mat); - - glLoadMatrixf(glmat); - } - break; - } - } -} - - -bool COpenGLDriver::updateVertexHardwareBuffer(SHWBufferLink_opengl *HWBuffer) -{ - if (!HWBuffer) - return false; - - if (!FeatureAvailable[IRR_ARB_vertex_buffer_object]) - return false; - -#if defined(GL_ARB_vertex_buffer_object) - const scene::IMeshBuffer* mb = HWBuffer->MeshBuffer; - const void* vertices=mb->getVertices(); - const u32 vertexCount=mb->getVertexCount(); - const E_VERTEX_TYPE vType=mb->getVertexType(); - const u32 vertexSize = getVertexPitchFromType(vType); - - //buffer vertex data, and convert colours... - core::array<c8> buffer(vertexSize * vertexCount); - memcpy(buffer.pointer(), vertices, vertexSize * vertexCount); - - // in order to convert the colors into opengl format (RGBA) - switch (vType) - { - case EVT_STANDARD: - { - S3DVertex* pb = reinterpret_cast<S3DVertex*>(buffer.pointer()); - const S3DVertex* po = static_cast<const S3DVertex*>(vertices); - for (u32 i=0; i<vertexCount; i++) - { - po[i].Color.toOpenGLColor((u8*)&(pb[i].Color)); - } - } - break; - case EVT_2TCOORDS: - { - S3DVertex2TCoords* pb = reinterpret_cast<S3DVertex2TCoords*>(buffer.pointer()); - const S3DVertex2TCoords* po = static_cast<const S3DVertex2TCoords*>(vertices); - for (u32 i=0; i<vertexCount; i++) - { - po[i].Color.toOpenGLColor((u8*)&(pb[i].Color)); - } - } - break; - case EVT_TANGENTS: - { - S3DVertexTangents* pb = reinterpret_cast<S3DVertexTangents*>(buffer.pointer()); - const S3DVertexTangents* po = static_cast<const S3DVertexTangents*>(vertices); - for (u32 i=0; i<vertexCount; i++) - { - po[i].Color.toOpenGLColor((u8*)&(pb[i].Color)); - } - } - break; - default: - { - return false; - } - } - - //get or create buffer - bool newBuffer=false; - if (!HWBuffer->vbo_verticesID) - { - extGlGenBuffers(1, &HWBuffer->vbo_verticesID); - if (!HWBuffer->vbo_verticesID) - return false; - newBuffer=true; - } - else if (HWBuffer->vbo_verticesSize < vertexCount*vertexSize) - { - newBuffer=true; - } - - extGlBindBuffer(GL_ARRAY_BUFFER, HWBuffer->vbo_verticesID); - - //copy data to graphics card - glGetError(); // clear error storage - if (!newBuffer) - extGlBufferSubData(GL_ARRAY_BUFFER, 0, vertexCount * vertexSize, buffer.const_pointer()); - else - { - HWBuffer->vbo_verticesSize = vertexCount*vertexSize; - - if (HWBuffer->Mapped_Vertex==scene::EHM_STATIC) - extGlBufferData(GL_ARRAY_BUFFER, vertexCount * vertexSize, buffer.const_pointer(), GL_STATIC_DRAW); - else if (HWBuffer->Mapped_Vertex==scene::EHM_DYNAMIC) - extGlBufferData(GL_ARRAY_BUFFER, vertexCount * vertexSize, buffer.const_pointer(), GL_DYNAMIC_DRAW); - else //scene::EHM_STREAM - extGlBufferData(GL_ARRAY_BUFFER, vertexCount * vertexSize, buffer.const_pointer(), GL_STREAM_DRAW); - } - - extGlBindBuffer(GL_ARRAY_BUFFER, 0); - - return (glGetError() == GL_NO_ERROR); -#else - return false; -#endif -} - - -bool COpenGLDriver::updateIndexHardwareBuffer(SHWBufferLink_opengl *HWBuffer) -{ - if (!HWBuffer) - return false; - - if (!FeatureAvailable[IRR_ARB_vertex_buffer_object]) - return false; - -#if defined(GL_ARB_vertex_buffer_object) - const scene::IMeshBuffer* mb = HWBuffer->MeshBuffer; - - const void* indices=mb->getIndices(); - u32 indexCount= mb->getIndexCount(); - - GLenum indexSize; - switch (mb->getIndexType()) - { - case EIT_16BIT: - { - indexSize=sizeof(u16); - break; - } - case EIT_32BIT: - { - indexSize=sizeof(u32); - break; - } - default: - { - return false; - } - } - - - //get or create buffer - bool newBuffer=false; - if (!HWBuffer->vbo_indicesID) - { - extGlGenBuffers(1, &HWBuffer->vbo_indicesID); - if (!HWBuffer->vbo_indicesID) - return false; - newBuffer=true; - } - else if (HWBuffer->vbo_indicesSize < indexCount*indexSize) - { - newBuffer=true; - } - - extGlBindBuffer(GL_ELEMENT_ARRAY_BUFFER, HWBuffer->vbo_indicesID); - - //copy data to graphics card - glGetError(); // clear error storage - if (!newBuffer) - extGlBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, indexCount * indexSize, indices); - else - { - HWBuffer->vbo_indicesSize = indexCount*indexSize; - - if (HWBuffer->Mapped_Index==scene::EHM_STATIC) - extGlBufferData(GL_ELEMENT_ARRAY_BUFFER, indexCount * indexSize, indices, GL_STATIC_DRAW); - else if (HWBuffer->Mapped_Index==scene::EHM_DYNAMIC) - extGlBufferData(GL_ELEMENT_ARRAY_BUFFER, indexCount * indexSize, indices, GL_DYNAMIC_DRAW); - else //scene::EHM_STREAM - extGlBufferData(GL_ELEMENT_ARRAY_BUFFER, indexCount * indexSize, indices, GL_STREAM_DRAW); - } - - extGlBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - - return (glGetError() == GL_NO_ERROR); -#else - return false; -#endif -} - - -//! updates hardware buffer if needed -bool COpenGLDriver::updateHardwareBuffer(SHWBufferLink *HWBuffer) -{ - if (!HWBuffer) - return false; - - if (HWBuffer->Mapped_Vertex!=scene::EHM_NEVER) - { - if (HWBuffer->ChangedID_Vertex != HWBuffer->MeshBuffer->getChangedID_Vertex() - || !((SHWBufferLink_opengl*)HWBuffer)->vbo_verticesID) - { - - HWBuffer->ChangedID_Vertex = HWBuffer->MeshBuffer->getChangedID_Vertex(); - - if (!updateVertexHardwareBuffer((SHWBufferLink_opengl*)HWBuffer)) - return false; - } - } - - if (HWBuffer->Mapped_Index!=scene::EHM_NEVER) - { - if (HWBuffer->ChangedID_Index != HWBuffer->MeshBuffer->getChangedID_Index() - || !((SHWBufferLink_opengl*)HWBuffer)->vbo_indicesID) - { - - HWBuffer->ChangedID_Index = HWBuffer->MeshBuffer->getChangedID_Index(); - - if (!updateIndexHardwareBuffer((SHWBufferLink_opengl*)HWBuffer)) - return false; - } - } - - return true; -} - - -//! Create hardware buffer from meshbuffer -COpenGLDriver::SHWBufferLink *COpenGLDriver::createHardwareBuffer(const scene::IMeshBuffer* mb) -{ -#if defined(GL_ARB_vertex_buffer_object) - if (!mb || (mb->getHardwareMappingHint_Index()==scene::EHM_NEVER && mb->getHardwareMappingHint_Vertex()==scene::EHM_NEVER)) - return 0; - - SHWBufferLink_opengl *HWBuffer=new SHWBufferLink_opengl(mb); - - //add to map - HWBufferMap.insert(HWBuffer->MeshBuffer, HWBuffer); - - HWBuffer->ChangedID_Vertex=HWBuffer->MeshBuffer->getChangedID_Vertex(); - HWBuffer->ChangedID_Index=HWBuffer->MeshBuffer->getChangedID_Index(); - HWBuffer->Mapped_Vertex=mb->getHardwareMappingHint_Vertex(); - HWBuffer->Mapped_Index=mb->getHardwareMappingHint_Index(); - HWBuffer->LastUsed=0; - HWBuffer->vbo_verticesID=0; - HWBuffer->vbo_indicesID=0; - HWBuffer->vbo_verticesSize=0; - HWBuffer->vbo_indicesSize=0; - - if (!updateHardwareBuffer(HWBuffer)) - { - deleteHardwareBuffer(HWBuffer); - return 0; - } - - return HWBuffer; -#else - return 0; -#endif -} - - -void COpenGLDriver::deleteHardwareBuffer(SHWBufferLink *_HWBuffer) -{ - if (!_HWBuffer) - return; - -#if defined(GL_ARB_vertex_buffer_object) - SHWBufferLink_opengl *HWBuffer=(SHWBufferLink_opengl*)_HWBuffer; - if (HWBuffer->vbo_verticesID) - { - extGlDeleteBuffers(1, &HWBuffer->vbo_verticesID); - HWBuffer->vbo_verticesID=0; - } - if (HWBuffer->vbo_indicesID) - { - extGlDeleteBuffers(1, &HWBuffer->vbo_indicesID); - HWBuffer->vbo_indicesID=0; - } -#endif - - CNullDriver::deleteHardwareBuffer(_HWBuffer); -} - - -//! Draw hardware buffer -void COpenGLDriver::drawHardwareBuffer(SHWBufferLink *_HWBuffer) -{ - if (!_HWBuffer) - return; - - updateHardwareBuffer(_HWBuffer); //check if update is needed - _HWBuffer->LastUsed=0; //reset count - -#if defined(GL_ARB_vertex_buffer_object) - SHWBufferLink_opengl *HWBuffer=(SHWBufferLink_opengl*)_HWBuffer; - - const scene::IMeshBuffer* mb = HWBuffer->MeshBuffer; - const void *vertices=mb->getVertices(); - const void *indexList=mb->getIndices(); - - if (HWBuffer->Mapped_Vertex!=scene::EHM_NEVER) - { - extGlBindBuffer(GL_ARRAY_BUFFER, HWBuffer->vbo_verticesID); - vertices=0; - } - - if (HWBuffer->Mapped_Index!=scene::EHM_NEVER) - { - extGlBindBuffer(GL_ELEMENT_ARRAY_BUFFER, HWBuffer->vbo_indicesID); - indexList=0; - } - - drawVertexPrimitiveList(vertices, mb->getVertexCount(), indexList, mb->getIndexCount()/3, mb->getVertexType(), scene::EPT_TRIANGLES, mb->getIndexType()); - - if (HWBuffer->Mapped_Vertex!=scene::EHM_NEVER) - extGlBindBuffer(GL_ARRAY_BUFFER, 0); - if (HWBuffer->Mapped_Index!=scene::EHM_NEVER) - extGlBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); -#endif -} - - -// small helper function to create vertex buffer object adress offsets -static inline u8* buffer_offset(const long offset) -{ - return ((u8*)0 + offset); -} - - -//! draws a vertex primitive list -void COpenGLDriver::drawVertexPrimitiveList(const void* vertices, u32 vertexCount, - const void* indexList, u32 primitiveCount, - E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType) -{ - if (!primitiveCount || !vertexCount) - return; - - if (!checkPrimitiveCount(primitiveCount)) - return; - - CNullDriver::drawVertexPrimitiveList(vertices, vertexCount, indexList, primitiveCount, vType, pType, iType); - - if (vertices) - createColorBuffer(vertices, vertexCount, vType); - - // draw everything - setRenderStates3DMode(); - - if (MultiTextureExtension) - extGlClientActiveTexture(GL_TEXTURE0_ARB); - - glEnableClientState(GL_COLOR_ARRAY); - glEnableClientState(GL_VERTEX_ARRAY); - if ((pType!=scene::EPT_POINTS) && (pType!=scene::EPT_POINT_SPRITES)) - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - if ((pType!=scene::EPT_POINTS) && (pType!=scene::EPT_POINT_SPRITES)) - glEnableClientState(GL_NORMAL_ARRAY); - - if (vertices) - glColorPointer(4, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]); - - switch (vType) - { - case EVT_STANDARD: - if (vertices) - { - glNormalPointer(GL_FLOAT, sizeof(S3DVertex), &(static_cast<const S3DVertex*>(vertices))[0].Normal); - glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex), &(static_cast<const S3DVertex*>(vertices))[0].TCoords); - glVertexPointer(3, GL_FLOAT, sizeof(S3DVertex), &(static_cast<const S3DVertex*>(vertices))[0].Pos); - } - else - { - glNormalPointer(GL_FLOAT, sizeof(S3DVertex), buffer_offset(12)); - glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(S3DVertex), buffer_offset(24)); - glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex), buffer_offset(28)); - glVertexPointer(3, GL_FLOAT, sizeof(S3DVertex), 0); - } - - if (MultiTextureExtension && CurrentTexture[1]) - { - extGlClientActiveTexture(GL_TEXTURE1_ARB); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - if (vertices) - glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex), &(static_cast<const S3DVertex*>(vertices))[0].TCoords); - else - glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex), buffer_offset(28)); - } - break; - case EVT_2TCOORDS: - if (vertices) - { - glNormalPointer(GL_FLOAT, sizeof(S3DVertex2TCoords), &(static_cast<const S3DVertex2TCoords*>(vertices))[0].Normal); - glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), &(static_cast<const S3DVertex2TCoords*>(vertices))[0].TCoords); - glVertexPointer(3, GL_FLOAT, sizeof(S3DVertex2TCoords), &(static_cast<const S3DVertex2TCoords*>(vertices))[0].Pos); - } - else - { - glNormalPointer(GL_FLOAT, sizeof(S3DVertex2TCoords), buffer_offset(12)); - glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(S3DVertex2TCoords), buffer_offset(24)); - glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), buffer_offset(28)); - glVertexPointer(3, GL_FLOAT, sizeof(S3DVertex2TCoords), buffer_offset(0)); - } - - - if (MultiTextureExtension) - { - extGlClientActiveTexture(GL_TEXTURE1_ARB); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - if (vertices) - glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), &(static_cast<const S3DVertex2TCoords*>(vertices))[0].TCoords2); - else - glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), buffer_offset(36)); - } - break; - case EVT_TANGENTS: - if (vertices) - { - glNormalPointer(GL_FLOAT, sizeof(S3DVertexTangents), &(static_cast<const S3DVertexTangents*>(vertices))[0].Normal); - glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertexTangents), &(static_cast<const S3DVertexTangents*>(vertices))[0].TCoords); - glVertexPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), &(static_cast<const S3DVertexTangents*>(vertices))[0].Pos); - } - else - { - glNormalPointer(GL_FLOAT, sizeof(S3DVertexTangents), buffer_offset(12)); - glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(S3DVertexTangents), buffer_offset(24)); - glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertexTangents), buffer_offset(28)); - glVertexPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), buffer_offset(0)); - } - - if (MultiTextureExtension) - { - extGlClientActiveTexture(GL_TEXTURE1_ARB); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - if (vertices) - glTexCoordPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), &(static_cast<const S3DVertexTangents*>(vertices))[0].Tangent); - else - glTexCoordPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), buffer_offset(36)); - - extGlClientActiveTexture(GL_TEXTURE2_ARB); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - if (vertices) - glTexCoordPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), &(static_cast<const S3DVertexTangents*>(vertices))[0].Binormal); - else - glTexCoordPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), buffer_offset(48)); - } - break; - } - - renderArray(indexList, primitiveCount, pType, iType); - - if (MultiTextureExtension) - { - if (vType==EVT_TANGENTS) - { - extGlClientActiveTexture(GL_TEXTURE2_ARB); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - } - if ((vType!=EVT_STANDARD) || CurrentTexture[1]) - { - extGlClientActiveTexture(GL_TEXTURE1_ARB); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - } - extGlClientActiveTexture(GL_TEXTURE0_ARB); - } - glDisableClientState(GL_COLOR_ARRAY); - glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_NORMAL_ARRAY); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); -} - - -void COpenGLDriver::createColorBuffer(const void* vertices, u32 vertexCount, E_VERTEX_TYPE vType) -{ - // convert colors to gl color format. - vertexCount *= 4; //reused as color component count - ColorBuffer.set_used(vertexCount); - u32 i; - - switch (vType) - { - case EVT_STANDARD: - { - const S3DVertex* p = static_cast<const S3DVertex*>(vertices); - for (i=0; i<vertexCount; i+=4) - { - p->Color.toOpenGLColor(&ColorBuffer[i]); - ++p; - } - } - break; - case EVT_2TCOORDS: - { - const S3DVertex2TCoords* p = static_cast<const S3DVertex2TCoords*>(vertices); - for (i=0; i<vertexCount; i+=4) - { - p->Color.toOpenGLColor(&ColorBuffer[i]); - ++p; - } - } - break; - case EVT_TANGENTS: - { - const S3DVertexTangents* p = static_cast<const S3DVertexTangents*>(vertices); - for (i=0; i<vertexCount; i+=4) - { - p->Color.toOpenGLColor(&ColorBuffer[i]); - ++p; - } - } - break; - } -} - - -void COpenGLDriver::renderArray(const void* indexList, u32 primitiveCount, - scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType) -{ - GLenum indexSize=0; - - switch (iType) - { - case EIT_16BIT: - { - indexSize=GL_UNSIGNED_SHORT; - break; - } - case EIT_32BIT: - { - indexSize=GL_UNSIGNED_INT; - break; - } - } - - switch (pType) - { - case scene::EPT_POINTS: - case scene::EPT_POINT_SPRITES: - { -#ifdef GL_ARB_point_sprite - if (pType==scene::EPT_POINT_SPRITES && FeatureAvailable[IRR_ARB_point_sprite]) - glEnable(GL_POINT_SPRITE_ARB); -#endif - - // prepare size and attenuation (where supported) - GLfloat particleSize=Material.Thickness; -// if (AntiAlias) -// particleSize=core::clamp(particleSize, DimSmoothedPoint[0], DimSmoothedPoint[1]); -// else - particleSize=core::clamp(particleSize, DimAliasedPoint[0], DimAliasedPoint[1]); -#if defined(GL_VERSION_1_4) || defined(GL_ARB_point_parameters) || defined(GL_EXT_point_parameters) || defined(GL_SGIS_point_parameters) - const float att[] = {1.0f, 1.0f, 0.0f}; -#if defined(GL_VERSION_1_4) - extGlPointParameterfv(GL_POINT_DISTANCE_ATTENUATION, att); -// extGlPointParameterf(GL_POINT_SIZE_MIN,1.f); - extGlPointParameterf(GL_POINT_SIZE_MAX, particleSize); - extGlPointParameterf(GL_POINT_FADE_THRESHOLD_SIZE, 1.0f); -#elif defined(GL_ARB_point_parameters) - extGlPointParameterfv(GL_POINT_DISTANCE_ATTENUATION_ARB, att); -// extGlPointParameterf(GL_POINT_SIZE_MIN_ARB,1.f); - extGlPointParameterf(GL_POINT_SIZE_MAX_ARB, particleSize); - extGlPointParameterf(GL_POINT_FADE_THRESHOLD_SIZE_ARB, 1.0f); -#elif defined(GL_EXT_point_parameters) - extGlPointParameterfv(GL_DISTANCE_ATTENUATION_EXT, att); -// extGlPointParameterf(GL_POINT_SIZE_MIN_EXT,1.f); - extGlPointParameterf(GL_POINT_SIZE_MAX_EXT, particleSize); - extGlPointParameterf(GL_POINT_FADE_THRESHOLD_SIZE_EXT, 1.0f); -#elif defined(GL_SGIS_point_parameters) - extGlPointParameterfv(GL_DISTANCE_ATTENUATION_SGIS, att); -// extGlPointParameterf(GL_POINT_SIZE_MIN_SGIS,1.f); - extGlPointParameterf(GL_POINT_SIZE_MAX_SGIS, particleSize); - extGlPointParameterf(GL_POINT_FADE_THRESHOLD_SIZE_SGIS, 1.0f); -#endif -#endif - glPointSize(particleSize); - -#ifdef GL_ARB_point_sprite - if (pType==scene::EPT_POINT_SPRITES && FeatureAvailable[IRR_ARB_point_sprite]) - glTexEnvf(GL_POINT_SPRITE_ARB,GL_COORD_REPLACE, GL_TRUE); -#endif - glDrawArrays(GL_POINTS, 0, primitiveCount); -#ifdef GL_ARB_point_sprite - if (pType==scene::EPT_POINT_SPRITES && FeatureAvailable[IRR_ARB_point_sprite]) - { - glDisable(GL_POINT_SPRITE_ARB); - glTexEnvf(GL_POINT_SPRITE_ARB,GL_COORD_REPLACE, GL_FALSE); - } -#endif - } - break; - case scene::EPT_LINE_STRIP: - glDrawElements(GL_LINE_STRIP, primitiveCount+1, indexSize, indexList); - break; - case scene::EPT_LINE_LOOP: - glDrawElements(GL_LINE_LOOP, primitiveCount, indexSize, indexList); - break; - case scene::EPT_LINES: - glDrawElements(GL_LINES, primitiveCount*2, indexSize, indexList); - break; - case scene::EPT_TRIANGLE_STRIP: - glDrawElements(GL_TRIANGLE_STRIP, primitiveCount+2, indexSize, indexList); - break; - case scene::EPT_TRIANGLE_FAN: - glDrawElements(GL_TRIANGLE_FAN, primitiveCount+2, indexSize, indexList); - break; - case scene::EPT_TRIANGLES: - glDrawElements(GL_TRIANGLES, primitiveCount*3, indexSize, indexList); - break; - case scene::EPT_QUAD_STRIP: - glDrawElements(GL_QUAD_STRIP, primitiveCount*2+2, indexSize, indexList); - break; - case scene::EPT_QUADS: - glDrawElements(GL_QUADS, primitiveCount*4, indexSize, indexList); - break; - case scene::EPT_POLYGON: - glDrawElements(GL_POLYGON, primitiveCount, indexSize, indexList); - break; - } -} - - -//! draws a vertex primitive list in 2d -void COpenGLDriver::draw2DVertexPrimitiveList(const void* vertices, u32 vertexCount, - const void* indexList, u32 primitiveCount, - E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType) -{ - if (!primitiveCount || !vertexCount) - return; - - if (!checkPrimitiveCount(primitiveCount)) - return; - - CNullDriver::draw2DVertexPrimitiveList(vertices, vertexCount, indexList, primitiveCount, vType, pType, iType); - - if (vertices) - createColorBuffer(vertices, vertexCount, vType); - - // draw everything - this->setActiveTexture(0, Material.getTexture(0)); - setRenderStates2DMode(false, (Material.getTexture(0) != 0), false); - - if (MultiTextureExtension) - extGlClientActiveTexture(GL_TEXTURE0_ARB); - - glEnableClientState(GL_COLOR_ARRAY); - glEnableClientState(GL_VERTEX_ARRAY); - if ((pType!=scene::EPT_POINTS) && (pType!=scene::EPT_POINT_SPRITES)) - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - - if (vertices) - glColorPointer(4, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]); - - switch (vType) - { - case EVT_STANDARD: - if (vertices) - { - glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex), &(static_cast<const S3DVertex*>(vertices))[0].TCoords); - glVertexPointer(2, GL_FLOAT, sizeof(S3DVertex), &(static_cast<const S3DVertex*>(vertices))[0].Pos); - } - else - { - glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(S3DVertex), buffer_offset(24)); - glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex), buffer_offset(28)); - glVertexPointer(2, GL_FLOAT, sizeof(S3DVertex), 0); - } - - if (MultiTextureExtension && CurrentTexture[1]) - { - extGlClientActiveTexture(GL_TEXTURE1_ARB); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - if (vertices) - glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex), &(static_cast<const S3DVertex*>(vertices))[0].TCoords); - else - glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex), buffer_offset(28)); - } - break; - case EVT_2TCOORDS: - if (vertices) - { - glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), &(static_cast<const S3DVertex2TCoords*>(vertices))[0].TCoords); - glVertexPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), &(static_cast<const S3DVertex2TCoords*>(vertices))[0].Pos); - } - else - { - glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(S3DVertex2TCoords), buffer_offset(24)); - glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), buffer_offset(28)); - glVertexPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), buffer_offset(0)); - } - - if (MultiTextureExtension) - { - extGlClientActiveTexture(GL_TEXTURE1_ARB); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - if (vertices) - glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), &(static_cast<const S3DVertex2TCoords*>(vertices))[0].TCoords2); - else - glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), buffer_offset(36)); - } - break; - case EVT_TANGENTS: - if (vertices) - { - glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertexTangents), &(static_cast<const S3DVertexTangents*>(vertices))[0].TCoords); - glVertexPointer(2, GL_FLOAT, sizeof(S3DVertexTangents), &(static_cast<const S3DVertexTangents*>(vertices))[0].Pos); - } - else - { - glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(S3DVertexTangents), buffer_offset(24)); - glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertexTangents), buffer_offset(28)); - glVertexPointer(2, GL_FLOAT, sizeof(S3DVertexTangents), buffer_offset(0)); - } - - break; - } - - renderArray(indexList, primitiveCount, pType, iType); - - if (MultiTextureExtension) - { - if ((vType!=EVT_STANDARD) || CurrentTexture[1]) - { - extGlClientActiveTexture(GL_TEXTURE1_ARB); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - } - extGlClientActiveTexture(GL_TEXTURE0_ARB); - } - glDisableClientState(GL_COLOR_ARRAY); - glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); -} - - -//! draws a 2d image, using a color and the alpha channel of the texture if -//! desired. The image is drawn at pos, clipped against clipRect (if != 0). -//! Only the subtexture defined by sourceRect is used. -void COpenGLDriver::draw2DImage(const video::ITexture* texture, - const core::position2d<s32>& pos, - const core::rect<s32>& sourceRect, - const core::rect<s32>* clipRect, SColor color, - bool useAlphaChannelOfTexture) -{ - if (!texture) - return; - - if (!sourceRect.isValid()) - return; - - core::position2d<s32> targetPos(pos); - core::position2d<s32> sourcePos(sourceRect.UpperLeftCorner); - // This needs to be signed as it may go negative. - core::dimension2d<s32> sourceSize(sourceRect.getSize()); - if (clipRect) - { - if (targetPos.X < clipRect->UpperLeftCorner.X) - { - sourceSize.Width += targetPos.X - clipRect->UpperLeftCorner.X; - if (sourceSize.Width <= 0) - return; - - sourcePos.X -= targetPos.X - clipRect->UpperLeftCorner.X; - targetPos.X = clipRect->UpperLeftCorner.X; - } - - if (targetPos.X + sourceSize.Width > clipRect->LowerRightCorner.X) - { - sourceSize.Width -= (targetPos.X + sourceSize.Width) - clipRect->LowerRightCorner.X; - if (sourceSize.Width <= 0) - return; - } - - if (targetPos.Y < clipRect->UpperLeftCorner.Y) - { - sourceSize.Height += targetPos.Y - clipRect->UpperLeftCorner.Y; - if (sourceSize.Height <= 0) - return; - - sourcePos.Y -= targetPos.Y - clipRect->UpperLeftCorner.Y; - targetPos.Y = clipRect->UpperLeftCorner.Y; - } - - if (targetPos.Y + sourceSize.Height > clipRect->LowerRightCorner.Y) - { - sourceSize.Height -= (targetPos.Y + sourceSize.Height) - clipRect->LowerRightCorner.Y; - if (sourceSize.Height <= 0) - return; - } - } - - // clip these coordinates - - if (targetPos.X<0) - { - sourceSize.Width += targetPos.X; - if (sourceSize.Width <= 0) - return; - - sourcePos.X -= targetPos.X; - targetPos.X = 0; - } - - const core::dimension2d<u32>& renderTargetSize = getCurrentRenderTargetSize(); - - if (targetPos.X + sourceSize.Width > (s32)renderTargetSize.Width) - { - sourceSize.Width -= (targetPos.X + sourceSize.Width) - renderTargetSize.Width; - if (sourceSize.Width <= 0) - return; - } - - if (targetPos.Y<0) - { - sourceSize.Height += targetPos.Y; - if (sourceSize.Height <= 0) - return; - - sourcePos.Y -= targetPos.Y; - targetPos.Y = 0; - } - - if (targetPos.Y + sourceSize.Height > (s32)renderTargetSize.Height) - { - sourceSize.Height -= (targetPos.Y + sourceSize.Height) - renderTargetSize.Height; - if (sourceSize.Height <= 0) - return; - } - - // ok, we've clipped everything. - // now draw it. - - // texcoords need to be flipped horizontally for RTTs - const bool isRTT = texture->isRenderTarget(); - const core::dimension2d<u32>& ss = texture->getOriginalSize(); - const f32 invW = 1.f / static_cast<f32>(ss.Width); - const f32 invH = 1.f / static_cast<f32>(ss.Height); - const core::rect<f32> tcoords( - sourcePos.X * invW, - (isRTT?(sourcePos.Y + sourceSize.Height):sourcePos.Y) * invH, - (sourcePos.X + sourceSize.Width) * invW, - (isRTT?sourcePos.Y:(sourcePos.Y + sourceSize.Height)) * invH); - - const core::rect<s32> poss(targetPos, sourceSize); - - disableTextures(1); - if (!setActiveTexture(0, texture)) - return; - setRenderStates2DMode(color.getAlpha()<255, true, useAlphaChannelOfTexture); - - glColor4ub(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); - glBegin(GL_QUADS); - - glTexCoord2f(tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y); - glVertex2f(GLfloat(poss.UpperLeftCorner.X), GLfloat(poss.UpperLeftCorner.Y)); - - glTexCoord2f(tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y); - glVertex2f(GLfloat(poss.LowerRightCorner.X), GLfloat(poss.UpperLeftCorner.Y)); - - glTexCoord2f(tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y); - glVertex2f(GLfloat(poss.LowerRightCorner.X), GLfloat(poss.LowerRightCorner.Y)); - - glTexCoord2f(tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y); - glVertex2f(GLfloat(poss.UpperLeftCorner.X), GLfloat(poss.LowerRightCorner.Y)); - - glEnd(); -} - - -//! The same, but with a four element array of colors, one for each vertex -void COpenGLDriver::draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect, - const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect, - const video::SColor* const colors, bool useAlphaChannelOfTexture) -{ - if (!texture) - return; - - // texcoords need to be flipped horizontally for RTTs - const bool isRTT = texture->isRenderTarget(); - const core::dimension2d<u32>& ss = texture->getOriginalSize(); - const f32 invW = 1.f / static_cast<f32>(ss.Width); - const f32 invH = 1.f / static_cast<f32>(ss.Height); - const core::rect<f32> tcoords( - sourceRect.UpperLeftCorner.X * invW, - (isRTT?sourceRect.LowerRightCorner.Y:sourceRect.UpperLeftCorner.Y) * invH, - sourceRect.LowerRightCorner.X * invW, - (isRTT?sourceRect.UpperLeftCorner.Y:sourceRect.LowerRightCorner.Y) *invH); - - const video::SColor temp[4] = - { - 0xFFFFFFFF, - 0xFFFFFFFF, - 0xFFFFFFFF, - 0xFFFFFFFF - }; - - const video::SColor* const useColor = colors ? colors : temp; - - disableTextures(1); - setActiveTexture(0, texture); - setRenderStates2DMode(useColor[0].getAlpha()<255 || useColor[1].getAlpha()<255 || - useColor[2].getAlpha()<255 || useColor[3].getAlpha()<255, - true, useAlphaChannelOfTexture); - - if (clipRect) - { - if (!clipRect->isValid()) - return; - - glEnable(GL_SCISSOR_TEST); - const core::dimension2d<u32>& renderTargetSize = getCurrentRenderTargetSize(); - glScissor(clipRect->UpperLeftCorner.X, renderTargetSize.Height-clipRect->LowerRightCorner.Y, - clipRect->getWidth(), clipRect->getHeight()); - } - - glBegin(GL_QUADS); - - glColor4ub(useColor[0].getRed(), useColor[0].getGreen(), useColor[0].getBlue(), useColor[0].getAlpha()); - glTexCoord2f(tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y); - glVertex2f(GLfloat(destRect.UpperLeftCorner.X), GLfloat(destRect.UpperLeftCorner.Y)); - - glColor4ub(useColor[3].getRed(), useColor[3].getGreen(), useColor[3].getBlue(), useColor[3].getAlpha()); - glTexCoord2f(tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y); - glVertex2f(GLfloat(destRect.LowerRightCorner.X), GLfloat(destRect.UpperLeftCorner.Y)); - - glColor4ub(useColor[2].getRed(), useColor[2].getGreen(), useColor[2].getBlue(), useColor[2].getAlpha()); - glTexCoord2f(tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y); - glVertex2f(GLfloat(destRect.LowerRightCorner.X), GLfloat(destRect.LowerRightCorner.Y)); - - glColor4ub(useColor[1].getRed(), useColor[1].getGreen(), useColor[1].getBlue(), useColor[1].getAlpha()); - glTexCoord2f(tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y); - glVertex2f(GLfloat(destRect.UpperLeftCorner.X), GLfloat(destRect.LowerRightCorner.Y)); - - glEnd(); - - if (clipRect) - glDisable(GL_SCISSOR_TEST); -} - - -//! draws a set of 2d images, using a color and the alpha channel of the -//! texture if desired. The images are drawn beginning at pos and concatenated -//! in one line. All drawings are clipped against clipRect (if != 0). -//! The subtextures are defined by the array of sourceRects and are chosen -//! by the indices given. -void COpenGLDriver::draw2DImage(const video::ITexture* texture, - const core::position2d<s32>& pos, - const core::array<core::rect<s32> >& sourceRects, - const core::array<s32>& indices, - const core::rect<s32>* clipRect, SColor color, - bool useAlphaChannelOfTexture) -{ - if (!texture) - return; - - disableTextures(1); - if (!setActiveTexture(0, texture)) - return; - setRenderStates2DMode(color.getAlpha()<255, true, useAlphaChannelOfTexture); - - glColor4ub(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); - if (clipRect) - { - if (!clipRect->isValid()) - return; - - glEnable(GL_SCISSOR_TEST); - const core::dimension2d<u32>& renderTargetSize = getCurrentRenderTargetSize(); - glScissor(clipRect->UpperLeftCorner.X, renderTargetSize.Height-clipRect->LowerRightCorner.Y, - clipRect->getWidth(),clipRect->getHeight()); - } - - const core::dimension2d<u32>& ss = texture->getOriginalSize(); - core::position2d<s32> targetPos(pos); - // texcoords need to be flipped horizontally for RTTs - const bool isRTT = texture->isRenderTarget(); - const f32 invW = 1.f / static_cast<f32>(ss.Width); - const f32 invH = 1.f / static_cast<f32>(ss.Height); - - for (u32 i=0; i<indices.size(); ++i) - { - const s32 currentIndex = indices[i]; - if (!sourceRects[currentIndex].isValid()) - break; - - const core::rect<f32> tcoords( - sourceRects[currentIndex].UpperLeftCorner.X * invW, - (isRTT?sourceRects[currentIndex].LowerRightCorner.Y:sourceRects[currentIndex].UpperLeftCorner.Y) * invH, - sourceRects[currentIndex].LowerRightCorner.X * invW, - (isRTT?sourceRects[currentIndex].UpperLeftCorner.Y:sourceRects[currentIndex].LowerRightCorner.Y) * invH); - - const core::rect<s32> poss(targetPos, sourceRects[currentIndex].getSize()); - - glBegin(GL_QUADS); - - glTexCoord2f(tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y); - glVertex2f(GLfloat(poss.UpperLeftCorner.X), GLfloat(poss.UpperLeftCorner.Y)); - - glTexCoord2f(tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y); - glVertex2f(GLfloat(poss.LowerRightCorner.X), GLfloat(poss.UpperLeftCorner.Y)); - - glTexCoord2f(tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y); - glVertex2f(GLfloat(poss.LowerRightCorner.X), GLfloat(poss.LowerRightCorner.Y)); - - glTexCoord2f(tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y); - glVertex2f(GLfloat(poss.UpperLeftCorner.X), GLfloat(poss.LowerRightCorner.Y)); - - glEnd(); - targetPos.X += sourceRects[currentIndex].getWidth(); - } - if (clipRect) - glDisable(GL_SCISSOR_TEST); -} - - -//! draw a 2d rectangle -void COpenGLDriver::draw2DRectangle(SColor color, const core::rect<s32>& position, - const core::rect<s32>* clip) -{ - disableTextures(); - setRenderStates2DMode(color.getAlpha() < 255, false, false); - - core::rect<s32> pos = position; - - if (clip) - pos.clipAgainst(*clip); - - if (!pos.isValid()) - return; - - glColor4ub(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); - glRectf(GLfloat(pos.UpperLeftCorner.X), GLfloat(pos.UpperLeftCorner.Y), - GLfloat(pos.LowerRightCorner.X), GLfloat(pos.LowerRightCorner.Y)); -} - - -//! draw an 2d rectangle -void COpenGLDriver::draw2DRectangle(const core::rect<s32>& position, - SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, - const core::rect<s32>* clip) -{ - core::rect<s32> pos = position; - - if (clip) - pos.clipAgainst(*clip); - - if (!pos.isValid()) - return; - - disableTextures(); - - setRenderStates2DMode(colorLeftUp.getAlpha() < 255 || - colorRightUp.getAlpha() < 255 || - colorLeftDown.getAlpha() < 255 || - colorRightDown.getAlpha() < 255, false, false); - - glBegin(GL_QUADS); - glColor4ub(colorLeftUp.getRed(), colorLeftUp.getGreen(), - colorLeftUp.getBlue(), colorLeftUp.getAlpha()); - glVertex2f(GLfloat(pos.UpperLeftCorner.X), GLfloat(pos.UpperLeftCorner.Y)); - - glColor4ub(colorRightUp.getRed(), colorRightUp.getGreen(), - colorRightUp.getBlue(), colorRightUp.getAlpha()); - glVertex2f(GLfloat(pos.LowerRightCorner.X), GLfloat(pos.UpperLeftCorner.Y)); - - glColor4ub(colorRightDown.getRed(), colorRightDown.getGreen(), - colorRightDown.getBlue(), colorRightDown.getAlpha()); - glVertex2f(GLfloat(pos.LowerRightCorner.X), GLfloat(pos.LowerRightCorner.Y)); - - glColor4ub(colorLeftDown.getRed(), colorLeftDown.getGreen(), - colorLeftDown.getBlue(), colorLeftDown.getAlpha()); - glVertex2f(GLfloat(pos.UpperLeftCorner.X), GLfloat(pos.LowerRightCorner.Y)); - - glEnd(); -} - - -//! Draws a 2d line. -void COpenGLDriver::draw2DLine(const core::position2d<s32>& start, - const core::position2d<s32>& end, - SColor color) -{ - disableTextures(); - setRenderStates2DMode(color.getAlpha() < 255, false, false); - - glBegin(GL_LINES); - glColor4ub(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); - glVertex2f(GLfloat(start.X), GLfloat(start.Y)); - glVertex2f(GLfloat(end.X), GLfloat(end.Y)); - glEnd(); -} - -//! Draws a pixel -void COpenGLDriver::drawPixel(u32 x, u32 y, const SColor &color) -{ - const core::dimension2d<u32>& renderTargetSize = getCurrentRenderTargetSize(); - if (x > (u32)renderTargetSize.Width || y > (u32)renderTargetSize.Height) - return; - - disableTextures(); - setRenderStates2DMode(color.getAlpha() < 255, false, false); - - glBegin(GL_POINTS); - glColor4ub(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); - glVertex2i(x, y); - glEnd(); -} - -bool COpenGLDriver::setActiveTexture(u32 stage, const video::ITexture* texture) -{ - if (stage >= MaxTextureUnits) - return false; - - if (CurrentTexture[stage]==texture) - return true; - - if (MultiTextureExtension) - extGlActiveTexture(GL_TEXTURE0_ARB + stage); - - CurrentTexture[stage]=texture; - - if (!texture) - { - glDisable(GL_TEXTURE_2D); - return true; - } - else - { - if (texture->getDriverType() != EDT_OPENGL) - { - glDisable(GL_TEXTURE_2D); - os::Printer::log("Fatal Error: Tried to set a texture not owned by this driver.", ELL_ERROR); - return false; - } - - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, - static_cast<const COpenGLTexture*>(texture)->getOpenGLTextureName()); - } - return true; -} - - -//! disables all textures beginning with the optional fromStage parameter. Otherwise all texture stages are disabled. -//! Returns whether disabling was successful or not. -bool COpenGLDriver::disableTextures(u32 fromStage) -{ - bool result=true; - for (u32 i=fromStage; i<MaxTextureUnits; ++i) - result &= setActiveTexture(i, 0); - return result; -} - - -//! creates a matrix in supplied GLfloat array to pass to OpenGL -inline void COpenGLDriver::createGLMatrix(GLfloat gl_matrix[16], const core::matrix4& m) -{ - memcpy(gl_matrix, m.pointer(), 16 * sizeof(f32)); -} - - -//! creates a opengltexturematrix from a D3D style texture matrix -inline void COpenGLDriver::createGLTextureMatrix(GLfloat *o, const core::matrix4& m) -{ - o[0] = m[0]; - o[1] = m[1]; - o[2] = 0.f; - o[3] = 0.f; - - o[4] = m[4]; - o[5] = m[5]; - o[6] = 0.f; - o[7] = 0.f; - - o[8] = 0.f; - o[9] = 0.f; - o[10] = 1.f; - o[11] = 0.f; - - o[12] = m[8]; - o[13] = m[9]; - o[14] = 0.f; - o[15] = 1.f; -} - - -//! returns a device dependent texture from a software surface (IImage) -video::ITexture* COpenGLDriver::createDeviceDependentTexture(IImage* surface, const io::path& name) -{ - return new COpenGLTexture(surface, name, this); -} - - -//! Sets a material. All 3d drawing functions draw geometry now using this material. -void COpenGLDriver::setMaterial(const SMaterial& material) -{ - Material = material; - OverrideMaterial.apply(Material); - - for (s32 i = MaxTextureUnits-1; i>= 0; --i) - { - setTransform ((E_TRANSFORMATION_STATE) (ETS_TEXTURE_0 + i), - Material.getTextureMatrix(i)); - } -} - - -//! prints error if an error happened. -bool COpenGLDriver::testGLError() -{ -#ifdef _DEBUG - GLenum g = glGetError(); - switch (g) - { - case GL_NO_ERROR: - return false; - case GL_INVALID_ENUM: - os::Printer::log("GL_INVALID_ENUM", ELL_ERROR); break; - case GL_INVALID_VALUE: - os::Printer::log("GL_INVALID_VALUE", ELL_ERROR); break; - case GL_INVALID_OPERATION: - os::Printer::log("GL_INVALID_OPERATION", ELL_ERROR); break; - case GL_STACK_OVERFLOW: - os::Printer::log("GL_STACK_OVERFLOW", ELL_ERROR); break; - case GL_STACK_UNDERFLOW: - os::Printer::log("GL_STACK_UNDERFLOW", ELL_ERROR); break; - case GL_OUT_OF_MEMORY: - os::Printer::log("GL_OUT_OF_MEMORY", ELL_ERROR); break; - case GL_TABLE_TOO_LARGE: - os::Printer::log("GL_TABLE_TOO_LARGE", ELL_ERROR); break; -#if defined(GL_EXT_framebuffer_object) - case GL_INVALID_FRAMEBUFFER_OPERATION_EXT: - os::Printer::log("GL_INVALID_FRAMEBUFFER_OPERATION", ELL_ERROR); break; -#endif - }; - return true; -#else - return false; -#endif -} - - -//! sets the needed renderstates -void COpenGLDriver::setRenderStates3DMode() -{ - if (CurrentRenderMode != ERM_3D) - { - // Reset Texture Stages - glDisable(GL_BLEND); - glDisable(GL_ALPHA_TEST); - glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR); - - // switch back the matrices - glMatrixMode(GL_MODELVIEW); - glLoadMatrixf((Matrices[ETS_VIEW] * Matrices[ETS_WORLD]).pointer()); - - GLfloat glmat[16]; - createGLMatrix(glmat, Matrices[ETS_PROJECTION]); - glmat[12] *= -1.0f; - glMatrixMode(GL_PROJECTION); - glLoadMatrixf(glmat); - - ResetRenderStates = true; - } - - if (ResetRenderStates || LastMaterial != Material) - { - // unset old material - - if (LastMaterial.MaterialType != Material.MaterialType && - static_cast<u32>(LastMaterial.MaterialType) < MaterialRenderers.size()) - MaterialRenderers[LastMaterial.MaterialType].Renderer->OnUnsetMaterial(); - - // set new material. - if (static_cast<u32>(Material.MaterialType) < MaterialRenderers.size()) - MaterialRenderers[Material.MaterialType].Renderer->OnSetMaterial( - Material, LastMaterial, ResetRenderStates, this); - - LastMaterial = Material; - ResetRenderStates = false; - } - - if (static_cast<u32>(Material.MaterialType) < MaterialRenderers.size()) - MaterialRenderers[Material.MaterialType].Renderer->OnRender(this, video::EVT_STANDARD); - - CurrentRenderMode = ERM_3D; -} - - -void COpenGLDriver::setWrapMode(const SMaterial& material) -{ - // texture address mode - // Has to be checked always because it depends on the textures - for (u32 u=0; u<MaxTextureUnits; ++u) - { - if (MultiTextureExtension) - extGlActiveTexture(GL_TEXTURE0_ARB + u); - else if (u>0) - break; // stop loop - - GLint mode=GL_REPEAT; - switch (material.TextureLayer[u].TextureWrap) - { - case ETC_REPEAT: - mode=GL_REPEAT; - break; - case ETC_CLAMP: - mode=GL_CLAMP; - break; - case ETC_CLAMP_TO_EDGE: -#ifdef GL_VERSION_1_2 - if (Version>101) - mode=GL_CLAMP_TO_EDGE; - else -#endif -#ifdef GL_SGIS_texture_edge_clamp - if (FeatureAvailable[IRR_SGIS_texture_edge_clamp]) - mode=GL_CLAMP_TO_EDGE_SGIS; - else -#endif - // fallback - mode=GL_CLAMP; - break; - case ETC_CLAMP_TO_BORDER: -#ifdef GL_VERSION_1_3 - if (Version>102) - mode=GL_CLAMP_TO_BORDER; - else -#endif -#ifdef GL_ARB_texture_border_clamp - if (FeatureAvailable[IRR_ARB_texture_border_clamp]) - mode=GL_CLAMP_TO_BORDER_ARB; - else -#endif -#ifdef GL_SGIS_texture_border_clamp - if (FeatureAvailable[IRR_SGIS_texture_border_clamp]) - mode=GL_CLAMP_TO_BORDER_SGIS; - else -#endif - // fallback - mode=GL_CLAMP; - break; - case ETC_MIRROR: -#ifdef GL_VERSION_1_4 - if (Version>103) - mode=GL_MIRRORED_REPEAT; - else -#endif -#ifdef GL_ARB_texture_border_clamp - if (FeatureAvailable[IRR_ARB_texture_mirrored_repeat]) - mode=GL_MIRRORED_REPEAT_ARB; - else -#endif -#ifdef GL_IBM_texture_mirrored_repeat - if (FeatureAvailable[IRR_IBM_texture_mirrored_repeat]) - mode=GL_MIRRORED_REPEAT_IBM; - else -#endif - mode=GL_REPEAT; - break; - } - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, mode); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, mode); - } -} - - -//! Can be called by an IMaterialRenderer to make its work easier. -void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMaterial& lastmaterial, - bool resetAllRenderStates) -{ - if (resetAllRenderStates || - lastmaterial.ColorMaterial != material.ColorMaterial) - { - if (material.ColorMaterial != ECM_NONE) - glEnable(GL_COLOR_MATERIAL); - switch (material.ColorMaterial) - { - case ECM_NONE: - glDisable(GL_COLOR_MATERIAL); - break; - case ECM_DIFFUSE: - glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); - break; - case ECM_AMBIENT: - glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT); - break; - case ECM_EMISSIVE: - glColorMaterial(GL_FRONT_AND_BACK, GL_EMISSION); - break; - case ECM_SPECULAR: - glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR); - break; - case ECM_DIFFUSE_AND_AMBIENT: - glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); - break; - } - } - - if (resetAllRenderStates || - lastmaterial.AmbientColor != material.AmbientColor || - lastmaterial.DiffuseColor != material.DiffuseColor || - lastmaterial.EmissiveColor != material.EmissiveColor || - lastmaterial.ColorMaterial != material.ColorMaterial) - { - GLfloat color[4]; - - const f32 inv = 1.0f / 255.0f; - - if ((material.ColorMaterial != video::ECM_AMBIENT) && - (material.ColorMaterial != video::ECM_DIFFUSE_AND_AMBIENT)) - { - color[0] = material.AmbientColor.getRed() * inv; - color[1] = material.AmbientColor.getGreen() * inv; - color[2] = material.AmbientColor.getBlue() * inv; - color[3] = material.AmbientColor.getAlpha() * inv; - glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, color); - } - - if ((material.ColorMaterial != video::ECM_DIFFUSE) && - (material.ColorMaterial != video::ECM_DIFFUSE_AND_AMBIENT)) - { - color[0] = material.DiffuseColor.getRed() * inv; - color[1] = material.DiffuseColor.getGreen() * inv; - color[2] = material.DiffuseColor.getBlue() * inv; - color[3] = material.DiffuseColor.getAlpha() * inv; - glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, color); - } - - if (material.ColorMaterial != video::ECM_EMISSIVE) - { - color[0] = material.EmissiveColor.getRed() * inv; - color[1] = material.EmissiveColor.getGreen() * inv; - color[2] = material.EmissiveColor.getBlue() * inv; - color[3] = material.EmissiveColor.getAlpha() * inv; - glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, color); - } - } - - if (resetAllRenderStates || - lastmaterial.SpecularColor != material.SpecularColor || - lastmaterial.Shininess != material.Shininess || - lastmaterial.ColorMaterial != material.ColorMaterial) - { - GLfloat color[4]={0.f,0.f,0.f,1.f}; - const f32 inv = 1.0f / 255.0f; - - glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, material.Shininess); - // disable Specular colors if no shininess is set - if ((material.Shininess != 0.0f) && - (material.ColorMaterial != video::ECM_SPECULAR)) - { -#ifdef GL_EXT_separate_specular_color - if (FeatureAvailable[IRR_EXT_separate_specular_color]) - glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); -#endif - color[0] = material.SpecularColor.getRed() * inv; - color[1] = material.SpecularColor.getGreen() * inv; - color[2] = material.SpecularColor.getBlue() * inv; - color[3] = material.SpecularColor.getAlpha() * inv; - } -#ifdef GL_EXT_separate_specular_color - else if (FeatureAvailable[IRR_EXT_separate_specular_color]) - glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR); -#endif - glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, color); - } - - // Texture filter - // Has to be checked always because it depends on the textures - // Filtering has to be set for each texture layer - for (u32 i=0; i<MaxTextureUnits; ++i) - { - if (MultiTextureExtension) - extGlActiveTexture(GL_TEXTURE0_ARB + i); - else if (i>0) - break; - -#ifdef GL_EXT_texture_lod_bias - if (FeatureAvailable[IRR_EXT_texture_lod_bias]) - { - if (material.TextureLayer[i].LODBias) - { - const float tmp = core::clamp(material.TextureLayer[i].LODBias * 0.125f, -MaxTextureLODBias, MaxTextureLODBias); - glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, tmp); - } - else - glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0.f); - } -#endif - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, - (material.TextureLayer[i].BilinearFilter || material.TextureLayer[i].TrilinearFilter) ? GL_LINEAR : GL_NEAREST); - - if (material.getTexture(i) && material.getTexture(i)->hasMipMaps()) - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, - material.TextureLayer[i].TrilinearFilter ? GL_LINEAR_MIPMAP_LINEAR : - material.TextureLayer[i].BilinearFilter ? GL_LINEAR_MIPMAP_NEAREST : - GL_NEAREST_MIPMAP_NEAREST); - else - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, - (material.TextureLayer[i].BilinearFilter || material.TextureLayer[i].TrilinearFilter) ? GL_LINEAR : GL_NEAREST); - -#ifdef GL_EXT_texture_filter_anisotropic - if (FeatureAvailable[IRR_EXT_texture_filter_anisotropic]) - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, - material.TextureLayer[i].AnisotropicFilter>1 ? core::min_(MaxAnisotropy, material.TextureLayer[i].AnisotropicFilter) : 1); -#endif - } - - // fillmode - if (resetAllRenderStates || (lastmaterial.Wireframe != material.Wireframe) || (lastmaterial.PointCloud != material.PointCloud)) - glPolygonMode(GL_FRONT_AND_BACK, material.Wireframe ? GL_LINE : material.PointCloud? GL_POINT : GL_FILL); - - // shademode - if (resetAllRenderStates || (lastmaterial.GouraudShading != material.GouraudShading)) - { - if (material.GouraudShading) - glShadeModel(GL_SMOOTH); - else - glShadeModel(GL_FLAT); - } - - // lighting - if (resetAllRenderStates || (lastmaterial.Lighting != material.Lighting)) - { - if (material.Lighting) - glEnable(GL_LIGHTING); - else - glDisable(GL_LIGHTING); - } - - // zbuffer - if (resetAllRenderStates || lastmaterial.ZBuffer != material.ZBuffer) - { - switch (material.ZBuffer) - { - case ECFN_NEVER: - glDisable(GL_DEPTH_TEST); - break; - case ECFN_LESSEQUAL: - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_LEQUAL); - break; - case ECFN_EQUAL: - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_EQUAL); - break; - case ECFN_LESS: - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_LESS); - break; - case ECFN_NOTEQUAL: - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_NOTEQUAL); - break; - case ECFN_GREATEREQUAL: - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_GEQUAL); - break; - case ECFN_GREATER: - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_GREATER); - break; - case ECFN_ALWAYS: - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_ALWAYS); - break; - } - } - - // zwrite -// if (resetAllRenderStates || lastmaterial.ZWriteEnable != material.ZWriteEnable) - { - if (material.ZWriteEnable && (AllowZWriteOnTransparent || !material.isTransparent())) - { - glDepthMask(GL_TRUE); - } - else - glDepthMask(GL_FALSE); - } - - // back face culling - if (resetAllRenderStates || (lastmaterial.FrontfaceCulling != material.FrontfaceCulling) || (lastmaterial.BackfaceCulling != material.BackfaceCulling)) - { - if ((material.FrontfaceCulling) && (material.BackfaceCulling)) - { - glCullFace(GL_FRONT_AND_BACK); - glEnable(GL_CULL_FACE); - } - else - if (material.BackfaceCulling) - { - glCullFace(GL_BACK); - glEnable(GL_CULL_FACE); - } - else - if (material.FrontfaceCulling) - { - glCullFace(GL_FRONT); - glEnable(GL_CULL_FACE); - } - else - glDisable(GL_CULL_FACE); - } - - // fog - if (resetAllRenderStates || lastmaterial.FogEnable != material.FogEnable) - { - if (material.FogEnable) - glEnable(GL_FOG); - else - glDisable(GL_FOG); - } - - // normalization - if (resetAllRenderStates || lastmaterial.NormalizeNormals != material.NormalizeNormals) - { - if (material.NormalizeNormals) - glEnable(GL_NORMALIZE); - else - glDisable(GL_NORMALIZE); - } - - // Color Mask - if (resetAllRenderStates || lastmaterial.ColorMask != material.ColorMask) - { - glColorMask( - (material.ColorMask & ECP_RED)?GL_TRUE:GL_FALSE, - (material.ColorMask & ECP_GREEN)?GL_TRUE:GL_FALSE, - (material.ColorMask & ECP_BLUE)?GL_TRUE:GL_FALSE, - (material.ColorMask & ECP_ALPHA)?GL_TRUE:GL_FALSE); - } - - // thickness - if (resetAllRenderStates || lastmaterial.Thickness != material.Thickness) - { - if (AntiAlias) - { -// glPointSize(core::clamp(static_cast<GLfloat>(material.Thickness), DimSmoothedPoint[0], DimSmoothedPoint[1])); - // we don't use point smoothing - glPointSize(core::clamp(static_cast<GLfloat>(material.Thickness), DimAliasedPoint[0], DimAliasedPoint[1])); - glLineWidth(core::clamp(static_cast<GLfloat>(material.Thickness), DimSmoothedLine[0], DimSmoothedLine[1])); - } - else - { - glPointSize(core::clamp(static_cast<GLfloat>(material.Thickness), DimAliasedPoint[0], DimAliasedPoint[1])); - glLineWidth(core::clamp(static_cast<GLfloat>(material.Thickness), DimAliasedLine[0], DimAliasedLine[1])); - } - } - - // Anti aliasing - if (resetAllRenderStates || lastmaterial.AntiAliasing != material.AntiAliasing) - { - if (FeatureAvailable[IRR_ARB_multisample]) - { - if (material.AntiAliasing & EAAM_ALPHA_TO_COVERAGE) - glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE_ARB); - else if (lastmaterial.AntiAliasing & EAAM_ALPHA_TO_COVERAGE) - glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE_ARB); - - if ((AntiAlias >= 2) && (material.AntiAliasing & (EAAM_SIMPLE|EAAM_QUALITY))) - { - glEnable(GL_MULTISAMPLE_ARB); -#ifdef GL_NV_multisample_filter_hint - if (FeatureAvailable[IRR_NV_multisample_filter_hint]) - { - if ((material.AntiAliasing & EAAM_QUALITY) == EAAM_QUALITY) - glHint(GL_MULTISAMPLE_FILTER_HINT_NV, GL_NICEST); - else - glHint(GL_MULTISAMPLE_FILTER_HINT_NV, GL_NICEST); - } -#endif - } - else - glDisable(GL_MULTISAMPLE_ARB); - } - if ((material.AntiAliasing & EAAM_LINE_SMOOTH) != (lastmaterial.AntiAliasing & EAAM_LINE_SMOOTH)) - { - if (material.AntiAliasing & EAAM_LINE_SMOOTH) - glEnable(GL_LINE_SMOOTH); - else if (lastmaterial.AntiAliasing & EAAM_LINE_SMOOTH) - glDisable(GL_LINE_SMOOTH); - } - if ((material.AntiAliasing & EAAM_POINT_SMOOTH) != (lastmaterial.AntiAliasing & EAAM_POINT_SMOOTH)) - { - if (material.AntiAliasing & EAAM_POINT_SMOOTH) - // often in software, and thus very slow - glEnable(GL_POINT_SMOOTH); - else if (lastmaterial.AntiAliasing & EAAM_POINT_SMOOTH) - glDisable(GL_POINT_SMOOTH); - } - } - - setWrapMode(material); - - // be sure to leave in texture stage 0 - if (MultiTextureExtension) - extGlActiveTexture(GL_TEXTURE0_ARB); -} - - -//! sets the needed renderstates -void COpenGLDriver::setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel) -{ - if (CurrentRenderMode != ERM_2D || Transformation3DChanged) - { - // unset last 3d material - if (CurrentRenderMode == ERM_3D) - { - if (static_cast<u32>(LastMaterial.MaterialType) < MaterialRenderers.size()) - MaterialRenderers[LastMaterial.MaterialType].Renderer->OnUnsetMaterial(); - SMaterial mat; - mat.ZBuffer=ECFN_NEVER; - mat.Lighting=false; - mat.AntiAliasing=video::EAAM_OFF; - mat.TextureLayer[0].BilinearFilter=false; - setBasicRenderStates(mat, mat, true); - LastMaterial = mat; - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - } - - glMatrixMode(GL_PROJECTION); - - const core::dimension2d<u32>& renderTargetSize = getCurrentRenderTargetSize(); - core::matrix4 m; - m.buildProjectionMatrixOrthoLH(f32(renderTargetSize.Width), f32(-(s32)(renderTargetSize.Height)), -1.0, 1.0); - m.setTranslation(core::vector3df(-1,1,0)); - glLoadMatrixf(m.pointer()); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef(0.375, 0.375, 0.0); - - glMatrixMode(GL_TEXTURE); - glLoadIdentity(); - - Transformation3DChanged = false; - } - - if (alphaChannel || alpha) - { - glEnable(GL_BLEND); - glEnable(GL_ALPHA_TEST); - glAlphaFunc(GL_GREATER, 0.f); - } - else - { - glDisable(GL_BLEND); - glDisable(GL_ALPHA_TEST); - } - - if (texture) - { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - - if (alphaChannel) - { - // if alpha and alpha texture just modulate, otherwise use only the alpha channel - if (alpha) - { - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - } - else - { -#ifdef GL_ARB_texture_env_combine - if (FeatureAvailable[IRR_ARB_texture_env_combine]) - { - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE); - // rgb always modulates - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PRIMARY_COLOR_EXT); - } - else -#endif - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - } - } - else - { - if (alpha) - { -#ifdef GL_ARB_texture_env_combine - if (FeatureAvailable[IRR_ARB_texture_env_combine]) - { - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PRIMARY_COLOR_EXT); - // rgb always modulates - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PRIMARY_COLOR_EXT); - } - else -#endif - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - } - else - { - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - } - } - } - - CurrentRenderMode = ERM_2D; -} - - -//! \return Returns the name of the video driver. -const wchar_t* COpenGLDriver::getName() const -{ - return Name.c_str(); -} - - -//! deletes all dynamic lights there are -void COpenGLDriver::deleteAllDynamicLights() -{ - for (s32 i=0; i<MaxLights; ++i) - glDisable(GL_LIGHT0 + i); - - RequestedLights.clear(); - - CNullDriver::deleteAllDynamicLights(); -} - - -//! adds a dynamic light -s32 COpenGLDriver::addDynamicLight(const SLight& light) -{ - CNullDriver::addDynamicLight(light); - - RequestedLights.push_back(RequestedLight(light)); - - u32 newLightIndex = RequestedLights.size() - 1; - - // Try and assign a hardware light just now, but don't worry if I can't - assignHardwareLight(newLightIndex); - - return (s32)newLightIndex; -} - - -void COpenGLDriver::assignHardwareLight(u32 lightIndex) -{ - setTransform(ETS_WORLD, core::matrix4()); - - s32 lidx; - for (lidx=GL_LIGHT0; lidx < GL_LIGHT0 + MaxLights; ++lidx) - { - if(!glIsEnabled(lidx)) - { - RequestedLights[lightIndex].HardwareLightIndex = lidx; - break; - } - } - - if(lidx == GL_LIGHT0 + MaxLights) // There's no room for it just now - return; - - GLfloat data[4]; - const SLight & light = RequestedLights[lightIndex].LightData; - - switch (light.Type) - { - case video::ELT_SPOT: - data[0] = light.Direction.X; - data[1] = light.Direction.Y; - data[2] = light.Direction.Z; - data[3] = 0.0f; - glLightfv(lidx, GL_SPOT_DIRECTION, data); - - // set position - data[0] = light.Position.X; - data[1] = light.Position.Y; - data[2] = light.Position.Z; - data[3] = 1.0f; // 1.0f for positional light - glLightfv(lidx, GL_POSITION, data); - - glLightf(lidx, GL_SPOT_EXPONENT, light.Falloff); - glLightf(lidx, GL_SPOT_CUTOFF, light.OuterCone); - break; - case video::ELT_POINT: - // set position - data[0] = light.Position.X; - data[1] = light.Position.Y; - data[2] = light.Position.Z; - data[3] = 1.0f; // 1.0f for positional light - glLightfv(lidx, GL_POSITION, data); - - glLightf(lidx, GL_SPOT_EXPONENT, 0.0f); - glLightf(lidx, GL_SPOT_CUTOFF, 180.0f); - break; - case video::ELT_DIRECTIONAL: - // set direction - data[0] = -light.Direction.X; - data[1] = -light.Direction.Y; - data[2] = -light.Direction.Z; - data[3] = 0.0f; // 0.0f for directional light - glLightfv(lidx, GL_POSITION, data); - - glLightf(lidx, GL_SPOT_EXPONENT, 0.0f); - glLightf(lidx, GL_SPOT_CUTOFF, 180.0f); - break; - } - - // set diffuse color - data[0] = light.DiffuseColor.r; - data[1] = light.DiffuseColor.g; - data[2] = light.DiffuseColor.b; - data[3] = light.DiffuseColor.a; - glLightfv(lidx, GL_DIFFUSE, data); - - // set specular color - data[0] = light.SpecularColor.r; - data[1] = light.SpecularColor.g; - data[2] = light.SpecularColor.b; - data[3] = light.SpecularColor.a; - glLightfv(lidx, GL_SPECULAR, data); - - // set ambient color - data[0] = light.AmbientColor.r; - data[1] = light.AmbientColor.g; - data[2] = light.AmbientColor.b; - data[3] = light.AmbientColor.a; - glLightfv(lidx, GL_AMBIENT, data); - - // 1.0f / (constant + linear * d + quadratic*(d*d); - - // set attenuation - glLightf(lidx, GL_CONSTANT_ATTENUATION, light.Attenuation.X); - glLightf(lidx, GL_LINEAR_ATTENUATION, light.Attenuation.Y); - glLightf(lidx, GL_QUADRATIC_ATTENUATION, light.Attenuation.Z); - - glEnable(lidx); -} - - -//! Turns a dynamic light on or off -//! \param lightIndex: the index returned by addDynamicLight -//! \param turnOn: true to turn the light on, false to turn it off -void COpenGLDriver::turnLightOn(s32 lightIndex, bool turnOn) -{ - if(lightIndex < 0 || lightIndex >= (s32)RequestedLights.size()) - return; - - RequestedLight & requestedLight = RequestedLights[lightIndex]; - - requestedLight.DesireToBeOn = turnOn; - - if(turnOn) - { - if(-1 == requestedLight.HardwareLightIndex) - assignHardwareLight(lightIndex); - } - else - { - if(-1 != requestedLight.HardwareLightIndex) - { - // It's currently assigned, so free up the hardware light - glDisable(requestedLight.HardwareLightIndex); - requestedLight.HardwareLightIndex = -1; - - // Now let the first light that's waiting on a free hardware light grab it - for(u32 requested = 0; requested < RequestedLights.size(); ++requested) - if(RequestedLights[requested].DesireToBeOn - && - -1 == RequestedLights[requested].HardwareLightIndex) - { - assignHardwareLight(requested); - break; - } - } - } -} - - -//! returns the maximal amount of dynamic lights the device can handle -u32 COpenGLDriver::getMaximalDynamicLightAmount() const -{ - return MaxLights; -} - - -//! Sets the dynamic ambient light color. The default color is -//! (0,0,0,0) which means it is dark. -//! \param color: New color of the ambient light. -void COpenGLDriver::setAmbientLight(const SColorf& color) -{ - GLfloat data[4] = {color.r, color.g, color.b, color.a}; - glLightModelfv(GL_LIGHT_MODEL_AMBIENT, data); -} - - -// this code was sent in by Oliver Klems, thank you! (I modified the glViewport -// method just a bit. -void COpenGLDriver::setViewPort(const core::rect<s32>& area) -{ - core::rect<s32> vp = area; - core::rect<s32> rendert(0,0, getCurrentRenderTargetSize().Width, getCurrentRenderTargetSize().Height); - vp.clipAgainst(rendert); - - if (vp.getHeight()>0 && vp.getWidth()>0) - glViewport(vp.UpperLeftCorner.X, - getCurrentRenderTargetSize().Height - vp.UpperLeftCorner.Y - vp.getHeight(), - vp.getWidth(), vp.getHeight()); - - ViewPort = vp; -} - - -//! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do -//! this: First, draw all geometry. Then use this method, to draw the shadow -//! volume. Next use IVideoDriver::drawStencilShadow() to visualize the shadow. -void COpenGLDriver::drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail) -{ - if (!StencilBuffer || !count) - return; - - // unset last 3d material - if (CurrentRenderMode == ERM_3D && - static_cast<u32>(Material.MaterialType) < MaterialRenderers.size()) - { - MaterialRenderers[Material.MaterialType].Renderer->OnUnsetMaterial(); - ResetRenderStates = true; - } - - // store current OpenGL state - glPushAttrib(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_ENABLE_BIT | - GL_POLYGON_BIT | GL_STENCIL_BUFFER_BIT); - - glDisable(GL_LIGHTING); - glDisable(GL_FOG); - glDepthFunc(GL_LEQUAL); - glDepthMask(GL_FALSE); // no depth buffer writing - glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); // no color buffer drawing - glEnable(GL_STENCIL_TEST); - glEnable(GL_POLYGON_OFFSET_FILL); - glPolygonOffset(0.0f, 1.0f); - - glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(3,GL_FLOAT,sizeof(core::vector3df),&triangles[0]); - glStencilMask(~0); - glStencilFunc(GL_ALWAYS, 0, ~0); - - GLenum incr = GL_INCR; - GLenum decr = GL_DECR; -#ifdef GL_EXT_stencil_wrap - if (FeatureAvailable[IRR_EXT_stencil_wrap]) - { - incr = GL_INCR_WRAP_EXT; - decr = GL_DECR_WRAP_EXT; - } -#endif - - // The first parts are not correctly working, yet. -#if 0 -#ifdef GL_EXT_stencil_two_side - if (FeatureAvailable[IRR_EXT_stencil_two_side]) - { - glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT); -#ifdef GL_NV_depth_clamp - if (FeatureAvailable[IRR_NV_depth_clamp]) - glEnable(GL_DEPTH_CLAMP_NV); -#endif - glDisable(GL_CULL_FACE); - if (!zfail) - { - // ZPASS Method - - extGlActiveStencilFace(GL_BACK); - glStencilOp(GL_KEEP, GL_KEEP, decr); - glStencilMask(~0); - glStencilFunc(GL_ALWAYS, 0, ~0); - - extGlActiveStencilFace(GL_FRONT); - glStencilOp(GL_KEEP, GL_KEEP, incr); - glStencilMask(~0); - glStencilFunc(GL_ALWAYS, 0, ~0); - - glDrawArrays(GL_TRIANGLES,0,count); - } - else - { - // ZFAIL Method - - extGlActiveStencilFace(GL_BACK); - glStencilOp(GL_KEEP, incr, GL_KEEP); - glStencilMask(~0); - glStencilFunc(GL_ALWAYS, 0, ~0); - - extGlActiveStencilFace(GL_FRONT); - glStencilOp(GL_KEEP, decr, GL_KEEP); - glStencilMask(~0); - glStencilFunc(GL_ALWAYS, 0, ~0); - - glDrawArrays(GL_TRIANGLES,0,count); - } - } - else -#endif - if (FeatureAvailable[IRR_ATI_separate_stencil]) - { - glDisable(GL_CULL_FACE); - if (!zfail) - { - // ZPASS Method - - extGlStencilOpSeparate(GL_BACK, GL_KEEP, GL_KEEP, decr); - extGlStencilOpSeparate(GL_FRONT, GL_KEEP, GL_KEEP, incr); - extGlStencilFuncSeparate(GL_FRONT_AND_BACK, GL_ALWAYS, 0, ~0); - glStencilMask(~0); - - glDrawArrays(GL_TRIANGLES,0,count); - } - else - { - // ZFAIL Method - - extGlStencilOpSeparate(GL_BACK, GL_KEEP, incr, GL_KEEP); - extGlStencilOpSeparate(GL_FRONT, GL_KEEP, decr, GL_KEEP); - extGlStencilFuncSeparate(GL_FRONT_AND_BACK, GL_ALWAYS, 0, ~0); - - glDrawArrays(GL_TRIANGLES,0,count); - } - } - else -#endif - { - glEnable(GL_CULL_FACE); - if (!zfail) - { - // ZPASS Method - - glCullFace(GL_BACK); - glStencilOp(GL_KEEP, GL_KEEP, incr); - glDrawArrays(GL_TRIANGLES,0,count); - - glCullFace(GL_FRONT); - glStencilOp(GL_KEEP, GL_KEEP, decr); - glDrawArrays(GL_TRIANGLES,0,count); - } - else - { - // ZFAIL Method - - glStencilOp(GL_KEEP, incr, GL_KEEP); - glCullFace(GL_FRONT); - glDrawArrays(GL_TRIANGLES,0,count); - - glStencilOp(GL_KEEP, decr, GL_KEEP); - glCullFace(GL_BACK); - glDrawArrays(GL_TRIANGLES,0,count); - } - } - - glDisableClientState(GL_VERTEX_ARRAY); //not stored on stack - glPopAttrib(); -} - - -void COpenGLDriver::drawStencilShadow(bool clearStencilBuffer, video::SColor leftUpEdge, - video::SColor rightUpEdge, video::SColor leftDownEdge, video::SColor rightDownEdge) -{ - if (!StencilBuffer) - return; - - disableTextures(); - - // store attributes - glPushAttrib(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_ENABLE_BIT | GL_POLYGON_BIT | GL_STENCIL_BUFFER_BIT); - - glDisable(GL_LIGHTING); - glDisable(GL_FOG); - glDepthMask(GL_FALSE); - - glShadeModel(GL_FLAT); - glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - glEnable(GL_STENCIL_TEST); - glStencilFunc(GL_NOTEQUAL, 0, ~0); - glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); - - // draw a shadow rectangle covering the entire screen using stencil buffer - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glLoadIdentity(); - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - - glBegin(GL_QUADS); - - glColor4ub(leftDownEdge.getRed(), leftDownEdge.getGreen(), leftDownEdge.getBlue(), leftDownEdge.getAlpha()); - glVertex3f(-1.f,-1.f,-0.9f); - - glColor4ub(leftUpEdge.getRed(), leftUpEdge.getGreen(), leftUpEdge.getBlue(), leftUpEdge.getAlpha()); - glVertex3f(-1.f, 1.f,-0.9f); - - glColor4ub(rightUpEdge.getRed(), rightUpEdge.getGreen(), rightUpEdge.getBlue(), rightUpEdge.getAlpha()); - glVertex3f(1.f, 1.f,-0.9f); - - glColor4ub(rightDownEdge.getRed(), rightDownEdge.getGreen(), rightDownEdge.getBlue(), rightDownEdge.getAlpha()); - glVertex3f(1.f,-1.f,-0.9f); - - glEnd(); - - clearBuffers(false, false, clearStencilBuffer, 0x0); - - // restore settings - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); - glPopAttrib(); -} - - -//! Sets the fog mode. -void COpenGLDriver::setFog(SColor c, E_FOG_TYPE fogType, f32 start, - f32 end, f32 density, bool pixelFog, bool rangeFog) -{ - CNullDriver::setFog(c, fogType, start, end, density, pixelFog, rangeFog); - - glFogf(GL_FOG_MODE, GLfloat((fogType==EFT_FOG_LINEAR)? GL_LINEAR : (fogType==EFT_FOG_EXP)?GL_EXP:GL_EXP2)); - -#ifdef GL_EXT_fog_coord - if (FeatureAvailable[IRR_EXT_fog_coord]) - glFogi(GL_FOG_COORDINATE_SOURCE, GL_FRAGMENT_DEPTH); -#endif -#ifdef GL_NV_fog_distance - if (FeatureAvailable[IRR_NV_fog_distance]) - { - if (rangeFog) - glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_RADIAL_NV); - else - glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_PLANE_ABSOLUTE_NV); - } -#endif - - if (fogType==EFT_FOG_LINEAR) - { - glFogf(GL_FOG_START, start); - glFogf(GL_FOG_END, end); - } - else - glFogf(GL_FOG_DENSITY, density); - - if (pixelFog) - glHint(GL_FOG_HINT, GL_NICEST); - else - glHint(GL_FOG_HINT, GL_FASTEST); - - SColorf color(c); - GLfloat data[4] = {color.r, color.g, color.b, color.a}; - glFogfv(GL_FOG_COLOR, data); -} - - -//! Draws a 3d line. -void COpenGLDriver::draw3DLine(const core::vector3df& start, - const core::vector3df& end, SColor color) -{ - setRenderStates3DMode(); - - glBegin(GL_LINES); - glColor4ub(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); - glVertex3f(start.X, start.Y, start.Z); - - glVertex3f(end.X, end.Y, end.Z); - glEnd(); -} - - - -//! Only used by the internal engine. Used to notify the driver that -//! the window was resized. -void COpenGLDriver::OnResize(const core::dimension2d<u32>& size) -{ - CNullDriver::OnResize(size); - glViewport(0, 0, size.Width, size.Height); - Transformation3DChanged = true; -} - - -//! Returns type of video driver -E_DRIVER_TYPE COpenGLDriver::getDriverType() const -{ - return EDT_OPENGL; -} - - -//! returns color format -ECOLOR_FORMAT COpenGLDriver::getColorFormat() const -{ - return ColorFormat; -} - - -//! Sets a vertex shader constant. -void COpenGLDriver::setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount) -{ -#ifdef GL_ARB_vertex_program - for (s32 i=0; i<constantAmount; ++i) - extGlProgramLocalParameter4fv(GL_VERTEX_PROGRAM_ARB, startRegister+i, &data[i*4]); -#endif -} - -//! Sets a pixel shader constant. -void COpenGLDriver::setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount) -{ -#ifdef GL_ARB_fragment_program - for (s32 i=0; i<constantAmount; ++i) - extGlProgramLocalParameter4fv(GL_FRAGMENT_PROGRAM_ARB, startRegister+i, &data[i*4]); -#endif -} - -//! Sets a constant for the vertex shader based on a name. -bool COpenGLDriver::setVertexShaderConstant(const c8* name, const f32* floats, int count) -{ - //pass this along, as in GLSL the same routine is used for both vertex and fragment shaders - return setPixelShaderConstant(name, floats, count); -} - -//! Sets a constant for the pixel shader based on a name. -bool COpenGLDriver::setPixelShaderConstant(const c8* name, const f32* floats, int count) -{ - os::Printer::log("Error: Please call services->setPixelShaderConstant(), not VideoDriver->setPixelShaderConstant()."); - return false; -} - - -//! Adds a new material renderer to the VideoDriver, using pixel and/or -//! vertex shaders to render geometry. -s32 COpenGLDriver::addShaderMaterial(const c8* vertexShaderProgram, - const c8* pixelShaderProgram, - IShaderConstantSetCallBack* callback, - E_MATERIAL_TYPE baseMaterial, s32 userData) -{ - s32 nr = -1; - COpenGLShaderMaterialRenderer* r = new COpenGLShaderMaterialRenderer( - this, nr, vertexShaderProgram, pixelShaderProgram, - callback, getMaterialRenderer(baseMaterial), userData); - - r->drop(); - return nr; -} - - -//! Adds a new material renderer to the VideoDriver, using GLSL to render geometry. -s32 COpenGLDriver::addHighLevelShaderMaterial( - const c8* vertexShaderProgram, - const c8* vertexShaderEntryPointName, - E_VERTEX_SHADER_TYPE vsCompileTarget, - const c8* pixelShaderProgram, - const c8* pixelShaderEntryPointName, - E_PIXEL_SHADER_TYPE psCompileTarget, - IShaderConstantSetCallBack* callback, - E_MATERIAL_TYPE baseMaterial, - s32 userData) -{ - s32 nr = -1; - - COpenGLSLMaterialRenderer* r = new COpenGLSLMaterialRenderer( - this, nr, vertexShaderProgram, vertexShaderEntryPointName, - vsCompileTarget, pixelShaderProgram, pixelShaderEntryPointName, psCompileTarget, - callback,getMaterialRenderer(baseMaterial), userData); - - r->drop(); - return nr; -} - -//! Returns a pointer to the IVideoDriver interface. (Implementation for -//! IMaterialRendererServices) -IVideoDriver* COpenGLDriver::getVideoDriver() -{ - return this; -} - - -//! Returns pointer to the IGPUProgrammingServices interface. -IGPUProgrammingServices* COpenGLDriver::getGPUProgrammingServices() -{ - return this; -} - - -ITexture* COpenGLDriver::addRenderTargetTexture(const core::dimension2d<u32>& size, - const io::path& name, - const ECOLOR_FORMAT format) -{ - //disable mip-mapping - bool generateMipLevels = getTextureCreationFlag(ETCF_CREATE_MIP_MAPS); - setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, false); - - video::ITexture* rtt = 0; -#if defined(GL_EXT_framebuffer_object) - // if driver supports FrameBufferObjects, use them - if (queryFeature(EVDF_FRAMEBUFFER_OBJECT)) - { - rtt = new COpenGLFBOTexture(size, name, this, format); - if (rtt) - { - bool success = false; - addTexture(rtt); - ITexture* tex = createDepthTexture(rtt); - if (tex) - { - success = static_cast<video::COpenGLFBODepthTexture*>(tex)->attach(rtt); - tex->drop(); - } - rtt->drop(); - if (!success) - { - removeTexture(rtt); - rtt=0; - } - } - } - else -#endif - { - // the simple texture is only possible for size <= screensize - // we try to find an optimal size with the original constraints - core::dimension2du destSize(core::min_(size.Width,ScreenSize.Width), core::min_(size.Height,ScreenSize.Height)); - destSize = destSize.getOptimalSize((size==size.getOptimalSize()), false, false); - rtt = addTexture(destSize, name, ECF_A8R8G8B8); - if (rtt) - { - static_cast<video::COpenGLTexture*>(rtt)->setIsRenderTarget(true); - } - } - - //restore mip-mapping - setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, generateMipLevels); - - return rtt; -} - - -//! Returns the maximum amount of primitives (mostly vertices) which -//! the device is able to render with one drawIndexedTriangleList -//! call. -u32 COpenGLDriver::getMaximalPrimitiveCount() const -{ - return 0x7fffffff; -} - - -//! set or reset render target -bool COpenGLDriver::setRenderTarget(video::E_RENDER_TARGET target, bool clearTarget, - bool clearZBuffer, SColor color) -{ - if (target != CurrentTarget) - setRenderTarget(0, false, false, 0x0); - - if (ERT_RENDER_TEXTURE == target) - { - os::Printer::log("Fatal Error: For render textures call setRenderTarget with the actual texture as first parameter.", ELL_ERROR); - return false; - } - - if (Stereo && (ERT_STEREO_RIGHT_BUFFER == target)) - { - if (Doublebuffer) - glDrawBuffer(GL_BACK_RIGHT); - else - glDrawBuffer(GL_FRONT_RIGHT); - } - else if (Stereo && ERT_STEREO_BOTH_BUFFERS == target) - { - if (Doublebuffer) - glDrawBuffer(GL_BACK); - else - glDrawBuffer(GL_FRONT); - } - else if ((target >= ERT_AUX_BUFFER0) && (target-ERT_AUX_BUFFER0 < MaxAuxBuffers)) - { - glDrawBuffer(GL_AUX0+target-ERT_AUX_BUFFER0); - } - else - { - if (Doublebuffer) - glDrawBuffer(GL_BACK_LEFT); - else - glDrawBuffer(GL_FRONT_LEFT); - // exit with false, but also with working color buffer - if (target != ERT_FRAME_BUFFER) - return false; - } - CurrentTarget=target; - clearBuffers(clearTarget, clearZBuffer, false, color); - return true; -} - - -//! set or reset render target -bool COpenGLDriver::setRenderTarget(video::ITexture* texture, bool clearBackBuffer, - bool clearZBuffer, SColor color) -{ - // check for right driver type - - if (texture && texture->getDriverType() != EDT_OPENGL) - { - os::Printer::log("Fatal Error: Tried to set a texture not owned by this driver.", ELL_ERROR); - return false; - } - - // check if we should set the previous RT back - - setActiveTexture(0, 0); - ResetRenderStates=true; - if (RenderTargetTexture!=0) - { - RenderTargetTexture->unbindRTT(); - } - - if (texture) - { - // we want to set a new target. so do this. - glViewport(0, 0, texture->getSize().Width, texture->getSize().Height); - RenderTargetTexture = static_cast<COpenGLTexture*>(texture); - RenderTargetTexture->bindRTT(); - CurrentRendertargetSize = texture->getSize(); - CurrentTarget=ERT_RENDER_TEXTURE; - } - else - { - glViewport(0,0,ScreenSize.Width,ScreenSize.Height); - RenderTargetTexture = 0; - CurrentRendertargetSize = core::dimension2d<u32>(0,0); - CurrentTarget=ERT_FRAME_BUFFER; - } - - clearBuffers(clearBackBuffer, clearZBuffer, false, color); - return true; -} - - -// returns the current size of the screen or rendertarget -const core::dimension2d<u32>& COpenGLDriver::getCurrentRenderTargetSize() const -{ - if (CurrentRendertargetSize.Width == 0) - return ScreenSize; - else - return CurrentRendertargetSize; -} - - -//! Clears the ZBuffer. -void COpenGLDriver::clearZBuffer() -{ - clearBuffers(false, true, false, 0x0); -} - - -//! Returns an image created from the last rendered frame. -IImage* COpenGLDriver::createScreenShot() -{ - IImage* newImage = new CImage(ECF_R8G8B8, ScreenSize); - - u8* pixels = static_cast<u8*>(newImage->lock()); - if (!pixels) - { - newImage->drop(); - return 0; - } - - // allows to read pixels in top-to-bottom order -#ifdef GL_MESA_pack_invert - if (FeatureAvailable[IRR_MESA_pack_invert]) - glPixelStorei(GL_PACK_INVERT_MESA, GL_TRUE); -#endif - - // We want to read the front buffer to get the latest render finished. - glReadBuffer(GL_FRONT); - glReadPixels(0, 0, ScreenSize.Width, ScreenSize.Height, GL_RGB, GL_UNSIGNED_BYTE, pixels); - glReadBuffer(GL_BACK); - -#ifdef GL_MESA_pack_invert - if (FeatureAvailable[IRR_MESA_pack_invert]) - glPixelStorei(GL_PACK_INVERT_MESA, GL_FALSE); - else -#endif - { - // opengl images are horizontally flipped, so we have to fix that here. - const s32 pitch=newImage->getPitch(); - u8* p2 = pixels + (ScreenSize.Height - 1) * pitch; - u8* tmpBuffer = new u8[pitch]; - for (u32 i=0; i < ScreenSize.Height; i += 2) - { - memcpy(tmpBuffer, pixels, pitch); - memcpy(pixels, p2, pitch); - memcpy(p2, tmpBuffer, pitch); - pixels += pitch; - p2 -= pitch; - } - delete [] tmpBuffer; - } - - newImage->unlock(); - - if (testGLError()) - { - newImage->drop(); - return 0; - } - - return newImage; -} - - -//! get depth texture for the given render target texture -ITexture* COpenGLDriver::createDepthTexture(ITexture* texture, bool shared) -{ - if ((texture->getDriverType() != EDT_OPENGL) || (!texture->isRenderTarget())) - return 0; - COpenGLTexture* tex = static_cast<COpenGLTexture*>(texture); - - if (!tex->isFrameBufferObject()) - return 0; - - if (shared) - { - for (u32 i=0; i<DepthTextures.size(); ++i) - { - if (DepthTextures[i]->getSize()==texture->getSize()) - { - DepthTextures[i]->grab(); - return DepthTextures[i]; - } - } - DepthTextures.push_back(new COpenGLFBODepthTexture(texture->getSize(), "depth1", this)); - return DepthTextures.getLast(); - } - return (new COpenGLFBODepthTexture(texture->getSize(), "depth1", this)); -} - - -void COpenGLDriver::removeDepthTexture(ITexture* texture) -{ - for (u32 i=0; i<DepthTextures.size(); ++i) - { - if (texture==DepthTextures[i]) - { - DepthTextures.erase(i); - return; - } - } -} - - -//! Set/unset a clipping plane. -bool COpenGLDriver::setClipPlane(u32 index, const core::plane3df& plane, bool enable) -{ - if (index >= MaxUserClipPlanes) - return false; - - UserClipPlane[index]=plane; - enableClipPlane(index, enable); - return true; -} - - -void COpenGLDriver::uploadClipPlane(u32 index) -{ - // opengl needs an array of doubles for the plane equation - double clip_plane[4]; - clip_plane[0] = UserClipPlane[index].Normal.X; - clip_plane[1] = UserClipPlane[index].Normal.Y; - clip_plane[2] = UserClipPlane[index].Normal.Z; - clip_plane[3] = UserClipPlane[index].D; - glClipPlane(GL_CLIP_PLANE0 + index, clip_plane); -} - - -//! Enable/disable a clipping plane. -void COpenGLDriver::enableClipPlane(u32 index, bool enable) -{ - if (index >= MaxUserClipPlanes) - return; - if (enable) - { - if (!UserClipPlaneEnabled[index]) - { - uploadClipPlane(index); - glEnable(GL_CLIP_PLANE0 + index); - } - } - else - glDisable(GL_CLIP_PLANE0 + index); - - UserClipPlaneEnabled[index]=enable; -} - - -} // end namespace -} // end namespace - -#endif // _IRR_COMPILE_WITH_OPENGL_ - -namespace irr -{ -namespace video -{ - - -// ----------------------------------- -// WINDOWS VERSION -// ----------------------------------- -#ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_ -IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params, - io::IFileSystem* io, CIrrDeviceWin32* device) -{ -#ifdef _IRR_COMPILE_WITH_OPENGL_ - COpenGLDriver* ogl = new COpenGLDriver(params, io, device); - if (!ogl->initDriver(params, device)) - { - ogl->drop(); - ogl = 0; - } - return ogl; -#else - return 0; -#endif // _IRR_COMPILE_WITH_OPENGL_ -} -#endif // _IRR_COMPILE_WITH_WINDOWS_DEVICE_ - -// ----------------------------------- -// MACOSX VERSION -// ----------------------------------- -#if defined(_IRR_COMPILE_WITH_OSX_DEVICE_) -IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params, - io::IFileSystem* io, CIrrDeviceMacOSX *device) -{ -#ifdef _IRR_COMPILE_WITH_OPENGL_ - return new COpenGLDriver(params, io, device); -#else - return 0; -#endif // _IRR_COMPILE_WITH_OPENGL_ -} -#endif // _IRR_COMPILE_WITH_OSX_DEVICE_ - -// ----------------------------------- -// X11 VERSION -// ----------------------------------- -#ifdef _IRR_COMPILE_WITH_X11_DEVICE_ -IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params, - io::IFileSystem* io, CIrrDeviceLinux* device) -{ -#ifdef _IRR_COMPILE_WITH_OPENGL_ - COpenGLDriver* ogl = new COpenGLDriver(params, io, device); - if (!ogl->initDriver(params, device)) - { - ogl->drop(); - ogl = 0; - } - return ogl; -#else - return 0; -#endif // _IRR_COMPILE_WITH_OPENGL_ -} -#endif // _IRR_COMPILE_WITH_X11_DEVICE_ - - -// ----------------------------------- -// SDL VERSION -// ----------------------------------- -#ifdef _IRR_COMPILE_WITH_SDL_DEVICE_ -IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params, - io::IFileSystem* io, CIrrDeviceSDL* device) -{ -#ifdef _IRR_COMPILE_WITH_OPENGL_ - return new COpenGLDriver(params, io, device); -#else - return 0; -#endif // _IRR_COMPILE_WITH_OPENGL_ -} -#endif // _IRR_COMPILE_WITH_SDL_DEVICE_ - -} // end namespace -} // end namespace - - diff --git a/irrlicht-1.6/source/Irrlicht/COpenGLDriver.h b/irrlicht-1.6/source/Irrlicht/COpenGLDriver.h deleted file mode 100644 index e2d4022a9..000000000 --- a/irrlicht-1.6/source/Irrlicht/COpenGLDriver.h +++ /dev/null @@ -1,440 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in Irrlicht.h - -#ifndef __C_VIDEO_OPEN_GL_H_INCLUDED__ -#define __C_VIDEO_OPEN_GL_H_INCLUDED__ - -#include "IrrCompileConfig.h" - -#include "SIrrCreationParameters.h" - -namespace irr -{ - class CIrrDeviceWin32; - class CIrrDeviceLinux; - class CIrrDeviceSDL; - class CIrrDeviceMacOSX; -} - -#ifdef _IRR_COMPILE_WITH_OPENGL_ - -#include "CNullDriver.h" -#include "IMaterialRendererServices.h" -// also includes the OpenGL stuff -#include "COpenGLExtensionHandler.h" - -namespace irr -{ - -namespace video -{ - class COpenGLTexture; - - class COpenGLDriver : public CNullDriver, public IMaterialRendererServices, public COpenGLExtensionHandler - { - public: - - #ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_ - COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, CIrrDeviceWin32* device); - //! inits the windows specific parts of the open gl driver - bool initDriver(SIrrlichtCreationParameters params, CIrrDeviceWin32* device); - #endif - - #ifdef _IRR_COMPILE_WITH_X11_DEVICE_ - COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, CIrrDeviceLinux* device); - //! inits the GLX specific parts of the open gl driver - bool initDriver(SIrrlichtCreationParameters params, CIrrDeviceLinux* device); - #endif - - #ifdef _IRR_COMPILE_WITH_SDL_DEVICE_ - COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, CIrrDeviceSDL* device); - #endif - - #ifdef _IRR_COMPILE_WITH_OSX_DEVICE_ - COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, CIrrDeviceMacOSX *device); - #endif - - //! destructor - virtual ~COpenGLDriver(); - - //! clears the zbuffer - virtual bool beginScene(bool backBuffer=true, bool zBuffer=true, - SColor color=SColor(255,0,0,0), - void* windowId=0, - core::rect<s32>* sourceRect=0); - - //! presents the rendered scene on the screen, returns false if failed - virtual bool endScene(); - - //! sets transformation - virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat); - - - struct SHWBufferLink_opengl : public SHWBufferLink - { - SHWBufferLink_opengl(const scene::IMeshBuffer *_MeshBuffer): SHWBufferLink(_MeshBuffer), vbo_verticesID(0),vbo_indicesID(0){} - - GLuint vbo_verticesID; //tmp - GLuint vbo_indicesID; //tmp - - GLuint vbo_verticesSize; //tmp - GLuint vbo_indicesSize; //tmp - }; - - //! updates hardware buffer if needed - virtual bool updateHardwareBuffer(SHWBufferLink *HWBuffer); - - //! Create hardware buffer from mesh - virtual SHWBufferLink *createHardwareBuffer(const scene::IMeshBuffer* mb); - - //! Delete hardware buffer (only some drivers can) - virtual void deleteHardwareBuffer(SHWBufferLink *HWBuffer); - - //! Draw hardware buffer - virtual void drawHardwareBuffer(SHWBufferLink *HWBuffer); - - //! draws a vertex primitive list - virtual void drawVertexPrimitiveList(const void* vertices, u32 vertexCount, - const void* indexList, u32 primitiveCount, - E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType); - - //! draws a vertex primitive list in 2d - virtual void draw2DVertexPrimitiveList(const void* vertices, u32 vertexCount, - const void* indexList, u32 primitiveCount, - E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType); - - //! queries the features of the driver, returns true if feature is available - virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const - { - return FeatureEnabled[feature] && COpenGLExtensionHandler::queryFeature(feature); - } - - //! Sets a material. All 3d drawing functions draw geometry now - //! using this material. - //! \param material: Material to be used from now on. - virtual void setMaterial(const SMaterial& material); - - //! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. - virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos, - const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0, - SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false); - - //! draws a set of 2d images, using a color and the alpha - /** channel of the texture if desired. The images are drawn - beginning at pos and concatenated in one line. All drawings - are clipped against clipRect (if != 0). - The subtextures are defined by the array of sourceRects - and are chosen by the indices given. - \param texture: Texture to be drawn. - \param pos: Upper left 2d destination position where the image will be drawn. - \param sourceRects: Source rectangles of the image. - \param indices: List of indices which choose the actual rectangle used each time. - \param clipRect: Pointer to rectangle on the screen where the image is clipped to. - This pointer can be 0. Then the image is not clipped. - \param color: Color with which the image is colored. - Note that the alpha component is used: If alpha is other than 255, the image will be transparent. - \param useAlphaChannelOfTexture: If true, the alpha channel of the texture is - used to draw the image. */ - virtual void draw2DImage(const video::ITexture* texture, - const core::position2d<s32>& pos, - const core::array<core::rect<s32> >& sourceRects, - const core::array<s32>& indices, - const core::rect<s32>* clipRect=0, - SColor color=SColor(255,255,255,255), - bool useAlphaChannelOfTexture=false); - - //! Draws a part of the texture into the rectangle. - virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect, - const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0, - const video::SColor* const colors=0, bool useAlphaChannelOfTexture=false); - - //! draw an 2d rectangle - virtual void draw2DRectangle(SColor color, const core::rect<s32>& pos, - const core::rect<s32>* clip = 0); - - //!Draws an 2d rectangle with a gradient. - virtual void draw2DRectangle(const core::rect<s32>& pos, - SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, - const core::rect<s32>* clip = 0); - - //! Draws a 2d line. - virtual void draw2DLine(const core::position2d<s32>& start, - const core::position2d<s32>& end, - SColor color=SColor(255,255,255,255)); - - //! Draws a single pixel - virtual void drawPixel(u32 x, u32 y, const SColor & color); - - //! Draws a 3d line. - virtual void draw3DLine(const core::vector3df& start, - const core::vector3df& end, - SColor color = SColor(255,255,255,255)); - - //! \return Returns the name of the video driver. Example: In case of the Direct3D8 - //! driver, it would return "Direct3D8.1". - virtual const wchar_t* getName() const; - - //! deletes all dynamic lights there are - virtual void deleteAllDynamicLights(); - - //! adds a dynamic light, returning an index to the light - //! \param light: the light data to use to create the light - //! \return An index to the light, or -1 if an error occurs - virtual s32 addDynamicLight(const SLight& light); - - //! Turns a dynamic light on or off - //! \param lightIndex: the index returned by addDynamicLight - //! \param turnOn: true to turn the light on, false to turn it off - virtual void turnLightOn(s32 lightIndex, bool turnOn); - - //! returns the maximal amount of dynamic lights the device can handle - virtual u32 getMaximalDynamicLightAmount() const; - - //! Sets the dynamic ambient light color. The default color is - //! (0,0,0,0) which means it is dark. - //! \param color: New color of the ambient light. - virtual void setAmbientLight(const SColorf& color); - - //! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do - //! this: First, draw all geometry. Then use this method, to draw the shadow - //! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow. - virtual void drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail); - - //! Fills the stencil shadow with color. After the shadow volume has been drawn - //! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this - //! to draw the color of the shadow. - virtual void drawStencilShadow(bool clearStencilBuffer=false, - video::SColor leftUpEdge = video::SColor(0,0,0,0), - video::SColor rightUpEdge = video::SColor(0,0,0,0), - video::SColor leftDownEdge = video::SColor(0,0,0,0), - video::SColor rightDownEdge = video::SColor(0,0,0,0)); - - //! sets a viewport - virtual void setViewPort(const core::rect<s32>& area); - - //! Sets the fog mode. - virtual void setFog(SColor color, E_FOG_TYPE fogType, f32 start, - f32 end, f32 density, bool pixelFog, bool rangeFog); - - //! Only used by the internal engine. Used to notify the driver that - //! the window was resized. - virtual void OnResize(const core::dimension2d<u32>& size); - - //! Returns type of video driver - virtual E_DRIVER_TYPE getDriverType() const; - - //! get color format of the current color buffer - virtual ECOLOR_FORMAT getColorFormat() const; - - //! Returns the transformation set by setTransform - virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) const; - - //! Can be called by an IMaterialRenderer to make its work easier. - virtual void setBasicRenderStates(const SMaterial& material, const SMaterial& lastmaterial, - bool resetAllRenderstates); - - //! Sets a vertex shader constant. - virtual void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1); - - //! Sets a pixel shader constant. - virtual void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1); - - //! Sets a constant for the vertex shader based on a name. - virtual bool setVertexShaderConstant(const c8* name, const f32* floats, int count); - - //! Sets a constant for the pixel shader based on a name. - virtual bool setPixelShaderConstant(const c8* name, const f32* floats, int count); - - //! sets the current Texture - //! Returns whether setting was a success or not. - bool setActiveTexture(u32 stage, const video::ITexture* texture); - - //! disables all textures beginning with the optional fromStage parameter. Otherwise all texture stages are disabled. - //! Returns whether disabling was successful or not. - bool disableTextures(u32 fromStage=0); - - //! Adds a new material renderer to the VideoDriver, using - //! extGLGetObjectParameteriv(shaderHandle, GL_OBJECT_COMPILE_STATUS_ARB, &status) - //! pixel and/or vertex shaders to render geometry. - virtual s32 addShaderMaterial(const c8* vertexShaderProgram, const c8* pixelShaderProgram, - IShaderConstantSetCallBack* callback, E_MATERIAL_TYPE baseMaterial, s32 userData); - - //! Adds a new material renderer to the VideoDriver, using GLSL to render geometry. - virtual s32 addHighLevelShaderMaterial(const c8* vertexShaderProgram, const c8* vertexShaderEntryPointName, - E_VERTEX_SHADER_TYPE vsCompileTarget, const c8* pixelShaderProgram, const c8* pixelShaderEntryPointName, - E_PIXEL_SHADER_TYPE psCompileTarget, IShaderConstantSetCallBack* callback, E_MATERIAL_TYPE baseMaterial, - s32 userData); - - //! Returns pointer to the IGPUProgrammingServices interface. - virtual IGPUProgrammingServices* getGPUProgrammingServices(); - - //! Returns a pointer to the IVideoDriver interface. (Implementation for - //! IMaterialRendererServices) - virtual IVideoDriver* getVideoDriver(); - - //! Returns the maximum amount of primitives (mostly vertices) which - //! the device is able to render with one drawIndexedTriangleList - //! call. - virtual u32 getMaximalPrimitiveCount() const; - - virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size, - const io::path& name, const ECOLOR_FORMAT format = ECF_UNKNOWN); - - //! set or reset render target - virtual bool setRenderTarget(video::E_RENDER_TARGET target, bool clearTarget, - bool clearZBuffer, SColor color); - - //! set or reset render target texture - virtual bool setRenderTarget(video::ITexture* texture, bool clearBackBuffer, - bool clearZBuffer, SColor color); - - //! Clears the ZBuffer. - virtual void clearZBuffer(); - - //! Returns an image created from the last rendered frame. - virtual IImage* createScreenShot(); - - //! checks if an OpenGL error has happend and prints it - //! for performance reasons only available in debug mode - bool testGLError(); - - //! Set/unset a clipping plane. - //! There are at least 6 clipping planes available for the user to set at will. - //! \param index: The plane index. Must be between 0 and MaxUserClipPlanes. - //! \param plane: The plane itself. - //! \param enable: If true, enable the clipping plane else disable it. - virtual bool setClipPlane(u32 index, const core::plane3df& plane, bool enable=false); - - //! Enable/disable a clipping plane. - //! There are at least 6 clipping planes available for the user to set at will. - //! \param index: The plane index. Must be between 0 and MaxUserClipPlanes. - //! \param enable: If true, enable the clipping plane else disable it. - virtual void enableClipPlane(u32 index, bool enable); - - //! Returns the graphics card vendor name. - virtual core::stringc getVendorInfo() {return vendorName;} - - ITexture* createDepthTexture(ITexture* texture, bool shared=true); - void removeDepthTexture(ITexture* texture); - - private: - - //! clears the zbuffer and color buffer - void clearBuffers(bool backBuffer, bool zBuffer, bool stencilBuffer, SColor color); - - bool updateVertexHardwareBuffer(SHWBufferLink_opengl *HWBuffer); - bool updateIndexHardwareBuffer(SHWBufferLink_opengl *HWBuffer); - - void uploadClipPlane(u32 index); - - //! inits the parts of the open gl driver used on all platforms - bool genericDriverInit(const core::dimension2d<u32>& screenSize, bool stencilBuffer); - //! returns a device dependent texture from a software surface (IImage) - virtual video::ITexture* createDeviceDependentTexture(IImage* surface, const io::path& name); - - //! creates a transposed matrix in supplied GLfloat array to pass to OpenGL - inline void createGLMatrix(GLfloat gl_matrix[16], const core::matrix4& m); - inline void createGLTextureMatrix(GLfloat gl_matrix[16], const core::matrix4& m); - - //! Set GL pipeline to desired texture wrap modes of the material - void setWrapMode(const SMaterial& material); - - //! sets the needed renderstates - void setRenderStates3DMode(); - - //! sets the needed renderstates - void setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel); - - // returns the current size of the screen or rendertarget - virtual const core::dimension2d<u32>& getCurrentRenderTargetSize() const; - - void createMaterialRenderers(); - - //! Assign a hardware light to the specified requested light, if any - //! free hardware lights exist. - //! \param[in] lightIndex: the index of the requesting light - void assignHardwareLight(u32 lightIndex); - - //! helper function for render setup. - void createColorBuffer(const void* vertices, u32 vertexCount, E_VERTEX_TYPE vType); - - //! helper function doing the actual rendering. - void renderArray(const void* indexList, u32 primitiveCount, - scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType); - - core::stringw Name; - core::matrix4 Matrices[ETS_COUNT]; - core::array<u8> ColorBuffer; - - //! enumeration for rendering modes such as 2d and 3d for minizing the switching of renderStates. - enum E_RENDER_MODE - { - ERM_NONE = 0, // no render state has been set yet. - ERM_2D, // 2d drawing rendermode - ERM_3D // 3d rendering mode - }; - - E_RENDER_MODE CurrentRenderMode; - //! bool to make all renderstates reset if set to true. - bool ResetRenderStates; - bool Transformation3DChanged; - u8 AntiAlias; - - SMaterial Material, LastMaterial; - COpenGLTexture* RenderTargetTexture; - const ITexture* CurrentTexture[MATERIAL_MAX_TEXTURES]; - core::array<ITexture*> DepthTextures; - core::array<core::plane3df> UserClipPlane; - core::array<bool> UserClipPlaneEnabled; - - core::dimension2d<u32> CurrentRendertargetSize; - - core::stringc vendorName; - - core::matrix4 TextureFlipMatrix; - - //! Color buffer format - ECOLOR_FORMAT ColorFormat; - - //! Render target type for render operations - E_RENDER_TARGET CurrentTarget; - - bool Doublebuffer; - bool Stereo; - - //! All the lights that have been requested; a hardware limited - //! number of them will be used at once. - struct RequestedLight - { - RequestedLight(SLight const & lightData) - : LightData(lightData), HardwareLightIndex(-1), DesireToBeOn(true) { } - - SLight LightData; - s32 HardwareLightIndex; // GL_LIGHT0 - GL_LIGHT7 - bool DesireToBeOn; - }; - core::array<RequestedLight> RequestedLights; - - #ifdef _IRR_WINDOWS_API_ - HDC HDc; // Private GDI Device Context - HWND Window; - HGLRC HRc; // Permanent Rendering Context - #endif - #ifdef _IRR_COMPILE_WITH_X11_DEVICE_ - GLXDrawable Drawable; - #endif - #ifdef _IRR_COMPILE_WITH_OSX_DEVICE_ - CIrrDeviceMacOSX *_device; - #endif - - E_DEVICE_TYPE DeviceType; - }; - -} // end namespace video -} // end namespace irr - - -#endif // _IRR_COMPILE_WITH_OPENGL_ -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/COpenGLExtensionHandler.cpp b/irrlicht-1.6/source/Irrlicht/COpenGLExtensionHandler.cpp deleted file mode 100644 index 2b63dd023..000000000 --- a/irrlicht-1.6/source/Irrlicht/COpenGLExtensionHandler.cpp +++ /dev/null @@ -1,547 +0,0 @@ -// Copyright (C) 2002-2009 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_OPENGL_ - -#include "COpenGLExtensionHandler.h" -#include "irrString.h" -#include "SMaterial.h" // for MATERIAL_MAX_TEXTURES -#include "fast_atof.h" - -namespace irr -{ -namespace video -{ - -COpenGLExtensionHandler::COpenGLExtensionHandler() : - StencilBuffer(false), MultiTextureExtension(false), - TextureCompressionExtension(false), - MaxTextureUnits(1), MaxLights(1), MaxAnisotropy(1), MaxUserClipPlanes(0), - MaxAuxBuffers(0), MaxIndices(65535), MaxTextureSize(1), MaxTextureLODBias(0.f), - MaxMultipleRenderTargets(1), Version(0), ShaderLanguageVersion(0) -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - ,pGlActiveTextureARB(0), pGlClientActiveTextureARB(0), - pGlGenProgramsARB(0), pGlBindProgramARB(0), pGlProgramStringARB(0), - pGlDeleteProgramsARB(0), pGlProgramLocalParameter4fvARB(0), - pGlCreateShaderObjectARB(0), pGlShaderSourceARB(0), - pGlCompileShaderARB(0), pGlCreateProgramObjectARB(0), pGlAttachObjectARB(0), - pGlLinkProgramARB(0), pGlUseProgramObjectARB(0), pGlDeleteObjectARB(0), - pGlGetObjectParameterivARB(0), pGlGetUniformLocationARB(0), - pGlUniform1ivARB(0), pGlUniform1fvARB(0), pGlUniform2fvARB(0), pGlUniform3fvARB(0), pGlUniform4fvARB(0), pGlUniformMatrix2fvARB(0), - pGlUniformMatrix3fvARB(0), pGlUniformMatrix4fvARB(0), pGlGetActiveUniformARB(0), pGlPointParameterfARB(0), pGlPointParameterfvARB(0), - pGlStencilFuncSeparate(0), pGlStencilOpSeparate(0), - pGlStencilFuncSeparateATI(0), pGlStencilOpSeparateATI(0), - pGlCompressedTexImage2D(0), -#if defined(GLX_SGI_swap_control) - glxSwapIntervalSGI(0), -#endif - pGlBindFramebufferEXT(0), pGlDeleteFramebuffersEXT(0), pGlGenFramebuffersEXT(0), - pGlCheckFramebufferStatusEXT(0), pGlFramebufferTexture2DEXT(0), - pGlBindRenderbufferEXT(0), pGlDeleteRenderbuffersEXT(0), pGlGenRenderbuffersEXT(0), - pGlRenderbufferStorageEXT(0), pGlFramebufferRenderbufferEXT(0), - pGlDrawBuffersARB(0), pGlDrawBuffersATI(0), - pGlGenBuffersARB(0), pGlBindBufferARB(0), pGlBufferDataARB(0), pGlDeleteBuffersARB(0), - pGlBufferSubDataARB(0), pGlGetBufferSubDataARB(0), pGlMapBufferARB(0), pGlUnmapBufferARB(0), - pGlIsBufferARB(0), pGlGetBufferParameterivARB(0), pGlGetBufferPointervARB(0), - pGlProvokingVertexARB(0), pGlProvokingVertexEXT(0) - - -#endif // _IRR_OPENGL_USE_EXTPOINTER_ -{ - for (u32 i=0; i<IRR_OpenGL_Feature_Count; ++i) - FeatureAvailable[i]=false; - DimAliasedLine[0]=1.f; - DimAliasedLine[1]=1.f; - DimAliasedPoint[0]=1.f; - DimAliasedPoint[1]=1.f; - DimSmoothedLine[0]=1.f; - DimSmoothedLine[1]=1.f; - DimSmoothedPoint[0]=1.f; - DimSmoothedPoint[1]=1.f; -} - - -void COpenGLExtensionHandler::dump() const -{ - for (u32 i=0; i<IRR_OpenGL_Feature_Count; ++i) - os::Printer::log(OpenGLFeatureStrings[i], FeatureAvailable[i]?" true":" false"); -} - -void COpenGLExtensionHandler::initExtensions(bool stencilBuffer) -{ - const f32 ogl_ver = core::fast_atof(reinterpret_cast<const c8*>(glGetString(GL_VERSION))); - Version = static_cast<u16>(core::floor32(ogl_ver)*100+core::round32(core::fract(ogl_ver)*10.0f)); - if ( Version >= 102) - os::Printer::log("OpenGL driver version is 1.2 or better.", ELL_INFORMATION); - else - os::Printer::log("OpenGL driver version is not 1.2 or better.", ELL_WARNING); - - { - const char* t = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)); - size_t len = 0; - c8 *str = 0; - if (t) - { - len = strlen(t); - str = new c8[len+1]; - } - c8* p = str; - - for (size_t i=0; i<len; ++i) - { - str[i] = static_cast<char>(t[i]); - - if (str[i] == ' ') - { - str[i] = 0; - for (u32 j=0; j<IRR_OpenGL_Feature_Count; ++j) - { - if (!strcmp(OpenGLFeatureStrings[j], p)) - { - FeatureAvailable[j] = true; - break; - } - } - - p = p + strlen(p) + 1; - } - } - - delete [] str; - } - - MultiTextureExtension = FeatureAvailable[IRR_ARB_multitexture]; - TextureCompressionExtension = FeatureAvailable[IRR_ARB_texture_compression]; - StencilBuffer=stencilBuffer; - -#ifdef _IRR_WINDOWS_API_ - // get multitexturing function pointers - pGlActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC) wglGetProcAddress("glActiveTextureARB"); - pGlClientActiveTextureARB = (PFNGLCLIENTACTIVETEXTUREARBPROC) wglGetProcAddress("glClientActiveTextureARB"); - - // get fragment and vertex program function pointers - pGlGenProgramsARB = (PFNGLGENPROGRAMSARBPROC) wglGetProcAddress("glGenProgramsARB"); - pGlBindProgramARB = (PFNGLBINDPROGRAMARBPROC) wglGetProcAddress("glBindProgramARB"); - pGlProgramStringARB = (PFNGLPROGRAMSTRINGARBPROC) wglGetProcAddress("glProgramStringARB"); - pGlDeleteProgramsARB = (PFNGLDELETEPROGRAMSNVPROC) wglGetProcAddress("glDeleteProgramsARB"); - pGlProgramLocalParameter4fvARB = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) wglGetProcAddress("glProgramLocalParameter4fvARB"); - pGlCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC) wglGetProcAddress("glCreateShaderObjectARB"); - pGlShaderSourceARB = (PFNGLSHADERSOURCEARBPROC) wglGetProcAddress("glShaderSourceARB"); - pGlCompileShaderARB = (PFNGLCOMPILESHADERARBPROC) wglGetProcAddress("glCompileShaderARB"); - pGlCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC) wglGetProcAddress("glCreateProgramObjectARB"); - pGlAttachObjectARB = (PFNGLATTACHOBJECTARBPROC) wglGetProcAddress("glAttachObjectARB"); - pGlLinkProgramARB = (PFNGLLINKPROGRAMARBPROC) wglGetProcAddress("glLinkProgramARB"); - pGlUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC) wglGetProcAddress("glUseProgramObjectARB"); - pGlDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC) wglGetProcAddress("glDeleteObjectARB"); - pGlGetInfoLogARB = (PFNGLGETINFOLOGARBPROC) wglGetProcAddress("glGetInfoLogARB"); - pGlGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC) wglGetProcAddress("glGetObjectParameterivARB"); - pGlGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC) wglGetProcAddress("glGetUniformLocationARB"); - pGlUniform4fvARB = (PFNGLUNIFORM4FVARBPROC) wglGetProcAddress("glUniform4fvARB"); - pGlUniform1ivARB = (PFNGLUNIFORM1IVARBPROC) wglGetProcAddress("glUniform1ivARB"); - pGlUniform1fvARB = (PFNGLUNIFORM1FVARBPROC) wglGetProcAddress("glUniform1fvARB"); - pGlUniform2fvARB = (PFNGLUNIFORM2FVARBPROC) wglGetProcAddress("glUniform2fvARB"); - pGlUniform3fvARB = (PFNGLUNIFORM3FVARBPROC) wglGetProcAddress("glUniform3fvARB"); - pGlUniformMatrix2fvARB = (PFNGLUNIFORMMATRIX2FVARBPROC) wglGetProcAddress("glUniformMatrix2fvARB"); - pGlUniformMatrix3fvARB = (PFNGLUNIFORMMATRIX3FVARBPROC) wglGetProcAddress("glUniformMatrix3fvARB"); - pGlUniformMatrix4fvARB = (PFNGLUNIFORMMATRIX4FVARBPROC) wglGetProcAddress("glUniformMatrix4fvARB"); - pGlGetActiveUniformARB = (PFNGLGETACTIVEUNIFORMARBPROC) wglGetProcAddress("glGetActiveUniformARB"); - - // get point parameter extension - pGlPointParameterfARB = (PFNGLPOINTPARAMETERFARBPROC) wglGetProcAddress("glPointParameterfARB"); - pGlPointParameterfvARB = (PFNGLPOINTPARAMETERFVARBPROC) wglGetProcAddress("glPointParameterfvARB"); - - // get stencil extension - pGlStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC) wglGetProcAddress("glStencilFuncSeparate"); - pGlStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC) wglGetProcAddress("glStencilOpSeparate"); - pGlStencilFuncSeparateATI = (PFNGLSTENCILFUNCSEPARATEATIPROC) wglGetProcAddress("glStencilFuncSeparateATI"); - pGlStencilOpSeparateATI = (PFNGLSTENCILOPSEPARATEATIPROC) wglGetProcAddress("glStencilOpSeparateATI"); - - // compressed textures - pGlCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC) wglGetProcAddress("glCompressedTexImage2D"); - - // FrameBufferObjects - pGlBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC) wglGetProcAddress("glBindFramebufferEXT"); - pGlDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC) wglGetProcAddress("glDeleteFramebuffersEXT"); - pGlGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC) wglGetProcAddress("glGenFramebuffersEXT"); - pGlCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) wglGetProcAddress("glCheckFramebufferStatusEXT"); - pGlFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) wglGetProcAddress("glFramebufferTexture2DEXT"); - pGlBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC) wglGetProcAddress("glBindRenderbufferEXT"); - pGlDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC) wglGetProcAddress("glDeleteRenderbuffersEXT"); - pGlGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC) wglGetProcAddress("glGenRenderbuffersEXT"); - pGlRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC) wglGetProcAddress("glRenderbufferStorageEXT"); - pGlFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) wglGetProcAddress("glFramebufferRenderbufferEXT"); - pGlDrawBuffersARB = (PFNGLDRAWBUFFERSARBPROC) wglGetProcAddress("glDrawBuffersARB"); - pGlDrawBuffersATI = (PFNGLDRAWBUFFERSATIPROC) wglGetProcAddress("glDrawBuffersATI"); - - // get vertex buffer extension - pGlGenBuffersARB = (PFNGLGENBUFFERSARBPROC) wglGetProcAddress("glGenBuffersARB"); - pGlBindBufferARB = (PFNGLBINDBUFFERARBPROC) wglGetProcAddress("glBindBufferARB"); - pGlBufferDataARB = (PFNGLBUFFERDATAARBPROC) wglGetProcAddress("glBufferDataARB"); - pGlDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC) wglGetProcAddress("glDeleteBuffersARB"); - pGlBufferSubDataARB= (PFNGLBUFFERSUBDATAARBPROC) wglGetProcAddress("glBufferSubDataARB"); - pGlGetBufferSubDataARB= (PFNGLGETBUFFERSUBDATAARBPROC)wglGetProcAddress("glGetBufferSubDataARB"); - pGlMapBufferARB= (PFNGLMAPBUFFERARBPROC) wglGetProcAddress("glMapBufferARB"); - pGlUnmapBufferARB= (PFNGLUNMAPBUFFERARBPROC) wglGetProcAddress("glUnmapBufferARB"); - pGlIsBufferARB= (PFNGLISBUFFERARBPROC) wglGetProcAddress("glIsBufferARB"); - pGlGetBufferParameterivARB= (PFNGLGETBUFFERPARAMETERIVARBPROC) wglGetProcAddress("glGetBufferParameterivARB"); - pGlGetBufferPointervARB= (PFNGLGETBUFFERPOINTERVARBPROC) wglGetProcAddress("glGetBufferPointervARB"); - pGlProvokingVertexARB= (PFNGLPROVOKINGVERTEXPROC) wglGetProcAddress("glProvokingVertex"); - pGlProvokingVertexEXT= (PFNGLPROVOKINGVERTEXEXTPROC) wglGetProcAddress("glProvokingVertexEXT"); - - -#elif defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined (_IRR_COMPILE_WITH_SDL_DEVICE_) - #ifdef _IRR_OPENGL_USE_EXTPOINTER_ - - #if defined(_IRR_COMPILE_WITH_SDL_DEVICE_) && !defined(_IRR_COMPILE_WITH_X11_DEVICE_) - #define IRR_OGL_LOAD_EXTENSION(x) SDL_GL_GetProcAddress(reinterpret_cast<const char*>(x)) - #else - // Accessing the correct function is quite complex - // All libraries should support the ARB version, however - // since GLX 1.4 the non-ARB version is the official one - // So we have to check the runtime environment and - // choose the proper symbol - // In case you still have problems please enable the - // next line by uncommenting it - // #define _IRR_GETPROCADDRESS_WORKAROUND_ - - #ifndef _IRR_GETPROCADDRESS_WORKAROUND_ - __GLXextFuncPtr (*IRR_OGL_LOAD_EXTENSION)(const GLubyte*)=0; - #ifdef GLX_VERSION_1_4 - int major=0,minor=0; - if (glXGetCurrentDisplay()) - glXQueryVersion(glXGetCurrentDisplay(), &major, &minor); - if ((major>1) || (minor>3)) - IRR_OGL_LOAD_EXTENSION=glXGetProcAddress; - else - #endif - IRR_OGL_LOAD_EXTENSION=glXGetProcAddressARB; - #else - #define IRR_OGL_LOAD_EXTENSION glXGetProcAddressARB - #endif - #endif - - pGlActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glActiveTextureARB")); - - pGlClientActiveTextureARB = (PFNGLCLIENTACTIVETEXTUREARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glClientActiveTextureARB")); - - // get fragment and vertex program function pointers - pGlGenProgramsARB = (PFNGLGENPROGRAMSARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glGenProgramsARB")); - - pGlBindProgramARB = (PFNGLBINDPROGRAMARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glBindProgramARB")); - - pGlProgramStringARB = (PFNGLPROGRAMSTRINGARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glProgramStringARB")); - - pGlDeleteProgramsARB = (PFNGLDELETEPROGRAMSNVPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glDeleteProgramsARB")); - - pGlProgramLocalParameter4fvARB = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glProgramLocalParameter4fvARB")); - - pGlCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glCreateShaderObjectARB")); - - pGlShaderSourceARB = (PFNGLSHADERSOURCEARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glShaderSourceARB")); - - pGlCompileShaderARB = (PFNGLCOMPILESHADERARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glCompileShaderARB")); - - pGlCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glCreateProgramObjectARB")); - - pGlAttachObjectARB = (PFNGLATTACHOBJECTARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glAttachObjectARB")); - - pGlLinkProgramARB = (PFNGLLINKPROGRAMARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glLinkProgramARB")); - - pGlUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glUseProgramObjectARB")); - - pGlDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glDeleteObjectARB")); - - pGlGetInfoLogARB = (PFNGLGETINFOLOGARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glGetInfoLogARB")); - - pGlGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glGetObjectParameterivARB")); - - pGlGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glGetUniformLocationARB")); - - pGlUniform4fvARB = (PFNGLUNIFORM4FVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glUniform4fvARB")); - - pGlUniform1ivARB = (PFNGLUNIFORM1IVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glUniform1ivARB")); - - pGlUniform1fvARB = (PFNGLUNIFORM1FVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glUniform1fvARB")); - - pGlUniform2fvARB = (PFNGLUNIFORM2FVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glUniform2fvARB")); - - pGlUniform3fvARB = (PFNGLUNIFORM3FVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glUniform3fvARB")); - - pGlUniform4fvARB = (PFNGLUNIFORM4FVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glUniform4fvARB")); - - pGlUniformMatrix2fvARB = (PFNGLUNIFORMMATRIX2FVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glUniformMatrix2fvARB")); - - pGlUniformMatrix3fvARB = (PFNGLUNIFORMMATRIX3FVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glUniformMatrix3fvARB")); - - pGlUniformMatrix4fvARB = (PFNGLUNIFORMMATRIX4FVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glUniformMatrix4fvARB")); - - pGlGetActiveUniformARB = (PFNGLGETACTIVEUNIFORMARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glGetActiveUniformARB")); - - // get point parameter extension - pGlPointParameterfARB = (PFNGLPOINTPARAMETERFARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glPointParameterfARB")); - pGlPointParameterfvARB = (PFNGLPOINTPARAMETERFVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glPointParameterfvARB")); - - // get stencil extension - pGlStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glStencilFuncSeparate")); - pGlStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glStencilOpSeparate")); - pGlStencilFuncSeparateATI = (PFNGLSTENCILFUNCSEPARATEATIPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glStencilFuncSeparateATI")); - pGlStencilOpSeparateATI = (PFNGLSTENCILOPSEPARATEATIPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glStencilOpSeparateATI")); - - // compressed textures - pGlCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glCompressedTexImage2D")); - - #if defined(GLX_SGI_swap_control) && !defined(_IRR_COMPILE_WITH_SDL_DEVICE_) - // get vsync extension - glxSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glXSwapIntervalSGI")); - #endif - - // FrameBufferObjects - pGlBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glBindFramebufferEXT")); - - pGlDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glDeleteFramebuffersEXT")); - - pGlGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glGenFramebuffersEXT")); - - pGlCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glCheckFramebufferStatusEXT")); - - pGlFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glFramebufferTexture2DEXT")); - - pGlBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glBindRenderbufferEXT")); - - pGlDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glDeleteRenderbuffersEXT")); - - pGlGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glGenRenderbuffersEXT")); - - pGlRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glRenderbufferStorageEXT")); - - pGlFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glFramebufferRenderbufferEXT")); - - pGlDrawBuffersARB = (PFNGLDRAWBUFFERSARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glDrawBuffersARB")); - - pGlDrawBuffersATI = (PFNGLDRAWBUFFERSATIPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glDrawBuffersATI")); - - pGlGenBuffersARB = (PFNGLGENBUFFERSARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glGenBuffersARB")); - - pGlBindBufferARB = (PFNGLBINDBUFFERARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glBindBufferARB")); - - pGlBufferDataARB = (PFNGLBUFFERDATAARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glBufferDataARB")); - - pGlDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glDeleteBuffersARB")); - - pGlBufferSubDataARB = (PFNGLBUFFERSUBDATAARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glBufferSubDataARB")); - - pGlGetBufferSubDataARB = (PFNGLGETBUFFERSUBDATAARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glGetBufferSubDataARB")); - - pGlMapBufferARB = (PFNGLMAPBUFFERARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glMapBufferARB")); - - pGlUnmapBufferARB = (PFNGLUNMAPBUFFERARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glUnmapBufferARB")); - - pGlIsBufferARB = (PFNGLISBUFFERARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glIsBufferARB")); - - pGlGetBufferParameterivARB = (PFNGLGETBUFFERPARAMETERIVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glGetBufferParameterivARB")); - - pGlGetBufferPointervARB = (PFNGLGETBUFFERPOINTERVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glGetBufferPointervARB")); - pGlProvokingVertexARB= (PFNGLPROVOKINGVERTEXPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glProvokingVertex")); - pGlProvokingVertexEXT= (PFNGLPROVOKINGVERTEXEXTPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glProvokingVertexEXT")); - - - #endif // _IRR_OPENGL_USE_EXTPOINTER_ -#endif // _IRR_WINDOWS_API_ - - GLint num; - // set some properties -#if defined(GL_ARB_multitexture) || defined(GL_VERSION_1_3) - if (Version>102 || FeatureAvailable[IRR_ARB_multitexture]) - { - glGetIntegerv(GL_MAX_TEXTURE_UNITS, &num); - MaxTextureUnits=static_cast<u8>(num); - } -#endif - glGetIntegerv(GL_MAX_LIGHTS, &num); - MaxLights=static_cast<u8>(num); -#ifdef GL_EXT_texture_filter_anisotropic - if (FeatureAvailable[IRR_EXT_texture_filter_anisotropic]) - glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &num); - MaxAnisotropy=static_cast<u8>(num); -#endif -#ifdef GL_VERSION_1_2 - if (Version>101) - { - glGetIntegerv(GL_MAX_ELEMENTS_INDICES, &num); - MaxIndices=num; - } -#endif - glGetIntegerv(GL_MAX_TEXTURE_SIZE, &num); - MaxTextureSize=static_cast<u32>(num); -#ifdef EXT_texture_lod_bias - if (FeatureAvailable[IRR_EXT_texture_lod_bias]) - glGetFloatv(GL_MAX_TEXTURE_LOD_BIAS_EXT, &MaxTextureLODBias); -#endif - glGetIntegerv(GL_MAX_CLIP_PLANES, &num); - MaxUserClipPlanes=static_cast<u8>(num); - glGetIntegerv(GL_AUX_BUFFERS, &num); - MaxAuxBuffers=static_cast<u8>(num); -#ifdef ARB_draw_buffers - if (FeatureAvailable[IRR_ARB_draw_buffers]) - { - glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, reinterpret_cast<GLint*>(&MaxUserClipPlanes)); - MaxMultipleRenderTargets = static_cast<u8>(MaxUserClipPlanes); - } -#elif defined(ATI_draw_buffers) - if (FeatureAvailable[IRR_ATI_draw_buffers]) - { - glGetIntegerv(GL_MAX_DRAW_BUFFERS_ATI, reinterpret_cast<GLint*>(&MaxUserClipPlanes)); - MaxMultipleRenderTargets = static_cast<u8>(MaxUserClipPlanes); - } -#endif - glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, DimAliasedLine); - glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, DimAliasedPoint); - glGetFloatv(GL_SMOOTH_LINE_WIDTH_RANGE, DimSmoothedLine); - glGetFloatv(GL_SMOOTH_POINT_SIZE_RANGE, DimSmoothedPoint); -#if defined(GL_ARB_shading_language_100) || defined (GL_VERSION_2_0) - if (FeatureAvailable[IRR_ARB_shading_language_100] || Version>=200) - { - glGetError(); // clean error buffer -#ifdef GL_SHADING_LANGUAGE_VERSION - const GLubyte* shaderVersion = glGetString(GL_SHADING_LANGUAGE_VERSION); -#else - const GLubyte* shaderVersion = glGetString(GL_SHADING_LANGUAGE_VERSION_ARB); -#endif - if (glGetError() == GL_INVALID_ENUM) - ShaderLanguageVersion = 100; - else - { - const f32 sl_ver = core::fast_atof(reinterpret_cast<const c8*>(shaderVersion)); - ShaderLanguageVersion = static_cast<u16>(core::floor32(sl_ver)*100+core::round32(core::fract(sl_ver)*10.0f)); - } - } -#endif - -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (!pGlActiveTextureARB || !pGlClientActiveTextureARB) - { - MultiTextureExtension = false; - os::Printer::log("Failed to load OpenGL's multitexture extension, proceeding without.", ELL_WARNING); - } - else -#endif - if (MaxTextureUnits < 2) - { - MultiTextureExtension = false; - os::Printer::log("Warning: OpenGL device only has one texture unit. Disabling multitexturing.", ELL_WARNING); - } - MaxTextureUnits = core::min_(MaxTextureUnits,static_cast<u8>(MATERIAL_MAX_TEXTURES)); - -} - -bool COpenGLExtensionHandler::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const -{ - switch (feature) - { - case EVDF_RENDER_TO_TARGET: - return true; - case EVDF_MULTITEXTURE: - return MultiTextureExtension; - case EVDF_BILINEAR_FILTER: - return true; - case EVDF_MIP_MAP: - return true; - case EVDF_MIP_MAP_AUTO_UPDATE: - return FeatureAvailable[IRR_SGIS_generate_mipmap]; - case EVDF_STENCIL_BUFFER: - return StencilBuffer; - case EVDF_ARB_VERTEX_PROGRAM_1: - return FeatureAvailable[IRR_ARB_vertex_program]; - case EVDF_ARB_FRAGMENT_PROGRAM_1: - return FeatureAvailable[IRR_ARB_fragment_program]; - case EVDF_ARB_GLSL: - return (FeatureAvailable[IRR_ARB_shading_language_100]||Version>=200); - case EVDF_TEXTURE_NSQUARE: - return true; // non-square is always supported - case EVDF_TEXTURE_NPOT: - // Some ATI cards seem to have only SW support in OpenGL 2.0 - // drivers if the extension is not exposed, so we skip this - // extra test for now! - // return (FeatureAvailable[IRR_ARB_texture_non_power_of_two]||Version>=200); - return (FeatureAvailable[IRR_ARB_texture_non_power_of_two]); - case EVDF_FRAMEBUFFER_OBJECT: - return FeatureAvailable[IRR_EXT_framebuffer_object]; - case EVDF_VERTEX_BUFFER_OBJECT: - return FeatureAvailable[IRR_ARB_vertex_buffer_object]; - case EVDF_COLOR_MASK: - return true; - case EVDF_ALPHA_TO_COVERAGE: - return FeatureAvailable[IRR_ARB_multisample]; - default: - return false; - }; -} - - -} -} - -#endif diff --git a/irrlicht-1.6/source/Irrlicht/COpenGLExtensionHandler.h b/irrlicht-1.6/source/Irrlicht/COpenGLExtensionHandler.h deleted file mode 100644 index 175693681..000000000 --- a/irrlicht-1.6/source/Irrlicht/COpenGLExtensionHandler.h +++ /dev/null @@ -1,1674 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in Irrlicht.h - -#ifndef __C_OPEN_GL_FEATURE_MAP_H_INCLUDED__ -#define __C_OPEN_GL_FEATURE_MAP_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_OPENGL_ - -#include "EDriverFeatures.h" -#include "irrTypes.h" -#include "os.h" - -#if defined(_IRR_WINDOWS_API_) - // include windows headers for HWND - #define WIN32_LEAN_AND_MEAN - #include <windows.h> - #if defined(_IRR_OPENGL_USE_EXTPOINTER_) - #define GL_GLEXT_LEGACY 1 - #endif - #include <GL/gl.h> - #if defined(_IRR_OPENGL_USE_EXTPOINTER_) - #include "glext.h" - #endif - #include "wglext.h" - - #ifdef _MSC_VER - #pragma comment(lib, "OpenGL32.lib") - #endif - -#elif defined(_IRR_COMPILE_WITH_OSX_DEVICE_) - #include "CIrrDeviceMacOSX.h" - #if defined(_IRR_OPENGL_USE_EXTPOINTER_) - #define GL_GLEXT_LEGACY 1 - #endif - #include <OpenGL/gl.h> - #if defined(_IRR_OPENGL_USE_EXTPOINTER_) - #include "glext.h" - #endif -#elif defined(_IRR_COMPILE_WITH_SDL_DEVICE_) && !defined(_IRR_COMPILE_WITH_X11_DEVICE_) - #if defined(_IRR_OPENGL_USE_EXTPOINTER_) - #define GL_GLEXT_LEGACY 1 - #define GLX_GLXEXT_LEGACY 1 - #else - #define GL_GLEXT_PROTOTYPES 1 - #define GLX_GLXEXT_PROTOTYPES 1 - #endif - #define NO_SDL_GLEXT - #include <SDL/SDL_video.h> - #include <SDL/SDL_opengl.h> - #include "glext.h" -#else - #if defined(_IRR_OPENGL_USE_EXTPOINTER_) - #define GL_GLEXT_LEGACY 1 - #define GLX_GLXEXT_LEGACY 1 - #else - #define GL_GLEXT_PROTOTYPES 1 - #define GLX_GLXEXT_PROTOTYPES 1 - #endif - #include <GL/gl.h> - #include <GL/glx.h> - #if defined(_IRR_OPENGL_USE_EXTPOINTER_) - #include "glext.h" - #undef GLX_ARB_get_proc_address // avoid problems with local glxext.h - #include "glxext.h" - #endif -#endif - - -namespace irr -{ -namespace video -{ - - -static const char* const OpenGLFeatureStrings[] = { - "GL_3DFX_multisample", - "GL_3DFX_tbuffer", - "GL_3DFX_texture_compression_FXT1", - "GL_AMD_draw_buffers_blend", - "GL_AMD_performance_monitor", - "GL_AMD_texture_texture4", - "GL_AMD_vertex_shader_tesselator", - "GL_APPLE_aux_depth_stencil", - "GL_APPLE_client_storage", - "GL_APPLE_element_array", - "GL_APPLE_fence", - "GL_APPLE_float_pixels", - "GL_APPLE_flush_buffer_range", - "GL_APPLE_object_purgeable", - "GL_APPLE_row_bytes", - "GL_APPLE_specular_vector", - "GL_APPLE_texture_range", - "GL_APPLE_transform_hint", - "GL_APPLE_vertex_array_object", - "GL_APPLE_vertex_array_range", - "GL_APPLE_vertex_program_evaluators", - "GL_APPLE_ycbcr_422", - "GL_ARB_color_buffer_float", - "GL_ARB_compatibility", - "GL_ARB_copy_buffer", - "GL_ARB_depth_buffer_float", - "GL_ARB_depth_clamp", - "GL_ARB_depth_texture", - "GL_ARB_draw_buffers", - "GL_ARB_draw_buffers_blend", - "GL_ARB_draw_elements_base_vertex", - "GL_ARB_draw_instanced", - "GL_ARB_fragment_coord_conventions", - "GL_ARB_fragment_program", - "GL_ARB_fragment_program_shadow", - "GL_ARB_fragment_shader", - "GL_ARB_framebuffer_object", - "GL_ARB_framebuffer_sRGB", - "GL_ARB_geometry_shader4", - "GL_ARB_half_float_pixel", - "GL_ARB_half_float_vertex", - "GL_ARB_imaging", - "GL_ARB_instanced_arrays", - "GL_ARB_map_buffer_range", - "GL_ARB_matrix_palette", - "GL_ARB_multisample", - "GL_ARB_multitexture", - "GL_ARB_occlusion_query", - "GL_ARB_pixel_buffer_object", - "GL_ARB_point_parameters", - "GL_ARB_point_sprite", - "GL_ARB_provoking_vertex", - "GL_ARB_sample_shading", - "GL_ARB_seamless_cube_map", - "GL_ARB_shader_objects", - "GL_ARB_shader_texture_lod", - "GL_ARB_shading_language_100", - "GL_ARB_shadow", - "GL_ARB_shadow_ambient", - "GL_ARB_sync", - "GL_ARB_texture_border_clamp", - "GL_ARB_texture_buffer_object", - "GL_ARB_texture_compression", - "GL_ARB_texture_compression_rgtc", - "GL_ARB_texture_cube_map", - "GL_ARB_texture_cube_map_array", - "GL_ARB_texture_env_add", - "GL_ARB_texture_env_combine", - "GL_ARB_texture_env_crossbar", - "GL_ARB_texture_env_dot3", - "GL_ARB_texture_float", - "GL_ARB_texture_gather", - "GL_ARB_texture_mirrored_repeat", - "GL_ARB_texture_multisample", - "GL_ARB_texture_non_power_of_two", - "GL_ARB_texture_query_lod", - "GL_ARB_texture_rectangle", - "GL_ARB_texture_rg", - "GL_ARB_transpose_matrix", - "GL_ARB_uniform_buffer_object", - "GL_ARB_vertex_array_bgra", - "GL_ARB_vertex_array_object", - "GL_ARB_vertex_blend", - "GL_ARB_vertex_buffer_object", - "GL_ARB_vertex_program", - "GL_ARB_vertex_shader", - "GL_ARB_window_pos", - "GL_ATI_draw_buffers", - "GL_ATI_element_array", - "GL_ATI_envmap_bumpmap", - "GL_ATI_fragment_shader", - "GL_ATI_map_object_buffer", - "GL_ATI_meminfo", - "GL_ATI_pixel_format_float", - "GL_ATI_pn_triangles", - "GL_ATI_separate_stencil", - "GL_ATI_text_fragment_shader", - "GL_ATI_texture_env_combine3", - "GL_ATI_texture_float", - "GL_ATI_texture_mirror_once", - "GL_ATI_vertex_array_object", - "GL_ATI_vertex_attrib_array_object", - "GL_ATI_vertex_streams", - "GL_EXT_422_pixels", - "GL_EXT_abgr", - "GL_EXT_bgra", - "GL_EXT_bindable_uniform", - "GL_EXT_blend_color", - "GL_EXT_blend_equation_separate", - "GL_EXT_blend_func_separate", - "GL_EXT_blend_logic_op", - "GL_EXT_blend_minmax", - "GL_EXT_blend_subtract", - "GL_EXT_clip_volume_hint", - "GL_EXT_cmyka", - "GL_EXT_color_subtable", - "GL_EXT_compiled_vertex_array", - "GL_EXT_convolution", - "GL_EXT_coordinate_frame", - "GL_EXT_copy_texture", - "GL_EXT_cull_vertex", - "GL_EXT_depth_bounds_test", - "GL_EXT_direct_state_access", - "GL_EXT_draw_buffers2", - "GL_EXT_draw_instanced", - "GL_EXT_draw_range_elements", - "GL_EXT_fog_coord", - "GL_EXT_framebuffer_blit", - "GL_EXT_framebuffer_multisample", - "GL_EXT_framebuffer_object", - "GL_EXT_framebuffer_sRGB", - "GL_EXT_geometry_shader4", - "GL_EXT_gpu_program_parameters", - "GL_EXT_gpu_shader4", - "GL_EXT_histogram", - "GL_EXT_index_array_formats", - "GL_EXT_index_func", - "GL_EXT_index_material", - "GL_EXT_index_texture", - "GL_EXT_light_texture", - "GL_EXT_misc_attribute", - "GL_EXT_multi_draw_arrays", - "GL_EXT_multisample", - "GL_EXT_packed_depth_stencil", - "GL_EXT_packed_float", - "GL_EXT_packed_pixels", - "GL_EXT_paletted_texture", - "GL_EXT_pixel_buffer_object", - "GL_EXT_pixel_transform", - "GL_EXT_pixel_transform_color_table", - "GL_EXT_point_parameters", - "GL_EXT_polygon_offset", - "GL_EXT_provoking_vertex", - "GL_EXT_rescale_normal", - "GL_EXT_secondary_color", - "GL_EXT_separate_specular_color", - "GL_EXT_shadow_funcs", - "GL_EXT_shared_texture_palette", - "GL_EXT_stencil_clear_tag", - "GL_EXT_stencil_two_side", - "GL_EXT_stencil_wrap", - "GL_EXT_subtexture", - "GL_EXT_texture", - "GL_EXT_texture3D", - "GL_EXT_texture_array", - "GL_EXT_texture_buffer_object", - "GL_EXT_texture_compression_latc", - "GL_EXT_texture_compression_rgtc", - "GL_EXT_texture_compression_s3tc", - "GL_EXT_texture_cube_map", - "GL_EXT_texture_env_add", - "GL_EXT_texture_env_combine", - "GL_EXT_texture_env_dot3", - "GL_EXT_texture_filter_anisotropic", - "GL_EXT_texture_integer", - "GL_EXT_texture_lod_bias", - "GL_EXT_texture_mirror_clamp", - "GL_EXT_texture_object", - "GL_EXT_texture_perturb_normal", - "GL_EXT_texture_shared_exponent", - "GL_EXT_texture_snorm", - "GL_EXT_texture_sRGB", - "GL_EXT_texture_swizzle", - "GL_EXT_timer_query", - "GL_EXT_transform_feedback", - "GL_EXT_vertex_array", - "GL_EXT_vertex_array_bgra", - "GL_EXT_vertex_shader", - "GL_EXT_vertex_weighting", - "GL_FfdMaskSGIX", - "GL_GREMEDY_frame_terminator", - "GL_GREMEDY_string_marker", - "GL_HP_convolution_border_modes", - "GL_HP_image_transform", - "GL_HP_occlusion_test", - "GL_HP_texture_lighting", - "GL_IBM_cull_vertex", - "GL_IBM_multimode_draw_arrays", - "GL_IBM_rasterpos_clip", - "GL_IBM_texture_mirrored_repeat", - "GL_IBM_vertex_array_lists", - "GL_INGR_blend_func_separate", - "GL_INGR_color_clamp", - "GL_INGR_interlace_read", - "GL_INGR_palette_buffer", - "GL_INTEL_parallel_arrays", - "GL_INTEL_texture_scissor", - "GL_MESA_pack_invert", - "GL_MESA_resize_buffers", - "GL_MESA_window_pos", - "GL_MESAX_texture_stack", - "GL_MESA_ycbcr_texture", - "GL_NV_blend_square", - "GL_NV_conditional_render", - "GL_NV_copy_depth_to_color", - "GL_NV_depth_buffer_float", - "GL_NV_depth_clamp", - "GL_NV_evaluators", - "GL_NV_explicit_multisample", - "GL_NV_fence", - "GL_NV_float_buffer", - "GL_NV_fog_distance", - "GL_NV_fragment_program", - "GL_NV_fragment_program2", - "GL_NV_fragment_program4", - "GL_NV_fragment_program_option", - "GL_NV_framebuffer_multisample_coverage", - "GL_NV_geometry_program4", - "GL_NV_geometry_shader4", - "GL_NV_gpu_program4", - "GL_NV_half_float", - "GL_NV_light_max_exponent", - "GL_NV_multisample_filter_hint", - "GL_NV_occlusion_query", - "GL_NV_packed_depth_stencil", - "GL_NV_parameter_buffer_object", - "GL_NV_pixel_data_range", - "GL_NV_point_sprite", - "GL_NV_present_video", - "GL_NV_primitive_restart", - "GL_NV_register_combiners", - "GL_NV_register_combiners2", - "GL_NV_texgen_emboss", - "GL_NV_texgen_reflection", - "GL_NV_texture_compression_vtc", - "GL_NV_texture_env_combine4", - "GL_NV_texture_expand_normal", - "GL_NV_texture_rectangle", - "GL_NV_texture_shader", - "GL_NV_texture_shader2", - "GL_NV_texture_shader3", - "GL_NV_transform_feedback", - "GL_NV_transform_feedback2", - "GL_NV_vertex_array_range", - "GL_NV_vertex_array_range2", - "GL_NV_vertex_program", - "GL_NV_vertex_program1_1", - "GL_NV_vertex_program2", - "GL_NV_vertex_program2_option", - "GL_NV_vertex_program3", - "GL_NV_vertex_program4", - "GL_OES_read_format", - "GL_OML_interlace", - "GL_OML_resample", - "GL_OML_subsample", - "GL_PGI_misc_hints", - "GL_PGI_vertex_hints", - "GL_REND_screen_coordinates", - "GL_S3_s3tc", - "GL_SGI_color_matrix", - "GL_SGI_color_table", - "GL_SGI_depth_pass_instrument", - "GL_SGIS_detail_texture", - "GL_SGIS_fog_function", - "GL_SGIS_generate_mipmap", - "GL_SGIS_multisample", - "GL_SGIS_pixel_texture", - "GL_SGIS_point_line_texgen", - "GL_SGIS_point_parameters", - "GL_SGIS_sharpen_texture", - "GL_SGIS_texture4D", - "GL_SGIS_texture_border_clamp", - "GL_SGIS_texture_color_mask", - "GL_SGIS_texture_edge_clamp", - "GL_SGIS_texture_filter4", - "GL_SGIS_texture_lod", - "GL_SGIS_texture_select", - "GL_SGI_texture_color_table", - "GL_SGIX_async", - "GL_SGIX_async_histogram", - "GL_SGIX_async_pixel", - "GL_SGIX_blend_alpha_minmax", - "GL_SGIX_calligraphic_fragment", - "GL_SGIX_clipmap", - "GL_SGIX_convolution_accuracy", - "GL_SGIX_depth_pass_instrument", - "GL_SGIX_depth_texture", - "GL_SGIX_flush_raster", - "GL_SGIX_fog_offset", - "GL_SGIX_fog_scale", - "GL_SGIX_fragment_lighting", - "GL_SGIX_framezoom", - "GL_SGIX_igloo_interface", - "GL_SGIX_impact_pixel_texture", - "GL_SGIX_instruments", - "GL_SGIX_interlace", - "GL_SGIX_ir_instrument1", - "GL_SGIX_list_priority", - "GL_SGIX_pixel_texture", - "GL_SGIX_pixel_tiles", - "GL_SGIX_polynomial_ffd", - "GL_SGIX_reference_plane", - "GL_SGIX_resample", - "GL_SGIX_scalebias_hint", - "GL_SGIX_shadow", - "GL_SGIX_shadow_ambient", - "GL_SGIX_sprite", - "GL_SGIX_subsample", - "GL_SGIX_tag_sample_buffer", - "GL_SGIX_texture_add_env", - "GL_SGIX_texture_coordinate_clamp", - "GL_SGIX_texture_lod_bias", - "GL_SGIX_texture_multi_buffer", - "GL_SGIX_texture_scale_bias", - "GL_SGIX_texture_select", - "GL_SGIX_vertex_preclip", - "GL_SGIX_ycrcb", - "GL_SGIX_ycrcba", - "GL_SGIX_ycrcb_subsample", - "GL_SUN_convolution_border_modes", - "GL_SUN_global_alpha", - "GL_SUN_mesh_array", - "GL_SUN_slice_accum", - "GL_SUN_triangle_list", - "GL_SUN_vertex", - "GL_SUNX_constant_data", - "GL_WIN_phong_shading", - "GL_WIN_specular_fog" -}; - - -class COpenGLExtensionHandler -{ - public: - enum EOpenGLFeatures { - IRR_3DFX_multisample = 0, - IRR_3DFX_tbuffer, - IRR_3DFX_texture_compression_FXT1, - IRR_AMD_draw_buffers_blend, - IRR_AMD_performance_monitor, - IRR_AMD_texture_texture4, - IRR_AMD_vertex_shader_tesselator, - IRR_APPLE_aux_depth_stencil, - IRR_APPLE_client_storage, - IRR_APPLE_element_array, - IRR_APPLE_fence, - IRR_APPLE_float_pixels, - IRR_APPLE_flush_buffer_range, - IRR_APPLE_object_purgeable, - IRR_APPLE_row_bytes, - IRR_APPLE_specular_vector, - IRR_APPLE_texture_range, - IRR_APPLE_transform_hint, - IRR_APPLE_vertex_array_object, - IRR_APPLE_vertex_array_range, - IRR_APPLE_vertex_program_evaluators, - IRR_APPLE_ycbcr_422, - IRR_ARB_color_buffer_float, - IRR_ARB_compatibility, - IRR_ARB_copy_buffer, - IRR_ARB_depth_buffer_float, - IRR_ARB_depth_clamp, - IRR_ARB_depth_texture, - IRR_ARB_draw_buffers, - IRR_ARB_draw_buffers_blend, - IRR_ARB_draw_elements_base_vertex, - IRR_ARB_draw_instanced, - IRR_ARB_fragment_coord_conventions, - IRR_ARB_fragment_program, - IRR_ARB_fragment_program_shadow, - IRR_ARB_fragment_shader, - IRR_ARB_framebuffer_object, - IRR_ARB_framebuffer_sRGB, - IRR_ARB_geometry_shader4, - IRR_ARB_half_float_pixel, - IRR_ARB_half_float_vertex, - IRR_ARB_imaging, - IRR_ARB_instanced_arrays, - IRR_ARB_map_buffer_range, - IRR_ARB_matrix_palette, - IRR_ARB_multisample, - IRR_ARB_multitexture, - IRR_ARB_occlusion_query, - IRR_ARB_pixel_buffer_object, - IRR_ARB_point_parameters, - IRR_ARB_point_sprite, - IRR_ARB_provoking_vertex, - IRR_ARB_sample_shading, - IRR_ARB_seamless_cube_map, - IRR_ARB_shader_objects, - IRR_ARB_shader_texture_lod, - IRR_ARB_shading_language_100, - IRR_ARB_shadow, - IRR_ARB_shadow_ambient, - IRR_ARB_sync, - IRR_ARB_texture_border_clamp, - IRR_ARB_texture_buffer_object, - IRR_ARB_texture_compression, - IRR_ARB_texture_compression_rgtc, - IRR_ARB_texture_cube_map, - IRR_ARB_texture_cube_map_array, - IRR_ARB_texture_env_add, - IRR_ARB_texture_env_combine, - IRR_ARB_texture_env_crossbar, - IRR_ARB_texture_env_dot3, - IRR_ARB_texture_float, - IRR_ARB_texture_gather, - IRR_ARB_texture_mirrored_repeat, - IRR_ARB_texture_multisample, - IRR_ARB_texture_non_power_of_two, - IRR_ARB_texture_query_lod, - IRR_ARB_texture_rectangle, - IRR_ARB_texture_rg, - IRR_ARB_transpose_matrix, - IRR_ARB_uniform_buffer_object, - IRR_ARB_vertex_array_bgra, - IRR_ARB_vertex_array_object, - IRR_ARB_vertex_blend, - IRR_ARB_vertex_buffer_object, - IRR_ARB_vertex_program, - IRR_ARB_vertex_shader, - IRR_ARB_window_pos, - IRR_ATI_draw_buffers, - IRR_ATI_element_array, - IRR_ATI_envmap_bumpmap, - IRR_ATI_fragment_shader, - IRR_ATI_map_object_buffer, - IRR_ATI_meminfo, - IRR_ATI_pixel_format_float, - IRR_ATI_pn_triangles, - IRR_ATI_separate_stencil, - IRR_ATI_text_fragment_shader, - IRR_ATI_texture_env_combine3, - IRR_ATI_texture_float, - IRR_ATI_texture_mirror_once, - IRR_ATI_vertex_array_object, - IRR_ATI_vertex_attrib_array_object, - IRR_ATI_vertex_streams, - IRR_EXT_422_pixels, - IRR_EXT_abgr, - IRR_EXT_bgra, - IRR_EXT_bindable_uniform, - IRR_EXT_blend_color, - IRR_EXT_blend_equation_separate, - IRR_EXT_blend_func_separate, - IRR_EXT_blend_logic_op, - IRR_EXT_blend_minmax, - IRR_EXT_blend_subtract, - IRR_EXT_clip_volume_hint, - IRR_EXT_cmyka, - IRR_EXT_color_subtable, - IRR_EXT_compiled_vertex_array, - IRR_EXT_convolution, - IRR_EXT_coordinate_frame, - IRR_EXT_copy_texture, - IRR_EXT_cull_vertex, - IRR_EXT_depth_bounds_test, - IRR_EXT_direct_state_access, - IRR_EXT_draw_buffers2, - IRR_EXT_draw_instanced, - IRR_EXT_draw_range_elements, - IRR_EXT_fog_coord, - IRR_EXT_framebuffer_blit, - IRR_EXT_framebuffer_multisample, - IRR_EXT_framebuffer_object, - IRR_EXT_framebuffer_sRGB, - IRR_EXT_geometry_shader4, - IRR_EXT_gpu_program_parameters, - IRR_EXT_gpu_shader4, - IRR_EXT_histogram, - IRR_EXT_index_array_formats, - IRR_EXT_index_func, - IRR_EXT_index_material, - IRR_EXT_index_texture, - IRR_EXT_light_texture, - IRR_EXT_misc_attribute, - IRR_EXT_multi_draw_arrays, - IRR_EXT_multisample, - IRR_EXT_packed_depth_stencil, - IRR_EXT_packed_float, - IRR_EXT_packed_pixels, - IRR_EXT_paletted_texture, - IRR_EXT_pixel_buffer_object, - IRR_EXT_pixel_transform, - IRR_EXT_pixel_transform_color_table, - IRR_EXT_point_parameters, - IRR_EXT_polygon_offset, - IRR_EXT_provoking_vertex, - IRR_EXT_rescale_normal, - IRR_EXT_secondary_color, - IRR_EXT_separate_specular_color, - IRR_EXT_shadow_funcs, - IRR_EXT_shared_texture_palette, - IRR_EXT_stencil_clear_tag, - IRR_EXT_stencil_two_side, - IRR_EXT_stencil_wrap, - IRR_EXT_subtexture, - IRR_EXT_texture, - IRR_EXT_texture3D, - IRR_EXT_texture_array, - IRR_EXT_texture_buffer_object, - IRR_EXT_texture_compression_latc, - IRR_EXT_texture_compression_rgtc, - IRR_EXT_texture_compression_s3tc, - IRR_EXT_texture_cube_map, - IRR_EXT_texture_env_add, - IRR_EXT_texture_env_combine, - IRR_EXT_texture_env_dot3, - IRR_EXT_texture_filter_anisotropic, - IRR_EXT_texture_integer, - IRR_EXT_texture_lod_bias, - IRR_EXT_texture_mirror_clamp, - IRR_EXT_texture_object, - IRR_EXT_texture_perturb_normal, - IRR_EXT_texture_shared_exponent, - IRR_EXT_texture_snorm, - IRR_EXT_texture_sRGB, - IRR_EXT_texture_swizzle, - IRR_EXT_timer_query, - IRR_EXT_transform_feedback, - IRR_EXT_vertex_array, - IRR_EXT_vertex_array_bgra, - IRR_EXT_vertex_shader, - IRR_EXT_vertex_weighting, - IRR_FfdMaskSGIX, - IRR_GREMEDY_frame_terminator, - IRR_GREMEDY_string_marker, - IRR_HP_convolution_border_modes, - IRR_HP_image_transform, - IRR_HP_occlusion_test, - IRR_HP_texture_lighting, - IRR_IBM_cull_vertex, - IRR_IBM_multimode_draw_arrays, - IRR_IBM_rasterpos_clip, - IRR_IBM_texture_mirrored_repeat, - IRR_IBM_vertex_array_lists, - IRR_INGR_blend_func_separate, - IRR_INGR_color_clamp, - IRR_INGR_interlace_read, - IRR_INGR_palette_buffer, - IRR_INTEL_parallel_arrays, - IRR_INTEL_texture_scissor, - IRR_MESA_pack_invert, - IRR_MESA_resize_buffers, - IRR_MESA_window_pos, - IRR_MESAX_texture_stack, - IRR_MESA_ycbcr_texture, - IRR_NV_blend_square, - IRR_NV_conditional_render, - IRR_NV_copy_depth_to_color, - IRR_NV_depth_buffer_float, - IRR_NV_depth_clamp, - IRR_NV_evaluators, - IRR_NV_explicit_multisample, - IRR_NV_fence, - IRR_NV_float_buffer, - IRR_NV_fog_distance, - IRR_NV_fragment_program, - IRR_NV_fragment_program2, - IRR_NV_fragment_program4, - IRR_NV_fragment_program_option, - IRR_NV_framebuffer_multisample_coverage, - IRR_NV_geometry_program4, - IRR_NV_geometry_shader4, - IRR_NV_gpu_program4, - IRR_NV_half_float, - IRR_NV_light_max_exponent, - IRR_NV_multisample_filter_hint, - IRR_NV_occlusion_query, - IRR_NV_packed_depth_stencil, - IRR_NV_parameter_buffer_object, - IRR_NV_pixel_data_range, - IRR_NV_point_sprite, - IRR_NV_present_video, - IRR_NV_primitive_restart, - IRR_NV_register_combiners, - IRR_NV_register_combiners2, - IRR_NV_texgen_emboss, - IRR_NV_texgen_reflection, - IRR_NV_texture_compression_vtc, - IRR_NV_texture_env_combine4, - IRR_NV_texture_expand_normal, - IRR_NV_texture_rectangle, - IRR_NV_texture_shader, - IRR_NV_texture_shader2, - IRR_NV_texture_shader3, - IRR_NV_transform_feedback, - IRR_NV_transform_feedback2, - IRR_NV_vertex_array_range, - IRR_NV_vertex_array_range2, - IRR_NV_vertex_program, - IRR_NV_vertex_program1_1, - IRR_NV_vertex_program2, - IRR_NV_vertex_program2_option, - IRR_NV_vertex_program3, - IRR_NV_vertex_program4, - IRR_OES_read_format, - IRR_OML_interlace, - IRR_OML_resample, - IRR_OML_subsample, - IRR_PGI_misc_hints, - IRR_PGI_vertex_hints, - IRR_REND_screen_coordinates, - IRR_S3_s3tc, - IRR_SGI_color_matrix, - IRR_SGI_color_table, - IRR_SGI_depth_pass_instrument, - IRR_SGIS_detail_texture, - IRR_SGIS_fog_function, - IRR_SGIS_generate_mipmap, - IRR_SGIS_multisample, - IRR_SGIS_pixel_texture, - IRR_SGIS_point_line_texgen, - IRR_SGIS_point_parameters, - IRR_SGIS_sharpen_texture, - IRR_SGIS_texture4D, - IRR_SGIS_texture_border_clamp, - IRR_SGIS_texture_color_mask, - IRR_SGIS_texture_edge_clamp, - IRR_SGIS_texture_filter4, - IRR_SGIS_texture_lod, - IRR_SGIS_texture_select, - IRR_SGI_texture_color_table, - IRR_SGIX_async, - IRR_SGIX_async_histogram, - IRR_SGIX_async_pixel, - IRR_SGIX_blend_alpha_minmax, - IRR_SGIX_calligraphic_fragment, - IRR_SGIX_clipmap, - IRR_SGIX_convolution_accuracy, - IRR_SGIX_depth_pass_instrument, - IRR_SGIX_depth_texture, - IRR_SGIX_flush_raster, - IRR_SGIX_fog_offset, - IRR_SGIX_fog_scale, - IRR_SGIX_fragment_lighting, - IRR_SGIX_framezoom, - IRR_SGIX_igloo_interface, - IRR_SGIX_impact_pixel_texture, - IRR_SGIX_instruments, - IRR_SGIX_interlace, - IRR_SGIX_ir_instrument1, - IRR_SGIX_list_priority, - IRR_SGIX_pixel_texture, - IRR_SGIX_pixel_tiles, - IRR_SGIX_polynomial_ffd, - IRR_SGIX_reference_plane, - IRR_SGIX_resample, - IRR_SGIX_scalebias_hint, - IRR_SGIX_shadow, - IRR_SGIX_shadow_ambient, - IRR_SGIX_sprite, - IRR_SGIX_subsample, - IRR_SGIX_tag_sample_buffer, - IRR_SGIX_texture_add_env, - IRR_SGIX_texture_coordinate_clamp, - IRR_SGIX_texture_lod_bias, - IRR_SGIX_texture_multi_buffer, - IRR_SGIX_texture_scale_bias, - IRR_SGIX_texture_select, - IRR_SGIX_vertex_preclip, - IRR_SGIX_ycrcb, - IRR_SGIX_ycrcba, - IRR_SGIX_ycrcb_subsample, - IRR_SUN_convolution_border_modes, - IRR_SUN_global_alpha, - IRR_SUN_mesh_array, - IRR_SUN_slice_accum, - IRR_SUN_triangle_list, - IRR_SUN_vertex, - IRR_SUNX_constant_data, - IRR_WIN_phong_shading, - IRR_WIN_specular_fog, - IRR_OpenGL_Feature_Count - }; - - - // constructor - COpenGLExtensionHandler(); - - // deferred initialization - void initExtensions(bool stencilBuffer); - - //! queries the features of the driver, returns true if feature is available - bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const; - - //! queries the features of the driver, returns true if feature is available - bool queryOpenGLFeature(EOpenGLFeatures feature) const - { - return FeatureAvailable[feature]; - } - - //! show all features with availablity - void dump() const; - - // Some variables for properties - bool StencilBuffer; - bool MultiTextureExtension; - bool TextureCompressionExtension; - - // Some non-boolean properties - //! Maxmimum texture layers supported by the fixed pipeline - u8 MaxTextureUnits; - //! Maximum hardware lights supported - u8 MaxLights; - //! Maximal Anisotropy - u8 MaxAnisotropy; - //! Number of user clipplanes - u8 MaxUserClipPlanes; - //! Number of auxiliary buffers - u8 MaxAuxBuffers; - //! Optimal number of indices per meshbuffer - u32 MaxIndices; - //! Maximal texture dimension - u32 MaxTextureSize; - //! Maximal LOD Bias - f32 MaxTextureLODBias; - //! Number of rendertargets available as MRTs - u8 MaxMultipleRenderTargets; - //! Minimal and maximal supported thickness for lines without smoothing - GLfloat DimAliasedLine[2]; - //! Minimal and maximal supported thickness for points without smoothing - GLfloat DimAliasedPoint[2]; - //! Minimal and maximal supported thickness for lines with smoothing - GLfloat DimSmoothedLine[2]; - //! Minimal and maximal supported thickness for points with smoothing - GLfloat DimSmoothedPoint[2]; - - //! OpenGL version as Integer: 100*Major+Minor, i.e. 2.1 becomes 201 - u16 Version; - //! GLSL version as Integer: 100*Major+Minor - u16 ShaderLanguageVersion; - - // public access to the (loaded) extensions. - // general functions - void extGlActiveTexture(GLenum texture); - void extGlClientActiveTexture(GLenum texture); - void extGlPointParameterf(GLint loc, GLfloat f); - void extGlPointParameterfv(GLint loc, const GLfloat *v); - void extGlStencilFuncSeparate (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); - void extGlStencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass); - void extGlCompressedTexImage2D(GLenum target, GLint level, - GLenum internalformat, GLsizei width, GLsizei height, - GLint border, GLsizei imageSize, const void* data); - - // shader programming - void extGlGenPrograms(GLsizei n, GLuint *programs); - void extGlBindProgram(GLenum target, GLuint program); - void extGlProgramString(GLenum target, GLenum format, GLsizei len, const GLvoid *string); - void extGlDeletePrograms(GLsizei n, const GLuint *programs); - void extGlProgramLocalParameter4fv(GLenum, GLuint, const GLfloat *); - GLhandleARB extGlCreateShaderObject(GLenum shaderType); - void extGlShaderSource(GLhandleARB shader, int numOfStrings, const char **strings, int *lenOfStrings); - void extGlCompileShader(GLhandleARB shader); - GLhandleARB extGlCreateProgramObject(void); - void extGlAttachObject(GLhandleARB program, GLhandleARB shader); - void extGlLinkProgram(GLhandleARB program); - void extGlUseProgramObject(GLhandleARB prog); - void extGlDeleteObject(GLhandleARB object); - void extGlGetInfoLog(GLhandleARB object, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); - void extGlGetObjectParameteriv(GLhandleARB object, GLenum type, int *param); - GLint extGlGetUniformLocation(GLhandleARB program, const char *name); - void extGlUniform4fv(GLint location, GLsizei count, const GLfloat *v); - void extGlUniform1iv(GLint loc, GLsizei count, const GLint *v); - void extGlUniform1fv(GLint loc, GLsizei count, const GLfloat *v); - void extGlUniform2fv(GLint loc, GLsizei count, const GLfloat *v); - void extGlUniform3fv(GLint loc, GLsizei count, const GLfloat *v); - void extGlUniformMatrix2fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v); - void extGlUniformMatrix3fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v); - void extGlUniformMatrix4fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v); - void extGlGetActiveUniform(GLhandleARB program, GLuint index, GLsizei maxlength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); - - // framebuffer objects - void extGlBindFramebuffer(GLenum target, GLuint framebuffer); - void extGlDeleteFramebuffers(GLsizei n, const GLuint *framebuffers); - void extGlGenFramebuffers(GLsizei n, GLuint *framebuffers); - GLenum extGlCheckFramebufferStatus(GLenum target); - void extGlFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); - void extGlBindRenderbuffer(GLenum target, GLuint renderbuffer); - void extGlDeleteRenderbuffers(GLsizei n, const GLuint *renderbuffers); - void extGlGenRenderbuffers(GLsizei n, GLuint *renderbuffers); - void extGlRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); - void extGlFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); - void extGlActiveStencilFace(GLenum face); - void extGlDrawBuffers(GLsizei n, const GLenum *bufs); - - // vertex buffer object - void extGlGenBuffers(GLsizei n, GLuint *buffers); - void extGlBindBuffer(GLenum target, GLuint buffer); - void extGlBufferData(GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); - void extGlDeleteBuffers(GLsizei n, const GLuint *buffers); - void extGlBufferSubData (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); - void extGlGetBufferSubData (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); - void *extGlMapBuffer (GLenum target, GLenum access); - GLboolean extGlUnmapBuffer (GLenum target); - GLboolean extGlIsBuffer (GLuint buffer); - void extGlGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); - void extGlGetBufferPointerv (GLenum target, GLenum pname, GLvoid **params); - void extGlProvokingVertex(GLenum mode); - - - protected: - // the global feature array - bool FeatureAvailable[IRR_OpenGL_Feature_Count]; - - #if defined(_IRR_OPENGL_USE_EXTPOINTER_) - PFNGLACTIVETEXTUREARBPROC pGlActiveTextureARB; - PFNGLCLIENTACTIVETEXTUREARBPROC pGlClientActiveTextureARB; - PFNGLGENPROGRAMSARBPROC pGlGenProgramsARB; - PFNGLBINDPROGRAMARBPROC pGlBindProgramARB; - PFNGLPROGRAMSTRINGARBPROC pGlProgramStringARB; - PFNGLDELETEPROGRAMSNVPROC pGlDeleteProgramsARB; - PFNGLPROGRAMLOCALPARAMETER4FVARBPROC pGlProgramLocalParameter4fvARB; - PFNGLCREATESHADEROBJECTARBPROC pGlCreateShaderObjectARB; - PFNGLSHADERSOURCEARBPROC pGlShaderSourceARB; - PFNGLCOMPILESHADERARBPROC pGlCompileShaderARB; - PFNGLCREATEPROGRAMOBJECTARBPROC pGlCreateProgramObjectARB; - PFNGLATTACHOBJECTARBPROC pGlAttachObjectARB; - PFNGLLINKPROGRAMARBPROC pGlLinkProgramARB; - PFNGLUSEPROGRAMOBJECTARBPROC pGlUseProgramObjectARB; - PFNGLDELETEOBJECTARBPROC pGlDeleteObjectARB; - PFNGLGETINFOLOGARBPROC pGlGetInfoLogARB; - PFNGLGETOBJECTPARAMETERIVARBPROC pGlGetObjectParameterivARB; - PFNGLGETUNIFORMLOCATIONARBPROC pGlGetUniformLocationARB; - PFNGLUNIFORM1IVARBPROC pGlUniform1ivARB; - PFNGLUNIFORM1FVARBPROC pGlUniform1fvARB; - PFNGLUNIFORM2FVARBPROC pGlUniform2fvARB; - PFNGLUNIFORM3FVARBPROC pGlUniform3fvARB; - PFNGLUNIFORM4FVARBPROC pGlUniform4fvARB; - PFNGLUNIFORMMATRIX2FVARBPROC pGlUniformMatrix2fvARB; - PFNGLUNIFORMMATRIX3FVARBPROC pGlUniformMatrix3fvARB; - PFNGLUNIFORMMATRIX4FVARBPROC pGlUniformMatrix4fvARB; - PFNGLGETACTIVEUNIFORMARBPROC pGlGetActiveUniformARB; - PFNGLPOINTPARAMETERFARBPROC pGlPointParameterfARB; - PFNGLPOINTPARAMETERFVARBPROC pGlPointParameterfvARB; - PFNGLSTENCILFUNCSEPARATEPROC pGlStencilFuncSeparate; - PFNGLSTENCILOPSEPARATEPROC pGlStencilOpSeparate; - PFNGLSTENCILFUNCSEPARATEATIPROC pGlStencilFuncSeparateATI; - PFNGLSTENCILOPSEPARATEATIPROC pGlStencilOpSeparateATI; - PFNGLCOMPRESSEDTEXIMAGE2DPROC pGlCompressedTexImage2D; - #if defined(_IRR_LINUX_PLATFORM_) && defined(GLX_SGI_swap_control) - PFNGLXSWAPINTERVALSGIPROC glxSwapIntervalSGI; - #endif - PFNGLBINDFRAMEBUFFEREXTPROC pGlBindFramebufferEXT; - PFNGLDELETEFRAMEBUFFERSEXTPROC pGlDeleteFramebuffersEXT; - PFNGLGENFRAMEBUFFERSEXTPROC pGlGenFramebuffersEXT; - PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC pGlCheckFramebufferStatusEXT; - PFNGLFRAMEBUFFERTEXTURE2DEXTPROC pGlFramebufferTexture2DEXT; - PFNGLBINDRENDERBUFFEREXTPROC pGlBindRenderbufferEXT; - PFNGLDELETERENDERBUFFERSEXTPROC pGlDeleteRenderbuffersEXT; - PFNGLGENRENDERBUFFERSEXTPROC pGlGenRenderbuffersEXT; - PFNGLRENDERBUFFERSTORAGEEXTPROC pGlRenderbufferStorageEXT; - PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC pGlFramebufferRenderbufferEXT; - PFNGLACTIVESTENCILFACEEXTPROC pGlActiveStencilFaceEXT; - PFNGLDRAWBUFFERSARBPROC pGlDrawBuffersARB; - PFNGLDRAWBUFFERSATIPROC pGlDrawBuffersATI; - PFNGLGENBUFFERSARBPROC pGlGenBuffersARB; - PFNGLBINDBUFFERARBPROC pGlBindBufferARB; - PFNGLBUFFERDATAARBPROC pGlBufferDataARB; - PFNGLDELETEBUFFERSARBPROC pGlDeleteBuffersARB; - PFNGLBUFFERSUBDATAARBPROC pGlBufferSubDataARB; - PFNGLGETBUFFERSUBDATAARBPROC pGlGetBufferSubDataARB; - PFNGLMAPBUFFERARBPROC pGlMapBufferARB; - PFNGLUNMAPBUFFERARBPROC pGlUnmapBufferARB; - PFNGLISBUFFERARBPROC pGlIsBufferARB; - PFNGLGETBUFFERPARAMETERIVARBPROC pGlGetBufferParameterivARB; - PFNGLGETBUFFERPOINTERVARBPROC pGlGetBufferPointervARB; - PFNGLPROVOKINGVERTEXPROC pGlProvokingVertexARB; - PFNGLPROVOKINGVERTEXEXTPROC pGlProvokingVertexEXT; - #endif -}; - -inline void COpenGLExtensionHandler::extGlActiveTexture(GLenum texture) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (MultiTextureExtension && pGlActiveTextureARB) - pGlActiveTextureARB(texture); -#else - if (MultiTextureExtension) -#ifdef GL_ARB_multitexture - glActiveTextureARB(texture); -#else - glActiveTexture(texture); -#endif -#endif -} - -inline void COpenGLExtensionHandler::extGlClientActiveTexture(GLenum texture) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (MultiTextureExtension && pGlClientActiveTextureARB) - pGlClientActiveTextureARB(texture); -#else - if (MultiTextureExtension) - glClientActiveTextureARB(texture); -#endif -} - -inline void COpenGLExtensionHandler::extGlGenPrograms(GLsizei n, GLuint *programs) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlGenProgramsARB) - pGlGenProgramsARB(n, programs); -#elif defined(GL_ARB_vertex_program) - glGenProgramsARB(n,programs); -#else - os::Printer::log("glGenPrograms not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlBindProgram(GLenum target, GLuint program) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlBindProgramARB) - pGlBindProgramARB(target, program); -#elif defined(GL_ARB_vertex_program) - glBindProgramARB(target, program); -#else - os::Printer::log("glBindProgram not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlProgramString(GLenum target, GLenum format, GLsizei len, const GLvoid *string) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlProgramStringARB) - pGlProgramStringARB(target, format, len, string); -#elif defined(GL_ARB_vertex_program) - glProgramStringARB(target,format,len,string); -#else - os::Printer::log("glProgramString not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlDeletePrograms(GLsizei n, const GLuint *programs) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlDeleteProgramsARB) - pGlDeleteProgramsARB(n, programs); -#elif defined(GL_ARB_vertex_program) - glDeleteProgramsARB(n,programs); -#else - os::Printer::log("glDeletePrograms not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlProgramLocalParameter4fv(GLenum n, GLuint i, const GLfloat * f) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlProgramLocalParameter4fvARB) - pGlProgramLocalParameter4fvARB(n,i,f); -#elif defined(GL_ARB_vertex_program) - glProgramLocalParameter4fvARB(n,i,f); -#else - os::Printer::log("glProgramLocalParameter4fv not supported", ELL_ERROR); -#endif -} - -inline GLhandleARB COpenGLExtensionHandler::extGlCreateShaderObject(GLenum shaderType) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlCreateShaderObjectARB) - return pGlCreateShaderObjectARB(shaderType); -#elif defined(GL_ARB_shader_objects) - return glCreateShaderObjectARB(shaderType); -#else - os::Printer::log("glCreateShaderObject not supported", ELL_ERROR); -#endif - return 0; -} - -inline void COpenGLExtensionHandler::extGlShaderSource(GLhandleARB shader, int numOfStrings, const char **strings, int *lenOfStrings) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlShaderSourceARB) - pGlShaderSourceARB(shader, numOfStrings, strings, lenOfStrings); -#elif defined(GL_ARB_shader_objects) - glShaderSourceARB(shader, numOfStrings, strings, (GLint *)lenOfStrings); -#else - os::Printer::log("glShaderSource not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlCompileShader(GLhandleARB shader) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlCompileShaderARB) - pGlCompileShaderARB(shader); -#elif defined(GL_ARB_shader_objects) - glCompileShaderARB(shader); -#else - os::Printer::log("glCompileShader not supported", ELL_ERROR); -#endif -} - -inline GLhandleARB COpenGLExtensionHandler::extGlCreateProgramObject(void) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlCreateProgramObjectARB) - return pGlCreateProgramObjectARB(); -#elif defined(GL_ARB_shader_objects) - return glCreateProgramObjectARB(); -#else - os::Printer::log("glCreateProgramObject not supported", ELL_ERROR); -#endif - return 0; -} - -inline void COpenGLExtensionHandler::extGlAttachObject(GLhandleARB program, GLhandleARB shader) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlAttachObjectARB) - pGlAttachObjectARB(program, shader); -#elif defined(GL_ARB_shader_objects) - glAttachObjectARB(program, shader); -#else - os::Printer::log("glAttachObject not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlLinkProgram(GLhandleARB program) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlLinkProgramARB) - pGlLinkProgramARB(program); -#elif defined(GL_ARB_shader_objects) - glLinkProgramARB(program); -#else - os::Printer::log("glLinkProgram not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlUseProgramObject(GLhandleARB prog) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlUseProgramObjectARB) - pGlUseProgramObjectARB(prog); -#elif defined(GL_ARB_shader_objects) - glUseProgramObjectARB(prog); -#else - os::Printer::log("glUseProgramObject not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlDeleteObject(GLhandleARB object) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlDeleteObjectARB) - pGlDeleteObjectARB(object); -#elif defined(GL_ARB_shader_objects) - glDeleteObjectARB(object); -#else - os::Printer::log("gldeleteObject not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlGetInfoLog(GLhandleARB object, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlGetInfoLogARB) - pGlGetInfoLogARB(object, maxLength, length, infoLog); -#elif defined(GL_ARB_shader_objects) - glGetInfoLogARB(object, maxLength, length, infoLog); -#else - os::Printer::log("glGetInfoLog not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlGetObjectParameteriv(GLhandleARB object, GLenum type, int *param) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlGetObjectParameterivARB) - pGlGetObjectParameterivARB(object, type, param); -#elif defined(GL_ARB_shader_objects) - glGetObjectParameterivARB(object, type, (GLint *)param); -#else - os::Printer::log("glGetObjectParameteriv not supported", ELL_ERROR); -#endif -} - -inline GLint COpenGLExtensionHandler::extGlGetUniformLocation(GLhandleARB program, const char *name) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlGetUniformLocationARB) - return pGlGetUniformLocationARB(program, name); -#elif defined(GL_ARB_shader_objects) - return glGetUniformLocationARB(program, name); -#else - os::Printer::log("glGetUniformLocation not supported", ELL_ERROR); -#endif - return 0; -} - -inline void COpenGLExtensionHandler::extGlUniform4fv(GLint location, GLsizei count, const GLfloat *v) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlUniform4fvARB) - pGlUniform4fvARB(location, count, v); -#elif defined(GL_ARB_shader_objects) - glUniform4fvARB(location, count, v); -#else - os::Printer::log("glUniform4fv not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlUniform1iv(GLint loc, GLsizei count, const GLint *v) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlUniform1ivARB) - pGlUniform1ivARB(loc, count, v); -#elif defined(GL_ARB_shader_objects) - glUniform1ivARB(loc, count, v); -#else - os::Printer::log("glUniform1iv not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlUniform1fv(GLint loc, GLsizei count, const GLfloat *v) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlUniform1fvARB) - pGlUniform1fvARB(loc, count, v); -#elif defined(GL_ARB_shader_objects) - glUniform1fvARB(loc, count, v); -#else - os::Printer::log("glUniform1fv not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlUniform2fv(GLint loc, GLsizei count, const GLfloat *v) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlUniform2fvARB) - pGlUniform2fvARB(loc, count, v); -#elif defined(GL_ARB_shader_objects) - glUniform2fvARB(loc, count, v); -#else - os::Printer::log("glUniform2fv not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlUniform3fv(GLint loc, GLsizei count, const GLfloat *v) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlUniform3fvARB) - pGlUniform3fvARB(loc, count, v); -#elif defined(GL_ARB_shader_objects) - glUniform3fvARB(loc, count, v); -#else - os::Printer::log("glUniform3fv not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlUniformMatrix2fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlUniformMatrix2fvARB) - pGlUniformMatrix2fvARB(loc, count, transpose, v); -#elif defined(GL_ARB_shader_objects) - glUniformMatrix2fvARB(loc, count, transpose, v); -#else - os::Printer::log("glUniformMatrix2fv not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlUniformMatrix3fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlUniformMatrix3fvARB) - pGlUniformMatrix3fvARB(loc, count, transpose, v); -#elif defined(GL_ARB_shader_objects) - glUniformMatrix3fvARB(loc, count, transpose, v); -#else - os::Printer::log("glUniformMatrix3fv not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlUniformMatrix4fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlUniformMatrix4fvARB) - pGlUniformMatrix4fvARB(loc, count, transpose, v); -#elif defined(GL_ARB_shader_objects) - glUniformMatrix4fvARB(loc, count, transpose, v); -#else - os::Printer::log("glUniformMatrix4fv not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlGetActiveUniform(GLhandleARB program, - GLuint index, GLsizei maxlength, GLsizei *length, - GLint *size, GLenum *type, GLcharARB *name) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlGetActiveUniformARB) - pGlGetActiveUniformARB(program, index, maxlength, length, size, type, name); -#elif defined(GL_ARB_shader_objects) - glGetActiveUniformARB(program, index, maxlength, length, size, type, name); -#else - os::Printer::log("glGetActiveUniform not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlPointParameterf(GLint loc, GLfloat f) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlPointParameterfARB) - pGlPointParameterfARB(loc, f); -#elif defined(GL_ARB_point_parameters) - glPointParameterfARB(loc, f); -#else - os::Printer::log("glPointParameterf not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlPointParameterfv(GLint loc, const GLfloat *v) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlPointParameterfvARB) - pGlPointParameterfvARB(loc, v); -#elif defined(GL_ARB_point_parameters) - glPointParameterfvARB(loc, v); -#else - os::Printer::log("glPointParameterfv not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlStencilFuncSeparate (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlStencilFuncSeparate) - pGlStencilFuncSeparate(frontfunc, backfunc, ref, mask); - else if (pGlStencilFuncSeparateATI) - pGlStencilFuncSeparateATI(frontfunc, backfunc, ref, mask); -#elif defined(GL_VERSION_2_0) - glStencilFuncSeparate(frontfunc, backfunc, ref, mask); -#elif defined(GL_ATI_separate_stencil) - glStencilFuncSeparateATI(frontfunc, backfunc, ref, mask); -#else - os::Printer::log("glStencilFuncSeparate not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlStencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlStencilOpSeparate) - pGlStencilOpSeparate(face, fail, zfail, zpass); - else if (pGlStencilOpSeparateATI) - pGlStencilOpSeparateATI(face, fail, zfail, zpass); -#elif defined(GL_VERSION_2_0) - glStencilOpSeparate(face, fail, zfail, zpass); -#elif defined(GL_ATI_separate_stencil) - glStencilOpSeparateATI(face, fail, zfail, zpass); -#else - os::Printer::log("glStencilOpSeparate not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, - GLsizei height, GLint border, GLsizei imageSize, const void* data) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlCompressedTexImage2D) - pGlCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data); -#elif defined(GL_ARB_texture_compression) - glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data); -#else - os::Printer::log("glCompressedTexImage2D not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlBindFramebuffer(GLenum target, GLuint framebuffer) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlBindFramebufferEXT) - pGlBindFramebufferEXT(target, framebuffer); -#elif defined(GL_EXT_framebuffer_object) - glBindFramebufferEXT(target, framebuffer); -#else - os::Printer::log("glBindFramebuffer not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlDeleteFramebuffers(GLsizei n, const GLuint *framebuffers) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlDeleteFramebuffersEXT) - pGlDeleteFramebuffersEXT(n, framebuffers); -#elif defined(GL_EXT_framebuffer_object) - glDeleteFramebuffersEXT(n, framebuffers); -#else - os::Printer::log("glDeleteFramebuffers not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlGenFramebuffers(GLsizei n, GLuint *framebuffers) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlGenFramebuffersEXT) - pGlGenFramebuffersEXT(n, framebuffers); -#elif defined(GL_EXT_framebuffer_object) - glGenFramebuffersEXT(n, framebuffers); -#else - os::Printer::log("glGenFramebuffers not supported", ELL_ERROR); -#endif -} - -inline GLenum COpenGLExtensionHandler::extGlCheckFramebufferStatus(GLenum target) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlCheckFramebufferStatusEXT) - return pGlCheckFramebufferStatusEXT(target); - else - return 0; -#elif defined(GL_EXT_framebuffer_object) - return glCheckFramebufferStatusEXT(target); -#else - os::Printer::log("glCheckFramebufferStatus not supported", ELL_ERROR); - return 0; -#endif -} - -inline void COpenGLExtensionHandler::extGlFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlFramebufferTexture2DEXT) - pGlFramebufferTexture2DEXT(target, attachment, textarget, texture, level); -#elif defined(GL_EXT_framebuffer_object) - glFramebufferTexture2DEXT(target, attachment, textarget, texture, level); -#else - os::Printer::log("glFramebufferTexture2D not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlBindRenderbuffer(GLenum target, GLuint renderbuffer) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlBindRenderbufferEXT) - pGlBindRenderbufferEXT(target, renderbuffer); -#elif defined(GL_EXT_framebuffer_object) - glBindRenderbufferEXT(target, renderbuffer); -#else - os::Printer::log("glBindRenderbuffer not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlDeleteRenderbuffers(GLsizei n, const GLuint *renderbuffers) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlDeleteRenderbuffersEXT) - pGlDeleteRenderbuffersEXT(n, renderbuffers); -#elif defined(GL_EXT_framebuffer_object) - glDeleteRenderbuffersEXT(n, renderbuffers); -#else - os::Printer::log("glDeleteRenderbuffers not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlGenRenderbuffers(GLsizei n, GLuint *renderbuffers) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlGenRenderbuffersEXT) - pGlGenRenderbuffersEXT(n, renderbuffers); -#elif defined(GL_EXT_framebuffer_object) - glGenRenderbuffersEXT(n, renderbuffers); -#else - os::Printer::log("glGenRenderbuffers not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlRenderbufferStorageEXT) - pGlRenderbufferStorageEXT(target, internalformat, width, height); -#elif defined(GL_EXT_framebuffer_object) - glRenderbufferStorageEXT(target, internalformat, width, height); -#else - os::Printer::log("glRenderbufferStorage not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlFramebufferRenderbufferEXT) - pGlFramebufferRenderbufferEXT(target, attachment, renderbuffertarget, renderbuffer); -#elif defined(GL_EXT_framebuffer_object) - glFramebufferRenderbufferEXT(target, attachment, renderbuffertarget, renderbuffer); -#else - os::Printer::log("glFramebufferRenderbuffer not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlActiveStencilFace(GLenum face) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlActiveStencilFaceEXT) - pGlActiveStencilFaceEXT(face); -#elif defined(GL_EXT_stencil_two_side) - glActiveStencilFaceEXT(face); -#else - os::Printer::log("glActiveStencilFace not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlDrawBuffers(GLsizei n, const GLenum *bufs) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlDrawBuffersARB) - pGlDrawBuffersARB(n, bufs); - else if (pGlDrawBuffersATI) - pGlDrawBuffersATI(n, bufs); -#elif defined(GL_ARB_draw_buffers) - glDrawBuffersARB(n, bufs); -#elif defined(GL_ATI_draw_buffers) - glDrawBuffersATI(n, bufs); -#else - os::Printer::log("glDrawBuffers not supported", ELL_ERROR); -#endif -} - - -inline void COpenGLExtensionHandler::extGlGenBuffers(GLsizei n, GLuint *buffers) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlGenBuffersARB) - pGlGenBuffersARB(n, buffers); -#elif defined(GL_ARB_vertex_buffer_object) - glGenBuffers(n, buffers); -#else - os::Printer::log("glGenBuffers not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlBindBuffer(GLenum target, GLuint buffer) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlBindBufferARB) - pGlBindBufferARB(target, buffer); -#elif defined(GL_ARB_vertex_buffer_object) - glBindBuffer(target, buffer); -#else - os::Printer::log("glBindBuffer not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlBufferData(GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlBufferDataARB) - pGlBufferDataARB(target, size, data, usage); -#elif defined(GL_ARB_vertex_buffer_object) - glBufferData(target, size, data, usage); -#else - os::Printer::log("glBufferData not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlDeleteBuffers(GLsizei n, const GLuint *buffers) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlDeleteBuffersARB) - pGlDeleteBuffersARB(n, buffers); -#elif defined(GL_ARB_vertex_buffer_object) - glDeleteBuffers(n, buffers); -#else - os::Printer::log("glDeleteBuffers not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlBufferSubData(GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlBufferSubDataARB) - pGlBufferSubDataARB(target, offset, size, data); -#elif defined(GL_ARB_vertex_buffer_object) - glBufferSubData(target, offset, size, data); -#else - os::Printer::log("glBufferSubData not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlGetBufferSubData(GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlGetBufferSubDataARB) - pGlGetBufferSubDataARB(target, offset, size, data); -#elif defined(GL_ARB_vertex_buffer_object) - glGetBufferSubData(target, offset, size, data); -#else - os::Printer::log("glGetBufferSubData not supported", ELL_ERROR); -#endif -} - -inline void *COpenGLExtensionHandler::extGlMapBuffer(GLenum target, GLenum access) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlMapBufferARB) - return pGlMapBufferARB(target, access); - return 0; -#elif defined(GL_ARB_vertex_buffer_object) - return glMapBuffer(target, access); -#else - os::Printer::log("glMapBuffer not supported", ELL_ERROR); - return 0; -#endif -} - -inline GLboolean COpenGLExtensionHandler::extGlUnmapBuffer (GLenum target) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlUnmapBufferARB) - return pGlUnmapBufferARB(target); - return false; -#elif defined(GL_ARB_vertex_buffer_object) - return glUnmapBuffer(target); -#else - os::Printer::log("glUnmapBuffer not supported", ELL_ERROR); - return false; -#endif -} - -inline GLboolean COpenGLExtensionHandler::extGlIsBuffer (GLuint buffer) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlIsBufferARB) - return pGlIsBufferARB(buffer); - return false; -#elif defined(GL_ARB_vertex_buffer_object) - return glIsBuffer(buffer); -#else - os::Printer::log("glDeleteBuffers not supported", ELL_ERROR); - return false; -#endif -} - -inline void COpenGLExtensionHandler::extGlGetBufferParameteriv (GLenum target, GLenum pname, GLint *params) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlGetBufferParameterivARB) - pGlGetBufferParameterivARB(target, pname, params); -#elif defined(GL_ARB_vertex_buffer_object) - glGetBufferParameteriv(target, pname, params); -#else - os::Printer::log("glGetBufferParameteriv not supported", ELL_ERROR); -#endif -} - -inline void COpenGLExtensionHandler::extGlGetBufferPointerv (GLenum target, GLenum pname, GLvoid **params) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlGetBufferPointervARB) - pGlGetBufferPointervARB(target, pname, params); -#elif defined(GL_ARB_vertex_buffer_object) - glGetBufferPointerv(target, pname, params); -#else - os::Printer::log("glGetBufferPointerv not supported", ELL_ERROR); -#endif -} - - -inline void COpenGLExtensionHandler::extGlProvokingVertex(GLenum mode) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (FeatureAvailable[IRR_ARB_provoking_vertex] && pGlProvokingVertexARB) - pGlProvokingVertexARB(mode); - else if (FeatureAvailable[IRR_EXT_provoking_vertex] && pGlProvokingVertexEXT) - pGlProvokingVertexEXT(mode); -#elif defined(GL_ARB_provoking_vertex) - glProvokingVertex(mode); -#elif defined(GL_EXT_provoking_vertex) - glProvokingVertexEXT(mode); -#else - os::Printer::log("glProvokingVertex not supported", ELL_ERROR); -#endif -} - - -} -} - -#endif - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/COpenGLMaterialRenderer.h b/irrlicht-1.6/source/Irrlicht/COpenGLMaterialRenderer.h deleted file mode 100644 index 5851d8257..000000000 --- a/irrlicht-1.6/source/Irrlicht/COpenGLMaterialRenderer.h +++ /dev/null @@ -1,707 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_OPENGL_MATERIAL_RENDERER_H_INCLUDED__ -#define __C_OPENGL_MATERIAL_RENDERER_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_OPENGL_ - -#include "COpenGLDriver.h" -#include "IMaterialRenderer.h" -#if defined(_IRR_OSX_PLATFORM_) - #define GL_COMBINE_EXT 0x8570 - #define GL_COMBINE_RGB_EXT 0x8571 - #define GL_COMBINE_ALPHA_EXT 0x8572 - #define GL_RGB_SCALE_EXT 0x8573 - #define GL_ADD_SIGNED_EXT 0x8574 - #define GL_INTERPOLATE_EXT 0x8575 - #define GL_CONSTANT_EXT 0x8576 - #define GL_PRIMARY_COLOR_EXT 0x8577 - #define GL_PREVIOUS_EXT 0x8578 - #define GL_SOURCE0_RGB_EXT 0x8580 - #define GL_SOURCE1_RGB_EXT 0x8581 - #define GL_SOURCE2_RGB_EXT 0x8582 - #define GL_SOURCE3_RGB_EXT 0x8583 - #define GL_SOURCE4_RGB_EXT 0x8584 - #define GL_SOURCE5_RGB_EXT 0x8585 - #define GL_SOURCE6_RGB_EXT 0x8586 - #define GL_SOURCE7_RGB_EXT 0x8587 - #define GL_SOURCE0_ALPHA_EXT 0x8588 - #define GL_SOURCE1_ALPHA_EXT 0x8589 - #define GL_SOURCE2_ALPHA_EXT 0x858A - #define GL_SOURCE3_ALPHA_EXT 0x858B - #define GL_SOURCE4_ALPHA_EXT 0x858C - #define GL_SOURCE5_ALPHA_EXT 0x858D - #define GL_SOURCE6_ALPHA_EXT 0x858E - #define GL_SOURCE7_ALPHA_EXT 0x858F - #define GL_OPERAND0_RGB_EXT 0x8590 - #define GL_OPERAND1_RGB_EXT 0x8591 - #define GL_OPERAND2_RGB_EXT 0x8592 - #define GL_OPERAND3_RGB_EXT 0x8593 - #define GL_OPERAND4_RGB_EXT 0x8594 - #define GL_OPERAND5_RGB_EXT 0x8595 - #define GL_OPERAND6_RGB_EXT 0x8596 - #define GL_OPERAND7_RGB_EXT 0x8597 - #define GL_OPERAND0_ALPHA_EXT 0x8598 - #define GL_OPERAND1_ALPHA_EXT 0x8599 - #define GL_OPERAND2_ALPHA_EXT 0x859A - #define GL_OPERAND3_ALPHA_EXT 0x859B - #define GL_OPERAND4_ALPHA_EXT 0x859C - #define GL_OPERAND5_ALPHA_EXT 0x859D - #define GL_OPERAND6_ALPHA_EXT 0x859E - #define GL_OPERAND7_ALPHA_EXT 0x859F -#endif - -namespace irr -{ -namespace video -{ - -//! Base class for all internal OpenGL material renderers -class COpenGLMaterialRenderer : public IMaterialRenderer -{ -public: - - //! Constructor - COpenGLMaterialRenderer(video::COpenGLDriver* driver) : Driver(driver) - { - } - -protected: - - video::COpenGLDriver* Driver; -}; - - -//! Solid material renderer -class COpenGLMaterialRenderer_SOLID : public COpenGLMaterialRenderer -{ -public: - - COpenGLMaterialRenderer_SOLID(video::COpenGLDriver* d) - : COpenGLMaterialRenderer(d) {} - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - Driver->disableTextures(1); - Driver->setActiveTexture(0, material.getTexture(0)); - Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - - if (resetAllRenderstates || (material.MaterialType != lastMaterial.MaterialType)) - { - // thanks to Murphy, the following line removed some - // bugs with several OpenGL implementations. - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - } - } -}; - - -//! Generic Texture Blend -class COpenGLMaterialRenderer_ONETEXTURE_BLEND : public COpenGLMaterialRenderer -{ -public: - - COpenGLMaterialRenderer_ONETEXTURE_BLEND(video::COpenGLDriver* d) - : COpenGLMaterialRenderer(d) {} - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - Driver->disableTextures(1); - Driver->setActiveTexture(0, material.getTexture(0)); - Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - -// if (material.MaterialType != lastMaterial.MaterialType || -// material.MaterialTypeParam != lastMaterial.MaterialTypeParam || -// resetAllRenderstates) - { - E_BLEND_FACTOR srcFact,dstFact; - E_MODULATE_FUNC modulate; - u32 alphaSource; - unpack_texureBlendFunc ( srcFact, dstFact, modulate, alphaSource, material.MaterialTypeParam ); - - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT); - - glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, (f32) modulate ); - - glBlendFunc( getGLBlend(srcFact), getGLBlend(dstFact) ); - glEnable(GL_ALPHA_TEST); - glAlphaFunc(GL_GREATER, 0.f); - glEnable(GL_BLEND); - - if ( textureBlendFunc_hasAlpha(srcFact) || textureBlendFunc_hasAlpha(dstFact) ) - { - if (alphaSource==EAS_VERTEX_COLOR) - { - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PRIMARY_COLOR_EXT); - } - else if (alphaSource==EAS_TEXTURE) - { - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE); - } - else - { - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_MODULATE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_PRIMARY_COLOR_EXT); - } - - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PRIMARY_COLOR_EXT); - } - } - } - - virtual void OnUnsetMaterial() - { - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_MODULATE); - glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 1.f ); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT); - - glDisable(GL_BLEND); - glDisable(GL_ALPHA_TEST); - } - - //! Returns if the material is transparent. - /** Is not always transparent, but mostly. */ - virtual bool isTransparent() const - { - return true; - } - - private: - - u32 getGLBlend ( E_BLEND_FACTOR factor ) const - { - u32 r = 0; - switch ( factor ) - { - case EBF_ZERO: r = GL_ZERO; break; - case EBF_ONE: r = GL_ONE; break; - case EBF_DST_COLOR: r = GL_DST_COLOR; break; - case EBF_ONE_MINUS_DST_COLOR: r = GL_ONE_MINUS_DST_COLOR; break; - case EBF_SRC_COLOR: r = GL_SRC_COLOR; break; - case EBF_ONE_MINUS_SRC_COLOR: r = GL_ONE_MINUS_SRC_COLOR; break; - case EBF_SRC_ALPHA: r = GL_SRC_ALPHA; break; - case EBF_ONE_MINUS_SRC_ALPHA: r = GL_ONE_MINUS_SRC_ALPHA; break; - case EBF_DST_ALPHA: r = GL_DST_ALPHA; break; - case EBF_ONE_MINUS_DST_ALPHA: r = GL_ONE_MINUS_DST_ALPHA; break; - case EBF_SRC_ALPHA_SATURATE: r = GL_SRC_ALPHA_SATURATE; break; - } - return r; - } - -}; - - -//! Solid 2 layer material renderer -class COpenGLMaterialRenderer_SOLID_2_LAYER : public COpenGLMaterialRenderer -{ -public: - - COpenGLMaterialRenderer_SOLID_2_LAYER(video::COpenGLDriver* d) - : COpenGLMaterialRenderer(d) {} - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - Driver->disableTextures(2); - Driver->setActiveTexture(1, material.getTexture(1)); - Driver->setActiveTexture(0, material.getTexture(0)); - Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - if (Driver->queryFeature(EVDF_MULTITEXTURE)) - { - Driver->extGlActiveTexture(GL_TEXTURE1_ARB); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PRIMARY_COLOR_EXT); - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_INTERPOLATE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_PRIMARY_COLOR); - glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_ALPHA); - } - } - } - - virtual void OnUnsetMaterial() - { - if (Driver->queryFeature(EVDF_MULTITEXTURE)) - { - Driver->extGlActiveTexture(GL_TEXTURE1_ARB); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_COLOR); - Driver->extGlActiveTexture(GL_TEXTURE0_ARB); - } - } -}; - - -//! Transparent add color material renderer -class COpenGLMaterialRenderer_TRANSPARENT_ADD_COLOR : public COpenGLMaterialRenderer -{ -public: - - COpenGLMaterialRenderer_TRANSPARENT_ADD_COLOR(video::COpenGLDriver* d) - : COpenGLMaterialRenderer(d) {} - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - Driver->disableTextures(1); - Driver->setActiveTexture(0, material.getTexture(0)); - Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - - if ((material.MaterialType != lastMaterial.MaterialType) || resetAllRenderstates) - { - glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glEnable(GL_BLEND); - } - } - - virtual void OnUnsetMaterial() - { - glDisable(GL_BLEND); - } - - //! Returns if the material is transparent. - virtual bool isTransparent() const - { - return true; - } -}; - - -//! Transparent vertex alpha material renderer -class COpenGLMaterialRenderer_TRANSPARENT_VERTEX_ALPHA : public COpenGLMaterialRenderer -{ -public: - - COpenGLMaterialRenderer_TRANSPARENT_VERTEX_ALPHA(video::COpenGLDriver* d) - : COpenGLMaterialRenderer(d) {} - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - Driver->disableTextures(1); - Driver->setActiveTexture(0, material.getTexture(0)); - Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); - - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PRIMARY_COLOR_EXT ); - - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PRIMARY_COLOR_EXT ); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE); - - glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - } - } - - virtual void OnUnsetMaterial() - { - // default values - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_MODULATE ); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE ); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_PREVIOUS_EXT ); - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE ); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT); - - glDisable(GL_BLEND); - } - - //! Returns if the material is transparent. - virtual bool isTransparent() const - { - return true; - } -}; - - -//! Transparent alpha channel material renderer -class COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL : public COpenGLMaterialRenderer -{ -public: - - COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL(video::COpenGLDriver* d) - : COpenGLMaterialRenderer(d) {} - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - Driver->disableTextures(1); - Driver->setActiveTexture(0, material.getTexture(0)); - Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates - || material.MaterialTypeParam != lastMaterial.MaterialTypeParam ) - { - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT); - - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE); - - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - glEnable(GL_ALPHA_TEST); - - glAlphaFunc(GL_GREATER, material.MaterialTypeParam); - } - } - - virtual void OnUnsetMaterial() - { - glDisable(GL_ALPHA_TEST); - glDisable(GL_BLEND); - } - - //! Returns if the material is transparent. - virtual bool isTransparent() const - { - return true; - } -}; - - -//! Transparent alpha channel material renderer -class COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF : public COpenGLMaterialRenderer -{ -public: - - COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF(video::COpenGLDriver* d) - : COpenGLMaterialRenderer(d) {} - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - Driver->disableTextures(1); - Driver->setActiveTexture(0, material.getTexture(0)); - Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - glEnable(GL_ALPHA_TEST); - glAlphaFunc(GL_GREATER, 0.5f); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - } - } - - virtual void OnUnsetMaterial() - { - glDisable(GL_ALPHA_TEST); - } - - //! Returns if the material is transparent. - virtual bool isTransparent() const - { - return false; // this material is not really transparent because it does no blending. - } -}; - - -//! material renderer for all kinds of lightmaps -class COpenGLMaterialRenderer_LIGHTMAP : public COpenGLMaterialRenderer -{ -public: - - COpenGLMaterialRenderer_LIGHTMAP(video::COpenGLDriver* d) - : COpenGLMaterialRenderer(d) {} - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - Driver->disableTextures(2); - Driver->setActiveTexture(1, material.getTexture(1)); - Driver->setActiveTexture(0, material.getTexture(0)); - Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - // diffuse map - - switch (material.MaterialType) - { - case EMT_LIGHTMAP_LIGHTING: - case EMT_LIGHTMAP_LIGHTING_M2: - case EMT_LIGHTMAP_LIGHTING_M4: - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - break; - case EMT_LIGHTMAP_ADD: - case EMT_LIGHTMAP: - case EMT_LIGHTMAP_M2: - case EMT_LIGHTMAP_M4: - default: - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - break; - } - - if (Driver->queryFeature(EVDF_MULTITEXTURE)) - { - // lightmap - - Driver->extGlActiveTexture(GL_TEXTURE1_ARB); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); - - if (material.MaterialType == EMT_LIGHTMAP_ADD) - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD_SIGNED_ARB); - else - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); - - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE); - - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_MODULATE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PREVIOUS_ARB); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_PREVIOUS_ARB); - - switch (material.MaterialType) - { - case EMT_LIGHTMAP_M4: - case EMT_LIGHTMAP_LIGHTING_M4: - glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 4.0f); - break; - case EMT_LIGHTMAP_M2: - case EMT_LIGHTMAP_LIGHTING_M2: - glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f); - break; - default: - glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 1.0f); - } - } - } - } - - virtual void OnUnsetMaterial() - { - if (Driver->queryFeature(EVDF_MULTITEXTURE)) - { - Driver->extGlActiveTexture(GL_TEXTURE1_ARB); - glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 1.f ); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - Driver->extGlActiveTexture(GL_TEXTURE0_ARB); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - } - } -}; - - - -//! detail map material renderer -class COpenGLMaterialRenderer_DETAIL_MAP : public COpenGLMaterialRenderer -{ -public: - - COpenGLMaterialRenderer_DETAIL_MAP(video::COpenGLDriver* d) - : COpenGLMaterialRenderer(d) {} - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - Driver->disableTextures(2); - Driver->setActiveTexture(1, material.getTexture(1)); - Driver->setActiveTexture(0, material.getTexture(0)); - Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - // diffuse map is default modulated - - // detail map on second layer - if (Driver->queryFeature(EVDF_MULTITEXTURE)) - { - Driver->extGlActiveTexture(GL_TEXTURE1_ARB); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD_SIGNED_EXT); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE); - } - } - } - - virtual void OnUnsetMaterial() - { - if (Driver->queryFeature(EVDF_MULTITEXTURE)) - { - Driver->extGlActiveTexture(GL_TEXTURE1_ARB); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - Driver->extGlActiveTexture(GL_TEXTURE0_ARB); - } - } -}; - - -//! sphere map material renderer -class COpenGLMaterialRenderer_SPHERE_MAP : public COpenGLMaterialRenderer -{ -public: - - COpenGLMaterialRenderer_SPHERE_MAP(video::COpenGLDriver* d) - : COpenGLMaterialRenderer(d) {} - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - Driver->disableTextures(1); - Driver->setActiveTexture(0, material.getTexture(0)); - // texture needs to be flipped for OpenGL - core::matrix4 tmp = Driver->getTransform(ETS_TEXTURE_0); - tmp[5]*=-1; - Driver->setTransform(ETS_TEXTURE_0, tmp); - Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); - glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); - - glEnable(GL_TEXTURE_GEN_S); - glEnable(GL_TEXTURE_GEN_T); - } - } - - virtual void OnUnsetMaterial() - { - glDisable(GL_TEXTURE_GEN_S); - glDisable(GL_TEXTURE_GEN_T); - } -}; - - -//! reflection 2 layer material renderer -class COpenGLMaterialRenderer_REFLECTION_2_LAYER : public COpenGLMaterialRenderer -{ -public: - - COpenGLMaterialRenderer_REFLECTION_2_LAYER(video::COpenGLDriver* d) - : COpenGLMaterialRenderer(d) {} - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - Driver->disableTextures(2); - Driver->setActiveTexture(1, material.getTexture(1)); - Driver->setActiveTexture(0, material.getTexture(0)); - Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - if (Driver->queryFeature(EVDF_MULTITEXTURE)) - { - Driver->extGlActiveTexture(GL_TEXTURE1_ARB); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE); - } - glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); - glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); - glEnable(GL_TEXTURE_GEN_S); - glEnable(GL_TEXTURE_GEN_T); - } - } - - virtual void OnUnsetMaterial() - { - if (Driver->queryFeature(EVDF_MULTITEXTURE)) - { - Driver->extGlActiveTexture(GL_TEXTURE1_ARB); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - } - glDisable(GL_TEXTURE_GEN_S); - glDisable(GL_TEXTURE_GEN_T); - if (Driver->queryFeature(EVDF_MULTITEXTURE)) - { - Driver->extGlActiveTexture(GL_TEXTURE0_ARB); - } - } -}; - - -//! reflection 2 layer material renderer -class COpenGLMaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER : public COpenGLMaterialRenderer -{ -public: - - COpenGLMaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER(video::COpenGLDriver* d) - : COpenGLMaterialRenderer(d) {} - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - Driver->disableTextures(2); - Driver->setActiveTexture(1, material.getTexture(1)); - Driver->setActiveTexture(0, material.getTexture(0)); - Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); - - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - if (Driver->queryFeature(EVDF_MULTITEXTURE)) - { - Driver->extGlActiveTexture(GL_TEXTURE1_ARB); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE); - } - glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); - glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); - glEnable(GL_TEXTURE_GEN_S); - glEnable(GL_TEXTURE_GEN_T); - - glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR); - glEnable(GL_BLEND); - } - } - - virtual void OnUnsetMaterial() - { - if (Driver->queryFeature(EVDF_MULTITEXTURE)) - { - Driver->extGlActiveTexture(GL_TEXTURE1_ARB); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - } - glDisable(GL_TEXTURE_GEN_S); - glDisable(GL_TEXTURE_GEN_T); - if (Driver->queryFeature(EVDF_MULTITEXTURE)) - { - Driver->extGlActiveTexture(GL_TEXTURE0_ARB); - } - glDisable(GL_BLEND); - } - - //! Returns if the material is transparent. - virtual bool isTransparent() const - { - return true; - } -}; - -} // end namespace video -} // end namespace irr - -#endif -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/COpenGLNormalMapRenderer.cpp b/irrlicht-1.6/source/Irrlicht/COpenGLNormalMapRenderer.cpp deleted file mode 100644 index 6135ee457..000000000 --- a/irrlicht-1.6/source/Irrlicht/COpenGLNormalMapRenderer.cpp +++ /dev/null @@ -1,308 +0,0 @@ -// Copyright (C) 2002-2009 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_OPENGL_ - -#include "COpenGLNormalMapRenderer.h" -#include "IGPUProgrammingServices.h" -#include "IShaderConstantSetCallBack.h" -#include "IVideoDriver.h" -#include "os.h" -#include "COpenGLDriver.h" - -namespace irr -{ -namespace video -{ - -// Irrlicht Engine OpenGL render path normal map vertex shader -// I guess it could be optimized a lot, because I wrote it in D3D ASM and -// transferred it 1:1 to OpenGL -const char OPENGL_NORMAL_MAP_VSH[] = - "!!ARBvp1.0\n"\ - "#input\n"\ - "# 0-3: transposed world matrix;\n"\ - "#;12: Light01 position \n"\ - "#;13: x,y,z: Light01 color; .w: 1/LightRadius^2 \n"\ - "#;14: Light02 position \n"\ - "#;15: x,y,z: Light02 color; .w: 1/LightRadius^2 \n"\ - "\n"\ - "ATTRIB InPos = vertex.position;\n"\ - "ATTRIB InColor = vertex.color;\n"\ - "ATTRIB InNormal = vertex.normal;\n"\ - "ATTRIB InTexCoord = vertex.texcoord[0];\n"\ - "ATTRIB InTangent = vertex.texcoord[1];\n"\ - "ATTRIB InBinormal = vertex.texcoord[2];\n"\ - "\n"\ - "#output\n"\ - "OUTPUT OutPos = result.position;\n"\ - "OUTPUT OutLightColor1 = result.color.primary;\n"\ - "OUTPUT OutLightColor2 = result.color.secondary;\n"\ - "OUTPUT OutTexCoord = result.texcoord[0];\n"\ - "OUTPUT OutLightVector1 = result.texcoord[1];\n"\ - "OUTPUT OutLightVector2 = result.texcoord[2];\n"\ - "\n"\ - "PARAM MVP[4] = { state.matrix.mvp }; # modelViewProjection matrix.\n"\ - "TEMP Temp;\n"\ - "TEMP TempColor;\n"\ - "TEMP TempNormal;\n"\ - "TEMP TempTangent;\n"\ - "TEMP TempBinormal;\n"\ - "TEMP TempLightVector1;\n"\ - "TEMP TempLightVector2;\n"\ - "TEMP TempTransLightV1;\n"\ - "TEMP TempTransLightV2;\n"\ - "\n"\ - "# transform position to clip space \n"\ - "DP4 OutPos.x, MVP[0], InPos;\n"\ - "DP4 OutPos.y, MVP[1], InPos;\n"\ - "DP4 Temp.z, MVP[2], InPos;\n"\ - "DP4 OutPos.w, MVP[3], InPos;\n"\ - "MOV OutPos.z, Temp.z;\n"\ - "MOV result.fogcoord.x, Temp.z;\n"\ - "\n"\ - "# transform normal \n"\ - "DP3 TempNormal.x, InNormal.x, program.local[0];\n"\ - "DP3 TempNormal.y, InNormal.y, program.local[1]; \n"\ - "DP3 TempNormal.z, InNormal.z, program.local[2];\n"\ - "\n"\ - "# transform tangent \n"\ - "DP3 TempTangent.x, InTangent.x, program.local[0];\n"\ - "DP3 TempTangent.y, InTangent.y, program.local[1]; \n"\ - "DP3 TempTangent.z, InTangent.z, program.local[2];\n"\ - "\n"\ - "# transform binormal \n"\ - "DP3 TempBinormal.x, InBinormal.x, program.local[0];\n"\ - "DP3 TempBinormal.y, InBinormal.y, program.local[1]; \n"\ - "DP3 TempBinormal.z, InBinormal.z, program.local[2];\n"\ - "\n"\ - "# vertex into world position \n"\ - "DP4 Temp.x, InPos, program.local[0];\n"\ - "DP4 Temp.y, InPos, program.local[1];\n"\ - "DP4 Temp.z, InPos, program.local[2];\n"\ - "DP4 Temp.w, InPos, program.local[3];\n"\ - "\n"\ - "# vertex - lightpositions \n"\ - "SUB TempLightVector1, program.local[12], Temp; \n"\ - "SUB TempLightVector2, program.local[14], Temp; \n"\ - "\n"\ - "# transform the light vector 1 with U, V, W \n"\ - "DP3 TempTransLightV1.x, TempTangent, TempLightVector1; \n"\ - "DP3 TempTransLightV1.y, TempBinormal, TempLightVector1; \n"\ - "DP3 TempTransLightV1.z, TempNormal, TempLightVector1; \n"\ - "\n"\ - "# transform the light vector 2 with U, V, W \n"\ - "DP3 TempTransLightV2.x, TempTangent, TempLightVector2; \n"\ - "DP3 TempTransLightV2.y, TempBinormal, TempLightVector2; \n"\ - "DP3 TempTransLightV2.z, TempNormal, TempLightVector2; \n"\ - "\n"\ - "# normalize light vector 1 \n"\ - "DP3 TempTransLightV1.w, TempTransLightV1, TempTransLightV1; \n"\ - "RSQ TempTransLightV1.w, TempTransLightV1.w; \n"\ - "MUL TempTransLightV1, TempTransLightV1, TempTransLightV1.w;\n"\ - "\n"\ - "# normalize light vector 2 \n"\ - "DP3 TempTransLightV2.w, TempTransLightV2, TempTransLightV2; \n"\ - "RSQ TempTransLightV2.w, TempTransLightV2.w; \n"\ - "MUL TempTransLightV2, TempTransLightV2, TempTransLightV2.w;\n"\ - "\n"\ - "\n"\ - "# move light vectors out\n"\ - "MAD OutLightVector1, TempTransLightV1, {0.5,0.5,0.5,0.5}, {0.5,0.5,0.5,0.5}; \n"\ - "MAD OutLightVector2, TempTransLightV2, {0.5,0.5,0.5,0.5}, {0.5,0.5,0.5,0.5}; \n"\ - "\n"\ - "# calculate attenuation of light 1\n"\ - "MOV TempLightVector1.w, {0,0,0,0}; \n"\ - "DP3 TempLightVector1.x, TempLightVector1, TempLightVector1; \n"\ - "MUL TempLightVector1.x, TempLightVector1.x, program.local[13].w; \n"\ - "RSQ TempLightVector1, TempLightVector1.x; \n"\ - "MUL OutLightColor1, TempLightVector1, program.local[13]; # resulting light color = lightcolor * attenuation \n"\ - "\n"\ - "# calculate attenuation of light 2\n"\ - "MOV TempLightVector2.w, {0,0,0,0}; \n"\ - "DP3 TempLightVector2.x, TempLightVector2, TempLightVector2; \n"\ - "MUL TempLightVector2.x, TempLightVector2.x, program.local[15].w; \n"\ - "RSQ TempLightVector2, TempLightVector2.x; \n"\ - "MUL OutLightColor2, TempLightVector2, program.local[15]; # resulting light color = lightcolor * attenuation \n"\ - "\n"\ - "# move out texture coordinates and original alpha value\n"\ - "MOV OutTexCoord, InTexCoord; \n"\ - "MOV OutLightColor1.w, InColor.w; \n"\ - "\n"\ - "END\n"; - -// Irrlicht Engine OpenGL render path normal map pixel shader -// I guess it could be optimized a bit, because I wrote it in D3D ASM and -// transfered it 1:1 to OpenGL -const char OPENGL_NORMAL_MAP_PSH[] = - "!!ARBfp1.0\n"\ - "#_IRR_FOG_MODE_\n"\ - "\n"\ - "#Input\n"\ - "ATTRIB inTexCoord = fragment.texcoord[0]; \n"\ - "ATTRIB light1Vector = fragment.texcoord[1]; \n"\ - "ATTRIB light2Vector = fragment.texcoord[2]; \n"\ - "ATTRIB light1Color = fragment.color.primary; \n"\ - "ATTRIB light2Color = fragment.color.secondary; \n"\ - "\n"\ - "#Output\n"\ - "OUTPUT outColor = result.color;\n"\ - "TEMP temp;\n"\ - "TEMP temp2;\n"\ - "TEMP colorMapColor;\n"\ - "TEMP normalMapColor;\n"\ - "\n"\ - "# fetch color and normal map; \n"\ - "TXP colorMapColor, inTexCoord, texture[0], 2D; \n"\ - "TXP normalMapColor, inTexCoord, texture[1], 2D; \n"\ - "\n"\ - "# calculate color of light1; \n"\ - "MAD normalMapColor, normalMapColor, {2,2,2,2}, {-1,-1,-1,-1}; \n"\ - "MAD temp, light1Vector, {2,2,2,2}, {-1,-1,-1,-1}; \n"\ - "DP3_SAT temp, normalMapColor, temp; \n"\ - "MUL temp, light1Color, temp; \n"\ - "\n"\ - "# calculate color of light2; \n"\ - "MAD temp2, light2Vector, {2,2,2,2}, {-1,-1,-1,-1}; \n"\ - "DP3_SAT temp2, normalMapColor, temp2; \n"\ - "MAD temp, light2Color, temp2, temp; \n"\ - "\n"\ - "# luminance * base color; \n"\ - "MUL outColor, temp, colorMapColor; \n"\ - "MOV outColor.a, light1Color.a; #write interpolated vertex alpha value\n"\ - "\n"\ - "END\n"; - -//! Constructor -COpenGLNormalMapRenderer::COpenGLNormalMapRenderer(video::COpenGLDriver* driver, - s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial) - : COpenGLShaderMaterialRenderer(driver, 0, baseMaterial), CompiledShaders(true) -{ - - #ifdef _DEBUG - setDebugName("COpenGLNormalMapRenderer"); - #endif - - // set this as callback. We could have done this in - // the initialization list, but some compilers don't like it. - - CallBack = this; - - // basically, this thing simply compiles the hardcoded shaders if the - // hardware is able to do them, otherwise it maps to the base material - - if (!driver->queryFeature(video::EVDF_ARB_FRAGMENT_PROGRAM_1) || - !driver->queryFeature(video::EVDF_ARB_VERTEX_PROGRAM_1)) - { - // this hardware is not able to do shaders. Fall back to - // base material. - outMaterialTypeNr = driver->addMaterialRenderer(this); - return; - } - - // check if already compiled normal map shaders are there. - - video::IMaterialRenderer* renderer = driver->getMaterialRenderer(EMT_NORMAL_MAP_SOLID); - - if (renderer) - { - // use the already compiled shaders - video::COpenGLNormalMapRenderer* nmr = reinterpret_cast<video::COpenGLNormalMapRenderer*>(renderer); - CompiledShaders = false; - - VertexShader = nmr->VertexShader; - PixelShader = nmr->PixelShader; - - outMaterialTypeNr = driver->addMaterialRenderer(this); - } - else - { - // compile shaders on our own - init(outMaterialTypeNr, OPENGL_NORMAL_MAP_VSH, OPENGL_NORMAL_MAP_PSH, EVT_TANGENTS); - } - - // fallback if compilation has failed - if (-1==outMaterialTypeNr) - outMaterialTypeNr = driver->addMaterialRenderer(this); -} - - -//! Destructor -COpenGLNormalMapRenderer::~COpenGLNormalMapRenderer() -{ - if (CallBack == this) - CallBack = 0; - - if (!CompiledShaders) - { - // prevent this from deleting shaders we did not create - VertexShader = 0; - PixelShader.clear(); - } -} - - -//! Returns the render capability of the material. -s32 COpenGLNormalMapRenderer::getRenderCapability() const -{ - if (Driver->queryFeature(video::EVDF_ARB_FRAGMENT_PROGRAM_1) && - Driver->queryFeature(video::EVDF_ARB_VERTEX_PROGRAM_1)) - return 0; - - return 1; -} - - -//! Called by the engine when the vertex and/or pixel shader constants for an -//! material renderer should be set. -void COpenGLNormalMapRenderer::OnSetConstants(IMaterialRendererServices* services, s32 userData) -{ - video::IVideoDriver* driver = services->getVideoDriver(); - - // set transposed world matrix - const core::matrix4& tWorld = driver->getTransform(video::ETS_WORLD).getTransposed(); - services->setVertexShaderConstant(tWorld.pointer(), 0, 4); - - // set transposed worldViewProj matrix - core::matrix4 worldViewProj(driver->getTransform(video::ETS_PROJECTION)); - worldViewProj *= driver->getTransform(video::ETS_VIEW); - worldViewProj *= driver->getTransform(video::ETS_WORLD); - core::matrix4 tr(worldViewProj.getTransposed()); - services->setVertexShaderConstant(tr.pointer(), 8, 4); - - // here we fetch the fixed function lights from the driver - // and set them as constants - - u32 cnt = driver->getDynamicLightCount(); - - for (u32 i=0; i<2; ++i) - { - video::SLight light; - - if (i<cnt) - light = driver->getDynamicLight(i); - else - { - light.DiffuseColor.set(0,0,0); // make light dark - light.Radius = 1.0f; - } - - light.DiffuseColor.a = 1.0f/(light.Radius*light.Radius); // set attenuation - - services->setVertexShaderConstant( - reinterpret_cast<const f32*>(&light.Position), 12+(i*2), 1); - - services->setVertexShaderConstant( - reinterpret_cast<const f32*>(&light.DiffuseColor), 13+(i*2), 1); - } -} - - -} // end namespace video -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/COpenGLNormalMapRenderer.h b/irrlicht-1.6/source/Irrlicht/COpenGLNormalMapRenderer.h deleted file mode 100644 index 4b50954b1..000000000 --- a/irrlicht-1.6/source/Irrlicht/COpenGLNormalMapRenderer.h +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_OPENGL_NORMAL_MAP_RENDERER_H_INCLUDED__ -#define __C_OPENGL_NORMAL_MAP_RENDERER_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_OPENGL_ - -#include "COpenGLShaderMaterialRenderer.h" -#include "IShaderConstantSetCallBack.h" - -namespace irr -{ -namespace video -{ - -//! Class for rendering normal maps with OpenGL -class COpenGLNormalMapRenderer : public COpenGLShaderMaterialRenderer, public IShaderConstantSetCallBack -{ -public: - - //! Constructor - COpenGLNormalMapRenderer(video::COpenGLDriver* driver, - s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial); - - //! Destructor - ~COpenGLNormalMapRenderer(); - - //! Called by the engine when the vertex and/or pixel shader constants for an - //! material renderer should be set. - virtual void OnSetConstants(IMaterialRendererServices* services, s32 userData); - - //! Returns the render capability of the material. - virtual s32 getRenderCapability() const; - -protected: - - bool CompiledShaders; -}; - - -} // end namespace video -} // end namespace irr - -#endif -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/COpenGLParallaxMapRenderer.cpp b/irrlicht-1.6/source/Irrlicht/COpenGLParallaxMapRenderer.cpp deleted file mode 100644 index 70be541ce..000000000 --- a/irrlicht-1.6/source/Irrlicht/COpenGLParallaxMapRenderer.cpp +++ /dev/null @@ -1,373 +0,0 @@ -// Copyright (C) 2002-2009 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_OPENGL_ - -#include "COpenGLParallaxMapRenderer.h" -#include "COpenGLDriver.h" -#include "IGPUProgrammingServices.h" -#include "IShaderConstantSetCallBack.h" -#include "IVideoDriver.h" -#include "os.h" - -namespace irr -{ -namespace video -{ - -// Irrlicht Engine OpenGL render path parallax map vertex shader -// I guess it could be optimized a lot, because I wrote it in D3D ASM and -// transferred it 1:1 to OpenGL -const char OPENGL_PARALLAX_MAP_VSH[] = - "!!ARBvp1.0\n"\ - "#input\n"\ - "# 0-3: transposed world matrix;\n"\ - "#;12: Light01 position \n"\ - "#;13: x,y,z: Light01 color; .w: 1/LightRadius^2 \n"\ - "#;14: Light02 position \n"\ - "#;15: x,y,z: Light02 color; .w: 1/LightRadius^2 \n"\ - "#;16: Eye position \n"\ - "\n"\ - "ATTRIB InPos = vertex.position;\n"\ - "ATTRIB InColor = vertex.color;\n"\ - "ATTRIB InNormal = vertex.normal;\n"\ - "ATTRIB InTexCoord = vertex.texcoord[0];\n"\ - "ATTRIB InTangent = vertex.texcoord[1];\n"\ - "ATTRIB InBinormal = vertex.texcoord[2];\n"\ - "\n"\ - "#output\n"\ - "OUTPUT OutPos = result.position;\n"\ - "OUTPUT OutLightColor1 = result.color.primary;\n"\ - "OUTPUT OutLightColor2 = result.color.secondary;\n"\ - "OUTPUT OutTexCoord = result.texcoord[0];\n"\ - "OUTPUT OutLightVector1 = result.texcoord[1];\n"\ - "OUTPUT OutLightVector2 = result.texcoord[2];\n"\ - "OUTPUT OutEyeVector = result.texcoord[3];\n"\ - "\n"\ - "PARAM MVP[4] = { state.matrix.mvp }; # modelViewProjection matrix.\n"\ - "TEMP Temp;\n"\ - "TEMP TempColor;\n"\ - "TEMP TempNormal;\n"\ - "TEMP TempTangent;\n"\ - "TEMP TempBinormal;\n"\ - "TEMP TempLightVector1;\n"\ - "TEMP TempLightVector2;\n"\ - "TEMP TempEyeVector;\n"\ - "TEMP TempTransLightV1;\n"\ - "TEMP TempTransLightV2;\n"\ - "\n"\ - "# transform position to clip space \n"\ - "DP4 OutPos.x, MVP[0], InPos;\n"\ - "DP4 OutPos.y, MVP[1], InPos;\n"\ - "DP4 Temp.z, MVP[2], InPos;\n"\ - "DP4 OutPos.w, MVP[3], InPos;\n"\ - "MOV OutPos.z, Temp.z;\n"\ - "MOV result.fogcoord.x, Temp.z;\n"\ - "\n"\ - "# transform normal \n"\ - "DP3 TempNormal.x, InNormal.x, program.local[0];\n"\ - "DP3 TempNormal.y, InNormal.y, program.local[1]; \n"\ - "DP3 TempNormal.z, InNormal.z, program.local[2];\n"\ - "\n"\ - "# transform tangent \n"\ - "DP3 TempTangent.x, InTangent.x, program.local[0];\n"\ - "DP3 TempTangent.y, InTangent.y, program.local[1]; \n"\ - "DP3 TempTangent.z, InTangent.z, program.local[2];\n"\ - "\n"\ - "# transform binormal \n"\ - "DP3 TempBinormal.x, InBinormal.x, program.local[0];\n"\ - "DP3 TempBinormal.y, InBinormal.y, program.local[1]; \n"\ - "DP3 TempBinormal.z, InBinormal.z, program.local[2];\n"\ - "\n"\ - "# vertex into world position \n"\ - "DP4 Temp.x, InPos, program.local[0];\n"\ - "DP4 Temp.y, InPos, program.local[1];\n"\ - "DP4 Temp.z, InPos, program.local[2];\n"\ - "DP4 Temp.w, InPos, program.local[3];\n"\ - "\n"\ - "# vertex - lightpositions \n"\ - "SUB TempLightVector1, program.local[12], Temp; \n"\ - "SUB TempLightVector2, program.local[14], Temp; \n"\ - "\n"\ - "# eye vector \n"\ - "SUB Temp, program.local[16], Temp; \n"\ - "\n"\ - "# transform the light vector 1 with U, V, W \n"\ - "DP3 TempTransLightV1.x, TempTangent, TempLightVector1; \n"\ - "DP3 TempTransLightV1.y, TempBinormal, TempLightVector1; \n"\ - "DP3 TempTransLightV1.z, TempNormal, TempLightVector1; \n"\ - "\n"\ - "# transform the light vector 2 with U, V, W \n"\ - "DP3 TempTransLightV2.x, TempTangent, TempLightVector2; \n"\ - "DP3 TempTransLightV2.y, TempBinormal, TempLightVector2; \n"\ - "DP3 TempTransLightV2.z, TempNormal, TempLightVector2; \n"\ - "\n"\ - "# transform the eye vector with U, V, W \n"\ - "DP3 TempEyeVector.x, TempTangent, Temp; \n"\ - "DP3 TempEyeVector.y, TempBinormal, Temp; \n"\ - "DP3 TempEyeVector.z, TempNormal, Temp; \n"\ - "\n"\ - "# normalize light vector 1 \n"\ - "DP3 TempTransLightV1.w, TempTransLightV1, TempTransLightV1; \n"\ - "RSQ TempTransLightV1.w, TempTransLightV1.w; \n"\ - "MUL TempTransLightV1, TempTransLightV1, TempTransLightV1.w;\n"\ - "\n"\ - "# normalize light vector 2 \n"\ - "DP3 TempTransLightV2.w, TempTransLightV2, TempTransLightV2; \n"\ - "RSQ TempTransLightV2.w, TempTransLightV2.w; \n"\ - "MUL TempTransLightV2, TempTransLightV2, TempTransLightV2.w;\n"\ - "\n"\ - "# normalize eye vector \n"\ - "DP3 TempEyeVector.w, TempEyeVector, TempEyeVector; \n"\ - "RSQ TempEyeVector.w, TempEyeVector.w; \n"\ - "MUL TempEyeVector, TempEyeVector, TempEyeVector.w;\n"\ - "MUL TempEyeVector, TempEyeVector, {1,-1,-1,1}; # flip x \n"\ - "\n"\ - "\n"\ - "# move light and eye vectors out\n"\ - "MAD OutLightVector1, TempTransLightV1, {0.5,0.5,0.5,0.5}, {0.5,0.5,0.5,0.5}; \n"\ - "MAD OutLightVector2, TempTransLightV2, {0.5,0.5,0.5,0.5}, {0.5,0.5,0.5,0.5}; \n"\ - "MAD OutEyeVector, TempEyeVector, {0.5,0.5,0.5,0.5}, {0.5,0.5,0.5,0.5}; \n"\ - "\n"\ - "# calculate attenuation of light 1\n"\ - "MOV TempLightVector1.w, {0,0,0,0}; \n"\ - "DP3 TempLightVector1.x, TempLightVector1, TempLightVector1; \n"\ - "MUL TempLightVector1.x, TempLightVector1.x, program.local[13].w; \n"\ - "RSQ TempLightVector1, TempLightVector1.x; \n"\ - "MUL OutLightColor1, TempLightVector1, program.local[13]; # resulting light color = lightcolor * attenuation \n"\ - "\n"\ - "# calculate attenuation of light 2\n"\ - "MOV TempLightVector2.w, {0,0,0,0}; \n"\ - "DP3 TempLightVector2.x, TempLightVector2, TempLightVector2; \n"\ - "MUL TempLightVector2.x, TempLightVector2.x, program.local[15].w; \n"\ - "RSQ TempLightVector2, TempLightVector2.x; \n"\ - "MUL OutLightColor2, TempLightVector2, program.local[15]; # resulting light color = lightcolor * attenuation \n"\ - "\n"\ - "# move out texture coordinates and original alpha value\n"\ - "MOV OutTexCoord, InTexCoord; \n"\ - "MOV OutLightColor1.w, InColor.w; \n"\ - "\n"\ - "END\n"; - -// Irrlicht Engine OpenGL render path parallax map pixel shader -// I guess it could be optimized a bit, because I wrote it in D3D ASM and -// transfered it 1:1 to OpenGL -const char OPENGL_PARALLAX_MAP_PSH[] = - "!!ARBfp1.0\n"\ - "#_IRR_FOG_MODE_\n"\ - "\n"\ - "#Input\n"\ - "ATTRIB inTexCoord = fragment.texcoord[0]; \n"\ - "ATTRIB light1Vector = fragment.texcoord[1]; \n"\ - "ATTRIB light2Vector = fragment.texcoord[2]; \n"\ - "ATTRIB eyeVector = fragment.texcoord[3]; \n"\ - "ATTRIB light1Color = fragment.color.primary; \n"\ - "ATTRIB light2Color = fragment.color.secondary; \n"\ - "\n"\ - "#Output\n"\ - "OUTPUT outColor = result.color;\n"\ - "TEMP temp;\n"\ - "TEMP temp2;\n"\ - "TEMP colorMapColor;\n"\ - "TEMP normalMapColor;\n"\ - "\n"\ - "PARAM height_scale = program.local[0]; \n"\ - "# fetch color and normal map; \n"\ - "TXP normalMapColor, inTexCoord, texture[1], 2D; \n"\ - "MAD normalMapColor, normalMapColor, {2,2,2,2}, {-1,-1,-1,-1}; \n"\ - "\n"\ - "\n"\ - "# extract eye vector (so substract 0.5f and multiply by 2)\n"\ - "MAD temp, eyeVector, {2,2,2,2}, {-1,-1,-1,-1};\n"\ - "\n"\ - "# height = height * scale \n"\ - "MUL normalMapColor, normalMapColor, height_scale;\n"\ - "\n"\ - "# calculate new texture coord: height * eye + oldTexCoord\n"\ - "MAD temp, temp, normalMapColor.wwww, inTexCoord;\n"\ - "\n"\ - "# fetch new textures \n"\ - "TXP colorMapColor, temp, texture[0], 2D; \n"\ - "TXP normalMapColor, temp, texture[1], 2D; \n"\ - "\n"\ - "# calculate color of light1; \n"\ - "MAD normalMapColor, normalMapColor, {2,2,2,2}, {-1,-1,-1,-1}; \n"\ - "MAD temp, light1Vector, {2,2,2,2}, {-1,-1,-1,-1}; \n"\ - "DP3_SAT temp, normalMapColor, temp; \n"\ - "MUL temp, light1Color, temp; \n"\ - "\n"\ - "# calculate color of light2; \n"\ - "MAD temp2, light2Vector, {2,2,2,2}, {-1,-1,-1,-1}; \n"\ - "DP3_SAT temp2, normalMapColor, temp2; \n"\ - "MAD temp, light2Color, temp2, temp; \n"\ - "\n"\ - "# luminance * base color; \n"\ - "MUL outColor, temp, colorMapColor; \n"\ - "MOV outColor.a, light1Color.a; #write interpolated vertex alpha value\n"\ - "\n"\ - "END\n"; - -//! Constructor -COpenGLParallaxMapRenderer::COpenGLParallaxMapRenderer(video::COpenGLDriver* driver, - s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial) - : COpenGLShaderMaterialRenderer(driver, 0, baseMaterial), CompiledShaders(true) -{ - - #ifdef _DEBUG - setDebugName("COpenGLParallaxMapRenderer"); - #endif - - // set this as callback. We could have done this in - // the initialization list, but some compilers don't like it. - - CallBack = this; - - // basically, this simply compiles the hard coded shaders if the - // hardware is able to do them, otherwise it maps to the base material - - if (!driver->queryFeature(video::EVDF_ARB_FRAGMENT_PROGRAM_1) || - !driver->queryFeature(video::EVDF_ARB_VERTEX_PROGRAM_1)) - { - // this hardware is not able to do shaders. Fall back to - // base material. - outMaterialTypeNr = driver->addMaterialRenderer(this); - return; - } - - // check if already compiled normal map shaders are there. - - video::IMaterialRenderer* renderer = driver->getMaterialRenderer(EMT_PARALLAX_MAP_SOLID); - - if (renderer) - { - // use the already compiled shaders - video::COpenGLParallaxMapRenderer* nmr = reinterpret_cast<video::COpenGLParallaxMapRenderer*>(renderer); - CompiledShaders = false; - - VertexShader = nmr->VertexShader; - PixelShader = nmr->PixelShader; - - outMaterialTypeNr = driver->addMaterialRenderer(this); - } - else - { - // compile shaders on our own - init(outMaterialTypeNr, OPENGL_PARALLAX_MAP_VSH, OPENGL_PARALLAX_MAP_PSH, EVT_TANGENTS); - } - - // fallback if compilation has failed - if (-1==outMaterialTypeNr) - outMaterialTypeNr = driver->addMaterialRenderer(this); -} - - -//! Destructor -COpenGLParallaxMapRenderer::~COpenGLParallaxMapRenderer() -{ - if (CallBack == this) - CallBack = 0; - - if (!CompiledShaders) - { - // prevent this from deleting shaders we did not create - VertexShader = 0; - PixelShader.clear(); - } -} - - -void COpenGLParallaxMapRenderer::OnSetMaterial(const video::SMaterial& material, - const video::SMaterial& lastMaterial, - bool resetAllRenderstates, video::IMaterialRendererServices* services) -{ - COpenGLShaderMaterialRenderer::OnSetMaterial(material, lastMaterial, - resetAllRenderstates, services); - - CurrentScale = material.MaterialTypeParam; -} - - - -//! Returns the render capability of the material. -s32 COpenGLParallaxMapRenderer::getRenderCapability() const -{ - if (Driver->queryFeature(video::EVDF_ARB_FRAGMENT_PROGRAM_1) && - Driver->queryFeature(video::EVDF_ARB_VERTEX_PROGRAM_1)) - return 0; - - return 1; -} - - -//! Called by the engine when the vertex and/or pixel shader constants for an -//! material renderer should be set. -void COpenGLParallaxMapRenderer::OnSetConstants(IMaterialRendererServices* services, s32 userData) -{ - video::IVideoDriver* driver = services->getVideoDriver(); - - // set transposed world matrix - const core::matrix4& tWorld = driver->getTransform(video::ETS_WORLD).getTransposed(); - services->setVertexShaderConstant(tWorld.pointer(), 0, 4); - - // The viewpoint is at (0., 0., 0.) in eye space. - // Turning this into a vector [0 0 0 1] and multiply it by - // the inverse of the view matrix, the resulting vector is the - // object space location of the camera. - - f32 floats[4] = {0.0f,0.0f,0.0f,1.0f}; - core::matrix4 minv(driver->getTransform(video::ETS_VIEW)); - minv.makeInverse(); - minv.multiplyWith1x4Matrix(floats); - services->setVertexShaderConstant(floats, 16, 1); - - // set transposed worldViewProj matrix - core::matrix4 worldViewProj(driver->getTransform(video::ETS_PROJECTION)); - worldViewProj *= driver->getTransform(video::ETS_VIEW); - worldViewProj *= driver->getTransform(video::ETS_WORLD); - core::matrix4 tr(worldViewProj.getTransposed()); - services->setVertexShaderConstant(tr.pointer(), 8, 4); - - // here we fetch the fixed function lights from the driver - // and set them as constants - - u32 cnt = driver->getDynamicLightCount(); - - for (u32 i=0; i<2; ++i) - { - video::SLight light; - - if (i<cnt) - light = driver->getDynamicLight(i); - else - { - light.DiffuseColor.set(0,0,0); // make light dark - light.Radius = 1.0f; - } - - light.DiffuseColor.a = 1.0f/(light.Radius*light.Radius); // set attenuation - - services->setVertexShaderConstant( - reinterpret_cast<const f32*>(&light.Position), 12+(i*2), 1); - - services->setVertexShaderConstant( - reinterpret_cast<const f32*>(&light.DiffuseColor), 13+(i*2), 1); - } - - // set scale factor - f32 factor = 0.02f; // default value - if (CurrentScale != 0.0f) - factor = CurrentScale; - - f32 c6[] = {factor, factor, factor, factor}; - services->setPixelShaderConstant(c6, 0, 1); -} - - -} // end namespace video -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/COpenGLParallaxMapRenderer.h b/irrlicht-1.6/source/Irrlicht/COpenGLParallaxMapRenderer.h deleted file mode 100644 index 3424c3fe8..000000000 --- a/irrlicht-1.6/source/Irrlicht/COpenGLParallaxMapRenderer.h +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_OPENGL_PARALLAX_MAP_RENDERER_H_INCLUDED__ -#define __C_OPENGL_PARALLAX_MAP_RENDERER_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_OPENGL_ - -#include "COpenGLShaderMaterialRenderer.h" -#include "IShaderConstantSetCallBack.h" - -namespace irr -{ -namespace video -{ - -//! Class for rendering normal maps with OpenGL -class COpenGLParallaxMapRenderer : public COpenGLShaderMaterialRenderer, public IShaderConstantSetCallBack -{ -public: - - //! Constructor - COpenGLParallaxMapRenderer(video::COpenGLDriver* driver, - s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial); - - //! Destructor - ~COpenGLParallaxMapRenderer(); - - //! Called by the engine when the vertex and/or pixel shader constants for an - //! material renderer should be set. - virtual void OnSetConstants(IMaterialRendererServices* services, s32 userData); - - //! Returns the render capability of the material. - virtual s32 getRenderCapability() const; - - virtual void OnSetMaterial(const SMaterial& material) { } - virtual void OnSetMaterial(const video::SMaterial& material, - const video::SMaterial& lastMaterial, - bool resetAllRenderstates, video::IMaterialRendererServices* services); - -protected: - - bool CompiledShaders; - f32 CurrentScale; -}; - - -} // end namespace video -} // end namespace irr - -#endif -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/COpenGLSLMaterialRenderer.cpp b/irrlicht-1.6/source/Irrlicht/COpenGLSLMaterialRenderer.cpp deleted file mode 100644 index da64802ef..000000000 --- a/irrlicht-1.6/source/Irrlicht/COpenGLSLMaterialRenderer.cpp +++ /dev/null @@ -1,377 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -// This file was originally written by William Finlayson. I (Nikolaus -// Gebhardt) did some minor modifications and changes to it and integrated it -// into Irrlicht. Thanks a lot to William for his work on this and that he gave -// me his permission to add it into Irrlicht using the zlib license. - -// After Irrlicht 0.12, Michael Zoech did some improvements to this renderer, I -// merged this into Irrlicht 0.14, thanks to him for his work. - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_OPENGL_ - -#include "COpenGLSLMaterialRenderer.h" -#include "IGPUProgrammingServices.h" -#include "IShaderConstantSetCallBack.h" -#include "IMaterialRendererServices.h" -#include "IVideoDriver.h" -#include "os.h" -#include "COpenGLDriver.h" - -namespace irr -{ -namespace video -{ - - -//! Constructor -COpenGLSLMaterialRenderer::COpenGLSLMaterialRenderer(video::COpenGLDriver* driver, - s32& outMaterialTypeNr, const c8* vertexShaderProgram, - const c8* vertexShaderEntryPointName, - E_VERTEX_SHADER_TYPE vsCompileTarget, - const c8* pixelShaderProgram, - const c8* pixelShaderEntryPointName, - E_PIXEL_SHADER_TYPE psCompileTarget, - IShaderConstantSetCallBack* callback, - video::IMaterialRenderer* baseMaterial, - s32 userData) - : Driver(driver), CallBack(callback), BaseMaterial(baseMaterial), - Program(0), UserData(userData) -{ - #ifdef _DEBUG - setDebugName("COpenGLSLMaterialRenderer"); - #endif - - //entry points must always be main, and the compile target isn't selectable - //it is fine to ignore what has been asked for, as the compiler should spot anything wrong - //just check that GLSL is available - - if (BaseMaterial) - BaseMaterial->grab(); - - if (CallBack) - CallBack->grab(); - - if (!Driver->queryFeature(EVDF_ARB_GLSL)) - return; - - init(outMaterialTypeNr, vertexShaderProgram, pixelShaderProgram); -} - - -//! constructor only for use by derived classes who want to -//! create a fall back material for example. -COpenGLSLMaterialRenderer::COpenGLSLMaterialRenderer(COpenGLDriver* driver, - IShaderConstantSetCallBack* callback, - IMaterialRenderer* baseMaterial, s32 userData) -: Driver(driver), CallBack(callback), BaseMaterial(baseMaterial), - Program(0), UserData(userData) -{ - if (BaseMaterial) - BaseMaterial->grab(); - - if (CallBack) - CallBack->grab(); -} - - -//! Destructor -COpenGLSLMaterialRenderer::~COpenGLSLMaterialRenderer() -{ - if (CallBack) - CallBack->drop(); - - if(Program) - { - Driver->extGlDeleteObject(Program); - Program = 0; - } - - UniformInfo.clear(); - - if (BaseMaterial) - BaseMaterial->drop(); -} - -void COpenGLSLMaterialRenderer::init(s32& outMaterialTypeNr, - const c8* vertexShaderProgram, - const c8* pixelShaderProgram) -{ - outMaterialTypeNr = -1; - - if (!createProgram()) - return; - -#if defined(GL_ARB_vertex_shader) && defined (GL_ARB_fragment_shader) - if (vertexShaderProgram) - if (!createShader(GL_VERTEX_SHADER_ARB, vertexShaderProgram)) - return; - - - if (pixelShaderProgram) - if (!createShader(GL_FRAGMENT_SHADER_ARB, pixelShaderProgram)) - return; -#endif - - if (!linkProgram()) - return; - - // register myself as new material - outMaterialTypeNr = Driver->addMaterialRenderer(this); -} - - -bool COpenGLSLMaterialRenderer::OnRender(IMaterialRendererServices* service, - E_VERTEX_TYPE vtxtype) -{ - // call callback to set shader constants - if (CallBack && (Program)) - CallBack->OnSetConstants(this, UserData); - - return true; -} - - -void COpenGLSLMaterialRenderer::OnSetMaterial(const video::SMaterial& material, - const video::SMaterial& lastMaterial, - bool resetAllRenderstates, - video::IMaterialRendererServices* services) -{ - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { - if (Program) - Driver->extGlUseProgramObject(Program); - - if (BaseMaterial) - BaseMaterial->OnSetMaterial(material, material, true, this); - } - - //let callback know used material - if (CallBack) - CallBack->OnSetMaterial(material); - - for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i) - Driver->setActiveTexture(i, material.getTexture(i)); - Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); -} - - -void COpenGLSLMaterialRenderer::OnUnsetMaterial() -{ - Driver->extGlUseProgramObject(0); - - if (BaseMaterial) - BaseMaterial->OnUnsetMaterial(); -} - -//! Returns if the material is transparent. -bool COpenGLSLMaterialRenderer::isTransparent() const -{ - return BaseMaterial ? BaseMaterial->isTransparent() : false; -} - -bool COpenGLSLMaterialRenderer::createProgram() -{ - Program = Driver->extGlCreateProgramObject(); - return true; -} - -bool COpenGLSLMaterialRenderer::createShader(GLenum shaderType, const char* shader) -{ - GLhandleARB shaderHandle = Driver->extGlCreateShaderObject(shaderType); - - Driver->extGlShaderSource(shaderHandle, 1, &shader, NULL); - Driver->extGlCompileShader(shaderHandle); - - int status = 0; - -#ifdef GL_ARB_shader_objects - Driver->extGlGetObjectParameteriv(shaderHandle, GL_OBJECT_COMPILE_STATUS_ARB, &status); -#endif - - if (!status) - { - os::Printer::log("GLSL shader failed to compile", ELL_ERROR); - // check error message and log it - int maxLength=0; - GLsizei length; -#ifdef GL_ARB_shader_objects - Driver->extGlGetObjectParameteriv(shaderHandle, - GL_OBJECT_INFO_LOG_LENGTH_ARB, &maxLength); -#endif - GLcharARB *pInfoLog = new GLcharARB[maxLength]; - Driver->extGlGetInfoLog(shaderHandle, maxLength, &length, pInfoLog); - os::Printer::log(reinterpret_cast<const c8*>(pInfoLog), ELL_ERROR); - delete [] pInfoLog; - - return false; - } - - Driver->extGlAttachObject(Program, shaderHandle); - - return true; -} - - -bool COpenGLSLMaterialRenderer::linkProgram() -{ - Driver->extGlLinkProgram(Program); - - int status = 0; - -#ifdef GL_ARB_shader_objects - Driver->extGlGetObjectParameteriv(Program, GL_OBJECT_LINK_STATUS_ARB, &status); -#endif - - if (!status) - { - os::Printer::log("GLSL shader program failed to link", ELL_ERROR); - // check error message and log it - int maxLength=0; - GLsizei length; -#ifdef GL_ARB_shader_objects - Driver->extGlGetObjectParameteriv(Program, - GL_OBJECT_INFO_LOG_LENGTH_ARB, &maxLength); -#endif - GLcharARB *pInfoLog = new GLcharARB[maxLength]; - Driver->extGlGetInfoLog(Program, maxLength, &length, pInfoLog); - os::Printer::log(reinterpret_cast<const c8*>(pInfoLog), ELL_ERROR); - delete [] pInfoLog; - - return false; - } - - // get uniforms information - - int num = 0; -#ifdef GL_ARB_shader_objects - Driver->extGlGetObjectParameteriv(Program, GL_OBJECT_ACTIVE_UNIFORMS_ARB, &num); -#endif - - if (num == 0) - { - // no uniforms - return true; - } - - int maxlen = 0; -#ifdef GL_ARB_shader_objects - Driver->extGlGetObjectParameteriv(Program, GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB, &maxlen); -#endif - - if (maxlen == 0) - { - os::Printer::log("GLSL: failed to retrieve uniform information", ELL_ERROR); - return false; - } - - c8 *buf = new c8[maxlen]; - - UniformInfo.clear(); - UniformInfo.reallocate(num); - - for (int i=0; i < num; ++i) - { - SUniformInfo ui; - memset(buf, 0, maxlen); - - GLint size; - Driver->extGlGetActiveUniform(Program, i, maxlen, 0, &size, &ui.type, reinterpret_cast<GLcharARB*>(buf)); - ui.name = buf; - - UniformInfo.push_back(ui); - } - - delete [] buf; - - return true; -} - - -void COpenGLSLMaterialRenderer::setBasicRenderStates(const SMaterial& material, - const SMaterial& lastMaterial, - bool resetAllRenderstates) -{ - // forward - Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); -} - - -bool COpenGLSLMaterialRenderer::setVertexShaderConstant(const c8* name, const f32* floats, int count) -{ - return setPixelShaderConstant(name, floats, count); -} - - -void COpenGLSLMaterialRenderer::setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount) -{ - os::Printer::log("Cannot set constant, please use high level shader call instead.", ELL_WARNING); -} - -bool COpenGLSLMaterialRenderer::setPixelShaderConstant(const c8* name, const f32* floats, int count) -{ - int i, num = static_cast<int>(UniformInfo.size()); - - for (i=0; i < num; ++i) - { - if (UniformInfo[i].name == name) - break; - } - - if (i == num) - return false; - -#ifdef GL_ARB_shader_objects - GLint Location=Driver->extGlGetUniformLocation(Program,name); - - switch (UniformInfo[i].type) - { - case GL_FLOAT: - Driver->extGlUniform1fv(Location, count, floats); - break; - case GL_FLOAT_VEC2_ARB: - Driver->extGlUniform2fv(Location, count/2, floats); - break; - case GL_FLOAT_VEC3_ARB: - Driver->extGlUniform3fv(Location, count/3, floats); - break; - case GL_FLOAT_VEC4_ARB: - Driver->extGlUniform4fv(Location, count/4, floats); - break; - case GL_FLOAT_MAT2_ARB: - Driver->extGlUniformMatrix2fv(Location, count/4, false, floats); - break; - case GL_FLOAT_MAT3_ARB: - Driver->extGlUniformMatrix3fv(Location, count/9, false, floats); - break; - case GL_FLOAT_MAT4_ARB: - Driver->extGlUniformMatrix4fv(Location, count/16, false, floats); - break; - default: - Driver->extGlUniform1iv(Location, count, reinterpret_cast<const GLint*>(floats)); - break; - } -#endif - - return true; -} - -void COpenGLSLMaterialRenderer::setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount) -{ - os::Printer::log("Cannot set constant, use high level shader call.", ELL_WARNING); -} - -IVideoDriver* COpenGLSLMaterialRenderer::getVideoDriver() -{ - return Driver; -} - -} // end namespace video -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/COpenGLSLMaterialRenderer.h b/irrlicht-1.6/source/Irrlicht/COpenGLSLMaterialRenderer.h deleted file mode 100644 index 4cffbefb0..000000000 --- a/irrlicht-1.6/source/Irrlicht/COpenGLSLMaterialRenderer.h +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_OPENGL_SHADER_LANGUAGE_MATERIAL_RENDERER_H_INCLUDED__ -#define __C_OPENGL_SHADER_LANGUAGE_MATERIAL_RENDERER_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_OPENGL_ - -#ifdef _IRR_WINDOWS_API_ - #define WIN32_LEAN_AND_MEAN - #include <windows.h> - #include <GL/gl.h> - #include "glext.h" -#else -#if defined(_IRR_OPENGL_USE_EXTPOINTER_) - #define GL_GLEXT_LEGACY 1 -#else - #define GL_GLEXT_PROTOTYPES 1 -#endif -#if defined(_IRR_OSX_PLATFORM_) - #include <OpenGL/gl.h> -#else - #include <GL/gl.h> -#endif -#if defined(_IRR_OPENGL_USE_EXTPOINTER_) - #include "glext.h" -#endif -#endif - - -#include "IMaterialRenderer.h" -#include "IMaterialRendererServices.h" -#include "IGPUProgrammingServices.h" -#include "irrArray.h" -#include "irrString.h" - -namespace irr -{ -namespace video -{ - -class COpenGLDriver; -class IShaderConstantSetCallBack; - -//! Class for using GLSL shaders with OpenGL -//! Please note: This renderer implements its own IMaterialRendererServices -class COpenGLSLMaterialRenderer : public IMaterialRenderer, public IMaterialRendererServices -{ -public: - - //! Constructor - COpenGLSLMaterialRenderer( - COpenGLDriver* driver, - s32& outMaterialTypeNr, - const c8* vertexShaderProgram, - const c8* vertexShaderEntryPointName, - E_VERTEX_SHADER_TYPE vsCompileTarget, - const c8* pixelShaderProgram, - const c8* pixelShaderEntryPointName, - E_PIXEL_SHADER_TYPE psCompileTarget, - IShaderConstantSetCallBack* callback, - IMaterialRenderer* baseMaterial, - s32 userData); - - //! Destructor - virtual ~COpenGLSLMaterialRenderer(); - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services); - - virtual bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype); - - virtual void OnUnsetMaterial(); - - //! Returns if the material is transparent. - virtual bool isTransparent() const; - - // implementations for the render services - virtual void setBasicRenderStates(const SMaterial& material, const SMaterial& lastMaterial, bool resetAllRenderstates); - virtual bool setVertexShaderConstant(const c8* name, const f32* floats, int count); - virtual void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1); - virtual bool setPixelShaderConstant(const c8* name, const f32* floats, int count); - virtual void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1); - virtual IVideoDriver* getVideoDriver(); - -protected: - - //! constructor only for use by derived classes who want to - //! create a fall back material for example. - COpenGLSLMaterialRenderer(COpenGLDriver* driver, - IShaderConstantSetCallBack* callback, - IMaterialRenderer* baseMaterial, - s32 userData=0); - - void init(s32& outMaterialTypeNr, - const c8* vertexShaderProgram, - const c8* pixelShaderProgram); - - bool createProgram(); - bool createShader(GLenum shaderType, const char* shader); - bool linkProgram(); - - COpenGLDriver* Driver; - IShaderConstantSetCallBack* CallBack; - IMaterialRenderer* BaseMaterial; - - struct SUniformInfo - { - core::stringc name; - GLenum type; - }; - - GLhandleARB Program; - core::array<SUniformInfo> UniformInfo; - s32 UserData; -}; - - -} // end namespace video -} // end namespace irr - -#endif // compile with OpenGL -#endif // if included - diff --git a/irrlicht-1.6/source/Irrlicht/COpenGLShaderMaterialRenderer.cpp b/irrlicht-1.6/source/Irrlicht/COpenGLShaderMaterialRenderer.cpp deleted file mode 100644 index aa7767920..000000000 --- a/irrlicht-1.6/source/Irrlicht/COpenGLShaderMaterialRenderer.cpp +++ /dev/null @@ -1,311 +0,0 @@ -// Copyright (C) 2002-2009 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_OPENGL_ - -#include "COpenGLShaderMaterialRenderer.h" -#include "IGPUProgrammingServices.h" -#include "IShaderConstantSetCallBack.h" -#include "IVideoDriver.h" -#include "os.h" -#include "COpenGLDriver.h" - -namespace irr -{ -namespace video -{ - - -//! Constructor -COpenGLShaderMaterialRenderer::COpenGLShaderMaterialRenderer(video::COpenGLDriver* driver, - s32& outMaterialTypeNr, const c8* vertexShaderProgram, const c8* pixelShaderProgram, - IShaderConstantSetCallBack* callback, IMaterialRenderer* baseMaterial, s32 userData) - : Driver(driver), CallBack(callback), BaseMaterial(baseMaterial), - VertexShader(0), UserData(userData) -{ - #ifdef _DEBUG - setDebugName("COpenGLShaderMaterialRenderer"); - #endif - - PixelShader.set_used(4); - for (u32 i=0; i<4; ++i) - { - PixelShader[i]=0; - } - - if (BaseMaterial) - BaseMaterial->grab(); - - if (CallBack) - CallBack->grab(); - - init(outMaterialTypeNr, vertexShaderProgram, pixelShaderProgram, EVT_STANDARD); -} - - -//! constructor only for use by derived classes who want to -//! create a fall back material for example. -COpenGLShaderMaterialRenderer::COpenGLShaderMaterialRenderer(COpenGLDriver* driver, - IShaderConstantSetCallBack* callback, - IMaterialRenderer* baseMaterial, s32 userData) -: Driver(driver), CallBack(callback), BaseMaterial(baseMaterial), - VertexShader(0), UserData(userData) -{ - PixelShader.set_used(4); - for (u32 i=0; i<4; ++i) - { - PixelShader[i]=0; - } - - if (BaseMaterial) - BaseMaterial->grab(); - - if (CallBack) - CallBack->grab(); -} - - -//! Destructor -COpenGLShaderMaterialRenderer::~COpenGLShaderMaterialRenderer() -{ - if (CallBack) - CallBack->drop(); - - if (VertexShader) - Driver->extGlDeletePrograms(1, &VertexShader); - - for (u32 i=0; i<PixelShader.size(); ++i) - if (PixelShader[i]) - Driver->extGlDeletePrograms(1, &PixelShader[i]); - - if (BaseMaterial) - BaseMaterial->drop(); -} - - -void COpenGLShaderMaterialRenderer::init(s32& outMaterialTypeNr, const c8* vertexShaderProgram, - const c8* pixelShaderProgram, E_VERTEX_TYPE type) -{ - outMaterialTypeNr = -1; - - bool success; - - // create vertex shader - success=createVertexShader(vertexShaderProgram); - - // create pixel shader - if (!createPixelShader(pixelShaderProgram) || !success) - return; - - // register as a new material - outMaterialTypeNr = Driver->addMaterialRenderer(this); -} - - -bool COpenGLShaderMaterialRenderer::OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype) -{ - // call callback to set shader constants - if (CallBack && (VertexShader || PixelShader[0])) - CallBack->OnSetConstants(service, UserData); - - return true; -} - - -void COpenGLShaderMaterialRenderer::OnSetMaterial(const video::SMaterial& material, const video::SMaterial& lastMaterial, - bool resetAllRenderstates, video::IMaterialRendererServices* services) -{ - if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) - { -#ifdef GL_ARB_vertex_program - if (VertexShader) - { - // set new vertex shader - Driver->extGlBindProgram(GL_VERTEX_PROGRAM_ARB, VertexShader); - glEnable(GL_VERTEX_PROGRAM_ARB); - } -#endif - - // set new pixel shader -#ifdef GL_ARB_fragment_program - if (PixelShader[0]) - { - if (!material.FogEnable) - { - Driver->extGlBindProgram(GL_FRAGMENT_PROGRAM_ARB, PixelShader[0]); - } - else - { - GLint curFogMode; - glGetIntegerv(GL_FOG_MODE, &curFogMode); -// if (Driver->LinearFog && PixelShader[1]) - if (curFogMode==GL_LINEAR && PixelShader[1]) - Driver->extGlBindProgram(GL_FRAGMENT_PROGRAM_ARB, PixelShader[1]); -// else if (!Driver->LinearFog && PixelShader[2]) - else if (curFogMode==GL_EXP && PixelShader[2]) - Driver->extGlBindProgram(GL_FRAGMENT_PROGRAM_ARB, PixelShader[2]); - else if (curFogMode==GL_EXP2 && PixelShader[3]) - Driver->extGlBindProgram(GL_FRAGMENT_PROGRAM_ARB, PixelShader[3]); - else - Driver->extGlBindProgram(GL_FRAGMENT_PROGRAM_ARB, PixelShader[0]); - } - glEnable(GL_FRAGMENT_PROGRAM_ARB); - } -#endif - - if (BaseMaterial) - BaseMaterial->OnSetMaterial(material, material, true, services); - } - - //let callback know used material - if (CallBack) - CallBack->OnSetMaterial(material); - - for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i) - Driver->setActiveTexture(i, material.getTexture(i)); - Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); -} - - -void COpenGLShaderMaterialRenderer::OnUnsetMaterial() -{ - // disable vertex shader -#ifdef GL_ARB_vertex_program - if (VertexShader) - glDisable(GL_VERTEX_PROGRAM_ARB); -#endif - -#ifdef GL_ARB_fragment_program - if (PixelShader[0]) - glDisable(GL_FRAGMENT_PROGRAM_ARB); -#endif - - if (BaseMaterial) - BaseMaterial->OnUnsetMaterial(); -} - - -//! Returns if the material is transparent. -bool COpenGLShaderMaterialRenderer::isTransparent() const -{ - return BaseMaterial ? BaseMaterial->isTransparent() : false; -} - - -// This method needs a properly cleaned error state before the checked instruction is called -bool COpenGLShaderMaterialRenderer::checkError(const irr::c8* type) -{ -#ifdef GL_ARB_vertex_program - GLenum g = glGetError(); - if (g != GL_NO_ERROR) - { - GLint errPos; - glGetIntegerv( GL_PROGRAM_ERROR_POSITION_ARB, &errPos ); - - core::stringc errString = type; - errString += " compilation failed at position "; - errString += core::stringc(s32(errPos)); - errString += ":\n"; - errString += reinterpret_cast<const char*>(glGetString(GL_PROGRAM_ERROR_STRING_ARB)); - - os::Printer::log(errString.c_str(), ELL_ERROR); - return true; - } -#endif - return false; -} - - -bool COpenGLShaderMaterialRenderer::createPixelShader(const c8* pxsh) -{ - if (!pxsh) - return true; - - const core::stringc inshdr(pxsh); - core::stringc shdr; - const s32 pos = inshdr.find("#_IRR_FOG_MODE_"); - const u32 numShaders = (-1 != pos)?4:1; - - for (u32 i=0; i<numShaders; ++i) - { - if (i==0) - { - shdr=inshdr; - } - else - { - shdr = inshdr.subString(0, pos); - switch (i) { - case 1: shdr += "OPTION ARB_fog_linear;"; break; - case 2: shdr += "OPTION ARB_fog_exp;"; break; - case 3: shdr += "OPTION ARB_fog_exp2;"; break; - } - shdr += inshdr.subString(pos+16, inshdr.size()-pos-16); - } -#ifdef GL_ARB_fragment_program - Driver->extGlGenPrograms(1, &PixelShader[i]); - Driver->extGlBindProgram(GL_FRAGMENT_PROGRAM_ARB, PixelShader[i]); - - // clear error buffer - while(glGetError() != GL_NO_ERROR) - {} - - // compile - Driver->extGlProgramString(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, - shdr.size(), shdr.c_str()); - - if (checkError("Pixel shader")) - { - Driver->extGlDeletePrograms(1, &PixelShader[i]); - PixelShader[i]=0; - - return false; - } -#else - return false; -#endif - } - - return true; -} - - -bool COpenGLShaderMaterialRenderer::createVertexShader(const c8* vtxsh) -{ - if (!vtxsh) - return true; - -#ifdef GL_ARB_vertex_program - Driver->extGlGenPrograms(1, &VertexShader); - Driver->extGlBindProgram(GL_VERTEX_PROGRAM_ARB, VertexShader); - - // clear error buffer - while(glGetError() != GL_NO_ERROR) - {} - - // compile - Driver->extGlProgramString(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, - (GLsizei)strlen(vtxsh), vtxsh); - - if (checkError("Vertex shader")) - { - Driver->extGlDeletePrograms(1, &VertexShader); - VertexShader=0; - - return false; - } -#else - return false; -#endif - - return true; -} - - -} // end namespace video -} // end namespace irr - - -#endif diff --git a/irrlicht-1.6/source/Irrlicht/COpenGLShaderMaterialRenderer.h b/irrlicht-1.6/source/Irrlicht/COpenGLShaderMaterialRenderer.h deleted file mode 100644 index bf1824518..000000000 --- a/irrlicht-1.6/source/Irrlicht/COpenGLShaderMaterialRenderer.h +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_OPENGL_SHADER_MATERIAL_RENDERER_H_INCLUDED__ -#define __C_OPENGL_SHADER_MATERIAL_RENDERER_H_INCLUDED__ - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_OPENGL_ - -#if defined(_IRR_OPENGL_USE_EXTPOINTER_) - #define GL_GLEXT_LEGACY 1 -#else - #define GL_GLEXT_PROTOTYPES 1 -#endif -#ifdef _IRR_WINDOWS_API_ - #define WIN32_LEAN_AND_MEAN - #include <windows.h> - #include <GL/gl.h> -#elif defined(_IRR_OSX_PLATFORM_) - #include <OpenGL/gl.h> -#elif defined(_IRR_COMPILE_WITH_SDL_DEVICE_) - #define NO_SDL_GLEXT - #include <SDL/SDL_video.h> - #include <SDL/SDL_opengl.h> -#else - #include <GL/gl.h> -#endif - -#include "IMaterialRenderer.h" - -namespace irr -{ -namespace video -{ - -class COpenGLDriver; -class IShaderConstantSetCallBack; -class IMaterialRenderer; - -//! Class for using vertex and pixel shaders with OpenGL -class COpenGLShaderMaterialRenderer : public IMaterialRenderer -{ -public: - - //! Constructor - COpenGLShaderMaterialRenderer(COpenGLDriver* driver, - s32& outMaterialTypeNr, const c8* vertexShaderProgram, const c8* pixelShaderProgram, - IShaderConstantSetCallBack* callback, IMaterialRenderer* baseMaterial, s32 userData); - - //! Destructor - virtual ~COpenGLShaderMaterialRenderer(); - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services); - - virtual bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype); - - virtual void OnUnsetMaterial(); - - //! Returns if the material is transparent. - virtual bool isTransparent() const; - -protected: - - //! constructor only for use by derived classes who want to - //! create a fall back material for example. - COpenGLShaderMaterialRenderer(COpenGLDriver* driver, - IShaderConstantSetCallBack* callback, - IMaterialRenderer* baseMaterial, s32 userData=0); - - // must not be called more than once! - void init(s32& outMaterialTypeNr, const c8* vertexShaderProgram, - const c8* pixelShaderProgram, E_VERTEX_TYPE type); - - bool createPixelShader(const c8* pxsh); - bool createVertexShader(const c8* vtxsh); - bool checkError(const irr::c8* type); - - COpenGLDriver* Driver; - IShaderConstantSetCallBack* CallBack; - IMaterialRenderer* BaseMaterial; - - GLuint VertexShader; - // We have 4 values here, [0] is the non-fog version, the other three are - // ARB_fog_linear, ARB_fog_exp, and ARB_fog_exp2 in that order - core::array<GLuint> PixelShader; - s32 UserData; -}; - - -} // end namespace video -} // end namespace irr - -#endif -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/COpenGLTexture.cpp b/irrlicht-1.6/source/Irrlicht/COpenGLTexture.cpp deleted file mode 100644 index ec83d74a6..000000000 --- a/irrlicht-1.6/source/Irrlicht/COpenGLTexture.cpp +++ /dev/null @@ -1,827 +0,0 @@ -// Copyright (C) 2002-2009 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_OPENGL_ - -#include "irrTypes.h" -#include "COpenGLTexture.h" -#include "COpenGLDriver.h" -#include "os.h" -#include "CImage.h" -#include "CColorConverter.h" - -#include "irrString.h" - -namespace irr -{ -namespace video -{ - -//! constructor for usual textures -COpenGLTexture::COpenGLTexture(IImage* origImage, const io::path& name, COpenGLDriver* driver) - : ITexture(name), ColorFormat(ECF_A8R8G8B8), Driver(driver), Image(0), - TextureName(0), InternalFormat(GL_RGBA), PixelFormat(GL_BGRA_EXT), - PixelType(GL_UNSIGNED_BYTE), - IsRenderTarget(false), AutomaticMipmapUpdate(false), - ReadOnlyLock(false), KeepImage(true) -{ - #ifdef _DEBUG - setDebugName("COpenGLTexture"); - #endif - - HasMipMaps = Driver->getTextureCreationFlag(ETCF_CREATE_MIP_MAPS); - getImageData(origImage); - - glGenTextures(1, &TextureName); - - if (ImageSize==TextureSize) - Image = new CImage(ColorFormat, origImage); - else - { - Image = new CImage(ColorFormat, TextureSize); - // scale texture - origImage->copyToScaling(Image); - } - copyTexture(); - if (!KeepImage) - { - Image->drop(); - Image=0; - } -} - -//! constructor for basic setup (only for derived classes) -COpenGLTexture::COpenGLTexture(const io::path& name, COpenGLDriver* driver) - : ITexture(name), ColorFormat(ECF_A8R8G8B8), Driver(driver), Image(0), - TextureName(0), InternalFormat(GL_RGBA), PixelFormat(GL_BGRA_EXT), - PixelType(GL_UNSIGNED_BYTE), - HasMipMaps(true), IsRenderTarget(false), AutomaticMipmapUpdate(false), - ReadOnlyLock(false), KeepImage(true) -{ - #ifdef _DEBUG - setDebugName("COpenGLTexture"); - #endif -} - - -//! destructor -COpenGLTexture::~COpenGLTexture() -{ - if (TextureName) - glDeleteTextures(1, &TextureName); - if (Image) - Image->drop(); -} - - -ECOLOR_FORMAT COpenGLTexture::getBestColorFormat(ECOLOR_FORMAT format) -{ - ECOLOR_FORMAT destFormat = ECF_A8R8G8B8; - switch (format) - { - case ECF_A1R5G5B5: - if (!Driver->getTextureCreationFlag(ETCF_ALWAYS_32_BIT)) - destFormat = ECF_A1R5G5B5; - break; - case ECF_R5G6B5: - if (!Driver->getTextureCreationFlag(ETCF_ALWAYS_32_BIT)) - destFormat = ECF_A1R5G5B5; - break; - case ECF_A8R8G8B8: - if (Driver->getTextureCreationFlag(ETCF_ALWAYS_16_BIT) || - Driver->getTextureCreationFlag(ETCF_OPTIMIZED_FOR_SPEED)) - destFormat = ECF_A1R5G5B5; - break; - case ECF_R8G8B8: - if (Driver->getTextureCreationFlag(ETCF_ALWAYS_16_BIT) || - Driver->getTextureCreationFlag(ETCF_OPTIMIZED_FOR_SPEED)) - destFormat = ECF_A1R5G5B5; - default: - break; - } - if (Driver->getTextureCreationFlag(ETCF_NO_ALPHA_CHANNEL)) - { - switch (destFormat) - { - case ECF_A1R5G5B5: - destFormat = ECF_R5G6B5; - break; - case ECF_A8R8G8B8: - destFormat = ECF_R8G8B8; - break; - default: - break; - } - } - return destFormat; -} - - -void COpenGLTexture::getImageData(IImage* image) -{ - if (!image) - { - os::Printer::log("No image for OpenGL texture.", ELL_ERROR); - return; - } - - ImageSize = image->getDimension(); - - if ( !ImageSize.Width || !ImageSize.Height) - { - os::Printer::log("Invalid size of image for OpenGL Texture.", ELL_ERROR); - return; - } - - const f32 ratio = (f32)ImageSize.Width/(f32)ImageSize.Height; - if ((ImageSize.Width>Driver->MaxTextureSize) && (ratio >= 1.0f)) - { - ImageSize.Width = Driver->MaxTextureSize; - ImageSize.Height = (u32)(Driver->MaxTextureSize/ratio); - } - else if (ImageSize.Height>Driver->MaxTextureSize) - { - ImageSize.Height = Driver->MaxTextureSize; - ImageSize.Width = (u32)(Driver->MaxTextureSize*ratio); - } - TextureSize=ImageSize.getOptimalSize(!Driver->queryFeature(EVDF_TEXTURE_NPOT)); - - ColorFormat = getBestColorFormat(image->getColorFormat()); -} - - -//! copies the the texture into an open gl texture. -void COpenGLTexture::copyTexture(bool newTexture) -{ - if (!Image) - { - os::Printer::log("No image for OpenGL texture to upload", ELL_ERROR); - return; - } - - switch (ColorFormat) - { - case ECF_A1R5G5B5: - InternalFormat=GL_RGBA; - PixelFormat=GL_BGRA_EXT; - PixelType=GL_UNSIGNED_SHORT_1_5_5_5_REV; - break; - case ECF_R5G6B5: - InternalFormat=GL_RGB; - PixelFormat=GL_BGR; - PixelType=GL_UNSIGNED_SHORT_5_6_5_REV; - break; - case ECF_R8G8B8: - InternalFormat=GL_RGB; - PixelFormat=GL_BGR; - PixelType=GL_UNSIGNED_BYTE; - break; - case ECF_A8R8G8B8: - InternalFormat=GL_RGBA; - PixelFormat=GL_BGRA_EXT; - if (Driver->Version > 101) - PixelType=GL_UNSIGNED_INT_8_8_8_8_REV; - break; - default: - os::Printer::log("Unsupported texture format", ELL_ERROR); - break; - } - - Driver->setActiveTexture(0, this); - if (Driver->testGLError()) - os::Printer::log("Could not bind Texture", ELL_ERROR); - - if (newTexture) - { -#ifndef DISABLE_MIPMAPPING -#ifdef GL_SGIS_generate_mipmap - if (HasMipMaps && Driver->queryFeature(EVDF_MIP_MAP_AUTO_UPDATE)) - { - if (Driver->getTextureCreationFlag(ETCF_OPTIMIZED_FOR_SPEED)) - glHint(GL_GENERATE_MIPMAP_HINT_SGIS, GL_FASTEST); - else if (Driver->getTextureCreationFlag(ETCF_OPTIMIZED_FOR_QUALITY)) - glHint(GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST); - else - glHint(GL_GENERATE_MIPMAP_HINT_SGIS, GL_DONT_CARE); - // automatically generate and update mipmaps - glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE ); - AutomaticMipmapUpdate=true; - } - else -#endif - { - AutomaticMipmapUpdate=false; - regenerateMipMapLevels(); - } - if (HasMipMaps) // might have changed in regenerateMipMapLevels - { - // enable bilinear mipmap filter - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - } - else - #else - HasMipMaps=false; - os::Printer::log("Did not create OpenGL texture mip maps.", ELL_ERROR); - #endif - { - // enable bilinear filter without mipmaps - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - } - } - - void* source = Image->lock(); - if (newTexture) - glTexImage2D(GL_TEXTURE_2D, 0, InternalFormat, Image->getDimension().Width, - Image->getDimension().Height, 0, PixelFormat, PixelType, source); - else - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, Image->getDimension().Width, - Image->getDimension().Height, PixelFormat, PixelType, source); - Image->unlock(); - - if (Driver->testGLError()) - os::Printer::log("Could not glTexImage2D", ELL_ERROR); -} - - -//! lock function -void* COpenGLTexture::lock(bool readOnly) -{ - ReadOnlyLock |= readOnly; - - if (!Image || IsRenderTarget) - { - // prepare the data storage if necessary - if (!Image) - Image = new CImage(ECF_A8R8G8B8, ImageSize); - if (!Image) - return 0; - - u8* pPixels = static_cast<u8*>(Image->lock()); - if (!pPixels) - { - return 0; - } - // we need to keep the correct texture bound... - GLint tmpTexture; - glGetIntegerv(GL_TEXTURE_BINDING_2D, &tmpTexture); - glBindTexture(GL_TEXTURE_2D, TextureName); - - // allows to read pixels in top-to-bottom order -#ifdef GL_MESA_pack_invert - if (Driver->queryOpenGLFeature(COpenGLExtensionHandler::IRR_MESA_pack_invert)) - glPixelStorei(GL_PACK_INVERT_MESA, GL_TRUE); -#endif - - glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, pPixels); - -#ifdef GL_MESA_pack_invert - if (Driver->queryOpenGLFeature(COpenGLExtensionHandler::IRR_MESA_pack_invert)) - glPixelStorei(GL_PACK_INVERT_MESA, GL_FALSE); - else -#endif - { - // opengl images are horizontally flipped, so we have to fix that here. - const s32 pitch=Image->getPitch(); - u8* p2 = pPixels + (ImageSize.Height - 1) * pitch; - u8* tmpBuffer = new u8[pitch]; - for (u32 i=0; i < ImageSize.Height; i += 2) - { - memcpy(tmpBuffer, pPixels, pitch); - memcpy(pPixels, p2, pitch); - memcpy(p2, tmpBuffer, pitch); - pPixels += pitch; - p2 -= pitch; - } - delete [] tmpBuffer; - } - Image->unlock(); - - //reset old bound texture - glBindTexture(GL_TEXTURE_2D, tmpTexture); - } - return Image->lock(); -} - - -//! unlock function -void COpenGLTexture::unlock() -{ - if (!Image) - return; - Image->unlock(); - if (!ReadOnlyLock) - copyTexture(false); - ReadOnlyLock = false; - if (!KeepImage) - { - Image->drop(); - Image=0; - } -} - - -//! Returns size of the original image. -const core::dimension2d<u32>& COpenGLTexture::getOriginalSize() const -{ - return ImageSize; -} - - -//! Returns size of the texture. -const core::dimension2d<u32>& COpenGLTexture::getSize() const -{ - return TextureSize; -} - - -//! returns driver type of texture, i.e. the driver, which created the texture -E_DRIVER_TYPE COpenGLTexture::getDriverType() const -{ - return EDT_OPENGL; -} - - -//! returns color format of texture -ECOLOR_FORMAT COpenGLTexture::getColorFormat() const -{ - return ColorFormat; -} - - -//! returns pitch of texture (in bytes) -u32 COpenGLTexture::getPitch() const -{ - if (Image) - return Image->getPitch(); - else - return 0; -} - - -//! return open gl texture name -GLuint COpenGLTexture::getOpenGLTextureName() const -{ - return TextureName; -} - - -//! Returns whether this texture has mipmaps -//! return true if texture has mipmaps -bool COpenGLTexture::hasMipMaps() const -{ - return HasMipMaps; -} - - -//! Regenerates the mip map levels of the texture. Useful after locking and -//! modifying the texture -void COpenGLTexture::regenerateMipMapLevels() -{ - if (AutomaticMipmapUpdate || !HasMipMaps || !Image) - return; - if ((Image->getDimension().Width==1) && (Image->getDimension().Height==1)) - return; - - // Manually create mipmaps - u32 width=Image->getDimension().Width; - u32 height=Image->getDimension().Height; - u32 i=0; - u8* target = new u8[Image->getImageDataSizeInBytes()]; - do - { - if (width>1) - width>>=1; - if (height>1) - height>>=1; - ++i; - Image->copyToScaling(target, width, height, Image->getColorFormat()); - glTexImage2D(GL_TEXTURE_2D, i, InternalFormat, width, height, - 0, PixelFormat, PixelType, target); - } - while (width!=1 || height!=1); - delete [] target; - Image->unlock(); -} - - -bool COpenGLTexture::isRenderTarget() const -{ - return IsRenderTarget; -} - - -void COpenGLTexture::setIsRenderTarget(bool isTarget) -{ - IsRenderTarget = isTarget; -} - - -bool COpenGLTexture::isFrameBufferObject() const -{ - return false; -} - - -//! Bind Render Target Texture -void COpenGLTexture::bindRTT() -{ -} - - -//! Unbind Render Target Texture -void COpenGLTexture::unbindRTT() -{ - Driver->setActiveTexture(0, this); - - // Copy Our ViewPort To The Texture - glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, getSize().Width, getSize().Height); -} - - -/* FBO Textures */ - -// helper function for render to texture -static bool checkFBOStatus(COpenGLDriver* Driver); - -//! RTT ColorFrameBuffer constructor -COpenGLFBOTexture::COpenGLFBOTexture(const core::dimension2d<u32>& size, - const io::path& name, - COpenGLDriver* driver, - const ECOLOR_FORMAT format) - : COpenGLTexture(name, driver), DepthTexture(0), ColorFrameBuffer(0) -{ - #ifdef _DEBUG - setDebugName("COpenGLTexture_FBO"); - #endif - - ImageSize = size; - TextureSize = size; - - GLint FilteringType; - InternalFormat = getOpenGLFormatAndParametersFromColorFormat(format, FilteringType, PixelFormat, PixelType); - - HasMipMaps = false; - IsRenderTarget = true; - -#ifdef GL_EXT_framebuffer_object - // generate frame buffer - Driver->extGlGenFramebuffers(1, &ColorFrameBuffer); - Driver->extGlBindFramebuffer(GL_FRAMEBUFFER_EXT, ColorFrameBuffer); - - // generate color texture - glGenTextures(1, &TextureName); - Driver->setActiveTexture(0, this); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, FilteringType); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexImage2D(GL_TEXTURE_2D, 0, InternalFormat, ImageSize.Width, - ImageSize.Height, 0, PixelFormat, PixelType, 0); - - // attach color texture to frame buffer - Driver->extGlFramebufferTexture2D(GL_FRAMEBUFFER_EXT, - GL_COLOR_ATTACHMENT0_EXT, - GL_TEXTURE_2D, - TextureName, - 0); -#endif - unbindRTT(); -} - -GLint COpenGLFBOTexture::getOpenGLFormatAndParametersFromColorFormat(ECOLOR_FORMAT format, - GLint& filtering, - GLenum& colorformat, - GLenum& type) -{ - // default - filtering = GL_LINEAR; - colorformat = GL_RGBA; - type = GL_UNSIGNED_BYTE; - - switch(format) - { - // Floating Point texture formats. Thanks to Patryk "Nadro" Nadrowski. - case ECF_R16F: - { -#ifdef GL_ARB_texture_rg - filtering = GL_NEAREST; - colorformat = GL_RED; - type = GL_FLOAT; - - return GL_R16F; -#else - return GL_RGB8; -#endif - } - case ECF_G16R16F: - { -#ifdef GL_ARB_texture_rg - filtering = GL_NEAREST; - colorformat = GL_RG; - type = GL_FLOAT; - - return GL_RG16F; -#else - return GL_RGB8; -#endif - } - case ECF_A16B16G16R16F: - { -#ifdef GL_ARB_texture_rg - filtering = GL_NEAREST; - colorformat = GL_RGBA; - type = GL_FLOAT; - - return GL_RGBA16F_ARB; -#else - return GL_RGBA8; -#endif - } - case ECF_R32F: - { -#ifdef GL_ARB_texture_rg - filtering = GL_NEAREST; - colorformat = GL_RED; - type = GL_FLOAT; - - return GL_R32F; -#else - return GL_RGB8; -#endif - } - case ECF_G32R32F: - { -#ifdef GL_ARB_texture_rg - filtering = GL_NEAREST; - colorformat = GL_RG; - type = GL_FLOAT; - - return GL_RG32F; -#else - return GL_RGB8; -#endif - } - case ECF_A32B32G32R32F: - { -#ifdef GL_ARB_texture_float - filtering = GL_NEAREST; - colorformat = GL_RGBA; - type = GL_FLOAT; - - return GL_RGBA32F_ARB; -#else - return GL_RGBA8; -#endif - } - default: - { - return GL_RGBA8; - } - } -} - - -//! destructor -COpenGLFBOTexture::~COpenGLFBOTexture() -{ - if (DepthTexture) - if (DepthTexture->drop()) - Driver->removeDepthTexture(DepthTexture); - if (ColorFrameBuffer) - Driver->extGlDeleteFramebuffers(1, &ColorFrameBuffer); -} - - -bool COpenGLFBOTexture::isFrameBufferObject() const -{ - return true; -} - - -//! Bind Render Target Texture -void COpenGLFBOTexture::bindRTT() -{ -#ifdef GL_EXT_framebuffer_object - if (ColorFrameBuffer != 0) - Driver->extGlBindFramebuffer(GL_FRAMEBUFFER_EXT, ColorFrameBuffer); -#endif -} - - -//! Unbind Render Target Texture -void COpenGLFBOTexture::unbindRTT() -{ -#ifdef GL_EXT_framebuffer_object - if (ColorFrameBuffer != 0) - Driver->extGlBindFramebuffer(GL_FRAMEBUFFER_EXT, 0); -#endif -} - - -/* FBO Depth Textures */ - -//! RTT DepthBuffer constructor -COpenGLFBODepthTexture::COpenGLFBODepthTexture( - const core::dimension2d<u32>& size, - const io::path& name, - COpenGLDriver* driver, - bool useStencil) - : COpenGLFBOTexture(size, name, driver), DepthRenderBuffer(0), - StencilRenderBuffer(0), UseStencil(useStencil) -{ -#ifdef _DEBUG - setDebugName("COpenGLTextureFBO_Depth"); -#endif - - ImageSize = size; - TextureSize = size; - InternalFormat = GL_RGBA; - PixelFormat = GL_RGBA; - PixelType = GL_UNSIGNED_BYTE; - HasMipMaps = false; - - if (useStencil) - { - glGenTextures(1, &DepthRenderBuffer); - glBindTexture(GL_TEXTURE_2D, DepthRenderBuffer); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); -#ifdef GL_EXT_packed_depth_stencil - if (Driver->queryOpenGLFeature(COpenGLExtensionHandler::IRR_EXT_packed_depth_stencil)) - { - // generate packed depth stencil texture - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_STENCIL_EXT, ImageSize.Width, - ImageSize.Height, 0, GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, 0); - StencilRenderBuffer = DepthRenderBuffer; // stencil is packed with depth - } - else // generate separate stencil and depth textures -#endif - { - // generate depth texture - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, ImageSize.Width, - ImageSize.Height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, 0); - - // we 're in trouble! the code below does not complete - // the FBO currently... stencil buffer is only - // supported with EXT_packed_depth_stencil extension - // (above) - -// // generate stencil texture -// glGenTextures(1, &StencilRenderBuffer); -// glBindTexture(GL_TEXTURE_2D, StencilRenderBuffer); -// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); -// glTexImage2D(GL_TEXTURE_2D, 0, GL_STENCIL_INDEX, ImageSize.Width, -// ImageSize.Height, 0, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, 0); -// glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); -// glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - } - } -#ifdef GL_EXT_framebuffer_object - else - { - // generate depth buffer - Driver->extGlGenRenderbuffers(1, &DepthRenderBuffer); - Driver->extGlBindRenderbuffer(GL_RENDERBUFFER_EXT, DepthRenderBuffer); - Driver->extGlRenderbufferStorage(GL_RENDERBUFFER_EXT, - GL_DEPTH_COMPONENT, ImageSize.Width, - ImageSize.Height); - } -#endif -} - - -//! destructor -COpenGLFBODepthTexture::~COpenGLFBODepthTexture() -{ - if (DepthRenderBuffer && UseStencil) - glDeleteTextures(1, &DepthRenderBuffer); - else - Driver->extGlDeleteRenderbuffers(1, &DepthRenderBuffer); - if (StencilRenderBuffer && StencilRenderBuffer != DepthRenderBuffer) - glDeleteTextures(1, &StencilRenderBuffer); -} - - -//combine depth texture and rtt -bool COpenGLFBODepthTexture::attach(ITexture* renderTex) -{ - if (!renderTex) - return false; - video::COpenGLFBOTexture* rtt = static_cast<video::COpenGLFBOTexture*>(renderTex); - rtt->bindRTT(); -#ifdef GL_EXT_framebuffer_object - if (UseStencil) - { - // attach stencil texture to stencil buffer - Driver->extGlFramebufferTexture2D(GL_FRAMEBUFFER_EXT, - GL_STENCIL_ATTACHMENT_EXT, - GL_TEXTURE_2D, - StencilRenderBuffer, - 0); - - // attach depth texture to depth buffer - Driver->extGlFramebufferTexture2D(GL_FRAMEBUFFER_EXT, - GL_DEPTH_ATTACHMENT_EXT, - GL_TEXTURE_2D, - DepthRenderBuffer, - 0); - } - else - { - // attach depth renderbuffer to depth buffer - Driver->extGlFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, - GL_DEPTH_ATTACHMENT_EXT, - GL_RENDERBUFFER_EXT, - DepthRenderBuffer); - } -#endif - // check the status - if (!checkFBOStatus(Driver)) - { - os::Printer::log("FBO incomplete"); - return false; - } - rtt->DepthTexture=this; - grab(); // grab the depth buffer, not the RTT - rtt->unbindRTT(); - return true; -} - - -//! Bind Render Target Texture -void COpenGLFBODepthTexture::bindRTT() -{ -} - - -//! Unbind Render Target Texture -void COpenGLFBODepthTexture::unbindRTT() -{ -} - - -bool checkFBOStatus(COpenGLDriver* Driver) -{ -#ifdef GL_EXT_framebuffer_object - GLenum status = Driver->extGlCheckFramebufferStatus(GL_FRAMEBUFFER_EXT); - - switch (status) - { - //Our FBO is perfect, return true - case GL_FRAMEBUFFER_COMPLETE_EXT: - return true; - - case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: - os::Printer::log("FBO has invalid read buffer", ELL_ERROR); - break; - - case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT: - os::Printer::log("FBO has invalid draw buffer", ELL_ERROR); - break; - - case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: - os::Printer::log("FBO has one or several incomplete image attachments", ELL_ERROR); - break; - - case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT: - os::Printer::log("FBO has one or several image attachments with different internal formats", ELL_ERROR); - break; - - case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: - os::Printer::log("FBO has one or several image attachments with different dimensions", ELL_ERROR); - break; - -// not part of fbo_object anymore, but won't harm as it is just a return value -#ifdef GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT - case GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT: - os::Printer::log("FBO has a duplicate image attachment", ELL_ERROR); - break; -#endif - - case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT: - os::Printer::log("FBO missing an image attachment", ELL_ERROR); - break; - - case GL_FRAMEBUFFER_UNSUPPORTED_EXT: - os::Printer::log("FBO format unsupported", ELL_ERROR); - break; - - default: - break; - } -#endif - os::Printer::log("FBO error", ELL_ERROR); - return false; -} - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_OPENGL_ - diff --git a/irrlicht-1.6/source/Irrlicht/COpenGLTexture.h b/irrlicht-1.6/source/Irrlicht/COpenGLTexture.h deleted file mode 100644 index 505be762c..000000000 --- a/irrlicht-1.6/source/Irrlicht/COpenGLTexture.h +++ /dev/null @@ -1,199 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_OPEN_GL_TEXTURE_H_INCLUDED__ -#define __C_OPEN_GL_TEXTURE_H_INCLUDED__ - -#include "ITexture.h" -#include "IImage.h" - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_OPENGL_ - -#if defined(_IRR_OPENGL_USE_EXTPOINTER_) - #define GL_GLEXT_LEGACY 1 -#else - #define GL_GLEXT_PROTOTYPES 1 -#endif -#ifdef _IRR_WINDOWS_API_ - // include windows headers for HWND - #define WIN32_LEAN_AND_MEAN - #include <windows.h> - #include <GL/gl.h> -#ifdef _MSC_VER - #pragma comment(lib, "OpenGL32.lib") -#endif -#elif defined(_IRR_OSX_PLATFORM_) - #include <OpenGL/gl.h> -#elif defined(_IRR_COMPILE_WITH_SDL_DEVICE_) - #define NO_SDL_GLEXT - #include <SDL/SDL_video.h> - #include <SDL/SDL_opengl.h> -#else - #if defined(_IRR_OSX_PLATFORM_) - #include <OpenGL/gl.h> - #else - #include <GL/gl.h> - #endif -#endif - - -namespace irr -{ -namespace video -{ - -class COpenGLDriver; -//! OpenGL texture. -class COpenGLTexture : public ITexture -{ -public: - - //! constructor - COpenGLTexture(IImage* surface, const io::path& name, COpenGLDriver* driver=0); - - //! destructor - virtual ~COpenGLTexture(); - - //! lock function - virtual void* lock(bool readOnly = false); - - //! unlock function - virtual void unlock(); - - //! Returns original size of the texture (image). - virtual const core::dimension2d<u32>& getOriginalSize() const; - - //! Returns size of the texture. - virtual const core::dimension2d<u32>& getSize() const; - - //! returns driver type of texture (=the driver, that created it) - virtual E_DRIVER_TYPE getDriverType() const; - - //! returns color format of texture - virtual ECOLOR_FORMAT getColorFormat() const; - - //! returns pitch of texture (in bytes) - virtual u32 getPitch() const; - - //! return open gl texture name - GLuint getOpenGLTextureName() const; - - //! return whether this texture has mipmaps - virtual bool hasMipMaps() const; - - //! Regenerates the mip map levels of the texture. Useful after - //! locking and modifying the texture - virtual void regenerateMipMapLevels(); - - //! Is it a render target? - virtual bool isRenderTarget() const; - - //! Is it a FrameBufferObject? - virtual bool isFrameBufferObject() const; - - //! Bind RenderTargetTexture - virtual void bindRTT(); - - //! Unbind RenderTargetTexture - virtual void unbindRTT(); - - //! sets whether this texture is intended to be used as a render target. - void setIsRenderTarget(bool isTarget); - -protected: - - //! protected constructor with basic setup, no GL texture name created, for derived classes - COpenGLTexture(const io::path& name, COpenGLDriver* driver); - - //! get the desired color format based on texture creation flags and the input format. - ECOLOR_FORMAT getBestColorFormat(ECOLOR_FORMAT format); - - //! convert the image into an internal image with better properties for this driver. - void getImageData(IImage* image); - - //! copies the texture into an OpenGL texture. - //! \param: newTexture is true if method is called from a newly created texture for the first time. Otherwise call with false to improve memory handling. - void copyTexture(bool newTexture=true); - - core::dimension2d<u32> ImageSize; - core::dimension2d<u32> TextureSize; - ECOLOR_FORMAT ColorFormat; - s32 Pitch; - COpenGLDriver* Driver; - IImage* Image; - - GLuint TextureName; - GLint InternalFormat; - GLenum PixelFormat; - GLenum PixelType; - - bool HasMipMaps; - bool IsRenderTarget; - bool AutomaticMipmapUpdate; - bool ReadOnlyLock; - bool KeepImage; -}; - -//! OpenGL FBO texture. -class COpenGLFBOTexture : public COpenGLTexture -{ -public: - - //! FrameBufferObject constructor - COpenGLFBOTexture(const core::dimension2d<u32>& size, const io::path& name, - COpenGLDriver* driver = 0, const ECOLOR_FORMAT format = ECF_UNKNOWN); - - //! destructor - virtual ~COpenGLFBOTexture(); - - //! Is it a FrameBufferObject? - virtual bool isFrameBufferObject() const; - - //! Bind RenderTargetTexture - virtual void bindRTT(); - - //! Unbind RenderTargetTexture - virtual void unbindRTT(); - - ITexture* DepthTexture; -protected: - GLint getOpenGLFormatAndParametersFromColorFormat( - ECOLOR_FORMAT format, GLint& filtering, GLenum& colorformat, GLenum& type); - - GLuint ColorFrameBuffer; -}; - - -//! OpenGL FBO depth texture. -class COpenGLFBODepthTexture : public COpenGLFBOTexture -{ -public: - //! FrameBufferObject depth constructor - COpenGLFBODepthTexture(const core::dimension2d<u32>& size, const io::path& name, COpenGLDriver* driver=0, bool useStencil=false); - - //! destructor - virtual ~COpenGLFBODepthTexture(); - - //! Bind RenderTargetTexture - virtual void bindRTT(); - - //! Unbind RenderTargetTexture - virtual void unbindRTT(); - - bool attach(ITexture*); - -protected: - GLuint DepthRenderBuffer; - GLuint StencilRenderBuffer; - bool UseStencil; -}; - - -} // end namespace video -} // end namespace irr - -#endif -#endif // _IRR_COMPILE_WITH_OPENGL_ - diff --git a/irrlicht-1.6/source/Irrlicht/CPLYMeshFileLoader.cpp b/irrlicht-1.6/source/Irrlicht/CPLYMeshFileLoader.cpp deleted file mode 100644 index 9cff36b39..000000000 --- a/irrlicht-1.6/source/Irrlicht/CPLYMeshFileLoader.cpp +++ /dev/null @@ -1,789 +0,0 @@ -// Copyright (C) 2009 Gaz Davidson -// 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_PLY_LOADER_ - -#include "CPLYMeshFileLoader.h" -#include "IMeshManipulator.h" -#include "SMesh.h" -#include "CDynamicMeshBuffer.h" -#include "SAnimatedMesh.h" -#include "IReadFile.h" -#include "fast_atof.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - -// input buffer must be at least twice as long as the longest line in the file -#define PLY_INPUT_BUFFER_SIZE 51200 // file is loaded in 50k chunks - -// constructor -CPLYMeshFileLoader::CPLYMeshFileLoader() -: File(0), Buffer(0) -{ -} - -CPLYMeshFileLoader::~CPLYMeshFileLoader() -{ - // delete the buffer in case we didn't earlier - // (we do, but this could be disabled to increase the speed of loading hundreds of meshes) - if (Buffer) - { - delete [] Buffer; - Buffer = 0; - } - - // Destroy the element list if it exists - for (u32 i=0; i<ElementList.size(); ++i) - delete ElementList[i]; - ElementList.clear(); -} - -//! returns true if the file maybe is able to be loaded by this class -bool CPLYMeshFileLoader::isALoadableFileExtension(const io::path& filename) const -{ - return core::hasFileExtension(filename, "ply"); -} - - -//! creates/loads an animated mesh from the file. -IAnimatedMesh* CPLYMeshFileLoader::createMesh(io::IReadFile* file) -{ - if (!file) - return 0; - - File = file; - File->grab(); - - // attempt to allocate the buffer and fill with data - if (!allocateBuffer()) - { - File->drop(); - File = 0; - return 0; - } - - // start with empty mesh - SAnimatedMesh* animMesh = 0; - u32 vertCount=0; - - // Currently only supports ASCII meshes - if (strcmp(getNextLine(), "ply")) - { - os::Printer::log("Not a valid PLY file", file->getFileName().c_str(), ELL_ERROR); - } - else - { - // cut the next line out - c8 *line = getNextLine(); - // grab the word from this line - c8 *word = getNextWord(); - - // ignore comments - while (strcmp(word, "comment") == 0) - { - line = getNextLine(); - word = getNextWord(); - } - - bool readingHeader = true; - bool continueReading = true; - IsBinaryFile = false; - IsWrongEndian= false; - - do - { - if (strcmp(word, "format") == 0) - { - word = getNextWord(); - - if (strcmp(word, "binary_little_endian") == 0) - { - IsBinaryFile = true; -#ifdef __BIG_ENDIAN__ - IsWrongEndian = true; -#endif - - } - else if (strcmp(word, "binary_big_endian") == 0) - { - IsBinaryFile = true; -#ifndef __BIG_ENDIAN__ - IsWrongEndian = true; -#endif - } - else if (strcmp(word, "ascii")) - { - // abort if this isn't an ascii or a binary mesh - os::Printer::log("Unsupported PLY mesh format", word, ELL_ERROR); - continueReading = false; - } - - if (continueReading) - { - word = getNextWord(); - if (strcmp(word, "1.0")) - { - os::Printer::log("Unsupported PLY mesh version", word, ELL_WARNING); - } - } - } - else if (strcmp(word, "property") == 0) - { - word = getNextWord(); - - if (!ElementList.size()) - { - os::Printer::log("PLY property found before element", word, ELL_WARNING); - } - else - { - // get element - SPLYElement* el = ElementList[ElementList.size()-1]; - - // fill property struct - SPLYProperty prop; - prop.Type = getPropertyType(word); - el->KnownSize += prop.size(); - - if (prop.Type == EPLYPT_LIST) - { - el->IsFixedWidth = false; - - word = getNextWord(); - - prop.Data.List.CountType = getPropertyType(word); - if (IsBinaryFile && prop.Data.List.CountType == EPLYPT_UNKNOWN) - { - os::Printer::log("Cannot read binary PLY file containing data types of unknown length", word, ELL_ERROR); - continueReading = false; - } - else - { - word = getNextWord(); - prop.Data.List.ItemType = getPropertyType(word); - if (IsBinaryFile && prop.Data.List.ItemType == EPLYPT_UNKNOWN) - { - os::Printer::log("Cannot read binary PLY file containing data types of unknown length", word, ELL_ERROR); - continueReading = false; - } - } - } - else if (IsBinaryFile && prop.Type == EPLYPT_UNKNOWN) - { - os::Printer::log("Cannot read binary PLY file containing data types of unknown length", word, ELL_ERROR); - continueReading = false; - } - - prop.Name = getNextWord(); - - // add property to element - el->Properties.push_back(prop); - } - } - else if (strcmp(word, "element") == 0) - { - SPLYElement* el = new SPLYElement; - el->Name = getNextWord(); - el->Count = atoi(getNextWord()); - el->IsFixedWidth = true; - el->KnownSize = 0; - ElementList.push_back(el); - - if (el->Name == "vertex") - vertCount = el->Count; - - } - else if (strcmp(word, "end_header") == 0) - { - readingHeader = false; - if (IsBinaryFile) - { - StartPointer = LineEndPointer + 1; - } - } - else if (strcmp(word, "comment") == 0) - { - // ignore line - } - else - { - os::Printer::log("Unknown item in PLY file", word, ELL_WARNING); - } - - if (readingHeader && continueReading) - { - line = getNextLine(); - word = getNextWord(); - } - } - while (readingHeader && continueReading); - - // now to read the actual data from the file - if (continueReading) - { - // create a mesh buffer - CDynamicMeshBuffer *mb = new CDynamicMeshBuffer(video::EVT_STANDARD, vertCount > 65565 ? video::EIT_32BIT : video::EIT_16BIT); - mb->getVertexBuffer().reallocate(vertCount); - mb->getIndexBuffer().reallocate(vertCount); - mb->setHardwareMappingHint(EHM_STATIC); - - // loop through each of the elements - for (u32 i=0; i<ElementList.size(); ++i) - { - // do we want this element type? - if (ElementList[i]->Name == "vertex") - { - // loop through vertex properties - for (u32 j=0; j < ElementList[i]->Count; ++j) - readVertex(*ElementList[i], mb); - } - else if (ElementList[i]->Name == "face") - { - // read faces - for (u32 j=0; j < ElementList[i]->Count; ++j) - readFace(*ElementList[i], mb); - } - else - { - // skip these elements - for (u32 j=0; j < ElementList[i]->Count; ++j) - skipElement(*ElementList[i]); - } - } - mb->recalculateBoundingBox(); - SMesh* m = new SMesh(); - m->addMeshBuffer(mb); - m->recalculateBoundingBox(); - mb->drop(); - animMesh = new SAnimatedMesh(); - animMesh->addMesh(m); - animMesh->recalculateBoundingBox(); - m->drop(); - } - } - - - // free the buffer - delete [] Buffer; - Buffer = 0; - File->drop(); - File = 0; - - // if we managed to create a mesh, return it - return animMesh; -} - -bool CPLYMeshFileLoader::readVertex(const SPLYElement &Element, scene::CDynamicMeshBuffer* mb) -{ - if (!IsBinaryFile) - getNextLine(); - - video::S3DVertex vert; - vert.Color.set(255,255,255,255); - vert.TCoords.X = 0.0f; - vert.TCoords.Y = 0.0f; - vert.Normal.X = 0.0f; - vert.Normal.Y = 1.0f; - vert.Normal.Z = 0.0f; - - for (u32 i=0; i < Element.Properties.size(); ++i) - { - E_PLY_PROPERTY_TYPE t = Element.Properties[i].Type; - - if (Element.Properties[i].Name == "x") - vert.Pos.X = getFloat(t); - else if (Element.Properties[i].Name == "y") - vert.Pos.Z = getFloat(t); - else if (Element.Properties[i].Name == "z") - vert.Pos.Y = getFloat(t); - else if (Element.Properties[i].Name == "nx") - vert.Normal.X = getFloat(t); - else if (Element.Properties[i].Name == "ny") - vert.Normal.Z = getFloat(t); - else if (Element.Properties[i].Name == "nz") - vert.Normal.Y = getFloat(t); - else if (Element.Properties[i].Name == "u") - vert.TCoords.X = getFloat(t); - else if (Element.Properties[i].Name == "v") - vert.TCoords.Y = getFloat(t); - else if (Element.Properties[i].Name == "red") - { - u32 value = Element.Properties[i].isFloat() ? (u32)(getFloat(t)*255.0f) : getInt(t); - vert.Color.setRed(value); - } - else if (Element.Properties[i].Name == "green") - { - u32 value = Element.Properties[i].isFloat() ? (u32)(getFloat(t)*255.0f) : getInt(t); - vert.Color.setGreen(value); - } - else if (Element.Properties[i].Name == "blue") - { - u32 value = Element.Properties[i].isFloat() ? (u32)(getFloat(t)*255.0f) : getInt(t); - vert.Color.setBlue(value); - } - else if (Element.Properties[i].Name == "alpha") - { - u32 value = Element.Properties[i].isFloat() ? (u32)(getFloat(t)*255.0f) : getInt(t); - vert.Color.setAlpha(value); - } - else - skipProperty(Element.Properties[i]); - } - - mb->getVertexBuffer().push_back(vert); - - return true; -} - -bool CPLYMeshFileLoader::readFace(const SPLYElement &Element, scene::CDynamicMeshBuffer* mb) -{ - if (!IsBinaryFile) - getNextLine(); - - for (u32 i=0; i < Element.Properties.size(); ++i) - { - if ( (Element.Properties[i].Name == "vertex_indices" || - Element.Properties[i].Name == "vertex_index") && Element.Properties[i].Type == EPLYPT_LIST) - { - // get count - s32 count = getInt(Element.Properties[i].Data.List.CountType); - u32 a = getInt(Element.Properties[i].Data.List.ItemType), - b = getInt(Element.Properties[i].Data.List.ItemType), - c = getInt(Element.Properties[i].Data.List.ItemType); - s32 j = 3; - - mb->getIndexBuffer().push_back(a); - mb->getIndexBuffer().push_back(c); - mb->getIndexBuffer().push_back(b); - - for (; j < count; ++j) - { - b = c; - c = getInt(Element.Properties[i].Data.List.ItemType); - mb->getIndexBuffer().push_back(a); - mb->getIndexBuffer().push_back(c); - mb->getIndexBuffer().push_back(b); - } - } - else if (Element.Properties[i].Name == "intensity") - { - // todo: face intensity - skipProperty(Element.Properties[i]); - } - else - skipProperty(Element.Properties[i]); - } - return true; -} - -// skips an element and all properties. return false on EOF -void CPLYMeshFileLoader::skipElement(const SPLYElement &Element) -{ - if (IsBinaryFile) - if (Element.IsFixedWidth) - moveForward(Element.KnownSize); - else - for (u32 i=0; i < Element.Properties.size(); ++i) - skipProperty(Element.Properties[i]); - else - getNextLine(); -} - -void CPLYMeshFileLoader::skipProperty(const SPLYProperty &Property) -{ - if (Property.Type == EPLYPT_LIST) - { - s32 count = getInt(Property.Data.List.CountType); - - for (s32 i=0; i < count; ++i) - getInt(Property.Data.List.CountType); - } - else - { - if (IsBinaryFile) - moveForward(Property.size()); - else - getNextWord(); - } -} - - -bool CPLYMeshFileLoader::allocateBuffer() -{ - // Destroy the element list if it exists - for (u32 i=0; i<ElementList.size(); ++i) - delete ElementList[i]; - ElementList.clear(); - - if (!Buffer) - Buffer = new c8[PLY_INPUT_BUFFER_SIZE]; - - // not enough memory? - if (!Buffer) - return false; - - // blank memory - memset(Buffer, 0, PLY_INPUT_BUFFER_SIZE); - - StartPointer = Buffer; - EndPointer = Buffer; - LineEndPointer = Buffer-1; - WordLength = -1; - EndOfFile = false; - - // get data from the file - fillBuffer(); - - return true; -} - -// gets more data from the file. returns false on EOF -void CPLYMeshFileLoader::fillBuffer() -{ - if (EndOfFile) - return; - - u32 length = EndPointer - StartPointer; - if (length && StartPointer != Buffer) - { - // copy the remaining data to the start of the buffer - memcpy(Buffer, StartPointer, length); - } - // reset start position - StartPointer = Buffer; - EndPointer = StartPointer + length; - - if (File->getPos() == File->getSize()) - { - EndOfFile = true; - } - else - { - // read data from the file - u32 count = File->read(EndPointer, PLY_INPUT_BUFFER_SIZE - length); - - // increment the end pointer by the number of bytes read - EndPointer = EndPointer + count; - - // if we didn't completely fill the buffer - if (count != PLY_INPUT_BUFFER_SIZE - length) - { - // blank the rest of the memory - memset(EndPointer, 0, Buffer + PLY_INPUT_BUFFER_SIZE - EndPointer); - - // end of file - EndOfFile = true; - } - } -} - -// skips x bytes in the file, getting more data if required -void CPLYMeshFileLoader::moveForward(u32 bytes) -{ - if (StartPointer + bytes >= EndPointer) - fillBuffer(); - if (StartPointer + bytes < EndPointer) - StartPointer += bytes; - else - StartPointer = EndPointer; -} - -E_PLY_PROPERTY_TYPE CPLYMeshFileLoader::getPropertyType(const c8* typeString) const -{ - if (strcmp(typeString, "char") == 0 || - strcmp(typeString, "uchar") == 0 || - strcmp(typeString, "int8") == 0 || - strcmp(typeString, "uint8") == 0) - { - return EPLYPT_INT8; - } - else if (strcmp(typeString, "uint") == 0 || - strcmp(typeString, "int16") == 0 || - strcmp(typeString, "uint16") == 0 || - strcmp(typeString, "short") == 0 || - strcmp(typeString, "ushort") == 0) - { - return EPLYPT_INT16; - } - else if (strcmp(typeString, "int") == 0 || - strcmp(typeString, "long") == 0 || - strcmp(typeString, "ulong") == 0 || - strcmp(typeString, "int32") == 0 || - strcmp(typeString, "uint32") == 0) - { - return EPLYPT_INT32; - } - else if (strcmp(typeString, "float") == 0 || - strcmp(typeString, "float32") == 0) - { - return EPLYPT_FLOAT32; - } - else if (strcmp(typeString, "float64") == 0 || - strcmp(typeString, "double") == 0) - { - return EPLYPT_FLOAT64; - } - else if ( strcmp(typeString, "list") == 0 ) - { - return EPLYPT_LIST; - } - else - { - // unsupported type. - // cannot be loaded in binary mode - return EPLYPT_UNKNOWN; - } -} - - -// Split the string data into a line in place by terminating it instead of copying. -c8* CPLYMeshFileLoader::getNextLine() -{ - // move the start pointer along - StartPointer = LineEndPointer + 1; - - // crlf split across buffer move - if (*StartPointer == '\n') - { - *StartPointer = '\0'; - ++StartPointer; - } - - // begin at the start of the next line - c8* pos = StartPointer; - while (pos < EndPointer && *pos && *pos != '\r' && *pos != '\n') - ++pos; - - if ( pos < EndPointer && ( *(pos+1) == '\r' || *(pos+1) == '\n') ) - { - *pos = '\0'; - ++pos; - } - - // we have reached the end of the buffer - if (pos >= EndPointer) - { - // get data from the file - if (!EndOfFile) - { - fillBuffer(); - // reset line end pointer - LineEndPointer = StartPointer - 1; - - if (StartPointer != EndPointer) - return getNextLine(); - else - return Buffer; - } - else - { - // EOF - StartPointer = EndPointer-1; - *StartPointer = '\0'; - return StartPointer; - } - } - else - { - // null terminate the string in place - *pos = '\0'; - LineEndPointer = pos; - WordLength = -1; - // return pointer to the start of the line - return StartPointer; - } -} -// null terminate the next word on the previous line and move the next word pointer along -// since we already have a full line in the buffer, we never need to retrieve more data -c8* CPLYMeshFileLoader::getNextWord() -{ - // move the start pointer along - StartPointer += WordLength + 1; - - if (StartPointer == LineEndPointer) - { - WordLength = -1; // - return LineEndPointer; - } - // begin at the start of the next word - c8* pos = StartPointer; - while (*pos && pos < LineEndPointer && pos < EndPointer && *pos != ' ' && *pos != '\t') - ++pos; - - while(*pos && pos < LineEndPointer && pos < EndPointer && (*pos == ' ' || *pos == '\t') ) - { - // null terminate the string in place - *pos = '\0'; - ++pos; - } - --pos; - WordLength = pos-StartPointer; - // return pointer to the start of the word - return StartPointer; -} -// read the next float from the file and move the start pointer along -f32 CPLYMeshFileLoader::getFloat(E_PLY_PROPERTY_TYPE t) -{ - f32 retVal = 0.0f; - - if (IsBinaryFile) - { - if (EndPointer - StartPointer < 8) - fillBuffer(); - - if (EndPointer - StartPointer > 0) - { - switch (t) - { - case EPLYPT_INT8: - retVal = *StartPointer; - StartPointer++; - break; - case EPLYPT_INT16: - if (IsWrongEndian) - retVal = os::Byteswap::byteswap(*(reinterpret_cast<s16*>(StartPointer))); - else - retVal = *(reinterpret_cast<s16*>(StartPointer)); - StartPointer += 2; - break; - case EPLYPT_INT32: - if (IsWrongEndian) - retVal = f32(os::Byteswap::byteswap(*(reinterpret_cast<s32*>(StartPointer)))); - else - retVal = f32(*(reinterpret_cast<s32*>(StartPointer))); - StartPointer += 4; - break; - case EPLYPT_FLOAT32: - if (IsWrongEndian) - retVal = os::Byteswap::byteswap(*(reinterpret_cast<f32*>(StartPointer))); - else - retVal = *(reinterpret_cast<f32*>(StartPointer)); - StartPointer += 4; - break; - case EPLYPT_FLOAT64: - // todo: byteswap 64-bit - retVal = f32(*(reinterpret_cast<f64*>(StartPointer))); - StartPointer += 8; - break; - case EPLYPT_LIST: - case EPLYPT_UNKNOWN: - default: - retVal = 0.0f; - StartPointer++; // ouch! - } - } - else - retVal = 0.0f; - } - else - { - c8* word = getNextWord(); - switch (t) - { - case EPLYPT_INT8: - case EPLYPT_INT16: - case EPLYPT_INT32: - retVal = f32(atoi(word)); - break; - case EPLYPT_FLOAT32: - case EPLYPT_FLOAT64: - retVal = f32(atof(word)); - break; - case EPLYPT_LIST: - case EPLYPT_UNKNOWN: - default: - retVal = 0.0f; - } - } - return retVal; -} -// read the next int from the file and move the start pointer along -u32 CPLYMeshFileLoader::getInt(E_PLY_PROPERTY_TYPE t) -{ - u32 retVal = 0; - - if (IsBinaryFile) - { - if (!EndOfFile && EndPointer - StartPointer < 8) - fillBuffer(); - - if (EndPointer - StartPointer) - { - switch (t) - { - case EPLYPT_INT8: - retVal = *StartPointer; - StartPointer++; - break; - case EPLYPT_INT16: - if (IsWrongEndian) - retVal = os::Byteswap::byteswap(*(reinterpret_cast<u16*>(StartPointer))); - else - retVal = *(reinterpret_cast<u16*>(StartPointer)); - StartPointer += 2; - break; - case EPLYPT_INT32: - if (IsWrongEndian) - retVal = os::Byteswap::byteswap(*(reinterpret_cast<s32*>(StartPointer))); - else - retVal = *(reinterpret_cast<s32*>(StartPointer)); - StartPointer += 4; - break; - case EPLYPT_FLOAT32: - if (IsWrongEndian) - retVal = (u32)os::Byteswap::byteswap(*(reinterpret_cast<f32*>(StartPointer))); - else - retVal = (u32)(*(reinterpret_cast<f32*>(StartPointer))); - StartPointer += 4; - break; - case EPLYPT_FLOAT64: - // todo: byteswap 64-bit - retVal = (u32)(*(reinterpret_cast<f64*>(StartPointer))); - StartPointer += 8; - break; - case EPLYPT_LIST: - case EPLYPT_UNKNOWN: - default: - retVal = 0; - StartPointer++; // ouch! - } - } - else - retVal = 0; - } - else - { - c8* word = getNextWord(); - switch (t) - { - case EPLYPT_INT8: - case EPLYPT_INT16: - case EPLYPT_INT32: - retVal = atoi(word); - break; - case EPLYPT_FLOAT32: - case EPLYPT_FLOAT64: - retVal = u32(atof(word)); - break; - case EPLYPT_LIST: - case EPLYPT_UNKNOWN: - default: - retVal = 0; - } - } - return retVal; -} - - - -} // end namespace scene -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_PLY_LOADER_ - diff --git a/irrlicht-1.6/source/Irrlicht/CPLYMeshFileLoader.h b/irrlicht-1.6/source/Irrlicht/CPLYMeshFileLoader.h deleted file mode 100644 index 5f4524458..000000000 --- a/irrlicht-1.6/source/Irrlicht/CPLYMeshFileLoader.h +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright (C) 2009 Gaz Davidson -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_PLY_MESH_FILE_LOADER_H_INCLUDED__ -#define __C_PLY_MESH_FILE_LOADER_H_INCLUDED__ - -#include "IMeshLoader.h" -#include "CDynamicMeshBuffer.h" - -namespace irr -{ -namespace scene -{ - -enum E_PLY_PROPERTY_TYPE -{ - EPLYPT_INT8 = 0, - EPLYPT_INT16, - EPLYPT_INT32, - EPLYPT_FLOAT32, - EPLYPT_FLOAT64, - EPLYPT_LIST, - EPLYPT_UNKNOWN -}; - -//! Meshloader capable of loading obj meshes. -class CPLYMeshFileLoader : public IMeshLoader -{ -public: - - //! Constructor - CPLYMeshFileLoader(); - - //! Destructor - virtual ~CPLYMeshFileLoader(); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".ply") - virtual bool isALoadableFileExtension(const io::path& filename) const; - - //! creates/loads an animated mesh from the file. - virtual IAnimatedMesh* createMesh(io::IReadFile* file); - -private: - - struct SPLYProperty - { - core::stringc Name; - E_PLY_PROPERTY_TYPE Type; - union - { - u8 Int8; - u16 Int16; - u32 Int32; - f32 Float32; - f64 Double; - struct SPLYListProperty - { - E_PLY_PROPERTY_TYPE CountType; - E_PLY_PROPERTY_TYPE ItemType; - } List; - - } Data; - - inline u32 size() const - { - switch(Type) - { - case EPLYPT_INT8: - return 1; - case EPLYPT_INT16: - return 2; - case EPLYPT_INT32: - case EPLYPT_FLOAT32: - return 4; - case EPLYPT_FLOAT64: - return 8; - case EPLYPT_LIST: - case EPLYPT_UNKNOWN: - default: - return 0; - } - } - - inline bool isFloat() const - { - switch(Type) - { - case EPLYPT_FLOAT32: - case EPLYPT_FLOAT64: - return true; - case EPLYPT_INT8: - case EPLYPT_INT16: - case EPLYPT_INT32: - case EPLYPT_LIST: - case EPLYPT_UNKNOWN: - default: - return false; - } - } - }; - - struct SPLYElement - { - // name of the element. We only want "vertex" and "face" elements - // but we have to parse the others anyway. - core::stringc Name; - // The number of elements in the file - u32 Count; - // Properties of this element - core::array<SPLYProperty> Properties; - // in binary files, true if this is a fixed size - bool IsFixedWidth; - // known size in bytes, 0 if unknown - u32 KnownSize; - }; - - bool allocateBuffer(); - c8* getNextLine(); - c8* getNextWord(); - void fillBuffer(); - E_PLY_PROPERTY_TYPE getPropertyType(const c8* typeString) const; - - bool readVertex(const SPLYElement &Element, scene::CDynamicMeshBuffer* mb); - bool readFace(const SPLYElement &Element, scene::CDynamicMeshBuffer* mb); - void skipElement(const SPLYElement &Element); - void skipProperty(const SPLYProperty &Property); - f32 getFloat(E_PLY_PROPERTY_TYPE t); - u32 getInt(E_PLY_PROPERTY_TYPE t); - void moveForward(u32 bytes); - - core::array<SPLYElement*> ElementList; - - io::IReadFile *File; - c8 *Buffer; - bool IsBinaryFile, IsWrongEndian, EndOfFile; - s32 LineLength, WordLength; - c8 *StartPointer, *EndPointer, *LineEndPointer; -}; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CPLYMeshWriter.cpp b/irrlicht-1.6/source/Irrlicht/CPLYMeshWriter.cpp deleted file mode 100644 index a6e8617c6..000000000 --- a/irrlicht-1.6/source/Irrlicht/CPLYMeshWriter.cpp +++ /dev/null @@ -1,183 +0,0 @@ -// Copyright (C) 2008-2009 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_PLY_WRITER_ - -#include "CPLYMeshWriter.h" -#include "os.h" -#include "IMesh.h" -#include "IMeshBuffer.h" -#include "IWriteFile.h" - -namespace irr -{ -namespace scene -{ - -CPLYMeshWriter::CPLYMeshWriter() -{ - #ifdef _DEBUG - setDebugName("CPLYMeshWriter"); - #endif -} - - -//! Returns the type of the mesh writer -EMESH_WRITER_TYPE CPLYMeshWriter::getType() const -{ - return EMWT_PLY; -} - -//! writes a mesh -bool CPLYMeshWriter::writeMesh(io::IWriteFile* file, scene::IMesh* mesh, s32 flags) -{ - if (!file || !mesh) - return false; - - os::Printer::log("Writing mesh", file->getFileName()); - - // write PLY header - core::stringc header = - "ply\n" - "format ascii 1.0\n" - "comment Irrlicht Engine "; - header += IRRLICHT_SDK_VERSION; - - // get vertex and triangle counts - u32 VertexCount = 0; - u32 TriangleCount = 0; - - for (u32 i=0; i < mesh->getMeshBufferCount(); ++i) - { - VertexCount += mesh->getMeshBuffer(i)->getVertexCount(); - TriangleCount += mesh->getMeshBuffer(i)->getIndexCount() / 3; - } - - // vertex definition - header += "\nelement vertex "; - header += VertexCount; - - header += "\n" - "property float x\n" - "property float y\n" - "property float z\n" - "property float nx\n" - "property float ny\n" - "property float nz\n"; - // todo: writer flags for extended (r,g,b,u,v) and non-standard (alpha,u1,uv,tx,ty,tz) properties - // "property uchar red\n" - // "property uchar green\n" - // "property uchar blue\n" - // "property uchar alpha\n" - // "property float u\n" - // "property float v\n"; - // "property float u1\n - // "property float v1\n" - // "property float tx\n" - // "property float ty\n" - // "property float tz\n" - - // face definition - - header += "element face "; - header += TriangleCount; - header += "\n" - "property list uchar int vertex_indices\n" - "end_header\n"; - - // write header - file->write(header.c_str(), header.size()); - - // write vertices - - c8 outLine[1024]; - - for (u32 i=0; i < mesh->getMeshBufferCount(); ++i) - { - scene::IMeshBuffer* mb = mesh->getMeshBuffer(i); - for (u32 j=0; j < mb->getVertexCount(); ++j) - { - const core::vector3df& pos = mb->getPosition(j); - const core::vector3df& n = mb->getNormal(j); -// const core::vector2df& tc = mb->getTCoords(j); - - u8 *buf = (u8*)mb->getVertices(); - switch(mb->getVertexType()) - { - case video::EVT_STANDARD: - buf += sizeof(video::S3DVertex)*j; - break; - case video::EVT_2TCOORDS: - buf += sizeof(video::S3DVertex2TCoords)*j; - break; - case video::EVT_TANGENTS: - buf += sizeof(video::S3DVertexTangents)*j; - break; - } -// video::SColor &col = ( (video::S3DVertex*)buf )->Color; - - // x y z nx ny nz red green blue alpha u v [u1 v1 | tx ty tz]\n - snprintf(outLine, 1024, - "%f %f %f %f %f %f\n",// %u %u %u %u %f %f\n", - pos.X, pos.Z, pos.Y, // Y and Z are flipped - n.X, n.Z, n.Y); - /*col.getRed(), col.getGreen(), col.getBlue(), col.getAlpha(), - tc.X, tc.Y);*/ - - // write the line - file->write(outLine, strlen(outLine)); - } - } - - // index of the first vertex in the current mesh buffer - u32 StartOffset = 0; - - // write triangles - for (u32 i=0; i < mesh->getMeshBufferCount(); ++i) - { - scene::IMeshBuffer* mb = mesh->getMeshBuffer(i); - for (u32 j=0; j < mb->getIndexCount(); j+=3) - { - // y and z are flipped so triangles are reversed - u32 a=StartOffset, - b=StartOffset, - c=StartOffset; - - switch(mb->getIndexType()) - { - case video::EIT_16BIT: - a += mb->getIndices()[j+0]; - c += mb->getIndices()[j+1]; - b += mb->getIndices()[j+2]; - break; - case video::EIT_32BIT: - a += ((u32*)mb->getIndices()) [j+0]; - c += ((u32*)mb->getIndices()) [j+0]; - b += ((u32*)mb->getIndices()) [j+0]; - break; - } - - // count a b c\n - snprintf(outLine, 1024, "3 %u %u %u\n", a, b, c); - // write the line - file->write(outLine, strlen(outLine)); - } - - // increment offset - StartOffset += mb->getVertexCount(); - } - - // all done! - - - return true; -} - -} // end namespace -} // end namespace - -#endif // _IRR_COMPILE_WITH_PLY_WRITER_ - diff --git a/irrlicht-1.6/source/Irrlicht/CPLYMeshWriter.h b/irrlicht-1.6/source/Irrlicht/CPLYMeshWriter.h deleted file mode 100644 index 1e23eed89..000000000 --- a/irrlicht-1.6/source/Irrlicht/CPLYMeshWriter.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2009 Gaz Davidson -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_PLY_MESH_WRITER_H_INCLUDED__ -#define __IRR_PLY_MESH_WRITER_H_INCLUDED__ - -#include "IMeshWriter.h" - -namespace irr -{ - -namespace scene -{ - class IMeshBuffer; - - //! class to write PLY mesh files - class CPLYMeshWriter : public IMeshWriter - { - public: - - CPLYMeshWriter(); - - //! 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); - - }; - -} // end namespace -} // end namespace - -#endif diff --git a/irrlicht-1.6/source/Irrlicht/CPakReader.cpp b/irrlicht-1.6/source/Irrlicht/CPakReader.cpp deleted file mode 100644 index 00388a438..000000000 --- a/irrlicht-1.6/source/Irrlicht/CPakReader.cpp +++ /dev/null @@ -1,192 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h -// Code contributed by skreamz - -#include "CPakReader.h" - -#ifdef __IRR_COMPILE_WITH_PAK_ARCHIVE_LOADER_ - -#include "os.h" -#include "coreutil.h" - -namespace irr -{ -namespace io -{ - -//! Constructor -CArchiveLoaderPAK::CArchiveLoaderPAK( io::IFileSystem* fs) -: FileSystem(fs) -{ - #ifdef _DEBUG - setDebugName("CArchiveLoaderPAK"); - #endif -} - - -//! returns true if the file maybe is able to be loaded by this class -bool CArchiveLoaderPAK::isALoadableFileFormat(const io::path& filename) const -{ - return core::hasFileExtension ( filename, "pak" ); -} - -//! Check to see if the loader can create archives of this type. -bool CArchiveLoaderPAK::isALoadableFileFormat(E_FILE_ARCHIVE_TYPE fileType) const -{ - return fileType == EFAT_PAK; -} - -//! Creates an archive from the filename -/** \param file File handle to check. -\return Pointer to newly created archive, or 0 upon error. */ -IFileArchive* CArchiveLoaderPAK::createArchive(const io::path& filename, bool ignoreCase, bool ignorePaths) const -{ - IFileArchive *archive = 0; - io::IReadFile* file = FileSystem->createAndOpenFile(filename); - - if (file) - { - archive = createArchive ( file, ignoreCase, ignorePaths ); - file->drop (); - } - - return archive; -} - -//! creates/loads an archive from the file. -//! \return Pointer to the created archive. Returns 0 if loading failed. -IFileArchive* CArchiveLoaderPAK::createArchive(io::IReadFile* file, bool ignoreCase, bool ignorePaths) const -{ - IFileArchive *archive = 0; - if ( file ) - { - file->seek ( 0 ); - archive = new CPakReader(file, ignoreCase, ignorePaths); - } - return archive; -} - - -//! Check if the file might be loaded by this class -/** Check might look into the file. -\param file File handle to check. -\return True if file seems to be loadable. */ -bool CArchiveLoaderPAK::isALoadableFileFormat(io::IReadFile* file) const -{ - SPAKFileHeader header; - - file->read( &header.tag, 4 ); - - return header.tag[0] == 'P' && header.tag[1] == 'A'; -} - - -/*! - PAK Reader -*/ -CPakReader::CPakReader(IReadFile* file, bool ignoreCase, bool ignorePaths) -: CFileList(file ? file->getFileName() : "", ignoreCase, ignorePaths), File(file) -{ - #ifdef _DEBUG - setDebugName("CPakReader"); - #endif - - if (File) - { - File->grab(); - - // scan local headers - scanLocalHeader(); - - sort(); - } -} - - -CPakReader::~CPakReader() -{ - if (File) - File->drop(); -} - - -const IFileList* CPakReader::getFileList() const -{ - return this; -} - -//! scans for a local header, returns false if there is no more local file header. -bool CPakReader::scanLocalHeader() -{ - - c8 tmp[1024]; - io::path PakFileName; - - memset(&header, 0, sizeof(SPAKFileHeader)); - File->read(&header, sizeof(SPAKFileHeader)); - - if (header.tag[0] != 'P' && header.tag[1] != 'A') - return false; // local file headers end here. - - File->seek(header.offset); - - const int count = header.length / ((sizeof(u32) * 2) + 56); - - for(int i = 0; i < count; i++) - { - // read filename - PakFileName.reserve(56+2); - File->read(tmp, 56); - tmp[56] = 0x0; - PakFileName = tmp; - - #ifdef _DEBUG - os::Printer::log(PakFileName.c_str()); - #endif - - s32 offset; - s32 size; - - File->read(&offset, sizeof(u32)); - File->read(&size, sizeof(u32)); - -#ifdef __BIG_ENDIAN__ - os::Byteswap::byteswap(offset); - os::Byteswap::byteswap(size); -#endif - - addItem(PakFileName, size, false, Offsets.size()); - Offsets.push_back(offset); - } - return true; -} - - -//! opens a file by file name -IReadFile* CPakReader::createAndOpenFile(const io::path& filename) -{ - s32 index = findFile(filename, false); - - if (index != -1) - return createAndOpenFile(index); - - return 0; -} - - -//! opens a file by index -IReadFile* CPakReader::createAndOpenFile(u32 index) -{ - if (index < Files.size()) - { - return createLimitReadFile(Files[index].FullName, File, Offsets[Files[index].ID], Files[index].Size); - } - else - return 0; -} - -} // end namespace io -} // end namespace irr - -#endif // __IRR_COMPILE_WITH_PAK_ARCHIVE_LOADER_ diff --git a/irrlicht-1.6/source/Irrlicht/CPakReader.h b/irrlicht-1.6/source/Irrlicht/CPakReader.h deleted file mode 100644 index 22a815863..000000000 --- a/irrlicht-1.6/source/Irrlicht/CPakReader.h +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_PAK_READER_H_INCLUDED__ -#define __C_PAK_READER_H_INCLUDED__ - -#include "IrrCompileConfig.h" - -#ifdef __IRR_COMPILE_WITH_PAK_ARCHIVE_LOADER_ - -#include "IReferenceCounted.h" -#include "IReadFile.h" -#include "irrArray.h" -#include "irrString.h" -#include "IFileSystem.h" -#include "CFileList.h" - -namespace irr -{ -namespace io -{ - struct SPAKFileHeader - { - c8 tag[4]; - u32 offset; - u32 length; - }; - - //! Archiveloader capable of loading PAK Archives - class CArchiveLoaderPAK : public IArchiveLoader - { - public: - - //! Constructor - CArchiveLoaderPAK(io::IFileSystem* fs); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".zip") - virtual bool isALoadableFileFormat(const io::path& filename) const; - - //! Check if the file might be loaded by this class - /** Check might look into the file. - \param file File handle to check. - \return True if file seems to be loadable. */ - virtual bool isALoadableFileFormat(io::IReadFile* file) const; - - //! Check to see if the loader can create archives of this type. - /** Check based on the archive type. - \param fileType The archive type to check. - \return True if the archile loader supports this type, false if not */ - virtual bool isALoadableFileFormat(E_FILE_ARCHIVE_TYPE fileType) const; - - //! Creates an archive from the filename - /** \param file File handle to check. - \return Pointer to newly created archive, or 0 upon error. */ - virtual IFileArchive* createArchive(const io::path& filename, bool ignoreCase, bool ignorePaths) const; - - //! creates/loads an archive from the file. - //! \return Pointer to the created archive. Returns 0 if loading failed. - virtual io::IFileArchive* createArchive(io::IReadFile* file, bool ignoreCase, bool ignorePaths) const; - - //! Returns the type of archive created by this loader - virtual E_FILE_ARCHIVE_TYPE getType() const { return EFAT_PAK; } - - private: - io::IFileSystem* FileSystem; - }; - - - //! reads from pak - class CPakReader : public virtual IFileArchive, virtual CFileList - { - public: - - CPakReader(IReadFile* file, bool ignoreCase, bool ignorePaths); - virtual ~CPakReader(); - - // file archive methods - - //! return the id of the file Archive - - virtual const io::path& getArchiveName() const - { - return File->getFileName(); - } - - //! opens a file by file name - virtual IReadFile* createAndOpenFile(const io::path& filename); - - //! opens a file by index - virtual IReadFile* createAndOpenFile(u32 index); - - //! returns the list of files - virtual const IFileList* getFileList() const; - - //! get the class Type - virtual E_FILE_ARCHIVE_TYPE getType() const { return EFAT_PAK; } - - private: - - //! scans for a local header, returns false if there is no more local file header. - bool scanLocalHeader(); - - //! splits filename from zip file into useful filenames and paths - //void extractFilename(SPakFileEntry* entry); - - IReadFile* File; - - SPAKFileHeader header; - - //! Contains offsets of the files from the start of the archive file - core::array<u32> Offsets; - }; - -} // end namespace io -} // end namespace irr - -#endif // __IRR_COMPILE_WITH_PAK_ARCHIVE_LOADER_ - -#endif // __C_PAK_READER_H_INCLUDED__ - diff --git a/irrlicht-1.6/source/Irrlicht/CParticleAnimatedMeshSceneNodeEmitter.cpp b/irrlicht-1.6/source/Irrlicht/CParticleAnimatedMeshSceneNodeEmitter.cpp deleted file mode 100644 index 6ecead677..000000000 --- a/irrlicht-1.6/source/Irrlicht/CParticleAnimatedMeshSceneNodeEmitter.cpp +++ /dev/null @@ -1,192 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CParticleAnimatedMeshSceneNodeEmitter.h" -#include "IAnimatedMeshSceneNode.h" -#include "IMesh.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CParticleAnimatedMeshSceneNodeEmitter::CParticleAnimatedMeshSceneNodeEmitter( - IAnimatedMeshSceneNode* node, bool useNormalDirection, - const core::vector3df& direction, f32 normalDirectionModifier, - s32 mbNumber, bool everyMeshVertex, - u32 minParticlesPerSecond, u32 maxParticlesPerSecond, - const video::SColor& minStartColor, const video::SColor& maxStartColor, - u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees, - const core::dimension2df& minStartSize, const core::dimension2df& maxStartSize ) - : Node(0), AnimatedMesh(0), BaseMesh(0), TotalVertices(0), MBCount(0), MBNumber(mbNumber), - Direction(direction), NormalDirectionModifier(normalDirectionModifier), - MinParticlesPerSecond(minParticlesPerSecond), MaxParticlesPerSecond(maxParticlesPerSecond), - MinStartColor(minStartColor), MaxStartColor(maxStartColor), - MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax), - MaxStartSize(maxStartSize), MinStartSize(minStartSize), - Time(0), Emitted(0), MaxAngleDegrees(maxAngleDegrees), - EveryMeshVertex(everyMeshVertex), UseNormalDirection(useNormalDirection) -{ - #ifdef _DEBUG - setDebugName("CParticleAnimatedMeshSceneNodeEmitter"); - #endif - setAnimatedMeshSceneNode(node); -} - - -//! Prepares an array with new particles to emitt into the system -//! and returns how much new particles there are. -s32 CParticleAnimatedMeshSceneNodeEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray) -{ - Time += timeSinceLastCall; - - const u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond); - const f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond; - const f32 everyWhatMillisecond = 1000.0f / perSecond; - - if(Time > everyWhatMillisecond) - { - Particles.set_used(0); - u32 amount = (u32)((Time / everyWhatMillisecond) + 0.5f); - Time = 0; - SParticle p; - - if(amount > MaxParticlesPerSecond * 2) - amount = MaxParticlesPerSecond * 2; - - // Get Mesh for this frame - IMesh* frameMesh = AnimatedMesh->getMesh( core::floor32(Node->getFrameNr()), - 255, Node->getStartFrame(), Node->getEndFrame() ); - for(u32 i=0; i<amount; ++i) - { - if( EveryMeshVertex ) - { - for( u32 j=0; j<frameMesh->getMeshBufferCount(); ++j ) - { - for( u32 k=0; k<frameMesh->getMeshBuffer(j)->getVertexCount(); ++k ) - { - p.pos = frameMesh->getMeshBuffer(j)->getPosition(k); - if( UseNormalDirection ) - p.vector = frameMesh->getMeshBuffer(j)->getNormal(k) / - NormalDirectionModifier; - else - p.vector = Direction; - - p.startTime = now; - - if( MaxAngleDegrees ) - { - core::vector3df tgt = p.vector; - tgt.rotateXYBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees); - tgt.rotateYZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees); - tgt.rotateXZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees); - p.vector = tgt; - } - - if(MaxLifeTime - MinLifeTime == 0) - p.endTime = now + MinLifeTime; - else - p.endTime = now + MinLifeTime + (os::Randomizer::rand() % (MaxLifeTime - MinLifeTime)); - - p.color = MinStartColor.getInterpolated( - MaxStartColor, (os::Randomizer::rand() % 100) / 100.0f); - - p.startColor = p.color; - p.startVector = p.vector; - - if (MinStartSize==MaxStartSize) - p.startSize = MinStartSize; - else - p.startSize = MinStartSize.getInterpolated( - MaxStartSize, (os::Randomizer::rand() % 100) / 100.0f); - p.size = p.startSize; - - Particles.push_back(p); - } - } - } - else - { - s32 randomMB = 0; - if( MBNumber < 0 ) - randomMB = os::Randomizer::rand() % MBCount; - else - randomMB = MBNumber; - - u32 vertexNumber = frameMesh->getMeshBuffer(randomMB)->getVertexCount(); - if (!vertexNumber) - continue; - vertexNumber = os::Randomizer::rand() % vertexNumber; - - p.pos = frameMesh->getMeshBuffer(randomMB)->getPosition(vertexNumber); - if( UseNormalDirection ) - p.vector = frameMesh->getMeshBuffer(randomMB)->getNormal(vertexNumber) / - NormalDirectionModifier; - else - p.vector = Direction; - - p.startTime = now; - - if( MaxAngleDegrees ) - { - core::vector3df tgt = Direction; - tgt.rotateXYBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees); - tgt.rotateYZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees); - tgt.rotateXZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees); - p.vector = tgt; - } - - if(MaxLifeTime - MinLifeTime == 0) - p.endTime = now + MinLifeTime; - else - p.endTime = now + MinLifeTime + (os::Randomizer::rand() % (MaxLifeTime - MinLifeTime)); - - p.color = MinStartColor.getInterpolated( - MaxStartColor, (os::Randomizer::rand() % 100) / 100.0f); - - p.startColor = p.color; - p.startVector = p.vector; - - if (MinStartSize==MaxStartSize) - p.startSize = MinStartSize; - else - p.startSize = MinStartSize.getInterpolated( - MaxStartSize, (os::Randomizer::rand() % 100) / 100.0f); - p.size = p.startSize; - - Particles.push_back(p); - } - } - - outArray = Particles.pointer(); - - return Particles.size(); - } - - return 0; -} - - -//! Set Mesh to emit particles from -void CParticleAnimatedMeshSceneNodeEmitter::setAnimatedMeshSceneNode( IAnimatedMeshSceneNode* node ) -{ - Node = node; - AnimatedMesh = node->getMesh(); - BaseMesh = AnimatedMesh->getMesh(0); - - TotalVertices = 0; - MBCount = BaseMesh->getMeshBufferCount(); - VertexPerMeshBufferList.reallocate(MBCount); - for( u32 i = 0; i < MBCount; ++i ) - { - VertexPerMeshBufferList.push_back( BaseMesh->getMeshBuffer(i)->getVertexCount() ); - TotalVertices += BaseMesh->getMeshBuffer(i)->getVertexCount(); - } -} - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CParticleAnimatedMeshSceneNodeEmitter.h b/irrlicht-1.6/source/Irrlicht/CParticleAnimatedMeshSceneNodeEmitter.h deleted file mode 100644 index d6bf9233f..000000000 --- a/irrlicht-1.6/source/Irrlicht/CParticleAnimatedMeshSceneNodeEmitter.h +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_PARTICLE_ANIMATED_MESH_SCENE_NODE_EMITTER_H_INCLUDED__ -#define __C_PARTICLE_ANIMATED_MESH_SCENE_NODE_EMITTER_H_INCLUDED__ - -#include "IParticleAnimatedMeshSceneNodeEmitter.h" -#include "irrArray.h" - -namespace irr -{ -namespace scene -{ - -//! An animated mesh emitter -class CParticleAnimatedMeshSceneNodeEmitter : public IParticleAnimatedMeshSceneNodeEmitter -{ -public: - - //! constructor - CParticleAnimatedMeshSceneNodeEmitter( - IAnimatedMeshSceneNode* node, - bool useNormalDirection = true, - const core::vector3df& direction = core::vector3df(0.0f,0.0f,-1.0f), - f32 normalDirectionModifier = 100.0f, - s32 mbNumber = -1, - bool everyMeshVertex = false, - u32 minParticlesPerSecond = 20, - u32 maxParticlesPerSecond = 40, - const video::SColor& minStartColor = video::SColor(255,0,0,0), - const video::SColor& maxStartColor = video::SColor(255,255,255,255), - u32 lifeTimeMin = 2000, - u32 lifeTimeMax = 4000, - s32 maxAngleDegrees = 0, - const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f), - const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) - ); - - //! Prepares an array with new particles to emitt into the system - //! and returns how much new particles there are. - virtual s32 emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray); - - //! Set Mesh to emit particles from - virtual void setAnimatedMeshSceneNode( IAnimatedMeshSceneNode* node ); - - //! Set whether to use vertex normal for direction, or direction specified - virtual void setUseNormalDirection( bool useNormalDirection ) { UseNormalDirection = useNormalDirection; } - - //! Set direction the emitter emits particles - virtual void setDirection( const core::vector3df& newDirection ) { Direction = newDirection; } - - //! Set the amount that the normal is divided by for getting a particles direction - virtual void setNormalDirectionModifier( f32 normalDirectionModifier ) { NormalDirectionModifier = normalDirectionModifier; } - - //! Sets whether to emit min<->max particles for every vertex per second, or to pick - //! min<->max vertices every second - virtual void setEveryMeshVertex( bool everyMeshVertex ) { EveryMeshVertex = everyMeshVertex; } - - //! Set minimum number of particles the emitter emits per second - virtual void setMinParticlesPerSecond( u32 minPPS ) { MinParticlesPerSecond = minPPS; } - - //! Set maximum number of particles the emitter emits per second - virtual void setMaxParticlesPerSecond( u32 maxPPS ) { MaxParticlesPerSecond = maxPPS; } - - //! Set minimum starting color for particles - virtual void setMinStartColor( const video::SColor& color ) { MinStartColor = color; } - - //! Set maximum starting color for particles - virtual void setMaxStartColor( const video::SColor& color ) { MaxStartColor = color; } - - //! Set the maximum starting size for particles - virtual void setMaxStartSize( const core::dimension2df& size ) { MaxStartSize = size; }; - - //! Set the minimum starting size for particles - virtual void setMinStartSize( const core::dimension2df& size ) { MinStartSize = size; }; - - //! Get Mesh we're emitting particles from - virtual const IAnimatedMeshSceneNode* getAnimatedMeshSceneNode() const { return Node; } - - //! Get whether to use vertex normal for direciton, or direction specified - virtual bool isUsingNormalDirection() const { return UseNormalDirection; } - - //! Get direction the emitter emits particles - virtual const core::vector3df& getDirection() const { return Direction; } - - //! Get the amount that the normal is divided by for getting a particles direction - virtual f32 getNormalDirectionModifier() const { return NormalDirectionModifier; } - - //! Gets whether to emit min<->max particles for every vertex per second, or to pick - //! min<->max vertices every second - virtual bool getEveryMeshVertex() const { return EveryMeshVertex; } - - //! Get the minimum number of particles the emitter emits per second - virtual u32 getMinParticlesPerSecond() const { return MinParticlesPerSecond; } - - //! Get the maximum number of particles the emitter emits per second - virtual u32 getMaxParticlesPerSecond() const { return MaxParticlesPerSecond; } - - //! Get the minimum starting color for particles - virtual const video::SColor& getMinStartColor() const { return MinStartColor; } - - //! Get the maximum starting color for particles - virtual const video::SColor& getMaxStartColor() const { return MaxStartColor; } - - //! Get the maximum starting size for particles - virtual const core::dimension2df& getMaxStartSize() const { return MaxStartSize; }; - - //! Get the minimum starting size for particles - virtual const core::dimension2df& getMinStartSize() const { return MinStartSize; }; - -private: - - IAnimatedMeshSceneNode* Node; - IAnimatedMesh* AnimatedMesh; - const IMesh* BaseMesh; - s32 TotalVertices; - u32 MBCount; - s32 MBNumber; - core::array<s32> VertexPerMeshBufferList; - - core::array<SParticle> Particles; - core::vector3df Direction; - f32 NormalDirectionModifier; - u32 MinParticlesPerSecond, MaxParticlesPerSecond; - video::SColor MinStartColor, MaxStartColor; - u32 MinLifeTime, MaxLifeTime; - core::dimension2df MaxStartSize, MinStartSize; - - u32 Time; - u32 Emitted; - s32 MaxAngleDegrees; - - bool EveryMeshVertex; - bool UseNormalDirection; -}; - -} // end namespace scene -} // end namespace irr - - -#endif // __C_PARTICLE_ANIMATED_MESH_SCENE_NODE_EMITTER_H_INCLUDED__ - diff --git a/irrlicht-1.6/source/Irrlicht/CParticleAttractionAffector.cpp b/irrlicht-1.6/source/Irrlicht/CParticleAttractionAffector.cpp deleted file mode 100644 index 872c9457c..000000000 --- a/irrlicht-1.6/source/Irrlicht/CParticleAttractionAffector.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CParticleAttractionAffector.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CParticleAttractionAffector::CParticleAttractionAffector( - const core::vector3df& point, f32 speed, bool attract, - bool affectX, bool affectY, bool affectZ ) - : Point(point), Speed(speed), AffectX(affectX), AffectY(affectY), - AffectZ(affectZ), Attract(attract), LastTime(0) -{ - #ifdef _DEBUG - setDebugName("CParticleAttractionAffector"); - #endif -} - - -//! Affects an array of particles. -void CParticleAttractionAffector::affect(u32 now, SParticle* particlearray, u32 count) -{ - if( LastTime == 0 ) - { - LastTime = now; - return; - } - - f32 timeDelta = ( now - LastTime ) / 1000.0f; - LastTime = now; - - if( !Enabled ) - return; - - for(u32 i=0; i<count; ++i) - { - core::vector3df direction = (Point - particlearray[i].pos).normalize(); - direction *= Speed * timeDelta; - - if( !Attract ) - direction *= -1.0f; - - if( AffectX ) - particlearray[i].pos.X += direction.X; - - if( AffectY ) - particlearray[i].pos.Y += direction.Y; - - if( AffectZ ) - particlearray[i].pos.Z += direction.Z; - } -} - - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CParticleAttractionAffector.h b/irrlicht-1.6/source/Irrlicht/CParticleAttractionAffector.h deleted file mode 100644 index 0c5eddac1..000000000 --- a/irrlicht-1.6/source/Irrlicht/CParticleAttractionAffector.h +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_PARTICLE_ATTRACTION_AFFECTOR_H_INCLUDED__ -#define __C_PARTICLE_ATTRACTION_AFFECTOR_H_INCLUDED__ - -#include "IParticleAttractionAffector.h" - -namespace irr -{ -namespace scene -{ - -//! Particle Affector for attracting particles to a point -class CParticleAttractionAffector : public IParticleAttractionAffector -{ -public: - - CParticleAttractionAffector( - const core::vector3df& point = core::vector3df(), f32 speed = 1.0f, - bool attract = true, bool affectX = true, - bool affectY = true, bool affectZ = true ); - - //! Affects a particle. - virtual void affect(u32 now, SParticle* particlearray, u32 count); - - //! Set the point that particles will attract to - virtual void setPoint( const core::vector3df& point ) { Point = point; } - - //! Set the speed, in game units per second that the particles will attract to - //! the specified point - virtual void setSpeed( f32 speed ) { Speed = speed; } - - //! Set whether or not the particles are attracting or detracting - virtual void setAttract( bool attract ) { Attract = attract; } - - //! Set whether or not this will affect particles in the X direction - virtual void setAffectX( bool affect ) { AffectX = affect; } - - //! Set whether or not this will affect particles in the Y direction - virtual void setAffectY( bool affect ) { AffectY = affect; } - - //! Set whether or not this will affect particles in the Z direction - virtual void setAffectZ( bool affect ) { AffectZ = affect; } - - //! Get the point that particles are attracted to - virtual const core::vector3df& getPoint() const { return Point; } - - //! Get the speed that points attract to the specified point - virtual f32 getSpeed() const { return Speed; } - - //! Get whether or not the particles are attracting or detracting - virtual bool getAttract() const { return Attract; } - - //! Get whether or not the particles X position are affected - virtual bool getAffectX() const { return AffectX; } - - //! Get whether or not the particles Y position are affected - virtual bool getAffectY() const { return AffectY; } - - //! Get whether or not the particles Z position are affected - virtual bool getAffectZ() const { return AffectZ; } - -private: - - core::vector3df Point; - f32 Speed; - bool AffectX; - bool AffectY; - bool AffectZ; - bool Attract; - u32 LastTime; -}; - -} // end namespace scene -} // end namespace irr - - -#endif // __C_PARTICLE_ATTRACTION_AFFECTOR_H_INCLUDED__ - diff --git a/irrlicht-1.6/source/Irrlicht/CParticleBoxEmitter.cpp b/irrlicht-1.6/source/Irrlicht/CParticleBoxEmitter.cpp deleted file mode 100644 index 138e0515e..000000000 --- a/irrlicht-1.6/source/Irrlicht/CParticleBoxEmitter.cpp +++ /dev/null @@ -1,170 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CParticleBoxEmitter.h" -#include "os.h" -#include "IAttributes.h" -#include "irrMath.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CParticleBoxEmitter::CParticleBoxEmitter( - const core::aabbox3df& box, const core::vector3df& direction, - u32 minParticlesPerSecond, u32 maxParticlesPerSecond, - video::SColor minStartColor, video::SColor maxStartColor, - u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees, - const core::dimension2df& minStartSize, const core::dimension2df& maxStartSize) - : Box(box), Direction(direction), - MaxStartSize(maxStartSize), MinStartSize(minStartSize), - MinParticlesPerSecond(minParticlesPerSecond), - MaxParticlesPerSecond(maxParticlesPerSecond), - MinStartColor(minStartColor), MaxStartColor(maxStartColor), - MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax), - Time(0), Emitted(0), MaxAngleDegrees(maxAngleDegrees) -{ - #ifdef _DEBUG - setDebugName("CParticleBoxEmitter"); - #endif -} - - -//! Prepares an array with new particles to emitt into the system -//! and returns how much new particles there are. -s32 CParticleBoxEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray) -{ - Time += timeSinceLastCall; - - const u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond); - const f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond; - const f32 everyWhatMillisecond = 1000.0f / perSecond; - - if (Time > everyWhatMillisecond) - { - Particles.set_used(0); - u32 amount = (u32)((Time / everyWhatMillisecond) + 0.5f); - Time = 0; - SParticle p; - const core::vector3df& extent = Box.getExtent(); - - if (amount > MaxParticlesPerSecond*2) - amount = MaxParticlesPerSecond * 2; - - for (u32 i=0; i<amount; ++i) - { - p.pos.X = Box.MinEdge.X + fmodf((f32)os::Randomizer::rand(), extent.X); - p.pos.Y = Box.MinEdge.Y + fmodf((f32)os::Randomizer::rand(), extent.Y); - p.pos.Z = Box.MinEdge.Z + fmodf((f32)os::Randomizer::rand(), extent.Z); - - p.startTime = now; - p.vector = Direction; - - if (MaxAngleDegrees) - { - core::vector3df tgt = Direction; - tgt.rotateXYBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees); - tgt.rotateYZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees); - tgt.rotateXZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees); - p.vector = tgt; - } - - if (MaxLifeTime - MinLifeTime == 0) - p.endTime = now + MinLifeTime; - else - p.endTime = now + MinLifeTime + (os::Randomizer::rand() % (MaxLifeTime - MinLifeTime)); - - p.color = MinStartColor.getInterpolated( - MaxStartColor, (os::Randomizer::rand() % 100) / 100.0f); - - p.startColor = p.color; - p.startVector = p.vector; - - if (MinStartSize==MaxStartSize) - p.startSize = MinStartSize; - else - p.startSize = MinStartSize.getInterpolated( - MaxStartSize, (os::Randomizer::rand() % 100) / 100.0f); - p.size = p.startSize; - - Particles.push_back(p); - } - - outArray = Particles.pointer(); - - return Particles.size(); - } - - return 0; -} - - -//! Writes attributes of the object. -void CParticleBoxEmitter::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const -{ - core::vector3df b = Box.getExtent(); - b *= 0.5f; - out->addVector3d("Box", b); - out->addVector3d("Direction", Direction); - out->addInt("MinParticlesPerSecond", MinParticlesPerSecond); - out->addInt("MaxParticlesPerSecond", MaxParticlesPerSecond); - out->addColor("MinStartColor", MinStartColor); - out->addColor("MaxStartColor", MaxStartColor); - out->addInt("MinLifeTime", MinLifeTime); - out->addInt("MaxLifeTime", MaxLifeTime); - out->addInt("MaxAngleDegrees", MaxAngleDegrees); -} - - -//! Reads attributes of the object. -void CParticleBoxEmitter::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - // read data and correct input values here - - core::vector3df b = in->getAttributeAsVector3d("Box"); - - if (b.X <= 0) - b.X = 1.0f; - if (b.Y <= 0) - b.Y = 1.0f; - if (b.Z <= 0) - b.Z = 1.0f; - - Box.MinEdge.X = -b.X; - Box.MinEdge.Y = -b.Y; - Box.MinEdge.Z = -b.Z; - Box.MaxEdge.X = b.X; - Box.MaxEdge.Y = b.Y; - Box.MaxEdge.Z = b.Z; - - Direction = in->getAttributeAsVector3d("Direction"); - if (Direction.getLength() == 0) - Direction.set(0,0.01f,0); - - MinParticlesPerSecond = in->getAttributeAsInt("MinParticlesPerSecond"); - MaxParticlesPerSecond = in->getAttributeAsInt("MaxParticlesPerSecond"); - - MinParticlesPerSecond = core::max_(1u, MinParticlesPerSecond); - MaxParticlesPerSecond = core::max_(MaxParticlesPerSecond, 1u); - MaxParticlesPerSecond = core::min_(MaxParticlesPerSecond, 200u); - MinParticlesPerSecond = core::min_(MinParticlesPerSecond, MaxParticlesPerSecond); - - MinStartColor = in->getAttributeAsColor("MinStartColor"); - MaxStartColor = in->getAttributeAsColor("MaxStartColor"); - MinLifeTime = in->getAttributeAsInt("MinLifeTime"); - MaxLifeTime = in->getAttributeAsInt("MaxLifeTime"); - MaxAngleDegrees = in->getAttributeAsInt("MaxAngleDegrees"); - - MinLifeTime = core::max_(0u, MinLifeTime); - MaxLifeTime = core::max_(MaxLifeTime, MinLifeTime); - MinLifeTime = core::min_(MinLifeTime, MaxLifeTime); - -} - - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CParticleBoxEmitter.h b/irrlicht-1.6/source/Irrlicht/CParticleBoxEmitter.h deleted file mode 100644 index f59e77198..000000000 --- a/irrlicht-1.6/source/Irrlicht/CParticleBoxEmitter.h +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_PARTICLE_BOX_EMITTER_H_INCLUDED__ -#define __C_PARTICLE_BOX_EMITTER_H_INCLUDED__ - -#include "IParticleBoxEmitter.h" -#include "irrArray.h" -#include "aabbox3d.h" - -namespace irr -{ -namespace scene -{ - -//! A default box emitter -class CParticleBoxEmitter : public IParticleBoxEmitter -{ -public: - - //! constructor - CParticleBoxEmitter( - const core::aabbox3df& box, - const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f), - u32 minParticlesPerSecond = 20, - u32 maxParticlesPerSecond = 40, - video::SColor minStartColor = video::SColor(255,0,0,0), - video::SColor maxStartColor = video::SColor(255,255,255,255), - u32 lifeTimeMin=2000, - u32 lifeTimeMax=4000, - s32 maxAngleDegrees=0, - const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f), - const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) - ); - - //! Prepares an array with new particles to emitt into the system - //! and returns how much new particles there are. - virtual s32 emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray); - - //! Set direction the emitter emits particles. - virtual void setDirection( const core::vector3df& newDirection ) { Direction = newDirection; } - - //! Set minimum number of particles emitted per second. - virtual void setMinParticlesPerSecond( u32 minPPS ) { MinParticlesPerSecond = minPPS; } - - //! Set maximum number of particles emitted per second. - virtual void setMaxParticlesPerSecond( u32 maxPPS ) { MaxParticlesPerSecond = maxPPS; } - - //! Set minimum start color. - virtual void setMinStartColor( const video::SColor& color ) { MinStartColor = color; } - - //! Set maximum start color. - virtual void setMaxStartColor( const video::SColor& color ) { MaxStartColor = color; } - - //! Set the maximum starting size for particles - virtual void setMaxStartSize( const core::dimension2df& size ) { MaxStartSize = size; }; - - //! Set the minimum starting size for particles - virtual void setMinStartSize( const core::dimension2df& size ) { MinStartSize = size; }; - - //! Set box from which the particles are emitted. - virtual void setBox( const core::aabbox3df& box ) { Box = box; } - - //! Gets direction the emitter emits particles. - virtual const core::vector3df& getDirection() const { return Direction; } - - //! Gets minimum number of particles emitted per second. - virtual u32 getMinParticlesPerSecond() const { return MinParticlesPerSecond; } - - //! Gets maximum number of particles emitted per second. - virtual u32 getMaxParticlesPerSecond() const { return MaxParticlesPerSecond; } - - //! Gets minimum start color. - virtual const video::SColor& getMinStartColor() const { return MinStartColor; } - - //! Gets maximum start color. - virtual const video::SColor& getMaxStartColor() const { return MaxStartColor; } - - //! Gets the maximum starting size for particles - virtual const core::dimension2df& getMaxStartSize() const { return MaxStartSize; }; - - //! Gets the minimum starting size for particles - virtual const core::dimension2df& getMinStartSize() const { return MinStartSize; }; - - //! Get box from which the particles are emitted. - virtual const core::aabbox3df& getBox() const { return Box; } - - //! Writes attributes of the object. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; - - //! Reads attributes of the object. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - -private: - - core::array<SParticle> Particles; - core::aabbox3df Box; - core::vector3df Direction; - core::dimension2df MaxStartSize, MinStartSize; - u32 MinParticlesPerSecond, MaxParticlesPerSecond; - video::SColor MinStartColor, MaxStartColor; - u32 MinLifeTime, MaxLifeTime; - - u32 Time; - u32 Emitted; - s32 MaxAngleDegrees; -}; - -} // end namespace scene -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CParticleCylinderEmitter.cpp b/irrlicht-1.6/source/Irrlicht/CParticleCylinderEmitter.cpp deleted file mode 100644 index 095f447ed..000000000 --- a/irrlicht-1.6/source/Irrlicht/CParticleCylinderEmitter.cpp +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CParticleCylinderEmitter.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CParticleCylinderEmitter::CParticleCylinderEmitter( - const core::vector3df& center, f32 radius, - const core::vector3df& normal, f32 length, - bool outlineOnly, const core::vector3df& direction, - u32 minParticlesPerSecond, u32 maxParticlesPerSecond, - const video::SColor& minStartColor, const video::SColor& maxStartColor, - u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees, - const core::dimension2df& minStartSize, - const core::dimension2df& maxStartSize ) - : Center(center), Normal(normal), Direction(direction), - MaxStartSize(maxStartSize), MinStartSize(minStartSize), - MinParticlesPerSecond(minParticlesPerSecond), - MaxParticlesPerSecond(maxParticlesPerSecond), - MinStartColor(minStartColor), MaxStartColor(maxStartColor), - MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax), - Radius(radius), Length(length), Time(0), Emitted(0), - MaxAngleDegrees(maxAngleDegrees), OutlineOnly(outlineOnly) -{ - #ifdef _DEBUG - setDebugName("CParticleCylinderEmitter"); - #endif -} - - -//! Prepares an array with new particles to emitt into the system -//! and returns how much new particles there are. -s32 CParticleCylinderEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray) -{ - Time += timeSinceLastCall; - - const u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond); - const f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond; - const f32 everyWhatMillisecond = 1000.0f / perSecond; - - if(Time > everyWhatMillisecond) - { - Particles.set_used(0); - u32 amount = (u32)((Time / everyWhatMillisecond) + 0.5f); - Time = 0; - SParticle p; - - if(amount > MaxParticlesPerSecond*2) - amount = MaxParticlesPerSecond * 2; - - for(u32 i=0; i<amount; ++i) - { - // Random distance from center if outline only is not true - f32 distance; - if( !OutlineOnly ) - distance = fmodf( (f32)os::Randomizer::rand(), Radius * 1000.0f ) * 0.001f; - else - distance = Radius; - - // Random direction from center - p.pos.set(Center.X + distance, Center.Y, Center.Z + distance); - p.pos.rotateXZBy( os::Randomizer::rand() % 360, Center ); - - // Random length - const f32 length = fmodf( (f32)os::Randomizer::rand(), Length * 1000.0f ) * 0.001f; - - // Random point along the cylinders length - p.pos += Normal * length; - - p.startTime = now; - p.vector = Direction; - - if( MaxAngleDegrees ) - { - core::vector3df tgt = Direction; - tgt.rotateXYBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df()); - tgt.rotateYZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df()); - tgt.rotateXZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df()); - p.vector = tgt; - } - - if(MaxLifeTime - MinLifeTime == 0) - p.endTime = now + MinLifeTime; - else - p.endTime = now + MinLifeTime + (os::Randomizer::rand() % (MaxLifeTime - MinLifeTime)); - - p.color = MinStartColor.getInterpolated( - MaxStartColor, (os::Randomizer::rand() % 100) / 100.0f); - - p.startColor = p.color; - p.startVector = p.vector; - - if (MinStartSize==MaxStartSize) - p.startSize = MinStartSize; - else - p.startSize = MinStartSize.getInterpolated( - MaxStartSize, (os::Randomizer::rand() % 100) / 100.0f); - p.size = p.startSize; - - Particles.push_back(p); - } - - outArray = Particles.pointer(); - - return Particles.size(); - } - - return 0; -} - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CParticleCylinderEmitter.h b/irrlicht-1.6/source/Irrlicht/CParticleCylinderEmitter.h deleted file mode 100644 index 709aa567f..000000000 --- a/irrlicht-1.6/source/Irrlicht/CParticleCylinderEmitter.h +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_PARTICLE_CYLINDER_EMITTER_H_INCLUDED__ -#define __C_PARTICLE_CYLINDER_EMITTER_H_INCLUDED__ - -#include "IParticleCylinderEmitter.h" -#include "irrArray.h" - -namespace irr -{ -namespace scene -{ - -//! A default box emitter -class CParticleCylinderEmitter : public IParticleCylinderEmitter -{ -public: - - //! constructor - CParticleCylinderEmitter( - const core::vector3df& center, f32 radius, - const core::vector3df& normal, f32 length, - bool outlineOnly = false, const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f), - u32 minParticlesPerSecond = 20, - u32 maxParticlesPerSecond = 40, - const video::SColor& minStartColor = video::SColor(255,0,0,0), - const video::SColor& maxStartColor = video::SColor(255,255,255,255), - u32 lifeTimeMin=2000, - u32 lifeTimeMax=4000, - s32 maxAngleDegrees=0, - const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f), - const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) - ); - - //! Prepares an array with new particles to emitt into the system - //! and returns how much new particles there are. - virtual s32 emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray); - - //! Set the center of the radius for the cylinder, at one end of the cylinder - virtual void setCenter( const core::vector3df& center ) { Center = center; } - - //! Set the normal of the cylinder - virtual void setNormal( const core::vector3df& normal ) { Normal = normal; } - - //! Set the radius of the cylinder - virtual void setRadius( f32 radius ) { Radius = radius; } - - //! Set the length of the cylinder - virtual void setLength( f32 length ) { Length = length; } - - //! Set whether or not to draw points inside the cylinder - virtual void setOutlineOnly( bool outlineOnly ) { OutlineOnly = outlineOnly; } - - //! Set direction the emitter emits particles - virtual void setDirection( const core::vector3df& newDirection ) { Direction = newDirection; } - - //! Set direction the emitter emits particles - virtual void setMinParticlesPerSecond( u32 minPPS ) { MinParticlesPerSecond = minPPS; } - - //! Set direction the emitter emits particles - virtual void setMaxParticlesPerSecond( u32 maxPPS ) { MaxParticlesPerSecond = maxPPS; } - - //! Set direction the emitter emits particles - virtual void setMinStartColor( const video::SColor& color ) { MinStartColor = color; } - - //! Set direction the emitter emits particles - virtual void setMaxStartColor( const video::SColor& color ) { MaxStartColor = color; } - - //! Set the maximum starting size for particles - virtual void setMaxStartSize( const core::dimension2df& size ) { MaxStartSize = size; }; - - //! Set the minimum starting size for particles - virtual void setMinStartSize( const core::dimension2df& size ) { MinStartSize = size; }; - - //! Get the center of the cylinder - virtual const core::vector3df& getCenter() const { return Center; } - - //! Get the normal of the cylinder - virtual const core::vector3df& getNormal() const { return Normal; } - - //! Get the radius of the cylinder - virtual f32 getRadius() const { return Radius; } - - //! Get the center of the cylinder - virtual f32 getLength() const { return Length; } - - //! Get whether or not to draw points inside the cylinder - virtual bool getOutlineOnly() const { return OutlineOnly; } - - //! Gets direction the emitter emits particles - virtual const core::vector3df& getDirection() const { return Direction; } - - //! Gets direction the emitter emits particles - virtual u32 getMinParticlesPerSecond() const { return MinParticlesPerSecond; } - - //! Gets direction the emitter emits particles - virtual u32 getMaxParticlesPerSecond() const { return MaxParticlesPerSecond; } - - //! Gets direction the emitter emits particles - virtual const video::SColor& getMinStartColor() const { return MinStartColor; } - - //! Gets direction the emitter emits particles - virtual const video::SColor& getMaxStartColor() const { return MaxStartColor; } - - //! Gets the maximum starting size for particles - virtual const core::dimension2df& getMaxStartSize() const { return MaxStartSize; }; - - //! Gets the minimum starting size for particles - virtual const core::dimension2df& getMinStartSize() const { return MinStartSize; }; - -private: - - core::array<SParticle> Particles; - - core::vector3df Center; - core::vector3df Normal; - core::vector3df Direction; - core::dimension2df MaxStartSize, MinStartSize; - u32 MinParticlesPerSecond, MaxParticlesPerSecond; - video::SColor MinStartColor, MaxStartColor; - u32 MinLifeTime, MaxLifeTime; - - f32 Radius; - f32 Length; - - u32 Time; - u32 Emitted; - s32 MaxAngleDegrees; - - bool OutlineOnly; -}; - -} // end namespace scene -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CParticleFadeOutAffector.cpp b/irrlicht-1.6/source/Irrlicht/CParticleFadeOutAffector.cpp deleted file mode 100644 index 5559c424a..000000000 --- a/irrlicht-1.6/source/Irrlicht/CParticleFadeOutAffector.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CParticleFadeOutAffector.h" -#include "IAttributes.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CParticleFadeOutAffector::CParticleFadeOutAffector( - const video::SColor& targetColor, u32 fadeOutTime) - : IParticleFadeOutAffector(), TargetColor(targetColor) -{ - - #ifdef _DEBUG - setDebugName("CParticleFadeOutAffector"); - #endif - - FadeOutTime = fadeOutTime ? static_cast<f32>(fadeOutTime) : 1.0f; -} - - -//! Affects an array of particles. -void CParticleFadeOutAffector::affect(u32 now, SParticle* particlearray, u32 count) -{ - if (!Enabled) - return; - f32 d; - - for (u32 i=0; i<count; ++i) - { - if (particlearray[i].endTime - now < FadeOutTime) - { - d = (particlearray[i].endTime - now) / FadeOutTime; - particlearray[i].color = particlearray[i].startColor.getInterpolated( - TargetColor, d); - } - } -} - - -//! Writes attributes of the object. -//! Implement this to expose the attributes of your scene node animator for -//! scripting languages, editors, debuggers or xml serialization purposes. -void CParticleFadeOutAffector::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const -{ - out->addColor("TargetColor", TargetColor); - out->addFloat("FadeOutTime", FadeOutTime); -} - -//! Reads attributes of the object. -//! Implement this to set the attributes of your scene node animator for -//! scripting languages, editors, debuggers or xml deserialization purposes. -//! \param startIndex: start index where to start reading attributes. -//! \return: returns last index of an attribute read by this affector -void CParticleFadeOutAffector::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - TargetColor = in->getAttributeAsColor("TargetColor"); - FadeOutTime = in->getAttributeAsFloat("FadeOutTime"); -} - - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CParticleFadeOutAffector.h b/irrlicht-1.6/source/Irrlicht/CParticleFadeOutAffector.h deleted file mode 100644 index 7ad97fa02..000000000 --- a/irrlicht-1.6/source/Irrlicht/CParticleFadeOutAffector.h +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_PARTICLE_FADE_OUT_AFFECTOR_H_INCLUDED__ -#define __C_PARTICLE_FADE_OUT_AFFECTOR_H_INCLUDED__ - -#include "IParticleFadeOutAffector.h" -#include "SColor.h" - -namespace irr -{ -namespace scene -{ - -//! Particle Affector for fading out a color -class CParticleFadeOutAffector : public IParticleFadeOutAffector -{ -public: - - CParticleFadeOutAffector(const video::SColor& targetColor, u32 fadeOutTime); - - //! Affects a particle. - virtual void affect(u32 now, SParticle* particlearray, u32 count); - - //! Sets the targetColor, i.e. the color the particles will interpolate - //! to over time. - virtual void setTargetColor( const video::SColor& targetColor ) { TargetColor = targetColor; } - - //! Sets the amount of time it takes for each particle to fade out. - virtual void setFadeOutTime( f32 fadeOutTime ) { FadeOutTime = fadeOutTime; } - - //! Sets the targetColor, i.e. the color the particles will interpolate - //! to over time. - virtual const video::SColor& getTargetColor() const { return TargetColor; } - - //! Sets the amount of time it takes for each particle to fade out. - virtual f32 getFadeOutTime() const { return FadeOutTime; } - - //! Writes attributes of the object. - //! Implement this to expose the attributes of your scene node animator for - //! scripting languages, editors, debuggers or xml serialization purposes. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; - - //! Reads attributes of the object. - //! Implement this to set the attributes of your scene node animator for - //! scripting languages, editors, debuggers or xml deserialization purposes. - //! \param startIndex: start index where to start reading attributes. - //! \return: returns last index of an attribute read by this affector - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - -private: - - video::SColor TargetColor; - f32 FadeOutTime; -}; - -} // end namespace scene -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CParticleGravityAffector.cpp b/irrlicht-1.6/source/Irrlicht/CParticleGravityAffector.cpp deleted file mode 100644 index c57ca34ed..000000000 --- a/irrlicht-1.6/source/Irrlicht/CParticleGravityAffector.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CParticleGravityAffector.h" -#include "os.h" -#include "IAttributes.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CParticleGravityAffector::CParticleGravityAffector( - const core::vector3df& gravity, u32 timeForceLost) - : IParticleGravityAffector(), TimeForceLost(static_cast<f32>(timeForceLost)), Gravity(gravity) -{ - #ifdef _DEBUG - setDebugName("CParticleGravityAffector"); - #endif -} - - -//! Affects an array of particles. -void CParticleGravityAffector::affect(u32 now, SParticle* particlearray, u32 count) -{ - if (!Enabled) - return; - f32 d; - - for (u32 i=0; i<count; ++i) - { - d = (now - particlearray[i].startTime) / TimeForceLost; - if (d > 1.0f) - d = 1.0f; - if (d < 0.0f) - d = 0.0f; - d = 1.0f - d; - - particlearray[i].vector = particlearray[i].startVector.getInterpolated(Gravity, d); - } -} - -//! Writes attributes of the object. -void CParticleGravityAffector::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const -{ - out->addVector3d("Gravity", Gravity); - out->addFloat("TimeForceLost", TimeForceLost); -} - - -//! Reads attributes of the object. -void CParticleGravityAffector::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - Gravity = in->getAttributeAsVector3d("Gravity"); - TimeForceLost = in->getAttributeAsFloat("TimeForceLost"); -} - - - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CParticleGravityAffector.h b/irrlicht-1.6/source/Irrlicht/CParticleGravityAffector.h deleted file mode 100644 index d517c25f1..000000000 --- a/irrlicht-1.6/source/Irrlicht/CParticleGravityAffector.h +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_PARTICLE_GRAVITY_AFFECTOR_H_INCLUDED__ -#define __C_PARTICLE_GRAVITY_AFFECTOR_H_INCLUDED__ - -#include "IParticleGravityAffector.h" -#include "SColor.h" - -namespace irr -{ -namespace scene -{ - -//! Particle Affector for affecting direction of particle -class CParticleGravityAffector : public IParticleGravityAffector -{ -public: - - CParticleGravityAffector( - const core::vector3df& gravity = core::vector3df(0.0f,-0.03f,0.0f), - u32 timeForceLost = 1000); - - //! Affects a particle. - virtual void affect(u32 now, SParticle* particlearray, u32 count); - - //! Set the time in milliseconds when the gravity force is totally - //! lost and the particle does not move any more. - virtual void setTimeForceLost( f32 timeForceLost ) { TimeForceLost = timeForceLost; } - - //! Set the direction and force of gravity. - virtual void setGravity( const core::vector3df& gravity ) { Gravity = gravity; } - - //! Set the time in milliseconds when the gravity force is totally - //! lost and the particle does not move any more. - virtual f32 getTimeForceLost() const { return TimeForceLost; } - - //! Set the direction and force of gravity. - virtual const core::vector3df& getGravity() const { return Gravity; } - - //! Writes attributes of the object. - //! Implement this to expose the attributes of your scene node animator for - //! scripting languages, editors, debuggers or xml serialization purposes. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; - - //! Reads attributes of the object. - //! Implement this to set the attributes of your scene node animator for - //! scripting languages, editors, debuggers or xml deserialization purposes. - //! \param startIndex: start index where to start reading attributes. - //! \return: returns last index of an attribute read by this affector - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - -private: - f32 TimeForceLost; - core::vector3df Gravity; -}; - -} // end namespace scene -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CParticleMeshEmitter.cpp b/irrlicht-1.6/source/Irrlicht/CParticleMeshEmitter.cpp deleted file mode 100644 index 2f6735502..000000000 --- a/irrlicht-1.6/source/Irrlicht/CParticleMeshEmitter.cpp +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright (C) 2002-2009 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" -#include "CParticleMeshEmitter.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CParticleMeshEmitter::CParticleMeshEmitter( - IMesh* mesh, bool useNormalDirection, - const core::vector3df& direction, f32 normalDirectionModifier, - s32 mbNumber, bool everyMeshVertex, - u32 minParticlesPerSecond, u32 maxParticlesPerSecond, - const video::SColor& minStartColor, const video::SColor& maxStartColor, - u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees, - const core::dimension2df& minStartSize, - const core::dimension2df& maxStartSize ) - : Mesh(0), TotalVertices(0), MBCount(0), MBNumber(mbNumber), - NormalDirectionModifier(normalDirectionModifier), Direction(direction), - MaxStartSize(maxStartSize), MinStartSize(minStartSize), - MinParticlesPerSecond(minParticlesPerSecond), MaxParticlesPerSecond(maxParticlesPerSecond), - MinStartColor(minStartColor), MaxStartColor(maxStartColor), - MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax), - Time(0), Emitted(0), MaxAngleDegrees(maxAngleDegrees), - EveryMeshVertex(everyMeshVertex), UseNormalDirection(useNormalDirection) -{ - #ifdef _DEBUG - setDebugName("CParticleMeshEmitter"); - #endif - setMesh(mesh); -} - - -//! Prepares an array with new particles to emitt into the system -//! and returns how much new particles there are. -s32 CParticleMeshEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray) -{ - Time += timeSinceLastCall; - - const u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond); - const f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond; - const f32 everyWhatMillisecond = 1000.0f / perSecond; - - if(Time > everyWhatMillisecond) - { - Particles.set_used(0); - u32 amount = (u32)((Time / everyWhatMillisecond) + 0.5f); - Time = 0; - SParticle p; - - if(amount > MaxParticlesPerSecond * 2) - amount = MaxParticlesPerSecond * 2; - - for(u32 i=0; i<amount; ++i) - { - if( EveryMeshVertex ) - { - for( u32 j=0; j<Mesh->getMeshBufferCount(); ++j ) - { - for( u32 k=0; k<Mesh->getMeshBuffer(j)->getVertexCount(); ++k ) - { - p.pos = Mesh->getMeshBuffer(j)->getPosition(k); - if( UseNormalDirection ) - p.vector = Mesh->getMeshBuffer(j)->getNormal(k) / - NormalDirectionModifier; - else - p.vector = Direction; - - p.startTime = now; - - if( MaxAngleDegrees ) - { - core::vector3df tgt = p.vector; - tgt.rotateXYBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df(0,0,0)); - tgt.rotateYZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df(0,0,0)); - tgt.rotateXZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df(0,0,0)); - p.vector = tgt; - } - - if(MaxLifeTime - MinLifeTime == 0) - p.endTime = now + MinLifeTime; - else - p.endTime = now + MinLifeTime + (os::Randomizer::rand() % (MaxLifeTime - MinLifeTime)); - - p.color = MinStartColor.getInterpolated( - MaxStartColor, (os::Randomizer::rand() % 100) / 100.0f); - - p.startColor = p.color; - p.startVector = p.vector; - - if (MinStartSize==MaxStartSize) - p.startSize = MinStartSize; - else - p.startSize = MinStartSize.getInterpolated( - MaxStartSize, (os::Randomizer::rand() % 100) / 100.0f); - p.size = p.startSize; - - Particles.push_back(p); - } - } - } - else - { - s32 randomMB = 0; - - if( MBNumber < 0 ) - { - randomMB = os::Randomizer::rand() % MBCount; - } - else - { - randomMB = MBNumber; - } - - u32 vertexNumber = Mesh->getMeshBuffer(randomMB)->getVertexCount(); - if (!vertexNumber) - continue; - vertexNumber = os::Randomizer::rand() % vertexNumber; - - p.pos = Mesh->getMeshBuffer(randomMB)->getPosition(vertexNumber); - if( UseNormalDirection ) - p.vector = Mesh->getMeshBuffer(randomMB)->getNormal(vertexNumber) / - NormalDirectionModifier; - else - p.vector = Direction; - - p.startTime = now; - - if( MaxAngleDegrees ) - { - core::vector3df tgt = Direction; - tgt.rotateXYBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df(0,0,0)); - tgt.rotateYZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df(0,0,0)); - tgt.rotateXZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df(0,0,0)); - p.vector = tgt; - } - - if(MaxLifeTime - MinLifeTime == 0) - p.endTime = now + MinLifeTime; - else - p.endTime = now + MinLifeTime + (os::Randomizer::rand() % (MaxLifeTime - MinLifeTime)); - - p.color = MinStartColor.getInterpolated( - MaxStartColor, (os::Randomizer::rand() % 100) / 100.0f); - - p.startColor = p.color; - p.startVector = p.vector; - - if (MinStartSize==MaxStartSize) - p.startSize = MinStartSize; - else - p.startSize = MinStartSize.getInterpolated( - MaxStartSize, (os::Randomizer::rand() % 100) / 100.0f); - p.size = p.startSize; - - Particles.push_back(p); - } - } - - outArray = Particles.pointer(); - - return Particles.size(); - } - - return 0; -} - - -//! Set Mesh to emit particles from -void CParticleMeshEmitter::setMesh(IMesh* mesh) -{ - Mesh = mesh; - - TotalVertices = 0; - MBCount = Mesh->getMeshBufferCount(); - VertexPerMeshBufferList.reallocate(MBCount); - for( u32 i = 0; i < MBCount; ++i ) - { - VertexPerMeshBufferList.push_back( Mesh->getMeshBuffer(i)->getVertexCount() ); - TotalVertices += Mesh->getMeshBuffer(i)->getVertexCount(); - } -} - - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CParticleMeshEmitter.h b/irrlicht-1.6/source/Irrlicht/CParticleMeshEmitter.h deleted file mode 100644 index 3cbb4f359..000000000 --- a/irrlicht-1.6/source/Irrlicht/CParticleMeshEmitter.h +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_PARTICLE_MESH_EMITTER_H_INCLUDED__ -#define __C_PARTICLE_MESH_EMITTER_H_INCLUDED__ - -#include "IParticleMeshEmitter.h" -#include "irrArray.h" -#include "aabbox3d.h" -#include "IMeshBuffer.h" - -namespace irr -{ -namespace scene -{ - -//! A default box emitter -class CParticleMeshEmitter : public IParticleMeshEmitter -{ -public: - - //! constructor - CParticleMeshEmitter( - IMesh* mesh, bool useNormalDirection = true, - const core::vector3df& direction = core::vector3df(0.0f,0.0f,0.0f), - f32 normalDirectionModifier = 100.0f, - s32 mbNumber = -1, - bool everyMeshVertex = false, - u32 minParticlesPerSecond = 20, - u32 maxParticlesPerSecond = 40, - const video::SColor& minStartColor = video::SColor(255,0,0,0), - const video::SColor& maxStartColor = video::SColor(255,255,255,255), - u32 lifeTimeMin = 2000, - u32 lifeTimeMax = 4000, - s32 maxAngleDegrees = 0, - const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f), - const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) - ); - - //! Prepares an array with new particles to emitt into the system - //! and returns how much new particles there are. - virtual s32 emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray); - - //! Set Mesh to emit particles from - virtual void setMesh( IMesh* mesh ); - - //! Set whether to use vertex normal for direction, or direction specified - virtual void setUseNormalDirection( bool useNormalDirection ) { UseNormalDirection = useNormalDirection; } - - //! Set direction the emitter emits particles - virtual void setDirection( const core::vector3df& newDirection ) { Direction = newDirection; } - - //! Set the amount that the normal is divided by for getting a particles direction - virtual void setNormalDirectionModifier( f32 normalDirectionModifier ) { NormalDirectionModifier = normalDirectionModifier; } - - //! Sets whether to emit min<->max particles for every vertex per second, or to pick - //! min<->max vertices every second - virtual void setEveryMeshVertex( bool everyMeshVertex ) { EveryMeshVertex = everyMeshVertex; } - - //! Set minimum number of particles the emitter emits per second - virtual void setMinParticlesPerSecond( u32 minPPS ) { MinParticlesPerSecond = minPPS; } - - //! Set maximum number of particles the emitter emits per second - virtual void setMaxParticlesPerSecond( u32 maxPPS ) { MaxParticlesPerSecond = maxPPS; } - - //! Set minimum starting color for particles - virtual void setMinStartColor( const video::SColor& color ) { MinStartColor = color; } - - //! Set maximum starting color for particles - virtual void setMaxStartColor( const video::SColor& color ) { MaxStartColor = color; } - - //! Set the maximum starting size for particles - virtual void setMaxStartSize( const core::dimension2df& size ) { MaxStartSize = size; }; - - //! Set the minimum starting size for particles - virtual void setMinStartSize( const core::dimension2df& size ) { MinStartSize = size; }; - - //! Get Mesh we're emitting particles from - virtual const IMesh* getMesh() const { return Mesh; } - - //! Get whether to use vertex normal for direciton, or direction specified - virtual bool isUsingNormalDirection() const { return UseNormalDirection; } - - //! Get direction the emitter emits particles - virtual const core::vector3df& getDirection() const { return Direction; } - - //! Get the amount that the normal is divided by for getting a particles direction - virtual f32 getNormalDirectionModifier() const { return NormalDirectionModifier; } - - //! Gets whether to emit min<->max particles for every vertex per second, or to pick - //! min<->max vertices every second - virtual bool getEveryMeshVertex() const { return EveryMeshVertex; } - - //! Get the minimum number of particles the emitter emits per second - virtual u32 getMinParticlesPerSecond() const { return MinParticlesPerSecond; } - - //! Get the maximum number of particles the emitter emits per second - virtual u32 getMaxParticlesPerSecond() const { return MaxParticlesPerSecond; } - - //! Get the minimum starting color for particles - virtual const video::SColor& getMinStartColor() const { return MinStartColor; } - - //! Get the maximum starting color for particles - virtual const video::SColor& getMaxStartColor() const { return MaxStartColor; } - - //! Gets the maximum starting size for particles - virtual const core::dimension2df& getMaxStartSize() const { return MaxStartSize; }; - - //! Gets the minimum starting size for particles - virtual const core::dimension2df& getMinStartSize() const { return MinStartSize; }; - -private: - - const IMesh* Mesh; - core::array<s32> VertexPerMeshBufferList; - s32 TotalVertices; - u32 MBCount; - s32 MBNumber; - - f32 NormalDirectionModifier; - core::array<SParticle> Particles; - core::vector3df Direction; - core::dimension2df MaxStartSize, MinStartSize; - u32 MinParticlesPerSecond, MaxParticlesPerSecond; - video::SColor MinStartColor, MaxStartColor; - u32 MinLifeTime, MaxLifeTime; - - u32 Time; - u32 Emitted; - s32 MaxAngleDegrees; - - bool EveryMeshVertex; - bool UseNormalDirection; -}; - -} // end namespace scene -} // end namespace irr - - -#endif // __C_PARTICLE_MESH_EMITTER_H_INCLUDED__ - diff --git a/irrlicht-1.6/source/Irrlicht/CParticlePointEmitter.cpp b/irrlicht-1.6/source/Irrlicht/CParticlePointEmitter.cpp deleted file mode 100644 index 7a94f6d0c..000000000 --- a/irrlicht-1.6/source/Irrlicht/CParticlePointEmitter.cpp +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CParticlePointEmitter.h" -#include "os.h" -#include "IAttributes.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CParticlePointEmitter::CParticlePointEmitter( - const core::vector3df& direction, u32 minParticlesPerSecond, - u32 maxParticlesPerSecond, video::SColor minStartColor, - video::SColor maxStartColor, u32 lifeTimeMin, u32 lifeTimeMax, - s32 maxAngleDegrees, - const core::dimension2df& minStartSize, - const core::dimension2df& maxStartSize) - : Direction(direction), - MinStartSize(minStartSize), MaxStartSize(maxStartSize), - MinParticlesPerSecond(minParticlesPerSecond), - MaxParticlesPerSecond(maxParticlesPerSecond), - MinStartColor(minStartColor), MaxStartColor(maxStartColor), - MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax), - MaxAngleDegrees(maxAngleDegrees), Time(0), Emitted(0) -{ - #ifdef _DEBUG - setDebugName("CParticlePointEmitter"); - #endif -} - - -//! Prepares an array with new particles to emitt into the system -//! and returns how much new particles there are. -s32 CParticlePointEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray) -{ - Time += timeSinceLastCall; - - const u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond); - const f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond; - const f32 everyWhatMillisecond = 1000.0f / perSecond; - - if (Time > everyWhatMillisecond) - { - Time = 0; - Particle.startTime = now; - Particle.vector = Direction; - - if (MaxAngleDegrees) - { - core::vector3df tgt = Direction; - tgt.rotateXYBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees); - tgt.rotateYZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees); - tgt.rotateXZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees); - Particle.vector = tgt; - } - - if (MaxLifeTime - MinLifeTime == 0) - Particle.endTime = now + MinLifeTime; - else - Particle.endTime = now + MinLifeTime + (os::Randomizer::rand() % (MaxLifeTime - MinLifeTime)); - - Particle.color = MinStartColor.getInterpolated( - MaxStartColor, (os::Randomizer::rand() % 100) / 100.0f); - - Particle.startColor = Particle.color; - Particle.startVector = Particle.vector; - - if (MinStartSize==MaxStartSize) - Particle.startSize = MinStartSize; - else - Particle.startSize = MinStartSize.getInterpolated( - MaxStartSize, (os::Randomizer::rand() % 100) / 100.0f); - Particle.size = Particle.startSize; - - outArray = &Particle; - return 1; - } - - return 0; -} - - -//! Writes attributes of the object. -void CParticlePointEmitter::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const -{ - out->addVector3d("Direction", Direction); - out->addInt("MinParticlesPerSecond", MinParticlesPerSecond); - out->addInt("MaxParticlesPerSecond", MaxParticlesPerSecond); - out->addColor("MinStartColor", MinStartColor); - out->addColor("MaxStartColor", MaxStartColor); - out->addInt("MinLifeTime", MinLifeTime); - out->addInt("MaxLifeTime", MaxLifeTime); - out->addInt("MaxAngleDegrees", MaxAngleDegrees); -} - - -//! Reads attributes of the object. -void CParticlePointEmitter::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - Direction = in->getAttributeAsVector3d("Direction"); - if (Direction.getLength() == 0) - Direction.set(0,0.01f,0); - - MinParticlesPerSecond = in->getAttributeAsInt("MinParticlesPerSecond"); - MaxParticlesPerSecond = in->getAttributeAsInt("MaxParticlesPerSecond"); - - MinParticlesPerSecond = core::max_(1u, MinParticlesPerSecond); - MaxParticlesPerSecond = core::max_(MaxParticlesPerSecond, 1u); - MaxParticlesPerSecond = core::min_(MaxParticlesPerSecond, 200u); - MinParticlesPerSecond = core::min_(MinParticlesPerSecond, MaxParticlesPerSecond); - - MinStartColor = in->getAttributeAsColor("MinStartColor"); - MaxStartColor = in->getAttributeAsColor("MaxStartColor"); - MinLifeTime = in->getAttributeAsInt("MinLifeTime"); - MaxLifeTime = in->getAttributeAsInt("MaxLifeTime"); - MaxAngleDegrees = in->getAttributeAsInt("MaxAngleDegrees"); - - MinLifeTime = core::max_(0u, MinLifeTime); - MaxLifeTime = core::max_(MaxLifeTime, MinLifeTime); - MinLifeTime = core::min_(MinLifeTime, MaxLifeTime); -} - - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CParticlePointEmitter.h b/irrlicht-1.6/source/Irrlicht/CParticlePointEmitter.h deleted file mode 100644 index 4ae94045d..000000000 --- a/irrlicht-1.6/source/Irrlicht/CParticlePointEmitter.h +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_PARTICLE_POINT_EMITTER_H_INCLUDED__ -#define __C_PARTICLE_POINT_EMITTER_H_INCLUDED__ - -#include "IParticleEmitter.h" -#include "irrArray.h" - -namespace irr -{ -namespace scene -{ - -//! A default point emitter -class CParticlePointEmitter : public IParticlePointEmitter -{ -public: - - //! constructor - CParticlePointEmitter( - const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f), - u32 minParticlesPerSecond = 5, - u32 maxParticlesPerSecond = 10, - video::SColor minStartColor = video::SColor(255,0,0,0), - video::SColor maxStartColor = video::SColor(255,255,255,255), - u32 lifeTimeMin=2000, - u32 lifeTimeMax=4000, - s32 maxAngleDegrees=0, - const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f), - const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) ); - - //! Prepares an array with new particles to emitt into the system - //! and returns how much new particles there are. - virtual s32 emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray); - - //! Set direction the emitter emits particles. - virtual void setDirection( const core::vector3df& newDirection ) { Direction = newDirection; } - - //! Set minimum number of particles emitted per second. - virtual void setMinParticlesPerSecond( u32 minPPS ) { MinParticlesPerSecond = minPPS; } - - //! Set maximum number of particles emitted per second. - virtual void setMaxParticlesPerSecond( u32 maxPPS ) { MaxParticlesPerSecond = maxPPS; } - - //! Set minimum start color. - virtual void setMinStartColor( const video::SColor& color ) { MinStartColor = color; } - - //! Set maximum start color. - virtual void setMaxStartColor( const video::SColor& color ) { MaxStartColor = color; } - - //! Set the maximum starting size for particles - virtual void setMaxStartSize( const core::dimension2df& size ) { MaxStartSize = size; }; - - //! Set the minimum starting size for particles - virtual void setMinStartSize( const core::dimension2df& size ) { MinStartSize = size; }; - - //! Gets direction the emitter emits particles. - virtual const core::vector3df& getDirection() const { return Direction; } - - //! Gets minimum number of particles emitted per second. - virtual u32 getMinParticlesPerSecond() const { return MinParticlesPerSecond; } - - //! Gets maximum number of particles emitted per second. - virtual u32 getMaxParticlesPerSecond() const { return MaxParticlesPerSecond; } - - //! Gets minimum start color. - virtual const video::SColor& getMinStartColor() const { return MinStartColor; } - - //! Gets maximum start color. - virtual const video::SColor& getMaxStartColor() const { return MaxStartColor; } - - //! Gets the maximum starting size for particles - virtual const core::dimension2df& getMaxStartSize() const { return MaxStartSize; }; - - //! Gets the minimum starting size for particles - virtual const core::dimension2df& getMinStartSize() const { return MinStartSize; }; - - //! Writes attributes of the object. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; - - //! Reads attributes of the object. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - -private: - - SParticle Particle; - core::vector3df Direction; - core::dimension2df MinStartSize, MaxStartSize; - u32 MinParticlesPerSecond, MaxParticlesPerSecond; - video::SColor MinStartColor, MaxStartColor; - u32 MinLifeTime, MaxLifeTime; - s32 MaxAngleDegrees; - - u32 Time; - u32 Emitted; -}; - -} // end namespace scene -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CParticleRingEmitter.cpp b/irrlicht-1.6/source/Irrlicht/CParticleRingEmitter.cpp deleted file mode 100644 index e424f94a1..000000000 --- a/irrlicht-1.6/source/Irrlicht/CParticleRingEmitter.cpp +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CParticleRingEmitter.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CParticleRingEmitter::CParticleRingEmitter( - const core::vector3df& center, f32 radius, f32 ringThickness, - const core::vector3df& direction, u32 minParticlesPerSecond, - u32 maxParticlesPerSecond, const video::SColor& minStartColor, - const video::SColor& maxStartColor, u32 lifeTimeMin, u32 lifeTimeMax, - s32 maxAngleDegrees, - const core::dimension2df& minStartSize, - const core::dimension2df& maxStartSize ) - : Center(center), Radius(radius), RingThickness(ringThickness), - Direction(direction), - MaxStartSize(maxStartSize), MinStartSize(minStartSize), - MinParticlesPerSecond(minParticlesPerSecond), - MaxParticlesPerSecond(maxParticlesPerSecond), - MinStartColor(minStartColor), MaxStartColor(maxStartColor), - MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax), - Time(0), Emitted(0), MaxAngleDegrees(maxAngleDegrees) -{ - #ifdef _DEBUG - setDebugName("CParticleRingEmitter"); - #endif -} - - -//! Prepares an array with new particles to emitt into the system -//! and returns how much new particles there are. -s32 CParticleRingEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray) -{ - Time += timeSinceLastCall; - - u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond); - f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond; - f32 everyWhatMillisecond = 1000.0f / perSecond; - - if(Time > everyWhatMillisecond) - { - Particles.set_used(0); - u32 amount = (u32)((Time / everyWhatMillisecond) + 0.5f); - Time = 0; - SParticle p; - - if(amount > MaxParticlesPerSecond*2) - amount = MaxParticlesPerSecond * 2; - - for(u32 i=0; i<amount; ++i) - { - f32 distance = fmodf( (f32)os::Randomizer::rand(), RingThickness * 0.5f * 1000.0f ) * 0.001f; - s32 plusMinus = os::Randomizer::rand() % 2; - if( plusMinus ) - distance *= -1.0f; - distance += Radius; - - p.pos.set(Center.X + distance, Center.Y, Center.Z + distance); - p.pos.rotateXZBy( ( os::Randomizer::rand() % 3600 ) * 0.1f, Center ); - - p.startTime = now; - p.vector = Direction; - - if(MaxAngleDegrees) - { - core::vector3df tgt = Direction; - tgt.rotateXYBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, Center ); - tgt.rotateYZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, Center ); - tgt.rotateXZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, Center ); - p.vector = tgt; - } - - if(MaxLifeTime - MinLifeTime == 0) - p.endTime = now + MinLifeTime; - else - p.endTime = now + MinLifeTime + (os::Randomizer::rand() % (MaxLifeTime - MinLifeTime)); - - p.color = MinStartColor.getInterpolated( - MaxStartColor, (os::Randomizer::rand() % 100) / 100.0f); - - p.startColor = p.color; - p.startVector = p.vector; - - if (MinStartSize==MaxStartSize) - p.startSize = MinStartSize; - else - p.startSize = MinStartSize.getInterpolated( - MaxStartSize, (os::Randomizer::rand() % 100) / 100.0f); - p.size = p.startSize; - - Particles.push_back(p); - } - - outArray = Particles.pointer(); - - return Particles.size(); - } - - return 0; -} - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CParticleRingEmitter.h b/irrlicht-1.6/source/Irrlicht/CParticleRingEmitter.h deleted file mode 100644 index 21451e946..000000000 --- a/irrlicht-1.6/source/Irrlicht/CParticleRingEmitter.h +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_PARTICLE_RING_EMITTER_H_INCLUDED__ -#define __C_PARTICLE_RING_EMITTER_H_INCLUDED__ - -#include "IParticleRingEmitter.h" -#include "irrArray.h" - -namespace irr -{ -namespace scene -{ - -//! A ring emitter -class CParticleRingEmitter : public IParticleRingEmitter -{ -public: - - //! constructor - CParticleRingEmitter( - const core::vector3df& center, f32 radius, f32 ringThickness, - const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f), - u32 minParticlesPerSecond = 20, - u32 maxParticlesPerSecond = 40, - const video::SColor& minStartColor = video::SColor(255,0,0,0), - const video::SColor& maxStartColor = video::SColor(255,255,255,255), - u32 lifeTimeMin=2000, - u32 lifeTimeMax=4000, - s32 maxAngleDegrees=0, - const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f), - const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) - ); - - //! Prepares an array with new particles to emitt into the system - //! and returns how much new particles there are. - virtual s32 emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray); - - //! Set direction the emitter emits particles - virtual void setDirection( const core::vector3df& newDirection ) { Direction = newDirection; } - - //! Set minimum number of particles the emitter emits per second - virtual void setMinParticlesPerSecond( u32 minPPS ) { MinParticlesPerSecond = minPPS; } - - //! Set maximum number of particles the emitter emits per second - virtual void setMaxParticlesPerSecond( u32 maxPPS ) { MaxParticlesPerSecond = maxPPS; } - - //! Set minimum starting color for particles - virtual void setMinStartColor( const video::SColor& color ) { MinStartColor = color; } - - //! Set maximum starting color for particles - virtual void setMaxStartColor( const video::SColor& color ) { MaxStartColor = color; } - - //! Set the maximum starting size for particles - virtual void setMaxStartSize( const core::dimension2df& size ) { MaxStartSize = size; }; - - //! Set the minimum starting size for particles - virtual void setMinStartSize( const core::dimension2df& size ) { MinStartSize = size; }; - - //! Set the center of the ring - virtual void setCenter( const core::vector3df& center ) { Center = center; } - - //! Set the radius of the ring - virtual void setRadius( f32 radius ) { Radius = radius; } - - //! Set the thickness of the ring - virtual void setRingThickness( f32 ringThickness ) { RingThickness = ringThickness; } - - //! Gets direction the emitter emits particles - virtual const core::vector3df& getDirection() const { return Direction; } - - //! Gets the minimum number of particles the emitter emits per second - virtual u32 getMinParticlesPerSecond() const { return MinParticlesPerSecond; } - - //! Gets the maximum number of particles the emitter emits per second - virtual u32 getMaxParticlesPerSecond() const { return MaxParticlesPerSecond; } - - //! Gets the minimum starting color for particles - virtual const video::SColor& getMinStartColor() const { return MinStartColor; } - - //! Gets the maximum starting color for particles - virtual const video::SColor& getMaxStartColor() const { return MaxStartColor; } - - //! Gets the maximum starting size for particles - virtual const core::dimension2df& getMaxStartSize() const { return MaxStartSize; }; - - //! Gets the minimum starting size for particles - virtual const core::dimension2df& getMinStartSize() const { return MinStartSize; }; - - //! Get the center of the ring - virtual const core::vector3df& getCenter() const { return Center; } - - //! Get the radius of the ring - virtual f32 getRadius() const { return Radius; } - - //! Get the thickness of the ring - virtual f32 getRingThickness() const { return RingThickness; } - -private: - - core::array<SParticle> Particles; - - core::vector3df Center; - f32 Radius; - f32 RingThickness; - - core::vector3df Direction; - core::dimension2df MaxStartSize, MinStartSize; - u32 MinParticlesPerSecond, MaxParticlesPerSecond; - video::SColor MinStartColor, MaxStartColor; - u32 MinLifeTime, MaxLifeTime; - - u32 Time; - u32 Emitted; - s32 MaxAngleDegrees; -}; - -} // end namespace scene -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CParticleRotationAffector.cpp b/irrlicht-1.6/source/Irrlicht/CParticleRotationAffector.cpp deleted file mode 100644 index 90a15949b..000000000 --- a/irrlicht-1.6/source/Irrlicht/CParticleRotationAffector.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CParticleRotationAffector.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CParticleRotationAffector::CParticleRotationAffector( const core::vector3df& speed, const core::vector3df& pivotPoint ) - : PivotPoint(pivotPoint), Speed(speed), LastTime(0) -{ - #ifdef _DEBUG - setDebugName("CParticleRotationAffector"); - #endif -} - - -//! Affects an array of particles. -void CParticleRotationAffector::affect(u32 now, SParticle* particlearray, u32 count) -{ - if( LastTime == 0 ) - { - LastTime = now; - return; - } - - f32 timeDelta = ( now - LastTime ) / 1000.0f; - LastTime = now; - - if( !Enabled ) - return; - - for(u32 i=0; i<count; ++i) - { - if( Speed.X != 0.0f ) - particlearray[i].pos.rotateYZBy( timeDelta * Speed.X, PivotPoint ); - - if( Speed.Y != 0.0f ) - particlearray[i].pos.rotateXZBy( timeDelta * Speed.Y, PivotPoint ); - - if( Speed.Z != 0.0f ) - particlearray[i].pos.rotateXYBy( timeDelta * Speed.Z, PivotPoint ); - } -} - - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CParticleRotationAffector.h b/irrlicht-1.6/source/Irrlicht/CParticleRotationAffector.h deleted file mode 100644 index 68fc81adb..000000000 --- a/irrlicht-1.6/source/Irrlicht/CParticleRotationAffector.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_PARTICLE_ROTATION_AFFECTOR_H_INCLUDED__ -#define __C_PARTICLE_ROTATION_AFFECTOR_H_INCLUDED__ - -#include "IParticleRotationAffector.h" - -namespace irr -{ -namespace scene -{ - -//! Particle Affector for rotating particles about a point -class CParticleRotationAffector : public IParticleRotationAffector -{ -public: - - CParticleRotationAffector( const core::vector3df& speed = core::vector3df(5.0f, 5.0f, 5.0f), - const core::vector3df& point = core::vector3df() ); - - //! Affects a particle. - virtual void affect(u32 now, SParticle* particlearray, u32 count); - - //! Set the point that particles will attract to - virtual void setPivotPoint( const core::vector3df& point ) { PivotPoint = point; } - - //! Set the speed in degrees per second - virtual void setSpeed( const core::vector3df& speed ) { Speed = speed; } - - //! Get the point that particles are attracted to - virtual const core::vector3df& getPivotPoint() const { return PivotPoint; } - - //! Get the speed in degrees per second - virtual const core::vector3df& getSpeed() const { return Speed; } - -private: - - core::vector3df PivotPoint; - core::vector3df Speed; - u32 LastTime; -}; - -} // end namespace scene -} // end namespace irr - - -#endif // __C_PARTICLE_ROTATION_AFFECTOR_H_INCLUDED__ - diff --git a/irrlicht-1.6/source/Irrlicht/CParticleScaleAffector.cpp b/irrlicht-1.6/source/Irrlicht/CParticleScaleAffector.cpp deleted file mode 100644 index b3c2715d5..000000000 --- a/irrlicht-1.6/source/Irrlicht/CParticleScaleAffector.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include "CParticleScaleAffector.h" -#include "IAttributes.h" - -namespace irr -{ - namespace scene - { - CParticleScaleAffector::CParticleScaleAffector(const core::dimension2df& scaleTo) - : ScaleTo(scaleTo) - { - #ifdef _DEBUG - setDebugName("CParticleScaleAffector"); - #endif - } - - - void CParticleScaleAffector::affect (u32 now, SParticle *particlearray, u32 count) - { - for(u32 i=0;i<count;i++) - { - const u32 maxdiff = particlearray[i].endTime - particlearray[i].startTime; - const u32 curdiff = now - particlearray[i].startTime; - const f32 newscale = (f32)curdiff/maxdiff; - particlearray[i].size = particlearray[i].startSize+ScaleTo*newscale; - } - } - - - void CParticleScaleAffector::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const - { - out->addFloat("ScaleToWidth", ScaleTo.Width); - out->addFloat("ScaleToHeight", ScaleTo.Height); - } - - - void CParticleScaleAffector::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) - { - ScaleTo.Width = in->getAttributeAsFloat("ScaleToWidth"); - ScaleTo.Height = in->getAttributeAsFloat("ScaleToHeight"); - } - - - E_PARTICLE_AFFECTOR_TYPE CParticleScaleAffector::getType() const - { - return scene::EPAT_SCALE; - } - } -} - diff --git a/irrlicht-1.6/source/Irrlicht/CParticleScaleAffector.h b/irrlicht-1.6/source/Irrlicht/CParticleScaleAffector.h deleted file mode 100644 index 99f7b0bfe..000000000 --- a/irrlicht-1.6/source/Irrlicht/CParticleScaleAffector.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef C_PARTICLE_SCALE_AFFECTOR_H -#define C_PARTICLE_SCALE_AFFECTOR_H - -#include <IParticleAffector.h> - -namespace irr -{ - namespace scene - { - class CParticleScaleAffector : public IParticleAffector - { - public: - CParticleScaleAffector(const core::dimension2df& scaleTo = core::dimension2df(1.0f, 1.0f)); - - virtual void affect(u32 now, SParticle *particlearray, u32 count); - - //! Writes attributes of the object. - //! Implement this to expose the attributes of your scene node animator for - //! scripting languages, editors, debuggers or xml serialization purposes. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; - - //! Reads attributes of the object. - //! Implement this to set the attributes of your scene node animator for - //! scripting languages, editors, debuggers or xml deserialization purposes. - //! \param startIndex: start index where to start reading attributes. - //! \return: returns last index of an attribute read by this affector - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - - //! Get emitter type - virtual E_PARTICLE_AFFECTOR_TYPE getType() const; - - protected: - core::dimension2df ScaleTo; - }; - } -} - - -#endif // C_PARTICLE_SCALE_AFFECTOR_H - diff --git a/irrlicht-1.6/source/Irrlicht/CParticleSphereEmitter.cpp b/irrlicht-1.6/source/Irrlicht/CParticleSphereEmitter.cpp deleted file mode 100644 index 5fefe7df0..000000000 --- a/irrlicht-1.6/source/Irrlicht/CParticleSphereEmitter.cpp +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright (C) 2002-2009 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" -#include "CParticleSphereEmitter.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CParticleSphereEmitter::CParticleSphereEmitter( - const core::vector3df& center, f32 radius, - const core::vector3df& direction, u32 minParticlesPerSecond, - u32 maxParticlesPerSecond, const video::SColor& minStartColor, - const video::SColor& maxStartColor, u32 lifeTimeMin, u32 lifeTimeMax, - s32 maxAngleDegrees, - const core::dimension2df& minStartSize, - const core::dimension2df& maxStartSize ) - : Center(center), Radius(radius), Direction(direction), - MinStartSize(minStartSize), MaxStartSize(maxStartSize), - MinParticlesPerSecond(minParticlesPerSecond), - MaxParticlesPerSecond(maxParticlesPerSecond), - MinStartColor(minStartColor), MaxStartColor(maxStartColor), - MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax), - Time(0), Emitted(0), MaxAngleDegrees(maxAngleDegrees) -{ - #ifdef _DEBUG - setDebugName("CParticleSphereEmitter"); - #endif - -} - - -//! Prepares an array with new particles to emitt into the system -//! and returns how much new particles there are. -s32 CParticleSphereEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray) -{ - Time += timeSinceLastCall; - - const u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond); - const f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond; - const f32 everyWhatMillisecond = 1000.0f / perSecond; - - if(Time > everyWhatMillisecond) - { - Particles.set_used(0); - u32 amount = (u32)((Time / everyWhatMillisecond) + 0.5f); - Time = 0; - SParticle p; - - if(amount > MaxParticlesPerSecond*2) - amount = MaxParticlesPerSecond * 2; - - for(u32 i=0; i<amount; ++i) - { - // Random distance from center - f32 distance = fmodf( (f32)os::Randomizer::rand(), Radius * 1000.0f ) * 0.001f; - - // Random direction from center - p.pos.set(Center + distance); - p.pos.rotateXYBy( os::Randomizer::rand() % 360, Center ); - p.pos.rotateYZBy( os::Randomizer::rand() % 360, Center ); - p.pos.rotateXZBy( os::Randomizer::rand() % 360, Center ); - - p.startTime = now; - p.vector = Direction; - - if(MaxAngleDegrees) - { - core::vector3df tgt = Direction; - tgt.rotateXYBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees); - tgt.rotateYZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees); - tgt.rotateXZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees); - p.vector = tgt; - } - - if(MaxLifeTime - MinLifeTime == 0) - p.endTime = now + MinLifeTime; - else - p.endTime = now + MinLifeTime + (os::Randomizer::rand() % (MaxLifeTime - MinLifeTime)); - - p.color = MinStartColor.getInterpolated( - MaxStartColor, (os::Randomizer::rand() % 100) / 100.0f); - - p.startColor = p.color; - p.startVector = p.vector; - - if (MinStartSize==MaxStartSize) - p.startSize = MinStartSize; - else - p.startSize = MinStartSize.getInterpolated( - MaxStartSize, (os::Randomizer::rand() % 100) / 100.0f); - p.size = p.startSize; - - Particles.push_back(p); - } - - outArray = Particles.pointer(); - - return Particles.size(); - } - - return 0; -} - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CParticleSphereEmitter.h b/irrlicht-1.6/source/Irrlicht/CParticleSphereEmitter.h deleted file mode 100644 index 7618d0bf5..000000000 --- a/irrlicht-1.6/source/Irrlicht/CParticleSphereEmitter.h +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_PARTICLE_SPHERE_EMITTER_H_INCLUDED__ -#define __C_PARTICLE_SPHERE_EMITTER_H_INCLUDED__ - -#include "IParticleSphereEmitter.h" -#include "irrArray.h" -#include "aabbox3d.h" - -namespace irr -{ -namespace scene -{ - -//! A default box emitter -class CParticleSphereEmitter : public IParticleSphereEmitter -{ -public: - - //! constructor - CParticleSphereEmitter( - const core::vector3df& center, f32 radius, - const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f), - u32 minParticlesPerSecond = 20, - u32 maxParticlesPerSecond = 40, - const video::SColor& minStartColor = video::SColor(255,0,0,0), - const video::SColor& maxStartColor = video::SColor(255,255,255,255), - u32 lifeTimeMin=2000, - u32 lifeTimeMax=4000, - s32 maxAngleDegrees=0, - const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f), - const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) ); - - //! Prepares an array with new particles to emitt into the system - //! and returns how much new particles there are. - virtual s32 emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray); - - //! Set direction the emitter emits particles - virtual void setDirection( const core::vector3df& newDirection ) { Direction = newDirection; } - - //! Set minimum number of particles per second. - virtual void setMinParticlesPerSecond( u32 minPPS ) { MinParticlesPerSecond = minPPS; } - - //! Set maximum number of particles per second. - virtual void setMaxParticlesPerSecond( u32 maxPPS ) { MaxParticlesPerSecond = maxPPS; } - - //! Set minimum start color - virtual void setMinStartColor( const video::SColor& color ) { MinStartColor = color; } - - //! Set maximum start color - virtual void setMaxStartColor( const video::SColor& color ) { MaxStartColor = color; } - - //! Set the maximum starting size for particles - virtual void setMaxStartSize( const core::dimension2df& size ) { MaxStartSize = size; }; - - //! Set the minimum starting size for particles - virtual void setMinStartSize( const core::dimension2df& size ) { MinStartSize = size; }; - - //! Set the center of the sphere for particle emissions - virtual void setCenter( const core::vector3df& center ) { Center = center; } - - //! Set the radius of the sphere for particle emissions - virtual void setRadius( f32 radius ) { Radius = radius; } - - //! Gets direction the emitter emits particles - virtual const core::vector3df& getDirection() const { return Direction; } - - //! Get minimum number of particles per second. - virtual u32 getMinParticlesPerSecond() const { return MinParticlesPerSecond; } - - //! Get maximum number of particles per second. - virtual u32 getMaxParticlesPerSecond() const { return MaxParticlesPerSecond; } - - //! Get minimum start color - virtual const video::SColor& getMinStartColor() const { return MinStartColor; } - - //! Get maximum start color - virtual const video::SColor& getMaxStartColor() const { return MaxStartColor; } - - //! Gets the maximum starting size for particles - virtual const core::dimension2df& getMaxStartSize() const { return MaxStartSize; }; - - //! Gets the minimum starting size for particles - virtual const core::dimension2df& getMinStartSize() const { return MinStartSize; }; - - //! Get the center of the sphere for particle emissions - virtual const core::vector3df& getCenter() const { return Center; } - - //! Get the radius of the sphere for particle emissions - virtual f32 getRadius() const { return Radius; } - -private: - - core::array<SParticle> Particles; - - core::vector3df Center; - f32 Radius; - core::vector3df Direction; - - core::dimension2df MinStartSize, MaxStartSize; - u32 MinParticlesPerSecond, MaxParticlesPerSecond; - video::SColor MinStartColor, MaxStartColor; - u32 MinLifeTime, MaxLifeTime; - - u32 Time; - u32 Emitted; - s32 MaxAngleDegrees; -}; - -} // end namespace scene -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CParticleSystemSceneNode.cpp b/irrlicht-1.6/source/Irrlicht/CParticleSystemSceneNode.cpp deleted file mode 100644 index 24ad0f169..000000000 --- a/irrlicht-1.6/source/Irrlicht/CParticleSystemSceneNode.cpp +++ /dev/null @@ -1,682 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CParticleSystemSceneNode.h" -#include "os.h" -#include "ISceneManager.h" -#include "ICameraSceneNode.h" -#include "IVideoDriver.h" - -#include "CParticleAnimatedMeshSceneNodeEmitter.h" -#include "CParticleBoxEmitter.h" -#include "CParticleCylinderEmitter.h" -#include "CParticleMeshEmitter.h" -#include "CParticlePointEmitter.h" -#include "CParticleRingEmitter.h" -#include "CParticleSphereEmitter.h" -#include "CParticleAttractionAffector.h" -#include "CParticleFadeOutAffector.h" -#include "CParticleGravityAffector.h" -#include "CParticleRotationAffector.h" -#include "CParticleScaleAffector.h" -#include "SViewFrustum.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CParticleSystemSceneNode::CParticleSystemSceneNode(bool createDefaultEmitter, - ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position, const core::vector3df& rotation, - const core::vector3df& scale) - : IParticleSystemSceneNode(parent, mgr, id, position, rotation, scale), - Emitter(0), ParticleSize(core::dimension2d<f32>(5.0f, 5.0f)), LastEmitTime(0), - MaxParticles(0xffff), Buffer(0), ParticlesAreGlobal(true) -{ - #ifdef _DEBUG - setDebugName("CParticleSystemSceneNode"); - #endif - - Buffer = new SMeshBuffer(); - if (createDefaultEmitter) - { - IParticleEmitter* e = createBoxEmitter(); - setEmitter(e); - e->drop(); - } -} - - -//! destructor -CParticleSystemSceneNode::~CParticleSystemSceneNode() -{ - if (Emitter) - Emitter->drop(); - if (Buffer) - Buffer->drop(); - - removeAllAffectors(); -} - - -//! Gets the particle emitter, which creates the particles. -IParticleEmitter* CParticleSystemSceneNode::getEmitter() -{ - return Emitter; -} - - -//! Sets the particle emitter, which creates the particles. -void CParticleSystemSceneNode::setEmitter(IParticleEmitter* emitter) -{ - if (emitter == Emitter) - return; - if (Emitter) - Emitter->drop(); - - Emitter = emitter; - - if (Emitter) - Emitter->grab(); -} - - -//! Adds new particle effector to the particle system. -void CParticleSystemSceneNode::addAffector(IParticleAffector* affector) -{ - affector->grab(); - AffectorList.push_back(affector); -} - - -//! Removes all particle affectors in the particle system. -void CParticleSystemSceneNode::removeAllAffectors() -{ - core::list<IParticleAffector*>::Iterator it = AffectorList.begin(); - while (it != AffectorList.end()) - { - (*it)->drop(); - it = AffectorList.erase(it); - } -} - - -//! Returns the material based on the zero based index i. -video::SMaterial& CParticleSystemSceneNode::getMaterial(u32 i) -{ - return Buffer->Material; -} - - -//! Returns amount of materials used by this scene node. -u32 CParticleSystemSceneNode::getMaterialCount() const -{ - return 1; -} - - -//! Creates a particle emitter for an animated mesh scene node -IParticleAnimatedMeshSceneNodeEmitter* -CParticleSystemSceneNode::createAnimatedMeshSceneNodeEmitter( - scene::IAnimatedMeshSceneNode* node, bool useNormalDirection, - const core::vector3df& direction, f32 normalDirectionModifier, - s32 mbNumber, bool everyMeshVertex, - u32 minParticlesPerSecond, u32 maxParticlesPerSecond, - const video::SColor& minStartColor, const video::SColor& maxStartColor, - u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees, - const core::dimension2df& minStartSize, - const core::dimension2df& maxStartSize ) -{ - return new CParticleAnimatedMeshSceneNodeEmitter( node, - useNormalDirection, direction, normalDirectionModifier, - mbNumber, everyMeshVertex, - minParticlesPerSecond, maxParticlesPerSecond, - minStartColor, maxStartColor, - lifeTimeMin, lifeTimeMax, maxAngleDegrees, - minStartSize, maxStartSize ); -} - - -//! Creates a box particle emitter. -IParticleBoxEmitter* CParticleSystemSceneNode::createBoxEmitter( - const core::aabbox3df& box, const core::vector3df& direction, - u32 minParticlesPerSecond, u32 maxParticlesPerSecond, - const video::SColor& minStartColor, const video::SColor& maxStartColor, - u32 lifeTimeMin, u32 lifeTimeMax, - s32 maxAngleDegrees, const core::dimension2df& minStartSize, - const core::dimension2df& maxStartSize ) -{ - return new CParticleBoxEmitter(box, direction, minParticlesPerSecond, - maxParticlesPerSecond, minStartColor, maxStartColor, - lifeTimeMin, lifeTimeMax, maxAngleDegrees, - minStartSize, maxStartSize ); -} - - -//! Creates a particle emitter for emitting from a cylinder -IParticleCylinderEmitter* CParticleSystemSceneNode::createCylinderEmitter( - const core::vector3df& center, f32 radius, - const core::vector3df& normal, f32 length, - bool outlineOnly, const core::vector3df& direction, - u32 minParticlesPerSecond, u32 maxParticlesPerSecond, - const video::SColor& minStartColor, const video::SColor& maxStartColor, - u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees, - const core::dimension2df& minStartSize, - const core::dimension2df& maxStartSize ) -{ - return new CParticleCylinderEmitter( center, radius, normal, length, - outlineOnly, direction, - minParticlesPerSecond, maxParticlesPerSecond, - minStartColor, maxStartColor, - lifeTimeMin, lifeTimeMax, maxAngleDegrees, - minStartSize, maxStartSize ); -} - - -//! Creates a mesh particle emitter. -IParticleMeshEmitter* CParticleSystemSceneNode::createMeshEmitter( - scene::IMesh* mesh, bool useNormalDirection, - const core::vector3df& direction, f32 normalDirectionModifier, - s32 mbNumber, bool everyMeshVertex, - u32 minParticlesPerSecond, u32 maxParticlesPerSecond, - const video::SColor& minStartColor, const video::SColor& maxStartColor, - u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees, - const core::dimension2df& minStartSize, - const core::dimension2df& maxStartSize) -{ - return new CParticleMeshEmitter( mesh, useNormalDirection, direction, - normalDirectionModifier, mbNumber, everyMeshVertex, - minParticlesPerSecond, maxParticlesPerSecond, - minStartColor, maxStartColor, - lifeTimeMin, lifeTimeMax, maxAngleDegrees, - minStartSize, maxStartSize ); -} - - -//! Creates a point particle emitter. -IParticlePointEmitter* CParticleSystemSceneNode::createPointEmitter( - const core::vector3df& direction, u32 minParticlesPerSecond, - u32 maxParticlesPerSecond, const video::SColor& minStartColor, - const video::SColor& maxStartColor, u32 lifeTimeMin, u32 lifeTimeMax, - s32 maxAngleDegrees, const core::dimension2df& minStartSize, - const core::dimension2df& maxStartSize ) -{ - return new CParticlePointEmitter(direction, minParticlesPerSecond, - maxParticlesPerSecond, minStartColor, maxStartColor, - lifeTimeMin, lifeTimeMax, maxAngleDegrees, - minStartSize, maxStartSize ); -} - - -//! Creates a ring particle emitter. -IParticleRingEmitter* CParticleSystemSceneNode::createRingEmitter( - const core::vector3df& center, f32 radius, f32 ringThickness, - const core::vector3df& direction, - u32 minParticlesPerSecond, u32 maxParticlesPerSecond, - const video::SColor& minStartColor, const video::SColor& maxStartColor, - u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees, - const core::dimension2df& minStartSize, const core::dimension2df& maxStartSize ) -{ - return new CParticleRingEmitter( center, radius, ringThickness, direction, - minParticlesPerSecond, maxParticlesPerSecond, minStartColor, - maxStartColor, lifeTimeMin, lifeTimeMax, maxAngleDegrees, - minStartSize, maxStartSize ); -} - - -//! Creates a sphere particle emitter. -IParticleSphereEmitter* CParticleSystemSceneNode::createSphereEmitter( - const core::vector3df& center, f32 radius, const core::vector3df& direction, - u32 minParticlesPerSecond, u32 maxParticlesPerSecond, - const video::SColor& minStartColor, const video::SColor& maxStartColor, - u32 lifeTimeMin, u32 lifeTimeMax, - s32 maxAngleDegrees, const core::dimension2df& minStartSize, - const core::dimension2df& maxStartSize ) -{ - return new CParticleSphereEmitter(center, radius, direction, - minParticlesPerSecond, maxParticlesPerSecond, - minStartColor, maxStartColor, - lifeTimeMin, lifeTimeMax, maxAngleDegrees, - minStartSize, maxStartSize ); -} - - -//! Creates a point attraction affector. This affector modifies the positions of the -//! particles and attracts them to a specified point at a specified speed per second. -IParticleAttractionAffector* CParticleSystemSceneNode::createAttractionAffector( - const core::vector3df& point, f32 speed, bool attract, - bool affectX, bool affectY, bool affectZ ) -{ - return new CParticleAttractionAffector( point, speed, attract, affectX, affectY, affectZ ); -} - -//! Creates a scale particle affector. -IParticleAffector* CParticleSystemSceneNode::createScaleParticleAffector(const core::dimension2df& scaleTo) -{ - return new CParticleScaleAffector(scaleTo); -} - - -//! Creates a fade out particle affector. -IParticleFadeOutAffector* CParticleSystemSceneNode::createFadeOutParticleAffector( - const video::SColor& targetColor, u32 timeNeededToFadeOut) -{ - return new CParticleFadeOutAffector(targetColor, timeNeededToFadeOut); -} - - -//! Creates a gravity affector. -IParticleGravityAffector* CParticleSystemSceneNode::createGravityAffector( - const core::vector3df& gravity, u32 timeForceLost) -{ - return new CParticleGravityAffector(gravity, timeForceLost); -} - - -//! Creates a rotation affector. This affector rotates the particles around a specified pivot -//! point. The speed represents Degrees of rotation per second. -IParticleRotationAffector* CParticleSystemSceneNode::createRotationAffector( - const core::vector3df& speed, const core::vector3df& pivotPoint ) -{ - return new CParticleRotationAffector( speed, pivotPoint ); -} - - -//! pre render event -void CParticleSystemSceneNode::OnRegisterSceneNode() -{ - doParticleSystem(os::Timer::getTime()); - - if (IsVisible && (Particles.size() != 0)) - { - SceneManager->registerNodeForRendering(this); - ISceneNode::OnRegisterSceneNode(); - } -} - - -//! render -void CParticleSystemSceneNode::render() -{ - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - ICameraSceneNode* camera = SceneManager->getActiveCamera(); - - if (!camera || !driver) - return; - - -#if 0 - // calculate vectors for letting particles look to camera - core::vector3df view(camera->getTarget() - camera->getAbsolutePosition()); - view.normalize(); - - view *= -1.0f; - -#else - - const core::matrix4 &m = camera->getViewFrustum()->getTransform( video::ETS_VIEW ); - - const core::vector3df view ( -m[2], -m[6] , -m[10] ); - -#endif - - // reallocate arrays, if they are too small - reallocateBuffers(); - - // create particle vertex data - s32 idx = 0; - for (u32 i=0; i<Particles.size(); ++i) - { - const SParticle& particle = Particles[i]; - - #if 0 - core::vector3df horizontal = camera->getUpVector().crossProduct(view); - horizontal.normalize(); - horizontal *= 0.5f * particle.size.Width; - - core::vector3df vertical = horizontal.crossProduct(view); - vertical.normalize(); - vertical *= 0.5f * particle.size.Height; - - #else - f32 f; - - f = 0.5f * particle.size.Width; - const core::vector3df horizontal ( m[0] * f, m[4] * f, m[8] * f ); - - f = -0.5f * particle.size.Height; - const core::vector3df vertical ( m[1] * f, m[5] * f, m[9] * f ); - #endif - - Buffer->Vertices[0+idx].Pos = particle.pos + horizontal + vertical; - Buffer->Vertices[0+idx].Color = particle.color; - Buffer->Vertices[0+idx].Normal = view; - - Buffer->Vertices[1+idx].Pos = particle.pos + horizontal - vertical; - Buffer->Vertices[1+idx].Color = particle.color; - Buffer->Vertices[1+idx].Normal = view; - - Buffer->Vertices[2+idx].Pos = particle.pos - horizontal - vertical; - Buffer->Vertices[2+idx].Color = particle.color; - Buffer->Vertices[2+idx].Normal = view; - - Buffer->Vertices[3+idx].Pos = particle.pos - horizontal + vertical; - Buffer->Vertices[3+idx].Color = particle.color; - Buffer->Vertices[3+idx].Normal = view; - - idx +=4; - } - - // render all - core::matrix4 mat; - if (!ParticlesAreGlobal) - mat.setTranslation(AbsoluteTransformation.getTranslation()); - driver->setTransform(video::ETS_WORLD, mat); - - driver->setMaterial(Buffer->Material); - - driver->drawVertexPrimitiveList(Buffer->getVertices(), Particles.size()*4, - Buffer->getIndices(), Particles.size()*2, video::EVT_STANDARD, EPT_TRIANGLES,Buffer->getIndexType()); - - // for debug purposes only: - if ( DebugDataVisible & scene::EDS_BBOX ) - { - driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); - video::SMaterial deb_m; - deb_m.Lighting = false; - driver->setMaterial(deb_m); - driver->draw3DBox(Buffer->BoundingBox, video::SColor(0,255,255,255)); - } -} - - -//! returns the axis aligned bounding box of this node -const core::aabbox3d<f32>& CParticleSystemSceneNode::getBoundingBox() const -{ - return Buffer->getBoundingBox(); -} - - -void CParticleSystemSceneNode::doParticleSystem(u32 time) -{ - if (LastEmitTime==0) - { - LastEmitTime = time; - return; - } - - u32 now = time; - u32 timediff = time - LastEmitTime; - LastEmitTime = time; - - // run emitter - - if (Emitter && IsVisible) - { - SParticle* array = 0; - s32 newParticles = Emitter->emitt(now, timediff, array); - - if (newParticles && array) - { - s32 j=Particles.size(); - if (newParticles > 16250-j) - newParticles=16250-j; - Particles.set_used(j+newParticles); - for (s32 i=j; i<j+newParticles; ++i) - { - Particles[i]=array[i-j]; - AbsoluteTransformation.rotateVect(Particles[i].startVector); - if (ParticlesAreGlobal) - AbsoluteTransformation.transformVect(Particles[i].pos); - } - } - } - - // run affectors - core::list<IParticleAffector*>::Iterator ait = AffectorList.begin(); - for (; ait != AffectorList.end(); ++ait) - (*ait)->affect(now, Particles.pointer(), Particles.size()); - - if (ParticlesAreGlobal) - Buffer->BoundingBox.reset(AbsoluteTransformation.getTranslation()); - else - Buffer->BoundingBox.reset(core::vector3df(0,0,0)); - - // animate all particles - f32 scale = (f32)timediff; - - for (u32 i=0; i<Particles.size();) - { - if (now > Particles[i].endTime) - Particles.erase(i); - else - { - Particles[i].pos += (Particles[i].vector * scale); - Buffer->BoundingBox.addInternalPoint(Particles[i].pos); - ++i; - } - } - - const f32 m = (ParticleSize.Width > ParticleSize.Height ? ParticleSize.Width : ParticleSize.Height) * 0.5f; - Buffer->BoundingBox.MaxEdge.X += m; - Buffer->BoundingBox.MaxEdge.Y += m; - Buffer->BoundingBox.MaxEdge.Z += m; - - Buffer->BoundingBox.MinEdge.X -= m; - Buffer->BoundingBox.MinEdge.Y -= m; - Buffer->BoundingBox.MinEdge.Z -= m; - - if (ParticlesAreGlobal) - { - core::matrix4 absinv( AbsoluteTransformation, core::matrix4::EM4CONST_INVERSE ); - absinv.transformBoxEx(Buffer->BoundingBox); - } -} - - -//! Sets if the particles should be global. If it is, the particles are affected by -//! the movement of the particle system scene node too, otherwise they completely -//! ignore it. Default is true. -void CParticleSystemSceneNode::setParticlesAreGlobal(bool global) -{ - ParticlesAreGlobal = global; -} - - -//! Sets the size of all particles. -void CParticleSystemSceneNode::setParticleSize(const core::dimension2d<f32> &size) -{ - os::Printer::log("setParticleSize is deprecated, use setMinStartSize/setMaxStartSize in emitter.", irr::ELL_WARNING); - //A bit of a hack, but better here than in the particle code - if (Emitter) - { - Emitter->setMinStartSize(size); - Emitter->setMaxStartSize(size); - } - ParticleSize = size; -} - - -void CParticleSystemSceneNode::reallocateBuffers() -{ - if (Particles.size() * 4 > Buffer->getVertexCount() || - Particles.size() * 6 > Buffer->getIndexCount()) - { - u32 oldSize = Buffer->getVertexCount(); - Buffer->Vertices.set_used(Particles.size() * 4); - - u32 i; - - // fill remaining vertices - for (i=oldSize; i<Buffer->Vertices.size(); i+=4) - { - Buffer->Vertices[0+i].TCoords.set(0.0f, 0.0f); - Buffer->Vertices[1+i].TCoords.set(0.0f, 1.0f); - Buffer->Vertices[2+i].TCoords.set(1.0f, 1.0f); - Buffer->Vertices[3+i].TCoords.set(1.0f, 0.0f); - } - - // fill remaining indices - u32 oldIdxSize = Buffer->getIndexCount(); - u32 oldvertices = oldSize; - Buffer->Indices.set_used(Particles.size() * 6); - - for (i=oldIdxSize; i<Buffer->Indices.size(); i+=6) - { - Buffer->Indices[0+i] = (u16)0+oldvertices; - Buffer->Indices[1+i] = (u16)2+oldvertices; - Buffer->Indices[2+i] = (u16)1+oldvertices; - Buffer->Indices[3+i] = (u16)0+oldvertices; - Buffer->Indices[4+i] = (u16)3+oldvertices; - Buffer->Indices[5+i] = (u16)2+oldvertices; - oldvertices += 4; - } - } -} - - -//! Writes attributes of the scene node. -void CParticleSystemSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const -{ - IParticleSystemSceneNode::serializeAttributes(out, options); - - out->addBool("GlobalParticles", ParticlesAreGlobal); - out->addFloat("ParticleWidth", ParticleSize.Width); - out->addFloat("ParticleHeight", ParticleSize.Height); - - // write emitter - - E_PARTICLE_EMITTER_TYPE type = EPET_COUNT; - if (Emitter) - type = Emitter->getType(); - - out->addEnum("Emitter", (s32)type, ParticleEmitterTypeNames); - - if (Emitter) - Emitter->serializeAttributes(out, options); - - // write affectors - - E_PARTICLE_AFFECTOR_TYPE atype = EPAT_NONE; - - for (core::list<IParticleAffector*>::ConstIterator it = AffectorList.begin(); - it != AffectorList.end(); ++it) - { - atype = (*it)->getType(); - - out->addEnum("Affector", (s32)atype, ParticleAffectorTypeNames); - - (*it)->serializeAttributes(out); - } - - // add empty affector to make it possible to add further affectors - - if (options && options->Flags & io::EARWF_FOR_EDITOR) - out->addEnum("Affector", EPAT_NONE, ParticleAffectorTypeNames); -} - - -//! Reads attributes of the scene node. -void CParticleSystemSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - IParticleSystemSceneNode::deserializeAttributes(in, options); - - ParticlesAreGlobal = in->getAttributeAsBool("GlobalParticles"); - ParticleSize.Width = in->getAttributeAsFloat("ParticleWidth"); - ParticleSize.Height = in->getAttributeAsFloat("ParticleHeight"); - - // read emitter - - int emitterIdx = in->findAttribute("Emitter"); - if (emitterIdx == -1) - return; - - if (Emitter) - Emitter->drop(); - Emitter = 0; - - E_PARTICLE_EMITTER_TYPE type = (E_PARTICLE_EMITTER_TYPE) - in->getAttributeAsEnumeration("Emitter", ParticleEmitterTypeNames); - - switch(type) - { - case EPET_POINT: - Emitter = createPointEmitter(); - break; - case EPET_BOX: - Emitter = createBoxEmitter(); - break; - default: - break; - } - - u32 idx = 0; - -#if 0 - if (Emitter) - idx = Emitter->deserializeAttributes(idx, in); - - ++idx; -#else - if (Emitter) - Emitter->deserializeAttributes(in); -#endif - - // read affectors - - removeAllAffectors(); - u32 cnt = in->getAttributeCount(); - - while(idx < cnt) - { - const char* name = in->getAttributeName(idx); - - if (!name || strcmp("Affector", name)) - return; - - E_PARTICLE_AFFECTOR_TYPE atype = - (E_PARTICLE_AFFECTOR_TYPE)in->getAttributeAsEnumeration(idx, ParticleAffectorTypeNames); - - IParticleAffector* aff = 0; - - switch(atype) - { - case EPAT_FADE_OUT: - aff = createFadeOutParticleAffector(); - break; - case EPAT_GRAVITY: - aff = createGravityAffector(); - break; - case EPAT_SCALE: - aff = createScaleParticleAffector(); - break; - case EPAT_NONE: - default: - break; - } - - ++idx; - - if (aff) - { -#if 0 - idx = aff->deserializeAttributes(idx, in, options); - ++idx; -#else - aff->deserializeAttributes(in, options); -#endif - - addAffector(aff); - aff->drop(); - } - } -} - - -} // end namespace scene -} // end namespace irr - - diff --git a/irrlicht-1.6/source/Irrlicht/CParticleSystemSceneNode.h b/irrlicht-1.6/source/Irrlicht/CParticleSystemSceneNode.h deleted file mode 100644 index 915cf95ed..000000000 --- a/irrlicht-1.6/source/Irrlicht/CParticleSystemSceneNode.h +++ /dev/null @@ -1,229 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_PARTICLE_SYSTEM_SCENE_NODE_H_INCLUDED__ -#define __C_PARTICLE_SYSTEM_SCENE_NODE_H_INCLUDED__ - -#include "IParticleSystemSceneNode.h" -#include "irrArray.h" -#include "irrList.h" -#include "SMeshBuffer.h" - -namespace irr -{ -namespace scene -{ - -//! A particle system scene node. -/** A scene node controlling a particle system. The behavior of the particles -can be controlled by setting the right particle emitters and affectors. -*/ -class CParticleSystemSceneNode : public IParticleSystemSceneNode -{ -public: - - //! constructor - CParticleSystemSceneNode(bool createDefaultEmitter, - ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position, - const core::vector3df& rotation, - const core::vector3df& scale); - - //! destructor - virtual ~CParticleSystemSceneNode(); - - //! Gets the particle emitter, which creates the particles. - virtual IParticleEmitter* getEmitter(); - - //! Sets the particle emitter, which creates the particles. - virtual void setEmitter(IParticleEmitter* emitter); - - //! Adds new particle affector to the particle system. - virtual void addAffector(IParticleAffector* affector); - - //! Removes all particle affectors in the particle system. - virtual void removeAllAffectors(); - - //! Returns the material based on the zero based index i. - virtual video::SMaterial& getMaterial(u32 i); - - //! Returns amount of materials used by this scene node. - virtual u32 getMaterialCount() const; - - //! pre render event - virtual void OnRegisterSceneNode(); - - //! render - virtual void render(); - - //! returns the axis aligned bounding box of this node - virtual const core::aabbox3d<f32>& getBoundingBox() const; - - //! Creates a particle emitter for an animated mesh scene node - virtual IParticleAnimatedMeshSceneNodeEmitter* createAnimatedMeshSceneNodeEmitter( - scene::IAnimatedMeshSceneNode* node, bool useNormalDirection = true, - const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f), - f32 normalDirectionModifier = 100.0f, s32 mbNumber = -1, - bool everyMeshVertex = false, u32 minParticlesPerSecond = 5, - u32 maxParticlesPerSecond = 10, - const video::SColor& minStartColor = video::SColor(255,0,0,0), - const video::SColor& maxStartColor = video::SColor(255,255,255,255), - u32 lifeTimeMin = 2000, u32 lifeTimeMax = 4000, - s32 maxAngleDegrees = 0, - const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f), - const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) ); - - //! Creates a box particle emitter. - virtual IParticleBoxEmitter* createBoxEmitter( - const core::aabbox3df& box = core::aabbox3d<f32>(-10,0,-10,5,30,10), - const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f), - u32 minParticlesPerSecond = 5, - u32 maxParticlesPerSecond = 10, - const video::SColor& minStartColor = video::SColor(255,0,0,0), - const video::SColor& maxStartColor = video::SColor(255,255,255,255), - u32 lifeTimeMin=2000, u32 lifeTimeMax=4000, - s32 maxAngleDegrees=0, - const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f), - const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) ); - - //! Creates a particle emitter for emitting from a cylinder - virtual IParticleCylinderEmitter* createCylinderEmitter( - const core::vector3df& center, f32 radius, - const core::vector3df& normal, f32 length, - bool outlineOnly = false, const core::vector3df& direction = core::vector3df(0.0f,0.5f,0.0f), - u32 minParticlesPerSecond = 5, u32 maxParticlesPersSecond = 10, - const video::SColor& minStartColor = video::SColor(255,0,0,0), - const video::SColor& maxStartColor = video::SColor(255,255,255,255), - u32 lifeTimeMin = 2000, u32 lifeTimeMax = 4000, - s32 maxAngleDegrees = 0, - const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f), - const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) ); - - //! Creates a mesh particle emitter. - virtual IParticleMeshEmitter* createMeshEmitter( - scene::IMesh* mesh, bool useNormalDirection = true, - const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f), - f32 normalDirectionModifier = 100.0f, s32 mbNumber = -1, - bool everyMeshVertex = false, - u32 minParticlesPerSecond = 5, - u32 maxParticlesPerSecond = 10, - const video::SColor& minStartColor = video::SColor(255,0,0,0), - const video::SColor& maxStartColor = video::SColor(255,255,255,255), - u32 lifeTimeMin = 2000, u32 lifeTimeMax = 4000, - s32 maxAngleDegrees = 0, - const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f), - const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) ); - - //! Creates a point particle emitter. - virtual IParticlePointEmitter* createPointEmitter( - const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f), - u32 minParticlesPerSecond = 5, - u32 maxParticlesPerSecond = 10, - const video::SColor& minStartColor = video::SColor(255,0,0,0), - const video::SColor& maxStartColor = video::SColor(255,255,255,255), - u32 lifeTimeMin=2000, u32 lifeTimeMax=4000, - s32 maxAngleDegrees=0, - const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f), - const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) ); - - //! Creates a ring particle emitter. - virtual IParticleRingEmitter* createRingEmitter( - const core::vector3df& center, f32 radius, f32 ringThickness, - const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f), - u32 minParticlesPerSecond = 5, - u32 maxParticlesPerSecond = 10, - const video::SColor& minStartColor = video::SColor(255,0,0,0), - const video::SColor& maxStartColor = video::SColor(255,255,255,255), - u32 lifeTimeMin=2000, u32 lifeTimeMax=4000, - s32 maxAngleDegrees=0, - const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f), - const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) ); - - //! Creates a sphere particle emitter. - virtual IParticleSphereEmitter* createSphereEmitter( - const core::vector3df& center, f32 radius, - const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f), - u32 minParticlesPerSecond = 5, - u32 maxParticlesPerSecond = 10, - const video::SColor& minStartColor = video::SColor(255,0,0,0), - const video::SColor& maxStartColor = video::SColor(255,255,255,255), - u32 lifeTimeMin=2000, u32 lifeTimeMax=4000, - s32 maxAngleDegrees=0, - const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f), - const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) ); - - //! Creates a point attraction affector. This affector modifies the positions of the - //! particles and attracts them to a specified point at a specified speed per second. - virtual IParticleAttractionAffector* createAttractionAffector( - const core::vector3df& point, f32 speed = 1.0f, bool attract = true, - bool affectX = true, bool affectY = true, bool affectZ = true); - - //! Creates a scale particle affector. - virtual IParticleAffector* createScaleParticleAffector(const core::dimension2df& scaleTo = core::dimension2df(1.0f, 1.0f)); - - //! Creates a fade out particle affector. - virtual IParticleFadeOutAffector* createFadeOutParticleAffector( - const video::SColor& targetColor = video::SColor(0,0,0,0), - u32 timeNeededToFadeOut = 1000); - - //! Creates a gravity affector. - virtual IParticleGravityAffector* createGravityAffector( - const core::vector3df& gravity = core::vector3df(0.0f,-0.03f,0.0f), - u32 timeForceLost = 1000); - - //! Creates a rotation affector. This affector rotates the particles - //! around a specified pivot point. The speed is in Degrees per second. - virtual IParticleRotationAffector* createRotationAffector( - const core::vector3df& speed = core::vector3df(5.0f,5.0f,5.0f), - const core::vector3df& pivotPoint = core::vector3df(0.0f,0.0f,0.0f) ); - - //! Sets the size of all particles. - virtual void setParticleSize( - const core::dimension2d<f32> &size = core::dimension2d<f32>(5.0f, 5.0f)); - - //! Sets if the particles should be global. If they are, the particles are affected by - //! the movement of the particle system scene node too, otherwise they completely - //! ignore it. Default is true. - virtual void setParticlesAreGlobal(bool global=true); - - //! Writes attributes of the scene node. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const; - - //! Reads attributes of the scene node. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() const { return ESNT_PARTICLE_SYSTEM; } - -private: - - void doParticleSystem(u32 time); - void reallocateBuffers(); - - core::list<IParticleAffector*> AffectorList; - IParticleEmitter* Emitter; - core::array<SParticle> Particles; - core::dimension2d<f32> ParticleSize; - u32 LastEmitTime; - s32 MaxParticles; - - SMeshBuffer* Buffer; - - enum E_PARTICLES_PRIMITIVE - { - EPP_POINT=0, - EPP_BILLBOARD, - EPP_POINTSPRITE - }; - E_PARTICLES_PRIMITIVE ParticlePrimitive; - - bool ParticlesAreGlobal; -}; - -} // end namespace scene -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CQ3LevelMesh.cpp b/irrlicht-1.6/source/Irrlicht/CQ3LevelMesh.cpp deleted file mode 100644 index 082da3502..000000000 --- a/irrlicht-1.6/source/Irrlicht/CQ3LevelMesh.cpp +++ /dev/null @@ -1,1969 +0,0 @@ -// Copyright (C) 2002-2009 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_BSP_LOADER_ - -#include "CQ3LevelMesh.h" -#include "ISceneManager.h" -#include "os.h" -#include "SMeshBufferLightMap.h" -#include "irrString.h" -#include "ILightSceneNode.h" -#include "IQ3Shader.h" -#include "IFileList.h" - -//#define TJUNCTION_SOLVER_ROUND -//#define TJUNCTION_SOLVER_0125 - -namespace irr -{ -namespace scene -{ - - using namespace quake3; - -//! constructor -CQ3LevelMesh::CQ3LevelMesh(io::IFileSystem* fs, scene::ISceneManager* smgr, - const Q3LevelLoadParameter &loadParam) - : LoadParam(loadParam), Textures(0), LightMaps(0), - Vertices(0), Faces(0), Planes(0), Nodes(0), Leafs(0), LeafFaces(0), - MeshVerts(0), Brushes(0), FileSystem(fs), SceneManager(smgr) -{ - #ifdef _DEBUG - IReferenceCounted::setDebugName("CQ3LevelMesh"); - #endif - - for ( s32 i = 0; i!= E_Q3_MESH_SIZE; ++i ) - { - Mesh[i] = 0; - } - - Driver = smgr ? smgr->getVideoDriver() : 0; - if (Driver) - Driver->grab(); - - if (FileSystem) - FileSystem->grab(); - - // load default shaders - InitShader(); -} - - -//! destructor -CQ3LevelMesh::~CQ3LevelMesh() -{ - cleanLoader (); - - if (Driver) - Driver->drop(); - - if (FileSystem) - FileSystem->drop(); - - for ( s32 i = 0; i!= E_Q3_MESH_SIZE; ++i ) - { - if ( Mesh[i] ) - { - Mesh[i]->drop(); - Mesh[i] = 0; - } - } - - ReleaseShader(); - ReleaseEntity(); -} - - -//! loads a level from a .bsp-File. Also tries to load all needed textures. Returns true if successful. -bool CQ3LevelMesh::loadFile(io::IReadFile* file) -{ - if (!file) - return false; - - LevelName = file->getFileName(); - - file->read(&header, sizeof(tBSPHeader)); - - #ifdef __BIG_ENDIAN__ - header.strID = os::Byteswap::byteswap(header.strID); - header.version = os::Byteswap::byteswap(header.version); - #endif - - if ( (header.strID != 0x50534249 || // IBSP - ( header.version != 0x2e // quake3 - && header.version != 0x2f // rtcw - ) - ) - && - ( header.strID != 0x50534252 || header.version != 1 ) // RBSP, starwars jedi, sof - ) - { - os::Printer::log("Could not load .bsp file, unknown header.", file->getFileName(), ELL_ERROR); - return false; - } - -#if 0 - if ( header.strID == 0x50534252 ) // RBSP Raven - { - LoadParam.swapHeader = 1; - } -#endif - - // now read lumps - file->read(&Lumps[0], sizeof(tBSPLump)*kMaxLumps); - - - s32 i; - if ( LoadParam.swapHeader ) - { - for ( i=0; i< kMaxLumps;++i) - { - Lumps[i].offset = os::Byteswap::byteswap(Lumps[i].offset); - Lumps[i].length = os::Byteswap::byteswap(Lumps[i].length); - } - } - - for ( i = 0; i!= E_Q3_MESH_SIZE; ++i ) - { - Mesh[i] = new SMesh(); - } - - ReleaseEntity(); - - // load everything - loadEntities(&Lumps[kEntities], file); // load the entities - loadTextures(&Lumps[kShaders], file); // Load the textures - loadLightmaps(&Lumps[kLightmaps], file); // Load the lightmaps - loadVerts(&Lumps[kVertices], file); // Load the vertices - loadFaces(&Lumps[kFaces], file); // Load the faces - loadPlanes(&Lumps[kPlanes], file); // Load the Planes of the BSP - loadNodes(&Lumps[kNodes], file); // load the Nodes of the BSP - loadLeafs(&Lumps[kLeafs], file); // load the Leafs of the BSP - loadLeafFaces(&Lumps[kLeafFaces], file); // load the Faces of the Leafs of the BSP - loadVisData(&Lumps[kVisData], file); // load the visibility data of the clusters - loadModels(&Lumps[kModels], file); // load the models - loadMeshVerts(&Lumps[kMeshVerts], file); // load the mesh vertices - loadBrushes(&Lumps[kBrushes], file); // load the brushes of the BSP - loadBrushSides(&Lumps[kBrushSides], file); // load the brushsides of the BSP - loadLeafBrushes(&Lumps[kLeafBrushes], file); // load the brushes of the leaf - loadFogs(&Lumps[kFogs], file ); // load the fogs - - - loadTextures(); - constructMesh(); - solveTJunction (); - - cleanMeshes(); - calcBoundingBoxes(); - cleanLoader (); - - return true; -} - -/*! -*/ -void CQ3LevelMesh::cleanLoader () -{ - delete [] Textures; Textures = 0; - delete [] LightMaps; LightMaps = 0; - delete [] Vertices; Vertices = 0; - delete [] Faces; Faces = 0; - delete [] Planes; Planes = 0; - delete [] Nodes; Nodes = 0; - delete [] Leafs; Leafs = 0; - delete [] LeafFaces; LeafFaces = 0; - delete [] MeshVerts; MeshVerts = 0; - delete [] Brushes; Brushes = 0; - - Lightmap.clear (); - Tex.clear (); -} - -//! returns the amount of frames in milliseconds. If the amount is 1, it is a static (=non animated) mesh. -u32 CQ3LevelMesh::getFrameCount() const -{ - return 1; -} - - -//! returns the animated mesh based on a detail level. 0 is the lowest, 255 the highest detail. Note, that some Meshes will ignore the detail level. -IMesh* CQ3LevelMesh::getMesh(s32 frameInMs, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop) -{ - return Mesh[frameInMs]; -} - - -void CQ3LevelMesh::loadTextures(tBSPLump* l, io::IReadFile* file) -{ - NumTextures = l->length / sizeof(tBSPTexture); - Textures = new tBSPTexture[NumTextures]; - - file->seek(l->offset); - file->read(Textures, l->length); - - if ( LoadParam.swapHeader ) - { - for (s32 i=0;i<NumTextures;++i) - { - Textures[i].flags = os::Byteswap::byteswap(Textures[i].flags); - Textures[i].contents = os::Byteswap::byteswap(Textures[i].contents); - //os::Printer::log("Loaded texture", Textures[i].strName, ELL_INFORMATION); - } - } -} - - -void CQ3LevelMesh::loadLightmaps(tBSPLump* l, io::IReadFile* file) -{ - NumLightMaps = l->length / sizeof(tBSPLightmap); - LightMaps = new tBSPLightmap[NumLightMaps]; - - file->seek(l->offset); - file->read(LightMaps, l->length); -} - -/*! -*/ -void CQ3LevelMesh::loadVerts(tBSPLump* l, io::IReadFile* file) -{ - NumVertices = l->length / sizeof(tBSPVertex); - Vertices = new tBSPVertex[NumVertices]; - - file->seek(l->offset); - file->read(Vertices, l->length); - - if ( LoadParam.swapHeader ) - for (s32 i=0;i<NumVertices;i++) - { - Vertices[i].vPosition[0] = os::Byteswap::byteswap(Vertices[i].vPosition[0]); - Vertices[i].vPosition[1] = os::Byteswap::byteswap(Vertices[i].vPosition[1]); - Vertices[i].vPosition[2] = os::Byteswap::byteswap(Vertices[i].vPosition[2]); - Vertices[i].vTextureCoord[0] = os::Byteswap::byteswap(Vertices[i].vTextureCoord[0]); - Vertices[i].vTextureCoord[1] = os::Byteswap::byteswap(Vertices[i].vTextureCoord[1]); - Vertices[i].vLightmapCoord[0] = os::Byteswap::byteswap(Vertices[i].vLightmapCoord[0]); - Vertices[i].vLightmapCoord[1] = os::Byteswap::byteswap(Vertices[i].vLightmapCoord[1]); - Vertices[i].vNormal[0] = os::Byteswap::byteswap(Vertices[i].vNormal[0]); - Vertices[i].vNormal[1] = os::Byteswap::byteswap(Vertices[i].vNormal[1]); - Vertices[i].vNormal[2] = os::Byteswap::byteswap(Vertices[i].vNormal[2]); - } -} - - -/*! -*/ -void CQ3LevelMesh::loadFaces(tBSPLump* l, io::IReadFile* file) -{ - NumFaces = l->length / sizeof(tBSPFace); - Faces = new tBSPFace[NumFaces]; - - file->seek(l->offset); - file->read(Faces, l->length); - - if ( LoadParam.swapHeader ) - { - for ( s32 i=0;i<NumFaces;i++) - { - Faces[i].textureID = os::Byteswap::byteswap(Faces[i].textureID); - Faces[i].fogNum = os::Byteswap::byteswap(Faces[i].fogNum); - Faces[i].type = os::Byteswap::byteswap(Faces[i].type); - Faces[i].vertexIndex = os::Byteswap::byteswap(Faces[i].vertexIndex); - Faces[i].numOfVerts = os::Byteswap::byteswap(Faces[i].numOfVerts); - Faces[i].meshVertIndex = os::Byteswap::byteswap(Faces[i].meshVertIndex); - Faces[i].numMeshVerts = os::Byteswap::byteswap(Faces[i].numMeshVerts); - Faces[i].lightmapID = os::Byteswap::byteswap(Faces[i].lightmapID); - Faces[i].lMapCorner[0] = os::Byteswap::byteswap(Faces[i].lMapCorner[0]); - Faces[i].lMapCorner[1] = os::Byteswap::byteswap(Faces[i].lMapCorner[1]); - Faces[i].lMapSize[0] = os::Byteswap::byteswap(Faces[i].lMapSize[0]); - Faces[i].lMapSize[1] = os::Byteswap::byteswap(Faces[i].lMapSize[1]); - Faces[i].lMapPos[0] = os::Byteswap::byteswap(Faces[i].lMapPos[0]); - Faces[i].lMapPos[1] = os::Byteswap::byteswap(Faces[i].lMapPos[1]); - Faces[i].lMapPos[2] = os::Byteswap::byteswap(Faces[i].lMapPos[2]); - Faces[i].lMapBitsets[0][0] = os::Byteswap::byteswap(Faces[i].lMapBitsets[0][0]); - Faces[i].lMapBitsets[0][1] = os::Byteswap::byteswap(Faces[i].lMapBitsets[0][1]); - Faces[i].lMapBitsets[0][2] = os::Byteswap::byteswap(Faces[i].lMapBitsets[0][2]); - Faces[i].lMapBitsets[1][0] = os::Byteswap::byteswap(Faces[i].lMapBitsets[1][0]); - Faces[i].lMapBitsets[1][1] = os::Byteswap::byteswap(Faces[i].lMapBitsets[1][1]); - Faces[i].lMapBitsets[1][2] = os::Byteswap::byteswap(Faces[i].lMapBitsets[1][2]); - Faces[i].vNormal[0] = os::Byteswap::byteswap(Faces[i].vNormal[0]); - Faces[i].vNormal[1] = os::Byteswap::byteswap(Faces[i].vNormal[1]); - Faces[i].vNormal[2] = os::Byteswap::byteswap(Faces[i].vNormal[2]); - Faces[i].size[0] = os::Byteswap::byteswap(Faces[i].size[0]); - Faces[i].size[1] = os::Byteswap::byteswap(Faces[i].size[1]); - } - } -} - - -/*! -*/ -void CQ3LevelMesh::loadPlanes(tBSPLump* l, io::IReadFile* file) -{ - // ignore -} - - -/*! -*/ -void CQ3LevelMesh::loadNodes(tBSPLump* l, io::IReadFile* file) -{ - // ignore -} - - -/*! -*/ -void CQ3LevelMesh::loadLeafs(tBSPLump* l, io::IReadFile* file) -{ - // ignore -} - - -/*! -*/ -void CQ3LevelMesh::loadLeafFaces(tBSPLump* l, io::IReadFile* file) -{ - // ignore -} - - -/*! -*/ -void CQ3LevelMesh::loadVisData(tBSPLump* l, io::IReadFile* file) -{ - // ignore -} - - -/*! -*/ -void CQ3LevelMesh::loadEntities(tBSPLump* l, io::IReadFile* file) -{ - core::array<u8> entity; - entity.set_used( l->length + 2 ); - entity[l->length + 1 ] = 0; - - file->seek(l->offset); - file->read( entity.pointer(), l->length); - - parser_parse( entity.pointer(), l->length, &CQ3LevelMesh::scriptcallback_entity ); -} - - -/*! - load fog brushes -*/ -void CQ3LevelMesh::loadFogs(tBSPLump* l, io::IReadFile* file) -{ - u32 files = l->length / sizeof(tBSPFog); - - file->seek( l->offset ); - tBSPFog fog; - const IShader *shader; - STexShader t; - for ( u32 i = 0; i!= files; ++i ) - { - file->read( &fog, sizeof( fog ) ); - - shader = getShader( fog.shader ); - t.Texture = 0; - t.ShaderID = shader ? shader->ID : -1; - - FogMap.push_back ( t ); - } -} - - -/*! - load models named in bsp -*/ -void CQ3LevelMesh::loadModels(tBSPLump* l, io::IReadFile* file) -{ - u32 files = l->length / sizeof(tBSPModel); - file->seek( l->offset ); - - tBSPModel def; - for ( u32 i = 0; i!= files; ++i ) - { - file->read( &def, sizeof( def ) ); - } - -} - -/*! -*/ -void CQ3LevelMesh::loadMeshVerts(tBSPLump* l, io::IReadFile* file) -{ - NumMeshVerts = l->length / sizeof(s32); - MeshVerts = new s32[NumMeshVerts]; - - file->seek(l->offset); - file->read(MeshVerts, l->length); - - if ( LoadParam.swapHeader ) - { - for (int i=0;i<NumMeshVerts;i++) - MeshVerts[i] = os::Byteswap::byteswap(MeshVerts[i]); - } -} - -/*! -*/ -void CQ3LevelMesh::loadBrushes(tBSPLump* l, io::IReadFile* file) -{ - // ignore -} - -/*! -*/ -void CQ3LevelMesh::loadBrushSides(tBSPLump* l, io::IReadFile* file) -{ - // ignore -} - -/*! -*/ -void CQ3LevelMesh::loadLeafBrushes(tBSPLump* l, io::IReadFile* file) -{ - // ignore -} - -/*! -*/ -inline bool isQ3WhiteSpace( const u8 symbol ) -{ - return symbol == ' ' || symbol == '\t' || symbol == '\r'; -} - -/*! -*/ -inline bool isQ3ValidName( const u8 symbol ) -{ - return (symbol >= 'a' && symbol <= 'z' ) || - (symbol >= 'A' && symbol <= 'Z' ) || - (symbol >= '0' && symbol <= '9' ) || - (symbol == '/' || symbol == '_' || symbol == '.' ); -} - -/*! -*/ -void CQ3LevelMesh::parser_nextToken() -{ - u8 symbol; - - Parser.token = ""; - Parser.tokenresult = Q3_TOKEN_UNRESOLVED; - - // skip white space - do - { - if ( Parser.index >= Parser.sourcesize ) - { - Parser.tokenresult = Q3_TOKEN_EOF; - return; - } - - symbol = Parser.source [ Parser.index ]; - Parser.index += 1; - } while ( isQ3WhiteSpace( symbol ) ); - - // first symbol, one symbol - switch ( symbol ) - { - case 0: - Parser.tokenresult = Q3_TOKEN_EOF; - return; - - case '/': - // comment or divide - if ( Parser.index >= Parser.sourcesize ) - { - Parser.tokenresult = Q3_TOKEN_EOF; - return; - } - symbol = Parser.source [ Parser.index ]; - Parser.index += 1; - if ( isQ3WhiteSpace( symbol ) ) - { - Parser.tokenresult = Q3_TOKEN_MATH_DIVIDE; - return; - } - else - if ( symbol == '*' ) - { - // C-style comment in quake? - } - else - if ( symbol == '/' ) - { - // skip to eol - do - { - if ( Parser.index >= Parser.sourcesize ) - { - Parser.tokenresult = Q3_TOKEN_EOF; - return; - } - symbol = Parser.source [ Parser.index ]; - Parser.index += 1; - } while ( symbol != '\n' ); - Parser.tokenresult = Q3_TOKEN_COMMENT; - return; - } - // take /[name] as valid token..?!?!?. mhmm, maybe - break; - - case '\n': - Parser.tokenresult = Q3_TOKEN_EOL; - return; - case '{': - Parser.tokenresult = Q3_TOKEN_START_LIST; - return; - case '}': - Parser.tokenresult = Q3_TOKEN_END_LIST; - return; - - case '"': - // string literal - do - { - if ( Parser.index >= Parser.sourcesize ) - { - Parser.tokenresult = Q3_TOKEN_EOF; - return; - } - symbol = Parser.source [ Parser.index ]; - Parser.index += 1; - if ( symbol != '"' ) - Parser.token.append( symbol ); - } while ( symbol != '"' ); - Parser.tokenresult = Q3_TOKEN_ENTITY; - return; - } - - // user identity - Parser.token.append( symbol ); - - // continue till whitespace - bool validName = true; - do - { - if ( Parser.index >= Parser.sourcesize ) - { - Parser.tokenresult = Q3_TOKEN_EOF; - return; - } - symbol = Parser.source [ Parser.index ]; - - validName = isQ3ValidName( symbol ); - if ( validName ) - { - Parser.token.append( symbol ); - Parser.index += 1; - } - } while ( validName ); - - Parser.tokenresult = Q3_TOKEN_TOKEN; - return; -} - - -/* - parse entity & shader - calls callback on content in {} -*/ -void CQ3LevelMesh::parser_parse( const void * data, const u32 size, CQ3LevelMesh::tParserCallback callback ) -{ - Parser.source = static_cast<const c8*>(data); - Parser.sourcesize = size; - Parser.index = 0; - - SVarGroupList *groupList; - - s32 active; - s32 last; - - SVariable entity ( "" ); - - groupList = new SVarGroupList(); - - groupList->VariableGroup.push_back( SVarGroup() ); - active = last = 0; - - do - { - parser_nextToken(); - - switch ( Parser.tokenresult ) - { - case Q3_TOKEN_START_LIST: - { - //stack = core::min_( stack + 1, 7 ); - - groupList->VariableGroup.push_back( SVarGroup() ); - last = active; - active = groupList->VariableGroup.size() - 1; - entity.clear(); - } break; - - // a unregisterd variable is finished - case Q3_TOKEN_EOL: - { - if ( entity.isValid() ) - { - groupList->VariableGroup[active].Variable.push_back( entity ); - entity.clear(); - } - } break; - - case Q3_TOKEN_TOKEN: - case Q3_TOKEN_ENTITY: - { - Parser.token.make_lower(); - - // store content based on line-delemiter - if ( 0 == entity.isValid() ) - { - entity.name = Parser.token; - entity.content = ""; - - } - else - { - if ( entity.content.size() ) - { - entity.content += " "; - } - entity.content += Parser.token; - } - } break; - - case Q3_TOKEN_END_LIST: - { - //stack = core::max_( stack - 1, 0 ); - - // close tag for first - if ( active == 1 ) - { - (this->*callback)( groupList, Q3_TOKEN_END_LIST ); - - // new group - groupList->drop(); - groupList = new SVarGroupList(); - groupList->VariableGroup.push_back( SVarGroup() ); - last = 0; - } - - active = last; - entity.clear(); - - } break; - - default: - break; - } - - } while ( Parser.tokenresult != Q3_TOKEN_EOF ); - - (this->*callback)( groupList, Q3_TOKEN_EOF ); - - groupList->drop(); -} - - -/* - this loader applies only textures for stage 1 & 2 -*/ -s32 CQ3LevelMesh::setShaderFogMaterial( video::SMaterial &material, const tBSPFace * face ) const -{ - material.MaterialType = video::EMT_SOLID; - material.Wireframe = false; - material.Lighting = false; - material.BackfaceCulling = false; - material.setTexture(0, 0); - material.setTexture(1, 0); - material.setTexture(2, 0); - material.setTexture(3, 0); - material.ZBuffer = video::ECFN_LESSEQUAL; - material.ZWriteEnable = false; - material.MaterialTypeParam = 0.f; - - s32 shaderState = -1; - - if ( (u32) face->fogNum < FogMap.size() ) - { - material.setTexture(0, FogMap [ face->fogNum ].Texture); - shaderState = FogMap [ face->fogNum ].ShaderID; - } - - return shaderState; - -} -/* - this loader applies only textures for stage 1 & 2 -*/ -s32 CQ3LevelMesh::setShaderMaterial( video::SMaterial &material, const tBSPFace * face ) const -{ - material.MaterialType = video::EMT_SOLID; - material.Wireframe = false; - material.Lighting = false; - material.BackfaceCulling = true; - material.setTexture(0, 0); - material.setTexture(1, 0); - material.setTexture(2, 0); - material.setTexture(3, 0); - material.ZBuffer = video::ECFN_LESSEQUAL; - material.ZWriteEnable = true; - material.MaterialTypeParam = 0.f; - - s32 shaderState = -1; - - if ( face->textureID >= 0 ) - { - material.setTexture(0, Tex [ face->textureID ].Texture); - shaderState = Tex [ face->textureID ].ShaderID; - } - - if ( face->lightmapID >= 0 ) - { - material.setTexture(1, Lightmap [ face->lightmapID ]); - material.MaterialType = LoadParam.defaultLightMapMaterial; - } - - // store shader ID - material.MaterialTypeParam2 = (f32) shaderState; - - const IShader *shader = getShader(shaderState); - if ( 0 == shader ) - return shaderState; - - return shaderState; - -#if 0 - const SVarGroup *group; - - - // generic - group = shader->getGroup( 1 ); - if ( group ) - { - material.BackfaceCulling = getCullingFunction( group->get( "cull" ) ); - - if ( group->isDefined( "surfaceparm", "nolightmap" ) ) - { - material.MaterialType = video::EMT_SOLID; - material.setTexture(1, 0); - } - - } - - // try to get the best of the 8 texture stages.. - - // texture 1, texture 2 - u32 startPos; - for ( s32 g = 2; g <= 3; ++g ) - { - group = shader->getGroup( g ); - if ( 0 == group ) - continue; - - startPos = 0; - - if ( group->isDefined( "depthwrite" ) ) - { - material.ZWriteEnable = true; - } - - SBlendFunc blendfunc ( LoadParam.defaultModulate ); - getBlendFunc( group->get( "blendfunc" ), blendfunc ); - getBlendFunc( group->get( "alphafunc" ), blendfunc ); - - if ( 0 == LoadParam.alpharef && - ( blendfunc.type == video::EMT_TRANSPARENT_ALPHA_CHANNEL || - blendfunc.type == video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF - ) - ) - { - blendfunc.type = video::EMT_TRANSPARENT_ALPHA_CHANNEL; - blendfunc.param0 = 0.f; - } - - material.MaterialType = blendfunc.type; - material.MaterialTypeParam = blendfunc.param0; - - // try if we can match better - shaderState |= (material.MaterialType == video::EMT_SOLID ) ? 0x00020000 : 0; - } - - //material.BackfaceCulling = false; - - if ( shader->VarGroup->VariableGroup.size() <= 4 ) - { - shaderState |= 0x00010000; - } - - material.MaterialTypeParam2 = (f32) shaderState; - return shaderState; -#endif -} - - -/*! -*/ -void CQ3LevelMesh::solveTJunction() -{ -} - -/*! - constructs a mesh from the quake 3 level file. -*/ -void CQ3LevelMesh::constructMesh() -{ - if ( LoadParam.verbose > 0 ) - { - LoadParam.startTime = os::Timer::getRealTime(); - - if ( LoadParam.verbose > 1 ) - { - snprintf( buf, sizeof ( buf ), - "quake3::constructMesh start to create %d faces, %d vertices,%d mesh vertices", - NumFaces, - NumVertices, - NumMeshVerts - ); - os::Printer::log(buf, ELL_INFORMATION); - } - - } - - s32 i, j, k,s; - - s32 *index; - - video::S3DVertex2TCoords temp[3]; - video::SMaterial material; - video::SMaterial material2; - - SToBuffer item [ E_Q3_MESH_SIZE ]; - u32 itemSize; - - for ( i=0; i < NumFaces; ++i) - { - const tBSPFace * face = Faces + i; - - s32 shaderState = setShaderMaterial( material, face ); - itemSize = 0; - - const IShader *shader = getShader(shaderState); - - if ( face->fogNum >= 0 ) - { - setShaderFogMaterial ( material2, face ); - item[itemSize].index = E_Q3_MESH_FOG; - item[itemSize].takeVertexColor = 1; - itemSize += 1; - } - - switch( face->type ) - { - case 1: // normal polygons - case 2: // patches - case 3: // meshes - { - if ( 0 == shader ) - { - if ( LoadParam.cleanUnResolvedMeshes || material.getTexture(0) ) - { - item[itemSize].takeVertexColor = 1; - item[itemSize].index = E_Q3_MESH_GEOMETRY; - itemSize += 1; - } - else - { - item[itemSize].takeVertexColor = 1; - item[itemSize].index = E_Q3_MESH_UNRESOLVED; - itemSize += 1; - } - } - else - { - item[itemSize].takeVertexColor = 1; - item[itemSize].index = E_Q3_MESH_ITEMS; - itemSize += 1; - } - - } break; - - case 4: // billboards - //item[itemSize].takeVertexColor = 1; - //item[itemSize].index = E_Q3_MESH_ITEMS; - //itemSize += 1; - break; - - } - - for ( u32 g = 0; g != itemSize; ++g ) - { - scene::SMeshBufferLightMap* buffer = 0; - - if ( item[g].index == E_Q3_MESH_GEOMETRY ) - { - if ( 0 == item[g].takeVertexColor ) - { - item[g].takeVertexColor = material.getTexture(0) == 0 || material.getTexture(1) == 0; - } - - if (Faces[i].lightmapID < -1 || Faces[i].lightmapID > NumLightMaps-1) - { - Faces[i].lightmapID = -1; - } - -#if 0 - // there are lightmapsids and textureid with -1 - const s32 tmp_index = ((Faces[i].lightmapID+1) * (NumTextures+1)) + (Faces[i].textureID+1); - buffer = (SMeshBufferLightMap*) Mesh[E_Q3_MESH_GEOMETRY]->getMeshBuffer(tmp_index); - buffer->setHardwareMappingHint ( EHM_STATIC ); - buffer->getMaterial() = material; -#endif - } - - // Construct a unique mesh for each shader or combine meshbuffers for same shader - if ( 0 == buffer ) - { - - if ( LoadParam.mergeShaderBuffer == 1 ) - { - // combine - buffer = (SMeshBufferLightMap*) Mesh[ item[g].index ]->getMeshBuffer( - item[g].index != E_Q3_MESH_FOG ? material : material2 ); - } - - // create a seperate mesh buffer - if ( 0 == buffer ) - { - buffer = new scene::SMeshBufferLightMap(); - Mesh[ item[g].index ]->addMeshBuffer( buffer ); - buffer->drop(); - buffer->getMaterial() = item[g].index != E_Q3_MESH_FOG ? material : material2; - if ( item[g].index == E_Q3_MESH_GEOMETRY ) - buffer->setHardwareMappingHint ( EHM_STATIC ); - } - } - - - switch(Faces[i].type) - { - case 4: // billboards - break; - case 2: // patches - createCurvedSurface_bezier( buffer, i, - LoadParam.patchTesselation, - item[g].takeVertexColor - ); - break; - - case 1: // normal polygons - case 3: // mesh vertices - index = MeshVerts + face->meshVertIndex; - k = buffer->getVertexCount(); - - // reallocate better if many small meshes are used - s = buffer->getIndexCount()+face->numMeshVerts; - if ( buffer->Indices.allocated_size () < (u32) s ) - { - if ( buffer->Indices.allocated_size () > 0 && - face->numMeshVerts < 20 && NumFaces > 1000 - ) - { - s = buffer->getIndexCount() + (NumFaces >> 3 * face->numMeshVerts ); - } - buffer->Indices.reallocate( s); - } - - for ( j = 0; j < face->numMeshVerts; ++j ) - { - buffer->Indices.push_back( k + index [j] ); - } - - s = k+face->numOfVerts; - if ( buffer->Vertices.allocated_size () < (u32) s ) - { - if ( buffer->Indices.allocated_size () > 0 && - face->numOfVerts < 20 && NumFaces > 1000 - ) - { - s = buffer->getIndexCount() + (NumFaces >> 3 * face->numOfVerts ); - } - buffer->Vertices.reallocate( s); - } - for ( j = 0; j != face->numOfVerts; ++j ) - { - copy( &temp[0], &Vertices[ j + face->vertexIndex ], item[g].takeVertexColor ); - buffer->Vertices.push_back( temp[0] ); - } - break; - - } // end switch - } - } - - if ( LoadParam.verbose > 0 ) - { - LoadParam.endTime = os::Timer::getRealTime(); - - snprintf( buf, sizeof ( buf ), - "quake3::constructMesh needed %04d ms to create %d faces, %d vertices,%d mesh vertices", - LoadParam.endTime - LoadParam.startTime, - NumFaces, - NumVertices, - NumMeshVerts - ); - os::Printer::log(buf, ELL_INFORMATION); - } - -} - - - - - -void CQ3LevelMesh::S3DVertex2TCoords_64::copy( video::S3DVertex2TCoords &dest ) const -{ -#if defined (TJUNCTION_SOLVER_ROUND) - dest.Pos.X = core::round_( (f32) Pos.X ); - dest.Pos.Y = core::round_( (f32) Pos.Y ); - dest.Pos.Z = core::round_( (f32) Pos.Z ); -#elif defined (TJUNCTION_SOLVER_0125) - dest.Pos.X = (f32) ( floor ( Pos.X * 8.f + 0.5 ) * 0.125 ); - dest.Pos.Y = (f32) ( floor ( Pos.Y * 8.f + 0.5 ) * 0.125 ); - dest.Pos.Z = (f32) ( floor ( Pos.Z * 8.f + 0.5 ) * 0.125 ); -#else - dest.Pos.X = (f32) Pos.X; - dest.Pos.Y = (f32) Pos.Y; - dest.Pos.Z = (f32) Pos.Z; -#endif - - dest.Normal.X = (f32) Normal.X; - dest.Normal.Y = (f32) Normal.Y; - dest.Normal.Z = (f32) Normal.Z; - dest.Normal.normalize(); - - dest.Color = Color.toSColor(); - - dest.TCoords.X = (f32) TCoords.X; - dest.TCoords.Y = (f32) TCoords.Y; - - dest.TCoords2.X = (f32) TCoords2.X; - dest.TCoords2.Y = (f32) TCoords2.Y; -} - - -void CQ3LevelMesh::copy( S3DVertex2TCoords_64 * dest, const tBSPVertex * source, s32 vertexcolor ) const -{ -#if defined (TJUNCTION_SOLVER_ROUND) - dest->Pos.X = core::round_( source->vPosition[0] ); - dest->Pos.Y = core::round_( source->vPosition[2] ); - dest->Pos.Z = core::round_( source->vPosition[1] ); -#elif defined (TJUNCTION_SOLVER_0125) - dest->Pos.X = (f32) ( floor ( source->vPosition[0] * 8.f + 0.5 ) * 0.125 ); - dest->Pos.Y = (f32) ( floor ( source->vPosition[2] * 8.f + 0.5 ) * 0.125 ); - dest->Pos.Z = (f32) ( floor ( source->vPosition[1] * 8.f + 0.5 ) * 0.125 ); -#else - dest->Pos.X = source->vPosition[0]; - dest->Pos.Y = source->vPosition[2]; - dest->Pos.Z = source->vPosition[1]; -#endif - - dest->Normal.X = source->vNormal[0]; - dest->Normal.Y = source->vNormal[2]; - dest->Normal.Z = source->vNormal[1]; - dest->Normal.normalize(); - - dest->TCoords.X = source->vTextureCoord[0]; - dest->TCoords.Y = source->vTextureCoord[1]; - dest->TCoords2.X = source->vLightmapCoord[0]; - dest->TCoords2.Y = source->vLightmapCoord[1]; - - if ( vertexcolor ) - { - //u32 a = core::s32_min( source->color[3] * LoadParam.defaultModulate, 255 ); - u32 a = source->color[3]; - u32 r = core::s32_min( source->color[0] * LoadParam.defaultModulate, 255 ); - u32 g = core::s32_min( source->color[1] * LoadParam.defaultModulate, 255 ); - u32 b = core::s32_min( source->color[2] * LoadParam.defaultModulate, 255 ); - - dest->Color.set(a * 1.f/255.f, r * 1.f/255.f, - g * 1.f/255.f, b * 1.f/255.f); - } - else - { - dest->Color.set( 1.f, 1.f, 1.f, 1.f ); - } -} - - -inline void CQ3LevelMesh::copy( video::S3DVertex2TCoords * dest, const tBSPVertex * source, s32 vertexcolor ) const -{ -#if defined (TJUNCTION_SOLVER_ROUND) - dest->Pos.X = core::round_( source->vPosition[0] ); - dest->Pos.Y = core::round_( source->vPosition[2] ); - dest->Pos.Z = core::round_( source->vPosition[1] ); -#elif defined (TJUNCTION_SOLVER_0125) - dest->Pos.X = (f32) ( floor ( source->vPosition[0] * 8.f + 0.5 ) * 0.125 ); - dest->Pos.Y = (f32) ( floor ( source->vPosition[2] * 8.f + 0.5 ) * 0.125 ); - dest->Pos.Z = (f32) ( floor ( source->vPosition[1] * 8.f + 0.5 ) * 0.125 ); -#else - dest->Pos.X = source->vPosition[0]; - dest->Pos.Y = source->vPosition[2]; - dest->Pos.Z = source->vPosition[1]; -#endif - - dest->Normal.X = source->vNormal[0]; - dest->Normal.Y = source->vNormal[2]; - dest->Normal.Z = source->vNormal[1]; - dest->Normal.normalize(); - - dest->TCoords.X = source->vTextureCoord[0]; - dest->TCoords.Y = source->vTextureCoord[1]; - dest->TCoords2.X = source->vLightmapCoord[0]; - dest->TCoords2.Y = source->vLightmapCoord[1]; - - if ( vertexcolor ) - { - //u32 a = core::s32_min( source->color[3] * LoadParam.defaultModulate, 255 ); - u32 a = source->color[3]; - u32 r = core::s32_min( source->color[0] * LoadParam.defaultModulate, 255 ); - u32 g = core::s32_min( source->color[1] * LoadParam.defaultModulate, 255 ); - u32 b = core::s32_min( source->color[2] * LoadParam.defaultModulate, 255 ); - - dest->Color.set(a << 24 | r << 16 | g << 8 | b); - } - else - { - dest->Color.set(0xFFFFFFFF); - } -} - - -void CQ3LevelMesh::SBezier::tesselate( s32 level ) -{ - //Calculate how many vertices across/down there are - s32 j, k; - - column[0].set_used( level + 1 ); - column[1].set_used( level + 1 ); - column[2].set_used( level + 1 ); - - const f64 w = 0.0 + (1.0 / (f64) level ); - - //Tesselate along the columns - for( j = 0; j <= level; ++j) - { - const f64 f = w * (f64) j; - - column[0][j] = control[0].getInterpolated_quadratic(control[3], control[6], f ); - column[1][j] = control[1].getInterpolated_quadratic(control[4], control[7], f ); - column[2][j] = control[2].getInterpolated_quadratic(control[5], control[8], f ); - } - - const u32 idx = Patch->Vertices.size(); - Patch->Vertices.reallocate(idx+level*level); - //Tesselate across the rows to get final vertices - video::S3DVertex2TCoords v; - S3DVertex2TCoords_64 f; - for( j = 0; j <= level; ++j) - { - for( k = 0; k <= level; ++k) - { - f = column[0][j].getInterpolated_quadratic(column[1][j], column[2][j], w * (f64) k); - f.copy( v ); - Patch->Vertices.push_back( v ); - } - } - - Patch->Indices.reallocate(Patch->Indices.size()+6*level*level); - // connect - for( j = 0; j < level; ++j) - { - for( k = 0; k < level; ++k) - { - const s32 inx = idx + ( k * ( level + 1 ) ) + j; - - Patch->Indices.push_back( inx + 0 ); - Patch->Indices.push_back( inx + (level + 1 ) + 0 ); - Patch->Indices.push_back( inx + (level + 1 ) + 1 ); - - Patch->Indices.push_back( inx + 0 ); - Patch->Indices.push_back( inx + (level + 1 ) + 1 ); - Patch->Indices.push_back( inx + 1 ); - - } - } -} - - -/*! - no subdivision -*/ -void CQ3LevelMesh::createCurvedSurface_nosubdivision(SMeshBufferLightMap* meshBuffer, - s32 faceIndex, - s32 patchTesselation, - s32 storevertexcolor) -{ - tBSPFace * face = &Faces[faceIndex]; - u32 j,k,m; - - // number of control points across & up - const u32 controlWidth = face->size[0]; - const u32 controlHeight = face->size[1]; - if ( 0 == controlWidth || 0 == controlHeight ) - return; - - video::S3DVertex2TCoords v; - - m = meshBuffer->Vertices.size(); - meshBuffer->Vertices.reallocate(m+controlHeight * controlWidth); - for ( j = 0; j!= controlHeight * controlWidth; ++j ) - { - copy( &v, &Vertices [ face->vertexIndex + j ], storevertexcolor ); - meshBuffer->Vertices.push_back( v ); - } - - meshBuffer->Indices.reallocate(meshBuffer->Indices.size()+6*(controlHeight-1) * (controlWidth-1)); - for ( j = 0; j!= controlHeight - 1; ++j ) - { - for ( k = 0; k!= controlWidth - 1; ++k ) - { - meshBuffer->Indices.push_back( m + k + 0 ); - meshBuffer->Indices.push_back( m + k + controlWidth + 0 ); - meshBuffer->Indices.push_back( m + k + controlWidth + 1 ); - - meshBuffer->Indices.push_back( m + k + 0 ); - meshBuffer->Indices.push_back( m + k + controlWidth + 1 ); - meshBuffer->Indices.push_back( m + k + 1 ); - } - m += controlWidth; - } -} - - -/*! -*/ -void CQ3LevelMesh::createCurvedSurface_bezier(SMeshBufferLightMap* meshBuffer, - s32 faceIndex, - s32 patchTesselation, - s32 storevertexcolor) -{ - - tBSPFace * face = &Faces[faceIndex]; - u32 j,k; - - // number of control points across & up - const u32 controlWidth = face->size[0]; - const u32 controlHeight = face->size[1]; - - if ( 0 == controlWidth || 0 == controlHeight ) - return; - - // number of biquadratic patches - const u32 biquadWidth = (controlWidth - 1)/2; - const u32 biquadHeight = (controlHeight -1)/2; - - if ( LoadParam.verbose > 1 ) - { - LoadParam.startTime = os::Timer::getRealTime(); - } - - // Create space for a temporary array of the patch's control points - core::array<S3DVertex2TCoords_64> controlPoint; - controlPoint.set_used( controlWidth * controlHeight ); - - for( j = 0; j < controlPoint.size(); ++j) - { - copy( &controlPoint[j], &Vertices [ face->vertexIndex + j ], storevertexcolor ); - } - - // create a temporary patch - Bezier.Patch = new scene::SMeshBufferLightMap(); - - //Loop through the biquadratic patches - for( j = 0; j < biquadHeight; ++j) - { - for( k = 0; k < biquadWidth; ++k) - { - // set up this patch - const s32 inx = j*controlWidth*2 + k*2; - - // setup bezier control points for this patch - Bezier.control[0] = controlPoint[ inx + 0]; - Bezier.control[1] = controlPoint[ inx + 1]; - Bezier.control[2] = controlPoint[ inx + 2]; - Bezier.control[3] = controlPoint[ inx + controlWidth + 0 ]; - Bezier.control[4] = controlPoint[ inx + controlWidth + 1 ]; - Bezier.control[5] = controlPoint[ inx + controlWidth + 2 ]; - Bezier.control[6] = controlPoint[ inx + controlWidth * 2 + 0]; - Bezier.control[7] = controlPoint[ inx + controlWidth * 2 + 1]; - Bezier.control[8] = controlPoint[ inx + controlWidth * 2 + 2]; - - Bezier.tesselate( patchTesselation ); - } - } - - // stitch together with existing geometry - // TODO: only border needs to be checked - const u32 bsize = Bezier.Patch->getVertexCount(); - const u32 msize = meshBuffer->getVertexCount(); -/* - for ( j = 0; j!= bsize; ++j ) - { - const core::vector3df &v = Bezier.Patch->Vertices[j].Pos; - - for ( k = 0; k!= msize; ++k ) - { - const core::vector3df &m = meshBuffer->Vertices[k].Pos; - - if ( !v.equals( m, tolerance ) ) - continue; - - meshBuffer->Vertices[k].Pos = v; - //Bezier.Patch->Vertices[j].Pos = m; - } - } -*/ - - // add Patch to meshbuffer - meshBuffer->Vertices.reallocate(msize+bsize); - for ( j = 0; j!= bsize; ++j ) - { - meshBuffer->Vertices.push_back( Bezier.Patch->Vertices[j] ); - } - - // add indices to meshbuffer - meshBuffer->Indices.reallocate(meshBuffer->getIndexCount()+Bezier.Patch->getIndexCount()); - for ( j = 0; j!= Bezier.Patch->getIndexCount(); ++j ) - { - meshBuffer->Indices.push_back( msize + Bezier.Patch->Indices[j] ); - } - - delete Bezier.Patch; - - if ( LoadParam.verbose > 1 ) - { - LoadParam.endTime = os::Timer::getRealTime(); - - snprintf( buf, sizeof ( buf ), - "quake3::createCurvedSurface_bezier needed %04d ms to create bezier patch.(%dx%d)", - LoadParam.endTime - LoadParam.startTime, - biquadWidth, - biquadHeight - ); - os::Printer::log(buf, ELL_INFORMATION); - } - -} - - - -/*! - Loads entities from file -*/ -void CQ3LevelMesh::getConfiguration( io::IReadFile* file ) -{ - tBSPLump l; - l.offset = file->getPos(); - l.length = file->getSize (); - - core::array<u8> entity; - entity.set_used( l.length + 2 ); - entity[l.length + 1 ] = 0; - - file->seek(l.offset); - file->read( entity.pointer(), l.length); - - parser_parse( entity.pointer(), l.length, &CQ3LevelMesh::scriptcallback_config ); - - if ( Entity.size () ) - Entity.getLast().name = file->getFileName(); -} - - -//! get's an interface to the entities -tQ3EntityList & CQ3LevelMesh::getEntityList() -{ -// Entity.sort(); - return Entity; -} - - -/*! -*/ -const IShader * CQ3LevelMesh::getShader(u32 index) const -{ - index &= 0xFFFF; - - if ( index < Shader.size() ) - { - return &Shader[index]; - } - - return 0; -} - - -/*! - loads the shader definition -*/ -const IShader* CQ3LevelMesh::getShader( const c8 * filename, bool fileNameIsValid ) -{ - core::stringc searchName ( filename ); - - IShader search; - search.name = searchName; - search.name.replace( '\\', '/' ); - search.name.make_lower(); - - - core::stringc message; - s32 index; - - //! is Shader already in cache? - index = Shader.linear_search( search ); - if ( index >= 0 ) - { - if ( LoadParam.verbose > 1 ) - { - message = searchName + " found " + Shader[index].name; - os::Printer::log("quake3:getShader", message.c_str(), ELL_INFORMATION); - } - - return &Shader[index]; - } - - io::path loadFile; - - if ( !fileNameIsValid ) - { - // extract the shader name from the last path component in filename - // "scripts/[name].shader" - core::stringc cut( search.name ); - - s32 end = cut.findLast( '/' ); - s32 start = cut.findLast( '/', end - 1 ); - - loadFile = LoadParam.scriptDir; - loadFile.append( cut.subString( start, end - start ) ); - loadFile.append( ".shader" ); - } - else - { - loadFile = search.name; - } - - // already loaded the file ? - index = ShaderFile.binary_search( loadFile ); - if ( index >= 0 ) - return 0; - - // add file to loaded files - ShaderFile.push_back( loadFile ); - - if ( !FileSystem->existFile( loadFile.c_str() ) ) - { - if ( LoadParam.verbose > 1 ) - { - message = loadFile + " for " + searchName + " failed "; - os::Printer::log("quake3:getShader", message.c_str(), ELL_INFORMATION); - } - return 0; - } - - if ( LoadParam.verbose ) - { - message = loadFile + " for " + searchName; - os::Printer::log("quake3:getShader Load shader", message.c_str(), ELL_INFORMATION); - } - - - io::IReadFile *file = FileSystem->createAndOpenFile( loadFile.c_str() ); - if ( file ) - { - getShader ( file ); - file->drop (); - } - - - // search again - index = Shader.linear_search( search ); - return index >= 0 ? &Shader[index] : 0; -} - -/*! - loads the shader definition -*/ -void CQ3LevelMesh::getShader( io::IReadFile* file ) -{ - if ( 0 == file ) - return; - - // load script - core::array<u8> script; - const long len = file->getSize(); - - script.set_used( len + 2 ); - - file->seek( 0 ); - file->read( script.pointer(), len ); - script[ len + 1 ] = 0; - - // start a parser instance - parser_parse( script.pointer(), len, &CQ3LevelMesh::scriptcallback_shader ); -} - - -//! adding default shaders -void CQ3LevelMesh::InitShader() -{ - ReleaseShader(); - - IShader element; - - SVarGroup group; - SVariable variable ( "noshader" ); - - group.Variable.push_back( variable ); - - element.VarGroup = new SVarGroupList(); - element.VarGroup->VariableGroup.push_back( group ); - element.VarGroup->VariableGroup.push_back( SVarGroup() ); - element.name = element.VarGroup->VariableGroup[0].Variable[0].name; - element.ID = Shader.size(); - Shader.push_back( element ); - - if ( LoadParam.loadAllShaders ) - { - io::EFileSystemType current = FileSystem->setFileListSystem ( io::FILESYSTEM_VIRTUAL ); - io::path save = FileSystem->getWorkingDirectory(); - - io::path newDir; - newDir = "/"; - newDir += LoadParam.scriptDir; - newDir += "/"; - FileSystem->changeWorkingDirectoryTo ( newDir.c_str() ); - - core::stringc s; - io::IFileList *fileList = FileSystem->createFileList (); - for (u32 i=0; i< fileList->getFileCount(); ++i) - { - s = fileList->getFullFileName(i); - if ( s.find ( ".shader" ) >= 0 ) - { - if ( 0 == LoadParam.loadSkyShader && s.find ( "sky.shader" ) >= 0 ) - { - } - else - { - getShader ( s.c_str () ); - } - } - } - fileList->drop (); - - FileSystem->changeWorkingDirectoryTo ( save ); - FileSystem->setFileListSystem ( current ); - } -} - - -//! script callback for shaders -//! i'm having troubles with the reference counting, during callback.. resorting.. -void CQ3LevelMesh::ReleaseShader() -{ - for ( u32 i = 0; i!= Shader.size(); ++i ) - { - Shader[i].VarGroup->drop(); - } - Shader.clear(); - ShaderFile.clear(); -} - - -/*! -*/ -void CQ3LevelMesh::ReleaseEntity() -{ - for ( u32 i = 0; i!= Entity.size(); ++i ) - { - Entity[i].VarGroup->drop(); - } - Entity.clear(); -} - - -// config in simple (quake3) and advanced style -void CQ3LevelMesh::scriptcallback_config( SVarGroupList *& grouplist, eToken token ) -{ - IShader element; - - if ( token == Q3_TOKEN_END_LIST ) - { - if ( 0 == grouplist->VariableGroup[0].Variable.size() ) - return; - - element.name = grouplist->VariableGroup[0].Variable[0].name; - } - else - { - if ( grouplist->VariableGroup.size() != 2 ) - return; - - element.name = "configuration"; - } - - grouplist->grab(); - element.VarGroup = grouplist; - element.ID = Entity.size(); - Entity.push_back( element ); -} - - -// entity only has only one valid level.. and no assoziative name.. -void CQ3LevelMesh::scriptcallback_entity( SVarGroupList *& grouplist, eToken token ) -{ - if ( token != Q3_TOKEN_END_LIST || grouplist->VariableGroup.size() != 2 ) - return; - - grouplist->grab(); - - IEntity element; - element.VarGroup = grouplist; - element.ID = Entity.size(); - element.name = grouplist->VariableGroup[1].get( "classname" ); - - - Entity.push_back( element ); -} - - -//!. script callback for shaders -void CQ3LevelMesh::scriptcallback_shader( SVarGroupList *& grouplist,eToken token ) -{ - if ( token != Q3_TOKEN_END_LIST || grouplist->VariableGroup[0].Variable.size()==0) - return; - - - IShader element; - - grouplist->grab(); - element.VarGroup = grouplist; - element.name = element.VarGroup->VariableGroup[0].Variable[0].name; - element.ID = Shader.size(); -/* - core::stringc s; - dumpShader ( s, &element ); - printf ( s.c_str () ); -*/ - Shader.push_back( element ); -} - - -/*! - delete all buffers without geometry in it. -*/ -void CQ3LevelMesh::cleanMeshes() -{ - if ( 0 == LoadParam.cleanUnResolvedMeshes ) - return; - - // delete all buffers without geometry in it. - u32 run = 0; - u32 remove = 0; - - irr::scene::SMesh *m; - IMeshBuffer *b; - for ( u32 g = 0; g < E_Q3_MESH_SIZE; ++g ) - { - bool texture0important = ( g == 0 ); - - run = 0; - remove = 0; - m = Mesh[g]; - if ( LoadParam.verbose > 0 ) - { - LoadParam.startTime = os::Timer::getRealTime(); - if ( LoadParam.verbose > 1 ) - { - snprintf( buf, sizeof ( buf ), - "quake3::cleanMeshes%d start for %d meshes", - g, - m->MeshBuffers.size() - ); - os::Printer::log(buf, ELL_INFORMATION); - } - } - - u32 i = 0; - s32 blockstart = -1; - s32 blockcount; - - while( i < m->MeshBuffers.size()) - { - run += 1; - - b = m->MeshBuffers[i]; - - if ( b->getVertexCount() == 0 || b->getIndexCount() == 0 || - ( texture0important && b->getMaterial().getTexture(0) == 0 ) - ) - { - if ( blockstart < 0 ) - { - blockstart = i; - blockcount = 0; - } - blockcount += 1; - i += 1; - - // delete Meshbuffer - i -= 1; - remove += 1; - b->drop(); - m->MeshBuffers.erase(i); - } - else - { - // clean blockwise - if ( blockstart >= 0 ) - { - if ( LoadParam.verbose > 1 ) - { - snprintf( buf, sizeof ( buf ), - "quake3::cleanMeshes%d cleaning mesh %d %d size", - g, - blockstart, - blockcount - ); - os::Printer::log(buf, ELL_INFORMATION); - } - blockstart = -1; - } - i += 1; - } - } - - if ( LoadParam.verbose > 0 ) - { - LoadParam.endTime = os::Timer::getRealTime(); - snprintf( buf, sizeof ( buf ), - "quake3::cleanMeshes%d needed %04d ms to clean %d of %d meshes", - g, - LoadParam.endTime - LoadParam.startTime, - remove, - run - ); - os::Printer::log(buf, ELL_INFORMATION); - } - - } - -} - - -// recalculate bounding boxes -void CQ3LevelMesh::calcBoundingBoxes() -{ - if ( LoadParam.verbose > 0 ) - { - LoadParam.startTime = os::Timer::getRealTime(); - - if ( LoadParam.verbose > 1 ) - { - snprintf( buf, sizeof ( buf ), - "quake3::calcBoundingBoxes start create %d textures and %d lightmaps", - NumTextures, - NumLightMaps - ); - os::Printer::log(buf, ELL_INFORMATION); - } - - } - - // create bounding box - for ( u32 g = 0; g != E_Q3_MESH_SIZE; ++g ) - { - for ( u32 j=0; j < Mesh[g]->MeshBuffers.size(); ++j) - { - ((SMeshBufferLightMap*)Mesh[g]->MeshBuffers[j])->recalculateBoundingBox(); - } - - Mesh[g]->recalculateBoundingBox(); - } - - if ( LoadParam.verbose > 0 ) - { - LoadParam.endTime = os::Timer::getRealTime(); - - snprintf( buf, sizeof ( buf ), - "quake3::calcBoundingBoxes needed %04d ms to create %d textures and %d lightmaps", - LoadParam.endTime - LoadParam.startTime, - NumTextures, - NumLightMaps - ); - os::Printer::log( buf, ELL_INFORMATION); - } - -} - - -//! loads the textures -void CQ3LevelMesh::loadTextures() -{ - if (!Driver) - return; - - if ( LoadParam.verbose > 0 ) - { - LoadParam.startTime = os::Timer::getRealTime(); - - if ( LoadParam.verbose > 1 ) - { - snprintf( buf, sizeof ( buf ), - "quake3::loadTextures start create %d textures and %d lightmaps", - NumTextures, - NumLightMaps - ); - os::Printer::log( buf, ELL_INFORMATION); - } - - } - - c8 lightmapname[255]; - s32 t; - - // load lightmaps. - Lightmap.set_used(NumLightMaps+1); - -/* - bool oldMipMapState = Driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS); - Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false); -*/ - core::dimension2d<u32> lmapsize(128,128); - - video::IImage* lmapImg; - for ( t = 0; t < NumLightMaps ; ++t) - { - sprintf(lightmapname, "%s.lightmap.%d", LevelName.c_str(), t); - - // lightmap is a CTexture::R8G8B8 format - lmapImg = Driver->createImageFromData( - video::ECF_R8G8B8, - lmapsize, - LightMaps[t].imageBits, false, true ); - - Lightmap[t] = Driver->addTexture( lightmapname, lmapImg ); - lmapImg->drop(); - - } - -// Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, oldMipMapState); - - // load textures - Tex.set_used( NumTextures+1 ); - - const IShader * shader; - - core::stringc list; - core::stringc check; - tTexArray textureArray; - - // pre-load shaders - for ( t=0; t< NumTextures; ++t) - { - shader = getShader(Textures[t].strName, false); - } - - for ( t=0; t< NumTextures; ++t) - { - Tex[t].ShaderID = -1; - Tex[t].Texture = 0; - - list = ""; - - // get a shader ( if one exists ) - shader = getShader( Textures[t].strName, false); - if ( shader ) - { - Tex[t].ShaderID = shader->ID; - - // if texture name == stage1 Texture map - const SVarGroup * group; - - group = shader->getGroup( 2 ); - if ( group ) - { - if ( core::cutFilenameExtension( check, group->get( "map" ) ) == Textures[t].strName ) - { - list += check; - } - else - if ( check == "$lightmap" ) - { - // we check if lightmap is in stage 1 and texture in stage 2 - group = shader->getGroup( 3 ); - if ( group ) - list += group->get( "map" ); - } - } - } - else - { - // no shader, take it - list += Textures[t].strName; - } - - u32 pos = 0; - getTextures( textureArray, list, pos, FileSystem, Driver ); - - Tex[t].Texture = textureArray[0]; - } - - if ( LoadParam.verbose > 0 ) - { - LoadParam.endTime = os::Timer::getRealTime(); - - snprintf( buf, sizeof ( buf ), - "quake3::loadTextures needed %04d ms to create %d textures and %d lightmaps", - LoadParam.endTime - LoadParam.startTime, - NumTextures, - NumLightMaps - ); - os::Printer::log( buf, ELL_INFORMATION); - } - -} - - -//! Returns an axis aligned bounding box of the mesh. -//! \return A bounding box of this mesh is returned. -const core::aabbox3d<f32>& CQ3LevelMesh::getBoundingBox() const -{ - return Mesh[0]->getBoundingBox(); -} - -void CQ3LevelMesh::setBoundingBox( const core::aabbox3df& box) -{ - Mesh[0]->setBoundingBox(box); //? -} - - -//! Returns the type of the animated mesh. -E_ANIMATED_MESH_TYPE CQ3LevelMesh::getMeshType() const -{ - return scene::EAMT_BSP; -} - -} // end namespace scene -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BSP_LOADER_ diff --git a/irrlicht-1.6/source/Irrlicht/CQ3LevelMesh.h b/irrlicht-1.6/source/Irrlicht/CQ3LevelMesh.h deleted file mode 100644 index 9d58319e0..000000000 --- a/irrlicht-1.6/source/Irrlicht/CQ3LevelMesh.h +++ /dev/null @@ -1,464 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_Q3_LEVEL_MESH_H_INCLUDED__ -#define __C_Q3_LEVEL_MESH_H_INCLUDED__ - -#include "IQ3LevelMesh.h" -#include "IReadFile.h" -#include "IFileSystem.h" -#include "SMesh.h" -#include "SMeshBufferLightMap.h" -#include "IVideoDriver.h" -#include "irrString.h" -#include "ISceneManager.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - class CQ3LevelMesh : public IQ3LevelMesh - { - public: - - //! constructor - CQ3LevelMesh(io::IFileSystem* fs, scene::ISceneManager* smgr, - const quake3::Q3LevelLoadParameter &loadParam); - - //! destructor - virtual ~CQ3LevelMesh(); - - //! loads a level from a .bsp-File. Also tries to load all - //! needed textures. Returns true if successful. - bool loadFile(io::IReadFile* file); - - //! returns the amount of frames in milliseconds. If the amount - //! is 1, it is a static (=non animated) mesh. - virtual u32 getFrameCount() const; - - //! returns the animated mesh based on a detail level. 0 is the - //! lowest, 255 the highest detail. Note, that some Meshes will - //! ignore the detail level. - virtual IMesh* getMesh(s32 frameInMs, s32 detailLevel=255, - s32 startFrameLoop=-1, s32 endFrameLoop=-1); - - //! Returns an axis aligned bounding box of the mesh. - //! \return A bounding box of this mesh is returned. - virtual const core::aabbox3d<f32>& getBoundingBox() const; - - virtual void setBoundingBox( const core::aabbox3df& box); - - - //! Returns the type of the animated mesh. - virtual E_ANIMATED_MESH_TYPE getMeshType() const; - - //! loads the shader definition - virtual void getShader( io::IReadFile* file ); - - //! loads the shader definition - virtual const quake3::IShader * getShader( const c8 * filename, bool fileNameIsValid=true ); - - //! returns a already loaded Shader - virtual const quake3::IShader * getShader( u32 index ) const; - - - //! loads a configuration file - virtual void getConfiguration( io::IReadFile* file ); - //! get's an interface to the entities - virtual quake3::tQ3EntityList & getEntityList(); - - - //Link to held meshes? ... - - - //! returns amount of mesh buffers. - virtual u32 getMeshBufferCount() const - { - return 0; - } - - //! returns pointer to a mesh buffer - virtual IMeshBuffer* getMeshBuffer(u32 nr) const - { - return 0; - } - - //! Returns pointer to a mesh buffer which fits a material - /** \param material: material to search for - \return Pointer to the mesh buffer or 0 if there is no such mesh buffer. */ - virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const - { - return 0; - } - - virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue) - { - return; - } - - //! set the hardware mapping hint, for driver - virtual void setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX) - { - return; - } - - //! flags the meshbuffer as changed, reloads hardware buffers - virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX) - { - return; - } - - private: - - - void constructMesh(); - void solveTJunction(); - void loadTextures(); - - struct STexShader - { - video::ITexture* Texture; - s32 ShaderID; - }; - - core::array< STexShader > Tex; - core::array<video::ITexture*> Lightmap; - - enum eLumps - { - kEntities = 0, // Stores player/object positions, etc... - kShaders = 1, // Stores texture information - kPlanes = 2, // Stores the splitting planes - kNodes = 3, // Stores the BSP nodes - kLeafs = 4, // Stores the leafs of the nodes - kLeafFaces = 5, // Stores the leaf's indices into the faces - kLeafBrushes = 6, // Stores the leaf's indices into the brushes - kModels = 7, // Stores the info of world models - kBrushes = 8, // Stores the brushes info (for collision) - kBrushSides = 9, // Stores the brush surfaces info - kVertices = 10, // Stores the level vertices - kMeshVerts = 11, // Stores the model vertices offsets - kFogs = 12, // Stores the shader files (blending, anims..) - kFaces = 13, // Stores the faces for the level - kLightmaps = 14, // Stores the lightmaps for the level - kLightGrid = 15, // Stores extra world lighting information - kVisData = 16, // Stores PVS and cluster info (visibility) - kLightArray = 17, // RBSP - kMaxLumps // A constant to store the number of lumps - }; - - enum eBspSurfaceType - { - BSP_MST_BAD, - BSP_MST_PLANAR, - BSP_MST_PATCH, - BSP_MST_TRIANGLE_SOUP, - BSP_MST_FLARE, - BSP_MST_FOLIAGE - - }; - - struct tBSPHeader - { - s32 strID; // This should always be 'IBSP' - s32 version; // This should be 0x2e for Quake 3 files - }; - tBSPHeader header; - - struct tBSPLump - { - s32 offset; - s32 length; - }; - - - struct tBSPVertex - { - f32 vPosition[3]; // (x, y, z) position. - f32 vTextureCoord[2]; // (u, v) texture coordinate - f32 vLightmapCoord[2]; // (u, v) lightmap coordinate - f32 vNormal[3]; // (x, y, z) normal vector - u8 color[4]; // RGBA color for the vertex - }; - - struct tBSPFace - { - s32 textureID; // The index into the texture array - s32 fogNum; // The index for the effects (or -1 = n/a) - s32 type; // 1=polygon, 2=patch, 3=mesh, 4=billboard - s32 vertexIndex; // The index into this face's first vertex - s32 numOfVerts; // The number of vertices for this face - s32 meshVertIndex; // The index into the first meshvertex - s32 numMeshVerts; // The number of mesh vertices - s32 lightmapID; // The texture index for the lightmap - s32 lMapCorner[2]; // The face's lightmap corner in the image - s32 lMapSize[2]; // The size of the lightmap section - f32 lMapPos[3]; // The 3D origin of lightmap. - f32 lMapBitsets[2][3]; // The 3D space for s and t unit vectors. - f32 vNormal[3]; // The face normal. - s32 size[2]; // The bezier patch dimensions. - }; - - struct tBSPTexture - { - c8 strName[64]; // The name of the texture w/o the extension - u32 flags; // The surface flags (unknown) - u32 contents; // The content flags (unknown) - }; - - struct tBSPLightmap - { - u8 imageBits[128][128][3]; // The RGB data in a 128x128 image - }; - - struct tBSPNode - { - s32 plane; // The index into the planes array - s32 front; // The child index for the front node - s32 back; // The child index for the back node - s32 mins[3]; // The bounding box min position. - s32 maxs[3]; // The bounding box max position. - }; - - struct tBSPLeaf - { - s32 cluster; // The visibility cluster - s32 area; // The area portal - s32 mins[3]; // The bounding box min position - s32 maxs[3]; // The bounding box max position - s32 leafface; // The first index into the face array - s32 numOfLeafFaces; // The number of faces for this leaf - s32 leafBrush; // The first index for into the brushes - s32 numOfLeafBrushes; // The number of brushes for this leaf - }; - - struct tBSPPlane - { - f32 vNormal[3]; // Plane normal. - f32 d; // The plane distance from origin - }; - - struct tBSPVisData - { - s32 numOfClusters; // The number of clusters - s32 bytesPerCluster; // Bytes (8 bits) in the cluster's bitset - c8 *pBitsets; // Array of bytes holding the cluster vis. - }; - - struct tBSPBrush - { - s32 brushSide; // The starting brush side for the brush - s32 numOfBrushSides; // Number of brush sides for the brush - s32 textureID; // The texture index for the brush - }; - - struct tBSPBrushSide - { - s32 plane; // The plane index - s32 textureID; // The texture index - }; - - struct tBSPModel - { - f32 min[3]; // The min position for the bounding box - f32 max[3]; // The max position for the bounding box. - s32 faceIndex; // The first face index in the model - s32 numOfFaces; // The number of faces in the model - s32 brushIndex; // The first brush index in the model - s32 numOfBrushes; // The number brushes for the model - }; - - struct tBSPFog - { - c8 shader[64]; // The name of the shader file - s32 brushIndex; // The brush index for this shader - s32 visibleSide; // the brush side that ray tests need to clip against (-1 == none - }; - core::array < STexShader > FogMap; - - struct tBSPLights - { - u8 ambient[3]; // This is the ambient color in RGB - u8 directional[3]; // This is the directional color in RGB - u8 direction[2]; // The direction of the light: [phi,theta] - }; - - void loadTextures (tBSPLump* l, io::IReadFile* file); // Load the textures - void loadLightmaps (tBSPLump* l, io::IReadFile* file); // Load the lightmaps - void loadVerts (tBSPLump* l, io::IReadFile* file); // Load the vertices - void loadFaces (tBSPLump* l, io::IReadFile* file); // Load the faces - void loadPlanes (tBSPLump* l, io::IReadFile* file); // Load the Planes of the BSP - void loadNodes (tBSPLump* l, io::IReadFile* file); // load the Nodes of the BSP - void loadLeafs (tBSPLump* l, io::IReadFile* file); // load the Leafs of the BSP - void loadLeafFaces (tBSPLump* l, io::IReadFile* file); // load the Faces of the Leafs of the BSP - void loadVisData (tBSPLump* l, io::IReadFile* file); // load the visibility data of the clusters - void loadEntities (tBSPLump* l, io::IReadFile* file); // load the entities - void loadModels (tBSPLump* l, io::IReadFile* file); // load the models - void loadMeshVerts (tBSPLump* l, io::IReadFile* file); // load the mesh vertices - void loadBrushes (tBSPLump* l, io::IReadFile* file); // load the brushes of the BSP - void loadBrushSides (tBSPLump* l, io::IReadFile* file); // load the brushsides of the BSP - void loadLeafBrushes(tBSPLump* l, io::IReadFile* file); // load the brushes of the leaf - void loadFogs (tBSPLump* l, io::IReadFile* file); // load the shaders - - //bi-quadratic bezier patches - void createCurvedSurface_bezier(SMeshBufferLightMap* meshBuffer, - s32 faceIndex, s32 patchTesselation, s32 storevertexcolor); - - void createCurvedSurface_nosubdivision(SMeshBufferLightMap* meshBuffer, - s32 faceIndex, s32 patchTesselation, s32 storevertexcolor); - - struct S3DVertex2TCoords_64 - { - core::vector3d<f64> Pos; - core::vector3d<f64> Normal; - video::SColorf Color; - core::vector2d<f64> TCoords; - core::vector2d<f64> TCoords2; - - void copy( video::S3DVertex2TCoords &dest ) const; - - S3DVertex2TCoords_64() {} - S3DVertex2TCoords_64(const core::vector3d<f64>& pos, const core::vector3d<f64>& normal, const video::SColorf& color, - const core::vector2d<f64>& tcoords, const core::vector2d<f64>& tcoords2) - : Pos(pos), Normal(normal), Color(color), TCoords(tcoords), TCoords2(tcoords2) {} - - S3DVertex2TCoords_64 getInterpolated_quadratic(const S3DVertex2TCoords_64& v2, - const S3DVertex2TCoords_64& v3, const f64 d) const - { - return S3DVertex2TCoords_64 ( - Pos.getInterpolated_quadratic ( v2.Pos, v3.Pos, d ), - Normal.getInterpolated_quadratic ( v2.Normal, v3.Normal, d ), - Color.getInterpolated_quadratic ( v2.Color, v3.Color, (f32) d ), - TCoords.getInterpolated_quadratic ( v2.TCoords, v3.TCoords, d ), - TCoords2.getInterpolated_quadratic ( v2.TCoords2, v3.TCoords2, d )); - } - }; - - inline void copy( video::S3DVertex2TCoords * dest, const tBSPVertex * source, - s32 vertexcolor ) const; - void copy( S3DVertex2TCoords_64 * dest, const tBSPVertex * source, s32 vertexcolor ) const; - - - struct SBezier - { - SMeshBufferLightMap *Patch; - S3DVertex2TCoords_64 control[9]; - - void tesselate(s32 level); - - private: - s32 Level; - - core::array<S3DVertex2TCoords_64> column[3]; - - }; - SBezier Bezier; - - quake3::Q3LevelLoadParameter LoadParam; - - tBSPLump Lumps[kMaxLumps]; - - tBSPTexture* Textures; - s32 NumTextures; - - tBSPLightmap* LightMaps; - s32 NumLightMaps; - - tBSPVertex* Vertices; - s32 NumVertices; - - tBSPFace* Faces; - s32 NumFaces; - - tBSPPlane* Planes; - s32 NumPlanes; - - tBSPNode* Nodes; - s32 NumNodes; - - tBSPLeaf* Leafs; - s32 NumLeafs; - - s32 *LeafFaces; - s32 NumLeafFaces; - - s32 *MeshVerts; // The vertex offsets for a mesh - s32 NumMeshVerts; - - tBSPBrush* Brushes; - s32 NumBrushes; - - scene::SMesh* Mesh[quake3::E_Q3_MESH_SIZE]; - video::IVideoDriver* Driver; - core::stringc LevelName; - io::IFileSystem* FileSystem; // needs because there are no file extenstions stored in .bsp files. - - // Additional content - scene::ISceneManager* SceneManager; - enum eToken - { - Q3_TOKEN_UNRESOLVED = 0, - Q3_TOKEN_EOF = 1, - Q3_TOKEN_START_LIST, - Q3_TOKEN_END_LIST, - Q3_TOKEN_ENTITY, - Q3_TOKEN_TOKEN, - Q3_TOKEN_EOL, - Q3_TOKEN_COMMENT, - Q3_TOKEN_MATH_DIVIDE, - Q3_TOKEN_MATH_ADD, - Q3_TOKEN_MATH_MULTIPY - }; - struct SQ3Parser - { - const c8 *source; - u32 sourcesize; - u32 index; - core::stringc token; - eToken tokenresult; - }; - SQ3Parser Parser; - - - typedef void( CQ3LevelMesh::*tParserCallback ) ( quake3::SVarGroupList *& groupList, eToken token ); - void parser_parse( const void * data, u32 size, tParserCallback callback ); - void parser_nextToken(); - - void dumpVarGroup( const quake3::SVarGroup * group, s32 stack ) const; - - void scriptcallback_entity( quake3::SVarGroupList *& grouplist, eToken token ); - void scriptcallback_shader( quake3::SVarGroupList *& grouplist, eToken token ); - void scriptcallback_config( quake3::SVarGroupList *& grouplist, eToken token ); - - core::array < quake3::IShader > Shader; - core::array < quake3::IShader > Entity; //quake3::tQ3EntityList Entity; - - - quake3::tStringList ShaderFile; - void InitShader(); - void ReleaseShader(); - void ReleaseEntity(); - - - s32 setShaderMaterial( video::SMaterial & material, const tBSPFace * face ) const; - s32 setShaderFogMaterial( video::SMaterial &material, const tBSPFace * face ) const; - - struct SToBuffer - { - s32 takeVertexColor; - u32 index; - }; - - void cleanMeshes(); - void cleanLoader (); - void calcBoundingBoxes(); - c8 buf[128]; - }; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CQuake3ShaderSceneNode.cpp b/irrlicht-1.6/source/Irrlicht/CQuake3ShaderSceneNode.cpp deleted file mode 100644 index 31f1ddc21..000000000 --- a/irrlicht-1.6/source/Irrlicht/CQuake3ShaderSceneNode.cpp +++ /dev/null @@ -1,1337 +0,0 @@ -// Copyright (C) 2002-2009 Thomas Alten / 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_BSP_LOADER_ - -#include "CQuake3ShaderSceneNode.h" -#include "ISceneManager.h" -#include "IVideoDriver.h" -#include "ICameraSceneNode.h" -#include "SViewFrustum.h" -#include "IMeshManipulator.h" -#include "SMesh.h" -#include "IMaterialRenderer.h" - -namespace irr -{ -namespace scene -{ - -// who, if not you.. -using namespace quake3; - -/*! -*/ -CQuake3ShaderSceneNode::CQuake3ShaderSceneNode( - scene::ISceneNode* parent, scene::ISceneManager* mgr,s32 id, - io::IFileSystem *fileSystem, scene::IMeshBuffer *original, - const IShader * shader) -: scene::IMeshSceneNode(parent, mgr, id, - core::vector3df(0.f, 0.f, 0.f), - core::vector3df(0.f, 0.f, 0.f), - core::vector3df(1.f, 1.f, 1.f)), - Shader(shader), Mesh(0), Original(0), MeshBuffer(0), TimeAbs(0.f) -{ - #ifdef _DEBUG - core::stringc dName = "CQuake3ShaderSceneNode "; - dName += Shader->name; - - setDebugName( dName.c_str() ); - #endif - - // name the Scene Node - this->Name = Shader->name; - - // take lightmap vertex type - MeshBuffer = new SMeshBuffer(); - - Mesh = new SMesh (); - Mesh->addMeshBuffer ( MeshBuffer ); - MeshBuffer->drop (); - - //Original = new SMeshBufferLightMap(); - Original = (scene::SMeshBufferLightMap*) original; - Original->grab(); - - // clone meshbuffer to modifiable buffer - cloneBuffer( MeshBuffer, (scene::SMeshBufferLightMap*) original, - original->getMaterial().ColorMask != 0 - ); - - // load all Textures in all stages - loadTextures( fileSystem ); - - setAutomaticCulling( scene::EAC_OFF ); - -} - -/*! -*/ -CQuake3ShaderSceneNode::~CQuake3ShaderSceneNode() -{ - if (Mesh) - Mesh->drop(); - - if (Original) - Original->drop(); -} - - - -/* - create single copies -*/ -void CQuake3ShaderSceneNode::cloneBuffer( scene::SMeshBuffer *dest, scene::SMeshBufferLightMap * buffer, bool translateCenter ) -{ - dest->Material = buffer->Material; - dest->Indices = buffer->Indices; - - const u32 vsize = buffer->Vertices.size(); - - dest->Vertices.set_used( vsize ); - for ( u32 i = 0; i!= vsize; ++i ) - { - const video::S3DVertex2TCoords& src = buffer->Vertices[i]; - video::S3DVertex &dst = dest->Vertices[i]; - - dst.Pos = src.Pos; - dst.Normal = src.Normal; - dst.Color = 0xFFFFFFFF; - dst.TCoords = src.TCoords; - - if ( i == 0 ) - dest->BoundingBox.reset ( src.Pos ); - else - dest->BoundingBox.addInternalPoint ( src.Pos ); - } - - // move the (temp) Mesh to a ScenePosititon - // set Scene Node Position - - if ( translateCenter ) - { - MeshOffset = dest->BoundingBox.getCenter(); - setPosition( MeshOffset ); - - core::matrix4 m; - m.setTranslation( -MeshOffset ); - SceneManager->getMeshManipulator()->transform( dest, m ); - } - - - // No Texture!. Use Shader-Pointer for sorting - dest->Material.setTexture(0, (video::ITexture*) Shader); -} - - -/* - load the textures for all stages -*/ -void CQuake3ShaderSceneNode::loadTextures( io::IFileSystem * fileSystem ) -{ - const SVarGroup *group; - u32 i; - - video::IVideoDriver *driver = SceneManager->getVideoDriver(); - - // generic stage - u32 mipmap = 0; - group = Shader->getGroup( 1 ); - if ( group->isDefined ( "nomipmaps" ) ) - { - mipmap = 2 | (driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS)? 1: 0 ); - driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false); - } - - // clear all stages and prefill empty - Q3Texture.setAllocStrategy ( core::ALLOC_STRATEGY_SAFE ); - Q3Texture.clear(); - for ( i = 0; i != Shader->VarGroup->VariableGroup.size(); ++i ) - { - Q3Texture.push_back( SQ3Texture() ); - } - - u32 pos; - - // get texture map - for ( i = 0; i < Shader->VarGroup->VariableGroup.size(); ++i ) - { - group = Shader->getGroup( i ); - - const core::stringc &mapname = group->get( "map" ); - if ( 0 == mapname.size() ) - continue; - - // our lightmap is passed in material.Texture[2] - if ( mapname == "$lightmap" ) - { - Q3Texture [i].Texture.push_back( Original->getMaterial().getTexture(1) ); - } - else - { - pos = 0; - getTextures( Q3Texture [i].Texture, mapname, pos, fileSystem, driver ); - } - } - - // get anim map - for ( i = 0; i < Shader->VarGroup->VariableGroup.size(); ++i ) - { - if ( Q3Texture [i].Texture.size() ) - continue; - - group = Shader->getGroup( i ); - - const core::stringc &animmap = group->get( "animmap" ); - if ( 0 == animmap.size() ) - continue; - - // first parameter is frequency - pos = 0; - Q3Texture [i].TextureFrequency = core::max_( 0.0001f, getAsFloat( animmap, pos ) ); - - getTextures( Q3Texture [i].Texture, animmap, pos,fileSystem, driver ); - } - - // get clamp map - for ( i = 0; i < Shader->VarGroup->VariableGroup.size(); ++i ) - { - if ( Q3Texture [i].Texture.size() ) - continue; - - group = Shader->getGroup( i ); - - const core::stringc &clampmap = group->get( "clampmap" ); - if ( 0 == clampmap.size() ) - continue; - - Q3Texture [i].TextureAddressMode = video::ETC_CLAMP_TO_EDGE; - pos = 0; - getTextures( Q3Texture [i].Texture, clampmap, pos,fileSystem, driver ); - } - - if ( mipmap & 2 ) - driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, mipmap & 1); -} - -/* - Register each texture stage, if first is visible -*/ -void CQuake3ShaderSceneNode::OnRegisterSceneNode() -{ - if ( isVisible() ) - { - SceneManager->registerNodeForRendering(this, getRenderStage() ); - } - ISceneNode::OnRegisterSceneNode(); -} - -/* - is this a transparent node ? -*/ -E_SCENE_NODE_RENDER_PASS CQuake3ShaderSceneNode::getRenderStage() const -{ - E_SCENE_NODE_RENDER_PASS ret = ESNRP_SOLID; - - // generic stage - const SVarGroup *group; - - group = Shader->getGroup( 1 ); -/* - else - if ( group->getIndex( "portal" ) >= 0 ) - { - ret = ESNRP_TRANSPARENT_EFFECT; - } - else -*/ - if ( group->isDefined( "sort", "opaque" ) ) - { - ret = ESNRP_SOLID; - } - else - if ( group->isDefined( "sort", "additive" ) ) - { - ret = ESNRP_TRANSPARENT; - } - else - if ( strstr ( Shader->name.c_str(), "flame" ) || - group->isDefined( "surfaceparm", "water" ) || - group->isDefined( "sort", "underwater" ) || - group->isDefined( "sort", "underwater" ) - ) - { - ret = ESNRP_TRANSPARENT_EFFECT; - } - else - { - // Look if first drawing stage needs graphical underlay - for ( u32 stage = 2; stage < Shader->VarGroup->VariableGroup.size(); ++stage ) - { - if ( 0 == Q3Texture [ stage ].Texture.size() ) - continue; - - group = Shader->getGroup( stage ); - - SBlendFunc blendfunc ( video::EMFN_MODULATE_1X ); - getBlendFunc( group->get( "blendfunc" ), blendfunc ); - getBlendFunc( group->get( "alphafunc" ), blendfunc ); - - //ret = blendfunc.isTransparent ? ESNRP_TRANSPARENT : ESNRP_SOLID; - if ( blendfunc.isTransparent ) - { - ret = ESNRP_TRANSPARENT; - } - break; - } - } - - return ret; -} - - -/* - render in multipass technique -*/ -void CQuake3ShaderSceneNode::render() -{ - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - E_SCENE_NODE_RENDER_PASS pass = SceneManager->getSceneNodeRenderPass(); - - video::SMaterial material; - const SVarGroup *group; - - material.Lighting = false; - material.setTexture(1, 0); - material.NormalizeNormals = false; - - // generic stage - group = Shader->getGroup( 1 ); - material.BackfaceCulling = getCullingFunction( group->get( "cull" ) ); - - u32 pushProjection = 0; - core::matrix4 projection ( core::matrix4::EM4CONST_NOTHING ); - - // decal ( solve z-fighting ) - if ( group->isDefined( "polygonoffset" ) ) - { - projection = driver->getTransform( video::ETS_PROJECTION ); - - core::matrix4 decalProjection ( projection ); - -/* - f32 n = SceneManager->getActiveCamera()->getNearValue(); - f32 f = SceneManager->getActiveCamera()->getFarValue (); - - f32 delta = 0.01f; - f32 pz = 0.2f; - f32 epsilon = -2.f * f * n * delta / ( ( f + n ) * pz * ( pz + delta ) ); - decalProjection[10] *= 1.f + epsilon; -*/ - // TODO: involve camera - decalProjection[10] -= 0.0002f; - driver->setTransform( video::ETS_PROJECTION, decalProjection ); - pushProjection |= 1; - } - - driver->setTransform(video::ETS_WORLD, AbsoluteTransformation ); - - //! render all stages - u32 drawCount = (pass == ESNRP_TRANSPARENT_EFFECT) ? 1 : 0; - core::matrix4 textureMatrix ( core::matrix4::EM4CONST_NOTHING ); - for ( u32 stage = 1; stage < Shader->VarGroup->VariableGroup.size(); ++stage ) - { - SQ3Texture &q = Q3Texture[stage]; - - // advance current stage - textureMatrix.makeIdentity(); - animate( stage, textureMatrix ); - - // stage finished, no drawing stage ( vertex transform only ) - video::ITexture * tex = q.Texture.size() ? q.Texture [ q.TextureIndex ] : 0; - if ( 0 == tex ) - continue; - - // current stage - group = Shader->getGroup( stage ); - - material.setTexture(0, tex ); - material.ZBuffer = getDepthFunction( group->get( "depthfunc" ) ); - - if ( group->isDefined( "depthwrite" ) ) - { - material.ZWriteEnable = true; - } - else - { - material.ZWriteEnable = drawCount == 0; - } - - //resolve quake3 blendfunction to irrlicht Material Type - SBlendFunc blendfunc ( video::EMFN_MODULATE_1X ); - getBlendFunc( group->get( "blendfunc" ), blendfunc ); - getBlendFunc( group->get( "alphafunc" ), blendfunc ); - - material.MaterialType = blendfunc.type; - material.MaterialTypeParam = blendfunc.param0; - - material.TextureLayer[0].TextureWrap = q.TextureAddressMode; - //material.TextureLayer[0].TrilinearFilter = 1; - //material.TextureLayer[0].AnisotropicFilter = 0xFF; - material.setTextureMatrix( 0, textureMatrix ); - - driver->setMaterial( material ); - driver->drawMeshBuffer( MeshBuffer ); - drawCount += 1; - - } - - if ( DebugDataVisible & scene::EDS_MESH_WIRE_OVERLAY ) - { - video::SMaterial deb_m; - deb_m.Wireframe = true; - deb_m.Lighting = false; - deb_m.BackfaceCulling = material.BackfaceCulling; - driver->setMaterial( deb_m ); - - driver->drawMeshBuffer( MeshBuffer ); - } - - // show normals - if ( DebugDataVisible & scene::EDS_NORMALS ) - { - video::SMaterial deb_m; - - IAnimatedMesh * arrow = SceneManager->addArrowMesh ( - "__debugnormalq3", - 0xFFECEC00,0xFF999900, - 4, 8, - 8.f, 6.f, - 0.5f,1.f - ); - if ( 0 == arrow ) - { - arrow = SceneManager->getMesh ( "__debugnormalq3" ); - } - const IMesh *mesh = arrow->getMesh ( 0 ); - - // find a good scaling factor - - core::matrix4 m2; - - // draw normals - const scene::IMeshBuffer* mb = MeshBuffer; - const u32 vSize = video::getVertexPitchFromType(mb->getVertexType()); - const video::S3DVertex* v = ( const video::S3DVertex*)mb->getVertices(); - - //f32 colCycle = 270.f / (f32) core::s32_max ( mb->getVertexCount() - 1, 1 ); - - for ( u32 i=0; i != mb->getVertexCount(); ++i ) - { - // Align to v->normal - m2.buildRotateFromTo ( core::vector3df ( 0.f, 1.f, 0 ), v->Normal ); - m2.setTranslation ( v->Pos + AbsoluteTransformation.getTranslation () ); -/* - core::quaternion quatRot( v->Normal.Z, 0.f, -v->Normal.X, 1 + v->Normal.Y ); - quatRot.normalize(); - quatRot.getMatrix ( m2, v->Pos ); - - m2 [ 12 ] += AbsoluteTransformation [ 12 ]; - m2 [ 13 ] += AbsoluteTransformation [ 13 ]; - m2 [ 14 ] += AbsoluteTransformation [ 14 ]; -*/ - driver->setTransform(video::ETS_WORLD, m2 ); - - deb_m.Lighting = true; -/* - irr::video::SColorHSL color; - irr::video::SColor rgb(0); - color.Hue = i * colCycle * core::DEGTORAD; - color.Saturation = 1.f; - color.Luminance = 0.5f; - color.toRGB( deb_m.EmissiveColor ); -*/ - switch ( i ) - { - case 0: deb_m.EmissiveColor.set(0xFFFFFFFF); break; - case 1: deb_m.EmissiveColor.set(0xFFFF0000); break; - case 2: deb_m.EmissiveColor.set(0xFF00FF00); break; - case 3: deb_m.EmissiveColor.set(0xFF0000FF); break; - default: - deb_m.EmissiveColor = v->Color; break; - } - driver->setMaterial( deb_m ); - - for ( u32 a = 0; a != mesh->getMeshBufferCount(); ++a ) - driver->drawMeshBuffer ( mesh->getMeshBuffer ( a ) ); - - v = (const video::S3DVertex*) ( (u8*) v + vSize ); - } - driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); - } - - - if ( pushProjection & 1 ) - { - driver->setTransform( video::ETS_PROJECTION, projection ); - } - - if ( DebugDataVisible & scene::EDS_BBOX ) - { - video::SMaterial deb_m; - deb_m.Lighting = false; - driver->setMaterial(deb_m); - driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); - driver->draw3DBox( getBoundingBox(), video::SColor(255,255,0,0)); - } - -} - - -/*! -3.3.1 deformVertexes wave <div> <func> <base> <amplitude> <phase> <freq> - Designed for water surfaces, modifying the values differently at each point. - It accepts the standard wave functions of the type sin, triangle, square, sawtooth - or inversesawtooth. The "div" parameter is used to control the wave "spread" - - a value equal to the tessSize of the surface is a good default value - (tessSize is subdivision size, in game units, used for the shader when seen in the game world) . -*/ -void CQuake3ShaderSceneNode::deformvertexes_wave( f32 dt, SModifierFunction &function ) -{ - function.wave = core::reciprocal( function.wave ); - - const f32 phase = function.phase; - - const u32 vsize = Original->Vertices.size(); - for ( u32 i = 0; i != vsize; ++i ) - { - const video::S3DVertex2TCoords &src = Original->Vertices[i]; - video::S3DVertex &dst = MeshBuffer->Vertices[i]; - - if ( 0 == function.count ) - dst.Pos = src.Pos - MeshOffset; - - const f32 wavephase = (dst.Pos.X + dst.Pos.Y + dst.Pos.Z) * function.wave; - function.phase = phase + wavephase; - - const f32 f = function.evaluate( dt ); - - dst.Pos.X += f * src.Normal.X; - dst.Pos.Y += f * src.Normal.Y; - dst.Pos.Z += f * src.Normal.Z; - - if ( i == 0 ) - MeshBuffer->BoundingBox.reset ( dst.Pos ); - else - MeshBuffer->BoundingBox.addInternalPoint ( dst.Pos ); - } - function.count = 1; -} - -/*! - deformVertexes move x y z func base amplitude phase freq - The move parameter is used to make a brush, curve patch or model - appear to move together as a unit. The x y z values are the distance - and direction in game units the object appears to move relative to - it's point of origin in the map. The func base amplitude phase freq values are - the same as found in other waveform manipulations. - - The product of the function modifies the values x, y, and z. - Therefore, if you have an amplitude of 5 and an x value of 2, - the object will travel 10 units from its point of origin along the x axis. - This results in a total of 20 units of motion along the x axis, since the - amplitude is the variation both above and below the base. - - It must be noted that an object made with this shader does not actually - change position, it only appears to. - - Design Notes: - If an object is made up of surfaces with different shaders, all must have - matching deformVertexes move values or the object will appear to tear itself apart. -*/ -void CQuake3ShaderSceneNode::deformvertexes_move( f32 dt, SModifierFunction &function ) -{ - function.wave = core::reciprocal( function.wave ); - const f32 f = function.evaluate( dt ); - - const u32 vsize = Original->Vertices.size(); - for ( u32 i = 0; i != vsize; ++i ) - { - const video::S3DVertex2TCoords &src = Original->Vertices[i]; - video::S3DVertex &dst = MeshBuffer->Vertices[i]; - - if ( 0 == function.count ) - dst.Pos = src.Pos - MeshOffset; - - dst.Pos.X += f * function.x; - dst.Pos.Y += f * function.y; - dst.Pos.Z += f * function.z; - - if ( i == 0 ) - MeshBuffer->BoundingBox.reset ( dst.Pos ); - else - MeshBuffer->BoundingBox.addInternalPoint ( dst.Pos ); - } - function.count = 1; - -} - -/*! - 3.3.2 deformVertexes normal <div> <func> <base> <amplitude ~0.1-~0.5> <frequency ~1.0-~4.0> - This deformation affects the normals of a vertex without actually moving it, - which will effect later shader options like lighting and especially environment mapping. - If the shader stages don't use normals in any of their calculations, there will - be no visible effect. - - Design Notes: Putting values of 0.1 t o 0.5 in Amplitude and 1.0 to 4.0 in the - Frequency can produce some satisfying results. Some things that have been - done with it: A small fluttering bat, falling leaves, rain, flags. -*/ -void CQuake3ShaderSceneNode::deformvertexes_normal( f32 dt, SModifierFunction &function ) -{ - function.func = SINUS; - const u32 vsize = Original->Vertices.size(); - for ( u32 i = 0; i != vsize; ++i ) - { - const video::S3DVertex2TCoords &src = Original->Vertices[i]; - video::S3DVertex &dst = MeshBuffer->Vertices[i]; - - function.base = atan2f ( src.Pos.X, src.Pos.Y ); - function.phase = src.Pos.X + src.Pos.Z; - - const f32 lat = function.evaluate( dt ); - - function.base = src.Normal.Y; - function.phase = src.Normal.Z + src.Normal.X; - - const f32 lng = function.evaluate( dt ); - - dst.Normal.X = cosf ( lat ) * sinf ( lng ); - dst.Normal.Y = sinf ( lat ) * sinf ( lng ); - dst.Normal.Z = cosf ( lng ); - - } -} - - -/*! - 3.3.3 deformVertexes bulge <bulgeWidth> <bulgeHeight> <bulgeSpeed> - This forces a bulge to move along the given s and t directions. Designed for use - on curved pipes. - - Specific parameter definitions for deform keywords: - <div> This is roughly defined as the size of the waves that occur. - It is measured in game units. Smaller values create a greater - density of smaller wave forms occurring in a given area. - Larger values create a lesser density of waves, or otherwise put, - the appearance of larger waves. To look correct this value should - closely correspond to the value (in pixels) set for tessSize (tessellation size) - of the texture. A value of 100.0 is a good default value - (which means your tessSize should be close to that for things to look "wavelike"). - - <func> This is the type of wave form being created. Sin stands for sine wave, - a regular smoothly flowing wave. Triangle is a wave with a sharp ascent - and a sharp decay. It will make a choppy looking wave forms. - A square wave is simply on or off for the period of the - frequency with no in between. The sawtooth wave has the ascent of a - triangle wave, but has the decay cut off sharply like a square wave. - An inversesawtooth wave reverses this. - - <base> This is the distance, in game units that the apparent surface of the - texture is displaced from the actual surface of the brush as placed - in the editor. A positive value appears above the brush surface. - A negative value appears below the brush surface. - An example of this is the Quad effect, which essentially is a - shell with a positive base value to stand it away from the model - surface and a 0 (zero) value for amplitude. - - <amplitude> The distance that the deformation moves away from the base value. - See Wave Forms in the introduction for a description of amplitude. - - <phase> See Wave Forms in the introduction for a description of phase) - - <frequency> See Wave Forms in the introduction for a description of frequency) - - Design Note: The div and amplitude parameters, when used in conjunction with - liquid volumes like water should take into consideration how much the water - will be moving. A large ocean area would have have massive swells (big div values) - that rose and fell dramatically (big amplitude values). While a small, quiet pool - may move very little. -*/ -void CQuake3ShaderSceneNode::deformvertexes_bulge( f32 dt, SModifierFunction &function ) -{ - function.func = SINUS; - function.wave = core::reciprocal( function.bulgewidth ); - - dt *= function.bulgespeed * 0.1f; - const f32 phase = function.phase; - - const u32 vsize = Original->Vertices.size(); - for ( u32 i = 0; i != vsize; ++i ) - { - const video::S3DVertex2TCoords &src = Original->Vertices[i]; - video::S3DVertex &dst = MeshBuffer->Vertices[i]; - - const f32 wavephase = (Original->Vertices[i].TCoords.X ) * function.wave; - function.phase = phase + wavephase; - - const f32 f = function.evaluate( dt ); - - if ( 0 == function.count ) - dst.Pos = src.Pos - MeshOffset; - - dst.Pos.X += f * src.Normal.X; - dst.Pos.Y += f * src.Normal.Y; - dst.Pos.Z += f * src.Normal.Z; - - if ( i == 0 ) - MeshBuffer->BoundingBox.reset ( dst.Pos ); - else - MeshBuffer->BoundingBox.addInternalPoint ( dst.Pos ); - } - - function.count = 1; -} - - -/*! - deformVertexes autosprite - - This function can be used to make any given triangle quad - (pair of triangles that form a square rectangle) automatically behave - like a sprite without having to make it a separate entity. This means - that the "sprite" on which the texture is placed will rotate to always - appear at right angles to the player's view as a sprite would. Any four-sided - brush side, flat patch, or pair of triangles in a model can have the autosprite - effect on it. The brush face containing a texture with this shader keyword must - be square. -*/ -void CQuake3ShaderSceneNode::deformvertexes_autosprite( f32 dt, SModifierFunction &function ) -{ - u32 vsize = Original->Vertices.size(); - u32 g; - u32 i; - - const core::vector3df& camPos = SceneManager->getActiveCamera()->getPosition(); - - video::S3DVertex * dv = MeshBuffer->Vertices.pointer(); - const video::S3DVertex2TCoords * vin = Original->Vertices.pointer(); - - core::matrix4 lookat ( core::matrix4::EM4CONST_NOTHING ); - core::quaternion q; - for ( i = 0; i < vsize; i += 4 ) - { - // quad-plane - core::vector3df center = 0.25f * ( vin[i+0].Pos + vin[i+1].Pos + vin[i+2].Pos + vin[i+3].Pos ); - core::vector3df forward = camPos - center; - - q.rotationFromTo ( vin[i].Normal, forward ); - q.getMatrixCenter ( lookat, center, MeshOffset ); - - for ( g = 0; g < 4; ++g ) - { - lookat.transformVect ( dv[i+g].Pos, vin[i+g].Pos ); - lookat.rotateVect ( dv[i+g].Normal, vin[i+g].Normal ); - } - - } - function.count = 1; -} - - -/*! - deformVertexes autosprite2 - Is a slightly modified "sprite" that only rotates around the middle of its longest axis. - This allows you to make a pillar of fire that you can walk around, or an energy beam - stretched across the room. -*/ - -struct sortaxis -{ - core::vector3df v; - bool operator < ( const sortaxis &other ) const - { - return v.getLengthSQ () < other.v.getLengthSQ (); - } -}; -/*! -*/ -void CQuake3ShaderSceneNode::deformvertexes_autosprite2( f32 dt, SModifierFunction &function ) -{ - u32 vsize = Original->Vertices.size(); - u32 g; - u32 i; - - const core::vector3df camPos = SceneManager->getActiveCamera()->getAbsolutePosition(); - - video::S3DVertex * dv = MeshBuffer->Vertices.pointer(); - const video::S3DVertex2TCoords * vin = Original->Vertices.pointer(); - - core::matrix4 lookat ( core::matrix4::EM4CONST_NOTHING ); - - core::array < sortaxis > axis; - axis.set_used ( 3 ); - - for ( i = 0; i < vsize; i += 4 ) - { - // quad-plane - core::vector3df center = 0.25f * ( vin[i+0].Pos + vin[i+1].Pos + vin[i+2].Pos + vin[i+3].Pos ); - - // longes axe - axis[0].v = vin[i+1].Pos - vin[i+0].Pos; - axis[1].v = vin[i+2].Pos - vin[i+0].Pos; - axis[2].v = vin[i+3].Pos - vin[i+0].Pos; - axis.set_sorted ( false ); - axis.sort (); - - lookat.buildAxisAlignedBillboard ( camPos, center, MeshOffset, axis[1].v, vin[i+0].Normal ); - - for ( g = 0; g < 4; ++g ) - { - lookat.transformVect ( dv[i+g].Pos, vin[i+g].Pos ); - lookat.rotateVect ( dv[i+g].Normal, vin[i+g].Normal ); - } - } - function.count = 1; -} - -/* - Generate Vertex Color -*/ -void CQuake3ShaderSceneNode::vertextransform_rgbgen( f32 dt, SModifierFunction &function ) -{ - u32 i; - const u32 vsize = Original->Vertices.size(); - - switch ( function.rgbgen ) - { - case IDENTITY: - //rgbgen identity - for ( i = 0; i != vsize; ++i ) - MeshBuffer->Vertices[i].Color.set(0xFFFFFFFF); - break; - - case IDENTITYLIGHTING: - // rgbgen identitylighting TODO: overbright - for ( i = 0; i != vsize; ++i ) - MeshBuffer->Vertices[i].Color.set(0xFF7F7F7F); - break; - - case EXACTVERTEX: - // alphagen exactvertex TODO lighting - case VERTEX: - // rgbgen vertex - for ( i = 0; i != vsize; ++i ) - MeshBuffer->Vertices[i].Color=Original->Vertices[i].Color; - break; - case WAVE: - { - // rgbGen wave <func> <base> <amp> <phase> <freq> - f32 f = function.evaluate( dt ) * 255.f; - s32 value = core::clamp( core::floor32(f), 0, 255 ); - value = 0xFF000000 | value << 16 | value << 8 | value; - - for ( i = 0; i != vsize; ++i ) - MeshBuffer->Vertices[i].Color.set(value); - } break; - case CONSTANT: - { - //rgbgen const ( x y z ) - video::SColorf cf( function.x, function.y, function.z ); - video::SColor col = cf.toSColor(); - for ( i = 0; i != vsize; ++i ) - MeshBuffer->Vertices[i].Color=col; - } break; - default: - break; - } -} - -/* - Generate Vertex Color, Alpha -*/ -void CQuake3ShaderSceneNode::vertextransform_alphagen( f32 dt, SModifierFunction &function ) -{ - u32 i; - const u32 vsize = Original->Vertices.size(); - - switch ( function.alphagen ) - { - case IDENTITY: - //alphagen identity - for ( i = 0; i != vsize; ++i ) - MeshBuffer->Vertices[i].Color.setAlpha ( 0xFF ); - break; - - case EXACTVERTEX: - // alphagen exactvertex TODO lighting - case VERTEX: - // alphagen vertex - for ( i = 0; i != vsize; ++i ) - MeshBuffer->Vertices[i].Color.setAlpha ( Original->Vertices[i].Color.getAlpha() ); - break; - case CONSTANT: - { - // alphagen const - u32 a = (u32) ( function.x * 255.f ); - for ( i = 0; i != vsize; ++i ) - MeshBuffer->Vertices[i].Color.setAlpha ( a ); - } break; - - case LIGHTINGSPECULAR: - { - // alphagen lightingspecular TODO!!! - const SViewFrustum *frustum = SceneManager->getActiveCamera()->getViewFrustum(); - const core::matrix4 &view = frustum->getTransform ( video::ETS_VIEW ); - - const f32 *m = view.pointer(); - - for ( i = 0; i != vsize; ++i ) - { - const core::vector3df &n = Original->Vertices[i].Normal; - MeshBuffer->Vertices[i].Color.setAlpha ((u32)( 128.f *(1.f+(n.X*m[0]+n.Y*m[1]+n.Z*m[2])))); - } - - } break; - - - case WAVE: - { - // alphagen wave - f32 f = function.evaluate( dt ) * 255.f; - s32 value = core::clamp( core::floor32(f), 0, 255 ); - - for ( i = 0; i != vsize; ++i ) - MeshBuffer->Vertices[i].Color.setAlpha ( value ); - } break; - default: - break; - } -} - - - -/* - Generate Texture Coordinates -*/ -void CQuake3ShaderSceneNode::vertextransform_tcgen( f32 dt, SModifierFunction &function ) -{ - u32 i; - const u32 vsize = Original->Vertices.size(); - - switch ( function.tcgen ) - { - case TURBULENCE: - //tcgen turb - { - function.wave = core::reciprocal( function.phase ); - - const f32 phase = function.phase; - - for ( i = 0; i != vsize; ++i ) - { - const video::S3DVertex2TCoords &src = Original->Vertices[i]; - video::S3DVertex &dst = MeshBuffer->Vertices[i]; - - const f32 wavephase = (src.Pos.X + src.Pos.Y + src.Pos.Z) * function.wave; - function.phase = phase + wavephase; - - const f32 f = function.evaluate( dt ); - - dst.TCoords.X = src.TCoords.X + f * src.Normal.X; - dst.TCoords.Y = src.TCoords.Y + f * src.Normal.Y; - } - } - break; - - case TEXTURE: - // tcgen texture - for ( i = 0; i != vsize; ++i ) - MeshBuffer->Vertices[i].TCoords = Original->Vertices[i].TCoords; - break; - case LIGHTMAP: - // tcgen lightmap - for ( i = 0; i != vsize; ++i ) - MeshBuffer->Vertices[i].TCoords = Original->Vertices[i].TCoords2; - break; - case ENVIRONMENT: - { - // tcgen environment - const SViewFrustum *frustum = SceneManager->getActiveCamera()->getViewFrustum(); - const core::matrix4 &view = frustum->getTransform ( video::ETS_VIEW ); - - const f32 *m = view.pointer(); - - core::vector3df n; - for ( i = 0; i != vsize; ++i ) - { - //const core::vector3df &n = Original->Vertices[i].Normal; - - n = frustum->cameraPosition - Original->Vertices[i].Pos; - n.normalize(); - n += Original->Vertices[i].Normal; - n.normalize(); - - MeshBuffer->Vertices[i].TCoords.X = 0.5f*(1.f+(n.X*m[0]+n.Y*m[1]+n.Z*m[2])); - MeshBuffer->Vertices[i].TCoords.Y = 0.5f*(1.f+(n.X*m[4]+n.Y*m[5]+n.Z*m[6])); - } - - } break; - default: - break; - } -} - - -#if 0 -/* - Transform Texture Coordinates -*/ -void CQuake3ShaderSceneNode::transformtex( const core::matrix4 &m, const u32 addressMode ) -{ - u32 i; - const u32 vsize = MeshBuffer->Vertices.size(); - - f32 tx1; - f32 ty1; - - if ( addressMode ) - { - for ( i = 0; i != vsize; ++i ) - { - core::vector2df &tx = MeshBuffer->Vertices[i].TCoords; - - tx1 = m[0] * tx.X + m[4] * tx.Y + m[8]; - ty1 = m[1] * tx.X + m[5] * tx.Y + m[9]; - - tx.X = tx1; - tx.Y = ty1; - } - } - else - { - - for ( i = 0; i != vsize; ++i ) - { - core::vector2df &tx = MeshBuffer->Vertices[i].TCoords; - - tx1 = m[0] * tx.X + m[4] * tx.Y + m[8]; - ty1 = m[1] * tx.X + m[5] * tx.Y + m[9]; - - tx.X = tx1 <= 0.f ? 0.f : tx1 >= 1.f ? 1.f : tx1; - tx.Y = ty1 <= 0.f ? 0.f : ty1 >= 1.f ? 1.f : ty1; - - //tx.X = core::clamp( tx1, 0.f, 1.f ); - //tx.Y = core::clamp( ty1, 0.f, 1.f ); - } - } -} - -#endif - - -/* - Texture & Vertex Transform Animator - - Return a Texture Transformation for this stage - Vertex transformation are called if found - -*/ -void CQuake3ShaderSceneNode::animate( u32 stage,core::matrix4 &texture ) -{ - const SVarGroup *group = Shader->getGroup( stage ); - - // select current texture - SQ3Texture &q3Tex = Q3Texture [ stage ]; - if ( q3Tex.TextureFrequency != 0.f ) - { - s32 v = core::floor32( TimeAbs * q3Tex.TextureFrequency ); - q3Tex.TextureIndex = v % q3Tex.Texture.size(); - } - - core::matrix4 m2; - SModifierFunction function; - - f32 f[16]; - - // walk group for all modifiers - for ( u32 g = 0; g != group->Variable.size(); ++g ) - { - const SVariable &v = group->Variable[g]; - - // get the modifier - static const c8 * modifierList[] = - { - "tcmod","deformvertexes","rgbgen","tcgen","map","alphagen" - }; - - u32 pos = 0; - function.masterfunc0 = (eQ3ModifierFunction) isEqual( v.name, pos, modifierList, 6 ); - - if ( UNKNOWN == function.masterfunc0 ) - continue; - - switch ( function.masterfunc0 ) - { - //tcmod - case TCMOD: - m2.makeIdentity(); - break; - default: - break; - } - - // get the modifier function - static const c8 * funclist[] = - { - "scroll","scale","rotate","stretch","turb", - "wave","identity","vertex", - "texture","lightmap","environment","$lightmap", - "bulge","autosprite","autosprite2","transform", - "exactvertex","const","lightingspecular","move","normal", - "identitylighting" - }; - static const c8 * groupToken[] = { "(", ")" }; - - pos = 0; - function.masterfunc1 = (eQ3ModifierFunction) isEqual( v.content, pos, funclist, 22 ); - if ( function.masterfunc1 != UNKNOWN ) - function.masterfunc1 = (eQ3ModifierFunction) ((u32) function.masterfunc1 + FUNCTION2 + 1); - - switch ( function.masterfunc1 ) - { - case SCROLL: - // tcMod scroll <sSpeed> <tSpeed> - f[0] = getAsFloat( v.content, pos ) * TimeAbs; - f[1] = getAsFloat( v.content, pos ) * TimeAbs; - m2.setTextureTranslate( f[0], f[1] ); - break; - case SCALE: - // tcmod scale <sScale> <tScale> - f[0] = getAsFloat( v.content, pos ); - f[1] = getAsFloat( v.content, pos ); - m2.setTextureScale( f[0], f[1] ); - break; - case ROTATE: - // tcmod rotate <degress per second> - m2.setTextureRotationCenter( getAsFloat( v.content, pos ) * - core::DEGTORAD * - TimeAbs - ); - break; - case TRANSFORM: - // tcMod <transform> <m00> <m01> <m10> <m11> <t0> <t1> - memset(f, 0, sizeof ( f )); - f[10] = f[15] = 1.f; - - f[0] = getAsFloat( v.content, pos ); - f[1] = getAsFloat( v.content, pos ); - f[4] = getAsFloat( v.content, pos ); - f[5] = getAsFloat( v.content, pos ); - f[8] = getAsFloat( v.content, pos ); - f[9] = getAsFloat( v.content, pos ); - m2.setM ( f ); - break; - - case STRETCH: // stretch - case TURBULENCE: // turb - case WAVE: // wave - case IDENTITY: // identity - case IDENTITYLIGHTING: - case VERTEX: // vertex - case MOVE: - case CONSTANT: - { - // turb == sin, default == sin - function.func = SINUS; - - if ( function.masterfunc0 == DEFORMVERTEXES ) - { - switch ( function.masterfunc1 ) - { - case WAVE: - // deformvertexes wave - function.wave = getAsFloat( v.content, pos ); - break; - case MOVE: - //deformvertexes move - function.x = getAsFloat( v.content, pos ); - function.z = getAsFloat( v.content, pos ); - function.y = getAsFloat( v.content, pos ); - break; - default: - break; - } - } - - switch ( function.masterfunc1 ) - { - case STRETCH: - case TURBULENCE: - case WAVE: - case MOVE: - getModifierFunc( function, v.content, pos ); - break; - default: - break; - } - - switch ( function.masterfunc1 ) - { - case STRETCH: - //tcMod stretch <func> <base> <amplitude> <phase> <frequency> - f[0] = core::reciprocal( function.evaluate(TimeAbs) ); - m2.setTextureScaleCenter( f[0], f[0] ); - break; - case TURBULENCE: - //tcMod turb <base> <amplitude> <phase> <freq> - //function.tcgen = TURBULENCE; - m2.setTextureRotationCenter( function.frequency * - core::DEGTORAD * - TimeAbs - ); - break; - case WAVE: - case IDENTITY: - case IDENTITYLIGHTING: - case VERTEX: - case EXACTVERTEX: - case CONSTANT: - case LIGHTINGSPECULAR: - case MOVE: - switch ( function.masterfunc0 ) - { - case DEFORMVERTEXES: - switch ( function.masterfunc1 ) - { - case WAVE: - deformvertexes_wave( TimeAbs, function ); - break; - case MOVE: - deformvertexes_move( TimeAbs, function ); - break; - default: - break; - } - break; - case RGBGEN: - function.rgbgen = function.masterfunc1; - if ( function.rgbgen == CONSTANT ) - { - isEqual ( v.content, pos, groupToken, 2 ); - function.x = getAsFloat( v.content, pos ); - function.y = getAsFloat( v.content, pos ); - function.z = getAsFloat( v.content, pos ); - } - //vertextransform_rgbgen( TimeAbs, function ); - break; - case ALPHAGEN: - function.alphagen = function.masterfunc1; - if ( function.alphagen == CONSTANT ) - { - function.x = getAsFloat( v.content, pos ); - } - - //vertextransform_alphagen( TimeAbs, function ); - break; - default: - break; - } - break; - default: - break; - } - - } break; - case TEXTURE: - case LIGHTMAP: - case ENVIRONMENT: - // "texture","lightmap","environment" - function.tcgen = function.masterfunc1; - break; - case DOLLAR_LIGHTMAP: - // map == lightmap, tcgen == lightmap - function.tcgen = LIGHTMAP; - break; - case BULGE: - // deformvertexes bulge - function.bulgewidth = getAsFloat( v.content, pos ); - function.bulgeheight = getAsFloat( v.content, pos ); - function.bulgespeed = getAsFloat( v.content, pos ); - - deformvertexes_bulge(TimeAbs, function); - break; - - case NORMAL: - // deformvertexes normal - function.amp = getAsFloat( v.content, pos ); - function.frequency = getAsFloat( v.content, pos ); - - deformvertexes_normal(TimeAbs, function); - break; - - case AUTOSPRITE: - // deformvertexes autosprite - deformvertexes_autosprite(TimeAbs, function); - break; - - case AUTOSPRITE2: - // deformvertexes autosprite2 - deformvertexes_autosprite2(TimeAbs, function); - break; - default: - break; - } // func - - switch ( function.masterfunc0 ) - { - case TCMOD: - texture *= m2; - break; - default: - break; - } - - } // group - - vertextransform_rgbgen( TimeAbs, function ); - vertextransform_alphagen( TimeAbs, function ); - vertextransform_tcgen( TimeAbs, function ); -} - - -void CQuake3ShaderSceneNode::OnAnimate(u32 timeMs) -{ - TimeAbs = f32( timeMs ) * (1.f/1000.f); - ISceneNode::OnAnimate( timeMs ); -} - -const core::aabbox3d<f32>& CQuake3ShaderSceneNode::getBoundingBox() const -{ - return MeshBuffer->getBoundingBox(); -} - - -u32 CQuake3ShaderSceneNode::getMaterialCount() const -{ - return Q3Texture.size(); -} - -video::SMaterial& CQuake3ShaderSceneNode::getMaterial(u32 i) -{ - video::SMaterial& m = MeshBuffer->Material; - m.setTexture(0, 0); - if ( Q3Texture [ i ].TextureIndex ) - m.setTexture(0, Q3Texture [ i ].Texture [ Q3Texture [ i ].TextureIndex ]); - return m; -} - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CQuake3ShaderSceneNode.h b/irrlicht-1.6/source/Irrlicht/CQuake3ShaderSceneNode.h deleted file mode 100644 index fde277a73..000000000 --- a/irrlicht-1.6/source/Irrlicht/CQuake3ShaderSceneNode.h +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_QUAKE3_SCENE_NODE_H_INCLUDED__ -#define __C_QUAKE3_SCENE_NODE_H_INCLUDED__ - -#include "IMeshSceneNode.h" -#include "IQ3Shader.h" -#include "IFileSystem.h" -#include "SMeshBuffer.h" -#include "SMeshBufferLightMap.h" -#include "SMesh.h" -#include "ISceneManager.h" - -namespace irr -{ -namespace scene -{ - -//! Scene node which is a quake3 shader. -class CQuake3ShaderSceneNode : public scene::IMeshSceneNode -{ -public: - - CQuake3ShaderSceneNode( ISceneNode* parent, ISceneManager* mgr, s32 id, - io::IFileSystem *fileSystem, - IMeshBuffer *original, - const quake3::IShader * shader - ); - - virtual ~CQuake3ShaderSceneNode(); - - virtual void OnRegisterSceneNode(); - virtual void render(); - virtual void OnAnimate(u32 timeMs); - virtual const core::aabbox3d<f32>& getBoundingBox() const; - - virtual u32 getMaterialCount() const; - virtual video::SMaterial& getMaterial(u32 i); - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() const { return ESNT_Q3SHADER_SCENE_NODE; } - - virtual void setMesh(IMesh* mesh){} - virtual IMesh* getMesh() { return Mesh; } - virtual void setReadOnlyMaterials(bool readonly) {} - virtual bool isReadOnlyMaterials() const { return true; } - -private: - const quake3::IShader* Shader; - SMesh *Mesh; - SMeshBufferLightMap* Original; - SMeshBuffer* MeshBuffer; - core::vector3df MeshOffset; - - struct SQ3Texture - { - SQ3Texture () : - TextureIndex ( 0 ), - TextureFrequency(0.f), - TextureAddressMode( video::ETC_REPEAT ) - { - Texture.setAllocStrategy ( core::ALLOC_STRATEGY_SAFE ); - } - - quake3::tTexArray Texture; - - u32 TextureIndex; - f32 TextureFrequency; - video::E_TEXTURE_CLAMP TextureAddressMode; // Wrapping/Clamping - }; - - core::array< SQ3Texture > Q3Texture; - - void loadTextures ( io::IFileSystem * fileSystem ); - void addBuffer ( scene::SMeshBufferLightMap * buffer ); - void cloneBuffer ( scene::SMeshBuffer *dest, scene::SMeshBufferLightMap * buffer, bool translateCenter ); - - void deformvertexes_wave ( f32 dt, quake3::SModifierFunction &function ); - void deformvertexes_move ( f32 dt, quake3::SModifierFunction &function ); - void deformvertexes_bulge( f32 dt, quake3::SModifierFunction &function ); - void deformvertexes_autosprite( f32 dt, quake3::SModifierFunction &function ); - void deformvertexes_autosprite2( f32 dt, quake3::SModifierFunction &function ); - void deformvertexes_normal ( f32 dt, quake3::SModifierFunction &function ); - - void vertextransform_tcgen ( f32 dt, quake3::SModifierFunction &function ); - void vertextransform_rgbgen ( f32 dt, quake3::SModifierFunction &function ); - void vertextransform_alphagen ( f32 dt, quake3::SModifierFunction &function ); - - void transformtex ( const core::matrix4 &m, const u32 clamp ); - - f32 TimeAbs; - - void animate( u32 stage, core::matrix4 &texture ); - - E_SCENE_NODE_RENDER_PASS getRenderStage() const; - -}; - - -} // end namespace scene -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CReadFile.cpp b/irrlicht-1.6/source/Irrlicht/CReadFile.cpp deleted file mode 100644 index b0d1a5b8e..000000000 --- a/irrlicht-1.6/source/Irrlicht/CReadFile.cpp +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CReadFile.h" - -namespace irr -{ -namespace io -{ - - -CReadFile::CReadFile(const io::path& fileName) -: File(0), FileSize(0), Filename(fileName) -{ - #ifdef _DEBUG - setDebugName("CReadFile"); - #endif - - openFile(); -} - - -CReadFile::~CReadFile() -{ - if (File) - fclose(File); -} - - -//! returns how much was read -s32 CReadFile::read(void* buffer, u32 sizeToRead) -{ - if (!isOpen()) - return 0; - - return (s32)fread(buffer, 1, sizeToRead, File); -} - - -//! changes position in file, returns true if successful -//! if relativeMovement==true, the pos is changed relative to current pos, -//! otherwise from begin of file -bool CReadFile::seek(long finalPos, bool relativeMovement) -{ - if (!isOpen()) - return false; - - return fseek(File, finalPos, relativeMovement ? SEEK_CUR : SEEK_SET) == 0; -} - - -//! returns size of file -long CReadFile::getSize() const -{ - return FileSize; -} - - -//! returns where in the file we are. -long CReadFile::getPos() const -{ - return ftell(File); -} - - -//! opens the file -void CReadFile::openFile() -{ - if (Filename.size() == 0) // bugfix posted by rt - { - File = 0; - return; - } - -#if defined ( _IRR_WCHAR_FILESYSTEM ) - File = _wfopen(Filename.c_str(), L"rb"); -#else - File = fopen(Filename.c_str(), "rb"); -#endif - - if (File) - { - // get FileSize - - fseek(File, 0, SEEK_END); - FileSize = getPos(); - fseek(File, 0, SEEK_SET); - } -} - - -//! returns name of file -const io::path& CReadFile::getFileName() const -{ - return Filename; -} - - - -IReadFile* createReadFile(const io::path& fileName) -{ - CReadFile* file = new CReadFile(fileName); - if (file->isOpen()) - return file; - - file->drop(); - return 0; -} - - -} // end namespace io -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CReadFile.h b/irrlicht-1.6/source/Irrlicht/CReadFile.h deleted file mode 100644 index aca25112c..000000000 --- a/irrlicht-1.6/source/Irrlicht/CReadFile.h +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_READ_FILE_H_INCLUDED__ -#define __C_READ_FILE_H_INCLUDED__ - -#include <stdio.h> -#include "IReadFile.h" -#include "irrString.h" - -namespace irr -{ - -namespace io -{ - - /*! - Class for reading a real file from disk. - */ - class CReadFile : public IReadFile - { - public: - - CReadFile(const io::path& fileName); - - virtual ~CReadFile(); - - //! returns how much was read - virtual s32 read(void* buffer, u32 sizeToRead); - - //! changes position in file, returns true if successful - virtual bool seek(long finalPos, bool relativeMovement = false); - - //! returns size of file - virtual long getSize() const; - - //! returns if file is open - virtual bool isOpen() const - { - return File != 0; - } - - //! returns where in the file we are. - virtual long getPos() const; - - //! returns name of file - virtual const io::path& getFileName() const; - - private: - - //! opens the file - void openFile(); - - FILE* File; - long FileSize; - io::path Filename; - }; - -} // end namespace io -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CSTLMeshFileLoader.cpp b/irrlicht-1.6/source/Irrlicht/CSTLMeshFileLoader.cpp deleted file mode 100644 index 720d68129..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSTLMeshFileLoader.cpp +++ /dev/null @@ -1,258 +0,0 @@ -// Copyright (C) 2007-2009 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" -#include "os.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 io::path& filename) const -{ - return core::hasFileExtension ( filename, "stl" ); -} - - - -//! 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(); - SMeshBuffer* meshBuffer = new SMeshBuffer(); - mesh->addMeshBuffer(meshBuffer); - meshBuffer->drop(); - - 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); - if (normal==core::vector3df()) - normal=core::plane3df(vertex[2],vertex[1],vertex[0]).Normal; - mb->Vertices.push_back(video::S3DVertex(vertex[2],normal,color, core::vector2df())); - mb->Vertices.push_back(video::S3DVertex(vertex[1],normal,color, core::vector2df())); - mb->Vertices.push_back(video::S3DVertex(vertex[0],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) - mesh->getMeshBuffer(0)->recalculateBoundingBox(); - - // 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 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); - } - vec.X=-vec.X; -} - - -//! 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_ - diff --git a/irrlicht-1.6/source/Irrlicht/CSTLMeshFileLoader.h b/irrlicht-1.6/source/Irrlicht/CSTLMeshFileLoader.h deleted file mode 100644 index fc8280c90..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSTLMeshFileLoader.h +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2007-2009 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 "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 io::path& 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 3d vector of floats - void getNextVector(io::IReadFile* file, core::vector3df& vec, bool binary) const; -}; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CSTLMeshWriter.cpp b/irrlicht-1.6/source/Irrlicht/CSTLMeshWriter.cpp deleted file mode 100644 index 647aa6aad..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSTLMeshWriter.cpp +++ /dev/null @@ -1,187 +0,0 @@ -// Copyright (C) 2002-2009 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) -{ - #ifdef _DEBUG - setDebugName("CSTLMeshWriter"); - #endif - - 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 (flags & scene::EMWF_WRITE_COMPRESSED) - 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 u32 indexCount = buffer->getIndexCount(); - const u16 attributes = 0; - for (u32 j=0; j<indexCount; j+=3) - { - const core::vector3df& v1 = buffer->getPosition(buffer->getIndices()[j]); - const core::vector3df& v2 = buffer->getPosition(buffer->getIndices()[j+1]); - const core::vector3df& v3 = buffer->getPosition(buffer->getIndices()[j+2]); - const core::plane3df tmpplane(v1,v2,v3); - file->write(&tmpplane.Normal, 12); - file->write(&v1, 12); - file->write(&v2, 12); - file->write(&v3, 12); - file->write(&attributes, 2); - } - } - } - 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 u32 indexCount = buffer->getIndexCount(); - for (u32 j=0; j<indexCount; j+=3) - { - writeFace(file, - buffer->getPosition(buffer->getIndices()[j]), - buffer->getPosition(buffer->getIndices()[j+1]), - buffer->getPosition(buffer->getIndices()[j+2])); - } - 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 = core::stringc(v.X); - s += " "; - s += core::stringc(v.Y); - s += " "; - s += core::stringc(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 - diff --git a/irrlicht-1.6/source/Irrlicht/CSTLMeshWriter.h b/irrlicht-1.6/source/Irrlicht/CSTLMeshWriter.h deleted file mode 100644 index 017d0eb3e..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSTLMeshWriter.h +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2002-2009 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 - diff --git a/irrlicht-1.6/source/Irrlicht/CSceneCollisionManager.cpp b/irrlicht-1.6/source/Irrlicht/CSceneCollisionManager.cpp deleted file mode 100644 index 3860242b1..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSceneCollisionManager.cpp +++ /dev/null @@ -1,940 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CSceneCollisionManager.h" -#include "ISceneNode.h" -#include "ICameraSceneNode.h" -#include "ITriangleSelector.h" -#include "SViewFrustum.h" - -#include "os.h" -#include "irrMath.h" -#include <float.h> // For FLT_MAX - -namespace irr -{ -namespace scene -{ - -//! constructor -CSceneCollisionManager::CSceneCollisionManager(ISceneManager* smanager, video::IVideoDriver* driver) -: SceneManager(smanager), Driver(driver) -{ - #ifdef _DEBUG - setDebugName("CSceneCollisionManager"); - #endif - - if (Driver) - Driver->grab(); -} - - -//! destructor -CSceneCollisionManager::~CSceneCollisionManager() -{ - if (Driver) - Driver->drop(); -} - - -//! Returns the scene node, which is currently visible at the given -//! screen coordinates, viewed from the currently active camera. -ISceneNode* CSceneCollisionManager::getSceneNodeFromScreenCoordinatesBB( - const core::position2d<s32>& pos, s32 idBitMask, bool bNoDebugObjects, scene::ISceneNode* root) -{ - const core::line3d<f32> ln = getRayFromScreenCoordinates(pos, 0); - - if ( ln.start == ln.end ) - return 0; - - return getSceneNodeFromRayBB(ln, idBitMask, bNoDebugObjects, root); -} - - -//! Returns the nearest scene node which collides with a 3d ray and -//! which id matches a bitmask. -ISceneNode* CSceneCollisionManager::getSceneNodeFromRayBB(const core::line3d<f32>& ray, - s32 idBitMask, bool bNoDebugObjects, scene::ISceneNode* root) -{ - ISceneNode* best = 0; - f32 dist = FLT_MAX; - - core::line3d<f32> truncatableRay(ray); - - getPickedNodeBB((root==0)?SceneManager->getRootSceneNode():root, truncatableRay, - idBitMask, bNoDebugObjects, dist, best); - - return best; -} - - -//! recursive method for going through all scene nodes -void CSceneCollisionManager::getPickedNodeBB(ISceneNode* root, - core::line3df& ray, s32 bits, bool bNoDebugObjects, - f32& outbestdistance, ISceneNode*& outbestnode) -{ - const core::list<ISceneNode*>& children = root->getChildren(); - const core::vector3df rayVector = ray.getVector().normalize(); - - core::list<ISceneNode*>::ConstIterator it = children.begin(); - for (; it != children.end(); ++it) - { - ISceneNode* current = *it; - - if (current->isVisible()) - { - if((bNoDebugObjects ? !current->isDebugObject() : true) && - (bits==0 || (bits != 0 && (current->getID() & bits)))) - { - // get world to object space transform - core::matrix4 worldToObject; - if (!current->getAbsoluteTransformation().getInverse(worldToObject)) - continue; - - // transform vector from world space to object space - core::line3df objectRay(ray); - worldToObject.transformVect(objectRay.start); - worldToObject.transformVect(objectRay.end); - - const core::aabbox3df & objectBox = current->getBoundingBox(); - - // Do the initial intersection test in object space, since the - // object space box test is more accurate. - if(objectBox.isPointInside(objectRay.start)) - { - // If the line starts inside the box, then consider the distance as being - // to the centre of the box. - const f32 toIntersectionSq = objectRay.start.getDistanceFromSQ(objectBox.getCenter()); - if(toIntersectionSq < outbestdistance) - { - outbestdistance = toIntersectionSq; - outbestnode = current; - - // And we can truncate the ray to stop us hitting further nodes. - ray.end = ray.start + (rayVector * sqrtf(toIntersectionSq)); - } - } - else if (objectBox.intersectsWithLine(objectRay)) - { - // Now transform into world space, since we need to use world space - // scales and distances. - core::aabbox3df worldBox(objectBox); - current->getAbsoluteTransformation().transformBox(worldBox); - - core::vector3df edges[8]; - worldBox.getEdges(edges); - - /* We need to check against each of 6 faces, composed of these corners: - /3--------/7 - / | / | - / | / | - 1---------5 | - | 2- - -| -6 - | / | / - |/ | / - 0---------4/ - - Note that we define them as opposite pairs of faces. - */ - static const s32 faceEdges[6][3] = - { - { 0, 1, 5 }, // Front - { 6, 7, 3 }, // Back - { 2, 3, 1 }, // Left - { 4, 5, 7 }, // Right - { 1, 3, 7 }, // Top - { 2, 0, 4 } // Bottom - }; - - core::vector3df intersection; - core::plane3df facePlane; - f32 bestDistToBoxBorder = FLT_MAX; - f32 bestToIntersectionSq = FLT_MAX; - - for(s32 face = 0; face < 6; ++face) - { - facePlane.setPlane(edges[faceEdges[face][0]], - edges[faceEdges[face][1]], - edges[faceEdges[face][2]]); - - // Only consider lines that might be entering through this face, since we - // already know that the start point is outside the box. - if(facePlane.classifyPointRelation(ray.start) != core::ISREL3D_FRONT) - continue; - - // Don't bother using a limited ray, since we already know that it should be long - // enough to intersect with the box. - if(facePlane.getIntersectionWithLine(ray.start, rayVector, intersection)) - { - const f32 toIntersectionSq = ray.start.getDistanceFromSQ(intersection); - if(toIntersectionSq < outbestdistance) - { - // We have to check that the intersection with this plane is actually - // on the box, so need to go back to object space again. - worldToObject.transformVect(intersection); - - // find the closes point on the box borders. Have to do this as exact checks will fail due to floating point problems. - f32 distToBorder = core::max_ ( core::min_ (core::abs_(objectBox.MinEdge.X-intersection.X), core::abs_(objectBox.MaxEdge.X-intersection.X)), - core::min_ (core::abs_(objectBox.MinEdge.Y-intersection.Y), core::abs_(objectBox.MaxEdge.Y-intersection.Y)), - core::min_ (core::abs_(objectBox.MinEdge.Z-intersection.Z), core::abs_(objectBox.MaxEdge.Z-intersection.Z)) ); - if ( distToBorder < bestDistToBoxBorder ) - { - bestDistToBoxBorder = distToBorder; - bestToIntersectionSq = toIntersectionSq; - } - } - } - - // If the ray could be entering through the first face of a pair, then it can't - // also be entering through the opposite face, and so we can skip that face. - if(0 == (face % 2)) - ++face; - } - - if ( bestDistToBoxBorder < FLT_MAX ) - { - outbestdistance = bestToIntersectionSq; - outbestnode = current; - - // If we got a hit, we can now truncate the ray to stop us hitting further nodes. - ray.end = ray.start + (rayVector * sqrtf(outbestdistance)); - } - } - } - - // Only check the children if this node is visible. - getPickedNodeBB(current, ray, bits, bNoDebugObjects, outbestdistance, outbestnode); - } - } -} - - -ISceneNode* CSceneCollisionManager::getSceneNodeAndCollisionPointFromRay( - core::line3df ray, - core::vector3df & outCollisionPoint, - core::triangle3df & outTriangle, - s32 idBitMask, - ISceneNode * collisionRootNode, - bool noDebugObjects) -{ - ISceneNode* bestNode = 0; - f32 bestDistanceSquared = FLT_MAX; - - if(0 == collisionRootNode) - collisionRootNode = SceneManager->getRootSceneNode(); - - // We don't try to do anything too clever, like sorting the candidate - // nodes by distance to bounding-box. In the example below, we could do the - // triangle collision check with node A first, but we'd have to check node B - // anyway, as the actual collision point could be (and is) closer than the - // collision point in node A. - // - // ray end - // | - // AAAAAAAAAA - // A | - // A | B - // A | B - // A BBBBB - // A | - // A | - // | - // | - // ray start - // - // We therefore have to do a full BB and triangle collision on every scene - // node in order to find the nearest collision point, so sorting them by - // bounding box would be pointless. - - getPickedNodeFromBBAndSelector(collisionRootNode, ray, idBitMask, - noDebugObjects, bestDistanceSquared, bestNode, - outCollisionPoint, outTriangle); - return bestNode; -} - - -void CSceneCollisionManager::getPickedNodeFromBBAndSelector( - ISceneNode * root, - const core::line3df & ray, - s32 bits, - bool noDebugObjects, - f32 & outBestDistanceSquared, - ISceneNode * & outBestNode, - core::vector3df & outBestCollisionPoint, - core::triangle3df & outBestTriangle) -{ - const core::list<ISceneNode*>& children = root->getChildren(); - - core::list<ISceneNode*>::ConstIterator it = children.begin(); - for (; it != children.end(); ++it) - { - ISceneNode* current = *it; - ITriangleSelector * selector = current->getTriangleSelector(); - - if (selector && current->isVisible() && - (noDebugObjects ? !current->isDebugObject() : true) && - (bits==0 || (bits != 0 && (current->getID() & bits)))) - { - // get world to object space transform - core::matrix4 mat; - if (!current->getAbsoluteTransformation().getInverse(mat)) - continue; - - // transform vector from world space to object space - core::line3df line(ray); - mat.transformVect(line.start); - mat.transformVect(line.end); - - const core::aabbox3df& box = current->getBoundingBox(); - - core::vector3df candidateCollisionPoint; - core::triangle3df candidateTriangle; - - // do intersection test in object space - const ISceneNode * hitNode = 0; - if (box.intersectsWithLine(line) && - getCollisionPoint(ray, selector, candidateCollisionPoint, candidateTriangle, hitNode)) - { - const f32 distanceSquared = (candidateCollisionPoint - ray.start).getLengthSQ(); - - if(distanceSquared < outBestDistanceSquared) - { - outBestDistanceSquared = distanceSquared; - outBestNode = current; - outBestCollisionPoint = candidateCollisionPoint; - outBestTriangle = candidateTriangle; - } - } - } - - getPickedNodeFromBBAndSelector(current, ray, bits, noDebugObjects, - outBestDistanceSquared, outBestNode, - outBestCollisionPoint, outBestTriangle); - } -} - - -//! Returns the scene node, at which the overgiven camera is looking at and -//! which id matches the bitmask. -ISceneNode* CSceneCollisionManager::getSceneNodeFromCameraBB( - ICameraSceneNode* camera, s32 idBitMask, bool bNoDebugObjects) -{ - if (!camera) - return 0; - - const core::vector3df start = camera->getAbsolutePosition(); - core::vector3df end = camera->getTarget(); - - end = start + ((end - start).normalize() * camera->getFarValue()); - - return getSceneNodeFromRayBB(core::line3d<f32>(start, end), idBitMask, bNoDebugObjects); -} - - -//! Finds the collision point of a line and lots of triangles, if there is one. -bool CSceneCollisionManager::getCollisionPoint(const core::line3d<f32>& ray, - ITriangleSelector* selector, core::vector3df& outIntersection, - core::triangle3df& outTriangle, - const ISceneNode*& outNode) -{ - if (!selector) - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; - } - - s32 totalcnt = selector->getTriangleCount(); - Triangles.set_used(totalcnt); - - s32 cnt = 0; - selector->getTriangles(Triangles.pointer(), totalcnt, cnt, ray); - - const core::vector3df linevect = ray.getVector().normalize(); - core::vector3df intersection; - f32 nearest = FLT_MAX; - bool found = false; - const f32 raylength = ray.getLengthSQ(); - - const f32 minX = core::min_(ray.start.X, ray.end.X); - const f32 maxX = core::max_(ray.start.X, ray.end.X); - const f32 minY = core::min_(ray.start.Y, ray.end.Y); - const f32 maxY = core::max_(ray.start.Y, ray.end.Y); - const f32 minZ = core::min_(ray.start.Z, ray.end.Z); - const f32 maxZ = core::max_(ray.start.Z, ray.end.Z); - - for (s32 i=0; i<cnt; ++i) - { - const core::triangle3df & triangle = Triangles[i]; - - if(minX > triangle.pointA.X && minX > triangle.pointB.X && minX > triangle.pointC.X) - continue; - if(maxX < triangle.pointA.X && maxX < triangle.pointB.X && maxX < triangle.pointC.X) - continue; - if(minY > triangle.pointA.Y && minY > triangle.pointB.Y && minY > triangle.pointC.Y) - continue; - if(maxY < triangle.pointA.Y && maxY < triangle.pointB.Y && maxY < triangle.pointC.Y) - continue; - if(minZ > triangle.pointA.Z && minZ > triangle.pointB.Z && minZ > triangle.pointC.Z) - continue; - if(maxZ < triangle.pointA.Z && maxZ < triangle.pointB.Z && maxZ < triangle.pointC.Z) - continue; - - if (triangle.getIntersectionWithLine(ray.start, linevect, intersection)) - { - const f32 tmp = intersection.getDistanceFromSQ(ray.start); - const f32 tmp2 = intersection.getDistanceFromSQ(ray.end); - - if (tmp < raylength && tmp2 < raylength && tmp < nearest) - { - nearest = tmp; - outTriangle = triangle; - outIntersection = intersection; - outNode = selector->getSceneNodeForTriangle(i); - found = true; - } - } - } - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return found; -} - - -//! Collides a moving ellipsoid with a 3d world with gravity and returns -//! the resulting new position of the ellipsoid. -core::vector3df CSceneCollisionManager::getCollisionResultPosition( - ITriangleSelector* selector, - const core::vector3df &position, const core::vector3df& radius, - const core::vector3df& direction, - core::triangle3df& triout, - core::vector3df& hitPosition, - bool& outFalling, - const ISceneNode*& outNode, - f32 slidingSpeed, - const core::vector3df& gravity) -{ - return collideEllipsoidWithWorld(selector, position, - radius, direction, slidingSpeed, gravity, triout, hitPosition, outFalling, outNode); -} - - -bool CSceneCollisionManager::testTriangleIntersection(SCollisionData* colData, - const core::triangle3df& triangle) -{ - const core::plane3d<f32> trianglePlane = triangle.getPlane(); - - // only check front facing polygons - if ( !trianglePlane.isFrontFacing(colData->normalizedVelocity) ) - return false; - - // get interval of plane intersection - - f32 t1, t0; - bool embeddedInPlane = false; - - // calculate signed distance from sphere position to triangle plane - f32 signedDistToTrianglePlane = trianglePlane.getDistanceTo( - colData->basePoint); - - f32 normalDotVelocity = - trianglePlane.Normal.dotProduct(colData->velocity); - - if ( core::iszero ( normalDotVelocity ) ) - { - // sphere is traveling parallel to plane - - if (fabs(signedDistToTrianglePlane) >= 1.0f) - return false; // no collision possible - else - { - // sphere is embedded in plane - embeddedInPlane = true; - t0 = 0.0; - t1 = 1.0; - } - } - else - { - normalDotVelocity = core::reciprocal ( normalDotVelocity ); - - // N.D is not 0. Calculate intersection interval - t0 = (-1.f - signedDistToTrianglePlane) * normalDotVelocity; - t1 = (1.f - signedDistToTrianglePlane) * normalDotVelocity; - - // Swap so t0 < t1 - if (t0 > t1) { f32 tmp = t1; t1 = t0; t0 = tmp; } - - // check if at least one value is within the range - if (t0 > 1.0f || t1 < 0.0f) - return false; // both t values are outside 1 and 0, no collision possible - - // clamp to 0 and 1 - t0 = core::clamp ( t0, 0.f, 1.f ); - t1 = core::clamp ( t1, 0.f, 1.f ); - } - - // at this point we have t0 and t1, if there is any intersection, it - // is between this interval - core::vector3df collisionPoint; - bool foundCollision = false; - f32 t = 1.0f; - - // first check the easy case: Collision within the triangle; - // if this happens, it must be at t0 and this is when the sphere - // rests on the front side of the triangle plane. This can only happen - // if the sphere is not embedded in the triangle plane. - - if (!embeddedInPlane) - { - core::vector3df planeIntersectionPoint = - (colData->basePoint - trianglePlane.Normal) - + (colData->velocity * t0); - - if (triangle.isPointInside(planeIntersectionPoint)) - { - foundCollision = true; - t = t0; - collisionPoint = planeIntersectionPoint; - } - } - - // if we havent found a collision already we will have to sweep - // the sphere against points and edges of the triangle. Note: A - // collision inside the triangle will always happen before a - // vertex or edge collision. - - if (!foundCollision) - { - core::vector3df velocity = colData->velocity; - core::vector3df base = colData->basePoint; - - f32 velocitySqaredLength = velocity.getLengthSQ(); - f32 a,b,c; - f32 newT; - - // for each edge or vertex a quadratic equation has to be solved: - // a*t^2 + b*t + c = 0. We calculate a,b, and c for each test. - - // check against points - a = velocitySqaredLength; - - // p1 - b = 2.0f * (velocity.dotProduct(base - triangle.pointA)); - c = (triangle.pointA-base).getLengthSQ() - 1.f; - if (getLowestRoot(a,b,c,t, &newT)) - { - t = newT; - foundCollision = true; - collisionPoint = triangle.pointA; - } - - // p2 - if (!foundCollision) - { - b = 2.0f * (velocity.dotProduct(base - triangle.pointB)); - c = (triangle.pointB-base).getLengthSQ() - 1.f; - if (getLowestRoot(a,b,c,t, &newT)) - { - t = newT; - foundCollision = true; - collisionPoint = triangle.pointB; - } - } - - // p3 - if (!foundCollision) - { - b = 2.0f * (velocity.dotProduct(base - triangle.pointC)); - c = (triangle.pointC-base).getLengthSQ() - 1.f; - if (getLowestRoot(a,b,c,t, &newT)) - { - t = newT; - foundCollision = true; - collisionPoint = triangle.pointC; - } - } - - // check against edges: - - // p1 --- p2 - core::vector3df edge = triangle.pointB - triangle.pointA; - core::vector3df baseToVertex = triangle.pointA - base; - f32 edgeSqaredLength = edge.getLengthSQ(); - f32 edgeDotVelocity = edge.dotProduct(velocity); - f32 edgeDotBaseToVertex = edge.dotProduct(baseToVertex); - - // calculate parameters for equation - a = edgeSqaredLength* -velocitySqaredLength + - edgeDotVelocity*edgeDotVelocity; - b = edgeSqaredLength* (2.f *velocity.dotProduct(baseToVertex)) - - 2.0f*edgeDotVelocity*edgeDotBaseToVertex; - c = edgeSqaredLength* (1.f -baseToVertex.getLengthSQ()) + - edgeDotBaseToVertex*edgeDotBaseToVertex; - - // does the swept sphere collide against infinite edge? - if (getLowestRoot(a,b,c,t,&newT)) - { - f32 f = (edgeDotVelocity*newT - edgeDotBaseToVertex) / edgeSqaredLength; - if (f >=0.0f && f <= 1.0f) - { - // intersection took place within segment - t = newT; - foundCollision = true; - collisionPoint = triangle.pointA + (edge*f); - } - } - - // p2 --- p3 - edge = triangle.pointC-triangle.pointB; - baseToVertex = triangle.pointB - base; - edgeSqaredLength = edge.getLengthSQ(); - edgeDotVelocity = edge.dotProduct(velocity); - edgeDotBaseToVertex = edge.dotProduct(baseToVertex); - - // calculate parameters for equation - a = edgeSqaredLength* -velocitySqaredLength + - edgeDotVelocity*edgeDotVelocity; - b = edgeSqaredLength* (2*velocity.dotProduct(baseToVertex)) - - 2.0f*edgeDotVelocity*edgeDotBaseToVertex; - c = edgeSqaredLength* (1-baseToVertex.getLengthSQ()) + - edgeDotBaseToVertex*edgeDotBaseToVertex; - - // does the swept sphere collide against infinite edge? - if (getLowestRoot(a,b,c,t,&newT)) - { - f32 f = (edgeDotVelocity*newT-edgeDotBaseToVertex) / - edgeSqaredLength; - if (f >=0.0f && f <= 1.0f) - { - // intersection took place within segment - t = newT; - foundCollision = true; - collisionPoint = triangle.pointB + (edge*f); - } - } - - - // p3 --- p1 - edge = triangle.pointA-triangle.pointC; - baseToVertex = triangle.pointC - base; - edgeSqaredLength = edge.getLengthSQ(); - edgeDotVelocity = edge.dotProduct(velocity); - edgeDotBaseToVertex = edge.dotProduct(baseToVertex); - - // calculate parameters for equation - a = edgeSqaredLength* -velocitySqaredLength + - edgeDotVelocity*edgeDotVelocity; - b = edgeSqaredLength* (2*velocity.dotProduct(baseToVertex)) - - 2.0f*edgeDotVelocity*edgeDotBaseToVertex; - c = edgeSqaredLength* (1-baseToVertex.getLengthSQ()) + - edgeDotBaseToVertex*edgeDotBaseToVertex; - - // does the swept sphere collide against infinite edge? - if (getLowestRoot(a,b,c,t,&newT)) - { - f32 f = (edgeDotVelocity*newT-edgeDotBaseToVertex) / - edgeSqaredLength; - if (f >=0.0f && f <= 1.0f) - { - // intersection took place within segment - t = newT; - foundCollision = true; - collisionPoint = triangle.pointC + (edge*f); - } - } - }// end no collision found - - // set result: - if (foundCollision) - { - // distance to collision is t - f32 distToCollision = t*colData->velocity.getLength(); - - // does this triangle qualify for closest hit? - if (!colData->foundCollision || - distToCollision < colData->nearestDistance) - { - colData->nearestDistance = distToCollision; - colData->intersectionPoint = collisionPoint; - colData->foundCollision = true; - colData->intersectionTriangle = triangle; - ++colData->triangleHits; - return true; - } - }// end found collision - - return false; -} - - -//! Collides a moving ellipsoid with a 3d world with gravity and returns -//! the resulting new position of the ellipsoid. -core::vector3df CSceneCollisionManager::collideEllipsoidWithWorld( - ITriangleSelector* selector, const core::vector3df &position, - const core::vector3df& radius, const core::vector3df& velocity, - f32 slidingSpeed, - const core::vector3df& gravity, - core::triangle3df& triout, - core::vector3df& hitPosition, - bool& outFalling, - const ISceneNode*& outNode) -{ - if (!selector || radius.X == 0.0f || radius.Y == 0.0f || radius.Z == 0.0f) - return position; - - // This code is based on the paper "Improved Collision detection and Response" - // by Kasper Fauerby, but some parts are modified. - - SCollisionData colData; - colData.R3Position = position; - colData.R3Velocity = velocity; - colData.eRadius = radius; - colData.nearestDistance = FLT_MAX; - colData.selector = selector; - colData.slidingSpeed = slidingSpeed; - colData.triangleHits = 0; - colData.triangleIndex = -1; - - core::vector3df eSpacePosition = colData.R3Position / colData.eRadius; - core::vector3df eSpaceVelocity = colData.R3Velocity / colData.eRadius; - - // iterate until we have our final position - - core::vector3df finalPos = collideWithWorld( - 0, colData, eSpacePosition, eSpaceVelocity); - - outFalling = false; - - // add gravity - - if (gravity != core::vector3df(0,0,0)) - { - colData.R3Position = finalPos * colData.eRadius; - colData.R3Velocity = gravity; - colData.triangleHits = 0; - - eSpaceVelocity = gravity/colData.eRadius; - - finalPos = collideWithWorld(0, colData, - finalPos, eSpaceVelocity); - - outFalling = (colData.triangleHits == 0); - } - - if (colData.triangleHits) - { - triout = colData.intersectionTriangle; - triout.pointA *= colData.eRadius; - triout.pointB *= colData.eRadius; - triout.pointC *= colData.eRadius; - outNode = selector->getSceneNodeForTriangle(colData.triangleIndex); - } - - finalPos *= colData.eRadius; - hitPosition = colData.intersectionPoint * colData.eRadius; - return finalPos; -} - - -core::vector3df CSceneCollisionManager::collideWithWorld(s32 recursionDepth, - SCollisionData &colData, core::vector3df pos, core::vector3df vel) -{ - f32 veryCloseDistance = colData.slidingSpeed; - - if (recursionDepth > 5) - return pos; - - colData.velocity = vel; - colData.normalizedVelocity = vel; - colData.normalizedVelocity.normalize(); - colData.basePoint = pos; - colData.foundCollision = false; - colData.nearestDistance = FLT_MAX; - - //------------------ collide with world - - // get all triangles with which we might collide - core::aabbox3d<f32> box(colData.R3Position); - box.addInternalPoint(colData.R3Position + colData.R3Velocity); - box.MinEdge -= colData.eRadius; - box.MaxEdge += colData.eRadius; - - s32 totalTriangleCnt = colData.selector->getTriangleCount(); - Triangles.set_used(totalTriangleCnt); - - core::matrix4 scaleMatrix; - scaleMatrix.setScale( - core::vector3df(1.0f / colData.eRadius.X, - 1.0f / colData.eRadius.Y, - 1.0f / colData.eRadius.Z)); - - s32 triangleCnt = 0; - colData.selector->getTriangles(Triangles.pointer(), totalTriangleCnt, triangleCnt, box, &scaleMatrix); - - for (s32 i=0; i<triangleCnt; ++i) - if(testTriangleIntersection(&colData, Triangles[i])) - colData.triangleIndex = i; - - //---------------- end collide with world - - if (!colData.foundCollision) - return pos + vel; - - // original destination point - const core::vector3df destinationPoint = pos + vel; - core::vector3df newBasePoint = pos; - - // only update if we are not already very close - // and if so only move very close to intersection, not to the - // exact point - if (colData.nearestDistance >= veryCloseDistance) - { - core::vector3df v = vel; - v.setLength( colData.nearestDistance - veryCloseDistance ); - newBasePoint = colData.basePoint + v; - - v.normalize(); - colData.intersectionPoint -= (v * veryCloseDistance); - } - - // calculate sliding plane - - const core::vector3df slidePlaneOrigin = colData.intersectionPoint; - const core::vector3df slidePlaneNormal = (newBasePoint - colData.intersectionPoint).normalize(); - core::plane3d<f32> slidingPlane(slidePlaneOrigin, slidePlaneNormal); - - core::vector3df newDestinationPoint = - destinationPoint - - (slidePlaneNormal * slidingPlane.getDistanceTo(destinationPoint)); - - // generate slide vector - - const core::vector3df newVelocityVector = newDestinationPoint - - colData.intersectionPoint; - - if (newVelocityVector.getLength() < veryCloseDistance) - return newBasePoint; - - return collideWithWorld(recursionDepth+1, colData, - newBasePoint, newVelocityVector); -} - - -//! Returns a 3d ray which would go through the 2d screen coodinates. -core::line3d<f32> CSceneCollisionManager::getRayFromScreenCoordinates( - const core::position2d<s32> & pos, ICameraSceneNode* camera) -{ - core::line3d<f32> ln(0,0,0,0,0,0); - - if (!SceneManager) - return ln; - - if (!camera) - camera = SceneManager->getActiveCamera(); - - if (!camera) - return ln; - - const scene::SViewFrustum* f = camera->getViewFrustum(); - - core::vector3df farLeftUp = f->getFarLeftUp(); - core::vector3df lefttoright = f->getFarRightUp() - farLeftUp; - core::vector3df uptodown = f->getFarLeftDown() - farLeftUp; - - const core::rect<s32>& viewPort = Driver->getViewPort(); - core::dimension2d<u32> screenSize(viewPort.getWidth(), viewPort.getHeight()); - - f32 dx = pos.X / (f32)screenSize.Width; - f32 dy = pos.Y / (f32)screenSize.Height; - - if (camera->isOrthogonal()) - ln.start = f->cameraPosition + (lefttoright * (dx-0.5f)) + (uptodown * (dy-0.5f)); - else - ln.start = f->cameraPosition; - - ln.end = farLeftUp + (lefttoright * dx) + (uptodown * dy); - - return ln; -} - - -//! Calculates 2d screen position from a 3d position. -core::position2d<s32> CSceneCollisionManager::getScreenCoordinatesFrom3DPosition( - const core::vector3df & pos3d, ICameraSceneNode* camera) -{ - if (!SceneManager || !Driver) - return core::position2d<s32>(-1000,-1000); - - if (!camera) - camera = SceneManager->getActiveCamera(); - - if (!camera) - return core::position2d<s32>(-1000,-1000); - - const core::rect<s32>& viewPort = Driver->getViewPort(); - core::dimension2d<u32> dim(viewPort.getWidth(), viewPort.getHeight()); - - dim.Width /= 2; - dim.Height /= 2; - - core::matrix4 trans = camera->getProjectionMatrix(); - trans *= camera->getViewMatrix(); - - f32 transformedPos[4] = { pos3d.X, pos3d.Y, pos3d.Z, 1.0f }; - - trans.multiplyWith1x4Matrix(transformedPos); - - if (transformedPos[3] < 0) - return core::position2d<s32>(-10000,-10000); - - const f32 zDiv = transformedPos[3] == 0.0f ? 1.0f : - core::reciprocal(transformedPos[3]); - - return core::position2d<s32>( - core::round32(dim.Width * transformedPos[0] * zDiv) + dim.Width, - dim.Height - core::round32(dim.Height * (transformedPos[1] * zDiv))); -} - - -inline bool CSceneCollisionManager::getLowestRoot(f32 a, f32 b, f32 c, f32 maxR, f32* root) -{ - // check if solution exists - f32 determinant = b*b - 4.0f*a*c; - - // if determinant is negative, no solution - if (determinant < 0.0f) return false; - - // calculate two roots: (if det==0 then x1==x2 - // but lets disregard that slight optimization) - // burningwater: sqrt( 0) is an illegal operation.... smth should be done... - - f32 sqrtD = (f32)sqrt(determinant); - - f32 r1 = (-b - sqrtD) / (2*a); - f32 r2 = (-b + sqrtD) / (2*a); - - // sort so x1 <= x2 - if (r1 > r2) { f32 tmp=r2; r2=r1; r1=tmp; } - - // get lowest root - if (r1 > 0 && r1 < maxR) - { - *root = r1; - return true; - } - - // its possible that we want x2, this can happen if x1 < 0 - if (r2 > 0 && r2 < maxR) - { - *root = r2; - return true; - } - - return false; -} - - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CSceneCollisionManager.h b/irrlicht-1.6/source/Irrlicht/CSceneCollisionManager.h deleted file mode 100644 index 2cc7710b0..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSceneCollisionManager.h +++ /dev/null @@ -1,158 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_SCENE_COLLISION_MANAGER_H_INCLUDED__ -#define __C_SCENE_COLLISION_MANAGER_H_INCLUDED__ - -#include "ISceneCollisionManager.h" -#include "ISceneManager.h" -#include "IVideoDriver.h" - -namespace irr -{ -namespace scene -{ - - //! The Scene Collision Manager provides methods for performing collision tests and picking on scene nodes. - class CSceneCollisionManager : public ISceneCollisionManager - { - public: - - //! constructor - CSceneCollisionManager(ISceneManager* smanager, video::IVideoDriver* driver); - - //! destructor - virtual ~CSceneCollisionManager(); - - //! Returns the scene node, which is currently visible at the given - //! screen coordinates, viewed from the currently active camera. - virtual ISceneNode* getSceneNodeFromScreenCoordinatesBB(const core::position2d<s32>& pos, - s32 idBitMask=0, bool bNoDebugObjects=false, ISceneNode* root=0); - - //! Returns the nearest scene node which collides with a 3d ray and - //! whose id matches a bitmask. - virtual ISceneNode* getSceneNodeFromRayBB(const core::line3d<f32>& ray, - s32 idBitMask=0, bool bNoDebugObjects=false, - ISceneNode* root=0); - - //! Returns the scene node, at which the overgiven camera is looking at and - //! which id matches the bitmask. - virtual ISceneNode* getSceneNodeFromCameraBB(ICameraSceneNode* camera, - s32 idBitMask=0, bool bNoDebugObjects = false); - - //! Finds the collision point of a line and lots of triangles, if there is one. - virtual bool getCollisionPoint(const core::line3d<f32>& ray, - ITriangleSelector* selector, core::vector3df& outCollisionPoint, - core::triangle3df& outTriangle, - const ISceneNode* & outNode); - - //! Collides a moving ellipsoid with a 3d world with gravity and returns - //! the resulting new position of the ellipsoid. - virtual core::vector3df getCollisionResultPosition( - ITriangleSelector* selector, - const core::vector3df &ellipsoidPosition, - const core::vector3df& ellipsoidRadius, - const core::vector3df& ellipsoidDirectionAndSpeed, - core::triangle3df& triout, - core::vector3df& hitPosition, - bool& outFalling, - const ISceneNode*& outNode, - f32 slidingSpeed, - const core::vector3df& gravityDirectionAndSpeed); - - //! Returns a 3d ray which would go through the 2d screen coodinates. - virtual core::line3d<f32> getRayFromScreenCoordinates( - const core::position2d<s32> & pos, ICameraSceneNode* camera = 0); - - //! Calculates 2d screen position from a 3d position. - virtual core::position2d<s32> getScreenCoordinatesFrom3DPosition( - const core::vector3df & pos, ICameraSceneNode* camera=0); - - //! Gets the scene node and nearest collision point for a ray based on - //! the nodes' id bitmasks, bounding boxes and triangle selectors. - virtual ISceneNode* getSceneNodeAndCollisionPointFromRay( - core::line3df ray, - core::vector3df & outCollisionPoint, - core::triangle3df & outTriangle, - s32 idBitMask = 0, - ISceneNode * collisionRootNode = 0, - bool noDebugObjects = false); - - - private: - - //! recursive method for going through all scene nodes - void getPickedNodeBB(ISceneNode* root, core::line3df& ray, s32 bits, - bool bNoDebugObjects, - f32& outbestdistance, ISceneNode*& outbestnode); - - //! recursive method for going through all scene nodes - void getPickedNodeFromBBAndSelector(ISceneNode * root, - const core::line3df & ray, - s32 bits, - bool noDebugObjects, - f32 & outBestDistanceSquared, - ISceneNode * & outBestNode, - core::vector3df & outBestCollisionPoint, - core::triangle3df & outBestTriangle); - - - struct SCollisionData - { - core::vector3df eRadius; - - core::vector3df R3Velocity; - core::vector3df R3Position; - - core::vector3df velocity; - core::vector3df normalizedVelocity; - core::vector3df basePoint; - - bool foundCollision; - f32 nearestDistance; - core::vector3df intersectionPoint; - - core::triangle3df intersectionTriangle; - s32 triangleIndex; - s32 triangleHits; - - f32 slidingSpeed; - - ITriangleSelector* selector; - }; - - //! Tests the current collision data against an individual triangle. - /** - \param colData: the collision data. - \param triangle: the triangle to test against. - \return true if the triangle is hit (and is the closest hit), false otherwise */ - bool testTriangleIntersection(SCollisionData* colData, - const core::triangle3df& triangle); - - //! recursive method for doing collision response - core::vector3df collideEllipsoidWithWorld(ITriangleSelector* selector, - const core::vector3df &position, - const core::vector3df& radius, const core::vector3df& velocity, - f32 slidingSpeed, - const core::vector3df& gravity, core::triangle3df& triout, - core::vector3df& hitPosition, - bool& outFalling, - const ISceneNode*& outNode); - - core::vector3df collideWithWorld(s32 recursionDepth, SCollisionData &colData, - core::vector3df pos, core::vector3df vel); - - inline bool getLowestRoot(f32 a, f32 b, f32 c, f32 maxR, f32* root); - - ISceneManager* SceneManager; - video::IVideoDriver* Driver; - core::array<core::triangle3df> Triangles; // triangle buffer - }; - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CSceneManager.cpp b/irrlicht-1.6/source/Irrlicht/CSceneManager.cpp deleted file mode 100644 index 307d437b3..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSceneManager.cpp +++ /dev/null @@ -1,2589 +0,0 @@ -// Copyright (C) 2002-2009 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" -#include "CSceneManager.h" -#include "IVideoDriver.h" -#include "IFileSystem.h" -#include "SAnimatedMesh.h" -#include "CMeshCache.h" -#include "IWriteFile.h" -#include "IXMLWriter.h" -#include "ISceneUserDataSerializer.h" -#include "IGUIEnvironment.h" -#include "IMaterialRenderer.h" -#include "IReadFile.h" - -#include "os.h" - -#ifdef _IRR_COMPILE_WITH_IRR_MESH_LOADER_ -#include "CIrrMeshFileLoader.h" -#endif - -#ifdef _IRR_COMPILE_WITH_BSP_LOADER_ -#include "CBSPMeshFileLoader.h" -#endif - -#ifdef _IRR_COMPILE_WITH_MD2_LOADER_ -#include "CMD2MeshFileLoader.h" -#endif - -#ifdef _IRR_COMPILE_WITH_MS3D_LOADER_ -#include "CMS3DMeshFileLoader.h" -#endif - -#ifdef _IRR_COMPILE_WITH_3DS_LOADER_ -#include "C3DSMeshFileLoader.h" -#endif - -#ifdef _IRR_COMPILE_WITH_X_LOADER_ -#include "CXMeshFileLoader.h" -#endif - -#ifdef _IRR_COMPILE_WITH_OCT_LOADER_ -#include "COCTLoader.h" -#endif - -#ifdef _IRR_COMPILE_WITH_CSM_LOADER_ -#include "CCSMLoader.h" -#endif - -#ifdef _IRR_COMPILE_WITH_LMTS_LOADER_ -#include "CLMTSMeshFileLoader.h" -#endif - -#ifdef _IRR_COMPILE_WITH_MY3D_LOADER_ -#include "CMY3DMeshFileLoader.h" -#endif - -#ifdef _IRR_COMPILE_WITH_COLLADA_LOADER_ -#include "CColladaFileLoader.h" -#endif - -#ifdef _IRR_COMPILE_WITH_DMF_LOADER_ -#include "CDMFLoader.h" -#endif - -#ifdef _IRR_COMPILE_WITH_OGRE_LOADER_ -#include "COgreMeshFileLoader.h" -#endif - -#ifdef _IRR_COMPILE_WITH_OBJ_LOADER_ -#include "COBJMeshFileLoader.h" -#endif - -#ifdef _IRR_COMPILE_WITH_MD3_LOADER_ -#include "CMD3MeshFileLoader.h" -#endif - -#ifdef _IRR_COMPILE_WITH_B3D_LOADER_ -#include "CB3DMeshFileLoader.h" -#endif - -#ifdef _IRR_COMPILE_WITH_LWO_LOADER_ -#include "CLWOMeshFileLoader.h" -#endif - -#ifdef _IRR_COMPILE_WITH_STL_LOADER_ -#include "CSTLMeshFileLoader.h" -#endif - -#ifdef _IRR_COMPILE_WITH_PLY_LOADER_ -#include "CPLYMeshFileLoader.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 - -#ifdef _IRR_COMPILE_WITH_OBJ_WRITER_ -#include "COBJMeshWriter.h" -#endif - -#ifdef _IRR_COMPILE_WITH_PLY_WRITER_ -#include "CPLYMeshWriter.h" -#endif - -#include "CCubeSceneNode.h" -#include "CSphereSceneNode.h" -#include "CAnimatedMeshSceneNode.h" -#include "COctTreeSceneNode.h" -#include "CCameraSceneNode.h" - -#include "CLightSceneNode.h" -#include "CBillboardSceneNode.h" -#include "CMeshSceneNode.h" -#include "CSkyBoxSceneNode.h" -#include "CSkyDomeSceneNode.h" -#include "CParticleSystemSceneNode.h" -#include "CDummyTransformationSceneNode.h" -#include "CWaterSurfaceSceneNode.h" -#include "CTerrainSceneNode.h" -#include "CEmptySceneNode.h" -#include "CTextSceneNode.h" -#include "CDefaultSceneNodeFactory.h" - -#include "CSceneCollisionManager.h" -#include "CTriangleSelector.h" -#include "COctTreeTriangleSelector.h" -#include "CTriangleBBSelector.h" -#include "CMetaTriangleSelector.h" -#include "CTerrainTriangleSelector.h" - -#include "CSceneNodeAnimatorRotation.h" -#include "CSceneNodeAnimatorFlyCircle.h" -#include "CSceneNodeAnimatorFlyStraight.h" -#include "CSceneNodeAnimatorTexture.h" -#include "CSceneNodeAnimatorCollisionResponse.h" -#include "CSceneNodeAnimatorDelete.h" -#include "CSceneNodeAnimatorFollowSpline.h" -#include "CSceneNodeAnimatorCameraFPS.h" -#include "CSceneNodeAnimatorCameraMaya.h" -#include "CDefaultSceneNodeAnimatorFactory.h" - -#include "CQuake3ShaderSceneNode.h" -#include "CVolumeLightSceneNode.h" -#include "CGeometryCreator.h" - -//! Enable debug features -#define SCENEMANAGER_DEBUG - -namespace irr -{ -namespace scene -{ - -//! constructor -CSceneManager::CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs, - gui::ICursorControl* cursorControl, IMeshCache* cache, - gui::IGUIEnvironment* gui) -: ISceneNode(0, 0), Driver(driver), FileSystem(fs), GUIEnvironment(gui), - CursorControl(cursorControl), CollisionManager(0), - ActiveCamera(0), ShadowColor(150,0,0,0), AmbientLight(0,0,0,0), - MeshCache(cache), CurrentRendertime(ESNRP_NONE), LightManager(0), - IRR_XML_FORMAT_SCENE(L"irr_scene"), IRR_XML_FORMAT_NODE(L"node"), IRR_XML_FORMAT_NODE_ATTR_TYPE(L"type") -{ - #ifdef _DEBUG - ISceneManager::setDebugName("CSceneManager ISceneManager"); - ISceneNode::setDebugName("CSceneManager ISceneNode"); - #endif - - // root node's scene manager - SceneManager = this; - - // set scene parameters - Parameters.setAttribute( DEBUG_NORMAL_LENGTH, 1.f ); - Parameters.setAttribute( DEBUG_NORMAL_COLOR, video::SColor(255, 34, 221, 221)); - - if (Driver) - Driver->grab(); - - if (FileSystem) - FileSystem->grab(); - - if (CursorControl) - CursorControl->grab(); - - if (GUIEnvironment) - GUIEnvironment->grab(); - - // create mesh cache if not there already - if (!MeshCache) - MeshCache = new CMeshCache(); - else - MeshCache->grab(); - - // create collision manager - CollisionManager = new CSceneCollisionManager(this, Driver); - - // create geometry creator - GeometryCreator = new CGeometryCreator(); - - // add file format loaders - - #ifdef _IRR_COMPILE_WITH_IRR_MESH_LOADER_ - MeshLoaderList.push_back(new CIrrMeshFileLoader(this, FileSystem)); - #endif - #ifdef _IRR_COMPILE_WITH_BSP_LOADER_ - MeshLoaderList.push_back(new CBSPMeshFileLoader(this, FileSystem)); - #endif - #ifdef _IRR_COMPILE_WITH_MD2_LOADER_ - MeshLoaderList.push_back(new CMD2MeshFileLoader()); - #endif - #ifdef _IRR_COMPILE_WITH_MS3D_LOADER_ - MeshLoaderList.push_back(new CMS3DMeshFileLoader(Driver)); - #endif - #ifdef _IRR_COMPILE_WITH_3DS_LOADER_ - MeshLoaderList.push_back(new C3DSMeshFileLoader(this, FileSystem)); - #endif - #ifdef _IRR_COMPILE_WITH_X_LOADER_ - MeshLoaderList.push_back(new CXMeshFileLoader(this, FileSystem)); - #endif - #ifdef _IRR_COMPILE_WITH_OCT_LOADER_ - MeshLoaderList.push_back(new COCTLoader(this, FileSystem)); - #endif - #ifdef _IRR_COMPILE_WITH_CSM_LOADER_ - MeshLoaderList.push_back(new CCSMLoader(this, FileSystem)); - #endif - #ifdef _IRR_COMPILE_WITH_LMTS_LOADER_ - MeshLoaderList.push_back(new CLMTSMeshFileLoader(FileSystem, Driver, &Parameters)); - #endif - #ifdef _IRR_COMPILE_WITH_MY3D_LOADER_ - MeshLoaderList.push_back(new CMY3DMeshFileLoader(this, FileSystem)); - #endif - #ifdef _IRR_COMPILE_WITH_COLLADA_LOADER_ - MeshLoaderList.push_back(new CColladaFileLoader(this, FileSystem)); - #endif - #ifdef _IRR_COMPILE_WITH_DMF_LOADER_ - MeshLoaderList.push_back(new CDMFLoader(this, FileSystem)); - #endif - #ifdef _IRR_COMPILE_WITH_OGRE_LOADER_ - MeshLoaderList.push_back(new COgreMeshFileLoader(FileSystem, Driver)); - #endif - #ifdef _IRR_COMPILE_WITH_OBJ_LOADER_ - MeshLoaderList.push_back(new COBJMeshFileLoader(this, FileSystem)); - #endif - #ifdef _IRR_COMPILE_WITH_MD3_LOADER_ - MeshLoaderList.push_back(new CMD3MeshFileLoader( this)); - #endif - #ifdef _IRR_COMPILE_WITH_B3D_LOADER_ - MeshLoaderList.push_back(new CB3DMeshFileLoader(this)); - #endif - #ifdef _IRR_COMPILE_WITH_LWO_LOADER_ - MeshLoaderList.push_back(new CLWOMeshFileLoader(this, FileSystem)); - #endif - #ifdef _IRR_COMPILE_WITH_STL_LOADER_ - MeshLoaderList.push_back(new CSTLMeshFileLoader()); - #endif - #ifdef _IRR_COMPILE_WITH_PLY_LOADER_ - MeshLoaderList.push_back(new CPLYMeshFileLoader()); - #endif - - // factories - ISceneNodeFactory* factory = new CDefaultSceneNodeFactory(this); - registerSceneNodeFactory(factory); - factory->drop(); - - ISceneNodeAnimatorFactory* animatorFactory = new CDefaultSceneNodeAnimatorFactory(this, CursorControl); - registerSceneNodeAnimatorFactory(animatorFactory); - animatorFactory->drop(); -} - - -//! destructor -CSceneManager::~CSceneManager() -{ - clearDeletionList(); - - if (FileSystem) - FileSystem->drop(); - - if (CursorControl) - CursorControl->drop(); - - if (CollisionManager) - CollisionManager->drop(); - - if (GeometryCreator) - GeometryCreator->drop(); - - if (GUIEnvironment) - GUIEnvironment->drop(); - - u32 i; - - for (i=0; i<MeshLoaderList.size(); ++i) - MeshLoaderList[i]->drop(); - - if (ActiveCamera) - ActiveCamera->drop(); - ActiveCamera = 0; - - if (MeshCache) - MeshCache->drop(); - - for (i=0; i<SceneNodeFactoryList.size(); ++i) - SceneNodeFactoryList[i]->drop(); - - for (i=0; i<SceneNodeAnimatorFactoryList.size(); ++i) - SceneNodeAnimatorFactoryList[i]->drop(); - - //! force to remove hardwareTextures from the driver - //! because Scenes may hold internally data bounded to sceneNodes - //! which may be destroyed twice - if (Driver) - Driver->removeAllHardwareBuffers (); - - if(LightManager) - LightManager->drop(); - - // remove all nodes and animators before dropping the driver - // as render targets may be destroyed twice - - removeAll(); - removeAnimators(); - - if (Driver) - Driver->drop(); -} - - -//! gets an animateable mesh. loads it if needed. returned pointer must not be dropped. -IAnimatedMesh* CSceneManager::getMesh(const io::path& filename) -{ - IAnimatedMesh* msh = MeshCache->getMeshByFilename(filename); - if (msh) - return msh; - - io::IReadFile* file = FileSystem->createAndOpenFile(filename); - if (!file) - { - os::Printer::log("Could not load mesh, because file could not be opened: ", filename, ELL_ERROR); - return 0; - } - - s32 count = MeshLoaderList.size(); - for (s32 i=count-1; i>=0; --i) - { - if (MeshLoaderList[i]->isALoadableFileExtension(filename)) - { - // reset file to avoid side effects of previous calls to createMesh - file->seek(0); - msh = MeshLoaderList[i]->createMesh(file); - if (msh) - { - MeshCache->addMesh(filename, msh); - msh->drop(); - break; - } - } - } - - file->drop(); - - if (!msh) - os::Printer::log("Could not load mesh, file format seems to be unsupported", filename, ELL_ERROR); - else - os::Printer::log("Loaded mesh", filename, ELL_INFORMATION); - - return msh; -} - - -//! gets an animateable mesh. loads it if needed. returned pointer must not be dropped. -IAnimatedMesh* CSceneManager::getMesh(io::IReadFile* file) -{ - if (!file) - return 0; - - io::path name = file->getFileName(); - IAnimatedMesh* msh = MeshCache->getMeshByFilename(file->getFileName()); - if (msh) - return msh; - - name.make_lower(); - s32 count = MeshLoaderList.size(); - for (s32 i=count-1; i>=0; --i) - { - if (MeshLoaderList[i]->isALoadableFileExtension(name)) - { - // reset file to avoid side effects of previous calls to createMesh - file->seek(0); - msh = MeshLoaderList[i]->createMesh(file); - if (msh) - { - MeshCache->addMesh(file->getFileName(), msh); - msh->drop(); - break; - } - } - } - - if (!msh) - os::Printer::log("Could not load mesh, file format seems to be unsupported", file->getFileName(), ELL_ERROR); - else - os::Printer::log("Loaded mesh", file->getFileName(), ELL_INFORMATION); - - return msh; -} - - -//! returns the video driver -video::IVideoDriver* CSceneManager::getVideoDriver() -{ - return Driver; -} - - -//! returns the GUI Environment -gui::IGUIEnvironment* CSceneManager::getGUIEnvironment() -{ - return GUIEnvironment; -} - -//! Get the active FileSystem -/** \return Pointer to the FileSystem -This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ -io::IFileSystem* CSceneManager::getFileSystem() -{ - return FileSystem; -} - - - -//! Adds a text scene node, which is able to display -//! 2d text at a position in three dimensional space -ITextSceneNode* CSceneManager::addTextSceneNode(gui::IGUIFont* font, - const wchar_t* text, video::SColor color, ISceneNode* parent, - const core::vector3df& position, s32 id) -{ - if (!font) - return 0; - - if (!parent) - parent = this; - - ITextSceneNode* t = new CTextSceneNode(parent, this, id, font, - getSceneCollisionManager(), position, text, color); - t->drop(); - - return t; -} - - -//! Adds a text scene node, which uses billboards -IBillboardTextSceneNode* CSceneManager::addBillboardTextSceneNode(gui::IGUIFont* font, - const wchar_t* text, ISceneNode* parent, - const core::dimension2d<f32>& size, - const core::vector3df& position, s32 id, - video::SColor colorTop, video::SColor colorBottom) -{ - if (!font && GUIEnvironment) - font = GUIEnvironment->getBuiltInFont(); - - if(!font) - return 0; - - if (!parent) - parent = this; - - IBillboardTextSceneNode* node = new CBillboardTextSceneNode(parent, this, id, font, text, position, size, - colorTop, colorBottom); - node->drop(); - - return node; - -} - - -//! Adds a scene node, which can render a quake3 shader -IMeshSceneNode* CSceneManager::addQuake3SceneNode(IMeshBuffer* meshBuffer, - const quake3::IShader * shader, - ISceneNode* parent, s32 id ) -{ -#ifdef _IRR_COMPILE_WITH_BSP_LOADER_ - if ( 0 == shader ) - return 0; - - if (!parent) - parent = this; - - CQuake3ShaderSceneNode* node = new CQuake3ShaderSceneNode( parent, - this, id, FileSystem, - meshBuffer, shader ); - node->drop(); - - return node; -#else - return 0; -#endif -} - - -//! adds Volume Lighting Scene Node. -//! the returned pointer must not be dropped. -IVolumeLightSceneNode* CSceneManager::addVolumeLightSceneNode( - ISceneNode* parent, s32 id, - const u32 subdivU, const u32 subdivV, - const video::SColor foot, const video::SColor tail, - const core::vector3df& position, const core::vector3df& rotation, const core::vector3df& scale) -{ - if (!parent) - parent = this; - - IVolumeLightSceneNode* node = new CVolumeLightSceneNode(parent, this, id, subdivU, subdivV, foot, tail, position, rotation, scale); - node->drop(); - - return node; -} - - -//! adds a test scene node for test purposes to the scene. It is a simple cube of (1,1,1) size. -//! the returned pointer must not be dropped. -IMeshSceneNode* CSceneManager::addCubeSceneNode(f32 size, ISceneNode* parent, - s32 id, const core::vector3df& position, - const core::vector3df& rotation, const core::vector3df& scale) -{ - if (!parent) - parent = this; - - IMeshSceneNode* node = new CCubeSceneNode(size, parent, this, id, position, rotation, scale); - node->drop(); - - return node; -} - - -//! Adds a sphere scene node for test purposes to the scene. -IMeshSceneNode* CSceneManager::addSphereSceneNode(f32 radius, s32 polyCount, - ISceneNode* parent, s32 id, const core::vector3df& position, - const core::vector3df& rotation, const core::vector3df& scale) -{ - if (!parent) - parent = this; - - IMeshSceneNode* node = new CSphereSceneNode(radius, polyCount, polyCount, parent, this, id, position, rotation, scale); - node->drop(); - - return node; -} - - -//! adds a scene node for rendering a static mesh -//! the returned pointer must not be dropped. -IMeshSceneNode* CSceneManager::addMeshSceneNode(IMesh* mesh, ISceneNode* parent, s32 id, - const core::vector3df& position, const core::vector3df& rotation, - const core::vector3df& scale, bool alsoAddIfMeshPointerZero) -{ - if (!alsoAddIfMeshPointerZero && !mesh) - return 0; - - if (!parent) - parent = this; - - IMeshSceneNode* node = new CMeshSceneNode(mesh, parent, this, id, position, rotation, scale); - node->drop(); - - return node; -} - - -//! Adds a scene node for rendering a animated water surface mesh. -ISceneNode* CSceneManager::addWaterSurfaceSceneNode(IMesh* mesh, f32 waveHeight, f32 waveSpeed, f32 waveLength, - ISceneNode* parent, s32 id, const core::vector3df& position, - const core::vector3df& rotation, const core::vector3df& scale) -{ - if (!mesh) - return 0; - - if (!parent) - parent = this; - - ISceneNode* node = new CWaterSurfaceSceneNode(waveHeight, waveSpeed, waveLength, - mesh, parent, this, id, position, rotation, scale); - - node->drop(); - - return node; -} - - -//! adds a scene node for rendering an animated mesh model -IAnimatedMeshSceneNode* CSceneManager::addAnimatedMeshSceneNode(IAnimatedMesh* mesh, ISceneNode* parent, s32 id, - const core::vector3df& position, const core::vector3df& rotation, - const core::vector3df& scale, bool alsoAddIfMeshPointerZero) -{ - if (!alsoAddIfMeshPointerZero && !mesh) - return 0; - - if (!parent) - parent = this; - - IAnimatedMeshSceneNode* node = - new CAnimatedMeshSceneNode(mesh, parent, this, id, position, rotation, scale); - node->drop(); - - return node; -} - - -//! Adds a scene node for rendering using a octtree to the scene graph. This a good method for rendering -//! scenes with lots of geometry. The Octree is built on the fly from the mesh, much -//! faster then a bsp tree. -IMeshSceneNode* CSceneManager::addOctTreeSceneNode(IAnimatedMesh* mesh, ISceneNode* parent, - s32 id, s32 minimalPolysPerNode, bool alsoAddIfMeshPointerZero) -{ - if (!alsoAddIfMeshPointerZero && (!mesh || !mesh->getFrameCount())) - return 0; - - return addOctTreeSceneNode(mesh ? mesh->getMesh(0) : 0, - parent, id, minimalPolysPerNode, - alsoAddIfMeshPointerZero); -} - - -//! Adds a scene node for rendering using a octtree. This a good method for rendering -//! scenes with lots of geometry. The Octree is built on the fly from the mesh, much -//! faster then a bsp tree. -IMeshSceneNode* CSceneManager::addOctTreeSceneNode(IMesh* mesh, ISceneNode* parent, - s32 id, s32 minimalPolysPerNode, bool alsoAddIfMeshPointerZero) -{ - if (!alsoAddIfMeshPointerZero && !mesh) - return 0; - - if (!parent) - parent = this; - - COctTreeSceneNode* node = new COctTreeSceneNode(parent, this, id, minimalPolysPerNode); - - if (node) - { - node->setMesh(mesh); - node->drop(); - } - - return node; -} - - -//! Adds a camera scene node to the tree and sets it as active camera. -//! \param position: Position of the space relative to its parent where the camera will be placed. -//! \param lookat: Position where the camera will look at. Also known as target. -//! \param parent: Parent scene node of the camera. Can be null. If the parent moves, -//! the camera will move too. -//! \return Returns pointer to interface to camera -ICameraSceneNode* CSceneManager::addCameraSceneNode(ISceneNode* parent, - const core::vector3df& position, const core::vector3df& lookat, s32 id) -{ - if (!parent) - parent = this; - - ICameraSceneNode* node = new CCameraSceneNode(parent, this, id, position, lookat); - node->drop(); - - setActiveCamera(node); - - return node; -} - - -//! Adds a camera scene node which is able to be controlld with the mouse similar -//! to in the 3D Software Maya by Alias Wavefront. -//! The returned pointer must not be dropped. -ICameraSceneNode* CSceneManager::addCameraSceneNodeMaya(ISceneNode* parent, - f32 rotateSpeed, f32 zoomSpeed, f32 translationSpeed, s32 id) -{ - if (!parent) - parent = this; - - ICameraSceneNode* node = new CCameraSceneNode(parent, this, id); - ISceneNodeAnimator* anm = new CSceneNodeAnimatorCameraMaya(CursorControl, - rotateSpeed, zoomSpeed, translationSpeed); - - node->addAnimator(anm); - setActiveCamera(node); - - anm->drop(); - node->drop(); - - return node; -} - - -//! Adds a camera scene node which is able to be controled with the mouse and keys -//! like in most first person shooters (FPS): -ICameraSceneNode* CSceneManager::addCameraSceneNodeFPS(ISceneNode* parent, - f32 rotateSpeed, f32 moveSpeed, s32 id, - SKeyMap* keyMapArray, s32 keyMapSize, bool noVerticalMovement, f32 jumpSpeed, bool invertMouseY) -{ - if (!parent) - parent = this; - - ICameraSceneNode* node = new CCameraSceneNode(parent, this, id); - ISceneNodeAnimator* anm = new CSceneNodeAnimatorCameraFPS(CursorControl, - rotateSpeed, moveSpeed, jumpSpeed, - keyMapArray, keyMapSize, noVerticalMovement, invertMouseY); - - // Bind the node's rotation to its target. This is consistent with 1.4.2 and below. - node->bindTargetAndRotation(true); - - node->addAnimator(anm); - setActiveCamera(node); - - anm->drop(); - node->drop(); - - return node; -} - - -//! Adds a dynamic light scene node. The light will cast dynamic light on all -//! other scene nodes in the scene, which have the material flag video::MTF_LIGHTING -//! turned on. (This is the default setting in most scene nodes). -ILightSceneNode* CSceneManager::addLightSceneNode(ISceneNode* parent, - const core::vector3df& position, video::SColorf color, f32 range, s32 id) -{ - if (!parent) - parent = this; - - ILightSceneNode* node = new CLightSceneNode(parent, this, id, position, color, range); - node->drop(); - - return node; -} - - -//! Adds a billboard scene node to the scene. A billboard is like a 3d sprite: A 2d element, -//! which always looks to the camera. It is usually used for things like explosions, fire, -//! lensflares and things like that. -IBillboardSceneNode* CSceneManager::addBillboardSceneNode(ISceneNode* parent, - const core::dimension2d<f32>& size, const core::vector3df& position, s32 id, - video::SColor colorTop, video::SColor colorBottom - ) -{ - if (!parent) - parent = this; - - IBillboardSceneNode* node = new CBillboardSceneNode(parent, this, id, position, size, - colorTop, colorBottom); - node->drop(); - - return node; -} - - -//! Adds a skybox scene node. A skybox is a big cube with 6 textures on it and -//! is drawn around the camera position. -ISceneNode* CSceneManager::addSkyBoxSceneNode(video::ITexture* top, video::ITexture* bottom, - video::ITexture* left, video::ITexture* right, video::ITexture* front, - video::ITexture* back, ISceneNode* parent, s32 id) -{ - if (!parent) - parent = this; - - ISceneNode* node = new CSkyBoxSceneNode(top, bottom, left, right, - front, back, parent, this, id); - - node->drop(); - return node; -} - - -//! Adds a skydome scene node. A skydome is a large (half-) sphere with a -//! panoramic texture on it and is drawn around the camera position. -ISceneNode* CSceneManager::addSkyDomeSceneNode(video::ITexture* texture, - u32 horiRes, u32 vertRes, f32 texturePercentage,f32 spherePercentage, f32 radius, - ISceneNode* parent, s32 id) -{ - if (!parent) - parent = this; - - ISceneNode* node = new CSkyDomeSceneNode(texture, horiRes, vertRes, - texturePercentage, spherePercentage, radius, parent, this, id); - - node->drop(); - return node; -} - - -//! Adds a particle system scene node. -IParticleSystemSceneNode* CSceneManager::addParticleSystemSceneNode( - bool withDefaultEmitter, ISceneNode* parent, s32 id, - const core::vector3df& position, const core::vector3df& rotation, - const core::vector3df& scale) -{ - if (!parent) - parent = this; - - IParticleSystemSceneNode* node = new CParticleSystemSceneNode(withDefaultEmitter, - parent, this, id, position, rotation, scale); - node->drop(); - - return node; -} - - -//! Adds a terrain scene node to the scene graph. -ITerrainSceneNode* CSceneManager::addTerrainSceneNode( - const io::path& heightMapFileName, - ISceneNode* parent, s32 id, - const core::vector3df& position, - const core::vector3df& rotation, - const core::vector3df& scale, - video::SColor vertexColor, - s32 maxLOD, E_TERRAIN_PATCH_SIZE patchSize, s32 smoothFactor, - bool addAlsoIfHeightmapEmpty) -{ - io::IReadFile* file = FileSystem->createAndOpenFile(heightMapFileName); - - if(!file && !addAlsoIfHeightmapEmpty) - { - os::Printer::log("Could not load terrain, because file could not be opened.", - heightMapFileName, ELL_ERROR); - return 0; - } - - ITerrainSceneNode* terrain = addTerrainSceneNode(file, parent, id, - position, rotation, scale, vertexColor, maxLOD, patchSize, - smoothFactor, addAlsoIfHeightmapEmpty); - - if (file) - file->drop(); - - return terrain; -} - -//! Adds a terrain scene node to the scene graph. -ITerrainSceneNode* CSceneManager::addTerrainSceneNode( - io::IReadFile* heightMapFile, - ISceneNode* parent, s32 id, - const core::vector3df& position, - const core::vector3df& rotation, - const core::vector3df& scale, - video::SColor vertexColor, - s32 maxLOD, E_TERRAIN_PATCH_SIZE patchSize, - s32 smoothFactor, - bool addAlsoIfHeightmapEmpty) -{ - if (!parent) - parent = this; - - if (!heightMapFile && !addAlsoIfHeightmapEmpty) - { - os::Printer::log("Could not load terrain, because file could not be opened.", ELL_ERROR); - return 0; - } - - CTerrainSceneNode* node = new CTerrainSceneNode(parent, this, FileSystem, id, - maxLOD, patchSize, position, rotation, scale); - - if (!node->loadHeightMap(heightMapFile, vertexColor, smoothFactor)) - { - if (!addAlsoIfHeightmapEmpty) - { - node->remove(); - node->drop(); - return 0; - } - } - - node->drop(); - return node; -} - - -//! Adds an empty scene node. -ISceneNode* CSceneManager::addEmptySceneNode(ISceneNode* parent, s32 id) -{ - if (!parent) - parent = this; - - ISceneNode* node = new CEmptySceneNode(parent, this, id); - node->drop(); - - return node; -} - - -//! Adds a dummy transformation scene node to the scene graph. -IDummyTransformationSceneNode* CSceneManager::addDummyTransformationSceneNode( - ISceneNode* parent, s32 id) -{ - if (!parent) - parent = this; - - IDummyTransformationSceneNode* node = new CDummyTransformationSceneNode( - parent, this, id); - node->drop(); - - return node; -} - -//! Adds a Hill Plane mesh to the mesh pool. The mesh is generated on the fly -//! and looks like a plane with some hills on it. You can specify how many hills -//! there should be on the plane and how high they should be. Also you must -//! specify a name for the mesh, because the mesh is added to the mesh pool, -//! and can be retrieved again using ISceneManager::getMesh with the name as -//! parameter. -IAnimatedMesh* CSceneManager::addHillPlaneMesh(const io::path& name, - const core::dimension2d<f32>& tileSize, - const core::dimension2d<u32>& tileCount, - video::SMaterial* material, f32 hillHeight, - const core::dimension2d<f32>& countHills, - const core::dimension2d<f32>& textureRepeatCount) -{ - if (MeshCache->isMeshLoaded(name)) - return MeshCache->getMeshByFilename(name); - - IMesh* mesh = GeometryCreator->createHillPlaneMesh(tileSize, - tileCount, material, hillHeight, countHills, - textureRepeatCount); - if (!mesh) - return 0; - - SAnimatedMesh* animatedMesh = new SAnimatedMesh(); - if (!animatedMesh) - { - mesh->drop(); - return 0; - } - - animatedMesh->addMesh(mesh); - mesh->drop(); - animatedMesh->recalculateBoundingBox(); - - MeshCache->addMesh(name, animatedMesh); - animatedMesh->drop(); - - return animatedMesh; -} - - -//! Adds a terrain mesh to the mesh pool. -IAnimatedMesh* CSceneManager::addTerrainMesh(const io::path& name, - video::IImage* texture, video::IImage* heightmap, - const core::dimension2d<f32>& stretchSize, - f32 maxHeight, - const core::dimension2d<u32>& defaultVertexBlockSize) -{ - if (MeshCache->isMeshLoaded(name)) - return MeshCache->getMeshByFilename(name); - - IMesh* mesh = GeometryCreator->createTerrainMesh(texture, heightmap, - stretchSize, maxHeight, getVideoDriver(), - defaultVertexBlockSize); - if (!mesh) - return 0; - - SAnimatedMesh* animatedMesh = new SAnimatedMesh(); - if (!animatedMesh) - { - mesh->drop(); - return 0; - } - - animatedMesh->addMesh(mesh); - mesh->drop(); - animatedMesh->recalculateBoundingBox(); - - MeshCache->addMesh(name, animatedMesh); - animatedMesh->drop(); - - return animatedMesh; -} - - -//! Adds an arrow mesh to the mesh pool. -IAnimatedMesh* CSceneManager::addArrowMesh(const io::path& name, - video::SColor vtxColor0, video::SColor vtxColor1, - u32 tesselationCylinder, u32 tesselationCone, f32 height, - f32 cylinderHeight, f32 width0,f32 width1) -{ - if (MeshCache->isMeshLoaded(name)) - return MeshCache->getMeshByFilename(name); - - IMesh* mesh = GeometryCreator->createArrowMesh( tesselationCylinder, - tesselationCone, height, cylinderHeight, width0,width1, - vtxColor0, vtxColor1); - if (!mesh) - return 0; - - SAnimatedMesh* animatedMesh = new SAnimatedMesh(); - if (!animatedMesh) - { - mesh->drop(); - return 0; - } - - animatedMesh->addMesh(mesh); - mesh->drop(); - animatedMesh->recalculateBoundingBox(); - - MeshCache->addMesh(name, animatedMesh); - animatedMesh->drop(); - - return animatedMesh; -} - - -//! Adds a static sphere mesh to the mesh pool. -IAnimatedMesh* CSceneManager::addSphereMesh(const io::path& name, - f32 radius, u32 polyCountX, u32 polyCountY) -{ - if (MeshCache->isMeshLoaded(name)) - return MeshCache->getMeshByFilename(name); - - IMesh* mesh = GeometryCreator->createSphereMesh(radius, polyCountX, polyCountY); - if (!mesh) - return 0; - - SAnimatedMesh* animatedMesh = new SAnimatedMesh(); - if (!animatedMesh) - { - mesh->drop(); - return 0; - } - - animatedMesh->addMesh(mesh); - mesh->drop(); - animatedMesh->recalculateBoundingBox(); - - MeshCache->addMesh(name, animatedMesh); - animatedMesh->drop(); - - return animatedMesh; -} - - - -//! Adds a static volume light mesh to the mesh pool. -IAnimatedMesh* CSceneManager::addVolumeLightMesh(const io::path& name, - const u32 SubdivideU, const u32 SubdivideV, - const video::SColor FootColor, const video::SColor TailColor) -{ - if (MeshCache->isMeshLoaded(name)) - return MeshCache->getMeshByFilename(name); - - IMesh* mesh = GeometryCreator->createVolumeLightMesh(SubdivideU, SubdivideV, FootColor, TailColor); - if (!mesh) - return 0; - - SAnimatedMesh* animatedMesh = new SAnimatedMesh(); - if (!animatedMesh) - { - mesh->drop(); - return 0; - } - - animatedMesh->addMesh(mesh); - mesh->drop(); - animatedMesh->recalculateBoundingBox(); - - MeshCache->addMesh(name, animatedMesh); - animatedMesh->drop(); - - return animatedMesh; -} - - -//! Returns the root scene node. This is the scene node wich is parent -//! of all scene nodes. The root scene node is a special scene node which -//! only exists to manage all scene nodes. It is not rendered and cannot -//! be removed from the scene. -//! \return Returns a pointer to the root scene node. -ISceneNode* CSceneManager::getRootSceneNode() -{ - return this; -} - - -//! Returns the current active camera. -//! \return The active camera is returned. Note that this can be NULL, if there -//! was no camera created yet. -ICameraSceneNode* CSceneManager::getActiveCamera() const -{ - return ActiveCamera; -} - - -//! Sets the active camera. The previous active camera will be deactivated. -//! \param camera: The new camera which should be active. -void CSceneManager::setActiveCamera(ICameraSceneNode* camera) -{ - if (camera) - camera->grab(); - if (ActiveCamera) - ActiveCamera->drop(); - - ActiveCamera = camera; -} - - -//! renders the node. -void CSceneManager::render() -{ -} - - -//! returns the axis aligned bounding box of this node -const core::aabbox3d<f32>& CSceneManager::getBoundingBox() const -{ - _IRR_DEBUG_BREAK_IF(true) // Bounding Box of Scene Manager wanted. - - // should never be used. - return *((core::aabbox3d<f32>*)0); -} - - -//! returns if node is culled -bool CSceneManager::isCulled(const ISceneNode* node) const -{ - const ICameraSceneNode* cam = getActiveCamera(); - if (!cam) - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; - } - - switch ( node->getAutomaticCulling() ) - { - // can be seen by a bounding box ? - case scene::EAC_BOX: - { - core::aabbox3d<f32> tbox = node->getBoundingBox(); - node->getAbsoluteTransformation().transformBoxEx(tbox); - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return !(tbox.intersectsWithBox(cam->getViewFrustum()->getBoundingBox() )); - } - - // can be seen by a bounding sphere - case scene::EAC_FRUSTUM_SPHERE: - { // requires bbox diameter - } - break; - - // can be seen by cam pyramid planes ? - case scene::EAC_FRUSTUM_BOX: - { - SViewFrustum frust = *cam->getViewFrustum(); - - //transform the frustum to the node's current absolute transformation - core::matrix4 invTrans(node->getAbsoluteTransformation(), core::matrix4::EM4CONST_INVERSE); - //invTrans.makeInverse(); - frust.transform(invTrans); - - core::vector3df edges[8]; - node->getBoundingBox().getEdges(edges); - - for (s32 i=0; i<scene::SViewFrustum::VF_PLANE_COUNT; ++i) - { - bool boxInFrustum=false; - for (u32 j=0; j<8; ++j) - { - if (frust.planes[i].classifyPointRelation(edges[j]) != core::ISREL3D_FRONT) - { - boxInFrustum=true; - break; - } - } - - if (!boxInFrustum) - return true; - } - } - break; - - case scene::EAC_OFF: - break; - } - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; -} - - -//! registers a node for rendering it at a specific time. -u32 CSceneManager::registerNodeForRendering(ISceneNode* node, E_SCENE_NODE_RENDER_PASS time) -{ - u32 taken = 0; - - switch(time) - { - // take camera if it is not already registered - case ESNRP_CAMERA: - { - taken = 1; - for ( u32 i = 0; i != CameraList.size(); ++i ) - { - if ( CameraList[i] == node ) - { - taken = 0; - break; - } - } - if ( taken ) - { - CameraList.push_back(node); - } - } - break; - - case ESNRP_LIGHT: - // TODO: Point Light culling.. - // Lighting model in irrlicht has to be redone.. - //if (!isCulled(node)) - { - LightList.push_back(static_cast<ILightSceneNode*>(node)); - taken = 1; - } - break; - - case ESNRP_SKY_BOX: - SkyBoxList.push_back(node); - taken = 1; - break; - case ESNRP_SOLID: - if (!isCulled(node)) - { - SolidNodeList.push_back(node); - taken = 1; - } - break; - case ESNRP_TRANSPARENT: - if (!isCulled(node)) - { - TransparentNodeList.push_back(TransparentNodeEntry(node, camWorldPos)); - taken = 1; - } - break; - case ESNRP_TRANSPARENT_EFFECT: - if (!isCulled(node)) - { - TransparentEffectNodeList.push_back(TransparentNodeEntry(node, camWorldPos)); - taken = 1; - } - break; - case ESNRP_AUTOMATIC: - if (!isCulled(node)) - { - u32 count = node->getMaterialCount(); - - taken = 0; - for (u32 i=0; i<count; ++i) - { - video::IMaterialRenderer* rnd = - Driver->getMaterialRenderer(node->getMaterial(i).MaterialType); - if (rnd && rnd->isTransparent()) - { - // register as transparent node - TransparentNodeEntry e(node, camWorldPos); - TransparentNodeList.push_back(e); - taken = 1; - break; - } - } - - // not transparent, register as solid - if ( 0 == taken ) - { - SolidNodeList.push_back(node); - taken = 1; - } - } - break; - case ESNRP_SHADOW: - if (!isCulled(node)) - { - ShadowNodeList.push_back(node); - taken = 1; - } - break; - - case ESNRP_NONE: // ignore this one - break; - } - -#ifdef SCENEMANAGER_DEBUG - s32 index = Parameters.findAttribute ( "calls" ); - Parameters.setAttribute ( index, Parameters.getAttributeAsInt ( index ) + 1 ); - - if ( 0 == taken ) - { - index = Parameters.findAttribute ( "culled" ); - Parameters.setAttribute ( index, Parameters.getAttributeAsInt ( index ) + 1 ); - } -#endif - - return taken; -} - - -//! This method is called just before the rendering process of the whole scene. -//! draws all scene nodes -void CSceneManager::drawAll() -{ - if (!Driver) - return; - - // reset attributes - Parameters.setAttribute ( "culled", 0 ); - Parameters.setAttribute ( "calls", 0 ); - Parameters.setAttribute ( "drawn_solid", 0 ); - Parameters.setAttribute ( "drawn_transparent", 0 ); - Parameters.setAttribute ( "drawn_transparent_effect", 0 ); - - // reset all transforms - video::IVideoDriver* driver = getVideoDriver(); - if ( driver ) - { - driver->setTransform ( video::ETS_PROJECTION, core::IdentityMatrix ); - driver->setTransform ( video::ETS_VIEW, core::IdentityMatrix ); - driver->setTransform ( video::ETS_WORLD, core::IdentityMatrix ); - driver->setTransform ( video::ETS_TEXTURE_0, core::IdentityMatrix ); - driver->setTransform ( video::ETS_TEXTURE_1, core::IdentityMatrix ); - driver->setTransform ( video::ETS_TEXTURE_2, core::IdentityMatrix ); - driver->setTransform ( video::ETS_TEXTURE_3, core::IdentityMatrix ); - } - - driver->setAllowZWriteOnTransparent(Parameters.getAttributeAsBool( ALLOW_ZWRITE_ON_TRANSPARENT) ); - - // do animations and other stuff. - OnAnimate(os::Timer::getTime()); - - /*! - First Scene Node for prerendering should be the active camera - consistent Camera is needed for culling - */ - camWorldPos.set(0,0,0); - if ( ActiveCamera ) - { - ActiveCamera->OnRegisterSceneNode(); - camWorldPos = ActiveCamera->getAbsolutePosition(); - } - - // let all nodes register themselves - OnRegisterSceneNode(); - - if(LightManager) - LightManager->OnPreRender(LightList); - - u32 i; // new ISO for scoping problem in some compilers - - //render camera scenes - { - CurrentRendertime = ESNRP_CAMERA; - Driver->getOverrideMaterial().Enabled = ((Driver->getOverrideMaterial().EnablePasses & CurrentRendertime) != 0); - - if(LightManager) - LightManager->OnRenderPassPreRender(CurrentRendertime); - - for (i=0; i<CameraList.size(); ++i) - CameraList[i]->render(); - - CameraList.set_used(0); - - if(LightManager) - LightManager->OnRenderPassPostRender(CurrentRendertime); - } - - //render lights scenes - { - CurrentRendertime = ESNRP_LIGHT; - Driver->getOverrideMaterial().Enabled = ((Driver->getOverrideMaterial().EnablePasses & CurrentRendertime) != 0); - - if(LightManager) - { - LightManager->OnRenderPassPreRender(CurrentRendertime); - } - else - { - // Sort the lights by distance from the camera - core::vector3df camWorldPos(0, 0, 0); - if(ActiveCamera) - camWorldPos = ActiveCamera->getAbsolutePosition(); - - core::array<DistanceNodeEntry> SortedLights; - SortedLights.set_used(LightList.size()); - for(s32 light = (s32)LightList.size() - 1; light >= 0; --light) - SortedLights[light].setNodeAndDistanceFromPosition(LightList[light], camWorldPos); - - SortedLights.set_sorted(false); - SortedLights.sort(); - - for(s32 light = (s32)LightList.size() - 1; light >= 0; --light) - LightList[light] = static_cast<ILightSceneNode*>(SortedLights[light].Node); - } - - Driver->deleteAllDynamicLights(); - - Driver->setAmbientLight(AmbientLight); - - u32 maxLights = LightList.size(); - - if(!LightManager) - maxLights = core::min_ ( Driver->getMaximalDynamicLightAmount(), maxLights); - - for (i=0; i< maxLights; ++i) - LightList[i]->render(); - - if(LightManager) - LightManager->OnRenderPassPostRender(CurrentRendertime); - } - - // render skyboxes - { - CurrentRendertime = ESNRP_SKY_BOX; - Driver->getOverrideMaterial().Enabled = ((Driver->getOverrideMaterial().EnablePasses & CurrentRendertime) != 0); - - if(LightManager) - { - LightManager->OnRenderPassPreRender(CurrentRendertime); - for (i=0; i<SkyBoxList.size(); ++i) - { - ISceneNode* node = SkyBoxList[i]; - LightManager->OnNodePreRender(node); - node->render(); - LightManager->OnNodePostRender(node); - } - } - else - { - for (i=0; i<SkyBoxList.size(); ++i) - SkyBoxList[i]->render(); - } - - SkyBoxList.set_used(0); - - if(LightManager) - LightManager->OnRenderPassPostRender(CurrentRendertime); - } - - - // render default objects - { - CurrentRendertime = ESNRP_SOLID; - Driver->getOverrideMaterial().Enabled = ((Driver->getOverrideMaterial().EnablePasses & CurrentRendertime) != 0); - - SolidNodeList.sort(); // sort by textures - - if(LightManager) - { - LightManager->OnRenderPassPreRender(CurrentRendertime); - for (i=0; i<SolidNodeList.size(); ++i) - { - ISceneNode* node = SolidNodeList[i].Node; - LightManager->OnNodePreRender(node); - node->render(); - LightManager->OnNodePostRender(node); - } - } - else - { - for (i=0; i<SolidNodeList.size(); ++i) - SolidNodeList[i].Node->render(); - } - - Parameters.setAttribute ( "drawn_solid", (s32) SolidNodeList.size() ); - SolidNodeList.set_used(0); - - if(LightManager) - LightManager->OnRenderPassPostRender(CurrentRendertime); - } - - // render shadows - { - CurrentRendertime = ESNRP_SHADOW; - Driver->getOverrideMaterial().Enabled = ((Driver->getOverrideMaterial().EnablePasses & CurrentRendertime) != 0); - - if(LightManager) - { - LightManager->OnRenderPassPreRender(CurrentRendertime); - for (i=0; i<ShadowNodeList.size(); ++i) - { - ISceneNode* node = ShadowNodeList[i]; - LightManager->OnNodePreRender(node); - node->render(); - LightManager->OnNodePostRender(node); - } - } - else - { - for (i=0; i<ShadowNodeList.size(); ++i) - ShadowNodeList[i]->render(); - } - - if (!ShadowNodeList.empty()) - Driver->drawStencilShadow(true,ShadowColor, ShadowColor, - ShadowColor, ShadowColor); - - ShadowNodeList.set_used(0); - - if(LightManager) - LightManager->OnRenderPassPostRender(CurrentRendertime); - } - - // render transparent objects. - { - CurrentRendertime = ESNRP_TRANSPARENT; - Driver->getOverrideMaterial().Enabled = ((Driver->getOverrideMaterial().EnablePasses & CurrentRendertime) != 0); - - TransparentNodeList.sort(); // sort by distance from camera - if(LightManager) - { - LightManager->OnRenderPassPreRender(CurrentRendertime); - - for (i=0; i<TransparentNodeList.size(); ++i) - { - ISceneNode* node = TransparentNodeList[i].Node; - LightManager->OnNodePreRender(node); - node->render(); - LightManager->OnNodePostRender(node); - } - } - else - { - for (i=0; i<TransparentNodeList.size(); ++i) - TransparentNodeList[i].Node->render(); - } - - Parameters.setAttribute ( "drawn_transparent", (s32) TransparentNodeList.size() ); - TransparentNodeList.set_used(0); - - if(LightManager) - LightManager->OnRenderPassPostRender(CurrentRendertime); - } - - // render transparent effect objects. - { - CurrentRendertime = ESNRP_TRANSPARENT_EFFECT; - Driver->getOverrideMaterial().Enabled = ((Driver->getOverrideMaterial().EnablePasses & CurrentRendertime) != 0); - - TransparentEffectNodeList.sort(); // sort by distance from camera - - if(LightManager) - { - LightManager->OnRenderPassPreRender(CurrentRendertime); - - for (i=0; i<TransparentEffectNodeList.size(); ++i) - { - ISceneNode* node = TransparentEffectNodeList[i].Node; - LightManager->OnNodePreRender(node); - node->render(); - LightManager->OnNodePostRender(node); - } - } - else - { - for (i=0; i<TransparentEffectNodeList.size(); ++i) - TransparentEffectNodeList[i].Node->render(); - } - - Parameters.setAttribute ( "drawn_transparent_effect", (s32) TransparentEffectNodeList.size() ); - TransparentEffectNodeList.set_used(0); - } - - if(LightManager) - LightManager->OnPostRender(); - - LightList.set_used(0); - clearDeletionList(); - - CurrentRendertime = ESNRP_NONE; -} - -void CSceneManager::setLightManager(ILightManager* lightManager) -{ - if ( lightManager ) - lightManager->grab(); - if(LightManager) - LightManager->drop(); - - LightManager = lightManager; -} - - -//! Sets the color of stencil buffers shadows drawn by the scene manager. -void CSceneManager::setShadowColor(video::SColor color) -{ - ShadowColor = color; -} - - -//! Returns the current color of shadows. -video::SColor CSceneManager::getShadowColor() const -{ - return ShadowColor; -} - - - -//! creates a rotation animator, which rotates the attached scene node around itself. -ISceneNodeAnimator* CSceneManager::createRotationAnimator(const core::vector3df& rotationPerSecond) -{ - ISceneNodeAnimator* anim = new CSceneNodeAnimatorRotation(os::Timer::getTime(), - rotationPerSecond); - - return anim; -} - - - -//! creates a fly circle animator, which lets the attached scene node fly around a center. -ISceneNodeAnimator* CSceneManager::createFlyCircleAnimator( - const core::vector3df& center, f32 radius, f32 speed, - const core::vector3df& direction, - f32 startPosition, - f32 radiusEllipsoid) -{ - const f32 orbitDurationMs = (core::DEGTORAD * 360.f) / speed; - const u32 effectiveTime = os::Timer::getTime() + (u32)(orbitDurationMs * startPosition); - - ISceneNodeAnimator* anim = new CSceneNodeAnimatorFlyCircle( - effectiveTime, center, - radius, speed, direction,radiusEllipsoid); - return anim; -} - - -//! Creates a fly straight animator, which lets the attached scene node -//! fly or move along a line between two points. -ISceneNodeAnimator* CSceneManager::createFlyStraightAnimator(const core::vector3df& startPoint, - const core::vector3df& endPoint, u32 timeForWay, bool loop,bool pingpong) -{ - ISceneNodeAnimator* anim = new CSceneNodeAnimatorFlyStraight(startPoint, - endPoint, timeForWay, loop, os::Timer::getTime(), pingpong); - - return anim; -} - - -//! Creates a texture animator, which switches the textures of the target scene -//! node based on a list of textures. -ISceneNodeAnimator* CSceneManager::createTextureAnimator(const core::array<video::ITexture*>& textures, - s32 timePerFrame, bool loop) -{ - ISceneNodeAnimator* anim = new CSceneNodeAnimatorTexture(textures, - timePerFrame, loop, os::Timer::getTime()); - - return anim; -} - - -//! Creates a scene node animator, which deletes the scene node after -//! some time automaticly. -ISceneNodeAnimator* CSceneManager::createDeleteAnimator(u32 when) -{ - return new CSceneNodeAnimatorDelete(this, os::Timer::getTime() + when); -} - - - - -//! Creates a special scene node animator for doing automatic collision detection -//! and response. -ISceneNodeAnimatorCollisionResponse* CSceneManager::createCollisionResponseAnimator( - ITriangleSelector* world, ISceneNode* sceneNode, const core::vector3df& ellipsoidRadius, - const core::vector3df& gravityPerSecond, - const core::vector3df& ellipsoidTranslation, f32 slidingValue) -{ - ISceneNodeAnimatorCollisionResponse* anim = new - CSceneNodeAnimatorCollisionResponse(this, world, sceneNode, - ellipsoidRadius, gravityPerSecond, - ellipsoidTranslation, slidingValue); - - return anim; -} - - -//! Creates a follow spline animator. -ISceneNodeAnimator* CSceneManager::createFollowSplineAnimator(s32 startTime, - const core::array< core::vector3df >& points, - f32 speed, f32 tightness) -{ - ISceneNodeAnimator* a = new CSceneNodeAnimatorFollowSpline(startTime, points, - speed, tightness); - return a; -} - - - -//! Adds an external mesh loader. -void CSceneManager::addExternalMeshLoader(IMeshLoader* externalLoader) -{ - if (!externalLoader) - return; - - externalLoader->grab(); - MeshLoaderList.push_back(externalLoader); -} - - -//! Returns a pointer to the scene collision manager. -ISceneCollisionManager* CSceneManager::getSceneCollisionManager() -{ - return CollisionManager; -} - - -//! Returns a pointer to the mesh manipulator. -IMeshManipulator* CSceneManager::getMeshManipulator() -{ - return Driver->getMeshManipulator(); -} - - -//! Creates a simple ITriangleSelector, based on a mesh. -ITriangleSelector* CSceneManager::createTriangleSelector(IMesh* mesh, ISceneNode* node) -{ - if (!mesh) - return 0; - - return new CTriangleSelector(mesh, node); -} - - -//! Creates a simple and updatable ITriangleSelector, based on a the mesh owned by an -//! animated scene node -ITriangleSelector* CSceneManager::createTriangleSelector(IAnimatedMeshSceneNode* node) -{ - if(!node || !node->getMesh()) - return 0; - - return new CTriangleSelector(node); -} - -//! Creates a simple dynamic ITriangleSelector, based on a axis aligned bounding box. -ITriangleSelector* CSceneManager::createTriangleSelectorFromBoundingBox(ISceneNode* node) -{ - if (!node) - return 0; - - return new CTriangleBBSelector(node); -} - - -//! Creates a simple ITriangleSelector, based on a mesh. -ITriangleSelector* CSceneManager::createOctTreeTriangleSelector(IMesh* mesh, - ISceneNode* node, - s32 minimalPolysPerNode) -{ - if (!mesh) - return 0; - - return new COctTreeTriangleSelector(mesh, node, minimalPolysPerNode); -} - - - -//! Creates a meta triangle selector. -IMetaTriangleSelector* CSceneManager::createMetaTriangleSelector() -{ - return new CMetaTriangleSelector(); -} - - - -//! Creates a triangle selector which can select triangles from a terrain scene node -ITriangleSelector* CSceneManager::createTerrainTriangleSelector( - ITerrainSceneNode* node, s32 LOD) -{ - return new CTerrainTriangleSelector(node, LOD); -} - - - -//! Adds a scene node to the deletion queue. -void CSceneManager::addToDeletionQueue(ISceneNode* node) -{ - if (!node) - return; - - node->grab(); - DeletionList.push_back(node); -} - - -//! clears the deletion list -void CSceneManager::clearDeletionList() -{ - if (DeletionList.empty()) - return; - - for (u32 i=0; i<DeletionList.size(); ++i) - { - DeletionList[i]->remove(); - DeletionList[i]->drop(); - } - - DeletionList.clear(); -} - - -//! Returns the first scene node with the specified name. -ISceneNode* CSceneManager::getSceneNodeFromName(const char* name, ISceneNode* start) -{ - if (start == 0) - start = getRootSceneNode(); - - if (!strcmp(start->getName(),name)) - return start; - - ISceneNode* node = 0; - - const core::list<ISceneNode*>& list = start->getChildren(); - core::list<ISceneNode*>::ConstIterator it = list.begin(); - for (; it!=list.end(); ++it) - { - node = getSceneNodeFromName(name, *it); - if (node) - return node; - } - - return 0; -} - - -//! Returns the first scene node with the specified id. -ISceneNode* CSceneManager::getSceneNodeFromId(s32 id, ISceneNode* start) -{ - if (start == 0) - start = getRootSceneNode(); - - if (start->getID() == id) - return start; - - ISceneNode* node = 0; - - const core::list<ISceneNode*>& list = start->getChildren(); - core::list<ISceneNode*>::ConstIterator it = list.begin(); - for (; it!=list.end(); ++it) - { - node = getSceneNodeFromId(id, *it); - if (node) - return node; - } - - return 0; -} - - -//! Returns the first scene node with the specified type. -ISceneNode* CSceneManager::getSceneNodeFromType(scene::ESCENE_NODE_TYPE type, ISceneNode* start) -{ - if (start == 0) - start = getRootSceneNode(); - - if (start->getType() == type || ESNT_ANY == type) - return start; - - ISceneNode* node = 0; - - const core::list<ISceneNode*>& list = start->getChildren(); - core::list<ISceneNode*>::ConstIterator it = list.begin(); - for (; it!=list.end(); ++it) - { - node = getSceneNodeFromType(type, *it); - if (node) - return node; - } - - return 0; -} - -//! returns scene nodes by type. -void CSceneManager::getSceneNodesFromType(ESCENE_NODE_TYPE type, core::array<scene::ISceneNode*>& outNodes, ISceneNode* start) -{ - if (start == 0) - start = getRootSceneNode(); - - if (start->getType() == type || ESNT_ANY == type) - outNodes.push_back(start); - - const core::list<ISceneNode*>& list = start->getChildren(); - core::list<ISceneNode*>::ConstIterator it = list.begin(); - - for (; it!=list.end(); ++it) - { - getSceneNodesFromType(type, outNodes, *it); - } -} - - -//! Posts an input event to the environment. Usually you do not have to -//! use this method, it is used by the internal engine. -bool CSceneManager::postEventFromUser(const SEvent& event) -{ - bool ret = false; - ICameraSceneNode* cam = getActiveCamera(); - if (cam) - ret = cam->OnEvent(event); - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return ret; -} - - -//! Removes all children of this scene node -void CSceneManager::removeAll() -{ - ISceneNode::removeAll(); - setActiveCamera(0); -} - - -//! Clears the whole scene. All scene nodes are removed. -void CSceneManager::clear() -{ - removeAll(); -} - - -//! Returns interface to the parameters set in this scene. -io::IAttributes* CSceneManager::getParameters() -{ - return &Parameters; -} - - -//! Returns current render pass. -E_SCENE_NODE_RENDER_PASS CSceneManager::getSceneNodeRenderPass() const -{ - return CurrentRendertime; -} - - - -//! Returns an interface to the mesh cache which is shared beween all existing scene managers. -IMeshCache* CSceneManager::getMeshCache() -{ - return MeshCache; -} - - -//! Creates a new scene manager. -ISceneManager* CSceneManager::createNewSceneManager(bool cloneContent) -{ - CSceneManager* manager = new CSceneManager(Driver, FileSystem, CursorControl, MeshCache, GUIEnvironment); - - if (cloneContent) - manager->cloneMembers(this, manager); - - return manager; -} - - -//! Returns the default scene node factory which can create all built in scene nodes -ISceneNodeFactory* CSceneManager::getDefaultSceneNodeFactory() -{ - return getSceneNodeFactory(0); -} - - -//! Adds a scene node factory to the scene manager. -void CSceneManager::registerSceneNodeFactory(ISceneNodeFactory* factoryToAdd) -{ - if (factoryToAdd) - { - factoryToAdd->grab(); - SceneNodeFactoryList.push_back(factoryToAdd); - } -} - - -//! Returns amount of registered scene node factories. -u32 CSceneManager::getRegisteredSceneNodeFactoryCount() const -{ - return SceneNodeFactoryList.size(); -} - - -//! Returns a scene node factory by index -ISceneNodeFactory* CSceneManager::getSceneNodeFactory(u32 index) -{ - if (index<SceneNodeFactoryList.size()) - return SceneNodeFactoryList[index]; - - return 0; -} - - -//! Returns the default scene node animator factory which can create all built-in scene node animators -ISceneNodeAnimatorFactory* CSceneManager::getDefaultSceneNodeAnimatorFactory() -{ - return getSceneNodeAnimatorFactory(0); -} - -//! Adds a scene node animator factory to the scene manager. -void CSceneManager::registerSceneNodeAnimatorFactory(ISceneNodeAnimatorFactory* factoryToAdd) -{ - if (factoryToAdd) - { - factoryToAdd->grab(); - SceneNodeAnimatorFactoryList.push_back(factoryToAdd); - } -} - - -//! Returns amount of registered scene node animator factories. -u32 CSceneManager::getRegisteredSceneNodeAnimatorFactoryCount() const -{ - return SceneNodeAnimatorFactoryList.size(); -} - - -//! Returns a scene node animator factory by index -ISceneNodeAnimatorFactory* CSceneManager::getSceneNodeAnimatorFactory(u32 index) -{ - if (index<SceneNodeAnimatorFactoryList.size()) - return SceneNodeAnimatorFactoryList[index]; - - return 0; -} - - -//! Saves the current scene into a file. -//! \param filename: Name of the file . -bool CSceneManager::saveScene(const io::path& filename, ISceneUserDataSerializer* userDataSerializer) -{ - bool ret = false; - io::IWriteFile* file = FileSystem->createAndWriteFile(filename); - if (file) - { - ret = saveScene(file, userDataSerializer); - file->drop(); - } - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return ret; -} - - -//! Saves the current scene into a file. -bool CSceneManager::saveScene(io::IWriteFile* file, ISceneUserDataSerializer* userDataSerializer) -{ - if (!file) - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; - } - - io::IXMLWriter* writer = FileSystem->createXMLWriter(file); - if (!writer) - { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; - } - - writer->writeXMLHeader(); - writeSceneNode(writer, this, userDataSerializer); - writer->drop(); - - return true; -} - - -//! Loads a scene. Note that the current scene is not cleared before. -//! \param filename: Name of the file . -bool CSceneManager::loadScene(const io::path& filename, ISceneUserDataSerializer* userDataSerializer) -{ - bool ret = false; - io::IReadFile* read = FileSystem->createAndOpenFile(filename); - if (!read) - { - os::Printer::log("Unable to open scene file", filename, ELL_ERROR); - } - else - { - ret = loadScene(read, userDataSerializer); - read->drop(); - } - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return ret; -} - - -//! Loads a scene. Note that the current scene is not cleared before. -bool CSceneManager::loadScene(io::IReadFile* file, ISceneUserDataSerializer* userDataSerializer) -{ - if (!file) - { - os::Printer::log("Unable to open scene file", ELL_ERROR); - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; - } - - io::IXMLReader* reader = FileSystem->createXMLReader(file); - if (!reader) - { - os::Printer::log("Scene is not a valid XML file", file->getFileName(), ELL_ERROR); - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; - } - - // for mesh loading, set collada loading attributes - - bool oldColladaSingleMesh = getParameters()->getAttributeAsBool(COLLADA_CREATE_SCENE_INSTANCES); - getParameters()->setAttribute(COLLADA_CREATE_SCENE_INSTANCES, false); - - // read file - - while(reader->read()) - { - readSceneNode(reader, 0, userDataSerializer); - } - - // restore old collada parameters - - getParameters()->setAttribute(COLLADA_CREATE_SCENE_INSTANCES, oldColladaSingleMesh); - - // finish up - - reader->drop(); - return true; -} - - -//! reads a scene node -void CSceneManager::readSceneNode(io::IXMLReader* reader, ISceneNode* parent, ISceneUserDataSerializer* userDataSerializer) -{ - if (!reader) - return; - - scene::ISceneNode* node = 0; - - if (!parent && IRR_XML_FORMAT_SCENE==reader->getNodeName()) - node = this; // root - else if (parent && IRR_XML_FORMAT_NODE==reader->getNodeName()) - { - // find node type and create it - core::stringc attrName = reader->getAttributeValue(IRR_XML_FORMAT_NODE_ATTR_TYPE.c_str()); - - for (s32 i=(s32)SceneNodeFactoryList.size()-1; i>=0 && !node; --i) - node = SceneNodeFactoryList[i]->addSceneNode(attrName.c_str(), parent); - - if (!node) - os::Printer::log("Could not create scene node of unknown type", attrName.c_str()); - } - - // read attributes - while(reader->read()) - { - bool endreached = false; - - switch (reader->getNodeType()) - { - case io::EXN_ELEMENT_END: - if ((IRR_XML_FORMAT_NODE==reader->getNodeName()) || - (IRR_XML_FORMAT_SCENE==reader->getNodeName())) - { - endreached = true; - } - break; - case io::EXN_ELEMENT: - if (core::stringw(L"attributes")==reader->getNodeName()) - { - // read attributes - io::IAttributes* attr = FileSystem->createEmptyAttributes(Driver); - attr->read(reader, true); - - if (node) - node->deserializeAttributes(attr); - - attr->drop(); - } - else - if (core::stringw(L"materials")==reader->getNodeName()) - readMaterials(reader, node); - else - if (core::stringw(L"animators")==reader->getNodeName()) - readAnimators(reader, node); - else - if (core::stringw(L"userData")==reader->getNodeName()) - readUserData(reader, node, userDataSerializer); - else - if ((IRR_XML_FORMAT_NODE==reader->getNodeName()) || - (IRR_XML_FORMAT_SCENE==reader->getNodeName())) - { - readSceneNode(reader, node, userDataSerializer); - } - else - { - os::Printer::log("Found unknown element in irrlicht scene file", - core::stringc(reader->getNodeName()).c_str()); - } - break; - default: - break; - } - - if (endreached) - break; - } - if ( node && userDataSerializer ) - userDataSerializer->OnCreateNode(node); -} - - -//! reads materials of a node -void CSceneManager::readMaterials(io::IXMLReader* reader, ISceneNode* node) -{ - u32 nr = 0; - - while(reader->read()) - { - const wchar_t* name = reader->getNodeName(); - - switch(reader->getNodeType()) - { - case io::EXN_ELEMENT_END: - if (core::stringw(L"materials")==name) - return; - break; - case io::EXN_ELEMENT: - if (core::stringw(L"attributes")==name) - { - // read materials from attribute list - io::IAttributes* attr = FileSystem->createEmptyAttributes(Driver); - attr->read(reader); - - if (node && node->getMaterialCount() > nr) - { - getVideoDriver()->fillMaterialStructureFromAttributes( - node->getMaterial(nr), attr); - } - - attr->drop(); - ++nr; - } - break; - default: - break; - } - } -} - - -//! reads animators of a node -void CSceneManager::readAnimators(io::IXMLReader* reader, ISceneNode* node) -{ - while(reader->read()) - { - const wchar_t* name = reader->getNodeName(); - - switch(reader->getNodeType()) - { - case io::EXN_ELEMENT_END: - if (core::stringw(L"animators")==name) - return; - break; - case io::EXN_ELEMENT: - if (core::stringw(L"attributes")==name) - { - // read animator data from attribute list - io::IAttributes* attr = FileSystem->createEmptyAttributes(Driver); - attr->read(reader); - - if (node) - { - core::stringc typeName = attr->getAttributeAsString("Type"); - ISceneNodeAnimator* anim = 0; - - for (int i=0; i<(int)SceneNodeAnimatorFactoryList.size() && !anim; ++i) - anim = SceneNodeAnimatorFactoryList[i]->createSceneNodeAnimator(typeName.c_str(), node); - - if (anim) - { - anim->deserializeAttributes(attr); - anim->drop(); - } - } - - attr->drop(); - } - break; - default: - break; - } - } -} - - -//! reads user data of a node -void CSceneManager::readUserData(io::IXMLReader* reader, ISceneNode* node, ISceneUserDataSerializer* userDataSerializer) -{ - while(reader->read()) - { - const wchar_t* name = reader->getNodeName(); - - switch(reader->getNodeType()) - { - case io::EXN_ELEMENT_END: - if (core::stringw(L"userData")==name) - return; - break; - case io::EXN_ELEMENT: - if (core::stringw(L"attributes")==name) - { - // read user data from attribute list - io::IAttributes* attr = FileSystem->createEmptyAttributes(Driver); - attr->read(reader); - - if (node && userDataSerializer) - { - userDataSerializer->OnReadUserData(node, attr); - } - - attr->drop(); - } - break; - default: - break; - } - } -} - - -//! writes a scene node -void CSceneManager::writeSceneNode(io::IXMLWriter* writer, ISceneNode* node, ISceneUserDataSerializer* userDataSerializer) -{ - if (!writer || !node || node->isDebugObject()) - return; - - const wchar_t* name; - - if (node == this) - { - name = IRR_XML_FORMAT_SCENE.c_str(); - writer->writeElement(name, false); - } - else - { - name = IRR_XML_FORMAT_NODE.c_str(); - writer->writeElement(name, false, IRR_XML_FORMAT_NODE_ATTR_TYPE.c_str(), - core::stringw(getSceneNodeTypeName(node->getType())).c_str()); - } - - writer->writeLineBreak(); - writer->writeLineBreak(); - - // write properties - - io::IAttributes* attr = FileSystem->createEmptyAttributes(Driver); - node->serializeAttributes(attr); - - if (attr->getAttributeCount() != 0) - { - attr->write(writer); - writer->writeLineBreak(); - } - - // write materials - - if (node->getMaterialCount() && getVideoDriver()) - { - const wchar_t* materialElement = L"materials"; - - writer->writeElement(materialElement); - writer->writeLineBreak(); - - for (u32 i=0; i < node->getMaterialCount(); ++i) - { - io::IAttributes* tmp_attr = - getVideoDriver()->createAttributesFromMaterial(node->getMaterial(i)); - tmp_attr->write(writer); - tmp_attr->drop(); - } - - writer->writeClosingTag(materialElement); - writer->writeLineBreak(); - } - - // write animators - - if (!node->getAnimators().empty()) - { - const wchar_t* animatorElement = L"animators"; - writer->writeElement(animatorElement); - writer->writeLineBreak(); - - core::list<ISceneNodeAnimator*>::ConstIterator it = node->getAnimators().begin(); - for (; it != node->getAnimators().end(); ++it) - { - attr->clear(); - attr->addString("Type", getAnimatorTypeName((*it)->getType())); - - (*it)->serializeAttributes(attr); - - attr->write(writer); - } - - writer->writeClosingTag(animatorElement); - writer->writeLineBreak(); - } - - // write possible user data - - if ( userDataSerializer ) - { - io::IAttributes* userData = userDataSerializer->createUserData(node); - if (userData) - { - const wchar_t* userDataElement = L"userData"; - - writer->writeLineBreak(); - writer->writeElement(userDataElement); - writer->writeLineBreak(); - - userData->write(writer); - - writer->writeClosingTag(userDataElement); - writer->writeLineBreak(); - writer->writeLineBreak(); - - userData->drop(); - } - } - - // write children - - core::list<ISceneNode*>::ConstIterator it = node->getChildren().begin(); - for (; it != node->getChildren().end(); ++it) - writeSceneNode(writer, (*it), userDataSerializer); - - attr->drop(); - - writer->writeClosingTag(name); - writer->writeLineBreak(); - writer->writeLineBreak(); -} - - -//! Returns a typename from a scene node type or null if not found -const c8* CSceneManager::getSceneNodeTypeName(ESCENE_NODE_TYPE type) -{ - const char* name = 0; - - for (int i=(int)SceneNodeFactoryList.size()-1; !name && i>=0; --i) - name = SceneNodeFactoryList[i]->getCreateableSceneNodeTypeName(type); - - return name; -} - -//! Adds a scene node to the scene by name -ISceneNode* CSceneManager::addSceneNode(const char* sceneNodeTypeName, ISceneNode* parent) -{ - ISceneNode* node = 0; - - for (int i=(int)SceneNodeFactoryList.size()-1; i>=0 && !node; --i) - node = SceneNodeFactoryList[i]->addSceneNode(sceneNodeTypeName, parent); - - return node; -} - - -//! Returns a typename from a scene node animator type or null if not found -const c8* CSceneManager::getAnimatorTypeName(ESCENE_NODE_ANIMATOR_TYPE type) -{ - const char* name = 0; - - for (u32 i=0; !name && i<SceneNodeAnimatorFactoryList.size(); ++i) - name = SceneNodeAnimatorFactoryList[i]->getCreateableSceneNodeAnimatorTypeName(type); - - return name; -} - - -//! Writes attributes of the scene node. -void CSceneManager::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const -{ - out->addString ("Name", Name.c_str()); - out->addInt ("Id", ID ); - out->addColorf ("AmbientLight", AmbientLight); -} - -//! Reads attributes of the scene node. -void CSceneManager::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - Name = in->getAttributeAsString("Name"); - ID = in->getAttributeAsInt("Id"); - AmbientLight = in->getAttributeAsColorf("AmbientLight"); - - RelativeTranslation.set(0,0,0); - RelativeRotation.set(0,0,0); - RelativeScale.set(1,1,1); - IsVisible = true; - AutomaticCullingState = scene::EAC_BOX; - DebugDataVisible = scene::EDS_OFF; - IsDebugObject = false; - - updateAbsolutePosition(); -} - - -//! Sets ambient color of the scene -void CSceneManager::setAmbientLight(const video::SColorf &ambientColor) -{ - AmbientLight = ambientColor; -} - - -//! Returns ambient color of the scene -const video::SColorf& CSceneManager::getAmbientLight() const -{ - return AmbientLight; -} - - -//! Get a skinned mesh, which is not available as header-only code -ISkinnedMesh* CSceneManager::createSkinnedMesh() -{ -#ifdef _IRR_COMPILE_WITH_SKINNED_MESH_SUPPORT_ - return new CSkinnedMesh(); -#else - return 0; -#endif -} - -//! Returns a mesh writer implementation if available -IMeshWriter* CSceneManager::createMeshWriter(EMESH_WRITER_TYPE type) -{ - switch(type) - { - case EMWT_IRR_MESH: -#ifdef _IRR_COMPILE_WITH_IRR_WRITER_ - return new CIrrMeshWriter(Driver, FileSystem); -#else - return 0; -#endif - case EMWT_COLLADA: -#ifdef _IRR_COMPILE_WITH_COLLADA_WRITER_ - return new CColladaMeshWriter(Driver, FileSystem); -#else - return 0; -#endif - case EMWT_STL: -#ifdef _IRR_COMPILE_WITH_STL_WRITER_ - return new CSTLMeshWriter(this); -#else - return 0; -#endif - case EMWT_OBJ: -#ifdef _IRR_COMPILE_WITH_OBJ_WRITER_ - return new COBJMeshWriter(this, FileSystem); -#else - return 0; -#endif - - case EMWT_PLY: -#ifdef _IRR_COMPILE_WITH_PLY_WRITER_ - return new CPLYMeshWriter(); -#else - return 0; -#endif - } - - return 0; -} - - -// creates a scenemanager -ISceneManager* createSceneManager(video::IVideoDriver* driver, - io::IFileSystem* fs, gui::ICursorControl* cursorcontrol, - gui::IGUIEnvironment *guiEnvironment) -{ - return new CSceneManager(driver, fs, cursorcontrol, 0, guiEnvironment ); -} - - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CSceneManager.h b/irrlicht-1.6/source/Irrlicht/CSceneManager.h deleted file mode 100644 index 3082fa82a..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSceneManager.h +++ /dev/null @@ -1,642 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_SCENE_MANAGER_H_INCLUDED__ -#define __C_SCENE_MANAGER_H_INCLUDED__ - -#include "ISceneManager.h" -#include "ISceneNode.h" -#include "ICursorControl.h" -#include "irrString.h" -#include "irrArray.h" -#include "IMeshLoader.h" -#include "CAttributes.h" -#include "ILightManager.h" - -namespace irr -{ -namespace io -{ - class IXMLWriter; - class IFileSystem; -} -namespace scene -{ - class IMeshCache; - class IGeometryCreator; - - /*! - The Scene Manager manages scene nodes, mesh recources, cameras and all the other stuff. - */ - class CSceneManager : public ISceneManager, public ISceneNode - { - public: - - //! constructor - CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs, - gui::ICursorControl* cursorControl, IMeshCache* cache = 0, - gui::IGUIEnvironment *guiEnvironment = 0); - - //! destructor - virtual ~CSceneManager(); - - //! gets an animateable mesh. loads it if needed. returned pointer must not be dropped. - virtual IAnimatedMesh* getMesh(const io::path& filename); - - //! gets an animateable mesh. loads it if needed. returned pointer must not be dropped. - virtual IAnimatedMesh* getMesh(io::IReadFile* file); - - //! Returns an interface to the mesh cache which is shared beween all existing scene managers. - virtual IMeshCache* getMeshCache(); - - //! returns the video driver - virtual video::IVideoDriver* getVideoDriver(); - - //! return the gui environment - virtual gui::IGUIEnvironment* getGUIEnvironment(); - - //! return the filesystem - virtual io::IFileSystem* getFileSystem(); - - //! adds Volume Lighting Scene Node. - //! the returned pointer must not be dropped. - virtual IVolumeLightSceneNode* addVolumeLightSceneNode(ISceneNode* parent=0, s32 id=-1, - const u32 subdivU = 32, const u32 subdivV = 32, - const video::SColor foot = video::SColor(51, 0, 230, 180), - const video::SColor tail = video::SColor(0, 0, 0, 0), - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); - - //! adds a cube scene node to the scene. It is a simple cube of (1,1,1) size. - //! the returned pointer must not be dropped. - virtual IMeshSceneNode* addCubeSceneNode(f32 size=10.0f, ISceneNode* parent=0, s32 id=-1, - const core::vector3df& position = core::vector3df(0,0,0), const core::vector3df& rotation = core::vector3df(0,0,0), const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); - - //! Adds a sphere scene node to the scene. - virtual IMeshSceneNode* addSphereSceneNode(f32 radius=5.0f, s32 polyCount=16, ISceneNode* parent=0, s32 id=-1, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); - - //! adds a scene node for rendering an animated mesh model - virtual IAnimatedMeshSceneNode* addAnimatedMeshSceneNode(IAnimatedMesh* mesh, ISceneNode* parent=0, s32 id=-1, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f), - bool alsoAddIfMeshPointerZero=false); - - //! adds a scene node for rendering a static mesh - //! the returned pointer must not be dropped. - virtual IMeshSceneNode* addMeshSceneNode(IMesh* mesh, ISceneNode* parent=0, s32 id=-1, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f), - bool alsoAddIfMeshPointerZero=false); - - //! Adds a scene node for rendering a animated water surface mesh. - virtual ISceneNode* addWaterSurfaceSceneNode(IMesh* mesh, f32 waveHeight, f32 waveSpeed, f32 wlenght, ISceneNode* parent=0, s32 id=-1, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); - - //! renders the node. - virtual void render(); - - //! returns the axis aligned bounding box of this node - virtual const core::aabbox3d<f32>& getBoundingBox() const; - - //! registers a node for rendering it at a specific time. - virtual u32 registerNodeForRendering(ISceneNode* node, E_SCENE_NODE_RENDER_PASS = ESNRP_AUTOMATIC); - - //! draws all scene nodes - virtual void drawAll(); - - //! Adds a scene node for rendering using a octtree to the scene graph. This a good method for rendering - //! scenes with lots of geometry. The Octree is built on the fly from the mesh, much - //! faster then a bsp tree. - virtual IMeshSceneNode* addOctTreeSceneNode(IAnimatedMesh* mesh, ISceneNode* parent=0, - s32 id=-1, s32 minimalPolysPerNode=512, bool alsoAddIfMeshPointerZero=false); - - //! Adss a scene node for rendering using a octtree. This a good method for rendering - //! scenes with lots of geometry. The Octree is built on the fly from the mesh, much - //! faster then a bsp tree. - virtual IMeshSceneNode* addOctTreeSceneNode(IMesh* mesh, ISceneNode* parent=0, - s32 id=-1, s32 minimalPolysPerNode=128, bool alsoAddIfMeshPointerZero=false); - - //! Adds a camera scene node to the tree and sets it as active camera. - //! \param position: Position of the space relative to its parent where the camera will be placed. - //! \param lookat: Position where the camera will look at. Also known as target. - //! \param parent: Parent scene node of the camera. Can be null. If the parent moves, - //! the camera will move too. - //! \return Pointer to interface to camera - virtual ICameraSceneNode* addCameraSceneNode(ISceneNode* parent = 0, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& lookat = core::vector3df(0,0,100), s32 id=-1); - - //! Adds a camera scene node which is able to be controlle with the mouse similar - //! like in the 3D Software Maya by Alias Wavefront. - //! The returned pointer must not be dropped. - virtual ICameraSceneNode* addCameraSceneNodeMaya(ISceneNode* parent = 0, - f32 rotateSpeed = -1500.0f, f32 zoomSpeed = 200.0f, f32 translationSpeed = 1500.0f, s32 id=-1); - - //! Adds a camera scene node which is able to be controled with the mouse and keys - //! like in most first person shooters (FPS): - virtual ICameraSceneNode* addCameraSceneNodeFPS(ISceneNode* parent = 0, - f32 rotateSpeed = 100.0f, f32 moveSpeed = .5f, s32 id=-1, - SKeyMap* keyMapArray=0, s32 keyMapSize=0, bool noVerticalMovement=false, - f32 jumpSpeed = 0.f, bool invertMouseY=false); - - //! Adds a dynamic light scene node. The light will cast dynamic light on all - //! other scene nodes in the scene, which have the material flag video::MTF_LIGHTING - //! turned on. (This is the default setting in most scene nodes). - virtual ILightSceneNode* addLightSceneNode(ISceneNode* parent = 0, - const core::vector3df& position = core::vector3df(0,0,0), - video::SColorf color = video::SColorf(1.0f, 1.0f, 1.0f), - f32 range=100.0f, s32 id=-1); - - //! Adds a billboard scene node to the scene. A billboard is like a 3d sprite: A 2d element, - //! which always looks to the camera. It is usually used for things like explosions, fire, - //! lensflares and things like that. - virtual IBillboardSceneNode* addBillboardSceneNode(ISceneNode* parent = 0, - const core::dimension2d<f32>& size = core::dimension2d<f32>(10.0f, 10.0f), - const core::vector3df& position = core::vector3df(0,0,0), s32 id=-1, - video::SColor shadeTop = 0xFFFFFFFF, video::SColor shadeBottom = 0xFFFFFFFF); - - //! Adds a skybox scene node. A skybox is a big cube with 6 textures on it and - //! is drawn around the camera position. - virtual ISceneNode* addSkyBoxSceneNode(video::ITexture* top, video::ITexture* bottom, - video::ITexture* left, video::ITexture* right, video::ITexture* front, - video::ITexture* back, ISceneNode* parent = 0, s32 id=-1); - - //! Adds a skydome scene node. A skydome is a large (half-) sphere with a - //! panoramic texture on it and is drawn around the camera position. - virtual ISceneNode* addSkyDomeSceneNode(video::ITexture* texture, - u32 horiRes=16, u32 vertRes=8, - f32 texturePercentage=0.9, f32 spherePercentage=2.0,f32 radius = 1000.f, - ISceneNode* parent=0, s32 id=-1); - - //! Adds a text scene node, which is able to display - //! 2d text at a position in three dimensional space - virtual ITextSceneNode* addTextSceneNode(gui::IGUIFont* font, const wchar_t* text, - video::SColor color=video::SColor(100,255,255,255), - ISceneNode* parent = 0, const core::vector3df& position = core::vector3df(0,0,0), - s32 id=-1); - - //! Adds a text scene node, which uses billboards - virtual IBillboardTextSceneNode* addBillboardTextSceneNode(gui::IGUIFont* font, const wchar_t* text, - ISceneNode* parent = 0, - const core::dimension2d<f32>& size = core::dimension2d<f32>(10.0f, 10.0f), - const core::vector3df& position = core::vector3df(0,0,0), s32 id=-1, - video::SColor colorTop = 0xFFFFFFFF, video::SColor colorBottom = 0xFFFFFFFF); - - //! Adds a scene node, which can render a quake3 shader - virtual IMeshSceneNode* addQuake3SceneNode(IMeshBuffer* meshBuffer, const quake3::IShader * shader, - ISceneNode* parent=0, s32 id=-1 - ); - - - //! Adds a Hill Plane mesh to the mesh pool. The mesh is - //! generated on the fly and looks like a plane with some hills - //! on it. You can specify how many hills should be on the plane - //! and how high they should be. Also you must specify a name - //! for the mesh because the mesh is added to the mesh pool and - //! can be retrieved back using ISceneManager::getMesh with the - //! name as parameter. - virtual IAnimatedMesh* addHillPlaneMesh(const io::path& name, - const core::dimension2d<f32>& tileSize, const core::dimension2d<u32>& tileCount, - video::SMaterial* material = 0, f32 hillHeight = 0.0f, - const core::dimension2d<f32>& countHills = core::dimension2d<f32>(1.0f, 1.0f), - const core::dimension2d<f32>& textureRepeatCount = core::dimension2d<f32>(1.0f, 1.0f)); - - //! Adds a terrain mesh to the mesh pool. - virtual IAnimatedMesh* addTerrainMesh(const io::path& meshname, video::IImage* texture, video::IImage* heightmap, - const core::dimension2d<f32>& stretchSize, - f32 maxHeight, const core::dimension2d<u32>& defaultVertexBlockSize); - - //! Add a arrow mesh to the mesh pool - virtual IAnimatedMesh* addArrowMesh(const io::path& name, - video::SColor vtxColor0, video::SColor vtxColor1, - u32 tesselationCylinder, u32 tesselationCone, - f32 height, f32 cylinderHeight, f32 width0, - f32 width1); - - //! Adds a static sphere mesh to the mesh pool. - IAnimatedMesh* addSphereMesh(const io::path& name, - f32 radius=5.f, u32 polyCountX=16, u32 polyCountY=16); - - //! Adds a static volume light mesh to the mesh pool. - IAnimatedMesh* addVolumeLightMesh(const io::path& name, - const u32 SubdivideU = 32, const u32 SubdivideV = 32, - const video::SColor FootColor = video::SColor(51, 0, 230, 180), - const video::SColor TailColor = video::SColor(0, 0, 0, 0)); - - //! Adds a particle system scene node. - virtual IParticleSystemSceneNode* addParticleSystemSceneNode( - bool withDefaultEmitter=true, ISceneNode* parent=0, s32 id=-1, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); - - //! Adds a terrain scene node to the scene graph. - virtual ITerrainSceneNode* addTerrainSceneNode( - const io::path& heightMapFileName, - ISceneNode* parent=0, s32 id=-1, - const core::vector3df& position = core::vector3df(0.0f,0.0f,0.0f), - const core::vector3df& rotation = core::vector3df(0.0f,0.0f,0.0f), - const core::vector3df& scale = core::vector3df(1.0f,1.0f,1.0f), - video::SColor vertexColor = video::SColor(255,255,255,255), - s32 maxLOD=4, E_TERRAIN_PATCH_SIZE patchSize=ETPS_17,s32 smoothFactor=0, - bool addAlsoIfHeightmapEmpty = false); - - //! Adds a terrain scene node to the scene graph. - virtual ITerrainSceneNode* addTerrainSceneNode( - io::IReadFile* heightMap, - ISceneNode* parent=0, s32 id=-1, - const core::vector3df& position = core::vector3df(0.0f,0.0f,0.0f), - const core::vector3df& rotation = core::vector3df(0.0f,0.0f,0.0f), - const core::vector3df& scale = core::vector3df(1.0f,1.0f,1.0f), - video::SColor vertexColor = video::SColor(255,255,255,255), - s32 maxLOD=4, E_TERRAIN_PATCH_SIZE patchSize=ETPS_17,s32 smoothFactor=0, - bool addAlsoIfHeightmapEmpty=false); - - //! Adds a dummy transformation scene node to the scene graph. - virtual IDummyTransformationSceneNode* addDummyTransformationSceneNode( - ISceneNode* parent=0, s32 id=-1); - - //! Adds an empty scene node. - virtual ISceneNode* addEmptySceneNode(ISceneNode* parent, s32 id=-1); - - //! Returns the root scene node. This is the scene node wich is parent - //! of all scene nodes. The root scene node is a special scene node which - //! only exists to manage all scene nodes. It is not rendered and cannot - //! be removed from the scene. - //! \return Pointer to the root scene node. - virtual ISceneNode* getRootSceneNode(); - - //! Returns the current active camera. - //! \return The active camera is returned. Note that this can be NULL, if there - //! was no camera created yet. - virtual ICameraSceneNode* getActiveCamera() const; - - //! Sets the active camera. The previous active camera will be deactivated. - //! \param camera: The new camera which should be active. - virtual void setActiveCamera(ICameraSceneNode* camera); - - //! creates a rotation animator, which rotates the attached scene node around itself. - //! \param rotationPerSecond: Specifies the speed of the animation - //! \return The animator. Attach it to a scene node with ISceneNode::addAnimator() - //! and the animator will animate it. - virtual ISceneNodeAnimator* createRotationAnimator(const core::vector3df& rotationPerSecond); - - //! creates a fly circle animator - /** Lets the attached scene node fly around a center. - \param center Center relative to node origin - \param speed: The orbital speed, in radians per millisecond. - \param direction: Specifies the upvector used for alignment of the mesh. - \param startPosition: The position on the circle where the animator will - begin. Value is in multiples of a circle, i.e. 0.5 is half way around. - \return The animator. Attach it to a scene node with ISceneNode::addAnimator() - */ - virtual ISceneNodeAnimator* createFlyCircleAnimator( - const core::vector3df& center=core::vector3df(0.f, 0.f, 0.f), - f32 radius=100.f, f32 speed=0.001f, - const core::vector3df& direction=core::vector3df(0.f, 1.f, 0.f), - f32 startPosition = 0.f, - f32 radiusEllipsoid = 0.f); - - //! Creates a fly straight animator, which lets the attached scene node - //! fly or move along a line between two points. - virtual ISceneNodeAnimator* createFlyStraightAnimator(const core::vector3df& startPoint, - const core::vector3df& endPoint, u32 timeForWay, bool loop=false,bool pingpong = false); - - //! Creates a texture animator, which switches the textures of the target scene - //! node based on a list of textures. - virtual ISceneNodeAnimator* createTextureAnimator(const core::array<video::ITexture*>& textures, - s32 timePerFrame, bool loop); - - //! Creates a scene node animator, which deletes the scene node after - //! some time automaticly. - virtual ISceneNodeAnimator* createDeleteAnimator(u32 timeMS); - - - //! Creates a special scene node animator for doing automatic collision detection - //! and response. - virtual ISceneNodeAnimatorCollisionResponse* createCollisionResponseAnimator( - ITriangleSelector* world, ISceneNode* sceneNode, - const core::vector3df& ellipsoidRadius = core::vector3df(30,60,30), - const core::vector3df& gravityPerSecond = core::vector3df(0,-1.0f,0), - const core::vector3df& ellipsoidTranslation = core::vector3df(0,0,0), - f32 slidingValue = 0.0005f); - - //! Creates a follow spline animator. - virtual ISceneNodeAnimator* createFollowSplineAnimator(s32 startTime, - const core::array< core::vector3df >& points, - f32 speed = 1.0f, f32 tightness = 0.5f); - - - //! Creates a simple ITriangleSelector, based on a mesh. - virtual ITriangleSelector* createTriangleSelector(IMesh* mesh, ISceneNode* node); - - //! Creates a simple ITriangleSelector, based on an animated mesh scene node. - //! Details of the mesh associated with the node will be extracted internally. - //! Call ITriangleSelector::update() to have the triangle selector updated based - //! on the current frame of the animated mesh scene node. - //! \param: The animated mesh scene node from which to build the selector - virtual ITriangleSelector* createTriangleSelector(IAnimatedMeshSceneNode* node); - - //! Creates a simple ITriangleSelector, based on a mesh. - virtual ITriangleSelector* createOctTreeTriangleSelector(IMesh* mesh, - ISceneNode* node, s32 minimalPolysPerNode); - - //! Creates a simple dynamic ITriangleSelector, based on a axis aligned bounding box. - virtual ITriangleSelector* createTriangleSelectorFromBoundingBox( - ISceneNode* node); - - //! Creates a meta triangle selector. - virtual IMetaTriangleSelector* createMetaTriangleSelector(); - - //! Creates a triangle selector which can select triangles from a terrain scene node - //! \param: Pointer to the created terrain scene node - //! \param: Level of detail, 0 for highest detail. - virtual ITriangleSelector* createTerrainTriangleSelector( - ITerrainSceneNode* node, s32 LOD=0); - - //! Adds an external mesh loader. - virtual void addExternalMeshLoader(IMeshLoader* externalLoader); - - //! Returns a pointer to the scene collision manager. - virtual ISceneCollisionManager* getSceneCollisionManager(); - - //! Returns a pointer to the mesh manipulator. - virtual IMeshManipulator* getMeshManipulator(); - - //! Sets the color of stencil buffers shadows drawn by the scene manager. - virtual void setShadowColor(video::SColor color); - - //! Returns the current color of shadows. - virtual video::SColor getShadowColor() const; - - //! Adds a scene node to the deletion queue. - virtual void addToDeletionQueue(ISceneNode* node); - - //! Returns the first scene node with the specified id. - virtual ISceneNode* getSceneNodeFromId(s32 id, ISceneNode* start=0); - - //! Returns the first scene node with the specified name. - virtual ISceneNode* getSceneNodeFromName(const c8* name, ISceneNode* start=0); - - //! Returns the first scene node with the specified type. - virtual ISceneNode* getSceneNodeFromType(scene::ESCENE_NODE_TYPE type, ISceneNode* start=0); - - //! returns scene nodes by type. - virtual void getSceneNodesFromType(ESCENE_NODE_TYPE type, core::array<scene::ISceneNode*>& outNodes, ISceneNode* start=0); - - //! Posts an input event to the environment. Usually you do not have to - //! use this method, it is used by the internal engine. - virtual bool postEventFromUser(const SEvent& event); - - //! Clears the whole scene. All scene nodes are removed. - virtual void clear(); - - //! Removes all children of this scene node - virtual void removeAll(); - - //! Returns interface to the parameters set in this scene. - virtual io::IAttributes* getParameters(); - - //! Returns current render pass. - virtual E_SCENE_NODE_RENDER_PASS getSceneNodeRenderPass() const; - - //! Creates a new scene manager. - virtual ISceneManager* createNewSceneManager(bool cloneContent); - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() const { return ESNT_UNKNOWN; } - - //! Returns the default scene node factory which can create all built in scene nodes - virtual ISceneNodeFactory* getDefaultSceneNodeFactory(); - - //! Adds a scene node factory to the scene manager. - /** Use this to extend the scene manager with new scene node types which it should be - able to create automaticly, for example when loading data from xml files. */ - virtual void registerSceneNodeFactory(ISceneNodeFactory* factoryToAdd); - - //! Returns amount of registered scene node factories. - virtual u32 getRegisteredSceneNodeFactoryCount() const; - - //! Returns a scene node factory by index - virtual ISceneNodeFactory* getSceneNodeFactory(u32 index); - - //! Returns a typename from a scene node type or null if not found - virtual const c8* getSceneNodeTypeName(ESCENE_NODE_TYPE type); - - //! Returns a typename from a scene node animator type or null if not found - virtual const c8* getAnimatorTypeName(ESCENE_NODE_ANIMATOR_TYPE type); - - //! Adds a scene node to the scene by name - virtual ISceneNode* addSceneNode(const char* sceneNodeTypeName, ISceneNode* parent=0); - - //! Returns the default scene node animator factory which can create all built-in scene node animators - virtual ISceneNodeAnimatorFactory* getDefaultSceneNodeAnimatorFactory(); - - //! Adds a scene node animator factory to the scene manager. - virtual void registerSceneNodeAnimatorFactory(ISceneNodeAnimatorFactory* factoryToAdd); - - //! Returns amount of registered scene node animator factories. - virtual u32 getRegisteredSceneNodeAnimatorFactoryCount() const; - - //! Returns a scene node animator factory by index - virtual ISceneNodeAnimatorFactory* getSceneNodeAnimatorFactory(u32 index); - - //! Saves the current scene into a file. - //! \param filename: Name of the file . - virtual bool saveScene(const io::path& filename, ISceneUserDataSerializer* userDataSerializer=0); - - //! Saves the current scene into a file. - virtual bool saveScene(io::IWriteFile* file, ISceneUserDataSerializer* userDataSerializer=0); - - //! Loads a scene. Note that the current scene is not cleared before. - //! \param filename: Name of the file . - virtual bool loadScene(const io::path& filename, ISceneUserDataSerializer* userDataSerializer=0); - - //! Loads a scene. Note that the current scene is not cleared before. - virtual bool loadScene(io::IReadFile* file, ISceneUserDataSerializer* userDataSerializer=0); - - //! Writes attributes of the scene node. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const; - - //! Reads attributes of the scene node. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - //! Returns a mesh writer implementation if available - virtual IMeshWriter* createMeshWriter(EMESH_WRITER_TYPE type); - - //! Get a skinned mesh, which is not available as header-only code - virtual ISkinnedMesh* createSkinnedMesh(); - - //! Sets ambient color of the scene - virtual void setAmbientLight(const video::SColorf &ambientColor); - - //! Returns ambient color of the scene - virtual const video::SColorf& getAmbientLight() const; - - //! Register a custom callbacks manager which gets callbacks during scene rendering. - virtual void setLightManager(ILightManager* lightManager); - - //! Get an instance of a geometry creator. - virtual const IGeometryCreator* getGeometryCreator(void) const { return GeometryCreator; } - - //! returns if node is culled - virtual bool isCulled(const ISceneNode* node) const; - - private: - - //! clears the deletion list - void clearDeletionList(); - - //! writes a scene node - void writeSceneNode(io::IXMLWriter* writer, ISceneNode* node, ISceneUserDataSerializer* userDataSerializer); - - //! reads a scene node - void readSceneNode(io::IXMLReader* reader, ISceneNode* parent, ISceneUserDataSerializer* userDataSerializer); - - //! read materials - void readMaterials(io::IXMLReader* reader, ISceneNode* node); - - //! reads animators of a node - void readAnimators(io::IXMLReader* reader, ISceneNode* node); - - //! reads user data of a node - void readUserData(io::IXMLReader* reader, ISceneNode* node, ISceneUserDataSerializer* userDataSerializer); - - struct DefaultNodeEntry - { - DefaultNodeEntry(ISceneNode* n) : - Node(n), TextureValue(0) - { - if (n->getMaterialCount()) - TextureValue = (n->getMaterial(0).getTexture(0)); - } - - bool operator < (const DefaultNodeEntry& other) const - { - return (TextureValue < other.TextureValue); - } - - ISceneNode* Node; - private: - void* TextureValue; - }; - - //! sort on distance (center) to camera - struct TransparentNodeEntry - { - TransparentNodeEntry(ISceneNode* n, const core::vector3df& camera) - : Node(n) - { - Distance = Node->getAbsoluteTransformation().getTranslation().getDistanceFromSQ(camera); - } - - bool operator < (const TransparentNodeEntry& other) const - { - return Distance > other.Distance; - } - - ISceneNode* Node; - private: - f64 Distance; - }; - - //! sort on distance (sphere) to camera - struct DistanceNodeEntry - { - DistanceNodeEntry(ISceneNode* n, f32 d) - : Node(n), Distance(d) {} - - DistanceNodeEntry(ISceneNode* n, const core::vector3df& cameraPos) - : Node(n) - { - setNodeAndDistanceFromPosition(n, cameraPos); - } - - bool operator < (const DistanceNodeEntry& other) const - { - return Distance < other.Distance; - } - - void setNodeAndDistanceFromPosition(ISceneNode* n, const core::vector3df & fromPosition) - { - Node = n; - Distance = Node->getAbsoluteTransformation().getTranslation().getDistanceFromSQ(fromPosition); - Distance -= Node->getBoundingBox().getExtent().getLengthSQ() * 0.5; - } - - ISceneNode* Node; - private: - f64 Distance; - }; - - //! video driver - video::IVideoDriver* Driver; - - //! file system - io::IFileSystem* FileSystem; - - //! GUI Enviroment ( Debug Purpose ) - gui::IGUIEnvironment* GUIEnvironment; - - //! cursor control - gui::ICursorControl* CursorControl; - - //! collision manager - ISceneCollisionManager* CollisionManager; - - //! render pass lists - core::array<ISceneNode*> CameraList; - core::array<ILightSceneNode*> LightList; - core::array<ISceneNode*> ShadowNodeList; - core::array<ISceneNode*> SkyBoxList; - core::array<DefaultNodeEntry> SolidNodeList; - core::array<TransparentNodeEntry> TransparentNodeList; - core::array<TransparentNodeEntry> TransparentEffectNodeList; - - core::array<IMeshLoader*> MeshLoaderList; - core::array<ISceneNode*> DeletionList; - core::array<ISceneNodeFactory*> SceneNodeFactoryList; - core::array<ISceneNodeAnimatorFactory*> SceneNodeAnimatorFactoryList; - - //! current active camera - ICameraSceneNode* ActiveCamera; - core::vector3df camWorldPos; // Position of camera for transparent nodes. - - video::SColor ShadowColor; - video::SColorf AmbientLight; - - //! String parameters - io::CAttributes Parameters; - - //! Mesh cache - IMeshCache* MeshCache; - - E_SCENE_NODE_RENDER_PASS CurrentRendertime; - - //! An optional callbacks manager to allow the user app finer control - //! over the scene lighting and rendering. - ILightManager* LightManager; - - //! constants for reading and writing XML. - //! Not made static due to portability problems. - const core::stringw IRR_XML_FORMAT_SCENE; - const core::stringw IRR_XML_FORMAT_NODE; - const core::stringw IRR_XML_FORMAT_NODE_ATTR_TYPE; - - IGeometryCreator* GeometryCreator; - }; - -} // end namespace video -} // end namespace scene - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorCameraFPS.cpp b/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorCameraFPS.cpp deleted file mode 100644 index 4aa326045..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorCameraFPS.cpp +++ /dev/null @@ -1,356 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CSceneNodeAnimatorCameraFPS.h" -#include "IVideoDriver.h" -#include "ISceneManager.h" -#include "Keycodes.h" -#include "ICursorControl.h" -#include "ICameraSceneNode.h" -#include "ISceneNodeAnimatorCollisionResponse.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CSceneNodeAnimatorCameraFPS::CSceneNodeAnimatorCameraFPS(gui::ICursorControl* cursorControl, - f32 rotateSpeed, f32 moveSpeed, f32 jumpSpeed, - SKeyMap* keyMapArray, u32 keyMapSize, bool noVerticalMovement, bool invertY) -: CursorControl(cursorControl), MaxVerticalAngle(88.0f), - MoveSpeed(moveSpeed), RotateSpeed(rotateSpeed), JumpSpeed(jumpSpeed), - MouseYDirection(invertY ? -1.0f : 1.0f), - LastAnimationTime(0), firstUpdate(true), NoVerticalMovement(noVerticalMovement) -{ - #ifdef _DEBUG - setDebugName("CCameraSceneNodeAnimatorFPS"); - #endif - - if (CursorControl) - CursorControl->grab(); - - allKeysUp(); - - // create key map - if (!keyMapArray || !keyMapSize) - { - // create default key map - KeyMap.push_back(SCamKeyMap(EKA_MOVE_FORWARD, irr::KEY_UP)); - KeyMap.push_back(SCamKeyMap(EKA_MOVE_BACKWARD, irr::KEY_DOWN)); - KeyMap.push_back(SCamKeyMap(EKA_STRAFE_LEFT, irr::KEY_LEFT)); - KeyMap.push_back(SCamKeyMap(EKA_STRAFE_RIGHT, irr::KEY_RIGHT)); - KeyMap.push_back(SCamKeyMap(EKA_JUMP_UP, irr::KEY_KEY_J)); - } - else - { - // create custom key map - setKeyMap(keyMapArray, keyMapSize); - } -} - - -//! destructor -CSceneNodeAnimatorCameraFPS::~CSceneNodeAnimatorCameraFPS() -{ - if (CursorControl) - CursorControl->drop(); -} - - -//! It is possible to send mouse and key events to the camera. Most cameras -//! may ignore this input, but camera scene nodes which are created for -//! example with scene::ISceneManager::addMayaCameraSceneNode or -//! scene::ISceneManager::addFPSCameraSceneNode, may want to get this input -//! for changing their position, look at target or whatever. -bool CSceneNodeAnimatorCameraFPS::OnEvent(const SEvent& evt) -{ - switch(evt.EventType) - { - case EET_KEY_INPUT_EVENT: - for (u32 i=0; i<KeyMap.size(); ++i) - { - if (KeyMap[i].keycode == evt.KeyInput.Key) - { - CursorKeys[KeyMap[i].action] = evt.KeyInput.PressedDown; - return true; - } - } - break; - - case EET_MOUSE_INPUT_EVENT: - if (evt.MouseInput.Event == EMIE_MOUSE_MOVED) - { - CursorPos = CursorControl->getRelativePosition(); - return true; - } - break; - - default: - break; - } - - return false; -} - - -void CSceneNodeAnimatorCameraFPS::animateNode(ISceneNode* node, u32 timeMs) -{ - if (!node || node->getType() != ESNT_CAMERA) - return; - - ICameraSceneNode* camera = static_cast<ICameraSceneNode*>(node); - - if (firstUpdate) - { - camera->updateAbsolutePosition(); - if (CursorControl && camera) - { - CursorControl->setPosition(0.5f, 0.5f); - CursorPos = CenterCursor = CursorControl->getRelativePosition(); - } - - LastAnimationTime = timeMs; - - firstUpdate = false; - } - - // If the camera isn't the active camera, and receiving input, then don't process it. - if(!camera->isInputReceiverEnabled()) - return; - - scene::ISceneManager * smgr = camera->getSceneManager(); - if(smgr && smgr->getActiveCamera() != camera) - return; - - // get time - f32 timeDiff = (f32) ( timeMs - LastAnimationTime ); - LastAnimationTime = timeMs; - - // update position - core::vector3df pos = camera->getPosition(); - - // Update rotation - core::vector3df target = (camera->getTarget() - camera->getAbsolutePosition()); - core::vector3df relativeRotation = target.getHorizontalAngle(); - - if (CursorControl) - { - if (CursorPos != CenterCursor) - { - relativeRotation.Y -= (0.5f - CursorPos.X) * RotateSpeed; - relativeRotation.X -= (0.5f - CursorPos.Y) * RotateSpeed * MouseYDirection; - - // X < MaxVerticalAngle or X > 360-MaxVerticalAngle - - if (relativeRotation.X > MaxVerticalAngle*2 && - relativeRotation.X < 360.0f-MaxVerticalAngle) - { - relativeRotation.X = 360.0f-MaxVerticalAngle; - } - else - if (relativeRotation.X > MaxVerticalAngle && - relativeRotation.X < 360.0f-MaxVerticalAngle) - { - relativeRotation.X = MaxVerticalAngle; - } - - // Do the fix as normal, special case below - // reset cursor position to the centre of the window. - CursorControl->setPosition(0.5f, 0.5f); - CenterCursor = CursorControl->getRelativePosition(); - - // needed to avoid problems when the event receiver is disabled - CursorPos = CenterCursor; - } - - // Special case, mouse is whipped outside of window before it can update. - video::IVideoDriver* driver = smgr->getVideoDriver(); - core::vector2d<u32> mousepos(u32(CursorControl->getPosition().X), u32(CursorControl->getPosition().Y)); - core::rect<u32> screenRect(0, 0, driver->getScreenSize().Width, driver->getScreenSize().Height); - - // Only if we are moving outside quickly. - bool reset = !screenRect.isPointInside(mousepos); - - if(reset) - { - // Force a reset. - CursorControl->setPosition(0.5f, 0.5f); - CenterCursor = CursorControl->getRelativePosition(); - CursorPos = CenterCursor; - } - } - - // set target - - target.set(0,0, core::max_(1.f, pos.getLength())); - core::vector3df movedir = target; - - core::matrix4 mat; - mat.setRotationDegrees(core::vector3df(relativeRotation.X, relativeRotation.Y, 0)); - mat.transformVect(target); - - if (NoVerticalMovement) - { - mat.setRotationDegrees(core::vector3df(0, relativeRotation.Y, 0)); - mat.transformVect(movedir); - } - else - { - movedir = target; - } - - movedir.normalize(); - - if (CursorKeys[EKA_MOVE_FORWARD]) - pos += movedir * timeDiff * MoveSpeed; - - if (CursorKeys[EKA_MOVE_BACKWARD]) - pos -= movedir * timeDiff * MoveSpeed; - - // strafing - - core::vector3df strafevect = target; - strafevect = strafevect.crossProduct(camera->getUpVector()); - - if (NoVerticalMovement) - strafevect.Y = 0.0f; - - strafevect.normalize(); - - if (CursorKeys[EKA_STRAFE_LEFT]) - pos += strafevect * timeDiff * MoveSpeed; - - if (CursorKeys[EKA_STRAFE_RIGHT]) - pos -= strafevect * timeDiff * MoveSpeed; - - // For jumping, we find the collision response animator attached to our camera - // and if it's not falling, we tell it to jump. - if (CursorKeys[EKA_JUMP_UP]) - { - const core::list<ISceneNodeAnimator*> & animators = camera->getAnimators(); - core::list<ISceneNodeAnimator*>::ConstIterator it = animators.begin(); - while(it != animators.end()) - { - if(ESNAT_COLLISION_RESPONSE == (*it)->getType()) - { - ISceneNodeAnimatorCollisionResponse * collisionResponse = - static_cast<ISceneNodeAnimatorCollisionResponse *>(*it); - - if(!collisionResponse->isFalling()) - collisionResponse->jump(JumpSpeed); - } - - it++; - } - } - - // write translation - camera->setPosition(pos); - - // write right target - target += pos; - camera->setTarget(target); -} - - -void CSceneNodeAnimatorCameraFPS::allKeysUp() -{ - for (u32 i=0; i<6; ++i) - CursorKeys[i] = false; -} - - -//! Sets the rotation speed -void CSceneNodeAnimatorCameraFPS::setRotateSpeed(f32 speed) -{ - RotateSpeed = speed; -} - - -//! Sets the movement speed -void CSceneNodeAnimatorCameraFPS::setMoveSpeed(f32 speed) -{ - MoveSpeed = speed; -} - - -//! Gets the rotation speed -f32 CSceneNodeAnimatorCameraFPS::getRotateSpeed() const -{ - return RotateSpeed; -} - - -// Gets the movement speed -f32 CSceneNodeAnimatorCameraFPS::getMoveSpeed() const -{ - return MoveSpeed; -} - - -//! Sets the keyboard mapping for this animator -void CSceneNodeAnimatorCameraFPS::setKeyMap(SKeyMap *map, u32 count) -{ - // clear the keymap - KeyMap.clear(); - - // add actions - for (u32 i=0; i<count; ++i) - { - switch(map[i].Action) - { - case EKA_MOVE_FORWARD: KeyMap.push_back(SCamKeyMap(EKA_MOVE_FORWARD, map[i].KeyCode)); - break; - case EKA_MOVE_BACKWARD: KeyMap.push_back(SCamKeyMap(EKA_MOVE_BACKWARD, map[i].KeyCode)); - break; - case EKA_STRAFE_LEFT: KeyMap.push_back(SCamKeyMap(EKA_STRAFE_LEFT, map[i].KeyCode)); - break; - case EKA_STRAFE_RIGHT: KeyMap.push_back(SCamKeyMap(EKA_STRAFE_RIGHT, map[i].KeyCode)); - break; - case EKA_JUMP_UP: KeyMap.push_back(SCamKeyMap(EKA_JUMP_UP, map[i].KeyCode)); - break; - default: - break; - } - } -} - - -//! Sets whether vertical movement should be allowed. -void CSceneNodeAnimatorCameraFPS::setVerticalMovement(bool allow) -{ - NoVerticalMovement = !allow; -} - - -//! Sets whether the Y axis of the mouse should be inverted. -void CSceneNodeAnimatorCameraFPS::setInvertMouse(bool invert) -{ - if (invert) - MouseYDirection = -1.0f; - else - MouseYDirection = 1.0f; -} - - -ISceneNodeAnimator* CSceneNodeAnimatorCameraFPS::createClone(ISceneNode* node, ISceneManager* newManager) -{ - CSceneNodeAnimatorCameraFPS * newAnimator = - new CSceneNodeAnimatorCameraFPS(CursorControl, RotateSpeed, MoveSpeed, JumpSpeed, - 0, 0, NoVerticalMovement); - newAnimator->setKeyMap(KeyMap); - return newAnimator; -} - - -void CSceneNodeAnimatorCameraFPS::setKeyMap(const core::array<SCamKeyMap>& keymap) -{ - KeyMap=keymap; -} - - -} // namespace scene -} // namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorCameraFPS.h b/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorCameraFPS.h deleted file mode 100644 index bcc239693..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorCameraFPS.h +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_SCENE_NODE_ANIMATOR_CAMERA_FPS_H_INCLUDED__ -#define __C_SCENE_NODE_ANIMATOR_CAMERA_FPS_H_INCLUDED__ - -#include "ISceneNodeAnimatorCameraFPS.h" -#include "vector2d.h" -#include "SKeyMap.h" -#include "irrArray.h" - -namespace irr -{ -namespace gui -{ - class ICursorControl; -} - -namespace scene -{ - - //! Special scene node animator for FPS cameras - class CSceneNodeAnimatorCameraFPS : public ISceneNodeAnimatorCameraFPS - { - public: - - //! Constructor - CSceneNodeAnimatorCameraFPS(gui::ICursorControl* cursorControl, - f32 rotateSpeed = 100.0f, f32 moveSpeed = .5f, f32 jumpSpeed=0.f, - SKeyMap* keyMapArray=0, u32 keyMapSize=0, bool noVerticalMovement=false, - bool invertY=false); - - //! Destructor - virtual ~CSceneNodeAnimatorCameraFPS(); - - //! Animates the scene node, currently only works on cameras - virtual void animateNode(ISceneNode* node, u32 timeMs); - - //! Event receiver - virtual bool OnEvent(const SEvent& event); - - //! Returns the speed of movement in units per second - virtual f32 getMoveSpeed() const; - - //! Sets the speed of movement in units per second - virtual void setMoveSpeed(f32 moveSpeed); - - //! Returns the rotation speed - virtual f32 getRotateSpeed() const; - - //! Set the rotation speed - virtual void setRotateSpeed(f32 rotateSpeed); - - //! Sets the keyboard mapping for this animator - //! \param keymap: an array of keyboard mappings, see SKeyMap - //! \param count: the size of the keyboard map array - virtual void setKeyMap(SKeyMap *map, u32 count); - - //! Sets whether vertical movement should be allowed. - virtual void setVerticalMovement(bool allow); - - //! Sets whether the Y axis of the mouse should be inverted. - /** If enabled then moving the mouse down will cause - the camera to look up. It is disabled by default. */ - virtual void setInvertMouse(bool invert); - - //! This animator will receive events when attached to the active camera - virtual bool isEventReceiverEnabled() const - { - return true; - } - - //! Returns the type of this animator - virtual ESCENE_NODE_ANIMATOR_TYPE getType() const - { - return ESNAT_CAMERA_FPS; - } - - //! Creates a clone of this animator. - /** Please note that you will have to drop - (IReferenceCounted::drop()) the returned pointer once you're - done with it. */ - virtual ISceneNodeAnimator* createClone(ISceneNode* node, ISceneManager* newManager=0); - - struct SCamKeyMap - { - SCamKeyMap() {}; - SCamKeyMap(s32 a, EKEY_CODE k) : action(a), keycode(k) {} - - s32 action; - EKEY_CODE keycode; - }; - - //! Sets the keyboard mapping for this animator - /** Helper function for the clone method. - \param keymap the new keymap array */ - void setKeyMap(const core::array<SCamKeyMap>& keymap); - - private: - void allKeysUp(); - - gui::ICursorControl *CursorControl; - - f32 MaxVerticalAngle; - - f32 MoveSpeed; - f32 RotateSpeed; - f32 JumpSpeed; - // -1.0f for inverted mouse, defaults to 1.0f - f32 MouseYDirection; - - s32 LastAnimationTime; - - core::array<SCamKeyMap> KeyMap; - core::position2d<f32> CenterCursor, CursorPos; - - bool CursorKeys[6]; - - bool firstUpdate; - bool NoVerticalMovement; - }; - -} // end namespace scene -} // end namespace irr - -#endif // __C_SCENE_NODE_ANIMATOR_CAMERA_FPS_H_INCLUDED__ - diff --git a/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorCameraMaya.cpp b/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorCameraMaya.cpp deleted file mode 100644 index 1842c08ed..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorCameraMaya.cpp +++ /dev/null @@ -1,296 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CSceneNodeAnimatorCameraMaya.h" -#include "ICursorControl.h" -#include "ICameraSceneNode.h" -#include "SViewFrustum.h" -#include "ISceneManager.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CSceneNodeAnimatorCameraMaya::CSceneNodeAnimatorCameraMaya(gui::ICursorControl* cursor, f32 rotate, f32 zoom, f32 translate) - : CursorControl(cursor), Zooming(false), Rotating(false), Moving(false), - Translating(false), ZoomSpeed(zoom), RotateSpeed(rotate), TranslateSpeed(translate), - CurrentZoom(70.0f), RotX(0.0f), RotY(0.0f), OldCamera(0), MousePos(0.5f, 0.5f) -{ - #ifdef _DEBUG - setDebugName("CSceneNodeAnimatorCameraMaya"); - #endif - - if (CursorControl) - { - CursorControl->grab(); - MousePos = CursorControl->getRelativePosition(); - } - - allKeysUp(); -} - - -//! destructor -CSceneNodeAnimatorCameraMaya::~CSceneNodeAnimatorCameraMaya() -{ - if (CursorControl) - CursorControl->drop(); -} - - -//! It is possible to send mouse and key events to the camera. Most cameras -//! may ignore this input, but camera scene nodes which are created for -//! example with scene::ISceneManager::addMayaCameraSceneNode or -//! scene::ISceneManager::addMeshViewerCameraSceneNode, may want to get this input -//! for changing their position, look at target or whatever. -bool CSceneNodeAnimatorCameraMaya::OnEvent(const SEvent& event) -{ - if (event.EventType != EET_MOUSE_INPUT_EVENT) - return false; - - switch(event.MouseInput.Event) - { - case EMIE_LMOUSE_PRESSED_DOWN: - MouseKeys[0] = true; - break; - case EMIE_RMOUSE_PRESSED_DOWN: - MouseKeys[2] = true; - break; - case EMIE_MMOUSE_PRESSED_DOWN: - MouseKeys[1] = true; - break; - case EMIE_LMOUSE_LEFT_UP: - MouseKeys[0] = false; - break; - case EMIE_RMOUSE_LEFT_UP: - MouseKeys[2] = false; - break; - case EMIE_MMOUSE_LEFT_UP: - MouseKeys[1] = false; - break; - case EMIE_MOUSE_MOVED: - MousePos = CursorControl->getRelativePosition(); - break; - case EMIE_MOUSE_WHEEL: - case EMIE_MOUSE_DOUBLE_CLICK: - case EMIE_MOUSE_TRIPLE_CLICK: - case EMIE_COUNT: - return false; - } - return true; -} - - -//! OnAnimate() is called just before rendering the whole scene. -//! nodes may calculate or store animations here, and may do other useful things, -//! dependent on what they are. -void CSceneNodeAnimatorCameraMaya::animateNode(ISceneNode *node, u32 timeMs) -{ - //Alt + LM = Rotate around camera pivot - //Alt + LM + MM = Dolly forth/back in view direction (speed % distance camera pivot - max distance to pivot) - //Alt + MM = Move on camera plane (Screen center is about the mouse pointer, depending on move speed) - - if (!node || node->getType() != ESNT_CAMERA) - return; - - ICameraSceneNode* camera = static_cast<ICameraSceneNode*>(node); - - // If the camera isn't the active camera, and receiving input, then don't process it. - if(!camera->isInputReceiverEnabled()) - return; - - scene::ISceneManager * smgr = camera->getSceneManager(); - if(smgr && smgr->getActiveCamera() != camera) - return; - - if (OldCamera != camera) - { - OldTarget = camera->getTarget(); - OldCamera = camera; - } - - core::vector3df target = camera->getTarget(); - - f32 nRotX = RotX; - f32 nRotY = RotY; - f32 nZoom = CurrentZoom; - - if ( (isMouseKeyDown(0) && isMouseKeyDown(2)) || isMouseKeyDown(1) ) - { - if (!Zooming) - { - ZoomStart = MousePos; - Zooming = true; - nZoom = CurrentZoom; - } - else - { - const f32 targetMinDistance = 0.1f; - nZoom += (ZoomStart.X - MousePos.X) * ZoomSpeed; - - if (nZoom < targetMinDistance) // jox: fixed bug: bounce back when zooming to close - nZoom = targetMinDistance; - } - } - else if (Zooming) - { - const f32 old = CurrentZoom; - CurrentZoom = CurrentZoom + (ZoomStart.X - MousePos.X ) * ZoomSpeed; - nZoom = CurrentZoom; - - if (nZoom < 0) - nZoom = CurrentZoom = old; - Zooming = false; - } - - // Translation --------------------------------- - - core::vector3df translate(OldTarget), upVector(camera->getUpVector()); - - core::vector3df tvectX = Pos - target; - tvectX = tvectX.crossProduct(upVector); - tvectX.normalize(); - - const SViewFrustum* const va = camera->getViewFrustum(); - core::vector3df tvectY = (va->getFarLeftDown() - va->getFarRightDown()); - tvectY = tvectY.crossProduct(upVector.Y > 0 ? Pos - target : target - Pos); - tvectY.normalize(); - - if (isMouseKeyDown(2) && !Zooming) - { - if (!Translating) - { - TranslateStart = MousePos; - Translating = true; - } - else - { - translate += tvectX * (TranslateStart.X - MousePos.X)*TranslateSpeed + - tvectY * (TranslateStart.Y - MousePos.Y)*TranslateSpeed; - } - } - else if (Translating) - { - translate += tvectX * (TranslateStart.X - MousePos.X)*TranslateSpeed + - tvectY * (TranslateStart.Y - MousePos.Y)*TranslateSpeed; - OldTarget = translate; - Translating = false; - } - - // Rotation ------------------------------------ - - if (isMouseKeyDown(0) && !Zooming) - { - if (!Rotating) - { - RotateStart = MousePos; - Rotating = true; - nRotX = RotX; - nRotY = RotY; - } - else - { - nRotX += (RotateStart.X - MousePos.X) * RotateSpeed; - nRotY += (RotateStart.Y - MousePos.Y) * RotateSpeed; - } - } - else if (Rotating) - { - RotX += (RotateStart.X - MousePos.X) * RotateSpeed; - RotY += (RotateStart.Y - MousePos.Y) * RotateSpeed; - nRotX = RotX; - nRotY = RotY; - Rotating = false; - } - - // Set Pos ------------------------------------ - - target = translate; - - Pos.X = nZoom + target.X; - Pos.Y = target.Y; - Pos.Z = target.Z; - - Pos.rotateXYBy(nRotY, target); - Pos.rotateXZBy(-nRotX, target); - - // Rotation Error ---------------------------- - - // jox: fixed bug: jitter when rotating to the top and bottom of y - upVector.set(0,1,0); - upVector.rotateXYBy(-nRotY); - upVector.rotateXZBy(-nRotX+180.f); - - camera->setPosition(Pos); - camera->setTarget(target); - camera->setUpVector(upVector); -} - - -bool CSceneNodeAnimatorCameraMaya::isMouseKeyDown(s32 key) -{ - return MouseKeys[key]; -} - - -void CSceneNodeAnimatorCameraMaya::allKeysUp() -{ - for (s32 i=0; i<3; ++i) - MouseKeys[i] = false; -} - - -//! Sets the rotation speed -void CSceneNodeAnimatorCameraMaya::setRotateSpeed(f32 speed) -{ - RotateSpeed = speed; -} - - -//! Sets the movement speed -void CSceneNodeAnimatorCameraMaya::setMoveSpeed(f32 speed) -{ - TranslateSpeed = speed; -} - - -//! Sets the zoom speed -void CSceneNodeAnimatorCameraMaya::setZoomSpeed(f32 speed) -{ - ZoomSpeed = speed; -} - - -//! Gets the rotation speed -f32 CSceneNodeAnimatorCameraMaya::getRotateSpeed() const -{ - return RotateSpeed; -} - - -// Gets the movement speed -f32 CSceneNodeAnimatorCameraMaya::getMoveSpeed() const -{ - return TranslateSpeed; -} - - -//! Gets the zoom speed -f32 CSceneNodeAnimatorCameraMaya::getZoomSpeed() const -{ - return ZoomSpeed; -} - -ISceneNodeAnimator* CSceneNodeAnimatorCameraMaya::createClone(ISceneNode* node, ISceneManager* newManager) -{ - CSceneNodeAnimatorCameraMaya * newAnimator = - new CSceneNodeAnimatorCameraMaya(CursorControl, RotateSpeed, ZoomSpeed, TranslateSpeed); - return newAnimator; -} - -} // end namespace -} // end namespace - diff --git a/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorCameraMaya.h b/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorCameraMaya.h deleted file mode 100644 index 4350770f8..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorCameraMaya.h +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_SCENE_NODE_ANIMATOR_CAMERA_MAYA_H_INCLUDED__ -#define __C_SCENE_NODE_ANIMATOR_CAMERA_MAYA_H_INCLUDED__ - -#include "ISceneNodeAnimatorCameraMaya.h" -#include "ICameraSceneNode.h" -#include "vector2d.h" - -namespace irr -{ - -namespace gui -{ - class ICursorControl; -} - -namespace scene -{ - - //! Special scene node animator for FPS cameras - /** This scene node animator can be attached to a camera to make it act - like a 3d modelling tool camera - */ - class CSceneNodeAnimatorCameraMaya : public ISceneNodeAnimatorCameraMaya - { - public: - //! Constructor - CSceneNodeAnimatorCameraMaya(gui::ICursorControl* cursor, f32 rotateSpeed = -1500.0f, - f32 zoomSpeed = 200.0f, f32 translationSpeed = 1500.0f); - - //! Destructor - virtual ~CSceneNodeAnimatorCameraMaya(); - - //! Animates the scene node, currently only works on cameras - virtual void animateNode(ISceneNode* node, u32 timeMs); - - //! Event receiver - virtual bool OnEvent(const SEvent& event); - - //! Returns the speed of movement in units per millisecond - virtual f32 getMoveSpeed() const; - - //! Sets the speed of movement in units per millisecond - virtual void setMoveSpeed(f32 moveSpeed); - - //! Returns the rotation speed - virtual f32 getRotateSpeed() const; - - //! Set the rotation speed - virtual void setRotateSpeed(f32 rotateSpeed); - - //! Returns the zoom speed - virtual f32 getZoomSpeed() const; - - //! Set the zoom speed - virtual void setZoomSpeed(f32 zoomSpeed); - - //! This animator will receive events when attached to the active camera - virtual bool isEventReceiverEnabled() const - { - return true; - } - - //! Returns type of the scene node - virtual ESCENE_NODE_ANIMATOR_TYPE getType() const - { - return ESNAT_CAMERA_MAYA; - } - - //! Creates a clone of this animator. - /** Please note that you will have to drop - (IReferenceCounted::drop()) the returned pointer after calling - this. */ - virtual ISceneNodeAnimator* createClone(ISceneNode* node, ISceneManager* newManager=0); - - private: - - void allKeysUp(); - void animate(); - bool isMouseKeyDown(s32 key); - - bool MouseKeys[3]; - - gui::ICursorControl *CursorControl; - core::vector3df Pos; - bool Zooming; - bool Rotating; - bool Moving; - bool Translating; - f32 ZoomSpeed; - f32 RotateSpeed; - f32 TranslateSpeed; - core::position2df RotateStart; - core::position2df ZoomStart; - core::position2df TranslateStart; - f32 CurrentZoom; - f32 RotX, RotY; - core::vector3df OldTarget; - scene::ICameraSceneNode* OldCamera; - - core::position2df MousePos; - }; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorCollisionResponse.cpp b/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorCollisionResponse.cpp deleted file mode 100644 index 21ce37e4f..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorCollisionResponse.cpp +++ /dev/null @@ -1,303 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CSceneNodeAnimatorCollisionResponse.h" -#include "ISceneCollisionManager.h" -#include "ISceneManager.h" -#include "ICameraSceneNode.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CSceneNodeAnimatorCollisionResponse::CSceneNodeAnimatorCollisionResponse( - ISceneManager* scenemanager, - ITriangleSelector* world, ISceneNode* object, - const core::vector3df& ellipsoidRadius, - const core::vector3df& gravityPerSecond, - const core::vector3df& ellipsoidTranslation, - f32 slidingSpeed) -: Radius(ellipsoidRadius), Gravity(gravityPerSecond), Translation(ellipsoidTranslation), - World(world), Object(object), SceneManager(scenemanager), LastTime(0), - SlidingSpeed(slidingSpeed), CollisionCallback(0), - Falling(false), IsCamera(false), AnimateCameraTarget(true), CollisionOccurred(false), - FirstUpdate(true) -{ - #ifdef _DEBUG - setDebugName("CSceneNodeAnimatorCollisionResponse"); - #endif - - if (World) - World->grab(); - - setNode(Object); -} - - -//! destructor -CSceneNodeAnimatorCollisionResponse::~CSceneNodeAnimatorCollisionResponse() -{ - if (World) - World->drop(); - - if (CollisionCallback) - CollisionCallback->drop(); -} - - -//! Returns if the attached scene node is falling, which means that -//! there is no blocking wall from the scene node in the direction of -//! the gravity. -bool CSceneNodeAnimatorCollisionResponse::isFalling() const -{ - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return Falling; -} - - -//! Sets the radius of the ellipsoid with which collision detection and -//! response is done. -void CSceneNodeAnimatorCollisionResponse::setEllipsoidRadius( - const core::vector3df& radius) -{ - Radius = radius; - FirstUpdate = true; -} - - -//! Returns the radius of the ellipsoid with wich the collision detection and -//! response is done. -core::vector3df CSceneNodeAnimatorCollisionResponse::getEllipsoidRadius() const -{ - return Radius; -} - - -//! Sets the gravity of the environment. -void CSceneNodeAnimatorCollisionResponse::setGravity(const core::vector3df& gravity) -{ - Gravity = gravity; - FirstUpdate = true; -} - - -//! Returns current vector of gravity. -core::vector3df CSceneNodeAnimatorCollisionResponse::getGravity() const -{ - return Gravity; -} - - -//! 'Jump' the animator, by adding a jump speed opposite to its gravity -void CSceneNodeAnimatorCollisionResponse::jump(f32 jumpSpeed) -{ - FallingVelocity -= (core::vector3df(Gravity).normalize()) * jumpSpeed; - Falling = true; -} - - -//! Sets the translation of the ellipsoid for collision detection. -void CSceneNodeAnimatorCollisionResponse::setEllipsoidTranslation(const core::vector3df &translation) -{ - Translation = translation; -} - - -//! Returns the translation of the ellipsoid for collision detection. -core::vector3df CSceneNodeAnimatorCollisionResponse::getEllipsoidTranslation() const -{ - return Translation; -} - - -//! Sets a triangle selector holding all triangles of the world with which -//! the scene node may collide. -void CSceneNodeAnimatorCollisionResponse::setWorld(ITriangleSelector* newWorld) -{ - if (newWorld) - newWorld->grab(); - - if (World) - World->drop(); - - World = newWorld; - - FirstUpdate = true; -} - - -//! Returns the current triangle selector containing all triangles for -//! collision detection. -ITriangleSelector* CSceneNodeAnimatorCollisionResponse::getWorld() const -{ - return World; -} - - -void CSceneNodeAnimatorCollisionResponse::animateNode(ISceneNode* node, u32 timeMs) -{ - CollisionOccurred = false; - - if (node != Object) - setNode(node); - - if(!Object || !World) - return; - - // trigger reset - if ( timeMs == 0 ) - { - FirstUpdate = true; - timeMs = LastTime; - } - - if ( FirstUpdate ) - { - LastPosition = Object->getPosition(); - Falling = false; - LastTime = timeMs; - FallingVelocity.set ( 0, 0, 0 ); - - FirstUpdate = false; - } - - u32 diff = timeMs - LastTime; - LastTime = timeMs; - - CollisionResultPosition = Object->getPosition(); - core::vector3df vel = CollisionResultPosition - LastPosition; - - FallingVelocity += Gravity * (f32)diff * 0.001f; - - CollisionTriangle = RefTriangle; - CollisionPoint = core::vector3df(); - CollisionResultPosition = core::vector3df(); - CollisionNode = 0; - - core::vector3df force = vel + FallingVelocity; - - if ( AnimateCameraTarget ) - { - // TODO: divide SlidingSpeed by frame time - - bool f = false; - CollisionResultPosition - = SceneManager->getSceneCollisionManager()->getCollisionResultPosition( - World, LastPosition-Translation, - Radius, vel, CollisionTriangle, CollisionPoint, f, - CollisionNode, SlidingSpeed, FallingVelocity); - - CollisionOccurred = (CollisionTriangle != RefTriangle); - - CollisionResultPosition += Translation; - - if (f)//CollisionTriangle == RefTriangle) - { - Falling = true; - } - else - { - Falling = false; - FallingVelocity.set(0, 0, 0); - } - - bool collisionConsumed = false; - - if (CollisionOccurred && CollisionCallback) - collisionConsumed = CollisionCallback->onCollision(*this); - - if(!collisionConsumed) - Object->setPosition(CollisionResultPosition); - } - - // move camera target - if (AnimateCameraTarget && IsCamera) - { - const core::vector3df pdiff = Object->getPosition() - LastPosition - vel; - ICameraSceneNode* cam = (ICameraSceneNode*)Object; - cam->setTarget(cam->getTarget() + pdiff); - } - - LastPosition = Object->getPosition(); -} - - -void CSceneNodeAnimatorCollisionResponse::setNode(ISceneNode* node) -{ - Object = node; - - if (Object) - { - LastPosition = Object->getPosition(); - IsCamera = (Object->getType() == ESNT_CAMERA); - } - - LastTime = os::Timer::getTime(); -} - - -//! Writes attributes of the scene node animator. -void CSceneNodeAnimatorCollisionResponse::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const -{ - out->addVector3d("Radius", Radius); - out->addVector3d("Gravity", Gravity); - out->addVector3d("Translation", Translation); - out->addBool("AnimateCameraTarget", AnimateCameraTarget); -} - - -//! Reads attributes of the scene node animator. -void CSceneNodeAnimatorCollisionResponse::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - Radius = in->getAttributeAsVector3d("Radius"); - Gravity = in->getAttributeAsVector3d("Gravity"); - Translation = in->getAttributeAsVector3d("Translation"); - AnimateCameraTarget = in->getAttributeAsBool("AnimateCameraTarget"); -} - - -ISceneNodeAnimator* CSceneNodeAnimatorCollisionResponse::createClone(ISceneNode* node, ISceneManager* newManager) -{ - if (!newManager) newManager = SceneManager; - - CSceneNodeAnimatorCollisionResponse * newAnimator = - new CSceneNodeAnimatorCollisionResponse(newManager, World, Object, Radius, - (Gravity * 1000.0f), Translation, SlidingSpeed); - - return newAnimator; -} - -void CSceneNodeAnimatorCollisionResponse::setCollisionCallback(ICollisionCallback* callback) -{ - if ( CollisionCallback == callback ) - return; - - if (CollisionCallback) - CollisionCallback->drop(); - - CollisionCallback = callback; - - if (CollisionCallback) - CollisionCallback->grab(); -} - -//! Should the Target react on collision ( default = true ) -void CSceneNodeAnimatorCollisionResponse::setAnimateTarget ( bool enable ) -{ - AnimateCameraTarget = enable; - FirstUpdate = true; -} - -//! Should the Target react on collision ( default = true ) -bool CSceneNodeAnimatorCollisionResponse::getAnimateTarget () const -{ - return AnimateCameraTarget; -} - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorCollisionResponse.h b/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorCollisionResponse.h deleted file mode 100644 index f8d8e8ecd..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorCollisionResponse.h +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_SCENE_NODE_ANIMATOR_COLLISION_RESPONSE_H_INCLUDED__ -#define __C_SCENE_NODE_ANIMATOR_COLLISION_RESPONSE_H_INCLUDED__ - -#include "ISceneNodeAnimatorCollisionResponse.h" - -namespace irr -{ -namespace scene -{ - - //! Special scene node animator for doing automatic collision detection and response. - /** This scene node animator can be attached to any scene node modifying it in that - way, that it cannot move through walls of the world, is influenced by gravity and - acceleration. This animator is useful for example for first person shooter - games. Attach it for example to a first person shooter camera, and the camera will - behave as the player control in a first person shooter game: The camera stops and - slides at walls, walks up stairs, falls down if there is no floor under it, and so on. - */ - class CSceneNodeAnimatorCollisionResponse : public ISceneNodeAnimatorCollisionResponse - { - public: - - //! constructor - CSceneNodeAnimatorCollisionResponse(ISceneManager* scenemanager, - ITriangleSelector* world, ISceneNode* object, - const core::vector3df& ellipsoidRadius = core::vector3df(30,60,30), - const core::vector3df& gravityPerSecond = core::vector3df(0,-100.0f,0), - const core::vector3df& ellipsoidTranslation = core::vector3df(0,0,0), - f32 slidingSpeed = 0.0005f); - - //! destructor - virtual ~CSceneNodeAnimatorCollisionResponse(); - - //! Returns if the attached scene node is falling, which means that - //! there is no blocking wall from the scene node in the direction of - //! the gravity. - virtual bool isFalling() const; - - //! Sets the radius of the ellipsoid with which collision detection and - //! response is done. - virtual void setEllipsoidRadius(const core::vector3df& radius); - - //! Returns the radius of the ellipsoid with which the collision detection and - //! response is done. - virtual core::vector3df getEllipsoidRadius() const; - - //! Sets the gravity of the environment. - virtual void setGravity(const core::vector3df& gravity); - - //! 'Jump' the animator, by adding a jump speed opposite to its gravity - virtual void jump(f32 jumpSpeed); - - //! Should the Target react on collision ( default = true ) - virtual void setAnimateTarget ( bool enable ); - virtual bool getAnimateTarget () const; - - //! Returns current vector of gravity. - virtual core::vector3df getGravity() const; - - //! Sets the translation of the ellipsoid for collision detection. - virtual void setEllipsoidTranslation(const core::vector3df &translation); - - //! Returns the translation of the ellipsoid for collision detection. - virtual core::vector3df getEllipsoidTranslation() const; - - //! Sets a triangle selector holding all triangles of the world with which - //! the scene node may collide. - virtual void setWorld(ITriangleSelector* newWorld); - - //! Returns the current triangle selector containing all triangles for - //! collision detection. - virtual ITriangleSelector* getWorld() const; - - //! animates a scene node - virtual void animateNode(ISceneNode* node, u32 timeMs); - - //! Writes attributes of the scene node animator. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const; - - //! Reads attributes of the scene node animator. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - //! Returns type of the scene node animator - virtual ESCENE_NODE_ANIMATOR_TYPE getType() const { return ESNAT_COLLISION_RESPONSE; } - - //! Creates a clone of this animator. - /** Please note that you will have to drop - (IReferenceCounted::drop()) the returned pointer after calling - this. */ - virtual ISceneNodeAnimator* createClone(ISceneNode* node, ISceneManager* newManager=0); - - //! Set the single node that this animator will act on. - virtual void setTargetNode(ISceneNode * node) { setNode(node); } - - //! Gets the single node that this animator is acting on. - virtual ISceneNode* getTargetNode(void) const { return Object; } - - //! Returns true if a collision occurred during the last animateNode() - virtual bool collisionOccurred() const { return CollisionOccurred; } - - //! Returns the last point of collision. - virtual const core::vector3df & getCollisionPoint() const { return CollisionPoint; } - - //! Returns the last triangle that caused a collision. - virtual const core::triangle3df & getCollisionTriangle() const { return CollisionTriangle; } - - virtual const core::vector3df & getCollisionResultPosition(void) const { return CollisionResultPosition; } - - virtual const ISceneNode* getCollisionNode(void) const { return CollisionNode; } - - - //! Sets a callback interface which will be called if a collision occurs. - /** \param callback: collision callback handler that will be called when a collision - occurs. Set this to 0 to disable the callback. - */ - virtual void setCollisionCallback(ICollisionCallback* callback); - - private: - - void setNode(ISceneNode* node); - - core::vector3df Radius; - core::vector3df Gravity; - core::vector3df Translation; - core::vector3df FallingVelocity; // In the direction of Gravity. - - core::vector3df LastPosition; - core::triangle3df RefTriangle; - - ITriangleSelector* World; - ISceneNode* Object; - ISceneManager* SceneManager; - u32 LastTime; - f32 SlidingSpeed; - - core::vector3df CollisionPoint; - core::triangle3df CollisionTriangle; - core::vector3df CollisionResultPosition; - const ISceneNode * CollisionNode; - ICollisionCallback* CollisionCallback; - - bool Falling; - bool IsCamera; - bool AnimateCameraTarget; - bool CollisionOccurred; - bool FirstUpdate; - }; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorDelete.cpp b/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorDelete.cpp deleted file mode 100644 index 2925ab9bf..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorDelete.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CSceneNodeAnimatorDelete.h" -#include "ISceneManager.h" - -namespace irr -{ -namespace scene -{ - - -//! constructor -CSceneNodeAnimatorDelete::CSceneNodeAnimatorDelete(ISceneManager* manager, u32 time) -: ISceneNodeAnimatorFinishing(time), SceneManager(manager) -{ - #ifdef _DEBUG - setDebugName("CSceneNodeAnimatorDelete"); - #endif -} - - -//! animates a scene node -void CSceneNodeAnimatorDelete::animateNode(ISceneNode* node, u32 timeMs) -{ - if (timeMs > FinishTime) - { - HasFinished = true; - if(node && SceneManager) - { - // don't delete if scene manager is attached to an editor - if (!SceneManager->getParameters()->getAttributeAsBool(IRR_SCENE_MANAGER_IS_EDITOR)) - SceneManager->addToDeletionQueue(node); - } - } -} - - -ISceneNodeAnimator* CSceneNodeAnimatorDelete::createClone(ISceneNode* node, ISceneManager* newManager) -{ - CSceneNodeAnimatorDelete * newAnimator = - new CSceneNodeAnimatorDelete(SceneManager, FinishTime); - - return newAnimator; -} - - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorDelete.h b/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorDelete.h deleted file mode 100644 index 42332bcd2..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorDelete.h +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_SCENE_NODE_ANIMATOR_DELETE_H_INCLUDED__ -#define __C_SCENE_NODE_ANIMATOR_DELETE_H_INCLUDED__ - -#include "ISceneNodeAnimatorFinishing.h" - -namespace irr -{ -namespace scene -{ - class CSceneNodeAnimatorDelete : public ISceneNodeAnimatorFinishing - { - public: - - //! constructor - CSceneNodeAnimatorDelete(ISceneManager* manager, u32 when); - - //! animates a scene node - virtual void animateNode(ISceneNode* node, u32 timeMs); - - //! Returns type of the scene node animator - virtual ESCENE_NODE_ANIMATOR_TYPE getType() const - { - return ESNAT_DELETION; - } - - //! Creates a clone of this animator. - /** Please note that you will have to drop - (IReferenceCounted::drop()) the returned pointer after calling - this. */ - virtual ISceneNodeAnimator* createClone(ISceneNode* node, ISceneManager* newManager=0); - - private: - - ISceneManager* SceneManager; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorFlyCircle.cpp b/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorFlyCircle.cpp deleted file mode 100644 index 6cebaa062..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorFlyCircle.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CSceneNodeAnimatorFlyCircle.h" - -namespace irr -{ -namespace scene -{ - - -//! constructor -CSceneNodeAnimatorFlyCircle::CSceneNodeAnimatorFlyCircle(u32 time, - const core::vector3df& center, f32 radius, f32 speed, - const core::vector3df& direction, f32 radiusEllipsoid) - : Center(center), Direction(direction), Radius(radius), - RadiusEllipsoid(radiusEllipsoid), Speed(speed), StartTime(time) -{ - #ifdef _DEBUG - setDebugName("CSceneNodeAnimatorFlyCircle"); - #endif - init(); -} - - -void CSceneNodeAnimatorFlyCircle::init() -{ - Direction.normalize(); - - if (Direction.Y != 0) - VecV = core::vector3df(50,0,0).crossProduct(Direction).normalize(); - else - VecV = core::vector3df(0,50,0).crossProduct(Direction).normalize(); - VecU = VecV.crossProduct(Direction).normalize(); -} - - -//! animates a scene node -void CSceneNodeAnimatorFlyCircle::animateNode(ISceneNode* node, u32 timeMs) -{ - if ( 0 == node ) - return; - - f32 time; - - // Check for the condition where the StartTime is in the future. - if(StartTime > timeMs) - time = ((s32)timeMs - (s32)StartTime) * Speed; - else - time = (timeMs-StartTime) * Speed; - -// node->setPosition(Center + Radius * ((VecU*cosf(time)) + (VecV*sinf(time)))); - f32 r2 = RadiusEllipsoid == 0.f ? Radius : RadiusEllipsoid; - node->setPosition(Center + (Radius*cosf(time)*VecU) + (r2*sinf(time)*VecV ) ); -} - - -//! Writes attributes of the scene node animator. -void CSceneNodeAnimatorFlyCircle::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const -{ - out->addVector3d("Center", Center); - out->addFloat("Radius", Radius); - out->addFloat("Speed", Speed); - out->addVector3d("Direction", Direction); - out->addFloat("RadiusEllipsoid", Radius); -} - - -//! Reads attributes of the scene node animator. -void CSceneNodeAnimatorFlyCircle::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - Center = in->getAttributeAsVector3d("Center"); - Radius = in->getAttributeAsFloat("Radius"); - Speed = in->getAttributeAsFloat("Speed"); - Direction = in->getAttributeAsVector3d("Direction"); - StartTime = 0; - - if (Direction.equals(core::vector3df(0,0,0))) - Direction.set(0,1,0); // irrlicht 1.1 backwards compatibility - else - Direction.normalize(); - - RadiusEllipsoid = in->getAttributeAsFloat("RadiusEllipsoid"); - init(); -} - - -ISceneNodeAnimator* CSceneNodeAnimatorFlyCircle::createClone(ISceneNode* node, ISceneManager* newManager) -{ - CSceneNodeAnimatorFlyCircle * newAnimator = - new CSceneNodeAnimatorFlyCircle(StartTime, Center, Radius, Speed, Direction, RadiusEllipsoid); - - return newAnimator; -} - - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorFlyCircle.h b/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorFlyCircle.h deleted file mode 100644 index 3b6826da6..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorFlyCircle.h +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_SCENE_NODE_ANIMATOR_FLY_CIRCLE_H_INCLUDED__ -#define __C_SCENE_NODE_ANIMATOR_FLY_CIRCLE_H_INCLUDED__ - -#include "ISceneNode.h" - -namespace irr -{ -namespace scene -{ - class CSceneNodeAnimatorFlyCircle : public ISceneNodeAnimator - { - public: - - //! constructor - CSceneNodeAnimatorFlyCircle(u32 time, - const core::vector3df& center, f32 radius, - f32 speed, const core::vector3df& direction, - f32 radiusEllipsoid); - - //! animates a scene node - virtual void animateNode(ISceneNode* node, u32 timeMs); - - //! Writes attributes of the scene node animator. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const; - - //! Reads attributes of the scene node animator. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - //! Returns type of the scene node animator - virtual ESCENE_NODE_ANIMATOR_TYPE getType() const { return ESNAT_FLY_CIRCLE; } - - //! Creates a clone of this animator. - /** Please note that you will have to drop - (IReferenceCounted::drop()) the returned pointer after calling - this. */ - virtual ISceneNodeAnimator* createClone(ISceneNode* node, ISceneManager* newManager=0); - - private: - // do some initial calculations - void init(); - - // circle center - core::vector3df Center; - // up-vector, normal to the circle's plane - core::vector3df Direction; - // Two helper vectors - core::vector3df VecU; - core::vector3df VecV; - f32 Radius; - f32 RadiusEllipsoid; - f32 Speed; - u32 StartTime; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorFlyStraight.cpp b/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorFlyStraight.cpp deleted file mode 100644 index e120b4ba0..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorFlyStraight.cpp +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CSceneNodeAnimatorFlyStraight.h" - -namespace irr -{ -namespace scene -{ - - -//! constructor -CSceneNodeAnimatorFlyStraight::CSceneNodeAnimatorFlyStraight(const core::vector3df& startPoint, - const core::vector3df& endPoint, u32 timeForWay, - bool loop, u32 now, bool pingpong) -: ISceneNodeAnimatorFinishing(now + timeForWay), - Start(startPoint), End(endPoint), TimeFactor(0.0f), StartTime(now), - TimeForWay(timeForWay), Loop(loop), PingPong(pingpong) -{ - #ifdef _DEBUG - setDebugName("CSceneNodeAnimatorFlyStraight"); - #endif - - recalculateIntermediateValues(); -} - - -void CSceneNodeAnimatorFlyStraight::recalculateIntermediateValues() -{ - Vector = End - Start; - TimeFactor = (f32)Vector.getLength() / TimeForWay; - Vector.normalize(); -} - - -//! animates a scene node -void CSceneNodeAnimatorFlyStraight::animateNode(ISceneNode* node, u32 timeMs) -{ - if (!node) - return; - - u32 t = (timeMs-StartTime); - - core::vector3df pos = Start; - - if (!Loop && t >= TimeForWay) - { - pos = End; - HasFinished = true; - } - else - { - f32 phase = fmodf( (f32) t, (f32) TimeForWay ); - core::vector3df rel = Vector * phase * TimeFactor; - - if ( !PingPong || phase < TimeForWay * 0.5f ) - { - pos += rel; - } - else - { - pos = End - rel; - } - } - - node->setPosition(pos); -} - - -//! Writes attributes of the scene node animator. -void CSceneNodeAnimatorFlyStraight::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const -{ - out->addVector3d("Start", Start); - out->addVector3d("End", End); - out->addInt("TimeForWay", TimeForWay); - out->addBool("Loop", Loop); - out->addBool("PingPong", PingPong); -} - - -//! Reads attributes of the scene node animator. -void CSceneNodeAnimatorFlyStraight::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - Start = in->getAttributeAsVector3d("Start"); - End = in->getAttributeAsVector3d("End"); - TimeForWay = in->getAttributeAsInt("TimeForWay"); - Loop = in->getAttributeAsBool("Loop"); - PingPong = in->getAttributeAsBool("PingPong"); - - recalculateIntermediateValues(); -} - - -ISceneNodeAnimator* CSceneNodeAnimatorFlyStraight::createClone(ISceneNode* node, ISceneManager* newManager) -{ - CSceneNodeAnimatorFlyStraight * newAnimator = - new CSceneNodeAnimatorFlyStraight(Start, End, TimeForWay, Loop, StartTime, PingPong); - - return newAnimator; -} - - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorFlyStraight.h b/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorFlyStraight.h deleted file mode 100644 index 673b8f850..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorFlyStraight.h +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_SCENE_NODE_ANIMATOR_FLY_STRAIGHT_H_INCLUDED__ -#define __C_SCENE_NODE_ANIMATOR_FLY_STRAIGHT_H_INCLUDED__ - -#include "ISceneNodeAnimatorFinishing.h" - -namespace irr -{ -namespace scene -{ - class CSceneNodeAnimatorFlyStraight : public ISceneNodeAnimatorFinishing - { - public: - - //! constructor - CSceneNodeAnimatorFlyStraight(const core::vector3df& startPoint, - const core::vector3df& endPoint, - u32 timeForWay, - bool loop, u32 now, bool pingpong); - - //! animates a scene node - virtual void animateNode(ISceneNode* node, u32 timeMs); - - //! Writes attributes of the scene node animator. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const; - - //! Reads attributes of the scene node animator. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - //! Returns type of the scene node animator - virtual ESCENE_NODE_ANIMATOR_TYPE getType() const { return ESNAT_FLY_STRAIGHT; } - - //! Creates a clone of this animator. - /** Please note that you will have to drop - (IReferenceCounted::drop()) the returned pointer after calling this. */ - virtual ISceneNodeAnimator* createClone(ISceneNode* node, ISceneManager* newManager=0); - - private: - - void recalculateIntermediateValues(); - - core::vector3df Start; - core::vector3df End; - core::vector3df Vector; - f32 TimeFactor; - u32 StartTime; - u32 TimeForWay; - bool Loop; - bool PingPong; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorFollowSpline.cpp b/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorFollowSpline.cpp deleted file mode 100644 index adbb9c268..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorFollowSpline.cpp +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CSceneNodeAnimatorFollowSpline.h" - -namespace irr -{ -namespace scene -{ - - -//! constructor -CSceneNodeAnimatorFollowSpline::CSceneNodeAnimatorFollowSpline(u32 time, - const core::array<core::vector3df>& points, f32 speed, - f32 tightness) -: Points(points), Speed(speed), Tightness(tightness), StartTime(time) -{ - #ifdef _DEBUG - setDebugName("CSceneNodeAnimatorFollowSpline"); - #endif -} - - -inline s32 CSceneNodeAnimatorFollowSpline::clamp(s32 idx, s32 size) -{ - return ( idx<0 ? size+idx : ( idx>=size ? idx-size : idx ) ); -} - - -//! animates a scene node -void CSceneNodeAnimatorFollowSpline::animateNode(ISceneNode* node, u32 timeMs) -{ - if(!node) - return; - - const u32 pSize = Points.size(); - if (pSize==0) - return; - if (pSize==1) - { - node->setPosition(Points[0]); - return; - } - - const f32 dt = ( (timeMs-StartTime) * Speed * 0.001f ); - const f32 u = core::fract ( dt ); - const s32 idx = core::floor32( dt ) % pSize; - //const f32 u = 0.001f * fmodf( dt, 1000.0f ); - - const core::vector3df& p0 = Points[ clamp( idx - 1, pSize ) ]; - const core::vector3df& p1 = Points[ clamp( idx + 0, pSize ) ]; // starting point - const core::vector3df& p2 = Points[ clamp( idx + 1, pSize ) ]; // end point - const core::vector3df& p3 = Points[ clamp( idx + 2, pSize ) ]; - - // hermite polynomials - const f32 h1 = 2.0f * u * u * u - 3.0f * u * u + 1.0f; - const f32 h2 = -2.0f * u * u * u + 3.0f * u * u; - const f32 h3 = u * u * u - 2.0f * u * u + u; - const f32 h4 = u * u * u - u * u; - - // tangents - const core::vector3df t1 = ( p2 - p0 ) * Tightness; - const core::vector3df t2 = ( p3 - p1 ) * Tightness; - - // interpolated point - node->setPosition(p1 * h1 + p2 * h2 + t1 * h3 + t2 * h4); -} - - -//! Writes attributes of the scene node animator. -void CSceneNodeAnimatorFollowSpline::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const -{ - out->addFloat("Speed", Speed); - out->addFloat("Tightness", Tightness); - - u32 count = Points.size(); - - if ( options && (options->Flags & io::EARWF_FOR_EDITOR)) - { - // add one point in addition when serializing for editors - // to make it easier to add points quickly - count += 1; - } - - for (u32 i=0; i<count; ++i) - { - core::stringc tname = "Point"; - tname += (int)(i+1); - - out->addVector3d(tname.c_str(), i<Points.size() ? Points[i] : core::vector3df(0,0,0) ); - } -} - - -//! Reads attributes of the scene node animator. -void CSceneNodeAnimatorFollowSpline::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - Speed = in->getAttributeAsFloat("Speed"); - Tightness = in->getAttributeAsFloat("Tightness"); - Points.clear(); - - for(u32 i=1; true; ++i) - { - core::stringc pname = "Point"; - pname += i; - - if (in->existsAttribute(pname.c_str())) - Points.push_back(in->getAttributeAsVector3d(pname.c_str())); - else - break; - } - - // remove last point if double entry from editor - if ( options && (options->Flags & io::EARWF_FOR_EDITOR) && - Points.size() > 2 && Points.getLast() == core::vector3df(0,0,0)) - { - Points.erase(Points.size()-1); - - if (Points.size() > 2 && Points.getLast() == core::vector3df(0,0,0)) - Points.erase(Points.size()-1); - } -} - - -ISceneNodeAnimator* CSceneNodeAnimatorFollowSpline::createClone(ISceneNode* node, ISceneManager* newManager) -{ - CSceneNodeAnimatorFollowSpline * newAnimator = - new CSceneNodeAnimatorFollowSpline(StartTime, Points, Speed, Tightness); - - return newAnimator; -} - - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorFollowSpline.h b/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorFollowSpline.h deleted file mode 100644 index ce1087382..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorFollowSpline.h +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_SCENE_NODE_ANIMATOR_FOLLOW_SPLINE_H_INCLUDED__ -#define __C_SCENE_NODE_ANIMATOR_FOLLOW_SPLINE_H_INCLUDED__ - -#include "ISceneNode.h" -#include "irrArray.h" - -namespace irr -{ -namespace scene -{ - //! Scene node animator based free code Matthias Gall wrote and sent in. (Most of - //! this code is written by him, I only modified bits.) - class CSceneNodeAnimatorFollowSpline : public ISceneNodeAnimator - { - public: - - //! constructor - CSceneNodeAnimatorFollowSpline(u32 startTime, - const core::array< core::vector3df >& points, - f32 speed = 1.0f, f32 tightness = 0.5f); - - //! animates a scene node - virtual void animateNode(ISceneNode* node, u32 timeMs); - - //! Writes attributes of the scene node animator. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const; - - //! Reads attributes of the scene node animator. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - //! Returns type of the scene node animator - virtual ESCENE_NODE_ANIMATOR_TYPE getType() const { return ESNAT_FOLLOW_SPLINE; } - - //! Creates a clone of this animator. - /** Please note that you will have to drop - (IReferenceCounted::drop()) the returned pointer after calling - this. */ - virtual ISceneNodeAnimator* createClone(ISceneNode* node, ISceneManager* newManager=0); - - protected: - - //! clamps a the value idx to fit into range 0..size-1 - s32 clamp(s32 idx, s32 size); - - core::array< core::vector3df > Points; - f32 Speed; - f32 Tightness; - u32 StartTime; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorRotation.cpp b/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorRotation.cpp deleted file mode 100644 index 785a241d6..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorRotation.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CSceneNodeAnimatorRotation.h" - -namespace irr -{ -namespace scene -{ - - -//! constructor -CSceneNodeAnimatorRotation::CSceneNodeAnimatorRotation(u32 time, const core::vector3df& rotation) -: Rotation(rotation), StartTime(time) -{ - #ifdef _DEBUG - setDebugName("CSceneNodeAnimatorRotation"); - #endif -} - - -//! animates a scene node -void CSceneNodeAnimatorRotation::animateNode(ISceneNode* node, u32 timeMs) -{ - if (node) // thanks to warui for this fix - { - const u32 diffTime = timeMs - StartTime; - - if (diffTime != 0) - { - // clip the rotation to small values, to avoid - // precision problems with huge floats. - core::vector3df rot = node->getRotation() + Rotation*(diffTime*0.1f); - if (rot.X>360.f) - fmodf(rot.X, 360.f); - if (rot.Y>360.f) - fmodf(rot.Y, 360.f); - if (rot.Z>360.f) - fmodf(rot.Z, 360.f); - node->setRotation(rot); - StartTime=timeMs; - } - } -} - - -//! Writes attributes of the scene node animator. -void CSceneNodeAnimatorRotation::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const -{ - out->addVector3d("Rotation", Rotation); -} - - -//! Reads attributes of the scene node animator. -void CSceneNodeAnimatorRotation::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - Rotation = in->getAttributeAsVector3d("Rotation"); -} - - -ISceneNodeAnimator* CSceneNodeAnimatorRotation::createClone(ISceneNode* node, ISceneManager* newManager) -{ - CSceneNodeAnimatorRotation * newAnimator = - new CSceneNodeAnimatorRotation(StartTime, Rotation); - - return newAnimator; -} - - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorRotation.h b/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorRotation.h deleted file mode 100644 index ced746590..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorRotation.h +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_SCENE_NODE_ANIMATOR_ROTATION_H_INCLUDED__ -#define __C_SCENE_NODE_ANIMATOR_ROTATION_H_INCLUDED__ - -#include "ISceneNode.h" - -namespace irr -{ -namespace scene -{ - class CSceneNodeAnimatorRotation : public ISceneNodeAnimator - { - public: - - //! constructor - CSceneNodeAnimatorRotation(u32 time, const core::vector3df& rotation); - - //! animates a scene node - virtual void animateNode(ISceneNode* node, u32 timeMs); - - //! Writes attributes of the scene node animator. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const; - - //! Reads attributes of the scene node animator. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - //! Returns type of the scene node animator - virtual ESCENE_NODE_ANIMATOR_TYPE getType() const { return ESNAT_ROTATION; } - - //! Creates a clone of this animator. - /** Please note that you will have to drop - (IReferenceCounted::drop()) the returned pointer after calling this. */ - virtual ISceneNodeAnimator* createClone(ISceneNode* node, ISceneManager* newManager=0); - - private: - - core::vector3df Rotation; - u32 StartTime; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorTexture.cpp b/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorTexture.cpp deleted file mode 100644 index 9901afa66..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorTexture.cpp +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CSceneNodeAnimatorTexture.h" -#include "ITexture.h" - -namespace irr -{ -namespace scene -{ - - -//! constructor -CSceneNodeAnimatorTexture::CSceneNodeAnimatorTexture(const core::array<video::ITexture*>& textures, - s32 timePerFrame, bool loop, u32 now) -: ISceneNodeAnimatorFinishing(0), - TimePerFrame(timePerFrame), StartTime(now), Loop(loop) -{ - #ifdef _DEBUG - setDebugName("CSceneNodeAnimatorTexture"); - #endif - - for (u32 i=0; i<textures.size(); ++i) - { - if (textures[i]) - textures[i]->grab(); - - Textures.push_back(textures[i]); - } - - FinishTime = now + (timePerFrame * Textures.size()); -} - - -//! destructor -CSceneNodeAnimatorTexture::~CSceneNodeAnimatorTexture() -{ - clearTextures(); -} - - -void CSceneNodeAnimatorTexture::clearTextures() -{ - for (u32 i=0; i<Textures.size(); ++i) - if (Textures[i]) - Textures[i]->drop(); -} - - -//! animates a scene node -void CSceneNodeAnimatorTexture::animateNode(ISceneNode* node, u32 timeMs) -{ - if(!node) - return; - - if (Textures.size()) - { - const u32 t = (timeMs-StartTime); - - u32 idx = 0; - if (!Loop && timeMs >= FinishTime) - { - idx = Textures.size() - 1; - HasFinished = true; - } - else - { - idx = (t/TimePerFrame) % Textures.size(); - } - - if (idx < Textures.size()) - node->setMaterialTexture(0, Textures[idx]); - } -} - - -//! Writes attributes of the scene node animator. -void CSceneNodeAnimatorTexture::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const -{ - out->addInt("TimePerFrame", TimePerFrame); - out->addBool("Loop", Loop); - - // add one texture in addition when serializing for editors - // to make it easier to add textures quickly - - u32 count = Textures.size(); - if ( options && (options->Flags & io::EARWF_FOR_EDITOR)) - count += 1; - - for (u32 i=0; i<count; ++i) - { - core::stringc tname = "Texture"; - tname += (int)(i+1); - - out->addTexture(tname.c_str(), i<Textures.size() ? Textures[i] : 0); - } -} - - -//! Reads attributes of the scene node animator. -void CSceneNodeAnimatorTexture::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - TimePerFrame = in->getAttributeAsInt("TimePerFrame"); - Loop = in->getAttributeAsBool("Loop"); - - clearTextures(); - - for(u32 i=1; true; ++i) - { - core::stringc tname = "Texture"; - tname += (int)i; - - if (in->existsAttribute(tname.c_str())) - { - video::ITexture* tex = in->getAttributeAsTexture(tname.c_str()); - if (tex) - { - tex->grab(); - Textures.push_back(tex); - } - } - else - break; - } -} - - -ISceneNodeAnimator* CSceneNodeAnimatorTexture::createClone(ISceneNode* node, ISceneManager* newManager) -{ - CSceneNodeAnimatorTexture * newAnimator = - new CSceneNodeAnimatorTexture(Textures, TimePerFrame, Loop, StartTime); - - return newAnimator; -} - - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorTexture.h b/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorTexture.h deleted file mode 100644 index 04e9fec58..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSceneNodeAnimatorTexture.h +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_SCENE_NODE_ANIMATOR_TEXTURE_H_INCLUDED__ -#define __C_SCENE_NODE_ANIMATOR_TEXTURE_H_INCLUDED__ - -#include "irrArray.h" -#include "ISceneNodeAnimatorFinishing.h" - -namespace irr -{ -namespace scene -{ - class CSceneNodeAnimatorTexture : public ISceneNodeAnimatorFinishing - { - public: - - //! constructor - CSceneNodeAnimatorTexture(const core::array<video::ITexture*>& textures, - s32 timePerFrame, bool loop, u32 now); - - //! destructor - virtual ~CSceneNodeAnimatorTexture(); - - //! animates a scene node - virtual void animateNode(ISceneNode* node, u32 timeMs); - - //! Writes attributes of the scene node animator. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const; - - //! Reads attributes of the scene node animator. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - //! Returns type of the scene node animator - virtual ESCENE_NODE_ANIMATOR_TYPE getType() const { return ESNAT_TEXTURE; } - - //! Creates a clone of this animator. - /** Please note that you will have to drop - (IReferenceCounted::drop()) the returned pointer after calling - this. */ - virtual ISceneNodeAnimator* createClone(ISceneNode* node, ISceneManager* newManager=0); - - private: - - void clearTextures(); - - core::array<video::ITexture*> Textures; - u32 TimePerFrame; - u32 StartTime; - bool Loop; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CShadowVolumeSceneNode.cpp b/irrlicht-1.6/source/Irrlicht/CShadowVolumeSceneNode.cpp deleted file mode 100644 index 93335ff23..000000000 --- a/irrlicht-1.6/source/Irrlicht/CShadowVolumeSceneNode.cpp +++ /dev/null @@ -1,439 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CShadowVolumeSceneNode.h" -#include "ISceneManager.h" -#include "IMesh.h" -#include "IVideoDriver.h" -#include "SLight.h" - -namespace irr -{ -namespace scene -{ - - -//! constructor -CShadowVolumeSceneNode::CShadowVolumeSceneNode(const IMesh* shadowMesh, ISceneNode* parent, - ISceneManager* mgr, s32 id, bool zfailmethod, f32 infinity) -: IShadowVolumeSceneNode(parent, mgr, id), - ShadowMesh(0), IndexCount(0), VertexCount(0), ShadowVolumesUsed(0), - Infinity(infinity), UseZFailMethod(zfailmethod) -{ - #ifdef _DEBUG - setDebugName("CShadowVolumeSceneNode"); - #endif - setShadowMesh(shadowMesh); - setAutomaticCulling(scene::EAC_OFF); -} - - -//! destructor -CShadowVolumeSceneNode::~CShadowVolumeSceneNode() -{ - if (ShadowMesh) - ShadowMesh->drop(); - - for (u32 i=0; i<ShadowVolumes.size(); ++i) - delete [] ShadowVolumes[i].vertices; -} - - -void CShadowVolumeSceneNode::createShadowVolume(const core::vector3df& light) -{ - SShadowVolume* svp = 0; - - // builds the shadow volume and adds it to the shadow volume list. - - if (ShadowVolumes.size() > ShadowVolumesUsed) - { - // get the next unused buffer - svp = &ShadowVolumes[ShadowVolumesUsed]; - if (svp->size >= IndexCount*5) - svp->count = 0; - else - { - svp->size = IndexCount*5; - svp->count = 0; - delete [] svp->vertices; - svp->vertices = new core::vector3df[svp->size]; - } - - ++ShadowVolumesUsed; - } - else - { - // add a buffer - SShadowVolume tmp; - // lets make a rather large shadowbuffer - tmp.size = IndexCount*5; - tmp.count = 0; - tmp.vertices = new core::vector3df[tmp.size]; - ShadowVolumes.push_back(tmp); - svp = &ShadowVolumes[ShadowVolumes.size()-1]; - ++ShadowVolumesUsed; - } - - const u32 faceCount = IndexCount / 3; - - if (faceCount * 6 > Edges.size()) - Edges.set_used(faceCount*6); - - u32 numEdges = 0; - const core::vector3df ls = light * Infinity; // light scaled - - //if (UseZFailMethod) - // createZFailVolume(faceCount, numEdges, light, svp); - //else - // createZPassVolume(faceCount, numEdges, light, svp, false); - - // the createZFailVolume does currently not work 100% correctly, - // so we create createZPassVolume with caps if the zfail method - // is used - createZPassVolume(faceCount, numEdges, light, svp, UseZFailMethod); - - for (u32 i=0; i<numEdges; ++i) - { - core::vector3df &v1 = Vertices[Edges[2*i+0]]; - core::vector3df &v2 = Vertices[Edges[2*i+1]]; - core::vector3df v3(v1 - ls); - core::vector3df v4(v2 - ls); - - // Add a quad (two triangles) to the vertex list - if (svp->vertices && svp->count < svp->size-5) - { - svp->vertices[svp->count++] = v1; - svp->vertices[svp->count++] = v2; - svp->vertices[svp->count++] = v3; - - svp->vertices[svp->count++] = v2; - svp->vertices[svp->count++] = v4; - svp->vertices[svp->count++] = v3; - } - } -} - - -void CShadowVolumeSceneNode::createZFailVolume(s32 faceCount, u32& numEdges, - const core::vector3df& light, - SShadowVolume* svp) -{ - s32 i; - const core::vector3df ls = light * Infinity; - - // Check every face if it is front or back facing the light. - for (i=0; i<faceCount; ++i) - { - const u16 wFace0 = Indices[3*i+0]; - const u16 wFace1 = Indices[3*i+1]; - const u16 wFace2 = Indices[3*i+2]; - - const core::vector3df v0 = Vertices[wFace0]; - const core::vector3df v1 = Vertices[wFace1]; - const core::vector3df v2 = Vertices[wFace2]; - - if (core::triangle3df(v0,v1,v2).isFrontFacing(light)) - { - FaceData[i] = false; // it's a back facing face - - if (svp->vertices && svp->count < svp->size-5) - { - // add front cap - svp->vertices[svp->count++] = v0; - svp->vertices[svp->count++] = v2; - svp->vertices[svp->count++] = v1; - - // add back cap - svp->vertices[svp->count++] = v0 - ls; - svp->vertices[svp->count++] = v1 - ls; - svp->vertices[svp->count++] = v2 - ls; - } - } - else - FaceData[i] = true; // it's a front facing face - } - - for(i=0; i<faceCount; ++i) - { - if (FaceData[i] == true) - { - const u16 wFace0 = Indices[3*i+0]; - const u16 wFace1 = Indices[3*i+1]; - const u16 wFace2 = Indices[3*i+2]; - - const u16 adj0 = Adjacency[3*i+0]; - const u16 adj1 = Adjacency[3*i+1]; - const u16 adj2 = Adjacency[3*i+2]; - - if (adj0 != (u16)-1 && FaceData[adj0] == false) - { - // add edge v0-v1 - Edges[2*numEdges+0] = wFace0; - Edges[2*numEdges+1] = wFace1; - ++numEdges; - } - - if (adj1 != (u16)-1 && FaceData[adj1] == false) - { - // add edge v1-v2 - Edges[2*numEdges+0] = wFace1; - Edges[2*numEdges+1] = wFace2; - ++numEdges; - } - - if (adj2 != (u16)-1 && FaceData[adj2] == false) - { - // add edge v2-v0 - Edges[2*numEdges+0] = wFace2; - Edges[2*numEdges+1] = wFace0; - ++numEdges; - } - } - } -} - - -void CShadowVolumeSceneNode::createZPassVolume(s32 faceCount, - u32& numEdges, - core::vector3df light, - SShadowVolume* svp, bool caps) -{ - light *= Infinity; - if (light == core::vector3df(0,0,0)) - light = core::vector3df(0.0001f,0.0001f,0.0001f); - - for (s32 i=0; i<faceCount; ++i) - { - const u16 wFace0 = Indices[3*i+0]; - const u16 wFace1 = Indices[3*i+1]; - const u16 wFace2 = Indices[3*i+2]; - - if (core::triangle3df(Vertices[wFace0],Vertices[wFace1],Vertices[wFace2]).isFrontFacing(light)) - { - Edges[2*numEdges+0] = wFace0; - Edges[2*numEdges+1] = wFace1; - ++numEdges; - - Edges[2*numEdges+0] = wFace1; - Edges[2*numEdges+1] = wFace2; - ++numEdges; - - Edges[2*numEdges+0] = wFace2; - Edges[2*numEdges+1] = wFace0; - ++numEdges; - - if (caps && svp->vertices && svp->count < svp->size-5) - { - svp->vertices[svp->count++] = Vertices[wFace0]; - svp->vertices[svp->count++] = Vertices[wFace2]; - svp->vertices[svp->count++] = Vertices[wFace1]; - - svp->vertices[svp->count++] = Vertices[wFace0] - light; - svp->vertices[svp->count++] = Vertices[wFace1] - light; - svp->vertices[svp->count++] = Vertices[wFace2] - light; - } - } - } -} - - -void CShadowVolumeSceneNode::setShadowMesh(const IMesh* mesh) -{ - if ( ShadowMesh == mesh ) - return; - if (ShadowMesh) - ShadowMesh->drop(); - ShadowMesh = mesh; - if (ShadowMesh) - ShadowMesh->grab(); -} - - -void CShadowVolumeSceneNode::updateShadowVolumes() -{ - const u32 oldIndexCount = IndexCount; - const u32 oldVertexCount = VertexCount; - - VertexCount = 0; - IndexCount = 0; - ShadowVolumesUsed = 0; - - const IMesh* const mesh = ShadowMesh; - if (!mesh) - return; - - // calculate total amount of vertices and indices - - u32 i; - u32 totalVertices = 0; - u32 totalIndices = 0; - const u32 bufcnt = mesh->getMeshBufferCount(); - - for (i=0; i<bufcnt; ++i) - { - const IMeshBuffer* buf = mesh->getMeshBuffer(i); - totalIndices += buf->getIndexCount(); - totalVertices += buf->getVertexCount(); - } - - // allocate memory if necessary - - if (totalVertices > Vertices.size()) - Vertices.set_used(totalVertices); - - if (totalIndices > Indices.size()) - { - Indices.set_used(totalIndices); - - if (UseZFailMethod) - FaceData.set_used(totalIndices / 3); - } - - // copy mesh - - for (i=0; i<bufcnt; ++i) - { - const IMeshBuffer* buf = mesh->getMeshBuffer(i); - - const u16* idxp = buf->getIndices(); - const u16* idxpend = idxp + buf->getIndexCount(); - for (; idxp!=idxpend; ++idxp) - Indices[IndexCount++] = *idxp + VertexCount; - - const u32 vtxcnt = buf->getVertexCount(); - for (u32 j=0; j<vtxcnt; ++j) - Vertices[VertexCount++] = buf->getPosition(j); - } - - // recalculate adjacency if necessary - if (oldVertexCount != VertexCount && oldIndexCount != IndexCount && UseZFailMethod) - calculateAdjacency(); - - // create as much shadow volumes as there are lights but - // do not ignore the max light settings. - - const u32 lights = SceneManager->getVideoDriver()->getDynamicLightCount(); - core::matrix4 mat = Parent->getAbsoluteTransformation(); - mat.makeInverse(); - const core::vector3df parentpos = Parent->getAbsolutePosition(); - core::vector3df lpos; - - // TODO: Only correct for point lights. - for (i=0; i<lights; ++i) - { - const video::SLight& dl = SceneManager->getVideoDriver()->getDynamicLight(i); - lpos = dl.Position; - if (dl.CastShadows && - fabs((lpos - parentpos).getLengthSQ()) <= (dl.Radius*dl.Radius*4.0f)) - { - mat.transformVect(lpos); - createShadowVolume(lpos); - } - } -} - - -//! pre render method -void CShadowVolumeSceneNode::OnRegisterSceneNode() -{ - if (IsVisible) - { - SceneManager->registerNodeForRendering(this, scene::ESNRP_SHADOW); - ISceneNode::OnRegisterSceneNode(); - } -} - - -//! renders the node. -void CShadowVolumeSceneNode::render() -{ - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - - if (!ShadowVolumesUsed || !driver) - return; - - driver->setTransform(video::ETS_WORLD, Parent->getAbsoluteTransformation()); - - for (u32 i=0; i<ShadowVolumesUsed; ++i) - driver->drawStencilShadowVolume(ShadowVolumes[i].vertices, - ShadowVolumes[i].count, UseZFailMethod); - - if ( DebugDataVisible & scene::EDS_MESH_WIRE_OVERLAY ) - { - video::SMaterial mat; - mat.Lighting = false; - mat.Wireframe = true; - mat.ZBuffer = true; - driver->setMaterial(mat); - driver->setTransform(video::ETS_WORLD, core::IdentityMatrix); - - for (u32 i=0; i<ShadowVolumesUsed; ++i) - driver->drawVertexPrimitiveList(ShadowVolumes[i].vertices, - ShadowVolumes[i].count,0,0,video::EVT_STANDARD,scene::EPT_LINES); - } -} - - -//! returns the axis aligned bounding box of this node -const core::aabbox3d<f32>& CShadowVolumeSceneNode::getBoundingBox() const -{ - return Box; -} - - -//! Generates adjacency information based on mesh indices. -void CShadowVolumeSceneNode::calculateAdjacency(f32 epsilon) -{ - Adjacency.set_used(IndexCount); - - epsilon *= epsilon; - - // go through all faces and fetch their three neighbours - for (u32 f=0; f<IndexCount; f+=3) - { - for (u32 edge = 0; edge<3; ++edge) - { - core::vector3df v1 = Vertices[Indices[f+edge]]; - core::vector3df v2 = Vertices[Indices[f+((edge+1)%3)]]; - - // now we search an_O_ther _F_ace with these two - // vertices, which is not the current face. - - u32 of; - - for (of=0; of<IndexCount; of+=3) - { - if (of != f) - { - s32 cnt1 = 0; - s32 cnt2 = 0; - - for (s32 e=0; e<3; ++e) - { - const f32 t1 = v1.getDistanceFromSQ(Vertices[Indices[of+e]]); - if (core::iszero(t1)) - ++cnt1; - - const f32 t2 = v2.getDistanceFromSQ(Vertices[Indices[of+e]]); - if (core::iszero(t2)) - ++cnt2; - } - - if (cnt1 == 1 && cnt2 == 1) - break; - } - } - - if (of == IndexCount) - Adjacency[f + edge] = f; - else - Adjacency[f + edge] = of / 3; - } - } -} - - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CShadowVolumeSceneNode.h b/irrlicht-1.6/source/Irrlicht/CShadowVolumeSceneNode.h deleted file mode 100644 index b3854a82a..000000000 --- a/irrlicht-1.6/source/Irrlicht/CShadowVolumeSceneNode.h +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_SHADOW_VOLUME_SCENE_NODE_H_INCLUDED__ -#define __C_SHADOW_VOLUME_SCENE_NODE_H_INCLUDED__ - -#include "IShadowVolumeSceneNode.h" - -namespace irr -{ -namespace scene -{ - - //! Scene node for rendering a shadow volume into a stencil buffer. - class CShadowVolumeSceneNode : public IShadowVolumeSceneNode - { - public: - - //! constructor - CShadowVolumeSceneNode(const IMesh* shadowMesh, ISceneNode* parent, ISceneManager* mgr, - s32 id, bool zfailmethod=true, f32 infinity=10000.0f); - - //! destructor - virtual ~CShadowVolumeSceneNode(); - - //! Sets the mesh from which the shadow volume should be generated. - /** To optimize shadow rendering, use a simpler mesh for shadows. - */ - virtual void setShadowMesh(const IMesh* mesh); - - //! Updates the shadow volumes for current light positions. - virtual void updateShadowVolumes(); - - //! pre render method - virtual void OnRegisterSceneNode(); - - //! renders the node. - virtual void render(); - - //! returns the axis aligned bounding box of this node - virtual const core::aabbox3d<f32>& getBoundingBox() const; - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() const { return ESNT_SHADOW_VOLUME; } - - private: - - struct SShadowVolume - { - core::vector3df* vertices; - u32 count; - u32 size; - }; - - void createShadowVolume(const core::vector3df& pos); - void createZPassVolume(s32 faceCount, u32& numEdges, core::vector3df light, SShadowVolume* svp, bool caps); - void createZFailVolume(s32 faceCount, u32& numEdges, const core::vector3df& light, SShadowVolume* svp); - - //! Generates adjacency information based on mesh indices. - void calculateAdjacency(f32 epsilon=0.0001f); - - core::aabbox3d<f32> Box; - - // a shadow volume for every light - core::array<SShadowVolume> ShadowVolumes; - - core::array<core::vector3df> Vertices; - core::array<u16> Indices; - core::array<u16> Adjacency; - core::array<u16> Edges; - // used for zfail method, if face is front facing - core::array<bool> FaceData; - - const scene::IMesh* ShadowMesh; - - u32 IndexCount; - u32 VertexCount; - - u32 ShadowVolumesUsed; - - f32 Infinity; - - bool UseZFailMethod; - }; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CSkinnedMesh.cpp b/irrlicht-1.6/source/Irrlicht/CSkinnedMesh.cpp deleted file mode 100644 index 1ee487aa5..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSkinnedMesh.cpp +++ /dev/null @@ -1,1461 +0,0 @@ -// Copyright (C) 2002-2009 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_SKINNED_MESH_SUPPORT_ - -#include "CSkinnedMesh.h" -#include "CBoneSceneNode.h" -#include "IAnimatedMeshSceneNode.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - - -//! constructor -CSkinnedMesh::CSkinnedMesh() -: SkinningBuffers(0), AnimationFrames(0.f), - LastAnimatedFrame(0.f), LastSkinnedFrame(0.f), - InterpolationMode(EIM_LINEAR), - HasAnimation(false), PreparedForSkinning(false), - BoneControlUsed(false), AnimateNormals(true), HardwareSkinning(false) -{ - #ifdef _DEBUG - setDebugName("CSkinnedMesh"); - #endif - - SkinningBuffers=&LocalBuffers; -} - - -//! destructor -CSkinnedMesh::~CSkinnedMesh() -{ - for (u32 i=0; i<AllJoints.size(); ++i) - delete AllJoints[i]; - - for (u32 j=0; j<LocalBuffers.size(); ++j) - { - if (LocalBuffers[j]) - LocalBuffers[j]->drop(); - } -} - - -//! returns the amount of frames in milliseconds. -//! If the amount is 1, it is a static (=non animated) mesh. -u32 CSkinnedMesh::getFrameCount() const -{ - return core::floor32(AnimationFrames); -} - - -//! returns the animated mesh based on a detail level. 0 is the lowest, 255 the highest detail. Note, that some Meshes will ignore the detail level. -IMesh* CSkinnedMesh::getMesh(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop) -{ - //animate(frame,startFrameLoop, endFrameLoop); - if (frame==-1) - return this; - - animateMesh((f32)frame, 1.0f); - buildAll_LocalAnimatedMatrices(); - skinMesh(); - return this; -} - - -//-------------------------------------------------------------------------- -// Keyframe Animation -//-------------------------------------------------------------------------- - - -//! Animates this mesh's joints based on frame input -//! blend: {0-old position, 1-New position} -void CSkinnedMesh::animateMesh(f32 frame, f32 blend) -{ - if ( !HasAnimation || LastAnimatedFrame==frame) - return; - - LastAnimatedFrame=frame; - - if (blend<=0.f) - return; //No need to animate - - for (u32 i=0; i<AllJoints.size(); ++i) - { - //To Bitplane: The joints can be animated here with no input from their parents, but for setAnimationMode extra checks are needed to their parents - SJoint *joint = AllJoints[i]; - - const core::vector3df oldPosition = joint->Animatedposition; - const core::vector3df oldScale = joint->Animatedscale; - const core::quaternion oldRotation = joint->Animatedrotation; - - core::vector3df position = oldPosition; - core::vector3df scale = oldScale; - core::quaternion rotation = oldRotation; - - getFrameData(frame, joint, - position, joint->positionHint, - scale, joint->scaleHint, - rotation, joint->rotationHint); - - if (blend==1.0f) - { - //No blending needed - joint->Animatedposition = position; - joint->Animatedscale = scale; - joint->Animatedrotation = rotation; - } - else - { - //Blend animation - joint->Animatedposition = core::lerp(oldPosition, position, blend); - joint->Animatedscale = core::lerp(oldScale, scale, blend); - joint->Animatedrotation.slerp(oldRotation, rotation, blend); - } - - //Note: - //_LocalAnimatedMatrix needs to be built at some point, but this function may be called lots of times for - //one render (to play two animations at the same time) _LocalAnimatedMatrix only needs to be built once. - //a call to buildAllLocalAnimatedMatrices is needed before skinning the mesh, and before the user gets the joints to move - - //---------------- - // Temp! - buildAll_LocalAnimatedMatrices(); - //----------------- - } - - updateBoundingBox(); -} - - -void CSkinnedMesh::buildAll_LocalAnimatedMatrices() -{ - for (u32 i=0; i<AllJoints.size(); ++i) - { - SJoint *joint = AllJoints[i]; - - //Could be faster: - - if (joint->UseAnimationFrom && - (joint->UseAnimationFrom->PositionKeys.size() || - joint->UseAnimationFrom->ScaleKeys.size() || - joint->UseAnimationFrom->RotationKeys.size() )) - { - joint->LocalAnimatedMatrix=joint->Animatedrotation.getMatrix(); - - // --- joint->LocalAnimatedMatrix *= joint->Animatedrotation.getMatrix() --- - f32 *m1 = joint->LocalAnimatedMatrix.pointer(); - core::vector3df &Pos = joint->Animatedposition; - m1[0] += Pos.X*m1[3]; - m1[1] += Pos.Y*m1[3]; - m1[2] += Pos.Z*m1[3]; - m1[4] += Pos.X*m1[7]; - m1[5] += Pos.Y*m1[7]; - m1[6] += Pos.Z*m1[7]; - m1[8] += Pos.X*m1[11]; - m1[9] += Pos.Y*m1[11]; - m1[10] += Pos.Z*m1[11]; - m1[12] += Pos.X*m1[15]; - m1[13] += Pos.Y*m1[15]; - m1[14] += Pos.Z*m1[15]; - // ----------------------------------- - - joint->GlobalSkinningSpace=false; - - if (joint->ScaleKeys.size()) - { - /* - core::matrix4 scaleMatrix; - scaleMatrix.setScale(joint->Animatedscale); - joint->LocalAnimatedMatrix *= scaleMatrix; - */ - - // -------- joint->LocalAnimatedMatrix *= scaleMatrix ----------------- - core::matrix4& mat = joint->LocalAnimatedMatrix; - mat[0] *= joint->Animatedscale.X; - mat[1] *= joint->Animatedscale.X; - mat[2] *= joint->Animatedscale.X; - mat[3] *= joint->Animatedscale.X; - mat[4] *= joint->Animatedscale.Y; - mat[5] *= joint->Animatedscale.Y; - mat[6] *= joint->Animatedscale.Y; - mat[7] *= joint->Animatedscale.Y; - mat[8] *= joint->Animatedscale.Z; - mat[9] *= joint->Animatedscale.Z; - mat[10] *= joint->Animatedscale.Z; - mat[11] *= joint->Animatedscale.Z; - // ----------------------------------- - - } - } - else - { - joint->LocalAnimatedMatrix=joint->LocalMatrix; - } - } -} - - -void CSkinnedMesh::buildAll_GlobalAnimatedMatrices(SJoint *joint, SJoint *parentJoint) -{ - if (!joint) - { - for (u32 i=0; i<RootJoints.size(); ++i) - buildAll_GlobalAnimatedMatrices(RootJoints[i], 0); - return; - } - else - { - // Find global matrix... - if (!parentJoint || joint->GlobalSkinningSpace) - joint->GlobalAnimatedMatrix = joint->LocalAnimatedMatrix; - else - joint->GlobalAnimatedMatrix = parentJoint->GlobalAnimatedMatrix * joint->LocalAnimatedMatrix; - - } - - for (u32 j=0; j<joint->Children.size(); ++j) - buildAll_GlobalAnimatedMatrices(joint->Children[j], joint); -} - - -void CSkinnedMesh::getFrameData(f32 frame, SJoint *joint, - core::vector3df &position, s32 &positionHint, - core::vector3df &scale, s32 &scaleHint, - core::quaternion &rotation, s32 &rotationHint) -{ - s32 foundPositionIndex = -1; - s32 foundScaleIndex = -1; - s32 foundRotationIndex = -1; - - if (joint->UseAnimationFrom) - { - const core::array<SPositionKey> &PositionKeys=joint->UseAnimationFrom->PositionKeys; - const core::array<SScaleKey> &ScaleKeys=joint->UseAnimationFrom->ScaleKeys; - const core::array<SRotationKey> &RotationKeys=joint->UseAnimationFrom->RotationKeys; - - if (PositionKeys.size()) - { - foundPositionIndex = -1; - - //Test the Hints... - if (positionHint>=0 && (u32)positionHint < PositionKeys.size()) - { - //check this hint - if (positionHint>0 && PositionKeys[positionHint].frame>=frame && PositionKeys[positionHint-1].frame<frame ) - foundPositionIndex=positionHint; - else if (positionHint+1 < (s32)PositionKeys.size()) - { - //check the next index - if ( PositionKeys[positionHint+1].frame>=frame && - PositionKeys[positionHint+0].frame<frame) - { - positionHint++; - foundPositionIndex=positionHint; - } - } - } - - //The hint test failed, do a full scan... - if (foundPositionIndex==-1) - { - for (u32 i=0; i<PositionKeys.size(); ++i) - { - if (PositionKeys[i].frame >= frame) //Keys should to be sorted by frame - { - foundPositionIndex=i; - positionHint=i; - break; - } - } - } - - //Do interpolation... - if (foundPositionIndex!=-1) - { - if (InterpolationMode==EIM_CONSTANT || foundPositionIndex==0) - { - position = PositionKeys[foundPositionIndex].position; - } - else if (InterpolationMode==EIM_LINEAR) - { - const SPositionKey& KeyA = PositionKeys[foundPositionIndex]; - const SPositionKey& KeyB = PositionKeys[foundPositionIndex-1]; - - const f32 fd1 = frame - KeyA.frame; - const f32 fd2 = KeyB.frame - frame; - position = ((KeyB.position-KeyA.position)/(fd1+fd2))*fd1 + KeyA.position; - } - } - } - - //------------------------------------------------------------ - - if (ScaleKeys.size()) - { - foundScaleIndex = -1; - - //Test the Hints... - if (scaleHint>=0 && (u32)scaleHint < ScaleKeys.size()) - { - //check this hint - if (scaleHint>0 && ScaleKeys[scaleHint].frame>=frame && ScaleKeys[scaleHint-1].frame<frame ) - foundScaleIndex=scaleHint; - else if (scaleHint+1 < (s32)ScaleKeys.size()) - { - //check the next index - if ( ScaleKeys[scaleHint+1].frame>=frame && - ScaleKeys[scaleHint+0].frame<frame) - { - scaleHint++; - foundScaleIndex=scaleHint; - } - } - } - - - //The hint test failed, do a full scan... - if (foundScaleIndex==-1) - { - for (u32 i=0; i<ScaleKeys.size(); ++i) - { - if (ScaleKeys[i].frame >= frame) //Keys should to be sorted by frame - { - foundScaleIndex=i; - scaleHint=i; - break; - } - } - } - - //Do interpolation... - if (foundScaleIndex!=-1) - { - if (InterpolationMode==EIM_CONSTANT || foundScaleIndex==0) - { - scale = ScaleKeys[foundScaleIndex].scale; - } - else if (InterpolationMode==EIM_LINEAR) - { - const SScaleKey& KeyA = ScaleKeys[foundScaleIndex]; - const SScaleKey& KeyB = ScaleKeys[foundScaleIndex-1]; - - const f32 fd1 = frame - KeyA.frame; - const f32 fd2 = KeyB.frame - frame; - scale = ((KeyB.scale-KeyA.scale)/(fd1+fd2))*fd1 + KeyA.scale; - } - } - } - - //------------------------------------------------------------- - - if (RotationKeys.size()) - { - foundRotationIndex = -1; - - //Test the Hints... - if (rotationHint>=0 && (u32)rotationHint < RotationKeys.size()) - { - //check this hint - if (rotationHint>0 && RotationKeys[rotationHint].frame>=frame && RotationKeys[rotationHint-1].frame<frame ) - foundRotationIndex=rotationHint; - else if (rotationHint+1 < (s32)RotationKeys.size()) - { - //check the next index - if ( RotationKeys[rotationHint+1].frame>=frame && - RotationKeys[rotationHint+0].frame<frame) - { - rotationHint++; - foundRotationIndex=rotationHint; - } - } - } - - - //The hint test failed, do a full scan... - if (foundRotationIndex==-1) - { - for (u32 i=0; i<RotationKeys.size(); ++i) - { - if (RotationKeys[i].frame >= frame) //Keys should be sorted by frame - { - foundRotationIndex=i; - rotationHint=i; - break; - } - } - } - - //Do interpolation... - if (foundRotationIndex!=-1) - { - if (InterpolationMode==EIM_CONSTANT || foundRotationIndex==0) - { - rotation = RotationKeys[foundRotationIndex].rotation; - } - else if (InterpolationMode==EIM_LINEAR) - { - const SRotationKey& KeyA = RotationKeys[foundRotationIndex]; - const SRotationKey& KeyB = RotationKeys[foundRotationIndex-1]; - - const f32 fd1 = frame - KeyA.frame; - const f32 fd2 = KeyB.frame - frame; - const f32 t = fd1/(fd1+fd2); - - /* - f32 t = 0; - if (KeyA.frame!=KeyB.frame) - t = (frame-KeyA.frame) / (KeyB.frame - KeyA.frame); - */ - - rotation.slerp(KeyA.rotation, KeyB.rotation, t); - } - } - } - } -} - -//-------------------------------------------------------------------------- -// Software Skinning -//-------------------------------------------------------------------------- - -//! Preforms a software skin on this mesh based of joint positions -void CSkinnedMesh::skinMesh() -{ - if ( !HasAnimation) - return; - - //---------------- - // This is marked as "Temp!". A shiny dubloon to whomever can tell me why. - buildAll_GlobalAnimatedMatrices(); - //----------------- - - if (!HardwareSkinning) - { - //Software skin.... - u32 i; - - //rigid animation - for (i=0; i<AllJoints.size(); ++i) - { - for (u32 j=0; j<AllJoints[i]->AttachedMeshes.size(); ++j) - { - SSkinMeshBuffer* Buffer=(*SkinningBuffers)[ AllJoints[i]->AttachedMeshes[j] ]; - Buffer->Transformation=AllJoints[i]->GlobalAnimatedMatrix; - } - } - - //clear skinning helper array - for (i=0; i<Vertices_Moved.size(); ++i) - for (u32 j=0; j<Vertices_Moved[i].size(); ++j) - Vertices_Moved[i][j]=false; - - //skin starting with the root joints - for (i=0; i<RootJoints.size(); ++i) - SkinJoint(RootJoints[i], 0); - - for (i=0; i<SkinningBuffers->size(); ++i) - (*SkinningBuffers)[i]->setDirty(EBT_VERTEX); - } -} - - -void CSkinnedMesh::SkinJoint(SJoint *joint, SJoint *parentJoint) -{ - if (joint->Weights.size()) - { - //Find this joints pull on vertices... - core::matrix4 jointVertexPull(core::matrix4::EM4CONST_NOTHING); - jointVertexPull.setbyproduct(joint->GlobalAnimatedMatrix, joint->GlobalInversedMatrix); - - core::vector3df thisVertexMove, thisNormalMove; - - core::array<scene::SSkinMeshBuffer*> &buffersUsed=*SkinningBuffers; - - //Skin Vertices Positions and Normals... - for (u32 i=0; i<joint->Weights.size(); ++i) - { - SWeight& weight = joint->Weights[i]; - - // Pull this vertex... - jointVertexPull.transformVect(thisVertexMove, weight.StaticPos); - - if (AnimateNormals) - jointVertexPull.rotateVect(thisNormalMove, weight.StaticNormal); - - if (! (*(weight.Moved)) ) - { - *(weight.Moved) = true; - - buffersUsed[weight.buffer_id]->getVertex(weight.vertex_id)->Pos = thisVertexMove * weight.strength; - - if (AnimateNormals) - buffersUsed[weight.buffer_id]->getVertex(weight.vertex_id)->Normal = thisNormalMove * weight.strength; - - //*(weight._Pos) = thisVertexMove * weight.strength; - } - else - { - buffersUsed[weight.buffer_id]->getVertex(weight.vertex_id)->Pos += thisVertexMove * weight.strength; - - if (AnimateNormals) - buffersUsed[weight.buffer_id]->getVertex(weight.vertex_id)->Normal += thisNormalMove * weight.strength; - - //*(weight._Pos) += thisVertexMove * weight.strength; - } - - buffersUsed[weight.buffer_id]->boundingBoxNeedsRecalculated(); - } - } - - //Skin all children - for (u32 j=0; j<joint->Children.size(); ++j) - SkinJoint(joint->Children[j], joint); -} - - -E_ANIMATED_MESH_TYPE CSkinnedMesh::getMeshType() const -{ - return EAMT_SKINNED; -} - - -//! Gets joint count. -u32 CSkinnedMesh::getJointCount() const -{ - return AllJoints.size(); -} - - -//! Gets the name of a joint. -const c8* CSkinnedMesh::getJointName(u32 number) const -{ - if (number >= AllJoints.size()) - return 0; - return AllJoints[number]->Name.c_str(); -} - - -//! Gets a joint number from its name -s32 CSkinnedMesh::getJointNumber(const c8* name) const -{ - for (u32 i=0; i<AllJoints.size(); ++i) - { - if (AllJoints[i]->Name == name) - return i; - } - - return -1; -} - - -//! returns amount of mesh buffers. -u32 CSkinnedMesh::getMeshBufferCount() const -{ - return LocalBuffers.size(); -} - - -//! returns pointer to a mesh buffer -IMeshBuffer* CSkinnedMesh::getMeshBuffer(u32 nr) const -{ - if (nr < LocalBuffers.size()) - return LocalBuffers[nr]; - else - return 0; -} - - -//! Returns pointer to a mesh buffer which fits a material -IMeshBuffer* CSkinnedMesh::getMeshBuffer(const video::SMaterial &material) const -{ - for (u32 i=0; i<LocalBuffers.size(); ++i) - { - if (LocalBuffers[i]->getMaterial() == material) - return LocalBuffers[i]; - } - return 0; -} - - -//! returns an axis aligned bounding box -const core::aabbox3d<f32>& CSkinnedMesh::getBoundingBox() const -{ - return BoundingBox; -} - - -//! set user axis aligned bounding box -void CSkinnedMesh::setBoundingBox( const core::aabbox3df& box) -{ - BoundingBox = box; -} - - -//! sets a flag of all contained materials to a new value -void CSkinnedMesh::setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue) -{ - for (u32 i=0; i<LocalBuffers.size(); ++i) - LocalBuffers[i]->Material.setFlag(flag,newvalue); -} - - -//! set the hardware mapping hint, for driver -void CSkinnedMesh::setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint, - E_BUFFER_TYPE buffer) -{ - for (u32 i=0; i<LocalBuffers.size(); ++i) - LocalBuffers[i]->setHardwareMappingHint(newMappingHint, buffer); -} - - -//! flags the meshbuffer as changed, reloads hardware buffers -void CSkinnedMesh::setDirty(E_BUFFER_TYPE buffer) -{ - for (u32 i=0; i<LocalBuffers.size(); ++i) - LocalBuffers[i]->setDirty(buffer); -} - - -//! uses animation from another mesh -bool CSkinnedMesh::useAnimationFrom(const ISkinnedMesh *mesh) -{ - bool unmatched=false; - - for(u32 i=0;i<AllJoints.size();++i) - { - SJoint *joint=AllJoints[i]; - joint->UseAnimationFrom=0; - - if (joint->Name=="") - unmatched=true; - else - { - for(u32 j=0;j<mesh->getAllJoints().size();++j) - { - SJoint *otherJoint=mesh->getAllJoints()[j]; - if (joint->Name==otherJoint->Name) - { - joint->UseAnimationFrom=otherJoint; - } - } - if (!joint->UseAnimationFrom) - unmatched=true; - } - } - - checkForAnimation(); - - return !unmatched; -} - - -//!Update Normals when Animating -//!False= Don't animate them, faster -//!True= Update normals (default) -void CSkinnedMesh::updateNormalsWhenAnimating(bool on) -{ - AnimateNormals = on; -} - - -//!Sets Interpolation Mode -void CSkinnedMesh::setInterpolationMode(E_INTERPOLATION_MODE mode) -{ - InterpolationMode = mode; -} - - -core::array<scene::SSkinMeshBuffer*> &CSkinnedMesh::getMeshBuffers() -{ - return LocalBuffers; -} - - -core::array<CSkinnedMesh::SJoint*> &CSkinnedMesh::getAllJoints() -{ - return AllJoints; -} - - -const core::array<CSkinnedMesh::SJoint*> &CSkinnedMesh::getAllJoints() const -{ - return AllJoints; -} - - -//! (This feature is not implementated in irrlicht yet) -bool CSkinnedMesh::setHardwareSkinning(bool on) -{ - if (HardwareSkinning!=on) - { - - if (on) - { - - //set mesh to static pose... - for (u32 i=0; i<AllJoints.size(); ++i) - { - SJoint *joint=AllJoints[i]; - for (u32 j=0; j<joint->Weights.size(); ++j) - { - const u16 buffer_id=joint->Weights[j].buffer_id; - const u32 vertex_id=joint->Weights[j].vertex_id; - LocalBuffers[buffer_id]->getVertex(vertex_id)->Pos = joint->Weights[j].StaticPos; - LocalBuffers[buffer_id]->getVertex(vertex_id)->Normal = joint->Weights[j].StaticNormal; - LocalBuffers[buffer_id]->boundingBoxNeedsRecalculated(); - } - } - } - - HardwareSkinning=on; - } - return HardwareSkinning; -} - - -void CSkinnedMesh::CalculateGlobalMatrices(SJoint *joint,SJoint *parentJoint) -{ - if (!joint && parentJoint) // bit of protection from endless loops - return; - - //Go through the root bones - if (!joint) - { - for (u32 i=0; i<RootJoints.size(); ++i) - CalculateGlobalMatrices(RootJoints[i],0); - return; - } - - if (!parentJoint) - joint->GlobalMatrix = joint->LocalMatrix; - else - joint->GlobalMatrix = parentJoint->GlobalMatrix * joint->LocalMatrix; - - joint->LocalAnimatedMatrix=joint->LocalMatrix; - joint->GlobalAnimatedMatrix=joint->GlobalMatrix; - - if (joint->GlobalInversedMatrix.isIdentity())//might be pre calculated - { - joint->GlobalInversedMatrix = joint->GlobalMatrix; - joint->GlobalInversedMatrix.makeInverse(); // slow - } - - for (u32 j=0; j<joint->Children.size(); ++j) - CalculateGlobalMatrices(joint->Children[j],joint); -} - - -void CSkinnedMesh::checkForAnimation() -{ - u32 i,j; - //Check for animation... - HasAnimation = false; - for(i=0;i<AllJoints.size();++i) - { - if (AllJoints[i]->UseAnimationFrom) - { - if (AllJoints[i]->UseAnimationFrom->PositionKeys.size() || - AllJoints[i]->UseAnimationFrom->ScaleKeys.size() || - AllJoints[i]->UseAnimationFrom->RotationKeys.size() ) - { - HasAnimation = true; - } - } - } - - //meshes with weights, are still counted as animated for ragdolls, etc - if (!HasAnimation) - { - for(i=0;i<AllJoints.size();++i) - { - if (AllJoints[i]->Weights.size()) - HasAnimation = true; - } - } - - if (HasAnimation) - { - //--- Find the length of the animation --- - AnimationFrames=0; - for(i=0;i<AllJoints.size();++i) - { - if (AllJoints[i]->UseAnimationFrom) - { - if (AllJoints[i]->UseAnimationFrom->PositionKeys.size()) - if (AllJoints[i]->UseAnimationFrom->PositionKeys.getLast().frame > AnimationFrames) - AnimationFrames=AllJoints[i]->UseAnimationFrom->PositionKeys.getLast().frame; - - if (AllJoints[i]->UseAnimationFrom->ScaleKeys.size()) - if (AllJoints[i]->UseAnimationFrom->ScaleKeys.getLast().frame > AnimationFrames) - AnimationFrames=AllJoints[i]->UseAnimationFrom->ScaleKeys.getLast().frame; - - if (AllJoints[i]->UseAnimationFrom->RotationKeys.size()) - if (AllJoints[i]->UseAnimationFrom->RotationKeys.getLast().frame > AnimationFrames) - AnimationFrames=AllJoints[i]->UseAnimationFrom->RotationKeys.getLast().frame; - } - } - } - - if (HasAnimation && !PreparedForSkinning) - { - PreparedForSkinning=true; - - //check for bugs: - for(i=0; i < AllJoints.size(); ++i) - { - SJoint *joint = AllJoints[i]; - for (j=0; j<joint->Weights.size(); ++j) - { - const u16 buffer_id=joint->Weights[j].buffer_id; - const u32 vertex_id=joint->Weights[j].vertex_id; - - //check for invalid ids - if (buffer_id>=LocalBuffers.size()) - { - os::Printer::log("Skinned Mesh: Weight buffer id too large", ELL_WARNING); - joint->Weights[j].buffer_id = joint->Weights[j].vertex_id =0; - } - else if (vertex_id>=LocalBuffers[buffer_id]->getVertexCount()) - { - os::Printer::log("Skinned Mesh: Weight vertex id too large", ELL_WARNING); - joint->Weights[j].buffer_id = joint->Weights[j].vertex_id =0; - } - } - } - - //An array used in skinning - - for (i=0; i<Vertices_Moved.size(); ++i) - for (j=0; j<Vertices_Moved[i].size(); ++j) - Vertices_Moved[i][j] = false; - - // For skinning: cache weight values for speed - - for (i=0; i<AllJoints.size(); ++i) - { - SJoint *joint = AllJoints[i]; - for (j=0; j<joint->Weights.size(); ++j) - { - const u16 buffer_id=joint->Weights[j].buffer_id; - const u32 vertex_id=joint->Weights[j].vertex_id; - - joint->Weights[j].Moved = &Vertices_Moved[buffer_id] [vertex_id]; - joint->Weights[j].StaticPos = LocalBuffers[buffer_id]->getVertex(vertex_id)->Pos; - joint->Weights[j].StaticNormal = LocalBuffers[buffer_id]->getVertex(vertex_id)->Normal; - - //joint->Weights[j]._Pos=&Buffers[buffer_id]->getVertex(vertex_id)->Pos; - } - } - - // normalize weights - normalizeWeights(); - } -} - - -//! called by loader after populating with mesh and bone data -void CSkinnedMesh::finalize() -{ - u32 i; - - LastAnimatedFrame=-1; - LastSkinnedFrame=-1; - - //calculate bounding box - for (i=0; i<LocalBuffers.size(); ++i) - { - LocalBuffers[i]->recalculateBoundingBox(); - } - - if (AllJoints.size() || RootJoints.size()) - { - // populate AllJoints or RootJoints, depending on which is empty - if (!RootJoints.size()) - { - - for(u32 CheckingIdx=0; CheckingIdx < AllJoints.size(); ++CheckingIdx) - { - - bool foundParent=false; - for(i=0; i < AllJoints.size(); ++i) - { - for(u32 n=0; n < AllJoints[i]->Children.size(); ++n) - { - if (AllJoints[i]->Children[n] == AllJoints[CheckingIdx]) - foundParent=true; - } - } - - if (!foundParent) - RootJoints.push_back(AllJoints[CheckingIdx]); - } - } - else - { - AllJoints=RootJoints; - } - } - - for(i=0; i < AllJoints.size(); ++i) - { - AllJoints[i]->UseAnimationFrom=AllJoints[i]; - } - - //Set array sizes... - - for (i=0; i<LocalBuffers.size(); ++i) - { - Vertices_Moved.push_back( core::array<bool>() ); - Vertices_Moved[i].set_used(LocalBuffers[i]->getVertexCount()); - } - - //Todo: optimise keys here... - - checkForAnimation(); - - if (HasAnimation) - { - //--- optimize and check keyframes --- - for(i=0;i<AllJoints.size();++i) - { - core::array<SPositionKey> &PositionKeys =AllJoints[i]->PositionKeys; - core::array<SScaleKey> &ScaleKeys = AllJoints[i]->ScaleKeys; - core::array<SRotationKey> &RotationKeys = AllJoints[i]->RotationKeys; - - if (PositionKeys.size()>2) - { - for(u32 j=0;j<PositionKeys.size()-2;++j) - { - if (PositionKeys[j].position == PositionKeys[j+1].position && PositionKeys[j+1].position == PositionKeys[j+2].position) - { - PositionKeys.erase(j+1); //the middle key is unneeded - --j; - } - } - } - - if (PositionKeys.size()>1) - { - for(u32 j=0;j<PositionKeys.size()-1;++j) - { - if (PositionKeys[j].frame >= PositionKeys[j+1].frame) //bad frame, unneed and may cause problems - { - PositionKeys.erase(j+1); - --j; - } - } - } - - if (ScaleKeys.size()>2) - { - for(u32 j=0;j<ScaleKeys.size()-2;++j) - { - if (ScaleKeys[j].scale == ScaleKeys[j+1].scale && ScaleKeys[j+1].scale == ScaleKeys[j+2].scale) - { - ScaleKeys.erase(j+1); //the middle key is unneeded - --j; - } - } - } - - if (ScaleKeys.size()>1) - { - for(u32 j=0;j<ScaleKeys.size()-1;++j) - { - if (ScaleKeys[j].frame >= ScaleKeys[j+1].frame) //bad frame, unneed and may cause problems - { - ScaleKeys.erase(j+1); - --j; - } - } - } - - if (RotationKeys.size()>2) - { - for(u32 j=0;j<RotationKeys.size()-2;++j) - { - if (RotationKeys[j].rotation == RotationKeys[j+1].rotation && RotationKeys[j+1].rotation == RotationKeys[j+2].rotation) - { - RotationKeys.erase(j+1); //the middle key is unneeded - --j; - } - } - } - - if (RotationKeys.size()>1) - { - for(u32 j=0;j<RotationKeys.size()-1;++j) - { - if (RotationKeys[j].frame >= RotationKeys[j+1].frame) //bad frame, unneed and may cause problems - { - RotationKeys.erase(j+1); - --j; - } - } - } - - - //Fill empty keyframe areas - if (PositionKeys.size()) - { - SPositionKey *Key; - Key=&PositionKeys[0];//getFirst - if (Key->frame!=0) - { - PositionKeys.push_front(*Key); - Key=&PositionKeys[0];//getFirst - Key->frame=0; - } - - Key=&PositionKeys.getLast(); - if (Key->frame!=AnimationFrames) - { - PositionKeys.push_back(*Key); - Key=&PositionKeys.getLast(); - Key->frame=AnimationFrames; - } - } - - if (ScaleKeys.size()) - { - SScaleKey *Key; - Key=&ScaleKeys[0];//getFirst - if (Key->frame!=0) - { - ScaleKeys.push_front(*Key); - Key=&ScaleKeys[0];//getFirst - Key->frame=0; - } - - Key=&ScaleKeys.getLast(); - if (Key->frame!=AnimationFrames) - { - ScaleKeys.push_back(*Key); - Key=&ScaleKeys.getLast(); - Key->frame=AnimationFrames; - } - } - - if (RotationKeys.size()) - { - SRotationKey *Key; - Key=&RotationKeys[0];//getFirst - if (Key->frame!=0) - { - RotationKeys.push_front(*Key); - Key=&RotationKeys[0];//getFirst - Key->frame=0; - } - - Key=&RotationKeys.getLast(); - if (Key->frame!=AnimationFrames) - { - RotationKeys.push_back(*Key); - Key=&RotationKeys.getLast(); - Key->frame=AnimationFrames; - } - } - } - } - - //Needed for animation and skinning... - - CalculateGlobalMatrices(0,0); - - //animateMesh(0, 1); - //buildAll_LocalAnimatedMatrices(); - //buildAll_GlobalAnimatedMatrices(); - - //rigid animation for non animated meshes - for (i=0; i<AllJoints.size(); ++i) - { - for (u32 j=0; j<AllJoints[i]->AttachedMeshes.size(); ++j) - { - SSkinMeshBuffer* Buffer=(*SkinningBuffers)[ AllJoints[i]->AttachedMeshes[j] ]; - Buffer->Transformation=AllJoints[i]->GlobalAnimatedMatrix; - } - } - - //calculate bounding box - if (LocalBuffers.empty()) - BoundingBox.reset(0,0,0); - else - { - irr::core::aabbox3df bb(LocalBuffers[0]->BoundingBox); - LocalBuffers[0]->Transformation.transformBoxEx(bb); - BoundingBox.reset(bb); - - for (u32 j=1; j<LocalBuffers.size(); ++j) - { - bb = LocalBuffers[j]->BoundingBox; - LocalBuffers[j]->Transformation.transformBoxEx(bb); - - BoundingBox.addInternalBox(bb); - } - } -} - - -void CSkinnedMesh::updateBoundingBox(void) -{ - if(!SkinningBuffers) - return; - - core::array<SSkinMeshBuffer*> & buffer = *SkinningBuffers; - BoundingBox.reset(0,0,0); - - if (!buffer.empty()) - { - for (u32 j=0; j<buffer.size(); ++j) - { - buffer[j]->recalculateBoundingBox(); - core::aabbox3df bb = buffer[j]->BoundingBox; - buffer[j]->Transformation.transformBoxEx(bb); - - BoundingBox.addInternalBox(bb); - } - } -} - - -scene::SSkinMeshBuffer *CSkinnedMesh::addMeshBuffer() -{ - scene::SSkinMeshBuffer *buffer=new scene::SSkinMeshBuffer(); - LocalBuffers.push_back(buffer); - return buffer; -} - - -CSkinnedMesh::SJoint *CSkinnedMesh::addJoint(SJoint *parent) -{ - SJoint *joint=new SJoint; - - AllJoints.push_back(joint); - if (!parent) - { - //Add root joints to array in finalize() - } - else - { - //Set parent (Be careful of the mesh loader also setting the parent) - parent->Children.push_back(joint); - } - - return joint; -} - - -CSkinnedMesh::SPositionKey *CSkinnedMesh::addPositionKey(SJoint *joint) -{ - if (!joint) - return 0; - - joint->PositionKeys.push_back(SPositionKey()); - return &joint->PositionKeys.getLast(); -} - - -CSkinnedMesh::SScaleKey *CSkinnedMesh::addScaleKey(SJoint *joint) -{ - if (!joint) - return 0; - - joint->ScaleKeys.push_back(SScaleKey()); - return &joint->ScaleKeys.getLast(); -} - - -CSkinnedMesh::SRotationKey *CSkinnedMesh::addRotationKey(SJoint *joint) -{ - if (!joint) - return 0; - - joint->RotationKeys.push_back(SRotationKey()); - return &joint->RotationKeys.getLast(); -} - - -CSkinnedMesh::SWeight *CSkinnedMesh::addWeight(SJoint *joint) -{ - if (!joint) - return 0; - - joint->Weights.push_back(SWeight()); - return &joint->Weights.getLast(); -} - - -bool CSkinnedMesh::isStatic() -{ - return !HasAnimation; -} - - -void CSkinnedMesh::normalizeWeights() -{ - // note: unsure if weights ids are going to be used. - - // Normalise the weights on bones.... - - u32 i,j; - core::array< core::array<f32> > Vertices_TotalWeight; - - for (i=0; i<LocalBuffers.size(); ++i) - { - Vertices_TotalWeight.push_back(core::array<f32>()); - Vertices_TotalWeight[i].set_used(LocalBuffers[i]->getVertexCount()); - } - - for (i=0; i<Vertices_TotalWeight.size(); ++i) - for (j=0; j<Vertices_TotalWeight[i].size(); ++j) - Vertices_TotalWeight[i][j] = 0; - - for (i=0; i<AllJoints.size(); ++i) - { - SJoint *joint=AllJoints[i]; - for (j=0; j<joint->Weights.size(); ++j) - { - if (joint->Weights[j].strength<=0)//Check for invalid weights - { - joint->Weights.erase(j); - --j; - } - else - { - Vertices_TotalWeight[ joint->Weights[j].buffer_id ] [ joint->Weights[j].vertex_id ] += joint->Weights[j].strength; - } - } - } - - for (i=0; i<AllJoints.size(); ++i) - { - SJoint *joint=AllJoints[i]; - for (j=0; j< joint->Weights.size(); ++j) - { - const f32 total = Vertices_TotalWeight[ joint->Weights[j].buffer_id ] [ joint->Weights[j].vertex_id ]; - if (total != 0 && total != 1) - joint->Weights[j].strength /= total; - } - } -} - - -void CSkinnedMesh::recoverJointsFromMesh(core::array<IBoneSceneNode*> &JointChildSceneNodes) -{ - for (u32 i=0;i<AllJoints.size();++i) - { - IBoneSceneNode* node=JointChildSceneNodes[i]; - SJoint *joint=AllJoints[i]; - node->setPosition( joint->LocalAnimatedMatrix.getTranslation() ); - node->setRotation( joint->LocalAnimatedMatrix.getRotationDegrees() ); - - //node->setScale( joint->LocalAnimatedMatrix.getScale() ); - - node->positionHint=joint->positionHint; - node->scaleHint=joint->scaleHint; - node->rotationHint=joint->rotationHint; - - //node->setAbsoluteTransformation(joint->GlobalMatrix); //not going to work - - //Note: This updateAbsolutePosition will not work well if joints are not nested like b3d - //node->updateAbsolutePosition(); - } -} - - -void CSkinnedMesh::transferJointsToMesh(const core::array<IBoneSceneNode*> &JointChildSceneNodes) -{ - for (u32 i=0; i<AllJoints.size(); ++i) - { - const IBoneSceneNode* const node=JointChildSceneNodes[i]; - SJoint *joint=AllJoints[i]; - - joint->LocalAnimatedMatrix.setTranslation(node->getPosition()); - joint->LocalAnimatedMatrix.setRotationDegrees(node->getRotation()); - - //joint->LocalAnimatedMatrix.setScale( node->getScale() ); - - joint->positionHint=node->positionHint; - joint->scaleHint=node->scaleHint; - joint->rotationHint=node->rotationHint; - - if (node->getSkinningSpace()==EBSS_GLOBAL) - joint->GlobalSkinningSpace=true; - else - joint->GlobalSkinningSpace=false; - } - //Remove cache, temp... - LastAnimatedFrame=-1; - LastSkinnedFrame=-1; -} - - -void CSkinnedMesh::transferOnlyJointsHintsToMesh(const core::array<IBoneSceneNode*> &JointChildSceneNodes) -{ - for (u32 i=0;i<AllJoints.size();++i) - { - const IBoneSceneNode* const node=JointChildSceneNodes[i]; - SJoint *joint=AllJoints[i]; - - joint->positionHint=node->positionHint; - joint->scaleHint=node->scaleHint; - joint->rotationHint=node->rotationHint; - } -} - - -void CSkinnedMesh::createJoints(core::array<IBoneSceneNode*> &JointChildSceneNodes, - IAnimatedMeshSceneNode* AnimatedMeshSceneNode, - ISceneManager* SceneManager) -{ - u32 i; - - //Create new joints - for (i=0;i<AllJoints.size();++i) - { - JointChildSceneNodes.push_back(new CBoneSceneNode(0, SceneManager, 0, i, AllJoints[i]->Name.c_str())); - } - - //Match up parents - for (i=0;i<JointChildSceneNodes.size();++i) - { - IBoneSceneNode* node=JointChildSceneNodes[i]; - const SJoint* const joint=AllJoints[i]; //should be fine - - s32 parentID=-1; - - for (u32 j=0;j<AllJoints.size();++j) - { - if (i!=j && parentID==-1) - { - const SJoint* const parentTest=AllJoints[j]; - for (u32 n=0;n<parentTest->Children.size();++n) - { - if (parentTest->Children[n]==joint) - { - parentID=j; - break; - } - } - } - } - - if (parentID!=-1) - node->setParent( JointChildSceneNodes[parentID] ); - else - node->setParent( AnimatedMeshSceneNode ); - - node->drop(); - } -} - - -void CSkinnedMesh::convertMeshToTangents() -{ - // now calculate tangents - for (u32 b=0; b < LocalBuffers.size(); ++b) - { - if (LocalBuffers[b]) - { - LocalBuffers[b]->MoveTo_Tangents(); - - const s32 idxCnt = LocalBuffers[b]->getIndexCount(); - - u16* idx = LocalBuffers[b]->getIndices(); - video::S3DVertexTangents* v = - (video::S3DVertexTangents*)LocalBuffers[b]->getVertices(); - - for (s32 i=0; i<idxCnt; i+=3) - { - calculateTangents( - v[idx[i+0]].Normal, - v[idx[i+0]].Tangent, - v[idx[i+0]].Binormal, - v[idx[i+0]].Pos, - v[idx[i+1]].Pos, - v[idx[i+2]].Pos, - v[idx[i+0]].TCoords, - v[idx[i+1]].TCoords, - v[idx[i+2]].TCoords); - - calculateTangents( - v[idx[i+1]].Normal, - v[idx[i+1]].Tangent, - v[idx[i+1]].Binormal, - v[idx[i+1]].Pos, - v[idx[i+2]].Pos, - v[idx[i+0]].Pos, - v[idx[i+1]].TCoords, - v[idx[i+2]].TCoords, - v[idx[i+0]].TCoords); - - calculateTangents( - v[idx[i+2]].Normal, - v[idx[i+2]].Tangent, - v[idx[i+2]].Binormal, - v[idx[i+2]].Pos, - v[idx[i+0]].Pos, - v[idx[i+1]].Pos, - v[idx[i+2]].TCoords, - v[idx[i+0]].TCoords, - v[idx[i+1]].TCoords); - } - } - } -} - - -void CSkinnedMesh::calculateTangents( - core::vector3df& normal, - core::vector3df& tangent, - core::vector3df& binormal, - core::vector3df& vt1, core::vector3df& vt2, core::vector3df& vt3, // vertices - core::vector2df& tc1, core::vector2df& tc2, core::vector2df& tc3) // texture coords -{ - core::vector3df v1 = vt1 - vt2; - core::vector3df v2 = vt3 - vt1; - normal = v2.crossProduct(v1); - normal.normalize(); - - // binormal - - f32 deltaX1 = tc1.X - tc2.X; - f32 deltaX2 = tc3.X - tc1.X; - binormal = (v1 * deltaX2) - (v2 * deltaX1); - binormal.normalize(); - - // tangent - - f32 deltaY1 = tc1.Y - tc2.Y; - f32 deltaY2 = tc3.Y - tc1.Y; - tangent = (v1 * deltaY2) - (v2 * deltaY1); - tangent.normalize(); - - // adjust - - core::vector3df txb = tangent.crossProduct(binormal); - if (txb.dotProduct(normal) < 0.0f) - { - tangent *= -1.0f; - binormal *= -1.0f; - } -} - - - - - - - - -} // end namespace scene -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_SKINNED_MESH_SUPPORT_ - diff --git a/irrlicht-1.6/source/Irrlicht/CSkinnedMesh.h b/irrlicht-1.6/source/Irrlicht/CSkinnedMesh.h deleted file mode 100644 index b636cd718..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSkinnedMesh.h +++ /dev/null @@ -1,201 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -//New skinned mesh - -#ifndef __C_SKINNED_MESH_H_INCLUDED__ -#define __C_SKINNED_MESH_H_INCLUDED__ - -#include "ISkinnedMesh.h" -#include "SMeshBuffer.h" -#include "S3DVertex.h" -#include "irrString.h" -#include "matrix4.h" -#include "quaternion.h" - -namespace irr -{ -namespace scene -{ - - class IAnimatedMeshSceneNode; - class IBoneSceneNode; - - class CSkinnedMesh: public ISkinnedMesh - { - public: - - //! constructor - CSkinnedMesh(); - - //! destructor - virtual ~CSkinnedMesh(); - - //! returns the amount of frames. If the amount is 1, it is a static (=non animated) mesh. - virtual u32 getFrameCount() const; - - //! returns the animated mesh based on a detail level (which is ignored) - virtual IMesh* getMesh(s32 frame, s32 detailLevel=255, s32 startFrameLoop=-1, s32 endFrameLoop=-1); - - //! Animates this mesh's joints based on frame input - //! blend: {0-old position, 1-New position} - virtual void animateMesh(f32 frame, f32 blend); - - //! Preforms a software skin on this mesh based of joint positions - virtual void skinMesh(); - - //! returns amount of mesh buffers. - virtual u32 getMeshBufferCount() const; - - //! returns pointer to a mesh buffer - virtual IMeshBuffer* getMeshBuffer(u32 nr) const; - - //! Returns pointer to a mesh buffer which fits a material - /** \param material: material to search for - \return Returns the pointer to the mesh buffer or - NULL if there is no such mesh buffer. */ - virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const; - - //! returns an axis aligned bounding box - virtual const core::aabbox3d<f32>& getBoundingBox() const; - - //! set user axis aligned bounding box - virtual void setBoundingBox( const core::aabbox3df& box); - - //! sets a flag of all contained materials to a new value - virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue); - - //! set the hardware mapping hint, for driver - virtual void setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX); - - //! flags the meshbuffer as changed, reloads hardware buffers - virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX); - - //! Returns the type of the animated mesh. - virtual E_ANIMATED_MESH_TYPE getMeshType() const; - - //! Gets joint count. - virtual u32 getJointCount() const; - - //! Gets the name of a joint. - virtual const c8* getJointName(u32 number) const; - - //! Gets a joint number from its name - virtual s32 getJointNumber(const c8* name) const; - - //! uses animation from another mesh - virtual bool useAnimationFrom(const ISkinnedMesh *mesh); - - //! Update Normals when Animating - //! False= Don't (default) - //! True = Update normals, slower - virtual void updateNormalsWhenAnimating(bool on); - - //! Sets Interpolation Mode - virtual void setInterpolationMode(E_INTERPOLATION_MODE mode); - - //! Recovers the joints from the mesh - virtual void recoverJointsFromMesh(core::array<IBoneSceneNode*> &JointChildSceneNodes); - - //! Tranfers the joint data to the mesh - virtual void transferJointsToMesh(const core::array<IBoneSceneNode*> &JointChildSceneNodes); - - //! Tranfers the joint hints to the mesh - virtual void transferOnlyJointsHintsToMesh(const core::array<IBoneSceneNode*> &JointChildSceneNodes); - - //! Creates an array of joints from this mesh - virtual void createJoints(core::array<IBoneSceneNode*> &JointChildSceneNodes, - IAnimatedMeshSceneNode* AnimatedMeshSceneNode, - ISceneManager* SceneManager); - - //! Convertes the mesh to contain tangent information - virtual void convertMeshToTangents(); - - //! Does the mesh have no animation - virtual bool isStatic(); - - //! (This feature is not implemented in irrlicht yet) - virtual bool setHardwareSkinning(bool on); - - //Interface for the mesh loaders (finalize should lock these functions, and they should have some prefix like loader_ - - //these functions will use the needed arrays, set vaules, etc to help the loaders - - //! exposed for loaders to add mesh buffers - virtual core::array<SSkinMeshBuffer*> &getMeshBuffers(); - - //! alternative method for adding joints - virtual core::array<SJoint*> &getAllJoints(); - - //! alternative method for adding joints - virtual const core::array<SJoint*> &getAllJoints() const; - - //! loaders should call this after populating the mesh - virtual void finalize(); - - virtual SSkinMeshBuffer *addMeshBuffer(); - - virtual SJoint *addJoint(SJoint *parent=0); - - virtual SPositionKey *addPositionKey(SJoint *joint); - virtual SRotationKey *addRotationKey(SJoint *joint); - virtual SScaleKey *addScaleKey(SJoint *joint); - - virtual SWeight *addWeight(SJoint *joint); - - virtual void updateBoundingBox(void); - -private: - void checkForAnimation(); - - void normalizeWeights(); - - void buildAll_LocalAnimatedMatrices(); //public? - - void buildAll_GlobalAnimatedMatrices(SJoint *Joint=0, SJoint *ParentJoint=0); - - void getFrameData(f32 frame, SJoint *Node, - core::vector3df &position, s32 &positionHint, - core::vector3df &scale, s32 &scaleHint, - core::quaternion &rotation, s32 &rotationHint); - - void CalculateGlobalMatrices(SJoint *Joint,SJoint *ParentJoint); - - void SkinJoint(SJoint *Joint, SJoint *ParentJoint); - - void calculateTangents(core::vector3df& normal, - core::vector3df& tangent, core::vector3df& binormal, - core::vector3df& vt1, core::vector3df& vt2, core::vector3df& vt3, - core::vector2df& tc1, core::vector2df& tc2, core::vector2df& tc3); - - core::array<SSkinMeshBuffer*> *SkinningBuffers; //Meshbuffer to skin, default is to skin localBuffers - - core::array<SSkinMeshBuffer*> LocalBuffers; - - core::array<SJoint*> AllJoints; - core::array<SJoint*> RootJoints; - - core::aabbox3d<f32> BoundingBox; - - core::array< core::array<bool> > Vertices_Moved; - - f32 AnimationFrames; - - f32 LastAnimatedFrame; - f32 LastSkinnedFrame; - - E_INTERPOLATION_MODE InterpolationMode; - - bool HasAnimation; - bool PreparedForSkinning; - bool BoneControlUsed; - bool AnimateNormals; - bool HardwareSkinning; - }; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CSkyBoxSceneNode.cpp b/irrlicht-1.6/source/Irrlicht/CSkyBoxSceneNode.cpp deleted file mode 100644 index 5b02888b6..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSkyBoxSceneNode.cpp +++ /dev/null @@ -1,261 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CSkyBoxSceneNode.h" -#include "IVideoDriver.h" -#include "ISceneManager.h" -#include "ICameraSceneNode.h" -#include "S3DVertex.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CSkyBoxSceneNode::CSkyBoxSceneNode(video::ITexture* top, video::ITexture* bottom, video::ITexture* left, - video::ITexture* right, video::ITexture* front, video::ITexture* back, ISceneNode* parent, ISceneManager* mgr, s32 id) -: ISceneNode(parent, mgr, id) -{ - #ifdef _DEBUG - setDebugName("CSkyBoxSceneNode"); - #endif - - setAutomaticCulling(scene::EAC_OFF); - Box.MaxEdge.set(0,0,0); - Box.MinEdge.set(0,0,0); - - // create indices - - Indices[0] = 0; - Indices[1] = 1; - Indices[2] = 2; - Indices[3] = 3; - - // create material - - video::SMaterial mat; - mat.Lighting = false; - mat.ZBuffer = video::ECFN_NEVER; - mat.ZWriteEnable = false; - mat.AntiAliasing=0; - mat.TextureLayer[0].TextureWrap = video::ETC_CLAMP; - - /* Hey, I am no artist, but look at that - cool ASCII art I made! ;) - - -111 111 - /6--------/5 y - / | / | ^ z - / | 11-1 | | / - -11-1 3---------2 | |/ - | 7- - -| -4 1-11 *---->x - | -1-11 | / 3-------|2 - |/ | / | //| - 0---------1/ | // | - -1-1-1 1-1-1 |// | - 0--------1 - */ - - video::ITexture* tex = front; - if (!tex) tex = left; - if (!tex) tex = back; - if (!tex) tex = right; - if (!tex) tex = top; - if (!tex) tex = bottom; - - const f32 onepixel = tex?(1.0f / (tex->getSize().Width * 1.5f)) : 0.0f; - const f32 t = 1.0f - onepixel; - const f32 o = 0.0f + onepixel; - - // create front side - - Material[0] = mat; - Material[0].setTexture(0, front); - Vertices[0] = video::S3DVertex(-1,-1,-1, 0,0,1, video::SColor(255,255,255,255), t, t); - Vertices[1] = video::S3DVertex( 1,-1,-1, 0,0,1, video::SColor(255,255,255,255), o, t); - Vertices[2] = video::S3DVertex( 1, 1,-1, 0,0,1, video::SColor(255,255,255,255), o, o); - Vertices[3] = video::S3DVertex(-1, 1,-1, 0,0,1, video::SColor(255,255,255,255), t, o); - - // create left side - - Material[1] = mat; - Material[1].setTexture(0, left); - Vertices[4] = video::S3DVertex( 1,-1,-1, -1,0,0, video::SColor(255,255,255,255), t, t); - Vertices[5] = video::S3DVertex( 1,-1, 1, -1,0,0, video::SColor(255,255,255,255), o, t); - Vertices[6] = video::S3DVertex( 1, 1, 1, -1,0,0, video::SColor(255,255,255,255), o, o); - Vertices[7] = video::S3DVertex( 1, 1,-1, -1,0,0, video::SColor(255,255,255,255), t, o); - - // create back side - - Material[2] = mat; - Material[2].setTexture(0, back); - Vertices[8] = video::S3DVertex( 1,-1, 1, 0,0,-1, video::SColor(255,255,255,255), t, t); - Vertices[9] = video::S3DVertex(-1,-1, 1, 0,0,-1, video::SColor(255,255,255,255), o, t); - Vertices[10] = video::S3DVertex(-1, 1, 1, 0,0,-1, video::SColor(255,255,255,255), o, o); - Vertices[11] = video::S3DVertex( 1, 1, 1, 0,0,-1, video::SColor(255,255,255,255), t, o); - - // create right side - - Material[3] = mat; - Material[3].setTexture(0, right); - Vertices[12] = video::S3DVertex(-1,-1, 1, 1,0,0, video::SColor(255,255,255,255), t, t); - Vertices[13] = video::S3DVertex(-1,-1,-1, 1,0,0, video::SColor(255,255,255,255), o, t); - Vertices[14] = video::S3DVertex(-1, 1,-1, 1,0,0, video::SColor(255,255,255,255), o, o); - Vertices[15] = video::S3DVertex(-1, 1, 1, 1,0,0, video::SColor(255,255,255,255), t, o); - - // create top side - - Material[4] = mat; - Material[4].setTexture(0, top); - Vertices[16] = video::S3DVertex( 1, 1,-1, 0,-1,0, video::SColor(255,255,255,255), t, t); - Vertices[17] = video::S3DVertex( 1, 1, 1, 0,-1,0, video::SColor(255,255,255,255), o, t); - Vertices[18] = video::S3DVertex(-1, 1, 1, 0,-1,0, video::SColor(255,255,255,255), o, o); - Vertices[19] = video::S3DVertex(-1, 1,-1, 0,-1,0, video::SColor(255,255,255,255), t, o); - - // create bottom side - - Material[5] = mat; - Material[5].setTexture(0, bottom); - Vertices[20] = video::S3DVertex( 1,-1, 1, 0,1,0, video::SColor(255,255,255,255), o, o); - Vertices[21] = video::S3DVertex( 1,-1,-1, 0,1,0, video::SColor(255,255,255,255), t, o); - Vertices[22] = video::S3DVertex(-1,-1,-1, 0,1,0, video::SColor(255,255,255,255), t, t); - Vertices[23] = video::S3DVertex(-1,-1, 1, 0,1,0, video::SColor(255,255,255,255), o, t); -} - - -//! renders the node. -void CSkyBoxSceneNode::render() -{ - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - scene::ICameraSceneNode* camera = SceneManager->getActiveCamera(); - - if (!camera || !driver) - return; - - if ( !camera->isOrthogonal() ) - { - // draw perspective skybox - - core::matrix4 translate(AbsoluteTransformation); - translate.setTranslation(camera->getAbsolutePosition()); - - // Draw the sky box between the near and far clip plane - const f32 viewDistance = (camera->getNearValue() + camera->getFarValue()) * 0.5f; - core::matrix4 scale; - scale.setScale(core::vector3df(viewDistance, viewDistance, viewDistance)); - - driver->setTransform(video::ETS_WORLD, translate * scale); - - for (s32 i=0; i<6; ++i) - { - driver->setMaterial(Material[i]); - driver->drawIndexedTriangleFan(&Vertices[i*4], 4, Indices, 2); - } - } - else - { - // draw orthogonal skybox, - // simply choose one texture and draw it as 2d picture. - // there could be better ways to do this, but currently I think this is ok. - - core::vector3df lookVect = camera->getTarget() - camera->getAbsolutePosition(); - lookVect.normalize(); - core::vector3df absVect( core::abs_(lookVect.X), - core::abs_(lookVect.Y), - core::abs_(lookVect.Z)); - - int idx = 0; - - if ( absVect.X >= absVect.Y && absVect.X >= absVect.Z ) - { - // x direction - idx = lookVect.X > 0 ? 0 : 2; - } - else - if ( absVect.Y >= absVect.X && absVect.Y >= absVect.Z ) - { - // y direction - idx = lookVect.Y > 0 ? 4 : 5; - } - else - if ( absVect.Z >= absVect.X && absVect.Z >= absVect.Y ) - { - // z direction - idx = lookVect.Z > 0 ? 1 : 3; - } - - video::ITexture* tex = Material[idx].getTexture(0); - - if ( tex ) - { - core::rect<s32> rctDest(core::position2d<s32>(-1,0), - core::dimension2di(driver->getCurrentRenderTargetSize())); - core::rect<s32> rctSrc(core::position2d<s32>(0,0), - core::dimension2di(tex->getSize())); - - driver->draw2DImage(tex, rctDest, rctSrc); - } - } -} - - - -//! returns the axis aligned bounding box of this node -const core::aabbox3d<f32>& CSkyBoxSceneNode::getBoundingBox() const -{ - return Box; -} - - -void CSkyBoxSceneNode::OnRegisterSceneNode() -{ - if (IsVisible) - SceneManager->registerNodeForRendering(this, ESNRP_SKY_BOX); - - ISceneNode::OnRegisterSceneNode(); -} - - -//! returns the material based on the zero based index i. To get the amount -//! of materials used by this scene node, use getMaterialCount(). -//! This function is needed for inserting the node into the scene hirachy on a -//! optimal position for minimizing renderstate changes, but can also be used -//! to directly modify the material of a scene node. -video::SMaterial& CSkyBoxSceneNode::getMaterial(u32 i) -{ - return Material[i]; -} - - -//! returns amount of materials used by this scene node. -u32 CSkyBoxSceneNode::getMaterialCount() const -{ - return 6; -} - - -//! Creates a clone of this scene node and its children. -ISceneNode* CSkyBoxSceneNode::clone(ISceneNode* newParent, ISceneManager* newManager) -{ - if (!newParent) newParent = Parent; - if (!newManager) newManager = SceneManager; - - CSkyBoxSceneNode* nb = new CSkyBoxSceneNode(0,0,0,0,0,0, newParent, - newManager, ID); - - nb->cloneMembers(this, newManager); - - for (u32 i=0; i<6; ++i) - nb->Material[i] = Material[i]; - - nb->drop(); - return nb; -} - - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CSkyBoxSceneNode.h b/irrlicht-1.6/source/Irrlicht/CSkyBoxSceneNode.h deleted file mode 100644 index e229cd110..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSkyBoxSceneNode.h +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_SKY_BOX_SCENE_NODE_H_INCLUDED__ -#define __C_SKY_BOX_SCENE_NODE_H_INCLUDED__ - -#include "ISceneNode.h" -#include "S3DVertex.h" - -namespace irr -{ -namespace scene -{ - - // Skybox, rendered with zbuffer turned off, before all other nodes. - class CSkyBoxSceneNode : public ISceneNode - { - public: - - //! constructor - CSkyBoxSceneNode(video::ITexture* top, video::ITexture* bottom, video::ITexture* left, - video::ITexture* right, video::ITexture* front, video::ITexture* back, - ISceneNode* parent, ISceneManager* mgr, s32 id); - - virtual void OnRegisterSceneNode(); - - //! renders the node. - virtual void render(); - - //! returns the axis aligned bounding box of this node - virtual const core::aabbox3d<f32>& getBoundingBox() const; - - //! returns the material based on the zero based index i. To get the amount - //! of materials used by this scene node, use getMaterialCount(). - //! This function is needed for inserting the node into the scene hirachy on a - //! optimal position for minimizing renderstate changes, but can also be used - //! to directly modify the material of a scene node. - virtual video::SMaterial& getMaterial(u32 i); - - //! returns amount of materials used by this scene node. - virtual u32 getMaterialCount() const; - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() const { return ESNT_SKY_BOX; } - - //! Creates a clone of this scene node and its children. - virtual ISceneNode* clone(ISceneNode* newParent=0, ISceneManager* newManager=0); - - private: - - core::aabbox3d<f32> Box; - u16 Indices[4]; - video::S3DVertex Vertices[4*6]; - video::SMaterial Material[6]; - }; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CSkyDomeSceneNode.cpp b/irrlicht-1.6/source/Irrlicht/CSkyDomeSceneNode.cpp deleted file mode 100644 index 4c8941a59..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSkyDomeSceneNode.cpp +++ /dev/null @@ -1,291 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h -// Code for this scene node has been contributed by Anders la Cour-Harbo (alc) - -#include "CSkyDomeSceneNode.h" -#include "IVideoDriver.h" -#include "ISceneManager.h" -#include "ICameraSceneNode.h" -#include "IAnimatedMesh.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - -/* horiRes and vertRes: - Controls the number of faces along the horizontal axis (30 is a good value) - and the number of faces along the vertical axis (8 is a good value). - - texturePercentage: - Only the top texturePercentage of the image is used, e.g. 0.8 uses the top 80% of the image, - 1.0 uses the entire image. This is useful as some landscape images have a small banner - at the bottom that you don't want. - - spherePercentage: - This controls how far around the sphere the sky dome goes. For value 1.0 you get exactly the upper - hemisphere, for 1.1 you get slightly more, and for 2.0 you get a full sphere. It is sometimes useful - to use a value slightly bigger than 1 to avoid a gap between some ground place and the sky. This - parameters stretches the image to fit the chosen "sphere-size". */ - -CSkyDomeSceneNode::CSkyDomeSceneNode(video::ITexture* sky, u32 horiRes, u32 vertRes, - f32 texturePercentage, f32 spherePercentage, f32 radius, - ISceneNode* parent, ISceneManager* mgr, s32 id) - : ISceneNode(parent, mgr, id), Buffer(0), - HorizontalResolution(horiRes), VerticalResolution(vertRes), - TexturePercentage(texturePercentage), - SpherePercentage(spherePercentage), Radius(radius) -{ - #ifdef _DEBUG - setDebugName("CSkyDomeSceneNode"); - #endif - - setAutomaticCulling(scene::EAC_OFF); - - Buffer = new SMeshBuffer(); - Buffer->Material.Lighting = false; - Buffer->Material.ZBuffer = video::ECFN_NEVER; - Buffer->Material.ZWriteEnable = false; - Buffer->Material.AntiAliasing = video::EAAM_OFF; - Buffer->Material.setTexture(0, sky); - Buffer->BoundingBox.MaxEdge.set(0,0,0); - Buffer->BoundingBox.MinEdge.set(0,0,0); - - Buffer->Vertices.clear(); - Buffer->Indices.clear(); - - // regenerate the mesh - generateMesh(); -} - - -CSkyDomeSceneNode::~CSkyDomeSceneNode() -{ - if (Buffer) - Buffer->drop(); -} - - -void CSkyDomeSceneNode::generateMesh() -{ - f32 azimuth; - u32 k; - - const f32 azimuth_step = (core::PI * 2.f) / HorizontalResolution; - if (SpherePercentage < 0.f) - SpherePercentage = -SpherePercentage; - if (SpherePercentage > 2.f) - SpherePercentage = 2.f; - const f32 elevation_step = SpherePercentage * core::HALF_PI / (f32)VerticalResolution; - - Buffer->Vertices.reallocate( (HorizontalResolution + 1) * (VerticalResolution + 1) ); - Buffer->Indices.reallocate(3 * (2*VerticalResolution - 1) * HorizontalResolution); - - video::S3DVertex vtx; - vtx.Color.set(255,255,255,255); - vtx.Normal.set(0.0f,-1.f,0.0f); - - const f32 tcV = TexturePercentage / VerticalResolution; - for (k = 0, azimuth = 0; k <= HorizontalResolution; ++k) - { - f32 elevation = core::HALF_PI; - const f32 tcU = (f32)k / (f32)HorizontalResolution; - const f32 sinA = sinf(azimuth); - const f32 cosA = cosf(azimuth); - for (u32 j = 0; j <= VerticalResolution; ++j) - { - const f32 cosEr = Radius * cosf(elevation); - vtx.Pos.set(cosEr*sinA, Radius*sinf(elevation), cosEr*cosA); - vtx.TCoords.set(tcU, j*tcV); - - vtx.Normal = -vtx.Pos; - vtx.Normal.normalize(); - - Buffer->Vertices.push_back(vtx); - elevation -= elevation_step; - } - azimuth += azimuth_step; - } - - for (k = 0; k < HorizontalResolution; ++k) - { - Buffer->Indices.push_back(VerticalResolution + 2 + (VerticalResolution + 1)*k); - Buffer->Indices.push_back(1 + (VerticalResolution + 1)*k); - Buffer->Indices.push_back(0 + (VerticalResolution + 1)*k); - - for (u32 j = 1; j < VerticalResolution; ++j) - { - Buffer->Indices.push_back(VerticalResolution + 2 + (VerticalResolution + 1)*k + j); - Buffer->Indices.push_back(1 + (VerticalResolution + 1)*k + j); - Buffer->Indices.push_back(0 + (VerticalResolution + 1)*k + j); - - Buffer->Indices.push_back(VerticalResolution + 1 + (VerticalResolution + 1)*k + j); - Buffer->Indices.push_back(VerticalResolution + 2 + (VerticalResolution + 1)*k + j); - Buffer->Indices.push_back(0 + (VerticalResolution + 1)*k + j); - } - } -} - - -//! renders the node. -void CSkyDomeSceneNode::render() -{ - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - scene::ICameraSceneNode* camera = SceneManager->getActiveCamera(); - - if (!camera || !driver) - return; - - if ( !camera->isOrthogonal() ) - { - core::matrix4 mat(AbsoluteTransformation); - mat.setTranslation(camera->getAbsolutePosition()); - - driver->setTransform(video::ETS_WORLD, mat); - - driver->setMaterial(Buffer->Material); - driver->drawMeshBuffer(Buffer); - } - - // for debug purposes only: - if ( DebugDataVisible ) - { - video::SMaterial m; - m.Lighting = false; - driver->setMaterial(m); - - if ( DebugDataVisible & scene::EDS_NORMALS ) - { - IAnimatedMesh * arrow = SceneManager->addArrowMesh ( - "__debugnormal2", 0xFFECEC00, - 0xFF999900, 4, 8, 1.f * 40.f, 0.6f * 40.f, 0.05f * 40.f, 0.3f * 40.f); - if ( 0 == arrow ) - { - arrow = SceneManager->getMesh ( "__debugnormal2" ); - } - IMesh *mesh = arrow->getMesh(0); - - // find a good scaling factor - core::matrix4 m2; - - // draw normals - const scene::IMeshBuffer* mb = Buffer; - const u32 vSize = video::getVertexPitchFromType(mb->getVertexType()); - const video::S3DVertex* v = ( const video::S3DVertex*)mb->getVertices(); - for ( u32 i=0; i != mb->getVertexCount(); ++i ) - { - // align to v->Normal - core::quaternion quatRot(v->Normal.X, 0.f, -v->Normal.X, 1+v->Normal.Y); - quatRot.normalize(); - quatRot.getMatrix(m2, v->Pos); - - m2 = AbsoluteTransformation * m2; - - driver->setTransform(video::ETS_WORLD, m2); - for (u32 a = 0; a != mesh->getMeshBufferCount(); ++a) - driver->drawMeshBuffer(mesh->getMeshBuffer(a)); - - v = (const video::S3DVertex*) ( (u8*) v + vSize ); - } - driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); - } - - // show mesh - if ( DebugDataVisible & scene::EDS_MESH_WIRE_OVERLAY ) - { - m.Wireframe = true; - driver->setMaterial(m); - - driver->drawMeshBuffer(Buffer); - } - } -} - - -//! returns the axis aligned bounding box of this node -const core::aabbox3d<f32>& CSkyDomeSceneNode::getBoundingBox() const -{ - return Buffer->BoundingBox; -} - - -void CSkyDomeSceneNode::OnRegisterSceneNode() -{ - if (IsVisible) - { - SceneManager->registerNodeForRendering(this, ESNRP_SKY_BOX ); - } - - ISceneNode::OnRegisterSceneNode(); -} - - -//! returns the material based on the zero based index i. To get the amount -//! of materials used by this scene node, use getMaterialCount(). -//! This function is needed for inserting the node into the scene hirachy on a -//! optimal position for minimizing renderstate changes, but can also be used -//! to directly modify the material of a scene node. -video::SMaterial& CSkyDomeSceneNode::getMaterial(u32 i) -{ - return Buffer->Material; -} - - -//! returns amount of materials used by this scene node. -u32 CSkyDomeSceneNode::getMaterialCount() const -{ - return 1; -} - - -//! Writes attributes of the scene node. -void CSkyDomeSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const -{ - ISceneNode::serializeAttributes(out, options); - - out->addInt ("HorizontalResolution", HorizontalResolution); - out->addInt ("VerticalResolution", VerticalResolution); - out->addFloat("TexturePercentage", TexturePercentage); - out->addFloat("SpherePercentage", SpherePercentage); - out->addFloat("Radius", Radius); -} - - -//! Reads attributes of the scene node. -void CSkyDomeSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - HorizontalResolution = in->getAttributeAsInt ("HorizontalResolution"); - VerticalResolution = in->getAttributeAsInt ("VerticalResolution"); - TexturePercentage = in->getAttributeAsFloat("TexturePercentage"); - SpherePercentage = in->getAttributeAsFloat("SpherePercentage"); - Radius = in->getAttributeAsFloat("Radius"); - - ISceneNode::deserializeAttributes(in, options); - - // regenerate the mesh - generateMesh(); -} - -//! Creates a clone of this scene node and its children. -ISceneNode* CSkyDomeSceneNode::clone(ISceneNode* newParent, ISceneManager* newManager) -{ - if (!newParent) - newParent = Parent; - if (!newManager) - newManager = SceneManager; - - CSkyDomeSceneNode* nb = new CSkyDomeSceneNode(Buffer->Material.TextureLayer[0].Texture, HorizontalResolution, VerticalResolution, TexturePercentage, - SpherePercentage, Radius, newParent, newManager, ID); - - nb->cloneMembers(this, newManager); - - nb->drop(); - return nb; -} - - -} // namespace scene -} // namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CSkyDomeSceneNode.h b/irrlicht-1.6/source/Irrlicht/CSkyDomeSceneNode.h deleted file mode 100644 index 45556dbf8..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSkyDomeSceneNode.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h -// Code for this scene node has been contributed by Anders la Cour-Harbo (alc) - -#ifndef __C_SKY_DOME_SCENE_NODE_H_INCLUDED__ -#define __C_SKY_DOME_SCENE_NODE_H_INCLUDED__ - -#include "ISceneNode.h" -#include "SMeshBuffer.h" - -namespace irr -{ -namespace scene -{ - -class CSkyDomeSceneNode : public ISceneNode -{ - public: - CSkyDomeSceneNode(video::ITexture* texture, u32 horiRes, u32 vertRes, - f32 texturePercentage, f32 spherePercentage, f32 radius, - ISceneNode* parent, ISceneManager* smgr, s32 id); - virtual ~CSkyDomeSceneNode(); - virtual void OnRegisterSceneNode(); - virtual void render(); - virtual const core::aabbox3d<f32>& getBoundingBox() const; - virtual video::SMaterial& getMaterial(u32 i); - virtual u32 getMaterialCount() const; - virtual ESCENE_NODE_TYPE getType() const { return ESNT_SKY_DOME; } - - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - virtual ISceneNode* clone(ISceneNode* newParent=0, ISceneManager* newManager=0); - - private: - - void generateMesh(); - - SMeshBuffer* Buffer; - - u32 HorizontalResolution, VerticalResolution; - f32 TexturePercentage, SpherePercentage, Radius; -}; - - -} -} - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CSoftware2MaterialRenderer.h b/irrlicht-1.6/source/Irrlicht/CSoftware2MaterialRenderer.h deleted file mode 100644 index f96184615..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSoftware2MaterialRenderer.h +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_SOFTWARE2_MATERIAL_RENDERER_H_INCLUDED__ -#define __C_SOFTWARE2_MATERIAL_RENDERER_H_INCLUDED__ - -#include "SoftwareDriver2_compile_config.h" - -#include "IMaterialRenderer.h" -#include "CSoftwareDriver2.h" - -namespace irr -{ -namespace video -{ - -//! Base class for all internal Software2 material renderers -class CSoftware2MaterialRenderer : public IMaterialRenderer -{ -public: - - //! Constructor - CSoftware2MaterialRenderer(video::CBurningVideoDriver* driver) - : Driver(driver) - { - } - -protected: - - video::CBurningVideoDriver* Driver; -}; - -//! solid material renderer -class CSoftware2MaterialRenderer_SOLID : public CSoftware2MaterialRenderer -{ -public: - CSoftware2MaterialRenderer_SOLID ( video::CBurningVideoDriver* driver ) - :CSoftware2MaterialRenderer ( driver ) {} - - //! Returns if the material is transparent. - virtual bool isTransparent() const - { - return false; - } - -}; - - - -//! Transparent material renderer -class CSoftware2MaterialRenderer_TRANSPARENT_ADD_COLOR : public CSoftware2MaterialRenderer -{ -public: - CSoftware2MaterialRenderer_TRANSPARENT_ADD_COLOR ( video::CBurningVideoDriver* driver ) - : CSoftware2MaterialRenderer ( driver ) {} - - - //! Returns if the material is transparent. - virtual bool isTransparent() const - { - return true; - } - -}; - -//! unsupported material renderer -class CSoftware2MaterialRenderer_UNSUPPORTED : public CSoftware2MaterialRenderer -{ -public: - CSoftware2MaterialRenderer_UNSUPPORTED ( video::CBurningVideoDriver* driver ) - : CSoftware2MaterialRenderer ( driver ) {} - - virtual s32 getRenderCapability() const { return 1; } - -}; - -//! unsupported material renderer -class CBurningShader_REFERENCE : public CSoftware2MaterialRenderer -{ -public: - CBurningShader_REFERENCE ( video::CBurningVideoDriver* driver ) - : CSoftware2MaterialRenderer ( driver ) {} - - virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, - bool resetAllRenderstates, IMaterialRendererServices* services) - { - } - - virtual void OnUnsetMaterial() - { - } - - virtual bool isTransparent() const - { - return false; - } - - virtual bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype) - { - return true; - }; - - - virtual s32 getRenderCapability() const - { - return 1; - } - -}; - - - -} // end namespace video -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CSoftwareDriver.cpp b/irrlicht-1.6/source/Irrlicht/CSoftwareDriver.cpp deleted file mode 100644 index c5531b40c..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSoftwareDriver.cpp +++ /dev/null @@ -1,960 +0,0 @@ -// Copyright (C) 2002-2009 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" -#include "CSoftwareDriver.h" - -#ifdef _IRR_COMPILE_WITH_SOFTWARE_ - -#include "CSoftwareTexture.h" -#include "os.h" -#include "S3DVertex.h" - -namespace irr -{ -namespace video -{ - - -//! constructor -CSoftwareDriver::CSoftwareDriver(const core::dimension2d<u32>& windowSize, bool fullscreen, io::IFileSystem* io, video::IImagePresenter* presenter) -: CNullDriver(io, windowSize), BackBuffer(0), Presenter(presenter), WindowId(0), - SceneSourceRect(0), RenderTargetTexture(0), RenderTargetSurface(0), - CurrentTriangleRenderer(0), ZBuffer(0), Texture(0) -{ - #ifdef _DEBUG - setDebugName("CSoftwareDriver"); - #endif - - // create backbuffer - - BackBuffer = new CImage(ECF_A1R5G5B5, windowSize); - if (BackBuffer) - { - BackBuffer->fill(SColor(0)); - - // create z buffer - ZBuffer = video::createZBuffer(BackBuffer->getDimension()); - } - - // create triangle renderers - - TriangleRenderers[ETR_FLAT] = createTriangleRendererFlat(ZBuffer); - TriangleRenderers[ETR_FLAT_WIRE] = createTriangleRendererFlatWire(ZBuffer); - TriangleRenderers[ETR_GOURAUD] = createTriangleRendererGouraud(ZBuffer); - TriangleRenderers[ETR_GOURAUD_WIRE] = createTriangleRendererGouraudWire(ZBuffer); - TriangleRenderers[ETR_TEXTURE_FLAT] = createTriangleRendererTextureFlat(ZBuffer); - TriangleRenderers[ETR_TEXTURE_FLAT_WIRE] = createTriangleRendererTextureFlatWire(ZBuffer); - TriangleRenderers[ETR_TEXTURE_GOURAUD] = createTriangleRendererTextureGouraud(ZBuffer); - TriangleRenderers[ETR_TEXTURE_GOURAUD_WIRE] = createTriangleRendererTextureGouraudWire(ZBuffer); - TriangleRenderers[ETR_TEXTURE_GOURAUD_NOZ] = createTriangleRendererTextureGouraudNoZ(); - TriangleRenderers[ETR_TEXTURE_GOURAUD_ADD] = createTriangleRendererTextureGouraudAdd(ZBuffer); - - // select render target - - setRenderTarget(BackBuffer); - - // select the right renderer - - selectRightTriangleRenderer(); -} - - - -//! destructor -CSoftwareDriver::~CSoftwareDriver() -{ - // delete Backbuffer - if (BackBuffer) - BackBuffer->drop(); - - // delete triangle renderers - - for (s32 i=0; i<ETR_COUNT; ++i) - if (TriangleRenderers[i]) - TriangleRenderers[i]->drop(); - - // delete zbuffer - - if (ZBuffer) - ZBuffer->drop(); - - // delete current texture - - if (Texture) - Texture->drop(); - - if (RenderTargetTexture) - RenderTargetTexture->drop(); - - if (RenderTargetSurface) - RenderTargetSurface->drop(); -} - - - -//! switches to a triangle renderer -void CSoftwareDriver::switchToTriangleRenderer(ETriangleRenderer renderer) -{ - video::IImage* s = 0; - if (Texture) - s = ((CSoftwareTexture*)Texture)->getTexture(); - - CurrentTriangleRenderer = TriangleRenderers[renderer]; - CurrentTriangleRenderer->setBackfaceCulling(Material.BackfaceCulling == true); - CurrentTriangleRenderer->setTexture(s); - CurrentTriangleRenderer->setRenderTarget(RenderTargetSurface, ViewPort); -} - - -//! void selects the right triangle renderer based on the render states. -void CSoftwareDriver::selectRightTriangleRenderer() -{ - - ETriangleRenderer renderer = ETR_FLAT; - - if (Texture) - { - if (!Material.GouraudShading) - renderer = (!Material.Wireframe) ? ETR_TEXTURE_FLAT : ETR_TEXTURE_FLAT_WIRE; - else - { - if (Material.Wireframe) - renderer = ETR_TEXTURE_GOURAUD_WIRE; - else - { - if (Material.MaterialType == EMT_TRANSPARENT_ADD_COLOR || - Material.MaterialType == EMT_TRANSPARENT_ALPHA_CHANNEL || - Material.MaterialType == EMT_TRANSPARENT_VERTEX_ALPHA) - { - // simply draw all transparent stuff with the same renderer. at - // least it is transparent then. - renderer = ETR_TEXTURE_GOURAUD_ADD; - } - else - if ((Material.ZBuffer==ECFN_NEVER) && !Material.ZWriteEnable) - renderer = ETR_TEXTURE_GOURAUD_NOZ; - else - { - renderer = ETR_TEXTURE_GOURAUD; - } - } - } - } - else - { - if (!Material.GouraudShading) - renderer = (!Material.Wireframe) ? ETR_FLAT : ETR_FLAT_WIRE; - else - renderer = (!Material.Wireframe) ? ETR_GOURAUD : ETR_GOURAUD_WIRE; - } - - switchToTriangleRenderer(renderer); -} - - -//! queries the features of the driver, returns true if feature is available -bool CSoftwareDriver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const -{ - switch (feature) - { - case EVDF_RENDER_TO_TARGET: - case EVDF_TEXTURE_NSQUARE: - return FeatureEnabled[feature]; - default: - return false; - }; -} - - -//! sets transformation -void CSoftwareDriver::setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat) -{ - TransformationMatrix[state] = mat; -} - - -//! sets the current Texture -bool CSoftwareDriver::setActiveTexture(u32 stage, video::ITexture* texture) -{ - if (texture && texture->getDriverType() != EDT_SOFTWARE) - { - os::Printer::log("Fatal Error: Tried to set a texture not owned by this driver.", ELL_ERROR); - return false; - } - - if (Texture) - Texture->drop(); - - Texture = texture; - - if (Texture) - Texture->grab(); - - selectRightTriangleRenderer(); - return true; -} - - -//! sets a material -void CSoftwareDriver::setMaterial(const SMaterial& material) -{ - Material = material; - OverrideMaterial.apply(Material); - - for (u32 i = 0; i < 1; ++i) - { - setActiveTexture(i, Material.getTexture(i)); - setTransform ((E_TRANSFORMATION_STATE) ( ETS_TEXTURE_0 + i ), - material.getTextureMatrix(i)); - } -} - - -//! clears the zbuffer -bool CSoftwareDriver::beginScene(bool backBuffer, bool zBuffer, SColor color, - void* windowId, core::rect<s32>* sourceRect) -{ - CNullDriver::beginScene(backBuffer, zBuffer, color, windowId, sourceRect); - WindowId=windowId; - SceneSourceRect = sourceRect; - - if (backBuffer && BackBuffer) - BackBuffer->fill(color); - - if (ZBuffer && zBuffer) - ZBuffer->clear(); - - return true; -} - - -//! presents the rendered scene on the screen, returns false if failed -bool CSoftwareDriver::endScene() -{ - CNullDriver::endScene(); - - return Presenter->present(BackBuffer, WindowId, SceneSourceRect); -} - - -//! returns a device dependent texture from a software surface (IImage) -//! THIS METHOD HAS TO BE OVERRIDDEN BY DERIVED DRIVERS WITH OWN TEXTURES -ITexture* CSoftwareDriver::createDeviceDependentTexture(IImage* surface, const io::path& name) -{ - return new CSoftwareTexture(surface, name); -} - - -//! sets a render target -bool CSoftwareDriver::setRenderTarget(video::ITexture* texture, bool clearBackBuffer, - bool clearZBuffer, SColor color) -{ - if (texture && texture->getDriverType() != EDT_SOFTWARE) - { - os::Printer::log("Fatal Error: Tried to set a texture not owned by this driver.", ELL_ERROR); - return false; - } - - if (RenderTargetTexture) - RenderTargetTexture->drop(); - - RenderTargetTexture = texture; - - if (RenderTargetTexture) - { - RenderTargetTexture->grab(); - setRenderTarget(((CSoftwareTexture*)RenderTargetTexture)->getTexture()); - } - else - { - setRenderTarget(BackBuffer); - } - - if (RenderTargetSurface && (clearBackBuffer || clearZBuffer)) - { - if (clearZBuffer) - ZBuffer->clear(); - - if (clearBackBuffer) - ((video::CImage*)RenderTargetSurface)->fill( color ); - } - - return true; -} - - -//! sets a render target -void CSoftwareDriver::setRenderTarget(video::CImage* image) -{ - if (RenderTargetSurface) - RenderTargetSurface->drop(); - - RenderTargetSurface = image; - RenderTargetSize.Width = 0; - RenderTargetSize.Height = 0; - Render2DTranslation.X = 0; - Render2DTranslation.Y = 0; - - if (RenderTargetSurface) - { - RenderTargetSurface->grab(); - RenderTargetSize = RenderTargetSurface->getDimension(); - } - - setViewPort(core::rect<s32>(0,0,RenderTargetSize.Width,RenderTargetSize.Height)); - - if (ZBuffer) - ZBuffer->setSize(RenderTargetSize); -} - - -//! sets a viewport -void CSoftwareDriver::setViewPort(const core::rect<s32>& area) -{ - ViewPort = area; - - //TODO: the clipping is not correct, because the projection is affected. - // to correct this, ViewPortSize and Render2DTranslation will have to be corrected. - core::rect<s32> rendert(0,0,RenderTargetSize.Width,RenderTargetSize.Height); - ViewPort.clipAgainst(rendert); - - ViewPortSize = core::dimension2du(ViewPort.getSize()); - Render2DTranslation.X = (ViewPortSize.Width / 2) + ViewPort.UpperLeftCorner.X; - Render2DTranslation.Y = ViewPort.UpperLeftCorner.Y + ViewPortSize.Height - (ViewPortSize.Height / 2);// + ViewPort.UpperLeftCorner.Y; - - if (CurrentTriangleRenderer) - CurrentTriangleRenderer->setRenderTarget(RenderTargetSurface, ViewPort); -} - - -void CSoftwareDriver::drawVertexPrimitiveList(const void* vertices, u32 vertexCount, - const void* indexList, u32 primitiveCount, - E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType) - -{ - switch (iType) - { - case (EIT_16BIT): - { - drawVertexPrimitiveList16(vertices, vertexCount, (const u16*)indexList, primitiveCount, vType, pType); - break; - } - case (EIT_32BIT): - { - os::Printer::log("Software driver can not render 32bit buffers", ELL_ERROR); - break; - } - } -} - - -//! draws a vertex primitive list -void CSoftwareDriver::drawVertexPrimitiveList16(const void* vertices, u32 vertexCount, const u16* indexList, u32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType) -{ - const u16* indexPointer=0; - core::array<u16> newBuffer; - switch (pType) - { - case scene::EPT_LINE_STRIP: - { - switch (vType) - { - case EVT_STANDARD: - { - for (u32 i=0; i < primitiveCount-1; ++i) - draw3DLine(((S3DVertex*)vertices)[indexList[i]].Pos, - ((S3DVertex*)vertices)[indexList[i+1]].Pos, - ((S3DVertex*)vertices)[indexList[i]].Color); - } - break; - case EVT_2TCOORDS: - { - for (u32 i=0; i < primitiveCount-1; ++i) - draw3DLine(((S3DVertex2TCoords*)vertices)[indexList[i]].Pos, - ((S3DVertex2TCoords*)vertices)[indexList[i+1]].Pos, - ((S3DVertex2TCoords*)vertices)[indexList[i]].Color); - } - break; - case EVT_TANGENTS: - { - for (u32 i=0; i < primitiveCount-1; ++i) - draw3DLine(((S3DVertexTangents*)vertices)[indexList[i]].Pos, - ((S3DVertexTangents*)vertices)[indexList[i+1]].Pos, - ((S3DVertexTangents*)vertices)[indexList[i]].Color); - } - break; - } - } - return; - case scene::EPT_LINE_LOOP: - drawVertexPrimitiveList16(vertices, vertexCount, indexList, primitiveCount-1, vType, scene::EPT_LINE_STRIP); - switch (vType) - { - case EVT_STANDARD: - draw3DLine(((S3DVertex*)vertices)[indexList[primitiveCount-1]].Pos, - ((S3DVertex*)vertices)[indexList[0]].Pos, - ((S3DVertex*)vertices)[indexList[primitiveCount-1]].Color); - break; - case EVT_2TCOORDS: - draw3DLine(((S3DVertex2TCoords*)vertices)[indexList[primitiveCount-1]].Pos, - ((S3DVertex2TCoords*)vertices)[indexList[0]].Pos, - ((S3DVertex2TCoords*)vertices)[indexList[primitiveCount-1]].Color); - break; - case EVT_TANGENTS: - draw3DLine(((S3DVertexTangents*)vertices)[indexList[primitiveCount-1]].Pos, - ((S3DVertexTangents*)vertices)[indexList[0]].Pos, - ((S3DVertexTangents*)vertices)[indexList[primitiveCount-1]].Color); - break; - } - return; - case scene::EPT_LINES: - { - switch (vType) - { - case EVT_STANDARD: - { - for (u32 i=0; i < 2*primitiveCount; i+=2) - draw3DLine(((S3DVertex*)vertices)[indexList[i]].Pos, - ((S3DVertex*)vertices)[indexList[i+1]].Pos, - ((S3DVertex*)vertices)[indexList[i]].Color); - } - break; - case EVT_2TCOORDS: - { - for (u32 i=0; i < 2*primitiveCount; i+=2) - draw3DLine(((S3DVertex2TCoords*)vertices)[indexList[i]].Pos, - ((S3DVertex2TCoords*)vertices)[indexList[i+1]].Pos, - ((S3DVertex2TCoords*)vertices)[indexList[i]].Color); - } - break; - case EVT_TANGENTS: - { - for (u32 i=0; i < 2*primitiveCount; i+=2) - draw3DLine(((S3DVertexTangents*)vertices)[indexList[i]].Pos, - ((S3DVertexTangents*)vertices)[indexList[i+1]].Pos, - ((S3DVertexTangents*)vertices)[indexList[i]].Color); - } - break; - } - } - return; - case scene::EPT_TRIANGLE_FAN: - { - // TODO: don't convert fan to list - newBuffer.reallocate(primitiveCount*3); - for( u32 t=0; t<primitiveCount; ++t ) - { - newBuffer.push_back(indexList[0]); - newBuffer.push_back(indexList[t+1]); - newBuffer.push_back(indexList[t+2]); - } - - indexPointer = newBuffer.pointer(); - } - break; - case scene::EPT_TRIANGLES: - indexPointer=indexList; - break; - default: - return; - } - switch (vType) - { - case EVT_STANDARD: - drawClippedIndexedTriangleListT((S3DVertex*)vertices, vertexCount, indexPointer, primitiveCount); - break; - case EVT_2TCOORDS: - drawClippedIndexedTriangleListT((S3DVertex2TCoords*)vertices, vertexCount, indexPointer, primitiveCount); - break; - case EVT_TANGENTS: - drawClippedIndexedTriangleListT((S3DVertexTangents*)vertices, vertexCount, indexPointer, primitiveCount); - break; - } -} - - -template<class VERTEXTYPE> -void CSoftwareDriver::drawClippedIndexedTriangleListT(const VERTEXTYPE* vertices, - s32 vertexCount, const u16* indexList, s32 triangleCount) -{ - if (!RenderTargetSurface || !ZBuffer || !triangleCount) - return; - - if (!checkPrimitiveCount(triangleCount)) - return; - - // arrays for storing clipped vertices - core::array<VERTEXTYPE> clippedVertices; - core::array<u16> clippedIndices; - - // calculate inverse world transformation - core::matrix4 worldinv(TransformationMatrix[ETS_WORLD]); - worldinv.makeInverse(); - - // calculate view frustum planes - scene::SViewFrustum frustum(TransformationMatrix[ETS_PROJECTION] * TransformationMatrix[ETS_VIEW]); - - // copy and transform clipping planes ignoring far plane - core::plane3df planes[5]; // ordered by near, left, right, bottom, top - for (int p=0; p<5; ++p) - worldinv.transformPlane(frustum.planes[p+1], planes[p]); - - core::EIntersectionRelation3D inout[3]; // is point in front or back of plane? - - // temporary buffer for vertices to be clipped by all planes - core::array<VERTEXTYPE> tClpBuf; - int t; - - int i; - for (i=0; i<triangleCount; ++i) // for all input triangles - { - // add next triangle to tempClipBuffer - for (t=0; t<3; ++t) - tClpBuf.push_back(vertices[indexList[(i*3)+t]]); - - for (int p=0; p<5; ++p) // for all clip planes - for (int v=0; v<(int)tClpBuf.size(); v+=3) // for all vertices in temp clip buffer - { - int inside = 0; - int outside = 0; - - // test intersection relation of the current vertices - for (t=0; t<3; ++t) - { - inout[t] = planes[p].classifyPointRelation(tClpBuf[v+t].Pos); - if (inout[t] != core::ISREL3D_FRONT) - ++inside; - else - if (inout[t] == core::ISREL3D_FRONT) - ++outside; - } - - if (!outside) - { - // add all vertices to new buffer, this triangle needs no clipping. - // so simply don't change this part of the temporary triangle buffer - continue; - } - - if (!inside) - { - // all vertices are outside, don't add this triangle, so erase this - // triangle from the tClpBuf - tClpBuf.erase(v,3); - v -= 3; - continue; - } - - // this vertex has to be clipped by this clipping plane. - - // The following lines represent my try to implement some real clipping. - // There is a bug somewhere, and after some time I've given up. - // So now it is commented out, resulting that triangles which would need clipping - // are simply taken out (in the next two lines). -#ifndef __SOFTWARE_CLIPPING_PROBLEM__ - tClpBuf.erase(v,3); - v -= 3; -#endif - - /* - // my idea is the following: - // current vertex to next vertex relation: - // out - out : add nothing - // out - in : add middle point - // in - out : add first and middle point - // in - in : add both - - - // now based on the number of intersections, create new vertices - // into tClpBuf (at the front for not letting them be clipped again) - - int added = 0; - int prev = v+2; - for (int index=v; index<v+3; ++index) - { - if (inout[prev] == core::ISREL3D_BACK) - { - if (inout[index] != core::ISREL3D_BACK) - { - VERTEXTYPE& vt1 = tClpBuf[prev]; - VERTEXTYPE& vt2 = tClpBuf[index]; - - f32 fact = planes[p].getKnownIntersectionWithLine(vt1.Pos, vt2.Pos); - VERTEXTYPE nvt; - nvt.Pos = vt1.Pos.getInterpolated(vt2.Pos, fact); - nvt.Color = vt1.Color.getInterpolated(vt2.Color, fact); - nvt.TCoords = vt1.TCoords.getInterpolated(vt2.TCoords, fact); - - tClpBuf.push_front(nvt); ++index; ++prev; ++v; - ++added; - } - } - else - { - if (inout[index] != core::ISREL3D_BACK) - { - VERTEXTYPE vt1 = tClpBuf[index]; - VERTEXTYPE vt2 = tClpBuf[prev]; - tClpBuf.push_front(vt1); ++index; ++prev; ++v; - tClpBuf.push_front(vt2); ++index; ++prev; ++v; - added+= 2; - } - else - { - // same as above, but other way round. - VERTEXTYPE vt1 = tClpBuf[index]; - VERTEXTYPE vt2 = tClpBuf[prev]; - - f32 fact = planes[p].getKnownIntersectionWithLine(vt1.Pos, vt2.Pos); - VERTEXTYPE nvt; - nvt.Pos = vt1.Pos.getInterpolated(vt2.Pos, fact); - nvt.Color = vt1.Color.getInterpolated(vt2.Color, fact); - nvt.TCoords = vt1.TCoords.getInterpolated(vt2.TCoords, fact); - - tClpBuf.push_front(vt2); ++index; ++prev; ++v; - tClpBuf.push_front(nvt); ++index; ++prev; ++v; - added += 2; - } - } - - prev = index; - } - - // erase original vertices - tClpBuf.erase(v,3); - v -= 3; - */ - - - } // end for all clip planes - - // now add all remaining triangles in tempClipBuffer to clippedIndices - // and clippedVertices array. - if (clippedIndices.size() + tClpBuf.size() < 65535) - for (t=0; t<(int)tClpBuf.size(); ++t) - { - clippedIndices.push_back(clippedVertices.size()); - clippedVertices.push_back(tClpBuf[t]); - } - tClpBuf.clear(); - - } // end for all input triangles - - - // draw newly created triangles. - - // ----------------------------------------------------------- - // here all triangles are being drawn. I put this in a separate - // method, but the visual studio 6 compiler has great problems - // with templates and didn't accept two template methods in this - // class. - - // draw triangles - - CNullDriver::drawVertexPrimitiveList(clippedVertices.pointer(), clippedVertices.size(), - clippedIndices.pointer(), clippedIndices.size()/3, EVT_STANDARD, scene::EPT_TRIANGLES, EIT_16BIT); - - if (TransformedPoints.size() < clippedVertices.size()) - TransformedPoints.set_used(clippedVertices.size()); - - if (TransformedPoints.empty()) - return; - - const VERTEXTYPE* currentVertex = clippedVertices.pointer(); - S2DVertex* tp = &TransformedPoints[0]; - - core::dimension2d<u32> textureSize(0,0); - f32 zDiv; - - if (Texture) - textureSize = ((CSoftwareTexture*)Texture)->getTexture()->getDimension(); - - f32 transformedPos[4]; // transform all points in the list - - core::matrix4 matrix(TransformationMatrix[ETS_PROJECTION]); - matrix *= TransformationMatrix[ETS_VIEW]; - matrix *= TransformationMatrix[ETS_WORLD]; - - s32 ViewTransformWidth = (ViewPortSize.Width>>1); - s32 ViewTransformHeight = (ViewPortSize.Height>>1); - - for (i=0; i<(int)clippedVertices.size(); ++i) - { - transformedPos[0] = currentVertex->Pos.X; - transformedPos[1] = currentVertex->Pos.Y; - transformedPos[2] = currentVertex->Pos.Z; - transformedPos[3] = 1.0f; - - matrix.multiplyWith1x4Matrix(transformedPos); - zDiv = transformedPos[3] == 0.0f ? 1.0f : (1.0f / transformedPos[3]); - - tp->Pos.X = (s32)(ViewTransformWidth * (transformedPos[0] * zDiv) + (Render2DTranslation.X)); - tp->Pos.Y = (Render2DTranslation.Y - (s32)(ViewTransformHeight * (transformedPos[1] * zDiv))); - tp->Color = currentVertex->Color.toA1R5G5B5(); - tp->ZValue = (TZBufferType)(32767.0f * zDiv); - - tp->TCoords.X = (s32)(currentVertex->TCoords.X * textureSize.Width); - tp->TCoords.X <<= 8; - tp->TCoords.Y = (s32)(currentVertex->TCoords.Y * textureSize.Height); - tp->TCoords.Y <<= 8; - - ++currentVertex; - ++tp; - } - - // draw all transformed points from the index list - CurrentTriangleRenderer->drawIndexedTriangleList(&TransformedPoints[0], - clippedVertices.size(), clippedIndices.pointer(), clippedIndices.size()/3); -} - - -//! Draws a 3d line. -void CSoftwareDriver::draw3DLine(const core::vector3df& start, - const core::vector3df& end, SColor color) -{ - core::vector3df vect = start.crossProduct(end); - vect.normalize(); - vect *= Material.Thickness*0.3f; - - S3DVertex vtx[4]; - - vtx[0].Color = color; - vtx[1].Color = color; - vtx[2].Color = color; - vtx[3].Color = color; - - vtx[0].Pos = start; - vtx[1].Pos = end; - - vtx[2].Pos = start + vect; - vtx[3].Pos = end + vect; - - u16 idx[12] = {0,1,2, 0,2,1, 0,1,3, 0,3,1}; - - drawIndexedTriangleList(vtx, 4, idx, 4); -} - - -//! clips a triangle against the viewing frustum -void CSoftwareDriver::clipTriangle(f32* transformedPos) -{ -} - - -//! Only used by the internal engine. Used to notify the driver that -//! the window was resized. -void CSoftwareDriver::OnResize(const core::dimension2d<u32>& size) -{ - // make sure width and height are multiples of 2 - core::dimension2d<u32> realSize(size); - - if (realSize.Width % 2) - realSize.Width += 1; - - if (realSize.Height % 2) - realSize.Height += 1; - - if (ScreenSize != realSize) - { - if (ViewPort.getWidth() == (s32)ScreenSize.Width && - ViewPort.getHeight() == (s32)ScreenSize.Height) - { - ViewPort = core::rect<s32>(core::position2d<s32>(0,0), - core::dimension2di(realSize)); - } - - ScreenSize = realSize; - - bool resetRT = (RenderTargetSurface == BackBuffer); - - if (BackBuffer) - BackBuffer->drop(); - BackBuffer = new CImage(ECF_A1R5G5B5, realSize); - - if (resetRT) - setRenderTarget(BackBuffer); - } -} - -//! returns the current render target size -const core::dimension2d<u32>& CSoftwareDriver::getCurrentRenderTargetSize() const -{ - return RenderTargetSize; -} - - -//! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. -void CSoftwareDriver::draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos, - const core::rect<s32>& sourceRect, - const core::rect<s32>* clipRect, SColor color, - bool useAlphaChannelOfTexture) -{ - if (texture) - { - if (texture->getDriverType() != EDT_SOFTWARE) - { - os::Printer::log("Fatal Error: Tried to copy from a surface not owned by this driver.", ELL_ERROR); - return; - } - - if (useAlphaChannelOfTexture) - ((CSoftwareTexture*)texture)->getImage()->copyToWithAlpha( - RenderTargetSurface, destPos, sourceRect, color, clipRect); - else - ((CSoftwareTexture*)texture)->getImage()->copyTo( - RenderTargetSurface, destPos, sourceRect, clipRect); - } -} - - - -//! Draws a 2d line. -void CSoftwareDriver::draw2DLine(const core::position2d<s32>& start, - const core::position2d<s32>& end, - SColor color) -{ - RenderTargetSurface->drawLine(start, end, color ); -} - - -//! Draws a pixel -void CSoftwareDriver::drawPixel(u32 x, u32 y, const SColor & color) -{ - BackBuffer->setPixel(x, y, color, true); -} - - -//! draw a 2d rectangle -void CSoftwareDriver::draw2DRectangle(SColor color, const core::rect<s32>& pos, - const core::rect<s32>* clip) -{ - if (clip) - { - core::rect<s32> p(pos); - - p.clipAgainst(*clip); - - if(!p.isValid()) - return; - - RenderTargetSurface->drawRectangle(p, color); - } - else - { - if(!pos.isValid()) - return; - - RenderTargetSurface->drawRectangle(pos, color); - } -} - - -//!Draws an 2d rectangle with a gradient. -void CSoftwareDriver::draw2DRectangle(const core::rect<s32>& pos, - SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, - const core::rect<s32>* clip) -{ - // TODO: implement - draw2DRectangle(colorLeftUp, pos, clip); -} - - -//! \return Returns the name of the video driver. Example: In case of the Direct3D8 -//! driver, it would return "Direct3D8.1". -const wchar_t* CSoftwareDriver::getName() const -{ - return L"Irrlicht Software Driver 1.0"; -} - - -//! Returns type of video driver -E_DRIVER_TYPE CSoftwareDriver::getDriverType() const -{ - return EDT_SOFTWARE; -} - - -//! returns color format -ECOLOR_FORMAT CSoftwareDriver::getColorFormat() const -{ - if (BackBuffer) - return BackBuffer->getColorFormat(); - else - return CNullDriver::getColorFormat(); -} - - -//! Returns the transformation set by setTransform -const core::matrix4& CSoftwareDriver::getTransform(E_TRANSFORMATION_STATE state) const -{ - return TransformationMatrix[state]; -} - - -//! Creates a render target texture. -ITexture* CSoftwareDriver::addRenderTargetTexture(const core::dimension2d<u32>& size, - const io::path& name, - const ECOLOR_FORMAT format) -{ - CImage* img = new CImage(video::ECF_A1R5G5B5, size); - ITexture* tex = new CSoftwareTexture(img, name, true); - img->drop(); - addTexture(tex); - tex->drop(); - return tex; -} - - -//! Clears the ZBuffer. -void CSoftwareDriver::clearZBuffer() -{ - if (ZBuffer) - ZBuffer->clear(); -} - - -//! Returns an image created from the last rendered frame. -IImage* CSoftwareDriver::createScreenShot() -{ - if (BackBuffer) - return new CImage(BackBuffer->getColorFormat(), BackBuffer); - else - return 0; -} - - -//! Returns the maximum amount of primitives (mostly vertices) which -//! the device is able to render with one drawIndexedTriangleList -//! call. -u32 CSoftwareDriver::getMaximalPrimitiveCount() const -{ - return 0x00800000; -} - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - - -//! creates a video driver -IVideoDriver* createSoftwareDriver(const core::dimension2d<u32>& windowSize, bool fullscreen, io::IFileSystem* io, video::IImagePresenter* presenter) -{ - #ifdef _IRR_COMPILE_WITH_SOFTWARE_ - return new CSoftwareDriver(windowSize, fullscreen, io, presenter); - #else - return 0; - #endif -} - - -} // end namespace video -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CSoftwareDriver.h b/irrlicht-1.6/source/Irrlicht/CSoftwareDriver.h deleted file mode 100644 index 82eb3b812..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSoftwareDriver.h +++ /dev/null @@ -1,180 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_VIDEO_SOFTWARE_H_INCLUDED__ -#define __C_VIDEO_SOFTWARE_H_INCLUDED__ - -#include "ITriangleRenderer.h" -#include "CNullDriver.h" -#include "SViewFrustum.h" -#include "CImage.h" - -namespace irr -{ -namespace video -{ - class CSoftwareDriver : public CNullDriver - { - public: - - //! constructor - CSoftwareDriver(const core::dimension2d<u32>& windowSize, bool fullscreen, io::IFileSystem* io, video::IImagePresenter* presenter); - - //! destructor - virtual ~CSoftwareDriver(); - - //! queries the features of the driver, returns true if feature is available - virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const; - - //! sets transformation - virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat); - - //! sets a material - virtual void setMaterial(const SMaterial& material); - - virtual bool setRenderTarget(video::ITexture* texture, bool clearBackBuffer, - bool clearZBuffer, SColor color); - - //! sets a viewport - virtual void setViewPort(const core::rect<s32>& area); - - //! clears the zbuffer - virtual bool beginScene(bool backBuffer=true, bool zBuffer=true, - SColor color=SColor(255,0,0,0), - void* windowId=0, - core::rect<s32>* sourceRect=0); - - //! presents the rendered scene on the screen, returns false if failed - virtual bool endScene(); - - //! Only used by the internal engine. Used to notify the driver that - //! the window was resized. - virtual void OnResize(const core::dimension2d<u32>& size); - - //! returns size of the current render target - virtual const core::dimension2d<u32>& getCurrentRenderTargetSize() const; - - //! draws a vertex primitive list - void drawVertexPrimitiveList(const void* vertices, u32 vertexCount, - const void* indexList, u32 primitiveCount, - E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType); - - //! Draws a 3d line. - virtual void draw3DLine(const core::vector3df& start, - const core::vector3df& end, SColor color = SColor(255,255,255,255)); - - //! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. - virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos, - const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0, - SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false); - - //! draw an 2d rectangle - virtual void draw2DRectangle(SColor color, const core::rect<s32>& pos, - const core::rect<s32>* clip = 0); - - //!Draws an 2d rectangle with a gradient. - virtual void draw2DRectangle(const core::rect<s32>& pos, - SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, - const core::rect<s32>* clip = 0); - - //! Draws a 2d line. - virtual void draw2DLine(const core::position2d<s32>& start, - const core::position2d<s32>& end, - SColor color=SColor(255,255,255,255)); - - //! Draws a single pixel - virtual void drawPixel(u32 x, u32 y, const SColor & color); - - //! \return Returns the name of the video driver. Example: In case of the Direct3D8 - //! driver, it would return "Direct3D8.1". - virtual const wchar_t* getName() const; - - //! Returns type of video driver - virtual E_DRIVER_TYPE getDriverType() const; - - //! get color format of the current color buffer - virtual ECOLOR_FORMAT getColorFormat() const; - - //! Returns the transformation set by setTransform - virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) const; - - //! returns a device dependent texture from a software surface (IImage) - //! THIS METHOD HAS TO BE OVERRIDDEN BY DERIVED DRIVERS WITH OWN TEXTURES - virtual video::ITexture* createDeviceDependentTexture(IImage* surface, const io::path& name); - - //! Creates a render target texture. - virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size, - const io::path& name, const ECOLOR_FORMAT format = ECF_UNKNOWN); - - //! Clears the ZBuffer. - virtual void clearZBuffer(); - - //! Returns an image created from the last rendered frame. - virtual IImage* createScreenShot(); - - //! Returns the maximum amount of primitives (mostly vertices) which - //! the device is able to render with one drawIndexedTriangleList - //! call. - virtual u32 getMaximalPrimitiveCount() const; - - protected: - - //! sets a render target - void setRenderTarget(video::CImage* image); - - //! sets the current Texture - bool setActiveTexture(u32 stage, video::ITexture* texture); - - //! switches to a triangle renderer - void switchToTriangleRenderer(ETriangleRenderer renderer); - - //! void selects the right triangle renderer based on the render states. - void selectRightTriangleRenderer(); - - //! clips a triangle agains the viewing frustum - void clipTriangle(f32* transformedPos); - - - //! draws a vertex primitive list - void drawVertexPrimitiveList16(const void* vertices, u32 vertexCount, - const u16* indexList, u32 primitiveCount, - E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType); - - - template<class VERTEXTYPE> - void drawClippedIndexedTriangleListT(const VERTEXTYPE* vertices, - s32 vertexCount, const u16* indexList, s32 triangleCount); - - video::CImage* BackBuffer; - video::IImagePresenter* Presenter; - void* WindowId; - core::rect<s32>* SceneSourceRect; - - core::array<S2DVertex> TransformedPoints; - - video::ITexture* RenderTargetTexture; - video::CImage* RenderTargetSurface; - core::position2d<s32> Render2DTranslation; - core::dimension2d<u32> RenderTargetSize; - core::dimension2d<u32> ViewPortSize; - - core::matrix4 TransformationMatrix[ETS_COUNT]; - - ITriangleRenderer* CurrentTriangleRenderer; - ITriangleRenderer* TriangleRenderers[ETR_COUNT]; - ETriangleRenderer CurrentRenderer; - - IZBuffer* ZBuffer; - - video::ITexture* Texture; - - SMaterial Material; - }; - -} // end namespace video -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CSoftwareDriver2.cpp b/irrlicht-1.6/source/Irrlicht/CSoftwareDriver2.cpp deleted file mode 100644 index f3f79086f..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSoftwareDriver2.cpp +++ /dev/null @@ -1,2151 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "CSoftwareDriver2.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -#include "SoftwareDriver2_helper.h" -#include "CSoftwareTexture2.h" -#include "CSoftware2MaterialRenderer.h" -#include "S3DVertex.h" -#include "S4DVertex.h" - - -#define MAT_TEXTURE(tex) ( (video::CSoftwareTexture2*) Material.org.getTexture ( tex ) ) - - -namespace irr -{ -namespace video -{ - - -//! constructor -CBurningVideoDriver::CBurningVideoDriver(const core::dimension2d<u32>& windowSize, bool fullscreen, io::IFileSystem* io, video::IImagePresenter* presenter) -: CNullDriver(io, windowSize), BackBuffer(0), Presenter(presenter), - WindowId(0), SceneSourceRect(0), - RenderTargetTexture(0), RenderTargetSurface(0), CurrentShader(0), - DepthBuffer(0), CurrentOut ( 12 * 2, 128 ), Temp ( 12 * 2, 128 ) -{ - #ifdef _DEBUG - setDebugName("CBurningVideoDriver"); - #endif - - // create backbuffer - BackBuffer = new CImage(BURNINGSHADER_COLOR_FORMAT, windowSize); - if (BackBuffer) - { - BackBuffer->fill(SColor(0)); - - // create z buffer - DepthBuffer = video::createDepthBuffer(BackBuffer->getDimension()); - } - - // create triangle renderers - - irr::memset32 ( BurningShader, 0, sizeof ( BurningShader ) ); - //BurningShader[ETR_FLAT] = createTRFlat2(DepthBuffer); - //BurningShader[ETR_FLAT_WIRE] = createTRFlatWire2(DepthBuffer); - BurningShader[ETR_GOURAUD] = createTriangleRendererGouraud2(DepthBuffer); - BurningShader[ETR_GOURAUD_ALPHA] = createTriangleRendererGouraudAlpha2(DepthBuffer ); - BurningShader[ETR_GOURAUD_ALPHA_NOZ] = createTRGouraudAlphaNoZ2(DepthBuffer ); - //BurningShader[ETR_GOURAUD_WIRE] = createTriangleRendererGouraudWire2(DepthBuffer); - //BurningShader[ETR_TEXTURE_FLAT] = createTriangleRendererTextureFlat2(DepthBuffer); - //BurningShader[ETR_TEXTURE_FLAT_WIRE] = createTriangleRendererTextureFlatWire2(DepthBuffer); - BurningShader[ETR_TEXTURE_GOURAUD] = createTriangleRendererTextureGouraud2(DepthBuffer); - BurningShader[ETR_TEXTURE_GOURAUD_LIGHTMAP_M1] = createTriangleRendererTextureLightMap2_M1(DepthBuffer); - BurningShader[ETR_TEXTURE_GOURAUD_LIGHTMAP_M2] = createTriangleRendererTextureLightMap2_M2(DepthBuffer); - BurningShader[ETR_TEXTURE_GOURAUD_LIGHTMAP_M4] = createTriangleRendererGTextureLightMap2_M4(DepthBuffer); - BurningShader[ETR_TEXTURE_LIGHTMAP_M4] = createTriangleRendererTextureLightMap2_M4(DepthBuffer); - BurningShader[ETR_TEXTURE_GOURAUD_LIGHTMAP_ADD] = createTriangleRendererTextureLightMap2_Add(DepthBuffer); - BurningShader[ETR_TEXTURE_GOURAUD_DETAIL_MAP] = createTriangleRendererTextureDetailMap2(DepthBuffer); - - BurningShader[ETR_TEXTURE_GOURAUD_WIRE] = createTriangleRendererTextureGouraudWire2(DepthBuffer); - BurningShader[ETR_TEXTURE_GOURAUD_NOZ] = createTRTextureGouraudNoZ2(); - BurningShader[ETR_TEXTURE_GOURAUD_ADD] = createTRTextureGouraudAdd2(DepthBuffer); - BurningShader[ETR_TEXTURE_GOURAUD_ADD_NO_Z] = createTRTextureGouraudAddNoZ2(DepthBuffer); - BurningShader[ETR_TEXTURE_GOURAUD_VERTEX_ALPHA] = createTriangleRendererTextureVertexAlpha2 ( DepthBuffer ); - - BurningShader[ETR_TEXTURE_GOURAUD_ALPHA] = createTRTextureGouraudAlpha(DepthBuffer ); - BurningShader[ETR_TEXTURE_GOURAUD_ALPHA_NOZ] = createTRTextureGouraudAlphaNoZ( DepthBuffer ); - - BurningShader[ETR_TEXTURE_BLEND] = createTRTextureBlend( DepthBuffer ); - - BurningShader[ETR_REFERENCE] = createTriangleRendererReference ( DepthBuffer ); - - - // add the same renderer for all solid types - CSoftware2MaterialRenderer_SOLID* smr = new CSoftware2MaterialRenderer_SOLID( this); - CSoftware2MaterialRenderer_TRANSPARENT_ADD_COLOR* tmr = new CSoftware2MaterialRenderer_TRANSPARENT_ADD_COLOR( this); - CSoftware2MaterialRenderer_UNSUPPORTED * umr = new CSoftware2MaterialRenderer_UNSUPPORTED ( this ); - - //!TODO: addMaterialRenderer depends on pushing order.... - addMaterialRenderer ( smr ); // EMT_SOLID - addMaterialRenderer ( smr ); // EMT_SOLID_2_LAYER, - addMaterialRenderer ( smr ); // EMT_LIGHTMAP, - addMaterialRenderer ( tmr ); // EMT_LIGHTMAP_ADD, - addMaterialRenderer ( smr ); // EMT_LIGHTMAP_M2, - addMaterialRenderer ( smr ); // EMT_LIGHTMAP_M4, - addMaterialRenderer ( smr ); // EMT_LIGHTMAP_LIGHTING, - addMaterialRenderer ( smr ); // EMT_LIGHTMAP_LIGHTING_M2, - addMaterialRenderer ( smr ); // EMT_LIGHTMAP_LIGHTING_M4, - addMaterialRenderer ( smr ); // EMT_DETAIL_MAP, - addMaterialRenderer ( umr ); // EMT_SPHERE_MAP, - addMaterialRenderer ( smr ); // EMT_REFLECTION_2_LAYER, - addMaterialRenderer ( tmr ); // EMT_TRANSPARENT_ADD_COLOR, - addMaterialRenderer ( tmr ); // EMT_TRANSPARENT_ALPHA_CHANNEL, - addMaterialRenderer ( tmr ); // EMT_TRANSPARENT_ALPHA_CHANNEL_REF, - addMaterialRenderer ( tmr ); // EMT_TRANSPARENT_VERTEX_ALPHA, - addMaterialRenderer ( smr ); // EMT_TRANSPARENT_REFLECTION_2_LAYER, - addMaterialRenderer ( umr ); // EMT_NORMAL_MAP_SOLID, - addMaterialRenderer ( umr ); // EMT_NORMAL_MAP_TRANSPARENT_ADD_COLOR, - addMaterialRenderer ( umr ); // EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA, - addMaterialRenderer ( umr ); // EMT_PARALLAX_MAP_SOLID, - addMaterialRenderer ( umr ); // EMT_PARALLAX_MAP_TRANSPARENT_ADD_COLOR, - addMaterialRenderer ( umr ); // EMT_PARALLAX_MAP_TRANSPARENT_VERTEX_ALPHA, - addMaterialRenderer ( tmr ); // EMT_ONETEXTURE_BLEND - - smr->drop (); - tmr->drop (); - umr->drop (); - - // select render target - setRenderTarget(BackBuffer); - - //reset Lightspace - LightSpace.reset (); - - // select the right renderer - setCurrentShader(); -} - - -//! destructor -CBurningVideoDriver::~CBurningVideoDriver() -{ - // delete Backbuffer - if (BackBuffer) - BackBuffer->drop(); - - // delete triangle renderers - - for (s32 i=0; i<ETR2_COUNT; ++i) - if (BurningShader[i]) - BurningShader[i]->drop(); - - // delete zbuffer - - if (DepthBuffer) - DepthBuffer->drop(); - - if (RenderTargetTexture) - RenderTargetTexture->drop(); - - if (RenderTargetSurface) - RenderTargetSurface->drop(); -} - - -/*! - selects the right triangle renderer based on the render states. -*/ -void CBurningVideoDriver::setCurrentShader() -{ - ITexture *texture0 = Material.org.getTexture(0); - ITexture *texture1 = Material.org.getTexture(1); - - bool zMaterialTest = Material.org.ZBuffer != ECFN_NEVER && - Material.org.ZWriteEnable && - ( AllowZWriteOnTransparent || !Material.org.isTransparent() ); - - EBurningFFShader shader = zMaterialTest ? ETR_TEXTURE_GOURAUD : ETR_TEXTURE_GOURAUD_NOZ; - - TransformationFlag[ ETS_TEXTURE_0] &= ~(ETF_TEXGEN_CAMERA_NORMAL|ETF_TEXGEN_CAMERA_REFLECTION); - LightSpace.Flags &= ~VERTEXTRANSFORM; - - switch ( Material.org.MaterialType ) - { - case EMT_ONETEXTURE_BLEND: - shader = ETR_TEXTURE_BLEND; - break; - - case EMT_TRANSPARENT_ALPHA_CHANNEL_REF: - Material.org.MaterialTypeParam = 0.5f; - // fall through - case EMT_TRANSPARENT_ALPHA_CHANNEL: - if ( texture0 && texture0->hasAlpha () ) - { - shader = zMaterialTest ? ETR_TEXTURE_GOURAUD_ALPHA : ETR_TEXTURE_GOURAUD_ALPHA_NOZ; - break; - } - // fall through - - case EMT_TRANSPARENT_ADD_COLOR: - shader = zMaterialTest ? ETR_TEXTURE_GOURAUD_ADD : ETR_TEXTURE_GOURAUD_ADD_NO_Z; - break; - - case EMT_TRANSPARENT_VERTEX_ALPHA: - shader = ETR_TEXTURE_GOURAUD_VERTEX_ALPHA; - break; - - case EMT_LIGHTMAP: - case EMT_LIGHTMAP_LIGHTING: - shader = ETR_TEXTURE_GOURAUD_LIGHTMAP_M1; - break; - - case EMT_LIGHTMAP_M2: - case EMT_LIGHTMAP_LIGHTING_M2: - shader = ETR_TEXTURE_GOURAUD_LIGHTMAP_M2; - break; - - case EMT_LIGHTMAP_LIGHTING_M4: - if ( texture1 ) - shader = ETR_TEXTURE_GOURAUD_LIGHTMAP_M4; - break; - case EMT_LIGHTMAP_M4: - if ( texture1 ) - shader = ETR_TEXTURE_LIGHTMAP_M4; - break; - - case EMT_LIGHTMAP_ADD: - if ( texture1 ) - shader = ETR_TEXTURE_GOURAUD_LIGHTMAP_ADD; - break; - - case EMT_DETAIL_MAP: - shader = ETR_TEXTURE_GOURAUD_DETAIL_MAP; - break; - - case EMT_SPHERE_MAP: - TransformationFlag[ ETS_TEXTURE_0] |= ETF_TEXGEN_CAMERA_REFLECTION; // ETF_TEXGEN_CAMERA_NORMAL; - LightSpace.Flags |= VERTEXTRANSFORM; - break; - case EMT_REFLECTION_2_LAYER: - shader = ETR_TEXTURE_GOURAUD_LIGHTMAP_M1; - TransformationFlag[ ETS_TEXTURE_1] |= ETF_TEXGEN_CAMERA_REFLECTION; - LightSpace.Flags |= VERTEXTRANSFORM; - break; - - default: - break; - - } - - if ( !texture0 ) - { - shader = ETR_GOURAUD; - } - - if ( Material.org.Wireframe ) - { - shader = ETR_TEXTURE_GOURAUD_WIRE; - } - - //shader = ETR_REFERENCE; - - // switchToTriangleRenderer - CurrentShader = BurningShader[shader]; - if ( CurrentShader ) - { - CurrentShader->setZCompareFunc ( Material.org.ZBuffer ); - CurrentShader->setRenderTarget(RenderTargetSurface, ViewPort); - CurrentShader->setMaterial ( Material ); - - switch ( shader ) - { - case ETR_TEXTURE_GOURAUD_ALPHA: - case ETR_TEXTURE_GOURAUD_ALPHA_NOZ: - case ETR_TEXTURE_BLEND: - CurrentShader->setParam ( 0, Material.org.MaterialTypeParam ); - break; - default: - break; - } - } - -} - - - -//! queries the features of the driver, returns true if feature is available -bool CBurningVideoDriver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const -{ - if (!FeatureEnabled[feature]) - return false; - - switch (feature) - { -#ifdef SOFTWARE_DRIVER_2_BILINEAR - case EVDF_BILINEAR_FILTER: - return true; -#endif -#ifdef SOFTWARE_DRIVER_2_MIPMAPPING - case EVDF_MIP_MAP: - return true; -#endif - case EVDF_RENDER_TO_TARGET: - case EVDF_MULTITEXTURE: - case EVDF_HARDWARE_TL: - case EVDF_TEXTURE_NSQUARE: - return true; - - default: - return false; - } -} - - - -//! sets transformation -void CBurningVideoDriver::setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat) -{ - Transformation[state] = mat; - core::setbit_cond ( TransformationFlag[state], mat.isIdentity(), ETF_IDENTITY ); - - switch ( state ) - { - case ETS_VIEW: - Transformation[ETS_VIEW_PROJECTION].setbyproduct_nocheck ( - Transformation[ETS_PROJECTION], - Transformation[ETS_VIEW] - ); - getCameraPosWorldSpace (); - break; - - case ETS_WORLD: - if ( TransformationFlag[state] & ETF_IDENTITY ) - { - Transformation[ETS_CURRENT] = Transformation[ETS_VIEW_PROJECTION]; - } - else - { - Transformation[ETS_CURRENT].setbyproduct_nocheck ( - Transformation[ETS_VIEW_PROJECTION], - Transformation[ETS_WORLD] - ); - } - TransformationFlag[ETS_CURRENT] = 0; - break; - case ETS_TEXTURE_0: - case ETS_TEXTURE_1: - case ETS_TEXTURE_2: - case ETS_TEXTURE_3: - if ( 0 == (TransformationFlag[state] & ETF_IDENTITY ) ) - LightSpace.Flags |= VERTEXTRANSFORM; - default: - break; - } -} - - -//! clears the zbuffer -bool CBurningVideoDriver::beginScene(bool backBuffer, bool zBuffer, - SColor color, void* windowId, core::rect<s32>* sourceRect) -{ - CNullDriver::beginScene(backBuffer, zBuffer, color, windowId, sourceRect); - WindowId = windowId; - SceneSourceRect = sourceRect; - - if (backBuffer && BackBuffer) - BackBuffer->fill(color); - - if (zBuffer && DepthBuffer) - DepthBuffer->clear(); - - memset ( TransformationFlag, 0, sizeof ( TransformationFlag ) ); - return true; -} - - -//! presents the rendered scene on the screen, returns false if failed -bool CBurningVideoDriver::endScene() -{ - CNullDriver::endScene(); - - return Presenter->present(BackBuffer, WindowId, SceneSourceRect); -} - - -//! sets a render target -bool CBurningVideoDriver::setRenderTarget(video::ITexture* texture, bool clearBackBuffer, - bool clearZBuffer, SColor color) -{ - if (texture && texture->getDriverType() != EDT_BURNINGSVIDEO) - { - os::Printer::log("Fatal Error: Tried to set a texture not owned by this driver.", ELL_ERROR); - return false; - } - - if (RenderTargetTexture) - RenderTargetTexture->drop(); - - RenderTargetTexture = texture; - - if (RenderTargetTexture) - { - RenderTargetTexture->grab(); - setRenderTarget(((CSoftwareTexture2*)RenderTargetTexture)->getTexture()); - } - else - { - setRenderTarget(BackBuffer); - } - - if (RenderTargetSurface && (clearBackBuffer || clearZBuffer)) - { - if (clearZBuffer) - DepthBuffer->clear(); - - if (clearBackBuffer) - RenderTargetSurface->fill( color ); - } - - return true; -} - - -//! sets a render target -void CBurningVideoDriver::setRenderTarget(video::CImage* image) -{ - if (RenderTargetSurface) - RenderTargetSurface->drop(); - - RenderTargetSurface = image; - RenderTargetSize.Width = 0; - RenderTargetSize.Height = 0; - - if (RenderTargetSurface) - { - RenderTargetSurface->grab(); - RenderTargetSize = RenderTargetSurface->getDimension(); - } - - setViewPort(core::rect<s32>(0,0,RenderTargetSize.Width,RenderTargetSize.Height)); - - if (DepthBuffer) - DepthBuffer->setSize(RenderTargetSize); -} - - - -//! sets a viewport -void CBurningVideoDriver::setViewPort(const core::rect<s32>& area) -{ - ViewPort = area; - - core::rect<s32> rendert(0,0,RenderTargetSize.Width,RenderTargetSize.Height); - ViewPort.clipAgainst(rendert); - - Transformation [ ETS_CLIPSCALE ].buildNDCToDCMatrix ( ViewPort, 1 ); - - - if (CurrentShader) - CurrentShader->setRenderTarget(RenderTargetSurface, ViewPort); -} - -/* - generic plane clipping in homogenous coordinates - special case ndc frustum <-w,w>,<-w,w>,<-w,w> - can be rewritten with compares e.q near plane, a.z < -a.w and b.z < -b.w -*/ - -const sVec4 CBurningVideoDriver::NDCPlane[6] = -{ - sVec4( 0.f, 0.f, -1.f, -1.f ), // near - sVec4( 0.f, 0.f, 1.f, -1.f ), // far - sVec4( 1.f, 0.f, 0.f, -1.f ), // left - sVec4( -1.f, 0.f, 0.f, -1.f ), // right - sVec4( 0.f, 1.f, 0.f, -1.f ), // bottom - sVec4( 0.f, -1.f, 0.f, -1.f ) // top -}; - - - -/* - test a vertex if it's inside the standard frustum - - this is the generic one.. - - f32 dotPlane; - for ( u32 i = 0; i!= 6; ++i ) - { - dotPlane = v->Pos.dotProduct ( NDCPlane[i] ); - core::setbit_cond( flag, dotPlane <= 0.f, 1 << i ); - } - - // this is the base for ndc frustum <-w,w>,<-w,w>,<-w,w> - core::setbit_cond( flag, ( v->Pos.z - v->Pos.w ) <= 0.f, 1 ); - core::setbit_cond( flag, (-v->Pos.z - v->Pos.w ) <= 0.f, 2 ); - core::setbit_cond( flag, ( v->Pos.x - v->Pos.w ) <= 0.f, 4 ); - core::setbit_cond( flag, (-v->Pos.x - v->Pos.w ) <= 0.f, 8 ); - core::setbit_cond( flag, ( v->Pos.y - v->Pos.w ) <= 0.f, 16 ); - core::setbit_cond( flag, (-v->Pos.y - v->Pos.w ) <= 0.f, 32 ); - -*/ -#ifdef IRRLICHT_FAST_MATH - -REALINLINE u32 CBurningVideoDriver::clipToFrustumTest ( const s4DVertex * v ) const -{ - f32 test[6]; - u32 flag; - const f32 w = - v->Pos.w; - - // a conditional move is needed....FCOMI ( but we don't have it ) - // so let the fpu calculate and write it back. - // cpu makes the compare, interleaving - - test[0] = v->Pos.z + w; - test[1] = -v->Pos.z + w; - test[2] = v->Pos.x + w; - test[3] = -v->Pos.x + w; - test[4] = v->Pos.y + w; - test[5] = -v->Pos.y + w; - - flag = (IR ( test[0] ) ) >> 31; - flag |= (IR ( test[1] ) & 0x80000000 ) >> 30; - flag |= (IR ( test[2] ) & 0x80000000 ) >> 29; - flag |= (IR ( test[3] ) & 0x80000000 ) >> 28; - flag |= (IR ( test[4] ) & 0x80000000 ) >> 27; - flag |= (IR ( test[5] ) & 0x80000000 ) >> 26; - -/* - flag = F32_LOWER_EQUAL_0 ( test[0] ); - flag |= F32_LOWER_EQUAL_0 ( test[1] ) << 1; - flag |= F32_LOWER_EQUAL_0 ( test[2] ) << 2; - flag |= F32_LOWER_EQUAL_0 ( test[3] ) << 3; - flag |= F32_LOWER_EQUAL_0 ( test[4] ) << 4; - flag |= F32_LOWER_EQUAL_0 ( test[5] ) << 5; -*/ - return flag; -} - -#else - - -REALINLINE u32 CBurningVideoDriver::clipToFrustumTest ( const s4DVertex * v ) const -{ - u32 flag = 0; - - if ( v->Pos.z <= v->Pos.w ) flag |= 1; - if (-v->Pos.z <= v->Pos.w ) flag |= 2; - - if ( v->Pos.x <= v->Pos.w ) flag |= 4; - if (-v->Pos.x <= v->Pos.w ) flag |= 8; - - if ( v->Pos.y <= v->Pos.w ) flag |= 16; - if (-v->Pos.y <= v->Pos.w ) flag |= 32; - -/* - for ( u32 i = 0; i!= 6; ++i ) - { - core::setbit_cond( flag, v->Pos.dotProduct ( NDCPlane[i] ) <= 0.f, 1 << i ); - } -*/ - return flag; -} - -#endif // _MSC_VER - -u32 CBurningVideoDriver::clipToHyperPlane ( s4DVertex * dest, const s4DVertex * source, u32 inCount, const sVec4 &plane ) -{ - u32 outCount = 0; - s4DVertex * out = dest; - - const s4DVertex * a; - const s4DVertex * b = source; - - f32 bDotPlane; - - bDotPlane = b->Pos.dotProduct ( plane ); - - for( u32 i = 1; i < inCount + 1; ++i) - { - const s32 condition = i - inCount; - const s32 index = (( ( condition >> 31 ) & ( i ^ condition ) ) ^ condition ) << 1; - - a = &source[ index ]; - - // current point inside - if ( a->Pos.dotProduct ( plane ) <= 0.f ) - { - // last point outside - if ( F32_GREATER_0 ( bDotPlane ) ) - { - // intersect line segment with plane - out->interpolate ( *b, *a, bDotPlane / (b->Pos - a->Pos).dotProduct ( plane ) ); - out += 2; - outCount += 1; - } - - // copy current to out - //*out = *a; - irr::memcpy32_small ( out, a, SIZEOF_SVERTEX * 2 ); - b = out; - - out += 2; - outCount += 1; - } - else - { - // current point outside - - if ( F32_LOWER_EQUAL_0 ( bDotPlane ) ) - { - // previous was inside - // intersect line segment with plane - out->interpolate ( *b, *a, bDotPlane / (b->Pos - a->Pos).dotProduct ( plane ) ); - out += 2; - outCount += 1; - } - // pointer - b = a; - } - - bDotPlane = b->Pos.dotProduct ( plane ); - - } - - return outCount; -} - - -u32 CBurningVideoDriver::clipToFrustum ( s4DVertex *v0, s4DVertex * v1, const u32 vIn ) -{ - u32 vOut = vIn; - - vOut = clipToHyperPlane ( v1, v0, vOut, NDCPlane[0] ); if ( vOut < vIn ) return vOut; - vOut = clipToHyperPlane ( v0, v1, vOut, NDCPlane[1] ); if ( vOut < vIn ) return vOut; - vOut = clipToHyperPlane ( v1, v0, vOut, NDCPlane[2] ); if ( vOut < vIn ) return vOut; - vOut = clipToHyperPlane ( v0, v1, vOut, NDCPlane[3] ); if ( vOut < vIn ) return vOut; - vOut = clipToHyperPlane ( v1, v0, vOut, NDCPlane[4] ); if ( vOut < vIn ) return vOut; - vOut = clipToHyperPlane ( v0, v1, vOut, NDCPlane[5] ); - return vOut; -} - -/*! - Part I: - apply Clip Scale matrix - From Normalized Device Coordiante ( NDC ) Space to Device Coordinate Space ( DC ) - - Part II: - Project homogeneous vector - homogeneous to non-homogenous coordinates ( dividebyW ) - - Incoming: ( xw, yw, zw, w, u, v, 1, R, G, B, A ) - Outgoing: ( xw/w, yw/w, zw/w, w/w, u/w, v/w, 1/w, R/w, G/w, B/w, A/w ) - - - replace w/w by 1/w -*/ -inline void CBurningVideoDriver::ndc_2_dc_and_project ( s4DVertex *dest,s4DVertex *source, u32 vIn ) const -{ - u32 g; - - for ( g = 0; g != vIn; g += 2 ) - { - if ( (dest[g].flag & VERTEX4D_PROJECTED ) == VERTEX4D_PROJECTED ) - continue; - - dest[g].flag = source[g].flag | VERTEX4D_PROJECTED; - - const f32 w = source[g].Pos.w; - const f32 iw = core::reciprocal ( w ); - - // to device coordinates - dest[g].Pos.x = iw * ( source[g].Pos.x * Transformation [ ETS_CLIPSCALE ][ 0] + w * Transformation [ ETS_CLIPSCALE ][12] ); - dest[g].Pos.y = iw * ( source[g].Pos.y * Transformation [ ETS_CLIPSCALE ][ 5] + w * Transformation [ ETS_CLIPSCALE ][13] ); - -#ifndef SOFTWARE_DRIVER_2_USE_WBUFFER - dest[g].Pos.z = iw * source[g].Pos.z; -#endif - - #ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #ifdef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - dest[g].Color[0] = source[g].Color[0] * iw; - #else - dest[g].Color[0] = source[g].Color[0]; - #endif - - #endif - - dest[g].Pos.w = iw; - } -} - - -inline void CBurningVideoDriver::ndc_2_dc_and_project2 ( const s4DVertex **v, const u32 size ) const -{ - u32 g; - - for ( g = 0; g != size; g += 1 ) - { - s4DVertex * a = (s4DVertex*) v[g]; - - if ( (a[1].flag & VERTEX4D_PROJECTED ) == VERTEX4D_PROJECTED ) - continue; - - a[1].flag = a->flag | VERTEX4D_PROJECTED; - - // project homogenous vertex, store 1/w - const f32 w = a->Pos.w; - const f32 iw = core::reciprocal ( w ); - - // to device coordinates - const f32 * p = Transformation [ ETS_CLIPSCALE ].pointer(); - a[1].Pos.x = iw * ( a->Pos.x * p[ 0] + w * p[12] ); - a[1].Pos.y = iw * ( a->Pos.y * p[ 5] + w * p[13] ); - -#ifndef SOFTWARE_DRIVER_2_USE_WBUFFER - a[1].Pos.z = a->Pos.z * iw; -#endif - - #ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #ifdef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - a[1].Color[0] = a->Color[0] * iw; - #else - a[1].Color[0] = a->Color[0]; - #endif - #endif - - a[1].Pos.w = iw; - - } - -} - - -/*! - crossproduct in projected 2D -> screen area triangle -*/ -inline f32 CBurningVideoDriver::screenarea ( const s4DVertex *v ) const -{ - return ( ( v[3].Pos.x - v[1].Pos.x ) * ( v[5].Pos.y - v[1].Pos.y ) ) - - ( ( v[3].Pos.y - v[1].Pos.y ) * ( v[5].Pos.x - v[1].Pos.x ) ); -} - - -/*! -*/ -inline f32 CBurningVideoDriver::texelarea ( const s4DVertex *v, int tex ) const -{ - f32 z; - - z = ( (v[2].Tex[tex].x - v[0].Tex[tex].x ) * (v[4].Tex[tex].y - v[0].Tex[tex].y ) ) - - ( (v[4].Tex[tex].x - v[0].Tex[tex].x ) * (v[2].Tex[tex].y - v[0].Tex[tex].y ) ); - - return MAT_TEXTURE ( tex )->getLODFactor ( z ); -} - -/*! - crossproduct in projected 2D -*/ -inline f32 CBurningVideoDriver::screenarea2 ( const s4DVertex **v ) const -{ - return ( (( v[1] + 1 )->Pos.x - (v[0] + 1 )->Pos.x ) * ( (v[2] + 1 )->Pos.y - (v[0] + 1 )->Pos.y ) ) - - ( (( v[1] + 1 )->Pos.y - (v[0] + 1 )->Pos.y ) * ( (v[2] + 1 )->Pos.x - (v[0] + 1 )->Pos.x ) ); -} - -/*! -*/ -inline f32 CBurningVideoDriver::texelarea2 ( const s4DVertex **v, s32 tex ) const -{ - f32 z; - z = ( (v[1]->Tex[tex].x - v[0]->Tex[tex].x ) * (v[2]->Tex[tex].y - v[0]->Tex[tex].y ) ) - - ( (v[2]->Tex[tex].x - v[0]->Tex[tex].x ) * (v[1]->Tex[tex].y - v[0]->Tex[tex].y ) ); - - return MAT_TEXTURE ( tex )->getLODFactor ( z ); -} - - -/*! -*/ -inline void CBurningVideoDriver::select_polygon_mipmap ( s4DVertex *v, u32 vIn, u32 tex, const core::dimension2du& texSize ) -{ - f32 f[2]; - - f[0] = (f32) texSize.Width - 0.25f; - f[1] = (f32) texSize.Height - 0.25f; - -#ifdef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - for ( u32 g = 0; g != vIn; g += 2 ) - { - (v + g + 1 )->Tex[tex].x = (v + g + 0)->Tex[tex].x * ( v + g + 1 )->Pos.w * f[0]; - (v + g + 1 )->Tex[tex].y = (v + g + 0)->Tex[tex].y * ( v + g + 1 )->Pos.w * f[1]; - } -#else - for ( u32 g = 0; g != vIn; g += 2 ) - { - (v + g + 1 )->Tex[tex].x = (v + g + 0)->Tex[tex].x * f[0]; - (v + g + 1 )->Tex[tex].y = (v + g + 0)->Tex[tex].y * f[1]; - } -#endif -} - -inline void CBurningVideoDriver::select_polygon_mipmap2 ( s4DVertex **v, u32 tex, const core::dimension2du& texSize ) const -{ - f32 f[2]; - - f[0] = (f32) texSize.Width - 0.25f; - f[1] = (f32) texSize.Height - 0.25f; - -#ifdef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - (v[0] + 1 )->Tex[tex].x = v[0]->Tex[tex].x * ( v[0] + 1 )->Pos.w * f[0]; - (v[0] + 1 )->Tex[tex].y = v[0]->Tex[tex].y * ( v[0] + 1 )->Pos.w * f[1]; - - (v[1] + 1 )->Tex[tex].x = v[1]->Tex[tex].x * ( v[1] + 1 )->Pos.w * f[0]; - (v[1] + 1 )->Tex[tex].y = v[1]->Tex[tex].y * ( v[1] + 1 )->Pos.w * f[1]; - - (v[2] + 1 )->Tex[tex].x = v[2]->Tex[tex].x * ( v[2] + 1 )->Pos.w * f[0]; - (v[2] + 1 )->Tex[tex].y = v[2]->Tex[tex].y * ( v[2] + 1 )->Pos.w * f[1]; - -#else - (v[0] + 1 )->Tex[tex].x = v[0]->Tex[tex].x * f[0]; - (v[0] + 1 )->Tex[tex].y = v[0]->Tex[tex].y * f[1]; - - (v[1] + 1 )->Tex[tex].x = v[1]->Tex[tex].x * f[0]; - (v[1] + 1 )->Tex[tex].y = v[1]->Tex[tex].y * f[1]; - - (v[2] + 1 )->Tex[tex].x = v[2]->Tex[tex].x * f[0]; - (v[2] + 1 )->Tex[tex].y = v[2]->Tex[tex].y * f[1]; -#endif -} - -// Vertex Cache -const SVSize CBurningVideoDriver::vSize[] = -{ - { VERTEX4D_FORMAT_TEXTURE_1 | VERTEX4D_FORMAT_COLOR_1, sizeof(S3DVertex), 1 }, - { VERTEX4D_FORMAT_TEXTURE_2 | VERTEX4D_FORMAT_COLOR_1, sizeof(S3DVertex2TCoords),2 }, - { VERTEX4D_FORMAT_TEXTURE_2 | VERTEX4D_FORMAT_COLOR_1, sizeof(S3DVertexTangents),2 }, - { VERTEX4D_FORMAT_TEXTURE_2 | VERTEX4D_FORMAT_COLOR_1, sizeof(S3DVertex), 2 }, -}; - - - -/*! - fill a cache line with transformed, light and clipp test triangles -*/ -void CBurningVideoDriver::VertexCache_fill(const u32 sourceIndex, - const u32 destIndex) -{ - u8 * source; - s4DVertex *dest; - - source = (u8*) VertexCache.vertices + ( sourceIndex * vSize[VertexCache.vType].Pitch ); - - // it's a look ahead so we never hit it.. - // but give priority... - //VertexCache.info[ destIndex ].hit = hitCount; - - // store info - VertexCache.info[ destIndex ].index = sourceIndex; - VertexCache.info[ destIndex ].hit = 0; - - // destination Vertex - dest = (s4DVertex *) ( (u8*) VertexCache.mem.data + ( destIndex << ( SIZEOF_SVERTEX_LOG2 + 1 ) ) ); - - // transform Model * World * Camera * Projection * NDCSpace matrix - const S3DVertex *base = ((S3DVertex*) source ); - Transformation [ ETS_CURRENT].transformVect ( &dest->Pos.x, base->Pos ); - - -#if defined (SOFTWARE_DRIVER_2_LIGHTING) || defined ( SOFTWARE_DRIVER_2_TEXTURE_TRANSFORM ) - - // vertex normal in light space - if ( Material.org.Lighting || (LightSpace.Flags & VERTEXTRANSFORM) ) - { - if ( TransformationFlag[ETS_WORLD] & ETF_IDENTITY ) - { - LightSpace.normal.set ( base->Normal.X, base->Normal.Y, base->Normal.Z, 1.f ); - LightSpace.vertex.set ( base->Pos.X, base->Pos.Y, base->Pos.Z, 1.f ); - } - else - { - Transformation[ETS_WORLD].rotateVect ( &LightSpace.normal.x, base->Normal ); - if ( LightSpace.Flags & NORMALIZE ) - LightSpace.normal.normalize_xyz(); - - // vertex in light space - if ( LightSpace.Flags & ( POINTLIGHT | FOG | SPECULAR | VERTEXTRANSFORM) ) - Transformation[ETS_WORLD].transformVect ( &LightSpace.vertex.x, base->Pos ); - } - - } -#endif - -#if defined ( SOFTWARE_DRIVER_2_USE_VERTEX_COLOR ) - // apply lighting model - #if defined (SOFTWARE_DRIVER_2_LIGHTING) - if ( Material.org.Lighting ) - { - lightVertex ( dest, base->Color.color ); - } - else - { - dest->Color[0].setA8R8G8B8 ( base->Color.color ); - } - #else - dest->Color[0].setA8R8G8B8 ( base->Color.color ); - #endif -#endif - - // Texture Transform -#if !defined ( SOFTWARE_DRIVER_2_TEXTURE_TRANSFORM ) - irr::memcpy32_small ( &dest->Tex[0],&base->TCoords, - vSize[VertexCache.vType].TexSize << 3 // * ( sizeof ( f32 ) * 2 ) - ); -#else - - if ( 0 == (LightSpace.Flags & VERTEXTRANSFORM) ) - { - irr::memcpy32_small ( &dest->Tex[0],&base->TCoords, - vSize[VertexCache.vType].TexSize << 3 // * ( sizeof ( f32 ) * 2 ) - ); - } - else - { - /* - Generate texture coordinates as linear functions so that: - u = Ux*x + Uy*y + Uz*z + Uw - v = Vx*x + Vy*y + Vz*z + Vw - The matrix M for this case is: - Ux Vx 0 0 - Uy Vy 0 0 - Uz Vz 0 0 - Uw Vw 0 0 - */ - - u32 t; - sVec4 n; - sVec2 srcT; - - for ( t = 0; t != vSize[VertexCache.vType].TexSize; ++t ) - { - const core::matrix4& M = Transformation [ ETS_TEXTURE_0 + t ]; - - // texgen - if ( TransformationFlag [ ETS_TEXTURE_0 + t ] & (ETF_TEXGEN_CAMERA_NORMAL|ETF_TEXGEN_CAMERA_REFLECTION) ) - { - n.x = LightSpace.campos.x - LightSpace.vertex.x; - n.y = LightSpace.campos.x - LightSpace.vertex.y; - n.z = LightSpace.campos.x - LightSpace.vertex.z; - n.normalize_xyz(); - n.x += LightSpace.normal.x; - n.y += LightSpace.normal.y; - n.z += LightSpace.normal.z; - n.normalize_xyz(); - - const f32 *view = Transformation[ETS_VIEW].pointer(); - - if ( TransformationFlag [ ETS_TEXTURE_0 + t ] & ETF_TEXGEN_CAMERA_REFLECTION ) - { - srcT.x = 0.5f * ( 1.f + (n.x * view[0] + n.y * view[4] + n.z * view[8] )); - srcT.y = 0.5f * ( 1.f + (n.x * view[1] + n.y * view[5] + n.z * view[9] )); - } - else - { - srcT.x = 0.5f * ( 1.f + (n.x * view[0] + n.y * view[1] + n.z * view[2] )); - srcT.y = 0.5f * ( 1.f + (n.x * view[4] + n.y * view[5] + n.z * view[6] )); - } - } - else - { - irr::memcpy32_small ( &srcT,(&base->TCoords) + t, - sizeof ( f32 ) * 2 ); - } - - switch ( Material.org.TextureLayer[t].TextureWrap ) - { - case ETC_REPEAT: - default: - dest->Tex[t].x = M[0] * srcT.x + M[4] * srcT.y + M[8]; - dest->Tex[t].y = M[1] * srcT.x + M[5] * srcT.y + M[9]; - break; - case ETC_CLAMP: - case ETC_CLAMP_TO_EDGE: - dest->Tex[t].x = core::clamp ( (f32) ( M[0] * srcT.x + M[4] * srcT.y + M[8] ), 0.f, 1.f ); - dest->Tex[t].y = core::clamp ( (f32) ( M[1] * srcT.x + M[5] * srcT.y + M[9] ), 0.f, 1.f ); - break; - } - } - - } -#endif - - dest[0].flag = dest[1].flag = vSize[VertexCache.vType].Format; - - // test vertex - dest[0].flag |= clipToFrustumTest ( dest); - - // to DC Space, project homogenous vertex - if ( (dest[0].flag & VERTEX4D_CLIPMASK ) == VERTEX4D_INSIDE ) - { - ndc_2_dc_and_project2 ( (const s4DVertex**) &dest, 1 ); - } - - //return dest; -} - -// - -REALINLINE s4DVertex * CBurningVideoDriver::VertexCache_getVertex ( const u32 sourceIndex ) -{ - for ( s32 i = 0; i < VERTEXCACHE_ELEMENT; ++i ) - { - if ( VertexCache.info[ i ].index == sourceIndex ) - { - return (s4DVertex *) ( (u8*) VertexCache.mem.data + ( i << ( SIZEOF_SVERTEX_LOG2 + 1 ) ) ); - } - } - return 0; -} - - -/* - Cache based on linear walk indices - fill blockwise on the next 16(Cache_Size) unique vertices in indexlist - merge the next 16 vertices with the current -*/ -REALINLINE void CBurningVideoDriver::VertexCache_get ( s4DVertex ** face ) -{ - SCacheInfo info[VERTEXCACHE_ELEMENT]; - - // next primitive must be complete in cache - if ( VertexCache.indicesIndex - VertexCache.indicesRun < 3 && - VertexCache.indicesIndex < VertexCache.indexCount - ) - { - // rewind to start of primitive - VertexCache.indicesIndex = VertexCache.indicesRun; - - irr::memset32 ( info, VERTEXCACHE_MISS, sizeof ( info ) ); - - // get the next unique vertices cache line - u32 fillIndex = 0; - u32 dIndex; - u32 i; - u32 sourceIndex; - - while ( VertexCache.indicesIndex < VertexCache.indexCount && - fillIndex < VERTEXCACHE_ELEMENT - ) - { - sourceIndex = VertexCache.iType == 1 ? - ((u16*)VertexCache.indices) [ VertexCache.indicesIndex ] : - ((u32*)VertexCache.indices) [ VertexCache.indicesIndex ]; - - - VertexCache.indicesIndex += 1; - - // if not exist, push back - s32 exist = 0; - for ( dIndex = 0; dIndex < fillIndex; ++dIndex ) - { - if ( info[ dIndex ].index == sourceIndex ) - { - exist = 1; - break; - } - } - - if ( 0 == exist ) - { - info[fillIndex++].index = sourceIndex; - } - } - - // clear marks - for ( i = 0; i!= VERTEXCACHE_ELEMENT; ++i ) - { - VertexCache.info[i].hit = 0; - } - - // mark all existing - for ( i = 0; i!= fillIndex; ++i ) - { - for ( dIndex = 0; dIndex < VERTEXCACHE_ELEMENT; ++dIndex ) - { - if ( VertexCache.info[ dIndex ].index == info[i].index ) - { - info[i].hit = dIndex; - VertexCache.info[ dIndex ].hit = 1; - break; - } - } - } - - // fill new - for ( i = 0; i!= fillIndex; ++i ) - { - if ( info[i].hit != VERTEXCACHE_MISS ) - continue; - - for ( dIndex = 0; dIndex < VERTEXCACHE_ELEMENT; ++dIndex ) - { - if ( 0 == VertexCache.info[dIndex].hit ) - { - VertexCache_fill ( info[i].index, dIndex ); - VertexCache.info[dIndex].hit += 1; - info[i].hit = dIndex; - break; - } - } - } - } - - const u32 i0 = core::if_c_a_else_0 ( VertexCache.pType != scene::EPT_TRIANGLE_FAN, VertexCache.indicesRun ); - - if ( VertexCache.iType == 1 ) - { - const u16 *p = (const u16 *) VertexCache.indices; - face[0] = VertexCache_getVertex ( p[ i0 ] ); - face[1] = VertexCache_getVertex ( p[ VertexCache.indicesRun + 1] ); - face[2] = VertexCache_getVertex ( p[ VertexCache.indicesRun + 2] ); - } - else - { - const u32 *p = (const u32 *) VertexCache.indices; - face[0] = VertexCache_getVertex ( p[ i0 ] ); - face[1] = VertexCache_getVertex ( p[ VertexCache.indicesRun + 1] ); - face[2] = VertexCache_getVertex ( p[ VertexCache.indicesRun + 2] ); - } - - VertexCache.indicesRun += VertexCache.primitivePitch; -} - -/*! -*/ -REALINLINE void CBurningVideoDriver::VertexCache_getbypass ( s4DVertex ** face ) -{ - const u32 i0 = core::if_c_a_else_0 ( VertexCache.pType != scene::EPT_TRIANGLE_FAN, VertexCache.indicesRun ); - - if ( VertexCache.iType == 1 ) - { - const u16 *p = (const u16 *) VertexCache.indices; - VertexCache_fill ( p[ i0 ], 0 ); - VertexCache_fill ( p[ VertexCache.indicesRun + 1], 1 ); - VertexCache_fill ( p[ VertexCache.indicesRun + 2], 2 ); - } - else - { - const u32 *p = (const u32 *) VertexCache.indices; - VertexCache_fill ( p[ i0 ], 0 ); - VertexCache_fill ( p[ VertexCache.indicesRun + 1], 1 ); - VertexCache_fill ( p[ VertexCache.indicesRun + 2], 2 ); - } - - VertexCache.indicesRun += VertexCache.primitivePitch; - - face[0] = (s4DVertex *) ( (u8*) VertexCache.mem.data + ( 0 << ( SIZEOF_SVERTEX_LOG2 + 1 ) ) ); - face[1] = (s4DVertex *) ( (u8*) VertexCache.mem.data + ( 1 << ( SIZEOF_SVERTEX_LOG2 + 1 ) ) ); - face[2] = (s4DVertex *) ( (u8*) VertexCache.mem.data + ( 2 << ( SIZEOF_SVERTEX_LOG2 + 1 ) ) ); - -} - -/*! -*/ -void CBurningVideoDriver::VertexCache_reset ( const void* vertices, u32 vertexCount, - const void* indices, u32 primitiveCount, - E_VERTEX_TYPE vType, - scene::E_PRIMITIVE_TYPE pType, - E_INDEX_TYPE iType) -{ - VertexCache.vertices = vertices; - VertexCache.vertexCount = vertexCount; - - VertexCache.indices = indices; - VertexCache.indicesIndex = 0; - VertexCache.indicesRun = 0; - - if ( Material.org.MaterialType == video::EMT_REFLECTION_2_LAYER ) - VertexCache.vType = 3; - else - VertexCache.vType = vType; - VertexCache.pType = pType; - VertexCache.iType = iType == EIT_16BIT ? 1 : 2; - - switch ( VertexCache.pType ) - { - // most types here will not work as expected, only triangles/triangle_fan - // is known to work. - case scene::EPT_POINTS: - VertexCache.indexCount = primitiveCount; - VertexCache.primitivePitch = 1; - break; - case scene::EPT_LINE_STRIP: - VertexCache.indexCount = primitiveCount+1; - VertexCache.primitivePitch = 1; - break; - case scene::EPT_LINE_LOOP: - VertexCache.indexCount = primitiveCount+1; - VertexCache.primitivePitch = 1; - break; - case scene::EPT_LINES: - VertexCache.indexCount = 2*primitiveCount; - VertexCache.primitivePitch = 2; - break; - case scene::EPT_TRIANGLE_STRIP: - VertexCache.indexCount = primitiveCount+2; - VertexCache.primitivePitch = 1; - break; - case scene::EPT_TRIANGLES: - VertexCache.indexCount = primitiveCount + primitiveCount + primitiveCount; - VertexCache.primitivePitch = 3; - break; - case scene::EPT_TRIANGLE_FAN: - VertexCache.indexCount = primitiveCount + 2; - VertexCache.primitivePitch = 1; - break; - case scene::EPT_QUAD_STRIP: - VertexCache.indexCount = 2*primitiveCount + 2; - VertexCache.primitivePitch = 2; - break; - case scene::EPT_QUADS: - VertexCache.indexCount = 4*primitiveCount; - VertexCache.primitivePitch = 4; - break; - case scene::EPT_POLYGON: - VertexCache.indexCount = primitiveCount+1; - VertexCache.primitivePitch = 1; - break; - case scene::EPT_POINT_SPRITES: - VertexCache.indexCount = primitiveCount; - VertexCache.primitivePitch = 1; - break; - } - - irr::memset32 ( VertexCache.info, VERTEXCACHE_MISS, sizeof ( VertexCache.info ) ); -} - - -void CBurningVideoDriver::drawVertexPrimitiveList(const void* vertices, u32 vertexCount, - const void* indexList, u32 primitiveCount, - E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType) - -{ - if (!checkPrimitiveCount(primitiveCount)) - return; - - CNullDriver::drawVertexPrimitiveList(vertices, vertexCount, indexList, primitiveCount, vType, pType, iType); - - if ( 0 == CurrentShader ) - return; - - VertexCache_reset ( vertices, vertexCount, indexList, primitiveCount, vType, pType, iType ); - - const s4DVertex * face[3]; - - f32 dc_area; - s32 lodLevel; - u32 i; - u32 g; - video::CSoftwareTexture2* tex; - - for ( i = 0; i < (u32) primitiveCount; ++i ) - { - VertexCache_get ( (s4DVertex**) face ); - - // if fully outside or outside on same side - if ( ( (face[0]->flag | face[1]->flag | face[2]->flag) & VERTEX4D_CLIPMASK ) - != VERTEX4D_INSIDE - ) - continue; - - // if fully inside - if ( ( face[0]->flag & face[1]->flag & face[2]->flag & VERTEX4D_CLIPMASK ) == VERTEX4D_INSIDE ) - { - dc_area = screenarea2 ( face ); - if ( Material.org.BackfaceCulling && F32_LOWER_EQUAL_0( dc_area ) ) - continue; - if ( Material.org.FrontfaceCulling && F32_GREATER_EQUAL_0( dc_area ) ) - continue; - - dc_area = core::reciprocal ( dc_area ); - - // select mipmap - - for ( g = 0; g != vSize[VertexCache.vType].TexSize; ++g ) - //for ( g = 0; g != BURNING_MATERIAL_MAX_TEXTURES; ++g ) - { - if ( 0 == (tex = MAT_TEXTURE ( g )) ) - { - CurrentShader->setTextureParam(g, 0, 0); - continue; - } - - lodLevel = s32_log2_f32 ( texelarea2 ( face, g ) * dc_area ); - CurrentShader->setTextureParam(g, tex, lodLevel); - select_polygon_mipmap2 ( (s4DVertex**) face, g, tex->getSize() ); - - } - - // rasterize - CurrentShader->drawTriangle ( face[0] + 1, face[1] + 1, face[2] + 1 ); - continue; - } - - // else if not complete inside clipping necessary - irr::memcpy32_small ( ( (u8*) CurrentOut.data + ( 0 << ( SIZEOF_SVERTEX_LOG2 + 1 ) ) ), face[0], SIZEOF_SVERTEX * 2 ); - irr::memcpy32_small ( ( (u8*) CurrentOut.data + ( 1 << ( SIZEOF_SVERTEX_LOG2 + 1 ) ) ), face[1], SIZEOF_SVERTEX * 2 ); - irr::memcpy32_small ( ( (u8*) CurrentOut.data + ( 2 << ( SIZEOF_SVERTEX_LOG2 + 1 ) ) ), face[2], SIZEOF_SVERTEX * 2 ); - - const u32 flag = CurrentOut.data->flag & VERTEX4D_FORMAT_MASK; - - for ( g = 0; g != CurrentOut.ElementSize; ++g ) - { - CurrentOut.data[g].flag = flag; - Temp.data[g].flag = flag; - } - - u32 vOut; - vOut = clipToFrustum ( CurrentOut.data, Temp.data, 3 ); -/* - if ( vOut < 3 ) - { - char buf[256]; - struct SCheck - { - u32 flag; - const char * name; - }; - - SCheck check[5]; - check[0].flag = face[0]->flag; - check[0].name = "face0"; - check[1].flag = face[1]->flag; - check[1].name = "face1"; - check[2].flag = face[2]->flag; - check[2].name = "face2"; - check[3].flag = (face[0]->flag & face[1]->flag & face[2]->flag); - check[3].name = "AND "; - check[4].flag = (face[0]->flag | face[1]->flag | face[2]->flag); - check[4].name = "OR "; - - for ( s32 h = 0; h!= 5; ++h ) - { - sprintf ( buf, "%s: %d %d %d %d %d %d", - check[h].name, - ( check[h].flag & 1 ), - ( check[h].flag & 2 ) >> 1, - ( check[h].flag & 4 ) >> 2, - ( check[h].flag & 8 ) >> 3, - ( check[h].flag & 16 ) >> 4, - ( check[h].flag & 32 ) >> 5 - ); - os::Printer::log( buf ); - } - - sprintf ( buf, "Vout: %d\n", vOut ); - os::Printer::log( buf ); - - int hold = 1; - } -*/ - if ( vOut < 3 ) - continue; - - vOut <<= 1; - - // to DC Space, project homogenous vertex - ndc_2_dc_and_project ( CurrentOut.data + 1, CurrentOut.data, vOut ); - -/* - // TODO: don't stick on 32 Bit Pointer - #define PointerAsValue(x) ( (u32) (u32*) (x) ) - - // if not complete inside clipping necessary - if ( ( test & VERTEX4D_INSIDE ) != VERTEX4D_INSIDE ) - { - u32 v[2] = { PointerAsValue ( Temp ) , PointerAsValue ( CurrentOut ) }; - for ( g = 0; g != 6; ++g ) - { - vOut = clipToHyperPlane ( (s4DVertex*) v[0], (s4DVertex*) v[1], vOut, NDCPlane[g] ); - if ( vOut < 3 ) - break; - - v[0] ^= v[1]; - v[1] ^= v[0]; - v[0] ^= v[1]; - } - - if ( vOut < 3 ) - continue; - - } -*/ - - // check 2d backface culling on first - dc_area = screenarea ( CurrentOut.data ); - if ( Material.org.BackfaceCulling && F32_LOWER_EQUAL_0 ( dc_area ) ) - continue; - if ( Material.org.FrontfaceCulling && F32_GREATER_EQUAL_0( dc_area ) ) - continue; - - // select mipmap - //for ( g = 0; g != BURNING_MATERIAL_MAX_TEXTURES; ++g ) - for ( g = 0; g != vSize[VertexCache.vType].TexSize; ++g ) - { - if ( 0 == (tex = MAT_TEXTURE ( g )) ) - { - CurrentShader->setTextureParam(g, 0, 0); - continue; - } - - lodLevel = s32_log2_f32 ( texelarea ( CurrentOut.data, g ) / dc_area ); - CurrentShader->setTextureParam(g, tex, lodLevel); - select_polygon_mipmap ( CurrentOut.data, vOut, g, tex->getSize() ); - } - - // re-tesselate ( triangle-fan, 0-1-2,0-2-3.. ) - for ( g = 0; g <= vOut - 6; g += 2 ) - { - // rasterize - CurrentShader->drawTriangle ( CurrentOut.data + 0 + 1, - CurrentOut.data + g + 3, - CurrentOut.data + g + 5); - } - - } - - // dump statistics -/* - char buf [64]; - sprintf ( buf,"VCount:%d PCount:%d CacheMiss: %d", - vertexCount, primitiveCount, - VertexCache.CacheMiss - ); - os::Printer::log( buf ); -*/ - -} - - -//! Sets the dynamic ambient light color. The default color is -//! (0,0,0,0) which means it is dark. -//! \param color: New color of the ambient light. -void CBurningVideoDriver::setAmbientLight(const SColorf& color) -{ - LightSpace.Global_AmbientLight.setColorf ( color ); -} - - -//! adds a dynamic light -s32 CBurningVideoDriver::addDynamicLight(const SLight& dl) -{ - (void) CNullDriver::addDynamicLight( dl ); - - SBurningShaderLight l; -// l.org = dl; - l.Type = dl.Type; - l.LightIsOn = true; - - l.AmbientColor.setColorf ( dl.AmbientColor ); - l.DiffuseColor.setColorf ( dl.DiffuseColor ); - l.SpecularColor.setColorf ( dl.SpecularColor ); - - switch ( dl.Type ) - { - case video::ELT_DIRECTIONAL: - l.pos.x = -dl.Direction.X; - l.pos.y = -dl.Direction.Y; - l.pos.z = -dl.Direction.Z; - l.pos.w = 1.f; - break; - case ELT_POINT: - case ELT_SPOT: - LightSpace.Flags |= POINTLIGHT; - l.pos.x = dl.Position.X; - l.pos.y = dl.Position.Y; - l.pos.z = dl.Position.Z; - l.pos.w = 1.f; -/* - l.radius = (1.f / dl.Attenuation.Y) * (1.f / dl.Attenuation.Y); - l.constantAttenuation = dl.Attenuation.X; - l.linearAttenuation = dl.Attenuation.Y; - l.quadraticAttenuation = dl.Attenuation.Z; -*/ - l.radius = dl.Radius * dl.Radius; - l.constantAttenuation = dl.Attenuation.X; - l.linearAttenuation = 1.f / dl.Radius; - l.quadraticAttenuation = dl.Attenuation.Z; - - break; - } - - LightSpace.Light.push_back ( l ); - return LightSpace.Light.size() - 1; -} - -//! Turns a dynamic light on or off -void CBurningVideoDriver::turnLightOn(s32 lightIndex, bool turnOn) -{ - if(lightIndex > -1 && lightIndex < (s32)LightSpace.Light.size()) - LightSpace.Light[lightIndex].LightIsOn = turnOn; -} - -//! deletes all dynamic lights there are -void CBurningVideoDriver::deleteAllDynamicLights() -{ - LightSpace.reset (); - CNullDriver::deleteAllDynamicLights(); - -} - -//! returns the maximal amount of dynamic lights the device can handle -u32 CBurningVideoDriver::getMaximalDynamicLightAmount() const -{ - return 8; -} - - -//! sets a material -void CBurningVideoDriver::setMaterial(const SMaterial& material) -{ - Material.org = material; - -#ifdef SOFTWARE_DRIVER_2_TEXTURE_TRANSFORM - for (u32 i = 0; i < 2; ++i) - { - setTransform((E_TRANSFORMATION_STATE) (ETS_TEXTURE_0 + i), - material.getTextureMatrix(i)); - } -#endif - -#ifdef SOFTWARE_DRIVER_2_LIGHTING - Material.AmbientColor.setR8G8B8 ( Material.org.AmbientColor.color ); - Material.DiffuseColor.setR8G8B8 ( Material.org.DiffuseColor.color ); - Material.EmissiveColor.setR8G8B8 ( Material.org.EmissiveColor.color ); - Material.SpecularColor.setR8G8B8 ( Material.org.SpecularColor.color ); - - core::setbit_cond ( LightSpace.Flags, Material.org.Shininess != 0.f, SPECULAR ); - core::setbit_cond ( LightSpace.Flags, Material.org.FogEnable, FOG ); - core::setbit_cond ( LightSpace.Flags, Material.org.NormalizeNormals, NORMALIZE ); -#endif - - setCurrentShader(); -} - - -/*! - Camera Position in World Space -*/ -void CBurningVideoDriver::getCameraPosWorldSpace () -{ - Transformation[ETS_VIEW_INVERSE] = Transformation[ ETS_VIEW ]; - Transformation[ETS_VIEW_INVERSE].makeInverse (); - TransformationFlag[ETS_VIEW_INVERSE] = 0; - - const f32 *M = Transformation[ETS_VIEW_INVERSE].pointer (); - - /* The viewpoint is at (0., 0., 0.) in eye space. - Turning this into a vector [0 0 0 1] and multiply it by - the inverse of the view matrix, the resulting vector is the - object space location of the camera. - */ - - LightSpace.campos.x = M[12]; - LightSpace.campos.y = M[13]; - LightSpace.campos.z = M[14]; - LightSpace.campos.w = 1.f; -} - -#ifdef SOFTWARE_DRIVER_2_LIGHTING - -//! Sets the fog mode. -void CBurningVideoDriver::setFog(SColor color, E_FOG_TYPE fogType, f32 start, - f32 end, f32 density, bool pixelFog, bool rangeFog) -{ - CNullDriver::setFog(color, fogType, start, end, density, pixelFog, rangeFog); - LightSpace.FogColor.setA8R8G8B8 ( color.color ); -} - -/*! - applies lighting model -*/ -void CBurningVideoDriver::lightVertex ( s4DVertex *dest, u32 vertexargb ) -{ - sVec3 dColor; - - dColor = LightSpace.Global_AmbientLight; - dColor.add ( Material.EmissiveColor ); - - if ( Lights.size () == 0 ) - { - dColor.saturate( dest->Color[0], vertexargb); - return; - } - - sVec3 ambient; - sVec3 diffuse; - sVec3 specular; - - - // the universe started in darkness.. - ambient.set ( 0.f, 0.f, 0.f ); - diffuse.set ( 0.f, 0.f, 0.f ); - specular.set ( 0.f, 0.f, 0.f ); - - - u32 i; - f32 dot; - f32 len; - f32 attenuation; - sVec4 vp; // unit vector vertex to light - sVec4 lightHalf; // blinn-phong reflection - - for ( i = 0; i!= LightSpace.Light.size (); ++i ) - { - const SBurningShaderLight &light = LightSpace.Light[i]; - - // accumulate ambient - ambient.add ( light.AmbientColor ); - - switch ( light.Type ) - { - case video::ELT_SPOT: - case video::ELT_POINT: - // surface to light - vp.x = light.pos.x - LightSpace.vertex.x; - vp.y = light.pos.y - LightSpace.vertex.y; - vp.z = light.pos.z - LightSpace.vertex.z; - - len = vp.get_length_xyz_square(); - if ( light.radius < len ) - continue; - - len = core::squareroot ( len ); - - attenuation = light.constantAttenuation + ( 1.f - ( len * light.linearAttenuation ) ); - - // build diffuse reflection - - //angle between normal and light vector - vp.mulReciprocal ( len ); - dot = LightSpace.normal.dot_xyz ( vp ); - if ( dot < 0.f ) - continue; - - // diffuse component - diffuse.mulAdd ( light.DiffuseColor, dot * attenuation ); - - if ( !(LightSpace.Flags & SPECULAR) ) - continue; - - // build specular - // surface to view - lightHalf.x = LightSpace.campos.x - LightSpace.vertex.x; - lightHalf.y = LightSpace.campos.y - LightSpace.vertex.y; - lightHalf.z = LightSpace.campos.z - LightSpace.vertex.z; - lightHalf.normalize_xyz(); - lightHalf += vp; - lightHalf.normalize_xyz(); - - // specular - dot = LightSpace.normal.dot_xyz ( lightHalf ); - if ( dot < 0.f ) - continue; - - //specular += light.SpecularColor * ( powf ( Material.org.Shininess ,dot ) * attenuation ); - specular.mulAdd ( light.SpecularColor, dot * attenuation ); - break; - - case video::ELT_DIRECTIONAL: - - //angle between normal and light vector - dot = LightSpace.normal.dot_xyz ( light.pos ); - if ( dot < 0.f ) - continue; - - // diffuse component - diffuse.mulAdd ( light.DiffuseColor, dot ); - break; - } - - } - - // sum up lights - dColor.mulAdd (ambient, Material.AmbientColor ); - dColor.mulAdd (diffuse, Material.DiffuseColor); - dColor.mulAdd (specular, Material.SpecularColor); - - dColor.saturate ( dest->Color[0], vertexargb ); -} - -#endif - - -//! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. -void CBurningVideoDriver::draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos, - const core::rect<s32>& sourceRect, - const core::rect<s32>* clipRect, SColor color, - bool useAlphaChannelOfTexture) -{ - if (texture) - { - if (texture->getDriverType() != EDT_BURNINGSVIDEO) - { - os::Printer::log("Fatal Error: Tried to copy from a surface not owned by this driver.", ELL_ERROR); - return; - } - - if (useAlphaChannelOfTexture) - ((CSoftwareTexture2*)texture)->getImage()->copyToWithAlpha( - BackBuffer, destPos, sourceRect, color, clipRect); - else - ((CSoftwareTexture2*)texture)->getImage()->copyTo( - BackBuffer, destPos, sourceRect, clipRect); - } -} - - -//! Draws a 2d line. -void CBurningVideoDriver::draw2DLine(const core::position2d<s32>& start, - const core::position2d<s32>& end, - SColor color) -{ - BackBuffer->drawLine(start, end, color ); -} - - -//! Draws a pixel -void CBurningVideoDriver::drawPixel(u32 x, u32 y, const SColor & color) -{ - BackBuffer->setPixel(x, y, color, true); -} - - -//! draw an 2d rectangle -void CBurningVideoDriver::draw2DRectangle(SColor color, const core::rect<s32>& pos, - const core::rect<s32>* clip) -{ - if (clip) - { - core::rect<s32> p(pos); - - p.clipAgainst(*clip); - - if(!p.isValid()) - return; - - BackBuffer->drawRectangle(p, color); - } - else - { - if(!pos.isValid()) - return; - - BackBuffer->drawRectangle(pos, color); - } -} - - -//! Only used by the internal engine. Used to notify the driver that -//! the window was resized. -void CBurningVideoDriver::OnResize(const core::dimension2d<u32>& size) -{ - // make sure width and height are multiples of 2 - core::dimension2d<u32> realSize(size); - - if (realSize.Width % 2) - realSize.Width += 1; - - if (realSize.Height % 2) - realSize.Height += 1; - - if (ScreenSize != realSize) - { - if (ViewPort.getWidth() == (s32)ScreenSize.Width && - ViewPort.getHeight() == (s32)ScreenSize.Height) - { - ViewPort.UpperLeftCorner.X = 0; - ViewPort.UpperLeftCorner.Y = 0; - ViewPort.LowerRightCorner.X = realSize.Width; - ViewPort.LowerRightCorner.X = realSize.Height; - } - - ScreenSize = realSize; - - bool resetRT = (RenderTargetSurface == BackBuffer); - - if (BackBuffer) - BackBuffer->drop(); - BackBuffer = new CImage(BURNINGSHADER_COLOR_FORMAT, realSize); - - if (resetRT) - setRenderTarget(BackBuffer); - } -} - - -//! returns the current render target size -const core::dimension2d<u32>& CBurningVideoDriver::getCurrentRenderTargetSize() const -{ - return RenderTargetSize; -} - - -//!Draws an 2d rectangle with a gradient. -void CBurningVideoDriver::draw2DRectangle(const core::rect<s32>& position, - SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, - const core::rect<s32>* clip) -{ -#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - - core::rect<s32> pos = position; - - if (clip) - pos.clipAgainst(*clip); - - if (!pos.isValid()) - return; - - const core::dimension2d<s32> renderTargetSize ( ViewPort.getSize() ); - - const s32 xPlus = -(renderTargetSize.Width>>1); - const f32 xFact = 1.0f / (renderTargetSize.Width>>1); - - const s32 yPlus = renderTargetSize.Height-(renderTargetSize.Height>>1); - const f32 yFact = 1.0f / (renderTargetSize.Height>>1); - - // fill VertexCache direct - s4DVertex *v; - - VertexCache.vertexCount = 4; - - VertexCache.info[0].index = 0; - VertexCache.info[1].index = 1; - VertexCache.info[2].index = 2; - VertexCache.info[3].index = 3; - - v = &VertexCache.mem.data [ 0 ]; - - v[0].Pos.set ( (f32)(pos.UpperLeftCorner.X+xPlus) * xFact, (f32)(yPlus-pos.UpperLeftCorner.Y) * yFact, 0.f, 1.f ); - v[0].Color[0].setA8R8G8B8 ( colorLeftUp.color ); - - v[2].Pos.set ( (f32)(pos.LowerRightCorner.X+xPlus) * xFact, (f32)(yPlus- pos.UpperLeftCorner.Y) * yFact, 0.f, 1.f ); - v[2].Color[0].setA8R8G8B8 ( colorRightUp.color ); - - v[4].Pos.set ( (f32)(pos.LowerRightCorner.X+xPlus) * xFact, (f32)(yPlus-pos.LowerRightCorner.Y) * yFact, 0.f ,1.f ); - v[4].Color[0].setA8R8G8B8 ( colorRightDown.color ); - - v[6].Pos.set ( (f32)(pos.UpperLeftCorner.X+xPlus) * xFact, (f32)(yPlus-pos.LowerRightCorner.Y) * yFact, 0.f, 1.f ); - v[6].Color[0].setA8R8G8B8 ( colorLeftDown.color ); - - s32 i; - u32 g; - - for ( i = 0; i!= 8; i += 2 ) - { - v[i + 0].flag = clipToFrustumTest ( v + i ); - v[i + 1].flag = 0; - if ( (v[i].flag & VERTEX4D_INSIDE ) == VERTEX4D_INSIDE ) - { - ndc_2_dc_and_project ( v + i + 1, v + i, 2 ); - } - } - - - IBurningShader * render; - - render = BurningShader [ ETR_GOURAUD_ALPHA_NOZ ]; - render->setRenderTarget(RenderTargetSurface, ViewPort); - - static const s16 indexList[6] = {0,1,2,0,2,3}; - - s4DVertex * face[3]; - - for ( i = 0; i!= 6; i += 3 ) - { - face[0] = VertexCache_getVertex ( indexList [ i + 0 ] ); - face[1] = VertexCache_getVertex ( indexList [ i + 1 ] ); - face[2] = VertexCache_getVertex ( indexList [ i + 2 ] ); - - // test clipping - u32 test = face[0]->flag & face[1]->flag & face[2]->flag & VERTEX4D_INSIDE; - - if ( test == VERTEX4D_INSIDE ) - { - render->drawTriangle ( face[0] + 1, face[1] + 1, face[2] + 1 ); - continue; - } - // Todo: all vertices are clipped in 2d.. - // is this true ? - u32 vOut = 6; - memcpy ( CurrentOut.data + 0, face[0], sizeof ( s4DVertex ) * 2 ); - memcpy ( CurrentOut.data + 2, face[1], sizeof ( s4DVertex ) * 2 ); - memcpy ( CurrentOut.data + 4, face[2], sizeof ( s4DVertex ) * 2 ); - - vOut = clipToFrustum ( CurrentOut.data, Temp.data, 3 ); - if ( vOut < 3 ) - continue; - - vOut <<= 1; - // to DC Space, project homogenous vertex - ndc_2_dc_and_project ( CurrentOut.data + 1, CurrentOut.data, vOut ); - - // re-tesselate ( triangle-fan, 0-1-2,0-2-3.. ) - for ( g = 0; g <= vOut - 6; g += 2 ) - { - // rasterize - render->drawTriangle ( CurrentOut.data + 1, &CurrentOut.data[g + 3], &CurrentOut.data[g + 5] ); - } - - } -#else - draw2DRectangle ( colorLeftUp, position, clip ); -#endif -} - - -//! Draws a 3d line. -void CBurningVideoDriver::draw3DLine(const core::vector3df& start, - const core::vector3df& end, SColor color) -{ - Transformation [ ETS_CURRENT].transformVect ( &CurrentOut.data[0].Pos.x, start ); - Transformation [ ETS_CURRENT].transformVect ( &CurrentOut.data[2].Pos.x, end ); - - u32 g; - u32 vOut; - - // no clipping flags - for ( g = 0; g != CurrentOut.ElementSize; ++g ) - { - CurrentOut.data[g].flag = 0; - Temp.data[g].flag = 0; - } - - // vertices count per line - vOut = clipToFrustum ( CurrentOut.data, Temp.data, 2 ); - if ( vOut < 2 ) - return; - - vOut <<= 1; - - IBurningShader * line; - line = BurningShader [ ETR_TEXTURE_GOURAUD_WIRE ]; - line->setRenderTarget(RenderTargetSurface, ViewPort); - - // to DC Space, project homogenous vertex - ndc_2_dc_and_project ( CurrentOut.data + 1, CurrentOut.data, vOut ); - - // unproject vertex color -#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - for ( g = 0; g != vOut; g+= 2 ) - { - CurrentOut.data[ g + 1].Color[0].setA8R8G8B8 ( color.color ); - } -#endif - - - for ( g = 0; g <= vOut - 4; g += 2 ) - { - // rasterize - line->drawLine ( CurrentOut.data + 1, CurrentOut.data + g + 3 ); - } -} - - -//! \return Returns the name of the video driver. Example: In case of the DirectX8 -//! driver, it would return "Direct3D8.1". -const wchar_t* CBurningVideoDriver::getName() const -{ -#ifdef BURNINGVIDEO_RENDERER_BEAUTIFUL - return L"Burning's Video 0.44 beautiful"; -#elif defined ( BURNINGVIDEO_RENDERER_ULTRA_FAST ) - return L"Burning's Video 0.44 ultra fast"; -#elif defined ( BURNINGVIDEO_RENDERER_FAST ) - return L"Burning's Video 0.44 fast"; -#else - return L"Burning's Video 0.44"; -#endif -} - -//! Returns the graphics card vendor name. -core::stringc CBurningVideoDriver::getVendorInfo() -{ - return "Burning's Video: Ing. Thomas Alten (c) 2006-2009"; -} - - -//! Returns type of video driver -E_DRIVER_TYPE CBurningVideoDriver::getDriverType() const -{ - return EDT_BURNINGSVIDEO; -} - - -//! returns color format -ECOLOR_FORMAT CBurningVideoDriver::getColorFormat() const -{ - return BURNINGSHADER_COLOR_FORMAT; -} - - -//! Returns the transformation set by setTransform -const core::matrix4& CBurningVideoDriver::getTransform(E_TRANSFORMATION_STATE state) const -{ - return Transformation[state]; -} - - -//! Creates a render target texture. -ITexture* CBurningVideoDriver::addRenderTargetTexture(const core::dimension2d<u32>& size, - const io::path& name, const ECOLOR_FORMAT format) -{ - CImage* img = new CImage(BURNINGSHADER_COLOR_FORMAT, size); - ITexture* tex = new CSoftwareTexture2(img, name, CSoftwareTexture2::IS_RENDERTARGET ); - img->drop(); - addTexture(tex); - tex->drop(); - return tex; -} - - -//! Clears the DepthBuffer. -void CBurningVideoDriver::clearZBuffer() -{ - if (DepthBuffer) - DepthBuffer->clear(); -} - - -//! Returns an image created from the last rendered frame. -IImage* CBurningVideoDriver::createScreenShot() -{ - if (BackBuffer) - return new CImage(BackBuffer->getColorFormat(), BackBuffer); - else - return 0; - -} - - -//! returns a device dependent texture from a software surface (IImage) -//! THIS METHOD HAS TO BE OVERRIDDEN BY DERIVED DRIVERS WITH OWN TEXTURES -ITexture* CBurningVideoDriver::createDeviceDependentTexture(IImage* surface, const io::path& name) -{ - return new CSoftwareTexture2( - surface, name, - (getTextureCreationFlag(ETCF_CREATE_MIP_MAPS) ? CSoftwareTexture2::GEN_MIPMAP : 0 ) | - (getTextureCreationFlag(ETCF_ALLOW_NON_POWER_2) ? 0 : CSoftwareTexture2::NP2_SIZE ) - ); - -} - - -//! Returns the maximum amount of primitives (mostly vertices) which -//! the device is able to render with one drawIndexedTriangleList -//! call. -u32 CBurningVideoDriver::getMaximalPrimitiveCount() const -{ - return 0xFFFFFFFF; -} - - -//! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do -//! this: First, draw all geometry. Then use this method, to draw the shadow -//! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow. -void CBurningVideoDriver::drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail) -{ -/* - if (!StencilBuffer || !count) - return; - - setRenderStatesStencilShadowMode(zfail); - - if (!zfail) - { - // ZPASS Method - - // Draw front-side of shadow volume in stencil/z only - pID3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW ); - pID3DDevice->SetRenderState(D3DRS_STENCILPASS, D3DSTENCILOP_INCRSAT); - pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df)); - - // Now reverse cull order so front sides of shadow volume are written. - pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CW ); - pID3DDevice->SetRenderState( D3DRS_STENCILPASS, D3DSTENCILOP_DECRSAT); - pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df)); - } - else - { - // ZFAIL Method - - // Draw front-side of shadow volume in stencil/z only - pID3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW ); - pID3DDevice->SetRenderState(D3DRS_STENCILZFAIL, D3DSTENCILOP_INCRSAT ); - pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df)); - - // Now reverse cull order so front sides of shadow volume are written. - pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW ); - pID3DDevice->SetRenderState( D3DRS_STENCILZFAIL, D3DSTENCILOP_DECRSAT ); - pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df)); - } -*/ -} - - - -//! Fills the stencil shadow with color. After the shadow volume has been drawn -//! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this -//! to draw the color of the shadow. -void CBurningVideoDriver::drawStencilShadow(bool clearStencilBuffer, video::SColor leftUpEdge, - video::SColor rightUpEdge, video::SColor leftDownEdge, video::SColor rightDownEdge) -{ -/* - if (!StencilBuffer) - return; - - S3DVertex vtx[4]; - vtx[0] = S3DVertex(1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, leftUpEdge, 0.0f, 0.0f); - vtx[1] = S3DVertex(1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, rightUpEdge, 0.0f, 1.0f); - vtx[2] = S3DVertex(-1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, leftDownEdge, 1.0f, 0.0f); - vtx[3] = S3DVertex(-1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, rightDownEdge, 1.0f, 1.0f); - - s16 indices[6] = {0,1,2,1,3,2}; - - setRenderStatesStencilFillMode( - leftUpEdge.getAlpha() < 255 || - rightUpEdge.getAlpha() < 255 || - leftDownEdge.getAlpha() < 255 || - rightDownEdge.getAlpha() < 255); - - setTexture(0,0); - - setVertexShader(EVT_STANDARD); - - pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, &indices[0], - D3DFMT_INDEX16, &vtx[0], sizeof(S3DVertex)); - - if (clearStencilBuffer) - pID3DDevice->Clear( 0, NULL, D3DCLEAR_STENCIL,0, 1.0, 0); -*/ -} - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - -//! creates a video driver -IVideoDriver* createSoftwareDriver2(const core::dimension2d<u32>& windowSize, bool fullscreen, io::IFileSystem* io, video::IImagePresenter* presenter) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CBurningVideoDriver(windowSize, fullscreen, io, presenter); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - - -} // end namespace video -} // end namespace irr diff --git a/irrlicht-1.6/source/Irrlicht/CSoftwareDriver2.h b/irrlicht-1.6/source/Irrlicht/CSoftwareDriver2.h deleted file mode 100644 index c5df9b9d2..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSoftwareDriver2.h +++ /dev/null @@ -1,275 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_VIDEO_2_SOFTWARE_H_INCLUDED__ -#define __C_VIDEO_2_SOFTWARE_H_INCLUDED__ - -#include "SoftwareDriver2_compile_config.h" -#include "IBurningShader.h" -#include "CNullDriver.h" -#include "CImage.h" -#include "os.h" -#include "irrString.h" - -namespace irr -{ -namespace video -{ - class CBurningVideoDriver : public CNullDriver - { - public: - - //! constructor - CBurningVideoDriver(const core::dimension2d<u32>& windowSize, bool fullscreen, io::IFileSystem* io, video::IImagePresenter* presenter); - - //! destructor - virtual ~CBurningVideoDriver(); - - //! queries the features of the driver, returns true if feature is available - virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const; - - //! sets transformation - virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat); - - //! sets a material - virtual void setMaterial(const SMaterial& material); - - virtual bool setRenderTarget(video::ITexture* texture, bool clearBackBuffer, - bool clearZBuffer, SColor color); - - //! sets a viewport - virtual void setViewPort(const core::rect<s32>& area); - - //! clears the zbuffer - virtual bool beginScene(bool backBuffer=true, bool zBuffer=true, - SColor color=SColor(255,0,0,0), - void* windowId=0, - core::rect<s32>* sourceRect=0); - - //! presents the rendered scene on the screen, returns false if failed - virtual bool endScene(); - - //! Only used by the internal engine. Used to notify the driver that - //! the window was resized. - virtual void OnResize(const core::dimension2d<u32>& size); - - //! returns size of the current render target - virtual const core::dimension2d<u32>& getCurrentRenderTargetSize() const; - - //! deletes all dynamic lights there are - virtual void deleteAllDynamicLights(); - - //! adds a dynamic light, returning an index to the light - //! \param light: the light data to use to create the light - //! \return An index to the light, or -1 if an error occurs - virtual s32 addDynamicLight(const SLight& light); - - //! Turns a dynamic light on or off - //! \param lightIndex: the index returned by addDynamicLight - //! \param turnOn: true to turn the light on, false to turn it off - virtual void turnLightOn(s32 lightIndex, bool turnOn); - - //! returns the maximal amount of dynamic lights the device can handle - virtual u32 getMaximalDynamicLightAmount() const; - - //! Sets the dynamic ambient light color. The default color is - //! (0,0,0,0) which means it is dark. - //! \param color: New color of the ambient light. - virtual void setAmbientLight(const SColorf& color); - - //! draws a vertex primitive list - void drawVertexPrimitiveList(const void* vertices, u32 vertexCount, - const void* indexList, u32 primitiveCount, - E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType); - - //! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. - virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos, - const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0, - SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false); - - //! Draws a 3d line. - virtual void draw3DLine(const core::vector3df& start, - const core::vector3df& end, SColor color = SColor(255,255,255,255)); - - //! draw an 2d rectangle - virtual void draw2DRectangle(SColor color, const core::rect<s32>& pos, - const core::rect<s32>* clip = 0); - - //!Draws an 2d rectangle with a gradient. - virtual void draw2DRectangle(const core::rect<s32>& pos, - SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, - const core::rect<s32>* clip = 0); - - //! Draws a 2d line. - virtual void draw2DLine(const core::position2d<s32>& start, - const core::position2d<s32>& end, - SColor color=SColor(255,255,255,255)); - - //! Draws a single pixel - virtual void drawPixel(u32 x, u32 y, const SColor & color); - - //! \return Returns the name of the video driver. Example: In case of the DirectX8 - //! driver, it would return "Direct3D8.1". - virtual const wchar_t* getName() const; - - //! Returns type of video driver - virtual E_DRIVER_TYPE getDriverType() const; - - //! get color format of the current color buffer - virtual ECOLOR_FORMAT getColorFormat() const; - - //! Returns the transformation set by setTransform - virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) const; - - //! Creates a render target texture. - virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size, - const io::path& name, const ECOLOR_FORMAT format = ECF_UNKNOWN); - - //! Clears the DepthBuffer. - virtual void clearZBuffer(); - - //! Returns an image created from the last rendered frame. - virtual IImage* createScreenShot(); - - //! Returns the maximum amount of primitives (mostly vertices) which - //! the device is able to render with one drawIndexedTriangleList - //! call. - virtual u32 getMaximalPrimitiveCount() const; - - //! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do - //! this: First, draw all geometry. Then use this method, to draw the shadow - //! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow. - virtual void drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail); - - //! Fills the stencil shadow with color. After the shadow volume has been drawn - //! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this - //! to draw the color of the shadow. - virtual void drawStencilShadow(bool clearStencilBuffer=false, - video::SColor leftUpEdge = video::SColor(0,0,0,0), - video::SColor rightUpEdge = video::SColor(0,0,0,0), - video::SColor leftDownEdge = video::SColor(0,0,0,0), - video::SColor rightDownEdge = video::SColor(0,0,0,0)); - - //! Returns the graphics card vendor name. - virtual core::stringc getVendorInfo(); - - protected: - - - //! sets a render target - void setRenderTarget(video::CImage* image); - - //! sets the current Texture - //bool setTexture(u32 stage, video::ITexture* texture); - - //! returns a device dependent texture from a software surface (IImage) - //! THIS METHOD HAS TO BE OVERRIDDEN BY DERIVED DRIVERS WITH OWN TEXTURES - virtual video::ITexture* createDeviceDependentTexture(IImage* surface, const io::path& name); - - video::CImage* BackBuffer; - video::IImagePresenter* Presenter; - - void* WindowId; - core::rect<s32>* SceneSourceRect; - - video::ITexture* RenderTargetTexture; - video::IImage* RenderTargetSurface; - core::dimension2d<u32> RenderTargetSize; - - //! selects the right triangle renderer based on the render states. - void setCurrentShader(); - - IBurningShader* CurrentShader; - IBurningShader* BurningShader[ETR2_COUNT]; - - IDepthBuffer* DepthBuffer; - - - /* - extend Matrix Stack - -> combined CameraProjection - -> combined CameraProjectionWorld - -> ClipScale from NDC to DC Space - */ - enum E_TRANSFORMATION_STATE_BURNING_VIDEO - { - ETS_VIEW_PROJECTION = ETS_COUNT, - ETS_CURRENT, - ETS_CLIPSCALE, - ETS_VIEW_INVERSE, - - ETS_COUNT_BURNING - }; - - enum E_TRANSFORMATION_FLAG - { - ETF_IDENTITY = 1, - ETF_TEXGEN_CAMERA_NORMAL = 2, - ETF_TEXGEN_CAMERA_REFLECTION = 4, - }; - u32 TransformationFlag[ETS_COUNT_BURNING]; - core::matrix4 Transformation[ETS_COUNT_BURNING]; - - void getCameraPosWorldSpace (); - - - // Vertex Cache - static const SVSize vSize[]; - - SVertexCache VertexCache; - - void VertexCache_reset (const void* vertices, u32 vertexCount, - const void* indices, u32 indexCount, - E_VERTEX_TYPE vType,scene::E_PRIMITIVE_TYPE pType, - E_INDEX_TYPE iType); - void VertexCache_get ( s4DVertex ** face ); - void VertexCache_getbypass ( s4DVertex ** face ); - - void VertexCache_fill ( const u32 sourceIndex,const u32 destIndex ); - s4DVertex * VertexCache_getVertex ( const u32 sourceIndex ); - - - // culling & clipping - u32 clipToHyperPlane ( s4DVertex * dest, const s4DVertex * source, u32 inCount, const sVec4 &plane ); - u32 clipToFrustumTest ( const s4DVertex * v ) const; - u32 clipToFrustum ( s4DVertex *source, s4DVertex * temp, const u32 vIn ); - - -#ifdef SOFTWARE_DRIVER_2_LIGHTING - - void lightVertex ( s4DVertex *dest, u32 vertexargb ); - //! Sets the fog mode. - virtual void setFog(SColor color, E_FOG_TYPE fogType, f32 start, - f32 end, f32 density, bool pixelFog, bool rangeFog); -#endif - - - // holds transformed, clipped vertices - SAlignedVertex CurrentOut; - SAlignedVertex Temp; - - void ndc_2_dc_and_project ( s4DVertex *dest,s4DVertex *source, u32 vIn ) const; - f32 screenarea ( const s4DVertex *v0 ) const; - void select_polygon_mipmap ( s4DVertex *source, u32 vIn, u32 tex, const core::dimension2du& texSize ); - f32 texelarea ( const s4DVertex *v0, int tex ) const; - - - void ndc_2_dc_and_project2 ( const s4DVertex **v, const u32 size ) const; - f32 screenarea2 ( const s4DVertex **v ) const; - f32 texelarea2 ( const s4DVertex **v, int tex ) const; - void select_polygon_mipmap2 ( s4DVertex **source, u32 tex, const core::dimension2du& texSize ) const; - - - SBurningShaderLightSpace LightSpace; - SBurningShaderMaterial Material; - - static const sVec4 NDCPlane[6]; - }; - -} // end namespace video -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CSoftwareTexture.cpp b/irrlicht-1.6/source/Irrlicht/CSoftwareTexture.cpp deleted file mode 100644 index 4f4e56cf8..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSoftwareTexture.cpp +++ /dev/null @@ -1,149 +0,0 @@ -// Copyright (C) 2002-2009 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_SOFTWARE_ - -#include "CSoftwareTexture.h" -#include "os.h" - -namespace irr -{ -namespace video -{ - -//! constructor -CSoftwareTexture::CSoftwareTexture(IImage* image, const io::path& name, bool renderTarget) -: ITexture(name), Texture(0), IsRenderTarget(renderTarget) -{ - #ifdef _DEBUG - setDebugName("CSoftwareTexture"); - #endif - - if (image) - { - OrigSize = image->getDimension(); - core::dimension2d<u32> optSize=OrigSize.getOptimalSize(); - - Image = new CImage(ECF_A1R5G5B5, image); - - if (optSize == OrigSize) - { - Texture = Image; - Texture->grab(); - } - else - { - Texture = new CImage(ECF_A1R5G5B5, optSize); - Image->copyToScaling(Texture); - } - } -} - - - -//! destructor -CSoftwareTexture::~CSoftwareTexture() -{ - if (Image) - Image->drop(); - - if (Texture) - Texture->drop(); -} - - - -//! lock function -void* CSoftwareTexture::lock(bool readOnly) -{ - return Image->lock(); -} - - - -//! unlock function -void CSoftwareTexture::unlock() -{ - if (Image != Texture) - { - os::Printer::log("Performance warning, slow unlock of non power of 2 texture.", ELL_WARNING); - Image->copyToScaling(Texture); - } - - Image->unlock(); -} - - -//! Returns original size of the texture. -const core::dimension2d<u32>& CSoftwareTexture::getOriginalSize() const -{ - return OrigSize; -} - - -//! Returns (=size) of the texture. -const core::dimension2d<u32>& CSoftwareTexture::getSize() const -{ - return Image->getDimension(); -} - - -//! returns unoptimized surface -CImage* CSoftwareTexture::getImage() -{ - return Image; -} - - - -//! returns texture surface -CImage* CSoftwareTexture::getTexture() -{ - return Texture; -} - - - -//! returns driver type of texture (=the driver, who created the texture) -E_DRIVER_TYPE CSoftwareTexture::getDriverType() const -{ - return EDT_SOFTWARE; -} - - - -//! returns color format of texture -ECOLOR_FORMAT CSoftwareTexture::getColorFormat() const -{ - return ECF_A1R5G5B5; -} - - - -//! returns pitch of texture (in bytes) -u32 CSoftwareTexture::getPitch() const -{ - return Image->getDimension().Width * 2; -} - - -//! Regenerates the mip map levels of the texture. Useful after locking and -//! modifying the texture -void CSoftwareTexture::regenerateMipMapLevels() -{ - // our software textures don't have mip maps -} - -bool CSoftwareTexture::isRenderTarget() const -{ - return IsRenderTarget; -} - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_SOFTWARE_ - diff --git a/irrlicht-1.6/source/Irrlicht/CSoftwareTexture.h b/irrlicht-1.6/source/Irrlicht/CSoftwareTexture.h deleted file mode 100644 index d3784068c..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSoftwareTexture.h +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_SOFTWARE_TEXTURE_H_INCLUDED__ -#define __C_SOFTWARE_TEXTURE_H_INCLUDED__ - -#include "ITexture.h" -#include "CImage.h" - -namespace irr -{ -namespace video -{ - -/*! - interface for a Video Driver dependent Texture. -*/ -class CSoftwareTexture : public ITexture -{ -public: - - //! constructor - CSoftwareTexture(IImage* surface, const io::path& name, bool renderTarget=false); - - //! destructor - virtual ~CSoftwareTexture(); - - //! lock function - virtual void* lock(bool readOnly = false); - - //! unlock function - virtual void unlock(); - - //! Returns original size of the texture. - virtual const core::dimension2d<u32>& getOriginalSize() const; - - //! Returns (=size) of the texture. - virtual const core::dimension2d<u32>& getSize() const; - - //! returns unoptimized surface - virtual CImage* getImage(); - - //! returns texture surface - virtual CImage* getTexture(); - - //! returns driver type of texture (=the driver, who created the texture) - virtual E_DRIVER_TYPE getDriverType() const; - - //! returns color format of texture - virtual ECOLOR_FORMAT getColorFormat() const; - - //! returns pitch of texture (in bytes) - virtual u32 getPitch() const; - - //! Regenerates the mip map levels of the texture. Useful after locking and - //! modifying the texture - virtual void regenerateMipMapLevels(); - - //! is it a render target? - virtual bool isRenderTarget() const; - -private: - CImage* Image; - CImage* Texture; - core::dimension2d<u32> OrigSize; - bool IsRenderTarget; -}; - - -} // end namespace video -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CSoftwareTexture2.cpp b/irrlicht-1.6/source/Irrlicht/CSoftwareTexture2.cpp deleted file mode 100644 index fd2db0886..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSoftwareTexture2.cpp +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt / Thomas Alten -// 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_BURNINGSVIDEO_ - -#include "SoftwareDriver2_compile_config.h" -#include "SoftwareDriver2_helper.h" -#include "CSoftwareTexture2.h" -#include "os.h" - -namespace irr -{ -namespace video -{ - -//! constructor -CSoftwareTexture2::CSoftwareTexture2(IImage* image, const io::path& name, u32 flags ) -: ITexture(name), MipMapLOD(0), Flags ( flags ) -{ - #ifdef _DEBUG - setDebugName("CSoftwareTexture2"); - #endif - - #ifndef SOFTWARE_DRIVER_2_MIPMAPPING - Flags &= ~GEN_MIPMAP; - #endif - - memset32 ( MipMap, 0, sizeof ( MipMap ) ); - - if (image) - { - OrigSize = image->getDimension(); - - core::setbit_cond ( Flags, - image->getColorFormat () == video::ECF_A8R8G8B8 || - image->getColorFormat () == video::ECF_A1R5G5B5, - HAS_ALPHA - ); - - core::dimension2d<u32> optSize( - OrigSize.getOptimalSize( 0 != ( Flags & NP2_SIZE ), - false, false, - ( Flags & NP2_SIZE ) ? SOFTWARE_DRIVER_2_TEXTURE_MAXSIZE : 0) - ); - - if ( OrigSize == optSize ) - { - MipMap[0] = new CImage(BURNINGSHADER_COLOR_FORMAT, image); - } - else - { - char buf[256]; - core::stringw showName ( name ); - snprintf ( buf, 256, "Burningvideo: Warning Texture %ls reformat %dx%d -> %dx%d,%d", - showName.c_str(), - OrigSize.Width, OrigSize.Height, optSize.Width, optSize.Height, - BURNINGSHADER_COLOR_FORMAT - ); - - OrigSize = optSize; - os::Printer::log ( buf, ELL_WARNING ); - MipMap[0] = new CImage(BURNINGSHADER_COLOR_FORMAT, optSize); - MipMap[0]->fill ( 0 ); - - - // temporary CImage needed - CImage * temp = new CImage ( BURNINGSHADER_COLOR_FORMAT, image ); - temp->copyToScalingBoxFilter ( MipMap[0],0, false ); - //temp->copyToScaling(MipMap[0]); - temp->drop (); - } - } - - regenerateMipMapLevels(); - setCurrentMipMapLOD(0); -} - - -//! destructor -CSoftwareTexture2::~CSoftwareTexture2() -{ - for ( s32 i = 0; i!= SOFTWARE_DRIVER_2_MIPMAPPING_MAX; ++i ) - { - if ( MipMap[i] ) - MipMap[i]->drop(); - } -} - - -//! Regenerates the mip map levels of the texture. Useful after locking and -//! modifying the texture -void CSoftwareTexture2::regenerateMipMapLevels() -{ - if ( !hasMipMaps () ) - return; - - s32 i; - - // release - for ( i = 1; i < SOFTWARE_DRIVER_2_MIPMAPPING_MAX; ++i ) - { - if ( MipMap[i] ) - MipMap[i]->drop(); - } - - core::dimension2d<u32> newSize; - core::dimension2d<u32> currentSize; - - i = 1; - CImage * c = MipMap[0]; - while ( i < SOFTWARE_DRIVER_2_MIPMAPPING_MAX ) - { - currentSize = c->getDimension(); - newSize.Width = core::s32_max ( 1, currentSize.Width >> SOFTWARE_DRIVER_2_MIPMAPPING_SCALE ); - newSize.Height = core::s32_max ( 1, currentSize.Height >> SOFTWARE_DRIVER_2_MIPMAPPING_SCALE ); - - MipMap[i] = new CImage(BURNINGSHADER_COLOR_FORMAT, newSize); - MipMap[i]->fill ( 0 ); - MipMap[0]->copyToScalingBoxFilter( MipMap[i], 0, false ); - c = MipMap[i]; - ++i; - } -} - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - diff --git a/irrlicht-1.6/source/Irrlicht/CSoftwareTexture2.h b/irrlicht-1.6/source/Irrlicht/CSoftwareTexture2.h deleted file mode 100644 index 36a77ea16..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSoftwareTexture2.h +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_SOFTWARE_2_TEXTURE_H_INCLUDED__ -#define __C_SOFTWARE_2_TEXTURE_H_INCLUDED__ - -#include "SoftwareDriver2_compile_config.h" - -#include "ITexture.h" -#include "CImage.h" - -namespace irr -{ -namespace video -{ - -/*! - interface for a Video Driver dependent Texture. -*/ -class CSoftwareTexture2 : public ITexture -{ -public: - - //! constructor - enum eTex2Flags - { - GEN_MIPMAP = 1, - IS_RENDERTARGET = 2, - NP2_SIZE = 4, - HAS_ALPHA = 8 - }; - CSoftwareTexture2( IImage* surface, const io::path& name, u32 flags ); - - //! destructor - virtual ~CSoftwareTexture2(); - - //! lock function - virtual void* lock(bool readOnly = false) - { - return MipMap[MipMapLOD]->lock(); - } - - //! unlock function - virtual void unlock() - { - MipMap[MipMapLOD]->unlock(); - } - - //! Returns original size of the texture. - virtual const core::dimension2d<u32>& getOriginalSize() const - { - //return MipMap[0]->getDimension(); - return OrigSize; - } - - //! Returns the size of the largest mipmap. - f32 getLODFactor( const f32 texArea ) const - { - return MipMap[0]->getImageDataSizeInPixels () * texArea; - } - - //! Returns (=size) of the texture. - virtual const core::dimension2d<u32>& getSize() const - { - return MipMap[MipMapLOD]->getDimension(); - } - - //! returns unoptimized surface - virtual CImage* getImage() const - { - return MipMap[0]; - } - - //! returns texture surface - virtual CImage* getTexture() const - { - return MipMap[MipMapLOD]; - } - - - //! returns driver type of texture (=the driver, who created the texture) - virtual E_DRIVER_TYPE getDriverType() const - { - return EDT_BURNINGSVIDEO; - } - - //! returns color format of texture - virtual ECOLOR_FORMAT getColorFormat() const - { - return BURNINGSHADER_COLOR_FORMAT; - } - - //! returns pitch of texture (in bytes) - virtual u32 getPitch() const - { - return MipMap[MipMapLOD]->getPitch(); - } - - //! Regenerates the mip map levels of the texture. Useful after locking and - //! modifying the texture - virtual void regenerateMipMapLevels(); - - //! Select a Mipmap Level - virtual void setCurrentMipMapLOD ( s32 lod ) - { - if ( Flags & GEN_MIPMAP ) - MipMapLOD = lod; - } - - //! support mipmaps - virtual bool hasMipMaps() const - { - return (Flags & GEN_MIPMAP ) != 0; - } - - //! Returns if the texture has an alpha channel - virtual bool hasAlpha() const - { - return (Flags & HAS_ALPHA ) != 0; - } - - //! is a render target - virtual bool isRenderTarget() const - { - return (Flags & IS_RENDERTARGET) != 0; - } - -private: - core::dimension2d<u32> OrigSize; - - CImage * MipMap[SOFTWARE_DRIVER_2_MIPMAPPING_MAX]; - - s32 MipMapLOD; - u32 Flags; -}; - - -} // end namespace video -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CSphereSceneNode.cpp b/irrlicht-1.6/source/Irrlicht/CSphereSceneNode.cpp deleted file mode 100644 index c1063685d..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSphereSceneNode.cpp +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CSphereSceneNode.h" -#include "IVideoDriver.h" -#include "ISceneManager.h" -#include "S3DVertex.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CSphereSceneNode::CSphereSceneNode(f32 radius, u32 polyCountX, u32 polyCountY, ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position, const core::vector3df& rotation, const core::vector3df& scale) -: IMeshSceneNode(parent, mgr, id, position, rotation, scale), Mesh(0), - Radius(radius), PolyCountX(polyCountX), PolyCountY(polyCountY) -{ - #ifdef _DEBUG - setDebugName("CSphereSceneNode"); - #endif - - Mesh = SceneManager->getGeometryCreator()->createSphereMesh(radius, polyCountX, polyCountY); -} - - - -//! destructor -CSphereSceneNode::~CSphereSceneNode() -{ - if (Mesh) - Mesh->drop(); -} - - -//! renders the node. -void CSphereSceneNode::render() -{ - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - - if (Mesh && driver) - { - driver->setMaterial(Mesh->getMeshBuffer(0)->getMaterial()); - driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); - driver->drawMeshBuffer(Mesh->getMeshBuffer(0)); - if ( DebugDataVisible & scene::EDS_BBOX ) - { - video::SMaterial m; - m.Lighting = false; - driver->setMaterial(m); - driver->draw3DBox(Mesh->getMeshBuffer(0)->getBoundingBox(), video::SColor(255,255,255,255)); - } - } -} - - - -//! returns the axis aligned bounding box of this node -const core::aabbox3d<f32>& CSphereSceneNode::getBoundingBox() const -{ - return Mesh ? Mesh->getBoundingBox() : Box; -} - - -void CSphereSceneNode::OnRegisterSceneNode() -{ - if (IsVisible) - SceneManager->registerNodeForRendering(this); - - ISceneNode::OnRegisterSceneNode(); -} - - -//! returns the material based on the zero based index i. To get the amount -//! of materials used by this scene node, use getMaterialCount(). -//! This function is needed for inserting the node into the scene hirachy on a -//! optimal position for minimizing renderstate changes, but can also be used -//! to directly modify the material of a scene node. -video::SMaterial& CSphereSceneNode::getMaterial(u32 i) -{ - if (i>0 || !Mesh) - return ISceneNode::getMaterial(i); - else - return Mesh->getMeshBuffer(i)->getMaterial(); -} - - -//! returns amount of materials used by this scene node. -u32 CSphereSceneNode::getMaterialCount() const -{ - return 1; -} - - -//! Writes attributes of the scene node. -void CSphereSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const -{ - ISceneNode::serializeAttributes(out, options); - - out->addFloat("Radius", Radius); - out->addInt("PolyCountX", PolyCountX); - out->addInt("PolyCountY", PolyCountY); -} - - -//! Reads attributes of the scene node. -void CSphereSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - f32 oldRadius = Radius; - u32 oldPolyCountX = PolyCountX; - u32 oldPolyCountY = PolyCountY; - - Radius = in->getAttributeAsFloat("Radius"); - PolyCountX = in->getAttributeAsInt("PolyCountX"); - PolyCountY = in->getAttributeAsInt("PolyCountY"); - // legacy values read for compatibility with older versions - u32 polyCount = in->getAttributeAsInt("PolyCount"); - if (PolyCountX ==0 && PolyCountY == 0) - PolyCountX = PolyCountY = polyCount; - - Radius = core::max_(Radius, 0.0001f); - - if ( !core::equals(Radius, oldRadius) || PolyCountX != oldPolyCountX || PolyCountY != oldPolyCountY) - { - if (Mesh) - Mesh->drop(); - Mesh = SceneManager->getGeometryCreator()->createSphereMesh(Radius, PolyCountX, PolyCountY); - } - - ISceneNode::deserializeAttributes(in, options); -} - -//! Creates a clone of this scene node and its children. -ISceneNode* CSphereSceneNode::clone(ISceneNode* newParent, ISceneManager* newManager) -{ - if (!newParent) - newParent = Parent; - if (!newManager) - newManager = SceneManager; - - CSphereSceneNode* nb = new CSphereSceneNode(Radius, PolyCountX, PolyCountY, newParent, - newManager, ID, RelativeTranslation); - - nb->cloneMembers(this, newManager); - nb->getMaterial(0) = Mesh->getMeshBuffer(0)->getMaterial(); - - nb->drop(); - return nb; -} - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CSphereSceneNode.h b/irrlicht-1.6/source/Irrlicht/CSphereSceneNode.h deleted file mode 100644 index 1583ac31c..000000000 --- a/irrlicht-1.6/source/Irrlicht/CSphereSceneNode.h +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_SHPERE_SCENE_NODE_H_INCLUDED__ -#define __C_SHPERE_SCENE_NODE_H_INCLUDED__ - -#include "IMeshSceneNode.h" -#include "IMesh.h" - -namespace irr -{ -namespace scene -{ - class CSphereSceneNode : public IMeshSceneNode - { - public: - - //! constructor - CSphereSceneNode(f32 size, u32 polyCountX, u32 polyCountY, ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); - - //! destructor - virtual ~CSphereSceneNode(); - - virtual void OnRegisterSceneNode(); - - //! renders the node. - virtual void render(); - - //! returns the axis aligned bounding box of this node - virtual const core::aabbox3d<f32>& getBoundingBox() const; - - //! returns the material based on the zero based index i. To get the amount - //! of materials used by this scene node, use getMaterialCount(). - //! This function is needed for inserting the node into the scene hirachy on a - //! optimal position for minimizing renderstate changes, but can also be used - //! to directly modify the material of a scene node. - virtual video::SMaterial& getMaterial(u32 i); - - //! returns amount of materials used by this scene node. - virtual u32 getMaterialCount() const; - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() const { return ESNT_SPHERE; } - - //! Writes attributes of the scene node. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const; - - //! Reads attributes of the scene node. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - //! Creates a clone of this scene node and its children. - virtual ISceneNode* clone(ISceneNode* newParent=0, ISceneManager* newManager=0); - - //! The mesh cannot be changed - virtual void setMesh(IMesh* mesh) {} - - //! Returns the current mesh - virtual IMesh* getMesh() { return Mesh; } - - //! Sets if the scene node should not copy the materials of the mesh but use them in a read only style. - /* In this way it is possible to change the materials a mesh causing all mesh scene nodes - referencing this mesh to change too. */ - virtual void setReadOnlyMaterials(bool readonly) {} - - //! Returns if the scene node should not copy the materials of the mesh but use them in a read only style - virtual bool isReadOnlyMaterials() const { return false; } - - private: - - IMesh* Mesh; - core::aabbox3d<f32> Box; - f32 Radius; - u32 PolyCountX; - u32 PolyCountY; - }; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CTRFlat.cpp b/irrlicht-1.6/source/Irrlicht/CTRFlat.cpp deleted file mode 100644 index f9ac119de..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTRFlat.cpp +++ /dev/null @@ -1,300 +0,0 @@ -// Copyright (C) 2002-2009 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" -#include "CTRTextureGouraud.h" - -#ifdef _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -class CTRFlat : public CTRTextureGouraud -{ -public: - - CTRFlat(IZBuffer* zbuffer) - : CTRTextureGouraud(zbuffer) - { - #ifdef _DEBUG - setDebugName("CTRFlat"); - #endif - } - - //! draws an indexed triangle list - virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount) - { - const S2DVertex *v1, *v2, *v3; - - u16 color; - f32 tmpDiv; // temporary division factor - f32 longest; // saves the longest span - s32 height; // saves height of triangle - u16* targetSurface; // target pointer where to plot pixels - s32 spanEnd; // saves end of spans - f32 leftdeltaxf; // amount of pixels to increase on left side of triangle - f32 rightdeltaxf; // amount of pixels to increase on right side of triangle - s32 leftx, rightx; // position where we are - f32 leftxf, rightxf; // same as above, but as f32 values - s32 span; // current span - u16 *hSpanBegin, *hSpanEnd; // pointer used when plotting pixels - core::rect<s32> TriangleRect; - - s32 leftZValue, rightZValue; - s32 leftZStep, rightZStep; - s32 spanZValue, spanZStep; // ZValues when drawing a span - TZBufferType* zTarget, *spanZTarget; // target of ZBuffer; - - lockedSurface = (u16*)RenderTarget->lock(); - lockedZBuffer = ZBuffer->lock(); - - for (s32 i=0; i<triangleCount; ++i) - { - v1 = &vertices[*indexList]; - ++indexList; - v2 = &vertices[*indexList]; - ++indexList; - v3 = &vertices[*indexList]; - ++indexList; - - // back face culling - - if (BackFaceCullingEnabled) - { - s32 z = ((v3->Pos.X - v1->Pos.X) * (v3->Pos.Y - v2->Pos.Y)) - - ((v3->Pos.Y - v1->Pos.Y) * (v3->Pos.X - v2->Pos.X)); - - if (z < 0) - continue; - } - - //near plane clipping - - if (v1->ZValue<0 && v2->ZValue<0 && v3->ZValue<0) - continue; - - // sort for width for inscreen clipping - - if (v1->Pos.X > v2->Pos.X) swapVertices(&v1, &v2); - if (v1->Pos.X > v3->Pos.X) swapVertices(&v1, &v3); - if (v2->Pos.X > v3->Pos.X) swapVertices(&v2, &v3); - - if ((v1->Pos.X - v3->Pos.X) == 0) - continue; - - TriangleRect.UpperLeftCorner.X = v1->Pos.X; - TriangleRect.LowerRightCorner.X = v3->Pos.X; - - // sort for height for faster drawing. - - if (v1->Pos.Y > v2->Pos.Y) swapVertices(&v1, &v2); - if (v1->Pos.Y > v3->Pos.Y) swapVertices(&v1, &v3); - if (v2->Pos.Y > v3->Pos.Y) swapVertices(&v2, &v3); - - TriangleRect.UpperLeftCorner.Y = v1->Pos.Y; - TriangleRect.LowerRightCorner.Y = v3->Pos.Y; - - if (!TriangleRect.isRectCollided(ViewPortRect)) - continue; - - // calculate height of triangle - height = v3->Pos.Y - v1->Pos.Y; - if (!height) - continue; - - // calculate longest span - - longest = (v2->Pos.Y - v1->Pos.Y) / (f32)height * (v3->Pos.X - v1->Pos.X) + (v1->Pos.X - v2->Pos.X); - - spanEnd = v2->Pos.Y; - span = v1->Pos.Y; - leftxf = (f32)v1->Pos.X; - rightxf = (f32)v1->Pos.X; - - leftZValue = v1->ZValue; - rightZValue = v1->ZValue; - - color = v1->Color; - - targetSurface = lockedSurface + span * SurfaceWidth; - zTarget = lockedZBuffer + span * SurfaceWidth; - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - rightdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - rightZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); - - tmpDiv = 1.0f / (f32)height; - leftdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - leftZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (f32)height; - rightdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - rightZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); - - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - leftdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - leftZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); - } - - - // do it twice, once for the first half of the triangle, - // end then for the second half. - - for (s32 triangleHalf=0; triangleHalf<2; ++triangleHalf) - { - if (spanEnd > ViewPortRect.LowerRightCorner.Y) - spanEnd = ViewPortRect.LowerRightCorner.Y; - - // if the span <0, than we can skip these spans, - // and proceed to the next spans which are really on the screen. - if (span < ViewPortRect.UpperLeftCorner.Y) - { - // we'll use leftx as temp variable - if (spanEnd < ViewPortRect.UpperLeftCorner.Y) - { - leftx = spanEnd - span; - span = spanEnd; - } - else - { - leftx = ViewPortRect.UpperLeftCorner.Y - span; - span = ViewPortRect.UpperLeftCorner.Y; - } - - leftxf += leftdeltaxf*leftx; - rightxf += rightdeltaxf*leftx; - targetSurface += SurfaceWidth*leftx; - zTarget += SurfaceWidth*leftx; - leftZValue += leftZStep*leftx; - rightZValue += rightZStep*leftx; - } - - - // the main loop. Go through every span and draw it. - - while (span < spanEnd) - { - leftx = (s32)(leftxf); - rightx = (s32)(rightxf + 0.5f); - - // perform some clipping - - // TODO: clipping is not correct when leftx is clipped. - - if (leftx<ViewPortRect.UpperLeftCorner.X) - leftx = ViewPortRect.UpperLeftCorner.X; - else - if (leftx>ViewPortRect.LowerRightCorner.X) - leftx = ViewPortRect.LowerRightCorner.X; - - if (rightx<ViewPortRect.UpperLeftCorner.X) - rightx = ViewPortRect.UpperLeftCorner.X; - else - if (rightx>ViewPortRect.LowerRightCorner.X) - rightx = ViewPortRect.LowerRightCorner.X; - - // draw the span - - if (rightx - leftx != 0) - { - tmpDiv = 1.0f / (rightx - leftx); - spanZValue = leftZValue; - spanZStep = (s32)((rightZValue - leftZValue) * tmpDiv); - - hSpanBegin = targetSurface + leftx; - spanZTarget = zTarget + leftx; - hSpanEnd = targetSurface + rightx; - - while (hSpanBegin < hSpanEnd) - { - if (spanZValue > *spanZTarget) - { - *spanZTarget = spanZValue; - *hSpanBegin = color; - } - - spanZValue += spanZStep; - ++hSpanBegin; - ++spanZTarget; - } - } - - leftxf += leftdeltaxf; - rightxf += rightdeltaxf; - ++span; - targetSurface += SurfaceWidth; - zTarget += SurfaceWidth; - leftZValue += leftZStep; - rightZValue += rightZStep; - } - - if (triangleHalf>0) // break, we've gout only two halves - break; - - - // setup variables for second half of the triangle. - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - rightdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - rightxf = (f32)v2->Pos.X; - - rightZValue = v2->ZValue; - rightZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - leftdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - leftxf = (f32)v2->Pos.X; - - leftZValue = v2->ZValue; - leftZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); - } - - - spanEnd = v3->Pos.Y; - } - - } - - RenderTarget->unlock(); - ZBuffer->unlock(); - } -}; - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -ITriangleRenderer* createTriangleRendererFlat(IZBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_SOFTWARE_ - return new CTRFlat(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_SOFTWARE_ -} - -} // end namespace video -} // end namespace irr - - - diff --git a/irrlicht-1.6/source/Irrlicht/CTRFlatWire.cpp b/irrlicht-1.6/source/Irrlicht/CTRFlatWire.cpp deleted file mode 100644 index 711336010..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTRFlatWire.cpp +++ /dev/null @@ -1,281 +0,0 @@ -// Copyright (C) 2002-2009 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" -#include "CTRTextureGouraud.h" - -#ifdef _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -class CTRFlatWire : public CTRTextureGouraud -{ -public: - - CTRFlatWire(IZBuffer* zbuffer) - : CTRTextureGouraud(zbuffer) - { - #ifdef _DEBUG - setDebugName("CTRWire"); - #endif - } - - //! draws an indexed triangle list - virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount) - { - const S2DVertex *v1, *v2, *v3; - - u16 color; - f32 tmpDiv; // temporary division factor - f32 longest; // saves the longest span - s32 height; // saves height of triangle - u16* targetSurface; // target pointer where to plot pixels - s32 spanEnd; // saves end of spans - f32 leftdeltaxf; // amount of pixels to increase on left side of triangle - f32 rightdeltaxf; // amount of pixels to increase on right side of triangle - s32 leftx, rightx; // position where we are - f32 leftxf, rightxf; // same as above, but as f32 values - s32 span; // current span - core::rect<s32> TriangleRect; - - s32 leftZValue, rightZValue; - s32 leftZStep, rightZStep; - TZBufferType* zTarget; // target of ZBuffer; - - lockedSurface = (u16*)RenderTarget->lock(); - lockedZBuffer = ZBuffer->lock(); - - for (s32 i=0; i<triangleCount; ++i) - { - v1 = &vertices[*indexList]; - ++indexList; - v2 = &vertices[*indexList]; - ++indexList; - v3 = &vertices[*indexList]; - ++indexList; - - // back face culling - - if (BackFaceCullingEnabled) - { - s32 z = ((v3->Pos.X - v1->Pos.X) * (v3->Pos.Y - v2->Pos.Y)) - - ((v3->Pos.Y - v1->Pos.Y) * (v3->Pos.X - v2->Pos.X)); - - if (z < 0) - continue; - } - - //near plane clipping - - if (v1->ZValue<0 && v2->ZValue<0 && v3->ZValue<0) - continue; - - // sort for width for inscreen clipping - - if (v1->Pos.X > v2->Pos.X) swapVertices(&v1, &v2); - if (v1->Pos.X > v3->Pos.X) swapVertices(&v1, &v3); - if (v2->Pos.X > v3->Pos.X) swapVertices(&v2, &v3); - - if ((v1->Pos.X - v3->Pos.X) == 0) - continue; - - TriangleRect.UpperLeftCorner.X = v1->Pos.X; - TriangleRect.LowerRightCorner.X = v3->Pos.X; - - // sort for height for faster drawing. - - if (v1->Pos.Y > v2->Pos.Y) swapVertices(&v1, &v2); - if (v1->Pos.Y > v3->Pos.Y) swapVertices(&v1, &v3); - if (v2->Pos.Y > v3->Pos.Y) swapVertices(&v2, &v3); - - TriangleRect.UpperLeftCorner.Y = v1->Pos.Y; - TriangleRect.LowerRightCorner.Y = v3->Pos.Y; - - if (!TriangleRect.isRectCollided(ViewPortRect)) - continue; - - // calculate height of triangle - height = v3->Pos.Y - v1->Pos.Y; - if (!height) - continue; - - // calculate longest span - - longest = (v2->Pos.Y - v1->Pos.Y) / (f32)height * (v3->Pos.X - v1->Pos.X) + (v1->Pos.X - v2->Pos.X); - - spanEnd = v2->Pos.Y; - span = v1->Pos.Y; - leftxf = (f32)v1->Pos.X; - rightxf = (f32)v1->Pos.X; - - leftZValue = v1->ZValue; - rightZValue = v1->ZValue; - - color = v1->Color; - - targetSurface = lockedSurface + span * SurfaceWidth; - zTarget = lockedZBuffer + span * SurfaceWidth; - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - rightdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - rightZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); - - tmpDiv = 1.0f / (f32)height; - leftdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - leftZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (f32)height; - rightdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - rightZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); - - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - leftdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - leftZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); - } - - - // do it twice, once for the first half of the triangle, - // end then for the second half. - - for (s32 triangleHalf=0; triangleHalf<2; ++triangleHalf) - { - if (spanEnd > ViewPortRect.LowerRightCorner.Y) - spanEnd = ViewPortRect.LowerRightCorner.Y; - - // if the span <0, than we can skip these spans, - // and proceed to the next spans which are really on the screen. - if (span < ViewPortRect.UpperLeftCorner.Y) - { - // we'll use leftx as temp variable - if (spanEnd < ViewPortRect.UpperLeftCorner.Y) - { - leftx = spanEnd - span; - span = spanEnd; - } - else - { - leftx = ViewPortRect.UpperLeftCorner.Y - span; - span = ViewPortRect.UpperLeftCorner.Y; - } - - leftxf += leftdeltaxf*leftx; - rightxf += rightdeltaxf*leftx; - targetSurface += SurfaceWidth*leftx; - zTarget += SurfaceWidth*leftx; - leftZValue += leftZStep*leftx; - rightZValue += rightZStep*leftx; - } - - - // the main loop. Go through every span and draw it. - - while (span < spanEnd) - { - leftx = (s32)(leftxf); - rightx = (s32)(rightxf + 0.5f); - - // perform some clipping - - if (leftx>=ViewPortRect.UpperLeftCorner.X && - leftx<=ViewPortRect.LowerRightCorner.X) - { - if (leftZValue > *(zTarget + leftx)) - { - *(zTarget + leftx) = leftZValue; - *(targetSurface + leftx) = color; - } - } - - - if (rightx>=ViewPortRect.UpperLeftCorner.X && - rightx<=ViewPortRect.LowerRightCorner.X) - { - if (rightZValue > *(zTarget + rightx)) - { - *(zTarget + rightx) = rightZValue; - *(targetSurface + rightx) = color; - } - - } - - // draw the span - - leftxf += leftdeltaxf; - rightxf += rightdeltaxf; - ++span; - targetSurface += SurfaceWidth; - zTarget += SurfaceWidth; - leftZValue += leftZStep; - rightZValue += rightZStep; - } - - if (triangleHalf>0) // break, we've gout only two halves - break; - - - // setup variables for second half of the triangle. - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - rightdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - rightxf = (f32)v2->Pos.X; - - rightZValue = v2->ZValue; - rightZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - leftdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - leftxf = (f32)v2->Pos.X; - - leftZValue = v2->ZValue; - leftZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); - } - - - spanEnd = v3->Pos.Y; - } - - } - - RenderTarget->unlock(); - ZBuffer->unlock(); - } -}; - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -ITriangleRenderer* createTriangleRendererFlatWire(IZBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_SOFTWARE_ - return new CTRFlatWire(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_SOFTWARE_ -} - -} // end namespace video -} // end namespace irr - - diff --git a/irrlicht-1.6/source/Irrlicht/CTRGouraud.cpp b/irrlicht-1.6/source/Irrlicht/CTRGouraud.cpp deleted file mode 100644 index 5ffb7233b..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTRGouraud.cpp +++ /dev/null @@ -1,358 +0,0 @@ -// Copyright (C) 2002-2009 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" -#include "CTRTextureGouraud.h" - -#ifdef _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - - -class CTRGouraud : public CTRTextureGouraud -{ -public: - - CTRGouraud(IZBuffer* zbuffer) - : CTRTextureGouraud(zbuffer) - { - #ifdef _DEBUG - setDebugName("CTRGouraud"); - #endif - } - - //! draws an indexed triangle list - virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount) - { - const S2DVertex *v1, *v2, *v3; - - f32 tmpDiv; // temporary division factor - f32 longest; // saves the longest span - s32 height; // saves height of triangle - u16* targetSurface; // target pointer where to plot pixels - s32 spanEnd; // saves end of spans - f32 leftdeltaxf; // amount of pixels to increase on left side of triangle - f32 rightdeltaxf; // amount of pixels to increase on right side of triangle - s32 leftx, rightx; // position where we are - f32 leftxf, rightxf; // same as above, but as f32 values - s32 span; // current span - u16 *hSpanBegin, *hSpanEnd; // pointer used when plotting pixels - s32 leftR, leftG, leftB, rightR, rightG, rightB; // color values - s32 leftStepR, leftStepG, leftStepB, - rightStepR, rightStepG, rightStepB; // color steps - s32 spanR, spanG, spanB, spanStepR, spanStepG, spanStepB; // color interpolating values while drawing a span. - - core::rect<s32> TriangleRect; - - s32 leftZValue, rightZValue; - s32 leftZStep, rightZStep; - s32 spanZValue, spanZStep; // ZValues when drawing a span - TZBufferType* zTarget, *spanZTarget; // target of ZBuffer; - - lockedSurface = (u16*)RenderTarget->lock(); - lockedZBuffer = ZBuffer->lock(); - - for (s32 i=0; i<triangleCount; ++i) - { - v1 = &vertices[*indexList]; - ++indexList; - v2 = &vertices[*indexList]; - ++indexList; - v3 = &vertices[*indexList]; - ++indexList; - - // back face culling - - if (BackFaceCullingEnabled) - { - s32 z = ((v3->Pos.X - v1->Pos.X) * (v3->Pos.Y - v2->Pos.Y)) - - ((v3->Pos.Y - v1->Pos.Y) * (v3->Pos.X - v2->Pos.X)); - - if (z < 0) - continue; - } - - //near plane clipping - - if (v1->ZValue<0 && v2->ZValue<0 && v3->ZValue<0) - continue; - - // sort for width for inscreen clipping - - if (v1->Pos.X > v2->Pos.X) swapVertices(&v1, &v2); - if (v1->Pos.X > v3->Pos.X) swapVertices(&v1, &v3); - if (v2->Pos.X > v3->Pos.X) swapVertices(&v2, &v3); - - if ((v1->Pos.X - v3->Pos.X) == 0) - continue; - - TriangleRect.UpperLeftCorner.X = v1->Pos.X; - TriangleRect.LowerRightCorner.X = v3->Pos.X; - - // sort for height for faster drawing. - - if (v1->Pos.Y > v2->Pos.Y) swapVertices(&v1, &v2); - if (v1->Pos.Y > v3->Pos.Y) swapVertices(&v1, &v3); - if (v2->Pos.Y > v3->Pos.Y) swapVertices(&v2, &v3); - - TriangleRect.UpperLeftCorner.Y = v1->Pos.Y; - TriangleRect.LowerRightCorner.Y = v3->Pos.Y; - - if (!TriangleRect.isRectCollided(ViewPortRect)) - continue; - - // calculate height of triangle - height = v3->Pos.Y - v1->Pos.Y; - if (!height) - continue; - - // calculate longest span - - longest = (v2->Pos.Y - v1->Pos.Y) / (f32)height * (v3->Pos.X - v1->Pos.X) + (v1->Pos.X - v2->Pos.X); - - spanEnd = v2->Pos.Y; - span = v1->Pos.Y; - leftxf = (f32)v1->Pos.X; - rightxf = (f32)v1->Pos.X; - - leftZValue = v1->ZValue; - rightZValue = v1->ZValue; - - leftR = rightR = video::getRed(v1->Color)<<11; - leftG = rightG = video::getGreen(v1->Color)<<11; - leftB = rightB = video::getBlue(v1->Color)<<11; - - targetSurface = lockedSurface + span * SurfaceWidth; - zTarget = lockedZBuffer + span * SurfaceWidth; - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - rightdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - rightZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); - rightStepR = (s32)(((s32)(video::getRed(v2->Color)<<11) - rightR) * tmpDiv); - rightStepG = (s32)(((s32)(video::getGreen(v2->Color)<<11) - rightG) * tmpDiv); - rightStepB = (s32)(((s32)(video::getBlue(v2->Color)<<11) - rightB) * tmpDiv); - - tmpDiv = 1.0f / (f32)height; - leftdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - leftZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); - leftStepR = (s32)(((s32)(video::getRed(v3->Color)<<11) - leftR) * tmpDiv); - leftStepG = (s32)(((s32)(video::getGreen(v3->Color)<<11) - leftG) * tmpDiv); - leftStepB = (s32)(((s32)(video::getBlue(v3->Color)<<11) - leftB) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (f32)height; - rightdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - rightZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); - rightStepR = (s32)(((s32)(video::getRed(v3->Color)<<11) - rightR) * tmpDiv); - rightStepG = (s32)(((s32)(video::getGreen(v3->Color)<<11) - rightG) * tmpDiv); - rightStepB = (s32)(((s32)(video::getBlue(v3->Color)<<11) - rightB) * tmpDiv); - - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - leftdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - leftZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); - leftStepR = (s32)(((s32)(video::getRed(v2->Color)<<11) - leftR) * tmpDiv); - leftStepG = (s32)(((s32)(video::getGreen(v2->Color)<<11) - leftG) * tmpDiv); - leftStepB = (s32)(((s32)(video::getBlue(v2->Color)<<11) - leftB) * tmpDiv); - } - - - // do it twice, once for the first half of the triangle, - // end then for the second half. - - for (s32 triangleHalf=0; triangleHalf<2; ++triangleHalf) - { - if (spanEnd > ViewPortRect.LowerRightCorner.Y) - spanEnd = ViewPortRect.LowerRightCorner.Y; - - // if the span <0, than we can skip these spans, - // and proceed to the next spans which are really on the screen. - if (span < ViewPortRect.UpperLeftCorner.Y) - { - // we'll use leftx as temp variable - if (spanEnd < ViewPortRect.UpperLeftCorner.Y) - { - leftx = spanEnd - span; - span = spanEnd; - } - else - { - leftx = ViewPortRect.UpperLeftCorner.Y - span; - span = ViewPortRect.UpperLeftCorner.Y; - } - - leftxf += leftdeltaxf*leftx; - rightxf += rightdeltaxf*leftx; - targetSurface += SurfaceWidth*leftx; - zTarget += SurfaceWidth*leftx; - leftZValue += leftZStep*leftx; - rightZValue += rightZStep*leftx; - - leftR += leftStepR*leftx; - leftG += leftStepG*leftx; - leftB += leftStepB*leftx; - rightR += rightStepR*leftx; - rightG += rightStepG*leftx; - rightB += rightStepB*leftx; - } - - - // the main loop. Go through every span and draw it. - - while (span < spanEnd) - { - leftx = (s32)(leftxf); - rightx = (s32)(rightxf + 0.5f); - - // perform some clipping - - // TODO: clipping is not correct when leftx is clipped. - - if (leftx<ViewPortRect.UpperLeftCorner.X) - leftx = ViewPortRect.UpperLeftCorner.X; - else - if (leftx>ViewPortRect.LowerRightCorner.X) - leftx = ViewPortRect.LowerRightCorner.X; - - if (rightx<ViewPortRect.UpperLeftCorner.X) - rightx = ViewPortRect.UpperLeftCorner.X; - else - if (rightx>ViewPortRect.LowerRightCorner.X) - rightx = ViewPortRect.LowerRightCorner.X; - - // draw the span - - if (rightx - leftx != 0) - { - tmpDiv = 1.0f / (rightx - leftx); - spanZValue = leftZValue; - spanZStep = (s32)((rightZValue - leftZValue) * tmpDiv); - - hSpanBegin = targetSurface + leftx; - spanZTarget = zTarget + leftx; - hSpanEnd = targetSurface + rightx; - - spanR = leftR; - spanG = leftG; - spanB = leftB; - spanStepR = (s32)((rightR - leftR) * tmpDiv); - spanStepG = (s32)((rightG - leftG) * tmpDiv); - spanStepB = (s32)((rightB - leftB) * tmpDiv); - - while (hSpanBegin < hSpanEnd) - { - if (spanZValue > *spanZTarget) - { - *spanZTarget = spanZValue; - *hSpanBegin = video::RGB16(spanR>>8, spanG>>8, spanB>>8); - } - - spanR += spanStepR; - spanG += spanStepG; - spanB += spanStepB; - - spanZValue += spanZStep; - ++hSpanBegin; - ++spanZTarget; - } - } - - leftxf += leftdeltaxf; - rightxf += rightdeltaxf; - ++span; - targetSurface += SurfaceWidth; - zTarget += SurfaceWidth; - leftZValue += leftZStep; - rightZValue += rightZStep; - - leftR += leftStepR; - leftG += leftStepG; - leftB += leftStepB; - rightR += rightStepR; - rightG += rightStepG; - rightB += rightStepB; - } - - if (triangleHalf>0) // break, we've gout only two halves - break; - - - // setup variables for second half of the triangle. - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - rightdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - rightxf = (f32)v2->Pos.X; - - rightZValue = v2->ZValue; - rightZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); - - rightR = video::getRed(v2->Color)<<11; - rightG = video::getGreen(v2->Color)<<11; - rightB = video::getBlue(v2->Color)<<11; - rightStepR = (s32)(((s32)(video::getRed(v3->Color)<<11) - rightR) * tmpDiv); - rightStepG = (s32)(((s32)(video::getGreen(v3->Color)<<11) - rightG) * tmpDiv); - rightStepB = (s32)(((s32)(video::getBlue(v3->Color)<<11) - rightB) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - leftdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - leftxf = (f32)v2->Pos.X; - - leftZValue = v2->ZValue; - leftZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); - - leftR = video::getRed(v2->Color)<<11; - leftG = video::getGreen(v2->Color)<<11; - leftB = video::getBlue(v2->Color)<<11; - leftStepR = (s32)(((s32)(video::getRed(v3->Color)<<11) - leftR) * tmpDiv); - leftStepG = (s32)(((s32)(video::getGreen(v3->Color)<<11) - leftG) * tmpDiv); - leftStepB = (s32)(((s32)(video::getBlue(v3->Color)<<11) - leftB) * tmpDiv); - } - - - spanEnd = v3->Pos.Y; - } - - } - - RenderTarget->unlock(); - ZBuffer->unlock(); - } - -}; - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -ITriangleRenderer* createTriangleRendererGouraud(IZBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_SOFTWARE_ - return new CTRGouraud(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_SOFTWARE_ -} - -} // end namespace video -} // end namespace irr - - diff --git a/irrlicht-1.6/source/Irrlicht/CTRGouraud2.cpp b/irrlicht-1.6/source/Irrlicht/CTRGouraud2.cpp deleted file mode 100644 index 617025851..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTRGouraud2.cpp +++ /dev/null @@ -1,648 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "IBurningShader.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -// compile flag for this file -#undef USE_ZBUFFER -#undef IPOL_Z -#undef CMP_Z -#undef WRITE_Z - -#undef IPOL_W -#undef CMP_W -#undef WRITE_W - -#undef SUBTEXEL -#undef INVERSE_W - -#undef IPOL_C0 -#undef IPOL_T0 -#undef IPOL_T1 - -// define render case -#define SUBTEXEL -#define INVERSE_W - -#define USE_ZBUFFER -#define IPOL_W -#define CMP_W -#define WRITE_W - -#define IPOL_C0 -//#define IPOL_T0 -//#define IPOL_T1 - -// apply global override -#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef INVERSE_W -#endif - -#ifndef SOFTWARE_DRIVER_2_SUBTEXEL - #undef SUBTEXEL -#endif - -#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #undef IPOL_C0 -#endif - -#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) - #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef IPOL_W - #endif - #define IPOL_Z - - #ifdef CMP_W - #undef CMP_W - #define CMP_Z - #endif - - #ifdef WRITE_W - #undef WRITE_W - #define WRITE_Z - #endif - -#endif - - -namespace irr -{ - -namespace video -{ - -class CTRGouraud2 : public IBurningShader -{ -public: - - //! constructor - CTRGouraud2(IDepthBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - - -private: - void scanline_bilinear (); - sScanConvertData scan; - sScanLineData line; - -}; - -//! constructor -CTRGouraud2::CTRGouraud2(IDepthBuffer* zbuffer) -: IBurningShader(zbuffer) -{ - #ifdef _DEBUG - setDebugName("CTRGouraud2"); - #endif -} - - - -/*! -*/ -void CTRGouraud2::scanline_bilinear () -{ - tVideoSample *dst; - -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC; -#endif -#ifdef IPOL_T0 - sVec2 slopeT[0]; -#endif -#ifdef IPOL_T1 - sVec2 slopeT[1]; -#endif - - // apply top-left fill-convention, left - xStart = core::ceil32( line.x[0] ); - xEnd = core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC = (line.c[0][1] - line.c[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC * subPixel; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0] * subPixel; -#endif -#ifdef IPOL_T1 - line.t[1][0] += slopeT[1] * subPixel; -#endif -#endif - - dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; - -#ifdef USE_ZBUFFER - z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; -#endif - - - -#ifdef IPOL_C0 - tFixPoint r0, g0, b0; - -#ifdef INVERSE_W - f32 inversew; -#endif - -#endif - - for ( s32 i = 0; i <= dx; ++i ) - { -#ifdef CMP_Z - if ( line.z[0] < z[i] ) -#endif -#ifdef CMP_W - if ( line.w[0] >= z[i] ) -#endif - - { -#ifdef IPOL_C0 -#ifdef INVERSE_W - inversew = core::reciprocal ( line.w[0] ); - - getSample_color ( r0, g0, b0, line.c[0][0] * inversew ); -#else - getSample_color ( r0, g0, b0, line.c[0][0] ); -#endif - - dst[i] = fix_to_color ( r0, g0, b0 ); -#else - dst[i] = COLOR_BRIGHT_WHITE; -#endif - -#ifdef WRITE_Z - z[i] = line.z[0]; -#endif -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - - } - -#ifdef IPOL_Z - line.z[0] += slopeZ; -#endif -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0]; -#endif -#ifdef IPOL_T1 - line.t[1][0] += slopeT[1]; -#endif - } - -} - -void CTRGouraud2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - // sort on height, y - if ( a->Pos.y > b->Pos.y ) swapVertexPointer(&a, &b); - if ( a->Pos.y > c->Pos.y ) swapVertexPointer(&a, &c); - if ( b->Pos.y > c->Pos.y ) swapVertexPointer(&b, &c); - - const f32 ca = c->Pos.y - a->Pos.y; - const f32 ba = b->Pos.y - a->Pos.y; - const f32 cb = c->Pos.y - b->Pos.y; - // calculate delta y of the edges - scan.invDeltaY[0] = core::reciprocal( ca ); - scan.invDeltaY[1] = core::reciprocal( ba ); - scan.invDeltaY[2] = core::reciprocal( cb ); - - if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) - return; - - // find if the major edge is left or right aligned - f32 temp[4]; - - temp[0] = a->Pos.x - c->Pos.x; - temp[1] = -ca; - temp[2] = b->Pos.x - a->Pos.x; - temp[3] = ba; - - scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1; - scan.right = 1 - scan.left; - - // calculate slopes for the major edge - scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; - scan.x[0] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; - scan.z[0] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; - scan.w[0] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0][0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; - scan.c[0][0] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; - scan.t[0][0] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; - scan.t[1][0] = a->Tex[1]; -#endif - - // top left fill convention y run - s32 yStart; - s32 yEnd; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - - - // rasterize upper sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[1] ) - { - // calculate slopes for top edge - scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; - scan.x[1] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; - scan.z[1] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; - scan.w[1] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0][1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; - scan.c[0][1] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; - scan.t[0][1] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; - scan.t[1][1] = a->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = core::ceil32( a->Pos.y ); - yEnd = core::ceil32( b->Pos.y ) - 1; - -#ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - a->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0] * subPixel; - scan.c[0][1] += scan.slopeC[0][1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0] * subPixel; - scan.t[0][1] += scan.slopeT[0][1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0] * subPixel; - scan.t[1][1] += scan.slopeT[1][1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[0][scan.left] = scan.c[0][0]; - line.c[0][scan.right] = scan.c[0][1]; -#endif - -#ifdef IPOL_T0 - line.t[0][scan.left] = scan.t[0][0]; - line.t[0][scan.right] = scan.t[0][1]; -#endif - -#ifdef IPOL_T1 - line.t[1][scan.left] = scan.t[1][0]; - line.t[1][scan.right] = scan.t[1][1]; -#endif - - // render a scanline - scanline_bilinear (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0]; - scan.c[0][1] += scan.slopeC[0][1]; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0]; - scan.t[0][1] += scan.slopeT[0][1]; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0]; - scan.t[1][1] += scan.slopeT[1][1]; -#endif - - } - } - - // rasterize lower sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[2] ) - { - // advance to middle point - if( (f32) 0.0 != scan.invDeltaY[1] ) - { - temp[0] = b->Pos.y - a->Pos.y; // dy - - scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; -#ifdef IPOL_Z - scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; -#endif -#ifdef IPOL_W - scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; -#endif -#ifdef IPOL_C0 - scan.c[0][0] = a->Color[0] + scan.slopeC[0][0] * temp[0]; -#endif -#ifdef IPOL_T0 - scan.t[0][0] = a->Tex[0] + scan.slopeT[0][0] * temp[0]; -#endif -#ifdef IPOL_T1 - scan.t[1][0] = a->Tex[1] + scan.slopeT[1][0] * temp[0]; -#endif - - } - - // calculate slopes for bottom edge - scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; - scan.x[1] = b->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; - scan.z[1] = b->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; - scan.w[1] = b->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0][1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; - scan.c[0][1] = b->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; - scan.t[0][1] = b->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; - scan.t[1][1] = b->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = core::ceil32( b->Pos.y ); - yEnd = core::ceil32( c->Pos.y ) - 1; - -#ifdef SUBTEXEL - - subPixel = ( (f32) yStart ) - b->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0] * subPixel; - scan.c[0][1] += scan.slopeC[0][1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0] * subPixel; - scan.t[0][1] += scan.slopeT[0][1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0] * subPixel; - scan.t[1][1] += scan.slopeT[1][1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[0][scan.left] = scan.c[0][0]; - line.c[0][scan.right] = scan.c[0][1]; -#endif - -#ifdef IPOL_T0 - line.t[0][scan.left] = scan.t[0][0]; - line.t[0][scan.right] = scan.t[0][1]; -#endif - -#ifdef IPOL_T1 - line.t[1][scan.left] = scan.t[1][0]; - line.t[1][scan.right] = scan.t[1][1]; -#endif - - // render a scanline - scanline_bilinear (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0]; - scan.c[0][1] += scan.slopeC[0][1]; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0]; - scan.t[0][1] += scan.slopeT[0][1]; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0]; - scan.t[1][1] += scan.slopeT[1][1]; -#endif - - } - } - - -} - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -IBurningShader* createTriangleRendererGouraud2(IDepthBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CTRGouraud2(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - -} // end namespace video -} // end namespace irr - - - diff --git a/irrlicht-1.6/source/Irrlicht/CTRGouraudAlpha2.cpp b/irrlicht-1.6/source/Irrlicht/CTRGouraudAlpha2.cpp deleted file mode 100644 index dab272b4b..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTRGouraudAlpha2.cpp +++ /dev/null @@ -1,657 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "IBurningShader.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -// compile flag for this file -#undef USE_ZBUFFER -#undef IPOL_Z -#undef CMP_Z -#undef WRITE_Z - -#undef IPOL_W -#undef CMP_W -#undef WRITE_W - -#undef SUBTEXEL -#undef INVERSE_W - -#undef IPOL_C0 -#undef IPOL_T0 -#undef IPOL_T1 - -// define render case -#define SUBTEXEL -#define INVERSE_W - -#define USE_ZBUFFER -#define IPOL_W -#define CMP_W -#define WRITE_W - -#define IPOL_C0 -//#define IPOL_T0 -//#define IPOL_T1 - -// apply global override -#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef INVERSE_W -#endif - -#ifndef SOFTWARE_DRIVER_2_SUBTEXEL - #undef SUBTEXEL -#endif - -#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #undef IPOL_C0 -#endif - -#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) - #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef IPOL_W - #endif - #define IPOL_Z - - #ifdef CMP_W - #undef CMP_W - #define CMP_Z - #endif - - #ifdef WRITE_W - #undef WRITE_W - #define WRITE_Z - #endif - -#endif - - - -namespace irr -{ - -namespace video -{ - -class CTRGouraudAlpha2 : public IBurningShader -{ -public: - - //! constructor - CTRGouraudAlpha2(IDepthBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - - -private: - void scanline_bilinear (); - - sScanConvertData scan; - sScanLineData line; - -}; - -//! constructor -CTRGouraudAlpha2::CTRGouraudAlpha2(IDepthBuffer* zbuffer) -: IBurningShader(zbuffer) -{ - #ifdef _DEBUG - setDebugName("CTRGouraudAlpha2"); - #endif -} - - - -/*! -*/ -void CTRGouraudAlpha2::scanline_bilinear () -{ - tVideoSample *dst; - -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC; -#endif -#ifdef IPOL_T0 - sVec2 slopeT[0]; -#endif -#ifdef IPOL_T1 - sVec2 slopeT[1]; -#endif - - // apply top-left fill-convention, left - xStart = core::ceil32( line.x[0] ); - xEnd = core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC = (line.c[0][1] - line.c[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC * subPixel; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0] * subPixel; -#endif -#ifdef IPOL_T1 - line.t[1][0] += slopeT[1] * subPixel; -#endif -#endif - - dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; - -#ifdef USE_ZBUFFER - z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; -#endif - - - -#ifdef IPOL_C0 - -#ifdef INVERSE_W - f32 inversew; -#endif - - tFixPoint a0; - tFixPoint r0, g0, b0; - tFixPoint r1, g1, b1; - tFixPoint r2, g2, b2; -#endif - - for ( s32 i = 0; i <= dx; ++i ) - { -#ifdef CMP_Z - if ( line.z[0] < z[i] ) -#endif -#ifdef CMP_W - if ( line.w[0] >= z[i] ) -#endif - - { -#ifdef IPOL_C0 -#ifdef INVERSE_W - inversew = core::reciprocal ( line.w[0] ); - - getSample_color ( a0, r0, g0, b0, line.c[0][0] * inversew ); -#else - getSample_color ( a0, r0, g0, b0, line.c[0][0] ); -#endif - - color_to_fix ( r1, g1, b1, dst[i] ); - - r2 = r1 + imulFix ( a0, r0 - r1 ); - g2 = g1 + imulFix ( a0, g0 - g1 ); - b2 = b1 + imulFix ( a0, b0 - b1 ); - - dst[i] = fix_to_color ( r2, g2, b2 ); -#else - dst[i] = COLOR_BRIGHT_WHITE; -#endif -#ifdef WRITE_Z - z[i] = line.z[0]; -#endif -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - - } - -#ifdef IPOL_Z - line.z[0] += slopeZ; -#endif -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0]; -#endif -#ifdef IPOL_T1 - line.t[1][0] += slopeT[1]; -#endif - } - -} - -void CTRGouraudAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - // sort on height, y - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - - const f32 ca = c->Pos.y - a->Pos.y; - const f32 ba = b->Pos.y - a->Pos.y; - const f32 cb = c->Pos.y - b->Pos.y; - // calculate delta y of the edges - scan.invDeltaY[0] = core::reciprocal( ca ); - scan.invDeltaY[1] = core::reciprocal( ba ); - scan.invDeltaY[2] = core::reciprocal( cb ); - - if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) - return; - - // find if the major edge is left or right aligned - f32 temp[4]; - - temp[0] = a->Pos.x - c->Pos.x; - temp[1] = -ca; - temp[2] = b->Pos.x - a->Pos.x; - temp[3] = ba; - - scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1; - scan.right = 1 - scan.left; - - // calculate slopes for the major edge - scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; - scan.x[0] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; - scan.z[0] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; - scan.w[0] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0][0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; - scan.c[0][0] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; - scan.t[0][0] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; - scan.t[1][0] = a->Tex[1]; -#endif - - // top left fill convention y run - s32 yStart; - s32 yEnd; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - - - // rasterize upper sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[1] ) - { - // calculate slopes for top edge - scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; - scan.x[1] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; - scan.z[1] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; - scan.w[1] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0][1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; - scan.c[0][1] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; - scan.t[0][1] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; - scan.t[1][1] = a->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = core::ceil32( a->Pos.y ); - yEnd = core::ceil32( b->Pos.y ) - 1; - -#ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - a->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0] * subPixel; - scan.c[0][1] += scan.slopeC[0][1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0] * subPixel; - scan.t[0][1] += scan.slopeT[0][1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0] * subPixel; - scan.t[1][1] += scan.slopeT[1][1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[0][scan.left] = scan.c[0][0]; - line.c[0][scan.right] = scan.c[0][1]; -#endif - -#ifdef IPOL_T0 - line.t[0][scan.left] = scan.t[0][0]; - line.t[0][scan.right] = scan.t[0][1]; -#endif - -#ifdef IPOL_T1 - line.t[1][scan.left] = scan.t[1][0]; - line.t[1][scan.right] = scan.t[1][1]; -#endif - - // render a scanline - scanline_bilinear ( ); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0]; - scan.c[0][1] += scan.slopeC[0][1]; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0]; - scan.t[0][1] += scan.slopeT[0][1]; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0]; - scan.t[1][1] += scan.slopeT[1][1]; -#endif - - } - } - - // rasterize lower sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[2] ) - { - // advance to middle point - if( (f32) 0.0 != scan.invDeltaY[1] ) - { - temp[0] = b->Pos.y - a->Pos.y; // dy - - scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; -#ifdef IPOL_Z - scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; -#endif -#ifdef IPOL_W - scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; -#endif -#ifdef IPOL_C0 - scan.c[0][0] = a->Color[0] + scan.slopeC[0][0] * temp[0]; -#endif -#ifdef IPOL_T0 - scan.t[0][0] = a->Tex[0] + scan.slopeT[0][0] * temp[0]; -#endif -#ifdef IPOL_T1 - scan.t[1][0] = a->Tex[1] + scan.slopeT[1][0] * temp[0]; -#endif - - } - - // calculate slopes for bottom edge - scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; - scan.x[1] = b->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; - scan.z[1] = b->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; - scan.w[1] = b->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0][1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; - scan.c[0][1] = b->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; - scan.t[0][1] = b->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; - scan.t[1][1] = b->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = core::ceil32( b->Pos.y ); - yEnd = core::ceil32( c->Pos.y ) - 1; - -#ifdef SUBTEXEL - - subPixel = ( (f32) yStart ) - b->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0] * subPixel; - scan.c[0][1] += scan.slopeC[0][1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0] * subPixel; - scan.t[0][1] += scan.slopeT[0][1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0] * subPixel; - scan.t[1][1] += scan.slopeT[1][1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[0][scan.left] = scan.c[0][0]; - line.c[0][scan.right] = scan.c[0][1]; -#endif - -#ifdef IPOL_T0 - line.t[0][scan.left] = scan.t[0][0]; - line.t[0][scan.right] = scan.t[0][1]; -#endif - -#ifdef IPOL_T1 - line.t[1][scan.left] = scan.t[1][0]; - line.t[1][scan.right] = scan.t[1][1]; -#endif - - // render a scanline - scanline_bilinear ( ); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0]; - scan.c[0][1] += scan.slopeC[0][1]; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0]; - scan.t[0][1] += scan.slopeT[0][1]; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0]; - scan.t[1][1] += scan.slopeT[1][1]; -#endif - - } - } - -} - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -IBurningShader* createTriangleRendererGouraudAlpha2(IDepthBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CTRGouraudAlpha2(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - -} // end namespace video -} // end namespace irr - - - diff --git a/irrlicht-1.6/source/Irrlicht/CTRGouraudAlphaNoZ2.cpp b/irrlicht-1.6/source/Irrlicht/CTRGouraudAlphaNoZ2.cpp deleted file mode 100644 index 50c52ef19..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTRGouraudAlphaNoZ2.cpp +++ /dev/null @@ -1,657 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "IBurningShader.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -// compile flag for this file -#undef USE_ZBUFFER -#undef IPOL_Z -#undef CMP_Z -#undef WRITE_Z - -#undef IPOL_W -#undef CMP_W -#undef WRITE_W - -#undef SUBTEXEL -#undef INVERSE_W - -#undef IPOL_C0 -#undef IPOL_T0 -#undef IPOL_T1 - -// define render case -#define SUBTEXEL -//#define INVERSE_W - -//#define USE_ZBUFFER -//#define IPOL_W -//#define CMP_W -//#define WRITE_W - -#define IPOL_C0 -//#define IPOL_T0 -//#define IPOL_T1 - -// apply global override -#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef INVERSE_W -#endif - -#ifndef SOFTWARE_DRIVER_2_SUBTEXEL - #undef SUBTEXEL -#endif - -#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #undef IPOL_C0 -#endif - -#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) - #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef IPOL_W - #endif - //#define IPOL_Z - - #ifdef CMP_W - #undef CMP_W - #define CMP_Z - #endif - - #ifdef WRITE_W - #undef WRITE_W - #define WRITE_Z - #endif - -#endif - - - -namespace irr -{ - -namespace video -{ - -class CTRGouraudAlphaNoZ2 : public IBurningShader -{ -public: - - //! constructor - CTRGouraudAlphaNoZ2(IDepthBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - - -private: - void scanline_bilinear (); - sScanConvertData scan; - sScanLineData line; - -}; - -//! constructor -CTRGouraudAlphaNoZ2::CTRGouraudAlphaNoZ2(IDepthBuffer* zbuffer) -: IBurningShader(zbuffer) -{ - #ifdef _DEBUG - setDebugName("CTRGouraudAlphaNoZ2"); - #endif -} - - - -/*! -*/ -void CTRGouraudAlphaNoZ2::scanline_bilinear () -{ - tVideoSample *dst; - -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC; -#endif -#ifdef IPOL_T0 - sVec2 slopeT[0]; -#endif -#ifdef IPOL_T1 - sVec2 slopeT[1]; -#endif - - // apply top-left fill-convention, left - xStart = core::ceil32( line.x[0] ); - xEnd = core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC = (line.c[0][1] - line.c[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC * subPixel; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0] * subPixel; -#endif -#ifdef IPOL_T1 - line.t[1][0] += slopeT[1] * subPixel; -#endif -#endif - - dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; - -#ifdef USE_ZBUFFER - z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; -#endif - - - -#ifdef IPOL_C0 - -#ifdef INVERSE_W - f32 inversew; -#endif - - tFixPoint a0; - tFixPoint r0, g0, b0; - tFixPoint r1, g1, b1; - tFixPoint r2, g2, b2; -#endif - - for ( s32 i = 0; i <= dx; ++i ) - { -#ifdef CMP_Z - if ( line.z[0] < z[i] ) -#endif -#ifdef CMP_W - if ( line.w[0] >= z[i] ) -#endif - { - -#ifdef WRITE_Z - z[i] = line.z[0]; -#endif - -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - -#ifdef IPOL_C0 -#ifdef IPOL_W - inversew = core::reciprocal ( line.w[0] ); - - getSample_color ( a0, r0, g0, b0, line.c[0][0] * inversew ); -#else - getSample_color ( a0, r0, g0, b0, line.c[0][0] ); -#endif - - color_to_fix ( r1, g1, b1, dst[i] ); - - r2 = r1 + imulFix ( a0, r0 - r1 ); - g2 = g1 + imulFix ( a0, g0 - g1 ); - b2 = b1 + imulFix ( a0, b0 - b1 ); - - dst[i] = fix_to_color ( r2, g2, b2 ); -#else - dst[i] = COLOR_BRIGHT_WHITE; -#endif - - - } - -#ifdef IPOL_Z - line.z[0] += slopeZ; -#endif -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0]; -#endif -#ifdef IPOL_T1 - line.t[1][0] += slopeT[1]; -#endif - } - -} - -void CTRGouraudAlphaNoZ2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - // sort on height, y - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - - const f32 ca = c->Pos.y - a->Pos.y; - const f32 ba = b->Pos.y - a->Pos.y; - const f32 cb = c->Pos.y - b->Pos.y; - // calculate delta y of the edges - scan.invDeltaY[0] = core::reciprocal( ca ); - scan.invDeltaY[1] = core::reciprocal( ba ); - scan.invDeltaY[2] = core::reciprocal( cb ); - - if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) - return; - - // find if the major edge is left or right aligned - f32 temp[4]; - - temp[0] = a->Pos.x - c->Pos.x; - temp[1] = -ca; - temp[2] = b->Pos.x - a->Pos.x; - temp[3] = ba; - - scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1; - scan.right = 1 - scan.left; - - // calculate slopes for the major edge - scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; - scan.x[0] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; - scan.z[0] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; - scan.w[0] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0][0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; - scan.c[0][0] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; - scan.t[0][0] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; - scan.t[1][0] = a->Tex[1]; -#endif - - // top left fill convention y run - s32 yStart; - s32 yEnd; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - - // rasterize upper sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[1] ) - { - // calculate slopes for top edge - scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; - scan.x[1] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; - scan.z[1] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; - scan.w[1] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0][1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; - scan.c[0][1] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; - scan.t[0][1] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; - scan.t[1][1] = a->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = core::ceil32( a->Pos.y ); - yEnd = core::ceil32( b->Pos.y ) - 1; - -#ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - a->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0] * subPixel; - scan.c[0][1] += scan.slopeC[0][1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0] * subPixel; - scan.t[0][1] += scan.slopeT[0][1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0] * subPixel; - scan.t[1][1] += scan.slopeT[1][1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[0][scan.left] = scan.c[0][0]; - line.c[0][scan.right] = scan.c[0][1]; -#endif - -#ifdef IPOL_T0 - line.t[0][scan.left] = scan.t[0][0]; - line.t[0][scan.right] = scan.t[0][1]; -#endif - -#ifdef IPOL_T1 - line.t[1][scan.left] = scan.t[1][0]; - line.t[1][scan.right] = scan.t[1][1]; -#endif - - // render a scanline - scanline_bilinear (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0]; - scan.c[0][1] += scan.slopeC[0][1]; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0]; - scan.t[0][1] += scan.slopeT[0][1]; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0]; - scan.t[1][1] += scan.slopeT[1][1]; -#endif - - } - } - - // rasterize lower sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[2] ) - { - // advance to middle point - if( (f32) 0.0 != scan.invDeltaY[1] ) - { - temp[0] = b->Pos.y - a->Pos.y; // dy - - scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; -#ifdef IPOL_Z - scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; -#endif -#ifdef IPOL_W - scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; -#endif -#ifdef IPOL_C0 - scan.c[0][0] = a->Color[0] + scan.slopeC[0][0] * temp[0]; -#endif -#ifdef IPOL_T0 - scan.t[0][0] = a->Tex[0] + scan.slopeT[0][0] * temp[0]; -#endif -#ifdef IPOL_T1 - scan.t[1][0] = a->Tex[1] + scan.slopeT[1][0] * temp[0]; -#endif - - } - - // calculate slopes for bottom edge - scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; - scan.x[1] = b->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; - scan.z[1] = b->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; - scan.w[1] = b->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0][1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; - scan.c[0][1] = b->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; - scan.t[0][1] = b->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; - scan.t[1][1] = b->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = core::ceil32( b->Pos.y ); - yEnd = core::ceil32( c->Pos.y ) - 1; - -#ifdef SUBTEXEL - - subPixel = ( (f32) yStart ) - b->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0] * subPixel; - scan.c[0][1] += scan.slopeC[0][1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0] * subPixel; - scan.t[0][1] += scan.slopeT[0][1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0] * subPixel; - scan.t[1][1] += scan.slopeT[1][1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[0][scan.left] = scan.c[0][0]; - line.c[0][scan.right] = scan.c[0][1]; -#endif - -#ifdef IPOL_T0 - line.t[0][scan.left] = scan.t[0][0]; - line.t[0][scan.right] = scan.t[0][1]; -#endif - -#ifdef IPOL_T1 - line.t[1][scan.left] = scan.t[1][0]; - line.t[1][scan.right] = scan.t[1][1]; -#endif - - // render a scanline - scanline_bilinear (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0]; - scan.c[0][1] += scan.slopeC[0][1]; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0]; - scan.t[0][1] += scan.slopeT[0][1]; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0]; - scan.t[1][1] += scan.slopeT[1][1]; -#endif - - } - } - -} - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -IBurningShader* createTRGouraudAlphaNoZ2(IDepthBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CTRGouraudAlphaNoZ2(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - -} // end namespace video -} // end namespace irr - - diff --git a/irrlicht-1.6/source/Irrlicht/CTRGouraudWire.cpp b/irrlicht-1.6/source/Irrlicht/CTRGouraudWire.cpp deleted file mode 100644 index c301a4cb0..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTRGouraudWire.cpp +++ /dev/null @@ -1,326 +0,0 @@ -// Copyright (C) 2002-2009 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" -#include "CTRTextureGouraud.h" - -#ifdef _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -class CTRGouraudWire : public CTRTextureGouraud -{ -public: - - CTRGouraudWire(IZBuffer* zbuffer) - : CTRTextureGouraud(zbuffer) - { - #ifdef _DEBUG - setDebugName("CTRGouraudWire"); - #endif - } - - //! draws an indexed triangle list - virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount) - { - const S2DVertex *v1, *v2, *v3; - - f32 tmpDiv; // temporary division factor - f32 longest; // saves the longest span - s32 height; // saves height of triangle - u16* targetSurface; // target pointer where to plot pixels - s32 spanEnd; // saves end of spans - f32 leftdeltaxf; // amount of pixels to increase on left side of triangle - f32 rightdeltaxf; // amount of pixels to increase on right side of triangle - s32 leftx, rightx; // position where we are - f32 leftxf, rightxf; // same as above, but as f32 values - s32 span; // current span - s32 leftR, leftG, leftB, rightR, rightG, rightB; // color values - s32 leftStepR, leftStepG, leftStepB, - rightStepR, rightStepG, rightStepB; // color steps - - core::rect<s32> TriangleRect; - - s32 leftZValue, rightZValue; - s32 leftZStep, rightZStep; - TZBufferType* zTarget; // target of ZBuffer; - - lockedSurface = (u16*)RenderTarget->lock(); - lockedZBuffer = ZBuffer->lock(); - - for (s32 i=0; i<triangleCount; ++i) - { - v1 = &vertices[*indexList]; - ++indexList; - v2 = &vertices[*indexList]; - ++indexList; - v3 = &vertices[*indexList]; - ++indexList; - - // back face culling - - if (BackFaceCullingEnabled) - { - s32 z = ((v3->Pos.X - v1->Pos.X) * (v3->Pos.Y - v2->Pos.Y)) - - ((v3->Pos.Y - v1->Pos.Y) * (v3->Pos.X - v2->Pos.X)); - - if (z < 0) - continue; - } - - //near plane clipping - - if (v1->ZValue<0 && v2->ZValue<0 && v3->ZValue<0) - continue; - - // sort for width for inscreen clipping - - if (v1->Pos.X > v2->Pos.X) swapVertices(&v1, &v2); - if (v1->Pos.X > v3->Pos.X) swapVertices(&v1, &v3); - if (v2->Pos.X > v3->Pos.X) swapVertices(&v2, &v3); - - if ((v1->Pos.X - v3->Pos.X) == 0) - continue; - - TriangleRect.UpperLeftCorner.X = v1->Pos.X; - TriangleRect.LowerRightCorner.X = v3->Pos.X; - - // sort for height for faster drawing. - - if (v1->Pos.Y > v2->Pos.Y) swapVertices(&v1, &v2); - if (v1->Pos.Y > v3->Pos.Y) swapVertices(&v1, &v3); - if (v2->Pos.Y > v3->Pos.Y) swapVertices(&v2, &v3); - - TriangleRect.UpperLeftCorner.Y = v1->Pos.Y; - TriangleRect.LowerRightCorner.Y = v3->Pos.Y; - - if (!TriangleRect.isRectCollided(ViewPortRect)) - continue; - - // calculate height of triangle - height = v3->Pos.Y - v1->Pos.Y; - if (!height) - continue; - - // calculate longest span - - longest = (v2->Pos.Y - v1->Pos.Y) / (f32)height * (v3->Pos.X - v1->Pos.X) + (v1->Pos.X - v2->Pos.X); - - spanEnd = v2->Pos.Y; - span = v1->Pos.Y; - leftxf = (f32)v1->Pos.X; - rightxf = (f32)v1->Pos.X; - - leftZValue = v1->ZValue; - rightZValue = v1->ZValue; - - leftR = rightR = video::getRed(v1->Color)<<11; - leftG = rightG = video::getGreen(v1->Color)<<11; - leftB = rightB = video::getBlue(v1->Color)<<11; - - targetSurface = lockedSurface + span * SurfaceWidth; - zTarget = lockedZBuffer + span * SurfaceWidth; - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - rightdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - rightZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); - rightStepR = (s32)(((s32)(video::getRed(v2->Color)<<11) - rightR) * tmpDiv); - rightStepG = (s32)(((s32)(video::getGreen(v2->Color)<<11) - rightG) * tmpDiv); - rightStepB = (s32)(((s32)(video::getBlue(v2->Color)<<11) - rightB) * tmpDiv); - - tmpDiv = 1.0f / (f32)height; - leftdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - leftZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); - leftStepR = (s32)(((s32)(video::getRed(v3->Color)<<11) - leftR) * tmpDiv); - leftStepG = (s32)(((s32)(video::getGreen(v3->Color)<<11) - leftG) * tmpDiv); - leftStepB = (s32)(((s32)(video::getBlue(v3->Color)<<11) - leftB) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (f32)height; - rightdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - rightZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); - rightStepR = (s32)(((s32)(video::getRed(v3->Color)<<11) - rightR) * tmpDiv); - rightStepG = (s32)(((s32)(video::getGreen(v3->Color)<<11) - rightG) * tmpDiv); - rightStepB = (s32)(((s32)(video::getBlue(v3->Color)<<11) - rightB) * tmpDiv); - - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - leftdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - leftZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); - leftStepR = (s32)(((s32)(video::getRed(v2->Color)<<11) - leftR) * tmpDiv); - leftStepG = (s32)(((s32)(video::getGreen(v2->Color)<<11) - leftG) * tmpDiv); - leftStepB = (s32)(((s32)(video::getBlue(v2->Color)<<11) - leftB) * tmpDiv); - } - - - // do it twice, once for the first half of the triangle, - // end then for the second half. - - for (s32 triangleHalf=0; triangleHalf<2; ++triangleHalf) - { - if (spanEnd > ViewPortRect.LowerRightCorner.Y) - spanEnd = ViewPortRect.LowerRightCorner.Y; - - // if the span <0, than we can skip these spans, - // and proceed to the next spans which are really on the screen. - if (span < ViewPortRect.UpperLeftCorner.Y) - { - // we'll use leftx as temp variable - if (spanEnd < ViewPortRect.UpperLeftCorner.Y) - { - leftx = spanEnd - span; - span = spanEnd; - } - else - { - leftx = ViewPortRect.UpperLeftCorner.Y - span; - span = ViewPortRect.UpperLeftCorner.Y; - } - - leftxf += leftdeltaxf*leftx; - rightxf += rightdeltaxf*leftx; - targetSurface += SurfaceWidth*leftx; - zTarget += SurfaceWidth*leftx; - leftZValue += leftZStep*leftx; - rightZValue += rightZStep*leftx; - - leftR += leftStepR*leftx; - leftG += leftStepG*leftx; - leftB += leftStepB*leftx; - rightR += rightStepR*leftx; - rightG += rightStepG*leftx; - rightB += rightStepB*leftx; - } - - - // the main loop. Go through every span and draw it. - - while (span < spanEnd) - { - leftx = (s32)(leftxf); - rightx = (s32)(rightxf + 0.5f); - - // perform some clipping - - if (leftx>=ViewPortRect.UpperLeftCorner.X && - leftx<=ViewPortRect.LowerRightCorner.X) - { - if (leftZValue > *(zTarget + leftx)) - { - *(zTarget + leftx) = leftZValue; - *(targetSurface + leftx) = video::RGB16(leftR>>8, leftG>>8, leftB>>8); - } - } - - - if (rightx>=ViewPortRect.UpperLeftCorner.X && - rightx<=ViewPortRect.LowerRightCorner.X) - { - if (rightZValue > *(zTarget + rightx)) - { - *(zTarget + rightx) = rightZValue; - *(targetSurface + rightx) = video::RGB16(rightR, rightG, rightB); - } - - } - - leftxf += leftdeltaxf; - rightxf += rightdeltaxf; - ++span; - targetSurface += SurfaceWidth; - zTarget += SurfaceWidth; - leftZValue += leftZStep; - rightZValue += rightZStep; - - leftR += leftStepR; - leftG += leftStepG; - leftB += leftStepB; - rightR += rightStepR; - rightG += rightStepG; - rightB += rightStepB; - } - - if (triangleHalf>0) // break, we've gout only two halves - break; - - - // setup variables for second half of the triangle. - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - rightdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - rightxf = (f32)v2->Pos.X; - - rightZValue = v2->ZValue; - rightZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); - - rightR = video::getRed(v2->Color)<<11; - rightG = video::getGreen(v2->Color)<<11; - rightB = video::getBlue(v2->Color)<<11; - rightStepR = (s32)(((s32)(video::getRed(v3->Color)<<11) - rightR) * tmpDiv); - rightStepG = (s32)(((s32)(video::getGreen(v3->Color)<<11) - rightG) * tmpDiv); - rightStepB = (s32)(((s32)(video::getBlue(v3->Color)<<11) - rightB) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - leftdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - leftxf = (f32)v2->Pos.X; - - leftZValue = v2->ZValue; - leftZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); - - leftR = video::getRed(v2->Color)<<11; - leftG = video::getGreen(v2->Color)<<11; - leftB = video::getBlue(v2->Color)<<11; - leftStepR = (s32)(((s32)(video::getRed(v3->Color)<<11) - leftR) * tmpDiv); - leftStepG = (s32)(((s32)(video::getGreen(v3->Color)<<11) - leftG) * tmpDiv); - leftStepB = (s32)(((s32)(video::getBlue(v3->Color)<<11) - leftB) * tmpDiv); - } - - - spanEnd = v3->Pos.Y; - } - - } - - RenderTarget->unlock(); - ZBuffer->unlock(); - } - -}; - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - - -//! creates a flat triangle renderer -ITriangleRenderer* createTriangleRendererGouraudWire(IZBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_SOFTWARE_ - return new CTRGouraudWire(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_SOFTWARE_ -} - -} // end namespace video -} // end namespace irr - - diff --git a/irrlicht-1.6/source/Irrlicht/CTRTextureBlend.cpp b/irrlicht-1.6/source/Irrlicht/CTRTextureBlend.cpp deleted file mode 100644 index 736796e66..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTRTextureBlend.cpp +++ /dev/null @@ -1,2385 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "IBurningShader.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -// compile flag for this file -#undef USE_ZBUFFER -#undef IPOL_Z -#undef CMP_Z -#undef WRITE_Z - -#undef IPOL_W -#undef CMP_W -#undef WRITE_W - -#undef SUBTEXEL -#undef INVERSE_W - -#undef IPOL_C0 -#undef IPOL_T0 -#undef IPOL_T1 - -// define render case -#define SUBTEXEL -#define INVERSE_W - -#define USE_ZBUFFER -#define IPOL_W -#define CMP_W -#define WRITE_W - -#define IPOL_C0 -#define IPOL_T0 -//#define IPOL_T1 - -// apply global override -#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef INVERSE_W -#endif - -#ifndef SOFTWARE_DRIVER_2_SUBTEXEL - #undef SUBTEXEL -#endif - -#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #undef IPOL_C0 -#endif - -#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) - #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef IPOL_W - #endif - #define IPOL_Z - - #ifdef CMP_W - #undef CMP_W - #define CMP_Z - #endif - - #ifdef WRITE_W - #undef WRITE_W - #define WRITE_Z - #endif - -#endif - - - -namespace irr -{ - -namespace video -{ - -class CTRTextureBlend : public IBurningShader -{ -public: - - //! constructor - CTRTextureBlend(IDepthBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - - virtual void setZCompareFunc ( u32 func); - virtual void setParam ( u32 index, f32 value); - - -private: - // fragment shader - typedef void (CTRTextureBlend::*tFragmentShader) (); - void fragment_dst_color_zero (); - void fragment_dst_color_one (); - void fragment_dst_color_src_alpha (); - void fragment_dst_color_one_minus_dst_alpha (); - void fragment_zero_one_minus_scr_color (); - void fragment_src_color_src_alpha (); - void fragment_one_one_minus_src_alpha (); - void fragment_one_minus_dst_alpha_one(); - void fragment_src_alpha_one(); - - tFragmentShader fragmentShader; - sScanConvertData scan; - sScanLineData line; - - u32 ZCompare; -}; - -//! constructor -CTRTextureBlend::CTRTextureBlend(IDepthBuffer* zbuffer) -: IBurningShader(zbuffer) -{ - #ifdef _DEBUG - setDebugName("CTRTextureBlend"); - #endif - - ZCompare = 1; -} - -/*! -*/ -void CTRTextureBlend::setZCompareFunc ( u32 func) -{ - ZCompare = func; -} - -/*! -*/ -void CTRTextureBlend::setParam ( u32 index, f32 value) -{ - u8 showname = 0; - - E_BLEND_FACTOR srcFact,dstFact; - E_MODULATE_FUNC modulate; - u32 alphaSrc; - unpack_texureBlendFunc ( srcFact, dstFact, modulate, alphaSrc, value ); - - fragmentShader = 0; - - if ( srcFact == EBF_DST_COLOR && dstFact == EBF_ZERO ) - { - fragmentShader = &CTRTextureBlend::fragment_dst_color_zero; - } - else - if ( srcFact == EBF_DST_COLOR && dstFact == EBF_ONE ) - { - fragmentShader = &CTRTextureBlend::fragment_dst_color_one; - } - else - if ( srcFact == EBF_DST_COLOR && dstFact == EBF_SRC_ALPHA) - { - fragmentShader = &CTRTextureBlend::fragment_dst_color_src_alpha; - } - else - if ( srcFact == EBF_DST_COLOR && dstFact == EBF_ONE_MINUS_DST_ALPHA) - { - fragmentShader = &CTRTextureBlend::fragment_dst_color_one_minus_dst_alpha; - } - else - if ( srcFact == EBF_ZERO && dstFact == EBF_ONE_MINUS_SRC_COLOR ) - { - fragmentShader = &CTRTextureBlend::fragment_zero_one_minus_scr_color; - } - else - if ( srcFact == EBF_ONE && dstFact == EBF_ONE_MINUS_SRC_ALPHA) - { - fragmentShader = &CTRTextureBlend::fragment_one_one_minus_src_alpha; - } - else - if ( srcFact == EBF_ONE_MINUS_DST_ALPHA && dstFact == EBF_ONE ) - { - fragmentShader = &CTRTextureBlend::fragment_one_minus_dst_alpha_one; - } - else - if ( srcFact == EBF_SRC_ALPHA && dstFact == EBF_ONE ) - { - fragmentShader = &CTRTextureBlend::fragment_src_alpha_one; - } - else - if ( srcFact == EBF_SRC_COLOR && dstFact == EBF_SRC_ALPHA ) - { - fragmentShader = &CTRTextureBlend::fragment_src_color_src_alpha; - } - else - { - showname = 1; - fragmentShader = &CTRTextureBlend::fragment_dst_color_zero; - } - - static const c8 *n[] = - { - "gl_zero", - "gl_one", - "gl_dst_color", - "gl_one_minus_dst_color", - "gl_src_color", - "gl_one_minus_src_color", - "gl_src_alpha", - "gl_one_minus_src_alpha", - "gl_dst_alpha", - "gl_one_minus_dst_alpha", - "gl_src_alpha_saturate" - }; - - static E_BLEND_FACTOR lsrcFact = EBF_ZERO; - static E_BLEND_FACTOR ldstFact = EBF_ZERO; - - if ( showname && ( lsrcFact != srcFact || ldstFact != dstFact ) ) - { - char buf[128]; - snprintf ( buf, 128, "missing shader: %s %s",n[srcFact], n[dstFact] ); - os::Printer::log( buf, ELL_INFORMATION ); - - lsrcFact = srcFact; - ldstFact = dstFact; - } - -} - - -/*! -*/ -void CTRTextureBlend::fragment_dst_color_src_alpha () -{ - tVideoSample *dst; - -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC[MATERIAL_MAX_COLORS]; -#endif -#ifdef IPOL_T0 - sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES]; -#endif - - // apply top-left fill-convention, left - xStart = core::ceil32( line.x[0] ); - xEnd = core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC[0] = (line.c[0][1] - line.c[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC[0] * subPixel; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0] * subPixel; -#endif -#ifdef IPOL_T1 - line.t[1][0] += slopeT[1] * subPixel; -#endif -#endif - - dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; - -#ifdef USE_ZBUFFER - z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; -#endif - - - f32 iw = FIX_POINT_F32_MUL; - - tFixPoint a0, r0, g0, b0; - tFixPoint r1, g1, b1; - - s32 i; - - switch ( ZCompare ) - { - case 1: - for ( i = 0; i <= dx; ++i ) - { -#ifdef CMP_W - if ( line.w[0] >= z[i] ) -#endif - - { - -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - -#ifdef INVERSE_W - iw = fix_inverse32 ( line.w[0] ); -#endif - - getSample_texture ( (tFixPointu&) a0, (tFixPointu&)r0, (tFixPointu&)g0, (tFixPointu&)b0, - &IT[0], - tofix ( line.t[0][0].x,iw), - tofix ( line.t[0][0].y,iw) - ); - - color_to_fix ( r1, g1, b1, dst[i] ); - - dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex2 ( r0, r1 ) ), - clampfix_maxcolor ( imulFix_tex2 ( g0, g1 ) ), - clampfix_maxcolor ( imulFix_tex2 ( b0, b1 ) ) - ); - } - -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0]; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC[0]; -#endif - } - break; - - case 2: - for ( i = 0; i <= dx; ++i ) - { -#ifdef CMP_W - if ( line.w[0] == z[i] ) -#endif - - { - -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - -#ifdef INVERSE_W - iw = fix_inverse32 ( line.w[0] ); -#endif - - getSample_texture ( (tFixPointu&) a0, (tFixPointu&)r0, (tFixPointu&)g0, (tFixPointu&)b0, - &IT[0], - tofix ( line.t[0][0].x,iw), - tofix ( line.t[0][0].y,iw) - ); - - color_to_fix ( r1, g1, b1, dst[i] ); - - dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex2 ( r0, r1 ) ), - clampfix_maxcolor ( imulFix_tex2 ( g0, g1 ) ), - clampfix_maxcolor ( imulFix_tex2 ( b0, b1 ) ) - ); - - } - -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0]; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC[0]; -#endif - }break; - } // zcompare - -} - -/*! -*/ -void CTRTextureBlend::fragment_src_color_src_alpha () -{ - tVideoSample *dst; - -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC[MATERIAL_MAX_COLORS]; -#endif -#ifdef IPOL_T0 - sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES]; -#endif - - // apply top-left fill-convention, left - xStart = core::ceil32( line.x[0] ); - xEnd = core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC[0] = (line.c[0][1] - line.c[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC[0] * subPixel; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0] * subPixel; -#endif -#ifdef IPOL_T1 - line.t[1][0] += slopeT[1] * subPixel; -#endif -#endif - - dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; - -#ifdef USE_ZBUFFER - z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; -#endif - - - f32 iw = FIX_POINT_F32_MUL; - - tFixPointu a0, r0, g0, b0; - tFixPoint r1, g1, b1; - - s32 i; - - switch ( ZCompare ) - { - case 1: - for ( i = 0; i <= dx; ++i ) - { -#ifdef CMP_W - if ( line.w[0] >= z[i] ) -#endif - - { - -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - -#ifdef INVERSE_W - iw = fix_inverse32 ( line.w[0] ); -#endif - - getSample_texture ( a0, r0, g0, b0, &IT[0], tofix ( line.t[0][0].x,iw), tofix ( line.t[0][0].y,iw) ); - color_to_fix ( r1, g1, b1, dst[i] ); - -// u32 check = imulFix_tex1( r0, r1 ); - dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex1( r0, r1 ) + imulFix_tex1( r1, a0 ) ), - clampfix_maxcolor ( imulFix_tex1( g0, g1 ) + imulFix_tex1( g1, a0 ) ), - clampfix_maxcolor ( imulFix_tex1( b0, b1 ) + imulFix_tex1( b1, a0 ) ) - ); - } - -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0]; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC[0]; -#endif - } - break; - - case 2: - for ( i = 0; i <= dx; ++i ) - { -#ifdef CMP_W - if ( line.w[0] == z[i] ) -#endif - - { - -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - -#ifdef INVERSE_W - iw = fix_inverse32 ( line.w[0] ); -#endif - - getSample_texture ( (tFixPointu&) a0, (tFixPointu&)r0, (tFixPointu&)g0, (tFixPointu&)b0, - &IT[0], - tofix ( line.t[0][0].x,iw), - tofix ( line.t[0][0].y,iw) - ); - - color_to_fix ( r1, g1, b1, dst[i] ); - - dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex2 ( r0, r1 ) ), - clampfix_maxcolor ( imulFix_tex2 ( g0, g1 ) ), - clampfix_maxcolor ( imulFix_tex2 ( b0, b1 ) ) - ); - - } - -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0]; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC[0]; -#endif - }break; - } // zcompare - -} - -/*! -*/ -void CTRTextureBlend::fragment_one_one_minus_src_alpha() -{ - tVideoSample *dst; - -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC[MATERIAL_MAX_COLORS]; -#endif -#ifdef IPOL_T0 - sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES]; -#endif - - // apply top-left fill-convention, left - xStart = core::ceil32( line.x[0] ); - xEnd = core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC[0] = (line.c[0][1] - line.c[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC[0] * subPixel; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0] * subPixel; -#endif -#ifdef IPOL_T1 - line.t[1][0] += slopeT[1] * subPixel; -#endif -#endif - - dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; - -#ifdef USE_ZBUFFER - z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; -#endif - - - f32 iw = FIX_POINT_F32_MUL; - - tFixPointu a0,r0, g0, b0; - tFixPoint r1, g1, b1; - tFixPoint r2, g2, b2; - - s32 i; - - switch ( ZCompare ) - { - case 1: - for ( i = 0; i <= dx; ++i ) - { -#ifdef CMP_W - if ( line.w[0] >= z[i] ) -#endif - - { - -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - -#ifdef INVERSE_W - iw = fix_inverse32 ( line.w[0] ); -#endif - - getSample_texture ( a0, r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) ); - a0 = FIX_POINT_ONE - a0; - - color_to_fix1 ( r1, g1, b1, dst[i] ); -#ifdef IPOL_C0 - getSample_color ( r2, g2, b2, line.c[0][0],iw ); - - dst[i] = fix_to_color ( imulFix ( r0 + imulFix ( r1, a0 ), r2 ), - imulFix ( g0 + imulFix ( g1, a0 ), g2 ), - imulFix ( b0 + imulFix ( b1, a0 ), b2 ) - ); -#else - dst[i] = fix_to_color ( r0 + imulFix ( r1, a0 ), - g0 + imulFix ( g1, a0 ), - b0 + imulFix ( b1, a0 ) - ); - -#endif - - } - -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0]; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC[0]; -#endif - } - break; - - case 2: - for ( i = 0; i <= dx; ++i ) - { -#ifdef CMP_W - if ( line.w[0] == z[i] ) -#endif - - { - -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - -#ifdef INVERSE_W - iw = fix_inverse32 ( line.w[0] ); -#endif - getSample_texture ( a0, r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) ); - a0 = FIX_POINT_ONE - a0; - - color_to_fix1 ( r1, g1, b1, dst[i] ); -#ifdef IPOL_C0 - getSample_color ( r2, g2, b2, line.c[0][0],iw ); - - dst[i] = fix_to_color ( imulFix ( r0 + imulFix ( r1, a0 ), r2 ), - imulFix ( g0 + imulFix ( g1, a0 ), g2 ), - imulFix ( b0 + imulFix ( b1, a0 ), b2 ) - ); -#else - dst[i] = fix_to_color ( r0 + imulFix ( r1, a0 ), - g0 + imulFix ( g1, a0 ), - b0 + imulFix ( b1, a0 ) - ); - -#endif - - } - -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0]; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC[0]; -#endif - }break; - } // zcompare - -} - -/*! -*/ -void CTRTextureBlend::fragment_one_minus_dst_alpha_one () -{ - tVideoSample *dst; - -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC[MATERIAL_MAX_COLORS]; -#endif -#ifdef IPOL_T0 - sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES]; -#endif - - // apply top-left fill-convention, left - xStart = core::ceil32( line.x[0] ); - xEnd = core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC[0] = (line.c[0][1] - line.c[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC[0] * subPixel; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0] * subPixel; -#endif -#ifdef IPOL_T1 - line.t[1][0] += slopeT[1] * subPixel; -#endif -#endif - - dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; - -#ifdef USE_ZBUFFER - z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; -#endif - - - f32 iw = FIX_POINT_F32_MUL; - - tFixPoint r0, g0, b0; - tFixPoint a1, r1, g1, b1; - tFixPoint r2, g2, b2; - - s32 i; - - switch ( ZCompare ) - { - case 1: - for ( i = 0; i <= dx; ++i ) - { -#ifdef CMP_W - if ( line.w[0] >= z[i] ) -#endif - - { - -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - -#ifdef INVERSE_W - iw = fix_inverse32 ( line.w[0] ); -#endif - - getSample_texture ( r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) ); - color_to_fix1 ( a1, r1, g1, b1, dst[i] ); -#ifdef IPOL_C0 - getSample_color ( r2, g2, b2, line.c[0][0],iw ); - - a1 = FIX_POINT_ONE - a1; - dst[i] = fix_to_color ( imulFix ( imulFix ( r0, a1 ) + r1, r2 ), - imulFix ( imulFix ( g0, a1 ) + g1, g2 ), - imulFix ( imulFix ( b0, a1 ) + b1, b2 ) - ); -#else - dst[i] = fix_to_color ( imulFix ( r0, a1) + r0, - imulFix ( g0, a1) + g0, - imulFix ( b0, a1) + b0 - ); - -#endif - - } - -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0]; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC[0]; -#endif - } - break; - - case 2: - for ( i = 0; i <= dx; ++i ) - { -#ifdef CMP_W - if ( line.w[0] == z[i] ) -#endif - - { - -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - -#ifdef INVERSE_W - iw = fix_inverse32 ( line.w[0] ); -#endif - getSample_texture ( r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) ); - color_to_fix1 ( a1, r1, g1, b1, dst[i] ); - -#ifdef IPOL_C0 - getSample_color ( r2, g2, b2, line.c[0][0],iw ); - - a1 = FIX_POINT_ONE - a1; - dst[i] = fix_to_color ( imulFix ( imulFix ( r0, a1 ) + r1, r2 ), - imulFix ( imulFix ( g0, a1 ) + g1, g2 ), - imulFix ( imulFix ( b0, a1 ) + b1, b2 ) - ); -#else - dst[i] = fix_to_color ( imulFix ( r0, a1) + r0, - imulFix ( g0, a1) + g0, - imulFix ( b0, a1) + b0 - ); - -#endif - - } - -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0]; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC[0]; -#endif - }break; - } // zcompare - -} - -/*! -*/ -void CTRTextureBlend::fragment_src_alpha_one () -{ - tVideoSample *dst; - -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC[MATERIAL_MAX_COLORS]; -#endif -#ifdef IPOL_T0 - sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES]; -#endif - - // apply top-left fill-convention, left - xStart = core::ceil32( line.x[0] ); - xEnd = core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC[0] = (line.c[0][1] - line.c[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC[0] * subPixel; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0] * subPixel; -#endif -#ifdef IPOL_T1 - line.t[1][0] += slopeT[1] * subPixel; -#endif -#endif - - dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; - -#ifdef USE_ZBUFFER - z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; -#endif - - - f32 iw = FIX_POINT_F32_MUL; - - tFixPointu a0, r0, g0, b0; - tFixPoint r1, g1, b1; - tFixPoint r2, g2, b2; - - s32 i; - - switch ( ZCompare ) - { - case 1: - for ( i = 0; i <= dx; ++i ) - { -#ifdef CMP_W - if ( line.w[0] >= z[i] ) -#endif - - { - - -#ifdef INVERSE_W - iw = fix_inverse32 ( line.w[0] ); -#endif - - getSample_texture ( a0, r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) ); - if ( a0 > 0 ) - { - a0 >>= 8; - - color_to_fix ( r1, g1, b1, dst[i] ); - -#ifdef IPOL_C0 - getSample_color ( r2, g2, b2, line.c[0][0],iw ); - - dst[i] = fix4_to_color ( a0, - clampfix_maxcolor ( imulFix (r0,a0 ) + r1), - clampfix_maxcolor ( imulFix (g0,a0 ) + g1), - clampfix_maxcolor ( imulFix (b0,a0 ) + b1) - ); - -/* - a0 >>= 8; - dst[i] = fix4_to_color ( a0, - imulFix ( imulFix ( r0, a0 ) + r1, r2 ), - imulFix ( imulFix ( g0, a0 ) + g1, g2 ), - imulFix ( imulFix ( b0, a0 ) + b1, b2 ) - ); -*/ -#else - dst[i] = fix4_to_color ( a0, - clampfix_maxcolor ( imulFix (r0,a0 ) + r1 ), - clampfix_maxcolor ( imulFix (g0,a0 ) + g1 ), - clampfix_maxcolor ( imulFix (b0,a0 ) + b1 ) - ); - -#endif - -#ifdef WRITE_W - //z[i] = line.w[0]; -#endif - } - - } - -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0]; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC[0]; -#endif - } - break; - - case 2: - for ( i = 0; i <= dx; ++i ) - { -#ifdef CMP_W - if ( line.w[0] == z[i] ) -#endif - { - -#ifdef INVERSE_W - iw = fix_inverse32 ( line.w[0] ); -#endif - - getSample_texture ( a0, r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) ); - if ( a0 > 0 ) - { - a0 >>= 8; - - color_to_fix ( r1, g1, b1, dst[i] ); - -#ifdef IPOL_C0 - getSample_color ( r2, g2, b2, line.c[0][0],iw ); - - dst[i] = fix4_to_color ( a0, - clampfix_maxcolor ( imulFix ( imulFix (r0,a0 ) + r1, r2 ) ), - clampfix_maxcolor ( imulFix ( imulFix (g0,a0 ) + g1, g2 ) ), - clampfix_maxcolor ( imulFix ( imulFix (b0,a0 ) + b1, b2 ) ) - ); - -/* - a0 >>= 8; - dst[i] = fix4_to_color ( a0, - imulFix ( imulFix ( r0, a0 ) + r1, r2 ), - imulFix ( imulFix ( g0, a0 ) + g1, g2 ), - imulFix ( imulFix ( b0, a0 ) + b1, b2 ) - ); -*/ -#else - dst[i] = fix4_to_color ( a0, - clampfix_maxcolor ( imulFix (r0,a0 ) + r1 ), - clampfix_maxcolor ( imulFix (g0,a0 ) + g1 ), - clampfix_maxcolor ( imulFix (b0,a0 ) + b1 ) - ); - -#endif - -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - } - } -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0]; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC[0]; -#endif - }break; - } // zcompare - -} - - -/*! -*/ -void CTRTextureBlend::fragment_dst_color_one_minus_dst_alpha () -{ - tVideoSample *dst; - -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC[MATERIAL_MAX_COLORS]; -#endif -#ifdef IPOL_T0 - sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES]; -#endif - - // apply top-left fill-convention, left - xStart = core::ceil32( line.x[0] ); - xEnd = core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC[0] = (line.c[0][1] - line.c[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC[0] * subPixel; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0] * subPixel; -#endif -#ifdef IPOL_T1 - line.t[1][0] += slopeT[1] * subPixel; -#endif -#endif - - dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; - -#ifdef USE_ZBUFFER - z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; -#endif - - - f32 iw = FIX_POINT_F32_MUL; - - tFixPoint r0, g0, b0; - tFixPoint a1, r1, g1, b1; - tFixPoint r2, g2, b2; - - s32 i; - - switch ( ZCompare ) - { - case 1: - for ( i = 0; i <= dx; ++i ) - { -#ifdef CMP_W - if ( line.w[0] >= z[i] ) -#endif - - { - -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - -#ifdef INVERSE_W - iw = fix_inverse32 ( line.w[0] ); -#endif - - getSample_texture ( r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) ); - color_to_fix1 ( a1, r1, g1, b1, dst[i] ); -#ifdef IPOL_C0 - getSample_color ( r2, g2, b2, line.c[0][0],iw ); - - a1 = FIX_POINT_ONE - a1; - dst[i] = fix_to_color ( imulFix ( imulFix ( r1, r0 + a1 ), r2 ), - imulFix ( imulFix ( g1, g0 + a1 ), g2 ), - imulFix ( imulFix ( b1, b0 + a1 ), b2 ) - ); -#else - dst[i] = fix_to_color ( imulFix ( r1, r0 + a1 ), - imulFix ( g1, g0 + a1 ), - imulFix ( b1, b0 + a1 ) - ); - -#endif - - } - -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0]; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC[0]; -#endif - } - break; - - case 2: - for ( i = 0; i <= dx; ++i ) - { -#ifdef CMP_W - if ( line.w[0] == z[i] ) -#endif - - { - -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - -#ifdef INVERSE_W - iw = fix_inverse32 ( line.w[0] ); -#endif - getSample_texture ( r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) ); - color_to_fix1 ( a1, r1, g1, b1, dst[i] ); - -#ifdef IPOL_C0 - getSample_color ( r2, g2, b2, line.c[0][0],iw ); - - a1 = FIX_POINT_ONE - a1; - dst[i] = fix_to_color ( imulFix ( imulFix ( r1, r0 + a1 ), r2 ), - imulFix ( imulFix ( g1, g0 + a1 ), g2 ), - imulFix ( imulFix ( b1, b0 + a1 ), b2 ) - ); -#else - dst[i] = fix_to_color ( imulFix ( r1, r0 + a1 ), - imulFix ( g1, g0 + a1 ), - imulFix ( b1, b0 + a1 ) - ); - -#endif - - } - -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0]; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC[0]; -#endif - }break; - } // zcompare - -} - -/*! -*/ -void CTRTextureBlend::fragment_dst_color_zero () -{ - tVideoSample *dst; - -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC[MATERIAL_MAX_COLORS]; -#endif -#ifdef IPOL_T0 - sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES]; -#endif - - // apply top-left fill-convention, left - xStart = core::ceil32( line.x[0] ); - xEnd = core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC[0] = (line.c[0][1] - line.c[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC[0] * subPixel; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0] * subPixel; -#endif -#ifdef IPOL_T1 - line.t[1][0] += slopeT[1] * subPixel; -#endif -#endif - - dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; - -#ifdef USE_ZBUFFER - z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; -#endif - - - f32 iw = FIX_POINT_F32_MUL; - - tFixPoint r0, g0, b0; - tFixPoint r1, g1, b1; - tFixPoint r2, g2, b2; - - s32 i; - - switch ( ZCompare ) - { - case 1: - for ( i = 0; i <= dx; ++i ) - { -#ifdef CMP_W - if ( line.w[0] >= z[i] ) -#endif - - { - -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - -#ifdef INVERSE_W - iw = fix_inverse32 ( line.w[0] ); -#endif - - getSample_texture ( r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) ); - color_to_fix1 ( r1, g1, b1, dst[i] ); - -#ifdef IPOL_C0 - getSample_color ( r2, g2, b2, line.c[0][0],iw ); - - dst[i] = fix_to_color ( imulFix ( imulFix ( r0, r1 ), r2 ), - imulFix ( imulFix ( g0, g1 ), g2 ), - imulFix ( imulFix ( b0, b1 ), b2 ) ); -#else - dst[i] = fix_to_color ( imulFix ( r0, r1 ), - imulFix ( g0, g1 ), - imulFix ( b0, b1 ) - ); - -#endif - - } - -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0]; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC[0]; -#endif - } - break; - - case 2: - for ( i = 0; i <= dx; ++i ) - { -#ifdef CMP_W - if ( line.w[0] == z[i] ) -#endif - - { - -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - -#ifdef INVERSE_W - iw = fix_inverse32 ( line.w[0] ); -#endif - getSample_texture ( r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) ); - color_to_fix1 ( r1, g1, b1, dst[i] ); - -#ifdef IPOL_C0 - getSample_color ( r2, g2, b2, line.c[0][0],iw ); - - dst[i] = fix_to_color ( imulFix ( imulFix ( r0, r1 ), r2 ), - imulFix ( imulFix ( g0, g1 ), g2 ), - imulFix ( imulFix ( b0, b1 ), b2 ) - ); -#else - dst[i] = fix_to_color ( imulFix ( r0, r1 ), - imulFix ( g0, g1 ), - imulFix ( b0, b1 ) - ); - -#endif - - } - -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0]; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC[0]; -#endif - }break; - } // zcompare - -} - -/*! -*/ -void CTRTextureBlend::fragment_dst_color_one () -{ - tVideoSample *dst; - -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC[MATERIAL_MAX_COLORS]; -#endif -#ifdef IPOL_T0 - sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES]; -#endif - - // apply top-left fill-convention, left - xStart = core::ceil32( line.x[0] ); - xEnd = core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC[0] = (line.c[0][1] - line.c[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC[0] * subPixel; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0] * subPixel; -#endif -#ifdef IPOL_T1 - line.t[1][0] += slopeT[1] * subPixel; -#endif -#endif - - dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; - -#ifdef USE_ZBUFFER - z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; -#endif - - - f32 iw = FIX_POINT_F32_MUL; - - tFixPoint r0, g0, b0; - tFixPoint r1, g1, b1; - tFixPoint r2, g2, b2; - - s32 i; - - switch ( ZCompare ) - { - case 1: - for ( i = 0; i <= dx; ++i ) - { -#ifdef CMP_W - if ( line.w[0] >= z[i] ) -#endif - - { - -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - -#ifdef INVERSE_W - iw = fix_inverse32 ( line.w[0] ); -#endif - - getSample_texture ( r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) ); - color_to_fix ( r1, g1, b1, dst[i] ); -#ifdef IPOL_C0 - getSample_color ( r2, g2, b2, line.c[0][0],iw ); - - dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex1 ( r0, r1 ) + r1 ), - clampfix_maxcolor ( imulFix_tex1 ( g0, g1 ) + g1 ), - clampfix_maxcolor ( imulFix_tex1 ( b0, b1 ) + b1 ) - ); - -#else - dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex1 ( r0, r1 ) + r1 ), - clampfix_maxcolor ( imulFix_tex1 ( g0, g1 ) + g1 ), - clampfix_maxcolor ( imulFix_tex1 ( b0, b1 ) + b1 ) - ); - -#endif - - } - -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0]; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC[0]; -#endif - } - break; - - case 2: - for ( i = 0; i <= dx; ++i ) - { -#ifdef CMP_W - if ( line.w[0] == z[i] ) -#endif - - { - -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - -#ifdef INVERSE_W - iw = fix_inverse32 ( line.w[0] ); -#endif - getSample_texture ( r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) ); - color_to_fix ( r1, g1, b1, dst[i] ); - -#ifdef IPOL_C0 - getSample_color ( r2, g2, b2, line.c[0][0],iw ); - - dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex1 ( r0, r1 ) + r1 ), - clampfix_maxcolor ( imulFix_tex1 ( g0, g1 ) + g1 ), - clampfix_maxcolor ( imulFix_tex1 ( b0, b1 ) + b1 ) - ); - -#else - dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex1 ( r0, r1 ) + r1 ), - clampfix_maxcolor ( imulFix_tex1 ( g0, g1 ) + g1 ), - clampfix_maxcolor ( imulFix_tex1 ( b0, b1 ) + b1 ) - ); - -#endif - - - } - -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0]; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC[0]; -#endif - }break; - } // zcompare - -} - -/*! -*/ -void CTRTextureBlend::fragment_zero_one_minus_scr_color () -{ - tVideoSample *dst; - -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC[MATERIAL_MAX_COLORS]; -#endif -#ifdef IPOL_T0 - sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES]; -#endif - - // apply top-left fill-convention, left - xStart = core::ceil32( line.x[0] ); - xEnd = core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC[0] = (line.c[0][1] - line.c[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC[0] * subPixel; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0] * subPixel; -#endif -#ifdef IPOL_T1 - line.t[1][0] += slopeT[1] * subPixel; -#endif -#endif - - dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; - -#ifdef USE_ZBUFFER - z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; -#endif - - - f32 iw = FIX_POINT_F32_MUL; - - tFixPoint r0, g0, b0; - tFixPoint r1, g1, b1; - tFixPoint r2, g2, b2; - - s32 i; - - switch ( ZCompare ) - { - case 1: - for ( i = 0; i <= dx; ++i ) - { -#ifdef CMP_W - if ( line.w[0] >= z[i] ) -#endif - - { - -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - -#ifdef INVERSE_W - iw = fix_inverse32 ( line.w[0] ); -#endif - - getSample_texture ( r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) ); - color_to_fix1 ( r1, g1, b1, dst[i] ); -#ifdef IPOL_C0 - getSample_color ( r2, g2, b2, line.c[0][0],iw ); - - dst[i] = fix_to_color ( imulFix ( FIX_POINT_ONE - r0, r1 ), - imulFix ( FIX_POINT_ONE - g0, g1 ), - imulFix ( FIX_POINT_ONE - b0, b1 ) - ); - -#else - dst[i] = fix_to_color ( imulFix ( FIX_POINT_ONE - r0, r1 ), - imulFix ( FIX_POINT_ONE - g0, g1 ), - imulFix ( FIX_POINT_ONE - b0, b1 ) - ); - -#endif - - } - -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0]; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC[0]; -#endif - } - break; - - case 2: - for ( i = 0; i <= dx; ++i ) - { -#ifdef CMP_W - if ( line.w[0] == z[i] ) -#endif - - { - -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - -#ifdef INVERSE_W - iw = fix_inverse32 ( line.w[0] ); -#endif - getSample_texture ( r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) ); - color_to_fix1 ( r1, g1, b1, dst[i] ); -#ifdef IPOL_C0 - getSample_color ( r2, g2, b2, line.c[0][0],iw ); - - dst[i] = fix_to_color ( imulFix ( FIX_POINT_ONE - r0, r1 ), - imulFix ( FIX_POINT_ONE - g0, g1 ), - imulFix ( FIX_POINT_ONE - b0, b1 ) - ); - -#else - dst[i] = fix_to_color ( imulFix ( FIX_POINT_ONE - r0, r1 ), - imulFix ( FIX_POINT_ONE - g0, g1 ), - imulFix ( FIX_POINT_ONE - b0, b1 ) - ); - -#endif - - } - -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0]; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC[0]; -#endif - }break; - } // zcompare - -} - - - -void CTRTextureBlend::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - if ( 0 == fragmentShader ) - return; - - // sort on height, y - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - - const f32 ca = c->Pos.y - a->Pos.y; - const f32 ba = b->Pos.y - a->Pos.y; - const f32 cb = c->Pos.y - b->Pos.y; - // calculate delta y of the edges - scan.invDeltaY[0] = core::reciprocal( ca ); - scan.invDeltaY[1] = core::reciprocal( ba ); - scan.invDeltaY[2] = core::reciprocal( cb ); - - if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) - return; - - // find if the major edge is left or right aligned - f32 temp[4]; - - temp[0] = a->Pos.x - c->Pos.x; - temp[1] = -ca; - temp[2] = b->Pos.x - a->Pos.x; - temp[3] = ba; - - scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1; - scan.right = 1 - scan.left; - - // calculate slopes for the major edge - scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; - scan.x[0] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; - scan.z[0] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; - scan.w[0] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0][0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; - scan.c[0][0] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; - scan.t[0][0] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; - scan.t[1][0] = a->Tex[1]; -#endif - - // top left fill convention y run - s32 yStart; - s32 yEnd; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - - // rasterize upper sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[1] ) - { - // calculate slopes for top edge - scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; - scan.x[1] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; - scan.z[1] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; - scan.w[1] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0][1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; - scan.c[0][1] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; - scan.t[0][1] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; - scan.t[1][1] = a->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = core::ceil32( a->Pos.y ); - yEnd = core::ceil32( b->Pos.y ) - 1; - -#ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - a->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0] * subPixel; - scan.c[0][1] += scan.slopeC[0][1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0] * subPixel; - scan.t[0][1] += scan.slopeT[0][1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0] * subPixel; - scan.t[1][1] += scan.slopeT[1][1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[0][scan.left] = scan.c[0][0]; - line.c[0][scan.right] = scan.c[0][1]; -#endif - -#ifdef IPOL_T0 - line.t[0][scan.left] = scan.t[0][0]; - line.t[0][scan.right] = scan.t[0][1]; -#endif - -#ifdef IPOL_T1 - line.t[1][scan.left] = scan.t[1][0]; - line.t[1][scan.right] = scan.t[1][1]; -#endif - - // render a scanline - (this->*fragmentShader) (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0]; - scan.c[0][1] += scan.slopeC[0][1]; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0]; - scan.t[0][1] += scan.slopeT[0][1]; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0]; - scan.t[1][1] += scan.slopeT[1][1]; -#endif - - } - } - - // rasterize lower sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[2] ) - { - // advance to middle point - if( (f32) 0.0 != scan.invDeltaY[1] ) - { - temp[0] = b->Pos.y - a->Pos.y; // dy - - scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; -#ifdef IPOL_Z - scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; -#endif -#ifdef IPOL_W - scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; -#endif -#ifdef IPOL_C0 - scan.c[0][0] = a->Color[0] + scan.slopeC[0][0] * temp[0]; -#endif -#ifdef IPOL_T0 - scan.t[0][0] = a->Tex[0] + scan.slopeT[0][0] * temp[0]; -#endif -#ifdef IPOL_T1 - scan.t[1][0] = a->Tex[1] + scan.slopeT[1][0] * temp[0]; -#endif - - } - - // calculate slopes for bottom edge - scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; - scan.x[1] = b->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; - scan.z[1] = b->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; - scan.w[1] = b->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0][1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; - scan.c[0][1] = b->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; - scan.t[0][1] = b->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; - scan.t[1][1] = b->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = core::ceil32( b->Pos.y ); - yEnd = core::ceil32( c->Pos.y ) - 1; - -#ifdef SUBTEXEL - - subPixel = ( (f32) yStart ) - b->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0] * subPixel; - scan.c[0][1] += scan.slopeC[0][1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0] * subPixel; - scan.t[0][1] += scan.slopeT[0][1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0] * subPixel; - scan.t[1][1] += scan.slopeT[1][1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[0][scan.left] = scan.c[0][0]; - line.c[0][scan.right] = scan.c[0][1]; -#endif - -#ifdef IPOL_T0 - line.t[0][scan.left] = scan.t[0][0]; - line.t[0][scan.right] = scan.t[0][1]; -#endif - -#ifdef IPOL_T1 - line.t[1][scan.left] = scan.t[1][0]; - line.t[1][scan.right] = scan.t[1][1]; -#endif - - // render a scanline - (this->*fragmentShader) (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0]; - scan.c[0][1] += scan.slopeC[0][1]; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0]; - scan.t[0][1] += scan.slopeT[0][1]; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0]; - scan.t[1][1] += scan.slopeT[1][1]; -#endif - - } - } - -} - - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -IBurningShader* createTRTextureBlend(IDepthBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CTRTextureBlend(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - -} // end namespace video -} // end namespace irr - - diff --git a/irrlicht-1.6/source/Irrlicht/CTRTextureDetailMap2.cpp b/irrlicht-1.6/source/Irrlicht/CTRTextureDetailMap2.cpp deleted file mode 100644 index 0f3345881..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTRTextureDetailMap2.cpp +++ /dev/null @@ -1,661 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "IBurningShader.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -// compile flag for this file -#undef USE_ZBUFFER -#undef IPOL_Z -#undef CMP_Z -#undef WRITE_Z - -#undef IPOL_W -#undef CMP_W -#undef WRITE_W - -#undef SUBTEXEL -#undef INVERSE_W - -#undef IPOL_C0 -#undef IPOL_T0 -#undef IPOL_T1 - -// define render case -#define SUBTEXEL -#define INVERSE_W - -#define USE_ZBUFFER -#define IPOL_W -#define CMP_W -#define WRITE_W - -#define IPOL_C0 -#define IPOL_T0 -#define IPOL_T1 - -// apply global override -#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef INVERSE_W -#endif - -#ifndef SOFTWARE_DRIVER_2_SUBTEXEL - #undef SUBTEXEL -#endif - -#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #undef IPOL_C0 -#endif - - -#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) - #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef IPOL_W - #endif - #define IPOL_Z - - #ifdef CMP_W - #undef CMP_W - #define CMP_Z - #endif - - #ifdef WRITE_W - #undef WRITE_W - #define WRITE_Z - #endif - -#endif - - -namespace irr -{ - -namespace video -{ - -class CTRTextureDetailMap2 : public IBurningShader -{ -public: - - //! constructor - CTRTextureDetailMap2(IDepthBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - - -private: - void scanline_bilinear (); - sScanConvertData scan; - sScanLineData line; - -}; - -//! constructor -CTRTextureDetailMap2::CTRTextureDetailMap2(IDepthBuffer* zbuffer) -: IBurningShader(zbuffer) -{ - #ifdef _DEBUG - setDebugName("CTRTextureDetailMap2"); - #endif -} - - - -/*! -*/ -void CTRTextureDetailMap2::scanline_bilinear () -{ - tVideoSample *dst; - -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC; -#endif -#ifdef IPOL_T0 - sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES]; -#endif - - // apply top-left fill-convention, left - xStart = core::ceil32( line.x[0] ); - xEnd = core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC = (line.c[0][1] - line.c[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC * subPixel; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0] * subPixel; -#endif -#ifdef IPOL_T1 - line.t[1][0] += slopeT[1] * subPixel; -#endif -#endif - - dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; - -#ifdef USE_ZBUFFER - z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; -#endif - - -#ifdef INVERSE_W - f32 inversew; -#endif - - tFixPoint tx0, tx1; - tFixPoint ty0, ty1; - - tFixPoint r0, g0, b0; - tFixPoint r1, g1, b1; - tFixPoint r2, g2, b2; - - - for ( s32 i = 0; i <= dx; ++i ) - { -#ifdef CMP_Z - if ( line.z[0] < z[i] ) -#endif -#ifdef CMP_W - if ( line.w[0] >= z[i] ) -#endif - - { -#ifdef INVERSE_W - inversew = fix_inverse32 ( line.w[0] ); - - tx0 = tofix ( line.t[0][0].x,inversew); - ty0 = tofix ( line.t[0][0].y,inversew); - tx1 = tofix ( line.t[1][0].x,inversew); - ty1 = tofix ( line.t[1][0].y,inversew); - -#else - tx0 = tofix ( line.t[0][0].x ); - ty0 = tofix ( line.t[0][0].y ); - tx1 = tofix ( line.t[1][0].x ); - ty1 = tofix ( line.t[1][0].y ); -#endif - getSample_texture ( r0, g0, b0, &IT[0], tx0,ty0 ); - getSample_texture ( r1, g1, b1, &IT[1], tx1,ty1 ); - -#define FIX_POINT_HALF_COLOR ( (tFixPoint) ( ((f32) COLOR_MAX / 2.f * FIX_POINT_F32_MUL ) ) ) - - // bias half color - r1 += -FIX_POINT_HALF_COLOR; - g1 += -FIX_POINT_HALF_COLOR; - b1 += -FIX_POINT_HALF_COLOR; - - r2 = clampfix_mincolor ( clampfix_maxcolor ( r0 + r1 ) ); - g2 = clampfix_mincolor ( clampfix_maxcolor ( g0 + g1 ) ); - b2 = clampfix_mincolor ( clampfix_maxcolor ( b0 + b1 ) ); - - dst[i] = fix_to_color ( r2, g2, b2 ); - -#ifdef WRITE_Z - z[i] = line.z[0]; -#endif -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - - } - -#ifdef IPOL_Z - line.z[0] += slopeZ; -#endif -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0]; -#endif -#ifdef IPOL_T1 - line.t[1][0] += slopeT[1]; -#endif - } - -} - -void CTRTextureDetailMap2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - // sort on height, y - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - - const f32 ca = c->Pos.y - a->Pos.y; - const f32 ba = b->Pos.y - a->Pos.y; - const f32 cb = c->Pos.y - b->Pos.y; - // calculate delta y of the edges - scan.invDeltaY[0] = core::reciprocal( ca ); - scan.invDeltaY[1] = core::reciprocal( ba ); - scan.invDeltaY[2] = core::reciprocal( cb ); - - if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) - return; - - // find if the major edge is left or right aligned - f32 temp[4]; - - temp[0] = a->Pos.x - c->Pos.x; - temp[1] = -ca; - temp[2] = b->Pos.x - a->Pos.x; - temp[3] = ba; - - scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1; - scan.right = 1 - scan.left; - - // calculate slopes for the major edge - scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; - scan.x[0] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; - scan.z[0] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; - scan.w[0] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0][0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; - scan.c[0][0] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; - scan.t[0][0] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; - scan.t[1][0] = a->Tex[1]; -#endif - - // top left fill convention y run - s32 yStart; - s32 yEnd; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - - // rasterize upper sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[1] ) - { - // calculate slopes for top edge - scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; - scan.x[1] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; - scan.z[1] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; - scan.w[1] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0][1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; - scan.c[0][1] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; - scan.t[0][1] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; - scan.t[1][1] = a->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = core::ceil32( a->Pos.y ); - yEnd = core::ceil32( b->Pos.y ) - 1; - -#ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - a->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0] * subPixel; - scan.c[0][1] += scan.slopeC[0][1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0] * subPixel; - scan.t[0][1] += scan.slopeT[0][1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0] * subPixel; - scan.t[1][1] += scan.slopeT[1][1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[0][scan.left] = scan.c[0][0]; - line.c[0][scan.right] = scan.c[0][1]; -#endif - -#ifdef IPOL_T0 - line.t[0][scan.left] = scan.t[0][0]; - line.t[0][scan.right] = scan.t[0][1]; -#endif - -#ifdef IPOL_T1 - line.t[1][scan.left] = scan.t[1][0]; - line.t[1][scan.right] = scan.t[1][1]; -#endif - - // render a scanline - scanline_bilinear (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0]; - scan.c[0][1] += scan.slopeC[0][1]; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0]; - scan.t[0][1] += scan.slopeT[0][1]; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0]; - scan.t[1][1] += scan.slopeT[1][1]; -#endif - - } - } - - // rasterize lower sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[2] ) - { - // advance to middle point - if( (f32) 0.0 != scan.invDeltaY[1] ) - { - temp[0] = b->Pos.y - a->Pos.y; // dy - - scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; -#ifdef IPOL_Z - scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; -#endif -#ifdef IPOL_W - scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; -#endif -#ifdef IPOL_C0 - scan.c[0][0] = a->Color[0] + scan.slopeC[0][0] * temp[0]; -#endif -#ifdef IPOL_T0 - scan.t[0][0] = a->Tex[0] + scan.slopeT[0][0] * temp[0]; -#endif -#ifdef IPOL_T1 - scan.t[1][0] = a->Tex[1] + scan.slopeT[1][0] * temp[0]; -#endif - - } - - // calculate slopes for bottom edge - scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; - scan.x[1] = b->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; - scan.z[1] = b->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; - scan.w[1] = b->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0][1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; - scan.c[0][1] = b->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; - scan.t[0][1] = b->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; - scan.t[1][1] = b->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = core::ceil32( b->Pos.y ); - yEnd = core::ceil32( c->Pos.y ) - 1; - -#ifdef SUBTEXEL - - subPixel = ( (f32) yStart ) - b->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0] * subPixel; - scan.c[0][1] += scan.slopeC[0][1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0] * subPixel; - scan.t[0][1] += scan.slopeT[0][1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0] * subPixel; - scan.t[1][1] += scan.slopeT[1][1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[0][scan.left] = scan.c[0][0]; - line.c[0][scan.right] = scan.c[0][1]; -#endif - -#ifdef IPOL_T0 - line.t[0][scan.left] = scan.t[0][0]; - line.t[0][scan.right] = scan.t[0][1]; -#endif - -#ifdef IPOL_T1 - line.t[1][scan.left] = scan.t[1][0]; - line.t[1][scan.right] = scan.t[1][1]; -#endif - - // render a scanline - scanline_bilinear (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0]; - scan.c[0][1] += scan.slopeC[0][1]; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0]; - scan.t[0][1] += scan.slopeT[0][1]; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0]; - scan.t[1][1] += scan.slopeT[1][1]; -#endif - - } - } - -} - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -IBurningShader* createTriangleRendererTextureDetailMap2(IDepthBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CTRTextureDetailMap2(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - -} // end namespace video -} // end namespace irr - - diff --git a/irrlicht-1.6/source/Irrlicht/CTRTextureFlat.cpp b/irrlicht-1.6/source/Irrlicht/CTRTextureFlat.cpp deleted file mode 100644 index 67c3b7a7a..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTRTextureFlat.cpp +++ /dev/null @@ -1,339 +0,0 @@ -// Copyright (C) 2002-2009 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" -#include "CTRTextureGouraud.h" - -#ifdef _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -class CTRTextureFlat : public CTRTextureGouraud -{ -public: - - CTRTextureFlat(IZBuffer* zbuffer) - : CTRTextureGouraud(zbuffer) - { - #ifdef _DEBUG - setDebugName("CTRTextureFlat"); - #endif - } - - //! draws an indexed triangle list - virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount) - { - const S2DVertex *v1, *v2, *v3; - - f32 tmpDiv; // temporary division factor - f32 longest; // saves the longest span - s32 height; // saves height of triangle - u16* targetSurface; // target pointer where to plot pixels - s32 spanEnd; // saves end of spans - f32 leftdeltaxf; // amount of pixels to increase on left side of triangle - f32 rightdeltaxf; // amount of pixels to increase on right side of triangle - s32 leftx, rightx; // position where we are - f32 leftxf, rightxf; // same as above, but as f32 values - s32 span; // current span - u16 *hSpanBegin, *hSpanEnd; // pointer used when plotting pixels - s32 leftTx, rightTx, leftTy, rightTy; // texture interpolating values - s32 leftTxStep, rightTxStep, leftTyStep, rightTyStep; // texture interpolating values - s32 spanTx, spanTy, spanTxStep, spanTyStep; // values of Texturecoords when drawing a span - core::rect<s32> TriangleRect; - - s32 leftZValue, rightZValue; - s32 leftZStep, rightZStep; - s32 spanZValue, spanZStep; // ZValues when drawing a span - TZBufferType* zTarget, *spanZTarget; // target of ZBuffer; - - lockedSurface = (u16*)RenderTarget->lock(); - lockedZBuffer = ZBuffer->lock(); - lockedTexture = (u16*)Texture->lock(); - - for (s32 i=0; i<triangleCount; ++i) - { - v1 = &vertices[*indexList]; - ++indexList; - v2 = &vertices[*indexList]; - ++indexList; - v3 = &vertices[*indexList]; - ++indexList; - - // back face culling - - if (BackFaceCullingEnabled) - { - s32 z = ((v3->Pos.X - v1->Pos.X) * (v3->Pos.Y - v2->Pos.Y)) - - ((v3->Pos.Y - v1->Pos.Y) * (v3->Pos.X - v2->Pos.X)); - - if (z < 0) - continue; - } - - //near plane clipping - - if (v1->ZValue<0 && v2->ZValue<0 && v3->ZValue<0) - continue; - - // sort for width for inscreen clipping - - if (v1->Pos.X > v2->Pos.X) swapVertices(&v1, &v2); - if (v1->Pos.X > v3->Pos.X) swapVertices(&v1, &v3); - if (v2->Pos.X > v3->Pos.X) swapVertices(&v2, &v3); - - if ((v1->Pos.X - v3->Pos.X) == 0) - continue; - - TriangleRect.UpperLeftCorner.X = v1->Pos.X; - TriangleRect.LowerRightCorner.X = v3->Pos.X; - - // sort for height for faster drawing. - - if (v1->Pos.Y > v2->Pos.Y) swapVertices(&v1, &v2); - if (v1->Pos.Y > v3->Pos.Y) swapVertices(&v1, &v3); - if (v2->Pos.Y > v3->Pos.Y) swapVertices(&v2, &v3); - - TriangleRect.UpperLeftCorner.Y = v1->Pos.Y; - TriangleRect.LowerRightCorner.Y = v3->Pos.Y; - - if (!TriangleRect.isRectCollided(ViewPortRect)) - continue; - - // calculate height of triangle - height = v3->Pos.Y - v1->Pos.Y; - if (!height) - continue; - - // calculate longest span - - longest = (v2->Pos.Y - v1->Pos.Y) / (f32)height * (v3->Pos.X - v1->Pos.X) + (v1->Pos.X - v2->Pos.X); - - spanEnd = v2->Pos.Y; - span = v1->Pos.Y; - leftxf = (f32)v1->Pos.X; - rightxf = (f32)v1->Pos.X; - - leftZValue = v1->ZValue; - rightZValue = v1->ZValue; - - leftTx = rightTx = v1->TCoords.X; - leftTy = rightTy = v1->TCoords.Y; - - targetSurface = lockedSurface + span * SurfaceWidth; - zTarget = lockedZBuffer + span * SurfaceWidth; - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - rightdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - rightZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); - rightTxStep = (s32)((v2->TCoords.X - rightTx) * tmpDiv); - rightTyStep = (s32)((v2->TCoords.Y - rightTy) * tmpDiv); - - tmpDiv = 1.0f / (f32)height; - leftdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - leftZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); - leftTxStep = (s32)((v3->TCoords.X - leftTx) * tmpDiv); - leftTyStep = (s32)((v3->TCoords.Y - leftTy) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (f32)height; - rightdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - rightZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); - rightTxStep = (s32)((v3->TCoords.X - rightTx) * tmpDiv); - rightTyStep = (s32)((v3->TCoords.Y - rightTy) * tmpDiv); - - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - leftdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - leftZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); - leftTxStep = (s32)((v2->TCoords.X - leftTx) * tmpDiv); - leftTyStep = (s32)((v2->TCoords.Y - leftTy) * tmpDiv); - } - - - // do it twice, once for the first half of the triangle, - // end then for the second half. - - for (s32 triangleHalf=0; triangleHalf<2; ++triangleHalf) - { - if (spanEnd > ViewPortRect.LowerRightCorner.Y) - spanEnd = ViewPortRect.LowerRightCorner.Y; - - // if the span <0, than we can skip these spans, - // and proceed to the next spans which are really on the screen. - if (span < ViewPortRect.UpperLeftCorner.Y) - { - // we'll use leftx as temp variable - if (spanEnd < ViewPortRect.UpperLeftCorner.Y) - { - leftx = spanEnd - span; - span = spanEnd; - } - else - { - leftx = ViewPortRect.UpperLeftCorner.Y - span; - span = ViewPortRect.UpperLeftCorner.Y; - } - - leftxf += leftdeltaxf*leftx; - rightxf += rightdeltaxf*leftx; - targetSurface += SurfaceWidth*leftx; - zTarget += SurfaceWidth*leftx; - leftZValue += leftZStep*leftx; - rightZValue += rightZStep*leftx; - - leftTx += leftTxStep*leftx; - leftTy += leftTyStep*leftx; - rightTx += rightTxStep*leftx; - rightTy += rightTyStep*leftx; - } - - - // the main loop. Go through every span and draw it. - - while (span < spanEnd) - { - leftx = (s32)(leftxf); - rightx = (s32)(rightxf + 0.5f); - - // perform some clipping - - // TODO: clipping is not correct when leftx is clipped. - - if (leftx<ViewPortRect.UpperLeftCorner.X) - leftx = ViewPortRect.UpperLeftCorner.X; - else - if (leftx>ViewPortRect.LowerRightCorner.X) - leftx = ViewPortRect.LowerRightCorner.X; - - if (rightx<ViewPortRect.UpperLeftCorner.X) - rightx = ViewPortRect.UpperLeftCorner.X; - else - if (rightx>ViewPortRect.LowerRightCorner.X) - rightx = ViewPortRect.LowerRightCorner.X; - - // draw the span - - if (rightx - leftx != 0) - { - tmpDiv = 1.0f / (rightx - leftx); - spanZValue = leftZValue; - spanZStep = (s32)((rightZValue - leftZValue) * tmpDiv); - - hSpanBegin = targetSurface + leftx; - spanZTarget = zTarget + leftx; - hSpanEnd = targetSurface + rightx; - - spanTx = leftTx; - spanTy = leftTy; - spanTxStep = (s32)((rightTx - leftTx) * tmpDiv); - spanTyStep = (s32)((rightTy - leftTy) * tmpDiv); - - while (hSpanBegin < hSpanEnd) - { - if (spanZValue > *spanZTarget) - { - *spanZTarget = spanZValue; - *hSpanBegin = lockedTexture[((spanTy>>8)&textureYMask) * lockedTextureWidth + ((spanTx>>8)&textureXMask)]; - } - - spanTx += spanTxStep; - spanTy += spanTyStep; - - spanZValue += spanZStep; - ++hSpanBegin; - ++spanZTarget; - } - } - - leftxf += leftdeltaxf; - rightxf += rightdeltaxf; - ++span; - targetSurface += SurfaceWidth; - zTarget += SurfaceWidth; - leftZValue += leftZStep; - rightZValue += rightZStep; - - leftTx += leftTxStep; - leftTy += leftTyStep; - rightTx += rightTxStep; - rightTy += rightTyStep; - } - - if (triangleHalf>0) // break, we've gout only two halves - break; - - - // setup variables for second half of the triangle. - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - rightdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - rightxf = (f32)v2->Pos.X; - - rightZValue = v2->ZValue; - rightZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); - - rightTx = v2->TCoords.X; - rightTy = v2->TCoords.Y; - rightTxStep = (s32)((v3->TCoords.X - rightTx) * tmpDiv); - rightTyStep = (s32)((v3->TCoords.Y - rightTy) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - leftdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - leftxf = (f32)v2->Pos.X; - - leftZValue = v2->ZValue; - leftZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); - - leftTx = v2->TCoords.X; - leftTy = v2->TCoords.Y; - leftTxStep = (s32)((v3->TCoords.X - leftTx) * tmpDiv); - leftTyStep = (s32)((v3->TCoords.Y - leftTy) * tmpDiv); - } - - - spanEnd = v3->Pos.Y; - } - - } - - RenderTarget->unlock(); - ZBuffer->unlock(); - Texture->unlock(); - - } -}; - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -ITriangleRenderer* createTriangleRendererTextureFlat(IZBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_SOFTWARE_ - return new CTRTextureFlat(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_SOFTWARE_ -} - -} // end namespace video -} // end namespace irr diff --git a/irrlicht-1.6/source/Irrlicht/CTRTextureFlatWire.cpp b/irrlicht-1.6/source/Irrlicht/CTRTextureFlatWire.cpp deleted file mode 100644 index d1d4694c4..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTRTextureFlatWire.cpp +++ /dev/null @@ -1,313 +0,0 @@ -// Copyright (C) 2002-2009 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" -#include "CTRTextureGouraud.h" - -#ifdef _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -class CTRTextureFlatWire : public CTRTextureGouraud -{ -public: - - CTRTextureFlatWire(IZBuffer* zbuffer) - : CTRTextureGouraud(zbuffer) - { - #ifdef _DEBUG - setDebugName("CTRTextureFlatWire"); - #endif - } - - //! draws an indexed triangle list - virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount) - { - const S2DVertex *v1, *v2, *v3; - - f32 tmpDiv; // temporary division factor - f32 longest; // saves the longest span - s32 height; // saves height of triangle - u16* targetSurface; // target pointer where to plot pixels - s32 spanEnd; // saves end of spans - f32 leftdeltaxf; // amount of pixels to increase on left side of triangle - f32 rightdeltaxf; // amount of pixels to increase on right side of triangle - s32 leftx, rightx; // position where we are - f32 leftxf, rightxf; // same as above, but as f32 values - s32 span; // current span - s32 leftTx, rightTx, leftTy, rightTy; // texture interpolating values - s32 leftTxStep, rightTxStep, leftTyStep, rightTyStep; // texture interpolating values - core::rect<s32> TriangleRect; - - s32 leftZValue, rightZValue; - s32 leftZStep, rightZStep; - TZBufferType* zTarget; // target of ZBuffer; - - lockedSurface = (u16*)RenderTarget->lock(); - lockedZBuffer = ZBuffer->lock(); - lockedTexture = (u16*)Texture->lock(); - - for (s32 i=0; i<triangleCount; ++i) - { - v1 = &vertices[*indexList]; - ++indexList; - v2 = &vertices[*indexList]; - ++indexList; - v3 = &vertices[*indexList]; - ++indexList; - - // back face culling - - if (BackFaceCullingEnabled) - { - s32 z = ((v3->Pos.X - v1->Pos.X) * (v3->Pos.Y - v2->Pos.Y)) - - ((v3->Pos.Y - v1->Pos.Y) * (v3->Pos.X - v2->Pos.X)); - - if (z < 0) - continue; - } - - //near plane clipping - - if (v1->ZValue<0 && v2->ZValue<0 && v3->ZValue<0) - continue; - - // sort for width for inscreen clipping - - if (v1->Pos.X > v2->Pos.X) swapVertices(&v1, &v2); - if (v1->Pos.X > v3->Pos.X) swapVertices(&v1, &v3); - if (v2->Pos.X > v3->Pos.X) swapVertices(&v2, &v3); - - if ((v1->Pos.X - v3->Pos.X) == 0) - continue; - - TriangleRect.UpperLeftCorner.X = v1->Pos.X; - TriangleRect.LowerRightCorner.X = v3->Pos.X; - - // sort for height for faster drawing. - - if (v1->Pos.Y > v2->Pos.Y) swapVertices(&v1, &v2); - if (v1->Pos.Y > v3->Pos.Y) swapVertices(&v1, &v3); - if (v2->Pos.Y > v3->Pos.Y) swapVertices(&v2, &v3); - - TriangleRect.UpperLeftCorner.Y = v1->Pos.Y; - TriangleRect.LowerRightCorner.Y = v3->Pos.Y; - - if (!TriangleRect.isRectCollided(ViewPortRect)) - continue; - - // calculate height of triangle - height = v3->Pos.Y - v1->Pos.Y; - if (!height) - continue; - - // calculate longest span - - longest = (v2->Pos.Y - v1->Pos.Y) / (f32)height * (v3->Pos.X - v1->Pos.X) + (v1->Pos.X - v2->Pos.X); - - spanEnd = v2->Pos.Y; - span = v1->Pos.Y; - leftxf = (f32)v1->Pos.X; - rightxf = (f32)v1->Pos.X; - - leftZValue = v1->ZValue; - rightZValue = v1->ZValue; - - leftTx = rightTx = v1->TCoords.X; - leftTy = rightTy = v1->TCoords.Y; - - targetSurface = lockedSurface + span * SurfaceWidth; - zTarget = lockedZBuffer + span * SurfaceWidth; - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - rightdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - rightZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); - rightTxStep = (s32)((v2->TCoords.X - rightTx) * tmpDiv); - rightTyStep = (s32)((v2->TCoords.Y - rightTy) * tmpDiv); - - tmpDiv = 1.0f / (f32)height; - leftdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - leftZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); - leftTxStep = (s32)((v3->TCoords.X - leftTx) * tmpDiv); - leftTyStep = (s32)((v3->TCoords.Y - leftTy) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (f32)height; - rightdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - rightZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); - rightTxStep = (s32)((v3->TCoords.X - rightTx) * tmpDiv); - rightTyStep = (s32)((v3->TCoords.Y - rightTy) * tmpDiv); - - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - leftdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - leftZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); - leftTxStep = (s32)((v2->TCoords.X - leftTx) * tmpDiv); - leftTyStep = (s32)((v2->TCoords.Y - leftTy) * tmpDiv); - } - - - // do it twice, once for the first half of the triangle, - // end then for the second half. - - for (s32 triangleHalf=0; triangleHalf<2; ++triangleHalf) - { - if (spanEnd > ViewPortRect.LowerRightCorner.Y) - spanEnd = ViewPortRect.LowerRightCorner.Y; - - // if the span <0, than we can skip these spans, - // and proceed to the next spans which are really on the screen. - if (span < ViewPortRect.UpperLeftCorner.Y) - { - // we'll use leftx as temp variable - if (spanEnd < ViewPortRect.UpperLeftCorner.Y) - { - leftx = spanEnd - span; - span = spanEnd; - } - else - { - leftx = ViewPortRect.UpperLeftCorner.Y - span; - span = ViewPortRect.UpperLeftCorner.Y; - } - - leftxf += leftdeltaxf*leftx; - rightxf += rightdeltaxf*leftx; - targetSurface += SurfaceWidth*leftx; - zTarget += SurfaceWidth*leftx; - leftZValue += leftZStep*leftx; - rightZValue += rightZStep*leftx; - - leftTx += leftTxStep*leftx; - leftTy += leftTyStep*leftx; - rightTx += rightTxStep*leftx; - rightTy += rightTyStep*leftx; - } - - - // the main loop. Go through every span and draw it. - - while (span < spanEnd) - { - leftx = (s32)(leftxf); - rightx = (s32)(rightxf + 0.5f); - - // perform some clipping - - if (leftx>=ViewPortRect.UpperLeftCorner.X && - leftx<=ViewPortRect.LowerRightCorner.X) - { - if (leftZValue > *(zTarget + leftx)) - { - *(zTarget + leftx) = leftZValue; - *(targetSurface + leftx) = lockedTexture[((leftTy>>8)&textureYMask) * lockedTextureWidth + ((rightTx>>8)&textureXMask)]; - } - } - - - if (rightx>=ViewPortRect.UpperLeftCorner.X && - rightx<=ViewPortRect.LowerRightCorner.X) - { - if (rightZValue > *(zTarget + rightx)) - { - *(zTarget + rightx) = rightZValue; - *(targetSurface + rightx) = lockedTexture[((rightTy>>8)&textureYMask) * lockedTextureWidth + ((rightTx>>8)&textureXMask)]; - } - - } - - - leftxf += leftdeltaxf; - rightxf += rightdeltaxf; - ++span; - targetSurface += SurfaceWidth; - zTarget += SurfaceWidth; - leftZValue += leftZStep; - rightZValue += rightZStep; - - leftTx += leftTxStep; - leftTy += leftTyStep; - rightTx += rightTxStep; - rightTy += rightTyStep; - } - - if (triangleHalf>0) // break, we've gout only two halves - break; - - - // setup variables for second half of the triangle. - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - rightdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - rightxf = (f32)v2->Pos.X; - - rightZValue = v2->ZValue; - rightZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); - - rightTx = v2->TCoords.X; - rightTy = v2->TCoords.Y; - rightTxStep = (s32)((v3->TCoords.X - rightTx) * tmpDiv); - rightTyStep = (s32)((v3->TCoords.Y - rightTy) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - leftdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - leftxf = (f32)v2->Pos.X; - - leftZValue = v2->ZValue; - leftZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); - - leftTx = v2->TCoords.X; - leftTy = v2->TCoords.Y; - leftTxStep = (s32)((v3->TCoords.X - leftTx) * tmpDiv); - leftTyStep = (s32)((v3->TCoords.Y - leftTy) * tmpDiv); - } - - - spanEnd = v3->Pos.Y; - } - - } - - RenderTarget->unlock(); - ZBuffer->unlock(); - Texture->unlock(); - - } -}; - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -ITriangleRenderer* createTriangleRendererTextureFlatWire(IZBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_SOFTWARE_ - return new CTRTextureFlatWire(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_SOFTWARE_ -} - -} // end namespace video -} // end namespace irr - - diff --git a/irrlicht-1.6/source/Irrlicht/CTRTextureGouraud.cpp b/irrlicht-1.6/source/Irrlicht/CTRTextureGouraud.cpp deleted file mode 100644 index bd8225d0e..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTRTextureGouraud.cpp +++ /dev/null @@ -1,468 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CTRTextureGouraud.h" - -#ifdef _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -//! constructor -CTRTextureGouraud::CTRTextureGouraud(IZBuffer* zbuffer) - : RenderTarget(0), ZBuffer(zbuffer), SurfaceWidth(0), SurfaceHeight(0), - BackFaceCullingEnabled(true), lockedZBuffer(0), - lockedSurface(0), lockedTexture(0), lockedTextureWidth(0), - textureXMask(0), textureYMask(0), Texture(0) -{ - #ifdef _DEBUG - setDebugName("CTRTextureGouraud"); - #endif - - if (ZBuffer) - zbuffer->grab(); -} - - - -//! destructor -CTRTextureGouraud::~CTRTextureGouraud() -{ - if (RenderTarget) - RenderTarget->drop(); - - if (ZBuffer) - ZBuffer->drop(); - - if (Texture) - Texture->drop(); -} - - - -//! sets the Texture -void CTRTextureGouraud::setTexture(video::IImage* texture) -{ - if (Texture) - Texture->drop(); - - Texture = texture; - - if (Texture) - { - Texture->grab(); - lockedTextureWidth = Texture->getDimension().Width; - - textureXMask = lockedTextureWidth-1; - textureYMask = Texture->getDimension().Height-1; - } -} - - - - -//! en or disables the backface culling -void CTRTextureGouraud::setBackfaceCulling(bool enabled) -{ - BackFaceCullingEnabled = enabled; -} - - - -//! sets a render target -void CTRTextureGouraud::setRenderTarget(video::IImage* surface, const core::rect<s32>& viewPort) -{ - if (RenderTarget) - RenderTarget->drop(); - - RenderTarget = surface; - - if (RenderTarget) - { - SurfaceWidth = RenderTarget->getDimension().Width; - SurfaceHeight = RenderTarget->getDimension().Height; - RenderTarget->grab(); - ViewPortRect = viewPort; - } -} - - - -//! draws an indexed triangle list -void CTRTextureGouraud::drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount) -{ - const S2DVertex *v1, *v2, *v3; - - f32 tmpDiv; // temporary division factor - f32 longest; // saves the longest span - s32 height; // saves height of triangle - u16* targetSurface; // target pointer where to plot pixels - s32 spanEnd; // saves end of spans - f32 leftdeltaxf; // amount of pixels to increase on left side of triangle - f32 rightdeltaxf; // amount of pixels to increase on right side of triangle - s32 leftx, rightx; // position where we are - f32 leftxf, rightxf; // same as above, but as f32 values - s32 span; // current span - u16 *hSpanBegin, *hSpanEnd; // pointer used when plotting pixels - s32 leftR, leftG, leftB, rightR, rightG, rightB; // color values - s32 leftStepR, leftStepG, leftStepB, - rightStepR, rightStepG, rightStepB; // color steps - s32 spanR, spanG, spanB, spanStepR, spanStepG, spanStepB; // color interpolating values while drawing a span. - s32 leftTx, rightTx, leftTy, rightTy; // texture interpolating values - s32 leftTxStep, rightTxStep, leftTyStep, rightTyStep; // texture interpolating values - s32 spanTx, spanTy, spanTxStep, spanTyStep; // values of Texturecoords when drawing a span - core::rect<s32> TriangleRect; - - s32 leftZValue, rightZValue; - s32 leftZStep, rightZStep; - s32 spanZValue, spanZStep; // ZValues when drawing a span - TZBufferType* zTarget, *spanZTarget; // target of ZBuffer; - - lockedSurface = (u16*)RenderTarget->lock(); - lockedZBuffer = ZBuffer->lock(); - lockedTexture = (u16*)Texture->lock(); - - for (s32 i=0; i<triangleCount; ++i) - { - v1 = &vertices[*indexList]; - ++indexList; - v2 = &vertices[*indexList]; - ++indexList; - v3 = &vertices[*indexList]; - ++indexList; - - // back face culling - - if (BackFaceCullingEnabled) - { - s32 z = ((v3->Pos.X - v1->Pos.X) * (v3->Pos.Y - v2->Pos.Y)) - - ((v3->Pos.Y - v1->Pos.Y) * (v3->Pos.X - v2->Pos.X)); - - if (z < 0) - continue; - } - - //near plane clipping - - if (v1->ZValue<0 && v2->ZValue<0 && v3->ZValue<0) - continue; - - // sort for width for inscreen clipping - - if (v1->Pos.X > v2->Pos.X) swapVertices(&v1, &v2); - if (v1->Pos.X > v3->Pos.X) swapVertices(&v1, &v3); - if (v2->Pos.X > v3->Pos.X) swapVertices(&v2, &v3); - - if ((v1->Pos.X - v3->Pos.X) == 0) - continue; - - TriangleRect.UpperLeftCorner.X = v1->Pos.X; - TriangleRect.LowerRightCorner.X = v3->Pos.X; - - // sort for height for faster drawing. - - if (v1->Pos.Y > v2->Pos.Y) swapVertices(&v1, &v2); - if (v1->Pos.Y > v3->Pos.Y) swapVertices(&v1, &v3); - if (v2->Pos.Y > v3->Pos.Y) swapVertices(&v2, &v3); - - TriangleRect.UpperLeftCorner.Y = v1->Pos.Y; - TriangleRect.LowerRightCorner.Y = v3->Pos.Y; - - if (!TriangleRect.isRectCollided(ViewPortRect)) - continue; - - // calculate height of triangle - height = v3->Pos.Y - v1->Pos.Y; - if (!height) - continue; - - // calculate longest span - - longest = (v2->Pos.Y - v1->Pos.Y) / (f32)height * (v3->Pos.X - v1->Pos.X) + (v1->Pos.X - v2->Pos.X); - - spanEnd = v2->Pos.Y; - span = v1->Pos.Y; - leftxf = (f32)v1->Pos.X; - rightxf = (f32)v1->Pos.X; - - leftZValue = v1->ZValue; - rightZValue = v1->ZValue; - - leftR = rightR = video::getRed(v1->Color)<<8; - leftG = rightG = video::getGreen(v1->Color)<<8; - leftB = rightB = video::getBlue(v1->Color)<<8; - leftTx = rightTx = v1->TCoords.X; - leftTy = rightTy = v1->TCoords.Y; - - targetSurface = lockedSurface + span * SurfaceWidth; - zTarget = lockedZBuffer + span * SurfaceWidth; - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - rightdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - rightZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); - rightStepR = (s32)(((s32)(video::getRed(v2->Color)<<8) - rightR) * tmpDiv); - rightStepG = (s32)(((s32)(video::getGreen(v2->Color)<<8) - rightG) * tmpDiv); - rightStepB = (s32)(((s32)(video::getBlue(v2->Color)<<8) - rightB) * tmpDiv); - rightTxStep = (s32)((v2->TCoords.X - rightTx) * tmpDiv); - rightTyStep = (s32)((v2->TCoords.Y - rightTy) * tmpDiv); - - tmpDiv = 1.0f / (f32)height; - leftdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - leftZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); - leftStepR = (s32)(((s32)(video::getRed(v3->Color)<<8) - leftR) * tmpDiv); - leftStepG = (s32)(((s32)(video::getGreen(v3->Color)<<8) - leftG) * tmpDiv); - leftStepB = (s32)(((s32)(video::getBlue(v3->Color)<<8) - leftB) * tmpDiv); - leftTxStep = (s32)((v3->TCoords.X - leftTx) * tmpDiv); - leftTyStep = (s32)((v3->TCoords.Y - leftTy) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (f32)height; - rightdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - rightZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); - rightStepR = (s32)(((s32)(video::getRed(v3->Color)<<8) - rightR) * tmpDiv); - rightStepG = (s32)(((s32)(video::getGreen(v3->Color)<<8) - rightG) * tmpDiv); - rightStepB = (s32)(((s32)(video::getBlue(v3->Color)<<8) - rightB) * tmpDiv); - rightTxStep = (s32)((v3->TCoords.X - rightTx) * tmpDiv); - rightTyStep = (s32)((v3->TCoords.Y - rightTy) * tmpDiv); - - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - leftdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - leftZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); - leftStepR = (s32)(((s32)(video::getRed(v2->Color)<<8) - leftR) * tmpDiv); - leftStepG = (s32)(((s32)(video::getGreen(v2->Color)<<8) - leftG) * tmpDiv); - leftStepB = (s32)(((s32)(video::getBlue(v2->Color)<<8) - leftB) * tmpDiv); - leftTxStep = (s32)((v2->TCoords.X - leftTx) * tmpDiv); - leftTyStep = (s32)((v2->TCoords.Y - leftTy) * tmpDiv); - } - - - // do it twice, once for the first half of the triangle, - // end then for the second half. - - for (s32 triangleHalf=0; triangleHalf<2; ++triangleHalf) - { - if (spanEnd > ViewPortRect.LowerRightCorner.Y) - spanEnd = ViewPortRect.LowerRightCorner.Y; - - // if the span <0, than we can skip these spans, - // and proceed to the next spans which are really on the screen. - if (span < ViewPortRect.UpperLeftCorner.Y) - { - // we'll use leftx as temp variable - if (spanEnd < ViewPortRect.UpperLeftCorner.Y) - { - leftx = spanEnd - span; - span = spanEnd; - } - else - { - leftx = ViewPortRect.UpperLeftCorner.Y - span; - span = ViewPortRect.UpperLeftCorner.Y; - } - - leftxf += leftdeltaxf*leftx; - rightxf += rightdeltaxf*leftx; - targetSurface += SurfaceWidth*leftx; - zTarget += SurfaceWidth*leftx; - leftZValue += leftZStep*leftx; - rightZValue += rightZStep*leftx; - - leftR += leftStepR*leftx; - leftG += leftStepG*leftx; - leftB += leftStepB*leftx; - rightR += rightStepR*leftx; - rightG += rightStepG*leftx; - rightB += rightStepB*leftx; - - leftTx += leftTxStep*leftx; - leftTy += leftTyStep*leftx; - rightTx += rightTxStep*leftx; - rightTy += rightTyStep*leftx; - } - - - // the main loop. Go through every span and draw it. - - while (span < spanEnd) - { - leftx = (s32)(leftxf); - rightx = (s32)(rightxf + 0.5f); - - // perform some clipping - // thanks to a correction by hybrid - // calculations delayed to correctly propagate to textures etc. - s32 tDiffLeft=0, tDiffRight=0; - if (leftx<ViewPortRect.UpperLeftCorner.X) - tDiffLeft=ViewPortRect.UpperLeftCorner.X-leftx; - else - if (leftx>ViewPortRect.LowerRightCorner.X) - tDiffLeft=ViewPortRect.LowerRightCorner.X-leftx; - - if (rightx<ViewPortRect.UpperLeftCorner.X) - tDiffRight=ViewPortRect.UpperLeftCorner.X-rightx; - else - if (rightx>ViewPortRect.LowerRightCorner.X) - tDiffRight=ViewPortRect.LowerRightCorner.X-rightx; - - // draw the span - if (rightx + tDiffRight - leftx - tDiffLeft) - { - tmpDiv = 1.0f / (f32)(rightx - leftx); - spanZStep = (s32)((rightZValue - leftZValue) * tmpDiv); - spanZValue = leftZValue+tDiffLeft*spanZStep; - - spanStepR = (s32)((rightR - leftR) * tmpDiv); - spanR = leftR+tDiffLeft*spanStepR; - spanStepG = (s32)((rightG - leftG) * tmpDiv); - spanG = leftG+tDiffLeft*spanStepG; - spanStepB = (s32)((rightB - leftB) * tmpDiv); - spanB = leftB+tDiffLeft*spanStepB; - - spanTxStep = (s32)((rightTx - leftTx) * tmpDiv); - spanTx = leftTx + tDiffLeft*spanTxStep; - spanTyStep = (s32)((rightTy - leftTy) * tmpDiv); - spanTy = leftTy+tDiffLeft*spanTyStep; - - hSpanBegin = targetSurface + leftx+tDiffLeft; - spanZTarget = zTarget + leftx+tDiffLeft; - hSpanEnd = targetSurface + rightx+tDiffRight; - - while (hSpanBegin < hSpanEnd) - { - if (spanZValue > *spanZTarget) - { - *spanZTarget = spanZValue; - u16 color = lockedTexture[((spanTy>>8)&textureYMask) * lockedTextureWidth + ((spanTx>>8)&textureXMask)]; - *hSpanBegin = video::RGB16(video::getRed(color) * (spanR>>8) >>2, - video::getGreen(color) * (spanG>>8) >>2, - video::getBlue(color) * (spanB>>8) >>2); - } - - spanR += spanStepR; - spanG += spanStepG; - spanB += spanStepB; - - spanTx += spanTxStep; - spanTy += spanTyStep; - - spanZValue += spanZStep; - ++hSpanBegin; - ++spanZTarget; - } - } - - leftxf += leftdeltaxf; - rightxf += rightdeltaxf; - ++span; - targetSurface += SurfaceWidth; - zTarget += SurfaceWidth; - leftZValue += leftZStep; - rightZValue += rightZStep; - - leftR += leftStepR; - leftG += leftStepG; - leftB += leftStepB; - rightR += rightStepR; - rightG += rightStepG; - rightB += rightStepB; - - leftTx += leftTxStep; - leftTy += leftTyStep; - rightTx += rightTxStep; - rightTy += rightTyStep; - } - - if (triangleHalf>0) // break, we've gout only two halves - break; - - - // setup variables for second half of the triangle. - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - rightdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - rightxf = (f32)v2->Pos.X; - - rightZValue = v2->ZValue; - rightZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); - - rightR = video::getRed(v2->Color)<<8; - rightG = video::getGreen(v2->Color)<<8; - rightB = video::getBlue(v2->Color)<<8; - rightStepR = (s32)(((s32)(video::getRed(v3->Color)<<8) - rightR) * tmpDiv); - rightStepG = (s32)(((s32)(video::getGreen(v3->Color)<<8) - rightG) * tmpDiv); - rightStepB = (s32)(((s32)(video::getBlue(v3->Color)<<8) - rightB) * tmpDiv); - - rightTx = v2->TCoords.X; - rightTy = v2->TCoords.Y; - rightTxStep = (s32)((v3->TCoords.X - rightTx) * tmpDiv); - rightTyStep = (s32)((v3->TCoords.Y - rightTy) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - leftdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - leftxf = (f32)v2->Pos.X; - - leftZValue = v2->ZValue; - leftZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); - - leftR = video::getRed(v2->Color)<<8; - leftG = video::getGreen(v2->Color)<<8; - leftB = video::getBlue(v2->Color)<<8; - leftStepR = (s32)(((s32)(video::getRed(v3->Color)<<8) - leftR) * tmpDiv); - leftStepG = (s32)(((s32)(video::getGreen(v3->Color)<<8) - leftG) * tmpDiv); - leftStepB = (s32)(((s32)(video::getBlue(v3->Color)<<8) - leftB) * tmpDiv); - - leftTx = v2->TCoords.X; - leftTy = v2->TCoords.Y; - leftTxStep = (s32)((v3->TCoords.X - leftTx) * tmpDiv); - leftTyStep = (s32)((v3->TCoords.Y - leftTy) * tmpDiv); - } - - - spanEnd = v3->Pos.Y; - } - - } - - RenderTarget->unlock(); - ZBuffer->unlock(); - Texture->unlock(); -} - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -ITriangleRenderer* createTriangleRendererTextureGouraud(IZBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_SOFTWARE_ - return new CTRTextureGouraud(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_SOFTWARE_ -} - - -} // end namespace video -} // end namespace irr - - diff --git a/irrlicht-1.6/source/Irrlicht/CTRTextureGouraud.h b/irrlicht-1.6/source/Irrlicht/CTRTextureGouraud.h deleted file mode 100644 index 443f16c62..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTRTextureGouraud.h +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_TRIANGLE_RENDERER_TEXTURE_GOURAUD_H_INCLUDED__ -#define __C_TRIANGLE_RENDERER_TEXTURE_GOURAUD_H_INCLUDED__ - -#include "IrrCompileConfig.h" - -#ifndef _IRR_COMPILE_WITH_SOFTWARE_ -// forward declarations for create methods -namespace irr -{ -namespace video -{ - class ITriangleRenderer; - class IZBuffer; -} // end namespace video -} // end namespace irr - -#else - -#include "ITriangleRenderer.h" -#include "IImage.h" - -namespace irr -{ -namespace video -{ - //! CTRTextureGouraud class - class CTRTextureGouraud : public ITriangleRenderer - { - public: - - //! constructor - CTRTextureGouraud(IZBuffer* zbuffer); - - //! destructor - virtual ~CTRTextureGouraud(); - - //! sets a render target - virtual void setRenderTarget(video::IImage* surface, const core::rect<s32>& viewPort); - - //! draws an indexed triangle list - virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount); - - //! en or disables the backface culling - virtual void setBackfaceCulling(bool enabled = true); - - //! sets the Texture - virtual void setTexture(video::IImage* texture); - - protected: - - //! vertauscht zwei vertizen - inline void swapVertices(const S2DVertex** v1, const S2DVertex** v2) - { - const S2DVertex* b = *v1; - *v1 = *v2; - *v2 = b; - } - - video::IImage* RenderTarget; - core::rect<s32> ViewPortRect; - - IZBuffer* ZBuffer; - - s32 SurfaceWidth; - s32 SurfaceHeight; - bool BackFaceCullingEnabled; - TZBufferType* lockedZBuffer; - u16* lockedSurface; - u16* lockedTexture; - s32 lockedTextureWidth; - s32 textureXMask, textureYMask; - video::IImage* Texture; - }; - -} // end namespace video -} // end namespace irr - -#endif - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CTRTextureGouraud2.cpp b/irrlicht-1.6/source/Irrlicht/CTRTextureGouraud2.cpp deleted file mode 100644 index 5bf845560..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTRTextureGouraud2.cpp +++ /dev/null @@ -1,674 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "IBurningShader.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -// compile flag for this file -#undef USE_ZBUFFER -#undef IPOL_Z -#undef CMP_Z -#undef WRITE_Z - -#undef IPOL_W -#undef CMP_W -#undef WRITE_W - -#undef SUBTEXEL -#undef INVERSE_W - -#undef IPOL_C0 -#undef IPOL_T0 -#undef IPOL_T1 - -// define render case -#define SUBTEXEL -#define INVERSE_W - -#define USE_ZBUFFER -#define IPOL_W -#define CMP_W -#define WRITE_W - -#define IPOL_C0 -#define IPOL_T0 -//#define IPOL_T1 - -// apply global override -#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef INVERSE_W -#endif - -#ifndef SOFTWARE_DRIVER_2_SUBTEXEL - #undef SUBTEXEL -#endif - -#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #undef IPOL_C0 -#endif - -#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) - #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef IPOL_W - #endif - #define IPOL_Z - - #ifdef CMP_W - #undef CMP_W - #define CMP_Z - #endif - - #ifdef WRITE_W - #undef WRITE_W - #define WRITE_Z - #endif - -#endif - - -namespace irr -{ - -namespace video -{ - -class CTRTextureGouraud2 : public IBurningShader -{ -public: - - //! constructor - CTRTextureGouraud2(IDepthBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - - -private: - void scanline_bilinear (); - sScanConvertData scan; - sScanLineData line; - -}; - -//! constructor -CTRTextureGouraud2::CTRTextureGouraud2(IDepthBuffer* zbuffer) -: IBurningShader(zbuffer) -{ - #ifdef _DEBUG - setDebugName("CTRTextureGouraud2"); - #endif -} - - - -/*! -*/ -void CTRTextureGouraud2::scanline_bilinear () -{ - tVideoSample *dst; - -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC; -#endif -#ifdef IPOL_T0 - sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES]; -#endif - - // apply top-left fill-convention, left - xStart = core::ceil32( line.x[0] ); - xEnd = core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC = (line.c[0][1] - line.c[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC * subPixel; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0] * subPixel; -#endif -#ifdef IPOL_T1 - line.t[1][0] += slopeT[1] * subPixel; -#endif -#endif - - dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; - -#ifdef USE_ZBUFFER - z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; -#endif - - -#ifdef INVERSE_W - f32 inversew; -#endif - - tFixPoint tx0; - tFixPoint ty0; - - tFixPoint r0, g0, b0; - -#ifdef IPOL_C0 - tFixPoint r1, g1, b1; -#endif - -#ifdef BURNINGVIDEO_RENDERER_FAST - u32 dIndex = ( line.y & 3 ) << 2; -#endif - - for ( s32 i = 0; i <= dx; ++i ) - { -#ifdef CMP_Z - if ( line.z[0] < z[i] ) -#endif -#ifdef CMP_W - if ( line.w[0] >= z[i] ) -#endif - { -#ifdef WRITE_Z - z[i] = line.z[0]; -#endif -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - - -#ifdef INVERSE_W - inversew = fix_inverse32 ( line.w[0] ); - tx0 = tofix ( line.t[0][0].x, inversew); - ty0 = tofix ( line.t[0][0].y, inversew); - -#ifdef IPOL_C0 - r1 = tofix ( line.c[0][0].y ,inversew ); - g1 = tofix ( line.c[0][0].z ,inversew ); - b1 = tofix ( line.c[0][0].w ,inversew ); -#endif - -#else - tx0 = tofix ( line.t[0][0].x ); - ty0 = tofix ( line.t[0][0].y ); -#ifdef IPOL_C0 - getTexel_plain2 ( r1, g1, b1, line.c[0][0] ); -#endif -#endif - -#ifdef IPOL_C0 - getSample_texture ( r0, g0, b0, &IT[0], tx0,ty0 ); - - dst[i] = fix_to_color ( imulFix ( r0, r1 ), - imulFix ( g0, g1 ), - imulFix ( b0, b1 ) - ); -#else - -#ifdef BURNINGVIDEO_RENDERER_FAST - const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ]; - dst[i] = getTexel_plain ( &IT[0], d + tx0, d + ty0 ); -#else - getSample_texture ( r0, g0, b0, &IT[0], tx0,ty0 ); - dst[i] = fix_to_color ( r0, g0, b0 ); -#endif - -#endif - - } - -#ifdef IPOL_Z - line.z[0] += slopeZ; -#endif -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0]; -#endif -#ifdef IPOL_T1 - line.t[1][0] += slopeT[1]; -#endif - } - -} - -void CTRTextureGouraud2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - // sort on height, y - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - - const f32 ca = c->Pos.y - a->Pos.y; - const f32 ba = b->Pos.y - a->Pos.y; - const f32 cb = c->Pos.y - b->Pos.y; - // calculate delta y of the edges - scan.invDeltaY[0] = core::reciprocal( ca ); - scan.invDeltaY[1] = core::reciprocal( ba ); - scan.invDeltaY[2] = core::reciprocal( cb ); - - if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) - return; - - // find if the major edge is left or right aligned - f32 temp[4]; - - temp[0] = a->Pos.x - c->Pos.x; - temp[1] = -ca; - temp[2] = b->Pos.x - a->Pos.x; - temp[3] = ba; - - scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1; - scan.right = 1 - scan.left; - - // calculate slopes for the major edge - scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; - scan.x[0] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; - scan.z[0] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; - scan.w[0] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0][0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; - scan.c[0][0] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; - scan.t[0][0] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; - scan.t[1][0] = a->Tex[1]; -#endif - - // top left fill convention y run - s32 yStart; - s32 yEnd; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - - // rasterize upper sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[1] ) - { - // calculate slopes for top edge - scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; - scan.x[1] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; - scan.z[1] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; - scan.w[1] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0][1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; - scan.c[0][1] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; - scan.t[0][1] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; - scan.t[1][1] = a->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = core::ceil32( a->Pos.y ); - yEnd = core::ceil32( b->Pos.y ) - 1; - -#ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - a->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0] * subPixel; - scan.c[0][1] += scan.slopeC[0][1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0] * subPixel; - scan.t[0][1] += scan.slopeT[0][1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0] * subPixel; - scan.t[1][1] += scan.slopeT[1][1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[0][scan.left] = scan.c[0][0]; - line.c[0][scan.right] = scan.c[0][1]; -#endif - -#ifdef IPOL_T0 - line.t[0][scan.left] = scan.t[0][0]; - line.t[0][scan.right] = scan.t[0][1]; -#endif - -#ifdef IPOL_T1 - line.t[1][scan.left] = scan.t[1][0]; - line.t[1][scan.right] = scan.t[1][1]; -#endif - - // render a scanline - scanline_bilinear (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0]; - scan.c[0][1] += scan.slopeC[0][1]; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0]; - scan.t[0][1] += scan.slopeT[0][1]; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0]; - scan.t[1][1] += scan.slopeT[1][1]; -#endif - - } - } - - // rasterize lower sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[2] ) - { - // advance to middle point - if( (f32) 0.0 != scan.invDeltaY[1] ) - { - temp[0] = b->Pos.y - a->Pos.y; // dy - - scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; -#ifdef IPOL_Z - scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; -#endif -#ifdef IPOL_W - scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; -#endif -#ifdef IPOL_C0 - scan.c[0][0] = a->Color[0] + scan.slopeC[0][0] * temp[0]; -#endif -#ifdef IPOL_T0 - scan.t[0][0] = a->Tex[0] + scan.slopeT[0][0] * temp[0]; -#endif -#ifdef IPOL_T1 - scan.t[1][0] = a->Tex[1] + scan.slopeT[1][0] * temp[0]; -#endif - - } - - // calculate slopes for bottom edge - scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; - scan.x[1] = b->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; - scan.z[1] = b->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; - scan.w[1] = b->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0][1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; - scan.c[0][1] = b->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; - scan.t[0][1] = b->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; - scan.t[1][1] = b->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = core::ceil32( b->Pos.y ); - yEnd = core::ceil32( c->Pos.y ) - 1; - -#ifdef SUBTEXEL - - subPixel = ( (f32) yStart ) - b->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0] * subPixel; - scan.c[0][1] += scan.slopeC[0][1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0] * subPixel; - scan.t[0][1] += scan.slopeT[0][1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0] * subPixel; - scan.t[1][1] += scan.slopeT[1][1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[0][scan.left] = scan.c[0][0]; - line.c[0][scan.right] = scan.c[0][1]; -#endif - -#ifdef IPOL_T0 - line.t[0][scan.left] = scan.t[0][0]; - line.t[0][scan.right] = scan.t[0][1]; -#endif - -#ifdef IPOL_T1 - line.t[1][scan.left] = scan.t[1][0]; - line.t[1][scan.right] = scan.t[1][1]; -#endif - - // render a scanline - scanline_bilinear ( ); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0]; - scan.c[0][1] += scan.slopeC[0][1]; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0]; - scan.t[0][1] += scan.slopeT[0][1]; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0]; - scan.t[1][1] += scan.slopeT[1][1]; -#endif - - } - } - -} - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -IBurningShader* createTriangleRendererTextureGouraud2(IDepthBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CTRTextureGouraud2(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - -} // end namespace video -} // end namespace irr - - - diff --git a/irrlicht-1.6/source/Irrlicht/CTRTextureGouraudAdd.cpp b/irrlicht-1.6/source/Irrlicht/CTRTextureGouraudAdd.cpp deleted file mode 100644 index 6b373afa1..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTRTextureGouraudAdd.cpp +++ /dev/null @@ -1,419 +0,0 @@ -// Copyright (C) 2002-2009 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" -#include "CTRTextureGouraud.h" - -#ifdef _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -class CTRTextureGouraudAdd : public CTRTextureGouraud -{ -public: - - //! constructor - CTRTextureGouraudAdd(IZBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount); - -protected: - -}; - -//! constructor -CTRTextureGouraudAdd::CTRTextureGouraudAdd(IZBuffer* zbuffer) -: CTRTextureGouraud(zbuffer) -{ - #ifdef _DEBUG - setDebugName("CTRTextureGouraudAdd"); - #endif -} - - -//! draws an indexed triangle list -void CTRTextureGouraudAdd::drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount) -{ - const S2DVertex *v1, *v2, *v3; - - u16 color; - f32 tmpDiv; // temporary division factor - f32 longest; // saves the longest span - s32 height; // saves height of triangle - u16* targetSurface; // target pointer where to plot pixels - s32 spanEnd; // saves end of spans - f32 leftdeltaxf; // amount of pixels to increase on left side of triangle - f32 rightdeltaxf; // amount of pixels to increase on right side of triangle - s32 leftx, rightx; // position where we are - f32 leftxf, rightxf; // same as above, but as f32 values - s32 span; // current span - u16 *hSpanBegin, *hSpanEnd; // pointer used when plotting pixels - s32 leftR, leftG, leftB, rightR, rightG, rightB; // color values - s32 leftStepR, leftStepG, leftStepB, - rightStepR, rightStepG, rightStepB; // color steps - s32 spanR, spanG, spanB, spanStepR, spanStepG, spanStepB; // color interpolating values while drawing a span. - s32 leftTx, rightTx, leftTy, rightTy; // texture interpolating values - s32 leftTxStep, rightTxStep, leftTyStep, rightTyStep; // texture interpolating values - s32 spanTx, spanTy, spanTxStep, spanTyStep; // values of Texturecoords when drawing a span - core::rect<s32> TriangleRect; - - s32 leftZValue, rightZValue; - s32 leftZStep, rightZStep; - s32 spanZValue, spanZStep; // ZValues when drawing a span - TZBufferType* zTarget, *spanZTarget; // target of ZBuffer; - - lockedSurface = (u16*)RenderTarget->lock(); - lockedZBuffer = ZBuffer->lock(); - lockedTexture = (u16*)Texture->lock(); - - for (s32 i=0; i<triangleCount; ++i) - { - v1 = &vertices[*indexList]; - ++indexList; - v2 = &vertices[*indexList]; - ++indexList; - v3 = &vertices[*indexList]; - ++indexList; - - // back face culling - - if (BackFaceCullingEnabled) - { - s32 z = ((v3->Pos.X - v1->Pos.X) * (v3->Pos.Y - v2->Pos.Y)) - - ((v3->Pos.Y - v1->Pos.Y) * (v3->Pos.X - v2->Pos.X)); - - if (z < 0) - continue; - } - - //near plane clipping - - if (v1->ZValue<0 && v2->ZValue<0 && v3->ZValue<0) - continue; - - // sort for width for inscreen clipping - - if (v1->Pos.X > v2->Pos.X) swapVertices(&v1, &v2); - if (v1->Pos.X > v3->Pos.X) swapVertices(&v1, &v3); - if (v2->Pos.X > v3->Pos.X) swapVertices(&v2, &v3); - - if ((v1->Pos.X - v3->Pos.X) == 0) - continue; - - TriangleRect.UpperLeftCorner.X = v1->Pos.X; - TriangleRect.LowerRightCorner.X = v3->Pos.X; - - // sort for height for faster drawing. - - if (v1->Pos.Y > v2->Pos.Y) swapVertices(&v1, &v2); - if (v1->Pos.Y > v3->Pos.Y) swapVertices(&v1, &v3); - if (v2->Pos.Y > v3->Pos.Y) swapVertices(&v2, &v3); - - TriangleRect.UpperLeftCorner.Y = v1->Pos.Y; - TriangleRect.LowerRightCorner.Y = v3->Pos.Y; - - if (!TriangleRect.isRectCollided(ViewPortRect)) - continue; - - // calculate height of triangle - height = v3->Pos.Y - v1->Pos.Y; - if (!height) - continue; - - // calculate longest span - - longest = (v2->Pos.Y - v1->Pos.Y) / (f32)height * (v3->Pos.X - v1->Pos.X) + (v1->Pos.X - v2->Pos.X); - - spanEnd = v2->Pos.Y; - span = v1->Pos.Y; - leftxf = (f32)v1->Pos.X; - rightxf = (f32)v1->Pos.X; - - leftZValue = v1->ZValue; - rightZValue = v1->ZValue; - - leftR = rightR = video::getRed(v1->Color)<<8; - leftG = rightG = video::getGreen(v1->Color)<<8; - leftB = rightB = video::getBlue(v1->Color)<<8; - leftTx = rightTx = v1->TCoords.X; - leftTy = rightTy = v1->TCoords.Y; - - targetSurface = lockedSurface + span * SurfaceWidth; - zTarget = lockedZBuffer + span * SurfaceWidth; - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - rightdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - rightZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); - rightStepR = (s32)(((s32)(video::getRed(v2->Color)<<8) - rightR) * tmpDiv); - rightStepG = (s32)(((s32)(video::getGreen(v2->Color)<<8) - rightG) * tmpDiv); - rightStepB = (s32)(((s32)(video::getBlue(v2->Color)<<8) - rightB) * tmpDiv); - rightTxStep = (s32)((v2->TCoords.X - rightTx) * tmpDiv); - rightTyStep = (s32)((v2->TCoords.Y - rightTy) * tmpDiv); - - tmpDiv = 1.0f / (f32)height; - leftdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - leftZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); - leftStepR = (s32)(((s32)(video::getRed(v3->Color)<<8) - leftR) * tmpDiv); - leftStepG = (s32)(((s32)(video::getGreen(v3->Color)<<8) - leftG) * tmpDiv); - leftStepB = (s32)(((s32)(video::getBlue(v3->Color)<<8) - leftB) * tmpDiv); - leftTxStep = (s32)((v3->TCoords.X - leftTx) * tmpDiv); - leftTyStep = (s32)((v3->TCoords.Y - leftTy) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (f32)height; - rightdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - rightZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); - rightStepR = (s32)(((s32)(video::getRed(v3->Color)<<8) - rightR) * tmpDiv); - rightStepG = (s32)(((s32)(video::getGreen(v3->Color)<<8) - rightG) * tmpDiv); - rightStepB = (s32)(((s32)(video::getBlue(v3->Color)<<8) - rightB) * tmpDiv); - rightTxStep = (s32)((v3->TCoords.X - rightTx) * tmpDiv); - rightTyStep = (s32)((v3->TCoords.Y - rightTy) * tmpDiv); - - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - leftdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - leftZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); - leftStepR = (s32)(((s32)(video::getRed(v2->Color)<<8) - leftR) * tmpDiv); - leftStepG = (s32)(((s32)(video::getGreen(v2->Color)<<8) - leftG) * tmpDiv); - leftStepB = (s32)(((s32)(video::getBlue(v2->Color)<<8) - leftB) * tmpDiv); - leftTxStep = (s32)((v2->TCoords.X - leftTx) * tmpDiv); - leftTyStep = (s32)((v2->TCoords.Y - leftTy) * tmpDiv); - } - - - // do it twice, once for the first half of the triangle, - // end then for the second half. - - for (s32 triangleHalf=0; triangleHalf<2; ++triangleHalf) - { - if (spanEnd > ViewPortRect.LowerRightCorner.Y) - spanEnd = ViewPortRect.LowerRightCorner.Y; - - // if the span <0, than we can skip these spans, - // and proceed to the next spans which are really on the screen. - if (span < ViewPortRect.UpperLeftCorner.Y) - { - // we'll use leftx as temp variable - if (spanEnd < ViewPortRect.UpperLeftCorner.Y) - { - leftx = spanEnd - span; - span = spanEnd; - } - else - { - leftx = ViewPortRect.UpperLeftCorner.Y - span; - span = ViewPortRect.UpperLeftCorner.Y; - } - - leftxf += leftdeltaxf*leftx; - rightxf += rightdeltaxf*leftx; - targetSurface += SurfaceWidth*leftx; - zTarget += SurfaceWidth*leftx; - leftZValue += leftZStep*leftx; - rightZValue += rightZStep*leftx; - - leftR += leftStepR*leftx; - leftG += leftStepG*leftx; - leftB += leftStepB*leftx; - rightR += rightStepR*leftx; - rightG += rightStepG*leftx; - rightB += rightStepB*leftx; - - leftTx += leftTxStep*leftx; - leftTy += leftTyStep*leftx; - rightTx += rightTxStep*leftx; - rightTy += rightTyStep*leftx; - } - - - // the main loop. Go through every span and draw it. - - while (span < spanEnd) - { - leftx = (s32)(leftxf); - rightx = (s32)(rightxf + 0.5f); - - // perform some clipping - // thanks to a correction by hybrid - // calculations delayed to correctly propagate to textures etc. - s32 tDiffLeft=0, tDiffRight=0; - if (leftx<ViewPortRect.UpperLeftCorner.X) - tDiffLeft=ViewPortRect.UpperLeftCorner.X-leftx; - else - if (leftx>ViewPortRect.LowerRightCorner.X) - tDiffLeft=ViewPortRect.LowerRightCorner.X-leftx; - - if (rightx<ViewPortRect.UpperLeftCorner.X) - tDiffRight=ViewPortRect.UpperLeftCorner.X-rightx; - else - if (rightx>ViewPortRect.LowerRightCorner.X) - tDiffRight=ViewPortRect.LowerRightCorner.X-rightx; - - // draw the span - if (rightx + tDiffRight - leftx - tDiffLeft) - { - tmpDiv = 1.0f / (f32)(rightx - leftx); - spanZStep = (s32)((rightZValue - leftZValue) * tmpDiv); - spanZValue = leftZValue+tDiffLeft*spanZStep; - - spanStepR = (s32)((rightR - leftR) * tmpDiv); - spanR = leftR+tDiffLeft*spanStepR; - spanStepG = (s32)((rightG - leftG) * tmpDiv); - spanG = leftG+tDiffLeft*spanStepG; - spanStepB = (s32)((rightB - leftB) * tmpDiv); - spanB = leftB+tDiffLeft*spanStepB; - - spanTxStep = (s32)((rightTx - leftTx) * tmpDiv); - spanTx = leftTx + tDiffLeft*spanTxStep; - spanTyStep = (s32)((rightTy - leftTy) * tmpDiv); - spanTy = leftTy+tDiffLeft*spanTyStep; - - hSpanBegin = targetSurface + leftx+tDiffLeft; - spanZTarget = zTarget + leftx+tDiffLeft; - hSpanEnd = targetSurface + rightx+tDiffRight; - - while (hSpanBegin < hSpanEnd) - { - if (spanZValue > *spanZTarget) - { - //*spanZTarget = spanZValue; - color = lockedTexture[((spanTy>>8)&textureYMask) * lockedTextureWidth + ((spanTx>>8)&textureXMask)]; - - s32 basis = *hSpanBegin; - s32 r = (video::getRed(basis)<<3) + (video::getRed(color)<<3); - if (r > 255) r = 255; - s32 g = (video::getGreen(basis)<<3) + (video::getGreen(color)<<3); - if (g > 255) g = 255; - s32 b = (video::getBlue(basis)<<3) + (video::getBlue(color)<<3); - if (b > 255) b = 255; - - *hSpanBegin = video::RGB16(r, g, b); - } - - spanR += spanStepR; - spanG += spanStepG; - spanB += spanStepB; - - spanTx += spanTxStep; - spanTy += spanTyStep; - - spanZValue += spanZStep; - ++hSpanBegin; - ++spanZTarget; - } - } - - leftxf += leftdeltaxf; - rightxf += rightdeltaxf; - ++span; - targetSurface += SurfaceWidth; - zTarget += SurfaceWidth; - leftZValue += leftZStep; - rightZValue += rightZStep; - - leftR += leftStepR; - leftG += leftStepG; - leftB += leftStepB; - rightR += rightStepR; - rightG += rightStepG; - rightB += rightStepB; - - leftTx += leftTxStep; - leftTy += leftTyStep; - rightTx += rightTxStep; - rightTy += rightTyStep; - } - - if (triangleHalf>0) // break, we've gout only two halves - break; - - - // setup variables for second half of the triangle. - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - rightdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - rightxf = (f32)v2->Pos.X; - - rightZValue = v2->ZValue; - rightZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); - - rightR = video::getRed(v2->Color)<<8; - rightG = video::getGreen(v2->Color)<<8; - rightB = video::getBlue(v2->Color)<<8; - rightStepR = (s32)(((s32)(video::getRed(v3->Color)<<8) - rightR) * tmpDiv); - rightStepG = (s32)(((s32)(video::getGreen(v3->Color)<<8) - rightG) * tmpDiv); - rightStepB = (s32)(((s32)(video::getBlue(v3->Color)<<8) - rightB) * tmpDiv); - - rightTx = v2->TCoords.X; - rightTy = v2->TCoords.Y; - rightTxStep = (s32)((v3->TCoords.X - rightTx) * tmpDiv); - rightTyStep = (s32)((v3->TCoords.Y - rightTy) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - leftdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - leftxf = (f32)v2->Pos.X; - - leftZValue = v2->ZValue; - leftZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); - - leftR = video::getRed(v2->Color)<<8; - leftG = video::getGreen(v2->Color)<<8; - leftB = video::getBlue(v2->Color)<<8; - leftStepR = (s32)(((s32)(video::getRed(v3->Color)<<8) - leftR) * tmpDiv); - leftStepG = (s32)(((s32)(video::getGreen(v3->Color)<<8) - leftG) * tmpDiv); - leftStepB = (s32)(((s32)(video::getBlue(v3->Color)<<8) - leftB) * tmpDiv); - - leftTx = v2->TCoords.X; - leftTy = v2->TCoords.Y; - leftTxStep = (s32)((v3->TCoords.X - leftTx) * tmpDiv); - leftTyStep = (s32)((v3->TCoords.Y - leftTy) * tmpDiv); - } - - - spanEnd = v3->Pos.Y; - } - - } - - RenderTarget->unlock(); - ZBuffer->unlock(); - Texture->unlock(); -} - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -ITriangleRenderer* createTriangleRendererTextureGouraudAdd(IZBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_SOFTWARE_ - return new CTRTextureGouraudAdd(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_SOFTWARE_ -} - -} // end namespace video -} // end namespace irr - - - diff --git a/irrlicht-1.6/source/Irrlicht/CTRTextureGouraudAdd2.cpp b/irrlicht-1.6/source/Irrlicht/CTRTextureGouraudAdd2.cpp deleted file mode 100644 index 0ec81e8b7..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTRTextureGouraudAdd2.cpp +++ /dev/null @@ -1,680 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "IBurningShader.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -// compile flag for this file -#undef USE_ZBUFFER -#undef IPOL_Z -#undef CMP_Z -#undef WRITE_Z - -#undef IPOL_W -#undef CMP_W -#undef WRITE_W - -#undef SUBTEXEL -#undef INVERSE_W - -#undef IPOL_C0 -#undef IPOL_T0 -#undef IPOL_T1 - -// define render case -#define SUBTEXEL -#define INVERSE_W - -#define USE_ZBUFFER -#define IPOL_W -#define CMP_W -#define WRITE_W - -//#define IPOL_C0 -#define IPOL_T0 -//#define IPOL_T1 - -// apply global override -#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef INVERSE_W -#endif - -#ifndef SOFTWARE_DRIVER_2_SUBTEXEL - #undef SUBTEXEL -#endif - -#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #undef IPOL_C0 -#endif - -#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) - #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef IPOL_W - #endif - #define IPOL_Z - - #ifdef CMP_W - #undef CMP_W - #define CMP_Z - #endif - - #ifdef WRITE_W - #undef WRITE_W - #define WRITE_Z - #endif - -#endif - - - -namespace irr -{ - -namespace video -{ - -class CTRTextureGouraudAdd2 : public IBurningShader -{ -public: - - //! constructor - CTRTextureGouraudAdd2(IDepthBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - - -private: - void scanline_bilinear (); - sScanLineData line; - -}; - -//! constructor -CTRTextureGouraudAdd2::CTRTextureGouraudAdd2(IDepthBuffer* zbuffer) -: IBurningShader(zbuffer) -{ - #ifdef _DEBUG - setDebugName("CTRTextureGouraudAdd2"); - #endif -} - - - -/*! -*/ -void CTRTextureGouraudAdd2::scanline_bilinear () -{ - tVideoSample *dst; - -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC; -#endif -#ifdef IPOL_T0 - sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES]; -#endif - - // apply top-left fill-convention, left - xStart = core::ceil32( line.x[0] ); - xEnd = core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC = (line.c[1] - line.c[0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC * subPixel; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0] * subPixel; -#endif -#ifdef IPOL_T1 - line.t[1][0] += slopeT[1] * subPixel; -#endif -#endif - - dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; - -#ifdef USE_ZBUFFER - z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; -#endif - - -#ifdef INVERSE_W - f32 inversew; -#endif - - -#ifdef BURNINGVIDEO_RENDERER_FAST - u32 dIndex = ( line.y & 3 ) << 2; - -#else - tFixPoint tx0; - tFixPoint ty0; - - tFixPoint r0, g0, b0; - tFixPoint r1, g1, b1; -#endif - - - for ( s32 i = 0; i <= dx; ++i ) - { -#ifdef CMP_Z - if ( line.z[0] < z[i] ) -#endif -#ifdef CMP_W - if ( line.w[0] >= z[i] ) -#endif - - { - - -#ifdef BURNINGVIDEO_RENDERER_FAST - - const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ]; - - -#ifdef INVERSE_W - inversew = fix_inverse32 ( line.w[0] ); - - dst[i] = PixelAdd32 ( - dst[i], - getTexel_plain ( &IT[0], d + tofix ( line.t[0][0].x,inversew), - d + tofix ( line.t[0][0].y,inversew) ) - ); -#else - dst[i] = PixelAdd32 ( - dst[i], - getTexel_plain ( &IT[0], d + tofix ( line.t[0][0].x), - d + tofix ( line.t[0][0].y) ) - ); - -#endif -#else - -#ifdef INVERSE_W - inversew = fix_inverse32 ( line.w[0] ); - - tx0 = tofix ( line.t[0][0].x,inversew); - ty0 = tofix ( line.t[0][0].y,inversew); -#else - tx0 = tofix ( line.t[0][0].x ); - ty0 = tofix ( line.t[0][0].y ); -#endif - getSample_texture ( r0, g0, b0, &IT[0], tx0,ty0 ); - - color_to_fix ( r1, g1, b1, dst[i] ); - - dst[i] = fix_to_color ( clampfix_maxcolor ( r1 + r0 ), - clampfix_maxcolor ( g1 + g0 ), - clampfix_maxcolor ( b1 + b0 ) - ); -#endif - -#ifdef WRITE_Z - z[i] = line.z[0]; -#endif -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - - } - -#ifdef IPOL_Z - line.z[0] += slopeZ; -#endif -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0]; -#endif -#ifdef IPOL_T1 - line.t[1][0] += slopeT[1]; -#endif - } - -} - -void CTRTextureGouraudAdd2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - sScanConvertData scan; - - // sort on height, y - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - - const f32 ca = c->Pos.y - a->Pos.y; - const f32 ba = b->Pos.y - a->Pos.y; - const f32 cb = c->Pos.y - b->Pos.y; - // calculate delta y of the edges - scan.invDeltaY[0] = core::reciprocal( ca ); - scan.invDeltaY[1] = core::reciprocal( ba ); - scan.invDeltaY[2] = core::reciprocal( cb ); - - // find if the major edge is left or right aligned - f32 temp[4]; - - temp[0] = a->Pos.x - c->Pos.x; - temp[1] = -ca; - temp[2] = b->Pos.x - a->Pos.x; - temp[3] = ba; - - scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1; - scan.right = 1 - scan.left; - - // calculate slopes for the major edge - scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; - scan.x[0] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; - scan.z[0] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; - scan.w[0] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; - scan.c[0] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; - scan.t[0][0] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; - scan.t[1][0] = a->Tex[1]; -#endif - - // top left fill convention y run - s32 yStart; - s32 yEnd; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - - // rasterize upper sub-triangle - if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) - { - // calculate slopes for top edge - scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; - scan.x[1] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; - scan.z[1] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; - scan.w[1] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; - scan.c[1] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; - scan.t[0][1] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; - scan.t[1][1] = a->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = core::ceil32( a->Pos.y ); - yEnd = core::ceil32( b->Pos.y ) - 1; - -#ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - a->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0] * subPixel; - scan.t[0][1] += scan.slopeT[0][1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0] * subPixel; - scan.t[1][1] += scan.slopeT[1][1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t[0][scan.left] = scan.t[0][0]; - line.t[0][scan.right] = scan.t[0][1]; -#endif - -#ifdef IPOL_T1 - line.t[1][scan.left] = scan.t[1][0]; - line.t[1][scan.right] = scan.t[1][1]; -#endif - - // render a scanline - scanline_bilinear (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0]; - scan.t[0][1] += scan.slopeT[0][1]; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0]; - scan.t[1][1] += scan.slopeT[1][1]; -#endif - - } - } - - // rasterize lower sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[2] ) - { - // advance to middle point - if( (f32) 0.0 != scan.invDeltaY[1] ) - { - temp[0] = b->Pos.y - a->Pos.y; // dy - - scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; -#ifdef IPOL_Z - scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; -#endif -#ifdef IPOL_W - scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; -#endif -#ifdef IPOL_C0 - scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; -#endif -#ifdef IPOL_T0 - scan.t[0][0] = a->Tex[0] + scan.slopeT[0][0] * temp[0]; -#endif -#ifdef IPOL_T1 - scan.t[1][0] = a->Tex[1] + scan.slopeT[1][0] * temp[0]; -#endif - - } - - // calculate slopes for bottom edge - scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; - scan.x[1] = b->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; - scan.z[1] = b->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; - scan.w[1] = b->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; - scan.c[1] = b->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; - scan.t[0][1] = b->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; - scan.t[1][1] = b->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = core::ceil32( b->Pos.y ); - yEnd = core::ceil32( c->Pos.y ) - 1; - -#ifdef SUBTEXEL - - subPixel = ( (f32) yStart ) - b->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0] * subPixel; - scan.t[0][1] += scan.slopeT[0][1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0] * subPixel; - scan.t[1][1] += scan.slopeT[1][1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t[0][scan.left] = scan.t[0][0]; - line.t[0][scan.right] = scan.t[0][1]; -#endif - -#ifdef IPOL_T1 - line.t[1][scan.left] = scan.t[1][0]; - line.t[1][scan.right] = scan.t[1][1]; -#endif - - // render a scanline - scanline_bilinear (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0]; - scan.t[0][1] += scan.slopeT[0][1]; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0]; - scan.t[1][1] += scan.slopeT[1][1]; -#endif - - } - } - -} - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -IBurningShader* createTRTextureGouraudAdd2(IDepthBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CTRTextureGouraudAdd2(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - -} // end namespace video -} // end namespace irr - - - diff --git a/irrlicht-1.6/source/Irrlicht/CTRTextureGouraudAddNoZ2.cpp b/irrlicht-1.6/source/Irrlicht/CTRTextureGouraudAddNoZ2.cpp deleted file mode 100644 index 027706688..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTRTextureGouraudAddNoZ2.cpp +++ /dev/null @@ -1,649 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "IBurningShader.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -// compile flag for this file -#undef USE_ZBUFFER -#undef IPOL_Z -#undef CMP_Z -#undef WRITE_Z - -#undef IPOL_W -#undef CMP_W -#undef WRITE_W - -#undef SUBTEXEL -#undef INVERSE_W - -#undef IPOL_C0 -#undef IPOL_T0 -#undef IPOL_T1 - -// define render case -#define SUBTEXEL -#define INVERSE_W - -#define USE_ZBUFFER -#define IPOL_W -#define CMP_W -//#define WRITE_W - -//#define IPOL_C0 -#define IPOL_T0 -//#define IPOL_T1 - -// apply global override -#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef INVERSE_W - #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef IPOL_W - #endif -#endif - -#ifndef SOFTWARE_DRIVER_2_SUBTEXEL - #undef SUBTEXEL -#endif - -#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #undef IPOL_C0 -#endif - -#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) - #define IPOL_Z - - #ifdef CMP_W - #undef CMP_W - #define CMP_Z - #endif - - #ifdef WRITE_W - #undef WRITE_W - #define WRITE_Z - #endif - -#endif - - -namespace irr -{ - -namespace video -{ - -class CTRTextureGouraudAddNoZ2 : public IBurningShader -{ -public: - - //! constructor - CTRTextureGouraudAddNoZ2(IDepthBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - - -private: - void scanline_bilinear (); - sScanConvertData scan; - sScanLineData line; - -}; - -//! constructor -CTRTextureGouraudAddNoZ2::CTRTextureGouraudAddNoZ2(IDepthBuffer* zbuffer) -: IBurningShader(zbuffer) -{ - #ifdef _DEBUG - setDebugName("CTRTextureGouraudAddNoZ2"); - #endif -} - - - -/*! -*/ -void CTRTextureGouraudAddNoZ2::scanline_bilinear () -{ - tVideoSample *dst; - -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC; -#endif -#ifdef IPOL_T0 - sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES]; -#endif - - // apply top-left fill-convention, left - xStart = core::ceil32( line.x[0] ); - xEnd = core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC = (line.c[1] - line.c[0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC * subPixel; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0] * subPixel; -#endif -#ifdef IPOL_T1 - line.t[1][0] += slopeT[1] * subPixel; -#endif -#endif - - dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; - -#ifdef USE_ZBUFFER - z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; -#endif - - -#ifdef IPOL_W - f32 inversew; -#endif - - tFixPoint tx0; - tFixPoint ty0; - - tFixPoint r0, g0, b0; - tFixPoint r1, g1, b1; - tFixPoint r2, g2, b2; - - - for ( s32 i = 0; i <= dx; ++i ) - { -#ifdef CMP_Z - if ( line.z[0] < z[i] ) -#endif -#ifdef CMP_W - if ( line.w[0] >= z[i] ) -#endif - { -#ifdef IPOL_W - inversew = fix_inverse32 ( line.w[0] ); - - tx0 = tofix ( line.t[0][0].x,inversew); - ty0 = tofix ( line.t[0][0].y,inversew); -#else - tx0 = tofix ( line.t[0][0].x ); - ty0 = tofix ( line.t[0][0].y ); -#endif - - getSample_texture ( r0, g0, b0, &IT[0], tx0,ty0 ); - - color_to_fix ( r1, g1, b1, dst[i] ); - - r2 = clampfix_maxcolor ( r1 + r0 ); - g2 = clampfix_maxcolor ( g1 + g0 ); - b2 = clampfix_maxcolor ( b1 + b0 ); - - - dst[i] = fix_to_color ( r2, g2, b2 ); - -#ifdef WRITE_Z - z[i] = line.z[0]; -#endif -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - } - -#ifdef IPOL_Z - line.z[0] += slopeZ; -#endif -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0]; -#endif -#ifdef IPOL_T1 - line.t[1][0] += slopeT[1]; -#endif - } - -} - -void CTRTextureGouraudAddNoZ2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - // sort on height, y - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - - const f32 ca = c->Pos.y - a->Pos.y; - const f32 ba = b->Pos.y - a->Pos.y; - const f32 cb = c->Pos.y - b->Pos.y; - // calculate delta y of the edges - scan.invDeltaY[0] = core::reciprocal( ca ); - scan.invDeltaY[1] = core::reciprocal( ba ); - scan.invDeltaY[2] = core::reciprocal( cb ); - - if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) - return; - - // find if the major edge is left or right aligned - f32 temp[4]; - - temp[0] = a->Pos.x - c->Pos.x; - temp[1] = -ca; - temp[2] = b->Pos.x - a->Pos.x; - temp[3] = ba; - - scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1; - scan.right = 1 - scan.left; - - // calculate slopes for the major edge - scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; - scan.x[0] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; - scan.z[0] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; - scan.w[0] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; - scan.c[0] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; - scan.t[0][0] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; - scan.t[1][0] = a->Tex[1]; -#endif - - // top left fill convention y run - s32 yStart; - s32 yEnd; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - - // rasterize upper sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[1] ) - { - // calculate slopes for top edge - scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; - scan.x[1] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; - scan.z[1] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; - scan.w[1] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; - scan.c[1] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; - scan.t[0][1] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; - scan.t[1][1] = a->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = core::ceil32( a->Pos.y ); - yEnd = core::ceil32( b->Pos.y ) - 1; - -#ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - a->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0] * subPixel; - scan.t[0][1] += scan.slopeT[0][1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0] * subPixel; - scan.t[1][1] += scan.slopeT[1][1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t[0][scan.left] = scan.t[0][0]; - line.t[0][scan.right] = scan.t[0][1]; -#endif - -#ifdef IPOL_T1 - line.t[1][scan.left] = scan.t[1][0]; - line.t[1][scan.right] = scan.t[1][1]; -#endif - - // render a scanline - scanline_bilinear (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0]; - scan.t[0][1] += scan.slopeT[0][1]; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0]; - scan.t[1][1] += scan.slopeT[1][1]; -#endif - - } - } - - // rasterize lower sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[2] ) - { - // advance to middle point - if( (f32) 0.0 != scan.invDeltaY[1] ) - { - temp[0] = b->Pos.y - a->Pos.y; // dy - - scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; -#ifdef IPOL_Z - scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; -#endif -#ifdef IPOL_W - scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; -#endif -#ifdef IPOL_C0 - scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; -#endif -#ifdef IPOL_T0 - scan.t[0][0] = a->Tex[0] + scan.slopeT[0][0] * temp[0]; -#endif -#ifdef IPOL_T1 - scan.t[1][0] = a->Tex[1] + scan.slopeT[1][0] * temp[0]; -#endif - - } - - // calculate slopes for bottom edge - scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; - scan.x[1] = b->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; - scan.z[1] = b->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; - scan.w[1] = b->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; - scan.c[1] = b->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; - scan.t[0][1] = b->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; - scan.t[1][1] = b->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = core::ceil32( b->Pos.y ); - yEnd = core::ceil32( c->Pos.y ) - 1; - -#ifdef SUBTEXEL - - subPixel = ( (f32) yStart ) - b->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0] * subPixel; - scan.t[0][1] += scan.slopeT[0][1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0] * subPixel; - scan.t[1][1] += scan.slopeT[1][1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t[0][scan.left] = scan.t[0][0]; - line.t[0][scan.right] = scan.t[0][1]; -#endif - -#ifdef IPOL_T1 - line.t[1][scan.left] = scan.t[1][0]; - line.t[1][scan.right] = scan.t[1][1]; -#endif - - // render a scanline - scanline_bilinear ( ); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0]; - scan.t[0][1] += scan.slopeT[0][1]; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0]; - scan.t[1][1] += scan.slopeT[1][1]; -#endif - - } - } - -} - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -IBurningShader* createTRTextureGouraudAddNoZ2(IDepthBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CTRTextureGouraudAddNoZ2(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - -} // end namespace video -} // end namespace irr - - diff --git a/irrlicht-1.6/source/Irrlicht/CTRTextureGouraudAlpha.cpp b/irrlicht-1.6/source/Irrlicht/CTRTextureGouraudAlpha.cpp deleted file mode 100644 index 1e651f53d..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTRTextureGouraudAlpha.cpp +++ /dev/null @@ -1,744 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "IBurningShader.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -// compile flag for this file -#undef USE_ZBUFFER -#undef IPOL_Z -#undef CMP_Z -#undef WRITE_Z - -#undef IPOL_W -#undef CMP_W -#undef WRITE_W - -#undef SUBTEXEL -#undef INVERSE_W - -#undef IPOL_C0 -#undef IPOL_T0 -#undef IPOL_T1 - -// define render case -#define SUBTEXEL -#define INVERSE_W - -#define USE_ZBUFFER -#define IPOL_W -#define CMP_W -#define WRITE_W - -#define IPOL_C0 -#define IPOL_T0 -//#define IPOL_T1 - -// apply global override -#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef INVERSE_W -#endif - -#ifndef SOFTWARE_DRIVER_2_SUBTEXEL - #undef SUBTEXEL -#endif - -#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #undef IPOL_C0 -#endif - -#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) - #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef IPOL_W - #endif - #define IPOL_Z - - #ifdef CMP_W - #undef CMP_W - #define CMP_Z - #endif - - #ifdef WRITE_W - #undef WRITE_W - #define WRITE_Z - #endif - -#endif - - - -namespace irr -{ - -namespace video -{ - -class CTRTextureGouraudAlpha2 : public IBurningShader -{ -public: - - //! constructor - CTRTextureGouraudAlpha2(IDepthBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - - virtual void setParam ( u32 index, f32 value); - - -private: - void scanline_bilinear (); - - sScanConvertData scan; - sScanLineData line; - - u32 AlphaRef; -}; - -//! constructor -CTRTextureGouraudAlpha2::CTRTextureGouraudAlpha2(IDepthBuffer* zbuffer) -: IBurningShader(zbuffer) -{ - #ifdef _DEBUG - setDebugName("CTRTextureGouraudAlpha2"); - #endif - - AlphaRef = 0; -} - - -/*! -*/ -void CTRTextureGouraudAlpha2::setParam ( u32 index, f32 value) -{ -#ifdef BURNINGVIDEO_RENDERER_FAST - AlphaRef = core::floor32 ( value * 256.f ); -#else - AlphaRef = u32_to_fixPoint ( core::floor32 ( value * 256.f ) ); -#endif -} - -/*! -*/ -void CTRTextureGouraudAlpha2::scanline_bilinear () -{ - tVideoSample *dst; - -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC[MATERIAL_MAX_COLORS]; -#endif -#ifdef IPOL_T0 - sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES]; -#endif - - // apply top-left fill-convention, left - xStart = core::ceil32( line.x[0] ); - xEnd = core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC[0] = (line.c[0][1] - line.c[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC[0] * subPixel; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0] * subPixel; -#endif -#ifdef IPOL_T1 - line.t[1][0] += slopeT[1] * subPixel; -#endif -#endif - - dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; - -#ifdef USE_ZBUFFER - z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; -#endif - - -#ifdef INVERSE_W - f32 inversew; -#endif - -#ifdef BURNINGVIDEO_RENDERER_FAST - u32 dIndex = ( line.y & 3 ) << 2; - -#else - tFixPoint a0; - tFixPoint r0, g0, b0; -#endif - -#ifdef IPOL_C0 - tFixPoint r1, g1, b1; - tFixPoint r2, g2, b2; -#endif - - for ( s32 i = 0; i <= dx; ++i ) - { -#ifdef CMP_Z - if ( line.z[0] < z[i] ) -#endif -#ifdef CMP_W - if ( line.w[0] >= z[i] ) -#endif - - { - -#ifdef BURNINGVIDEO_RENDERER_FAST - - const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ]; - -#ifdef INVERSE_W - - inversew = fix_inverse32 ( line.w[0] ); - - u32 argb = getTexel_plain ( &IT[0], d + tofix ( line.t[0][0].x,inversew), - d + tofix ( line.t[0][0].y,inversew) - ); - -#else - - u32 argb = getTexel_plain ( &IT[0], d + tofix ( line.t[0][0].x), - d + tofix ( line.t[0][0].y) - ); - -#endif - - const u32 alpha = ( argb >> 24 ); - if ( alpha > AlphaRef ) - { -#ifdef WRITE_Z - z[i] = line.z[0]; -#endif -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - - dst[i] = PixelBlend32 ( dst[i], argb, alpha ); - } - - -#else - -#ifdef INVERSE_W - inversew = fix_inverse32 ( line.w[0] ); - getSample_texture ( (tFixPointu&) a0, (tFixPointu&) r0, (tFixPointu&)g0, (tFixPointu&)b0, - &IT[0], - tofix ( line.t[0][0].x,inversew), - tofix ( line.t[0][0].y,inversew) - ); -#else - getSample_texture ( (tFixPointu&) a0, (tFixPointu&) r0, (tFixPointu&)g0, (tFixPointu&)b0, - &IT[0], - tofix ( line.t[0][0].x), - tofix ( line.t[0][0].y) - ); -#endif - if ( (tFixPointu) a0 > AlphaRef ) - { -#ifdef WRITE_Z - z[i] = line.z[0]; -#endif -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - -#ifdef INVERSE_W - getSample_color ( r2, g2, b2, line.c[0][0], inversew ); -#else - getSample_color ( r2, g2, b2, line.c[0][0] ); -#endif - r0 = imulFix ( r0, r2 ); - g0 = imulFix ( g0, g2 ); - b0 = imulFix ( b0, b2 ); - - color_to_fix ( r1, g1, b1, dst[i] ); - - a0 >>= 8; - - r2 = r1 + imulFix ( a0, r0 - r1 ); - g2 = g1 + imulFix ( a0, g0 - g1 ); - b2 = b1 + imulFix ( a0, b0 - b1 ); - dst[i] = fix4_to_color ( a0, r2, g2, b2 ); - -/* - dst[i] = PixelBlend32 ( dst[i], - fix_to_color ( r0,g0, b0 ), - fixPointu_to_u32 ( a0 ) - ); -*/ -/* - getSample_color ( r2, g2, b2, line.c[0][0], inversew * COLOR_MAX ); - color_to_fix ( r1, g1, b1, dst[i] ); - - r2 = r0 + imulFix ( a0, r1 - r0 ); - g2 = g0 + imulFix ( a0, g1 - g0 ); - b2 = b0 + imulFix ( a0, b1 - b0 ); - dst[i] = fix_to_color ( r2, g2, b2 ); -*/ - - } -#endif - - } - -#ifdef IPOL_Z - line.z[0] += slopeZ; -#endif -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC[0]; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0]; -#endif -#ifdef IPOL_T1 - line.t[1][0] += slopeT[1]; -#endif - } - -} - -void CTRTextureGouraudAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - // sort on height, y - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - - const f32 ca = c->Pos.y - a->Pos.y; - const f32 ba = b->Pos.y - a->Pos.y; - const f32 cb = c->Pos.y - b->Pos.y; - // calculate delta y of the edges - scan.invDeltaY[0] = core::reciprocal( ca ); - scan.invDeltaY[1] = core::reciprocal( ba ); - scan.invDeltaY[2] = core::reciprocal( cb ); - - if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) - return; - - // find if the major edge is left or right aligned - f32 temp[4]; - - temp[0] = a->Pos.x - c->Pos.x; - temp[1] = -ca; - temp[2] = b->Pos.x - a->Pos.x; - temp[3] = ba; - - scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1; - scan.right = 1 - scan.left; - - // calculate slopes for the major edge - scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; - scan.x[0] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; - scan.z[0] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; - scan.w[0] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0][0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; - scan.c[0][0] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; - scan.t[0][0] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; - scan.t[1][0] = a->Tex[1]; -#endif - - // top left fill convention y run - s32 yStart; - s32 yEnd; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - - // rasterize upper sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[1] ) - { - // calculate slopes for top edge - scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; - scan.x[1] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; - scan.z[1] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; - scan.w[1] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0][1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; - scan.c[0][1] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; - scan.t[0][1] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; - scan.t[1][1] = a->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = core::ceil32( a->Pos.y ); - yEnd = core::ceil32( b->Pos.y ) - 1; - -#ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - a->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0] * subPixel; - scan.c[0][1] += scan.slopeC[0][1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0] * subPixel; - scan.t[0][1] += scan.slopeT[0][1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0] * subPixel; - scan.t[1][1] += scan.slopeT[1][1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[0][scan.left] = scan.c[0][0]; - line.c[0][scan.right] = scan.c[0][1]; -#endif - -#ifdef IPOL_T0 - line.t[0][scan.left] = scan.t[0][0]; - line.t[0][scan.right] = scan.t[0][1]; -#endif - -#ifdef IPOL_T1 - line.t[1][scan.left] = scan.t[1][0]; - line.t[1][scan.right] = scan.t[1][1]; -#endif - - // render a scanline - scanline_bilinear ( ); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0]; - scan.c[0][1] += scan.slopeC[0][1]; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0]; - scan.t[0][1] += scan.slopeT[0][1]; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0]; - scan.t[1][1] += scan.slopeT[1][1]; -#endif - - } - } - - // rasterize lower sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[2] ) - { - // advance to middle point - if( (f32) 0.0 != scan.invDeltaY[1] ) - { - temp[0] = b->Pos.y - a->Pos.y; // dy - - scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; -#ifdef IPOL_Z - scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; -#endif -#ifdef IPOL_W - scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; -#endif -#ifdef IPOL_C0 - scan.c[0][0] = a->Color[0] + scan.slopeC[0][0] * temp[0]; -#endif -#ifdef IPOL_T0 - scan.t[0][0] = a->Tex[0] + scan.slopeT[0][0] * temp[0]; -#endif -#ifdef IPOL_T1 - scan.t[1][0] = a->Tex[1] + scan.slopeT[1][0] * temp[0]; -#endif - - } - - // calculate slopes for bottom edge - scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; - scan.x[1] = b->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; - scan.z[1] = b->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; - scan.w[1] = b->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0][1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; - scan.c[0][1] = b->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; - scan.t[0][1] = b->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; - scan.t[1][1] = b->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = core::ceil32( b->Pos.y ); - yEnd = core::ceil32( c->Pos.y ) - 1; - -#ifdef SUBTEXEL - - subPixel = ( (f32) yStart ) - b->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0] * subPixel; - scan.c[0][1] += scan.slopeC[0][1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0] * subPixel; - scan.t[0][1] += scan.slopeT[0][1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0] * subPixel; - scan.t[1][1] += scan.slopeT[1][1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[0][scan.left] = scan.c[0][0]; - line.c[0][scan.right] = scan.c[0][1]; -#endif - -#ifdef IPOL_T0 - line.t[0][scan.left] = scan.t[0][0]; - line.t[0][scan.right] = scan.t[0][1]; -#endif - -#ifdef IPOL_T1 - line.t[1][scan.left] = scan.t[1][0]; - line.t[1][scan.right] = scan.t[1][1]; -#endif - - // render a scanline - scanline_bilinear ( ); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0]; - scan.c[0][1] += scan.slopeC[0][1]; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0]; - scan.t[0][1] += scan.slopeT[0][1]; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0]; - scan.t[1][1] += scan.slopeT[1][1]; -#endif - - } - } - -} - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - - -//! creates a flat triangle renderer -IBurningShader* createTRTextureGouraudAlpha(IDepthBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CTRTextureGouraudAlpha2(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - -} // end namespace video -} // end namespace irr - - diff --git a/irrlicht-1.6/source/Irrlicht/CTRTextureGouraudAlphaNoZ.cpp b/irrlicht-1.6/source/Irrlicht/CTRTextureGouraudAlphaNoZ.cpp deleted file mode 100644 index 394f41edb..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTRTextureGouraudAlphaNoZ.cpp +++ /dev/null @@ -1,745 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "IBurningShader.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -// compile flag for this file -#undef USE_ZBUFFER -#undef IPOL_Z -#undef CMP_Z -#undef WRITE_Z - -#undef IPOL_W -#undef CMP_W -#undef WRITE_W - -#undef SUBTEXEL -#undef INVERSE_W - -#undef IPOL_C0 -#undef IPOL_T0 -#undef IPOL_T1 - -// define render case -#define SUBTEXEL -#define INVERSE_W - -#define USE_ZBUFFER -#define IPOL_W -#define CMP_W -//#define WRITE_W - -#define IPOL_C0 -#define IPOL_T0 -//#define IPOL_T1 - -// apply global override -#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef INVERSE_W -#endif - -#ifndef SOFTWARE_DRIVER_2_SUBTEXEL - #undef SUBTEXEL -#endif - -#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #undef IPOL_C0 -#endif - -#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) - #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef IPOL_W - #endif - #define IPOL_Z - - #ifdef CMP_W - #undef CMP_W - #define CMP_Z - #endif - - #ifdef WRITE_W - #undef WRITE_W - #define WRITE_Z - #endif - -#endif - - - -namespace irr -{ - -namespace video -{ - -class CTRTextureGouraudAlphaNoZ : public IBurningShader -{ -public: - - //! constructor - CTRTextureGouraudAlphaNoZ(IDepthBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - - virtual void setParam ( u32 index, f32 value); - - -private: - void scanline_bilinear (); - - sScanConvertData scan; - sScanLineData line; - - u32 AlphaRef; -}; - -//! constructor -CTRTextureGouraudAlphaNoZ::CTRTextureGouraudAlphaNoZ(IDepthBuffer* zbuffer) -: IBurningShader(zbuffer) -{ - #ifdef _DEBUG - setDebugName("CTRTextureGouraudAlphaNoZ"); - #endif - - AlphaRef = 0; -} - - -/*! -*/ -void CTRTextureGouraudAlphaNoZ::setParam ( u32 index, f32 value) -{ -#ifdef BURNINGVIDEO_RENDERER_FAST - AlphaRef = core::floor32 ( value * 256.f ); -#else - AlphaRef = u32_to_fixPoint ( core::floor32 ( value * 256.f ) ); -#endif -} - -/*! -*/ -void CTRTextureGouraudAlphaNoZ::scanline_bilinear () -{ - tVideoSample *dst; - -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC[MATERIAL_MAX_COLORS]; -#endif -#ifdef IPOL_T0 - sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES]; -#endif - - // apply top-left fill-convention, left - xStart = core::ceil32( line.x[0] ); - xEnd = core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC[0] = (line.c[0][1] - line.c[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC[0] * subPixel; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0] * subPixel; -#endif -#ifdef IPOL_T1 - line.t[1][0] += slopeT[1] * subPixel; -#endif -#endif - - dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; - -#ifdef USE_ZBUFFER - z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; -#endif - - -#ifdef INVERSE_W - f32 inversew; -#endif - -#ifdef BURNINGVIDEO_RENDERER_FAST - u32 dIndex = ( line.y & 3 ) << 2; - -#else - tFixPoint a0; - tFixPoint r0, g0, b0; -#endif - -#ifdef IPOL_C0 - tFixPoint r1, g1, b1; - tFixPoint r2, g2, b2; -#endif - - for ( s32 i = 0; i <= dx; ++i ) - { -#ifdef CMP_Z - if ( line.z[0] < z[i] ) -#endif -#ifdef CMP_W - if ( line.w[0] >= z[i] ) -#endif - - { - -#ifdef BURNINGVIDEO_RENDERER_FAST - - const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ]; - -#ifdef INVERSE_W - - inversew = fix_inverse32 ( line.w[0] ); - - u32 argb = getTexel_plain ( &IT[0], d + tofix ( line.t[0][0].x,inversew), - d + tofix ( line.t[0][0].y,inversew) - ); - -#else - - u32 argb = getTexel_plain ( &IT[0], d + tofix ( line.t[0][0].x), - d + tofix ( line.t[0][0].y) - ); - -#endif - - const u32 alpha = ( argb >> 24 ); - if ( alpha > AlphaRef ) - { -#ifdef WRITE_Z - z[i] = line.z[0]; -#endif -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - - dst[i] = PixelBlend32 ( dst[i], argb, alpha ); - } - - -#else - -#ifdef INVERSE_W - inversew = fix_inverse32 ( line.w[0] ); - getSample_texture ( (tFixPointu&) a0, (tFixPointu&) r0, (tFixPointu&)g0, (tFixPointu&)b0, - &IT[0], - tofix ( line.t[0][0].x,inversew), - tofix ( line.t[0][0].y,inversew) - ); -#else - getSample_texture ( (tFixPointu&) a0, (tFixPointu&) r0, (tFixPointu&)g0, (tFixPointu&)b0, - &IT[0], - tofix ( line.t[0][0].x), - tofix ( line.t[0][0].y) - ); -#endif - if ( (tFixPointu) a0 > AlphaRef ) - { -#ifdef WRITE_Z - z[i] = line.z[0]; -#endif -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - -#ifdef INVERSE_W - getSample_color ( r2, g2, b2, line.c[0][0], inversew ); -#else - getSample_color ( r2, g2, b2, line.c[0][0] ); -#endif - r0 = imulFix ( r0, r2 ); - g0 = imulFix ( g0, g2 ); - b0 = imulFix ( b0, b2 ); - - color_to_fix ( r1, g1, b1, dst[i] ); - - a0 >>= 8; - - r2 = r1 + imulFix ( a0, r0 - r1 ); - g2 = g1 + imulFix ( a0, g0 - g1 ); - b2 = b1 + imulFix ( a0, b0 - b1 ); - dst[i] = fix4_to_color ( a0, r2, g2, b2 ); - -/* - dst[i] = PixelBlend32 ( dst[i], - fix_to_color ( r0,g0, b0 ), - fixPointu_to_u32 ( a0 ) - ); -*/ -/* - getSample_color ( r2, g2, b2, line.c[0][0], inversew * COLOR_MAX ); - color_to_fix ( r1, g1, b1, dst[i] ); - - r2 = r0 + imulFix ( a0, r1 - r0 ); - g2 = g0 + imulFix ( a0, g1 - g0 ); - b2 = b0 + imulFix ( a0, b1 - b0 ); - dst[i] = fix_to_color ( r2, g2, b2 ); -*/ - - } -#endif - - } - -#ifdef IPOL_Z - line.z[0] += slopeZ; -#endif -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC[0]; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0]; -#endif -#ifdef IPOL_T1 - line.t[1][0] += slopeT[1]; -#endif - } - -} - -void CTRTextureGouraudAlphaNoZ::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - // sort on height, y - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - - const f32 ca = c->Pos.y - a->Pos.y; - const f32 ba = b->Pos.y - a->Pos.y; - const f32 cb = c->Pos.y - b->Pos.y; - // calculate delta y of the edges - scan.invDeltaY[0] = core::reciprocal( ca ); - scan.invDeltaY[1] = core::reciprocal( ba ); - scan.invDeltaY[2] = core::reciprocal( cb ); - - if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) - return; - - // find if the major edge is left or right aligned - f32 temp[4]; - - temp[0] = a->Pos.x - c->Pos.x; - temp[1] = -ca; - temp[2] = b->Pos.x - a->Pos.x; - temp[3] = ba; - - scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1; - scan.right = 1 - scan.left; - - // calculate slopes for the major edge - scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; - scan.x[0] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; - scan.z[0] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; - scan.w[0] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0][0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; - scan.c[0][0] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; - scan.t[0][0] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; - scan.t[1][0] = a->Tex[1]; -#endif - - // top left fill convention y run - s32 yStart; - s32 yEnd; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - - // rasterize upper sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[1] ) - { - // calculate slopes for top edge - scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; - scan.x[1] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; - scan.z[1] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; - scan.w[1] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0][1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; - scan.c[0][1] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; - scan.t[0][1] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; - scan.t[1][1] = a->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = core::ceil32( a->Pos.y ); - yEnd = core::ceil32( b->Pos.y ) - 1; - -#ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - a->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0] * subPixel; - scan.c[0][1] += scan.slopeC[0][1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0] * subPixel; - scan.t[0][1] += scan.slopeT[0][1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0] * subPixel; - scan.t[1][1] += scan.slopeT[1][1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[0][scan.left] = scan.c[0][0]; - line.c[0][scan.right] = scan.c[0][1]; -#endif - -#ifdef IPOL_T0 - line.t[0][scan.left] = scan.t[0][0]; - line.t[0][scan.right] = scan.t[0][1]; -#endif - -#ifdef IPOL_T1 - line.t[1][scan.left] = scan.t[1][0]; - line.t[1][scan.right] = scan.t[1][1]; -#endif - - // render a scanline - scanline_bilinear ( ); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0]; - scan.c[0][1] += scan.slopeC[0][1]; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0]; - scan.t[0][1] += scan.slopeT[0][1]; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0]; - scan.t[1][1] += scan.slopeT[1][1]; -#endif - - } - } - - // rasterize lower sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[2] ) - { - // advance to middle point - if( (f32) 0.0 != scan.invDeltaY[1] ) - { - temp[0] = b->Pos.y - a->Pos.y; // dy - - scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; -#ifdef IPOL_Z - scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; -#endif -#ifdef IPOL_W - scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; -#endif -#ifdef IPOL_C0 - scan.c[0][0] = a->Color[0] + scan.slopeC[0][0] * temp[0]; -#endif -#ifdef IPOL_T0 - scan.t[0][0] = a->Tex[0] + scan.slopeT[0][0] * temp[0]; -#endif -#ifdef IPOL_T1 - scan.t[1][0] = a->Tex[1] + scan.slopeT[1][0] * temp[0]; -#endif - - } - - // calculate slopes for bottom edge - scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; - scan.x[1] = b->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; - scan.z[1] = b->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; - scan.w[1] = b->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0][1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; - scan.c[0][1] = b->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; - scan.t[0][1] = b->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; - scan.t[1][1] = b->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = core::ceil32( b->Pos.y ); - yEnd = core::ceil32( c->Pos.y ) - 1; - -#ifdef SUBTEXEL - - subPixel = ( (f32) yStart ) - b->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0] * subPixel; - scan.c[0][1] += scan.slopeC[0][1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0] * subPixel; - scan.t[0][1] += scan.slopeT[0][1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0] * subPixel; - scan.t[1][1] += scan.slopeT[1][1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[0][scan.left] = scan.c[0][0]; - line.c[0][scan.right] = scan.c[0][1]; -#endif - -#ifdef IPOL_T0 - line.t[0][scan.left] = scan.t[0][0]; - line.t[0][scan.right] = scan.t[0][1]; -#endif - -#ifdef IPOL_T1 - line.t[1][scan.left] = scan.t[1][0]; - line.t[1][scan.right] = scan.t[1][1]; -#endif - - // render a scanline - scanline_bilinear ( ); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0]; - scan.c[0][1] += scan.slopeC[0][1]; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0]; - scan.t[0][1] += scan.slopeT[0][1]; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0]; - scan.t[1][1] += scan.slopeT[1][1]; -#endif - - } - } - - -} - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - - -//! creates a flat triangle renderer -IBurningShader* createTRTextureGouraudAlphaNoZ(IDepthBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CTRTextureGouraudAlphaNoZ(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - -} // end namespace video -} // end namespace irr - - diff --git a/irrlicht-1.6/source/Irrlicht/CTRTextureGouraudNoZ.cpp b/irrlicht-1.6/source/Irrlicht/CTRTextureGouraudNoZ.cpp deleted file mode 100644 index 9f105ce2c..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTRTextureGouraudNoZ.cpp +++ /dev/null @@ -1,367 +0,0 @@ -// Copyright (C) 2002-2009 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" -#include "CTRTextureGouraud.h" -#include "SColor.h" - -#ifdef _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -class CTRTextureGouraudNoZ : public CTRTextureGouraud -{ -public: - - CTRTextureGouraudNoZ() - : CTRTextureGouraud(0) - { - #ifdef _DEBUG - setDebugName("CTRGouraudWireNoZ"); - #endif - } - - //! draws an indexed triangle list - virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount) - { - const S2DVertex *v1, *v2, *v3; - - u16 color; - f32 tmpDiv; // temporary division factor - f32 longest; // saves the longest span - s32 height; // saves height of triangle - u16* targetSurface; // target pointer where to plot pixels - s32 spanEnd; // saves end of spans - f32 leftdeltaxf; // amount of pixels to increase on left side of triangle - f32 rightdeltaxf; // amount of pixels to increase on right side of triangle - s32 leftx, rightx; // position where we are - f32 leftxf, rightxf; // same as above, but as f32 values - s32 span; // current span - u16 *hSpanBegin, *hSpanEnd; // pointer used when plotting pixels - s32 leftR, leftG, leftB, rightR, rightG, rightB; // color values - s32 leftStepR, leftStepG, leftStepB, - rightStepR, rightStepG, rightStepB; // color steps - s32 spanR, spanG, spanB, spanStepR, spanStepG, spanStepB; // color interpolating values while drawing a span. - s32 leftTx, rightTx, leftTy, rightTy; // texture interpolating values - s32 leftTxStep, rightTxStep, leftTyStep, rightTyStep; // texture interpolating values - s32 spanTx, spanTy, spanTxStep, spanTyStep; // values of Texturecoords when drawing a span - core::rect<s32> TriangleRect; - - lockedSurface = (u16*)RenderTarget->lock(); - lockedTexture = (u16*)Texture->lock(); - - for (s32 i=0; i<triangleCount; ++i) - { - v1 = &vertices[*indexList]; - ++indexList; - v2 = &vertices[*indexList]; - ++indexList; - v3 = &vertices[*indexList]; - ++indexList; - - // back face culling - - if (BackFaceCullingEnabled) - { - s32 z = ((v3->Pos.X - v1->Pos.X) * (v3->Pos.Y - v2->Pos.Y)) - - ((v3->Pos.Y - v1->Pos.Y) * (v3->Pos.X - v2->Pos.X)); - - if (z < 0) - continue; - } - - //near plane clipping - - if (v1->ZValue<0 && v2->ZValue<0 && v3->ZValue<0) - continue; - - // sort for width for inscreen clipping - - if (v1->Pos.X > v2->Pos.X) swapVertices(&v1, &v2); - if (v1->Pos.X > v3->Pos.X) swapVertices(&v1, &v3); - if (v2->Pos.X > v3->Pos.X) swapVertices(&v2, &v3); - - if ((v1->Pos.X - v3->Pos.X) == 0) - continue; - - TriangleRect.UpperLeftCorner.X = v1->Pos.X; - TriangleRect.LowerRightCorner.X = v3->Pos.X; - - // sort for height for faster drawing. - - if (v1->Pos.Y > v2->Pos.Y) swapVertices(&v1, &v2); - if (v1->Pos.Y > v3->Pos.Y) swapVertices(&v1, &v3); - if (v2->Pos.Y > v3->Pos.Y) swapVertices(&v2, &v3); - - TriangleRect.UpperLeftCorner.Y = v1->Pos.Y; - TriangleRect.LowerRightCorner.Y = v3->Pos.Y; - - if (!TriangleRect.isRectCollided(ViewPortRect)) - continue; - - // calculate height of triangle - height = v3->Pos.Y - v1->Pos.Y; - if (!height) - continue; - - // calculate longest span - - longest = (v2->Pos.Y - v1->Pos.Y) / (f32)height * (v3->Pos.X - v1->Pos.X) + (v1->Pos.X - v2->Pos.X); - - spanEnd = v2->Pos.Y; - span = v1->Pos.Y; - leftxf = (f32)v1->Pos.X; - rightxf = (f32)v1->Pos.X; - - leftR = rightR = video::getRed(v1->Color)<<8; - leftG = rightG = video::getGreen(v1->Color)<<8; - leftB = rightB = video::getBlue(v1->Color)<<8; - leftTx = rightTx = v1->TCoords.X; - leftTy = rightTy = v1->TCoords.Y; - - targetSurface = lockedSurface + span * SurfaceWidth; - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - rightdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - rightStepR = (s32)(((s32)(video::getRed(v2->Color)<<8) - rightR) * tmpDiv); - rightStepG = (s32)(((s32)(video::getGreen(v2->Color)<<8) - rightG) * tmpDiv); - rightStepB = (s32)(((s32)(video::getBlue(v2->Color)<<8) - rightB) * tmpDiv); - rightTxStep = (s32)((v2->TCoords.X - rightTx) * tmpDiv); - rightTyStep = (s32)((v2->TCoords.Y - rightTy) * tmpDiv); - - tmpDiv = 1.0f / (f32)height; - leftdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - leftStepR = (s32)(((s32)(video::getRed(v3->Color)<<8) - leftR) * tmpDiv); - leftStepG = (s32)(((s32)(video::getGreen(v3->Color)<<8) - leftG) * tmpDiv); - leftStepB = (s32)(((s32)(video::getBlue(v3->Color)<<8) - leftB) * tmpDiv); - leftTxStep = (s32)((v3->TCoords.X - leftTx) * tmpDiv); - leftTyStep = (s32)((v3->TCoords.Y - leftTy) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (f32)height; - rightdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - rightStepR = (s32)(((s32)(video::getRed(v3->Color)<<8) - rightR) * tmpDiv); - rightStepG = (s32)(((s32)(video::getGreen(v3->Color)<<8) - rightG) * tmpDiv); - rightStepB = (s32)(((s32)(video::getBlue(v3->Color)<<8) - rightB) * tmpDiv); - rightTxStep = (s32)((v3->TCoords.X - rightTx) * tmpDiv); - rightTyStep = (s32)((v3->TCoords.Y - rightTy) * tmpDiv); - - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - leftdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - leftStepR = (s32)(((s32)(video::getRed(v2->Color)<<8) - leftR) * tmpDiv); - leftStepG = (s32)(((s32)(video::getGreen(v2->Color)<<8) - leftG) * tmpDiv); - leftStepB = (s32)(((s32)(video::getBlue(v2->Color)<<8) - leftB) * tmpDiv); - leftTxStep = (s32)((v2->TCoords.X - leftTx) * tmpDiv); - leftTyStep = (s32)((v2->TCoords.Y - leftTy) * tmpDiv); - } - - - // do it twice, once for the first half of the triangle, - // end then for the second half. - - for (s32 triangleHalf=0; triangleHalf<2; ++triangleHalf) - { - if (spanEnd > ViewPortRect.LowerRightCorner.Y) - spanEnd = ViewPortRect.LowerRightCorner.Y; - - // if the span <0, than we can skip these spans, - // and proceed to the next spans which are really on the screen. - if (span < ViewPortRect.UpperLeftCorner.Y) - { - // we'll use leftx as temp variable - if (spanEnd < ViewPortRect.UpperLeftCorner.Y) - { - leftx = spanEnd - span; - span = spanEnd; - } - else - { - leftx = ViewPortRect.UpperLeftCorner.Y - span; - span = ViewPortRect.UpperLeftCorner.Y; - } - - leftxf += leftdeltaxf*leftx; - rightxf += rightdeltaxf*leftx; - targetSurface += SurfaceWidth*leftx; - - leftR += leftStepR*leftx; - leftG += leftStepG*leftx; - leftB += leftStepB*leftx; - rightR += rightStepR*leftx; - rightG += rightStepG*leftx; - rightB += rightStepB*leftx; - - leftTx += leftTxStep*leftx; - leftTy += leftTyStep*leftx; - rightTx += rightTxStep*leftx; - rightTy += rightTyStep*leftx; - } - - - // the main loop. Go through every span and draw it. - - while (span < spanEnd) - { - leftx = (s32)(leftxf); - rightx = (s32)(rightxf + 0.5f); - - // perform some clipping - // thanks to a correction by hybrid - // calculations delayed to correctly propagate to textures etc. - s32 tDiffLeft=0, tDiffRight=0; - if (leftx<ViewPortRect.UpperLeftCorner.X) - tDiffLeft=ViewPortRect.UpperLeftCorner.X-leftx; - else - if (leftx>ViewPortRect.LowerRightCorner.X) - tDiffLeft=ViewPortRect.LowerRightCorner.X-leftx; - - if (rightx<ViewPortRect.UpperLeftCorner.X) - tDiffRight=ViewPortRect.UpperLeftCorner.X-rightx; - else - if (rightx>ViewPortRect.LowerRightCorner.X) - tDiffRight=ViewPortRect.LowerRightCorner.X-rightx; - - // draw the span - if (rightx + tDiffRight - leftx - tDiffLeft) - { - tmpDiv = 1.0f / (f32)(rightx - leftx); - - spanStepR = (s32)((rightR - leftR) * tmpDiv); - spanR = leftR+tDiffLeft*spanStepR; - spanStepG = (s32)((rightG - leftG) * tmpDiv); - spanG = leftG+tDiffLeft*spanStepG; - spanStepB = (s32)((rightB - leftB) * tmpDiv); - spanB = leftB+tDiffLeft*spanStepB; - - spanTxStep = (s32)((rightTx - leftTx) * tmpDiv); - spanTx = leftTx + tDiffLeft*spanTxStep; - spanTyStep = (s32)((rightTy - leftTy) * tmpDiv); - spanTy = leftTy+tDiffLeft*spanTyStep; - - hSpanBegin = targetSurface + leftx+tDiffLeft; - hSpanEnd = targetSurface + rightx+tDiffRight; - - while (hSpanBegin < hSpanEnd) - { - color = lockedTexture[((spanTy>>8)&textureYMask) * lockedTextureWidth + ((spanTx>>8)&textureXMask)]; - *hSpanBegin = video::RGB16(video::getRed(color) * (spanR>>8) >>2, - video::getGreen(color) * (spanG>>8) >>2, - video::getBlue(color) * (spanB>>8) >>2); - - spanR += spanStepR; - spanG += spanStepG; - spanB += spanStepB; - - spanTx += spanTxStep; - spanTy += spanTyStep; - - ++hSpanBegin; - } - } - - leftxf += leftdeltaxf; - rightxf += rightdeltaxf; - ++span; - targetSurface += SurfaceWidth; - - leftR += leftStepR; - leftG += leftStepG; - leftB += leftStepB; - rightR += rightStepR; - rightG += rightStepG; - rightB += rightStepB; - - leftTx += leftTxStep; - leftTy += leftTyStep; - rightTx += rightTxStep; - rightTy += rightTyStep; - } - - if (triangleHalf>0) // break, we've gout only two halves - break; - - - // setup variables for second half of the triangle. - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - rightdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - rightxf = (f32)v2->Pos.X; - - rightR = video::getRed(v2->Color)<<8; - rightG = video::getGreen(v2->Color)<<8; - rightB = video::getBlue(v2->Color)<<8; - rightStepR = (s32)(((s32)(video::getRed(v3->Color)<<8) - rightR) * tmpDiv); - rightStepG = (s32)(((s32)(video::getGreen(v3->Color)<<8) - rightG) * tmpDiv); - rightStepB = (s32)(((s32)(video::getBlue(v3->Color)<<8) - rightB) * tmpDiv); - - rightTx = v2->TCoords.X; - rightTy = v2->TCoords.Y; - rightTxStep = (s32)((v3->TCoords.X - rightTx) * tmpDiv); - rightTyStep = (s32)((v3->TCoords.Y - rightTy) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - leftdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - leftxf = (f32)v2->Pos.X; - - leftR = video::getRed(v2->Color)<<8; - leftG = video::getGreen(v2->Color)<<8; - leftB = video::getBlue(v2->Color)<<8; - leftStepR = (s32)(((s32)(video::getRed(v3->Color)<<8) - leftR) * tmpDiv); - leftStepG = (s32)(((s32)(video::getGreen(v3->Color)<<8) - leftG) * tmpDiv); - leftStepB = (s32)(((s32)(video::getBlue(v3->Color)<<8) - leftB) * tmpDiv); - - leftTx = v2->TCoords.X; - leftTy = v2->TCoords.Y; - leftTxStep = (s32)((v3->TCoords.X - leftTx) * tmpDiv); - leftTyStep = (s32)((v3->TCoords.Y - leftTy) * tmpDiv); - } - - - spanEnd = v3->Pos.Y; - } - - } - - RenderTarget->unlock(); - Texture->unlock(); - } - -}; - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -ITriangleRenderer* createTriangleRendererTextureGouraudNoZ() -{ - #ifdef _IRR_COMPILE_WITH_SOFTWARE_ - return new CTRTextureGouraudNoZ(); - #else - return 0; - #endif // _IRR_COMPILE_WITH_SOFTWARE_ -} - -} // end namespace video -} // end namespace irr - - diff --git a/irrlicht-1.6/source/Irrlicht/CTRTextureGouraudNoZ2.cpp b/irrlicht-1.6/source/Irrlicht/CTRTextureGouraudNoZ2.cpp deleted file mode 100644 index a05af5a2b..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTRTextureGouraudNoZ2.cpp +++ /dev/null @@ -1,647 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "IBurningShader.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -// compile flag for this file -#undef USE_ZBUFFER -#undef IPOL_Z -#undef CMP_Z -#undef WRITE_Z - -#undef IPOL_W -#undef CMP_W -#undef WRITE_W - -#undef SUBTEXEL -#undef INVERSE_W - -#undef IPOL_C0 -#undef IPOL_T0 -#undef IPOL_T1 - -// define render case -#ifdef BURNINGVIDEO_RENDERER_FAST - #define SUBTEXEL - #define INVERSE_W -#else - #define SUBTEXEL - #define INVERSE_W -#endif - -//#define USE_ZBUFFER -#define IPOL_W -//#define CMP_W -//#define WRITE_W - -//#define IPOL_C0 -#define IPOL_T0 -//#define IPOL_T1 - -#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #undef IPOL_C0 -#endif - -// apply global override -#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef INVERSE_W - #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef IPOL_W - #endif -#endif - -#ifndef SOFTWARE_DRIVER_2_SUBTEXEL - #undef SUBTEXEL -#endif - -#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) - #define IPOL_Z - - #ifdef CMP_W - #undef CMP_W - #define CMP_Z - #endif - - #ifdef WRITE_W - #undef WRITE_W - #define WRITE_Z - #endif - -#endif - - -namespace irr -{ - -namespace video -{ - -class CTRTextureGouraudNoZ2 : public IBurningShader -{ -public: - - //! constructor - CTRTextureGouraudNoZ2(IDepthBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - - -private: - void scanline_bilinear (); - sScanConvertData scan; - sScanLineData line; - -}; - -//! constructor -CTRTextureGouraudNoZ2::CTRTextureGouraudNoZ2(IDepthBuffer* zbuffer) -: IBurningShader(0) -{ - #ifdef _DEBUG - setDebugName("CTRTextureGouraudNoZ2"); - #endif -} - - - -/*! -*/ -void CTRTextureGouraudNoZ2::scanline_bilinear ( ) -{ - tVideoSample *dst; - -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC; -#endif -#ifdef IPOL_T0 - sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES]; -#endif - - // apply top-left fill-convention, left - xStart = core::ceil32( line.x[0] ); - xEnd = core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC = (line.c[1] - line.c[0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC * subPixel; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0] * subPixel; -#endif -#ifdef IPOL_T1 - line.t[1][0] += slopeT[1] * subPixel; -#endif -#endif - - dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; - -#ifdef USE_ZBUFFER - z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; -#endif - - -#ifdef INVERSE_W - f32 inversew; -#endif - - tFixPoint tx0; - tFixPoint ty0; - - - for ( s32 i = 0; i <= dx; ++i ) - { -#ifdef CMP_Z - if ( line.z[0] < z[i] ) -#endif -#ifdef CMP_W - if ( line.w[0] >= z[i] ) -#endif - - { -#ifdef INVERSE_W - inversew = fix_inverse32 ( line.w[0] ); - - tx0 = tofix ( line.t[0][0].x,inversew); - ty0 = tofix ( line.t[0][0].y,inversew); -#else - tx0 = tofix ( line.t[0][0].x ); - ty0 = tofix ( line.t[0][0].y ); -#endif - dst[i] = getTexel_plain ( &IT[0], tx0, ty0 ); - -/* - getSample_texture ( r0, g0, b0, &IT[0], tx0, ty0 ); - dst[i] = fix_to_color ( r0, g0, b0 ); -*/ -#ifdef WRITE_Z - z[i] = line.z[0]; -#endif -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - } - -#ifdef IPOL_Z - line.z[0] += slopeZ; -#endif -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0]; -#endif -#ifdef IPOL_T1 - line.t[1][0] += slopeT[1]; -#endif - } - -} - -void CTRTextureGouraudNoZ2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - // sort on height, y - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - - const f32 ca = c->Pos.y - a->Pos.y; - const f32 ba = b->Pos.y - a->Pos.y; - const f32 cb = c->Pos.y - b->Pos.y; - // calculate delta y of the edges - scan.invDeltaY[0] = core::reciprocal( ca ); - scan.invDeltaY[1] = core::reciprocal( ba ); - scan.invDeltaY[2] = core::reciprocal( cb ); - - if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) - return; - - // find if the major edge is left or right aligned - f32 temp[4]; - - temp[0] = a->Pos.x - c->Pos.x; - temp[1] = -ca; - temp[2] = b->Pos.x - a->Pos.x; - temp[3] = ba; - - scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1; - scan.right = 1 - scan.left; - - // calculate slopes for the major edge - scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; - scan.x[0] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; - scan.z[0] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; - scan.w[0] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; - scan.c[0] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; - scan.t[0][0] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; - scan.t[1][0] = a->Tex[1]; -#endif - - // top left fill convention y run - s32 yStart; - s32 yEnd; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - - // rasterize upper sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[1] ) - { - // calculate slopes for top edge - scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; - scan.x[1] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; - scan.z[1] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; - scan.w[1] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; - scan.c[1] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; - scan.t[0][1] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; - scan.t[1][1] = a->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = core::ceil32( a->Pos.y ); - yEnd = core::ceil32( b->Pos.y ) - 1; - -#ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - a->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0] * subPixel; - scan.t[0][1] += scan.slopeT[0][1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0] * subPixel; - scan.t[1][1] += scan.slopeT[1][1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t[0][scan.left] = scan.t[0][0]; - line.t[0][scan.right] = scan.t[0][1]; -#endif - -#ifdef IPOL_T1 - line.t[1][scan.left] = scan.t[1][0]; - line.t[1][scan.right] = scan.t[1][1]; -#endif - - // render a scanline - scanline_bilinear ( ); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0]; - scan.t[0][1] += scan.slopeT[0][1]; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0]; - scan.t[1][1] += scan.slopeT[1][1]; -#endif - - } - } - - // rasterize lower sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[2] ) - { - // advance to middle point - if( (f32) 0.0 != scan.invDeltaY[1] ) - { - temp[0] = b->Pos.y - a->Pos.y; // dy - - scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; -#ifdef IPOL_Z - scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; -#endif -#ifdef IPOL_W - scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; -#endif -#ifdef IPOL_C0 - scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; -#endif -#ifdef IPOL_T0 - scan.t[0][0] = a->Tex[0] + scan.slopeT[0][0] * temp[0]; -#endif -#ifdef IPOL_T1 - scan.t[1][0] = a->Tex[1] + scan.slopeT[1][0] * temp[0]; -#endif - - } - - // calculate slopes for bottom edge - scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; - scan.x[1] = b->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; - scan.z[1] = b->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; - scan.w[1] = b->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; - scan.c[1] = b->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; - scan.t[0][1] = b->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; - scan.t[1][1] = b->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = core::ceil32( b->Pos.y ); - yEnd = core::ceil32( c->Pos.y ) - 1; - -#ifdef SUBTEXEL - - subPixel = ( (f32) yStart ) - b->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0] * subPixel; - scan.t[0][1] += scan.slopeT[0][1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0] * subPixel; - scan.t[1][1] += scan.slopeT[1][1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t[0][scan.left] = scan.t[0][0]; - line.t[0][scan.right] = scan.t[0][1]; -#endif - -#ifdef IPOL_T1 - line.t[1][scan.left] = scan.t[1][0]; - line.t[1][scan.right] = scan.t[1][1]; -#endif - - // render a scanline - scanline_bilinear (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0]; - scan.t[0][1] += scan.slopeT[0][1]; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0]; - scan.t[1][1] += scan.slopeT[1][1]; -#endif - - } - } - -} - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -IBurningShader* createTRTextureGouraudNoZ2() -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CTRTextureGouraudNoZ2( 0 ); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - -} // end namespace video -} // end namespace irr - - - diff --git a/irrlicht-1.6/source/Irrlicht/CTRTextureGouraudVertexAlpha2.cpp b/irrlicht-1.6/source/Irrlicht/CTRTextureGouraudVertexAlpha2.cpp deleted file mode 100644 index 02a953ca6..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTRTextureGouraudVertexAlpha2.cpp +++ /dev/null @@ -1,690 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "IBurningShader.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -// compile flag for this file -#undef USE_ZBUFFER -#undef IPOL_Z -#undef CMP_Z -#undef WRITE_Z - -#undef IPOL_W -#undef CMP_W -#undef WRITE_W - -#undef SUBTEXEL -#undef INVERSE_W - -#undef IPOL_C0 -#undef IPOL_T0 -#undef IPOL_T1 - -// define render case -#define SUBTEXEL -#define INVERSE_W - -#define USE_ZBUFFER -#define IPOL_W -#define CMP_W -//#define WRITE_W - -#define IPOL_C0 -#define IPOL_T0 -//#define IPOL_T1 - -// apply global override -#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef INVERSE_W -#endif - -#ifndef SOFTWARE_DRIVER_2_SUBTEXEL - #undef SUBTEXEL -#endif - -#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #undef IPOL_C0 -#endif - -#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) - #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef IPOL_W - #endif - #define IPOL_Z - - #ifdef CMP_W - #undef CMP_W - #define CMP_Z - #endif - - #ifdef WRITE_W - #undef WRITE_W - #define WRITE_Z - #endif - -#endif - -namespace irr -{ - -namespace video -{ - -class CTRTextureVertexAlpha2 : public IBurningShader -{ -public: - - //! constructor - CTRTextureVertexAlpha2(IDepthBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - - -private: - void scanline_bilinear (); - sScanConvertData scan; - sScanLineData line; - -}; - -//! constructor -CTRTextureVertexAlpha2::CTRTextureVertexAlpha2(IDepthBuffer* zbuffer) -: IBurningShader(zbuffer) -{ - #ifdef _DEBUG - setDebugName("CTRTextureVertexAlpha2"); - #endif -} - - - -/*! -*/ -void CTRTextureVertexAlpha2::scanline_bilinear ( ) -{ - tVideoSample *dst; - -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC; -#endif -#ifdef IPOL_T0 - sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES]; -#endif - - // apply top-left fill-convention, left - xStart = core::ceil32( line.x[0] ); - xEnd = core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC = (line.c[0][1] - line.c[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC * subPixel; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0] * subPixel; -#endif -#ifdef IPOL_T1 - line.t[1][0] += slopeT[1] * subPixel; -#endif -#endif - - dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; - -#ifdef USE_ZBUFFER - z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; -#endif - - -#ifdef INVERSE_W - f32 inversew; -#endif - -//#define __TEST_THIS - -#ifdef __TEST_THIS - -#else - tFixPoint tx0; - tFixPoint ty0; - - tFixPoint r0, g0, b0; - tFixPoint r1, g1, b1; - tFixPoint r2, g2, b2; -#endif - - -#ifdef IPOL_C0 - tFixPoint a3; -#endif - - - for ( s32 i = 0; i <= dx; ++i ) - { -#ifdef CMP_Z - if ( line.z[0] < z[i] ) -#endif -#ifdef CMP_W - if ( line.w[0] >= z[i] ) -#endif - - { -#ifdef __TEST_THIS - - inversew = fix_inverse32 ( line.w[0] ); - - dst[i] = PixelAdd32 ( - dst[i], - getTexel_plain ( &IT[0], tofix ( line.t[0][0].x,inversew), - tofix ( line.t[0][0].y,inversew) ) - ); - -#else - -#ifdef INVERSE_W - inversew = fix_inverse32 ( line.w[0] ); - - tx0 = tofix ( line.t[0][0].x,inversew); - ty0 = tofix ( line.t[0][0].y,inversew); - -#ifdef IPOL_C0 - a3 = tofix ( line.c[0][0].y,inversew ); -#endif - -#else - tx0 = tofix ( line.t[0][0].x ); - ty0 = tofix ( line.t[0][0].y ); - -#ifdef IPOL_C0 - a3 = tofix ( line.c[0][0].y ); -#endif - - -#endif - - getSample_texture ( r0, g0, b0, &IT[0], tx0, ty0 ); - color_to_fix ( r1, g1, b1, dst[i] ); - -#ifdef IPOL_C0 - r2 = clampfix_maxcolor ( r1 + imulFix ( r0, a3 ) ); - g2 = clampfix_maxcolor ( g1 + imulFix ( g0, a3 ) ); - b2 = clampfix_maxcolor ( b1 + imulFix ( b0, a3 ) ); -#else - r2 = clampfix_maxcolor ( r1 + r0 ); - g2 = clampfix_maxcolor ( g1 + g0 ); - b2 = clampfix_maxcolor ( b1 + b0 ); -#endif - - dst[i] = fix_to_color ( r2, g2, b2 ); - -#ifdef WRITE_Z - z[i] = line.z[0]; -#endif -#ifdef WRITE_W - z[i] = line.w[0]; -#endif -#endif - } - -#ifdef IPOL_Z - line.z[0] += slopeZ; -#endif -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0]; -#endif -#ifdef IPOL_T1 - line.t[1][0] += slopeT[1]; -#endif - } - -} - -void CTRTextureVertexAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - // sort on height, y - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - - const f32 ca = c->Pos.y - a->Pos.y; - const f32 ba = b->Pos.y - a->Pos.y; - const f32 cb = c->Pos.y - b->Pos.y; - // calculate delta y of the edges - scan.invDeltaY[0] = core::reciprocal( ca ); - scan.invDeltaY[1] = core::reciprocal( ba ); - scan.invDeltaY[2] = core::reciprocal( cb ); - - if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) - return; - - // find if the major edge is left or right aligned - f32 temp[4]; - - temp[0] = a->Pos.x - c->Pos.x; - temp[1] = -ca; - temp[2] = b->Pos.x - a->Pos.x; - temp[3] = ba; - - scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1; - scan.right = 1 - scan.left; - - // calculate slopes for the major edge - scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; - scan.x[0] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; - scan.z[0] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; - scan.w[0] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0][0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; - scan.c[0][0] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; - scan.t[0][0] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; - scan.t[1][0] = a->Tex[1]; -#endif - - // top left fill convention y run - s32 yStart; - s32 yEnd; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - - // rasterize upper sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[1] ) - { - // calculate slopes for top edge - scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; - scan.x[1] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; - scan.z[1] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; - scan.w[1] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0][1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; - scan.c[0][1] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; - scan.t[0][1] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; - scan.t[1][1] = a->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = core::ceil32( a->Pos.y ); - yEnd = core::ceil32( b->Pos.y ) - 1; - -#ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - a->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0] * subPixel; - scan.c[0][1] += scan.slopeC[0][1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0] * subPixel; - scan.t[0][1] += scan.slopeT[0][1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0] * subPixel; - scan.t[1][1] += scan.slopeT[1][1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[0][scan.left] = scan.c[0][0]; - line.c[0][scan.right] = scan.c[0][1]; -#endif - -#ifdef IPOL_T0 - line.t[0][scan.left] = scan.t[0][0]; - line.t[0][scan.right] = scan.t[0][1]; -#endif - -#ifdef IPOL_T1 - line.t[1][scan.left] = scan.t[1][0]; - line.t[1][scan.right] = scan.t[1][1]; -#endif - - // render a scanline - scanline_bilinear (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0]; - scan.c[0][1] += scan.slopeC[0][1]; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0]; - scan.t[0][1] += scan.slopeT[0][1]; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0]; - scan.t[1][1] += scan.slopeT[1][1]; -#endif - - } - } - - // rasterize lower sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[2] ) - { - // advance to middle point - if( (f32) 0.0 != scan.invDeltaY[1] ) - { - temp[0] = b->Pos.y - a->Pos.y; // dy - - scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; -#ifdef IPOL_Z - scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; -#endif -#ifdef IPOL_W - scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; -#endif -#ifdef IPOL_C0 - scan.c[0][0] = a->Color[0] + scan.slopeC[0][0] * temp[0]; -#endif -#ifdef IPOL_T0 - scan.t[0][0] = a->Tex[0] + scan.slopeT[0][0] * temp[0]; -#endif -#ifdef IPOL_T1 - scan.t[1][0] = a->Tex[1] + scan.slopeT[1][0] * temp[0]; -#endif - - } - - // calculate slopes for bottom edge - scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; - scan.x[1] = b->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; - scan.z[1] = b->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; - scan.w[1] = b->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0][1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; - scan.c[0][1] = b->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; - scan.t[0][1] = b->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; - scan.t[1][1] = b->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = core::ceil32( b->Pos.y ); - yEnd = core::ceil32( c->Pos.y ) - 1; - -#ifdef SUBTEXEL - - subPixel = ( (f32) yStart ) - b->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0] * subPixel; - scan.c[0][1] += scan.slopeC[0][1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0] * subPixel; - scan.t[0][1] += scan.slopeT[0][1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0] * subPixel; - scan.t[1][1] += scan.slopeT[1][1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[0][scan.left] = scan.c[0][0]; - line.c[0][scan.right] = scan.c[0][1]; -#endif - -#ifdef IPOL_T0 - line.t[0][scan.left] = scan.t[0][0]; - line.t[0][scan.right] = scan.t[0][1]; -#endif - -#ifdef IPOL_T1 - line.t[1][scan.left] = scan.t[1][0]; - line.t[1][scan.right] = scan.t[1][1]; -#endif - - // render a scanline - scanline_bilinear (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0]; - scan.c[0][1] += scan.slopeC[0][1]; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0]; - scan.t[0][1] += scan.slopeT[0][1]; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0]; - scan.t[1][1] += scan.slopeT[1][1]; -#endif - - } - } - -} - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -IBurningShader* createTriangleRendererTextureVertexAlpha2(IDepthBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CTRTextureVertexAlpha2(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - -} // end namespace video -} // end namespace irr - - - diff --git a/irrlicht-1.6/source/Irrlicht/CTRTextureGouraudWire.cpp b/irrlicht-1.6/source/Irrlicht/CTRTextureGouraudWire.cpp deleted file mode 100644 index 0cbf20ed6..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTRTextureGouraudWire.cpp +++ /dev/null @@ -1,364 +0,0 @@ -// Copyright (C) 2002-2009 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" -#include "CTRTextureGouraud.h" - -#ifdef _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -class CTRTextureGouraudWire : public CTRTextureGouraud -{ -public: - - CTRTextureGouraudWire(IZBuffer* zbuffer) - : CTRTextureGouraud(zbuffer) - { - #ifdef _DEBUG - setDebugName("CTRGouraudWire"); - #endif - } - - //! draws an indexed triangle list - virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount) - { - const S2DVertex *v1, *v2, *v3; - - u16 color; - f32 tmpDiv; // temporary division factor - f32 longest; // saves the longest span - s32 height; // saves height of triangle - u16* targetSurface; // target pointer where to plot pixels - s32 spanEnd; // saves end of spans - f32 leftdeltaxf; // amount of pixels to increase on left side of triangle - f32 rightdeltaxf; // amount of pixels to increase on right side of triangle - s32 leftx, rightx; // position where we are - f32 leftxf, rightxf; // same as above, but as f32 values - s32 span; // current span - s32 leftR, leftG, leftB, rightR, rightG, rightB; // color values - s32 leftStepR, leftStepG, leftStepB, - rightStepR, rightStepG, rightStepB; // color steps - s32 leftTx, rightTx, leftTy, rightTy; // texture interpolating values - s32 leftTxStep, rightTxStep, leftTyStep, rightTyStep; // texture interpolating values - core::rect<s32> TriangleRect; - - s32 leftZValue, rightZValue; - s32 leftZStep, rightZStep; - TZBufferType* zTarget;//, *spanZTarget; // target of ZBuffer; - - lockedSurface = (u16*)RenderTarget->lock(); - lockedZBuffer = ZBuffer->lock(); - lockedTexture = (u16*)Texture->lock(); - - for (s32 i=0; i<triangleCount; ++i) - { - v1 = &vertices[*indexList]; - ++indexList; - v2 = &vertices[*indexList]; - ++indexList; - v3 = &vertices[*indexList]; - ++indexList; - - // back face culling - - if (BackFaceCullingEnabled) - { - s32 z = ((v3->Pos.X - v1->Pos.X) * (v3->Pos.Y - v2->Pos.Y)) - - ((v3->Pos.Y - v1->Pos.Y) * (v3->Pos.X - v2->Pos.X)); - - if (z < 0) - continue; - } - - //near plane clipping - - if (v1->ZValue<0 && v2->ZValue<0 && v3->ZValue<0) - continue; - - // sort for width for inscreen clipping - - if (v1->Pos.X > v2->Pos.X) swapVertices(&v1, &v2); - if (v1->Pos.X > v3->Pos.X) swapVertices(&v1, &v3); - if (v2->Pos.X > v3->Pos.X) swapVertices(&v2, &v3); - - if ((v1->Pos.X - v3->Pos.X) == 0) - continue; - - TriangleRect.UpperLeftCorner.X = v1->Pos.X; - TriangleRect.LowerRightCorner.X = v3->Pos.X; - - // sort for height for faster drawing. - - if (v1->Pos.Y > v2->Pos.Y) swapVertices(&v1, &v2); - if (v1->Pos.Y > v3->Pos.Y) swapVertices(&v1, &v3); - if (v2->Pos.Y > v3->Pos.Y) swapVertices(&v2, &v3); - - TriangleRect.UpperLeftCorner.Y = v1->Pos.Y; - TriangleRect.LowerRightCorner.Y = v3->Pos.Y; - - if (!TriangleRect.isRectCollided(ViewPortRect)) - continue; - - // calculate height of triangle - height = v3->Pos.Y - v1->Pos.Y; - if (!height) - continue; - - // calculate longest span - - longest = (v2->Pos.Y - v1->Pos.Y) / (f32)height * (v3->Pos.X - v1->Pos.X) + (v1->Pos.X - v2->Pos.X); - - spanEnd = v2->Pos.Y; - span = v1->Pos.Y; - leftxf = (f32)v1->Pos.X; - rightxf = (f32)v1->Pos.X; - - leftZValue = v1->ZValue; - rightZValue = v1->ZValue; - - leftR = rightR = video::getRed(v1->Color)<<8; - leftG = rightG = video::getGreen(v1->Color)<<8; - leftB = rightB = video::getBlue(v1->Color)<<8; - leftTx = rightTx = v1->TCoords.X; - leftTy = rightTy = v1->TCoords.Y; - - targetSurface = lockedSurface + span * SurfaceWidth; - zTarget = lockedZBuffer + span * SurfaceWidth; - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - rightdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - rightZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); - rightStepR = (s32)(((s32)(video::getRed(v2->Color)<<8) - rightR) * tmpDiv); - rightStepG = (s32)(((s32)(video::getGreen(v2->Color)<<8) - rightG) * tmpDiv); - rightStepB = (s32)(((s32)(video::getBlue(v2->Color)<<8) - rightB) * tmpDiv); - rightTxStep = (s32)((v2->TCoords.X - rightTx) * tmpDiv); - rightTyStep = (s32)((v2->TCoords.Y - rightTy) * tmpDiv); - - tmpDiv = 1.0f / (f32)height; - leftdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - leftZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); - leftStepR = (s32)(((s32)(video::getRed(v3->Color)<<8) - leftR) * tmpDiv); - leftStepG = (s32)(((s32)(video::getGreen(v3->Color)<<8) - leftG) * tmpDiv); - leftStepB = (s32)(((s32)(video::getBlue(v3->Color)<<8) - leftB) * tmpDiv); - leftTxStep = (s32)((v3->TCoords.X - leftTx) * tmpDiv); - leftTyStep = (s32)((v3->TCoords.Y - leftTy) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (f32)height; - rightdeltaxf = (v3->Pos.X - v1->Pos.X) * tmpDiv; - rightZStep = (s32)((v3->ZValue - v1->ZValue) * tmpDiv); - rightStepR = (s32)(((s32)(video::getRed(v3->Color)<<8) - rightR) * tmpDiv); - rightStepG = (s32)(((s32)(video::getGreen(v3->Color)<<8) - rightG) * tmpDiv); - rightStepB = (s32)(((s32)(video::getBlue(v3->Color)<<8) - rightB) * tmpDiv); - rightTxStep = (s32)((v3->TCoords.X - rightTx) * tmpDiv); - rightTyStep = (s32)((v3->TCoords.Y - rightTy) * tmpDiv); - - tmpDiv = 1.0f / (f32)(v2->Pos.Y - v1->Pos.Y); - leftdeltaxf = (v2->Pos.X - v1->Pos.X) * tmpDiv; - leftZStep = (s32)((v2->ZValue - v1->ZValue) * tmpDiv); - leftStepR = (s32)(((s32)(video::getRed(v2->Color)<<8) - leftR) * tmpDiv); - leftStepG = (s32)(((s32)(video::getGreen(v2->Color)<<8) - leftG) * tmpDiv); - leftStepB = (s32)(((s32)(video::getBlue(v2->Color)<<8) - leftB) * tmpDiv); - leftTxStep = (s32)((v2->TCoords.X - leftTx) * tmpDiv); - leftTyStep = (s32)((v2->TCoords.Y - leftTy) * tmpDiv); - } - - - // do it twice, once for the first half of the triangle, - // end then for the second half. - - for (s32 triangleHalf=0; triangleHalf<2; ++triangleHalf) - { - if (spanEnd > ViewPortRect.LowerRightCorner.Y) - spanEnd = ViewPortRect.LowerRightCorner.Y; - - // if the span <0, than we can skip these spans, - // and proceed to the next spans which are really on the screen. - if (span < ViewPortRect.UpperLeftCorner.Y) - { - // we'll use leftx as temp variable - if (spanEnd < ViewPortRect.UpperLeftCorner.Y) - { - leftx = spanEnd - span; - span = spanEnd; - } - else - { - leftx = ViewPortRect.UpperLeftCorner.Y - span; - span = ViewPortRect.UpperLeftCorner.Y; - } - - leftxf += leftdeltaxf*leftx; - rightxf += rightdeltaxf*leftx; - targetSurface += SurfaceWidth*leftx; - zTarget += SurfaceWidth*leftx; - leftZValue += leftZStep*leftx; - rightZValue += rightZStep*leftx; - - leftR += leftStepR*leftx; - leftG += leftStepG*leftx; - leftB += leftStepB*leftx; - rightR += rightStepR*leftx; - rightG += rightStepG*leftx; - rightB += rightStepB*leftx; - - leftTx += leftTxStep*leftx; - leftTy += leftTyStep*leftx; - rightTx += rightTxStep*leftx; - rightTy += rightTyStep*leftx; - } - - - // the main loop. Go through every span and draw it. - - while (span < spanEnd) - { - leftx = (s32)(leftxf); - rightx = (s32)(rightxf + 0.5f); - - // perform some clipping - - if (leftx>=ViewPortRect.UpperLeftCorner.X && - leftx<=ViewPortRect.LowerRightCorner.X) - { - if (leftZValue > *(zTarget + leftx)) - { - *(zTarget + leftx) = leftZValue; - color = lockedTexture[((leftTy>>8)&textureYMask) * lockedTextureWidth + ((leftTx>>8)&textureXMask)]; - *(targetSurface + leftx) = video::RGB16(video::getRed(color) * (leftR>>8) >>2, - video::getGreen(color) * (leftG>>8) >>2, - video::getBlue(color) * (leftR>>8) >>2); - } - } - - - if (rightx>=ViewPortRect.UpperLeftCorner.X && - rightx<=ViewPortRect.LowerRightCorner.X) - { - if (rightZValue > *(zTarget + rightx)) - { - *(zTarget + rightx) = rightZValue; - color = lockedTexture[((rightTy>>8)&textureYMask) * lockedTextureWidth + ((rightTx>>8)&textureXMask)]; - *(targetSurface + rightx) = video::RGB16(video::getRed(color) * (rightR>>8) >>2, - video::getGreen(color) * (rightG>>8) >>2, - video::getBlue(color) * (rightR>>8) >>2); - } - - } - - leftxf += leftdeltaxf; - rightxf += rightdeltaxf; - ++span; - targetSurface += SurfaceWidth; - zTarget += SurfaceWidth; - leftZValue += leftZStep; - rightZValue += rightZStep; - - leftR += leftStepR; - leftG += leftStepG; - leftB += leftStepB; - rightR += rightStepR; - rightG += rightStepG; - rightB += rightStepB; - - leftTx += leftTxStep; - leftTy += leftTyStep; - rightTx += rightTxStep; - rightTy += rightTyStep; - } - - if (triangleHalf>0) // break, we've gout only two halves - break; - - - // setup variables for second half of the triangle. - - if (longest < 0.0f) - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - rightdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - rightxf = (f32)v2->Pos.X; - - rightZValue = v2->ZValue; - rightZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); - - rightR = video::getRed(v2->Color)<<8; - rightG = video::getGreen(v2->Color)<<8; - rightB = video::getBlue(v2->Color)<<8; - rightStepR = (s32)(((s32)(video::getRed(v3->Color)<<8) - rightR) * tmpDiv); - rightStepG = (s32)(((s32)(video::getGreen(v3->Color)<<8) - rightG) * tmpDiv); - rightStepB = (s32)(((s32)(video::getBlue(v3->Color)<<8) - rightB) * tmpDiv); - - rightTx = v2->TCoords.X; - rightTy = v2->TCoords.Y; - rightTxStep = (s32)((v3->TCoords.X - rightTx) * tmpDiv); - rightTyStep = (s32)((v3->TCoords.Y - rightTy) * tmpDiv); - } - else - { - tmpDiv = 1.0f / (v3->Pos.Y - v2->Pos.Y); - - leftdeltaxf = (v3->Pos.X - v2->Pos.X) * tmpDiv; - leftxf = (f32)v2->Pos.X; - - leftZValue = v2->ZValue; - leftZStep = (s32)((v3->ZValue - v2->ZValue) * tmpDiv); - - leftR = video::getRed(v2->Color)<<8; - leftG = video::getGreen(v2->Color)<<8; - leftB = video::getBlue(v2->Color)<<8; - leftStepR = (s32)(((s32)(video::getRed(v3->Color)<<8) - leftR) * tmpDiv); - leftStepG = (s32)(((s32)(video::getGreen(v3->Color)<<8) - leftG) * tmpDiv); - leftStepB = (s32)(((s32)(video::getBlue(v3->Color)<<8) - leftB) * tmpDiv); - - leftTx = v2->TCoords.X; - leftTy = v2->TCoords.Y; - leftTxStep = (s32)((v3->TCoords.X - leftTx) * tmpDiv); - leftTyStep = (s32)((v3->TCoords.Y - leftTy) * tmpDiv); - } - - - spanEnd = v3->Pos.Y; - } - - } - - RenderTarget->unlock(); - ZBuffer->unlock(); - Texture->unlock(); - } -}; - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -ITriangleRenderer* createTriangleRendererTextureGouraudWire(IZBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_SOFTWARE_ - return new CTRTextureGouraudWire(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_SOFTWARE_ -} - -} // end namespace video -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CTRTextureLightMap2_Add.cpp b/irrlicht-1.6/source/Irrlicht/CTRTextureLightMap2_Add.cpp deleted file mode 100644 index b7b7244c5..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTRTextureLightMap2_Add.cpp +++ /dev/null @@ -1,672 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "IBurningShader.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -// compile flag for this file -#undef USE_ZBUFFER -#undef IPOL_Z -#undef CMP_Z -#undef WRITE_Z - -#undef IPOL_W -#undef CMP_W -#undef WRITE_W - -#undef SUBTEXEL -#undef INVERSE_W - -#undef IPOL_C0 -#undef IPOL_T0 -#undef IPOL_T1 - -// define render case -#define SUBTEXEL -#define INVERSE_W - -#define USE_ZBUFFER -#define IPOL_W -#define CMP_W -#define WRITE_W - -//#define IPOL_C0 -#define IPOL_T0 -#define IPOL_T1 - -// apply global override -#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef INVERSE_W -#endif - -#ifndef SOFTWARE_DRIVER_2_SUBTEXEL - #undef SUBTEXEL -#endif - -#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #undef IPOL_C0 -#endif - -#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) - #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef IPOL_W - #endif - #define IPOL_Z - - #ifdef CMP_W - #undef CMP_W - #define CMP_Z - #endif - - #ifdef WRITE_W - #undef WRITE_W - #define WRITE_Z - #endif - -#endif - -namespace irr -{ - -namespace video -{ - -class CTRTextureLightMap2_Add : public IBurningShader -{ -public: - - //! constructor - CTRTextureLightMap2_Add(IDepthBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - - -private: - void scanline_bilinear (); - - sScanConvertData scan; - sScanLineData line; - -}; - -//! constructor -CTRTextureLightMap2_Add::CTRTextureLightMap2_Add(IDepthBuffer* zbuffer) -: IBurningShader(zbuffer) -{ - #ifdef _DEBUG - setDebugName("CTRTextureLightMap2_Add"); - #endif -} - - - -/*! -*/ -REALINLINE void CTRTextureLightMap2_Add::scanline_bilinear () -{ - tVideoSample *dst; - -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC; -#endif -#ifdef IPOL_T0 - sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES]; -#endif - - // apply top-left fill-convention, left - xStart = core::ceil32( line.x[0] ); - xEnd = core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC = (line.c[1] - line.c[0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC * subPixel; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0] * subPixel; -#endif -#ifdef IPOL_T1 - line.t[1][0] += slopeT[1] * subPixel; -#endif -#endif - - dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; - -#ifdef USE_ZBUFFER - z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; -#endif - - - - -#ifdef BURNINGVIDEO_RENDERER_FAST - u32 dIndex = ( line.y & 3 ) << 2; - - -#else - // - tFixPoint r0, g0, b0; - tFixPoint r1, g1, b1; -#endif - - - for ( s32 i = 0; i <= dx; i++ ) - { -#ifdef CMP_Z - if ( line.z[0] < z[i] ) -#endif -#ifdef CMP_W - if ( line.w[0] >= z[i] ) -#endif - { - -#ifdef WRITE_Z - z[i] = line.z[0]; -#endif -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - -#ifdef BURNINGVIDEO_RENDERER_FAST - -#ifdef INVERSE_W - - const f32 inversew = fix_inverse32 ( line.w[0] ); - - const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ]; - - dst[i] = PixelAdd32 ( - getTexel_plain ( &IT[0], d + tofix ( line.t[0][0].x,inversew), - d + tofix ( line.t[0][0].y,inversew) ), - getTexel_plain ( &IT[1], d + tofix ( line.t[1][0].x,inversew), - d + tofix ( line.t[1][0].y,inversew) ) - ); -#else - const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ]; - - dst[i] = PixelAdd32 ( - getTexel_plain ( &IT[0], d + tofix ( line.t[0][0].x), - d + tofix ( line.t[0][0].y) ), - getTexel_plain ( &IT[1], d + tofix ( line.t[1][0].x), - d + tofix ( line.t[1][0].y) ) - ); - -#endif - -#else - const f32 inversew = fix_inverse32 ( line.w[0] ); - - getSample_texture ( r0, g0, b0, &IT[0], tofix ( line.t[0][0].x,inversew), tofix ( line.t[0][0].y,inversew) ); - getSample_texture ( r1, g1, b1, &IT[1], tofix ( line.t[0][1].x,inversew), tofix ( line.t[0][1].y,inversew) ); - - dst[i] = fix_to_color ( clampfix_maxcolor ( r0 + r1 ), - clampfix_maxcolor ( g0 + g1 ), - clampfix_maxcolor ( b0 + b1 ) - ); -#endif - - } - -#ifdef IPOL_Z - line.z[0] += slopeZ; -#endif -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0]; -#endif -#ifdef IPOL_T1 - line.t[1][0] += slopeT[1]; -#endif - } - -} - -void CTRTextureLightMap2_Add::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - // sort on height, y - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - - const f32 ca = c->Pos.y - a->Pos.y; - const f32 ba = b->Pos.y - a->Pos.y; - const f32 cb = c->Pos.y - b->Pos.y; - // calculate delta y of the edges - scan.invDeltaY[0] = core::reciprocal( ca ); - scan.invDeltaY[1] = core::reciprocal( ba ); - scan.invDeltaY[2] = core::reciprocal( cb ); - - if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) - return; - - // find if the major edge is left or right aligned - f32 temp[4]; - - temp[0] = a->Pos.x - c->Pos.x; - temp[1] = -ca; - temp[2] = b->Pos.x - a->Pos.x; - temp[3] = ba; - - scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1; - scan.right = 1 - scan.left; - - // calculate slopes for the major edge - scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; - scan.x[0] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; - scan.z[0] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; - scan.w[0] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; - scan.c[0] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; - scan.t[0][0] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; - scan.t[1][0] = a->Tex[1]; -#endif - - // top left fill convention y run - s32 yStart; - s32 yEnd; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - - // rasterize upper sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[1] ) - { - // calculate slopes for top edge - scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; - scan.x[1] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; - scan.z[1] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; - scan.w[1] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; - scan.c[1] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; - scan.t[0][1] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; - scan.t[1][1] = a->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = core::ceil32( a->Pos.y ); - yEnd = core::ceil32( b->Pos.y ) - 1; - -#ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - a->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0] * subPixel; - scan.t[0][1] += scan.slopeT[0][1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0] * subPixel; - scan.t[1][1] += scan.slopeT[1][1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t[0][scan.left] = scan.t[0][0]; - line.t[0][scan.right] = scan.t[0][1]; -#endif - -#ifdef IPOL_T1 - line.t[1][scan.left] = scan.t[1][0]; - line.t[1][scan.right] = scan.t[1][1]; -#endif - - // render a scanline - scanline_bilinear (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0]; - scan.t[0][1] += scan.slopeT[0][1]; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0]; - scan.t[1][1] += scan.slopeT[1][1]; -#endif - - } - } - - // rasterize lower sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[2] ) - { - // advance to middle point - if( (f32) 0.0 != scan.invDeltaY[1] ) - { - temp[0] = b->Pos.y - a->Pos.y; // dy - - scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; -#ifdef IPOL_Z - scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; -#endif -#ifdef IPOL_W - scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; -#endif -#ifdef IPOL_C0 - scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; -#endif -#ifdef IPOL_T0 - scan.t[0][0] = a->Tex[0] + scan.slopeT[0][0] * temp[0]; -#endif -#ifdef IPOL_T1 - scan.t[1][0] = a->Tex[1] + scan.slopeT[1][0] * temp[0]; -#endif - - } - - // calculate slopes for bottom edge - scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; - scan.x[1] = b->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; - scan.z[1] = b->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; - scan.w[1] = b->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; - scan.c[1] = b->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; - scan.t[0][1] = b->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; - scan.t[1][1] = b->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = core::ceil32( b->Pos.y ); - yEnd = core::ceil32( c->Pos.y ) - 1; - -#ifdef SUBTEXEL - - subPixel = ( (f32) yStart ) - b->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0] * subPixel; - scan.t[0][1] += scan.slopeT[0][1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0] * subPixel; - scan.t[1][1] += scan.slopeT[1][1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t[0][scan.left] = scan.t[0][0]; - line.t[0][scan.right] = scan.t[0][1]; -#endif - -#ifdef IPOL_T1 - line.t[1][scan.left] = scan.t[1][0]; - line.t[1][scan.right] = scan.t[1][1]; -#endif - - // render a scanline - scanline_bilinear (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0]; - scan.t[0][1] += scan.slopeT[0][1]; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0]; - scan.t[1][1] += scan.slopeT[1][1]; -#endif - - } - } - - -} - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - -//! creates a flat triangle renderer -IBurningShader* createTriangleRendererTextureLightMap2_Add(IDepthBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CTRTextureLightMap2_Add(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - -} // end namespace video -} // end namespace irr - - - diff --git a/irrlicht-1.6/source/Irrlicht/CTRTextureLightMap2_M1.cpp b/irrlicht-1.6/source/Irrlicht/CTRTextureLightMap2_M1.cpp deleted file mode 100644 index f1b262b97..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTRTextureLightMap2_M1.cpp +++ /dev/null @@ -1,644 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "IBurningShader.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -// compile flag for this file -#undef USE_ZBUFFER -#undef IPOL_Z -#undef CMP_Z -#undef WRITE_Z - -#undef IPOL_W -#undef CMP_W -#undef WRITE_W - -#undef SUBTEXEL -#undef INVERSE_W - -#undef IPOL_C0 -#undef IPOL_T0 -#undef IPOL_T1 - -// define render case -#define SUBTEXEL -#define INVERSE_W - -#define USE_ZBUFFER -#define IPOL_W -#define CMP_W -#define WRITE_W - -//#define IPOL_C0 -#define IPOL_T0 -#define IPOL_T1 - -// apply global override -#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef INVERSE_W -#endif - -#ifndef SOFTWARE_DRIVER_2_SUBTEXEL - #undef SUBTEXEL -#endif - -#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #undef IPOL_C0 -#endif - -#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) - #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef IPOL_W - #endif - #define IPOL_Z - - #ifdef CMP_W - #undef CMP_W - #define CMP_Z - #endif - - #ifdef WRITE_W - #undef WRITE_W - #define WRITE_Z - #endif - -#endif - -namespace irr -{ - -namespace video -{ - -class CTRTextureLightMap2_M1 : public IBurningShader -{ -public: - - //! constructor - CTRTextureLightMap2_M1(IDepthBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - - -private: - void scanline_bilinear2 (); - - sScanLineData line; - -}; - -//! constructor -CTRTextureLightMap2_M1::CTRTextureLightMap2_M1(IDepthBuffer* zbuffer) -: IBurningShader(zbuffer) -{ - #ifdef _DEBUG - setDebugName("CTRTextureLightMap2_M1"); - #endif -} - -/*! -*/ -REALINLINE void CTRTextureLightMap2_M1::scanline_bilinear2 () -{ - tVideoSample *dst; - fp24 *z; - - s32 xStart; - s32 xEnd; - s32 dx; - s32 i; - - - // apply top-left fill-convention, left - xStart = core::ceil32( line.x[0] ); - xEnd = core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - - // search z-buffer for first not occulled pixel - z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; - - // subTexel - const f32 subPixel = ( (f32) xStart ) - line.x[0]; - -#ifdef IPOL_W - const f32 b = (line.w[1] - line.w[0]) * invDeltaX; - f32 a = line.w[0] + ( b * subPixel ); - - i = 0; - - while ( a <= z[i] ) - { - a += b; - - i += 1; - if ( i > dx ) - return; - - } - - // lazy setup rest of scanline - - line.w[0] = a; - line.w[1] = b; -#else - const f32 b = (line.z[1] - line.z[0]) * invDeltaX; - f32 a = line.z[0] + ( b * subPixel ); - - i = 0; - - while ( a > z[i] ) - { - a += b; - - i += 1; - if ( i > dx ) - return; - - } - - // lazy setup rest of scanline - - line.z[0] = a; - line.z[1] = b; -#endif - dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; - - a = (f32) i + subPixel; - - line.t[0][1] = (line.t[0][1] - line.t[0][0]) * invDeltaX; - line.t[1][1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; - - line.t[0][0] += line.t[0][1] * a; - line.t[1][0] += line.t[1][1] * a; - - -#ifdef BURNINGVIDEO_RENDERER_FAST - u32 dIndex = ( line.y & 3 ) << 2; - - tFixPoint r0, g0, b0; - tFixPoint r1, g1, b1; - -#else - // - tFixPoint r0, g0, b0; - tFixPoint r1, g1, b1; -#endif - - - for ( ;i <= dx; i++ ) - { -#ifdef IPOL_W - if ( line.w[0] >= z[i] ) - { - z[i] = line.w[0]; -#else - if ( line.z[0] < z[i] ) - { - z[i] = line.z[0]; -#endif - -#ifdef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - f32 inversew = fix_inverse32 ( line.w[0] ); -#else - f32 inversew = FIX_POINT_F32_MUL; -#endif - - - -#ifdef BURNINGVIDEO_RENDERER_FAST - - const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ]; - - getSample_texture ( r0, g0, b0, &IT[0], d + tofix ( line.t[0][0].x,inversew), d + tofix ( line.t[0][0].y,inversew) ); - getSample_texture ( r1, g1, b1, &IT[1], d + tofix ( line.t[1][0].x,inversew), d + tofix ( line.t[1][0].y,inversew) ); -#else - getSample_texture ( r0, g0, b0, &IT[0], tofix ( line.t[0][0].x,inversew), tofix ( line.t[0][0].y,inversew) ); - getSample_texture ( r1, g1, b1, &IT[1], tofix ( line.t[1][0].x,inversew), tofix ( line.t[1][0].y,inversew) ); - -#endif - - dst[i] = fix_to_color ( imulFix_tex1 ( r0, r1 ), - imulFix_tex1 ( g0, g1 ), - imulFix_tex1 ( b0, b1 ) - ); - } - -#ifdef IPOL_W - line.w[0] += line.w[1]; -#else - line.z[0] += line.z[1]; -#endif - line.t[0][0] += line.t[0][1]; - line.t[1][0] += line.t[1][1]; - } - -} - - - -void CTRTextureLightMap2_M1::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - sScanConvertData scan; - - // sort on height, y - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - - const f32 ca = c->Pos.y - a->Pos.y; - const f32 ba = b->Pos.y - a->Pos.y; - const f32 cb = c->Pos.y - b->Pos.y; - // calculate delta y of the edges - scan.invDeltaY[0] = core::reciprocal( ca ); - scan.invDeltaY[1] = core::reciprocal( ba ); - scan.invDeltaY[2] = core::reciprocal( cb ); - - if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) - return; - - // find if the major edge is left or right aligned - f32 temp[4]; - - temp[0] = a->Pos.x - c->Pos.x; - temp[1] = -ca; - temp[2] = b->Pos.x - a->Pos.x; - temp[3] = ba; - - scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1; - scan.right = 1 - scan.left; - - // calculate slopes for the major edge - scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; - scan.x[0] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; - scan.z[0] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; - scan.w[0] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; - scan.c[0] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; - scan.t[0][0] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; - scan.t[1][0] = a->Tex[1]; -#endif - - // top left fill convention y run - s32 yStart; - s32 yEnd; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - - // rasterize upper sub-triangle - if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) - { - // calculate slopes for top edge - scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; - scan.x[1] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; - scan.z[1] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; - scan.w[1] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; - scan.c[1] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; - scan.t[0][1] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; - scan.t[1][1] = a->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = core::ceil32( a->Pos.y ); - yEnd = core::ceil32( b->Pos.y ) - 1; - -#ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - a->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0] * subPixel; - scan.t[0][1] += scan.slopeT[0][1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0] * subPixel; - scan.t[1][1] += scan.slopeT[1][1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t[0][scan.left] = scan.t[0][0]; - line.t[0][scan.right] = scan.t[0][1]; -#endif - -#ifdef IPOL_T1 - line.t[1][scan.left] = scan.t[1][0]; - line.t[1][scan.right] = scan.t[1][1]; -#endif - - // render a scanline - scanline_bilinear2 (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0]; - scan.t[0][1] += scan.slopeT[0][1]; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0]; - scan.t[1][1] += scan.slopeT[1][1]; -#endif - - } - } - - // rasterize lower sub-triangle - //if ( (f32) 0.0 != scan.invDeltaY[2] ) - if ( F32_GREATER_0 ( scan.invDeltaY[2] ) ) - { - // advance to middle point - if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) - { - temp[0] = b->Pos.y - a->Pos.y; // dy - - scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; -#ifdef IPOL_Z - scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; -#endif -#ifdef IPOL_W - scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; -#endif -#ifdef IPOL_C0 - scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; -#endif -#ifdef IPOL_T0 - scan.t[0][0] = a->Tex[0] + scan.slopeT[0][0] * temp[0]; -#endif -#ifdef IPOL_T1 - scan.t[1][0] = a->Tex[1] + scan.slopeT[1][0] * temp[0]; -#endif - - } - - // calculate slopes for bottom edge - scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; - scan.x[1] = b->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; - scan.z[1] = b->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; - scan.w[1] = b->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; - scan.c[1] = b->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; - scan.t[0][1] = b->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; - scan.t[1][1] = b->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = core::ceil32( b->Pos.y ); - yEnd = core::ceil32( c->Pos.y ) - 1; - -#ifdef SUBTEXEL - - subPixel = ( (f32) yStart ) - b->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0] * subPixel; - scan.t[0][1] += scan.slopeT[0][1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0] * subPixel; - scan.t[1][1] += scan.slopeT[1][1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t[0][scan.left] = scan.t[0][0]; - line.t[0][scan.right] = scan.t[0][1]; -#endif - -#ifdef IPOL_T1 - line.t[1][scan.left] = scan.t[1][0]; - line.t[1][scan.right] = scan.t[1][1]; -#endif - - // render a scanline - scanline_bilinear2 (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0]; - scan.t[0][1] += scan.slopeT[0][1]; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0]; - scan.t[1][1] += scan.slopeT[1][1]; -#endif - - } - } - -} - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - - - -//! creates a flat triangle renderer -IBurningShader* createTriangleRendererTextureLightMap2_M1(IDepthBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CTRTextureLightMap2_M1(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - -} // end namespace video -} // end namespace irr - - - diff --git a/irrlicht-1.6/source/Irrlicht/CTRTextureLightMap2_M2.cpp b/irrlicht-1.6/source/Irrlicht/CTRTextureLightMap2_M2.cpp deleted file mode 100644 index 2591502b8..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTRTextureLightMap2_M2.cpp +++ /dev/null @@ -1,644 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "IBurningShader.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -// compile flag for this file -#undef USE_ZBUFFER -#undef IPOL_Z -#undef CMP_Z -#undef WRITE_Z - -#undef IPOL_W -#undef CMP_W -#undef WRITE_W - -#undef SUBTEXEL -#undef INVERSE_W - -#undef IPOL_C0 -#undef IPOL_T0 -#undef IPOL_T1 - -// define render case -#define SUBTEXEL -#define INVERSE_W - -#define USE_ZBUFFER -#define IPOL_W -#define CMP_W -#define WRITE_W - -//#define IPOL_C0 -#define IPOL_T0 -#define IPOL_T1 - -// apply global override -#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef INVERSE_W -#endif - -#ifndef SOFTWARE_DRIVER_2_SUBTEXEL - #undef SUBTEXEL -#endif - -#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #undef IPOL_C0 -#endif - -#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) - #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef IPOL_W - #endif - #define IPOL_Z - - #ifdef CMP_W - #undef CMP_W - #define CMP_Z - #endif - - #ifdef WRITE_W - #undef WRITE_W - #define WRITE_Z - #endif - -#endif - -namespace irr -{ - -namespace video -{ - -class CTRTextureLightMap2_M2 : public IBurningShader -{ -public: - - //! constructor - CTRTextureLightMap2_M2(IDepthBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - - -private: - void scanline_bilinear2 (); - - sScanLineData line; - -}; - -//! constructor -CTRTextureLightMap2_M2::CTRTextureLightMap2_M2(IDepthBuffer* zbuffer) -: IBurningShader(zbuffer) -{ - #ifdef _DEBUG - setDebugName("CTRTextureLightMap2_M2"); - #endif -} - -/*! -*/ -REALINLINE void CTRTextureLightMap2_M2::scanline_bilinear2 () -{ - tVideoSample *dst; - fp24 *z; - - s32 xStart; - s32 xEnd; - s32 dx; - s32 i; - - - // apply top-left fill-convention, left - xStart = core::ceil32( line.x[0] ); - xEnd = core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - - // search z-buffer for first not occulled pixel - z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; - - // subTexel - const f32 subPixel = ( (f32) xStart ) - line.x[0]; - -#ifdef IPOL_W - const f32 b = (line.w[1] - line.w[0]) * invDeltaX; - f32 a = line.w[0] + ( b * subPixel ); - - i = 0; - - while ( a <= z[i] ) - { - a += b; - - i += 1; - if ( i > dx ) - return; - - } - - // lazy setup rest of scanline - - line.w[0] = a; - line.w[1] = b; -#else - const f32 b = (line.z[1] - line.z[0]) * invDeltaX; - f32 a = line.z[0] + ( b * subPixel ); - - i = 0; - - while ( a > z[i] ) - { - a += b; - - i += 1; - if ( i > dx ) - return; - - } - - // lazy setup rest of scanline - - line.z[0] = a; - line.z[1] = b; -#endif - dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; - - a = (f32) i + subPixel; - - line.t[0][1] = (line.t[0][1] - line.t[0][0]) * invDeltaX; - line.t[1][1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; - - line.t[0][0] += line.t[0][1] * a; - line.t[1][0] += line.t[1][1] * a; - - -#ifdef BURNINGVIDEO_RENDERER_FAST - u32 dIndex = ( line.y & 3 ) << 2; - - tFixPoint r0, g0, b0; - tFixPoint r1, g1, b1; - -#else - // - tFixPoint r0, g0, b0; - tFixPoint r1, g1, b1; -#endif - - - for ( ;i <= dx; i++ ) - { -#ifdef IPOL_W - if ( line.w[0] >= z[i] ) - { - z[i] = line.w[0]; -#else - if ( line.z[0] < z[i] ) - { - z[i] = line.z[0]; -#endif - -#ifdef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - f32 inversew = fix_inverse32 ( line.w[0] ); -#else - f32 inversew = FIX_POINT_F32_MUL; -#endif - - - -#ifdef BURNINGVIDEO_RENDERER_FAST - - const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ]; - - getSample_texture ( r0, g0, b0, &IT[0], d + tofix ( line.t[0][0].x,inversew), d + tofix ( line.t[0][0].y,inversew) ); - getSample_texture ( r1, g1, b1, &IT[1], d + tofix ( line.t[1][0].x,inversew), d + tofix ( line.t[1][0].y,inversew) ); -#else - getSample_texture ( r0, g0, b0, &IT[0], tofix ( line.t[0][0].x,inversew), tofix ( line.t[0][0].y,inversew) ); - getSample_texture ( r1, g1, b1, &IT[1], tofix ( line.t[1][0].x,inversew), tofix ( line.t[1][0].y,inversew) ); - -#endif - - dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex2 ( r0, r1 ) ), - clampfix_maxcolor ( imulFix_tex2 ( g0, g1 ) ), - clampfix_maxcolor ( imulFix_tex2 ( b0, b1 ) ) - ); - } - -#ifdef IPOL_W - line.w[0] += line.w[1]; -#else - line.z[0] += line.z[1]; -#endif - line.t[0][0] += line.t[0][1]; - line.t[1][0] += line.t[1][1]; - } - -} - - - -void CTRTextureLightMap2_M2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - sScanConvertData scan; - - // sort on height, y - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - - const f32 ca = c->Pos.y - a->Pos.y; - const f32 ba = b->Pos.y - a->Pos.y; - const f32 cb = c->Pos.y - b->Pos.y; - // calculate delta y of the edges - scan.invDeltaY[0] = core::reciprocal( ca ); - scan.invDeltaY[1] = core::reciprocal( ba ); - scan.invDeltaY[2] = core::reciprocal( cb ); - - if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) - return; - - // find if the major edge is left or right aligned - f32 temp[4]; - - temp[0] = a->Pos.x - c->Pos.x; - temp[1] = -ca; - temp[2] = b->Pos.x - a->Pos.x; - temp[3] = ba; - - scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1; - scan.right = 1 - scan.left; - - // calculate slopes for the major edge - scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; - scan.x[0] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; - scan.z[0] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; - scan.w[0] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; - scan.c[0] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; - scan.t[0][0] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; - scan.t[1][0] = a->Tex[1]; -#endif - - // top left fill convention y run - s32 yStart; - s32 yEnd; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - - // rasterize upper sub-triangle - if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) - { - // calculate slopes for top edge - scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; - scan.x[1] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; - scan.z[1] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; - scan.w[1] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; - scan.c[1] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; - scan.t[0][1] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; - scan.t[1][1] = a->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = core::ceil32( a->Pos.y ); - yEnd = core::ceil32( b->Pos.y ) - 1; - -#ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - a->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0] * subPixel; - scan.t[0][1] += scan.slopeT[0][1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0] * subPixel; - scan.t[1][1] += scan.slopeT[1][1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t[0][scan.left] = scan.t[0][0]; - line.t[0][scan.right] = scan.t[0][1]; -#endif - -#ifdef IPOL_T1 - line.t[1][scan.left] = scan.t[1][0]; - line.t[1][scan.right] = scan.t[1][1]; -#endif - - // render a scanline - scanline_bilinear2 (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0]; - scan.t[0][1] += scan.slopeT[0][1]; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0]; - scan.t[1][1] += scan.slopeT[1][1]; -#endif - - } - } - - // rasterize lower sub-triangle - //if ( (f32) 0.0 != scan.invDeltaY[2] ) - if ( F32_GREATER_0 ( scan.invDeltaY[2] ) ) - { - // advance to middle point - if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) - { - temp[0] = b->Pos.y - a->Pos.y; // dy - - scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; -#ifdef IPOL_Z - scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; -#endif -#ifdef IPOL_W - scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; -#endif -#ifdef IPOL_C0 - scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; -#endif -#ifdef IPOL_T0 - scan.t[0][0] = a->Tex[0] + scan.slopeT[0][0] * temp[0]; -#endif -#ifdef IPOL_T1 - scan.t[1][0] = a->Tex[1] + scan.slopeT[1][0] * temp[0]; -#endif - - } - - // calculate slopes for bottom edge - scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; - scan.x[1] = b->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; - scan.z[1] = b->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; - scan.w[1] = b->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; - scan.c[1] = b->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; - scan.t[0][1] = b->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; - scan.t[1][1] = b->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = core::ceil32( b->Pos.y ); - yEnd = core::ceil32( c->Pos.y ) - 1; - -#ifdef SUBTEXEL - - subPixel = ( (f32) yStart ) - b->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0] * subPixel; - scan.t[0][1] += scan.slopeT[0][1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0] * subPixel; - scan.t[1][1] += scan.slopeT[1][1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t[0][scan.left] = scan.t[0][0]; - line.t[0][scan.right] = scan.t[0][1]; -#endif - -#ifdef IPOL_T1 - line.t[1][scan.left] = scan.t[1][0]; - line.t[1][scan.right] = scan.t[1][1]; -#endif - - // render a scanline - scanline_bilinear2 (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0]; - scan.t[0][1] += scan.slopeT[0][1]; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0]; - scan.t[1][1] += scan.slopeT[1][1]; -#endif - - } - } - -} - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - - - -//! creates a flat triangle renderer -IBurningShader* createTriangleRendererTextureLightMap2_M2(IDepthBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CTRTextureLightMap2_M2(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - -} // end namespace video -} // end namespace irr - - - diff --git a/irrlicht-1.6/source/Irrlicht/CTRTextureLightMap2_M4.cpp b/irrlicht-1.6/source/Irrlicht/CTRTextureLightMap2_M4.cpp deleted file mode 100644 index 80a245e78..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTRTextureLightMap2_M4.cpp +++ /dev/null @@ -1,1344 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "IBurningShader.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -// compile flag for this file -#undef USE_ZBUFFER -#undef IPOL_Z -#undef CMP_Z -#undef WRITE_Z - -#undef IPOL_W -#undef CMP_W -#undef WRITE_W - -#undef SUBTEXEL -#undef INVERSE_W - -#undef IPOL_C0 -#undef IPOL_T0 -#undef IPOL_T1 - -// define render case -#define SUBTEXEL -#define INVERSE_W - -#define USE_ZBUFFER -#define IPOL_W -#define CMP_W -#define WRITE_W - -//#define IPOL_C0 -#define IPOL_T0 -#define IPOL_T1 - -// apply global override -#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef INVERSE_W -#endif - -#ifndef SOFTWARE_DRIVER_2_SUBTEXEL - #undef SUBTEXEL -#endif - -#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #undef IPOL_C0 -#endif - -#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) - #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef IPOL_W - #endif - #define IPOL_Z - - #ifdef CMP_W - #undef CMP_W - #define CMP_Z - #endif - - #ifdef WRITE_W - #undef WRITE_W - #define WRITE_Z - #endif - -#endif - -namespace irr -{ - -namespace video -{ - -class CTRTextureLightMap2_M4 : public IBurningShader -{ -public: - - //! constructor - CTRTextureLightMap2_M4(IDepthBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - - -private: - - void drawTriangle_Min ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - void drawTriangle_Mag ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - - void scanline_bilinear (); - void scanline_bilinear2_mag (); - void scanline_bilinear2_min (); - - sScanLineData line; - -}; - -//! constructor -CTRTextureLightMap2_M4::CTRTextureLightMap2_M4(IDepthBuffer* zbuffer) -: IBurningShader(zbuffer) -{ - #ifdef _DEBUG - setDebugName("CTRTextureLightMap2_M4"); - #endif -} - -/*! -*/ -REALINLINE void CTRTextureLightMap2_M4::scanline_bilinear2_mag () -{ - tVideoSample *dst; - fp24 *z; - - // apply top-left fill-convention, left - const s32 xStart = irr::core::ceil32( line.x[0] ); - const s32 xEnd = irr::core::ceil32( line.x[1] ) - 1; - s32 dx; - s32 i; - - - dx = xEnd - xStart; - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - - // search z-buffer for first not occulled pixel - i = ( line.y * RenderTarget->getDimension().Width ) + xStart; - z = (fp24*) DepthBuffer->lock() + i; - dst = (tVideoSample*)RenderTarget->lock() + i; - - // subTexel - const f32 subPixel = ( (f32) xStart ) - line.x[0]; - -#ifdef IPOL_W - const fp24 b = (line.w[1] - line.w[0]) * invDeltaX; - fp24 a = line.w[0] + ( b * subPixel ); - - i = 0; - - while ( a < z[i] ) - { - a += b; - - i += 1; - if ( i > dx ) - return; - - } - - // lazy setup rest of scanline - - line.w[0] = a; - line.w[1] = b; -#else - const f32 b = (line.z[1] - line.z[0]) * invDeltaX; - f32 a = line.z[0] + ( b * subPixel ); - - i = 0; - - while ( a > z[i] ) - { - a += b; - - i += 1; - if ( i > dx ) - return; - - } - - // lazy setup rest of scanline - - line.z[0] = a; - line.z[1] = b; -#endif - - a = (f32) i + subPixel; - - line.t[0][1] = (line.t[0][1] - line.t[0][0]) * invDeltaX; - line.t[1][1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; - - line.t[0][0] += line.t[0][1] * a; - line.t[1][0] += line.t[1][1] * a; - - -#ifdef BURNINGVIDEO_RENDERER_FAST - u32 dIndex = ( line.y & 3 ) << 2; - - tFixPoint r0, g0, b0; - tFixPoint r1, g1, b1; - -#else - // - tFixPoint r0, g0, b0; - tFixPoint r1, g1, b1; -#endif - - - for ( ;i <= dx; i++ ) - { -#ifdef IPOL_W - if ( line.w[0] >= z[i] ) - { - z[i] = line.w[0]; -#else - if ( line.z[0] < z[i] ) - { - z[i] = line.z[0]; -#endif - -#ifdef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - f32 inversew = fix_inverse32 ( line.w[0] ); -#else - f32 inversew = FIX_POINT_F32_MUL; -#endif - - - -#ifdef BURNINGVIDEO_RENDERER_FAST - - const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ]; - - getSample_texture ( r0, g0, b0, &IT[0], d + tofix ( line.t[0][0].x,inversew), d + tofix ( line.t[0][0].y,inversew) ); - getSample_texture ( r1, g1, b1, &IT[1], d + tofix ( line.t[1][0].x,inversew), d + tofix ( line.t[1][0].y,inversew) ); -#else - getSample_texture ( r0, g0, b0, &IT[0], tofix ( line.t[0][0].x,inversew), tofix ( line.t[0][0].y,inversew) ); - getSample_texture ( r1, g1, b1, &IT[1], tofix ( line.t[1][0].x,inversew), tofix ( line.t[1][0].y,inversew) ); - -#endif - - dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex4 ( r0, r1 ) ), - clampfix_maxcolor ( imulFix_tex4 ( g0, g1 ) ), - clampfix_maxcolor ( imulFix_tex4 ( b0, b1 ) ) - ); - } - -#ifdef IPOL_W - line.w[0] += line.w[1]; -#else - line.z[0] += line.z[1]; -#endif - line.t[0][0] += line.t[0][1]; - line.t[1][0] += line.t[1][1]; - } - -} - -/*! -*/ -REALINLINE void CTRTextureLightMap2_M4::scanline_bilinear2_min () -{ - tVideoSample *dst; - fp24 *z; - - s32 xStart; - s32 xEnd; - s32 dx; - s32 i; - - - // apply top-left fill-convention, left - xStart = core::ceil32( line.x[0] ); - xEnd = core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - - // search z-buffer for first not occulled pixel - z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; - - // subTexel - const f32 subPixel = ( (f32) xStart ) - line.x[0]; - -#ifdef IPOL_W - const f32 b = (line.w[1] - line.w[0]) * invDeltaX; - f32 a = line.w[0] + ( b * subPixel ); - - i = 0; - - while ( a <= z[i] ) - { - a += b; - - i += 1; - if ( i > dx ) - return; - - } - - // lazy setup rest of scanline - - line.w[0] = a; - line.w[1] = b; -#else - const f32 b = (line.z[1] - line.z[0]) * invDeltaX; - f32 a = line.z[0] + ( b * subPixel ); - - i = 0; - - while ( a > z[i] ) - { - a += b; - - i += 1; - if ( i > dx ) - return; - - } - - // lazy setup rest of scanline - - line.z[0] = a; - line.z[1] = b; -#endif - dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; - - a = (f32) i + subPixel; - - line.t[0][1] = (line.t[0][1] - line.t[0][0]) * invDeltaX; - line.t[1][1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; - - line.t[0][0] += line.t[0][1] * a; - line.t[1][0] += line.t[1][1] * a; - - - tFixPoint r0, g0, b0; - tFixPoint r1, g1, b1; - - - for ( ;i <= dx; i++ ) - { -#ifdef IPOL_W - if ( line.w[0] >= z[i] ) - { - z[i] = line.w[0]; -#else - if ( line.z[0] < z[i] ) - { - z[i] = line.z[0]; -#endif - -#ifdef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - f32 inversew = fix_inverse32 ( line.w[0] ); -#else - f32 inversew = FIX_POINT_F32_MUL; -#endif - - - getTexel_fix ( r0, g0, b0, &IT[0], tofix ( line.t[0][0].x,inversew), tofix ( line.t[0][0].y,inversew) ); - getTexel_fix ( r1, g1, b1, &IT[1], tofix ( line.t[1][0].x,inversew), tofix ( line.t[1][0].y,inversew) ); - - dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex4 ( r0, r1 ) ), - clampfix_maxcolor ( imulFix_tex4 ( g0, g1 ) ), - clampfix_maxcolor ( imulFix_tex4 ( b0, b1 ) ) - ); - } - -#ifdef IPOL_W - line.w[0] += line.w[1]; -#else - line.z[0] += line.z[1]; -#endif - line.t[0][0] += line.t[0][1]; - line.t[1][0] += line.t[1][1]; - } - -} - - -#if 0 -/*! -*/ -REALINLINE void CTRTextureLightMap2_M4::scanline_bilinear () -{ - tVideoSample *dst; - -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC; -#endif -#ifdef IPOL_T0 - sVec2 slopeT[0]; -#endif -#ifdef IPOL_T1 - sVec2 slopeT[1]; -#endif - - // apply top-left fill-convention, left - xStart = core::ceil32( line.x[0] ); - xEnd = core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC = (line.c[1] - line.c[0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC * subPixel; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0] * subPixel; -#endif -#ifdef IPOL_T1 - line.t[1][0] += slopeT[1] * subPixel; -#endif -#endif - - dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; - -#ifdef USE_ZBUFFER - z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; -#endif - - -#ifdef INVERSE_W - f32 inversew; -#endif - - tFixPointu tx0, tx1; - tFixPointu ty0, ty1; - - tFixPoint r0, g0, b0; - tFixPoint r1, g1, b1; - tFixPoint r2, g2, b2; - -#ifdef IPOL_C0 - tFixPoint r3, g3, b3; -#endif - - for ( s32 i = 0; i <= dx; i++ ) - { -#ifdef CMP_Z - if ( line.z[0] < z[i] ) -#endif -#ifdef CMP_W - if ( line.w[0] >= z[i] ) -#endif - { -#ifdef INVERSE_W - inversew = fix_inverse32 ( line.w[0] ); - - tx0 = tofix ( line.t[0][0].x,inversew); - ty0 = tofix ( line.t[0][0].y,inversew); - tx1 = tofix ( line.t[1][0].x,inversew); - ty1 = tofix ( line.t[1][0].y,inversew); - -#ifdef IPOL_C0 - r3 = tofix ( line.c[0].y ,inversew ); - g3 = tofix ( line.c[0].z ,inversew ); - b3 = tofix ( line.c[0].w ,inversew ); -#endif - -#else - tx0 = tofix ( line.t[0][0].x ); - ty0 = tofix ( line.t[0][0].y ); - tx1 = tofix ( line.t[1][0].x ); - ty1 = tofix ( line.t[1][0].y ); - -#endif - getSample_texture ( r0, g0, b0, &IT[0], tx0, ty0 ); - getSample_texture ( r1, g1, b1, &IT[1], tx1, ty1 ); - -#ifdef IPOL_C0 - r2 = imulFix ( r0, r3 ); - g2 = imulFix ( g0, g3 ); - b2 = imulFix ( b0, b3 ); - - r2 = clampfix_maxcolor ( imulFix_tex4 ( r2, r1 ) ); - g2 = clampfix_maxcolor ( imulFix_tex4 ( g2, g1 ) ); - b2 = clampfix_maxcolor ( imulFix_tex4 ( b2, b1 ) ); -/* - r2 = r3 << 8; - g2 = g3 << 8; - b2 = b3 << 8; -*/ -#else - r2 = clampfix_maxcolor ( imulFix_tex4 ( r0, r1 ) ); - g2 = clampfix_maxcolor ( imulFix_tex4 ( g0, g1 ) ); - b2 = clampfix_maxcolor ( imulFix_tex4 ( b0, b1 ) ); -#endif - - - dst[i] = fix_to_color ( r2, g2, b2 ); - -#ifdef WRITE_Z - z[i] = line.z[0]; -#endif -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - } - -#ifdef IPOL_Z - line.z[0] += slopeZ; -#endif -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_C0 - line.c[0] += slopeC; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0]; -#endif -#ifdef IPOL_T1 - line.t[1][0] += slopeT[1]; -#endif - } - -} -#endif - - -//#ifdef BURNINGVIDEO_RENDERER_FAST -#if 1 - -void CTRTextureLightMap2_M4::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - if ( IT[0].lodLevel <= 2 ) - drawTriangle_Mag ( a, b, c ); - else - drawTriangle_Min ( a, b, c ); -} - -void CTRTextureLightMap2_M4::drawTriangle_Min ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - sScanConvertData scan; - - // sort on height, y - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - - const f32 ca = c->Pos.y - a->Pos.y; - const f32 ba = b->Pos.y - a->Pos.y; - const f32 cb = c->Pos.y - b->Pos.y; - // calculate delta y of the edges - scan.invDeltaY[0] = core::reciprocal( ca ); - scan.invDeltaY[1] = core::reciprocal( ba ); - scan.invDeltaY[2] = core::reciprocal( cb ); - - if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) - return; - - // find if the major edge is left or right aligned - f32 temp[4]; - - temp[0] = a->Pos.x - c->Pos.x; - temp[1] = -ca; - temp[2] = b->Pos.x - a->Pos.x; - temp[3] = ba; - - scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1; - scan.right = 1 - scan.left; - - // calculate slopes for the major edge - scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; - scan.x[0] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; - scan.z[0] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; - scan.w[0] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; - scan.c[0] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; - scan.t[0][0] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; - scan.t[1][0] = a->Tex[1]; -#endif - - // top left fill convention y run - s32 yStart; - s32 yEnd; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - - // rasterize upper sub-triangle - if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) - { - // calculate slopes for top edge - scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; - scan.x[1] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; - scan.z[1] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; - scan.w[1] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; - scan.c[1] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; - scan.t[0][1] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; - scan.t[1][1] = a->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = core::ceil32( a->Pos.y ); - yEnd = core::ceil32( b->Pos.y ) - 1; - -#ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - a->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0] * subPixel; - scan.t[0][1] += scan.slopeT[0][1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0] * subPixel; - scan.t[1][1] += scan.slopeT[1][1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t[0][scan.left] = scan.t[0][0]; - line.t[0][scan.right] = scan.t[0][1]; -#endif - -#ifdef IPOL_T1 - line.t[1][scan.left] = scan.t[1][0]; - line.t[1][scan.right] = scan.t[1][1]; -#endif - - // render a scanline - scanline_bilinear2_min (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0]; - scan.t[0][1] += scan.slopeT[0][1]; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0]; - scan.t[1][1] += scan.slopeT[1][1]; -#endif - - } - } - - // rasterize lower sub-triangle - //if ( (f32) 0.0 != scan.invDeltaY[2] ) - if ( F32_GREATER_0 ( scan.invDeltaY[2] ) ) - { - // advance to middle point - if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) - { - temp[0] = b->Pos.y - a->Pos.y; // dy - - scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; -#ifdef IPOL_Z - scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; -#endif -#ifdef IPOL_W - scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; -#endif -#ifdef IPOL_C0 - scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; -#endif -#ifdef IPOL_T0 - scan.t[0][0] = a->Tex[0] + scan.slopeT[0][0] * temp[0]; -#endif -#ifdef IPOL_T1 - scan.t[1][0] = a->Tex[1] + scan.slopeT[1][0] * temp[0]; -#endif - - } - - // calculate slopes for bottom edge - scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; - scan.x[1] = b->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; - scan.z[1] = b->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; - scan.w[1] = b->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; - scan.c[1] = b->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; - scan.t[0][1] = b->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; - scan.t[1][1] = b->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = core::ceil32( b->Pos.y ); - yEnd = core::ceil32( c->Pos.y ) - 1; - -#ifdef SUBTEXEL - - subPixel = ( (f32) yStart ) - b->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0] * subPixel; - scan.t[0][1] += scan.slopeT[0][1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0] * subPixel; - scan.t[1][1] += scan.slopeT[1][1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t[0][scan.left] = scan.t[0][0]; - line.t[0][scan.right] = scan.t[0][1]; -#endif - -#ifdef IPOL_T1 - line.t[1][scan.left] = scan.t[1][0]; - line.t[1][scan.right] = scan.t[1][1]; -#endif - - // render a scanline - scanline_bilinear2_min (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0]; - scan.t[0][1] += scan.slopeT[0][1]; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0]; - scan.t[1][1] += scan.slopeT[1][1]; -#endif - - } - } - -} - -void CTRTextureLightMap2_M4::drawTriangle_Mag ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) - -#else - -void CTRTextureLightMap2_M4::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) - -#endif - -{ - sScanConvertData scan; - - // sort on height, y - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - - const f32 ca = c->Pos.y - a->Pos.y; - const f32 ba = b->Pos.y - a->Pos.y; - const f32 cb = c->Pos.y - b->Pos.y; - // calculate delta y of the edges - scan.invDeltaY[0] = core::reciprocal( ca ); - scan.invDeltaY[1] = core::reciprocal( ba ); - scan.invDeltaY[2] = core::reciprocal( cb ); - - if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) - return; - - // find if the major edge is left or right aligned - f32 temp[4]; - - temp[0] = a->Pos.x - c->Pos.x; - temp[1] = -ca; - temp[2] = b->Pos.x - a->Pos.x; - temp[3] = ba; - - scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1; - scan.right = 1 - scan.left; - - // calculate slopes for the major edge - scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; - scan.x[0] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; - scan.z[0] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; - scan.w[0] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; - scan.c[0] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; - scan.t[0][0] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; - scan.t[1][0] = a->Tex[1]; -#endif - - // top left fill convention y run - s32 yStart; - s32 yEnd; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - - - // rasterize upper sub-triangle - if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) - { - // calculate slopes for top edge - scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; - scan.x[1] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; - scan.z[1] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; - scan.w[1] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; - scan.c[1] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; - scan.t[0][1] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; - scan.t[1][1] = a->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = core::ceil32( a->Pos.y ); - yEnd = core::ceil32( b->Pos.y ) - 1; - -#ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - a->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0] * subPixel; - scan.t[0][1] += scan.slopeT[0][1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0] * subPixel; - scan.t[1][1] += scan.slopeT[1][1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t[0][scan.left] = scan.t[0][0]; - line.t[0][scan.right] = scan.t[0][1]; -#endif - -#ifdef IPOL_T1 - line.t[1][scan.left] = scan.t[1][0]; - line.t[1][scan.right] = scan.t[1][1]; -#endif - - // render a scanline - scanline_bilinear2_mag (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0]; - scan.t[0][1] += scan.slopeT[0][1]; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0]; - scan.t[1][1] += scan.slopeT[1][1]; -#endif - - } - } - - // rasterize lower sub-triangle - //if ( (f32) 0.0 != scan.invDeltaY[2] ) - if ( F32_GREATER_0 ( scan.invDeltaY[2] ) ) - { - // advance to middle point - if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) - { - temp[0] = b->Pos.y - a->Pos.y; // dy - - scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; -#ifdef IPOL_Z - scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; -#endif -#ifdef IPOL_W - scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; -#endif -#ifdef IPOL_C0 - scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; -#endif -#ifdef IPOL_T0 - scan.t[0][0] = a->Tex[0] + scan.slopeT[0][0] * temp[0]; -#endif -#ifdef IPOL_T1 - scan.t[1][0] = a->Tex[1] + scan.slopeT[1][0] * temp[0]; -#endif - - } - - // calculate slopes for bottom edge - scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; - scan.x[1] = b->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; - scan.z[1] = b->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; - scan.w[1] = b->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; - scan.c[1] = b->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; - scan.t[0][1] = b->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; - scan.t[1][1] = b->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = core::ceil32( b->Pos.y ); - yEnd = core::ceil32( c->Pos.y ) - 1; - -#ifdef SUBTEXEL - - subPixel = ( (f32) yStart ) - b->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0] * subPixel; - scan.c[1] += scan.slopeC[1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0] * subPixel; - scan.t[0][1] += scan.slopeT[0][1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0] * subPixel; - scan.t[1][1] += scan.slopeT[1][1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[scan.left] = scan.c[0]; - line.c[scan.right] = scan.c[1]; -#endif - -#ifdef IPOL_T0 - line.t[0][scan.left] = scan.t[0][0]; - line.t[0][scan.right] = scan.t[0][1]; -#endif - -#ifdef IPOL_T1 - line.t[1][scan.left] = scan.t[1][0]; - line.t[1][scan.right] = scan.t[1][1]; -#endif - - // render a scanline - scanline_bilinear2_mag (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0] += scan.slopeC[0]; - scan.c[1] += scan.slopeC[1]; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0]; - scan.t[0][1] += scan.slopeT[0][1]; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0]; - scan.t[1][1] += scan.slopeT[1][1]; -#endif - - } - } - -} - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - - -//! creates a flat triangle renderer -IBurningShader* createTriangleRendererTextureLightMap2_M4(IDepthBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CTRTextureLightMap2_M4(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - -} // end namespace video -} // end namespace irr - - - diff --git a/irrlicht-1.6/source/Irrlicht/CTRTextureLightMapGouraud2_M4.cpp b/irrlicht-1.6/source/Irrlicht/CTRTextureLightMapGouraud2_M4.cpp deleted file mode 100644 index 4097d9de7..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTRTextureLightMapGouraud2_M4.cpp +++ /dev/null @@ -1,690 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "IBurningShader.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -// compile flag for this file -#undef USE_ZBUFFER -#undef IPOL_Z -#undef CMP_Z -#undef WRITE_Z - -#undef IPOL_W -#undef CMP_W -#undef WRITE_W - -#undef SUBTEXEL -#undef INVERSE_W - -#undef IPOL_C0 -#undef IPOL_T0 -#undef IPOL_T1 - -// define render case -#define SUBTEXEL -#define INVERSE_W - -#define USE_ZBUFFER -#define IPOL_W -#define CMP_W -#define WRITE_W - -#define IPOL_C0 -#define IPOL_T0 -#define IPOL_T1 - -// apply global override -#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef INVERSE_W -#endif - -#ifndef SOFTWARE_DRIVER_2_SUBTEXEL - #undef SUBTEXEL -#endif - -#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #undef IPOL_C0 -#endif - -#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) - #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef IPOL_W - #endif - #define IPOL_Z - - #ifdef CMP_W - #undef CMP_W - #define CMP_Z - #endif - - #ifdef WRITE_W - #undef WRITE_W - #define WRITE_Z - #endif - -#endif - -namespace irr -{ - -namespace video -{ - -class CTRGTextureLightMap2_M4 : public IBurningShader -{ -public: - - //! constructor - CTRGTextureLightMap2_M4(IDepthBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - - -private: - void scanline_bilinear (); - - sScanConvertData scan; - sScanLineData line; - -}; - -//! constructor -CTRGTextureLightMap2_M4::CTRGTextureLightMap2_M4(IDepthBuffer* zbuffer) -: IBurningShader(zbuffer) -{ - #ifdef _DEBUG - setDebugName("CTRGTextureLightMap2_M4"); - #endif -} - - - -/*! -*/ -void CTRGTextureLightMap2_M4::scanline_bilinear () -{ - tVideoSample *dst; - -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - s32 xStart; - s32 xEnd; - s32 dx; - - -#ifdef SUBTEXEL - f32 subPixel; -#endif - -#ifdef IPOL_Z - f32 slopeZ; -#endif -#ifdef IPOL_W - fp24 slopeW; -#endif -#ifdef IPOL_C0 - sVec4 slopeC; -#endif -#ifdef IPOL_T0 - sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES]; -#endif - - // apply top-left fill-convention, left - xStart = core::ceil32( line.x[0] ); - xEnd = core::ceil32( line.x[1] ) - 1; - - dx = xEnd - xStart; - - if ( dx < 0 ) - return; - - // slopes - const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); - -#ifdef IPOL_Z - slopeZ = (line.z[1] - line.z[0]) * invDeltaX; -#endif -#ifdef IPOL_W - slopeW = (line.w[1] - line.w[0]) * invDeltaX; -#endif -#ifdef IPOL_C0 - slopeC = (line.c[0][1] - line.c[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T0 - slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; -#endif -#ifdef IPOL_T1 - slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; -#endif - -#ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; -#ifdef IPOL_Z - line.z[0] += slopeZ * subPixel; -#endif -#ifdef IPOL_W - line.w[0] += slopeW * subPixel; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC * subPixel; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0] * subPixel; -#endif -#ifdef IPOL_T1 - line.t[1][0] += slopeT[1] * subPixel; -#endif -#endif - - dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; - -#ifdef USE_ZBUFFER - z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; -#endif - - -#ifdef INVERSE_W - f32 inversew; -#endif - - tFixPoint tx0, tx1; - tFixPoint ty0, ty1; - - tFixPoint r0, g0, b0; - tFixPoint r1, g1, b1; - tFixPoint r2, g2, b2; - -#ifdef IPOL_C0 - tFixPoint r3, g3, b3; -#endif - - for ( s32 i = 0; i <= dx; i++ ) - { -#ifdef CMP_Z - if ( line.z[0] < z[i] ) -#endif -#ifdef CMP_W - if ( line.w[0] >= z[i] ) -#endif - { -#ifdef INVERSE_W - inversew = fix_inverse32 ( line.w[0] ); - - tx0 = tofix ( line.t[0][0].x,inversew); - ty0 = tofix ( line.t[0][0].y,inversew); - tx1 = tofix ( line.t[1][0].x,inversew); - ty1 = tofix ( line.t[1][0].y,inversew); - -#ifdef IPOL_C0 - r3 = tofix ( line.c[0][0].y ,inversew ); - g3 = tofix ( line.c[0][0].z ,inversew ); - b3 = tofix ( line.c[0][0].w ,inversew ); -#endif - -#else - tx0 = tofix ( line.t[0][0].x ); - ty0 = tofix ( line.t[0][0].y ); - tx1 = tofix ( line.t[1][0].x ); - ty1 = tofix ( line.t[1][0].y ); - -#ifdef IPOL_C0 - r3 = tofix ( line.c[0][0].y ); - g3 = tofix ( line.c[0][0].z ); - b3 = tofix ( line.c[0][0].w ); -#endif - -#endif - getSample_texture ( r0, g0, b0, &IT[0], tx0, ty0 ); - getSample_texture ( r1, g1, b1, &IT[1], tx1, ty1 ); - -#ifdef IPOL_C0 - r2 = imulFix ( r0, r3 ); - g2 = imulFix ( g0, g3 ); - b2 = imulFix ( b0, b3 ); - - r2 = clampfix_maxcolor ( imulFix_tex4 ( r2, r1 ) ); - g2 = clampfix_maxcolor ( imulFix_tex4 ( g2, g1 ) ); - b2 = clampfix_maxcolor ( imulFix_tex4 ( b2, b1 ) ); -/* - r2 = r3 << 8; - g2 = g3 << 8; - b2 = b3 << 8; -*/ -#else - r2 = clampfix_maxcolor ( imulFix_tex4 ( r0, r1 ) ); - g2 = clampfix_maxcolor ( imulFix_tex4 ( g0, g1 ) ); - b2 = clampfix_maxcolor ( imulFix_tex4 ( b0, b1 ) ); -#endif - - - dst[i] = fix_to_color ( r2, g2, b2 ); - -#ifdef WRITE_Z - z[i] = line.z[0]; -#endif -#ifdef WRITE_W - z[i] = line.w[0]; -#endif - } - -#ifdef IPOL_Z - line.z[0] += slopeZ; -#endif -#ifdef IPOL_W - line.w[0] += slopeW; -#endif -#ifdef IPOL_C0 - line.c[0][0] += slopeC; -#endif -#ifdef IPOL_T0 - line.t[0][0] += slopeT[0]; -#endif -#ifdef IPOL_T1 - line.t[1][0] += slopeT[1]; -#endif - } - -} - -void CTRGTextureLightMap2_M4::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - // sort on height, y - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - - const f32 ca = c->Pos.y - a->Pos.y; - const f32 ba = b->Pos.y - a->Pos.y; - const f32 cb = c->Pos.y - b->Pos.y; - // calculate delta y of the edges - scan.invDeltaY[0] = core::reciprocal( ca ); - scan.invDeltaY[1] = core::reciprocal( ba ); - scan.invDeltaY[2] = core::reciprocal( cb ); - - if ( F32_LOWER_0 ( scan.invDeltaY[0] ) ) - return; - - // find if the major edge is left or right aligned - f32 temp[4]; - - temp[0] = a->Pos.x - c->Pos.x; - temp[1] = -ca; - temp[2] = b->Pos.x - a->Pos.x; - temp[3] = ba; - - scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1; - scan.right = 1 - scan.left; - - // calculate slopes for the major edge - scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; - scan.x[0] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; - scan.z[0] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; - scan.w[0] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0][0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; - scan.c[0][0] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; - scan.t[0][0] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; - scan.t[1][0] = a->Tex[1]; -#endif - - // top left fill convention y run - s32 yStart; - s32 yEnd; - -#ifdef SUBTEXEL - f32 subPixel; -#endif - - - // rasterize upper sub-triangle - //if ( (f32) 0.0 != scan.invDeltaY[1] ) - if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) - { - // calculate slopes for top edge - scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; - scan.x[1] = a->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; - scan.z[1] = a->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; - scan.w[1] = a->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0][1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; - scan.c[0][1] = a->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; - scan.t[0][1] = a->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; - scan.t[1][1] = a->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = core::ceil32( a->Pos.y ); - yEnd = core::ceil32( b->Pos.y ) - 1; - -#ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - a->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0] * subPixel; - scan.c[0][1] += scan.slopeC[0][1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0] * subPixel; - scan.t[0][1] += scan.slopeT[0][1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0] * subPixel; - scan.t[1][1] += scan.slopeT[1][1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[0][scan.left] = scan.c[0][0]; - line.c[0][scan.right] = scan.c[0][1]; -#endif - -#ifdef IPOL_T0 - line.t[0][scan.left] = scan.t[0][0]; - line.t[0][scan.right] = scan.t[0][1]; -#endif - -#ifdef IPOL_T1 - line.t[1][scan.left] = scan.t[1][0]; - line.t[1][scan.right] = scan.t[1][1]; -#endif - - // render a scanline - scanline_bilinear (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0]; - scan.c[0][1] += scan.slopeC[0][1]; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0]; - scan.t[0][1] += scan.slopeT[0][1]; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0]; - scan.t[1][1] += scan.slopeT[1][1]; -#endif - - } - } - - // rasterize lower sub-triangle - //if ( (f32) 0.0 != scan.invDeltaY[2] ) - if ( F32_GREATER_0 ( scan.invDeltaY[2] ) ) - { - // advance to middle point - //if( (f32) 0.0 != scan.invDeltaY[1] ) - if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) - { - temp[0] = b->Pos.y - a->Pos.y; // dy - - scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; -#ifdef IPOL_Z - scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; -#endif -#ifdef IPOL_W - scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; -#endif -#ifdef IPOL_C0 - scan.c[0][0] = a->Color[0] + scan.slopeC[0][0] * temp[0]; -#endif -#ifdef IPOL_T0 - scan.t[0][0] = a->Tex[0] + scan.slopeT[0][0] * temp[0]; -#endif -#ifdef IPOL_T1 - scan.t[1][0] = a->Tex[1] + scan.slopeT[1][0] * temp[0]; -#endif - - } - - // calculate slopes for bottom edge - scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; - scan.x[1] = b->Pos.x; - -#ifdef IPOL_Z - scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; - scan.z[1] = b->Pos.z; -#endif - -#ifdef IPOL_W - scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; - scan.w[1] = b->Pos.w; -#endif - -#ifdef IPOL_C0 - scan.slopeC[0][1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; - scan.c[0][1] = b->Color[0]; -#endif - -#ifdef IPOL_T0 - scan.slopeT[0][1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; - scan.t[0][1] = b->Tex[0]; -#endif - -#ifdef IPOL_T1 - scan.slopeT[1][1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; - scan.t[1][1] = b->Tex[1]; -#endif - - // apply top-left fill convention, top part - yStart = core::ceil32( b->Pos.y ); - yEnd = core::ceil32( c->Pos.y ) - 1; - -#ifdef SUBTEXEL - - subPixel = ( (f32) yStart ) - b->Pos.y; - - // correct to pixel center - scan.x[0] += scan.slopeX[0] * subPixel; - scan.x[1] += scan.slopeX[1] * subPixel; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0] * subPixel; - scan.z[1] += scan.slopeZ[1] * subPixel; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0] * subPixel; - scan.w[1] += scan.slopeW[1] * subPixel; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0] * subPixel; - scan.c[0][1] += scan.slopeC[0][1] * subPixel; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0] * subPixel; - scan.t[0][1] += scan.slopeT[0][1] * subPixel; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0] * subPixel; - scan.t[1][1] += scan.slopeT[1][1] * subPixel; -#endif - -#endif - - // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) - { - line.x[scan.left] = scan.x[0]; - line.x[scan.right] = scan.x[1]; - -#ifdef IPOL_Z - line.z[scan.left] = scan.z[0]; - line.z[scan.right] = scan.z[1]; -#endif - -#ifdef IPOL_W - line.w[scan.left] = scan.w[0]; - line.w[scan.right] = scan.w[1]; -#endif - -#ifdef IPOL_C0 - line.c[0][scan.left] = scan.c[0][0]; - line.c[0][scan.right] = scan.c[0][1]; -#endif - -#ifdef IPOL_T0 - line.t[0][scan.left] = scan.t[0][0]; - line.t[0][scan.right] = scan.t[0][1]; -#endif - -#ifdef IPOL_T1 - line.t[1][scan.left] = scan.t[1][0]; - line.t[1][scan.right] = scan.t[1][1]; -#endif - - // render a scanline - scanline_bilinear (); - - scan.x[0] += scan.slopeX[0]; - scan.x[1] += scan.slopeX[1]; - -#ifdef IPOL_Z - scan.z[0] += scan.slopeZ[0]; - scan.z[1] += scan.slopeZ[1]; -#endif - -#ifdef IPOL_W - scan.w[0] += scan.slopeW[0]; - scan.w[1] += scan.slopeW[1]; -#endif - -#ifdef IPOL_C0 - scan.c[0][0] += scan.slopeC[0][0]; - scan.c[0][1] += scan.slopeC[0][1]; -#endif - -#ifdef IPOL_T0 - scan.t[0][0] += scan.slopeT[0][0]; - scan.t[0][1] += scan.slopeT[0][1]; -#endif - -#ifdef IPOL_T1 - scan.t[1][0] += scan.slopeT[1][0]; - scan.t[1][1] += scan.slopeT[1][1]; -#endif - - } - } - -} - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - - -//! creates a flat triangle renderer -IBurningShader* createTriangleRendererGTextureLightMap2_M4(IDepthBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CTRGTextureLightMap2_M4(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - -} // end namespace video -} // end namespace irr - - - diff --git a/irrlicht-1.6/source/Irrlicht/CTRTextureWire2.cpp b/irrlicht-1.6/source/Irrlicht/CTRTextureWire2.cpp deleted file mode 100644 index 17de4521b..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTRTextureWire2.cpp +++ /dev/null @@ -1,298 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" -#include "IBurningShader.h" - -#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -// compile flag for this file -#undef USE_ZBUFFER -#undef IPOL_Z -#undef CMP_Z -#undef WRITE_Z - -#undef IPOL_W -#undef CMP_W -#undef WRITE_W - -#undef SUBTEXEL -#undef INVERSE_W - -#undef IPOL_C0 -#undef IPOL_T0 -#undef IPOL_T1 - -// define render case -#define SUBTEXEL -#define INVERSE_W - -#define USE_ZBUFFER -#define IPOL_W -#define CMP_W -#define WRITE_W - - -//#define IPOL_C0 -#define IPOL_T0 -//#define IPOL_T1 - -// apply global override -#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef INVERSE_W -#endif - -#ifndef SOFTWARE_DRIVER_2_SUBTEXEL - #undef SUBTEXEL -#endif - -#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) - #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #undef IPOL_W - #endif - #define IPOL_Z - - #ifdef CMP_W - #undef CMP_W - #define CMP_Z - #endif - - #ifdef WRITE_W - #undef WRITE_W - #define WRITE_Z - #endif - -#endif - - -namespace irr -{ - -namespace video -{ - -class CTRTextureWire2 : public IBurningShader -{ -public: - - //! constructor - CTRTextureWire2(IDepthBuffer* zbuffer); - - //! draws an indexed triangle list - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); - virtual void drawLine ( const s4DVertex *a,const s4DVertex *b); - - - -private: - void renderAlphaLine ( const s4DVertex *a,const s4DVertex *b ) const; - void renderLine ( const s4DVertex *a,const s4DVertex *b ) const; - -}; - -//! constructor -CTRTextureWire2::CTRTextureWire2(IDepthBuffer* zbuffer) -: IBurningShader(zbuffer) -{ - #ifdef _DEBUG - setDebugName("CTRTextureWire2"); - #endif -} - - -// swap integer with xor -static inline void swap_xor ( s32 &a, s32 &b ) -{ - a ^= b; - b ^= a; - a ^= b; -} - - -/*! -*/ -void CTRTextureWire2::renderLine ( const s4DVertex *a,const s4DVertex *b ) const -{ - - int pitch0 = RenderTarget->getDimension().Width << VIDEO_SAMPLE_GRANULARITY; - int pitch1 = RenderTarget->getDimension().Width << 2; - - int aposx = (int) a->Pos.x; - int aposy = (int) a->Pos.y; - int bposx = (int) b->Pos.x; - int bposy = (int) b->Pos.y; - - int dx = bposx - aposx; - int dy = bposy - aposy; - - int c; - int m; - int d = 0; - int run; - - tVideoSample *dst; -#ifdef USE_ZBUFFER - fp24 *z; -#endif - - int xInc0 = 1 << VIDEO_SAMPLE_GRANULARITY; - int yInc0 = pitch0; - - int xInc1 = 4; - int yInc1 = pitch1; - - tVideoSample color; - -#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - tFixPoint r0, g0, b0; - getSample_color ( r0, g0, b0, a->Color[0] ); - color = fix_to_color ( r0, g0, b0 ); -#else - color = (tVideoSample) 0xFFFFFFFF; -#endif - - if ( dx < 0 ) - { - xInc0 = - ( 1 << VIDEO_SAMPLE_GRANULARITY); - xInc1 = -4; - dx = -dx; - } - - if ( dy > dx ) - { - swap_xor ( dx, dy ); - swap_xor ( xInc0, yInc0 ); - swap_xor ( xInc1, yInc1 ); - } - - if ( 0 == dx ) - return; - - dst = (tVideoSample*) ( (u8*) (tVideoSample*)RenderTarget->lock() + ( aposy * pitch0 ) + (aposx << VIDEO_SAMPLE_GRANULARITY ) ); -#ifdef USE_ZBUFFER - z = (fp24*) ( (u8*) (fp24*) DepthBuffer->lock() + ( aposy * pitch1 ) + (aposx << 2 ) ); -#endif - - c = dx << 1; - m = dy << 1; - -#ifdef IPOL_Z - f32 slopeZ = (b->Pos.z - a->Pos.z) / f32(dx); - f32 dataZ = a->Pos.z; -#endif - -#ifdef IPOL_W - fp24 slopeW = (b->Pos.w - a->Pos.w) / f32( dx ); - fp24 dataW = a->Pos.w; -#endif - - run = dx; - while ( run ) - { -#ifdef CMP_Z - if ( *z >= dataZ ) -#endif -#ifdef CMP_W - if ( dataW >= *z ) -#endif - { -#ifdef WRITE_Z - *z = dataZ; -#endif -#ifdef WRITE_W - *z = dataW; -#endif - - *dst = color; - - } - - dst = (tVideoSample*) ( (u8*) dst + xInc0 ); // x += xInc -#ifdef IPOL_Z - z = (fp24*) ( (u8*) z + xInc1 ); -#endif -#ifdef IPOL_W - z = (fp24*) ( (u8*) z + xInc1 ); -#endif - - d += m; - if ( d > dx ) - { - dst = (tVideoSample*) ( (u8*) dst + yInc0 ); // y += yInc -#ifdef IPOL_Z - z = (fp24*) ( (u8*) z + yInc1 ); -#endif -#ifdef IPOL_W - z = (fp24*) ( (u8*) z + yInc1 ); -#endif - - d -= c; - } - run -= 1; -#ifdef IPOL_Z - dataZ += slopeZ; -#endif -#ifdef IPOL_W - dataW += slopeW; -#endif - - } - -} - -void CTRTextureWire2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) -{ - sScanLineData line; - - // sort on height, y - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); - if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); - - renderLine ( a, b ); - renderLine ( b, c ); - renderLine ( a, c ); - -} - - -void CTRTextureWire2::drawLine ( const s4DVertex *a,const s4DVertex *b) -{ - - // query access to TexMaps - - // sort on height, y - if ( a->Pos.y > b->Pos.y ) swapVertexPointer(&a, &b); - - renderLine ( a, b ); - -} - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ - -namespace irr -{ -namespace video -{ - - -//! creates a flat triangle renderer -IBurningShader* createTriangleRendererTextureGouraudWire2(IDepthBuffer* zbuffer) -{ - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CTRTextureWire2(zbuffer); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ -} - - -} // end namespace video -} // end namespace irr - - diff --git a/irrlicht-1.6/source/Irrlicht/CTarReader.cpp b/irrlicht-1.6/source/Irrlicht/CTarReader.cpp deleted file mode 100644 index 04d922222..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTarReader.cpp +++ /dev/null @@ -1,254 +0,0 @@ -// Copyright (C) 2009 Gaz Davidson -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CTarReader.h" - -#ifdef __IRR_COMPILE_WITH_TAR_ARCHIVE_LOADER_ - -#include "CFileList.h" -#include "CLimitReadFile.h" -#include "os.h" -#include "coreutil.h" -#include "errno.h" - -namespace irr -{ -namespace io -{ - -//! Constructor -CArchiveLoaderTAR::CArchiveLoaderTAR(io::IFileSystem* fs) -: FileSystem(fs) -{ - #ifdef _DEBUG - setDebugName("CArchiveLoaderTAR"); - #endif -} - - -//! returns true if the file maybe is able to be loaded by this class -bool CArchiveLoaderTAR::isALoadableFileFormat(const io::path& filename) const -{ - return core::hasFileExtension(filename, "tar"); -} - -//! Check to see if the loader can create archives of this type. -bool CArchiveLoaderTAR::isALoadableFileFormat(E_FILE_ARCHIVE_TYPE fileType) const -{ - return fileType == EFAT_TAR; -} - -//! Creates an archive from the filename -/** \param file File handle to check. -\return Pointer to newly created archive, or 0 upon error. */ -IFileArchive* CArchiveLoaderTAR::createArchive(const io::path& filename, bool ignoreCase, bool ignorePaths) const -{ - IFileArchive *archive = 0; - io::IReadFile* file = FileSystem->createAndOpenFile(filename); - - if (file) - { - archive = createArchive(file, ignoreCase, ignorePaths); - file->drop(); - } - - return archive; -} - - -//! creates/loads an archive from the file. -//! \return Pointer to the created archive. Returns 0 if loading failed. -IFileArchive* CArchiveLoaderTAR::createArchive(io::IReadFile* file, bool ignoreCase, bool ignorePaths) const -{ - IFileArchive *archive = 0; - if (file) - { - file->seek(0); - archive = new CTarReader(file, ignoreCase, ignorePaths); - } - return archive; -} - -//! Check if the file might be loaded by this class -/** Check might look into the file. -\param file File handle to check. -\return True if file seems to be loadable. */ -bool CArchiveLoaderTAR::isALoadableFileFormat(io::IReadFile* file) const -{ - // TAR files consist of blocks of 512 bytes - // if it isn't a multiple of 512 then it's not a TAR file. - if (file->getSize() % 512) - return false; - - file->seek(0); - - // read header of first file - STarHeader fHead; - file->read(&fHead, sizeof(STarHeader)); - - u32 checksum = 0; - sscanf(fHead.Checksum, "%o", &checksum); - - // verify checksum - - // some old TAR writers assume that chars are signed, others assume unsigned - // USTAR archives have a longer header, old TAR archives end after linkname - - u32 checksum1=0; - s32 checksum2=0; - - // remember to blank the checksum field! - memset(fHead.Checksum, ' ', 8); - - // old header - for (u8* p = (u8*)(&fHead); p < (u8*)(&fHead.Magic[0]); ++p) - { - checksum1 += *p; - checksum2 += c8(*p); - } - - if (!strcmp(fHead.Magic, "star")) - { - for (u8* p = (u8*)(&fHead.Magic[0]); p < (u8*)(&fHead) + sizeof(fHead); ++p) - { - checksum1 += *p; - checksum2 += c8(*p); - } - } - return checksum1 == checksum || checksum2 == (s32)checksum; -} - -/* - TAR Archive -*/ -CTarReader::CTarReader(IReadFile* file, bool ignoreCase, bool ignorePaths) - : CFileList(file ? file->getFileName() : "", ignoreCase, ignorePaths), File(file) -{ - #ifdef _DEBUG - setDebugName("CTarReader"); - #endif - - if (File) - { - File->grab(); - - // fill the file list - populateFileList(); - - sort(); - } -} - - -CTarReader::~CTarReader() -{ - if (File) - File->drop(); -} - -const IFileList* CTarReader::getFileList() const -{ - return this; -} - - -u32 CTarReader::populateFileList() -{ - STarHeader fHead; - Files.clear(); - - u32 pos = 0; - while ( s32(pos + sizeof(STarHeader)) < File->getSize()) - { - // seek to next file header - File->seek(pos); - - // read the header - File->read(&fHead, sizeof(fHead)); - - // only add standard files for now - if (fHead.Link == ETLI_REGULAR_FILE || ETLI_REGULAR_FILE_OLD) - { - io::path fullPath = ""; - fullPath.reserve(255); - - // USTAR archives have a filename prefix - // may not be null terminated, copy carefully! - if (!strcmp(fHead.Magic, "ustar")) - { - c8* np = fHead.FileNamePrefix; - while(*np && (np - fHead.FileNamePrefix) < 155) - fullPath.append(*np); - np++; - } - - // append the file name - c8* np = fHead.FileName; - while(*np && (np - fHead.FileName) < 100) - { - fullPath.append(*np); - np++; - } - - // get size - core::stringc sSize = ""; - sSize.reserve(12); - np = fHead.Size; - while(*np && (np - fHead.Size) < 12) - { - sSize.append(*np); - np++; - } - - u32 size = strtoul(sSize.c_str(), NULL, 8); - if (errno == ERANGE) - os::Printer::log("File too large", fullPath, ELL_WARNING); - - // save start position - u32 offset = pos + 512; - - // move to next file header block - pos = offset + (size / 512) * 512 + ((size % 512) ? 512 : 0); - - // add file to list - addItem(fullPath, size, false, Offsets.size()); - Offsets.push_back(offset); - } - else - { - // todo: ETLI_DIRECTORY, ETLI_LINK_TO_ARCHIVED_FILE - - // move to next block - pos += 512; - } - - } - - return Files.size(); -} - -//! opens a file by file name -IReadFile* CTarReader::createAndOpenFile(const io::path& filename) -{ - const s32 index = findFile(filename, false); - - if (index != -1) - return createAndOpenFile(index); - - return 0; -} - -//! opens a file by index -IReadFile* CTarReader::createAndOpenFile(u32 index) -{ - if (index < Files.size()) - return createLimitReadFile(Files[index].FullName, File, Offsets[Files[index].ID], Files[index].Size); - else - return 0; -} - -} // end namespace io -} // end namespace irr - -#endif // __IRR_COMPILE_WITH_TAR_ARCHIVE_LOADER_ diff --git a/irrlicht-1.6/source/Irrlicht/CTarReader.h b/irrlicht-1.6/source/Irrlicht/CTarReader.h deleted file mode 100644 index d2501566f..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTarReader.h +++ /dev/null @@ -1,147 +0,0 @@ -// Copyright (C) 2009 Gaz Davidson -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_TAR_READER_H_INCLUDED__ -#define __C_TAR_READER_H_INCLUDED__ - -#include "IrrCompileConfig.h" - -#ifdef __IRR_COMPILE_WITH_TAR_ARCHIVE_LOADER_ - -#include "IReferenceCounted.h" -#include "IReadFile.h" -#include "irrArray.h" -#include "irrString.h" -#include "IFileSystem.h" -#include "CFileList.h" - -namespace irr -{ -namespace io -{ - -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) -# pragma pack( push, packing ) -# pragma pack( 1 ) -# define PACK_STRUCT -#elif defined( __GNUC__ ) -# define PACK_STRUCT __attribute__((packed)) -#else -# error compiler not supported -#endif - - enum E_TAR_LINK_INDICATOR - { - ETLI_REGULAR_FILE_OLD = 0 , - ETLI_REGULAR_FILE = '0', - ETLI_LINK_TO_ARCHIVED_FILE = '1', - ETLI_SYMBOLIC_LINK = '2', - ETLI_CHAR_SPECIAL_DEVICE = '3', - ETLI_BLOCK_SPECIAL_DEVICE = '4', - ETLI_DIRECTORY = '5', - ETLI_FIFO_SPECIAL_FILE = '6' - }; - - struct STarHeader - { - c8 FileName[100]; - c8 FileMode[8]; - c8 UserID[8]; - c8 GroupID[8]; - c8 Size[12]; - c8 ModifiedTime[12]; - c8 Checksum[8]; - c8 Link; - c8 LinkName[100]; - c8 Magic[6]; - c8 USTARVersion[2]; - c8 UserName[32]; - c8 GroupName[32]; - c8 DeviceMajor[8]; - c8 DeviceMinor[8]; - c8 FileNamePrefix[155]; - } PACK_STRUCT; - - -// Default alignment -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) -# pragma pack( pop, packing ) -#endif - -#undef PACK_STRUCT - - //! Archiveloader capable of loading ZIP Archives - class CArchiveLoaderTAR : public IArchiveLoader - { - public: - - //! Constructor - CArchiveLoaderTAR(io::IFileSystem* fs); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".tar") - virtual bool isALoadableFileFormat(const io::path& filename) const; - - //! Check if the file might be loaded by this class - /** Check might look into the file. - \param file File handle to check. - \return True if file seems to be loadable. */ - virtual bool isALoadableFileFormat(io::IReadFile* file) const; - - //! Check to see if the loader can create archives of this type. - /** Check based on the archive type. - \param fileType The archive type to check. - \return True if the archile loader supports this type, false if not */ - virtual bool isALoadableFileFormat(E_FILE_ARCHIVE_TYPE fileType) const; - - //! Creates an archive from the filename - /** \param file File handle to check. - \return Pointer to newly created archive, or 0 upon error. */ - virtual IFileArchive* createArchive(const io::path& filename, bool ignoreCase, bool ignorePaths) const; - - //! creates/loads an archive from the file. - //! \return Pointer to the created archive. Returns 0 if loading failed. - virtual io::IFileArchive* createArchive(io::IReadFile* file, bool ignoreCase, bool ignorePaths) const; - - private: - io::IFileSystem* FileSystem; - }; - - - - class CTarReader : public virtual IFileArchive, virtual CFileList - { - public: - - CTarReader(IReadFile* file, bool ignoreCase, bool ignorePaths); - - virtual ~CTarReader(); - - //! opens a file by file name - virtual IReadFile* createAndOpenFile(const io::path& filename); - - //! opens a file by index - virtual IReadFile* createAndOpenFile(u32 index); - - //! returns the list of files - virtual const IFileList* getFileList() const; - - //! get the class Type - virtual E_FILE_ARCHIVE_TYPE getType() const { return EFAT_TAR; } - - private: - - u32 populateFileList(); - - IReadFile* File; - - //! Contains offsets of the files from the start of the archive file - core::array<u32> Offsets; - }; - -} // end namespace io -} // end namespace irr - -#endif // __IRR_COMPILE_WITH_TAR_ARCHIVE_LOADER_ -#endif // __C_TAR_READER_H_INCLUDED__ diff --git a/irrlicht-1.6/source/Irrlicht/CTerrainSceneNode.cpp b/irrlicht-1.6/source/Irrlicht/CTerrainSceneNode.cpp deleted file mode 100644 index ca12be07b..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTerrainSceneNode.cpp +++ /dev/null @@ -1,1503 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -// The code for the TerrainSceneNode is based on the GeoMipMapSceneNode -// developed by Spintz. He made it available for Irrlicht and allowed it to be -// distributed under this licence. I only modified some parts. A lot of thanks -// go to him. - -#include "CTerrainSceneNode.h" -#include "CTerrainTriangleSelector.h" -#include "IVideoDriver.h" -#include "ISceneManager.h" -#include "ICameraSceneNode.h" -#include "SMeshBufferLightMap.h" -#include "SViewFrustum.h" -#include "irrMath.h" -#include "os.h" -#include "IGUIFont.h" -#include "IFileSystem.h" -#include "IReadFile.h" -#include "ITextSceneNode.h" -#include "IAnimatedMesh.h" - -namespace irr -{ -namespace scene -{ - - //! constructor - CTerrainSceneNode::CTerrainSceneNode(ISceneNode* parent, ISceneManager* mgr, - io::IFileSystem* fs, s32 id, s32 maxLOD, E_TERRAIN_PATCH_SIZE patchSize, - const core::vector3df& position, - const core::vector3df& rotation, - const core::vector3df& scale) - : ITerrainSceneNode(parent, mgr, id, position, rotation, scale), - TerrainData(patchSize, maxLOD, position, rotation, scale), RenderBuffer(0), - VerticesToRender(0), IndicesToRender(0), DynamicSelectorUpdate(false), - OverrideDistanceThreshold(false), UseDefaultRotationPivot(true), ForceRecalculation(false), - OldCameraPosition(core::vector3df(-99999.9f, -99999.9f, -99999.9f)), - OldCameraRotation(core::vector3df(-99999.9f, -99999.9f, -99999.9f)), - OldCameraUp(core::vector3df(-99999.9f, -99999.9f, -99999.9f)), - CameraMovementDelta(10.0f), CameraRotationDelta(1.0f),CameraFOVDelta(0.1f), - TCoordScale1(1.0f), TCoordScale2(1.0f), FileSystem(fs) - { - #ifdef _DEBUG - setDebugName("CTerrainSceneNode"); - #endif - - RenderBuffer = new CDynamicMeshBuffer(video::EVT_2TCOORDS, video::EIT_16BIT); - RenderBuffer->setHardwareMappingHint(scene::EHM_STATIC, scene::EBT_VERTEX); - RenderBuffer->setHardwareMappingHint(scene::EHM_DYNAMIC, scene::EBT_INDEX); - - if (FileSystem) - FileSystem->grab(); - - setAutomaticCulling(scene::EAC_OFF); - } - - - //! destructor - CTerrainSceneNode::~CTerrainSceneNode() - { - delete [] TerrainData.Patches; - - if (FileSystem) - FileSystem->drop(); - - if (RenderBuffer) - RenderBuffer->drop(); - } - - - //! Initializes the terrain data. Loads the vertices from the heightMapFile - bool CTerrainSceneNode::loadHeightMap(io::IReadFile* file, video::SColor vertexColor, - s32 smoothFactor) - { - if (!file) - return false; - - Mesh.MeshBuffers.clear(); - const u32 startTime = os::Timer::getRealTime(); - video::IImage* heightMap = SceneManager->getVideoDriver()->createImageFromFile(file); - - if (!heightMap) - { - os::Printer::log("Unable to load heightmap."); - return false; - } - - HeightmapFile = file->getFileName(); - - // Get the dimension of the heightmap data - TerrainData.Size = heightMap->getDimension().Width; - - switch (TerrainData.PatchSize) - { - case ETPS_9: - if (TerrainData.MaxLOD > 3) - { - TerrainData.MaxLOD = 3; - } - break; - case ETPS_17: - if (TerrainData.MaxLOD > 4) - { - TerrainData.MaxLOD = 4; - } - break; - case ETPS_33: - if (TerrainData.MaxLOD > 5) - { - TerrainData.MaxLOD = 5; - } - break; - case ETPS_65: - if (TerrainData.MaxLOD > 6) - { - TerrainData.MaxLOD = 6; - } - break; - case ETPS_129: - if (TerrainData.MaxLOD > 7) - { - TerrainData.MaxLOD = 7; - } - break; - } - - // --- Generate vertex data from heightmap ---- - // resize the vertex array for the mesh buffer one time (makes loading faster) - //SMeshBufferLightMap* mb = new SMeshBufferLightMap(); - - scene::CDynamicMeshBuffer *mb=0; - - const u32 numVertices = TerrainData.Size * TerrainData.Size; - if (numVertices <= 65536) - { - //small enough for 16bit buffers - mb=new scene::CDynamicMeshBuffer(video::EVT_2TCOORDS, video::EIT_16BIT); - RenderBuffer->getIndexBuffer().setType(video::EIT_16BIT); - } - else - { - //we need 32bit buffers - mb=new scene::CDynamicMeshBuffer(video::EVT_2TCOORDS, video::EIT_32BIT); - RenderBuffer->getIndexBuffer().setType(video::EIT_32BIT); - } - - mb->getVertexBuffer().set_used(numVertices); - - // Read the heightmap to get the vertex data - // Apply positions changes, scaling changes - const f32 tdSize = 1.0f/(f32)(TerrainData.Size-1); - s32 index = 0; - float fx=0.f; - float fx2=0.f; - for (s32 x = 0; x < TerrainData.Size; ++x) - { - float fz=0.f; - float fz2=0.f; - for (s32 z = 0; z < TerrainData.Size; ++z) - { - video::S3DVertex2TCoords& vertex= static_cast<video::S3DVertex2TCoords*>(mb->getVertexBuffer().pointer())[index++]; - vertex.Normal.set(0.0f, 1.0f, 0.0f); - vertex.Color = vertexColor; - vertex.Pos.X = fx; - vertex.Pos.Y = (f32) heightMap->getPixel(TerrainData.Size-x-1,z).getLuminance(); - vertex.Pos.Z = fz; - - vertex.TCoords.X = vertex.TCoords2.X = 1.f-fx2; - vertex.TCoords.Y = vertex.TCoords2.Y = fz2; - - ++fz; - fz2 += tdSize; - } - ++fx; - fx2 += tdSize; - } - - // drop heightMap, no longer needed - heightMap->drop(); - - smoothTerrain(mb, smoothFactor); - - // calculate smooth normals for the vertices - calculateNormals(mb); - - // add the MeshBuffer to the mesh - Mesh.addMeshBuffer(mb); - - // We copy the data to the renderBuffer, after the normals have been calculated. - RenderBuffer->getVertexBuffer().set_used(numVertices); - - for (u32 i = 0; i < numVertices; ++i) - { - RenderBuffer->getVertexBuffer()[i] = mb->getVertexBuffer()[i]; - RenderBuffer->getVertexBuffer()[i].Pos *= TerrainData.Scale; - RenderBuffer->getVertexBuffer()[i].Pos += TerrainData.Position; - } - - // We no longer need the mb - mb->drop(); - - // calculate all the necessary data for the patches and the terrain - calculateDistanceThresholds(); - createPatches(); - calculatePatchData(); - - // set the default rotation pivot point to the terrain nodes center - TerrainData.RotationPivot = TerrainData.Center; - - // Rotate the vertices of the terrain by the rotation - // specified. Must be done after calculating the terrain data, - // so we know what the current center of the terrain is. - setRotation(TerrainData.Rotation); - - // Pre-allocate memory for indices - - RenderBuffer->getIndexBuffer().set_used( - TerrainData.PatchCount * TerrainData.PatchCount * - TerrainData.CalcPatchSize * TerrainData.CalcPatchSize * 6); - - RenderBuffer->setDirty(); - - const u32 endTime = os::Timer::getRealTime(); - - c8 tmp[255]; - snprintf(tmp, 255, "Generated terrain data (%dx%d) in %.4f seconds", - TerrainData.Size, TerrainData.Size, (endTime - startTime) / 1000.0f ); - os::Printer::log(tmp); - - return true; - } - - - //! Initializes the terrain data. Loads the vertices from the heightMapFile - bool CTerrainSceneNode::loadHeightMapRAW(io::IReadFile* file, - s32 bitsPerPixel, bool signedData, bool floatVals, - s32 width, video::SColor vertexColor, s32 smoothFactor) - { - if (!file) - return false; - if (floatVals && bitsPerPixel != 32) - return false; - - // start reading - const u32 startTime = os::Timer::getTime(); - - Mesh.MeshBuffers.clear(); - - const s32 bytesPerPixel = bitsPerPixel / 8; - - // Get the dimension of the heightmap data - const s32 filesize = file->getSize(); - if (!width) - TerrainData.Size = core::floor32(sqrtf((f32)(filesize / bytesPerPixel))); - else - { - if ((filesize-file->getPos())/bytesPerPixel>width*width) - { - os::Printer::log("Error reading heightmap RAW file", "File is too small."); - return false; - } - TerrainData.Size = width; - } - - switch (TerrainData.PatchSize) - { - case ETPS_9: - if (TerrainData.MaxLOD > 3) - { - TerrainData.MaxLOD = 3; - } - break; - case ETPS_17: - if (TerrainData.MaxLOD > 4) - { - TerrainData.MaxLOD = 4; - } - break; - case ETPS_33: - if (TerrainData.MaxLOD > 5) - { - TerrainData.MaxLOD = 5; - } - break; - case ETPS_65: - if (TerrainData.MaxLOD > 6) - { - TerrainData.MaxLOD = 6; - } - break; - case ETPS_129: - if (TerrainData.MaxLOD > 7) - { - TerrainData.MaxLOD = 7; - } - break; - } - - // --- Generate vertex data from heightmap ---- - // resize the vertex array for the mesh buffer one time (makes loading faster) - scene::CDynamicMeshBuffer *mb=0; - const u32 numVertices = TerrainData.Size * TerrainData.Size; - if (numVertices <= 65536) - { - //small enough for 16bit buffers - mb=new scene::CDynamicMeshBuffer(video::EVT_2TCOORDS, video::EIT_16BIT); - RenderBuffer->getIndexBuffer().setType(video::EIT_16BIT); - } - else - { - //we need 32bit buffers - mb=new scene::CDynamicMeshBuffer(video::EVT_2TCOORDS, video::EIT_32BIT); - RenderBuffer->getIndexBuffer().setType(video::EIT_32BIT); - } - - mb->getVertexBuffer().reallocate(numVertices); - - video::S3DVertex2TCoords vertex; - vertex.Normal.set(0.0f, 1.0f, 0.0f); - vertex.Color = vertexColor; - - // Read the heightmap to get the vertex data - // Apply positions changes, scaling changes - const f32 tdSize = 1.0f/(f32)(TerrainData.Size-1); - float fx=0.f; - float fx2=0.f; - for (s32 x = 0; x < TerrainData.Size; ++x) - { - float fz=0.f; - float fz2=0.f; - for (s32 z = 0; z < TerrainData.Size; ++z) - { - bool failure=false; - vertex.Pos.X = fx; - if (floatVals) - { - if (file->read(&vertex.Pos.Y, bytesPerPixel) != bytesPerPixel) - failure=true; - } - else if (signedData) - { - switch (bytesPerPixel) - { - case 1: - { - s8 val; - if (file->read(&val, bytesPerPixel) != bytesPerPixel) - failure=true; - vertex.Pos.Y=val; - } - break; - case 2: - { - s16 val; - if (file->read(&val, bytesPerPixel) != bytesPerPixel) - failure=true; - vertex.Pos.Y=val/256.f; - } - break; - case 4: - { - s32 val; - if (file->read(&val, bytesPerPixel) != bytesPerPixel) - failure=true; - vertex.Pos.Y=val/16777216.f; - } - break; - } - } - else - { - switch (bytesPerPixel) - { - case 1: - { - u8 val; - if (file->read(&val, bytesPerPixel) != bytesPerPixel) - failure=true; - vertex.Pos.Y=val; - } - break; - case 2: - { - u16 val; - if (file->read(&val, bytesPerPixel) != bytesPerPixel) - failure=true; - vertex.Pos.Y=val/256.f; - } - break; - case 4: - { - u32 val; - if (file->read(&val, bytesPerPixel) != bytesPerPixel) - failure=true; - vertex.Pos.Y=val/16777216.f; - } - break; - } - } - if (failure) - { - os::Printer::log("Error reading heightmap RAW file."); - mb->drop(); - return false; - } - vertex.Pos.Z = fz; - - vertex.TCoords.X = vertex.TCoords2.X = 1.f-fx2; - vertex.TCoords.Y = vertex.TCoords2.Y = fz2; - - mb->getVertexBuffer().push_back(vertex); - ++fz; - fz2 += tdSize; - } - ++fx; - fx2 += tdSize; - } - - smoothTerrain(mb, smoothFactor); - - // calculate smooth normals for the vertices - calculateNormals(mb); - - // add the MeshBuffer to the mesh - Mesh.addMeshBuffer(mb); - const u32 vertexCount = mb->getVertexCount(); - - // We copy the data to the renderBuffer, after the normals have been calculated. - RenderBuffer->getVertexBuffer().set_used(vertexCount); - - for (u32 i = 0; i < vertexCount; i++) - { - RenderBuffer->getVertexBuffer()[i] = mb->getVertexBuffer()[i]; - RenderBuffer->getVertexBuffer()[i].Pos *= TerrainData.Scale; - RenderBuffer->getVertexBuffer()[i].Pos += TerrainData.Position; - } - - // We no longer need the mb - mb->drop(); - - // calculate all the necessary data for the patches and the terrain - calculateDistanceThresholds(); - createPatches(); - calculatePatchData(); - - // set the default rotation pivot point to the terrain nodes center - TerrainData.RotationPivot = TerrainData.Center; - - // Rotate the vertices of the terrain by the rotation specified. Must be done - // after calculating the terrain data, so we know what the current center of the - // terrain is. - setRotation(TerrainData.Rotation); - - // Pre-allocate memory for indices - RenderBuffer->getIndexBuffer().set_used( - TerrainData.PatchCount*TerrainData.PatchCount* - TerrainData.CalcPatchSize*TerrainData.CalcPatchSize*6); - - const u32 endTime = os::Timer::getTime(); - - c8 tmp[255]; - snprintf(tmp, 255, "Generated terrain data (%dx%d) in %.4f seconds", - TerrainData.Size, TerrainData.Size, (endTime - startTime) / 1000.0f); - os::Printer::log(tmp); - - return true; - } - - - //! Sets the scale of the scene node. - //! \param scale: New scale of the node - void CTerrainSceneNode::setScale(const core::vector3df& scale) - { - TerrainData.Scale = scale; - applyTransformation(); - ForceRecalculation = true; - } - - - //! Sets the rotation of the node. This only modifies - //! the relative rotation of the node. - //! \param rotation: New rotation of the node in degrees. - void CTerrainSceneNode::setRotation(const core::vector3df& rotation) - { - TerrainData.Rotation = rotation; - applyTransformation(); - ForceRecalculation = true; - } - - - //! Sets the pivot point for rotation of this node. This is useful for the TiledTerrainManager to - //! rotate all terrain tiles around a global world point. - //! NOTE: The default for the RotationPivot will be the center of the individual tile. - void CTerrainSceneNode::setRotationPivot(const core::vector3df& pivot) - { - UseDefaultRotationPivot = false; - TerrainData.RotationPivot = pivot; - } - - - //! Sets the position of the node. - //! \param newpos: New postition of the scene node. - void CTerrainSceneNode::setPosition(const core::vector3df& newpos) - { - TerrainData.Position = newpos; - applyTransformation(); - ForceRecalculation = true; - } - - - //! Apply transformation changes(scale, position, rotation) - void CTerrainSceneNode::applyTransformation() - { - if (!Mesh.getMeshBufferCount()) - return; - - TerrainData.Position = TerrainData.Position; - s32 vtxCount = Mesh.getMeshBuffer(0)->getVertexCount(); - core::matrix4 rotMatrix; - rotMatrix.setRotationDegrees(TerrainData.Rotation); - - for (s32 i = 0; i < vtxCount; ++i) - { - RenderBuffer->getVertexBuffer()[i].Pos = Mesh.getMeshBuffer(0)->getPosition(i) * TerrainData.Scale + TerrainData.Position; - - RenderBuffer->getVertexBuffer()[i].Pos -= TerrainData.RotationPivot; - rotMatrix.inverseRotateVect(RenderBuffer->getVertexBuffer()[i].Pos); - RenderBuffer->getVertexBuffer()[i].Pos += TerrainData.RotationPivot; - } - - calculateDistanceThresholds(true); - calculatePatchData(); - - RenderBuffer->setDirty(EBT_VERTEX); - } - - - //! Updates the scene nodes indices if the camera has moved or rotated by a certain - //! threshold, which can be changed using the SetCameraMovementDeltaThreshold and - //! SetCameraRotationDeltaThreshold functions. This also determines if a given patch - //! for the scene node is within the view frustum and if it's not the indices are not - //! generated for that patch. - void CTerrainSceneNode::OnRegisterSceneNode() - { - if (!IsVisible || !SceneManager->getActiveCamera()) - return; - - preRenderLODCalculations(); - preRenderIndicesCalculations(); - ISceneNode::OnRegisterSceneNode(); - ForceRecalculation = false; - } - - - void CTerrainSceneNode::preRenderLODCalculations() - { - scene::ICameraSceneNode * camera = SceneManager->getActiveCamera(); - if(!camera) - return; - - SceneManager->registerNodeForRendering(this); - // Do Not call ISceneNode::OnRegisterSceneNode(), this node should have no children - - // Determine the camera rotation, based on the camera direction. - const core::vector3df cameraPosition = camera->getAbsolutePosition(); - const core::vector3df cameraRotation = core::line3d<f32>(cameraPosition, camera->getTarget()).getVector().getHorizontalAngle(); - core::vector3df cameraUp = camera->getUpVector(); - cameraUp.normalize(); - const f32 CameraFOV = SceneManager->getActiveCamera()->getFOV(); - - // Only check on the Camera's Y Rotation - if (!ForceRecalculation) - { - if ((fabsf(cameraRotation.X - OldCameraRotation.X) < CameraRotationDelta) && - (fabsf(cameraRotation.Y - OldCameraRotation.Y) < CameraRotationDelta)) - { - if ((fabs(cameraPosition.X - OldCameraPosition.X) < CameraMovementDelta) && - (fabs(cameraPosition.Y - OldCameraPosition.Y) < CameraMovementDelta) && - (fabs(cameraPosition.Z - OldCameraPosition.Z) < CameraMovementDelta)) - { - if (fabs(CameraFOV-OldCameraFOV) < CameraFOVDelta && - cameraUp.dotProduct(OldCameraUp) > (1.f - (cos(core::DEGTORAD * CameraRotationDelta)))) - { - return; - } - } - } - } - - OldCameraPosition = cameraPosition; - OldCameraRotation = cameraRotation; - OldCameraUp = cameraUp; - OldCameraFOV = CameraFOV; - - const SViewFrustum* frustum = SceneManager->getActiveCamera()->getViewFrustum(); - - // Determine each patches LOD based on distance from camera (and whether or not they are in - // the view frustum). - const s32 count = TerrainData.PatchCount * TerrainData.PatchCount; - for (s32 j = 0; j < count; ++j) - { - if (frustum->getBoundingBox().intersectsWithBox(TerrainData.Patches[j].BoundingBox)) - { - const f32 distance = (cameraPosition.X - TerrainData.Patches[j].Center.X) * (cameraPosition.X - TerrainData.Patches[j].Center.X) + - (cameraPosition.Y - TerrainData.Patches[j].Center.Y) * (cameraPosition.Y - TerrainData.Patches[j].Center.Y) + - (cameraPosition.Z - TerrainData.Patches[j].Center.Z) * (cameraPosition.Z - TerrainData.Patches[j].Center.Z); - - for (s32 i = TerrainData.MaxLOD - 1; i >= 0; --i) - { - if (distance >= TerrainData.LODDistanceThreshold[i]) - { - TerrainData.Patches[j].CurrentLOD = i; - break; - } - //else if (i == 0) - { - // If we've turned off a patch from viewing, because of the frustum, and now we turn around and it's - // too close, we need to turn it back on, at the highest LOD. The if above doesn't catch this. - TerrainData.Patches[j].CurrentLOD = 0; - } - } - } - else - { - TerrainData.Patches[j].CurrentLOD = -1; - } - } - } - - - void CTerrainSceneNode::preRenderIndicesCalculations() - { - scene::IIndexBuffer& indexBuffer = RenderBuffer->getIndexBuffer(); - IndicesToRender = 0; - indexBuffer.set_used(0); - - s32 index = 0; - // Then generate the indices for all patches that are visible. - for (s32 i = 0; i < TerrainData.PatchCount; ++i) - { - for (s32 j = 0; j < TerrainData.PatchCount; ++j) - { - if (TerrainData.Patches[index].CurrentLOD >= 0) - { - s32 x = 0; - s32 z = 0; - - // calculate the step we take this patch, based on the patches current LOD - const s32 step = 1 << TerrainData.Patches[index].CurrentLOD; - - // Loop through patch and generate indices - while (z < TerrainData.CalcPatchSize) - { - const s32 index11 = getIndex(j, i, index, x, z); - const s32 index21 = getIndex(j, i, index, x + step, z); - const s32 index12 = getIndex(j, i, index, x, z + step); - const s32 index22 = getIndex(j, i, index, x + step, z + step); - - indexBuffer.push_back(index12); - indexBuffer.push_back(index11); - indexBuffer.push_back(index22); - indexBuffer.push_back(index22); - indexBuffer.push_back(index11); - indexBuffer.push_back(index21); - IndicesToRender+=6; - - // increment index position horizontally - x += step; - - // we've hit an edge - if (x >= TerrainData.CalcPatchSize) - { - x = 0; - z += step; - } - } - } - ++index; - } - } - - RenderBuffer->setDirty(EBT_INDEX); - - if (DynamicSelectorUpdate && TriangleSelector) - { - CTerrainTriangleSelector* selector = (CTerrainTriangleSelector*)TriangleSelector; - selector->setTriangleData(this, -1); - } - } - - - //! Render the scene node - void CTerrainSceneNode::render() - { - if (!IsVisible || !SceneManager->getActiveCamera()) - return; - - if (!Mesh.getMeshBufferCount()) - return; - - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - - driver->setTransform (video::ETS_WORLD, core::IdentityMatrix); - driver->setMaterial(Mesh.getMeshBuffer(0)->getMaterial()); - - RenderBuffer->getIndexBuffer().set_used(IndicesToRender); - - // For use with geomorphing - driver->drawMeshBuffer(RenderBuffer); - - RenderBuffer->getIndexBuffer().set_used(RenderBuffer->getIndexBuffer().allocated_size()); - - // for debug purposes only: - if (DebugDataVisible) - { - video::SMaterial m; - m.Lighting = false; - driver->setMaterial(m); - if (DebugDataVisible & scene::EDS_BBOX) - driver->draw3DBox(TerrainData.BoundingBox, video::SColor(255,255,255,255)); - - const s32 count = TerrainData.PatchCount * TerrainData.PatchCount; - s32 visible = 0; - if (DebugDataVisible & scene::EDS_BBOX_BUFFERS) - { - for (s32 j = 0; j < count; ++j) - { - driver->draw3DBox(TerrainData.Patches[j].BoundingBox, video::SColor(255,255,0,0)); - visible += (TerrainData.Patches[j].CurrentLOD >= 0); - } - } - - if (DebugDataVisible & scene::EDS_NORMALS) - { - IAnimatedMesh * arrow = SceneManager->addArrowMesh( - "__debugnormal", 0xFFECEC00, - 0xFF999900, 4, 8, 1.f, 0.6f, 0.05f, - 0.3f); - if (0 == arrow) - { - arrow = SceneManager->getMesh( "__debugnormal"); - } - IMesh *mesh = arrow->getMesh(0); - - // find a good scaling factor - - core::matrix4 m2; - - // draw normals - driver->setTransform(video::ETS_WORLD, core::IdentityMatrix); - for (u32 i=0; i != RenderBuffer->getVertexCount(); ++i) - { - const core::vector3df& v = RenderBuffer->getNormal(i); - // align to v->Normal - if (core::vector3df(0,-1,0)==v) - { - m2.makeIdentity(); - m2[5]=-m2[5]; - } - else - { - core::quaternion quatRot; - m2=quatRot.rotationFromTo(v,core::vector3df(0,1,0)).getMatrix(); - } - - m2.setTranslation(RenderBuffer->getPosition(i)); - m2=AbsoluteTransformation*m2; - - driver->setTransform(video::ETS_WORLD, m2 ); - for (u32 a = 0; a != mesh->getMeshBufferCount(); ++a) - driver->drawMeshBuffer(mesh->getMeshBuffer(a)); - } - driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); - } - - static u32 lastTime = 0; - - const u32 now = os::Timer::getRealTime(); - if (now - lastTime > 1000) - { - char buf[64]; - snprintf(buf, 64, "Count: %d, Visible: %d", count, visible); - os::Printer::log(buf); - - lastTime = now; - } - } - } - - - //! Return the bounding box of the entire terrain. - const core::aabbox3d<f32>& CTerrainSceneNode::getBoundingBox() const - { - return TerrainData.BoundingBox; - } - - - //! Return the bounding box of a patch - const core::aabbox3d<f32>& CTerrainSceneNode::getBoundingBox(s32 patchX, s32 patchZ) const - { - return TerrainData.Patches[patchX * TerrainData.PatchCount + patchZ].BoundingBox; - } - - - //! Gets the meshbuffer data based on a specified Level of Detail. - //! \param mb: A reference to an SMeshBuffer object - //! \param LOD: The Level Of Detail you want the indices from. - void CTerrainSceneNode::getMeshBufferForLOD(IDynamicMeshBuffer& mb, s32 LOD ) const - { - if (!Mesh.getMeshBufferCount()) - return; - - LOD = core::clamp(LOD, 0, TerrainData.MaxLOD - 1); - - const u32 numVertices = Mesh.getMeshBuffer(0)->getVertexCount(); - mb.getVertexBuffer().reallocate(numVertices); - video::S3DVertex2TCoords* vertices = (video::S3DVertex2TCoords*)Mesh.getMeshBuffer(0)->getVertices(); - - for (u32 n=0; n<numVertices; ++n) - mb.getVertexBuffer().push_back(vertices[n]); - - mb.getIndexBuffer().setType(RenderBuffer->getIndexBuffer().getType()); - - // calculate the step we take for all patches, since LOD is the same - const s32 step = 1 << LOD; - - // Generate the indices for all patches at the specified LOD - s32 index = 0; - for (s32 i=0; i<TerrainData.PatchCount; ++i) - { - for (s32 j=0; j<TerrainData.PatchCount; ++j) - { - s32 x = 0; - s32 z = 0; - - // Loop through patch and generate indices - while (z < TerrainData.CalcPatchSize) - { - const s32 index11 = getIndex(j, i, index, x, z); - const s32 index21 = getIndex(j, i, index, x + step, z); - const s32 index12 = getIndex(j, i, index, x, z + step); - const s32 index22 = getIndex(j, i, index, x + step, z + step); - - mb.getIndexBuffer().push_back(index12); - mb.getIndexBuffer().push_back(index11); - mb.getIndexBuffer().push_back(index22); - mb.getIndexBuffer().push_back(index22); - mb.getIndexBuffer().push_back(index11); - mb.getIndexBuffer().push_back(index21); - - // increment index position horizontally - x += step; - - if (x >= TerrainData.CalcPatchSize) // we've hit an edge - { - x = 0; - z += step; - } - } - ++index; - } - } - } - - - //! Gets the indices for a specified patch at a specified Level of Detail. - //! \param mb: A reference to an array of u32 indices. - //! \param patchX: Patch x coordinate. - //! \param patchZ: Patch z coordinate. - //! \param LOD: The level of detail to get for that patch. If -1, then get - //! the CurrentLOD. If the CurrentLOD is set to -1, meaning it's not shown, - //! then it will retrieve the triangles at the highest LOD (0). - //! \return: Number if indices put into the buffer. - s32 CTerrainSceneNode::getIndicesForPatch(core::array<u32>& indices, s32 patchX, s32 patchZ, s32 LOD) - { - if (patchX < 0 || patchX > TerrainData.PatchCount-1 || - patchZ < 0 || patchZ > TerrainData.PatchCount-1) - return -1; - - if (LOD < -1 || LOD > TerrainData.MaxLOD - 1) - return -1; - - core::array<s32> cLODs; - bool setLODs = false; - - // If LOD of -1 was passed in, use the CurrentLOD of the patch specified - if (LOD == -1) - { - LOD = TerrainData.Patches[patchX * TerrainData.PatchCount + patchZ].CurrentLOD; - } - else - { - getCurrentLODOfPatches(cLODs); - setCurrentLODOfPatches(LOD); - setLODs = true; - } - - if (LOD < 0) - return -2; // Patch not visible, don't generate indices. - - // calculate the step we take for this LOD - const s32 step = 1 << LOD; - - // Generate the indices for the specified patch at the specified LOD - const s32 index = patchX * TerrainData.PatchCount + patchZ; - - s32 x = 0; - s32 z = 0; - - indices.set_used(TerrainData.PatchSize * TerrainData.PatchSize * 6); - - // Loop through patch and generate indices - s32 rv=0; - while (z<TerrainData.CalcPatchSize) - { - const s32 index11 = getIndex(patchZ, patchX, index, x, z); - const s32 index21 = getIndex(patchZ, patchX, index, x + step, z); - const s32 index12 = getIndex(patchZ, patchX, index, x, z + step); - const s32 index22 = getIndex(patchZ, patchX, index, x + step, z + step); - - indices[rv++] = index12; - indices[rv++] = index11; - indices[rv++] = index22; - indices[rv++] = index22; - indices[rv++] = index11; - indices[rv++] = index21; - - // increment index position horizontally - x += step; - - if (x >= TerrainData.CalcPatchSize) // we've hit an edge - { - x = 0; - z += step; - } - } - - if (setLODs) - setCurrentLODOfPatches(cLODs); - - return rv; - } - - - //! Populates an array with the CurrentLOD of each patch. - //! \param LODs: A reference to a core::array<s32> to hold the values - //! \return Returns the number of elements in the array - s32 CTerrainSceneNode::getCurrentLODOfPatches(core::array<s32>& LODs) const - { - s32 numLODs; - LODs.clear(); - - const s32 count = TerrainData.PatchCount * TerrainData.PatchCount; - for (numLODs = 0; numLODs < count; numLODs++) - LODs.push_back(TerrainData.Patches[numLODs].CurrentLOD); - - return LODs.size(); - } - - - //! Manually sets the LOD of a patch - //! \param patchX: Patch x coordinate. - //! \param patchZ: Patch z coordinate. - //! \param LOD: The level of detail to set the patch to. - void CTerrainSceneNode::setLODOfPatch(s32 patchX, s32 patchZ, s32 LOD) - { - TerrainData.Patches[patchX * TerrainData.PatchCount + patchZ].CurrentLOD = LOD; - } - - - //! Override the default generation of distance thresholds for determining the LOD a patch - //! is rendered at. - bool CTerrainSceneNode::overrideLODDistance(s32 LOD, f64 newDistance) - { - OverrideDistanceThreshold = true; - - if (LOD < 0 || LOD > TerrainData.MaxLOD - 1) - return false; - - TerrainData.LODDistanceThreshold[LOD] = newDistance * newDistance; - - return true; - } - - - //! Creates a planar texture mapping on the terrain - //! \param resolution: resolution of the planar mapping. This is the value - //! specifying the relation between world space and texture coordinate space. - void CTerrainSceneNode::scaleTexture(f32 resolution, f32 resolution2) - { - TCoordScale1 = resolution; - TCoordScale2 = resolution2; - - const f32 resBySize = resolution / (f32)(TerrainData.Size-1); - const f32 res2BySize = resolution2 / (f32)(TerrainData.Size-1); - u32 index = 0; - f32 xval = 0.f; - f32 x2val = 0.f; - for (s32 x=0; x<TerrainData.Size; ++x) - { - f32 zval=0.f; - f32 z2val=0.f; - for (s32 z=0; z<TerrainData.Size; ++z) - { - RenderBuffer->getVertexBuffer()[index].TCoords.X = 1.f-xval; - RenderBuffer->getVertexBuffer()[index].TCoords.Y = zval; - - if (RenderBuffer->getVertexType()==video::EVT_2TCOORDS) - { - if (resolution2 == 0) - { - ((video::S3DVertex2TCoords&)RenderBuffer->getVertexBuffer()[index]).TCoords2 = RenderBuffer->getVertexBuffer()[index].TCoords; - } - else - { - ((video::S3DVertex2TCoords&)RenderBuffer->getVertexBuffer()[index]).TCoords2.X = 1.f-x2val; - ((video::S3DVertex2TCoords&)RenderBuffer->getVertexBuffer()[index]).TCoords2.Y = z2val; - } - } - - ++index; - zval += resBySize; - z2val += res2BySize; - } - xval += resBySize; - x2val += res2BySize; - } - - RenderBuffer->setDirty(EBT_VERTEX); - } - - - //! used to get the indices when generating index data for patches at varying levels of detail. - u32 CTerrainSceneNode::getIndex(const s32 PatchX, const s32 PatchZ, - const s32 PatchIndex, u32 vX, u32 vZ) const - { - // top border - if (vZ == 0) - { - if (TerrainData.Patches[PatchIndex].Top && - TerrainData.Patches[PatchIndex].CurrentLOD < TerrainData.Patches[PatchIndex].Top->CurrentLOD && - (vX % (1 << TerrainData.Patches[PatchIndex].Top->CurrentLOD)) != 0 ) - { - vX -= vX % (1 << TerrainData.Patches[PatchIndex].Top->CurrentLOD); - } - } - else - if (vZ == (u32)TerrainData.CalcPatchSize) // bottom border - { - if (TerrainData.Patches[PatchIndex].Bottom && - TerrainData.Patches[PatchIndex].CurrentLOD < TerrainData.Patches[PatchIndex].Bottom->CurrentLOD && - (vX % (1 << TerrainData.Patches[PatchIndex].Bottom->CurrentLOD)) != 0) - { - vX -= vX % (1 << TerrainData.Patches[PatchIndex].Bottom->CurrentLOD); - } - } - - // left border - if (vX == 0) - { - if (TerrainData.Patches[PatchIndex].Left && - TerrainData.Patches[PatchIndex].CurrentLOD < TerrainData.Patches[PatchIndex].Left->CurrentLOD && - (vZ % (1 << TerrainData.Patches[PatchIndex].Left->CurrentLOD)) != 0) - { - vZ -= vZ % (1 << TerrainData.Patches[PatchIndex].Left->CurrentLOD); - } - } - else - if (vX == (u32)TerrainData.CalcPatchSize) // right border - { - if (TerrainData.Patches[PatchIndex].Right && - TerrainData.Patches[PatchIndex].CurrentLOD < TerrainData.Patches[PatchIndex].Right->CurrentLOD && - (vZ % (1 << TerrainData.Patches[PatchIndex].Right->CurrentLOD)) != 0) - { - vZ -= vZ % (1 << TerrainData.Patches[PatchIndex].Right->CurrentLOD); - } - } - - if (vZ >= (u32)TerrainData.PatchSize) - vZ = TerrainData.CalcPatchSize; - - if (vX >= (u32)TerrainData.PatchSize) - vX = TerrainData.CalcPatchSize; - - return (vZ + ((TerrainData.CalcPatchSize) * PatchZ)) * TerrainData.Size + - (vX + ((TerrainData.CalcPatchSize) * PatchX)); - } - - - //! smooth the terrain - void CTerrainSceneNode::smoothTerrain(CDynamicMeshBuffer* mb, s32 smoothFactor) - { - for (s32 run = 0; run < smoothFactor; ++run) - { - s32 yd = TerrainData.Size; - for (s32 y = 1; y < TerrainData.Size - 1; ++y) - { - for (s32 x = 1; x < TerrainData.Size - 1; ++x) - { - mb->getVertexBuffer()[x + yd].Pos.Y = - (mb->getVertexBuffer()[x-1 + yd].Pos.Y + - mb->getVertexBuffer()[x+1 + yd].Pos.Y + - mb->getVertexBuffer()[x + yd - TerrainData.Size].Pos.Y + - mb->getVertexBuffer()[x + yd - TerrainData.Size].Pos.Y) * 0.25f; - } - yd += TerrainData.Size; - } - } - } - - - //! calculate smooth normals - void CTerrainSceneNode::calculateNormals(CDynamicMeshBuffer* mb) - { - s32 count; - core::vector3df a, b, c, t; - - for (s32 x=0; x<TerrainData.Size; ++x) - { - for (s32 z=0; z<TerrainData.Size; ++z) - { - count = 0; - core::vector3df normal; - - // top left - if (x>0 && z>0) - { - a = mb->getVertexBuffer()[(x-1)*TerrainData.Size+z-1].Pos; - b = mb->getVertexBuffer()[(x-1)*TerrainData.Size+z].Pos; - c = mb->getVertexBuffer()[x*TerrainData.Size+z].Pos; - b -= a; - c -= a; - t = b.crossProduct(c); - t.normalize(); - normal += t; - - a = mb->getVertexBuffer()[(x-1)*TerrainData.Size+z-1].Pos; - b = mb->getVertexBuffer()[x*TerrainData.Size+z-1].Pos; - c = mb->getVertexBuffer()[x*TerrainData.Size+z].Pos; - b -= a; - c -= a; - t = b.crossProduct(c); - t.normalize(); - normal += t; - - count += 2; - } - - // top right - if (x>0 && z<TerrainData.Size-1) - { - a = mb->getVertexBuffer()[(x-1)*TerrainData.Size+z].Pos; - b = mb->getVertexBuffer()[(x-1)*TerrainData.Size+z+1].Pos; - c = mb->getVertexBuffer()[x*TerrainData.Size+z+1].Pos; - b -= a; - c -= a; - t = b.crossProduct(c); - t.normalize(); - normal += t; - - a = mb->getVertexBuffer()[(x-1)*TerrainData.Size+z].Pos; - b = mb->getVertexBuffer()[x*TerrainData.Size+z+1].Pos; - c = mb->getVertexBuffer()[x*TerrainData.Size+z].Pos; - b -= a; - c -= a; - t = b.crossProduct(c); - t.normalize(); - normal += t; - - count += 2; - } - - // bottom right - if (x<TerrainData.Size-1 && z<TerrainData.Size-1) - { - a = mb->getVertexBuffer()[x*TerrainData.Size+z+1].Pos; - b = mb->getVertexBuffer()[x*TerrainData.Size+z].Pos; - c = mb->getVertexBuffer()[(x+1)*TerrainData.Size+z+1].Pos; - b -= a; - c -= a; - t = b.crossProduct(c); - t.normalize(); - normal += t; - - a = mb->getVertexBuffer()[x*TerrainData.Size+z+1].Pos; - b = mb->getVertexBuffer()[(x+1)*TerrainData.Size+z+1].Pos; - c = mb->getVertexBuffer()[(x+1)*TerrainData.Size+z].Pos; - b -= a; - c -= a; - t = b.crossProduct(c); - t.normalize(); - normal += t; - - count += 2; - } - - // bottom left - if (x<TerrainData.Size-1 && z>0) - { - a = mb->getVertexBuffer()[x*TerrainData.Size+z-1].Pos; - b = mb->getVertexBuffer()[x*TerrainData.Size+z].Pos; - c = mb->getVertexBuffer()[(x+1)*TerrainData.Size+z].Pos; - b -= a; - c -= a; - t = b.crossProduct(c); - t.normalize(); - normal += t; - - a = mb->getVertexBuffer()[x*TerrainData.Size+z-1].Pos; - b = mb->getVertexBuffer()[(x+1)*TerrainData.Size+z].Pos; - c = mb->getVertexBuffer()[(x+1)*TerrainData.Size+z-1].Pos; - b -= a; - c -= a; - t = b.crossProduct(c); - t.normalize(); - normal += t; - - count += 2; - } - - if (count != 0) - { - normal.normalize(); - } - else - { - normal.set(0.0f, 1.0f, 0.0f); - } - - mb->getVertexBuffer()[x * TerrainData.Size + z].Normal = normal; - } - } - } - - - //! create patches, stuff that needs to be done only once for patches goes here. - void CTerrainSceneNode::createPatches() - { - TerrainData.PatchCount = (TerrainData.Size - 1) / (TerrainData.CalcPatchSize); - - if (TerrainData.Patches) - delete [] TerrainData.Patches; - - TerrainData.Patches = new SPatch[TerrainData.PatchCount * TerrainData.PatchCount]; - } - - - //! used to calculate the internal STerrainData structure both at creation and after scaling/position calls. - void CTerrainSceneNode::calculatePatchData() - { - // Reset the Terrains Bounding Box for re-calculation - TerrainData.BoundingBox = core::aabbox3df(999999.9f, 999999.9f, 999999.9f, -999999.9f, -999999.9f, -999999.9f); - - for (s32 x = 0; x < TerrainData.PatchCount; ++x) - { - for (s32 z = 0; z < TerrainData.PatchCount; ++z) - { - const s32 index = x * TerrainData.PatchCount + z; - TerrainData.Patches[index].CurrentLOD = 0; - - // For each patch, calculate the bounding box (mins and maxes) - TerrainData.Patches[index].BoundingBox = core::aabbox3df(999999.9f, 999999.9f, 999999.9f, - -999999.9f, -999999.9f, -999999.9f); - - for (s32 xx = x*(TerrainData.CalcPatchSize); xx <= (x + 1) * TerrainData.CalcPatchSize; ++xx) - for (s32 zz = z*(TerrainData.CalcPatchSize); zz <= (z + 1) * TerrainData.CalcPatchSize; ++zz) - TerrainData.Patches[index].BoundingBox.addInternalPoint(RenderBuffer->getVertexBuffer()[xx * TerrainData.Size + zz].Pos); - - - // Reconfigure the bounding box of the terrain as a whole - TerrainData.BoundingBox.addInternalBox(TerrainData.Patches[index].BoundingBox); - - // get center of Patch - TerrainData.Patches[index].Center = TerrainData.Patches[index].BoundingBox.getCenter(); - - // Assign Neighbours - // Top - if (x > 0) - TerrainData.Patches[index].Top = &TerrainData.Patches[(x-1) * TerrainData.PatchCount + z]; - else - TerrainData.Patches[index].Top = 0; - - // Bottom - if (x < TerrainData.PatchCount - 1) - TerrainData.Patches[index].Bottom = &TerrainData.Patches[(x+1) * TerrainData.PatchCount + z]; - else - TerrainData.Patches[index].Bottom = 0; - - // Left - if (z > 0) - TerrainData.Patches[index].Left = &TerrainData.Patches[x * TerrainData.PatchCount + z - 1]; - else - TerrainData.Patches[index].Left = 0; - - // Right - if (z < TerrainData.PatchCount - 1) - TerrainData.Patches[index].Right = &TerrainData.Patches[x * TerrainData.PatchCount + z + 1]; - else - TerrainData.Patches[index].Right = 0; - } - } - - // get center of Terrain - TerrainData.Center = TerrainData.BoundingBox.getCenter(); - - // if the default rotation pivot is still being used, update it. - if (UseDefaultRotationPivot) - { - TerrainData.RotationPivot = TerrainData.Center; - } - } - - - //! used to calculate or recalculate the distance thresholds - void CTerrainSceneNode::calculateDistanceThresholds(bool scalechanged) - { - // Only update the LODDistanceThreshold if it's not manually changed - if (!OverrideDistanceThreshold) - { - TerrainData.LODDistanceThreshold.set_used(0); - // Determine new distance threshold for determining what LOD to draw patches at - TerrainData.LODDistanceThreshold.reallocate(TerrainData.MaxLOD); - - const f64 size = TerrainData.PatchSize * TerrainData.PatchSize * - TerrainData.Scale.X * TerrainData.Scale.Z; - for (s32 i=0; i<TerrainData.MaxLOD; ++i) - { - TerrainData.LODDistanceThreshold.push_back(size * ((i+1+ i / 2) * (i+1+ i / 2))); - } - } - } - - - void CTerrainSceneNode::setCurrentLODOfPatches(s32 lod) - { - const s32 count = TerrainData.PatchCount * TerrainData.PatchCount; - for (s32 i=0; i< count; ++i) - TerrainData.Patches[i].CurrentLOD = lod; - } - - - void CTerrainSceneNode::setCurrentLODOfPatches(const core::array<s32>& lodarray) - { - const s32 count = TerrainData.PatchCount * TerrainData.PatchCount; - for (s32 i=0; i<count; ++i) - TerrainData.Patches[i].CurrentLOD = lodarray[i]; - } - - - //! Gets the height - f32 CTerrainSceneNode::getHeight(f32 x, f32 z) const - { - if (!Mesh.getMeshBufferCount()) - return 0; - - f32 height = -999999.9f; - - core::matrix4 rotMatrix; - rotMatrix.setRotationDegrees(TerrainData.Rotation); - core::vector3df pos(x, 0.0f, z); - rotMatrix.rotateVect(pos); - pos -= TerrainData.Position; - pos /= TerrainData.Scale; - - s32 X(core::floor32(pos.X)); - s32 Z(core::floor32(pos.Z)); - - if (X >= 0 && X < TerrainData.Size-1 && - Z >= 0 && Z < TerrainData.Size-1) - { - const video::S3DVertex2TCoords* Vertices = (const video::S3DVertex2TCoords*)Mesh.getMeshBuffer(0)->getVertices(); - const core::vector3df& a = Vertices[X * TerrainData.Size + Z].Pos; - const core::vector3df& b = Vertices[(X + 1) * TerrainData.Size + Z].Pos; - const core::vector3df& c = Vertices[X * TerrainData.Size + (Z + 1)].Pos; - const core::vector3df& d = Vertices[(X + 1) * TerrainData.Size + (Z + 1)].Pos; - - // offset from integer position - const f32 dx = pos.X - X; - const f32 dz = pos.Z - Z; - - if (dx > dz) - height = a.Y + (d.Y - b.Y)*dz + (b.Y - a.Y)*dx; - else - height = a.Y + (d.Y - c.Y)*dx + (c.Y - a.Y)*dz; - - height *= TerrainData.Scale.Y; - height += TerrainData.Position.Y; - } - - return height; - } - - - //! Writes attributes of the scene node. - void CTerrainSceneNode::serializeAttributes(io::IAttributes* out, - io::SAttributeReadWriteOptions* options) const - { - ISceneNode::serializeAttributes(out, options); - - out->addString("Heightmap", HeightmapFile.c_str()); - out->addFloat("TextureScale1", TCoordScale1); - out->addFloat("TextureScale2", TCoordScale2); - } - - - //! Reads attributes of the scene node. - void CTerrainSceneNode::deserializeAttributes(io::IAttributes* in, - io::SAttributeReadWriteOptions* options) - { - io::path newHeightmap = in->getAttributeAsString("Heightmap"); - f32 tcoordScale1 = in->getAttributeAsFloat("TextureScale1"); - f32 tcoordScale2 = in->getAttributeAsFloat("TextureScale2"); - - // set possible new heightmap - - if (newHeightmap.size() != 0 && newHeightmap != HeightmapFile) - { - io::IReadFile* file = FileSystem->createAndOpenFile(newHeightmap.c_str()); - if (file) - { - loadHeightMap(file, video::SColor(255,255,255,255), 0); - file->drop(); - } - else - os::Printer::log("could not open heightmap", newHeightmap.c_str()); - } - - // set possible new scale - - if (core::equals(tcoordScale1, 0.f)) - tcoordScale1 = 1.0f; - - if (core::equals(tcoordScale2, 0.f)) - tcoordScale2 = 1.0f; - - if (!core::equals(tcoordScale1, TCoordScale1) || - !core::equals(tcoordScale2, TCoordScale2)) - { - scaleTexture(tcoordScale1, tcoordScale2); - } - - ISceneNode::deserializeAttributes(in, options); - } - - - //! Creates a clone of this scene node and its children. - ISceneNode* CTerrainSceneNode::clone(ISceneNode* newParent, ISceneManager* newManager) - { - if (!newParent) - newParent = Parent; - if (!newManager) - newManager = SceneManager; - - CTerrainSceneNode* nb = new CTerrainSceneNode( - newParent, newManager, FileSystem, ID, - 4, ETPS_17, getPosition(), getRotation(), getScale()); - - nb->cloneMembers(this, newManager); - - // instead of cloning the data structures, recreate the terrain. - // (temporary solution) - - // load file - - io::IReadFile* file = FileSystem->createAndOpenFile(HeightmapFile.c_str()); - if (file) - { - nb->loadHeightMap(file, video::SColor(255,255,255,255), 0); - file->drop(); - } - - // scale textures - - nb->scaleTexture(TCoordScale1, TCoordScale2); - - // copy materials - - for (unsigned int m = 0; m<Mesh.getMeshBufferCount(); ++m) - { - if (nb->Mesh.getMeshBufferCount()>m && - nb->Mesh.getMeshBuffer(m) && - Mesh.getMeshBuffer(m)) - { - nb->Mesh.getMeshBuffer(m)->getMaterial() = - Mesh.getMeshBuffer(m)->getMaterial(); - } - } - - nb->RenderBuffer->Material = RenderBuffer->Material; - - // finish - - nb->drop(); - return nb; - } - -} // end namespace scene -} // end namespace irr - - diff --git a/irrlicht-1.6/source/Irrlicht/CTerrainSceneNode.h b/irrlicht-1.6/source/Irrlicht/CTerrainSceneNode.h deleted file mode 100644 index 66705ef31..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTerrainSceneNode.h +++ /dev/null @@ -1,343 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -// The code for the TerrainSceneNode is based on the GeoMipMapSceneNode -// developed by Spintz. He made it available for Irrlicht and allowed it to be -// distributed under this licence. I only modified some parts. A lot of thanks go to him. - -#ifndef __C_TERRAIN_SCENE_NODE_H__ -#define __C_TERRAIN_SCENE_NODE_H__ - -#include "ITerrainSceneNode.h" -#include "SMesh.h" -#include "CDynamicMeshBuffer.h" -#include "path.h" - -namespace irr -{ -namespace io -{ - class IFileSystem; - class IReadFile; -} -namespace scene -{ - class ITextSceneNode; - - //! A scene node for displaying terrain using the geo mip map algorithm. - class CTerrainSceneNode : public ITerrainSceneNode - { - public: - - //! constructor - //! \param parent: The node which this node is a child of. Making this node a child of another node, or - //! making it a parent of another node is yet untested and most likely does not work properly. - //! \param mgr: Pointer to the scene manager. - //! \param id: The id of the node - //! \param maxLOD: The maximum LOD ( Level of Detail ) for the node. - //! \param patchSize: An E_GEOMIPMAP_PATCH_SIZE enumeration defining the size of each patch of the terrain. - //! \param position: The absolute position of this node. - //! \param rotation: The absolute rotation of this node. ( NOT YET IMPLEMENTED ) - //! \param scale: The scale factor for the terrain. If you're using a heightmap of size 128x128 and would like - //! your terrain to be 12800x12800 in game units, then use a scale factor of ( core::vector ( 100.0f, 100.0f, 100.0f ). - //! If you use a Y scaling factor of 0.0f, then your terrain will be flat. - CTerrainSceneNode(ISceneNode* parent, ISceneManager* mgr, io::IFileSystem* fs, s32 id, - s32 maxLOD = 4, E_TERRAIN_PATCH_SIZE patchSize = ETPS_17, - const core::vector3df& position = core::vector3df(0.0f, 0.0f, 0.0f), - const core::vector3df& rotation = core::vector3df(0.0f, 0.0f, 0.0f), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); - - virtual ~CTerrainSceneNode(); - - //! Initializes the terrain data. Loads the vertices from the heightMapFile. - virtual bool loadHeightMap(io::IReadFile* file, - video::SColor vertexColor = video::SColor ( 255, 255, 255, 255 ), s32 smoothFactor = 0 ); - - //! Initializes the terrain data. Loads the vertices from the heightMapFile. - virtual bool loadHeightMapRAW(io::IReadFile* file, s32 bitsPerPixel = 16, - bool signedData=true, bool floatVals=false, s32 width=0, video::SColor vertexColor = video::SColor ( 255, 255, 255, 255 ), s32 smoothFactor = 0 ); - - //! Returns the material based on the zero based index i. This scene node only uses - //! 1 material. - //! \param i: Zero based index i. UNUSED, left in for virtual purposes. - //! \return Returns the single material this scene node uses. - virtual video::SMaterial& getMaterial ( u32 i ) - { - return Mesh.getMeshBuffer(i)->getMaterial(); - } - - //! Returns amount of materials used by this scene node ( always 1 ) - //! \return Returns current count of materials used by this scene node ( always 1 ) - virtual u32 getMaterialCount() const - { - return Mesh.getMeshBufferCount(); - } - - //! Gets the last scaling factor applied to the scene node. This value only represents the - //! last scaling factor presented to the node. For instance, if you make create the node - //! with a scale factor of ( 1.0f, 1.0f, 1.0f ) then call setScale ( 50.0f, 5.0f, 50.0f ), - //! then make another call to setScale with the values ( 2.0f, 2.0f, 2.0f ), this will return - //! core::vector3df ( 2.0f, 2.0f, 2.0f ), although the total scaling of the scene node is - //! core::vector3df ( 100.0f, 10.0f, 100.0f ). - //! \return Returns the last scaling factor passed to the scene node. - virtual const core::vector3df& getScale() const - { - return TerrainData.Scale; - } - - //! Scales the scene nodes vertices by the vector specified. - //! \param scale: Scaling factor to apply to the node. - virtual void setScale(const core::vector3df& scale); - - //! Gets the last rotation factor applied to the scene node. - //! \return Returns the last rotation factor applied to the scene node. - virtual const core::vector3df& getRotation() const - { - return TerrainData.Rotation; - } - - //! Rotates the node. This only modifies the relative rotation of the node. - //! \param rotation: New rotation of the node in degrees. - virtual void setRotation(const core::vector3df& rotation); - - //! Sets the pivot point for rotation of this node. - //! NOTE: The default for the RotationPivot will be the center of the individual tile. - virtual void setRotationPivot( const core::vector3df& pivot ); - - //! Gets the last positioning vector applied to the scene node. - //! \return Returns the last position vector applied to the scene node. - virtual const core::vector3df& getPosition() const - { - return TerrainData.Position; - } - - //! Moves the scene nodes vertices by the vector specified. - //! \param newpos: Vector specifying how much to move each vertex of the scene node. - virtual void setPosition(const core::vector3df& newpos); - - //! Updates the scene nodes indices if the camera has moved or rotated by a certain - //! threshold, which can be changed using the SetCameraMovementDeltaThreshold and - //! SetCameraRotationDeltaThreshold functions. This also determines if a given patch - //! for the scene node is within the view frustum and if it's not the indices are not - //! generated for that patch. - virtual void OnRegisterSceneNode(); - - //! Render the scene node - virtual void render(); - - //! Return the bounding box of the entire terrain. - virtual const core::aabbox3d<f32>& getBoundingBox() const; - - //! Return the bounding box of a patch - virtual const core::aabbox3d<f32>& getBoundingBox(s32 patchX, s32 patchZ) const; - - //! Return the number of indices currently used to draw the scene node. - virtual u32 getIndexCount() const { return IndicesToRender; } - - //! Returns the mesh - virtual IMesh* getMesh() { return &Mesh; } - - //! Returns a pointer to the buffer used by the terrain (most users will not need this) - virtual IMeshBuffer* getRenderBuffer() { return RenderBuffer; } - - //! Gets the meshbuffer data based on a specified Level of Detail. - //! \param mb: A reference to an IDynamicMeshBuffer object - //! \param LOD: The Level Of Detail you want the indices from. - virtual void getMeshBufferForLOD(IDynamicMeshBuffer& mb, s32 LOD=0) const; - - //! Gets the indices for a specified patch at a specified Level of Detail. - //! \param indices: A reference to an array of u32 indices. - //! \param patchX: Patch x coordinate. - //! \param patchZ: Patch z coordinate. - //! \param LOD: The level of detail to get for that patch. If -1, then get - //! the CurrentLOD. If the CurrentLOD is set to -1, meaning it's not shown, - //! then it will retrieve the triangles at the highest LOD (0). - //! \return: Number of indices put into the buffer. - virtual s32 getIndicesForPatch(core::array<u32>& indices, - s32 patchX, s32 patchZ, s32 LOD=0); - - //! Populates an array with the CurrentLOD of each patch. - //! \param LODs: A reference to a core::array<s32> to hold the values - //! \return Returns the number of elements in the array - virtual s32 getCurrentLODOfPatches(core::array<s32>& LODs) const; - - //! Manually sets the LOD of a patch - //! \param patchX: Patch x coordinate. - //! \param patchZ: Patch z coordinate. - //! \param LOD: The level of detail to set the patch to. - virtual void setLODOfPatch(s32 patchX, s32 patchZ, s32 LOD=0); - - //! Returns center of terrain. - virtual const core::vector3df& getTerrainCenter() const - { - return TerrainData.Center; - } - - //! Returns center of terrain. - virtual f32 getHeight( f32 x, f32 y ) const; - - //! Sets the movement camera threshold which is used to determine when to recalculate - //! indices for the scene node. The default value is 10.0f. - virtual void setCameraMovementDelta(f32 delta) - { - CameraMovementDelta = delta; - } - - //! Sets the rotation camera threshold which is used to determine when to recalculate - //! indices for the scene node. The default value is 1.0f. - virtual void setCameraRotationDelta(f32 delta) - { - CameraRotationDelta = delta; - } - - //! Sets whether or not the node should dynamically update it its associated selector when - //! the geomipmap data changes. - //! param bVal: Boolean value representing whether or not to update selector dynamically. - //! NOTE: Temporarily disabled while working out issues with DynamicSelectorUpdate - virtual void setDynamicSelectorUpdate(bool bVal ) { DynamicSelectorUpdate = false; } - - //! Override the default generation of distance thresholds for determining the LOD a patch - //! is rendered at. If any LOD is overridden, then the scene node will no longer apply - //! scaling factors to these values. If you override these distances and then apply - //! a scale to the scene node, it is your responsibility to update the new distances to - //! work best with your new terrain size. - virtual bool overrideLODDistance( s32 LOD, f64 newDistance ); - - //! Scales the two textures - virtual void scaleTexture(f32 scale = 1.0f, f32 scale2 = 0.0f); - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() const {return ESNT_TERRAIN;} - - //! Writes attributes of the scene node. - virtual void serializeAttributes(io::IAttributes* out, - io::SAttributeReadWriteOptions* options=0) const; - - //! Reads attributes of the scene node. - virtual void deserializeAttributes(io::IAttributes* in, - io::SAttributeReadWriteOptions* options=0); - - //! Creates a clone of this scene node and its children. - virtual ISceneNode* clone(ISceneNode* newParent, - ISceneManager* newManager); - - private: - - friend class CTerrainTriangleSelector; - - struct SPatch - { - SPatch() - : CurrentLOD(-1), Top(0), Bottom(0), Right(0), Left(0) - { - } - - s32 CurrentLOD; - core::aabbox3df BoundingBox; - core::vector3df Center; - SPatch* Top; - SPatch* Bottom; - SPatch* Right; - SPatch* Left; - }; - - struct STerrainData - { - STerrainData() - : Size(0), PatchSize(0), CalcPatchSize(0), - PatchCount(0), MaxLOD(0), - BoundingBox(core::aabbox3df( 99999.9f, 99999.9f, 99999.9f, -99999.9f, -99999.9f, -99999.9f)), - Patches(0) - { - } - - STerrainData(s32 patchSize, s32 maxLOD, const core::vector3df& position, const core::vector3df& rotation, const core::vector3df& scale) - : Size(0), Position(position), Rotation(rotation), Scale(scale), - PatchSize(patchSize), CalcPatchSize(patchSize-1), - PatchCount(0), MaxLOD(maxLOD), - BoundingBox(core::aabbox3df( 99999.9f, 99999.9f, 99999.9f, -99999.9f, -99999.9f, -99999.9f)), - Patches(0) - { - } - - s32 Size; - core::vector3df Position; - core::vector3df Rotation; - core::vector3df RotationPivot; - core::vector3df Scale; - core::vector3df Center; - s32 PatchSize; - s32 CalcPatchSize; - s32 PatchCount; - s32 MaxLOD; - core::aabbox3df BoundingBox; - core::array<f64> LODDistanceThreshold; - SPatch* Patches; - }; - - virtual void preRenderLODCalculations(); - virtual void preRenderIndicesCalculations(); - - //! get indices when generating index data for patches at varying levels of detail. - u32 getIndex(const s32 PatchX, const s32 PatchZ, const s32 PatchIndex, u32 vX, u32 vZ) const; - - //! smooth the terrain - void smoothTerrain(CDynamicMeshBuffer* mb, s32 smoothFactor); - - //! calculate smooth normals - void calculateNormals(CDynamicMeshBuffer* mb); - - //! create patches, stuff that needs to only be done once for patches goes here. - void createPatches(); - - //! calculate the internal STerrainData structure - void calculatePatchData(); - - //! calculate or recalculate the distance thresholds - void calculateDistanceThresholds(bool scalechanged = false); - - //! sets the CurrentLOD of all patches to the specified LOD - void setCurrentLODOfPatches(s32 i); - - //! sets the CurrentLOD of TerrainData patches to the LODs specified in the array - void setCurrentLODOfPatches(const core::array<s32>& lodarray); - - //! Apply transformation changes( scale, position, rotation ) - void applyTransformation(); - - STerrainData TerrainData; - SMesh Mesh; - - CDynamicMeshBuffer *RenderBuffer; - - u32 VerticesToRender; - u32 IndicesToRender; - - bool DynamicSelectorUpdate; - bool OverrideDistanceThreshold; - bool UseDefaultRotationPivot; - bool ForceRecalculation; - - core::vector3df OldCameraPosition; - core::vector3df OldCameraRotation; - core::vector3df OldCameraUp; - f32 OldCameraFOV; - f32 CameraMovementDelta; - f32 CameraRotationDelta; - f32 CameraFOVDelta; - - // needed for (de)serialization - f32 TCoordScale1; - f32 TCoordScale2; - io::path HeightmapFile; - io::IFileSystem* FileSystem; - }; - - -} // end namespace scene -} // end namespace irr - -#endif // __C_TERRAIN_SCENE_NODE_H__ - - diff --git a/irrlicht-1.6/source/Irrlicht/CTerrainTriangleSelector.cpp b/irrlicht-1.6/source/Irrlicht/CTerrainTriangleSelector.cpp deleted file mode 100644 index 54a83b63c..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTerrainTriangleSelector.cpp +++ /dev/null @@ -1,191 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CTerrainTriangleSelector.h" -#include "CTerrainSceneNode.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - - -//! constructor -CTerrainTriangleSelector::CTerrainTriangleSelector ( ITerrainSceneNode* node, s32 LOD ) - : SceneNode(node) -{ - #ifdef _DEBUG - setDebugName ("CTerrainTriangleSelector"); - #endif - - setTriangleData(node, LOD); -} - - -//! destructor -CTerrainTriangleSelector::~CTerrainTriangleSelector() -{ - TrianglePatches.TrianglePatchArray.clear(); -} - - -//! Clears and sets triangle data -void CTerrainTriangleSelector::setTriangleData(ITerrainSceneNode* node, s32 LOD) -{ - core::triangle3df tri; - core::array<u32> indices; - - // Get pointer to the GeoMipMaps vertices - video::S3DVertex2TCoords* vertices = static_cast<video::S3DVertex2TCoords*>(node->getRenderBuffer()->getVertices()); - - // Clear current data - const s32 count = (static_cast<CTerrainSceneNode*>(node))->TerrainData.PatchCount; - TrianglePatches.TotalTriangles = 0; - TrianglePatches.NumPatches = count*count; - - TrianglePatches.TrianglePatchArray.reallocate(TrianglePatches.NumPatches); - for (s32 o=0; o<TrianglePatches.NumPatches; ++o) - TrianglePatches.TrianglePatchArray.push_back(SGeoMipMapTrianglePatch()); - - s32 tIndex = 0; - for(s32 x = 0; x < count; ++x ) - { - for(s32 z = 0; z < count; ++z ) - { - TrianglePatches.TrianglePatchArray[tIndex].NumTriangles = 0; - TrianglePatches.TrianglePatchArray[tIndex].Box = node->getBoundingBox( x, z ); - u32 indexCount = node->getIndicesForPatch( indices, x, z, LOD ); - - TrianglePatches.TrianglePatchArray[tIndex].Triangles.reallocate(indexCount/3); - for(u32 i = 0; i < indexCount; i += 3 ) - { - tri.pointA = vertices[indices[i+0]].Pos; - tri.pointB = vertices[indices[i+1]].Pos; - tri.pointC = vertices[indices[i+2]].Pos; - TrianglePatches.TrianglePatchArray[tIndex].Triangles.push_back(tri); - ++TrianglePatches.TrianglePatchArray[tIndex].NumTriangles; - } - - TrianglePatches.TotalTriangles += TrianglePatches.TrianglePatchArray[tIndex].NumTriangles; - ++tIndex; - } - } -} - -//! Gets all triangles. -void CTerrainTriangleSelector::getTriangles ( core::triangle3df* triangles, s32 arraySize, - s32& outTriangleCount, const core::matrix4* transform) const -{ - s32 count = TrianglePatches.TotalTriangles; - - if (count > arraySize) - count = arraySize; - - core::matrix4 mat; - - if (transform) - mat = (*transform); - - s32 tIndex = 0; - - for (s32 i=0; i<TrianglePatches.NumPatches; ++i) - { - if (tIndex + TrianglePatches.TrianglePatchArray[i].NumTriangles <= count) - for (s32 j=0; j<TrianglePatches.TrianglePatchArray[i].NumTriangles; ++j) - { - triangles[tIndex] = TrianglePatches.TrianglePatchArray[i].Triangles[j]; - - mat.transformVect(triangles[tIndex].pointA); - mat.transformVect(triangles[tIndex].pointB); - mat.transformVect(triangles[tIndex].pointC); - - ++tIndex; - } - } - - outTriangleCount = tIndex; -} - - -//! Gets all triangles which lie within a specific bounding box. -void CTerrainTriangleSelector::getTriangles ( core::triangle3df* triangles, s32 arraySize, - s32& outTriangleCount, const core::aabbox3d<f32>& box, - const core::matrix4* transform) const -{ - s32 count = TrianglePatches.TotalTriangles; - - if (count > arraySize) - count = arraySize; - - core::matrix4 mat; - - if (transform) - mat = (*transform); - - s32 tIndex = 0; - - for (s32 i=0; i<TrianglePatches.NumPatches; ++i) - { - if (tIndex + TrianglePatches.TrianglePatchArray[i].NumTriangles <= count && - TrianglePatches.TrianglePatchArray[i].Box.intersectsWithBox(box)) - for (s32 j=0; j<TrianglePatches.TrianglePatchArray[i].NumTriangles; ++j) - { - triangles[tIndex] = TrianglePatches.TrianglePatchArray[i].Triangles[j]; - - mat.transformVect(triangles[tIndex].pointA); - mat.transformVect(triangles[tIndex].pointB); - mat.transformVect(triangles[tIndex].pointC); - - ++tIndex; - } - } - - outTriangleCount = tIndex; -} - -//! Gets all triangles which have or may have contact with a 3d line. -void CTerrainTriangleSelector::getTriangles(core::triangle3df* triangles, s32 arraySize, - s32& outTriangleCount, const core::line3d<f32>& line, - const core::matrix4* transform) const -{ - const s32 count = core::min_((s32)TrianglePatches.TotalTriangles, arraySize); - - core::matrix4 mat; - - if (transform) - mat = (*transform); - - s32 tIndex = 0; - - for (s32 i=0; i<TrianglePatches.NumPatches; ++i) - { - if (tIndex + TrianglePatches.TrianglePatchArray[i].NumTriangles <= count - && TrianglePatches.TrianglePatchArray[i].Box.intersectsWithLine(line)) - { - for (s32 j=0; j<TrianglePatches.TrianglePatchArray[i].NumTriangles; ++j) - { - triangles[tIndex] = TrianglePatches.TrianglePatchArray[i].Triangles[j]; - - mat.transformVect(triangles[tIndex].pointA); - mat.transformVect(triangles[tIndex].pointB); - mat.transformVect(triangles[tIndex].pointC); - - ++tIndex; - } - } - } - - outTriangleCount = tIndex; -} - -//! Returns amount of all available triangles in this selector -s32 CTerrainTriangleSelector::getTriangleCount() const -{ - return TrianglePatches.TotalTriangles; -} - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CTerrainTriangleSelector.h b/irrlicht-1.6/source/Irrlicht/CTerrainTriangleSelector.h deleted file mode 100644 index 5840f3f45..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTerrainTriangleSelector.h +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -// The code for the TerrainTriangleSelector is based on the GeoMipMapSelector -// developed by Spintz. He made it available for Irrlicht and allowed it to be -// distributed under this licence. I only modified some parts. A lot of thanks go to him. - -#ifndef __C_TERRAIN_TRIANGLE_SELECTOR_H__ -#define __C_TERRAIN_TRIANGLE_SELECTOR_H__ - -#include "ITriangleSelector.h" -#include "irrArray.h" - -namespace irr -{ -namespace scene -{ - -class ITerrainSceneNode; - -//! Triangle Selector for the TerrainSceneNode -//! The code for the TerrainTriangleSelector is based on the GeoMipMapSelector -//! developed by Spintz. He made it available for Irrlicht and allowed it to be -//! distributed under this licence. I only modified some parts. A lot of thanks go to him. -class CTerrainTriangleSelector : public ITriangleSelector -{ -public: - - //! Constructs a selector based on an IGeoMipMapSceneNode - CTerrainTriangleSelector(ITerrainSceneNode* node, s32 LOD); - - //! Destructor - virtual ~CTerrainTriangleSelector(); - - //! Clears and sets triangle data - virtual void setTriangleData (ITerrainSceneNode* node, s32 LOD); - - //! Gets all triangles. - void getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount, - const core::matrix4* transform=0) const; - - //! Gets all triangles which lie within a specific bounding box. - void getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount, - const core::aabbox3d<f32>& box, const core::matrix4* transform=0) const; - - //! Gets all triangles which have or may have contact with a 3d line. - virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, - s32& outTriangleCount, const core::line3d<f32>& line, - const core::matrix4* transform=0) const; - - //! Returns amount of all available triangles in this selector - virtual s32 getTriangleCount() const; - - //! Return the scene node associated with a given triangle. - /** ITerrainSceneNode is an ISceneNode, we just don't know it yet. */ - virtual const ISceneNode* getSceneNodeForTriangle(u32 triangleIndex) const - { return (ISceneNode*)SceneNode; } - -private: - - friend class CTerrainSceneNode; - - struct SGeoMipMapTrianglePatch - { - core::array<core::triangle3df> Triangles; - s32 NumTriangles; - core::aabbox3df Box; - }; - - struct SGeoMipMapTrianglePatches - { - SGeoMipMapTrianglePatches() : - NumPatches(0), TotalTriangles(0) - { - } - - core::array<SGeoMipMapTrianglePatch> TrianglePatchArray; - s32 NumPatches; - u32 TotalTriangles; - }; - - ITerrainSceneNode* SceneNode; - SGeoMipMapTrianglePatches TrianglePatches; -}; - -} // end namespace scene -} // end namespace irr - - -#endif // __C_TERRAIN_TRIANGLE_SELECTOR_H__ - diff --git a/irrlicht-1.6/source/Irrlicht/CTextSceneNode.cpp b/irrlicht-1.6/source/Irrlicht/CTextSceneNode.cpp deleted file mode 100644 index 242541ef1..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTextSceneNode.cpp +++ /dev/null @@ -1,454 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CTextSceneNode.h" -#include "ISceneManager.h" -#include "IVideoDriver.h" -#include "ICameraSceneNode.h" -#include "IGUISpriteBank.h" -#include "SMeshBuffer.h" -#include "os.h" - - -namespace irr -{ -namespace scene -{ - - -//! constructor -CTextSceneNode::CTextSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - gui::IGUIFont* font, scene::ISceneCollisionManager* coll, - const core::vector3df& position, const wchar_t* text, - video::SColor color) - : ITextSceneNode(parent, mgr, id, position), Text(text), Color(color), - Font(font), Coll(coll) - -{ - #ifdef _DEBUG - setDebugName("CTextSceneNode"); - #endif - - if (Font) - Font->grab(); - - setAutomaticCulling(scene::EAC_OFF); -} - -//! destructor -CTextSceneNode::~CTextSceneNode() -{ - if (Font) - Font->drop(); -} - -void CTextSceneNode::OnRegisterSceneNode() -{ - if (IsVisible) - SceneManager->registerNodeForRendering(this, ESNRP_TRANSPARENT); - - ISceneNode::OnRegisterSceneNode(); -} - -//! renders the node. -void CTextSceneNode::render() -{ - if (!Font || !Coll) - return; - - core::position2d<s32> pos = Coll->getScreenCoordinatesFrom3DPosition(getAbsolutePosition(), - SceneManager->getActiveCamera()); - - core::rect<s32> r(pos, core::dimension2d<s32>(1,1)); - Font->draw(Text.c_str(), r, Color, true, true); -} - - -//! returns the axis aligned bounding box of this node -const core::aabbox3d<f32>& CTextSceneNode::getBoundingBox() const -{ - return Box; -} - -//! sets the text string -void CTextSceneNode::setText(const wchar_t* text) -{ - Text = text; -} - - -//! sets the color of the text -void CTextSceneNode::setTextColor(video::SColor color) -{ - Color = color; -} - - -//!--------------------------------- CBillboardTextSceneNode ---------------------------------------------- - - -//! constructor -CBillboardTextSceneNode::CBillboardTextSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - gui::IGUIFont* font,const wchar_t* text, - const core::vector3df& position, const core::dimension2d<f32>& size, - video::SColor colorTop,video::SColor shade_bottom ) -: IBillboardTextSceneNode(parent, mgr, id, position), - Font(0), ColorTop(colorTop), ColorBottom(shade_bottom), Mesh(0) -{ - #ifdef _DEBUG - setDebugName("CBillboardTextSceneNode"); - #endif - - Material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; - Material.MaterialTypeParam = 1.f / 255.f; - Material.BackfaceCulling = false; - Material.Lighting = false; - Material.ZBuffer = video::ECFN_LESSEQUAL; - Material.ZWriteEnable = false; - - if (font) - { - // doesn't support other font types - if (font->getType() == gui::EGFT_BITMAP) - { - Font = (gui::IGUIFontBitmap*)font; - Font->grab(); - - // mesh with one buffer per texture - Mesh = new SMesh(); - for (u32 i=0; i<Font->getSpriteBank()->getTextureCount(); ++i) - { - SMeshBuffer *mb = new SMeshBuffer(); - mb->Material = Material; - mb->Material.setTexture(0, Font->getSpriteBank()->getTexture(i)); - Mesh->addMeshBuffer(mb); - mb->drop(); - } - } - else - { - os::Printer::log("Sorry, CBillboardTextSceneNode does not support this font type", ELL_INFORMATION); - } - } - - setText(text); - setSize(size); - - setAutomaticCulling ( scene::EAC_BOX ); -} - - - -CBillboardTextSceneNode::~CBillboardTextSceneNode() -{ - if (Font) - Font->drop(); - - if (Mesh) - Mesh->drop(); - -} - - -//! sets the text string -void CBillboardTextSceneNode::setText(const wchar_t* text) -{ - Text = text; - - Symbol.clear(); - - // clear mesh - for (u32 j=0; j < Mesh->getMeshBufferCount(); ++j) - { - ((SMeshBuffer*)Mesh->getMeshBuffer(j))->Indices.clear(); - ((SMeshBuffer*)Mesh->getMeshBuffer(j))->Vertices.clear(); - } - - if (!Font) - return; - - const core::array< core::rect<s32> > &sourceRects = Font->getSpriteBank()->getPositions(); - const core::array< gui::SGUISprite > &sprites = Font->getSpriteBank()->getSprites(); - - f32 dim[2]; - f32 tex[4]; - - u32 i; - for ( i = 0; i != Text.size (); ++i ) - { - SSymbolInfo info; - - u32 spriteno = Font->getSpriteNoFromChar( &text[i] ); - u32 rectno = sprites[spriteno].Frames[0].rectNumber; - u32 texno = sprites[spriteno].Frames[0].textureNumber; - - dim[0] = core::reciprocal ( (f32) Font->getSpriteBank()->getTexture(texno)->getSize().Width ); - dim[1] = core::reciprocal ( (f32) Font->getSpriteBank()->getTexture(texno)->getSize().Height ); - - const core::rect<s32>& s = sourceRects[rectno]; - - // add space for letter to buffer - SMeshBuffer* buf = (SMeshBuffer*)Mesh->getMeshBuffer(texno); - u32 firstInd = buf->Indices.size(); - u32 firstVert = buf->Vertices.size(); - buf->Indices.set_used(firstInd + 6); - buf->Vertices.set_used(firstVert + 4); - - tex[0] = (s.LowerRightCorner.X * dim[0]) + 0.5f*dim[0]; // half pixel - tex[1] = (s.LowerRightCorner.Y * dim[1]) + 0.5f*dim[1]; - tex[2] = (s.UpperLeftCorner.Y * dim[1]) - 0.5f*dim[1]; - tex[3] = (s.UpperLeftCorner.X * dim[0]) - 0.5f*dim[0]; - - buf->Vertices[firstVert+0].TCoords.set(tex[0], tex[1]); - buf->Vertices[firstVert+1].TCoords.set(tex[0], tex[2]); - buf->Vertices[firstVert+2].TCoords.set(tex[3], tex[2]); - buf->Vertices[firstVert+3].TCoords.set(tex[3], tex[1]); - - buf->Vertices[firstVert+0].Color = ColorBottom; - buf->Vertices[firstVert+3].Color = ColorBottom; - buf->Vertices[firstVert+1].Color = ColorTop; - buf->Vertices[firstVert+2].Color = ColorTop; - - buf->Indices[firstInd+0] = (u16)firstVert+0; - buf->Indices[firstInd+1] = (u16)firstVert+2; - buf->Indices[firstInd+2] = (u16)firstVert+1; - buf->Indices[firstInd+3] = (u16)firstVert+0; - buf->Indices[firstInd+4] = (u16)firstVert+3; - buf->Indices[firstInd+5] = (u16)firstVert+2; - - wchar_t *tp = 0; - if (i>0) - tp = &Text[i-1]; - - info.Width = (f32)s.getWidth(); - info.bufNo = texno; - info.Kerning = (f32)Font->getKerningWidth(&Text[i], tp); - info.firstInd = firstInd; - info.firstVert = firstVert; - - Symbol.push_back(info); - } -} - - -//! pre render event -void CBillboardTextSceneNode::OnRegisterSceneNode() -{ - if (!IsVisible || !Font || !Mesh) - return; - - ICameraSceneNode* camera = SceneManager->getActiveCamera(); - if (!camera) - return; - - // get text width - f32 textLength = 0.f; - u32 i; - for(i=0; i!=Symbol.size(); ++i) - { - SSymbolInfo &info = Symbol[i]; - textLength += info.Kerning + info.Width; - } - if (textLength<0.0f) - textLength=1.0f; - -// const core::matrix4 &m = camera->getViewFrustum()->Matrices[ video::ETS_VIEW ]; - - // make billboard look to camera - core::vector3df pos = getAbsolutePosition(); - - core::vector3df campos = camera->getAbsolutePosition(); - core::vector3df target = camera->getTarget(); - core::vector3df up = camera->getUpVector(); - core::vector3df view = target - campos; - view.normalize(); - - core::vector3df horizontal = up.crossProduct(view); - if ( horizontal.getLength() == 0 ) - { - horizontal.set(up.Y,up.X,up.Z); - } - - horizontal.normalize(); - core::vector3df space = horizontal; - - horizontal *= 0.5f * Size.Width; - - core::vector3df vertical = horizontal.crossProduct(view); - vertical.normalize(); - vertical *= 0.5f * Size.Height; - - view *= -1.0f; - - // center text - pos += space * (Size.Width * -0.5f); - - for ( i = 0; i!= Symbol.size(); ++i ) - { - SSymbolInfo &info = Symbol[i]; - f32 infw = info.Width / textLength; - f32 infk = info.Kerning / textLength; - f32 w = (Size.Width * infw * 0.5f); - pos += space * w; - - SMeshBuffer* buf = (SMeshBuffer*)Mesh->getMeshBuffer(info.bufNo); - - buf->Vertices[info.firstVert+0].Normal = view; - buf->Vertices[info.firstVert+1].Normal = view; - buf->Vertices[info.firstVert+2].Normal = view; - buf->Vertices[info.firstVert+3].Normal = view; - - buf->Vertices[info.firstVert+0].Pos = pos + (space * w) + vertical; - buf->Vertices[info.firstVert+1].Pos = pos + (space * w) - vertical; - buf->Vertices[info.firstVert+2].Pos = pos - (space * w) - vertical; - buf->Vertices[info.firstVert+3].Pos = pos - (space * w) + vertical; - - pos += space * (Size.Width*infk + w); - } - - // make bounding box - - for (i=0; i< Mesh->getMeshBufferCount() ; ++i) - Mesh->getMeshBuffer(i)->recalculateBoundingBox(); - Mesh->recalculateBoundingBox(); - - BBox = Mesh->getBoundingBox(); - core::matrix4 mat( getAbsoluteTransformation(), core::matrix4::EM4CONST_INVERSE ); - mat.transformBoxEx(BBox); - - SceneManager->registerNodeForRendering(this, ESNRP_TRANSPARENT); - ISceneNode::OnRegisterSceneNode(); -} - - -//! render -void CBillboardTextSceneNode::render() -{ - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - - // draw - core::matrix4 mat; - driver->setTransform(video::ETS_WORLD, mat); - - for (u32 i = 0; i < Mesh->getMeshBufferCount(); ++i) - { - driver->setMaterial(Mesh->getMeshBuffer(i)->getMaterial()); - driver->drawMeshBuffer(Mesh->getMeshBuffer(i)); - } - - if ( DebugDataVisible & scene::EDS_BBOX ) - { - driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); - video::SMaterial m; - m.Lighting = false; - driver->setMaterial(m); - driver->draw3DBox(BBox, video::SColor(0,208,195,152)); - } -} - - -//! returns the axis aligned bounding box of this node -const core::aabbox3d<f32>& CBillboardTextSceneNode::getBoundingBox() const -{ - return BBox; -} - - -//! sets the size of the billboard -void CBillboardTextSceneNode::setSize(const core::dimension2d<f32>& size) -{ - Size = size; - - if (Size.Width == 0.0f) - Size.Width = 1.0f; - - if (Size.Height == 0.0f ) - Size.Height = 1.0f; - - //f32 avg = (size.Width + size.Height)/6; - //BBox.MinEdge.set(-avg,-avg,-avg); - //BBox.MaxEdge.set(avg,avg,avg); -} - - -video::SMaterial& CBillboardTextSceneNode::getMaterial(u32 i) -{ - if (Mesh && Mesh->getMeshBufferCount() > i ) - return Mesh->getMeshBuffer(i)->getMaterial(); - else - return Material; -} - - -//! returns amount of materials used by this scene node. -u32 CBillboardTextSceneNode::getMaterialCount() const -{ - if (Mesh) - return Mesh->getMeshBufferCount(); - else - return 0; -} - - -//! gets the size of the billboard -const core::dimension2d<f32>& CBillboardTextSceneNode::getSize() const -{ - return Size; -} - - -//! sets the color of the text -void CBillboardTextSceneNode::setTextColor(video::SColor color) -{ - Color = color; -} - -//! Set the color of all vertices of the billboard -//! \param overallColor: the color to set -void CBillboardTextSceneNode::setColor(const video::SColor & overallColor) -{ - for ( u32 i = 0; i != Text.size (); ++i ) - { - const SSymbolInfo &info = Symbol[i]; - SMeshBuffer* buf = (SMeshBuffer*)Mesh->getMeshBuffer(info.bufNo); - buf->Vertices[info.firstVert+0].Color = overallColor; - buf->Vertices[info.firstVert+1].Color = overallColor; - buf->Vertices[info.firstVert+2].Color = overallColor; - buf->Vertices[info.firstVert+3].Color = overallColor; - } -} - - -//! Set the color of the top and bottom vertices of the billboard -//! \param topColor: the color to set the top vertices -//! \param bottomColor: the color to set the bottom vertices -void CBillboardTextSceneNode::setColor(const video::SColor & topColor, const video::SColor & bottomColor) -{ - ColorBottom = bottomColor; - ColorTop = topColor; - for ( u32 i = 0; i != Text.size (); ++i ) - { - const SSymbolInfo &info = Symbol[i]; - SMeshBuffer* buf = (SMeshBuffer*)Mesh->getMeshBuffer(info.bufNo); - buf->Vertices[info.firstVert+0].Color = ColorBottom; - buf->Vertices[info.firstVert+3].Color = ColorBottom; - buf->Vertices[info.firstVert+1].Color = ColorTop; - buf->Vertices[info.firstVert+2].Color = ColorTop; - } -} - - -//! Gets the color of the top and bottom vertices of the billboard -//! \param topColor: stores the color of the top vertices -//! \param bottomColor: stores the color of the bottom vertices -void CBillboardTextSceneNode::getColor(video::SColor & topColor, video::SColor & bottomColor) const -{ - topColor = ColorTop; - bottomColor = ColorBottom; -} - - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CTextSceneNode.h b/irrlicht-1.6/source/Irrlicht/CTextSceneNode.h deleted file mode 100644 index 8588dc786..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTextSceneNode.h +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_TEXT_SCENE_NODE_H_INCLUDED__ -#define __C_TEXT_SCENE_NODE_H_INCLUDED__ - -#include "ITextSceneNode.h" -#include "IBillboardTextSceneNode.h" -#include "IGUIFont.h" -#include "IGUIFontBitmap.h" -#include "ISceneCollisionManager.h" -#include "SMesh.h" - -namespace irr -{ -namespace scene -{ - - - class CTextSceneNode : public ITextSceneNode - { - public: - - //! constructor - CTextSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - gui::IGUIFont* font, scene::ISceneCollisionManager* coll, - const core::vector3df& position = core::vector3df(0,0,0), const wchar_t* text=0, - video::SColor color=video::SColor(100,0,0,0)); - - //! destructor - virtual ~CTextSceneNode(); - - virtual void OnRegisterSceneNode(); - - //! renders the node. - virtual void render(); - - //! returns the axis aligned bounding box of this node - virtual const core::aabbox3d<f32>& getBoundingBox() const; - - //! sets the text string - virtual void setText(const wchar_t* text); - - //! sets the color of the text - virtual void setTextColor(video::SColor color); - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() const { return ESNT_TEXT; } - - private: - - core::stringw Text; - video::SColor Color; - gui::IGUIFont* Font; - scene::ISceneCollisionManager* Coll; - core::aabbox3d<f32> Box; - }; - - class CBillboardTextSceneNode : public IBillboardTextSceneNode - { - public: - - CBillboardTextSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - gui::IGUIFont* font,const wchar_t* text, - const core::vector3df& position, const core::dimension2d<f32>& size, - video::SColor colorTop, video::SColor shade_bottom); - - //! destructor - virtual ~CBillboardTextSceneNode(); - - virtual void OnRegisterSceneNode(); - - //! renders the node. - virtual void render(); - - //! returns the axis aligned bounding box of this node - virtual const core::aabbox3d<f32>& getBoundingBox() const; - - //! sets the text string - virtual void setText(const wchar_t* text); - - //! sets the color of the text - virtual void setTextColor(video::SColor color); - - //! sets the size of the billboard - virtual void setSize(const core::dimension2d<f32>& size); - - //! gets the size of the billboard - virtual const core::dimension2d<f32>& getSize() const; - - virtual video::SMaterial& getMaterial(u32 i); - - //! returns amount of materials used by this scene node. - virtual u32 getMaterialCount() const; - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() const { return ESNT_TEXT; } - - //! Set the color of all vertices of the billboard - //! \param overallColor: the color to set - virtual void setColor(const video::SColor & overallColor); - - //! Set the color of the top and bottom vertices of the billboard - //! \param topColor: the color to set the top vertices - //! \param bottomColor: the color to set the bottom vertices - virtual void setColor(const video::SColor & topColor, const video::SColor & bottomColor); - - //! Gets the color of the top and bottom vertices of the billboard - //! \param topColor: stores the color of the top vertices - //! \param bottomColor: stores the color of the bottom vertices - virtual void getColor(video::SColor & topColor, video::SColor & bottomColor) const; - - private: - - core::stringw Text; - video::SColor Color; - gui::IGUIFontBitmap* Font; - - core::dimension2d<f32> Size; - core::aabbox3d<f32> BBox; - video::SMaterial Material; - - video::SColor ColorTop; - video::SColor ColorBottom; - struct SSymbolInfo - { - u32 bufNo; - f32 Width; - f32 Kerning; - u32 firstInd; - u32 firstVert; - }; - - core::array < SSymbolInfo > Symbol; - - SMesh *Mesh; - }; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CTimer.h b/irrlicht-1.6/source/Irrlicht/CTimer.h deleted file mode 100644 index 3e4d4e74a..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTimer.h +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_IRR_C_TIMER_H_INCLUDED__ -#define __C_IRR_C_TIMER_H_INCLUDED__ - -#include "ITimer.h" -#include "os.h" - -namespace irr -{ - //! Device independent implementation of the timer - class CTimer : public ITimer - { - public: - - CTimer() - { - os::Timer::initTimer(); - } - - //! Returns current real time in milliseconds of the system. - /** This value does not start with 0 when the application starts. - For example in one implementation the value returned could be the - amount of milliseconds which have elapsed since the system was started. */ - virtual u32 getRealTime() const - { - return os::Timer::getRealTime(); - } - - //! Returns current virtual time in milliseconds. - /** This value starts with 0 and can be manipulated using setTime(), stopTimer(), - startTimer(), etc. This value depends on the set speed of the timer if the timer - is stopped, etc. If you need the system time, use getRealTime() */ - virtual u32 getTime() const - { - return os::Timer::getTime(); - } - - //! sets current virtual time - virtual void setTime(u32 time) - { - os::Timer::setTime(time); - } - - //! Stops the game timer. - /** The timer is reference counted, which means everything which calls - stopTimer() will also have to call startTimer(), otherwise the timer may not start/stop - corretly again. */ - virtual void stop() - { - os::Timer::stopTimer(); - } - - //! Starts the game timer. - /** The timer is reference counted, which means everything which calls - stopTimer() will also have to call startTimer(), otherwise the timer may not start/stop - corretly again. */ - virtual void start() - { - os::Timer::startTimer(); - } - - //! Sets the speed of the timer - /** The speed is the factor with which the time is running faster or slower then the - real system time. */ - virtual void setSpeed(f32 speed = 1.0f) - { - os::Timer::setSpeed(speed); - } - - //! Returns current speed of the timer - /** The speed is the factor with which the time is running faster or slower then the - real system time. */ - virtual f32 getSpeed() const - { - return os::Timer::getSpeed(); - } - - //! Returns if game timer is currently stopped - virtual bool isStopped() const - { - bool ret = os::Timer::isStopped(); - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return ret; - } - - //! Advances the virtual time - /** Makes the virtual timer update the time value based on the real time. This is - called automaticly when calling IrrlichtDevice::run(), but you can call it manually - if you don't use this method. */ - virtual void tick() - { - os::Timer::tick(); - } - }; - -} // end namespace - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CTriangleBBSelector.cpp b/irrlicht-1.6/source/Irrlicht/CTriangleBBSelector.cpp deleted file mode 100644 index 034e19d04..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTriangleBBSelector.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CTriangleBBSelector.h" -#include "ISceneNode.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CTriangleBBSelector::CTriangleBBSelector(const ISceneNode* node) -: CTriangleSelector(node) -{ - #ifdef _DEBUG - setDebugName("CTriangleBBSelector"); - #endif - - Triangles.set_used(12); // a box has 12 triangles. -} - - - -//! Gets all triangles. -void CTriangleBBSelector::getTriangles(core::triangle3df* triangles, - s32 arraySize, s32& outTriangleCount, - const core::matrix4* transform) const -{ - if (!SceneNode) - return; - - // construct triangles - const core::aabbox3d<f32>& box = SceneNode->getBoundingBox(); - core::vector3df edges[8]; - box.getEdges(edges); - - Triangles[0].set( edges[3], edges[0], edges[2]); - Triangles[1].set( edges[3], edges[1], edges[0]); - - Triangles[2].set( edges[3], edges[2], edges[7]); - Triangles[3].set( edges[7], edges[2], edges[6]); - - Triangles[4].set( edges[7], edges[6], edges[4]); - Triangles[5].set( edges[5], edges[7], edges[4]); - - Triangles[6].set( edges[5], edges[4], edges[0]); - Triangles[7].set( edges[5], edges[0], edges[1]); - - Triangles[8].set( edges[1], edges[3], edges[7]); - Triangles[9].set( edges[1], edges[7], edges[5]); - - Triangles[10].set(edges[0], edges[6], edges[2]); - Triangles[11].set(edges[0], edges[4], edges[6]); - - // call parent - CTriangleSelector::getTriangles(triangles, arraySize, outTriangleCount, transform); -} - - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CTriangleBBSelector.h b/irrlicht-1.6/source/Irrlicht/CTriangleBBSelector.h deleted file mode 100644 index db85286eb..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTriangleBBSelector.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_TRIANGLE_BB_SELECTOR_H_INCLUDED__ -#define __C_TRIANGLE_BB_SELECTOR_H_INCLUDED__ - -#include "CTriangleSelector.h" - -namespace irr -{ -namespace scene -{ - -//! Stupid triangle selector without optimization -class CTriangleBBSelector : public CTriangleSelector -{ -public: - - //! Constructs a selector based on a mesh - CTriangleBBSelector(const ISceneNode* node); - - //! Gets all triangles. - virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount, - const core::matrix4* transform=0) const; -}; - -} // end namespace scene -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CTriangleSelector.cpp b/irrlicht-1.6/source/Irrlicht/CTriangleSelector.cpp deleted file mode 100644 index b892ca0fb..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTriangleSelector.cpp +++ /dev/null @@ -1,237 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CTriangleSelector.h" -#include "ISceneNode.h" -#include "IMeshBuffer.h" -#include "IAnimatedMeshSceneNode.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CTriangleSelector::CTriangleSelector(const ISceneNode* node) -: SceneNode(node), AnimatedNode(0), LastMeshFrame(-1) -{ - #ifdef _DEBUG - setDebugName("CTriangleSelector"); - #endif -} - - -//! constructor -CTriangleSelector::CTriangleSelector(const IMesh* mesh, const ISceneNode* node) -: SceneNode(node), AnimatedNode(0) -{ - #ifdef _DEBUG - setDebugName("CTriangleSelector"); - #endif - - createFromMesh(mesh); -} - -CTriangleSelector::CTriangleSelector(IAnimatedMeshSceneNode* node) -: SceneNode(reinterpret_cast<ISceneNode*>(node)), AnimatedNode(node) -{ - #ifdef _DEBUG - setDebugName("CTriangleSelector"); - #endif - - if (!AnimatedNode) - return; - - IAnimatedMesh * animatedMesh = AnimatedNode->getMesh(); - if (!animatedMesh) - return; - - IMesh * mesh = animatedMesh->getMesh((s32)AnimatedNode->getFrameNr()); - - if (mesh) - createFromMesh(mesh); -} - -void CTriangleSelector::createFromMesh(const IMesh * mesh) -{ - const u32 cnt = mesh->getMeshBufferCount(); - u32 totalFaceCount = 0; - for (u32 j=0; j<cnt; ++j) - totalFaceCount += mesh->getMeshBuffer(j)->getIndexCount(); - totalFaceCount /= 3; - Triangles.reallocate(totalFaceCount); - - for (u32 i=0; i<cnt; ++i) - { - const IMeshBuffer* buf = mesh->getMeshBuffer(i); - - const u32 idxCnt = buf->getIndexCount(); - const u16* const indices = buf->getIndices(); - - for (u32 j=0; j<idxCnt; j+=3) - { - Triangles.push_back(core::triangle3df( - buf->getPosition(indices[j+0]), - buf->getPosition(indices[j+1]), - buf->getPosition(indices[j+2]))); - } - } -} - -void CTriangleSelector::updateFromMesh(const IMesh* mesh) const -{ - if (!mesh) - return; - - u32 meshBuffers = mesh->getMeshBufferCount(); - u32 triangleCount = 0; - - for (u32 i = 0; i < meshBuffers; ++i) - { - IMeshBuffer* buf = mesh->getMeshBuffer(i); - u32 idxCnt = buf->getIndexCount(); - const u16* indices = buf->getIndices(); - - switch (buf->getVertexType()) - { - case video::EVT_STANDARD: - { - video::S3DVertex* vtx = (video::S3DVertex*)buf->getVertices(); - for (u32 index = 0; index < idxCnt; index += 3) - { - core::triangle3df & tri = Triangles[triangleCount++]; - tri.pointA = vtx[indices[index + 0]].Pos; - tri.pointB = vtx[indices[index + 1]].Pos; - tri.pointC = vtx[indices[index + 2]].Pos; - } - } - break; - case video::EVT_2TCOORDS: - { - video::S3DVertex2TCoords* vtx = (video::S3DVertex2TCoords*)buf->getVertices(); - for (u32 index = 0; index < idxCnt; index += 3) - { - core::triangle3df & tri = Triangles[triangleCount++]; - tri.pointA = vtx[indices[index + 0]].Pos; - tri.pointB = vtx[indices[index + 1]].Pos; - tri.pointC = vtx[indices[index + 2]].Pos; - } - } - break; - case video::EVT_TANGENTS: - { - video::S3DVertexTangents* vtx = (video::S3DVertexTangents*)buf->getVertices(); - for (u32 index = 0; index < idxCnt; index += 3) - { - core::triangle3df & tri = Triangles[triangleCount++]; - tri.pointA = vtx[indices[index + 0]].Pos; - tri.pointB = vtx[indices[index + 1]].Pos; - tri.pointC = vtx[indices[index + 2]].Pos; - } - } - break; - } - } -} - - -//! constructor -CTriangleSelector::CTriangleSelector(const core::aabbox3d<f32>& box, const ISceneNode* node) -: SceneNode(node) -{ - #ifdef _DEBUG - setDebugName("CTriangleSelector"); - #endif - - // TODO -} - - - -void CTriangleSelector::update(void) const -{ - if (!AnimatedNode) - return; //< harmless no-op - - s32 currentFrame = (s32)AnimatedNode->getFrameNr(); - if (currentFrame == LastMeshFrame) - return; //< Nothing to do - - LastMeshFrame = currentFrame; - IAnimatedMesh * animatedMesh = AnimatedNode->getMesh(); - - if (animatedMesh) - { - IMesh * mesh = animatedMesh->getMesh(LastMeshFrame); - - if (mesh) - updateFromMesh(mesh); - } -} - -//! Gets all triangles. -void CTriangleSelector::getTriangles(core::triangle3df* triangles, - s32 arraySize, s32& outTriangleCount, - const core::matrix4* transform) const -{ - // Update my triangles if necessary - update(); - - s32 cnt = Triangles.size(); - if (cnt > arraySize) - cnt = arraySize; - - core::matrix4 mat; - - if (transform) - mat = *transform; - - if (SceneNode) - mat *= SceneNode->getAbsoluteTransformation(); - - for (s32 i=0; i<cnt; ++i) - { - mat.transformVect( triangles[i].pointA, Triangles[i].pointA ); - mat.transformVect( triangles[i].pointB, Triangles[i].pointB ); - mat.transformVect( triangles[i].pointC, Triangles[i].pointC ); - } - - outTriangleCount = cnt; -} - - - -//! Gets all triangles which lie within a specific bounding box. -void CTriangleSelector::getTriangles(core::triangle3df* triangles, - s32 arraySize, s32& outTriangleCount, - const core::aabbox3d<f32>& box, - const core::matrix4* transform) const -{ - // return all triangles - return getTriangles(triangles, arraySize, outTriangleCount, transform); -} - - -//! Gets all triangles which have or may have contact with a 3d line. -void CTriangleSelector::getTriangles(core::triangle3df* triangles, - s32 arraySize, s32& outTriangleCount, - const core::line3d<f32>& line, - const core::matrix4* transform) const -{ - // return all triangles - return getTriangles(triangles, arraySize, outTriangleCount, transform); -} - - -//! Returns amount of all available triangles in this selector -s32 CTriangleSelector::getTriangleCount() const -{ - return Triangles.size(); -} - - - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CTriangleSelector.h b/irrlicht-1.6/source/Irrlicht/CTriangleSelector.h deleted file mode 100644 index 1f452ca9a..000000000 --- a/irrlicht-1.6/source/Irrlicht/CTriangleSelector.h +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_TRIANGLE_SELECTOR_H_INCLUDED__ -#define __C_TRIANGLE_SELECTOR_H_INCLUDED__ - -#include "ITriangleSelector.h" -#include "IMesh.h" -#include "irrArray.h" - -namespace irr -{ -namespace scene -{ - -class ISceneNode; -class IAnimatedMeshSceneNode; - -//! Stupid triangle selector without optimization -class CTriangleSelector : public ITriangleSelector -{ -public: - - //! Constructs a selector based on a mesh - CTriangleSelector(const ISceneNode* node); - - //! Constructs a selector based on a mesh - CTriangleSelector(const IMesh* mesh, const ISceneNode* node); - - //! Constructs a selector based on an animated mesh scene node - //!\param node An animated mesh scene node, which must have a valid mesh - CTriangleSelector(IAnimatedMeshSceneNode* node); - - //! Constructs a selector based on a bounding box - CTriangleSelector(const core::aabbox3d<f32>& box, const ISceneNode* node); - - //! Gets all triangles. - void getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount, - const core::matrix4* transform=0) const; - - //! Gets all triangles which lie within a specific bounding box. - void getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount, - const core::aabbox3d<f32>& box, const core::matrix4* transform=0) const; - - //! Gets all triangles which have or may have contact with a 3d line. - virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, - s32& outTriangleCount, const core::line3d<f32>& line, - const core::matrix4* transform=0) const; - - //! Returns amount of all available triangles in this selector - virtual s32 getTriangleCount() const; - - //! Return the scene node associated with a given triangle. - virtual const ISceneNode* getSceneNodeForTriangle(u32 triangleIndex) const { return SceneNode; } - -protected: - //! Create from a mesh - virtual void createFromMesh(const IMesh* mesh); - - //! Update when the mesh has changed - virtual void updateFromMesh(const IMesh* mesh) const; - - //! Update the triangle selector, which will only have an effect if it - //! was built from an animated mesh and that mesh's frame has changed - //! since the last time it was updated. - virtual void update(void) const; - - const ISceneNode* SceneNode; - mutable core::array<core::triangle3df> Triangles; - - IAnimatedMeshSceneNode* AnimatedNode; - mutable s32 LastMeshFrame; -}; - -} // end namespace scene -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CVideoModeList.cpp b/irrlicht-1.6/source/Irrlicht/CVideoModeList.cpp deleted file mode 100644 index c4ea77850..000000000 --- a/irrlicht-1.6/source/Irrlicht/CVideoModeList.cpp +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CVideoModeList.h" -#include "irrMath.h" - -namespace irr -{ -namespace video -{ - -//! constructor -CVideoModeList::CVideoModeList() -{ - #ifdef _DEBUG - setDebugName("CVideoModeList"); - #endif - - Desktop.depth = 0; - Desktop.size = core::dimension2d<u32>(0,0); -} - - -void CVideoModeList::setDesktop(s32 desktopDepth, const core::dimension2d<u32>& desktopSize) -{ - Desktop.depth = desktopDepth; - Desktop.size = desktopSize; -} - - -//! Gets amount of video modes in the list. -s32 CVideoModeList::getVideoModeCount() const -{ - return (s32)VideoModes.size(); -} - - -//! Returns the screen size of a video mode in pixels. -core::dimension2d<u32> CVideoModeList::getVideoModeResolution(s32 modeNumber) const -{ - if (modeNumber < 0 || modeNumber > (s32)VideoModes.size()) - return core::dimension2d<u32>(0,0); - - return VideoModes[modeNumber].size; -} - - -core::dimension2d<u32> CVideoModeList::getVideoModeResolution( - const core::dimension2d<u32>& minSize, - const core::dimension2d<u32>& maxSize) const -{ - u32 best=VideoModes.size(); - // if only one or no mode - if (best<2) - return getVideoModeResolution(0); - - u32 i; - for (i=0; i<VideoModes.size(); ++i) - { - if (VideoModes[i].size.Width>=minSize.Width && - VideoModes[i].size.Height>=minSize.Height && - VideoModes[i].size.Width<=maxSize.Width && - VideoModes[i].size.Height<=maxSize.Height) - best=i; - } - // we take the last one found, the largest one fitting - if (best<VideoModes.size()) - return VideoModes[best].size; - const u32 minArea = minSize.getArea(); - const u32 maxArea = maxSize.getArea(); - u32 minDist = 0xffffffff; - best=0; - for (i=0; i<VideoModes.size(); ++i) - { - const u32 area = VideoModes[i].size.getArea(); - const u32 dist = core::min_(abs(int(minArea-area)), abs(int(maxArea-area))); - if (dist<minDist) - { - minDist=dist; - best=i; - } - } - return VideoModes[best].size; -} - - -//! Returns the pixel depth of a video mode in bits. -s32 CVideoModeList::getVideoModeDepth(s32 modeNumber) const -{ - if (modeNumber < 0 || modeNumber > (s32)VideoModes.size()) - return 0; - - return VideoModes[modeNumber].depth; -} - - -//! Returns current desktop screen resolution. -const core::dimension2d<u32>& CVideoModeList::getDesktopResolution() const -{ - return Desktop.size; -} - - -//! Returns the pixel depth of a video mode in bits. -s32 CVideoModeList::getDesktopDepth() const -{ - return Desktop.depth; -} - - -//! adds a new mode to the list -void CVideoModeList::addMode(const core::dimension2d<u32>& size, s32 depth) -{ - SVideoMode m; - m.depth = depth; - m.size = size; - - for (u32 i=0; i<VideoModes.size(); ++i) - { - if (VideoModes[i] == m) - return; - } - - VideoModes.push_back(m); - VideoModes.sort(); // TODO: could be replaced by inserting into right place -} - - -} // end namespace video -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CVideoModeList.h b/irrlicht-1.6/source/Irrlicht/CVideoModeList.h deleted file mode 100644 index 1b462d749..000000000 --- a/irrlicht-1.6/source/Irrlicht/CVideoModeList.h +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_C_VIDEO_MODE_LIST_H_INCLUDED__ -#define __IRR_C_VIDEO_MODE_LIST_H_INCLUDED__ - -#include "IVideoModeList.h" -#include "dimension2d.h" -#include "irrArray.h" - -namespace irr -{ -namespace video -{ - - class CVideoModeList : public IVideoModeList - { - public: - - //! constructor - CVideoModeList(); - - //! Gets amount of video modes in the list. - virtual s32 getVideoModeCount() const; - - //! Returns the screen size of a video mode in pixels. - virtual core::dimension2d<u32> getVideoModeResolution(s32 modeNumber) const; - - //! Returns the screen size of an optimal video mode in pixels. - virtual core::dimension2d<u32> getVideoModeResolution(const core::dimension2d<u32>& minSize, const core::dimension2d<u32>& maxSize) const; - - //! Returns the pixel depth of a video mode in bits. - virtual s32 getVideoModeDepth(s32 modeNumber) const; - - //! Returns current desktop screen resolution. - virtual const core::dimension2d<u32>& getDesktopResolution() const; - - //! Returns the pixel depth of a video mode in bits. - virtual s32 getDesktopDepth() const; - - //! adds a new mode to the list - void addMode(const core::dimension2d<u32>& size, s32 depth); - - void setDesktop(s32 desktopDepth, const core::dimension2d<u32>& desktopSize); - - private: - - struct SVideoMode - { - core::dimension2d<u32> size; - s32 depth; - - bool operator==(const SVideoMode& other) const - { - return size == other.size && depth == other.depth; - } - - bool operator <(const SVideoMode& other) const - { - return (size.Width < other.size.Width || - (size.Width == other.size.Width && - size.Height < other.size.Height) || - (size.Width == other.size.Width && - size.Height == other.size.Height && - depth < other.depth)); - } - }; - - core::array<SVideoMode> VideoModes; - SVideoMode Desktop; - }; - -} // end namespace video -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CVolumeLightSceneNode.cpp b/irrlicht-1.6/source/Irrlicht/CVolumeLightSceneNode.cpp deleted file mode 100644 index 423d86b70..000000000 --- a/irrlicht-1.6/source/Irrlicht/CVolumeLightSceneNode.cpp +++ /dev/null @@ -1,201 +0,0 @@ -// Copyright (C) 2007-2009 Dean Wadsworth -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CVolumeLightSceneNode.h" -#include "IVideoDriver.h" -#include "ISceneManager.h" -#include "S3DVertex.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CVolumeLightSceneNode::CVolumeLightSceneNode(ISceneNode* parent, ISceneManager* mgr, - s32 id, const u32 subdivU, const u32 subdivV, - const video::SColor foot, - const video::SColor tail, - const core::vector3df& position, - const core::vector3df& rotation, const core::vector3df& scale) - : IVolumeLightSceneNode(parent, mgr, id, position, rotation, scale), - Mesh(0), LPDistance(8.0f), - SubdivideU(subdivU), SubdivideV(subdivV), - FootColor(foot), TailColor(tail), - LightDimensions(core::vector3df(1.0f, 1.2f, 1.0f)) -{ - #ifdef _DEBUG - setDebugName("CVolumeLightSceneNode"); - #endif - - constructLight(); -} - - -CVolumeLightSceneNode::~CVolumeLightSceneNode() -{ - if (Mesh) - Mesh->drop(); -} - - -void CVolumeLightSceneNode::constructLight() -{ - if (Mesh) - Mesh->drop(); - Mesh = SceneManager->getGeometryCreator()->createVolumeLightMesh(SubdivideU, SubdivideV, FootColor, TailColor, LPDistance, LightDimensions); -} - - -//! renders the node. -void CVolumeLightSceneNode::render() -{ - if (!Mesh) - return; - - video::IVideoDriver* driver = SceneManager->getVideoDriver(); - driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); - - driver->setMaterial(Mesh->getMeshBuffer(0)->getMaterial()); - driver->drawMeshBuffer(Mesh->getMeshBuffer(0)); -} - - -//! returns the axis aligned bounding box of this node -const core::aabbox3d<f32>& CVolumeLightSceneNode::getBoundingBox() const -{ - return Mesh->getBoundingBox(); -} - - -void CVolumeLightSceneNode::OnRegisterSceneNode() -{ - if (IsVisible) - { - SceneManager->registerNodeForRendering(this, ESNRP_TRANSPARENT); - } - ISceneNode::OnRegisterSceneNode(); -} - - -//! returns the material based on the zero based index i. To get the amount -//! of materials used by this scene node, use getMaterialCount(). -//! This function is needed for inserting the node into the scene hirachy on a -//! optimal position for minimizing renderstate changes, but can also be used -//! to directly modify the material of a scene node. -video::SMaterial& CVolumeLightSceneNode::getMaterial(u32 i) -{ - return Mesh->getMeshBuffer(i)->getMaterial(); -} - - -//! returns amount of materials used by this scene node. -u32 CVolumeLightSceneNode::getMaterialCount() const -{ - return 1; -} - - -void CVolumeLightSceneNode::setSubDivideU (const u32 inU) -{ - if (inU != SubdivideU) - { - SubdivideU = inU; - constructLight(); - } -} - - -void CVolumeLightSceneNode::setSubDivideV (const u32 inV) -{ - if (inV != SubdivideV) - { - SubdivideV = inV; - constructLight(); - } -} - - -void CVolumeLightSceneNode::setFootColor(const video::SColor inColor) -{ - if (inColor != FootColor) - { - FootColor = inColor; - constructLight(); - } -} - - -void CVolumeLightSceneNode::setTailColor(const video::SColor inColor) -{ - if (inColor != TailColor) - { - TailColor = inColor; - constructLight(); - } -} - - -//! Writes attributes of the scene node. -void CVolumeLightSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const -{ - ISceneNode::serializeAttributes(out, options); - - out->addFloat("lpDistance", LPDistance); - out->addInt("subDivideU", SubdivideU); - out->addInt("subDivideV", SubdivideV); - - out->addColor("footColor", FootColor); - out->addColor("tailColor", TailColor); - - out->addVector3d("lightDimension", LightDimensions); -} - - -//! Reads attributes of the scene node. -void CVolumeLightSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - LPDistance = in->getAttributeAsFloat("lpDistance"); - LPDistance = core::max_(LPDistance, 8.0f); - - SubdivideU = in->getAttributeAsInt("subDivideU"); - SubdivideU = core::max_(SubdivideU, 1u); - - SubdivideV = in->getAttributeAsInt("subDivideV"); - SubdivideV = core::max_(SubdivideV, 1u); - - FootColor = in->getAttributeAsColor("footColor"); - TailColor = in->getAttributeAsColor("tailColor"); - - LightDimensions = in->getAttributeAsVector3d("lightDimension"); - - constructLight(); - - ISceneNode::deserializeAttributes(in, options); -} - - -//! Creates a clone of this scene node and its children. -ISceneNode* CVolumeLightSceneNode::clone(ISceneNode* newParent, ISceneManager* newManager) -{ - if (!newParent) - newParent = Parent; - if (!newManager) - newManager = SceneManager; - - CVolumeLightSceneNode* nb = new CVolumeLightSceneNode(newParent, - newManager, ID, SubdivideU, SubdivideV, FootColor, TailColor, RelativeTranslation); - - nb->cloneMembers(this, newManager); - nb->getMaterial(0) = Mesh->getMeshBuffer(0)->getMaterial(); - - nb->drop(); - return nb; -} - - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CVolumeLightSceneNode.h b/irrlicht-1.6/source/Irrlicht/CVolumeLightSceneNode.h deleted file mode 100644 index 3bdb08c25..000000000 --- a/irrlicht-1.6/source/Irrlicht/CVolumeLightSceneNode.h +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h -// -// created by Dean Wadsworth aka Varmint Dec 31 2007 - -#ifndef __VOLUME_LIGHT_SCENE_NODE_H_INCLUDED__ -#define __VOLUME_LIGHT_SCENE_NODE_H_INCLUDED__ - -#include "IVolumeLightSceneNode.h" -#include "IMesh.h" - -namespace irr -{ -namespace scene -{ - class CVolumeLightSceneNode : public IVolumeLightSceneNode - { - public: - - //! constructor - CVolumeLightSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - const u32 subdivU = 32, const u32 subdivV = 32, - const video::SColor foot = video::SColor(51, 0, 230, 180), - const video::SColor tail = video::SColor(0, 0, 0, 0), - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); - - virtual ~CVolumeLightSceneNode(); - - virtual void OnRegisterSceneNode(); - - //! renders the node. - virtual void render(); - - //! returns the axis aligned bounding box of this node - virtual const core::aabbox3d<f32>& getBoundingBox() const; - - //! returns the material based on the zero based index i. - virtual video::SMaterial& getMaterial(u32 i); - - //! returns amount of materials used by this scene node. - virtual u32 getMaterialCount() const; - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() const { return ESNT_CUBE; } - - //! Writes attributes of the scene node. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const; - - //! Reads attributes of the scene node. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - //! Creates a clone of this scene node and its children. - virtual ISceneNode* clone(ISceneNode* newParent=0, ISceneManager* newManager=0); - - virtual void setSubDivideU(const u32 inU); - virtual void setSubDivideV(const u32 inV); - - virtual u32 getSubDivideU() const { return SubdivideU; } - virtual u32 getSubDivideV() const { return SubdivideV; } - - virtual void setFootColor(const video::SColor inColor); - virtual void setTailColor(const video::SColor inColor); - - virtual video::SColor getFootColor() const { return FootColor; } - virtual video::SColor getTailColor() const { return TailColor; } - - private: - void constructLight(); - - IMesh* Mesh; - - f32 LPDistance; // Distance to hypothetical lightsource point -- affects fov angle - - u32 SubdivideU; // Number of subdivisions in U and V space. - u32 SubdivideV; // Controls the number of "slices" in the volume. - // NOTE : Total number of polygons = 2 + ((SubdivideU + 1) + (SubdivideV + 1)) * 2 - // Each slice being a quad plus the rectangular plane at the bottom. - - video::SColor FootColor; // Color at the source - video::SColor TailColor; // Color at the end. - - core::vector3df LightDimensions; // LightDimensions.Y Distance of shooting -- Length of beams - // LightDimensions.X and LightDimensions.Z determine the size/dimension of the plane - }; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CWaterSurfaceSceneNode.cpp b/irrlicht-1.6/source/Irrlicht/CWaterSurfaceSceneNode.cpp deleted file mode 100644 index 14a0ab4cb..000000000 --- a/irrlicht-1.6/source/Irrlicht/CWaterSurfaceSceneNode.cpp +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CWaterSurfaceSceneNode.h" -#include "ISceneManager.h" -#include "IMeshManipulator.h" -#include "IMeshCache.h" -#include "S3DVertex.h" -#include "SMesh.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - -//! constructor -CWaterSurfaceSceneNode::CWaterSurfaceSceneNode(f32 waveHeight, f32 waveSpeed, f32 waveLength, - IMesh* mesh, ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position, const core::vector3df& rotation, - const core::vector3df& scale) - : CMeshSceneNode(mesh, parent, mgr, id, position, rotation, scale), - WaveLength(waveLength), WaveSpeed(waveSpeed), WaveHeight(waveHeight), - OriginalMesh(0) -{ - #ifdef _DEBUG - setDebugName("CWaterSurfaceSceneNode"); - #endif - - // create copy of the mesh - if (!mesh) - return; - - // Mesh is set in CMeshSceneNode constructor, now it is moved to OriginalMesh - IMesh* clone = SceneManager->getMeshManipulator()->createMeshCopy(mesh); - OriginalMesh = Mesh; - Mesh = clone; -} - - -//! destructor -CWaterSurfaceSceneNode::~CWaterSurfaceSceneNode() -{ - // Mesh is dropped in CMeshSceneNode destructor - if (OriginalMesh) - OriginalMesh->drop(); -} - - -//! frame -void CWaterSurfaceSceneNode::OnRegisterSceneNode() -{ - CMeshSceneNode::OnRegisterSceneNode(); -} - - -void CWaterSurfaceSceneNode::OnAnimate(u32 timeMs) -{ - if (Mesh && IsVisible) - { - const u32 meshBufferCount = Mesh->getMeshBufferCount(); - const f32 time = timeMs / WaveSpeed; - - for (u32 b=0; b<meshBufferCount; ++b) - { - const u32 vtxCnt = Mesh->getMeshBuffer(b)->getVertexCount(); - - for (u32 i=0; i<vtxCnt; ++i) - Mesh->getMeshBuffer(b)->getPosition(i).Y = addWave( - OriginalMesh->getMeshBuffer(b)->getPosition(i), - time); - }// end for all mesh buffers - - SceneManager->getMeshManipulator()->recalculateNormals(Mesh); - } - CMeshSceneNode::OnAnimate(timeMs); -} - - -void CWaterSurfaceSceneNode::setMesh(IMesh* mesh) -{ - CMeshSceneNode::setMesh(mesh); - if (!mesh) - return; - if (OriginalMesh) - OriginalMesh->drop(); - IMesh* clone = SceneManager->getMeshManipulator()->createMeshCopy(mesh); - OriginalMesh = mesh; - Mesh = clone; -} - - -//! Writes attributes of the scene node. -void CWaterSurfaceSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const -{ - out->addFloat("WaveLength", WaveLength); - out->addFloat("WaveSpeed", WaveSpeed); - out->addFloat("WaveHeight", WaveHeight); - - CMeshSceneNode::serializeAttributes(out, options); - // serialize original mesh - out->setAttribute("Mesh", SceneManager->getMeshCache()->getMeshFilename(OriginalMesh).c_str()); -} - - -//! Reads attributes of the scene node. -void CWaterSurfaceSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - WaveLength = in->getAttributeAsFloat("WaveLength"); - WaveSpeed = in->getAttributeAsFloat("WaveSpeed"); - WaveHeight = in->getAttributeAsFloat("WaveHeight"); - - if (Mesh) - { - Mesh->drop(); - Mesh = OriginalMesh; - OriginalMesh = 0; - } - // deserialize original mesh - CMeshSceneNode::deserializeAttributes(in, options); - - if (Mesh) - { - IMesh* clone = SceneManager->getMeshManipulator()->createMeshCopy(Mesh); - OriginalMesh = Mesh; - Mesh = clone; - } -} - - -f32 CWaterSurfaceSceneNode::addWave(const core::vector3df &source, f32 time) const -{ - return source.Y + - (sinf(((source.X/WaveLength) + time)) * WaveHeight) + - (cosf(((source.Z/WaveLength) + time)) * WaveHeight); -} - -} // end namespace scene -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CWaterSurfaceSceneNode.h b/irrlicht-1.6/source/Irrlicht/CWaterSurfaceSceneNode.h deleted file mode 100644 index 2b5e2785d..000000000 --- a/irrlicht-1.6/source/Irrlicht/CWaterSurfaceSceneNode.h +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_WATER_SURFACE_SCENE_NODE_H_INCLUDED__ -#define __C_WATER_SURFACE_SCENE_NODE_H_INCLUDED__ - -#include "CMeshSceneNode.h" - -namespace irr -{ -namespace scene -{ - - class CWaterSurfaceSceneNode : public CMeshSceneNode - { - public: - - //! constructor - CWaterSurfaceSceneNode(f32 waveHeight, f32 waveSpeed, f32 waveLength, - IMesh* mesh, ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& rotation = core::vector3df(0,0,0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); - - //! destructor - virtual ~CWaterSurfaceSceneNode(); - - //! frame registration - virtual void OnRegisterSceneNode(); - - //! animated update - virtual void OnAnimate(u32 timeMs); - - //! Update mesh - virtual void setMesh(IMesh* mesh); - - //! Returns type of the scene node - virtual ESCENE_NODE_TYPE getType() const { return ESNT_WATER_SURFACE; } - - //! Writes attributes of the scene node. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; - - //! Reads attributes of the scene node. - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - - private: - - inline f32 addWave(const core::vector3df &source, f32 time) const; - - f32 WaveLength; - f32 WaveSpeed; - f32 WaveHeight; - IMesh* OriginalMesh; - }; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CWriteFile.cpp b/irrlicht-1.6/source/Irrlicht/CWriteFile.cpp deleted file mode 100644 index 0a4f12da3..000000000 --- a/irrlicht-1.6/source/Irrlicht/CWriteFile.cpp +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CWriteFile.h" -#include <stdio.h> - -namespace irr -{ -namespace io -{ - - -CWriteFile::CWriteFile(const io::path& fileName, bool append) -: FileSize(0) -{ - #ifdef _DEBUG - setDebugName("CWriteFile"); - #endif - - Filename = fileName; - openFile(append); -} - - - -CWriteFile::~CWriteFile() -{ - if (File) - fclose(File); -} - - - -//! returns if file is open -inline bool CWriteFile::isOpen() const -{ - return File != 0; -} - - - -//! returns how much was read -s32 CWriteFile::write(const void* buffer, u32 sizeToWrite) -{ - if (!isOpen()) - return 0; - - return (s32)fwrite(buffer, 1, sizeToWrite, File); -} - - - -//! changes position in file, returns true if successful -//! if relativeMovement==true, the pos is changed relative to current pos, -//! otherwise from begin of file -bool CWriteFile::seek(long finalPos, bool relativeMovement) -{ - if (!isOpen()) - return false; - - return fseek(File, finalPos, relativeMovement ? SEEK_CUR : SEEK_SET) == 0; -} - - - -//! returns where in the file we are. -long CWriteFile::getPos() const -{ - return ftell(File); -} - - - -//! opens the file -void CWriteFile::openFile(bool append) -{ - if (Filename.size() == 0) - { - File = 0; - return; - } - -#if defined(_IRR_WCHAR_FILESYSTEM) - File = _wfopen(Filename.c_str(), append ? L"ab" : L"wb"); -#else - File = fopen(Filename.c_str(), append ? "ab" : "wb"); -#endif - - if (File) - { - // get FileSize - - fseek(File, 0, SEEK_END); - FileSize = ftell(File); - fseek(File, 0, SEEK_SET); - } -} - - - -//! returns name of file -const io::path& CWriteFile::getFileName() const -{ - return Filename; -} - - - -IWriteFile* createWriteFile(const io::path& fileName, bool append) -{ - CWriteFile* file = new CWriteFile(fileName, append); - if (file->isOpen()) - return file; - - file->drop(); - return 0; -} - - -} // end namespace io -} // end namespace irr - diff --git a/irrlicht-1.6/source/Irrlicht/CWriteFile.h b/irrlicht-1.6/source/Irrlicht/CWriteFile.h deleted file mode 100644 index 36a651e70..000000000 --- a/irrlicht-1.6/source/Irrlicht/CWriteFile.h +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_WRITE_FILE_H_INCLUDED__ -#define __C_WRITE_FILE_H_INCLUDED__ - -#include <stdio.h> -#include "IWriteFile.h" -#include "irrString.h" - -namespace irr -{ - -namespace io -{ - - /*! - Class for writing a real file to disk. - */ - class CWriteFile : public IWriteFile - { - public: - - CWriteFile(const io::path& fileName, bool append); - - virtual ~CWriteFile(); - - //! Reads an amount of bytes from the file. - virtual s32 write(const void* buffer, u32 sizeToWrite); - - //! Changes position in file, returns true if successful. - virtual bool seek(long finalPos, bool relativeMovement = false); - - //! Returns the current position in the file. - virtual long getPos() const; - - //! Returns name of file. - virtual const io::path& getFileName() const; - - //! returns if file is open - bool isOpen() const; - - private: - - //! opens the file - void openFile(bool append); - - io::path Filename; - FILE* File; - long FileSize; - }; - -} // end namespace io -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CXMLReader.cpp b/irrlicht-1.6/source/Irrlicht/CXMLReader.cpp deleted file mode 100644 index dac2c7ac4..000000000 --- a/irrlicht-1.6/source/Irrlicht/CXMLReader.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CXMLReaderImpl.h" -#include "CXMLReader.h" -#include "IReadFile.h" - -namespace irr -{ -namespace io -{ - //! Irrlicht implementation of the file read callback for the xml parser - class CIrrXMLFileReadCallBack : public IFileReadCallBack - { - public: - - //! construct from FILE pointer - CIrrXMLFileReadCallBack(IReadFile* file) - : ReadFile(file) - { - ReadFile->grab(); - } - - //! destructor - virtual ~CIrrXMLFileReadCallBack() - { - ReadFile->drop(); - } - - //! Reads an amount of bytes from the file. - virtual int read(void* buffer, int sizeToRead) - { - return ReadFile->read(buffer, sizeToRead); - } - - //! Returns size of file in bytes - virtual long getSize() const - { - return ReadFile->getSize(); - } - - private: - - IReadFile* ReadFile; - }; // end class CMyXMLFileReadCallBack - - - // now create an implementation for IXMLReader using irrXML. - - //! Creates an instance of a wide character xml parser. - IXMLReader* createIXMLReader(IReadFile* file) - { - if (!file) - return 0; - - return new CXMLReaderImpl<wchar_t, IReferenceCounted>(new CIrrXMLFileReadCallBack(file)); - } - - //! Creates an instance of an UFT-8 or ASCII character xml parser. - IXMLReaderUTF8* createIXMLReaderUTF8(IReadFile* file) - { - if (!file) - return 0; - - return new CXMLReaderImpl<char, IReferenceCounted>(new CIrrXMLFileReadCallBack(file)); - } - -} // end namespace -} // end namespace diff --git a/irrlicht-1.6/source/Irrlicht/CXMLReader.h b/irrlicht-1.6/source/Irrlicht/CXMLReader.h deleted file mode 100644 index 62c1b9084..000000000 --- a/irrlicht-1.6/source/Irrlicht/CXMLReader.h +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_XML_READER_H_INCLUDED__ -#define __C_XML_READER_H_INCLUDED__ - -#include "IXMLReader.h" - -namespace irr -{ -namespace io -{ - class IReadFile; - - //! creates an IXMLReader - IXMLReader* createIXMLReader(IReadFile* file); - - //! creates an IXMLReader - IXMLReaderUTF8* createIXMLReaderUTF8(IReadFile* file); - -} // end namespace irr -} // end namespace io - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CXMLReaderImpl.h b/irrlicht-1.6/source/Irrlicht/CXMLReaderImpl.h deleted file mode 100644 index 24f12b133..000000000 --- a/irrlicht-1.6/source/Irrlicht/CXMLReaderImpl.h +++ /dev/null @@ -1,798 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine" and the "irrXML" project. -// For conditions of distribution and use, see copyright notice in irrlicht.h and/or irrXML.h - -#ifndef __ICXML_READER_IMPL_H_INCLUDED__ -#define __ICXML_READER_IMPL_H_INCLUDED__ - -#include "irrXML.h" -#include "irrString.h" -#include "irrArray.h" -#include "fast_atof.h" - -#ifdef _DEBUG -#define IRR_DEBUGPRINT(x) printf((x)); -#else // _DEBUG -#define IRR_DEBUGPRINT(x) -#endif // _DEBUG - - -namespace irr -{ -namespace io -{ - - -//! implementation of the IrrXMLReader -template<class char_type, class superclass> -class CXMLReaderImpl : public IIrrXMLReader<char_type, superclass> -{ -public: - - //! Constructor - CXMLReaderImpl(IFileReadCallBack* callback, bool deleteCallBack = true) - : TextData(0), P(0), TextBegin(0), TextSize(0), CurrentNodeType(EXN_NONE), - SourceFormat(ETF_ASCII), TargetFormat(ETF_ASCII) - { - if (!callback) - return; - - storeTargetFormat(); - - // read whole xml file - - readFile(callback); - - // clean up - - if (deleteCallBack) - delete callback; - - // create list with special characters - - createSpecialCharacterList(); - - // set pointer to text begin - P = TextBegin; - } - - - //! Destructor - virtual ~CXMLReaderImpl() - { - delete [] TextData; - } - - - //! Reads forward to the next xml node. - //! \return Returns false, if there was no further node. - virtual bool read() - { - // if not end reached, parse the node - if (P && (unsigned int)(P - TextBegin) < TextSize - 1 && *P != 0) - { - return parseCurrentNode(); - } - - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return false; - } - - - //! Returns the type of the current XML node. - virtual EXML_NODE getNodeType() const - { - return CurrentNodeType; - } - - - //! Returns attribute count of the current XML node. - virtual unsigned int getAttributeCount() const - { - return Attributes.size(); - } - - - //! Returns name of an attribute. - virtual const char_type* getAttributeName(int idx) const - { - if ((u32)idx >= Attributes.size()) - return 0; - - return Attributes[idx].Name.c_str(); - } - - - //! Returns the value of an attribute. - virtual const char_type* getAttributeValue(int idx) const - { - if ((unsigned int)idx >= Attributes.size()) - return 0; - - return Attributes[idx].Value.c_str(); - } - - - //! Returns the value of an attribute. - virtual const char_type* getAttributeValue(const char_type* name) const - { - const SAttribute* attr = getAttributeByName(name); - if (!attr) - return 0; - - return attr->Value.c_str(); - } - - - //! Returns the value of an attribute - virtual const char_type* getAttributeValueSafe(const char_type* name) const - { - const SAttribute* attr = getAttributeByName(name); - if (!attr) - return EmptyString.c_str(); - - return attr->Value.c_str(); - } - - - - //! Returns the value of an attribute as integer. - int getAttributeValueAsInt(const char_type* name) const - { - return (int)getAttributeValueAsFloat(name); - } - - - //! Returns the value of an attribute as integer. - int getAttributeValueAsInt(int idx) const - { - return (int)getAttributeValueAsFloat(idx); - } - - - //! Returns the value of an attribute as float. - float getAttributeValueAsFloat(const char_type* name) const - { - const SAttribute* attr = getAttributeByName(name); - if (!attr) - return 0; - - core::stringc c = attr->Value.c_str(); - return core::fast_atof(c.c_str()); - } - - - //! Returns the value of an attribute as float. - float getAttributeValueAsFloat(int idx) const - { - const char_type* attrvalue = getAttributeValue(idx); - if (!attrvalue) - return 0; - - core::stringc c = attrvalue; - return core::fast_atof(c.c_str()); - } - - - //! Returns the name of the current node. - virtual const char_type* getNodeName() const - { - return NodeName.c_str(); - } - - - //! Returns data of the current node. - virtual const char_type* getNodeData() const - { - return NodeName.c_str(); - } - - - //! Returns if an element is an empty element, like <foo /> - virtual bool isEmptyElement() const - { - return IsEmptyElement; - } - - //! Returns format of the source xml file. - virtual ETEXT_FORMAT getSourceFormat() const - { - return SourceFormat; - } - - //! Returns format of the strings returned by the parser. - virtual ETEXT_FORMAT getParserFormat() const - { - return TargetFormat; - } - -private: - - // Reads the current xml node - // return false if no further node is found - bool parseCurrentNode() - { - char_type* start = P; - - // more forward until '<' found - while(*P != L'<' && *P) - ++P; - - // not a node, so return false - if (!*P) - return false; - - if (P - start > 0) - { - // we found some text, store it - if (setText(start, P)) - return true; - } - - ++P; - - // based on current token, parse and report next element - switch(*P) - { - case L'/': - parseClosingXMLElement(); - break; - case L'?': - ignoreDefinition(); - break; - case L'!': - if (!parseCDATA()) - parseComment(); - break; - default: - parseOpeningXMLElement(); - break; - } - return true; - } - - - //! sets the state that text was found. Returns true if set should be set - bool setText(char_type* start, char_type* end) - { - // check if text is more than 2 characters, and if not, check if there is - // only white space, so that this text won't be reported - if (end - start < 3) - { - char_type* p = start; - for(; p != end; ++p) - if (!isWhiteSpace(*p)) - break; - - if (p == end) - return false; - } - - // set current text to the parsed text, and replace xml special characters - core::string<char_type> s(start, (int)(end - start)); - NodeName = replaceSpecialCharacters(s); - - // current XML node type is text - CurrentNodeType = EXN_TEXT; - - return true; - } - - - - //! ignores an xml definition like <?xml something /> - void ignoreDefinition() - { - CurrentNodeType = EXN_UNKNOWN; - - // move until end marked with '>' reached - while(*P != L'>') - ++P; - - ++P; - } - - - //! parses a comment - void parseComment() - { - CurrentNodeType = EXN_COMMENT; - P += 1; - - char_type *pCommentBegin = P; - - int count = 1; - - // move until end of comment reached - while(count) - { - if (*P == L'>') - --count; - else - if (*P == L'<') - ++count; - - ++P; - } - - P -= 3; - NodeName = core::string<char_type>(pCommentBegin+2, (int)(P - pCommentBegin-2)); - P += 3; - } - - - //! parses an opening xml element and reads attributes - void parseOpeningXMLElement() - { - CurrentNodeType = EXN_ELEMENT; - IsEmptyElement = false; - Attributes.clear(); - - // find name - const char_type* startName = P; - - // find end of element - while(*P != L'>' && !isWhiteSpace(*P)) - ++P; - - const char_type* endName = P; - - // find Attributes - while(*P != L'>') - { - if (isWhiteSpace(*P)) - ++P; - else - { - if (*P != L'/') - { - // we've got an attribute - - // read the attribute names - const char_type* attributeNameBegin = P; - - while(!isWhiteSpace(*P) && *P != L'=') - ++P; - - const char_type* attributeNameEnd = P; - ++P; - - // read the attribute value - // check for quotes and single quotes, thx to murphy - while( (*P != L'\"') && (*P != L'\'') && *P) - ++P; - - if (!*P) // malformatted xml file - return; - - const char_type attributeQuoteChar = *P; - - ++P; - const char_type* attributeValueBegin = P; - - while(*P != attributeQuoteChar && *P) - ++P; - - if (!*P) // malformatted xml file - return; - - const char_type* attributeValueEnd = P; - ++P; - - SAttribute attr; - attr.Name = core::string<char_type>(attributeNameBegin, - (int)(attributeNameEnd - attributeNameBegin)); - - core::string<char_type> s(attributeValueBegin, - (int)(attributeValueEnd - attributeValueBegin)); - - attr.Value = replaceSpecialCharacters(s); - Attributes.push_back(attr); - } - else - { - // tag is closed directly - ++P; - IsEmptyElement = true; - break; - } - } - } - - // check if this tag is closing directly - if (endName > startName && *(endName-1) == L'/') - { - // directly closing tag - IsEmptyElement = true; - endName--; - } - - NodeName = core::string<char_type>(startName, (int)(endName - startName)); - - ++P; - } - - - //! parses an closing xml tag - void parseClosingXMLElement() - { - CurrentNodeType = EXN_ELEMENT_END; - IsEmptyElement = false; - Attributes.clear(); - - ++P; - const char_type* pBeginClose = P; - - while(*P != L'>') - ++P; - - NodeName = core::string<char_type>(pBeginClose, (int)(P - pBeginClose)); - ++P; - } - - //! parses a possible CDATA section, returns false if begin was not a CDATA section - bool parseCDATA() - { - if (*(P+1) != L'[') - return false; - - CurrentNodeType = EXN_CDATA; - - // skip '<![CDATA[' - int count=0; - while( *P && count<8 ) - { - ++P; - ++count; - } - - if (!*P) - return true; - - char_type *cDataBegin = P; - char_type *cDataEnd = 0; - - // find end of CDATA - while(*P && !cDataEnd) - { - if (*P == L'>' && - (*(P-1) == L']') && - (*(P-2) == L']')) - { - cDataEnd = P - 2; - } - - ++P; - } - - if ( cDataEnd ) - NodeName = core::string<char_type>(cDataBegin, (int)(cDataEnd - cDataBegin)); - else - NodeName = ""; - - return true; - } - - - // structure for storing attribute-name pairs - struct SAttribute - { - core::string<char_type> Name; - core::string<char_type> Value; - }; - - // finds a current attribute by name, returns 0 if not found - const SAttribute* getAttributeByName(const char_type* name) const - { - if (!name) - return 0; - - core::string<char_type> n = name; - - for (int i=0; i<(int)Attributes.size(); ++i) - if (Attributes[i].Name == n) - return &Attributes[i]; - - return 0; - } - - // replaces xml special characters in a string and creates a new one - core::string<char_type> replaceSpecialCharacters( - core::string<char_type>& origstr) - { - int pos = origstr.findFirst(L'&'); - int oldPos = 0; - - if (pos == -1) - return origstr; - - core::string<char_type> newstr; - - while(pos != -1 && pos < (int)origstr.size()-2) - { - // check if it is one of the special characters - - int specialChar = -1; - for (int i=0; i<(int)SpecialCharacters.size(); ++i) - { - const char_type* p = &origstr.c_str()[pos]+1; - - if (equalsn(&SpecialCharacters[i][1], p, SpecialCharacters[i].size()-1)) - { - specialChar = i; - break; - } - } - - if (specialChar != -1) - { - newstr.append(origstr.subString(oldPos, pos - oldPos)); - newstr.append(SpecialCharacters[specialChar][0]); - pos += SpecialCharacters[specialChar].size(); - } - else - { - newstr.append(origstr.subString(oldPos, pos - oldPos + 1)); - pos += 1; - } - - // find next & - oldPos = pos; - pos = origstr.findNext(L'&', pos); - } - - if (oldPos < (int)origstr.size()-1) - newstr.append(origstr.subString(oldPos, origstr.size()-oldPos)); - - return newstr; - } - - - - //! reads the xml file and converts it into the wanted character format. - bool readFile(IFileReadCallBack* callback) - { - long size = callback->getSize(); - if (size<0) - return false; - size += 4; // We need four terminating 0's at the end. - // For ASCII we need 1 0's, for UTF-16 2, for UTF-32 4. - - char* data8 = new char[size]; - - if (!callback->read(data8, size-4)) - { - delete [] data8; - return false; - } - - // add zeros at end - - memset(data8+size-4, 0, 4); - - char16* data16 = reinterpret_cast<char16*>(data8); - char32* data32 = reinterpret_cast<char32*>(data8); - - // now we need to convert the data to the desired target format - // based on the byte order mark. - - const unsigned char UTF8[] = {0xEF, 0xBB, 0xBF}; // 0xEFBBBF; - const int UTF16_BE = 0xFFFE; - const int UTF16_LE = 0xFEFF; - const int UTF32_BE = 0xFFFE0000; - const int UTF32_LE = 0x0000FEFF; - - // check source for all utf versions and convert to target data format - - if (size >= 4 && data32[0] == (char32)UTF32_BE) - { - // UTF-32, big endian - SourceFormat = ETF_UTF32_BE; - convertTextData(data32+1, data8, (size/4)-1); // data32+1 because we need to skip the header - } - else - if (size >= 4 && data32[0] == (char32)UTF32_LE) - { - // UTF-32, little endian - SourceFormat = ETF_UTF32_LE; - convertTextData(data32+1, data8, (size/4)-1); // data32+1 because we need to skip the header - } - else - if (size >= 2 && data16[0] == UTF16_BE) - { - // UTF-16, big endian - SourceFormat = ETF_UTF16_BE; - convertTextData(data16+1, data8, (size/2)-1); // data16+1 because we need to skip the header - } - else - if (size >= 2 && data16[0] == UTF16_LE) - { - // UTF-16, little endian - SourceFormat = ETF_UTF16_LE; - convertTextData(data16+1, data8, (size/2)-1); // data16+1 because we need to skip the header - } - else - if (size >= 3 && memcmp(data8,UTF8,3)==0) - { - // UTF-8 - SourceFormat = ETF_UTF8; - convertTextData(data8+3, data8, size-3); // data8+3 because we need to skip the header - } - else - { - // ASCII - SourceFormat = ETF_ASCII; - convertTextData(data8, data8, size); - } - - return true; - } - - - //! converts the text file into the desired format. - //! \param source: begin of the text (without byte order mark) - //! \param pointerToStore: pointer to text data block which can be - //! stored or deleted based on the nesessary conversion. - //! \param sizeWithoutHeader: Text size in characters without header - template<class src_char_type> - void convertTextData(src_char_type* source, char* pointerToStore, int sizeWithoutHeader) - { - // convert little to big endian if necessary - if (sizeof(src_char_type) > 1 && - isLittleEndian(TargetFormat) != isLittleEndian(SourceFormat)) - convertToLittleEndian(source); - - // check if conversion is necessary: - if (sizeof(src_char_type) == sizeof(char_type)) - { - // no need to convert - TextBegin = (char_type*)source; - TextData = (char_type*)pointerToStore; - TextSize = sizeWithoutHeader; - } - else - { - // convert source into target data format. - // TODO: implement a real conversion. This one just - // copies bytes. This is a problem when there are - // unicode symbols using more than one character. - - TextData = new char_type[sizeWithoutHeader]; - - for (int i=0; i<sizeWithoutHeader; ++i) - TextData[i] = (char_type)source[i]; - - TextBegin = TextData; - TextSize = sizeWithoutHeader; - - // delete original data because no longer needed - delete [] pointerToStore; - } - } - - //! converts whole text buffer to little endian - template<class src_char_type> - void convertToLittleEndian(src_char_type* t) - { - if (sizeof(src_char_type) == 4) - { - // 32 bit - - while(*t) - { - *t = ((*t & 0xff000000) >> 24) | - ((*t & 0x00ff0000) >> 8) | - ((*t & 0x0000ff00) << 8) | - ((*t & 0x000000ff) << 24); - ++t; - } - } - else - { - // 16 bit - - while(*t) - { - *t = (*t >> 8) | (*t << 8); - ++t; - } - } - } - - //! returns if a format is little endian - inline bool isLittleEndian(ETEXT_FORMAT f) - { - return f == ETF_ASCII || - f == ETF_UTF8 || - f == ETF_UTF16_LE || - f == ETF_UTF32_LE; - } - - - //! returns true if a character is whitespace - inline bool isWhiteSpace(char_type c) - { - return (c==' ' || c=='\t' || c=='\n' || c=='\r'); - } - - - //! generates a list with xml special characters - void createSpecialCharacterList() - { - // list of strings containing special symbols, - // the first character is the special character, - // the following is the symbol string without trailing &. - - SpecialCharacters.push_back("&"); - SpecialCharacters.push_back("<lt;"); - SpecialCharacters.push_back(">gt;"); - SpecialCharacters.push_back("\"quot;"); - SpecialCharacters.push_back("'apos;"); - - } - - - //! compares the first n characters of the strings - bool equalsn(const char_type* str1, const char_type* str2, int len) - { - int i; - for(i=0; str1[i] && str2[i] && i < len; ++i) - if (str1[i] != str2[i]) - return false; - - // if one (or both) of the strings was smaller then they - // are only equal if they have the same lenght - return (i == len) || (str1[i] == 0 && str2[i] == 0); - } - - - //! stores the target text format - void storeTargetFormat() - { - // get target format. We could have done this using template specialization, - // but VisualStudio 6 don't like it and we want to support it. - - switch(sizeof(char_type)) - { - case 1: - TargetFormat = ETF_UTF8; - break; - case 2: - TargetFormat = ETF_UTF16_LE; - break; - case 4: - TargetFormat = ETF_UTF32_LE; - break; - default: - TargetFormat = ETF_ASCII; // should never happen. - } - } - - - // instance variables: - - char_type* TextData; // data block of the text file - char_type* P; // current point in text to parse - char_type* TextBegin; // start of text to parse - unsigned int TextSize; // size of text to parse in characters, not bytes - - EXML_NODE CurrentNodeType; // type of the currently parsed node - ETEXT_FORMAT SourceFormat; // source format of the xml file - ETEXT_FORMAT TargetFormat; // output format of this parser - - core::string<char_type> NodeName; // name of the node currently in - core::string<char_type> EmptyString; // empty string to be returned by getSafe() methods - - bool IsEmptyElement; // is the currently parsed node empty? - - core::array< core::string<char_type> > SpecialCharacters; // see createSpecialCharacterList() - - core::array<SAttribute> Attributes; // attributes of current element - -}; // end CXMLReaderImpl - - -} // end namespace -} // end namespace - -#endif diff --git a/irrlicht-1.6/source/Irrlicht/CXMLWriter.cpp b/irrlicht-1.6/source/Irrlicht/CXMLWriter.cpp deleted file mode 100644 index 43dea14a3..000000000 --- a/irrlicht-1.6/source/Irrlicht/CXMLWriter.cpp +++ /dev/null @@ -1,253 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CXMLWriter.h" -#include <wchar.h> -#include "irrString.h" -#include "IrrCompileConfig.h" - -namespace irr -{ -namespace io -{ - - -//! Constructor -CXMLWriter::CXMLWriter(IWriteFile* file) -: File(file), Tabs(0), TextWrittenLast(false) -{ - #ifdef _DEBUG - setDebugName("CXMLWriter"); - #endif - - if (File) - File->grab(); -} - - - -//! Destructor -CXMLWriter::~CXMLWriter() -{ - if (File) - File->drop(); -} - - - -//! Writes a xml 1.0 header like <?xml version="1.0"?> -void CXMLWriter::writeXMLHeader() -{ - if (!File) - return; - - if (sizeof(wchar_t)==2) - { - const u16 h = 0xFEFF; - File->write(&h, 2); - } - else - { - const u32 h = 0x0000FEFF; - File->write(&h, sizeof(wchar_t)); - } - - const wchar_t* const p = L"<?xml version=\"1.0\"?>"; - File->write(p, wcslen(p)*sizeof(wchar_t)); - - writeLineBreak(); - TextWrittenLast = false; -} - - - -//! Writes an xml element with maximal 5 attributes -void CXMLWriter::writeElement(const wchar_t* name, bool empty, - const wchar_t* attr1Name, const wchar_t* attr1Value, - const wchar_t* attr2Name, const wchar_t* attr2Value, - const wchar_t* attr3Name, const wchar_t* attr3Value, - const wchar_t* attr4Name, const wchar_t* attr4Value, - const wchar_t* attr5Name, const wchar_t* attr5Value) -{ - if (!File || !name) - return; - - if (Tabs > 0) - { - for (int i=0; i<Tabs; ++i) - File->write(L"\t", sizeof(wchar_t)); - } - - // write name - - File->write(L"<", sizeof(wchar_t)); - File->write(name, wcslen(name)*sizeof(wchar_t)); - - // write attributes - - writeAttribute(attr1Name, attr1Value); - writeAttribute(attr2Name, attr2Value); - writeAttribute(attr3Name, attr3Value); - writeAttribute(attr4Name, attr4Value); - writeAttribute(attr5Name, attr5Value); - - // write closing tag - if (empty) - File->write(L" />", 3*sizeof(wchar_t)); - else - { - File->write(L">", sizeof(wchar_t)); - ++Tabs; - } - - TextWrittenLast = false; -} - -//! Writes an xml element with any number of attributes -void CXMLWriter::writeElement(const wchar_t* name, bool empty, - core::array<core::stringw> &names, - core::array<core::stringw> &values) -{ - if (!File || !name) - return; - - if (Tabs > 0) - { - for (int i=0; i<Tabs; ++i) - File->write(L"\t", sizeof(wchar_t)); - } - - // write name - - File->write(L"<", sizeof(wchar_t)); - File->write(name, wcslen(name)*sizeof(wchar_t)); - - // write attributes - u32 i=0; - for (; i < names.size() && i < values.size(); ++i) - writeAttribute(names[i].c_str(), values[i].c_str()); - - // write closing tag - if (empty) - File->write(L" />", 3*sizeof(wchar_t)); - else - { - File->write(L">", sizeof(wchar_t)); - ++Tabs; - } - - TextWrittenLast = false; -} - - -void CXMLWriter::writeAttribute(const wchar_t* name, const wchar_t* value) -{ - if (!name || !value) - return; - - File->write(L" ", sizeof(wchar_t)); - File->write(name, wcslen(name)*sizeof(wchar_t)); - File->write(L"=\"", 2*sizeof(wchar_t)); - writeText(value); - File->write(L"\"", sizeof(wchar_t)); -} - - -//! Writes a comment into the xml file -void CXMLWriter::writeComment(const wchar_t* comment) -{ - if (!File || !comment) - return; - - File->write(L"<!--", 4*sizeof(wchar_t)); - writeText(comment); - File->write(L"-->", 3*sizeof(wchar_t)); -} - - -//! Writes the closing tag for an element. Like </foo> -void CXMLWriter::writeClosingTag(const wchar_t* name) -{ - if (!File || !name) - return; - - --Tabs; - - if (Tabs > 0 && !TextWrittenLast) - { - for (int i=0; i<Tabs; ++i) - File->write(L"\t", sizeof(wchar_t)); - } - - File->write(L"</", 2*sizeof(wchar_t)); - File->write(name, wcslen(name)*sizeof(wchar_t)); - File->write(L">", sizeof(wchar_t)); - TextWrittenLast = false; -} - - - -const CXMLWriter::XMLSpecialCharacters XMLWSChar[] = -{ - { L'&', L"&" }, - { L'<', L"<" }, - { L'>', L">" }, - { L'"', L""" }, - { L'\0', 0 } -}; - - -//! Writes a text into the file. All occurrences of special characters like -//! & (&), < (<), > (>), and " (") are automaticly replaced. -void CXMLWriter::writeText(const wchar_t* text) -{ - if (!File || !text) - return; - - core::stringw s; - const wchar_t* p = text; - - while(*p) - { - // check if it is matching - bool found = false; - for (s32 i=0; XMLWSChar[i].Character != '\0'; ++i) - if (*p == XMLWSChar[i].Character) - { - s.append(XMLWSChar[i].Symbol); - found = true; - break; - } - - if (!found) - s.append(*p); - ++p; - } - - // write new string - File->write(s.c_str(), s.size()*sizeof(wchar_t)); - TextWrittenLast = true; -} - - -//! Writes a line break -void CXMLWriter::writeLineBreak() -{ - if (!File) - return; - -#if defined(_IRR_OSX_PLATFORM_) - File->write(L"\r", sizeof(wchar_t)); -#elif defined(_IRR_WINDOWS_API_) - File->write(L"\r\n", 2*sizeof(wchar_t)); -#else - File->write(L"\n", sizeof(wchar_t)); -#endif - -} - - -} // end namespace irr -} // end namespace io - diff --git a/irrlicht-1.6/source/Irrlicht/CXMLWriter.h b/irrlicht-1.6/source/Irrlicht/CXMLWriter.h deleted file mode 100644 index 0921d366b..000000000 --- a/irrlicht-1.6/source/Irrlicht/CXMLWriter.h +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_XML_WRITER_H_INCLUDED__ -#define __C_XML_WRITER_H_INCLUDED__ - -#include <wchar.h> -#include "IXMLWriter.h" -#include "IWriteFile.h" - -namespace irr -{ -namespace io -{ - - //! Interface providing methods for making it easier to write XML files. - class CXMLWriter : public IXMLWriter - { - public: - - //! Constructor - CXMLWriter(IWriteFile* file); - - //! Destructor - virtual ~CXMLWriter(); - - //! Writes a xml 1.0 header like <?xml version="1.0"?> - virtual void writeXMLHeader(); - - //! Writes an xml element with maximal 5 attributes - virtual void writeElement(const wchar_t* name, bool empty=false, - const wchar_t* attr1Name = 0, const wchar_t* attr1Value = 0, - const wchar_t* attr2Name = 0, const wchar_t* attr2Value = 0, - const wchar_t* attr3Name = 0, const wchar_t* attr3Value = 0, - const wchar_t* attr4Name = 0, const wchar_t* attr4Value = 0, - const wchar_t* attr5Name = 0, const wchar_t* attr5Value = 0); - - //! Writes an xml element with any number of attributes - virtual void writeElement(const wchar_t* name, bool empty, - core::array<core::stringw> &names, core::array<core::stringw> &values); - - //! Writes a comment into the xml file - virtual void writeComment(const wchar_t* comment); - - //! Writes the closing tag for an element. Like </foo> - virtual void writeClosingTag(const wchar_t* name); - - //! Writes a text into the file. All occurrences of special characters like - //! & (&), < (<), > (>), and " (") are automaticly replaced. - virtual void writeText(const wchar_t* text); - - //! Writes a line break - virtual void writeLineBreak(); - - struct XMLSpecialCharacters - { - wchar_t Character; - const wchar_t* Symbol; - }; - - private: - - void writeAttribute(const wchar_t* att, const wchar_t* name); - - IWriteFile* File; - s32 Tabs; - - bool TextWrittenLast; - }; - -} // end namespace irr -} // end namespace io - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CXMeshFileLoader.cpp b/irrlicht-1.6/source/Irrlicht/CXMeshFileLoader.cpp deleted file mode 100644 index 23b5411ee..000000000 --- a/irrlicht-1.6/source/Irrlicht/CXMeshFileLoader.cpp +++ /dev/null @@ -1,2406 +0,0 @@ -// Copyright (C) 2002-2009 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_X_LOADER_ - -#include "CXMeshFileLoader.h" -#include "os.h" - -#include "fast_atof.h" -#include "coreutil.h" -#include "ISceneManager.h" -#include "IVideoDriver.h" -#include "IFileSystem.h" -#include "IReadFile.h" - -#ifdef _DEBUG -#define _XREADER_DEBUG -#endif -//#define BETTER_MESHBUFFER_SPLITTING_FOR_X - -namespace irr -{ -namespace scene -{ - -//! Constructor -CXMeshFileLoader::CXMeshFileLoader(scene::ISceneManager* smgr, io::IFileSystem* fs) -: SceneManager(smgr), FileSystem(fs), AllJoints(0), AnimatedMesh(0), - Buffer(0), P(0), End(0), BinaryNumCount(0), Line(0), - CurFrame(0), MajorVersion(0), MinorVersion(0), BinaryFormat(false), FloatSize(0) -{ - #ifdef _DEBUG - setDebugName("CXMeshFileLoader"); - #endif -} - - -//! returns true if the file maybe is able to be loaded by this class -//! based on the file extension (e.g. ".bsp") -bool CXMeshFileLoader::isALoadableFileExtension(const io::path& filename) const -{ - return core::hasFileExtension ( filename, "x" ); -} - - -//! 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* CXMeshFileLoader::createMesh(io::IReadFile* f) -{ - if (!f) - return 0; - -#ifdef _XREADER_DEBUG - u32 time = os::Timer::getRealTime(); -#endif - - AnimatedMesh = new CSkinnedMesh(); - - if (load(f)) - { - AnimatedMesh->finalize(); - } - else - { - AnimatedMesh->drop(); - AnimatedMesh = 0; - } -#ifdef _XREADER_DEBUG - time = os::Timer::getRealTime() - time; - core::stringc tmpString = "Time to load "; - tmpString += BinaryFormat ? "binary" : "ascii"; - tmpString += " X file: "; - tmpString += time; - tmpString += "ms"; - os::Printer::log(tmpString.c_str()); -#endif - //Clear up - - MajorVersion=0; - MinorVersion=0; - BinaryFormat=0; - BinaryNumCount=0; - FloatSize=0; - P=0; - End=0; - CurFrame=0; - TemplateMaterials.clear(); - - delete [] Buffer; - Buffer = 0; - - for (u32 i=0; i<Meshes.size(); ++i) - delete Meshes[i]; - Meshes.clear(); - - return AnimatedMesh; -} - - -bool CXMeshFileLoader::load(io::IReadFile* file) -{ - if (!readFileIntoMemory(file)) - return false; - - if (!parseFile()) - return false; - - for (u32 n=0; n<Meshes.size(); ++n) - { - SXMesh *mesh=Meshes[n]; - - // default material if nothing loaded - if (!mesh->Materials.size()) - { - mesh->Materials.push_back(video::SMaterial()); - mesh->Materials[0].DiffuseColor.set(0xff777777); - mesh->Materials[0].Shininess=0.f; - mesh->Materials[0].SpecularColor.set(0xff777777); - mesh->Materials[0].EmissiveColor.set(0xff000000); - } - - u32 i; - - mesh->Buffers.reallocate(mesh->Materials.size()); -#ifndef BETTER_MESHBUFFER_SPLITTING_FOR_X - const u32 bufferOffset = AnimatedMesh->getMeshBufferCount(); -#endif - for (i=0; i<mesh->Materials.size(); ++i) - { - mesh->Buffers.push_back( AnimatedMesh->addMeshBuffer() ); - mesh->Buffers.getLast()->Material = mesh->Materials[i]; - - if (!mesh->HasSkinning) - { - //Set up rigid animation - if (mesh->AttachedJointID!=-1) - { - AnimatedMesh->getAllJoints()[mesh->AttachedJointID]->AttachedMeshes.push_back( AnimatedMesh->getMeshBuffers().size()-1 ); - } - } - } - - if (!mesh->FaceMaterialIndices.size()) - { - mesh->FaceMaterialIndices.set_used(mesh->Indices.size() / 3); - for (i=0; i<mesh->FaceMaterialIndices.size(); ++i) - mesh->FaceMaterialIndices[i]=0; - } - - if (!mesh->HasVertexColors) - { - for (u32 j=0;j<mesh->FaceMaterialIndices.size();++j) - { - for (u32 id=j*3+0;id<=j*3+2;++id) - { - mesh->Vertices[ mesh->Indices[id] ].Color = mesh->Buffers[mesh->FaceMaterialIndices[j]]->Material.DiffuseColor; - } - } - } - - #ifdef BETTER_MESHBUFFER_SPLITTING_FOR_X - { - //the same vertex can be used in many different meshbuffers, but it's slow to work out - - core::array< core::array< u32 > > verticesLinkIndex; - verticesLinkIndex.reallocate(mesh->Vertices.size()); - core::array< core::array< u16 > > verticesLinkBuffer; - verticesLinkBuffer.reallocate(mesh->Vertices.size()); - - for (i=0;i<mesh->Vertices.size();++i) - { - verticesLinkIndex.push_back( core::array< u32 >() ); - verticesLinkBuffer.push_back( core::array< u16 >() ); - } - - for (i=0;i<mesh->FaceMaterialIndices.size();++i) - { - for (u32 id=i*3+0;id<=i*3+2;++id) - { - core::array< u16 > &Array=verticesLinkBuffer[ mesh->Indices[id] ]; - bool found=false; - - for (u32 j=0; j < Array.size(); ++j) - { - if (Array[j]==mesh->FaceMaterialIndices[i]) - { - found=true; - break; - } - } - - if (!found) - Array.push_back( mesh->FaceMaterialIndices[i] ); - } - } - - for (i=0;i<verticesLinkBuffer.size();++i) - { - if (!verticesLinkBuffer[i].size()) - verticesLinkBuffer[i].push_back(0); - } - - for (i=0;i<mesh->Vertices.size();++i) - { - core::array< u16 > &Array = verticesLinkBuffer[i]; - verticesLinkIndex[i].reallocate(Array.size()); - for (u32 j=0; j < Array.size(); ++j) - { - scene::SSkinMeshBuffer *buffer = mesh->Buffers[ Array[j] ]; - verticesLinkIndex[i].push_back( buffer->Vertices_Standard.size() ); - buffer->Vertices_Standard.push_back( mesh->Vertices[i] ); - } - } - - for (i=0;i<mesh->FaceMaterialIndices.size();++i) - { - scene::SSkinMeshBuffer *buffer=mesh->Buffers[ mesh->FaceMaterialIndices[i] ]; - - for (u32 id=i*3+0;id<=i*3+2;++id) - { - core::array< u16 > &Array=verticesLinkBuffer[ mesh->Indices[id] ]; - - for (u32 j=0;j< Array.size() ;++j) - { - if ( Array[j]== mesh->FaceMaterialIndices[i] ) - buffer->Indices.push_back( verticesLinkIndex[ mesh->Indices[id] ][j] ); - } - } - } - - for (u32 j=0;j<mesh->WeightJoint.size();++j) - { - ISkinnedMesh::SJoint* joint = AnimatedMesh->getAllJoints()[mesh->WeightJoint[j]]; - ISkinnedMesh::SWeight& weight = joint->Weights[mesh->WeightNum[j]]; - - u32 id = weight.vertex_id; - - if (id>=verticesLinkIndex.size()) - { - os::Printer::log("X loader: Weight id out of range", ELL_WARNING); - id=0; - weight.strength=0.f; - } - - if (verticesLinkBuffer[id].size()==1) - { - weight.vertex_id=verticesLinkIndex[id][0]; - weight.buffer_id=verticesLinkBuffer[id][0]; - } - else if (verticesLinkBuffer[id].size() != 0) - { - for (u32 k=1; k < verticesLinkBuffer[id].size(); ++k) - { - ISkinnedMesh::SWeight* WeightClone = AnimatedMesh->addWeight(joint); - WeightClone->strength = weight.strength; - WeightClone->vertex_id = verticesLinkIndex[id][k]; - WeightClone->buffer_id = verticesLinkBuffer[id][k]; - } - } - } - } - #else - { - core::array< u32 > verticesLinkIndex; - core::array< s16 > verticesLinkBuffer; - verticesLinkBuffer.set_used(mesh->Vertices.size()); - - // init with 0 - for (i=0;i<mesh->Vertices.size();++i) - { - verticesLinkBuffer[i]=-1; - } - - bool warned = false; - // store meshbuffer number per vertex - for (i=0;i<mesh->FaceMaterialIndices.size();++i) - { - for (u32 id=i*3+0;id<=i*3+2;++id) - { - if ((verticesLinkBuffer[mesh->Indices[id]] != -1) && (verticesLinkBuffer[mesh->Indices[id]] != (s16)mesh->FaceMaterialIndices[i])) - { - if (!warned) - { - os::Printer::log("X loader", "Duplicated vertex, animation might be corrupted.", ELL_WARNING); - warned=true; - } - const u32 tmp = mesh->Vertices.size(); - mesh->Vertices.push_back(mesh->Vertices[ mesh->Indices[id] ]); - mesh->Indices[id] = tmp; - verticesLinkBuffer.set_used(mesh->Vertices.size()); - } - verticesLinkBuffer[ mesh->Indices[id] ] = mesh->FaceMaterialIndices[i]; - } - } - - if (mesh->FaceMaterialIndices.size() != 0) - { - // store vertices in buffers and remember relation in verticesLinkIndex - u32* vCountArray = new u32[mesh->Buffers.size()]; - memset(vCountArray, 0, mesh->Buffers.size()*sizeof(u32)); - // count vertices in each buffer and reallocate - for (i=0; i<mesh->Vertices.size(); ++i) - ++vCountArray[verticesLinkBuffer[i]]; - if (mesh->TCoords2.size()) - { - for (i=0; i!=mesh->Buffers.size(); ++i) - { - mesh->Buffers[i]->Vertices_2TCoords.reallocate(vCountArray[i]); - mesh->Buffers[i]->VertexType=video::EVT_2TCOORDS; - } - } - else - { - for (i=0; i!=mesh->Buffers.size(); ++i) - mesh->Buffers[i]->Vertices_Standard.reallocate(vCountArray[i]); - } - - verticesLinkIndex.set_used(mesh->Vertices.size()); - // actually store vertices - for (i=0; i<mesh->Vertices.size(); ++i) - { - scene::SSkinMeshBuffer *buffer = mesh->Buffers[ verticesLinkBuffer[i] ]; - - if (mesh->TCoords2.size()) - { - verticesLinkIndex[i] = buffer->Vertices_2TCoords.size(); - buffer->Vertices_2TCoords.push_back( mesh->Vertices[i] ); - buffer->Vertices_2TCoords.getLast().TCoords2=mesh->TCoords2[i]; - } - else - { - verticesLinkIndex[i] = buffer->Vertices_Standard.size(); - buffer->Vertices_Standard.push_back( mesh->Vertices[i] ); - } - } - - // count indices per buffer and reallocate - memset(vCountArray, 0, mesh->Buffers.size()*sizeof(u32)); - for (i=0; i<mesh->FaceMaterialIndices.size(); ++i) - ++vCountArray[ mesh->FaceMaterialIndices[i] ]; - for (i=0; i!=mesh->Buffers.size(); ++i) - mesh->Buffers[i]->Indices.reallocate(vCountArray[i]); - delete [] vCountArray; - // create indices per buffer - for (i=0; i<mesh->FaceMaterialIndices.size(); ++i) - { - scene::SSkinMeshBuffer *buffer = mesh->Buffers[ mesh->FaceMaterialIndices[i] ]; - for (u32 id=i*3+0; id!=i*3+3; ++id) - { - buffer->Indices.push_back( verticesLinkIndex[ mesh->Indices[id] ] ); - } - } - } - - for (u32 j=0; j<mesh->WeightJoint.size(); ++j) - { - ISkinnedMesh::SWeight& weight = (AnimatedMesh->getAllJoints()[mesh->WeightJoint[j]]->Weights[mesh->WeightNum[j]]); - - u32 id = weight.vertex_id; - - if (id>=verticesLinkIndex.size()) - { - os::Printer::log("X loader: Weight id out of range", ELL_WARNING); - id=0; - weight.strength=0.f; - } - - weight.vertex_id=verticesLinkIndex[id]; - weight.buffer_id=verticesLinkBuffer[id] + bufferOffset; - } - } - #endif - - } - - return true; -} - - -//! Reads file into memory -bool CXMeshFileLoader::readFileIntoMemory(io::IReadFile* file) -{ - const long size = file->getSize(); - if (size < 12) - { - os::Printer::log("X File is too small.", ELL_WARNING); - return false; - } - - Buffer = new c8[size]; - - //! read all into memory - if (file->read(Buffer, size) != size) - { - os::Printer::log("Could not read from x file.", ELL_WARNING); - return false; - } - - Line = 1; - End = Buffer + size; - - //! check header "xof " - if (strncmp(Buffer, "xof ", 4)!=0) - { - os::Printer::log("Not an x file, wrong header.", ELL_WARNING); - return false; - } - - //! read minor and major version, e.g. 0302 or 0303 - c8 tmp[3]; - tmp[2] = 0x0; - tmp[0] = Buffer[4]; - tmp[1] = Buffer[5]; - MajorVersion = core::strtol10(tmp); - - tmp[0] = Buffer[6]; - tmp[1] = Buffer[7]; - MinorVersion = core::strtol10(tmp); - - //! read format - if (strncmp(&Buffer[8], "txt ", 4) ==0) - BinaryFormat = false; - else if (strncmp(&Buffer[8], "bin ", 4) ==0) - BinaryFormat = true; - else - { - os::Printer::log("Only uncompressed x files currently supported.", ELL_WARNING); - return false; - } - BinaryNumCount=0; - - //! read float size - if (strncmp(&Buffer[12], "0032", 4) ==0) - FloatSize = 4; - else if (strncmp(&Buffer[12], "0064", 4) ==0) - FloatSize = 8; - else - { - os::Printer::log("Float size not supported.", ELL_WARNING); - return false; - } - - P = &Buffer[16]; - - readUntilEndOfLine(); - FilePath = FileSystem->getFileDir(file->getFileName()) + "/"; - FilePath += '/'; - - return true; -} - - -//! Parses the file -bool CXMeshFileLoader::parseFile() -{ - while(parseDataObject()) - { - // loop - } - - return true; -} - - -//! Parses the next Data object in the file -bool CXMeshFileLoader::parseDataObject() -{ - core::stringc objectName = getNextToken(); - - if (objectName.size() == 0) - return false; - - // parse specific object -#ifdef _XREADER_DEBUG - os::Printer::log("debug DataObject:", objectName.c_str() ); -#endif - - if (objectName == "template") - return parseDataObjectTemplate(); - else - if (objectName == "Frame") - { - return parseDataObjectFrame( 0 ); - } - else - if (objectName == "Mesh") - { - // some meshes have no frames at all - //CurFrame = AnimatedMesh->addJoint(0); - - SXMesh *mesh=new SXMesh; - - //mesh->Buffer=AnimatedMesh->addMeshBuffer(); - Meshes.push_back(mesh); - - return parseDataObjectMesh(*mesh); - } - else - if (objectName == "AnimationSet") - { - return parseDataObjectAnimationSet(); - } - else - if (objectName == "Material") - { - // template materials now available thanks to joeWright - TemplateMaterials.push_back(SXTemplateMaterial()); - TemplateMaterials.getLast().Name = getNextToken(); - return parseDataObjectMaterial(TemplateMaterials.getLast().Material); - } - else - if (objectName == "}") - { - os::Printer::log("} found in dataObject", ELL_WARNING); - return true; - } - - os::Printer::log("Unknown data object in animation of .x file", objectName.c_str(), ELL_WARNING); - - return parseUnknownDataObject(); -} - - -bool CXMeshFileLoader::parseDataObjectTemplate() -{ -#ifdef _XREADER_DEBUG - os::Printer::log("CXFileReader: Reading template"); -#endif - - // parse a template data object. Currently not stored. - core::stringc name; - - if (!readHeadOfDataObject(&name)) - { - os::Printer::log("Left delimiter in template data object missing.", - name.c_str(), ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - - // read GUID - getNextToken(); - - // read and ignore data members - while(true) - { - core::stringc s = getNextToken(); - - if (s == "}") - break; - - if (s.size() == 0) - return false; - } - - return true; -} - - -bool CXMeshFileLoader::parseDataObjectFrame(CSkinnedMesh::SJoint *Parent) -{ -#ifdef _XREADER_DEBUG - os::Printer::log("CXFileReader: Reading frame"); -#endif - - // A coordinate frame, or "frame of reference." The Frame template - // is open and can contain any object. The Direct3D extensions (D3DX) - // mesh-loading functions recognize Mesh, FrameTransformMatrix, and - // Frame template instances as child objects when loading a Frame - // instance. - - u32 JointID=0; - - core::stringc name; - - if (!readHeadOfDataObject(&name)) - { - os::Printer::log("No opening brace in Frame found in x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - - CSkinnedMesh::SJoint *joint=0; - - if (name.size()) - { - for (u32 n=0; n < AnimatedMesh->getAllJoints().size(); ++n) - { - if (AnimatedMesh->getAllJoints()[n]->Name==name) - { - joint=AnimatedMesh->getAllJoints()[n]; - JointID=n; - break; - } - } - } - - if (!joint) - { -#ifdef _XREADER_DEBUG - os::Printer::log("creating joint ", name.c_str()); -#endif - joint=AnimatedMesh->addJoint(Parent); - joint->Name=name; - JointID=AnimatedMesh->getAllJoints().size()-1; - } - else - { -#ifdef _XREADER_DEBUG - os::Printer::log("using joint ", name.c_str()); -#endif - if (Parent) - Parent->Children.push_back(joint); - } - - // Now inside a frame. - // read tokens until closing brace is reached. - - while(true) - { - core::stringc objectName = getNextToken(); - -#ifdef _XREADER_DEBUG - os::Printer::log("debug DataObject in frame:", objectName.c_str() ); -#endif - - if (objectName.size() == 0) - { - os::Printer::log("Unexpected ending found in Frame in x file.", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - else - if (objectName == "}") - { - break; // frame finished - } - else - if (objectName == "Frame") - { - - if (!parseDataObjectFrame(joint)) - return false; - } - else - if (objectName == "FrameTransformMatrix") - { - if (!parseDataObjectTransformationMatrix(joint->LocalMatrix)) - return false; - - //joint->LocalAnimatedMatrix - //joint->LocalAnimatedMatrix.makeInverse(); - //joint->LocalMatrix=tmp*joint->LocalAnimatedMatrix; - } - else - if (objectName == "Mesh") - { - /* - frame.Meshes.push_back(SXMesh()); - if (!parseDataObjectMesh(frame.Meshes.getLast())) - return false; - */ - SXMesh *mesh=new SXMesh; - - mesh->AttachedJointID=JointID; - - Meshes.push_back(mesh); - - if (!parseDataObjectMesh(*mesh)) - return false; - } - else - { - os::Printer::log("Unknown data object in frame in x file", objectName.c_str(), ELL_WARNING); - if (!parseUnknownDataObject()) - return false; - } - } - - return true; -} - - -bool CXMeshFileLoader::parseDataObjectTransformationMatrix(core::matrix4 &mat) -{ -#ifdef _XREADER_DEBUG - os::Printer::log("CXFileReader: Reading Transformation Matrix"); -#endif - - if (!readHeadOfDataObject()) - { - os::Printer::log("No opening brace in Transformation Matrix found in x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - - readMatrix(mat); - - if (!checkForOneFollowingSemicolons()) - { - os::Printer::log("No finishing semicolon in Transformation Matrix found in x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - } - - if (!checkForClosingBrace()) - { - os::Printer::log("No closing brace in Transformation Matrix found in x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - - return true; -} - - -bool CXMeshFileLoader::parseDataObjectMesh(SXMesh &mesh) -{ - core::stringc name; - - if (!readHeadOfDataObject(&name)) - { -#ifdef _XREADER_DEBUG - os::Printer::log("CXFileReader: Reading mesh"); -#endif - os::Printer::log("No opening brace in Mesh found in x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - -#ifdef _XREADER_DEBUG - os::Printer::log("CXFileReader: Reading mesh", name.c_str()); -#endif - - // read vertex count - const u32 nVertices = readInt(); - - // read vertices - mesh.Vertices.set_used(nVertices); - for (u32 n=0; n<nVertices; ++n) - { - readVector3(mesh.Vertices[n].Pos); - mesh.Vertices[n].Color=0xFFFFFFFF; - } - - if (!checkForTwoFollowingSemicolons()) - { - os::Printer::log("No finishing semicolon in Mesh Vertex Array found in x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - } - - // read faces - const u32 nFaces = readInt(); - - mesh.Indices.set_used(nFaces * 3); - mesh.IndexCountPerFace.set_used(nFaces); - - core::array<u32> polygonfaces; - u32 currentIndex = 0; - - for (u32 k=0; k<nFaces; ++k) - { - const u32 fcnt = readInt(); - - if (fcnt != 3) - { - if (fcnt < 3) - { - os::Printer::log("Invalid face count (<3) found in Mesh x file reader.", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - - // read face indices - polygonfaces.set_used(fcnt); - u32 triangles = (fcnt-2); - mesh.Indices.set_used(mesh.Indices.size() + ((triangles-1)*3)); - mesh.IndexCountPerFace[k] = (u16)(triangles * 3); - - for (u32 f=0; f<fcnt; ++f) - polygonfaces[f] = readInt(); - - for (u32 jk=0; jk<triangles; ++jk) - { - mesh.Indices[currentIndex++] = polygonfaces[0]; - mesh.Indices[currentIndex++] = polygonfaces[jk+1]; - mesh.Indices[currentIndex++] = polygonfaces[jk+2]; - } - - // TODO: change face indices in material list - } - else - { - mesh.Indices[currentIndex++] = readInt(); - mesh.Indices[currentIndex++] = readInt(); - mesh.Indices[currentIndex++] = readInt(); - mesh.IndexCountPerFace[k] = 3; - } - } - - if (!checkForTwoFollowingSemicolons()) - { - os::Printer::log("No finishing semicolon in Mesh Face Array found in x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - } - - // here, other data objects may follow - - while(true) - { - core::stringc objectName = getNextToken(); - - if (objectName.size() == 0) - { - os::Printer::log("Unexpected ending found in Mesh in x file.", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - else - if (objectName == "}") - { - break; // mesh finished - } - -#ifdef _XREADER_DEBUG - os::Printer::log("debug DataObject in mesh:", objectName.c_str() ); -#endif - - if (objectName == "MeshNormals") - { - if (!parseDataObjectMeshNormals(mesh)) - return false; - } - else - if (objectName == "MeshTextureCoords") - { - if (!parseDataObjectMeshTextureCoords(mesh)) - return false; - } - else - if (objectName == "MeshVertexColors") - { - if (!parseDataObjectMeshVertexColors(mesh)) - return false; - } - else - if (objectName == "MeshMaterialList") - { - if (!parseDataObjectMeshMaterialList(mesh)) - return false; - } - else - if (objectName == "VertexDuplicationIndices") - { - // we'll ignore vertex duplication indices - // TODO: read them - if (!parseUnknownDataObject()) - return false; - } - else - if (objectName == "DeclData") - { - // arbitrary vertex attributes - // first comes the number of element definitions - // then the vertex element type definitions - // with format type;tesselator;semantics;usageindex - // we want to support 2;0;6;0 == tangent - // 2;0;7;0 == binormal - // 2;0;3;0 == normal - // 1/2;0;5;0 == 1st uv coord - // and 1/2;0;5;1 == 2nd uv coord - // type==2 is 3xf32, type==1 is 2xf32 - u32 j; - const u32 dcnt = readInt(); - u16 size = 0; - s16 normalpos = -1; - s16 uvpos = -1; - s16 uv2pos = -1; - s16 tangentpos = -1; - s16 binormalpos = -1; - s16 normaltype = -1; - s16 uvtype = -1; - s16 uv2type = -1; - s16 tangenttype = -1; - s16 binormaltype = -1; - for (j=0; j<dcnt; ++j) - { - const u32 type = readInt(); - //const u32 tesselator = readInt(); - readInt(); - const u32 semantics = readInt(); - const u32 index = readInt(); - switch (semantics) - { - case 3: - normalpos = size; - normaltype = type; - break; - case 5: - if (index==0) - { - uvpos = size; - uvtype = type; - } - else if (index==1) - { - uv2pos = size; - uv2type = type; - } - break; - case 6: - tangentpos = size; - tangenttype = type; - break; - case 7: - binormalpos = size; - binormaltype = type; - break; - default: - break; - } - switch (type) - { - case 0: - size += 4; - break; - case 1: - size += 8; - break; - case 2: - size += 12; - break; - case 3: - size += 16; - break; - case 4: - case 5: - case 6: - size += 4; - break; - case 7: - size += 8; - break; - case 8: - case 9: - size += 4; - break; - case 10: - size += 8; - break; - case 11: - size += 4; - break; - case 12: - size += 8; - break; - case 13: - size += 4; - break; - case 14: - size += 4; - break; - case 15: - size += 4; - break; - case 16: - size += 8; - break; - } - } - const u32 datasize = readInt(); - u32* data = new u32[datasize]; - for (j=0; j<datasize; ++j) - data[j]=readInt(); - - if (!checkForOneFollowingSemicolons()) - { - os::Printer::log("No finishing semicolon in DeclData found.", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - } - if (!checkForClosingBrace()) - { - os::Printer::log("No closing brace in DeclData.", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - delete [] data; - return false; - } - u8* dataptr = (u8*) data; - if ((uv2pos != -1) && (uv2type == 1)) - mesh.TCoords2.reallocate(mesh.Vertices.size()); - for (j=0; j<mesh.Vertices.size(); ++j) - { - if ((normalpos != -1) && (normaltype == 2)) - mesh.Vertices[j].Normal.set(*((core::vector3df*)(dataptr+normalpos))); - if ((uvpos != -1) && (uvtype == 1)) - mesh.Vertices[j].TCoords.set(*((core::vector2df*)(dataptr+uvpos))); - if ((uv2pos != -1) && (uv2type == 1)) - mesh.TCoords2.push_back(*((core::vector2df*)(dataptr+uv2pos))); - dataptr += size; - } - delete [] data; - } - else - if (objectName == "FVFData") - { - if (!readHeadOfDataObject()) - { - os::Printer::log("No starting brace in FVFData found.", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - const u32 dataformat = readInt(); - const u32 datasize = readInt(); - u32* data = new u32[datasize]; - for (u32 j=0; j<datasize; ++j) - data[j]=readInt(); - if (dataformat&0x102) // 2nd uv set - { - mesh.TCoords2.reallocate(mesh.Vertices.size()); - u8* dataptr = (u8*) data; - const u32 size=((dataformat>>8)&0xf)*sizeof(core::vector2df); - for (u32 j=0; j<mesh.Vertices.size(); ++j) - { - mesh.TCoords2.push_back(*((core::vector2df*)(dataptr))); - dataptr += size; - } - } - delete [] data; - if (!checkForOneFollowingSemicolons()) - { - os::Printer::log("No finishing semicolon in FVFData found.", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - } - if (!checkForClosingBrace()) - { - os::Printer::log("No closing brace in FVFData found in x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - } - else - if (objectName == "XSkinMeshHeader") - { - if (!parseDataObjectSkinMeshHeader(mesh)) - return false; - } - else - if (objectName == "SkinWeights") - { - //mesh.SkinWeights.push_back(SXSkinWeight()); - //if (!parseDataObjectSkinWeights(mesh.SkinWeights.getLast())) - if (!parseDataObjectSkinWeights(mesh)) - return false; - } - else - { - os::Printer::log("Unknown data object in mesh in x file", objectName.c_str(), ELL_WARNING); - if (!parseUnknownDataObject()) - return false; - } - } - - return true; -} - - -bool CXMeshFileLoader::parseDataObjectSkinWeights(SXMesh &mesh) -{ -#ifdef _XREADER_DEBUG - os::Printer::log("CXFileReader: Reading mesh skin weights"); -#endif - - if (!readHeadOfDataObject()) - { - os::Printer::log("No opening brace in Skin Weights found in .x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - - core::stringc TransformNodeName; - - if (!getNextTokenAsString(TransformNodeName)) - { - os::Printer::log("Unknown syntax while reading transfrom node name string in .x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - - mesh.HasSkinning=true; - - CSkinnedMesh::SJoint *joint=0; - - u32 n; - for (n=0; n < AnimatedMesh->getAllJoints().size(); ++n) - { - if (AnimatedMesh->getAllJoints()[n]->Name==TransformNodeName) - { - joint=AnimatedMesh->getAllJoints()[n]; - break; - } - } - - if (!joint) - { -#ifdef _XREADER_DEBUG - os::Printer::log("creating joint for skinning ", TransformNodeName.c_str()); -#endif - n = AnimatedMesh->getAllJoints().size(); - joint=AnimatedMesh->addJoint(0); - joint->Name=TransformNodeName; - } - - // read vertex weights - const u32 nWeights = readInt(); - - // read vertex indices - u32 i; - - const u32 jointStart = joint->Weights.size(); - joint->Weights.reallocate(jointStart+nWeights); - - mesh.WeightJoint.reallocate( mesh.WeightJoint.size() + nWeights ); - mesh.WeightNum.reallocate( mesh.WeightNum.size() + nWeights ); - - for (i=0; i<nWeights; ++i) - { - mesh.WeightJoint.push_back(n); - mesh.WeightNum.push_back(joint->Weights.size()); - - CSkinnedMesh::SWeight *weight=AnimatedMesh->addWeight(joint); - - weight->buffer_id=0; - weight->vertex_id=readInt(); - } - - // read vertex weights - - for (i=jointStart; i<jointStart+nWeights; ++i) - joint->Weights[i].strength = readFloat(); - - // read matrix offset - - // transforms the mesh vertices to the space of the bone - // When concatenated to the bone's transform, this provides the - // world space coordinates of the mesh as affected by the bone - core::matrix4& MatrixOffset = joint->GlobalInversedMatrix; - - readMatrix(MatrixOffset); - - if (!checkForOneFollowingSemicolons()) - { - os::Printer::log("No finishing semicolon in Skin Weights found in x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - } - - if (!checkForClosingBrace()) - { - os::Printer::log("No closing brace in Skin Weights found in x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - - return true; -} - - -bool CXMeshFileLoader::parseDataObjectSkinMeshHeader(SXMesh& mesh) -{ -#ifdef _XREADER_DEBUG - os::Printer::log("CXFileReader: Reading skin mesh header"); -#endif - - if (!readHeadOfDataObject()) - { - os::Printer::log("No opening brace in Skin Mesh header found in .x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - - mesh.MaxSkinWeightsPerVertex = readInt(); - mesh.MaxSkinWeightsPerFace = readInt(); - mesh.BoneCount = readInt(); - - if (!BinaryFormat) - getNextToken(); // skip semicolon - - if (!checkForClosingBrace()) - { - os::Printer::log("No closing brace in skin mesh header in x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - - return true; -} - - -bool CXMeshFileLoader::parseDataObjectMeshNormals(SXMesh &mesh) -{ -#ifdef _XREADER_DEBUG - os::Printer::log("CXFileReader: reading mesh normals"); -#endif - - if (!readHeadOfDataObject()) - { - os::Printer::log("No opening brace in Mesh Normals found in x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - - // read count - const u32 nNormals = readInt(); - core::array<core::vector3df> normals; - normals.set_used(nNormals); - - // read normals - for (u32 i=0; i<nNormals; ++i) - readVector3(normals[i]); - - if (!checkForTwoFollowingSemicolons()) - { - os::Printer::log("No finishing semicolon in Mesh Normals Array found in x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - } - - core::array<u32> normalIndices; - normalIndices.set_used(mesh.Indices.size()); - - // read face normal indices - const u32 nFNormals = readInt(); - - u32 normalidx = 0; - core::array<u32> polygonfaces; - for (u32 k=0; k<nFNormals; ++k) - { - const u32 fcnt = readInt(); - u32 triangles = fcnt - 2; - u32 indexcount = triangles * 3; - - if (indexcount != mesh.IndexCountPerFace[k]) - { - os::Printer::log("Not matching normal and face index count found in x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - - if (indexcount == 3) - { - // default, only one triangle in this face - for (u32 h=0; h<3; ++h) - { - const u32 normalnum = readInt(); - mesh.Vertices[mesh.Indices[normalidx++]].Normal.set(normals[normalnum]); - } - } - else - { - polygonfaces.set_used(fcnt); - // multiple triangles in this face - for (u32 h=0; h<fcnt; ++h) - polygonfaces[h] = readInt(); - - for (u32 jk=0; jk<triangles; ++jk) - { - mesh.Vertices[mesh.Indices[normalidx++]].Normal.set(normals[polygonfaces[0]]); - mesh.Vertices[mesh.Indices[normalidx++]].Normal.set(normals[polygonfaces[jk+1]]); - mesh.Vertices[mesh.Indices[normalidx++]].Normal.set(normals[polygonfaces[jk+2]]); - } - } - } - - if (!checkForTwoFollowingSemicolons()) - { - os::Printer::log("No finishing semicolon in Mesh Face Normals Array found in x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - } - - if (!checkForClosingBrace()) - { - os::Printer::log("No closing brace in Mesh Normals found in x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - - return true; -} - - -bool CXMeshFileLoader::parseDataObjectMeshTextureCoords(SXMesh &mesh) -{ -#ifdef _XREADER_DEBUG - os::Printer::log("CXFileReader: reading mesh texture coordinates"); -#endif - - if (!readHeadOfDataObject()) - { - os::Printer::log("No opening brace in Mesh Texture Coordinates found in x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - - const u32 nCoords = readInt(); - for (u32 i=0; i<nCoords; ++i) - readVector2(mesh.Vertices[i].TCoords); - - if (!checkForTwoFollowingSemicolons()) - { - os::Printer::log("No finishing semicolon in Mesh Texture Coordinates Array found in x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - } - - if (!checkForClosingBrace()) - { - os::Printer::log("No closing brace in Mesh Texture Coordinates Array found in x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - - return true; -} - - -bool CXMeshFileLoader::parseDataObjectMeshVertexColors(SXMesh &mesh) -{ -#ifdef _XREADER_DEBUG - os::Printer::log("CXFileReader: reading mesh vertex colors"); -#endif - - if (!readHeadOfDataObject()) - { - os::Printer::log("No opening brace for Mesh Vertex Colors found in x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - - mesh.HasVertexColors=true; - const u32 nColors = readInt(); - for (u32 i=0; i<nColors; ++i) - { - const u32 Index=readInt(); - if (Index>=mesh.Vertices.size()) - { - os::Printer::log("index value in parseDataObjectMeshVertexColors out of bounds", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - readRGBA(mesh.Vertices[Index].Color); - checkForOneFollowingSemicolons(); - } - - if (!checkForOneFollowingSemicolons()) - { - os::Printer::log("No finishing semicolon in Mesh Vertex Colors Array found in x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - } - - if (!checkForClosingBrace()) - { - os::Printer::log("No closing brace in Mesh Texture Coordinates Array found in x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - - return true; -} - - -bool CXMeshFileLoader::parseDataObjectMeshMaterialList(SXMesh &mesh) -{ -#ifdef _XREADER_DEBUG - os::Printer::log("CXFileReader: Reading mesh material list"); -#endif - - if (!readHeadOfDataObject()) - { - os::Printer::log("No opening brace in Mesh Material List found in x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - - // read material count - mesh.Materials.reallocate(readInt()); - - // read non triangulated face material index count - const u32 nFaceIndices = readInt(); - - // There seems to be a compact representation of "all faces the same material" - // being represented as 1;1;0;; which means 1 material, 1 face with first material - // all the other faces have to obey then, so check is disabled - //if (nFaceIndices != mesh.IndexCountPerFace.size()) - // os::Printer::log("Index count per face not equal to face material index count in x file.", ELL_WARNING); - - // read non triangulated face indices and create triangulated ones - mesh.FaceMaterialIndices.set_used( mesh.Indices.size() / 3); - u32 triangulatedindex = 0; - u32 ind = 0; - for (u32 tfi=0; tfi<mesh.IndexCountPerFace.size(); ++tfi) - { - if (tfi<nFaceIndices) - ind = readInt(); - const u32 fc = mesh.IndexCountPerFace[tfi]/3; - for (u32 k=0; k<fc; ++k) - mesh.FaceMaterialIndices[triangulatedindex++] = ind; - } - - // in version 03.02, the face indices end with two semicolons. - // commented out version check, as version 03.03 exported from blender also has 2 semicolons - if (!BinaryFormat) // && MajorVersion == 3 && MinorVersion <= 2) - { - if (P[0] == ';') - ++P; - } - - // read following data objects - - while(true) - { - core::stringc objectName = getNextToken(); - - if (objectName.size() == 0) - { - os::Printer::log("Unexpected ending found in Mesh Material list in .x file.", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - else - if (objectName == "}") - { - break; // material list finished - } - else - if (objectName == "{") - { - // template materials now available thanks to joeWright - objectName = getNextToken(); - for (u32 i=0; i<TemplateMaterials.size(); ++i) - if (TemplateMaterials[i].Name == objectName) - mesh.Materials.push_back(TemplateMaterials[i].Material); - getNextToken(); // skip } - } - else - if (objectName == "Material") - { - mesh.Materials.push_back(video::SMaterial()); - if (!parseDataObjectMaterial(mesh.Materials.getLast())) - return false; - } - else - if (objectName == ";") - { - // ignore - } - else - { - os::Printer::log("Unknown data object in material list in x file", objectName.c_str(), ELL_WARNING); - if (!parseUnknownDataObject()) - return false; - } - } - return true; -} - - -bool CXMeshFileLoader::parseDataObjectMaterial(video::SMaterial& material) -{ -#ifdef _XREADER_DEBUG - os::Printer::log("CXFileReader: Reading mesh material"); -#endif - - if (!readHeadOfDataObject()) - { - os::Printer::log("No opening brace in Mesh Material found in .x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - - // read RGBA - readRGBA(material.DiffuseColor); checkForOneFollowingSemicolons(); - - // read power - material.Shininess = readFloat(); - - // read specular - readRGB(material.SpecularColor); checkForOneFollowingSemicolons(); - - // read emissive - readRGB(material.EmissiveColor); checkForOneFollowingSemicolons(); - - // read other data objects - int textureLayer=0; - while(true) - { - core::stringc objectName = getNextToken(); - - if (objectName.size() == 0) - { - os::Printer::log("Unexpected ending found in Mesh Material in .x file.", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - else - if (objectName == "}") - { - break; // material finished - } - else - if (objectName.equals_ignore_case("TextureFilename")) - { - // some exporters write "TextureFileName" instead. - core::stringc TextureFileName; - if (!parseDataObjectTextureFilename(TextureFileName)) - return false; - - // original name - if (FileSystem->existFile(TextureFileName)) - material.setTexture(textureLayer, SceneManager->getVideoDriver()->getTexture(TextureFileName)); - // mesh path - else - { - TextureFileName=FilePath + FileSystem->getFileBasename(TextureFileName); - if (FileSystem->existFile(TextureFileName)) - material.setTexture(textureLayer, SceneManager->getVideoDriver()->getTexture(TextureFileName)); - // working directory - else - material.setTexture(textureLayer, SceneManager->getVideoDriver()->getTexture(FileSystem->getFileBasename(TextureFileName))); - } - ++textureLayer; - if (textureLayer==2) - material.MaterialType=video::EMT_LIGHTMAP; - } - else - if (objectName.equals_ignore_case("NormalmapFilename")) - { - // some exporters write "NormalmapFileName" instead. - core::stringc TextureFileName; - if (!parseDataObjectTextureFilename(TextureFileName)) - return false; - - // original name - if (FileSystem->existFile(TextureFileName)) - material.setTexture(1, SceneManager->getVideoDriver()->getTexture(TextureFileName)); - // mesh path - else - { - TextureFileName=FilePath + FileSystem->getFileBasename(TextureFileName); - if (FileSystem->existFile(TextureFileName)) - material.setTexture(1, SceneManager->getVideoDriver()->getTexture(TextureFileName)); - // working directory - else - material.setTexture(1, SceneManager->getVideoDriver()->getTexture(FileSystem->getFileBasename(TextureFileName))); - } - if (textureLayer==1) - ++textureLayer; - } - else - { - os::Printer::log("Unknown data object in material in .x file", objectName.c_str(), ELL_WARNING); - if (!parseUnknownDataObject()) - return false; - } - } - - return true; -} - - -bool CXMeshFileLoader::parseDataObjectAnimationSet() -{ -#ifdef _XREADER_DEBUG - os::Printer::log("CXFileReader: Reading animation set"); -#endif - - core::stringc AnimationName; - - if (!readHeadOfDataObject(&AnimationName)) - { - os::Printer::log("No opening brace in Animation Set found in x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - - while(true) - { - core::stringc objectName = getNextToken(); - - if (objectName.size() == 0) - { - os::Printer::log("Unexpected ending found in Animation set in x file.", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - else - if (objectName == "}") - { - break; // animation set finished - } - else - if (objectName == "Animation") - { - if (!parseDataObjectAnimation()) - return false; - } - else - { - os::Printer::log("Unknown data object in animation set in x file", objectName.c_str(), ELL_WARNING); - if (!parseUnknownDataObject()) - return false; - } - } - return true; -} - - -bool CXMeshFileLoader::parseDataObjectAnimation() -{ -#ifdef _XREADER_DEBUG - os::Printer::log("CXFileReader: reading animation"); -#endif - - if (!readHeadOfDataObject()) - { - os::Printer::log("No opening brace in Animation found in x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - - //anim.closed = true; - //anim.linearPositionQuality = true; - CSkinnedMesh::SJoint animationDump; - - core::stringc FrameName; - - while(true) - { - core::stringc objectName = getNextToken(); - - if (objectName.size() == 0) - { - os::Printer::log("Unexpected ending found in Animation in x file.", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - else - if (objectName == "}") - { - break; // animation finished - } - else - if (objectName == "AnimationKey") - { - if (!parseDataObjectAnimationKey(&animationDump)) - return false; - } - else - if (objectName == "AnimationOptions") - { - //TODO: parse options. - if (!parseUnknownDataObject()) - return false; - } - else - if (objectName == "{") - { - // read frame name - FrameName = getNextToken(); - - if (!checkForClosingBrace()) - { - os::Printer::log("Unexpected ending found in Animation in x file.", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - } - else - { - os::Printer::log("Unknown data object in animation in x file", objectName.c_str(), ELL_WARNING); - if (!parseUnknownDataObject()) - return false; - } - } - - if (FrameName.size() != 0) - { -#ifdef _XREADER_DEBUG - os::Printer::log("getting name: ", FrameName.c_str()); -#endif - CSkinnedMesh::SJoint *joint=0; - - u32 n; - for (n=0; n < AnimatedMesh->getAllJoints().size(); ++n) - { - if (AnimatedMesh->getAllJoints()[n]->Name==FrameName) - { - joint=AnimatedMesh->getAllJoints()[n]; - break; - } - } - - if (!joint) - { -#ifdef _XREADER_DEBUG - os::Printer::log("creating joint for animation ", FrameName.c_str()); -#endif - joint=AnimatedMesh->addJoint(0); - joint->Name=FrameName; - } - - joint->PositionKeys.reallocate(joint->PositionKeys.size()+animationDump.PositionKeys.size()); - for (n=0; n<animationDump.PositionKeys.size(); ++n) - { - joint->PositionKeys.push_back(animationDump.PositionKeys[n]); - } - - joint->ScaleKeys.reallocate(joint->ScaleKeys.size()+animationDump.ScaleKeys.size()); - for (n=0; n<animationDump.ScaleKeys.size(); ++n) - { - joint->ScaleKeys.push_back(animationDump.ScaleKeys[n]); - } - - joint->RotationKeys.reallocate(joint->RotationKeys.size()+animationDump.RotationKeys.size()); - for (n=0; n<animationDump.RotationKeys.size(); ++n) - { - joint->RotationKeys.push_back(animationDump.RotationKeys[n]); - } - } - else - os::Printer::log("joint name was never given", ELL_WARNING); - - return true; -} - - -bool CXMeshFileLoader::parseDataObjectAnimationKey(ISkinnedMesh::SJoint *joint) -{ -#ifdef _XREADER_DEBUG - os::Printer::log("CXFileReader: reading animation key"); -#endif - - if (!readHeadOfDataObject()) - { - os::Printer::log("No opening brace in Animation Key found in x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - - // read key type - - const u32 keyType = readInt(); - - if (keyType > 4) - { - os::Printer::log("Unknown key type found in Animation Key in x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - - // read number of keys - const u32 numberOfKeys = readInt(); - - // eat the semicolon after the "0". if there are keys present, readInt() - // does this for us. If there aren't, we need to do it explicitly - if (numberOfKeys == 0) - checkForOneFollowingSemicolons(); - - for (u32 i=0; i<numberOfKeys; ++i) - { - // read time - const f32 time = (f32)readInt(); - - // read keys - switch(keyType) - { - case 0: //rotation - { - //read quaternions - - // read count - if (readInt() != 4) - { - os::Printer::log("Expected 4 numbers in animation key in x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - - f32 W = -readFloat(); - f32 X = -readFloat(); - f32 Y = -readFloat(); - f32 Z = -readFloat(); - - if (!checkForTwoFollowingSemicolons()) - { - os::Printer::log("No finishing semicolon after quaternion animation key in x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - } - - ISkinnedMesh::SRotationKey *key=AnimatedMesh->addRotationKey(joint); - key->frame=time; - key->rotation.set(X,Y,Z,W); - } - break; - case 1: //scale - case 2: //position - { - // read vectors - - // read count - if (readInt() != 3) - { - os::Printer::log("Expected 3 numbers in animation key in x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - - core::vector3df vector; - readVector3(vector); - - if (!checkForTwoFollowingSemicolons()) - { - os::Printer::log("No finishing semicolon after vector animation key in x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - } - - if (keyType==2) - { - ISkinnedMesh::SPositionKey *key=AnimatedMesh->addPositionKey(joint); - key->frame=time; - key->position=vector; - } - else - { - ISkinnedMesh::SScaleKey *key=AnimatedMesh->addScaleKey(joint); - key->frame=time; - key->scale=vector; - } - } - break; - case 3: - case 4: - { - // read matrix - - // read count - if (readInt() != 16) - { - os::Printer::log("Expected 16 numbers in animation key in x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - - // read matrix - core::matrix4 mat(core::matrix4::EM4CONST_NOTHING); - readMatrix(mat); - - //mat=joint->LocalMatrix*mat; - - if (!checkForOneFollowingSemicolons()) - { - os::Printer::log("No finishing semicolon after matrix animation key in x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - } - - //core::vector3df rotation = mat.getRotationDegrees(); - - ISkinnedMesh::SRotationKey *keyR=AnimatedMesh->addRotationKey(joint); - keyR->frame=time; - keyR->rotation= core::quaternion(mat); - - - ISkinnedMesh::SPositionKey *keyP=AnimatedMesh->addPositionKey(joint); - keyP->frame=time; - keyP->position=mat.getTranslation(); - -/* - core::vector3df scale=mat.getScale(); - - if (scale.X==0) - scale.X=1; - if (scale.Y==0) - scale.Y=1; - if (scale.Z==0) - scale.Z=1; - ISkinnedMesh::SScaleKey *keyS=AnimatedMesh->addScaleKey(joint); - keyS->frame=time; - keyS->scale=scale; -*/ - } - break; - } // end switch - } - - if (!checkForOneFollowingSemicolons()) - --P; - - if (!checkForClosingBrace()) - { - os::Printer::log("No closing brace in animation key in x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - - return true; -} - - -bool CXMeshFileLoader::parseDataObjectTextureFilename(core::stringc& texturename) -{ -#ifdef _XREADER_DEBUG - os::Printer::log("CXFileReader: reading texture filename"); -#endif - - if (!readHeadOfDataObject()) - { - os::Printer::log("No opening brace in Texture filename found in x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - - if (!getNextTokenAsString(texturename)) - { - os::Printer::log("Unknown syntax while reading texture filename string in x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - - if (!checkForClosingBrace()) - { - os::Printer::log("No closing brace in Texture filename found in x file", ELL_WARNING); - os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); - return false; - } - - return true; -} - - -bool CXMeshFileLoader::parseUnknownDataObject() -{ - // find opening delimiter - while(true) - { - core::stringc t = getNextToken(); - - if (t.size() == 0) - return false; - - if (t == "{") - break; - } - - u32 counter = 1; - - // parse until closing delimiter - - while(counter) - { - core::stringc t = getNextToken(); - - if (t.size() == 0) - return false; - - if (t == "{") - ++counter; - else - if (t == "}") - --counter; - } - - return true; -} - - -//! checks for closing curly brace, returns false if not there -bool CXMeshFileLoader::checkForClosingBrace() -{ - return (getNextToken() == "}"); -} - - -//! checks for one following semicolon, returns false if not there -bool CXMeshFileLoader::checkForOneFollowingSemicolons() -{ - if (BinaryFormat) - return true; - - if (getNextToken() == ";") - return true; - else - { - --P; - return false; - } -} - - -//! checks for two following semicolons, returns false if they are not there -bool CXMeshFileLoader::checkForTwoFollowingSemicolons() -{ - if (BinaryFormat) - return true; - - for (u32 k=0; k<2; ++k) - { - if (getNextToken() != ";") - { - --P; - return false; - } - } - - return true; -} - - -//! reads header of dataobject including the opening brace. -//! returns false if error happened, and writes name of object -//! if there is one -bool CXMeshFileLoader::readHeadOfDataObject(core::stringc* outname) -{ - core::stringc nameOrBrace = getNextToken(); - if (nameOrBrace != "{") - { - if (outname) - (*outname) = nameOrBrace; - - if (getNextToken() != "{") - return false; - } - - return true; -} - - -//! returns next parseable token. Returns empty string if no token there -core::stringc CXMeshFileLoader::getNextToken() -{ - core::stringc s; - - // process binary-formatted file - if (BinaryFormat) - { - // in binary mode it will only return NAME and STRING token - // and (correctly) skip over other tokens. - - s16 tok = readBinWord(); - u32 len; - - // standalone tokens - switch (tok) { - case 1: - // name token - len = readBinDWord(); - s = core::stringc(P, len); - P += len; - return s; - case 2: - // string token - len = readBinDWord(); - s = core::stringc(P, len); - P += (len + 2); - return s; - case 3: - // integer token - P += 4; - return "<integer>"; - case 5: - // GUID token - P += 16; - return "<guid>"; - case 6: - len = readBinDWord(); - P += (len * 4); - return "<int_list>"; - case 7: - len = readBinDWord(); - P += (len * FloatSize); - return "<flt_list>"; - case 0x0a: - return "{"; - case 0x0b: - return "}"; - case 0x0c: - return "("; - case 0x0d: - return ")"; - case 0x0e: - return "["; - case 0x0f: - return "]"; - case 0x10: - return "<"; - case 0x11: - return ">"; - case 0x12: - return "."; - case 0x13: - return ","; - case 0x14: - return ";"; - case 0x1f: - return "template"; - case 0x28: - return "WORD"; - case 0x29: - return "DWORD"; - case 0x2a: - return "FLOAT"; - case 0x2b: - return "DOUBLE"; - case 0x2c: - return "CHAR"; - case 0x2d: - return "UCHAR"; - case 0x2e: - return "SWORD"; - case 0x2f: - return "SDWORD"; - case 0x30: - return "void"; - case 0x31: - return "string"; - case 0x32: - return "unicode"; - case 0x33: - return "cstring"; - case 0x34: - return "array"; - } - } - // process text-formatted file - else - { - findNextNoneWhiteSpace(); - - if (P >= End) - return s; - - while((P < End) && !core::isspace(P[0])) - { - // either keep token delimiters when already holding a token, or return if first valid char - if (P[0]==';' || P[0]=='}' || P[0]=='{' || P[0]==',') - { - if (!s.size()) - { - s.append(P[0]); - ++P; - } - break; // stop for delimiter - } - s.append(P[0]); - ++P; - } - } - return s; -} - - -//! places pointer to next begin of a token, which must be a number, -// and ignores comments -void CXMeshFileLoader::findNextNoneWhiteSpaceNumber() -{ - if (BinaryFormat) - return; - - while((P < End) && (P[0] != '-') && (P[0] != '.') && - !( core::isdigit(P[0]))) - { - // check if this is a comment - if ((P[0] == '/' && P[1] == '/') || P[0] == '#') - readUntilEndOfLine(); - else - ++P; - } -} - - -// places pointer to next begin of a token, and ignores comments -void CXMeshFileLoader::findNextNoneWhiteSpace() -{ - if (BinaryFormat) - return; - - while(true) - { - while((P < End) && core::isspace(P[0])) - { - if (*P=='\n') - ++Line; - ++P; - } - - if (P >= End) - return; - - // check if this is a comment - if ((P[0] == '/' && P[1] == '/') || - P[0] == '#') - readUntilEndOfLine(); - else - break; - } -} - - -//! reads a x file style string -bool CXMeshFileLoader::getNextTokenAsString(core::stringc& out) -{ - if (BinaryFormat) - { - out=getNextToken(); - return true; - } - findNextNoneWhiteSpace(); - - if (P >= End) - return false; - - if (P[0] != '"') - return false; - ++P; - - while(P < End && P[0]!='"') - { - out.append(P[0]); - ++P; - } - - if ( P[1] != ';' || P[0] != '"') - return false; - P+=2; - - return true; -} - - -void CXMeshFileLoader::readUntilEndOfLine() -{ - if (BinaryFormat) - return; - - while(P < End) - { - if (P[0] == '\n' || P[0] == '\r') - { - ++P; - ++Line; - return; - } - - ++P; - } -} - - -u16 CXMeshFileLoader::readBinWord() -{ -#ifdef __BIG_ENDIAN__ - const u16 tmp = os::Byteswap::byteswap(*(u16 *)P); -#else - const u16 tmp = *(u16 *)P; -#endif - P += 2; - return tmp; -} - - -u32 CXMeshFileLoader::readBinDWord() -{ -#ifdef __BIG_ENDIAN__ - const u32 tmp = os::Byteswap::byteswap(*(u32 *)P); -#else - const u32 tmp = *(u32 *)P; -#endif - P += 4; - return tmp; -} - - -u32 CXMeshFileLoader::readInt() -{ - if (BinaryFormat) - { - if (!BinaryNumCount) - { - const u16 tmp = readBinWord(); // 0x06 or 0x03 - if (tmp == 0x06) - BinaryNumCount = readBinDWord(); - else - BinaryNumCount = 1; // single int - } - --BinaryNumCount; - return readBinDWord(); - } - else - { - findNextNoneWhiteSpaceNumber(); - return core::strtol10(P, &P); - } -} - - -f32 CXMeshFileLoader::readFloat() -{ - if (BinaryFormat) - { - if (!BinaryNumCount) - { - const u16 tmp = readBinWord(); // 0x07 or 0x42 - if (tmp == 0x07) - BinaryNumCount = readBinDWord(); - else - BinaryNumCount = 1; // single int - } - --BinaryNumCount; - if (FloatSize == 8) - { -#ifdef __BIG_ENDIAN__ - c8 ctmp[8]; - *((f32*)(ctmp+4)) = os::Byteswap::byteswap(*(f32 *)P); - *((f32*)(ctmp)) = os::Byteswap::byteswap(*(f32 *)P+4); - const f32 tmp = (f32)(*(f64 *)ctmp); -#else - const f32 tmp = (f32)(*(f64 *)P); -#endif - P += 8; - return tmp; - } - else - { -#ifdef __BIG_ENDIAN__ - const f32 tmp = os::Byteswap::byteswap(*(f32 *)P); -#else - const f32 tmp = *(f32 *)P; -#endif - P += 4; - return tmp; - } - } - findNextNoneWhiteSpaceNumber(); - f32 ftmp; - P = core::fast_atof_move(P, ftmp); - return ftmp; -} - - -// read 2-dimensional vector. Stops at semicolon after second value for text file format -bool CXMeshFileLoader::readVector2(core::vector2df& vec) -{ - vec.X = readFloat(); - vec.Y = readFloat(); - return true; -} - - -// read 3-dimensional vector. Stops at semicolon after third value for text file format -bool CXMeshFileLoader::readVector3(core::vector3df& vec) -{ - vec.X = readFloat(); - vec.Y = readFloat(); - vec.Z = readFloat(); - return true; -} - - -// read color without alpha value. Stops after second semicolon after blue value -bool CXMeshFileLoader::readRGB(video::SColor& color) -{ - video::SColorf tmpColor; - tmpColor.r = readFloat(); - tmpColor.g = readFloat(); - tmpColor.b = readFloat(); - color = tmpColor.toSColor(); - return checkForOneFollowingSemicolons(); -} - - -// read color with alpha value. Stops after second semicolon after blue value -bool CXMeshFileLoader::readRGBA(video::SColor& color) -{ - video::SColorf tmpColor; - tmpColor.r = readFloat(); - tmpColor.g = readFloat(); - tmpColor.b = readFloat(); - tmpColor.a = readFloat(); - color = tmpColor.toSColor(); - return checkForOneFollowingSemicolons(); -} - - -// read matrix from list of floats -bool CXMeshFileLoader::readMatrix(core::matrix4& mat) -{ - for (u32 i=0; i<16; ++i) - mat[i] = readFloat(); - return checkForOneFollowingSemicolons(); -} - - -} // end namespace scene -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_X_LOADER_ - diff --git a/irrlicht-1.6/source/Irrlicht/CXMeshFileLoader.h b/irrlicht-1.6/source/Irrlicht/CXMeshFileLoader.h deleted file mode 100644 index 59ec4dce8..000000000 --- a/irrlicht-1.6/source/Irrlicht/CXMeshFileLoader.h +++ /dev/null @@ -1,198 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_X_MESH_FILE_LOADER_H_INCLUDED__ -#define __C_X_MESH_FILE_LOADER_H_INCLUDED__ - -#include "IMeshLoader.h" -#include "irrString.h" -#include "CSkinnedMesh.h" - - -namespace irr -{ -namespace io -{ - class IFileSystem; - class IReadFile; -} // end namespace io -namespace scene -{ -class IMeshManipulator; - -//! Meshloader capable of loading x meshes. -class CXMeshFileLoader : public IMeshLoader -{ -public: - - //! Constructor - CXMeshFileLoader(scene::ISceneManager* smgr, io::IFileSystem* fs); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".cob") - virtual bool isALoadableFileExtension(const io::path& 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); - - struct SXTemplateMaterial - { - core::stringc Name; // template name from Xfile - video::SMaterial Material; // material - }; - - struct SXMesh - { - SXMesh() : MaxSkinWeightsPerVertex(0), MaxSkinWeightsPerFace(0), BoneCount(0),AttachedJointID(-1),HasSkinning(false), HasVertexColors(false) {} - // this mesh contains triangulated texture data. - // because in an .x file, faces can be made of more than 3 - // vertices, the indices data structure is triangulated during the - // loading process. The IndexCountPerFace array is filled during - // this triangulation process and stores how much indices belong to - // every face. This data structure can be ignored, because all data - // in this structure is triangulated. - - core::stringc Name; - - u32 MaxSkinWeightsPerVertex; - u32 MaxSkinWeightsPerFace; - u32 BoneCount; - - core::array<u16> IndexCountPerFace; // default 3, but could be more - - core::array<scene::SSkinMeshBuffer*> Buffers; - - core::array<video::S3DVertex> Vertices; - core::array<core::vector2df> TCoords2; - - core::array<u32> Indices; - - core::array<u32> FaceMaterialIndices; // index of material for each face - - core::array<video::SMaterial> Materials; // material array - - core::array<u32> WeightJoint; - core::array<u32> WeightNum; - - s32 AttachedJointID; - - bool HasSkinning; - bool HasVertexColors; - }; - -private: - - bool load(io::IReadFile* file); - - bool readFileIntoMemory(io::IReadFile* file); - - bool parseFile(); - - bool parseDataObject(); - - bool parseDataObjectTemplate(); - - bool parseDataObjectFrame(CSkinnedMesh::SJoint *parent); - - bool parseDataObjectTransformationMatrix(core::matrix4 &mat); - - bool parseDataObjectMesh(SXMesh &mesh); - - bool parseDataObjectSkinWeights(SXMesh &mesh); - - bool parseDataObjectSkinMeshHeader(SXMesh &mesh); - - bool parseDataObjectMeshNormals(SXMesh &mesh); - - bool parseDataObjectMeshTextureCoords(SXMesh &mesh); - - bool parseDataObjectMeshVertexColors(SXMesh &mesh); - - bool parseDataObjectMeshMaterialList(SXMesh &mesh); - - bool parseDataObjectMaterial(video::SMaterial& material); - - bool parseDataObjectAnimationSet(); - - bool parseDataObjectAnimation(); - - bool parseDataObjectAnimationKey(ISkinnedMesh::SJoint *joint); - - bool parseDataObjectTextureFilename(core::stringc& texturename); - - bool parseUnknownDataObject(); - - //! places pointer to next begin of a token, and ignores comments - void findNextNoneWhiteSpace(); - - //! places pointer to next begin of a token, which must be a number, - // and ignores comments - void findNextNoneWhiteSpaceNumber(); - - //! returns next parseable token. Returns empty string if no token there - core::stringc getNextToken(); - - //! reads header of dataobject including the opening brace. - //! returns false if error happened, and writes name of object - //! if there is one - bool readHeadOfDataObject(core::stringc* outname=0); - - //! checks for closing curly brace, returns false if not there - bool checkForClosingBrace(); - - //! checks for one following semicolons, returns false if not there - bool checkForOneFollowingSemicolons(); - - //! checks for two following semicolons, returns false if they are not there - bool checkForTwoFollowingSemicolons(); - - //! reads a x file style string - bool getNextTokenAsString(core::stringc& out); - - void readUntilEndOfLine(); - - u16 readBinWord(); - u32 readBinDWord(); - u32 readInt(); - f32 readFloat(); - bool readVector2(core::vector2df& vec); - bool readVector3(core::vector3df& vec); - bool readMatrix(core::matrix4& mat); - bool readRGB(video::SColor& color); - bool readRGBA(video::SColor& color); - - ISceneManager* SceneManager; - io::IFileSystem* FileSystem; - - core::array<CSkinnedMesh::SJoint*> *AllJoints; - - CSkinnedMesh* AnimatedMesh; - - c8* Buffer; - const c8* P; - c8* End; - // counter for number arrays in binary format - u32 BinaryNumCount; - u32 Line; - io::path FilePath; - - CSkinnedMesh::SJoint *CurFrame; - - core::array<SXMesh*> Meshes; - - core::array<SXTemplateMaterial> TemplateMaterials; - - u32 MajorVersion; - u32 MinorVersion; - bool BinaryFormat; - c8 FloatSize; -}; - -} // end namespace scene -} // end namespace irr - -#endif diff --git a/irrlicht-1.6/source/Irrlicht/CZBuffer.cpp b/irrlicht-1.6/source/Irrlicht/CZBuffer.cpp deleted file mode 100644 index 53bf79bfb..000000000 --- a/irrlicht-1.6/source/Irrlicht/CZBuffer.cpp +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright (C) 2002-2009 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" -#include "CZBuffer.h" -#include "irrString.h" - -#ifdef _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - - -//! constructor -CZBuffer::CZBuffer(const core::dimension2d<u32>& size) -: Buffer(0), BufferEnd(0), Size(0,0), TotalSize(0) -{ - #ifdef _DEBUG - setDebugName("CZBuffer"); - #endif - - setSize(size); -} - - - -//! destructor -CZBuffer::~CZBuffer() -{ - delete [] Buffer; -} - - - -//! clears the zbuffer -void CZBuffer::clear() -{ - memset(Buffer, 0, (BufferEnd-Buffer)*sizeof(TZBufferType)); -} - - - -//! sets the new size of the zbuffer -void CZBuffer::setSize(const core::dimension2d<u32>& size) -{ - if (size == Size) - return; - - Size = size; - - delete [] Buffer; - - TotalSize = size.Width * size.Height; - Buffer = new TZBufferType[TotalSize]; - BufferEnd = Buffer + TotalSize; -} - - - -//! returns the size of the zbuffer -const core::dimension2d<u32>& CZBuffer::getSize() const -{ - return Size; -} - - - -//! locks the zbuffer -TZBufferType* CZBuffer::lock() -{ - return Buffer; -} - - - -//! unlocks the zbuffer -void CZBuffer::unlock() -{ -} - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_SOFTWARE_ - -namespace irr -{ -namespace video -{ - -//! creates a ZBuffer -IZBuffer* createZBuffer(const core::dimension2d<u32>& size) -{ - #ifdef _IRR_COMPILE_WITH_SOFTWARE_ - return new CZBuffer(size); - #else - return 0; - #endif // _IRR_COMPILE_WITH_SOFTWARE_ -} - - -} // end namespace video -} // end namespace irr - - - diff --git a/irrlicht-1.6/source/Irrlicht/CZBuffer.h b/irrlicht-1.6/source/Irrlicht/CZBuffer.h deleted file mode 100644 index 72a7971a1..000000000 --- a/irrlicht-1.6/source/Irrlicht/CZBuffer.h +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_Z_BUFFER_H_INCLUDED__ -#define __C_Z_BUFFER_H_INCLUDED__ - -#include "IZBuffer.h" - -namespace irr -{ -namespace video -{ - - class CZBuffer : public IZBuffer - { - public: - - //! constructor - CZBuffer(const core::dimension2d<u32>& size); - - //! destructor - virtual ~CZBuffer(); - - //! clears the zbuffer - virtual void clear(); - - //! sets the new size of the zbuffer - virtual void setSize(const core::dimension2d<u32>& size); - - //! returns the size of the zbuffer - virtual const core::dimension2d<u32>& getSize() const; - - //! locks the zbuffer - virtual TZBufferType* lock(); - - //! unlocks the zbuffer - virtual void unlock(); - - private: - - TZBufferType* Buffer; - TZBufferType* BufferEnd; - core::dimension2d<u32> Size; - s32 TotalSize; - }; - -} // end namespace video -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/CZipReader.cpp b/irrlicht-1.6/source/Irrlicht/CZipReader.cpp deleted file mode 100644 index 882c64175..000000000 --- a/irrlicht-1.6/source/Irrlicht/CZipReader.cpp +++ /dev/null @@ -1,536 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CZipReader.h" - -#ifdef __IRR_COMPILE_WITH_ZIP_ARCHIVE_LOADER_ - -#include "CFileList.h" -#include "CReadFile.h" -#include "os.h" -#include "coreutil.h" - -#include "IrrCompileConfig.h" -#ifdef _IRR_COMPILE_WITH_ZLIB_ - #ifndef _IRR_USE_NON_SYSTEM_ZLIB_ - #include <zlib.h> // use system lib - #else // _IRR_USE_NON_SYSTEM_ZLIB_ - #include "zlib/zlib.h" - #endif // _IRR_USE_NON_SYSTEM_ZLIB_ -#endif // _IRR_COMPILE_WITH_ZLIB_ - -namespace irr -{ -namespace io -{ - - -// ----------------------------------------------------------------------------- -// zip loader -// ----------------------------------------------------------------------------- - -//! Constructor -CArchiveLoaderZIP::CArchiveLoaderZIP(io::IFileSystem* fs) -: FileSystem(fs) -{ - #ifdef _DEBUG - setDebugName("CArchiveLoaderZIP"); - #endif -} - -//! returns true if the file maybe is able to be loaded by this class -bool CArchiveLoaderZIP::isALoadableFileFormat(const io::path& filename) const -{ - return core::hasFileExtension(filename, "zip", "pk3") || - core::hasFileExtension(filename, "gz", "tgz"); -} - -//! Check to see if the loader can create archives of this type. -bool CArchiveLoaderZIP::isALoadableFileFormat(E_FILE_ARCHIVE_TYPE fileType) const -{ - return (fileType == EFAT_ZIP || fileType == EFAT_GZIP); -} - - -//! Creates an archive from the filename -/** \param file File handle to check. -\return Pointer to newly created archive, or 0 upon error. */ -IFileArchive* CArchiveLoaderZIP::createArchive(const io::path& filename, bool ignoreCase, bool ignorePaths) const -{ - IFileArchive *archive = 0; - io::IReadFile* file = FileSystem->createAndOpenFile(filename); - - if (file) - { - archive = createArchive(file, ignoreCase, ignorePaths); - file->drop(); - } - - return archive; -} - -//! creates/loads an archive from the file. -//! \return Pointer to the created archive. Returns 0 if loading failed. -IFileArchive* CArchiveLoaderZIP::createArchive(io::IReadFile* file, bool ignoreCase, bool ignorePaths) const -{ - IFileArchive *archive = 0; - if (file) - { - file->seek(0); - - u16 sig; - file->read(&sig, 2); - -#ifdef __BIG_ENDIAN__ - os::Byteswap::byteswap(sig); -#endif - - file->seek(0); - - bool isGZip = (sig == 0x8b1f); - - archive = new CZipReader(file, ignoreCase, ignorePaths, isGZip); - } - return archive; -} - -//! Check if the file might be loaded by this class -/** Check might look into the file. -\param file File handle to check. -\return True if file seems to be loadable. */ -bool CArchiveLoaderZIP::isALoadableFileFormat(io::IReadFile* file) const -{ - SZIPFileHeader header; - - file->read( &header.Sig, 4 ); -#ifdef __BIG_ENDIAN__ - os::Byteswap::byteswap(header.Sig); -#endif - - return header.Sig == 0x04034b50 || // ZIP - *((u16*)(&header.Sig)) == 0x8b1f; // gzip -} - -// ----------------------------------------------------------------------------- -// zip archive -// ----------------------------------------------------------------------------- - -CZipReader::CZipReader(IReadFile* file, bool ignoreCase, bool ignorePaths, bool isGZip) - : CFileList(file ? file->getFileName() : "", ignoreCase, ignorePaths), File(file), IsGZip(isGZip) -{ - #ifdef _DEBUG - setDebugName("CZipReader"); - #endif - - if (File) - { - File->grab(); - - // load file entries - if (IsGZip) - while (scanGZipHeader()) { } - else - while (scanZipHeader()) { } - - sort(); - } -} - -CZipReader::~CZipReader() -{ - if (File) - File->drop(); -} - - -//! get the archive type -E_FILE_ARCHIVE_TYPE CZipReader::getType() const -{ - return IsGZip ? EFAT_GZIP : EFAT_ZIP; -} - -const IFileList* CZipReader::getFileList() const -{ - return this; -} - -#if 0 -#include <windows.h> - -const c8 *sigName( u32 sig ) -{ - switch ( sig ) - { - case 0x04034b50: return "PK0304"; - case 0x02014b50: return "PK0102"; - case 0x06054b50: return "PK0506"; - } - return "unknown"; -} - -bool CZipReader::scanLocalHeader2() -{ - c8 buf [ 128 ]; - c8 *c; - - File->read( &temp.header.Sig, 4 ); - -#ifdef __BIG_ENDIAN__ - os::Byteswap::byteswap(temp.header.Sig); -#endif - - sprintf ( buf, "sig: %08x,%s,", temp.header.Sig, sigName ( temp.header.Sig ) ); - OutputDebugStringA ( buf ); - - // Local File Header - if ( temp.header.Sig == 0x04034b50 ) - { - File->read( &temp.header.VersionToExtract, sizeof( temp.header ) - 4 ); - - temp.zipFileName.reserve( temp.header.FilenameLength+2); - c = (c8*) temp.zipFileName.c_str(); - File->read( c, temp.header.FilenameLength); - c [ temp.header.FilenameLength ] = 0; - temp.zipFileName.verify(); - - sprintf ( buf, "%d,'%s'\n", temp.header.CompressionMethod, c ); - OutputDebugStringA ( buf ); - - if (temp.header.ExtraFieldLength) - { - File->seek( temp.header.ExtraFieldLength, true); - } - - if (temp.header.GeneralBitFlag & ZIP_INFO_IN_DATA_DESCRIPTOR) - { - // read data descriptor - File->seek(sizeof(SZIPFileDataDescriptor), true ); - } - - // compressed data - temp.fileDataPosition = File->getPos(); - File->seek( temp.header.DataDescriptor.CompressedSize, true); - FileList.push_back( temp ); - return true; - } - - // Central directory structure - if ( temp.header.Sig == 0x04034b50 ) - { - //SZIPFileCentralDirFileHeader h; - //File->read( &h, sizeof( h ) - 4 ); - return true; - } - - // End of central dir - if ( temp.header.Sig == 0x06054b50 ) - { - return true; - } - - // eof - if ( temp.header.Sig == 0x02014b50 ) - { - return false; - } - - return false; -} - -#endif - -//! scans for a local header, returns false if there is no more local file header. -//! The gzip file format seems to think that there can be multiple files in a gzip file -//! but none -bool CZipReader::scanGZipHeader() -{ - SZipFileEntry entry; - entry.Offset = 0; - memset(&entry.header, 0, sizeof(SZIPFileHeader)); - - // read header - SGZIPMemberHeader header; - if (File->read(&header, sizeof(SGZIPMemberHeader)) == sizeof(SGZIPMemberHeader)) - { - -#ifdef __BIG_ENDIAN__ - os::Byteswap::byteswap(header.sig); - os::Byteswap::byteswap(header.time); -#endif - - // check header value - if (header.sig != 0x8b1f) - return false; - - // now get the file info - if (header.flags & EGZF_EXTRA_FIELDS) - { - // read lenth of extra data - u16 dataLen; - - File->read(&dataLen, 2); - -#ifdef __BIG_ENDIAN__ - os::Byteswap::byteswap(dataLen); -#endif - - // skip it - File->seek(dataLen, true); - } - - io::path ZipFileName = ""; - - if (header.flags & EGZF_FILE_NAME) - { - c8 c; - File->read(&c, 1); - while (c) - { - ZipFileName.append(c); - File->read(&c, 1); - } - } - else - { - // no file name? - ZipFileName = Path; - core::deletePathFromFilename(ZipFileName); - - // rename tgz to tar or remove gz extension - if (core::hasFileExtension(ZipFileName, "tgz")) - { - ZipFileName[ ZipFileName.size() - 2] = 'a'; - ZipFileName[ ZipFileName.size() - 1] = 'r'; - } - else if (core::hasFileExtension(ZipFileName, "gz")) - { - ZipFileName[ ZipFileName.size() - 3] = 0; - ZipFileName.validate(); - } - } - - if (header.flags & EGZF_COMMENT) - { - c8 c='a'; - while (c) - File->read(&c, 1); - } - - if (header.flags & EGZF_CRC16) - File->seek(2, true); - - // we are now at the start of the data blocks - entry.Offset = File->getPos(); - - entry.header.FilenameLength = ZipFileName.size(); - - entry.header.CompressionMethod = header.compressionMethod; - entry.header.DataDescriptor.CompressedSize = (File->getSize() - 8) - File->getPos(); - - // seek to file end - File->seek(entry.header.DataDescriptor.CompressedSize, true); - - // read CRC - File->read(&entry.header.DataDescriptor.CRC32, 4); - // read uncompressed size - File->read(&entry.header.DataDescriptor.UncompressedSize, 4); - -#ifdef __BIG_ENDIAN__ - os::Byteswap::byteswap(entry.header.DataDescriptor.CRC32); - os::Byteswap::byteswap(entry.header.DataDescriptor.UncompressedSize); -#endif - - //! now we've filled all the fields, this is just a standard deflate block - addItem(ZipFileName, entry.header.DataDescriptor.UncompressedSize, false, 0); - FileInfo.push_back(entry); - } - - // there's only one block of data in a gzip file - return false; -} - -//! scans for a local header, returns false if there is no more local file header. -bool CZipReader::scanZipHeader() -{ - io::path ZipFileName = ""; - SZipFileEntry entry; - entry.Offset = 0; - memset(&entry.header, 0, sizeof(SZIPFileHeader)); - - File->read(&entry.header, sizeof(SZIPFileHeader)); - -#ifdef __BIG_ENDIAN__ - entry.header.Sig = os::Byteswap::byteswap(entry.header.Sig); - entry.header.VersionToExtract = os::Byteswap::byteswap(entry.header.VersionToExtract); - entry.header.GeneralBitFlag = os::Byteswap::byteswap(entry.header.GeneralBitFlag); - entry.header.CompressionMethod = os::Byteswap::byteswap(entry.header.CompressionMethod); - entry.header.LastModFileTime = os::Byteswap::byteswap(entry.header.LastModFileTime); - entry.header.LastModFileDate = os::Byteswap::byteswap(entry.header.LastModFileDate); - entry.header.DataDescriptor.CRC32 = os::Byteswap::byteswap(entry.header.DataDescriptor.CRC32); - entry.header.DataDescriptor.CompressedSize = os::Byteswap::byteswap(entry.header.DataDescriptor.CompressedSize); - entry.header.DataDescriptor.UncompressedSize = os::Byteswap::byteswap(entry.header.DataDescriptor.UncompressedSize); - entry.header.FilenameLength = os::Byteswap::byteswap(entry.header.FilenameLength); - entry.header.ExtraFieldLength = os::Byteswap::byteswap(entry.header.ExtraFieldLength); -#endif - - if (entry.header.Sig != 0x04034b50) - return false; // local file headers end here. - - // read filename - { - c8 *tmp = new c8 [ entry.header.FilenameLength + 2 ]; - File->read(tmp, entry.header.FilenameLength); - tmp[entry.header.FilenameLength] = 0; - ZipFileName = tmp; - delete [] tmp; - } - - // move forward length of extra field. - - if (entry.header.ExtraFieldLength) - File->seek(entry.header.ExtraFieldLength, true); - - // if bit 3 was set, read DataDescriptor, following after the compressed data - if (entry.header.GeneralBitFlag & ZIP_INFO_IN_DATA_DESCRIPTOR) - { - // read data descriptor - File->read(&entry.header.DataDescriptor, sizeof(entry.header.DataDescriptor)); -#ifdef __BIG_ENDIAN__ - entry.header.DataDescriptor.CRC32 = os::Byteswap::byteswap(entry.header.DataDescriptor.CRC32); - entry.header.DataDescriptor.CompressedSize = os::Byteswap::byteswap(entry.header.DataDescriptor.CompressedSize); - entry.header.DataDescriptor.UncompressedSize = os::Byteswap::byteswap(entry.header.DataDescriptor.UncompressedSize); -#endif - } - - // store position in file - entry.Offset = File->getPos(); - // move forward length of data - File->seek(entry.header.DataDescriptor.CompressedSize, true); - - #ifdef _DEBUG - //os::Debuginfo::print("added file from archive", ZipFileName.c_str()); - #endif - - addItem(ZipFileName, entry.header.DataDescriptor.UncompressedSize, false, FileInfo.size()); - FileInfo.push_back(entry); - - return true; -} - - -//! opens a file by file name -IReadFile* CZipReader::createAndOpenFile(const io::path& filename) -{ - s32 index = findFile(filename, false); - - if (index != -1) - return createAndOpenFile(index); - - return 0; -} - - -//! opens a file by index -IReadFile* CZipReader::createAndOpenFile(u32 index) -{ - - //0 - The file is stored (no compression) - //1 - The file is Shrunk - //2 - The file is Reduced with compression factor 1 - //3 - The file is Reduced with compression factor 2 - //4 - The file is Reduced with compression factor 3 - //5 - The file is Reduced with compression factor 4 - //6 - The file is Imploded - //7 - Reserved for Tokenizing compression algorithm - //8 - The file is Deflated - //9 - Reserved for enhanced Deflating - //10 - PKWARE Date Compression Library Imploding - - const SZipFileEntry &e = FileInfo[Files[index].ID]; - wchar_t buf[64]; - switch(e.header.CompressionMethod) - { - case 0: // no compression - { - return createLimitReadFile(Files[index].FullName, File, e.Offset, e.header.DataDescriptor.CompressedSize); - } - case 8: - { - #ifdef _IRR_COMPILE_WITH_ZLIB_ - - const u32 uncompressedSize = e.header.DataDescriptor.UncompressedSize; - const u32 compressedSize = e.header.DataDescriptor.CompressedSize; - - void* pBuf = new c8[ uncompressedSize ]; - if (!pBuf) - { - swprintf ( buf, 64, L"Not enough memory for decompressing %s", Files[index].FullName.c_str() ); - os::Printer::log( buf, ELL_ERROR); - return 0; - } - - c8 *pcData = new c8[ compressedSize ]; - if (!pcData) - { - swprintf ( buf, 64, L"Not enough memory for decompressing %s", Files[index].FullName.c_str() ); - os::Printer::log( buf, ELL_ERROR); - delete [] (c8*)pBuf; - return 0; - } - - //memset(pcData, 0, compressedSize ); - File->seek(e.Offset); - File->read(pcData, compressedSize ); - - // Setup the inflate stream. - z_stream stream; - s32 err; - - stream.next_in = (Bytef*)pcData; - stream.avail_in = (uInt)compressedSize; - stream.next_out = (Bytef*)pBuf; - stream.avail_out = uncompressedSize; - stream.zalloc = (alloc_func)0; - stream.zfree = (free_func)0; - - // Perform inflation. wbits < 0 indicates no zlib header inside the data. - err = inflateInit2(&stream, -MAX_WBITS); - if (err == Z_OK) - { - err = inflate(&stream, Z_FINISH); - inflateEnd(&stream); - if (err == Z_STREAM_END) - err = Z_OK; - err = Z_OK; - inflateEnd(&stream); - } - - delete[] pcData; - - if (err != Z_OK) - { - swprintf ( buf, 64, L"Error decompressing %s", Files[index].FullName.c_str() ); - os::Printer::log( buf, ELL_ERROR); - delete [] (c8*)pBuf; - return 0; - } - else - return io::createMemoryReadFile(pBuf, uncompressedSize, Files[index].FullName, true); - - #else - return 0; // zlib not compiled, we cannot decompress the data. - #endif - } - default: - swprintf ( buf, 64, L"file has unsupported compression method. %s", Files[index].FullName.c_str() ); - os::Printer::log( buf, ELL_ERROR); - return 0; - }; - -} - -} // end namespace io -} // end namespace irr - -#endif // __IRR_COMPILE_WITH_ZIP_ARCHIVE_LOADER_ diff --git a/irrlicht-1.6/source/Irrlicht/CZipReader.h b/irrlicht-1.6/source/Irrlicht/CZipReader.h deleted file mode 100644 index 85ab459d5..000000000 --- a/irrlicht-1.6/source/Irrlicht/CZipReader.h +++ /dev/null @@ -1,219 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_ZIP_READER_H_INCLUDED__ -#define __C_ZIP_READER_H_INCLUDED__ - -#include "IrrCompileConfig.h" - -#ifdef __IRR_COMPILE_WITH_ZIP_ARCHIVE_LOADER_ - -#include "IReadFile.h" -#include "irrArray.h" -#include "irrString.h" -#include "IFileSystem.h" -#include "CFileList.h" - -namespace irr -{ -namespace io -{ - // set if the file is encrypted - const s16 ZIP_FILE_ENCRYPTED = 0x0001; - // the fields crc-32, compressed size and uncompressed size are set to - // zero in the local header - const s16 ZIP_INFO_IN_DATA_DESCRIPTOR = 0x0008; - -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) -# pragma pack( push, packing ) -# pragma pack( 1 ) -# define PACK_STRUCT -#elif defined( __GNUC__ ) -# define PACK_STRUCT __attribute__((packed)) -#else -# error compiler not supported -#endif - - - struct SZIPFileDataDescriptor - { - u32 CRC32; - u32 CompressedSize; - u32 UncompressedSize; - } PACK_STRUCT; - - struct SZIPFileHeader - { - u32 Sig; // 'PK0304' little endian (0x04034b50) - s16 VersionToExtract; - s16 GeneralBitFlag; - s16 CompressionMethod; - s16 LastModFileTime; - s16 LastModFileDate; - SZIPFileDataDescriptor DataDescriptor; - s16 FilenameLength; - s16 ExtraFieldLength; - // filename (variable size) - // extra field (variable size ) - } PACK_STRUCT; - - struct SZIPFileCentralDirFileHeader - { - u32 central_file_header_signature; // 'PK0102' (0x02014b50) - u16 version_made_by; - u16 version_needed_to_extract; - u16 general_purpose_bit_flag; - u16 compression_method; - u16 last_mod_file_time; - u16 last_mod_file_date; - u32 crc_32; - u32 compressed_size; - u32 uncompressed_size; - u16 filename_length; - u16 extra_field_length; - u16 file_comment_length; - u16 disk_number_start; - u16 internal_file_attributes; - u32 external_file_attributes; - u32 relative_offset_of_local_header; - - // filename (variable size) - // extra field (variable size) - // file comment (variable size) - - } PACK_STRUCT; - - struct SZIPFileCentralDirEnd - { - u32 sig; // 'PK0506' end_of central dir signature // (0x06054b50) - u16 numberDisk; // number of this disk - u16 numberStart; // number of the disk with the start of the central directory - u16 totalDisk; // total number of entries in the central dir on this disk - u16 totalEntries; // total number of entries in the central dir - u32 size; // size of the central directory - u32 offset; // offset of start of centraldirectory with respect to the starting disk number - u16 comment_length; // zipfile comment length - // zipfile comment (variable size) - } PACK_STRUCT; - - enum E_GZIP_FLAGS - { - EGZF_TEXT_DAT = 1, - EGZF_CRC16 = 2, - EGZF_EXTRA_FIELDS = 4, - EGZF_FILE_NAME = 8, - EGZF_COMMENT = 16 - }; - - struct SGZIPMemberHeader - { - u16 sig; // 0x8b1f - u8 compressionMethod; // 8 = deflate - u8 flags; - u32 time; - u8 extraFlags; // slow compress = 2, fast compress = 4 - u8 operatingSystem; - } PACK_STRUCT; - -// Default alignment -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) -# pragma pack( pop, packing ) -#endif - -#undef PACK_STRUCT - - //! Contains extended info about zip files in the archive - struct SZipFileEntry - { - //! Position of data in the archive file - s32 Offset; - - //! The header for this file containing compression info etc - SZIPFileHeader header; - }; - - //! Archiveloader capable of loading ZIP Archives - class CArchiveLoaderZIP : public IArchiveLoader - { - public: - - //! Constructor - CArchiveLoaderZIP(io::IFileSystem* fs); - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (e.g. ".zip") - virtual bool isALoadableFileFormat(const io::path& filename) const; - - //! Check if the file might be loaded by this class - /** Check might look into the file. - \param file File handle to check. - \return True if file seems to be loadable. */ - virtual bool isALoadableFileFormat(io::IReadFile* file) const; - - //! Check to see if the loader can create archives of this type. - /** Check based on the archive type. - \param fileType The archive type to check. - \return True if the archile loader supports this type, false if not */ - virtual bool isALoadableFileFormat(E_FILE_ARCHIVE_TYPE fileType) const; - - //! Creates an archive from the filename - /** \param file File handle to check. - \return Pointer to newly created archive, or 0 upon error. */ - virtual IFileArchive* createArchive(const io::path& filename, bool ignoreCase, bool ignorePaths) const; - - //! creates/loads an archive from the file. - //! \return Pointer to the created archive. Returns 0 if loading failed. - virtual io::IFileArchive* createArchive(io::IReadFile* file, bool ignoreCase, bool ignorePaths) const; - - private: - io::IFileSystem* FileSystem; - }; - -/*! - Zip file Reader written April 2002 by N.Gebhardt. -*/ - class CZipReader : public virtual IFileArchive, virtual CFileList - { - public: - - //! constructor - CZipReader(IReadFile* file, bool ignoreCase, bool ignorePaths, bool isGZip=false); - - //! destructor - virtual ~CZipReader(); - - //! opens a file by file name - virtual IReadFile* createAndOpenFile(const io::path& filename); - - //! opens a file by index - virtual IReadFile* createAndOpenFile(u32 index); - - //! returns the list of files - virtual const IFileList* getFileList() const; - - //! get the archive type - virtual E_FILE_ARCHIVE_TYPE getType() const; - - protected: - - IReadFile* File; - - //! reads the next file header from a ZIP file, returns false if there are no more headers. - bool scanZipHeader(); - - //! the same but for gzip files - bool scanGZipHeader(); - - bool IsGZip; - - // holds extended info about files - core::array<SZipFileEntry> FileInfo; - }; - - -} // end namespace io -} // end namespace irr - -#endif // __IRR_COMPILE_WITH_ZIP_ARCHIVE_LOADER_ -#endif // __C_ZIP_READER_H_INCLUDED__ diff --git a/irrlicht-1.6/source/Irrlicht/IBurningShader.cpp b/irrlicht-1.6/source/Irrlicht/IBurningShader.cpp deleted file mode 100644 index bb2e99c6d..000000000 --- a/irrlicht-1.6/source/Irrlicht/IBurningShader.cpp +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt / Thomas Alten -// 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_BURNINGSVIDEO_ - -#include "SoftwareDriver2_compile_config.h" -#include "IBurningShader.h" - -namespace irr -{ - -namespace video -{ - - const tFixPointu IBurningShader::dithermask[ 4 * 4] = - { - 0x00,0x80,0x20,0xa0, - 0xc0,0x40,0xe0,0x60, - 0x30,0xb0,0x10,0x90, - 0xf0,0x70,0xd0,0x50 - }; - - IBurningShader::IBurningShader(IDepthBuffer* zbuffer) - :RenderTarget(0),DepthBuffer(zbuffer) - { - #ifdef _DEBUG - setDebugName("IBurningShader"); - #endif - - for ( u32 i = 0; i != BURNING_MATERIAL_MAX_TEXTURES; ++i ) - { - IT[i].Texture = 0; - } - - if ( DepthBuffer ) - DepthBuffer->grab(); - } - - - //! destructor - IBurningShader::~IBurningShader() - { - if (RenderTarget) - RenderTarget->drop(); - - if (DepthBuffer) - DepthBuffer->drop(); - - for ( u32 i = 0; i != BURNING_MATERIAL_MAX_TEXTURES; ++i ) - { - if ( IT[i].Texture ) - IT[i].Texture->drop(); - } - } - - //! sets a render target - void IBurningShader::setRenderTarget(video::IImage* surface, const core::rect<s32>& viewPort) - { - if (RenderTarget) - RenderTarget->drop(); - - RenderTarget = (video::CImage* ) surface; - - if (RenderTarget) - { - RenderTarget->grab(); - - //(tVideoSample*)RenderTarget->lock() = (tVideoSample*)RenderTarget->lock(); - //(fp24*) DepthBuffer->lock() = DepthBuffer->lock(); - } - - } - - - //! sets the Texture - void IBurningShader::setTextureParam( u32 stage, video::CSoftwareTexture2* texture, s32 lodLevel) - { - sInternalTexture *it = &IT[stage]; - - if ( it->Texture) - it->Texture->drop(); - - it->Texture = texture; - - if ( it->Texture) - { - it->Texture->grab(); - - // select mignify and magnify ( lodLevel ) - //SOFTWARE_DRIVER_2_MIPMAPPING_LOD_BIAS - it->lodLevel = lodLevel; - it->Texture->setCurrentMipMapLOD ( - core::s32_clamp ( lodLevel + SOFTWARE_DRIVER_2_MIPMAPPING_LOD_BIAS, 0, SOFTWARE_DRIVER_2_MIPMAPPING_MAX - 1 ) - ); - - // prepare for optimal fixpoint - it->pitchlog2 = s32_log2_s32 ( it->Texture->getPitch() ); - - const core::dimension2d<u32> &dim = it->Texture->getSize(); - it->textureXMask = s32_to_fixPoint ( dim.Width - 1 ) & FIX_POINT_UNSIGNED_MASK; - it->textureYMask = s32_to_fixPoint ( dim.Height - 1 ) & FIX_POINT_UNSIGNED_MASK; - it->data = (tVideoSample*) it->Texture->lock(); - } - } - - - -} // end namespace video -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ diff --git a/irrlicht-1.6/source/Irrlicht/IBurningShader.h b/irrlicht-1.6/source/Irrlicht/IBurningShader.h deleted file mode 100644 index 771fd88e2..000000000 --- a/irrlicht-1.6/source/Irrlicht/IBurningShader.h +++ /dev/null @@ -1,189 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_BURNING_SHADER_H_INCLUDED__ -#define __I_BURNING_SHADER_H_INCLUDED__ - -#include "SoftwareDriver2_compile_config.h" -#include "IReferenceCounted.h" -#include "irrMath.h" -#include "IImage.h" -#include "S2DVertex.h" -#include "rect.h" -#include "IDepthBuffer.h" -#include "S4DVertex.h" -#include "irrArray.h" -#include "SLight.h" -#include "SMaterial.h" -#include "os.h" - - -namespace irr -{ - -namespace video -{ - - struct SBurningShaderLight - { - //SLight org; - bool LightIsOn; - - E_LIGHT_TYPE Type; - f32 radius; - f32 linearAttenuation; - f32 constantAttenuation; - f32 quadraticAttenuation; - sVec4 pos; - - sVec3 AmbientColor; - sVec3 DiffuseColor; - sVec3 SpecularColor; - }; - - enum eLightFlags - { - ENABLED = 0x01, - POINTLIGHT = 0x02, - SPECULAR = 0x04, - FOG = 0x08, - NORMALIZE = 0x10, - VERTEXTRANSFORM = 0x20, - }; - - struct SBurningShaderLightSpace - { - void reset () - { - Light.set_used ( 0 ); - Global_AmbientLight.set ( 0.f, 0.f, 0.f ); - Flags = 0; - } - core::array<SBurningShaderLight> Light; - sVec3 Global_AmbientLight; - sVec4 FogColor; - sVec4 campos; - sVec4 vertex; - sVec4 normal; - u32 Flags; - }; - - struct SBurningShaderMaterial - { - SMaterial org; - - sVec3 AmbientColor; - sVec3 DiffuseColor; - sVec3 SpecularColor; - sVec3 EmissiveColor; - - }; - - enum EBurningFFShader - { - ETR_FLAT = 0, - ETR_FLAT_WIRE, - ETR_GOURAUD, - ETR_GOURAUD_WIRE, - ETR_TEXTURE_FLAT, - ETR_TEXTURE_FLAT_WIRE, - ETR_TEXTURE_GOURAUD, - ETR_TEXTURE_GOURAUD_WIRE, - ETR_TEXTURE_GOURAUD_NOZ, - ETR_TEXTURE_GOURAUD_ADD, - ETR_TEXTURE_GOURAUD_ADD_NO_Z, - - ETR_TEXTURE_GOURAUD_VERTEX_ALPHA, - - ETR_TEXTURE_GOURAUD_LIGHTMAP_M1, - ETR_TEXTURE_GOURAUD_LIGHTMAP_M2, - ETR_TEXTURE_GOURAUD_LIGHTMAP_M4, - ETR_TEXTURE_LIGHTMAP_M4, - - ETR_TEXTURE_GOURAUD_DETAIL_MAP, - ETR_TEXTURE_GOURAUD_LIGHTMAP_ADD, - - ETR_GOURAUD_ALPHA, - ETR_GOURAUD_ALPHA_NOZ, - - ETR_TEXTURE_GOURAUD_ALPHA, - ETR_TEXTURE_GOURAUD_ALPHA_NOZ, - - ETR_TEXTURE_BLEND, - ETR_REFERENCE, - ETR_INVALID, - - ETR2_COUNT - }; - - - class IBurningShader : public virtual IReferenceCounted - { - public: - IBurningShader(IDepthBuffer* zbuffer); - - //! destructor - virtual ~IBurningShader(); - - //! sets a render target - virtual void setRenderTarget(video::IImage* surface, const core::rect<s32>& viewPort); - - //! sets the Texture - virtual void setTextureParam( u32 stage, video::CSoftwareTexture2* texture, s32 lodLevel); - virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) = 0; - virtual void drawLine ( const s4DVertex *a,const s4DVertex *b) {}; - - virtual void setParam ( u32 index, f32 value) {}; - virtual void setZCompareFunc ( u32 func) {}; - - virtual void setMaterial ( const SBurningShaderMaterial &material ) {}; - - protected: - - video::CImage* RenderTarget; - IDepthBuffer* DepthBuffer; - - sInternalTexture IT[ BURNING_MATERIAL_MAX_TEXTURES ]; - - static const tFixPointu dithermask[ 4 * 4]; - }; - - - IBurningShader* createTriangleRendererTextureGouraud2(IDepthBuffer* zbuffer); - IBurningShader* createTriangleRendererTextureLightMap2_M1(IDepthBuffer* zbuffer); - IBurningShader* createTriangleRendererTextureLightMap2_M2(IDepthBuffer* zbuffer); - IBurningShader* createTriangleRendererTextureLightMap2_M4(IDepthBuffer* zbuffer); - IBurningShader* createTriangleRendererGTextureLightMap2_M4(IDepthBuffer* zbuffer); - IBurningShader* createTriangleRendererTextureLightMap2_Add(IDepthBuffer* zbuffer); - IBurningShader* createTriangleRendererTextureDetailMap2(IDepthBuffer* zbuffer); - IBurningShader* createTriangleRendererTextureVertexAlpha2(IDepthBuffer* zbuffer); - - - IBurningShader* createTriangleRendererTextureGouraudWire2(IDepthBuffer* zbuffer); - IBurningShader* createTriangleRendererGouraud2(IDepthBuffer* zbuffer); - IBurningShader* createTriangleRendererGouraudAlpha2(IDepthBuffer* zbuffer); - IBurningShader* createTRGouraudAlphaNoZ2(IDepthBuffer* zbuffer); - IBurningShader* createTriangleRendererGouraudWire2(IDepthBuffer* zbuffer); - IBurningShader* createTriangleRendererTextureFlat2(IDepthBuffer* zbuffer); - IBurningShader* createTriangleRendererTextureFlatWire2(IDepthBuffer* zbuffer); - IBurningShader* createTRFlat2(IDepthBuffer* zbuffer); - IBurningShader* createTRFlatWire2(IDepthBuffer* zbuffer); - IBurningShader* createTRTextureGouraudNoZ2(); - IBurningShader* createTRTextureGouraudAdd2(IDepthBuffer* zbuffer); - IBurningShader* createTRTextureGouraudAddNoZ2(IDepthBuffer* zbuffer); - - IBurningShader* createTRTextureGouraudAlpha(IDepthBuffer* zbuffer); - IBurningShader* createTRTextureGouraudAlphaNoZ(IDepthBuffer* zbuffer); - IBurningShader* createTRTextureBlend(IDepthBuffer* zbuffer); - IBurningShader* createTRTextureInverseAlphaBlend(IDepthBuffer* zbuffer); - - IBurningShader* createTriangleRendererReference(IDepthBuffer* zbuffer); - - - -} // end namespace video -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/IDepthBuffer.h b/irrlicht-1.6/source/Irrlicht/IDepthBuffer.h deleted file mode 100644 index b9c331517..000000000 --- a/irrlicht-1.6/source/Irrlicht/IDepthBuffer.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_Z2_BUFFER_H_INCLUDED__ -#define __I_Z2_BUFFER_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "dimension2d.h" -#include "S4DVertex.h" - -namespace irr -{ -namespace video -{ - class IDepthBuffer : public virtual IReferenceCounted - { - public: - - //! destructor - virtual ~IDepthBuffer() {}; - - //! clears the zbuffer - virtual void clear() = 0; - - //! sets the new size of the zbuffer - virtual void setSize(const core::dimension2d<u32>& size) = 0; - - //! returns the size of the zbuffer - virtual const core::dimension2d<u32>& getSize() const = 0; - - //! locks the zbuffer - virtual void* lock() = 0; - - //! unlocks the zbuffer - virtual void unlock() = 0; - - //! returns pitch of depthbuffer (in bytes) - virtual u32 getPitch() const = 0; - - }; - - - //! creates a ZBuffer - IDepthBuffer* createDepthBuffer(const core::dimension2d<u32>& size); - -} // end namespace video -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/IImagePresenter.h b/irrlicht-1.6/source/Irrlicht/IImagePresenter.h deleted file mode 100644 index 75077137e..000000000 --- a/irrlicht-1.6/source/Irrlicht/IImagePresenter.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_IMAGE_PRESENTER_H_INCLUDED__ -#define __I_IMAGE_PRESENTER_H_INCLUDED__ - -#include "IImage.h" - -namespace irr -{ -namespace video -{ - -/*! - Interface for a class which is able to present an IImage - an the Screen. Usually only implemented by an IrrDevice for - presenting Software Device Rendered images. - - This class should be used only internally. -*/ - - class IImagePresenter - { - public: - - virtual ~IImagePresenter() {}; - //! presents a surface in the client area - virtual bool present(video::IImage* surface, void* windowId=0, core::rect<s32>* src=0 ) = 0; - }; - -} // end namespace video -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/ISceneNodeAnimatorFinishing.h b/irrlicht-1.6/source/Irrlicht/ISceneNodeAnimatorFinishing.h deleted file mode 100755 index 60d1033d6..000000000 --- a/irrlicht-1.6/source/Irrlicht/ISceneNodeAnimatorFinishing.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2002-2008 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_SCENE_NODE_ANIMATOR_FINISHING_H_INCLUDED__ -#define __I_SCENE_NODE_ANIMATOR_FINISHING_H_INCLUDED__ - -#include "ISceneNode.h" - -namespace irr -{ -namespace scene -{ - //! This is an abstract base class for animators that have a discrete end time. - class ISceneNodeAnimatorFinishing : public ISceneNodeAnimator - { - public: - - //! constructor - ISceneNodeAnimatorFinishing(u32 finishTime) - : FinishTime(finishTime), HasFinished(false) { } - - virtual bool hasFinished(void) const { return HasFinished; } - - protected: - - u32 FinishTime; - bool HasFinished; - }; - - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/ITriangleRenderer.h b/irrlicht-1.6/source/Irrlicht/ITriangleRenderer.h deleted file mode 100644 index 36f975d62..000000000 --- a/irrlicht-1.6/source/Irrlicht/ITriangleRenderer.h +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_TRIANGLE_RENDERER_H_INCLUDED__ -#define __I_TRIANGLE_RENDERER_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "S2DVertex.h" -#include "rect.h" -#include "IZBuffer.h" - -namespace irr -{ -namespace video -{ - class IImage; - - enum ETriangleRenderer - { - ETR_FLAT = 0, - ETR_FLAT_WIRE, - ETR_GOURAUD, - ETR_GOURAUD_WIRE, - ETR_TEXTURE_FLAT, - ETR_TEXTURE_FLAT_WIRE, - ETR_TEXTURE_GOURAUD, - ETR_TEXTURE_GOURAUD_WIRE, - ETR_TEXTURE_GOURAUD_NOZ, - ETR_TEXTURE_GOURAUD_ADD, - ETR_COUNT - }; - - class ITriangleRenderer : public virtual IReferenceCounted - { - public: - - //! sets a render target - virtual void setRenderTarget(video::IImage* surface, const core::rect<s32>& viewPort) = 0; - - //! en or disables the backface culling - virtual void setBackfaceCulling(bool enabled = true) = 0; - - //! sets the Texture - virtual void setTexture(video::IImage* texture) = 0; - - //! draws an indexed triangle list - virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount) = 0; - }; - - - ITriangleRenderer* createTriangleRendererTextureGouraud(IZBuffer* zbuffer); - ITriangleRenderer* createTriangleRendererTextureGouraudWire(IZBuffer* zbuffer); - ITriangleRenderer* createTriangleRendererGouraud(IZBuffer* zbuffer); - ITriangleRenderer* createTriangleRendererGouraudWire(IZBuffer* zbuffer); - ITriangleRenderer* createTriangleRendererTextureFlat(IZBuffer* zbuffer); - ITriangleRenderer* createTriangleRendererTextureFlatWire(IZBuffer* zbuffer); - ITriangleRenderer* createTriangleRendererFlat(IZBuffer* zbuffer); - ITriangleRenderer* createTriangleRendererFlatWire(IZBuffer* zbuffer); - ITriangleRenderer* createTriangleRendererTextureGouraudNoZ(); - ITriangleRenderer* createTriangleRendererTextureGouraudAdd(IZBuffer* zbuffer); - - -} // end namespace video -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/IZBuffer.h b/irrlicht-1.6/source/Irrlicht/IZBuffer.h deleted file mode 100644 index e96544502..000000000 --- a/irrlicht-1.6/source/Irrlicht/IZBuffer.h +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __I_Z_BUFFER_H_INCLUDED__ -#define __I_Z_BUFFER_H_INCLUDED__ - -#include "IReferenceCounted.h" -#include "dimension2d.h" -#include "S2DVertex.h" - -namespace irr -{ -namespace video -{ - class IZBuffer : public virtual IReferenceCounted - { - public: - - //! destructor - virtual ~IZBuffer() {}; - - //! clears the zbuffer - virtual void clear() = 0; - - //! sets the new size of the zbuffer - virtual void setSize(const core::dimension2d<u32>& size) = 0; - - //! returns the size of the zbuffer - virtual const core::dimension2d<u32>& getSize() const = 0; - - //! locks the zbuffer - virtual TZBufferType* lock() = 0; - - //! unlocks the zbuffer - virtual void unlock() = 0; - }; - - - //! creates a ZBuffer - IZBuffer* createZBuffer(const core::dimension2d<u32>& size); - -} // end namespace video -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/Irrlicht.cpp b/irrlicht-1.6/source/Irrlicht/Irrlicht.cpp deleted file mode 100644 index ea46242aa..000000000 --- a/irrlicht-1.6/source/Irrlicht/Irrlicht.cpp +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright (C) 2002-2009 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" - -static const char* const copyright = "Irrlicht Engine (c) 2002-2009 Nikolaus Gebhardt"; - -#ifdef _IRR_WINDOWS_ - #include <windows.h> - #if defined(_DEBUG) && !defined(__GNUWIN32__) && !defined(_WIN32_WCE) - #include <crtdbg.h> - #endif // _DEBUG -#endif - -#include "irrlicht.h" -#ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_ -#include "CIrrDeviceWin32.h" -#endif - -#ifdef _IRR_COMPILE_WITH_OSX_DEVICE_ -#include "MacOSX/CIrrDeviceMacOSX.h" -#endif - -#ifdef _IRR_COMPILE_WITH_WINDOWS_CE_DEVICE_ -#include "CIrrDeviceWinCE.h" -#endif - -#ifdef _IRR_COMPILE_WITH_X11_DEVICE_ -#include "CIrrDeviceLinux.h" -#endif - -#ifdef _IRR_COMPILE_WITH_SDL_DEVICE_ -#include "CIrrDeviceSDL.h" -#endif - -#ifdef _IRR_COMPILE_WITH_CONSOLE_DEVICE_ -#include "CIrrDeviceConsole.h" -#endif - -namespace irr -{ - //! stub for calling createDeviceEx - IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDevice(video::E_DRIVER_TYPE driverType, - const core::dimension2d<u32>& windowSize, - u32 bits, bool fullscreen, - bool stencilbuffer, bool vsync, IEventReceiver* res) - { - SIrrlichtCreationParameters p; - p.DriverType = driverType; - p.WindowSize = windowSize; - p.Bits = (u8)bits; - p.Fullscreen = fullscreen; - p.Stencilbuffer = stencilbuffer; - p.Vsync = vsync; - p.EventReceiver = res; - - return createDeviceEx(p); - } - - extern "C" IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDeviceEx(const SIrrlichtCreationParameters& params) - { - - IrrlichtDevice* dev = 0; - -#ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_ - if (params.DeviceType == EIDT_WIN32 || (!dev && params.DeviceType == EIDT_BEST)) - dev = new CIrrDeviceWin32(params); -#endif - -#ifdef _IRR_COMPILE_WITH_OSX_DEVICE_ - if (params.DeviceType == EIDT_OSX || (!dev && params.DeviceType == EIDT_BEST)) - dev = new CIrrDeviceMacOSX(params); -#endif - -#ifdef _IRR_COMPILE_WITH_WINDOWS_CE_DEVICE_ - if (params.DeviceType == EIDT_WINCE || (!dev && params.DeviceType == EIDT_BEST)) - dev = new CIrrDeviceWinCE(params); -#endif - -#ifdef _IRR_COMPILE_WITH_X11_DEVICE_ - if (params.DeviceType == EIDT_X11 || (!dev && params.DeviceType == EIDT_BEST)) - dev = new CIrrDeviceLinux(params); -#endif - -#ifdef _IRR_COMPILE_WITH_SDL_DEVICE_ - if (params.DeviceType == EIDT_SDL || (!dev && params.DeviceType == EIDT_BEST)) - dev = new CIrrDeviceSDL(params); -#endif - -#ifdef _IRR_COMPILE_WITH_CONSOLE_DEVICE_ - if (params.DeviceType == EIDT_CONSOLE || (!dev && params.DeviceType == EIDT_BEST)) - dev = new CIrrDeviceConsole(params); -#endif - - if (dev && !dev->getVideoDriver() && params.DriverType != video::EDT_NULL) - { - dev->closeDevice(); // destroy window - dev->run(); // consume quit message - dev->drop(); - dev = 0; - } - - return dev; - } - -namespace core -{ - const matrix4 IdentityMatrix(matrix4::EM4CONST_IDENTITY); -} - -namespace video -{ - SMaterial IdentityMaterial; -} - -} // end namespace irr - - -#if defined(_IRR_WINDOWS_API_) - -BOOL APIENTRY DllMain( HANDLE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved ) -{ - // _crtBreakAlloc = 139; - - switch (ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - #if defined(_DEBUG) && !defined(__GNUWIN32__) && !defined(__BORLANDC__) && !defined (_WIN32_WCE) && !defined (_IRR_XBOX_PLATFORM_) - _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF | _CRTDBG_ALLOC_MEM_DF); - #endif - break; - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - case DLL_PROCESS_DETACH: - break; - } - return TRUE; -} - -#endif // defined(_IRR_WINDOWS_) - diff --git a/irrlicht-1.6/source/Irrlicht/Irrlicht.dev b/irrlicht-1.6/source/Irrlicht/Irrlicht.dev deleted file mode 100644 index 8fa572ef3..000000000 --- a/irrlicht-1.6/source/Irrlicht/Irrlicht.dev +++ /dev/null @@ -1,6300 +0,0 @@ -[Project] -FileName=Irrlicht.dev -Name=Irrlicht -Ver=1 -IsCpp=1 -Type=3 -Compiler=-D__GNUWIN32__ -W -DWIN32 -DNDEBUG -D_WINDOWS -D_MBCS -D_USRDLL -DIRRLICHT_EXPORTS_@@_ -CppCompiler=-D__GNUWIN32__ -W -DWIN32 -DNDEBUG -D_WINDOWS -D_MBCS -D_USRDLL -DIRRLICHT_EXPORTS_@@_ -Includes=..\..\include;zlib -Linker=-lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lwinmm -lopengl32_@@_ -Libs= -UnitCount=625 -Folders=doc,include,include/core,include/gui,include/io,include/scene,include/video,Irrlicht,Irrlicht/extern,Irrlicht/extern/jpeglib,Irrlicht/extern/libpng,Irrlicht/extern/zlib,Irrlicht/gui,Irrlicht/io,Irrlicht/io/archive,Irrlicht/io/attributes,Irrlicht/io/file,Irrlicht/io/xml,Irrlicht/irr,Irrlicht/irr/IrrlichtDevice,Irrlicht/scene,Irrlicht/scene/animators,Irrlicht/scene/collision,Irrlicht/scene/mesh,Irrlicht/scene/mesh/loaders,Irrlicht/scene/mesh/writers,Irrlicht/scene/nodes,Irrlicht/scene/nodes/particles,Irrlicht/video,"Irrlicht/video/Burning Video",Irrlicht/video/DirectX8,Irrlicht/video/DirectX9,Irrlicht/video/Null,Irrlicht/video/Null/Loader,Irrlicht/video/Null/Writer,Irrlicht/video/OpenGL,Irrlicht/video/Software -ObjFiles= -PrivateResource= -ResourceIncludes= -MakeIncludes= -Icon= -ExeOutput=..\..\bin\Win32-gcc -ObjectOutput=obj -OverrideOutput=1 -OverrideOutputName=Irrlicht.dll -HostApplication= -CommandLine= -UseCustomMakefile=0 -CustomMakefile= -IncludeVersionInfo=0 -SupportXPThemes=0 -CompilerSet=0 -CompilerSettings=0000000001001000000100 - -[Unit1] -FileName=..\..\include\EDriverTypes.h -Folder=include/video -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit2] -FileName=..\..\include\ITexture.h -Folder=include/video -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit3] -FileName=..\..\include\IVideoDriver.h -Folder=include/video -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit4] -FileName=..\..\include\S3DVertex.h -Folder=include/video -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit5] -FileName=..\..\include\SColor.h -Folder=include/video -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit6] -FileName=..\..\include\SLight.h -Folder=include/video -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit7] -FileName=..\..\include\SMaterial.h -Folder=include/video -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit8] -FileName=..\..\include\aabbox3d.h -Folder=include/core -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit9] -FileName=..\..\include\dimension2d.h -Folder=include/core -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit10] -FileName=..\..\include\heapsort.h -Folder=include/core -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit11] -FileName=..\..\include\irrArray.h -Folder=include/core -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit12] -FileName=..\..\include\irrList.h -Folder=include/core -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit13] -FileName=..\..\include\irrMath.h -Folder=include/core -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit14] -FileName=..\..\include\irrString.h -Folder=include/core -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit15] -FileName=..\..\include\line2d.h -Folder=include/core -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit16] -FileName=..\..\include\line3d.h -Folder=include/core -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit17] -FileName=..\..\include\matrix4.h -Folder=include/core -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit18] -FileName=..\..\include\plane3d.h -Folder=include/core -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit19] -FileName=..\..\include\position2d.h -Folder=include/core -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit20] -FileName=..\..\include\rect.h -Folder=include/core -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit21] -FileName=..\..\include\vector2d.h -Folder=include/core -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit22] -FileName=..\..\include\vector3d.h -Folder=include/core -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit23] -FileName=..\..\include\IFileList.h -Folder=include/io -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit24] -FileName=..\..\include\IFileSystem.h -Folder=include/io -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit25] -FileName=..\..\include\IReadFile.H -Folder=include/io -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit26] -FileName=..\..\include\IAnimatedMesh.h -Folder=include/scene -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit27] -FileName=..\..\include\IAnimatedMeshSceneNode.h -Folder=include/scene -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit28] -FileName=..\..\include\IBillboardSceneNode.h -Folder=include/scene -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit29] -FileName=..\..\include\ICameraSceneNode.h -Folder=include/scene -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit30] -FileName=..\..\include\ILightSceneNode.h -Folder=include/scene -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit31] -FileName=..\..\include\IMesh.h -Folder=include/scene -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit32] -FileName=..\..\include\IMeshBuffer.h -Folder=include/scene -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit33] -FileName=..\..\include\IQ3LevelMesh.h -Folder=include/scene -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit34] -FileName=..\..\include\ISceneManager.h -Folder=include/scene -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit35] -FileName=..\..\include\ISceneNode.h -Folder=include/scene -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit36] -FileName=..\..\include\ISceneNodeAnimator.h -Folder=include/scene -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit37] -FileName=..\..\include\SMesh.h -Folder=include/scene -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit38] -FileName=..\..\include\SMeshBuffer.h -Folder=include/scene -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit39] -FileName=..\..\include\SMeshBufferLightMap.h -Folder=include/scene -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit40] -FileName=..\..\include\ICursorControl.h -Folder=include/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit41] -FileName=..\..\include\IGUIButton.h -Folder=include/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit42] -FileName=..\..\include\IGUICheckbox.h -Folder=include/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit43] -FileName=..\..\include\IGUIElement.h -Folder=include/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit44] -FileName=..\..\include\IGUIEnvironment.h -Folder=include/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit45] -FileName=..\..\include\IGUIFileOpenDialog.h -Folder=include/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit46] -FileName=..\..\include\IGUIFont.h -Folder=include/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit47] -FileName=..\..\include\IGUIImage.h -Folder=include/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit48] -FileName=..\..\include\IGUIListBox.h -Folder=include/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit49] -FileName=..\..\include\IGUIMeshViewer.h -Folder=include/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit50] -FileName=..\..\include\IGUIScrollBar.h -Folder=include/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit51] -FileName=..\..\include\IGUISkin.h -Folder=include/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit52] -FileName=..\..\include\IGUIWindow.h -Folder=include/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit53] -FileName=..\..\include\IEventReceiver.h -Folder=include -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit54] -FileName=..\..\include\Irrlicht.h -Folder=include -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit55] -FileName=..\..\include\IrrlichtDevice.h -Folder=include -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit56] -FileName=..\..\include\irrTypes.h -Folder=include -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit57] -FileName=..\..\include\Keycodes.h -Folder=include -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit58] -FileName=..\..\include\SIrrCreationParameters.h -Folder=include -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit59] -FileName=BuiltInFont.h -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit60] -FileName=CGUIButton.cpp -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit61] -FileName=CGUIButton.h -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit62] -FileName=CGUICheckbox.cpp -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit63] -FileName=CGUICheckbox.h -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit64] -FileName=CGUIComboBox.cpp -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit65] -FileName=CGUIComboBox.h -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit66] -FileName=CGUIContextMenu.cpp -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit67] -FileName=CGUIContextMenu.h -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit68] -FileName=CGUIEditBox.cpp -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit69] -FileName=CGUIEditBox.h -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit70] -FileName=CGUIEnvironment.cpp -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit71] -FileName=CGUIEnvironment.h -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit72] -FileName=CGUIFileOpenDialog.cpp -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit73] -FileName=CGUIFileOpenDialog.h -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit74] -FileName=CGUIFont.cpp -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit75] -FileName=CGUIFont.h -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit76] -FileName=CGUIImage.cpp -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit77] -FileName=CGUIImage.H -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit78] -FileName=CGUIInOutFader.cpp -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit79] -FileName=CGUIInOutFader.h -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit80] -FileName=CGUIListBox.cpp -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit81] -FileName=CGUIListBox.h -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit82] -FileName=CGUIMenu.cpp -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit83] -FileName=CGUIMenu.h -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit84] -FileName=CGUIMeshViewer.cpp -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit85] -FileName=CGUIMeshViewer.h -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit86] -FileName=CGUIMessageBox.cpp -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit87] -FileName=CGUIMessageBox.h -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit88] -FileName=CGUIModalScreen.cpp -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit89] -FileName=CGUIModalScreen.h -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit90] -FileName=CGUIScrollBar.cpp -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit91] -FileName=CGUIScrollBar.h -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit92] -FileName=CGUISkin.cpp -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit93] -FileName=CGUISkin.h -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit94] -FileName=CGUIStaticText.cpp -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit95] -FileName=CGUIStaticText.h -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit96] -FileName=CGUITabControl.cpp -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit97] -FileName=CGUITabControl.h -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit98] -FileName=CGUIToolBar.cpp -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit99] -FileName=CGUIToolBar.h -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit100] -FileName=CGUIWindow.cpp -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit101] -FileName=CGUIWindow.h -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit102] -FileName=CSoftwareDriver.cpp -Folder=Irrlicht/video/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit103] -FileName=CSoftwareDriver.h -Folder=Irrlicht/video/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit104] -FileName=CSoftwareTexture.cpp -Folder=Irrlicht/video/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit105] -FileName=CSoftwareTexture.h -Folder=Irrlicht/video/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit106] -FileName=CTRFlat.cpp -Folder=Irrlicht/video/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit107] -FileName=CTRFlatWire.cpp -Folder=Irrlicht/video/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit108] -FileName=CTRGouraud.cpp -Folder=Irrlicht/video/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit109] -FileName=CTRGouraudWire.cpp -Folder=Irrlicht/video/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit110] -FileName=CTRTextureFlat.cpp -Folder=Irrlicht/video/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit111] -FileName=CTRTextureFlatWire.cpp -Folder=Irrlicht/video/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit112] -FileName=CTRTextureGouraud.cpp -Folder=Irrlicht/video/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit113] -FileName=CTRTextureGouraud.h -Folder=Irrlicht/video/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit114] -FileName=CTRTextureGouraudAdd.cpp -Folder=Irrlicht/video/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit115] -FileName=CTRTextureGouraudNoZ.cpp -Folder=Irrlicht/video/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit116] -FileName=CTRTextureGouraudWire.cpp -Folder=Irrlicht/video/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit117] -FileName=CZBuffer.cpp -Folder=Irrlicht/video/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit118] -FileName=CZBuffer.h -Folder=Irrlicht/video/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit119] -FileName=IZBuffer.h -Folder=Irrlicht/video/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit120] -FileName=S2DVertex.h -Folder=Irrlicht/video/Software -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit121] -FileName=COpenGLDriver.cpp -Folder=Irrlicht/video/OpenGL -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit122] -FileName=COpenGLDriver.h -Folder=Irrlicht/video/OpenGL -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit123] -FileName=COpenGLMaterialRenderer.h -Folder=Irrlicht/video/OpenGL -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit124] -FileName=COpenGLNormalMapRenderer.cpp -Folder=Irrlicht/video/OpenGL -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit125] -FileName=COpenGLNormalMapRenderer.h -Folder=Irrlicht/video/OpenGL -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit126] -FileName=COpenGLParallaxMapRenderer.cpp -Folder=Irrlicht/video/OpenGL -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit127] -FileName=COpenGLParallaxMapRenderer.h -Folder=Irrlicht/video/OpenGL -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit128] -FileName=COpenGLShaderMaterialRenderer.cpp -Folder=Irrlicht/video/OpenGL -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit129] -FileName=COpenGLShaderMaterialRenderer.h -Folder=Irrlicht/video/OpenGL -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit130] -FileName=COpenGLTexture.cpp -Folder=Irrlicht/video/OpenGL -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit131] -FileName=COpenGLTexture.h -Folder=Irrlicht/video/OpenGL -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit132] -FileName=glext.h -Folder=Irrlicht/video/OpenGL -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit133] -FileName=CD3D8Driver.cpp -Folder=Irrlicht/video/DirectX8 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit134] -FileName=CD3D8Driver.h -Folder=Irrlicht/video/DirectX8 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit135] -FileName=CD3D8MaterialRenderer.h -Folder=Irrlicht/video/DirectX8 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit136] -FileName=CD3D8NormalMapRenderer.cpp -Folder=Irrlicht/video/DirectX8 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit137] -FileName=CD3D8NormalMapRenderer.h -Folder=Irrlicht/video/DirectX8 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit138] -FileName=CD3D8ParallaxMapRenderer.cpp -Folder=Irrlicht/video/DirectX8 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit139] -FileName=CD3D8ParallaxMapRenderer.h -Folder=Irrlicht/video/DirectX8 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit140] -FileName=CD3D8ShaderMaterialRenderer.cpp -Folder=Irrlicht/video/DirectX8 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit141] -FileName=CD3D8ShaderMaterialRenderer.h -Folder=Irrlicht/video/DirectX8 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit142] -FileName=CD3D8Texture.cpp -Folder=Irrlicht/video/DirectX8 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit143] -FileName=CD3D8Texture.h -Folder=Irrlicht/video/DirectX8 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit144] -FileName=CColorConverter.cpp -Folder=Irrlicht/video/Null -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit145] -FileName=CColorConverter.h -Folder=Irrlicht/video/Null -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit146] -FileName=CFPSCounter.cpp -Folder=Irrlicht/video/Null -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit147] -FileName=CFPSCounter.h -Folder=Irrlicht/video/Null -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit148] -FileName=CImage.cpp -Folder=Irrlicht/video/Null -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit149] -FileName=CImage.h -Folder=Irrlicht/video/Null -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit150] -FileName=CImageLoaderBMP.cpp -Folder=Irrlicht/video/Null/Loader -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit151] -FileName=CImageLoaderBMP.h -Folder=Irrlicht/video/Null/Loader -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit152] -FileName=CImageLoaderJPG.cpp -Folder=Irrlicht/video/Null/Loader -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit153] -FileName=CImageLoaderJPG.h -Folder=Irrlicht/video/Null/Loader -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit154] -FileName=CImageLoaderPCX.cpp -Folder=Irrlicht/video/Null/Loader -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit155] -FileName=CImageLoaderPCX.h -Folder=Irrlicht/video/Null/Loader -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit156] -FileName=CImageLoaderPNG.cpp -Folder=Irrlicht/video/Null/Loader -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit157] -FileName=CImageLoaderPNG.h -Folder=Irrlicht/video/Null/Loader -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit158] -FileName=CImageLoaderPSD.cpp -Folder=Irrlicht/video/Null/Loader -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit159] -FileName=CImageLoaderPSD.h -Folder=Irrlicht/video/Null/Loader -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit160] -FileName=CImageLoaderTGA.cpp -Folder=Irrlicht/video/Null/Loader -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit161] -FileName=CImageLoaderTGA.h -Folder=Irrlicht/video/Null/Loader -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit162] -FileName=CNullDriver.cpp -Folder=Irrlicht/video/Null -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit163] -FileName=CNullDriver.h -Folder=Irrlicht/video/Null -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit164] -FileName=CD3D9Driver.cpp -Folder=Irrlicht/video/DirectX9 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit165] -FileName=CD3D9Driver.h -Folder=Irrlicht/video/DirectX9 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit166] -FileName=CD3D9HLSLMaterialRenderer.cpp -Folder=Irrlicht/video/DirectX9 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit167] -FileName=CD3D9HLSLMaterialRenderer.h -Folder=Irrlicht/video/DirectX9 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit168] -FileName=CD3D9MaterialRenderer.h -Folder=Irrlicht/video/DirectX9 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit169] -FileName=CD3D9NormalMapRenderer.cpp -Folder=Irrlicht/video/DirectX9 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit170] -FileName=CD3D9NormalMapRenderer.h -Folder=Irrlicht/video/DirectX9 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit171] -FileName=CD3D9ParallaxMapRenderer.cpp -Folder=Irrlicht/video/DirectX9 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit172] -FileName=CD3D9ParallaxMapRenderer.h -Folder=Irrlicht/video/DirectX9 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit173] -FileName=CD3D9ShaderMaterialRenderer.cpp -Folder=Irrlicht/video/DirectX9 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit174] -FileName=CD3D9ShaderMaterialRenderer.h -Folder=Irrlicht/video/DirectX9 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit175] -FileName=CD3D9Texture.cpp -Folder=Irrlicht/video/DirectX9 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit176] -FileName=CD3D9Texture.h -Folder=Irrlicht/video/DirectX9 -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit177] -FileName=CVideoModeList.cpp -Folder=Irrlicht/video -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit178] -FileName=CVideoModeList.h -Folder=Irrlicht/video -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit179] -FileName=C3DSMeshFileLoader.cpp -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit180] -FileName=C3DSMeshFileLoader.h -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit181] -FileName=CAnimatedMeshMD2.cpp -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit182] -FileName=CAnimatedMeshMD2.h -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit183] -FileName=CAnimatedMeshSceneNode.cpp -Folder=Irrlicht/scene/nodes -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit184] -FileName=CAnimatedMeshSceneNode.h -Folder=Irrlicht/scene/nodes -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit185] -FileName=CBillboardSceneNode.cpp -Folder=Irrlicht/scene/nodes -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit186] -FileName=CBillboardSceneNode.h -Folder=Irrlicht/scene/nodes -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit187] -FileName=CCameraSceneNode.cpp -Folder=Irrlicht/scene/nodes -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit188] -FileName=CCameraSceneNode.h -Folder=Irrlicht/scene/nodes -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit189] -FileName=CColladaFileLoader.cpp -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit190] -FileName=CColladaFileLoader.h -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit191] -FileName=CCSMLoader.cpp -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit192] -FileName=CCSMLoader.h -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit193] -FileName=CDMFLoader.cpp -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit194] -FileName=CDMFLoader.h -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit195] -FileName=CDummyTransformationSceneNode.cpp -Folder=Irrlicht/scene/nodes -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit196] -FileName=CDummyTransformationSceneNode.h -Folder=Irrlicht/scene/nodes -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit197] -FileName=CEmptySceneNode.cpp -Folder=Irrlicht/scene/nodes -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit198] -FileName=CEmptySceneNode.h -Folder=Irrlicht/scene/nodes -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit199] -FileName=CGeometryCreator.cpp -Folder=Irrlicht/scene/mesh -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit200] -FileName=CGeometryCreator.h -Folder=Irrlicht/scene/mesh -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit201] -FileName=CLightSceneNode.cpp -Folder=Irrlicht/scene/nodes -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit202] -FileName=CLightSceneNode.h -Folder=Irrlicht/scene/nodes -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit203] -FileName=CLMTSMeshFileLoader.cpp -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit204] -FileName=CLMTSMeshFileLoader.h -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit205] -FileName=CMeshManipulator.cpp -Folder=Irrlicht/scene/mesh -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit206] -FileName=CMeshManipulator.h -Folder=Irrlicht/scene/mesh -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit207] -FileName=CMeshSceneNode.cpp -Folder=Irrlicht/scene/nodes -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit208] -FileName=CMeshSceneNode.h -Folder=Irrlicht/scene/nodes -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit209] -FileName=CMetaTriangleSelector.cpp -Folder=Irrlicht/scene/collision -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit210] -FileName=CMetaTriangleSelector.h -Folder=Irrlicht/scene/collision -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit211] -FileName=CMY3DHelper.h -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit212] -FileName=CMY3DMeshFileLoader.cpp -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit213] -FileName=CMY3DMeshFileLoader.h -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit214] -FileName=..\..\include\EGUIAlignment.h -Folder=include/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit215] -FileName=COCTLoader.cpp -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit216] -FileName=COCTLoader.h -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit217] -FileName=COctTreeSceneNode.cpp -Folder=Irrlicht/scene/nodes -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit218] -FileName=COctTreeSceneNode.h -Folder=Irrlicht/scene/nodes -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit219] -FileName=COctTreeTriangleSelector.cpp -Folder=Irrlicht/scene/collision -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit220] -FileName=COctTreeTriangleSelector.h -Folder=Irrlicht/scene/collision -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit221] -FileName=CParticleBoxEmitter.cpp -Folder=Irrlicht/scene/nodes/particles -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit222] -FileName=CParticleBoxEmitter.h -Folder=Irrlicht/scene/nodes/particles -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit223] -FileName=CParticleFadeOutAffector.cpp -Folder=Irrlicht/scene/nodes/particles -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit224] -FileName=CParticleFadeOutAffector.h -Folder=Irrlicht/scene/nodes/particles -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit225] -FileName=CParticleGravityAffector.cpp -Folder=Irrlicht/scene/nodes/particles -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit226] -FileName=CParticleGravityAffector.h -Folder=Irrlicht/scene/nodes/particles -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit227] -FileName=CParticlePointEmitter.cpp -Folder=Irrlicht/scene/nodes/particles -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit228] -FileName=CParticlePointEmitter.h -Folder=Irrlicht/scene/nodes/particles -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit229] -FileName=CParticleSystemSceneNode.cpp -Folder=Irrlicht/scene/nodes/particles -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit230] -FileName=CParticleSystemSceneNode.h -Folder=Irrlicht/scene/nodes/particles -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit231] -FileName=CQ3LevelMesh.cpp -Folder=Irrlicht/scene/mesh -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit232] -FileName=CQ3LevelMesh.h -Folder=Irrlicht/scene/mesh -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit233] -FileName=CSceneCollisionManager.cpp -Folder=Irrlicht/scene/collision -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit234] -FileName=CSceneCollisionManager.h -Folder=Irrlicht/scene/collision -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit235] -FileName=CSceneManager.cpp -Folder=Irrlicht/scene -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit236] -FileName=CSceneManager.h -Folder=Irrlicht/scene -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit237] -FileName=CSceneNodeAnimatorCollisionResponse.cpp -Folder=Irrlicht/scene/animators -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit238] -FileName=CSceneNodeAnimatorCollisionResponse.h -Folder=Irrlicht/scene/animators -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit239] -FileName=CSceneNodeAnimatorDelete.cpp -Folder=Irrlicht/scene/animators -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit240] -FileName=CSceneNodeAnimatorDelete.h -Folder=Irrlicht/scene/animators -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit241] -FileName=CSceneNodeAnimatorFlyCircle.cpp -Folder=Irrlicht/scene/animators -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit242] -FileName=CSceneNodeAnimatorFlyCircle.h -Folder=Irrlicht/scene/animators -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit243] -FileName=CSceneNodeAnimatorFlyStraight.cpp -Folder=Irrlicht/scene/animators -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit244] -FileName=CSceneNodeAnimatorFlyStraight.h -Folder=Irrlicht/scene/animators -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit245] -FileName=CSceneNodeAnimatorFollowSpline.cpp -Folder=Irrlicht/scene/animators -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit246] -FileName=CSceneNodeAnimatorFollowSpline.h -Folder=Irrlicht/scene/animators -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit247] -FileName=CSceneNodeAnimatorRotation.cpp -Folder=Irrlicht/scene/animators -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit248] -FileName=CSceneNodeAnimatorRotation.h -Folder=Irrlicht/scene/animators -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit249] -FileName=CSceneNodeAnimatorTexture.cpp -Folder=Irrlicht/scene/animators -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit250] -FileName=CSceneNodeAnimatorTexture.h -Folder=Irrlicht/scene/animators -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit251] -FileName=CShadowVolumeSceneNode.cpp -Folder=Irrlicht/scene/nodes -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit252] -FileName=CShadowVolumeSceneNode.h -Folder=Irrlicht/scene/nodes -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit253] -FileName=CSkyBoxSceneNode.cpp -Folder=Irrlicht/scene/nodes -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit254] -FileName=CSkyBoxSceneNode.h -Folder=Irrlicht/scene/nodes -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit255] -FileName=COBJMeshFileLoader.cpp -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit256] -FileName=COBJMeshFileLoader.h -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit257] -FileName=CTerrainSceneNode.cpp -Folder=Irrlicht/scene/nodes -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit258] -FileName=CTerrainSceneNode.h -Folder=Irrlicht/scene/nodes -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit259] -FileName=CTerrainTriangleSelector.cpp -Folder=Irrlicht/scene/collision -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit260] -FileName=CTerrainTriangleSelector.h -Folder=Irrlicht/scene/collision -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit261] -FileName=CTextSceneNode.cpp -Folder=Irrlicht/scene/nodes -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit262] -FileName=CTextSceneNode.h -Folder=Irrlicht/scene/nodes -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit263] -FileName=CTriangleBBSelector.cpp -Folder=Irrlicht/scene/collision -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit264] -FileName=CTriangleBBSelector.h -Folder=Irrlicht/scene/collision -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit265] -FileName=CTriangleSelector.cpp -Folder=Irrlicht/scene/collision -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit266] -FileName=CTriangleSelector.h -Folder=Irrlicht/scene/collision -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit267] -FileName=CWaterSurfaceSceneNode.cpp -Folder=Irrlicht/scene/nodes -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit268] -FileName=CWaterSurfaceSceneNode.h -Folder=Irrlicht/scene/nodes -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit269] -FileName=..\..\include\SExposedVideoData.h -Folder=include/video -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit270] -FileName=..\..\include\SKeyMap.h -Folder=include -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit271] -FileName=..\..\include\SMeshBufferTangents.h -Folder=include/video -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit272] -FileName=..\..\include\SParticle.h -Folder=include/scene -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit273] -FileName=CXMeshFileLoader.cpp -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit274] -FileName=CXMeshFileLoader.h -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit275] -FileName=OctTree.h -Folder=Irrlicht/scene/mesh -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit276] -FileName=CFileList.cpp -Folder=Irrlicht/io -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit277] -FileName=CFileList.h -Folder=Irrlicht/io -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit278] -FileName=CFileSystem.cpp -CompileCpp=1 -Folder=Irrlicht/io -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit279] -FileName=CFileSystem.h -CompileCpp=1 -Folder=Irrlicht/io -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit280] -FileName=CLimitReadFile.cpp -CompileCpp=1 -Folder=Irrlicht/io/file -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit281] -FileName=CLimitReadFile.h -CompileCpp=1 -Folder=Irrlicht/io/file -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit282] -FileName=CMemoryFile.cpp -Folder=Irrlicht/io/file -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit283] -FileName=CMemoryFile.h -Folder=Irrlicht/io/file -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit284] -FileName=CReadFile.cpp -Folder=Irrlicht/io/file -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit285] -FileName=CReadFile.h -Folder=Irrlicht/io/file -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit286] -FileName=CWriteFile.cpp -Folder=Irrlicht/io/file -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit287] -FileName=CWriteFile.h -Folder=Irrlicht/io/file -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit288] -FileName=CXMLReader.cpp -Folder=Irrlicht/io/xml -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit289] -FileName=CXMLReader.h -Folder=Irrlicht/io/xml -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit290] -FileName=CXMLWriter.cpp -Folder=Irrlicht/io/xml -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit291] -FileName=CXMLWriter.h -Folder=Irrlicht/io/xml -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit292] -FileName=CZipReader.cpp -Folder=Irrlicht/io/archive -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit293] -FileName=CZipReader.h -Folder=Irrlicht/io/archive -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit294] -FileName=irrXML.cpp -Folder=Irrlicht/io/xml -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit295] -FileName=zlib\adler32.c -Folder=Irrlicht/extern/zlib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit296] -FileName=zlib\compress.c -Folder=Irrlicht/extern/zlib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit297] -FileName=zlib\crc32.c -Folder=Irrlicht/extern/zlib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit298] -FileName=zlib\crc32.h -Folder=Irrlicht/extern/zlib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit299] -FileName=zlib\deflate.c -Folder=Irrlicht/extern/zlib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit300] -FileName=zlib\deflate.h -Folder=Irrlicht/extern/zlib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit301] -FileName=zlib\inffast.c -Folder=Irrlicht/extern/zlib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit302] -FileName=zlib\inffast.h -Folder=Irrlicht/extern/zlib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit303] -FileName=zlib\inflate.c -Folder=Irrlicht/extern/zlib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit304] -FileName=zlib\inftrees.c -Folder=Irrlicht/extern/zlib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit305] -FileName=zlib\inftrees.h -Folder=Irrlicht/extern/zlib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit306] -FileName=zlib\trees.c -Folder=Irrlicht/extern/zlib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit307] -FileName=zlib\trees.h -Folder=Irrlicht/extern/zlib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit308] -FileName=zlib\uncompr.c -Folder=Irrlicht/extern/zlib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit309] -FileName=zlib\zconf.h -Folder=Irrlicht/extern/zlib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit310] -FileName=zlib\zlib.h -Folder=Irrlicht/extern/zlib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit311] -FileName=zlib\zutil.c -Folder=Irrlicht/extern/zlib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit312] -FileName=zlib\zutil.h -Folder=Irrlicht/extern/zlib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit313] -FileName=jpeglib\cderror.h -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit314] -FileName=CSceneNodeAnimatorCameraFPS.h -CompileCpp=1 -Folder=Irrlicht/scene/animators -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit315] -FileName=CSceneNodeAnimatorCameraMaya.cpp -CompileCpp=1 -Folder=Irrlicht/scene/animators -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit316] -FileName=jpeglib\jcapimin.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit317] -FileName=jpeglib\jcapistd.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit318] -FileName=jpeglib\jccoefct.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit319] -FileName=jpeglib\jccolor.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit320] -FileName=jpeglib\jcdctmgr.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit321] -FileName=jpeglib\jchuff.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit322] -FileName=jpeglib\jchuff.h -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit323] -FileName=jpeglib\jcinit.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit324] -FileName=jpeglib\jcmainct.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit325] -FileName=jpeglib\jcmarker.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit326] -FileName=jpeglib\jcmaster.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit327] -FileName=jpeglib\jcomapi.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit328] -FileName=jpeglib\jconfig.h -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit329] -FileName=jpeglib\jcparam.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit330] -FileName=jpeglib\jcphuff.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit331] -FileName=jpeglib\jcprepct.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit332] -FileName=jpeglib\jcsample.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit333] -FileName=jpeglib\jctrans.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit334] -FileName=jpeglib\jdapimin.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit335] -FileName=jpeglib\jdapistd.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit336] -FileName=jpeglib\jdatadst.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit337] -FileName=jpeglib\jdatasrc.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit338] -FileName=jpeglib\jdcoefct.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit339] -FileName=jpeglib\jdcolor.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit340] -FileName=jpeglib\jdct.h -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit341] -FileName=jpeglib\jddctmgr.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit342] -FileName=jpeglib\jdhuff.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit343] -FileName=jpeglib\jdhuff.h -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit344] -FileName=jpeglib\jdinput.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit345] -FileName=jpeglib\jdmainct.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit346] -FileName=jpeglib\jdmarker.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit347] -FileName=jpeglib\jdmaster.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit348] -FileName=jpeglib\jdmerge.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit349] -FileName=jpeglib\jdphuff.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit350] -FileName=jpeglib\jdpostct.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit351] -FileName=jpeglib\jdsample.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit352] -FileName=jpeglib\jdtrans.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit353] -FileName=jpeglib\jerror.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit354] -FileName=jpeglib\jerror.h -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit355] -FileName=jpeglib\jfdctflt.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit356] -FileName=jpeglib\jfdctfst.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit357] -FileName=jpeglib\jfdctint.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit358] -FileName=jpeglib\jidctflt.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit359] -FileName=jpeglib\jidctfst.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit360] -FileName=jpeglib\jidctint.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit361] -FileName=jpeglib\jidctred.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit362] -FileName=jpeglib\jinclude.h -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit363] -FileName=jpeglib\jmemmgr.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit364] -FileName=jpeglib\jmemnobs.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit365] -FileName=jpeglib\jmemsys.h -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit366] -FileName=jpeglib\jmorecfg.h -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit367] -FileName=jpeglib\jpegint.h -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit368] -FileName=jpeglib\jpeglib.h -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit369] -FileName=jpeglib\jquant1.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit370] -FileName=jpeglib\jquant2.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit371] -FileName=jpeglib\jutils.c -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit372] -FileName=jpeglib\jversion.h -Folder=Irrlicht/extern/jpeglib -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit373] -FileName=CMD3MeshFileLoader.h -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit374] -FileName=CMD3MeshFileLoader.cpp -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit375] -FileName=CAnimatedMeshMD3.h -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit376] -FileName=CAnimatedMeshMD3.cpp -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit377] -FileName=CGUISpriteBank.h -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit378] -FileName=CGUISpriteBank.cpp -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit379] -FileName=..\..\include\IGUIFontBitmap.h -Folder=include/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit380] -FileName=..\..\include\IGUISpriteBank.h -Folder=include/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit381] -FileName=COpenGLExtensionHandler.cpp -Folder=Irrlicht/video/OpenGL -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit382] -FileName=CGUISpinBox.h -CompileCpp=1 -Folder=Irrlicht/gui -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit383] -FileName=CGUISpinBox.cpp -CompileCpp=1 -Folder=Irrlicht/gui -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit384] -FileName=..\..\include\IGUISpinBox.h -CompileCpp=1 -Folder=include/gui -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit385] -FileName=..\..\include\SViewFrustum.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit386] -FileName=..\..\include\triangle3d.h -CompileCpp=1 -Folder=include/core -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit387] -FileName=libpng\png.c -CompileCpp=0 -Folder=Irrlicht/extern/libpng -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit388] -FileName=libpng\png.h -CompileCpp=1 -Folder=Irrlicht/extern/libpng -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit389] -FileName=libpng\pngconf.h -CompileCpp=1 -Folder=Irrlicht/extern/libpng -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit390] -FileName=libpng\pngerror.c -Folder=Irrlicht/extern/libpng -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit391] -FileName=libpng\pngget.c -CompileCpp=0 -Folder=Irrlicht/extern/libpng -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit392] -FileName=libpng\pngmem.c -CompileCpp=0 -Folder=Irrlicht/extern/libpng -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit393] -FileName=libpng\pngpread.c -CompileCpp=0 -Folder=Irrlicht/extern/libpng -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit394] -FileName=libpng\pngread.c -CompileCpp=0 -Folder=Irrlicht/extern/libpng -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit395] -FileName=libpng\pngrio.c -CompileCpp=0 -Folder=Irrlicht/extern/libpng -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit396] -FileName=libpng\pngrtran.c -Folder=Irrlicht/extern/libpng -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit397] -FileName=libpng\pngrutil.c -Folder=Irrlicht/extern/libpng -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit398] -FileName=libpng\pngset.c -Folder=Irrlicht/extern/libpng -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit399] -FileName=libpng\pngtrans.c -Folder=Irrlicht/extern/libpng -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit400] -FileName=libpng\pngwio.c -Folder=Irrlicht/extern/libpng -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit401] -FileName=libpng\pngwrite.c -Folder=Irrlicht/extern/libpng -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit402] -FileName=libpng\pngwtran.c -Folder=Irrlicht/extern/libpng -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit403] -FileName=libpng\pngwutil.c -Folder=Irrlicht/extern/libpng -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit404] -FileName=CIrrDeviceLinux.cpp -Folder=Irrlicht/irr/IrrlichtDevice -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit405] -FileName=CIrrDeviceLinux.h -Folder=Irrlicht/irr/IrrlichtDevice -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit406] -FileName=CIrrDeviceStub.cpp -Folder=Irrlicht/irr/IrrlichtDevice -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit407] -FileName=CIrrDeviceStub.h -Folder=Irrlicht/irr/IrrlichtDevice -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit408] -FileName=CIrrDeviceWin32.cpp -Folder=Irrlicht/irr/IrrlichtDevice -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit409] -FileName=CIrrDeviceWin32.h -Folder=Irrlicht/irr/IrrlichtDevice -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit410] -FileName=CLogger.cpp -Folder=Irrlicht/irr -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit411] -FileName=CLogger.h -Folder=Irrlicht/irr -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit412] -FileName=COSOperator.cpp -Folder=Irrlicht/irr -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit413] -FileName=COSOperator.h -Folder=Irrlicht/irr -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit414] -FileName=CTimer.h -Folder=Irrlicht/irr -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit415] -FileName=IImagePresenter.h -Folder=Irrlicht/irr -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit416] -FileName=Irrlicht.cpp -Folder=Irrlicht/irr -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit417] -FileName=os.cpp -Folder=Irrlicht/irr -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit418] -FileName=os.h -Folder=Irrlicht/irr -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit419] -FileName=..\..\include\IrrCompileConfig.h -Folder=include -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit420] -FileName=CMeshCache.h -Folder=Irrlicht/scene/mesh -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit421] -FileName=CMeshCache.cpp -Folder=Irrlicht/scene/mesh -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit422] -FileName=COpenGLSLMaterialRenderer.h -Folder=Irrlicht/video/OpenGL -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit423] -FileName=COpenGLSLMaterialRenderer.cpp -Folder=Irrlicht/video/OpenGL -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit424] -FileName=CSoftwareTexture2.h -Folder=Irrlicht/video/Burning Video -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit425] -FileName=S4DVertex.h -Folder=Irrlicht/video/Burning Video -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit426] -FileName=SoftwareDriver2_compile_config.h -Folder=Irrlicht/video/Burning Video -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit427] -FileName=CSoftwareDriver2.h -Folder=Irrlicht/video/Burning Video -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit428] -FileName=CTRTextureGouraudNoZ2.cpp -Folder=Irrlicht/video/Burning Video -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit429] -FileName=CTRTextureLightMap2_M2.cpp -Folder=Irrlicht/video/Burning Video -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit430] -FileName=CTRTextureLightMap2_M4.cpp -Folder=Irrlicht/video/Burning Video -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit431] -FileName=CTRTextureLightMap2_M1.cpp -Folder=Irrlicht/video/Burning Video -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit432] -FileName=SoftwareDriver2_helper.h -Folder=Irrlicht/video/Burning Video -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit433] -FileName=CSoftwareDriver2.cpp -Folder=Irrlicht/video/Burning Video -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit434] -FileName=CSoftwareTexture2.cpp -Folder=Irrlicht/video/Burning Video -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit435] -FileName=CTRTextureGouraud2.cpp -Folder=Irrlicht/video/Burning Video -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[VersionInfo] -Major=0 -Minor=1 -Release=1 -Build=1 -LanguageID=1033 -CharsetID=1252 -CompanyName= -FileVersion=0.1 -FileDescription=Developed using the Dev-C++ IDE -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename=Irrlicht.dll -ProductName=Irrlicht -ProductVersion=0.1 -AutoIncBuildNr=0 - -[Unit436] -FileName=COgreMeshFileLoader.h -CompileCpp=1 -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit437] -FileName=COgreMeshFileLoader.cpp -CompileCpp=1 -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit438] -FileName=CDefaultSceneNodeFactory.h -CompileCpp=1 -Folder=Irrlicht/scene/nodes -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit439] -FileName=CDefaultSceneNodeAnimatorFactory.cpp -CompileCpp=1 -Folder=Irrlicht/scene/animators -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit440] -FileName=CDefaultSceneNodeAnimatorFactory.h -CompileCpp=1 -Folder=Irrlicht/scene/animators -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit441] -FileName=CDefaultSceneNodeFactory.cpp -CompileCpp=1 -Folder=Irrlicht/scene/nodes -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit442] -FileName=CAttributes.h -CompileCpp=1 -Folder=Irrlicht/io/attributes -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit443] -FileName=CAttributeImpl.h -CompileCpp=1 -Folder=Irrlicht/io/attributes -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit444] -FileName=CAttributes.cpp -CompileCpp=1 -Folder=Irrlicht/io/attributes -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit445] -FileName=CCubeSceneNode.h -CompileCpp=1 -Folder=Irrlicht/scene/nodes -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit446] -FileName=CCubeSceneNode.cpp -CompileCpp=1 -Folder=Irrlicht/scene/nodes -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit447] -FileName=CTRTextureGouraudAddNoZ2.cpp -CompileCpp=1 -Folder=Irrlicht/video/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit448] -FileName=CTRTextureGouraudAdd2.cpp -CompileCpp=1 -Folder=Irrlicht/video/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit449] -FileName=CTRGouraud2.cpp -CompileCpp=1 -Folder=Irrlicht/video/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit450] -FileName=CTRGouraudAlpha2.cpp -CompileCpp=1 -Folder=Irrlicht/video/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit451] -FileName=CTRGouraudAlphaNoZ2.cpp -CompileCpp=1 -Folder=Irrlicht/video/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit452] -FileName=CTRTextureDetailMap2.cpp -CompileCpp=1 -Folder=Irrlicht/video/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit453] -FileName=CTRTextureLightMap2_Add.cpp -CompileCpp=1 -Folder=Irrlicht/video/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit454] -FileName=CTRTextureWire2.cpp -CompileCpp=1 -Folder=Irrlicht/video/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit455] -FileName=CTRTextureGouraudVertexAlpha2.cpp -CompileCpp=1 -Folder=Irrlicht/video/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit456] -FileName=..\..\changes.txt -CompileCpp=1 -Folder=doc -Compile=0 -Link=0 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit457] -FileName=..\..\readme.txt -CompileCpp=1 -Folder=doc -Compile=0 -Link=0 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit458] -FileName=CSphereSceneNode.cpp -CompileCpp=1 -Folder=Irrlicht/scene/nodes -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit459] -FileName=CSphereSceneNode.h -CompileCpp=1 -Folder=Irrlicht/scene/nodes -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit460] -FileName=CPakReader.h -CompileCpp=1 -Folder=Irrlicht/io/archive -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit461] -FileName=CPakReader.cpp -CompileCpp=1 -Folder=Irrlicht/io/archive -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit462] -FileName=CSkyDomeSceneNode.h -CompileCpp=1 -Folder=Irrlicht/scene/nodes -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit463] -FileName=CSkyDomeSceneNode.cpp -CompileCpp=1 -Folder=Irrlicht/scene/nodes -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit464] -FileName=CImageWriterTGA.h -CompileCpp=1 -Folder=Irrlicht/video/Null/Writer -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit465] -FileName=CImageWriterBMP.cpp -CompileCpp=1 -Folder=Irrlicht/video/Null/Writer -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit466] -FileName=CImageWriterBMP.h -CompileCpp=1 -Folder=Irrlicht/video/Null/Writer -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit467] -FileName=CImageWriterJPG.cpp -CompileCpp=1 -Folder=Irrlicht/video/Null/Writer -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit468] -FileName=CImageWriterJPG.h -CompileCpp=1 -Folder=Irrlicht/video/Null/Writer -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit469] -FileName=CImageWriterPCX.cpp -CompileCpp=1 -Folder=Irrlicht/video/Null/Writer -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit470] -FileName=CImageWriterPCX.h -CompileCpp=1 -Folder=Irrlicht/video/Null/Writer -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit471] -FileName=CImageWriterPNG.cpp -Folder=Irrlicht/video/Null/Writer -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= -CompileCpp=1 - -[Unit472] -FileName=CImageWriterPNG.h -Folder=Irrlicht/video/Null/Writer -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= -CompileCpp=1 - -[Unit473] -FileName=CImageWriterPPM.cpp -CompileCpp=1 -Folder=Irrlicht/video/Null/Writer -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit474] -FileName=CImageWriterPPM.h -CompileCpp=1 -Folder=Irrlicht/video/Null/Writer -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit475] -FileName=CImageWriterPSD.cpp -CompileCpp=1 -Folder=Irrlicht/video/Null/Writer -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit476] -FileName=CImageWriterPSD.h -CompileCpp=1 -Folder=Irrlicht/video/Null/Writer -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit477] -FileName=CImageWriterTGA.cpp -CompileCpp=1 -Folder=Irrlicht/video/Null/Writer -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit478] -FileName=CTRTextureLightMapGouraud2_M4.cpp -CompileCpp=1 -Folder=Irrlicht/video/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit479] -FileName=CGUIColorSelectDialog.cpp -CompileCpp=1 -Folder=Irrlicht/gui -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit480] -FileName=IBurningShader.h -CompileCpp=1 -Folder=Irrlicht/video/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit481] -FileName=IBurningShader.cpp -CompileCpp=1 -Folder=Irrlicht/video/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit482] -FileName=IDepthBuffer.h -CompileCpp=1 -Folder=Irrlicht/video/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit483] -FileName=CDepthBuffer.h -CompileCpp=1 -Folder=Irrlicht/video/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit484] -FileName=CDepthBuffer.cpp -CompileCpp=1 -Folder=Irrlicht/video/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit485] -FileName=CQuake3ShaderSceneNode.h -CompileCpp=1 -Folder=Irrlicht/scene/nodes -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit486] -FileName=CQuake3ShaderSceneNode.cpp -CompileCpp=1 -Folder=Irrlicht/scene/nodes -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit487] -FileName=..\..\include\fast_atof.h -CompileCpp=1 -Folder=include -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit488] -FileName=CTRTextureBlend.cpp -CompileCpp=1 -Folder=Irrlicht/video/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit489] -FileName=CTRTextureGouraudAlpha.cpp -CompileCpp=1 -Folder=Irrlicht/video/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit490] -FileName=CTRTextureGouraudAlphaNoZ.cpp -CompileCpp=1 -Folder=Irrlicht/video/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit491] -FileName=CDefaultGUIElementFactory.cpp -CompileCpp=1 -Folder=Irrlicht/gui -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit492] -FileName=CDefaultGUIElementFactory.h -CompileCpp=1 -Folder=Irrlicht/gui -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit493] -FileName=CGUIColorSelectDialog.h -CompileCpp=1 -Folder=Irrlicht/gui -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit494] -FileName=CSoftware2MaterialRenderer.h -CompileCpp=1 -Folder=Irrlicht/video/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit495] -FileName=CXMLReaderImpl.h -CompileCpp=1 -Folder=Irrlicht/io/xml -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit496] -FileName=ITriangleRenderer.h -CompileCpp=1 -Folder=Irrlicht/video/Software -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit497] -FileName=..\..\include\EGUIElementTypes.h -Folder=include/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit498] -FileName=..\..\include\ESceneNodeAnimatorTypes.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit499] -FileName=..\..\include\ESceneNodeTypes.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit500] -FileName=..\..\include\ETerrainElements.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit501] -FileName=..\..\include\IAnimatedMeshMD2.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit502] -FileName=..\..\include\IAttributeExchangingObject.h -CompileCpp=1 -Folder=include/io -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit503] -FileName=..\..\include\IAttributes.h -CompileCpp=1 -Folder=include/io -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit504] -FileName=..\..\include\IDummyTransformationSceneNode.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit505] -FileName=..\..\include\IGPUProgrammingServices.h -CompileCpp=1 -Folder=include/video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit506] -FileName=..\..\include\IGUIColorSelectDialog.h -CompileCpp=1 -Folder=include/gui -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit507] -FileName=..\..\include\IGUIComboBox.h -CompileCpp=1 -Folder=include/gui -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit508] -FileName=..\..\include\IGUIContextMenu.h -CompileCpp=1 -Folder=include/gui -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit509] -FileName=..\..\include\IGUIEditBox.h -CompileCpp=1 -Folder=include/gui -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit510] -FileName=..\..\include\IGUIElementFactory.h -CompileCpp=1 -Folder=include/gui -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit511] -FileName=..\..\include\IGUIInOutFader.h -CompileCpp=1 -Folder=include/gui -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit512] -FileName=..\..\include\IGUIStaticText.h -CompileCpp=1 -Folder=include/gui -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit513] -FileName=..\..\include\IGUITabControl.h -CompileCpp=1 -Folder=include/gui -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit514] -FileName=..\..\include\IGUIToolbar.h -CompileCpp=1 -Folder=include/gui -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit515] -FileName=..\..\include\IImage.h -CompileCpp=1 -Folder=include/video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit516] -FileName=..\..\include\IImageLoader.h -CompileCpp=1 -Folder=include/video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit517] -FileName=..\..\include\IImageWriter.h -CompileCpp=1 -Folder=include/video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit518] -FileName=..\..\include\ILogger.h -CompileCpp=1 -Folder=include/io -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit519] -FileName=..\..\include\IMaterialRenderer.h -CompileCpp=1 -Folder=include/video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit520] -FileName=..\..\include\IMaterialRendererServices.h -CompileCpp=1 -Folder=include/video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit521] -FileName=..\..\include\IMeshCache.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit522] -FileName=..\..\include\IMeshLoader.h -CompileCpp=1 -Folder=include/io -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit523] -FileName=..\..\include\IMeshManipulator.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit524] -FileName=..\..\include\IMeshSceneNode.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit525] -FileName=..\..\include\IMetaTriangleSelector.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit526] -FileName=..\..\include\IOSOperator.h -CompileCpp=1 -Folder=include/io -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit527] -FileName=..\..\include\IParticleAffector.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit528] -FileName=..\..\include\IParticleEmitter.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit529] -FileName=..\..\include\IParticleSystemSceneNode.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit530] -FileName=..\..\include\IQ3Shader.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit531] -FileName=..\..\include\irrAllocator.h -CompileCpp=1 -Folder=include/core -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit532] -FileName=..\..\include\irrMap.h -CompileCpp=1 -Folder=include/core -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit533] -FileName=..\..\include\irrXML.h -CompileCpp=1 -Folder=include/io -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit534] -FileName=..\..\include\ISceneCollisionManager.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit535] -FileName=..\..\include\ISceneNodeAnimatorCollisionResponse.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit536] -FileName=..\..\include\ISceneNodeAnimatorFactory.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit537] -FileName=..\..\include\ISceneNodeFactory.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit538] -FileName=..\..\include\ISceneUserDataSerializer.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit539] -FileName=..\..\include\IShaderConstantSetCallBack.h -CompileCpp=1 -Folder=include/video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit540] -FileName=..\..\include\IShadowVolumeSceneNode.h -CompileCpp=1 -Folder=include/video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit541] -FileName=..\..\include\ITerrainSceneNode.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit542] -FileName=..\..\include\ITextSceneNode.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit543] -FileName=..\..\include\ITimer.h -CompileCpp=1 -Folder=include -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit544] -FileName=..\..\include\ITriangleSelector.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit545] -FileName=..\..\include\IVideoModeList.h -CompileCpp=1 -Folder=include/video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit546] -FileName=..\..\include\IWriteFile.h -CompileCpp=1 -Folder=include/io -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit547] -FileName=..\..\include\IXMLReader.h -CompileCpp=1 -Folder=include/io -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit548] -FileName=..\..\include\IXMLWriter.h -CompileCpp=1 -Folder=include/io -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit549] -FileName=..\..\include\quaternion.h -CompileCpp=1 -Folder=include/core -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit550] -FileName=..\..\include\SAnimatedMesh.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit551] -FileName=..\..\include\SceneParameters.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit552] -FileName=..\..\include\IReferenceCounted.h -CompileCpp=1 -Folder=include -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit553] -FileName=CParticleAnimatedMeshSceneNodeEmitter.h -CompileCpp=1 -Folder=Irrlicht/scene/nodes/particles -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit554] -FileName=CParticleAnimatedMeshSceneNodeEmitter.cpp -CompileCpp=1 -Folder=Irrlicht/scene/nodes/particles -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit555] -FileName=CParticleSphereEmitter.h -CompileCpp=1 -Folder=Irrlicht/scene/nodes/particles -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit556] -FileName=CParticleAttractionAffector.cpp -CompileCpp=1 -Folder=Irrlicht/scene/nodes/particles -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit557] -FileName=CParticleAttractionAffector.h -CompileCpp=1 -Folder=Irrlicht/scene/nodes/particles -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit558] -FileName=CParticleCylinderEmitter.cpp -CompileCpp=1 -Folder=Irrlicht/scene/nodes/particles -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit559] -FileName=CParticleCylinderEmitter.h -CompileCpp=1 -Folder=Irrlicht/scene/nodes/particles -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit560] -FileName=CParticleMeshEmitter.cpp -CompileCpp=1 -Folder=Irrlicht/scene/nodes/particles -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit561] -FileName=CParticleMeshEmitter.h -CompileCpp=1 -Folder=Irrlicht/scene/nodes/particles -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit562] -FileName=CParticleRingEmitter.cpp -CompileCpp=1 -Folder=Irrlicht/scene/nodes/particles -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit563] -FileName=CParticleRingEmitter.h -CompileCpp=1 -Folder=Irrlicht/scene/nodes/particles -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit564] -FileName=CParticleRotationAffector.cpp -CompileCpp=1 -Folder=Irrlicht/scene/nodes/particles -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit565] -FileName=CParticleRotationAffector.h -CompileCpp=1 -Folder=Irrlicht/scene/nodes/particles -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit566] -FileName=CParticleSphereEmitter.cpp -CompileCpp=1 -Folder=Irrlicht/scene/nodes/particles -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit567] -FileName=CIrrMeshWriter.h -CompileCpp=1 -Folder=Irrlicht/scene/mesh/writers -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit568] -FileName=CIrrMeshWriter.cpp -CompileCpp=1 -Folder=Irrlicht/scene/mesh/writers -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit569] -FileName=CColladaMeshWriter.h -CompileCpp=1 -Folder=Irrlicht/scene/mesh/writers -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit570] -FileName=CColladaMeshWriter.cpp -CompileCpp=1 -Folder=Irrlicht/scene/mesh/writers -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit571] -FileName=CIrrMeshFileLoader.h -CompileCpp=1 -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit572] -FileName=CIrrMeshFileLoader.cpp -CompileCpp=1 -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit573] -FileName=CBSPMeshFileLoader.h -CompileCpp=1 -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit574] -FileName=CBSPMeshFileLoader.cpp -CompileCpp=1 -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit575] -FileName=CMD2MeshFileLoader.h -CompileCpp=1 -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit576] -FileName=CMD2MeshFileLoader.cpp -CompileCpp=1 -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit577] -FileName=CMS3DMeshFileLoader.h -CompileCpp=1 -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit578] -FileName=CMS3DMeshFileLoader.cpp -CompileCpp=1 -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit579] -FileName=CB3DMeshFileLoader.h -CompileCpp=1 -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit580] -FileName=CB3DMeshFileLoader.cpp -CompileCpp=1 -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit581] -FileName=CSkinnedMesh.h -CompileCpp=1 -Folder=Irrlicht/scene/mesh -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit582] -FileName=CSkinnedMesh.cpp -CompileCpp=1 -Folder=Irrlicht/scene/mesh -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit583] -FileName=CBoneSceneNode.h -CompileCpp=1 -Folder=Irrlicht/scene/nodes -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit584] -FileName=CBoneSceneNode.cpp -CompileCpp=1 -Folder=Irrlicht/scene/nodes -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit585] -FileName=CSTLMeshWriter.cpp -CompileCpp=1 -Folder=Irrlicht/scene/mesh/writers -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit586] -FileName=CSTLMeshFileLoader.cpp -CompileCpp=1 -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit587] -FileName=CImageLoaderPPM.cpp -CompileCpp=1 -Folder=Irrlicht/video/Null/Loader -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit588] -FileName=CImageLoaderPPM.h -CompileCpp=1 -Folder=Irrlicht/video/Null/Loader -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit589] -FileName=CBurningShader_Raster_Reference.cpp -CompileCpp=1 -Folder=Irrlicht/video/Burning Video -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit590] -FileName=CImageLoaderWAL.cpp -CompileCpp=1 -Folder=Irrlicht/video/Null/Loader -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit591] -FileName=CImageLoaderWAL.h -Folder=Irrlicht/video/Null/Loader -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit592] -FileName=CGUITable.h -Folder=Irrlicht/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit593] -FileName=CGUITable.cpp -CompileCpp=1 -Folder=Irrlicht/gui -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit594] -FileName=..\..\include\IGUITable.h -Folder=include/gui -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit595] -FileName=CVolumeLightSceneNode.h -CompileCpp=1 -Folder=Irrlicht/scene/nodes -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit596] -FileName=CVolumeLightSceneNode.cpp -CompileCpp=1 -Folder=Irrlicht/scene/nodes -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit597] -FileName=..\..\include\IVolumeLightSceneNode.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit598] -FileName=CLWOMeshFileLoader.cpp -CompileCpp=1 -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit599] -FileName=CLWOMeshFileLoader.h -CompileCpp=1 -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit600] -FileName=..\..\include\ISceneNodeAnimatorCameraMaya.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit601] -FileName=..\..\include\ISceneNodeAnimatorCameraFPS.h -CompileCpp=1 -Folder=include/scene -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit602] -FileName=CSceneNodeAnimatorCameraMaya.h -Folder=Irrlicht/scene/animators -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit603] -FileName=CSceneNodeAnimatorCameraFPS.cpp -Folder=Irrlicht/scene/animators -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit604] -FileName=COBJMeshWriter.cpp -CompileCpp=1 -Folder=Irrlicht/scene/mesh/writers -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit605] -FileName=..\..\include\SSkinMeshBuffer.h -Folder=include/scene -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit606] -FileName=CParticleScaleAffector.cpp -Folder=Irrlicht/scene/nodes/particles -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit607] -FileName=CParticleScaleAffector.h -Folder=Irrlicht/scene/nodes/particles -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit608] -FileName=CGUIImageList.cpp -CompileCpp=1 -Folder=Irrlicht/gui -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit609] -FileName=CGUIImageList.h -CompileCpp=1 -Folder=Irrlicht/gui -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit610] -FileName=CGUITreeView.cpp -CompileCpp=1 -Folder=Irrlicht/gui -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit611] -FileName=CGUITreeView.h -CompileCpp=1 -Folder=Irrlicht/gui -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit612] -FileName=CIrrDeviceConsole.cpp -CompileCpp=1 -Folder=Irrlicht/irr/IrrlichtDevice -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit613] -FileName=CIrrDeviceConsole.h -CompileCpp=1 -Folder=Irrlicht/irr/IrrlichtDevice -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit614] -FileName=CPLYMeshWriter.cpp -CompileCpp=1 -Folder=Irrlicht/scene/mesh/writers -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit615] -FileName=CPLYMeshWriter.h -CompileCpp=1 -Folder=Irrlicht/scene/mesh/writers -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit616] -FileName=CPLYMeshFileLoader.cpp -CompileCpp=1 -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit617] -FileName=CPLYMeshFileLoader.h -CompileCpp=1 -Folder=Irrlicht/scene/mesh/loaders -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit618] -FileName=CIrrDeviceSDL.cpp -CompileCpp=1 -Folder=Irrlicht/irr/IrrlichtDevice -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit619] -FileName=CIrrDeviceSDL.h -CompileCpp=1 -Folder=Irrlicht/irr/IrrlichtDevice -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit620] -FileName=CImageLoaderRGB.cpp -CompileCpp=1 -Folder=Irrlicht/video/Null/Loader -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit621] -FileName=CImageLoaderRGB.h -CompileCpp=1 -Folder=Irrlicht/video/Null/Loader -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit622] -FileName=CTarReader.cpp -Folder=Irrlicht/io/archive -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit623] -FileName=CTarReader.h -Folder=Irrlicht/io/archive -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - - -[Unit624] -FileName=CMountPointReader.cpp -Folder=Irrlicht/io/archive -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit625] -FileName=CMountPointReader.h -Folder=Irrlicht/io/archive -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - diff --git a/irrlicht-1.6/source/Irrlicht/Irrlicht.dsp b/irrlicht-1.6/source/Irrlicht/Irrlicht.dsp deleted file mode 100644 index f0db08c4d..000000000 --- a/irrlicht-1.6/source/Irrlicht/Irrlicht.dsp +++ /dev/null @@ -1,2365 +0,0 @@ -# Microsoft Developer Studio Project File - Name="Irrlicht" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** NICHT BEARBEITEN ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=Irrlicht - Win32 Debug -!MESSAGE Dies ist kein gltiges Makefile. Zum Erstellen dieses Projekts mit NMAKE -!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und fhren Sie den Befehl -!MESSAGE -!MESSAGE NMAKE /f "Irrlicht.mak". -!MESSAGE -!MESSAGE Sie knnen beim Ausfhren von NMAKE eine Konfiguration angeben -!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: -!MESSAGE -!MESSAGE NMAKE /f "Irrlicht.mak" CFG="Irrlicht - Win32 Debug" -!MESSAGE -!MESSAGE Fr die Konfiguration stehen zur Auswahl: -!MESSAGE -!MESSAGE "Irrlicht - Win32 Release" (basierend auf "Win32 (x86) Dynamic-Link Library") -!MESSAGE "Irrlicht - Win32 Debug" (basierend auf "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "Irrlicht - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "..\Release" -# PROP Intermediate_Dir "..\Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IRRLICHT_EXPORTS" /Yu"stdafx.h" /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /I "../../include" /I "zlib" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IRRLICHT_EXPORTS" /FD /c -# SUBTRACT CPP /YX /Yc /Yu -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0xc07 /d "NDEBUG" -# ADD RSC /l 0xc07 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 - -!ELSEIF "$(CFG)" == "Irrlicht - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "..\Debug" -# PROP Intermediate_Dir "..\Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IRRLICHT_EXPORTS" /Yu"stdafx.h" /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../include" /I "zlib" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IRRLICHT_EXPORTS" /FD /GZ /c -# SUBTRACT CPP /YX /Yc /Yu -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0xc07 /d "_DEBUG" -# ADD RSC /l 0xc07 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "Irrlicht - Win32 Release" -# Name "Irrlicht - Win32 Debug" -# Begin Group "include" - -# PROP Default_Filter "" -# Begin Group "video" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\include\EDriverTypes.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IGPUProgrammingServices.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\ITexture.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IVideoDriver.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\S3DVertex.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\SColor.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\SLight.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\SMaterial.h -# End Source File -# End Group -# Begin Group "core" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\include\aabbox3d.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\dimension2d.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\heapsort.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\irrAllocator.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\irrArray.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\irrList.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\irrMath.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\irrString.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\line2d.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\line3d.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\matrix4.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\plane3d.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\position2d.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\rect.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\vector2d.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\vector3d.h -# End Source File -# End Group -# Begin Group "io" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\include\IFileList.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IFileSystem.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IReadFile.H -# End Source File -# End Group -# Begin Group "scene" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\include\IAnimatedMesh.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IAnimatedMeshSceneNode.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IBillboardSceneNode.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\ICameraSceneNode.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\ILightSceneNode.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IMesh.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IMeshBuffer.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IQ3LevelMesh.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\ISceneManager.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\ISceneNode.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\ISceneNodeAnimator.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\SMesh.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\SMeshBuffer.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\SMeshBufferLightMap.h -# End Source File -# End Group -# Begin Group "gui" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\include\ICursorControl.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IGUIButton.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IGUICheckbox.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IGUIElement.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IGUIEnvironment.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IGUIFileOpenDialog.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IGUIFont.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IGUIImage.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IGUIListBox.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IGUIMeshViewer.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IGUIScrollBar.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IGUISkin.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IGUIWindow.h -# End Source File -# End Group -# Begin Source File - -SOURCE=..\..\include\IEventReceiver.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IReferenceCounted.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\Irrlicht.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\IrrlichtDevice.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\irrTypes.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\Keycodes.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\SIrrCreationParameters.h -# End Source File -# End Group -# Begin Group "gui_impl" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\BuiltInFont.h -# End Source File -# Begin Source File - -SOURCE=.\CDefaultGUIElementFactory.cpp -# End Source File -# Begin Source File - -SOURCE=.\CDefaultGUIElementFactory.h -# End Source File -# Begin Source File - -SOURCE=.\CGUIButton.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIButton.h -# End Source File -# Begin Source File - -SOURCE=.\CGUICheckBox.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUICheckbox.h -# End Source File -# Begin Source File - -SOURCE=.\CGUIColorSelectDialog.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIColorSelectDialog.h -# End Source File -# Begin Source File - -SOURCE=.\CGUIComboBox.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIComboBox.h -# End Source File -# Begin Source File - -SOURCE=.\CGUIContextMenu.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIContextMenu.h -# End Source File -# Begin Source File - -SOURCE=.\CGUIEditBox.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIEditBox.h -# End Source File -# Begin Source File - -SOURCE=.\CGUIEnvironment.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIEnvironment.h -# End Source File -# Begin Source File - -SOURCE=.\CGUIFileOpenDialog.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIFileOpenDialog.h -# End Source File -# Begin Source File - -SOURCE=.\CGUIFont.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIFont.h -# End Source File -# Begin Source File - -SOURCE=.\CGUIImage.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIImage.H -# End Source File -# Begin Source File - -SOURCE=.\CGUIInOutFader.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIInOutFader.h -# End Source File -# Begin Source File - -SOURCE=.\CGUIListBox.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIListBox.h -# End Source File -# Begin Source File - -SOURCE=.\CGUIMenu.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIMenu.h -# End Source File -# Begin Source File - -SOURCE=.\CGUIMeshViewer.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIMeshViewer.h -# End Source File -# Begin Source File - -SOURCE=.\CGUIMessageBox.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIMessageBox.h -# End Source File -# Begin Source File - -SOURCE=.\CGUIModalScreen.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIModalScreen.h -# End Source File -# Begin Source File - -SOURCE=.\CGUIScrollBar.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIScrollBar.h -# End Source File -# Begin Source File - -SOURCE=.\CGUISkin.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUISkin.h -# End Source File -# Begin Source File - -SOURCE=.\CGUISpriteBank.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUISpriteBank.h -# End Source File -# Begin Source File - -SOURCE=.\CGUIStaticText.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIStaticText.h -# End Source File -# Begin Source File - -SOURCE=.\CGUITabControl.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUITabControl.h -# End Source File -# Begin Source File - -SOURCE=.\CGUIToolBar.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIToolBar.h -# End Source File -# Begin Source File - -SOURCE=.\CGUIWindow.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUIWindow.h -# End Source File -# Begin Source File - -SOURCE=.\GUIIcons.h -# End Source File -# End Group -# Begin Group "video_impl" - -# PROP Default_Filter "" -# Begin Group "Software" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\CSoftwareDriver.cpp -# End Source File -# Begin Source File - -SOURCE=.\CSoftwareDriver.h -# End Source File -# Begin Source File - -SOURCE=.\CSoftwareTexture.cpp -# End Source File -# Begin Source File - -SOURCE=.\CSoftwareTexture.h -# End Source File -# Begin Source File - -SOURCE=.\CTRFlat.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRFlatWire.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRGouraud.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRGouraudWire.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureFlat.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureFlatWire.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureGouraud.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureGouraud.h -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureGouraudAdd.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureGouraudNoZ.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureGouraudWire.cpp -# End Source File -# Begin Source File - -SOURCE=.\CZBuffer.cpp -# End Source File -# Begin Source File - -SOURCE=.\CZBuffer.h -# End Source File -# Begin Source File - -SOURCE=.\ITriangleRenderer.h -# End Source File -# Begin Source File - -SOURCE=.\IZBuffer.h -# End Source File -# Begin Source File - -SOURCE=.\S2DVertex.h -# End Source File -# End Group -# Begin Group "OpenGL" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\COpenGLDriver.cpp -# End Source File -# Begin Source File - -SOURCE=.\COpenGLDriver.h -# End Source File -# Begin Source File - -SOURCE=.\COpenGLExtensionHandler.cpp -# End Source File -# Begin Source File - -SOURCE=.\COpenGLExtensionHandler.h -# End Source File -# Begin Source File - -SOURCE=.\COpenGLMaterialRenderer.h -# End Source File -# Begin Source File - -SOURCE=.\COpenGLNormalMapRenderer.cpp -# End Source File -# Begin Source File - -SOURCE=.\COpenGLNormalMapRenderer.h -# End Source File -# Begin Source File - -SOURCE=.\COpenGLParallaxMapRenderer.cpp -# End Source File -# Begin Source File - -SOURCE=.\COpenGLParallaxMapRenderer.h -# End Source File -# Begin Source File - -SOURCE=.\COpenGLShaderMaterialRenderer.cpp -# End Source File -# Begin Source File - -SOURCE=.\COpenGLShaderMaterialRenderer.h -# End Source File -# Begin Source File - -SOURCE=.\COpenGLSLMaterialRenderer.cpp -# End Source File -# Begin Source File - -SOURCE=.\COpenGLSLMaterialRenderer.h -# End Source File -# Begin Source File - -SOURCE=.\COpenGLTexture.cpp -# End Source File -# Begin Source File - -SOURCE=.\COpenGLTexture.h -# End Source File -# Begin Source File - -SOURCE=.\glext.h -# End Source File -# End Group -# Begin Group "DirectX8" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\CD3D8Driver.cpp -# End Source File -# Begin Source File - -SOURCE=.\CD3D8Driver.h -# End Source File -# Begin Source File - -SOURCE=.\CD3D8MaterialRenderer.h -# End Source File -# Begin Source File - -SOURCE=.\CD3D8NormalMapRenderer.cpp -# End Source File -# Begin Source File - -SOURCE=.\CD3D8NormalMapRenderer.h -# End Source File -# Begin Source File - -SOURCE=.\CD3D8ParallaxMapRenderer.cpp -# End Source File -# Begin Source File - -SOURCE=.\CD3D8ParallaxMapRenderer.h -# End Source File -# Begin Source File - -SOURCE=.\CD3D8ShaderMaterialRenderer.cpp -# End Source File -# Begin Source File - -SOURCE=.\CD3D8ShaderMaterialRenderer.h -# End Source File -# Begin Source File - -SOURCE=.\CD3D8Texture.cpp -# End Source File -# Begin Source File - -SOURCE=.\CD3D8Texture.h -# End Source File -# End Group -# Begin Group "Null" - -# PROP Default_Filter "" -# Begin Group "ImageWriter" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\CImageWriterBMP.cpp -# End Source File -# Begin Source File - -SOURCE=.\CImageWriterBMP.h -# End Source File -# Begin Source File - -SOURCE=.\CImageWriterJPG.cpp -# End Source File -# Begin Source File - -SOURCE=.\CImageWriterJPG.h -# End Source File -# Begin Source File - -SOURCE=.\CImageWriterPCX.cpp -# End Source File -# Begin Source File - -SOURCE=.\CImageWriterPCX.h -# End Source File -# Begin Source File - -SOURCE=.\CImageWriterPNG.cpp -# End Source File -# Begin Source File - -SOURCE=.\CImageWriterPNG.h -# End Source File -# Begin Source File - -SOURCE=.\CImageWriterPPM.cpp -# End Source File -# Begin Source File - -SOURCE=.\CImageWriterPPM.h -# End Source File -# Begin Source File - -SOURCE=.\CImageWriterPSD.cpp -# End Source File -# Begin Source File - -SOURCE=.\CImageWriterPSD.h -# End Source File -# Begin Source File - -SOURCE=.\CImageWriterTGA.cpp -# End Source File -# Begin Source File - -SOURCE=.\CImageWriterTGA.h -# End Source File -# End Group -# Begin Source File - -SOURCE=.\CColorConverter.cpp -# End Source File -# Begin Source File - -SOURCE=.\CColorConverter.h -# End Source File -# Begin Source File - -SOURCE=.\CFPSCounter.cpp -# End Source File -# Begin Source File - -SOURCE=.\CFPSCounter.h -# End Source File -# Begin Source File - -SOURCE=.\CImage.cpp -# End Source File -# Begin Source File - -SOURCE=.\CImage.h -# End Source File -# Begin Source File - -SOURCE=.\CImageLoaderBMP.cpp -# End Source File -# Begin Source File - -SOURCE=.\CImageLoaderBMP.h -# End Source File -# Begin Source File - -SOURCE=.\CImageLoaderJPG.cpp -# End Source File -# Begin Source File - -SOURCE=.\CImageLoaderJPG.h -# End Source File -# Begin Source File - -SOURCE=.\CImageLoaderPCX.cpp -# End Source File -# Begin Source File - -SOURCE=.\CImageLoaderPCX.h -# End Source File -# Begin Source File - -SOURCE=.\CImageLoaderPNG.cpp -# End Source File -# Begin Source File - -SOURCE=.\CImageLoaderPNG.h -# End Source File -# Begin Source File - -SOURCE=.\CImageLoaderPSD.cpp -# End Source File -# Begin Source File - -SOURCE=.\CImageLoaderPSD.h -# End Source File -# Begin Source File - -SOURCE=.\CImageLoaderTGA.cpp -# End Source File -# Begin Source File - -SOURCE=.\CImageLoaderTGA.h -# End Source File -# Begin Source File - -SOURCE=.\CNullDriver.cpp -# End Source File -# Begin Source File - -SOURCE=.\CNullDriver.h -# End Source File -# End Group -# Begin Group "DirectX9" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\CD3D9Driver.cpp -# End Source File -# Begin Source File - -SOURCE=.\CD3D9Driver.h -# End Source File -# Begin Source File - -SOURCE=.\CD3D9HLSLMaterialRenderer.cpp -# End Source File -# Begin Source File - -SOURCE=.\CD3D9HLSLMaterialRenderer.h -# End Source File -# Begin Source File - -SOURCE=.\CD3D9MaterialRenderer.h -# End Source File -# Begin Source File - -SOURCE=.\CD3D9NormalMapRenderer.cpp -# End Source File -# Begin Source File - -SOURCE=.\CD3D9NormalMapRenderer.h -# End Source File -# Begin Source File - -SOURCE=.\CD3D9ParallaxMapRenderer.cpp -# End Source File -# Begin Source File - -SOURCE=.\CD3D9ParallaxMapRenderer.h -# End Source File -# Begin Source File - -SOURCE=.\CD3D9ShaderMaterialRenderer.cpp -# End Source File -# Begin Source File - -SOURCE=.\CD3D9ShaderMaterialRenderer.h -# End Source File -# Begin Source File - -SOURCE=.\CD3D9Texture.cpp -# End Source File -# Begin Source File - -SOURCE=.\CD3D9Texture.h -# End Source File -# End Group -# Begin Group "Software2" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\CDepthBuffer.cpp -# End Source File -# Begin Source File - -SOURCE=.\CDepthBuffer.h -# End Source File -# Begin Source File - -SOURCE=.\CSoftware2MaterialRenderer.h -# End Source File -# Begin Source File - -SOURCE=.\CSoftwareDriver2.cpp -# End Source File -# Begin Source File - -SOURCE=.\CSoftwareDriver2.h -# End Source File -# Begin Source File - -SOURCE=.\CSoftwareTexture2.cpp -# End Source File -# Begin Source File - -SOURCE=.\CSoftwareTexture2.h -# End Source File -# Begin Source File - -SOURCE=.\CTRGouraud2.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRGouraudAlpha2.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRGouraudAlphaNoZ2.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureBlend.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureDetailMap2.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureGouraud2.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureGouraudAdd2.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureGouraudAddNoZ2.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureGouraudAlpha.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureGouraudAlphaNoZ.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureGouraudNoZ2.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureGouraudVertexAlpha2.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureLightMap2_Add.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureLightMap2_M1.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureLightMap2_M1.h -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureLightMap2_M2.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureLightMap2_M4.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureLightMapGouraud2_M4.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTRTextureWire2.cpp -# End Source File -# Begin Source File - -SOURCE=.\IBurningShader.cpp -# End Source File -# Begin Source File - -SOURCE=.\IBurningShader.h -# End Source File -# Begin Source File - -SOURCE=.\IDepthBuffer.h -# End Source File -# Begin Source File - -SOURCE=.\S4DVertex.h -# End Source File -# Begin Source File - -SOURCE=.\SoftwareDriver2_compile_config.h -# End Source File -# Begin Source File - -SOURCE=.\SoftwareDriver2_helper.h -# End Source File -# End Group -# Begin Source File - -SOURCE=.\CVideoModeList.cpp -# End Source File -# Begin Source File - -SOURCE=.\CVideoModeList.h -# End Source File -# End Group -# Begin Group "scene_impl" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\C3DSMeshFileLoader.cpp -# End Source File -# Begin Source File - -SOURCE=.\C3DSMeshFileLoader.h -# End Source File -# Begin Source File - -SOURCE=.\CAnimatedMeshMD2.cpp -# End Source File -# Begin Source File - -SOURCE=.\CAnimatedMeshMD2.h -# End Source File -# Begin Source File - -SOURCE=.\CAnimatedMeshMD3.cpp -# End Source File -# Begin Source File - -SOURCE=.\CAnimatedMeshMD3.h -# End Source File -# Begin Source File - -SOURCE=.\CAnimatedMeshSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CAnimatedMeshSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CB3DMeshFileLoader.cpp -# End Source File -# Begin Source File - -SOURCE=.\CB3DMeshFileLoader.h -# End Source File -# Begin Source File - -SOURCE=.\CBillboardSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CBillboardSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CBoneSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CBoneSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CBSPMeshFileLoader.cpp -# End Source File -# Begin Source File - -SOURCE=.\CBSPMeshFileLoader.h -# End Source File -# Begin Source File - -SOURCE=.\CCameraFPSSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CCameraFPSSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CCameraMayaSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CCameraMayaSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CCameraSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CCameraSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CColladaFileLoader.cpp -# End Source File -# Begin Source File - -SOURCE=.\CColladaFileLoader.h -# End Source File -# Begin Source File - -SOURCE=.\CColladaMeshWriter.cpp -# End Source File -# Begin Source File - -SOURCE=.\CCSMLoader.cpp -# End Source File -# Begin Source File - -SOURCE=.\CCSMLoader.h -# End Source File -# Begin Source File - -SOURCE=.\CCubeSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CCubeSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CDefaultSceneNodeAnimatorFactory.cpp -# End Source File -# Begin Source File - -SOURCE=.\CDefaultSceneNodeAnimatorFactory.h -# End Source File -# Begin Source File - -SOURCE=.\CDefaultSceneNodeFactory.cpp -# End Source File -# Begin Source File - -SOURCE=.\CDefaultSceneNodeFactory.h -# End Source File -# Begin Source File - -SOURCE=.\CDMFLoader.cpp -# End Source File -# Begin Source File - -SOURCE=.\CDMFLoader.h -# End Source File -# Begin Source File - -SOURCE=.\CDummyTransformationSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CDummyTransformationSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CEmptySceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CEmptySceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CGeometryCreator.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGeometryCreator.h -# End Source File -# Begin Source File - -SOURCE=.\CGUISpinBox.cpp -# End Source File -# Begin Source File - -SOURCE=.\CGUISpinBox.h -# End Source File -# Begin Source File - -SOURCE=.\CImageLoaderPPM.cpp -# End Source File -# Begin Source File - -SOURCE=.\CIrrDeviceSDL.cpp -# End Source File -# Begin Source File - -SOURCE=.\CIrrDeviceSDL.h -# End Source File -# Begin Source File - -SOURCE=.\CIrrMeshFileLoader.cpp -# End Source File -# Begin Source File - -SOURCE=.\CIrrMeshWriter.cpp -# End Source File -# Begin Source File - -SOURCE=.\CLightSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CLightSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CLMTSMeshFileLoader.cpp -# End Source File -# Begin Source File - -SOURCE=.\CLMTSMeshFileLoader.h -# End Source File -# Begin Source File - -SOURCE=.\CMD2MeshFileLoader.cpp -# End Source File -# Begin Source File - -SOURCE=.\CMD2MeshFileLoader.h -# End Source File -# Begin Source File - -SOURCE=.\CMD3MeshFileLoader.cpp -# End Source File -# Begin Source File - -SOURCE=.\CMD3MeshFileLoader.h -# End Source File -# Begin Source File - -SOURCE=.\CMeshCache.cpp -# End Source File -# Begin Source File - -SOURCE=.\CMeshCache.h -# End Source File -# Begin Source File - -SOURCE=.\CMeshManipulator.cpp -# End Source File -# Begin Source File - -SOURCE=.\CMeshManipulator.h -# End Source File -# Begin Source File - -SOURCE=.\CMeshSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CMeshSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CMetaTriangleSelector.cpp -# End Source File -# Begin Source File - -SOURCE=.\CMetaTriangleSelector.h -# End Source File -# Begin Source File - -SOURCE=.\CMS3DMeshFileLoader.cpp -# End Source File -# Begin Source File - -SOURCE=.\CMS3DMeshFileLoader.h -# End Source File -# Begin Source File - -SOURCE=.\CMY3DHelper.h -# End Source File -# Begin Source File - -SOURCE=.\CMY3DMeshFileLoader.cpp -# End Source File -# Begin Source File - -SOURCE=.\CMY3DMeshFileLoader.h -# End Source File -# Begin Source File - -SOURCE=.\CMY3DStuff.h -# End Source File -# Begin Source File - -SOURCE=.\COBJMeshFileLoader.cpp -# End Source File -# Begin Source File - -SOURCE=.\COBJMeshFileLoader.h -# End Source File -# Begin Source File - -SOURCE=.\COCTLoader.cpp -# End Source File -# Begin Source File - -SOURCE=.\COCTLoader.h -# End Source File -# Begin Source File - -SOURCE=.\COctTreeSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\COctTreeSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\COctTreeTriangleSelector.cpp -# End Source File -# Begin Source File - -SOURCE=.\COctTreeTriangleSelector.h -# End Source File -# Begin Source File - -SOURCE=.\COgreMeshFileLoader.cpp -# End Source File -# Begin Source File - -SOURCE=.\COgreMeshFileLoader.h -# End Source File -# Begin Source File - -SOURCE=.\CParticleAnimatedMeshSceneNodeEmitter.cpp -# End Source File -# Begin Source File - -SOURCE=.\CParticleAnimatedMeshSceneNodeEmitter.h -# End Source File -# Begin Source File - -SOURCE=.\CParticleAttractionAffector.cpp -# End Source File -# Begin Source File - -SOURCE=.\CParticleAttractionAffector.h -# End Source File -# Begin Source File - -SOURCE=.\CParticleBoxEmitter.cpp -# End Source File -# Begin Source File - -SOURCE=.\CParticleBoxEmitter.h -# End Source File -# Begin Source File - -SOURCE=.\CParticleCylinderEmitter.cpp -# End Source File -# Begin Source File - -SOURCE=.\CParticleCylinderEmitter.h -# End Source File -# Begin Source File - -SOURCE=.\CParticleFadeOutAffector.cpp -# End Source File -# Begin Source File - -SOURCE=.\CParticleFadeOutAffector.h -# End Source File -# Begin Source File - -SOURCE=.\CParticleGravityAffector.cpp -# End Source File -# Begin Source File - -SOURCE=.\CParticleGravityAffector.h -# End Source File -# Begin Source File - -SOURCE=.\CParticleMeshEmitter.cpp -# End Source File -# Begin Source File - -SOURCE=.\CParticleMeshEmitter.h -# End Source File -# Begin Source File - -SOURCE=.\CParticlePointEmitter.cpp -# End Source File -# Begin Source File - -SOURCE=.\CParticlePointEmitter.h -# End Source File -# Begin Source File - -SOURCE=.\CParticleRingEmitter.cpp -# End Source File -# Begin Source File - -SOURCE=.\CParticleRingEmitter.h -# End Source File -# Begin Source File - -SOURCE=.\CParticleRotationAffector.cpp -# End Source File -# Begin Source File - -SOURCE=.\CParticleRotationAffector.h -# End Source File -# Begin Source File - -SOURCE=.\CParticleSphereEmitter.cpp -# End Source File -# Begin Source File - -SOURCE=.\CParticleSphereEmitter.h -# End Source File -# Begin Source File - -SOURCE=.\CParticleSystemSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CParticleSystemSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CQ3LevelMesh.cpp -# End Source File -# Begin Source File - -SOURCE=.\CQ3LevelMesh.h -# End Source File -# Begin Source File - -SOURCE=.\CQuake3ShaderSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CQuake3ShaderSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CSceneCollisionManager.cpp -# End Source File -# Begin Source File - -SOURCE=.\CSceneCollisionManager.h -# End Source File -# Begin Source File - -SOURCE=.\CSceneManager.cpp -# End Source File -# Begin Source File - -SOURCE=.\CSceneManager.h -# End Source File -# Begin Source File - -SOURCE=.\CSceneNodeAnimatorCollisionResponse.cpp -# End Source File -# Begin Source File - -SOURCE=.\CSceneNodeAnimatorCollisionResponse.h -# End Source File -# Begin Source File - -SOURCE=.\CSceneNodeAnimatorDelete.cpp -# End Source File -# Begin Source File - -SOURCE=.\CSceneNodeAnimatorDelete.h -# End Source File -# Begin Source File - -SOURCE=.\CSceneNodeAnimatorFlyCircle.cpp -# End Source File -# Begin Source File - -SOURCE=.\CSceneNodeAnimatorFlyCircle.h -# End Source File -# Begin Source File - -SOURCE=.\CSceneNodeAnimatorFlyStraight.cpp -# End Source File -# Begin Source File - -SOURCE=.\CSceneNodeAnimatorFlyStraight.h -# End Source File -# Begin Source File - -SOURCE=.\CSceneNodeAnimatorFollowSpline.cpp -# End Source File -# Begin Source File - -SOURCE=.\CSceneNodeAnimatorFollowSpline.h -# End Source File -# Begin Source File - -SOURCE=.\CSceneNodeAnimatorRotation.cpp -# End Source File -# Begin Source File - -SOURCE=.\CSceneNodeAnimatorRotation.h -# End Source File -# Begin Source File - -SOURCE=.\CSceneNodeAnimatorTexture.cpp -# End Source File -# Begin Source File - -SOURCE=.\CSceneNodeAnimatorTexture.h -# End Source File -# Begin Source File - -SOURCE=.\CShadowVolumeSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CShadowVolumeSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CSkinnedMesh.cpp -# End Source File -# Begin Source File - -SOURCE=.\CSkinnedMesh.h -# End Source File -# Begin Source File - -SOURCE=.\CSkyBoxSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CSkyBoxSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CSkyDomeSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CSkyDomeSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CSphereSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CSphereSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CSTLMeshFileLoader.cpp -# End Source File -# Begin Source File - -SOURCE=.\CSTLMeshWriter.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTerrainSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTerrainSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CTerrainTriangleSelector.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTerrainTriangleSelector.h -# End Source File -# Begin Source File - -SOURCE=.\CTextSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTextSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CTriangleBBSelector.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTriangleBBSelector.h -# End Source File -# Begin Source File - -SOURCE=.\CTriangleSelector.cpp -# End Source File -# Begin Source File - -SOURCE=.\CTriangleSelector.h -# End Source File -# Begin Source File - -SOURCE=.\CWaterSurfaceSceneNode.cpp -# End Source File -# Begin Source File - -SOURCE=.\CWaterSurfaceSceneNode.h -# End Source File -# Begin Source File - -SOURCE=.\CXMeshFileLoader.cpp -# End Source File -# Begin Source File - -SOURCE=.\CXMeshFileLoader.h -# End Source File -# Begin Source File - -SOURCE=.\dmfsupport.h -# End Source File -# Begin Source File - -SOURCE=.\OctTree.h -# End Source File -# End Group -# Begin Group "io_impl" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\CAttributeImpl.h -# End Source File -# Begin Source File - -SOURCE=.\CAttributes.cpp -# End Source File -# Begin Source File - -SOURCE=.\CAttributes.h -# End Source File -# Begin Source File - -SOURCE=.\CFileList.cpp -# End Source File -# Begin Source File - -SOURCE=.\CFileList.h -# End Source File -# Begin Source File - -SOURCE=.\CFileSystem.cpp -# End Source File -# Begin Source File - -SOURCE=.\CFileSystem.h -# End Source File -# Begin Source File - -SOURCE=.\CLimitReadFile.cpp -# End Source File -# Begin Source File - -SOURCE=.\CLimitReadFile.h -# End Source File -# Begin Source File - -SOURCE=.\CMemoryReadFile.cpp -# End Source File -# Begin Source File - -SOURCE=.\CMemoryReadFile.h -# End Source File -# Begin Source File - -SOURCE=.\CPakReader.cpp -# End Source File -# Begin Source File - -SOURCE=.\CPakReader.h -# End Source File -# Begin Source File - -SOURCE=.\CReadFile.cpp -# End Source File -# Begin Source File - -SOURCE=.\CReadFile.h -# End Source File -# Begin Source File - -SOURCE=.\CWriteFile.cpp -# End Source File -# Begin Source File - -SOURCE=.\CWriteFile.h -# End Source File -# Begin Source File - -SOURCE=.\CXMLReader.cpp -# End Source File -# Begin Source File - -SOURCE=.\CXMLReader.h -# End Source File -# Begin Source File - -SOURCE=.\CXMLReaderImpl.h -# End Source File -# Begin Source File - -SOURCE=.\CXMLWriter.cpp -# End Source File -# Begin Source File - -SOURCE=.\CXMLWriter.h -# End Source File -# Begin Source File - -SOURCE=.\CZipReader.cpp -# End Source File -# Begin Source File - -SOURCE=.\CZipReader.h -# End Source File -# Begin Source File - -SOURCE=.\irrXML.cpp -# End Source File -# End Group -# Begin Group "other_impl" - -# PROP Default_Filter "" -# Begin Group "extern" - -# PROP Default_Filter "" -# Begin Group "zlib" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\zlib\adler32.c -# End Source File -# Begin Source File - -SOURCE=.\zlib\compress.c -# End Source File -# Begin Source File - -SOURCE=.\zlib\crc32.c -# End Source File -# Begin Source File - -SOURCE=.\zlib\crc32.h -# End Source File -# Begin Source File - -SOURCE=.\zlib\deflate.c -# End Source File -# Begin Source File - -SOURCE=.\zlib\deflate.h -# End Source File -# Begin Source File - -SOURCE=.\zlib\inffast.c -# End Source File -# Begin Source File - -SOURCE=.\zlib\inffast.h -# End Source File -# Begin Source File - -SOURCE=.\zlib\inflate.c -# End Source File -# Begin Source File - -SOURCE=.\zlib\inftrees.c -# End Source File -# Begin Source File - -SOURCE=.\zlib\inftrees.h -# End Source File -# Begin Source File - -SOURCE=.\zlib\trees.c -# End Source File -# Begin Source File - -SOURCE=.\zlib\trees.h -# End Source File -# Begin Source File - -SOURCE=.\zlib\uncompr.c -# End Source File -# Begin Source File - -SOURCE=.\zlib\zconf.h -# End Source File -# Begin Source File - -SOURCE=.\zlib\zlib.h -# End Source File -# Begin Source File - -SOURCE=.\zlib\zutil.c -# End Source File -# Begin Source File - -SOURCE=.\zlib\zutil.h -# End Source File -# End Group -# Begin Group "jpeglib" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\jpeglib\cderror.h -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\cdjpeg.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\cdjpeg.h -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jcapimin.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jcapistd.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jccoefct.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jccolor.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jcdctmgr.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jchuff.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jchuff.h -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jcinit.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jcmainct.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jcmarker.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jcmaster.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jcomapi.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jconfig.h -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jcparam.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jcphuff.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jcprepct.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jcsample.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jctrans.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jdapimin.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jdapistd.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jdatadst.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jdatasrc.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jdcoefct.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jdcolor.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jdct.h -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jddctmgr.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jdhuff.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jdhuff.h -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jdinput.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jdmainct.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jdmarker.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jdmaster.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jdmerge.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jdphuff.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jdpostct.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jdsample.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jdtrans.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jerror.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jerror.h -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jfdctflt.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jfdctfst.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jfdctint.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jidctflt.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jidctfst.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jidctint.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jidctred.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jinclude.h -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jmemmgr.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jmemnobs.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jmemsys.h -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jmorecfg.h -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jpegint.h -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jpeglib.h -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jquant1.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jquant2.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jutils.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\jversion.h -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\rdbmp.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\rdcolmap.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\rdgif.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\rdppm.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\rdrle.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\rdswitch.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\rdtarga.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\transupp.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\transupp.h -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\wrbmp.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\wrgif.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\wrppm.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\wrrle.c -# End Source File -# Begin Source File - -SOURCE=.\jpeglib\wrtarga.c -# End Source File -# End Group -# Begin Group "libpng" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\libpng\png.c -# End Source File -# Begin Source File - -SOURCE=.\libpng\png.h -# End Source File -# Begin Source File - -SOURCE=.\libpng\pngconf.h -# End Source File -# Begin Source File - -SOURCE=.\libpng\pngerror.c -# End Source File -# Begin Source File - -SOURCE=.\libpng\pngget.c -# End Source File -# Begin Source File - -SOURCE=.\libpng\pngmem.c -# End Source File -# Begin Source File - -SOURCE=.\libpng\pngpread.c -# End Source File -# Begin Source File - -SOURCE=.\libpng\pngread.c -# End Source File -# Begin Source File - -SOURCE=.\libpng\pngrio.c -# End Source File -# Begin Source File - -SOURCE=.\libpng\pngrtran.c -# End Source File -# Begin Source File - -SOURCE=.\libpng\pngrutil.c -# End Source File -# Begin Source File - -SOURCE=.\libpng\pngset.c -# End Source File -# Begin Source File - -SOURCE=.\libpng\pngtrans.c -# End Source File -# Begin Source File - -SOURCE=.\libpng\pngwio.c -# End Source File -# Begin Source File - -SOURCE=.\libpng\pngwrite.c -# End Source File -# Begin Source File - -SOURCE=.\libpng\pngwtran.c -# End Source File -# Begin Source File - -SOURCE=.\libpng\pngwutil.c -# End Source File -# End Group -# End Group -# Begin Source File - -SOURCE=.\CIrrDeviceLinux.cpp -# End Source File -# Begin Source File - -SOURCE=.\CIrrDeviceLinux.h -# End Source File -# Begin Source File - -SOURCE=.\CIrrDeviceStub.cpp -# End Source File -# Begin Source File - -SOURCE=.\CIrrDeviceStub.h -# End Source File -# Begin Source File - -SOURCE=.\CIrrDeviceWin32.cpp -# End Source File -# Begin Source File - -SOURCE=.\CIrrDeviceWin32.h -# End Source File -# Begin Source File - -SOURCE=.\CLogger.cpp -# End Source File -# Begin Source File - -SOURCE=.\CLogger.h -# End Source File -# Begin Source File - -SOURCE=.\COSOperator.cpp -# End Source File -# Begin Source File - -SOURCE=.\COSOperator.h -# End Source File -# Begin Source File - -SOURCE=.\CTimer.h -# End Source File -# Begin Source File - -SOURCE=.\fast_atof.h -# End Source File -# Begin Source File - -SOURCE=.\IImagePresenter.h -# End Source File -# Begin Source File - -SOURCE=.\Irrlicht.cpp -# End Source File -# Begin Source File - -SOURCE=.\os.cpp -# End Source File -# Begin Source File - -SOURCE=.\os.h -# End Source File -# End Group -# Begin Group "doc" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\changes.txt -# End Source File -# End Group -# Begin Source File - -SOURCE=.\glxext.h -# End Source File -# End Target -# End Project diff --git a/irrlicht-1.6/source/Irrlicht/Irrlicht.dsw b/irrlicht-1.6/source/Irrlicht/Irrlicht.dsw deleted file mode 100644 index 99cd376be..000000000 --- a/irrlicht-1.6/source/Irrlicht/Irrlicht.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNUNG: DIESE ARBEITSBEREICHSDATEI DARF NICHT BEARBEITET ODER GELSCHT WERDEN! - -############################################################################### - -Project: "Irrlicht"=.\Irrlicht.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/irrlicht-1.6/source/Irrlicht/Irrlicht.plg b/irrlicht-1.6/source/Irrlicht/Irrlicht.plg deleted file mode 100644 index c7da5bdec..000000000 --- a/irrlicht-1.6/source/Irrlicht/Irrlicht.plg +++ /dev/null @@ -1,310 +0,0 @@ -<html> -<body> -<pre> -<h1>Erstellungsprotokoll</h1> -<h3> ---------------------Konfiguration: Irrlicht - Win32 Debug-------------------- -</h3> -<h3>Befehlszeilen</h3> -Erstellen der temporren Datei "C:\Users\niko\AppData\Local\Temp\RSP644E.tmp" mit Inhalten -[ -/nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../include" /I "zlib" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IRRLICHT_EXPORTS" /Fo"..\Debug/" /Fd"..\Debug/" /FD /GZ /c -"C:\Development\irrlicht-1.4\irrlicht\source\Irrlicht\CImageLoaderPPM.cpp" -] -Creating command line "cl.exe @C:\Users\niko\AppData\Local\Temp\RSP644E.tmp" -Erstellen der temporren Datei "C:\Users\niko\AppData\Local\Temp\RSP645E.tmp" mit Inhalten -[ -kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:yes /pdb:"..\Debug/Irrlicht.pdb" /debug /machine:I386 /out:"..\Debug/Irrlicht.dll" /implib:"..\Debug/Irrlicht.lib" /pdbtype:sept -"\Development\irrlicht-1.4\irrlicht\source\Debug\CDefaultGUIElementFactory.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CGUIButton.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CGUICheckBox.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CGUIColorSelectDialog.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CGUIComboBox.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CGUIContextMenu.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CGUIEditBox.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CGUIEnvironment.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CGUIFileOpenDialog.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CGUIFont.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CGUIImage.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CGUIInOutFader.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CGUIListBox.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CGUIMenu.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CGUIMeshViewer.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CGUIMessageBox.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CGUIModalScreen.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CGUIScrollBar.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CGUISkin.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CGUISpriteBank.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CGUIStaticText.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CGUITabControl.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CGUIToolBar.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CGUIWindow.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CSoftwareDriver.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CSoftwareTexture.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CTRFlat.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CTRFlatWire.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CTRGouraud.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CTRGouraudWire.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CTRTextureFlat.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CTRTextureFlatWire.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CTRTextureGouraud.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CTRTextureGouraudAdd.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CTRTextureGouraudNoZ.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CTRTextureGouraudWire.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CZBuffer.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\COpenGLDriver.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\COpenGLExtensionHandler.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\COpenGLNormalMapRenderer.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\COpenGLParallaxMapRenderer.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\COpenGLShaderMaterialRenderer.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\COpenGLSLMaterialRenderer.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\COpenGLTexture.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CD3D8Driver.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CD3D8NormalMapRenderer.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CD3D8ParallaxMapRenderer.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CD3D8ShaderMaterialRenderer.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CD3D8Texture.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CImageWriterBMP.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CImageWriterJPG.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CImageWriterPCX.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CImageWriterPNG.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CImageWriterPPM.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CImageWriterPSD.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CImageWriterTGA.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CColorConverter.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CFPSCounter.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CImage.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CImageLoaderBMP.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CImageLoaderJPG.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CImageLoaderPCX.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CImageLoaderPNG.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CImageLoaderPSD.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CImageLoaderTGA.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CNullDriver.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CD3D9Driver.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CD3D9HLSLMaterialRenderer.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CD3D9NormalMapRenderer.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CD3D9ParallaxMapRenderer.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CD3D9ShaderMaterialRenderer.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CD3D9Texture.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CDepthBuffer.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CSoftwareDriver2.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CSoftwareTexture2.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CTRGouraud2.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CTRGouraudAlpha2.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CTRGouraudAlphaNoZ2.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CTRTextureBlend.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CTRTextureDetailMap2.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CTRTextureGouraud2.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CTRTextureGouraudAdd2.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CTRTextureGouraudAddNoZ2.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CTRTextureGouraudAlpha.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CTRTextureGouraudAlphaNoZ.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CTRTextureGouraudNoZ2.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CTRTextureGouraudVertexAlpha2.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CTRTextureLightMap2_Add.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CTRTextureLightMap2_M1.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CTRTextureLightMap2_M2.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CTRTextureLightMap2_M4.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CTRTextureLightMapGouraud2_M4.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CTRTextureWire2.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\IBurningShader.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CVideoModeList.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\C3DSMeshFileLoader.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CAnimatedMeshMD2.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CAnimatedMeshMD3.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CAnimatedMeshSceneNode.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CB3DMeshFileLoader.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CBillboardSceneNode.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CBoneSceneNode.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CBSPMeshFileLoader.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CCameraFPSSceneNode.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CCameraMayaSceneNode.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CCameraSceneNode.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CColladaFileLoader.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CCSMLoader.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CCubeSceneNode.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CDefaultSceneNodeAnimatorFactory.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CDefaultSceneNodeFactory.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CDMFLoader.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CDummyTransformationSceneNode.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CEmptySceneNode.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CGeometryCreator.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CGUISpinBox.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CIrrDeviceSDL.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CLightSceneNode.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CLMTSMeshFileLoader.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CMD2MeshFileLoader.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CMD3MeshFileLoader.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CMeshCache.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CMeshManipulator.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CMeshSceneNode.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CMetaTriangleSelector.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CMS3DMeshFileLoader.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CMY3DMeshFileLoader.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\COBJMeshFileLoader.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\COCTLoader.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\COctTreeSceneNode.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\COctTreeTriangleSelector.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\COgreMeshFileLoader.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CParticleAnimatedMeshSceneNodeEmitter.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CParticleAttractionAffector.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CParticleBoxEmitter.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CParticleCylinderEmitter.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CParticleFadeOutAffector.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CParticleGravityAffector.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CParticleMeshEmitter.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CParticlePointEmitter.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CParticleRingEmitter.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CParticleRotationAffector.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CParticleSphereEmitter.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CParticleSystemSceneNode.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CQ3LevelMesh.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CQuake3ShaderSceneNode.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CSceneCollisionManager.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CSceneManager.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CSceneNodeAnimatorCollisionResponse.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CSceneNodeAnimatorDelete.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CSceneNodeAnimatorFlyCircle.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CSceneNodeAnimatorFlyStraight.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CSceneNodeAnimatorFollowSpline.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CSceneNodeAnimatorRotation.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CSceneNodeAnimatorTexture.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CShadowVolumeSceneNode.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CSkinnedMesh.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CSkyBoxSceneNode.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CSkyDomeSceneNode.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CSphereSceneNode.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CTerrainSceneNode.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CTerrainTriangleSelector.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CTextSceneNode.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CTriangleBBSelector.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CTriangleSelector.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CWaterSurfaceSceneNode.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CXMeshFileLoader.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CAttributes.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CFileList.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CFileSystem.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CLimitReadFile.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CMemoryReadFile.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CPakReader.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CReadFile.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CWriteFile.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CXMLReader.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CXMLWriter.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CZipReader.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\irrXML.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\adler32.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\compress.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\crc32.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\deflate.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\inffast.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\inflate.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\inftrees.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\trees.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\uncompr.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\zutil.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\cdjpeg.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jcapimin.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jcapistd.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jccoefct.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jccolor.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jcdctmgr.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jchuff.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jcinit.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jcmainct.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jcmarker.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jcmaster.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jcomapi.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jcparam.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jcphuff.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jcprepct.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jcsample.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jctrans.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jdapimin.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jdapistd.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jdatadst.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jdatasrc.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jdcoefct.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jdcolor.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jddctmgr.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jdhuff.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jdinput.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jdmainct.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jdmarker.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jdmaster.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jdmerge.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jdphuff.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jdpostct.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jdsample.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jdtrans.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jerror.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jfdctflt.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jfdctfst.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jfdctint.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jidctflt.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jidctfst.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jidctint.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jidctred.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jmemmgr.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jmemnobs.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jquant1.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jquant2.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\jutils.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\rdbmp.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\rdcolmap.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\rdgif.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\rdppm.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\rdrle.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\rdswitch.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\rdtarga.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\transupp.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\wrbmp.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\wrgif.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\wrppm.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\wrrle.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\wrtarga.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\png.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\pngerror.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\pngget.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\pngmem.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\pngpread.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\pngread.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\pngrio.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\pngrtran.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\pngrutil.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\pngset.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\pngtrans.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\pngwio.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\pngwrite.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\pngwtran.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\pngwutil.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CIrrDeviceLinux.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CIrrDeviceStub.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CIrrDeviceWin32.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CLogger.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\COSOperator.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\Irrlicht.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\os.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CIrrMeshFileLoader.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CIrrMeshWriter.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CSTLMeshWriter.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CSTLMeshFileLoader.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CColladaMeshWriter.obj" -"\Development\irrlicht-1.4\irrlicht\source\Debug\CImageLoaderPPM.obj" -] -Erstellen der Befehlzeile "link.exe @C:\Users\niko\AppData\Local\Temp\RSP645E.tmp" -<h3>Ausgabefenster</h3> -Kompilierung luft... -CImageLoaderPPM.cpp -Compiling Irrlicht with Visual Studio 6.0, support for DX9 is disabled. -Linker-Vorgang luft... - Bibliothek ..\Debug/Irrlicht.lib und Objekt ..\Debug/Irrlicht.exp wird erstellt - - - -<h3>Ergebnisse</h3> -Irrlicht.dll - 0 Fehler, 0 Warnung(en) -</pre> -</body> -</html> diff --git a/irrlicht-1.6/source/Irrlicht/Irrlicht7.1.sln b/irrlicht-1.6/source/Irrlicht/Irrlicht7.1.sln deleted file mode 100644 index a748a6f2a..000000000 --- a/irrlicht-1.6/source/Irrlicht/Irrlicht7.1.sln +++ /dev/null @@ -1,33 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Irrlicht", "Irrlicht7.1.vcproj", "{E08E042A-6C45-411B-92BE-3CC31331019F}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfiguration) = preSolution - Debug = Debug - Release = Release - Release - Fast FPU = Release - Fast FPU - Static lib - Debug|Win32 = Static lib - Debug|Win32 - Static lib - Release - Fast FPU|Win32 = Static lib - Release - Fast FPU|Win32 - Static lib - Release|Win32 = Static lib - Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {E08E042A-6C45-411B-92BE-3CC31331019F}.Debug.ActiveCfg = Debug|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Debug.Build.0 = Debug|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Release.ActiveCfg = Release|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Release.Build.0 = Release|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU.ActiveCfg = Relase - Fast FPU|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU.Build.0 = Relase - Fast FPU|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Debug|Win32.ActiveCfg = Static lib - Debug|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Debug|Win32.Build.0 = Static lib - Debug|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Release - Fast FPU|Win32.ActiveCfg = Static lib - Release - Fast FPU|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Release - Fast FPU|Win32.Build.0 = Static lib - Release - Fast FPU|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Release|Win32.ActiveCfg = Static lib - Release|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Release|Win32.Build.0 = Static lib - Release|Win32 - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution - EndGlobalSection -EndGlobal diff --git a/irrlicht-1.6/source/Irrlicht/Irrlicht7.1.vcproj b/irrlicht-1.6/source/Irrlicht/Irrlicht7.1.vcproj deleted file mode 100644 index b6c203fc0..000000000 --- a/irrlicht-1.6/source/Irrlicht/Irrlicht7.1.vcproj +++ /dev/null @@ -1,2381 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?> -<VisualStudioProject - ProjectType="Visual C++" - Version="7.10" - Name="Irrlicht" - ProjectGUID="{E08E042A-6C45-411B-92BE-3CC31331019F}" - RootNamespace="Irrlicht"> - <Platforms> - <Platform - Name="Win32"/> - </Platforms> - <Configurations> - <Configuration - Name="Debug|Win32" - OutputDirectory="..\obj\IrrDebug" - IntermediateDirectory="..\obj\IrrDebug" - ConfigurationType="2" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="FALSE" - CharacterSet="0"> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - AdditionalIncludeDirectories="..\..\include;zlib" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;IRRLICHT_EXPORTS;_CRT_SECURE_NO_DEPRECATE" - ExceptionHandling="FALSE" - BasicRuntimeChecks="3" - RuntimeLibrary="1" - DisableLanguageExtensions="FALSE" - RuntimeTypeInfo="FALSE" - PrecompiledHeaderFile=".\..\obj\IrrDebug/Irrlicht.pch" - AssemblerListingLocation=".\..\obj\IrrDebug/" - ObjectFile=".\..\obj\IrrDebug/" - ProgramDataBaseFileName=".\..\obj\IrrDebug/" - WarningLevel="3" - SuppressStartupBanner="TRUE" - DebugInformationFormat="3" - CompileAs="0"/> - <Tool - Name="VCCustomBuildTool"/> - <Tool - Name="VCLinkerTool" - AdditionalOptions="/MACHINE:I386" - AdditionalDependencies="kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib opengl32.lib winmm.lib" - OutputFile="..\..\bin\Win32-visualstudio\Irrlicht.dll" - LinkIncremental="2" - SuppressStartupBanner="TRUE" - IgnoreDefaultLibraryNames="libci.lib" - GenerateDebugInformation="TRUE" - ProgramDatabaseFile="..\obj\IrrDebug\Irrlicht.pdb" - ImportLibrary="..\..\lib\Win32-visualstudio\Irrlicht.lib"/> - <Tool - Name="VCMIDLTool" - PreprocessorDefinitions="_DEBUG" - MkTypLibCompatible="TRUE" - SuppressStartupBanner="TRUE" - TargetEnvironment="1" - TypeLibraryName=".\..\Debug/Irrlicht.tlb"/> - <Tool - Name="VCPostBuildEventTool"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="_DEBUG" - Culture="3079"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCWebDeploymentTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - <Configuration - Name="Release|Win32" - OutputDirectory="obj\IrrRelease" - IntermediateDirectory="obj\IrrRelease" - ConfigurationType="2" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="FALSE" - CharacterSet="2" - WholeProgramOptimization="TRUE"> - <Tool - Name="VCCLCompilerTool" - Optimization="2" - InlineFunctionExpansion="1" - EnableIntrinsicFunctions="FALSE" - AdditionalIncludeDirectories="..\..\include;zlib" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;IRRLICHT_EXPORTS;_CRT_SECURE_NO_DEPRECATE" - StringPooling="TRUE" - ExceptionHandling="FALSE" - RuntimeLibrary="0" - BufferSecurityCheck="FALSE" - EnableFunctionLevelLinking="TRUE" - PrecompiledHeaderFile=".\..\obj\IrrRelease/Irrlicht.pch" - AssemblerListingLocation=".\..\obj\IrrRelease/" - ObjectFile=".\..\obj\IrrRelease/" - ProgramDataBaseFileName=".\..\obj\IrrRelease/" - WarningLevel="3" - SuppressStartupBanner="TRUE" - DebugInformationFormat="0" - CompileAs="0"/> - <Tool - Name="VCCustomBuildTool"/> - <Tool - Name="VCLinkerTool" - AdditionalOptions="/MACHINE:I386" - AdditionalDependencies="kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib opengl32.lib winmm.lib" - OutputFile="..\..\bin\Win32-visualstudio\Irrlicht.dll" - LinkIncremental="1" - SuppressStartupBanner="TRUE" - IgnoreDefaultLibraryNames="libci.lib" - GenerateDebugInformation="FALSE" - ProgramDatabaseFile="..\obj\IrrRelease\Irrlicht.pdb" - ImportLibrary="..\..\lib\Win32-visualstudio\Irrlicht.lib"/> - <Tool - Name="VCMIDLTool" - PreprocessorDefinitions="NDEBUG" - MkTypLibCompatible="TRUE" - SuppressStartupBanner="TRUE" - TargetEnvironment="1" - TypeLibraryName=".\..\Release/Irrlicht.tlb"/> - <Tool - Name="VCPostBuildEventTool"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="NDEBUG" - Culture="3079"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCWebDeploymentTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - <Configuration - Name="Release - Fast FPU|Win32" - OutputDirectory="$(ConfigurationName)" - IntermediateDirectory="$(ConfigurationName)" - ConfigurationType="2" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="FALSE" - CharacterSet="2" - WholeProgramOptimization="TRUE"> - <Tool - Name="VCCLCompilerTool" - Optimization="3" - InlineFunctionExpansion="2" - EnableIntrinsicFunctions="TRUE" - FavorSizeOrSpeed="0" - OmitFramePointers="TRUE" - AdditionalIncludeDirectories="..\..\include;zlib" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;IRRLICHT_EXPORTS;_CRT_SECURE_NO_DEPRECATE" - StringPooling="TRUE" - ExceptionHandling="FALSE" - RuntimeLibrary="0" - BufferSecurityCheck="FALSE" - EnableFunctionLevelLinking="TRUE" - RuntimeTypeInfo="FALSE" - PrecompiledHeaderFile=".\..\obj\IrrRelease/Irrlicht.pch" - AssemblerListingLocation=".\..\obj\IrrRelease/" - ObjectFile=".\..\obj\IrrRelease/" - ProgramDataBaseFileName=".\..\obj\IrrRelease/" - WarningLevel="3" - SuppressStartupBanner="TRUE" - DebugInformationFormat="0" - CallingConvention="1" - CompileAs="0"/> - <Tool - Name="VCCustomBuildTool"/> - <Tool - Name="VCLinkerTool" - AdditionalOptions="/MACHINE:I386" - AdditionalDependencies="kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib opengl32.lib winmm.lib" - OutputFile="..\..\bin\Win32-visualstudio\Irrlicht.dll" - LinkIncremental="1" - SuppressStartupBanner="TRUE" - IgnoreDefaultLibraryNames="libci.lib" - GenerateDebugInformation="FALSE" - ProgramDatabaseFile="..\obj\IrrRelease\Irrlicht.pdb" - ImportLibrary="..\..\lib\Win32-visualstudio\Irrlicht.lib"/> - <Tool - Name="VCMIDLTool" - PreprocessorDefinitions="NDEBUG" - MkTypLibCompatible="TRUE" - SuppressStartupBanner="TRUE" - TargetEnvironment="1" - TypeLibraryName=".\..\Release/Irrlicht.tlb"/> - <Tool - Name="VCPostBuildEventTool"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="NDEBUG" - Culture="3079"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCWebDeploymentTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - <Configuration - Name="Static lib - Debug|Win32" - OutputDirectory="$(ConfigurationName)" - IntermediateDirectory="$(ConfigurationName)" - ConfigurationType="4" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="FALSE" - CharacterSet="0"> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - AdditionalIncludeDirectories="..\..\include;zlib" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;_IRR_STATIC_LIB_;_CRT_SECURE_NO_DEPRECATE" - ExceptionHandling="FALSE" - BasicRuntimeChecks="3" - RuntimeLibrary="1" - DisableLanguageExtensions="FALSE" - RuntimeTypeInfo="FALSE" - PrecompiledHeaderFile=".\..\obj\IrrDebug/Irrlicht.pch" - AssemblerListingLocation=".\..\obj\IrrDebug/" - ObjectFile=".\..\obj\IrrDebug/" - ProgramDataBaseFileName=".\..\obj\IrrDebug/" - WarningLevel="3" - SuppressStartupBanner="TRUE" - DebugInformationFormat="3" - CompileAs="0"/> - <Tool - Name="VCCustomBuildTool"/> - <Tool - Name="VCLibrarianTool" - AdditionalDependencies="winmm.lib" - OutputFile="..\..\lib\Win32-visualstudio\Irrlicht.lib"/> - <Tool - Name="VCMIDLTool" - PreprocessorDefinitions="_DEBUG" - MkTypLibCompatible="TRUE" - SuppressStartupBanner="TRUE" - TargetEnvironment="1" - TypeLibraryName=".\..\Debug/Irrlicht.tlb"/> - <Tool - Name="VCPostBuildEventTool"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="_DEBUG" - Culture="3079"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - <Configuration - Name="Static lib - Release|Win32" - OutputDirectory="$(ConfigurationName)" - IntermediateDirectory="$(ConfigurationName)" - ConfigurationType="4" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="FALSE" - CharacterSet="2" - WholeProgramOptimization="TRUE"> - <Tool - Name="VCCLCompilerTool" - Optimization="2" - InlineFunctionExpansion="1" - EnableIntrinsicFunctions="FALSE" - AdditionalIncludeDirectories="..\..\include;zlib" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;_IRR_STATIC_LIB_;_CRT_SECURE_NO_DEPRECATE" - StringPooling="TRUE" - ExceptionHandling="FALSE" - RuntimeLibrary="0" - BufferSecurityCheck="FALSE" - EnableFunctionLevelLinking="TRUE" - PrecompiledHeaderFile=".\..\obj\IrrRelease/Irrlicht.pch" - AssemblerListingLocation=".\..\obj\IrrRelease/" - ObjectFile=".\..\obj\IrrRelease/" - ProgramDataBaseFileName=".\..\obj\IrrRelease/" - WarningLevel="3" - SuppressStartupBanner="TRUE" - DebugInformationFormat="0" - CompileAs="0"/> - <Tool - Name="VCCustomBuildTool"/> - <Tool - Name="VCLibrarianTool" - AdditionalDependencies="winmm.lib" - OutputFile="..\..\lib\Win32-visualstudio\Irrlicht.lib"/> - <Tool - Name="VCMIDLTool" - PreprocessorDefinitions="NDEBUG" - MkTypLibCompatible="TRUE" - SuppressStartupBanner="TRUE" - TargetEnvironment="1" - TypeLibraryName=".\..\Release/Irrlicht.tlb"/> - <Tool - Name="VCPostBuildEventTool"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="NDEBUG" - Culture="3079"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - <Configuration - Name="Static lib - Release - Fast FPU|Win32" - OutputDirectory="$(ConfigurationName)" - IntermediateDirectory="$(ConfigurationName)" - ConfigurationType="4" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="FALSE" - CharacterSet="2" - WholeProgramOptimization="TRUE"> - <Tool - Name="VCCLCompilerTool" - Optimization="3" - InlineFunctionExpansion="2" - EnableIntrinsicFunctions="TRUE" - FavorSizeOrSpeed="0" - OmitFramePointers="TRUE" - AdditionalIncludeDirectories="..\..\include;zlib" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;_IRR_STATIC_LIB_;_CRT_SECURE_NO_DEPRECATE" - StringPooling="TRUE" - ExceptionHandling="FALSE" - RuntimeLibrary="0" - BufferSecurityCheck="FALSE" - EnableFunctionLevelLinking="TRUE" - RuntimeTypeInfo="FALSE" - PrecompiledHeaderFile=".\..\obj\IrrRelease/Irrlicht.pch" - AssemblerListingLocation=".\..\obj\IrrRelease/" - ObjectFile=".\..\obj\IrrRelease/" - ProgramDataBaseFileName=".\..\obj\IrrRelease/" - WarningLevel="3" - SuppressStartupBanner="TRUE" - DebugInformationFormat="0" - CallingConvention="1" - CompileAs="0"/> - <Tool - Name="VCCustomBuildTool"/> - <Tool - Name="VCLibrarianTool" - AdditionalDependencies="winmm.lib" - OutputFile="..\..\lib\Win32-visualstudio\Irrlicht.lib"/> - <Tool - Name="VCMIDLTool" - PreprocessorDefinitions="NDEBUG" - MkTypLibCompatible="TRUE" - SuppressStartupBanner="TRUE" - TargetEnvironment="1" - TypeLibraryName=".\..\Release/Irrlicht.tlb"/> - <Tool - Name="VCPostBuildEventTool"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="NDEBUG" - Culture="3079"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - </Configurations> - <References> - </References> - <Files> - <Filter - Name="include"> - <File - RelativePath=".\..\..\include\IEventReceiver.h"> - </File> - <File - RelativePath=".\..\..\include\ILogger.h"> - </File> - <File - RelativePath=".\..\..\include\IOSOperator.h"> - </File> - <File - RelativePath="..\..\include\IReferenceCounted.h"> - </File> - <File - RelativePath=".\..\..\include\IrrCompileConfig.h"> - </File> - <File - RelativePath=".\..\..\include\irrlicht.h"> - </File> - <File - RelativePath=".\..\..\include\IrrlichtDevice.h"> - </File> - <File - RelativePath=".\..\..\include\irrTypes.h"> - </File> - <File - RelativePath=".\..\..\include\ITimer.h"> - </File> - <File - RelativePath=".\..\..\include\Keycodes.h"> - </File> - <File - RelativePath=".\..\..\include\SIrrCreationParameters.h"> - </File> - <File - RelativePath=".\..\..\include\SKeyMap.h"> - </File> - <Filter - Name="video"> - <File - RelativePath=".\..\..\include\EDriverTypes.h"> - </File> - <File - RelativePath=".\..\..\include\IGPUProgrammingServices.h"> - </File> - <File - RelativePath=".\..\..\include\IImage.h"> - </File> - <File - RelativePath=".\..\..\include\IImageLoader.h"> - </File> - <File - RelativePath=".\..\..\include\IMaterialRenderer.h"> - </File> - <File - RelativePath=".\..\..\include\IMaterialRendererServices.h"> - </File> - <File - RelativePath=".\..\..\include\IShaderConstantSetCallBack.h"> - </File> - <File - RelativePath=".\..\..\include\ITexture.h"> - </File> - <File - RelativePath=".\..\..\include\IVideoDriver.h"> - </File> - <File - RelativePath=".\..\..\include\IVideoModeList.h"> - </File> - <File - RelativePath=".\..\..\include\S3DVertex.h"> - </File> - <File - RelativePath=".\..\..\include\SColor.h"> - </File> - <File - RelativePath=".\..\..\include\SExposedVideoData.h"> - </File> - <File - RelativePath=".\..\..\include\SLight.h"> - </File> - <File - RelativePath=".\..\..\include\SMaterial.h"> - </File> - </Filter> - <Filter - Name="core"> - <File - RelativePath=".\..\..\include\aabbox3d.h"> - </File> - <File - RelativePath=".\..\..\include\dimension2d.h"> - </File> - <File - RelativePath=".\..\..\include\heapsort.h"> - </File> - <File - RelativePath=".\..\..\include\irrAllocator.h"> - </File> - <File - RelativePath=".\..\..\include\irrArray.h"> - </File> - <File - RelativePath=".\..\..\include\irrList.h"> - </File> - <File - RelativePath="..\..\include\irrMap.h"> - </File> - <File - RelativePath=".\..\..\include\irrMath.h"> - </File> - <File - RelativePath=".\..\..\include\irrString.h"> - </File> - <File - RelativePath=".\..\..\include\line2d.h"> - </File> - <File - RelativePath=".\..\..\include\line3d.h"> - </File> - <File - RelativePath=".\..\..\include\matrix4.h"> - </File> - <File - RelativePath=".\..\..\include\plane3d.h"> - </File> - <File - RelativePath=".\..\..\include\position2d.h"> - </File> - <File - RelativePath=".\..\..\include\quaternion.h"> - </File> - <File - RelativePath=".\..\..\include\rect.h"> - </File> - <File - RelativePath=".\..\..\include\triangle3d.h"> - </File> - <File - RelativePath=".\..\..\include\vector2d.h"> - </File> - <File - RelativePath=".\..\..\include\vector3d.h"> - </File> - </Filter> - <Filter - Name="io"> - <File - RelativePath=".\..\..\include\IAttributeExchangingObject.h"> - </File> - <File - RelativePath=".\..\..\include\IAttributes.h"> - </File> - <File - RelativePath=".\..\..\include\IFileList.h"> - </File> - <File - RelativePath=".\..\..\include\IFileSystem.h"> - </File> - <File - RelativePath=".\..\..\include\IReadFile.h"> - </File> - <File - RelativePath=".\..\..\include\irrXML.h"> - </File> - <File - RelativePath=".\..\..\include\IWriteFile.h"> - </File> - <File - RelativePath=".\..\..\include\IXMLReader.h"> - </File> - <File - RelativePath=".\..\..\include\IXMLWriter.h"> - </File> - </Filter> - <Filter - Name="scene"> - <File - RelativePath="..\..\include\ECullingTypes.h"> - </File> - <File - RelativePath="..\..\include\EDebugSceneTypes.h"> - </File> - <File - RelativePath="..\..\include\EMeshWriterEnums.h"> - </File> - <File - RelativePath=".\..\..\include\ESceneNodeAnimatorTypes.h"> - </File> - <File - RelativePath=".\..\..\include\ESceneNodeTypes.h"> - </File> - <File - RelativePath=".\..\..\include\IAnimatedMesh.h"> - </File> - <File - RelativePath=".\..\..\include\IAnimatedMeshMD2.h"> - </File> - <File - RelativePath=".\..\..\include\IAnimatedMeshMS3D.h"> - </File> - <File - RelativePath=".\..\..\include\IAnimatedMeshSceneNode.h"> - </File> - <File - RelativePath=".\..\..\include\IAnimatedMeshX.h"> - </File> - <File - RelativePath=".\..\..\include\IBillboardSceneNode.h"> - </File> - <File - RelativePath=".\..\..\include\ICameraSceneNode.h"> - </File> - <File - RelativePath=".\..\..\include\IDummyTransformationSceneNode.h"> - </File> - <File - RelativePath=".\..\..\include\ILightSceneNode.h"> - </File> - <File - RelativePath=".\..\..\include\IMesh.h"> - </File> - <File - RelativePath=".\..\..\include\IMeshBuffer.h"> - </File> - <File - RelativePath=".\..\..\include\IMeshCache.h"> - </File> - <File - RelativePath=".\..\..\include\IMeshLoader.h"> - </File> - <File - RelativePath=".\..\..\include\IMeshManipulator.h"> - </File> - <File - RelativePath=".\..\..\include\IMeshSceneNode.h"> - </File> - <File - RelativePath="..\..\include\IMeshWriter.h"> - </File> - <File - RelativePath=".\..\..\include\IMetaTriangleSelector.h"> - </File> - <File - RelativePath=".\..\..\include\IParticleAffector.h"> - </File> - <File - RelativePath=".\..\..\include\IParticleEmitter.h"> - </File> - <File - RelativePath=".\..\..\include\IParticleSystemSceneNode.h"> - </File> - <File - RelativePath=".\..\..\include\IQ3LevelMesh.h"> - </File> - <File - RelativePath="..\..\include\IQ3Shader.h"> - </File> - <File - RelativePath=".\..\..\include\ISceneCollisionManager.h"> - </File> - <File - RelativePath=".\..\..\include\ISceneManager.h"> - </File> - <File - RelativePath=".\..\..\include\ISceneNode.h"> - </File> - <File - RelativePath=".\..\..\include\ISceneNodeAnimator.h"> - </File> - <File - RelativePath=".\..\..\include\ISceneNodeAnimatorCameraFPS.h"> - </File> - <File - RelativePath=".\..\..\include\ISceneNodeAnimatorCameraMaya.h"> - </File> - <File - RelativePath=".\..\..\include\ISceneNodeAnimatorCollisionResponse.h"> - </File> - <File - RelativePath=".\..\..\include\ISceneNodeAnimatorFactory.h"> - </File> - <File - RelativePath=".\..\..\include\ISceneNodeFactory.h"> - </File> - <File - RelativePath=".\..\..\include\ISceneNodeMeshLoader.h"> - </File> - <File - RelativePath=".\..\..\include\IShadowVolumeSceneNode.h"> - </File> - <File - RelativePath="..\..\include\ISkinnedMesh.h"> - </File> - <File - RelativePath=".\..\..\include\ITerrainSceneNode.h"> - </File> - <File - RelativePath=".\..\..\include\ITextSceneNode.h"> - </File> - <File - RelativePath=".\..\..\include\ITriangleSelector.h"> - </File> - <File - RelativePath=".\..\..\include\IVolumeLightSceneNode.h"> - </File> - <File - RelativePath=".\..\..\include\SAnimatedMesh.h"> - </File> - <File - RelativePath=".\..\..\include\SceneParameters.h"> - </File> - <File - RelativePath=".\..\..\include\SMesh.h"> - </File> - <File - RelativePath=".\..\..\include\SMeshBuffer.h"> - </File> - <File - RelativePath=".\..\..\include\SMeshBufferLightMap.h"> - </File> - <File - RelativePath=".\..\..\include\SMeshBufferTangents.h"> - </File> - <File - RelativePath=".\..\..\include\SParticle.h"> - </File> - <File - RelativePath=".\..\..\include\SSkinMeshBuffer.h"> - </File> - <File - RelativePath=".\..\..\include\SViewFrustum.h"> - </File> - </Filter> - <Filter - Name="gui"> - <File - RelativePath=".\..\..\include\EGUIElementTypes.h"> - </File> - <File - RelativePath="..\..\include\EMessageBoxFlags.h"> - </File> - <File - RelativePath=".\..\..\include\ICursorControl.h"> - </File> - <File - RelativePath=".\..\..\include\IGUIButton.h"> - </File> - <File - RelativePath=".\..\..\include\IGUICheckbox.h"> - </File> - <File - RelativePath=".\..\..\include\IGUIComboBox.h"> - </File> - <File - RelativePath=".\..\..\include\IGUIContextMenu.h"> - </File> - <File - RelativePath=".\..\..\include\IGUIEditBox.h"> - </File> - <File - RelativePath=".\..\..\include\IGUIElement.h"> - </File> - <File - RelativePath="..\..\include\IGUIElementFactory.h"> - </File> - <File - RelativePath=".\..\..\include\IGUIEnvironment.h"> - </File> - <File - RelativePath=".\..\..\include\IGUIFileOpenDialog.h"> - </File> - <File - RelativePath=".\..\..\include\IGUIFont.h"> - </File> - <File - RelativePath=".\..\..\include\IGUIImage.h"> - </File> - <File - RelativePath="..\..\include\IGUIImageList.h"> - </File> - <File - RelativePath=".\..\..\include\IGUIInOutFader.h"> - </File> - <File - RelativePath=".\..\..\include\IGUIListBox.h"> - </File> - <File - RelativePath=".\..\..\include\IGUIMeshViewer.h"> - </File> - <File - RelativePath=".\..\..\include\IGUIScrollBar.h"> - </File> - <File - RelativePath=".\..\..\include\IGUISkin.h"> - </File> - <File - RelativePath="..\..\include\IGUISpinBox.h"> - </File> - <File - RelativePath="..\..\include\IGUISpriteBank.h"> - </File> - <File - RelativePath=".\..\..\include\IGUIStaticText.h"> - </File> - <File - RelativePath=".\..\..\include\IGUITabControl.h"> - </File> - <File - RelativePath=".\..\..\include\IGUITable.h"> - </File> - <File - RelativePath=".\..\..\include\IGUIToolbar.h"> - </File> - <File - RelativePath="..\..\include\IGUITreeView.h"> - </File> - <File - RelativePath=".\..\..\include\IGUIWindow.h"> - </File> - </Filter> - </Filter> - <Filter - Name="gui impl"> - <File - RelativePath="BuiltInFont.h"> - </File> - <File - RelativePath="CDefaultGUIElementFactory.cpp"> - </File> - <File - RelativePath="CDefaultGUIElementFactory.h"> - </File> - <File - RelativePath="CGUIButton.cpp"> - </File> - <File - RelativePath="CGUIButton.h"> - </File> - <File - RelativePath="CGUICheckbox.cpp"> - </File> - <File - RelativePath="CGUICheckbox.h"> - </File> - <File - RelativePath="CGUIColorSelectDialog.cpp"> - </File> - <File - RelativePath="CGUIColorSelectDialog.h"> - </File> - <File - RelativePath="CGUIComboBox.cpp"> - </File> - <File - RelativePath="CGUIComboBox.h"> - </File> - <File - RelativePath="CGUIContextMenu.cpp"> - </File> - <File - RelativePath="CGUIContextMenu.h"> - </File> - <File - RelativePath="CGUIEditBox.cpp"> - </File> - <File - RelativePath="CGUIEditBox.h"> - </File> - <File - RelativePath="CGUIEnvironment.cpp"> - </File> - <File - RelativePath="CGUIEnvironment.h"> - </File> - <File - RelativePath="CGUIFileOpenDialog.cpp"> - </File> - <File - RelativePath="CGUIFileOpenDialog.h"> - </File> - <File - RelativePath="CGUIFont.cpp"> - </File> - <File - RelativePath="CGUIFont.h"> - </File> - <File - RelativePath="CGUIImage.cpp"> - </File> - <File - RelativePath="CGUIImage.h"> - </File> - <File - RelativePath=".\CGUIImageList.cpp"> - </File> - <File - RelativePath=".\CGUIImageList.h"> - </File> - <File - RelativePath="CGUIInOutFader.cpp"> - </File> - <File - RelativePath="CGUIInOutFader.h"> - </File> - <File - RelativePath="CGUIListBox.cpp"> - </File> - <File - RelativePath="CGUIListBox.h"> - </File> - <File - RelativePath="CGUIMenu.cpp"> - </File> - <File - RelativePath="CGUIMenu.h"> - </File> - <File - RelativePath="CGUIMeshViewer.cpp"> - </File> - <File - RelativePath="CGUIMeshViewer.h"> - </File> - <File - RelativePath="CGUIMessageBox.cpp"> - </File> - <File - RelativePath="CGUIMessageBox.h"> - </File> - <File - RelativePath="CGUIModalScreen.cpp"> - </File> - <File - RelativePath="CGUIModalScreen.h"> - </File> - <File - RelativePath="CGUIScrollBar.cpp"> - </File> - <File - RelativePath="CGUIScrollBar.h"> - </File> - <File - RelativePath="CGUISkin.cpp"> - </File> - <File - RelativePath="CGUISkin.h"> - </File> - <File - RelativePath="CGUISpinBox.cpp"> - </File> - <File - RelativePath="CGUISpinBox.h"> - </File> - <File - RelativePath="CGUISpriteBank.cpp"> - </File> - <File - RelativePath="CGUISpriteBank.h"> - </File> - <File - RelativePath="CGUIStaticText.cpp"> - </File> - <File - RelativePath="CGUIStaticText.h"> - </File> - <File - RelativePath="CGUITabControl.cpp"> - </File> - <File - RelativePath="CGUITabControl.h"> - </File> - <File - RelativePath="CGUITable.cpp"> - </File> - <File - RelativePath="CGUITable.h"> - </File> - <File - RelativePath="CGUIToolBar.cpp"> - </File> - <File - RelativePath="CGUIToolBar.h"> - </File> - <File - RelativePath=".\CGUITreeView.cpp"> - </File> - <File - RelativePath=".\CGUITreeView.h"> - </File> - <File - RelativePath="CGUIWindow.cpp"> - </File> - <File - RelativePath="CGUIWindow.h"> - </File> - </Filter> - <Filter - Name="video impl"> - <File - RelativePath="CVideoModeList.cpp"> - </File> - <File - RelativePath="CVideoModeList.h"> - </File> - <Filter - Name="Software"> - <File - RelativePath="CSoftwareDriver.cpp"> - </File> - <File - RelativePath="CSoftwareDriver.h"> - </File> - <File - RelativePath="CSoftwareTexture.cpp"> - </File> - <File - RelativePath="CSoftwareTexture.h"> - </File> - <File - RelativePath="CTRFlat.cpp"> - </File> - <File - RelativePath="CTRFlatWire.cpp"> - </File> - <File - RelativePath="CTRGouraud.cpp"> - </File> - <File - RelativePath="CTRGouraudWire.cpp"> - </File> - <File - RelativePath="CTRTextureFlat.cpp"> - </File> - <File - RelativePath="CTRTextureFlatWire.cpp"> - </File> - <File - RelativePath="CTRTextureGouraud.cpp"> - </File> - <File - RelativePath="CTRTextureGouraud.h"> - </File> - <File - RelativePath="CTRTextureGouraudAdd.cpp"> - </File> - <File - RelativePath="CTRTextureGouraudNoZ.cpp"> - </File> - <File - RelativePath="CTRTextureGouraudWire.cpp"> - </File> - <File - RelativePath="CZBuffer.cpp"> - </File> - <File - RelativePath="CZBuffer.h"> - </File> - <File - RelativePath="ITriangleRenderer.h"> - </File> - <File - RelativePath="IZBuffer.h"> - </File> - <File - RelativePath="S2DVertex.h"> - </File> - </Filter> - <Filter - Name="OpenGL"> - <File - RelativePath="COpenGLDriver.cpp"> - </File> - <File - RelativePath="COpenGLDriver.h"> - </File> - <File - RelativePath="COpenGLExtensionHandler.cpp"> - </File> - <File - RelativePath="COpenGLExtensionHandler.h"> - </File> - <File - RelativePath="COpenGLMaterialRenderer.h"> - </File> - <File - RelativePath="COpenGLNormalMapRenderer.cpp"> - </File> - <File - RelativePath="COpenGLNormalMapRenderer.h"> - </File> - <File - RelativePath="COpenGLParallaxMapRenderer.cpp"> - </File> - <File - RelativePath="COpenGLParallaxMapRenderer.h"> - </File> - <File - RelativePath="COpenGLShaderMaterialRenderer.cpp"> - </File> - <File - RelativePath="COpenGLShaderMaterialRenderer.h"> - </File> - <File - RelativePath="COpenGLSLMaterialRenderer.cpp"> - </File> - <File - RelativePath="COpenGLSLMaterialRenderer.h"> - </File> - <File - RelativePath="COpenGLTexture.cpp"> - </File> - <File - RelativePath="COpenGLTexture.h"> - </File> - <File - RelativePath="glext.h"> - </File> - </Filter> - <Filter - Name="Direct3D8"> - <File - RelativePath="CD3D8Driver.cpp"> - </File> - <File - RelativePath="CD3D8Driver.h"> - </File> - <File - RelativePath="CD3D8MaterialRenderer.h"> - </File> - <File - RelativePath="CD3D8NormalMapRenderer.cpp"> - </File> - <File - RelativePath="CD3D8NormalMapRenderer.h"> - </File> - <File - RelativePath="CD3D8ParallaxMapRenderer.cpp"> - </File> - <File - RelativePath="CD3D8ParallaxMapRenderer.h"> - </File> - <File - RelativePath="CD3D8ShaderMaterialRenderer.cpp"> - </File> - <File - RelativePath="CD3D8ShaderMaterialRenderer.h"> - </File> - <File - RelativePath="CD3D8Texture.cpp"> - </File> - <File - RelativePath="CD3D8Texture.h"> - </File> - </Filter> - <Filter - Name="Null"> - <File - RelativePath="CColorConverter.cpp"> - </File> - <File - RelativePath="CColorConverter.h"> - </File> - <File - RelativePath="CFPSCounter.cpp"> - </File> - <File - RelativePath="CFPSCounter.h"> - </File> - <File - RelativePath="CImage.cpp"> - </File> - <File - RelativePath="CImage.h"> - </File> - <File - RelativePath="CImageLoaderBMP.cpp"> - </File> - <File - RelativePath="CImageLoaderBMP.h"> - </File> - <File - RelativePath="CImageLoaderJPG.cpp"> - </File> - <File - RelativePath="CImageLoaderJPG.h"> - </File> - <File - RelativePath="CImageLoaderPCX.cpp"> - </File> - <File - RelativePath="CImageLoaderPCX.h"> - </File> - <File - RelativePath="CImageLoaderPNG.cpp"> - </File> - <File - RelativePath="CImageLoaderPNG.h"> - </File> - <File - RelativePath="CImageLoaderPPM.cpp"> - </File> - <File - RelativePath="CImageLoaderPPM.h"> - </File> - <File - RelativePath="CImageLoaderPSD.cpp"> - </File> - <File - RelativePath="CImageLoaderPSD.h"> - </File> - <File - RelativePath="CImageLoaderRGB.cpp"> - </File> - <File - RelativePath="CImageLoaderRGB.h"> - </File> - <File - RelativePath="CImageLoaderTGA.cpp"> - </File> - <File - RelativePath="CImageLoaderTGA.h"> - </File> - <File - RelativePath="CImageLoaderWAL.cpp"> - </File> - <File - RelativePath="CImageLoaderWAL.h"> - </File> - <File - RelativePath="CNullDriver.cpp"> - </File> - <File - RelativePath="CNullDriver.h"> - </File> - <File - RelativePath="IImagePresenter.h"> - </File> - <Filter - Name="Writer"> - <File - RelativePath="CImageWriterBMP.cpp"> - </File> - <File - RelativePath="CImageWriterBMP.h"> - </File> - <File - RelativePath="CImageWriterJPG.cpp"> - </File> - <File - RelativePath="CImageWriterJPG.h"> - </File> - <File - RelativePath="CImageWriterPCX.cpp"> - </File> - <File - RelativePath="CImageWriterPCX.h"> - </File> - <File - RelativePath="CImageWriterPNG.cpp"> - </File> - <File - RelativePath="CImageWriterPNG.h"> - </File> - <File - RelativePath="CImageWriterPPM.cpp"> - </File> - <File - RelativePath="CImageWriterPPM.h"> - </File> - <File - RelativePath="CImageWriterPSD.cpp"> - </File> - <File - RelativePath="CImageWriterPSD.h"> - </File> - <File - RelativePath="CImageWriterTGA.cpp"> - </File> - <File - RelativePath="CImageWriterTGA.h"> - </File> - </Filter> - </Filter> - <Filter - Name="Direct3D9"> - <File - RelativePath="CD3D9Driver.cpp"> - </File> - <File - RelativePath="CD3D9Driver.h"> - </File> - <File - RelativePath="CD3D9HLSLMaterialRenderer.cpp"> - </File> - <File - RelativePath="CD3D9HLSLMaterialRenderer.h"> - </File> - <File - RelativePath="CD3D9MaterialRenderer.h"> - </File> - <File - RelativePath="CD3D9NormalMapRenderer.cpp"> - </File> - <File - RelativePath="CD3D9NormalMapRenderer.h"> - </File> - <File - RelativePath="CD3D9ParallaxMapRenderer.cpp"> - </File> - <File - RelativePath="CD3D9ParallaxMapRenderer.h"> - </File> - <File - RelativePath="CD3D9ShaderMaterialRenderer.cpp"> - </File> - <File - RelativePath="CD3D9ShaderMaterialRenderer.h"> - </File> - <File - RelativePath="CD3D9Texture.cpp"> - </File> - <File - RelativePath="CD3D9Texture.h"> - </File> - </Filter> - <Filter - Name="Burning Video"> - <File - RelativePath="CBurningShader_Raster_Reference.cpp"> - </File> - <File - RelativePath="CDepthBuffer.cpp"> - </File> - <File - RelativePath="CDepthBuffer.h"> - </File> - <File - RelativePath="CSoftware2MaterialRenderer.h"> - </File> - <File - RelativePath="CSoftwareDriver2.cpp"> - </File> - <File - RelativePath="CSoftwareDriver2.h"> - </File> - <File - RelativePath="CSoftwareTexture2.cpp"> - </File> - <File - RelativePath="CSoftwareTexture2.h"> - </File> - <File - RelativePath="CTRGouraud2.cpp"> - </File> - <File - RelativePath="CTRGouraudAlpha2.cpp"> - </File> - <File - RelativePath="CTRGouraudAlphaNoZ2.cpp"> - </File> - <File - RelativePath="CTRTextureBlend.cpp"> - </File> - <File - RelativePath="CTRTextureDetailMap2.cpp"> - </File> - <File - RelativePath="CTRTextureGouraud2.cpp"> - </File> - <File - RelativePath="CTRTextureGouraudAdd2.cpp"> - </File> - <File - RelativePath="CTRTextureGouraudAddNoZ2.cpp"> - </File> - <File - RelativePath="CTRTextureGouraudAlpha.cpp"> - </File> - <File - RelativePath="CTRTextureGouraudAlphaNoZ.cpp"> - </File> - <File - RelativePath="CTRTextureGouraudNoZ2.cpp"> - </File> - <File - RelativePath="CTRTextureGouraudVertexAlpha2.cpp"> - </File> - <File - RelativePath="CTRTextureLightMap2_Add.cpp"> - </File> - <File - RelativePath="CTRTextureLightMap2_M1.cpp"> - </File> - <File - RelativePath="CTRTextureLightMap2_M2.cpp"> - </File> - <File - RelativePath="CTRTextureLightMap2_M4.cpp"> - </File> - <File - RelativePath="CTRTextureLightMapGouraud2_M4.cpp"> - </File> - <File - RelativePath="CTRTextureWire2.cpp"> - </File> - <File - RelativePath="IBurningShader.cpp"> - </File> - <File - RelativePath="IBurningShader.h"> - </File> - <File - RelativePath="IDepthBuffer.h"> - </File> - <File - RelativePath="S4DVertex.h"> - </File> - <File - RelativePath="SoftwareDriver2_compile_config.h"> - </File> - <File - RelativePath="SoftwareDriver2_helper.h"> - </File> - </Filter> - </Filter> - <Filter - Name="scene impl"> - <File - RelativePath="CDefaultSceneNodeAnimatorFactory.cpp"> - </File> - <File - RelativePath="CDefaultSceneNodeAnimatorFactory.h"> - </File> - <File - RelativePath="CDefaultSceneNodeFactory.cpp"> - </File> - <File - RelativePath="CDefaultSceneNodeFactory.h"> - </File> - <File - RelativePath="CGeometryCreator.cpp"> - </File> - <File - RelativePath="CGeometryCreator.h"> - </File> - <File - RelativePath="CMeshCache.cpp"> - </File> - <File - RelativePath="CMeshCache.h"> - </File> - <File - RelativePath="CMeshManipulator.cpp"> - </File> - <File - RelativePath="CMeshManipulator.h"> - </File> - <File - RelativePath="CSceneManager.cpp"> - </File> - <File - RelativePath="CSceneManager.h"> - </File> - <File - RelativePath="OctTree.h"> - </File> - <Filter - Name="loaders"> - <File - RelativePath="C3DSMeshFileLoader.cpp"> - </File> - <File - RelativePath="C3DSMeshFileLoader.h"> - </File> - <File - RelativePath="CAnimatedMeshMD2.cpp"> - </File> - <File - RelativePath="CAnimatedMeshMD2.h"> - </File> - <File - RelativePath=".\CAnimatedMeshMD3.cpp"> - </File> - <File - RelativePath=".\CAnimatedMeshMD3.h"> - </File> - <File - RelativePath=".\CB3DMeshFileLoader.cpp"> - </File> - <File - RelativePath=".\CB3DMeshFileLoader.h"> - </File> - <File - RelativePath=".\CBSPMeshFileLoader.cpp"> - </File> - <File - RelativePath=".\CBSPMeshFileLoader.h"> - </File> - <File - RelativePath=".\CColladaFileLoader.cpp"> - </File> - <File - RelativePath=".\CColladaFileLoader.h"> - </File> - <File - RelativePath=".\CCSMLoader.cpp"> - </File> - <File - RelativePath=".\CCSMLoader.h"> - </File> - <File - RelativePath=".\CDMFLoader.cpp"> - </File> - <File - RelativePath=".\CDMFLoader.h"> - </File> - <File - RelativePath=".\CIrrMeshFileLoader.cpp"> - </File> - <File - RelativePath=".\CIrrMeshFileLoader.h"> - </File> - <File - RelativePath=".\CLMTSMeshFileLoader.cpp"> - </File> - <File - RelativePath=".\CLMTSMeshFileLoader.h"> - </File> - <File - RelativePath=".\CLWOMeshFileLoader.cpp"> - </File> - <File - RelativePath=".\CLWOMeshFileLoader.h"> - </File> - <File - RelativePath=".\CMD2MeshFileLoader.cpp"> - </File> - <File - RelativePath=".\CMD2MeshFileLoader.h"> - </File> - <File - RelativePath=".\CMD3MeshFileLoader.cpp"> - </File> - <File - RelativePath=".\CMD3MeshFileLoader.h"> - </File> - <File - RelativePath=".\CMS3DMeshFileLoader.cpp"> - </File> - <File - RelativePath=".\CMS3DMeshFileLoader.h"> - </File> - <File - RelativePath=".\CMY3DHelper.h"> - </File> - <File - RelativePath=".\CMY3DMeshFileLoader.cpp"> - </File> - <File - RelativePath=".\CMY3DMeshFileLoader.h"> - </File> - <File - RelativePath=".\COBJMeshFileLoader.cpp"> - </File> - <File - RelativePath=".\COBJMeshFileLoader.h"> - </File> - <File - RelativePath=".\COCTLoader.cpp"> - </File> - <File - RelativePath=".\COCTLoader.h"> - </File> - <File - RelativePath=".\COgreMeshFileLoader.cpp"> - </File> - <File - RelativePath=".\COgreMeshFileLoader.h"> - </File> - <File - RelativePath=".\CPLYMeshFileLoader.cpp"> - </File> - <File - RelativePath=".\CPLYMeshFileLoader.h"> - </File> - <File - RelativePath=".\CQ3LevelMesh.cpp"> - </File> - <File - RelativePath=".\CQ3LevelMesh.h"> - </File> - <File - RelativePath=".\CSkinnedMesh.cpp"> - </File> - <File - RelativePath=".\CSkinnedMesh.h"> - </File> - <File - RelativePath="CSTLMeshFileLoader.cpp"> - </File> - <File - RelativePath="CSTLMeshFileLoader.h"> - </File> - <File - RelativePath="CXMeshFileLoader.cpp"> - </File> - <File - RelativePath="CXMeshFileLoader.h"> - </File> - <File - RelativePath=".\dmfsupport.h"> - </File> - </Filter> - <Filter - Name="sceneNodes"> - <File - RelativePath=".\CAnimatedMeshSceneNode.cpp"> - </File> - <File - RelativePath=".\CAnimatedMeshSceneNode.h"> - </File> - <File - RelativePath=".\CBillboardSceneNode.cpp"> - </File> - <File - RelativePath=".\CBillboardSceneNode.h"> - </File> - <File - RelativePath=".\CBoneSceneNode.cpp"> - </File> - <File - RelativePath=".\CBoneSceneNode.h"> - </File> - <File - RelativePath=".\CCameraSceneNode.cpp"> - </File> - <File - RelativePath=".\CCameraSceneNode.h"> - </File> - <File - RelativePath=".\CCubeSceneNode.cpp"> - </File> - <File - RelativePath=".\CCubeSceneNode.h"> - </File> - <File - RelativePath="CDummyTransformationSceneNode.cpp"> - </File> - <File - RelativePath="CDummyTransformationSceneNode.h"> - </File> - <File - RelativePath="CEmptySceneNode.cpp"> - </File> - <File - RelativePath="CEmptySceneNode.h"> - </File> - <File - RelativePath=".\CLightSceneNode.cpp"> - </File> - <File - RelativePath=".\CLightSceneNode.h"> - </File> - <File - RelativePath=".\CMeshSceneNode.cpp"> - </File> - <File - RelativePath=".\CMeshSceneNode.h"> - </File> - <File - RelativePath=".\COctTreeSceneNode.cpp"> - </File> - <File - RelativePath=".\COctTreeSceneNode.h"> - </File> - <File - RelativePath=".\CQuake3ShaderSceneNode.cpp"> - </File> - <File - RelativePath=".\CQuake3ShaderSceneNode.h"> - </File> - <File - RelativePath=".\CShadowVolumeSceneNode.cpp"> - </File> - <File - RelativePath=".\CShadowVolumeSceneNode.h"> - </File> - <File - RelativePath=".\CSkyBoxSceneNode.cpp"> - </File> - <File - RelativePath=".\CSkyBoxSceneNode.h"> - </File> - <File - RelativePath=".\CSkyDomeSceneNode.cpp"> - </File> - <File - RelativePath=".\CSkyDomeSceneNode.h"> - </File> - <File - RelativePath=".\CSphereSceneNode.cpp"> - </File> - <File - RelativePath=".\CSphereSceneNode.h"> - </File> - <File - RelativePath="CTerrainSceneNode.cpp"> - </File> - <File - RelativePath="CTerrainSceneNode.h"> - </File> - <File - RelativePath=".\CTextSceneNode.cpp"> - </File> - <File - RelativePath=".\CTextSceneNode.h"> - </File> - <File - RelativePath=".\CVolumeLightSceneNode.cpp"> - </File> - <File - RelativePath=".\CVolumeLightSceneNode.h"> - </File> - <File - RelativePath="CWaterSurfaceSceneNode.cpp"> - </File> - <File - RelativePath="CWaterSurfaceSceneNode.h"> - </File> - </Filter> - <Filter - Name="particleSystem"> - <File - RelativePath="CParticleAnimatedMeshSceneNodeEmitter.cpp"> - </File> - <File - RelativePath="CParticleAttractionAffector.cpp"> - </File> - <File - RelativePath="CParticleBoxEmitter.cpp"> - </File> - <File - RelativePath="CParticleBoxEmitter.h"> - </File> - <File - RelativePath="CParticleCylinderEmitter.cpp"> - </File> - <File - RelativePath="CParticleFadeOutAffector.cpp"> - </File> - <File - RelativePath="CParticleFadeOutAffector.h"> - </File> - <File - RelativePath="CParticleGravityAffector.cpp"> - </File> - <File - RelativePath="CParticleGravityAffector.h"> - </File> - <File - RelativePath="CParticleMeshEmitter.cpp"> - </File> - <File - RelativePath="CParticlePointEmitter.cpp"> - </File> - <File - RelativePath="CParticlePointEmitter.h"> - </File> - <File - RelativePath="CParticleRingEmitter.cpp"> - </File> - <File - RelativePath="CParticleRotationAffector.cpp"> - </File> - <File - RelativePath="CParticleScaleAffector.cpp"> - </File> - <File - RelativePath="CParticleScaleAffector.h"> - </File> - <File - RelativePath="CParticleSphereEmitter.cpp"> - </File> - <File - RelativePath="CParticleSystemSceneNode.cpp"> - </File> - <File - RelativePath="CParticleSystemSceneNode.h"> - </File> - </Filter> - <Filter - Name="collision"> - <File - RelativePath="CMetaTriangleSelector.cpp"> - </File> - <File - RelativePath="CMetaTriangleSelector.h"> - </File> - <File - RelativePath="COctTreeTriangleSelector.cpp"> - </File> - <File - RelativePath="COctTreeTriangleSelector.h"> - </File> - <File - RelativePath="CSceneCollisionManager.cpp"> - </File> - <File - RelativePath="CSceneCollisionManager.h"> - </File> - <File - RelativePath="CTerrainTriangleSelector.cpp"> - </File> - <File - RelativePath="CTerrainTriangleSelector.h"> - </File> - <File - RelativePath="CTriangleBBSelector.cpp"> - </File> - <File - RelativePath="CTriangleBBSelector.h"> - </File> - <File - RelativePath="CTriangleSelector.cpp"> - </File> - <File - RelativePath="CTriangleSelector.h"> - </File> - </Filter> - <Filter - Name="animators"> - <File - RelativePath="CSceneNodeAnimatorCameraFPS.cpp"> - </File> - <File - RelativePath="CSceneNodeAnimatorCameraFPS.h"> - </File> - <File - RelativePath="CSceneNodeAnimatorCameraMaya.cpp"> - </File> - <File - RelativePath="CSceneNodeAnimatorCameraMaya.h"> - </File> - <File - RelativePath="CSceneNodeAnimatorCollisionResponse.cpp"> - </File> - <File - RelativePath="CSceneNodeAnimatorCollisionResponse.h"> - </File> - <File - RelativePath="CSceneNodeAnimatorDelete.cpp"> - </File> - <File - RelativePath="CSceneNodeAnimatorDelete.h"> - </File> - <File - RelativePath="CSceneNodeAnimatorFlyCircle.cpp"> - </File> - <File - RelativePath="CSceneNodeAnimatorFlyCircle.h"> - </File> - <File - RelativePath="CSceneNodeAnimatorFlyStraight.cpp"> - </File> - <File - RelativePath="CSceneNodeAnimatorFlyStraight.h"> - </File> - <File - RelativePath="CSceneNodeAnimatorFollowSpline.cpp"> - </File> - <File - RelativePath="CSceneNodeAnimatorFollowSpline.h"> - </File> - <File - RelativePath="CSceneNodeAnimatorRotation.cpp"> - </File> - <File - RelativePath="CSceneNodeAnimatorRotation.h"> - </File> - <File - RelativePath="CSceneNodeAnimatorTexture.cpp"> - </File> - <File - RelativePath="CSceneNodeAnimatorTexture.h"> - </File> - </Filter> - <Filter - Name="writers" - Filter=""> - <File - RelativePath="CColladaMeshWriter.cpp"> - </File> - <File - RelativePath="CColladaMeshWriter.h"> - </File> - <File - RelativePath="CIrrMeshWriter.cpp"> - </File> - <File - RelativePath="CIrrMeshWriter.h"> - </File> - <File - RelativePath="COBJMeshWriter.cpp"> - </File> - <File - RelativePath="COBJMeshWriter.h"> - </File> - <File - RelativePath="CPLYMeshWriter.cpp"> - </File> - <File - RelativePath="CPLYMeshWriter.h"> - </File> - <File - RelativePath="CSTLMeshWriter.cpp"> - </File> - <File - RelativePath="CSTLMeshWriter.h"> - </File> - </Filter> - </Filter> - <Filter - Name="io impl"> - <File - RelativePath=".\CAttributeImpl.h"> - </File> - <File - RelativePath=".\CAttributes.cpp"> - </File> - <File - RelativePath=".\CAttributes.h"> - </File> - <File - RelativePath=".\CFileList.cpp"> - </File> - <File - RelativePath=".\CFileList.h"> - </File> - <File - RelativePath=".\CFileSystem.cpp"> - </File> - <File - RelativePath=".\CFileSystem.h"> - </File> - <File - RelativePath=".\CLimitReadFile.cpp"> - </File> - <File - RelativePath=".\CLimitReadFile.h"> - </File> - <File - RelativePath=".\CMemoryFile.cpp"> - </File> - <File - RelativePath=".\CMemoryFile.h"> - </File> - <File - RelativePath=".\CMountPointReader.cpp"> - </File> - <File - RelativePath=".\CMountPointReader.h"> - </File> - <File - RelativePath=".\CPakReader.cpp"> - </File> - <File - RelativePath=".\CPakReader.h"> - </File> - <File - RelativePath=".\CReadFile.cpp"> - </File> - <File - RelativePath=".\CReadFile.h"> - </File> - <File - RelativePath=".\CTarReader.cpp"> - </File> - <File - RelativePath=".\CTarReader.h"> - </File> - <File - RelativePath="CWriteFile.cpp"> - </File> - <File - RelativePath="CWriteFile.h"> - </File> - <File - RelativePath="CXMLReader.cpp"> - </File> - <File - RelativePath="CXMLReader.h"> - </File> - <File - RelativePath=".\CXMLReaderImpl.h"> - </File> - <File - RelativePath="CXMLWriter.cpp"> - </File> - <File - RelativePath="CXMLWriter.h"> - </File> - <File - RelativePath=".\CZipReader.cpp"> - </File> - <File - RelativePath=".\CZipReader.h"> - </File> - <File - RelativePath=".\irrXML.cpp"> - </File> - </Filter> - <Filter - Name="irr impl"> - <File - RelativePath="CIrrDeviceConsole.cpp"> - </File> - <File - RelativePath="CIrrDeviceConsole.h"> - </File> - <File - RelativePath="CIrrDeviceLinux.cpp"> - </File> - <File - RelativePath="CIrrDeviceLinux.h"> - </File> - <File - RelativePath="CIrrDeviceStub.cpp"> - </File> - <File - RelativePath="CIrrDeviceStub.h"> - </File> - <File - RelativePath="CIrrDeviceWin32.cpp"> - </File> - <File - RelativePath="CIrrDeviceWin32.h"> - </File> - <File - RelativePath="CLogger.cpp"> - </File> - <File - RelativePath="CLogger.h"> - </File> - <File - RelativePath="COSOperator.cpp"> - </File> - <File - RelativePath="COSOperator.h"> - </File> - <File - RelativePath="CTimer.h"> - </File> - <File - RelativePath=".\Irrlicht.cpp"> - </File> - <File - RelativePath="os.cpp"> - </File> - <File - RelativePath="os.h"> - </File> - <Filter - Name="extern"> - <Filter - Name="zlib"> - <File - RelativePath="zlib\adler32.c"> - </File> - <File - RelativePath=".\zlib\compress.c"> - </File> - <File - RelativePath=".\zlib\crc32.c"> - </File> - <File - RelativePath=".\zlib\crc32.h"> - </File> - <File - RelativePath=".\zlib\deflate.c"> - </File> - <File - RelativePath="zlib\deflate.h"> - </File> - <File - RelativePath="zlib\inffast.c"> - </File> - <File - RelativePath="zlib\inffast.h"> - </File> - <File - RelativePath="zlib\inffixed.h"> - </File> - <File - RelativePath="zlib\inflate.c"> - </File> - <File - RelativePath="zlib\inftrees.c"> - </File> - <File - RelativePath="zlib\inftrees.h"> - </File> - <File - RelativePath="zlib\trees.c"> - </File> - <File - RelativePath="zlib\trees.h"> - </File> - <File - RelativePath="zlib\uncompr.c"> - </File> - <File - RelativePath="zlib\zconf.h"> - </File> - <File - RelativePath="zlib\zlib.h"> - </File> - <File - RelativePath="zlib\zutil.c"> - </File> - <File - RelativePath="zlib\zutil.h"> - </File> - </Filter> - <Filter - Name="jpeglib"> - <File - RelativePath="jpeglib\cderror.h"> - </File> - <File - RelativePath="jpeglib\jcapimin.c"> - </File> - <File - RelativePath="jpeglib\jcapistd.c"> - </File> - <File - RelativePath="jpeglib\jccoefct.c"> - </File> - <File - RelativePath="jpeglib\jccolor.c"> - </File> - <File - RelativePath="jpeglib\jcdctmgr.c"> - </File> - <File - RelativePath="jpeglib\jchuff.c"> - </File> - <File - RelativePath="jpeglib\jchuff.h"> - </File> - <File - RelativePath="jpeglib\jcinit.c"> - </File> - <File - RelativePath="jpeglib\jcmainct.c"> - </File> - <File - RelativePath="jpeglib\jcmarker.c"> - </File> - <File - RelativePath="jpeglib\jcmaster.c"> - </File> - <File - RelativePath="jpeglib\jcomapi.c"> - </File> - <File - RelativePath="jpeglib\jconfig.h"> - </File> - <File - RelativePath="jpeglib\jcparam.c"> - </File> - <File - RelativePath="jpeglib\jcphuff.c"> - </File> - <File - RelativePath="jpeglib\jcprepct.c"> - </File> - <File - RelativePath="jpeglib\jcsample.c"> - </File> - <File - RelativePath="jpeglib\jctrans.c"> - </File> - <File - RelativePath="jpeglib\jdapimin.c"> - </File> - <File - RelativePath="jpeglib\jdapistd.c"> - </File> - <File - RelativePath="jpeglib\jdatadst.c"> - </File> - <File - RelativePath="jpeglib\jdatasrc.c"> - </File> - <File - RelativePath="jpeglib\jdcoefct.c"> - </File> - <File - RelativePath="jpeglib\jdcolor.c"> - </File> - <File - RelativePath="jpeglib\jdct.h"> - </File> - <File - RelativePath="jpeglib\jddctmgr.c"> - </File> - <File - RelativePath="jpeglib\jdhuff.c"> - </File> - <File - RelativePath="jpeglib\jdhuff.h"> - </File> - <File - RelativePath="jpeglib\jdinput.c"> - </File> - <File - RelativePath="jpeglib\jdmainct.c"> - </File> - <File - RelativePath="jpeglib\jdmarker.c"> - </File> - <File - RelativePath="jpeglib\jdmaster.c"> - </File> - <File - RelativePath="jpeglib\jdmerge.c"> - </File> - <File - RelativePath="jpeglib\jdphuff.c"> - </File> - <File - RelativePath="jpeglib\jdpostct.c"> - </File> - <File - RelativePath="jpeglib\jdsample.c"> - </File> - <File - RelativePath="jpeglib\jdtrans.c"> - </File> - <File - RelativePath="jpeglib\jerror.c"> - </File> - <File - RelativePath="jpeglib\jerror.h"> - </File> - <File - RelativePath="jpeglib\jfdctflt.c"> - </File> - <File - RelativePath="jpeglib\jfdctfst.c"> - </File> - <File - RelativePath="jpeglib\jfdctint.c"> - </File> - <File - RelativePath="jpeglib\jidctflt.c"> - </File> - <File - RelativePath="jpeglib\jidctfst.c"> - </File> - <File - RelativePath="jpeglib\jidctint.c"> - </File> - <File - RelativePath="jpeglib\jidctred.c"> - </File> - <File - RelativePath="jpeglib\jinclude.h"> - </File> - <File - RelativePath="jpeglib\jmemmgr.c"> - </File> - <File - RelativePath="jpeglib\jmemnobs.c"> - </File> - <File - RelativePath="jpeglib\jmemsys.h"> - </File> - <File - RelativePath="jpeglib\jmorecfg.h"> - </File> - <File - RelativePath="jpeglib\jpegint.h"> - </File> - <File - RelativePath="jpeglib\jpeglib.h"> - </File> - <File - RelativePath="jpeglib\jquant1.c"> - </File> - <File - RelativePath="jpeglib\jquant2.c"> - </File> - <File - RelativePath="jpeglib\jutils.c"> - </File> - <File - RelativePath="jpeglib\jversion.h"> - </File> - </Filter> - <Filter - Name="libpng"> - <File - RelativePath=".\libpng\png.c"> - </File> - <File - RelativePath=".\libpng\png.h"> - </File> - <File - RelativePath=".\libpng\pngconf.h"> - </File> - <File - RelativePath=".\libpng\pngerror.c"> - </File> - <File - RelativePath=".\libpng\pngget.c"> - </File> - <File - RelativePath=".\libpng\pngmem.c"> - </File> - <File - RelativePath=".\libpng\pngpread.c"> - </File> - <File - RelativePath=".\libpng\pngread.c"> - </File> - <File - RelativePath=".\libpng\pngrio.c"> - </File> - <File - RelativePath=".\libpng\pngrtran.c"> - </File> - <File - RelativePath=".\libpng\pngrutil.c"> - </File> - <File - RelativePath=".\libpng\pngset.c"> - </File> - <File - RelativePath=".\libpng\pngtrans.c"> - </File> - <File - RelativePath=".\libpng\pngwio.c"> - </File> - <File - RelativePath=".\libpng\pngwrite.c"> - </File> - <File - RelativePath=".\libpng\pngwtran.c"> - </File> - <File - RelativePath=".\libpng\pngwutil.c"> - </File> - </Filter> - </Filter> - </Filter> - <Filter - Name="doc"> - <File - RelativePath="..\..\changes.txt"> - </File> - <File - RelativePath="..\..\readme.txt"> - </File> - </Filter> - </Files> - <Globals> - </Globals> -</VisualStudioProject> diff --git a/irrlicht-1.6/source/Irrlicht/Irrlicht8.0.sln b/irrlicht-1.6/source/Irrlicht/Irrlicht8.0.sln deleted file mode 100644 index e9759b209..000000000 --- a/irrlicht-1.6/source/Irrlicht/Irrlicht8.0.sln +++ /dev/null @@ -1,29 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Irrlicht", "Irrlicht8.0.vcproj", "{E08E042A-6C45-411B-92BE-3CC31331019F}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - Static lib - Debug|Win32 = Static lib - Debug|Win32 - Static lib - Release - Fast FPU|Win32 = Static lib - Release - Fast FPU|Win32 - Static lib - Release|Win32 = Static lib - Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E08E042A-6C45-411B-92BE-3CC31331019F}.Debug|Win32.ActiveCfg = Debug|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Debug|Win32.Build.0 = Debug|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Release|Win32.ActiveCfg = Release|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Release|Win32.Build.0 = Release|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Debug|Win32.ActiveCfg = Static lib - Debug|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Debug|Win32.Build.0 = Static lib - Debug|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Release - Fast FPU|Win32.ActiveCfg = Static lib - Release - Fast FPU|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Release - Fast FPU|Win32.Build.0 = Static lib - Release - Fast FPU|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Release|Win32.ActiveCfg = Static lib - Release|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Release|Win32.Build.0 = Static lib - Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/irrlicht-1.6/source/Irrlicht/Irrlicht8.0.vcproj b/irrlicht-1.6/source/Irrlicht/Irrlicht8.0.vcproj deleted file mode 100644 index a9766994d..000000000 --- a/irrlicht-1.6/source/Irrlicht/Irrlicht8.0.vcproj +++ /dev/null @@ -1,3297 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?> -<VisualStudioProject - ProjectType="Visual C++" - Version="8,00" - Name="Irrlicht" - ProjectGUID="{E08E042A-6C45-411B-92BE-3CC31331019F}" - RootNamespace="Irrlicht" - > - <Platforms> - <Platform - Name="Win32" - /> - </Platforms> - <ToolFiles> - </ToolFiles> - <Configurations> - <Configuration - Name="Debug|Win32" - OutputDirectory="..\obj\IrrDebug" - IntermediateDirectory="..\obj\IrrDebug" - ConfigurationType="2" - InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="false" - CharacterSet="0" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - PreprocessorDefinitions="_DEBUG" - MkTypLibCompatible="true" - SuppressStartupBanner="true" - TargetEnvironment="1" - TypeLibraryName=".\..\Debug/Irrlicht.tlb" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - AdditionalIncludeDirectories="..\..\include;zlib" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;IRRLICHT_EXPORTS;_CRT_SECURE_NO_DEPRECATE" - ExceptionHandling="0" - BasicRuntimeChecks="3" - RuntimeLibrary="1" - DisableLanguageExtensions="false" - RuntimeTypeInfo="false" - PrecompiledHeaderFile=".\..\obj\IrrDebug/Irrlicht.pch" - AssemblerListingLocation=".\..\obj\IrrDebug/" - ObjectFile=".\..\obj\IrrDebug/" - ProgramDataBaseFileName=".\..\obj\IrrDebug/" - WarningLevel="3" - SuppressStartupBanner="true" - DebugInformationFormat="3" - CompileAs="0" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="_DEBUG" - Culture="3079" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - UseLibraryDependencyInputs="true" - AdditionalOptions="/MACHINE:I386" - AdditionalDependencies="kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib opengl32.lib winmm.lib" - OutputFile="..\..\bin\Win32-visualstudio\Irrlicht.dll" - LinkIncremental="2" - SuppressStartupBanner="true" - AdditionalLibraryDirectories="" - IgnoreDefaultLibraryNames="libci.lib" - GenerateDebugInformation="true" - ProgramDatabaseFile="..\obj\IrrDebug\Irrlicht.pdb" - ImportLibrary="..\..\lib\Win32-visualstudio\Irrlicht.lib" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCWebDeploymentTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - <Configuration - Name="Release|Win32" - OutputDirectory="obj\IrrRelease" - IntermediateDirectory="obj\IrrRelease" - ConfigurationType="2" - InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="false" - CharacterSet="2" - WholeProgramOptimization="1" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - PreprocessorDefinitions="NDEBUG" - MkTypLibCompatible="true" - SuppressStartupBanner="true" - TargetEnvironment="1" - TypeLibraryName=".\..\Release/Irrlicht.tlb" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="2" - InlineFunctionExpansion="1" - EnableIntrinsicFunctions="false" - AdditionalIncludeDirectories="..\..\include;zlib" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;IRRLICHT_EXPORTS;_CRT_SECURE_NO_DEPRECATE" - StringPooling="true" - ExceptionHandling="0" - RuntimeLibrary="0" - BufferSecurityCheck="false" - EnableFunctionLevelLinking="true" - PrecompiledHeaderFile=".\..\obj\IrrRelease/Irrlicht.pch" - AssemblerListingLocation=".\..\obj\IrrRelease/" - ObjectFile=".\..\obj\IrrRelease/" - ProgramDataBaseFileName=".\..\obj\IrrRelease/" - WarningLevel="3" - SuppressStartupBanner="true" - DebugInformationFormat="0" - CompileAs="0" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="NDEBUG" - Culture="3079" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - AdditionalOptions="/MACHINE:I386" - AdditionalDependencies="kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib opengl32.lib winmm.lib" - OutputFile="..\..\bin\Win32-visualstudio\Irrlicht.dll" - LinkIncremental="1" - SuppressStartupBanner="true" - IgnoreDefaultLibraryNames="libci.lib" - GenerateDebugInformation="false" - ProgramDatabaseFile="..\obj\IrrRelease\Irrlicht.pdb" - ImportLibrary="..\..\lib\Win32-visualstudio\Irrlicht.lib" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCWebDeploymentTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - <Configuration - Name="Release - Fast FPU|Win32" - OutputDirectory="$(ConfigurationName)" - IntermediateDirectory="$(ConfigurationName)" - ConfigurationType="2" - InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="false" - CharacterSet="2" - WholeProgramOptimization="1" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - PreprocessorDefinitions="NDEBUG" - MkTypLibCompatible="true" - SuppressStartupBanner="true" - TargetEnvironment="1" - TypeLibraryName=".\..\Release/Irrlicht.tlb" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="3" - InlineFunctionExpansion="2" - EnableIntrinsicFunctions="true" - FavorSizeOrSpeed="0" - OmitFramePointers="true" - AdditionalIncludeDirectories="..\..\include;zlib" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;IRRLICHT_EXPORTS;_CRT_SECURE_NO_DEPRECATE;" - StringPooling="true" - ExceptionHandling="0" - RuntimeLibrary="0" - BufferSecurityCheck="false" - EnableFunctionLevelLinking="true" - EnableEnhancedInstructionSet="1" - FloatingPointModel="2" - RuntimeTypeInfo="false" - PrecompiledHeaderFile=".\..\obj\IrrReleaseFastFPU/Irrlicht.pch" - ExpandAttributedSource="true" - AssemblerOutput="4" - AssemblerListingLocation=".\..\obj\IrrReleaseFastFPU/" - ObjectFile=".\..\obj\IrrReleaseFastFPU/" - ProgramDataBaseFileName=".\..\obj\IrrReleaseFastFPU/" - WarningLevel="3" - SuppressStartupBanner="true" - DebugInformationFormat="0" - CallingConvention="1" - CompileAs="0" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="NDEBUG" - Culture="3079" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - AdditionalOptions="/MACHINE:I386" - AdditionalDependencies="kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib opengl32.lib winmm.lib" - OutputFile="..\..\bin\Win32-visualstudio\Irrlicht.dll" - LinkIncremental="1" - SuppressStartupBanner="true" - IgnoreDefaultLibraryNames="libci.lib" - GenerateDebugInformation="false" - ProgramDatabaseFile="..\obj\IrrRelease\Irrlicht.pdb" - ImportLibrary="..\..\lib\Win32-visualstudio\Irrlicht.lib" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCWebDeploymentTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - <Configuration - Name="Static lib - Debug|Win32" - OutputDirectory="$(ConfigurationName)" - IntermediateDirectory="$(ConfigurationName)" - ConfigurationType="4" - InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="false" - CharacterSet="0" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - PreprocessorDefinitions="_DEBUG" - MkTypLibCompatible="true" - SuppressStartupBanner="true" - TargetEnvironment="1" - TypeLibraryName=".\..\Debug/Irrlicht.tlb" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - AdditionalIncludeDirectories="..\..\include;zlib" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;_IRR_STATIC_LIB_;_CRT_SECURE_NO_DEPRECATE" - ExceptionHandling="0" - BasicRuntimeChecks="3" - RuntimeLibrary="1" - DisableLanguageExtensions="false" - RuntimeTypeInfo="false" - PrecompiledHeaderFile=".\..\obj\IrrDebugStatic/Irrlicht.pch" - AssemblerListingLocation=".\..\obj\IrrDebugStatic/" - ObjectFile=".\..\obj\IrrDebugStatic/" - ProgramDataBaseFileName=".\..\obj\IrrDebugStatic/" - WarningLevel="3" - SuppressStartupBanner="true" - DebugInformationFormat="3" - CompileAs="0" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="_DEBUG" - Culture="3079" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLibrarianTool" - AdditionalDependencies="winmm.lib" - OutputFile="..\..\lib\Win32-visualstudio\Irrlicht.lib" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - <Configuration - Name="Static lib - Release|Win32" - OutputDirectory="$(ConfigurationName)" - IntermediateDirectory="$(ConfigurationName)" - ConfigurationType="4" - InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="false" - CharacterSet="2" - WholeProgramOptimization="1" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - PreprocessorDefinitions="NDEBUG" - MkTypLibCompatible="true" - SuppressStartupBanner="true" - TargetEnvironment="1" - TypeLibraryName=".\..\Release/Irrlicht.tlb" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="2" - InlineFunctionExpansion="1" - EnableIntrinsicFunctions="false" - AdditionalIncludeDirectories="..\..\include;zlib" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;_IRR_STATIC_LIB_;_CRT_SECURE_NO_DEPRECATE" - StringPooling="true" - ExceptionHandling="0" - RuntimeLibrary="0" - BufferSecurityCheck="false" - EnableFunctionLevelLinking="true" - PrecompiledHeaderFile=".\..\obj\IrrReleaseStatic/Irrlicht.pch" - AssemblerListingLocation=".\..\obj\IrrReleaseStatic/" - ObjectFile=".\..\obj\IrrReleaseStatic/" - ProgramDataBaseFileName=".\..\obj\IrrReleaseStatic/" - WarningLevel="3" - SuppressStartupBanner="true" - DebugInformationFormat="0" - CompileAs="0" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="NDEBUG" - Culture="3079" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLibrarianTool" - AdditionalDependencies="winmm.lib" - OutputFile="..\..\lib\Win32-visualstudio\Irrlicht.lib" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - <Configuration - Name="Static lib - Release - Fast FPU|Win32" - OutputDirectory="$(ConfigurationName)" - IntermediateDirectory="$(ConfigurationName)" - ConfigurationType="4" - InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="false" - CharacterSet="2" - WholeProgramOptimization="1" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - PreprocessorDefinitions="NDEBUG" - MkTypLibCompatible="true" - SuppressStartupBanner="true" - TargetEnvironment="1" - TypeLibraryName=".\..\Release/Irrlicht.tlb" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="3" - InlineFunctionExpansion="2" - EnableIntrinsicFunctions="true" - FavorSizeOrSpeed="0" - OmitFramePointers="true" - AdditionalIncludeDirectories="..\..\include;zlib" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;_IRR_STATIC_LIB_;_CRT_SECURE_NO_DEPRECATE" - StringPooling="true" - ExceptionHandling="0" - RuntimeLibrary="0" - BufferSecurityCheck="false" - EnableFunctionLevelLinking="true" - FloatingPointModel="2" - RuntimeTypeInfo="false" - PrecompiledHeaderFile=".\..\obj\IrrReleaseFastFPUStatic/Irrlicht.pch" - AssemblerListingLocation=".\..\obj\IrrReleaseFastFPUStatic/" - ObjectFile=".\..\obj\IrrReleaseFastFPUStatic/" - ProgramDataBaseFileName=".\..\obj\IrrReleaseFastFPUStatic/" - WarningLevel="3" - SuppressStartupBanner="true" - DebugInformationFormat="0" - CallingConvention="1" - CompileAs="0" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="NDEBUG" - Culture="3079" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLibrarianTool" - AdditionalDependencies="winmm.lib" - OutputFile="..\..\lib\Win32-visualstudio\Irrlicht.lib" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - </Configurations> - <References> - </References> - <Files> - <Filter - Name="include" - > - <File - RelativePath=".\..\..\include\IEventReceiver.h" - > - </File> - <File - RelativePath=".\..\..\include\ILogger.h" - > - </File> - <File - RelativePath=".\..\..\include\IOSOperator.h" - > - </File> - <File - RelativePath=".\..\..\include\IReferenceCounted.h" - > - </File> - <File - RelativePath=".\..\..\include\IrrCompileConfig.h" - > - </File> - <File - RelativePath=".\..\..\include\irrlicht.h" - > - </File> - <File - RelativePath=".\..\..\include\IrrlichtDevice.h" - > - </File> - <File - RelativePath=".\..\..\include\ITimer.h" - > - </File> - <File - RelativePath=".\..\..\include\Keycodes.h" - > - </File> - <File - RelativePath=".\..\..\include\SIrrCreationParameters.h" - > - </File> - <File - RelativePath=".\..\..\include\SKeyMap.h" - > - </File> - <Filter - Name="video" - > - <File - RelativePath=".\..\..\include\EDriverTypes.h" - > - </File> - <File - RelativePath=".\..\..\include\IGPUProgrammingServices.h" - > - </File> - <File - RelativePath=".\..\..\include\IImage.h" - > - </File> - <File - RelativePath=".\..\..\include\IImageLoader.h" - > - </File> - <File - RelativePath=".\..\..\include\IMaterialRenderer.h" - > - </File> - <File - RelativePath=".\..\..\include\IMaterialRendererServices.h" - > - </File> - <File - RelativePath=".\..\..\include\IShaderConstantSetCallBack.h" - > - </File> - <File - RelativePath=".\..\..\include\ITexture.h" - > - </File> - <File - RelativePath=".\..\..\include\IVideoDriver.h" - > - </File> - <File - RelativePath=".\..\..\include\IVideoModeList.h" - > - </File> - <File - RelativePath=".\..\..\include\S3DVertex.h" - > - </File> - <File - RelativePath=".\..\..\include\SColor.h" - > - </File> - <File - RelativePath=".\..\..\include\SExposedVideoData.h" - > - </File> - <File - RelativePath=".\..\..\include\SLight.h" - > - </File> - <File - RelativePath=".\..\..\include\SMaterial.h" - > - </File> - <File - RelativePath="..\..\include\SMaterialLayer.h" - > - </File> - </Filter> - <Filter - Name="core" - > - <File - RelativePath=".\..\..\include\aabbox3d.h" - > - </File> - <File - RelativePath="..\..\include\coreutil.h" - > - </File> - <File - RelativePath=".\..\..\include\dimension2d.h" - > - </File> - <File - RelativePath=".\..\..\include\heapsort.h" - > - </File> - <File - RelativePath=".\..\..\include\irrAllocator.h" - > - </File> - <File - RelativePath=".\..\..\include\irrArray.h" - > - </File> - <File - RelativePath=".\..\..\include\irrList.h" - > - </File> - <File - RelativePath="..\..\include\irrMap.h" - > - </File> - <File - RelativePath=".\..\..\include\irrMath.h" - > - </File> - <File - RelativePath=".\..\..\include\irrString.h" - > - </File> - <File - RelativePath=".\..\..\include\irrTypes.h" - > - </File> - <File - RelativePath=".\..\..\include\line2d.h" - > - </File> - <File - RelativePath=".\..\..\include\line3d.h" - > - </File> - <File - RelativePath=".\..\..\include\matrix4.h" - > - </File> - <File - RelativePath=".\..\..\include\plane3d.h" - > - </File> - <File - RelativePath=".\..\..\include\position2d.h" - > - </File> - <File - RelativePath=".\..\..\include\quaternion.h" - > - </File> - <File - RelativePath=".\..\..\include\rect.h" - > - </File> - <File - RelativePath=".\..\..\include\triangle3d.h" - > - </File> - <File - RelativePath=".\..\..\include\vector2d.h" - > - </File> - <File - RelativePath=".\..\..\include\vector3d.h" - > - </File> - </Filter> - <Filter - Name="io" - > - <File - RelativePath=".\..\..\include\IAttributeExchangingObject.h" - > - </File> - <File - RelativePath=".\..\..\include\IAttributes.h" - > - </File> - <File - RelativePath="..\..\include\IFileArchive.h" - > - </File> - <File - RelativePath=".\..\..\include\IFileList.h" - > - </File> - <File - RelativePath=".\..\..\include\IFileSystem.h" - > - </File> - <File - RelativePath=".\..\..\include\IReadFile.h" - > - </File> - <File - RelativePath=".\..\..\include\irrXML.h" - > - </File> - <File - RelativePath=".\..\..\include\IWriteFile.h" - > - </File> - <File - RelativePath=".\..\..\include\IXMLReader.h" - > - </File> - <File - RelativePath=".\..\..\include\IXMLWriter.h" - > - </File> - </Filter> - <Filter - Name="scene" - > - <File - RelativePath="..\..\include\ECullingTypes.h" - > - </File> - <File - RelativePath="..\..\include\EDebugSceneTypes.h" - > - </File> - <File - RelativePath="..\..\include\EMeshWriterEnums.h" - > - </File> - <File - RelativePath=".\..\..\include\ESceneNodeAnimatorTypes.h" - > - </File> - <File - RelativePath=".\..\..\include\ESceneNodeTypes.h" - > - </File> - <File - RelativePath=".\..\..\include\IAnimatedMesh.h" - > - </File> - <File - RelativePath=".\..\..\include\IAnimatedMeshMD2.h" - > - </File> - <File - RelativePath="..\..\include\IAnimatedMeshMD3.h" - > - </File> - <File - RelativePath=".\..\..\include\IAnimatedMeshMS3D.h" - > - </File> - <File - RelativePath=".\..\..\include\IAnimatedMeshSceneNode.h" - > - </File> - <File - RelativePath=".\..\..\include\IBillboardSceneNode.h" - > - </File> - <File - RelativePath=".\..\..\include\ICameraSceneNode.h" - > - </File> - <File - RelativePath=".\..\..\include\IDummyTransformationSceneNode.h" - > - </File> - <File - RelativePath="..\..\include\IGeometryCreator.h" - > - </File> - <File - RelativePath="..\..\include\ILightManager.h" - > - </File> - <File - RelativePath=".\..\..\include\ILightSceneNode.h" - > - </File> - <File - RelativePath=".\..\..\include\IMesh.h" - > - </File> - <File - RelativePath=".\..\..\include\IMeshBuffer.h" - > - </File> - <File - RelativePath=".\..\..\include\IMeshCache.h" - > - </File> - <File - RelativePath=".\..\..\include\IMeshLoader.h" - > - </File> - <File - RelativePath=".\..\..\include\IMeshManipulator.h" - > - </File> - <File - RelativePath=".\..\..\include\IMeshSceneNode.h" - > - </File> - <File - RelativePath="..\..\include\IMeshWriter.h" - > - </File> - <File - RelativePath=".\..\..\include\IMetaTriangleSelector.h" - > - </File> - <File - RelativePath=".\..\..\include\IQ3LevelMesh.h" - > - </File> - <File - RelativePath="..\..\include\IQ3Shader.h" - > - </File> - <File - RelativePath=".\..\..\include\ISceneCollisionManager.h" - > - </File> - <File - RelativePath=".\..\..\include\ISceneManager.h" - > - </File> - <File - RelativePath=".\..\..\include\ISceneNode.h" - > - </File> - <File - RelativePath=".\..\..\include\ISceneNodeAnimator.h" - > - </File> - <File - RelativePath="..\..\include\ISceneNodeAnimatorCameraFPS.h" - > - </File> - <File - RelativePath="..\..\include\ISceneNodeAnimatorCameraMaya.h" - > - </File> - <File - RelativePath=".\..\..\include\ISceneNodeAnimatorCollisionResponse.h" - > - </File> - <File - RelativePath=".\..\..\include\ISceneNodeAnimatorFactory.h" - > - </File> - <File - RelativePath=".\..\..\include\ISceneNodeFactory.h" - > - </File> - <File - RelativePath=".\..\..\include\IShadowVolumeSceneNode.h" - > - </File> - <File - RelativePath="..\..\include\ISkinnedMesh.h" - > - </File> - <File - RelativePath=".\..\..\include\ITerrainSceneNode.h" - > - </File> - <File - RelativePath=".\..\..\include\ITextSceneNode.h" - > - </File> - <File - RelativePath=".\..\..\include\ITriangleSelector.h" - > - </File> - <File - RelativePath=".\..\..\include\IVolumeLightSceneNode.h" - > - </File> - <File - RelativePath=".\..\..\include\SAnimatedMesh.h" - > - </File> - <File - RelativePath=".\..\..\include\SceneParameters.h" - > - </File> - <File - RelativePath=".\..\..\include\SMesh.h" - > - </File> - <File - RelativePath=".\..\..\include\SMeshBuffer.h" - > - </File> - <File - RelativePath=".\..\..\include\SMeshBufferLightMap.h" - > - </File> - <File - RelativePath=".\..\..\include\SMeshBufferTangents.h" - > - </File> - <File - RelativePath="..\..\include\SSharedMeshBuffer.h" - > - </File> - <File - RelativePath=".\..\..\include\SSkinMeshBuffer.h" - > - </File> - <File - RelativePath=".\..\..\include\SViewFrustum.h" - > - </File> - <Filter - Name="particle" - > - <File - RelativePath=".\..\..\include\IParticleAffector.h" - > - </File> - <File - RelativePath="..\..\include\IParticleAnimatedMeshSceneNodeEmitter.h" - > - </File> - <File - RelativePath="..\..\include\IParticleAttractionAffector.h" - > - </File> - <File - RelativePath="..\..\include\IParticleBoxEmitter.h" - > - </File> - <File - RelativePath="..\..\include\IParticleCylinderEmitter.h" - > - </File> - <File - RelativePath=".\..\..\include\IParticleEmitter.h" - > - </File> - <File - RelativePath="..\..\include\IParticleFadeOutAffector.h" - > - </File> - <File - RelativePath="..\..\include\IParticleGravityAffector.h" - > - </File> - <File - RelativePath="..\..\include\IParticleMeshEmitter.h" - > - </File> - <File - RelativePath="..\..\include\IParticleRingEmitter.h" - > - </File> - <File - RelativePath="..\..\include\IParticleRotationAffector.h" - > - </File> - <File - RelativePath="..\..\include\IParticleSphereEmitter.h" - > - </File> - <File - RelativePath=".\..\..\include\IParticleSystemSceneNode.h" - > - </File> - <File - RelativePath=".\..\..\include\SParticle.h" - > - </File> - </Filter> - </Filter> - <Filter - Name="gui" - > - <File - RelativePath="..\..\include\EGUIAlignment.h" - > - </File> - <File - RelativePath=".\..\..\include\EGUIElementTypes.h" - > - </File> - <File - RelativePath="..\..\include\EMessageBoxFlags.h" - > - </File> - <File - RelativePath=".\..\..\include\ICursorControl.h" - > - </File> - <File - RelativePath=".\..\..\include\IGUIButton.h" - > - </File> - <File - RelativePath=".\..\..\include\IGUICheckbox.h" - > - </File> - <File - RelativePath="..\..\include\IGUIColorSelectDialog.h" - > - </File> - <File - RelativePath=".\..\..\include\IGUIComboBox.h" - > - </File> - <File - RelativePath=".\..\..\include\IGUIContextMenu.h" - > - </File> - <File - RelativePath=".\..\..\include\IGUIEditBox.h" - > - </File> - <File - RelativePath=".\..\..\include\IGUIElement.h" - > - </File> - <File - RelativePath="..\..\include\IGUIElementFactory.h" - > - </File> - <File - RelativePath=".\..\..\include\IGUIEnvironment.h" - > - </File> - <File - RelativePath=".\..\..\include\IGUIFileOpenDialog.h" - > - </File> - <File - RelativePath=".\..\..\include\IGUIFont.h" - > - </File> - <File - RelativePath="..\..\include\IGUIFontBitmap.h" - > - </File> - <File - RelativePath=".\..\..\include\IGUIImage.h" - > - </File> - <File - RelativePath="..\..\include\IGUIImageList.h" - > - </File> - <File - RelativePath=".\..\..\include\IGUIInOutFader.h" - > - </File> - <File - RelativePath=".\..\..\include\IGUIListBox.h" - > - </File> - <File - RelativePath=".\..\..\include\IGUIMeshViewer.h" - > - </File> - <File - RelativePath=".\..\..\include\IGUIScrollBar.h" - > - </File> - <File - RelativePath=".\..\..\include\IGUISkin.h" - > - </File> - <File - RelativePath="..\..\include\IGUISpinBox.h" - > - </File> - <File - RelativePath="..\..\include\IGUISpriteBank.h" - > - </File> - <File - RelativePath=".\..\..\include\IGUIStaticText.h" - > - </File> - <File - RelativePath=".\..\..\include\IGUITabControl.h" - > - </File> - <File - RelativePath="..\..\include\IGUITable.h" - > - </File> - <File - RelativePath=".\..\..\include\IGUIToolbar.h" - > - </File> - <File - RelativePath="..\..\include\IGUITreeView.h" - > - </File> - <File - RelativePath=".\..\..\include\IGUIWindow.h" - > - </File> - </Filter> - </Filter> - <Filter - Name="gui impl" - > - <File - RelativePath=".\BuiltInFont.h" - > - </File> - <File - RelativePath=".\CDefaultGUIElementFactory.cpp" - > - </File> - <File - RelativePath=".\CDefaultGUIElementFactory.h" - > - </File> - <File - RelativePath=".\CGUIButton.cpp" - > - </File> - <File - RelativePath=".\CGUIButton.h" - > - </File> - <File - RelativePath=".\CGUICheckbox.cpp" - > - </File> - <File - RelativePath=".\CGUICheckbox.h" - > - </File> - <File - RelativePath=".\CGUIColorSelectDialog.cpp" - > - </File> - <File - RelativePath=".\CGUIColorSelectDialog.h" - > - </File> - <File - RelativePath="CGUIComboBox.cpp" - > - </File> - <File - RelativePath="CGUIComboBox.h" - > - </File> - <File - RelativePath="CGUIContextMenu.cpp" - > - </File> - <File - RelativePath="CGUIContextMenu.h" - > - </File> - <File - RelativePath="CGUIEditBox.cpp" - > - </File> - <File - RelativePath="CGUIEditBox.h" - > - </File> - <File - RelativePath=".\CGUIEnvironment.cpp" - > - </File> - <File - RelativePath=".\CGUIEnvironment.h" - > - </File> - <File - RelativePath=".\CGUIFileOpenDialog.cpp" - > - </File> - <File - RelativePath=".\CGUIFileOpenDialog.h" - > - </File> - <File - RelativePath=".\CGUIFont.cpp" - > - </File> - <File - RelativePath=".\CGUIFont.h" - > - </File> - <File - RelativePath=".\CGUIImage.cpp" - > - </File> - <File - RelativePath=".\CGUIImage.h" - > - </File> - <File - RelativePath=".\CGUIImageList.cpp" - > - </File> - <File - RelativePath=".\CGUIImageList.h" - > - </File> - <File - RelativePath="CGUIInOutFader.cpp" - > - </File> - <File - RelativePath="CGUIInOutFader.h" - > - </File> - <File - RelativePath=".\CGUIListBox.cpp" - > - </File> - <File - RelativePath=".\CGUIListBox.h" - > - </File> - <File - RelativePath="CGUIMenu.cpp" - > - </File> - <File - RelativePath="CGUIMenu.h" - > - </File> - <File - RelativePath=".\CGUIMeshViewer.cpp" - > - </File> - <File - RelativePath=".\CGUIMeshViewer.h" - > - </File> - <File - RelativePath="CGUIMessageBox.cpp" - > - </File> - <File - RelativePath="CGUIMessageBox.h" - > - </File> - <File - RelativePath="CGUIModalScreen.cpp" - > - </File> - <File - RelativePath="CGUIModalScreen.h" - > - </File> - <File - RelativePath=".\CGUIScrollBar.cpp" - > - </File> - <File - RelativePath=".\CGUIScrollBar.h" - > - </File> - <File - RelativePath=".\CGUISkin.cpp" - > - </File> - <File - RelativePath=".\CGUISkin.h" - > - </File> - <File - RelativePath=".\CGUISpinBox.cpp" - > - </File> - <File - RelativePath=".\CGUISpinBox.h" - > - </File> - <File - RelativePath=".\CGUISpriteBank.cpp" - > - </File> - <File - RelativePath=".\CGUISpriteBank.h" - > - </File> - <File - RelativePath=".\CGUIStaticText.cpp" - > - </File> - <File - RelativePath=".\CGUIStaticText.h" - > - </File> - <File - RelativePath="CGUITabControl.cpp" - > - </File> - <File - RelativePath="CGUITabControl.h" - > - </File> - <File - RelativePath=".\CGUITable.cpp" - > - </File> - <File - RelativePath=".\CGUITable.h" - > - </File> - <File - RelativePath="CGUIToolBar.cpp" - > - </File> - <File - RelativePath="CGUIToolBar.h" - > - </File> - <File - RelativePath=".\CGUITreeView.cpp" - > - </File> - <File - RelativePath=".\CGUITreeView.h" - > - </File> - <File - RelativePath=".\CGUIWindow.cpp" - > - </File> - <File - RelativePath=".\CGUIWindow.h" - > - </File> - </Filter> - <Filter - Name="video impl" - > - <File - RelativePath="CVideoModeList.cpp" - > - </File> - <File - RelativePath="CVideoModeList.h" - > - </File> - <Filter - Name="Software" - > - <File - RelativePath=".\CSoftwareDriver.cpp" - > - </File> - <File - RelativePath=".\CSoftwareDriver.h" - > - </File> - <File - RelativePath=".\CSoftwareTexture.cpp" - > - </File> - <File - RelativePath=".\CSoftwareTexture.h" - > - </File> - <File - RelativePath=".\CTRFlat.cpp" - > - </File> - <File - RelativePath=".\CTRFlatWire.cpp" - > - </File> - <File - RelativePath=".\CTRGouraud.cpp" - > - </File> - <File - RelativePath=".\CTRGouraudWire.cpp" - > - </File> - <File - RelativePath=".\CTRTextureFlat.cpp" - > - </File> - <File - RelativePath=".\CTRTextureFlatWire.cpp" - > - </File> - <File - RelativePath=".\CTRTextureGouraud.cpp" - > - </File> - <File - RelativePath=".\CTRTextureGouraud.h" - > - </File> - <File - RelativePath=".\CTRTextureGouraudAdd.cpp" - > - </File> - <File - RelativePath=".\CTRTextureGouraudNoZ.cpp" - > - </File> - <File - RelativePath=".\CTRTextureGouraudWire.cpp" - > - </File> - <File - RelativePath=".\CZBuffer.cpp" - > - </File> - <File - RelativePath=".\CZBuffer.h" - > - </File> - <File - RelativePath=".\ITriangleRenderer.h" - > - </File> - <File - RelativePath=".\IZBuffer.h" - > - </File> - <File - RelativePath=".\S2DVertex.h" - > - </File> - </Filter> - <Filter - Name="OpenGL" - > - <File - RelativePath=".\COpenGLDriver.cpp" - > - </File> - <File - RelativePath=".\COpenGLDriver.h" - > - </File> - <File - RelativePath=".\COpenGLExtensionHandler.cpp" - > - </File> - <File - RelativePath=".\COpenGLExtensionHandler.h" - > - </File> - <File - RelativePath=".\COpenGLMaterialRenderer.h" - > - </File> - <File - RelativePath=".\COpenGLNormalMapRenderer.cpp" - > - </File> - <File - RelativePath=".\COpenGLNormalMapRenderer.h" - > - </File> - <File - RelativePath=".\COpenGLParallaxMapRenderer.cpp" - > - </File> - <File - RelativePath=".\COpenGLParallaxMapRenderer.h" - > - </File> - <File - RelativePath=".\COpenGLShaderMaterialRenderer.cpp" - > - </File> - <File - RelativePath=".\COpenGLShaderMaterialRenderer.h" - > - </File> - <File - RelativePath=".\COpenGLSLMaterialRenderer.cpp" - > - </File> - <File - RelativePath=".\COpenGLSLMaterialRenderer.h" - > - </File> - <File - RelativePath=".\COpenGLTexture.cpp" - > - </File> - <File - RelativePath=".\COpenGLTexture.h" - > - </File> - <File - RelativePath=".\glext.h" - > - </File> - </Filter> - <Filter - Name="Direct3D8" - > - <File - RelativePath=".\CD3D8Driver.cpp" - > - </File> - <File - RelativePath=".\CD3D8Driver.h" - > - </File> - <File - RelativePath=".\CD3D8MaterialRenderer.h" - > - </File> - <File - RelativePath=".\CD3D8NormalMapRenderer.cpp" - > - </File> - <File - RelativePath=".\CD3D8NormalMapRenderer.h" - > - </File> - <File - RelativePath=".\CD3D8ParallaxMapRenderer.cpp" - > - </File> - <File - RelativePath=".\CD3D8ParallaxMapRenderer.h" - > - </File> - <File - RelativePath=".\CD3D8ShaderMaterialRenderer.cpp" - > - </File> - <File - RelativePath=".\CD3D8ShaderMaterialRenderer.h" - > - </File> - <File - RelativePath=".\CD3D8Texture.cpp" - > - </File> - <File - RelativePath=".\CD3D8Texture.h" - > - </File> - </Filter> - <Filter - Name="Null" - > - <File - RelativePath=".\CColorConverter.cpp" - > - </File> - <File - RelativePath=".\CColorConverter.h" - > - </File> - <File - RelativePath=".\CFPSCounter.cpp" - > - </File> - <File - RelativePath=".\CFPSCounter.h" - > - </File> - <File - RelativePath="CImage.cpp" - > - </File> - <File - RelativePath="CImage.h" - > - </File> - <File - RelativePath="CImageLoaderBMP.cpp" - > - </File> - <File - RelativePath="CImageLoaderBMP.h" - > - </File> - <File - RelativePath="CImageLoaderJPG.cpp" - > - </File> - <File - RelativePath="CImageLoaderJPG.h" - > - </File> - <File - RelativePath="CImageLoaderPCX.cpp" - > - </File> - <File - RelativePath="CImageLoaderPCX.h" - > - </File> - <File - RelativePath="CImageLoaderPNG.cpp" - > - </File> - <File - RelativePath="CImageLoaderPNG.h" - > - </File> - <File - RelativePath="CImageLoaderPPM.cpp" - > - </File> - <File - RelativePath="CImageLoaderPPM.h" - > - </File> - <File - RelativePath="CImageLoaderPSD.cpp" - > - </File> - <File - RelativePath="CImageLoaderPSD.h" - > - </File> - <File - RelativePath="CImageLoaderRGB.cpp" - > - </File> - <File - RelativePath="CImageLoaderRGB.h" - > - </File> - <File - RelativePath="CImageLoaderTGA.cpp" - > - </File> - <File - RelativePath="CImageLoaderTGA.h" - > - </File> - <File - RelativePath="CImageLoaderWAL.cpp" - > - </File> - <File - RelativePath="CImageLoaderWAL.h" - > - </File> - <File - RelativePath=".\CNullDriver.cpp" - > - </File> - <File - RelativePath=".\CNullDriver.h" - > - </File> - <File - RelativePath="IImagePresenter.h" - > - </File> - <Filter - Name="Writer" - > - <File - RelativePath=".\CImageWriterBMP.cpp" - > - </File> - <File - RelativePath=".\CImageWriterBMP.h" - > - </File> - <File - RelativePath=".\CImageWriterJPG.cpp" - > - </File> - <File - RelativePath=".\CImageWriterJPG.h" - > - </File> - <File - RelativePath=".\CImageWriterPCX.cpp" - > - </File> - <File - RelativePath=".\CImageWriterPCX.h" - > - </File> - <File - RelativePath=".\CImageWriterPNG.cpp" - > - </File> - <File - RelativePath=".\CImageWriterPNG.h" - > - </File> - <File - RelativePath=".\CImageWriterPPM.cpp" - > - </File> - <File - RelativePath=".\CImageWriterPPM.h" - > - </File> - <File - RelativePath=".\CImageWriterPSD.cpp" - > - </File> - <File - RelativePath=".\CImageWriterPSD.h" - > - </File> - <File - RelativePath=".\CImageWriterTGA.cpp" - > - </File> - <File - RelativePath=".\CImageWriterTGA.h" - > - </File> - </Filter> - </Filter> - <Filter - Name="Direct3D9" - > - <File - RelativePath=".\CD3D9Driver.cpp" - > - </File> - <File - RelativePath=".\CD3D9Driver.h" - > - </File> - <File - RelativePath=".\CD3D9HLSLMaterialRenderer.cpp" - > - </File> - <File - RelativePath=".\CD3D9HLSLMaterialRenderer.h" - > - </File> - <File - RelativePath=".\CD3D9MaterialRenderer.h" - > - </File> - <File - RelativePath=".\CD3D9NormalMapRenderer.cpp" - > - </File> - <File - RelativePath=".\CD3D9NormalMapRenderer.h" - > - </File> - <File - RelativePath=".\CD3D9ParallaxMapRenderer.cpp" - > - </File> - <File - RelativePath=".\CD3D9ParallaxMapRenderer.h" - > - </File> - <File - RelativePath=".\CD3D9ShaderMaterialRenderer.cpp" - > - </File> - <File - RelativePath=".\CD3D9ShaderMaterialRenderer.h" - > - </File> - <File - RelativePath=".\CD3D9Texture.cpp" - > - </File> - <File - RelativePath=".\CD3D9Texture.h" - > - </File> - </Filter> - <Filter - Name="Burning Video" - > - <File - RelativePath=".\CBurningShader_Raster_Reference.cpp" - > - </File> - <File - RelativePath=".\CDepthBuffer.cpp" - > - </File> - <File - RelativePath=".\CDepthBuffer.h" - > - </File> - <File - RelativePath=".\CSoftware2MaterialRenderer.h" - > - </File> - <File - RelativePath=".\CSoftwareDriver2.cpp" - > - </File> - <File - RelativePath=".\CSoftwareDriver2.h" - > - </File> - <File - RelativePath=".\CSoftwareTexture2.cpp" - > - </File> - <File - RelativePath=".\CSoftwareTexture2.h" - > - </File> - <File - RelativePath=".\CTRGouraud2.cpp" - > - </File> - <File - RelativePath=".\CTRGouraudAlpha2.cpp" - > - </File> - <File - RelativePath=".\CTRGouraudAlphaNoZ2.cpp" - > - </File> - <File - RelativePath=".\CTRTextureBlend.cpp" - > - </File> - <File - RelativePath=".\CTRTextureDetailMap2.cpp" - > - </File> - <File - RelativePath=".\CTRTextureGouraud2.cpp" - > - </File> - <File - RelativePath=".\CTRTextureGouraudAdd2.cpp" - > - </File> - <File - RelativePath=".\CTRTextureGouraudAddNoZ2.cpp" - > - </File> - <File - RelativePath=".\CTRTextureGouraudAlpha.cpp" - > - </File> - <File - RelativePath=".\CTRTextureGouraudAlphaNoZ.cpp" - > - </File> - <File - RelativePath=".\CTRTextureGouraudNoZ2.cpp" - > - </File> - <File - RelativePath=".\CTRTextureGouraudVertexAlpha2.cpp" - > - </File> - <File - RelativePath=".\CTRTextureLightMap2_Add.cpp" - > - </File> - <File - RelativePath=".\CTRTextureLightMap2_M1.cpp" - > - </File> - <File - RelativePath=".\CTRTextureLightMap2_M2.cpp" - > - </File> - <File - RelativePath=".\CTRTextureLightMap2_M4.cpp" - > - </File> - <File - RelativePath=".\CTRTextureLightMapGouraud2_M4.cpp" - > - </File> - <File - RelativePath=".\CTRTextureWire2.cpp" - > - </File> - <File - RelativePath=".\IBurningShader.cpp" - > - </File> - <File - RelativePath=".\IBurningShader.h" - > - </File> - <File - RelativePath=".\IDepthBuffer.h" - > - </File> - <File - RelativePath=".\S4DVertex.h" - > - </File> - <File - RelativePath=".\SoftwareDriver2_compile_config.h" - > - </File> - <File - RelativePath=".\SoftwareDriver2_helper.h" - > - </File> - </Filter> - </Filter> - <Filter - Name="scene impl" - > - <File - RelativePath=".\CDefaultSceneNodeAnimatorFactory.cpp" - > - </File> - <File - RelativePath=".\CDefaultSceneNodeAnimatorFactory.h" - > - </File> - <File - RelativePath=".\CDefaultSceneNodeFactory.cpp" - > - </File> - <File - RelativePath=".\CDefaultSceneNodeFactory.h" - > - </File> - <File - RelativePath=".\CGeometryCreator.cpp" - > - </File> - <File - RelativePath=".\CGeometryCreator.h" - > - </File> - <File - RelativePath=".\CMeshCache.cpp" - > - </File> - <File - RelativePath=".\CMeshCache.h" - > - </File> - <File - RelativePath="CMeshManipulator.cpp" - > - </File> - <File - RelativePath="CMeshManipulator.h" - > - </File> - <File - RelativePath=".\CSceneManager.cpp" - > - </File> - <File - RelativePath=".\CSceneManager.h" - > - </File> - <Filter - Name="loaders" - > - <File - RelativePath=".\C3DSMeshFileLoader.cpp" - > - </File> - <File - RelativePath=".\C3DSMeshFileLoader.h" - > - </File> - <File - RelativePath=".\CAnimatedMeshMD2.cpp" - > - </File> - <File - RelativePath=".\CAnimatedMeshMD2.h" - > - </File> - <File - RelativePath=".\CAnimatedMeshMD3.cpp" - > - </File> - <File - RelativePath=".\CAnimatedMeshMD3.h" - > - </File> - <File - RelativePath=".\CB3DMeshFileLoader.cpp" - > - </File> - <File - RelativePath=".\CB3DMeshFileLoader.h" - > - </File> - <File - RelativePath=".\CBSPMeshFileLoader.cpp" - > - </File> - <File - RelativePath=".\CBSPMeshFileLoader.h" - > - </File> - <File - RelativePath=".\CColladaFileLoader.cpp" - > - </File> - <File - RelativePath=".\CColladaFileLoader.h" - > - </File> - <File - RelativePath=".\CCSMLoader.cpp" - > - </File> - <File - RelativePath=".\CCSMLoader.h" - > - </File> - <File - RelativePath=".\CDMFLoader.cpp" - > - </File> - <File - RelativePath=".\CDMFLoader.h" - > - </File> - <File - RelativePath=".\CIrrMeshFileLoader.cpp" - > - </File> - <File - RelativePath=".\CIrrMeshFileLoader.h" - > - </File> - <File - RelativePath=".\CLMTSMeshFileLoader.cpp" - > - </File> - <File - RelativePath=".\CLMTSMeshFileLoader.h" - > - </File> - <File - RelativePath=".\CLWOMeshFileLoader.cpp" - > - </File> - <File - RelativePath=".\CLWOMeshFileLoader.h" - > - </File> - <File - RelativePath=".\CMD2MeshFileLoader.cpp" - > - </File> - <File - RelativePath=".\CMD2MeshFileLoader.h" - > - </File> - <File - RelativePath=".\CMD3MeshFileLoader.cpp" - > - </File> - <File - RelativePath=".\CMD3MeshFileLoader.h" - > - </File> - <File - RelativePath=".\CMS3DMeshFileLoader.cpp" - > - </File> - <File - RelativePath=".\CMS3DMeshFileLoader.h" - > - </File> - <File - RelativePath=".\CMY3DHelper.h" - > - </File> - <File - RelativePath=".\CMY3DMeshFileLoader.cpp" - > - </File> - <File - RelativePath=".\CMY3DMeshFileLoader.h" - > - </File> - <File - RelativePath=".\COBJMeshFileLoader.cpp" - > - </File> - <File - RelativePath=".\COBJMeshFileLoader.h" - > - </File> - <File - RelativePath=".\COCTLoader.cpp" - > - </File> - <File - RelativePath=".\COCTLoader.h" - > - </File> - <File - RelativePath=".\COgreMeshFileLoader.cpp" - > - </File> - <File - RelativePath=".\CPLYMeshFileLoader.cpp" - > - </File> - <File - RelativePath=".\CPLYMeshFileLoader.h" - > - </File> - <File - RelativePath=".\COgreMeshFileLoader.h" - > - </File> - <File - RelativePath=".\CQ3LevelMesh.cpp" - > - </File> - <File - RelativePath=".\CQ3LevelMesh.h" - > - </File> - <File - RelativePath=".\CSkinnedMesh.cpp" - > - </File> - <File - RelativePath=".\CSkinnedMesh.h" - > - </File> - <File - RelativePath="CSTLMeshFileLoader.cpp" - > - </File> - <File - RelativePath="CSTLMeshFileLoader.h" - > - </File> - <File - RelativePath="CXMeshFileLoader.cpp" - > - </File> - <File - RelativePath="CXMeshFileLoader.h" - > - </File> - <File - RelativePath=".\dmfsupport.h" - > - </File> - </Filter> - <Filter - Name="sceneNodes" - > - <File - RelativePath=".\CAnimatedMeshSceneNode.cpp" - > - </File> - <File - RelativePath=".\CAnimatedMeshSceneNode.h" - > - </File> - <File - RelativePath=".\CBillboardSceneNode.cpp" - > - </File> - <File - RelativePath=".\CBillboardSceneNode.h" - > - </File> - <File - RelativePath=".\CBoneSceneNode.cpp" - > - </File> - <File - RelativePath=".\CBoneSceneNode.h" - > - </File> - <File - RelativePath=".\CCameraSceneNode.cpp" - > - </File> - <File - RelativePath=".\CCameraSceneNode.h" - > - </File> - <File - RelativePath=".\CCubeSceneNode.cpp" - > - </File> - <File - RelativePath=".\CCubeSceneNode.h" - > - </File> - <File - RelativePath=".\CDummyTransformationSceneNode.cpp" - > - </File> - <File - RelativePath=".\CDummyTransformationSceneNode.h" - > - </File> - <File - RelativePath="CEmptySceneNode.cpp" - > - </File> - <File - RelativePath="CEmptySceneNode.h" - > - </File> - <File - RelativePath=".\CLightSceneNode.cpp" - > - </File> - <File - RelativePath=".\CLightSceneNode.h" - > - </File> - <File - RelativePath=".\CMeshSceneNode.cpp" - > - </File> - <File - RelativePath=".\CMeshSceneNode.h" - > - </File> - <File - RelativePath=".\COctTreeSceneNode.cpp" - > - </File> - <File - RelativePath=".\COctTreeSceneNode.h" - > - </File> - <File - RelativePath=".\CQuake3ShaderSceneNode.cpp" - > - </File> - <File - RelativePath=".\CQuake3ShaderSceneNode.h" - > - </File> - <File - RelativePath=".\CShadowVolumeSceneNode.cpp" - > - </File> - <File - RelativePath=".\CShadowVolumeSceneNode.h" - > - </File> - <File - RelativePath=".\CSkyBoxSceneNode.cpp" - > - </File> - <File - RelativePath=".\CSkyBoxSceneNode.h" - > - </File> - <File - RelativePath=".\CSkyDomeSceneNode.cpp" - > - </File> - <File - RelativePath=".\CSkyDomeSceneNode.h" - > - </File> - <File - RelativePath=".\CSphereSceneNode.cpp" - > - </File> - <File - RelativePath=".\CSphereSceneNode.h" - > - </File> - <File - RelativePath="CTerrainSceneNode.cpp" - > - </File> - <File - RelativePath="CTerrainSceneNode.h" - > - </File> - <File - RelativePath=".\CTextSceneNode.cpp" - > - </File> - <File - RelativePath=".\CTextSceneNode.h" - > - </File> - <File - RelativePath=".\CVolumeLightSceneNode.cpp" - > - </File> - <File - RelativePath=".\CVolumeLightSceneNode.h" - > - </File> - <File - RelativePath="CWaterSurfaceSceneNode.cpp" - > - </File> - <File - RelativePath="CWaterSurfaceSceneNode.h" - > - </File> - </Filter> - <Filter - Name="particleSystem" - > - <File - RelativePath="CParticleAnimatedMeshSceneNodeEmitter.cpp" - > - </File> - <File - RelativePath="CParticleAttractionAffector.cpp" - > - </File> - <File - RelativePath="CParticleBoxEmitter.cpp" - > - </File> - <File - RelativePath="CParticleBoxEmitter.h" - > - </File> - <File - RelativePath="CParticleCylinderEmitter.cpp" - > - </File> - <File - RelativePath="CParticleFadeOutAffector.cpp" - > - </File> - <File - RelativePath="CParticleFadeOutAffector.h" - > - </File> - <File - RelativePath="CParticleGravityAffector.cpp" - > - </File> - <File - RelativePath="CParticleGravityAffector.h" - > - </File> - <File - RelativePath="CParticleMeshEmitter.cpp" - > - </File> - <File - RelativePath="CParticlePointEmitter.cpp" - > - </File> - <File - RelativePath="CParticlePointEmitter.h" - > - </File> - <File - RelativePath="CParticleRingEmitter.cpp" - > - </File> - <File - RelativePath="CParticleRotationAffector.cpp" - > - </File> - <File - RelativePath="CParticleScaleAffector.cpp" - > - </File> - <File - RelativePath="CParticleScaleAffector.cpp" - > - </File> - <File - RelativePath="CParticleScaleAffector.h" - > - </File> - <File - RelativePath="CParticleScaleAffector.h" - > - </File> - <File - RelativePath="CParticleSphereEmitter.cpp" - > - </File> - <File - RelativePath="CParticleSystemSceneNode.cpp" - > - </File> - <File - RelativePath="CParticleSystemSceneNode.h" - > - </File> - </Filter> - <Filter - Name="collision" - > - <File - RelativePath="CMetaTriangleSelector.cpp" - > - </File> - <File - RelativePath="CMetaTriangleSelector.h" - > - </File> - <File - RelativePath="COctTreeTriangleSelector.cpp" - > - </File> - <File - RelativePath="COctTreeTriangleSelector.h" - > - </File> - <File - RelativePath="CSceneCollisionManager.cpp" - > - </File> - <File - RelativePath="CSceneCollisionManager.h" - > - </File> - <File - RelativePath="CTerrainTriangleSelector.cpp" - > - </File> - <File - RelativePath="CTerrainTriangleSelector.h" - > - </File> - <File - RelativePath="CTriangleBBSelector.cpp" - > - </File> - <File - RelativePath="CTriangleBBSelector.h" - > - </File> - <File - RelativePath="CTriangleSelector.cpp" - > - </File> - <File - RelativePath="CTriangleSelector.h" - > - </File> - <File - RelativePath=".\OctTree.h" - > - </File> - </Filter> - <Filter - Name="animators" - > - <File - RelativePath="CSceneNodeAnimatorCameraFPS.cpp" - > - </File> - <File - RelativePath="CSceneNodeAnimatorCameraFPS.h" - > - </File> - <File - RelativePath="CSceneNodeAnimatorCameraMaya.cpp" - > - </File> - <File - RelativePath="CSceneNodeAnimatorCameraMaya.h" - > - </File> - <File - RelativePath="CSceneNodeAnimatorCollisionResponse.cpp" - > - </File> - <File - RelativePath="CSceneNodeAnimatorCollisionResponse.h" - > - </File> - <File - RelativePath="CSceneNodeAnimatorDelete.cpp" - > - </File> - <File - RelativePath="CSceneNodeAnimatorDelete.h" - > - </File> - <File - RelativePath="CSceneNodeAnimatorFlyCircle.cpp" - > - </File> - <File - RelativePath="CSceneNodeAnimatorFlyCircle.h" - > - </File> - <File - RelativePath="CSceneNodeAnimatorFlyStraight.cpp" - > - </File> - <File - RelativePath="CSceneNodeAnimatorFlyStraight.h" - > - </File> - <File - RelativePath="CSceneNodeAnimatorFollowSpline.cpp" - > - </File> - <File - RelativePath="CSceneNodeAnimatorFollowSpline.h" - > - </File> - <File - RelativePath="CSceneNodeAnimatorRotation.cpp" - > - </File> - <File - RelativePath="CSceneNodeAnimatorRotation.h" - > - </File> - <File - RelativePath="CSceneNodeAnimatorTexture.cpp" - > - </File> - <File - RelativePath="CSceneNodeAnimatorTexture.h" - > - </File> - </Filter> - <Filter - Name="writers" - > - <File - RelativePath="CColladaMeshWriter.cpp" - > - </File> - <File - RelativePath="CColladaMeshWriter.h" - > - </File> - <File - RelativePath="CIrrMeshWriter.cpp" - > - </File> - <File - RelativePath="CIrrMeshWriter.h" - > - </File> - <File - RelativePath="COBJMeshWriter.cpp" - > - </File> - <File - RelativePath="COBJMeshWriter.h" - > - </File> - <File - RelativePath="CPLYMeshWriter.cpp" - > - </File> - <File - RelativePath="CPLYMeshWriter.h" - > - </File> - <File - RelativePath="CSTLMeshWriter.cpp" - > - </File> - <File - RelativePath="CSTLMeshWriter.h" - > - </File> - </Filter> - </Filter> - <Filter - Name="io impl" - > - <File - RelativePath="CAttributeImpl.h" - > - </File> - <File - RelativePath="CAttributes.cpp" - > - </File> - <File - RelativePath="CAttributes.h" - > - </File> - <File - RelativePath="CFileList.cpp" - > - </File> - <File - RelativePath="CFileList.h" - > - </File> - <File - RelativePath="CFileSystem.cpp" - > - </File> - <File - RelativePath="CFileSystem.h" - > - </File> - <File - RelativePath="CLimitReadFile.cpp" - > - </File> - <File - RelativePath="CLimitReadFile.h" - > - </File> - <File - RelativePath=".\CMemoryFile.cpp" - > - </File> - <File - RelativePath=".\CMemoryFile.h" - > - </File> - <File - RelativePath="CPakReader.cpp" - > - </File> - <File - RelativePath="CPakReader.h" - > - </File> - <File - RelativePath="CTarReader.cpp" - > - </File> - <File - RelativePath="CTarReader.h" - > - </File> - <File - RelativePath="CMountPointReader.cpp" - > - </File> - <File - RelativePath="CMountPointReader.h" - > - </File> - <File - RelativePath="CReadFile.cpp" - > - </File> - <File - RelativePath="CReadFile.h" - > - </File> - <File - RelativePath="CWriteFile.cpp" - > - </File> - <File - RelativePath="CWriteFile.h" - > - </File> - <File - RelativePath="CXMLReader.cpp" - > - </File> - <File - RelativePath="CXMLReader.h" - > - </File> - <File - RelativePath="CXMLReaderImpl.h" - > - </File> - <File - RelativePath="CXMLWriter.cpp" - > - </File> - <File - RelativePath="CXMLWriter.h" - > - </File> - <File - RelativePath="CZipReader.cpp" - > - </File> - <File - RelativePath="CZipReader.h" - > - </File> - <File - RelativePath="irrXML.cpp" - > - </File> - </Filter> - <Filter - Name="irr impl" - > - <File - RelativePath=".\CIrrDeviceConsole.cpp" - > - </File> - <File - RelativePath=".\CIrrDeviceConsole.h" - > - </File> - <File - RelativePath="CIrrDeviceLinux.cpp" - > - </File> - <File - RelativePath="CIrrDeviceLinux.h" - > - </File> - <File - RelativePath=".\CIrrDeviceSDL.cpp" - > - </File> - <File - RelativePath=".\CIrrDeviceSDL.h" - > - </File> - <File - RelativePath="CIrrDeviceStub.cpp" - > - </File> - <File - RelativePath="CIrrDeviceStub.h" - > - </File> - <File - RelativePath="CIrrDeviceWin32.cpp" - > - </File> - <File - RelativePath="CIrrDeviceWin32.h" - > - </File> - <File - RelativePath="CLogger.cpp" - > - </File> - <File - RelativePath="CLogger.h" - > - </File> - <File - RelativePath="COSOperator.cpp" - > - </File> - <File - RelativePath="COSOperator.h" - > - </File> - <File - RelativePath="CTimer.h" - > - </File> - <File - RelativePath=".\Irrlicht.cpp" - > - </File> - <File - RelativePath="os.cpp" - > - </File> - <File - RelativePath="os.h" - > - </File> - <Filter - Name="extern" - > - <Filter - Name="zlib" - > - <File - RelativePath="zlib\adler32.c" - > - </File> - <File - RelativePath=".\zlib\compress.c" - > - </File> - <File - RelativePath=".\zlib\crc32.c" - > - </File> - <File - RelativePath=".\zlib\crc32.h" - > - </File> - <File - RelativePath=".\zlib\deflate.c" - > - </File> - <File - RelativePath="zlib\deflate.h" - > - </File> - <File - RelativePath="zlib\inffast.c" - > - </File> - <File - RelativePath="zlib\inffast.h" - > - </File> - <File - RelativePath="zlib\inffixed.h" - > - </File> - <File - RelativePath="zlib\inflate.c" - > - </File> - <File - RelativePath="zlib\inftrees.c" - > - </File> - <File - RelativePath="zlib\inftrees.h" - > - </File> - <File - RelativePath="zlib\trees.c" - > - </File> - <File - RelativePath="zlib\trees.h" - > - </File> - <File - RelativePath="zlib\uncompr.c" - > - </File> - <File - RelativePath="zlib\zconf.h" - > - </File> - <File - RelativePath="zlib\zlib.h" - > - </File> - <File - RelativePath="zlib\zutil.c" - > - </File> - <File - RelativePath="zlib\zutil.h" - > - </File> - </Filter> - <Filter - Name="jpeglib" - > - <File - RelativePath="jpeglib\cderror.h" - > - </File> - <File - RelativePath="jpeglib\jcapimin.c" - > - </File> - <File - RelativePath="jpeglib\jcapistd.c" - > - </File> - <File - RelativePath="jpeglib\jccoefct.c" - > - </File> - <File - RelativePath="jpeglib\jccolor.c" - > - </File> - <File - RelativePath="jpeglib\jcdctmgr.c" - > - </File> - <File - RelativePath="jpeglib\jchuff.c" - > - </File> - <File - RelativePath="jpeglib\jchuff.h" - > - </File> - <File - RelativePath="jpeglib\jcinit.c" - > - </File> - <File - RelativePath="jpeglib\jcmainct.c" - > - </File> - <File - RelativePath="jpeglib\jcmarker.c" - > - </File> - <File - RelativePath="jpeglib\jcmaster.c" - > - </File> - <File - RelativePath="jpeglib\jcomapi.c" - > - </File> - <File - RelativePath="jpeglib\jconfig.h" - > - </File> - <File - RelativePath="jpeglib\jcparam.c" - > - </File> - <File - RelativePath="jpeglib\jcphuff.c" - > - </File> - <File - RelativePath="jpeglib\jcprepct.c" - > - </File> - <File - RelativePath="jpeglib\jcsample.c" - > - </File> - <File - RelativePath="jpeglib\jctrans.c" - > - </File> - <File - RelativePath="jpeglib\jdapimin.c" - > - </File> - <File - RelativePath="jpeglib\jdapistd.c" - > - </File> - <File - RelativePath="jpeglib\jdatadst.c" - > - </File> - <File - RelativePath="jpeglib\jdatasrc.c" - > - </File> - <File - RelativePath="jpeglib\jdcoefct.c" - > - </File> - <File - RelativePath="jpeglib\jdcolor.c" - > - </File> - <File - RelativePath="jpeglib\jdct.h" - > - </File> - <File - RelativePath="jpeglib\jddctmgr.c" - > - </File> - <File - RelativePath="jpeglib\jdhuff.c" - > - </File> - <File - RelativePath="jpeglib\jdhuff.h" - > - </File> - <File - RelativePath="jpeglib\jdinput.c" - > - </File> - <File - RelativePath="jpeglib\jdmainct.c" - > - </File> - <File - RelativePath="jpeglib\jdmarker.c" - > - </File> - <File - RelativePath="jpeglib\jdmaster.c" - > - </File> - <File - RelativePath="jpeglib\jdmerge.c" - > - </File> - <File - RelativePath="jpeglib\jdphuff.c" - > - </File> - <File - RelativePath="jpeglib\jdpostct.c" - > - </File> - <File - RelativePath="jpeglib\jdsample.c" - > - </File> - <File - RelativePath="jpeglib\jdtrans.c" - > - </File> - <File - RelativePath="jpeglib\jerror.c" - > - </File> - <File - RelativePath="jpeglib\jerror.h" - > - </File> - <File - RelativePath="jpeglib\jfdctflt.c" - > - </File> - <File - RelativePath="jpeglib\jfdctfst.c" - > - </File> - <File - RelativePath="jpeglib\jfdctint.c" - > - </File> - <File - RelativePath="jpeglib\jidctflt.c" - > - </File> - <File - RelativePath="jpeglib\jidctfst.c" - > - </File> - <File - RelativePath="jpeglib\jidctint.c" - > - </File> - <File - RelativePath="jpeglib\jidctred.c" - > - </File> - <File - RelativePath="jpeglib\jinclude.h" - > - </File> - <File - RelativePath="jpeglib\jmemmgr.c" - > - </File> - <File - RelativePath="jpeglib\jmemnobs.c" - > - </File> - <File - RelativePath="jpeglib\jmemsys.h" - > - </File> - <File - RelativePath="jpeglib\jmorecfg.h" - > - </File> - <File - RelativePath="jpeglib\jpegint.h" - > - </File> - <File - RelativePath="jpeglib\jpeglib.h" - > - </File> - <File - RelativePath="jpeglib\jquant1.c" - > - </File> - <File - RelativePath="jpeglib\jquant2.c" - > - </File> - <File - RelativePath="jpeglib\jutils.c" - > - </File> - <File - RelativePath="jpeglib\jversion.h" - > - </File> - </Filter> - <Filter - Name="libpng" - > - <File - RelativePath=".\libpng\png.c" - > - </File> - <File - RelativePath=".\libpng\png.h" - > - </File> - <File - RelativePath=".\libpng\pngconf.h" - > - </File> - <File - RelativePath=".\libpng\pngerror.c" - > - </File> - <File - RelativePath=".\libpng\pngget.c" - > - </File> - <File - RelativePath=".\libpng\pngmem.c" - > - </File> - <File - RelativePath=".\libpng\pngpread.c" - > - </File> - <File - RelativePath=".\libpng\pngread.c" - > - </File> - <File - RelativePath=".\libpng\pngrio.c" - > - </File> - <File - RelativePath=".\libpng\pngrtran.c" - > - </File> - <File - RelativePath=".\libpng\pngrutil.c" - > - </File> - <File - RelativePath=".\libpng\pngset.c" - > - </File> - <File - RelativePath=".\libpng\pngtrans.c" - > - </File> - <File - RelativePath=".\libpng\pngwio.c" - > - </File> - <File - RelativePath=".\libpng\pngwrite.c" - > - </File> - <File - RelativePath=".\libpng\pngwtran.c" - > - </File> - <File - RelativePath=".\libpng\pngwutil.c" - > - </File> - </Filter> - </Filter> - </Filter> - <Filter - Name="doc" - > - <File - RelativePath="..\..\changes.txt" - > - </File> - <File - RelativePath="..\..\readme.txt" - > - </File> - </Filter> - </Files> - <Globals> - </Globals> -</VisualStudioProject> diff --git a/irrlicht-1.6/source/Irrlicht/Irrlicht9.0.sln b/irrlicht-1.6/source/Irrlicht/Irrlicht9.0.sln deleted file mode 100644 index 17f0dab23..000000000 --- a/irrlicht-1.6/source/Irrlicht/Irrlicht9.0.sln +++ /dev/null @@ -1,32 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual C++ Express 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Irrlicht", "Irrlicht9.0.vcproj", "{E08E042A-6C45-411B-92BE-3CC31331019F}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release - Fast FPU|Win32 = Release - Fast FPU|Win32 - Release|Win32 = Release|Win32 - Static lib - Debug|Win32 = Static lib - Debug|Win32 - Static lib - Release - Fast FPU|Win32 = Static lib - Release - Fast FPU|Win32 - Static lib - Release|Win32 = Static lib - Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E08E042A-6C45-411B-92BE-3CC31331019F}.Debug|Win32.ActiveCfg = Debug|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Debug|Win32.Build.0 = Debug|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU|Win32.ActiveCfg = Release - Fast FPU|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU|Win32.Build.0 = Release - Fast FPU|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Release|Win32.ActiveCfg = Release|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Release|Win32.Build.0 = Release|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Debug|Win32.ActiveCfg = Static lib - Debug|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Debug|Win32.Build.0 = Static lib - Debug|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Release - Fast FPU|Win32.ActiveCfg = Static lib - Release - Fast FPU|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Release - Fast FPU|Win32.Build.0 = Static lib - Release - Fast FPU|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Release|Win32.ActiveCfg = Static lib - Release|Win32 - {E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Release|Win32.Build.0 = Static lib - Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/irrlicht-1.6/source/Irrlicht/Irrlicht9.0.vcproj b/irrlicht-1.6/source/Irrlicht/Irrlicht9.0.vcproj deleted file mode 100644 index f4cbe073c..000000000 --- a/irrlicht-1.6/source/Irrlicht/Irrlicht9.0.vcproj +++ /dev/null @@ -1,3403 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?> -<VisualStudioProject - ProjectType="Visual C++" - Version="9.00" - Name="Irrlicht" - ProjectGUID="{E08E042A-6C45-411B-92BE-3CC31331019F}" - RootNamespace="Irrlicht" - TargetFrameworkVersion="131072" - > - <Platforms> - <Platform - Name="Win32" - /> - </Platforms> - <ToolFiles> - </ToolFiles> - <Configurations> - <Configuration - Name="Debug|Win32" - OutputDirectory="..\obj\IrrDebug" - IntermediateDirectory="..\obj\IrrDebug" - ConfigurationType="2" - InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="false" - CharacterSet="0" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - PreprocessorDefinitions="_DEBUG" - MkTypLibCompatible="true" - SuppressStartupBanner="true" - TargetEnvironment="1" - TypeLibraryName=".\..\Debug/Irrlicht.tlb" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - AdditionalIncludeDirectories="..\..\include;zlib" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;IRRLICHT_EXPORTS;_CRT_SECURE_NO_DEPRECATE" - ExceptionHandling="0" - BasicRuntimeChecks="3" - RuntimeLibrary="1" - DisableLanguageExtensions="false" - RuntimeTypeInfo="false" - PrecompiledHeaderFile=".\..\obj\IrrDebug/Irrlicht.pch" - AssemblerListingLocation=".\..\obj\IrrDebug/" - ObjectFile=".\..\obj\IrrDebug/" - ProgramDataBaseFileName=".\..\obj\IrrDebug/" - WarningLevel="3" - SuppressStartupBanner="true" - DebugInformationFormat="3" - CompileAs="0" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="_DEBUG" - Culture="3079" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - UseLibraryDependencyInputs="true" - AdditionalOptions="/MACHINE:I386" - AdditionalDependencies="kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib opengl32.lib winmm.lib" - OutputFile="..\..\bin\Win32-visualstudio\Irrlicht.dll" - LinkIncremental="2" - SuppressStartupBanner="true" - AdditionalLibraryDirectories="" - IgnoreDefaultLibraryNames="libci.lib" - GenerateDebugInformation="true" - ProgramDatabaseFile="..\obj\IrrDebug\Irrlicht.pdb" - RandomizedBaseAddress="1" - DataExecutionPrevention="0" - ImportLibrary="..\..\lib\Win32-visualstudio\Irrlicht.lib" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - <Configuration - Name="Release|Win32" - OutputDirectory="obj\IrrRelease" - IntermediateDirectory="obj\IrrRelease" - ConfigurationType="2" - InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="false" - CharacterSet="2" - WholeProgramOptimization="1" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - PreprocessorDefinitions="NDEBUG" - MkTypLibCompatible="true" - SuppressStartupBanner="true" - TargetEnvironment="1" - TypeLibraryName=".\..\Release/Irrlicht.tlb" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="2" - InlineFunctionExpansion="1" - EnableIntrinsicFunctions="false" - AdditionalIncludeDirectories="..\..\include;zlib" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;IRRLICHT_EXPORTS;_CRT_SECURE_NO_DEPRECATE" - StringPooling="true" - ExceptionHandling="0" - RuntimeLibrary="0" - BufferSecurityCheck="false" - EnableFunctionLevelLinking="true" - PrecompiledHeaderFile=".\..\obj\IrrRelease/Irrlicht.pch" - AssemblerListingLocation=".\..\obj\IrrRelease/" - ObjectFile=".\..\obj\IrrRelease/" - ProgramDataBaseFileName=".\..\obj\IrrRelease/" - WarningLevel="3" - SuppressStartupBanner="true" - DebugInformationFormat="0" - CompileAs="0" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="NDEBUG" - Culture="3079" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - AdditionalOptions="/MACHINE:I386" - AdditionalDependencies="kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib opengl32.lib winmm.lib" - OutputFile="..\..\bin\Win32-visualstudio\Irrlicht.dll" - LinkIncremental="1" - SuppressStartupBanner="true" - IgnoreDefaultLibraryNames="libci.lib" - GenerateDebugInformation="false" - ProgramDatabaseFile="..\obj\IrrRelease\Irrlicht.pdb" - RandomizedBaseAddress="1" - DataExecutionPrevention="0" - ImportLibrary="..\..\lib\Win32-visualstudio\Irrlicht.lib" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - <Configuration - Name="Release - Fast FPU|Win32" - OutputDirectory="$(ConfigurationName)" - IntermediateDirectory="$(ConfigurationName)" - ConfigurationType="2" - InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="false" - CharacterSet="2" - WholeProgramOptimization="1" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - PreprocessorDefinitions="NDEBUG" - MkTypLibCompatible="true" - SuppressStartupBanner="true" - TargetEnvironment="1" - TypeLibraryName=".\..\Release/Irrlicht.tlb" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="3" - InlineFunctionExpansion="2" - EnableIntrinsicFunctions="true" - FavorSizeOrSpeed="1" - OmitFramePointers="true" - AdditionalIncludeDirectories="..\..\include;zlib" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;IRRLICHT_EXPORTS;_CRT_SECURE_NO_DEPRECATE" - StringPooling="true" - ExceptionHandling="0" - RuntimeLibrary="0" - BufferSecurityCheck="false" - EnableFunctionLevelLinking="true" - EnableEnhancedInstructionSet="2" - FloatingPointModel="2" - RuntimeTypeInfo="false" - PrecompiledHeaderFile=".\..\obj\IrrRelease/Irrlicht.pch" - AssemblerListingLocation=".\..\obj\IrrReleaseFastFPU/" - ObjectFile=".\..\obj\IrrReleaseFastFPU/" - ProgramDataBaseFileName=".\..\obj\IrrReleaseFastFPU/" - WarningLevel="3" - WarnAsError="false" - SuppressStartupBanner="true" - DebugInformationFormat="0" - CallingConvention="1" - CompileAs="0" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="NDEBUG" - Culture="3079" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - AdditionalOptions="/MACHINE:I386" - AdditionalDependencies="kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib opengl32.lib winmm.lib" - OutputFile="..\..\bin\Win32-visualstudio\Irrlicht.dll" - LinkIncremental="1" - SuppressStartupBanner="true" - IgnoreDefaultLibraryNames="libci.lib" - GenerateDebugInformation="false" - ProgramDatabaseFile="..\obj\IrrRelease\Irrlicht.pdb" - SubSystem="2" - OptimizeReferences="2" - RandomizedBaseAddress="1" - DataExecutionPrevention="0" - ImportLibrary="..\..\lib\Win32-visualstudio\Irrlicht.lib" - TargetMachine="1" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - <Configuration - Name="Static lib - Debug|Win32" - OutputDirectory="$(ConfigurationName)" - IntermediateDirectory="$(ConfigurationName)" - ConfigurationType="4" - InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="false" - CharacterSet="0" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - PreprocessorDefinitions="_DEBUG" - MkTypLibCompatible="true" - SuppressStartupBanner="true" - TargetEnvironment="1" - TypeLibraryName=".\..\Debug/Irrlicht.tlb" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - AdditionalIncludeDirectories="..\..\include;zlib" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;_IRR_STATIC_LIB_;_CRT_SECURE_NO_DEPRECATE" - ExceptionHandling="0" - BasicRuntimeChecks="3" - RuntimeLibrary="1" - DisableLanguageExtensions="false" - RuntimeTypeInfo="false" - PrecompiledHeaderFile=".\..\obj\IrrDebug/Irrlicht.pch" - AssemblerListingLocation=".\..\obj\IrrDebugStatic/" - ObjectFile=".\..\obj\IrrDebugStatic/" - ProgramDataBaseFileName=".\..\obj\IrrDebugStatic/" - WarningLevel="3" - SuppressStartupBanner="true" - DebugInformationFormat="3" - CompileAs="0" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="_DEBUG" - Culture="3079" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLibrarianTool" - AdditionalDependencies="winmm.lib" - OutputFile="..\..\lib\Win32-visualstudio\Irrlicht.lib" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - <Configuration - Name="Static lib - Release|Win32" - OutputDirectory="$(ConfigurationName)" - IntermediateDirectory="$(ConfigurationName)" - ConfigurationType="4" - InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="false" - CharacterSet="2" - WholeProgramOptimization="1" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - PreprocessorDefinitions="NDEBUG" - MkTypLibCompatible="true" - SuppressStartupBanner="true" - TargetEnvironment="1" - TypeLibraryName=".\..\Release/Irrlicht.tlb" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="2" - InlineFunctionExpansion="1" - EnableIntrinsicFunctions="false" - AdditionalIncludeDirectories="..\..\include;zlib" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;_IRR_STATIC_LIB_;_CRT_SECURE_NO_DEPRECATE" - StringPooling="true" - ExceptionHandling="0" - RuntimeLibrary="0" - BufferSecurityCheck="false" - EnableFunctionLevelLinking="true" - PrecompiledHeaderFile=".\..\obj\IrrRelease/Irrlicht.pch" - AssemblerListingLocation=".\..\obj\IrrReleaseStatic/" - ObjectFile=".\..\obj\IrrReleaseStatic/" - ProgramDataBaseFileName=".\..\obj\IrrReleaseStatic/" - WarningLevel="3" - SuppressStartupBanner="true" - DebugInformationFormat="0" - CompileAs="0" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="NDEBUG" - Culture="3079" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLibrarianTool" - AdditionalDependencies="winmm.lib" - OutputFile="..\..\lib\Win32-visualstudio\Irrlicht.lib" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - <Configuration - Name="Static lib - Release - Fast FPU|Win32" - OutputDirectory="$(ConfigurationName)" - IntermediateDirectory="$(ConfigurationName)" - ConfigurationType="4" - InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="false" - CharacterSet="2" - WholeProgramOptimization="1" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - PreprocessorDefinitions="NDEBUG" - MkTypLibCompatible="true" - SuppressStartupBanner="true" - TargetEnvironment="1" - TypeLibraryName=".\..\Release/Irrlicht.tlb" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="3" - InlineFunctionExpansion="2" - EnableIntrinsicFunctions="true" - FavorSizeOrSpeed="0" - OmitFramePointers="true" - AdditionalIncludeDirectories="..\..\include;zlib" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;_IRR_STATIC_LIB_;_CRT_SECURE_NO_DEPRECATE" - StringPooling="true" - ExceptionHandling="0" - RuntimeLibrary="0" - BufferSecurityCheck="false" - EnableFunctionLevelLinking="true" - FloatingPointModel="2" - RuntimeTypeInfo="false" - PrecompiledHeaderFile=".\..\obj\IrrRelease/Irrlicht.pch" - AssemblerListingLocation=".\..\obj\IrrReleaseFastFPUStatic/" - ObjectFile=".\..\obj\IrrReleaseFastFPUStatic/" - ProgramDataBaseFileName=".\..\obj\IrrReleaseFastFPUStatic/" - WarningLevel="3" - SuppressStartupBanner="true" - DebugInformationFormat="0" - CallingConvention="1" - CompileAs="0" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="NDEBUG" - Culture="3079" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLibrarianTool" - AdditionalDependencies="winmm.lib" - OutputFile="..\..\lib\Win32-visualstudio\Irrlicht.lib" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - <Configuration - Name="SDL-Debug|Win32" - OutputDirectory="$(ConfigurationName)" - IntermediateDirectory="$(ConfigurationName)" - ConfigurationType="2" - InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="false" - CharacterSet="0" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - PreprocessorDefinitions="_DEBUG" - MkTypLibCompatible="true" - SuppressStartupBanner="true" - TargetEnvironment="1" - TypeLibraryName=".\..\Debug/Irrlicht.tlb" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - AdditionalIncludeDirectories="..\..\include;zlib" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;IRRLICHT_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_IRR_USE_SDL_DEVICE_=1" - ExceptionHandling="0" - BasicRuntimeChecks="3" - RuntimeLibrary="1" - DisableLanguageExtensions="false" - RuntimeTypeInfo="false" - PrecompiledHeaderFile=".\..\obj\IrrDebug/Irrlicht.pch" - AssemblerListingLocation=".\..\obj\IrrDebug/" - ObjectFile=".\..\obj\IrrDebug/" - ProgramDataBaseFileName=".\..\obj\IrrDebug/" - WarningLevel="3" - SuppressStartupBanner="true" - DebugInformationFormat="3" - CompileAs="0" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="_DEBUG" - Culture="3079" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - UseLibraryDependencyInputs="true" - AdditionalOptions="/MACHINE:I386" - AdditionalDependencies="kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib opengl32.lib winmm.lib" - OutputFile="..\..\bin\Win32-visualstudio\Irrlicht.dll" - LinkIncremental="2" - SuppressStartupBanner="true" - AdditionalLibraryDirectories="" - IgnoreDefaultLibraryNames="libci.lib" - GenerateDebugInformation="true" - ProgramDatabaseFile="..\obj\IrrDebug\Irrlicht.pdb" - RandomizedBaseAddress="1" - DataExecutionPrevention="0" - ImportLibrary="..\..\lib\Win32-visualstudio\Irrlicht.lib" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - </Configurations> - <References> - </References> - <Files> - <Filter - Name="include" - > - <File - RelativePath="..\..\include\IEventReceiver.h" - > - </File> - <File - RelativePath="..\..\include\ILogger.h" - > - </File> - <File - RelativePath="..\..\include\IOSOperator.h" - > - </File> - <File - RelativePath="..\..\include\IReferenceCounted.h" - > - </File> - <File - RelativePath="..\..\include\IrrCompileConfig.h" - > - </File> - <File - RelativePath="..\..\include\irrlicht.h" - > - </File> - <File - RelativePath="..\..\include\IrrlichtDevice.h" - > - </File> - <File - RelativePath="..\..\include\irrTypes.h" - > - </File> - <File - RelativePath="..\..\include\ITimer.h" - > - </File> - <File - RelativePath="..\..\include\Keycodes.h" - > - </File> - <File - RelativePath="..\..\include\SIrrCreationParameters.h" - > - </File> - <File - RelativePath="..\..\include\SKeyMap.h" - > - </File> - <Filter - Name="video" - > - <File - RelativePath="..\..\include\EDriverTypes.h" - > - </File> - <File - RelativePath="..\..\include\IGeometryCreator.h" - > - </File> - <File - RelativePath="..\..\include\IGPUProgrammingServices.h" - > - </File> - <File - RelativePath="..\..\include\IImage.h" - > - </File> - <File - RelativePath="..\..\include\IImageLoader.h" - > - </File> - <File - RelativePath="..\..\include\IMaterialRenderer.h" - > - </File> - <File - RelativePath="..\..\include\IMaterialRendererServices.h" - > - </File> - <File - RelativePath="..\..\include\IShaderConstantSetCallBack.h" - > - </File> - <File - RelativePath="..\..\include\ITexture.h" - > - </File> - <File - RelativePath="..\..\include\IVideoDriver.h" - > - </File> - <File - RelativePath="..\..\include\IVideoModeList.h" - > - </File> - <File - RelativePath="..\..\include\S3DVertex.h" - > - </File> - <File - RelativePath="..\..\include\SColor.h" - > - </File> - <File - RelativePath="..\..\include\SExposedVideoData.h" - > - </File> - <File - RelativePath="..\..\include\SLight.h" - > - </File> - <File - RelativePath="..\..\include\SMaterial.h" - > - </File> - <File - RelativePath="..\..\include\SMaterialLayer.h" - > - </File> - </Filter> - <Filter - Name="core" - > - <File - RelativePath="..\..\include\aabbox3d.h" - > - </File> - <File - RelativePath="..\..\include\dimension2d.h" - > - </File> - <File - RelativePath="..\..\include\heapsort.h" - > - </File> - <File - RelativePath="..\..\include\irrAllocator.h" - > - </File> - <File - RelativePath="..\..\include\irrArray.h" - > - </File> - <File - RelativePath="..\..\include\irrList.h" - > - </File> - <File - RelativePath="..\..\include\irrMap.h" - > - </File> - <File - RelativePath="..\..\include\irrMath.h" - > - </File> - <File - RelativePath="..\..\include\irrString.h" - > - </File> - <File - RelativePath="..\..\include\line2d.h" - > - </File> - <File - RelativePath="..\..\include\line3d.h" - > - </File> - <File - RelativePath="..\..\include\matrix4.h" - > - </File> - <File - RelativePath="..\..\include\plane3d.h" - > - </File> - <File - RelativePath="..\..\include\position2d.h" - > - </File> - <File - RelativePath="..\..\include\quaternion.h" - > - </File> - <File - RelativePath="..\..\include\rect.h" - > - </File> - <File - RelativePath="..\..\include\triangle3d.h" - > - </File> - <File - RelativePath="..\..\include\vector2d.h" - > - </File> - <File - RelativePath="..\..\include\vector3d.h" - > - </File> - </Filter> - <Filter - Name="io" - > - <File - RelativePath="..\..\include\IAttributeExchangingObject.h" - > - </File> - <File - RelativePath="..\..\include\IAttributes.h" - > - </File> - <File - RelativePath="..\..\include\IFileList.h" - > - </File> - <File - RelativePath="..\..\include\IFileSystem.h" - > - </File> - <File - RelativePath="..\..\include\IReadFile.h" - > - </File> - <File - RelativePath="..\..\include\irrXML.h" - > - </File> - <File - RelativePath="..\..\include\IWriteFile.h" - > - </File> - <File - RelativePath="..\..\include\IXMLReader.h" - > - </File> - <File - RelativePath="..\..\include\IXMLWriter.h" - > - </File> - </Filter> - <Filter - Name="scene" - > - <File - RelativePath="..\..\include\CDynamicMeshBuffer.h" - > - </File> - <File - RelativePath="..\..\include\CIndexBuffer.h" - > - </File> - <File - RelativePath="..\..\include\CMeshBuffer.h" - > - </File> - <File - RelativePath="..\..\include\CVertexBuffer.h" - > - </File> - <File - RelativePath="..\..\include\ECullingTypes.h" - > - </File> - <File - RelativePath="..\..\include\EDebugSceneTypes.h" - > - </File> - <File - RelativePath="..\..\include\EMeshWriterEnums.h" - > - </File> - <File - RelativePath="..\..\include\ESceneNodeAnimatorTypes.h" - > - </File> - <File - RelativePath="..\..\include\ESceneNodeTypes.h" - > - </File> - <File - RelativePath="..\..\include\IAnimatedMesh.h" - > - </File> - <File - RelativePath="..\..\include\IAnimatedMeshMD2.h" - > - </File> - <File - RelativePath="..\..\include\IAnimatedMeshMS3D.h" - > - </File> - <File - RelativePath="..\..\include\IAnimatedMeshSceneNode.h" - > - </File> - <File - RelativePath="..\..\include\IBillboardSceneNode.h" - > - </File> - <File - RelativePath="..\..\include\ICameraSceneNode.h" - > - </File> - <File - RelativePath="..\..\include\IDummyTransformationSceneNode.h" - > - </File> - <File - RelativePath="..\..\include\ILightSceneNode.h" - > - </File> - <File - RelativePath="..\..\include\IMesh.h" - > - </File> - <File - RelativePath="..\..\include\IMeshBuffer.h" - > - </File> - <File - RelativePath="..\..\include\IMeshCache.h" - > - </File> - <File - RelativePath="..\..\include\IMeshLoader.h" - > - </File> - <File - RelativePath="..\..\include\IMeshManipulator.h" - > - </File> - <File - RelativePath="..\..\include\IMeshSceneNode.h" - > - </File> - <File - RelativePath="..\..\include\IMeshWriter.h" - > - </File> - <File - RelativePath="..\..\include\IMetaTriangleSelector.h" - > - </File> - <File - RelativePath="..\..\include\IParticleAffector.h" - > - </File> - <File - RelativePath="..\..\include\IParticleAnimatedMeshSceneNodeEmitter.h" - > - </File> - <File - RelativePath="..\..\include\IParticleAttractionAffector.h" - > - </File> - <File - RelativePath="..\..\include\IParticleBoxEmitter.h" - > - </File> - <File - RelativePath="..\..\include\IParticleCylinderEmitter.h" - > - </File> - <File - RelativePath="..\..\include\IParticleEmitter.h" - > - </File> - <File - RelativePath="..\..\include\IParticleFadeOutAffector.h" - > - </File> - <File - RelativePath="..\..\include\IParticleGravityAffector.h" - > - </File> - <File - RelativePath="..\..\include\IParticleMeshEmitter.h" - > - </File> - <File - RelativePath="..\..\include\IParticleRingEmitter.h" - > - </File> - <File - RelativePath="..\..\include\IParticleRotationAffector.h" - > - </File> - <File - RelativePath="..\..\include\IParticleSphereEmitter.h" - > - </File> - <File - RelativePath="..\..\include\IParticleSystemSceneNode.h" - > - </File> - <File - RelativePath="..\..\include\IQ3LevelMesh.h" - > - </File> - <File - RelativePath="..\..\include\ISceneCollisionManager.h" - > - </File> - <File - RelativePath="..\..\include\ISceneManager.h" - > - </File> - <File - RelativePath="..\..\include\ISceneNode.h" - > - </File> - <File - RelativePath="..\..\include\ISceneNodeAnimator.h" - > - </File> - <File - RelativePath="..\..\include\ISceneNodeAnimatorCameraFPS.h" - > - </File> - <File - RelativePath="..\..\include\ISceneNodeAnimatorCameraMaya.h" - > - </File> - <File - RelativePath="..\..\include\ISceneNodeAnimatorCollisionResponse.h" - > - </File> - <File - RelativePath="..\..\include\ISceneNodeAnimatorFactory.h" - > - </File> - <File - RelativePath="..\..\include\ISceneNodeFactory.h" - > - </File> - <File - RelativePath="..\..\include\IShadowVolumeSceneNode.h" - > - </File> - <File - RelativePath="..\..\include\ISkinnedMesh.h" - > - </File> - <File - RelativePath="..\..\include\ITerrainSceneNode.h" - > - </File> - <File - RelativePath="..\..\include\ITextSceneNode.h" - > - </File> - <File - RelativePath="..\..\include\ITriangleSelector.h" - > - </File> - <File - RelativePath="..\..\include\IVolumeLightSceneNode.h" - > - </File> - <File - RelativePath="..\..\include\SAnimatedMesh.h" - > - </File> - <File - RelativePath="..\..\include\SceneParameters.h" - > - </File> - <File - RelativePath="..\..\include\SMesh.h" - > - </File> - <File - RelativePath="..\..\include\SMeshBuffer.h" - > - </File> - <File - RelativePath="..\..\include\SMeshBufferLightMap.h" - > - </File> - <File - RelativePath="..\..\include\SMeshBufferTangents.h" - > - </File> - <File - RelativePath="..\..\include\SParticle.h" - > - </File> - <File - RelativePath="..\..\include\SSkinMeshBuffer.h" - > - </File> - <File - RelativePath="..\..\include\SViewFrustum.h" - > - </File> - </Filter> - <Filter - Name="gui" - > - <File - RelativePath="..\..\include\EGUIAlignment.h" - > - </File> - <File - RelativePath="..\..\include\EGUIElementTypes.h" - > - </File> - <File - RelativePath="..\..\include\EMessageBoxFlags.h" - > - </File> - <File - RelativePath="..\..\include\ICursorControl.h" - > - </File> - <File - RelativePath="..\..\include\IGUIButton.h" - > - </File> - <File - RelativePath="..\..\include\IGUICheckbox.h" - > - </File> - <File - RelativePath="..\..\include\IGUIComboBox.h" - > - </File> - <File - RelativePath="..\..\include\IGUIContextMenu.h" - > - </File> - <File - RelativePath="..\..\include\IGUIEditBox.h" - > - </File> - <File - RelativePath="..\..\include\IGUIElement.h" - > - </File> - <File - RelativePath="..\..\include\IGUIElementFactory.h" - > - </File> - <File - RelativePath="..\..\include\IGUIEnvironment.h" - > - </File> - <File - RelativePath="..\..\include\IGUIFileOpenDialog.h" - > - </File> - <File - RelativePath="..\..\include\IGUIFont.h" - > - </File> - <File - RelativePath="..\..\include\IGUIImage.h" - > - </File> - <File - RelativePath="..\..\include\IGUIImageList.h" - > - </File> - <File - RelativePath="..\..\include\IGUIInOutFader.h" - > - </File> - <File - RelativePath="..\..\include\IGUIListBox.h" - > - </File> - <File - RelativePath="..\..\include\IGUIMeshViewer.h" - > - </File> - <File - RelativePath="..\..\include\IGUIScrollBar.h" - > - </File> - <File - RelativePath="..\..\include\IGUISkin.h" - > - </File> - <File - RelativePath="..\..\include\IGUISpinBox.h" - > - </File> - <File - RelativePath="..\..\include\IGUISpriteBank.h" - > - </File> - <File - RelativePath="..\..\include\IGUIStaticText.h" - > - </File> - <File - RelativePath="..\..\include\IGUITabControl.h" - > - </File> - <File - RelativePath="..\..\include\IGUIToolbar.h" - > - </File> - <File - RelativePath="..\..\include\IGUITreeView.h" - > - </File> - <File - RelativePath="..\..\include\IGUIWindow.h" - > - </File> - </Filter> - </Filter> - <Filter - Name="doc" - > - <File - RelativePath="..\..\changes.txt" - > - </File> - <File - RelativePath="..\..\readme.txt" - > - </File> - </Filter> - <Filter - Name="Irrlicht" - > - <Filter - Name="scene" - > - <File - RelativePath="CDefaultSceneNodeAnimatorFactory.cpp" - > - </File> - <File - RelativePath="CDefaultSceneNodeAnimatorFactory.h" - > - </File> - <File - RelativePath="CDefaultSceneNodeFactory.cpp" - > - </File> - <File - RelativePath="CDefaultSceneNodeFactory.h" - > - </File> - <File - RelativePath="CGeometryCreator.cpp" - > - </File> - <File - RelativePath="CGeometryCreator.h" - > - </File> - <File - RelativePath="CMeshCache.cpp" - > - </File> - <File - RelativePath="CMeshCache.h" - > - </File> - <File - RelativePath="CMeshManipulator.cpp" - > - </File> - <File - RelativePath="CMeshManipulator.h" - > - </File> - <File - RelativePath="CSceneManager.cpp" - > - </File> - <File - RelativePath="CSceneManager.h" - > - </File> - <File - RelativePath="OctTree.h" - > - </File> - <Filter - Name="loaders" - > - <File - RelativePath="C3DSMeshFileLoader.cpp" - > - </File> - <File - RelativePath="C3DSMeshFileLoader.h" - > - </File> - <File - RelativePath="CAnimatedMeshMD2.cpp" - > - </File> - <File - RelativePath="CAnimatedMeshMD2.h" - > - </File> - <File - RelativePath="CAnimatedMeshMD3.cpp" - > - </File> - <File - RelativePath="CAnimatedMeshMD3.h" - > - </File> - <File - RelativePath="CB3DMeshFileLoader.cpp" - > - </File> - <File - RelativePath="CB3DMeshFileLoader.h" - > - </File> - <File - RelativePath="CBSPMeshFileLoader.cpp" - > - </File> - <File - RelativePath="CBSPMeshFileLoader.h" - > - </File> - <File - RelativePath="CColladaFileLoader.cpp" - > - </File> - <File - RelativePath="CColladaFileLoader.h" - > - </File> - <File - RelativePath="CCSMLoader.cpp" - > - </File> - <File - RelativePath="CCSMLoader.h" - > - </File> - <File - RelativePath="CDMFLoader.cpp" - > - </File> - <File - RelativePath="CDMFLoader.h" - > - </File> - <File - RelativePath="CIrrMeshFileLoader.cpp" - > - </File> - <File - RelativePath="CIrrMeshFileLoader.h" - > - </File> - <File - RelativePath="CLMTSMeshFileLoader.cpp" - > - </File> - <File - RelativePath="CLMTSMeshFileLoader.h" - > - </File> - <File - RelativePath="CLWOMeshFileLoader.cpp" - > - </File> - <File - RelativePath="CLWOMeshFileLoader.h" - > - </File> - <File - RelativePath="CMD2MeshFileLoader.cpp" - > - </File> - <File - RelativePath="CMD2MeshFileLoader.h" - > - </File> - <File - RelativePath="CMD3MeshFileLoader.cpp" - > - </File> - <File - RelativePath="CMD3MeshFileLoader.h" - > - </File> - <File - RelativePath="CMS3DMeshFileLoader.cpp" - > - </File> - <File - RelativePath="CMS3DMeshFileLoader.h" - > - </File> - <File - RelativePath="CMY3DHelper.h" - > - </File> - <File - RelativePath="CMY3DMeshFileLoader.cpp" - > - </File> - <File - RelativePath="CMY3DMeshFileLoader.h" - > - </File> - <File - RelativePath="COBJMeshFileLoader.cpp" - > - </File> - <File - RelativePath="COBJMeshFileLoader.h" - > - </File> - <File - RelativePath="COCTLoader.cpp" - > - </File> - <File - RelativePath="COCTLoader.h" - > - </File> - <File - RelativePath="COgreMeshFileLoader.cpp" - > - </File> - <File - RelativePath="COgreMeshFileLoader.h" - > - </File> - <File - RelativePath="CPLYMeshFileLoader.cpp" - > - </File> - <File - RelativePath="CPLYMeshFileLoader.h" - > - </File> - <File - RelativePath="CQ3LevelMesh.cpp" - > - </File> - <File - RelativePath="CQ3LevelMesh.h" - > - </File> - <File - RelativePath="CSkinnedMesh.cpp" - > - </File> - <File - RelativePath="CSkinnedMesh.h" - > - </File> - <File - RelativePath="CSTLMeshFileLoader.cpp" - > - </File> - <File - RelativePath="CSTLMeshFileLoader.h" - > - </File> - <File - RelativePath="CXMeshFileLoader.cpp" - > - </File> - <File - RelativePath="CXMeshFileLoader.h" - > - </File> - <File - RelativePath="dmfsupport.h" - > - </File> - </Filter> - <Filter - Name="sceneNodes" - > - <File - RelativePath="CAnimatedMeshSceneNode.cpp" - > - </File> - <File - RelativePath="CAnimatedMeshSceneNode.h" - > - </File> - <File - RelativePath="CBillboardSceneNode.cpp" - > - </File> - <File - RelativePath="CBillboardSceneNode.h" - > - </File> - <File - RelativePath="CBoneSceneNode.cpp" - > - </File> - <File - RelativePath="CBoneSceneNode.h" - > - </File> - <File - RelativePath="CCameraSceneNode.cpp" - > - </File> - <File - RelativePath="CCameraSceneNode.h" - > - </File> - <File - RelativePath="CCubeSceneNode.cpp" - > - </File> - <File - RelativePath="CCubeSceneNode.h" - > - </File> - <File - RelativePath="CDummyTransformationSceneNode.cpp" - > - </File> - <File - RelativePath="CDummyTransformationSceneNode.h" - > - </File> - <File - RelativePath="CEmptySceneNode.cpp" - > - </File> - <File - RelativePath="CEmptySceneNode.h" - > - </File> - <File - RelativePath="CLightSceneNode.cpp" - > - </File> - <File - RelativePath="CLightSceneNode.h" - > - </File> - <File - RelativePath="CMeshSceneNode.cpp" - > - </File> - <File - RelativePath="CMeshSceneNode.h" - > - </File> - <File - RelativePath="COctTreeSceneNode.cpp" - > - </File> - <File - RelativePath="COctTreeSceneNode.h" - > - </File> - <File - RelativePath="CQuake3ShaderSceneNode.cpp" - > - </File> - <File - RelativePath="CQuake3ShaderSceneNode.h" - > - </File> - <File - RelativePath="CShadowVolumeSceneNode.cpp" - > - </File> - <File - RelativePath="CShadowVolumeSceneNode.h" - > - </File> - <File - RelativePath="CSkyBoxSceneNode.cpp" - > - </File> - <File - RelativePath="CSkyBoxSceneNode.h" - > - </File> - <File - RelativePath="CSkyDomeSceneNode.cpp" - > - </File> - <File - RelativePath="CSkyDomeSceneNode.h" - > - </File> - <File - RelativePath="CSphereSceneNode.cpp" - > - </File> - <File - RelativePath="CSphereSceneNode.h" - > - </File> - <File - RelativePath="CTerrainSceneNode.cpp" - > - </File> - <File - RelativePath="CTerrainSceneNode.h" - > - </File> - <File - RelativePath="CTextSceneNode.cpp" - > - </File> - <File - RelativePath="CTextSceneNode.h" - > - </File> - <File - RelativePath="CVolumeLightSceneNode.cpp" - > - </File> - <File - RelativePath="CVolumeLightSceneNode.h" - > - </File> - <File - RelativePath="CWaterSurfaceSceneNode.cpp" - > - </File> - <File - RelativePath="CWaterSurfaceSceneNode.h" - > - </File> - </Filter> - <Filter - Name="particleSystem" - > - <File - RelativePath="CParticleAnimatedMeshSceneNodeEmitter.cpp" - > - </File> - <File - RelativePath=".\CParticleAnimatedMeshSceneNodeEmitter.h" - > - </File> - <File - RelativePath="CParticleAttractionAffector.cpp" - > - </File> - <File - RelativePath=".\CParticleAttractionAffector.h" - > - </File> - <File - RelativePath="CParticleBoxEmitter.cpp" - > - </File> - <File - RelativePath="CParticleBoxEmitter.h" - > - </File> - <File - RelativePath="CParticleCylinderEmitter.cpp" - > - </File> - <File - RelativePath=".\CParticleCylinderEmitter.h" - > - </File> - <File - RelativePath="CParticleFadeOutAffector.cpp" - > - </File> - <File - RelativePath="CParticleFadeOutAffector.h" - > - </File> - <File - RelativePath="CParticleGravityAffector.cpp" - > - </File> - <File - RelativePath="CParticleGravityAffector.h" - > - </File> - <File - RelativePath="CParticleMeshEmitter.cpp" - > - </File> - <File - RelativePath=".\CParticleMeshEmitter.h" - > - </File> - <File - RelativePath="CParticlePointEmitter.cpp" - > - </File> - <File - RelativePath="CParticlePointEmitter.h" - > - </File> - <File - RelativePath="CParticleRingEmitter.cpp" - > - </File> - <File - RelativePath=".\CParticleRingEmitter.h" - > - </File> - <File - RelativePath="CParticleRotationAffector.cpp" - > - </File> - <File - RelativePath=".\CParticleRotationAffector.h" - > - </File> - <File - RelativePath="CParticleScaleAffector.cpp" - > - </File> - <File - RelativePath="CParticleScaleAffector.h" - > - </File> - <File - RelativePath="CParticleSphereEmitter.cpp" - > - </File> - <File - RelativePath=".\CParticleSphereEmitter.h" - > - </File> - <File - RelativePath="CParticleSystemSceneNode.cpp" - > - </File> - <File - RelativePath="CParticleSystemSceneNode.h" - > - </File> - </Filter> - <Filter - Name="collision" - > - <File - RelativePath="CMetaTriangleSelector.cpp" - > - </File> - <File - RelativePath="CMetaTriangleSelector.h" - > - </File> - <File - RelativePath="COctTreeTriangleSelector.cpp" - > - </File> - <File - RelativePath="COctTreeTriangleSelector.h" - > - </File> - <File - RelativePath="CSceneCollisionManager.cpp" - > - </File> - <File - RelativePath="CSceneCollisionManager.h" - > - </File> - <File - RelativePath="CTerrainTriangleSelector.cpp" - > - </File> - <File - RelativePath="CTerrainTriangleSelector.h" - > - </File> - <File - RelativePath="CTriangleBBSelector.cpp" - > - </File> - <File - RelativePath="CTriangleBBSelector.h" - > - </File> - <File - RelativePath="CTriangleSelector.cpp" - > - </File> - <File - RelativePath="CTriangleSelector.h" - > - </File> - </Filter> - <Filter - Name="animators" - > - <File - RelativePath="CSceneNodeAnimatorCameraFPS.cpp" - > - </File> - <File - RelativePath="CSceneNodeAnimatorCameraFPS.h" - > - </File> - <File - RelativePath="CSceneNodeAnimatorCameraMaya.cpp" - > - </File> - <File - RelativePath="CSceneNodeAnimatorCameraMaya.h" - > - </File> - <File - RelativePath="CSceneNodeAnimatorCollisionResponse.cpp" - > - </File> - <File - RelativePath="CSceneNodeAnimatorCollisionResponse.h" - > - </File> - <File - RelativePath="CSceneNodeAnimatorDelete.cpp" - > - </File> - <File - RelativePath="CSceneNodeAnimatorDelete.h" - > - </File> - <File - RelativePath="CSceneNodeAnimatorFlyCircle.cpp" - > - </File> - <File - RelativePath="CSceneNodeAnimatorFlyCircle.h" - > - </File> - <File - RelativePath="CSceneNodeAnimatorFlyStraight.cpp" - > - </File> - <File - RelativePath="CSceneNodeAnimatorFlyStraight.h" - > - </File> - <File - RelativePath="CSceneNodeAnimatorFollowSpline.cpp" - > - </File> - <File - RelativePath="CSceneNodeAnimatorFollowSpline.h" - > - </File> - <File - RelativePath="CSceneNodeAnimatorRotation.cpp" - > - </File> - <File - RelativePath="CSceneNodeAnimatorRotation.h" - > - </File> - <File - RelativePath="CSceneNodeAnimatorTexture.cpp" - > - </File> - <File - RelativePath="CSceneNodeAnimatorTexture.h" - > - </File> - </Filter> - <Filter - Name="writers" - > - <File - RelativePath="CColladaMeshWriter.cpp" - > - </File> - <File - RelativePath="CColladaMeshWriter.h" - > - </File> - <File - RelativePath="CIrrMeshWriter.cpp" - > - </File> - <File - RelativePath="CIrrMeshWriter.h" - > - </File> - <File - RelativePath="COBJMeshWriter.cpp" - > - </File> - <File - RelativePath="COBJMeshWriter.h" - > - </File> - <File - RelativePath=".\CPLYMeshWriter.cpp" - > - </File> - <File - RelativePath=".\CPLYMeshWriter.h" - > - </File> - <File - RelativePath="CSTLMeshWriter.cpp" - > - </File> - <File - RelativePath="CSTLMeshWriter.h" - > - </File> - </Filter> - </Filter> - <Filter - Name="video" - > - <File - RelativePath="CVideoModeList.cpp" - > - </File> - <File - RelativePath="CVideoModeList.h" - > - </File> - <Filter - Name="Software" - > - <File - RelativePath="CSoftwareDriver.cpp" - > - </File> - <File - RelativePath="CSoftwareDriver.h" - > - </File> - <File - RelativePath="CSoftwareTexture.cpp" - > - </File> - <File - RelativePath="CSoftwareTexture.h" - > - </File> - <File - RelativePath="CTRFlat.cpp" - > - </File> - <File - RelativePath="CTRFlatWire.cpp" - > - </File> - <File - RelativePath="CTRGouraud.cpp" - > - </File> - <File - RelativePath="CTRGouraudWire.cpp" - > - </File> - <File - RelativePath="CTRTextureFlat.cpp" - > - </File> - <File - RelativePath="CTRTextureFlatWire.cpp" - > - </File> - <File - RelativePath="CTRTextureGouraud.cpp" - > - </File> - <File - RelativePath="CTRTextureGouraud.h" - > - </File> - <File - RelativePath="CTRTextureGouraudAdd.cpp" - > - </File> - <File - RelativePath="CTRTextureGouraudNoZ.cpp" - > - </File> - <File - RelativePath="CTRTextureGouraudWire.cpp" - > - </File> - <File - RelativePath="CZBuffer.cpp" - > - </File> - <File - RelativePath="CZBuffer.h" - > - </File> - <File - RelativePath="ITriangleRenderer.h" - > - </File> - <File - RelativePath="IZBuffer.h" - > - </File> - <File - RelativePath="S2DVertex.h" - > - </File> - </Filter> - <Filter - Name="OpenGL" - > - <File - RelativePath="COpenGLDriver.cpp" - > - </File> - <File - RelativePath="COpenGLDriver.h" - > - </File> - <File - RelativePath="COpenGLExtensionHandler.cpp" - > - </File> - <File - RelativePath="COpenGLExtensionHandler.h" - > - </File> - <File - RelativePath="COpenGLMaterialRenderer.h" - > - </File> - <File - RelativePath="COpenGLNormalMapRenderer.cpp" - > - </File> - <File - RelativePath="COpenGLNormalMapRenderer.h" - > - </File> - <File - RelativePath="COpenGLParallaxMapRenderer.cpp" - > - </File> - <File - RelativePath="COpenGLParallaxMapRenderer.h" - > - </File> - <File - RelativePath="COpenGLShaderMaterialRenderer.cpp" - > - </File> - <File - RelativePath="COpenGLShaderMaterialRenderer.h" - > - </File> - <File - RelativePath="COpenGLSLMaterialRenderer.cpp" - > - </File> - <File - RelativePath="COpenGLSLMaterialRenderer.h" - > - </File> - <File - RelativePath="COpenGLTexture.cpp" - > - </File> - <File - RelativePath="COpenGLTexture.h" - > - </File> - <File - RelativePath="glext.h" - > - </File> - </Filter> - <Filter - Name="Direct3D8" - > - <File - RelativePath="CD3D8Driver.cpp" - > - </File> - <File - RelativePath="CD3D8Driver.h" - > - </File> - <File - RelativePath="CD3D8MaterialRenderer.h" - > - </File> - <File - RelativePath="CD3D8NormalMapRenderer.cpp" - > - </File> - <File - RelativePath="CD3D8NormalMapRenderer.h" - > - </File> - <File - RelativePath="CD3D8ParallaxMapRenderer.cpp" - > - </File> - <File - RelativePath="CD3D8ParallaxMapRenderer.h" - > - </File> - <File - RelativePath="CD3D8ShaderMaterialRenderer.cpp" - > - </File> - <File - RelativePath="CD3D8ShaderMaterialRenderer.h" - > - </File> - <File - RelativePath="CD3D8Texture.cpp" - > - </File> - <File - RelativePath="CD3D8Texture.h" - > - </File> - </Filter> - <Filter - Name="Null" - > - <File - RelativePath="CColorConverter.cpp" - > - </File> - <File - RelativePath="CColorConverter.h" - > - </File> - <File - RelativePath="CFPSCounter.cpp" - > - </File> - <File - RelativePath="CFPSCounter.h" - > - </File> - <File - RelativePath="CImage.cpp" - > - </File> - <File - RelativePath="CImage.h" - > - </File> - <File - RelativePath="CNullDriver.cpp" - > - </File> - <File - RelativePath="CNullDriver.h" - > - </File> - <File - RelativePath="IImagePresenter.h" - > - </File> - <Filter - Name="Writer" - > - <File - RelativePath="CImageWriterBMP.cpp" - > - </File> - <File - RelativePath="CImageWriterBMP.h" - > - </File> - <File - RelativePath="CImageWriterJPG.cpp" - > - </File> - <File - RelativePath="CImageWriterJPG.h" - > - </File> - <File - RelativePath="CImageWriterPCX.cpp" - > - </File> - <File - RelativePath="CImageWriterPCX.h" - > - </File> - <File - RelativePath="CImageWriterPNG.cpp" - > - </File> - <File - RelativePath="CImageWriterPNG.h" - > - </File> - <File - RelativePath="CImageWriterPPM.cpp" - > - </File> - <File - RelativePath="CImageWriterPPM.h" - > - </File> - <File - RelativePath="CImageWriterPSD.cpp" - > - </File> - <File - RelativePath="CImageWriterPSD.h" - > - </File> - <File - RelativePath="CImageWriterTGA.cpp" - > - </File> - <File - RelativePath="CImageWriterTGA.h" - > - </File> - </Filter> - <Filter - Name="Loader" - > - <File - RelativePath="CImageLoaderBMP.cpp" - > - </File> - <File - RelativePath="CImageLoaderBMP.h" - > - </File> - <File - RelativePath="CImageLoaderJPG.cpp" - > - </File> - <File - RelativePath="CImageLoaderJPG.h" - > - </File> - <File - RelativePath="CImageLoaderPCX.cpp" - > - </File> - <File - RelativePath="CImageLoaderPCX.h" - > - </File> - <File - RelativePath="CImageLoaderPNG.cpp" - > - </File> - <File - RelativePath="CImageLoaderPNG.h" - > - </File> - <File - RelativePath="CImageLoaderPPM.cpp" - > - </File> - <File - RelativePath="CImageLoaderPPM.h" - > - </File> - <File - RelativePath="CImageLoaderPSD.cpp" - > - </File> - <File - RelativePath="CImageLoaderPSD.h" - > - </File> - <File - RelativePath=".\CImageLoaderRGB.cpp" - > - </File> - <File - RelativePath=".\CImageLoaderRGB.h" - > - </File> - <File - RelativePath="CImageLoaderTGA.cpp" - > - </File> - <File - RelativePath="CImageLoaderTGA.h" - > - </File> - <File - RelativePath="CImageLoaderWAL.cpp" - > - </File> - <File - RelativePath="CImageLoaderWAL.h" - > - </File> - </Filter> - </Filter> - <Filter - Name="Direct3D9" - > - <File - RelativePath="CD3D9Driver.cpp" - > - </File> - <File - RelativePath="CD3D9Driver.h" - > - </File> - <File - RelativePath="CD3D9HLSLMaterialRenderer.cpp" - > - </File> - <File - RelativePath="CD3D9HLSLMaterialRenderer.h" - > - </File> - <File - RelativePath="CD3D9MaterialRenderer.h" - > - </File> - <File - RelativePath="CD3D9NormalMapRenderer.cpp" - > - </File> - <File - RelativePath="CD3D9NormalMapRenderer.h" - > - </File> - <File - RelativePath="CD3D9ParallaxMapRenderer.cpp" - > - </File> - <File - RelativePath="CD3D9ParallaxMapRenderer.h" - > - </File> - <File - RelativePath="CD3D9ShaderMaterialRenderer.cpp" - > - </File> - <File - RelativePath="CD3D9ShaderMaterialRenderer.h" - > - </File> - <File - RelativePath="CD3D9Texture.cpp" - > - </File> - <File - RelativePath="CD3D9Texture.h" - > - </File> - </Filter> - <Filter - Name="Burning Video" - > - <File - RelativePath="CBurningShader_Raster_Reference.cpp" - > - </File> - <File - RelativePath="CDepthBuffer.cpp" - > - </File> - <File - RelativePath="CDepthBuffer.h" - > - </File> - <File - RelativePath="CSoftware2MaterialRenderer.h" - > - </File> - <File - RelativePath="CSoftwareDriver2.cpp" - > - </File> - <File - RelativePath="CSoftwareDriver2.h" - > - </File> - <File - RelativePath="CSoftwareTexture2.cpp" - > - </File> - <File - RelativePath="CSoftwareTexture2.h" - > - </File> - <File - RelativePath="CTRGouraud2.cpp" - > - </File> - <File - RelativePath="CTRGouraudAlpha2.cpp" - > - </File> - <File - RelativePath="CTRGouraudAlphaNoZ2.cpp" - > - </File> - <File - RelativePath="CTRTextureBlend.cpp" - > - </File> - <File - RelativePath="CTRTextureDetailMap2.cpp" - > - </File> - <File - RelativePath="CTRTextureGouraud2.cpp" - > - </File> - <File - RelativePath="CTRTextureGouraudAdd2.cpp" - > - </File> - <File - RelativePath="CTRTextureGouraudAddNoZ2.cpp" - > - </File> - <File - RelativePath="CTRTextureGouraudAlpha.cpp" - > - </File> - <File - RelativePath="CTRTextureGouraudAlphaNoZ.cpp" - > - </File> - <File - RelativePath="CTRTextureGouraudNoZ2.cpp" - > - </File> - <File - RelativePath="CTRTextureGouraudVertexAlpha2.cpp" - > - </File> - <File - RelativePath="CTRTextureLightMap2_Add.cpp" - > - </File> - <File - RelativePath="CTRTextureLightMap2_M1.cpp" - > - </File> - <File - RelativePath="CTRTextureLightMap2_M2.cpp" - > - </File> - <File - RelativePath="CTRTextureLightMap2_M4.cpp" - > - </File> - <File - RelativePath="CTRTextureLightMapGouraud2_M4.cpp" - > - </File> - <File - RelativePath="CTRTextureWire2.cpp" - > - </File> - <File - RelativePath="IBurningShader.cpp" - > - </File> - <File - RelativePath="IBurningShader.h" - > - </File> - <File - RelativePath="IDepthBuffer.h" - > - </File> - <File - RelativePath="S4DVertex.h" - > - </File> - <File - RelativePath="SoftwareDriver2_compile_config.h" - > - </File> - <File - RelativePath="SoftwareDriver2_helper.h" - > - </File> - </Filter> - </Filter> - <Filter - Name="irr" - > - <File - RelativePath="CLogger.cpp" - > - </File> - <File - RelativePath="CLogger.h" - > - </File> - <File - RelativePath="COSOperator.cpp" - > - </File> - <File - RelativePath="COSOperator.h" - > - </File> - <File - RelativePath="CTimer.h" - > - </File> - <File - RelativePath="Irrlicht.cpp" - > - </File> - <File - RelativePath="os.cpp" - > - </File> - <File - RelativePath="os.h" - > - </File> - <Filter - Name="extern" - > - <Filter - Name="zlib" - > - <File - RelativePath="zlib\adler32.c" - > - </File> - <File - RelativePath="zlib\compress.c" - > - </File> - <File - RelativePath="zlib\crc32.c" - > - </File> - <File - RelativePath="zlib\crc32.h" - > - </File> - <File - RelativePath="zlib\deflate.c" - > - </File> - <File - RelativePath="zlib\deflate.h" - > - </File> - <File - RelativePath="zlib\inffast.c" - > - </File> - <File - RelativePath="zlib\inffast.h" - > - </File> - <File - RelativePath="zlib\inffixed.h" - > - </File> - <File - RelativePath="zlib\inflate.c" - > - </File> - <File - RelativePath="zlib\inftrees.c" - > - </File> - <File - RelativePath="zlib\inftrees.h" - > - </File> - <File - RelativePath="zlib\trees.c" - > - </File> - <File - RelativePath="zlib\trees.h" - > - </File> - <File - RelativePath="zlib\uncompr.c" - > - </File> - <File - RelativePath="zlib\zconf.h" - > - </File> - <File - RelativePath="zlib\zlib.h" - > - </File> - <File - RelativePath="zlib\zutil.c" - > - </File> - <File - RelativePath="zlib\zutil.h" - > - </File> - </Filter> - <Filter - Name="jpeglib" - > - <File - RelativePath="jpeglib\cderror.h" - > - </File> - <File - RelativePath="jpeglib\jcapimin.c" - > - </File> - <File - RelativePath="jpeglib\jcapistd.c" - > - </File> - <File - RelativePath="jpeglib\jccoefct.c" - > - </File> - <File - RelativePath="jpeglib\jccolor.c" - > - </File> - <File - RelativePath="jpeglib\jcdctmgr.c" - > - </File> - <File - RelativePath="jpeglib\jchuff.c" - > - </File> - <File - RelativePath="jpeglib\jchuff.h" - > - </File> - <File - RelativePath="jpeglib\jcinit.c" - > - </File> - <File - RelativePath="jpeglib\jcmainct.c" - > - </File> - <File - RelativePath="jpeglib\jcmarker.c" - > - </File> - <File - RelativePath="jpeglib\jcmaster.c" - > - </File> - <File - RelativePath="jpeglib\jcomapi.c" - > - </File> - <File - RelativePath="jpeglib\jconfig.h" - > - </File> - <File - RelativePath="jpeglib\jcparam.c" - > - </File> - <File - RelativePath="jpeglib\jcphuff.c" - > - </File> - <File - RelativePath="jpeglib\jcprepct.c" - > - </File> - <File - RelativePath="jpeglib\jcsample.c" - > - </File> - <File - RelativePath="jpeglib\jctrans.c" - > - </File> - <File - RelativePath="jpeglib\jdapimin.c" - > - </File> - <File - RelativePath="jpeglib\jdapistd.c" - > - </File> - <File - RelativePath="jpeglib\jdatadst.c" - > - </File> - <File - RelativePath="jpeglib\jdatasrc.c" - > - </File> - <File - RelativePath="jpeglib\jdcoefct.c" - > - </File> - <File - RelativePath="jpeglib\jdcolor.c" - > - </File> - <File - RelativePath="jpeglib\jdct.h" - > - </File> - <File - RelativePath="jpeglib\jddctmgr.c" - > - </File> - <File - RelativePath="jpeglib\jdhuff.c" - > - </File> - <File - RelativePath="jpeglib\jdhuff.h" - > - </File> - <File - RelativePath="jpeglib\jdinput.c" - > - </File> - <File - RelativePath="jpeglib\jdmainct.c" - > - </File> - <File - RelativePath="jpeglib\jdmarker.c" - > - </File> - <File - RelativePath="jpeglib\jdmaster.c" - > - </File> - <File - RelativePath="jpeglib\jdmerge.c" - > - </File> - <File - RelativePath="jpeglib\jdphuff.c" - > - </File> - <File - RelativePath="jpeglib\jdpostct.c" - > - </File> - <File - RelativePath="jpeglib\jdsample.c" - > - </File> - <File - RelativePath="jpeglib\jdtrans.c" - > - </File> - <File - RelativePath="jpeglib\jerror.c" - > - </File> - <File - RelativePath="jpeglib\jerror.h" - > - </File> - <File - RelativePath="jpeglib\jfdctflt.c" - > - </File> - <File - RelativePath="jpeglib\jfdctfst.c" - > - </File> - <File - RelativePath="jpeglib\jfdctint.c" - > - </File> - <File - RelativePath="jpeglib\jidctflt.c" - > - </File> - <File - RelativePath="jpeglib\jidctfst.c" - > - </File> - <File - RelativePath="jpeglib\jidctint.c" - > - </File> - <File - RelativePath="jpeglib\jidctred.c" - > - </File> - <File - RelativePath="jpeglib\jinclude.h" - > - </File> - <File - RelativePath="jpeglib\jmemmgr.c" - > - </File> - <File - RelativePath="jpeglib\jmemnobs.c" - > - </File> - <File - RelativePath="jpeglib\jmemsys.h" - > - </File> - <File - RelativePath="jpeglib\jmorecfg.h" - > - </File> - <File - RelativePath="jpeglib\jpegint.h" - > - </File> - <File - RelativePath="jpeglib\jpeglib.h" - > - </File> - <File - RelativePath="jpeglib\jquant1.c" - > - </File> - <File - RelativePath="jpeglib\jquant2.c" - > - </File> - <File - RelativePath="jpeglib\jutils.c" - > - </File> - <File - RelativePath="jpeglib\jversion.h" - > - </File> - </Filter> - <Filter - Name="libpng" - > - <File - RelativePath="libpng\png.c" - > - </File> - <File - RelativePath="libpng\png.h" - > - </File> - <File - RelativePath="libpng\pngconf.h" - > - </File> - <File - RelativePath="libpng\pngerror.c" - > - </File> - <File - RelativePath="libpng\pngget.c" - > - </File> - <File - RelativePath="libpng\pngmem.c" - > - </File> - <File - RelativePath="libpng\pngpread.c" - > - </File> - <File - RelativePath="libpng\pngread.c" - > - </File> - <File - RelativePath="libpng\pngrio.c" - > - </File> - <File - RelativePath="libpng\pngrtran.c" - > - </File> - <File - RelativePath="libpng\pngrutil.c" - > - </File> - <File - RelativePath="libpng\pngset.c" - > - </File> - <File - RelativePath="libpng\pngtrans.c" - > - </File> - <File - RelativePath="libpng\pngwio.c" - > - </File> - <File - RelativePath="libpng\pngwrite.c" - > - </File> - <File - RelativePath="libpng\pngwtran.c" - > - </File> - <File - RelativePath="libpng\pngwutil.c" - > - </File> - </Filter> - </Filter> - <Filter - Name="device" - > - <File - RelativePath=".\CIrrDeviceConsole.cpp" - > - </File> - <File - RelativePath=".\CIrrDeviceConsole.h" - > - </File> - <File - RelativePath="CIrrDeviceLinux.cpp" - > - </File> - <File - RelativePath="CIrrDeviceLinux.h" - > - </File> - <File - RelativePath="CIrrDeviceSDL.cpp" - > - </File> - <File - RelativePath="CIrrDeviceSDL.h" - > - </File> - <File - RelativePath="CIrrDeviceStub.cpp" - > - </File> - <File - RelativePath="CIrrDeviceStub.h" - > - </File> - <File - RelativePath="CIrrDeviceWin32.cpp" - > - </File> - <File - RelativePath="CIrrDeviceWin32.h" - > - </File> - </Filter> - </Filter> - <Filter - Name="io" - > - <File - RelativePath="CAttributeImpl.h" - > - </File> - <File - RelativePath="CAttributes.cpp" - > - </File> - <File - RelativePath="CAttributes.h" - > - </File> - <File - RelativePath="CFileList.cpp" - > - </File> - <File - RelativePath="CFileList.h" - > - </File> - <File - RelativePath="CFileSystem.cpp" - > - </File> - <File - RelativePath="CFileSystem.h" - > - </File> - <File - RelativePath="CLimitReadFile.cpp" - > - </File> - <File - RelativePath="CLimitReadFile.h" - > - </File> - <File - RelativePath="CMemoryFile.cpp" - > - </File> - <File - RelativePath="CMemoryFile.h" - > - </File> - <File - RelativePath="CPakReader.cpp" - > - </File> - <File - RelativePath="CPakReader.h" - > - </File> - <File - RelativePath="CReadFile.cpp" - > - </File> - <File - RelativePath="CReadFile.h" - > - </File> - <File - RelativePath="CTarReader.cpp" - > - </File> - <File - RelativePath="CTarReader.h" - > - </File> - <File - RelativePath="CMountPointReader.cpp" - > - </File> - <File - RelativePath="CMountPointReader.h" - > - </File> - <File - RelativePath="CWriteFile.cpp" - > - </File> - <File - RelativePath="CWriteFile.h" - > - </File> - <File - RelativePath="CXMLReader.cpp" - > - </File> - <File - RelativePath="CXMLReader.h" - > - </File> - <File - RelativePath="CXMLReaderImpl.h" - > - </File> - <File - RelativePath="CXMLWriter.cpp" - > - </File> - <File - RelativePath="CXMLWriter.h" - > - </File> - <File - RelativePath="CZipReader.cpp" - > - </File> - <File - RelativePath="CZipReader.h" - > - </File> - <File - RelativePath="irrXML.cpp" - > - </File> - </Filter> - <Filter - Name="gui" - > - <File - RelativePath="BuiltInFont.h" - > - </File> - <File - RelativePath="CDefaultGUIElementFactory.cpp" - > - </File> - <File - RelativePath="CDefaultGUIElementFactory.h" - > - </File> - <File - RelativePath="CGUIButton.cpp" - > - </File> - <File - RelativePath="CGUIButton.h" - > - </File> - <File - RelativePath="CGUICheckbox.cpp" - > - </File> - <File - RelativePath="CGUICheckbox.h" - > - </File> - <File - RelativePath="CGUIColorSelectDialog.cpp" - > - </File> - <File - RelativePath="CGUIColorSelectDialog.h" - > - </File> - <File - RelativePath="CGUIComboBox.cpp" - > - </File> - <File - RelativePath="CGUIComboBox.h" - > - </File> - <File - RelativePath="CGUIContextMenu.cpp" - > - </File> - <File - RelativePath="CGUIContextMenu.h" - > - </File> - <File - RelativePath="CGUIEditBox.cpp" - > - </File> - <File - RelativePath="CGUIEditBox.h" - > - </File> - <File - RelativePath="CGUIEnvironment.cpp" - > - </File> - <File - RelativePath="CGUIEnvironment.h" - > - </File> - <File - RelativePath="CGUIFileOpenDialog.cpp" - > - </File> - <File - RelativePath="CGUIFileOpenDialog.h" - > - </File> - <File - RelativePath="CGUIFont.cpp" - > - </File> - <File - RelativePath="CGUIFont.h" - > - </File> - <File - RelativePath="CGUIImage.cpp" - > - </File> - <File - RelativePath="CGUIImage.h" - > - </File> - <File - RelativePath=".\CGUIImageList.cpp" - > - </File> - <File - RelativePath=".\CGUIImageList.h" - > - </File> - <File - RelativePath="CGUIInOutFader.cpp" - > - </File> - <File - RelativePath="CGUIInOutFader.h" - > - </File> - <File - RelativePath="CGUIListBox.cpp" - > - </File> - <File - RelativePath="CGUIListBox.h" - > - </File> - <File - RelativePath="CGUIMenu.cpp" - > - </File> - <File - RelativePath="CGUIMenu.h" - > - </File> - <File - RelativePath="CGUIMeshViewer.cpp" - > - </File> - <File - RelativePath="CGUIMeshViewer.h" - > - </File> - <File - RelativePath="CGUIMessageBox.cpp" - > - </File> - <File - RelativePath="CGUIMessageBox.h" - > - </File> - <File - RelativePath="CGUIModalScreen.cpp" - > - </File> - <File - RelativePath="CGUIModalScreen.h" - > - </File> - <File - RelativePath="CGUIScrollBar.cpp" - > - </File> - <File - RelativePath="CGUIScrollBar.h" - > - </File> - <File - RelativePath="CGUISkin.cpp" - > - </File> - <File - RelativePath="CGUISkin.h" - > - </File> - <File - RelativePath="CGUISpinBox.cpp" - > - </File> - <File - RelativePath="CGUISpinBox.h" - > - </File> - <File - RelativePath="CGUISpriteBank.cpp" - > - </File> - <File - RelativePath="CGUISpriteBank.h" - > - </File> - <File - RelativePath="CGUIStaticText.cpp" - > - </File> - <File - RelativePath="CGUIStaticText.h" - > - </File> - <File - RelativePath="CGUITabControl.cpp" - > - </File> - <File - RelativePath="CGUITabControl.h" - > - </File> - <File - RelativePath="CGUITable.cpp" - > - </File> - <File - RelativePath="CGUITable.h" - > - </File> - <File - RelativePath="CGUIToolBar.cpp" - > - </File> - <File - RelativePath="CGUIToolBar.h" - > - </File> - <File - RelativePath=".\CGUITreeView.cpp" - > - </File> - <File - RelativePath=".\CGUITreeView.h" - > - </File> - <File - RelativePath="CGUIWindow.cpp" - > - </File> - <File - RelativePath="CGUIWindow.h" - > - </File> - </Filter> - </Filter> - </Files> - <Globals> - </Globals> -</VisualStudioProject> diff --git a/irrlicht-1.6/source/Irrlicht/Irrlicht_Win32-gcc.cbp b/irrlicht-1.6/source/Irrlicht/Irrlicht_Win32-gcc.cbp deleted file mode 100644 index 586b9ec2e..000000000 --- a/irrlicht-1.6/source/Irrlicht/Irrlicht_Win32-gcc.cbp +++ /dev/null @@ -1,1839 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> -<CodeBlocks_project_file> - <FileVersion major="1" minor="6" /> - <Project> - <Option title="Irrlicht" /> - <Option pch_mode="0" /> - <Option compiler="gcc" /> - <Build> - <Target title="Debug"> - <Option output="..\..\bin\Win32-gcc\Irrlicht.dll" prefix_auto="0" extension_auto="0" /> - <Option object_output="..\obj\IrrDebuggcc" /> - <Option type="3" /> - <Option compiler="gcc" /> - <Option createDefFile="1" /> - <Option createStaticLib="1" /> - <Compiler> - <Add option="-W" /> - <Add option="-g" /> - <Add option="-O0" /> - <Add option="-DWIN32" /> - <Add option="-D_DEBUG" /> - <Add option="-D_WINDOWS" /> - <Add option="-D_USRDLL" /> - <Add option="-DIRRLICHT_EXPORTS" /> - <Add option="-D_CRT_SECURE_NO_DEPRECATE" /> - <Add directory="..\..\include" /> - <Add directory="zlib" /> - </Compiler> - <Linker> - <Add library="kernel32" /> - <Add library="user32" /> - <Add library="gdi32" /> - <Add library="winspool" /> - <Add library="comdlg32" /> - <Add library="advapi32" /> - <Add library="shell32" /> - <Add library="ole32" /> - <Add library="oleaut32" /> - <Add library="uuid" /> - <Add library="opengl32" /> - </Linker> - </Target> - <Target title="Release"> - <Option output="..\..\bin\Win32-gcc\Irrlicht.dll" prefix_auto="0" extension_auto="0" /> - <Option object_output="obj\IrrReleasegcc" /> - <Option type="3" /> - <Option compiler="gcc" /> - <Option createDefFile="1" /> - <Option createStaticLib="1" /> - <Compiler> - <Add option="-O2" /> - <Add option="-W" /> - <Add option="-DWIN32" /> - <Add option="-DNDEBUG" /> - <Add option="-D_WINDOWS" /> - <Add option="-D_USRDLL" /> - <Add option="-DIRRLICHT_EXPORTS" /> - <Add option="-D_CRT_SECURE_NO_DEPRECATE" /> - <Add option="-D__GNUWIN32__" /> - <Add directory="..\..\include" /> - <Add directory="zlib" /> - </Compiler> - <Linker> - <Add library="kernel32" /> - <Add library="user32" /> - <Add library="gdi32" /> - <Add library="winspool" /> - <Add library="comdlg32" /> - <Add library="advapi32" /> - <Add library="shell32" /> - <Add library="ole32" /> - <Add library="oleaut32" /> - <Add library="uuid" /> - <Add library="opengl32" /> - </Linker> - </Target> - <Target title="Release - Fast FPU"> - <Option output="..\..\bin\Win32-gcc\Irrlicht.dll" prefix_auto="0" extension_auto="0" /> - <Option object_output="Release - Fast FPU" /> - <Option type="3" /> - <Option compiler="gcc" /> - <Option createDefFile="1" /> - <Option createStaticLib="1" /> - <Compiler> - <Add option="-O3" /> - <Add option="-W" /> - <Add option="-DWIN32" /> - <Add option="-DNDEBUG" /> - <Add option="-D_WINDOWS" /> - <Add option="-D_USRDLL" /> - <Add option="-DIRRLICHT_EXPORTS" /> - <Add option="-D_CRT_SECURE_NO_DEPRECATE" /> - <Add directory="..\..\include" /> - <Add directory="zlib" /> - </Compiler> - <Linker> - <Add library="kernel32" /> - <Add library="user32" /> - <Add library="gdi32" /> - <Add library="winspool" /> - <Add library="comdlg32" /> - <Add library="advapi32" /> - <Add library="shell32" /> - <Add library="ole32" /> - <Add library="oleaut32" /> - <Add library="uuid" /> - <Add library="opengl32" /> - </Linker> - </Target> - </Build> - <VirtualTargets> - <Add alias="All" targets="Debug;Release;Release - Fast FPU;" /> - </VirtualTargets> - <Unit filename="..\..\changes.txt"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\ECullingTypes.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\EDebugSceneTypes.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\EDriverTypes.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\EGUIElementTypes.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\EMeshWriterEnums.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\EMessageBoxFlags.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\ESceneNodeAnimatorTypes.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\ESceneNodeTypes.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IAnimatedMesh.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IAnimatedMeshMD2.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IAnimatedMeshSceneNode.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IAttributeExchangingObject.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IAttributes.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IBillboardSceneNode.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IBoneSceneNode.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\ICameraSceneNode.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\ICursorControl.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IDummyTransformationSceneNode.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IEventReceiver.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IFileList.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IFileSystem.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IGPUProgrammingServices.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IGUIButton.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IGUICheckbox.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IGUIComboBox.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IGUIContextMenu.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IGUIEditBox.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IGUIElement.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IGUIElementFactory.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IGUIEnvironment.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IGUIFileOpenDialog.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IGUIFont.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IGUIImage.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IGUIInOutFader.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IGUIListBox.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IGUIMeshViewer.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IGUIScrollBar.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IGUISkin.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IGUISpinBox.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IGUISpriteBank.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IGUIStaticText.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IGUITabControl.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IGUIToolbar.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IGUIWindow.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IImage.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IImageLoader.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\ILightSceneNode.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\ILogger.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IMaterialRenderer.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IMaterialRendererServices.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IMesh.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IMeshBuffer.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IMeshCache.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IMeshLoader.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IMeshManipulator.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IMeshSceneNode.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IMeshWriter.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IMetaTriangleSelector.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IOSOperator.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IParticleAffector.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IParticleEmitter.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IParticleSystemSceneNode.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IQ3LevelMesh.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IReadFile.H"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IReferenceCounted.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\ISceneCollisionManager.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\ISceneManager.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\ISceneNode.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\ISceneNodeAnimator.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\ISceneNodeAnimatorCollisionResponse.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\ISceneNodeAnimatorFactory.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\ISceneNodeFactory.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\ISceneNodeMeshLoader.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IShaderConstantSetCallBack.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IShadowVolumeSceneNode.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\ISkinnedMesh.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\ITerrainSceneNode.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\ITextSceneNode.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\ITexture.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\ITimer.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\ITriangleSelector.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IVideoDriver.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IVideoModeList.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IWriteFile.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IXMLReader.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IXMLWriter.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IrrCompileConfig.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\IrrlichtDevice.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\Keycodes.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\S3DVertex.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\SAnimatedMesh.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\SColor.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\SExposedVideoData.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\SIrrCreationParameters.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\SKeyMap.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\SLight.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\SMaterial.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\SMesh.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\SMeshBuffer.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\SMeshBufferLightMap.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\SMeshBufferTangents.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\SParticle.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\SViewFrustum.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\SceneParameters.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\aabbox3d.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\dimension2d.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\heapsort.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\irrAllocator.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\irrArray.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\irrList.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\irrMap.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\irrMath.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\irrString.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\irrTypes.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\irrXML.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\irrlicht.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\line2d.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\line3d.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\matrix4.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\plane3d.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\position2d.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\quaternion.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\rect.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\triangle3d.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\vector2d.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\include\vector3d.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="..\..\readme.txt"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="BuiltInFont.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="C3DSMeshFileLoader.cpp" /> - <Unit filename="C3DSMeshFileLoader.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CAnimatedMeshMD2.cpp" /> - <Unit filename="CAnimatedMeshMD2.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CAnimatedMeshMD3.cpp" /> - <Unit filename="CAnimatedMeshMD3.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CAnimatedMeshSceneNode.cpp" /> - <Unit filename="CAnimatedMeshSceneNode.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CAttributeImpl.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CAttributes.cpp" /> - <Unit filename="CAttributes.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CB3DMeshFileLoader.cpp" /> - <Unit filename="CB3DMeshFileLoader.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CBSPMeshFileLoader.cpp" /> - <Unit filename="CBSPMeshFileLoader.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CBillboardSceneNode.cpp" /> - <Unit filename="CBillboardSceneNode.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CBoneSceneNode.cpp" /> - <Unit filename="CBoneSceneNode.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CCSMLoader.cpp" /> - <Unit filename="CCSMLoader.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CCameraFPSSceneNode.cpp" /> - <Unit filename="CCameraFPSSceneNode.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CCameraMayaSceneNode.cpp" /> - <Unit filename="CCameraMayaSceneNode.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CCameraSceneNode.cpp" /> - <Unit filename="CCameraSceneNode.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CColladaFileLoader.cpp" /> - <Unit filename="CColladaFileLoader.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CColladaMeshWriter.cpp" /> - <Unit filename="CColladaMeshWriter.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CColorConverter.cpp" /> - <Unit filename="CColorConverter.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CCubeSceneNode.cpp" /> - <Unit filename="CCubeSceneNode.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CD3D8Driver.cpp" /> - <Unit filename="CD3D8Driver.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CD3D8MaterialRenderer.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CD3D8NormalMapRenderer.cpp" /> - <Unit filename="CD3D8NormalMapRenderer.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CD3D8ParallaxMapRenderer.cpp" /> - <Unit filename="CD3D8ParallaxMapRenderer.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CD3D8ShaderMaterialRenderer.cpp" /> - <Unit filename="CD3D8ShaderMaterialRenderer.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CD3D8Texture.cpp" /> - <Unit filename="CD3D8Texture.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CD3D9Driver.cpp" /> - <Unit filename="CD3D9Driver.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CD3D9HLSLMaterialRenderer.cpp" /> - <Unit filename="CD3D9HLSLMaterialRenderer.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CD3D9MaterialRenderer.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CD3D9NormalMapRenderer.cpp" /> - <Unit filename="CD3D9NormalMapRenderer.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CD3D9ParallaxMapRenderer.cpp" /> - <Unit filename="CD3D9ParallaxMapRenderer.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CD3D9ShaderMaterialRenderer.cpp" /> - <Unit filename="CD3D9ShaderMaterialRenderer.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CD3D9Texture.cpp" /> - <Unit filename="CD3D9Texture.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CDMFLoader.cpp" /> - <Unit filename="CDMFLoader.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CDefaultGUIElementFactory.cpp" /> - <Unit filename="CDefaultGUIElementFactory.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CDefaultSceneNodeAnimatorFactory.cpp" /> - <Unit filename="CDefaultSceneNodeAnimatorFactory.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CDefaultSceneNodeFactory.cpp" /> - <Unit filename="CDefaultSceneNodeFactory.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CDepthBuffer.cpp" /> - <Unit filename="CDepthBuffer.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CDummyTransformationSceneNode.cpp" /> - <Unit filename="CDummyTransformationSceneNode.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CEmptySceneNode.cpp" /> - <Unit filename="CEmptySceneNode.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CFPSCounter.cpp" /> - <Unit filename="CFPSCounter.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CFileList.cpp" /> - <Unit filename="CFileList.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CFileSystem.cpp" /> - <Unit filename="CFileSystem.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CGUIButton.cpp" /> - <Unit filename="CGUIButton.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CGUICheckbox.cpp" /> - <Unit filename="CGUICheckbox.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CGUIColorSelectDialog.cpp" /> - <Unit filename="CGUIColorSelectDialog.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CGUIComboBox.cpp" /> - <Unit filename="CGUIComboBox.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CGUIContextMenu.cpp" /> - <Unit filename="CGUIContextMenu.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CGUIEditBox.cpp" /> - <Unit filename="CGUIEditBox.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CGUIEnvironment.cpp" /> - <Unit filename="CGUIEnvironment.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CGUIFileOpenDialog.cpp" /> - <Unit filename="CGUIFileOpenDialog.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CGUIFont.cpp" /> - <Unit filename="CGUIFont.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CGUIImage.cpp" /> - <Unit filename="CGUIImage.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CGUIInOutFader.cpp" /> - <Unit filename="CGUIInOutFader.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CGUIListBox.cpp" /> - <Unit filename="CGUIListBox.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CGUIMenu.cpp" /> - <Unit filename="CGUIMenu.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CGUIMeshViewer.cpp" /> - <Unit filename="CGUIMeshViewer.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CGUIMessageBox.cpp" /> - <Unit filename="CGUIMessageBox.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CGUIModalScreen.cpp" /> - <Unit filename="CGUIModalScreen.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CGUIScrollBar.cpp" /> - <Unit filename="CGUIScrollBar.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CGUISkin.cpp" /> - <Unit filename="CGUISkin.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CGUISpinBox.cpp" /> - <Unit filename="CGUISpinBox.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CGUISpriteBank.cpp" /> - <Unit filename="CGUISpriteBank.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CGUIStaticText.cpp" /> - <Unit filename="CGUIStaticText.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CGUITabControl.cpp" /> - <Unit filename="CGUITabControl.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CGUIToolBar.cpp" /> - <Unit filename="CGUIToolBar.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CGUIWindow.cpp" /> - <Unit filename="CGUIWindow.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CGeometryCreator.cpp" /> - <Unit filename="CGeometryCreator.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CImage.cpp" /> - <Unit filename="CImage.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CImageLoaderBMP.cpp" /> - <Unit filename="CImageLoaderBMP.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CImageLoaderJPG.cpp" /> - <Unit filename="CImageLoaderJPG.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CImageLoaderPCX.cpp" /> - <Unit filename="CImageLoaderPCX.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CImageLoaderPNG.cpp" /> - <Unit filename="CImageLoaderPNG.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CImageLoaderPPM.cpp" /> - <Unit filename="CImageLoaderPPM.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CImageLoaderPSD.cpp" /> - <Unit filename="CImageLoaderPSD.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CImageLoaderTGA.cpp" /> - <Unit filename="CImageLoaderTGA.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CImageWriterBMP.cpp" /> - <Unit filename="CImageWriterBMP.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CImageWriterJPG.cpp" /> - <Unit filename="CImageWriterJPG.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CImageWriterPCX.cpp" /> - <Unit filename="CImageWriterPCX.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CImageWriterPNG.cpp" /> - <Unit filename="CImageWriterPNG.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CImageWriterPPM.cpp" /> - <Unit filename="CImageWriterPPM.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CImageWriterPSD.cpp" /> - <Unit filename="CImageWriterPSD.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CImageWriterTGA.cpp" /> - <Unit filename="CImageWriterTGA.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CIrrDeviceLinux.cpp" /> - <Unit filename="CIrrDeviceLinux.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CIrrDeviceStub.cpp" /> - <Unit filename="CIrrDeviceStub.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CIrrDeviceWin32.cpp" /> - <Unit filename="CIrrDeviceWin32.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CIrrMeshFileLoader.cpp" /> - <Unit filename="CIrrMeshFileLoader.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CIrrMeshWriter.cpp" /> - <Unit filename="CIrrMeshWriter.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CLMTSMeshFileLoader.cpp" /> - <Unit filename="CLMTSMeshFileLoader.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CLightSceneNode.cpp" /> - <Unit filename="CLightSceneNode.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CLimitReadFile.cpp" /> - <Unit filename="CLimitReadFile.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CLogger.cpp" /> - <Unit filename="CLogger.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CMD2MeshFileLoader.cpp" /> - <Unit filename="CMD2MeshFileLoader.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CMD3MeshFileLoader.cpp" /> - <Unit filename="CMD3MeshFileLoader.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CMS3DMeshFileLoader.cpp" /> - <Unit filename="CMS3DMeshFileLoader.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CMY3DHelper.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CMY3DMeshFileLoader.cpp" /> - <Unit filename="CMY3DMeshFileLoader.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CMY3DStuff.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CMemoryReadFile.cpp" /> - <Unit filename="CMemoryReadFile.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CMeshCache.cpp" /> - <Unit filename="CMeshCache.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CMeshManipulator.cpp" /> - <Unit filename="CMeshManipulator.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CMeshSceneNode.cpp" /> - <Unit filename="CMeshSceneNode.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CMetaTriangleSelector.cpp" /> - <Unit filename="CMetaTriangleSelector.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CNullDriver.cpp" /> - <Unit filename="CNullDriver.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="COBJMeshFileLoader.cpp" /> - <Unit filename="COBJMeshFileLoader.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="COCTLoader.cpp" /> - <Unit filename="COCTLoader.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="COSOperator.cpp" /> - <Unit filename="COSOperator.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="COctTreeSceneNode.cpp" /> - <Unit filename="COctTreeSceneNode.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="COctTreeTriangleSelector.cpp" /> - <Unit filename="COctTreeTriangleSelector.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="COgreMeshFileLoader.cpp" /> - <Unit filename="COgreMeshFileLoader.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="COpenGLDriver.cpp" /> - <Unit filename="COpenGLDriver.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="COpenGLExtensionHandler.cpp" /> - <Unit filename="COpenGLExtensionHandler.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="COpenGLMaterialRenderer.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="COpenGLNormalMapRenderer.cpp" /> - <Unit filename="COpenGLNormalMapRenderer.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="COpenGLParallaxMapRenderer.cpp" /> - <Unit filename="COpenGLParallaxMapRenderer.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="COpenGLSLMaterialRenderer.cpp" /> - <Unit filename="COpenGLSLMaterialRenderer.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="COpenGLShaderMaterialRenderer.cpp" /> - <Unit filename="COpenGLShaderMaterialRenderer.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="COpenGLTexture.cpp" /> - <Unit filename="COpenGLTexture.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CPakReader.cpp" /> - <Unit filename="CPakReader.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CParticleAnimatedMeshSceneNodeEmitter.cpp" /> - <Unit filename="CParticleAttractionAffector.cpp" /> - <Unit filename="CParticleBoxEmitter.cpp" /> - <Unit filename="CParticleBoxEmitter.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CParticleCylinderEmitter.cpp" /> - <Unit filename="CParticleFadeOutAffector.cpp" /> - <Unit filename="CParticleFadeOutAffector.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CParticleGravityAffector.cpp" /> - <Unit filename="CParticleGravityAffector.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CParticleMeshEmitter.cpp" /> - <Unit filename="CParticlePointEmitter.cpp" /> - <Unit filename="CParticlePointEmitter.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CParticleRingEmitter.cpp" /> - <Unit filename="CParticleRotationAffector.cpp" /> - <Unit filename="CParticleSphereEmitter.cpp" /> - <Unit filename="CParticleSystemSceneNode.cpp" /> - <Unit filename="CParticleSystemSceneNode.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CQ3LevelMesh.cpp" /> - <Unit filename="CQ3LevelMesh.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CQuake3ShaderSceneNode.cpp" /> - <Unit filename="CQuake3ShaderSceneNode.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CReadFile.cpp" /> - <Unit filename="CReadFile.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CSTLMeshFileLoader.cpp" /> - <Unit filename="CSTLMeshFileLoader.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CSTLMeshWriter.cpp" /> - <Unit filename="CSTLMeshWriter.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CSceneCollisionManager.cpp" /> - <Unit filename="CSceneCollisionManager.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CSceneManager.cpp" /> - <Unit filename="CSceneManager.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CSceneNodeAnimatorCollisionResponse.cpp" /> - <Unit filename="CSceneNodeAnimatorCollisionResponse.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CSceneNodeAnimatorDelete.cpp" /> - <Unit filename="CSceneNodeAnimatorDelete.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CSceneNodeAnimatorFlyCircle.cpp" /> - <Unit filename="CSceneNodeAnimatorFlyCircle.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CSceneNodeAnimatorFlyStraight.cpp" /> - <Unit filename="CSceneNodeAnimatorFlyStraight.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CSceneNodeAnimatorFollowSpline.cpp" /> - <Unit filename="CSceneNodeAnimatorFollowSpline.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CSceneNodeAnimatorRotation.cpp" /> - <Unit filename="CSceneNodeAnimatorRotation.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CSceneNodeAnimatorTexture.cpp" /> - <Unit filename="CSceneNodeAnimatorTexture.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CShadowVolumeSceneNode.cpp" /> - <Unit filename="CShadowVolumeSceneNode.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CSkinnedMesh.cpp" /> - <Unit filename="CSkinnedMesh.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CSkyBoxSceneNode.cpp" /> - <Unit filename="CSkyBoxSceneNode.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CSkyDomeSceneNode.cpp" /> - <Unit filename="CSkyDomeSceneNode.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CSoftware2MaterialRenderer.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CSoftwareDriver.cpp" /> - <Unit filename="CSoftwareDriver.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CSoftwareDriver2.cpp" /> - <Unit filename="CSoftwareDriver2.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CSoftwareTexture.cpp" /> - <Unit filename="CSoftwareTexture.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CSoftwareTexture2.cpp" /> - <Unit filename="CSoftwareTexture2.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CSphereSceneNode.cpp" /> - <Unit filename="CSphereSceneNode.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CTRFlat.cpp" /> - <Unit filename="CTRFlatWire.cpp" /> - <Unit filename="CTRGouraud.cpp" /> - <Unit filename="CTRGouraud2.cpp" /> - <Unit filename="CTRGouraudAlpha2.cpp" /> - <Unit filename="CTRGouraudAlphaNoZ2.cpp" /> - <Unit filename="CTRGouraudWire.cpp" /> - <Unit filename="CTRTextureBlend.cpp" /> - <Unit filename="CTRTextureDetailMap2.cpp" /> - <Unit filename="CTRTextureFlat.cpp" /> - <Unit filename="CTRTextureFlatWire.cpp" /> - <Unit filename="CTRTextureGouraud.cpp" /> - <Unit filename="CTRTextureGouraud.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CTRTextureGouraud2.cpp" /> - <Unit filename="CTRTextureGouraudAdd.cpp" /> - <Unit filename="CTRTextureGouraudAdd2.cpp" /> - <Unit filename="CTRTextureGouraudAddNoZ2.cpp" /> - <Unit filename="CTRTextureGouraudAlpha.cpp" /> - <Unit filename="CTRTextureGouraudAlphaNoZ.cpp" /> - <Unit filename="CTRTextureGouraudNoZ.cpp" /> - <Unit filename="CTRTextureGouraudNoZ2.cpp" /> - <Unit filename="CTRTextureGouraudVertexAlpha2.cpp" /> - <Unit filename="CTRTextureGouraudWire.cpp" /> - <Unit filename="CTRTextureLightMap2_Add.cpp" /> - <Unit filename="CTRTextureLightMap2_M1.cpp" /> - <Unit filename="CTRTextureLightMap2_M2.cpp" /> - <Unit filename="CTRTextureLightMap2_M4.cpp" /> - <Unit filename="CTRTextureLightMapGouraud2_M4.cpp" /> - <Unit filename="CTRTextureWire2.cpp" /> - <Unit filename="CTerrainSceneNode.cpp" /> - <Unit filename="CTerrainSceneNode.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CTerrainTriangleSelector.cpp" /> - <Unit filename="CTerrainTriangleSelector.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CTextSceneNode.cpp" /> - <Unit filename="CTextSceneNode.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CTimer.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CTriangleBBSelector.cpp" /> - <Unit filename="CTriangleBBSelector.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CTriangleSelector.cpp" /> - <Unit filename="CTriangleSelector.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CVideoModeList.cpp" /> - <Unit filename="CVideoModeList.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CWaterSurfaceSceneNode.cpp" /> - <Unit filename="CWaterSurfaceSceneNode.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CWriteFile.cpp" /> - <Unit filename="CWriteFile.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CXMLReader.cpp" /> - <Unit filename="CXMLReader.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CXMLReaderImpl.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CXMLWriter.cpp" /> - <Unit filename="CXMLWriter.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CXMeshFileLoader.cpp" /> - <Unit filename="CXMeshFileLoader.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CZBuffer.cpp" /> - <Unit filename="CZBuffer.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="CZipReader.cpp" /> - <Unit filename="CZipReader.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="IBurningShader.cpp" /> - <Unit filename="IBurningShader.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="IDepthBuffer.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="IImagePresenter.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="ITriangleRenderer.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="IZBuffer.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="Irrlicht.cpp" /> - <Unit filename="OctTree.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="S2DVertex.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="S4DVertex.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="SoftwareDriver2_compile_config.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="SoftwareDriver2_helper.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="dmfsupport.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="glext.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="irrXML.cpp" /> - <Unit filename="jpeglib\cderror.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="jpeglib\cdjpeg.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\cdjpeg.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="jpeglib\jcapimin.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jcapistd.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jccoefct.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jccolor.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jcdctmgr.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jchuff.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jchuff.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="jpeglib\jcinit.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jcmainct.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jcmarker.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jcmaster.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jcomapi.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jconfig.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="jpeglib\jcparam.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jcphuff.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jcprepct.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jcsample.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jctrans.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jdapimin.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jdapistd.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jdatadst.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jdatasrc.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jdcoefct.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jdcolor.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jdct.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="jpeglib\jddctmgr.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jdhuff.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jdhuff.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="jpeglib\jdinput.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jdmainct.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jdmarker.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jdmaster.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jdmerge.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jdphuff.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jdpostct.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jdsample.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jdtrans.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jerror.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jerror.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="jpeglib\jfdctflt.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jfdctfst.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jfdctint.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jidctflt.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jidctfst.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jidctint.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jidctred.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jinclude.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="jpeglib\jmemmgr.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jmemnobs.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jmemsys.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="jpeglib\jmorecfg.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="jpeglib\jpegint.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="jpeglib\jpeglib.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="jpeglib\jquant1.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jquant2.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jutils.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="jpeglib\jversion.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="libpng\png.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="libpng\png.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="libpng\pngconf.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="libpng\pngerror.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="libpng\pngget.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="libpng\pngmem.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="libpng\pngpread.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="libpng\pngread.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="libpng\pngrio.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="libpng\pngrtran.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="libpng\pngrutil.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="libpng\pngset.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="libpng\pngtrans.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="libpng\pngwio.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="libpng\pngwrite.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="libpng\pngwtran.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="libpng\pngwutil.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="os.cpp" /> - <Unit filename="os.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="zlib\adler32.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="zlib\compress.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="zlib\crc32.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="zlib\crc32.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="zlib\deflate.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="zlib\deflate.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="zlib\inffast.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="zlib\inffast.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="zlib\inffixed.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="zlib\inflate.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="zlib\inftrees.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="zlib\inftrees.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="zlib\trees.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="zlib\trees.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="zlib\uncompr.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="zlib\zconf.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="zlib\zlib.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Unit filename="zlib\zutil.c"> - <Option compilerVar="CC" /> - </Unit> - <Unit filename="zlib\zutil.h"> - <Option compile="0" /> - <Option link="0" /> - </Unit> - <Extensions> - <code_completion /> - <envvars /> - <debugger /> - </Extensions> - </Project> -</CodeBlocks_project_file> diff --git a/irrlicht-1.6/source/Irrlicht/Irrlicht_Win32-gcc.depend b/irrlicht-1.6/source/Irrlicht/Irrlicht_Win32-gcc.depend deleted file mode 100644 index f36a90bdf..000000000 --- a/irrlicht-1.6/source/Irrlicht/Irrlicht_Win32-gcc.depend +++ /dev/null @@ -1,4679 +0,0 @@ -# depslib dependency file v1.0 -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\cdjpeg.c - "cdjpeg.h" - <ctype.h> - <signal.h> - <fcntl.h> - <io.h> - -1195285108 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\cdjpeg.h - "jinclude.h" - "jpeglib.h" - "jerror.h" - "cderror.h" - -1195285108 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jinclude.h - "jconfig.h" - <stddef.h> - <stdlib.h> - <sys/types.h> - <stdio.h> - <strings.h> - <string.h> - -1195285108 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jconfig.h - -1195285108 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jpeglib.h - "jconfig.h" - "jmorecfg.h" - "jpegint.h" - "jerror.h" - -1195285108 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jmorecfg.h - -1195285108 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jpegint.h - -1195285108 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jerror.h - -1195285108 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\cderror.h - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jcapimin.c - "jinclude.h" - "jpeglib.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jcapistd.c - "jinclude.h" - "jpeglib.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jccoefct.c - "jinclude.h" - "jpeglib.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jccolor.c - "jinclude.h" - "jpeglib.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jcdctmgr.c - "jinclude.h" - "jpeglib.h" - "jdct.h" - -1195285108 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jdct.h - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jchuff.c - "jinclude.h" - "jpeglib.h" - "jchuff.h" - -1195285108 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jchuff.h - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jcinit.c - "jinclude.h" - "jpeglib.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jcmainct.c - "jinclude.h" - "jpeglib.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jcmarker.c - "jinclude.h" - "jpeglib.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jcmaster.c - "jinclude.h" - "jpeglib.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jcomapi.c - "jinclude.h" - "jpeglib.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jcparam.c - "jinclude.h" - "jpeglib.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jcphuff.c - "jinclude.h" - "jpeglib.h" - "jchuff.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jcprepct.c - "jinclude.h" - "jpeglib.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jcsample.c - "jinclude.h" - "jpeglib.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jctrans.c - "jinclude.h" - "jpeglib.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jdapimin.c - "jinclude.h" - "jpeglib.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jdapistd.c - "jinclude.h" - "jpeglib.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jdatadst.c - "jinclude.h" - "jpeglib.h" - "jerror.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jdatasrc.c - "jinclude.h" - "jpeglib.h" - "jerror.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jdcoefct.c - "jinclude.h" - "jpeglib.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jdcolor.c - "jinclude.h" - "jpeglib.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jddctmgr.c - "jinclude.h" - "jpeglib.h" - "jdct.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jdhuff.c - "jinclude.h" - "jpeglib.h" - "jdhuff.h" - -1195285108 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jdhuff.h - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jdinput.c - "jinclude.h" - "jpeglib.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jdmainct.c - "jinclude.h" - "jpeglib.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jdmarker.c - "jinclude.h" - "jpeglib.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jdmaster.c - "jinclude.h" - "jpeglib.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jdmerge.c - "jinclude.h" - "jpeglib.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jdphuff.c - "jinclude.h" - "jpeglib.h" - "jdhuff.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jdpostct.c - "jinclude.h" - "jpeglib.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jdsample.c - "jinclude.h" - "jpeglib.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jdtrans.c - "jinclude.h" - "jpeglib.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jerror.c - "jinclude.h" - "jpeglib.h" - "jversion.h" - "jerror.h" - <windows.h> - "jerror.h" - -1195285108 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jversion.h - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jfdctflt.c - "jinclude.h" - "jpeglib.h" - "jdct.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jfdctfst.c - "jinclude.h" - "jpeglib.h" - "jdct.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jfdctint.c - "jinclude.h" - "jpeglib.h" - "jdct.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jidctflt.c - "jinclude.h" - "jpeglib.h" - "jdct.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jidctfst.c - "jinclude.h" - "jpeglib.h" - "jdct.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jidctint.c - "jinclude.h" - "jpeglib.h" - "jdct.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jidctred.c - "jinclude.h" - "jpeglib.h" - "jdct.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jmemmgr.c - "jinclude.h" - "jpeglib.h" - "jmemsys.h" - -1195285108 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jmemsys.h - <Files.h> - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jmemnobs.c - "jinclude.h" - "jpeglib.h" - "jmemsys.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jquant1.c - "jinclude.h" - "jpeglib.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jquant2.c - "jinclude.h" - "jpeglib.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jutils.c - "jinclude.h" - "jpeglib.h" - -1195285100 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\libpng\png.c - "png.h" - -1195285100 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\libpng\png.h - "zlib.h" - "pngconf.h" - <crtdbg.h> - -1195285103 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\zlib\zlib.h - "zconf.h" - -1195285103 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\zlib\zconf.h - <windows.h> - <sys/types.h> - <unistd.h> - <unixio.h> - -1195285100 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\libpng\pngconf.h - "pngusr.h" - "config.h" - <windows.h> - <stdio.h> - <stdio.h> - <sys/types.h> - <setjmp.h> - <strings.h> - <string.h> - <stdlib.h> - <fp.h> - <math.h> - <m68881.h> - <mem.h> - <alloc.h> - <malloc.h> - <time.h> - <dos.h> - -1195285100 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\libpng\pngerror.c - "png.h" - -1195285100 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\libpng\pngget.c - "png.h" - -1195285100 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\libpng\pngmem.c - "png.h" - -1195285100 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\libpng\pngpread.c - "png.h" - -1195285100 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\libpng\pngread.c - "png.h" - -1195285100 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\libpng\pngrio.c - "png.h" - -1195285101 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\libpng\pngrtran.c - "png.h" - -1195285100 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\libpng\pngrutil.c - "png.h" - -1195285100 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\libpng\pngset.c - "png.h" - -1195285100 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\libpng\pngtrans.c - "png.h" - -1195285100 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\libpng\pngwio.c - "png.h" - -1195285100 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\libpng\pngwrite.c - "png.h" - -1195285100 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\libpng\pngwtran.c - "png.h" - -1195285100 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\libpng\pngwutil.c - "png.h" - -1195285103 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\zlib\adler32.c - "zlib.h" - -1195285103 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\zlib\compress.c - "zlib.h" - -1195285103 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\zlib\crc32.c - <stdio.h> - "zutil.h" - <limits.h> - "crc32.h" - -1195285103 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\zlib\zutil.h - "zlib.h" - <stddef.h> - <string.h> - <stdlib.h> - <errno.h> - <alloc.h> - <malloc.h> - <malloc.h> - <unix.h> - <stdio.h> - -1195285103 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\zlib\crc32.h - -1195285103 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\zlib\deflate.c - "deflate.h" - -1195285103 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\zlib\deflate.h - "zutil.h" - -1195285103 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\zlib\inffast.c - "zutil.h" - "inftrees.h" - "inflate.h" - "inffast.h" - -1195285103 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\zlib\inftrees.h - -1195285103 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\zlib\inflate.h - -1195285103 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\zlib\inffast.h - -1195285103 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\zlib\inflate.c - "zutil.h" - "inftrees.h" - "inflate.h" - "inffast.h" - "inffixed.h" - <stdio.h> - -1195285103 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\zlib\inffixed.h - -1195285103 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\zlib\inftrees.c - "zutil.h" - "inftrees.h" - -1195285103 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\zlib\trees.c - "deflate.h" - <ctype.h> - "trees.h" - <stdio.h> - -1195285103 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\zlib\trees.h - -1195285103 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\zlib\uncompr.c - "zlib.h" - -1195285103 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\zlib\zutil.c - "zutil.h" - -1212214612 source:c:\development\irrlicht-1.4\irrlicht\include\ecullingtypes.h - "irrTypes.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\irrtypes.h - "IrrCompileConfig.h" - <wchar.h> - <crtdbg.h> - "assert.h" - <stdlib.h> - <crtdbg.h> - -1221911334 c:\development\irrlicht-1.4\irrlicht\include\irrcompileconfig.h - <stdio.h> - -1212214612 source:c:\development\irrlicht-1.4\irrlicht\include\edebugscenetypes.h - -1212214612 source:c:\development\irrlicht-1.4\irrlicht\include\edrivertypes.h - -1212214612 source:c:\development\irrlicht-1.4\irrlicht\include\eguielementtypes.h - "irrTypes.h" - -1212214612 source:c:\development\irrlicht-1.4\irrlicht\include\emeshwriterenums.h - "irrTypes.h" - -1212214609 source:c:\development\irrlicht-1.4\irrlicht\include\emessageboxflags.h - -1212214612 source:c:\development\irrlicht-1.4\irrlicht\include\escenenodeanimatortypes.h - -1212214609 source:c:\development\irrlicht-1.4\irrlicht\include\escenenodetypes.h - "irrTypes.h" - -1212214612 source:c:\development\irrlicht-1.4\irrlicht\include\ianimatedmesh.h - "aabbox3d.h" - "IMesh.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\aabbox3d.h - "irrMath.h" - "plane3d.h" - "line3d.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\irrmath.h - "IrrCompileConfig.h" - "irrTypes.h" - <math.h> - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\plane3d.h - "irrMath.h" - "vector3d.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\vector3d.h - "irrMath.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\line3d.h - "irrTypes.h" - "vector3d.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\imesh.h - "IReferenceCounted.h" - "SMaterial.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\ireferencecounted.h - "irrTypes.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\smaterial.h - "SColor.h" - "matrix4.h" - "irrArray.h" - "EMaterialTypes.h" - "EMaterialFlags.h" - "SMaterialLayer.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\scolor.h - "irrTypes.h" - "irrMath.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\matrix4.h - "irrTypes.h" - "vector3d.h" - "vector2d.h" - "plane3d.h" - "aabbox3d.h" - "rect.h" - "irrString.h" - -1212214613 c:\development\irrlicht-1.4\irrlicht\include\vector2d.h - "irrMath.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\rect.h - "irrTypes.h" - "dimension2d.h" - "position2d.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\dimension2d.h - "irrTypes.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\position2d.h - "irrTypes.h" - "dimension2d.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\irrstring.h - "irrTypes.h" - "irrAllocator.h" - "irrMath.h" - <stdio.h> - <string.h> - <stdlib.h> - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\irrallocator.h - "irrTypes.h" - <new> - <memory.h> - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\irrarray.h - "irrTypes.h" - "heapsort.h" - "irrAllocator.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\heapsort.h - "irrTypes.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\ematerialtypes.h - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\ematerialflags.h - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\smateriallayer.h - "matrix4.h" - "irrAllocator.h" - -1212214612 source:c:\development\irrlicht-1.4\irrlicht\include\ianimatedmeshmd2.h - "IAnimatedMesh.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\ianimatedmesh.h - "aabbox3d.h" - "IMesh.h" - -1212214612 source:c:\development\irrlicht-1.4\irrlicht\include\ianimatedmeshscenenode.h - "ISceneNode.h" - "IBoneSceneNode.h" - "IAnimatedMeshMD2.h" - "IAnimatedMeshMD3.h" - "IShadowVolumeSceneNode.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\iscenenode.h - "IAttributeExchangingObject.h" - "ESceneNodeTypes.h" - "ECullingTypes.h" - "EDebugSceneTypes.h" - "ISceneNodeAnimator.h" - "ITriangleSelector.h" - "SMaterial.h" - "irrString.h" - "aabbox3d.h" - "matrix4.h" - "irrList.h" - "IAttributes.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\iattributeexchangingobject.h - "IReferenceCounted.h" - -1212214609 c:\development\irrlicht-1.4\irrlicht\include\escenenodetypes.h - "irrTypes.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\ecullingtypes.h - "irrTypes.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\edebugscenetypes.h - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\iscenenodeanimator.h - "IReferenceCounted.h" - "vector3d.h" - "ESceneNodeAnimatorTypes.h" - "IAttributeExchangingObject.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\escenenodeanimatortypes.h - -1212214609 c:\development\irrlicht-1.4\irrlicht\include\itriangleselector.h - "IReferenceCounted.h" - "triangle3d.h" - "aabbox3d.h" - "matrix4.h" - "line3d.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\triangle3d.h - "vector3d.h" - "line3d.h" - "plane3d.h" - "aabbox3d.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\irrlist.h - "irrTypes.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\iattributes.h - "IReferenceCounted.h" - "SColor.h" - "vector3d.h" - "vector2d.h" - "line2d.h" - "line3d.h" - "triangle3d.h" - "position2d.h" - "rect.h" - "matrix4.h" - "quaternion.h" - "plane3d.h" - "triangle3d.h" - "line2d.h" - "line3d.h" - "irrString.h" - "irrArray.h" - "IXMLReader.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\line2d.h - "irrTypes.h" - "vector2d.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\quaternion.h - "irrTypes.h" - "irrMath.h" - "matrix4.h" - "vector3d.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\ixmlreader.h - "IReferenceCounted.h" - "irrXML.h" - -1212214609 c:\development\irrlicht-1.4\irrlicht\include\irrxml.h - <stdio.h> - "IrrCompileConfig.h" - <irrXML.h> - <string> - <irrXML.h> - <irrXML.h> - <irrXML.h> - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\ibonescenenode.h - "ISceneNode.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\ianimatedmeshmd2.h - "IAnimatedMesh.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\ianimatedmeshmd3.h - "IAnimatedMesh.h" - "IQ3Shader.h" - "quaternion.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\iq3shader.h - "irrArray.h" - "fast_atof.h" - "IFileSystem.h" - "IVideoDriver.h" - "coreutil.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\fast_atof.h - <stdlib.h> - "irrMath.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\ifilesystem.h - "IReferenceCounted.h" - "IXMLReader.h" - "irrString.h" - -1221910415 c:\development\irrlicht-1.4\irrlicht\include\ivideodriver.h - "rect.h" - "SColor.h" - "ITexture.h" - "irrArray.h" - "matrix4.h" - "plane3d.h" - "dimension2d.h" - "position2d.h" - "SMaterial.h" - "IMeshBuffer.h" - "triangle3d.h" - "EDriverTypes.h" - "EDriverFeatures.h" - -1212214609 c:\development\irrlicht-1.4\irrlicht\include\itexture.h - "IReferenceCounted.h" - "IImage.h" - "dimension2d.h" - "EDriverTypes.h" - "irrString.h" - "matrix4.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\iimage.h - "IReferenceCounted.h" - "position2d.h" - "rect.h" - "SColor.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\edrivertypes.h - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\imeshbuffer.h - "IReferenceCounted.h" - "SMaterial.h" - "aabbox3d.h" - "S3DVertex.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\s3dvertex.h - "vector3d.h" - "vector2d.h" - "SColor.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\edriverfeatures.h - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\coreutil.h - "irrString.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\ishadowvolumescenenode.h - "ISceneNode.h" - -1212214612 source:c:\development\irrlicht-1.4\irrlicht\include\iattributeexchangingobject.h - "IReferenceCounted.h" - -1212214612 source:c:\development\irrlicht-1.4\irrlicht\include\iattributes.h - "IReferenceCounted.h" - "SColor.h" - "vector3d.h" - "vector2d.h" - "line2d.h" - "line3d.h" - "triangle3d.h" - "position2d.h" - "rect.h" - "matrix4.h" - "quaternion.h" - "plane3d.h" - "triangle3d.h" - "line2d.h" - "line3d.h" - "irrString.h" - "irrArray.h" - "IXMLReader.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\c3dsmeshfileloader.cpp - "IrrCompileConfig.h" - "C3DSMeshFileLoader.h" - "os.h" - "SMeshBuffer.h" - "SAnimatedMesh.h" - "IReadFile.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\c3dsmeshfileloader.h - "IMeshLoader.h" - "IFileSystem.h" - "IVideoDriver.h" - "irrString.h" - "SMesh.h" - "IMeshManipulator.h" - "matrix4.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\imeshloader.h - "IReferenceCounted.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\smesh.h - "IMesh.h" - "IMeshBuffer.h" - "aabbox3d.h" - "irrArray.h" - -1212214611 c:\development\irrlicht-1.4\irrlicht\include\imeshmanipulator.h - "IReferenceCounted.h" - "vector3d.h" - "aabbox3d.h" - "matrix4.h" - "IAnimatedMesh.h" - "SColor.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\os.h - "IrrCompileConfig.h" - "irrTypes.h" - "ILogger.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\ilogger.h - "IReferenceCounted.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\smeshbuffer.h - "CMeshBuffer.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\cmeshbuffer.h - "irrArray.h" - "IMeshBuffer.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\sanimatedmesh.h - "IAnimatedMesh.h" - "IMesh.h" - "aabbox3d.h" - "irrArray.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\ireadfile.h - "IReferenceCounted.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\c3dsmeshfileloader.h - "IMeshLoader.h" - "IFileSystem.h" - "IVideoDriver.h" - "irrString.h" - "SMesh.h" - "IMeshManipulator.h" - "matrix4.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\canimatedmeshmd2.cpp - "IrrCompileConfig.h" - "CAnimatedMeshMD2.h" - "os.h" - "SColor.h" - "IReadFile.h" - "irrMath.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\canimatedmeshmd2.h - "IAnimatedMeshMD2.h" - "IMesh.h" - "CMeshBuffer.h" - "IReadFile.h" - "S3DVertex.h" - "irrArray.h" - "irrString.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\canimatedmeshmd2.h - "IAnimatedMeshMD2.h" - "IMesh.h" - "CMeshBuffer.h" - "IReadFile.h" - "S3DVertex.h" - "irrArray.h" - "irrString.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\canimatedmeshmd3.cpp - "IrrCompileConfig.h" - "CAnimatedMeshMD3.h" - "os.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\canimatedmeshmd3.h - "IAnimatedMeshMD3.h" - "IReadFile.h" - "IFileSystem.h" - "irrArray.h" - "irrString.h" - "SMesh.h" - "SMeshBuffer.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\canimatedmeshmd3.h - "IAnimatedMeshMD3.h" - "IReadFile.h" - "IFileSystem.h" - "irrArray.h" - "irrString.h" - "SMesh.h" - "SMeshBuffer.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\canimatedmeshscenenode.cpp - "CAnimatedMeshSceneNode.h" - "IVideoDriver.h" - "ISceneManager.h" - "S3DVertex.h" - "os.h" - "CShadowVolumeSceneNode.h" - "IAnimatedMeshMD3.h" - "CSkinnedMesh.h" - "IDummyTransformationSceneNode.h" - "IBoneSceneNode.h" - "IMaterialRenderer.h" - "IMesh.h" - "IMeshCache.h" - "IAnimatedMesh.h" - "quaternion.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\canimatedmeshscenenode.h - "IAnimatedMeshSceneNode.h" - "IAnimatedMesh.h" - "matrix4.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\ianimatedmeshscenenode.h - "ISceneNode.h" - "IBoneSceneNode.h" - "IAnimatedMeshMD2.h" - "IAnimatedMeshMD3.h" - "IShadowVolumeSceneNode.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\iscenemanager.h - "IReferenceCounted.h" - "irrArray.h" - "vector3d.h" - "dimension2d.h" - "SColor.h" - "ETerrainElements.h" - "ESceneNodeTypes.h" - "EMeshWriterEnums.h" - "SceneParameters.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\eterrainelements.h - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\emeshwriterenums.h - "irrTypes.h" - -1221910415 c:\development\irrlicht-1.4\irrlicht\include\sceneparameters.h - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cshadowvolumescenenode.h - "IShadowVolumeSceneNode.h" - -1221578952 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cskinnedmesh.h - "ISkinnedMesh.h" - "SMeshBuffer.h" - "S3DVertex.h" - "irrString.h" - "matrix4.h" - "quaternion.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\iskinnedmesh.h - "irrArray.h" - "IBoneSceneNode.h" - "IAnimatedMesh.h" - "SSkinMeshBuffer.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\sskinmeshbuffer.h - "IMeshBuffer.h" - "S3DVertex.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\idummytransformationscenenode.h - "ISceneNode.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\imaterialrenderer.h - "IReferenceCounted.h" - "SMaterial.h" - "S3DVertex.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\imeshcache.h - "IReferenceCounted.h" - "irrString.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\canimatedmeshscenenode.h - "IAnimatedMeshSceneNode.h" - "IAnimatedMesh.h" - "matrix4.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cattributes.cpp - "CAttributes.h" - "CAttributeImpl.h" - "ITexture.h" - "IXMLWriter.h" - "IVideoDriver.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cattributes.h - "IAttributes.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cattributeimpl.h - "CAttributes.h" - "fast_atof.h" - "ITexture.h" - "IVideoDriver.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\ixmlwriter.h - "IReferenceCounted.h" - "irrArray.h" - "irrString.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cattributes.h - "IAttributes.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cb3dmeshfileloader.cpp - "IrrCompileConfig.h" - "CB3DMeshFileLoader.h" - "IVideoDriver.h" - "os.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cb3dmeshfileloader.h - "IrrCompileConfig.h" - "IMeshLoader.h" - "ISceneManager.h" - "CSkinnedMesh.h" - "IReadFile.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cb3dmeshfileloader.h - "IrrCompileConfig.h" - "IMeshLoader.h" - "ISceneManager.h" - "CSkinnedMesh.h" - "IReadFile.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cbspmeshfileloader.cpp - "IrrCompileConfig.h" - "CBSPMeshFileLoader.h" - "CQ3LevelMesh.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cbspmeshfileloader.h - "IMeshLoader.h" - "IFileSystem.h" - "IVideoDriver.h" - "ISceneManager.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cq3levelmesh.h - "IQ3LevelMesh.h" - "IReadFile.h" - "IFileSystem.h" - "SMesh.h" - "SMeshBufferLightMap.h" - "IVideoDriver.h" - "irrString.h" - "ISceneManager.h" - "os.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\iq3levelmesh.h - "IAnimatedMesh.h" - "IQ3Shader.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\smeshbufferlightmap.h - "CMeshBuffer.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cbspmeshfileloader.h - "IMeshLoader.h" - "IFileSystem.h" - "IVideoDriver.h" - "ISceneManager.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cbillboardscenenode.cpp - "CBillboardSceneNode.h" - "IVideoDriver.h" - "ISceneManager.h" - "ICameraSceneNode.h" - "os.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cbillboardscenenode.h - "IBillboardSceneNode.h" - "S3DVertex.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\ibillboardscenenode.h - "ISceneNode.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\icamerascenenode.h - "ISceneNode.h" - "IEventReceiver.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\ieventreceiver.h - "ILogger.h" - "position2d.h" - "Keycodes.h" - -1212214609 c:\development\irrlicht-1.4\irrlicht\include\keycodes.h - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cbillboardscenenode.h - "IBillboardSceneNode.h" - "S3DVertex.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cbonescenenode.cpp - "IrrCompileConfig.h" - "CBoneSceneNode.h" - -1221578951 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cbonescenenode.h - "IBoneSceneNode.h" - "irrString.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cbonescenenode.h - "IBoneSceneNode.h" - "irrString.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ccsmloader.cpp - "IrrCompileConfig.h" - "CCSMLoader.h" - "os.h" - "IFileSystem.h" - "IReadFile.h" - "ISceneManager.h" - "IAttributes.h" - "SMesh.h" - "IVideoDriver.h" - "SAnimatedMesh.h" - "SMeshBufferLightMap.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ccsmloader.h - "irrArray.h" - "IMesh.h" - "irrString.h" - "IFileSystem.h" - "IMeshLoader.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ccsmloader.h - "irrArray.h" - "IMesh.h" - "irrString.h" - "IFileSystem.h" - "IMeshLoader.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ccamerafpsscenenode.cpp - "CCameraFPSSceneNode.h" - "IVideoDriver.h" - "ISceneManager.h" - "os.h" - "Keycodes.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ccamerafpsscenenode.h - "ICursorControl.h" - "CCameraSceneNode.h" - "vector2d.h" - "SKeyMap.h" - "irrArray.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\icursorcontrol.h - "IReferenceCounted.h" - "position2d.h" - "rect.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ccamerascenenode.h - "ICameraSceneNode.h" - "SViewFrustum.h" - -1212214611 c:\development\irrlicht-1.4\irrlicht\include\sviewfrustum.h - "plane3d.h" - "vector3d.h" - "aabbox3d.h" - "matrix4.h" - "IVideoDriver.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\skeymap.h - "Keycodes.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ccamerafpsscenenode.h - "ICursorControl.h" - "CCameraSceneNode.h" - "vector2d.h" - "SKeyMap.h" - "irrArray.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ccameramayascenenode.cpp - "CCameraMayaSceneNode.h" - "IVideoDriver.h" - "ISceneManager.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ccameramayascenenode.h - "CCameraSceneNode.h" - "vector2d.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ccameramayascenenode.h - "CCameraSceneNode.h" - "vector2d.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ccamerascenenode.cpp - "CCameraSceneNode.h" - "ISceneManager.h" - "IVideoDriver.h" - "os.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ccamerascenenode.h - "ICameraSceneNode.h" - "SViewFrustum.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ccolladafileloader.cpp - "IrrCompileConfig.h" - "CColladaFileLoader.h" - "os.h" - "IXMLReader.h" - "IDummyTransformationSceneNode.h" - "SAnimatedMesh.h" - "fast_atof.h" - "quaternion.h" - "ILightSceneNode.h" - "ICameraSceneNode.h" - "IMeshManipulator.h" - "IReadFile.h" - "IAttributes.h" - "IMeshCache.h" - "IMeshSceneNode.h" - "SMeshBufferLightMap.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ccolladafileloader.h - "IMeshLoader.h" - "IFileSystem.h" - "IVideoDriver.h" - "irrString.h" - "SMesh.h" - "SMeshBuffer.h" - "ISceneManager.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\ilightscenenode.h - "ISceneNode.h" - "SLight.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\slight.h - "SColor.h" - -1212214609 c:\development\irrlicht-1.4\irrlicht\include\imeshscenenode.h - "ISceneNode.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ccolladafileloader.h - "IMeshLoader.h" - "IFileSystem.h" - "IVideoDriver.h" - "irrString.h" - "SMesh.h" - "SMeshBuffer.h" - "ISceneManager.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ccolladameshwriter.cpp - "IrrCompileConfig.h" - "CColladaMeshWriter.h" - "os.h" - "IFileSystem.h" - "IWriteFile.h" - "IXMLWriter.h" - "IMesh.h" - "IAttributes.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ccolladameshwriter.h - "IMeshWriter.h" - "S3DVertex.h" - "IVideoDriver.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\imeshwriter.h - "IReferenceCounted.h" - "EMeshWriterEnums.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\iwritefile.h - "IReferenceCounted.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ccolladameshwriter.h - "IMeshWriter.h" - "S3DVertex.h" - "IVideoDriver.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ccolorconverter.cpp - "CColorConverter.h" - "SColor.h" - "os.h" - "irrString.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ccolorconverter.h - "irrTypes.h" - "IImage.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ccolorconverter.h - "irrTypes.h" - "IImage.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ccubescenenode.cpp - "CCubeSceneNode.h" - "IVideoDriver.h" - "ISceneManager.h" - "S3DVertex.h" - "os.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ccubescenenode.h - "ISceneNode.h" - "SMeshBuffer.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ccubescenenode.h - "ISceneNode.h" - "SMeshBuffer.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cd3d8driver.cpp - "IrrCompileConfig.h" - "CD3D8Driver.h" - "os.h" - "S3DVertex.h" - "CD3D8Texture.h" - "CImage.h" - "CD3D8MaterialRenderer.h" - "CD3D8ShaderMaterialRenderer.h" - "CD3D8NormalMapRenderer.h" - "CD3D8ParallaxMapRenderer.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cd3d8driver.h - "IrrCompileConfig.h" - <windows.h> - <xtl.h> - "CNullDriver.h" - "IMaterialRendererServices.h" - <d3d8.h> - -1221910415 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cnulldriver.h - "IVideoDriver.h" - "IFileSystem.h" - "IImagePresenter.h" - "IGPUProgrammingServices.h" - "irrArray.h" - "irrString.h" - "IAttributes.h" - "IMeshBuffer.h" - "CFPSCounter.h" - "S3DVertex.h" - "SLight.h" - "SExposedVideoData.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\iimagepresenter.h - "IImage.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\igpuprogrammingservices.h - "IReferenceCounted.h" - "SMaterial.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cfpscounter.h - "irrTypes.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\sexposedvideodata.h - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\imaterialrendererservices.h - "IReferenceCounted.h" - "SMaterial.h" - "S3DVertex.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cd3d8texture.h - "IrrCompileConfig.h" - "ITexture.h" - "IImage.h" - <d3d8.h> - -1221578952 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimage.h - "IImage.h" - "rect.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cd3d8materialrenderer.h - "IrrCompileConfig.h" - <d3d8.h> - "IMaterialRenderer.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cd3d8shadermaterialrenderer.h - "IrrCompileConfig.h" - <d3d8.h> - <d3dx8core.h> - "IMaterialRenderer.h" - "S3DVertex.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cd3d8normalmaprenderer.h - "IrrCompileConfig.h" - <d3d8.h> - "CD3D8ShaderMaterialRenderer.h" - "IShaderConstantSetCallBack.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\ishaderconstantsetcallback.h - "IReferenceCounted.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cd3d8parallaxmaprenderer.h - "IrrCompileConfig.h" - <d3d8.h> - "CD3D8ShaderMaterialRenderer.h" - "IShaderConstantSetCallBack.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cd3d8driver.h - "IrrCompileConfig.h" - <windows.h> - <xtl.h> - "CNullDriver.h" - "IMaterialRendererServices.h" - <d3d8.h> - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cd3d8normalmaprenderer.cpp - "IrrCompileConfig.h" - "CD3D8NormalMapRenderer.h" - "IMaterialRendererServices.h" - "IVideoDriver.h" - "os.h" - "SLight.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cd3d8normalmaprenderer.h - "IrrCompileConfig.h" - <d3d8.h> - "CD3D8ShaderMaterialRenderer.h" - "IShaderConstantSetCallBack.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cd3d8parallaxmaprenderer.cpp - "IrrCompileConfig.h" - "CD3D8ParallaxMapRenderer.h" - "IMaterialRendererServices.h" - "IVideoDriver.h" - "os.h" - "SLight.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cd3d8parallaxmaprenderer.h - "IrrCompileConfig.h" - <d3d8.h> - "CD3D8ShaderMaterialRenderer.h" - "IShaderConstantSetCallBack.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cd3d8shadermaterialrenderer.cpp - "CD3D8ShaderMaterialRenderer.h" - "IrrCompileConfig.h" - <d3d8.h> - <d3dx8core.h> - "IShaderConstantSetCallBack.h" - "IMaterialRendererServices.h" - "IVideoDriver.h" - "os.h" - <stdio.h> - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cd3d8shadermaterialrenderer.h - "IrrCompileConfig.h" - <d3d8.h> - <d3dx8core.h> - "IMaterialRenderer.h" - "S3DVertex.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cd3d8texture.cpp - "IrrCompileConfig.h" - "CD3D8Texture.h" - "CD3D8Driver.h" - "os.h" - <d3dx8tex.h> - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cd3d8texture.h - "IrrCompileConfig.h" - "ITexture.h" - "IImage.h" - <d3d8.h> - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cd3d9driver.cpp - "CD3D9Driver.h" - "os.h" - "S3DVertex.h" - "CD3D9Texture.h" - "CImage.h" - "CD3D9MaterialRenderer.h" - "CD3D9ShaderMaterialRenderer.h" - "CD3D9NormalMapRenderer.h" - "CD3D9ParallaxMapRenderer.h" - "CD3D9HLSLMaterialRenderer.h" - <float.h> - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cd3d9driver.h - "IrrCompileConfig.h" - <windows.h> - "CNullDriver.h" - "IMaterialRendererServices.h" - <d3d9.h> - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cd3d9texture.h - "IrrCompileConfig.h" - "ITexture.h" - "IImage.h" - <d3d9.h> - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cd3d9materialrenderer.h - "IrrCompileConfig.h" - <d3d9.h> - "IMaterialRenderer.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cd3d9shadermaterialrenderer.h - "IrrCompileConfig.h" - <d3d9.h> - <d3dx9shader.h> - "IMaterialRenderer.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cd3d9normalmaprenderer.h - "IrrCompileConfig.h" - <d3d9.h> - "CD3D9ShaderMaterialRenderer.h" - "IShaderConstantSetCallBack.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cd3d9parallaxmaprenderer.h - "IrrCompileConfig.h" - <d3d9.h> - "CD3D9ShaderMaterialRenderer.h" - "IShaderConstantSetCallBack.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cd3d9hlslmaterialrenderer.h - "IrrCompileConfig.h" - "CD3D9ShaderMaterialRenderer.h" - "IGPUProgrammingServices.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cd3d9driver.h - "IrrCompileConfig.h" - <windows.h> - "CNullDriver.h" - "IMaterialRendererServices.h" - <d3d9.h> - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cd3d9hlslmaterialrenderer.cpp - "IrrCompileConfig.h" - "CD3D9HLSLMaterialRenderer.h" - "IShaderConstantSetCallBack.h" - "IVideoDriver.h" - "os.h" - "irrString.h" - <stdio.h> - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cd3d9hlslmaterialrenderer.h - "IrrCompileConfig.h" - "CD3D9ShaderMaterialRenderer.h" - "IGPUProgrammingServices.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cd3d9normalmaprenderer.cpp - "IrrCompileConfig.h" - "CD3D9NormalMapRenderer.h" - "IVideoDriver.h" - "IMaterialRendererServices.h" - "os.h" - "SLight.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cd3d9normalmaprenderer.h - "IrrCompileConfig.h" - <d3d9.h> - "CD3D9ShaderMaterialRenderer.h" - "IShaderConstantSetCallBack.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cd3d9parallaxmaprenderer.cpp - "IrrCompileConfig.h" - "CD3D9ParallaxMapRenderer.h" - "IMaterialRendererServices.h" - "IVideoDriver.h" - "os.h" - "SLight.h" - "CReadFile.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\creadfile.h - <stdio.h> - "IReadFile.h" - "irrString.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cd3d9parallaxmaprenderer.h - "IrrCompileConfig.h" - <d3d9.h> - "CD3D9ShaderMaterialRenderer.h" - "IShaderConstantSetCallBack.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cd3d9shadermaterialrenderer.cpp - "IrrCompileConfig.h" - "CD3D9ShaderMaterialRenderer.h" - "IShaderConstantSetCallBack.h" - "IMaterialRendererServices.h" - "IVideoDriver.h" - "os.h" - "irrString.h" - <stdio.h> - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cd3d9shadermaterialrenderer.h - "IrrCompileConfig.h" - <d3d9.h> - <d3dx9shader.h> - "IMaterialRenderer.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cd3d9texture.cpp - "IrrCompileConfig.h" - "CD3D9Texture.h" - "CD3D9Driver.h" - "os.h" - <d3dx9tex.h> - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cd3d9texture.h - "IrrCompileConfig.h" - "ITexture.h" - "IImage.h" - <d3d9.h> - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cdmfloader.cpp - "IrrCompileConfig.h" - "CDMFLoader.h" - "ISceneManager.h" - "IAttributes.h" - "SAnimatedMesh.h" - "SMeshBufferLightMap.h" - "irrString.h" - "irrMath.h" - "dmfsupport.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cdmfloader.h - "IMeshLoader.h" - "IReadFile.h" - "SMesh.h" - "IVideoDriver.h" - "ISceneManager.h" - "SAnimatedMesh.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\dmfsupport.h - "irrString.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cdmfloader.h - "IMeshLoader.h" - "IReadFile.h" - "SMesh.h" - "IVideoDriver.h" - "ISceneManager.h" - "SAnimatedMesh.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cdefaultguielementfactory.cpp - "CDefaultGUIElementFactory.h" - "IGUIEnvironment.h" - "IGUIButton.h" - "IGUICheckBox.h" - "IGUIComboBox.h" - "IGUIContextMenu.h" - "IGUIEditBox.h" - "IGUISpinBox.h" - "IGUIFileOpenDialog.h" - "IGUIColorSelectDialog.h" - "IGUIInOutFader.h" - "IGUIImage.h" - "IGUIListBox.h" - "IGUIMeshViewer.h" - "IGUIScrollBar.h" - "IGUIStaticText.h" - "IGUITabControl.h" - "IGUIToolbar.h" - "IGUIWindow.h" - <string.h> - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cdefaultguielementfactory.h - "IrrCompileConfig.h" - "IGUIElementFactory.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\iguielementfactory.h - "IReferenceCounted.h" - "EGUIElementTypes.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\eguielementtypes.h - "irrTypes.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\iguienvironment.h - "IReferenceCounted.h" - "IGUISkin.h" - "rect.h" - "EMessageBoxFlags.h" - "IEventReceiver.h" - "IXMLReader.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\iguiskin.h - "IAttributeExchangingObject.h" - "SColor.h" - "rect.h" - -1212214609 c:\development\irrlicht-1.4\irrlicht\include\emessageboxflags.h - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\iguibutton.h - "IGUIElement.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\iguielement.h - "IAttributeExchangingObject.h" - "irrList.h" - "rect.h" - "irrString.h" - "IEventReceiver.h" - "EGUIElementTypes.h" - "IAttributes.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\iguicheckbox.h - "IGUIElement.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\iguicombobox.h - "IGUIElement.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\iguicontextmenu.h - "IGUIElement.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\iguieditbox.h - "IGUIElement.h" - "SColor.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\iguispinbox.h - "IGUIElement.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\iguifileopendialog.h - "IGUIElement.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\iguicolorselectdialog.h - "IGUIElement.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\iguiinoutfader.h - "IGUIElement.h" - "SColor.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\iguiimage.h - "IGUIElement.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\iguilistbox.h - "IGUIElement.h" - "SColor.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\iguimeshviewer.h - "IGUIElement.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\iguiscrollbar.h - "IGUIElement.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\iguistatictext.h - "IGUIElement.h" - "SColor.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\iguitabcontrol.h - "IGUIElement.h" - "SColor.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\iguitoolbar.h - "IGUIElement.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\iguiwindow.h - "IGUIElement.h" - "EMessageBoxFlags.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cdefaultguielementfactory.h - "IrrCompileConfig.h" - "IGUIElementFactory.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cdefaultscenenodeanimatorfactory.cpp - "CDefaultSceneNodeAnimatorFactory.h" - "ISceneNodeAnimatorCollisionResponse.h" - "ISceneManager.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cdefaultscenenodeanimatorfactory.h - "ISceneNodeAnimatorFactory.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\iscenenodeanimatorfactory.h - "IReferenceCounted.h" - "ESceneNodeAnimatorTypes.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\iscenenodeanimatorcollisionresponse.h - "ISceneNode.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cdefaultscenenodeanimatorfactory.h - "ISceneNodeAnimatorFactory.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cdefaultscenenodefactory.cpp - "CDefaultSceneNodeFactory.h" - "ISceneManager.h" - "ITextSceneNode.h" - "ITerrainSceneNode.h" - "IDummyTransformationSceneNode.h" - "ICameraSceneNode.h" - "IBillboardSceneNode.h" - "IAnimatedMeshSceneNode.h" - "IParticleSystemSceneNode.h" - "ILightSceneNode.h" - "IMeshSceneNode.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cdefaultscenenodefactory.h - "ISceneNodeFactory.h" - "irrArray.h" - "irrString.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\iscenenodefactory.h - "IReferenceCounted.h" - "ESceneNodeTypes.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\itextscenenode.h - "ISceneNode.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\iterrainscenenode.h - "ETerrainElements.h" - "ISceneNode.h" - "SMeshBufferLightMap.h" - "irrArray.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\iparticlesystemscenenode.h - "ISceneNode.h" - "IParticleAnimatedMeshSceneNodeEmitter.h" - "IParticleBoxEmitter.h" - "IParticleCylinderEmitter.h" - "IParticleMeshEmitter.h" - "IParticleRingEmitter.h" - "IParticleSphereEmitter.h" - "IParticleAttractionAffector.h" - "IParticleFadeOutAffector.h" - "IParticleGravityAffector.h" - "IParticleRotationAffector.h" - "dimension2d.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\iparticleanimatedmeshscenenodeemitter.h - "IParticleEmitter.h" - "IAnimatedMeshSceneNode.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\iparticleemitter.h - "IAttributeExchangingObject.h" - "SParticle.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\sparticle.h - "vector3d.h" - "SColor.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\iparticleboxemitter.h - "IParticleEmitter.h" - "aabbox3d.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\iparticlecylinderemitter.h - "IParticleEmitter.h" - -1212214611 c:\development\irrlicht-1.4\irrlicht\include\iparticlemeshemitter.h - "IParticleEmitter.h" - "IMesh.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\iparticleringemitter.h - "IParticleEmitter.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\iparticlesphereemitter.h - "IParticleEmitter.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\iparticleattractionaffector.h - "IParticleAffector.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\iparticleaffector.h - "IAttributeExchangingObject.h" - "SParticle.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\iparticlefadeoutaffector.h - "IParticleAffector.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\iparticlegravityaffector.h - "IParticleAffector.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\iparticlerotationaffector.h - "IParticleAffector.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cdefaultscenenodefactory.h - "ISceneNodeFactory.h" - "irrArray.h" - "irrString.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cdepthbuffer.cpp - "IrrCompileConfig.h" - "SoftwareDriver2_compile_config.h" - "CDepthBuffer.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\softwaredriver2_compile_config.h - "IrrCompileConfig.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cdepthbuffer.h - "IDepthBuffer.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\idepthbuffer.h - "IReferenceCounted.h" - "dimension2d.h" - "S4DVertex.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\s4dvertex.h - "SoftwareDriver2_compile_config.h" - "SoftwareDriver2_helper.h" - "irrAllocator.h" - -1221578952 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\softwaredriver2_helper.h - "SoftwareDriver2_compile_config.h" - "irrMath.h" - "CSoftwareTexture2.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\csoftwaretexture2.h - "SoftwareDriver2_compile_config.h" - "ITexture.h" - "CImage.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cdepthbuffer.h - "IDepthBuffer.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cdummytransformationscenenode.cpp - "CDummyTransformationSceneNode.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cdummytransformationscenenode.h - "IDummyTransformationSceneNode.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cdummytransformationscenenode.h - "IDummyTransformationSceneNode.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cemptyscenenode.cpp - "CEmptySceneNode.h" - "ISceneManager.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cemptyscenenode.h - "ISceneNode.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cemptyscenenode.h - "ISceneNode.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cfpscounter.cpp - "CFPSCounter.h" - "irrMath.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cfpscounter.h - "irrTypes.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cfilelist.cpp - "CFileList.h" - "IrrCompileConfig.h" - "irrArray.h" - <stdlib.h> - <stdio.h> - <stdlib.h> - <string.h> - <sys/types.h> - <dirent.h> - <sys/stat.h> - <unistd.h> - <io.h> - <direct.h> - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cfilelist.h - "IFileList.h" - "irrString.h" - "irrArray.h" - -1212214611 c:\development\irrlicht-1.4\irrlicht\include\ifilelist.h - "IReferenceCounted.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cfilelist.h - "IFileList.h" - "irrString.h" - "irrArray.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cfilesystem.cpp - "CFileSystem.h" - "IReadFile.h" - "IWriteFile.h" - "CZipReader.h" - "CPakReader.h" - "CFileList.h" - "CXMLReader.h" - "CXMLWriter.h" - "stdio.h" - "os.h" - "IrrCompileConfig.h" - "CAttributes.h" - "CMemoryReadFile.h" - <direct.h> - <unistd.h> - <limits.h> - <stdlib.h> - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cfilesystem.h - "IFileSystem.h" - "irrArray.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\czipreader.h - "IReferenceCounted.h" - "IReadFile.h" - "irrArray.h" - "irrString.h" - "IFileSystem.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cpakreader.h - "IReferenceCounted.h" - "IReadFile.h" - "irrArray.h" - "irrString.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cxmlreader.h - "IXMLReader.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cxmlwriter.h - <wchar.h> - "IXMLWriter.h" - "IWriteFile.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cmemoryreadfile.h - "IReadFile.h" - "irrString.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cfilesystem.h - "IFileSystem.h" - "irrArray.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguibutton.cpp - "CGUIButton.h" - "IGUISkin.h" - "IGUIEnvironment.h" - "IVideoDriver.h" - "IGUIFont.h" - "os.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguibutton.h - "IrrCompileConfig.h" - "IGUIButton.h" - "IGUISpriteBank.h" - "SColor.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\iguispritebank.h - "IReferenceCounted.h" - "irrArray.h" - "SColor.h" - "rect.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\iguifont.h - "IReferenceCounted.h" - "SColor.h" - "rect.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguibutton.h - "IrrCompileConfig.h" - "IGUIButton.h" - "IGUISpriteBank.h" - "SColor.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguicheckbox.cpp - "CGUICheckBox.h" - "IGUISkin.h" - "IGUIEnvironment.h" - "IVideoDriver.h" - "IGUIFont.h" - "os.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguicheckbox.h - "IrrCompileConfig.h" - "IGUICheckBox.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguicheckbox.h - "IrrCompileConfig.h" - "IGUICheckBox.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguicolorselectdialog.cpp - "CGUIColorSelectDialog.h" - "IGUISkin.h" - "IGUIEnvironment.h" - "IVideoDriver.h" - "IGUIButton.h" - "IGUIStaticText.h" - "IGUIFont.h" - "IGUISpriteBank.h" - "IFileList.h" - "os.h" - "SoftwareDriver2_helper.h" - "CImage.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguicolorselectdialog.h - "IrrCompileConfig.h" - "IGUIColorSelectDialog.h" - "IGUIButton.h" - "IGUIEditBox.h" - "IGUIScrollBar.h" - "IGUIImage.h" - "irrArray.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguicolorselectdialog.h - "IrrCompileConfig.h" - "IGUIColorSelectDialog.h" - "IGUIButton.h" - "IGUIEditBox.h" - "IGUIScrollBar.h" - "IGUIImage.h" - "irrArray.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguicombobox.cpp - "CGUIComboBox.h" - "IGUIEnvironment.h" - "IVideoDriver.h" - "IGUISkin.h" - "IGUIEnvironment.h" - "IGUIFont.h" - "IGUIButton.h" - "CGUIListBox.h" - "os.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguicombobox.h - "IrrCompileConfig.h" - "IGUIComboBox.h" - "irrString.h" - "irrArray.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguilistbox.h - "IrrCompileConfig.h" - "IGUIListBox.h" - "irrArray.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguicombobox.h - "IrrCompileConfig.h" - "IGUIComboBox.h" - "irrString.h" - "irrArray.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguicontextmenu.cpp - "CGUIContextMenu.h" - "IGUISkin.h" - "IGUIEnvironment.h" - "IVideoDriver.h" - "IGUIFont.h" - "IGUISpriteBank.h" - "os.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguicontextmenu.h - "IrrCompileConfig.h" - "IGUIContextMenu.h" - "irrString.h" - "irrArray.h" - "IGUIFont.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguicontextmenu.h - "IrrCompileConfig.h" - "IGUIContextMenu.h" - "irrString.h" - "irrArray.h" - "IGUIFont.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguieditbox.cpp - "CGUIEditBox.h" - "IGUISkin.h" - "IGUIEnvironment.h" - "IGUIFont.h" - "IVideoDriver.h" - "rect.h" - "os.h" - "Keycodes.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguieditbox.h - "IrrCompileConfig.h" - "IGUIEditBox.h" - "irrArray.h" - "IOSOperator.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\iosoperator.h - "IReferenceCounted.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguieditbox.h - "IrrCompileConfig.h" - "IGUIEditBox.h" - "irrArray.h" - "IOSOperator.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguienvironment.cpp - "CGUIEnvironment.h" - "IVideoDriver.h" - "CGUISkin.h" - "CGUIButton.h" - "CGUIWindow.h" - "CGUIScrollBar.h" - "CGUIFont.h" - "CGUISpriteBank.h" - "CGUIImage.h" - "CGUIMeshViewer.h" - "CGUICheckBox.h" - "CGUIListBox.h" - "CGUIFileOpenDialog.h" - "CGUIColorSelectDialog.h" - "CGUIStaticText.h" - "CGUIEditBox.h" - "CGUISpinBox.h" - "CGUIInOutFader.h" - "CGUIMessageBox.h" - "CGUIModalScreen.h" - "CGUITabControl.h" - "CGUIContextMenu.h" - "CGUIComboBox.h" - "CGUIMenu.h" - "CGUIToolBar.h" - "CDefaultGUIElementFactory.h" - "IWriteFile.h" - "IXMLWriter.h" - "BuiltInFont.h" - "os.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguienvironment.h - "IrrCompileConfig.h" - "IGUIEnvironment.h" - "IGUIElement.h" - "irrArray.h" - "IFileSystem.h" - "IOSOperator.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguiskin.h - "IrrCompileConfig.h" - "IGUISkin.h" - "irrString.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguiwindow.h - "IrrCompileConfig.h" - "IGUIWindow.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguiscrollbar.h - "IrrCompileConfig.h" - "IGUIScrollBar.h" - "IGUIButton.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguifont.h - "IrrCompileConfig.h" - "IGUIFontBitmap.h" - "irrString.h" - "irrMap.h" - "IXMLReader.h" - "IReadFile.h" - "irrArray.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\iguifontbitmap.h - "IGUIFont.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\irrmap.h - "irrTypes.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguispritebank.h - "IrrCompileConfig.h" - "IGUISpriteBank.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguiimage.h - "IrrCompileConfig.h" - "IGUIImage.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguimeshviewer.h - "IrrCompileConfig.h" - "IGUIMeshViewer.h" - "SMaterial.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguifileopendialog.h - "IrrCompileConfig.h" - "IGUIFileOpenDialog.h" - "IGUIButton.h" - "IGUIListBox.h" - "IFileSystem.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguistatictext.h - "IrrCompileConfig.h" - "IGUIStaticText.h" - "irrArray.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguispinbox.h - "IrrCompileConfig.h" - "IGUISpinBox.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguiinoutfader.h - "IrrCompileConfig.h" - "IGUIInOutFader.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguimessagebox.h - "IrrCompileConfig.h" - "CGUIWindow.h" - "IGUIStaticText.h" - "irrArray.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguimodalscreen.h - "IrrCompileConfig.h" - "IGUIElement.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguitabcontrol.h - "IrrCompileConfig.h" - "IGUITabControl.h" - "irrArray.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguimenu.h - "IrrCompileConfig.h" - "CGUIContextMenu.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguitoolbar.h - "IrrCompileConfig.h" - "IGUIToolbar.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\builtinfont.h - "IrrCompileConfig.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguienvironment.h - "IrrCompileConfig.h" - "IGUIEnvironment.h" - "IGUIElement.h" - "irrArray.h" - "IFileSystem.h" - "IOSOperator.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguifileopendialog.cpp - "CGUIFileOpenDialog.h" - "IGUISkin.h" - "IGUIEnvironment.h" - "IVideoDriver.h" - "IGUIButton.h" - "IGUIStaticText.h" - "IGUIFont.h" - "IGUIFontBitmap.h" - "IFileList.h" - "os.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguifileopendialog.h - "IrrCompileConfig.h" - "IGUIFileOpenDialog.h" - "IGUIButton.h" - "IGUIListBox.h" - "IFileSystem.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguifont.cpp - "CGUIFont.h" - "os.h" - "IGUIEnvironment.h" - "IXMLReader.h" - "IReadFile.h" - "IVideoDriver.h" - "IGUISpriteBank.h" - "CImage.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguifont.h - "IrrCompileConfig.h" - "IGUIFontBitmap.h" - "irrString.h" - "irrMap.h" - "IXMLReader.h" - "IReadFile.h" - "irrArray.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguiimage.cpp - "CGUIImage.h" - "IGUISkin.h" - "IGUIEnvironment.h" - "IVideoDriver.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguiimage.h - "IrrCompileConfig.h" - "IGUIImage.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguiinoutfader.cpp - "CGUIInOutFader.h" - "IGUIEnvironment.h" - "IVideoDriver.h" - "os.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguiinoutfader.h - "IrrCompileConfig.h" - "IGUIInOutFader.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguilistbox.cpp - "CGUIListBox.h" - "CGUIListBox.h" - "IGUISkin.h" - "IGUIEnvironment.h" - "IVideoDriver.h" - "IGUIFont.h" - "IGUISpriteBank.h" - "CGUIScrollBar.h" - "os.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguilistbox.h - "IrrCompileConfig.h" - "IGUIListBox.h" - "irrArray.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguimenu.cpp - "CGUIMenu.h" - "IGUISkin.h" - "IGUIEnvironment.h" - "IVideoDriver.h" - "IGUIFont.h" - "os.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguimenu.h - "IrrCompileConfig.h" - "CGUIContextMenu.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguimeshviewer.cpp - "CGUIMeshViewer.h" - "IGUIEnvironment.h" - "IVideoDriver.h" - "IAnimatedMesh.h" - "IMesh.h" - "os.h" - "IGUISkin.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguimeshviewer.h - "IrrCompileConfig.h" - "IGUIMeshViewer.h" - "SMaterial.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguimessagebox.cpp - "CGUIMessageBox.h" - "IGUISkin.h" - "IGUIEnvironment.h" - "IGUIButton.h" - "IGUIFont.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguimessagebox.h - "IrrCompileConfig.h" - "CGUIWindow.h" - "IGUIStaticText.h" - "irrArray.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguimodalscreen.cpp - "CGUIModalScreen.h" - "IGUIEnvironment.h" - "os.h" - "IVideoDriver.h" - "IGUISkin.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguimodalscreen.h - "IrrCompileConfig.h" - "IGUIElement.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguiscrollbar.cpp - "CGUIScrollBar.h" - "IGUISkin.h" - "IGUIEnvironment.h" - "IVideoDriver.h" - "CGUIButton.h" - "IGUIFont.h" - "IGUIFontBitmap.h" - "os.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguiscrollbar.h - "IrrCompileConfig.h" - "IGUIScrollBar.h" - "IGUIButton.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguiskin.cpp - "CGUISkin.h" - "IGUIFont.h" - "IGUISpriteBank.h" - "IVideoDriver.h" - "IAttributes.h" - "SoftwareDriver2_helper.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguiskin.h - "IrrCompileConfig.h" - "IGUISkin.h" - "irrString.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguispinbox.cpp - "CGUISpinBox.h" - "CGUIEditBox.h" - "CGUIButton.h" - "IGUIEnvironment.h" - "IEventReceiver.h" - "fast_atof.h" - <float.h> - <wchar.h> - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguispinbox.h - "IrrCompileConfig.h" - "IGUISpinBox.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguispritebank.cpp - "CGUISpriteBank.h" - "IGUIEnvironment.h" - "IVideoDriver.h" - "ITexture.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguispritebank.h - "IrrCompileConfig.h" - "IGUISpriteBank.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguistatictext.cpp - "CGUIStaticText.h" - "IGUISkin.h" - "IGUIEnvironment.h" - "IGUIFont.h" - "IVideoDriver.h" - "rect.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguistatictext.h - "IrrCompileConfig.h" - "IGUIStaticText.h" - "irrArray.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguitabcontrol.cpp - "CGUITabControl.h" - "IGUISkin.h" - "IGUIEnvironment.h" - "IGUIFont.h" - "IVideoDriver.h" - "rect.h" - "os.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguitabcontrol.h - "IrrCompileConfig.h" - "IGUITabControl.h" - "irrArray.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguitoolbar.cpp - "CGUIToolBar.h" - "IGUISkin.h" - "IGUIEnvironment.h" - "IVideoDriver.h" - "IGUIButton.h" - "IGUIFont.h" - "CGUIButton.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguitoolbar.h - "IrrCompileConfig.h" - "IGUIToolbar.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguiwindow.cpp - "CGUIWindow.h" - "IGUISkin.h" - "IGUIEnvironment.h" - "IVideoDriver.h" - "IGUIButton.h" - "IGUIFont.h" - "IGUIFontBitmap.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cguiwindow.h - "IrrCompileConfig.h" - "IGUIWindow.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cgeometrycreator.cpp - "CGeometryCreator.h" - "SAnimatedMesh.h" - "SMeshBuffer.h" - "SMesh.h" - "IVideoDriver.h" - "CImage.h" - "os.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cgeometrycreator.h - "IMesh.h" - "IImage.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cgeometrycreator.h - "IMesh.h" - "IImage.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimage.cpp - "CImage.h" - "irrString.h" - "SoftwareDriver2_helper.h" - "CColorConverter.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimage.h - "IImage.h" - "rect.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimageloaderbmp.cpp - "CImageLoaderBMP.h" - "IReadFile.h" - "SColor.h" - "CColorConverter.h" - "CImage.h" - "os.h" - "irrString.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimageloaderbmp.h - "IrrCompileConfig.h" - "IImageLoader.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\iimageloader.h - "IReferenceCounted.h" - "IImage.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimageloaderbmp.h - "IrrCompileConfig.h" - "IImageLoader.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimageloaderjpg.cpp - "CImageLoaderJPG.h" - "IReadFile.h" - "CImage.h" - "os.h" - "irrString.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimageloaderjpg.h - "IrrCompileConfig.h" - "IImageLoader.h" - <stdio.h> - <jpeglib.h> - "jpeglib/jpeglib.h" - <setjmp.h> - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimageloaderjpg.h - "IrrCompileConfig.h" - "IImageLoader.h" - <stdio.h> - <jpeglib.h> - "jpeglib/jpeglib.h" - <setjmp.h> - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimageloaderpcx.cpp - "CImageLoaderPCX.h" - "IReadFile.h" - "SColor.h" - "CColorConverter.h" - "CImage.h" - "os.h" - "irrString.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimageloaderpcx.h - "IrrCompileConfig.h" - "IImageLoader.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimageloaderpcx.h - "IrrCompileConfig.h" - "IImageLoader.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimageloaderpng.cpp - "CImageLoaderPNG.h" - <png.h> - "libpng/png.h" - "CImage.h" - "CReadFile.h" - "os.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimageloaderpng.h - "IrrCompileConfig.h" - "IImageLoader.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimageloaderpng.h - "IrrCompileConfig.h" - "IImageLoader.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimageloaderppm.cpp - "CImageLoaderPPM.h" - "IReadFile.h" - "CColorConverter.h" - "CImage.h" - "os.h" - "fast_atof.h" - "coreutil.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimageloaderppm.h - "IrrCompileConfig.h" - "IImageLoader.h" - "irrString.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimageloaderppm.h - "IrrCompileConfig.h" - "IImageLoader.h" - "irrString.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimageloaderpsd.cpp - "CImageLoaderPSD.h" - "IReadFile.h" - "os.h" - "CImage.h" - "irrString.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimageloaderpsd.h - "IrrCompileConfig.h" - "IImageLoader.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimageloaderpsd.h - "IrrCompileConfig.h" - "IImageLoader.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimageloadertga.cpp - "CImageLoaderTGA.h" - "IReadFile.h" - "os.h" - "CColorConverter.h" - "CImage.h" - "irrString.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimageloadertga.h - "IrrCompileConfig.h" - "IImageLoader.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimageloadertga.h - "IrrCompileConfig.h" - "IImageLoader.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimagewriterbmp.cpp - "CImageWriterBMP.h" - "CImageLoaderBMP.h" - "IWriteFile.h" - "CColorConverter.h" - "irrString.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimagewriterbmp.h - "IrrCompileConfig.h" - "IImageWriter.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\iimagewriter.h - "IReferenceCounted.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimagewriterbmp.h - "IrrCompileConfig.h" - "IImageWriter.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimagewriterjpg.cpp - "CImageWriterJPG.h" - "CColorConverter.h" - "IWriteFile.h" - "CImage.h" - "irrString.h" - <stdio.h> - <jpeglib.h> - <jerror.h> - "jpeglib/jpeglib.h" - "jpeglib/jerror.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimagewriterjpg.h - "IrrCompileConfig.h" - "IImageWriter.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimagewriterjpg.h - "IrrCompileConfig.h" - "IImageWriter.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimagewriterpcx.cpp - "CImageWriterPCX.h" - "CImageLoaderPCX.h" - "IWriteFile.h" - "os.h" - "irrString.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimagewriterpcx.h - "IrrCompileConfig.h" - "IImageWriter.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimagewriterpcx.h - "IrrCompileConfig.h" - "IImageWriter.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimagewriterpng.cpp - "CImageWriterPNG.h" - "CImageLoaderPNG.h" - "CColorConverter.h" - "IWriteFile.h" - "irrString.h" - "os.h" - <png.h> - "libpng/png.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimagewriterpng.h - "IrrCompileConfig.h" - "IImageWriter.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimagewriterpng.h - "IrrCompileConfig.h" - "IImageWriter.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimagewriterppm.cpp - "CImageWriterPPM.h" - "IWriteFile.h" - "IImage.h" - "dimension2d.h" - "irrString.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimagewriterppm.h - "IrrCompileConfig.h" - "IImageWriter.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimagewriterppm.h - "IrrCompileConfig.h" - "IImageWriter.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimagewriterpsd.cpp - "CImageWriterPSD.h" - "CImageLoaderPSD.h" - "IWriteFile.h" - "os.h" - "irrString.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimagewriterpsd.h - "IrrCompileConfig.h" - "IImageWriter.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimagewriterpsd.h - "IrrCompileConfig.h" - "IImageWriter.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimagewritertga.cpp - "CImageWriterTGA.h" - "CImageLoaderTGA.h" - "IWriteFile.h" - "CColorConverter.h" - "irrString.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimagewritertga.h - "IrrCompileConfig.h" - "IImageWriter.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cimagewritertga.h - "IrrCompileConfig.h" - "IImageWriter.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cirrdevicelinux.cpp - "CIrrDeviceLinux.h" - <stdio.h> - <stdlib.h> - <sys/utsname.h> - <time.h> - "IEventReceiver.h" - "os.h" - "CTimer.h" - "irrString.h" - "Keycodes.h" - "COSOperator.h" - "CColorConverter.h" - "SIrrCreationParameters.h" - <X11/XKBlib.h> - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cirrdevicelinux.h - "IrrCompileConfig.h" - "CIrrDeviceStub.h" - "IrrlichtDevice.h" - "IImagePresenter.h" - "ICursorControl.h" - <GL/gl.h> - <GL/glx.h> - "glxext.h" - <X11/Xlib.h> - <X11/Xutil.h> - <X11/extensions/xf86vmode.h> - <X11/extensions/Xrandr.h> - <X11/keysym.h> - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cirrdevicestub.h - "IrrlichtDevice.h" - "IImagePresenter.h" - "CVideoModeList.h" - -1221578959 c:\development\irrlicht-1.4\irrlicht\include\irrlichtdevice.h - "IReferenceCounted.h" - "dimension2d.h" - "IVideoDriver.h" - "EDriverTypes.h" - "IEventReceiver.h" - "ICursorControl.h" - "IVideoModeList.h" - "ITimer.h" - "IOSOperator.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\ivideomodelist.h - "IReferenceCounted.h" - "dimension2d.h" - -1212214609 c:\development\irrlicht-1.4\irrlicht\include\itimer.h - "IReferenceCounted.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cvideomodelist.h - "IVideoModeList.h" - "dimension2d.h" - "irrArray.h" - -1195285115 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\glxext.h - <windows.h> - <inttypes.h> - <inttypes.h> - <inttypes.h> - <stdint.h> - <stdint.h> - <inttypes.h> - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctimer.h - "ITimer.h" - "os.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cosoperator.h - "IOSOperator.h" - "irrString.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\sirrcreationparameters.h - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cirrdevicelinux.h - "IrrCompileConfig.h" - "CIrrDeviceStub.h" - "IrrlichtDevice.h" - "IImagePresenter.h" - "ICursorControl.h" - <GL/gl.h> - <GL/glx.h> - "glxext.h" - <X11/Xlib.h> - <X11/Xutil.h> - <X11/extensions/xf86vmode.h> - <X11/extensions/Xrandr.h> - <X11/keysym.h> - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cirrdevicestub.cpp - "CIrrDeviceStub.h" - "ISceneManager.h" - "IEventReceiver.h" - "IFileSystem.h" - "IGUIEnvironment.h" - "os.h" - "IrrCompileConfig.h" - "CTimer.h" - "CLogger.h" - "irrString.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\clogger.h - "ILogger.h" - "os.h" - "irrString.h" - "IEventReceiver.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cirrdevicestub.h - "IrrlichtDevice.h" - "IImagePresenter.h" - "CVideoModeList.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cirrdevicewin32.cpp - "IrrCompileConfig.h" - "CIrrDeviceWin32.h" - "IEventReceiver.h" - "irrList.h" - "os.h" - "CTimer.h" - "irrString.h" - "COSOperator.h" - "dimension2d.h" - <winuser.h> - "irrlicht.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cirrdevicewin32.h - "IrrCompileConfig.h" - "CIrrDeviceStub.h" - "IrrlichtDevice.h" - "IImagePresenter.h" - <windows.h> - -1221911308 c:\development\irrlicht-1.4\irrlicht\include\irrlicht.h - "IrrCompileConfig.h" - "aabbox3d.h" - "coreutil.h" - "irrArray.h" - "irrMap.h" - "irrMath.h" - "irrString.h" - "irrTypes.h" - "SColor.h" - "SLight.h" - "dimension2d.h" - "EDriverTypes.h" - "IAttributes.h" - "IAttributeExchangingObject.h" - "IAnimatedMesh.h" - "IAnimatedMeshMD2.h" - "IAnimatedMeshMD3.h" - "IQ3LevelMesh.h" - "IAnimatedMeshSceneNode.h" - "IBillboardSceneNode.h" - "IBoneSceneNode.h" - "ICameraSceneNode.h" - "IDummyTransformationSceneNode.h" - "IEventReceiver.h" - "IFileList.h" - "IFileSystem.h" - "IGPUProgrammingServices.h" - "IGUIButton.h" - "IGUICheckBox.h" - "IGUIColorSelectDialog.h" - "IGUIComboBox.h" - "IGUIContextMenu.h" - "IGUIEditBox.h" - "IGUIElement.h" - "IGUIElementFactory.h" - "IGUIEnvironment.h" - "IGUIFileOpenDialog.h" - "IGUIFont.h" - "IGUIFontBitmap.h" - "IGUIImage.h" - "IGUIInOutFader.h" - "IGUIListBox.h" - "IGUIMeshViewer.h" - "IGUIScrollBar.h" - "IGUISkin.h" - "IGUISpinBox.h" - "IGUISpriteBank.h" - "IGUIStaticText.h" - "IGUITabControl.h" - "IGUIToolbar.h" - "IGUIWindow.h" - "IImage.h" - "ILightSceneNode.h" - "ILogger.h" - "IMaterialRenderer.h" - "IMaterialRendererServices.h" - "IMesh.h" - "IMeshBuffer.h" - "IMeshCache.h" - "IMeshSceneNode.h" - "IMeshManipulator.h" - "IMeshWriter.h" - "IMetaTriangleSelector.h" - "IReadFile.h" - "IrrlichtDevice.h" - "ISceneManager.h" - "ISceneNode.h" - "ISceneUserDataSerializer.h" - "ITriangleSelector.h" - "ISceneNodeAnimator.h" - "ISceneCollisionManager.h" - "ISceneNodeFactory.h" - "ISceneNodeAnimatorFactory.h" - "ISceneNodeAnimatorCollisionResponse.h" - "IShaderConstantSetCallBack.h" - "IShadowVolumeSceneNode.h" - "IParticleSystemSceneNode.h" - "ISkinnedMesh.h" - "ITerrainSceneNode.h" - "ITextSceneNode.h" - "ITexture.h" - "IReferenceCounted.h" - "IVideoDriver.h" - "IVideoModeList.h" - "IWriteFile.h" - "IXMLReader.h" - "IXMLWriter.h" - "Keycodes.h" - "line2d.h" - "line3d.h" - "irrList.h" - "matrix4.h" - "plane3d.h" - "vector2d.h" - "vector3d.h" - "triangle3d.h" - "position2d.h" - "quaternion.h" - "rect.h" - "S3DVertex.h" - "SAnimatedMesh.h" - "SExposedVideoData.h" - "SKeyMap.h" - "SMaterial.h" - "SMesh.h" - "SMeshBuffer.h" - "SMeshBufferLightMap.h" - "SMeshBufferTangents.h" - "SViewFrustum.h" - "SIrrCreationParameters.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\imetatriangleselector.h - "ITriangleSelector.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\isceneuserdataserializer.h - "IReferenceCounted.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\iscenecollisionmanager.h - "IReferenceCounted.h" - "vector3d.h" - "triangle3d.h" - "position2d.h" - "line3d.h" - -1212214612 c:\development\irrlicht-1.4\irrlicht\include\smeshbuffertangents.h - "CMeshBuffer.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cirrdevicewin32.h - "IrrCompileConfig.h" - "CIrrDeviceStub.h" - "IrrlichtDevice.h" - "IImagePresenter.h" - <windows.h> - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cirrmeshfileloader.cpp - "IrrCompileConfig.h" - "CIrrMeshFileLoader.h" - "os.h" - "IXMLReader.h" - "SAnimatedMesh.h" - "fast_atof.h" - "IReadFile.h" - "IAttributes.h" - "IMeshSceneNode.h" - "SMeshBufferLightMap.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cirrmeshfileloader.h - "IMeshLoader.h" - "IFileSystem.h" - "IVideoDriver.h" - "irrString.h" - "SMesh.h" - "SMeshBuffer.h" - "ISceneManager.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cirrmeshfileloader.h - "IMeshLoader.h" - "IFileSystem.h" - "IVideoDriver.h" - "irrString.h" - "SMesh.h" - "SMeshBuffer.h" - "ISceneManager.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cirrmeshwriter.cpp - "IrrCompileConfig.h" - "CIrrMeshWriter.h" - "os.h" - "IWriteFile.h" - "IXMLWriter.h" - "IMesh.h" - "IAttributes.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cirrmeshwriter.h - "IMeshWriter.h" - "S3DVertex.h" - "IVideoDriver.h" - "IFileSystem.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cirrmeshwriter.h - "IMeshWriter.h" - "S3DVertex.h" - "IVideoDriver.h" - "IFileSystem.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\clmtsmeshfileloader.cpp - "IrrCompileConfig.h" - "SMeshBufferLightMap.h" - "SAnimatedMesh.h" - "SMeshBuffer.h" - "irrString.h" - "IReadFile.h" - "IAttributes.h" - "ISceneManager.h" - "CLMTSMeshFileLoader.h" - "os.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\clmtsmeshfileloader.h - "IMeshLoader.h" - "SMesh.h" - "IFileSystem.h" - "IVideoDriver.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\clmtsmeshfileloader.h - "IMeshLoader.h" - "SMesh.h" - "IFileSystem.h" - "IVideoDriver.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\clightscenenode.cpp - "CLightSceneNode.h" - "IVideoDriver.h" - "ISceneManager.h" - "ICameraSceneNode.h" - "os.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\clightscenenode.h - "ILightSceneNode.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\clightscenenode.h - "ILightSceneNode.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\climitreadfile.cpp - "CLimitReadFile.h" - "irrString.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\climitreadfile.h - "IReadFile.h" - "irrString.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\climitreadfile.h - "IReadFile.h" - "irrString.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\clogger.cpp - "CLogger.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\clogger.h - "ILogger.h" - "os.h" - "irrString.h" - "IEventReceiver.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cmd2meshfileloader.cpp - "IrrCompileConfig.h" - "CMD2MeshFileLoader.h" - "CAnimatedMeshMD2.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cmd2meshfileloader.h - "IMeshLoader.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cmd2meshfileloader.h - "IMeshLoader.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cmd3meshfileloader.cpp - "IrrCompileConfig.h" - "CMD3MeshFileLoader.h" - "CAnimatedMeshMD3.h" - "irrString.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cmd3meshfileloader.h - "IMeshLoader.h" - "IFileSystem.h" - "IVideoDriver.h" - "IAnimatedMeshMD3.h" - "IQ3Shader.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cmd3meshfileloader.h - "IMeshLoader.h" - "IFileSystem.h" - "IVideoDriver.h" - "IAnimatedMeshMD3.h" - "IQ3Shader.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cms3dmeshfileloader.cpp - "IrrCompileConfig.h" - "IReadFile.h" - "os.h" - "CMS3DMeshFileLoader.h" - "CSkinnedMesh.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cms3dmeshfileloader.h - "IMeshLoader.h" - "IVideoDriver.h" - "CSkinnedMesh.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cms3dmeshfileloader.h - "IMeshLoader.h" - "IVideoDriver.h" - "CSkinnedMesh.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cmy3dmeshfileloader.cpp - "IrrCompileConfig.h" - "CMY3DMeshFileLoader.h" - "SAnimatedMesh.h" - "SMeshBuffer.h" - "IReadFile.h" - "IAttributes.h" - "CImage.h" - "CColorConverter.h" - "CMY3DHelper.h" - "os.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cmy3dmeshfileloader.h - "IMeshLoader.h" - "SMesh.h" - "SMeshBufferLightMap.h" - "IFileSystem.h" - "IVideoDriver.h" - "irrString.h" - "ISceneManager.h" - "CMY3DStuff.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cmy3dstuff.h - <irrTypes.h> - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cmy3dhelper.h - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cmy3dmeshfileloader.h - "IMeshLoader.h" - "SMesh.h" - "SMeshBufferLightMap.h" - "IFileSystem.h" - "IVideoDriver.h" - "irrString.h" - "ISceneManager.h" - "CMY3DStuff.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cmemoryreadfile.cpp - "CMemoryReadFile.h" - "irrString.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cmemoryreadfile.h - "IReadFile.h" - "irrString.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cmeshcache.cpp - "CMeshCache.h" - "IAnimatedMesh.h" - "IMesh.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cmeshcache.h - "IMeshCache.h" - "irrArray.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cmeshcache.h - "IMeshCache.h" - "irrArray.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cmeshmanipulator.cpp - "CMeshManipulator.h" - "SMesh.h" - "CMeshBuffer.h" - "SAnimatedMesh.h" - "os.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cmeshmanipulator.h - "IMeshManipulator.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cmeshmanipulator.h - "IMeshManipulator.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cmeshscenenode.cpp - "CMeshSceneNode.h" - "IVideoDriver.h" - "ISceneManager.h" - "S3DVertex.h" - "ICameraSceneNode.h" - "IMeshCache.h" - "IAnimatedMesh.h" - "IMaterialRenderer.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cmeshscenenode.h - "IMeshSceneNode.h" - "IMesh.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cmeshscenenode.h - "IMeshSceneNode.h" - "IMesh.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cmetatriangleselector.cpp - "CMetaTriangleSelector.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cmetatriangleselector.h - "IMetaTriangleSelector.h" - "irrArray.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cmetatriangleselector.h - "IMetaTriangleSelector.h" - "irrArray.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cnulldriver.cpp - "CNullDriver.h" - "CSoftwareTexture.h" - "os.h" - "CImage.h" - "CAttributes.h" - "IReadFile.h" - "IWriteFile.h" - "IImageLoader.h" - "IImageWriter.h" - "IMaterialRenderer.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\csoftwaretexture.h - "ITexture.h" - "CImage.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cnulldriver.h - "IVideoDriver.h" - "IFileSystem.h" - "IImagePresenter.h" - "IGPUProgrammingServices.h" - "irrArray.h" - "irrString.h" - "IAttributes.h" - "IMeshBuffer.h" - "CFPSCounter.h" - "S3DVertex.h" - "SLight.h" - "SExposedVideoData.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cobjmeshfileloader.cpp - "IrrCompileConfig.h" - "COBJMeshFileLoader.h" - "SMesh.h" - "SMeshBuffer.h" - "SAnimatedMesh.h" - "IReadFile.h" - "fast_atof.h" - "coreutil.h" - "irrMap.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cobjmeshfileloader.h - "IMeshLoader.h" - "IFileSystem.h" - "IVideoDriver.h" - "irrString.h" - "SMeshBuffer.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cobjmeshfileloader.h - "IMeshLoader.h" - "IFileSystem.h" - "IVideoDriver.h" - "irrString.h" - "SMeshBuffer.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\coctloader.cpp - "IrrCompileConfig.h" - "COCTLoader.h" - "ISceneManager.h" - "os.h" - "SAnimatedMesh.h" - "SMeshBufferLightMap.h" - "irrString.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\coctloader.h - "IMeshLoader.h" - "IReadFile.h" - "SMesh.h" - "IVideoDriver.h" - "irrString.h" - "ISceneManager.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\coctloader.h - "IMeshLoader.h" - "IReadFile.h" - "SMesh.h" - "IVideoDriver.h" - "irrString.h" - "ISceneManager.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cosoperator.cpp - "COSOperator.h" - "IrrCompileConfig.h" - <windows.h> - <string.h> - <unistd.h> - "OSXClipboard.h" - <sys/types.h> - <sys/sysctl.h> - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cosoperator.h - "IOSOperator.h" - "irrString.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cocttreescenenode.cpp - "COctTreeSceneNode.h" - "OctTree.h" - "ISceneManager.h" - "IVideoDriver.h" - "ICameraSceneNode.h" - "IMeshCache.h" - "IAnimatedMesh.h" - "IMaterialRenderer.h" - "os.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cocttreescenenode.h - "ISceneNode.h" - "IMesh.h" - "OctTree.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\octtree.h - "SViewFrustum.h" - "S3DVertex.h" - "aabbox3d.h" - "irrArray.h" - "irrString.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cocttreescenenode.h - "ISceneNode.h" - "IMesh.h" - "OctTree.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cocttreetriangleselector.cpp - "COctTreeTriangleSelector.h" - "ISceneNode.h" - "os.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cocttreetriangleselector.h - "CTriangleSelector.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctriangleselector.h - "ITriangleSelector.h" - "IMesh.h" - "irrArray.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cocttreetriangleselector.h - "CTriangleSelector.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cogremeshfileloader.cpp - "IrrCompileConfig.h" - "COgreMeshFileLoader.h" - "os.h" - "SMeshBuffer.h" - "SAnimatedMesh.h" - "IReadFile.h" - "fast_atof.h" - "coreutil.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cogremeshfileloader.h - "IMeshLoader.h" - "IFileSystem.h" - "IVideoDriver.h" - "irrString.h" - "SMesh.h" - "SMeshBuffer.h" - "SMeshBufferLightMap.h" - "IMeshManipulator.h" - "matrix4.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cogremeshfileloader.h - "IMeshLoader.h" - "IFileSystem.h" - "IVideoDriver.h" - "irrString.h" - "SMesh.h" - "SMeshBuffer.h" - "SMeshBufferLightMap.h" - "IMeshManipulator.h" - "matrix4.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\copengldriver.cpp - "COpenGLDriver.h" - "CNullDriver.h" - "COpenGLTexture.h" - "COpenGLMaterialRenderer.h" - "COpenGLShaderMaterialRenderer.h" - "COpenGLSLMaterialRenderer.h" - "COpenGLNormalMapRenderer.h" - "COpenGLParallaxMapRenderer.h" - "CImage.h" - "os.h" - <SDL/SDL.h> - -1221578952 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\copengldriver.h - "IrrCompileConfig.h" - <windows.h> - "CIrrDeviceMacOSX.h" - "CNullDriver.h" - "IMaterialRendererServices.h" - "COpenGLExtensionHandler.h" - <GL/gl.h> - "glext.h" - <OpenGL/gl.h> - "glext.h" - <SDL/SDL_opengl.h> - "glext.h" - <GL/gl.h> - <GL/glx.h> - "glext.h" - "glxext.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\copenglextensionhandler.h - "IrrCompileConfig.h" - "EDriverFeatures.h" - "irrTypes.h" - "os.h" - <windows.h> - <GL/gl.h> - "glext.h" - "CIrrDeviceMacOSX.h" - <OpenGL/gl.h> - "glext.h" - <SDL/SDL_opengl.h> - "glext.h" - <GL/gl.h> - <GL/glx.h> - "glext.h" - "glxext.h" - -1195285115 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\glext.h - <windows.h> - <stddef.h> - <inttypes.h> - <inttypes.h> - <inttypes.h> - <stdint.h> - <stdint.h> - <inttypes.h> - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\copengltexture.h - "ITexture.h" - "IImage.h" - "IrrCompileConfig.h" - <windows.h> - <GL/gl.h> - "glext.h" - <OpenGL/gl.h> - <GL/gl.h> - "glext.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\copenglmaterialrenderer.h - "IrrCompileConfig.h" - "COpenGLDriver.h" - "IMaterialRenderer.h" - "IMaterialRenderer.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\copenglshadermaterialrenderer.h - "IrrCompileConfig.h" - <windows.h> - <GL/gl.h> - <OpenGL/gl.h> - <GL/gl.h> - "glext.h" - "IMaterialRenderer.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\copenglslmaterialrenderer.h - "IrrCompileConfig.h" - <windows.h> - <GL/gl.h> - "glext.h" - <OpenGL/gl.h> - <GL/gl.h> - "glext.h" - "IMaterialRenderer.h" - "IMaterialRendererServices.h" - "IGPUProgrammingServices.h" - "irrArray.h" - "irrString.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\copenglnormalmaprenderer.h - "IrrCompileConfig.h" - "COpenGLShaderMaterialRenderer.h" - "IShaderConstantSetCallBack.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\copenglparallaxmaprenderer.h - "IrrCompileConfig.h" - "COpenGLShaderMaterialRenderer.h" - "IShaderConstantSetCallBack.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\copengldriver.h - "IrrCompileConfig.h" - "CNullDriver.h" - "IMaterialRendererServices.h" - "COpenGLExtensionHandler.h" - <windows.h> - <GL/gl.h> - "glext.h" - "CIrrDeviceMacOSX.h" - <OpenGL/gl.h> - "glext.h" - <SDL/SDL_opengl.h> - "glext.h" - <GL/gl.h> - <GL/glx.h> - "glext.h" - "glxext.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\copenglextensionhandler.cpp - "IrrCompileConfig.h" - "COpenGLExtensionHandler.h" - "irrString.h" - "SMaterial.h" - "fast_atof.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\copenglextensionhandler.h - "IrrCompileConfig.h" - "EDriverFeatures.h" - "irrTypes.h" - "os.h" - <windows.h> - <GL/gl.h> - "glext.h" - "CIrrDeviceMacOSX.h" - <OpenGL/gl.h> - "glext.h" - <SDL/SDL_opengl.h> - "glext.h" - <GL/gl.h> - <GL/glx.h> - "glext.h" - "glxext.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\copenglnormalmaprenderer.cpp - "IrrCompileConfig.h" - "COpenGLNormalMapRenderer.h" - "IGPUProgrammingServices.h" - "IShaderConstantSetCallBack.h" - "IVideoDriver.h" - "os.h" - "COpenGLDriver.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\copenglnormalmaprenderer.h - "IrrCompileConfig.h" - "COpenGLShaderMaterialRenderer.h" - "IShaderConstantSetCallBack.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\copenglparallaxmaprenderer.cpp - "IrrCompileConfig.h" - "COpenGLParallaxMapRenderer.h" - "COpenGLDriver.h" - "IGPUProgrammingServices.h" - "IShaderConstantSetCallBack.h" - "IVideoDriver.h" - "os.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\copenglparallaxmaprenderer.h - "IrrCompileConfig.h" - "COpenGLShaderMaterialRenderer.h" - "IShaderConstantSetCallBack.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\copenglslmaterialrenderer.cpp - "IrrCompileConfig.h" - "COpenGLSLMaterialRenderer.h" - "IGPUProgrammingServices.h" - "IShaderConstantSetCallBack.h" - "IMaterialRendererServices.h" - "IVideoDriver.h" - "os.h" - "COpenGLDriver.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\copenglslmaterialrenderer.h - "IrrCompileConfig.h" - <windows.h> - <GL/gl.h> - "glext.h" - <OpenGL/gl.h> - <GL/gl.h> - "glext.h" - "IMaterialRenderer.h" - "IMaterialRendererServices.h" - "IGPUProgrammingServices.h" - "irrArray.h" - "irrString.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\copenglshadermaterialrenderer.cpp - "IrrCompileConfig.h" - "COpenGLShaderMaterialRenderer.h" - "IGPUProgrammingServices.h" - "IShaderConstantSetCallBack.h" - "IVideoDriver.h" - "os.h" - "COpenGLDriver.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\copenglshadermaterialrenderer.h - "IrrCompileConfig.h" - <windows.h> - <GL/gl.h> - <OpenGL/gl.h> - <GL/gl.h> - "glext.h" - "IMaterialRenderer.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\copengltexture.cpp - "IrrCompileConfig.h" - "irrTypes.h" - "COpenGLTexture.h" - "COpenGLDriver.h" - "os.h" - "CImage.h" - "CColorConverter.h" - "irrString.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\copengltexture.h - "ITexture.h" - "IImage.h" - "IrrCompileConfig.h" - <windows.h> - <GL/gl.h> - "glext.h" - <OpenGL/gl.h> - <GL/gl.h> - "glext.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cpakreader.cpp - "CPakReader.h" - "os.h" - "IrrCompileConfig.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cpakreader.h - "IReferenceCounted.h" - "IReadFile.h" - "irrArray.h" - "irrString.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cparticleanimatedmeshscenenodeemitter.cpp - "CParticleAnimatedMeshSceneNodeEmitter.h" - "IAnimatedMeshSceneNode.h" - "IMesh.h" - "os.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cparticleanimatedmeshscenenodeemitter.h - "IParticleAnimatedMeshSceneNodeEmitter.h" - "irrArray.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cparticleattractionaffector.cpp - "CParticleAttractionAffector.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cparticleattractionaffector.h - "IParticleAttractionAffector.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cparticleboxemitter.cpp - "CParticleBoxEmitter.h" - "os.h" - "IAttributes.h" - "irrMath.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cparticleboxemitter.h - "IParticleBoxEmitter.h" - "irrArray.h" - "aabbox3d.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cparticleboxemitter.h - "IParticleBoxEmitter.h" - "irrArray.h" - "aabbox3d.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cparticlecylinderemitter.cpp - "CParticleCylinderEmitter.h" - "os.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cparticlecylinderemitter.h - "IParticleCylinderEmitter.h" - "irrArray.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cparticlefadeoutaffector.cpp - "CParticleFadeOutAffector.h" - "IAttributes.h" - "os.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cparticlefadeoutaffector.h - "IParticleFadeOutAffector.h" - "SColor.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cparticlefadeoutaffector.h - "IParticleFadeOutAffector.h" - "SColor.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cparticlegravityaffector.cpp - "CParticleGravityAffector.h" - "os.h" - "IAttributes.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cparticlegravityaffector.h - "IParticleGravityAffector.h" - "SColor.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cparticlegravityaffector.h - "IParticleGravityAffector.h" - "SColor.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cparticlemeshemitter.cpp - "IrrCompileConfig.h" - "CParticleMeshEmitter.h" - "os.h" - <math.h> - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cparticlemeshemitter.h - "IParticleMeshEmitter.h" - "irrArray.h" - "aabbox3d.h" - "IMeshBuffer.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cparticlepointemitter.cpp - "CParticlePointEmitter.h" - "os.h" - "IAttributes.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cparticlepointemitter.h - "IParticleEmitter.h" - "irrArray.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cparticlepointemitter.h - "IParticleEmitter.h" - "irrArray.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cparticleringemitter.cpp - "CParticleRingEmitter.h" - "os.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cparticleringemitter.h - "IParticleRingEmitter.h" - "irrArray.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cparticlerotationaffector.cpp - "CParticleRotationAffector.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cparticlerotationaffector.h - "IParticleRotationAffector.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cparticlesphereemitter.cpp - "IrrCompileConfig.h" - "CParticleSphereEmitter.h" - "os.h" - <math.h> - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cparticlesphereemitter.h - "IParticleSphereEmitter.h" - "irrArray.h" - "aabbox3d.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cparticlesystemscenenode.cpp - "CParticleSystemSceneNode.h" - "os.h" - "ISceneManager.h" - "ICameraSceneNode.h" - "IVideoDriver.h" - "CParticleAnimatedMeshSceneNodeEmitter.h" - "CParticleBoxEmitter.h" - "CParticleCylinderEmitter.h" - "CParticleMeshEmitter.h" - "CParticlePointEmitter.h" - "CParticleRingEmitter.h" - "CParticleSphereEmitter.h" - "CParticleAttractionAffector.h" - "CParticleFadeOutAffector.h" - "CParticleGravityAffector.h" - "CParticleRotationAffector.h" - "SViewFrustum.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cparticlesystemscenenode.h - "IParticleSystemSceneNode.h" - "irrArray.h" - "irrList.h" - "SMeshBuffer.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cparticlesystemscenenode.h - "IParticleSystemSceneNode.h" - "irrArray.h" - "irrList.h" - "SMeshBuffer.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cq3levelmesh.cpp - "IrrCompileConfig.h" - "CQ3LevelMesh.h" - "ISceneManager.h" - "os.h" - "SMeshBufferLightMap.h" - "irrString.h" - "ILightSceneNode.h" - "IQ3Shader.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cq3levelmesh.h - "IQ3LevelMesh.h" - "IReadFile.h" - "IFileSystem.h" - "SMesh.h" - "SMeshBufferLightMap.h" - "IVideoDriver.h" - "irrString.h" - "ISceneManager.h" - "os.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cquake3shaderscenenode.cpp - "IrrCompileConfig.h" - "CQuake3ShaderSceneNode.h" - "ISceneManager.h" - "IVideoDriver.h" - "ICameraSceneNode.h" - "SViewFrustum.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cquake3shaderscenenode.h - "ISceneNode.h" - "IQ3Shader.h" - "IFileSystem.h" - "SMeshBuffer.h" - "SMeshBufferLightMap.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cquake3shaderscenenode.h - "ISceneNode.h" - "IQ3Shader.h" - "IFileSystem.h" - "SMeshBuffer.h" - "SMeshBufferLightMap.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\creadfile.cpp - "CReadFile.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\creadfile.h - <stdio.h> - "IReadFile.h" - "irrString.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cstlmeshfileloader.cpp - "IrrCompileConfig.h" - "CSTLMeshFileLoader.h" - "SMesh.h" - "SMeshBuffer.h" - "SAnimatedMesh.h" - "IReadFile.h" - "fast_atof.h" - "coreutil.h" - "os.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cstlmeshfileloader.h - "IMeshLoader.h" - "irrString.h" - "SColor.h" - "vector3d.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cstlmeshfileloader.h - "IMeshLoader.h" - "irrString.h" - "SColor.h" - "vector3d.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cstlmeshwriter.cpp - "IrrCompileConfig.h" - "CSTLMeshWriter.h" - "os.h" - "IMesh.h" - "IMeshBuffer.h" - "IAttributes.h" - "ISceneManager.h" - "IMeshCache.h" - "IWriteFile.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cstlmeshwriter.h - "IMeshWriter.h" - "S3DVertex.h" - "irrString.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cstlmeshwriter.h - "IMeshWriter.h" - "S3DVertex.h" - "irrString.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cscenecollisionmanager.cpp - "CSceneCollisionManager.h" - "ISceneNode.h" - "ICameraSceneNode.h" - "ITriangleSelector.h" - "SViewFrustum.h" - "os.h" - "irrMath.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cscenecollisionmanager.h - "ISceneCollisionManager.h" - "ISceneManager.h" - "IVideoDriver.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cscenecollisionmanager.h - "ISceneCollisionManager.h" - "ISceneManager.h" - "IVideoDriver.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cscenemanager.cpp - "IrrCompileConfig.h" - "CSceneManager.h" - "IVideoDriver.h" - "IFileSystem.h" - "SAnimatedMesh.h" - "CMeshCache.h" - "IWriteFile.h" - "IXMLWriter.h" - "ISceneUserDataSerializer.h" - "IGUIEnvironment.h" - "IMaterialRenderer.h" - "IReadFile.h" - "os.h" - "CGeometryCreator.h" - "CIrrMeshFileLoader.h" - "CBSPMeshFileLoader.h" - "CMD2MeshFileLoader.h" - "CMS3DMeshFileLoader.h" - "C3DSMeshFileLoader.h" - "CXMeshFileLoader.h" - "COCTLoader.h" - "CCSMLoader.h" - "CLMTSMeshFileLoader.h" - "CMY3DMeshFileLoader.h" - "CColladaFileLoader.h" - "CDMFLoader.h" - "COgreMeshFileLoader.h" - "COBJMeshFileLoader.h" - "CMD3MeshFileLoader.h" - "CB3DMeshFileLoader.h" - "CSTLMeshFileLoader.h" - "CColladaMeshWriter.h" - "CIrrMeshWriter.h" - "CSTLMeshWriter.h" - "CCubeSceneNode.h" - "CSphereSceneNode.h" - "CAnimatedMeshSceneNode.h" - "COctTreeSceneNode.h" - "CCameraSceneNode.h" - "CCameraMayaSceneNode.h" - "CCameraFPSSceneNode.h" - "CLightSceneNode.h" - "CBillboardSceneNode.h" - "CMeshSceneNode.h" - "CSkyBoxSceneNode.h" - "CSkyDomeSceneNode.h" - "CParticleSystemSceneNode.h" - "CDummyTransformationSceneNode.h" - "CWaterSurfaceSceneNode.h" - "CTerrainSceneNode.h" - "CEmptySceneNode.h" - "CTextSceneNode.h" - "CDefaultSceneNodeFactory.h" - "CSceneCollisionManager.h" - "CMeshManipulator.h" - "CTriangleSelector.h" - "COctTreeTriangleSelector.h" - "CTriangleBBSelector.h" - "CMetaTriangleSelector.h" - "CTerrainTriangleSelector.h" - "CSceneNodeAnimatorRotation.h" - "CSceneNodeAnimatorFlyCircle.h" - "CSceneNodeAnimatorFlyStraight.h" - "CSceneNodeAnimatorTexture.h" - "CSceneNodeAnimatorCollisionResponse.h" - "CSceneNodeAnimatorDelete.h" - "CSceneNodeAnimatorFollowSpline.h" - "CDefaultSceneNodeAnimatorFactory.h" - "CQuake3ShaderSceneNode.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cscenemanager.h - "ISceneManager.h" - "ISceneNode.h" - "ICursorControl.h" - "irrString.h" - "irrArray.h" - "IMeshLoader.h" - "CAttributes.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cxmeshfileloader.h - "IMeshLoader.h" - "irrString.h" - "CSkinnedMesh.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cspherescenenode.h - "ISceneNode.h" - "IMesh.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cskyboxscenenode.h - "ISceneNode.h" - "S3DVertex.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cskydomescenenode.h - "ISceneNode.h" - "SMeshBuffer.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cwatersurfacescenenode.h - "CMeshSceneNode.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cterrainscenenode.h - "ITerrainSceneNode.h" - "SMesh.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctextscenenode.h - "ITextSceneNode.h" - "IGUIFont.h" - "IGUIFontBitmap.h" - "ISceneCollisionManager.h" - "SMesh.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctrianglebbselector.h - "CTriangleSelector.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cterraintriangleselector.h - "ITriangleSelector.h" - "IMesh.h" - "irrArray.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cscenenodeanimatorrotation.h - "ISceneNode.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cscenenodeanimatorflycircle.h - "ISceneNode.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cscenenodeanimatorflystraight.h - "ISceneNode.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cscenenodeanimatortexture.h - "irrArray.h" - "ISceneNode.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cscenenodeanimatorcollisionresponse.h - "ISceneNodeAnimatorCollisionResponse.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cscenenodeanimatordelete.h - "ISceneNode.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cscenenodeanimatorfollowspline.h - "ISceneNode.h" - "irrArray.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cscenemanager.h - "ISceneManager.h" - "ISceneNode.h" - "ICursorControl.h" - "irrString.h" - "irrArray.h" - "IMeshLoader.h" - "CAttributes.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cscenenodeanimatorcollisionresponse.cpp - "CSceneNodeAnimatorCollisionResponse.h" - "ISceneCollisionManager.h" - "ISceneManager.h" - "os.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cscenenodeanimatorcollisionresponse.h - "ISceneNodeAnimatorCollisionResponse.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cscenenodeanimatordelete.cpp - "CSceneNodeAnimatorDelete.h" - "ISceneManager.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cscenenodeanimatordelete.h - "ISceneNode.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cscenenodeanimatorflycircle.cpp - "CSceneNodeAnimatorFlyCircle.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cscenenodeanimatorflycircle.h - "ISceneNode.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cscenenodeanimatorflystraight.cpp - "CSceneNodeAnimatorFlyStraight.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cscenenodeanimatorflystraight.h - "ISceneNode.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cscenenodeanimatorfollowspline.cpp - "CSceneNodeAnimatorFollowSpline.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cscenenodeanimatorfollowspline.h - "ISceneNode.h" - "irrArray.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cscenenodeanimatorrotation.cpp - "CSceneNodeAnimatorRotation.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cscenenodeanimatorrotation.h - "ISceneNode.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cscenenodeanimatortexture.cpp - "CSceneNodeAnimatorTexture.h" - "ITexture.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cscenenodeanimatortexture.h - "irrArray.h" - "ISceneNode.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cshadowvolumescenenode.cpp - "CShadowVolumeSceneNode.h" - "ISceneManager.h" - "IMesh.h" - "IVideoDriver.h" - "SLight.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cshadowvolumescenenode.h - "IShadowVolumeSceneNode.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cskinnedmesh.cpp - "IrrCompileConfig.h" - "CSkinnedMesh.h" - "CBoneSceneNode.h" - "IAnimatedMeshSceneNode.h" - "os.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cskinnedmesh.h - "ISkinnedMesh.h" - "SMeshBuffer.h" - "S3DVertex.h" - "irrString.h" - "matrix4.h" - "quaternion.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cskyboxscenenode.cpp - "CSkyBoxSceneNode.h" - "IVideoDriver.h" - "ISceneManager.h" - "ICameraSceneNode.h" - "S3DVertex.h" - "os.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cskyboxscenenode.h - "ISceneNode.h" - "S3DVertex.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cskydomescenenode.cpp - "CSkyDomeSceneNode.h" - "IVideoDriver.h" - "ISceneManager.h" - "ICameraSceneNode.h" - "os.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cskydomescenenode.h - "ISceneNode.h" - "SMeshBuffer.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\csoftwaredriver.cpp - "CSoftwareDriver.h" - "IrrCompileConfig.h" - "CSoftwareTexture.h" - "os.h" - "S3DVertex.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\csoftwaredriver.h - "ITriangleRenderer.h" - "CNullDriver.h" - "SViewFrustum.h" - "CImage.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\itrianglerenderer.h - "IReferenceCounted.h" - "S2DVertex.h" - "rect.h" - "IZBuffer.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\s2dvertex.h - "vector2d.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\izbuffer.h - "IReferenceCounted.h" - "dimension2d.h" - "S2DVertex.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\csoftwaredriver.h - "ITriangleRenderer.h" - "CNullDriver.h" - "SViewFrustum.h" - "CImage.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\csoftwaredriver2.cpp - "CSoftwareDriver2.h" - "IrrCompileConfig.h" - "SoftwareDriver2_helper.h" - "CSoftwareTexture2.h" - "CSoftware2MaterialRenderer.h" - "S3DVertex.h" - "S4DVertex.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\csoftwaredriver2.h - "SoftwareDriver2_compile_config.h" - "IBurningShader.h" - "CNullDriver.h" - "CImage.h" - "os.h" - "irrString.h" - -1212214599 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\iburningshader.h - "SoftwareDriver2_compile_config.h" - "IReferenceCounted.h" - "irrMath.h" - "IImage.h" - "S2DVertex.h" - "rect.h" - "IDepthBuffer.h" - "S4DVertex.h" - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\csoftware2materialrenderer.h - "SoftwareDriver2_compile_config.h" - "IMaterialRenderer.h" - "CSoftwareDriver2.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\csoftwaredriver2.h - "SoftwareDriver2_compile_config.h" - "IBurningShader.h" - "CNullDriver.h" - "CImage.h" - "os.h" - "irrString.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\csoftwaretexture.cpp - "IrrCompileConfig.h" - "CSoftwareTexture.h" - "os.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\csoftwaretexture.h - "ITexture.h" - "CImage.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\csoftwaretexture2.cpp - "IrrCompileConfig.h" - "SoftwareDriver2_compile_config.h" - "SoftwareDriver2_helper.h" - "CSoftwareTexture2.h" - "os.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\csoftwaretexture2.h - "SoftwareDriver2_compile_config.h" - "ITexture.h" - "CImage.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cspherescenenode.cpp - "CSphereSceneNode.h" - "IVideoDriver.h" - "ISceneManager.h" - "CGeometryCreator.h" - "S3DVertex.h" - "os.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cspherescenenode.h - "ISceneNode.h" - "IMesh.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctrflat.cpp - "IrrCompileConfig.h" - "CTRTextureGouraud.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctrtexturegouraud.h - "IrrCompileConfig.h" - "ITriangleRenderer.h" - "IImage.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctrflatwire.cpp - "IrrCompileConfig.h" - "CTRTextureGouraud.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctrgouraud.cpp - "IrrCompileConfig.h" - "CTRTextureGouraud.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctrgouraud2.cpp - "IrrCompileConfig.h" - "IBurningShader.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctrgouraudalpha2.cpp - "IrrCompileConfig.h" - "IBurningShader.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctrgouraudalphanoz2.cpp - "IrrCompileConfig.h" - "IBurningShader.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctrgouraudwire.cpp - "IrrCompileConfig.h" - "CTRTextureGouraud.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctrtextureblend.cpp - "IrrCompileConfig.h" - "IBurningShader.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctrtexturedetailmap2.cpp - "IrrCompileConfig.h" - "IBurningShader.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctrtextureflat.cpp - "IrrCompileConfig.h" - "CTRTextureGouraud.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctrtextureflatwire.cpp - "IrrCompileConfig.h" - "CTRTextureGouraud.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctrtexturegouraud.cpp - "CTRTextureGouraud.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctrtexturegouraud.h - "IrrCompileConfig.h" - "ITriangleRenderer.h" - "IImage.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctrtexturegouraud2.cpp - "IrrCompileConfig.h" - "IBurningShader.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctrtexturegouraudadd.cpp - "IrrCompileConfig.h" - "CTRTextureGouraud.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctrtexturegouraudadd2.cpp - "IrrCompileConfig.h" - "IBurningShader.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctrtexturegouraudaddnoz2.cpp - "IrrCompileConfig.h" - "IBurningShader.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctrtexturegouraudalpha.cpp - "IrrCompileConfig.h" - "IBurningShader.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctrtexturegouraudalphanoz.cpp - "IrrCompileConfig.h" - "IBurningShader.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctrtexturegouraudnoz.cpp - "IrrCompileConfig.h" - "CTRTextureGouraud.h" - "SColor.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctrtexturegouraudnoz2.cpp - "IrrCompileConfig.h" - "IBurningShader.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctrtexturegouraudvertexalpha2.cpp - "IrrCompileConfig.h" - "IBurningShader.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctrtexturegouraudwire.cpp - "IrrCompileConfig.h" - "CTRTextureGouraud.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctrtexturelightmap2_add.cpp - "IrrCompileConfig.h" - "IBurningShader.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctrtexturelightmap2_m1.cpp - "IrrCompileConfig.h" - "IBurningShader.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctrtexturelightmap2_m2.cpp - "IrrCompileConfig.h" - "IBurningShader.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctrtexturelightmap2_m4.cpp - "IrrCompileConfig.h" - "IBurningShader.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctrtexturelightmapgouraud2_m4.cpp - "IrrCompileConfig.h" - "IBurningShader.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctrtexturewire2.cpp - "IrrCompileConfig.h" - "IBurningShader.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cterrainscenenode.cpp - "CTerrainSceneNode.h" - "CTerrainTriangleSelector.h" - "IVideoDriver.h" - "ISceneManager.h" - "ICameraSceneNode.h" - "SMeshBufferLightMap.h" - "SViewFrustum.h" - "irrMath.h" - "os.h" - "IGUIFont.h" - "IFileSystem.h" - "IReadFile.h" - "ITextSceneNode.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cterrainscenenode.h - "ITerrainSceneNode.h" - "SMesh.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cterraintriangleselector.cpp - "CTerrainTriangleSelector.h" - "CTerrainSceneNode.h" - "os.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cterraintriangleselector.h - "ITriangleSelector.h" - "IMesh.h" - "irrArray.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctextscenenode.cpp - "CTextSceneNode.h" - "ISceneManager.h" - "IVideoDriver.h" - "ICameraSceneNode.h" - "IGUISpriteBank.h" - "SMeshBuffer.h" - "os.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctextscenenode.h - "ITextSceneNode.h" - "IGUIFont.h" - "IGUIFontBitmap.h" - "ISceneCollisionManager.h" - "SMesh.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctrianglebbselector.cpp - "CTriangleBBSelector.h" - "ISceneNode.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctrianglebbselector.h - "CTriangleSelector.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctriangleselector.cpp - "CTriangleSelector.h" - "ISceneNode.h" - "IMeshBuffer.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\ctriangleselector.h - "ITriangleSelector.h" - "IMesh.h" - "irrArray.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cvideomodelist.cpp - "CVideoModeList.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cvideomodelist.h - "IVideoModeList.h" - "dimension2d.h" - "irrArray.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cwatersurfacescenenode.cpp - "CWaterSurfaceSceneNode.h" - "ISceneManager.h" - "IMeshManipulator.h" - "IMeshCache.h" - "S3DVertex.h" - "SMesh.h" - "os.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cwatersurfacescenenode.h - "CMeshSceneNode.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cwritefile.cpp - "CWriteFile.h" - <stdio.h> - -1212214601 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cwritefile.h - <stdio.h> - "IWriteFile.h" - "irrString.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cwritefile.h - <stdio.h> - "IWriteFile.h" - "irrString.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cxmlreader.cpp - "CXMLReaderImpl.h" - "CXMLReader.h" - "IReadFile.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cxmlreaderimpl.h - "irrXML.h" - "irrString.h" - "irrArray.h" - "fast_atof.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cxmlreader.h - "IXMLReader.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cxmlwriter.cpp - "CXMLWriter.h" - <wchar.h> - "irrString.h" - "IrrCompileConfig.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cxmlwriter.h - <wchar.h> - "IXMLWriter.h" - "IWriteFile.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cxmeshfileloader.cpp - "IrrCompileConfig.h" - "CXMeshFileLoader.h" - "os.h" - "fast_atof.h" - "coreutil.h" - "ISceneManager.h" - "IVideoDriver.h" - "IReadFile.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\cxmeshfileloader.h - "IMeshLoader.h" - "irrString.h" - "CSkinnedMesh.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\czbuffer.cpp - "IrrCompileConfig.h" - "CZBuffer.h" - "irrString.h" - -1212214600 c:\development\irrlicht-1.4\irrlicht\source\irrlicht\czbuffer.h - "IZBuffer.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\czbuffer.h - "IZBuffer.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\czipreader.cpp - "CZipReader.h" - "CFileList.h" - "CReadFile.h" - "os.h" - "IrrCompileConfig.h" - <zlib.h> - "zlib/zlib.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\czipreader.h - "IReferenceCounted.h" - "IReadFile.h" - "irrArray.h" - "irrString.h" - "IFileSystem.h" - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\iburningshader.cpp - "IrrCompileConfig.h" - "SoftwareDriver2_compile_config.h" - "IBurningShader.h" - -1212214599 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\iburningshader.h - "SoftwareDriver2_compile_config.h" - "IReferenceCounted.h" - "irrMath.h" - "IImage.h" - "S2DVertex.h" - "rect.h" - "IDepthBuffer.h" - "S4DVertex.h" - -1212297774 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\irrlicht.cpp - "IrrCompileConfig.h" - <windows.h> - <crtdbg.h> - <xtl.h> - "irrlicht.h" - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\irrxml.cpp - "irrXML.h" - "irrString.h" - "irrArray.h" - "fast_atof.h" - "CXMLReaderImpl.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\cdjpeg.h - "jinclude.h" - "jpeglib.h" - "jerror.h" - "cderror.h" - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jchuff.h - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jdhuff.h - -1195285108 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\jpeglib\jerror.h - -1195285100 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\libpng\png.h - "zlib.h" - "pngconf.h" - <crtdbg.h> - -1212214600 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\os.cpp - "os.h" - "irrString.h" - "IrrCompileConfig.h" - "irrMath.h" - <SDL/SDL_endian.h> - <stdlib.h> - <libkern/OSByteOrder.h> - <sys/endian.h> - <byteswap.h> - <xtl.h> - <windows.h> - <stdio.h> - <time.h> - <sys/time.h> - -1212214601 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\os.h - "IrrCompileConfig.h" - "irrTypes.h" - "ILogger.h" - -1195285103 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\zlib\crc32.h - -1195285103 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\zlib\deflate.h - "zutil.h" - -1195285103 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\zlib\inffast.h - -1195285103 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\zlib\inftrees.h - -1195285103 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\zlib\trees.h - -1195285103 source:c:\development\irrlicht-1.4\irrlicht\source\irrlicht\zlib\zutil.h - "zlib.h" - <stddef.h> - <string.h> - <stdlib.h> - <errno.h> - <alloc.h> - <malloc.h> - <malloc.h> - <unix.h> - <stdio.h> - diff --git a/irrlicht-1.6/source/Irrlicht/MacOSX/._MainMenu.nib b/irrlicht-1.6/source/Irrlicht/MacOSX/._MainMenu.nib deleted file mode 100644 index ed1f83f52..000000000 Binary files a/irrlicht-1.6/source/Irrlicht/MacOSX/._MainMenu.nib and /dev/null differ diff --git a/irrlicht-1.6/source/Irrlicht/MacOSX/AppDelegate.h b/irrlicht-1.6/source/Irrlicht/MacOSX/AppDelegate.h deleted file mode 100644 index 38dbbc18e..000000000 --- a/irrlicht-1.6/source/Irrlicht/MacOSX/AppDelegate.h +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2005-2009 Etienne Petitjean -// 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_OSX_DEVICE_ - -#import <Cocoa/Cocoa.h> -#import "CIrrDeviceMacOSX.h" - -@interface AppDelegate : NSObject -{ - BOOL _quit; - irr::CIrrDeviceMacOSX *_device; -} - -- (id)initWithDevice:(irr::CIrrDeviceMacOSX *)device; -- (BOOL)isQuit; - -@end - -#endif // _IRR_COMPILE_WITH_OSX_DEVICE_ diff --git a/irrlicht-1.6/source/Irrlicht/MacOSX/AppDelegate.mm b/irrlicht-1.6/source/Irrlicht/MacOSX/AppDelegate.mm deleted file mode 100644 index 54ae83f16..000000000 --- a/irrlicht-1.6/source/Irrlicht/MacOSX/AppDelegate.mm +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (C) 2005-2009 Etienne Petitjean -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in Irrlicht.h - -#import "AppDelegate.h" - -#ifdef _IRR_COMPILE_WITH_OSX_DEVICE_ - -@implementation AppDelegate - -- (id)initWithDevice:(irr::CIrrDeviceMacOSX *)device -{ - self = [super init]; - if (self) _device = device; - return (self); -} - -- (void)applicationDidFinishLaunching:(NSNotification *)aNotification -{ - _quit = FALSE; -} - -- (void)orderFrontStandardAboutPanel:(id)sender -{ - [NSApp orderFrontStandardAboutPanel:sender]; -} - -- (void)unhideAllApplications:(id)sender -{ - [NSApp unhideAllApplications:sender]; -} - -- (void)hide:(id)sender -{ - [NSApp hide:sender]; -} - -- (void)hideOtherApplications:(id)sender -{ - [NSApp hideOtherApplications:sender]; -} - -- (void)terminate:(id)sender -{ - _quit = TRUE; -} - -- (void)windowWillClose:(id)sender -{ - _quit = TRUE; -} - -- (NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize -{ - if (_device->isResizable()) - return proposedFrameSize; - else - return [window frame].size; -} - -- (void)windowDidResize:(NSNotification *)aNotification -{ - NSWindow *window; - NSRect frame; - - window = [aNotification object]; - frame = [window frame]; - _device->setResize((int)frame.size.width,(int)frame.size.height); -} - -- (BOOL)isQuit -{ - return (_quit); -} - -@end - -#endif // _IRR_COMPILE_WITH_OSX_DEVICE_ diff --git a/irrlicht-1.6/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.h b/irrlicht-1.6/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.h deleted file mode 100644 index 6b0e058b1..000000000 --- a/irrlicht-1.6/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.h +++ /dev/null @@ -1,249 +0,0 @@ -// Copyright (C) 2005-2009 Etienne Petitjean -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in Irrlicht.h - -#ifndef __C_IRR_DEVICE_MACOSX_H_INCLUDED__ -#define __C_IRR_DEVICE_MACOSX_H_INCLUDED__ - -#include "IrrCompileConfig.h" - -#ifdef _IRR_COMPILE_WITH_OSX_DEVICE_ - -#include "CIrrDeviceStub.h" -#include "IrrlichtDevice.h" -#include "IImagePresenter.h" -#include "IGUIEnvironment.h" -#include "ICursorControl.h" - -#include <OpenGL/OpenGL.h> -#include <map> - -class NSWindow; -class NSOpenGLContext; -class NSBitmapImageRep; - -namespace irr -{ - class CIrrDeviceMacOSX : public CIrrDeviceStub, video::IImagePresenter - { - public: - - //! constructor - CIrrDeviceMacOSX(const SIrrlichtCreationParameters& params); - - //! destructor - virtual ~CIrrDeviceMacOSX(); - - //! runs the device. Returns false if device wants to be deleted - virtual bool run(); - - //! Cause the device to temporarily pause execution and let other processes to run - // This should bring down processor usage without major performance loss for Irrlicht - virtual void yield(); - - //! Pause execution and let other processes to run for a specified amount of time. - virtual void sleep(u32 timeMs, bool pauseTimer); - - //! sets the caption of the window - virtual void setWindowCaption(const wchar_t* text); - - //! returns if window is active. if not, nothing need to be drawn - virtual bool isWindowActive() const; - - //! Checks if the Irrlicht window has focus - virtual bool isWindowFocused() const; - - //! Checks if the Irrlicht window is minimized - virtual bool isWindowMinimized() const; - - //! presents a surface in the client area - virtual bool present(video::IImage* surface, void* windowId=0, core::rect<s32>* src=0 ); - - //! notifies the device that it should close itself - virtual void closeDevice(); - - //! Sets if the window should be resizable in windowed mode. - virtual void setResizable(bool resize); - - //! Returns true if the window is resizable, false if not - virtual bool isResizable() const; - - //! Minimizes the window if possible - virtual void minimizeWindow(); - - //! Maximizes the window if possible. - virtual void maximizeWindow(); - - //! Restore the window to normal size if possible. - virtual void restoreWindow(); - - //! Activate any joysticks, and generate events for them. - virtual bool activateJoysticks(core::array<SJoystickInfo> & joystickInfo); - - //! \return Returns a pointer to a list with all video modes - //! supported by the gfx adapter. - virtual video::IVideoModeList* getVideoModeList(); - - //! Get the device type - virtual E_DEVICE_TYPE getType() const - { - return EIDT_OSX; - } - - void flush(); - void setMouseLocation(int x, int y); - void setResize(int width, int height); - void setCursorVisible(bool visible); - - private: - - //! create the driver - void createDriver(); - - //! Implementation of the macos x cursor control - class CCursorControl : public gui::ICursorControl - { - public: - - CCursorControl(const core::dimension2d<u32>& wsize, CIrrDeviceMacOSX *device) - : WindowSize(wsize), IsVisible(true), InvWindowSize(0.0f, 0.0f), Device(device), UseReferenceRect(false) - { - CursorPos.X = CursorPos.Y = 0; - if (WindowSize.Width!=0) - InvWindowSize.Width = 1.0f / WindowSize.Width; - if (WindowSize.Height!=0) - InvWindowSize.Height = 1.0f / WindowSize.Height; - } - - //! Changes the visible state of the mouse cursor. - virtual void setVisible(bool visible) - { - IsVisible = visible; - Device->setCursorVisible(visible); - } - - //! Returns if the cursor is currently visible. - virtual bool isVisible() const - { - return IsVisible; - } - - //! Sets the new position of the cursor. - virtual void setPosition(const core::position2d<f32> &pos) - { - setPosition(pos.X, pos.Y); - } - - //! Sets the new position of the cursor. - virtual void setPosition(f32 x, f32 y) - { - setPosition((s32)(x*WindowSize.Width), (s32)(y*WindowSize.Height)); - } - - //! Sets the new position of the cursor. - virtual void setPosition(const core::position2d<s32> &pos) - { - if (CursorPos.X != pos.X || CursorPos.Y != pos.Y) - setPosition(pos.X, pos.Y); - } - - //! Sets the new position of the cursor. - virtual void setPosition(s32 x, s32 y) - { - if (UseReferenceRect) - { - Device->setMouseLocation(ReferenceRect.UpperLeftCorner.X + x, ReferenceRect.UpperLeftCorner.Y + y); - } - else - { - Device->setMouseLocation(x,y); - } - } - - //! Returns the current position of the mouse cursor. - virtual core::position2d<s32> getPosition() - { - return CursorPos; - } - - //! Returns the current position of the mouse cursor. - virtual core::position2d<f32> getRelativePosition() - { - if (!UseReferenceRect) - { - return core::position2d<f32>(CursorPos.X * InvWindowSize.Width, - CursorPos.Y * InvWindowSize.Height); - } - - return core::position2d<f32>(CursorPos.X / (f32)ReferenceRect.getWidth(), - CursorPos.Y / (f32)ReferenceRect.getHeight()); - } - - //! Sets an absolute reference rect for calculating the cursor position. - virtual void setReferenceRect(core::rect<s32>* rect=0) - { - if (rect) - { - ReferenceRect = *rect; - UseReferenceRect = true; - - // prevent division through zero and uneven sizes - - if (!ReferenceRect.getHeight() || ReferenceRect.getHeight()%2) - ReferenceRect.LowerRightCorner.Y += 1; - - if (!ReferenceRect.getWidth() || ReferenceRect.getWidth()%2) - ReferenceRect.LowerRightCorner.X += 1; - } - else - UseReferenceRect = false; - } - - //! Updates the internal cursor position - void updateInternalCursorPosition(int x,int y) - { - CursorPos.X = x; - CursorPos.Y = y; - } - - private: - - core::position2d<s32> CursorPos; - core::dimension2d<s32> WindowSize; - core::dimension2d<float> InvWindowSize; - core::rect<s32> ReferenceRect; - CIrrDeviceMacOSX *Device; - bool IsVisible; - bool UseReferenceRect; - }; - - bool createWindow(); - void initKeycodes(); - void storeMouseLocation(); - void postMouseEvent(void *event, irr::SEvent &ievent); - void postKeyEvent(void *event, irr::SEvent &ievent, bool pressed); - void pollJoysticks(); - - NSWindow *Window; - CGLContextObj CGLContext; - NSOpenGLContext *OGLContext; - int DeviceWidth, - DeviceHeight; - std::map<int,int> KeyCodes; - int ScreenWidth, - ScreenHeight; - bool IsActive; - NSBitmapImageRep *SoftwareDriverTarget; - bool IsSoftwareRenderer, - IsShiftDown, - IsControlDown, - IsResizable; - u32 MouseButtonStates; - }; - - -} // end namespace irr - -#endif // _IRR_COMPILE_WITH_OSX_DEVICE_ -#endif // __C_IRR_DEVICE_MACOSX_H_INCLUDED__ - diff --git a/irrlicht-1.6/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm b/irrlicht-1.6/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm deleted file mode 100644 index 9d6005ce3..000000000 --- a/irrlicht-1.6/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm +++ /dev/null @@ -1,1453 +0,0 @@ -// Copyright (C) 2005-2009 Etienne Petitjean -// 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_OSX_DEVICE_ - -#import <Cocoa/Cocoa.h> -#import <OpenGL/gl.h> -#import <Carbon/Carbon.h> - -#include "CIrrDeviceMacOSX.h" -#include "IEventReceiver.h" -#include "irrList.h" -#include "os.h" -#include "CTimer.h" -#include "irrString.h" -#include "Keycodes.h" -#include <stdio.h> -#include <sys/utsname.h> -#include "COSOperator.h" -#include "CColorConverter.h" -#include "irrlicht.h" - - -#import <wchar.h> -#import <time.h> -#import "AppDelegate.h" - -#if defined _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ - -#include <IOKit/IOKitLib.h> -#include <IOKit/IOCFPlugIn.h> -#ifdef MACOS_10_0_4 -#include <IOKit/hidsystem/IOHIDUsageTables.h> -#else -/* The header was moved here in Mac OS X 10.1 */ -#include <Kernel/IOKit/hidsystem/IOHIDUsageTables.h> -#endif -#include <IOKit/hid/IOHIDLib.h> -#include <IOKit/hid/IOHIDKeys.h> - -struct JoystickComponent -{ - IOHIDElementCookie cookie; // unique value which identifies element, will NOT change - long min; // reported min value possible - long max; // reported max value possible - - long minRead; //min read value - long maxRead; //max read value - - JoystickComponent() : min(0), minRead(0), max(0), maxRead(0) - { - } -}; - -struct JoystickInfo -{ - irr::core::array <JoystickComponent> axisComp; - irr::core::array <JoystickComponent> buttonComp; - irr::core::array <JoystickComponent> hatComp; - - int hats; - int axes; - int buttons; - - int numActiveJoysticks; - - irr::SEvent persistentData; - - IOHIDDeviceInterface ** interface; - bool removed; - char joystickName[256]; - long usage; // usage page from IOUSBHID Parser.h which defines general usage - long usagePage; // usage within above page from IOUSBHID Parser.h which defines specific usage - - JoystickInfo() : hats(0), axes(0), buttons(0), interface(0), removed(false), usage(0), usagePage(0), numActiveJoysticks(0) - { - interface = NULL; - memset(joystickName, '\0', 256); - axisComp.clear(); - buttonComp.clear(); - hatComp.clear(); - - persistentData.EventType = irr::EET_JOYSTICK_INPUT_EVENT; - persistentData.JoystickEvent.POV = 65535; - persistentData.JoystickEvent.ButtonStates = 0; - } -}; -irr::core::array<JoystickInfo> ActiveJoysticks; - -//helper functions for init joystick -static IOReturn closeJoystickDevice (JoystickInfo* joyInfo) -{ - IOReturn result = kIOReturnSuccess; - if (joyInfo && joyInfo->interface) - { - /* close the interface */ - result = (*(joyInfo->interface))->close (joyInfo->interface); - if (kIOReturnNotOpen == result) - { - /* do nothing as device was not opened, thus can't be closed */ - } - else if (kIOReturnSuccess != result) - irr::os::Printer::log("IOHIDDeviceInterface failed to close", irr::ELL_ERROR); - /* release the interface */ - result = (*(joyInfo->interface))->Release (joyInfo->interface); - if (kIOReturnSuccess != result) - irr::os::Printer::log("IOHIDDeviceInterface failed to release", irr::ELL_ERROR); - joyInfo->interface = NULL; - } - return result; -} - -static void addComponentInfo (CFTypeRef refElement, JoystickComponent *pComponent, int numActiveJoysticks) -{ - long number; - CFTypeRef refType; - - refType = CFDictionaryGetValue ((CFDictionaryRef)refElement, CFSTR(kIOHIDElementCookieKey)); - if (refType && CFNumberGetValue ((CFNumberRef)refType, kCFNumberLongType, &number)) - pComponent->cookie = (IOHIDElementCookie) number; - refType = CFDictionaryGetValue ((CFDictionaryRef)refElement, CFSTR(kIOHIDElementMinKey)); - if (refType && CFNumberGetValue ((CFNumberRef)refType, kCFNumberLongType, &number)) - pComponent->minRead = pComponent->min = number; - refType = CFDictionaryGetValue ((CFDictionaryRef)refElement, CFSTR(kIOHIDElementMaxKey)); - if (refType && CFNumberGetValue ((CFNumberRef)refType, kCFNumberLongType, &number)) - pComponent->maxRead = pComponent->max = number; -} - -static void getJoystickComponentArrayHandler (const void * value, void * parameter); - -static void addJoystickComponent (CFTypeRef refElement, JoystickInfo* joyInfo) -{ - long elementType, usagePage, usage; - CFTypeRef refElementType = CFDictionaryGetValue ((CFDictionaryRef)refElement, CFSTR(kIOHIDElementTypeKey)); - CFTypeRef refUsagePage = CFDictionaryGetValue ((CFDictionaryRef)refElement, CFSTR(kIOHIDElementUsagePageKey)); - CFTypeRef refUsage = CFDictionaryGetValue ((CFDictionaryRef)refElement, CFSTR(kIOHIDElementUsageKey)); - - - if ((refElementType) && (CFNumberGetValue ((CFNumberRef)refElementType, kCFNumberLongType, &elementType))) - { - /* look at types of interest */ - if ((elementType == kIOHIDElementTypeInput_Misc) || (elementType == kIOHIDElementTypeInput_Button) || - (elementType == kIOHIDElementTypeInput_Axis)) - { - if (refUsagePage && CFNumberGetValue ((CFNumberRef)refUsagePage, kCFNumberLongType, &usagePage) && - refUsage && CFNumberGetValue ((CFNumberRef)refUsage, kCFNumberLongType, &usage)) - { - switch (usagePage) /* only interested in kHIDPage_GenericDesktop and kHIDPage_Button */ - { - case kHIDPage_GenericDesktop: - { - switch (usage) /* look at usage to determine function */ - { - case kHIDUsage_GD_X: - case kHIDUsage_GD_Y: - case kHIDUsage_GD_Z: - case kHIDUsage_GD_Rx: - case kHIDUsage_GD_Ry: - case kHIDUsage_GD_Rz: - case kHIDUsage_GD_Slider: - case kHIDUsage_GD_Dial: - case kHIDUsage_GD_Wheel: - { - joyInfo->axes++; - JoystickComponent newComponent; - addComponentInfo(refElement, &newComponent, joyInfo->numActiveJoysticks); - joyInfo->axisComp.push_back(newComponent); - } - break; - case kHIDUsage_GD_Hatswitch: - { - joyInfo->hats++; - JoystickComponent newComponent; - addComponentInfo(refElement, &newComponent, joyInfo->numActiveJoysticks); - joyInfo->hatComp.push_back(newComponent); - } - break; - } - } - break; - case kHIDPage_Button: - { - joyInfo->buttons++; - JoystickComponent newComponent; - addComponentInfo(refElement, &newComponent, joyInfo->numActiveJoysticks); - joyInfo->buttonComp.push_back(newComponent); - } - break; - default: - break; - } - } - } - else if (kIOHIDElementTypeCollection == elementType) - { - //get elements - CFTypeRef refElementTop = CFDictionaryGetValue ((CFMutableDictionaryRef) refElement, CFSTR(kIOHIDElementKey)); - if (refElementTop) - { - CFTypeID type = CFGetTypeID (refElementTop); - if (type == CFArrayGetTypeID()) - { - CFRange range = {0, CFArrayGetCount ((CFArrayRef)refElementTop)}; - CFArrayApplyFunction ((CFArrayRef)refElementTop, range, getJoystickComponentArrayHandler, joyInfo); - } - } - } - } - -} - -static void getJoystickComponentArrayHandler (const void * value, void * parameter) -{ - if (CFGetTypeID (value) == CFDictionaryGetTypeID ()) - addJoystickComponent ((CFTypeRef) value, (JoystickInfo *) parameter); -} - -static void joystickTopLevelElementHandler (const void * value, void * parameter) -{ - CFTypeRef refCF = 0; - if (CFGetTypeID (value) != CFDictionaryGetTypeID ()) - return; - refCF = CFDictionaryGetValue ((CFDictionaryRef)value, CFSTR(kIOHIDElementUsagePageKey)); - if (!CFNumberGetValue ((CFNumberRef)refCF, kCFNumberLongType, &((JoystickInfo *) parameter)->usagePage)) - irr::os::Printer::log("CFNumberGetValue error retrieving JoystickInfo->usagePage", irr::ELL_ERROR); - refCF = CFDictionaryGetValue ((CFDictionaryRef)value, CFSTR(kIOHIDElementUsageKey)); - if (!CFNumberGetValue ((CFNumberRef)refCF, kCFNumberLongType, &((JoystickInfo *) parameter)->usage)) - irr::os::Printer::log("CFNumberGetValue error retrieving JoystickInfo->usage", irr::ELL_ERROR); -} - -static void getJoystickDeviceInfo (io_object_t hidDevice, CFMutableDictionaryRef hidProperties, JoystickInfo *joyInfo) -{ - CFMutableDictionaryRef usbProperties = 0; - io_registry_entry_t parent1, parent2; - - /* Mac OS X currently is not mirroring all USB properties to HID page so need to look at USB device page also - * get dictionary for usb properties: step up two levels and get CF dictionary for USB properties - */ - if ((KERN_SUCCESS == IORegistryEntryGetParentEntry (hidDevice, kIOServicePlane, &parent1)) && - (KERN_SUCCESS == IORegistryEntryGetParentEntry (parent1, kIOServicePlane, &parent2)) && - (KERN_SUCCESS == IORegistryEntryCreateCFProperties (parent2, &usbProperties, kCFAllocatorDefault, kNilOptions))) - { - if (usbProperties) - { - CFTypeRef refCF = 0; - /* get device info - * try hid dictionary first, if fail then go to usb dictionary - */ - - - /* get joystickName name */ - refCF = CFDictionaryGetValue (hidProperties, CFSTR(kIOHIDProductKey)); - if (!refCF) - refCF = CFDictionaryGetValue (usbProperties, CFSTR("USB Product Name")); - if (refCF) - { - if (!CFStringGetCString ((CFStringRef)refCF, joyInfo->joystickName, 256, CFStringGetSystemEncoding ())) - irr::os::Printer::log("CFStringGetCString error getting joyInfo->joystickName", irr::ELL_ERROR); - } - - /* get usage page and usage */ - refCF = CFDictionaryGetValue (hidProperties, CFSTR(kIOHIDPrimaryUsagePageKey)); - if (refCF) - { - if (!CFNumberGetValue ((CFNumberRef)refCF, kCFNumberLongType, &joyInfo->usagePage)) - irr::os::Printer::log("CFNumberGetValue error getting joyInfo->usagePage", irr::ELL_ERROR); - refCF = CFDictionaryGetValue (hidProperties, CFSTR(kIOHIDPrimaryUsageKey)); - if (refCF) - if (!CFNumberGetValue ((CFNumberRef)refCF, kCFNumberLongType, &joyInfo->usage)) - irr::os::Printer::log("CFNumberGetValue error getting joyInfo->usage", irr::ELL_ERROR); - } - - if (NULL == refCF) /* get top level element HID usage page or usage */ - { - /* use top level element instead */ - CFTypeRef refCFTopElement = 0; - refCFTopElement = CFDictionaryGetValue (hidProperties, CFSTR(kIOHIDElementKey)); - { - /* refCFTopElement points to an array of element dictionaries */ - CFRange range = {0, CFArrayGetCount ((CFArrayRef)refCFTopElement)}; - CFArrayApplyFunction ((CFArrayRef)refCFTopElement, range, joystickTopLevelElementHandler, joyInfo); - } - } - - CFRelease (usbProperties); - } - else - irr::os::Printer::log("IORegistryEntryCreateCFProperties failed to create usbProperties", irr::ELL_ERROR); - - if (kIOReturnSuccess != IOObjectRelease (parent2)) - irr::os::Printer::log("IOObjectRelease failed to release parent2", irr::ELL_ERROR); - if (kIOReturnSuccess != IOObjectRelease (parent1)) - irr::os::Printer::log("IOObjectRelease failed to release parent1", irr::ELL_ERROR); - } -} - -#endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ - -//------------------------------------------------------------------------------------------ -Boolean GetDictionaryBoolean(CFDictionaryRef theDict, const void* key) -{ - // get a boolean from the dictionary - Boolean value = false; - CFBooleanRef boolRef; - boolRef = (CFBooleanRef)CFDictionaryGetValue(theDict, key); - if (boolRef != NULL) - value = CFBooleanGetValue(boolRef); - return value; -} -//------------------------------------------------------------------------------------------ -long GetDictionaryLong(CFDictionaryRef theDict, const void* key) -{ - // get a long from the dictionary - long value = 0; - CFNumberRef numRef; - numRef = (CFNumberRef)CFDictionaryGetValue(theDict, key); - if (numRef != NULL) - CFNumberGetValue(numRef, kCFNumberLongType, &value); - return value; -} - -namespace irr -{ - namespace video - { - IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& param, io::IFileSystem* io, CIrrDeviceMacOSX *device); - } -} // end namespace irr - -static bool firstLaunch = true; - -namespace irr -{ -//! constructor -CIrrDeviceMacOSX::CIrrDeviceMacOSX(const SIrrlichtCreationParameters& param) - : CIrrDeviceStub(param), Window(NULL), IsActive(true), OGLContext(NULL), CGLContext(NULL), - SoftwareDriverTarget(0), IsSoftwareRenderer(false), IsResizable(false), - IsShiftDown(false), IsControlDown(false), MouseButtonStates(0) -{ - struct utsname name; - NSString *path; - - #ifdef _DEBUG - setDebugName("CIrrDeviceMacOSX"); - #endif - - if (firstLaunch) - { - firstLaunch = false; - - [[NSAutoreleasePool alloc] init]; - [NSApplication sharedApplication]; - [NSApp setDelegate:[[[AppDelegate alloc] initWithDevice:this] autorelease]]; - [NSBundle loadNibNamed:@"MainMenu" owner:[NSApp delegate]]; - [NSApp finishLaunching]; - - path = [[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent]; - chdir([path fileSystemRepresentation]); - } - - uname(&name); - Operator = new COSOperator(name.version); - os::Printer::log(name.version,ELL_INFORMATION); - - initKeycodes(); - if (CreationParams.DriverType != video::EDT_NULL) - createWindow(); - - setResizable(false); - - CursorControl = new CCursorControl(CreationParams.WindowSize, this); - createDriver(); - - if (IsSoftwareRenderer && CreationParams.DriverType != video::EDT_NULL) - { - // create context for rendering raw bitmap - } - - createGUIAndScene(); -} - -CIrrDeviceMacOSX::~CIrrDeviceMacOSX() -{ - SetSystemUIMode(kUIModeNormal, 0); - closeDevice(); -#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) - for(u32 joystick = 0; joystick < ActiveJoysticks.size(); ++joystick) - { - if(ActiveJoysticks[joystick].interface) - closeJoystickDevice(&ActiveJoysticks[joystick]); - } -#endif -} - -void CIrrDeviceMacOSX::closeDevice() -{ - if (Window != NULL) - { - [Window setIsVisible:FALSE]; - - if (OGLContext != NULL) - { - [OGLContext clearDrawable]; - [OGLContext release]; - OGLContext = NULL; - } - - [Window setReleasedWhenClosed:TRUE]; - [Window release]; - Window = NULL; - } - else - { - if (CGLContext != NULL) - { - CGLSetCurrentContext(NULL); - CGLClearDrawable(CGLContext); - CGLDestroyContext(CGLContext); - } - } - - IsActive = false; - CGLContext = NULL; -} - -bool CIrrDeviceMacOSX::createWindow() -{ - CGDisplayErr error; - bool result; - CGDirectDisplayID display; - CGLPixelFormatObj pixelFormat; - CGRect displayRect; - CGLPixelFormatAttribute fullattribs[32]; - CFDictionaryRef displaymode, olddisplaymode; - GLint numPixelFormats, newSwapInterval; - int alphaSize = CreationParams.WithAlphaChannel?4:0, depthSize = CreationParams.ZBufferBits; - - if (CreationParams.WithAlphaChannel && (CreationParams.Bits == 32)) - alphaSize = 8; - - result = false; - display = CGMainDisplayID(); - ScreenWidth = (int) CGDisplayPixelsWide(display); - ScreenHeight = (int) CGDisplayPixelsHigh(display); - - VideoModeList.setDesktop(CreationParams.Bits, core::dimension2d<u32>(ScreenWidth, ScreenHeight)); - - if (!CreationParams.Fullscreen) - { - Window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,CreationParams.WindowSize.Width,CreationParams.WindowSize.Height) styleMask:NSTitledWindowMask+NSClosableWindowMask+NSResizableWindowMask backing:NSBackingStoreBuffered defer:FALSE]; - if (Window != NULL) - { - NSOpenGLPixelFormatAttribute windowattribs[] = - { - NSOpenGLPFANoRecovery, - NSOpenGLPFAAccelerated, - NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute)depthSize, - NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute)CreationParams.Bits, - NSOpenGLPFAAlphaSize, (NSOpenGLPixelFormatAttribute)alphaSize, - NSOpenGLPFASampleBuffers, (NSOpenGLPixelFormatAttribute)1, - NSOpenGLPFASamples, (NSOpenGLPixelFormatAttribute)CreationParams.AntiAlias, - NSOpenGLPFAStencilSize, (NSOpenGLPixelFormatAttribute)(CreationParams.Stencilbuffer?1:0), - NSOpenGLPFADoubleBuffer, - (NSOpenGLPixelFormatAttribute)nil - }; - - if (CreationParams.AntiAlias<2) - { - windowattribs[ 9] = (NSOpenGLPixelFormatAttribute)0; - windowattribs[11] = (NSOpenGLPixelFormatAttribute)0; - } - - NSOpenGLPixelFormat *format; - for (int i=0; i<3; ++i) - { - if (1==i) - { - // Second try without stencilbuffer - if (CreationParams.Stencilbuffer) - { - windowattribs[13]=(NSOpenGLPixelFormatAttribute)0; - } - else - continue; - } - else if (2==i) - { - // Third try without Doublebuffer - os::Printer::log("No doublebuffering available.", ELL_WARNING); - windowattribs[14]=(NSOpenGLPixelFormatAttribute)nil; - } - - format = [[NSOpenGLPixelFormat alloc] initWithAttributes:windowattribs]; - if (format == NULL) - { - if (CreationParams.AntiAlias>1) - { - while (!format && windowattribs[12]>1) - { - windowattribs[12] = (NSOpenGLPixelFormatAttribute)((int)windowattribs[12]-1); - format = [[NSOpenGLPixelFormat alloc] initWithAttributes:windowattribs]; - } - - if (!format) - { - windowattribs[9] = (NSOpenGLPixelFormatAttribute)0; - windowattribs[11] = (NSOpenGLPixelFormatAttribute)0; - format = [[NSOpenGLPixelFormat alloc] initWithAttributes:windowattribs]; - if (!format) - { - // reset values for next try - windowattribs[9] = (NSOpenGLPixelFormatAttribute)1; - windowattribs[11] = (NSOpenGLPixelFormatAttribute)CreationParams.AntiAlias; - } - else - { - os::Printer::log("No FSAA available.", ELL_WARNING); - } - - } - } - } - else - break; - } - CreationParams.AntiAlias = windowattribs[11]; - CreationParams.Stencilbuffer=(windowattribs[13]==1); - - if (format != NULL) - { - OGLContext = [[NSOpenGLContext alloc] initWithFormat:format shareContext:NULL]; - [format release]; - } - - if (OGLContext != NULL) - { - [Window center]; - [Window setDelegate:[NSApp delegate]]; - [OGLContext setView:[Window contentView]]; - [Window setAcceptsMouseMovedEvents:TRUE]; - [Window setIsVisible:TRUE]; - [Window makeKeyAndOrderFront:nil]; - - CGLContext = (CGLContextObj) [OGLContext CGLContextObj]; - DeviceWidth = CreationParams.WindowSize.Width; - DeviceHeight = CreationParams.WindowSize.Height; - result = true; - } - } - } - else - { - displaymode = CGDisplayBestModeForParameters(display,CreationParams.Bits,CreationParams.WindowSize.Width,CreationParams.WindowSize.Height,NULL); - if (displaymode != NULL) - { - olddisplaymode = CGDisplayCurrentMode(display); - error = CGCaptureAllDisplays(); - if (error == CGDisplayNoErr) - { - error = CGDisplaySwitchToMode(display,displaymode); - if (error == CGDisplayNoErr) - { - pixelFormat = NULL; - numPixelFormats = 0; - - int index = 0; - fullattribs[index++] = kCGLPFAFullScreen; - fullattribs[index++] = kCGLPFADisplayMask; - fullattribs[index++] = (CGLPixelFormatAttribute)CGDisplayIDToOpenGLDisplayMask(display); - fullattribs[index++] = kCGLPFADoubleBuffer; - fullattribs[index++] = kCGLPFAAccelerated; - fullattribs[index++] = kCGLPFADepthSize; - fullattribs[index++] = (CGLPixelFormatAttribute)depthSize; - fullattribs[index++] = kCGLPFAColorSize; - fullattribs[index++] = (CGLPixelFormatAttribute)CreationParams.Bits; - fullattribs[index++] = kCGLPFAAlphaSize; - fullattribs[index++] = (CGLPixelFormatAttribute)alphaSize; - - if (CreationParams.AntiAlias) - { - fullattribs[index++] = kCGLPFASampleBuffers; - fullattribs[index++] = (CGLPixelFormatAttribute)1; - fullattribs[index++] = kCGLPFASamples; - fullattribs[index++] = (CGLPixelFormatAttribute)CreationParams.AntiAlias; - } - - if (CreationParams.Stencilbuffer) - { - fullattribs[index++] = kCGLPFAStencilSize; - fullattribs[index++] = (CGLPixelFormatAttribute)1; - } - - fullattribs[index++] = (CGLPixelFormatAttribute)NULL; - CGLChoosePixelFormat(fullattribs,&pixelFormat,&numPixelFormats); - - if (pixelFormat != NULL) - { - CGLCreateContext(pixelFormat,NULL,&CGLContext); - CGLDestroyPixelFormat(pixelFormat); - } - - if (CGLContext != NULL) - { - CGLSetFullScreen(CGLContext); - displayRect = CGDisplayBounds(display); - ScreenWidth = DeviceWidth = (int)displayRect.size.width; - ScreenHeight = DeviceHeight = (int)displayRect.size.height; - result = true; - } - } - } - } - } - - if (result) - { - if (Window == NULL) - SetSystemUIMode(kUIModeAllHidden, kUIOptionAutoShowMenuBar); - CGLSetCurrentContext(CGLContext); - newSwapInterval = (CreationParams.Vsync) ? 1 : 0; - CGLSetParameter(CGLContext,kCGLCPSwapInterval,&newSwapInterval); - glViewport(0,0,DeviceWidth,DeviceHeight); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - } - - return (result); -} - -void CIrrDeviceMacOSX::setResize(int width, int height) -{ - // set new window size - DeviceWidth = width; - DeviceHeight = height; - - // update the size of the opengl rendering context - [OGLContext update]; - - // resize the driver to the inner pane size - NSRect driverFrame = [Window contentRectForFrameRect:[Window frame]]; - getVideoDriver()->OnResize(core::dimension2d<u32>( (s32)driverFrame.size.width, (s32)driverFrame.size.height)); -} - -void CIrrDeviceMacOSX::createDriver() -{ - switch (CreationParams.DriverType) - { - case video::EDT_SOFTWARE: - #ifdef _IRR_COMPILE_WITH_SOFTWARE_ - VideoDriver = video::createSoftwareDriver(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this); - IsSoftwareRenderer = true; - #else - os::Printer::log("No Software driver support compiled in.", ELL_ERROR); - #endif - break; - - case video::EDT_BURNINGSVIDEO: - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - VideoDriver = video::createSoftwareDriver2(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this); - IsSoftwareRenderer = true; - #else - os::Printer::log("Burning's video driver was not compiled in.", ELL_ERROR); - #endif - break; - - case video::EDT_OPENGL: - #ifdef _IRR_COMPILE_WITH_OPENGL_ - VideoDriver = video::createOpenGLDriver(CreationParams, FileSystem, this); - #else - os::Printer::log("No OpenGL support compiled in.", ELL_ERROR); - #endif - break; - - case video::EDT_DIRECT3D8: - case video::EDT_DIRECT3D9: - os::Printer::log("This driver is not available in OSX. Try OpenGL or Software renderer.", ELL_ERROR); - break; - - case video::EDT_NULL: - VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize); - break; - - default: - os::Printer::log("Unable to create video driver of unknown type.", ELL_ERROR); - break; - } - -} - -void CIrrDeviceMacOSX::flush() -{ - if (CGLContext != NULL) - { - glFinish(); - CGLFlushDrawable(CGLContext); - } -} - -bool CIrrDeviceMacOSX::run() -{ - NSEvent *event; - irr::SEvent ievent; - - os::Timer::tick(); - storeMouseLocation(); - - event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:nil inMode:NSDefaultRunLoopMode dequeue:YES]; - if (event != nil) - { - bzero(&ievent,sizeof(ievent)); - - switch([(NSEvent *)event type]) - { - case NSKeyDown: - postKeyEvent(event,ievent,true); - break; - - case NSKeyUp: - postKeyEvent(event,ievent,false); - break; - - case NSFlagsChanged: - ievent.EventType = irr::EET_KEY_INPUT_EVENT; - ievent.KeyInput.Shift = ([(NSEvent *)event modifierFlags] & NSShiftKeyMask ) != 0; - ievent.KeyInput.Control = ([(NSEvent *)event modifierFlags] & NSControlKeyMask) != 0; - - if (IsShiftDown != ievent.KeyInput.Shift) - { - ievent.KeyInput.Char = irr::KEY_SHIFT; - ievent.KeyInput.Key = irr::KEY_SHIFT; - ievent.KeyInput.PressedDown = ievent.KeyInput.Shift; - - IsShiftDown = ievent.KeyInput.Shift; - - postEventFromUser(ievent); - } - - if (IsControlDown != ievent.KeyInput.Control) - { - ievent.KeyInput.Char = irr::KEY_CONTROL; - ievent.KeyInput.Key = irr::KEY_CONTROL; - ievent.KeyInput.PressedDown = ievent.KeyInput.Control; - - IsControlDown = ievent.KeyInput.Control; - - postEventFromUser(ievent); - } - - [NSApp sendEvent:event]; - break; - - case NSLeftMouseDown: - ievent.EventType = irr::EET_MOUSE_INPUT_EVENT; - ievent.MouseInput.Event = irr::EMIE_LMOUSE_PRESSED_DOWN; - MouseButtonStates |= irr::EMBSM_LEFT; - ievent.MouseInput.ButtonStates = MouseButtonStates; - postMouseEvent(event,ievent); - break; - - case NSLeftMouseUp: - ievent.EventType = irr::EET_MOUSE_INPUT_EVENT; - MouseButtonStates &= !irr::EMBSM_LEFT; - ievent.MouseInput.ButtonStates = MouseButtonStates; - ievent.MouseInput.Event = irr::EMIE_LMOUSE_LEFT_UP; - postMouseEvent(event,ievent); - break; - - case NSOtherMouseDown: - ievent.EventType = irr::EET_MOUSE_INPUT_EVENT; - ievent.MouseInput.Event = irr::EMIE_MMOUSE_PRESSED_DOWN; - MouseButtonStates |= irr::EMBSM_MIDDLE; - ievent.MouseInput.ButtonStates = MouseButtonStates; - postMouseEvent(event,ievent); - break; - - case NSOtherMouseUp: - ievent.EventType = irr::EET_MOUSE_INPUT_EVENT; - MouseButtonStates &= !irr::EMBSM_MIDDLE; - ievent.MouseInput.ButtonStates = MouseButtonStates; - ievent.MouseInput.Event = irr::EMIE_MMOUSE_LEFT_UP; - postMouseEvent(event,ievent); - break; - - case NSMouseMoved: - case NSLeftMouseDragged: - case NSRightMouseDragged: - case NSOtherMouseDragged: - ievent.EventType = irr::EET_MOUSE_INPUT_EVENT; - ievent.MouseInput.Event = irr::EMIE_MOUSE_MOVED; - ievent.MouseInput.ButtonStates = MouseButtonStates; - postMouseEvent(event,ievent); - break; - - case NSRightMouseDown: - ievent.EventType = irr::EET_MOUSE_INPUT_EVENT; - ievent.MouseInput.Event = irr::EMIE_RMOUSE_PRESSED_DOWN; - MouseButtonStates |= irr::EMBSM_RIGHT; - ievent.MouseInput.ButtonStates = MouseButtonStates; - postMouseEvent(event,ievent); - break; - - case NSRightMouseUp: - ievent.EventType = irr::EET_MOUSE_INPUT_EVENT; - ievent.MouseInput.Event = irr::EMIE_RMOUSE_LEFT_UP; - MouseButtonStates &= !irr::EMBSM_RIGHT; - ievent.MouseInput.ButtonStates = MouseButtonStates; - postMouseEvent(event,ievent); - break; - - case NSScrollWheel: - ievent.EventType = irr::EET_MOUSE_INPUT_EVENT; - ievent.MouseInput.Event = irr::EMIE_MOUSE_WHEEL; - ievent.MouseInput.Wheel = [(NSEvent *)event deltaY]; - if (ievent.MouseInput.Wheel < 1.0f) ievent.MouseInput.Wheel *= 10.0f; - else ievent.MouseInput.Wheel *= 5.0f; - postMouseEvent(event,ievent); - break; - - default: - [NSApp sendEvent:event]; - break; - } - } - - pollJoysticks(); - - return (![[NSApp delegate] isQuit] && IsActive); -} - -//! Pause the current process for the minimum time allowed only to allow other processes to execute -void CIrrDeviceMacOSX::yield() -{ - // TODO: Does this work or maybe is there a better way? - struct timespec ts = {0,0}; - nanosleep(&ts, NULL); -} - -//! Pause execution and let other processes to run for a specified amount of time. -void CIrrDeviceMacOSX::sleep(u32 timeMs, bool pauseTimer=false) -{ - // TODO: Does this work or maybe is there a better way? - - bool wasStopped = Timer ? Timer->isStopped() : true; - - struct timespec ts; - ts.tv_sec = (time_t) (timeMs / 1000); - ts.tv_nsec = (long) (timeMs % 1000) * 1000000; - - if (pauseTimer && !wasStopped) - Timer->stop(); - - nanosleep(&ts, NULL); - - if (pauseTimer && !wasStopped) - Timer->start(); -} - -void CIrrDeviceMacOSX::setWindowCaption(const wchar_t* text) -{ - size_t size; - char title[1024]; - - if (Window != NULL) - { - size = wcstombs(title,text,1024); - if (size == 1024) title[1023] = 0; - [Window setTitle:[NSString stringWithCString:title length:size]]; - } -} - - -bool CIrrDeviceMacOSX::isWindowActive() const -{ - return (IsActive); -} - - -bool CIrrDeviceMacOSX::isWindowFocused() const -{ - if (Window != NULL) - return [Window isKeyWindow]; - return false; -} - - -bool CIrrDeviceMacOSX::isWindowMinimized() const -{ - if (Window != NULL) - return [Window isMiniaturized]; - return false; -} - - -void CIrrDeviceMacOSX::postKeyEvent(void *event,irr::SEvent &ievent,bool pressed) -{ - NSString *str; - std::map<int,int>::const_iterator iter; - unsigned int result,c,mkey,mchar; - const unsigned char *cStr; - BOOL skipCommand; - - str = [(NSEvent *)event characters]; - if (str != nil && [str length] > 0) - { - mkey = mchar = 0; - skipCommand = false; - c = [str characterAtIndex:0]; - - iter = KeyCodes.find(c); - if (iter != KeyCodes.end()) - mkey = (*iter).second; - else - { - // workaround for period character - if (c == 0x2E) - { - mkey = irr::KEY_PERIOD; - mchar = '.'; - } - else - { - cStr = (unsigned char *)[str cStringUsingEncoding:NSWindowsCP1252StringEncoding]; - if (cStr != NULL && strlen((char*)cStr) > 0) - { - mchar = cStr[0]; - mkey = toupper(mchar); - if ([(NSEvent *)event modifierFlags] & NSCommandKeyMask) - { - if (mkey == 'C' || mkey == 'V' || mkey == 'X') - { - mchar = 0; - skipCommand = true; - } - } - } - } - } - - ievent.EventType = irr::EET_KEY_INPUT_EVENT; - ievent.KeyInput.Key = (irr::EKEY_CODE)mkey; - ievent.KeyInput.PressedDown = pressed; - ievent.KeyInput.Shift = ([(NSEvent *)event modifierFlags] & NSShiftKeyMask) != 0; - ievent.KeyInput.Control = ([(NSEvent *)event modifierFlags] & NSControlKeyMask) != 0; - ievent.KeyInput.Char = mchar; - - if (skipCommand) - ievent.KeyInput.Control = true; - else if ([(NSEvent *)event modifierFlags] & NSCommandKeyMask) - [NSApp sendEvent:(NSEvent *)event]; - - postEventFromUser(ievent); - } -} - -void CIrrDeviceMacOSX::postMouseEvent(void *event,irr::SEvent &ievent) -{ - bool post = true; - - if (Window != NULL) - { - ievent.MouseInput.X = (int)[(NSEvent *)event locationInWindow].x; - ievent.MouseInput.Y = DeviceHeight - (int)[(NSEvent *)event locationInWindow].y; - - if (ievent.MouseInput.Y < 0) - post = false; - } - else - { - ievent.MouseInput.X = (int)[NSEvent mouseLocation].x; - ievent.MouseInput.Y = DeviceHeight - (int)[NSEvent mouseLocation].y; - } - - if (post) - postEventFromUser(ievent); - - [NSApp sendEvent:(NSEvent *)event]; -} - -void CIrrDeviceMacOSX::storeMouseLocation() -{ - NSPoint p; - int x,y; - - p = [NSEvent mouseLocation]; - - if (Window != NULL) - { - p = [Window convertScreenToBase:p]; - x = (int)p.x; - y = DeviceHeight - (int)p.y; - } - else - { - x = (int)p.x; - y = (int)p.y; - y -= (ScreenHeight - DeviceHeight); - } - - ((CCursorControl *)CursorControl)->updateInternalCursorPosition(x,y); -} - - -void CIrrDeviceMacOSX::setMouseLocation(int x,int y) -{ - NSPoint p; - CGPoint c; - - if (Window != NULL) - { - // Irrlicht window exists - p.x = (float) x; - p.y = (float) (DeviceHeight - y); - p = [Window convertBaseToScreen:p]; - p.y = ScreenHeight - p.y; - } - else - { - p.x = (float) x; - p.y = (float) y + (ScreenHeight - DeviceHeight); - } - - c.x = p.x; - c.y = p.y; - CGSetLocalEventsSuppressionInterval(0); - CGWarpMouseCursorPosition(c); -} - - -void CIrrDeviceMacOSX::setCursorVisible(bool visible) -{ - CGDirectDisplayID display; - - display = CGMainDisplayID(); - if (visible) - CGDisplayShowCursor(display); - else - CGDisplayHideCursor(display); -} - - -void CIrrDeviceMacOSX::initKeycodes() -{ - KeyCodes[NSUpArrowFunctionKey] = irr::KEY_UP; - KeyCodes[NSDownArrowFunctionKey] = irr::KEY_DOWN; - KeyCodes[NSLeftArrowFunctionKey] = irr::KEY_LEFT; - KeyCodes[NSRightArrowFunctionKey] = irr::KEY_RIGHT; - KeyCodes[NSF1FunctionKey] = irr::KEY_F1; - KeyCodes[NSF2FunctionKey] = irr::KEY_F2; - KeyCodes[NSF3FunctionKey] = irr::KEY_F3; - KeyCodes[NSF4FunctionKey] = irr::KEY_F4; - KeyCodes[NSF5FunctionKey] = irr::KEY_F5; - KeyCodes[NSF6FunctionKey] = irr::KEY_F6; - KeyCodes[NSF7FunctionKey] = irr::KEY_F7; - KeyCodes[NSF8FunctionKey] = irr::KEY_F8; - KeyCodes[NSF9FunctionKey] = irr::KEY_F9; - KeyCodes[NSF10FunctionKey] = irr::KEY_F10; - KeyCodes[NSF11FunctionKey] = irr::KEY_F11; - KeyCodes[NSF12FunctionKey] = irr::KEY_F12; - KeyCodes[NSF13FunctionKey] = irr::KEY_F13; - KeyCodes[NSF14FunctionKey] = irr::KEY_F14; - KeyCodes[NSF15FunctionKey] = irr::KEY_F15; - KeyCodes[NSF16FunctionKey] = irr::KEY_F16; - KeyCodes[NSHomeFunctionKey] = irr::KEY_HOME; - KeyCodes[NSEndFunctionKey] = irr::KEY_END; - KeyCodes[NSInsertFunctionKey] = irr::KEY_INSERT; - KeyCodes[NSDeleteFunctionKey] = irr::KEY_DELETE; - KeyCodes[NSHelpFunctionKey] = irr::KEY_HELP; - KeyCodes[NSSelectFunctionKey] = irr::KEY_SELECT; - KeyCodes[NSPrintFunctionKey] = irr::KEY_PRINT; - KeyCodes[NSExecuteFunctionKey] = irr::KEY_EXECUT; - KeyCodes[NSPrintScreenFunctionKey] = irr::KEY_SNAPSHOT; - KeyCodes[NSPauseFunctionKey] = irr::KEY_PAUSE; - KeyCodes[NSScrollLockFunctionKey] = irr::KEY_SCROLL; - KeyCodes[0x7F] = irr::KEY_BACK; - KeyCodes[0x09] = irr::KEY_TAB; - KeyCodes[0x0D] = irr::KEY_RETURN; - KeyCodes[0x03] = irr::KEY_RETURN; - KeyCodes[0x1B] = irr::KEY_ESCAPE; -} - - - -//! Sets if the window should be resizable in windowed mode. -void CIrrDeviceMacOSX::setResizable(bool resize) -{ - IsResizable = resize; -} - -bool CIrrDeviceMacOSX::isResizable() const -{ - return IsResizable; -} - -void CIrrDeviceMacOSX::minimizeWindow() -{ - // todo: implement -} - -//! Maximizes the window if possible. -void CIrrDeviceMacOSX::maximizeWindow() -{ - // todo: implement -} - -//! Restore the window to normal size if possible. -void CIrrDeviceMacOSX::restoreWindow() -{ - // todo: implement -} - -bool CIrrDeviceMacOSX::present(video::IImage* surface, void* windowId, core::rect<s32>* src ) -{ - // todo: implement window ID and src rectangle - - if (!surface) - return false; - - if (IsSoftwareRenderer) - { - // do we need to change the size? - bool updateSize = !SoftwareDriverTarget || - s32([SoftwareDriverTarget size].width) != surface->getDimension().Width || - s32([SoftwareDriverTarget size].height) != surface->getDimension().Height; - - // release if necessary - if (SoftwareDriverTarget && updateSize) - [SoftwareDriverTarget release]; - - NSRect areaRect = NSMakeRect(0.0, 0.0, surface->getDimension().Width, surface->getDimension().Height); - - // get pointer to image data - unsigned char* imgData = (unsigned char*)surface->lock(); - - // create / update the target - if (updateSize) - { - // allocate target for IImage - SoftwareDriverTarget = [[NSBitmapImageRep alloc] - initWithBitmapDataPlanes: nil - pixelsWide: areaRect.size.width - pixelsHigh: areaRect.size.height - bitsPerSample: 8 - samplesPerPixel: 3 - hasAlpha: NO - isPlanar: NO - colorSpaceName: NSCalibratedRGBColorSpace - bytesPerRow: (3 * areaRect.size.width) - bitsPerPixel: 24]; - } - - const u32 destwidth = areaRect.size.width; - const u32 minWidth = core::min_(surface->getDimension().Width, destwidth); - const u32 destPitch = (3 * areaRect.size.width); - - u8* srcdata = reinterpret_cast<u8*>(imgData); - u8* destData = reinterpret_cast<u8*>([SoftwareDriverTarget bitmapData]); - const u32 destheight = areaRect.size.height; - const u32 srcheight = core::min_(surface->getDimension().Height, destheight); - const u32 srcPitch = surface->getPitch(); - for (u32 y=0; y!=srcheight; ++y) - { - video::CColorConverter::convert_viaFormat(srcdata, surface->getColorFormat(), minWidth, destData, video::ECF_R8G8B8); - srcdata += srcPitch; - destData += destPitch; - } - - // unlock the data - surface->unlock(); - - // todo: draw properly into a sub-view - [SoftwareDriverTarget draw]; - } - - return false; -} - -#if defined (_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) -static void joystickRemovalCallback(void * target, - IOReturn result, - void * refcon, - void * sender) -{ - JoystickInfo *joy = (JoystickInfo *) refcon; - joy->removed = 1; -} -#endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ - - -bool CIrrDeviceMacOSX::activateJoysticks(core::array<SJoystickInfo> & joystickInfo) -{ -#if defined (_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) - ActiveJoysticks.clear(); - joystickInfo.clear(); - - io_object_t hidObject = 0; - io_iterator_t hidIterator = 0; - IOReturn result = kIOReturnSuccess; - mach_port_t masterPort = 0; - CFMutableDictionaryRef hidDictionaryRef = NULL; - - result = IOMasterPort (bootstrap_port, &masterPort); - if (kIOReturnSuccess != result) - { - os::Printer::log("initialiseJoysticks IOMasterPort failed", ELL_ERROR); - return false; - } - - hidDictionaryRef = IOServiceMatching (kIOHIDDeviceKey); - if (!hidDictionaryRef) - { - os::Printer::log("initialiseJoysticks IOServiceMatching failed", ELL_ERROR); - return false; - } - result = IOServiceGetMatchingServices (masterPort, hidDictionaryRef, &hidIterator); - - if (kIOReturnSuccess != result) - { - os::Printer::log("initialiseJoysticks IOServiceGetMatchingServices failed", ELL_ERROR); - return false; - } - - //no joysticks just return - if (!hidIterator) - return false; - - while ((hidObject = IOIteratorNext (hidIterator))) - { - JoystickInfo info; - - // get dictionary for HID properties - CFMutableDictionaryRef hidProperties = 0; - - kern_return_t kern_result = IORegistryEntryCreateCFProperties (hidObject, &hidProperties, kCFAllocatorDefault, kNilOptions); - if ((kern_result == KERN_SUCCESS) && hidProperties) - { - HRESULT plugInResult = S_OK; - SInt32 score = 0; - IOCFPlugInInterface ** ppPlugInInterface = NULL; - result = IOCreatePlugInInterfaceForService (hidObject, kIOHIDDeviceUserClientTypeID, - kIOCFPlugInInterfaceID, &ppPlugInInterface, &score); - if (kIOReturnSuccess == result) - { - plugInResult = (*ppPlugInInterface)->QueryInterface (ppPlugInInterface, - CFUUIDGetUUIDBytes (kIOHIDDeviceInterfaceID), (void **) &(info.interface)); - if (plugInResult != S_OK) - os::Printer::log("initialiseJoysticks query HID class device interface failed", ELL_ERROR); - (*ppPlugInInterface)->Release(ppPlugInInterface); - } - else - continue; - - if (info.interface != NULL) - { - result = (*(info.interface))->open (info.interface, 0); - if (result == kIOReturnSuccess) - { - (*(info.interface))->setRemovalCallback (info.interface, joystickRemovalCallback, &info, &info); - getJoystickDeviceInfo(hidObject, hidProperties, &info); - - // get elements - CFTypeRef refElementTop = CFDictionaryGetValue (hidProperties, CFSTR(kIOHIDElementKey)); - if (refElementTop) - { - CFTypeID type = CFGetTypeID (refElementTop); - if (type == CFArrayGetTypeID()) - { - CFRange range = {0, CFArrayGetCount ((CFArrayRef)refElementTop)}; - info.numActiveJoysticks = ActiveJoysticks.size(); - CFArrayApplyFunction ((CFArrayRef)refElementTop, range, getJoystickComponentArrayHandler, &info); - } - } - } - else - { - CFRelease (hidProperties); - os::Printer::log("initialiseJoysticks Open interface failed", ELL_ERROR); - continue; - } - - CFRelease (hidProperties); - - result = IOObjectRelease (hidObject); - - if ( (info.usagePage != kHIDPage_GenericDesktop) || - ((info.usage != kHIDUsage_GD_Joystick && - info.usage != kHIDUsage_GD_GamePad && - info.usage != kHIDUsage_GD_MultiAxisController)) ) - { - closeJoystickDevice (&info); - continue; - } - - for (u32 i = 0; i < 6; i++) - info.persistentData.JoystickEvent.Axis[i] = 0; - - ActiveJoysticks.push_back(info); - - SJoystickInfo returnInfo; - returnInfo.Axes = info.axes; - //returnInfo.Hats = info.hats; - returnInfo.Buttons = info.buttons; - returnInfo.Name = info.joystickName; - returnInfo.PovHat = SJoystickInfo::POV_HAT_UNKNOWN; - - //if (info.hatComp.size()) - // returnInfo.PovHat = SJoystickInfo::POV_HAT_PRESENT; - //else - // returnInfo.PovHat = SJoystickInfo::POV_HAT_ABSENT; - - joystickInfo.push_back(returnInfo); - } - - } - else - { - continue; - } - } - result = IOObjectRelease (hidIterator); - - return true; -#endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ - - return false; -} - -void CIrrDeviceMacOSX::pollJoysticks() -{ -#if defined (_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) - if(0 == ActiveJoysticks.size()) - return; - - u32 joystick; - for (joystick = 0; joystick < ActiveJoysticks.size(); ++joystick) - { - if (ActiveJoysticks[joystick].removed) - continue; - - bool found = false; - ActiveJoysticks[joystick].persistentData.JoystickEvent.Joystick = joystick; - - if (ActiveJoysticks[joystick].interface) - { - for (u32 n = 0; n < ActiveJoysticks[joystick].axisComp.size(); n++) - { - IOReturn result = kIOReturnSuccess; - IOHIDEventStruct hidEvent; - hidEvent.value = 0; - result = (*(ActiveJoysticks[joystick].interface))->getElementValue(ActiveJoysticks[joystick].interface, ActiveJoysticks[joystick].axisComp[n].cookie, &hidEvent); - if (kIOReturnSuccess == result) - { - const f32 min = -32768.0f; - const f32 max = 32767.0f; - const f32 deviceScale = max - min; - const f32 readScale = (f32)ActiveJoysticks[joystick].axisComp[n].maxRead - (f32)ActiveJoysticks[joystick].axisComp[n].minRead; - - if (hidEvent.value < ActiveJoysticks[joystick].axisComp[n].minRead) - ActiveJoysticks[joystick].axisComp[n].minRead = hidEvent.value; - if (hidEvent.value > ActiveJoysticks[joystick].axisComp[n].maxRead) - ActiveJoysticks[joystick].axisComp[n].maxRead = hidEvent.value; - - if (readScale != 0.0f) - hidEvent.value = (int)(((f32)((f32)hidEvent.value - (f32)ActiveJoysticks[joystick].axisComp[n].minRead) * deviceScale / readScale) + min); - - if (ActiveJoysticks[joystick].persistentData.JoystickEvent.Axis[n] != (s16)hidEvent.value) - found = true; - ActiveJoysticks[joystick].persistentData.JoystickEvent.Axis[n] = (s16)hidEvent.value; - } - }//axis check - - for (u32 n = 0; n < ActiveJoysticks[joystick].buttonComp.size(); n++) - { - IOReturn result = kIOReturnSuccess; - IOHIDEventStruct hidEvent; - hidEvent.value = 0; - result = (*(ActiveJoysticks[joystick].interface))->getElementValue(ActiveJoysticks[joystick].interface, ActiveJoysticks[joystick].buttonComp[n].cookie, &hidEvent); - if (kIOReturnSuccess == result) - { - u32 ButtonStates = 0; - - if (hidEvent.value && !((ActiveJoysticks[joystick].persistentData.JoystickEvent.ButtonStates & (1 << n)) ? true : false) ) - found = true; - else if (!hidEvent.value && ((ActiveJoysticks[joystick].persistentData.JoystickEvent.ButtonStates & (1 << n)) ? true : false)) - found = true; - - if (hidEvent.value) - ActiveJoysticks[joystick].persistentData.JoystickEvent.ButtonStates |= (1 << n); - else - ActiveJoysticks[joystick].persistentData.JoystickEvent.ButtonStates &= ~(1 << n); - } - }//button check - //still ToDo..will be done soon :) -/* - for (u32 n = 0; n < ActiveJoysticks[joystick].hatComp.size(); n++) - { - IOReturn result = kIOReturnSuccess; - IOHIDEventStruct hidEvent; - hidEvent.value = 0; - result = (*(ActiveJoysticks[joystick].interface))->getElementValue(ActiveJoysticks[joystick].interface, ActiveJoysticks[joystick].hatComp[n].cookie, &hidEvent); - if (kIOReturnSuccess == result) - { - if (ActiveJoysticks[joystick].persistentData.JoystickEvent.POV != hidEvent.value) - found = true; - ActiveJoysticks[joystick].persistentData.JoystickEvent.POV = hidEvent.value; - } - }//hat check -*/ - } - - if (found) - postEventFromUser(ActiveJoysticks[joystick].persistentData); - } -#endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ -} - -video::IVideoModeList* CIrrDeviceMacOSX::getVideoModeList() -{ - if (!VideoModeList.getVideoModeCount()) - { - CGDirectDisplayID display; - display = CGMainDisplayID(); - - CFArrayRef availableModes = CGDisplayAvailableModes(display); - unsigned int numberOfAvailableModes = CFArrayGetCount(availableModes); - for (u32 i= 0; i<numberOfAvailableModes; ++i) - { - // look at each mode in the available list - CFDictionaryRef mode = (CFDictionaryRef)CFArrayGetValueAtIndex(availableModes, i); - long bitsPerPixel = GetDictionaryLong(mode, kCGDisplayBitsPerPixel); - Boolean safeForHardware = GetDictionaryBoolean(mode, kCGDisplayModeIsSafeForHardware); - Boolean stretched = GetDictionaryBoolean(mode, kCGDisplayModeIsStretched); - - if (!safeForHardware) - continue; - - long width = GetDictionaryLong(mode, kCGDisplayWidth); - long height = GetDictionaryLong(mode, kCGDisplayHeight); - // long refresh = GetDictionaryLong((mode), kCGDisplayRefreshRate); - VideoModeList.addMode(core::dimension2d<u32>(width, height), - bitsPerPixel); - } - } - return &VideoModeList; -} - -} // end namespace - -#endif // _IRR_COMPILE_WITH_OSX_DEVICE_ diff --git a/irrlicht-1.6/source/Irrlicht/MacOSX/DemoApp-Info.plist b/irrlicht-1.6/source/Irrlicht/MacOSX/DemoApp-Info.plist deleted file mode 100644 index a754c7f5e..000000000 --- a/irrlicht-1.6/source/Irrlicht/MacOSX/DemoApp-Info.plist +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> -<plist version="1.0"> -<dict> - <key>CFBundleDevelopmentRegion</key> - <string>English</string> - <key>CFBundleExecutable</key> - <string>${EXECUTABLE_NAME}</string> - <key>CFBundleIdentifier</key> - <string>com.irrlicht.${EXECUTABLE_NAME}</string> - <key>CFBundleInfoDictionaryVersion</key> - <string>6.0</string> - <key>CFBundlePackageType</key> - <string>APPL</string> - <key>CFBundleSignature</key> - <string>IRRL</string> - <key>CFBundleVersion</key> - <string>1.0</string> - <key>NSMainNibFile</key> - <string>MainMenu</string> - <key>NSPrincipalClass</key> - <string>NSApplication</string> -</dict> -</plist> diff --git a/irrlicht-1.6/source/Irrlicht/MacOSX/Irrlicht-Info.plist b/irrlicht-1.6/source/Irrlicht/MacOSX/Irrlicht-Info.plist deleted file mode 100644 index fd4ba5126..000000000 --- a/irrlicht-1.6/source/Irrlicht/MacOSX/Irrlicht-Info.plist +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> -<plist version="1.0"> -<dict> - <key>CFBundleDevelopmentRegion</key> - <string>English</string> - <key>CFBundleExecutable</key> - <string>${EXECUTABLE_NAME}</string> - <key>CFBundleIdentifier</key> - <string>org.irrlichtengine.${PRODUCT_NAME:identifier}</string> - <key>CFBundleInfoDictionaryVersion</key> - <string>6.0</string> - <key>CFBundlePackageType</key> - <string>FMWK</string> - <key>CFBundleSignature</key> - <string>????</string> - <key>CFBundleVersion</key> - <string>1.6</string> -</dict> -</plist> diff --git a/irrlicht-1.6/source/Irrlicht/MacOSX/MacOSX.xcodeproj/project.pbxproj b/irrlicht-1.6/source/Irrlicht/MacOSX/MacOSX.xcodeproj/project.pbxproj deleted file mode 100644 index 425d89978..000000000 --- a/irrlicht-1.6/source/Irrlicht/MacOSX/MacOSX.xcodeproj/project.pbxproj +++ /dev/null @@ -1,5752 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 42; - objects = { - -/* Begin PBXAggregateTarget section */ - B81CFFC6097FE9980057C06F /* All */ = { - isa = PBXAggregateTarget; - buildConfigurationList = B81CFFE8097FE9C30057C06F /* Build configuration list for PBXAggregateTarget "All" */; - buildPhases = ( - ); - dependencies = ( - 0946CCD90EC99D8C00D945A5 /* PBXTargetDependency */, - 0946CCD60EC99D8200D945A5 /* PBXTargetDependency */, - 09F649720D2CE2A1001E0599 /* PBXTargetDependency */, - 09F649450D2CE100001E0599 /* PBXTargetDependency */, - 09F649210D2CDFF0001E0599 /* PBXTargetDependency */, - 4CA5CB9A0A4868B500ADB3D7 /* PBXTargetDependency */, - 4CA5CB980A4868B500ADB3D7 /* PBXTargetDependency */, - 4CA5CB960A4868B500ADB3D7 /* PBXTargetDependency */, - 4CA5CB940A4868B500ADB3D7 /* PBXTargetDependency */, - 4CA5CB920A4868B500ADB3D7 /* PBXTargetDependency */, - 4CA5CB900A4868B500ADB3D7 /* PBXTargetDependency */, - 4CA5CB8E0A4868B500ADB3D7 /* PBXTargetDependency */, - 4CA5CB8C0A4868B500ADB3D7 /* PBXTargetDependency */, - 4CA5CB8A0A4868B500ADB3D7 /* PBXTargetDependency */, - 4CA5CB880A4868B500ADB3D7 /* PBXTargetDependency */, - 4CA5CB860A4868B500ADB3D7 /* PBXTargetDependency */, - 4CA5CB840A4868B500ADB3D7 /* PBXTargetDependency */, - 4CA5CB820A4868B500ADB3D7 /* PBXTargetDependency */, - ); - name = All; - productName = ALL; - }; -/* End PBXAggregateTarget section */ - -/* Begin PBXBuildFile section */ - 09022C560EA0E97F00CD54EE /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 4C53E1650A484C2C0014E966 /* MainMenu.nib */; }; - 09022C570EA0E97F00CD54EE /* DemoApp-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4C53E38E0A4855BA0014E966 /* DemoApp-Info.plist */; }; - 09022C5B0EA0E97F00CD54EE /* libIrrlicht.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E24D0A4850120014E966 /* libIrrlicht.a */; }; - 09022C5C0EA0E97F00CD54EE /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E26D0A4850D60014E966 /* Cocoa.framework */; }; - 09022C5D0EA0E97F00CD54EE /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E26E0A4850D60014E966 /* OpenGL.framework */; }; - 09022C5E0EA0E97F00CD54EE /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0925113D0D744ADE006784D9 /* Carbon.framework */; }; - 09022C7E0EA0EA9D00CD54EE /* CGUIAttributeEditor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 09022C690EA0EA9D00CD54EE /* CGUIAttributeEditor.cpp */; }; - 09022C7F0EA0EA9D00CD54EE /* CGUIEditFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 09022C6E0EA0EA9D00CD54EE /* CGUIEditFactory.cpp */; }; - 09022C800EA0EA9D00CD54EE /* CGUIEditWindow.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 09022C700EA0EA9D00CD54EE /* CGUIEditWindow.cpp */; }; - 09022C810EA0EA9D00CD54EE /* CGUIEditWorkspace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 09022C720EA0EA9D00CD54EE /* CGUIEditWorkspace.cpp */; }; - 09022C820EA0EA9D00CD54EE /* CGUIPanel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 09022C750EA0EA9D00CD54EE /* CGUIPanel.cpp */; }; - 09022C830EA0EA9D00CD54EE /* CGUITextureCacheBrowser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 09022C790EA0EA9D00CD54EE /* CGUITextureCacheBrowser.cpp */; }; - 09022C840EA0EA9D00CD54EE /* CMemoryReadWriteFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 09022C7B0EA0EA9D00CD54EE /* CMemoryReadWriteFile.cpp */; }; - 09022C850EA0EA9D00CD54EE /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 09022C7D0EA0EA9D00CD54EE /* main.cpp */; }; - 090FBC820D31085E0076D847 /* CVolumeLightSceneNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 090FBC800D31085E0076D847 /* CVolumeLightSceneNode.cpp */; }; - 090FBC830D31085E0076D847 /* CVolumeLightSceneNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 090FBC810D31085E0076D847 /* CVolumeLightSceneNode.h */; }; - 0910B9DE0D1F5D4100D46B04 /* CBurningShader_Raster_Reference.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0910B9D90D1F5D4100D46B04 /* CBurningShader_Raster_Reference.cpp */; }; - 0910B9DF0D1F5D4100D46B04 /* CGUITable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0910B9DA0D1F5D4100D46B04 /* CGUITable.cpp */; }; - 0910B9E00D1F5D4100D46B04 /* CGUITable.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910B9DB0D1F5D4100D46B04 /* CGUITable.h */; }; - 0910B9E10D1F5D4100D46B04 /* CImageLoaderWAL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0910B9DC0D1F5D4100D46B04 /* CImageLoaderWAL.cpp */; }; - 0910B9E20D1F5D4100D46B04 /* CImageLoaderWAL.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910B9DD0D1F5D4100D46B04 /* CImageLoaderWAL.h */; }; - 0910BA240D1F64B300D46B04 /* CMeshBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910B9FD0D1F64B300D46B04 /* CMeshBuffer.h */; }; - 0910BA250D1F64B300D46B04 /* coreutil.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910B9FE0D1F64B300D46B04 /* coreutil.h */; }; - 0910BA260D1F64B300D46B04 /* ECullingTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910B9FF0D1F64B300D46B04 /* ECullingTypes.h */; }; - 0910BA270D1F64B300D46B04 /* EDebugSceneTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910BA000D1F64B300D46B04 /* EDebugSceneTypes.h */; }; - 0910BA280D1F64B300D46B04 /* EDriverFeatures.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910BA010D1F64B300D46B04 /* EDriverFeatures.h */; }; - 0910BA290D1F64B300D46B04 /* EGUIAlignment.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910BA020D1F64B300D46B04 /* EGUIAlignment.h */; }; - 0910BA2A0D1F64B300D46B04 /* EHardwareBufferFlags.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910BA030D1F64B300D46B04 /* EHardwareBufferFlags.h */; }; - 0910BA2B0D1F64B300D46B04 /* EMaterialFlags.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910BA040D1F64B300D46B04 /* EMaterialFlags.h */; }; - 0910BA2C0D1F64B300D46B04 /* EMaterialTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910BA050D1F64B300D46B04 /* EMaterialTypes.h */; }; - 0910BA2D0D1F64B300D46B04 /* EMeshWriterEnums.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910BA060D1F64B300D46B04 /* EMeshWriterEnums.h */; }; - 0910BA2E0D1F64B300D46B04 /* EMessageBoxFlags.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910BA070D1F64B300D46B04 /* EMessageBoxFlags.h */; }; - 0910BA2F0D1F64B300D46B04 /* ETerrainElements.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910BA080D1F64B300D46B04 /* ETerrainElements.h */; }; - 0910BA300D1F64B300D46B04 /* IAnimatedMeshMD3.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910BA090D1F64B300D46B04 /* IAnimatedMeshMD3.h */; }; - 0910BA310D1F64B300D46B04 /* IBoneSceneNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910BA0A0D1F64B300D46B04 /* IBoneSceneNode.h */; }; - 0910BA320D1F64B300D46B04 /* IGUIColorSelectDialog.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910BA0B0D1F64B300D46B04 /* IGUIColorSelectDialog.h */; }; - 0910BA330D1F64B300D46B04 /* IGUIElementFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910BA0C0D1F64B300D46B04 /* IGUIElementFactory.h */; }; - 0910BA340D1F64B300D46B04 /* IGUIFontBitmap.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910BA0D0D1F64B300D46B04 /* IGUIFontBitmap.h */; }; - 0910BA350D1F64B300D46B04 /* IGUISpinBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910BA0E0D1F64B300D46B04 /* IGUISpinBox.h */; }; - 0910BA360D1F64B300D46B04 /* IGUISpriteBank.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910BA0F0D1F64B300D46B04 /* IGUISpriteBank.h */; }; - 0910BA370D1F64B300D46B04 /* IGUITable.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910BA100D1F64B300D46B04 /* IGUITable.h */; }; - 0910BA380D1F64B300D46B04 /* IMeshWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910BA110D1F64B300D46B04 /* IMeshWriter.h */; }; - 0910BA390D1F64B300D46B04 /* IParticleAnimatedMeshSceneNodeEmitter.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910BA120D1F64B300D46B04 /* IParticleAnimatedMeshSceneNodeEmitter.h */; }; - 0910BA3A0D1F64B300D46B04 /* IParticleAttractionAffector.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910BA130D1F64B300D46B04 /* IParticleAttractionAffector.h */; }; - 0910BA3B0D1F64B300D46B04 /* IParticleBoxEmitter.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910BA140D1F64B300D46B04 /* IParticleBoxEmitter.h */; }; - 0910BA3C0D1F64B300D46B04 /* IParticleCylinderEmitter.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910BA150D1F64B300D46B04 /* IParticleCylinderEmitter.h */; }; - 0910BA3D0D1F64B300D46B04 /* IParticleFadeOutAffector.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910BA160D1F64B300D46B04 /* IParticleFadeOutAffector.h */; }; - 0910BA3E0D1F64B300D46B04 /* IParticleGravityAffector.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910BA170D1F64B300D46B04 /* IParticleGravityAffector.h */; }; - 0910BA3F0D1F64B300D46B04 /* IParticleMeshEmitter.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910BA180D1F64B300D46B04 /* IParticleMeshEmitter.h */; }; - 0910BA400D1F64B300D46B04 /* IParticleRingEmitter.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910BA190D1F64B300D46B04 /* IParticleRingEmitter.h */; }; - 0910BA410D1F64B300D46B04 /* IParticleRotationAffector.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910BA1A0D1F64B300D46B04 /* IParticleRotationAffector.h */; }; - 0910BA420D1F64B300D46B04 /* IParticleSphereEmitter.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910BA1B0D1F64B300D46B04 /* IParticleSphereEmitter.h */; }; - 0910BA430D1F64B300D46B04 /* IQ3Shader.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910BA1C0D1F64B300D46B04 /* IQ3Shader.h */; }; - 0910BA440D1F64B300D46B04 /* IReferenceCounted.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910BA1D0D1F64B300D46B04 /* IReferenceCounted.h */; }; - 0910BA450D1F64B300D46B04 /* irrMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910BA1E0D1F64B300D46B04 /* irrMap.h */; }; - 0910BA460D1F64B300D46B04 /* ISkinnedMesh.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910BA1F0D1F64B300D46B04 /* ISkinnedMesh.h */; }; - 0910BA470D1F64B300D46B04 /* SMaterialLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910BA200D1F64B300D46B04 /* SMaterialLayer.h */; }; - 0910BA480D1F64B300D46B04 /* SSharedMeshBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910BA210D1F64B300D46B04 /* SSharedMeshBuffer.h */; }; - 0910BA490D1F64B300D46B04 /* SSkinMeshBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910BA220D1F64B300D46B04 /* SSkinMeshBuffer.h */; }; - 0910BA4A0D1F64B300D46B04 /* SViewFrustum.h in Headers */ = {isa = PBXBuildFile; fileRef = 0910BA230D1F64B300D46B04 /* SViewFrustum.h */; }; - 0925113E0D744ADE006784D9 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0925113D0D744ADE006784D9 /* Carbon.framework */; }; - 0925113F0D744ADE006784D9 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0925113D0D744ADE006784D9 /* Carbon.framework */; }; - 092511400D744ADE006784D9 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0925113D0D744ADE006784D9 /* Carbon.framework */; }; - 092511410D744ADE006784D9 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0925113D0D744ADE006784D9 /* Carbon.framework */; }; - 092511420D744ADE006784D9 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0925113D0D744ADE006784D9 /* Carbon.framework */; }; - 092511430D744ADE006784D9 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0925113D0D744ADE006784D9 /* Carbon.framework */; }; - 092511440D744ADE006784D9 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0925113D0D744ADE006784D9 /* Carbon.framework */; }; - 092511450D744ADE006784D9 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0925113D0D744ADE006784D9 /* Carbon.framework */; }; - 092511460D744ADE006784D9 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0925113D0D744ADE006784D9 /* Carbon.framework */; }; - 092511470D744ADE006784D9 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0925113D0D744ADE006784D9 /* Carbon.framework */; }; - 092511480D744ADE006784D9 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0925113D0D744ADE006784D9 /* Carbon.framework */; }; - 092511490D744ADE006784D9 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0925113D0D744ADE006784D9 /* Carbon.framework */; }; - 0925114A0D744ADE006784D9 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0925113D0D744ADE006784D9 /* Carbon.framework */; }; - 0925114B0D744ADE006784D9 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0925113D0D744ADE006784D9 /* Carbon.framework */; }; - 0925114C0D744ADE006784D9 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0925113D0D744ADE006784D9 /* Carbon.framework */; }; - 0925114D0D744ADE006784D9 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0925113D0D744ADE006784D9 /* Carbon.framework */; }; - 09293C3E0ED32029003B8C9C /* png.c in Sources */ = {isa = PBXBuildFile; fileRef = 09293C2C0ED32029003B8C9C /* png.c */; }; - 09293C3F0ED32029003B8C9C /* pngerror.c in Sources */ = {isa = PBXBuildFile; fileRef = 09293C2D0ED32029003B8C9C /* pngerror.c */; }; - 09293C400ED32029003B8C9C /* pnggccrd.c in Sources */ = {isa = PBXBuildFile; fileRef = 09293C2E0ED32029003B8C9C /* pnggccrd.c */; }; - 09293C410ED32029003B8C9C /* pngget.c in Sources */ = {isa = PBXBuildFile; fileRef = 09293C2F0ED32029003B8C9C /* pngget.c */; }; - 09293C420ED32029003B8C9C /* pngmem.c in Sources */ = {isa = PBXBuildFile; fileRef = 09293C300ED32029003B8C9C /* pngmem.c */; }; - 09293C430ED32029003B8C9C /* pngpread.c in Sources */ = {isa = PBXBuildFile; fileRef = 09293C310ED32029003B8C9C /* pngpread.c */; }; - 09293C440ED32029003B8C9C /* pngread.c in Sources */ = {isa = PBXBuildFile; fileRef = 09293C320ED32029003B8C9C /* pngread.c */; }; - 09293C450ED32029003B8C9C /* pngrio.c in Sources */ = {isa = PBXBuildFile; fileRef = 09293C330ED32029003B8C9C /* pngrio.c */; }; - 09293C460ED32029003B8C9C /* pngrtran.c in Sources */ = {isa = PBXBuildFile; fileRef = 09293C340ED32029003B8C9C /* pngrtran.c */; }; - 09293C470ED32029003B8C9C /* pngrutil.c in Sources */ = {isa = PBXBuildFile; fileRef = 09293C350ED32029003B8C9C /* pngrutil.c */; }; - 09293C480ED32029003B8C9C /* pngset.c in Sources */ = {isa = PBXBuildFile; fileRef = 09293C360ED32029003B8C9C /* pngset.c */; }; - 09293C4A0ED32029003B8C9C /* pngtrans.c in Sources */ = {isa = PBXBuildFile; fileRef = 09293C380ED32029003B8C9C /* pngtrans.c */; }; - 09293C4C0ED32029003B8C9C /* pngwio.c in Sources */ = {isa = PBXBuildFile; fileRef = 09293C3A0ED32029003B8C9C /* pngwio.c */; }; - 09293C4D0ED32029003B8C9C /* pngwrite.c in Sources */ = {isa = PBXBuildFile; fileRef = 09293C3B0ED32029003B8C9C /* pngwrite.c */; }; - 09293C4E0ED32029003B8C9C /* pngwtran.c in Sources */ = {isa = PBXBuildFile; fileRef = 09293C3C0ED32029003B8C9C /* pngwtran.c */; }; - 09293C4F0ED32029003B8C9C /* pngwutil.c in Sources */ = {isa = PBXBuildFile; fileRef = 09293C3D0ED32029003B8C9C /* pngwutil.c */; }; - 0930CE560EC39F4500D63866 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0930CE550EC39F4500D63866 /* IOKit.framework */; }; - 0930CE570EC39F4500D63866 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0930CE550EC39F4500D63866 /* IOKit.framework */; }; - 0930CE580EC39F4500D63866 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0930CE550EC39F4500D63866 /* IOKit.framework */; }; - 0930CE590EC39F4500D63866 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0930CE550EC39F4500D63866 /* IOKit.framework */; }; - 0930CE5A0EC39F4500D63866 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0930CE550EC39F4500D63866 /* IOKit.framework */; }; - 0930CE5B0EC39F4500D63866 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0930CE550EC39F4500D63866 /* IOKit.framework */; }; - 0930CE5C0EC39F4500D63866 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0930CE550EC39F4500D63866 /* IOKit.framework */; }; - 0930CE5D0EC39F4500D63866 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0930CE550EC39F4500D63866 /* IOKit.framework */; }; - 0930CE5E0EC39F4500D63866 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0930CE550EC39F4500D63866 /* IOKit.framework */; }; - 0930CE5F0EC39F4500D63866 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0930CE550EC39F4500D63866 /* IOKit.framework */; }; - 0930CE600EC39F4500D63866 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0930CE550EC39F4500D63866 /* IOKit.framework */; }; - 0930CE610EC39F4500D63866 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0930CE550EC39F4500D63866 /* IOKit.framework */; }; - 0930CE620EC39F4500D63866 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0930CE550EC39F4500D63866 /* IOKit.framework */; }; - 0930CE630EC39F4500D63866 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0930CE550EC39F4500D63866 /* IOKit.framework */; }; - 0930CE640EC39F4500D63866 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0930CE550EC39F4500D63866 /* IOKit.framework */; }; - 0930CE650EC39F4500D63866 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0930CE550EC39F4500D63866 /* IOKit.framework */; }; - 0930CE660EC39F4500D63866 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0930CE550EC39F4500D63866 /* IOKit.framework */; }; - 093973C00E0458B200E0C987 /* CSceneNodeAnimatorCameraFPS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 093973BC0E0458B200E0C987 /* CSceneNodeAnimatorCameraFPS.cpp */; }; - 093973C10E0458B200E0C987 /* CSceneNodeAnimatorCameraFPS.h in Headers */ = {isa = PBXBuildFile; fileRef = 093973BD0E0458B200E0C987 /* CSceneNodeAnimatorCameraFPS.h */; }; - 093973C20E0458B200E0C987 /* CSceneNodeAnimatorCameraMaya.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 093973BE0E0458B200E0C987 /* CSceneNodeAnimatorCameraMaya.cpp */; }; - 093973C30E0458B200E0C987 /* CSceneNodeAnimatorCameraMaya.h in Headers */ = {isa = PBXBuildFile; fileRef = 093973BF0E0458B200E0C987 /* CSceneNodeAnimatorCameraMaya.h */; }; - 0946CCA70EC99BBE00D945A5 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 4C53E1650A484C2C0014E966 /* MainMenu.nib */; }; - 0946CCA80EC99BBE00D945A5 /* DemoApp-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4C53E38E0A4855BA0014E966 /* DemoApp-Info.plist */; }; - 0946CCAC0EC99BBE00D945A5 /* libIrrlicht.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E24D0A4850120014E966 /* libIrrlicht.a */; }; - 0946CCAD0EC99BBE00D945A5 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E26D0A4850D60014E966 /* Cocoa.framework */; }; - 0946CCAE0EC99BBE00D945A5 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E26E0A4850D60014E966 /* OpenGL.framework */; }; - 0946CCAF0EC99BBE00D945A5 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0925113D0D744ADE006784D9 /* Carbon.framework */; }; - 0946CCB00EC99BBE00D945A5 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0930CE550EC39F4500D63866 /* IOKit.framework */; }; - 0946CCCB0EC99C6E00D945A5 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0946CCCA0EC99C6E00D945A5 /* main.cpp */; }; - 096840470D0F1A2300333EFD /* CB3DMeshFileLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0968401E0D0F1A2300333EFD /* CB3DMeshFileLoader.cpp */; }; - 096840480D0F1A2300333EFD /* CB3DMeshFileLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 0968401F0D0F1A2300333EFD /* CB3DMeshFileLoader.h */; }; - 096840490D0F1A2300333EFD /* CBoneSceneNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 096840200D0F1A2300333EFD /* CBoneSceneNode.cpp */; }; - 0968404A0D0F1A2300333EFD /* CBoneSceneNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 096840210D0F1A2300333EFD /* CBoneSceneNode.h */; }; - 0968404B0D0F1A2300333EFD /* CBSPMeshFileLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 096840220D0F1A2300333EFD /* CBSPMeshFileLoader.cpp */; }; - 0968404C0D0F1A2300333EFD /* CBSPMeshFileLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 096840230D0F1A2300333EFD /* CBSPMeshFileLoader.h */; }; - 0968404E0D0F1A2300333EFD /* CColladaMeshWriter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 096840250D0F1A2300333EFD /* CColladaMeshWriter.cpp */; }; - 0968404F0D0F1A2300333EFD /* CColladaMeshWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = 096840260D0F1A2300333EFD /* CColladaMeshWriter.h */; }; - 096840500D0F1A2300333EFD /* CImageLoaderPPM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 096840270D0F1A2300333EFD /* CImageLoaderPPM.cpp */; }; - 096840510D0F1A2300333EFD /* CImageLoaderPPM.h in Headers */ = {isa = PBXBuildFile; fileRef = 096840280D0F1A2300333EFD /* CImageLoaderPPM.h */; }; - 096840540D0F1A2300333EFD /* CIrrMeshFileLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0968402B0D0F1A2300333EFD /* CIrrMeshFileLoader.cpp */; }; - 096840550D0F1A2300333EFD /* CIrrMeshFileLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 0968402C0D0F1A2300333EFD /* CIrrMeshFileLoader.h */; }; - 096840560D0F1A2300333EFD /* CIrrMeshWriter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0968402D0D0F1A2300333EFD /* CIrrMeshWriter.cpp */; }; - 096840570D0F1A2300333EFD /* CIrrMeshWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = 0968402E0D0F1A2300333EFD /* CIrrMeshWriter.h */; }; - 096840580D0F1A2300333EFD /* CMD2MeshFileLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0968402F0D0F1A2300333EFD /* CMD2MeshFileLoader.cpp */; }; - 096840590D0F1A2300333EFD /* CMD2MeshFileLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 096840300D0F1A2300333EFD /* CMD2MeshFileLoader.h */; }; - 0968405A0D0F1A2300333EFD /* CMS3DMeshFileLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 096840310D0F1A2300333EFD /* CMS3DMeshFileLoader.cpp */; }; - 0968405B0D0F1A2300333EFD /* CMS3DMeshFileLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 096840320D0F1A2300333EFD /* CMS3DMeshFileLoader.h */; }; - 0968405C0D0F1A2300333EFD /* CParticleAnimatedMeshSceneNodeEmitter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 096840330D0F1A2300333EFD /* CParticleAnimatedMeshSceneNodeEmitter.cpp */; }; - 0968405D0D0F1A2300333EFD /* CParticleAnimatedMeshSceneNodeEmitter.h in Headers */ = {isa = PBXBuildFile; fileRef = 096840340D0F1A2300333EFD /* CParticleAnimatedMeshSceneNodeEmitter.h */; }; - 0968405E0D0F1A2300333EFD /* CParticleAttractionAffector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 096840350D0F1A2300333EFD /* CParticleAttractionAffector.cpp */; }; - 0968405F0D0F1A2300333EFD /* CParticleAttractionAffector.h in Headers */ = {isa = PBXBuildFile; fileRef = 096840360D0F1A2300333EFD /* CParticleAttractionAffector.h */; }; - 096840600D0F1A2300333EFD /* CParticleCylinderEmitter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 096840370D0F1A2300333EFD /* CParticleCylinderEmitter.cpp */; }; - 096840610D0F1A2300333EFD /* CParticleCylinderEmitter.h in Headers */ = {isa = PBXBuildFile; fileRef = 096840380D0F1A2300333EFD /* CParticleCylinderEmitter.h */; }; - 096840620D0F1A2300333EFD /* CParticleMeshEmitter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 096840390D0F1A2300333EFD /* CParticleMeshEmitter.cpp */; }; - 096840630D0F1A2300333EFD /* CParticleMeshEmitter.h in Headers */ = {isa = PBXBuildFile; fileRef = 0968403A0D0F1A2300333EFD /* CParticleMeshEmitter.h */; }; - 096840640D0F1A2300333EFD /* CParticleRingEmitter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0968403B0D0F1A2300333EFD /* CParticleRingEmitter.cpp */; }; - 096840650D0F1A2300333EFD /* CParticleRingEmitter.h in Headers */ = {isa = PBXBuildFile; fileRef = 0968403C0D0F1A2300333EFD /* CParticleRingEmitter.h */; }; - 096840660D0F1A2300333EFD /* CParticleRotationAffector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0968403D0D0F1A2300333EFD /* CParticleRotationAffector.cpp */; }; - 096840670D0F1A2300333EFD /* CParticleRotationAffector.h in Headers */ = {isa = PBXBuildFile; fileRef = 0968403E0D0F1A2300333EFD /* CParticleRotationAffector.h */; }; - 096840680D0F1A2300333EFD /* CParticleSphereEmitter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0968403F0D0F1A2300333EFD /* CParticleSphereEmitter.cpp */; }; - 096840690D0F1A2300333EFD /* CParticleSphereEmitter.h in Headers */ = {isa = PBXBuildFile; fileRef = 096840400D0F1A2300333EFD /* CParticleSphereEmitter.h */; }; - 0968406A0D0F1A2300333EFD /* CSkinnedMesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 096840410D0F1A2300333EFD /* CSkinnedMesh.cpp */; }; - 0968406B0D0F1A2300333EFD /* CSkinnedMesh.h in Headers */ = {isa = PBXBuildFile; fileRef = 096840420D0F1A2300333EFD /* CSkinnedMesh.h */; }; - 0968406C0D0F1A2300333EFD /* CSTLMeshFileLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 096840430D0F1A2300333EFD /* CSTLMeshFileLoader.cpp */; }; - 0968406D0D0F1A2300333EFD /* CSTLMeshFileLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 096840440D0F1A2300333EFD /* CSTLMeshFileLoader.h */; }; - 0968406E0D0F1A2300333EFD /* CSTLMeshWriter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 096840450D0F1A2300333EFD /* CSTLMeshWriter.cpp */; }; - 0968406F0D0F1A2300333EFD /* CSTLMeshWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = 096840460D0F1A2300333EFD /* CSTLMeshWriter.h */; }; - 096CC0E00ECE65B500C81DC7 /* CParticleScaleAffector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 096CC0DE0ECE65B500C81DC7 /* CParticleScaleAffector.cpp */; }; - 096CC0E10ECE65B500C81DC7 /* CParticleScaleAffector.h in Headers */ = {isa = PBXBuildFile; fileRef = 096CC0DF0ECE65B500C81DC7 /* CParticleScaleAffector.h */; }; - 096F8E3D0EA2EFBA00907EC5 /* COBJMeshWriter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 096F8E3B0EA2EFBA00907EC5 /* COBJMeshWriter.cpp */; }; - 096F8E3E0EA2EFBA00907EC5 /* COBJMeshWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = 096F8E3C0EA2EFBA00907EC5 /* COBJMeshWriter.h */; }; - 09C638720D4F1A69000B6A18 /* CLWOMeshFileLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 09C638700D4F1A69000B6A18 /* CLWOMeshFileLoader.cpp */; }; - 09C638730D4F1A69000B6A18 /* CLWOMeshFileLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 09C638710D4F1A69000B6A18 /* CLWOMeshFileLoader.h */; }; - 09F460EB0D3223ED00D0A9B0 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 09F6492E0D2CE038001E0599 /* main.cpp */; }; - 09F648F80D2CDED9001E0599 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 4C53E1650A484C2C0014E966 /* MainMenu.nib */; }; - 09F648F90D2CDED9001E0599 /* DemoApp-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4C53E38E0A4855BA0014E966 /* DemoApp-Info.plist */; }; - 09F648FD0D2CDED9001E0599 /* libIrrlicht.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E24D0A4850120014E966 /* libIrrlicht.a */; }; - 09F648FE0D2CDED9001E0599 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E26D0A4850D60014E966 /* Cocoa.framework */; }; - 09F648FF0D2CDED9001E0599 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E26E0A4850D60014E966 /* OpenGL.framework */; }; - 09F6491A0D2CDF9A001E0599 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C0054710A48470500C844C2 /* main.cpp */; }; - 09F649330D2CE03E001E0599 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 4C53E1650A484C2C0014E966 /* MainMenu.nib */; }; - 09F649340D2CE03E001E0599 /* DemoApp-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4C53E38E0A4855BA0014E966 /* DemoApp-Info.plist */; }; - 09F649380D2CE03E001E0599 /* libIrrlicht.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E24D0A4850120014E966 /* libIrrlicht.a */; }; - 09F649390D2CE03E001E0599 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E26D0A4850D60014E966 /* Cocoa.framework */; }; - 09F6493A0D2CE03E001E0599 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E26E0A4850D60014E966 /* OpenGL.framework */; }; - 09F6495A0D2CE206001E0599 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 4C53E1650A484C2C0014E966 /* MainMenu.nib */; }; - 09F6495B0D2CE206001E0599 /* DemoApp-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4C53E38E0A4855BA0014E966 /* DemoApp-Info.plist */; }; - 09F6495F0D2CE206001E0599 /* libIrrlicht.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E24D0A4850120014E966 /* libIrrlicht.a */; }; - 09F649600D2CE206001E0599 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E26D0A4850D60014E966 /* Cocoa.framework */; }; - 09F649610D2CE206001E0599 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E26E0A4850D60014E966 /* OpenGL.framework */; }; - 09F649740D2CE2D0001E0599 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 09F649730D2CE2D0001E0599 /* main.cpp */; }; - 3430E4D61022C391006271FD /* CTarReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 3430E4D41022C391006271FD /* CTarReader.h */; }; - 3430E4D71022C391006271FD /* CTarReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3430E4D51022C391006271FD /* CTarReader.cpp */; }; - 344FD4A61039E98C0045FD3F /* CMountPointReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 344FD4A41039E98C0045FD3F /* CMountPointReader.cpp */; }; - 344FD4A71039E98C0045FD3F /* CMountPointReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 344FD4A51039E98C0045FD3F /* CMountPointReader.h */; }; - 3484C4E10F48D1B000C81F60 /* CGUIImageList.h in Headers */ = {isa = PBXBuildFile; fileRef = 3484C4DF0F48D1B000C81F60 /* CGUIImageList.h */; }; - 3484C4E20F48D1B000C81F60 /* CGUIImageList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3484C4E00F48D1B000C81F60 /* CGUIImageList.cpp */; }; - 3484C4EE0F48D3A100C81F60 /* CGUITreeView.h in Headers */ = {isa = PBXBuildFile; fileRef = 3484C4EC0F48D3A100C81F60 /* CGUITreeView.h */; }; - 3484C4EF0F48D3A100C81F60 /* CGUITreeView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3484C4ED0F48D3A100C81F60 /* CGUITreeView.cpp */; }; - 3484C4FD0F48D4CB00C81F60 /* CMemoryFile.h in Headers */ = {isa = PBXBuildFile; fileRef = 3484C4FB0F48D4CB00C81F60 /* CMemoryFile.h */; }; - 3484C4FE0F48D4CB00C81F60 /* CMemoryFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3484C4FC0F48D4CB00C81F60 /* CMemoryFile.cpp */; }; - 34EC243C0F59272E0037BC3A /* CIrrDeviceConsole.h in Headers */ = {isa = PBXBuildFile; fileRef = 34EC243A0F59272E0037BC3A /* CIrrDeviceConsole.h */; }; - 34EC243D0F59272E0037BC3A /* CIrrDeviceConsole.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 34EC243B0F59272E0037BC3A /* CIrrDeviceConsole.cpp */; }; - 34EF91D20F65FCA6000B5651 /* CImageLoaderRGB.h in Headers */ = {isa = PBXBuildFile; fileRef = 34EF91D00F65FCA6000B5651 /* CImageLoaderRGB.h */; }; - 34EF91D30F65FCA6000B5651 /* CImageLoaderRGB.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 34EF91D10F65FCA6000B5651 /* CImageLoaderRGB.cpp */; }; - 34EF91D70F65FCF6000B5651 /* CPLYMeshFileLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 34EF91D50F65FCF6000B5651 /* CPLYMeshFileLoader.h */; }; - 34EF91D80F65FCF6000B5651 /* CPLYMeshFileLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 34EF91D60F65FCF6000B5651 /* CPLYMeshFileLoader.cpp */; }; - 34EF91DC0F65FD14000B5651 /* CPLYMeshWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = 34EF91DA0F65FD14000B5651 /* CPLYMeshWriter.h */; }; - 34EF91DD0F65FD14000B5651 /* CPLYMeshWriter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 34EF91DB0F65FD14000B5651 /* CPLYMeshWriter.cpp */; }; - 4C364EA40A6C6DC2004CFBB4 /* COBJMeshFileLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C364EA20A6C6DC2004CFBB4 /* COBJMeshFileLoader.cpp */; }; - 4C43EEC00A74A5C800F942FC /* CPakReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C43EEBE0A74A5C800F942FC /* CPakReader.cpp */; }; - 4C53E2500A48504D0014E966 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C0054770A48470500C844C2 /* main.cpp */; }; - 4C53E2510A4850550014E966 /* libIrrlicht.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E24D0A4850120014E966 /* libIrrlicht.a */; }; - 4C53E26F0A4850D60014E966 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E26D0A4850D60014E966 /* Cocoa.framework */; }; - 4C53E2700A4850D60014E966 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E26E0A4850D60014E966 /* OpenGL.framework */; }; - 4C53E2710A4850D60014E966 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E26D0A4850D60014E966 /* Cocoa.framework */; }; - 4C53E2720A4850D60014E966 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E26E0A4850D60014E966 /* OpenGL.framework */; }; - 4C53E2730A4850D60014E966 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E26D0A4850D60014E966 /* Cocoa.framework */; }; - 4C53E2740A4850D60014E966 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E26E0A4850D60014E966 /* OpenGL.framework */; }; - 4C53E2750A4850D60014E966 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E26D0A4850D60014E966 /* Cocoa.framework */; }; - 4C53E2760A4850D60014E966 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E26E0A4850D60014E966 /* OpenGL.framework */; }; - 4C53E2770A4850D60014E966 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E26D0A4850D60014E966 /* Cocoa.framework */; }; - 4C53E2780A4850D60014E966 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E26E0A4850D60014E966 /* OpenGL.framework */; }; - 4C53E2790A4850D60014E966 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E26D0A4850D60014E966 /* Cocoa.framework */; }; - 4C53E27A0A4850D60014E966 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E26E0A4850D60014E966 /* OpenGL.framework */; }; - 4C53E27B0A4850D60014E966 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E26D0A4850D60014E966 /* Cocoa.framework */; }; - 4C53E27C0A4850D60014E966 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E26E0A4850D60014E966 /* OpenGL.framework */; }; - 4C53E27D0A4850D60014E966 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E26D0A4850D60014E966 /* Cocoa.framework */; }; - 4C53E27E0A4850D60014E966 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E26E0A4850D60014E966 /* OpenGL.framework */; }; - 4C53E27F0A4850D60014E966 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E26D0A4850D60014E966 /* Cocoa.framework */; }; - 4C53E2800A4850D60014E966 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E26E0A4850D60014E966 /* OpenGL.framework */; }; - 4C53E2810A4850D60014E966 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E26D0A4850D60014E966 /* Cocoa.framework */; }; - 4C53E2820A4850D60014E966 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E26E0A4850D60014E966 /* OpenGL.framework */; }; - 4C53E2830A4850D60014E966 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E26D0A4850D60014E966 /* Cocoa.framework */; }; - 4C53E2840A4850D60014E966 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E26E0A4850D60014E966 /* OpenGL.framework */; }; - 4C53E2850A4850D60014E966 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E26D0A4850D60014E966 /* Cocoa.framework */; }; - 4C53E2860A4850D60014E966 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E26E0A4850D60014E966 /* OpenGL.framework */; }; - 4C53E2870A4850D60014E966 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E26D0A4850D60014E966 /* Cocoa.framework */; }; - 4C53E2880A4850D60014E966 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E26E0A4850D60014E966 /* OpenGL.framework */; }; - 4C53E3890A48559C0014E966 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 4C53E1650A484C2C0014E966 /* MainMenu.nib */; }; - 4C53E38F0A4855BA0014E966 /* DemoApp-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4C53E38E0A4855BA0014E966 /* DemoApp-Info.plist */; }; - 4C53E3900A4855BA0014E966 /* DemoApp-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4C53E38E0A4855BA0014E966 /* DemoApp-Info.plist */; }; - 4C53E3910A4855BA0014E966 /* DemoApp-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4C53E38E0A4855BA0014E966 /* DemoApp-Info.plist */; }; - 4C53E3920A4855BA0014E966 /* DemoApp-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4C53E38E0A4855BA0014E966 /* DemoApp-Info.plist */; }; - 4C53E3930A4855BA0014E966 /* DemoApp-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4C53E38E0A4855BA0014E966 /* DemoApp-Info.plist */; }; - 4C53E3940A4855BA0014E966 /* DemoApp-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4C53E38E0A4855BA0014E966 /* DemoApp-Info.plist */; }; - 4C53E3950A4855BA0014E966 /* DemoApp-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4C53E38E0A4855BA0014E966 /* DemoApp-Info.plist */; }; - 4C53E3960A4855BA0014E966 /* DemoApp-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4C53E38E0A4855BA0014E966 /* DemoApp-Info.plist */; }; - 4C53E3970A4855BA0014E966 /* DemoApp-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4C53E38E0A4855BA0014E966 /* DemoApp-Info.plist */; }; - 4C53E3980A4855BA0014E966 /* DemoApp-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4C53E38E0A4855BA0014E966 /* DemoApp-Info.plist */; }; - 4C53E3990A4855BA0014E966 /* DemoApp-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4C53E38E0A4855BA0014E966 /* DemoApp-Info.plist */; }; - 4C53E39A0A4855BA0014E966 /* DemoApp-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4C53E38E0A4855BA0014E966 /* DemoApp-Info.plist */; }; - 4C53E39B0A4855BA0014E966 /* DemoApp-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4C53E38E0A4855BA0014E966 /* DemoApp-Info.plist */; }; - 4C53E3CA0A4856B30014E966 /* gzio.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E17D0A484C2C0014E966 /* gzio.c */; }; - 4C53E3D80A4856B30014E966 /* inffast.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E1800A484C2C0014E966 /* inffast.c */; }; - 4C53E3DC0A4856B30014E966 /* inftrees.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E1850A484C2C0014E966 /* inftrees.c */; }; - 4C53E3E40A4856B30014E966 /* uncompr.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E18D0A484C2C0014E966 /* uncompr.c */; }; - 4C53E3F30A4856B30014E966 /* compress.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E1750A484C2C0014E966 /* compress.c */; }; - 4C53E3F60A4856B30014E966 /* crc32.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E1770A484C2C0014E966 /* crc32.c */; }; - 4C53E3FE0A4856B30014E966 /* zutil.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E1920A484C2C0014E966 /* zutil.c */; }; - 4C53E4010A4856B30014E966 /* trees.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E18B0A484C2C0014E966 /* trees.c */; }; - 4C53E40A0A4856B30014E966 /* deflate.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E1790A484C2C0014E966 /* deflate.c */; }; - 4C53E4150A4856B30014E966 /* adler32.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E1720A484C2C0014E966 /* adler32.c */; }; - 4C53E4280A4856B30014E966 /* CImageLoaderPNG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF600A484C230014E966 /* CImageLoaderPNG.cpp */; }; - 4C53E4290A4856B30014E966 /* CColorConverter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DEFC0A484C220014E966 /* CColorConverter.cpp */; }; - 4C53E42A0A4856B30014E966 /* CSceneManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFAB0A484C240014E966 /* CSceneManager.cpp */; }; - 4C53E42B0A4856B30014E966 /* CTRTextureGouraudAdd2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFE30A484C250014E966 /* CTRTextureGouraudAdd2.cpp */; }; - 4C53E42C0A4856B30014E966 /* CNullDriver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF820A484C240014E966 /* CNullDriver.cpp */; }; - 4C53E42D0A4856B30014E966 /* CCSMLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DEFE0A484C220014E966 /* CCSMLoader.cpp */; }; - 4C53E42E0A4856B30014E966 /* irrXML.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E00E0A484C250014E966 /* irrXML.cpp */; }; - 4C53E42F0A4856B30014E966 /* CGUIListBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF420A484C230014E966 /* CGUIListBox.cpp */; }; - 4C53E4300A4856B30014E966 /* CTRGouraudWire.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFD70A484C240014E966 /* CTRGouraudWire.cpp */; }; - 4C53E4310A4856B30014E966 /* CIrrDeviceStub.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF680A484C230014E966 /* CIrrDeviceStub.cpp */; }; - 4C53E4320A4856B30014E966 /* CGUIMessageBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF480A484C230014E966 /* CGUIMessageBox.cpp */; }; - 4C53E4330A4856B30014E966 /* CMeshSceneNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF7A0A484C230014E966 /* CMeshSceneNode.cpp */; }; - 4C53E4340A4856B30014E966 /* CGUIStaticText.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF500A484C230014E966 /* CGUIStaticText.cpp */; }; - 4C53E4350A4856B30014E966 /* os.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E16A0A484C2C0014E966 /* os.cpp */; }; - 4C53E4360A4856B30014E966 /* COCTLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF840A484C240014E966 /* COCTLoader.cpp */; }; - 4C53E4370A4856B30014E966 /* CGUIContextMenu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF340A484C230014E966 /* CGUIContextMenu.cpp */; }; - 4C53E4390A4856B30014E966 /* CSceneNodeAnimatorFlyCircle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFB10A484C240014E966 /* CSceneNodeAnimatorFlyCircle.cpp */; }; - 4C53E43A0A4856B30014E966 /* CDefaultSceneNodeFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF1E0A484C230014E966 /* CDefaultSceneNodeFactory.cpp */; }; - 4C53E43B0A4856B30014E966 /* CD3D9Driver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF0D0A484C230014E966 /* CD3D9Driver.cpp */; }; - 4C53E43C0A4856B30014E966 /* CTRGouraud.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFD30A484C240014E966 /* CTRGouraud.cpp */; }; - 4C53E43D0A4856B30014E966 /* C3DSMeshFileLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DEE70A484C220014E966 /* C3DSMeshFileLoader.cpp */; }; - 4C53E43E0A4856B30014E966 /* COgreMeshFileLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF8A0A484C240014E966 /* COgreMeshFileLoader.cpp */; }; - 4C53E43F0A4856B30014E966 /* CMY3DMeshFileLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF7F0A484C230014E966 /* CMY3DMeshFileLoader.cpp */; }; - 4C53E4400A4856B30014E966 /* CLMTSMeshFileLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF700A484C230014E966 /* CLMTSMeshFileLoader.cpp */; }; - 4C53E4410A4856B30014E966 /* CGUIFileOpenDialog.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF3A0A484C230014E966 /* CGUIFileOpenDialog.cpp */; }; - 4C53E4420A4856B30014E966 /* CSceneNodeAnimatorDelete.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFAF0A484C240014E966 /* CSceneNodeAnimatorDelete.cpp */; }; - 4C53E4430A4856B30014E966 /* CTRGouraudAlphaNoZ2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFD60A484C240014E966 /* CTRGouraudAlphaNoZ2.cpp */; }; - 4C53E4440A4856B30014E966 /* CGeometryCreator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF2C0A484C230014E966 /* CGeometryCreator.cpp */; }; - 4C53E4450A4856B30014E966 /* CD3D8Texture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF0B0A484C230014E966 /* CD3D8Texture.cpp */; }; - 4C53E4460A4856B30014E966 /* CSkyBoxSceneNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFBD0A484C240014E966 /* CSkyBoxSceneNode.cpp */; }; - 4C53E4470A4856B30014E966 /* CMeshManipulator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF780A484C230014E966 /* CMeshManipulator.cpp */; }; - 4C53E4480A4856B30014E966 /* CTextSceneNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFCE0A484C240014E966 /* CTextSceneNode.cpp */; }; - 4C53E4490A4856B30014E966 /* CTRTextureDetailMap2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFDC0A484C250014E966 /* CTRTextureDetailMap2.cpp */; }; - 4C53E44A0A4856B30014E966 /* CTRTextureGouraudAddNoZ2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFE40A484C250014E966 /* CTRTextureGouraudAddNoZ2.cpp */; }; - 4C53E44C0A4856B30014E966 /* CTRTextureGouraudNoZ.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFE50A484C250014E966 /* CTRTextureGouraudNoZ.cpp */; }; - 4C53E44E0A4856B30014E966 /* CGUIScrollBar.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF4C0A484C230014E966 /* CGUIScrollBar.cpp */; }; - 4C53E44F0A4856B30014E966 /* CSceneCollisionManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFA90A484C240014E966 /* CSceneCollisionManager.cpp */; }; - 4C53E4500A4856B30014E966 /* CGUICheckBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF300A484C230014E966 /* CGUICheckBox.cpp */; }; - 4C53E4510A4856B30014E966 /* CQ3LevelMesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFA50A484C240014E966 /* CQ3LevelMesh.cpp */; }; - 4C53E4520A4856B30014E966 /* CParticleGravityAffector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF9F0A484C240014E966 /* CParticleGravityAffector.cpp */; }; - 4C53E4530A4856B30014E966 /* CSoftwareDriver2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFC20A484C240014E966 /* CSoftwareDriver2.cpp */; }; - 4C53E4540A4856B30014E966 /* CD3D9ParallaxMapRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF140A484C230014E966 /* CD3D9ParallaxMapRenderer.cpp */; }; - 4C53E4550A4856B30014E966 /* CD3D8ParallaxMapRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF070A484C230014E966 /* CD3D8ParallaxMapRenderer.cpp */; }; - 4C53E4560A4856B30014E966 /* CAnimatedMeshMD2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DEE90A484C220014E966 /* CAnimatedMeshMD2.cpp */; }; - 4C53E4570A4856B30014E966 /* CSceneNodeAnimatorFlyStraight.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFB30A484C240014E966 /* CSceneNodeAnimatorFlyStraight.cpp */; }; - 4C53E4580A4856B30014E966 /* CImageLoaderPCX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF5E0A484C230014E966 /* CImageLoaderPCX.cpp */; }; - 4C53E4590A4856B30014E966 /* CAnimatedMeshSceneNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DEED0A484C220014E966 /* CAnimatedMeshSceneNode.cpp */; }; - 4C53E45A0A4856B30014E966 /* CTriangleSelector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFDA0A484C250014E966 /* CTriangleSelector.cpp */; }; - 4C53E45B0A4856B30014E966 /* CTRTextureGouraudVertexAlpha2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFE70A484C250014E966 /* CTRTextureGouraudVertexAlpha2.cpp */; }; - 4C53E45C0A4856B30014E966 /* CTRTextureWire2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFED0A484C250014E966 /* CTRTextureWire2.cpp */; }; - 4C53E45D0A4856B30014E966 /* CTRTextureFlatWire.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFDE0A484C250014E966 /* CTRTextureFlatWire.cpp */; }; - 4C53E45E0A4856B30014E966 /* CTRGouraud2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFD40A484C240014E966 /* CTRGouraud2.cpp */; }; - 4C53E45F0A4856B30014E966 /* CEmptySceneNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF240A484C230014E966 /* CEmptySceneNode.cpp */; }; - 4C53E4600A4856B30014E966 /* CTRTextureLightMap2_Add.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFE90A484C250014E966 /* CTRTextureLightMap2_Add.cpp */; }; - 4C53E4610A4856B30014E966 /* CReadFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFA70A484C240014E966 /* CReadFile.cpp */; }; - 4C53E4620A4856B30014E966 /* COpenGLTexture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF970A484C240014E966 /* COpenGLTexture.cpp */; }; - 4C53E4640A4856B30014E966 /* COSOperator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF990A484C240014E966 /* COSOperator.cpp */; }; - 4C53E4660A4856B30014E966 /* CColladaFileLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DEFA0A484C220014E966 /* CColladaFileLoader.cpp */; }; - 4C53E4670A4856B30014E966 /* CCameraSceneNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DEF80A484C220014E966 /* CCameraSceneNode.cpp */; }; - 4C53E4680A4856B30014E966 /* CMetaTriangleSelector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF7C0A484C230014E966 /* CMetaTriangleSelector.cpp */; }; - 4C53E4690A4856B30014E966 /* CTRTextureFlat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFDD0A484C250014E966 /* CTRTextureFlat.cpp */; }; - 4C53E46A0A4856B30014E966 /* CVideoModeList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFEE0A484C250014E966 /* CVideoModeList.cpp */; }; - 4C53E46B0A4856B30014E966 /* CXMLReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFFA0A484C250014E966 /* CXMLReader.cpp */; }; - 4C53E46C0A4856B30014E966 /* COpenGLParallaxMapRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF910A484C240014E966 /* COpenGLParallaxMapRenderer.cpp */; }; - 4C53E46E0A4856B30014E966 /* CTRTextureGouraudNoZ2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFE60A484C250014E966 /* CTRTextureGouraudNoZ2.cpp */; }; - 4C53E46F0A4856B30014E966 /* CTRTextureGouraudWire.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFE80A484C250014E966 /* CTRTextureGouraudWire.cpp */; }; - 4C53E4700A4856B30014E966 /* CParticlePointEmitter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFA10A484C240014E966 /* CParticlePointEmitter.cpp */; }; - 4C53E4710A4856B30014E966 /* CGUIWindow.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF560A484C230014E966 /* CGUIWindow.cpp */; }; - 4C53E4720A4856B30014E966 /* CGUIModalScreen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF4A0A484C230014E966 /* CGUIModalScreen.cpp */; }; - 4C53E4730A4856B30014E966 /* CImageLoaderPSD.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF620A484C230014E966 /* CImageLoaderPSD.cpp */; }; - 4C53E4740A4856B30014E966 /* CWaterSurfaceSceneNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFF00A484C250014E966 /* CWaterSurfaceSceneNode.cpp */; }; - 4C53E4750A4856B30014E966 /* CXMeshFileLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFF80A484C250014E966 /* CXMeshFileLoader.cpp */; }; - 4C53E4760A4856B30014E966 /* CIrrDeviceLinux.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF660A484C230014E966 /* CIrrDeviceLinux.cpp */; }; - 4C53E4770A4856B30014E966 /* CLightSceneNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF6C0A484C230014E966 /* CLightSceneNode.cpp */; }; - 4C53E4780A4856B30014E966 /* CTRTextureGouraudAdd.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFE20A484C250014E966 /* CTRTextureGouraudAdd.cpp */; }; - 4C53E4790A4856B30014E966 /* CTRTextureGouraud2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFE10A484C250014E966 /* CTRTextureGouraud2.cpp */; }; - 4C53E47A0A4856B30014E966 /* CSoftwareDriver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFC00A484C240014E966 /* CSoftwareDriver.cpp */; }; - 4C53E47B0A4856B30014E966 /* CTRFlatWire.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFD20A484C240014E966 /* CTRFlatWire.cpp */; }; - 4C53E47C0A4856B30014E966 /* CTRGouraudAlpha2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFD50A484C240014E966 /* CTRGouraudAlpha2.cpp */; }; - 4C53E47D0A4856B30014E966 /* CSoftwareTexture2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFC60A484C240014E966 /* CSoftwareTexture2.cpp */; }; - 4C53E47E0A4856B30014E966 /* CZipReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E0030A484C250014E966 /* CZipReader.cpp */; }; - 4C53E47F0A4856B30014E966 /* COpenGLNormalMapRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF8F0A484C240014E966 /* COpenGLNormalMapRenderer.cpp */; }; - 4C53E4800A4856B30014E966 /* CTRTextureLightMap2_M1.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFEA0A484C250014E966 /* CTRTextureLightMap2_M1.cpp */; }; - 4C53E4810A4856B30014E966 /* CTRTextureLightMap2_M4.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFEC0A484C250014E966 /* CTRTextureLightMap2_M4.cpp */; }; - 4C53E4820A4856B30014E966 /* CGUISkin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF4E0A484C230014E966 /* CGUISkin.cpp */; }; - 4C53E4830A4856B30014E966 /* CD3D8Driver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF020A484C220014E966 /* CD3D8Driver.cpp */; }; - 4C53E4840A4856B30014E966 /* CIrrDeviceWin32.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF6A0A484C230014E966 /* CIrrDeviceWin32.cpp */; }; - 4C53E4850A4856B30014E966 /* CFileSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF280A484C230014E966 /* CFileSystem.cpp */; }; - 4C53E4860A4856B30014E966 /* CGUIMeshViewer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF460A484C230014E966 /* CGUIMeshViewer.cpp */; }; - 4C53E4870A4856B30014E966 /* CGUIComboBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF320A484C230014E966 /* CGUIComboBox.cpp */; }; - 4C53E4880A4856B30014E966 /* CSceneNodeAnimatorRotation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFB70A484C240014E966 /* CSceneNodeAnimatorRotation.cpp */; }; - 4C53E4890A4856B30014E966 /* CSceneNodeAnimatorTexture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFB90A484C240014E966 /* CSceneNodeAnimatorTexture.cpp */; }; - 4C53E48A0A4856B30014E966 /* COctTreeSceneNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF860A484C240014E966 /* COctTreeSceneNode.cpp */; }; - 4C53E48B0A4856B30014E966 /* CParticleSystemSceneNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFA30A484C240014E966 /* CParticleSystemSceneNode.cpp */; }; - 4C53E48C0A4856B30014E966 /* CTerrainSceneNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFCA0A484C240014E966 /* CTerrainSceneNode.cpp */; }; - 4C53E48E0A4856B30014E966 /* CGUIFont.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF3C0A484C230014E966 /* CGUIFont.cpp */; }; - 4C53E48F0A4856B30014E966 /* CParticleFadeOutAffector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF9D0A484C240014E966 /* CParticleFadeOutAffector.cpp */; }; - 4C53E4910A4856B30014E966 /* CDummyTransformationSceneNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF220A484C230014E966 /* CDummyTransformationSceneNode.cpp */; }; - 4C53E4920A4856B30014E966 /* CFileList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF260A484C230014E966 /* CFileList.cpp */; }; - 4C53E4930A4856B30014E966 /* CImageLoaderTGA.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF640A484C230014E966 /* CImageLoaderTGA.cpp */; }; - 4C53E4940A4856B30014E966 /* CXMLWriter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFFD0A484C250014E966 /* CXMLWriter.cpp */; }; - 4C53E4950A4856B30014E966 /* CSceneNodeAnimatorFollowSpline.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFB50A484C240014E966 /* CSceneNodeAnimatorFollowSpline.cpp */; }; - 4C53E4960A4856B30014E966 /* CZBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFFF0A484C250014E966 /* CZBuffer.cpp */; }; - 4C53E4970A4856B30014E966 /* CDMFLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF200A484C230014E966 /* CDMFLoader.cpp */; }; - 4C53E4980A4856B30014E966 /* CD3D9Texture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF180A484C230014E966 /* CD3D9Texture.cpp */; }; - 4C53E4990A4856B30014E966 /* COpenGLShaderMaterialRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF930A484C240014E966 /* COpenGLShaderMaterialRenderer.cpp */; }; - 4C53E49A0A4856B30014E966 /* Irrlicht.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E00A0A484C250014E966 /* Irrlicht.cpp */; }; - 4C53E49B0A4856B30014E966 /* CGUIEditBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF360A484C230014E966 /* CGUIEditBox.cpp */; }; - 4C53E49C0A4856B30014E966 /* COpenGLSLMaterialRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF950A484C240014E966 /* COpenGLSLMaterialRenderer.cpp */; }; - 4C53E49D0A4856B30014E966 /* CD3D9HLSLMaterialRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF0F0A484C230014E966 /* CD3D9HLSLMaterialRenderer.cpp */; }; - 4C53E49E0A4856B30014E966 /* CSoftwareTexture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFC40A484C240014E966 /* CSoftwareTexture.cpp */; }; - 4C53E49F0A4856B30014E966 /* CCubeSceneNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF000A484C220014E966 /* CCubeSceneNode.cpp */; }; - 4C53E4A00A4856B30014E966 /* CTriangleBBSelector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFD80A484C240014E966 /* CTriangleBBSelector.cpp */; }; - 4C53E4A10A4856B30014E966 /* CD3D9ShaderMaterialRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF160A484C230014E966 /* CD3D9ShaderMaterialRenderer.cpp */; }; - 4C53E4A20A4856B30014E966 /* CD3D8ShaderMaterialRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF090A484C230014E966 /* CD3D8ShaderMaterialRenderer.cpp */; }; - 4C53E4A30A4856B30014E966 /* CGUIButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF2E0A484C230014E966 /* CGUIButton.cpp */; }; - 4C53E4A40A4856B30014E966 /* CGUIToolBar.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF540A484C230014E966 /* CGUIToolBar.cpp */; }; - 4C53E4A50A4856B30014E966 /* CDefaultSceneNodeAnimatorFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF1C0A484C230014E966 /* CDefaultSceneNodeAnimatorFactory.cpp */; }; - 4C53E4A60A4856B30014E966 /* CBillboardSceneNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DEF20A484C220014E966 /* CBillboardSceneNode.cpp */; }; - 4C53E4A70A4856B30014E966 /* CSceneNodeAnimatorCollisionResponse.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFAD0A484C240014E966 /* CSceneNodeAnimatorCollisionResponse.cpp */; }; - 4C53E4A80A4856B30014E966 /* CLogger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF720A484C230014E966 /* CLogger.cpp */; }; - 4C53E4A90A4856B30014E966 /* CGUIInOutFader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF400A484C230014E966 /* CGUIInOutFader.cpp */; }; - 4C53E4AA0A4856B30014E966 /* CWriteFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFF20A484C250014E966 /* CWriteFile.cpp */; }; - 4C53E4AD0A4856B30014E966 /* CTRTextureGouraud.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFDF0A484C250014E966 /* CTRTextureGouraud.cpp */; }; - 4C53E4AE0A4856B30014E966 /* CTRFlat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFD10A484C240014E966 /* CTRFlat.cpp */; }; - 4C53E4AF0A4856B30014E966 /* CTerrainTriangleSelector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFCC0A484C240014E966 /* CTerrainTriangleSelector.cpp */; }; - 4C53E4B00A4856B30014E966 /* COctTreeTriangleSelector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF880A484C240014E966 /* COctTreeTriangleSelector.cpp */; }; - 4C53E4B10A4856B30014E966 /* CGUITabControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF520A484C230014E966 /* CGUITabControl.cpp */; }; - 4C53E4B20A4856B30014E966 /* CParticleBoxEmitter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF9B0A484C240014E966 /* CParticleBoxEmitter.cpp */; }; - 4C53E4B30A4856B30014E966 /* CGUIMenu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF440A484C230014E966 /* CGUIMenu.cpp */; }; - 4C53E4B40A4856B30014E966 /* CImage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF580A484C230014E966 /* CImage.cpp */; }; - 4C53E4B50A4856B30014E966 /* CShadowVolumeSceneNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFBB0A484C240014E966 /* CShadowVolumeSceneNode.cpp */; }; - 4C53E4B70A4856B30014E966 /* CGUIEnvironment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF380A484C230014E966 /* CGUIEnvironment.cpp */; }; - 4C53E4B80A4856B30014E966 /* CLimitReadFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF6E0A484C230014E966 /* CLimitReadFile.cpp */; }; - 4C53E4B90A4856B30014E966 /* CAttributes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DEF00A484C220014E966 /* CAttributes.cpp */; }; - 4C53E4BA0A4856B30014E966 /* COpenGLDriver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF8C0A484C240014E966 /* COpenGLDriver.cpp */; }; - 4C53E4BB0A4856B30014E966 /* CTRTextureLightMap2_M2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DFEB0A484C250014E966 /* CTRTextureLightMap2_M2.cpp */; }; - 4C53E4BC0A4856B30014E966 /* CGUIImage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF3E0A484C230014E966 /* CGUIImage.cpp */; }; - 4C53E4BD0A4856B30014E966 /* CD3D9NormalMapRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF120A484C230014E966 /* CD3D9NormalMapRenderer.cpp */; }; - 4C53E4BE0A4856B30014E966 /* CD3D8NormalMapRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF050A484C220014E966 /* CD3D8NormalMapRenderer.cpp */; }; - 4C53E4BF0A4856B30014E966 /* CMeshCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF760A484C230014E966 /* CMeshCache.cpp */; }; - 4C53E4C00A4856B30014E966 /* CImageLoaderJPG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF5C0A484C230014E966 /* CImageLoaderJPG.cpp */; }; - 4C53E4C10A4856B30014E966 /* CFPSCounter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C53DF2A0A484C230014E966 /* CFPSCounter.cpp */; }; - 4C53E57E0A4856B30014E966 /* OSXClipboard.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E1670A484C2C0014E966 /* OSXClipboard.mm */; }; - 4C53E57F0A4856B30014E966 /* CIrrDeviceMacOSX.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E15F0A484C2C0014E966 /* CIrrDeviceMacOSX.mm */; }; - 4C53E5800A4856B30014E966 /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E14D0A484C2C0014E966 /* AppDelegate.mm */; }; - 4C6DC9B70A48715A0017A6E5 /* inflate.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C6DC9B60A48715A0017A6E5 /* inflate.c */; }; - 4CA25BCE0A485EAD00B4E469 /* jcapimin.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E6F10A485CD80014E966 /* jcapimin.c */; }; - 4CA25BCF0A485EAD00B4E469 /* jcapistd.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E6F20A485CD80014E966 /* jcapistd.c */; }; - 4CA25BD00A485EAD00B4E469 /* jccoefct.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E6F30A485CD80014E966 /* jccoefct.c */; }; - 4CA25BD10A485EAD00B4E469 /* jccolor.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E6F40A485CD80014E966 /* jccolor.c */; }; - 4CA25BD20A485EAD00B4E469 /* jcdctmgr.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E6F50A485CD80014E966 /* jcdctmgr.c */; }; - 4CA25BD30A485EAD00B4E469 /* jchuff.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E6F60A485CD80014E966 /* jchuff.c */; }; - 4CA25BD50A485EAD00B4E469 /* jcinit.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E6F80A485CD80014E966 /* jcinit.c */; }; - 4CA25BD60A485EAD00B4E469 /* jcmainct.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E6F90A485CD80014E966 /* jcmainct.c */; }; - 4CA25BD70A485EAD00B4E469 /* jcmarker.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E6FA0A485CD80014E966 /* jcmarker.c */; }; - 4CA25BD80A485EAD00B4E469 /* jcmaster.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E6FB0A485CD80014E966 /* jcmaster.c */; }; - 4CA25BD90A485EAD00B4E469 /* jcomapi.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E6FC0A485CD80014E966 /* jcomapi.c */; }; - 4CA25BDB0A485EAD00B4E469 /* jcparam.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E70A0A485CD80014E966 /* jcparam.c */; }; - 4CA25BDC0A485EAD00B4E469 /* jcphuff.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E70B0A485CD80014E966 /* jcphuff.c */; }; - 4CA25BDD0A485EAD00B4E469 /* jcprepct.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E70C0A485CD80014E966 /* jcprepct.c */; }; - 4CA25BDE0A485EAD00B4E469 /* jcsample.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E70D0A485CD80014E966 /* jcsample.c */; }; - 4CA25BDF0A485EAD00B4E469 /* jctrans.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E70E0A485CD80014E966 /* jctrans.c */; }; - 4CA25BE00A485EAD00B4E469 /* jdapimin.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E70F0A485CD80014E966 /* jdapimin.c */; }; - 4CA25BE10A485EAD00B4E469 /* jdapistd.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E7100A485CD80014E966 /* jdapistd.c */; }; - 4CA25BE20A485EAD00B4E469 /* jdatadst.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E7110A485CD80014E966 /* jdatadst.c */; }; - 4CA25BE30A485EAD00B4E469 /* jdatasrc.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E7120A485CD80014E966 /* jdatasrc.c */; }; - 4CA25BE40A485EAD00B4E469 /* jdcoefct.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E7130A485CD80014E966 /* jdcoefct.c */; }; - 4CA25BE50A485EAD00B4E469 /* jdcolor.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E7140A485CD80014E966 /* jdcolor.c */; }; - 4CA25BE70A485EAD00B4E469 /* jddctmgr.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E7160A485CD80014E966 /* jddctmgr.c */; }; - 4CA25BE80A485EAD00B4E469 /* jdhuff.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E7170A485CD80014E966 /* jdhuff.c */; }; - 4CA25BEA0A485EAD00B4E469 /* jdinput.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E7190A485CD80014E966 /* jdinput.c */; }; - 4CA25BEB0A485EAD00B4E469 /* jdmainct.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E71A0A485CD80014E966 /* jdmainct.c */; }; - 4CA25BEC0A485EAD00B4E469 /* jdmarker.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E71B0A485CD80014E966 /* jdmarker.c */; }; - 4CA25BED0A485EAD00B4E469 /* jdmaster.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E71C0A485CD80014E966 /* jdmaster.c */; }; - 4CA25BEE0A485EAD00B4E469 /* jdmerge.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E71D0A485CD80014E966 /* jdmerge.c */; }; - 4CA25BEF0A485EAD00B4E469 /* jdphuff.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E71E0A485CD80014E966 /* jdphuff.c */; }; - 4CA25BF00A485EAD00B4E469 /* jdpostct.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E71F0A485CD80014E966 /* jdpostct.c */; }; - 4CA25BF10A485EAD00B4E469 /* jdsample.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E7200A485CD80014E966 /* jdsample.c */; }; - 4CA25BF20A485EAD00B4E469 /* jdtrans.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E7210A485CD80014E966 /* jdtrans.c */; }; - 4CA25BF30A485EAD00B4E469 /* jerror.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E7220A485CD80014E966 /* jerror.c */; }; - 4CA25BF50A485EAD00B4E469 /* jfdctflt.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E7240A485CD80014E966 /* jfdctflt.c */; }; - 4CA25BF60A485EAD00B4E469 /* jfdctfst.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E7250A485CD80014E966 /* jfdctfst.c */; }; - 4CA25BF70A485EAD00B4E469 /* jfdctint.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E7260A485CD80014E966 /* jfdctint.c */; }; - 4CA25BF80A485EAD00B4E469 /* jidctflt.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E7270A485CD80014E966 /* jidctflt.c */; }; - 4CA25BF90A485EAD00B4E469 /* jidctfst.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E7280A485CD80014E966 /* jidctfst.c */; }; - 4CA25BFA0A485EAD00B4E469 /* jidctint.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E7290A485CD80014E966 /* jidctint.c */; }; - 4CA25BFB0A485EAD00B4E469 /* jidctred.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E72A0A485CD80014E966 /* jidctred.c */; }; - 4CA25C000A485EAD00B4E469 /* jmemmgr.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E7300A485CD80014E966 /* jmemmgr.c */; }; - 4CA25C020A485EAD00B4E469 /* jmemnobs.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E7320A485CD80014E966 /* jmemnobs.c */; }; - 4CA25C080A485EAD00B4E469 /* jquant1.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E7390A485CD80014E966 /* jquant1.c */; }; - 4CA25C090A485EAD00B4E469 /* jquant2.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E73A0A485CD80014E966 /* jquant2.c */; }; - 4CA25C0A0A485EAD00B4E469 /* jutils.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E73B0A485CD80014E966 /* jutils.c */; }; - 4CA25C0C0A485EAD00B4E469 /* rdbmp.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E7540A485CD90014E966 /* rdbmp.c */; }; - 4CA25C0D0A485EAD00B4E469 /* rdcolmap.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E7550A485CD90014E966 /* rdcolmap.c */; }; - 4CA25C0E0A485EAD00B4E469 /* rdgif.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E7560A485CD90014E966 /* rdgif.c */; }; - 4CA25C100A485EAD00B4E469 /* rdppm.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E7590A485CD90014E966 /* rdppm.c */; }; - 4CA25C110A485EAD00B4E469 /* rdrle.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E75A0A485CD90014E966 /* rdrle.c */; }; - 4CA25C120A485EAD00B4E469 /* rdswitch.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E75B0A485CD90014E966 /* rdswitch.c */; }; - 4CA25C130A485EAD00B4E469 /* rdtarga.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E75C0A485CD90014E966 /* rdtarga.c */; }; - 4CA25C150A485EAD00B4E469 /* transupp.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E7660A485CD90014E966 /* transupp.c */; }; - 4CA25C170A485EAD00B4E469 /* wrbmp.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E76A0A485CD90014E966 /* wrbmp.c */; }; - 4CA25C180A485EAD00B4E469 /* wrgif.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E76B0A485CD90014E966 /* wrgif.c */; }; - 4CA25C1A0A485EAD00B4E469 /* wrppm.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E76E0A485CD90014E966 /* wrppm.c */; }; - 4CA25C1B0A485EAD00B4E469 /* wrrle.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E76F0A485CD90014E966 /* wrrle.c */; }; - 4CA25C1C0A485EAD00B4E469 /* wrtarga.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C53E7700A485CD90014E966 /* wrtarga.c */; }; - 4CA25C350A4860EE00B4E469 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C00547D0A48470500C844C2 /* main.cpp */; }; - 4CA25C360A48610400B4E469 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 4C53E1650A484C2C0014E966 /* MainMenu.nib */; }; - 4CA25C520A48618800B4E469 /* libIrrlicht.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E24D0A4850120014E966 /* libIrrlicht.a */; }; - 4CA25C560A4861AE00B4E469 /* libIrrlicht.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E24D0A4850120014E966 /* libIrrlicht.a */; }; - 4CA25C690A4861D100B4E469 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C0054830A48470500C844C2 /* main.cpp */; }; - 4CA25C6A0A4861D800B4E469 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 4C53E1650A484C2C0014E966 /* MainMenu.nib */; }; - 4CA25C8B0A48626600B4E469 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 4C53E1650A484C2C0014E966 /* MainMenu.nib */; }; - 4CA25C8C0A48627600B4E469 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C0054890A48470500C844C2 /* main.cpp */; }; - 4CA25C8D0A48628200B4E469 /* libIrrlicht.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E24D0A4850120014E966 /* libIrrlicht.a */; }; - 4CA5CBA70A4869C600ADB3D7 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 4C53E1650A484C2C0014E966 /* MainMenu.nib */; }; - 4CA5CBA90A4869DD00ADB3D7 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 4C53E1650A484C2C0014E966 /* MainMenu.nib */; }; - 4CA5CBAE0A4869E600ADB3D7 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C0054A30A48470500C844C2 /* main.cpp */; }; - 4CA5CBAF0A4869F300ADB3D7 /* libIrrlicht.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E24D0A4850120014E966 /* libIrrlicht.a */; }; - 4CA5CBB00A4869FD00ADB3D7 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C0054AA0A48470500C844C2 /* main.cpp */; }; - 4CA5CBB10A486A0200ADB3D7 /* libIrrlicht.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E24D0A4850120014E966 /* libIrrlicht.a */; }; - 4CA5CBB20A486A0D00ADB3D7 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C0054B00A48470500C844C2 /* main.cpp */; }; - 4CA5CBB30A486A1300ADB3D7 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 4C53E1650A484C2C0014E966 /* MainMenu.nib */; }; - 4CA5CBB40A486A1600ADB3D7 /* libIrrlicht.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E24D0A4850120014E966 /* libIrrlicht.a */; }; - 4CA5CBB50A486A1F00ADB3D7 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C0054B60A48470500C844C2 /* main.cpp */; }; - 4CA5CBB60A486A2200ADB3D7 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 4C53E1650A484C2C0014E966 /* MainMenu.nib */; }; - 4CA5CBB70A486A2500ADB3D7 /* libIrrlicht.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E24D0A4850120014E966 /* libIrrlicht.a */; }; - 4CA5CBB80A486A2E00ADB3D7 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C0054BC0A48470500C844C2 /* main.cpp */; }; - 4CA5CBB90A486A3100ADB3D7 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 4C53E1650A484C2C0014E966 /* MainMenu.nib */; }; - 4CA5CBBA0A486A3A00ADB3D7 /* libIrrlicht.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E24D0A4850120014E966 /* libIrrlicht.a */; }; - 4CA5CBBB0A486A4C00ADB3D7 /* CMainMenu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C0054C70A48470500C844C2 /* CMainMenu.cpp */; }; - 4CA5CBBC0A486A4C00ADB3D7 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C0054CA0A48470500C844C2 /* main.cpp */; }; - 4CA5CBBD0A486A4C00ADB3D7 /* CDemo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C0054C50A48470500C844C2 /* CDemo.cpp */; }; - 4CA5CBBE0A486A4F00ADB3D7 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 4C53E1650A484C2C0014E966 /* MainMenu.nib */; }; - 4CA5CBBF0A486A5700ADB3D7 /* libIrrlicht.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E24D0A4850120014E966 /* libIrrlicht.a */; }; - 4CC36B0F0A6B61DB0076C4B2 /* CSphereSceneNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CC36B0D0A6B61DB0076C4B2 /* CSphereSceneNode.cpp */; }; - 4CF146F50A486648006EBA03 /* libIrrlicht.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E24D0A4850120014E966 /* libIrrlicht.a */; }; - 4CF146F60A486651006EBA03 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 4C53E1650A484C2C0014E966 /* MainMenu.nib */; }; - 4CF146F70A486668006EBA03 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C00548F0A48470500C844C2 /* main.cpp */; }; - 4CF1470A0A4866FA006EBA03 /* libIrrlicht.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E24D0A4850120014E966 /* libIrrlicht.a */; }; - 4CF1470B0A486704006EBA03 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 4C53E1650A484C2C0014E966 /* MainMenu.nib */; }; - 4CF147100A486709006EBA03 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C0054950A48470500C844C2 /* main.cpp */; }; - 4CF147180A48676A006EBA03 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 4C53E1650A484C2C0014E966 /* MainMenu.nib */; }; - 4CF147190A48676E006EBA03 /* libIrrlicht.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C53E24D0A4850120014E966 /* libIrrlicht.a */; }; - 4CF1471A0A486774006EBA03 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C00549B0A48470500C844C2 /* main.cpp */; }; - 4CFA7BEE0A88735A00B03626 /* CImageLoaderBMP.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CFA7BDC0A88735900B03626 /* CImageLoaderBMP.cpp */; }; - 4CFA7BF00A88735A00B03626 /* CImageWriterBMP.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CFA7BDE0A88735900B03626 /* CImageWriterBMP.cpp */; }; - 4CFA7BF20A88735A00B03626 /* CImageWriterJPG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CFA7BE00A88735900B03626 /* CImageWriterJPG.cpp */; }; - 4CFA7BF40A88735A00B03626 /* CImageWriterPCX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CFA7BE20A88735900B03626 /* CImageWriterPCX.cpp */; }; - 4CFA7BF60A88735A00B03626 /* CImageWriterPNG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CFA7BE40A88735900B03626 /* CImageWriterPNG.cpp */; }; - 4CFA7BF80A88735A00B03626 /* CImageWriterPPM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CFA7BE60A88735900B03626 /* CImageWriterPPM.cpp */; }; - 4CFA7BFA0A88735A00B03626 /* CImageWriterPSD.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CFA7BE80A88735900B03626 /* CImageWriterPSD.cpp */; }; - 4CFA7BFC0A88735A00B03626 /* CImageWriterTGA.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CFA7BEA0A88735900B03626 /* CImageWriterTGA.cpp */; }; - 4CFA7BFE0A88735A00B03626 /* CSkyDomeSceneNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CFA7BEC0A88735A00B03626 /* CSkyDomeSceneNode.cpp */; }; - 5DD4804E0C7D91DF00728AA9 /* CDepthBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5DD4804C0C7D91DF00728AA9 /* CDepthBuffer.cpp */; }; - 5DD4804F0C7D91DF00728AA9 /* CDepthBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 5DD4804D0C7D91DF00728AA9 /* CDepthBuffer.h */; }; - 5DD480520C7D936700728AA9 /* IBurningShader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5DD480500C7D936700728AA9 /* IBurningShader.cpp */; }; - 5DD480530C7D936700728AA9 /* IBurningShader.h in Headers */ = {isa = PBXBuildFile; fileRef = 5DD480510C7D936700728AA9 /* IBurningShader.h */; }; - 5DD480550C7D93AB00728AA9 /* IDepthBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 5DD480540C7D93AB00728AA9 /* IDepthBuffer.h */; }; - 5DD4805A0C7D945800728AA9 /* CAnimatedMeshMD3.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5DD480560C7D945800728AA9 /* CAnimatedMeshMD3.cpp */; }; - 5DD4805B0C7D945800728AA9 /* CAnimatedMeshMD3.h in Headers */ = {isa = PBXBuildFile; fileRef = 5DD480570C7D945800728AA9 /* CAnimatedMeshMD3.h */; }; - 5DD4805C0C7D945800728AA9 /* CDefaultGUIElementFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5DD480580C7D945800728AA9 /* CDefaultGUIElementFactory.cpp */; }; - 5DD4805D0C7D945800728AA9 /* CDefaultGUIElementFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 5DD480590C7D945800728AA9 /* CDefaultGUIElementFactory.h */; }; - 5DD480640C7D947B00728AA9 /* CGUIColorSelectDialog.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5DD4805E0C7D947B00728AA9 /* CGUIColorSelectDialog.cpp */; }; - 5DD480650C7D947B00728AA9 /* CGUIColorSelectDialog.h in Headers */ = {isa = PBXBuildFile; fileRef = 5DD4805F0C7D947B00728AA9 /* CGUIColorSelectDialog.h */; }; - 5DD480660C7D947B00728AA9 /* CGUISpinBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5DD480600C7D947B00728AA9 /* CGUISpinBox.cpp */; }; - 5DD480670C7D947B00728AA9 /* CGUISpinBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 5DD480610C7D947B00728AA9 /* CGUISpinBox.h */; }; - 5DD480680C7D947B00728AA9 /* CGUISpriteBank.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5DD480620C7D947B00728AA9 /* CGUISpriteBank.cpp */; }; - 5DD480690C7D947B00728AA9 /* CGUISpriteBank.h in Headers */ = {isa = PBXBuildFile; fileRef = 5DD480630C7D947B00728AA9 /* CGUISpriteBank.h */; }; - 5DD480710C7D94AC00728AA9 /* CQuake3ShaderSceneNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5DD4806A0C7D94AC00728AA9 /* CQuake3ShaderSceneNode.cpp */; }; - 5DD480720C7D94AC00728AA9 /* CQuake3ShaderSceneNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 5DD4806B0C7D94AC00728AA9 /* CQuake3ShaderSceneNode.h */; }; - 5DD480730C7D94AC00728AA9 /* CTRTextureBlend.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5DD4806C0C7D94AC00728AA9 /* CTRTextureBlend.cpp */; }; - 5DD480740C7D94AC00728AA9 /* CTRTextureGouraudAlpha.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5DD4806D0C7D94AC00728AA9 /* CTRTextureGouraudAlpha.cpp */; }; - 5DD480750C7D94AC00728AA9 /* CTRTextureGouraudAlphaNoZ.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5DD4806E0C7D94AC00728AA9 /* CTRTextureGouraudAlphaNoZ.cpp */; }; - 5DD480760C7D94AC00728AA9 /* CTRTextureLightMapGouraud2_M4.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5DD4806F0C7D94AC00728AA9 /* CTRTextureLightMapGouraud2_M4.cpp */; }; - 5DD480770C7D94AC00728AA9 /* glxext.h in Headers */ = {isa = PBXBuildFile; fileRef = 5DD480700C7D94AC00728AA9 /* glxext.h */; }; - 5DD480C70C7DA66800728AA9 /* COpenGLExtensionHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 5DD480C10C7DA66800728AA9 /* COpenGLExtensionHandler.h */; }; - 5DD480C80C7DA66800728AA9 /* CMD3MeshFileLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 5DD480C20C7DA66800728AA9 /* CMD3MeshFileLoader.h */; }; - 5DD480C90C7DA66800728AA9 /* CIrrDeviceSDL.h in Headers */ = {isa = PBXBuildFile; fileRef = 5DD480C30C7DA66800728AA9 /* CIrrDeviceSDL.h */; }; - 5DD480CA0C7DA66800728AA9 /* CIrrDeviceSDL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5DD480C40C7DA66800728AA9 /* CIrrDeviceSDL.cpp */; }; - 5DD480CB0C7DA66800728AA9 /* COpenGLExtensionHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5DD480C50C7DA66800728AA9 /* COpenGLExtensionHandler.cpp */; }; - 5DD480CC0C7DA66800728AA9 /* CMD3MeshFileLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5DD480C60C7DA66800728AA9 /* CMD3MeshFileLoader.cpp */; }; -/* End PBXBuildFile section */ - -/* Begin PBXContainerItemProxy section */ - 09022C540EA0E97F00CD54EE /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = D2AAC07D0554694100DB518D; - remoteInfo = MacOSX; - }; - 0946CCA50EC99BBE00D945A5 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = D2AAC07D0554694100DB518D; - remoteInfo = MacOSX; - }; - 0946CCD50EC99D8200D945A5 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 0946CCA30EC99BBE00D945A5; - remoteInfo = MouseAndJoystick; - }; - 0946CCD80EC99D8C00D945A5 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 09022C520EA0E97F00CD54EE; - remoteInfo = GUIEditor; - }; - 09F648F60D2CDED9001E0599 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = D2AAC07D0554694100DB518D; - remoteInfo = MacOSX; - }; - 09F649200D2CDFF0001E0599 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 09F648F40D2CDED9001E0599; - remoteInfo = HelloWorld; - }; - 09F649310D2CE03E001E0599 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = D2AAC07D0554694100DB518D; - remoteInfo = MacOSX; - }; - 09F649440D2CE100001E0599 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 09F6492F0D2CE03E001E0599; - remoteInfo = LoadIrrFile; - }; - 09F649580D2CE206001E0599 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = D2AAC07D0554694100DB518D; - remoteInfo = MacOSX; - }; - 09F649710D2CE2A1001E0599 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 09F649560D2CE206001E0599; - remoteInfo = Quake3Shader; - }; - 4CA5CB810A4868B500ADB3D7 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = B8DEF35C0950229200FDEA7E; - remoteInfo = Demo; - }; - 4CA5CB830A4868B500ADB3D7 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = B81CFFAF097FE5F80057C06F; - remoteInfo = RenderToTexture; - }; - 4CA5CB850A4868B500ADB3D7 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = B81CFEC2097FDF020057C06F; - remoteInfo = TerrainRendering; - }; - 4CA5CB870A4868B500ADB3D7 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = B81CFEA4097FDE900057C06F; - remoteInfo = PerPixelLightning; - }; - 4CA5CB890A4868B500ADB3D7 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = B81CFF4A097FE3050057C06F; - remoteInfo = Shaders; - }; - 4CA5CB8B0A4868B500ADB3D7 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = B81CFF91097FE45E0057C06F; - remoteInfo = MeshViewer; - }; - 4CA5CB8D0A4868B500ADB3D7 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = B81CFEE8097FE05F0057C06F; - remoteInfo = SpecialFx; - }; - 4CA5CB8F0A4868B500ADB3D7 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = B81CFE82097FDDE20057C06F; - remoteInfo = Collision; - }; - 4CA5CB910A4868B500ADB3D7 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = B81CFDFE097FD9F50057C06F; - remoteInfo = 2DGraphics; - }; - 4CA5CB930A4868B500ADB3D7 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = B81CFF07097FE13E0057C06F; - remoteInfo = UserInterface; - }; - 4CA5CB950A4868B500ADB3D7 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = B81CFF78097FE3DC0057C06F; - remoteInfo = Movement; - }; - 4CA5CB970A4868B500ADB3D7 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = B81CFF1E097FE1E00057C06F; - remoteInfo = CustomSceneNode; - }; - 4CA5CB990A4868B500ADB3D7 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = B81CFF33097FE25F0057C06F; - remoteInfo = Quake3Map; - }; - B81CFE00097FD9F50057C06F /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = D2AAC07D0554694100DB518D; - remoteInfo = MacOSX; - }; - B81CFE84097FDDE20057C06F /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = D2AAC07D0554694100DB518D; - remoteInfo = MacOSX; - }; - B81CFEA6097FDE900057C06F /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = D2AAC07D0554694100DB518D; - remoteInfo = MacOSX; - }; - B81CFEC4097FDF020057C06F /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = D2AAC07D0554694100DB518D; - remoteInfo = MacOSX; - }; - B81CFEEA097FE05F0057C06F /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = D2AAC07D0554694100DB518D; - remoteInfo = MacOSX; - }; - B81CFF09097FE13E0057C06F /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = D2AAC07D0554694100DB518D; - remoteInfo = MacOSX; - }; - B81CFF20097FE1E00057C06F /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = D2AAC07D0554694100DB518D; - remoteInfo = MacOSX; - }; - B81CFF35097FE25F0057C06F /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = D2AAC07D0554694100DB518D; - remoteInfo = MacOSX; - }; - B81CFF4C097FE3050057C06F /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = D2AAC07D0554694100DB518D; - remoteInfo = MacOSX; - }; - B81CFF7A097FE3DC0057C06F /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = D2AAC07D0554694100DB518D; - remoteInfo = MacOSX; - }; - B81CFF93097FE45E0057C06F /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = D2AAC07D0554694100DB518D; - remoteInfo = MacOSX; - }; - B81CFFB1097FE5F80057C06F /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = D2AAC07D0554694100DB518D; - remoteInfo = MacOSX; - }; - B8DEF374095024F600FDEA7E /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = D2AAC07D0554694100DB518D; - remoteInfo = MacOSX; - }; -/* End PBXContainerItemProxy section */ - -/* Begin PBXFileReference section */ - 09022C620EA0E97F00CD54EE /* GUIEditor_dbg.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GUIEditor_dbg.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 09022C680EA0EA9D00CD54EE /* CGUIAttribute.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = CGUIAttribute.h; path = ../../../tools/GUIEditor/CGUIAttribute.h; sourceTree = SOURCE_ROOT; }; - 09022C690EA0EA9D00CD54EE /* CGUIAttributeEditor.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = CGUIAttributeEditor.cpp; path = ../../../tools/GUIEditor/CGUIAttributeEditor.cpp; sourceTree = SOURCE_ROOT; }; - 09022C6A0EA0EA9D00CD54EE /* CGUIAttributeEditor.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = CGUIAttributeEditor.h; path = ../../../tools/GUIEditor/CGUIAttributeEditor.h; sourceTree = SOURCE_ROOT; }; - 09022C6B0EA0EA9D00CD54EE /* CGUIBoolAttribute.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = CGUIBoolAttribute.h; path = ../../../tools/GUIEditor/CGUIBoolAttribute.h; sourceTree = SOURCE_ROOT; }; - 09022C6C0EA0EA9D00CD54EE /* CGUIColorAttribute.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = CGUIColorAttribute.h; path = ../../../tools/GUIEditor/CGUIColorAttribute.h; sourceTree = SOURCE_ROOT; }; - 09022C6D0EA0EA9D00CD54EE /* CGUIDummyEditorStub.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = CGUIDummyEditorStub.h; path = ../../../tools/GUIEditor/CGUIDummyEditorStub.h; sourceTree = SOURCE_ROOT; }; - 09022C6E0EA0EA9D00CD54EE /* CGUIEditFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = CGUIEditFactory.cpp; path = ../../../tools/GUIEditor/CGUIEditFactory.cpp; sourceTree = SOURCE_ROOT; }; - 09022C6F0EA0EA9D00CD54EE /* CGUIEditFactory.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = CGUIEditFactory.h; path = ../../../tools/GUIEditor/CGUIEditFactory.h; sourceTree = SOURCE_ROOT; }; - 09022C700EA0EA9D00CD54EE /* CGUIEditWindow.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = CGUIEditWindow.cpp; path = ../../../tools/GUIEditor/CGUIEditWindow.cpp; sourceTree = SOURCE_ROOT; }; - 09022C710EA0EA9D00CD54EE /* CGUIEditWindow.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = CGUIEditWindow.h; path = ../../../tools/GUIEditor/CGUIEditWindow.h; sourceTree = SOURCE_ROOT; }; - 09022C720EA0EA9D00CD54EE /* CGUIEditWorkspace.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = CGUIEditWorkspace.cpp; path = ../../../tools/GUIEditor/CGUIEditWorkspace.cpp; sourceTree = SOURCE_ROOT; }; - 09022C730EA0EA9D00CD54EE /* CGUIEditWorkspace.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = CGUIEditWorkspace.h; path = ../../../tools/GUIEditor/CGUIEditWorkspace.h; sourceTree = SOURCE_ROOT; }; - 09022C740EA0EA9D00CD54EE /* CGUIEnumAttribute.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = CGUIEnumAttribute.h; path = ../../../tools/GUIEditor/CGUIEnumAttribute.h; sourceTree = SOURCE_ROOT; }; - 09022C750EA0EA9D00CD54EE /* CGUIPanel.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = CGUIPanel.cpp; path = ../../../tools/GUIEditor/CGUIPanel.cpp; sourceTree = SOURCE_ROOT; }; - 09022C760EA0EA9D00CD54EE /* CGUIPanel.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = CGUIPanel.h; path = ../../../tools/GUIEditor/CGUIPanel.h; sourceTree = SOURCE_ROOT; }; - 09022C770EA0EA9D00CD54EE /* CGUIStringAttribute.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = CGUIStringAttribute.h; path = ../../../tools/GUIEditor/CGUIStringAttribute.h; sourceTree = SOURCE_ROOT; }; - 09022C780EA0EA9D00CD54EE /* CGUITextureAttribute.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = CGUITextureAttribute.h; path = ../../../tools/GUIEditor/CGUITextureAttribute.h; sourceTree = SOURCE_ROOT; }; - 09022C790EA0EA9D00CD54EE /* CGUITextureCacheBrowser.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = CGUITextureCacheBrowser.cpp; path = ../../../tools/GUIEditor/CGUITextureCacheBrowser.cpp; sourceTree = SOURCE_ROOT; }; - 09022C7A0EA0EA9D00CD54EE /* CGUITextureCacheBrowser.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = CGUITextureCacheBrowser.h; path = ../../../tools/GUIEditor/CGUITextureCacheBrowser.h; sourceTree = SOURCE_ROOT; }; - 09022C7B0EA0EA9D00CD54EE /* CMemoryReadWriteFile.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = CMemoryReadWriteFile.cpp; path = ../../../tools/GUIEditor/CMemoryReadWriteFile.cpp; sourceTree = SOURCE_ROOT; }; - 09022C7C0EA0EA9D00CD54EE /* CMemoryReadWriteFile.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = CMemoryReadWriteFile.h; path = ../../../tools/GUIEditor/CMemoryReadWriteFile.h; sourceTree = SOURCE_ROOT; }; - 09022C7D0EA0EA9D00CD54EE /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = main.cpp; path = ../../../tools/GUIEditor/main.cpp; sourceTree = SOURCE_ROOT; }; - 090FBC800D31085E0076D847 /* CVolumeLightSceneNode.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CVolumeLightSceneNode.cpp; sourceTree = "<group>"; }; - 090FBC810D31085E0076D847 /* CVolumeLightSceneNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CVolumeLightSceneNode.h; sourceTree = "<group>"; }; - 0910B9D90D1F5D4100D46B04 /* CBurningShader_Raster_Reference.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CBurningShader_Raster_Reference.cpp; sourceTree = "<group>"; }; - 0910B9DA0D1F5D4100D46B04 /* CGUITable.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CGUITable.cpp; sourceTree = "<group>"; }; - 0910B9DB0D1F5D4100D46B04 /* CGUITable.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CGUITable.h; sourceTree = "<group>"; }; - 0910B9DC0D1F5D4100D46B04 /* CImageLoaderWAL.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CImageLoaderWAL.cpp; sourceTree = "<group>"; }; - 0910B9DD0D1F5D4100D46B04 /* CImageLoaderWAL.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CImageLoaderWAL.h; sourceTree = "<group>"; }; - 0910B9FD0D1F64B300D46B04 /* CMeshBuffer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CMeshBuffer.h; sourceTree = "<group>"; }; - 0910B9FE0D1F64B300D46B04 /* coreutil.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = coreutil.h; sourceTree = "<group>"; }; - 0910B9FF0D1F64B300D46B04 /* ECullingTypes.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ECullingTypes.h; sourceTree = "<group>"; }; - 0910BA000D1F64B300D46B04 /* EDebugSceneTypes.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = EDebugSceneTypes.h; sourceTree = "<group>"; }; - 0910BA010D1F64B300D46B04 /* EDriverFeatures.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = EDriverFeatures.h; sourceTree = "<group>"; }; - 0910BA020D1F64B300D46B04 /* EGUIAlignment.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = EGUIAlignment.h; sourceTree = "<group>"; }; - 0910BA030D1F64B300D46B04 /* EHardwareBufferFlags.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = EHardwareBufferFlags.h; sourceTree = "<group>"; }; - 0910BA040D1F64B300D46B04 /* EMaterialFlags.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = EMaterialFlags.h; sourceTree = "<group>"; }; - 0910BA050D1F64B300D46B04 /* EMaterialTypes.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = EMaterialTypes.h; sourceTree = "<group>"; }; - 0910BA060D1F64B300D46B04 /* EMeshWriterEnums.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = EMeshWriterEnums.h; sourceTree = "<group>"; }; - 0910BA070D1F64B300D46B04 /* EMessageBoxFlags.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = EMessageBoxFlags.h; sourceTree = "<group>"; }; - 0910BA080D1F64B300D46B04 /* ETerrainElements.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ETerrainElements.h; sourceTree = "<group>"; }; - 0910BA090D1F64B300D46B04 /* IAnimatedMeshMD3.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IAnimatedMeshMD3.h; sourceTree = "<group>"; }; - 0910BA0A0D1F64B300D46B04 /* IBoneSceneNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IBoneSceneNode.h; sourceTree = "<group>"; }; - 0910BA0B0D1F64B300D46B04 /* IGUIColorSelectDialog.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IGUIColorSelectDialog.h; sourceTree = "<group>"; }; - 0910BA0C0D1F64B300D46B04 /* IGUIElementFactory.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IGUIElementFactory.h; sourceTree = "<group>"; }; - 0910BA0D0D1F64B300D46B04 /* IGUIFontBitmap.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IGUIFontBitmap.h; sourceTree = "<group>"; }; - 0910BA0E0D1F64B300D46B04 /* IGUISpinBox.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IGUISpinBox.h; sourceTree = "<group>"; }; - 0910BA0F0D1F64B300D46B04 /* IGUISpriteBank.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IGUISpriteBank.h; sourceTree = "<group>"; }; - 0910BA100D1F64B300D46B04 /* IGUITable.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IGUITable.h; sourceTree = "<group>"; }; - 0910BA110D1F64B300D46B04 /* IMeshWriter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IMeshWriter.h; sourceTree = "<group>"; }; - 0910BA120D1F64B300D46B04 /* IParticleAnimatedMeshSceneNodeEmitter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IParticleAnimatedMeshSceneNodeEmitter.h; sourceTree = "<group>"; }; - 0910BA130D1F64B300D46B04 /* IParticleAttractionAffector.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IParticleAttractionAffector.h; sourceTree = "<group>"; }; - 0910BA140D1F64B300D46B04 /* IParticleBoxEmitter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IParticleBoxEmitter.h; sourceTree = "<group>"; }; - 0910BA150D1F64B300D46B04 /* IParticleCylinderEmitter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IParticleCylinderEmitter.h; sourceTree = "<group>"; }; - 0910BA160D1F64B300D46B04 /* IParticleFadeOutAffector.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IParticleFadeOutAffector.h; sourceTree = "<group>"; }; - 0910BA170D1F64B300D46B04 /* IParticleGravityAffector.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IParticleGravityAffector.h; sourceTree = "<group>"; }; - 0910BA180D1F64B300D46B04 /* IParticleMeshEmitter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IParticleMeshEmitter.h; sourceTree = "<group>"; }; - 0910BA190D1F64B300D46B04 /* IParticleRingEmitter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IParticleRingEmitter.h; sourceTree = "<group>"; }; - 0910BA1A0D1F64B300D46B04 /* IParticleRotationAffector.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IParticleRotationAffector.h; sourceTree = "<group>"; }; - 0910BA1B0D1F64B300D46B04 /* IParticleSphereEmitter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IParticleSphereEmitter.h; sourceTree = "<group>"; }; - 0910BA1C0D1F64B300D46B04 /* IQ3Shader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IQ3Shader.h; sourceTree = "<group>"; }; - 0910BA1D0D1F64B300D46B04 /* IReferenceCounted.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IReferenceCounted.h; sourceTree = "<group>"; }; - 0910BA1E0D1F64B300D46B04 /* irrMap.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = irrMap.h; sourceTree = "<group>"; }; - 0910BA1F0D1F64B300D46B04 /* ISkinnedMesh.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ISkinnedMesh.h; sourceTree = "<group>"; }; - 0910BA200D1F64B300D46B04 /* SMaterialLayer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SMaterialLayer.h; sourceTree = "<group>"; }; - 0910BA210D1F64B300D46B04 /* SSharedMeshBuffer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SSharedMeshBuffer.h; sourceTree = "<group>"; }; - 0910BA220D1F64B300D46B04 /* SSkinMeshBuffer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SSkinMeshBuffer.h; sourceTree = "<group>"; }; - 0910BA230D1F64B300D46B04 /* SViewFrustum.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SViewFrustum.h; sourceTree = "<group>"; }; - 0925113D0D744ADE006784D9 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = "<absolute>"; }; - 09293C2C0ED32029003B8C9C /* png.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = png.c; path = libpng/png.c; sourceTree = "<group>"; }; - 09293C2D0ED32029003B8C9C /* pngerror.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngerror.c; path = libpng/pngerror.c; sourceTree = "<group>"; }; - 09293C2E0ED32029003B8C9C /* pnggccrd.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pnggccrd.c; path = libpng/pnggccrd.c; sourceTree = "<group>"; }; - 09293C2F0ED32029003B8C9C /* pngget.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngget.c; path = libpng/pngget.c; sourceTree = "<group>"; }; - 09293C300ED32029003B8C9C /* pngmem.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngmem.c; path = libpng/pngmem.c; sourceTree = "<group>"; }; - 09293C310ED32029003B8C9C /* pngpread.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngpread.c; path = libpng/pngpread.c; sourceTree = "<group>"; }; - 09293C320ED32029003B8C9C /* pngread.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngread.c; path = libpng/pngread.c; sourceTree = "<group>"; }; - 09293C330ED32029003B8C9C /* pngrio.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngrio.c; path = libpng/pngrio.c; sourceTree = "<group>"; }; - 09293C340ED32029003B8C9C /* pngrtran.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngrtran.c; path = libpng/pngrtran.c; sourceTree = "<group>"; }; - 09293C350ED32029003B8C9C /* pngrutil.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngrutil.c; path = libpng/pngrutil.c; sourceTree = "<group>"; }; - 09293C360ED32029003B8C9C /* pngset.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngset.c; path = libpng/pngset.c; sourceTree = "<group>"; }; - 09293C380ED32029003B8C9C /* pngtrans.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngtrans.c; path = libpng/pngtrans.c; sourceTree = "<group>"; }; - 09293C3A0ED32029003B8C9C /* pngwio.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngwio.c; path = libpng/pngwio.c; sourceTree = "<group>"; }; - 09293C3B0ED32029003B8C9C /* pngwrite.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngwrite.c; path = libpng/pngwrite.c; sourceTree = "<group>"; }; - 09293C3C0ED32029003B8C9C /* pngwtran.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngwtran.c; path = libpng/pngwtran.c; sourceTree = "<group>"; }; - 09293C3D0ED32029003B8C9C /* pngwutil.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngwutil.c; path = libpng/pngwutil.c; sourceTree = "<group>"; }; - 0930CE550EC39F4500D63866 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = /System/Library/Frameworks/IOKit.framework; sourceTree = "<absolute>"; }; - 093973BC0E0458B200E0C987 /* CSceneNodeAnimatorCameraFPS.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CSceneNodeAnimatorCameraFPS.cpp; sourceTree = "<group>"; }; - 093973BD0E0458B200E0C987 /* CSceneNodeAnimatorCameraFPS.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CSceneNodeAnimatorCameraFPS.h; sourceTree = "<group>"; }; - 093973BE0E0458B200E0C987 /* CSceneNodeAnimatorCameraMaya.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CSceneNodeAnimatorCameraMaya.cpp; sourceTree = "<group>"; }; - 093973BF0E0458B200E0C987 /* CSceneNodeAnimatorCameraMaya.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CSceneNodeAnimatorCameraMaya.h; sourceTree = "<group>"; }; - 0946CCB40EC99BBE00D945A5 /* MouseAndJoystick_dbg.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MouseAndJoystick_dbg.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 0946CCCA0EC99C6E00D945A5 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = main.cpp; path = 19.MouseAndJoystick/main.cpp; sourceTree = "<group>"; }; - 0968401E0D0F1A2300333EFD /* CB3DMeshFileLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CB3DMeshFileLoader.cpp; sourceTree = "<group>"; }; - 0968401F0D0F1A2300333EFD /* CB3DMeshFileLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CB3DMeshFileLoader.h; sourceTree = "<group>"; }; - 096840200D0F1A2300333EFD /* CBoneSceneNode.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CBoneSceneNode.cpp; sourceTree = "<group>"; }; - 096840210D0F1A2300333EFD /* CBoneSceneNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CBoneSceneNode.h; sourceTree = "<group>"; }; - 096840220D0F1A2300333EFD /* CBSPMeshFileLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CBSPMeshFileLoader.cpp; sourceTree = "<group>"; }; - 096840230D0F1A2300333EFD /* CBSPMeshFileLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CBSPMeshFileLoader.h; sourceTree = "<group>"; }; - 096840250D0F1A2300333EFD /* CColladaMeshWriter.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CColladaMeshWriter.cpp; sourceTree = "<group>"; }; - 096840260D0F1A2300333EFD /* CColladaMeshWriter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CColladaMeshWriter.h; sourceTree = "<group>"; }; - 096840270D0F1A2300333EFD /* CImageLoaderPPM.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CImageLoaderPPM.cpp; sourceTree = "<group>"; }; - 096840280D0F1A2300333EFD /* CImageLoaderPPM.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CImageLoaderPPM.h; sourceTree = "<group>"; }; - 0968402B0D0F1A2300333EFD /* CIrrMeshFileLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CIrrMeshFileLoader.cpp; sourceTree = "<group>"; }; - 0968402C0D0F1A2300333EFD /* CIrrMeshFileLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CIrrMeshFileLoader.h; sourceTree = "<group>"; }; - 0968402D0D0F1A2300333EFD /* CIrrMeshWriter.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CIrrMeshWriter.cpp; sourceTree = "<group>"; }; - 0968402E0D0F1A2300333EFD /* CIrrMeshWriter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CIrrMeshWriter.h; sourceTree = "<group>"; }; - 0968402F0D0F1A2300333EFD /* CMD2MeshFileLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CMD2MeshFileLoader.cpp; sourceTree = "<group>"; }; - 096840300D0F1A2300333EFD /* CMD2MeshFileLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CMD2MeshFileLoader.h; sourceTree = "<group>"; }; - 096840310D0F1A2300333EFD /* CMS3DMeshFileLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CMS3DMeshFileLoader.cpp; sourceTree = "<group>"; }; - 096840320D0F1A2300333EFD /* CMS3DMeshFileLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CMS3DMeshFileLoader.h; sourceTree = "<group>"; }; - 096840330D0F1A2300333EFD /* CParticleAnimatedMeshSceneNodeEmitter.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CParticleAnimatedMeshSceneNodeEmitter.cpp; sourceTree = "<group>"; }; - 096840340D0F1A2300333EFD /* CParticleAnimatedMeshSceneNodeEmitter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CParticleAnimatedMeshSceneNodeEmitter.h; sourceTree = "<group>"; }; - 096840350D0F1A2300333EFD /* CParticleAttractionAffector.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CParticleAttractionAffector.cpp; sourceTree = "<group>"; }; - 096840360D0F1A2300333EFD /* CParticleAttractionAffector.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CParticleAttractionAffector.h; sourceTree = "<group>"; }; - 096840370D0F1A2300333EFD /* CParticleCylinderEmitter.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CParticleCylinderEmitter.cpp; sourceTree = "<group>"; }; - 096840380D0F1A2300333EFD /* CParticleCylinderEmitter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CParticleCylinderEmitter.h; sourceTree = "<group>"; }; - 096840390D0F1A2300333EFD /* CParticleMeshEmitter.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CParticleMeshEmitter.cpp; sourceTree = "<group>"; }; - 0968403A0D0F1A2300333EFD /* CParticleMeshEmitter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CParticleMeshEmitter.h; sourceTree = "<group>"; }; - 0968403B0D0F1A2300333EFD /* CParticleRingEmitter.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CParticleRingEmitter.cpp; sourceTree = "<group>"; }; - 0968403C0D0F1A2300333EFD /* CParticleRingEmitter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CParticleRingEmitter.h; sourceTree = "<group>"; }; - 0968403D0D0F1A2300333EFD /* CParticleRotationAffector.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CParticleRotationAffector.cpp; sourceTree = "<group>"; }; - 0968403E0D0F1A2300333EFD /* CParticleRotationAffector.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CParticleRotationAffector.h; sourceTree = "<group>"; }; - 0968403F0D0F1A2300333EFD /* CParticleSphereEmitter.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CParticleSphereEmitter.cpp; sourceTree = "<group>"; }; - 096840400D0F1A2300333EFD /* CParticleSphereEmitter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CParticleSphereEmitter.h; sourceTree = "<group>"; }; - 096840410D0F1A2300333EFD /* CSkinnedMesh.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CSkinnedMesh.cpp; sourceTree = "<group>"; }; - 096840420D0F1A2300333EFD /* CSkinnedMesh.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CSkinnedMesh.h; sourceTree = "<group>"; }; - 096840430D0F1A2300333EFD /* CSTLMeshFileLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CSTLMeshFileLoader.cpp; sourceTree = "<group>"; }; - 096840440D0F1A2300333EFD /* CSTLMeshFileLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CSTLMeshFileLoader.h; sourceTree = "<group>"; }; - 096840450D0F1A2300333EFD /* CSTLMeshWriter.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CSTLMeshWriter.cpp; sourceTree = "<group>"; }; - 096840460D0F1A2300333EFD /* CSTLMeshWriter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CSTLMeshWriter.h; sourceTree = "<group>"; }; - 096CC0DE0ECE65B500C81DC7 /* CParticleScaleAffector.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CParticleScaleAffector.cpp; sourceTree = "<group>"; }; - 096CC0DF0ECE65B500C81DC7 /* CParticleScaleAffector.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CParticleScaleAffector.h; sourceTree = "<group>"; }; - 096F8E3B0EA2EFBA00907EC5 /* COBJMeshWriter.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = COBJMeshWriter.cpp; sourceTree = "<group>"; }; - 096F8E3C0EA2EFBA00907EC5 /* COBJMeshWriter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = COBJMeshWriter.h; sourceTree = "<group>"; }; - 09C638700D4F1A69000B6A18 /* CLWOMeshFileLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CLWOMeshFileLoader.cpp; sourceTree = "<group>"; }; - 09C638710D4F1A69000B6A18 /* CLWOMeshFileLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CLWOMeshFileLoader.h; sourceTree = "<group>"; }; - 09F649030D2CDED9001E0599 /* HelloWorld_dbg.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HelloWorld_dbg.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 09F6492E0D2CE038001E0599 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = main.cpp; path = 15.LoadIrrFile/main.cpp; sourceTree = "<group>"; }; - 09F6493E0D2CE03E001E0599 /* LoadIrrFile_dbg.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LoadIrrFile_dbg.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 09F649650D2CE206001E0599 /* Quake3Shader_dbg.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Quake3Shader_dbg.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 09F649730D2CE2D0001E0599 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = main.cpp; path = 16.Quake3MapShader/main.cpp; sourceTree = "<group>"; }; - 3430E4D41022C391006271FD /* CTarReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CTarReader.h; sourceTree = "<group>"; }; - 3430E4D51022C391006271FD /* CTarReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CTarReader.cpp; sourceTree = "<group>"; }; - 344FD4A41039E98C0045FD3F /* CMountPointReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CMountPointReader.cpp; sourceTree = "<group>"; }; - 344FD4A51039E98C0045FD3F /* CMountPointReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CMountPointReader.h; sourceTree = "<group>"; }; - 3484C4DF0F48D1B000C81F60 /* CGUIImageList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGUIImageList.h; sourceTree = "<group>"; }; - 3484C4E00F48D1B000C81F60 /* CGUIImageList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CGUIImageList.cpp; sourceTree = "<group>"; }; - 3484C4EC0F48D3A100C81F60 /* CGUITreeView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGUITreeView.h; sourceTree = "<group>"; }; - 3484C4ED0F48D3A100C81F60 /* CGUITreeView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CGUITreeView.cpp; sourceTree = "<group>"; }; - 3484C4FB0F48D4CB00C81F60 /* CMemoryFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CMemoryFile.h; sourceTree = "<group>"; }; - 3484C4FC0F48D4CB00C81F60 /* CMemoryFile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CMemoryFile.cpp; sourceTree = "<group>"; }; - 34EC243A0F59272E0037BC3A /* CIrrDeviceConsole.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CIrrDeviceConsole.h; sourceTree = "<group>"; }; - 34EC243B0F59272E0037BC3A /* CIrrDeviceConsole.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CIrrDeviceConsole.cpp; sourceTree = "<group>"; }; - 34EF91D00F65FCA6000B5651 /* CImageLoaderRGB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CImageLoaderRGB.h; sourceTree = "<group>"; }; - 34EF91D10F65FCA6000B5651 /* CImageLoaderRGB.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CImageLoaderRGB.cpp; sourceTree = "<group>"; }; - 34EF91D50F65FCF6000B5651 /* CPLYMeshFileLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CPLYMeshFileLoader.h; sourceTree = "<group>"; }; - 34EF91D60F65FCF6000B5651 /* CPLYMeshFileLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CPLYMeshFileLoader.cpp; sourceTree = "<group>"; }; - 34EF91DA0F65FD14000B5651 /* CPLYMeshWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CPLYMeshWriter.h; sourceTree = "<group>"; }; - 34EF91DB0F65FD14000B5651 /* CPLYMeshWriter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CPLYMeshWriter.cpp; sourceTree = "<group>"; }; - 4C0054710A48470500C844C2 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; }; - 4C0054770A48470500C844C2 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; }; - 4C00547D0A48470500C844C2 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; }; - 4C0054830A48470500C844C2 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 2; path = main.cpp; sourceTree = "<group>"; }; - 4C0054890A48470500C844C2 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; }; - 4C00548F0A48470500C844C2 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; }; - 4C0054950A48470500C844C2 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; }; - 4C00549B0A48470500C844C2 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; }; - 4C0054A30A48470500C844C2 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; }; - 4C0054AA0A48470500C844C2 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; }; - 4C0054B00A48470500C844C2 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; }; - 4C0054B60A48470500C844C2 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; }; - 4C0054BC0A48470500C844C2 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; }; - 4C0054C50A48470500C844C2 /* CDemo.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CDemo.cpp; sourceTree = "<group>"; }; - 4C0054C60A48470500C844C2 /* CDemo.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CDemo.h; sourceTree = "<group>"; }; - 4C0054C70A48470500C844C2 /* CMainMenu.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CMainMenu.cpp; sourceTree = "<group>"; }; - 4C0054C80A48470500C844C2 /* CMainMenu.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CMainMenu.h; sourceTree = "<group>"; }; - 4C0054CA0A48470500C844C2 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; }; - 4C364EA20A6C6DC2004CFBB4 /* COBJMeshFileLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = COBJMeshFileLoader.cpp; sourceTree = "<group>"; }; - 4C364EA30A6C6DC2004CFBB4 /* COBJMeshFileLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = COBJMeshFileLoader.h; sourceTree = "<group>"; }; - 4C43EEBE0A74A5C800F942FC /* CPakReader.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CPakReader.cpp; sourceTree = "<group>"; }; - 4C43EEBF0A74A5C800F942FC /* CPakReader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CPakReader.h; sourceTree = "<group>"; }; - 4C53DEE60A484C220014E966 /* BuiltInFont.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; lineEnding = 2; path = BuiltInFont.h; sourceTree = "<group>"; }; - 4C53DEE70A484C220014E966 /* C3DSMeshFileLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 2; path = C3DSMeshFileLoader.cpp; sourceTree = "<group>"; }; - 4C53DEE80A484C220014E966 /* C3DSMeshFileLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = C3DSMeshFileLoader.h; sourceTree = "<group>"; }; - 4C53DEE90A484C220014E966 /* CAnimatedMeshMD2.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 2; path = CAnimatedMeshMD2.cpp; sourceTree = "<group>"; }; - 4C53DEEA0A484C220014E966 /* CAnimatedMeshMD2.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CAnimatedMeshMD2.h; sourceTree = "<group>"; }; - 4C53DEED0A484C220014E966 /* CAnimatedMeshSceneNode.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CAnimatedMeshSceneNode.cpp; sourceTree = "<group>"; }; - 4C53DEEE0A484C220014E966 /* CAnimatedMeshSceneNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CAnimatedMeshSceneNode.h; sourceTree = "<group>"; }; - 4C53DEEF0A484C220014E966 /* CAttributeImpl.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CAttributeImpl.h; sourceTree = "<group>"; }; - 4C53DEF00A484C220014E966 /* CAttributes.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CAttributes.cpp; sourceTree = "<group>"; }; - 4C53DEF10A484C220014E966 /* CAttributes.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CAttributes.h; sourceTree = "<group>"; }; - 4C53DEF20A484C220014E966 /* CBillboardSceneNode.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CBillboardSceneNode.cpp; sourceTree = "<group>"; }; - 4C53DEF30A484C220014E966 /* CBillboardSceneNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CBillboardSceneNode.h; sourceTree = "<group>"; }; - 4C53DEF80A484C220014E966 /* CCameraSceneNode.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CCameraSceneNode.cpp; sourceTree = "<group>"; }; - 4C53DEF90A484C220014E966 /* CCameraSceneNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CCameraSceneNode.h; sourceTree = "<group>"; }; - 4C53DEFA0A484C220014E966 /* CColladaFileLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CColladaFileLoader.cpp; sourceTree = "<group>"; }; - 4C53DEFB0A484C220014E966 /* CColladaFileLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CColladaFileLoader.h; sourceTree = "<group>"; }; - 4C53DEFC0A484C220014E966 /* CColorConverter.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 2; path = CColorConverter.cpp; sourceTree = "<group>"; }; - 4C53DEFD0A484C220014E966 /* CColorConverter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CColorConverter.h; sourceTree = "<group>"; }; - 4C53DEFE0A484C220014E966 /* CCSMLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CCSMLoader.cpp; sourceTree = "<group>"; }; - 4C53DEFF0A484C220014E966 /* CCSMLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CCSMLoader.h; sourceTree = "<group>"; }; - 4C53DF000A484C220014E966 /* CCubeSceneNode.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CCubeSceneNode.cpp; sourceTree = "<group>"; }; - 4C53DF010A484C220014E966 /* CCubeSceneNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CCubeSceneNode.h; sourceTree = "<group>"; }; - 4C53DF020A484C220014E966 /* CD3D8Driver.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CD3D8Driver.cpp; sourceTree = "<group>"; }; - 4C53DF030A484C220014E966 /* CD3D8Driver.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CD3D8Driver.h; sourceTree = "<group>"; }; - 4C53DF040A484C220014E966 /* CD3D8MaterialRenderer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CD3D8MaterialRenderer.h; sourceTree = "<group>"; }; - 4C53DF050A484C220014E966 /* CD3D8NormalMapRenderer.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CD3D8NormalMapRenderer.cpp; sourceTree = "<group>"; }; - 4C53DF060A484C220014E966 /* CD3D8NormalMapRenderer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CD3D8NormalMapRenderer.h; sourceTree = "<group>"; }; - 4C53DF070A484C230014E966 /* CD3D8ParallaxMapRenderer.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CD3D8ParallaxMapRenderer.cpp; sourceTree = "<group>"; }; - 4C53DF080A484C230014E966 /* CD3D8ParallaxMapRenderer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CD3D8ParallaxMapRenderer.h; sourceTree = "<group>"; }; - 4C53DF090A484C230014E966 /* CD3D8ShaderMaterialRenderer.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CD3D8ShaderMaterialRenderer.cpp; sourceTree = "<group>"; }; - 4C53DF0A0A484C230014E966 /* CD3D8ShaderMaterialRenderer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CD3D8ShaderMaterialRenderer.h; sourceTree = "<group>"; }; - 4C53DF0B0A484C230014E966 /* CD3D8Texture.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CD3D8Texture.cpp; sourceTree = "<group>"; }; - 4C53DF0C0A484C230014E966 /* CD3D8Texture.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CD3D8Texture.h; sourceTree = "<group>"; }; - 4C53DF0D0A484C230014E966 /* CD3D9Driver.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CD3D9Driver.cpp; sourceTree = "<group>"; }; - 4C53DF0E0A484C230014E966 /* CD3D9Driver.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CD3D9Driver.h; sourceTree = "<group>"; }; - 4C53DF0F0A484C230014E966 /* CD3D9HLSLMaterialRenderer.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CD3D9HLSLMaterialRenderer.cpp; sourceTree = "<group>"; }; - 4C53DF100A484C230014E966 /* CD3D9HLSLMaterialRenderer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CD3D9HLSLMaterialRenderer.h; sourceTree = "<group>"; }; - 4C53DF110A484C230014E966 /* CD3D9MaterialRenderer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CD3D9MaterialRenderer.h; sourceTree = "<group>"; }; - 4C53DF120A484C230014E966 /* CD3D9NormalMapRenderer.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CD3D9NormalMapRenderer.cpp; sourceTree = "<group>"; }; - 4C53DF130A484C230014E966 /* CD3D9NormalMapRenderer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CD3D9NormalMapRenderer.h; sourceTree = "<group>"; }; - 4C53DF140A484C230014E966 /* CD3D9ParallaxMapRenderer.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CD3D9ParallaxMapRenderer.cpp; sourceTree = "<group>"; }; - 4C53DF150A484C230014E966 /* CD3D9ParallaxMapRenderer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CD3D9ParallaxMapRenderer.h; sourceTree = "<group>"; }; - 4C53DF160A484C230014E966 /* CD3D9ShaderMaterialRenderer.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CD3D9ShaderMaterialRenderer.cpp; sourceTree = "<group>"; }; - 4C53DF170A484C230014E966 /* CD3D9ShaderMaterialRenderer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CD3D9ShaderMaterialRenderer.h; sourceTree = "<group>"; }; - 4C53DF180A484C230014E966 /* CD3D9Texture.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CD3D9Texture.cpp; sourceTree = "<group>"; }; - 4C53DF190A484C230014E966 /* CD3D9Texture.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CD3D9Texture.h; sourceTree = "<group>"; }; - 4C53DF1C0A484C230014E966 /* CDefaultSceneNodeAnimatorFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CDefaultSceneNodeAnimatorFactory.cpp; sourceTree = "<group>"; }; - 4C53DF1D0A484C230014E966 /* CDefaultSceneNodeAnimatorFactory.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CDefaultSceneNodeAnimatorFactory.h; sourceTree = "<group>"; }; - 4C53DF1E0A484C230014E966 /* CDefaultSceneNodeFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CDefaultSceneNodeFactory.cpp; sourceTree = "<group>"; }; - 4C53DF1F0A484C230014E966 /* CDefaultSceneNodeFactory.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CDefaultSceneNodeFactory.h; sourceTree = "<group>"; }; - 4C53DF200A484C230014E966 /* CDMFLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CDMFLoader.cpp; sourceTree = "<group>"; }; - 4C53DF210A484C230014E966 /* CDMFLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CDMFLoader.h; sourceTree = "<group>"; }; - 4C53DF220A484C230014E966 /* CDummyTransformationSceneNode.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CDummyTransformationSceneNode.cpp; sourceTree = "<group>"; }; - 4C53DF230A484C230014E966 /* CDummyTransformationSceneNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CDummyTransformationSceneNode.h; sourceTree = "<group>"; }; - 4C53DF240A484C230014E966 /* CEmptySceneNode.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CEmptySceneNode.cpp; sourceTree = "<group>"; }; - 4C53DF250A484C230014E966 /* CEmptySceneNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CEmptySceneNode.h; sourceTree = "<group>"; }; - 4C53DF260A484C230014E966 /* CFileList.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CFileList.cpp; sourceTree = "<group>"; }; - 4C53DF270A484C230014E966 /* CFileList.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CFileList.h; sourceTree = "<group>"; }; - 4C53DF280A484C230014E966 /* CFileSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CFileSystem.cpp; sourceTree = "<group>"; }; - 4C53DF290A484C230014E966 /* CFileSystem.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CFileSystem.h; sourceTree = "<group>"; }; - 4C53DF2A0A484C230014E966 /* CFPSCounter.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CFPSCounter.cpp; sourceTree = "<group>"; }; - 4C53DF2B0A484C230014E966 /* CFPSCounter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CFPSCounter.h; sourceTree = "<group>"; }; - 4C53DF2C0A484C230014E966 /* CGeometryCreator.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CGeometryCreator.cpp; sourceTree = "<group>"; }; - 4C53DF2D0A484C230014E966 /* CGeometryCreator.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CGeometryCreator.h; sourceTree = "<group>"; }; - 4C53DF2E0A484C230014E966 /* CGUIButton.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CGUIButton.cpp; sourceTree = "<group>"; }; - 4C53DF2F0A484C230014E966 /* CGUIButton.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CGUIButton.h; sourceTree = "<group>"; }; - 4C53DF300A484C230014E966 /* CGUICheckBox.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CGUICheckBox.cpp; sourceTree = "<group>"; }; - 4C53DF310A484C230014E966 /* CGUICheckBox.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CGUICheckBox.h; sourceTree = "<group>"; }; - 4C53DF320A484C230014E966 /* CGUIComboBox.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CGUIComboBox.cpp; sourceTree = "<group>"; }; - 4C53DF330A484C230014E966 /* CGUIComboBox.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CGUIComboBox.h; sourceTree = "<group>"; }; - 4C53DF340A484C230014E966 /* CGUIContextMenu.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CGUIContextMenu.cpp; sourceTree = "<group>"; }; - 4C53DF350A484C230014E966 /* CGUIContextMenu.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CGUIContextMenu.h; sourceTree = "<group>"; }; - 4C53DF360A484C230014E966 /* CGUIEditBox.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CGUIEditBox.cpp; sourceTree = "<group>"; }; - 4C53DF370A484C230014E966 /* CGUIEditBox.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CGUIEditBox.h; sourceTree = "<group>"; }; - 4C53DF380A484C230014E966 /* CGUIEnvironment.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 2; path = CGUIEnvironment.cpp; sourceTree = "<group>"; }; - 4C53DF390A484C230014E966 /* CGUIEnvironment.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CGUIEnvironment.h; sourceTree = "<group>"; }; - 4C53DF3A0A484C230014E966 /* CGUIFileOpenDialog.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CGUIFileOpenDialog.cpp; sourceTree = "<group>"; }; - 4C53DF3B0A484C230014E966 /* CGUIFileOpenDialog.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CGUIFileOpenDialog.h; sourceTree = "<group>"; }; - 4C53DF3C0A484C230014E966 /* CGUIFont.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 2; path = CGUIFont.cpp; sourceTree = "<group>"; }; - 4C53DF3D0A484C230014E966 /* CGUIFont.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CGUIFont.h; sourceTree = "<group>"; }; - 4C53DF3E0A484C230014E966 /* CGUIImage.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CGUIImage.cpp; sourceTree = "<group>"; }; - 4C53DF3F0A484C230014E966 /* CGUIImage.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CGUIImage.h; sourceTree = "<group>"; }; - 4C53DF400A484C230014E966 /* CGUIInOutFader.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CGUIInOutFader.cpp; sourceTree = "<group>"; }; - 4C53DF410A484C230014E966 /* CGUIInOutFader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CGUIInOutFader.h; sourceTree = "<group>"; }; - 4C53DF420A484C230014E966 /* CGUIListBox.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CGUIListBox.cpp; sourceTree = "<group>"; }; - 4C53DF430A484C230014E966 /* CGUIListBox.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CGUIListBox.h; sourceTree = "<group>"; }; - 4C53DF440A484C230014E966 /* CGUIMenu.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CGUIMenu.cpp; sourceTree = "<group>"; }; - 4C53DF450A484C230014E966 /* CGUIMenu.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CGUIMenu.h; sourceTree = "<group>"; }; - 4C53DF460A484C230014E966 /* CGUIMeshViewer.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CGUIMeshViewer.cpp; sourceTree = "<group>"; }; - 4C53DF470A484C230014E966 /* CGUIMeshViewer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CGUIMeshViewer.h; sourceTree = "<group>"; }; - 4C53DF480A484C230014E966 /* CGUIMessageBox.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CGUIMessageBox.cpp; sourceTree = "<group>"; }; - 4C53DF490A484C230014E966 /* CGUIMessageBox.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CGUIMessageBox.h; sourceTree = "<group>"; }; - 4C53DF4A0A484C230014E966 /* CGUIModalScreen.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CGUIModalScreen.cpp; sourceTree = "<group>"; }; - 4C53DF4B0A484C230014E966 /* CGUIModalScreen.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CGUIModalScreen.h; sourceTree = "<group>"; }; - 4C53DF4C0A484C230014E966 /* CGUIScrollBar.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CGUIScrollBar.cpp; sourceTree = "<group>"; }; - 4C53DF4D0A484C230014E966 /* CGUIScrollBar.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CGUIScrollBar.h; sourceTree = "<group>"; }; - 4C53DF4E0A484C230014E966 /* CGUISkin.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CGUISkin.cpp; sourceTree = "<group>"; }; - 4C53DF4F0A484C230014E966 /* CGUISkin.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CGUISkin.h; sourceTree = "<group>"; }; - 4C53DF500A484C230014E966 /* CGUIStaticText.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CGUIStaticText.cpp; sourceTree = "<group>"; }; - 4C53DF510A484C230014E966 /* CGUIStaticText.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CGUIStaticText.h; sourceTree = "<group>"; }; - 4C53DF520A484C230014E966 /* CGUITabControl.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CGUITabControl.cpp; sourceTree = "<group>"; }; - 4C53DF530A484C230014E966 /* CGUITabControl.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CGUITabControl.h; sourceTree = "<group>"; }; - 4C53DF540A484C230014E966 /* CGUIToolBar.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CGUIToolBar.cpp; sourceTree = "<group>"; }; - 4C53DF550A484C230014E966 /* CGUIToolBar.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CGUIToolBar.h; sourceTree = "<group>"; }; - 4C53DF560A484C230014E966 /* CGUIWindow.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CGUIWindow.cpp; sourceTree = "<group>"; }; - 4C53DF570A484C230014E966 /* CGUIWindow.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CGUIWindow.h; sourceTree = "<group>"; }; - 4C53DF580A484C230014E966 /* CImage.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CImage.cpp; sourceTree = "<group>"; }; - 4C53DF590A484C230014E966 /* CImage.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CImage.h; sourceTree = "<group>"; }; - 4C53DF5C0A484C230014E966 /* CImageLoaderJPG.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CImageLoaderJPG.cpp; sourceTree = "<group>"; }; - 4C53DF5D0A484C230014E966 /* CImageLoaderJPG.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CImageLoaderJPG.h; sourceTree = "<group>"; }; - 4C53DF5E0A484C230014E966 /* CImageLoaderPCX.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 2; path = CImageLoaderPCX.cpp; sourceTree = "<group>"; }; - 4C53DF5F0A484C230014E966 /* CImageLoaderPCX.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CImageLoaderPCX.h; sourceTree = "<group>"; }; - 4C53DF600A484C230014E966 /* CImageLoaderPNG.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CImageLoaderPNG.cpp; sourceTree = "<group>"; }; - 4C53DF610A484C230014E966 /* CImageLoaderPNG.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CImageLoaderPNG.h; sourceTree = "<group>"; }; - 4C53DF620A484C230014E966 /* CImageLoaderPSD.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 2; path = CImageLoaderPSD.cpp; sourceTree = "<group>"; }; - 4C53DF630A484C230014E966 /* CImageLoaderPSD.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CImageLoaderPSD.h; sourceTree = "<group>"; }; - 4C53DF640A484C230014E966 /* CImageLoaderTGA.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 2; path = CImageLoaderTGA.cpp; sourceTree = "<group>"; }; - 4C53DF650A484C230014E966 /* CImageLoaderTGA.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CImageLoaderTGA.h; sourceTree = "<group>"; }; - 4C53DF660A484C230014E966 /* CIrrDeviceLinux.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CIrrDeviceLinux.cpp; sourceTree = "<group>"; }; - 4C53DF670A484C230014E966 /* CIrrDeviceLinux.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CIrrDeviceLinux.h; sourceTree = "<group>"; }; - 4C53DF680A484C230014E966 /* CIrrDeviceStub.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CIrrDeviceStub.cpp; sourceTree = "<group>"; }; - 4C53DF690A484C230014E966 /* CIrrDeviceStub.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CIrrDeviceStub.h; sourceTree = "<group>"; }; - 4C53DF6A0A484C230014E966 /* CIrrDeviceWin32.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CIrrDeviceWin32.cpp; sourceTree = "<group>"; }; - 4C53DF6B0A484C230014E966 /* CIrrDeviceWin32.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CIrrDeviceWin32.h; sourceTree = "<group>"; }; - 4C53DF6C0A484C230014E966 /* CLightSceneNode.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CLightSceneNode.cpp; sourceTree = "<group>"; }; - 4C53DF6D0A484C230014E966 /* CLightSceneNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CLightSceneNode.h; sourceTree = "<group>"; }; - 4C53DF6E0A484C230014E966 /* CLimitReadFile.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 2; path = CLimitReadFile.cpp; sourceTree = "<group>"; }; - 4C53DF6F0A484C230014E966 /* CLimitReadFile.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; lineEnding = 2; path = CLimitReadFile.h; sourceTree = "<group>"; }; - 4C53DF700A484C230014E966 /* CLMTSMeshFileLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CLMTSMeshFileLoader.cpp; sourceTree = "<group>"; }; - 4C53DF710A484C230014E966 /* CLMTSMeshFileLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CLMTSMeshFileLoader.h; sourceTree = "<group>"; }; - 4C53DF720A484C230014E966 /* CLogger.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CLogger.cpp; sourceTree = "<group>"; }; - 4C53DF730A484C230014E966 /* CLogger.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CLogger.h; sourceTree = "<group>"; }; - 4C53DF760A484C230014E966 /* CMeshCache.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CMeshCache.cpp; sourceTree = "<group>"; }; - 4C53DF770A484C230014E966 /* CMeshCache.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CMeshCache.h; sourceTree = "<group>"; }; - 4C53DF780A484C230014E966 /* CMeshManipulator.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CMeshManipulator.cpp; sourceTree = "<group>"; }; - 4C53DF790A484C230014E966 /* CMeshManipulator.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CMeshManipulator.h; sourceTree = "<group>"; }; - 4C53DF7A0A484C230014E966 /* CMeshSceneNode.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CMeshSceneNode.cpp; sourceTree = "<group>"; }; - 4C53DF7B0A484C230014E966 /* CMeshSceneNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CMeshSceneNode.h; sourceTree = "<group>"; }; - 4C53DF7C0A484C230014E966 /* CMetaTriangleSelector.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CMetaTriangleSelector.cpp; sourceTree = "<group>"; }; - 4C53DF7D0A484C230014E966 /* CMetaTriangleSelector.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CMetaTriangleSelector.h; sourceTree = "<group>"; }; - 4C53DF7E0A484C230014E966 /* CMY3DHelper.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CMY3DHelper.h; sourceTree = "<group>"; }; - 4C53DF7F0A484C230014E966 /* CMY3DMeshFileLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CMY3DMeshFileLoader.cpp; sourceTree = "<group>"; }; - 4C53DF800A484C230014E966 /* CMY3DMeshFileLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CMY3DMeshFileLoader.h; sourceTree = "<group>"; }; - 4C53DF820A484C240014E966 /* CNullDriver.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CNullDriver.cpp; sourceTree = "<group>"; }; - 4C53DF830A484C240014E966 /* CNullDriver.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CNullDriver.h; sourceTree = "<group>"; }; - 4C53DF840A484C240014E966 /* COCTLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = COCTLoader.cpp; sourceTree = "<group>"; }; - 4C53DF850A484C240014E966 /* COCTLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = COCTLoader.h; sourceTree = "<group>"; }; - 4C53DF860A484C240014E966 /* COctTreeSceneNode.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = COctTreeSceneNode.cpp; sourceTree = "<group>"; }; - 4C53DF870A484C240014E966 /* COctTreeSceneNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = COctTreeSceneNode.h; sourceTree = "<group>"; }; - 4C53DF880A484C240014E966 /* COctTreeTriangleSelector.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = COctTreeTriangleSelector.cpp; sourceTree = "<group>"; }; - 4C53DF890A484C240014E966 /* COctTreeTriangleSelector.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = COctTreeTriangleSelector.h; sourceTree = "<group>"; }; - 4C53DF8A0A484C240014E966 /* COgreMeshFileLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 2; path = COgreMeshFileLoader.cpp; sourceTree = "<group>"; }; - 4C53DF8B0A484C240014E966 /* COgreMeshFileLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; lineEnding = 2; path = COgreMeshFileLoader.h; sourceTree = "<group>"; }; - 4C53DF8C0A484C240014E966 /* COpenGLDriver.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 2; path = COpenGLDriver.cpp; sourceTree = "<group>"; }; - 4C53DF8D0A484C240014E966 /* COpenGLDriver.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; lineEnding = 2; path = COpenGLDriver.h; sourceTree = "<group>"; }; - 4C53DF8E0A484C240014E966 /* COpenGLMaterialRenderer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = COpenGLMaterialRenderer.h; sourceTree = "<group>"; }; - 4C53DF8F0A484C240014E966 /* COpenGLNormalMapRenderer.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = COpenGLNormalMapRenderer.cpp; sourceTree = "<group>"; }; - 4C53DF900A484C240014E966 /* COpenGLNormalMapRenderer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = COpenGLNormalMapRenderer.h; sourceTree = "<group>"; }; - 4C53DF910A484C240014E966 /* COpenGLParallaxMapRenderer.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = COpenGLParallaxMapRenderer.cpp; sourceTree = "<group>"; }; - 4C53DF920A484C240014E966 /* COpenGLParallaxMapRenderer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = COpenGLParallaxMapRenderer.h; sourceTree = "<group>"; }; - 4C53DF930A484C240014E966 /* COpenGLShaderMaterialRenderer.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = COpenGLShaderMaterialRenderer.cpp; sourceTree = "<group>"; }; - 4C53DF940A484C240014E966 /* COpenGLShaderMaterialRenderer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = COpenGLShaderMaterialRenderer.h; sourceTree = "<group>"; }; - 4C53DF950A484C240014E966 /* COpenGLSLMaterialRenderer.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 2; path = COpenGLSLMaterialRenderer.cpp; sourceTree = "<group>"; }; - 4C53DF960A484C240014E966 /* COpenGLSLMaterialRenderer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = COpenGLSLMaterialRenderer.h; sourceTree = "<group>"; }; - 4C53DF970A484C240014E966 /* COpenGLTexture.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = COpenGLTexture.cpp; sourceTree = "<group>"; }; - 4C53DF980A484C240014E966 /* COpenGLTexture.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = COpenGLTexture.h; sourceTree = "<group>"; }; - 4C53DF990A484C240014E966 /* COSOperator.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = COSOperator.cpp; sourceTree = "<group>"; }; - 4C53DF9A0A484C240014E966 /* COSOperator.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = COSOperator.h; sourceTree = "<group>"; }; - 4C53DF9B0A484C240014E966 /* CParticleBoxEmitter.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CParticleBoxEmitter.cpp; sourceTree = "<group>"; }; - 4C53DF9C0A484C240014E966 /* CParticleBoxEmitter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CParticleBoxEmitter.h; sourceTree = "<group>"; }; - 4C53DF9D0A484C240014E966 /* CParticleFadeOutAffector.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CParticleFadeOutAffector.cpp; sourceTree = "<group>"; }; - 4C53DF9E0A484C240014E966 /* CParticleFadeOutAffector.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CParticleFadeOutAffector.h; sourceTree = "<group>"; }; - 4C53DF9F0A484C240014E966 /* CParticleGravityAffector.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CParticleGravityAffector.cpp; sourceTree = "<group>"; }; - 4C53DFA00A484C240014E966 /* CParticleGravityAffector.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CParticleGravityAffector.h; sourceTree = "<group>"; }; - 4C53DFA10A484C240014E966 /* CParticlePointEmitter.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CParticlePointEmitter.cpp; sourceTree = "<group>"; }; - 4C53DFA20A484C240014E966 /* CParticlePointEmitter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CParticlePointEmitter.h; sourceTree = "<group>"; }; - 4C53DFA30A484C240014E966 /* CParticleSystemSceneNode.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CParticleSystemSceneNode.cpp; sourceTree = "<group>"; }; - 4C53DFA40A484C240014E966 /* CParticleSystemSceneNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CParticleSystemSceneNode.h; sourceTree = "<group>"; }; - 4C53DFA50A484C240014E966 /* CQ3LevelMesh.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 2; path = CQ3LevelMesh.cpp; sourceTree = "<group>"; }; - 4C53DFA60A484C240014E966 /* CQ3LevelMesh.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CQ3LevelMesh.h; sourceTree = "<group>"; }; - 4C53DFA70A484C240014E966 /* CReadFile.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CReadFile.cpp; sourceTree = "<group>"; }; - 4C53DFA80A484C240014E966 /* CReadFile.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; lineEnding = 2; path = CReadFile.h; sourceTree = "<group>"; }; - 4C53DFA90A484C240014E966 /* CSceneCollisionManager.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CSceneCollisionManager.cpp; sourceTree = "<group>"; }; - 4C53DFAA0A484C240014E966 /* CSceneCollisionManager.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CSceneCollisionManager.h; sourceTree = "<group>"; }; - 4C53DFAB0A484C240014E966 /* CSceneManager.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CSceneManager.cpp; sourceTree = "<group>"; }; - 4C53DFAC0A484C240014E966 /* CSceneManager.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CSceneManager.h; sourceTree = "<group>"; }; - 4C53DFAD0A484C240014E966 /* CSceneNodeAnimatorCollisionResponse.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CSceneNodeAnimatorCollisionResponse.cpp; sourceTree = "<group>"; }; - 4C53DFAE0A484C240014E966 /* CSceneNodeAnimatorCollisionResponse.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CSceneNodeAnimatorCollisionResponse.h; sourceTree = "<group>"; }; - 4C53DFAF0A484C240014E966 /* CSceneNodeAnimatorDelete.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CSceneNodeAnimatorDelete.cpp; sourceTree = "<group>"; }; - 4C53DFB00A484C240014E966 /* CSceneNodeAnimatorDelete.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CSceneNodeAnimatorDelete.h; sourceTree = "<group>"; }; - 4C53DFB10A484C240014E966 /* CSceneNodeAnimatorFlyCircle.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CSceneNodeAnimatorFlyCircle.cpp; sourceTree = "<group>"; }; - 4C53DFB20A484C240014E966 /* CSceneNodeAnimatorFlyCircle.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CSceneNodeAnimatorFlyCircle.h; sourceTree = "<group>"; }; - 4C53DFB30A484C240014E966 /* CSceneNodeAnimatorFlyStraight.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CSceneNodeAnimatorFlyStraight.cpp; sourceTree = "<group>"; }; - 4C53DFB40A484C240014E966 /* CSceneNodeAnimatorFlyStraight.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CSceneNodeAnimatorFlyStraight.h; sourceTree = "<group>"; }; - 4C53DFB50A484C240014E966 /* CSceneNodeAnimatorFollowSpline.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CSceneNodeAnimatorFollowSpline.cpp; sourceTree = "<group>"; }; - 4C53DFB60A484C240014E966 /* CSceneNodeAnimatorFollowSpline.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CSceneNodeAnimatorFollowSpline.h; sourceTree = "<group>"; }; - 4C53DFB70A484C240014E966 /* CSceneNodeAnimatorRotation.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CSceneNodeAnimatorRotation.cpp; sourceTree = "<group>"; }; - 4C53DFB80A484C240014E966 /* CSceneNodeAnimatorRotation.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CSceneNodeAnimatorRotation.h; sourceTree = "<group>"; }; - 4C53DFB90A484C240014E966 /* CSceneNodeAnimatorTexture.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CSceneNodeAnimatorTexture.cpp; sourceTree = "<group>"; }; - 4C53DFBA0A484C240014E966 /* CSceneNodeAnimatorTexture.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CSceneNodeAnimatorTexture.h; sourceTree = "<group>"; }; - 4C53DFBB0A484C240014E966 /* CShadowVolumeSceneNode.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CShadowVolumeSceneNode.cpp; sourceTree = "<group>"; }; - 4C53DFBC0A484C240014E966 /* CShadowVolumeSceneNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CShadowVolumeSceneNode.h; sourceTree = "<group>"; }; - 4C53DFBD0A484C240014E966 /* CSkyBoxSceneNode.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CSkyBoxSceneNode.cpp; sourceTree = "<group>"; }; - 4C53DFBE0A484C240014E966 /* CSkyBoxSceneNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CSkyBoxSceneNode.h; sourceTree = "<group>"; }; - 4C53DFBF0A484C240014E966 /* CSoftware2MaterialRenderer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CSoftware2MaterialRenderer.h; sourceTree = "<group>"; }; - 4C53DFC00A484C240014E966 /* CSoftwareDriver.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CSoftwareDriver.cpp; sourceTree = "<group>"; }; - 4C53DFC10A484C240014E966 /* CSoftwareDriver.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CSoftwareDriver.h; sourceTree = "<group>"; }; - 4C53DFC20A484C240014E966 /* CSoftwareDriver2.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CSoftwareDriver2.cpp; sourceTree = "<group>"; }; - 4C53DFC30A484C240014E966 /* CSoftwareDriver2.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CSoftwareDriver2.h; sourceTree = "<group>"; }; - 4C53DFC40A484C240014E966 /* CSoftwareTexture.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CSoftwareTexture.cpp; sourceTree = "<group>"; }; - 4C53DFC50A484C240014E966 /* CSoftwareTexture.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CSoftwareTexture.h; sourceTree = "<group>"; }; - 4C53DFC60A484C240014E966 /* CSoftwareTexture2.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CSoftwareTexture2.cpp; sourceTree = "<group>"; }; - 4C53DFC70A484C240014E966 /* CSoftwareTexture2.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CSoftwareTexture2.h; sourceTree = "<group>"; }; - 4C53DFCA0A484C240014E966 /* CTerrainSceneNode.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CTerrainSceneNode.cpp; sourceTree = "<group>"; }; - 4C53DFCB0A484C240014E966 /* CTerrainSceneNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CTerrainSceneNode.h; sourceTree = "<group>"; }; - 4C53DFCC0A484C240014E966 /* CTerrainTriangleSelector.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CTerrainTriangleSelector.cpp; sourceTree = "<group>"; }; - 4C53DFCD0A484C240014E966 /* CTerrainTriangleSelector.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CTerrainTriangleSelector.h; sourceTree = "<group>"; }; - 4C53DFCE0A484C240014E966 /* CTextSceneNode.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CTextSceneNode.cpp; sourceTree = "<group>"; }; - 4C53DFCF0A484C240014E966 /* CTextSceneNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CTextSceneNode.h; sourceTree = "<group>"; }; - 4C53DFD00A484C240014E966 /* CTimer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CTimer.h; sourceTree = "<group>"; }; - 4C53DFD10A484C240014E966 /* CTRFlat.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CTRFlat.cpp; sourceTree = "<group>"; }; - 4C53DFD20A484C240014E966 /* CTRFlatWire.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CTRFlatWire.cpp; sourceTree = "<group>"; }; - 4C53DFD30A484C240014E966 /* CTRGouraud.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CTRGouraud.cpp; sourceTree = "<group>"; }; - 4C53DFD40A484C240014E966 /* CTRGouraud2.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CTRGouraud2.cpp; sourceTree = "<group>"; }; - 4C53DFD50A484C240014E966 /* CTRGouraudAlpha2.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CTRGouraudAlpha2.cpp; sourceTree = "<group>"; }; - 4C53DFD60A484C240014E966 /* CTRGouraudAlphaNoZ2.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CTRGouraudAlphaNoZ2.cpp; sourceTree = "<group>"; }; - 4C53DFD70A484C240014E966 /* CTRGouraudWire.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CTRGouraudWire.cpp; sourceTree = "<group>"; }; - 4C53DFD80A484C240014E966 /* CTriangleBBSelector.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CTriangleBBSelector.cpp; sourceTree = "<group>"; }; - 4C53DFD90A484C250014E966 /* CTriangleBBSelector.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CTriangleBBSelector.h; sourceTree = "<group>"; }; - 4C53DFDA0A484C250014E966 /* CTriangleSelector.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CTriangleSelector.cpp; sourceTree = "<group>"; }; - 4C53DFDB0A484C250014E966 /* CTriangleSelector.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CTriangleSelector.h; sourceTree = "<group>"; }; - 4C53DFDC0A484C250014E966 /* CTRTextureDetailMap2.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CTRTextureDetailMap2.cpp; sourceTree = "<group>"; }; - 4C53DFDD0A484C250014E966 /* CTRTextureFlat.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CTRTextureFlat.cpp; sourceTree = "<group>"; }; - 4C53DFDE0A484C250014E966 /* CTRTextureFlatWire.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CTRTextureFlatWire.cpp; sourceTree = "<group>"; }; - 4C53DFDF0A484C250014E966 /* CTRTextureGouraud.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CTRTextureGouraud.cpp; sourceTree = "<group>"; }; - 4C53DFE00A484C250014E966 /* CTRTextureGouraud.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CTRTextureGouraud.h; sourceTree = "<group>"; }; - 4C53DFE10A484C250014E966 /* CTRTextureGouraud2.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CTRTextureGouraud2.cpp; sourceTree = "<group>"; }; - 4C53DFE20A484C250014E966 /* CTRTextureGouraudAdd.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CTRTextureGouraudAdd.cpp; sourceTree = "<group>"; }; - 4C53DFE30A484C250014E966 /* CTRTextureGouraudAdd2.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CTRTextureGouraudAdd2.cpp; sourceTree = "<group>"; }; - 4C53DFE40A484C250014E966 /* CTRTextureGouraudAddNoZ2.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CTRTextureGouraudAddNoZ2.cpp; sourceTree = "<group>"; }; - 4C53DFE50A484C250014E966 /* CTRTextureGouraudNoZ.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CTRTextureGouraudNoZ.cpp; sourceTree = "<group>"; }; - 4C53DFE60A484C250014E966 /* CTRTextureGouraudNoZ2.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CTRTextureGouraudNoZ2.cpp; sourceTree = "<group>"; }; - 4C53DFE70A484C250014E966 /* CTRTextureGouraudVertexAlpha2.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CTRTextureGouraudVertexAlpha2.cpp; sourceTree = "<group>"; }; - 4C53DFE80A484C250014E966 /* CTRTextureGouraudWire.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CTRTextureGouraudWire.cpp; sourceTree = "<group>"; }; - 4C53DFE90A484C250014E966 /* CTRTextureLightMap2_Add.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CTRTextureLightMap2_Add.cpp; sourceTree = "<group>"; }; - 4C53DFEA0A484C250014E966 /* CTRTextureLightMap2_M1.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CTRTextureLightMap2_M1.cpp; sourceTree = "<group>"; }; - 4C53DFEB0A484C250014E966 /* CTRTextureLightMap2_M2.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CTRTextureLightMap2_M2.cpp; sourceTree = "<group>"; }; - 4C53DFEC0A484C250014E966 /* CTRTextureLightMap2_M4.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CTRTextureLightMap2_M4.cpp; sourceTree = "<group>"; }; - 4C53DFED0A484C250014E966 /* CTRTextureWire2.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CTRTextureWire2.cpp; sourceTree = "<group>"; }; - 4C53DFEE0A484C250014E966 /* CVideoModeList.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CVideoModeList.cpp; sourceTree = "<group>"; }; - 4C53DFEF0A484C250014E966 /* CVideoModeList.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CVideoModeList.h; sourceTree = "<group>"; }; - 4C53DFF00A484C250014E966 /* CWaterSurfaceSceneNode.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CWaterSurfaceSceneNode.cpp; sourceTree = "<group>"; }; - 4C53DFF10A484C250014E966 /* CWaterSurfaceSceneNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CWaterSurfaceSceneNode.h; sourceTree = "<group>"; }; - 4C53DFF20A484C250014E966 /* CWriteFile.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CWriteFile.cpp; sourceTree = "<group>"; }; - 4C53DFF30A484C250014E966 /* CWriteFile.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CWriteFile.h; sourceTree = "<group>"; }; - 4C53DFF80A484C250014E966 /* CXMeshFileLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CXMeshFileLoader.cpp; sourceTree = "<group>"; }; - 4C53DFF90A484C250014E966 /* CXMeshFileLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CXMeshFileLoader.h; sourceTree = "<group>"; }; - 4C53DFFA0A484C250014E966 /* CXMLReader.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CXMLReader.cpp; sourceTree = "<group>"; }; - 4C53DFFB0A484C250014E966 /* CXMLReader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CXMLReader.h; sourceTree = "<group>"; }; - 4C53DFFC0A484C250014E966 /* CXMLReaderImpl.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CXMLReaderImpl.h; sourceTree = "<group>"; }; - 4C53DFFD0A484C250014E966 /* CXMLWriter.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CXMLWriter.cpp; sourceTree = "<group>"; }; - 4C53DFFE0A484C250014E966 /* CXMLWriter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CXMLWriter.h; sourceTree = "<group>"; }; - 4C53DFFF0A484C250014E966 /* CZBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CZBuffer.cpp; sourceTree = "<group>"; }; - 4C53E0000A484C250014E966 /* CZBuffer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CZBuffer.h; sourceTree = "<group>"; }; - 4C53E0030A484C250014E966 /* CZipReader.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 2; path = CZipReader.cpp; sourceTree = "<group>"; }; - 4C53E0040A484C250014E966 /* CZipReader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CZipReader.h; sourceTree = "<group>"; }; - 4C53E0050A484C250014E966 /* dmfsupport.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = dmfsupport.h; sourceTree = "<group>"; }; - 4C53E0070A484C250014E966 /* glext.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = glext.h; sourceTree = "<group>"; }; - 4C53E0090A484C250014E966 /* IImagePresenter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IImagePresenter.h; sourceTree = "<group>"; }; - 4C53E00A0A484C250014E966 /* Irrlicht.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Irrlicht.cpp; sourceTree = "<group>"; }; - 4C53E00E0A484C250014E966 /* irrXML.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = irrXML.cpp; sourceTree = "<group>"; }; - 4C53E00F0A484C250014E966 /* ITriangleRenderer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ITriangleRenderer.h; sourceTree = "<group>"; }; - 4C53E0110A484C250014E966 /* IZBuffer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IZBuffer.h; sourceTree = "<group>"; }; - 4C53E14C0A484C2C0014E966 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; }; - 4C53E14D0A484C2C0014E966 /* AppDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = AppDelegate.mm; sourceTree = "<group>"; }; - 4C53E15E0A484C2C0014E966 /* CIrrDeviceMacOSX.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CIrrDeviceMacOSX.h; sourceTree = "<group>"; }; - 4C53E15F0A484C2C0014E966 /* CIrrDeviceMacOSX.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = CIrrDeviceMacOSX.mm; sourceTree = "<group>"; }; - 4C53E1640A484C2C0014E966 /* MacOSX_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = MacOSX_Prefix.pch; sourceTree = "<group>"; }; - 4C53E1650A484C2C0014E966 /* MainMenu.nib */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; path = MainMenu.nib; sourceTree = "<group>"; }; - 4C53E1660A484C2C0014E966 /* OSXClipboard.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = OSXClipboard.h; sourceTree = "<group>"; }; - 4C53E1670A484C2C0014E966 /* OSXClipboard.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = OSXClipboard.mm; sourceTree = "<group>"; }; - 4C53E1690A484C2C0014E966 /* OctTree.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = OctTree.h; sourceTree = "<group>"; }; - 4C53E16A0A484C2C0014E966 /* os.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = os.cpp; sourceTree = "<group>"; }; - 4C53E16B0A484C2C0014E966 /* os.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; lineEnding = 2; path = os.h; sourceTree = "<group>"; }; - 4C53E16C0A484C2C0014E966 /* S2DVertex.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = S2DVertex.h; sourceTree = "<group>"; }; - 4C53E16D0A484C2C0014E966 /* S4DVertex.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = S4DVertex.h; sourceTree = "<group>"; }; - 4C53E16E0A484C2C0014E966 /* SoftwareDriver2_compile_config.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SoftwareDriver2_compile_config.h; sourceTree = "<group>"; }; - 4C53E16F0A484C2C0014E966 /* SoftwareDriver2_helper.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SoftwareDriver2_helper.h; sourceTree = "<group>"; }; - 4C53E1720A484C2C0014E966 /* adler32.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = adler32.c; sourceTree = "<group>"; }; - 4C53E1750A484C2C0014E966 /* compress.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = compress.c; sourceTree = "<group>"; }; - 4C53E1770A484C2C0014E966 /* crc32.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = crc32.c; sourceTree = "<group>"; }; - 4C53E1790A484C2C0014E966 /* deflate.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = deflate.c; sourceTree = "<group>"; }; - 4C53E17D0A484C2C0014E966 /* gzio.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = gzio.c; sourceTree = "<group>"; }; - 4C53E1800A484C2C0014E966 /* inffast.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = inffast.c; sourceTree = "<group>"; }; - 4C53E1850A484C2C0014E966 /* inftrees.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = inftrees.c; sourceTree = "<group>"; }; - 4C53E18B0A484C2C0014E966 /* trees.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = trees.c; sourceTree = "<group>"; }; - 4C53E18D0A484C2C0014E966 /* uncompr.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = uncompr.c; sourceTree = "<group>"; }; - 4C53E1920A484C2C0014E966 /* zutil.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = zutil.c; sourceTree = "<group>"; }; - 4C53E24D0A4850120014E966 /* libIrrlicht.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libIrrlicht.a; sourceTree = BUILT_PRODUCTS_DIR; }; - 4C53E2520A4850550014E966 /* Quake3Map_dbg.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Quake3Map_dbg.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 4C53E26D0A4850D60014E966 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; }; - 4C53E26E0A4850D60014E966 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = /System/Library/Frameworks/OpenGL.framework; sourceTree = "<absolute>"; }; - 4C53E38E0A4855BA0014E966 /* DemoApp-Info.plist */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.plist.xml; path = "DemoApp-Info.plist"; sourceTree = "<group>"; }; - 4C53E6F10A485CD80014E966 /* jcapimin.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jcapimin.c; sourceTree = "<group>"; }; - 4C53E6F20A485CD80014E966 /* jcapistd.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jcapistd.c; sourceTree = "<group>"; }; - 4C53E6F30A485CD80014E966 /* jccoefct.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jccoefct.c; sourceTree = "<group>"; }; - 4C53E6F40A485CD80014E966 /* jccolor.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jccolor.c; sourceTree = "<group>"; }; - 4C53E6F50A485CD80014E966 /* jcdctmgr.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jcdctmgr.c; sourceTree = "<group>"; }; - 4C53E6F60A485CD80014E966 /* jchuff.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jchuff.c; sourceTree = "<group>"; }; - 4C53E6F80A485CD80014E966 /* jcinit.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jcinit.c; sourceTree = "<group>"; }; - 4C53E6F90A485CD80014E966 /* jcmainct.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jcmainct.c; sourceTree = "<group>"; }; - 4C53E6FA0A485CD80014E966 /* jcmarker.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jcmarker.c; sourceTree = "<group>"; }; - 4C53E6FB0A485CD80014E966 /* jcmaster.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jcmaster.c; sourceTree = "<group>"; }; - 4C53E6FC0A485CD80014E966 /* jcomapi.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jcomapi.c; sourceTree = "<group>"; }; - 4C53E70A0A485CD80014E966 /* jcparam.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jcparam.c; sourceTree = "<group>"; }; - 4C53E70B0A485CD80014E966 /* jcphuff.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jcphuff.c; sourceTree = "<group>"; }; - 4C53E70C0A485CD80014E966 /* jcprepct.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jcprepct.c; sourceTree = "<group>"; }; - 4C53E70D0A485CD80014E966 /* jcsample.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jcsample.c; sourceTree = "<group>"; }; - 4C53E70E0A485CD80014E966 /* jctrans.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jctrans.c; sourceTree = "<group>"; }; - 4C53E70F0A485CD80014E966 /* jdapimin.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jdapimin.c; sourceTree = "<group>"; }; - 4C53E7100A485CD80014E966 /* jdapistd.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jdapistd.c; sourceTree = "<group>"; }; - 4C53E7110A485CD80014E966 /* jdatadst.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jdatadst.c; sourceTree = "<group>"; }; - 4C53E7120A485CD80014E966 /* jdatasrc.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jdatasrc.c; sourceTree = "<group>"; }; - 4C53E7130A485CD80014E966 /* jdcoefct.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jdcoefct.c; sourceTree = "<group>"; }; - 4C53E7140A485CD80014E966 /* jdcolor.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jdcolor.c; sourceTree = "<group>"; }; - 4C53E7160A485CD80014E966 /* jddctmgr.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jddctmgr.c; sourceTree = "<group>"; }; - 4C53E7170A485CD80014E966 /* jdhuff.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jdhuff.c; sourceTree = "<group>"; }; - 4C53E7190A485CD80014E966 /* jdinput.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jdinput.c; sourceTree = "<group>"; }; - 4C53E71A0A485CD80014E966 /* jdmainct.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jdmainct.c; sourceTree = "<group>"; }; - 4C53E71B0A485CD80014E966 /* jdmarker.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jdmarker.c; sourceTree = "<group>"; }; - 4C53E71C0A485CD80014E966 /* jdmaster.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jdmaster.c; sourceTree = "<group>"; }; - 4C53E71D0A485CD80014E966 /* jdmerge.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jdmerge.c; sourceTree = "<group>"; }; - 4C53E71E0A485CD80014E966 /* jdphuff.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jdphuff.c; sourceTree = "<group>"; }; - 4C53E71F0A485CD80014E966 /* jdpostct.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jdpostct.c; sourceTree = "<group>"; }; - 4C53E7200A485CD80014E966 /* jdsample.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jdsample.c; sourceTree = "<group>"; }; - 4C53E7210A485CD80014E966 /* jdtrans.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jdtrans.c; sourceTree = "<group>"; }; - 4C53E7220A485CD80014E966 /* jerror.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jerror.c; sourceTree = "<group>"; }; - 4C53E7240A485CD80014E966 /* jfdctflt.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jfdctflt.c; sourceTree = "<group>"; }; - 4C53E7250A485CD80014E966 /* jfdctfst.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jfdctfst.c; sourceTree = "<group>"; }; - 4C53E7260A485CD80014E966 /* jfdctint.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jfdctint.c; sourceTree = "<group>"; }; - 4C53E7270A485CD80014E966 /* jidctflt.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jidctflt.c; sourceTree = "<group>"; }; - 4C53E7280A485CD80014E966 /* jidctfst.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jidctfst.c; sourceTree = "<group>"; }; - 4C53E7290A485CD80014E966 /* jidctint.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jidctint.c; sourceTree = "<group>"; }; - 4C53E72A0A485CD80014E966 /* jidctred.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jidctred.c; sourceTree = "<group>"; }; - 4C53E7300A485CD80014E966 /* jmemmgr.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jmemmgr.c; sourceTree = "<group>"; }; - 4C53E7320A485CD80014E966 /* jmemnobs.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jmemnobs.c; sourceTree = "<group>"; }; - 4C53E7390A485CD80014E966 /* jquant1.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jquant1.c; sourceTree = "<group>"; }; - 4C53E73A0A485CD80014E966 /* jquant2.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jquant2.c; sourceTree = "<group>"; }; - 4C53E73B0A485CD80014E966 /* jutils.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = jutils.c; sourceTree = "<group>"; }; - 4C53E7540A485CD90014E966 /* rdbmp.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = rdbmp.c; sourceTree = "<group>"; }; - 4C53E7550A485CD90014E966 /* rdcolmap.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = rdcolmap.c; sourceTree = "<group>"; }; - 4C53E7560A485CD90014E966 /* rdgif.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = rdgif.c; sourceTree = "<group>"; }; - 4C53E7590A485CD90014E966 /* rdppm.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = rdppm.c; sourceTree = "<group>"; }; - 4C53E75A0A485CD90014E966 /* rdrle.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = rdrle.c; sourceTree = "<group>"; }; - 4C53E75B0A485CD90014E966 /* rdswitch.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = rdswitch.c; sourceTree = "<group>"; }; - 4C53E75C0A485CD90014E966 /* rdtarga.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = rdtarga.c; sourceTree = "<group>"; }; - 4C53E7660A485CD90014E966 /* transupp.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = transupp.c; sourceTree = "<group>"; }; - 4C53E76A0A485CD90014E966 /* wrbmp.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = wrbmp.c; sourceTree = "<group>"; }; - 4C53E76B0A485CD90014E966 /* wrgif.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = wrgif.c; sourceTree = "<group>"; }; - 4C53E76E0A485CD90014E966 /* wrppm.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = wrppm.c; sourceTree = "<group>"; }; - 4C53E76F0A485CD90014E966 /* wrrle.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = wrrle.c; sourceTree = "<group>"; }; - 4C53E7700A485CD90014E966 /* wrtarga.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = wrtarga.c; sourceTree = "<group>"; }; - 4C6DC9B60A48715A0017A6E5 /* inflate.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = inflate.c; sourceTree = "<group>"; }; - 4CA25B980A485D9800B4E469 /* CustomSceneNode_dbg.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CustomSceneNode_dbg.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 4CA25B9A0A485D9800B4E469 /* MeshViewer_dbg.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MeshViewer_dbg.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 4CA25B9C0A485D9800B4E469 /* RenderToTexture_dbg.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RenderToTexture_dbg.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 4CA25B9E0A485D9800B4E469 /* UserInterface_dbg.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = UserInterface_dbg.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 4CA25BA00A485D9800B4E469 /* PerPixelLighting_dbg.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PerPixelLighting_dbg.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 4CA25BA20A485D9800B4E469 /* Demo_dbg.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Demo_dbg.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 4CA25BA40A485D9800B4E469 /* Movement_dbg.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Movement_dbg.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 4CA25BA60A485D9800B4E469 /* Shaders_dbg.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Shaders_dbg.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 4CA25BA80A485D9800B4E469 /* SpecialFx_dbg.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SpecialFx_dbg.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 4CA25BAA0A485D9800B4E469 /* TerrainRendering_dbg.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TerrainRendering_dbg.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 4CA25BAC0A485D9800B4E469 /* 2DGraphics_dbg.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = 2DGraphics_dbg.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 4CA25BAE0A485D9800B4E469 /* Collision_dbg.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Collision_dbg.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 4CC36B0D0A6B61DB0076C4B2 /* CSphereSceneNode.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CSphereSceneNode.cpp; sourceTree = "<group>"; }; - 4CC36B0E0A6B61DB0076C4B2 /* CSphereSceneNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CSphereSceneNode.h; sourceTree = "<group>"; }; - 4CFA7BDC0A88735900B03626 /* CImageLoaderBMP.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 2; path = CImageLoaderBMP.cpp; sourceTree = "<group>"; }; - 4CFA7BDD0A88735900B03626 /* CImageLoaderBMP.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CImageLoaderBMP.h; sourceTree = "<group>"; }; - 4CFA7BDE0A88735900B03626 /* CImageWriterBMP.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CImageWriterBMP.cpp; sourceTree = "<group>"; }; - 4CFA7BDF0A88735900B03626 /* CImageWriterBMP.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CImageWriterBMP.h; sourceTree = "<group>"; }; - 4CFA7BE00A88735900B03626 /* CImageWriterJPG.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CImageWriterJPG.cpp; sourceTree = "<group>"; }; - 4CFA7BE10A88735900B03626 /* CImageWriterJPG.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CImageWriterJPG.h; sourceTree = "<group>"; }; - 4CFA7BE20A88735900B03626 /* CImageWriterPCX.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CImageWriterPCX.cpp; sourceTree = "<group>"; }; - 4CFA7BE30A88735900B03626 /* CImageWriterPCX.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CImageWriterPCX.h; sourceTree = "<group>"; }; - 4CFA7BE40A88735900B03626 /* CImageWriterPNG.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CImageWriterPNG.cpp; sourceTree = "<group>"; }; - 4CFA7BE50A88735900B03626 /* CImageWriterPNG.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CImageWriterPNG.h; sourceTree = "<group>"; }; - 4CFA7BE60A88735900B03626 /* CImageWriterPPM.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CImageWriterPPM.cpp; sourceTree = "<group>"; }; - 4CFA7BE70A88735900B03626 /* CImageWriterPPM.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CImageWriterPPM.h; sourceTree = "<group>"; }; - 4CFA7BE80A88735900B03626 /* CImageWriterPSD.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CImageWriterPSD.cpp; sourceTree = "<group>"; }; - 4CFA7BE90A88735900B03626 /* CImageWriterPSD.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CImageWriterPSD.h; sourceTree = "<group>"; }; - 4CFA7BEA0A88735900B03626 /* CImageWriterTGA.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CImageWriterTGA.cpp; sourceTree = "<group>"; }; - 4CFA7BEB0A88735900B03626 /* CImageWriterTGA.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CImageWriterTGA.h; sourceTree = "<group>"; }; - 4CFA7BEC0A88735A00B03626 /* CSkyDomeSceneNode.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CSkyDomeSceneNode.cpp; sourceTree = "<group>"; }; - 4CFA7BED0A88735A00B03626 /* CSkyDomeSceneNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CSkyDomeSceneNode.h; sourceTree = "<group>"; }; - 4CFA7C0A0A88742800B03626 /* aabbox3d.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = aabbox3d.h; sourceTree = "<group>"; }; - 4CFA7C0B0A88742800B03626 /* dimension2d.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = dimension2d.h; sourceTree = "<group>"; }; - 4CFA7C0C0A88742800B03626 /* EDriverTypes.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = EDriverTypes.h; sourceTree = "<group>"; }; - 4CFA7C0D0A88742800B03626 /* EGUIElementTypes.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = EGUIElementTypes.h; sourceTree = "<group>"; }; - 4CFA7C0E0A88742800B03626 /* ESceneNodeAnimatorTypes.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ESceneNodeAnimatorTypes.h; sourceTree = "<group>"; }; - 4CFA7C0F0A88742800B03626 /* ESceneNodeTypes.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ESceneNodeTypes.h; sourceTree = "<group>"; }; - 4CFA7C100A88742800B03626 /* heapsort.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = heapsort.h; sourceTree = "<group>"; }; - 4CFA7C110A88742900B03626 /* IAnimatedMesh.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IAnimatedMesh.h; sourceTree = "<group>"; }; - 4CFA7C130A88742900B03626 /* IAnimatedMeshMD2.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IAnimatedMeshMD2.h; sourceTree = "<group>"; }; - 4CFA7C150A88742900B03626 /* IAnimatedMeshSceneNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IAnimatedMeshSceneNode.h; sourceTree = "<group>"; }; - 4CFA7C170A88742900B03626 /* IAttributeExchangingObject.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IAttributeExchangingObject.h; sourceTree = "<group>"; }; - 4CFA7C180A88742900B03626 /* IAttributes.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IAttributes.h; sourceTree = "<group>"; }; - 4CFA7C190A88742900B03626 /* IBillboardSceneNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IBillboardSceneNode.h; sourceTree = "<group>"; }; - 4CFA7C1A0A88742900B03626 /* ICameraSceneNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ICameraSceneNode.h; sourceTree = "<group>"; }; - 4CFA7C1B0A88742900B03626 /* ICursorControl.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ICursorControl.h; sourceTree = "<group>"; }; - 4CFA7C1C0A88742900B03626 /* IDummyTransformationSceneNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IDummyTransformationSceneNode.h; sourceTree = "<group>"; }; - 4CFA7C1D0A88742900B03626 /* IEventReceiver.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IEventReceiver.h; sourceTree = "<group>"; }; - 4CFA7C1E0A88742900B03626 /* IFileList.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IFileList.h; sourceTree = "<group>"; }; - 4CFA7C1F0A88742900B03626 /* IFileSystem.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IFileSystem.h; sourceTree = "<group>"; }; - 4CFA7C200A88742900B03626 /* IGPUProgrammingServices.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IGPUProgrammingServices.h; sourceTree = "<group>"; }; - 4CFA7C210A88742900B03626 /* IGUIButton.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IGUIButton.h; sourceTree = "<group>"; }; - 4CFA7C220A88742900B03626 /* IGUICheckBox.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IGUICheckBox.h; sourceTree = "<group>"; }; - 4CFA7C230A88742900B03626 /* IGUIComboBox.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IGUIComboBox.h; sourceTree = "<group>"; }; - 4CFA7C240A88742900B03626 /* IGUIContextMenu.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IGUIContextMenu.h; sourceTree = "<group>"; }; - 4CFA7C250A88742900B03626 /* IGUIEditBox.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IGUIEditBox.h; sourceTree = "<group>"; }; - 4CFA7C260A88742900B03626 /* IGUIElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IGUIElement.h; sourceTree = "<group>"; }; - 4CFA7C270A88742900B03626 /* IGUIEnvironment.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IGUIEnvironment.h; sourceTree = "<group>"; }; - 4CFA7C280A88742900B03626 /* IGUIFileOpenDialog.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IGUIFileOpenDialog.h; sourceTree = "<group>"; }; - 4CFA7C290A88742900B03626 /* IGUIFont.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IGUIFont.h; sourceTree = "<group>"; }; - 4CFA7C2A0A88742900B03626 /* IGUIImage.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IGUIImage.h; sourceTree = "<group>"; }; - 4CFA7C2B0A88742900B03626 /* IGUIInOutFader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IGUIInOutFader.h; sourceTree = "<group>"; }; - 4CFA7C2C0A88742900B03626 /* IGUIListBox.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IGUIListBox.h; sourceTree = "<group>"; }; - 4CFA7C2D0A88742900B03626 /* IGUIMeshViewer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IGUIMeshViewer.h; sourceTree = "<group>"; }; - 4CFA7C2E0A88742900B03626 /* IGUIScrollBar.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IGUIScrollBar.h; sourceTree = "<group>"; }; - 4CFA7C2F0A88742900B03626 /* IGUISkin.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IGUISkin.h; sourceTree = "<group>"; }; - 4CFA7C300A88742900B03626 /* IGUIStaticText.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IGUIStaticText.h; sourceTree = "<group>"; }; - 4CFA7C310A88742900B03626 /* IGUITabControl.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IGUITabControl.h; sourceTree = "<group>"; }; - 4CFA7C320A88742900B03626 /* IGUIToolbar.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IGUIToolbar.h; sourceTree = "<group>"; }; - 4CFA7C330A88742900B03626 /* IGUIWindow.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IGUIWindow.h; sourceTree = "<group>"; }; - 4CFA7C340A88742900B03626 /* IImage.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IImage.h; sourceTree = "<group>"; }; - 4CFA7C350A88742900B03626 /* IImageLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IImageLoader.h; sourceTree = "<group>"; }; - 4CFA7C360A88742900B03626 /* IImageWriter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IImageWriter.h; sourceTree = "<group>"; }; - 4CFA7C370A88742900B03626 /* ILightSceneNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ILightSceneNode.h; sourceTree = "<group>"; }; - 4CFA7C380A88742900B03626 /* ILogger.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ILogger.h; sourceTree = "<group>"; }; - 4CFA7C390A88742900B03626 /* IMaterialRenderer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IMaterialRenderer.h; sourceTree = "<group>"; }; - 4CFA7C3A0A88742900B03626 /* IMaterialRendererServices.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IMaterialRendererServices.h; sourceTree = "<group>"; }; - 4CFA7C3B0A88742900B03626 /* IMesh.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IMesh.h; sourceTree = "<group>"; }; - 4CFA7C3C0A88742900B03626 /* IMeshBuffer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IMeshBuffer.h; sourceTree = "<group>"; }; - 4CFA7C3D0A88742900B03626 /* IMeshCache.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IMeshCache.h; sourceTree = "<group>"; }; - 4CFA7C3E0A88742900B03626 /* IMeshLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IMeshLoader.h; sourceTree = "<group>"; }; - 4CFA7C3F0A88742900B03626 /* IMeshManipulator.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IMeshManipulator.h; sourceTree = "<group>"; }; - 4CFA7C400A88742900B03626 /* IMeshSceneNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IMeshSceneNode.h; sourceTree = "<group>"; }; - 4CFA7C410A88742900B03626 /* IMetaTriangleSelector.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IMetaTriangleSelector.h; sourceTree = "<group>"; }; - 4CFA7C420A88742900B03626 /* IOSOperator.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IOSOperator.h; sourceTree = "<group>"; }; - 4CFA7C430A88742900B03626 /* IParticleAffector.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IParticleAffector.h; sourceTree = "<group>"; }; - 4CFA7C440A88742900B03626 /* IParticleEmitter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IParticleEmitter.h; sourceTree = "<group>"; }; - 4CFA7C450A88742900B03626 /* IParticleSystemSceneNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IParticleSystemSceneNode.h; sourceTree = "<group>"; }; - 4CFA7C460A88742900B03626 /* IQ3LevelMesh.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IQ3LevelMesh.h; sourceTree = "<group>"; }; - 4CFA7C470A88742900B03626 /* IReadFile.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; lineEnding = 2; path = IReadFile.h; sourceTree = "<group>"; }; - 4CFA7C480A88742900B03626 /* irrAllocator.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = irrAllocator.h; sourceTree = "<group>"; }; - 4CFA7C490A88742900B03626 /* irrArray.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = irrArray.h; sourceTree = "<group>"; }; - 4CFA7C4A0A88742900B03626 /* IrrCompileConfig.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IrrCompileConfig.h; sourceTree = "<group>"; }; - 4CFA7C4B0A88742900B03626 /* irrlicht.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = irrlicht.h; sourceTree = "<group>"; }; - 4CFA7C4C0A88742900B03626 /* IrrlichtDevice.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IrrlichtDevice.h; sourceTree = "<group>"; }; - 4CFA7C4D0A88742900B03626 /* irrList.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = irrList.h; sourceTree = "<group>"; }; - 4CFA7C4E0A88742900B03626 /* irrMath.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = irrMath.h; sourceTree = "<group>"; }; - 4CFA7C4F0A88742900B03626 /* irrString.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = irrString.h; sourceTree = "<group>"; }; - 4CFA7C500A88742900B03626 /* irrTypes.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; lineEnding = 2; path = irrTypes.h; sourceTree = "<group>"; }; - 4CFA7C510A88742900B03626 /* irrXML.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = irrXML.h; sourceTree = "<group>"; }; - 4CFA7C520A88742900B03626 /* ISceneCollisionManager.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ISceneCollisionManager.h; sourceTree = "<group>"; }; - 4CFA7C530A88742900B03626 /* ISceneManager.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ISceneManager.h; sourceTree = "<group>"; }; - 4CFA7C540A88742900B03626 /* ISceneNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ISceneNode.h; sourceTree = "<group>"; }; - 4CFA7C550A88742900B03626 /* ISceneNodeAnimator.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ISceneNodeAnimator.h; sourceTree = "<group>"; }; - 4CFA7C560A88742900B03626 /* ISceneNodeAnimatorCollisionResponse.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ISceneNodeAnimatorCollisionResponse.h; sourceTree = "<group>"; }; - 4CFA7C570A88742900B03626 /* ISceneNodeAnimatorFactory.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ISceneNodeAnimatorFactory.h; sourceTree = "<group>"; }; - 4CFA7C580A88742900B03626 /* ISceneNodeFactory.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ISceneNodeFactory.h; sourceTree = "<group>"; }; - 4CFA7C590A88742900B03626 /* ISceneUserDataSerializer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ISceneUserDataSerializer.h; sourceTree = "<group>"; }; - 4CFA7C5A0A88742900B03626 /* IShaderConstantSetCallBack.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IShaderConstantSetCallBack.h; sourceTree = "<group>"; }; - 4CFA7C5B0A88742900B03626 /* IShadowVolumeSceneNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IShadowVolumeSceneNode.h; sourceTree = "<group>"; }; - 4CFA7C5C0A88742900B03626 /* ITerrainSceneNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ITerrainSceneNode.h; sourceTree = "<group>"; }; - 4CFA7C5D0A88742900B03626 /* ITextSceneNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ITextSceneNode.h; sourceTree = "<group>"; }; - 4CFA7C5E0A88742900B03626 /* ITexture.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ITexture.h; sourceTree = "<group>"; }; - 4CFA7C5F0A88742900B03626 /* ITimer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ITimer.h; sourceTree = "<group>"; }; - 4CFA7C600A88742900B03626 /* ITriangleSelector.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ITriangleSelector.h; sourceTree = "<group>"; }; - 4CFA7C620A88742900B03626 /* IVideoDriver.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IVideoDriver.h; sourceTree = "<group>"; }; - 4CFA7C630A88742900B03626 /* IVideoModeList.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IVideoModeList.h; sourceTree = "<group>"; }; - 4CFA7C640A88742900B03626 /* IWriteFile.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IWriteFile.h; sourceTree = "<group>"; }; - 4CFA7C650A88742900B03626 /* IXMLReader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IXMLReader.h; sourceTree = "<group>"; }; - 4CFA7C660A88742900B03626 /* IXMLWriter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IXMLWriter.h; sourceTree = "<group>"; }; - 4CFA7C670A88742900B03626 /* Keycodes.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Keycodes.h; sourceTree = "<group>"; }; - 4CFA7C680A88742900B03626 /* line2d.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = line2d.h; sourceTree = "<group>"; }; - 4CFA7C690A88742900B03626 /* line3d.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = line3d.h; sourceTree = "<group>"; }; - 4CFA7C6A0A88742900B03626 /* matrix4.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = matrix4.h; sourceTree = "<group>"; }; - 4CFA7C6B0A88742900B03626 /* plane3d.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = plane3d.h; sourceTree = "<group>"; }; - 4CFA7C6C0A88742900B03626 /* position2d.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = position2d.h; sourceTree = "<group>"; }; - 4CFA7C6D0A88742900B03626 /* quaternion.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = quaternion.h; sourceTree = "<group>"; }; - 4CFA7C6E0A88742900B03626 /* rect.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = rect.h; sourceTree = "<group>"; }; - 4CFA7C6F0A88742900B03626 /* S3DVertex.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = S3DVertex.h; sourceTree = "<group>"; }; - 4CFA7C700A88742900B03626 /* SAnimatedMesh.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SAnimatedMesh.h; sourceTree = "<group>"; }; - 4CFA7C710A88742900B03626 /* SceneParameters.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SceneParameters.h; sourceTree = "<group>"; }; - 4CFA7C720A88742900B03626 /* SColor.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SColor.h; sourceTree = "<group>"; }; - 4CFA7C730A88742900B03626 /* SExposedVideoData.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SExposedVideoData.h; sourceTree = "<group>"; }; - 4CFA7C740A88742900B03626 /* SIrrCreationParameters.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SIrrCreationParameters.h; sourceTree = "<group>"; }; - 4CFA7C750A88742900B03626 /* SKeyMap.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SKeyMap.h; sourceTree = "<group>"; }; - 4CFA7C760A88742900B03626 /* SLight.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SLight.h; sourceTree = "<group>"; }; - 4CFA7C770A88742900B03626 /* SMaterial.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SMaterial.h; sourceTree = "<group>"; }; - 4CFA7C780A88742900B03626 /* SMesh.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SMesh.h; sourceTree = "<group>"; }; - 4CFA7C790A88742900B03626 /* SMeshBuffer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SMeshBuffer.h; sourceTree = "<group>"; }; - 4CFA7C7A0A88742900B03626 /* SMeshBufferLightMap.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SMeshBufferLightMap.h; sourceTree = "<group>"; }; - 4CFA7C7B0A88742900B03626 /* SMeshBufferTangents.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SMeshBufferTangents.h; sourceTree = "<group>"; }; - 4CFA7C7C0A88742900B03626 /* SParticle.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SParticle.h; sourceTree = "<group>"; }; - 4CFA7C7E0A88742900B03626 /* triangle3d.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = triangle3d.h; sourceTree = "<group>"; }; - 4CFA7C7F0A88742900B03626 /* vector2d.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = vector2d.h; sourceTree = "<group>"; }; - 4CFA7C800A88742900B03626 /* vector3d.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = vector3d.h; sourceTree = "<group>"; }; - 5DD4804C0C7D91DF00728AA9 /* CDepthBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CDepthBuffer.cpp; sourceTree = "<group>"; }; - 5DD4804D0C7D91DF00728AA9 /* CDepthBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDepthBuffer.h; sourceTree = "<group>"; }; - 5DD480500C7D936700728AA9 /* IBurningShader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IBurningShader.cpp; sourceTree = "<group>"; }; - 5DD480510C7D936700728AA9 /* IBurningShader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IBurningShader.h; sourceTree = "<group>"; }; - 5DD480540C7D93AB00728AA9 /* IDepthBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDepthBuffer.h; sourceTree = "<group>"; }; - 5DD480560C7D945800728AA9 /* CAnimatedMeshMD3.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CAnimatedMeshMD3.cpp; sourceTree = "<group>"; }; - 5DD480570C7D945800728AA9 /* CAnimatedMeshMD3.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CAnimatedMeshMD3.h; sourceTree = "<group>"; }; - 5DD480580C7D945800728AA9 /* CDefaultGUIElementFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CDefaultGUIElementFactory.cpp; sourceTree = "<group>"; }; - 5DD480590C7D945800728AA9 /* CDefaultGUIElementFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDefaultGUIElementFactory.h; sourceTree = "<group>"; }; - 5DD4805E0C7D947B00728AA9 /* CGUIColorSelectDialog.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CGUIColorSelectDialog.cpp; sourceTree = "<group>"; }; - 5DD4805F0C7D947B00728AA9 /* CGUIColorSelectDialog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGUIColorSelectDialog.h; sourceTree = "<group>"; }; - 5DD480600C7D947B00728AA9 /* CGUISpinBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CGUISpinBox.cpp; sourceTree = "<group>"; }; - 5DD480610C7D947B00728AA9 /* CGUISpinBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGUISpinBox.h; sourceTree = "<group>"; }; - 5DD480620C7D947B00728AA9 /* CGUISpriteBank.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CGUISpriteBank.cpp; sourceTree = "<group>"; }; - 5DD480630C7D947B00728AA9 /* CGUISpriteBank.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGUISpriteBank.h; sourceTree = "<group>"; }; - 5DD4806A0C7D94AC00728AA9 /* CQuake3ShaderSceneNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CQuake3ShaderSceneNode.cpp; sourceTree = "<group>"; }; - 5DD4806B0C7D94AC00728AA9 /* CQuake3ShaderSceneNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CQuake3ShaderSceneNode.h; sourceTree = "<group>"; }; - 5DD4806C0C7D94AC00728AA9 /* CTRTextureBlend.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CTRTextureBlend.cpp; sourceTree = "<group>"; }; - 5DD4806D0C7D94AC00728AA9 /* CTRTextureGouraudAlpha.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CTRTextureGouraudAlpha.cpp; sourceTree = "<group>"; }; - 5DD4806E0C7D94AC00728AA9 /* CTRTextureGouraudAlphaNoZ.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CTRTextureGouraudAlphaNoZ.cpp; sourceTree = "<group>"; }; - 5DD4806F0C7D94AC00728AA9 /* CTRTextureLightMapGouraud2_M4.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CTRTextureLightMapGouraud2_M4.cpp; sourceTree = "<group>"; }; - 5DD480700C7D94AC00728AA9 /* glxext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = glxext.h; sourceTree = "<group>"; }; - 5DD480C10C7DA66800728AA9 /* COpenGLExtensionHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = COpenGLExtensionHandler.h; sourceTree = "<group>"; }; - 5DD480C20C7DA66800728AA9 /* CMD3MeshFileLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CMD3MeshFileLoader.h; sourceTree = "<group>"; }; - 5DD480C30C7DA66800728AA9 /* CIrrDeviceSDL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CIrrDeviceSDL.h; sourceTree = "<group>"; }; - 5DD480C40C7DA66800728AA9 /* CIrrDeviceSDL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CIrrDeviceSDL.cpp; sourceTree = "<group>"; }; - 5DD480C50C7DA66800728AA9 /* COpenGLExtensionHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = COpenGLExtensionHandler.cpp; sourceTree = "<group>"; }; - 5DD480C60C7DA66800728AA9 /* CMD3MeshFileLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CMD3MeshFileLoader.cpp; sourceTree = "<group>"; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 09022C5A0EA0E97F00CD54EE /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 09022C5B0EA0E97F00CD54EE /* libIrrlicht.a in Frameworks */, - 09022C5C0EA0E97F00CD54EE /* Cocoa.framework in Frameworks */, - 09022C5D0EA0E97F00CD54EE /* OpenGL.framework in Frameworks */, - 09022C5E0EA0E97F00CD54EE /* Carbon.framework in Frameworks */, - 0930CE590EC39F4500D63866 /* IOKit.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 0946CCAB0EC99BBE00D945A5 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 0946CCAC0EC99BBE00D945A5 /* libIrrlicht.a in Frameworks */, - 0946CCAD0EC99BBE00D945A5 /* Cocoa.framework in Frameworks */, - 0946CCAE0EC99BBE00D945A5 /* OpenGL.framework in Frameworks */, - 0946CCAF0EC99BBE00D945A5 /* Carbon.framework in Frameworks */, - 0946CCB00EC99BBE00D945A5 /* IOKit.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 09F648FC0D2CDED9001E0599 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 09F648FD0D2CDED9001E0599 /* libIrrlicht.a in Frameworks */, - 09F648FE0D2CDED9001E0599 /* Cocoa.framework in Frameworks */, - 09F648FF0D2CDED9001E0599 /* OpenGL.framework in Frameworks */, - 092511400D744ADE006784D9 /* Carbon.framework in Frameworks */, - 0930CE5C0EC39F4500D63866 /* IOKit.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 09F649370D2CE03E001E0599 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 09F649380D2CE03E001E0599 /* libIrrlicht.a in Frameworks */, - 09F649390D2CE03E001E0599 /* Cocoa.framework in Frameworks */, - 09F6493A0D2CE03E001E0599 /* OpenGL.framework in Frameworks */, - 0925113F0D744ADE006784D9 /* Carbon.framework in Frameworks */, - 0930CE5B0EC39F4500D63866 /* IOKit.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 09F6495E0D2CE206001E0599 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 09F6495F0D2CE206001E0599 /* libIrrlicht.a in Frameworks */, - 09F649600D2CE206001E0599 /* Cocoa.framework in Frameworks */, - 09F649610D2CE206001E0599 /* OpenGL.framework in Frameworks */, - 0925113E0D744ADE006784D9 /* Carbon.framework in Frameworks */, - 0930CE5A0EC39F4500D63866 /* IOKit.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B81CFE08097FD9F50057C06F /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CF146F50A486648006EBA03 /* libIrrlicht.a in Frameworks */, - 4C53E2750A4850D60014E966 /* Cocoa.framework in Frameworks */, - 4C53E2760A4850D60014E966 /* OpenGL.framework in Frameworks */, - 092511490D744ADE006784D9 /* Carbon.framework in Frameworks */, - 0930CE650EC39F4500D63866 /* IOKit.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B81CFE89097FDDE20057C06F /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CF1470A0A4866FA006EBA03 /* libIrrlicht.a in Frameworks */, - 4C53E2770A4850D60014E966 /* Cocoa.framework in Frameworks */, - 4C53E2780A4850D60014E966 /* OpenGL.framework in Frameworks */, - 092511480D744ADE006784D9 /* Carbon.framework in Frameworks */, - 0930CE640EC39F4500D63866 /* IOKit.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B81CFEAB097FDE900057C06F /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CA5CBB40A486A1600ADB3D7 /* libIrrlicht.a in Frameworks */, - 4C53E27F0A4850D60014E966 /* Cocoa.framework in Frameworks */, - 4C53E2800A4850D60014E966 /* OpenGL.framework in Frameworks */, - 092511440D744ADE006784D9 /* Carbon.framework in Frameworks */, - 0930CE600EC39F4500D63866 /* IOKit.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B81CFEC9097FDF020057C06F /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CA5CBB70A486A2500ADB3D7 /* libIrrlicht.a in Frameworks */, - 4C53E2810A4850D60014E966 /* Cocoa.framework in Frameworks */, - 4C53E2820A4850D60014E966 /* OpenGL.framework in Frameworks */, - 092511430D744ADE006784D9 /* Carbon.framework in Frameworks */, - 0930CE5F0EC39F4500D63866 /* IOKit.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B81CFEEF097FE05F0057C06F /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CF147190A48676E006EBA03 /* libIrrlicht.a in Frameworks */, - 4C53E2790A4850D60014E966 /* Cocoa.framework in Frameworks */, - 4C53E27A0A4850D60014E966 /* OpenGL.framework in Frameworks */, - 092511470D744ADE006784D9 /* Carbon.framework in Frameworks */, - 0930CE630EC39F4500D63866 /* IOKit.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B81CFF0E097FE13E0057C06F /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CA25C8D0A48628200B4E469 /* libIrrlicht.a in Frameworks */, - 4C53E2730A4850D60014E966 /* Cocoa.framework in Frameworks */, - 4C53E2740A4850D60014E966 /* OpenGL.framework in Frameworks */, - 0925114A0D744ADE006784D9 /* Carbon.framework in Frameworks */, - 0930CE660EC39F4500D63866 /* IOKit.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B81CFF25097FE1E00057C06F /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CA25C520A48618800B4E469 /* libIrrlicht.a in Frameworks */, - 4C53E26F0A4850D60014E966 /* Cocoa.framework in Frameworks */, - 4C53E2700A4850D60014E966 /* OpenGL.framework in Frameworks */, - 0925114C0D744ADE006784D9 /* Carbon.framework in Frameworks */, - 0930CE580EC39F4500D63866 /* IOKit.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B81CFF3A097FE25F0057C06F /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 4C53E2510A4850550014E966 /* libIrrlicht.a in Frameworks */, - 4C53E2870A4850D60014E966 /* Cocoa.framework in Frameworks */, - 4C53E2880A4850D60014E966 /* OpenGL.framework in Frameworks */, - 0925114D0D744ADE006784D9 /* Carbon.framework in Frameworks */, - 0930CE570EC39F4500D63866 /* IOKit.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B81CFF51097FE3050057C06F /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CA5CBB10A486A0200ADB3D7 /* libIrrlicht.a in Frameworks */, - 4C53E27D0A4850D60014E966 /* Cocoa.framework in Frameworks */, - 4C53E27E0A4850D60014E966 /* OpenGL.framework in Frameworks */, - 092511450D744ADE006784D9 /* Carbon.framework in Frameworks */, - 0930CE610EC39F4500D63866 /* IOKit.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B81CFF7F097FE3DC0057C06F /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CA25C560A4861AE00B4E469 /* libIrrlicht.a in Frameworks */, - 4C53E2710A4850D60014E966 /* Cocoa.framework in Frameworks */, - 4C53E2720A4850D60014E966 /* OpenGL.framework in Frameworks */, - 0925114B0D744ADE006784D9 /* Carbon.framework in Frameworks */, - 0930CE560EC39F4500D63866 /* IOKit.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B81CFF98097FE45E0057C06F /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CA5CBAF0A4869F300ADB3D7 /* libIrrlicht.a in Frameworks */, - 4C53E27B0A4850D60014E966 /* Cocoa.framework in Frameworks */, - 4C53E27C0A4850D60014E966 /* OpenGL.framework in Frameworks */, - 092511460D744ADE006784D9 /* Carbon.framework in Frameworks */, - 0930CE620EC39F4500D63866 /* IOKit.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B81CFFB6097FE5F80057C06F /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CA5CBBA0A486A3A00ADB3D7 /* libIrrlicht.a in Frameworks */, - 4C53E2830A4850D60014E966 /* Cocoa.framework in Frameworks */, - 4C53E2840A4850D60014E966 /* OpenGL.framework in Frameworks */, - 092511420D744ADE006784D9 /* Carbon.framework in Frameworks */, - 0930CE5E0EC39F4500D63866 /* IOKit.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B8DEF35B0950229200FDEA7E /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CA5CBBF0A486A5700ADB3D7 /* libIrrlicht.a in Frameworks */, - 4C53E2850A4850D60014E966 /* Cocoa.framework in Frameworks */, - 4C53E2860A4850D60014E966 /* OpenGL.framework in Frameworks */, - 092511410D744ADE006784D9 /* Carbon.framework in Frameworks */, - 0930CE5D0EC39F4500D63866 /* IOKit.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - D2AAC07C0554694100DB518D /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 0867D691FE84028FC02AAC07 /* MacOSX */ = { - isa = PBXGroup; - children = ( - 09022C660EA0EA6500CD54EE /* Tools */, - 4CFA7C090A88742800B03626 /* include */, - 4C53DEE50A484C220014E966 /* Irrlicht */, - 4C00546D0A48470500C844C2 /* examples */, - 4C53E2540A48505D0014E966 /* Libraries */, - 4C53E24C0A484FED0014E966 /* Products */, - ); - name = MacOSX; - sourceTree = "<group>"; - }; - 09022C660EA0EA6500CD54EE /* Tools */ = { - isa = PBXGroup; - children = ( - 09022C670EA0EA7100CD54EE /* GUIEditor */, - ); - name = Tools; - sourceTree = "<group>"; - }; - 09022C670EA0EA7100CD54EE /* GUIEditor */ = { - isa = PBXGroup; - children = ( - 09022CA40EA0EC1900CD54EE /* source */, - 09022CA30EA0EC0E00CD54EE /* include */, - ); - name = GUIEditor; - sourceTree = "<group>"; - }; - 09022CA30EA0EC0E00CD54EE /* include */ = { - isa = PBXGroup; - children = ( - 09022C680EA0EA9D00CD54EE /* CGUIAttribute.h */, - 09022C6A0EA0EA9D00CD54EE /* CGUIAttributeEditor.h */, - 09022C6B0EA0EA9D00CD54EE /* CGUIBoolAttribute.h */, - 09022C6C0EA0EA9D00CD54EE /* CGUIColorAttribute.h */, - 09022C6D0EA0EA9D00CD54EE /* CGUIDummyEditorStub.h */, - 09022C6F0EA0EA9D00CD54EE /* CGUIEditFactory.h */, - 09022C710EA0EA9D00CD54EE /* CGUIEditWindow.h */, - 09022C730EA0EA9D00CD54EE /* CGUIEditWorkspace.h */, - 09022C740EA0EA9D00CD54EE /* CGUIEnumAttribute.h */, - 09022C760EA0EA9D00CD54EE /* CGUIPanel.h */, - 09022C770EA0EA9D00CD54EE /* CGUIStringAttribute.h */, - 09022C780EA0EA9D00CD54EE /* CGUITextureAttribute.h */, - 09022C7A0EA0EA9D00CD54EE /* CGUITextureCacheBrowser.h */, - 09022C7C0EA0EA9D00CD54EE /* CMemoryReadWriteFile.h */, - ); - name = include; - sourceTree = "<group>"; - }; - 09022CA40EA0EC1900CD54EE /* source */ = { - isa = PBXGroup; - children = ( - 09022C690EA0EA9D00CD54EE /* CGUIAttributeEditor.cpp */, - 09022C6E0EA0EA9D00CD54EE /* CGUIEditFactory.cpp */, - 09022C700EA0EA9D00CD54EE /* CGUIEditWindow.cpp */, - 09022C720EA0EA9D00CD54EE /* CGUIEditWorkspace.cpp */, - 09022C750EA0EA9D00CD54EE /* CGUIPanel.cpp */, - 09022C790EA0EA9D00CD54EE /* CGUITextureCacheBrowser.cpp */, - 09022C7B0EA0EA9D00CD54EE /* CMemoryReadWriteFile.cpp */, - 09022C7D0EA0EA9D00CD54EE /* main.cpp */, - ); - name = source; - sourceTree = "<group>"; - }; - 0910BA4D0D1F64D000D46B04 /* gui */ = { - isa = PBXGroup; - children = ( - 0910BA070D1F64B300D46B04 /* EMessageBoxFlags.h */, - 4CFA7C0D0A88742800B03626 /* EGUIElementTypes.h */, - 0910BA020D1F64B300D46B04 /* EGUIAlignment.h */, - 4CFA7C1B0A88742900B03626 /* ICursorControl.h */, - 4CFA7C210A88742900B03626 /* IGUIButton.h */, - 4CFA7C220A88742900B03626 /* IGUICheckBox.h */, - 0910BA0B0D1F64B300D46B04 /* IGUIColorSelectDialog.h */, - 4CFA7C230A88742900B03626 /* IGUIComboBox.h */, - 4CFA7C240A88742900B03626 /* IGUIContextMenu.h */, - 4CFA7C250A88742900B03626 /* IGUIEditBox.h */, - 4CFA7C260A88742900B03626 /* IGUIElement.h */, - 0910BA0C0D1F64B300D46B04 /* IGUIElementFactory.h */, - 4CFA7C270A88742900B03626 /* IGUIEnvironment.h */, - 4CFA7C280A88742900B03626 /* IGUIFileOpenDialog.h */, - 4CFA7C290A88742900B03626 /* IGUIFont.h */, - 0910BA0D0D1F64B300D46B04 /* IGUIFontBitmap.h */, - 4CFA7C2A0A88742900B03626 /* IGUIImage.h */, - 4CFA7C2B0A88742900B03626 /* IGUIInOutFader.h */, - 4CFA7C2C0A88742900B03626 /* IGUIListBox.h */, - 4CFA7C2D0A88742900B03626 /* IGUIMeshViewer.h */, - 4CFA7C2E0A88742900B03626 /* IGUIScrollBar.h */, - 4CFA7C2F0A88742900B03626 /* IGUISkin.h */, - 0910BA0E0D1F64B300D46B04 /* IGUISpinBox.h */, - 0910BA0F0D1F64B300D46B04 /* IGUISpriteBank.h */, - 4CFA7C300A88742900B03626 /* IGUIStaticText.h */, - 4CFA7C310A88742900B03626 /* IGUITabControl.h */, - 0910BA100D1F64B300D46B04 /* IGUITable.h */, - 4CFA7C320A88742900B03626 /* IGUIToolbar.h */, - 4CFA7C330A88742900B03626 /* IGUIWindow.h */, - ); - name = gui; - sourceTree = "<group>"; - }; - 0910BA4E0D1F652100D46B04 /* core */ = { - isa = PBXGroup; - children = ( - 4CFA7C500A88742900B03626 /* irrTypes.h */, - 0910B9FE0D1F64B300D46B04 /* coreutil.h */, - 4CFA7C5F0A88742900B03626 /* ITimer.h */, - 4CFA7C670A88742900B03626 /* Keycodes.h */, - 4CFA7C750A88742900B03626 /* SKeyMap.h */, - 4CFA7C0A0A88742800B03626 /* aabbox3d.h */, - 4CFA7C0B0A88742800B03626 /* dimension2d.h */, - 4CFA7C100A88742800B03626 /* heapsort.h */, - 4CFA7C480A88742900B03626 /* irrAllocator.h */, - 4CFA7C490A88742900B03626 /* irrArray.h */, - 4CFA7C4D0A88742900B03626 /* irrList.h */, - 0910BA1E0D1F64B300D46B04 /* irrMap.h */, - 4CFA7C4E0A88742900B03626 /* irrMath.h */, - 4CFA7C4F0A88742900B03626 /* irrString.h */, - 4CFA7C680A88742900B03626 /* line2d.h */, - 4CFA7C690A88742900B03626 /* line3d.h */, - 4CFA7C6A0A88742900B03626 /* matrix4.h */, - 4CFA7C6B0A88742900B03626 /* plane3d.h */, - 4CFA7C6C0A88742900B03626 /* position2d.h */, - 4CFA7C6D0A88742900B03626 /* quaternion.h */, - 4CFA7C6E0A88742900B03626 /* rect.h */, - 4CFA7C7E0A88742900B03626 /* triangle3d.h */, - 4CFA7C7F0A88742900B03626 /* vector2d.h */, - 4CFA7C800A88742900B03626 /* vector3d.h */, - ); - name = core; - sourceTree = "<group>"; - }; - 0910BA4F0D1F65A300D46B04 /* io */ = { - isa = PBXGroup; - children = ( - 4CFA7C360A88742900B03626 /* IImageWriter.h */, - 0910BA110D1F64B300D46B04 /* IMeshWriter.h */, - 4CFA7C170A88742900B03626 /* IAttributeExchangingObject.h */, - 4CFA7C180A88742900B03626 /* IAttributes.h */, - 4CFA7C1E0A88742900B03626 /* IFileList.h */, - 4CFA7C1F0A88742900B03626 /* IFileSystem.h */, - 4CFA7C470A88742900B03626 /* IReadFile.h */, - 4CFA7C510A88742900B03626 /* irrXML.h */, - 4CFA7C640A88742900B03626 /* IWriteFile.h */, - 4CFA7C650A88742900B03626 /* IXMLReader.h */, - 4CFA7C660A88742900B03626 /* IXMLWriter.h */, - ); - name = io; - sourceTree = "<group>"; - }; - 0910BA500D1F660300D46B04 /* scene */ = { - isa = PBXGroup; - children = ( - 0910BA220D1F64B300D46B04 /* SSkinMeshBuffer.h */, - 0910BA210D1F64B300D46B04 /* SSharedMeshBuffer.h */, - 0910BA0A0D1F64B300D46B04 /* IBoneSceneNode.h */, - 0910BA080D1F64B300D46B04 /* ETerrainElements.h */, - 0910BA030D1F64B300D46B04 /* EHardwareBufferFlags.h */, - 4CFA7C590A88742900B03626 /* ISceneUserDataSerializer.h */, - 0910B9FF0D1F64B300D46B04 /* ECullingTypes.h */, - 0910BA000D1F64B300D46B04 /* EDebugSceneTypes.h */, - 0910BA060D1F64B300D46B04 /* EMeshWriterEnums.h */, - 4CFA7C0E0A88742800B03626 /* ESceneNodeAnimatorTypes.h */, - 4CFA7C0F0A88742800B03626 /* ESceneNodeTypes.h */, - 4CFA7C110A88742900B03626 /* IAnimatedMesh.h */, - 4CFA7C130A88742900B03626 /* IAnimatedMeshMD2.h */, - 0910BA090D1F64B300D46B04 /* IAnimatedMeshMD3.h */, - 4CFA7C150A88742900B03626 /* IAnimatedMeshSceneNode.h */, - 4CFA7C190A88742900B03626 /* IBillboardSceneNode.h */, - 4CFA7C1A0A88742900B03626 /* ICameraSceneNode.h */, - 4CFA7C1C0A88742900B03626 /* IDummyTransformationSceneNode.h */, - 4CFA7C370A88742900B03626 /* ILightSceneNode.h */, - 4CFA7C3B0A88742900B03626 /* IMesh.h */, - 4CFA7C3C0A88742900B03626 /* IMeshBuffer.h */, - 4CFA7C3D0A88742900B03626 /* IMeshCache.h */, - 4CFA7C3E0A88742900B03626 /* IMeshLoader.h */, - 4CFA7C3F0A88742900B03626 /* IMeshManipulator.h */, - 4CFA7C400A88742900B03626 /* IMeshSceneNode.h */, - 4CFA7C410A88742900B03626 /* IMetaTriangleSelector.h */, - 4CFA7C430A88742900B03626 /* IParticleAffector.h */, - 0910BA120D1F64B300D46B04 /* IParticleAnimatedMeshSceneNodeEmitter.h */, - 0910BA130D1F64B300D46B04 /* IParticleAttractionAffector.h */, - 0910BA140D1F64B300D46B04 /* IParticleBoxEmitter.h */, - 0910BA150D1F64B300D46B04 /* IParticleCylinderEmitter.h */, - 4CFA7C440A88742900B03626 /* IParticleEmitter.h */, - 0910BA160D1F64B300D46B04 /* IParticleFadeOutAffector.h */, - 0910BA170D1F64B300D46B04 /* IParticleGravityAffector.h */, - 0910BA180D1F64B300D46B04 /* IParticleMeshEmitter.h */, - 0910BA190D1F64B300D46B04 /* IParticleRingEmitter.h */, - 0910BA1A0D1F64B300D46B04 /* IParticleRotationAffector.h */, - 0910BA1B0D1F64B300D46B04 /* IParticleSphereEmitter.h */, - 4CFA7C450A88742900B03626 /* IParticleSystemSceneNode.h */, - 4CFA7C460A88742900B03626 /* IQ3LevelMesh.h */, - 0910BA1C0D1F64B300D46B04 /* IQ3Shader.h */, - 4CFA7C520A88742900B03626 /* ISceneCollisionManager.h */, - 4CFA7C530A88742900B03626 /* ISceneManager.h */, - 4CFA7C540A88742900B03626 /* ISceneNode.h */, - 4CFA7C550A88742900B03626 /* ISceneNodeAnimator.h */, - 4CFA7C560A88742900B03626 /* ISceneNodeAnimatorCollisionResponse.h */, - 4CFA7C570A88742900B03626 /* ISceneNodeAnimatorFactory.h */, - 4CFA7C580A88742900B03626 /* ISceneNodeFactory.h */, - 4CFA7C5B0A88742900B03626 /* IShadowVolumeSceneNode.h */, - 0910BA1F0D1F64B300D46B04 /* ISkinnedMesh.h */, - 4CFA7C5C0A88742900B03626 /* ITerrainSceneNode.h */, - 4CFA7C5D0A88742900B03626 /* ITextSceneNode.h */, - 4CFA7C600A88742900B03626 /* ITriangleSelector.h */, - 4CFA7C700A88742900B03626 /* SAnimatedMesh.h */, - 4CFA7C710A88742900B03626 /* SceneParameters.h */, - 4CFA7C780A88742900B03626 /* SMesh.h */, - 4CFA7C790A88742900B03626 /* SMeshBuffer.h */, - 4CFA7C7A0A88742900B03626 /* SMeshBufferLightMap.h */, - 4CFA7C7B0A88742900B03626 /* SMeshBufferTangents.h */, - 4CFA7C7C0A88742900B03626 /* SParticle.h */, - 0910B9FD0D1F64B300D46B04 /* CMeshBuffer.h */, - 0910BA230D1F64B300D46B04 /* SViewFrustum.h */, - ); - name = scene; - sourceTree = "<group>"; - }; - 0910BA800D1F6ADA00D46B04 /* video */ = { - isa = PBXGroup; - children = ( - 0910BA200D1F64B300D46B04 /* SMaterialLayer.h */, - 0910BA050D1F64B300D46B04 /* EMaterialTypes.h */, - 0910BA040D1F64B300D46B04 /* EMaterialFlags.h */, - 0910BA010D1F64B300D46B04 /* EDriverFeatures.h */, - 4CFA7C200A88742900B03626 /* IGPUProgrammingServices.h */, - 4CFA7C340A88742900B03626 /* IImage.h */, - 4CFA7C350A88742900B03626 /* IImageLoader.h */, - 4CFA7C390A88742900B03626 /* IMaterialRenderer.h */, - 4CFA7C3A0A88742900B03626 /* IMaterialRendererServices.h */, - 4CFA7C5A0A88742900B03626 /* IShaderConstantSetCallBack.h */, - 4CFA7C5E0A88742900B03626 /* ITexture.h */, - 4CFA7C620A88742900B03626 /* IVideoDriver.h */, - 4CFA7C630A88742900B03626 /* IVideoModeList.h */, - 4CFA7C6F0A88742900B03626 /* S3DVertex.h */, - 4CFA7C720A88742900B03626 /* SColor.h */, - 4CFA7C730A88742900B03626 /* SExposedVideoData.h */, - 4CFA7C760A88742900B03626 /* SLight.h */, - 4CFA7C770A88742900B03626 /* SMaterial.h */, - ); - name = video; - sourceTree = "<group>"; - }; - 0910BA810D1F6BB800D46B04 /* gui */ = { - isa = PBXGroup; - children = ( - 34FFD9CB0F6601AC00420884 /* element */, - 4C53DEE60A484C220014E966 /* BuiltInFont.h */, - 5DD480580C7D945800728AA9 /* CDefaultGUIElementFactory.cpp */, - 5DD480590C7D945800728AA9 /* CDefaultGUIElementFactory.h */, - 4C53DF3C0A484C230014E966 /* CGUIFont.cpp */, - 4C53DF3D0A484C230014E966 /* CGUIFont.h */, - 4C53DF4E0A484C230014E966 /* CGUISkin.cpp */, - 4C53DF4F0A484C230014E966 /* CGUISkin.h */, - 5DD480620C7D947B00728AA9 /* CGUISpriteBank.cpp */, - 5DD480630C7D947B00728AA9 /* CGUISpriteBank.h */, - ); - name = gui; - sourceTree = "<group>"; - }; - 0910BA820D1F6C3900D46B04 /* io */ = { - isa = PBXGroup; - children = ( - 34FFD9CA0F66018500420884 /* xml */, - 34FFD9C90F66014200420884 /* file */, - 34FFD9C80F66012D00420884 /* attributes */, - 34FFD9C70F66011C00420884 /* archive */, - 4C53DF260A484C230014E966 /* CFileList.cpp */, - 4C53DF270A484C230014E966 /* CFileList.h */, - 4C53DF280A484C230014E966 /* CFileSystem.cpp */, - 4C53DF290A484C230014E966 /* CFileSystem.h */, - ); - name = io; - sourceTree = "<group>"; - }; - 0910BA830D1F6CA600D46B04 /* irr */ = { - isa = PBXGroup; - children = ( - 34FFD9C60F6600DA00420884 /* device */, - 4C53DF720A484C230014E966 /* CLogger.cpp */, - 4C53DF730A484C230014E966 /* CLogger.h */, - 4C53DF990A484C240014E966 /* COSOperator.cpp */, - 4C53DF9A0A484C240014E966 /* COSOperator.h */, - 4C53DFD00A484C240014E966 /* CTimer.h */, - 4C53E00A0A484C250014E966 /* Irrlicht.cpp */, - 4C53E16A0A484C2C0014E966 /* os.cpp */, - 4C53E16B0A484C2C0014E966 /* os.h */, - ); - name = irr; - sourceTree = "<group>"; - }; - 0910BA840D1F6D0200D46B04 /* scene */ = { - isa = PBXGroup; - children = ( - 0910BA850D1F6D0A00D46B04 /* animators */, - 0910BA860D1F6D2600D46B04 /* collision */, - 0910BA870D1F6D7500D46B04 /* loaders */, - 0910BA880D1F6F1600D46B04 /* particleSystem */, - 0910BA890D1F6F6600D46B04 /* sceneNodes */, - 0910BA8A0D1F70B800D46B04 /* writers */, - 4C53DF1D0A484C230014E966 /* CDefaultSceneNodeAnimatorFactory.h */, - 4C53DF1C0A484C230014E966 /* CDefaultSceneNodeAnimatorFactory.cpp */, - 4C53DF1E0A484C230014E966 /* CDefaultSceneNodeFactory.cpp */, - 4C53DF1F0A484C230014E966 /* CDefaultSceneNodeFactory.h */, - 4C53DF2C0A484C230014E966 /* CGeometryCreator.cpp */, - 4C53DF2D0A484C230014E966 /* CGeometryCreator.h */, - 4C53DF760A484C230014E966 /* CMeshCache.cpp */, - 4C53DF770A484C230014E966 /* CMeshCache.h */, - 4C53DF780A484C230014E966 /* CMeshManipulator.cpp */, - 4C53DF790A484C230014E966 /* CMeshManipulator.h */, - 4C53DFAB0A484C240014E966 /* CSceneManager.cpp */, - 4C53DFAC0A484C240014E966 /* CSceneManager.h */, - 4C53E1690A484C2C0014E966 /* OctTree.h */, - ); - name = scene; - sourceTree = "<group>"; - }; - 0910BA850D1F6D0A00D46B04 /* animators */ = { - isa = PBXGroup; - children = ( - 4C53DFAD0A484C240014E966 /* CSceneNodeAnimatorCollisionResponse.cpp */, - 4C53DFAE0A484C240014E966 /* CSceneNodeAnimatorCollisionResponse.h */, - 4C53DFAF0A484C240014E966 /* CSceneNodeAnimatorDelete.cpp */, - 4C53DFB00A484C240014E966 /* CSceneNodeAnimatorDelete.h */, - 4C53DFB10A484C240014E966 /* CSceneNodeAnimatorFlyCircle.cpp */, - 4C53DFB20A484C240014E966 /* CSceneNodeAnimatorFlyCircle.h */, - 4C53DFB30A484C240014E966 /* CSceneNodeAnimatorFlyStraight.cpp */, - 4C53DFB40A484C240014E966 /* CSceneNodeAnimatorFlyStraight.h */, - 4C53DFB50A484C240014E966 /* CSceneNodeAnimatorFollowSpline.cpp */, - 4C53DFB60A484C240014E966 /* CSceneNodeAnimatorFollowSpline.h */, - 4C53DFB70A484C240014E966 /* CSceneNodeAnimatorRotation.cpp */, - 4C53DFB80A484C240014E966 /* CSceneNodeAnimatorRotation.h */, - 4C53DFB90A484C240014E966 /* CSceneNodeAnimatorTexture.cpp */, - 4C53DFBA0A484C240014E966 /* CSceneNodeAnimatorTexture.h */, - ); - name = animators; - sourceTree = "<group>"; - }; - 0910BA860D1F6D2600D46B04 /* collision */ = { - isa = PBXGroup; - children = ( - 4C53DF880A484C240014E966 /* COctTreeTriangleSelector.cpp */, - 4C53DF890A484C240014E966 /* COctTreeTriangleSelector.h */, - 4C53DF7C0A484C230014E966 /* CMetaTriangleSelector.cpp */, - 4C53DF7D0A484C230014E966 /* CMetaTriangleSelector.h */, - 4C53DFA90A484C240014E966 /* CSceneCollisionManager.cpp */, - 4C53DFAA0A484C240014E966 /* CSceneCollisionManager.h */, - 4C53DFCC0A484C240014E966 /* CTerrainTriangleSelector.cpp */, - 4C53DFCD0A484C240014E966 /* CTerrainTriangleSelector.h */, - 4C53DFD80A484C240014E966 /* CTriangleBBSelector.cpp */, - 4C53DFD90A484C250014E966 /* CTriangleBBSelector.h */, - 4C53DFDA0A484C250014E966 /* CTriangleSelector.cpp */, - 4C53DFDB0A484C250014E966 /* CTriangleSelector.h */, - ); - name = collision; - sourceTree = "<group>"; - }; - 0910BA870D1F6D7500D46B04 /* loaders */ = { - isa = PBXGroup; - children = ( - 096840220D0F1A2300333EFD /* CBSPMeshFileLoader.cpp */, - 096840230D0F1A2300333EFD /* CBSPMeshFileLoader.h */, - 09C638700D4F1A69000B6A18 /* CLWOMeshFileLoader.cpp */, - 09C638710D4F1A69000B6A18 /* CLWOMeshFileLoader.h */, - 4C53DEE70A484C220014E966 /* C3DSMeshFileLoader.cpp */, - 4C53DEE80A484C220014E966 /* C3DSMeshFileLoader.h */, - 4C53DEE90A484C220014E966 /* CAnimatedMeshMD2.cpp */, - 4C53DEEA0A484C220014E966 /* CAnimatedMeshMD2.h */, - 5DD480560C7D945800728AA9 /* CAnimatedMeshMD3.cpp */, - 5DD480570C7D945800728AA9 /* CAnimatedMeshMD3.h */, - 0968401E0D0F1A2300333EFD /* CB3DMeshFileLoader.cpp */, - 0968401F0D0F1A2300333EFD /* CB3DMeshFileLoader.h */, - 4C53DEFA0A484C220014E966 /* CColladaFileLoader.cpp */, - 4C53DEFB0A484C220014E966 /* CColladaFileLoader.h */, - 4C53DEFE0A484C220014E966 /* CCSMLoader.cpp */, - 4C53DEFF0A484C220014E966 /* CCSMLoader.h */, - 4C53DF200A484C230014E966 /* CDMFLoader.cpp */, - 4C53DF210A484C230014E966 /* CDMFLoader.h */, - 0968402B0D0F1A2300333EFD /* CIrrMeshFileLoader.cpp */, - 0968402C0D0F1A2300333EFD /* CIrrMeshFileLoader.h */, - 4C53DF700A484C230014E966 /* CLMTSMeshFileLoader.cpp */, - 4C53DF710A484C230014E966 /* CLMTSMeshFileLoader.h */, - 0968402F0D0F1A2300333EFD /* CMD2MeshFileLoader.cpp */, - 096840300D0F1A2300333EFD /* CMD2MeshFileLoader.h */, - 5DD480C60C7DA66800728AA9 /* CMD3MeshFileLoader.cpp */, - 5DD480C20C7DA66800728AA9 /* CMD3MeshFileLoader.h */, - 096840310D0F1A2300333EFD /* CMS3DMeshFileLoader.cpp */, - 096840320D0F1A2300333EFD /* CMS3DMeshFileLoader.h */, - 4C53DF7E0A484C230014E966 /* CMY3DHelper.h */, - 4C53DF7F0A484C230014E966 /* CMY3DMeshFileLoader.cpp */, - 4C53DF800A484C230014E966 /* CMY3DMeshFileLoader.h */, - 4C364EA20A6C6DC2004CFBB4 /* COBJMeshFileLoader.cpp */, - 4C364EA30A6C6DC2004CFBB4 /* COBJMeshFileLoader.h */, - 4C53DF840A484C240014E966 /* COCTLoader.cpp */, - 4C53DF850A484C240014E966 /* COCTLoader.h */, - 4C53DF8A0A484C240014E966 /* COgreMeshFileLoader.cpp */, - 4C53DF8B0A484C240014E966 /* COgreMeshFileLoader.h */, - 34EF91D50F65FCF6000B5651 /* CPLYMeshFileLoader.h */, - 34EF91D60F65FCF6000B5651 /* CPLYMeshFileLoader.cpp */, - 4C53DFA50A484C240014E966 /* CQ3LevelMesh.cpp */, - 4C53DFA60A484C240014E966 /* CQ3LevelMesh.h */, - 096840410D0F1A2300333EFD /* CSkinnedMesh.cpp */, - 096840420D0F1A2300333EFD /* CSkinnedMesh.h */, - 096840430D0F1A2300333EFD /* CSTLMeshFileLoader.cpp */, - 096840440D0F1A2300333EFD /* CSTLMeshFileLoader.h */, - 4C53DFF80A484C250014E966 /* CXMeshFileLoader.cpp */, - 4C53DFF90A484C250014E966 /* CXMeshFileLoader.h */, - 4C53E0050A484C250014E966 /* dmfsupport.h */, - ); - name = loaders; - sourceTree = "<group>"; - }; - 0910BA880D1F6F1600D46B04 /* particleSystem */ = { - isa = PBXGroup; - children = ( - 096CC0DE0ECE65B500C81DC7 /* CParticleScaleAffector.cpp */, - 096CC0DF0ECE65B500C81DC7 /* CParticleScaleAffector.h */, - 096840330D0F1A2300333EFD /* CParticleAnimatedMeshSceneNodeEmitter.cpp */, - 096840340D0F1A2300333EFD /* CParticleAnimatedMeshSceneNodeEmitter.h */, - 096840350D0F1A2300333EFD /* CParticleAttractionAffector.cpp */, - 096840360D0F1A2300333EFD /* CParticleAttractionAffector.h */, - 4C53DF9B0A484C240014E966 /* CParticleBoxEmitter.cpp */, - 4C53DF9C0A484C240014E966 /* CParticleBoxEmitter.h */, - 096840370D0F1A2300333EFD /* CParticleCylinderEmitter.cpp */, - 096840380D0F1A2300333EFD /* CParticleCylinderEmitter.h */, - 4C53DF9D0A484C240014E966 /* CParticleFadeOutAffector.cpp */, - 4C53DF9E0A484C240014E966 /* CParticleFadeOutAffector.h */, - 4C53DF9F0A484C240014E966 /* CParticleGravityAffector.cpp */, - 4C53DFA00A484C240014E966 /* CParticleGravityAffector.h */, - 096840390D0F1A2300333EFD /* CParticleMeshEmitter.cpp */, - 0968403A0D0F1A2300333EFD /* CParticleMeshEmitter.h */, - 4C53DFA10A484C240014E966 /* CParticlePointEmitter.cpp */, - 4C53DFA20A484C240014E966 /* CParticlePointEmitter.h */, - 0968403B0D0F1A2300333EFD /* CParticleRingEmitter.cpp */, - 0968403C0D0F1A2300333EFD /* CParticleRingEmitter.h */, - 0968403D0D0F1A2300333EFD /* CParticleRotationAffector.cpp */, - 0968403E0D0F1A2300333EFD /* CParticleRotationAffector.h */, - 0968403F0D0F1A2300333EFD /* CParticleSphereEmitter.cpp */, - 096840400D0F1A2300333EFD /* CParticleSphereEmitter.h */, - 4C53DFA30A484C240014E966 /* CParticleSystemSceneNode.cpp */, - 4C53DFA40A484C240014E966 /* CParticleSystemSceneNode.h */, - ); - name = particleSystem; - sourceTree = "<group>"; - }; - 0910BA890D1F6F6600D46B04 /* sceneNodes */ = { - isa = PBXGroup; - children = ( - 093973BC0E0458B200E0C987 /* CSceneNodeAnimatorCameraFPS.cpp */, - 093973BD0E0458B200E0C987 /* CSceneNodeAnimatorCameraFPS.h */, - 093973BE0E0458B200E0C987 /* CSceneNodeAnimatorCameraMaya.cpp */, - 093973BF0E0458B200E0C987 /* CSceneNodeAnimatorCameraMaya.h */, - 4C53DEED0A484C220014E966 /* CAnimatedMeshSceneNode.cpp */, - 4C53DEEE0A484C220014E966 /* CAnimatedMeshSceneNode.h */, - 4C53DEF20A484C220014E966 /* CBillboardSceneNode.cpp */, - 4C53DEF30A484C220014E966 /* CBillboardSceneNode.h */, - 096840200D0F1A2300333EFD /* CBoneSceneNode.cpp */, - 096840210D0F1A2300333EFD /* CBoneSceneNode.h */, - 4C53DEF80A484C220014E966 /* CCameraSceneNode.cpp */, - 4C53DEF90A484C220014E966 /* CCameraSceneNode.h */, - 4C53DF000A484C220014E966 /* CCubeSceneNode.cpp */, - 4C53DF010A484C220014E966 /* CCubeSceneNode.h */, - 4C53DF220A484C230014E966 /* CDummyTransformationSceneNode.cpp */, - 4C53DF230A484C230014E966 /* CDummyTransformationSceneNode.h */, - 4C53DF240A484C230014E966 /* CEmptySceneNode.cpp */, - 4C53DF250A484C230014E966 /* CEmptySceneNode.h */, - 4C53DF6C0A484C230014E966 /* CLightSceneNode.cpp */, - 4C53DF6D0A484C230014E966 /* CLightSceneNode.h */, - 4C53DF7A0A484C230014E966 /* CMeshSceneNode.cpp */, - 4C53DF7B0A484C230014E966 /* CMeshSceneNode.h */, - 4C53DF860A484C240014E966 /* COctTreeSceneNode.cpp */, - 4C53DF870A484C240014E966 /* COctTreeSceneNode.h */, - 5DD4806A0C7D94AC00728AA9 /* CQuake3ShaderSceneNode.cpp */, - 5DD4806B0C7D94AC00728AA9 /* CQuake3ShaderSceneNode.h */, - 4C53DFBB0A484C240014E966 /* CShadowVolumeSceneNode.cpp */, - 4C53DFBC0A484C240014E966 /* CShadowVolumeSceneNode.h */, - 4C53DFBD0A484C240014E966 /* CSkyBoxSceneNode.cpp */, - 4C53DFBE0A484C240014E966 /* CSkyBoxSceneNode.h */, - 4CFA7BEC0A88735A00B03626 /* CSkyDomeSceneNode.cpp */, - 4CFA7BED0A88735A00B03626 /* CSkyDomeSceneNode.h */, - 4CC36B0D0A6B61DB0076C4B2 /* CSphereSceneNode.cpp */, - 4CC36B0E0A6B61DB0076C4B2 /* CSphereSceneNode.h */, - 4C53DFCA0A484C240014E966 /* CTerrainSceneNode.cpp */, - 4C53DFCB0A484C240014E966 /* CTerrainSceneNode.h */, - 4C53DFCE0A484C240014E966 /* CTextSceneNode.cpp */, - 4C53DFCF0A484C240014E966 /* CTextSceneNode.h */, - 090FBC800D31085E0076D847 /* CVolumeLightSceneNode.cpp */, - 090FBC810D31085E0076D847 /* CVolumeLightSceneNode.h */, - 4C53DFF00A484C250014E966 /* CWaterSurfaceSceneNode.cpp */, - 4C53DFF10A484C250014E966 /* CWaterSurfaceSceneNode.h */, - ); - name = sceneNodes; - sourceTree = "<group>"; - }; - 0910BA8A0D1F70B800D46B04 /* writers */ = { - isa = PBXGroup; - children = ( - 096840250D0F1A2300333EFD /* CColladaMeshWriter.cpp */, - 096840260D0F1A2300333EFD /* CColladaMeshWriter.h */, - 0968402D0D0F1A2300333EFD /* CIrrMeshWriter.cpp */, - 0968402E0D0F1A2300333EFD /* CIrrMeshWriter.h */, - 096F8E3B0EA2EFBA00907EC5 /* COBJMeshWriter.cpp */, - 096F8E3C0EA2EFBA00907EC5 /* COBJMeshWriter.h */, - 34EF91DA0F65FD14000B5651 /* CPLYMeshWriter.h */, - 34EF91DB0F65FD14000B5651 /* CPLYMeshWriter.cpp */, - 096840450D0F1A2300333EFD /* CSTLMeshWriter.cpp */, - 096840460D0F1A2300333EFD /* CSTLMeshWriter.h */, - ); - name = writers; - sourceTree = "<group>"; - }; - 0910BA8B0D1F71D600D46B04 /* video */ = { - isa = PBXGroup; - children = ( - 0910BA8C0D1F729400D46B04 /* Burning Video */, - 0910BA8D0D1F72DB00D46B04 /* Direct3D8 */, - 0910BA8E0D1F72FB00D46B04 /* Direct3D9 */, - 0910BA8F0D1F731900D46B04 /* Null */, - 0910BA910D1F738100D46B04 /* OpenGL */, - 0910BA920D1F73CC00D46B04 /* Software */, - 4C53DFEE0A484C250014E966 /* CVideoModeList.cpp */, - 4C53DFEF0A484C250014E966 /* CVideoModeList.h */, - ); - name = video; - sourceTree = "<group>"; - }; - 0910BA8C0D1F729400D46B04 /* Burning Video */ = { - isa = PBXGroup; - children = ( - 4C53E16D0A484C2C0014E966 /* S4DVertex.h */, - 4C53E16E0A484C2C0014E966 /* SoftwareDriver2_compile_config.h */, - 4C53E16F0A484C2C0014E966 /* SoftwareDriver2_helper.h */, - 5DD4804C0C7D91DF00728AA9 /* CDepthBuffer.cpp */, - 0910B9D90D1F5D4100D46B04 /* CBurningShader_Raster_Reference.cpp */, - 5DD480500C7D936700728AA9 /* IBurningShader.cpp */, - 5DD480510C7D936700728AA9 /* IBurningShader.h */, - 5DD4804D0C7D91DF00728AA9 /* CDepthBuffer.h */, - 4C53DFC20A484C240014E966 /* CSoftwareDriver2.cpp */, - 4C53DFC30A484C240014E966 /* CSoftwareDriver2.h */, - 4C53DFC60A484C240014E966 /* CSoftwareTexture2.cpp */, - 4C53DFC70A484C240014E966 /* CSoftwareTexture2.h */, - ); - name = "Burning Video"; - sourceTree = "<group>"; - }; - 0910BA8D0D1F72DB00D46B04 /* Direct3D8 */ = { - isa = PBXGroup; - children = ( - 4C53DF020A484C220014E966 /* CD3D8Driver.cpp */, - 4C53DF030A484C220014E966 /* CD3D8Driver.h */, - 4C53DF040A484C220014E966 /* CD3D8MaterialRenderer.h */, - 4C53DF050A484C220014E966 /* CD3D8NormalMapRenderer.cpp */, - 4C53DF060A484C220014E966 /* CD3D8NormalMapRenderer.h */, - 4C53DF070A484C230014E966 /* CD3D8ParallaxMapRenderer.cpp */, - 4C53DF080A484C230014E966 /* CD3D8ParallaxMapRenderer.h */, - 4C53DF090A484C230014E966 /* CD3D8ShaderMaterialRenderer.cpp */, - 4C53DF0A0A484C230014E966 /* CD3D8ShaderMaterialRenderer.h */, - 4C53DF0B0A484C230014E966 /* CD3D8Texture.cpp */, - 4C53DF0C0A484C230014E966 /* CD3D8Texture.h */, - ); - name = Direct3D8; - sourceTree = "<group>"; - }; - 0910BA8E0D1F72FB00D46B04 /* Direct3D9 */ = { - isa = PBXGroup; - children = ( - 4C53DF0D0A484C230014E966 /* CD3D9Driver.cpp */, - 4C53DF0E0A484C230014E966 /* CD3D9Driver.h */, - 4C53DF0F0A484C230014E966 /* CD3D9HLSLMaterialRenderer.cpp */, - 4C53DF100A484C230014E966 /* CD3D9HLSLMaterialRenderer.h */, - 4C53DF110A484C230014E966 /* CD3D9MaterialRenderer.h */, - 4C53DF120A484C230014E966 /* CD3D9NormalMapRenderer.cpp */, - 4C53DF130A484C230014E966 /* CD3D9NormalMapRenderer.h */, - 4C53DF140A484C230014E966 /* CD3D9ParallaxMapRenderer.cpp */, - 4C53DF150A484C230014E966 /* CD3D9ParallaxMapRenderer.h */, - 4C53DF160A484C230014E966 /* CD3D9ShaderMaterialRenderer.cpp */, - 4C53DF170A484C230014E966 /* CD3D9ShaderMaterialRenderer.h */, - 4C53DF180A484C230014E966 /* CD3D9Texture.cpp */, - 4C53DF190A484C230014E966 /* CD3D9Texture.h */, - ); - name = Direct3D9; - sourceTree = "<group>"; - }; - 0910BA8F0D1F731900D46B04 /* Null */ = { - isa = PBXGroup; - children = ( - 34EF91900F65F9AD000B5651 /* loader */, - 0910BA900D1F733100D46B04 /* writer */, - 4C53DEFC0A484C220014E966 /* CColorConverter.cpp */, - 4C53DEFD0A484C220014E966 /* CColorConverter.h */, - 4C53DF2A0A484C230014E966 /* CFPSCounter.cpp */, - 4C53DF2B0A484C230014E966 /* CFPSCounter.h */, - 4C53DF580A484C230014E966 /* CImage.cpp */, - 4C53DF590A484C230014E966 /* CImage.h */, - 4C53DF820A484C240014E966 /* CNullDriver.cpp */, - 4C53DF830A484C240014E966 /* CNullDriver.h */, - 4C53E0090A484C250014E966 /* IImagePresenter.h */, - ); - name = Null; - sourceTree = "<group>"; - }; - 0910BA900D1F733100D46B04 /* writer */ = { - isa = PBXGroup; - children = ( - 4CFA7BDE0A88735900B03626 /* CImageWriterBMP.cpp */, - 4CFA7BDF0A88735900B03626 /* CImageWriterBMP.h */, - 4CFA7BE00A88735900B03626 /* CImageWriterJPG.cpp */, - 4CFA7BE10A88735900B03626 /* CImageWriterJPG.h */, - 4CFA7BE20A88735900B03626 /* CImageWriterPCX.cpp */, - 4CFA7BE30A88735900B03626 /* CImageWriterPCX.h */, - 4CFA7BE40A88735900B03626 /* CImageWriterPNG.cpp */, - 4CFA7BE50A88735900B03626 /* CImageWriterPNG.h */, - 4CFA7BE60A88735900B03626 /* CImageWriterPPM.cpp */, - 4CFA7BE70A88735900B03626 /* CImageWriterPPM.h */, - 4CFA7BE80A88735900B03626 /* CImageWriterPSD.cpp */, - 4CFA7BE90A88735900B03626 /* CImageWriterPSD.h */, - 4CFA7BEA0A88735900B03626 /* CImageWriterTGA.cpp */, - 4CFA7BEB0A88735900B03626 /* CImageWriterTGA.h */, - ); - name = writer; - sourceTree = "<group>"; - }; - 0910BA910D1F738100D46B04 /* OpenGL */ = { - isa = PBXGroup; - children = ( - 5DD480700C7D94AC00728AA9 /* glxext.h */, - 4C53E0070A484C250014E966 /* glext.h */, - 5DD480C10C7DA66800728AA9 /* COpenGLExtensionHandler.h */, - 5DD480C50C7DA66800728AA9 /* COpenGLExtensionHandler.cpp */, - 4C53DF8C0A484C240014E966 /* COpenGLDriver.cpp */, - 4C53DF8D0A484C240014E966 /* COpenGLDriver.h */, - 4C53DF8E0A484C240014E966 /* COpenGLMaterialRenderer.h */, - 4C53DF8F0A484C240014E966 /* COpenGLNormalMapRenderer.cpp */, - 4C53DF900A484C240014E966 /* COpenGLNormalMapRenderer.h */, - 4C53DF910A484C240014E966 /* COpenGLParallaxMapRenderer.cpp */, - 4C53DF920A484C240014E966 /* COpenGLParallaxMapRenderer.h */, - 4C53DF930A484C240014E966 /* COpenGLShaderMaterialRenderer.cpp */, - 4C53DF940A484C240014E966 /* COpenGLShaderMaterialRenderer.h */, - 4C53DF950A484C240014E966 /* COpenGLSLMaterialRenderer.cpp */, - 4C53DF960A484C240014E966 /* COpenGLSLMaterialRenderer.h */, - 4C53DF970A484C240014E966 /* COpenGLTexture.cpp */, - 4C53DF980A484C240014E966 /* COpenGLTexture.h */, - ); - name = OpenGL; - sourceTree = "<group>"; - }; - 0910BA920D1F73CC00D46B04 /* Software */ = { - isa = PBXGroup; - children = ( - 4C53DFBF0A484C240014E966 /* CSoftware2MaterialRenderer.h */, - 4C53DFC00A484C240014E966 /* CSoftwareDriver.cpp */, - 4C53DFC10A484C240014E966 /* CSoftwareDriver.h */, - 4C53DFC40A484C240014E966 /* CSoftwareTexture.cpp */, - 4C53DFC50A484C240014E966 /* CSoftwareTexture.h */, - 4C53DFFF0A484C250014E966 /* CZBuffer.cpp */, - 4C53E0000A484C250014E966 /* CZBuffer.h */, - 5DD480540C7D93AB00728AA9 /* IDepthBuffer.h */, - 4C53E00F0A484C250014E966 /* ITriangleRenderer.h */, - 5DD4806C0C7D94AC00728AA9 /* CTRTextureBlend.cpp */, - 5DD4806D0C7D94AC00728AA9 /* CTRTextureGouraudAlpha.cpp */, - 5DD4806E0C7D94AC00728AA9 /* CTRTextureGouraudAlphaNoZ.cpp */, - 5DD4806F0C7D94AC00728AA9 /* CTRTextureLightMapGouraud2_M4.cpp */, - 4C53E0110A484C250014E966 /* IZBuffer.h */, - 4C53E16C0A484C2C0014E966 /* S2DVertex.h */, - 4C53DFD10A484C240014E966 /* CTRFlat.cpp */, - 4C53DFD20A484C240014E966 /* CTRFlatWire.cpp */, - 4C53DFD30A484C240014E966 /* CTRGouraud.cpp */, - 4C53DFD40A484C240014E966 /* CTRGouraud2.cpp */, - 4C53DFD50A484C240014E966 /* CTRGouraudAlpha2.cpp */, - 4C53DFD60A484C240014E966 /* CTRGouraudAlphaNoZ2.cpp */, - 4C53DFD70A484C240014E966 /* CTRGouraudWire.cpp */, - 4C53DFDC0A484C250014E966 /* CTRTextureDetailMap2.cpp */, - 4C53DFDD0A484C250014E966 /* CTRTextureFlat.cpp */, - 4C53DFDE0A484C250014E966 /* CTRTextureFlatWire.cpp */, - 4C53DFDF0A484C250014E966 /* CTRTextureGouraud.cpp */, - 4C53DFE00A484C250014E966 /* CTRTextureGouraud.h */, - 4C53DFE10A484C250014E966 /* CTRTextureGouraud2.cpp */, - 4C53DFE20A484C250014E966 /* CTRTextureGouraudAdd.cpp */, - 4C53DFE30A484C250014E966 /* CTRTextureGouraudAdd2.cpp */, - 4C53DFE40A484C250014E966 /* CTRTextureGouraudAddNoZ2.cpp */, - 4C53DFE50A484C250014E966 /* CTRTextureGouraudNoZ.cpp */, - 4C53DFE60A484C250014E966 /* CTRTextureGouraudNoZ2.cpp */, - 4C53DFE70A484C250014E966 /* CTRTextureGouraudVertexAlpha2.cpp */, - 4C53DFE80A484C250014E966 /* CTRTextureGouraudWire.cpp */, - 4C53DFE90A484C250014E966 /* CTRTextureLightMap2_Add.cpp */, - 4C53DFEA0A484C250014E966 /* CTRTextureLightMap2_M1.cpp */, - 4C53DFEB0A484C250014E966 /* CTRTextureLightMap2_M2.cpp */, - 4C53DFEC0A484C250014E966 /* CTRTextureLightMap2_M4.cpp */, - 4C53DFED0A484C250014E966 /* CTRTextureWire2.cpp */, - ); - name = Software; - sourceTree = "<group>"; - }; - 09293C2B0ED31FF8003B8C9C /* libpng */ = { - isa = PBXGroup; - children = ( - 09293C2C0ED32029003B8C9C /* png.c */, - 09293C2D0ED32029003B8C9C /* pngerror.c */, - 09293C2E0ED32029003B8C9C /* pnggccrd.c */, - 09293C2F0ED32029003B8C9C /* pngget.c */, - 09293C300ED32029003B8C9C /* pngmem.c */, - 09293C310ED32029003B8C9C /* pngpread.c */, - 09293C320ED32029003B8C9C /* pngread.c */, - 09293C330ED32029003B8C9C /* pngrio.c */, - 09293C340ED32029003B8C9C /* pngrtran.c */, - 09293C350ED32029003B8C9C /* pngrutil.c */, - 09293C360ED32029003B8C9C /* pngset.c */, - 09293C380ED32029003B8C9C /* pngtrans.c */, - 09293C3A0ED32029003B8C9C /* pngwio.c */, - 09293C3B0ED32029003B8C9C /* pngwrite.c */, - 09293C3C0ED32029003B8C9C /* pngwtran.c */, - 09293C3D0ED32029003B8C9C /* pngwutil.c */, - ); - name = libpng; - sourceTree = "<group>"; - }; - 0946CC980EC99B8B00D945A5 /* 19.MouseAndJoystick */ = { - isa = PBXGroup; - children = ( - 0946CCCA0EC99C6E00D945A5 /* main.cpp */, - ); - name = 19.MouseAndJoystick; - sourceTree = "<group>"; - }; - 09F6492D0D2CE017001E0599 /* 15.LoadIrrFile */ = { - isa = PBXGroup; - children = ( - 09F6492E0D2CE038001E0599 /* main.cpp */, - ); - name = 15.LoadIrrFile; - sourceTree = "<group>"; - }; - 09F649530D2CE1EB001E0599 /* 16.Quake3Shader */ = { - isa = PBXGroup; - children = ( - 09F649730D2CE2D0001E0599 /* main.cpp */, - ); - name = 16.Quake3Shader; - sourceTree = "<group>"; - }; - 34EF91900F65F9AD000B5651 /* loader */ = { - isa = PBXGroup; - children = ( - 4CFA7BDC0A88735900B03626 /* CImageLoaderBMP.cpp */, - 4CFA7BDD0A88735900B03626 /* CImageLoaderBMP.h */, - 4C53DF5C0A484C230014E966 /* CImageLoaderJPG.cpp */, - 4C53DF5D0A484C230014E966 /* CImageLoaderJPG.h */, - 4C53DF5E0A484C230014E966 /* CImageLoaderPCX.cpp */, - 4C53DF5F0A484C230014E966 /* CImageLoaderPCX.h */, - 4C53DF600A484C230014E966 /* CImageLoaderPNG.cpp */, - 4C53DF610A484C230014E966 /* CImageLoaderPNG.h */, - 096840270D0F1A2300333EFD /* CImageLoaderPPM.cpp */, - 096840280D0F1A2300333EFD /* CImageLoaderPPM.h */, - 4C53DF620A484C230014E966 /* CImageLoaderPSD.cpp */, - 4C53DF630A484C230014E966 /* CImageLoaderPSD.h */, - 34EF91D00F65FCA6000B5651 /* CImageLoaderRGB.h */, - 34EF91D10F65FCA6000B5651 /* CImageLoaderRGB.cpp */, - 4C53DF640A484C230014E966 /* CImageLoaderTGA.cpp */, - 4C53DF650A484C230014E966 /* CImageLoaderTGA.h */, - 0910B9DC0D1F5D4100D46B04 /* CImageLoaderWAL.cpp */, - 0910B9DD0D1F5D4100D46B04 /* CImageLoaderWAL.h */, - ); - name = loader; - sourceTree = "<group>"; - }; - 34FFD9C50F6600A900420884 /* libraries */ = { - isa = PBXGroup; - children = ( - 4C53E1710A484C2C0014E966 /* zlib */, - 4C53E0130A484C250014E966 /* jpeglib */, - 09293C2B0ED31FF8003B8C9C /* libpng */, - ); - name = libraries; - sourceTree = "<group>"; - }; - 34FFD9C60F6600DA00420884 /* device */ = { - isa = PBXGroup; - children = ( - 4C53E14A0A484C2C0014E966 /* MacOSX */, - 34EC243A0F59272E0037BC3A /* CIrrDeviceConsole.h */, - 34EC243B0F59272E0037BC3A /* CIrrDeviceConsole.cpp */, - 4C53DF660A484C230014E966 /* CIrrDeviceLinux.cpp */, - 4C53DF670A484C230014E966 /* CIrrDeviceLinux.h */, - 5DD480C40C7DA66800728AA9 /* CIrrDeviceSDL.cpp */, - 5DD480C30C7DA66800728AA9 /* CIrrDeviceSDL.h */, - 4C53DF680A484C230014E966 /* CIrrDeviceStub.cpp */, - 4C53DF690A484C230014E966 /* CIrrDeviceStub.h */, - 4C53DF6A0A484C230014E966 /* CIrrDeviceWin32.cpp */, - 4C53DF6B0A484C230014E966 /* CIrrDeviceWin32.h */, - ); - name = device; - sourceTree = "<group>"; - }; - 34FFD9C70F66011C00420884 /* archive */ = { - isa = PBXGroup; - children = ( - 344FD4A41039E98C0045FD3F /* CMountPointReader.cpp */, - 344FD4A51039E98C0045FD3F /* CMountPointReader.h */, - 3430E4D41022C391006271FD /* CTarReader.h */, - 3430E4D51022C391006271FD /* CTarReader.cpp */, - 4C53E0030A484C250014E966 /* CZipReader.cpp */, - 4C53E0040A484C250014E966 /* CZipReader.h */, - 4C43EEBE0A74A5C800F942FC /* CPakReader.cpp */, - 4C43EEBF0A74A5C800F942FC /* CPakReader.h */, - ); - name = archive; - sourceTree = "<group>"; - }; - 34FFD9C80F66012D00420884 /* attributes */ = { - isa = PBXGroup; - children = ( - 4C53DEEF0A484C220014E966 /* CAttributeImpl.h */, - 4C53DEF00A484C220014E966 /* CAttributes.cpp */, - 4C53DEF10A484C220014E966 /* CAttributes.h */, - ); - name = attributes; - sourceTree = "<group>"; - }; - 34FFD9C90F66014200420884 /* file */ = { - isa = PBXGroup; - children = ( - 4C53DFA70A484C240014E966 /* CReadFile.cpp */, - 4C53DFA80A484C240014E966 /* CReadFile.h */, - 4C53DFF20A484C250014E966 /* CWriteFile.cpp */, - 4C53DFF30A484C250014E966 /* CWriteFile.h */, - 4C53DF6E0A484C230014E966 /* CLimitReadFile.cpp */, - 4C53DF6F0A484C230014E966 /* CLimitReadFile.h */, - 3484C4FB0F48D4CB00C81F60 /* CMemoryFile.h */, - 3484C4FC0F48D4CB00C81F60 /* CMemoryFile.cpp */, - ); - name = file; - sourceTree = "<group>"; - }; - 34FFD9CA0F66018500420884 /* xml */ = { - isa = PBXGroup; - children = ( - 4C53DFFA0A484C250014E966 /* CXMLReader.cpp */, - 4C53DFFB0A484C250014E966 /* CXMLReader.h */, - 4C53DFFC0A484C250014E966 /* CXMLReaderImpl.h */, - 4C53DFFD0A484C250014E966 /* CXMLWriter.cpp */, - 4C53DFFE0A484C250014E966 /* CXMLWriter.h */, - 4C53E00E0A484C250014E966 /* irrXML.cpp */, - ); - name = xml; - sourceTree = "<group>"; - }; - 34FFD9CB0F6601AC00420884 /* element */ = { - isa = PBXGroup; - children = ( - 4C53DF2E0A484C230014E966 /* CGUIButton.cpp */, - 4C53DF2F0A484C230014E966 /* CGUIButton.h */, - 4C53DF300A484C230014E966 /* CGUICheckBox.cpp */, - 4C53DF310A484C230014E966 /* CGUICheckBox.h */, - 5DD4805E0C7D947B00728AA9 /* CGUIColorSelectDialog.cpp */, - 5DD4805F0C7D947B00728AA9 /* CGUIColorSelectDialog.h */, - 4C53DF320A484C230014E966 /* CGUIComboBox.cpp */, - 4C53DF330A484C230014E966 /* CGUIComboBox.h */, - 4C53DF340A484C230014E966 /* CGUIContextMenu.cpp */, - 4C53DF350A484C230014E966 /* CGUIContextMenu.h */, - 4C53DF360A484C230014E966 /* CGUIEditBox.cpp */, - 4C53DF370A484C230014E966 /* CGUIEditBox.h */, - 4C53DF380A484C230014E966 /* CGUIEnvironment.cpp */, - 4C53DF390A484C230014E966 /* CGUIEnvironment.h */, - 4C53DF3A0A484C230014E966 /* CGUIFileOpenDialog.cpp */, - 4C53DF3B0A484C230014E966 /* CGUIFileOpenDialog.h */, - 4C53DF3E0A484C230014E966 /* CGUIImage.cpp */, - 4C53DF3F0A484C230014E966 /* CGUIImage.h */, - 3484C4DF0F48D1B000C81F60 /* CGUIImageList.h */, - 3484C4E00F48D1B000C81F60 /* CGUIImageList.cpp */, - 4C53DF400A484C230014E966 /* CGUIInOutFader.cpp */, - 4C53DF410A484C230014E966 /* CGUIInOutFader.h */, - 4C53DF420A484C230014E966 /* CGUIListBox.cpp */, - 4C53DF430A484C230014E966 /* CGUIListBox.h */, - 4C53DF440A484C230014E966 /* CGUIMenu.cpp */, - 4C53DF450A484C230014E966 /* CGUIMenu.h */, - 4C53DF460A484C230014E966 /* CGUIMeshViewer.cpp */, - 4C53DF470A484C230014E966 /* CGUIMeshViewer.h */, - 4C53DF480A484C230014E966 /* CGUIMessageBox.cpp */, - 4C53DF490A484C230014E966 /* CGUIMessageBox.h */, - 4C53DF4A0A484C230014E966 /* CGUIModalScreen.cpp */, - 4C53DF4B0A484C230014E966 /* CGUIModalScreen.h */, - 4C53DF4C0A484C230014E966 /* CGUIScrollBar.cpp */, - 4C53DF4D0A484C230014E966 /* CGUIScrollBar.h */, - 5DD480600C7D947B00728AA9 /* CGUISpinBox.cpp */, - 5DD480610C7D947B00728AA9 /* CGUISpinBox.h */, - 4C53DF500A484C230014E966 /* CGUIStaticText.cpp */, - 4C53DF510A484C230014E966 /* CGUIStaticText.h */, - 4C53DF520A484C230014E966 /* CGUITabControl.cpp */, - 4C53DF530A484C230014E966 /* CGUITabControl.h */, - 0910B9DA0D1F5D4100D46B04 /* CGUITable.cpp */, - 0910B9DB0D1F5D4100D46B04 /* CGUITable.h */, - 4C53DF540A484C230014E966 /* CGUIToolBar.cpp */, - 4C53DF550A484C230014E966 /* CGUIToolBar.h */, - 3484C4EC0F48D3A100C81F60 /* CGUITreeView.h */, - 3484C4ED0F48D3A100C81F60 /* CGUITreeView.cpp */, - 4C53DF560A484C230014E966 /* CGUIWindow.cpp */, - 4C53DF570A484C230014E966 /* CGUIWindow.h */, - ); - name = element; - sourceTree = "<group>"; - }; - 4C00546D0A48470500C844C2 /* examples */ = { - isa = PBXGroup; - children = ( - 4C00546E0A48470500C844C2 /* 01.HelloWorld */, - 4C0054740A48470500C844C2 /* 02.Quake3Map */, - 4C00547A0A48470500C844C2 /* 03.CustomSceneNode */, - 4C0054800A48470500C844C2 /* 04.Movement */, - 4C0054860A48470500C844C2 /* 05.UserInterface */, - 4C00548C0A48470500C844C2 /* 06.2DGraphics */, - 4C0054920A48470500C844C2 /* 07.Collision */, - 4C0054980A48470500C844C2 /* 08.SpecialFX */, - 4C00549E0A48470500C844C2 /* 09.Meshviewer */, - 4C0054A70A48470500C844C2 /* 10.Shaders */, - 4C0054AD0A48470500C844C2 /* 11.PerPixelLighting */, - 4C0054B30A48470500C844C2 /* 12.TerrainRendering */, - 4C0054B90A48470500C844C2 /* 13.RenderToTexture */, - 09F6492D0D2CE017001E0599 /* 15.LoadIrrFile */, - 09F649530D2CE1EB001E0599 /* 16.Quake3Shader */, - 0946CC980EC99B8B00D945A5 /* 19.MouseAndJoystick */, - 4C0054C40A48470500C844C2 /* Demo */, - ); - name = examples; - path = ../../../examples; - sourceTree = SOURCE_ROOT; - }; - 4C00546E0A48470500C844C2 /* 01.HelloWorld */ = { - isa = PBXGroup; - children = ( - 4C0054710A48470500C844C2 /* main.cpp */, - ); - path = 01.HelloWorld; - sourceTree = "<group>"; - }; - 4C0054740A48470500C844C2 /* 02.Quake3Map */ = { - isa = PBXGroup; - children = ( - 4C0054770A48470500C844C2 /* main.cpp */, - ); - path = 02.Quake3Map; - sourceTree = "<group>"; - }; - 4C00547A0A48470500C844C2 /* 03.CustomSceneNode */ = { - isa = PBXGroup; - children = ( - 4C00547D0A48470500C844C2 /* main.cpp */, - ); - path = 03.CustomSceneNode; - sourceTree = "<group>"; - }; - 4C0054800A48470500C844C2 /* 04.Movement */ = { - isa = PBXGroup; - children = ( - 4C0054830A48470500C844C2 /* main.cpp */, - ); - path = 04.Movement; - sourceTree = "<group>"; - }; - 4C0054860A48470500C844C2 /* 05.UserInterface */ = { - isa = PBXGroup; - children = ( - 4C0054890A48470500C844C2 /* main.cpp */, - ); - path = 05.UserInterface; - sourceTree = "<group>"; - }; - 4C00548C0A48470500C844C2 /* 06.2DGraphics */ = { - isa = PBXGroup; - children = ( - 4C00548F0A48470500C844C2 /* main.cpp */, - ); - path = 06.2DGraphics; - sourceTree = "<group>"; - }; - 4C0054920A48470500C844C2 /* 07.Collision */ = { - isa = PBXGroup; - children = ( - 4C0054950A48470500C844C2 /* main.cpp */, - ); - path = 07.Collision; - sourceTree = "<group>"; - }; - 4C0054980A48470500C844C2 /* 08.SpecialFX */ = { - isa = PBXGroup; - children = ( - 4C00549B0A48470500C844C2 /* main.cpp */, - ); - path = 08.SpecialFX; - sourceTree = "<group>"; - }; - 4C00549E0A48470500C844C2 /* 09.Meshviewer */ = { - isa = PBXGroup; - children = ( - 4C0054A30A48470500C844C2 /* main.cpp */, - ); - path = 09.Meshviewer; - sourceTree = "<group>"; - }; - 4C0054A70A48470500C844C2 /* 10.Shaders */ = { - isa = PBXGroup; - children = ( - 4C0054AA0A48470500C844C2 /* main.cpp */, - ); - path = 10.Shaders; - sourceTree = "<group>"; - }; - 4C0054AD0A48470500C844C2 /* 11.PerPixelLighting */ = { - isa = PBXGroup; - children = ( - 4C0054B00A48470500C844C2 /* main.cpp */, - ); - path = 11.PerPixelLighting; - sourceTree = "<group>"; - }; - 4C0054B30A48470500C844C2 /* 12.TerrainRendering */ = { - isa = PBXGroup; - children = ( - 4C0054B60A48470500C844C2 /* main.cpp */, - ); - path = 12.TerrainRendering; - sourceTree = "<group>"; - }; - 4C0054B90A48470500C844C2 /* 13.RenderToTexture */ = { - isa = PBXGroup; - children = ( - 4C0054BC0A48470500C844C2 /* main.cpp */, - ); - path = 13.RenderToTexture; - sourceTree = "<group>"; - }; - 4C0054C40A48470500C844C2 /* Demo */ = { - isa = PBXGroup; - children = ( - 4C0054C50A48470500C844C2 /* CDemo.cpp */, - 4C0054C60A48470500C844C2 /* CDemo.h */, - 4C0054C70A48470500C844C2 /* CMainMenu.cpp */, - 4C0054C80A48470500C844C2 /* CMainMenu.h */, - 4C0054CA0A48470500C844C2 /* main.cpp */, - ); - path = Demo; - sourceTree = "<group>"; - }; - 4C53DEE50A484C220014E966 /* Irrlicht */ = { - isa = PBXGroup; - children = ( - 34FFD9C50F6600A900420884 /* libraries */, - 4C6DC9960A486B110017A6E5 /* Engine */, - ); - name = Irrlicht; - path = ..; - sourceTree = SOURCE_ROOT; - }; - 4C53E0130A484C250014E966 /* jpeglib */ = { - isa = PBXGroup; - children = ( - 4C53E6F10A485CD80014E966 /* jcapimin.c */, - 4C53E6F20A485CD80014E966 /* jcapistd.c */, - 4C53E6F30A485CD80014E966 /* jccoefct.c */, - 4C53E6F40A485CD80014E966 /* jccolor.c */, - 4C53E6F50A485CD80014E966 /* jcdctmgr.c */, - 4C53E6F60A485CD80014E966 /* jchuff.c */, - 4C53E6F80A485CD80014E966 /* jcinit.c */, - 4C53E6F90A485CD80014E966 /* jcmainct.c */, - 4C53E6FA0A485CD80014E966 /* jcmarker.c */, - 4C53E6FB0A485CD80014E966 /* jcmaster.c */, - 4C53E6FC0A485CD80014E966 /* jcomapi.c */, - 4C53E70A0A485CD80014E966 /* jcparam.c */, - 4C53E70B0A485CD80014E966 /* jcphuff.c */, - 4C53E70C0A485CD80014E966 /* jcprepct.c */, - 4C53E70D0A485CD80014E966 /* jcsample.c */, - 4C53E70E0A485CD80014E966 /* jctrans.c */, - 4C53E70F0A485CD80014E966 /* jdapimin.c */, - 4C53E7100A485CD80014E966 /* jdapistd.c */, - 4C53E7110A485CD80014E966 /* jdatadst.c */, - 4C53E7120A485CD80014E966 /* jdatasrc.c */, - 4C53E7130A485CD80014E966 /* jdcoefct.c */, - 4C53E7140A485CD80014E966 /* jdcolor.c */, - 4C53E7160A485CD80014E966 /* jddctmgr.c */, - 4C53E7170A485CD80014E966 /* jdhuff.c */, - 4C53E7190A485CD80014E966 /* jdinput.c */, - 4C53E71A0A485CD80014E966 /* jdmainct.c */, - 4C53E71B0A485CD80014E966 /* jdmarker.c */, - 4C53E71C0A485CD80014E966 /* jdmaster.c */, - 4C53E71D0A485CD80014E966 /* jdmerge.c */, - 4C53E71E0A485CD80014E966 /* jdphuff.c */, - 4C53E71F0A485CD80014E966 /* jdpostct.c */, - 4C53E7200A485CD80014E966 /* jdsample.c */, - 4C53E7210A485CD80014E966 /* jdtrans.c */, - 4C53E7220A485CD80014E966 /* jerror.c */, - 4C53E7240A485CD80014E966 /* jfdctflt.c */, - 4C53E7250A485CD80014E966 /* jfdctfst.c */, - 4C53E7260A485CD80014E966 /* jfdctint.c */, - 4C53E7270A485CD80014E966 /* jidctflt.c */, - 4C53E7280A485CD80014E966 /* jidctfst.c */, - 4C53E7290A485CD80014E966 /* jidctint.c */, - 4C53E72A0A485CD80014E966 /* jidctred.c */, - 4C53E7300A485CD80014E966 /* jmemmgr.c */, - 4C53E7320A485CD80014E966 /* jmemnobs.c */, - 4C53E7390A485CD80014E966 /* jquant1.c */, - 4C53E73A0A485CD80014E966 /* jquant2.c */, - 4C53E73B0A485CD80014E966 /* jutils.c */, - 4C53E7540A485CD90014E966 /* rdbmp.c */, - 4C53E7550A485CD90014E966 /* rdcolmap.c */, - 4C53E7560A485CD90014E966 /* rdgif.c */, - 4C53E7590A485CD90014E966 /* rdppm.c */, - 4C53E75A0A485CD90014E966 /* rdrle.c */, - 4C53E75B0A485CD90014E966 /* rdswitch.c */, - 4C53E75C0A485CD90014E966 /* rdtarga.c */, - 4C53E7660A485CD90014E966 /* transupp.c */, - 4C53E76A0A485CD90014E966 /* wrbmp.c */, - 4C53E76B0A485CD90014E966 /* wrgif.c */, - 4C53E76E0A485CD90014E966 /* wrppm.c */, - 4C53E76F0A485CD90014E966 /* wrrle.c */, - 4C53E7700A485CD90014E966 /* wrtarga.c */, - ); - path = jpeglib; - sourceTree = "<group>"; - }; - 4C53E14A0A484C2C0014E966 /* MacOSX */ = { - isa = PBXGroup; - children = ( - 4C53E38E0A4855BA0014E966 /* DemoApp-Info.plist */, - 4C53E14C0A484C2C0014E966 /* AppDelegate.h */, - 4C53E14D0A484C2C0014E966 /* AppDelegate.mm */, - 4C53E14E0A484C2C0014E966 /* build */, - 4C53E15E0A484C2C0014E966 /* CIrrDeviceMacOSX.h */, - 4C53E15F0A484C2C0014E966 /* CIrrDeviceMacOSX.mm */, - 4C53E1640A484C2C0014E966 /* MacOSX_Prefix.pch */, - 4C53E1650A484C2C0014E966 /* MainMenu.nib */, - 4C53E1660A484C2C0014E966 /* OSXClipboard.h */, - 4C53E1670A484C2C0014E966 /* OSXClipboard.mm */, - ); - path = MacOSX; - sourceTree = "<group>"; - }; - 4C53E14E0A484C2C0014E966 /* build */ = { - isa = PBXGroup; - children = ( - 4C53E14F0A484C2C0014E966 /* MacOSX.build */, - ); - path = build; - sourceTree = "<group>"; - }; - 4C53E14F0A484C2C0014E966 /* MacOSX.build */ = { - isa = PBXGroup; - children = ( - 4C53E1500A484C2C0014E966 /* MacOSX.pbxindex */, - ); - path = MacOSX.build; - sourceTree = "<group>"; - }; - 4C53E1500A484C2C0014E966 /* MacOSX.pbxindex */ = { - isa = PBXGroup; - children = ( - 4C53E1590A484C2C0014E966 /* strings.pbxstrings */, - ); - path = MacOSX.pbxindex; - sourceTree = "<group>"; - }; - 4C53E1590A484C2C0014E966 /* strings.pbxstrings */ = { - isa = PBXGroup; - children = ( - ); - path = strings.pbxstrings; - sourceTree = "<group>"; - }; - 4C53E1710A484C2C0014E966 /* zlib */ = { - isa = PBXGroup; - children = ( - 4C6DC9B60A48715A0017A6E5 /* inflate.c */, - 4C53E1720A484C2C0014E966 /* adler32.c */, - 4C53E1750A484C2C0014E966 /* compress.c */, - 4C53E1770A484C2C0014E966 /* crc32.c */, - 4C53E1790A484C2C0014E966 /* deflate.c */, - 4C53E17D0A484C2C0014E966 /* gzio.c */, - 4C53E1800A484C2C0014E966 /* inffast.c */, - 4C53E1850A484C2C0014E966 /* inftrees.c */, - 4C53E18B0A484C2C0014E966 /* trees.c */, - 4C53E18D0A484C2C0014E966 /* uncompr.c */, - 4C53E1920A484C2C0014E966 /* zutil.c */, - ); - path = zlib; - sourceTree = "<group>"; - }; - 4C53E24C0A484FED0014E966 /* Products */ = { - isa = PBXGroup; - children = ( - 0946CCB40EC99BBE00D945A5 /* MouseAndJoystick_dbg.app */, - 09022C620EA0E97F00CD54EE /* GUIEditor_dbg.app */, - 4C53E24D0A4850120014E966 /* libIrrlicht.a */, - 4C53E2520A4850550014E966 /* Quake3Map_dbg.app */, - 4CA25B980A485D9800B4E469 /* CustomSceneNode_dbg.app */, - 4CA25BA40A485D9800B4E469 /* Movement_dbg.app */, - 4CA25B9E0A485D9800B4E469 /* UserInterface_dbg.app */, - 4CA25BAC0A485D9800B4E469 /* 2DGraphics_dbg.app */, - 4CA25BAE0A485D9800B4E469 /* Collision_dbg.app */, - 4CA25BA80A485D9800B4E469 /* SpecialFx_dbg.app */, - 4CA25B9A0A485D9800B4E469 /* MeshViewer_dbg.app */, - 4CA25BA60A485D9800B4E469 /* Shaders_dbg.app */, - 4CA25BA00A485D9800B4E469 /* PerPixelLighting_dbg.app */, - 4CA25B9C0A485D9800B4E469 /* RenderToTexture_dbg.app */, - 4CA25BAA0A485D9800B4E469 /* TerrainRendering_dbg.app */, - 4CA25BA20A485D9800B4E469 /* Demo_dbg.app */, - 09F6493E0D2CE03E001E0599 /* LoadIrrFile_dbg.app */, - 09F649650D2CE206001E0599 /* Quake3Shader_dbg.app */, - 09F649030D2CDED9001E0599 /* HelloWorld_dbg.app */, - ); - name = Products; - sourceTree = "<group>"; - }; - 4C53E2540A48505D0014E966 /* Libraries */ = { - isa = PBXGroup; - children = ( - 0930CE550EC39F4500D63866 /* IOKit.framework */, - 0925113D0D744ADE006784D9 /* Carbon.framework */, - 4C53E26D0A4850D60014E966 /* Cocoa.framework */, - 4C53E26E0A4850D60014E966 /* OpenGL.framework */, - ); - name = Libraries; - sourceTree = "<group>"; - }; - 4C6DC9960A486B110017A6E5 /* Engine */ = { - isa = PBXGroup; - children = ( - 0910BA810D1F6BB800D46B04 /* gui */, - 0910BA820D1F6C3900D46B04 /* io */, - 0910BA830D1F6CA600D46B04 /* irr */, - 0910BA840D1F6D0200D46B04 /* scene */, - 0910BA8B0D1F71D600D46B04 /* video */, - ); - name = Engine; - sourceTree = "<group>"; - }; - 4CFA7C090A88742800B03626 /* include */ = { - isa = PBXGroup; - children = ( - 0910BA4E0D1F652100D46B04 /* core */, - 0910BA4D0D1F64D000D46B04 /* gui */, - 0910BA4F0D1F65A300D46B04 /* io */, - 0910BA500D1F660300D46B04 /* scene */, - 0910BA800D1F6ADA00D46B04 /* video */, - 0910BA1D0D1F64B300D46B04 /* IReferenceCounted.h */, - 4CFA7C0C0A88742800B03626 /* EDriverTypes.h */, - 4CFA7C1D0A88742900B03626 /* IEventReceiver.h */, - 4CFA7C420A88742900B03626 /* IOSOperator.h */, - 4CFA7C380A88742900B03626 /* ILogger.h */, - 4CFA7C4A0A88742900B03626 /* IrrCompileConfig.h */, - 4CFA7C4B0A88742900B03626 /* irrlicht.h */, - 4CFA7C4C0A88742900B03626 /* IrrlichtDevice.h */, - 4CFA7C740A88742900B03626 /* SIrrCreationParameters.h */, - ); - name = include; - path = ../../../include; - sourceTree = SOURCE_ROOT; - }; -/* End PBXGroup section */ - -/* Begin PBXHeadersBuildPhase section */ - D2AAC07A0554694100DB518D /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - 5DD4804F0C7D91DF00728AA9 /* CDepthBuffer.h in Headers */, - 5DD480530C7D936700728AA9 /* IBurningShader.h in Headers */, - 5DD480550C7D93AB00728AA9 /* IDepthBuffer.h in Headers */, - 5DD4805B0C7D945800728AA9 /* CAnimatedMeshMD3.h in Headers */, - 5DD4805D0C7D945800728AA9 /* CDefaultGUIElementFactory.h in Headers */, - 5DD480650C7D947B00728AA9 /* CGUIColorSelectDialog.h in Headers */, - 5DD480670C7D947B00728AA9 /* CGUISpinBox.h in Headers */, - 5DD480690C7D947B00728AA9 /* CGUISpriteBank.h in Headers */, - 5DD480720C7D94AC00728AA9 /* CQuake3ShaderSceneNode.h in Headers */, - 5DD480770C7D94AC00728AA9 /* glxext.h in Headers */, - 5DD480C70C7DA66800728AA9 /* COpenGLExtensionHandler.h in Headers */, - 5DD480C80C7DA66800728AA9 /* CMD3MeshFileLoader.h in Headers */, - 5DD480C90C7DA66800728AA9 /* CIrrDeviceSDL.h in Headers */, - 096840480D0F1A2300333EFD /* CB3DMeshFileLoader.h in Headers */, - 0968404A0D0F1A2300333EFD /* CBoneSceneNode.h in Headers */, - 0968404C0D0F1A2300333EFD /* CBSPMeshFileLoader.h in Headers */, - 0968404F0D0F1A2300333EFD /* CColladaMeshWriter.h in Headers */, - 096840510D0F1A2300333EFD /* CImageLoaderPPM.h in Headers */, - 096840550D0F1A2300333EFD /* CIrrMeshFileLoader.h in Headers */, - 096840570D0F1A2300333EFD /* CIrrMeshWriter.h in Headers */, - 096840590D0F1A2300333EFD /* CMD2MeshFileLoader.h in Headers */, - 0968405B0D0F1A2300333EFD /* CMS3DMeshFileLoader.h in Headers */, - 0968405D0D0F1A2300333EFD /* CParticleAnimatedMeshSceneNodeEmitter.h in Headers */, - 0968405F0D0F1A2300333EFD /* CParticleAttractionAffector.h in Headers */, - 096840610D0F1A2300333EFD /* CParticleCylinderEmitter.h in Headers */, - 096840630D0F1A2300333EFD /* CParticleMeshEmitter.h in Headers */, - 096840650D0F1A2300333EFD /* CParticleRingEmitter.h in Headers */, - 096840670D0F1A2300333EFD /* CParticleRotationAffector.h in Headers */, - 096840690D0F1A2300333EFD /* CParticleSphereEmitter.h in Headers */, - 0968406B0D0F1A2300333EFD /* CSkinnedMesh.h in Headers */, - 0968406D0D0F1A2300333EFD /* CSTLMeshFileLoader.h in Headers */, - 0968406F0D0F1A2300333EFD /* CSTLMeshWriter.h in Headers */, - 0910B9E00D1F5D4100D46B04 /* CGUITable.h in Headers */, - 0910B9E20D1F5D4100D46B04 /* CImageLoaderWAL.h in Headers */, - 0910BA240D1F64B300D46B04 /* CMeshBuffer.h in Headers */, - 0910BA250D1F64B300D46B04 /* coreutil.h in Headers */, - 0910BA260D1F64B300D46B04 /* ECullingTypes.h in Headers */, - 0910BA270D1F64B300D46B04 /* EDebugSceneTypes.h in Headers */, - 0910BA280D1F64B300D46B04 /* EDriverFeatures.h in Headers */, - 0910BA290D1F64B300D46B04 /* EGUIAlignment.h in Headers */, - 0910BA2A0D1F64B300D46B04 /* EHardwareBufferFlags.h in Headers */, - 0910BA2B0D1F64B300D46B04 /* EMaterialFlags.h in Headers */, - 0910BA2C0D1F64B300D46B04 /* EMaterialTypes.h in Headers */, - 0910BA2D0D1F64B300D46B04 /* EMeshWriterEnums.h in Headers */, - 0910BA2E0D1F64B300D46B04 /* EMessageBoxFlags.h in Headers */, - 0910BA2F0D1F64B300D46B04 /* ETerrainElements.h in Headers */, - 0910BA300D1F64B300D46B04 /* IAnimatedMeshMD3.h in Headers */, - 0910BA310D1F64B300D46B04 /* IBoneSceneNode.h in Headers */, - 0910BA320D1F64B300D46B04 /* IGUIColorSelectDialog.h in Headers */, - 0910BA330D1F64B300D46B04 /* IGUIElementFactory.h in Headers */, - 0910BA340D1F64B300D46B04 /* IGUIFontBitmap.h in Headers */, - 0910BA350D1F64B300D46B04 /* IGUISpinBox.h in Headers */, - 0910BA360D1F64B300D46B04 /* IGUISpriteBank.h in Headers */, - 0910BA370D1F64B300D46B04 /* IGUITable.h in Headers */, - 0910BA380D1F64B300D46B04 /* IMeshWriter.h in Headers */, - 0910BA390D1F64B300D46B04 /* IParticleAnimatedMeshSceneNodeEmitter.h in Headers */, - 0910BA3A0D1F64B300D46B04 /* IParticleAttractionAffector.h in Headers */, - 0910BA3B0D1F64B300D46B04 /* IParticleBoxEmitter.h in Headers */, - 0910BA3C0D1F64B300D46B04 /* IParticleCylinderEmitter.h in Headers */, - 0910BA3D0D1F64B300D46B04 /* IParticleFadeOutAffector.h in Headers */, - 0910BA3E0D1F64B300D46B04 /* IParticleGravityAffector.h in Headers */, - 0910BA3F0D1F64B300D46B04 /* IParticleMeshEmitter.h in Headers */, - 0910BA400D1F64B300D46B04 /* IParticleRingEmitter.h in Headers */, - 0910BA410D1F64B300D46B04 /* IParticleRotationAffector.h in Headers */, - 0910BA420D1F64B300D46B04 /* IParticleSphereEmitter.h in Headers */, - 0910BA430D1F64B300D46B04 /* IQ3Shader.h in Headers */, - 0910BA440D1F64B300D46B04 /* IReferenceCounted.h in Headers */, - 0910BA450D1F64B300D46B04 /* irrMap.h in Headers */, - 0910BA460D1F64B300D46B04 /* ISkinnedMesh.h in Headers */, - 0910BA470D1F64B300D46B04 /* SMaterialLayer.h in Headers */, - 0910BA480D1F64B300D46B04 /* SSharedMeshBuffer.h in Headers */, - 0910BA490D1F64B300D46B04 /* SSkinMeshBuffer.h in Headers */, - 0910BA4A0D1F64B300D46B04 /* SViewFrustum.h in Headers */, - 090FBC830D31085E0076D847 /* CVolumeLightSceneNode.h in Headers */, - 09C638730D4F1A69000B6A18 /* CLWOMeshFileLoader.h in Headers */, - 093973C10E0458B200E0C987 /* CSceneNodeAnimatorCameraFPS.h in Headers */, - 093973C30E0458B200E0C987 /* CSceneNodeAnimatorCameraMaya.h in Headers */, - 096F8E3E0EA2EFBA00907EC5 /* COBJMeshWriter.h in Headers */, - 096CC0E10ECE65B500C81DC7 /* CParticleScaleAffector.h in Headers */, - 3484C4E10F48D1B000C81F60 /* CGUIImageList.h in Headers */, - 3484C4EE0F48D3A100C81F60 /* CGUITreeView.h in Headers */, - 3484C4FD0F48D4CB00C81F60 /* CMemoryFile.h in Headers */, - 34EC243C0F59272E0037BC3A /* CIrrDeviceConsole.h in Headers */, - 34EF91D20F65FCA6000B5651 /* CImageLoaderRGB.h in Headers */, - 34EF91D70F65FCF6000B5651 /* CPLYMeshFileLoader.h in Headers */, - 34EF91DC0F65FD14000B5651 /* CPLYMeshWriter.h in Headers */, - 3430E4D61022C391006271FD /* CTarReader.h in Headers */, - 344FD4A71039E98C0045FD3F /* CMountPointReader.h in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXHeadersBuildPhase section */ - -/* Begin PBXNativeTarget section */ - 09022C520EA0E97F00CD54EE /* GUIEditor */ = { - isa = PBXNativeTarget; - buildConfigurationList = 09022C5F0EA0E97F00CD54EE /* Build configuration list for PBXNativeTarget "GUIEditor" */; - buildPhases = ( - 09022C550EA0E97F00CD54EE /* Resources */, - 09022C580EA0E97F00CD54EE /* Sources */, - 09022C5A0EA0E97F00CD54EE /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - 09022C530EA0E97F00CD54EE /* PBXTargetDependency */, - ); - name = GUIEditor; - productName = DemoApp; - productReference = 09022C620EA0E97F00CD54EE /* GUIEditor_dbg.app */; - productType = "com.apple.product-type.application"; - }; - 0946CCA30EC99BBE00D945A5 /* 19.MouseAndJoystick */ = { - isa = PBXNativeTarget; - buildConfigurationList = 0946CCB10EC99BBE00D945A5 /* Build configuration list for PBXNativeTarget "19.MouseAndJoystick" */; - buildPhases = ( - 0946CCA60EC99BBE00D945A5 /* Resources */, - 0946CCA90EC99BBE00D945A5 /* Sources */, - 0946CCAB0EC99BBE00D945A5 /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - 0946CCA40EC99BBE00D945A5 /* PBXTargetDependency */, - ); - name = 19.MouseAndJoystick; - productName = DemoApp; - productReference = 0946CCB40EC99BBE00D945A5 /* MouseAndJoystick_dbg.app */; - productType = "com.apple.product-type.application"; - }; - 09F648F40D2CDED9001E0599 /* 01.HelloWorld */ = { - isa = PBXNativeTarget; - buildConfigurationList = 09F649000D2CDED9001E0599 /* Build configuration list for PBXNativeTarget "01.HelloWorld" */; - buildPhases = ( - 09F648F70D2CDED9001E0599 /* Resources */, - 09F648FA0D2CDED9001E0599 /* Sources */, - 09F648FC0D2CDED9001E0599 /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - 09F648F50D2CDED9001E0599 /* PBXTargetDependency */, - ); - name = 01.HelloWorld; - productName = DemoApp; - productReference = 09F649030D2CDED9001E0599 /* HelloWorld_dbg.app */; - productType = "com.apple.product-type.application"; - }; - 09F6492F0D2CE03E001E0599 /* 15.LoadIrrFile */ = { - isa = PBXNativeTarget; - buildConfigurationList = 09F6493B0D2CE03E001E0599 /* Build configuration list for PBXNativeTarget "15.LoadIrrFile" */; - buildPhases = ( - 09F649320D2CE03E001E0599 /* Resources */, - 09F649350D2CE03E001E0599 /* Sources */, - 09F649370D2CE03E001E0599 /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - 09F649300D2CE03E001E0599 /* PBXTargetDependency */, - ); - name = 15.LoadIrrFile; - productName = DemoApp; - productReference = 09F6493E0D2CE03E001E0599 /* LoadIrrFile_dbg.app */; - productType = "com.apple.product-type.application"; - }; - 09F649560D2CE206001E0599 /* 16.Quake3Shader */ = { - isa = PBXNativeTarget; - buildConfigurationList = 09F649620D2CE206001E0599 /* Build configuration list for PBXNativeTarget "16.Quake3Shader" */; - buildPhases = ( - 09F649590D2CE206001E0599 /* Resources */, - 09F6495C0D2CE206001E0599 /* Sources */, - 09F6495E0D2CE206001E0599 /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - 09F649570D2CE206001E0599 /* PBXTargetDependency */, - ); - name = 16.Quake3Shader; - productName = DemoApp; - productReference = 09F649650D2CE206001E0599 /* Quake3Shader_dbg.app */; - productType = "com.apple.product-type.application"; - }; - B81CFDFE097FD9F50057C06F /* 06.2DGraphics */ = { - isa = PBXNativeTarget; - buildConfigurationList = B81CFE0C097FD9F50057C06F /* Build configuration list for PBXNativeTarget "06.2DGraphics" */; - buildPhases = ( - B81CFE01097FD9F50057C06F /* Resources */, - B81CFE03097FD9F50057C06F /* Sources */, - B81CFE08097FD9F50057C06F /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - B81CFDFF097FD9F50057C06F /* PBXTargetDependency */, - ); - name = 06.2DGraphics; - productName = DemoApp; - productReference = 4CA25BAC0A485D9800B4E469 /* 2DGraphics_dbg.app */; - productType = "com.apple.product-type.application"; - }; - B81CFE82097FDDE20057C06F /* 07.Collision */ = { - isa = PBXNativeTarget; - buildConfigurationList = B81CFE8D097FDDE20057C06F /* Build configuration list for PBXNativeTarget "07.Collision" */; - buildPhases = ( - B81CFE85097FDDE20057C06F /* Resources */, - B81CFE87097FDDE20057C06F /* Sources */, - B81CFE89097FDDE20057C06F /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - B81CFE83097FDDE20057C06F /* PBXTargetDependency */, - ); - name = 07.Collision; - productName = DemoApp; - productReference = 4CA25BAE0A485D9800B4E469 /* Collision_dbg.app */; - productType = "com.apple.product-type.application"; - }; - B81CFEA4097FDE900057C06F /* 11.PerPixelLightning */ = { - isa = PBXNativeTarget; - buildConfigurationList = B81CFEAF097FDE900057C06F /* Build configuration list for PBXNativeTarget "11.PerPixelLightning" */; - buildPhases = ( - B81CFEA7097FDE900057C06F /* Resources */, - B81CFEA9097FDE900057C06F /* Sources */, - B81CFEAB097FDE900057C06F /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - B81CFEA5097FDE900057C06F /* PBXTargetDependency */, - ); - name = 11.PerPixelLightning; - productName = DemoApp; - productReference = 4CA25BA00A485D9800B4E469 /* PerPixelLighting_dbg.app */; - productType = "com.apple.product-type.application"; - }; - B81CFEC2097FDF020057C06F /* 12.TerrainRendering */ = { - isa = PBXNativeTarget; - buildConfigurationList = B81CFECD097FDF020057C06F /* Build configuration list for PBXNativeTarget "12.TerrainRendering" */; - buildPhases = ( - B81CFEC5097FDF020057C06F /* Resources */, - B81CFEC7097FDF020057C06F /* Sources */, - B81CFEC9097FDF020057C06F /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - B81CFEC3097FDF020057C06F /* PBXTargetDependency */, - ); - name = 12.TerrainRendering; - productName = DemoApp; - productReference = 4CA25BAA0A485D9800B4E469 /* TerrainRendering_dbg.app */; - productType = "com.apple.product-type.application"; - }; - B81CFEE8097FE05F0057C06F /* 08.SpecialFx */ = { - isa = PBXNativeTarget; - buildConfigurationList = B81CFEF3097FE05F0057C06F /* Build configuration list for PBXNativeTarget "08.SpecialFx" */; - buildPhases = ( - B81CFEEB097FE05F0057C06F /* Resources */, - B81CFEED097FE05F0057C06F /* Sources */, - B81CFEEF097FE05F0057C06F /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - B81CFEE9097FE05F0057C06F /* PBXTargetDependency */, - ); - name = 08.SpecialFx; - productName = DemoApp; - productReference = 4CA25BA80A485D9800B4E469 /* SpecialFx_dbg.app */; - productType = "com.apple.product-type.application"; - }; - B81CFF07097FE13E0057C06F /* 05.UserInterface */ = { - isa = PBXNativeTarget; - buildConfigurationList = B81CFF12097FE13E0057C06F /* Build configuration list for PBXNativeTarget "05.UserInterface" */; - buildPhases = ( - B81CFF0A097FE13E0057C06F /* Resources */, - B81CFF0C097FE13E0057C06F /* Sources */, - B81CFF0E097FE13E0057C06F /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - B81CFF08097FE13E0057C06F /* PBXTargetDependency */, - ); - name = 05.UserInterface; - productName = DemoApp; - productReference = 4CA25B9E0A485D9800B4E469 /* UserInterface_dbg.app */; - productType = "com.apple.product-type.application"; - }; - B81CFF1E097FE1E00057C06F /* 03.CustomSceneNode */ = { - isa = PBXNativeTarget; - buildConfigurationList = B81CFF29097FE1E00057C06F /* Build configuration list for PBXNativeTarget "03.CustomSceneNode" */; - buildPhases = ( - B81CFF21097FE1E00057C06F /* Resources */, - B81CFF23097FE1E00057C06F /* Sources */, - B81CFF25097FE1E00057C06F /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - B81CFF1F097FE1E00057C06F /* PBXTargetDependency */, - ); - name = 03.CustomSceneNode; - productName = DemoApp; - productReference = 4CA25B980A485D9800B4E469 /* CustomSceneNode_dbg.app */; - productType = "com.apple.product-type.application"; - }; - B81CFF33097FE25F0057C06F /* 02.Quake3Map */ = { - isa = PBXNativeTarget; - buildConfigurationList = B81CFF3E097FE25F0057C06F /* Build configuration list for PBXNativeTarget "02.Quake3Map" */; - buildPhases = ( - B81CFF36097FE25F0057C06F /* Resources */, - B81CFF38097FE25F0057C06F /* Sources */, - B81CFF3A097FE25F0057C06F /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - B81CFF34097FE25F0057C06F /* PBXTargetDependency */, - ); - name = 02.Quake3Map; - productName = DemoApp; - productReference = 4C53E2520A4850550014E966 /* Quake3Map_dbg.app */; - productType = "com.apple.product-type.application"; - }; - B81CFF4A097FE3050057C06F /* 10.Shaders */ = { - isa = PBXNativeTarget; - buildConfigurationList = B81CFF55097FE3050057C06F /* Build configuration list for PBXNativeTarget "10.Shaders" */; - buildPhases = ( - B81CFF4D097FE3050057C06F /* Resources */, - B81CFF4F097FE3050057C06F /* Sources */, - B81CFF51097FE3050057C06F /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - B81CFF4B097FE3050057C06F /* PBXTargetDependency */, - ); - name = 10.Shaders; - productName = DemoApp; - productReference = 4CA25BA60A485D9800B4E469 /* Shaders_dbg.app */; - productType = "com.apple.product-type.application"; - }; - B81CFF78097FE3DC0057C06F /* 04.Movement */ = { - isa = PBXNativeTarget; - buildConfigurationList = B81CFF83097FE3DC0057C06F /* Build configuration list for PBXNativeTarget "04.Movement" */; - buildPhases = ( - B81CFF7B097FE3DC0057C06F /* Resources */, - B81CFF7D097FE3DC0057C06F /* Sources */, - B81CFF7F097FE3DC0057C06F /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - B81CFF79097FE3DC0057C06F /* PBXTargetDependency */, - ); - name = 04.Movement; - productName = DemoApp; - productReference = 4CA25BA40A485D9800B4E469 /* Movement_dbg.app */; - productType = "com.apple.product-type.application"; - }; - B81CFF91097FE45E0057C06F /* 09.MeshViewer */ = { - isa = PBXNativeTarget; - buildConfigurationList = B81CFF9C097FE45E0057C06F /* Build configuration list for PBXNativeTarget "09.MeshViewer" */; - buildPhases = ( - B81CFF94097FE45E0057C06F /* Resources */, - B81CFF96097FE45E0057C06F /* Sources */, - B81CFF98097FE45E0057C06F /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - B81CFF92097FE45E0057C06F /* PBXTargetDependency */, - ); - name = 09.MeshViewer; - productName = DemoApp; - productReference = 4CA25B9A0A485D9800B4E469 /* MeshViewer_dbg.app */; - productType = "com.apple.product-type.application"; - }; - B81CFFAF097FE5F80057C06F /* 13.RenderToTexture */ = { - isa = PBXNativeTarget; - buildConfigurationList = B81CFFBA097FE5F80057C06F /* Build configuration list for PBXNativeTarget "13.RenderToTexture" */; - buildPhases = ( - B81CFFB2097FE5F80057C06F /* Resources */, - B81CFFB4097FE5F80057C06F /* Sources */, - B81CFFB6097FE5F80057C06F /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - B81CFFB0097FE5F80057C06F /* PBXTargetDependency */, - ); - name = 13.RenderToTexture; - productName = DemoApp; - productReference = 4CA25B9C0A485D9800B4E469 /* RenderToTexture_dbg.app */; - productType = "com.apple.product-type.application"; - }; - B8DEF35C0950229200FDEA7E /* Demo */ = { - isa = PBXNativeTarget; - buildConfigurationList = B8DEF3600950229300FDEA7E /* Build configuration list for PBXNativeTarget "Demo" */; - buildPhases = ( - B8DEF3590950229200FDEA7E /* Resources */, - B8DEF35A0950229200FDEA7E /* Sources */, - B8DEF35B0950229200FDEA7E /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - B8DEF375095024F600FDEA7E /* PBXTargetDependency */, - ); - name = Demo; - productName = DemoApp; - productReference = 4CA25BA20A485D9800B4E469 /* Demo_dbg.app */; - productType = "com.apple.product-type.application"; - }; - D2AAC07D0554694100DB518D /* libIrrlicht.a */ = { - isa = PBXNativeTarget; - buildConfigurationList = 1DEB921E08733DC00010E9CD /* Build configuration list for PBXNativeTarget "libIrrlicht.a" */; - buildPhases = ( - D2AAC07A0554694100DB518D /* Headers */, - D2AAC07B0554694100DB518D /* Sources */, - D2AAC07C0554694100DB518D /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = libIrrlicht.a; - productName = MacOSX; - productReference = 4C53E24D0A4850120014E966 /* libIrrlicht.a */; - productType = "com.apple.product-type.library.static"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 0867D690FE84028FC02AAC07 /* Project object */ = { - isa = PBXProject; - buildConfigurationList = 1DEB922208733DC00010E9CD /* Build configuration list for PBXProject "MacOSX" */; - compatibilityVersion = "Xcode 2.4"; - hasScannedForEncodings = 1; - mainGroup = 0867D691FE84028FC02AAC07 /* MacOSX */; - productRefGroup = 0867D691FE84028FC02AAC07 /* MacOSX */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - D2AAC07D0554694100DB518D /* libIrrlicht.a */, - 09F648F40D2CDED9001E0599 /* 01.HelloWorld */, - B81CFF33097FE25F0057C06F /* 02.Quake3Map */, - B81CFF1E097FE1E00057C06F /* 03.CustomSceneNode */, - B81CFF78097FE3DC0057C06F /* 04.Movement */, - B81CFF07097FE13E0057C06F /* 05.UserInterface */, - B81CFDFE097FD9F50057C06F /* 06.2DGraphics */, - B81CFE82097FDDE20057C06F /* 07.Collision */, - B81CFEE8097FE05F0057C06F /* 08.SpecialFx */, - B81CFF91097FE45E0057C06F /* 09.MeshViewer */, - B81CFF4A097FE3050057C06F /* 10.Shaders */, - B81CFEA4097FDE900057C06F /* 11.PerPixelLightning */, - B81CFEC2097FDF020057C06F /* 12.TerrainRendering */, - B81CFFAF097FE5F80057C06F /* 13.RenderToTexture */, - 09F6492F0D2CE03E001E0599 /* 15.LoadIrrFile */, - 09F649560D2CE206001E0599 /* 16.Quake3Shader */, - 0946CCA30EC99BBE00D945A5 /* 19.MouseAndJoystick */, - B8DEF35C0950229200FDEA7E /* Demo */, - 09022C520EA0E97F00CD54EE /* GUIEditor */, - B81CFFC6097FE9980057C06F /* All */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 09022C550EA0E97F00CD54EE /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 09022C560EA0E97F00CD54EE /* MainMenu.nib in Resources */, - 09022C570EA0E97F00CD54EE /* DemoApp-Info.plist in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 0946CCA60EC99BBE00D945A5 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 0946CCA70EC99BBE00D945A5 /* MainMenu.nib in Resources */, - 0946CCA80EC99BBE00D945A5 /* DemoApp-Info.plist in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 09F648F70D2CDED9001E0599 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 09F648F80D2CDED9001E0599 /* MainMenu.nib in Resources */, - 09F648F90D2CDED9001E0599 /* DemoApp-Info.plist in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 09F649320D2CE03E001E0599 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 09F649330D2CE03E001E0599 /* MainMenu.nib in Resources */, - 09F649340D2CE03E001E0599 /* DemoApp-Info.plist in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 09F649590D2CE206001E0599 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 09F6495A0D2CE206001E0599 /* MainMenu.nib in Resources */, - 09F6495B0D2CE206001E0599 /* DemoApp-Info.plist in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B81CFE01097FD9F50057C06F /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CF146F60A486651006EBA03 /* MainMenu.nib in Resources */, - 4C53E3920A4855BA0014E966 /* DemoApp-Info.plist in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B81CFE85097FDDE20057C06F /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CF1470B0A486704006EBA03 /* MainMenu.nib in Resources */, - 4C53E3930A4855BA0014E966 /* DemoApp-Info.plist in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B81CFEA7097FDE900057C06F /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CA5CBB30A486A1300ADB3D7 /* MainMenu.nib in Resources */, - 4C53E3970A4855BA0014E966 /* DemoApp-Info.plist in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B81CFEC5097FDF020057C06F /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CA5CBB60A486A2200ADB3D7 /* MainMenu.nib in Resources */, - 4C53E3980A4855BA0014E966 /* DemoApp-Info.plist in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B81CFEEB097FE05F0057C06F /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CF147180A48676A006EBA03 /* MainMenu.nib in Resources */, - 4C53E3940A4855BA0014E966 /* DemoApp-Info.plist in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B81CFF0A097FE13E0057C06F /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CA25C8B0A48626600B4E469 /* MainMenu.nib in Resources */, - 4C53E3910A4855BA0014E966 /* DemoApp-Info.plist in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B81CFF21097FE1E00057C06F /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CA25C360A48610400B4E469 /* MainMenu.nib in Resources */, - 4C53E38F0A4855BA0014E966 /* DemoApp-Info.plist in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B81CFF36097FE25F0057C06F /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4C53E3890A48559C0014E966 /* MainMenu.nib in Resources */, - 4C53E39B0A4855BA0014E966 /* DemoApp-Info.plist in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B81CFF4D097FE3050057C06F /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CA5CBA70A4869C600ADB3D7 /* MainMenu.nib in Resources */, - 4C53E3960A4855BA0014E966 /* DemoApp-Info.plist in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B81CFF7B097FE3DC0057C06F /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CA25C6A0A4861D800B4E469 /* MainMenu.nib in Resources */, - 4C53E3900A4855BA0014E966 /* DemoApp-Info.plist in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B81CFF94097FE45E0057C06F /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CA5CBA90A4869DD00ADB3D7 /* MainMenu.nib in Resources */, - 4C53E3950A4855BA0014E966 /* DemoApp-Info.plist in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B81CFFB2097FE5F80057C06F /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CA5CBB90A486A3100ADB3D7 /* MainMenu.nib in Resources */, - 4C53E3990A4855BA0014E966 /* DemoApp-Info.plist in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B8DEF3590950229200FDEA7E /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CA5CBBE0A486A4F00ADB3D7 /* MainMenu.nib in Resources */, - 4C53E39A0A4855BA0014E966 /* DemoApp-Info.plist in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 09022C580EA0E97F00CD54EE /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 09022C7E0EA0EA9D00CD54EE /* CGUIAttributeEditor.cpp in Sources */, - 09022C7F0EA0EA9D00CD54EE /* CGUIEditFactory.cpp in Sources */, - 09022C800EA0EA9D00CD54EE /* CGUIEditWindow.cpp in Sources */, - 09022C810EA0EA9D00CD54EE /* CGUIEditWorkspace.cpp in Sources */, - 09022C820EA0EA9D00CD54EE /* CGUIPanel.cpp in Sources */, - 09022C830EA0EA9D00CD54EE /* CGUITextureCacheBrowser.cpp in Sources */, - 09022C840EA0EA9D00CD54EE /* CMemoryReadWriteFile.cpp in Sources */, - 09022C850EA0EA9D00CD54EE /* main.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 0946CCA90EC99BBE00D945A5 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 0946CCCB0EC99C6E00D945A5 /* main.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 09F648FA0D2CDED9001E0599 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 09F6491A0D2CDF9A001E0599 /* main.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 09F649350D2CE03E001E0599 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 09F460EB0D3223ED00D0A9B0 /* main.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 09F6495C0D2CE206001E0599 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 09F649740D2CE2D0001E0599 /* main.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B81CFE03097FD9F50057C06F /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CF146F70A486668006EBA03 /* main.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B81CFE87097FDDE20057C06F /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CF147100A486709006EBA03 /* main.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B81CFEA9097FDE900057C06F /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CA5CBB20A486A0D00ADB3D7 /* main.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B81CFEC7097FDF020057C06F /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CA5CBB50A486A1F00ADB3D7 /* main.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B81CFEED097FE05F0057C06F /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CF1471A0A486774006EBA03 /* main.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B81CFF0C097FE13E0057C06F /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CA25C8C0A48627600B4E469 /* main.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B81CFF23097FE1E00057C06F /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CA25C350A4860EE00B4E469 /* main.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B81CFF38097FE25F0057C06F /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4C53E2500A48504D0014E966 /* main.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B81CFF4F097FE3050057C06F /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CA5CBB00A4869FD00ADB3D7 /* main.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B81CFF7D097FE3DC0057C06F /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CA25C690A4861D100B4E469 /* main.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B81CFF96097FE45E0057C06F /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CA5CBAE0A4869E600ADB3D7 /* main.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B81CFFB4097FE5F80057C06F /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CA5CBB80A486A2E00ADB3D7 /* main.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B8DEF35A0950229200FDEA7E /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CA5CBBB0A486A4C00ADB3D7 /* CMainMenu.cpp in Sources */, - 4CA5CBBC0A486A4C00ADB3D7 /* main.cpp in Sources */, - 4CA5CBBD0A486A4C00ADB3D7 /* CDemo.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - D2AAC07B0554694100DB518D /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CA25BCE0A485EAD00B4E469 /* jcapimin.c in Sources */, - 4CA25BCF0A485EAD00B4E469 /* jcapistd.c in Sources */, - 4CA25BD00A485EAD00B4E469 /* jccoefct.c in Sources */, - 4CA25BD10A485EAD00B4E469 /* jccolor.c in Sources */, - 4CA25BD20A485EAD00B4E469 /* jcdctmgr.c in Sources */, - 4CA25BD30A485EAD00B4E469 /* jchuff.c in Sources */, - 4CA25BD50A485EAD00B4E469 /* jcinit.c in Sources */, - 4CA25BD60A485EAD00B4E469 /* jcmainct.c in Sources */, - 4CA25BD70A485EAD00B4E469 /* jcmarker.c in Sources */, - 4CA25BD80A485EAD00B4E469 /* jcmaster.c in Sources */, - 4CA25BD90A485EAD00B4E469 /* jcomapi.c in Sources */, - 4CA25BDB0A485EAD00B4E469 /* jcparam.c in Sources */, - 4CA25BDC0A485EAD00B4E469 /* jcphuff.c in Sources */, - 4CA25BDD0A485EAD00B4E469 /* jcprepct.c in Sources */, - 4CA25BDE0A485EAD00B4E469 /* jcsample.c in Sources */, - 4CA25BDF0A485EAD00B4E469 /* jctrans.c in Sources */, - 4CA25BE00A485EAD00B4E469 /* jdapimin.c in Sources */, - 4CA25BE10A485EAD00B4E469 /* jdapistd.c in Sources */, - 4CA25BE20A485EAD00B4E469 /* jdatadst.c in Sources */, - 4CA25BE30A485EAD00B4E469 /* jdatasrc.c in Sources */, - 4CA25BE40A485EAD00B4E469 /* jdcoefct.c in Sources */, - 4CA25BE50A485EAD00B4E469 /* jdcolor.c in Sources */, - 4CA25BE70A485EAD00B4E469 /* jddctmgr.c in Sources */, - 4CA25BE80A485EAD00B4E469 /* jdhuff.c in Sources */, - 4CA25BEA0A485EAD00B4E469 /* jdinput.c in Sources */, - 4CA25BEB0A485EAD00B4E469 /* jdmainct.c in Sources */, - 4CA25BEC0A485EAD00B4E469 /* jdmarker.c in Sources */, - 4CA25BED0A485EAD00B4E469 /* jdmaster.c in Sources */, - 4CA25BEE0A485EAD00B4E469 /* jdmerge.c in Sources */, - 4CA25BEF0A485EAD00B4E469 /* jdphuff.c in Sources */, - 4CA25BF00A485EAD00B4E469 /* jdpostct.c in Sources */, - 4CA25BF10A485EAD00B4E469 /* jdsample.c in Sources */, - 4CA25BF20A485EAD00B4E469 /* jdtrans.c in Sources */, - 4CA25BF30A485EAD00B4E469 /* jerror.c in Sources */, - 4CA25BF50A485EAD00B4E469 /* jfdctflt.c in Sources */, - 4CA25BF60A485EAD00B4E469 /* jfdctfst.c in Sources */, - 4CA25BF70A485EAD00B4E469 /* jfdctint.c in Sources */, - 4CA25BF80A485EAD00B4E469 /* jidctflt.c in Sources */, - 4CA25BF90A485EAD00B4E469 /* jidctfst.c in Sources */, - 4CA25BFA0A485EAD00B4E469 /* jidctint.c in Sources */, - 4CA25BFB0A485EAD00B4E469 /* jidctred.c in Sources */, - 4CA25C000A485EAD00B4E469 /* jmemmgr.c in Sources */, - 4CA25C020A485EAD00B4E469 /* jmemnobs.c in Sources */, - 4CA25C080A485EAD00B4E469 /* jquant1.c in Sources */, - 4CA25C090A485EAD00B4E469 /* jquant2.c in Sources */, - 4CA25C0A0A485EAD00B4E469 /* jutils.c in Sources */, - 4CA25C0C0A485EAD00B4E469 /* rdbmp.c in Sources */, - 4CA25C0D0A485EAD00B4E469 /* rdcolmap.c in Sources */, - 4CA25C0E0A485EAD00B4E469 /* rdgif.c in Sources */, - 4CA25C100A485EAD00B4E469 /* rdppm.c in Sources */, - 4CA25C110A485EAD00B4E469 /* rdrle.c in Sources */, - 4CA25C120A485EAD00B4E469 /* rdswitch.c in Sources */, - 4CA25C130A485EAD00B4E469 /* rdtarga.c in Sources */, - 4CA25C150A485EAD00B4E469 /* transupp.c in Sources */, - 4CA25C170A485EAD00B4E469 /* wrbmp.c in Sources */, - 4CA25C180A485EAD00B4E469 /* wrgif.c in Sources */, - 4CA25C1A0A485EAD00B4E469 /* wrppm.c in Sources */, - 4CA25C1B0A485EAD00B4E469 /* wrrle.c in Sources */, - 4CA25C1C0A485EAD00B4E469 /* wrtarga.c in Sources */, - 4C53E3CA0A4856B30014E966 /* gzio.c in Sources */, - 4C53E3D80A4856B30014E966 /* inffast.c in Sources */, - 4C53E3DC0A4856B30014E966 /* inftrees.c in Sources */, - 4C53E3E40A4856B30014E966 /* uncompr.c in Sources */, - 4C53E3F30A4856B30014E966 /* compress.c in Sources */, - 4C53E3F60A4856B30014E966 /* crc32.c in Sources */, - 4C53E3FE0A4856B30014E966 /* zutil.c in Sources */, - 4C53E4010A4856B30014E966 /* trees.c in Sources */, - 4C53E40A0A4856B30014E966 /* deflate.c in Sources */, - 4C53E4150A4856B30014E966 /* adler32.c in Sources */, - 4C53E4280A4856B30014E966 /* CImageLoaderPNG.cpp in Sources */, - 4C53E4290A4856B30014E966 /* CColorConverter.cpp in Sources */, - 4C53E42A0A4856B30014E966 /* CSceneManager.cpp in Sources */, - 4C53E42B0A4856B30014E966 /* CTRTextureGouraudAdd2.cpp in Sources */, - 4C53E42C0A4856B30014E966 /* CNullDriver.cpp in Sources */, - 4C53E42D0A4856B30014E966 /* CCSMLoader.cpp in Sources */, - 4C53E42E0A4856B30014E966 /* irrXML.cpp in Sources */, - 4C53E42F0A4856B30014E966 /* CGUIListBox.cpp in Sources */, - 4C53E4300A4856B30014E966 /* CTRGouraudWire.cpp in Sources */, - 4C53E4310A4856B30014E966 /* CIrrDeviceStub.cpp in Sources */, - 4C53E4320A4856B30014E966 /* CGUIMessageBox.cpp in Sources */, - 4C53E4330A4856B30014E966 /* CMeshSceneNode.cpp in Sources */, - 4C53E4340A4856B30014E966 /* CGUIStaticText.cpp in Sources */, - 4C53E4350A4856B30014E966 /* os.cpp in Sources */, - 4C53E4360A4856B30014E966 /* COCTLoader.cpp in Sources */, - 4C53E4370A4856B30014E966 /* CGUIContextMenu.cpp in Sources */, - 4C53E4390A4856B30014E966 /* CSceneNodeAnimatorFlyCircle.cpp in Sources */, - 4C53E43A0A4856B30014E966 /* CDefaultSceneNodeFactory.cpp in Sources */, - 4C53E43B0A4856B30014E966 /* CD3D9Driver.cpp in Sources */, - 4C53E43C0A4856B30014E966 /* CTRGouraud.cpp in Sources */, - 4C53E43D0A4856B30014E966 /* C3DSMeshFileLoader.cpp in Sources */, - 4C53E43E0A4856B30014E966 /* COgreMeshFileLoader.cpp in Sources */, - 4C53E43F0A4856B30014E966 /* CMY3DMeshFileLoader.cpp in Sources */, - 4C53E4400A4856B30014E966 /* CLMTSMeshFileLoader.cpp in Sources */, - 4C53E4410A4856B30014E966 /* CGUIFileOpenDialog.cpp in Sources */, - 4C53E4420A4856B30014E966 /* CSceneNodeAnimatorDelete.cpp in Sources */, - 4C53E4430A4856B30014E966 /* CTRGouraudAlphaNoZ2.cpp in Sources */, - 4C53E4440A4856B30014E966 /* CGeometryCreator.cpp in Sources */, - 4C53E4450A4856B30014E966 /* CD3D8Texture.cpp in Sources */, - 4C53E4460A4856B30014E966 /* CSkyBoxSceneNode.cpp in Sources */, - 4C53E4470A4856B30014E966 /* CMeshManipulator.cpp in Sources */, - 4C53E4480A4856B30014E966 /* CTextSceneNode.cpp in Sources */, - 4C53E4490A4856B30014E966 /* CTRTextureDetailMap2.cpp in Sources */, - 4C53E44A0A4856B30014E966 /* CTRTextureGouraudAddNoZ2.cpp in Sources */, - 4C53E44C0A4856B30014E966 /* CTRTextureGouraudNoZ.cpp in Sources */, - 4C53E44E0A4856B30014E966 /* CGUIScrollBar.cpp in Sources */, - 4C53E44F0A4856B30014E966 /* CSceneCollisionManager.cpp in Sources */, - 4C53E4500A4856B30014E966 /* CGUICheckBox.cpp in Sources */, - 4C53E4510A4856B30014E966 /* CQ3LevelMesh.cpp in Sources */, - 4C53E4520A4856B30014E966 /* CParticleGravityAffector.cpp in Sources */, - 4C53E4530A4856B30014E966 /* CSoftwareDriver2.cpp in Sources */, - 4C53E4540A4856B30014E966 /* CD3D9ParallaxMapRenderer.cpp in Sources */, - 4C53E4550A4856B30014E966 /* CD3D8ParallaxMapRenderer.cpp in Sources */, - 4C53E4560A4856B30014E966 /* CAnimatedMeshMD2.cpp in Sources */, - 4C53E4570A4856B30014E966 /* CSceneNodeAnimatorFlyStraight.cpp in Sources */, - 4C53E4580A4856B30014E966 /* CImageLoaderPCX.cpp in Sources */, - 4C53E4590A4856B30014E966 /* CAnimatedMeshSceneNode.cpp in Sources */, - 4C53E45A0A4856B30014E966 /* CTriangleSelector.cpp in Sources */, - 4C53E45B0A4856B30014E966 /* CTRTextureGouraudVertexAlpha2.cpp in Sources */, - 4C53E45C0A4856B30014E966 /* CTRTextureWire2.cpp in Sources */, - 4C53E45D0A4856B30014E966 /* CTRTextureFlatWire.cpp in Sources */, - 4C53E45E0A4856B30014E966 /* CTRGouraud2.cpp in Sources */, - 4C53E45F0A4856B30014E966 /* CEmptySceneNode.cpp in Sources */, - 4C53E4600A4856B30014E966 /* CTRTextureLightMap2_Add.cpp in Sources */, - 4C53E4610A4856B30014E966 /* CReadFile.cpp in Sources */, - 4C53E4620A4856B30014E966 /* COpenGLTexture.cpp in Sources */, - 4C53E4640A4856B30014E966 /* COSOperator.cpp in Sources */, - 4C53E4660A4856B30014E966 /* CColladaFileLoader.cpp in Sources */, - 4C53E4670A4856B30014E966 /* CCameraSceneNode.cpp in Sources */, - 4C53E4680A4856B30014E966 /* CMetaTriangleSelector.cpp in Sources */, - 4C53E4690A4856B30014E966 /* CTRTextureFlat.cpp in Sources */, - 4C53E46A0A4856B30014E966 /* CVideoModeList.cpp in Sources */, - 4C53E46B0A4856B30014E966 /* CXMLReader.cpp in Sources */, - 4C53E46C0A4856B30014E966 /* COpenGLParallaxMapRenderer.cpp in Sources */, - 4C53E46E0A4856B30014E966 /* CTRTextureGouraudNoZ2.cpp in Sources */, - 4C53E46F0A4856B30014E966 /* CTRTextureGouraudWire.cpp in Sources */, - 4C53E4700A4856B30014E966 /* CParticlePointEmitter.cpp in Sources */, - 4C53E4710A4856B30014E966 /* CGUIWindow.cpp in Sources */, - 4C53E4720A4856B30014E966 /* CGUIModalScreen.cpp in Sources */, - 4C53E4730A4856B30014E966 /* CImageLoaderPSD.cpp in Sources */, - 4C53E4740A4856B30014E966 /* CWaterSurfaceSceneNode.cpp in Sources */, - 4C53E4750A4856B30014E966 /* CXMeshFileLoader.cpp in Sources */, - 4C53E4760A4856B30014E966 /* CIrrDeviceLinux.cpp in Sources */, - 4C53E4770A4856B30014E966 /* CLightSceneNode.cpp in Sources */, - 4C53E4780A4856B30014E966 /* CTRTextureGouraudAdd.cpp in Sources */, - 4C53E4790A4856B30014E966 /* CTRTextureGouraud2.cpp in Sources */, - 4C53E47A0A4856B30014E966 /* CSoftwareDriver.cpp in Sources */, - 4C53E47B0A4856B30014E966 /* CTRFlatWire.cpp in Sources */, - 4C53E47C0A4856B30014E966 /* CTRGouraudAlpha2.cpp in Sources */, - 4C53E47D0A4856B30014E966 /* CSoftwareTexture2.cpp in Sources */, - 4C53E47E0A4856B30014E966 /* CZipReader.cpp in Sources */, - 4C53E47F0A4856B30014E966 /* COpenGLNormalMapRenderer.cpp in Sources */, - 4C53E4800A4856B30014E966 /* CTRTextureLightMap2_M1.cpp in Sources */, - 4C53E4810A4856B30014E966 /* CTRTextureLightMap2_M4.cpp in Sources */, - 4C53E4820A4856B30014E966 /* CGUISkin.cpp in Sources */, - 4C53E4830A4856B30014E966 /* CD3D8Driver.cpp in Sources */, - 4C53E4840A4856B30014E966 /* CIrrDeviceWin32.cpp in Sources */, - 4C53E4850A4856B30014E966 /* CFileSystem.cpp in Sources */, - 4C53E4860A4856B30014E966 /* CGUIMeshViewer.cpp in Sources */, - 4C53E4870A4856B30014E966 /* CGUIComboBox.cpp in Sources */, - 4C53E4880A4856B30014E966 /* CSceneNodeAnimatorRotation.cpp in Sources */, - 4C53E4890A4856B30014E966 /* CSceneNodeAnimatorTexture.cpp in Sources */, - 4C53E48A0A4856B30014E966 /* COctTreeSceneNode.cpp in Sources */, - 4C53E48B0A4856B30014E966 /* CParticleSystemSceneNode.cpp in Sources */, - 4C53E48C0A4856B30014E966 /* CTerrainSceneNode.cpp in Sources */, - 4C53E48E0A4856B30014E966 /* CGUIFont.cpp in Sources */, - 4C53E48F0A4856B30014E966 /* CParticleFadeOutAffector.cpp in Sources */, - 4C53E4910A4856B30014E966 /* CDummyTransformationSceneNode.cpp in Sources */, - 4C53E4920A4856B30014E966 /* CFileList.cpp in Sources */, - 4C53E4930A4856B30014E966 /* CImageLoaderTGA.cpp in Sources */, - 4C53E4940A4856B30014E966 /* CXMLWriter.cpp in Sources */, - 4C53E4950A4856B30014E966 /* CSceneNodeAnimatorFollowSpline.cpp in Sources */, - 4C53E4960A4856B30014E966 /* CZBuffer.cpp in Sources */, - 4C53E4970A4856B30014E966 /* CDMFLoader.cpp in Sources */, - 4C53E4980A4856B30014E966 /* CD3D9Texture.cpp in Sources */, - 4C53E4990A4856B30014E966 /* COpenGLShaderMaterialRenderer.cpp in Sources */, - 4C53E49A0A4856B30014E966 /* Irrlicht.cpp in Sources */, - 4C53E49B0A4856B30014E966 /* CGUIEditBox.cpp in Sources */, - 4C53E49C0A4856B30014E966 /* COpenGLSLMaterialRenderer.cpp in Sources */, - 4C53E49D0A4856B30014E966 /* CD3D9HLSLMaterialRenderer.cpp in Sources */, - 4C53E49E0A4856B30014E966 /* CSoftwareTexture.cpp in Sources */, - 4C53E49F0A4856B30014E966 /* CCubeSceneNode.cpp in Sources */, - 4C53E4A00A4856B30014E966 /* CTriangleBBSelector.cpp in Sources */, - 4C53E4A10A4856B30014E966 /* CD3D9ShaderMaterialRenderer.cpp in Sources */, - 4C53E4A20A4856B30014E966 /* CD3D8ShaderMaterialRenderer.cpp in Sources */, - 4C53E4A30A4856B30014E966 /* CGUIButton.cpp in Sources */, - 4C53E4A40A4856B30014E966 /* CGUIToolBar.cpp in Sources */, - 4C53E4A50A4856B30014E966 /* CDefaultSceneNodeAnimatorFactory.cpp in Sources */, - 4C53E4A60A4856B30014E966 /* CBillboardSceneNode.cpp in Sources */, - 4C53E4A70A4856B30014E966 /* CSceneNodeAnimatorCollisionResponse.cpp in Sources */, - 4C53E4A80A4856B30014E966 /* CLogger.cpp in Sources */, - 4C53E4A90A4856B30014E966 /* CGUIInOutFader.cpp in Sources */, - 4C53E4AA0A4856B30014E966 /* CWriteFile.cpp in Sources */, - 4C53E4AD0A4856B30014E966 /* CTRTextureGouraud.cpp in Sources */, - 4C53E4AE0A4856B30014E966 /* CTRFlat.cpp in Sources */, - 4C53E4AF0A4856B30014E966 /* CTerrainTriangleSelector.cpp in Sources */, - 4C53E4B00A4856B30014E966 /* COctTreeTriangleSelector.cpp in Sources */, - 4C53E4B10A4856B30014E966 /* CGUITabControl.cpp in Sources */, - 4C53E4B20A4856B30014E966 /* CParticleBoxEmitter.cpp in Sources */, - 4C53E4B30A4856B30014E966 /* CGUIMenu.cpp in Sources */, - 4C53E4B40A4856B30014E966 /* CImage.cpp in Sources */, - 4C53E4B50A4856B30014E966 /* CShadowVolumeSceneNode.cpp in Sources */, - 4C53E4B70A4856B30014E966 /* CGUIEnvironment.cpp in Sources */, - 4C53E4B80A4856B30014E966 /* CLimitReadFile.cpp in Sources */, - 4C53E4B90A4856B30014E966 /* CAttributes.cpp in Sources */, - 4C53E4BA0A4856B30014E966 /* COpenGLDriver.cpp in Sources */, - 4C53E4BB0A4856B30014E966 /* CTRTextureLightMap2_M2.cpp in Sources */, - 4C53E4BC0A4856B30014E966 /* CGUIImage.cpp in Sources */, - 4C53E4BD0A4856B30014E966 /* CD3D9NormalMapRenderer.cpp in Sources */, - 4C53E4BE0A4856B30014E966 /* CD3D8NormalMapRenderer.cpp in Sources */, - 4C53E4BF0A4856B30014E966 /* CMeshCache.cpp in Sources */, - 4C53E4C00A4856B30014E966 /* CImageLoaderJPG.cpp in Sources */, - 4C53E4C10A4856B30014E966 /* CFPSCounter.cpp in Sources */, - 4C53E57E0A4856B30014E966 /* OSXClipboard.mm in Sources */, - 4C53E57F0A4856B30014E966 /* CIrrDeviceMacOSX.mm in Sources */, - 4C53E5800A4856B30014E966 /* AppDelegate.mm in Sources */, - 4C6DC9B70A48715A0017A6E5 /* inflate.c in Sources */, - 4CC36B0F0A6B61DB0076C4B2 /* CSphereSceneNode.cpp in Sources */, - 4C364EA40A6C6DC2004CFBB4 /* COBJMeshFileLoader.cpp in Sources */, - 4C43EEC00A74A5C800F942FC /* CPakReader.cpp in Sources */, - 4CFA7BEE0A88735A00B03626 /* CImageLoaderBMP.cpp in Sources */, - 4CFA7BF00A88735A00B03626 /* CImageWriterBMP.cpp in Sources */, - 4CFA7BF20A88735A00B03626 /* CImageWriterJPG.cpp in Sources */, - 4CFA7BF40A88735A00B03626 /* CImageWriterPCX.cpp in Sources */, - 4CFA7BF60A88735A00B03626 /* CImageWriterPNG.cpp in Sources */, - 4CFA7BF80A88735A00B03626 /* CImageWriterPPM.cpp in Sources */, - 4CFA7BFA0A88735A00B03626 /* CImageWriterPSD.cpp in Sources */, - 4CFA7BFC0A88735A00B03626 /* CImageWriterTGA.cpp in Sources */, - 4CFA7BFE0A88735A00B03626 /* CSkyDomeSceneNode.cpp in Sources */, - 5DD4804E0C7D91DF00728AA9 /* CDepthBuffer.cpp in Sources */, - 5DD480520C7D936700728AA9 /* IBurningShader.cpp in Sources */, - 5DD4805A0C7D945800728AA9 /* CAnimatedMeshMD3.cpp in Sources */, - 5DD4805C0C7D945800728AA9 /* CDefaultGUIElementFactory.cpp in Sources */, - 5DD480640C7D947B00728AA9 /* CGUIColorSelectDialog.cpp in Sources */, - 5DD480660C7D947B00728AA9 /* CGUISpinBox.cpp in Sources */, - 5DD480680C7D947B00728AA9 /* CGUISpriteBank.cpp in Sources */, - 5DD480710C7D94AC00728AA9 /* CQuake3ShaderSceneNode.cpp in Sources */, - 5DD480730C7D94AC00728AA9 /* CTRTextureBlend.cpp in Sources */, - 5DD480740C7D94AC00728AA9 /* CTRTextureGouraudAlpha.cpp in Sources */, - 5DD480750C7D94AC00728AA9 /* CTRTextureGouraudAlphaNoZ.cpp in Sources */, - 5DD480760C7D94AC00728AA9 /* CTRTextureLightMapGouraud2_M4.cpp in Sources */, - 5DD480CA0C7DA66800728AA9 /* CIrrDeviceSDL.cpp in Sources */, - 5DD480CB0C7DA66800728AA9 /* COpenGLExtensionHandler.cpp in Sources */, - 5DD480CC0C7DA66800728AA9 /* CMD3MeshFileLoader.cpp in Sources */, - 096840470D0F1A2300333EFD /* CB3DMeshFileLoader.cpp in Sources */, - 096840490D0F1A2300333EFD /* CBoneSceneNode.cpp in Sources */, - 0968404B0D0F1A2300333EFD /* CBSPMeshFileLoader.cpp in Sources */, - 0968404E0D0F1A2300333EFD /* CColladaMeshWriter.cpp in Sources */, - 096840500D0F1A2300333EFD /* CImageLoaderPPM.cpp in Sources */, - 096840540D0F1A2300333EFD /* CIrrMeshFileLoader.cpp in Sources */, - 096840560D0F1A2300333EFD /* CIrrMeshWriter.cpp in Sources */, - 096840580D0F1A2300333EFD /* CMD2MeshFileLoader.cpp in Sources */, - 0968405A0D0F1A2300333EFD /* CMS3DMeshFileLoader.cpp in Sources */, - 0968405C0D0F1A2300333EFD /* CParticleAnimatedMeshSceneNodeEmitter.cpp in Sources */, - 0968405E0D0F1A2300333EFD /* CParticleAttractionAffector.cpp in Sources */, - 096840600D0F1A2300333EFD /* CParticleCylinderEmitter.cpp in Sources */, - 096840620D0F1A2300333EFD /* CParticleMeshEmitter.cpp in Sources */, - 096840640D0F1A2300333EFD /* CParticleRingEmitter.cpp in Sources */, - 096840660D0F1A2300333EFD /* CParticleRotationAffector.cpp in Sources */, - 096840680D0F1A2300333EFD /* CParticleSphereEmitter.cpp in Sources */, - 0968406A0D0F1A2300333EFD /* CSkinnedMesh.cpp in Sources */, - 0968406C0D0F1A2300333EFD /* CSTLMeshFileLoader.cpp in Sources */, - 0968406E0D0F1A2300333EFD /* CSTLMeshWriter.cpp in Sources */, - 0910B9DE0D1F5D4100D46B04 /* CBurningShader_Raster_Reference.cpp in Sources */, - 0910B9DF0D1F5D4100D46B04 /* CGUITable.cpp in Sources */, - 0910B9E10D1F5D4100D46B04 /* CImageLoaderWAL.cpp in Sources */, - 090FBC820D31085E0076D847 /* CVolumeLightSceneNode.cpp in Sources */, - 09C638720D4F1A69000B6A18 /* CLWOMeshFileLoader.cpp in Sources */, - 093973C00E0458B200E0C987 /* CSceneNodeAnimatorCameraFPS.cpp in Sources */, - 093973C20E0458B200E0C987 /* CSceneNodeAnimatorCameraMaya.cpp in Sources */, - 096F8E3D0EA2EFBA00907EC5 /* COBJMeshWriter.cpp in Sources */, - 096CC0E00ECE65B500C81DC7 /* CParticleScaleAffector.cpp in Sources */, - 09293C3E0ED32029003B8C9C /* png.c in Sources */, - 09293C3F0ED32029003B8C9C /* pngerror.c in Sources */, - 09293C400ED32029003B8C9C /* pnggccrd.c in Sources */, - 09293C410ED32029003B8C9C /* pngget.c in Sources */, - 09293C420ED32029003B8C9C /* pngmem.c in Sources */, - 09293C430ED32029003B8C9C /* pngpread.c in Sources */, - 09293C440ED32029003B8C9C /* pngread.c in Sources */, - 09293C450ED32029003B8C9C /* pngrio.c in Sources */, - 09293C460ED32029003B8C9C /* pngrtran.c in Sources */, - 09293C470ED32029003B8C9C /* pngrutil.c in Sources */, - 09293C480ED32029003B8C9C /* pngset.c in Sources */, - 09293C4A0ED32029003B8C9C /* pngtrans.c in Sources */, - 09293C4C0ED32029003B8C9C /* pngwio.c in Sources */, - 09293C4D0ED32029003B8C9C /* pngwrite.c in Sources */, - 09293C4E0ED32029003B8C9C /* pngwtran.c in Sources */, - 09293C4F0ED32029003B8C9C /* pngwutil.c in Sources */, - 3484C4E20F48D1B000C81F60 /* CGUIImageList.cpp in Sources */, - 3484C4EF0F48D3A100C81F60 /* CGUITreeView.cpp in Sources */, - 3484C4FE0F48D4CB00C81F60 /* CMemoryFile.cpp in Sources */, - 34EC243D0F59272E0037BC3A /* CIrrDeviceConsole.cpp in Sources */, - 34EF91D30F65FCA6000B5651 /* CImageLoaderRGB.cpp in Sources */, - 34EF91D80F65FCF6000B5651 /* CPLYMeshFileLoader.cpp in Sources */, - 34EF91DD0F65FD14000B5651 /* CPLYMeshWriter.cpp in Sources */, - 3430E4D71022C391006271FD /* CTarReader.cpp in Sources */, - 344FD4A61039E98C0045FD3F /* CMountPointReader.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXTargetDependency section */ - 09022C530EA0E97F00CD54EE /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = D2AAC07D0554694100DB518D /* libIrrlicht.a */; - targetProxy = 09022C540EA0E97F00CD54EE /* PBXContainerItemProxy */; - }; - 0946CCA40EC99BBE00D945A5 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = D2AAC07D0554694100DB518D /* libIrrlicht.a */; - targetProxy = 0946CCA50EC99BBE00D945A5 /* PBXContainerItemProxy */; - }; - 0946CCD60EC99D8200D945A5 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 0946CCA30EC99BBE00D945A5 /* 19.MouseAndJoystick */; - targetProxy = 0946CCD50EC99D8200D945A5 /* PBXContainerItemProxy */; - }; - 0946CCD90EC99D8C00D945A5 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 09022C520EA0E97F00CD54EE /* GUIEditor */; - targetProxy = 0946CCD80EC99D8C00D945A5 /* PBXContainerItemProxy */; - }; - 09F648F50D2CDED9001E0599 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = D2AAC07D0554694100DB518D /* libIrrlicht.a */; - targetProxy = 09F648F60D2CDED9001E0599 /* PBXContainerItemProxy */; - }; - 09F649210D2CDFF0001E0599 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 09F648F40D2CDED9001E0599 /* 01.HelloWorld */; - targetProxy = 09F649200D2CDFF0001E0599 /* PBXContainerItemProxy */; - }; - 09F649300D2CE03E001E0599 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = D2AAC07D0554694100DB518D /* libIrrlicht.a */; - targetProxy = 09F649310D2CE03E001E0599 /* PBXContainerItemProxy */; - }; - 09F649450D2CE100001E0599 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 09F6492F0D2CE03E001E0599 /* 15.LoadIrrFile */; - targetProxy = 09F649440D2CE100001E0599 /* PBXContainerItemProxy */; - }; - 09F649570D2CE206001E0599 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = D2AAC07D0554694100DB518D /* libIrrlicht.a */; - targetProxy = 09F649580D2CE206001E0599 /* PBXContainerItemProxy */; - }; - 09F649720D2CE2A1001E0599 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 09F649560D2CE206001E0599 /* 16.Quake3Shader */; - targetProxy = 09F649710D2CE2A1001E0599 /* PBXContainerItemProxy */; - }; - 4CA5CB820A4868B500ADB3D7 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = B8DEF35C0950229200FDEA7E /* Demo */; - targetProxy = 4CA5CB810A4868B500ADB3D7 /* PBXContainerItemProxy */; - }; - 4CA5CB840A4868B500ADB3D7 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = B81CFFAF097FE5F80057C06F /* 13.RenderToTexture */; - targetProxy = 4CA5CB830A4868B500ADB3D7 /* PBXContainerItemProxy */; - }; - 4CA5CB860A4868B500ADB3D7 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = B81CFEC2097FDF020057C06F /* 12.TerrainRendering */; - targetProxy = 4CA5CB850A4868B500ADB3D7 /* PBXContainerItemProxy */; - }; - 4CA5CB880A4868B500ADB3D7 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = B81CFEA4097FDE900057C06F /* 11.PerPixelLightning */; - targetProxy = 4CA5CB870A4868B500ADB3D7 /* PBXContainerItemProxy */; - }; - 4CA5CB8A0A4868B500ADB3D7 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = B81CFF4A097FE3050057C06F /* 10.Shaders */; - targetProxy = 4CA5CB890A4868B500ADB3D7 /* PBXContainerItemProxy */; - }; - 4CA5CB8C0A4868B500ADB3D7 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = B81CFF91097FE45E0057C06F /* 09.MeshViewer */; - targetProxy = 4CA5CB8B0A4868B500ADB3D7 /* PBXContainerItemProxy */; - }; - 4CA5CB8E0A4868B500ADB3D7 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = B81CFEE8097FE05F0057C06F /* 08.SpecialFx */; - targetProxy = 4CA5CB8D0A4868B500ADB3D7 /* PBXContainerItemProxy */; - }; - 4CA5CB900A4868B500ADB3D7 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = B81CFE82097FDDE20057C06F /* 07.Collision */; - targetProxy = 4CA5CB8F0A4868B500ADB3D7 /* PBXContainerItemProxy */; - }; - 4CA5CB920A4868B500ADB3D7 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = B81CFDFE097FD9F50057C06F /* 06.2DGraphics */; - targetProxy = 4CA5CB910A4868B500ADB3D7 /* PBXContainerItemProxy */; - }; - 4CA5CB940A4868B500ADB3D7 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = B81CFF07097FE13E0057C06F /* 05.UserInterface */; - targetProxy = 4CA5CB930A4868B500ADB3D7 /* PBXContainerItemProxy */; - }; - 4CA5CB960A4868B500ADB3D7 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = B81CFF78097FE3DC0057C06F /* 04.Movement */; - targetProxy = 4CA5CB950A4868B500ADB3D7 /* PBXContainerItemProxy */; - }; - 4CA5CB980A4868B500ADB3D7 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = B81CFF1E097FE1E00057C06F /* 03.CustomSceneNode */; - targetProxy = 4CA5CB970A4868B500ADB3D7 /* PBXContainerItemProxy */; - }; - 4CA5CB9A0A4868B500ADB3D7 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = B81CFF33097FE25F0057C06F /* 02.Quake3Map */; - targetProxy = 4CA5CB990A4868B500ADB3D7 /* PBXContainerItemProxy */; - }; - B81CFDFF097FD9F50057C06F /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = D2AAC07D0554694100DB518D /* libIrrlicht.a */; - targetProxy = B81CFE00097FD9F50057C06F /* PBXContainerItemProxy */; - }; - B81CFE83097FDDE20057C06F /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = D2AAC07D0554694100DB518D /* libIrrlicht.a */; - targetProxy = B81CFE84097FDDE20057C06F /* PBXContainerItemProxy */; - }; - B81CFEA5097FDE900057C06F /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = D2AAC07D0554694100DB518D /* libIrrlicht.a */; - targetProxy = B81CFEA6097FDE900057C06F /* PBXContainerItemProxy */; - }; - B81CFEC3097FDF020057C06F /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = D2AAC07D0554694100DB518D /* libIrrlicht.a */; - targetProxy = B81CFEC4097FDF020057C06F /* PBXContainerItemProxy */; - }; - B81CFEE9097FE05F0057C06F /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = D2AAC07D0554694100DB518D /* libIrrlicht.a */; - targetProxy = B81CFEEA097FE05F0057C06F /* PBXContainerItemProxy */; - }; - B81CFF08097FE13E0057C06F /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = D2AAC07D0554694100DB518D /* libIrrlicht.a */; - targetProxy = B81CFF09097FE13E0057C06F /* PBXContainerItemProxy */; - }; - B81CFF1F097FE1E00057C06F /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = D2AAC07D0554694100DB518D /* libIrrlicht.a */; - targetProxy = B81CFF20097FE1E00057C06F /* PBXContainerItemProxy */; - }; - B81CFF34097FE25F0057C06F /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = D2AAC07D0554694100DB518D /* libIrrlicht.a */; - targetProxy = B81CFF35097FE25F0057C06F /* PBXContainerItemProxy */; - }; - B81CFF4B097FE3050057C06F /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = D2AAC07D0554694100DB518D /* libIrrlicht.a */; - targetProxy = B81CFF4C097FE3050057C06F /* PBXContainerItemProxy */; - }; - B81CFF79097FE3DC0057C06F /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = D2AAC07D0554694100DB518D /* libIrrlicht.a */; - targetProxy = B81CFF7A097FE3DC0057C06F /* PBXContainerItemProxy */; - }; - B81CFF92097FE45E0057C06F /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = D2AAC07D0554694100DB518D /* libIrrlicht.a */; - targetProxy = B81CFF93097FE45E0057C06F /* PBXContainerItemProxy */; - }; - B81CFFB0097FE5F80057C06F /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = D2AAC07D0554694100DB518D /* libIrrlicht.a */; - targetProxy = B81CFFB1097FE5F80057C06F /* PBXContainerItemProxy */; - }; - B8DEF375095024F600FDEA7E /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = D2AAC07D0554694100DB518D /* libIrrlicht.a */; - targetProxy = B8DEF374095024F600FDEA7E /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - -/* Begin XCBuildConfiguration section */ - 09022C600EA0E97F00CD54EE /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - DEPLOYMENT_LOCATION = YES; - DSTROOT = ../../../bin/MacOSX; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_MODEL_TUNING = G5; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "DemoApp-Info.plist"; - INSTALL_PATH = /; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(LIBRARY_SEARCH_PATHS_QUOTED_1)", - ); - LIBRARY_SEARCH_PATHS_QUOTED_1 = "\"$(SRCROOT)/build/Debug\""; - OTHER_LDFLAGS = ( - "-framework", - Foundation, - "-framework", - AppKit, - ); - PREBINDING = NO; - PRODUCT_NAME = GUIEditor_dbg; - WRAPPER_EXTENSION = app; - ZERO_LINK = YES; - }; - name = Debug; - }; - 09022C610EA0E97F00CD54EE /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEAD_CODE_STRIPPING = YES; - DEPLOYMENT_LOCATION = YES; - DEPLOYMENT_POSTPROCESSING = YES; - DSTROOT = ../../../bin/MacOSX; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_MODEL_TUNING = G5; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "DemoApp-Info.plist"; - INSTALL_PATH = /; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(LIBRARY_SEARCH_PATHS_QUOTED_1)", - ); - LIBRARY_SEARCH_PATHS_QUOTED_1 = "\"$(SRCROOT)/build/Debug\""; - ONLY_LINK_ESSENTIAL_SYMBOLS = YES; - OTHER_LDFLAGS = ( - "-framework", - Foundation, - "-framework", - AppKit, - ); - PREBINDING = NO; - PRODUCT_NAME = GUIEditor; - SEPARATE_STRIP = YES; - STRIP_INSTALLED_PRODUCT = YES; - WRAPPER_EXTENSION = app; - ZERO_LINK = NO; - }; - name = Release; - }; - 0946CCB20EC99BBE00D945A5 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ( - ppc, - i386, - ); - COPY_PHASE_STRIP = NO; - DEPLOYMENT_LOCATION = YES; - DSTROOT = ../../../bin/MacOSX; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_MODEL_TUNING = G5; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "DemoApp-Info.plist"; - INSTALL_PATH = /; - OTHER_LDFLAGS = ( - "-framework", - Foundation, - "-framework", - AppKit, - ); - PREBINDING = NO; - PRODUCT_NAME = MouseAndJoystick_dbg; - WRAPPER_EXTENSION = app; - ZERO_LINK = YES; - }; - name = Debug; - }; - 0946CCB30EC99BBE00D945A5 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ( - ppc, - i386, - ); - COPY_PHASE_STRIP = YES; - DEAD_CODE_STRIPPING = YES; - DEPLOYMENT_LOCATION = YES; - DEPLOYMENT_POSTPROCESSING = YES; - DSTROOT = ../../../bin/MacOSX; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_MODEL_TUNING = G5; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "DemoApp-Info.plist"; - INSTALL_PATH = /; - ONLY_LINK_ESSENTIAL_SYMBOLS = YES; - OTHER_LDFLAGS = ( - "-framework", - Foundation, - "-framework", - AppKit, - ); - PREBINDING = NO; - PRODUCT_NAME = MouseAndJoystick; - SEPARATE_STRIP = YES; - STRIP_INSTALLED_PRODUCT = YES; - WRAPPER_EXTENSION = app; - ZERO_LINK = NO; - }; - name = Release; - }; - 09F649010D2CDED9001E0599 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - DEPLOYMENT_LOCATION = YES; - DSTROOT = ../../../bin/MacOSX; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_MODEL_TUNING = G5; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "DemoApp-Info.plist"; - INSTALL_PATH = /; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(LIBRARY_SEARCH_PATHS_QUOTED_1)", - ); - LIBRARY_SEARCH_PATHS_QUOTED_1 = "\"$(SRCROOT)/build/Debug\""; - OTHER_LDFLAGS = ( - "-framework", - Foundation, - "-framework", - AppKit, - ); - PREBINDING = NO; - PRODUCT_NAME = HelloWorld_dbg; - WRAPPER_EXTENSION = app; - ZERO_LINK = YES; - }; - name = Debug; - }; - 09F649020D2CDED9001E0599 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEAD_CODE_STRIPPING = YES; - DEPLOYMENT_LOCATION = YES; - DEPLOYMENT_POSTPROCESSING = YES; - DSTROOT = ../../../bin/MacOSX; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_MODEL_TUNING = G5; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "DemoApp-Info.plist"; - INSTALL_PATH = /; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(LIBRARY_SEARCH_PATHS_QUOTED_1)", - ); - LIBRARY_SEARCH_PATHS_QUOTED_1 = "\"$(SRCROOT)/build/Debug\""; - ONLY_LINK_ESSENTIAL_SYMBOLS = YES; - OTHER_LDFLAGS = ( - "-framework", - Foundation, - "-framework", - AppKit, - ); - PREBINDING = NO; - PRODUCT_NAME = HelloWorld; - SEPARATE_STRIP = YES; - STRIP_INSTALLED_PRODUCT = YES; - WRAPPER_EXTENSION = app; - ZERO_LINK = NO; - }; - name = Release; - }; - 09F6493C0D2CE03E001E0599 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - DEPLOYMENT_LOCATION = YES; - DSTROOT = ../../../bin/MacOSX; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_MODEL_TUNING = G5; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "DemoApp-Info.plist"; - INSTALL_PATH = /; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(LIBRARY_SEARCH_PATHS_QUOTED_1)", - ); - LIBRARY_SEARCH_PATHS_QUOTED_1 = "\"$(SRCROOT)/build/Debug\""; - OTHER_LDFLAGS = ( - "-framework", - Foundation, - "-framework", - AppKit, - ); - PREBINDING = NO; - PRODUCT_NAME = LoadIrrFile_dbg; - WRAPPER_EXTENSION = app; - ZERO_LINK = YES; - }; - name = Debug; - }; - 09F6493D0D2CE03E001E0599 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEAD_CODE_STRIPPING = YES; - DEPLOYMENT_LOCATION = YES; - DEPLOYMENT_POSTPROCESSING = YES; - DSTROOT = ../../../bin/MacOSX; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_MODEL_TUNING = G5; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "DemoApp-Info.plist"; - INSTALL_PATH = /; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(LIBRARY_SEARCH_PATHS_QUOTED_1)", - ); - LIBRARY_SEARCH_PATHS_QUOTED_1 = "\"$(SRCROOT)/build/Debug\""; - ONLY_LINK_ESSENTIAL_SYMBOLS = YES; - OTHER_LDFLAGS = ( - "-framework", - Foundation, - "-framework", - AppKit, - ); - PREBINDING = NO; - PRODUCT_NAME = LoadIrrFile; - SEPARATE_STRIP = YES; - STRIP_INSTALLED_PRODUCT = YES; - WRAPPER_EXTENSION = app; - ZERO_LINK = NO; - }; - name = Release; - }; - 09F649630D2CE206001E0599 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - DEPLOYMENT_LOCATION = YES; - DSTROOT = ../../../bin/MacOSX; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_MODEL_TUNING = G5; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "DemoApp-Info.plist"; - INSTALL_PATH = /; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(LIBRARY_SEARCH_PATHS_QUOTED_1)", - ); - LIBRARY_SEARCH_PATHS_QUOTED_1 = "\"$(SRCROOT)/build/Debug\""; - OTHER_LDFLAGS = ( - "-framework", - Foundation, - "-framework", - AppKit, - ); - PREBINDING = NO; - PRODUCT_NAME = Quake3Shader_dbg; - WRAPPER_EXTENSION = app; - ZERO_LINK = YES; - }; - name = Debug; - }; - 09F649640D2CE206001E0599 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEAD_CODE_STRIPPING = YES; - DEPLOYMENT_LOCATION = YES; - DEPLOYMENT_POSTPROCESSING = YES; - DSTROOT = ../../../bin/MacOSX; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_MODEL_TUNING = G5; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "DemoApp-Info.plist"; - INSTALL_PATH = /; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(LIBRARY_SEARCH_PATHS_QUOTED_1)", - ); - LIBRARY_SEARCH_PATHS_QUOTED_1 = "\"$(SRCROOT)/build/Debug\""; - ONLY_LINK_ESSENTIAL_SYMBOLS = YES; - OTHER_LDFLAGS = ( - "-framework", - Foundation, - "-framework", - AppKit, - ); - PREBINDING = NO; - PRODUCT_NAME = Quake3Shader; - SEPARATE_STRIP = YES; - STRIP_INSTALLED_PRODUCT = YES; - WRAPPER_EXTENSION = app; - ZERO_LINK = NO; - }; - name = Release; - }; - 1DEB921F08733DC00010E9CD /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ( - ppc, - i386, - ); - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_MODEL_TUNING = G5; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = MacOSX_Prefix.pch; - INSTALL_PATH = /usr/local/lib; - PRODUCT_NAME = Irrlicht; - SYMROOT = build; - ZERO_LINK = NO; - }; - name = Debug; - }; - 1DEB922008733DC00010E9CD /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ( - ppc, - i386, - ); - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_MODEL_TUNING = G5; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = MacOSX_Prefix.pch; - INSTALL_PATH = /usr/local/lib; - PRODUCT_NAME = Irrlicht; - }; - name = Release; - }; - 1DEB922308733DC00010E9CD /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ( - ppc, - i386, - ); - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_UNUSED_VARIABLE = NO; - HEADER_SEARCH_PATHS = ../../../include; - OTHER_CFLAGS = ( - "-DMACOSX", - "-D_DEBUG", - ); - PREBINDING = NO; - SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; - }; - name = Debug; - }; - 1DEB922408733DC00010E9CD /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ( - ppc, - i386, - ); - GCC_DYNAMIC_NO_PIC = YES; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_INLINES_ARE_PRIVATE_EXTERN = YES; - GCC_OPTIMIZATION_LEVEL = 3; - GCC_SYMBOLS_PRIVATE_EXTERN = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_UNUSED_VARIABLE = NO; - HEADER_SEARCH_PATHS = ../../../include; - INSTALL_MODE_FLAG = "a+rwx"; - OTHER_CFLAGS = "-DMACOSX"; - PREBINDING = NO; - SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; - }; - name = Release; - }; - B81CFE0D097FD9F50057C06F /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - DEPLOYMENT_LOCATION = YES; - DSTROOT = ../../../bin/MacOSX; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_MODEL_TUNING = G5; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "DemoApp-Info.plist"; - INSTALL_PATH = /; - OTHER_LDFLAGS = ( - "-framework", - Foundation, - "-framework", - AppKit, - ); - PREBINDING = NO; - PRODUCT_NAME = 2DGraphics_dbg; - WRAPPER_EXTENSION = app; - ZERO_LINK = YES; - }; - name = Debug; - }; - B81CFE0E097FD9F50057C06F /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEAD_CODE_STRIPPING = YES; - DEPLOYMENT_LOCATION = YES; - DEPLOYMENT_POSTPROCESSING = YES; - DSTROOT = ../../../bin/MacOSX; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_MODEL_TUNING = G5; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "DemoApp-Info.plist"; - INSTALL_PATH = /; - ONLY_LINK_ESSENTIAL_SYMBOLS = YES; - OTHER_LDFLAGS = ( - "-framework", - Foundation, - "-framework", - AppKit, - ); - PREBINDING = NO; - PRODUCT_NAME = 2DGraphics; - SEPARATE_STRIP = YES; - STRIP_INSTALLED_PRODUCT = YES; - WRAPPER_EXTENSION = app; - ZERO_LINK = NO; - }; - name = Release; - }; - B81CFE8E097FDDE20057C06F /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - DEPLOYMENT_LOCATION = YES; - DSTROOT = ../../../bin/MacOSX; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_MODEL_TUNING = G5; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "DemoApp-Info.plist"; - INSTALL_PATH = /; - OTHER_LDFLAGS = ( - "-framework", - Foundation, - "-framework", - AppKit, - ); - PREBINDING = NO; - PRODUCT_NAME = Collision_dbg; - WRAPPER_EXTENSION = app; - ZERO_LINK = YES; - }; - name = Debug; - }; - B81CFE8F097FDDE20057C06F /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEAD_CODE_STRIPPING = YES; - DEPLOYMENT_LOCATION = YES; - DEPLOYMENT_POSTPROCESSING = YES; - DSTROOT = ../../../bin/MacOSX; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_MODEL_TUNING = G5; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "DemoApp-Info.plist"; - INSTALL_PATH = /; - ONLY_LINK_ESSENTIAL_SYMBOLS = YES; - OTHER_LDFLAGS = ( - "-framework", - Foundation, - "-framework", - AppKit, - ); - PREBINDING = NO; - PRODUCT_NAME = Collision; - SEPARATE_STRIP = YES; - STRIP_INSTALLED_PRODUCT = YES; - WRAPPER_EXTENSION = app; - ZERO_LINK = NO; - }; - name = Release; - }; - B81CFEB0097FDE900057C06F /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - DEPLOYMENT_LOCATION = YES; - DSTROOT = ../../../bin/MacOSX; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_MODEL_TUNING = G5; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "DemoApp-Info.plist"; - INSTALL_PATH = /; - OTHER_LDFLAGS = ( - "-framework", - Foundation, - "-framework", - AppKit, - ); - PREBINDING = NO; - PRODUCT_NAME = PerPixelLighting_dbg; - WRAPPER_EXTENSION = app; - ZERO_LINK = YES; - }; - name = Debug; - }; - B81CFEB1097FDE900057C06F /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEAD_CODE_STRIPPING = YES; - DEPLOYMENT_LOCATION = YES; - DEPLOYMENT_POSTPROCESSING = YES; - DSTROOT = ../../../bin/MacOSX; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_MODEL_TUNING = G5; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "DemoApp-Info.plist"; - INSTALL_MODE_FLAG = "a+rwx"; - INSTALL_PATH = /; - ONLY_LINK_ESSENTIAL_SYMBOLS = YES; - OTHER_LDFLAGS = ( - "-framework", - Foundation, - "-framework", - AppKit, - ); - PREBINDING = NO; - PRODUCT_NAME = PerPixelLighting; - SEPARATE_STRIP = YES; - STRIP_INSTALLED_PRODUCT = YES; - WRAPPER_EXTENSION = app; - ZERO_LINK = NO; - }; - name = Release; - }; - B81CFECE097FDF020057C06F /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - DEPLOYMENT_LOCATION = YES; - DSTROOT = ../../../bin/MacOSX; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_MODEL_TUNING = G5; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "DemoApp-Info.plist"; - INSTALL_PATH = /; - OTHER_LDFLAGS = ( - "-framework", - Foundation, - "-framework", - AppKit, - ); - PREBINDING = NO; - PRODUCT_NAME = TerrainRendering_dbg; - WRAPPER_EXTENSION = app; - ZERO_LINK = YES; - }; - name = Debug; - }; - B81CFECF097FDF020057C06F /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEAD_CODE_STRIPPING = YES; - DEPLOYMENT_LOCATION = YES; - DEPLOYMENT_POSTPROCESSING = YES; - DSTROOT = ../../../bin/MacOSX; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_MODEL_TUNING = G5; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "DemoApp-Info.plist"; - INSTALL_PATH = /; - ONLY_LINK_ESSENTIAL_SYMBOLS = YES; - OTHER_LDFLAGS = ( - "-framework", - Foundation, - "-framework", - AppKit, - ); - PREBINDING = NO; - PRODUCT_NAME = TerrainRendering; - SEPARATE_STRIP = YES; - STRIP_INSTALLED_PRODUCT = YES; - WRAPPER_EXTENSION = app; - ZERO_LINK = NO; - }; - name = Release; - }; - B81CFEF4097FE05F0057C06F /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - DEPLOYMENT_LOCATION = YES; - DSTROOT = ../../../bin/MacOSX; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_MODEL_TUNING = G5; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "DemoApp-Info.plist"; - INSTALL_PATH = /; - OTHER_LDFLAGS = ( - "-framework", - Foundation, - "-framework", - AppKit, - ); - PREBINDING = NO; - PRODUCT_NAME = SpecialFx_dbg; - WRAPPER_EXTENSION = app; - ZERO_LINK = YES; - }; - name = Debug; - }; - B81CFEF5097FE05F0057C06F /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEAD_CODE_STRIPPING = YES; - DEPLOYMENT_LOCATION = YES; - DEPLOYMENT_POSTPROCESSING = YES; - DSTROOT = ../../../bin/MacOSX; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_MODEL_TUNING = G5; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "DemoApp-Info.plist"; - INSTALL_PATH = /; - ONLY_LINK_ESSENTIAL_SYMBOLS = YES; - OTHER_LDFLAGS = ( - "-framework", - Foundation, - "-framework", - AppKit, - ); - PREBINDING = NO; - PRODUCT_NAME = SpecialFx; - SEPARATE_STRIP = YES; - STRIP_INSTALLED_PRODUCT = YES; - WRAPPER_EXTENSION = app; - ZERO_LINK = NO; - }; - name = Release; - }; - B81CFF13097FE13E0057C06F /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - DEPLOYMENT_LOCATION = YES; - DSTROOT = ../../../bin/MacOSX; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_MODEL_TUNING = G5; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "DemoApp-Info.plist"; - INSTALL_PATH = /; - OTHER_LDFLAGS = ( - "-framework", - Foundation, - "-framework", - AppKit, - ); - PREBINDING = NO; - PRODUCT_NAME = UserInterface_dbg; - WRAPPER_EXTENSION = app; - ZERO_LINK = YES; - }; - name = Debug; - }; - B81CFF14097FE13E0057C06F /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEAD_CODE_STRIPPING = YES; - DEPLOYMENT_LOCATION = YES; - DEPLOYMENT_POSTPROCESSING = YES; - DSTROOT = ../../../bin/MacOSX; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_MODEL_TUNING = G5; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "DemoApp-Info.plist"; - INSTALL_PATH = /; - ONLY_LINK_ESSENTIAL_SYMBOLS = YES; - OTHER_LDFLAGS = ( - "-framework", - Foundation, - "-framework", - AppKit, - ); - PREBINDING = NO; - PRODUCT_NAME = UserInterface; - SEPARATE_STRIP = YES; - STRIP_INSTALLED_PRODUCT = YES; - WRAPPER_EXTENSION = app; - ZERO_LINK = NO; - }; - name = Release; - }; - B81CFF2A097FE1E00057C06F /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - DEPLOYMENT_LOCATION = YES; - DSTROOT = ../../../bin/MacOSX; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_MODEL_TUNING = G5; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "DemoApp-Info.plist"; - INSTALL_PATH = /; - OTHER_LDFLAGS = ( - "-framework", - Foundation, - "-framework", - AppKit, - ); - PREBINDING = NO; - PRODUCT_NAME = CustomSceneNode_dbg; - WRAPPER_EXTENSION = app; - ZERO_LINK = YES; - }; - name = Debug; - }; - B81CFF2B097FE1E00057C06F /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEAD_CODE_STRIPPING = YES; - DEPLOYMENT_LOCATION = YES; - DEPLOYMENT_POSTPROCESSING = YES; - DSTROOT = ../../../bin/MacOSX; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_MODEL_TUNING = G5; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "DemoApp-Info.plist"; - INSTALL_PATH = /; - ONLY_LINK_ESSENTIAL_SYMBOLS = YES; - OTHER_LDFLAGS = ( - "-framework", - Foundation, - "-framework", - AppKit, - ); - PREBINDING = NO; - PRODUCT_NAME = CustomSceneNode; - SEPARATE_STRIP = YES; - STRIP_INSTALLED_PRODUCT = YES; - WRAPPER_EXTENSION = app; - ZERO_LINK = NO; - }; - name = Release; - }; - B81CFF3F097FE25F0057C06F /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - DEPLOYMENT_LOCATION = YES; - DSTROOT = ../../../bin/MacOSX; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_MODEL_TUNING = G5; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "DemoApp-Info.plist"; - INSTALL_PATH = /; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(LIBRARY_SEARCH_PATHS_QUOTED_1)", - ); - LIBRARY_SEARCH_PATHS_QUOTED_1 = "\"$(SRCROOT)/build/Debug\""; - OTHER_LDFLAGS = ( - "-framework", - Foundation, - "-framework", - AppKit, - ); - PREBINDING = NO; - PRODUCT_NAME = Quake3Map_dbg; - WRAPPER_EXTENSION = app; - ZERO_LINK = YES; - }; - name = Debug; - }; - B81CFF40097FE25F0057C06F /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEAD_CODE_STRIPPING = YES; - DEPLOYMENT_LOCATION = YES; - DEPLOYMENT_POSTPROCESSING = YES; - DSTROOT = ../../../bin/MacOSX; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_MODEL_TUNING = G5; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "DemoApp-Info.plist"; - INSTALL_PATH = /; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(LIBRARY_SEARCH_PATHS_QUOTED_1)", - ); - LIBRARY_SEARCH_PATHS_QUOTED_1 = "\"$(SRCROOT)/build/Debug\""; - ONLY_LINK_ESSENTIAL_SYMBOLS = YES; - OTHER_LDFLAGS = ( - "-framework", - Foundation, - "-framework", - AppKit, - ); - PREBINDING = NO; - PRODUCT_NAME = Quake3Map; - SEPARATE_STRIP = YES; - STRIP_INSTALLED_PRODUCT = YES; - WRAPPER_EXTENSION = app; - ZERO_LINK = NO; - }; - name = Release; - }; - B81CFF56097FE3050057C06F /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - DEPLOYMENT_LOCATION = YES; - DSTROOT = ../../../bin/MacOSX; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_MODEL_TUNING = G5; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "DemoApp-Info.plist"; - INSTALL_PATH = /; - OTHER_LDFLAGS = ( - "-framework", - Foundation, - "-framework", - AppKit, - ); - PREBINDING = NO; - PRODUCT_NAME = Shaders_dbg; - WRAPPER_EXTENSION = app; - ZERO_LINK = YES; - }; - name = Debug; - }; - B81CFF57097FE3050057C06F /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEAD_CODE_STRIPPING = YES; - DEPLOYMENT_LOCATION = YES; - DEPLOYMENT_POSTPROCESSING = YES; - DSTROOT = ../../../bin/MacOSX; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_MODEL_TUNING = G5; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "DemoApp-Info.plist"; - INSTALL_PATH = /; - ONLY_LINK_ESSENTIAL_SYMBOLS = YES; - OTHER_LDFLAGS = ( - "-framework", - Foundation, - "-framework", - AppKit, - ); - PREBINDING = NO; - PRODUCT_NAME = Shaders; - SEPARATE_STRIP = YES; - STRIP_INSTALLED_PRODUCT = YES; - WRAPPER_EXTENSION = app; - ZERO_LINK = NO; - }; - name = Release; - }; - B81CFF84097FE3DC0057C06F /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ( - ppc, - i386, - ); - COPY_PHASE_STRIP = NO; - DEPLOYMENT_LOCATION = YES; - DSTROOT = ../../../bin/MacOSX; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_MODEL_TUNING = G5; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "DemoApp-Info.plist"; - INSTALL_PATH = /; - OTHER_LDFLAGS = ( - "-framework", - Foundation, - "-framework", - AppKit, - ); - PREBINDING = NO; - PRODUCT_NAME = Movement_dbg; - WRAPPER_EXTENSION = app; - ZERO_LINK = YES; - }; - name = Debug; - }; - B81CFF85097FE3DC0057C06F /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ( - ppc, - i386, - ); - COPY_PHASE_STRIP = YES; - DEAD_CODE_STRIPPING = YES; - DEPLOYMENT_LOCATION = YES; - DEPLOYMENT_POSTPROCESSING = YES; - DSTROOT = ../../../bin/MacOSX; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_MODEL_TUNING = G5; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "DemoApp-Info.plist"; - INSTALL_PATH = /; - ONLY_LINK_ESSENTIAL_SYMBOLS = YES; - OTHER_LDFLAGS = ( - "-framework", - Foundation, - "-framework", - AppKit, - ); - PREBINDING = NO; - PRODUCT_NAME = Movement; - SEPARATE_STRIP = YES; - STRIP_INSTALLED_PRODUCT = YES; - WRAPPER_EXTENSION = app; - ZERO_LINK = NO; - }; - name = Release; - }; - B81CFF9D097FE45E0057C06F /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - DEPLOYMENT_LOCATION = YES; - DSTROOT = ../../../bin/MacOSX; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_MODEL_TUNING = G5; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "DemoApp-Info.plist"; - INSTALL_PATH = /; - OTHER_LDFLAGS = ( - "-framework", - Foundation, - "-framework", - AppKit, - ); - PREBINDING = NO; - PRODUCT_NAME = MeshViewer_dbg; - WRAPPER_EXTENSION = app; - ZERO_LINK = YES; - }; - name = Debug; - }; - B81CFF9E097FE45E0057C06F /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEAD_CODE_STRIPPING = YES; - DEPLOYMENT_LOCATION = YES; - DEPLOYMENT_POSTPROCESSING = YES; - DSTROOT = ../../../bin/MacOSX; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_MODEL_TUNING = G5; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "DemoApp-Info.plist"; - INSTALL_PATH = /; - ONLY_LINK_ESSENTIAL_SYMBOLS = YES; - OTHER_LDFLAGS = ( - "-framework", - Foundation, - "-framework", - AppKit, - ); - PREBINDING = NO; - PRODUCT_NAME = MeshViewer; - SEPARATE_STRIP = YES; - STRIP_INSTALLED_PRODUCT = YES; - WRAPPER_EXTENSION = app; - ZERO_LINK = NO; - }; - name = Release; - }; - B81CFFBB097FE5F80057C06F /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - DEPLOYMENT_LOCATION = YES; - DSTROOT = ../../../bin/MacOSX; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_MODEL_TUNING = G5; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "DemoApp-Info.plist"; - INSTALL_PATH = /; - OTHER_LDFLAGS = ( - "-framework", - Foundation, - "-framework", - AppKit, - ); - PREBINDING = NO; - PRODUCT_NAME = RenderToTexture_dbg; - WRAPPER_EXTENSION = app; - ZERO_LINK = YES; - }; - name = Debug; - }; - B81CFFBC097FE5F80057C06F /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEAD_CODE_STRIPPING = YES; - DEPLOYMENT_LOCATION = YES; - DEPLOYMENT_POSTPROCESSING = YES; - DSTROOT = ../../../bin/MacOSX; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_MODEL_TUNING = G5; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "DemoApp-Info.plist"; - INSTALL_PATH = /; - ONLY_LINK_ESSENTIAL_SYMBOLS = YES; - OTHER_LDFLAGS = ( - "-framework", - Foundation, - "-framework", - AppKit, - ); - PREBINDING = NO; - PRODUCT_NAME = RenderToTexture; - SEPARATE_STRIP = YES; - STRIP_INSTALLED_PRODUCT = YES; - WRAPPER_EXTENSION = app; - ZERO_LINK = NO; - }; - name = Release; - }; - B81CFFE9097FE9C30057C06F /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - PRODUCT_NAME = ALL; - }; - name = Debug; - }; - B81CFFEA097FE9C30057C06F /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - PRODUCT_NAME = ALL; - ZERO_LINK = NO; - }; - name = Release; - }; - B8DEF3610950229300FDEA7E /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - DEPLOYMENT_LOCATION = YES; - DSTROOT = ../../../bin/MacOSX; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_MODEL_TUNING = G5; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "DemoApp-Info.plist"; - INSTALL_PATH = /; - OTHER_LDFLAGS = ( - "-framework", - Foundation, - "-framework", - AppKit, - ); - PREBINDING = NO; - PRODUCT_NAME = Demo_dbg; - WRAPPER_EXTENSION = app; - ZERO_LINK = YES; - }; - name = Debug; - }; - B8DEF3620950229300FDEA7E /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEAD_CODE_STRIPPING = YES; - DEPLOYMENT_LOCATION = YES; - DEPLOYMENT_POSTPROCESSING = YES; - DSTROOT = ../../../bin/MacOSX; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_MODEL_TUNING = G5; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "DemoApp-Info.plist"; - INSTALL_PATH = /; - ONLY_LINK_ESSENTIAL_SYMBOLS = YES; - OTHER_LDFLAGS = ( - "-framework", - Foundation, - "-framework", - AppKit, - ); - PREBINDING = NO; - PRODUCT_NAME = Demo; - SEPARATE_STRIP = YES; - STRIP_INSTALLED_PRODUCT = YES; - WRAPPER_EXTENSION = app; - ZERO_LINK = NO; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 09022C5F0EA0E97F00CD54EE /* Build configuration list for PBXNativeTarget "GUIEditor" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 09022C600EA0E97F00CD54EE /* Debug */, - 09022C610EA0E97F00CD54EE /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 0946CCB10EC99BBE00D945A5 /* Build configuration list for PBXNativeTarget "19.MouseAndJoystick" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 0946CCB20EC99BBE00D945A5 /* Debug */, - 0946CCB30EC99BBE00D945A5 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 09F649000D2CDED9001E0599 /* Build configuration list for PBXNativeTarget "01.HelloWorld" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 09F649010D2CDED9001E0599 /* Debug */, - 09F649020D2CDED9001E0599 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 09F6493B0D2CE03E001E0599 /* Build configuration list for PBXNativeTarget "15.LoadIrrFile" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 09F6493C0D2CE03E001E0599 /* Debug */, - 09F6493D0D2CE03E001E0599 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 09F649620D2CE206001E0599 /* Build configuration list for PBXNativeTarget "16.Quake3Shader" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 09F649630D2CE206001E0599 /* Debug */, - 09F649640D2CE206001E0599 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 1DEB921E08733DC00010E9CD /* Build configuration list for PBXNativeTarget "libIrrlicht.a" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 1DEB921F08733DC00010E9CD /* Debug */, - 1DEB922008733DC00010E9CD /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 1DEB922208733DC00010E9CD /* Build configuration list for PBXProject "MacOSX" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 1DEB922308733DC00010E9CD /* Debug */, - 1DEB922408733DC00010E9CD /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - B81CFE0C097FD9F50057C06F /* Build configuration list for PBXNativeTarget "06.2DGraphics" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - B81CFE0D097FD9F50057C06F /* Debug */, - B81CFE0E097FD9F50057C06F /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - B81CFE8D097FDDE20057C06F /* Build configuration list for PBXNativeTarget "07.Collision" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - B81CFE8E097FDDE20057C06F /* Debug */, - B81CFE8F097FDDE20057C06F /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - B81CFEAF097FDE900057C06F /* Build configuration list for PBXNativeTarget "11.PerPixelLightning" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - B81CFEB0097FDE900057C06F /* Debug */, - B81CFEB1097FDE900057C06F /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - B81CFECD097FDF020057C06F /* Build configuration list for PBXNativeTarget "12.TerrainRendering" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - B81CFECE097FDF020057C06F /* Debug */, - B81CFECF097FDF020057C06F /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - B81CFEF3097FE05F0057C06F /* Build configuration list for PBXNativeTarget "08.SpecialFx" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - B81CFEF4097FE05F0057C06F /* Debug */, - B81CFEF5097FE05F0057C06F /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - B81CFF12097FE13E0057C06F /* Build configuration list for PBXNativeTarget "05.UserInterface" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - B81CFF13097FE13E0057C06F /* Debug */, - B81CFF14097FE13E0057C06F /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - B81CFF29097FE1E00057C06F /* Build configuration list for PBXNativeTarget "03.CustomSceneNode" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - B81CFF2A097FE1E00057C06F /* Debug */, - B81CFF2B097FE1E00057C06F /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - B81CFF3E097FE25F0057C06F /* Build configuration list for PBXNativeTarget "02.Quake3Map" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - B81CFF3F097FE25F0057C06F /* Debug */, - B81CFF40097FE25F0057C06F /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - B81CFF55097FE3050057C06F /* Build configuration list for PBXNativeTarget "10.Shaders" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - B81CFF56097FE3050057C06F /* Debug */, - B81CFF57097FE3050057C06F /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - B81CFF83097FE3DC0057C06F /* Build configuration list for PBXNativeTarget "04.Movement" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - B81CFF84097FE3DC0057C06F /* Debug */, - B81CFF85097FE3DC0057C06F /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - B81CFF9C097FE45E0057C06F /* Build configuration list for PBXNativeTarget "09.MeshViewer" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - B81CFF9D097FE45E0057C06F /* Debug */, - B81CFF9E097FE45E0057C06F /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - B81CFFBA097FE5F80057C06F /* Build configuration list for PBXNativeTarget "13.RenderToTexture" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - B81CFFBB097FE5F80057C06F /* Debug */, - B81CFFBC097FE5F80057C06F /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - B81CFFE8097FE9C30057C06F /* Build configuration list for PBXAggregateTarget "All" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - B81CFFE9097FE9C30057C06F /* Debug */, - B81CFFEA097FE9C30057C06F /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - B8DEF3600950229300FDEA7E /* Build configuration list for PBXNativeTarget "Demo" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - B8DEF3610950229300FDEA7E /* Debug */, - B8DEF3620950229300FDEA7E /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 0867D690FE84028FC02AAC07 /* Project object */; -} diff --git a/irrlicht-1.6/source/Irrlicht/MacOSX/MacOSX_Prefix.pch b/irrlicht-1.6/source/Irrlicht/MacOSX/MacOSX_Prefix.pch deleted file mode 100644 index b3ea1099a..000000000 --- a/irrlicht-1.6/source/Irrlicht/MacOSX/MacOSX_Prefix.pch +++ /dev/null @@ -1,5 +0,0 @@ -// -// Prefix header for all source files of the 'MacOSX' target in the 'MacOSX' project. -// - -#include <architecture/byte_order.h> diff --git a/irrlicht-1.6/source/Irrlicht/MacOSX/MainMenu.nib/classes.nib b/irrlicht-1.6/source/Irrlicht/MacOSX/MainMenu.nib/classes.nib deleted file mode 100644 index b9b4b09f6..000000000 --- a/irrlicht-1.6/source/Irrlicht/MacOSX/MainMenu.nib/classes.nib +++ /dev/null @@ -1,4 +0,0 @@ -{ - IBClasses = ({CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }); - IBVersion = 1; -} \ No newline at end of file diff --git a/irrlicht-1.6/source/Irrlicht/MacOSX/MainMenu.nib/info.nib b/irrlicht-1.6/source/Irrlicht/MacOSX/MainMenu.nib/info.nib deleted file mode 100644 index d4de41f96..000000000 --- a/irrlicht-1.6/source/Irrlicht/MacOSX/MainMenu.nib/info.nib +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> -<plist version="1.0"> -<dict> - <key>IBDocumentLocation</key> - <string>195 413 356 240 0 0 1680 1028 </string> - <key>IBEditorPositions</key> - <dict> - <key>29</key> - <string>62 343 338 44 0 0 1680 1028 </string> - </dict> - <key>IBFramework Version</key> - <string>443.0</string> - <key>IBSystem Version</key> - <string>8F46</string> -</dict> -</plist> diff --git a/irrlicht-1.6/source/Irrlicht/MacOSX/MainMenu.nib/keyedobjects.nib b/irrlicht-1.6/source/Irrlicht/MacOSX/MainMenu.nib/keyedobjects.nib deleted file mode 100644 index 1a561028d..000000000 Binary files a/irrlicht-1.6/source/Irrlicht/MacOSX/MainMenu.nib/keyedobjects.nib and /dev/null differ diff --git a/irrlicht-1.6/source/Irrlicht/MacOSX/OSXClipboard.h b/irrlicht-1.6/source/Irrlicht/MacOSX/OSXClipboard.h deleted file mode 100644 index eeb0c962d..000000000 --- a/irrlicht-1.6/source/Irrlicht/MacOSX/OSXClipboard.h +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2005-2009 Etienne Petitjean -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in Irrlicht.h - -#ifdef __cplusplus -extern "C" { -#endif - - void OSXCopyToClipboard(const char *text); - char* OSXCopyFromClipboard(); - -#ifdef __cplusplus -} -#endif diff --git a/irrlicht-1.6/source/Irrlicht/MacOSX/OSXClipboard.mm b/irrlicht-1.6/source/Irrlicht/MacOSX/OSXClipboard.mm deleted file mode 100644 index 7a23ef227..000000000 --- a/irrlicht-1.6/source/Irrlicht/MacOSX/OSXClipboard.mm +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2005-2009 Etienne Petitjean -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in Irrlicht.h - -#include "OSXClipboard.h" -#import <Cocoa/Cocoa.h> - -void OSXCopyToClipboard(const char *text) -{ - NSString *str; - NSPasteboard *board; - - if (text != NULL && strlen(text) > 0) - { - str = [NSString stringWithCString:text encoding:NSWindowsCP1252StringEncoding]; - board = [NSPasteboard generalPasteboard]; - [board declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:NSApp]; - [board setString:str forType:NSStringPboardType]; - } -} - -char* OSXCopyFromClipboard() -{ - NSString *str; - NSPasteboard *board; - char *result; - - result = NULL; - board = [NSPasteboard generalPasteboard]; - str = [board stringForType:NSStringPboardType]; - if (str != nil) result = (char*)[str cStringUsingEncoding:NSWindowsCP1252StringEncoding]; - return (result); -} diff --git a/irrlicht-1.6/source/Irrlicht/OctTree.h b/irrlicht-1.6/source/Irrlicht/OctTree.h deleted file mode 100644 index 05600eae7..000000000 --- a/irrlicht-1.6/source/Irrlicht/OctTree.h +++ /dev/null @@ -1,404 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_OCT_TREE_H_INCLUDED__ -#define __C_OCT_TREE_H_INCLUDED__ - -#include "SViewFrustum.h" -#include "S3DVertex.h" -#include "aabbox3d.h" -#include "irrArray.h" -#include "CMeshBuffer.h" - -/*! - Flags for Octtree -*/ -#define OCTTREE_USE_HARDWARE // use meshbuffer for drawing, enables hardware acceleration -#define OCTTREE_PARENTTEST // bypass full invisible/visible test -#define OCTTREE_BOX_BASED // use bounding box or frustum for calculate polys - -namespace irr -{ - -//! template octtree. -/** T must be a vertex type which has a member -called .Pos, which is a core::vertex3df position. */ -template <class T> -class OctTree -{ -public: - -#if defined (OCTTREE_USE_HARDWARE) - struct SMeshChunk : public scene::CMeshBuffer<T> - { - SMeshChunk () - : scene::CMeshBuffer<T>(), MaterialId(0) - { - scene::CMeshBuffer<T>::grab(); - } - - virtual ~SMeshChunk () - { - //removeAllHardwareBuffers - } - - s32 MaterialId; - }; -#else - struct SMeshChunk - { - core::array<T> Vertices; - core::array<u16> Indices; - s32 MaterialId; - }; -#endif - - struct SIndexChunk - { - core::array<u16> Indices; - s32 MaterialId; - }; - - struct SIndexData - { - u16* Indices; - s32 CurrentSize; - s32 MaxSize; - }; - - - //! Constructor - OctTree(const core::array<SMeshChunk>& meshes, s32 minimalPolysPerNode=128) : - IndexData(0), IndexDataCount(meshes.size()), NodeCount(0) - { - IndexData = new SIndexData[IndexDataCount]; - - // construct array of all indices - - core::array<SIndexChunk>* indexChunks = new core::array<SIndexChunk>; - indexChunks->reallocate(meshes.size()); - for (u32 i=0; i!=meshes.size(); ++i) - { - IndexData[i].CurrentSize = 0; - IndexData[i].MaxSize = meshes[i].Indices.size(); - IndexData[i].Indices = new u16[IndexData[i].MaxSize]; - - indexChunks->push_back(SIndexChunk()); - SIndexChunk& tic = indexChunks->getLast(); - - tic.MaterialId = meshes[i].MaterialId; - tic.Indices = meshes[i].Indices; - } - - // create tree - Root = new OctTreeNode(NodeCount, 0, meshes, indexChunks, minimalPolysPerNode); - } - - //! returns all ids of polygons partially or fully enclosed - //! by this bounding box. - void calculatePolys(const core::aabbox3d<f32>& box) - { - for (u32 i=0; i!=IndexDataCount; ++i) - IndexData[i].CurrentSize = 0; - - Root->getPolys(box, IndexData, 0); - } - - //! returns all ids of polygons partially or fully enclosed - //! by a view frustum. - void calculatePolys(const scene::SViewFrustum& frustum) - { - for (u32 i=0; i!=IndexDataCount; ++i) - IndexData[i].CurrentSize = 0; - - Root->getPolys(frustum, IndexData, 0); - } - - const SIndexData* getIndexData() const - { - return IndexData; - } - - u32 getIndexDataCount() const - { - return IndexDataCount; - } - - u32 getNodeCount() const - { - return NodeCount; - } - - //! for debug purposes only, collects the bounding boxes of the tree - void getBoundingBoxes(const core::aabbox3d<f32>& box, - core::array< const core::aabbox3d<f32>* >&outBoxes) const - { - Root->getBoundingBoxes(box, outBoxes); - } - - //! destructor - ~OctTree() - { - for (u32 i=0; i<IndexDataCount; ++i) - delete [] IndexData[i].Indices; - - delete [] IndexData; - delete Root; - } - -private: - // private inner class - class OctTreeNode - { - public: - - // constructor - OctTreeNode(u32& nodeCount, u32 currentdepth, - const core::array<SMeshChunk>& allmeshdata, - core::array<SIndexChunk>* indices, - s32 minimalPolysPerNode) : IndexData(0), - Depth(currentdepth+1) - { - ++nodeCount; - - u32 i; // new ISO for scoping problem with different compilers - - for (i=0; i!=8; ++i) - Children[i] = 0; - - if (indices->empty()) - { - delete indices; - return; - } - - bool found = false; - - // find first point for bounding box - - for (i=0; i<indices->size(); ++i) - { - if (!(*indices)[i].Indices.empty()) - { - Box.reset(allmeshdata[i].Vertices[(*indices)[i].Indices[0]].Pos); - found = true; - break; - } - } - - if (!found) - { - delete indices; - return; - } - - s32 totalPrimitives = 0; - - // now lets calculate our bounding box - for (i=0; i<indices->size(); ++i) - { - totalPrimitives += (*indices)[i].Indices.size(); - for (u32 j=0; j<(*indices)[i].Indices.size(); ++j) - Box.addInternalPoint(allmeshdata[i].Vertices[(*indices)[i].Indices[j]].Pos); - } - - core::vector3df middle = Box.getCenter(); - core::vector3df edges[8]; - Box.getEdges(edges); - - // calculate all children - core::aabbox3d<f32> box; - core::array<u16> keepIndices; - - if (totalPrimitives > minimalPolysPerNode && !Box.isEmpty()) - for (u32 ch=0; ch!=8; ++ch) - { - box.reset(middle); - box.addInternalPoint(edges[ch]); - - // create indices for child - bool added = false; - core::array<SIndexChunk>* cindexChunks = new core::array<SIndexChunk>; - cindexChunks->reallocate(allmeshdata.size()); - for (i=0; i<allmeshdata.size(); ++i) - { - cindexChunks->push_back(SIndexChunk()); - SIndexChunk& tic = cindexChunks->getLast(); - tic.MaterialId = allmeshdata[i].MaterialId; - - for (u32 t=0; t<(*indices)[i].Indices.size(); t+=3) - { - if (box.isPointInside(allmeshdata[i].Vertices[(*indices)[i].Indices[t]].Pos) && - box.isPointInside(allmeshdata[i].Vertices[(*indices)[i].Indices[t+1]].Pos) && - box.isPointInside(allmeshdata[i].Vertices[(*indices)[i].Indices[t+2]].Pos)) - { - tic.Indices.push_back((*indices)[i].Indices[t]); - tic.Indices.push_back((*indices)[i].Indices[t+1]); - tic.Indices.push_back((*indices)[i].Indices[t+2]); - - added = true; - } - else - { - keepIndices.push_back((*indices)[i].Indices[t]); - keepIndices.push_back((*indices)[i].Indices[t+1]); - keepIndices.push_back((*indices)[i].Indices[t+2]); - } - } - - memcpy( (*indices)[i].Indices.pointer(), keepIndices.pointer(), keepIndices.size()*sizeof(u16)); - (*indices)[i].Indices.set_used(keepIndices.size()); - keepIndices.set_used(0); - } - - if (added) - Children[ch] = new OctTreeNode(nodeCount, Depth, - allmeshdata, cindexChunks, minimalPolysPerNode); - else - delete cindexChunks; - - } // end for all possible children - - IndexData = indices; - } - - // destructor - ~OctTreeNode() - { - delete IndexData; - - for (u32 i=0; i<8; ++i) - delete Children[i]; - } - - // returns all ids of polygons partially or full enclosed - // by this bounding box. - void getPolys(const core::aabbox3d<f32>& box, SIndexData* idxdata, u32 parentTest ) const - { -#if defined (OCTTREE_PARENTTEST ) - // if not full inside - if ( parentTest != 2 ) - { - // partially inside ? - if (!Box.intersectsWithBox(box)) - return; - - // fully inside ? - parentTest = Box.isFullInside(box)?2:1; - } -#else - if (Box.intersectsWithBox(box)) -#endif - { - const u32 cnt = IndexData->size(); - u32 i; // new ISO for scoping problem in some compilers - - for (i=0; i<cnt; ++i) - { - const s32 idxcnt = (*IndexData)[i].Indices.size(); - - if (idxcnt) - { - memcpy(&idxdata[i].Indices[idxdata[i].CurrentSize], - &(*IndexData)[i].Indices[0], idxcnt * sizeof(s16)); - idxdata[i].CurrentSize += idxcnt; - } - } - - for (i=0; i!=8; ++i) - if (Children[i]) - Children[i]->getPolys(box, idxdata,parentTest); - } - } - - // returns all ids of polygons partially or full enclosed - // by the view frustum. - void getPolys(const scene::SViewFrustum& frustum, SIndexData* idxdata,u32 parentTest) const - { - u32 i; // new ISO for scoping problem in some compilers - - // if parent is fully inside, no further check for the children is needed -#if defined (OCTTREE_PARENTTEST ) - if ( parentTest != 2 ) -#endif - { - core::vector3df edges[8]; - Box.getEdges(edges); - - for (i=0; i!=scene::SViewFrustum::VF_PLANE_COUNT; ++i) - { - u32 boxInFrustum=0; - - for (u32 j=0; j!=8; ++j) - { - if (frustum.planes[i].classifyPointRelation(edges[j]) != core::ISREL3D_FRONT) - { - boxInFrustum += 1; -#if !defined (OCTTREE_PARENTTEST ) - break; -#endif - } - } - - if ( 0 == boxInFrustum) // all edges outside - return; - -#if defined (OCTTREE_PARENTTEST ) - if ( 8 == boxInFrustum) // all edges in, all children in - parentTest = 2; -#endif - } - } - - const u32 cnt = IndexData->size(); - - for (i=0; i!=cnt; ++i) - { - s32 idxcnt = (*IndexData)[i].Indices.size(); - - if (idxcnt) - { - memcpy(&idxdata[i].Indices[idxdata[i].CurrentSize], - &(*IndexData)[i].Indices[0], idxcnt * sizeof(s16)); - idxdata[i].CurrentSize += idxcnt; - } - } - - for (i=0; i!=8; ++i) - if (Children[i]) - Children[i]->getPolys(frustum, idxdata,parentTest); - } - - //! for debug purposes only, collects the bounding boxes of the node - void getBoundingBoxes(const core::aabbox3d<f32>& box, - core::array< const core::aabbox3d<f32>* >&outBoxes) const - { - if (Box.intersectsWithBox(box)) - { - outBoxes.push_back(&Box); - - for (u32 i=0; i!=8; ++i) - if (Children[i]) - Children[i]->getBoundingBoxes(box, outBoxes); - } - } - - private: - - core::aabbox3df Box; - core::array<SIndexChunk>* IndexData; - OctTreeNode* Children[8]; - u32 Depth; - }; - - OctTreeNode* Root; - SIndexData* IndexData; - u32 IndexDataCount; - u32 NodeCount; -}; - -} // end namespace - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/S2DVertex.h b/irrlicht-1.6/source/Irrlicht/S2DVertex.h deleted file mode 100644 index 79b2caba7..000000000 --- a/irrlicht-1.6/source/Irrlicht/S2DVertex.h +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __S_K_2D_VERTEX_H_INCLUDED__ -#define __S_K_2D_VERTEX_H_INCLUDED__ - -#include "vector2d.h" - -typedef signed short TZBufferType; - -namespace irr -{ -namespace video -{ - - struct S2DVertex - { - core::vector2d<s32> Pos; // position - core::vector2d<s32> TCoords; // texture coordinates - TZBufferType ZValue; // zvalue - u16 Color; - }; - - -} // end namespace video -} // end namespace irr - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/S4DVertex.h b/irrlicht-1.6/source/Irrlicht/S4DVertex.h deleted file mode 100644 index 57472ab89..000000000 --- a/irrlicht-1.6/source/Irrlicht/S4DVertex.h +++ /dev/null @@ -1,596 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - - -#ifndef __S_4D_VERTEX_H_INCLUDED__ -#define __S_4D_VERTEX_H_INCLUDED__ - -#include "SoftwareDriver2_compile_config.h" -#include "SoftwareDriver2_helper.h" -#include "irrAllocator.h" - -namespace irr -{ - -namespace video -{ - -struct sVec2 -{ - f32 x; - f32 y; - - sVec2 () {} - - sVec2 ( f32 _x, f32 _y ) - : x ( _x ), y ( _y ) {} - - void set ( f32 _x, f32 _y ) - { - x = _x; - y = _y; - } - - // f = a * t + b * ( 1 - t ) - void interpolate(const sVec2& a, const sVec2& b, const f32 t) - { - x = b.x + ( ( a.x - b.x ) * t ); - y = b.y + ( ( a.y - b.y ) * t ); - } - - sVec2 operator-(const sVec2& other) const - { - return sVec2(x - other.x, y - other.y); - } - - sVec2 operator+(const sVec2& other) const - { - return sVec2(x + other.x, y + other.y); - } - - void operator+=(const sVec2& other) - { - x += other.x; - y += other.y; - } - - sVec2 operator*(const f32 s) const - { - return sVec2(x * s , y * s); - } - - void operator*=( const f32 s) - { - x *= s; - y *= s; - } - - void operator=(const sVec2& other) - { - x = other.x; - y = other.y; - } - -}; - -// A8R8G8B8 -struct sVec4; -struct sCompressedVec4 -{ - u32 argb; - - void setA8R8G8B8 ( u32 value ) - { - argb = value; - } - - void setColorf ( const video::SColorf & color ) - { - argb = core::floor32 ( color.a * 255.f ) << 24 | - core::floor32 ( color.r * 255.f ) << 16 | - core::floor32 ( color.g * 255.f ) << 8 | - core::floor32 ( color.b * 255.f ); - } - - void setVec4 ( const sVec4 & v ); - - // f = a * t + b * ( 1 - t ) - void interpolate(const sCompressedVec4& a, const sCompressedVec4& b, const f32 t) - { - argb = PixelBlend32 ( b.argb, a.argb, core::floor32 ( t * 256.f ) ); - } - - -}; - - -struct sVec4 -{ - f32 x, y, z, w; - - sVec4 () {} - - sVec4 ( f32 _x, f32 _y, f32 _z, f32 _w ) - : x ( _x ), y ( _y ), z( _z ), w ( _w ){} - - void set ( f32 _x, f32 _y, f32 _z, f32 _w ) - { - x = _x; - y = _y; - z = _z; - w = _w; - } - - void setA8R8G8B8 ( u32 argb ) - { - x = ( ( argb & 0xFF000000 ) >> 24 ) * ( 1.f / 255.f ); - y = ( ( argb & 0x00FF0000 ) >> 16 ) * ( 1.f / 255.f ); - z = ( ( argb & 0x0000FF00 ) >> 8 ) * ( 1.f / 255.f ); - w = ( ( argb & 0x000000FF ) ) * ( 1.f / 255.f ); - } - - - void setColorf ( const video::SColorf & color ) - { - x = color.a; - y = color.r; - z = color.g; - w = color.b; - } - - - // f = a * t + b * ( 1 - t ) - void interpolate(const sVec4& a, const sVec4& b, const f32 t) - { - x = b.x + ( ( a.x - b.x ) * t ); - y = b.y + ( ( a.y - b.y ) * t ); - z = b.z + ( ( a.z - b.z ) * t ); - w = b.w + ( ( a.w - b.w ) * t ); - } - - - f32 dotProduct(const sVec4& other) const - { - return x*other.x + y*other.y + z*other.z + w*other.w; - } - - f32 dot_xyz( const sVec4& other) const - { - return x*other.x + y*other.y + z*other.z; - } - - f32 get_length_xyz_square () const - { - return x * x + y * y + z * z; - } - - f32 get_length_xyz () const - { - return core::squareroot ( x * x + y * y + z * z ); - } - - void normalize_xyz () - { - const f32 l = core::reciprocal_squareroot ( x * x + y * y + z * z ); - - x *= l; - y *= l; - z *= l; - } - - void project_xyz () - { - w = core::reciprocal ( w ); - x *= w; - y *= w; - z *= w; - } - - sVec4 operator-(const sVec4& other) const - { - return sVec4(x - other.x, y - other.y, z - other.z,w - other.w); - } - - sVec4 operator+(const sVec4& other) const - { - return sVec4(x + other.x, y + other.y, z + other.z,w + other.w); - } - - void operator+=(const sVec4& other) - { - x += other.x; - y += other.y; - z += other.z; - w += other.w; - } - - sVec4 operator*(f32 s) const - { - return sVec4(x * s , y * s, z * s,w * s); - } - - sVec4 operator*(const sVec4 &other) const - { - return sVec4(x * other.x , y * other.y, z * other.z,w * other.w); - } - - void mulReciprocal ( f32 s ) - { - const f32 i = core::reciprocal ( s ); - x = (f32) ( x * i ); - y = (f32) ( y * i ); - z = (f32) ( z * i ); - w = (f32) ( w * i ); - } -/* - void operator*=(f32 s) - { - x *= s; - y *= s; - z *= s; - w *= s; - } -*/ - void operator*=(const sVec4 &other) - { - x *= other.x; - y *= other.y; - z *= other.z; - w *= other.w; - } - - void operator=(const sVec4& other) - { - x = other.x; - y = other.y; - z = other.z; - w = other.w; - } -}; - -struct sVec3 -{ - f32 r, g, b; - - void set ( f32 _r, f32 _g, f32 _b ) - { - r = _r; - g = _g; - b = _b; - } - - void setR8G8B8 ( u32 argb ) - { - r = ( ( argb & 0x00FF0000 ) >> 16 ) * ( 1.f / 255.f ); - g = ( ( argb & 0x0000FF00 ) >> 8 ) * ( 1.f / 255.f ); - b = ( ( argb & 0x000000FF ) ) * ( 1.f / 255.f ); - } - - void setColorf ( const video::SColorf & color ) - { - r = color.r; - g = color.g; - b = color.b; - } - - void add (const sVec3& other) - { - r += other.r; - g += other.g; - b += other.b; - } - - void mulAdd(const sVec3& other, const f32 v) - { - r += other.r * v; - g += other.g * v; - b += other.b * v; - } - - void mulAdd(const sVec3& v0, const sVec3& v1) - { - r += v0.r * v1.r; - g += v0.g * v1.g; - b += v0.b * v1.b; - } - - void saturate ( sVec4 &dest, u32 argb ) - { - dest.x = ( ( argb & 0xFF000000 ) >> 24 ) * ( 1.f / 255.f ); - dest.y = core::min_ ( r, 1.f ); - dest.z = core::min_ ( g, 1.f ); - dest.w = core::min_ ( b, 1.f ); - } - -}; - - - -inline void sCompressedVec4::setVec4 ( const sVec4 & v ) -{ - argb = core::floor32 ( v.x * 255.f ) << 24 | - core::floor32 ( v.y * 255.f ) << 16 | - core::floor32 ( v.z * 255.f ) << 8 | - core::floor32 ( v.w * 255.f ); -} - - -enum e4DVertexFlag -{ - VERTEX4D_INSIDE = 0x0000003F, - VERTEX4D_CLIPMASK = 0x0000003F, - VERTEX4D_PROJECTED = 0x00000100, - - VERTEX4D_FORMAT_MASK = 0xFFFF0000, - - VERTEX4D_FORMAT_MASK_TEXTURE = 0x000F0000, - VERTEX4D_FORMAT_TEXTURE_1 = 0x00010000, - VERTEX4D_FORMAT_TEXTURE_2 = 0x00020000, - VERTEX4D_FORMAT_TEXTURE_3 = 0x00030000, - VERTEX4D_FORMAT_TEXTURE_4 = 0x00040000, - - VERTEX4D_FORMAT_MASK_COLOR = 0x00F00000, - VERTEX4D_FORMAT_COLOR_1 = 0x00100000, - VERTEX4D_FORMAT_COLOR_2 = 0x00200000 - -}; - -const u32 MATERIAL_MAX_COLORS = 1; -const u32 BURNING_MATERIAL_MAX_TEXTURES = 2; - -// dummy Vertex. used for calculation vertex memory size -struct s4DVertex_proxy -{ - sVec4 Pos; - -#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - sVec4 Color[MATERIAL_MAX_COLORS]; -#endif - - sVec2 Tex[BURNING_MATERIAL_MAX_TEXTURES]; - u32 flag; -}; - -#define SIZEOF_SVERTEX 64 -#define SIZEOF_SVERTEX_LOG2 6 - -/*! - Internal BurningVideo Vertex -*/ -struct s4DVertex -{ - sVec4 Pos; - -#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - sVec4 Color[ MATERIAL_MAX_COLORS ]; -#endif - - sVec2 Tex[ BURNING_MATERIAL_MAX_TEXTURES ]; - - u32 flag; - - u8 fill [ SIZEOF_SVERTEX - sizeof (s4DVertex_proxy) ]; - - // f = a * t + b * ( 1 - t ) - void interpolate(const s4DVertex& b, const s4DVertex& a, const f32 t) - { - u32 i; - u32 size; - - Pos.interpolate ( a.Pos, b.Pos, t ); - -#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - size = (flag & VERTEX4D_FORMAT_MASK_COLOR) >> 20; - for ( i = 0; i!= size; ++i ) - { - Color[i].interpolate ( a.Color[i], b.Color[i], t ); - } -#endif - - size = (flag & VERTEX4D_FORMAT_MASK_TEXTURE) >> 16; - for ( i = 0; i!= size; ++i ) - { - Tex[i].interpolate ( a.Tex[i], b.Tex[i], t ); - } - - } -}; - -// ----------------- Vertex Cache --------------------------- - -struct SAlignedVertex -{ - SAlignedVertex ( u32 element, u32 aligned ) - : ElementSize ( element ) - { - u32 byteSize = (ElementSize << SIZEOF_SVERTEX_LOG2 ) + aligned; - mem = new u8 [ byteSize ]; - data = (s4DVertex*) mem; - } - - virtual ~SAlignedVertex () - { - delete [] mem; - } - - s4DVertex *data; - u8 *mem; - u32 ElementSize; -}; - - -// hold info for different Vertex Types -struct SVSize -{ - u32 Format; - u32 Pitch; - u32 TexSize; -}; - - -// a cache info -struct SCacheInfo -{ - u32 index; - u32 hit; -}; - -#define VERTEXCACHE_ELEMENT 16 -#define VERTEXCACHE_MISS 0xFFFFFFFF -struct SVertexCache -{ - SVertexCache (): mem ( VERTEXCACHE_ELEMENT * 2, 128 ) {} - - SCacheInfo info[VERTEXCACHE_ELEMENT]; - - - // Transformed and lite, clipping state - // + Clipped, Projected - SAlignedVertex mem; - - // source - const void* vertices; - u32 vertexCount; - - const void* indices; - u32 indexCount; - u32 indicesIndex; - - u32 indicesRun; - - // primitives consist of x vertices - u32 primitivePitch; - - u32 vType; //E_VERTEX_TYPE - u32 pType; //scene::E_PRIMITIVE_TYPE - u32 iType; //E_INDEX_TYPE iType - -}; - - -// swap 2 pointer -REALINLINE void swapVertexPointer(const s4DVertex** v1, const s4DVertex** v2) -{ - const s4DVertex* b = *v1; - *v1 = *v2; - *v2 = b; -} - - -// ------------------------ Internal Scanline Rasterizer ----------------------------- - - - -// internal scan convert -struct sScanConvertData -{ - u8 left; // major edge left/right - u8 right; // !left - - f32 invDeltaY[3]; // inverse edge delta y - - f32 x[2]; // x coordinate - f32 slopeX[2]; // x slope along edges - -#if defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) || defined ( SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT ) - f32 w[2]; // w coordinate - fp24 slopeW[2]; // w slope along edges -#else - f32 z[2]; // z coordinate - f32 slopeZ[2]; // z slope along edges -#endif - - sVec4 c[MATERIAL_MAX_COLORS][2]; // color - sVec4 slopeC[MATERIAL_MAX_COLORS][2]; // color slope along edges - - sVec2 t[BURNING_MATERIAL_MAX_TEXTURES][2]; // texture - sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES][2]; // texture slope along edges - -}; - -// passed to scan Line -struct sScanLineData -{ - s32 y; // y position of scanline - f32 x[2]; // x start, x end of scanline - -#if defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) || defined ( SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT ) - f32 w[2]; // w start, w end of scanline -#else - f32 z[2]; // z start, z end of scanline -#endif - -#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - sVec4 c[MATERIAL_MAX_COLORS][2]; // color start, color end of scanline -#endif - - sVec2 t[BURNING_MATERIAL_MAX_TEXTURES][2]; // texture start, texture end of scanline -}; - -// passed to pixel Shader -struct sPixelShaderData -{ - tVideoSample *dst; - fp24 *z; - - s32 xStart; - s32 xEnd; - s32 dx; - s32 i; -}; - -/* - load a color value -*/ -inline void getTexel_plain2 ( tFixPoint &r, tFixPoint &g, tFixPoint &b, - const sVec4 &v - ) -{ - r = tofix ( v.y ); - g = tofix ( v.z ); - b = tofix ( v.w ); -} - -/* - load a color value -*/ -inline void getSample_color ( tFixPoint &a, tFixPoint &r, tFixPoint &g, tFixPoint &b, - const sVec4 &v - ) -{ - a = tofix ( v.x ); - r = tofix ( v.y, COLOR_MAX * FIX_POINT_F32_MUL); - g = tofix ( v.z, COLOR_MAX * FIX_POINT_F32_MUL); - b = tofix ( v.w, COLOR_MAX * FIX_POINT_F32_MUL); -} - -/* - load a color value -*/ -inline void getSample_color ( tFixPoint &r, tFixPoint &g, tFixPoint &b,const sVec4 &v ) -{ - r = tofix ( v.y, COLOR_MAX * FIX_POINT_F32_MUL); - g = tofix ( v.z, COLOR_MAX * FIX_POINT_F32_MUL); - b = tofix ( v.w, COLOR_MAX * FIX_POINT_F32_MUL); -} - -/* - load a color value -*/ -inline void getSample_color ( tFixPoint &r, tFixPoint &g, tFixPoint &b, - const sVec4 &v, const f32 mulby ) -{ - r = tofix ( v.y, mulby); - g = tofix ( v.z, mulby); - b = tofix ( v.w, mulby); -} - - - -} - -} - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/SoftwareDriver2_compile_config.h b/irrlicht-1.6/source/Irrlicht/SoftwareDriver2_compile_config.h deleted file mode 100644 index 5e509df69..000000000 --- a/irrlicht-1.6/source/Irrlicht/SoftwareDriver2_compile_config.h +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __S_VIDEO_2_SOFTWARE_COMPILE_CONFIG_H_INCLUDED__ -#define __S_VIDEO_2_SOFTWARE_COMPILE_CONFIG_H_INCLUDED__ - -#include "IrrCompileConfig.h" - - -// Generic Render Flags for burning's video rasterizer -// defined now in irrlicht compile config - - -#ifdef BURNINGVIDEO_RENDERER_BEAUTIFUL - #define SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #define SOFTWARE_DRIVER_2_SUBTEXEL - #define SOFTWARE_DRIVER_2_BILINEAR - #define SOFTWARE_DRIVER_2_LIGHTING - #define SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #define SOFTWARE_DRIVER_2_32BIT - #define SOFTWARE_DRIVER_2_MIPMAPPING - #define SOFTWARE_DRIVER_2_USE_WBUFFER - #define SOFTWARE_DRIVER_2_TEXTURE_TRANSFORM - #define SOFTWARE_DRIVER_2_TEXTURE_MAXSIZE 0 -#endif - -//! Set Flags for Windows Mobile -#ifdef BURNINGVIDEO_RENDERER_CE - #define SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #define SOFTWARE_DRIVER_2_SUBTEXEL - //#define SOFTWARE_DRIVER_2_BILINEAR - //#define SOFTWARE_DRIVER_2_LIGHTING - #define SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #define SOFTWARE_DRIVER_2_16BIT - #define SOFTWARE_DRIVER_2_MIPMAPPING - #define SOFTWARE_DRIVER_2_USE_WBUFFER - //#define SOFTWARE_DRIVER_2_TEXTURE_TRANSFORM - #define SOFTWARE_DRIVER_2_TEXTURE_MAXSIZE 128 -#endif - -#ifdef BURNINGVIDEO_RENDERER_FAST - #define SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #define SOFTWARE_DRIVER_2_SUBTEXEL - //#define SOFTWARE_DRIVER_2_BILINEAR - //#define SOFTWARE_DRIVER_2_LIGHTING - //#define SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #define SOFTWARE_DRIVER_2_32BIT - #define SOFTWARE_DRIVER_2_MIPMAPPING - #define SOFTWARE_DRIVER_2_USE_WBUFFER - #define SOFTWARE_DRIVER_2_TEXTURE_MAXSIZE 0 -#endif - -#ifdef BURNINGVIDEO_RENDERER_ULTRA_FAST - #define BURNINGVIDEO_RENDERER_FAST - - //#define SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #define SOFTWARE_DRIVER_2_SUBTEXEL - //#define SOFTWARE_DRIVER_2_BILINEAR - //#define SOFTWARE_DRIVER_2_LIGHTING - //#define SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - //#define SOFTWARE_DRIVER_2_32BIT - #define SOFTWARE_DRIVER_2_MIPMAPPING - #define SOFTWARE_DRIVER_2_USE_WBUFFER - #define SOFTWARE_DRIVER_2_TEXTURE_MAXSIZE 0 -#endif - -// Derivate flags - -// texture format -#ifdef SOFTWARE_DRIVER_2_32BIT - #define BURNINGSHADER_COLOR_FORMAT ECF_A8R8G8B8 -#else - #define BURNINGSHADER_COLOR_FORMAT ECF_A1R5G5B5 -#endif - -// mip mapping -#if defined ( SOFTWARE_DRIVER_2_MIPMAPPING ) - #if defined( BURNINGVIDEO_RENDERER_BEAUTIFUL ) - #define SOFTWARE_DRIVER_2_MIPMAPPING_MAX 8 - #define SOFTWARE_DRIVER_2_MIPMAPPING_LOD_BIAS -1 - #elif defined ( BURNINGVIDEO_RENDERER_CE ) - #define SOFTWARE_DRIVER_2_MIPMAPPING_MAX 4 - #define SOFTWARE_DRIVER_2_MIPMAPPING_LOD_BIAS 0 - #else - #define SOFTWARE_DRIVER_2_MIPMAPPING_MAX 8 - #define SOFTWARE_DRIVER_2_MIPMAPPING_LOD_BIAS 0 - #endif -#else - #define SOFTWARE_DRIVER_2_MIPMAPPING_MAX 1 - #define SOFTWARE_DRIVER_2_MIPMAPPING_LOD_BIAS 0 -#endif - -#define SOFTWARE_DRIVER_2_MIPMAPPING_SCALE (8/SOFTWARE_DRIVER_2_MIPMAPPING_MAX) - -#ifndef REALINLINE - #ifdef _MSC_VER - #define REALINLINE __forceinline - #else - #define REALINLINE inline - #endif -#endif - -#endif diff --git a/irrlicht-1.6/source/Irrlicht/SoftwareDriver2_helper.h b/irrlicht-1.6/source/Irrlicht/SoftwareDriver2_helper.h deleted file mode 100644 index 16ec3461c..000000000 --- a/irrlicht-1.6/source/Irrlicht/SoftwareDriver2_helper.h +++ /dev/null @@ -1,937 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt / Thomas Alten -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -/* - History: - - changed behaviour for log2 textures ( replaced multiplies by shift ) -*/ - -#ifndef __S_VIDEO_2_SOFTWARE_HELPER_H_INCLUDED__ -#define __S_VIDEO_2_SOFTWARE_HELPER_H_INCLUDED__ - -#include "SoftwareDriver2_compile_config.h" -#include "irrMath.h" -#include "CSoftwareTexture2.h" -#include "SMaterial.h" - - - -namespace irr -{ - -// supporting different packed pixel needs many defines... - -#ifdef SOFTWARE_DRIVER_2_32BIT - typedef u32 tVideoSample; - - #define MASK_A 0xFF000000 - #define MASK_R 0x00FF0000 - #define MASK_G 0x0000FF00 - #define MASK_B 0x000000FF - - #define SHIFT_A 24 - #define SHIFT_R 16 - #define SHIFT_G 8 - #define SHIFT_B 0 - - #define COLOR_MAX 0xFF - #define COLOR_MAX_LOG2 8 - #define COLOR_BRIGHT_WHITE 0xFFFFFFFF - - #define VIDEO_SAMPLE_GRANULARITY 2 - -#else - typedef u16 tVideoSample; - - #define MASK_A 0x8000 - #define MASK_R 0x7C00 - #define MASK_G 0x03E0 - #define MASK_B 0x001F - - #define SHIFT_A 15 - #define SHIFT_R 10 - #define SHIFT_G 5 - #define SHIFT_B 0 - - #define COLOR_MAX 0x1F - #define COLOR_MAX_LOG2 5 - #define COLOR_BRIGHT_WHITE 0xFFFF - #define VIDEO_SAMPLE_GRANULARITY 1 - -#endif - - - - -// ----------------------- Generic ---------------------------------- - -//! a more useful memset for pixel -inline void memset32 ( void * dest, const u32 value, u32 bytesize ) -{ - u32 * d = (u32*) dest; - - u32 i; - - i = bytesize >> ( 2 + 3 ); - while( i ) - { - d[0] = value; - d[1] = value; - d[2] = value; - d[3] = value; - - d[4] = value; - d[5] = value; - d[6] = value; - d[7] = value; - - d += 8; - i -= 1; - } - - i = (bytesize >> 2 ) & 7; - while( i ) - { - d[0] = value; - d += 1; - i -= 1; - } - -} - -/* - use biased loop counter - --> 0 byte copy is forbidden -*/ -REALINLINE void memcpy32_small ( void * dest, const void *source, u32 bytesize ) -{ - u32 c = bytesize >> 2; - - do - { - ((u32*) dest ) [ c-1 ] = ((u32*) source) [ c-1 ]; - } while ( --c ); - -} - - - -// integer log2 of a float ieee 754. TODO: non ieee floating point -static inline s32 s32_log2_f32( f32 f) -{ - u32 x = IR ( f ); - return ((x & 0x7F800000) >> 23) - 127; -} - -static inline s32 s32_log2_s32(u32 x) -{ - return s32_log2_f32( (f32) x); -} - -static inline s32 s32_abs(s32 x) -{ - s32 b = x >> 31; - return (x ^ b ) - b; -} - - -//! conditional set based on mask and arithmetic shift -REALINLINE u32 if_mask_a_else_b ( const u32 mask, const u32 a, const u32 b ) -{ - return ( mask & ( a ^ b ) ) ^ b; -} - -// ------------------ Video--------------------------------------- -/*! - Pixel = dest * ( 1 - alpha ) + source * alpha - alpha [0;256] -*/ -REALINLINE u32 PixelBlend32 ( const u32 c2, const u32 c1, u32 alpha ) -{ - u32 srcRB = c1 & 0x00FF00FF; - u32 srcXG = c1 & 0x0000FF00; - - u32 dstRB = c2 & 0x00FF00FF; - u32 dstXG = c2 & 0x0000FF00; - - - u32 rb = srcRB - dstRB; - u32 xg = srcXG - dstXG; - - rb *= alpha; - xg *= alpha; - rb >>= 8; - xg >>= 8; - - rb += dstRB; - xg += dstXG; - - rb &= 0x00FF00FF; - xg &= 0x0000FF00; - - return rb | xg; -} - -/*! - Pixel = dest * ( 1 - alpha ) + source * alpha - alpha [0;32] -*/ -inline u16 PixelBlend16 ( const u16 c2, const u32 c1, const u16 alpha ) -{ - const u16 srcRB = c1 & 0x7C1F; - const u16 srcXG = c1 & 0x03E0; - - const u16 dstRB = c2 & 0x7C1F; - const u16 dstXG = c2 & 0x03E0; - - u32 rb = srcRB - dstRB; - u32 xg = srcXG - dstXG; - - rb *= alpha; - xg *= alpha; - rb >>= 5; - xg >>= 5; - - rb += dstRB; - xg += dstXG; - - rb &= 0x7C1F; - xg &= 0x03E0; - - return (u16)(rb | xg); -} - -/* - Pixel = c0 * (c1/31). c0 Alpha retain -*/ -inline u16 PixelMul16 ( const u16 c0, const u16 c1) -{ - return (u16)((( ( (c0 & 0x7C00) * (c1 & 0x7C00) ) & 0x3E000000 ) >> 15 ) | - (( ( (c0 & 0x03E0) * (c1 & 0x03E0) ) & 0x000F8000 ) >> 10 ) | - (( ( (c0 & 0x001F) * (c1 & 0x001F) ) & 0x000003E0 ) >> 5 ) | - (c0 & 0x8000)); -} - -/* - Pixel = c0 * (c1/31). -*/ -inline u16 PixelMul16_2 ( u16 c0, u16 c1) -{ - return (u16)(( ( (c0 & 0x7C00) * (c1 & 0x7C00) ) & 0x3E000000 ) >> 15 | - ( ( (c0 & 0x03E0) * (c1 & 0x03E0) ) & 0x000F8000 ) >> 10 | - ( ( (c0 & 0x001F) * (c1 & 0x001F) ) & 0x000003E0 ) >> 5 | - ( c0 & c1 & 0x8000)); -} - -/* - Pixel = c0 * (c1/255). c0 Alpha Retain -*/ -REALINLINE u32 PixelMul32 ( const u32 c0, const u32 c1) -{ - return (c0 & 0xFF000000) | - (( ( (c0 & 0x00FF0000) >> 12 ) * ( (c1 & 0x00FF0000) >> 12 ) ) & 0x00FF0000 ) | - (( ( (c0 & 0x0000FF00) * (c1 & 0x0000FF00) ) >> 16 ) & 0x0000FF00 ) | - (( ( (c0 & 0x000000FF) * (c1 & 0x000000FF) ) >> 8 ) & 0x000000FF); -} - -/* - Pixel = c0 * (c1/255). -*/ -REALINLINE u32 PixelMul32_2 ( const u32 c0, const u32 c1) -{ - return (( ( (c0 & 0xFF000000) >> 16 ) * ( (c1 & 0xFF000000) >> 16 ) ) & 0xFF000000 ) | - (( ( (c0 & 0x00FF0000) >> 12 ) * ( (c1 & 0x00FF0000) >> 12 ) ) & 0x00FF0000 ) | - (( ( (c0 & 0x0000FF00) * (c1 & 0x0000FF00) ) >> 16 ) & 0x0000FF00 ) | - (( ( (c0 & 0x000000FF) * (c1 & 0x000000FF) ) >> 8 ) & 0x000000FF); -} - -/* - Pixel = clamp ( c0 + c1, 0, 255 ) -*/ -REALINLINE u32 PixelAdd32 ( const u32 c2, const u32 c1) -{ - u32 sum = ( c2 & 0x00FFFFFF ) + ( c1 & 0x00FFFFFF ); - u32 low_bits = ( c2 ^ c1 ) & 0x00010101; - s32 carries = ( sum - low_bits ) & 0x01010100; - u32 modulo = sum - carries; - u32 clamp = carries - ( carries >> 8 ); - return modulo | clamp; -} - -#if 0 - -// 1 - Bit Alpha Blending -inline u16 PixelBlend16 ( const u16 destination, const u16 source ) -{ - if((source & 0x8000) == 0x8000) - return source; // The source is visible, so use it. - else - return destination; // The source is transparent, so use the destination. -} - -// 1 - Bit Alpha Blending 16Bit SIMD -inline u32 PixelBlend16_simd ( const u32 destination, const u32 source ) -{ - switch(source & 0x80008000) - { - case 0x80008000: // Both source pixels are visible - return source; - - case 0x80000000: // Only the first source pixel is visible - return (source & 0xFFFF0000) | (destination & 0x0000FFFF); - - case 0x00008000: // Only the second source pixel is visible. - return (destination & 0xFFFF0000) | (source & 0x0000FFFF); - - default: // Neither source pixel is visible. - return destination; - } -} -#else - -// 1 - Bit Alpha Blending -inline u16 PixelBlend16 ( const u16 c2, const u16 c1 ) -{ - u16 mask = ((c1 & 0x8000) >> 15 ) + 0x7fff; - return (c2 & mask ) | ( c1 & ~mask ); -} - -// 1 - Bit Alpha Blending 16Bit SIMD -inline u32 PixelBlend16_simd ( const u32 c2, const u32 c1 ) -{ - u32 mask = ((c1 & 0x80008000) >> 15 ) + 0x7fff7fff; - return (c2 & mask ) | ( c1 & ~mask ); -} - -#endif - -/*! - Pixel = dest * ( 1 - SourceAlpha ) + source * SourceAlpha -*/ -inline u32 PixelBlend32 ( const u32 c2, const u32 c1 ) -{ - // alpha test - u32 alpha = c1 & 0xFF000000; - - if ( 0 == alpha ) - return c2; - - if ( 0xFF000000 == alpha ) - { - return c1; - } - - alpha >>= 24; - - // add highbit alpha, if ( alpha > 127 ) alpha += 1; - alpha += ( alpha >> 7); - - u32 srcRB = c1 & 0x00FF00FF; - u32 srcXG = c1 & 0x0000FF00; - - u32 dstRB = c2 & 0x00FF00FF; - u32 dstXG = c2 & 0x0000FF00; - - - u32 rb = srcRB - dstRB; - u32 xg = srcXG - dstXG; - - rb *= alpha; - xg *= alpha; - rb >>= 8; - xg >>= 8; - - rb += dstRB; - xg += dstXG; - - rb &= 0x00FF00FF; - xg &= 0x0000FF00; - - return (c1 & 0xFF000000) | rb | xg; -} - - - -// ------------------ Fix Point ---------------------------------- - -typedef s32 tFixPoint; -typedef u32 tFixPointu; - -// Fix Point 9 -#if 1 - #define FIX_POINT_PRE 9 - #define FIX_POINT_FRACT_MASK 0x1FF - #define FIX_POINT_SIGNED_MASK 0xFFFFFE00 - #define FIX_POINT_UNSIGNED_MASK 0x7FFFFE00 - #define FIX_POINT_ONE 0x200 - #define FIX_POINT_ZERO_DOT_FIVE 0x100 - #define FIX_POINT_F32_MUL 512.f -#endif - -// Fix Point 7 -#if 0 - #define FIX_POINT_PRE 7 - #define FIX_POINT_FRACT_MASK 0x7F - #define FIX_POINT_SIGNED_MASK 0xFFFFFF80 - #define FIX_POINT_UNSIGNED_MASK 0x7FFFFF80 - #define FIX_POINT_ONE 0x80 - #define FIX_POINT_ZERO_DOT_FIVE 0x40 - #define FIX_POINT_F32_MUL 128.f -#endif - -#define FIXPOINT_COLOR_MAX ( COLOR_MAX << FIX_POINT_PRE ) - - -/* - convert signed integer to fixpoint -*/ -inline tFixPoint s32_to_fixPoint (const s32 x) -{ - return x << FIX_POINT_PRE; -} - -inline tFixPointu u32_to_fixPoint (const u32 x) -{ - return x << FIX_POINT_PRE; -} - -inline u32 fixPointu_to_u32 (const tFixPointu x) -{ - return x >> FIX_POINT_PRE; -} - - -// 1/x * FIX_POINT -REALINLINE f32 fix_inverse32 ( const f32 x ) -{ - return FIX_POINT_F32_MUL / x; -} - - -/* - convert float to fixpoint - fast convert (fistp on x86) HAS to be used.. - hints: compileflag /QIfist for msvc7. msvc 8.0 has smth different - others should use their favourite assembler.. -*/ -static inline int f_round2(f32 f) -{ - f += (3<<22); - return *((int*)&f) - 0x4b400000; -} - -/* - convert f32 to Fix Point. - multiply is needed anyway, so scale mulby -*/ -REALINLINE tFixPoint tofix (const f32 x, const f32 mulby = FIX_POINT_F32_MUL ) -{ - return (tFixPoint) (x * mulby); -} - - -/* - Fix Point , Fix Point Multiply -*/ -REALINLINE tFixPointu imulFixu(const tFixPointu x, const tFixPointu y) -{ - return (x * y) >> (tFixPointu) FIX_POINT_PRE; -} - -/* - Fix Point , Fix Point Multiply -*/ -REALINLINE tFixPoint imulFix(const tFixPoint x, const tFixPoint y) -{ - return ( x * y) >> ( FIX_POINT_PRE ); -} - -/* - Fix Point , Fix Point Multiply x * y * 2 -*/ -REALINLINE tFixPoint imulFix2(const tFixPoint x, const tFixPoint y) -{ - return ( x * y) >> ( FIX_POINT_PRE -1 ); -} - - -/* - Multiply x * y * 1 -*/ -REALINLINE tFixPoint imulFix_tex1(const tFixPoint x, const tFixPoint y) -{ - return ( ( (tFixPointu) x >> 2 ) * ( (tFixPointu) y >> 2 ) ) >> (tFixPointu) ( FIX_POINT_PRE + 4 ); -} - -/* - Multiply x * y * 2 -*/ -REALINLINE tFixPoint imulFix_tex2(const tFixPoint x, const tFixPoint y) -{ - return ( ( (tFixPointu) x >> 2 ) * ( (tFixPointu) y >> 2 ) ) >> (tFixPointu) ( FIX_POINT_PRE + 3 ); -} - -/* - Multiply x * y * 4 -*/ -REALINLINE tFixPoint imulFix_tex4(const tFixPoint x, const tFixPoint y) -{ -#ifdef SOFTWARE_DRIVER_2_32BIT - return ( ( (tFixPointu) x >> 2 ) * ( (tFixPointu) y >> 2 ) ) >> (tFixPointu) ( FIX_POINT_PRE + 2 ); -#else - return ( x * y) >> ( FIX_POINT_PRE + ( VIDEO_SAMPLE_GRANULARITY * 3 ) ); -#endif -} - -/*! - clamp FixPoint to maxcolor in FixPoint, min(a,31) -*/ -REALINLINE tFixPoint clampfix_maxcolor ( const tFixPoint a) -{ - tFixPoint c = (a - FIXPOINT_COLOR_MAX) >> 31; - return (a & c) | ( FIXPOINT_COLOR_MAX & ~c); -} - -/*! - clamp FixPoint to 0 in FixPoint, max(a,0) -*/ -inline tFixPoint clampfix_mincolor ( const tFixPoint a) -{ - return a - ( a & ( a >> 31 ) ); -} - - -// rount fixpoint to int -inline s32 roundFix ( const tFixPoint x ) -{ - return ( x + FIX_POINT_ZERO_DOT_FIVE ) >> FIX_POINT_PRE; -} - - - -// x in [0;1[ -inline s32 f32_to_23Bits(const f32 x) -{ - f32 y = x + 1.f; - return ((u32&)y) & 0x7FFFFF; // last 23 bits -} - -/*! - return VideoSample from fixpoint -*/ -REALINLINE tVideoSample fix_to_color ( const tFixPoint r, const tFixPoint g, const tFixPoint b ) -{ -#ifdef __BIG_ENDIAN__ - return FIXPOINT_COLOR_MAX | - ( r & FIXPOINT_COLOR_MAX) >> ( FIX_POINT_PRE - 8) | - ( g & FIXPOINT_COLOR_MAX) << ( 16 - FIX_POINT_PRE ) | - ( b & FIXPOINT_COLOR_MAX) << ( 24 - FIX_POINT_PRE ); -#else - return ( FIXPOINT_COLOR_MAX & FIXPOINT_COLOR_MAX) << ( SHIFT_A - FIX_POINT_PRE ) | - ( r & FIXPOINT_COLOR_MAX) << ( SHIFT_R - FIX_POINT_PRE ) | - ( g & FIXPOINT_COLOR_MAX) >> ( FIX_POINT_PRE - SHIFT_G ) | - ( b & FIXPOINT_COLOR_MAX) >> ( FIX_POINT_PRE - SHIFT_B ); -#endif -} - - -/*! - return VideoSample from fixpoint -*/ -REALINLINE tVideoSample fix4_to_color ( const tFixPoint a, const tFixPoint r, const tFixPoint g, const tFixPoint b ) -{ -#ifdef __BIG_ENDIAN__ - return ( a & (FIX_POINT_FRACT_MASK - 1 )) >> ( FIX_POINT_PRE ) | - ( r & FIXPOINT_COLOR_MAX) >> ( FIX_POINT_PRE - 8) | - ( g & FIXPOINT_COLOR_MAX) << ( 16 - FIX_POINT_PRE ) | - ( b & FIXPOINT_COLOR_MAX) << ( 24 - FIX_POINT_PRE ); -#else - return ( a & (FIX_POINT_FRACT_MASK - 1 )) << ( SHIFT_A - 1 ) | - ( r & FIXPOINT_COLOR_MAX) << ( SHIFT_R - FIX_POINT_PRE ) | - ( g & FIXPOINT_COLOR_MAX) >> ( FIX_POINT_PRE - SHIFT_G ) | - ( b & FIXPOINT_COLOR_MAX) >> ( FIX_POINT_PRE - SHIFT_B ); -#endif - -} - -/*! - return fixpoint from VideoSample granularity COLOR_MAX -*/ -inline void color_to_fix ( tFixPoint &r, tFixPoint &g, tFixPoint &b, const tVideoSample t00 ) -{ - (tFixPointu&) r = (t00 & MASK_R) >> ( SHIFT_R - FIX_POINT_PRE ); - (tFixPointu&) g = (t00 & MASK_G) << ( FIX_POINT_PRE - SHIFT_G ); - (tFixPointu&) b = (t00 & MASK_B) << ( FIX_POINT_PRE - SHIFT_B ); -} - -/*! - return fixpoint from VideoSample granularity COLOR_MAX -*/ -inline void color_to_fix ( tFixPoint &a, tFixPoint &r, tFixPoint &g, tFixPoint &b, const tVideoSample t00 ) -{ - (tFixPointu&) a = (t00 & MASK_A) >> ( SHIFT_A - FIX_POINT_PRE ); - (tFixPointu&) r = (t00 & MASK_R) >> ( SHIFT_R - FIX_POINT_PRE ); - (tFixPointu&) g = (t00 & MASK_G) << ( FIX_POINT_PRE - SHIFT_G ); - (tFixPointu&) b = (t00 & MASK_B) << ( FIX_POINT_PRE - SHIFT_B ); -} - -/*! - return fixpoint from VideoSample granularity 0..FIX_POINT_ONE -*/ -inline void color_to_fix1 ( tFixPoint &r, tFixPoint &g, tFixPoint &b, const tVideoSample t00 ) -{ - (tFixPointu&) r = (t00 & MASK_R) >> ( SHIFT_R + COLOR_MAX_LOG2 - FIX_POINT_PRE ); - (tFixPointu&) g = (t00 & MASK_G) >> ( SHIFT_G + COLOR_MAX_LOG2 - FIX_POINT_PRE ); - (tFixPointu&) b = (t00 & MASK_B) << ( FIX_POINT_PRE - COLOR_MAX_LOG2 ); -} - -/*! - return fixpoint from VideoSample granularity 0..FIX_POINT_ONE -*/ -inline void color_to_fix1 ( tFixPoint &a, tFixPoint &r, tFixPoint &g, tFixPoint &b, const tVideoSample t00 ) -{ - (tFixPointu&) a = (t00 & MASK_A) >> ( SHIFT_A + COLOR_MAX_LOG2 - FIX_POINT_PRE ); - (tFixPointu&) r = (t00 & MASK_R) >> ( SHIFT_R + COLOR_MAX_LOG2 - FIX_POINT_PRE ); - (tFixPointu&) g = (t00 & MASK_G) >> ( SHIFT_G + COLOR_MAX_LOG2 - FIX_POINT_PRE ); - (tFixPointu&) b = (t00 & MASK_B) << ( FIX_POINT_PRE - COLOR_MAX_LOG2 ); -} - - - -// ----- FP24 ---- floating point z-buffer - -#if 1 -typedef f32 fp24; -#else -struct fp24 -{ - u32 v; - - fp24() {} - - fp24 ( const f32 f ) - { - f32 y = f + 1.f; - v = ((u32&)y) & 0x7FFFFF; // last 23 bits - } - - void operator=(const f32 f ) - { - f32 y = f + 1.f; - v = ((u32&)y) & 0x7FFFFF; // last 23 bits - } - - void operator+=(const fp24 &other ) - { - v += other.v; - } - - operator f32 () const - { - f32 r = FR ( v ); - return r + 1.f; - } - -}; -#endif - - -// ------------------------ Internal Texture ----------------------------- - -struct sInternalTexture -{ - u32 textureXMask; - u32 textureYMask; - - u32 pitchlog2; - void *data; - - video::CSoftwareTexture2 *Texture; - s32 lodLevel; -}; - - - -// get video sample plain -inline tVideoSample getTexel_plain ( const sInternalTexture * t, const tFixPointu tx, const tFixPointu ty ) -{ - u32 ofs; - - ofs = ( ( ty & t->textureYMask ) >> FIX_POINT_PRE ) << t->pitchlog2; - ofs |= ( tx & t->textureXMask ) >> ( FIX_POINT_PRE - VIDEO_SAMPLE_GRANULARITY ); - - // texel - return *((tVideoSample*)( (u8*) t->data + ofs )); -} - -// get video sample to fix -inline void getTexel_fix ( tFixPoint &r, tFixPoint &g, tFixPoint &b, - const sInternalTexture * t, const tFixPointu tx, const tFixPointu ty - ) -{ - u32 ofs; - - ofs = ( ( ty & t->textureYMask ) >> FIX_POINT_PRE ) << t->pitchlog2; - ofs |= ( tx & t->textureXMask ) >> ( FIX_POINT_PRE - VIDEO_SAMPLE_GRANULARITY ); - - // texel - tVideoSample t00; - t00 = *((tVideoSample*)( (u8*) t->data + ofs )); - - r = (t00 & MASK_R) >> ( SHIFT_R - FIX_POINT_PRE); - g = (t00 & MASK_G) << ( FIX_POINT_PRE - SHIFT_G ); - b = (t00 & MASK_B) << ( FIX_POINT_PRE - SHIFT_B ); - -} - - -inline void getSample_texture_dither ( tFixPoint &r, tFixPoint &g, tFixPoint &b, - const sInternalTexture * t, const tFixPointu tx, const tFixPointu ty, - const u32 x, const u32 y - ) -{ - static const tFixPointu dithermask[] = - { - 0x00,0x80,0x20,0xa0, - 0xc0,0x40,0xe0,0x60, - 0x30,0xb0,0x10,0x90, - 0xf0,0x70,0xd0,0x50 - }; - - const u32 index = (y & 3 ) << 2 | (x & 3); - - const tFixPointu _ntx = (tx + dithermask [ index ] ) & t->textureXMask; - const tFixPointu _nty = (ty + dithermask [ index ] ) & t->textureYMask; - - u32 ofs; - ofs = ( ( _nty ) >> FIX_POINT_PRE ) << t->pitchlog2; - ofs |= ( _ntx ) >> ( FIX_POINT_PRE - VIDEO_SAMPLE_GRANULARITY ); - - // texel - const tVideoSample t00 = *((tVideoSample*)( (u8*) t->data + ofs )); - - (tFixPointu &) r = (t00 & MASK_R) >> ( SHIFT_R - FIX_POINT_PRE); - (tFixPointu &) g = (t00 & MASK_G) << ( FIX_POINT_PRE - SHIFT_G ); - (tFixPointu &) b = (t00 & MASK_B) << ( FIX_POINT_PRE - SHIFT_B ); - -} - -/* - load a sample from internal texture at position tx,ty to fixpoint -*/ -#ifndef SOFTWARE_DRIVER_2_BILINEAR - -// get Sample linear == getSample_fixpoint - -inline void getSample_texture ( tFixPoint &r, tFixPoint &g, tFixPoint &b, - const sInternalTexture * t, const tFixPointu tx, const tFixPointu ty - ) -{ - u32 ofs; - - ofs = ( ( ty & t->textureYMask ) >> FIX_POINT_PRE ) << t->pitchlog2; - ofs |= ( tx & t->textureXMask ) >> ( FIX_POINT_PRE - VIDEO_SAMPLE_GRANULARITY ); - - // texel - const tVideoSample t00 = *((tVideoSample*)( (u8*) t->data + ofs )); - - (tFixPointu &) r = (t00 & MASK_R) >> ( SHIFT_R - FIX_POINT_PRE); - (tFixPointu &) g = (t00 & MASK_G) << ( FIX_POINT_PRE - SHIFT_G ); - (tFixPointu &) b = (t00 & MASK_B) << ( FIX_POINT_PRE - SHIFT_B ); -} - -inline void getSample_texture ( tFixPointu &a, tFixPointu &r, tFixPointu &g, tFixPointu &b, - const sInternalTexture * t, const tFixPointu tx, const tFixPointu ty - ) -{ - u32 ofs; - - ofs = ( ( ty & t->textureYMask ) >> FIX_POINT_PRE ) << t->pitchlog2; - ofs |= ( tx & t->textureXMask ) >> ( FIX_POINT_PRE - VIDEO_SAMPLE_GRANULARITY ); - - // texel - const tVideoSample t00 = *((tVideoSample*)( (u8*) t->data + ofs )); - - (tFixPointu &)a = (t00 & MASK_A) >> ( SHIFT_A - FIX_POINT_PRE); - (tFixPointu &)r = (t00 & MASK_R) >> ( SHIFT_R - FIX_POINT_PRE); - (tFixPointu &)g = (t00 & MASK_G) << ( FIX_POINT_PRE - SHIFT_G ); - (tFixPointu &)b = (t00 & MASK_B) << ( FIX_POINT_PRE - SHIFT_B ); -} - - -#else - -// get sample linear -REALINLINE void getSample_linear ( tFixPointu &r, tFixPointu &g, tFixPointu &b, - const sInternalTexture * t, const tFixPointu tx, const tFixPointu ty - ) -{ - u32 ofs; - - ofs = ( ( ty & t->textureYMask ) >> FIX_POINT_PRE ) << t->pitchlog2; - ofs |= ( tx & t->textureXMask ) >> ( FIX_POINT_PRE - VIDEO_SAMPLE_GRANULARITY ); - - // texel - tVideoSample t00; - t00 = *((tVideoSample*)( (u8*) t->data + ofs )); - - r = (t00 & MASK_R) >> SHIFT_R; - g = (t00 & MASK_G) >> SHIFT_G; - b = (t00 & MASK_B); -} - -// get Sample bilinear -REALINLINE void getSample_texture ( tFixPoint &r, tFixPoint &g, tFixPoint &b, - const sInternalTexture * t, const tFixPointu tx, const tFixPointu ty - ) -{ - - tFixPointu r00,g00,b00; - tFixPointu r01,g01,b01; - tFixPointu r10,g10,b10; - tFixPointu r11,g11,b11; - - getSample_linear ( r00, g00, b00, t, tx,ty ); - getSample_linear ( r10, g10, b10, t, tx + FIX_POINT_ONE,ty ); - getSample_linear ( r01, g01, b01, t, tx,ty + FIX_POINT_ONE ); - getSample_linear ( r11, g11, b11, t, tx + FIX_POINT_ONE,ty + FIX_POINT_ONE ); - - const tFixPointu txFract = tx & FIX_POINT_FRACT_MASK; - const tFixPointu txFractInv = FIX_POINT_ONE - txFract; - - const tFixPointu tyFract = ty & FIX_POINT_FRACT_MASK; - const tFixPointu tyFractInv = FIX_POINT_ONE - tyFract; - - const tFixPointu w00 = imulFixu ( txFractInv, tyFractInv ); - const tFixPointu w10 = imulFixu ( txFract , tyFractInv ); - const tFixPointu w01 = imulFixu ( txFractInv, tyFract ); - const tFixPointu w11 = imulFixu ( txFract , tyFract ); - - r = (r00 * w00 ) + - (r01 * w01 ) + - (r10 * w10 ) + - (r11 * w11 ); - - g = (g00 * w00 ) + - (g01 * w01 ) + - (g10 * w10 ) + - (g11 * w11 ); - - b = (b00 * w00 ) + - (b01 * w01 ) + - (b10 * w10 ) + - (b11 * w11 ); - -} - - -// get sample linear -REALINLINE void getSample_linear ( tFixPointu &a, tFixPointu &r, tFixPointu &g, tFixPointu &b, - const sInternalTexture * t, const tFixPointu tx, const tFixPointu ty - ) -{ - u32 ofs; - - ofs = ( ( ty & t->textureYMask ) >> FIX_POINT_PRE ) << t->pitchlog2; - ofs |= ( tx & t->textureXMask ) >> ( FIX_POINT_PRE - VIDEO_SAMPLE_GRANULARITY ); - - // texel - tVideoSample t00; - t00 = *((tVideoSample*)( (u8*) t->data + ofs )); - - a = (t00 & MASK_A) >> SHIFT_A; - r = (t00 & MASK_R) >> SHIFT_R; - g = (t00 & MASK_G) >> SHIFT_G; - b = (t00 & MASK_B); -} - -// get Sample bilinear -REALINLINE void getSample_texture ( tFixPointu &a, tFixPointu &r, tFixPointu &g, tFixPointu &b, - const sInternalTexture * t, const tFixPointu tx, const tFixPointu ty - ) -{ - - tFixPointu a00, r00,g00,b00; - tFixPointu a01, r01,g01,b01; - tFixPointu a10, r10,g10,b10; - tFixPointu a11, r11,g11,b11; - - getSample_linear ( a00, r00, g00, b00, t, tx,ty ); - getSample_linear ( a10, r10, g10, b10, t, tx + FIX_POINT_ONE,ty ); - getSample_linear ( a01, r01, g01, b01, t, tx,ty + FIX_POINT_ONE ); - getSample_linear ( a11, r11, g11, b11, t, tx + FIX_POINT_ONE,ty + FIX_POINT_ONE ); - - const tFixPointu txFract = tx & FIX_POINT_FRACT_MASK; - const tFixPointu txFractInv = FIX_POINT_ONE - txFract; - - const tFixPointu tyFract = ty & FIX_POINT_FRACT_MASK; - const tFixPointu tyFractInv = FIX_POINT_ONE - tyFract; - - const tFixPointu w00 = imulFixu ( txFractInv, tyFractInv ); - const tFixPointu w10 = imulFixu ( txFract , tyFractInv ); - const tFixPointu w01 = imulFixu ( txFractInv, tyFract ); - const tFixPointu w11 = imulFixu ( txFract , tyFract ); - - a = (a00 * w00 ) + - (a01 * w01 ) + - (a10 * w10 ) + - (a11 * w11 ); - - r = (r00 * w00 ) + - (r01 * w01 ) + - (r10 * w10 ) + - (r11 * w11 ); - - g = (g00 * w00 ) + - (g01 * w01 ) + - (g10 * w10 ) + - (g11 * w11 ); - - b = (b00 * w00 ) + - (b01 * w01 ) + - (b10 * w10 ) + - (b11 * w11 ); - -} - - -#endif - -// some 2D Defines -struct AbsRectangle -{ - s32 x0; - s32 y0; - s32 x1; - s32 y1; -}; - -//! 2D Intersection test -inline bool intersect ( AbsRectangle &dest, const AbsRectangle& a, const AbsRectangle& b) -{ - dest.x0 = core::s32_max( a.x0, b.x0 ); - dest.y0 = core::s32_max( a.y0, b.y0 ); - dest.x1 = core::s32_min( a.x1, b.x1 ); - dest.y1 = core::s32_min( a.y1, b.y1 ); - return dest.x0 < dest.x1 && dest.y0 < dest.y1; -} - -// some 1D defines -struct sIntervall -{ - s32 start; - s32 end; -}; - -// returning intersection width -inline s32 intervall_intersect_test( const sIntervall& a, const sIntervall& b) -{ - return core::s32_min( a.end, b.end ) - core::s32_max( a.start, b.start ); -} - - -} // namespace - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/builtInFont.bmp b/irrlicht-1.6/source/Irrlicht/builtInFont.bmp deleted file mode 100644 index 7001c1231..000000000 Binary files a/irrlicht-1.6/source/Irrlicht/builtInFont.bmp and /dev/null differ diff --git a/irrlicht-1.6/source/Irrlicht/dmfsupport.h b/irrlicht-1.6/source/Irrlicht/dmfsupport.h deleted file mode 100644 index 0314edec1..000000000 --- a/irrlicht-1.6/source/Irrlicht/dmfsupport.h +++ /dev/null @@ -1,765 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h -// -// This file was originally written by Salvatore Russo. -// I (Nikolaus Gebhardt) did some minor modifications changes to it and integrated -// it into Irrlicht: -// - removed STL dependency -// - removed log file and replaced it with irrlicht logging -// - adapted code formatting a bit to Irrlicht style -// - removed memory leaks -// Thanks a lot to Salvatore for his work on this and that he gave me -// his permission to add it into Irrlicht. - -// This support library has been made by Salvatore Russo and is released under GNU public license for general uses. -// For uses in Irrlicht core and only for Irrlicht related uses I release this library under zlib license. -// It uses standard template libraries to create String class and StringList class used in DeleD -// plugins made by me. - -#ifndef __DMF_SUPPORT_H_INCLUDED__ -#define __DMF_SUPPORT_H_INCLUDED__ - -#include "irrString.h" -#include "fast_atof.h" - -namespace irr -{ -namespace scene -{ - -/** A structure representing some DeleD infos. -This structure contains data about DeleD level file like: version, ambient colour, number of objects etc...*/ -struct dmfHeader -{ - //main file header - core::stringc dmfName; //!<Scene name - f32 dmfVersion; //!<File version - video::SColor dmfAmbient; //!<Ambient color - f32 dmfShadow; //!<Shadow intensity - u32 numObjects; //!<Number of objects in this scene - u32 numMaterials; //!<Number of materials in this scene - u32 numVertices; //!<Total number of vertices faces*(vertices for each face) - u32 numFaces; //!<Total number of faces - u32 numLights; //!<Number of dynamic lights in this scene - u32 numWatVertices; //!<Total number of vertices of water plains watfaces*(vertices for each face) - u32 numWatFaces; //!<Total number of faces for water plains.Note that each water plane is a rectangle with one face only. -}; - - -/** A structure representing a DeleD material. -This structure contains texture names, an ID and some flags.*/ -struct dmfMaterial -{ - u32 materialID;//!<This material unique ID. - u32 textureLayers;//!<First texture Flag (0=Normal, 1=Color). - u32 textureFlag;//!<First texture Flag (0=Normal, 1=Color). - u32 lightmapFlag;//!<Lightmap Flag (0=Normal, others not considered). - u32 textureBlend;//!<Texture Blend mode used to support alpha maps (4=Alpha map, others not implemented yet). - core::stringc pathName;//!<Name of path defined in path element. - core::stringc textureName;//!<Name of first texture (only file name, no path). - core::stringc lightmapName;//!<Name of lightmap (only file name, no path). - u32 lightmapBlend;//!<Blend mode used to support alpha maps (not implemented yet). -}; - - -/** A structure representing a single face. -This structure contains first vertice index, number of vertices and the material used.*/ -struct dmfFace -{ - u32 firstVert;//!<First vertex index. - u32 numVerts;//!<Number of vertices for this face. - u32 materialID;//!<Material used for this face. -}; - - -/** A structure rapresenting a single vertice. -This structure contains vertice position coordinates and texture an lightmap UV.*/ -struct dmfVert -{ - core::vector3df pos;//!<Position of vertex - core::vector2df tc;//!<Texture UV coords - core::vector2df lc;//!<Lightmap UV coords -}; - - -/** A structure representing a single dynamic light. -This structure contains light position coordinates, diffuse colour, specular colour and maximum radius of light.*/ -struct dmfLight -{ - core::vector3df pos;//!<Position of this light. - video::SColorf diffuseColor;//!<Diffuse color. - video::SColorf specularColor;//!<Specular color. - f32 radius;//!<Maximum radius of light. -}; - -/** A structure rapresenting a single water plane. -This structure contains light position coordinates, diffuse colour, specular colour and maximum radius of light.*/ -struct dmfWaterPlane -{ - u32 waterID;//!<ID of specified water plane. - u32 numFaces;//!<number of faces that make this plain.Owing to the fact that this is a rectangle you'll have 1 every time. - u32 firstFace;//!<first face of this plain. - core::dimension2d<u32> tileNum;//!<number of tiles of this water plain. - f32 waveHeight;//!<height of waves. - f32 waveSpeed;//!<waves speed. - f32 waveLength;//!<waves length. -}; - - -/** A function to convert a hexstring to a int. -This function converts an hex string (i.e. FF) to its int value (i.e. 255). -\return An int representing the hex input value.*/ -int axtoi(const char *hexStg) -{ - unsigned int intValue = 0; // integer value of hex string - sscanf(hexStg, "%x", &intValue); - return (intValue); -} - - -/** A standard string. -A standard string created with standard template libraries.*/ -typedef core::stringc String; - -//Define a class StringList based on core::array and the defined class String -/** A simple stringlist class based on core::array. -This StringList class is based on core::array and the defined String class. -*/ -class StringList : public core::array<String> -{ -public: - - /**Basic Constructor*/ - StringList() - { - } - - /**Constructor based on file loading. - Look at LoadFromFile specifications.*/ - StringList(io::IReadFile* file) - { - LoadFromFile(file); - } - - /**Basic destructor.*/ - ~StringList() - { - clear(); - } - - //Adds a String to StringList - /** Add a string to this StringList.*/ - void Add(String str/*<String to add to the current StringList*/) - { - push_back(str); - } - - //Loads a stringlist from a file - //note that each String added to StringList - //is separated by a \\n character and it's present - //at the end of line. - /** Loads a StringList from a file. - This function loads a StringList from a file where each string is divided by a \\n char.*/ - void LoadFromFile(io::IReadFile* file) - { - const long sz = file->getSize(); - char* buf = new char[sz+1]; - file->read(buf, sz); - buf[sz] = 0; - char* p = buf; - char* start = p; - - while(*p) - { - if (*p == '\n') - { - core::stringc str(start, (u32)(p - start - 1)); - str.trim(); - Add(str); - start = p+1; - } - - ++p; - } - - if (p - start > 1) - { - core::stringc str(start, (u32)(p - start - 1)); - str.trim(); - Add(str); - } - - delete [] buf; - } -}; - -//This function subdivides a string in a list of strings -/** This function subdivides strings divided by divider in a list of strings. -\return A StringList made of all strings divided by divider.*/ -StringList SubdivideString(const String& str, const String& divider) -{ - StringList strings; //returned StringList - strings.clear(); //clear returned stringlist - - int c=0; - int l=str.size(); - - //process entire string - while(c<l) - { - String resultstr; - resultstr = ""; - //read characters until divider is encountered - while((str[c]!=divider[0]) && c<l) - { - resultstr += str[c]; - ++c; - } - - //Remove spaces \t and \n from string in my implementation... - //pay attention or change it in dll.h if you don't want to remove - //a particular char. - resultstr.trim();//trims string resultstr - strings.Add(resultstr);//add trimmed string - ++c; - } - - return strings; -} - - -//Get DeleD informations and convert in dmfHeader -/**This function extract a dmfHeader from a DMF file. -You must give in input a StringList representing a DMF file loaded with LoadFromFile. -\return true if function succeed or false on fail.*/ -bool GetDMFHeader(const StringList& RawFile, dmfHeader& header) -{ - StringList temp=SubdivideString(RawFile[0],String(";")); //file info - - if ( temp[0] != String("DeleD Map File") ) - return false; //not a deled file - - temp.clear(); - temp = SubdivideString(RawFile[1],String(" "));//get version - StringList temp1=SubdivideString(temp[1],String(";")); - - header.dmfVersion = (float)atof(temp1[0].c_str());//save version - if (header.dmfVersion < 0.91) - return false;//not correct version - - temp.clear(); - temp = SubdivideString(RawFile[2],String(";"));//get name,ambient color and shadow opacity - header.dmfName=temp[0];//save name - - //set ambient color - header.dmfAmbient.set(axtoi(temp[1].c_str())); - - //set Shadow intensity - header.dmfShadow = (float)atof(temp[2].c_str()); - - //set current position - int offs=3; - - //set Materials Number - header.numMaterials=atoi(RawFile[offs].c_str()); - offs+=header.numMaterials; - ++offs; - - //set Object Number - header.numObjects=atoi(RawFile[offs].c_str()); - - //retrieve face and vertices number - header.numVertices=0; - header.numFaces=0; - header.numWatFaces=0; - header.numWatVertices=0; - offs++; - - s32 fac; - int i; - - for(i=0; i < (int)header.numObjects; i++) - { - StringList wat=SubdivideString(RawFile[offs],String(";")); - StringList wat1=SubdivideString(wat[0],String("_")); - - ++offs; - offs += atoi(RawFile[offs].c_str()); - ++offs; - - fac=atoi(RawFile[offs].c_str()); - - if(!(wat1[0]==String("water") && wat[2]==String("0"))) - header.numFaces = header.numFaces + fac; - else - header.numWatFaces = header.numWatFaces + fac; - - offs++; - - for(int j=0; j<fac; j++) - { - if(!(wat1[0] == String("water") && wat[2] == String("0"))) - header.numVertices=header.numVertices + atoi(RawFile[offs+j].c_str()); - else - header.numWatVertices=header.numWatVertices + atoi(RawFile[offs + j].c_str()); - } - - offs = offs + fac; - } - - //retrieve number of dynamic lights - header.numLights=0; - temp.clear(); - temp1.clear(); - s32 lit = atoi(RawFile[offs].c_str()); - - for (i=0; i<lit; i++) - { - offs++; - temp=SubdivideString(RawFile[offs],String(";")); - - if(atoi(temp[0].c_str())==1) - { - temp1=SubdivideString(temp[18],String("_")); - - if(temp1[0]==String("dynamic")) - header.numLights++; - } - temp.clear(); - temp1.clear(); - } - - return true; //everything is OK so loading is correct -} - - -/**This function extract an array of dmfMaterial from a DMF file. -You must give in input a StringList representing a DMF file loaded with LoadFromFile. -\param RawFile StringList representing a DMF file. -\param materials Materials returned. -\param num_material Number of materials contained in DMF file. -\param use_material_dirs Here you can choose to use default DeleD structure for material dirs. -\return true if function succeed or false on fail.*/ -bool GetDMFMaterials(const StringList& RawFile, - core::array<dmfMaterial>& materials, - int num_material) -{ - // offset for already handled lines - const int offs=4; - - StringList temp; - StringList temp1; - - // The number of materials is predetermined - materials.reallocate(num_material); - for(int i=0; i<num_material; ++i) - { - materials.push_back(dmfMaterial()); - // get all tokens - temp=SubdivideString(RawFile[offs+i],";"); - // should be equal to first token - materials[i].materialID = i; - // The path used for the texture - materials[i].pathName = temp[2]; - materials[i].pathName.replace('\\','/'); - materials[i].pathName += "/"; - // temp[3] is reserved, temp[4] is the number of texture layers - materials[i].textureLayers = core::strtol10(temp[4].c_str()); - // Three values are separated by commas - temp1=SubdivideString(temp[5],","); - - materials[i].textureFlag = atoi(temp1[0].c_str()); - materials[i].textureName=temp1[1]; - materials[i].textureName.replace('\\','/'); - materials[i].textureBlend = atoi(temp1[2].c_str()); - if(temp.size()>=9) - { - temp1=SubdivideString(temp[temp.size() - 1],","); - materials[i].lightmapFlag=atoi(temp1[0].c_str()); - materials[i].lightmapName=temp1[1]; - materials[i].lightmapName.replace('\\','/'); - materials[i].lightmapBlend = atoi(temp1[2].c_str()); - } - else - { - materials[i].lightmapFlag=1; - materials[i].lightmapName=""; - } - } - return true; -} - - -/**This function extract an array of dmfMaterial from a DMF file considering 1st an 2nd layer for water plains. -You must give in input a StringList representing a DMF file loaded with LoadFromFile. -\return true if function succeed or false on fail.*/ -bool GetDMFWaterMaterials(const StringList& RawFile /**<StringList representing a DMF file.*/, - core::array<dmfMaterial>& materials/**<Materials returned.*/, - int num_material/**<Number of materials contained in DMF file.*/ - ) -{ - int offs=4; - StringList temp; - StringList temp1; - StringList temp2; - //Checking if this is a DeleD map File of version >= 0.91 - temp=SubdivideString(RawFile[0],String(";"));//file info - - if ( temp[0] != String("DeleD Map File") ) - return false;//not a deled file - - temp.clear(); - temp=SubdivideString(RawFile[1],String(" "));//get version - temp1=SubdivideString(temp[1],String(";")); - - if (atof(temp1[0].c_str()) < 0.91) - return false;//not correct version - - //end checking - temp.clear(); - temp1.clear(); - - for(int i=0;i<num_material;i++) - { - temp = SubdivideString(RawFile[offs+i],";"); - materials[i].materialID=i; - - temp1 = SubdivideString(temp[5],","); - materials[i].textureFlag=atoi(temp1[0].c_str()); - temp2 = SubdivideString(temp1[1],"\\"); - - materials[i].textureName=temp2.getLast(); - temp1.clear(); - temp2.clear(); - int a=temp.size(); - if(a==7) - { - temp1=SubdivideString(temp[6],","); - materials[i].lightmapFlag=atoi(temp1[0].c_str()); - temp2=SubdivideString(temp1[1],"\\"); - materials[i].lightmapName=temp2.getLast(); - } - else - { - materials[i].lightmapFlag=1; - materials[i].lightmapName="FFFFFFFF"; - } - temp1.clear(); - temp2.clear(); - } - return true; -} - - -/**This function extract an array of dmfVert and dmfFace from a DMF file. -You must give in input a StringList representing a DMF file loaded with LoadFromFile and two arrays long enough. -Please use GetDMFHeader() before this function to know number of vertices and faces. -\return true if function succeed or false on fail.*/ -bool GetDMFVerticesFaces(const StringList& RawFile/**<StringList representing a DMF file.*/, - dmfVert vertices[]/**<Vertices returned*/, - dmfFace faces[]/**Faces returned*/ - ) -{ - StringList temp,temp1; - - // skip materials - s32 offs = 4 + atoi(RawFile[3].c_str()); - - const s32 objs = atoi(RawFile[offs].c_str()); - offs++; -#ifdef _IRR_DMF_DEBUG_ - os::Printer::log("Reading objects", core::stringc(objs).c_str()); -#endif - - s32 vert_cnt=0, face_cnt=0; - for (int i=0; i<objs; ++i) - { - StringList wat=SubdivideString(RawFile[offs],";"); - StringList wat1=SubdivideString(wat[0],"_"); -#ifdef _IRR_DMF_DEBUG_ - os::Printer::log("Reading object", wat[0].c_str()); -#endif - - offs++; - // load vertices - core::array<core::vector3df> pos; - const u32 posCount = core::strtol10(RawFile[offs].c_str()); - ++offs; - pos.reallocate(posCount); - for (u32 i=0; i<posCount; ++i) - { - temp1=SubdivideString(RawFile[offs].c_str(),";"); - pos.push_back(core::vector3df(core::fast_atof(temp1[0].c_str()), - core::fast_atof(temp1[1].c_str()), - -core::fast_atof(temp1[2].c_str()))); - ++offs; - } - - const s32 numFaces=atoi(RawFile[offs].c_str()); - offs++; - if(!(wat1[0]==String("water") && wat[2]==String("0"))) - { - for(s32 j=0; j<numFaces; ++j) - { - temp=SubdivideString(RawFile[offs+j],";"); - - //first value is vertices number for this face - const s32 vert=core::strtol10(temp[0].c_str()); - faces[face_cnt].numVerts=vert; - //second is material ID - faces[face_cnt].materialID=atoi(temp[1].c_str()); - //vertices are ordined - faces[face_cnt].firstVert=vert_cnt; - - //now we'll create vertices structure - for(s32 k=0; k<vert; ++k) - { - //copy position - vertices[vert_cnt].pos.set(pos[core::strtol10(temp[2+k].c_str())]); - //get uv coords for tex and light if any - vertices[vert_cnt].tc.set(core::fast_atof(temp[2+vert+(2*k)].c_str()), - core::fast_atof(temp[2+vert+(2*k)+1].c_str())); - const u32 tmp_sz=temp.size(); - vertices[vert_cnt].lc.set(core::fast_atof(temp[tmp_sz-(2*vert)+(2*k)].c_str()), - core::fast_atof(temp[tmp_sz-(2*vert)+(2*k)+1].c_str())); - vert_cnt++; - } - - face_cnt++; - } - } - - offs+=numFaces; - } - - return true; -} - - -/**This function extract an array of dmfLights from a DMF file. -You must give in input a StringList representing a DMF file loaded with -LoadFromFile and one array long enough. Please use GetDMFHeader() before this -function to know number of dynamic lights. -\return true if function succeed or false on fail.*/ -bool GetDMFLights(const StringList& RawFile/**<StringList representing a DMF file.*/, - dmfLight lights[]/**<Lights returned.*/ - ) -{ - int offs=3; - StringList temp,temp1; - - //Checking if this is a DeleD map File of version >= 0.91 - temp=SubdivideString(RawFile[0],String(";"));//file info - - if ( temp[0] != String("DeleD Map File") ) - return false;//not a deled file - - temp.clear(); - temp=SubdivideString(RawFile[1],String(" "));//get version - temp1=SubdivideString(temp[1],String(";")); - - if (atof(temp1[0].c_str()) < 0.91) - return false;//not correct version - - //end checking - - temp.clear(); - temp1.clear(); - offs=offs + atoi(RawFile[offs].c_str()); - offs++; - s32 objs = atoi(RawFile[offs].c_str()); - s32 lit=0; - s32 d_lit=0; - offs++; - - //let's get position of lights in file - int i; - for(i=0;i<objs;i++) - { - offs++; - - offs = offs + atoi(RawFile[offs].c_str()); - offs++; - - offs = offs + atoi(RawFile[offs].c_str()); - offs++; - } - - //let's find dynamic lights - lit = atoi(RawFile[offs].c_str()); - - for(i=0;i<lit;i++) - { - offs++; - temp=SubdivideString(RawFile[offs],String(";")); - if(atoi(temp[0].c_str())==1) - { - temp1=SubdivideString(temp[18],String("_")); - if(temp1[0]==String("dynamic")) - { - lights[d_lit].radius = (float)atof(temp[4].c_str()); - lights[d_lit].pos.set((float)atof(temp[5].c_str()), - (float)atof(temp[6].c_str()), - (float)-atof(temp[7].c_str())); - - lights[d_lit].diffuseColor = video::SColorf( - video::SColor(255, atoi(temp[10].c_str()), atoi(temp[11].c_str()), - atoi(temp[12].c_str()))); - - lights[d_lit].specularColor = video::SColorf( - video::SColor(255, atoi(temp[13].c_str()), atoi(temp[14].c_str()), - atoi(temp[15].c_str()))); - - d_lit++; - } - } - temp.clear(); - temp1.clear(); - } - - return true; -} - - -/**This function extracts an array of dmfWaterPlane,dmfVert and dmfFace from a DMF file. -You must give in input a StringList representing a DMF file loaded with LoadFromFile and three arrays long enough. -Please use GetDMFHeader() before this function to know number of water plains and water faces as well as water vertices. -\return true if function succeed or false on fail.*/ -bool GetDMFWaterPlanes(const StringList& RawFile/**<StringList representing a DMF file.*/, - dmfWaterPlane wat_planes[]/**<Water planes returned.*/, - dmfVert vertices[]/**<Vertices returned*/, - dmfFace faces[]/**Faces returned*/ - ) -{ - int offs=3; - int offs1=0; - StringList temp,temp1; - - //Checking if this is a DeleD map File of version >= 0.91 - temp=SubdivideString(RawFile[0],String(";"));//file info - - if ( temp[0] != String("DeleD Map File") ) - return false;//not a deled file - - temp.clear(); - temp=SubdivideString(RawFile[1],String(" "));//get version - temp1=SubdivideString(temp[1],String(";")); - - if (atof(temp1[0].c_str()) < 0.91) - return false;//not correct version - - //end checking - - temp.clear(); - temp1.clear(); - offs=offs+atoi(RawFile[offs].c_str()); - offs++; - s32 objs=atoi(RawFile[offs].c_str()); - s32 fac=0,vert=0,tmp_sz=0,vert_cnt=0,face_cnt=0,wat_id=0; - core::dimension2d<u32> tilenum(40,40); - f32 waveheight=3.0f; - f32 wavespeed=300.0f; - f32 wavelength=80.0f; - offs++; - - for(int i=0;i<objs;i++) - { - StringList wat=SubdivideString(RawFile[offs],";"); - StringList wat1=SubdivideString(wat[0],"_"); - offs++; - offs1=offs; - offs=offs+atoi(RawFile[offs].c_str()); - offs++; - offs1++; - fac=atoi(RawFile[offs].c_str()); - offs++; - - if(wat1[0]==String("water") && wat[2]==String("0")) - { - StringList userinfo=SubdivideString(wat[7],","); - - int j; - - for (j=0; j<(int)userinfo.size(); j++) - { - switch(j) - { - case 0: - if(atoi(userinfo[0].c_str())) - tilenum.Width = atoi(userinfo[0].c_str()); - break; - case 1: - if(atoi(userinfo[1].c_str())) - tilenum.Height = atoi(userinfo[1].c_str()); - break; - case 2: - if(atof(userinfo[2].c_str())) - waveheight = (float)atof(userinfo[2].c_str()); - break; - case 3: - if(atof(userinfo[3].c_str())) - wavespeed = (float)atof(userinfo[3].c_str()); - break; - case 4: - if(atof(userinfo[4].c_str())) - wavelength = (float)atof(userinfo[4].c_str()); - break; - } - } - - wat_planes[wat_id].waterID=wat_id; - wat_planes[wat_id].numFaces=fac; - wat_planes[wat_id].firstFace=face_cnt; - wat_planes[wat_id].tileNum=tilenum; - wat_planes[wat_id].waveHeight=waveheight; - wat_planes[wat_id].waveSpeed=wavespeed; - wat_planes[wat_id].waveLength=wavelength; - - for(j=0;j<fac;j++) - { - temp=SubdivideString(RawFile[offs+j],";"); - - //first value is vertices number for this face - faces[face_cnt].numVerts=atoi(temp[0].c_str()); - vert=faces[face_cnt].numVerts; - //second is material ID - faces[face_cnt].materialID=atoi(temp[1].c_str()); - //vertices are ordined - faces[face_cnt].firstVert=vert_cnt; - - //now we'll create vertices structure - for(int k=0;k<vert;k++) - { - //get vertex position - temp1=SubdivideString(RawFile[offs1+atoi(temp[2+k].c_str())], ";"); - - //copy x,y,z values - vertices[vert_cnt].pos.set((float)atof(temp1[0].c_str()), - (float)atof(temp1[1].c_str()), - (float)-atof(temp1[2].c_str())); - - //get uv coords for tex and light if any - vertices[vert_cnt].tc.set((float)atof(temp[2+vert+(2*k)].c_str()), - (float)atof(temp[2+vert+(2*k)+1].c_str())); - tmp_sz=temp.size(); - - vertices[vert_cnt].lc.set((float)atof(temp[tmp_sz-(2*vert)+(2*k)].c_str()), - (float)atof(temp[tmp_sz-(2*vert)+(2*k)+1].c_str())); - ++vert_cnt; - temp1.clear(); - } - ++face_cnt; - temp.clear(); - } - } - offs=offs+fac; - } - - return true; -} - -} // end namespace -} // end namespace - -#endif /* __DMF_SUPPORT_H__ */ diff --git a/irrlicht-1.6/source/Irrlicht/glext.h b/irrlicht-1.6/source/Irrlicht/glext.h deleted file mode 100644 index e4f320318..000000000 --- a/irrlicht-1.6/source/Irrlicht/glext.h +++ /dev/null @@ -1,9253 +0,0 @@ -#ifndef __glext_h_ -#define __glext_h_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* -** Copyright (c) 2007-2009 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -/* Header file version number, required by OpenGL ABI for Linux */ -/* glext.h last updated $Date: 2009-08-03 02:13:51 -0700 (Mon, 03 Aug 2009) $ */ -/* Current version at http://www.opengl.org/registry/ */ -#define GL_GLEXT_VERSION 54 - -/* Function declaration macros - to move into glplatform.h */ - -#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) -#define WIN32_LEAN_AND_MEAN 1 -#include <windows.h> -#endif - -#ifndef APIENTRY -#define APIENTRY -#endif -#ifndef APIENTRYP -#define APIENTRYP APIENTRY * -#endif -#ifndef GLAPI -#define GLAPI extern -#endif - -/*************************************************************/ - -#ifndef GL_VERSION_1_2 -#define GL_UNSIGNED_BYTE_3_3_2 0x8032 -#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 -#define GL_UNSIGNED_INT_8_8_8_8 0x8035 -#define GL_UNSIGNED_INT_10_10_10_2 0x8036 -#define GL_TEXTURE_BINDING_3D 0x806A -#define GL_PACK_SKIP_IMAGES 0x806B -#define GL_PACK_IMAGE_HEIGHT 0x806C -#define GL_UNPACK_SKIP_IMAGES 0x806D -#define GL_UNPACK_IMAGE_HEIGHT 0x806E -#define GL_TEXTURE_3D 0x806F -#define GL_PROXY_TEXTURE_3D 0x8070 -#define GL_TEXTURE_DEPTH 0x8071 -#define GL_TEXTURE_WRAP_R 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE 0x8073 -#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 -#define GL_UNSIGNED_SHORT_5_6_5 0x8363 -#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 -#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 -#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 -#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 -#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 -#define GL_BGR 0x80E0 -#define GL_BGRA 0x80E1 -#define GL_MAX_ELEMENTS_VERTICES 0x80E8 -#define GL_MAX_ELEMENTS_INDICES 0x80E9 -#define GL_CLAMP_TO_EDGE 0x812F -#define GL_TEXTURE_MIN_LOD 0x813A -#define GL_TEXTURE_MAX_LOD 0x813B -#define GL_TEXTURE_BASE_LEVEL 0x813C -#define GL_TEXTURE_MAX_LEVEL 0x813D -#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 -#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 -#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 -#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 -#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E -#endif - -#ifndef GL_VERSION_1_2_DEPRECATED -#define GL_RESCALE_NORMAL 0x803A -#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 -#define GL_SINGLE_COLOR 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR 0x81FA -#define GL_ALIASED_POINT_SIZE_RANGE 0x846D -#endif - -#ifndef GL_ARB_imaging -#define GL_CONSTANT_COLOR 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 -#define GL_CONSTANT_ALPHA 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 -#define GL_BLEND_COLOR 0x8005 -#define GL_FUNC_ADD 0x8006 -#define GL_MIN 0x8007 -#define GL_MAX 0x8008 -#define GL_BLEND_EQUATION 0x8009 -#define GL_FUNC_SUBTRACT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT 0x800B -#endif - -#ifndef GL_ARB_imaging_DEPRECATED -#define GL_CONVOLUTION_1D 0x8010 -#define GL_CONVOLUTION_2D 0x8011 -#define GL_SEPARABLE_2D 0x8012 -#define GL_CONVOLUTION_BORDER_MODE 0x8013 -#define GL_CONVOLUTION_FILTER_SCALE 0x8014 -#define GL_CONVOLUTION_FILTER_BIAS 0x8015 -#define GL_REDUCE 0x8016 -#define GL_CONVOLUTION_FORMAT 0x8017 -#define GL_CONVOLUTION_WIDTH 0x8018 -#define GL_CONVOLUTION_HEIGHT 0x8019 -#define GL_MAX_CONVOLUTION_WIDTH 0x801A -#define GL_MAX_CONVOLUTION_HEIGHT 0x801B -#define GL_POST_CONVOLUTION_RED_SCALE 0x801C -#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D -#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E -#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F -#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 -#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 -#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 -#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 -#define GL_HISTOGRAM 0x8024 -#define GL_PROXY_HISTOGRAM 0x8025 -#define GL_HISTOGRAM_WIDTH 0x8026 -#define GL_HISTOGRAM_FORMAT 0x8027 -#define GL_HISTOGRAM_RED_SIZE 0x8028 -#define GL_HISTOGRAM_GREEN_SIZE 0x8029 -#define GL_HISTOGRAM_BLUE_SIZE 0x802A -#define GL_HISTOGRAM_ALPHA_SIZE 0x802B -#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C -#define GL_HISTOGRAM_SINK 0x802D -#define GL_MINMAX 0x802E -#define GL_MINMAX_FORMAT 0x802F -#define GL_MINMAX_SINK 0x8030 -#define GL_TABLE_TOO_LARGE 0x8031 -#define GL_COLOR_MATRIX 0x80B1 -#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 -#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 -#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 -#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 -#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 -#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 -#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 -#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 -#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA -#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB -#define GL_COLOR_TABLE 0x80D0 -#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 -#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 -#define GL_PROXY_COLOR_TABLE 0x80D3 -#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 -#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 -#define GL_COLOR_TABLE_SCALE 0x80D6 -#define GL_COLOR_TABLE_BIAS 0x80D7 -#define GL_COLOR_TABLE_FORMAT 0x80D8 -#define GL_COLOR_TABLE_WIDTH 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF -#define GL_CONSTANT_BORDER 0x8151 -#define GL_REPLICATE_BORDER 0x8153 -#define GL_CONVOLUTION_BORDER_COLOR 0x8154 -#endif - -#ifndef GL_VERSION_1_3 -#define GL_TEXTURE0 0x84C0 -#define GL_TEXTURE1 0x84C1 -#define GL_TEXTURE2 0x84C2 -#define GL_TEXTURE3 0x84C3 -#define GL_TEXTURE4 0x84C4 -#define GL_TEXTURE5 0x84C5 -#define GL_TEXTURE6 0x84C6 -#define GL_TEXTURE7 0x84C7 -#define GL_TEXTURE8 0x84C8 -#define GL_TEXTURE9 0x84C9 -#define GL_TEXTURE10 0x84CA -#define GL_TEXTURE11 0x84CB -#define GL_TEXTURE12 0x84CC -#define GL_TEXTURE13 0x84CD -#define GL_TEXTURE14 0x84CE -#define GL_TEXTURE15 0x84CF -#define GL_TEXTURE16 0x84D0 -#define GL_TEXTURE17 0x84D1 -#define GL_TEXTURE18 0x84D2 -#define GL_TEXTURE19 0x84D3 -#define GL_TEXTURE20 0x84D4 -#define GL_TEXTURE21 0x84D5 -#define GL_TEXTURE22 0x84D6 -#define GL_TEXTURE23 0x84D7 -#define GL_TEXTURE24 0x84D8 -#define GL_TEXTURE25 0x84D9 -#define GL_TEXTURE26 0x84DA -#define GL_TEXTURE27 0x84DB -#define GL_TEXTURE28 0x84DC -#define GL_TEXTURE29 0x84DD -#define GL_TEXTURE30 0x84DE -#define GL_TEXTURE31 0x84DF -#define GL_ACTIVE_TEXTURE 0x84E0 -#define GL_MULTISAMPLE 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE 0x809F -#define GL_SAMPLE_COVERAGE 0x80A0 -#define GL_SAMPLE_BUFFERS 0x80A8 -#define GL_SAMPLES 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT 0x80AB -#define GL_TEXTURE_CUBE_MAP 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C -#define GL_COMPRESSED_RGB 0x84ED -#define GL_COMPRESSED_RGBA 0x84EE -#define GL_TEXTURE_COMPRESSION_HINT 0x84EF -#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 -#define GL_TEXTURE_COMPRESSED 0x86A1 -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 -#define GL_CLAMP_TO_BORDER 0x812D -#endif - -#ifndef GL_VERSION_1_3_DEPRECATED -#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 -#define GL_MAX_TEXTURE_UNITS 0x84E2 -#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 -#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 -#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 -#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 -#define GL_MULTISAMPLE_BIT 0x20000000 -#define GL_NORMAL_MAP 0x8511 -#define GL_REFLECTION_MAP 0x8512 -#define GL_COMPRESSED_ALPHA 0x84E9 -#define GL_COMPRESSED_LUMINANCE 0x84EA -#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB -#define GL_COMPRESSED_INTENSITY 0x84EC -#define GL_COMBINE 0x8570 -#define GL_COMBINE_RGB 0x8571 -#define GL_COMBINE_ALPHA 0x8572 -#define GL_SOURCE0_RGB 0x8580 -#define GL_SOURCE1_RGB 0x8581 -#define GL_SOURCE2_RGB 0x8582 -#define GL_SOURCE0_ALPHA 0x8588 -#define GL_SOURCE1_ALPHA 0x8589 -#define GL_SOURCE2_ALPHA 0x858A -#define GL_OPERAND0_RGB 0x8590 -#define GL_OPERAND1_RGB 0x8591 -#define GL_OPERAND2_RGB 0x8592 -#define GL_OPERAND0_ALPHA 0x8598 -#define GL_OPERAND1_ALPHA 0x8599 -#define GL_OPERAND2_ALPHA 0x859A -#define GL_RGB_SCALE 0x8573 -#define GL_ADD_SIGNED 0x8574 -#define GL_INTERPOLATE 0x8575 -#define GL_SUBTRACT 0x84E7 -#define GL_CONSTANT 0x8576 -#define GL_PRIMARY_COLOR 0x8577 -#define GL_PREVIOUS 0x8578 -#define GL_DOT3_RGB 0x86AE -#define GL_DOT3_RGBA 0x86AF -#endif - -#ifndef GL_VERSION_1_4 -#define GL_BLEND_DST_RGB 0x80C8 -#define GL_BLEND_SRC_RGB 0x80C9 -#define GL_BLEND_DST_ALPHA 0x80CA -#define GL_BLEND_SRC_ALPHA 0x80CB -#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 -#define GL_DEPTH_COMPONENT16 0x81A5 -#define GL_DEPTH_COMPONENT24 0x81A6 -#define GL_DEPTH_COMPONENT32 0x81A7 -#define GL_MIRRORED_REPEAT 0x8370 -#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD -#define GL_TEXTURE_LOD_BIAS 0x8501 -#define GL_INCR_WRAP 0x8507 -#define GL_DECR_WRAP 0x8508 -#define GL_TEXTURE_DEPTH_SIZE 0x884A -#define GL_TEXTURE_COMPARE_MODE 0x884C -#define GL_TEXTURE_COMPARE_FUNC 0x884D -#endif - -#ifndef GL_VERSION_1_4_DEPRECATED -#define GL_POINT_SIZE_MIN 0x8126 -#define GL_POINT_SIZE_MAX 0x8127 -#define GL_POINT_DISTANCE_ATTENUATION 0x8129 -#define GL_GENERATE_MIPMAP 0x8191 -#define GL_GENERATE_MIPMAP_HINT 0x8192 -#define GL_FOG_COORDINATE_SOURCE 0x8450 -#define GL_FOG_COORDINATE 0x8451 -#define GL_FRAGMENT_DEPTH 0x8452 -#define GL_CURRENT_FOG_COORDINATE 0x8453 -#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 -#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 -#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 -#define GL_FOG_COORDINATE_ARRAY 0x8457 -#define GL_COLOR_SUM 0x8458 -#define GL_CURRENT_SECONDARY_COLOR 0x8459 -#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A -#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B -#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C -#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D -#define GL_SECONDARY_COLOR_ARRAY 0x845E -#define GL_TEXTURE_FILTER_CONTROL 0x8500 -#define GL_DEPTH_TEXTURE_MODE 0x884B -#define GL_COMPARE_R_TO_TEXTURE 0x884E -#endif - -#ifndef GL_VERSION_1_5 -#define GL_BUFFER_SIZE 0x8764 -#define GL_BUFFER_USAGE 0x8765 -#define GL_QUERY_COUNTER_BITS 0x8864 -#define GL_CURRENT_QUERY 0x8865 -#define GL_QUERY_RESULT 0x8866 -#define GL_QUERY_RESULT_AVAILABLE 0x8867 -#define GL_ARRAY_BUFFER 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER 0x8893 -#define GL_ARRAY_BUFFER_BINDING 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F -#define GL_READ_ONLY 0x88B8 -#define GL_WRITE_ONLY 0x88B9 -#define GL_READ_WRITE 0x88BA -#define GL_BUFFER_ACCESS 0x88BB -#define GL_BUFFER_MAPPED 0x88BC -#define GL_BUFFER_MAP_POINTER 0x88BD -#define GL_STREAM_DRAW 0x88E0 -#define GL_STREAM_READ 0x88E1 -#define GL_STREAM_COPY 0x88E2 -#define GL_STATIC_DRAW 0x88E4 -#define GL_STATIC_READ 0x88E5 -#define GL_STATIC_COPY 0x88E6 -#define GL_DYNAMIC_DRAW 0x88E8 -#define GL_DYNAMIC_READ 0x88E9 -#define GL_DYNAMIC_COPY 0x88EA -#define GL_SAMPLES_PASSED 0x8914 -#endif - -#ifndef GL_VERSION_1_5_DEPRECATED -#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 -#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A -#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B -#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C -#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D -#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E -#define GL_FOG_COORD_SRC 0x8450 -#define GL_FOG_COORD 0x8451 -#define GL_CURRENT_FOG_COORD 0x8453 -#define GL_FOG_COORD_ARRAY_TYPE 0x8454 -#define GL_FOG_COORD_ARRAY_STRIDE 0x8455 -#define GL_FOG_COORD_ARRAY_POINTER 0x8456 -#define GL_FOG_COORD_ARRAY 0x8457 -#define GL_FOG_COORD_ARRAY_BUFFER_BINDING 0x889D -#define GL_SRC0_RGB 0x8580 -#define GL_SRC1_RGB 0x8581 -#define GL_SRC2_RGB 0x8582 -#define GL_SRC0_ALPHA 0x8588 -#define GL_SRC1_ALPHA 0x8589 -#define GL_SRC2_ALPHA 0x858A -#endif - -#ifndef GL_VERSION_2_0 -#define GL_BLEND_EQUATION_RGB 0x8009 -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 -#define GL_CURRENT_VERTEX_ATTRIB 0x8626 -#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 -#define GL_STENCIL_BACK_FUNC 0x8800 -#define GL_STENCIL_BACK_FAIL 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 -#define GL_MAX_DRAW_BUFFERS 0x8824 -#define GL_DRAW_BUFFER0 0x8825 -#define GL_DRAW_BUFFER1 0x8826 -#define GL_DRAW_BUFFER2 0x8827 -#define GL_DRAW_BUFFER3 0x8828 -#define GL_DRAW_BUFFER4 0x8829 -#define GL_DRAW_BUFFER5 0x882A -#define GL_DRAW_BUFFER6 0x882B -#define GL_DRAW_BUFFER7 0x882C -#define GL_DRAW_BUFFER8 0x882D -#define GL_DRAW_BUFFER9 0x882E -#define GL_DRAW_BUFFER10 0x882F -#define GL_DRAW_BUFFER11 0x8830 -#define GL_DRAW_BUFFER12 0x8831 -#define GL_DRAW_BUFFER13 0x8832 -#define GL_DRAW_BUFFER14 0x8833 -#define GL_DRAW_BUFFER15 0x8834 -#define GL_BLEND_EQUATION_ALPHA 0x883D -#define GL_MAX_VERTEX_ATTRIBS 0x8869 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A -#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 -#define GL_FRAGMENT_SHADER 0x8B30 -#define GL_VERTEX_SHADER 0x8B31 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A -#define GL_MAX_VARYING_FLOATS 0x8B4B -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D -#define GL_SHADER_TYPE 0x8B4F -#define GL_FLOAT_VEC2 0x8B50 -#define GL_FLOAT_VEC3 0x8B51 -#define GL_FLOAT_VEC4 0x8B52 -#define GL_INT_VEC2 0x8B53 -#define GL_INT_VEC3 0x8B54 -#define GL_INT_VEC4 0x8B55 -#define GL_BOOL 0x8B56 -#define GL_BOOL_VEC2 0x8B57 -#define GL_BOOL_VEC3 0x8B58 -#define GL_BOOL_VEC4 0x8B59 -#define GL_FLOAT_MAT2 0x8B5A -#define GL_FLOAT_MAT3 0x8B5B -#define GL_FLOAT_MAT4 0x8B5C -#define GL_SAMPLER_1D 0x8B5D -#define GL_SAMPLER_2D 0x8B5E -#define GL_SAMPLER_3D 0x8B5F -#define GL_SAMPLER_CUBE 0x8B60 -#define GL_SAMPLER_1D_SHADOW 0x8B61 -#define GL_SAMPLER_2D_SHADOW 0x8B62 -#define GL_DELETE_STATUS 0x8B80 -#define GL_COMPILE_STATUS 0x8B81 -#define GL_LINK_STATUS 0x8B82 -#define GL_VALIDATE_STATUS 0x8B83 -#define GL_INFO_LOG_LENGTH 0x8B84 -#define GL_ATTACHED_SHADERS 0x8B85 -#define GL_ACTIVE_UNIFORMS 0x8B86 -#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 -#define GL_SHADER_SOURCE_LENGTH 0x8B88 -#define GL_ACTIVE_ATTRIBUTES 0x8B89 -#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B -#define GL_SHADING_LANGUAGE_VERSION 0x8B8C -#define GL_CURRENT_PROGRAM 0x8B8D -#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 -#define GL_LOWER_LEFT 0x8CA1 -#define GL_UPPER_LEFT 0x8CA2 -#define GL_STENCIL_BACK_REF 0x8CA3 -#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 -#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 -#endif - -#ifndef GL_VERSION_2_0_DEPRECATED -#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 -#define GL_POINT_SPRITE 0x8861 -#define GL_COORD_REPLACE 0x8862 -#define GL_MAX_TEXTURE_COORDS 0x8871 -#endif - -#ifndef GL_VERSION_2_1 -#define GL_PIXEL_PACK_BUFFER 0x88EB -#define GL_PIXEL_UNPACK_BUFFER 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF -#define GL_FLOAT_MAT2x3 0x8B65 -#define GL_FLOAT_MAT2x4 0x8B66 -#define GL_FLOAT_MAT3x2 0x8B67 -#define GL_FLOAT_MAT3x4 0x8B68 -#define GL_FLOAT_MAT4x2 0x8B69 -#define GL_FLOAT_MAT4x3 0x8B6A -#define GL_SRGB 0x8C40 -#define GL_SRGB8 0x8C41 -#define GL_SRGB_ALPHA 0x8C42 -#define GL_SRGB8_ALPHA8 0x8C43 -#define GL_COMPRESSED_SRGB 0x8C48 -#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 -#endif - -#ifndef GL_VERSION_2_1_DEPRECATED -#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F -#define GL_SLUMINANCE_ALPHA 0x8C44 -#define GL_SLUMINANCE8_ALPHA8 0x8C45 -#define GL_SLUMINANCE 0x8C46 -#define GL_SLUMINANCE8 0x8C47 -#define GL_COMPRESSED_SLUMINANCE 0x8C4A -#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B -#endif - -#ifndef GL_VERSION_3_0 -#define GL_COMPARE_REF_TO_TEXTURE 0x884E -#define GL_CLIP_DISTANCE0 0x3000 -#define GL_CLIP_DISTANCE1 0x3001 -#define GL_CLIP_DISTANCE2 0x3002 -#define GL_CLIP_DISTANCE3 0x3003 -#define GL_CLIP_DISTANCE4 0x3004 -#define GL_CLIP_DISTANCE5 0x3005 -#define GL_CLIP_DISTANCE6 0x3006 -#define GL_CLIP_DISTANCE7 0x3007 -#define GL_MAX_CLIP_DISTANCES 0x0D32 -#define GL_MAJOR_VERSION 0x821B -#define GL_MINOR_VERSION 0x821C -#define GL_NUM_EXTENSIONS 0x821D -#define GL_CONTEXT_FLAGS 0x821E -#define GL_DEPTH_BUFFER 0x8223 -#define GL_STENCIL_BUFFER 0x8224 -#define GL_COMPRESSED_RED 0x8225 -#define GL_COMPRESSED_RG 0x8226 -#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x0001 -#define GL_RGBA32F 0x8814 -#define GL_RGB32F 0x8815 -#define GL_RGBA16F 0x881A -#define GL_RGB16F 0x881B -#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD -#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF -#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 -#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 -#define GL_CLAMP_READ_COLOR 0x891C -#define GL_FIXED_ONLY 0x891D -#define GL_MAX_VARYING_COMPONENTS 0x8B4B -#define GL_TEXTURE_1D_ARRAY 0x8C18 -#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 -#define GL_TEXTURE_2D_ARRAY 0x8C1A -#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B -#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C -#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D -#define GL_R11F_G11F_B10F 0x8C3A -#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B -#define GL_RGB9_E5 0x8C3D -#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E -#define GL_TEXTURE_SHARED_SIZE 0x8C3F -#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 -#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 -#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 -#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 -#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 -#define GL_PRIMITIVES_GENERATED 0x8C87 -#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 -#define GL_RASTERIZER_DISCARD 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B -#define GL_INTERLEAVED_ATTRIBS 0x8C8C -#define GL_SEPARATE_ATTRIBS 0x8C8D -#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E -#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F -#define GL_RGBA32UI 0x8D70 -#define GL_RGB32UI 0x8D71 -#define GL_RGBA16UI 0x8D76 -#define GL_RGB16UI 0x8D77 -#define GL_RGBA8UI 0x8D7C -#define GL_RGB8UI 0x8D7D -#define GL_RGBA32I 0x8D82 -#define GL_RGB32I 0x8D83 -#define GL_RGBA16I 0x8D88 -#define GL_RGB16I 0x8D89 -#define GL_RGBA8I 0x8D8E -#define GL_RGB8I 0x8D8F -#define GL_RED_INTEGER 0x8D94 -#define GL_GREEN_INTEGER 0x8D95 -#define GL_BLUE_INTEGER 0x8D96 -#define GL_RGB_INTEGER 0x8D98 -#define GL_RGBA_INTEGER 0x8D99 -#define GL_BGR_INTEGER 0x8D9A -#define GL_BGRA_INTEGER 0x8D9B -#define GL_SAMPLER_1D_ARRAY 0x8DC0 -#define GL_SAMPLER_2D_ARRAY 0x8DC1 -#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 -#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 -#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 -#define GL_UNSIGNED_INT_VEC2 0x8DC6 -#define GL_UNSIGNED_INT_VEC3 0x8DC7 -#define GL_UNSIGNED_INT_VEC4 0x8DC8 -#define GL_INT_SAMPLER_1D 0x8DC9 -#define GL_INT_SAMPLER_2D 0x8DCA -#define GL_INT_SAMPLER_3D 0x8DCB -#define GL_INT_SAMPLER_CUBE 0x8DCC -#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE -#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF -#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 -#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 -#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 -#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 -#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 -#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 -#define GL_QUERY_WAIT 0x8E13 -#define GL_QUERY_NO_WAIT 0x8E14 -#define GL_QUERY_BY_REGION_WAIT 0x8E15 -#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 -#define GL_BUFFER_ACCESS_FLAGS 0x911F -#define GL_BUFFER_MAP_LENGTH 0x9120 -#define GL_BUFFER_MAP_OFFSET 0x9121 -/* Reuse tokens from ARB_depth_buffer_float */ -/* reuse GL_DEPTH_COMPONENT32F */ -/* reuse GL_DEPTH32F_STENCIL8 */ -/* reuse GL_FLOAT_32_UNSIGNED_INT_24_8_REV */ -/* Reuse tokens from ARB_framebuffer_object */ -/* reuse GL_INVALID_FRAMEBUFFER_OPERATION */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE */ -/* reuse GL_FRAMEBUFFER_DEFAULT */ -/* reuse GL_FRAMEBUFFER_UNDEFINED */ -/* reuse GL_DEPTH_STENCIL_ATTACHMENT */ -/* reuse GL_INDEX */ -/* reuse GL_MAX_RENDERBUFFER_SIZE */ -/* reuse GL_DEPTH_STENCIL */ -/* reuse GL_UNSIGNED_INT_24_8 */ -/* reuse GL_DEPTH24_STENCIL8 */ -/* reuse GL_TEXTURE_STENCIL_SIZE */ -/* reuse GL_TEXTURE_RED_TYPE */ -/* reuse GL_TEXTURE_GREEN_TYPE */ -/* reuse GL_TEXTURE_BLUE_TYPE */ -/* reuse GL_TEXTURE_ALPHA_TYPE */ -/* reuse GL_TEXTURE_DEPTH_TYPE */ -/* reuse GL_UNSIGNED_NORMALIZED */ -/* reuse GL_FRAMEBUFFER_BINDING */ -/* reuse GL_DRAW_FRAMEBUFFER_BINDING */ -/* reuse GL_RENDERBUFFER_BINDING */ -/* reuse GL_READ_FRAMEBUFFER */ -/* reuse GL_DRAW_FRAMEBUFFER */ -/* reuse GL_READ_FRAMEBUFFER_BINDING */ -/* reuse GL_RENDERBUFFER_SAMPLES */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ -/* reuse GL_FRAMEBUFFER_COMPLETE */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER */ -/* reuse GL_FRAMEBUFFER_UNSUPPORTED */ -/* reuse GL_MAX_COLOR_ATTACHMENTS */ -/* reuse GL_COLOR_ATTACHMENT0 */ -/* reuse GL_COLOR_ATTACHMENT1 */ -/* reuse GL_COLOR_ATTACHMENT2 */ -/* reuse GL_COLOR_ATTACHMENT3 */ -/* reuse GL_COLOR_ATTACHMENT4 */ -/* reuse GL_COLOR_ATTACHMENT5 */ -/* reuse GL_COLOR_ATTACHMENT6 */ -/* reuse GL_COLOR_ATTACHMENT7 */ -/* reuse GL_COLOR_ATTACHMENT8 */ -/* reuse GL_COLOR_ATTACHMENT9 */ -/* reuse GL_COLOR_ATTACHMENT10 */ -/* reuse GL_COLOR_ATTACHMENT11 */ -/* reuse GL_COLOR_ATTACHMENT12 */ -/* reuse GL_COLOR_ATTACHMENT13 */ -/* reuse GL_COLOR_ATTACHMENT14 */ -/* reuse GL_COLOR_ATTACHMENT15 */ -/* reuse GL_DEPTH_ATTACHMENT */ -/* reuse GL_STENCIL_ATTACHMENT */ -/* reuse GL_FRAMEBUFFER */ -/* reuse GL_RENDERBUFFER */ -/* reuse GL_RENDERBUFFER_WIDTH */ -/* reuse GL_RENDERBUFFER_HEIGHT */ -/* reuse GL_RENDERBUFFER_INTERNAL_FORMAT */ -/* reuse GL_STENCIL_INDEX1 */ -/* reuse GL_STENCIL_INDEX4 */ -/* reuse GL_STENCIL_INDEX8 */ -/* reuse GL_STENCIL_INDEX16 */ -/* reuse GL_RENDERBUFFER_RED_SIZE */ -/* reuse GL_RENDERBUFFER_GREEN_SIZE */ -/* reuse GL_RENDERBUFFER_BLUE_SIZE */ -/* reuse GL_RENDERBUFFER_ALPHA_SIZE */ -/* reuse GL_RENDERBUFFER_DEPTH_SIZE */ -/* reuse GL_RENDERBUFFER_STENCIL_SIZE */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */ -/* reuse GL_MAX_SAMPLES */ -/* Reuse tokens from ARB_framebuffer_sRGB */ -/* reuse GL_FRAMEBUFFER_SRGB */ -/* Reuse tokens from ARB_half_float_vertex */ -/* reuse GL_HALF_FLOAT */ -/* Reuse tokens from ARB_map_buffer_range */ -/* reuse GL_MAP_READ_BIT */ -/* reuse GL_MAP_WRITE_BIT */ -/* reuse GL_MAP_INVALIDATE_RANGE_BIT */ -/* reuse GL_MAP_INVALIDATE_BUFFER_BIT */ -/* reuse GL_MAP_FLUSH_EXPLICIT_BIT */ -/* reuse GL_MAP_UNSYNCHRONIZED_BIT */ -/* Reuse tokens from ARB_texture_compression_rgtc */ -/* reuse GL_COMPRESSED_RED_RGTC1 */ -/* reuse GL_COMPRESSED_SIGNED_RED_RGTC1 */ -/* reuse GL_COMPRESSED_RG_RGTC2 */ -/* reuse GL_COMPRESSED_SIGNED_RG_RGTC2 */ -/* Reuse tokens from ARB_texture_rg */ -/* reuse GL_RG */ -/* reuse GL_RG_INTEGER */ -/* reuse GL_R8 */ -/* reuse GL_R16 */ -/* reuse GL_RG8 */ -/* reuse GL_RG16 */ -/* reuse GL_R16F */ -/* reuse GL_R32F */ -/* reuse GL_RG16F */ -/* reuse GL_RG32F */ -/* reuse GL_R8I */ -/* reuse GL_R8UI */ -/* reuse GL_R16I */ -/* reuse GL_R16UI */ -/* reuse GL_R32I */ -/* reuse GL_R32UI */ -/* reuse GL_RG8I */ -/* reuse GL_RG8UI */ -/* reuse GL_RG16I */ -/* reuse GL_RG16UI */ -/* reuse GL_RG32I */ -/* reuse GL_RG32UI */ -/* Reuse tokens from ARB_vertex_array_object */ -/* reuse GL_VERTEX_ARRAY_BINDING */ -#endif - -#ifndef GL_VERSION_3_0_DEPRECATED -#define GL_CLAMP_VERTEX_COLOR 0x891A -#define GL_CLAMP_FRAGMENT_COLOR 0x891B -#define GL_ALPHA_INTEGER 0x8D97 -/* Reuse tokens from ARB_framebuffer_object */ -/* reuse GL_TEXTURE_LUMINANCE_TYPE */ -/* reuse GL_TEXTURE_INTENSITY_TYPE */ -#endif - -#ifndef GL_VERSION_3_1 -#define GL_SAMPLER_2D_RECT 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 -#define GL_SAMPLER_BUFFER 0x8DC2 -#define GL_INT_SAMPLER_2D_RECT 0x8DCD -#define GL_INT_SAMPLER_BUFFER 0x8DD0 -#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 -#define GL_TEXTURE_BUFFER 0x8C2A -#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B -#define GL_TEXTURE_BINDING_BUFFER 0x8C2C -#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D -#define GL_TEXTURE_BUFFER_FORMAT 0x8C2E -#define GL_TEXTURE_RECTANGLE 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 -#define GL_RED_SNORM 0x8F90 -#define GL_RG_SNORM 0x8F91 -#define GL_RGB_SNORM 0x8F92 -#define GL_RGBA_SNORM 0x8F93 -#define GL_R8_SNORM 0x8F94 -#define GL_RG8_SNORM 0x8F95 -#define GL_RGB8_SNORM 0x8F96 -#define GL_RGBA8_SNORM 0x8F97 -#define GL_R16_SNORM 0x8F98 -#define GL_RG16_SNORM 0x8F99 -#define GL_RGB16_SNORM 0x8F9A -#define GL_RGBA16_SNORM 0x8F9B -#define GL_SIGNED_NORMALIZED 0x8F9C -#define GL_PRIMITIVE_RESTART 0x8F9D -#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E -/* Reuse tokens from ARB_copy_buffer */ -/* reuse GL_COPY_READ_BUFFER */ -/* reuse GL_COPY_WRITE_BUFFER */ -/* Would reuse tokens from ARB_draw_instanced, but it has none */ -/* Reuse tokens from ARB_uniform_buffer_object */ -/* reuse GL_UNIFORM_BUFFER */ -/* reuse GL_UNIFORM_BUFFER_BINDING */ -/* reuse GL_UNIFORM_BUFFER_START */ -/* reuse GL_UNIFORM_BUFFER_SIZE */ -/* reuse GL_MAX_VERTEX_UNIFORM_BLOCKS */ -/* reuse GL_MAX_FRAGMENT_UNIFORM_BLOCKS */ -/* reuse GL_MAX_COMBINED_UNIFORM_BLOCKS */ -/* reuse GL_MAX_UNIFORM_BUFFER_BINDINGS */ -/* reuse GL_MAX_UNIFORM_BLOCK_SIZE */ -/* reuse GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS */ -/* reuse GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS */ -/* reuse GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT */ -/* reuse GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH */ -/* reuse GL_ACTIVE_UNIFORM_BLOCKS */ -/* reuse GL_UNIFORM_TYPE */ -/* reuse GL_UNIFORM_SIZE */ -/* reuse GL_UNIFORM_NAME_LENGTH */ -/* reuse GL_UNIFORM_BLOCK_INDEX */ -/* reuse GL_UNIFORM_OFFSET */ -/* reuse GL_UNIFORM_ARRAY_STRIDE */ -/* reuse GL_UNIFORM_MATRIX_STRIDE */ -/* reuse GL_UNIFORM_IS_ROW_MAJOR */ -/* reuse GL_UNIFORM_BLOCK_BINDING */ -/* reuse GL_UNIFORM_BLOCK_DATA_SIZE */ -/* reuse GL_UNIFORM_BLOCK_NAME_LENGTH */ -/* reuse GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS */ -/* reuse GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES */ -/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER */ -/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER */ -/* reuse GL_INVALID_INDEX */ -#endif - -#ifndef GL_VERSION_3_2 -#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 -#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 -#define GL_LINES_ADJACENCY 0x000A -#define GL_LINE_STRIP_ADJACENCY 0x000B -#define GL_TRIANGLES_ADJACENCY 0x000C -#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D -#define GL_PROGRAM_POINT_SIZE 0x8642 -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 -#define GL_GEOMETRY_SHADER 0x8DD9 -#define GL_GEOMETRY_VERTICES_OUT 0x8916 -#define GL_GEOMETRY_INPUT_TYPE 0x8917 -#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 -#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 -#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 -#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 -#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 -#define GL_CONTEXT_PROFILE_MASK 0x9126 -/* reuse GL_MAX_VARYING_COMPONENTS */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ -/* Reuse tokens from ARB_depth_clamp */ -/* reuse GL_DEPTH_CLAMP */ -/* Would reuse tokens from ARB_draw_elements_base_vertex, but it has none */ -/* Would reuse tokens from ARB_fragment_coord_conventions, but it has none */ -/* Reuse tokens from ARB_provoking_vertex */ -/* reuse GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION */ -/* reuse GL_FIRST_VERTEX_CONVENTION */ -/* reuse GL_LAST_VERTEX_CONVENTION */ -/* reuse GL_PROVOKING_VERTEX */ -/* Reuse tokens from ARB_seamless_cube_map */ -/* reuse GL_TEXTURE_CUBE_MAP_SEAMLESS */ -/* Reuse tokens from ARB_sync */ -/* reuse GL_MAX_SERVER_WAIT_TIMEOUT */ -/* reuse GL_OBJECT_TYPE */ -/* reuse GL_SYNC_CONDITION */ -/* reuse GL_SYNC_STATUS */ -/* reuse GL_SYNC_FLAGS */ -/* reuse GL_SYNC_FENCE */ -/* reuse GL_SYNC_GPU_COMMANDS_COMPLETE */ -/* reuse GL_UNSIGNALED */ -/* reuse GL_SIGNALED */ -/* reuse GL_ALREADY_SIGNALED */ -/* reuse GL_TIMEOUT_EXPIRED */ -/* reuse GL_CONDITION_SATISFIED */ -/* reuse GL_WAIT_FAILED */ -/* reuse GL_TIMEOUT_IGNORED */ -/* reuse GL_SYNC_FLUSH_COMMANDS_BIT */ -/* reuse GL_TIMEOUT_IGNORED */ -/* Reuse tokens from ARB_texture_multisample */ -/* reuse GL_SAMPLE_POSITION */ -/* reuse GL_SAMPLE_MASK */ -/* reuse GL_SAMPLE_MASK_VALUE */ -/* reuse GL_MAX_SAMPLE_MASK_WORDS */ -/* reuse GL_TEXTURE_2D_MULTISAMPLE */ -/* reuse GL_PROXY_TEXTURE_2D_MULTISAMPLE */ -/* reuse GL_TEXTURE_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_TEXTURE_BINDING_2D_MULTISAMPLE */ -/* reuse GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_TEXTURE_SAMPLES */ -/* reuse GL_TEXTURE_FIXED_SAMPLE_LOCATIONS */ -/* reuse GL_SAMPLER_2D_MULTISAMPLE */ -/* reuse GL_INT_SAMPLER_2D_MULTISAMPLE */ -/* reuse GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE */ -/* reuse GL_SAMPLER_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_MAX_COLOR_TEXTURE_SAMPLES */ -/* reuse GL_MAX_DEPTH_TEXTURE_SAMPLES */ -/* reuse GL_MAX_INTEGER_SAMPLES */ -/* Don't need to reuse tokens from ARB_vertex_array_bgra since they're already in 1.2 core */ -#endif - -#ifndef GL_ARB_multitexture -#define GL_TEXTURE0_ARB 0x84C0 -#define GL_TEXTURE1_ARB 0x84C1 -#define GL_TEXTURE2_ARB 0x84C2 -#define GL_TEXTURE3_ARB 0x84C3 -#define GL_TEXTURE4_ARB 0x84C4 -#define GL_TEXTURE5_ARB 0x84C5 -#define GL_TEXTURE6_ARB 0x84C6 -#define GL_TEXTURE7_ARB 0x84C7 -#define GL_TEXTURE8_ARB 0x84C8 -#define GL_TEXTURE9_ARB 0x84C9 -#define GL_TEXTURE10_ARB 0x84CA -#define GL_TEXTURE11_ARB 0x84CB -#define GL_TEXTURE12_ARB 0x84CC -#define GL_TEXTURE13_ARB 0x84CD -#define GL_TEXTURE14_ARB 0x84CE -#define GL_TEXTURE15_ARB 0x84CF -#define GL_TEXTURE16_ARB 0x84D0 -#define GL_TEXTURE17_ARB 0x84D1 -#define GL_TEXTURE18_ARB 0x84D2 -#define GL_TEXTURE19_ARB 0x84D3 -#define GL_TEXTURE20_ARB 0x84D4 -#define GL_TEXTURE21_ARB 0x84D5 -#define GL_TEXTURE22_ARB 0x84D6 -#define GL_TEXTURE23_ARB 0x84D7 -#define GL_TEXTURE24_ARB 0x84D8 -#define GL_TEXTURE25_ARB 0x84D9 -#define GL_TEXTURE26_ARB 0x84DA -#define GL_TEXTURE27_ARB 0x84DB -#define GL_TEXTURE28_ARB 0x84DC -#define GL_TEXTURE29_ARB 0x84DD -#define GL_TEXTURE30_ARB 0x84DE -#define GL_TEXTURE31_ARB 0x84DF -#define GL_ACTIVE_TEXTURE_ARB 0x84E0 -#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 -#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 -#endif - -#ifndef GL_ARB_transpose_matrix -#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 -#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 -#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 -#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 -#endif - -#ifndef GL_ARB_multisample -#define GL_MULTISAMPLE_ARB 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F -#define GL_SAMPLE_COVERAGE_ARB 0x80A0 -#define GL_SAMPLE_BUFFERS_ARB 0x80A8 -#define GL_SAMPLES_ARB 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB -#define GL_MULTISAMPLE_BIT_ARB 0x20000000 -#endif - -#ifndef GL_ARB_texture_env_add -#endif - -#ifndef GL_ARB_texture_cube_map -#define GL_NORMAL_MAP_ARB 0x8511 -#define GL_REFLECTION_MAP_ARB 0x8512 -#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C -#endif - -#ifndef GL_ARB_texture_compression -#define GL_COMPRESSED_ALPHA_ARB 0x84E9 -#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA -#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB -#define GL_COMPRESSED_INTENSITY_ARB 0x84EC -#define GL_COMPRESSED_RGB_ARB 0x84ED -#define GL_COMPRESSED_RGBA_ARB 0x84EE -#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF -#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 -#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 -#endif - -#ifndef GL_ARB_texture_border_clamp -#define GL_CLAMP_TO_BORDER_ARB 0x812D -#endif - -#ifndef GL_ARB_point_parameters -#define GL_POINT_SIZE_MIN_ARB 0x8126 -#define GL_POINT_SIZE_MAX_ARB 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 -#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 -#endif - -#ifndef GL_ARB_vertex_blend -#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 -#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 -#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 -#define GL_VERTEX_BLEND_ARB 0x86A7 -#define GL_CURRENT_WEIGHT_ARB 0x86A8 -#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 -#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA -#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB -#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC -#define GL_WEIGHT_ARRAY_ARB 0x86AD -#define GL_MODELVIEW0_ARB 0x1700 -#define GL_MODELVIEW1_ARB 0x850A -#define GL_MODELVIEW2_ARB 0x8722 -#define GL_MODELVIEW3_ARB 0x8723 -#define GL_MODELVIEW4_ARB 0x8724 -#define GL_MODELVIEW5_ARB 0x8725 -#define GL_MODELVIEW6_ARB 0x8726 -#define GL_MODELVIEW7_ARB 0x8727 -#define GL_MODELVIEW8_ARB 0x8728 -#define GL_MODELVIEW9_ARB 0x8729 -#define GL_MODELVIEW10_ARB 0x872A -#define GL_MODELVIEW11_ARB 0x872B -#define GL_MODELVIEW12_ARB 0x872C -#define GL_MODELVIEW13_ARB 0x872D -#define GL_MODELVIEW14_ARB 0x872E -#define GL_MODELVIEW15_ARB 0x872F -#define GL_MODELVIEW16_ARB 0x8730 -#define GL_MODELVIEW17_ARB 0x8731 -#define GL_MODELVIEW18_ARB 0x8732 -#define GL_MODELVIEW19_ARB 0x8733 -#define GL_MODELVIEW20_ARB 0x8734 -#define GL_MODELVIEW21_ARB 0x8735 -#define GL_MODELVIEW22_ARB 0x8736 -#define GL_MODELVIEW23_ARB 0x8737 -#define GL_MODELVIEW24_ARB 0x8738 -#define GL_MODELVIEW25_ARB 0x8739 -#define GL_MODELVIEW26_ARB 0x873A -#define GL_MODELVIEW27_ARB 0x873B -#define GL_MODELVIEW28_ARB 0x873C -#define GL_MODELVIEW29_ARB 0x873D -#define GL_MODELVIEW30_ARB 0x873E -#define GL_MODELVIEW31_ARB 0x873F -#endif - -#ifndef GL_ARB_matrix_palette -#define GL_MATRIX_PALETTE_ARB 0x8840 -#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 -#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 -#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 -#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 -#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 -#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 -#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 -#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 -#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 -#endif - -#ifndef GL_ARB_texture_env_combine -#define GL_COMBINE_ARB 0x8570 -#define GL_COMBINE_RGB_ARB 0x8571 -#define GL_COMBINE_ALPHA_ARB 0x8572 -#define GL_SOURCE0_RGB_ARB 0x8580 -#define GL_SOURCE1_RGB_ARB 0x8581 -#define GL_SOURCE2_RGB_ARB 0x8582 -#define GL_SOURCE0_ALPHA_ARB 0x8588 -#define GL_SOURCE1_ALPHA_ARB 0x8589 -#define GL_SOURCE2_ALPHA_ARB 0x858A -#define GL_OPERAND0_RGB_ARB 0x8590 -#define GL_OPERAND1_RGB_ARB 0x8591 -#define GL_OPERAND2_RGB_ARB 0x8592 -#define GL_OPERAND0_ALPHA_ARB 0x8598 -#define GL_OPERAND1_ALPHA_ARB 0x8599 -#define GL_OPERAND2_ALPHA_ARB 0x859A -#define GL_RGB_SCALE_ARB 0x8573 -#define GL_ADD_SIGNED_ARB 0x8574 -#define GL_INTERPOLATE_ARB 0x8575 -#define GL_SUBTRACT_ARB 0x84E7 -#define GL_CONSTANT_ARB 0x8576 -#define GL_PRIMARY_COLOR_ARB 0x8577 -#define GL_PREVIOUS_ARB 0x8578 -#endif - -#ifndef GL_ARB_texture_env_crossbar -#endif - -#ifndef GL_ARB_texture_env_dot3 -#define GL_DOT3_RGB_ARB 0x86AE -#define GL_DOT3_RGBA_ARB 0x86AF -#endif - -#ifndef GL_ARB_texture_mirrored_repeat -#define GL_MIRRORED_REPEAT_ARB 0x8370 -#endif - -#ifndef GL_ARB_depth_texture -#define GL_DEPTH_COMPONENT16_ARB 0x81A5 -#define GL_DEPTH_COMPONENT24_ARB 0x81A6 -#define GL_DEPTH_COMPONENT32_ARB 0x81A7 -#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A -#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B -#endif - -#ifndef GL_ARB_shadow -#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C -#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D -#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E -#endif - -#ifndef GL_ARB_shadow_ambient -#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF -#endif - -#ifndef GL_ARB_window_pos -#endif - -#ifndef GL_ARB_vertex_program -#define GL_COLOR_SUM_ARB 0x8458 -#define GL_VERTEX_PROGRAM_ARB 0x8620 -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 -#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 -#define GL_PROGRAM_LENGTH_ARB 0x8627 -#define GL_PROGRAM_STRING_ARB 0x8628 -#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E -#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F -#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 -#define GL_CURRENT_MATRIX_ARB 0x8641 -#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 -#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B -#define GL_PROGRAM_BINDING_ARB 0x8677 -#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A -#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 -#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 -#define GL_PROGRAM_FORMAT_ARB 0x8876 -#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 -#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 -#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 -#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 -#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 -#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 -#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 -#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 -#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 -#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 -#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA -#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB -#define GL_PROGRAM_ATTRIBS_ARB 0x88AC -#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD -#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE -#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF -#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 -#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 -#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 -#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 -#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 -#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 -#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 -#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 -#define GL_MATRIX0_ARB 0x88C0 -#define GL_MATRIX1_ARB 0x88C1 -#define GL_MATRIX2_ARB 0x88C2 -#define GL_MATRIX3_ARB 0x88C3 -#define GL_MATRIX4_ARB 0x88C4 -#define GL_MATRIX5_ARB 0x88C5 -#define GL_MATRIX6_ARB 0x88C6 -#define GL_MATRIX7_ARB 0x88C7 -#define GL_MATRIX8_ARB 0x88C8 -#define GL_MATRIX9_ARB 0x88C9 -#define GL_MATRIX10_ARB 0x88CA -#define GL_MATRIX11_ARB 0x88CB -#define GL_MATRIX12_ARB 0x88CC -#define GL_MATRIX13_ARB 0x88CD -#define GL_MATRIX14_ARB 0x88CE -#define GL_MATRIX15_ARB 0x88CF -#define GL_MATRIX16_ARB 0x88D0 -#define GL_MATRIX17_ARB 0x88D1 -#define GL_MATRIX18_ARB 0x88D2 -#define GL_MATRIX19_ARB 0x88D3 -#define GL_MATRIX20_ARB 0x88D4 -#define GL_MATRIX21_ARB 0x88D5 -#define GL_MATRIX22_ARB 0x88D6 -#define GL_MATRIX23_ARB 0x88D7 -#define GL_MATRIX24_ARB 0x88D8 -#define GL_MATRIX25_ARB 0x88D9 -#define GL_MATRIX26_ARB 0x88DA -#define GL_MATRIX27_ARB 0x88DB -#define GL_MATRIX28_ARB 0x88DC -#define GL_MATRIX29_ARB 0x88DD -#define GL_MATRIX30_ARB 0x88DE -#define GL_MATRIX31_ARB 0x88DF -#endif - -#ifndef GL_ARB_fragment_program -#define GL_FRAGMENT_PROGRAM_ARB 0x8804 -#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 -#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 -#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 -#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 -#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 -#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A -#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B -#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C -#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D -#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E -#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F -#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 -#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 -#endif - -#ifndef GL_ARB_vertex_buffer_object -#define GL_BUFFER_SIZE_ARB 0x8764 -#define GL_BUFFER_USAGE_ARB 0x8765 -#define GL_ARRAY_BUFFER_ARB 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 -#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 -#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 -#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A -#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B -#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C -#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D -#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F -#define GL_READ_ONLY_ARB 0x88B8 -#define GL_WRITE_ONLY_ARB 0x88B9 -#define GL_READ_WRITE_ARB 0x88BA -#define GL_BUFFER_ACCESS_ARB 0x88BB -#define GL_BUFFER_MAPPED_ARB 0x88BC -#define GL_BUFFER_MAP_POINTER_ARB 0x88BD -#define GL_STREAM_DRAW_ARB 0x88E0 -#define GL_STREAM_READ_ARB 0x88E1 -#define GL_STREAM_COPY_ARB 0x88E2 -#define GL_STATIC_DRAW_ARB 0x88E4 -#define GL_STATIC_READ_ARB 0x88E5 -#define GL_STATIC_COPY_ARB 0x88E6 -#define GL_DYNAMIC_DRAW_ARB 0x88E8 -#define GL_DYNAMIC_READ_ARB 0x88E9 -#define GL_DYNAMIC_COPY_ARB 0x88EA -#endif - -#ifndef GL_ARB_occlusion_query -#define GL_QUERY_COUNTER_BITS_ARB 0x8864 -#define GL_CURRENT_QUERY_ARB 0x8865 -#define GL_QUERY_RESULT_ARB 0x8866 -#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 -#define GL_SAMPLES_PASSED_ARB 0x8914 -#endif - -#ifndef GL_ARB_shader_objects -#define GL_PROGRAM_OBJECT_ARB 0x8B40 -#define GL_SHADER_OBJECT_ARB 0x8B48 -#define GL_OBJECT_TYPE_ARB 0x8B4E -#define GL_OBJECT_SUBTYPE_ARB 0x8B4F -#define GL_FLOAT_VEC2_ARB 0x8B50 -#define GL_FLOAT_VEC3_ARB 0x8B51 -#define GL_FLOAT_VEC4_ARB 0x8B52 -#define GL_INT_VEC2_ARB 0x8B53 -#define GL_INT_VEC3_ARB 0x8B54 -#define GL_INT_VEC4_ARB 0x8B55 -#define GL_BOOL_ARB 0x8B56 -#define GL_BOOL_VEC2_ARB 0x8B57 -#define GL_BOOL_VEC3_ARB 0x8B58 -#define GL_BOOL_VEC4_ARB 0x8B59 -#define GL_FLOAT_MAT2_ARB 0x8B5A -#define GL_FLOAT_MAT3_ARB 0x8B5B -#define GL_FLOAT_MAT4_ARB 0x8B5C -#define GL_SAMPLER_1D_ARB 0x8B5D -#define GL_SAMPLER_2D_ARB 0x8B5E -#define GL_SAMPLER_3D_ARB 0x8B5F -#define GL_SAMPLER_CUBE_ARB 0x8B60 -#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 -#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 -#define GL_SAMPLER_2D_RECT_ARB 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 -#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 -#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 -#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 -#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 -#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 -#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 -#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 -#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 -#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 -#endif - -#ifndef GL_ARB_vertex_shader -#define GL_VERTEX_SHADER_ARB 0x8B31 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A -#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D -#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 -#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A -#endif - -#ifndef GL_ARB_fragment_shader -#define GL_FRAGMENT_SHADER_ARB 0x8B30 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B -#endif - -#ifndef GL_ARB_shading_language_100 -#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C -#endif - -#ifndef GL_ARB_texture_non_power_of_two -#endif - -#ifndef GL_ARB_point_sprite -#define GL_POINT_SPRITE_ARB 0x8861 -#define GL_COORD_REPLACE_ARB 0x8862 -#endif - -#ifndef GL_ARB_fragment_program_shadow -#endif - -#ifndef GL_ARB_draw_buffers -#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 -#define GL_DRAW_BUFFER0_ARB 0x8825 -#define GL_DRAW_BUFFER1_ARB 0x8826 -#define GL_DRAW_BUFFER2_ARB 0x8827 -#define GL_DRAW_BUFFER3_ARB 0x8828 -#define GL_DRAW_BUFFER4_ARB 0x8829 -#define GL_DRAW_BUFFER5_ARB 0x882A -#define GL_DRAW_BUFFER6_ARB 0x882B -#define GL_DRAW_BUFFER7_ARB 0x882C -#define GL_DRAW_BUFFER8_ARB 0x882D -#define GL_DRAW_BUFFER9_ARB 0x882E -#define GL_DRAW_BUFFER10_ARB 0x882F -#define GL_DRAW_BUFFER11_ARB 0x8830 -#define GL_DRAW_BUFFER12_ARB 0x8831 -#define GL_DRAW_BUFFER13_ARB 0x8832 -#define GL_DRAW_BUFFER14_ARB 0x8833 -#define GL_DRAW_BUFFER15_ARB 0x8834 -#endif - -#ifndef GL_ARB_texture_rectangle -#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 -#endif - -#ifndef GL_ARB_color_buffer_float -#define GL_RGBA_FLOAT_MODE_ARB 0x8820 -#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A -#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B -#define GL_CLAMP_READ_COLOR_ARB 0x891C -#define GL_FIXED_ONLY_ARB 0x891D -#endif - -#ifndef GL_ARB_half_float_pixel -#define GL_HALF_FLOAT_ARB 0x140B -#endif - -#ifndef GL_ARB_texture_float -#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 -#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 -#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 -#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 -#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 -#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 -#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 -#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 -#define GL_RGBA32F_ARB 0x8814 -#define GL_RGB32F_ARB 0x8815 -#define GL_ALPHA32F_ARB 0x8816 -#define GL_INTENSITY32F_ARB 0x8817 -#define GL_LUMINANCE32F_ARB 0x8818 -#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 -#define GL_RGBA16F_ARB 0x881A -#define GL_RGB16F_ARB 0x881B -#define GL_ALPHA16F_ARB 0x881C -#define GL_INTENSITY16F_ARB 0x881D -#define GL_LUMINANCE16F_ARB 0x881E -#define GL_LUMINANCE_ALPHA16F_ARB 0x881F -#endif - -#ifndef GL_ARB_pixel_buffer_object -#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF -#endif - -#ifndef GL_ARB_depth_buffer_float -#define GL_DEPTH_COMPONENT32F 0x8CAC -#define GL_DEPTH32F_STENCIL8 0x8CAD -#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD -#endif - -#ifndef GL_ARB_draw_instanced -#endif - -#ifndef GL_ARB_framebuffer_object -#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 -#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 -#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 -#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 -#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 -#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 -#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 -#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 -#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 -#define GL_FRAMEBUFFER_DEFAULT 0x8218 -#define GL_FRAMEBUFFER_UNDEFINED 0x8219 -#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A -#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 -#define GL_DEPTH_STENCIL 0x84F9 -#define GL_UNSIGNED_INT_24_8 0x84FA -#define GL_DEPTH24_STENCIL8 0x88F0 -#define GL_TEXTURE_STENCIL_SIZE 0x88F1 -#define GL_TEXTURE_RED_TYPE 0x8C10 -#define GL_TEXTURE_GREEN_TYPE 0x8C11 -#define GL_TEXTURE_BLUE_TYPE 0x8C12 -#define GL_TEXTURE_ALPHA_TYPE 0x8C13 -#define GL_TEXTURE_DEPTH_TYPE 0x8C16 -#define GL_UNSIGNED_NORMALIZED 0x8C17 -#define GL_FRAMEBUFFER_BINDING 0x8CA6 -#define GL_DRAW_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING -#define GL_RENDERBUFFER_BINDING 0x8CA7 -#define GL_READ_FRAMEBUFFER 0x8CA8 -#define GL_DRAW_FRAMEBUFFER 0x8CA9 -#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA -#define GL_RENDERBUFFER_SAMPLES 0x8CAB -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 -#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB -#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC -#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD -#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF -#define GL_COLOR_ATTACHMENT0 0x8CE0 -#define GL_COLOR_ATTACHMENT1 0x8CE1 -#define GL_COLOR_ATTACHMENT2 0x8CE2 -#define GL_COLOR_ATTACHMENT3 0x8CE3 -#define GL_COLOR_ATTACHMENT4 0x8CE4 -#define GL_COLOR_ATTACHMENT5 0x8CE5 -#define GL_COLOR_ATTACHMENT6 0x8CE6 -#define GL_COLOR_ATTACHMENT7 0x8CE7 -#define GL_COLOR_ATTACHMENT8 0x8CE8 -#define GL_COLOR_ATTACHMENT9 0x8CE9 -#define GL_COLOR_ATTACHMENT10 0x8CEA -#define GL_COLOR_ATTACHMENT11 0x8CEB -#define GL_COLOR_ATTACHMENT12 0x8CEC -#define GL_COLOR_ATTACHMENT13 0x8CED -#define GL_COLOR_ATTACHMENT14 0x8CEE -#define GL_COLOR_ATTACHMENT15 0x8CEF -#define GL_DEPTH_ATTACHMENT 0x8D00 -#define GL_STENCIL_ATTACHMENT 0x8D20 -#define GL_FRAMEBUFFER 0x8D40 -#define GL_RENDERBUFFER 0x8D41 -#define GL_RENDERBUFFER_WIDTH 0x8D42 -#define GL_RENDERBUFFER_HEIGHT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 -#define GL_STENCIL_INDEX1 0x8D46 -#define GL_STENCIL_INDEX4 0x8D47 -#define GL_STENCIL_INDEX8 0x8D48 -#define GL_STENCIL_INDEX16 0x8D49 -#define GL_RENDERBUFFER_RED_SIZE 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 -#define GL_MAX_SAMPLES 0x8D57 -#endif - -#ifndef GL_ARB_framebuffer_object_DEPRECATED -#define GL_INDEX 0x8222 -#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 -#define GL_TEXTURE_INTENSITY_TYPE 0x8C15 -#endif - -#ifndef GL_ARB_framebuffer_sRGB -#define GL_FRAMEBUFFER_SRGB 0x8DB9 -#endif - -#ifndef GL_ARB_geometry_shader4 -#define GL_LINES_ADJACENCY_ARB 0x000A -#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B -#define GL_TRIANGLES_ADJACENCY_ARB 0x000C -#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D -#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 -#define GL_GEOMETRY_SHADER_ARB 0x8DD9 -#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA -#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB -#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC -#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD -#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 -/* reuse GL_MAX_VARYING_COMPONENTS */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ -#endif - -#ifndef GL_ARB_half_float_vertex -#define GL_HALF_FLOAT 0x140B -#endif - -#ifndef GL_ARB_instanced_arrays -#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE -#endif - -#ifndef GL_ARB_map_buffer_range -#define GL_MAP_READ_BIT 0x0001 -#define GL_MAP_WRITE_BIT 0x0002 -#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 -#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 -#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 -#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 -#endif - -#ifndef GL_ARB_texture_buffer_object -#define GL_TEXTURE_BUFFER_ARB 0x8C2A -#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B -#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C -#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D -#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E -#endif - -#ifndef GL_ARB_texture_compression_rgtc -#define GL_COMPRESSED_RED_RGTC1 0x8DBB -#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC -#define GL_COMPRESSED_RG_RGTC2 0x8DBD -#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE -#endif - -#ifndef GL_ARB_texture_rg -#define GL_RG 0x8227 -#define GL_RG_INTEGER 0x8228 -#define GL_R8 0x8229 -#define GL_R16 0x822A -#define GL_RG8 0x822B -#define GL_RG16 0x822C -#define GL_R16F 0x822D -#define GL_R32F 0x822E -#define GL_RG16F 0x822F -#define GL_RG32F 0x8230 -#define GL_R8I 0x8231 -#define GL_R8UI 0x8232 -#define GL_R16I 0x8233 -#define GL_R16UI 0x8234 -#define GL_R32I 0x8235 -#define GL_R32UI 0x8236 -#define GL_RG8I 0x8237 -#define GL_RG8UI 0x8238 -#define GL_RG16I 0x8239 -#define GL_RG16UI 0x823A -#define GL_RG32I 0x823B -#define GL_RG32UI 0x823C -#endif - -#ifndef GL_ARB_vertex_array_object -#define GL_VERTEX_ARRAY_BINDING 0x85B5 -#endif - -#ifndef GL_ARB_uniform_buffer_object -#define GL_UNIFORM_BUFFER 0x8A11 -#define GL_UNIFORM_BUFFER_BINDING 0x8A28 -#define GL_UNIFORM_BUFFER_START 0x8A29 -#define GL_UNIFORM_BUFFER_SIZE 0x8A2A -#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B -#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C -#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D -#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E -#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F -#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 -#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 -#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 -#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 -#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 -#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 -#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 -#define GL_UNIFORM_TYPE 0x8A37 -#define GL_UNIFORM_SIZE 0x8A38 -#define GL_UNIFORM_NAME_LENGTH 0x8A39 -#define GL_UNIFORM_BLOCK_INDEX 0x8A3A -#define GL_UNIFORM_OFFSET 0x8A3B -#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C -#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D -#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E -#define GL_UNIFORM_BLOCK_BINDING 0x8A3F -#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 -#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 -#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 -#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 -#define GL_INVALID_INDEX 0xFFFFFFFFu -#endif - -#ifndef GL_ARB_compatibility -/* ARB_compatibility just defines tokens from core 3.0 */ -#endif - -#ifndef GL_ARB_copy_buffer -#define GL_COPY_READ_BUFFER 0x8F36 -#define GL_COPY_WRITE_BUFFER 0x8F37 -#endif - -#ifndef GL_ARB_shader_texture_lod -#endif - -#ifndef GL_ARB_depth_clamp -#define GL_DEPTH_CLAMP 0x864F -#endif - -#ifndef GL_ARB_draw_elements_base_vertex -#endif - -#ifndef GL_ARB_fragment_coord_conventions -#endif - -#ifndef GL_ARB_provoking_vertex -#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C -#define GL_FIRST_VERTEX_CONVENTION 0x8E4D -#define GL_LAST_VERTEX_CONVENTION 0x8E4E -#define GL_PROVOKING_VERTEX 0x8E4F -#endif - -#ifndef GL_ARB_seamless_cube_map -#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F -#endif - -#ifndef GL_ARB_sync -#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 -#define GL_OBJECT_TYPE 0x9112 -#define GL_SYNC_CONDITION 0x9113 -#define GL_SYNC_STATUS 0x9114 -#define GL_SYNC_FLAGS 0x9115 -#define GL_SYNC_FENCE 0x9116 -#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 -#define GL_UNSIGNALED 0x9118 -#define GL_SIGNALED 0x9119 -#define GL_ALREADY_SIGNALED 0x911A -#define GL_TIMEOUT_EXPIRED 0x911B -#define GL_CONDITION_SATISFIED 0x911C -#define GL_WAIT_FAILED 0x911D -#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 -#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull -#endif - -#ifndef GL_ARB_texture_multisample -#define GL_SAMPLE_POSITION 0x8E50 -#define GL_SAMPLE_MASK 0x8E51 -#define GL_SAMPLE_MASK_VALUE 0x8E52 -#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 -#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 -#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 -#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 -#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 -#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 -#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 -#define GL_TEXTURE_SAMPLES 0x9106 -#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 -#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 -#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 -#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A -#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B -#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C -#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D -#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E -#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F -#define GL_MAX_INTEGER_SAMPLES 0x9110 -#endif - -#ifndef GL_ARB_vertex_array_bgra -/* reuse GL_BGRA */ -#endif - -#ifndef GL_ARB_draw_buffers_blend -#endif - -#ifndef GL_ARB_sample_shading -#define GL_SAMPLE_SHADING 0x8C36 -#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37 -#endif - -#ifndef GL_ARB_texture_cube_map_array -#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A -#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B -#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C -#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D -#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E -#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F -#endif - -#ifndef GL_ARB_texture_gather -#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E -#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F -#define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS 0x8F9F -#endif - -#ifndef GL_ARB_texture_query_lod -#endif - -#ifndef GL_EXT_abgr -#define GL_ABGR_EXT 0x8000 -#endif - -#ifndef GL_EXT_blend_color -#define GL_CONSTANT_COLOR_EXT 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 -#define GL_CONSTANT_ALPHA_EXT 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 -#define GL_BLEND_COLOR_EXT 0x8005 -#endif - -#ifndef GL_EXT_polygon_offset -#define GL_POLYGON_OFFSET_EXT 0x8037 -#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 -#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 -#endif - -#ifndef GL_EXT_texture -#define GL_ALPHA4_EXT 0x803B -#define GL_ALPHA8_EXT 0x803C -#define GL_ALPHA12_EXT 0x803D -#define GL_ALPHA16_EXT 0x803E -#define GL_LUMINANCE4_EXT 0x803F -#define GL_LUMINANCE8_EXT 0x8040 -#define GL_LUMINANCE12_EXT 0x8041 -#define GL_LUMINANCE16_EXT 0x8042 -#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 -#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 -#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 -#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 -#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 -#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 -#define GL_INTENSITY_EXT 0x8049 -#define GL_INTENSITY4_EXT 0x804A -#define GL_INTENSITY8_EXT 0x804B -#define GL_INTENSITY12_EXT 0x804C -#define GL_INTENSITY16_EXT 0x804D -#define GL_RGB2_EXT 0x804E -#define GL_RGB4_EXT 0x804F -#define GL_RGB5_EXT 0x8050 -#define GL_RGB8_EXT 0x8051 -#define GL_RGB10_EXT 0x8052 -#define GL_RGB12_EXT 0x8053 -#define GL_RGB16_EXT 0x8054 -#define GL_RGBA2_EXT 0x8055 -#define GL_RGBA4_EXT 0x8056 -#define GL_RGB5_A1_EXT 0x8057 -#define GL_RGBA8_EXT 0x8058 -#define GL_RGB10_A2_EXT 0x8059 -#define GL_RGBA12_EXT 0x805A -#define GL_RGBA16_EXT 0x805B -#define GL_TEXTURE_RED_SIZE_EXT 0x805C -#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D -#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E -#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F -#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 -#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 -#define GL_REPLACE_EXT 0x8062 -#define GL_PROXY_TEXTURE_1D_EXT 0x8063 -#define GL_PROXY_TEXTURE_2D_EXT 0x8064 -#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 -#endif - -#ifndef GL_EXT_texture3D -#define GL_PACK_SKIP_IMAGES_EXT 0x806B -#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C -#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D -#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E -#define GL_TEXTURE_3D_EXT 0x806F -#define GL_PROXY_TEXTURE_3D_EXT 0x8070 -#define GL_TEXTURE_DEPTH_EXT 0x8071 -#define GL_TEXTURE_WRAP_R_EXT 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 -#endif - -#ifndef GL_SGIS_texture_filter4 -#define GL_FILTER4_SGIS 0x8146 -#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 -#endif - -#ifndef GL_EXT_subtexture -#endif - -#ifndef GL_EXT_copy_texture -#endif - -#ifndef GL_EXT_histogram -#define GL_HISTOGRAM_EXT 0x8024 -#define GL_PROXY_HISTOGRAM_EXT 0x8025 -#define GL_HISTOGRAM_WIDTH_EXT 0x8026 -#define GL_HISTOGRAM_FORMAT_EXT 0x8027 -#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 -#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 -#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A -#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B -#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C -#define GL_HISTOGRAM_SINK_EXT 0x802D -#define GL_MINMAX_EXT 0x802E -#define GL_MINMAX_FORMAT_EXT 0x802F -#define GL_MINMAX_SINK_EXT 0x8030 -#define GL_TABLE_TOO_LARGE_EXT 0x8031 -#endif - -#ifndef GL_EXT_convolution -#define GL_CONVOLUTION_1D_EXT 0x8010 -#define GL_CONVOLUTION_2D_EXT 0x8011 -#define GL_SEPARABLE_2D_EXT 0x8012 -#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 -#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 -#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 -#define GL_REDUCE_EXT 0x8016 -#define GL_CONVOLUTION_FORMAT_EXT 0x8017 -#define GL_CONVOLUTION_WIDTH_EXT 0x8018 -#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 -#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A -#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B -#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C -#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D -#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E -#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F -#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 -#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 -#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 -#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 -#endif - -#ifndef GL_SGI_color_matrix -#define GL_COLOR_MATRIX_SGI 0x80B1 -#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 -#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 -#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 -#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 -#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 -#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 -#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 -#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 -#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA -#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB -#endif - -#ifndef GL_SGI_color_table -#define GL_COLOR_TABLE_SGI 0x80D0 -#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 -#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 -#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 -#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 -#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 -#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 -#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 -#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 -#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF -#endif - -#ifndef GL_SGIS_pixel_texture -#define GL_PIXEL_TEXTURE_SGIS 0x8353 -#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 -#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 -#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 -#endif - -#ifndef GL_SGIX_pixel_texture -#define GL_PIXEL_TEX_GEN_SGIX 0x8139 -#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B -#endif - -#ifndef GL_SGIS_texture4D -#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 -#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 -#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 -#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 -#define GL_TEXTURE_4D_SGIS 0x8134 -#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 -#define GL_TEXTURE_4DSIZE_SGIS 0x8136 -#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 -#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 -#define GL_TEXTURE_4D_BINDING_SGIS 0x814F -#endif - -#ifndef GL_SGI_texture_color_table -#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC -#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD -#endif - -#ifndef GL_EXT_cmyka -#define GL_CMYK_EXT 0x800C -#define GL_CMYKA_EXT 0x800D -#define GL_PACK_CMYK_HINT_EXT 0x800E -#define GL_UNPACK_CMYK_HINT_EXT 0x800F -#endif - -#ifndef GL_EXT_texture_object -#define GL_TEXTURE_PRIORITY_EXT 0x8066 -#define GL_TEXTURE_RESIDENT_EXT 0x8067 -#define GL_TEXTURE_1D_BINDING_EXT 0x8068 -#define GL_TEXTURE_2D_BINDING_EXT 0x8069 -#define GL_TEXTURE_3D_BINDING_EXT 0x806A -#endif - -#ifndef GL_SGIS_detail_texture -#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 -#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 -#define GL_LINEAR_DETAIL_SGIS 0x8097 -#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 -#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 -#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A -#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B -#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C -#endif - -#ifndef GL_SGIS_sharpen_texture -#define GL_LINEAR_SHARPEN_SGIS 0x80AD -#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE -#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF -#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 -#endif - -#ifndef GL_EXT_packed_pixels -#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 -#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 -#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 -#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 -#endif - -#ifndef GL_SGIS_texture_lod -#define GL_TEXTURE_MIN_LOD_SGIS 0x813A -#define GL_TEXTURE_MAX_LOD_SGIS 0x813B -#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C -#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D -#endif - -#ifndef GL_SGIS_multisample -#define GL_MULTISAMPLE_SGIS 0x809D -#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F -#define GL_SAMPLE_MASK_SGIS 0x80A0 -#define GL_1PASS_SGIS 0x80A1 -#define GL_2PASS_0_SGIS 0x80A2 -#define GL_2PASS_1_SGIS 0x80A3 -#define GL_4PASS_0_SGIS 0x80A4 -#define GL_4PASS_1_SGIS 0x80A5 -#define GL_4PASS_2_SGIS 0x80A6 -#define GL_4PASS_3_SGIS 0x80A7 -#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 -#define GL_SAMPLES_SGIS 0x80A9 -#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA -#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB -#define GL_SAMPLE_PATTERN_SGIS 0x80AC -#endif - -#ifndef GL_EXT_rescale_normal -#define GL_RESCALE_NORMAL_EXT 0x803A -#endif - -#ifndef GL_EXT_vertex_array -#define GL_VERTEX_ARRAY_EXT 0x8074 -#define GL_NORMAL_ARRAY_EXT 0x8075 -#define GL_COLOR_ARRAY_EXT 0x8076 -#define GL_INDEX_ARRAY_EXT 0x8077 -#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 -#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 -#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A -#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B -#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C -#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D -#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E -#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F -#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 -#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 -#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 -#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 -#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 -#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 -#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 -#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 -#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 -#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 -#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A -#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B -#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C -#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D -#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E -#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F -#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 -#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 -#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 -#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 -#endif - -#ifndef GL_EXT_misc_attribute -#endif - -#ifndef GL_SGIS_generate_mipmap -#define GL_GENERATE_MIPMAP_SGIS 0x8191 -#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 -#endif - -#ifndef GL_SGIX_clipmap -#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 -#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 -#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 -#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 -#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 -#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 -#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 -#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 -#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 -#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D -#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E -#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F -#endif - -#ifndef GL_SGIX_shadow -#define GL_TEXTURE_COMPARE_SGIX 0x819A -#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B -#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C -#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D -#endif - -#ifndef GL_SGIS_texture_edge_clamp -#define GL_CLAMP_TO_EDGE_SGIS 0x812F -#endif - -#ifndef GL_SGIS_texture_border_clamp -#define GL_CLAMP_TO_BORDER_SGIS 0x812D -#endif - -#ifndef GL_EXT_blend_minmax -#define GL_FUNC_ADD_EXT 0x8006 -#define GL_MIN_EXT 0x8007 -#define GL_MAX_EXT 0x8008 -#define GL_BLEND_EQUATION_EXT 0x8009 -#endif - -#ifndef GL_EXT_blend_subtract -#define GL_FUNC_SUBTRACT_EXT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B -#endif - -#ifndef GL_EXT_blend_logic_op -#endif - -#ifndef GL_SGIX_interlace -#define GL_INTERLACE_SGIX 0x8094 -#endif - -#ifndef GL_SGIX_pixel_tiles -#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E -#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F -#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 -#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 -#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 -#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 -#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 -#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 -#endif - -#ifndef GL_SGIS_texture_select -#define GL_DUAL_ALPHA4_SGIS 0x8110 -#define GL_DUAL_ALPHA8_SGIS 0x8111 -#define GL_DUAL_ALPHA12_SGIS 0x8112 -#define GL_DUAL_ALPHA16_SGIS 0x8113 -#define GL_DUAL_LUMINANCE4_SGIS 0x8114 -#define GL_DUAL_LUMINANCE8_SGIS 0x8115 -#define GL_DUAL_LUMINANCE12_SGIS 0x8116 -#define GL_DUAL_LUMINANCE16_SGIS 0x8117 -#define GL_DUAL_INTENSITY4_SGIS 0x8118 -#define GL_DUAL_INTENSITY8_SGIS 0x8119 -#define GL_DUAL_INTENSITY12_SGIS 0x811A -#define GL_DUAL_INTENSITY16_SGIS 0x811B -#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C -#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D -#define GL_QUAD_ALPHA4_SGIS 0x811E -#define GL_QUAD_ALPHA8_SGIS 0x811F -#define GL_QUAD_LUMINANCE4_SGIS 0x8120 -#define GL_QUAD_LUMINANCE8_SGIS 0x8121 -#define GL_QUAD_INTENSITY4_SGIS 0x8122 -#define GL_QUAD_INTENSITY8_SGIS 0x8123 -#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 -#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 -#endif - -#ifndef GL_SGIX_sprite -#define GL_SPRITE_SGIX 0x8148 -#define GL_SPRITE_MODE_SGIX 0x8149 -#define GL_SPRITE_AXIS_SGIX 0x814A -#define GL_SPRITE_TRANSLATION_SGIX 0x814B -#define GL_SPRITE_AXIAL_SGIX 0x814C -#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D -#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E -#endif - -#ifndef GL_SGIX_texture_multi_buffer -#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E -#endif - -#ifndef GL_EXT_point_parameters -#define GL_POINT_SIZE_MIN_EXT 0x8126 -#define GL_POINT_SIZE_MAX_EXT 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 -#define GL_DISTANCE_ATTENUATION_EXT 0x8129 -#endif - -#ifndef GL_SGIS_point_parameters -#define GL_POINT_SIZE_MIN_SGIS 0x8126 -#define GL_POINT_SIZE_MAX_SGIS 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 -#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 -#endif - -#ifndef GL_SGIX_instruments -#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 -#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 -#endif - -#ifndef GL_SGIX_texture_scale_bias -#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 -#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A -#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B -#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C -#endif - -#ifndef GL_SGIX_framezoom -#define GL_FRAMEZOOM_SGIX 0x818B -#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C -#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D -#endif - -#ifndef GL_SGIX_tag_sample_buffer -#endif - -#ifndef GL_FfdMaskSGIX -#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 -#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 -#endif - -#ifndef GL_SGIX_polynomial_ffd -#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 -#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 -#define GL_DEFORMATIONS_MASK_SGIX 0x8196 -#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 -#endif - -#ifndef GL_SGIX_reference_plane -#define GL_REFERENCE_PLANE_SGIX 0x817D -#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E -#endif - -#ifndef GL_SGIX_flush_raster -#endif - -#ifndef GL_SGIX_depth_texture -#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 -#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 -#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 -#endif - -#ifndef GL_SGIS_fog_function -#define GL_FOG_FUNC_SGIS 0x812A -#define GL_FOG_FUNC_POINTS_SGIS 0x812B -#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C -#endif - -#ifndef GL_SGIX_fog_offset -#define GL_FOG_OFFSET_SGIX 0x8198 -#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 -#endif - -#ifndef GL_HP_image_transform -#define GL_IMAGE_SCALE_X_HP 0x8155 -#define GL_IMAGE_SCALE_Y_HP 0x8156 -#define GL_IMAGE_TRANSLATE_X_HP 0x8157 -#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 -#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 -#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A -#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B -#define GL_IMAGE_MAG_FILTER_HP 0x815C -#define GL_IMAGE_MIN_FILTER_HP 0x815D -#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E -#define GL_CUBIC_HP 0x815F -#define GL_AVERAGE_HP 0x8160 -#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 -#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 -#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 -#endif - -#ifndef GL_HP_convolution_border_modes -#define GL_IGNORE_BORDER_HP 0x8150 -#define GL_CONSTANT_BORDER_HP 0x8151 -#define GL_REPLICATE_BORDER_HP 0x8153 -#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 -#endif - -#ifndef GL_INGR_palette_buffer -#endif - -#ifndef GL_SGIX_texture_add_env -#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE -#endif - -#ifndef GL_EXT_color_subtable -#endif - -#ifndef GL_PGI_vertex_hints -#define GL_VERTEX_DATA_HINT_PGI 0x1A22A -#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B -#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C -#define GL_MAX_VERTEX_HINT_PGI 0x1A22D -#define GL_COLOR3_BIT_PGI 0x00010000 -#define GL_COLOR4_BIT_PGI 0x00020000 -#define GL_EDGEFLAG_BIT_PGI 0x00040000 -#define GL_INDEX_BIT_PGI 0x00080000 -#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 -#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 -#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 -#define GL_MAT_EMISSION_BIT_PGI 0x00800000 -#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 -#define GL_MAT_SHININESS_BIT_PGI 0x02000000 -#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 -#define GL_NORMAL_BIT_PGI 0x08000000 -#define GL_TEXCOORD1_BIT_PGI 0x10000000 -#define GL_TEXCOORD2_BIT_PGI 0x20000000 -#define GL_TEXCOORD3_BIT_PGI 0x40000000 -#define GL_TEXCOORD4_BIT_PGI 0x80000000 -#define GL_VERTEX23_BIT_PGI 0x00000004 -#define GL_VERTEX4_BIT_PGI 0x00000008 -#endif - -#ifndef GL_PGI_misc_hints -#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 -#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD -#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE -#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 -#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 -#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 -#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C -#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D -#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E -#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F -#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 -#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 -#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 -#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 -#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 -#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 -#define GL_CLIP_NEAR_HINT_PGI 0x1A220 -#define GL_CLIP_FAR_HINT_PGI 0x1A221 -#define GL_WIDE_LINE_HINT_PGI 0x1A222 -#define GL_BACK_NORMALS_HINT_PGI 0x1A223 -#endif - -#ifndef GL_EXT_paletted_texture -#define GL_COLOR_INDEX1_EXT 0x80E2 -#define GL_COLOR_INDEX2_EXT 0x80E3 -#define GL_COLOR_INDEX4_EXT 0x80E4 -#define GL_COLOR_INDEX8_EXT 0x80E5 -#define GL_COLOR_INDEX12_EXT 0x80E6 -#define GL_COLOR_INDEX16_EXT 0x80E7 -#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED -#endif - -#ifndef GL_EXT_clip_volume_hint -#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 -#endif - -#ifndef GL_SGIX_list_priority -#define GL_LIST_PRIORITY_SGIX 0x8182 -#endif - -#ifndef GL_SGIX_ir_instrument1 -#define GL_IR_INSTRUMENT1_SGIX 0x817F -#endif - -#ifndef GL_SGIX_calligraphic_fragment -#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 -#endif - -#ifndef GL_SGIX_texture_lod_bias -#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E -#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F -#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 -#endif - -#ifndef GL_SGIX_shadow_ambient -#define GL_SHADOW_AMBIENT_SGIX 0x80BF -#endif - -#ifndef GL_EXT_index_texture -#endif - -#ifndef GL_EXT_index_material -#define GL_INDEX_MATERIAL_EXT 0x81B8 -#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 -#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA -#endif - -#ifndef GL_EXT_index_func -#define GL_INDEX_TEST_EXT 0x81B5 -#define GL_INDEX_TEST_FUNC_EXT 0x81B6 -#define GL_INDEX_TEST_REF_EXT 0x81B7 -#endif - -#ifndef GL_EXT_index_array_formats -#define GL_IUI_V2F_EXT 0x81AD -#define GL_IUI_V3F_EXT 0x81AE -#define GL_IUI_N3F_V2F_EXT 0x81AF -#define GL_IUI_N3F_V3F_EXT 0x81B0 -#define GL_T2F_IUI_V2F_EXT 0x81B1 -#define GL_T2F_IUI_V3F_EXT 0x81B2 -#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 -#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 -#endif - -#ifndef GL_EXT_compiled_vertex_array -#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 -#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 -#endif - -#ifndef GL_EXT_cull_vertex -#define GL_CULL_VERTEX_EXT 0x81AA -#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB -#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC -#endif - -#ifndef GL_SGIX_ycrcb -#define GL_YCRCB_422_SGIX 0x81BB -#define GL_YCRCB_444_SGIX 0x81BC -#endif - -#ifndef GL_SGIX_fragment_lighting -#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 -#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 -#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 -#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 -#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 -#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 -#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 -#define GL_LIGHT_ENV_MODE_SGIX 0x8407 -#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 -#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 -#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A -#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B -#define GL_FRAGMENT_LIGHT0_SGIX 0x840C -#define GL_FRAGMENT_LIGHT1_SGIX 0x840D -#define GL_FRAGMENT_LIGHT2_SGIX 0x840E -#define GL_FRAGMENT_LIGHT3_SGIX 0x840F -#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 -#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 -#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 -#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 -#endif - -#ifndef GL_IBM_rasterpos_clip -#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 -#endif - -#ifndef GL_HP_texture_lighting -#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 -#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 -#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 -#endif - -#ifndef GL_EXT_draw_range_elements -#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 -#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 -#endif - -#ifndef GL_WIN_phong_shading -#define GL_PHONG_WIN 0x80EA -#define GL_PHONG_HINT_WIN 0x80EB -#endif - -#ifndef GL_WIN_specular_fog -#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC -#endif - -#ifndef GL_EXT_light_texture -#define GL_FRAGMENT_MATERIAL_EXT 0x8349 -#define GL_FRAGMENT_NORMAL_EXT 0x834A -#define GL_FRAGMENT_COLOR_EXT 0x834C -#define GL_ATTENUATION_EXT 0x834D -#define GL_SHADOW_ATTENUATION_EXT 0x834E -#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F -#define GL_TEXTURE_LIGHT_EXT 0x8350 -#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 -#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 -/* reuse GL_FRAGMENT_DEPTH_EXT */ -#endif - -#ifndef GL_SGIX_blend_alpha_minmax -#define GL_ALPHA_MIN_SGIX 0x8320 -#define GL_ALPHA_MAX_SGIX 0x8321 -#endif - -#ifndef GL_SGIX_impact_pixel_texture -#define GL_PIXEL_TEX_GEN_Q_CEILING_SGIX 0x8184 -#define GL_PIXEL_TEX_GEN_Q_ROUND_SGIX 0x8185 -#define GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX 0x8186 -#define GL_PIXEL_TEX_GEN_ALPHA_REPLACE_SGIX 0x8187 -#define GL_PIXEL_TEX_GEN_ALPHA_NO_REPLACE_SGIX 0x8188 -#define GL_PIXEL_TEX_GEN_ALPHA_LS_SGIX 0x8189 -#define GL_PIXEL_TEX_GEN_ALPHA_MS_SGIX 0x818A -#endif - -#ifndef GL_EXT_bgra -#define GL_BGR_EXT 0x80E0 -#define GL_BGRA_EXT 0x80E1 -#endif - -#ifndef GL_SGIX_async -#define GL_ASYNC_MARKER_SGIX 0x8329 -#endif - -#ifndef GL_SGIX_async_pixel -#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C -#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D -#define GL_ASYNC_READ_PIXELS_SGIX 0x835E -#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F -#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 -#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 -#endif - -#ifndef GL_SGIX_async_histogram -#define GL_ASYNC_HISTOGRAM_SGIX 0x832C -#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D -#endif - -#ifndef GL_INTEL_texture_scissor -#endif - -#ifndef GL_INTEL_parallel_arrays -#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 -#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 -#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 -#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 -#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 -#endif - -#ifndef GL_HP_occlusion_test -#define GL_OCCLUSION_TEST_HP 0x8165 -#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 -#endif - -#ifndef GL_EXT_pixel_transform -#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 -#define GL_PIXEL_MAG_FILTER_EXT 0x8331 -#define GL_PIXEL_MIN_FILTER_EXT 0x8332 -#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 -#define GL_CUBIC_EXT 0x8334 -#define GL_AVERAGE_EXT 0x8335 -#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 -#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 -#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 -#endif - -#ifndef GL_EXT_pixel_transform_color_table -#endif - -#ifndef GL_EXT_shared_texture_palette -#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB -#endif - -#ifndef GL_EXT_separate_specular_color -#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 -#define GL_SINGLE_COLOR_EXT 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA -#endif - -#ifndef GL_EXT_secondary_color -#define GL_COLOR_SUM_EXT 0x8458 -#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 -#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A -#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B -#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C -#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D -#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E -#endif - -#ifndef GL_EXT_texture_perturb_normal -#define GL_PERTURB_EXT 0x85AE -#define GL_TEXTURE_NORMAL_EXT 0x85AF -#endif - -#ifndef GL_EXT_multi_draw_arrays -#endif - -#ifndef GL_EXT_fog_coord -#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 -#define GL_FOG_COORDINATE_EXT 0x8451 -#define GL_FRAGMENT_DEPTH_EXT 0x8452 -#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 -#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 -#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 -#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 -#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 -#endif - -#ifndef GL_REND_screen_coordinates -#define GL_SCREEN_COORDINATES_REND 0x8490 -#define GL_INVERTED_SCREEN_W_REND 0x8491 -#endif - -#ifndef GL_EXT_coordinate_frame -#define GL_TANGENT_ARRAY_EXT 0x8439 -#define GL_BINORMAL_ARRAY_EXT 0x843A -#define GL_CURRENT_TANGENT_EXT 0x843B -#define GL_CURRENT_BINORMAL_EXT 0x843C -#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E -#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F -#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 -#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 -#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 -#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 -#define GL_MAP1_TANGENT_EXT 0x8444 -#define GL_MAP2_TANGENT_EXT 0x8445 -#define GL_MAP1_BINORMAL_EXT 0x8446 -#define GL_MAP2_BINORMAL_EXT 0x8447 -#endif - -#ifndef GL_EXT_texture_env_combine -#define GL_COMBINE_EXT 0x8570 -#define GL_COMBINE_RGB_EXT 0x8571 -#define GL_COMBINE_ALPHA_EXT 0x8572 -#define GL_RGB_SCALE_EXT 0x8573 -#define GL_ADD_SIGNED_EXT 0x8574 -#define GL_INTERPOLATE_EXT 0x8575 -#define GL_CONSTANT_EXT 0x8576 -#define GL_PRIMARY_COLOR_EXT 0x8577 -#define GL_PREVIOUS_EXT 0x8578 -#define GL_SOURCE0_RGB_EXT 0x8580 -#define GL_SOURCE1_RGB_EXT 0x8581 -#define GL_SOURCE2_RGB_EXT 0x8582 -#define GL_SOURCE0_ALPHA_EXT 0x8588 -#define GL_SOURCE1_ALPHA_EXT 0x8589 -#define GL_SOURCE2_ALPHA_EXT 0x858A -#define GL_OPERAND0_RGB_EXT 0x8590 -#define GL_OPERAND1_RGB_EXT 0x8591 -#define GL_OPERAND2_RGB_EXT 0x8592 -#define GL_OPERAND0_ALPHA_EXT 0x8598 -#define GL_OPERAND1_ALPHA_EXT 0x8599 -#define GL_OPERAND2_ALPHA_EXT 0x859A -#endif - -#ifndef GL_APPLE_specular_vector -#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 -#endif - -#ifndef GL_APPLE_transform_hint -#define GL_TRANSFORM_HINT_APPLE 0x85B1 -#endif - -#ifndef GL_SGIX_fog_scale -#define GL_FOG_SCALE_SGIX 0x81FC -#define GL_FOG_SCALE_VALUE_SGIX 0x81FD -#endif - -#ifndef GL_SUNX_constant_data -#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 -#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 -#endif - -#ifndef GL_SUN_global_alpha -#define GL_GLOBAL_ALPHA_SUN 0x81D9 -#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA -#endif - -#ifndef GL_SUN_triangle_list -#define GL_RESTART_SUN 0x0001 -#define GL_REPLACE_MIDDLE_SUN 0x0002 -#define GL_REPLACE_OLDEST_SUN 0x0003 -#define GL_TRIANGLE_LIST_SUN 0x81D7 -#define GL_REPLACEMENT_CODE_SUN 0x81D8 -#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 -#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 -#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 -#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 -#define GL_R1UI_V3F_SUN 0x85C4 -#define GL_R1UI_C4UB_V3F_SUN 0x85C5 -#define GL_R1UI_C3F_V3F_SUN 0x85C6 -#define GL_R1UI_N3F_V3F_SUN 0x85C7 -#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 -#define GL_R1UI_T2F_V3F_SUN 0x85C9 -#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA -#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB -#endif - -#ifndef GL_SUN_vertex -#endif - -#ifndef GL_EXT_blend_func_separate -#define GL_BLEND_DST_RGB_EXT 0x80C8 -#define GL_BLEND_SRC_RGB_EXT 0x80C9 -#define GL_BLEND_DST_ALPHA_EXT 0x80CA -#define GL_BLEND_SRC_ALPHA_EXT 0x80CB -#endif - -#ifndef GL_INGR_color_clamp -#define GL_RED_MIN_CLAMP_INGR 0x8560 -#define GL_GREEN_MIN_CLAMP_INGR 0x8561 -#define GL_BLUE_MIN_CLAMP_INGR 0x8562 -#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 -#define GL_RED_MAX_CLAMP_INGR 0x8564 -#define GL_GREEN_MAX_CLAMP_INGR 0x8565 -#define GL_BLUE_MAX_CLAMP_INGR 0x8566 -#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 -#endif - -#ifndef GL_INGR_interlace_read -#define GL_INTERLACE_READ_INGR 0x8568 -#endif - -#ifndef GL_EXT_stencil_wrap -#define GL_INCR_WRAP_EXT 0x8507 -#define GL_DECR_WRAP_EXT 0x8508 -#endif - -#ifndef GL_EXT_422_pixels -#define GL_422_EXT 0x80CC -#define GL_422_REV_EXT 0x80CD -#define GL_422_AVERAGE_EXT 0x80CE -#define GL_422_REV_AVERAGE_EXT 0x80CF -#endif - -#ifndef GL_NV_texgen_reflection -#define GL_NORMAL_MAP_NV 0x8511 -#define GL_REFLECTION_MAP_NV 0x8512 -#endif - -#ifndef GL_EXT_texture_cube_map -#define GL_NORMAL_MAP_EXT 0x8511 -#define GL_REFLECTION_MAP_EXT 0x8512 -#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C -#endif - -#ifndef GL_SUN_convolution_border_modes -#define GL_WRAP_BORDER_SUN 0x81D4 -#endif - -#ifndef GL_EXT_texture_env_add -#endif - -#ifndef GL_EXT_texture_lod_bias -#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD -#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 -#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 -#endif - -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE -#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF -#endif - -#ifndef GL_EXT_vertex_weighting -#define GL_MODELVIEW0_STACK_DEPTH_EXT GL_MODELVIEW_STACK_DEPTH -#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 -#define GL_MODELVIEW0_MATRIX_EXT GL_MODELVIEW_MATRIX -#define GL_MODELVIEW1_MATRIX_EXT 0x8506 -#define GL_VERTEX_WEIGHTING_EXT 0x8509 -#define GL_MODELVIEW0_EXT GL_MODELVIEW -#define GL_MODELVIEW1_EXT 0x850A -#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B -#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C -#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D -#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E -#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F -#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 -#endif - -#ifndef GL_NV_light_max_exponent -#define GL_MAX_SHININESS_NV 0x8504 -#define GL_MAX_SPOT_EXPONENT_NV 0x8505 -#endif - -#ifndef GL_NV_vertex_array_range -#define GL_VERTEX_ARRAY_RANGE_NV 0x851D -#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E -#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F -#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 -#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 -#endif - -#ifndef GL_NV_register_combiners -#define GL_REGISTER_COMBINERS_NV 0x8522 -#define GL_VARIABLE_A_NV 0x8523 -#define GL_VARIABLE_B_NV 0x8524 -#define GL_VARIABLE_C_NV 0x8525 -#define GL_VARIABLE_D_NV 0x8526 -#define GL_VARIABLE_E_NV 0x8527 -#define GL_VARIABLE_F_NV 0x8528 -#define GL_VARIABLE_G_NV 0x8529 -#define GL_CONSTANT_COLOR0_NV 0x852A -#define GL_CONSTANT_COLOR1_NV 0x852B -#define GL_PRIMARY_COLOR_NV 0x852C -#define GL_SECONDARY_COLOR_NV 0x852D -#define GL_SPARE0_NV 0x852E -#define GL_SPARE1_NV 0x852F -#define GL_DISCARD_NV 0x8530 -#define GL_E_TIMES_F_NV 0x8531 -#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 -#define GL_UNSIGNED_IDENTITY_NV 0x8536 -#define GL_UNSIGNED_INVERT_NV 0x8537 -#define GL_EXPAND_NORMAL_NV 0x8538 -#define GL_EXPAND_NEGATE_NV 0x8539 -#define GL_HALF_BIAS_NORMAL_NV 0x853A -#define GL_HALF_BIAS_NEGATE_NV 0x853B -#define GL_SIGNED_IDENTITY_NV 0x853C -#define GL_SIGNED_NEGATE_NV 0x853D -#define GL_SCALE_BY_TWO_NV 0x853E -#define GL_SCALE_BY_FOUR_NV 0x853F -#define GL_SCALE_BY_ONE_HALF_NV 0x8540 -#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 -#define GL_COMBINER_INPUT_NV 0x8542 -#define GL_COMBINER_MAPPING_NV 0x8543 -#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 -#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 -#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 -#define GL_COMBINER_MUX_SUM_NV 0x8547 -#define GL_COMBINER_SCALE_NV 0x8548 -#define GL_COMBINER_BIAS_NV 0x8549 -#define GL_COMBINER_AB_OUTPUT_NV 0x854A -#define GL_COMBINER_CD_OUTPUT_NV 0x854B -#define GL_COMBINER_SUM_OUTPUT_NV 0x854C -#define GL_MAX_GENERAL_COMBINERS_NV 0x854D -#define GL_NUM_GENERAL_COMBINERS_NV 0x854E -#define GL_COLOR_SUM_CLAMP_NV 0x854F -#define GL_COMBINER0_NV 0x8550 -#define GL_COMBINER1_NV 0x8551 -#define GL_COMBINER2_NV 0x8552 -#define GL_COMBINER3_NV 0x8553 -#define GL_COMBINER4_NV 0x8554 -#define GL_COMBINER5_NV 0x8555 -#define GL_COMBINER6_NV 0x8556 -#define GL_COMBINER7_NV 0x8557 -/* reuse GL_TEXTURE0_ARB */ -/* reuse GL_TEXTURE1_ARB */ -/* reuse GL_ZERO */ -/* reuse GL_NONE */ -/* reuse GL_FOG */ -#endif - -#ifndef GL_NV_fog_distance -#define GL_FOG_DISTANCE_MODE_NV 0x855A -#define GL_EYE_RADIAL_NV 0x855B -#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C -/* reuse GL_EYE_PLANE */ -#endif - -#ifndef GL_NV_texgen_emboss -#define GL_EMBOSS_LIGHT_NV 0x855D -#define GL_EMBOSS_CONSTANT_NV 0x855E -#define GL_EMBOSS_MAP_NV 0x855F -#endif - -#ifndef GL_NV_blend_square -#endif - -#ifndef GL_NV_texture_env_combine4 -#define GL_COMBINE4_NV 0x8503 -#define GL_SOURCE3_RGB_NV 0x8583 -#define GL_SOURCE3_ALPHA_NV 0x858B -#define GL_OPERAND3_RGB_NV 0x8593 -#define GL_OPERAND3_ALPHA_NV 0x859B -#endif - -#ifndef GL_MESA_resize_buffers -#endif - -#ifndef GL_MESA_window_pos -#endif - -#ifndef GL_EXT_texture_compression_s3tc -#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 -#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 -#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 -#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 -#endif - -#ifndef GL_IBM_cull_vertex -#define GL_CULL_VERTEX_IBM 103050 -#endif - -#ifndef GL_IBM_multimode_draw_arrays -#endif - -#ifndef GL_IBM_vertex_array_lists -#define GL_VERTEX_ARRAY_LIST_IBM 103070 -#define GL_NORMAL_ARRAY_LIST_IBM 103071 -#define GL_COLOR_ARRAY_LIST_IBM 103072 -#define GL_INDEX_ARRAY_LIST_IBM 103073 -#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 -#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 -#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 -#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 -#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 -#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 -#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 -#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 -#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 -#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 -#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 -#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 -#endif - -#ifndef GL_SGIX_subsample -#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 -#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 -#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 -#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 -#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 -#endif - -#ifndef GL_SGIX_ycrcb_subsample -#endif - -#ifndef GL_SGIX_ycrcba -#define GL_YCRCB_SGIX 0x8318 -#define GL_YCRCBA_SGIX 0x8319 -#endif - -#ifndef GL_SGI_depth_pass_instrument -#define GL_DEPTH_PASS_INSTRUMENT_SGIX 0x8310 -#define GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX 0x8311 -#define GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX 0x8312 -#endif - -#ifndef GL_3DFX_texture_compression_FXT1 -#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 -#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 -#endif - -#ifndef GL_3DFX_multisample -#define GL_MULTISAMPLE_3DFX 0x86B2 -#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 -#define GL_SAMPLES_3DFX 0x86B4 -#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 -#endif - -#ifndef GL_3DFX_tbuffer -#endif - -#ifndef GL_EXT_multisample -#define GL_MULTISAMPLE_EXT 0x809D -#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F -#define GL_SAMPLE_MASK_EXT 0x80A0 -#define GL_1PASS_EXT 0x80A1 -#define GL_2PASS_0_EXT 0x80A2 -#define GL_2PASS_1_EXT 0x80A3 -#define GL_4PASS_0_EXT 0x80A4 -#define GL_4PASS_1_EXT 0x80A5 -#define GL_4PASS_2_EXT 0x80A6 -#define GL_4PASS_3_EXT 0x80A7 -#define GL_SAMPLE_BUFFERS_EXT 0x80A8 -#define GL_SAMPLES_EXT 0x80A9 -#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA -#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB -#define GL_SAMPLE_PATTERN_EXT 0x80AC -#define GL_MULTISAMPLE_BIT_EXT 0x20000000 -#endif - -#ifndef GL_SGIX_vertex_preclip -#define GL_VERTEX_PRECLIP_SGIX 0x83EE -#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF -#endif - -#ifndef GL_SGIX_convolution_accuracy -#define GL_CONVOLUTION_HINT_SGIX 0x8316 -#endif - -#ifndef GL_SGIX_resample -#define GL_PACK_RESAMPLE_SGIX 0x842C -#define GL_UNPACK_RESAMPLE_SGIX 0x842D -#define GL_RESAMPLE_REPLICATE_SGIX 0x842E -#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F -#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 -#endif - -#ifndef GL_SGIS_point_line_texgen -#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 -#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 -#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 -#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 -#define GL_EYE_POINT_SGIS 0x81F4 -#define GL_OBJECT_POINT_SGIS 0x81F5 -#define GL_EYE_LINE_SGIS 0x81F6 -#define GL_OBJECT_LINE_SGIS 0x81F7 -#endif - -#ifndef GL_SGIS_texture_color_mask -#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF -#endif - -#ifndef GL_EXT_texture_env_dot3 -#define GL_DOT3_RGB_EXT 0x8740 -#define GL_DOT3_RGBA_EXT 0x8741 -#endif - -#ifndef GL_ATI_texture_mirror_once -#define GL_MIRROR_CLAMP_ATI 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 -#endif - -#ifndef GL_NV_fence -#define GL_ALL_COMPLETED_NV 0x84F2 -#define GL_FENCE_STATUS_NV 0x84F3 -#define GL_FENCE_CONDITION_NV 0x84F4 -#endif - -#ifndef GL_IBM_texture_mirrored_repeat -#define GL_MIRRORED_REPEAT_IBM 0x8370 -#endif - -#ifndef GL_NV_evaluators -#define GL_EVAL_2D_NV 0x86C0 -#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 -#define GL_MAP_TESSELLATION_NV 0x86C2 -#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 -#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 -#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 -#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 -#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 -#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 -#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 -#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA -#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB -#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC -#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD -#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE -#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF -#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 -#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 -#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 -#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 -#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 -#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 -#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 -#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 -#endif - -#ifndef GL_NV_packed_depth_stencil -#define GL_DEPTH_STENCIL_NV 0x84F9 -#define GL_UNSIGNED_INT_24_8_NV 0x84FA -#endif - -#ifndef GL_NV_register_combiners2 -#define GL_PER_STAGE_CONSTANTS_NV 0x8535 -#endif - -#ifndef GL_NV_texture_compression_vtc -#endif - -#ifndef GL_NV_texture_rectangle -#define GL_TEXTURE_RECTANGLE_NV 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 -#endif - -#ifndef GL_NV_texture_shader -#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C -#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D -#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E -#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 -#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA -#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB -#define GL_DSDT_MAG_INTENSITY_NV 0x86DC -#define GL_SHADER_CONSISTENT_NV 0x86DD -#define GL_TEXTURE_SHADER_NV 0x86DE -#define GL_SHADER_OPERATION_NV 0x86DF -#define GL_CULL_MODES_NV 0x86E0 -#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 -#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 -#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 -#define GL_OFFSET_TEXTURE_2D_MATRIX_NV GL_OFFSET_TEXTURE_MATRIX_NV -#define GL_OFFSET_TEXTURE_2D_SCALE_NV GL_OFFSET_TEXTURE_SCALE_NV -#define GL_OFFSET_TEXTURE_2D_BIAS_NV GL_OFFSET_TEXTURE_BIAS_NV -#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 -#define GL_CONST_EYE_NV 0x86E5 -#define GL_PASS_THROUGH_NV 0x86E6 -#define GL_CULL_FRAGMENT_NV 0x86E7 -#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 -#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 -#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA -#define GL_DOT_PRODUCT_NV 0x86EC -#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED -#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE -#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 -#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 -#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 -#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 -#define GL_HILO_NV 0x86F4 -#define GL_DSDT_NV 0x86F5 -#define GL_DSDT_MAG_NV 0x86F6 -#define GL_DSDT_MAG_VIB_NV 0x86F7 -#define GL_HILO16_NV 0x86F8 -#define GL_SIGNED_HILO_NV 0x86F9 -#define GL_SIGNED_HILO16_NV 0x86FA -#define GL_SIGNED_RGBA_NV 0x86FB -#define GL_SIGNED_RGBA8_NV 0x86FC -#define GL_SIGNED_RGB_NV 0x86FE -#define GL_SIGNED_RGB8_NV 0x86FF -#define GL_SIGNED_LUMINANCE_NV 0x8701 -#define GL_SIGNED_LUMINANCE8_NV 0x8702 -#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 -#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 -#define GL_SIGNED_ALPHA_NV 0x8705 -#define GL_SIGNED_ALPHA8_NV 0x8706 -#define GL_SIGNED_INTENSITY_NV 0x8707 -#define GL_SIGNED_INTENSITY8_NV 0x8708 -#define GL_DSDT8_NV 0x8709 -#define GL_DSDT8_MAG8_NV 0x870A -#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B -#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C -#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D -#define GL_HI_SCALE_NV 0x870E -#define GL_LO_SCALE_NV 0x870F -#define GL_DS_SCALE_NV 0x8710 -#define GL_DT_SCALE_NV 0x8711 -#define GL_MAGNITUDE_SCALE_NV 0x8712 -#define GL_VIBRANCE_SCALE_NV 0x8713 -#define GL_HI_BIAS_NV 0x8714 -#define GL_LO_BIAS_NV 0x8715 -#define GL_DS_BIAS_NV 0x8716 -#define GL_DT_BIAS_NV 0x8717 -#define GL_MAGNITUDE_BIAS_NV 0x8718 -#define GL_VIBRANCE_BIAS_NV 0x8719 -#define GL_TEXTURE_BORDER_VALUES_NV 0x871A -#define GL_TEXTURE_HI_SIZE_NV 0x871B -#define GL_TEXTURE_LO_SIZE_NV 0x871C -#define GL_TEXTURE_DS_SIZE_NV 0x871D -#define GL_TEXTURE_DT_SIZE_NV 0x871E -#define GL_TEXTURE_MAG_SIZE_NV 0x871F -#endif - -#ifndef GL_NV_texture_shader2 -#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF -#endif - -#ifndef GL_NV_vertex_array_range2 -#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 -#endif - -#ifndef GL_NV_vertex_program -#define GL_VERTEX_PROGRAM_NV 0x8620 -#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 -#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 -#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 -#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 -#define GL_CURRENT_ATTRIB_NV 0x8626 -#define GL_PROGRAM_LENGTH_NV 0x8627 -#define GL_PROGRAM_STRING_NV 0x8628 -#define GL_MODELVIEW_PROJECTION_NV 0x8629 -#define GL_IDENTITY_NV 0x862A -#define GL_INVERSE_NV 0x862B -#define GL_TRANSPOSE_NV 0x862C -#define GL_INVERSE_TRANSPOSE_NV 0x862D -#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E -#define GL_MAX_TRACK_MATRICES_NV 0x862F -#define GL_MATRIX0_NV 0x8630 -#define GL_MATRIX1_NV 0x8631 -#define GL_MATRIX2_NV 0x8632 -#define GL_MATRIX3_NV 0x8633 -#define GL_MATRIX4_NV 0x8634 -#define GL_MATRIX5_NV 0x8635 -#define GL_MATRIX6_NV 0x8636 -#define GL_MATRIX7_NV 0x8637 -#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 -#define GL_CURRENT_MATRIX_NV 0x8641 -#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 -#define GL_PROGRAM_PARAMETER_NV 0x8644 -#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 -#define GL_PROGRAM_TARGET_NV 0x8646 -#define GL_PROGRAM_RESIDENT_NV 0x8647 -#define GL_TRACK_MATRIX_NV 0x8648 -#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 -#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A -#define GL_PROGRAM_ERROR_POSITION_NV 0x864B -#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 -#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 -#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 -#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 -#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 -#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 -#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 -#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 -#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 -#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 -#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A -#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B -#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C -#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D -#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E -#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F -#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 -#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 -#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 -#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 -#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 -#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 -#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 -#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 -#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 -#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 -#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A -#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B -#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C -#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D -#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E -#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F -#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 -#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 -#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 -#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 -#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 -#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 -#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 -#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 -#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 -#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 -#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A -#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B -#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C -#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D -#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E -#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F -#endif - -#ifndef GL_SGIX_texture_coordinate_clamp -#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 -#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A -#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B -#endif - -#ifndef GL_SGIX_scalebias_hint -#define GL_SCALEBIAS_HINT_SGIX 0x8322 -#endif - -#ifndef GL_OML_interlace -#define GL_INTERLACE_OML 0x8980 -#define GL_INTERLACE_READ_OML 0x8981 -#endif - -#ifndef GL_OML_subsample -#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 -#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 -#endif - -#ifndef GL_OML_resample -#define GL_PACK_RESAMPLE_OML 0x8984 -#define GL_UNPACK_RESAMPLE_OML 0x8985 -#define GL_RESAMPLE_REPLICATE_OML 0x8986 -#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 -#define GL_RESAMPLE_AVERAGE_OML 0x8988 -#define GL_RESAMPLE_DECIMATE_OML 0x8989 -#endif - -#ifndef GL_NV_copy_depth_to_color -#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E -#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F -#endif - -#ifndef GL_ATI_envmap_bumpmap -#define GL_BUMP_ROT_MATRIX_ATI 0x8775 -#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 -#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 -#define GL_BUMP_TEX_UNITS_ATI 0x8778 -#define GL_DUDV_ATI 0x8779 -#define GL_DU8DV8_ATI 0x877A -#define GL_BUMP_ENVMAP_ATI 0x877B -#define GL_BUMP_TARGET_ATI 0x877C -#endif - -#ifndef GL_ATI_fragment_shader -#define GL_FRAGMENT_SHADER_ATI 0x8920 -#define GL_REG_0_ATI 0x8921 -#define GL_REG_1_ATI 0x8922 -#define GL_REG_2_ATI 0x8923 -#define GL_REG_3_ATI 0x8924 -#define GL_REG_4_ATI 0x8925 -#define GL_REG_5_ATI 0x8926 -#define GL_REG_6_ATI 0x8927 -#define GL_REG_7_ATI 0x8928 -#define GL_REG_8_ATI 0x8929 -#define GL_REG_9_ATI 0x892A -#define GL_REG_10_ATI 0x892B -#define GL_REG_11_ATI 0x892C -#define GL_REG_12_ATI 0x892D -#define GL_REG_13_ATI 0x892E -#define GL_REG_14_ATI 0x892F -#define GL_REG_15_ATI 0x8930 -#define GL_REG_16_ATI 0x8931 -#define GL_REG_17_ATI 0x8932 -#define GL_REG_18_ATI 0x8933 -#define GL_REG_19_ATI 0x8934 -#define GL_REG_20_ATI 0x8935 -#define GL_REG_21_ATI 0x8936 -#define GL_REG_22_ATI 0x8937 -#define GL_REG_23_ATI 0x8938 -#define GL_REG_24_ATI 0x8939 -#define GL_REG_25_ATI 0x893A -#define GL_REG_26_ATI 0x893B -#define GL_REG_27_ATI 0x893C -#define GL_REG_28_ATI 0x893D -#define GL_REG_29_ATI 0x893E -#define GL_REG_30_ATI 0x893F -#define GL_REG_31_ATI 0x8940 -#define GL_CON_0_ATI 0x8941 -#define GL_CON_1_ATI 0x8942 -#define GL_CON_2_ATI 0x8943 -#define GL_CON_3_ATI 0x8944 -#define GL_CON_4_ATI 0x8945 -#define GL_CON_5_ATI 0x8946 -#define GL_CON_6_ATI 0x8947 -#define GL_CON_7_ATI 0x8948 -#define GL_CON_8_ATI 0x8949 -#define GL_CON_9_ATI 0x894A -#define GL_CON_10_ATI 0x894B -#define GL_CON_11_ATI 0x894C -#define GL_CON_12_ATI 0x894D -#define GL_CON_13_ATI 0x894E -#define GL_CON_14_ATI 0x894F -#define GL_CON_15_ATI 0x8950 -#define GL_CON_16_ATI 0x8951 -#define GL_CON_17_ATI 0x8952 -#define GL_CON_18_ATI 0x8953 -#define GL_CON_19_ATI 0x8954 -#define GL_CON_20_ATI 0x8955 -#define GL_CON_21_ATI 0x8956 -#define GL_CON_22_ATI 0x8957 -#define GL_CON_23_ATI 0x8958 -#define GL_CON_24_ATI 0x8959 -#define GL_CON_25_ATI 0x895A -#define GL_CON_26_ATI 0x895B -#define GL_CON_27_ATI 0x895C -#define GL_CON_28_ATI 0x895D -#define GL_CON_29_ATI 0x895E -#define GL_CON_30_ATI 0x895F -#define GL_CON_31_ATI 0x8960 -#define GL_MOV_ATI 0x8961 -#define GL_ADD_ATI 0x8963 -#define GL_MUL_ATI 0x8964 -#define GL_SUB_ATI 0x8965 -#define GL_DOT3_ATI 0x8966 -#define GL_DOT4_ATI 0x8967 -#define GL_MAD_ATI 0x8968 -#define GL_LERP_ATI 0x8969 -#define GL_CND_ATI 0x896A -#define GL_CND0_ATI 0x896B -#define GL_DOT2_ADD_ATI 0x896C -#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D -#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E -#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F -#define GL_NUM_PASSES_ATI 0x8970 -#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 -#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 -#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 -#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 -#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 -#define GL_SWIZZLE_STR_ATI 0x8976 -#define GL_SWIZZLE_STQ_ATI 0x8977 -#define GL_SWIZZLE_STR_DR_ATI 0x8978 -#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 -#define GL_SWIZZLE_STRQ_ATI 0x897A -#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B -#define GL_RED_BIT_ATI 0x00000001 -#define GL_GREEN_BIT_ATI 0x00000002 -#define GL_BLUE_BIT_ATI 0x00000004 -#define GL_2X_BIT_ATI 0x00000001 -#define GL_4X_BIT_ATI 0x00000002 -#define GL_8X_BIT_ATI 0x00000004 -#define GL_HALF_BIT_ATI 0x00000008 -#define GL_QUARTER_BIT_ATI 0x00000010 -#define GL_EIGHTH_BIT_ATI 0x00000020 -#define GL_SATURATE_BIT_ATI 0x00000040 -#define GL_COMP_BIT_ATI 0x00000002 -#define GL_NEGATE_BIT_ATI 0x00000004 -#define GL_BIAS_BIT_ATI 0x00000008 -#endif - -#ifndef GL_ATI_pn_triangles -#define GL_PN_TRIANGLES_ATI 0x87F0 -#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 -#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 -#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 -#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 -#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 -#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 -#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 -#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 -#endif - -#ifndef GL_ATI_vertex_array_object -#define GL_STATIC_ATI 0x8760 -#define GL_DYNAMIC_ATI 0x8761 -#define GL_PRESERVE_ATI 0x8762 -#define GL_DISCARD_ATI 0x8763 -#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 -#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 -#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 -#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 -#endif - -#ifndef GL_EXT_vertex_shader -#define GL_VERTEX_SHADER_EXT 0x8780 -#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 -#define GL_OP_INDEX_EXT 0x8782 -#define GL_OP_NEGATE_EXT 0x8783 -#define GL_OP_DOT3_EXT 0x8784 -#define GL_OP_DOT4_EXT 0x8785 -#define GL_OP_MUL_EXT 0x8786 -#define GL_OP_ADD_EXT 0x8787 -#define GL_OP_MADD_EXT 0x8788 -#define GL_OP_FRAC_EXT 0x8789 -#define GL_OP_MAX_EXT 0x878A -#define GL_OP_MIN_EXT 0x878B -#define GL_OP_SET_GE_EXT 0x878C -#define GL_OP_SET_LT_EXT 0x878D -#define GL_OP_CLAMP_EXT 0x878E -#define GL_OP_FLOOR_EXT 0x878F -#define GL_OP_ROUND_EXT 0x8790 -#define GL_OP_EXP_BASE_2_EXT 0x8791 -#define GL_OP_LOG_BASE_2_EXT 0x8792 -#define GL_OP_POWER_EXT 0x8793 -#define GL_OP_RECIP_EXT 0x8794 -#define GL_OP_RECIP_SQRT_EXT 0x8795 -#define GL_OP_SUB_EXT 0x8796 -#define GL_OP_CROSS_PRODUCT_EXT 0x8797 -#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 -#define GL_OP_MOV_EXT 0x8799 -#define GL_OUTPUT_VERTEX_EXT 0x879A -#define GL_OUTPUT_COLOR0_EXT 0x879B -#define GL_OUTPUT_COLOR1_EXT 0x879C -#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D -#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E -#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F -#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 -#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 -#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 -#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 -#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 -#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 -#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 -#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 -#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 -#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 -#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA -#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB -#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC -#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD -#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE -#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF -#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 -#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 -#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 -#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 -#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 -#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 -#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 -#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 -#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 -#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 -#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA -#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB -#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC -#define GL_OUTPUT_FOG_EXT 0x87BD -#define GL_SCALAR_EXT 0x87BE -#define GL_VECTOR_EXT 0x87BF -#define GL_MATRIX_EXT 0x87C0 -#define GL_VARIANT_EXT 0x87C1 -#define GL_INVARIANT_EXT 0x87C2 -#define GL_LOCAL_CONSTANT_EXT 0x87C3 -#define GL_LOCAL_EXT 0x87C4 -#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 -#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 -#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 -#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 -#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE -#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF -#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 -#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 -#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 -#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 -#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 -#define GL_X_EXT 0x87D5 -#define GL_Y_EXT 0x87D6 -#define GL_Z_EXT 0x87D7 -#define GL_W_EXT 0x87D8 -#define GL_NEGATIVE_X_EXT 0x87D9 -#define GL_NEGATIVE_Y_EXT 0x87DA -#define GL_NEGATIVE_Z_EXT 0x87DB -#define GL_NEGATIVE_W_EXT 0x87DC -#define GL_ZERO_EXT 0x87DD -#define GL_ONE_EXT 0x87DE -#define GL_NEGATIVE_ONE_EXT 0x87DF -#define GL_NORMALIZED_RANGE_EXT 0x87E0 -#define GL_FULL_RANGE_EXT 0x87E1 -#define GL_CURRENT_VERTEX_EXT 0x87E2 -#define GL_MVP_MATRIX_EXT 0x87E3 -#define GL_VARIANT_VALUE_EXT 0x87E4 -#define GL_VARIANT_DATATYPE_EXT 0x87E5 -#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 -#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 -#define GL_VARIANT_ARRAY_EXT 0x87E8 -#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 -#define GL_INVARIANT_VALUE_EXT 0x87EA -#define GL_INVARIANT_DATATYPE_EXT 0x87EB -#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC -#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED -#endif - -#ifndef GL_ATI_vertex_streams -#define GL_MAX_VERTEX_STREAMS_ATI 0x876B -#define GL_VERTEX_STREAM0_ATI 0x876C -#define GL_VERTEX_STREAM1_ATI 0x876D -#define GL_VERTEX_STREAM2_ATI 0x876E -#define GL_VERTEX_STREAM3_ATI 0x876F -#define GL_VERTEX_STREAM4_ATI 0x8770 -#define GL_VERTEX_STREAM5_ATI 0x8771 -#define GL_VERTEX_STREAM6_ATI 0x8772 -#define GL_VERTEX_STREAM7_ATI 0x8773 -#define GL_VERTEX_SOURCE_ATI 0x8774 -#endif - -#ifndef GL_ATI_element_array -#define GL_ELEMENT_ARRAY_ATI 0x8768 -#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 -#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A -#endif - -#ifndef GL_SUN_mesh_array -#define GL_QUAD_MESH_SUN 0x8614 -#define GL_TRIANGLE_MESH_SUN 0x8615 -#endif - -#ifndef GL_SUN_slice_accum -#define GL_SLICE_ACCUM_SUN 0x85CC -#endif - -#ifndef GL_NV_multisample_filter_hint -#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 -#endif - -#ifndef GL_NV_depth_clamp -#define GL_DEPTH_CLAMP_NV 0x864F -#endif - -#ifndef GL_NV_occlusion_query -#define GL_PIXEL_COUNTER_BITS_NV 0x8864 -#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 -#define GL_PIXEL_COUNT_NV 0x8866 -#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 -#endif - -#ifndef GL_NV_point_sprite -#define GL_POINT_SPRITE_NV 0x8861 -#define GL_COORD_REPLACE_NV 0x8862 -#define GL_POINT_SPRITE_R_MODE_NV 0x8863 -#endif - -#ifndef GL_NV_texture_shader3 -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 -#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 -#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 -#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 -#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 -#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A -#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B -#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C -#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D -#define GL_HILO8_NV 0x885E -#define GL_SIGNED_HILO8_NV 0x885F -#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 -#endif - -#ifndef GL_NV_vertex_program1_1 -#endif - -#ifndef GL_EXT_shadow_funcs -#endif - -#ifndef GL_EXT_stencil_two_side -#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 -#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 -#endif - -#ifndef GL_ATI_text_fragment_shader -#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 -#endif - -#ifndef GL_APPLE_client_storage -#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 -#endif - -#ifndef GL_APPLE_element_array -#define GL_ELEMENT_ARRAY_APPLE 0x8768 -#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8769 -#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x876A -#endif - -#ifndef GL_APPLE_fence -#define GL_DRAW_PIXELS_APPLE 0x8A0A -#define GL_FENCE_APPLE 0x8A0B -#endif - -#ifndef GL_APPLE_vertex_array_object -#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 -#endif - -#ifndef GL_APPLE_vertex_array_range -#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D -#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E -#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F -#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 -#define GL_STORAGE_CACHED_APPLE 0x85BE -#define GL_STORAGE_SHARED_APPLE 0x85BF -#endif - -#ifndef GL_APPLE_ycbcr_422 -#define GL_YCBCR_422_APPLE 0x85B9 -#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB -#endif - -#ifndef GL_S3_s3tc -#define GL_RGB_S3TC 0x83A0 -#define GL_RGB4_S3TC 0x83A1 -#define GL_RGBA_S3TC 0x83A2 -#define GL_RGBA4_S3TC 0x83A3 -#endif - -#ifndef GL_ATI_draw_buffers -#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 -#define GL_DRAW_BUFFER0_ATI 0x8825 -#define GL_DRAW_BUFFER1_ATI 0x8826 -#define GL_DRAW_BUFFER2_ATI 0x8827 -#define GL_DRAW_BUFFER3_ATI 0x8828 -#define GL_DRAW_BUFFER4_ATI 0x8829 -#define GL_DRAW_BUFFER5_ATI 0x882A -#define GL_DRAW_BUFFER6_ATI 0x882B -#define GL_DRAW_BUFFER7_ATI 0x882C -#define GL_DRAW_BUFFER8_ATI 0x882D -#define GL_DRAW_BUFFER9_ATI 0x882E -#define GL_DRAW_BUFFER10_ATI 0x882F -#define GL_DRAW_BUFFER11_ATI 0x8830 -#define GL_DRAW_BUFFER12_ATI 0x8831 -#define GL_DRAW_BUFFER13_ATI 0x8832 -#define GL_DRAW_BUFFER14_ATI 0x8833 -#define GL_DRAW_BUFFER15_ATI 0x8834 -#endif - -#ifndef GL_ATI_pixel_format_float -#define GL_TYPE_RGBA_FLOAT_ATI 0x8820 -#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 -#endif - -#ifndef GL_ATI_texture_env_combine3 -#define GL_MODULATE_ADD_ATI 0x8744 -#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 -#define GL_MODULATE_SUBTRACT_ATI 0x8746 -#endif - -#ifndef GL_ATI_texture_float -#define GL_RGBA_FLOAT32_ATI 0x8814 -#define GL_RGB_FLOAT32_ATI 0x8815 -#define GL_ALPHA_FLOAT32_ATI 0x8816 -#define GL_INTENSITY_FLOAT32_ATI 0x8817 -#define GL_LUMINANCE_FLOAT32_ATI 0x8818 -#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 -#define GL_RGBA_FLOAT16_ATI 0x881A -#define GL_RGB_FLOAT16_ATI 0x881B -#define GL_ALPHA_FLOAT16_ATI 0x881C -#define GL_INTENSITY_FLOAT16_ATI 0x881D -#define GL_LUMINANCE_FLOAT16_ATI 0x881E -#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F -#endif - -#ifndef GL_NV_float_buffer -#define GL_FLOAT_R_NV 0x8880 -#define GL_FLOAT_RG_NV 0x8881 -#define GL_FLOAT_RGB_NV 0x8882 -#define GL_FLOAT_RGBA_NV 0x8883 -#define GL_FLOAT_R16_NV 0x8884 -#define GL_FLOAT_R32_NV 0x8885 -#define GL_FLOAT_RG16_NV 0x8886 -#define GL_FLOAT_RG32_NV 0x8887 -#define GL_FLOAT_RGB16_NV 0x8888 -#define GL_FLOAT_RGB32_NV 0x8889 -#define GL_FLOAT_RGBA16_NV 0x888A -#define GL_FLOAT_RGBA32_NV 0x888B -#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C -#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D -#define GL_FLOAT_RGBA_MODE_NV 0x888E -#endif - -#ifndef GL_NV_fragment_program -#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 -#define GL_FRAGMENT_PROGRAM_NV 0x8870 -#define GL_MAX_TEXTURE_COORDS_NV 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 -#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 -#define GL_PROGRAM_ERROR_STRING_NV 0x8874 -#endif - -#ifndef GL_NV_half_float -#define GL_HALF_FLOAT_NV 0x140B -#endif - -#ifndef GL_NV_pixel_data_range -#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 -#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 -#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A -#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B -#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C -#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D -#endif - -#ifndef GL_NV_primitive_restart -#define GL_PRIMITIVE_RESTART_NV 0x8558 -#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 -#endif - -#ifndef GL_NV_texture_expand_normal -#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F -#endif - -#ifndef GL_NV_vertex_program2 -#endif - -#ifndef GL_ATI_map_object_buffer -#endif - -#ifndef GL_ATI_separate_stencil -#define GL_STENCIL_BACK_FUNC_ATI 0x8800 -#define GL_STENCIL_BACK_FAIL_ATI 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 -#endif - -#ifndef GL_ATI_vertex_attrib_array_object -#endif - -#ifndef GL_OES_read_format -#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B -#endif - -#ifndef GL_EXT_depth_bounds_test -#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 -#define GL_DEPTH_BOUNDS_EXT 0x8891 -#endif - -#ifndef GL_EXT_texture_mirror_clamp -#define GL_MIRROR_CLAMP_EXT 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 -#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 -#endif - -#ifndef GL_EXT_blend_equation_separate -#define GL_BLEND_EQUATION_RGB_EXT 0x8009 -#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D -#endif - -#ifndef GL_MESA_pack_invert -#define GL_PACK_INVERT_MESA 0x8758 -#endif - -#ifndef GL_MESA_ycbcr_texture -#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB -#define GL_YCBCR_MESA 0x8757 -#endif - -#ifndef GL_EXT_pixel_buffer_object -#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF -#endif - -#ifndef GL_NV_fragment_program_option -#endif - -#ifndef GL_NV_fragment_program2 -#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 -#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 -#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 -#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 -#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 -#endif - -#ifndef GL_NV_vertex_program2_option -/* reuse GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */ -/* reuse GL_MAX_PROGRAM_CALL_DEPTH_NV */ -#endif - -#ifndef GL_NV_vertex_program3 -/* reuse GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */ -#endif - -#ifndef GL_EXT_framebuffer_object -#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 -#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 -#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 -#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 -#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 -#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA -#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB -#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC -#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD -#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF -#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 -#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 -#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 -#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 -#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 -#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 -#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 -#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 -#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 -#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 -#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA -#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB -#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC -#define GL_COLOR_ATTACHMENT13_EXT 0x8CED -#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE -#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF -#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 -#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 -#define GL_FRAMEBUFFER_EXT 0x8D40 -#define GL_RENDERBUFFER_EXT 0x8D41 -#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 -#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 -#define GL_STENCIL_INDEX1_EXT 0x8D46 -#define GL_STENCIL_INDEX4_EXT 0x8D47 -#define GL_STENCIL_INDEX8_EXT 0x8D48 -#define GL_STENCIL_INDEX16_EXT 0x8D49 -#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 -#endif - -#ifndef GL_GREMEDY_string_marker -#endif - -#ifndef GL_EXT_packed_depth_stencil -#define GL_DEPTH_STENCIL_EXT 0x84F9 -#define GL_UNSIGNED_INT_24_8_EXT 0x84FA -#define GL_DEPTH24_STENCIL8_EXT 0x88F0 -#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 -#endif - -#ifndef GL_EXT_stencil_clear_tag -#define GL_STENCIL_TAG_BITS_EXT 0x88F2 -#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 -#endif - -#ifndef GL_EXT_texture_sRGB -#define GL_SRGB_EXT 0x8C40 -#define GL_SRGB8_EXT 0x8C41 -#define GL_SRGB_ALPHA_EXT 0x8C42 -#define GL_SRGB8_ALPHA8_EXT 0x8C43 -#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 -#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 -#define GL_SLUMINANCE_EXT 0x8C46 -#define GL_SLUMINANCE8_EXT 0x8C47 -#define GL_COMPRESSED_SRGB_EXT 0x8C48 -#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 -#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A -#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B -#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F -#endif - -#ifndef GL_EXT_framebuffer_blit -#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 -#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 -#define GL_DRAW_FRAMEBUFFER_BINDING_EXT GL_FRAMEBUFFER_BINDING_EXT -#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA -#endif - -#ifndef GL_EXT_framebuffer_multisample -#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 -#define GL_MAX_SAMPLES_EXT 0x8D57 -#endif - -#ifndef GL_MESAX_texture_stack -#define GL_TEXTURE_1D_STACK_MESAX 0x8759 -#define GL_TEXTURE_2D_STACK_MESAX 0x875A -#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B -#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C -#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D -#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E -#endif - -#ifndef GL_EXT_timer_query -#define GL_TIME_ELAPSED_EXT 0x88BF -#endif - -#ifndef GL_EXT_gpu_program_parameters -#endif - -#ifndef GL_APPLE_flush_buffer_range -#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 -#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 -#endif - -#ifndef GL_NV_gpu_program4 -#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 -#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 -#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 -#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 -#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 -#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 -#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 -#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 -#endif - -#ifndef GL_NV_geometry_program4 -#define GL_LINES_ADJACENCY_EXT 0x000A -#define GL_LINE_STRIP_ADJACENCY_EXT 0x000B -#define GL_TRIANGLES_ADJACENCY_EXT 0x000C -#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D -#define GL_GEOMETRY_PROGRAM_NV 0x8C26 -#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 -#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 -#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA -#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB -#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 -#define GL_PROGRAM_POINT_SIZE_EXT 0x8642 -#endif - -#ifndef GL_EXT_geometry_shader4 -#define GL_GEOMETRY_SHADER_EXT 0x8DD9 -/* reuse GL_GEOMETRY_VERTICES_OUT_EXT */ -/* reuse GL_GEOMETRY_INPUT_TYPE_EXT */ -/* reuse GL_GEOMETRY_OUTPUT_TYPE_EXT */ -/* reuse GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT */ -#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD -#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE -#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 -/* reuse GL_LINES_ADJACENCY_EXT */ -/* reuse GL_LINE_STRIP_ADJACENCY_EXT */ -/* reuse GL_TRIANGLES_ADJACENCY_EXT */ -/* reuse GL_TRIANGLE_STRIP_ADJACENCY_EXT */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */ -/* reuse GL_PROGRAM_POINT_SIZE_EXT */ -#endif - -#ifndef GL_NV_vertex_program4 -#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD -#endif - -#ifndef GL_EXT_gpu_shader4 -#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 -#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 -#define GL_SAMPLER_BUFFER_EXT 0x8DC2 -#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 -#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 -#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 -#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 -#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 -#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 -#define GL_INT_SAMPLER_1D_EXT 0x8DC9 -#define GL_INT_SAMPLER_2D_EXT 0x8DCA -#define GL_INT_SAMPLER_3D_EXT 0x8DCB -#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC -#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD -#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE -#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF -#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 -#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 -#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 -#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 -#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 -#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 -#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 -#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 -#endif - -#ifndef GL_EXT_draw_instanced -#endif - -#ifndef GL_EXT_packed_float -#define GL_R11F_G11F_B10F_EXT 0x8C3A -#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B -#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C -#endif - -#ifndef GL_EXT_texture_array -#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 -#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 -#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A -#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B -#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C -#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D -#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF -#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */ -#endif - -#ifndef GL_EXT_texture_buffer_object -#define GL_TEXTURE_BUFFER_EXT 0x8C2A -#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B -#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C -#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D -#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E -#endif - -#ifndef GL_EXT_texture_compression_latc -#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 -#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 -#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 -#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 -#endif - -#ifndef GL_EXT_texture_compression_rgtc -#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB -#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC -#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD -#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE -#endif - -#ifndef GL_EXT_texture_shared_exponent -#define GL_RGB9_E5_EXT 0x8C3D -#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E -#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F -#endif - -#ifndef GL_NV_depth_buffer_float -#define GL_DEPTH_COMPONENT32F_NV 0x8DAB -#define GL_DEPTH32F_STENCIL8_NV 0x8DAC -#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD -#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF -#endif - -#ifndef GL_NV_fragment_program4 -#endif - -#ifndef GL_NV_framebuffer_multisample_coverage -#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB -#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 -#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 -#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 -#endif - -#ifndef GL_EXT_framebuffer_sRGB -#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 -#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA -#endif - -#ifndef GL_NV_geometry_shader4 -#endif - -#ifndef GL_NV_parameter_buffer_object -#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 -#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 -#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 -#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 -#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 -#endif - -#ifndef GL_EXT_draw_buffers2 -#endif - -#ifndef GL_NV_transform_feedback -#define GL_BACK_PRIMARY_COLOR_NV 0x8C77 -#define GL_BACK_SECONDARY_COLOR_NV 0x8C78 -#define GL_TEXTURE_COORD_NV 0x8C79 -#define GL_CLIP_DISTANCE_NV 0x8C7A -#define GL_VERTEX_ID_NV 0x8C7B -#define GL_PRIMITIVE_ID_NV 0x8C7C -#define GL_GENERIC_ATTRIB_NV 0x8C7D -#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E -#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 -#define GL_ACTIVE_VARYINGS_NV 0x8C81 -#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 -#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 -#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 -#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 -#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 -#define GL_PRIMITIVES_GENERATED_NV 0x8C87 -#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 -#define GL_RASTERIZER_DISCARD_NV 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_ATTRIBS_NV 0x8C8A -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B -#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C -#define GL_SEPARATE_ATTRIBS_NV 0x8C8D -#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E -#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F -#endif - -#ifndef GL_EXT_bindable_uniform -#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 -#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 -#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 -#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED -#define GL_UNIFORM_BUFFER_EXT 0x8DEE -#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF -#endif - -#ifndef GL_EXT_texture_integer -#define GL_RGBA32UI_EXT 0x8D70 -#define GL_RGB32UI_EXT 0x8D71 -#define GL_ALPHA32UI_EXT 0x8D72 -#define GL_INTENSITY32UI_EXT 0x8D73 -#define GL_LUMINANCE32UI_EXT 0x8D74 -#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 -#define GL_RGBA16UI_EXT 0x8D76 -#define GL_RGB16UI_EXT 0x8D77 -#define GL_ALPHA16UI_EXT 0x8D78 -#define GL_INTENSITY16UI_EXT 0x8D79 -#define GL_LUMINANCE16UI_EXT 0x8D7A -#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B -#define GL_RGBA8UI_EXT 0x8D7C -#define GL_RGB8UI_EXT 0x8D7D -#define GL_ALPHA8UI_EXT 0x8D7E -#define GL_INTENSITY8UI_EXT 0x8D7F -#define GL_LUMINANCE8UI_EXT 0x8D80 -#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 -#define GL_RGBA32I_EXT 0x8D82 -#define GL_RGB32I_EXT 0x8D83 -#define GL_ALPHA32I_EXT 0x8D84 -#define GL_INTENSITY32I_EXT 0x8D85 -#define GL_LUMINANCE32I_EXT 0x8D86 -#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 -#define GL_RGBA16I_EXT 0x8D88 -#define GL_RGB16I_EXT 0x8D89 -#define GL_ALPHA16I_EXT 0x8D8A -#define GL_INTENSITY16I_EXT 0x8D8B -#define GL_LUMINANCE16I_EXT 0x8D8C -#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D -#define GL_RGBA8I_EXT 0x8D8E -#define GL_RGB8I_EXT 0x8D8F -#define GL_ALPHA8I_EXT 0x8D90 -#define GL_INTENSITY8I_EXT 0x8D91 -#define GL_LUMINANCE8I_EXT 0x8D92 -#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 -#define GL_RED_INTEGER_EXT 0x8D94 -#define GL_GREEN_INTEGER_EXT 0x8D95 -#define GL_BLUE_INTEGER_EXT 0x8D96 -#define GL_ALPHA_INTEGER_EXT 0x8D97 -#define GL_RGB_INTEGER_EXT 0x8D98 -#define GL_RGBA_INTEGER_EXT 0x8D99 -#define GL_BGR_INTEGER_EXT 0x8D9A -#define GL_BGRA_INTEGER_EXT 0x8D9B -#define GL_LUMINANCE_INTEGER_EXT 0x8D9C -#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D -#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E -#endif - -#ifndef GL_GREMEDY_frame_terminator -#endif - -#ifndef GL_NV_conditional_render -#define GL_QUERY_WAIT_NV 0x8E13 -#define GL_QUERY_NO_WAIT_NV 0x8E14 -#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 -#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 -#endif - -#ifndef GL_NV_present_video -#define GL_FRAME_NV 0x8E26 -#define GL_FIELDS_NV 0x8E27 -#define GL_CURRENT_TIME_NV 0x8E28 -#define GL_NUM_FILL_STREAMS_NV 0x8E29 -#define GL_PRESENT_TIME_NV 0x8E2A -#define GL_PRESENT_DURATION_NV 0x8E2B -#endif - -#ifndef GL_EXT_transform_feedback -#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E -#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84 -#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85 -#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F -#define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C -#define GL_SEPARATE_ATTRIBS_EXT 0x8C8D -#define GL_PRIMITIVES_GENERATED_EXT 0x8C87 -#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88 -#define GL_RASTERIZER_DISCARD_EXT 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80 -#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83 -#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F -#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76 -#endif - -#ifndef GL_EXT_direct_state_access -#define GL_PROGRAM_MATRIX_EXT 0x8E2D -#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E -#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F -#endif - -#ifndef GL_EXT_vertex_array_bgra -/* reuse GL_BGRA */ -#endif - -#ifndef GL_EXT_texture_swizzle -#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42 -#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43 -#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44 -#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45 -#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46 -#endif - -#ifndef GL_NV_explicit_multisample -#define GL_SAMPLE_POSITION_NV 0x8E50 -#define GL_SAMPLE_MASK_NV 0x8E51 -#define GL_SAMPLE_MASK_VALUE_NV 0x8E52 -#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53 -#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54 -#define GL_TEXTURE_RENDERBUFFER_NV 0x8E55 -#define GL_SAMPLER_RENDERBUFFER_NV 0x8E56 -#define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57 -#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58 -#define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59 -#endif - -#ifndef GL_NV_transform_feedback2 -#define GL_TRANSFORM_FEEDBACK_NV 0x8E22 -#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23 -#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24 -#define GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25 -#endif - -#ifndef GL_ATI_meminfo -#define GL_VBO_FREE_MEMORY_ATI 0x87FB -#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC -#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD -#endif - -#ifndef GL_AMD_performance_monitor -#define GL_COUNTER_TYPE_AMD 0x8BC0 -#define GL_COUNTER_RANGE_AMD 0x8BC1 -#define GL_UNSIGNED_INT64_AMD 0x8BC2 -#define GL_PERCENTAGE_AMD 0x8BC3 -#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 -#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 -#define GL_PERFMON_RESULT_AMD 0x8BC6 -#endif - -#ifndef GL_AMD_texture_texture4 -#endif - -#ifndef GL_AMD_vertex_shader_tesselator -#define GL_SAMPLER_BUFFER_AMD 0x9001 -#define GL_INT_SAMPLER_BUFFER_AMD 0x9002 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003 -#define GL_TESSELLATION_MODE_AMD 0x9004 -#define GL_TESSELLATION_FACTOR_AMD 0x9005 -#define GL_DISCRETE_AMD 0x9006 -#define GL_CONTINUOUS_AMD 0x9007 -#endif - -#ifndef GL_EXT_provoking_vertex -#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C -#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D -#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E -#define GL_PROVOKING_VERTEX_EXT 0x8E4F -#endif - -#ifndef GL_EXT_texture_snorm -#define GL_ALPHA_SNORM 0x9010 -#define GL_LUMINANCE_SNORM 0x9011 -#define GL_LUMINANCE_ALPHA_SNORM 0x9012 -#define GL_INTENSITY_SNORM 0x9013 -#define GL_ALPHA8_SNORM 0x9014 -#define GL_LUMINANCE8_SNORM 0x9015 -#define GL_LUMINANCE8_ALPHA8_SNORM 0x9016 -#define GL_INTENSITY8_SNORM 0x9017 -#define GL_ALPHA16_SNORM 0x9018 -#define GL_LUMINANCE16_SNORM 0x9019 -#define GL_LUMINANCE16_ALPHA16_SNORM 0x901A -#define GL_INTENSITY16_SNORM 0x901B -/* reuse GL_R_SNORM */ -/* reuse GL_RG_SNORM */ -/* reuse GL_RGB_SNORM */ -/* reuse GL_RGBA_SNORM */ -/* reuse GL_R8_SNORM */ -/* reuse GL_RG8_SNORM */ -/* reuse GL_RGB8_SNORM */ -/* reuse GL_RGBA8_SNORM */ -/* reuse GL_R16_SNORM */ -/* reuse GL_RG16_SNORM */ -/* reuse GL_RGB16_SNORM */ -/* reuse GL_RGBA16_SNORM */ -/* reuse GL_SIGNED_NORMALIZED */ -#endif - -#ifndef GL_AMD_draw_buffers_blend -#endif - -#ifndef GL_APPLE_texture_range -#define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7 -#define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8 -#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC -#define GL_STORAGE_PRIVATE_APPLE 0x85BD -/* reuse GL_STORAGE_CACHED_APPLE */ -/* reuse GL_STORAGE_SHARED_APPLE */ -#endif - -#ifndef GL_APPLE_float_pixels -#define GL_HALF_APPLE 0x140B -#define GL_RGBA_FLOAT32_APPLE 0x8814 -#define GL_RGB_FLOAT32_APPLE 0x8815 -#define GL_ALPHA_FLOAT32_APPLE 0x8816 -#define GL_INTENSITY_FLOAT32_APPLE 0x8817 -#define GL_LUMINANCE_FLOAT32_APPLE 0x8818 -#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 -#define GL_RGBA_FLOAT16_APPLE 0x881A -#define GL_RGB_FLOAT16_APPLE 0x881B -#define GL_ALPHA_FLOAT16_APPLE 0x881C -#define GL_INTENSITY_FLOAT16_APPLE 0x881D -#define GL_LUMINANCE_FLOAT16_APPLE 0x881E -#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F -#define GL_COLOR_FLOAT_APPLE 0x8A0F -#endif - -#ifndef GL_APPLE_vertex_program_evaluators -#define GL_VERTEX_ATTRIB_MAP1_APPLE 0x8A00 -#define GL_VERTEX_ATTRIB_MAP2_APPLE 0x8A01 -#define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE 0x8A02 -#define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03 -#define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04 -#define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05 -#define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE 0x8A06 -#define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07 -#define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08 -#define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09 -#endif - -#ifndef GL_APPLE_aux_depth_stencil -#define GL_AUX_DEPTH_STENCIL_APPLE 0x8A14 -#endif - -#ifndef GL_APPLE_object_purgeable -#define GL_BUFFER_OBJECT_APPLE 0x85B3 -#define GL_RELEASED_APPLE 0x8A19 -#define GL_VOLATILE_APPLE 0x8A1A -#define GL_RETAINED_APPLE 0x8A1B -#define GL_UNDEFINED_APPLE 0x8A1C -#define GL_PURGEABLE_APPLE 0x8A1D -#endif - -#ifndef GL_APPLE_row_bytes -#define GL_PACK_ROW_BYTES_APPLE 0x8A15 -#define GL_UNPACK_ROW_BYTES_APPLE 0x8A16 -#endif - - -/*************************************************************/ - -#include <stddef.h> -#ifndef GL_VERSION_2_0 -/* GL type for program/shader text */ -typedef char GLchar; -#endif - -#ifndef GL_VERSION_1_5 -/* GL types for handling large vertex buffer objects */ -typedef ptrdiff_t GLintptr; -typedef ptrdiff_t GLsizeiptr; -#endif - -#ifndef GL_ARB_vertex_buffer_object -/* GL types for handling large vertex buffer objects */ -typedef ptrdiff_t GLintptrARB; -typedef ptrdiff_t GLsizeiptrARB; -#endif - -#ifndef GL_ARB_shader_objects -/* GL types for program/shader text and shader object handles */ -typedef char GLcharARB; -typedef unsigned int GLhandleARB; -#endif - -/* GL type for "half" precision (s10e5) float data in host memory */ -#ifndef GL_ARB_half_float_pixel -typedef unsigned short GLhalfARB; -#endif - -#ifndef GL_NV_half_float -typedef unsigned short GLhalfNV; -#endif - -#ifndef GLEXT_64_TYPES_DEFINED -/* This code block is duplicated in glxext.h, so must be protected */ -#define GLEXT_64_TYPES_DEFINED -/* Define int32_t, int64_t, and uint64_t types for UST/MSC */ -/* (as used in the GL_EXT_timer_query extension). */ -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -#include <inttypes.h> -#elif defined(__sun__) || defined(__digital__) -#include <inttypes.h> -#if defined(__STDC__) -#if defined(__arch64__) || defined(_LP64) -typedef long int int64_t; -typedef unsigned long int uint64_t; -#else -typedef long long int int64_t; -typedef unsigned long long int uint64_t; -#endif /* __arch64__ */ -#endif /* __STDC__ */ -#elif defined( __VMS ) || defined(__sgi) -#include <inttypes.h> -#elif defined(__SCO__) || defined(__USLC__) -#include <stdint.h> -#elif defined(__UNIXOS2__) || defined(__SOL64__) -typedef long int int32_t; -typedef long long int int64_t; -typedef unsigned long long int uint64_t; -#elif defined(_WIN32) && defined(__GNUC__) -#include <stdint.h> -#elif defined(_WIN32) -typedef __int32 int32_t; -typedef __int64 int64_t; -typedef unsigned __int64 uint64_t; -#else -/* Fallback if nothing above works */ -#include <inttypes.h> -#endif -#endif - -#ifndef GL_EXT_timer_query -typedef int64_t GLint64EXT; -typedef uint64_t GLuint64EXT; -#endif - -#ifndef ARB_sync -typedef int64_t GLint64; -typedef uint64_t GLuint64; -typedef struct __GLsync *GLsync; -#endif - -#ifndef GL_VERSION_1_2 -#define GL_VERSION_1_2 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendColor (GLclampf, GLclampf, GLclampf, GLclampf); -GLAPI void APIENTRY glBlendEquation (GLenum); -GLAPI void APIENTRY glDrawRangeElements (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); -GLAPI void APIENTRY glTexImage3D (GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glCopyTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif - -#ifndef GL_VERSION_1_2_DEPRECATED -#define GL_VERSION_1_2_DEPRECATED 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorTable (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glColorTableParameterfv (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glColorTableParameteriv (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glCopyColorTable (GLenum, GLenum, GLint, GLint, GLsizei); -GLAPI void APIENTRY glGetColorTable (GLenum, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetColorTableParameterfv (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetColorTableParameteriv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glColorSubTable (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glCopyColorSubTable (GLenum, GLsizei, GLint, GLint, GLsizei); -GLAPI void APIENTRY glConvolutionFilter1D (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glConvolutionFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glConvolutionParameterf (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glConvolutionParameterfv (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glConvolutionParameteri (GLenum, GLenum, GLint); -GLAPI void APIENTRY glConvolutionParameteriv (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum, GLenum, GLint, GLint, GLsizei); -GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); -GLAPI void APIENTRY glGetConvolutionFilter (GLenum, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetSeparableFilter (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); -GLAPI void APIENTRY glSeparableFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); -GLAPI void APIENTRY glGetHistogram (GLenum, GLboolean, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetHistogramParameterfv (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetHistogramParameteriv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetMinmax (GLenum, GLboolean, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glHistogram (GLenum, GLsizei, GLenum, GLboolean); -GLAPI void APIENTRY glMinmax (GLenum, GLenum, GLboolean); -GLAPI void APIENTRY glResetHistogram (GLenum); -GLAPI void APIENTRY glResetMinmax (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); -typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); -#endif - -#ifndef GL_VERSION_1_3 -#define GL_VERSION_1_3 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveTexture (GLenum); -GLAPI void APIENTRY glSampleCoverage (GLclampf, GLboolean); -GLAPI void APIENTRY glCompressedTexImage3D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexImage2D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexImage1D (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glGetCompressedTexImage (GLenum, GLint, GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); -#endif - -#ifndef GL_VERSION_1_3_DEPRECATED -#define GL_VERSION_1_3_DEPRECATED 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glClientActiveTexture (GLenum); -GLAPI void APIENTRY glMultiTexCoord1d (GLenum, GLdouble); -GLAPI void APIENTRY glMultiTexCoord1dv (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord1f (GLenum, GLfloat); -GLAPI void APIENTRY glMultiTexCoord1fv (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord1i (GLenum, GLint); -GLAPI void APIENTRY glMultiTexCoord1iv (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord1s (GLenum, GLshort); -GLAPI void APIENTRY glMultiTexCoord1sv (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord2d (GLenum, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord2dv (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord2f (GLenum, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord2fv (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord2i (GLenum, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord2iv (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord2s (GLenum, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord2sv (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord3d (GLenum, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord3dv (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord3f (GLenum, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord3fv (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord3i (GLenum, GLint, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord3iv (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord3s (GLenum, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord3sv (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord4d (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord4dv (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord4f (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord4fv (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord4i (GLenum, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord4iv (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord4s (GLenum, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord4sv (GLenum, const GLshort *); -GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *); -GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *); -GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *); -GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); -#endif - -#ifndef GL_VERSION_1_4 -#define GL_VERSION_1_4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparate (GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glMultiDrawArrays (GLenum, GLint *, GLsizei *, GLsizei); -GLAPI void APIENTRY glMultiDrawElements (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); -GLAPI void APIENTRY glPointParameterf (GLenum, GLfloat); -GLAPI void APIENTRY glPointParameterfv (GLenum, const GLfloat *); -GLAPI void APIENTRY glPointParameteri (GLenum, GLint); -GLAPI void APIENTRY glPointParameteriv (GLenum, const GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); -#endif - -#ifndef GL_VERSION_1_4_DEPRECATED -#define GL_VERSION_1_4_DEPRECATED 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFogCoordf (GLfloat); -GLAPI void APIENTRY glFogCoordfv (const GLfloat *); -GLAPI void APIENTRY glFogCoordd (GLdouble); -GLAPI void APIENTRY glFogCoorddv (const GLdouble *); -GLAPI void APIENTRY glFogCoordPointer (GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glSecondaryColor3b (GLbyte, GLbyte, GLbyte); -GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *); -GLAPI void APIENTRY glSecondaryColor3d (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *); -GLAPI void APIENTRY glSecondaryColor3f (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *); -GLAPI void APIENTRY glSecondaryColor3i (GLint, GLint, GLint); -GLAPI void APIENTRY glSecondaryColor3iv (const GLint *); -GLAPI void APIENTRY glSecondaryColor3s (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *); -GLAPI void APIENTRY glSecondaryColor3ub (GLubyte, GLubyte, GLubyte); -GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *); -GLAPI void APIENTRY glSecondaryColor3ui (GLuint, GLuint, GLuint); -GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *); -GLAPI void APIENTRY glSecondaryColor3us (GLushort, GLushort, GLushort); -GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *); -GLAPI void APIENTRY glSecondaryColorPointer (GLint, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glWindowPos2d (GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos2dv (const GLdouble *); -GLAPI void APIENTRY glWindowPos2f (GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos2fv (const GLfloat *); -GLAPI void APIENTRY glWindowPos2i (GLint, GLint); -GLAPI void APIENTRY glWindowPos2iv (const GLint *); -GLAPI void APIENTRY glWindowPos2s (GLshort, GLshort); -GLAPI void APIENTRY glWindowPos2sv (const GLshort *); -GLAPI void APIENTRY glWindowPos3d (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos3dv (const GLdouble *); -GLAPI void APIENTRY glWindowPos3f (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos3fv (const GLfloat *); -GLAPI void APIENTRY glWindowPos3i (GLint, GLint, GLint); -GLAPI void APIENTRY glWindowPos3iv (const GLint *); -GLAPI void APIENTRY glWindowPos3s (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glWindowPos3sv (const GLshort *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); -typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); -typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); -typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); -#endif - -#ifndef GL_VERSION_1_5 -#define GL_VERSION_1_5 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenQueries (GLsizei, GLuint *); -GLAPI void APIENTRY glDeleteQueries (GLsizei, const GLuint *); -GLAPI GLboolean APIENTRY glIsQuery (GLuint); -GLAPI void APIENTRY glBeginQuery (GLenum, GLuint); -GLAPI void APIENTRY glEndQuery (GLenum); -GLAPI void APIENTRY glGetQueryiv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetQueryObjectiv (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetQueryObjectuiv (GLuint, GLenum, GLuint *); -GLAPI void APIENTRY glBindBuffer (GLenum, GLuint); -GLAPI void APIENTRY glDeleteBuffers (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenBuffers (GLsizei, GLuint *); -GLAPI GLboolean APIENTRY glIsBuffer (GLuint); -GLAPI void APIENTRY glBufferData (GLenum, GLsizeiptr, const GLvoid *, GLenum); -GLAPI void APIENTRY glBufferSubData (GLenum, GLintptr, GLsizeiptr, const GLvoid *); -GLAPI void APIENTRY glGetBufferSubData (GLenum, GLintptr, GLsizeiptr, GLvoid *); -GLAPI GLvoid* APIENTRY glMapBuffer (GLenum, GLenum); -GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum); -GLAPI void APIENTRY glGetBufferParameteriv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetBufferPointerv (GLenum, GLenum, GLvoid* *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); -typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); -typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); -typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); -typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); -typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid* *params); -#endif - -#ifndef GL_VERSION_2_0 -#define GL_VERSION_2_0 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationSeparate (GLenum, GLenum); -GLAPI void APIENTRY glDrawBuffers (GLsizei, const GLenum *); -GLAPI void APIENTRY glStencilOpSeparate (GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glStencilFuncSeparate (GLenum, GLenum, GLint, GLuint); -GLAPI void APIENTRY glStencilMaskSeparate (GLenum, GLuint); -GLAPI void APIENTRY glAttachShader (GLuint, GLuint); -GLAPI void APIENTRY glBindAttribLocation (GLuint, GLuint, const GLchar *); -GLAPI void APIENTRY glCompileShader (GLuint); -GLAPI GLuint APIENTRY glCreateProgram (void); -GLAPI GLuint APIENTRY glCreateShader (GLenum); -GLAPI void APIENTRY glDeleteProgram (GLuint); -GLAPI void APIENTRY glDeleteShader (GLuint); -GLAPI void APIENTRY glDetachShader (GLuint, GLuint); -GLAPI void APIENTRY glDisableVertexAttribArray (GLuint); -GLAPI void APIENTRY glEnableVertexAttribArray (GLuint); -GLAPI void APIENTRY glGetActiveAttrib (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); -GLAPI void APIENTRY glGetActiveUniform (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); -GLAPI void APIENTRY glGetAttachedShaders (GLuint, GLsizei, GLsizei *, GLuint *); -GLAPI GLint APIENTRY glGetAttribLocation (GLuint, const GLchar *); -GLAPI void APIENTRY glGetProgramiv (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetProgramInfoLog (GLuint, GLsizei, GLsizei *, GLchar *); -GLAPI void APIENTRY glGetShaderiv (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetShaderInfoLog (GLuint, GLsizei, GLsizei *, GLchar *); -GLAPI void APIENTRY glGetShaderSource (GLuint, GLsizei, GLsizei *, GLchar *); -GLAPI GLint APIENTRY glGetUniformLocation (GLuint, const GLchar *); -GLAPI void APIENTRY glGetUniformfv (GLuint, GLint, GLfloat *); -GLAPI void APIENTRY glGetUniformiv (GLuint, GLint, GLint *); -GLAPI void APIENTRY glGetVertexAttribdv (GLuint, GLenum, GLdouble *); -GLAPI void APIENTRY glGetVertexAttribfv (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVertexAttribiv (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint, GLenum, GLvoid* *); -GLAPI GLboolean APIENTRY glIsProgram (GLuint); -GLAPI GLboolean APIENTRY glIsShader (GLuint); -GLAPI void APIENTRY glLinkProgram (GLuint); -GLAPI void APIENTRY glShaderSource (GLuint, GLsizei, const GLchar* *, const GLint *); -GLAPI void APIENTRY glUseProgram (GLuint); -GLAPI void APIENTRY glUniform1f (GLint, GLfloat); -GLAPI void APIENTRY glUniform2f (GLint, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform3f (GLint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform4f (GLint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform1i (GLint, GLint); -GLAPI void APIENTRY glUniform2i (GLint, GLint, GLint); -GLAPI void APIENTRY glUniform3i (GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glUniform4i (GLint, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glUniform1fv (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform2fv (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform3fv (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform4fv (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform1iv (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform2iv (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform3iv (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform4iv (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniformMatrix2fv (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix3fv (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix4fv (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glValidateProgram (GLuint); -GLAPI void APIENTRY glVertexAttrib1d (GLuint, GLdouble); -GLAPI void APIENTRY glVertexAttrib1dv (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib1f (GLuint, GLfloat); -GLAPI void APIENTRY glVertexAttrib1fv (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib1s (GLuint, GLshort); -GLAPI void APIENTRY glVertexAttrib1sv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib2d (GLuint, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib2dv (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib2f (GLuint, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib2fv (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib2s (GLuint, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib2sv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib3d (GLuint, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib3dv (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib3f (GLuint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib3fv (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib3s (GLuint, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib3sv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint, const GLbyte *); -GLAPI void APIENTRY glVertexAttrib4Niv (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4Nub (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); -GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint, const GLushort *); -GLAPI void APIENTRY glVertexAttrib4bv (GLuint, const GLbyte *); -GLAPI void APIENTRY glVertexAttrib4d (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib4dv (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib4f (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib4fv (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib4iv (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttrib4s (GLuint, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib4sv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4ubv (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttrib4uiv (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttrib4usv (GLuint, const GLushort *); -GLAPI void APIENTRY glVertexAttribPointer (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); -typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); -typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); -typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); -typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); -typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); -typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); -typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); -typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); -typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); -typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); -typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); -typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); -typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); -typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); -typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_VERSION_2_1 -#define GL_VERSION_2_1 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUniformMatrix2x3fv (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix3x2fv (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix2x4fv (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix4x2fv (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix3x4fv (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix4x3fv (GLint, GLsizei, GLboolean, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -#endif - -#ifndef GL_VERSION_3_0 -#define GL_VERSION_3_0 1 -/* OpenGL 3.0 also reuses entry points from these extensions: */ -/* ARB_framebuffer_object */ -/* ARB_map_buffer_range */ -/* ARB_vertex_array_object */ -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorMaski (GLuint, GLboolean, GLboolean, GLboolean, GLboolean); -GLAPI void APIENTRY glGetBooleani_v (GLenum, GLuint, GLboolean *); -GLAPI void APIENTRY glGetIntegeri_v (GLenum, GLuint, GLint *); -GLAPI void APIENTRY glEnablei (GLenum, GLuint); -GLAPI void APIENTRY glDisablei (GLenum, GLuint); -GLAPI GLboolean APIENTRY glIsEnabledi (GLenum, GLuint); -GLAPI void APIENTRY glBeginTransformFeedback (GLenum); -GLAPI void APIENTRY glEndTransformFeedback (void); -GLAPI void APIENTRY glBindBufferRange (GLenum, GLuint, GLuint, GLintptr, GLsizeiptr); -GLAPI void APIENTRY glBindBufferBase (GLenum, GLuint, GLuint); -GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint, GLsizei, const GLchar* *, GLenum); -GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint, GLuint, GLsizei, GLsizei *, GLsizei *, GLenum *, GLchar *); -GLAPI void APIENTRY glClampColor (GLenum, GLenum); -GLAPI void APIENTRY glBeginConditionalRender (GLuint, GLenum); -GLAPI void APIENTRY glEndConditionalRender (void); -GLAPI void APIENTRY glVertexAttribIPointer (GLuint, GLint, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glGetVertexAttribIiv (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint, GLenum, GLuint *); -GLAPI void APIENTRY glVertexAttribI1i (GLuint, GLint); -GLAPI void APIENTRY glVertexAttribI2i (GLuint, GLint, GLint); -GLAPI void APIENTRY glVertexAttribI3i (GLuint, GLint, GLint, GLint); -GLAPI void APIENTRY glVertexAttribI4i (GLuint, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glVertexAttribI1ui (GLuint, GLuint); -GLAPI void APIENTRY glVertexAttribI2ui (GLuint, GLuint, GLuint); -GLAPI void APIENTRY glVertexAttribI3ui (GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glVertexAttribI4ui (GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glVertexAttribI1iv (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttribI2iv (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttribI3iv (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttribI4iv (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttribI1uiv (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttribI2uiv (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttribI3uiv (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttribI4uiv (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttribI4bv (GLuint, const GLbyte *); -GLAPI void APIENTRY glVertexAttribI4sv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttribI4ubv (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttribI4usv (GLuint, const GLushort *); -GLAPI void APIENTRY glGetUniformuiv (GLuint, GLint, GLuint *); -GLAPI void APIENTRY glBindFragDataLocation (GLuint, GLuint, const GLchar *); -GLAPI GLint APIENTRY glGetFragDataLocation (GLuint, const GLchar *); -GLAPI void APIENTRY glUniform1ui (GLint, GLuint); -GLAPI void APIENTRY glUniform2ui (GLint, GLuint, GLuint); -GLAPI void APIENTRY glUniform3ui (GLint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glUniform4ui (GLint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glUniform1uiv (GLint, GLsizei, const GLuint *); -GLAPI void APIENTRY glUniform2uiv (GLint, GLsizei, const GLuint *); -GLAPI void APIENTRY glUniform3uiv (GLint, GLsizei, const GLuint *); -GLAPI void APIENTRY glUniform4uiv (GLint, GLsizei, const GLuint *); -GLAPI void APIENTRY glTexParameterIiv (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glTexParameterIuiv (GLenum, GLenum, const GLuint *); -GLAPI void APIENTRY glGetTexParameterIiv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetTexParameterIuiv (GLenum, GLenum, GLuint *); -GLAPI void APIENTRY glClearBufferiv (GLenum, GLint, const GLint *); -GLAPI void APIENTRY glClearBufferuiv (GLenum, GLint, const GLuint *); -GLAPI void APIENTRY glClearBufferfv (GLenum, GLint, const GLfloat *); -GLAPI void APIENTRY glClearBufferfi (GLenum, GLint, GLfloat, GLint); -GLAPI const GLubyte * APIENTRY glGetStringi (GLenum, GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); -typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); -typedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index); -typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); -typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); -typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); -typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); -typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void); -typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); -typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); -typedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); -typedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); -typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); -typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); -typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); -typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); -#endif - -#ifndef GL_VERSION_3_1 -#define GL_VERSION_3_1 1 -/* OpenGL 3.1 also reuses entry points from these extensions: */ -/* ARB_copy_buffer */ -/* ARB_uniform_buffer_object */ -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstanced (GLenum, GLint, GLsizei, GLsizei); -GLAPI void APIENTRY glDrawElementsInstanced (GLenum, GLsizei, GLenum, const GLvoid *, GLsizei); -GLAPI void APIENTRY glTexBuffer (GLenum, GLenum, GLuint); -GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); -typedef void (APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalformat, GLuint buffer); -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index); -#endif - -#ifndef GL_VERSION_3_2 -#define GL_VERSION_3_2 1 -/* OpenGL 3.2 also reuses entry points from these extensions: */ -/* ARB_draw_elements_base_vertex */ -/* ARB_provoking_vertex */ -/* ARB_sync */ -/* ARB_texture_multisample */ -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetInteger64i_v (GLenum, GLuint, GLint64 *); -GLAPI void APIENTRY glGetBufferParameteri64v (GLenum, GLenum, GLint64 *); -GLAPI void APIENTRY glProgramParameteri (GLuint, GLenum, GLint); -GLAPI void APIENTRY glFramebufferTexture (GLenum, GLenum, GLuint, GLint); -GLAPI void APIENTRY glFramebufferTextureFace (GLenum, GLenum, GLuint, GLint, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -#endif - -#ifndef GL_ARB_multitexture -#define GL_ARB_multitexture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveTextureARB (GLenum); -GLAPI void APIENTRY glClientActiveTextureARB (GLenum); -GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum, GLdouble); -GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum, GLfloat); -GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum, GLint); -GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum, GLshort); -GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum, GLint, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum, const GLshort *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); -#endif - -#ifndef GL_ARB_transpose_matrix -#define GL_ARB_transpose_matrix 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *); -GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *); -GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *); -GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); -#endif - -#ifndef GL_ARB_multisample -#define GL_ARB_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleCoverageARB (GLclampf, GLboolean); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert); -#endif - -#ifndef GL_ARB_texture_env_add -#define GL_ARB_texture_env_add 1 -#endif - -#ifndef GL_ARB_texture_cube_map -#define GL_ARB_texture_cube_map 1 -#endif - -#ifndef GL_ARB_texture_compression -#define GL_ARB_texture_compression 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum, GLint, GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, GLvoid *img); -#endif - -#ifndef GL_ARB_texture_border_clamp -#define GL_ARB_texture_border_clamp 1 -#endif - -#ifndef GL_ARB_point_parameters -#define GL_ARB_point_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfARB (GLenum, GLfloat); -GLAPI void APIENTRY glPointParameterfvARB (GLenum, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_ARB_vertex_blend -#define GL_ARB_vertex_blend 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWeightbvARB (GLint, const GLbyte *); -GLAPI void APIENTRY glWeightsvARB (GLint, const GLshort *); -GLAPI void APIENTRY glWeightivARB (GLint, const GLint *); -GLAPI void APIENTRY glWeightfvARB (GLint, const GLfloat *); -GLAPI void APIENTRY glWeightdvARB (GLint, const GLdouble *); -GLAPI void APIENTRY glWeightubvARB (GLint, const GLubyte *); -GLAPI void APIENTRY glWeightusvARB (GLint, const GLushort *); -GLAPI void APIENTRY glWeightuivARB (GLint, const GLuint *); -GLAPI void APIENTRY glWeightPointerARB (GLint, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glVertexBlendARB (GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); -typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); -typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); -typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); -typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); -typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); -typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); -typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); -typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); -#endif - -#ifndef GL_ARB_matrix_palette -#define GL_ARB_matrix_palette 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint); -GLAPI void APIENTRY glMatrixIndexubvARB (GLint, const GLubyte *); -GLAPI void APIENTRY glMatrixIndexusvARB (GLint, const GLushort *); -GLAPI void APIENTRY glMatrixIndexuivARB (GLint, const GLuint *); -GLAPI void APIENTRY glMatrixIndexPointerARB (GLint, GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); -typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_ARB_texture_env_combine -#define GL_ARB_texture_env_combine 1 -#endif - -#ifndef GL_ARB_texture_env_crossbar -#define GL_ARB_texture_env_crossbar 1 -#endif - -#ifndef GL_ARB_texture_env_dot3 -#define GL_ARB_texture_env_dot3 1 -#endif - -#ifndef GL_ARB_texture_mirrored_repeat -#define GL_ARB_texture_mirrored_repeat 1 -#endif - -#ifndef GL_ARB_depth_texture -#define GL_ARB_depth_texture 1 -#endif - -#ifndef GL_ARB_shadow -#define GL_ARB_shadow 1 -#endif - -#ifndef GL_ARB_shadow_ambient -#define GL_ARB_shadow_ambient 1 -#endif - -#ifndef GL_ARB_window_pos -#define GL_ARB_window_pos 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWindowPos2dARB (GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *); -GLAPI void APIENTRY glWindowPos2fARB (GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *); -GLAPI void APIENTRY glWindowPos2iARB (GLint, GLint); -GLAPI void APIENTRY glWindowPos2ivARB (const GLint *); -GLAPI void APIENTRY glWindowPos2sARB (GLshort, GLshort); -GLAPI void APIENTRY glWindowPos2svARB (const GLshort *); -GLAPI void APIENTRY glWindowPos3dARB (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *); -GLAPI void APIENTRY glWindowPos3fARB (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *); -GLAPI void APIENTRY glWindowPos3iARB (GLint, GLint, GLint); -GLAPI void APIENTRY glWindowPos3ivARB (const GLint *); -GLAPI void APIENTRY glWindowPos3sARB (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glWindowPos3svARB (const GLshort *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); -#endif - -#ifndef GL_ARB_vertex_program -#define GL_ARB_vertex_program 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttrib1dARB (GLuint, GLdouble); -GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib1fARB (GLuint, GLfloat); -GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib1sARB (GLuint, GLshort); -GLAPI void APIENTRY glVertexAttrib1svARB (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib2dARB (GLuint, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib2fARB (GLuint, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib2sARB (GLuint, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib2svARB (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib3dARB (GLuint, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib3fARB (GLuint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib3sARB (GLuint, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib3svARB (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint, const GLbyte *); -GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); -GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint, const GLushort *); -GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint, const GLbyte *); -GLAPI void APIENTRY glVertexAttrib4dARB (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib4fARB (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttrib4sARB (GLuint, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib4svARB (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint, const GLushort *); -GLAPI void APIENTRY glVertexAttribPointerARB (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); -GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint); -GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint); -GLAPI void APIENTRY glProgramStringARB (GLenum, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glBindProgramARB (GLenum, GLuint); -GLAPI void APIENTRY glDeleteProgramsARB (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenProgramsARB (GLsizei, GLuint *); -GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum, GLuint, const GLdouble *); -GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum, GLuint, const GLfloat *); -GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum, GLuint, const GLdouble *); -GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum, GLuint, const GLfloat *); -GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum, GLuint, GLdouble *); -GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum, GLuint, GLfloat *); -GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum, GLuint, GLdouble *); -GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum, GLuint, GLfloat *); -GLAPI void APIENTRY glGetProgramivARB (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetProgramStringARB (GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint, GLenum, GLdouble *); -GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVertexAttribivARB (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint, GLenum, GLvoid* *); -GLAPI GLboolean APIENTRY glIsProgramARB (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string); -typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); -typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); -#endif - -#ifndef GL_ARB_fragment_program -#define GL_ARB_fragment_program 1 -/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */ -#endif - -#ifndef GL_ARB_vertex_buffer_object -#define GL_ARB_vertex_buffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindBufferARB (GLenum, GLuint); -GLAPI void APIENTRY glDeleteBuffersARB (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenBuffersARB (GLsizei, GLuint *); -GLAPI GLboolean APIENTRY glIsBufferARB (GLuint); -GLAPI void APIENTRY glBufferDataARB (GLenum, GLsizeiptrARB, const GLvoid *, GLenum); -GLAPI void APIENTRY glBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, const GLvoid *); -GLAPI void APIENTRY glGetBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, GLvoid *); -GLAPI GLvoid* APIENTRY glMapBufferARB (GLenum, GLenum); -GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum); -GLAPI void APIENTRY glGetBufferParameterivARB (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetBufferPointervARB (GLenum, GLenum, GLvoid* *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); -typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); -typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); -typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); -typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); -typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params); -#endif - -#ifndef GL_ARB_occlusion_query -#define GL_ARB_occlusion_query 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenQueriesARB (GLsizei, GLuint *); -GLAPI void APIENTRY glDeleteQueriesARB (GLsizei, const GLuint *); -GLAPI GLboolean APIENTRY glIsQueryARB (GLuint); -GLAPI void APIENTRY glBeginQueryARB (GLenum, GLuint); -GLAPI void APIENTRY glEndQueryARB (GLenum); -GLAPI void APIENTRY glGetQueryivARB (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetQueryObjectivARB (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint, GLenum, GLuint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); -#endif - -#ifndef GL_ARB_shader_objects -#define GL_ARB_shader_objects 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB); -GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum); -GLAPI void APIENTRY glDetachObjectARB (GLhandleARB, GLhandleARB); -GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum); -GLAPI void APIENTRY glShaderSourceARB (GLhandleARB, GLsizei, const GLcharARB* *, const GLint *); -GLAPI void APIENTRY glCompileShaderARB (GLhandleARB); -GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); -GLAPI void APIENTRY glAttachObjectARB (GLhandleARB, GLhandleARB); -GLAPI void APIENTRY glLinkProgramARB (GLhandleARB); -GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB); -GLAPI void APIENTRY glValidateProgramARB (GLhandleARB); -GLAPI void APIENTRY glUniform1fARB (GLint, GLfloat); -GLAPI void APIENTRY glUniform2fARB (GLint, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform3fARB (GLint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform4fARB (GLint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform1iARB (GLint, GLint); -GLAPI void APIENTRY glUniform2iARB (GLint, GLint, GLint); -GLAPI void APIENTRY glUniform3iARB (GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glUniform4iARB (GLint, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glUniform1fvARB (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform2fvARB (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform3fvARB (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform4fvARB (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform1ivARB (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform2ivARB (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform3ivARB (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform4ivARB (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniformMatrix2fvARB (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix3fvARB (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix4fvARB (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB, GLenum, GLfloat *); -GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB, GLenum, GLint *); -GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *); -GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB, GLsizei, GLsizei *, GLhandleARB *); -GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB, const GLcharARB *); -GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); -GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB, GLint, GLfloat *); -GLAPI void APIENTRY glGetUniformivARB (GLhandleARB, GLint, GLint *); -GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); -typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); -typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); -typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); -typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); -typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); -typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); -typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); -typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); -typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); -typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); -typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); -typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); -typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); -#endif - -#ifndef GL_ARB_vertex_shader -#define GL_ARB_vertex_shader 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB, GLuint, const GLcharARB *); -GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); -GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB, const GLcharARB *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); -typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); -#endif - -#ifndef GL_ARB_fragment_shader -#define GL_ARB_fragment_shader 1 -#endif - -#ifndef GL_ARB_shading_language_100 -#define GL_ARB_shading_language_100 1 -#endif - -#ifndef GL_ARB_texture_non_power_of_two -#define GL_ARB_texture_non_power_of_two 1 -#endif - -#ifndef GL_ARB_point_sprite -#define GL_ARB_point_sprite 1 -#endif - -#ifndef GL_ARB_fragment_program_shadow -#define GL_ARB_fragment_program_shadow 1 -#endif - -#ifndef GL_ARB_draw_buffers -#define GL_ARB_draw_buffers 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawBuffersARB (GLsizei, const GLenum *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); -#endif - -#ifndef GL_ARB_texture_rectangle -#define GL_ARB_texture_rectangle 1 -#endif - -#ifndef GL_ARB_color_buffer_float -#define GL_ARB_color_buffer_float 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glClampColorARB (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); -#endif - -#ifndef GL_ARB_half_float_pixel -#define GL_ARB_half_float_pixel 1 -#endif - -#ifndef GL_ARB_texture_float -#define GL_ARB_texture_float 1 -#endif - -#ifndef GL_ARB_pixel_buffer_object -#define GL_ARB_pixel_buffer_object 1 -#endif - -#ifndef GL_ARB_depth_buffer_float -#define GL_ARB_depth_buffer_float 1 -#endif - -#ifndef GL_ARB_draw_instanced -#define GL_ARB_draw_instanced 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstancedARB (GLenum, GLint, GLsizei, GLsizei); -GLAPI void APIENTRY glDrawElementsInstancedARB (GLenum, GLsizei, GLenum, const GLvoid *, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); -#endif - -#ifndef GL_ARB_framebuffer_object -#define GL_ARB_framebuffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint); -GLAPI void APIENTRY glBindRenderbuffer (GLenum, GLuint); -GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenRenderbuffers (GLsizei, GLuint *); -GLAPI void APIENTRY glRenderbufferStorage (GLenum, GLenum, GLsizei, GLsizei); -GLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum, GLenum, GLint *); -GLAPI GLboolean APIENTRY glIsFramebuffer (GLuint); -GLAPI void APIENTRY glBindFramebuffer (GLenum, GLuint); -GLAPI void APIENTRY glDeleteFramebuffers (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenFramebuffers (GLsizei, GLuint *); -GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum); -GLAPI void APIENTRY glFramebufferTexture1D (GLenum, GLenum, GLenum, GLuint, GLint); -GLAPI void APIENTRY glFramebufferTexture2D (GLenum, GLenum, GLenum, GLuint, GLint); -GLAPI void APIENTRY glFramebufferTexture3D (GLenum, GLenum, GLenum, GLuint, GLint, GLint); -GLAPI void APIENTRY glFramebufferRenderbuffer (GLenum, GLenum, GLenum, GLuint); -GLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGenerateMipmap (GLenum); -GLAPI void APIENTRY glBlitFramebuffer (GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum); -GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum, GLsizei, GLenum, GLsizei, GLsizei); -GLAPI void APIENTRY glFramebufferTextureLayer (GLenum, GLenum, GLuint, GLint, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); -typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); -typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); -typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); -typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); -typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); -typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -#endif - -#ifndef GL_ARB_framebuffer_sRGB -#define GL_ARB_framebuffer_sRGB 1 -#endif - -#ifndef GL_ARB_geometry_shader4 -#define GL_ARB_geometry_shader4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramParameteriARB (GLuint, GLenum, GLint); -GLAPI void APIENTRY glFramebufferTextureARB (GLenum, GLenum, GLuint, GLint); -GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum, GLenum, GLuint, GLint, GLint); -GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum, GLenum, GLuint, GLint, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -#endif - -#ifndef GL_ARB_half_float_vertex -#define GL_ARB_half_float_vertex 1 -#endif - -#ifndef GL_ARB_instanced_arrays -#define GL_ARB_instanced_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribDivisorARB (GLuint, GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); -#endif - -#ifndef GL_ARB_map_buffer_range -#define GL_ARB_map_buffer_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLvoid* APIENTRY glMapBufferRange (GLenum, GLintptr, GLsizeiptr, GLbitfield); -GLAPI void APIENTRY glFlushMappedBufferRange (GLenum, GLintptr, GLsizeiptr); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); -typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); -#endif - -#ifndef GL_ARB_texture_buffer_object -#define GL_ARB_texture_buffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexBufferARB (GLenum, GLenum, GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer); -#endif - -#ifndef GL_ARB_texture_compression_rgtc -#define GL_ARB_texture_compression_rgtc 1 -#endif - -#ifndef GL_ARB_texture_rg -#define GL_ARB_texture_rg 1 -#endif - -#ifndef GL_ARB_vertex_array_object -#define GL_ARB_vertex_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindVertexArray (GLuint); -GLAPI void APIENTRY glDeleteVertexArrays (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenVertexArrays (GLsizei, GLuint *); -GLAPI GLboolean APIENTRY glIsVertexArray (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); -typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); -typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); -typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); -#endif - -#ifndef GL_ARB_uniform_buffer_object -#define GL_ARB_uniform_buffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetUniformIndices (GLuint, GLsizei, const GLchar* *, GLuint *); -GLAPI void APIENTRY glGetActiveUniformsiv (GLuint, GLsizei, const GLuint *, GLenum, GLint *); -GLAPI void APIENTRY glGetActiveUniformName (GLuint, GLuint, GLsizei, GLsizei *, GLchar *); -GLAPI GLuint APIENTRY glGetUniformBlockIndex (GLuint, const GLchar *); -GLAPI void APIENTRY glGetActiveUniformBlockiv (GLuint, GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetActiveUniformBlockName (GLuint, GLuint, GLsizei, GLsizei *, GLchar *); -GLAPI void APIENTRY glUniformBlockBinding (GLuint, GLuint, GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar* *uniformNames, GLuint *uniformIndices); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); -typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); -typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); -#endif - -#ifndef GL_ARB_compatibility -#define GL_ARB_compatibility 1 -#endif - -#ifndef GL_ARB_copy_buffer -#define GL_ARB_copy_buffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCopyBufferSubData (GLenum, GLenum, GLintptr, GLintptr, GLsizeiptr); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -#endif - -#ifndef GL_ARB_shader_texture_lod -#define GL_ARB_shader_texture_lod 1 -#endif - -#ifndef GL_ARB_depth_clamp -#define GL_ARB_depth_clamp 1 -#endif - -#ifndef GL_ARB_draw_elements_base_vertex -#define GL_ARB_draw_elements_base_vertex 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum, GLsizei, GLenum, const GLvoid *, GLint); -GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *, GLint); -GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum, GLsizei, GLenum, const GLvoid *, GLsizei, GLint); -GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei, const GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount, GLint basevertex); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount, const GLint *basevertex); -#endif - -#ifndef GL_ARB_fragment_coord_conventions -#define GL_ARB_fragment_coord_conventions 1 -#endif - -#ifndef GL_ARB_provoking_vertex -#define GL_ARB_provoking_vertex 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProvokingVertex (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode); -#endif - -#ifndef GL_ARB_seamless_cube_map -#define GL_ARB_seamless_cube_map 1 -#endif - -#ifndef GL_ARB_sync -#define GL_ARB_sync 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLsync APIENTRY glFenceSync (GLenum, GLbitfield); -GLAPI GLboolean APIENTRY glIsSync (GLsync); -GLAPI void APIENTRY glDeleteSync (GLsync); -GLAPI GLenum APIENTRY glClientWaitSync (GLsync, GLbitfield, GLuint64); -GLAPI void APIENTRY glWaitSync (GLsync, GLbitfield, GLuint64); -GLAPI void APIENTRY glGetInteger64v (GLenum, GLint64 *); -GLAPI void APIENTRY glGetSynciv (GLsync, GLenum, GLsizei, GLsizei *, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); -typedef GLboolean (APIENTRYP PFNGLISSYNCPROC) (GLsync sync); -typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); -typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); -typedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); -typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *params); -typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -#endif - -#ifndef GL_ARB_texture_multisample -#define GL_ARB_texture_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage2DMultisample (GLenum, GLsizei, GLint, GLsizei, GLsizei, GLboolean); -GLAPI void APIENTRY glTexImage3DMultisample (GLenum, GLsizei, GLint, GLsizei, GLsizei, GLsizei, GLboolean); -GLAPI void APIENTRY glGetMultisamplefv (GLenum, GLuint, GLfloat *); -GLAPI void APIENTRY glSampleMaski (GLuint, GLbitfield); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val); -typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint index, GLbitfield mask); -#endif - -#ifndef GL_ARB_vertex_array_bgra -#define GL_ARB_vertex_array_bgra 1 -#endif - -#ifndef GL_ARB_draw_buffers_blend -#define GL_ARB_draw_buffers_blend 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationi (GLuint, GLenum); -GLAPI void APIENTRY glBlendEquationSeparatei (GLuint, GLenum, GLenum); -GLAPI void APIENTRY glBlendFunci (GLuint, GLenum, GLenum); -GLAPI void APIENTRY glBlendFuncSeparatei (GLuint, GLenum, GLenum, GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode); -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -typedef void (APIENTRYP PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst); -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -#endif - -#ifndef GL_ARB_sample_shading -#define GL_ARB_sample_shading 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMinSampleShading (GLclampf); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC) (GLclampf value); -#endif - -#ifndef GL_ARB_texture_cube_map_array -#define GL_ARB_texture_cube_map_array 1 -#endif - -#ifndef GL_ARB_texture_gather -#define GL_ARB_texture_gather 1 -#endif - -#ifndef GL_ARB_texture_query_lod -#define GL_ARB_texture_query_lod 1 -#endif - -#ifndef GL_EXT_abgr -#define GL_EXT_abgr 1 -#endif - -#ifndef GL_EXT_blend_color -#define GL_EXT_blend_color 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendColorEXT (GLclampf, GLclampf, GLclampf, GLclampf); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -#endif - -#ifndef GL_EXT_polygon_offset -#define GL_EXT_polygon_offset 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat, GLfloat); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); -#endif - -#ifndef GL_EXT_texture -#define GL_EXT_texture 1 -#endif - -#ifndef GL_EXT_texture3D -#define GL_EXT_texture3D 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage3DEXT (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -#endif - -#ifndef GL_SGIS_texture_filter4 -#define GL_SGIS_texture_filter4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum, GLenum, GLsizei, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); -typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); -#endif - -#ifndef GL_EXT_subtexture -#define GL_EXT_subtexture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexSubImage1DEXT (GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -#endif - -#ifndef GL_EXT_copy_texture -#define GL_EXT_copy_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint); -GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint); -GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei); -GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); -GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif - -#ifndef GL_EXT_histogram -#define GL_EXT_histogram 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetHistogramEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetMinmaxEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glHistogramEXT (GLenum, GLsizei, GLenum, GLboolean); -GLAPI void APIENTRY glMinmaxEXT (GLenum, GLenum, GLboolean); -GLAPI void APIENTRY glResetHistogramEXT (GLenum); -GLAPI void APIENTRY glResetMinmaxEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); -typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); -#endif - -#ifndef GL_EXT_convolution -#define GL_EXT_convolution 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum, GLenum, GLint); -GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum, GLenum, GLint, GLint, GLsizei); -GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); -GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); -GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); -#endif - -#ifndef GL_SGI_color_matrix -#define GL_SGI_color_matrix 1 -#endif - -#ifndef GL_SGI_color_table -#define GL_SGI_color_table 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorTableSGI (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glColorTableParameterivSGI (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glCopyColorTableSGI (GLenum, GLenum, GLint, GLint, GLsizei); -GLAPI void APIENTRY glGetColorTableSGI (GLenum, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum, GLenum, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); -#endif - -#ifndef GL_SGIX_pixel_texture -#define GL_SGIX_pixel_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTexGenSGIX (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); -#endif - -#ifndef GL_SGIS_pixel_texture -#define GL_SGIS_pixel_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum, GLint); -GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum, const GLint *); -GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum, GLfloat); -GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum, const GLfloat *); -GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum, GLint *); -GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); -#endif - -#ifndef GL_SGIS_texture4D -#define GL_SGIS_texture4D 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage4DSGIS (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); -#endif - -#ifndef GL_SGI_texture_color_table -#define GL_SGI_texture_color_table 1 -#endif - -#ifndef GL_EXT_cmyka -#define GL_EXT_cmyka 1 -#endif - -#ifndef GL_EXT_texture_object -#define GL_EXT_texture_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei, const GLuint *, GLboolean *); -GLAPI void APIENTRY glBindTextureEXT (GLenum, GLuint); -GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenTexturesEXT (GLsizei, GLuint *); -GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint); -GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei, const GLuint *, const GLclampf *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); -typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); -typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); -typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); -typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); -typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); -#endif - -#ifndef GL_SGIS_detail_texture -#define GL_SGIS_detail_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum, GLsizei, const GLfloat *); -GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); -#endif - -#ifndef GL_SGIS_sharpen_texture -#define GL_SGIS_sharpen_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum, GLsizei, const GLfloat *); -GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); -#endif - -#ifndef GL_EXT_packed_pixels -#define GL_EXT_packed_pixels 1 -#endif - -#ifndef GL_SGIS_texture_lod -#define GL_SGIS_texture_lod 1 -#endif - -#ifndef GL_SGIS_multisample -#define GL_SGIS_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleMaskSGIS (GLclampf, GLboolean); -GLAPI void APIENTRY glSamplePatternSGIS (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); -#endif - -#ifndef GL_EXT_rescale_normal -#define GL_EXT_rescale_normal 1 -#endif - -#ifndef GL_EXT_vertex_array -#define GL_EXT_vertex_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glArrayElementEXT (GLint); -GLAPI void APIENTRY glColorPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); -GLAPI void APIENTRY glDrawArraysEXT (GLenum, GLint, GLsizei); -GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei, GLsizei, const GLboolean *); -GLAPI void APIENTRY glGetPointervEXT (GLenum, GLvoid* *); -GLAPI void APIENTRY glIndexPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); -GLAPI void APIENTRY glNormalPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); -GLAPI void APIENTRY glTexCoordPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); -GLAPI void APIENTRY glVertexPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); -typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); -typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params); -typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -#endif - -#ifndef GL_EXT_misc_attribute -#define GL_EXT_misc_attribute 1 -#endif - -#ifndef GL_SGIS_generate_mipmap -#define GL_SGIS_generate_mipmap 1 -#endif - -#ifndef GL_SGIX_clipmap -#define GL_SGIX_clipmap 1 -#endif - -#ifndef GL_SGIX_shadow -#define GL_SGIX_shadow 1 -#endif - -#ifndef GL_SGIS_texture_edge_clamp -#define GL_SGIS_texture_edge_clamp 1 -#endif - -#ifndef GL_SGIS_texture_border_clamp -#define GL_SGIS_texture_border_clamp 1 -#endif - -#ifndef GL_EXT_blend_minmax -#define GL_EXT_blend_minmax 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); -#endif - -#ifndef GL_EXT_blend_subtract -#define GL_EXT_blend_subtract 1 -#endif - -#ifndef GL_EXT_blend_logic_op -#define GL_EXT_blend_logic_op 1 -#endif - -#ifndef GL_SGIX_interlace -#define GL_SGIX_interlace 1 -#endif - -#ifndef GL_SGIX_pixel_tiles -#define GL_SGIX_pixel_tiles 1 -#endif - -#ifndef GL_SGIX_texture_select -#define GL_SGIX_texture_select 1 -#endif - -#ifndef GL_SGIX_sprite -#define GL_SGIX_sprite 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum, GLfloat); -GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum, const GLfloat *); -GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum, GLint); -GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum, const GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); -#endif - -#ifndef GL_SGIX_texture_multi_buffer -#define GL_SGIX_texture_multi_buffer 1 -#endif - -#ifndef GL_EXT_point_parameters -#define GL_EXT_point_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfEXT (GLenum, GLfloat); -GLAPI void APIENTRY glPointParameterfvEXT (GLenum, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_SGIS_point_parameters -#define GL_SGIS_point_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfSGIS (GLenum, GLfloat); -GLAPI void APIENTRY glPointParameterfvSGIS (GLenum, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_SGIX_instruments -#define GL_SGIX_instruments 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); -GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei, GLint *); -GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *); -GLAPI void APIENTRY glReadInstrumentsSGIX (GLint); -GLAPI void APIENTRY glStartInstrumentsSGIX (void); -GLAPI void APIENTRY glStopInstrumentsSGIX (GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); -typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); -typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); -typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); -typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); -typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); -#endif - -#ifndef GL_SGIX_texture_scale_bias -#define GL_SGIX_texture_scale_bias 1 -#endif - -#ifndef GL_SGIX_framezoom -#define GL_SGIX_framezoom 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFrameZoomSGIX (GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); -#endif - -#ifndef GL_SGIX_tag_sample_buffer -#define GL_SGIX_tag_sample_buffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTagSampleBufferSGIX (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); -#endif - -#ifndef GL_SGIX_polynomial_ffd -#define GL_SGIX_polynomial_ffd 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble *); -GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat *); -GLAPI void APIENTRY glDeformSGIX (GLbitfield); -GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); -typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); -typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); -typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); -#endif - -#ifndef GL_SGIX_reference_plane -#define GL_SGIX_reference_plane 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); -#endif - -#ifndef GL_SGIX_flush_raster -#define GL_SGIX_flush_raster 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFlushRasterSGIX (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); -#endif - -#ifndef GL_SGIX_depth_texture -#define GL_SGIX_depth_texture 1 -#endif - -#ifndef GL_SGIS_fog_function -#define GL_SGIS_fog_function 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFogFuncSGIS (GLsizei, const GLfloat *); -GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); -#endif - -#ifndef GL_SGIX_fog_offset -#define GL_SGIX_fog_offset 1 -#endif - -#ifndef GL_HP_image_transform -#define GL_HP_image_transform 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glImageTransformParameteriHP (GLenum, GLenum, GLint); -GLAPI void APIENTRY glImageTransformParameterfHP (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glImageTransformParameterivHP (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum, GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); -#endif - -#ifndef GL_HP_convolution_border_modes -#define GL_HP_convolution_border_modes 1 -#endif - -#ifndef GL_SGIX_texture_add_env -#define GL_SGIX_texture_add_env 1 -#endif - -#ifndef GL_EXT_color_subtable -#define GL_EXT_color_subtable 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorSubTableEXT (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum, GLsizei, GLint, GLint, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -#endif - -#ifndef GL_PGI_vertex_hints -#define GL_PGI_vertex_hints 1 -#endif - -#ifndef GL_PGI_misc_hints -#define GL_PGI_misc_hints 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glHintPGI (GLenum, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); -#endif - -#ifndef GL_EXT_paletted_texture -#define GL_EXT_paletted_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorTableEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glGetColorTableEXT (GLenum, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum, GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -#endif - -#ifndef GL_EXT_clip_volume_hint -#define GL_EXT_clip_volume_hint 1 -#endif - -#ifndef GL_SGIX_list_priority -#define GL_SGIX_list_priority 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetListParameterivSGIX (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glListParameterfSGIX (GLuint, GLenum, GLfloat); -GLAPI void APIENTRY glListParameterfvSGIX (GLuint, GLenum, const GLfloat *); -GLAPI void APIENTRY glListParameteriSGIX (GLuint, GLenum, GLint); -GLAPI void APIENTRY glListParameterivSGIX (GLuint, GLenum, const GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); -#endif - -#ifndef GL_SGIX_ir_instrument1 -#define GL_SGIX_ir_instrument1 1 -#endif - -#ifndef GL_SGIX_calligraphic_fragment -#define GL_SGIX_calligraphic_fragment 1 -#endif - -#ifndef GL_SGIX_texture_lod_bias -#define GL_SGIX_texture_lod_bias 1 -#endif - -#ifndef GL_SGIX_shadow_ambient -#define GL_SGIX_shadow_ambient 1 -#endif - -#ifndef GL_EXT_index_texture -#define GL_EXT_index_texture 1 -#endif - -#ifndef GL_EXT_index_material -#define GL_EXT_index_material 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIndexMaterialEXT (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); -#endif - -#ifndef GL_EXT_index_func -#define GL_EXT_index_func 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIndexFuncEXT (GLenum, GLclampf); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); -#endif - -#ifndef GL_EXT_index_array_formats -#define GL_EXT_index_array_formats 1 -#endif - -#ifndef GL_EXT_compiled_vertex_array -#define GL_EXT_compiled_vertex_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glLockArraysEXT (GLint, GLsizei); -GLAPI void APIENTRY glUnlockArraysEXT (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); -#endif - -#ifndef GL_EXT_cull_vertex -#define GL_EXT_cull_vertex 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCullParameterdvEXT (GLenum, GLdouble *); -GLAPI void APIENTRY glCullParameterfvEXT (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); -#endif - -#ifndef GL_SGIX_ycrcb -#define GL_SGIX_ycrcb 1 -#endif - -#ifndef GL_SGIX_fragment_lighting -#define GL_SGIX_fragment_lighting 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum, GLenum); -GLAPI void APIENTRY glFragmentLightfSGIX (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glFragmentLightiSGIX (GLenum, GLenum, GLint); -GLAPI void APIENTRY glFragmentLightivSGIX (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum, GLfloat); -GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum, const GLfloat *); -GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum, GLint); -GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum, const GLint *); -GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum, GLenum, GLint); -GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glLightEnviSGIX (GLenum, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); -#endif - -#ifndef GL_IBM_rasterpos_clip -#define GL_IBM_rasterpos_clip 1 -#endif - -#ifndef GL_HP_texture_lighting -#define GL_HP_texture_lighting 1 -#endif - -#ifndef GL_EXT_draw_range_elements -#define GL_EXT_draw_range_elements 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -#endif - -#ifndef GL_WIN_phong_shading -#define GL_WIN_phong_shading 1 -#endif - -#ifndef GL_WIN_specular_fog -#define GL_WIN_specular_fog 1 -#endif - -#ifndef GL_EXT_light_texture -#define GL_EXT_light_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glApplyTextureEXT (GLenum); -GLAPI void APIENTRY glTextureLightEXT (GLenum); -GLAPI void APIENTRY glTextureMaterialEXT (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); -typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); -#endif - -#ifndef GL_SGIX_blend_alpha_minmax -#define GL_SGIX_blend_alpha_minmax 1 -#endif - -#ifndef GL_EXT_bgra -#define GL_EXT_bgra 1 -#endif - -#ifndef GL_SGIX_async -#define GL_SGIX_async 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint); -GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *); -GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *); -GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei); -GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint, GLsizei); -GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); -typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); -typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); -typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); -typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); -typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); -#endif - -#ifndef GL_SGIX_async_pixel -#define GL_SGIX_async_pixel 1 -#endif - -#ifndef GL_SGIX_async_histogram -#define GL_SGIX_async_histogram 1 -#endif - -#ifndef GL_INTEL_parallel_arrays -#define GL_INTEL_parallel_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexPointervINTEL (GLint, GLenum, const GLvoid* *); -GLAPI void APIENTRY glNormalPointervINTEL (GLenum, const GLvoid* *); -GLAPI void APIENTRY glColorPointervINTEL (GLint, GLenum, const GLvoid* *); -GLAPI void APIENTRY glTexCoordPointervINTEL (GLint, GLenum, const GLvoid* *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); -typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid* *pointer); -typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); -#endif - -#ifndef GL_HP_occlusion_test -#define GL_HP_occlusion_test 1 -#endif - -#ifndef GL_EXT_pixel_transform -#define GL_EXT_pixel_transform 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum, GLenum, GLint); -GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum, GLenum, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_EXT_pixel_transform_color_table -#define GL_EXT_pixel_transform_color_table 1 -#endif - -#ifndef GL_EXT_shared_texture_palette -#define GL_EXT_shared_texture_palette 1 -#endif - -#ifndef GL_EXT_separate_specular_color -#define GL_EXT_separate_specular_color 1 -#endif - -#ifndef GL_EXT_secondary_color -#define GL_EXT_secondary_color 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte, GLbyte, GLbyte); -GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *); -GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *); -GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *); -GLAPI void APIENTRY glSecondaryColor3iEXT (GLint, GLint, GLint); -GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *); -GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *); -GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte, GLubyte, GLubyte); -GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *); -GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint, GLuint, GLuint); -GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *); -GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort, GLushort, GLushort); -GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *); -GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint, GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_EXT_texture_perturb_normal -#define GL_EXT_texture_perturb_normal 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureNormalEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); -#endif - -#ifndef GL_EXT_multi_draw_arrays -#define GL_EXT_multi_draw_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei); -GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); -#endif - -#ifndef GL_EXT_fog_coord -#define GL_EXT_fog_coord 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFogCoordfEXT (GLfloat); -GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *); -GLAPI void APIENTRY glFogCoorddEXT (GLdouble); -GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *); -GLAPI void APIENTRY glFogCoordPointerEXT (GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); -typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); -typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); -typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_REND_screen_coordinates -#define GL_REND_screen_coordinates 1 -#endif - -#ifndef GL_EXT_coordinate_frame -#define GL_EXT_coordinate_frame 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTangent3bEXT (GLbyte, GLbyte, GLbyte); -GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *); -GLAPI void APIENTRY glTangent3dEXT (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *); -GLAPI void APIENTRY glTangent3fEXT (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *); -GLAPI void APIENTRY glTangent3iEXT (GLint, GLint, GLint); -GLAPI void APIENTRY glTangent3ivEXT (const GLint *); -GLAPI void APIENTRY glTangent3sEXT (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glTangent3svEXT (const GLshort *); -GLAPI void APIENTRY glBinormal3bEXT (GLbyte, GLbyte, GLbyte); -GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *); -GLAPI void APIENTRY glBinormal3dEXT (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *); -GLAPI void APIENTRY glBinormal3fEXT (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *); -GLAPI void APIENTRY glBinormal3iEXT (GLint, GLint, GLint); -GLAPI void APIENTRY glBinormal3ivEXT (const GLint *); -GLAPI void APIENTRY glBinormal3sEXT (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glBinormal3svEXT (const GLshort *); -GLAPI void APIENTRY glTangentPointerEXT (GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glBinormalPointerEXT (GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); -typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); -typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); -typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); -typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); -typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); -typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); -typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); -typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); -typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); -typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_EXT_texture_env_combine -#define GL_EXT_texture_env_combine 1 -#endif - -#ifndef GL_APPLE_specular_vector -#define GL_APPLE_specular_vector 1 -#endif - -#ifndef GL_APPLE_transform_hint -#define GL_APPLE_transform_hint 1 -#endif - -#ifndef GL_SGIX_fog_scale -#define GL_SGIX_fog_scale 1 -#endif - -#ifndef GL_SUNX_constant_data -#define GL_SUNX_constant_data 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFinishTextureSUNX (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); -#endif - -#ifndef GL_SUN_global_alpha -#define GL_SUN_global_alpha 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte); -GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort); -GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint); -GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat); -GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble); -GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte); -GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort); -GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); -#endif - -#ifndef GL_SUN_triangle_list -#define GL_SUN_triangle_list 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint); -GLAPI void APIENTRY glReplacementCodeusSUN (GLushort); -GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte); -GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *); -GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *); -GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *); -GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum, GLsizei, const GLvoid* *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const GLvoid* *pointer); -#endif - -#ifndef GL_SUN_vertex -#define GL_SUN_vertex 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat); -GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *, const GLfloat *); -GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *, const GLfloat *); -GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat, GLfloat, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *, const GLubyte *, const GLfloat *); -GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *, const GLubyte *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -#endif - -#ifndef GL_EXT_blend_func_separate -#define GL_EXT_blend_func_separate 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum, GLenum, GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#endif - -#ifndef GL_INGR_blend_func_separate -#define GL_INGR_blend_func_separate 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum, GLenum, GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#endif - -#ifndef GL_INGR_color_clamp -#define GL_INGR_color_clamp 1 -#endif - -#ifndef GL_INGR_interlace_read -#define GL_INGR_interlace_read 1 -#endif - -#ifndef GL_EXT_stencil_wrap -#define GL_EXT_stencil_wrap 1 -#endif - -#ifndef GL_EXT_422_pixels -#define GL_EXT_422_pixels 1 -#endif - -#ifndef GL_NV_texgen_reflection -#define GL_NV_texgen_reflection 1 -#endif - -#ifndef GL_SUN_convolution_border_modes -#define GL_SUN_convolution_border_modes 1 -#endif - -#ifndef GL_EXT_texture_env_add -#define GL_EXT_texture_env_add 1 -#endif - -#ifndef GL_EXT_texture_lod_bias -#define GL_EXT_texture_lod_bias 1 -#endif - -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_EXT_texture_filter_anisotropic 1 -#endif - -#ifndef GL_EXT_vertex_weighting -#define GL_EXT_vertex_weighting 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexWeightfEXT (GLfloat); -GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *); -GLAPI void APIENTRY glVertexWeightPointerEXT (GLsizei, GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_NV_light_max_exponent -#define GL_NV_light_max_exponent 1 -#endif - -#ifndef GL_NV_vertex_array_range -#define GL_NV_vertex_array_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); -GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); -typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const GLvoid *pointer); -#endif - -#ifndef GL_NV_register_combiners -#define GL_NV_register_combiners 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCombinerParameterfvNV (GLenum, const GLfloat *); -GLAPI void APIENTRY glCombinerParameterfNV (GLenum, GLfloat); -GLAPI void APIENTRY glCombinerParameterivNV (GLenum, const GLint *); -GLAPI void APIENTRY glCombinerParameteriNV (GLenum, GLint); -GLAPI void APIENTRY glCombinerInputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glCombinerOutputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLboolean, GLboolean, GLboolean); -GLAPI void APIENTRY glFinalCombinerInputNV (GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum, GLenum, GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum, GLenum, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum, GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum, GLenum, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); -typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); -#endif - -#ifndef GL_NV_fog_distance -#define GL_NV_fog_distance 1 -#endif - -#ifndef GL_NV_texgen_emboss -#define GL_NV_texgen_emboss 1 -#endif - -#ifndef GL_NV_blend_square -#define GL_NV_blend_square 1 -#endif - -#ifndef GL_NV_texture_env_combine4 -#define GL_NV_texture_env_combine4 1 -#endif - -#ifndef GL_MESA_resize_buffers -#define GL_MESA_resize_buffers 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glResizeBuffersMESA (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); -#endif - -#ifndef GL_MESA_window_pos -#define GL_MESA_window_pos 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWindowPos2dMESA (GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *); -GLAPI void APIENTRY glWindowPos2fMESA (GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *); -GLAPI void APIENTRY glWindowPos2iMESA (GLint, GLint); -GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *); -GLAPI void APIENTRY glWindowPos2sMESA (GLshort, GLshort); -GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *); -GLAPI void APIENTRY glWindowPos3dMESA (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *); -GLAPI void APIENTRY glWindowPos3fMESA (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *); -GLAPI void APIENTRY glWindowPos3iMESA (GLint, GLint, GLint); -GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *); -GLAPI void APIENTRY glWindowPos3sMESA (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *); -GLAPI void APIENTRY glWindowPos4dMESA (GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *); -GLAPI void APIENTRY glWindowPos4fMESA (GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *); -GLAPI void APIENTRY glWindowPos4iMESA (GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *); -GLAPI void APIENTRY glWindowPos4sMESA (GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); -#endif - -#ifndef GL_IBM_cull_vertex -#define GL_IBM_cull_vertex 1 -#endif - -#ifndef GL_IBM_multimode_draw_arrays -#define GL_IBM_multimode_draw_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *, const GLint *, const GLsizei *, GLsizei, GLint); -GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *, const GLsizei *, GLenum, const GLvoid* const *, GLsizei, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); -typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride); -#endif - -#ifndef GL_IBM_vertex_array_lists -#define GL_IBM_vertex_array_lists 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint, const GLboolean* *, GLint); -GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glIndexPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glNormalPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glTexCoordPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glVertexPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -#endif - -#ifndef GL_SGIX_subsample -#define GL_SGIX_subsample 1 -#endif - -#ifndef GL_SGIX_ycrcba -#define GL_SGIX_ycrcba 1 -#endif - -#ifndef GL_SGIX_ycrcb_subsample -#define GL_SGIX_ycrcb_subsample 1 -#endif - -#ifndef GL_SGIX_depth_pass_instrument -#define GL_SGIX_depth_pass_instrument 1 -#endif - -#ifndef GL_3DFX_texture_compression_FXT1 -#define GL_3DFX_texture_compression_FXT1 1 -#endif - -#ifndef GL_3DFX_multisample -#define GL_3DFX_multisample 1 -#endif - -#ifndef GL_3DFX_tbuffer -#define GL_3DFX_tbuffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTbufferMask3DFX (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); -#endif - -#ifndef GL_EXT_multisample -#define GL_EXT_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleMaskEXT (GLclampf, GLboolean); -GLAPI void APIENTRY glSamplePatternEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); -#endif - -#ifndef GL_SGIX_vertex_preclip -#define GL_SGIX_vertex_preclip 1 -#endif - -#ifndef GL_SGIX_convolution_accuracy -#define GL_SGIX_convolution_accuracy 1 -#endif - -#ifndef GL_SGIX_resample -#define GL_SGIX_resample 1 -#endif - -#ifndef GL_SGIS_point_line_texgen -#define GL_SGIS_point_line_texgen 1 -#endif - -#ifndef GL_SGIS_texture_color_mask -#define GL_SGIS_texture_color_mask 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean, GLboolean, GLboolean, GLboolean); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -#endif - -#ifndef GL_SGIX_igloo_interface -#define GL_SGIX_igloo_interface 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const GLvoid *params); -#endif - -#ifndef GL_EXT_texture_env_dot3 -#define GL_EXT_texture_env_dot3 1 -#endif - -#ifndef GL_ATI_texture_mirror_once -#define GL_ATI_texture_mirror_once 1 -#endif - -#ifndef GL_NV_fence -#define GL_NV_fence 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeleteFencesNV (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenFencesNV (GLsizei, GLuint *); -GLAPI GLboolean APIENTRY glIsFenceNV (GLuint); -GLAPI GLboolean APIENTRY glTestFenceNV (GLuint); -GLAPI void APIENTRY glGetFenceivNV (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glFinishFenceNV (GLuint); -GLAPI void APIENTRY glSetFenceNV (GLuint, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); -typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); -typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); -#endif - -#ifndef GL_NV_evaluators -#define GL_NV_evaluators 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLint, GLint, GLboolean, const GLvoid *); -GLAPI void APIENTRY glMapParameterivNV (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glMapParameterfvNV (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glGetMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLboolean, GLvoid *); -GLAPI void APIENTRY glGetMapParameterivNV (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetMapParameterfvNV (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum, GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum, GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glEvalMapsNV (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); -typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); -typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); -#endif - -#ifndef GL_NV_packed_depth_stencil -#define GL_NV_packed_depth_stencil 1 -#endif - -#ifndef GL_NV_register_combiners2 -#define GL_NV_register_combiners2 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum, GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); -#endif - -#ifndef GL_NV_texture_compression_vtc -#define GL_NV_texture_compression_vtc 1 -#endif - -#ifndef GL_NV_texture_rectangle -#define GL_NV_texture_rectangle 1 -#endif - -#ifndef GL_NV_texture_shader -#define GL_NV_texture_shader 1 -#endif - -#ifndef GL_NV_texture_shader2 -#define GL_NV_texture_shader2 1 -#endif - -#ifndef GL_NV_vertex_array_range2 -#define GL_NV_vertex_array_range2 1 -#endif - -#ifndef GL_NV_vertex_program -#define GL_NV_vertex_program 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei, const GLuint *, GLboolean *); -GLAPI void APIENTRY glBindProgramNV (GLenum, GLuint); -GLAPI void APIENTRY glDeleteProgramsNV (GLsizei, const GLuint *); -GLAPI void APIENTRY glExecuteProgramNV (GLenum, GLuint, const GLfloat *); -GLAPI void APIENTRY glGenProgramsNV (GLsizei, GLuint *); -GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum, GLuint, GLenum, GLdouble *); -GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum, GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetProgramivNV (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetProgramStringNV (GLuint, GLenum, GLubyte *); -GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum, GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint, GLenum, GLdouble *); -GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVertexAttribivNV (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint, GLenum, GLvoid* *); -GLAPI GLboolean APIENTRY glIsProgramNV (GLuint); -GLAPI void APIENTRY glLoadProgramNV (GLenum, GLuint, GLsizei, const GLubyte *); -GLAPI void APIENTRY glProgramParameter4dNV (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glProgramParameter4dvNV (GLenum, GLuint, const GLdouble *); -GLAPI void APIENTRY glProgramParameter4fNV (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glProgramParameter4fvNV (GLenum, GLuint, const GLfloat *); -GLAPI void APIENTRY glProgramParameters4dvNV (GLenum, GLuint, GLuint, const GLdouble *); -GLAPI void APIENTRY glProgramParameters4fvNV (GLenum, GLuint, GLuint, const GLfloat *); -GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei, const GLuint *); -GLAPI void APIENTRY glTrackMatrixNV (GLenum, GLuint, GLenum, GLenum); -GLAPI void APIENTRY glVertexAttribPointerNV (GLuint, GLint, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glVertexAttrib1dNV (GLuint, GLdouble); -GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib1fNV (GLuint, GLfloat); -GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib1sNV (GLuint, GLshort); -GLAPI void APIENTRY glVertexAttrib1svNV (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib2dNV (GLuint, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib2fNV (GLuint, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib2sNV (GLuint, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib2svNV (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib3dNV (GLuint, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib3fNV (GLuint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib3sNV (GLuint, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib3svNV (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4dNV (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib4fNV (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib4sNV (GLuint, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib4svNV (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); -GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint, GLsizei, const GLdouble *); -GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glVertexAttribs1svNV (GLuint, GLsizei, const GLshort *); -GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint, GLsizei, const GLdouble *); -GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glVertexAttribs2svNV (GLuint, GLsizei, const GLshort *); -GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint, GLsizei, const GLdouble *); -GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glVertexAttribs3svNV (GLuint, GLsizei, const GLshort *); -GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint, GLsizei, const GLdouble *); -GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glVertexAttribs4svNV (GLuint, GLsizei, const GLshort *); -GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint, GLsizei, const GLubyte *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); -typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); -typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); -typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); -typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLuint count, const GLdouble *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLuint count, const GLfloat *v); -typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); -#endif - -#ifndef GL_SGIX_texture_coordinate_clamp -#define GL_SGIX_texture_coordinate_clamp 1 -#endif - -#ifndef GL_SGIX_scalebias_hint -#define GL_SGIX_scalebias_hint 1 -#endif - -#ifndef GL_OML_interlace -#define GL_OML_interlace 1 -#endif - -#ifndef GL_OML_subsample -#define GL_OML_subsample 1 -#endif - -#ifndef GL_OML_resample -#define GL_OML_resample 1 -#endif - -#ifndef GL_NV_copy_depth_to_color -#define GL_NV_copy_depth_to_color 1 -#endif - -#ifndef GL_ATI_envmap_bumpmap -#define GL_ATI_envmap_bumpmap 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexBumpParameterivATI (GLenum, const GLint *); -GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum, GLint *); -GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); -typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); -typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); -typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); -#endif - -#ifndef GL_ATI_fragment_shader -#define GL_ATI_fragment_shader 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint); -GLAPI void APIENTRY glBindFragmentShaderATI (GLuint); -GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint); -GLAPI void APIENTRY glBeginFragmentShaderATI (void); -GLAPI void APIENTRY glEndFragmentShaderATI (void); -GLAPI void APIENTRY glPassTexCoordATI (GLuint, GLuint, GLenum); -GLAPI void APIENTRY glSampleMapATI (GLuint, GLuint, GLenum); -GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); -typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); -typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); -typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); -typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); -typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); -#endif - -#ifndef GL_ATI_pn_triangles -#define GL_ATI_pn_triangles 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPNTrianglesiATI (GLenum, GLint); -GLAPI void APIENTRY glPNTrianglesfATI (GLenum, GLfloat); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); -#endif - -#ifndef GL_ATI_vertex_array_object -#define GL_ATI_vertex_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei, const GLvoid *, GLenum); -GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint); -GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint, GLuint, GLsizei, const GLvoid *, GLenum); -GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetObjectBufferivATI (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glFreeObjectBufferATI (GLuint); -GLAPI void APIENTRY glArrayObjectATI (GLenum, GLint, GLenum, GLsizei, GLuint, GLuint); -GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetArrayObjectivATI (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glVariantArrayObjectATI (GLuint, GLenum, GLsizei, GLuint, GLuint); -GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint, GLenum, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const GLvoid *pointer, GLenum usage); -typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); -typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); -#endif - -#ifndef GL_EXT_vertex_shader -#define GL_EXT_vertex_shader 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginVertexShaderEXT (void); -GLAPI void APIENTRY glEndVertexShaderEXT (void); -GLAPI void APIENTRY glBindVertexShaderEXT (GLuint); -GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint); -GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint); -GLAPI void APIENTRY glShaderOp1EXT (GLenum, GLuint, GLuint); -GLAPI void APIENTRY glShaderOp2EXT (GLenum, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glShaderOp3EXT (GLenum, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glSwizzleEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glWriteMaskEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glInsertComponentEXT (GLuint, GLuint, GLuint); -GLAPI void APIENTRY glExtractComponentEXT (GLuint, GLuint, GLuint); -GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum, GLenum, GLenum, GLuint); -GLAPI void APIENTRY glSetInvariantEXT (GLuint, GLenum, const GLvoid *); -GLAPI void APIENTRY glSetLocalConstantEXT (GLuint, GLenum, const GLvoid *); -GLAPI void APIENTRY glVariantbvEXT (GLuint, const GLbyte *); -GLAPI void APIENTRY glVariantsvEXT (GLuint, const GLshort *); -GLAPI void APIENTRY glVariantivEXT (GLuint, const GLint *); -GLAPI void APIENTRY glVariantfvEXT (GLuint, const GLfloat *); -GLAPI void APIENTRY glVariantdvEXT (GLuint, const GLdouble *); -GLAPI void APIENTRY glVariantubvEXT (GLuint, const GLubyte *); -GLAPI void APIENTRY glVariantusvEXT (GLuint, const GLushort *); -GLAPI void APIENTRY glVariantuivEXT (GLuint, const GLuint *); -GLAPI void APIENTRY glVariantPointerEXT (GLuint, GLenum, GLuint, const GLvoid *); -GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint); -GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint); -GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum, GLenum); -GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum, GLenum); -GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum, GLenum, GLenum); -GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum, GLenum); -GLAPI GLuint APIENTRY glBindParameterEXT (GLenum); -GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint, GLenum); -GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint, GLenum, GLboolean *); -GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVariantPointervEXT (GLuint, GLenum, GLvoid* *); -GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint, GLenum, GLboolean *); -GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint, GLenum, GLboolean *); -GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint, GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); -typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); -typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); -typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); -typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); -typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); -typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); -typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); -typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); -typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); -typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); -typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); -typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); -typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); -typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); -typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); -typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); -typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); -typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); -typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); -typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); -typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); -typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); -typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); -typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); -typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); -typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid* *data); -typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -#endif - -#ifndef GL_ATI_vertex_streams -#define GL_ATI_vertex_streams 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexStream1sATI (GLenum, GLshort); -GLAPI void APIENTRY glVertexStream1svATI (GLenum, const GLshort *); -GLAPI void APIENTRY glVertexStream1iATI (GLenum, GLint); -GLAPI void APIENTRY glVertexStream1ivATI (GLenum, const GLint *); -GLAPI void APIENTRY glVertexStream1fATI (GLenum, GLfloat); -GLAPI void APIENTRY glVertexStream1fvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glVertexStream1dATI (GLenum, GLdouble); -GLAPI void APIENTRY glVertexStream1dvATI (GLenum, const GLdouble *); -GLAPI void APIENTRY glVertexStream2sATI (GLenum, GLshort, GLshort); -GLAPI void APIENTRY glVertexStream2svATI (GLenum, const GLshort *); -GLAPI void APIENTRY glVertexStream2iATI (GLenum, GLint, GLint); -GLAPI void APIENTRY glVertexStream2ivATI (GLenum, const GLint *); -GLAPI void APIENTRY glVertexStream2fATI (GLenum, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexStream2fvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glVertexStream2dATI (GLenum, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexStream2dvATI (GLenum, const GLdouble *); -GLAPI void APIENTRY glVertexStream3sATI (GLenum, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexStream3svATI (GLenum, const GLshort *); -GLAPI void APIENTRY glVertexStream3iATI (GLenum, GLint, GLint, GLint); -GLAPI void APIENTRY glVertexStream3ivATI (GLenum, const GLint *); -GLAPI void APIENTRY glVertexStream3fATI (GLenum, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexStream3fvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glVertexStream3dATI (GLenum, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexStream3dvATI (GLenum, const GLdouble *); -GLAPI void APIENTRY glVertexStream4sATI (GLenum, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexStream4svATI (GLenum, const GLshort *); -GLAPI void APIENTRY glVertexStream4iATI (GLenum, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glVertexStream4ivATI (GLenum, const GLint *); -GLAPI void APIENTRY glVertexStream4fATI (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexStream4fvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glVertexStream4dATI (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexStream4dvATI (GLenum, const GLdouble *); -GLAPI void APIENTRY glNormalStream3bATI (GLenum, GLbyte, GLbyte, GLbyte); -GLAPI void APIENTRY glNormalStream3bvATI (GLenum, const GLbyte *); -GLAPI void APIENTRY glNormalStream3sATI (GLenum, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glNormalStream3svATI (GLenum, const GLshort *); -GLAPI void APIENTRY glNormalStream3iATI (GLenum, GLint, GLint, GLint); -GLAPI void APIENTRY glNormalStream3ivATI (GLenum, const GLint *); -GLAPI void APIENTRY glNormalStream3fATI (GLenum, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glNormalStream3fvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glNormalStream3dATI (GLenum, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glNormalStream3dvATI (GLenum, const GLdouble *); -GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum); -GLAPI void APIENTRY glVertexBlendEnviATI (GLenum, GLint); -GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum, GLfloat); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); -typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); -#endif - -#ifndef GL_ATI_element_array -#define GL_ATI_element_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glElementPointerATI (GLenum, const GLvoid *); -GLAPI void APIENTRY glDrawElementArrayATI (GLenum, GLsizei); -GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum, GLuint, GLuint, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); -#endif - -#ifndef GL_SUN_mesh_array -#define GL_SUN_mesh_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum, GLint, GLsizei, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); -#endif - -#ifndef GL_SUN_slice_accum -#define GL_SUN_slice_accum 1 -#endif - -#ifndef GL_NV_multisample_filter_hint -#define GL_NV_multisample_filter_hint 1 -#endif - -#ifndef GL_NV_depth_clamp -#define GL_NV_depth_clamp 1 -#endif - -#ifndef GL_NV_occlusion_query -#define GL_NV_occlusion_query 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei, GLuint *); -GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei, const GLuint *); -GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint); -GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint); -GLAPI void APIENTRY glEndOcclusionQueryNV (void); -GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint, GLenum, GLuint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); -typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); -#endif - -#ifndef GL_NV_point_sprite -#define GL_NV_point_sprite 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameteriNV (GLenum, GLint); -GLAPI void APIENTRY glPointParameterivNV (GLenum, const GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); -#endif - -#ifndef GL_NV_texture_shader3 -#define GL_NV_texture_shader3 1 -#endif - -#ifndef GL_NV_vertex_program1_1 -#define GL_NV_vertex_program1_1 1 -#endif - -#ifndef GL_EXT_shadow_funcs -#define GL_EXT_shadow_funcs 1 -#endif - -#ifndef GL_EXT_stencil_two_side -#define GL_EXT_stencil_two_side 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); -#endif - -#ifndef GL_ATI_text_fragment_shader -#define GL_ATI_text_fragment_shader 1 -#endif - -#ifndef GL_APPLE_client_storage -#define GL_APPLE_client_storage 1 -#endif - -#ifndef GL_APPLE_element_array -#define GL_APPLE_element_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glElementPointerAPPLE (GLenum, const GLvoid *); -GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum, GLint, GLsizei); -GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, GLint, GLsizei); -GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum, const GLint *, const GLsizei *, GLsizei); -GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, const GLint *, const GLsizei *, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); -#endif - -#ifndef GL_APPLE_fence -#define GL_APPLE_fence 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenFencesAPPLE (GLsizei, GLuint *); -GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei, const GLuint *); -GLAPI void APIENTRY glSetFenceAPPLE (GLuint); -GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint); -GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint); -GLAPI void APIENTRY glFinishFenceAPPLE (GLuint); -GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum, GLuint); -GLAPI void APIENTRY glFinishObjectAPPLE (GLenum, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); -typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); -typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); -typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); -#endif - -#ifndef GL_APPLE_vertex_array_object -#define GL_APPLE_vertex_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint); -GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei, GLuint *); -GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); -typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); -typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays); -typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); -#endif - -#ifndef GL_APPLE_vertex_array_range -#define GL_APPLE_vertex_array_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei, GLvoid *); -GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei, GLvoid *); -GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); -typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); -#endif - -#ifndef GL_APPLE_ycbcr_422 -#define GL_APPLE_ycbcr_422 1 -#endif - -#ifndef GL_S3_s3tc -#define GL_S3_s3tc 1 -#endif - -#ifndef GL_ATI_draw_buffers -#define GL_ATI_draw_buffers 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawBuffersATI (GLsizei, const GLenum *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); -#endif - -#ifndef GL_ATI_pixel_format_float -#define GL_ATI_pixel_format_float 1 -/* This is really a WGL extension, but defines some associated GL enums. - * ATI does not export "GL_ATI_pixel_format_float" in the GL_EXTENSIONS string. - */ -#endif - -#ifndef GL_ATI_texture_env_combine3 -#define GL_ATI_texture_env_combine3 1 -#endif - -#ifndef GL_ATI_texture_float -#define GL_ATI_texture_float 1 -#endif - -#ifndef GL_NV_float_buffer -#define GL_NV_float_buffer 1 -#endif - -#ifndef GL_NV_fragment_program -#define GL_NV_fragment_program 1 -/* Some NV_fragment_program entry points are shared with ARB_vertex_program. */ -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint, GLsizei, const GLubyte *, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint, GLsizei, const GLubyte *, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint, GLsizei, const GLubyte *, const GLfloat *); -GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint, GLsizei, const GLubyte *, const GLdouble *); -GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint, GLsizei, const GLubyte *, GLfloat *); -GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint, GLsizei, const GLubyte *, GLdouble *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); -typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); -#endif - -#ifndef GL_NV_half_float -#define GL_NV_half_float 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertex2hNV (GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *); -GLAPI void APIENTRY glVertex3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *); -GLAPI void APIENTRY glVertex4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *); -GLAPI void APIENTRY glNormal3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *); -GLAPI void APIENTRY glColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *); -GLAPI void APIENTRY glColor4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *); -GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV); -GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *); -GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *); -GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *); -GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *); -GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum, GLhalfNV); -GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum, const GLhalfNV *); -GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum, const GLhalfNV *); -GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum, const GLhalfNV *); -GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum, const GLhalfNV *); -GLAPI void APIENTRY glFogCoordhNV (GLhalfNV); -GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *); -GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *); -GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV); -GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *); -GLAPI void APIENTRY glVertexAttrib1hNV (GLuint, GLhalfNV); -GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttrib2hNV (GLuint, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttrib3hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttrib4hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint, GLsizei, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint, GLsizei, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint, GLsizei, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint, GLsizei, const GLhalfNV *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); -typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); -typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); -typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); -typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); -typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); -typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); -typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); -typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -#endif - -#ifndef GL_NV_pixel_data_range -#define GL_NV_pixel_data_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelDataRangeNV (GLenum, GLsizei, GLvoid *); -GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, GLvoid *pointer); -typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); -#endif - -#ifndef GL_NV_primitive_restart -#define GL_NV_primitive_restart 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPrimitiveRestartNV (void); -GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); -#endif - -#ifndef GL_NV_texture_expand_normal -#define GL_NV_texture_expand_normal 1 -#endif - -#ifndef GL_NV_vertex_program2 -#define GL_NV_vertex_program2 1 -#endif - -#ifndef GL_ATI_map_object_buffer -#define GL_ATI_map_object_buffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLvoid* APIENTRY glMapObjectBufferATI (GLuint); -GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLvoid* (APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); -#endif - -#ifndef GL_ATI_separate_stencil -#define GL_ATI_separate_stencil 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStencilOpSeparateATI (GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum, GLenum, GLint, GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -#endif - -#ifndef GL_ATI_vertex_attrib_array_object -#define GL_ATI_vertex_attrib_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint, GLint, GLenum, GLboolean, GLsizei, GLuint, GLuint); -GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint, GLenum, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); -#endif - -#ifndef GL_OES_read_format -#define GL_OES_read_format 1 -#endif - -#ifndef GL_EXT_depth_bounds_test -#define GL_EXT_depth_bounds_test 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDepthBoundsEXT (GLclampd, GLclampd); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); -#endif - -#ifndef GL_EXT_texture_mirror_clamp -#define GL_EXT_texture_mirror_clamp 1 -#endif - -#ifndef GL_EXT_blend_equation_separate -#define GL_EXT_blend_equation_separate 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); -#endif - -#ifndef GL_MESA_pack_invert -#define GL_MESA_pack_invert 1 -#endif - -#ifndef GL_MESA_ycbcr_texture -#define GL_MESA_ycbcr_texture 1 -#endif - -#ifndef GL_EXT_pixel_buffer_object -#define GL_EXT_pixel_buffer_object 1 -#endif - -#ifndef GL_NV_fragment_program_option -#define GL_NV_fragment_program_option 1 -#endif - -#ifndef GL_NV_fragment_program2 -#define GL_NV_fragment_program2 1 -#endif - -#ifndef GL_NV_vertex_program2_option -#define GL_NV_vertex_program2_option 1 -#endif - -#ifndef GL_NV_vertex_program3 -#define GL_NV_vertex_program3 1 -#endif - -#ifndef GL_EXT_framebuffer_object -#define GL_EXT_framebuffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint); -GLAPI void APIENTRY glBindRenderbufferEXT (GLenum, GLuint); -GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei, GLuint *); -GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum, GLenum, GLsizei, GLsizei); -GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum, GLenum, GLint *); -GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint); -GLAPI void APIENTRY glBindFramebufferEXT (GLenum, GLuint); -GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei, GLuint *); -GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum); -GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum, GLenum, GLenum, GLuint, GLint); -GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum, GLenum, GLenum, GLuint, GLint); -GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum, GLenum, GLenum, GLuint, GLint, GLint); -GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum, GLenum, GLenum, GLuint); -GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGenerateMipmapEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); -typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); -typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); -typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); -typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); -typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); -#endif - -#ifndef GL_GREMEDY_string_marker -#define GL_GREMEDY_string_marker 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const GLvoid *string); -#endif - -#ifndef GL_EXT_packed_depth_stencil -#define GL_EXT_packed_depth_stencil 1 -#endif - -#ifndef GL_EXT_stencil_clear_tag -#define GL_EXT_stencil_clear_tag 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStencilClearTagEXT (GLsizei, GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSTENCILCLEARTAGEXTPROC) (GLsizei stencilTagBits, GLuint stencilClearTag); -#endif - -#ifndef GL_EXT_texture_sRGB -#define GL_EXT_texture_sRGB 1 -#endif - -#ifndef GL_EXT_framebuffer_blit -#define GL_EXT_framebuffer_blit 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlitFramebufferEXT (GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -#endif - -#ifndef GL_EXT_framebuffer_multisample -#define GL_EXT_framebuffer_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glRenderbufferStorageMultisampleEXT (GLenum, GLsizei, GLenum, GLsizei, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -#endif - -#ifndef GL_MESAX_texture_stack -#define GL_MESAX_texture_stack 1 -#endif - -#ifndef GL_EXT_timer_query -#define GL_EXT_timer_query 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint, GLenum, GLint64EXT *); -GLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint, GLenum, GLuint64EXT *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64EXT *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64EXT *params); -#endif - -#ifndef GL_EXT_gpu_program_parameters -#define GL_EXT_gpu_program_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramEnvParameters4fvEXT (GLenum, GLuint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glProgramLocalParameters4fvEXT (GLenum, GLuint, GLsizei, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); -#endif - -#ifndef GL_APPLE_flush_buffer_range -#define GL_APPLE_flush_buffer_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBufferParameteriAPPLE (GLenum, GLenum, GLint); -GLAPI void APIENTRY glFlushMappedBufferRangeAPPLE (GLenum, GLintptr, GLsizeiptr); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size); -#endif - -#ifndef GL_NV_gpu_program4 -#define GL_NV_gpu_program4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramLocalParameterI4iNV (GLenum, GLuint, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glProgramLocalParameterI4ivNV (GLenum, GLuint, const GLint *); -GLAPI void APIENTRY glProgramLocalParametersI4ivNV (GLenum, GLuint, GLsizei, const GLint *); -GLAPI void APIENTRY glProgramLocalParameterI4uiNV (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glProgramLocalParameterI4uivNV (GLenum, GLuint, const GLuint *); -GLAPI void APIENTRY glProgramLocalParametersI4uivNV (GLenum, GLuint, GLsizei, const GLuint *); -GLAPI void APIENTRY glProgramEnvParameterI4iNV (GLenum, GLuint, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glProgramEnvParameterI4ivNV (GLenum, GLuint, const GLint *); -GLAPI void APIENTRY glProgramEnvParametersI4ivNV (GLenum, GLuint, GLsizei, const GLint *); -GLAPI void APIENTRY glProgramEnvParameterI4uiNV (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glProgramEnvParameterI4uivNV (GLenum, GLuint, const GLuint *); -GLAPI void APIENTRY glProgramEnvParametersI4uivNV (GLenum, GLuint, GLsizei, const GLuint *); -GLAPI void APIENTRY glGetProgramLocalParameterIivNV (GLenum, GLuint, GLint *); -GLAPI void APIENTRY glGetProgramLocalParameterIuivNV (GLenum, GLuint, GLuint *); -GLAPI void APIENTRY glGetProgramEnvParameterIivNV (GLenum, GLuint, GLint *); -GLAPI void APIENTRY glGetProgramEnvParameterIuivNV (GLenum, GLuint, GLuint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); -#endif - -#ifndef GL_NV_geometry_program4 -#define GL_NV_geometry_program4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramVertexLimitNV (GLenum, GLint); -GLAPI void APIENTRY glFramebufferTextureEXT (GLenum, GLenum, GLuint, GLint); -GLAPI void APIENTRY glFramebufferTextureLayerEXT (GLenum, GLenum, GLuint, GLint, GLint); -GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum, GLenum, GLuint, GLint, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -#endif - -#ifndef GL_EXT_geometry_shader4 -#define GL_EXT_geometry_shader4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramParameteriEXT (GLuint, GLenum, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); -#endif - -#ifndef GL_NV_vertex_program4 -#define GL_NV_vertex_program4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribI1iEXT (GLuint, GLint); -GLAPI void APIENTRY glVertexAttribI2iEXT (GLuint, GLint, GLint); -GLAPI void APIENTRY glVertexAttribI3iEXT (GLuint, GLint, GLint, GLint); -GLAPI void APIENTRY glVertexAttribI4iEXT (GLuint, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glVertexAttribI1uiEXT (GLuint, GLuint); -GLAPI void APIENTRY glVertexAttribI2uiEXT (GLuint, GLuint, GLuint); -GLAPI void APIENTRY glVertexAttribI3uiEXT (GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glVertexAttribI4uiEXT (GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glVertexAttribI1ivEXT (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttribI2ivEXT (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttribI3ivEXT (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttribI4ivEXT (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttribI1uivEXT (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttribI2uivEXT (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttribI3uivEXT (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttribI4uivEXT (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttribI4bvEXT (GLuint, const GLbyte *); -GLAPI void APIENTRY glVertexAttribI4svEXT (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttribI4ubvEXT (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttribI4usvEXT (GLuint, const GLushort *); -GLAPI void APIENTRY glVertexAttribIPointerEXT (GLuint, GLint, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glGetVertexAttribIivEXT (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVertexAttribIuivEXT (GLuint, GLenum, GLuint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); -#endif - -#ifndef GL_EXT_gpu_shader4 -#define GL_EXT_gpu_shader4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetUniformuivEXT (GLuint, GLint, GLuint *); -GLAPI void APIENTRY glBindFragDataLocationEXT (GLuint, GLuint, const GLchar *); -GLAPI GLint APIENTRY glGetFragDataLocationEXT (GLuint, const GLchar *); -GLAPI void APIENTRY glUniform1uiEXT (GLint, GLuint); -GLAPI void APIENTRY glUniform2uiEXT (GLint, GLuint, GLuint); -GLAPI void APIENTRY glUniform3uiEXT (GLint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glUniform4uiEXT (GLint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glUniform1uivEXT (GLint, GLsizei, const GLuint *); -GLAPI void APIENTRY glUniform2uivEXT (GLint, GLsizei, const GLuint *); -GLAPI void APIENTRY glUniform3uivEXT (GLint, GLsizei, const GLuint *); -GLAPI void APIENTRY glUniform4uivEXT (GLint, GLsizei, const GLuint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); -typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); -typedef void (APIENTRYP PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); -typedef void (APIENTRYP PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (APIENTRYP PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (APIENTRYP PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -#endif - -#ifndef GL_EXT_draw_instanced -#define GL_EXT_draw_instanced 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstancedEXT (GLenum, GLint, GLsizei, GLsizei); -GLAPI void APIENTRY glDrawElementsInstancedEXT (GLenum, GLsizei, GLenum, const GLvoid *, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); -#endif - -#ifndef GL_EXT_packed_float -#define GL_EXT_packed_float 1 -#endif - -#ifndef GL_EXT_texture_array -#define GL_EXT_texture_array 1 -#endif - -#ifndef GL_EXT_texture_buffer_object -#define GL_EXT_texture_buffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexBufferEXT (GLenum, GLenum, GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); -#endif - -#ifndef GL_EXT_texture_compression_latc -#define GL_EXT_texture_compression_latc 1 -#endif - -#ifndef GL_EXT_texture_compression_rgtc -#define GL_EXT_texture_compression_rgtc 1 -#endif - -#ifndef GL_EXT_texture_shared_exponent -#define GL_EXT_texture_shared_exponent 1 -#endif - -#ifndef GL_NV_depth_buffer_float -#define GL_NV_depth_buffer_float 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDepthRangedNV (GLdouble, GLdouble); -GLAPI void APIENTRY glClearDepthdNV (GLdouble); -GLAPI void APIENTRY glDepthBoundsdNV (GLdouble, GLdouble); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); -typedef void (APIENTRYP PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); -typedef void (APIENTRYP PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); -#endif - -#ifndef GL_NV_fragment_program4 -#define GL_NV_fragment_program4 1 -#endif - -#ifndef GL_NV_framebuffer_multisample_coverage -#define GL_NV_framebuffer_multisample_coverage 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum, GLsizei, GLsizei, GLenum, GLsizei, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); -#endif - -#ifndef GL_EXT_framebuffer_sRGB -#define GL_EXT_framebuffer_sRGB 1 -#endif - -#ifndef GL_NV_geometry_shader4 -#define GL_NV_geometry_shader4 1 -#endif - -#ifndef GL_NV_parameter_buffer_object -#define GL_NV_parameter_buffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramBufferParametersfvNV (GLenum, GLuint, GLuint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glProgramBufferParametersIivNV (GLenum, GLuint, GLuint, GLsizei, const GLint *); -GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum, GLuint, GLuint, GLsizei, const GLuint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params); -typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params); -#endif - -#ifndef GL_EXT_draw_buffers2 -#define GL_EXT_draw_buffers2 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorMaskIndexedEXT (GLuint, GLboolean, GLboolean, GLboolean, GLboolean); -GLAPI void APIENTRY glGetBooleanIndexedvEXT (GLenum, GLuint, GLboolean *); -GLAPI void APIENTRY glGetIntegerIndexedvEXT (GLenum, GLuint, GLint *); -GLAPI void APIENTRY glEnableIndexedEXT (GLenum, GLuint); -GLAPI void APIENTRY glDisableIndexedEXT (GLenum, GLuint); -GLAPI GLboolean APIENTRY glIsEnabledIndexedEXT (GLenum, GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -typedef void (APIENTRYP PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data); -typedef void (APIENTRYP PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data); -typedef void (APIENTRYP PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); -typedef GLboolean (APIENTRYP PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); -#endif - -#ifndef GL_NV_transform_feedback -#define GL_NV_transform_feedback 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginTransformFeedbackNV (GLenum); -GLAPI void APIENTRY glEndTransformFeedbackNV (void); -GLAPI void APIENTRY glTransformFeedbackAttribsNV (GLuint, const GLint *, GLenum); -GLAPI void APIENTRY glBindBufferRangeNV (GLenum, GLuint, GLuint, GLintptr, GLsizeiptr); -GLAPI void APIENTRY glBindBufferOffsetNV (GLenum, GLuint, GLuint, GLintptr); -GLAPI void APIENTRY glBindBufferBaseNV (GLenum, GLuint, GLuint); -GLAPI void APIENTRY glTransformFeedbackVaryingsNV (GLuint, GLsizei, const GLchar* *, GLenum); -GLAPI void APIENTRY glActiveVaryingNV (GLuint, const GLchar *); -GLAPI GLint APIENTRY glGetVaryingLocationNV (GLuint, const GLchar *); -GLAPI void APIENTRY glGetActiveVaryingNV (GLuint, GLuint, GLsizei, GLsizei *, GLsizei *, GLenum *, GLchar *); -GLAPI void APIENTRY glGetTransformFeedbackVaryingNV (GLuint, GLuint, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); -typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, const GLint *attribs, GLenum bufferMode); -typedef void (APIENTRYP PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -typedef void (APIENTRYP PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); -typedef void (APIENTRYP PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); -#endif - -#ifndef GL_EXT_bindable_uniform -#define GL_EXT_bindable_uniform 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUniformBufferEXT (GLuint, GLint, GLuint); -GLAPI GLint APIENTRY glGetUniformBufferSizeEXT (GLuint, GLint); -GLAPI GLintptr APIENTRY glGetUniformOffsetEXT (GLuint, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); -typedef GLint (APIENTRYP PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); -typedef GLintptr (APIENTRYP PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); -#endif - -#ifndef GL_EXT_texture_integer -#define GL_EXT_texture_integer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexParameterIivEXT (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glTexParameterIuivEXT (GLenum, GLenum, const GLuint *); -GLAPI void APIENTRY glGetTexParameterIivEXT (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetTexParameterIuivEXT (GLenum, GLenum, GLuint *); -GLAPI void APIENTRY glClearColorIiEXT (GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glClearColorIuiEXT (GLuint, GLuint, GLuint, GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); -typedef void (APIENTRYP PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); -#endif - -#ifndef GL_GREMEDY_frame_terminator -#define GL_GREMEDY_frame_terminator 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFrameTerminatorGREMEDY (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void); -#endif - -#ifndef GL_NV_conditional_render -#define GL_NV_conditional_render 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginConditionalRenderNV (GLuint, GLenum); -GLAPI void APIENTRY glEndConditionalRenderNV (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); -typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void); -#endif - -#ifndef GL_NV_present_video -#define GL_NV_present_video 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPresentFrameKeyedNV (GLuint, GLuint64EXT, GLuint, GLuint, GLenum, GLenum, GLuint, GLuint, GLenum, GLuint, GLuint); -GLAPI void APIENTRY glPresentFrameDualFillNV (GLuint, GLuint64EXT, GLuint, GLuint, GLenum, GLenum, GLuint, GLenum, GLuint, GLenum, GLuint, GLenum, GLuint); -GLAPI void APIENTRY glGetVideoivNV (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVideouivNV (GLuint, GLenum, GLuint *); -GLAPI void APIENTRY glGetVideoi64vNV (GLuint, GLenum, GLint64EXT *); -GLAPI void APIENTRY glGetVideoui64vNV (GLuint, GLenum, GLuint64EXT *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); -typedef void (APIENTRYP PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); -typedef void (APIENTRYP PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT *params); -typedef void (APIENTRYP PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT *params); -#endif - -#ifndef GL_EXT_transform_feedback -#define GL_EXT_transform_feedback 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginTransformFeedbackEXT (GLenum); -GLAPI void APIENTRY glEndTransformFeedbackEXT (void); -GLAPI void APIENTRY glBindBufferRangeEXT (GLenum, GLuint, GLuint, GLintptr, GLsizeiptr); -GLAPI void APIENTRY glBindBufferOffsetEXT (GLenum, GLuint, GLuint, GLintptr); -GLAPI void APIENTRY glBindBufferBaseEXT (GLenum, GLuint, GLuint); -GLAPI void APIENTRY glTransformFeedbackVaryingsEXT (GLuint, GLsizei, const GLchar* *, GLenum); -GLAPI void APIENTRY glGetTransformFeedbackVaryingEXT (GLuint, GLuint, GLsizei, GLsizei *, GLsizei *, GLenum *, GLchar *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode); -typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void); -typedef void (APIENTRYP PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -typedef void (APIENTRYP PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -#endif - -#ifndef GL_EXT_direct_state_access -#define GL_EXT_direct_state_access 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glClientAttribDefaultEXT (GLbitfield); -GLAPI void APIENTRY glPushClientAttribDefaultEXT (GLbitfield); -GLAPI void APIENTRY glMatrixLoadfEXT (GLenum, const GLfloat *); -GLAPI void APIENTRY glMatrixLoaddEXT (GLenum, const GLdouble *); -GLAPI void APIENTRY glMatrixMultfEXT (GLenum, const GLfloat *); -GLAPI void APIENTRY glMatrixMultdEXT (GLenum, const GLdouble *); -GLAPI void APIENTRY glMatrixLoadIdentityEXT (GLenum); -GLAPI void APIENTRY glMatrixRotatefEXT (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glMatrixRotatedEXT (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMatrixScalefEXT (GLenum, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glMatrixScaledEXT (GLenum, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMatrixTranslatefEXT (GLenum, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glMatrixTranslatedEXT (GLenum, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMatrixFrustumEXT (GLenum, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMatrixOrthoEXT (GLenum, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMatrixPopEXT (GLenum); -GLAPI void APIENTRY glMatrixPushEXT (GLenum); -GLAPI void APIENTRY glMatrixLoadTransposefEXT (GLenum, const GLfloat *); -GLAPI void APIENTRY glMatrixLoadTransposedEXT (GLenum, const GLdouble *); -GLAPI void APIENTRY glMatrixMultTransposefEXT (GLenum, const GLfloat *); -GLAPI void APIENTRY glMatrixMultTransposedEXT (GLenum, const GLdouble *); -GLAPI void APIENTRY glTextureParameterfEXT (GLuint, GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glTextureParameterfvEXT (GLuint, GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glTextureParameteriEXT (GLuint, GLenum, GLenum, GLint); -GLAPI void APIENTRY glTextureParameterivEXT (GLuint, GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glTextureImage1DEXT (GLuint, GLenum, GLint, GLenum, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glTextureImage2DEXT (GLuint, GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glTextureSubImage1DEXT (GLuint, GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glTextureSubImage2DEXT (GLuint, GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glCopyTextureImage1DEXT (GLuint, GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint); -GLAPI void APIENTRY glCopyTextureImage2DEXT (GLuint, GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint); -GLAPI void APIENTRY glCopyTextureSubImage1DEXT (GLuint, GLenum, GLint, GLint, GLint, GLint, GLsizei); -GLAPI void APIENTRY glCopyTextureSubImage2DEXT (GLuint, GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); -GLAPI void APIENTRY glGetTextureImageEXT (GLuint, GLenum, GLint, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetTextureParameterfvEXT (GLuint, GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetTextureParameterivEXT (GLuint, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetTextureLevelParameterfvEXT (GLuint, GLenum, GLint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetTextureLevelParameterivEXT (GLuint, GLenum, GLint, GLenum, GLint *); -GLAPI void APIENTRY glTextureImage3DEXT (GLuint, GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glTextureSubImage3DEXT (GLuint, GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glCopyTextureSubImage3DEXT (GLuint, GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); -GLAPI void APIENTRY glMultiTexParameterfEXT (GLenum, GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glMultiTexParameterfvEXT (GLenum, GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexParameteriEXT (GLenum, GLenum, GLenum, GLint); -GLAPI void APIENTRY glMultiTexParameterivEXT (GLenum, GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexImage1DEXT (GLenum, GLenum, GLint, GLenum, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glMultiTexImage2DEXT (GLenum, GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glMultiTexSubImage1DEXT (GLenum, GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glMultiTexSubImage2DEXT (GLenum, GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glCopyMultiTexImage1DEXT (GLenum, GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint); -GLAPI void APIENTRY glCopyMultiTexImage2DEXT (GLenum, GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint); -GLAPI void APIENTRY glCopyMultiTexSubImage1DEXT (GLenum, GLenum, GLint, GLint, GLint, GLint, GLsizei); -GLAPI void APIENTRY glCopyMultiTexSubImage2DEXT (GLenum, GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); -GLAPI void APIENTRY glGetMultiTexImageEXT (GLenum, GLenum, GLint, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetMultiTexParameterfvEXT (GLenum, GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetMultiTexParameterivEXT (GLenum, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetMultiTexLevelParameterfvEXT (GLenum, GLenum, GLint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetMultiTexLevelParameterivEXT (GLenum, GLenum, GLint, GLenum, GLint *); -GLAPI void APIENTRY glMultiTexImage3DEXT (GLenum, GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glMultiTexSubImage3DEXT (GLenum, GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glCopyMultiTexSubImage3DEXT (GLenum, GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); -GLAPI void APIENTRY glBindMultiTextureEXT (GLenum, GLenum, GLuint); -GLAPI void APIENTRY glEnableClientStateIndexedEXT (GLenum, GLuint); -GLAPI void APIENTRY glDisableClientStateIndexedEXT (GLenum, GLuint); -GLAPI void APIENTRY glMultiTexCoordPointerEXT (GLenum, GLint, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glMultiTexEnvfEXT (GLenum, GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glMultiTexEnvfvEXT (GLenum, GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexEnviEXT (GLenum, GLenum, GLenum, GLint); -GLAPI void APIENTRY glMultiTexEnvivEXT (GLenum, GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexGendEXT (GLenum, GLenum, GLenum, GLdouble); -GLAPI void APIENTRY glMultiTexGendvEXT (GLenum, GLenum, GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexGenfEXT (GLenum, GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glMultiTexGenfvEXT (GLenum, GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexGeniEXT (GLenum, GLenum, GLenum, GLint); -GLAPI void APIENTRY glMultiTexGenivEXT (GLenum, GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glGetMultiTexEnvfvEXT (GLenum, GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetMultiTexEnvivEXT (GLenum, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetMultiTexGendvEXT (GLenum, GLenum, GLenum, GLdouble *); -GLAPI void APIENTRY glGetMultiTexGenfvEXT (GLenum, GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetMultiTexGenivEXT (GLenum, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetFloatIndexedvEXT (GLenum, GLuint, GLfloat *); -GLAPI void APIENTRY glGetDoubleIndexedvEXT (GLenum, GLuint, GLdouble *); -GLAPI void APIENTRY glGetPointerIndexedvEXT (GLenum, GLuint, GLvoid* *); -GLAPI void APIENTRY glCompressedTextureImage3DEXT (GLuint, GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTextureImage2DEXT (GLuint, GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTextureImage1DEXT (GLuint, GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTextureSubImage3DEXT (GLuint, GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTextureSubImage2DEXT (GLuint, GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTextureSubImage1DEXT (GLuint, GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glGetCompressedTextureImageEXT (GLuint, GLenum, GLint, GLvoid *); -GLAPI void APIENTRY glCompressedMultiTexImage3DEXT (GLenum, GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedMultiTexImage2DEXT (GLenum, GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedMultiTexImage1DEXT (GLenum, GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedMultiTexSubImage3DEXT (GLenum, GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedMultiTexSubImage2DEXT (GLenum, GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedMultiTexSubImage1DEXT (GLenum, GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glGetCompressedMultiTexImageEXT (GLenum, GLenum, GLint, GLvoid *); -GLAPI void APIENTRY glNamedProgramStringEXT (GLuint, GLenum, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glNamedProgramLocalParameter4dEXT (GLuint, GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glNamedProgramLocalParameter4dvEXT (GLuint, GLenum, GLuint, const GLdouble *); -GLAPI void APIENTRY glNamedProgramLocalParameter4fEXT (GLuint, GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glNamedProgramLocalParameter4fvEXT (GLuint, GLenum, GLuint, const GLfloat *); -GLAPI void APIENTRY glGetNamedProgramLocalParameterdvEXT (GLuint, GLenum, GLuint, GLdouble *); -GLAPI void APIENTRY glGetNamedProgramLocalParameterfvEXT (GLuint, GLenum, GLuint, GLfloat *); -GLAPI void APIENTRY glGetNamedProgramivEXT (GLuint, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetNamedProgramStringEXT (GLuint, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glNamedProgramLocalParameters4fvEXT (GLuint, GLenum, GLuint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glNamedProgramLocalParameterI4iEXT (GLuint, GLenum, GLuint, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glNamedProgramLocalParameterI4ivEXT (GLuint, GLenum, GLuint, const GLint *); -GLAPI void APIENTRY glNamedProgramLocalParametersI4ivEXT (GLuint, GLenum, GLuint, GLsizei, const GLint *); -GLAPI void APIENTRY glNamedProgramLocalParameterI4uiEXT (GLuint, GLenum, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glNamedProgramLocalParameterI4uivEXT (GLuint, GLenum, GLuint, const GLuint *); -GLAPI void APIENTRY glNamedProgramLocalParametersI4uivEXT (GLuint, GLenum, GLuint, GLsizei, const GLuint *); -GLAPI void APIENTRY glGetNamedProgramLocalParameterIivEXT (GLuint, GLenum, GLuint, GLint *); -GLAPI void APIENTRY glGetNamedProgramLocalParameterIuivEXT (GLuint, GLenum, GLuint, GLuint *); -GLAPI void APIENTRY glTextureParameterIivEXT (GLuint, GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glTextureParameterIuivEXT (GLuint, GLenum, GLenum, const GLuint *); -GLAPI void APIENTRY glGetTextureParameterIivEXT (GLuint, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetTextureParameterIuivEXT (GLuint, GLenum, GLenum, GLuint *); -GLAPI void APIENTRY glMultiTexParameterIivEXT (GLenum, GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexParameterIuivEXT (GLenum, GLenum, GLenum, const GLuint *); -GLAPI void APIENTRY glGetMultiTexParameterIivEXT (GLenum, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetMultiTexParameterIuivEXT (GLenum, GLenum, GLenum, GLuint *); -GLAPI void APIENTRY glProgramUniform1fEXT (GLuint, GLint, GLfloat); -GLAPI void APIENTRY glProgramUniform2fEXT (GLuint, GLint, GLfloat, GLfloat); -GLAPI void APIENTRY glProgramUniform3fEXT (GLuint, GLint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glProgramUniform4fEXT (GLuint, GLint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glProgramUniform1iEXT (GLuint, GLint, GLint); -GLAPI void APIENTRY glProgramUniform2iEXT (GLuint, GLint, GLint, GLint); -GLAPI void APIENTRY glProgramUniform3iEXT (GLuint, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glProgramUniform4iEXT (GLuint, GLint, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glProgramUniform1fvEXT (GLuint, GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glProgramUniform2fvEXT (GLuint, GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glProgramUniform3fvEXT (GLuint, GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glProgramUniform4fvEXT (GLuint, GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glProgramUniform1ivEXT (GLuint, GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glProgramUniform2ivEXT (GLuint, GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glProgramUniform3ivEXT (GLuint, GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glProgramUniform4ivEXT (GLuint, GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glProgramUniformMatrix2fvEXT (GLuint, GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glProgramUniformMatrix3fvEXT (GLuint, GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glProgramUniformMatrix4fvEXT (GLuint, GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint, GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint, GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint, GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint, GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint, GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint, GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glProgramUniform1uiEXT (GLuint, GLint, GLuint); -GLAPI void APIENTRY glProgramUniform2uiEXT (GLuint, GLint, GLuint, GLuint); -GLAPI void APIENTRY glProgramUniform3uiEXT (GLuint, GLint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glProgramUniform4uiEXT (GLuint, GLint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glProgramUniform1uivEXT (GLuint, GLint, GLsizei, const GLuint *); -GLAPI void APIENTRY glProgramUniform2uivEXT (GLuint, GLint, GLsizei, const GLuint *); -GLAPI void APIENTRY glProgramUniform3uivEXT (GLuint, GLint, GLsizei, const GLuint *); -GLAPI void APIENTRY glProgramUniform4uivEXT (GLuint, GLint, GLsizei, const GLuint *); -GLAPI void APIENTRY glNamedBufferDataEXT (GLuint, GLsizeiptr, const GLvoid *, GLenum); -GLAPI void APIENTRY glNamedBufferSubDataEXT (GLuint, GLintptr, GLsizeiptr, const GLvoid *); -GLAPI GLvoid* APIENTRY glMapNamedBufferEXT (GLuint, GLenum); -GLAPI GLboolean APIENTRY glUnmapNamedBufferEXT (GLuint); -GLAPI void APIENTRY glGetNamedBufferParameterivEXT (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetNamedBufferPointervEXT (GLuint, GLenum, GLvoid* *); -GLAPI void APIENTRY glGetNamedBufferSubDataEXT (GLuint, GLintptr, GLsizeiptr, GLvoid *); -GLAPI void APIENTRY glTextureBufferEXT (GLuint, GLenum, GLenum, GLuint); -GLAPI void APIENTRY glMultiTexBufferEXT (GLenum, GLenum, GLenum, GLuint); -GLAPI void APIENTRY glNamedRenderbufferStorageEXT (GLuint, GLenum, GLsizei, GLsizei); -GLAPI void APIENTRY glGetNamedRenderbufferParameterivEXT (GLuint, GLenum, GLint *); -GLAPI GLenum APIENTRY glCheckNamedFramebufferStatusEXT (GLuint, GLenum); -GLAPI void APIENTRY glNamedFramebufferTexture1DEXT (GLuint, GLenum, GLenum, GLuint, GLint); -GLAPI void APIENTRY glNamedFramebufferTexture2DEXT (GLuint, GLenum, GLenum, GLuint, GLint); -GLAPI void APIENTRY glNamedFramebufferTexture3DEXT (GLuint, GLenum, GLenum, GLuint, GLint, GLint); -GLAPI void APIENTRY glNamedFramebufferRenderbufferEXT (GLuint, GLenum, GLenum, GLuint); -GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameterivEXT (GLuint, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGenerateTextureMipmapEXT (GLuint, GLenum); -GLAPI void APIENTRY glGenerateMultiTexMipmapEXT (GLenum, GLenum); -GLAPI void APIENTRY glFramebufferDrawBufferEXT (GLuint, GLenum); -GLAPI void APIENTRY glFramebufferDrawBuffersEXT (GLuint, GLsizei, const GLenum *); -GLAPI void APIENTRY glFramebufferReadBufferEXT (GLuint, GLenum); -GLAPI void APIENTRY glGetFramebufferParameterivEXT (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleEXT (GLuint, GLsizei, GLenum, GLsizei, GLsizei); -GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleCoverageEXT (GLuint, GLsizei, GLsizei, GLenum, GLsizei, GLsizei); -GLAPI void APIENTRY glNamedFramebufferTextureEXT (GLuint, GLenum, GLuint, GLint); -GLAPI void APIENTRY glNamedFramebufferTextureLayerEXT (GLuint, GLenum, GLuint, GLint, GLint); -GLAPI void APIENTRY glNamedFramebufferTextureFaceEXT (GLuint, GLenum, GLuint, GLint, GLenum); -GLAPI void APIENTRY glTextureRenderbufferEXT (GLuint, GLenum, GLuint); -GLAPI void APIENTRY glMultiTexRenderbufferEXT (GLenum, GLenum, GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); -typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); -typedef void (APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m); -typedef void (APIENTRYP PFNGLMATRIXLOADDEXTPROC) (GLenum mode, const GLdouble *m); -typedef void (APIENTRYP PFNGLMATRIXMULTFEXTPROC) (GLenum mode, const GLfloat *m); -typedef void (APIENTRYP PFNGLMATRIXMULTDEXTPROC) (GLenum mode, const GLdouble *m); -typedef void (APIENTRYP PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLMATRIXROTATEFEXTPROC) (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLMATRIXROTATEDEXTPROC) (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLMATRIXSCALEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLMATRIXSCALEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLMATRIXFRUSTUMEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -typedef void (APIENTRYP PFNGLMATRIXORTHOEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -typedef void (APIENTRYP PFNGLMATRIXPOPEXTPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLMATRIXPUSHEXTPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); -typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); -typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); -typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); -typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture); -typedef void (APIENTRYP PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); -typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); -typedef void (APIENTRYP PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLMULTITEXENVIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMULTITEXGENDEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); -typedef void (APIENTRYP PFNGLMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); -typedef void (APIENTRYP PFNGLMULTITEXGENFEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLMULTITEXGENIEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat *data); -typedef void (APIENTRYP PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble *data); -typedef void (APIENTRYP PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLvoid* *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint lod, GLvoid *img); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint lod, GLvoid *img); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const GLvoid *string); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, GLvoid *string); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint *params); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const GLvoid *data, GLenum usage); -typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const GLvoid *data); -typedef GLvoid* (APIENTRYP PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, GLvoid* *params); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLvoid *data); -typedef void (APIENTRYP PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); -typedef void (APIENTRYP PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); -typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint *params); -typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPEXTPROC) (GLuint texture, GLenum target); -typedef void (APIENTRYP PFNGLGENERATEMULTITEXMIPMAPEXTPROC) (GLenum texunit, GLenum target); -typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); -typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); -typedef void (APIENTRYP PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); -typedef void (APIENTRYP PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer); -#endif - -#ifndef GL_EXT_vertex_array_bgra -#define GL_EXT_vertex_array_bgra 1 -#endif - -#ifndef GL_EXT_texture_swizzle -#define GL_EXT_texture_swizzle 1 -#endif - -#ifndef GL_NV_explicit_multisample -#define GL_NV_explicit_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetMultisamplefvNV (GLenum, GLuint, GLfloat *); -GLAPI void APIENTRY glSampleMaskIndexedNV (GLuint, GLbitfield); -GLAPI void APIENTRY glTexRenderbufferNV (GLenum, GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat *val); -typedef void (APIENTRYP PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask); -typedef void (APIENTRYP PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer); -#endif - -#ifndef GL_NV_transform_feedback2 -#define GL_NV_transform_feedback2 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindTransformFeedbackNV (GLenum, GLuint); -GLAPI void APIENTRY glDeleteTransformFeedbacksNV (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenTransformFeedbacksNV (GLsizei, GLuint *); -GLAPI GLboolean APIENTRY glIsTransformFeedbackNV (GLuint); -GLAPI void APIENTRY glPauseTransformFeedbackNV (void); -GLAPI void APIENTRY glResumeTransformFeedbackNV (void); -GLAPI void APIENTRY glDrawTransformFeedbackNV (GLenum, GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint *ids); -typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void); -typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void); -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id); -#endif - -#ifndef GL_ATI_meminfo -#define GL_ATI_meminfo 1 -#endif - -#ifndef GL_AMD_performance_monitor -#define GL_AMD_performance_monitor 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetPerfMonitorGroupsAMD (GLint *, GLsizei, GLuint *); -GLAPI void APIENTRY glGetPerfMonitorCountersAMD (GLuint, GLint *, GLint *, GLsizei, GLuint *); -GLAPI void APIENTRY glGetPerfMonitorGroupStringAMD (GLuint, GLsizei, GLsizei *, GLchar *); -GLAPI void APIENTRY glGetPerfMonitorCounterStringAMD (GLuint, GLuint, GLsizei, GLsizei *, GLchar *); -GLAPI void APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint, GLuint, GLenum, void *); -GLAPI void APIENTRY glGenPerfMonitorsAMD (GLsizei, GLuint *); -GLAPI void APIENTRY glDeletePerfMonitorsAMD (GLsizei, GLuint *); -GLAPI void APIENTRY glSelectPerfMonitorCountersAMD (GLuint, GLboolean, GLuint, GLint, GLuint *); -GLAPI void APIENTRY glBeginPerfMonitorAMD (GLuint); -GLAPI void APIENTRY glEndPerfMonitorAMD (GLuint); -GLAPI void APIENTRY glGetPerfMonitorCounterDataAMD (GLuint, GLenum, GLsizei, GLuint *, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); -typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); -typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); -typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); -typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, void *data); -typedef void (APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); -typedef void (APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); -typedef void (APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); -typedef void (APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); -typedef void (APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); -typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); -#endif - -#ifndef GL_AMD_texture_texture4 -#define GL_AMD_texture_texture4 1 -#endif - -#ifndef GL_AMD_vertex_shader_tesselator -#define GL_AMD_vertex_shader_tesselator 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTessellationFactorAMD (GLfloat); -GLAPI void APIENTRY glTessellationModeAMD (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor); -typedef void (APIENTRYP PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode); -#endif - -#ifndef GL_EXT_provoking_vertex -#define GL_EXT_provoking_vertex 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProvokingVertexEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode); -#endif - -#ifndef GL_EXT_texture_snorm -#define GL_EXT_texture_snorm 1 -#endif - -#ifndef GL_AMD_draw_buffers_blend -#define GL_AMD_draw_buffers_blend 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncIndexedAMD (GLuint, GLenum, GLenum); -GLAPI void APIENTRY glBlendFuncSeparateIndexedAMD (GLuint, GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glBlendEquationIndexedAMD (GLuint, GLenum); -GLAPI void APIENTRY glBlendEquationSeparateIndexedAMD (GLuint, GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst); -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -typedef void (APIENTRYP PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode); -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -#endif - -#ifndef GL_APPLE_texture_range -#define GL_APPLE_texture_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureRangeAPPLE (GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glGetTexParameterPointervAPPLE (GLenum, GLenum, GLvoid* *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, GLvoid* *params); -#endif - -#ifndef GL_APPLE_float_pixels -#define GL_APPLE_float_pixels 1 -#endif - -#ifndef GL_APPLE_vertex_program_evaluators -#define GL_APPLE_vertex_program_evaluators 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glEnableVertexAttribAPPLE (GLuint, GLenum); -GLAPI void APIENTRY glDisableVertexAttribAPPLE (GLuint, GLenum); -GLAPI GLboolean APIENTRY glIsVertexAttribEnabledAPPLE (GLuint, GLenum); -GLAPI void APIENTRY glMapVertexAttrib1dAPPLE (GLuint, GLuint, GLdouble, GLdouble, GLint, GLint, const GLdouble *); -GLAPI void APIENTRY glMapVertexAttrib1fAPPLE (GLuint, GLuint, GLfloat, GLfloat, GLint, GLint, const GLfloat *); -GLAPI void APIENTRY glMapVertexAttrib2dAPPLE (GLuint, GLuint, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble *); -GLAPI void APIENTRY glMapVertexAttrib2fAPPLE (GLuint, GLuint, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); -typedef GLboolean (APIENTRYP PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname); -typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); -typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); -typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); -typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); -#endif - -#ifndef GL_APPLE_aux_depth_stencil -#define GL_APPLE_aux_depth_stencil 1 -#endif - -#ifndef GL_APPLE_object_purgeable -#define GL_APPLE_object_purgeable 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLenum APIENTRY glObjectPurgeableAPPLE (GLenum, GLuint, GLenum); -GLAPI GLenum APIENTRY glObjectUnpurgeableAPPLE (GLenum, GLuint, GLenum); -GLAPI void APIENTRY glGetObjectParameterivAPPLE (GLenum, GLuint, GLenum, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLenum (APIENTRYP PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); -typedef GLenum (APIENTRYP PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint *params); -#endif - -#ifndef GL_APPLE_row_bytes -#define GL_APPLE_row_bytes 1 -#endif - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/irrlicht-1.6/source/Irrlicht/glxext.h b/irrlicht-1.6/source/Irrlicht/glxext.h deleted file mode 100644 index 3b1b139ae..000000000 --- a/irrlicht-1.6/source/Irrlicht/glxext.h +++ /dev/null @@ -1,845 +0,0 @@ -#ifndef __glxext_h_ -#define __glxext_h_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* -** Copyright (c) 2007-2009 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -/* Function declaration macros - to move into glplatform.h */ - -#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) -#define WIN32_LEAN_AND_MEAN 1 -#include <windows.h> -#endif - -#ifndef APIENTRY -#define APIENTRY -#endif -#ifndef APIENTRYP -#define APIENTRYP APIENTRY * -#endif -#ifndef GLAPI -#define GLAPI extern -#endif - -/*************************************************************/ - -/* Header file version number, required by OpenGL ABI for Linux */ -/* glxext.h last updated 2009/08/03 */ -/* Current version at http://www.opengl.org/registry/ */ -#define GLX_GLXEXT_VERSION 23 - -#ifndef GLX_VERSION_1_3 -#define GLX_WINDOW_BIT 0x00000001 -#define GLX_PIXMAP_BIT 0x00000002 -#define GLX_PBUFFER_BIT 0x00000004 -#define GLX_RGBA_BIT 0x00000001 -#define GLX_COLOR_INDEX_BIT 0x00000002 -#define GLX_PBUFFER_CLOBBER_MASK 0x08000000 -#define GLX_FRONT_LEFT_BUFFER_BIT 0x00000001 -#define GLX_FRONT_RIGHT_BUFFER_BIT 0x00000002 -#define GLX_BACK_LEFT_BUFFER_BIT 0x00000004 -#define GLX_BACK_RIGHT_BUFFER_BIT 0x00000008 -#define GLX_AUX_BUFFERS_BIT 0x00000010 -#define GLX_DEPTH_BUFFER_BIT 0x00000020 -#define GLX_STENCIL_BUFFER_BIT 0x00000040 -#define GLX_ACCUM_BUFFER_BIT 0x00000080 -#define GLX_CONFIG_CAVEAT 0x20 -#define GLX_X_VISUAL_TYPE 0x22 -#define GLX_TRANSPARENT_TYPE 0x23 -#define GLX_TRANSPARENT_INDEX_VALUE 0x24 -#define GLX_TRANSPARENT_RED_VALUE 0x25 -#define GLX_TRANSPARENT_GREEN_VALUE 0x26 -#define GLX_TRANSPARENT_BLUE_VALUE 0x27 -#define GLX_TRANSPARENT_ALPHA_VALUE 0x28 -#define GLX_DONT_CARE 0xFFFFFFFF -#define GLX_NONE 0x8000 -#define GLX_SLOW_CONFIG 0x8001 -#define GLX_TRUE_COLOR 0x8002 -#define GLX_DIRECT_COLOR 0x8003 -#define GLX_PSEUDO_COLOR 0x8004 -#define GLX_STATIC_COLOR 0x8005 -#define GLX_GRAY_SCALE 0x8006 -#define GLX_STATIC_GRAY 0x8007 -#define GLX_TRANSPARENT_RGB 0x8008 -#define GLX_TRANSPARENT_INDEX 0x8009 -#define GLX_VISUAL_ID 0x800B -#define GLX_SCREEN 0x800C -#define GLX_NON_CONFORMANT_CONFIG 0x800D -#define GLX_DRAWABLE_TYPE 0x8010 -#define GLX_RENDER_TYPE 0x8011 -#define GLX_X_RENDERABLE 0x8012 -#define GLX_FBCONFIG_ID 0x8013 -#define GLX_RGBA_TYPE 0x8014 -#define GLX_COLOR_INDEX_TYPE 0x8015 -#define GLX_MAX_PBUFFER_WIDTH 0x8016 -#define GLX_MAX_PBUFFER_HEIGHT 0x8017 -#define GLX_MAX_PBUFFER_PIXELS 0x8018 -#define GLX_PRESERVED_CONTENTS 0x801B -#define GLX_LARGEST_PBUFFER 0x801C -#define GLX_WIDTH 0x801D -#define GLX_HEIGHT 0x801E -#define GLX_EVENT_MASK 0x801F -#define GLX_DAMAGED 0x8020 -#define GLX_SAVED 0x8021 -#define GLX_WINDOW 0x8022 -#define GLX_PBUFFER 0x8023 -#define GLX_PBUFFER_HEIGHT 0x8040 -#define GLX_PBUFFER_WIDTH 0x8041 -#endif - -#ifndef GLX_VERSION_1_4 -#define GLX_SAMPLE_BUFFERS 100000 -#define GLX_SAMPLES 100001 -#endif - -#ifndef GLX_ARB_get_proc_address -#endif - -#ifndef GLX_ARB_multisample -#define GLX_SAMPLE_BUFFERS_ARB 100000 -#define GLX_SAMPLES_ARB 100001 -#endif - -#ifndef GLX_ARB_fbconfig_float -#define GLX_RGBA_FLOAT_TYPE_ARB 0x20B9 -#define GLX_RGBA_FLOAT_BIT_ARB 0x00000004 -#endif - -#ifndef GLX_ARB_create_context -#define GLX_CONTEXT_DEBUG_BIT_ARB 0x00000001 -#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 -#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091 -#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092 -#define GLX_CONTEXT_FLAGS_ARB 0x2094 -#endif - -#ifndef GLX_ARB_create_context_profile -#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 -#define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 -#define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126 -#endif - -#ifndef GLX_SGIS_multisample -#define GLX_SAMPLE_BUFFERS_SGIS 100000 -#define GLX_SAMPLES_SGIS 100001 -#endif - -#ifndef GLX_EXT_visual_info -#define GLX_X_VISUAL_TYPE_EXT 0x22 -#define GLX_TRANSPARENT_TYPE_EXT 0x23 -#define GLX_TRANSPARENT_INDEX_VALUE_EXT 0x24 -#define GLX_TRANSPARENT_RED_VALUE_EXT 0x25 -#define GLX_TRANSPARENT_GREEN_VALUE_EXT 0x26 -#define GLX_TRANSPARENT_BLUE_VALUE_EXT 0x27 -#define GLX_TRANSPARENT_ALPHA_VALUE_EXT 0x28 -#define GLX_NONE_EXT 0x8000 -#define GLX_TRUE_COLOR_EXT 0x8002 -#define GLX_DIRECT_COLOR_EXT 0x8003 -#define GLX_PSEUDO_COLOR_EXT 0x8004 -#define GLX_STATIC_COLOR_EXT 0x8005 -#define GLX_GRAY_SCALE_EXT 0x8006 -#define GLX_STATIC_GRAY_EXT 0x8007 -#define GLX_TRANSPARENT_RGB_EXT 0x8008 -#define GLX_TRANSPARENT_INDEX_EXT 0x8009 -#endif - -#ifndef GLX_SGI_swap_control -#endif - -#ifndef GLX_SGI_video_sync -#endif - -#ifndef GLX_SGI_make_current_read -#endif - -#ifndef GLX_SGIX_video_source -#endif - -#ifndef GLX_EXT_visual_rating -#define GLX_VISUAL_CAVEAT_EXT 0x20 -#define GLX_SLOW_VISUAL_EXT 0x8001 -#define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D -/* reuse GLX_NONE_EXT */ -#endif - -#ifndef GLX_EXT_import_context -#define GLX_SHARE_CONTEXT_EXT 0x800A -#define GLX_VISUAL_ID_EXT 0x800B -#define GLX_SCREEN_EXT 0x800C -#endif - -#ifndef GLX_SGIX_fbconfig -#define GLX_WINDOW_BIT_SGIX 0x00000001 -#define GLX_PIXMAP_BIT_SGIX 0x00000002 -#define GLX_RGBA_BIT_SGIX 0x00000001 -#define GLX_COLOR_INDEX_BIT_SGIX 0x00000002 -#define GLX_DRAWABLE_TYPE_SGIX 0x8010 -#define GLX_RENDER_TYPE_SGIX 0x8011 -#define GLX_X_RENDERABLE_SGIX 0x8012 -#define GLX_FBCONFIG_ID_SGIX 0x8013 -#define GLX_RGBA_TYPE_SGIX 0x8014 -#define GLX_COLOR_INDEX_TYPE_SGIX 0x8015 -/* reuse GLX_SCREEN_EXT */ -#endif - -#ifndef GLX_SGIX_pbuffer -#define GLX_PBUFFER_BIT_SGIX 0x00000004 -#define GLX_BUFFER_CLOBBER_MASK_SGIX 0x08000000 -#define GLX_FRONT_LEFT_BUFFER_BIT_SGIX 0x00000001 -#define GLX_FRONT_RIGHT_BUFFER_BIT_SGIX 0x00000002 -#define GLX_BACK_LEFT_BUFFER_BIT_SGIX 0x00000004 -#define GLX_BACK_RIGHT_BUFFER_BIT_SGIX 0x00000008 -#define GLX_AUX_BUFFERS_BIT_SGIX 0x00000010 -#define GLX_DEPTH_BUFFER_BIT_SGIX 0x00000020 -#define GLX_STENCIL_BUFFER_BIT_SGIX 0x00000040 -#define GLX_ACCUM_BUFFER_BIT_SGIX 0x00000080 -#define GLX_SAMPLE_BUFFERS_BIT_SGIX 0x00000100 -#define GLX_MAX_PBUFFER_WIDTH_SGIX 0x8016 -#define GLX_MAX_PBUFFER_HEIGHT_SGIX 0x8017 -#define GLX_MAX_PBUFFER_PIXELS_SGIX 0x8018 -#define GLX_OPTIMAL_PBUFFER_WIDTH_SGIX 0x8019 -#define GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX 0x801A -#define GLX_PRESERVED_CONTENTS_SGIX 0x801B -#define GLX_LARGEST_PBUFFER_SGIX 0x801C -#define GLX_WIDTH_SGIX 0x801D -#define GLX_HEIGHT_SGIX 0x801E -#define GLX_EVENT_MASK_SGIX 0x801F -#define GLX_DAMAGED_SGIX 0x8020 -#define GLX_SAVED_SGIX 0x8021 -#define GLX_WINDOW_SGIX 0x8022 -#define GLX_PBUFFER_SGIX 0x8023 -#endif - -#ifndef GLX_SGI_cushion -#endif - -#ifndef GLX_SGIX_video_resize -#define GLX_SYNC_FRAME_SGIX 0x00000000 -#define GLX_SYNC_SWAP_SGIX 0x00000001 -#endif - -#ifndef GLX_SGIX_dmbuffer -#define GLX_DIGITAL_MEDIA_PBUFFER_SGIX 0x8024 -#endif - -#ifndef GLX_SGIX_swap_group -#endif - -#ifndef GLX_SGIX_swap_barrier -#endif - -#ifndef GLX_SGIS_blended_overlay -#define GLX_BLENDED_RGBA_SGIS 0x8025 -#endif - -#ifndef GLX_SGIS_shared_multisample -#define GLX_MULTISAMPLE_SUB_RECT_WIDTH_SGIS 0x8026 -#define GLX_MULTISAMPLE_SUB_RECT_HEIGHT_SGIS 0x8027 -#endif - -#ifndef GLX_SUN_get_transparent_index -#endif - -#ifndef GLX_3DFX_multisample -#define GLX_SAMPLE_BUFFERS_3DFX 0x8050 -#define GLX_SAMPLES_3DFX 0x8051 -#endif - -#ifndef GLX_MESA_copy_sub_buffer -#endif - -#ifndef GLX_MESA_pixmap_colormap -#endif - -#ifndef GLX_MESA_release_buffers -#endif - -#ifndef GLX_MESA_set_3dfx_mode -#define GLX_3DFX_WINDOW_MODE_MESA 0x1 -#define GLX_3DFX_FULLSCREEN_MODE_MESA 0x2 -#endif - -#ifndef GLX_SGIX_visual_select_group -#define GLX_VISUAL_SELECT_GROUP_SGIX 0x8028 -#endif - -#ifndef GLX_OML_swap_method -#define GLX_SWAP_METHOD_OML 0x8060 -#define GLX_SWAP_EXCHANGE_OML 0x8061 -#define GLX_SWAP_COPY_OML 0x8062 -#define GLX_SWAP_UNDEFINED_OML 0x8063 -#endif - -#ifndef GLX_OML_sync_control -#endif - -#ifndef GLX_NV_float_buffer -#define GLX_FLOAT_COMPONENTS_NV 0x20B0 -#endif - -#ifndef GLX_SGIX_hyperpipe -#define GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX 80 -#define GLX_BAD_HYPERPIPE_CONFIG_SGIX 91 -#define GLX_BAD_HYPERPIPE_SGIX 92 -#define GLX_HYPERPIPE_DISPLAY_PIPE_SGIX 0x00000001 -#define GLX_HYPERPIPE_RENDER_PIPE_SGIX 0x00000002 -#define GLX_PIPE_RECT_SGIX 0x00000001 -#define GLX_PIPE_RECT_LIMITS_SGIX 0x00000002 -#define GLX_HYPERPIPE_STEREO_SGIX 0x00000003 -#define GLX_HYPERPIPE_PIXEL_AVERAGE_SGIX 0x00000004 -#define GLX_HYPERPIPE_ID_SGIX 0x8030 -#endif - -#ifndef GLX_MESA_agp_offset -#endif - -#ifndef GLX_EXT_fbconfig_packed_float -#define GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT 0x20B1 -#define GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT 0x00000008 -#endif - -#ifndef GLX_EXT_framebuffer_sRGB -#define GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20B2 -#endif - -#ifndef GLX_EXT_texture_from_pixmap -#define GLX_TEXTURE_1D_BIT_EXT 0x00000001 -#define GLX_TEXTURE_2D_BIT_EXT 0x00000002 -#define GLX_TEXTURE_RECTANGLE_BIT_EXT 0x00000004 -#define GLX_BIND_TO_TEXTURE_RGB_EXT 0x20D0 -#define GLX_BIND_TO_TEXTURE_RGBA_EXT 0x20D1 -#define GLX_BIND_TO_MIPMAP_TEXTURE_EXT 0x20D2 -#define GLX_BIND_TO_TEXTURE_TARGETS_EXT 0x20D3 -#define GLX_Y_INVERTED_EXT 0x20D4 -#define GLX_TEXTURE_FORMAT_EXT 0x20D5 -#define GLX_TEXTURE_TARGET_EXT 0x20D6 -#define GLX_MIPMAP_TEXTURE_EXT 0x20D7 -#define GLX_TEXTURE_FORMAT_NONE_EXT 0x20D8 -#define GLX_TEXTURE_FORMAT_RGB_EXT 0x20D9 -#define GLX_TEXTURE_FORMAT_RGBA_EXT 0x20DA -#define GLX_TEXTURE_1D_EXT 0x20DB -#define GLX_TEXTURE_2D_EXT 0x20DC -#define GLX_TEXTURE_RECTANGLE_EXT 0x20DD -#define GLX_FRONT_LEFT_EXT 0x20DE -#define GLX_FRONT_RIGHT_EXT 0x20DF -#define GLX_BACK_LEFT_EXT 0x20E0 -#define GLX_BACK_RIGHT_EXT 0x20E1 -#define GLX_FRONT_EXT GLX_FRONT_LEFT_EXT -#define GLX_BACK_EXT GLX_BACK_LEFT_EXT -#define GLX_AUX0_EXT 0x20E2 -#define GLX_AUX1_EXT 0x20E3 -#define GLX_AUX2_EXT 0x20E4 -#define GLX_AUX3_EXT 0x20E5 -#define GLX_AUX4_EXT 0x20E6 -#define GLX_AUX5_EXT 0x20E7 -#define GLX_AUX6_EXT 0x20E8 -#define GLX_AUX7_EXT 0x20E9 -#define GLX_AUX8_EXT 0x20EA -#define GLX_AUX9_EXT 0x20EB -#endif - -#ifndef GLX_NV_present_video -#define GLX_NUM_VIDEO_SLOTS_NV 0x20F0 -#endif - -#ifndef GLX_NV_video_out -#define GLX_VIDEO_OUT_COLOR_NV 0x20C3 -#define GLX_VIDEO_OUT_ALPHA_NV 0x20C4 -#define GLX_VIDEO_OUT_DEPTH_NV 0x20C5 -#define GLX_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6 -#define GLX_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7 -#define GLX_VIDEO_OUT_FRAME_NV 0x20C8 -#define GLX_VIDEO_OUT_FIELD_1_NV 0x20C9 -#define GLX_VIDEO_OUT_FIELD_2_NV 0x20CA -#define GLX_VIDEO_OUT_STACKED_FIELDS_1_2_NV 0x20CB -#define GLX_VIDEO_OUT_STACKED_FIELDS_2_1_NV 0x20CC -#endif - -#ifndef GLX_NV_swap_group -#endif - - -/*************************************************************/ - -#ifndef GLX_ARB_get_proc_address -typedef void (*__GLXextFuncPtr)(void); -#endif - -#ifndef GLX_SGIX_video_source -typedef XID GLXVideoSourceSGIX; -#endif - -#ifndef GLX_SGIX_fbconfig -typedef XID GLXFBConfigIDSGIX; -typedef struct __GLXFBConfigRec *GLXFBConfigSGIX; -#endif - -#ifndef GLX_SGIX_pbuffer -typedef XID GLXPbufferSGIX; -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came for SendEvent request */ - Display *display; /* display the event was read from */ - GLXDrawable drawable; /* i.d. of Drawable */ - int event_type; /* GLX_DAMAGED_SGIX or GLX_SAVED_SGIX */ - int draw_type; /* GLX_WINDOW_SGIX or GLX_PBUFFER_SGIX */ - unsigned int mask; /* mask indicating which buffers are affected*/ - int x, y; - int width, height; - int count; /* if nonzero, at least this many more */ -} GLXBufferClobberEventSGIX; -#endif - -#ifndef GLEXT_64_TYPES_DEFINED -/* This code block is duplicated in glext.h, so must be protected */ -#define GLEXT_64_TYPES_DEFINED -/* Define int32_t, int64_t, and uint64_t types for UST/MSC */ -/* (as used in the GLX_OML_sync_control extension). */ -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -#include <inttypes.h> -#elif defined(__sun__) || defined(__digital__) -#include <inttypes.h> -#if defined(__STDC__) -#if defined(__arch64__) || defined(_LP64) -typedef long int int64_t; -typedef unsigned long int uint64_t; -#else -typedef long long int int64_t; -typedef unsigned long long int uint64_t; -#endif /* __arch64__ */ -#endif /* __STDC__ */ -#elif defined( __VMS ) || defined(__sgi) -#include <inttypes.h> -#elif defined(__SCO__) || defined(__USLC__) -#include <stdint.h> -#elif defined(__UNIXOS2__) || defined(__SOL64__) -typedef long int int32_t; -typedef long long int int64_t; -typedef unsigned long long int uint64_t; -#elif defined(_WIN32) && defined(__GNUC__) -#include <stdint.h> -#elif defined(_WIN32) -typedef __int32 int32_t; -typedef __int64 int64_t; -typedef unsigned __int64 uint64_t; -#else -#include <inttypes.h> /* Fallback option */ -#endif -#endif - -#ifndef GLX_VERSION_1_3 -#define GLX_VERSION_1_3 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern GLXFBConfig * glXGetFBConfigs (Display *, int, int *); -extern GLXFBConfig * glXChooseFBConfig (Display *, int, const int *, int *); -extern int glXGetFBConfigAttrib (Display *, GLXFBConfig, int, int *); -extern XVisualInfo * glXGetVisualFromFBConfig (Display *, GLXFBConfig); -extern GLXWindow glXCreateWindow (Display *, GLXFBConfig, Window, const int *); -extern void glXDestroyWindow (Display *, GLXWindow); -extern GLXPixmap glXCreatePixmap (Display *, GLXFBConfig, Pixmap, const int *); -extern void glXDestroyPixmap (Display *, GLXPixmap); -extern GLXPbuffer glXCreatePbuffer (Display *, GLXFBConfig, const int *); -extern void glXDestroyPbuffer (Display *, GLXPbuffer); -extern void glXQueryDrawable (Display *, GLXDrawable, int, unsigned int *); -extern GLXContext glXCreateNewContext (Display *, GLXFBConfig, int, GLXContext, Bool); -extern Bool glXMakeContextCurrent (Display *, GLXDrawable, GLXDrawable, GLXContext); -extern GLXDrawable glXGetCurrentReadDrawable (void); -extern Display * glXGetCurrentDisplay (void); -extern int glXQueryContext (Display *, GLXContext, int, int *); -extern void glXSelectEvent (Display *, GLXDrawable, unsigned long); -extern void glXGetSelectedEvent (Display *, GLXDrawable, unsigned long *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef GLXFBConfig * ( * PFNGLXGETFBCONFIGSPROC) (Display *dpy, int screen, int *nelements); -typedef GLXFBConfig * ( * PFNGLXCHOOSEFBCONFIGPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements); -typedef int ( * PFNGLXGETFBCONFIGATTRIBPROC) (Display *dpy, GLXFBConfig config, int attribute, int *value); -typedef XVisualInfo * ( * PFNGLXGETVISUALFROMFBCONFIGPROC) (Display *dpy, GLXFBConfig config); -typedef GLXWindow ( * PFNGLXCREATEWINDOWPROC) (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list); -typedef void ( * PFNGLXDESTROYWINDOWPROC) (Display *dpy, GLXWindow win); -typedef GLXPixmap ( * PFNGLXCREATEPIXMAPPROC) (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list); -typedef void ( * PFNGLXDESTROYPIXMAPPROC) (Display *dpy, GLXPixmap pixmap); -typedef GLXPbuffer ( * PFNGLXCREATEPBUFFERPROC) (Display *dpy, GLXFBConfig config, const int *attrib_list); -typedef void ( * PFNGLXDESTROYPBUFFERPROC) (Display *dpy, GLXPbuffer pbuf); -typedef void ( * PFNGLXQUERYDRAWABLEPROC) (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value); -typedef GLXContext ( * PFNGLXCREATENEWCONTEXTPROC) (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct); -typedef Bool ( * PFNGLXMAKECONTEXTCURRENTPROC) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx); -typedef GLXDrawable ( * PFNGLXGETCURRENTREADDRAWABLEPROC) (void); -typedef Display * ( * PFNGLXGETCURRENTDISPLAYPROC) (void); -typedef int ( * PFNGLXQUERYCONTEXTPROC) (Display *dpy, GLXContext ctx, int attribute, int *value); -typedef void ( * PFNGLXSELECTEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long event_mask); -typedef void ( * PFNGLXGETSELECTEDEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long *event_mask); -#endif - -#ifndef GLX_VERSION_1_4 -#define GLX_VERSION_1_4 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern __GLXextFuncPtr glXGetProcAddress (const GLubyte *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef __GLXextFuncPtr ( * PFNGLXGETPROCADDRESSPROC) (const GLubyte *procName); -#endif - -#ifndef GLX_ARB_get_proc_address -#define GLX_ARB_get_proc_address 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern __GLXextFuncPtr glXGetProcAddressARB (const GLubyte *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef __GLXextFuncPtr ( * PFNGLXGETPROCADDRESSARBPROC) (const GLubyte *procName); -#endif - -#ifndef GLX_ARB_multisample -#define GLX_ARB_multisample 1 -#endif - -#ifndef GLX_ARB_fbconfig_float -#define GLX_ARB_fbconfig_float 1 -#endif - -#ifndef GLX_ARB_create_context -#define GLX_ARB_create_context 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern GLXContext glXCreateContextAttribsARB (Display *, GLXFBConfig, GLXContext, Bool, const int *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef GLXContext ( * PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display *dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list); -#endif - -#ifndef GLX_ARB_create_context_profile -#define GLX_ARB_create_context_profile 1 -#endif - -#ifndef GLX_SGIS_multisample -#define GLX_SGIS_multisample 1 -#endif - -#ifndef GLX_EXT_visual_info -#define GLX_EXT_visual_info 1 -#endif - -#ifndef GLX_SGI_swap_control -#define GLX_SGI_swap_control 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern int glXSwapIntervalSGI (int); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef int ( * PFNGLXSWAPINTERVALSGIPROC) (int interval); -#endif - -#ifndef GLX_SGI_video_sync -#define GLX_SGI_video_sync 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern int glXGetVideoSyncSGI (unsigned int *); -extern int glXWaitVideoSyncSGI (int, int, unsigned int *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef int ( * PFNGLXGETVIDEOSYNCSGIPROC) (unsigned int *count); -typedef int ( * PFNGLXWAITVIDEOSYNCSGIPROC) (int divisor, int remainder, unsigned int *count); -#endif - -#ifndef GLX_SGI_make_current_read -#define GLX_SGI_make_current_read 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern Bool glXMakeCurrentReadSGI (Display *, GLXDrawable, GLXDrawable, GLXContext); -extern GLXDrawable glXGetCurrentReadDrawableSGI (void); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef Bool ( * PFNGLXMAKECURRENTREADSGIPROC) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx); -typedef GLXDrawable ( * PFNGLXGETCURRENTREADDRAWABLESGIPROC) (void); -#endif - -#ifndef GLX_SGIX_video_source -#define GLX_SGIX_video_source 1 -#ifdef _VL_H -#ifdef GLX_GLXEXT_PROTOTYPES -extern GLXVideoSourceSGIX glXCreateGLXVideoSourceSGIX (Display *, int, VLServer, VLPath, int, VLNode); -extern void glXDestroyGLXVideoSourceSGIX (Display *, GLXVideoSourceSGIX); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef GLXVideoSourceSGIX ( * PFNGLXCREATEGLXVIDEOSOURCESGIXPROC) (Display *display, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode); -typedef void ( * PFNGLXDESTROYGLXVIDEOSOURCESGIXPROC) (Display *dpy, GLXVideoSourceSGIX glxvideosource); -#endif /* _VL_H */ -#endif - -#ifndef GLX_EXT_visual_rating -#define GLX_EXT_visual_rating 1 -#endif - -#ifndef GLX_EXT_import_context -#define GLX_EXT_import_context 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern Display * glXGetCurrentDisplayEXT (void); -extern int glXQueryContextInfoEXT (Display *, GLXContext, int, int *); -extern GLXContextID glXGetContextIDEXT (const GLXContext); -extern GLXContext glXImportContextEXT (Display *, GLXContextID); -extern void glXFreeContextEXT (Display *, GLXContext); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef Display * ( * PFNGLXGETCURRENTDISPLAYEXTPROC) (void); -typedef int ( * PFNGLXQUERYCONTEXTINFOEXTPROC) (Display *dpy, GLXContext context, int attribute, int *value); -typedef GLXContextID ( * PFNGLXGETCONTEXTIDEXTPROC) (const GLXContext context); -typedef GLXContext ( * PFNGLXIMPORTCONTEXTEXTPROC) (Display *dpy, GLXContextID contextID); -typedef void ( * PFNGLXFREECONTEXTEXTPROC) (Display *dpy, GLXContext context); -#endif - -#ifndef GLX_SGIX_fbconfig -#define GLX_SGIX_fbconfig 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern int glXGetFBConfigAttribSGIX (Display *, GLXFBConfigSGIX, int, int *); -extern GLXFBConfigSGIX * glXChooseFBConfigSGIX (Display *, int, int *, int *); -extern GLXPixmap glXCreateGLXPixmapWithConfigSGIX (Display *, GLXFBConfigSGIX, Pixmap); -extern GLXContext glXCreateContextWithConfigSGIX (Display *, GLXFBConfigSGIX, int, GLXContext, Bool); -extern XVisualInfo * glXGetVisualFromFBConfigSGIX (Display *, GLXFBConfigSGIX); -extern GLXFBConfigSGIX glXGetFBConfigFromVisualSGIX (Display *, XVisualInfo *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef int ( * PFNGLXGETFBCONFIGATTRIBSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, int attribute, int *value); -typedef GLXFBConfigSGIX * ( * PFNGLXCHOOSEFBCONFIGSGIXPROC) (Display *dpy, int screen, int *attrib_list, int *nelements); -typedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap); -typedef GLXContext ( * PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct); -typedef XVisualInfo * ( * PFNGLXGETVISUALFROMFBCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config); -typedef GLXFBConfigSGIX ( * PFNGLXGETFBCONFIGFROMVISUALSGIXPROC) (Display *dpy, XVisualInfo *vis); -#endif - -#ifndef GLX_SGIX_pbuffer -#define GLX_SGIX_pbuffer 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern GLXPbufferSGIX glXCreateGLXPbufferSGIX (Display *, GLXFBConfigSGIX, unsigned int, unsigned int, int *); -extern void glXDestroyGLXPbufferSGIX (Display *, GLXPbufferSGIX); -extern int glXQueryGLXPbufferSGIX (Display *, GLXPbufferSGIX, int, unsigned int *); -extern void glXSelectEventSGIX (Display *, GLXDrawable, unsigned long); -extern void glXGetSelectedEventSGIX (Display *, GLXDrawable, unsigned long *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef GLXPbufferSGIX ( * PFNGLXCREATEGLXPBUFFERSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list); -typedef void ( * PFNGLXDESTROYGLXPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuf); -typedef int ( * PFNGLXQUERYGLXPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value); -typedef void ( * PFNGLXSELECTEVENTSGIXPROC) (Display *dpy, GLXDrawable drawable, unsigned long mask); -typedef void ( * PFNGLXGETSELECTEDEVENTSGIXPROC) (Display *dpy, GLXDrawable drawable, unsigned long *mask); -#endif - -#ifndef GLX_SGI_cushion -#define GLX_SGI_cushion 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern void glXCushionSGI (Display *, Window, float); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef void ( * PFNGLXCUSHIONSGIPROC) (Display *dpy, Window window, float cushion); -#endif - -#ifndef GLX_SGIX_video_resize -#define GLX_SGIX_video_resize 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern int glXBindChannelToWindowSGIX (Display *, int, int, Window); -extern int glXChannelRectSGIX (Display *, int, int, int, int, int, int); -extern int glXQueryChannelRectSGIX (Display *, int, int, int *, int *, int *, int *); -extern int glXQueryChannelDeltasSGIX (Display *, int, int, int *, int *, int *, int *); -extern int glXChannelRectSyncSGIX (Display *, int, int, GLenum); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef int ( * PFNGLXBINDCHANNELTOWINDOWSGIXPROC) (Display *display, int screen, int channel, Window window); -typedef int ( * PFNGLXCHANNELRECTSGIXPROC) (Display *display, int screen, int channel, int x, int y, int w, int h); -typedef int ( * PFNGLXQUERYCHANNELRECTSGIXPROC) (Display *display, int screen, int channel, int *dx, int *dy, int *dw, int *dh); -typedef int ( * PFNGLXQUERYCHANNELDELTASSGIXPROC) (Display *display, int screen, int channel, int *x, int *y, int *w, int *h); -typedef int ( * PFNGLXCHANNELRECTSYNCSGIXPROC) (Display *display, int screen, int channel, GLenum synctype); -#endif - -#ifndef GLX_SGIX_dmbuffer -#define GLX_SGIX_dmbuffer 1 -#ifdef _DM_BUFFER_H_ -#ifdef GLX_GLXEXT_PROTOTYPES -extern Bool glXAssociateDMPbufferSGIX (Display *, GLXPbufferSGIX, DMparams *, DMbuffer); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef Bool ( * PFNGLXASSOCIATEDMPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer); -#endif /* _DM_BUFFER_H_ */ -#endif - -#ifndef GLX_SGIX_swap_group -#define GLX_SGIX_swap_group 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern void glXJoinSwapGroupSGIX (Display *, GLXDrawable, GLXDrawable); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef void ( * PFNGLXJOINSWAPGROUPSGIXPROC) (Display *dpy, GLXDrawable drawable, GLXDrawable member); -#endif - -#ifndef GLX_SGIX_swap_barrier -#define GLX_SGIX_swap_barrier 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern void glXBindSwapBarrierSGIX (Display *, GLXDrawable, int); -extern Bool glXQueryMaxSwapBarriersSGIX (Display *, int, int *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef void ( * PFNGLXBINDSWAPBARRIERSGIXPROC) (Display *dpy, GLXDrawable drawable, int barrier); -typedef Bool ( * PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC) (Display *dpy, int screen, int *max); -#endif - -#ifndef GLX_SUN_get_transparent_index -#define GLX_SUN_get_transparent_index 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern Status glXGetTransparentIndexSUN (Display *, Window, Window, long *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef Status ( * PFNGLXGETTRANSPARENTINDEXSUNPROC) (Display *dpy, Window overlay, Window underlay, long *pTransparentIndex); -#endif - -#ifndef GLX_MESA_copy_sub_buffer -#define GLX_MESA_copy_sub_buffer 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern void glXCopySubBufferMESA (Display *, GLXDrawable, int, int, int, int); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef void ( * PFNGLXCOPYSUBBUFFERMESAPROC) (Display *dpy, GLXDrawable drawable, int x, int y, int width, int height); -#endif - -#ifndef GLX_MESA_pixmap_colormap -#define GLX_MESA_pixmap_colormap 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern GLXPixmap glXCreateGLXPixmapMESA (Display *, XVisualInfo *, Pixmap, Colormap); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPMESAPROC) (Display *dpy, XVisualInfo *visual, Pixmap pixmap, Colormap cmap); -#endif - -#ifndef GLX_MESA_release_buffers -#define GLX_MESA_release_buffers 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern Bool glXReleaseBuffersMESA (Display *, GLXDrawable); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef Bool ( * PFNGLXRELEASEBUFFERSMESAPROC) (Display *dpy, GLXDrawable drawable); -#endif - -#ifndef GLX_MESA_set_3dfx_mode -#define GLX_MESA_set_3dfx_mode 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern Bool glXSet3DfxModeMESA (int); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef Bool ( * PFNGLXSET3DFXMODEMESAPROC) (int mode); -#endif - -#ifndef GLX_SGIX_visual_select_group -#define GLX_SGIX_visual_select_group 1 -#endif - -#ifndef GLX_OML_swap_method -#define GLX_OML_swap_method 1 -#endif - -#ifndef GLX_OML_sync_control -#define GLX_OML_sync_control 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern Bool glXGetSyncValuesOML (Display *, GLXDrawable, int64_t *, int64_t *, int64_t *); -extern Bool glXGetMscRateOML (Display *, GLXDrawable, int32_t *, int32_t *); -extern int64_t glXSwapBuffersMscOML (Display *, GLXDrawable, int64_t, int64_t, int64_t); -extern Bool glXWaitForMscOML (Display *, GLXDrawable, int64_t, int64_t, int64_t, int64_t *, int64_t *, int64_t *); -extern Bool glXWaitForSbcOML (Display *, GLXDrawable, int64_t, int64_t *, int64_t *, int64_t *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef Bool ( * PFNGLXGETSYNCVALUESOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t *ust, int64_t *msc, int64_t *sbc); -typedef Bool ( * PFNGLXGETMSCRATEOMLPROC) (Display *dpy, GLXDrawable drawable, int32_t *numerator, int32_t *denominator); -typedef int64_t ( * PFNGLXSWAPBUFFERSMSCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder); -typedef Bool ( * PFNGLXWAITFORMSCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc); -typedef Bool ( * PFNGLXWAITFORSBCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_sbc, int64_t *ust, int64_t *msc, int64_t *sbc); -#endif - -#ifndef GLX_NV_float_buffer -#define GLX_NV_float_buffer 1 -#endif - -#ifndef GLX_SGIX_hyperpipe -#define GLX_SGIX_hyperpipe 1 - -typedef struct { - char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; - int networkId; -} GLXHyperpipeNetworkSGIX; - -typedef struct { - char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; - int channel; - unsigned int - participationType; - int timeSlice; -} GLXHyperpipeConfigSGIX; - -typedef struct { - char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; - int srcXOrigin, srcYOrigin, srcWidth, srcHeight; - int destXOrigin, destYOrigin, destWidth, destHeight; -} GLXPipeRect; - -typedef struct { - char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; - int XOrigin, YOrigin, maxHeight, maxWidth; -} GLXPipeRectLimits; - -#ifdef GLX_GLXEXT_PROTOTYPES -extern GLXHyperpipeNetworkSGIX * glXQueryHyperpipeNetworkSGIX (Display *, int *); -extern int glXHyperpipeConfigSGIX (Display *, int, int, GLXHyperpipeConfigSGIX *, int *); -extern GLXHyperpipeConfigSGIX * glXQueryHyperpipeConfigSGIX (Display *, int, int *); -extern int glXDestroyHyperpipeConfigSGIX (Display *, int); -extern int glXBindHyperpipeSGIX (Display *, int); -extern int glXQueryHyperpipeBestAttribSGIX (Display *, int, int, int, void *, void *); -extern int glXHyperpipeAttribSGIX (Display *, int, int, int, void *); -extern int glXQueryHyperpipeAttribSGIX (Display *, int, int, int, void *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef GLXHyperpipeNetworkSGIX * ( * PFNGLXQUERYHYPERPIPENETWORKSGIXPROC) (Display *dpy, int *npipes); -typedef int ( * PFNGLXHYPERPIPECONFIGSGIXPROC) (Display *dpy, int networkId, int npipes, GLXHyperpipeConfigSGIX *cfg, int *hpId); -typedef GLXHyperpipeConfigSGIX * ( * PFNGLXQUERYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId, int *npipes); -typedef int ( * PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId); -typedef int ( * PFNGLXBINDHYPERPIPESGIXPROC) (Display *dpy, int hpId); -typedef int ( * PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList, void *returnAttribList); -typedef int ( * PFNGLXHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList); -typedef int ( * PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *returnAttribList); -#endif - -#ifndef GLX_MESA_agp_offset -#define GLX_MESA_agp_offset 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern unsigned int glXGetAGPOffsetMESA (const void *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef unsigned int ( * PFNGLXGETAGPOFFSETMESAPROC) (const void *pointer); -#endif - -#ifndef GLX_EXT_fbconfig_packed_float -#define GLX_EXT_fbconfig_packed_float 1 -#endif - -#ifndef GLX_EXT_framebuffer_sRGB -#define GLX_EXT_framebuffer_sRGB 1 -#endif - -#ifndef GLX_EXT_texture_from_pixmap -#define GLX_EXT_texture_from_pixmap 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern void glXBindTexImageEXT (Display *, GLXDrawable, int, const int *); -extern void glXReleaseTexImageEXT (Display *, GLXDrawable, int); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef void ( * PFNGLXBINDTEXIMAGEEXTPROC) (Display *dpy, GLXDrawable drawable, int buffer, const int *attrib_list); -typedef void ( * PFNGLXRELEASETEXIMAGEEXTPROC) (Display *dpy, GLXDrawable drawable, int buffer); -#endif - -#ifndef GLX_NV_present_video -#define GLX_NV_present_video 1 -#endif - -#ifndef GLX_NV_video_out -#define GLX_NV_video_out 1 -#endif - -#ifndef GLX_NV_swap_group -#define GLX_NV_swap_group 1 -#endif - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/irrlicht-1.6/source/Irrlicht/irrXML.cpp b/irrlicht-1.6/source/Irrlicht/irrXML.cpp deleted file mode 100644 index 17522cb8e..000000000 --- a/irrlicht-1.6/source/Irrlicht/irrXML.cpp +++ /dev/null @@ -1,180 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine" and the "irrXML" project. -// For conditions of distribution and use, see copyright notice in irrlicht.h and/or irrXML.h - -#include "irrXML.h" -#include "irrString.h" -#include "irrArray.h" -#include "fast_atof.h" -#include "CXMLReaderImpl.h" - -namespace irr -{ -namespace io -{ - -//! Implementation of the file read callback for ordinary files -class CFileReadCallBack : public IFileReadCallBack -{ -public: - - //! construct from filename - CFileReadCallBack(const char* filename) - : File(0), Size(-1), Close(true) - { - // open file - File = fopen(filename, "rb"); - - if (File) - getFileSize(); - } - - //! construct from FILE pointer - CFileReadCallBack(FILE* file) - : File(file), Size(-1), Close(false) - { - if (File) - getFileSize(); - } - - //! destructor - virtual ~CFileReadCallBack() - { - if (Close && File) - fclose(File); - } - - //! Reads an amount of bytes from the file. - virtual int read(void* buffer, int sizeToRead) - { - if (!File) - return 0; - - return (int)fread(buffer, 1, sizeToRead, File); - } - - //! Returns size of file in bytes - virtual long getSize() const - { - return Size; - } - -private: - - //! retrieves the file size of the open file - void getFileSize() - { - fseek(File, 0, SEEK_END); - Size = ftell(File); - fseek(File, 0, SEEK_SET); - } - - FILE* File; - long Size; - bool Close; - -}; // end class CFileReadCallBack - - - -// FACTORY FUNCTIONS: - - -//! Creates an instance of an UFT-8 or ASCII character xml parser. -IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(const char* filename) -{ - return createIrrXMLReader(new CFileReadCallBack(filename), true); -} - - -//! Creates an instance of an UFT-8 or ASCII character xml parser. -IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(FILE* file) -{ - return createIrrXMLReader(new CFileReadCallBack(file), true); -} - - -//! Creates an instance of an UFT-8 or ASCII character xml parser. -IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(IFileReadCallBack* callback, - bool deleteCallback) -{ - if (callback && (callback->getSize() >= 0)) - { - return new CXMLReaderImpl<char, IXMLBase>(callback, deleteCallback); - } - else - { - if(callback && deleteCallback) - delete callback; - - return 0; - } -} - - -//! Creates an instance of an UTF-16 xml parser. -IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(const char* filename) -{ - return createIrrXMLReaderUTF16(new CFileReadCallBack(filename), true); -} - - -//! Creates an instance of an UTF-16 xml parser. -IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(FILE* file) -{ - return createIrrXMLReaderUTF16(new CFileReadCallBack(file), true); -} - - -//! Creates an instance of an UTF-16 xml parser. -IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(IFileReadCallBack* callback, - bool deleteCallback) -{ - if (callback && (callback->getSize() >= 0)) - { - return new CXMLReaderImpl<char16, IXMLBase>(callback, deleteCallback); - } - else - { - if(callback && deleteCallback) - delete callback; - - return 0; - } -} - - -//! Creates an instance of an UTF-32 xml parser. -IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(const char* filename) -{ - return createIrrXMLReaderUTF32(new CFileReadCallBack(filename), true); -} - - -//! Creates an instance of an UTF-32 xml parser. -IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(FILE* file) -{ - return createIrrXMLReaderUTF32(new CFileReadCallBack(file), true); -} - - -//! Creates an instance of an UTF-32 xml parser. -IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(IFileReadCallBack* callback, - bool deleteCallback) -{ - if (callback && (callback->getSize() >= 0)) - { - return new CXMLReaderImpl<char32, IXMLBase>(callback, deleteCallback); - } - else - { - if(callback && deleteCallback) - delete callback; - - return 0; - } -} - - -} // end namespace io -} // end namespace irr diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/README b/irrlicht-1.6/source/Irrlicht/jpeglib/README deleted file mode 100644 index 911d0e843..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/README +++ /dev/null @@ -1,385 +0,0 @@ -The Independent JPEG Group's JPEG software -========================================== - -README for release 6b of 27-Mar-1998 -==================================== - -This distribution contains the sixth public release of the Independent JPEG -Group's free JPEG software. You are welcome to redistribute this software and -to use it for any purpose, subject to the conditions under LEGAL ISSUES, below. - -Serious users of this software (particularly those incorporating it into -larger programs) should contact IJG at jpeg-info@uunet.uu.net to be added to -our electronic mailing list. Mailing list members are notified of updates -and have a chance to participate in technical discussions, etc. - -This software is the work of Tom Lane, Philip Gladstone, Jim Boucher, -Lee Crocker, Julian Minguillon, Luis Ortiz, George Phillips, Davide Rossi, -Guido Vollbeding, Ge' Weijers, and other members of the Independent JPEG -Group. - -IJG is not affiliated with the official ISO JPEG standards committee. - - -DOCUMENTATION ROADMAP -===================== - -This file contains the following sections: - -OVERVIEW General description of JPEG and the IJG software. -LEGAL ISSUES Copyright, lack of warranty, terms of distribution. -REFERENCES Where to learn more about JPEG. -ARCHIVE LOCATIONS Where to find newer versions of this software. -RELATED SOFTWARE Other stuff you should get. -FILE FORMAT WARS Software *not* to get. -TO DO Plans for future IJG releases. - -Other documentation files in the distribution are: - -User documentation: - install.doc How to configure and install the IJG software. - usage.doc Usage instructions for cjpeg, djpeg, jpegtran, - rdjpgcom, and wrjpgcom. - *.1 Unix-style man pages for programs (same info as usage.doc). - wizard.doc Advanced usage instructions for JPEG wizards only. - change.log Version-to-version change highlights. -Programmer and internal documentation: - libjpeg.doc How to use the JPEG library in your own programs. - example.c Sample code for calling the JPEG library. - structure.doc Overview of the JPEG library's internal structure. - filelist.doc Road map of IJG files. - coderules.doc Coding style rules --- please read if you contribute code. - -Please read at least the files install.doc and usage.doc. Useful information -can also be found in the JPEG FAQ (Frequently Asked Questions) article. See -ARCHIVE LOCATIONS below to find out where to obtain the FAQ article. - -If you want to understand how the JPEG code works, we suggest reading one or -more of the REFERENCES, then looking at the documentation files (in roughly -the order listed) before diving into the code. - - -OVERVIEW -======== - -This package contains C software to implement JPEG image compression and -decompression. JPEG (pronounced "jay-peg") is a standardized compression -method for full-color and gray-scale images. JPEG is intended for compressing -"real-world" scenes; line drawings, cartoons and other non-realistic images -are not its strong suit. JPEG is lossy, meaning that the output image is not -exactly identical to the input image. Hence you must not use JPEG if you -have to have identical output bits. However, on typical photographic images, -very good compression levels can be obtained with no visible change, and -remarkably high compression levels are possible if you can tolerate a -low-quality image. For more details, see the references, or just experiment -with various compression settings. - -This software implements JPEG baseline, extended-sequential, and progressive -compression processes. Provision is made for supporting all variants of these -processes, although some uncommon parameter settings aren't implemented yet. -For legal reasons, we are not distributing code for the arithmetic-coding -variants of JPEG; see LEGAL ISSUES. We have made no provision for supporting -the hierarchical or lossless processes defined in the standard. - -We provide a set of library routines for reading and writing JPEG image files, -plus two sample applications "cjpeg" and "djpeg", which use the library to -perform conversion between JPEG and some other popular image file formats. -The library is intended to be reused in other applications. - -In order to support file conversion and viewing software, we have included -considerable functionality beyond the bare JPEG coding/decoding capability; -for example, the color quantization modules are not strictly part of JPEG -decoding, but they are essential for output to colormapped file formats or -colormapped displays. These extra functions can be compiled out of the -library if not required for a particular application. We have also included -"jpegtran", a utility for lossless transcoding between different JPEG -processes, and "rdjpgcom" and "wrjpgcom", two simple applications for -inserting and extracting textual comments in JFIF files. - -The emphasis in designing this software has been on achieving portability and -flexibility, while also making it fast enough to be useful. In particular, -the software is not intended to be read as a tutorial on JPEG. (See the -REFERENCES section for introductory material.) Rather, it is intended to -be reliable, portable, industrial-strength code. We do not claim to have -achieved that goal in every aspect of the software, but we strive for it. - -We welcome the use of this software as a component of commercial products. -No royalty is required, but we do ask for an acknowledgement in product -documentation, as described under LEGAL ISSUES. - - -LEGAL ISSUES -============ - -In plain English: - -1. We don't promise that this software works. (But if you find any bugs, - please let us know!) -2. You can use this software for whatever you want. You don't have to pay us. -3. You may not pretend that you wrote this software. If you use it in a - program, you must acknowledge somewhere in your documentation that - you've used the IJG code. - -In legalese: - -The authors make NO WARRANTY or representation, either express or implied, -with respect to this software, its quality, accuracy, merchantability, or -fitness for a particular purpose. This software is provided "AS IS", and you, -its user, assume the entire risk as to its quality and accuracy. - -This software is copyright (C) 1991-1998, Thomas G. Lane. -All Rights Reserved except as specified below. - -Permission is hereby granted to use, copy, modify, and distribute this -software (or portions thereof) for any purpose, without fee, subject to these -conditions: -(1) If any part of the source code for this software is distributed, then this -README file must be included, with this copyright and no-warranty notice -unaltered; and any additions, deletions, or changes to the original files -must be clearly indicated in accompanying documentation. -(2) If only executable code is distributed, then the accompanying -documentation must state that "this software is based in part on the work of -the Independent JPEG Group". -(3) Permission for use of this software is granted only if the user accepts -full responsibility for any undesirable consequences; the authors accept -NO LIABILITY for damages of any kind. - -These conditions apply to any software derived from or based on the IJG code, -not just to the unmodified library. If you use our work, you ought to -acknowledge us. - -Permission is NOT granted for the use of any IJG author's name or company name -in advertising or publicity relating to this software or products derived from -it. This software may be referred to only as "the Independent JPEG Group's -software". - -We specifically permit and encourage the use of this software as the basis of -commercial products, provided that all warranty or liability claims are -assumed by the product vendor. - - -ansi2knr.c is included in this distribution by permission of L. Peter Deutsch, -sole proprietor of its copyright holder, Aladdin Enterprises of Menlo Park, CA. -ansi2knr.c is NOT covered by the above copyright and conditions, but instead -by the usual distribution terms of the Free Software Foundation; principally, -that you must include source code if you redistribute it. (See the file -ansi2knr.c for full details.) However, since ansi2knr.c is not needed as part -of any program generated from the IJG code, this does not limit you more than -the foregoing paragraphs do. - -The Unix configuration script "configure" was produced with GNU Autoconf. -It is copyright by the Free Software Foundation but is freely distributable. -The same holds for its supporting scripts (config.guess, config.sub, -ltconfig, ltmain.sh). Another support script, install-sh, is copyright -by M.I.T. but is also freely distributable. - -It appears that the arithmetic coding option of the JPEG spec is covered by -patents owned by IBM, AT&T, and Mitsubishi. Hence arithmetic coding cannot -legally be used without obtaining one or more licenses. For this reason, -support for arithmetic coding has been removed from the free JPEG software. -(Since arithmetic coding provides only a marginal gain over the unpatented -Huffman mode, it is unlikely that very many implementations will support it.) -So far as we are aware, there are no patent restrictions on the remaining -code. - -The IJG distribution formerly included code to read and write GIF files. -To avoid entanglement with the Unisys LZW patent, GIF reading support has -been removed altogether, and the GIF writer has been simplified to produce -"uncompressed GIFs". This technique does not use the LZW algorithm; the -resulting GIF files are larger than usual, but are readable by all standard -GIF decoders. - -We are required to state that - "The Graphics Interchange Format(c) is the Copyright property of - CompuServe Incorporated. GIF(sm) is a Service Mark property of - CompuServe Incorporated." - - -REFERENCES -========== - -We highly recommend reading one or more of these references before trying to -understand the innards of the JPEG software. - -The best short technical introduction to the JPEG compression algorithm is - Wallace, Gregory K. "The JPEG Still Picture Compression Standard", - Communications of the ACM, April 1991 (vol. 34 no. 4), pp. 30-44. -(Adjacent articles in that issue discuss MPEG motion picture compression, -applications of JPEG, and related topics.) If you don't have the CACM issue -handy, a PostScript file containing a revised version of Wallace's article is -available at ftp://ftp.uu.net/graphics/jpeg/wallace.ps.gz. The file (actually -a preprint for an article that appeared in IEEE Trans. Consumer Electronics) -omits the sample images that appeared in CACM, but it includes corrections -and some added material. Note: the Wallace article is copyright ACM and IEEE, -and it may not be used for commercial purposes. - -A somewhat less technical, more leisurely introduction to JPEG can be found in -"The Data Compression Book" by Mark Nelson and Jean-loup Gailly, published by -M&T Books (New York), 2nd ed. 1996, ISBN 1-55851-434-1. This book provides -good explanations and example C code for a multitude of compression methods -including JPEG. It is an excellent source if you are comfortable reading C -code but don't know much about data compression in general. The book's JPEG -sample code is far from industrial-strength, but when you are ready to look -at a full implementation, you've got one here... - -The best full description of JPEG is the textbook "JPEG Still Image Data -Compression Standard" by William B. Pennebaker and Joan L. Mitchell, published -by Van Nostrand Reinhold, 1993, ISBN 0-442-01272-1. Price US$59.95, 638 pp. -The book includes the complete text of the ISO JPEG standards (DIS 10918-1 -and draft DIS 10918-2). This is by far the most complete exposition of JPEG -in existence, and we highly recommend it. - -The JPEG standard itself is not available electronically; you must order a -paper copy through ISO or ITU. (Unless you feel a need to own a certified -official copy, we recommend buying the Pennebaker and Mitchell book instead; -it's much cheaper and includes a great deal of useful explanatory material.) -In the USA, copies of the standard may be ordered from ANSI Sales at (212) -642-4900, or from Global Engineering Documents at (800) 854-7179. (ANSI -doesn't take credit card orders, but Global does.) It's not cheap: as of -1992, ANSI was charging $95 for Part 1 and $47 for Part 2, plus 7% -shipping/handling. The standard is divided into two parts, Part 1 being the -actual specification, while Part 2 covers compliance testing methods. Part 1 -is titled "Digital Compression and Coding of Continuous-tone Still Images, -Part 1: Requirements and guidelines" and has document numbers ISO/IEC IS -10918-1, ITU-T T.81. Part 2 is titled "Digital Compression and Coding of -Continuous-tone Still Images, Part 2: Compliance testing" and has document -numbers ISO/IEC IS 10918-2, ITU-T T.83. - -Some extensions to the original JPEG standard are defined in JPEG Part 3, -a newer ISO standard numbered ISO/IEC IS 10918-3 and ITU-T T.84. IJG -currently does not support any Part 3 extensions. - -The JPEG standard does not specify all details of an interchangeable file -format. For the omitted details we follow the "JFIF" conventions, revision -1.02. A copy of the JFIF spec is available from: - Literature Department - C-Cube Microsystems, Inc. - 1778 McCarthy Blvd. - Milpitas, CA 95035 - phone (408) 944-6300, fax (408) 944-6314 -A PostScript version of this document is available by FTP at -ftp://ftp.uu.net/graphics/jpeg/jfif.ps.gz. There is also a plain text -version at ftp://ftp.uu.net/graphics/jpeg/jfif.txt.gz, but it is missing -the figures. - -The TIFF 6.0 file format specification can be obtained by FTP from -ftp://ftp.sgi.com/graphics/tiff/TIFF6.ps.gz. The JPEG incorporation scheme -found in the TIFF 6.0 spec of 3-June-92 has a number of serious problems. -IJG does not recommend use of the TIFF 6.0 design (TIFF Compression tag 6). -Instead, we recommend the JPEG design proposed by TIFF Technical Note #2 -(Compression tag 7). Copies of this Note can be obtained from ftp.sgi.com or -from ftp://ftp.uu.net/graphics/jpeg/. It is expected that the next revision -of the TIFF spec will replace the 6.0 JPEG design with the Note's design. -Although IJG's own code does not support TIFF/JPEG, the free libtiff library -uses our library to implement TIFF/JPEG per the Note. libtiff is available -from ftp://ftp.sgi.com/graphics/tiff/. - - -ARCHIVE LOCATIONS -================= - -The "official" archive site for this software is ftp.uu.net (Internet -address 192.48.96.9). The most recent released version can always be found -there in directory graphics/jpeg. This particular version will be archived -as ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz. If you don't have -direct Internet access, UUNET's archives are also available via UUCP; contact -help@uunet.uu.net for information on retrieving files that way. - -Numerous Internet sites maintain copies of the UUNET files. However, only -ftp.uu.net is guaranteed to have the latest official version. - -You can also obtain this software in DOS-compatible "zip" archive format from -the SimTel archives (ftp://ftp.simtel.net/pub/simtelnet/msdos/graphics/), or -on CompuServe in the Graphics Support forum (GO CIS:GRAPHSUP), library 12 -"JPEG Tools". Again, these versions may sometimes lag behind the ftp.uu.net -release. - -The JPEG FAQ (Frequently Asked Questions) article is a useful source of -general information about JPEG. It is updated constantly and therefore is -not included in this distribution. The FAQ is posted every two weeks to -Usenet newsgroups comp.graphics.misc, news.answers, and other groups. -It is available on the World Wide Web at http://www.faqs.org/faqs/jpeg-faq/ -and other news.answers archive sites, including the official news.answers -archive at rtfm.mit.edu: ftp://rtfm.mit.edu/pub/usenet/news.answers/jpeg-faq/. -If you don't have Web or FTP access, send e-mail to mail-server@rtfm.mit.edu -with body - send usenet/news.answers/jpeg-faq/part1 - send usenet/news.answers/jpeg-faq/part2 - - -RELATED SOFTWARE -================ - -Numerous viewing and image manipulation programs now support JPEG. (Quite a -few of them use this library to do so.) The JPEG FAQ described above lists -some of the more popular free and shareware viewers, and tells where to -obtain them on Internet. - -If you are on a Unix machine, we highly recommend Jef Poskanzer's free -PBMPLUS software, which provides many useful operations on PPM-format image -files. In particular, it can convert PPM images to and from a wide range of -other formats, thus making cjpeg/djpeg considerably more useful. The latest -version is distributed by the NetPBM group, and is available from numerous -sites, notably ftp://wuarchive.wustl.edu/graphics/graphics/packages/NetPBM/. -Unfortunately PBMPLUS/NETPBM is not nearly as portable as the IJG software is; -you are likely to have difficulty making it work on any non-Unix machine. - -A different free JPEG implementation, written by the PVRG group at Stanford, -is available from ftp://havefun.stanford.edu/pub/jpeg/. This program -is designed for research and experimentation rather than production use; -it is slower, harder to use, and less portable than the IJG code, but it -is easier to read and modify. Also, the PVRG code supports lossless JPEG, -which we do not. (On the other hand, it doesn't do progressive JPEG.) - - -FILE FORMAT WARS -================ - -Some JPEG programs produce files that are not compatible with our library. -The root of the problem is that the ISO JPEG committee failed to specify a -concrete file format. Some vendors "filled in the blanks" on their own, -creating proprietary formats that no one else could read. (For example, none -of the early commercial JPEG implementations for the Macintosh were able to -exchange compressed files.) - -The file format we have adopted is called JFIF (see REFERENCES). This format -has been agreed to by a number of major commercial JPEG vendors, and it has -become the de facto standard. JFIF is a minimal or "low end" representation. -We recommend the use of TIFF/JPEG (TIFF revision 6.0 as modified by TIFF -Technical Note #2) for "high end" applications that need to record a lot of -additional data about an image. TIFF/JPEG is fairly new and not yet widely -supported, unfortunately. - -The upcoming JPEG Part 3 standard defines a file format called SPIFF. -SPIFF is interoperable with JFIF, in the sense that most JFIF decoders should -be able to read the most common variant of SPIFF. SPIFF has some technical -advantages over JFIF, but its major claim to fame is simply that it is an -official standard rather than an informal one. At this point it is unclear -whether SPIFF will supersede JFIF or whether JFIF will remain the de-facto -standard. IJG intends to support SPIFF once the standard is frozen, but we -have not decided whether it should become our default output format or not. -(In any case, our decoder will remain capable of reading JFIF indefinitely.) - -Various proprietary file formats incorporating JPEG compression also exist. -We have little or no sympathy for the existence of these formats. Indeed, -one of the original reasons for developing this free software was to help -force convergence on common, open format standards for JPEG files. Don't -use a proprietary file format! - - -TO DO -===== - -The major thrust for v7 will probably be improvement of visual quality. -The current method for scaling the quantization tables is known not to be -very good at low Q values. We also intend to investigate block boundary -smoothing, "poor man's variable quantization", and other means of improving -quality-vs-file-size performance without sacrificing compatibility. - -In future versions, we are considering supporting some of the upcoming JPEG -Part 3 extensions --- principally, variable quantization and the SPIFF file -format. - -As always, speeding things up is of great interest. - -Please send bug reports, offers of help, etc. to jpeg-info@uunet.uu.net. diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/Tcdjpeg.c b/irrlicht-1.6/source/Irrlicht/jpeglib/Tcdjpeg.c deleted file mode 100644 index d8667efc7..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/Tcdjpeg.c +++ /dev/null @@ -1,182 +0,0 @@ -#line 1 "cdjpeg.c" -/* - * cdjpeg.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains common support routines used by the IJG application - * programs (cjpeg, djpeg, jpegtran). - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ -#include <ctype.h> /* to declare isupper(), tolower() */ -#ifdef NEED_SIGNAL_CATCHER -#include <signal.h> /* to declare signal() */ -#endif -#ifdef USE_SETMODE -#include <fcntl.h> /* to declare setmode()'s parameter macros */ -/* If you have setmode() but not <io.h>, just delete this line: */ -#include <io.h> /* to declare setmode() */ -#endif - - -/* - * Signal catcher to ensure that temporary files are removed before aborting. - * NB: for Amiga Manx C this is actually a global routine named _abort(); - * we put "#define signal_catcher _abort" in jconfig.h. Talk about bogus... - */ - -#ifdef NEED_SIGNAL_CATCHER - -static j_common_ptr sig_cinfo; - -void /* must be global for Manx C */ -signal_catcher (signum) int signum; -{ - if (sig_cinfo != NULL) { - if (sig_cinfo->err != NULL) /* turn off trace output */ - sig_cinfo->err->trace_level = 0; - jpeg_destroy(sig_cinfo); /* clean up memory allocation & temp files */ - } - exit(EXIT_FAILURE); -} - - -GLOBAL(void) -enable_signal_catcher (cinfo) j_common_ptr cinfo; -{ - sig_cinfo = cinfo; -#ifdef SIGINT /* not all systems have SIGINT */ - signal(SIGINT, signal_catcher); -#endif -#ifdef SIGTERM /* not all systems have SIGTERM */ - signal(SIGTERM, signal_catcher); -#endif -} - -#endif - - -/* - * Optional progress monitor: display a percent-done figure on stderr. - */ - -#ifdef PROGRESS_REPORT - -METHODDEF(void) -progress_monitor (cinfo) j_common_ptr cinfo; -{ - cd_progress_ptr prog = (cd_progress_ptr) cinfo->progress; - int total_passes = prog->pub.total_passes + prog->total_extra_passes; - int percent_done = (int) (prog->pub.pass_counter*100L/prog->pub.pass_limit); - - if (percent_done != prog->percent_done) { - prog->percent_done = percent_done; - if (total_passes > 1) { - fprintf(stderr, "\rPass %d/%d: %3d%% ", - prog->pub.completed_passes + prog->completed_extra_passes + 1, - total_passes, percent_done); - } else { - fprintf(stderr, "\r %3d%% ", percent_done); - } - fflush(stderr); - } -} - - -GLOBAL(void) -start_progress_monitor (cinfo, progress) j_common_ptr cinfo; cd_progress_ptr progress; -{ - /* Enable progress display, unless trace output is on */ - if (cinfo->err->trace_level == 0) { - progress->pub.progress_monitor = progress_monitor; - progress->completed_extra_passes = 0; - progress->total_extra_passes = 0; - progress->percent_done = -1; - cinfo->progress = &progress->pub; - } -} - - -GLOBAL(void) -end_progress_monitor (cinfo) j_common_ptr cinfo; -{ - /* Clear away progress display */ - if (cinfo->err->trace_level == 0) { - fprintf(stderr, "\r \r"); - fflush(stderr); - } -} - -#endif - - -/* - * Case-insensitive matching of possibly-abbreviated keyword switches. - * keyword is the constant keyword (must be lower case already), - * minchars is length of minimum legal abbreviation. - */ - -GLOBAL(boolean) -keymatch (arg, keyword, minchars) char * arg; const char * keyword; int minchars; -{ - register int ca, ck; - register int nmatched = 0; - - while ((ca = *arg++) != '\0') { - if ((ck = *keyword++) == '\0') - return FALSE; /* arg longer than keyword, no good */ - if (isupper(ca)) /* force arg to lcase (assume ck is already) */ - ca = tolower(ca); - if (ca != ck) - return FALSE; /* no good */ - nmatched++; /* count matched characters */ - } - /* reached end of argument; fail if it's too short for unique abbrev */ - if (nmatched < minchars) - return FALSE; - return TRUE; /* A-OK */ -} - - -/* - * Routines to establish binary I/O mode for stdin and stdout. - * Non-Unix systems often require some hacking to get out of text mode. - */ - -GLOBAL(FILE *) -read_stdin () -{ - FILE * input_file = stdin; - -#ifdef USE_SETMODE /* need to hack file mode? */ - setmode(fileno(stdin), O_BINARY); -#endif -#ifdef USE_FDOPEN /* need to re-open in binary mode? */ - if ((input_file = fdopen(fileno(stdin), READ_BINARY)) == NULL) { - fprintf(stderr, "Cannot reopen stdin\n"); - exit(EXIT_FAILURE); - } -#endif - return input_file; -} - - -GLOBAL(FILE *) -write_stdout () -{ - FILE * output_file = stdout; - -#ifdef USE_SETMODE /* need to hack file mode? */ - setmode(fileno(stdout), O_BINARY); -#endif -#ifdef USE_FDOPEN /* need to re-open in binary mode? */ - if ((output_file = fdopen(fileno(stdout), WRITE_BINARY)) == NULL) { - fprintf(stderr, "Cannot reopen stdout\n"); - exit(EXIT_FAILURE); - } -#endif - return output_file; -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/ansi2knr b/irrlicht-1.6/source/Irrlicht/jpeglib/ansi2knr deleted file mode 100644 index 6ae639edf..000000000 Binary files a/irrlicht-1.6/source/Irrlicht/jpeglib/ansi2knr and /dev/null differ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/ansi2knr.1 b/irrlicht-1.6/source/Irrlicht/jpeglib/ansi2knr.1 deleted file mode 100644 index 60b33cf4a..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/ansi2knr.1 +++ /dev/null @@ -1,36 +0,0 @@ -.TH ANSI2KNR 1 "19 Jan 1996" -.SH NAME -ansi2knr \- convert ANSI C to Kernighan & Ritchie C -.SH SYNOPSIS -.I ansi2knr -[--varargs] input_file [output_file] -.SH DESCRIPTION -If no output_file is supplied, output goes to stdout. -.br -There are no error messages. -.sp -.I ansi2knr -recognizes function definitions by seeing a non-keyword identifier at the left -margin, followed by a left parenthesis, with a right parenthesis as the last -character on the line, and with a left brace as the first token on the -following line (ignoring possible intervening comments). It will recognize a -multi-line header provided that no intervening line ends with a left or right -brace or a semicolon. These algorithms ignore whitespace and comments, except -that the function name must be the first thing on the line. -.sp -The following constructs will confuse it: -.br - - Any other construct that starts at the left margin and follows the -above syntax (such as a macro or function call). -.br - - Some macros that tinker with the syntax of the function header. -.sp -The --varargs switch is obsolete, and is recognized only for -backwards compatibility. The present version of -.I ansi2knr -will always attempt to convert a ... argument to va_alist and va_dcl. -.SH AUTHOR -L. Peter Deutsch <ghost@aladdin.com> wrote the original ansi2knr and -continues to maintain the current version; most of the code in the current -version is his work. ansi2knr also includes contributions by Francois -Pinard <pinard@iro.umontreal.ca> and Jim Avera <jima@netcom.com>. diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/ansi2knr.c b/irrlicht-1.6/source/Irrlicht/jpeglib/ansi2knr.c deleted file mode 100644 index 0e3ab134a..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/ansi2knr.c +++ /dev/null @@ -1,693 +0,0 @@ -/* ansi2knr.c */ -/* Convert ANSI C function definitions to K&R ("traditional C") syntax */ - -/* -ansi2knr is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY. No author or distributor accepts responsibility to anyone for the -consequences of using it or for whether it serves any particular purpose or -works at all, unless he says so in writing. Refer to the GNU General Public -License (the "GPL") for full details. - -Everyone is granted permission to copy, modify and redistribute ansi2knr, -but only under the conditions described in the GPL. A copy of this license -is supposed to have been given to you along with ansi2knr so you can know -your rights and responsibilities. It should be in a file named COPYLEFT. -[In the IJG distribution, the GPL appears below, not in a separate file.] -Among other things, the copyright notice and this notice must be preserved -on all copies. - -We explicitly state here what we believe is already implied by the GPL: if -the ansi2knr program is distributed as a separate set of sources and a -separate executable file which are aggregated on a storage medium together -with another program, this in itself does not bring the other program under -the GPL, nor does the mere fact that such a program or the procedures for -constructing it invoke the ansi2knr executable bring any other part of the -program under the GPL. -*/ - -/* ----------- Here is the GNU GPL file COPYLEFT, referred to above ---------- ------ These terms do NOT apply to the JPEG software itself; see README ------ - - GHOSTSCRIPT GENERAL PUBLIC LICENSE - (Clarified 11 Feb 1988) - - Copyright (C) 1988 Richard M. Stallman - Everyone is permitted to copy and distribute verbatim copies of this - license, but changing it is not allowed. You can also use this wording - to make the terms for other programs. - - The license agreements of most software companies keep you at the -mercy of those companies. By contrast, our general public license is -intended to give everyone the right to share Ghostscript. To make sure -that you get the rights we want you to have, we need to make -restrictions that forbid anyone to deny you these rights or to ask you -to surrender the rights. Hence this license agreement. - - Specifically, we want to make sure that you have the right to give -away copies of Ghostscript, that you receive source code or else can get -it if you want it, that you can change Ghostscript or use pieces of it -in new free programs, and that you know you can do these things. - - To make sure that everyone has such rights, we have to forbid you to -deprive anyone else of these rights. For example, if you distribute -copies of Ghostscript, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must tell them their rights. - - Also, for our own protection, we must make certain that everyone finds -out that there is no warranty for Ghostscript. If Ghostscript is -modified by someone else and passed on, we want its recipients to know -that what they have is not what we distributed, so that any problems -introduced by others will not reflect on our reputation. - - Therefore we (Richard M. Stallman and the Free Software Foundation, -Inc.) make the following terms which say what you must do to be allowed -to distribute or change Ghostscript. - - - COPYING POLICIES - - 1. You may copy and distribute verbatim copies of Ghostscript source -code as you receive it, in any medium, provided that you conspicuously -and appropriately publish on each copy a valid copyright and license -notice "Copyright (C) 1989 Aladdin Enterprises. All rights reserved. -Distributed by Free Software Foundation, Inc." (or with whatever year is -appropriate); keep intact the notices on all files that refer to this -License Agreement and to the absence of any warranty; and give any other -recipients of the Ghostscript program a copy of this License Agreement -along with the program. You may charge a distribution fee for the -physical act of transferring a copy. - - 2. You may modify your copy or copies of Ghostscript or any portion of -it, and copy and distribute such modifications under the terms of -Paragraph 1 above, provided that you also do the following: - - a) cause the modified files to carry prominent notices stating - that you changed the files and the date of any change; and - - b) cause the whole of any work that you distribute or publish, - that in whole or in part contains or is a derivative of Ghostscript - or any part thereof, to be licensed at no charge to all third - parties on terms identical to those contained in this License - Agreement (except that you may choose to grant more extensive - warranty protection to some or all third parties, at your option). - - c) You may charge a distribution fee for the physical act of - transferring a copy, and you may at your option offer warranty - protection in exchange for a fee. - -Mere aggregation of another unrelated program with this program (or its -derivative) on a volume of a storage or distribution medium does not bring -the other program under the scope of these terms. - - 3. You may copy and distribute Ghostscript (or a portion or derivative -of it, under Paragraph 2) in object code or executable form under the -terms of Paragraphs 1 and 2 above provided that you also do one of the -following: - - a) accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of - Paragraphs 1 and 2 above; or, - - b) accompany it with a written offer, valid for at least three - years, to give any third party free (except for a nominal - shipping charge) a complete machine-readable copy of the - corresponding source code, to be distributed under the terms of - Paragraphs 1 and 2 above; or, - - c) accompany it with the information you received as to where the - corresponding source code may be obtained. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form alone.) - -For an executable file, complete source code means all the source code for -all modules it contains; but, as a special exception, it need not include -source code for modules which are standard libraries that accompany the -operating system on which the executable file runs. - - 4. You may not copy, sublicense, distribute or transfer Ghostscript -except as expressly provided under this License Agreement. Any attempt -otherwise to copy, sublicense, distribute or transfer Ghostscript is -void and your rights to use the program under this License agreement -shall be automatically terminated. However, parties who have received -computer software programs from you with this License Agreement will not -have their licenses terminated so long as such parties remain in full -compliance. - - 5. If you wish to incorporate parts of Ghostscript into other free -programs whose distribution conditions are different, write to the Free -Software Foundation at 675 Mass Ave, Cambridge, MA 02139. We have not -yet worked out a simple rule that can be stated here, but we will often -permit this. We will be guided by the two goals of preserving the free -status of all derivatives of our free software and of promoting the -sharing and reuse of software. - -Your comments and suggestions about our licensing policies and our -software are welcome! Please contact the Free Software Foundation, -Inc., 675 Mass Ave, Cambridge, MA 02139, or call (617) 876-3296. - - NO WARRANTY - - BECAUSE GHOSTSCRIPT IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY -NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW. EXCEPT -WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC, RICHARD -M. STALLMAN, ALADDIN ENTERPRISES, L. PETER DEUTSCH, AND/OR OTHER PARTIES -PROVIDE GHOSTSCRIPT "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER -EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE -ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF GHOSTSCRIPT IS WITH -YOU. SHOULD GHOSTSCRIPT PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL -NECESSARY SERVICING, REPAIR OR CORRECTION. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M. -STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., L. PETER DEUTSCH, ALADDIN -ENTERPRISES, AND/OR ANY OTHER PARTY WHO MAY MODIFY AND REDISTRIBUTE -GHOSTSCRIPT AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING -ANY LOST PROFITS, LOST MONIES, OR OTHER SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE -(INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED -INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A FAILURE OF THE -PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) GHOSTSCRIPT, EVEN IF YOU -HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM -BY ANY OTHER PARTY. - --------------------- End of file COPYLEFT ------------------------------ -*/ - -/* - * Usage: - ansi2knr input_file [output_file] - * If no output_file is supplied, output goes to stdout. - * There are no error messages. - * - * ansi2knr recognizes function definitions by seeing a non-keyword - * identifier at the left margin, followed by a left parenthesis, - * with a right parenthesis as the last character on the line, - * and with a left brace as the first token on the following line - * (ignoring possible intervening comments). - * It will recognize a multi-line header provided that no intervening - * line ends with a left or right brace or a semicolon. - * These algorithms ignore whitespace and comments, except that - * the function name must be the first thing on the line. - * The following constructs will confuse it: - * - Any other construct that starts at the left margin and - * follows the above syntax (such as a macro or function call). - * - Some macros that tinker with the syntax of the function header. - */ - -/* - * The original and principal author of ansi2knr is L. Peter Deutsch - * <ghost@aladdin.com>. Other authors are noted in the change history - * that follows (in reverse chronological order): - lpd 96-01-21 added code to cope with not HAVE_CONFIG_H and with - compilers that don't understand void, as suggested by - Tom Lane - lpd 96-01-15 changed to require that the first non-comment token - on the line following a function header be a left brace, - to reduce sensitivity to macros, as suggested by Tom Lane - <tgl@sss.pgh.pa.us> - lpd 95-06-22 removed #ifndefs whose sole purpose was to define - undefined preprocessor symbols as 0; changed all #ifdefs - for configuration symbols to #ifs - lpd 95-04-05 changed copyright notice to make it clear that - including ansi2knr in a program does not bring the entire - program under the GPL - lpd 94-12-18 added conditionals for systems where ctype macros - don't handle 8-bit characters properly, suggested by - Francois Pinard <pinard@iro.umontreal.ca>; - removed --varargs switch (this is now the default) - lpd 94-10-10 removed CONFIG_BROKETS conditional - lpd 94-07-16 added some conditionals to help GNU `configure', - suggested by Francois Pinard <pinard@iro.umontreal.ca>; - properly erase prototype args in function parameters, - contributed by Jim Avera <jima@netcom.com>; - correct error in writeblanks (it shouldn't erase EOLs) - lpd 89-xx-xx original version - */ - -/* Most of the conditionals here are to make ansi2knr work with */ -/* or without the GNU configure machinery. */ - -#if HAVE_CONFIG_H -# include <config.h> -#endif - -#include <stdio.h> -#include <ctype.h> - -#if HAVE_CONFIG_H - -/* - For properly autoconfiguring ansi2knr, use AC_CONFIG_HEADER(config.h). - This will define HAVE_CONFIG_H and so, activate the following lines. - */ - -# if STDC_HEADERS || HAVE_STRING_H -# include <string.h> -# else -# include <strings.h> -# endif - -#else /* not HAVE_CONFIG_H */ - -/* Otherwise do it the hard way */ - -# ifdef BSD -# include <strings.h> -# else -# ifdef VMS - extern int strlen(), strncmp(); -# else -# include <string.h> -# endif -# endif - -#endif /* not HAVE_CONFIG_H */ - -#if STDC_HEADERS -# include <stdlib.h> -#else -/* - malloc and free should be declared in stdlib.h, - but if you've got a K&R compiler, they probably aren't. - */ -# ifdef MSDOS -# include <malloc.h> -# else -# ifdef VMS - extern char *malloc(); - extern void free(); -# else - extern char *malloc(); - extern int free(); -# endif -# endif - -#endif - -/* - * The ctype macros don't always handle 8-bit characters correctly. - * Compensate for this here. - */ -#ifdef isascii -# undef HAVE_ISASCII /* just in case */ -# define HAVE_ISASCII 1 -#else -#endif -#if STDC_HEADERS || !HAVE_ISASCII -# define is_ascii(c) 1 -#else -# define is_ascii(c) isascii(c) -#endif - -#define is_space(c) (is_ascii(c) && isspace(c)) -#define is_alpha(c) (is_ascii(c) && isalpha(c)) -#define is_alnum(c) (is_ascii(c) && isalnum(c)) - -/* Scanning macros */ -#define isidchar(ch) (is_alnum(ch) || (ch) == '_') -#define isidfirstchar(ch) (is_alpha(ch) || (ch) == '_') - -/* Forward references */ -char *skipspace(); -int writeblanks(); -int test1(); -int convert1(); - -/* The main program */ -int -main(argc, argv) - int argc; - char *argv[]; -{ FILE *in, *out; -#define bufsize 5000 /* arbitrary size */ - char *buf; - char *line; - char *more; - /* - * In previous versions, ansi2knr recognized a --varargs switch. - * If this switch was supplied, ansi2knr would attempt to convert - * a ... argument to va_alist and va_dcl; if this switch was not - * supplied, ansi2knr would simply drop any such arguments. - * Now, ansi2knr always does this conversion, and we only - * check for this switch for backward compatibility. - */ - int convert_varargs = 1; - - if ( argc > 1 && argv[1][0] == '-' ) - { if ( !strcmp(argv[1], "--varargs") ) - { convert_varargs = 1; - argc--; - argv++; - } - else - { fprintf(stderr, "Unrecognized switch: %s\n", argv[1]); - exit(1); - } - } - switch ( argc ) - { - default: - printf("Usage: ansi2knr input_file [output_file]\n"); - exit(0); - case 2: - out = stdout; - break; - case 3: - out = fopen(argv[2], "w"); - if ( out == NULL ) - { fprintf(stderr, "Cannot open output file %s\n", argv[2]); - exit(1); - } - } - in = fopen(argv[1], "r"); - if ( in == NULL ) - { fprintf(stderr, "Cannot open input file %s\n", argv[1]); - exit(1); - } - fprintf(out, "#line 1 \"%s\"\n", argv[1]); - buf = malloc(bufsize); - line = buf; - while ( fgets(line, (unsigned)(buf + bufsize - line), in) != NULL ) - { -test: line += strlen(line); - switch ( test1(buf) ) - { - case 2: /* a function header */ - convert1(buf, out, 1, convert_varargs); - break; - case 1: /* a function */ - /* Check for a { at the start of the next line. */ - more = ++line; -f: if ( line >= buf + (bufsize - 1) ) /* overflow check */ - goto wl; - if ( fgets(line, (unsigned)(buf + bufsize - line), in) == NULL ) - goto wl; - switch ( *skipspace(more, 1) ) - { - case '{': - /* Definitely a function header. */ - convert1(buf, out, 0, convert_varargs); - fputs(more, out); - break; - case 0: - /* The next line was blank or a comment: */ - /* keep scanning for a non-comment. */ - line += strlen(line); - goto f; - default: - /* buf isn't a function header, but */ - /* more might be. */ - fputs(buf, out); - strcpy(buf, more); - line = buf; - goto test; - } - break; - case -1: /* maybe the start of a function */ - if ( line != buf + (bufsize - 1) ) /* overflow check */ - continue; - /* falls through */ - default: /* not a function */ -wl: fputs(buf, out); - break; - } - line = buf; - } - if ( line != buf ) - fputs(buf, out); - free(buf); - fclose(out); - fclose(in); - return 0; -} - -/* Skip over space and comments, in either direction. */ -char * -skipspace(p, dir) - register char *p; - register int dir; /* 1 for forward, -1 for backward */ -{ for ( ; ; ) - { while ( is_space(*p) ) - p += dir; - if ( !(*p == '/' && p[dir] == '*') ) - break; - p += dir; p += dir; - while ( !(*p == '*' && p[dir] == '/') ) - { if ( *p == 0 ) - return p; /* multi-line comment?? */ - p += dir; - } - p += dir; p += dir; - } - return p; -} - -/* - * Write blanks over part of a string. - * Don't overwrite end-of-line characters. - */ -int -writeblanks(start, end) - char *start; - char *end; -{ char *p; - for ( p = start; p < end; p++ ) - if ( *p != '\r' && *p != '\n' ) - *p = ' '; - return 0; -} - -/* - * Test whether the string in buf is a function definition. - * The string may contain and/or end with a newline. - * Return as follows: - * 0 - definitely not a function definition; - * 1 - definitely a function definition; - * 2 - definitely a function prototype (NOT USED); - * -1 - may be the beginning of a function definition, - * append another line and look again. - * The reason we don't attempt to convert function prototypes is that - * Ghostscript's declaration-generating macros look too much like - * prototypes, and confuse the algorithms. - */ -int -test1(buf) - char *buf; -{ register char *p = buf; - char *bend; - char *endfn; - int contin; - - if ( !isidfirstchar(*p) ) - return 0; /* no name at left margin */ - bend = skipspace(buf + strlen(buf) - 1, -1); - switch ( *bend ) - { - case ';': contin = 0 /*2*/; break; - case ')': contin = 1; break; - case '{': return 0; /* not a function */ - case '}': return 0; /* not a function */ - default: contin = -1; - } - while ( isidchar(*p) ) - p++; - endfn = p; - p = skipspace(p, 1); - if ( *p++ != '(' ) - return 0; /* not a function */ - p = skipspace(p, 1); - if ( *p == ')' ) - return 0; /* no parameters */ - /* Check that the apparent function name isn't a keyword. */ - /* We only need to check for keywords that could be followed */ - /* by a left parenthesis (which, unfortunately, is most of them). */ - { static char *words[] = - { "asm", "auto", "case", "char", "const", "double", - "extern", "float", "for", "if", "int", "long", - "register", "return", "short", "signed", "sizeof", - "static", "switch", "typedef", "unsigned", - "void", "volatile", "while", 0 - }; - char **key = words; - char *kp; - int len = endfn - buf; - - while ( (kp = *key) != 0 ) - { if ( strlen(kp) == len && !strncmp(kp, buf, len) ) - return 0; /* name is a keyword */ - key++; - } - } - return contin; -} - -/* Convert a recognized function definition or header to K&R syntax. */ -int -convert1(buf, out, header, convert_varargs) - char *buf; - FILE *out; - int header; /* Boolean */ - int convert_varargs; /* Boolean */ -{ char *endfn; - register char *p; - char **breaks; - unsigned num_breaks = 2; /* for testing */ - char **btop; - char **bp; - char **ap; - char *vararg = 0; - - /* Pre-ANSI implementations don't agree on whether strchr */ - /* is called strchr or index, so we open-code it here. */ - for ( endfn = buf; *(endfn++) != '('; ) - ; -top: p = endfn; - breaks = (char **)malloc(sizeof(char *) * num_breaks * 2); - if ( breaks == 0 ) - { /* Couldn't allocate break table, give up */ - fprintf(stderr, "Unable to allocate break table!\n"); - fputs(buf, out); - return -1; - } - btop = breaks + num_breaks * 2 - 2; - bp = breaks; - /* Parse the argument list */ - do - { int level = 0; - char *lp = NULL; - char *rp; - char *end = NULL; - - if ( bp >= btop ) - { /* Filled up break table. */ - /* Allocate a bigger one and start over. */ - free((char *)breaks); - num_breaks <<= 1; - goto top; - } - *bp++ = p; - /* Find the end of the argument */ - for ( ; end == NULL; p++ ) - { switch(*p) - { - case ',': - if ( !level ) end = p; - break; - case '(': - if ( !level ) lp = p; - level++; - break; - case ')': - if ( --level < 0 ) end = p; - else rp = p; - break; - case '/': - p = skipspace(p, 1) - 1; - break; - default: - ; - } - } - /* Erase any embedded prototype parameters. */ - if ( lp ) - writeblanks(lp + 1, rp); - p--; /* back up over terminator */ - /* Find the name being declared. */ - /* This is complicated because of procedure and */ - /* array modifiers. */ - for ( ; ; ) - { p = skipspace(p - 1, -1); - switch ( *p ) - { - case ']': /* skip array dimension(s) */ - case ')': /* skip procedure args OR name */ - { int level = 1; - while ( level ) - switch ( *--p ) - { - case ']': case ')': level++; break; - case '[': case '(': level--; break; - case '/': p = skipspace(p, -1) + 1; break; - default: ; - } - } - if ( *p == '(' && *skipspace(p + 1, 1) == '*' ) - { /* We found the name being declared */ - while ( !isidfirstchar(*p) ) - p = skipspace(p, 1) + 1; - goto found; - } - break; - default: - goto found; - } - } -found: if ( *p == '.' && p[-1] == '.' && p[-2] == '.' ) - { if ( convert_varargs ) - { *bp++ = "va_alist"; - vararg = p-2; - } - else - { p++; - if ( bp == breaks + 1 ) /* sole argument */ - writeblanks(breaks[0], p); - else - writeblanks(bp[-1] - 1, p); - bp--; - } - } - else - { while ( isidchar(*p) ) p--; - *bp++ = p+1; - } - p = end; - } - while ( *p++ == ',' ); - *bp = p; - /* Make a special check for 'void' arglist */ - if ( bp == breaks+2 ) - { p = skipspace(breaks[0], 1); - if ( !strncmp(p, "void", 4) ) - { p = skipspace(p+4, 1); - if ( p == breaks[2] - 1 ) - { bp = breaks; /* yup, pretend arglist is empty */ - writeblanks(breaks[0], p + 1); - } - } - } - /* Put out the function name and left parenthesis. */ - p = buf; - while ( p != endfn ) putc(*p, out), p++; - /* Put out the declaration. */ - if ( header ) - { fputs(");", out); - for ( p = breaks[0]; *p; p++ ) - if ( *p == '\r' || *p == '\n' ) - putc(*p, out); - } - else - { for ( ap = breaks+1; ap < bp; ap += 2 ) - { p = *ap; - while ( isidchar(*p) ) - putc(*p, out), p++; - if ( ap < bp - 1 ) - fputs(", ", out); - } - fputs(") ", out); - /* Put out the argument declarations */ - for ( ap = breaks+2; ap <= bp; ap += 2 ) - (*ap)[-1] = ';'; - if ( vararg != 0 ) - { *vararg = 0; - fputs(breaks[0], out); /* any prior args */ - fputs("va_dcl", out); /* the final arg */ - fputs(bp[0], out); - } - else - fputs(breaks[0], out); - } - free((char *)breaks); - return 0; -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/cderror.h b/irrlicht-1.6/source/Irrlicht/jpeglib/cderror.h deleted file mode 100644 index c19d38fb4..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/cderror.h +++ /dev/null @@ -1,132 +0,0 @@ -/* - * cderror.h - * - * Copyright (C) 1994-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file defines the error and message codes for the cjpeg/djpeg - * applications. These strings are not needed as part of the JPEG library - * proper. - * Edit this file to add new codes, or to translate the message strings to - * some other language. - */ - -/* - * To define the enum list of message codes, include this file without - * defining macro JMESSAGE. To create a message string table, include it - * again with a suitable JMESSAGE definition (see jerror.c for an example). - */ -#ifndef JMESSAGE -#ifndef CDERROR_H -#define CDERROR_H -/* First time through, define the enum list */ -#define JMAKE_ENUM_LIST -#else -/* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */ -#define JMESSAGE(code,string) -#endif /* CDERROR_H */ -#endif /* JMESSAGE */ - -#ifdef JMAKE_ENUM_LIST - -typedef enum { - -#define JMESSAGE(code,string) code , - -#endif /* JMAKE_ENUM_LIST */ - -JMESSAGE(JMSG_FIRSTADDONCODE=1000, NULL) /* Must be first entry! */ - -#ifdef BMP_SUPPORTED -JMESSAGE(JERR_BMP_BADCMAP, "Unsupported BMP colormap format") -JMESSAGE(JERR_BMP_BADDEPTH, "Only 8- and 24-bit BMP files are supported") -JMESSAGE(JERR_BMP_BADHEADER, "Invalid BMP file: bad header length") -JMESSAGE(JERR_BMP_BADPLANES, "Invalid BMP file: biPlanes not equal to 1") -JMESSAGE(JERR_BMP_COLORSPACE, "BMP output must be grayscale or RGB") -JMESSAGE(JERR_BMP_COMPRESSED, "Sorry, compressed BMPs not yet supported") -JMESSAGE(JERR_BMP_NOT, "Not a BMP file - does not start with BM") -JMESSAGE(JTRC_BMP, "%ux%u 24-bit BMP image") -JMESSAGE(JTRC_BMP_MAPPED, "%ux%u 8-bit colormapped BMP image") -JMESSAGE(JTRC_BMP_OS2, "%ux%u 24-bit OS2 BMP image") -JMESSAGE(JTRC_BMP_OS2_MAPPED, "%ux%u 8-bit colormapped OS2 BMP image") -#endif /* BMP_SUPPORTED */ - -#ifdef GIF_SUPPORTED -JMESSAGE(JERR_GIF_BUG, "GIF output got confused") -JMESSAGE(JERR_GIF_CODESIZE, "Bogus GIF codesize %d") -JMESSAGE(JERR_GIF_COLORSPACE, "GIF output must be grayscale or RGB") -JMESSAGE(JERR_GIF_IMAGENOTFOUND, "Too few images in GIF file") -JMESSAGE(JERR_GIF_NOT, "Not a GIF file") -JMESSAGE(JTRC_GIF, "%ux%ux%d GIF image") -JMESSAGE(JTRC_GIF_BADVERSION, - "Warning: unexpected GIF version number '%c%c%c'") -JMESSAGE(JTRC_GIF_EXTENSION, "Ignoring GIF extension block of type 0x%02x") -JMESSAGE(JTRC_GIF_NONSQUARE, "Caution: nonsquare pixels in input") -JMESSAGE(JWRN_GIF_BADDATA, "Corrupt data in GIF file") -JMESSAGE(JWRN_GIF_CHAR, "Bogus char 0x%02x in GIF file, ignoring") -JMESSAGE(JWRN_GIF_ENDCODE, "Premature end of GIF image") -JMESSAGE(JWRN_GIF_NOMOREDATA, "Ran out of GIF bits") -#endif /* GIF_SUPPORTED */ - -#ifdef PPM_SUPPORTED -JMESSAGE(JERR_PPM_COLORSPACE, "PPM output must be grayscale or RGB") -JMESSAGE(JERR_PPM_NONNUMERIC, "Nonnumeric data in PPM file") -JMESSAGE(JERR_PPM_NOT, "Not a PPM/PGM file") -JMESSAGE(JTRC_PGM, "%ux%u PGM image") -JMESSAGE(JTRC_PGM_TEXT, "%ux%u text PGM image") -JMESSAGE(JTRC_PPM, "%ux%u PPM image") -JMESSAGE(JTRC_PPM_TEXT, "%ux%u text PPM image") -#endif /* PPM_SUPPORTED */ - -#ifdef RLE_SUPPORTED -JMESSAGE(JERR_RLE_BADERROR, "Bogus error code from RLE library") -JMESSAGE(JERR_RLE_COLORSPACE, "RLE output must be grayscale or RGB") -JMESSAGE(JERR_RLE_DIMENSIONS, "Image dimensions (%ux%u) too large for RLE") -JMESSAGE(JERR_RLE_EMPTY, "Empty RLE file") -JMESSAGE(JERR_RLE_EOF, "Premature EOF in RLE header") -JMESSAGE(JERR_RLE_MEM, "Insufficient memory for RLE header") -JMESSAGE(JERR_RLE_NOT, "Not an RLE file") -JMESSAGE(JERR_RLE_TOOMANYCHANNELS, "Cannot handle %d output channels for RLE") -JMESSAGE(JERR_RLE_UNSUPPORTED, "Cannot handle this RLE setup") -JMESSAGE(JTRC_RLE, "%ux%u full-color RLE file") -JMESSAGE(JTRC_RLE_FULLMAP, "%ux%u full-color RLE file with map of length %d") -JMESSAGE(JTRC_RLE_GRAY, "%ux%u grayscale RLE file") -JMESSAGE(JTRC_RLE_MAPGRAY, "%ux%u grayscale RLE file with map of length %d") -JMESSAGE(JTRC_RLE_MAPPED, "%ux%u colormapped RLE file with map of length %d") -#endif /* RLE_SUPPORTED */ - -#ifdef TARGA_SUPPORTED -JMESSAGE(JERR_TGA_BADCMAP, "Unsupported Targa colormap format") -JMESSAGE(JERR_TGA_BADPARMS, "Invalid or unsupported Targa file") -JMESSAGE(JERR_TGA_COLORSPACE, "Targa output must be grayscale or RGB") -JMESSAGE(JTRC_TGA, "%ux%u RGB Targa image") -JMESSAGE(JTRC_TGA_GRAY, "%ux%u grayscale Targa image") -JMESSAGE(JTRC_TGA_MAPPED, "%ux%u colormapped Targa image") -#else -JMESSAGE(JERR_TGA_NOTCOMP, "Targa support was not compiled") -#endif /* TARGA_SUPPORTED */ - -JMESSAGE(JERR_BAD_CMAP_FILE, - "Color map file is invalid or of unsupported format") -JMESSAGE(JERR_TOO_MANY_COLORS, - "Output file format cannot handle %d colormap entries") -JMESSAGE(JERR_UNGETC_FAILED, "ungetc failed") -#ifdef TARGA_SUPPORTED -JMESSAGE(JERR_UNKNOWN_FORMAT, - "Unrecognized input file format --- perhaps you need -targa") -#else -JMESSAGE(JERR_UNKNOWN_FORMAT, "Unrecognized input file format") -#endif -JMESSAGE(JERR_UNSUPPORTED_FORMAT, "Unsupported output file format") - -#ifdef JMAKE_ENUM_LIST - - JMSG_LASTADDONCODE -} ADDON_MESSAGE_CODE; - -#undef JMAKE_ENUM_LIST -#endif /* JMAKE_ENUM_LIST */ - -/* Zap JMESSAGE macro so that future re-inclusions do nothing by default */ -#undef JMESSAGE diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/cdjpeg.c b/irrlicht-1.6/source/Irrlicht/jpeglib/cdjpeg.c deleted file mode 100644 index 2a1a1c88b..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/cdjpeg.c +++ /dev/null @@ -1,182 +0,0 @@ -/* - * cdjpeg.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains common support routines used by the IJG application - * programs (cjpeg, djpeg, jpegtran). - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ -#include <ctype.h> /* to declare isupper(), tolower() */ -#ifdef NEED_SIGNAL_CATCHER -#include <signal.h> /* to declare signal() */ -#endif -#ifdef USE_SETMODE -dsdsa -#include <fcntl.h> /* to declare setmode()'s parameter macros */ -/* If you have setmode() but not <io.h>, just delete this line: */ -#include <io.h> /* to declare setmode() */ -#endif - - -/* - * Signal catcher to ensure that temporary files are removed before aborting. - * NB: for Amiga Manx C this is actually a global routine named _abort(); - * we put "#define signal_catcher _abort" in jconfig.h. Talk about bogus... - */ - -#ifdef NEED_SIGNAL_CATCHER - -static j_common_ptr sig_cinfo; - -void /* must be global for Manx C */ -signal_catcher (int signum) -{ - if (sig_cinfo != NULL) { - if (sig_cinfo->err != NULL) /* turn off trace output */ - sig_cinfo->err->trace_level = 0; - jpeg_destroy(sig_cinfo); /* clean up memory allocation & temp files */ - } - exit(EXIT_FAILURE); -} - - -GLOBAL(void) -enable_signal_catcher (j_common_ptr cinfo) -{ - sig_cinfo = cinfo; -#ifdef SIGINT /* not all systems have SIGINT */ - signal(SIGINT, signal_catcher); -#endif -#ifdef SIGTERM /* not all systems have SIGTERM */ - signal(SIGTERM, signal_catcher); -#endif -} - -#endif - - -/* - * Optional progress monitor: display a percent-done figure on stderr. - */ - -#ifdef PROGRESS_REPORT - -METHODDEF(void) -progress_monitor (j_common_ptr cinfo) -{ - cd_progress_ptr prog = (cd_progress_ptr) cinfo->progress; - int total_passes = prog->pub.total_passes + prog->total_extra_passes; - int percent_done = (int) (prog->pub.pass_counter*100L/prog->pub.pass_limit); - - if (percent_done != prog->percent_done) { - prog->percent_done = percent_done; - if (total_passes > 1) { - fprintf(stderr, "\rPass %d/%d: %3d%% ", - prog->pub.completed_passes + prog->completed_extra_passes + 1, - total_passes, percent_done); - } else { - fprintf(stderr, "\r %3d%% ", percent_done); - } - fflush(stderr); - } -} - - -GLOBAL(void) -start_progress_monitor (j_common_ptr cinfo, cd_progress_ptr progress) -{ - /* Enable progress display, unless trace output is on */ - if (cinfo->err->trace_level == 0) { - progress->pub.progress_monitor = progress_monitor; - progress->completed_extra_passes = 0; - progress->total_extra_passes = 0; - progress->percent_done = -1; - cinfo->progress = &progress->pub; - } -} - - -GLOBAL(void) -end_progress_monitor (j_common_ptr cinfo) -{ - /* Clear away progress display */ - if (cinfo->err->trace_level == 0) { - fprintf(stderr, "\r \r"); - fflush(stderr); - } -} - -#endif - - -/* - * Case-insensitive matching of possibly-abbreviated keyword switches. - * keyword is the constant keyword (must be lower case already), - * minchars is length of minimum legal abbreviation. - */ - -GLOBAL(boolean) -keymatch (char * arg, const char * keyword, int minchars) -{ - register int ca, ck; - register int nmatched = 0; - - while ((ca = *arg++) != '\0') { - if ((ck = *keyword++) == '\0') - return FALSE; /* arg longer than keyword, no good */ - if (isupper(ca)) /* force arg to lcase (assume ck is already) */ - ca = tolower(ca); - if (ca != ck) - return FALSE; /* no good */ - nmatched++; /* count matched characters */ - } - /* reached end of argument; fail if it's too short for unique abbrev */ - if (nmatched < minchars) - return FALSE; - return TRUE; /* A-OK */ -} - - -/* - * Routines to establish binary I/O mode for stdin and stdout. - * Non-Unix systems often require some hacking to get out of text mode. - */ - -GLOBAL(FILE *) -read_stdin (void) -{ - FILE * input_file = stdin; - -#ifdef USE_SETMODE /* need to hack file mode? */ - setmode(fileno(stdin), O_BINARY); -#endif -#ifdef USE_FDOPEN /* need to re-open in binary mode? */ - if ((input_file = fdopen(fileno(stdin), READ_BINARY)) == NULL) { - fprintf(stderr, "Cannot reopen stdin\n"); - exit(EXIT_FAILURE); - } -#endif - return input_file; -} - - -GLOBAL(FILE *) -write_stdout (void) -{ - FILE * output_file = stdout; - -#ifdef USE_SETMODE /* need to hack file mode? */ - setmode(fileno(stdout), O_BINARY); -#endif -#ifdef USE_FDOPEN /* need to re-open in binary mode? */ - if ((output_file = fdopen(fileno(stdout), WRITE_BINARY)) == NULL) { - fprintf(stderr, "Cannot reopen stdout\n"); - exit(EXIT_FAILURE); - } -#endif - return output_file; -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/cdjpeg.h b/irrlicht-1.6/source/Irrlicht/jpeglib/cdjpeg.h deleted file mode 100644 index e54b86804..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/cdjpeg.h +++ /dev/null @@ -1,184 +0,0 @@ -/* - * cdjpeg.h - * - * Copyright (C) 1994-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains common declarations for the sample applications - * cjpeg and djpeg. It is NOT used by the core JPEG library. - */ - -//#define JPEG_CJPEG_DJPEG /* define proper options in jconfig.h */ -#define JPEG_INTERNAL_OPTIONS /* cjpeg.c,djpeg.c need to see xxx_SUPPORTED */ -#include "jinclude.h" -#include "jpeglib.h" -#include "jerror.h" /* get library error codes too */ -#include "cderror.h" /* get application-specific error codes */ - - -/* - * Object interface for cjpeg's source file decoding modules - */ - -typedef struct cjpeg_source_struct * cjpeg_source_ptr; - -struct cjpeg_source_struct { - JMETHOD(void, start_input, (j_compress_ptr cinfo, - cjpeg_source_ptr sinfo)); - JMETHOD(JDIMENSION, get_pixel_rows, (j_compress_ptr cinfo, - cjpeg_source_ptr sinfo)); - JMETHOD(void, finish_input, (j_compress_ptr cinfo, - cjpeg_source_ptr sinfo)); - - FILE *input_file; - - JSAMPARRAY buffer; - JDIMENSION buffer_height; -}; - - -/* - * Object interface for djpeg's output file encoding modules - */ - -typedef struct djpeg_dest_struct * djpeg_dest_ptr; - -struct djpeg_dest_struct { - /* start_output is called after jpeg_start_decompress finishes. - * The color map will be ready at this time, if one is needed. - */ - JMETHOD(void, start_output, (j_decompress_ptr cinfo, - djpeg_dest_ptr dinfo)); - /* Emit the specified number of pixel rows from the buffer. */ - JMETHOD(void, put_pixel_rows, (j_decompress_ptr cinfo, - djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied)); - /* Finish up at the end of the image. */ - JMETHOD(void, finish_output, (j_decompress_ptr cinfo, - djpeg_dest_ptr dinfo)); - - /* Target file spec; filled in by djpeg.c after object is created. */ - FILE * output_file; - - /* Output pixel-row buffer. Created by module init or start_output. - * Width is cinfo->output_width * cinfo->output_components; - * height is buffer_height. - */ - JSAMPARRAY buffer; - JDIMENSION buffer_height; -}; - - -/* - * cjpeg/djpeg may need to perform extra passes to convert to or from - * the source/destination file format. The JPEG library does not know - * about these passes, but we'd like them to be counted by the progress - * monitor. We use an expanded progress monitor object to hold the - * additional pass count. - */ - -struct cdjpeg_progress_mgr { - struct jpeg_progress_mgr pub; /* fields known to JPEG library */ - int completed_extra_passes; /* extra passes completed */ - int total_extra_passes; /* total extra */ - /* last printed percentage stored here to avoid multiple printouts */ - int percent_done; -}; - -typedef struct cdjpeg_progress_mgr * cd_progress_ptr; - - -/* Short forms of external names for systems with brain-damaged linkers. */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jinit_read_bmp jIRdBMP -#define jinit_write_bmp jIWrBMP -#define jinit_read_gif jIRdGIF -#define jinit_write_gif jIWrGIF -#define jinit_read_ppm jIRdPPM -#define jinit_write_ppm jIWrPPM -#define jinit_read_rle jIRdRLE -#define jinit_write_rle jIWrRLE -#define jinit_read_targa jIRdTarga -#define jinit_write_targa jIWrTarga -#define read_quant_tables RdQTables -#define read_scan_script RdScnScript -#define set_quant_slots SetQSlots -#define set_sample_factors SetSFacts -#define read_color_map RdCMap -#define enable_signal_catcher EnSigCatcher -#define start_progress_monitor StProgMon -#define end_progress_monitor EnProgMon -#define read_stdin RdStdin -#define write_stdout WrStdout -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - -/* Module selection routines for I/O modules. */ - -EXTERN(cjpeg_source_ptr) jinit_read_bmp JPP((j_compress_ptr cinfo)); -EXTERN(djpeg_dest_ptr) jinit_write_bmp JPP((j_decompress_ptr cinfo, - boolean is_os2)); -EXTERN(cjpeg_source_ptr) jinit_read_gif JPP((j_compress_ptr cinfo)); -EXTERN(djpeg_dest_ptr) jinit_write_gif JPP((j_decompress_ptr cinfo)); -EXTERN(cjpeg_source_ptr) jinit_read_ppm JPP((j_compress_ptr cinfo)); -EXTERN(djpeg_dest_ptr) jinit_write_ppm JPP((j_decompress_ptr cinfo)); -EXTERN(cjpeg_source_ptr) jinit_read_rle JPP((j_compress_ptr cinfo)); -EXTERN(djpeg_dest_ptr) jinit_write_rle JPP((j_decompress_ptr cinfo)); -EXTERN(cjpeg_source_ptr) jinit_read_targa JPP((j_compress_ptr cinfo)); -EXTERN(djpeg_dest_ptr) jinit_write_targa JPP((j_decompress_ptr cinfo)); - -/* cjpeg support routines (in rdswitch.c) */ - -EXTERN(boolean) read_quant_tables JPP((j_compress_ptr cinfo, char * filename, - int scale_factor, boolean force_baseline)); -EXTERN(boolean) read_scan_script JPP((j_compress_ptr cinfo, char * filename)); -EXTERN(boolean) set_quant_slots JPP((j_compress_ptr cinfo, char *arg)); -EXTERN(boolean) set_sample_factors JPP((j_compress_ptr cinfo, char *arg)); - -/* djpeg support routines (in rdcolmap.c) */ - -EXTERN(void) read_color_map JPP((j_decompress_ptr cinfo, FILE * infile)); - -/* common support routines (in cdjpeg.c) */ - -EXTERN(void) enable_signal_catcher JPP((j_common_ptr cinfo)); -EXTERN(void) start_progress_monitor JPP((j_common_ptr cinfo, - cd_progress_ptr progress)); -EXTERN(void) end_progress_monitor JPP((j_common_ptr cinfo)); -EXTERN(boolean) keymatch JPP((char * arg, const char * keyword, int minchars)); -EXTERN(FILE *) read_stdin JPP((void)); -EXTERN(FILE *) write_stdout JPP((void)); - -/* miscellaneous useful macros */ - -#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ -#define READ_BINARY "r" -#define WRITE_BINARY "w" -#else -#ifdef VMS /* VMS is very nonstandard */ -#define READ_BINARY "rb", "ctx=stm" -#define WRITE_BINARY "wb", "ctx=stm" -#else /* standard ANSI-compliant case */ -#define READ_BINARY "rb" -#define WRITE_BINARY "wb" -#endif -#endif - -#ifndef EXIT_FAILURE /* define exit() codes if not provided */ -#define EXIT_FAILURE 1 -#endif -#ifndef EXIT_SUCCESS -#ifdef VMS -#define EXIT_SUCCESS 1 /* VMS is very nonstandard */ -#else -#define EXIT_SUCCESS 0 -#endif -#endif -#ifndef EXIT_WARNING -#ifdef VMS -#define EXIT_WARNING 1 /* VMS is very nonstandard */ -#else -#define EXIT_WARNING 2 -#endif -#endif diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/change.log b/irrlicht-1.6/source/Irrlicht/jpeglib/change.log deleted file mode 100644 index 953680c91..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/change.log +++ /dev/null @@ -1,217 +0,0 @@ -CHANGE LOG for Independent JPEG Group's JPEG software - - -Version 6b 27-Mar-1998 ------------------------ - -jpegtran has new features for lossless image transformations (rotation -and flipping) as well as "lossless" reduction to grayscale. - -jpegtran now copies comments by default; it has a -copy switch to enable -copying all APPn blocks as well, or to suppress comments. (Formerly it -always suppressed comments and APPn blocks.) jpegtran now also preserves -JFIF version and resolution information. - -New decompressor library feature: COM and APPn markers found in the input -file can be saved in memory for later use by the application. (Before, -you had to code this up yourself with a custom marker processor.) - -There is an unused field "void * client_data" now in compress and decompress -parameter structs; this may be useful in some applications. - -JFIF version number information is now saved by the decoder and accepted by -the encoder. jpegtran uses this to copy the source file's version number, -to ensure "jpegtran -copy all" won't create bogus files that contain JFXX -extensions but claim to be version 1.01. Applications that generate their -own JFXX extension markers also (finally) have a supported way to cause the -encoder to emit JFIF version number 1.02. - -djpeg's trace mode reports JFIF 1.02 thumbnail images as such, rather -than as unknown APP0 markers. - -In -verbose mode, djpeg and rdjpgcom will try to print the contents of -APP12 markers as text. Some digital cameras store useful text information -in APP12 markers. - -Handling of truncated data streams is more robust: blocks beyond the one in -which the error occurs will be output as uniform gray, or left unchanged -if decoding a progressive JPEG. The appearance no longer depends on the -Huffman tables being used. - -Huffman tables are checked for validity much more carefully than before. - -To avoid the Unisys LZW patent, djpeg's GIF output capability has been -changed to produce "uncompressed GIFs", and cjpeg's GIF input capability -has been removed altogether. We're not happy about it either, but there -seems to be no good alternative. - -The configure script now supports building libjpeg as a shared library -on many flavors of Unix (all the ones that GNU libtool knows how to -build shared libraries for). Use "./configure --enable-shared" to -try this out. - -New jconfig file and makefiles for Microsoft Visual C++ and Developer Studio. -Also, a jconfig file and a build script for Metrowerks CodeWarrior -on Apple Macintosh. makefile.dj has been updated for DJGPP v2, and there -are miscellaneous other minor improvements in the makefiles. - -jmemmac.c now knows how to create temporary files following Mac System 7 -conventions. - -djpeg's -map switch is now able to read raw-format PPM files reliably. - -cjpeg -progressive -restart no longer generates any unnecessary DRI markers. - -Multiple calls to jpeg_simple_progression for a single JPEG object -no longer leak memory. - - -Version 6a 7-Feb-96 --------------------- - -Library initialization sequence modified to detect version mismatches -and struct field packing mismatches between library and calling application. -This change requires applications to be recompiled, but does not require -any application source code change. - -All routine declarations changed to the style "GLOBAL(type) name ...", -that is, GLOBAL, LOCAL, METHODDEF, EXTERN are now macros taking the -routine's return type as an argument. This makes it possible to add -Microsoft-style linkage keywords to all the routines by changing just -these macros. Note that any application code that was using these macros -will have to be changed. - -DCT coefficient quantization tables are now stored in normal array order -rather than zigzag order. Application code that calls jpeg_add_quant_table, -or otherwise manipulates quantization tables directly, will need to be -changed. If you need to make such code work with either older or newer -versions of the library, a test like "#if JPEG_LIB_VERSION >= 61" is -recommended. - -djpeg's trace capability now dumps DQT tables in natural order, not zigzag -order. This allows the trace output to be made into a "-qtables" file -more easily. - -New system-dependent memory manager module for use on Apple Macintosh. - -Fix bug in cjpeg's -smooth option: last one or two scanlines would be -duplicates of the prior line unless the image height mod 16 was 1 or 2. - -Repair minor problems in VMS, BCC, MC6 makefiles. - -New configure script based on latest GNU Autoconf. - -Correct the list of include files needed by MetroWerks C for ccommand(). - -Numerous small documentation updates. - - -Version 6 2-Aug-95 -------------------- - -Progressive JPEG support: library can read and write full progressive JPEG -files. A "buffered image" mode supports incremental decoding for on-the-fly -display of progressive images. Simply recompiling an existing IJG-v5-based -decoder with v6 should allow it to read progressive files, though of course -without any special progressive display. - -New "jpegtran" application performs lossless transcoding between different -JPEG formats; primarily, it can be used to convert baseline to progressive -JPEG and vice versa. In support of jpegtran, the library now allows lossless -reading and writing of JPEG files as DCT coefficient arrays. This ability -may be of use in other applications. - -Notes for programmers: -* We changed jpeg_start_decompress() to be able to suspend; this makes all -decoding modes available to suspending-input applications. However, -existing applications that use suspending input will need to be changed -to check the return value from jpeg_start_decompress(). You don't need to -do anything if you don't use a suspending data source. -* We changed the interface to the virtual array routines: access_virt_array -routines now take a count of the number of rows to access this time. The -last parameter to request_virt_array routines is now interpreted as the -maximum number of rows that may be accessed at once, but not necessarily -the height of every access. - - -Version 5b 15-Mar-95 ---------------------- - -Correct bugs with grayscale images having v_samp_factor > 1. - -jpeg_write_raw_data() now supports output suspension. - -Correct bugs in "configure" script for case of compiling in -a directory other than the one containing the source files. - -Repair bug in jquant1.c: sometimes didn't use as many colors as it could. - -Borland C makefile and jconfig file work under either MS-DOS or OS/2. - -Miscellaneous improvements to documentation. - - -Version 5a 7-Dec-94 --------------------- - -Changed color conversion roundoff behavior so that grayscale values are -represented exactly. (This causes test image files to change.) - -Make ordered dither use 16x16 instead of 4x4 pattern for a small quality -improvement. - -New configure script based on latest GNU Autoconf. -Fix configure script to handle CFLAGS correctly. -Rename *.auto files to *.cfg, so that configure script still works if -file names have been truncated for DOS. - -Fix bug in rdbmp.c: didn't allow for extra data between header and image. - -Modify rdppm.c/wrppm.c to handle 2-byte raw PPM/PGM formats for 12-bit data. - -Fix several bugs in rdrle.c. - -NEED_SHORT_EXTERNAL_NAMES option was broken. - -Revise jerror.h/jerror.c for more flexibility in message table. - -Repair oversight in jmemname.c NO_MKTEMP case: file could be there -but unreadable. - - -Version 5 24-Sep-94 --------------------- - -Version 5 represents a nearly complete redesign and rewrite of the IJG -software. Major user-visible changes include: - * Automatic configuration simplifies installation for most Unix systems. - * A range of speed vs. image quality tradeoffs are supported. - This includes resizing of an image during decompression: scaling down - by a factor of 1/2, 1/4, or 1/8 is handled very efficiently. - * New programs rdjpgcom and wrjpgcom allow insertion and extraction - of text comments in a JPEG file. - -The application programmer's interface to the library has changed completely. -Notable improvements include: - * We have eliminated the use of callback routines for handling the - uncompressed image data. The application now sees the library as a - set of routines that it calls to read or write image data on a - scanline-by-scanline basis. - * The application image data is represented in a conventional interleaved- - pixel format, rather than as a separate array for each color channel. - This can save a copying step in many programs. - * The handling of compressed data has been cleaned up: the application can - supply routines to source or sink the compressed data. It is possible to - suspend processing on source/sink buffer overrun, although this is not - supported in all operating modes. - * All static state has been eliminated from the library, so that multiple - instances of compression or decompression can be active concurrently. - * JPEG abbreviated datastream formats are supported, ie, quantization and - Huffman tables can be stored separately from the image data. - * And not only that, but the documentation of the library has improved - considerably! - - -The last widely used release before the version 5 rewrite was version 4A of -18-Feb-93. Change logs before that point have been discarded, since they -are not of much interest after the rewrite. diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/cjpeg.1 b/irrlicht-1.6/source/Irrlicht/jpeglib/cjpeg.1 deleted file mode 100644 index cf6a5b2e6..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/cjpeg.1 +++ /dev/null @@ -1,292 +0,0 @@ -.TH CJPEG 1 "20 March 1998" -.SH NAME -cjpeg \- compress an image file to a JPEG file -.SH SYNOPSIS -.B cjpeg -[ -.I options -] -[ -.I filename -] -.LP -.SH DESCRIPTION -.LP -.B cjpeg -compresses the named image file, or the standard input if no file is -named, and produces a JPEG/JFIF file on the standard output. -The currently supported input file formats are: PPM (PBMPLUS color -format), PGM (PBMPLUS gray-scale format), BMP, Targa, and RLE (Utah Raster -Toolkit format). (RLE is supported only if the URT library is available.) -.SH OPTIONS -All switch names may be abbreviated; for example, -.B \-grayscale -may be written -.B \-gray -or -.BR \-gr . -Most of the "basic" switches can be abbreviated to as little as one letter. -Upper and lower case are equivalent (thus -.B \-BMP -is the same as -.BR \-bmp ). -British spellings are also accepted (e.g., -.BR \-greyscale ), -though for brevity these are not mentioned below. -.PP -The basic switches are: -.TP -.BI \-quality " N" -Scale quantization tables to adjust image quality. Quality is 0 (worst) to -100 (best); default is 75. (See below for more info.) -.TP -.B \-grayscale -Create monochrome JPEG file from color input. Be sure to use this switch when -compressing a grayscale BMP file, because -.B cjpeg -isn't bright enough to notice whether a BMP file uses only shades of gray. -By saying -.BR \-grayscale , -you'll get a smaller JPEG file that takes less time to process. -.TP -.B \-optimize -Perform optimization of entropy encoding parameters. Without this, default -encoding parameters are used. -.B \-optimize -usually makes the JPEG file a little smaller, but -.B cjpeg -runs somewhat slower and needs much more memory. Image quality and speed of -decompression are unaffected by -.BR \-optimize . -.TP -.B \-progressive -Create progressive JPEG file (see below). -.TP -.B \-targa -Input file is Targa format. Targa files that contain an "identification" -field will not be automatically recognized by -.BR cjpeg ; -for such files you must specify -.B \-targa -to make -.B cjpeg -treat the input as Targa format. -For most Targa files, you won't need this switch. -.PP -The -.B \-quality -switch lets you trade off compressed file size against quality of the -reconstructed image: the higher the quality setting, the larger the JPEG file, -and the closer the output image will be to the original input. Normally you -want to use the lowest quality setting (smallest file) that decompresses into -something visually indistinguishable from the original image. For this -purpose the quality setting should be between 50 and 95; the default of 75 is -often about right. If you see defects at -.B \-quality -75, then go up 5 or 10 counts at a time until you are happy with the output -image. (The optimal setting will vary from one image to another.) -.PP -.B \-quality -100 will generate a quantization table of all 1's, minimizing loss in the -quantization step (but there is still information loss in subsampling, as well -as roundoff error). This setting is mainly of interest for experimental -purposes. Quality values above about 95 are -.B not -recommended for normal use; the compressed file size goes up dramatically for -hardly any gain in output image quality. -.PP -In the other direction, quality values below 50 will produce very small files -of low image quality. Settings around 5 to 10 might be useful in preparing an -index of a large image library, for example. Try -.B \-quality -2 (or so) for some amusing Cubist effects. (Note: quality -values below about 25 generate 2-byte quantization tables, which are -considered optional in the JPEG standard. -.B cjpeg -emits a warning message when you give such a quality value, because some -other JPEG programs may be unable to decode the resulting file. Use -.B \-baseline -if you need to ensure compatibility at low quality values.) -.PP -The -.B \-progressive -switch creates a "progressive JPEG" file. In this type of JPEG file, the data -is stored in multiple scans of increasing quality. If the file is being -transmitted over a slow communications link, the decoder can use the first -scan to display a low-quality image very quickly, and can then improve the -display with each subsequent scan. The final image is exactly equivalent to a -standard JPEG file of the same quality setting, and the total file size is -about the same --- often a little smaller. -.B Caution: -progressive JPEG is not yet widely implemented, so many decoders will be -unable to view a progressive JPEG file at all. -.PP -Switches for advanced users: -.TP -.B \-dct int -Use integer DCT method (default). -.TP -.B \-dct fast -Use fast integer DCT (less accurate). -.TP -.B \-dct float -Use floating-point DCT method. -The float method is very slightly more accurate than the int method, but is -much slower unless your machine has very fast floating-point hardware. Also -note that results of the floating-point method may vary slightly across -machines, while the integer methods should give the same results everywhere. -The fast integer method is much less accurate than the other two. -.TP -.BI \-restart " N" -Emit a JPEG restart marker every N MCU rows, or every N MCU blocks if "B" is -attached to the number. -.B \-restart 0 -(the default) means no restart markers. -.TP -.BI \-smooth " N" -Smooth the input image to eliminate dithering noise. N, ranging from 1 to -100, indicates the strength of smoothing. 0 (the default) means no smoothing. -.TP -.BI \-maxmemory " N" -Set limit for amount of memory to use in processing large images. Value is -in thousands of bytes, or millions of bytes if "M" is attached to the -number. For example, -.B \-max 4m -selects 4000000 bytes. If more space is needed, temporary files will be used. -.TP -.BI \-outfile " name" -Send output image to the named file, not to standard output. -.TP -.B \-verbose -Enable debug printout. More -.BR \-v 's -give more output. Also, version information is printed at startup. -.TP -.B \-debug -Same as -.BR \-verbose . -.PP -The -.B \-restart -option inserts extra markers that allow a JPEG decoder to resynchronize after -a transmission error. Without restart markers, any damage to a compressed -file will usually ruin the image from the point of the error to the end of the -image; with restart markers, the damage is usually confined to the portion of -the image up to the next restart marker. Of course, the restart markers -occupy extra space. We recommend -.B \-restart 1 -for images that will be transmitted across unreliable networks such as Usenet. -.PP -The -.B \-smooth -option filters the input to eliminate fine-scale noise. This is often useful -when converting dithered images to JPEG: a moderate smoothing factor of 10 to -50 gets rid of dithering patterns in the input file, resulting in a smaller -JPEG file and a better-looking image. Too large a smoothing factor will -visibly blur the image, however. -.PP -Switches for wizards: -.TP -.B \-baseline -Force baseline-compatible quantization tables to be generated. This clamps -quantization values to 8 bits even at low quality settings. (This switch is -poorly named, since it does not ensure that the output is actually baseline -JPEG. For example, you can use -.B \-baseline -and -.B \-progressive -together.) -.TP -.BI \-qtables " file" -Use the quantization tables given in the specified text file. -.TP -.BI \-qslots " N[,...]" -Select which quantization table to use for each color component. -.TP -.BI \-sample " HxV[,...]" -Set JPEG sampling factors for each color component. -.TP -.BI \-scans " file" -Use the scan script given in the specified text file. -.PP -The "wizard" switches are intended for experimentation with JPEG. If you -don't know what you are doing, \fBdon't use them\fR. These switches are -documented further in the file wizard.doc. -.SH EXAMPLES -.LP -This example compresses the PPM file foo.ppm with a quality factor of -60 and saves the output as foo.jpg: -.IP -.B cjpeg \-quality -.I 60 foo.ppm -.B > -.I foo.jpg -.SH HINTS -Color GIF files are not the ideal input for JPEG; JPEG is really intended for -compressing full-color (24-bit) images. In particular, don't try to convert -cartoons, line drawings, and other images that have only a few distinct -colors. GIF works great on these, JPEG does not. If you want to convert a -GIF to JPEG, you should experiment with -.BR cjpeg 's -.B \-quality -and -.B \-smooth -options to get a satisfactory conversion. -.B \-smooth 10 -or so is often helpful. -.PP -Avoid running an image through a series of JPEG compression/decompression -cycles. Image quality loss will accumulate; after ten or so cycles the image -may be noticeably worse than it was after one cycle. It's best to use a -lossless format while manipulating an image, then convert to JPEG format when -you are ready to file the image away. -.PP -The -.B \-optimize -option to -.B cjpeg -is worth using when you are making a "final" version for posting or archiving. -It's also a win when you are using low quality settings to make very small -JPEG files; the percentage improvement is often a lot more than it is on -larger files. (At present, -.B \-optimize -mode is always selected when generating progressive JPEG files.) -.SH ENVIRONMENT -.TP -.B JPEGMEM -If this environment variable is set, its value is the default memory limit. -The value is specified as described for the -.B \-maxmemory -switch. -.B JPEGMEM -overrides the default value specified when the program was compiled, and -itself is overridden by an explicit -.BR \-maxmemory . -.SH SEE ALSO -.BR djpeg (1), -.BR jpegtran (1), -.BR rdjpgcom (1), -.BR wrjpgcom (1) -.br -.BR ppm (5), -.BR pgm (5) -.br -Wallace, Gregory K. "The JPEG Still Picture Compression Standard", -Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44. -.SH AUTHOR -Independent JPEG Group -.SH BUGS -Arithmetic coding is not supported for legal reasons. -.PP -GIF input files are no longer supported, to avoid the Unisys LZW patent. -Use a Unisys-licensed program if you need to read a GIF file. (Conversion -of GIF files to JPEG is usually a bad idea anyway.) -.PP -Not all variants of BMP and Targa file formats are supported. -.PP -The -.B \-targa -switch is not a bug, it's a feature. (It would be a bug if the Targa format -designers had not been clueless.) -.PP -Still not as fast as we'd like. diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/cjpeg.c b/irrlicht-1.6/source/Irrlicht/jpeglib/cjpeg.c deleted file mode 100644 index b9102ee9c..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/cjpeg.c +++ /dev/null @@ -1,606 +0,0 @@ -/* - * cjpeg.c - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a command-line user interface for the JPEG compressor. - * It should work on any system with Unix- or MS-DOS-style command lines. - * - * Two different command line styles are permitted, depending on the - * compile-time switch TWO_FILE_COMMANDLINE: - * cjpeg [options] inputfile outputfile - * cjpeg [options] [inputfile] - * In the second style, output is always to standard output, which you'd - * normally redirect to a file or pipe to some other program. Input is - * either from a named file or from standard input (typically redirected). - * The second style is convenient on Unix but is unhelpful on systems that - * don't support pipes. Also, you MUST use the first style if your system - * doesn't do binary I/O to stdin/stdout. - * To simplify script writing, the "-outfile" switch is provided. The syntax - * cjpeg [options] -outfile outputfile inputfile - * works regardless of which command line style is used. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ -#include "jversion.h" /* for version message */ - -#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ -#ifdef __MWERKS__ -#include <SIOUX.h> /* Metrowerks needs this */ -#include <console.h> /* ... and this */ -#endif -#ifdef THINK_C -#include <console.h> /* Think declares it here */ -#endif -#endif - - -/* Create the add-on message string table. */ - -#define JMESSAGE(code,string) string , - -static const char * const cdjpeg_message_table[] = { -#include "cderror.h" - NULL -}; - - -/* - * This routine determines what format the input file is, - * and selects the appropriate input-reading module. - * - * To determine which family of input formats the file belongs to, - * we may look only at the first byte of the file, since C does not - * guarantee that more than one character can be pushed back with ungetc. - * Looking at additional bytes would require one of these approaches: - * 1) assume we can fseek() the input file (fails for piped input); - * 2) assume we can push back more than one character (works in - * some C implementations, but unportable); - * 3) provide our own buffering (breaks input readers that want to use - * stdio directly, such as the RLE library); - * or 4) don't put back the data, and modify the input_init methods to assume - * they start reading after the start of file (also breaks RLE library). - * #1 is attractive for MS-DOS but is untenable on Unix. - * - * The most portable solution for file types that can't be identified by their - * first byte is to make the user tell us what they are. This is also the - * only approach for "raw" file types that contain only arbitrary values. - * We presently apply this method for Targa files. Most of the time Targa - * files start with 0x00, so we recognize that case. Potentially, however, - * a Targa file could start with any byte value (byte 0 is the length of the - * seldom-used ID field), so we provide a switch to force Targa input mode. - */ - -static boolean is_targa; /* records user -targa switch */ - - -LOCAL(cjpeg_source_ptr) -select_file_type (j_compress_ptr cinfo, FILE * infile) -{ - int c; - - if (is_targa) { -#ifdef TARGA_SUPPORTED - return jinit_read_targa(cinfo); -#else - ERREXIT(cinfo, JERR_TGA_NOTCOMP); -#endif - } - - if ((c = getc(infile)) == EOF) - ERREXIT(cinfo, JERR_INPUT_EMPTY); - if (ungetc(c, infile) == EOF) - ERREXIT(cinfo, JERR_UNGETC_FAILED); - - switch (c) { -#ifdef BMP_SUPPORTED - case 'B': - return jinit_read_bmp(cinfo); -#endif -#ifdef GIF_SUPPORTED - case 'G': - return jinit_read_gif(cinfo); -#endif -#ifdef PPM_SUPPORTED - case 'P': - return jinit_read_ppm(cinfo); -#endif -#ifdef RLE_SUPPORTED - case 'R': - return jinit_read_rle(cinfo); -#endif -#ifdef TARGA_SUPPORTED - case 0x00: - return jinit_read_targa(cinfo); -#endif - default: - ERREXIT(cinfo, JERR_UNKNOWN_FORMAT); - break; - } - - return NULL; /* suppress compiler warnings */ -} - - -/* - * Argument-parsing code. - * The switch parser is designed to be useful with DOS-style command line - * syntax, ie, intermixed switches and file names, where only the switches - * to the left of a given file name affect processing of that file. - * The main program in this file doesn't actually use this capability... - */ - - -static const char * progname; /* program name for error messages */ -static char * outfilename; /* for -outfile switch */ - - -LOCAL(void) -usage (void) -/* complain about bad command line */ -{ - fprintf(stderr, "usage: %s [switches] ", progname); -#ifdef TWO_FILE_COMMANDLINE - fprintf(stderr, "inputfile outputfile\n"); -#else - fprintf(stderr, "[inputfile]\n"); -#endif - - fprintf(stderr, "Switches (names may be abbreviated):\n"); - fprintf(stderr, " -quality N Compression quality (0..100; 5-95 is useful range)\n"); - fprintf(stderr, " -grayscale Create monochrome JPEG file\n"); -#ifdef ENTROPY_OPT_SUPPORTED - fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but slow compression)\n"); -#endif -#ifdef C_PROGRESSIVE_SUPPORTED - fprintf(stderr, " -progressive Create progressive JPEG file\n"); -#endif -#ifdef TARGA_SUPPORTED - fprintf(stderr, " -targa Input file is Targa format (usually not needed)\n"); -#endif - fprintf(stderr, "Switches for advanced users:\n"); -#ifdef DCT_ISLOW_SUPPORTED - fprintf(stderr, " -dct int Use integer DCT method%s\n", - (JDCT_DEFAULT == JDCT_ISLOW ? " (default)" : "")); -#endif -#ifdef DCT_IFAST_SUPPORTED - fprintf(stderr, " -dct fast Use fast integer DCT (less accurate)%s\n", - (JDCT_DEFAULT == JDCT_IFAST ? " (default)" : "")); -#endif -#ifdef DCT_FLOAT_SUPPORTED - fprintf(stderr, " -dct float Use floating-point DCT method%s\n", - (JDCT_DEFAULT == JDCT_FLOAT ? " (default)" : "")); -#endif - fprintf(stderr, " -restart N Set restart interval in rows, or in blocks with B\n"); -#ifdef INPUT_SMOOTHING_SUPPORTED - fprintf(stderr, " -smooth N Smooth dithered input (N=1..100 is strength)\n"); -#endif - fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n"); - fprintf(stderr, " -outfile name Specify name for output file\n"); - fprintf(stderr, " -verbose or -debug Emit debug output\n"); - fprintf(stderr, "Switches for wizards:\n"); -#ifdef C_ARITH_CODING_SUPPORTED - fprintf(stderr, " -arithmetic Use arithmetic coding\n"); -#endif - fprintf(stderr, " -baseline Force baseline quantization tables\n"); - fprintf(stderr, " -qtables file Use quantization tables given in file\n"); - fprintf(stderr, " -qslots N[,...] Set component quantization tables\n"); - fprintf(stderr, " -sample HxV[,...] Set component sampling factors\n"); -#ifdef C_MULTISCAN_FILES_SUPPORTED - fprintf(stderr, " -scans file Create multi-scan JPEG per script file\n"); -#endif - exit(EXIT_FAILURE); -} - - -LOCAL(int) -parse_switches (j_compress_ptr cinfo, int argc, char **argv, - int last_file_arg_seen, boolean for_real) -/* Parse optional switches. - * Returns argv[] index of first file-name argument (== argc if none). - * Any file names with indexes <= last_file_arg_seen are ignored; - * they have presumably been processed in a previous iteration. - * (Pass 0 for last_file_arg_seen on the first or only iteration.) - * for_real is FALSE on the first (dummy) pass; we may skip any expensive - * processing. - */ -{ - int argn; - char * arg; - int quality; /* -quality parameter */ - int q_scale_factor; /* scaling percentage for -qtables */ - boolean force_baseline; - boolean simple_progressive; - char * qtablefile = NULL; /* saves -qtables filename if any */ - char * qslotsarg = NULL; /* saves -qslots parm if any */ - char * samplearg = NULL; /* saves -sample parm if any */ - char * scansarg = NULL; /* saves -scans parm if any */ - - /* Set up default JPEG parameters. */ - /* Note that default -quality level need not, and does not, - * match the default scaling for an explicit -qtables argument. - */ - quality = 75; /* default -quality value */ - q_scale_factor = 100; /* default to no scaling for -qtables */ - force_baseline = FALSE; /* by default, allow 16-bit quantizers */ - simple_progressive = FALSE; - is_targa = FALSE; - outfilename = NULL; - cinfo->err->trace_level = 0; - - /* Scan command line options, adjust parameters */ - - for (argn = 1; argn < argc; argn++) { - arg = argv[argn]; - if (*arg != '-') { - /* Not a switch, must be a file name argument */ - if (argn <= last_file_arg_seen) { - outfilename = NULL; /* -outfile applies to just one input file */ - continue; /* ignore this name if previously processed */ - } - break; /* else done parsing switches */ - } - arg++; /* advance past switch marker character */ - - if (keymatch(arg, "arithmetic", 1)) { - /* Use arithmetic coding. */ -#ifdef C_ARITH_CODING_SUPPORTED - cinfo->arith_code = TRUE; -#else - fprintf(stderr, "%s: sorry, arithmetic coding not supported\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "baseline", 1)) { - /* Force baseline-compatible output (8-bit quantizer values). */ - force_baseline = TRUE; - - } else if (keymatch(arg, "dct", 2)) { - /* Select DCT algorithm. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (keymatch(argv[argn], "int", 1)) { - cinfo->dct_method = JDCT_ISLOW; - } else if (keymatch(argv[argn], "fast", 2)) { - cinfo->dct_method = JDCT_IFAST; - } else if (keymatch(argv[argn], "float", 2)) { - cinfo->dct_method = JDCT_FLOAT; - } else - usage(); - - } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) { - /* Enable debug printouts. */ - /* On first -d, print version identification */ - static boolean printed_version = FALSE; - - if (! printed_version) { - fprintf(stderr, "Independent JPEG Group's CJPEG, version %s\n%s\n", - JVERSION, JCOPYRIGHT); - printed_version = TRUE; - } - cinfo->err->trace_level++; - - } else if (keymatch(arg, "grayscale", 2) || keymatch(arg, "greyscale",2)) { - /* Force a monochrome JPEG file to be generated. */ - jpeg_set_colorspace(cinfo, JCS_GRAYSCALE); - - } else if (keymatch(arg, "maxmemory", 3)) { - /* Maximum memory in Kb (or Mb with 'm'). */ - long lval; - char ch = 'x'; - - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) - usage(); - if (ch == 'm' || ch == 'M') - lval *= 1000L; - cinfo->mem->max_memory_to_use = lval * 1000L; - - } else if (keymatch(arg, "optimize", 1) || keymatch(arg, "optimise", 1)) { - /* Enable entropy parm optimization. */ -#ifdef ENTROPY_OPT_SUPPORTED - cinfo->optimize_coding = TRUE; -#else - fprintf(stderr, "%s: sorry, entropy optimization was not compiled\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "outfile", 4)) { - /* Set output file name. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - outfilename = argv[argn]; /* save it away for later use */ - - } else if (keymatch(arg, "progressive", 1)) { - /* Select simple progressive mode. */ -#ifdef C_PROGRESSIVE_SUPPORTED - simple_progressive = TRUE; - /* We must postpone execution until num_components is known. */ -#else - fprintf(stderr, "%s: sorry, progressive output was not compiled\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "quality", 1)) { - /* Quality factor (quantization table scaling factor). */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%d", &quality) != 1) - usage(); - /* Change scale factor in case -qtables is present. */ - q_scale_factor = jpeg_quality_scaling(quality); - - } else if (keymatch(arg, "qslots", 2)) { - /* Quantization table slot numbers. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - qslotsarg = argv[argn]; - /* Must delay setting qslots until after we have processed any - * colorspace-determining switches, since jpeg_set_colorspace sets - * default quant table numbers. - */ - - } else if (keymatch(arg, "qtables", 2)) { - /* Quantization tables fetched from file. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - qtablefile = argv[argn]; - /* We postpone actually reading the file in case -quality comes later. */ - - } else if (keymatch(arg, "restart", 1)) { - /* Restart interval in MCU rows (or in MCUs with 'b'). */ - long lval; - char ch = 'x'; - - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) - usage(); - if (lval < 0 || lval > 65535L) - usage(); - if (ch == 'b' || ch == 'B') { - cinfo->restart_interval = (unsigned int) lval; - cinfo->restart_in_rows = 0; /* else prior '-restart n' overrides me */ - } else { - cinfo->restart_in_rows = (int) lval; - /* restart_interval will be computed during startup */ - } - - } else if (keymatch(arg, "sample", 2)) { - /* Set sampling factors. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - samplearg = argv[argn]; - /* Must delay setting sample factors until after we have processed any - * colorspace-determining switches, since jpeg_set_colorspace sets - * default sampling factors. - */ - - } else if (keymatch(arg, "scans", 2)) { - /* Set scan script. */ -#ifdef C_MULTISCAN_FILES_SUPPORTED - if (++argn >= argc) /* advance to next argument */ - usage(); - scansarg = argv[argn]; - /* We must postpone reading the file in case -progressive appears. */ -#else - fprintf(stderr, "%s: sorry, multi-scan output was not compiled\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "smooth", 2)) { - /* Set input smoothing factor. */ - int val; - - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%d", &val) != 1) - usage(); - if (val < 0 || val > 100) - usage(); - cinfo->smoothing_factor = val; - - } else if (keymatch(arg, "targa", 1)) { - /* Input file is Targa format. */ - is_targa = TRUE; - - } else { - usage(); /* bogus switch */ - } - } - - /* Post-switch-scanning cleanup */ - - if (for_real) { - - /* Set quantization tables for selected quality. */ - /* Some or all may be overridden if -qtables is present. */ - jpeg_set_quality(cinfo, quality, force_baseline); - - if (qtablefile != NULL) /* process -qtables if it was present */ - if (! read_quant_tables(cinfo, qtablefile, - q_scale_factor, force_baseline)) - usage(); - - if (qslotsarg != NULL) /* process -qslots if it was present */ - if (! set_quant_slots(cinfo, qslotsarg)) - usage(); - - if (samplearg != NULL) /* process -sample if it was present */ - if (! set_sample_factors(cinfo, samplearg)) - usage(); - -#ifdef C_PROGRESSIVE_SUPPORTED - if (simple_progressive) /* process -progressive; -scans can override */ - jpeg_simple_progression(cinfo); -#endif - -#ifdef C_MULTISCAN_FILES_SUPPORTED - if (scansarg != NULL) /* process -scans if it was present */ - if (! read_scan_script(cinfo, scansarg)) - usage(); -#endif - } - - return argn; /* return index of next arg (file name) */ -} - - -/* - * The main program. - */ - -int -main (int argc, char **argv) -{ - struct jpeg_compress_struct cinfo; - struct jpeg_error_mgr jerr; -#ifdef PROGRESS_REPORT - struct cdjpeg_progress_mgr progress; -#endif - int file_index; - cjpeg_source_ptr src_mgr; - FILE * input_file; - FILE * output_file; - JDIMENSION num_scanlines; - - /* On Mac, fetch a command line. */ -#ifdef USE_CCOMMAND - argc = ccommand(&argv); -#endif - - progname = argv[0]; - if (progname == NULL || progname[0] == 0) - progname = "cjpeg"; /* in case C library doesn't provide it */ - - /* Initialize the JPEG compression object with default error handling. */ - cinfo.err = jpeg_std_error(&jerr); - jpeg_create_compress(&cinfo); - /* Add some application-specific error messages (from cderror.h) */ - jerr.addon_message_table = cdjpeg_message_table; - jerr.first_addon_message = JMSG_FIRSTADDONCODE; - jerr.last_addon_message = JMSG_LASTADDONCODE; - - /* Now safe to enable signal catcher. */ -#ifdef NEED_SIGNAL_CATCHER - enable_signal_catcher((j_common_ptr) &cinfo); -#endif - - /* Initialize JPEG parameters. - * Much of this may be overridden later. - * In particular, we don't yet know the input file's color space, - * but we need to provide some value for jpeg_set_defaults() to work. - */ - - cinfo.in_color_space = JCS_RGB; /* arbitrary guess */ - jpeg_set_defaults(&cinfo); - - /* Scan command line to find file names. - * It is convenient to use just one switch-parsing routine, but the switch - * values read here are ignored; we will rescan the switches after opening - * the input file. - */ - - file_index = parse_switches(&cinfo, argc, argv, 0, FALSE); - -#ifdef TWO_FILE_COMMANDLINE - /* Must have either -outfile switch or explicit output file name */ - if (outfilename == NULL) { - if (file_index != argc-2) { - fprintf(stderr, "%s: must name one input and one output file\n", - progname); - usage(); - } - outfilename = argv[file_index+1]; - } else { - if (file_index != argc-1) { - fprintf(stderr, "%s: must name one input and one output file\n", - progname); - usage(); - } - } -#else - /* Unix style: expect zero or one file name */ - if (file_index < argc-1) { - fprintf(stderr, "%s: only one input file\n", progname); - usage(); - } -#endif /* TWO_FILE_COMMANDLINE */ - - /* Open the input file. */ - if (file_index < argc) { - if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, argv[file_index]); - exit(EXIT_FAILURE); - } - } else { - /* default input file is stdin */ - input_file = read_stdin(); - } - - /* Open the output file. */ - if (outfilename != NULL) { - if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, outfilename); - exit(EXIT_FAILURE); - } - } else { - /* default output file is stdout */ - output_file = write_stdout(); - } - -#ifdef PROGRESS_REPORT - start_progress_monitor((j_common_ptr) &cinfo, &progress); -#endif - - /* Figure out the input file format, and set up to read it. */ - src_mgr = select_file_type(&cinfo, input_file); - src_mgr->input_file = input_file; - - /* Read the input file header to obtain file size & colorspace. */ - (*src_mgr->start_input) (&cinfo, src_mgr); - - /* Now that we know input colorspace, fix colorspace-dependent defaults */ - jpeg_default_colorspace(&cinfo); - - /* Adjust default compression parameters by re-parsing the options */ - file_index = parse_switches(&cinfo, argc, argv, 0, TRUE); - - /* Specify data destination for compression */ - jpeg_stdio_dest(&cinfo, output_file); - - /* Start compressor */ - jpeg_start_compress(&cinfo, TRUE); - - /* Process data */ - while (cinfo.next_scanline < cinfo.image_height) { - num_scanlines = (*src_mgr->get_pixel_rows) (&cinfo, src_mgr); - (void) jpeg_write_scanlines(&cinfo, src_mgr->buffer, num_scanlines); - } - - /* Finish compression and release memory */ - (*src_mgr->finish_input) (&cinfo, src_mgr); - jpeg_finish_compress(&cinfo); - jpeg_destroy_compress(&cinfo); - - /* Close files, if we opened them */ - if (input_file != stdin) - fclose(input_file); - if (output_file != stdout) - fclose(output_file); - -#ifdef PROGRESS_REPORT - end_progress_monitor((j_common_ptr) &cinfo); -#endif - - /* All done. */ - exit(jerr.num_warnings ? EXIT_WARNING : EXIT_SUCCESS); - return 0; /* suppress no-return-value warnings */ -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/ckconfig.c b/irrlicht-1.6/source/Irrlicht/jpeglib/ckconfig.c deleted file mode 100644 index 58e9c17f2..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/ckconfig.c +++ /dev/null @@ -1,402 +0,0 @@ -/* - * ckconfig.c - * - * Copyright (C) 1991-1994, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - */ - -/* - * This program is intended to help you determine how to configure the JPEG - * software for installation on a particular system. The idea is to try to - * compile and execute this program. If your compiler fails to compile the - * program, make changes as indicated in the comments below. Once you can - * compile the program, run it, and it will produce a "jconfig.h" file for - * your system. - * - * As a general rule, each time you try to compile this program, - * pay attention only to the *first* error message you get from the compiler. - * Many C compilers will issue lots of spurious error messages once they - * have gotten confused. Go to the line indicated in the first error message, - * and read the comments preceding that line to see what to change. - * - * Almost all of the edits you may need to make to this program consist of - * changing a line that reads "#define SOME_SYMBOL" to "#undef SOME_SYMBOL", - * or vice versa. This is called defining or undefining that symbol. - */ - - -/* First we must see if your system has the include files we need. - * We start out with the assumption that your system has all the ANSI-standard - * include files. If you get any error trying to include one of these files, - * undefine the corresponding HAVE_xxx symbol. - */ - -#define HAVE_STDDEF_H /* replace 'define' by 'undef' if error here */ -#ifdef HAVE_STDDEF_H /* next line will be skipped if you undef... */ -#include <stddef.h> -#endif - -#define HAVE_STDLIB_H /* same thing for stdlib.h */ -#ifdef HAVE_STDLIB_H -#include <stdlib.h> -#endif - -#include <stdio.h> /* If you ain't got this, you ain't got C. */ - -/* We have to see if your string functions are defined by - * strings.h (old BSD convention) or string.h (everybody else). - * We try the non-BSD convention first; define NEED_BSD_STRINGS - * if the compiler says it can't find string.h. - */ - -#undef NEED_BSD_STRINGS - -#ifdef NEED_BSD_STRINGS -#include <strings.h> -#else -#include <string.h> -#endif - -/* On some systems (especially older Unix machines), type size_t is - * defined only in the include file <sys/types.h>. If you get a failure - * on the size_t test below, try defining NEED_SYS_TYPES_H. - */ - -#undef NEED_SYS_TYPES_H /* start by assuming we don't need it */ -#ifdef NEED_SYS_TYPES_H -#include <sys/types.h> -#endif - - -/* Usually type size_t is defined in one of the include files we've included - * above. If not, you'll get an error on the "typedef size_t my_size_t;" line. - * In that case, first try defining NEED_SYS_TYPES_H just above. - * If that doesn't work, you'll have to search through your system library - * to figure out which include file defines "size_t". Look for a line that - * says "typedef something-or-other size_t;". Then, change the line below - * that says "#include <someincludefile.h>" to instead include the file - * you found size_t in, and define NEED_SPECIAL_INCLUDE. If you can't find - * type size_t anywhere, try replacing "#include <someincludefile.h>" with - * "typedef unsigned int size_t;". - */ - -#undef NEED_SPECIAL_INCLUDE /* assume we DON'T need it, for starters */ - -#ifdef NEED_SPECIAL_INCLUDE -#include <someincludefile.h> -#endif - -typedef size_t my_size_t; /* The payoff: do we have size_t now? */ - - -/* The next question is whether your compiler supports ANSI-style function - * prototypes. You need to know this in order to choose between using - * makefile.ansi and using makefile.unix. - * The #define line below is set to assume you have ANSI function prototypes. - * If you get an error in this group of lines, undefine HAVE_PROTOTYPES. - */ - -#define HAVE_PROTOTYPES - -#ifdef HAVE_PROTOTYPES -int testfunction (int arg1, int * arg2); /* check prototypes */ - -struct methods_struct { /* check method-pointer declarations */ - int (*error_exit) (char *msgtext); - int (*trace_message) (char *msgtext); - int (*another_method) (void); -}; - -int testfunction (int arg1, int * arg2) /* check definitions */ -{ - return arg2[arg1]; -} - -int test2function (void) /* check void arg list */ -{ - return 0; -} -#endif - - -/* Now we want to find out if your compiler knows what "unsigned char" means. - * If you get an error on the "unsigned char un_char;" line, - * then undefine HAVE_UNSIGNED_CHAR. - */ - -#define HAVE_UNSIGNED_CHAR - -#ifdef HAVE_UNSIGNED_CHAR -unsigned char un_char; -#endif - - -/* Now we want to find out if your compiler knows what "unsigned short" means. - * If you get an error on the "unsigned short un_short;" line, - * then undefine HAVE_UNSIGNED_SHORT. - */ - -#define HAVE_UNSIGNED_SHORT - -#ifdef HAVE_UNSIGNED_SHORT -unsigned short un_short; -#endif - - -/* Now we want to find out if your compiler understands type "void". - * If you get an error anywhere in here, undefine HAVE_VOID. - */ - -#define HAVE_VOID - -#ifdef HAVE_VOID -/* Caution: a C++ compiler will insist on complete prototypes */ -typedef void * void_ptr; /* check void * */ -#ifdef HAVE_PROTOTYPES /* check ptr to function returning void */ -typedef void (*void_func) (int a, int b); -#else -typedef void (*void_func) (); -#endif - -#ifdef HAVE_PROTOTYPES /* check void function result */ -void test3function (void_ptr arg1, void_func arg2) -#else -void test3function (arg1, arg2) - void_ptr arg1; - void_func arg2; -#endif -{ - char * locptr = (char *) arg1; /* check casting to and from void * */ - arg1 = (void *) locptr; - (*arg2) (1, 2); /* check call of fcn returning void */ -} -#endif - - -/* Now we want to find out if your compiler knows what "const" means. - * If you get an error here, undefine HAVE_CONST. - */ - -#define HAVE_CONST - -#ifdef HAVE_CONST -static const int carray[3] = {1, 2, 3}; - -#ifdef HAVE_PROTOTYPES -int test4function (const int arg1) -#else -int test4function (arg1) - const int arg1; -#endif -{ - return carray[arg1]; -} -#endif - - -/* If you get an error or warning about this structure definition, - * define INCOMPLETE_TYPES_BROKEN. - */ - -#undef INCOMPLETE_TYPES_BROKEN - -#ifndef INCOMPLETE_TYPES_BROKEN -typedef struct undefined_structure * undef_struct_ptr; -#endif - - -/* If you get an error about duplicate names, - * define NEED_SHORT_EXTERNAL_NAMES. - */ - -#undef NEED_SHORT_EXTERNAL_NAMES - -#ifndef NEED_SHORT_EXTERNAL_NAMES - -int possibly_duplicate_function () -{ - return 0; -} - -int possibly_dupli_function () -{ - return 1; -} - -#endif - - - -/************************************************************************ - * OK, that's it. You should not have to change anything beyond this - * point in order to compile and execute this program. (You might get - * some warnings, but you can ignore them.) - * When you run the program, it will make a couple more tests that it - * can do automatically, and then it will create jconfig.h and print out - * any additional suggestions it has. - ************************************************************************ - */ - - -#ifdef HAVE_PROTOTYPES -int is_char_signed (int arg) -#else -int is_char_signed (arg) - int arg; -#endif -{ - if (arg == 189) { /* expected result for unsigned char */ - return 0; /* type char is unsigned */ - } - else if (arg != -67) { /* expected result for signed char */ - printf("Hmm, it seems 'char' is not eight bits wide on your machine.\n"); - printf("I fear the JPEG software will not work at all.\n\n"); - } - return 1; /* assume char is signed otherwise */ -} - - -#ifdef HAVE_PROTOTYPES -int is_shifting_signed (long arg) -#else -int is_shifting_signed (arg) - long arg; -#endif -/* See whether right-shift on a long is signed or not. */ -{ - long res = arg >> 4; - - if (res == -0x7F7E80CL) { /* expected result for signed shift */ - return 1; /* right shift is signed */ - } - /* see if unsigned-shift hack will fix it. */ - /* we can't just test exact value since it depends on width of long... */ - res |= (~0L) << (32-4); - if (res == -0x7F7E80CL) { /* expected result now? */ - return 0; /* right shift is unsigned */ - } - printf("Right shift isn't acting as I expect it to.\n"); - printf("I fear the JPEG software will not work at all.\n\n"); - return 0; /* try it with unsigned anyway */ -} - - -#ifdef HAVE_PROTOTYPES -int main (int argc, char ** argv) -#else -int main (argc, argv) - int argc; - char ** argv; -#endif -{ - char signed_char_check = (char) (-67); - FILE *outfile; - - /* Attempt to write jconfig.h */ - if ((outfile = fopen("jconfig.h", "w")) == NULL) { - printf("Failed to write jconfig.h\n"); - return 1; - } - - /* Write out all the info */ - fprintf(outfile, "/* jconfig.h --- generated by ckconfig.c */\n"); - fprintf(outfile, "/* see jconfig.doc for explanations */\n\n"); -#ifdef HAVE_PROTOTYPES - fprintf(outfile, "#define HAVE_PROTOTYPES\n"); -#else - fprintf(outfile, "#undef HAVE_PROTOTYPES\n"); -#endif -#ifdef HAVE_UNSIGNED_CHAR - fprintf(outfile, "#define HAVE_UNSIGNED_CHAR\n"); -#else - fprintf(outfile, "#undef HAVE_UNSIGNED_CHAR\n"); -#endif -#ifdef HAVE_UNSIGNED_SHORT - fprintf(outfile, "#define HAVE_UNSIGNED_SHORT\n"); -#else - fprintf(outfile, "#undef HAVE_UNSIGNED_SHORT\n"); -#endif -#ifdef HAVE_VOID - fprintf(outfile, "/* #define void char */\n"); -#else - fprintf(outfile, "#define void char\n"); -#endif -#ifdef HAVE_CONST - fprintf(outfile, "/* #define const */\n"); -#else - fprintf(outfile, "#define const\n"); -#endif - if (is_char_signed((int) signed_char_check)) - fprintf(outfile, "#undef CHAR_IS_UNSIGNED\n"); - else - fprintf(outfile, "#define CHAR_IS_UNSIGNED\n"); -#ifdef HAVE_STDDEF_H - fprintf(outfile, "#define HAVE_STDDEF_H\n"); -#else - fprintf(outfile, "#undef HAVE_STDDEF_H\n"); -#endif -#ifdef HAVE_STDLIB_H - fprintf(outfile, "#define HAVE_STDLIB_H\n"); -#else - fprintf(outfile, "#undef HAVE_STDLIB_H\n"); -#endif -#ifdef NEED_BSD_STRINGS - fprintf(outfile, "#define NEED_BSD_STRINGS\n"); -#else - fprintf(outfile, "#undef NEED_BSD_STRINGS\n"); -#endif -#ifdef NEED_SYS_TYPES_H - fprintf(outfile, "#define NEED_SYS_TYPES_H\n"); -#else - fprintf(outfile, "#undef NEED_SYS_TYPES_H\n"); -#endif - fprintf(outfile, "#undef NEED_FAR_POINTERS\n"); -#ifdef NEED_SHORT_EXTERNAL_NAMES - fprintf(outfile, "#define NEED_SHORT_EXTERNAL_NAMES\n"); -#else - fprintf(outfile, "#undef NEED_SHORT_EXTERNAL_NAMES\n"); -#endif -#ifdef INCOMPLETE_TYPES_BROKEN - fprintf(outfile, "#define INCOMPLETE_TYPES_BROKEN\n"); -#else - fprintf(outfile, "#undef INCOMPLETE_TYPES_BROKEN\n"); -#endif - fprintf(outfile, "\n#ifdef JPEG_INTERNALS\n\n"); - if (is_shifting_signed(-0x7F7E80B1L)) - fprintf(outfile, "#undef RIGHT_SHIFT_IS_UNSIGNED\n"); - else - fprintf(outfile, "#define RIGHT_SHIFT_IS_UNSIGNED\n"); - fprintf(outfile, "\n#endif /* JPEG_INTERNALS */\n"); - fprintf(outfile, "\n#ifdef JPEG_CJPEG_DJPEG\n\n"); - fprintf(outfile, "#define BMP_SUPPORTED /* BMP image file format */\n"); - fprintf(outfile, "#define GIF_SUPPORTED /* GIF image file format */\n"); - fprintf(outfile, "#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */\n"); - fprintf(outfile, "#undef RLE_SUPPORTED /* Utah RLE image file format */\n"); - fprintf(outfile, "#define TARGA_SUPPORTED /* Targa image file format */\n\n"); - fprintf(outfile, "#undef TWO_FILE_COMMANDLINE /* You may need this on non-Unix systems */\n"); - fprintf(outfile, "#undef NEED_SIGNAL_CATCHER /* Define this if you use jmemname.c */\n"); - fprintf(outfile, "#undef DONT_USE_B_MODE\n"); - fprintf(outfile, "/* #define PROGRESS_REPORT */ /* optional */\n"); - fprintf(outfile, "\n#endif /* JPEG_CJPEG_DJPEG */\n"); - - /* Close the jconfig.h file */ - fclose(outfile); - - /* User report */ - printf("Configuration check for Independent JPEG Group's software done.\n"); - printf("\nI have written the jconfig.h file for you.\n\n"); -#ifdef HAVE_PROTOTYPES - printf("You should use makefile.ansi as the starting point for your Makefile.\n"); -#else - printf("You should use makefile.unix as the starting point for your Makefile.\n"); -#endif - -#ifdef NEED_SPECIAL_INCLUDE - printf("\nYou'll need to change jconfig.h to include the system include file\n"); - printf("that you found type size_t in, or add a direct definition of type\n"); - printf("size_t if that's what you used. Just add it to the end.\n"); -#endif - - return 0; -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/coderules.doc b/irrlicht-1.6/source/Irrlicht/jpeglib/coderules.doc deleted file mode 100644 index 2c5653410..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/coderules.doc +++ /dev/null @@ -1,118 +0,0 @@ -IJG JPEG LIBRARY: CODING RULES - -Copyright (C) 1991-1996, Thomas G. Lane. -This file is part of the Independent JPEG Group's software. -For conditions of distribution and use, see the accompanying README file. - - -Since numerous people will be contributing code and bug fixes, it's important -to establish a common coding style. The goal of using similar coding styles -is much more important than the details of just what that style is. - -In general we follow the recommendations of "Recommended C Style and Coding -Standards" revision 6.1 (Cannon et al. as modified by Spencer, Keppel and -Brader). This document is available in the IJG FTP archive (see -jpeg/doc/cstyle.ms.tbl.Z, or cstyle.txt.Z for those without nroff/tbl). - -Block comments should be laid out thusly: - -/* - * Block comments in this style. - */ - -We indent statements in K&R style, e.g., - if (test) { - then-part; - } else { - else-part; - } -with two spaces per indentation level. (This indentation convention is -handled automatically by GNU Emacs and many other text editors.) - -Multi-word names should be written in lower case with underscores, e.g., -multi_word_name (not multiWordName). Preprocessor symbols and enum constants -are similar but upper case (MULTI_WORD_NAME). Names should be unique within -the first fifteen characters. (On some older systems, global names must be -unique within six characters. We accommodate this without cluttering the -source code by using macros to substitute shorter names.) - -We use function prototypes everywhere; we rely on automatic source code -transformation to feed prototype-less C compilers. Transformation is done -by the simple and portable tool 'ansi2knr.c' (courtesy of Ghostscript). -ansi2knr is not very bright, so it imposes a format requirement on function -declarations: the function name MUST BEGIN IN COLUMN 1. Thus all functions -should be written in the following style: - -LOCAL(int *) -function_name (int a, char *b) -{ - code... -} - -Note that each function definition must begin with GLOBAL(type), LOCAL(type), -or METHODDEF(type). These macros expand to "static type" or just "type" as -appropriate. They provide a readable indication of the routine's usage and -can readily be changed for special needs. (For instance, special linkage -keywords can be inserted for use in Windows DLLs.) - -ansi2knr does not transform method declarations (function pointers in -structs). We handle these with a macro JMETHOD, defined as - #ifdef HAVE_PROTOTYPES - #define JMETHOD(type,methodname,arglist) type (*methodname) arglist - #else - #define JMETHOD(type,methodname,arglist) type (*methodname) () - #endif -which is used like this: - struct function_pointers { - JMETHOD(void, init_entropy_encoder, (int somearg, jparms *jp)); - JMETHOD(void, term_entropy_encoder, (void)); - }; -Note the set of parentheses surrounding the parameter list. - -A similar solution is used for forward and external function declarations -(see the EXTERN and JPP macros). - -If the code is to work on non-ANSI compilers, we cannot rely on a prototype -declaration to coerce actual parameters into the right types. Therefore, use -explicit casts on actual parameters whenever the actual parameter type is not -identical to the formal parameter. Beware of implicit conversions to "int". - -It seems there are some non-ANSI compilers in which the sizeof() operator -is defined to return int, yet size_t is defined as long. Needless to say, -this is brain-damaged. Always use the SIZEOF() macro in place of sizeof(), -so that the result is guaranteed to be of type size_t. - - -The JPEG library is intended to be used within larger programs. Furthermore, -we want it to be reentrant so that it can be used by applications that process -multiple images concurrently. The following rules support these requirements: - -1. Avoid direct use of file I/O, "malloc", error report printouts, etc; -pass these through the common routines provided. - -2. Minimize global namespace pollution. Functions should be declared static -wherever possible. (Note that our method-based calling conventions help this -a lot: in many modules only the initialization function will ever need to be -called directly, so only that function need be externally visible.) All -global function names should begin with "jpeg_", and should have an -abbreviated name (unique in the first six characters) substituted by macro -when NEED_SHORT_EXTERNAL_NAMES is set. - -3. Don't use global variables; anything that must be used in another module -should be in the common data structures. - -4. Don't use static variables except for read-only constant tables. Variables -that should be private to a module can be placed into private structures (see -the system architecture document, structure.doc). - -5. Source file names should begin with "j" for files that are part of the -library proper; source files that are not part of the library, such as cjpeg.c -and djpeg.c, do not begin with "j". Keep source file names to eight -characters (plus ".c" or ".h", etc) to make life easy for MS-DOSers. Keep -compression and decompression code in separate source files --- some -applications may want only one half of the library. - -Note: these rules (particularly #4) are not followed religiously in the -modules that are used in cjpeg/djpeg but are not part of the JPEG library -proper. Those modules are not really intended to be used in other -applications. diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/config.guess b/irrlicht-1.6/source/Irrlicht/jpeglib/config.guess deleted file mode 100644 index f60829f7e..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/config.guess +++ /dev/null @@ -1,883 +0,0 @@ -#! /bin/sh -# Attempt to guess a canonical system name. -# Copyright (C) 1992, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. -# -# This file is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Written by Per Bothner <bothner@cygnus.com>. -# The master version of this file is at the FSF in /home/gd/gnu/lib. -# -# This script attempts to guess a canonical system name similar to -# config.sub. If it succeeds, it prints the system name on stdout, and -# exits with 0. Otherwise, it exits with 1. -# -# The plan is that this can be called by configure scripts if you -# don't specify an explicit system type (host/target name). -# -# Only a few systems have been added to this list; please add others -# (but try to keep the structure clean). -# - -# This is needed to find uname on a Pyramid OSx when run in the BSD universe. -# (ghazi@noc.rutgers.edu 8/24/94.) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then - PATH=$PATH:/.attbin ; export PATH -fi - -UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown -UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown -UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown -UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown - -trap 'rm -f dummy.c dummy.o dummy; exit 1' 1 2 15 - -# Note: order is significant - the case branches are not exclusive. - -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - alpha:OSF1:*:*) - if test $UNAME_RELEASE = "V4.0"; then - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` - fi - # A Vn.n version is a released version. - # A Tn.n version is a released field test version. - # A Xn.n version is an unreleased experimental baselevel. - # 1.2 uses "1.2" for uname -r. - cat <<EOF >dummy.s - .globl main - .ent main -main: - .frame \$30,0,\$26,0 - .prologue 0 - .long 0x47e03d80 # implver $0 - lda \$2,259 - .long 0x47e20c21 # amask $2,$1 - srl \$1,8,\$2 - sll \$2,2,\$2 - sll \$0,3,\$0 - addl \$1,\$0,\$0 - addl \$2,\$0,\$0 - ret \$31,(\$26),1 - .end main -EOF - ${CC-cc} dummy.s -o dummy 2>/dev/null - if test "$?" = 0 ; then - ./dummy - case "$?" in - 7) - UNAME_MACHINE="alpha" - ;; - 15) - UNAME_MACHINE="alphaev5" - ;; - 14) - UNAME_MACHINE="alphaev56" - ;; - 10) - UNAME_MACHINE="alphapca56" - ;; - 16) - UNAME_MACHINE="alphaev6" - ;; - esac - fi - rm -f dummy.s dummy - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr [[A-Z]] [[a-z]]` - exit 0 ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit 0 ;; - Amiga*:UNIX_System_V:4.0:*) - echo m68k-cbm-sysv4 - exit 0;; - amiga:NetBSD:*:*) - echo m68k-cbm-netbsd${UNAME_RELEASE} - exit 0 ;; - amiga:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - arc64:OpenBSD:*:*) - echo mips64el-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - arc:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - hkmips:OpenBSD:*:*) - echo mips-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - pmax:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - sgi:OpenBSD:*:*) - echo mips-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - wgrisc:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} - exit 0;; - arm32:NetBSD:*:*) - echo arm-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - exit 0 ;; - SR2?01:HI-UX/MPP:*:*) - echo hppa1.1-hitachi-hiuxmpp - exit 0;; - Pyramid*:OSx*:*:*|MIS*:OSx*:*:*) - # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. - if test "`(/bin/universe) 2>/dev/null`" = att ; then - echo pyramid-pyramid-sysv3 - else - echo pyramid-pyramid-bsd - fi - exit 0 ;; - NILE:*:*:dcosx) - echo pyramid-pyramid-svr4 - exit 0 ;; - sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - i86pc:SunOS:5.*:*) - echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - sun4*:SunOS:6*:*) - # According to config.sub, this is the proper way to canonicalize - # SunOS6. Hard to guess exactly what SunOS6 will be like, but - # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - sun4*:SunOS:*:*) - case "`/usr/bin/arch -k`" in - Series*|S4*) - UNAME_RELEASE=`uname -v` - ;; - esac - # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` - exit 0 ;; - sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} - exit 0 ;; - sun*:*:4.2BSD:*) - UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 - case "`/bin/arch`" in - sun3) - echo m68k-sun-sunos${UNAME_RELEASE} - ;; - sun4) - echo sparc-sun-sunos${UNAME_RELEASE} - ;; - esac - exit 0 ;; - aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} - exit 0 ;; - atari*:NetBSD:*:*) - echo m68k-atari-netbsd${UNAME_RELEASE} - exit 0 ;; - atari*:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - sun3*:NetBSD:*:*) - echo m68k-sun-netbsd${UNAME_RELEASE} - exit 0 ;; - sun3*:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mac68k:NetBSD:*:*) - echo m68k-apple-netbsd${UNAME_RELEASE} - exit 0 ;; - mac68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme88k:OpenBSD:*:*) - echo m88k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} - exit 0 ;; - RISC*:Mach:*:*) - echo mips-dec-mach_bsd4.3 - exit 0 ;; - RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} - exit 0 ;; - VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} - exit 0 ;; - 2020:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} - exit 0 ;; - mips:*:*:UMIPS | mips:*:*:RISCos) - sed 's/^ //' << EOF >dummy.c - int main (argc, argv) int argc; char **argv; { - #if defined (host_mips) && defined (MIPSEB) - #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); - #endif - #endif - exit (-1); - } -EOF - ${CC-cc} dummy.c -o dummy \ - && ./dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ - && rm dummy.c dummy && exit 0 - rm -f dummy.c dummy - echo mips-mips-riscos${UNAME_RELEASE} - exit 0 ;; - Night_Hawk:Power_UNIX:*:*) - echo powerpc-harris-powerunix - exit 0 ;; - m88k:CX/UX:7*:*) - echo m88k-harris-cxux7 - exit 0 ;; - m88k:*:4*:R4*) - echo m88k-motorola-sysv4 - exit 0 ;; - m88k:*:3*:R3*) - echo m88k-motorola-sysv3 - exit 0 ;; - AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 -o $UNAME_PROCESSOR = mc88110 ] ; then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \ - -o ${TARGET_BINARY_INTERFACE}x = x ] ; then - echo m88k-dg-dgux${UNAME_RELEASE} - else - echo m88k-dg-dguxbcs${UNAME_RELEASE} - fi - else echo i586-dg-dgux${UNAME_RELEASE} - fi - exit 0 ;; - M88*:DolphinOS:*:*) # DolphinOS (SVR3) - echo m88k-dolphin-sysv3 - exit 0 ;; - M88*:*:R3*:*) - # Delta 88k system running SVR3 - echo m88k-motorola-sysv3 - exit 0 ;; - XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) - echo m88k-tektronix-sysv3 - exit 0 ;; - Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) - echo m68k-tektronix-bsd - exit 0 ;; - *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` - exit 0 ;; - ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' - i?86:AIX:*:*) - echo i386-ibm-aix - exit 0 ;; - *:AIX:2:3) - if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - sed 's/^ //' << EOF >dummy.c - #include <sys/systemcfg.h> - - main() - { - if (!__power_pc()) - exit(1); - puts("powerpc-ibm-aix3.2.5"); - exit(0); - } -EOF - ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0 - rm -f dummy.c dummy - echo rs6000-ibm-aix3.2.5 - elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then - echo rs6000-ibm-aix3.2.4 - else - echo rs6000-ibm-aix3.2 - fi - exit 0 ;; - *:AIX:*:4) - if /usr/sbin/lsattr -EHl proc0 | grep POWER >/dev/null 2>&1; then - IBM_ARCH=rs6000 - else - IBM_ARCH=powerpc - fi - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=4.${UNAME_RELEASE} - fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} - exit 0 ;; - *:AIX:*:*) - echo rs6000-ibm-aix - exit 0 ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) - echo romp-ibm-bsd4.4 - exit 0 ;; - ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC NetBSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to - exit 0 ;; # report: romp-ibm BSD 4.3 - *:BOSX:*:*) - echo rs6000-bull-bosx - exit 0 ;; - DPX/2?00:B.O.S.:*:*) - echo m68k-bull-sysv3 - exit 0 ;; - 9000/[34]??:4.3bsd:1.*:*) - echo m68k-hp-bsd - exit 0 ;; - hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) - echo m68k-hp-bsd4.4 - exit 0 ;; - 9000/[3478]??:HP-UX:*:*) - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; - 9000/7?? | 9000/8?[1679] ) HP_ARCH=hppa1.1 ;; - 9000/8?? ) HP_ARCH=hppa1.0 ;; - esac - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ${HP_ARCH}-hp-hpux${HPUX_REV} - exit 0 ;; - 3050*:HI-UX:*:*) - sed 's/^ //' << EOF >dummy.c - #include <unistd.h> - int - main () - { - long cpu = sysconf (_SC_CPU_VERSION); - /* The order matters, because CPU_IS_HP_MC68K erroneously returns - true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct - results, however. */ - if (CPU_IS_PA_RISC (cpu)) - { - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; - case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; - default: puts ("hppa-hitachi-hiuxwe2"); break; - } - } - else if (CPU_IS_HP_MC68K (cpu)) - puts ("m68k-hitachi-hiuxwe2"); - else puts ("unknown-hitachi-hiuxwe2"); - exit (0); - } -EOF - ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0 - rm -f dummy.c dummy - echo unknown-hitachi-hiuxwe2 - exit 0 ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) - echo hppa1.1-hp-bsd - exit 0 ;; - 9000/8??:4.3bsd:*:*) - echo hppa1.0-hp-bsd - exit 0 ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) - echo hppa1.1-hp-osf - exit 0 ;; - hp8??:OSF1:*:*) - echo hppa1.0-hp-osf - exit 0 ;; - i?86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk - else - echo ${UNAME_MACHINE}-unknown-osf1 - fi - exit 0 ;; - parisc*:Lites*:*:*) - echo hppa1.1-hp-lites - exit 0 ;; - C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) - echo c1-convex-bsd - exit 0 ;; - C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit 0 ;; - C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) - echo c34-convex-bsd - exit 0 ;; - C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) - echo c38-convex-bsd - exit 0 ;; - C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) - echo c4-convex-bsd - exit 0 ;; - CRAY*X-MP:*:*:*) - echo xmp-cray-unicos - exit 0 ;; - CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} - exit 0 ;; - CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ - | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ - -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ - exit 0 ;; - CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} - exit 0 ;; - CRAY-2:*:*:*) - echo cray2-cray-unicos - exit 0 ;; - F300:UNIX_System_V:*:*) - FUJITSU_SYS=`uname -p | tr [A-Z] [a-z] | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit 0 ;; - F301:UNIX_System_V:*:*) - echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'` - exit 0 ;; - hp3[0-9][05]:NetBSD:*:*) - echo m68k-hp-netbsd${UNAME_RELEASE} - exit 0 ;; - hp300:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - i?86:BSD/386:*:* | *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} - exit 0 ;; - *:FreeBSD:*:*) - echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit 0 ;; - *:NetBSD:*:*) - echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - exit 0 ;; - *:OpenBSD:*:*) - echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - exit 0 ;; - i*:CYGWIN*:*) - echo i386-pc-cygwin32 - exit 0 ;; - i*:MINGW*:*) - echo i386-pc-mingw32 - exit 0 ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin32 - exit 0 ;; - prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - *:GNU:*:*) - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` - exit 0 ;; - *:Linux:*:*) - # The BFD linker knows what the default object file format is, so - # first see if it will tell us. - ld_help_string=`ld --help 2>&1` - ld_supported_emulations=`echo $ld_help_string \ - | sed -ne '/supported emulations:/!d - s/[ ][ ]*/ /g - s/.*supported emulations: *// - s/ .*// - p'` - case "$ld_supported_emulations" in - i?86linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" ; exit 0 ;; - i?86coff) echo "${UNAME_MACHINE}-pc-linux-gnucoff" ; exit 0 ;; - sparclinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;; - m68klinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;; - elf32ppc) echo "powerpc-unknown-linux-gnu" ; exit 0 ;; - esac - - if test "${UNAME_MACHINE}" = "alpha" ; then - sed 's/^ //' <<EOF >dummy.s - .globl main - .ent main - main: - .frame \$30,0,\$26,0 - .prologue 0 - .long 0x47e03d80 # implver $0 - lda \$2,259 - .long 0x47e20c21 # amask $2,$1 - srl \$1,8,\$2 - sll \$2,2,\$2 - sll \$0,3,\$0 - addl \$1,\$0,\$0 - addl \$2,\$0,\$0 - ret \$31,(\$26),1 - .end main -EOF - LIBC="" - ${CC-cc} dummy.s -o dummy 2>/dev/null - if test "$?" = 0 ; then - ./dummy - case "$?" in - 7) - UNAME_MACHINE="alpha" - ;; - 15) - UNAME_MACHINE="alphaev5" - ;; - 14) - UNAME_MACHINE="alphaev56" - ;; - 10) - UNAME_MACHINE="alphapca56" - ;; - 16) - UNAME_MACHINE="alphaev6" - ;; - esac - - objdump --private-headers dummy | \ - grep ld.so.1 > /dev/null - if test "$?" = 0 ; then - LIBC="libc1" - fi - fi - rm -f dummy.s dummy - echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0 - elif test "${UNAME_MACHINE}" = "mips" ; then - cat >dummy.c <<EOF -main(argc, argv) - int argc; - char *argv[]; -{ -#ifdef __MIPSEB__ - printf ("%s-unknown-linux-gnu\n", argv[1]); -#endif -#ifdef __MIPSEL__ - printf ("%sel-unknown-linux-gnu\n", argv[1]); -#endif - return 0; -} -EOF - ${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0 - rm -f dummy.c dummy - else - # Either a pre-BFD a.out linker (linux-gnuoldld) - # or one that does not give us useful --help. - # GCC wants to distinguish between linux-gnuoldld and linux-gnuaout. - # If ld does not provide *any* "supported emulations:" - # that means it is gnuoldld. - echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations:" - test $? != 0 && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0 - - case "${UNAME_MACHINE}" in - i?86) - VENDOR=pc; - ;; - *) - VENDOR=unknown; - ;; - esac - # Determine whether the default compiler is a.out or elf - cat >dummy.c <<EOF -#include <features.h> -main(argc, argv) - int argc; - char *argv[]; -{ -#ifdef __ELF__ -# ifdef __GLIBC__ -# if __GLIBC__ >= 2 - printf ("%s-${VENDOR}-linux-gnu\n", argv[1]); -# else - printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); -# endif -# else - printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); -# endif -#else - printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]); -#endif - return 0; -} -EOF - ${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0 - rm -f dummy.c dummy - fi ;; -# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions -# are messed up and put the nodename in both sysname and nodename. - i?86:DYNIX/ptx:4*:*) - echo i386-sequent-sysv4 - exit 0 ;; - i?86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, - # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} - exit 0 ;; - i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*) - if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE} - else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE} - fi - exit 0 ;; - i?86:*:3.2:*) - if test -f /usr/options/cb.name; then - UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name` - echo ${UNAME_MACHINE}-pc-isc$UNAME_REL - elif /bin/uname -X 2>/dev/null >/dev/null ; then - UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` - (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 - (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ - && UNAME_MACHINE=i586 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL - else - echo ${UNAME_MACHINE}-pc-sysv32 - fi - exit 0 ;; - pc:*:*:*) - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i386. - echo i386-pc-msdosdjgpp - exit 0 ;; - Intel:Mach:3*:*) - echo i386-pc-mach3 - exit 0 ;; - paragon:*:*:*) - echo i860-intel-osf1 - exit 0 ;; - i860:*:4.*:*) # i860-SVR4 - if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 - else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 - fi - exit 0 ;; - mini*:CTIX:SYS*5:*) - # "miniframe" - echo m68010-convergent-sysv - exit 0 ;; - M68*:*:R3V[567]*:*) - test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; - 3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0) - OS_REL='' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && echo i486-ncr-sysv4.3${OS_REL} && exit 0 - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; - 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && echo i486-ncr-sysv4 && exit 0 ;; - m68*:LynxOS:2.*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - mc68030:UNIX_System_V:4.*:*) - echo m68k-atari-sysv4 - exit 0 ;; - i?86:LynxOS:2.*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} - exit 0 ;; - RM*:SINIX-*:*:*) - echo mips-sni-sysv4 - exit 0 ;; - *:SINIX-*:*:*) - if uname -p 2>/dev/null >/dev/null ; then - UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 - else - echo ns32k-sni-sysv - fi - exit 0 ;; - PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says <Richard.M.Bartel@ccMail.Census.GOV> - echo i586-unisys-sysv4 - exit 0 ;; - *:UNIX_System_V:4*:FTX*) - # From Gerald Hewes <hewes@openmarket.com>. - # How about differentiating between stratus architectures? -djm - echo hppa1.1-stratus-sysv4 - exit 0 ;; - *:*:*:FTX*) - # From seanf@swdc.stratus.com. - echo i860-stratus-sysv4 - exit 0 ;; - mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} - exit 0 ;; - news*:NEWS-OS:*:6*) - echo mips-sony-newsos6 - exit 0 ;; - R3000:*System_V*:*:* | R4000:UNIX_SYSV:*:*) - if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} - else - echo mips-unknown-sysv${UNAME_RELEASE} - fi - exit 0 ;; -esac - -#echo '(No uname command or uname output not recognized.)' 1>&2 -#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 - -cat >dummy.c <<EOF -#ifdef _SEQUENT_ -# include <sys/types.h> -# include <sys/utsname.h> -#endif -main () -{ -#if defined (sony) -#if defined (MIPSEB) - /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, - I don't know.... */ - printf ("mips-sony-bsd\n"); exit (0); -#else -#include <sys/param.h> - printf ("m68k-sony-newsos%s\n", -#ifdef NEWSOS4 - "4" -#else - "" -#endif - ); exit (0); -#endif -#endif - -#if defined (__arm) && defined (__acorn) && defined (__unix) - printf ("arm-acorn-riscix"); exit (0); -#endif - -#if defined (hp300) && !defined (hpux) - printf ("m68k-hp-bsd\n"); exit (0); -#endif - -#if defined (NeXT) -#if !defined (__ARCHITECTURE__) -#define __ARCHITECTURE__ "m68k" -#endif - int version; - version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; - printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); - exit (0); -#endif - -#if defined (MULTIMAX) || defined (n16) -#if defined (UMAXV) - printf ("ns32k-encore-sysv\n"); exit (0); -#else -#if defined (CMU) - printf ("ns32k-encore-mach\n"); exit (0); -#else - printf ("ns32k-encore-bsd\n"); exit (0); -#endif -#endif -#endif - -#if defined (__386BSD__) - printf ("i386-pc-bsd\n"); exit (0); -#endif - -#if defined (sequent) -#if defined (i386) - printf ("i386-sequent-dynix\n"); exit (0); -#endif -#if defined (ns32000) - printf ("ns32k-sequent-dynix\n"); exit (0); -#endif -#endif - -#if defined (_SEQUENT_) - struct utsname un; - - uname(&un); - - if (strncmp(un.version, "V2", 2) == 0) { - printf ("i386-sequent-ptx2\n"); exit (0); - } - if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ - printf ("i386-sequent-ptx1\n"); exit (0); - } - printf ("i386-sequent-ptx\n"); exit (0); - -#endif - -#if defined (vax) -#if !defined (ultrix) - printf ("vax-dec-bsd\n"); exit (0); -#else - printf ("vax-dec-ultrix\n"); exit (0); -#endif -#endif - -#if defined (alliant) && defined (i860) - printf ("i860-alliant-bsd\n"); exit (0); -#endif - - exit (1); -} -EOF - -${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm dummy.c dummy && exit 0 -rm -f dummy.c dummy - -# Apollos put the system type in the environment. - -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } - -# Convex versions that predate uname can use getsysinfo(1) - -if [ -x /usr/convex/getsysinfo ] -then - case `getsysinfo -f cpu_type` in - c1*) - echo c1-convex-bsd - exit 0 ;; - c2*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit 0 ;; - c34*) - echo c34-convex-bsd - exit 0 ;; - c38*) - echo c38-convex-bsd - exit 0 ;; - c4*) - echo c4-convex-bsd - exit 0 ;; - esac -fi - -#echo '(Unable to guess system type)' 1>&2 - -exit 1 diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/config.sub b/irrlicht-1.6/source/Irrlicht/jpeglib/config.sub deleted file mode 100644 index fe5c3646b..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/config.sub +++ /dev/null @@ -1,954 +0,0 @@ -#! /bin/sh -# Configuration validation subroutine script, version 1.1. -# Copyright (C) 1991, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. -# This file is (in principle) common to ALL GNU software. -# The presence of a machine in this file suggests that SOME GNU software -# can handle that machine. It does not imply ALL GNU software can. -# -# This file is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Configuration subroutine to validate and canonicalize a configuration type. -# Supply the specified configuration type as an argument. -# If it is invalid, we print an error message on stderr and exit with code 1. -# Otherwise, we print the canonical config type on stdout and succeed. - -# This file is supposed to be the same for all GNU packages -# and recognize all the CPU types, system types and aliases -# that are meaningful with *any* GNU software. -# Each package is responsible for reporting which valid configurations -# it does not support. The user should be able to distinguish -# a failure to support a valid configuration from a meaningless -# configuration. - -# The goal of this file is to map all the various variations of a given -# machine specification into a single specification in the form: -# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM -# or in some cases, the newer four-part form: -# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM -# It is wrong to echo any other type of specification. - -if [ x$1 = x ] -then - echo Configuration name missing. 1>&2 - echo "Usage: $0 CPU-MFR-OPSYS" 1>&2 - echo "or $0 ALIAS" 1>&2 - echo where ALIAS is a recognized configuration type. 1>&2 - exit 1 -fi - -# First pass through any local machine types. -case $1 in - *local*) - echo $1 - exit 0 - ;; - *) - ;; -esac - -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - linux-gnu*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac - -### Let's recognize common machines as not being operating systems so -### that things like config.sub decstation-3100 work. We also -### recognize some manufacturers as not being operating systems, so we -### can provide default operating systems below. -case $os in - -sun*os*) - # Prevent following clause from handling this invalid input. - ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple) - os= - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco5) - os=sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2v[4-9]*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -clix*) - basic_machine=clipper-intergraph - ;; - -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*) - os=-lynxos - ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` - ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` - ;; - -psos*) - os=-psos - ;; -esac - -# Decode aliases for certain CPU-COMPANY combinations. -case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - tahoe | i860 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \ - | arme[lb] | pyramid | mn10200 | mn10300 \ - | tron | a29k | 580 | i960 | h8300 | hppa | hppa1.0 | hppa1.1 \ - | alpha | alphaev5 | alphaev56 | we32k | ns16k | clipper \ - | i370 | sh | powerpc | powerpcle | 1750a | dsp16xx | pdp11 \ - | mips64 | mipsel | mips64el | mips64orion | mips64orionel \ - | mipstx39 | mipstx39el \ - | sparc | sparclet | sparclite | sparc64 | v850) - basic_machine=$basic_machine-unknown - ;; - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i[3456]86) - basic_machine=$basic_machine-pc - ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - vax-* | tahoe-* | i[3456]86-* | i860-* | m32r-* | m68k-* | m68000-* \ - | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \ - | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \ - | power-* | none-* | 580-* | cray2-* | h8300-* | i960-* \ - | xmp-* | ymp-* | hppa-* | hppa1.0-* | hppa1.1-* \ - | alpha-* | alphaev5-* | alphaev56-* | we32k-* | cydra-* \ - | ns16k-* | pn-* | np1-* | xps100-* | clipper-* | orion-* \ - | sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \ - | sparc64-* | mips64-* | mipsel-* \ - | mips64el-* | mips64orion-* | mips64orionel-* \ - | mipstx39-* | mipstx39el-* \ - | f301-*) - ;; - # Recognize the various machine names and aliases which stand - # for a CPU type and a company and sometimes even an OS. - 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att - ;; - 3b*) - basic_machine=we32k-att - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-cbm - ;; - amigaos | amigados) - basic_machine=m68k-cbm - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-cbm - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | ymp) - basic_machine=ymp-cray - os=-unicos - ;; - cray2) - basic_machine=cray2-cray - os=-unicos - ;; - [ctj]90-cray) - basic_machine=c90-cray - os=-unicos - ;; - crds | unos) - basic_machine=m68k-crds - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec - ;; - delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd - ;; - encore | umax | mmax) - basic_machine=ns32k-encore - ;; - fx2800) - basic_machine=i860-alliant - ;; - genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux - ;; - hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp - ;; - hp9k3[2-9][0-9]) - basic_machine=m68k-hp - ;; - hp9k7[0-9][0-9] | hp7[0-9][0-9] | hp9k8[0-9]7 | hp8[0-9]7) - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppa-next) - os=-nextstep3 - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm - os=-mvs - ;; -# I'm not sure what "Sysv32" means. Should this be sysv3.2? - i[3456]86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 - ;; - i[3456]86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 - ;; - i[3456]86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv - ;; - i[3456]86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) - ;; - *) - os=-irix4 - ;; - esac - ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - miniframe) - basic_machine=m68000-convergent - ;; - mipsel*-linux*) - basic_machine=mipsel-unknown - os=-linux-gnu - ;; - mips*-linux*) - basic_machine=mips-unknown - os=-linux-gnu - ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos - ;; - news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) - ;; - -ns2*) - os=-nextstep2 - ;; - *) - os=-nextstep3 - ;; - esac - ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - np1) - basic_machine=np1-gould - ;; - pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - pbd) - basic_machine=sparc-tti - ;; - pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 - ;; - pentium | p5) - basic_machine=i586-intel - ;; - pentiumpro | p6) - basic_machine=i686-intel - ;; - pentium-* | p5-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumpro-* | p6-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - k5) - # We don't have specific support for AMD's K5 yet, so just call it a Pentium - basic_machine=i586-amd - ;; - nexen) - # We don't have specific support for Nexgen yet, so just call it a Pentium - basic_machine=i586-nexgen - ;; - pn) - basic_machine=pn-gould - ;; - power) basic_machine=rs6000-ibm - ;; - ppc) basic_machine=powerpc-unknown - ;; - ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppcle | powerpclittle | ppc-le | powerpc-little) - basic_machine=powerpcle-unknown - ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ps2) - basic_machine=i386-ibm - ;; - rm[46]00) - basic_machine=mips-siemens - ;; - rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - sequent) - basic_machine=i386-sequent - ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 - ;; - spur) - basic_machine=spur-unknown - ;; - sun2) - basic_machine=m68000-sun - ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 - ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 - ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 - ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 - ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 - ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 - ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 - ;; - sun3 | sun3-*) - basic_machine=m68k-sun - ;; - sun4) - basic_machine=sparc-sun - ;; - sun386 | sun386i | roadrunner) - basic_machine=i386-sun - ;; - symmetry) - basic_machine=i386-sequent - os=-dynix - ;; - tx39) - basic_machine=mipstx39-unknown - ;; - tx39el) - basic_machine=mipstx39el-unknown - ;; - tower | tower-32) - basic_machine=m68k-ncr - ;; - udi29k) - basic_machine=a29k-amd - os=-udi - ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 - ;; - vaxv) - basic_machine=vax-dec - os=-sysv - ;; - vms) - basic_machine=vax-dec - os=-vms - ;; - vpp*|vx|vx-*) - basic_machine=f301-fujitsu - ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks - ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks - ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks - ;; - xmp) - basic_machine=xmp-cray - os=-unicos - ;; - xps | xps100) - basic_machine=xps100-honeywell - ;; - none) - basic_machine=none-none - os=-none - ;; - -# Here we handle the default manufacturer of certain CPU types. It is in -# some cases the only manufacturer, in others, it is the most popular. - mips) - if [ x$os = x-linux-gnu ]; then - basic_machine=mips-unknown - else - basic_machine=mips-mips - fi - ;; - romp) - basic_machine=romp-ibm - ;; - rs6000) - basic_machine=rs6000-ibm - ;; - vax) - basic_machine=vax-dec - ;; - pdp11) - basic_machine=pdp11-dec - ;; - we32k) - basic_machine=we32k-att - ;; - sparc) - basic_machine=sparc-sun - ;; - cydra) - basic_machine=cydra-cydrome - ;; - orion) - basic_machine=orion-highlevel - ;; - orion105) - basic_machine=clipper-highlevel - ;; - *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; -esac - -# Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` - ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` - ;; - *) - ;; -esac - -# Decode manufacturer-specific aliases for certain operating systems. - -if [ x"$os" != x"" ] -then -case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -solaris1 | -solaris1.*) - os=`echo $os | sed -e 's|solaris1|sunos4|'` - ;; - -solaris) - os=-solaris2 - ;; - -svr4*) - os=-sysv4 - ;; - -unixware*) - os=-sysv4.2uw - ;; - -gnu/linux*) - os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` - ;; - # First accept the basic system types. - # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. - # -sysv* is not here because it comes later, after sysvr4. - -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ - | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -cygwin32* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -uxpv*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - -linux*) - os=`echo $os | sed -e 's|linux|linux-gnu|'` - ;; - -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` - ;; - -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` - ;; - -osfrose*) - os=-osfrose - ;; - -osf*) - os=-osf - ;; - -utek*) - os=-bsd - ;; - -dynix*) - os=-bsd - ;; - -acis*) - os=-aos - ;; - -ctix* | -uts*) - os=-sysv - ;; - -ns2 ) - os=-nextstep2 - ;; - # Preserve the version number of sinix5. - -sinix5.*) - os=`echo $os | sed -e 's|sinix|sysv|'` - ;; - -sinix*) - os=-sysv4 - ;; - -triton*) - os=-sysv3 - ;; - -oss*) - os=-sysv3 - ;; - -svr4) - os=-sysv4 - ;; - -svr3) - os=-sysv3 - ;; - -sysvr4) - os=-sysv4 - ;; - # This must come after -sysvr4. - -sysv*) - ;; - -xenix) - os=-xenix - ;; - -none) - ;; - *) - # Get rid of the `-' at the beginning of $os. - os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 - exit 1 - ;; -esac -else - -# Here we handle the default operating systems that come with various machines. -# The value should be what the vendor currently ships out the door with their -# machine or put another way, the most popular os provided with the machine. - -# Note that if you're going to try to match "-MANUFACTURER" here (say, -# "-sun"), then you have to tell the case statement up towards the top -# that MANUFACTURER isn't an operating system. Otherwise, code above -# will signal an error saying that MANUFACTURER isn't an operating -# system, and we'll never get to this point. - -case $basic_machine in - *-acorn) - os=-riscix1.2 - ;; - arm*-semi) - os=-aout - ;; - pdp11-*) - os=-none - ;; - *-dec | vax-*) - os=-ultrix4.2 - ;; - m68*-apollo) - os=-domain - ;; - i386-sun) - os=-sunos4.0.2 - ;; - m68000-sun) - os=-sunos3 - # This also exists in the configure program, but was not the - # default. - # os=-sunos4 - ;; - *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 - ;; - sparc-* | *-sun) - os=-sunos4.1.1 - ;; - *-ibm) - os=-aix - ;; - *-hp) - os=-hpux - ;; - *-hitachi) - os=-hiux - ;; - i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv - ;; - *-cbm) - os=-amigaos - ;; - *-dg) - os=-dgux - ;; - *-dolphin) - os=-sysv3 - ;; - m68k-ccur) - os=-rtu - ;; - m88k-omron*) - os=-luna - ;; - *-next ) - os=-nextstep - ;; - *-sequent) - os=-ptx - ;; - *-crds) - os=-unos - ;; - *-ns) - os=-genix - ;; - i370-*) - os=-mvs - ;; - *-next) - os=-nextstep3 - ;; - *-gould) - os=-sysv - ;; - *-highlevel) - os=-bsd - ;; - *-encore) - os=-bsd - ;; - *-sgi) - os=-irix - ;; - *-siemens) - os=-sysv4 - ;; - *-masscomp) - os=-rtu - ;; - f301-fujitsu) - os=-uxpv - ;; - *) - os=-none - ;; -esac -fi - -# Here we handle the case where we know the os, and the CPU type, but not the -# manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - -riscix*) - vendor=acorn - ;; - -sunos*) - vendor=sun - ;; - -aix*) - vendor=ibm - ;; - -hpux*) - vendor=hp - ;; - -hiux*) - vendor=hitachi - ;; - -unos*) - vendor=crds - ;; - -dgux*) - vendor=dg - ;; - -luna*) - vendor=omron - ;; - -genix*) - vendor=ns - ;; - -mvs*) - vendor=ibm - ;; - -ptx*) - vendor=sequent - ;; - -vxsim* | -vxworks*) - vendor=wrs - ;; - -aux*) - vendor=apple - ;; - esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` - ;; -esac - -echo $basic_machine$os diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/configure b/irrlicht-1.6/source/Irrlicht/jpeglib/configure deleted file mode 100644 index d3239e707..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/configure +++ /dev/null @@ -1,2011 +0,0 @@ -#! /bin/sh - -# Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf version 2.12 -# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. -# -# This configure script is free software; the Free Software Foundation -# gives unlimited permission to copy, distribute and modify it. - -# Defaults: -ac_help= -ac_default_prefix=/usr/local -# Any additions from configure.in: -ac_help="$ac_help - --enable-shared build shared library using GNU libtool" -ac_help="$ac_help - --enable-static build static library using GNU libtool" -ac_help="$ac_help - --enable-maxmem[=N] enable use of temp files, set max mem usage to N MB" -ac_help="$ac_help -" - -# Initialize some variables set by options. -# The variables have the same names as the options, with -# dashes changed to underlines. -build=NONE -cache_file=./config.cache -exec_prefix=NONE -host=NONE -no_create= -nonopt=NONE -no_recursion= -prefix=NONE -program_prefix=NONE -program_suffix=NONE -program_transform_name=s,x,x, -silent= -site= -srcdir= -target=NONE -verbose= -x_includes=NONE -x_libraries=NONE -bindir='${exec_prefix}/bin' -sbindir='${exec_prefix}/sbin' -libexecdir='${exec_prefix}/libexec' -datadir='${prefix}/share' -sysconfdir='${prefix}/etc' -sharedstatedir='${prefix}/com' -localstatedir='${prefix}/var' -libdir='${exec_prefix}/lib' -includedir='${prefix}/include' -oldincludedir='/usr/include' -infodir='${prefix}/info' -mandir='${prefix}/man' - -# Initialize some other variables. -subdirs= -MFLAGS= MAKEFLAGS= -# Maximum number of lines to put in a shell here document. -ac_max_here_lines=12 - -ac_prev= -for ac_option -do - - # If the previous option needs an argument, assign it. - if test -n "$ac_prev"; then - eval "$ac_prev=\$ac_option" - ac_prev= - continue - fi - - case "$ac_option" in - -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; - *) ac_optarg= ;; - esac - - # Accept the important Cygnus configure options, so we can diagnose typos. - - case "$ac_option" in - - -bindir | --bindir | --bindi | --bind | --bin | --bi) - ac_prev=bindir ;; - -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) - bindir="$ac_optarg" ;; - - -build | --build | --buil | --bui | --bu) - ac_prev=build ;; - -build=* | --build=* | --buil=* | --bui=* | --bu=*) - build="$ac_optarg" ;; - - -cache-file | --cache-file | --cache-fil | --cache-fi \ - | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) - ac_prev=cache_file ;; - -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ - | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) - cache_file="$ac_optarg" ;; - - -datadir | --datadir | --datadi | --datad | --data | --dat | --da) - ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ - | --da=*) - datadir="$ac_optarg" ;; - - -disable-* | --disable-*) - ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then - { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } - fi - ac_feature=`echo $ac_feature| sed 's/-/_/g'` - eval "enable_${ac_feature}=no" ;; - - -enable-* | --enable-*) - ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then - { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } - fi - ac_feature=`echo $ac_feature| sed 's/-/_/g'` - case "$ac_option" in - *=*) ;; - *) ac_optarg=yes ;; - esac - eval "enable_${ac_feature}='$ac_optarg'" ;; - - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ - | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ - | --exec | --exe | --ex) - ac_prev=exec_prefix ;; - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ - | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ - | --exec=* | --exe=* | --ex=*) - exec_prefix="$ac_optarg" ;; - - -gas | --gas | --ga | --g) - # Obsolete; use --with-gas. - with_gas=yes ;; - - -help | --help | --hel | --he) - # Omit some internal or obsolete options to make the list less imposing. - # This message is too long to be a string in the A/UX 3.1 sh. - cat << EOF -Usage: configure [options] [host] -Options: [defaults in brackets after descriptions] -Configuration: - --cache-file=FILE cache test results in FILE - --help print this message - --no-create do not create output files - --quiet, --silent do not print \`checking...' messages - --version print the version of autoconf that created configure -Directory and file names: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [same as prefix] - --bindir=DIR user executables in DIR [EPREFIX/bin] - --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] - --libexecdir=DIR program executables in DIR [EPREFIX/libexec] - --datadir=DIR read-only architecture-independent data in DIR - [PREFIX/share] - --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data in DIR - [PREFIX/com] - --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] - --libdir=DIR object code libraries in DIR [EPREFIX/lib] - --includedir=DIR C header files in DIR [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] - --infodir=DIR info documentation in DIR [PREFIX/info] - --mandir=DIR man documentation in DIR [PREFIX/man] - --srcdir=DIR find the sources in DIR [configure dir or ..] - --program-prefix=PREFIX prepend PREFIX to installed program names - --program-suffix=SUFFIX append SUFFIX to installed program names - --program-transform-name=PROGRAM - run sed PROGRAM on installed program names -EOF - cat << EOF -Host type: - --build=BUILD configure for building on BUILD [BUILD=HOST] - --host=HOST configure for HOST [guessed] - --target=TARGET configure for TARGET [TARGET=HOST] -Features and packages: - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] - --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --x-includes=DIR X include files are in DIR - --x-libraries=DIR X library files are in DIR -EOF - if test -n "$ac_help"; then - echo "--enable and --with options recognized:$ac_help" - fi - exit 0 ;; - - -host | --host | --hos | --ho) - ac_prev=host ;; - -host=* | --host=* | --hos=* | --ho=*) - host="$ac_optarg" ;; - - -includedir | --includedir | --includedi | --included | --include \ - | --includ | --inclu | --incl | --inc) - ac_prev=includedir ;; - -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ - | --includ=* | --inclu=* | --incl=* | --inc=*) - includedir="$ac_optarg" ;; - - -infodir | --infodir | --infodi | --infod | --info | --inf) - ac_prev=infodir ;; - -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) - infodir="$ac_optarg" ;; - - -libdir | --libdir | --libdi | --libd) - ac_prev=libdir ;; - -libdir=* | --libdir=* | --libdi=* | --libd=*) - libdir="$ac_optarg" ;; - - -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ - | --libexe | --libex | --libe) - ac_prev=libexecdir ;; - -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ - | --libexe=* | --libex=* | --libe=*) - libexecdir="$ac_optarg" ;; - - -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst \ - | --locals | --local | --loca | --loc | --lo) - ac_prev=localstatedir ;; - -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* \ - | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) - localstatedir="$ac_optarg" ;; - - -mandir | --mandir | --mandi | --mand | --man | --ma | --m) - ac_prev=mandir ;; - -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) - mandir="$ac_optarg" ;; - - -nfp | --nfp | --nf) - # Obsolete; use --without-fp. - with_fp=no ;; - - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c) - no_create=yes ;; - - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) - no_recursion=yes ;; - - -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ - | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ - | --oldin | --oldi | --old | --ol | --o) - ac_prev=oldincludedir ;; - -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ - | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ - | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) - oldincludedir="$ac_optarg" ;; - - -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) - ac_prev=prefix ;; - -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix="$ac_optarg" ;; - - -program-prefix | --program-prefix | --program-prefi | --program-pref \ - | --program-pre | --program-pr | --program-p) - ac_prev=program_prefix ;; - -program-prefix=* | --program-prefix=* | --program-prefi=* \ - | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) - program_prefix="$ac_optarg" ;; - - -program-suffix | --program-suffix | --program-suffi | --program-suff \ - | --program-suf | --program-su | --program-s) - ac_prev=program_suffix ;; - -program-suffix=* | --program-suffix=* | --program-suffi=* \ - | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) - program_suffix="$ac_optarg" ;; - - -program-transform-name | --program-transform-name \ - | --program-transform-nam | --program-transform-na \ - | --program-transform-n | --program-transform- \ - | --program-transform | --program-transfor \ - | --program-transfo | --program-transf \ - | --program-trans | --program-tran \ - | --progr-tra | --program-tr | --program-t) - ac_prev=program_transform_name ;; - -program-transform-name=* | --program-transform-name=* \ - | --program-transform-nam=* | --program-transform-na=* \ - | --program-transform-n=* | --program-transform-=* \ - | --program-transform=* | --program-transfor=* \ - | --program-transfo=* | --program-transf=* \ - | --program-trans=* | --program-tran=* \ - | --progr-tra=* | --program-tr=* | --program-t=*) - program_transform_name="$ac_optarg" ;; - - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - silent=yes ;; - - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) - ac_prev=sbindir ;; - -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ - | --sbi=* | --sb=*) - sbindir="$ac_optarg" ;; - - -sharedstatedir | --sharedstatedir | --sharedstatedi \ - | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ - | --sharedst | --shareds | --shared | --share | --shar \ - | --sha | --sh) - ac_prev=sharedstatedir ;; - -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ - | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ - | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ - | --sha=* | --sh=*) - sharedstatedir="$ac_optarg" ;; - - -site | --site | --sit) - ac_prev=site ;; - -site=* | --site=* | --sit=*) - site="$ac_optarg" ;; - - -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) - ac_prev=srcdir ;; - -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) - srcdir="$ac_optarg" ;; - - -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ - | --syscon | --sysco | --sysc | --sys | --sy) - ac_prev=sysconfdir ;; - -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ - | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) - sysconfdir="$ac_optarg" ;; - - -target | --target | --targe | --targ | --tar | --ta | --t) - ac_prev=target ;; - -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) - target="$ac_optarg" ;; - - -v | -verbose | --verbose | --verbos | --verbo | --verb) - verbose=yes ;; - - -version | --version | --versio | --versi | --vers) - echo "configure generated by autoconf version 2.12" - exit 0 ;; - - -with-* | --with-*) - ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then - { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } - fi - ac_package=`echo $ac_package| sed 's/-/_/g'` - case "$ac_option" in - *=*) ;; - *) ac_optarg=yes ;; - esac - eval "with_${ac_package}='$ac_optarg'" ;; - - -without-* | --without-*) - ac_package=`echo $ac_option|sed -e 's/-*without-//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then - { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } - fi - ac_package=`echo $ac_package| sed 's/-/_/g'` - eval "with_${ac_package}=no" ;; - - --x) - # Obsolete; use --with-x. - with_x=yes ;; - - -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ - | --x-incl | --x-inc | --x-in | --x-i) - ac_prev=x_includes ;; - -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ - | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) - x_includes="$ac_optarg" ;; - - -x-libraries | --x-libraries | --x-librarie | --x-librari \ - | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) - ac_prev=x_libraries ;; - -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ - | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries="$ac_optarg" ;; - - -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } - ;; - - *=*) - varname=`echo "$ac_option"|sed -e 's/=.*//'` - # Reject names that aren't valid shell variable names. - if test -n "`echo $varname| sed 's/[a-zA-Z0-9_]//g'`"; then - { echo "configure: error: $varname: invalid shell variable name" 1>&2; exit 1; } - fi - val="`echo "$ac_option"|sed 's/[^=]*=//'`" - test -n "$verbose" && echo " setting shell variable $varname to $val" - eval "$varname='$val'" - eval "export $varname" ;; - - *) - if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then - echo "configure: warning: $ac_option: invalid host type" 1>&2 - fi - if test "x$nonopt" != xNONE; then - { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } - fi - nonopt="$ac_option" - ;; - - esac -done - -if test -n "$ac_prev"; then - { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } -fi - -trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 - -# File descriptor usage: -# 0 standard input -# 1 file creation -# 2 errors and warnings -# 3 some systems may open it to /dev/tty -# 4 used on the Kubota Titan -# 6 checking for... messages and results -# 5 compiler messages saved in config.log -if test "$silent" = yes; then - exec 6>/dev/null -else - exec 6>&1 -fi -exec 5>./config.log - -echo "\ -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. -" 1>&5 - -# Strip out --no-create and --no-recursion so they do not pile up. -# Also quote any args containing shell metacharacters. -ac_configure_args= -for ac_arg -do - case "$ac_arg" in - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c) ;; - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) - ac_configure_args="$ac_configure_args '$ac_arg'" ;; - *) ac_configure_args="$ac_configure_args $ac_arg" ;; - esac -done - -# NLS nuisances. -# Only set these to C if already set. These must not be set unconditionally -# because not all systems understand e.g. LANG=C (notably SCO). -# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! -# Non-C LC_CTYPE values break the ctype check. -if test "${LANG+set}" = set; then LANG=C; export LANG; fi -if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi -if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi -if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi - -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -rf conftest* confdefs.h -# AIX cpp loses on an empty file, so make sure it contains at least a newline. -echo > confdefs.h - -# A filename unique to this package, relative to the directory that -# configure is in, which we can look for to find out if srcdir is correct. -ac_unique_file=jcmaster.c - -# Find the source files, if location was not specified. -if test -z "$srcdir"; then - ac_srcdir_defaulted=yes - # Try the directory containing this script, then its parent. - ac_prog=$0 - ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` - test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. - srcdir=$ac_confdir - if test ! -r $srcdir/$ac_unique_file; then - srcdir=.. - fi -else - ac_srcdir_defaulted=no -fi -if test ! -r $srcdir/$ac_unique_file; then - if test "$ac_srcdir_defaulted" = yes; then - { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } - else - { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } - fi -fi -srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` - -# Prefer explicitly selected file to automatically selected ones. -if test -z "$CONFIG_SITE"; then - if test "x$prefix" != xNONE; then - CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" - else - CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" - fi -fi -for ac_site_file in $CONFIG_SITE; do - if test -r "$ac_site_file"; then - echo "loading site script $ac_site_file" - . "$ac_site_file" - fi -done - - -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - -if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then - # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. - if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then - ac_n= ac_c=' -' ac_t=' ' - else - ac_n=-n ac_c= ac_t= - fi -else - ac_n= ac_c='\c' ac_t= -fi - - - -# Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:538: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_CC="gcc" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -CC="$ac_cv_prog_CC" -if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:567: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - ac_prog_rejected=no - for ac_dir in $PATH; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - break - fi - done - IFS="$ac_save_ifs" -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# -gt 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - set dummy "$ac_dir/$ac_word" "$@" - shift - ac_cv_prog_CC="$@" - fi -fi -fi -fi -CC="$ac_cv_prog_CC" -if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - - test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } -fi - -echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:615: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 - -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - -cat > conftest.$ac_ext <<EOF -#line 625 "configure" -#include "confdefs.h" -main(){return(0);} -EOF -if { (eval echo configure:629: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then - ac_cv_prog_cc_works=yes - # If we can't run a trivial program, we are probably using a cross compiler. - if (./conftest; exit) 2>/dev/null; then - ac_cv_prog_cc_cross=no - else - ac_cv_prog_cc_cross=yes - fi -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - ac_cv_prog_cc_works=no -fi -rm -fr conftest* - -echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 -if test $ac_cv_prog_cc_works = no; then - { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } -fi -echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:649: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 -echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 -cross_compiling=$ac_cv_prog_cc_cross - -echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:654: checking whether we are using GNU C" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.c <<EOF -#ifdef __GNUC__ - yes; -#endif -EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:663: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then - ac_cv_prog_gcc=yes -else - ac_cv_prog_gcc=no -fi -fi - -echo "$ac_t""$ac_cv_prog_gcc" 1>&6 - -if test $ac_cv_prog_gcc = yes; then - GCC=yes - test "${CFLAGS+set}" = set || CFLAGS="-O2" -else - GCC= - test "${CFLAGS+set}" = set || CFLAGS="-O" -fi - -echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:681: checking how to run the C preprocessor" >&5 -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then -if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - # This must be in double quotes, not single quotes, because CPP may get - # substituted into the Makefile and "${CC-cc}" will confuse make. - CPP="${CC-cc} -E" - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. - cat > conftest.$ac_ext <<EOF -#line 696 "configure" -#include "confdefs.h" -#include <assert.h> -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:702: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` -if test -z "$ac_err"; then - : -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP="${CC-cc} -E -traditional-cpp" - cat > conftest.$ac_ext <<EOF -#line 713 "configure" -#include "confdefs.h" -#include <assert.h> -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:719: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` -if test -z "$ac_err"; then - : -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP=/lib/cpp -fi -rm -f conftest* -fi -rm -f conftest* - ac_cv_prog_CPP="$CPP" -fi - CPP="$ac_cv_prog_CPP" -else - ac_cv_prog_CPP="$CPP" -fi -echo "$ac_t""$CPP" 1>&6 - -echo $ac_n "checking for function prototypes""... $ac_c" 1>&6 -echo "configure:742: checking for function prototypes" >&5 -if eval "test \"`echo '$''{'ijg_cv_have_prototypes'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 747 "configure" -#include "confdefs.h" - -int testfunction (int arg1, int * arg2); /* check prototypes */ -struct methods_struct { /* check method-pointer declarations */ - int (*error_exit) (char *msgtext); - int (*trace_message) (char *msgtext); - int (*another_method) (void); -}; -int testfunction (int arg1, int * arg2) /* check definitions */ -{ return arg2[arg1]; } -int test2function (void) /* check void arg list */ -{ return 0; } - -int main() { - -; return 0; } -EOF -if { (eval echo configure:765: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - ijg_cv_have_prototypes=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ijg_cv_have_prototypes=no -fi -rm -f conftest* -fi - -echo "$ac_t""$ijg_cv_have_prototypes" 1>&6 -if test $ijg_cv_have_prototypes = yes; then - cat >> confdefs.h <<\EOF -#define HAVE_PROTOTYPES -EOF - -else - echo Your compiler does not seem to know about function prototypes. - echo Perhaps it needs a special switch to enable ANSI C mode. - echo If so, we recommend running configure like this: - echo " ./configure CC='cc -switch'" - echo where -switch is the proper switch. -fi -ac_safe=`echo "stddef.h" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for stddef.h""... $ac_c" 1>&6 -echo "configure:792: checking for stddef.h" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 797 "configure" -#include "confdefs.h" -#include <stddef.h> -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:802: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - cat >> confdefs.h <<\EOF -#define HAVE_STDDEF_H -EOF - -else - echo "$ac_t""no" 1>&6 -fi - -ac_safe=`echo "stdlib.h" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for stdlib.h""... $ac_c" 1>&6 -echo "configure:828: checking for stdlib.h" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 833 "configure" -#include "confdefs.h" -#include <stdlib.h> -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:838: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - cat >> confdefs.h <<\EOF -#define HAVE_STDLIB_H -EOF - -else - echo "$ac_t""no" 1>&6 -fi - -ac_safe=`echo "string.h" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for string.h""... $ac_c" 1>&6 -echo "configure:864: checking for string.h" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 869 "configure" -#include "confdefs.h" -#include <string.h> -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:874: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - : -else - echo "$ac_t""no" 1>&6 -cat >> confdefs.h <<\EOF -#define NEED_BSD_STRINGS -EOF - -fi - -echo $ac_n "checking for size_t""... $ac_c" 1>&6 -echo "configure:900: checking for size_t" >&5 -cat > conftest.$ac_ext <<EOF -#line 902 "configure" -#include "confdefs.h" - -#ifdef HAVE_STDDEF_H -#include <stddef.h> -#endif -#ifdef HAVE_STDLIB_H -#include <stdlib.h> -#endif -#include <stdio.h> -#ifdef NEED_BSD_STRINGS -#include <strings.h> -#else -#include <string.h> -#endif -typedef size_t my_size_t; - -int main() { - my_size_t foovar; -; return 0; } -EOF -if { (eval echo configure:923: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - ijg_size_t_ok=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ijg_size_t_ok="not ANSI, perhaps it is in sys/types.h" -fi -rm -f conftest* -echo "$ac_t""$ijg_size_t_ok" 1>&6 -if test "$ijg_size_t_ok" != yes; then -ac_safe=`echo "sys/types.h" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for sys/types.h""... $ac_c" 1>&6 -echo "configure:937: checking for sys/types.h" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 942 "configure" -#include "confdefs.h" -#include <sys/types.h> -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:947: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - cat >> confdefs.h <<\EOF -#define NEED_SYS_TYPES_H -EOF - -cat > conftest.$ac_ext <<EOF -#line 968 "configure" -#include "confdefs.h" -#include <sys/types.h> -EOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "size_t" >/dev/null 2>&1; then - rm -rf conftest* - ijg_size_t_ok="size_t is in sys/types.h" -else - rm -rf conftest* - ijg_size_t_ok=no -fi -rm -f conftest* - -else - echo "$ac_t""no" 1>&6 -ijg_size_t_ok=no -fi - -echo "$ac_t""$ijg_size_t_ok" 1>&6 -if test "$ijg_size_t_ok" = no; then - echo Type size_t is not defined in any of the usual places. - echo Try putting '"typedef unsigned int size_t;"' in jconfig.h. -fi -fi -echo $ac_n "checking for type unsigned char""... $ac_c" 1>&6 -echo "configure:994: checking for type unsigned char" >&5 -cat > conftest.$ac_ext <<EOF -#line 996 "configure" -#include "confdefs.h" - -int main() { - unsigned char un_char; -; return 0; } -EOF -if { (eval echo configure:1003: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - echo "$ac_t""yes" 1>&6 -cat >> confdefs.h <<\EOF -#define HAVE_UNSIGNED_CHAR -EOF - -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - echo "$ac_t""no" 1>&6 -fi -rm -f conftest* -echo $ac_n "checking for type unsigned short""... $ac_c" 1>&6 -echo "configure:1018: checking for type unsigned short" >&5 -cat > conftest.$ac_ext <<EOF -#line 1020 "configure" -#include "confdefs.h" - -int main() { - unsigned short un_short; -; return 0; } -EOF -if { (eval echo configure:1027: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - echo "$ac_t""yes" 1>&6 -cat >> confdefs.h <<\EOF -#define HAVE_UNSIGNED_SHORT -EOF - -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - echo "$ac_t""no" 1>&6 -fi -rm -f conftest* -echo $ac_n "checking for type void""... $ac_c" 1>&6 -echo "configure:1042: checking for type void" >&5 -cat > conftest.$ac_ext <<EOF -#line 1044 "configure" -#include "confdefs.h" - -/* Caution: a C++ compiler will insist on valid prototypes */ -typedef void * void_ptr; /* check void * */ -#ifdef HAVE_PROTOTYPES /* check ptr to function returning void */ -typedef void (*void_func) (int a, int b); -#else -typedef void (*void_func) (); -#endif - -#ifdef HAVE_PROTOTYPES /* check void function result */ -void test3function (void_ptr arg1, void_func arg2) -#else -void test3function (arg1, arg2) - void_ptr arg1; - void_func arg2; -#endif -{ - char * locptr = (char *) arg1; /* check casting to and from void * */ - arg1 = (void *) locptr; - (*arg2) (1, 2); /* check call of fcn returning void */ -} - -int main() { - -; return 0; } -EOF -if { (eval echo configure:1072: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - echo "$ac_t""yes" 1>&6 -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - echo "$ac_t""no" 1>&6 -cat >> confdefs.h <<\EOF -#define void char -EOF - -fi -rm -f conftest* - -echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:1088: checking for working const" >&5 -if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 1093 "configure" -#include "confdefs.h" - -int main() { - -/* Ultrix mips cc rejects this. */ -typedef int charset[2]; const charset x; -/* SunOS 4.1.1 cc rejects this. */ -char const *const *ccp; -char **p; -/* NEC SVR4.0.2 mips cc rejects this. */ -struct point {int x, y;}; -static struct point const zero = {0,0}; -/* AIX XL C 1.02.0.0 rejects this. - It does not let you subtract one const X* pointer from another in an arm - of an if-expression whose if-part is not a constant expression */ -const char *g = "string"; -ccp = &g + (g ? g-g : 0); -/* HPUX 7.0 cc rejects these. */ -++ccp; -p = (char**) ccp; -ccp = (char const *const *) p; -{ /* SCO 3.2v4 cc rejects this. */ - char *t; - char const *s = 0 ? (char *) 0 : (char const *) 0; - - *t++ = 0; -} -{ /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ - int x[] = {25, 17}; - const int *foo = &x[0]; - ++foo; -} -{ /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ - typedef const int *iptr; - iptr p = 0; - ++p; -} -{ /* AIX XL C 1.02.0.0 rejects this saying - "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ - struct s { int j; const int *ap[3]; }; - struct s *b; b->j = 5; -} -{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ - const int foo = 10; -} - -; return 0; } -EOF -if { (eval echo configure:1142: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - ac_cv_c_const=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_c_const=no -fi -rm -f conftest* -fi - -echo "$ac_t""$ac_cv_c_const" 1>&6 -if test $ac_cv_c_const = no; then - cat >> confdefs.h <<\EOF -#define const -EOF - -fi - -echo $ac_n "checking for inline""... $ac_c" 1>&6 -echo "configure:1163: checking for inline" >&5 -ijg_cv_inline="" -cat > conftest.$ac_ext <<EOF -#line 1166 "configure" -#include "confdefs.h" - -int main() { -} __inline__ int foo() { return 0; } -int bar() { return foo(); -; return 0; } -EOF -if { (eval echo configure:1174: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - ijg_cv_inline="__inline__" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - cat > conftest.$ac_ext <<EOF -#line 1182 "configure" -#include "confdefs.h" - -int main() { -} __inline int foo() { return 0; } -int bar() { return foo(); -; return 0; } -EOF -if { (eval echo configure:1190: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - ijg_cv_inline="__inline" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - cat > conftest.$ac_ext <<EOF -#line 1198 "configure" -#include "confdefs.h" - -int main() { -} inline int foo() { return 0; } -int bar() { return foo(); -; return 0; } -EOF -if { (eval echo configure:1206: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - ijg_cv_inline="inline" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 -fi -rm -f conftest* -fi -rm -f conftest* -fi -rm -f conftest* -echo "$ac_t""$ijg_cv_inline" 1>&6 -cat >> confdefs.h <<EOF -#define INLINE $ijg_cv_inline -EOF - -echo $ac_n "checking for broken incomplete types""... $ac_c" 1>&6 -echo "configure:1224: checking for broken incomplete types" >&5 -cat > conftest.$ac_ext <<EOF -#line 1226 "configure" -#include "confdefs.h" - typedef struct undefined_structure * undef_struct_ptr; -int main() { - -; return 0; } -EOF -if { (eval echo configure:1233: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - echo "$ac_t""ok" 1>&6 -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - echo "$ac_t""broken" 1>&6 -cat >> confdefs.h <<\EOF -#define INCOMPLETE_TYPES_BROKEN -EOF - -fi -rm -f conftest* -echo $ac_n "checking for short external names""... $ac_c" 1>&6 -echo "configure:1248: checking for short external names" >&5 -cat > conftest.$ac_ext <<EOF -#line 1250 "configure" -#include "confdefs.h" - -int possibly_duplicate_function () { return 0; } -int possibly_dupli_function () { return 1; } - -int main() { - -; return 0; } -EOF -if { (eval echo configure:1260: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then - rm -rf conftest* - echo "$ac_t""ok" 1>&6 -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - echo "$ac_t""short" 1>&6 -cat >> confdefs.h <<\EOF -#define NEED_SHORT_EXTERNAL_NAMES -EOF - -fi -rm -f conftest* -echo $ac_n "checking to see if char is signed""... $ac_c" 1>&6 -echo "configure:1275: checking to see if char is signed" >&5 -if test "$cross_compiling" = yes; then - echo Assuming that char is signed on target machine. -echo If it is unsigned, this will be a little bit inefficient. - -else - cat > conftest.$ac_ext <<EOF -#line 1282 "configure" -#include "confdefs.h" - -#ifdef HAVE_PROTOTYPES -int is_char_signed (int arg) -#else -int is_char_signed (arg) - int arg; -#endif -{ - if (arg == 189) { /* expected result for unsigned char */ - return 0; /* type char is unsigned */ - } - else if (arg != -67) { /* expected result for signed char */ - printf("Hmm, it seems 'char' is not eight bits wide on your machine.\n"); - printf("I fear the JPEG software will not work at all.\n\n"); - } - return 1; /* assume char is signed otherwise */ -} -char signed_char_check = (char) (-67); -main() { - exit(is_char_signed((int) signed_char_check)); -} -EOF -if { (eval echo configure:1306: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null -then - echo "$ac_t""no" 1>&6 -cat >> confdefs.h <<\EOF -#define CHAR_IS_UNSIGNED -EOF - -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - echo "$ac_t""yes" 1>&6 -fi -rm -fr conftest* -fi - -echo $ac_n "checking to see if right shift is signed""... $ac_c" 1>&6 -echo "configure:1323: checking to see if right shift is signed" >&5 -if test "$cross_compiling" = yes; then - echo "$ac_t""Assuming that right shift is signed on target machine." 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 1328 "configure" -#include "confdefs.h" - -#ifdef HAVE_PROTOTYPES -int is_shifting_signed (long arg) -#else -int is_shifting_signed (arg) - long arg; -#endif -/* See whether right-shift on a long is signed or not. */ -{ - long res = arg >> 4; - - if (res == -0x7F7E80CL) { /* expected result for signed shift */ - return 1; /* right shift is signed */ - } - /* see if unsigned-shift hack will fix it. */ - /* we can't just test exact value since it depends on width of long... */ - res |= (~0L) << (32-4); - if (res == -0x7F7E80CL) { /* expected result now? */ - return 0; /* right shift is unsigned */ - } - printf("Right shift isn't acting as I expect it to.\n"); - printf("I fear the JPEG software will not work at all.\n\n"); - return 0; /* try it with unsigned anyway */ -} -main() { - exit(is_shifting_signed(-0x7F7E80B1L)); -} -EOF -if { (eval echo configure:1358: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null -then - echo "$ac_t""no" 1>&6 -cat >> confdefs.h <<\EOF -#define RIGHT_SHIFT_IS_UNSIGNED -EOF - -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - echo "$ac_t""yes" 1>&6 -fi -rm -fr conftest* -fi - -echo $ac_n "checking to see if fopen accepts b spec""... $ac_c" 1>&6 -echo "configure:1375: checking to see if fopen accepts b spec" >&5 -if test "$cross_compiling" = yes; then - echo "$ac_t""Assuming that it does." 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 1380 "configure" -#include "confdefs.h" - -#include <stdio.h> -main() { - if (fopen("conftestdata", "wb") != NULL) - exit(0); - exit(1); -} -EOF -if { (eval echo configure:1390: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null -then - echo "$ac_t""yes" 1>&6 -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - echo "$ac_t""no" 1>&6 -cat >> confdefs.h <<\EOF -#define DONT_USE_B_MODE -EOF - -fi -rm -fr conftest* -fi - -ac_aux_dir= -for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do - if test -f $ac_dir/install-sh; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install-sh -c" - break - elif test -f $ac_dir/install.sh; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install.sh -c" - break - fi -done -if test -z "$ac_aux_dir"; then - { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; } -fi -ac_config_guess=$ac_aux_dir/config.guess -ac_config_sub=$ac_aux_dir/config.sub -ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. - -# Find a good install program. We prefer a C program (faster), -# so one script is as good as another. But avoid the broken or -# incompatible versions: -# SysV /etc/install, /usr/sbin/install -# SunOS /usr/etc/install -# IRIX /sbin/install -# AIX /bin/install -# AFS /usr/afsws/bin/install, which mishandles nonexistent args -# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" -# ./install, which can be erroneously created by make from ./install.sh. -echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:1436: checking for a BSD compatible install" >&5 -if test -z "$INSTALL"; then -if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do - # Account for people who put trailing slashes in PATH elements. - case "$ac_dir/" in - /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; - *) - # OSF1 and SCO ODT 3.0 have their own names for install. - for ac_prog in ginstall installbsd scoinst install; do - if test -f $ac_dir/$ac_prog; then - if test $ac_prog = install && - grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then - # AIX install. It has an incompatible calling convention. - # OSF/1 installbsd also uses dspmsg, but is usable. - : - else - ac_cv_path_install="$ac_dir/$ac_prog -c" - break 2 - fi - fi - done - ;; - esac - done - IFS="$ac_save_IFS" - -fi - if test "${ac_cv_path_install+set}" = set; then - INSTALL="$ac_cv_path_install" - else - # As a last resort, use the slow shell script. We don't cache a - # path for INSTALL within a source directory, because that will - # break other packages using the cache if that directory is - # removed, or if the path is relative. - INSTALL="$ac_install_sh" - fi -fi -echo "$ac_t""$INSTALL" 1>&6 - -# Use test -z because SunOS4 sh mishandles braces in ${var-val}. -# It thinks the first close brace ends the variable substitution. -test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' - -test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' - -# Extract the first word of "ranlib", so it can be a program name with args. -set dummy ranlib; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1488: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$RANLIB"; then - ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_RANLIB="ranlib" - break - fi - done - IFS="$ac_save_ifs" - test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":" -fi -fi -RANLIB="$ac_cv_prog_RANLIB" -if test -n "$RANLIB"; then - echo "$ac_t""$RANLIB" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - - -# Decide whether to use libtool, -# and if so whether to build shared, static, or both flavors of library. -LTSHARED="no" -# Check whether --enable-shared or --disable-shared was given. -if test "${enable_shared+set}" = set; then - enableval="$enable_shared" - LTSHARED="$enableval" -fi - -LTSTATIC="no" -# Check whether --enable-static or --disable-static was given. -if test "${enable_static+set}" = set; then - enableval="$enable_static" - LTSTATIC="$enableval" -fi - -if test "x$LTSHARED" != xno -o "x$LTSTATIC" != xno; then - USELIBTOOL="yes" - LIBTOOL="./libtool" - O="lo" - A="la" - LN='$(LIBTOOL) --mode=link $(CC)' - INSTALL_LIB='$(LIBTOOL) --mode=install ${INSTALL}' - INSTALL_PROGRAM="\$(LIBTOOL) --mode=install $INSTALL_PROGRAM" -else - USELIBTOOL="no" - LIBTOOL="" - O="o" - A="a" - LN='$(CC)' - INSTALL_LIB="$INSTALL_DATA" -fi - - - - - - -# Configure libtool if needed. -if test $USELIBTOOL = yes; then - disable_shared= - disable_static= - if test "x$LTSHARED" = xno; then - disable_shared="--disable-shared" - fi - if test "x$LTSTATIC" = xno; then - disable_static="--disable-static" - fi - $srcdir/ltconfig $disable_shared $disable_static $srcdir/ltmain.sh -fi - -# Select memory manager depending on user input. -# If no "-enable-maxmem", use jmemnobs -MEMORYMGR='jmemnobs.$(O)' -MAXMEM="no" -# Check whether --enable-maxmem or --disable-maxmem was given. -if test "${enable_maxmem+set}" = set; then - enableval="$enable_maxmem" - MAXMEM="$enableval" -fi - -# support --with-maxmem for backwards compatibility with IJG V5. -# Check whether --with-maxmem or --without-maxmem was given. -if test "${with_maxmem+set}" = set; then - withval="$with_maxmem" - MAXMEM="$withval" -fi - -if test "x$MAXMEM" = xyes; then - MAXMEM=1 -fi -if test "x$MAXMEM" != xno; then - if test -n "`echo $MAXMEM | sed 's/[0-9]//g'`"; then - { echo "configure: error: non-numeric argument to --enable-maxmem" 1>&2; exit 1; } - fi - DEFAULTMAXMEM=`expr $MAXMEM \* 1048576` -cat >> confdefs.h <<EOF -#define DEFAULT_MAX_MEM ${DEFAULTMAXMEM} -EOF - -echo $ac_n "checking for 'tmpfile()'""... $ac_c" 1>&6 -echo "configure:1596: checking for 'tmpfile()'" >&5 -cat > conftest.$ac_ext <<EOF -#line 1598 "configure" -#include "confdefs.h" -#include <stdio.h> -int main() { - FILE * tfile = tmpfile(); -; return 0; } -EOF -if { (eval echo configure:1605: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then - rm -rf conftest* - echo "$ac_t""yes" 1>&6 -MEMORYMGR='jmemansi.$(O)' -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - echo "$ac_t""no" 1>&6 -MEMORYMGR='jmemname.$(O)' -cat >> confdefs.h <<\EOF -#define NEED_SIGNAL_CATCHER -EOF - -echo $ac_n "checking for 'mktemp()'""... $ac_c" 1>&6 -echo "configure:1620: checking for 'mktemp()'" >&5 -cat > conftest.$ac_ext <<EOF -#line 1622 "configure" -#include "confdefs.h" - -int main() { - char fname[80]; mktemp(fname); -; return 0; } -EOF -if { (eval echo configure:1629: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then - rm -rf conftest* - echo "$ac_t""yes" 1>&6 -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - echo "$ac_t""no" 1>&6 -cat >> confdefs.h <<\EOF -#define NO_MKTEMP -EOF - -fi -rm -f conftest* -fi -rm -f conftest* -fi - - -# Extract the library version ID from jpeglib.h. -echo $ac_n "checking libjpeg version number""... $ac_c" 1>&6 -echo "configure:1650: checking libjpeg version number" >&5 -JPEG_LIB_VERSION=`sed -e '/^#define JPEG_LIB_VERSION/!d' -e 's/^[^0-9]*\([0-9][0-9]*\).*$/\1/' $srcdir/jpeglib.h` -echo "$ac_t""$JPEG_LIB_VERSION" 1>&6 - - -# Prepare to massage makefile.cfg correctly. -if test $ijg_cv_have_prototypes = yes; then - A2K_DEPS="" - COM_A2K="# " -else - A2K_DEPS="ansi2knr" - COM_A2K="" -fi - - -# ansi2knr needs -DBSD if string.h is missing -if test $ac_cv_header_string_h = no; then - ANSI2KNRFLAGS="-DBSD" -else - ANSI2KNRFLAGS="" -fi - -# Substitutions to enable or disable libtool-related stuff -if test $USELIBTOOL = yes -a $ijg_cv_have_prototypes = yes; then - COM_LT="" -else - COM_LT="# " -fi - -if test "x$LTSHARED" != xno; then - FORCE_INSTALL_LIB="install-lib" -else - FORCE_INSTALL_LIB="" -fi - -# Set up -I directives -if test "x$srcdir" = x.; then - INCLUDEFLAGS='-I$(srcdir)' -else - INCLUDEFLAGS='-I. -I$(srcdir)' -fi - -trap '' 1 2 15 - -trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 - -test "x$prefix" = xNONE && prefix=$ac_default_prefix -# Let make expand exec_prefix. -test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - -# Any assignment to VPATH causes Sun make to only execute -# the first set of double-colon rules, so remove it if not needed. -# If there is a colon in the path, we need to keep it. -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' -fi - -trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 - -DEFS=-DHAVE_CONFIG_H - -# Without the "./", some shells look in PATH for config.status. -: ${CONFIG_STATUS=./config.status} - -echo creating $CONFIG_STATUS -rm -f $CONFIG_STATUS -cat > $CONFIG_STATUS <<EOF -#! /bin/sh -# Generated automatically by configure. -# Run this file to recreate the current configuration. -# This directory was configured as follows, -# on host `(hostname || uname -n) 2>/dev/null | sed 1q`: -# -# $0 $ac_configure_args -# -# Compiler output produced by configure, useful for debugging -# configure, is in ./config.log if it exists. - -ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" -for ac_option -do - case "\$ac_option" in - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" - exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; - -version | --version | --versio | --versi | --vers | --ver | --ve | --v) - echo "$CONFIG_STATUS generated by autoconf version 2.12" - exit 0 ;; - -help | --help | --hel | --he | --h) - echo "\$ac_cs_usage"; exit 0 ;; - *) echo "\$ac_cs_usage"; exit 1 ;; - esac -done - -ac_given_srcdir=$srcdir -ac_given_INSTALL="$INSTALL" - -trap 'rm -fr `echo "Makefile:makefile.cfg jconfig.h:jconfig.cfg" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 -EOF -cat >> $CONFIG_STATUS <<EOF - -# Protect against being on the right side of a sed subst in config.status. -sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g; - s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF -$ac_vpsub -$extrasub -s%@CFLAGS@%$CFLAGS%g -s%@CPPFLAGS@%$CPPFLAGS%g -s%@CXXFLAGS@%$CXXFLAGS%g -s%@DEFS@%$DEFS%g -s%@LDFLAGS@%$LDFLAGS%g -s%@LIBS@%$LIBS%g -s%@exec_prefix@%$exec_prefix%g -s%@prefix@%$prefix%g -s%@program_transform_name@%$program_transform_name%g -s%@bindir@%$bindir%g -s%@sbindir@%$sbindir%g -s%@libexecdir@%$libexecdir%g -s%@datadir@%$datadir%g -s%@sysconfdir@%$sysconfdir%g -s%@sharedstatedir@%$sharedstatedir%g -s%@localstatedir@%$localstatedir%g -s%@libdir@%$libdir%g -s%@includedir@%$includedir%g -s%@oldincludedir@%$oldincludedir%g -s%@infodir@%$infodir%g -s%@mandir@%$mandir%g -s%@CC@%$CC%g -s%@CPP@%$CPP%g -s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g -s%@INSTALL_DATA@%$INSTALL_DATA%g -s%@RANLIB@%$RANLIB%g -s%@LIBTOOL@%$LIBTOOL%g -s%@O@%$O%g -s%@A@%$A%g -s%@LN@%$LN%g -s%@INSTALL_LIB@%$INSTALL_LIB%g -s%@MEMORYMGR@%$MEMORYMGR%g -s%@JPEG_LIB_VERSION@%$JPEG_LIB_VERSION%g -s%@A2K_DEPS@%$A2K_DEPS%g -s%@COM_A2K@%$COM_A2K%g -s%@ANSI2KNRFLAGS@%$ANSI2KNRFLAGS%g -s%@COM_LT@%$COM_LT%g -s%@FORCE_INSTALL_LIB@%$FORCE_INSTALL_LIB%g -s%@INCLUDEFLAGS@%$INCLUDEFLAGS%g - -CEOF -EOF - -cat >> $CONFIG_STATUS <<\EOF - -# Split the substitutions into bite-sized pieces for seds with -# small command number limits, like on Digital OSF/1 and HP-UX. -ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. -ac_file=1 # Number of current file. -ac_beg=1 # First line for current file. -ac_end=$ac_max_sed_cmds # Line after last line for current file. -ac_more_lines=: -ac_sed_cmds="" -while $ac_more_lines; do - if test $ac_beg -gt 1; then - sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file - else - sed "${ac_end}q" conftest.subs > conftest.s$ac_file - fi - if test ! -s conftest.s$ac_file; then - ac_more_lines=false - rm -f conftest.s$ac_file - else - if test -z "$ac_sed_cmds"; then - ac_sed_cmds="sed -f conftest.s$ac_file" - else - ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" - fi - ac_file=`expr $ac_file + 1` - ac_beg=$ac_end - ac_end=`expr $ac_end + $ac_max_sed_cmds` - fi -done -if test -z "$ac_sed_cmds"; then - ac_sed_cmds=cat -fi -EOF - -cat >> $CONFIG_STATUS <<EOF - -CONFIG_FILES=\${CONFIG_FILES-"Makefile:makefile.cfg"} -EOF -cat >> $CONFIG_STATUS <<\EOF -for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then - # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case "$ac_file" in - *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` - ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; - *) ac_file_in="${ac_file}.in" ;; - esac - - # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. - - # Remove last slash and all that follows it. Not all systems have dirname. - ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` - if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then - # The file is in a subdirectory. - test ! -d "$ac_dir" && mkdir "$ac_dir" - ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" - # A "../" for each directory in $ac_dir_suffix. - ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` - else - ac_dir_suffix= ac_dots= - fi - - case "$ac_given_srcdir" in - .) srcdir=. - if test -z "$ac_dots"; then top_srcdir=. - else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; - /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; - *) # Relative path. - srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" - top_srcdir="$ac_dots$ac_given_srcdir" ;; - esac - - case "$ac_given_INSTALL" in - [/$]*) INSTALL="$ac_given_INSTALL" ;; - *) INSTALL="$ac_dots$ac_given_INSTALL" ;; - esac - - echo creating "$ac_file" - rm -f "$ac_file" - configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." - case "$ac_file" in - *Makefile*) ac_comsub="1i\\ -# $configure_input" ;; - *) ac_comsub= ;; - esac - - ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` - sed -e "$ac_comsub -s%@configure_input@%$configure_input%g -s%@srcdir@%$srcdir%g -s%@top_srcdir@%$top_srcdir%g -s%@INSTALL@%$INSTALL%g -" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file -fi; done -rm -f conftest.s* - -# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where -# NAME is the cpp macro being defined and VALUE is the value it is being given. -# -# ac_d sets the value in "#define NAME VALUE" lines. -ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' -ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' -ac_dC='\3' -ac_dD='%g' -# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". -ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' -ac_uB='\([ ]\)%\1#\2define\3' -ac_uC=' ' -ac_uD='\4%g' -# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". -ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' -ac_eB='$%\1#\2define\3' -ac_eC=' ' -ac_eD='%g' - -if test "${CONFIG_HEADERS+set}" != set; then -EOF -cat >> $CONFIG_STATUS <<EOF - CONFIG_HEADERS="jconfig.h:jconfig.cfg" -EOF -cat >> $CONFIG_STATUS <<\EOF -fi -for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then - # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case "$ac_file" in - *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` - ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; - *) ac_file_in="${ac_file}.in" ;; - esac - - echo creating $ac_file - - rm -f conftest.frag conftest.in conftest.out - ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` - cat $ac_file_inputs > conftest.in - -EOF - -# Transform confdefs.h into a sed script conftest.vals that substitutes -# the proper values into config.h.in to produce config.h. And first: -# Protect against being on the right side of a sed subst in config.status. -# Protect against being in an unquoted here document in config.status. -rm -f conftest.vals -cat > conftest.hdr <<\EOF -s/[\\&%]/\\&/g -s%[\\$`]%\\&%g -s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp -s%ac_d%ac_u%gp -s%ac_u%ac_e%gp -EOF -sed -n -f conftest.hdr confdefs.h > conftest.vals -rm -f conftest.hdr - -# This sed command replaces #undef with comments. This is necessary, for -# example, in the case of _POSIX_SOURCE, which is predefined and required -# on some systems where configure will not decide to define it. -cat >> conftest.vals <<\EOF -EOF - -# Break up conftest.vals because some shells have a limit on -# the size of here documents, and old seds have small limits too. - -rm -f conftest.tail -while : -do - ac_lines=`grep -c . conftest.vals` - # grep -c gives empty output for an empty file on some AIX systems. - if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi - # Write a limited-size here document to conftest.frag. - echo ' cat > conftest.frag <<CEOF' >> $CONFIG_STATUS - sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS - echo 'CEOF - sed -f conftest.frag conftest.in > conftest.out - rm -f conftest.in - mv conftest.out conftest.in -' >> $CONFIG_STATUS - sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail - rm -f conftest.vals - mv conftest.tail conftest.vals -done -rm -f conftest.vals - -cat >> $CONFIG_STATUS <<\EOF - rm -f conftest.frag conftest.h - echo "/* $ac_file. Generated automatically by configure. */" > conftest.h - cat conftest.in >> conftest.h - rm -f conftest.in - if cmp -s $ac_file conftest.h 2>/dev/null; then - echo "$ac_file is unchanged" - rm -f conftest.h - else - # Remove last slash and all that follows it. Not all systems have dirname. - ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` - if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then - # The file is in a subdirectory. - test ! -d "$ac_dir" && mkdir "$ac_dir" - fi - rm -f $ac_file - mv conftest.h $ac_file - fi -fi; done - -EOF -cat >> $CONFIG_STATUS <<EOF - -EOF -cat >> $CONFIG_STATUS <<\EOF - -exit 0 -EOF -chmod +x $CONFIG_STATUS -rm -fr confdefs* $ac_clean_files -test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 - diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/djpeg.1 b/irrlicht-1.6/source/Irrlicht/jpeglib/djpeg.1 deleted file mode 100644 index a1a335a10..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/djpeg.1 +++ /dev/null @@ -1,253 +0,0 @@ -.TH DJPEG 1 "22 August 1997" -.SH NAME -djpeg \- decompress a JPEG file to an image file -.SH SYNOPSIS -.B djpeg -[ -.I options -] -[ -.I filename -] -.LP -.SH DESCRIPTION -.LP -.B djpeg -decompresses the named JPEG file, or the standard input if no file is named, -and produces an image file on the standard output. PBMPLUS (PPM/PGM), BMP, -GIF, Targa, or RLE (Utah Raster Toolkit) output format can be selected. -(RLE is supported only if the URT library is available.) -.SH OPTIONS -All switch names may be abbreviated; for example, -.B \-grayscale -may be written -.B \-gray -or -.BR \-gr . -Most of the "basic" switches can be abbreviated to as little as one letter. -Upper and lower case are equivalent (thus -.B \-BMP -is the same as -.BR \-bmp ). -British spellings are also accepted (e.g., -.BR \-greyscale ), -though for brevity these are not mentioned below. -.PP -The basic switches are: -.TP -.BI \-colors " N" -Reduce image to at most N colors. This reduces the number of colors used in -the output image, so that it can be displayed on a colormapped display or -stored in a colormapped file format. For example, if you have an 8-bit -display, you'd need to reduce to 256 or fewer colors. -.TP -.BI \-quantize " N" -Same as -.BR \-colors . -.B \-colors -is the recommended name, -.B \-quantize -is provided only for backwards compatibility. -.TP -.B \-fast -Select recommended processing options for fast, low quality output. (The -default options are chosen for highest quality output.) Currently, this is -equivalent to \fB\-dct fast \-nosmooth \-onepass \-dither ordered\fR. -.TP -.B \-grayscale -Force gray-scale output even if JPEG file is color. Useful for viewing on -monochrome displays; also, -.B djpeg -runs noticeably faster in this mode. -.TP -.BI \-scale " M/N" -Scale the output image by a factor M/N. Currently the scale factor must be -1/1, 1/2, 1/4, or 1/8. Scaling is handy if the image is larger than your -screen; also, -.B djpeg -runs much faster when scaling down the output. -.TP -.B \-bmp -Select BMP output format (Windows flavor). 8-bit colormapped format is -emitted if -.B \-colors -or -.B \-grayscale -is specified, or if the JPEG file is gray-scale; otherwise, 24-bit full-color -format is emitted. -.TP -.B \-gif -Select GIF output format. Since GIF does not support more than 256 colors, -.B \-colors 256 -is assumed (unless you specify a smaller number of colors). -.TP -.B \-os2 -Select BMP output format (OS/2 1.x flavor). 8-bit colormapped format is -emitted if -.B \-colors -or -.B \-grayscale -is specified, or if the JPEG file is gray-scale; otherwise, 24-bit full-color -format is emitted. -.TP -.B \-pnm -Select PBMPLUS (PPM/PGM) output format (this is the default format). -PGM is emitted if the JPEG file is gray-scale or if -.B \-grayscale -is specified; otherwise PPM is emitted. -.TP -.B \-rle -Select RLE output format. (Requires URT library.) -.TP -.B \-targa -Select Targa output format. Gray-scale format is emitted if the JPEG file is -gray-scale or if -.B \-grayscale -is specified; otherwise, colormapped format is emitted if -.B \-colors -is specified; otherwise, 24-bit full-color format is emitted. -.PP -Switches for advanced users: -.TP -.B \-dct int -Use integer DCT method (default). -.TP -.B \-dct fast -Use fast integer DCT (less accurate). -.TP -.B \-dct float -Use floating-point DCT method. -The float method is very slightly more accurate than the int method, but is -much slower unless your machine has very fast floating-point hardware. Also -note that results of the floating-point method may vary slightly across -machines, while the integer methods should give the same results everywhere. -The fast integer method is much less accurate than the other two. -.TP -.B \-dither fs -Use Floyd-Steinberg dithering in color quantization. -.TP -.B \-dither ordered -Use ordered dithering in color quantization. -.TP -.B \-dither none -Do not use dithering in color quantization. -By default, Floyd-Steinberg dithering is applied when quantizing colors; this -is slow but usually produces the best results. Ordered dither is a compromise -between speed and quality; no dithering is fast but usually looks awful. Note -that these switches have no effect unless color quantization is being done. -Ordered dither is only available in -.B \-onepass -mode. -.TP -.BI \-map " file" -Quantize to the colors used in the specified image file. This is useful for -producing multiple files with identical color maps, or for forcing a -predefined set of colors to be used. The -.I file -must be a GIF or PPM file. This option overrides -.B \-colors -and -.BR \-onepass . -.TP -.B \-nosmooth -Use a faster, lower-quality upsampling routine. -.TP -.B \-onepass -Use one-pass instead of two-pass color quantization. The one-pass method is -faster and needs less memory, but it produces a lower-quality image. -.B \-onepass -is ignored unless you also say -.B \-colors -.IR N . -Also, the one-pass method is always used for gray-scale output (the two-pass -method is no improvement then). -.TP -.BI \-maxmemory " N" -Set limit for amount of memory to use in processing large images. Value is -in thousands of bytes, or millions of bytes if "M" is attached to the -number. For example, -.B \-max 4m -selects 4000000 bytes. If more space is needed, temporary files will be used. -.TP -.BI \-outfile " name" -Send output image to the named file, not to standard output. -.TP -.B \-verbose -Enable debug printout. More -.BR \-v 's -give more output. Also, version information is printed at startup. -.TP -.B \-debug -Same as -.BR \-verbose . -.SH EXAMPLES -.LP -This example decompresses the JPEG file foo.jpg, quantizes it to -256 colors, and saves the output in 8-bit BMP format in foo.bmp: -.IP -.B djpeg \-colors 256 \-bmp -.I foo.jpg -.B > -.I foo.bmp -.SH HINTS -To get a quick preview of an image, use the -.B \-grayscale -and/or -.B \-scale -switches. -.B \-grayscale \-scale 1/8 -is the fastest case. -.PP -Several options are available that trade off image quality to gain speed. -.B \-fast -turns on the recommended settings. -.PP -.B \-dct fast -and/or -.B \-nosmooth -gain speed at a small sacrifice in quality. -When producing a color-quantized image, -.B \-onepass \-dither ordered -is fast but much lower quality than the default behavior. -.B \-dither none -may give acceptable results in two-pass mode, but is seldom tolerable in -one-pass mode. -.PP -If you are fortunate enough to have very fast floating point hardware, -\fB\-dct float\fR may be even faster than \fB\-dct fast\fR. But on most -machines \fB\-dct float\fR is slower than \fB\-dct int\fR; in this case it is -not worth using, because its theoretical accuracy advantage is too small to be -significant in practice. -.SH ENVIRONMENT -.TP -.B JPEGMEM -If this environment variable is set, its value is the default memory limit. -The value is specified as described for the -.B \-maxmemory -switch. -.B JPEGMEM -overrides the default value specified when the program was compiled, and -itself is overridden by an explicit -.BR \-maxmemory . -.SH SEE ALSO -.BR cjpeg (1), -.BR jpegtran (1), -.BR rdjpgcom (1), -.BR wrjpgcom (1) -.br -.BR ppm (5), -.BR pgm (5) -.br -Wallace, Gregory K. "The JPEG Still Picture Compression Standard", -Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44. -.SH AUTHOR -Independent JPEG Group -.SH BUGS -Arithmetic coding is not supported for legal reasons. -.PP -To avoid the Unisys LZW patent, -.B djpeg -produces uncompressed GIF files. These are larger than they should be, but -are readable by standard GIF decoders. -.PP -Still not as fast as we'd like. diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/djpeg.c b/irrlicht-1.6/source/Irrlicht/jpeglib/djpeg.c deleted file mode 100644 index a63523c5a..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/djpeg.c +++ /dev/null @@ -1,616 +0,0 @@ -/* - * djpeg.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a command-line user interface for the JPEG decompressor. - * It should work on any system with Unix- or MS-DOS-style command lines. - * - * Two different command line styles are permitted, depending on the - * compile-time switch TWO_FILE_COMMANDLINE: - * djpeg [options] inputfile outputfile - * djpeg [options] [inputfile] - * In the second style, output is always to standard output, which you'd - * normally redirect to a file or pipe to some other program. Input is - * either from a named file or from standard input (typically redirected). - * The second style is convenient on Unix but is unhelpful on systems that - * don't support pipes. Also, you MUST use the first style if your system - * doesn't do binary I/O to stdin/stdout. - * To simplify script writing, the "-outfile" switch is provided. The syntax - * djpeg [options] -outfile outputfile inputfile - * works regardless of which command line style is used. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ -#include "jversion.h" /* for version message */ - -#include <ctype.h> /* to declare isprint() */ - -#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ -#ifdef __MWERKS__ -#include <SIOUX.h> /* Metrowerks needs this */ -#include <console.h> /* ... and this */ -#endif -#ifdef THINK_C -#include <console.h> /* Think declares it here */ -#endif -#endif - - -/* Create the add-on message string table. */ - -#define JMESSAGE(code,string) string , - -static const char * const cdjpeg_message_table[] = { -#include "cderror.h" - NULL -}; - - -/* - * This list defines the known output image formats - * (not all of which need be supported by a given version). - * You can change the default output format by defining DEFAULT_FMT; - * indeed, you had better do so if you undefine PPM_SUPPORTED. - */ - -typedef enum { - FMT_BMP, /* BMP format (Windows flavor) */ - FMT_GIF, /* GIF format */ - FMT_OS2, /* BMP format (OS/2 flavor) */ - FMT_PPM, /* PPM/PGM (PBMPLUS formats) */ - FMT_RLE, /* RLE format */ - FMT_TARGA, /* Targa format */ - FMT_TIFF /* TIFF format */ -} IMAGE_FORMATS; - -#ifndef DEFAULT_FMT /* so can override from CFLAGS in Makefile */ -#define DEFAULT_FMT FMT_PPM -#endif - -static IMAGE_FORMATS requested_fmt; - - -/* - * Argument-parsing code. - * The switch parser is designed to be useful with DOS-style command line - * syntax, ie, intermixed switches and file names, where only the switches - * to the left of a given file name affect processing of that file. - * The main program in this file doesn't actually use this capability... - */ - - -static const char * progname; /* program name for error messages */ -static char * outfilename; /* for -outfile switch */ - - -LOCAL(void) -usage (void) -/* complain about bad command line */ -{ - fprintf(stderr, "usage: %s [switches] ", progname); -#ifdef TWO_FILE_COMMANDLINE - fprintf(stderr, "inputfile outputfile\n"); -#else - fprintf(stderr, "[inputfile]\n"); -#endif - - fprintf(stderr, "Switches (names may be abbreviated):\n"); - fprintf(stderr, " -colors N Reduce image to no more than N colors\n"); - fprintf(stderr, " -fast Fast, low-quality processing\n"); - fprintf(stderr, " -grayscale Force grayscale output\n"); -#ifdef IDCT_SCALING_SUPPORTED - fprintf(stderr, " -scale M/N Scale output image by fraction M/N, eg, 1/8\n"); -#endif -#ifdef BMP_SUPPORTED - fprintf(stderr, " -bmp Select BMP output format (Windows style)%s\n", - (DEFAULT_FMT == FMT_BMP ? " (default)" : "")); -#endif -#ifdef GIF_SUPPORTED - fprintf(stderr, " -gif Select GIF output format%s\n", - (DEFAULT_FMT == FMT_GIF ? " (default)" : "")); -#endif -#ifdef BMP_SUPPORTED - fprintf(stderr, " -os2 Select BMP output format (OS/2 style)%s\n", - (DEFAULT_FMT == FMT_OS2 ? " (default)" : "")); -#endif -#ifdef PPM_SUPPORTED - fprintf(stderr, " -pnm Select PBMPLUS (PPM/PGM) output format%s\n", - (DEFAULT_FMT == FMT_PPM ? " (default)" : "")); -#endif -#ifdef RLE_SUPPORTED - fprintf(stderr, " -rle Select Utah RLE output format%s\n", - (DEFAULT_FMT == FMT_RLE ? " (default)" : "")); -#endif -#ifdef TARGA_SUPPORTED - fprintf(stderr, " -targa Select Targa output format%s\n", - (DEFAULT_FMT == FMT_TARGA ? " (default)" : "")); -#endif - fprintf(stderr, "Switches for advanced users:\n"); -#ifdef DCT_ISLOW_SUPPORTED - fprintf(stderr, " -dct int Use integer DCT method%s\n", - (JDCT_DEFAULT == JDCT_ISLOW ? " (default)" : "")); -#endif -#ifdef DCT_IFAST_SUPPORTED - fprintf(stderr, " -dct fast Use fast integer DCT (less accurate)%s\n", - (JDCT_DEFAULT == JDCT_IFAST ? " (default)" : "")); -#endif -#ifdef DCT_FLOAT_SUPPORTED - fprintf(stderr, " -dct float Use floating-point DCT method%s\n", - (JDCT_DEFAULT == JDCT_FLOAT ? " (default)" : "")); -#endif - fprintf(stderr, " -dither fs Use F-S dithering (default)\n"); - fprintf(stderr, " -dither none Don't use dithering in quantization\n"); - fprintf(stderr, " -dither ordered Use ordered dither (medium speed, quality)\n"); -#ifdef QUANT_2PASS_SUPPORTED - fprintf(stderr, " -map FILE Map to colors used in named image file\n"); -#endif - fprintf(stderr, " -nosmooth Don't use high-quality upsampling\n"); -#ifdef QUANT_1PASS_SUPPORTED - fprintf(stderr, " -onepass Use 1-pass quantization (fast, low quality)\n"); -#endif - fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n"); - fprintf(stderr, " -outfile name Specify name for output file\n"); - fprintf(stderr, " -verbose or -debug Emit debug output\n"); - exit(EXIT_FAILURE); -} - - -LOCAL(int) -parse_switches (j_decompress_ptr cinfo, int argc, char **argv, - int last_file_arg_seen, boolean for_real) -/* Parse optional switches. - * Returns argv[] index of first file-name argument (== argc if none). - * Any file names with indexes <= last_file_arg_seen are ignored; - * they have presumably been processed in a previous iteration. - * (Pass 0 for last_file_arg_seen on the first or only iteration.) - * for_real is FALSE on the first (dummy) pass; we may skip any expensive - * processing. - */ -{ - int argn; - char * arg; - - /* Set up default JPEG parameters. */ - requested_fmt = DEFAULT_FMT; /* set default output file format */ - outfilename = NULL; - cinfo->err->trace_level = 0; - - /* Scan command line options, adjust parameters */ - - for (argn = 1; argn < argc; argn++) { - arg = argv[argn]; - if (*arg != '-') { - /* Not a switch, must be a file name argument */ - if (argn <= last_file_arg_seen) { - outfilename = NULL; /* -outfile applies to just one input file */ - continue; /* ignore this name if previously processed */ - } - break; /* else done parsing switches */ - } - arg++; /* advance past switch marker character */ - - if (keymatch(arg, "bmp", 1)) { - /* BMP output format. */ - requested_fmt = FMT_BMP; - - } else if (keymatch(arg, "colors", 1) || keymatch(arg, "colours", 1) || - keymatch(arg, "quantize", 1) || keymatch(arg, "quantise", 1)) { - /* Do color quantization. */ - int val; - - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%d", &val) != 1) - usage(); - cinfo->desired_number_of_colors = val; - cinfo->quantize_colors = TRUE; - - } else if (keymatch(arg, "dct", 2)) { - /* Select IDCT algorithm. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (keymatch(argv[argn], "int", 1)) { - cinfo->dct_method = JDCT_ISLOW; - } else if (keymatch(argv[argn], "fast", 2)) { - cinfo->dct_method = JDCT_IFAST; - } else if (keymatch(argv[argn], "float", 2)) { - cinfo->dct_method = JDCT_FLOAT; - } else - usage(); - - } else if (keymatch(arg, "dither", 2)) { - /* Select dithering algorithm. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (keymatch(argv[argn], "fs", 2)) { - cinfo->dither_mode = JDITHER_FS; - } else if (keymatch(argv[argn], "none", 2)) { - cinfo->dither_mode = JDITHER_NONE; - } else if (keymatch(argv[argn], "ordered", 2)) { - cinfo->dither_mode = JDITHER_ORDERED; - } else - usage(); - - } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) { - /* Enable debug printouts. */ - /* On first -d, print version identification */ - static boolean printed_version = FALSE; - - if (! printed_version) { - fprintf(stderr, "Independent JPEG Group's DJPEG, version %s\n%s\n", - JVERSION, JCOPYRIGHT); - printed_version = TRUE; - } - cinfo->err->trace_level++; - - } else if (keymatch(arg, "fast", 1)) { - /* Select recommended processing options for quick-and-dirty output. */ - cinfo->two_pass_quantize = FALSE; - cinfo->dither_mode = JDITHER_ORDERED; - if (! cinfo->quantize_colors) /* don't override an earlier -colors */ - cinfo->desired_number_of_colors = 216; - cinfo->dct_method = JDCT_FASTEST; - cinfo->do_fancy_upsampling = FALSE; - - } else if (keymatch(arg, "gif", 1)) { - /* GIF output format. */ - requested_fmt = FMT_GIF; - - } else if (keymatch(arg, "grayscale", 2) || keymatch(arg, "greyscale",2)) { - /* Force monochrome output. */ - cinfo->out_color_space = JCS_GRAYSCALE; - - } else if (keymatch(arg, "map", 3)) { - /* Quantize to a color map taken from an input file. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (for_real) { /* too expensive to do twice! */ -#ifdef QUANT_2PASS_SUPPORTED /* otherwise can't quantize to supplied map */ - FILE * mapfile; - - if ((mapfile = fopen(argv[argn], READ_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]); - exit(EXIT_FAILURE); - } - read_color_map(cinfo, mapfile); - fclose(mapfile); - cinfo->quantize_colors = TRUE; -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } - - } else if (keymatch(arg, "maxmemory", 3)) { - /* Maximum memory in Kb (or Mb with 'm'). */ - long lval; - char ch = 'x'; - - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) - usage(); - if (ch == 'm' || ch == 'M') - lval *= 1000L; - cinfo->mem->max_memory_to_use = lval * 1000L; - - } else if (keymatch(arg, "nosmooth", 3)) { - /* Suppress fancy upsampling */ - cinfo->do_fancy_upsampling = FALSE; - - } else if (keymatch(arg, "onepass", 3)) { - /* Use fast one-pass quantization. */ - cinfo->two_pass_quantize = FALSE; - - } else if (keymatch(arg, "os2", 3)) { - /* BMP output format (OS/2 flavor). */ - requested_fmt = FMT_OS2; - - } else if (keymatch(arg, "outfile", 4)) { - /* Set output file name. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - outfilename = argv[argn]; /* save it away for later use */ - - } else if (keymatch(arg, "pnm", 1) || keymatch(arg, "ppm", 1)) { - /* PPM/PGM output format. */ - requested_fmt = FMT_PPM; - - } else if (keymatch(arg, "rle", 1)) { - /* RLE output format. */ - requested_fmt = FMT_RLE; - - } else if (keymatch(arg, "scale", 1)) { - /* Scale the output image by a fraction M/N. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%d/%d", - &cinfo->scale_num, &cinfo->scale_denom) != 2) - usage(); - - } else if (keymatch(arg, "targa", 1)) { - /* Targa output format. */ - requested_fmt = FMT_TARGA; - - } else { - usage(); /* bogus switch */ - } - } - - return argn; /* return index of next arg (file name) */ -} - - -/* - * Marker processor for COM and interesting APPn markers. - * This replaces the library's built-in processor, which just skips the marker. - * We want to print out the marker as text, to the extent possible. - * Note this code relies on a non-suspending data source. - */ - -LOCAL(unsigned int) -jpeg_getc (j_decompress_ptr cinfo) -/* Read next byte */ -{ - struct jpeg_source_mgr * datasrc = cinfo->src; - - if (datasrc->bytes_in_buffer == 0) { - if (! (*datasrc->fill_input_buffer) (cinfo)) - ERREXIT(cinfo, JERR_CANT_SUSPEND); - } - datasrc->bytes_in_buffer--; - return GETJOCTET(*datasrc->next_input_byte++); -} - - -METHODDEF(boolean) -print_text_marker (j_decompress_ptr cinfo) -{ - boolean traceit = (cinfo->err->trace_level >= 1); - INT32 length; - unsigned int ch; - unsigned int lastch = 0; - - length = jpeg_getc(cinfo) << 8; - length += jpeg_getc(cinfo); - length -= 2; /* discount the length word itself */ - - if (traceit) { - if (cinfo->unread_marker == JPEG_COM) - fprintf(stderr, "Comment, length %ld:\n", (long) length); - else /* assume it is an APPn otherwise */ - fprintf(stderr, "APP%d, length %ld:\n", - cinfo->unread_marker - JPEG_APP0, (long) length); - } - - while (--length >= 0) { - ch = jpeg_getc(cinfo); - if (traceit) { - /* Emit the character in a readable form. - * Nonprintables are converted to \nnn form, - * while \ is converted to \\. - * Newlines in CR, CR/LF, or LF form will be printed as one newline. - */ - if (ch == '\r') { - fprintf(stderr, "\n"); - } else if (ch == '\n') { - if (lastch != '\r') - fprintf(stderr, "\n"); - } else if (ch == '\\') { - fprintf(stderr, "\\\\"); - } else if (isprint(ch)) { - putc(ch, stderr); - } else { - fprintf(stderr, "\\%03o", ch); - } - lastch = ch; - } - } - - if (traceit) - fprintf(stderr, "\n"); - - return TRUE; -} - - -/* - * The main program. - */ - -int -main (int argc, char **argv) -{ - struct jpeg_decompress_struct cinfo; - struct jpeg_error_mgr jerr; -#ifdef PROGRESS_REPORT - struct cdjpeg_progress_mgr progress; -#endif - int file_index; - djpeg_dest_ptr dest_mgr = NULL; - FILE * input_file; - FILE * output_file; - JDIMENSION num_scanlines; - - /* On Mac, fetch a command line. */ -#ifdef USE_CCOMMAND - argc = ccommand(&argv); -#endif - - progname = argv[0]; - if (progname == NULL || progname[0] == 0) - progname = "djpeg"; /* in case C library doesn't provide it */ - - /* Initialize the JPEG decompression object with default error handling. */ - cinfo.err = jpeg_std_error(&jerr); - jpeg_create_decompress(&cinfo); - /* Add some application-specific error messages (from cderror.h) */ - jerr.addon_message_table = cdjpeg_message_table; - jerr.first_addon_message = JMSG_FIRSTADDONCODE; - jerr.last_addon_message = JMSG_LASTADDONCODE; - - /* Insert custom marker processor for COM and APP12. - * APP12 is used by some digital camera makers for textual info, - * so we provide the ability to display it as text. - * If you like, additional APPn marker types can be selected for display, - * but don't try to override APP0 or APP14 this way (see libjpeg.doc). - */ - jpeg_set_marker_processor(&cinfo, JPEG_COM, print_text_marker); - jpeg_set_marker_processor(&cinfo, JPEG_APP0+12, print_text_marker); - - /* Now safe to enable signal catcher. */ -#ifdef NEED_SIGNAL_CATCHER - enable_signal_catcher((j_common_ptr) &cinfo); -#endif - - /* Scan command line to find file names. */ - /* It is convenient to use just one switch-parsing routine, but the switch - * values read here are ignored; we will rescan the switches after opening - * the input file. - * (Exception: tracing level set here controls verbosity for COM markers - * found during jpeg_read_header...) - */ - - file_index = parse_switches(&cinfo, argc, argv, 0, FALSE); - -#ifdef TWO_FILE_COMMANDLINE - /* Must have either -outfile switch or explicit output file name */ - if (outfilename == NULL) { - if (file_index != argc-2) { - fprintf(stderr, "%s: must name one input and one output file\n", - progname); - usage(); - } - outfilename = argv[file_index+1]; - } else { - if (file_index != argc-1) { - fprintf(stderr, "%s: must name one input and one output file\n", - progname); - usage(); - } - } -#else - /* Unix style: expect zero or one file name */ - if (file_index < argc-1) { - fprintf(stderr, "%s: only one input file\n", progname); - usage(); - } -#endif /* TWO_FILE_COMMANDLINE */ - - /* Open the input file. */ - if (file_index < argc) { - if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, argv[file_index]); - exit(EXIT_FAILURE); - } - } else { - /* default input file is stdin */ - input_file = read_stdin(); - } - - /* Open the output file. */ - if (outfilename != NULL) { - if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, outfilename); - exit(EXIT_FAILURE); - } - } else { - /* default output file is stdout */ - output_file = write_stdout(); - } - -#ifdef PROGRESS_REPORT - start_progress_monitor((j_common_ptr) &cinfo, &progress); -#endif - - /* Specify data source for decompression */ - jpeg_stdio_src(&cinfo, input_file); - - /* Read file header, set default decompression parameters */ - (void) jpeg_read_header(&cinfo, TRUE); - - /* Adjust default decompression parameters by re-parsing the options */ - file_index = parse_switches(&cinfo, argc, argv, 0, TRUE); - - /* Initialize the output module now to let it override any crucial - * option settings (for instance, GIF wants to force color quantization). - */ - switch (requested_fmt) { -#ifdef BMP_SUPPORTED - case FMT_BMP: - dest_mgr = jinit_write_bmp(&cinfo, FALSE); - break; - case FMT_OS2: - dest_mgr = jinit_write_bmp(&cinfo, TRUE); - break; -#endif -#ifdef GIF_SUPPORTED - case FMT_GIF: - dest_mgr = jinit_write_gif(&cinfo); - break; -#endif -#ifdef PPM_SUPPORTED - case FMT_PPM: - dest_mgr = jinit_write_ppm(&cinfo); - break; -#endif -#ifdef RLE_SUPPORTED - case FMT_RLE: - dest_mgr = jinit_write_rle(&cinfo); - break; -#endif -#ifdef TARGA_SUPPORTED - case FMT_TARGA: - dest_mgr = jinit_write_targa(&cinfo); - break; -#endif - default: - ERREXIT(&cinfo, JERR_UNSUPPORTED_FORMAT); - break; - } - dest_mgr->output_file = output_file; - - /* Start decompressor */ - (void) jpeg_start_decompress(&cinfo); - - /* Write output file header */ - (*dest_mgr->start_output) (&cinfo, dest_mgr); - - /* Process data */ - while (cinfo.output_scanline < cinfo.output_height) { - num_scanlines = jpeg_read_scanlines(&cinfo, dest_mgr->buffer, - dest_mgr->buffer_height); - (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines); - } - -#ifdef PROGRESS_REPORT - /* Hack: count final pass as done in case finish_output does an extra pass. - * The library won't have updated completed_passes. - */ - progress.pub.completed_passes = progress.pub.total_passes; -#endif - - /* Finish decompression and release memory. - * I must do it in this order because output module has allocated memory - * of lifespan JPOOL_IMAGE; it needs to finish before releasing memory. - */ - (*dest_mgr->finish_output) (&cinfo, dest_mgr); - (void) jpeg_finish_decompress(&cinfo); - jpeg_destroy_decompress(&cinfo); - - /* Close files, if we opened them */ - if (input_file != stdin) - fclose(input_file); - if (output_file != stdout) - fclose(output_file); - -#ifdef PROGRESS_REPORT - end_progress_monitor((j_common_ptr) &cinfo); -#endif - - /* All done. */ - exit(jerr.num_warnings ? EXIT_WARNING : EXIT_SUCCESS); - return 0; /* suppress no-return-value warnings */ -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/example.c b/irrlicht-1.6/source/Irrlicht/jpeglib/example.c deleted file mode 100644 index 9dcbd7d9a..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/example.c +++ /dev/null @@ -1,433 +0,0 @@ -/* - * example.c - * - * This file illustrates how to use the IJG code as a subroutine library - * to read or write JPEG image files. You should look at this code in - * conjunction with the documentation file libjpeg.doc. - * - * This code will not do anything useful as-is, but it may be helpful as a - * skeleton for constructing routines that call the JPEG library. - * - * We present these routines in the same coding style used in the JPEG code - * (ANSI function definitions, etc); but you are of course free to code your - * routines in a different style if you prefer. - */ - -#include <stdio.h> - -/* - * Include file for users of JPEG library. - * You will need to have included system headers that define at least - * the typedefs FILE and size_t before you can include jpeglib.h. - * (stdio.h is sufficient on ANSI-conforming systems.) - * You may also wish to include "jerror.h". - */ - -#include "jpeglib.h" - -/* - * <setjmp.h> is used for the optional error recovery mechanism shown in - * the second part of the example. - */ - -#include <setjmp.h> - - - -/******************** JPEG COMPRESSION SAMPLE INTERFACE *******************/ - -/* This half of the example shows how to feed data into the JPEG compressor. - * We present a minimal version that does not worry about refinements such - * as error recovery (the JPEG code will just exit() if it gets an error). - */ - - -/* - * IMAGE DATA FORMATS: - * - * The standard input image format is a rectangular array of pixels, with - * each pixel having the same number of "component" values (color channels). - * Each pixel row is an array of JSAMPLEs (which typically are unsigned chars). - * If you are working with color data, then the color values for each pixel - * must be adjacent in the row; for example, R,G,B,R,G,B,R,G,B,... for 24-bit - * RGB color. - * - * For this example, we'll assume that this data structure matches the way - * our application has stored the image in memory, so we can just pass a - * pointer to our image buffer. In particular, let's say that the image is - * RGB color and is described by: - */ - -extern JSAMPLE * image_buffer; /* Points to large array of R,G,B-order data */ -extern int image_height; /* Number of rows in image */ -extern int image_width; /* Number of columns in image */ - - -/* - * Sample routine for JPEG compression. We assume that the target file name - * and a compression quality factor are passed in. - */ - -GLOBAL(void) -write_JPEG_file (char * filename, int quality) -{ - /* This struct contains the JPEG compression parameters and pointers to - * working space (which is allocated as needed by the JPEG library). - * It is possible to have several such structures, representing multiple - * compression/decompression processes, in existence at once. We refer - * to any one struct (and its associated working data) as a "JPEG object". - */ - struct jpeg_compress_struct cinfo; - /* This struct represents a JPEG error handler. It is declared separately - * because applications often want to supply a specialized error handler - * (see the second half of this file for an example). But here we just - * take the easy way out and use the standard error handler, which will - * print a message on stderr and call exit() if compression fails. - * Note that this struct must live as long as the main JPEG parameter - * struct, to avoid dangling-pointer problems. - */ - struct jpeg_error_mgr jerr; - /* More stuff */ - FILE * outfile; /* target file */ - JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */ - int row_stride; /* physical row width in image buffer */ - - /* Step 1: allocate and initialize JPEG compression object */ - - /* We have to set up the error handler first, in case the initialization - * step fails. (Unlikely, but it could happen if you are out of memory.) - * This routine fills in the contents of struct jerr, and returns jerr's - * address which we place into the link field in cinfo. - */ - cinfo.err = jpeg_std_error(&jerr); - /* Now we can initialize the JPEG compression object. */ - jpeg_create_compress(&cinfo); - - /* Step 2: specify data destination (eg, a file) */ - /* Note: steps 2 and 3 can be done in either order. */ - - /* Here we use the library-supplied code to send compressed data to a - * stdio stream. You can also write your own code to do something else. - * VERY IMPORTANT: use "b" option to fopen() if you are on a machine that - * requires it in order to write binary files. - */ - if ((outfile = fopen(filename, "wb")) == NULL) { - fprintf(stderr, "can't open %s\n", filename); - exit(1); - } - jpeg_stdio_dest(&cinfo, outfile); - - /* Step 3: set parameters for compression */ - - /* First we supply a description of the input image. - * Four fields of the cinfo struct must be filled in: - */ - cinfo.image_width = image_width; /* image width and height, in pixels */ - cinfo.image_height = image_height; - cinfo.input_components = 3; /* # of color components per pixel */ - cinfo.in_color_space = JCS_RGB; /* colorspace of input image */ - /* Now use the library's routine to set default compression parameters. - * (You must set at least cinfo.in_color_space before calling this, - * since the defaults depend on the source color space.) - */ - jpeg_set_defaults(&cinfo); - /* Now you can set any non-default parameters you wish to. - * Here we just illustrate the use of quality (quantization table) scaling: - */ - jpeg_set_quality(&cinfo, quality, TRUE /* limit to baseline-JPEG values */); - - /* Step 4: Start compressor */ - - /* TRUE ensures that we will write a complete interchange-JPEG file. - * Pass TRUE unless you are very sure of what you're doing. - */ - jpeg_start_compress(&cinfo, TRUE); - - /* Step 5: while (scan lines remain to be written) */ - /* jpeg_write_scanlines(...); */ - - /* Here we use the library's state variable cinfo.next_scanline as the - * loop counter, so that we don't have to keep track ourselves. - * To keep things simple, we pass one scanline per call; you can pass - * more if you wish, though. - */ - row_stride = image_width * 3; /* JSAMPLEs per row in image_buffer */ - - while (cinfo.next_scanline < cinfo.image_height) { - /* jpeg_write_scanlines expects an array of pointers to scanlines. - * Here the array is only one element long, but you could pass - * more than one scanline at a time if that's more convenient. - */ - row_pointer[0] = & image_buffer[cinfo.next_scanline * row_stride]; - (void) jpeg_write_scanlines(&cinfo, row_pointer, 1); - } - - /* Step 6: Finish compression */ - - jpeg_finish_compress(&cinfo); - /* After finish_compress, we can close the output file. */ - fclose(outfile); - - /* Step 7: release JPEG compression object */ - - /* This is an important step since it will release a good deal of memory. */ - jpeg_destroy_compress(&cinfo); - - /* And we're done! */ -} - - -/* - * SOME FINE POINTS: - * - * In the above loop, we ignored the return value of jpeg_write_scanlines, - * which is the number of scanlines actually written. We could get away - * with this because we were only relying on the value of cinfo.next_scanline, - * which will be incremented correctly. If you maintain additional loop - * variables then you should be careful to increment them properly. - * Actually, for output to a stdio stream you needn't worry, because - * then jpeg_write_scanlines will write all the lines passed (or else exit - * with a fatal error). Partial writes can only occur if you use a data - * destination module that can demand suspension of the compressor. - * (If you don't know what that's for, you don't need it.) - * - * If the compressor requires full-image buffers (for entropy-coding - * optimization or a multi-scan JPEG file), it will create temporary - * files for anything that doesn't fit within the maximum-memory setting. - * (Note that temp files are NOT needed if you use the default parameters.) - * On some systems you may need to set up a signal handler to ensure that - * temporary files are deleted if the program is interrupted. See libjpeg.doc. - * - * Scanlines MUST be supplied in top-to-bottom order if you want your JPEG - * files to be compatible with everyone else's. If you cannot readily read - * your data in that order, you'll need an intermediate array to hold the - * image. See rdtarga.c or rdbmp.c for examples of handling bottom-to-top - * source data using the JPEG code's internal virtual-array mechanisms. - */ - - - -/******************** JPEG DECOMPRESSION SAMPLE INTERFACE *******************/ - -/* This half of the example shows how to read data from the JPEG decompressor. - * It's a bit more refined than the above, in that we show: - * (a) how to modify the JPEG library's standard error-reporting behavior; - * (b) how to allocate workspace using the library's memory manager. - * - * Just to make this example a little different from the first one, we'll - * assume that we do not intend to put the whole image into an in-memory - * buffer, but to send it line-by-line someplace else. We need a one- - * scanline-high JSAMPLE array as a work buffer, and we will let the JPEG - * memory manager allocate it for us. This approach is actually quite useful - * because we don't need to remember to deallocate the buffer separately: it - * will go away automatically when the JPEG object is cleaned up. - */ - - -/* - * ERROR HANDLING: - * - * The JPEG library's standard error handler (jerror.c) is divided into - * several "methods" which you can override individually. This lets you - * adjust the behavior without duplicating a lot of code, which you might - * have to update with each future release. - * - * Our example here shows how to override the "error_exit" method so that - * control is returned to the library's caller when a fatal error occurs, - * rather than calling exit() as the standard error_exit method does. - * - * We use C's setjmp/longjmp facility to return control. This means that the - * routine which calls the JPEG library must first execute a setjmp() call to - * establish the return point. We want the replacement error_exit to do a - * longjmp(). But we need to make the setjmp buffer accessible to the - * error_exit routine. To do this, we make a private extension of the - * standard JPEG error handler object. (If we were using C++, we'd say we - * were making a subclass of the regular error handler.) - * - * Here's the extended error handler struct: - */ - -struct my_error_mgr { - struct jpeg_error_mgr pub; /* "public" fields */ - - jmp_buf setjmp_buffer; /* for return to caller */ -}; - -typedef struct my_error_mgr * my_error_ptr; - -/* - * Here's the routine that will replace the standard error_exit method: - */ - -METHODDEF(void) -my_error_exit (j_common_ptr cinfo) -{ - /* cinfo->err really points to a my_error_mgr struct, so coerce pointer */ - my_error_ptr myerr = (my_error_ptr) cinfo->err; - - /* Always display the message. */ - /* We could postpone this until after returning, if we chose. */ - (*cinfo->err->output_message) (cinfo); - - /* Return control to the setjmp point */ - longjmp(myerr->setjmp_buffer, 1); -} - - -/* - * Sample routine for JPEG decompression. We assume that the source file name - * is passed in. We want to return 1 on success, 0 on error. - */ - - -GLOBAL(int) -read_JPEG_file (char * filename) -{ - /* This struct contains the JPEG decompression parameters and pointers to - * working space (which is allocated as needed by the JPEG library). - */ - struct jpeg_decompress_struct cinfo; - /* We use our private extension JPEG error handler. - * Note that this struct must live as long as the main JPEG parameter - * struct, to avoid dangling-pointer problems. - */ - struct my_error_mgr jerr; - /* More stuff */ - FILE * infile; /* source file */ - JSAMPARRAY buffer; /* Output row buffer */ - int row_stride; /* physical row width in output buffer */ - - /* In this example we want to open the input file before doing anything else, - * so that the setjmp() error recovery below can assume the file is open. - * VERY IMPORTANT: use "b" option to fopen() if you are on a machine that - * requires it in order to read binary files. - */ - - if ((infile = fopen(filename, "rb")) == NULL) { - fprintf(stderr, "can't open %s\n", filename); - return 0; - } - - /* Step 1: allocate and initialize JPEG decompression object */ - - /* We set up the normal JPEG error routines, then override error_exit. */ - cinfo.err = jpeg_std_error(&jerr.pub); - jerr.pub.error_exit = my_error_exit; - /* Establish the setjmp return context for my_error_exit to use. */ - if (setjmp(jerr.setjmp_buffer)) { - /* If we get here, the JPEG code has signaled an error. - * We need to clean up the JPEG object, close the input file, and return. - */ - jpeg_destroy_decompress(&cinfo); - fclose(infile); - return 0; - } - /* Now we can initialize the JPEG decompression object. */ - jpeg_create_decompress(&cinfo); - - /* Step 2: specify data source (eg, a file) */ - - jpeg_stdio_src(&cinfo, infile); - - /* Step 3: read file parameters with jpeg_read_header() */ - - (void) jpeg_read_header(&cinfo, TRUE); - /* We can ignore the return value from jpeg_read_header since - * (a) suspension is not possible with the stdio data source, and - * (b) we passed TRUE to reject a tables-only JPEG file as an error. - * See libjpeg.doc for more info. - */ - - /* Step 4: set parameters for decompression */ - - /* In this example, we don't need to change any of the defaults set by - * jpeg_read_header(), so we do nothing here. - */ - - /* Step 5: Start decompressor */ - - (void) jpeg_start_decompress(&cinfo); - /* We can ignore the return value since suspension is not possible - * with the stdio data source. - */ - - /* We may need to do some setup of our own at this point before reading - * the data. After jpeg_start_decompress() we have the correct scaled - * output image dimensions available, as well as the output colormap - * if we asked for color quantization. - * In this example, we need to make an output work buffer of the right size. - */ - /* JSAMPLEs per row in output buffer */ - row_stride = cinfo.output_width * cinfo.output_components; - /* Make a one-row-high sample array that will go away when done with image */ - buffer = (*cinfo.mem->alloc_sarray) - ((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1); - - /* Step 6: while (scan lines remain to be read) */ - /* jpeg_read_scanlines(...); */ - - /* Here we use the library's state variable cinfo.output_scanline as the - * loop counter, so that we don't have to keep track ourselves. - */ - while (cinfo.output_scanline < cinfo.output_height) { - /* jpeg_read_scanlines expects an array of pointers to scanlines. - * Here the array is only one element long, but you could ask for - * more than one scanline at a time if that's more convenient. - */ - (void) jpeg_read_scanlines(&cinfo, buffer, 1); - /* Assume put_scanline_someplace wants a pointer and sample count. */ - put_scanline_someplace(buffer[0], row_stride); - } - - /* Step 7: Finish decompression */ - - (void) jpeg_finish_decompress(&cinfo); - /* We can ignore the return value since suspension is not possible - * with the stdio data source. - */ - - /* Step 8: Release JPEG decompression object */ - - /* This is an important step since it will release a good deal of memory. */ - jpeg_destroy_decompress(&cinfo); - - /* After finish_decompress, we can close the input file. - * Here we postpone it until after no more JPEG errors are possible, - * so as to simplify the setjmp error logic above. (Actually, I don't - * think that jpeg_destroy can do an error exit, but why assume anything...) - */ - fclose(infile); - - /* At this point you may want to check to see whether any corrupt-data - * warnings occurred (test whether jerr.pub.num_warnings is nonzero). - */ - - /* And we're done! */ - return 1; -} - - -/* - * SOME FINE POINTS: - * - * In the above code, we ignored the return value of jpeg_read_scanlines, - * which is the number of scanlines actually read. We could get away with - * this because we asked for only one line at a time and we weren't using - * a suspending data source. See libjpeg.doc for more info. - * - * We cheated a bit by calling alloc_sarray() after jpeg_start_decompress(); - * we should have done it beforehand to ensure that the space would be - * counted against the JPEG max_memory setting. In some systems the above - * code would risk an out-of-memory error. However, in general we don't - * know the output image dimensions before jpeg_start_decompress(), unless we - * call jpeg_calc_output_dimensions(). See libjpeg.doc for more about this. - * - * Scanlines are returned in the same order as they appear in the JPEG file, - * which is standardly top-to-bottom. If you must emit data bottom-to-top, - * you can use one of the virtual arrays provided by the JPEG memory manager - * to invert the data. See wrbmp.c for an example. - * - * As with compression, some operating modes may require temporary files. - * On some systems you may need to set up a signal handler to ensure that - * temporary files are deleted if the program is interrupted. See libjpeg.doc. - */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/filelist.doc b/irrlicht-1.6/source/Irrlicht/jpeglib/filelist.doc deleted file mode 100644 index ad6a82d8c..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/filelist.doc +++ /dev/null @@ -1,210 +0,0 @@ -IJG JPEG LIBRARY: FILE LIST - -Copyright (C) 1994-1998, Thomas G. Lane. -This file is part of the Independent JPEG Group's software. -For conditions of distribution and use, see the accompanying README file. - - -Here is a road map to the files in the IJG JPEG distribution. The -distribution includes the JPEG library proper, plus two application -programs ("cjpeg" and "djpeg") which use the library to convert JPEG -files to and from some other popular image formats. A third application -"jpegtran" uses the library to do lossless conversion between different -variants of JPEG. There are also two stand-alone applications, -"rdjpgcom" and "wrjpgcom". - - -THE JPEG LIBRARY -================ - -Include files: - -jpeglib.h JPEG library's exported data and function declarations. -jconfig.h Configuration declarations. Note: this file is not present - in the distribution; it is generated during installation. -jmorecfg.h Additional configuration declarations; need not be changed - for a standard installation. -jerror.h Declares JPEG library's error and trace message codes. -jinclude.h Central include file used by all IJG .c files to reference - system include files. -jpegint.h JPEG library's internal data structures. -jchuff.h Private declarations for Huffman encoder modules. -jdhuff.h Private declarations for Huffman decoder modules. -jdct.h Private declarations for forward & reverse DCT subsystems. -jmemsys.h Private declarations for memory management subsystem. -jversion.h Version information. - -Applications using the library should include jpeglib.h (which in turn -includes jconfig.h and jmorecfg.h). Optionally, jerror.h may be included -if the application needs to reference individual JPEG error codes. The -other include files are intended for internal use and would not normally -be included by an application program. (cjpeg/djpeg/etc do use jinclude.h, -since its function is to improve portability of the whole IJG distribution. -Most other applications will directly include the system include files they -want, and hence won't need jinclude.h.) - - -C source code files: - -These files contain most of the functions intended to be called directly by -an application program: - -jcapimin.c Application program interface: core routines for compression. -jcapistd.c Application program interface: standard compression. -jdapimin.c Application program interface: core routines for decompression. -jdapistd.c Application program interface: standard decompression. -jcomapi.c Application program interface routines common to compression - and decompression. -jcparam.c Compression parameter setting helper routines. -jctrans.c API and library routines for transcoding compression. -jdtrans.c API and library routines for transcoding decompression. - -Compression side of the library: - -jcinit.c Initialization: determines which other modules to use. -jcmaster.c Master control: setup and inter-pass sequencing logic. -jcmainct.c Main buffer controller (preprocessor => JPEG compressor). -jcprepct.c Preprocessor buffer controller. -jccoefct.c Buffer controller for DCT coefficient buffer. -jccolor.c Color space conversion. -jcsample.c Downsampling. -jcdctmgr.c DCT manager (DCT implementation selection & control). -jfdctint.c Forward DCT using slow-but-accurate integer method. -jfdctfst.c Forward DCT using faster, less accurate integer method. -jfdctflt.c Forward DCT using floating-point arithmetic. -jchuff.c Huffman entropy coding for sequential JPEG. -jcphuff.c Huffman entropy coding for progressive JPEG. -jcmarker.c JPEG marker writing. -jdatadst.c Data destination manager for stdio output. - -Decompression side of the library: - -jdmaster.c Master control: determines which other modules to use. -jdinput.c Input controller: controls input processing modules. -jdmainct.c Main buffer controller (JPEG decompressor => postprocessor). -jdcoefct.c Buffer controller for DCT coefficient buffer. -jdpostct.c Postprocessor buffer controller. -jdmarker.c JPEG marker reading. -jdhuff.c Huffman entropy decoding for sequential JPEG. -jdphuff.c Huffman entropy decoding for progressive JPEG. -jddctmgr.c IDCT manager (IDCT implementation selection & control). -jidctint.c Inverse DCT using slow-but-accurate integer method. -jidctfst.c Inverse DCT using faster, less accurate integer method. -jidctflt.c Inverse DCT using floating-point arithmetic. -jidctred.c Inverse DCTs with reduced-size outputs. -jdsample.c Upsampling. -jdcolor.c Color space conversion. -jdmerge.c Merged upsampling/color conversion (faster, lower quality). -jquant1.c One-pass color quantization using a fixed-spacing colormap. -jquant2.c Two-pass color quantization using a custom-generated colormap. - Also handles one-pass quantization to an externally given map. -jdatasrc.c Data source manager for stdio input. - -Support files for both compression and decompression: - -jerror.c Standard error handling routines (application replaceable). -jmemmgr.c System-independent (more or less) memory management code. -jutils.c Miscellaneous utility routines. - -jmemmgr.c relies on a system-dependent memory management module. The IJG -distribution includes the following implementations of the system-dependent -module: - -jmemnobs.c "No backing store": assumes adequate virtual memory exists. -jmemansi.c Makes temporary files with ANSI-standard routine tmpfile(). -jmemname.c Makes temporary files with program-generated file names. -jmemdos.c Custom implementation for MS-DOS (16-bit environment only): - can use extended and expanded memory as well as temp files. -jmemmac.c Custom implementation for Apple Macintosh. - -Exactly one of the system-dependent modules should be configured into an -installed JPEG library (see install.doc for hints about which one to use). -On unusual systems you may find it worthwhile to make a special -system-dependent memory manager. - - -Non-C source code files: - -jmemdosa.asm 80x86 assembly code support for jmemdos.c; used only in - MS-DOS-specific configurations of the JPEG library. - - -CJPEG/DJPEG/JPEGTRAN -==================== - -Include files: - -cdjpeg.h Declarations shared by cjpeg/djpeg/jpegtran modules. -cderror.h Additional error and trace message codes for cjpeg et al. -transupp.h Declarations for jpegtran support routines in transupp.c. - -C source code files: - -cjpeg.c Main program for cjpeg. -djpeg.c Main program for djpeg. -jpegtran.c Main program for jpegtran. -cdjpeg.c Utility routines used by all three programs. -rdcolmap.c Code to read a colormap file for djpeg's "-map" switch. -rdswitch.c Code to process some of cjpeg's more complex switches. - Also used by jpegtran. -transupp.c Support code for jpegtran: lossless image manipulations. - -Image file reader modules for cjpeg: - -rdbmp.c BMP file input. -rdgif.c GIF file input (now just a stub). -rdppm.c PPM/PGM file input. -rdrle.c Utah RLE file input. -rdtarga.c Targa file input. - -Image file writer modules for djpeg: - -wrbmp.c BMP file output. -wrgif.c GIF file output (a mere shadow of its former self). -wrppm.c PPM/PGM file output. -wrrle.c Utah RLE file output. -wrtarga.c Targa file output. - - -RDJPGCOM/WRJPGCOM -================= - -C source code files: - -rdjpgcom.c Stand-alone rdjpgcom application. -wrjpgcom.c Stand-alone wrjpgcom application. - -These programs do not depend on the IJG library. They do use -jconfig.h and jinclude.h, only to improve portability. - - -ADDITIONAL FILES -================ - -Documentation (see README for a guide to the documentation files): - -README Master documentation file. -*.doc Other documentation files. -*.1 Documentation in Unix man page format. -change.log Version-to-version change highlights. -example.c Sample code for calling JPEG library. - -Configuration/installation files and programs (see install.doc for more info): - -configure Unix shell script to perform automatic configuration. -ltconfig Support scripts for configure (from GNU libtool). -ltmain.sh -config.guess -config.sub -install-sh Install shell script for those Unix systems lacking one. -ckconfig.c Program to generate jconfig.h on non-Unix systems. -jconfig.doc Template for making jconfig.h by hand. -makefile.* Sample makefiles for particular systems. -jconfig.* Sample jconfig.h for particular systems. -ansi2knr.c De-ANSIfier for pre-ANSI C compilers (courtesy of - L. Peter Deutsch and Aladdin Enterprises). - -Test files (see install.doc for test procedure): - -test*.* Source and comparison files for confidence test. - These are binary image files, NOT text files. diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/install-sh b/irrlicht-1.6/source/Irrlicht/jpeglib/install-sh deleted file mode 100644 index 082fd7c73..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/install-sh +++ /dev/null @@ -1,250 +0,0 @@ -#!/bin/sh -# -# install - install a program, script, or datafile -# This comes from X11R5 (mit/util/scripts/install.sh). -# -# Copyright 1991 by the Massachusetts Institute of Technology -# -# Permission to use, copy, modify, distribute, and sell this software and its -# documentation for any purpose is hereby granted without fee, provided that -# the above copyright notice appear in all copies and that both that -# copyright notice and this permission notice appear in supporting -# documentation, and that the name of M.I.T. not be used in advertising or -# publicity pertaining to distribution of the software without specific, -# written prior permission. M.I.T. makes no representations about the -# suitability of this software for any purpose. It is provided "as is" -# without express or implied warranty. -# -# Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it -# when there is no Makefile. -# -# This script is compatible with the BSD install script, but was written -# from scratch. It can only install one file at a time, a restriction -# shared with many OS's install programs. - - -# set DOITPROG to echo to test this script - -# Don't use :- since 4.3BSD and earlier shells don't like it. -doit="${DOITPROG-}" - - -# put in absolute paths if you don't have them in your path; or use env. vars. - -mvprog="${MVPROG-mv}" -cpprog="${CPPROG-cp}" -chmodprog="${CHMODPROG-chmod}" -chownprog="${CHOWNPROG-chown}" -chgrpprog="${CHGRPPROG-chgrp}" -stripprog="${STRIPPROG-strip}" -rmprog="${RMPROG-rm}" -mkdirprog="${MKDIRPROG-mkdir}" - -transformbasename="" -transform_arg="" -instcmd="$mvprog" -chmodcmd="$chmodprog 0755" -chowncmd="" -chgrpcmd="" -stripcmd="" -rmcmd="$rmprog -f" -mvcmd="$mvprog" -src="" -dst="" -dir_arg="" - -while [ x"$1" != x ]; do - case $1 in - -c) instcmd="$cpprog" - shift - continue;; - - -d) dir_arg=true - shift - continue;; - - -m) chmodcmd="$chmodprog $2" - shift - shift - continue;; - - -o) chowncmd="$chownprog $2" - shift - shift - continue;; - - -g) chgrpcmd="$chgrpprog $2" - shift - shift - continue;; - - -s) stripcmd="$stripprog" - shift - continue;; - - -t=*) transformarg=`echo $1 | sed 's/-t=//'` - shift - continue;; - - -b=*) transformbasename=`echo $1 | sed 's/-b=//'` - shift - continue;; - - *) if [ x"$src" = x ] - then - src=$1 - else - # this colon is to work around a 386BSD /bin/sh bug - : - dst=$1 - fi - shift - continue;; - esac -done - -if [ x"$src" = x ] -then - echo "install: no input file specified" - exit 1 -else - true -fi - -if [ x"$dir_arg" != x ]; then - dst=$src - src="" - - if [ -d $dst ]; then - instcmd=: - else - instcmd=mkdir - fi -else - -# Waiting for this to be detected by the "$instcmd $src $dsttmp" command -# might cause directories to be created, which would be especially bad -# if $src (and thus $dsttmp) contains '*'. - - if [ -f $src -o -d $src ] - then - true - else - echo "install: $src does not exist" - exit 1 - fi - - if [ x"$dst" = x ] - then - echo "install: no destination specified" - exit 1 - else - true - fi - -# If destination is a directory, append the input filename; if your system -# does not like double slashes in filenames, you may need to add some logic - - if [ -d $dst ] - then - dst="$dst"/`basename $src` - else - true - fi -fi - -## this sed command emulates the dirname command -dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` - -# Make sure that the destination directory exists. -# this part is taken from Noah Friedman's mkinstalldirs script - -# Skip lots of stat calls in the usual case. -if [ ! -d "$dstdir" ]; then -defaultIFS=' -' -IFS="${IFS-${defaultIFS}}" - -oIFS="${IFS}" -# Some sh's can't handle IFS=/ for some reason. -IFS='%' -set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` -IFS="${oIFS}" - -pathcomp='' - -while [ $# -ne 0 ] ; do - pathcomp="${pathcomp}${1}" - shift - - if [ ! -d "${pathcomp}" ] ; - then - $mkdirprog "${pathcomp}" - else - true - fi - - pathcomp="${pathcomp}/" -done -fi - -if [ x"$dir_arg" != x ] -then - $doit $instcmd $dst && - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi -else - -# If we're going to rename the final executable, determine the name now. - - if [ x"$transformarg" = x ] - then - dstfile=`basename $dst` - else - dstfile=`basename $dst $transformbasename | - sed $transformarg`$transformbasename - fi - -# don't allow the sed command to completely eliminate the filename - - if [ x"$dstfile" = x ] - then - dstfile=`basename $dst` - else - true - fi - -# Make a temp file name in the proper directory. - - dsttmp=$dstdir/#inst.$$# - -# Move or copy the file name to the temp name - - $doit $instcmd $src $dsttmp && - - trap "rm -f ${dsttmp}" 0 && - -# and set any options; do chmod last to preserve setuid bits - -# If any of these fail, we abort the whole thing. If we want to -# ignore errors from any of these, just make sure not to ignore -# errors from the above "$doit $instcmd $src $dsttmp" command. - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && - -# Now rename the file to the real destination. - - $doit $rmcmd -f $dstdir/$dstfile && - $doit $mvcmd $dsttmp $dstdir/$dstfile - -fi && - - -exit 0 diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/install.doc b/irrlicht-1.6/source/Irrlicht/jpeglib/install.doc deleted file mode 100644 index 7d72c93aa..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/install.doc +++ /dev/null @@ -1,1063 +0,0 @@ -INSTALLATION INSTRUCTIONS for the Independent JPEG Group's JPEG software - -Copyright (C) 1991-1998, Thomas G. Lane. -This file is part of the Independent JPEG Group's software. -For conditions of distribution and use, see the accompanying README file. - - -This file explains how to configure and install the IJG software. We have -tried to make this software extremely portable and flexible, so that it can be -adapted to almost any environment. The downside of this decision is that the -installation process is complicated. We have provided shortcuts to simplify -the task on common systems. But in any case, you will need at least a little -familiarity with C programming and program build procedures for your system. - -If you are only using this software as part of a larger program, the larger -program's installation procedure may take care of configuring the IJG code. -For example, Ghostscript's installation script will configure the IJG code. -You don't need to read this file if you just want to compile Ghostscript. - -If you are on a Unix machine, you may not need to read this file at all. -Try doing - ./configure - make - make test -If that doesn't complain, do - make install -(better do "make -n install" first to see if the makefile will put the files -where you want them). Read further if you run into snags or want to customize -the code for your system. - - -TABLE OF CONTENTS ------------------ - -Before you start -Configuring the software: - using the automatic "configure" script - using one of the supplied jconfig and makefile files - by hand -Building the software -Testing the software -Installing the software -Optional stuff -Optimization -Hints for specific systems - - -BEFORE YOU START -================ - -Before installing the software you must unpack the distributed source code. -Since you are reading this file, you have probably already succeeded in this -task. However, there is a potential for error if you needed to convert the -files to the local standard text file format (for example, if you are on -MS-DOS you may have converted LF end-of-line to CR/LF). You must apply -such conversion to all the files EXCEPT those whose names begin with "test". -The test files contain binary data; if you change them in any way then the -self-test will give bad results. - -Please check the last section of this file to see if there are hints for the -specific machine or compiler you are using. - - -CONFIGURING THE SOFTWARE -======================== - -To configure the IJG code for your system, you need to create two files: - * jconfig.h: contains values for system-dependent #define symbols. - * Makefile: controls the compilation process. -(On a non-Unix machine, you may create "project files" or some other -substitute for a Makefile. jconfig.h is needed in any environment.) - -We provide three different ways to generate these files: - * On a Unix system, you can just run the "configure" script. - * We provide sample jconfig files and makefiles for popular machines; - if your machine matches one of the samples, just copy the right sample - files to jconfig.h and Makefile. - * If all else fails, read the instructions below and make your own files. - - -Configuring the software using the automatic "configure" script ---------------------------------------------------------------- - -If you are on a Unix machine, you can just type - ./configure -and let the configure script construct appropriate configuration files. -If you're using "csh" on an old version of System V, you might need to type - sh configure -instead to prevent csh from trying to execute configure itself. -Expect configure to run for a few minutes, particularly on slower machines; -it works by compiling a series of test programs. - -Configure was created with GNU Autoconf and it follows the usual conventions -for GNU configure scripts. It makes a few assumptions that you may want to -override. You can do this by providing optional switches to configure: - -* If you want to build libjpeg as a shared library, say - ./configure --enable-shared -To get both shared and static libraries, say - ./configure --enable-shared --enable-static -Note that these switches invoke GNU libtool to take care of system-dependent -shared library building methods. If things don't work this way, please try -running configure without either switch; that should build a static library -without using libtool. If that works, your problem is probably with libtool -not with the IJG code. libtool is fairly new and doesn't support all flavors -of Unix yet. (You might be able to find a newer version of libtool than the -one included with libjpeg; see ftp.gnu.org. Report libtool problems to -bug-libtool@gnu.org.) - -* Configure will use gcc (GNU C compiler) if it's available, otherwise cc. -To force a particular compiler to be selected, use the CC option, for example - ./configure CC='cc' -The same method can be used to include any unusual compiler switches. -For example, on HP-UX you probably want to say - ./configure CC='cc -Aa' -to get HP's compiler to run in ANSI mode. - -* The default CFLAGS setting is "-O" for non-gcc compilers, "-O2" for gcc. -You can override this by saying, for example, - ./configure CFLAGS='-g' -if you want to compile with debugging support. - -* Configure will set up the makefile so that "make install" will install files -into /usr/local/bin, /usr/local/man, etc. You can specify an installation -prefix other than "/usr/local" by giving configure the option "--prefix=PATH". - -* If you don't have a lot of swap space, you may need to enable the IJG -software's internal virtual memory mechanism. To do this, give the option -"--enable-maxmem=N" where N is the default maxmemory limit in megabytes. -This is discussed in more detail under "Selecting a memory manager", below. -You probably don't need to worry about this on reasonably-sized Unix machines, -unless you plan to process very large images. - -Configure has some other features that are useful if you are cross-compiling -or working in a network of multiple machine types; but if you need those -features, you probably already know how to use them. - - -Configuring the software using one of the supplied jconfig and makefile files ------------------------------------------------------------------------------ - -If you have one of these systems, you can just use the provided configuration -files: - -Makefile jconfig file System and/or compiler - -makefile.manx jconfig.manx Amiga, Manx Aztec C -makefile.sas jconfig.sas Amiga, SAS C -makeproj.mac jconfig.mac Apple Macintosh, Metrowerks CodeWarrior -mak*jpeg.st jconfig.st Atari ST/STE/TT, Pure C or Turbo C -makefile.bcc jconfig.bcc MS-DOS or OS/2, Borland C -makefile.dj jconfig.dj MS-DOS, DJGPP (Delorie's port of GNU C) -makefile.mc6 jconfig.mc6 MS-DOS, Microsoft C (16-bit only) -makefile.wat jconfig.wat MS-DOS, OS/2, or Windows NT, Watcom C -makefile.vc jconfig.vc Windows NT/95, MS Visual C++ -make*.ds jconfig.vc Windows NT/95, MS Developer Studio -makefile.mms jconfig.vms Digital VMS, with MMS software -makefile.vms jconfig.vms Digital VMS, without MMS software - -Copy the proper jconfig file to jconfig.h and the makefile to Makefile (or -whatever your system uses as the standard makefile name). For more info see -the appropriate system-specific hints section near the end of this file. - - -Configuring the software by hand --------------------------------- - -First, generate a jconfig.h file. If you are moderately familiar with C, -the comments in jconfig.doc should be enough information to do this; just -copy jconfig.doc to jconfig.h and edit it appropriately. Otherwise, you may -prefer to use the ckconfig.c program. You will need to compile and execute -ckconfig.c by hand --- we hope you know at least enough to do that. -ckconfig.c may not compile the first try (in fact, the whole idea is for it -to fail if anything is going to). If you get compile errors, fix them by -editing ckconfig.c according to the directions given in ckconfig.c. Once -you get it to run, it will write a suitable jconfig.h file, and will also -print out some advice about which makefile to use. - -You may also want to look at the canned jconfig files, if there is one for a -system similar to yours. - -Second, select a makefile and copy it to Makefile (or whatever your system -uses as the standard makefile name). The most generic makefiles we provide -are - makefile.ansi: if your C compiler supports function prototypes - makefile.unix: if not. -(You have function prototypes if ckconfig.c put "#define HAVE_PROTOTYPES" -in jconfig.h.) You may want to start from one of the other makefiles if -there is one for a system similar to yours. - -Look over the selected Makefile and adjust options as needed. In particular -you may want to change the CC and CFLAGS definitions. For instance, if you -are using GCC, set CC=gcc. If you had to use any compiler switches to get -ckconfig.c to work, make sure the same switches are in CFLAGS. - -If you are on a system that doesn't use makefiles, you'll need to set up -project files (or whatever you do use) to compile all the source files and -link them into executable files cjpeg, djpeg, jpegtran, rdjpgcom, and wrjpgcom. -See the file lists in any of the makefiles to find out which files go into -each program. Note that the provided makefiles all make a "library" file -libjpeg first, but you don't have to do that if you don't want to; the file -lists identify which source files are actually needed for compression, -decompression, or both. As a last resort, you can make a batch script that -just compiles everything and links it all together; makefile.vms is an example -of this (it's for VMS systems that have no make-like utility). - -Here are comments about some specific configuration decisions you'll -need to make: - -Command line style ------------------- - -These programs can use a Unix-like command line style which supports -redirection and piping, like this: - cjpeg inputfile >outputfile - cjpeg <inputfile >outputfile - source program | cjpeg >outputfile -The simpler "two file" command line style is just - cjpeg inputfile outputfile -You may prefer the two-file style, particularly if you don't have pipes. - -You MUST use two-file style on any system that doesn't cope well with binary -data fed through stdin/stdout; this is true for some MS-DOS compilers, for -example. If you're not on a Unix system, it's safest to assume you need -two-file style. (But if your compiler provides either the Posix-standard -fdopen() library routine or a Microsoft-compatible setmode() routine, you -can safely use the Unix command line style, by defining USE_FDOPEN or -USE_SETMODE respectively.) - -To use the two-file style, make jconfig.h say "#define TWO_FILE_COMMANDLINE". - -Selecting a memory manager --------------------------- - -The IJG code is capable of working on images that are too big to fit in main -memory; data is swapped out to temporary files as necessary. However, the -code to do this is rather system-dependent. We provide five different -memory managers: - -* jmemansi.c This version uses the ANSI-standard library routine tmpfile(), - which not all non-ANSI systems have. On some systems - tmpfile() may put the temporary file in a non-optimal - location; if you don't like what it does, use jmemname.c. - -* jmemname.c This version creates named temporary files. For anything - except a Unix machine, you'll need to configure the - select_file_name() routine appropriately; see the comments - near the head of jmemname.c. If you use this version, define - NEED_SIGNAL_CATCHER in jconfig.h to make sure the temp files - are removed if the program is aborted. - -* jmemnobs.c (That stands for No Backing Store :-).) This will compile on - almost any system, but it assumes you have enough main memory - or virtual memory to hold the biggest images you work with. - -* jmemdos.c This should be used with most 16-bit MS-DOS compilers. - See the system-specific notes about MS-DOS for more info. - IMPORTANT: if you use this, define USE_MSDOS_MEMMGR in - jconfig.h, and include the assembly file jmemdosa.asm in the - programs. The supplied makefiles and jconfig files for - 16-bit MS-DOS compilers already do both. - -* jmemmac.c Custom version for Apple Macintosh; see the system-specific - notes for Macintosh for more info. - -To use a particular memory manager, change the SYSDEPMEM variable in your -makefile to equal the corresponding object file name (for example, jmemansi.o -or jmemansi.obj for jmemansi.c). - -If you have plenty of (real or virtual) main memory, just use jmemnobs.c. -"Plenty" means about ten bytes for every pixel in the largest images -you plan to process, so a lot of systems don't meet this criterion. -If yours doesn't, try jmemansi.c first. If that doesn't compile, you'll have -to use jmemname.c; be sure to adjust select_file_name() for local conditions. -You may also need to change unlink() to remove() in close_backing_store(). - -Except with jmemnobs.c or jmemmac.c, you need to adjust the DEFAULT_MAX_MEM -setting to a reasonable value for your system (either by adding a #define for -DEFAULT_MAX_MEM to jconfig.h, or by adding a -D switch to the Makefile). -This value limits the amount of data space the program will attempt to -allocate. Code and static data space isn't counted, so the actual memory -needs for cjpeg or djpeg are typically 100 to 150Kb more than the max-memory -setting. Larger max-memory settings reduce the amount of I/O needed to -process a large image, but too large a value can result in "insufficient -memory" failures. On most Unix machines (and other systems with virtual -memory), just set DEFAULT_MAX_MEM to several million and forget it. At the -other end of the spectrum, for MS-DOS machines you probably can't go much -above 300K to 400K. (On MS-DOS the value refers to conventional memory only. -Extended/expanded memory is handled separately by jmemdos.c.) - - -BUILDING THE SOFTWARE -===================== - -Now you should be able to compile the software. Just say "make" (or -whatever's necessary to start the compilation). Have a cup of coffee. - -Here are some things that could go wrong: - -If your compiler complains about undefined structures, you should be able to -shut it up by putting "#define INCOMPLETE_TYPES_BROKEN" in jconfig.h. - -If you have trouble with missing system include files or inclusion of the -wrong ones, read jinclude.h. This shouldn't happen if you used configure -or ckconfig.c to set up jconfig.h. - -There are a fair number of routines that do not use all of their parameters; -some compilers will issue warnings about this, which you can ignore. There -are also a few configuration checks that may give "unreachable code" warnings. -Any other warning deserves investigation. - -If you don't have a getenv() library routine, define NO_GETENV. - -Also see the system-specific hints, below. - - -TESTING THE SOFTWARE -==================== - -As a quick test of functionality we've included a small sample image in -several forms: - testorig.jpg Starting point for the djpeg tests. - testimg.ppm The output of djpeg testorig.jpg - testimg.bmp The output of djpeg -bmp -colors 256 testorig.jpg - testimg.jpg The output of cjpeg testimg.ppm - testprog.jpg Progressive-mode equivalent of testorig.jpg. - testimgp.jpg The output of cjpeg -progressive -optimize testimg.ppm -(The first- and second-generation .jpg files aren't identical since JPEG is -lossy.) If you can generate duplicates of the testimg* files then you -probably have working programs. - -With most of the makefiles, "make test" will perform the necessary -comparisons. - -If you're using a makefile that doesn't provide the test option, run djpeg -and cjpeg by hand and compare the output files to testimg* with whatever -binary file comparison tool you have. The files should be bit-for-bit -identical. - -If the programs complain "MAX_ALLOC_CHUNK is wrong, please fix", then you -need to reduce MAX_ALLOC_CHUNK to a value that fits in type size_t. -Try adding "#define MAX_ALLOC_CHUNK 65520L" to jconfig.h. A less likely -configuration error is "ALIGN_TYPE is wrong, please fix": defining ALIGN_TYPE -as long should take care of that one. - -If the cjpeg test run fails with "Missing Huffman code table entry", it's a -good bet that you needed to define RIGHT_SHIFT_IS_UNSIGNED. Go back to the -configuration step and run ckconfig.c. (This is a good plan for any other -test failure, too.) - -If you are using Unix (one-file) command line style on a non-Unix system, -it's a good idea to check that binary I/O through stdin/stdout actually -works. You should get the same results from "djpeg <testorig.jpg >out.ppm" -as from "djpeg -outfile out.ppm testorig.jpg". Note that the makefiles all -use the latter style and therefore do not exercise stdin/stdout! If this -check fails, try recompiling with USE_SETMODE or USE_FDOPEN defined. -If it still doesn't work, better use two-file style. - -If you chose a memory manager other than jmemnobs.c, you should test that -temporary-file usage works. Try "djpeg -bmp -colors 256 -max 0 testorig.jpg" -and make sure its output matches testimg.bmp. If you have any really large -images handy, try compressing them with -optimize and/or decompressing with --colors 256 to make sure your DEFAULT_MAX_MEM setting is not too large. - -NOTE: this is far from an exhaustive test of the JPEG software; some modules, -such as 1-pass color quantization, are not exercised at all. It's just a -quick test to give you some confidence that you haven't missed something -major. - - -INSTALLING THE SOFTWARE -======================= - -Once you're done with the above steps, you can install the software by -copying the executable files (cjpeg, djpeg, jpegtran, rdjpgcom, and wrjpgcom) -to wherever you normally install programs. On Unix systems, you'll also want -to put the man pages (cjpeg.1, djpeg.1, jpegtran.1, rdjpgcom.1, wrjpgcom.1) -in the man-page directory. The pre-fab makefiles don't support this step -since there's such a wide variety of installation procedures on different -systems. - -If you generated a Makefile with the "configure" script, you can just say - make install -to install the programs and their man pages into the standard places. -(You'll probably need to be root to do this.) We recommend first saying - make -n install -to see where configure thought the files should go. You may need to edit -the Makefile, particularly if your system's conventions for man page -filenames don't match what configure expects. - -If you want to install the IJG library itself, for use in compiling other -programs besides ours, then you need to put the four include files - jpeglib.h jerror.h jconfig.h jmorecfg.h -into your include-file directory, and put the library file libjpeg.a -(extension may vary depending on system) wherever library files go. -If you generated a Makefile with "configure", it will do what it thinks -is the right thing if you say - make install-lib - - -OPTIONAL STUFF -============== - -Progress monitor: - -If you like, you can #define PROGRESS_REPORT (in jconfig.h) to enable display -of percent-done progress reports. The routine provided in cdjpeg.c merely -prints percentages to stderr, but you can customize it to do something -fancier. - -Utah RLE file format support: - -We distribute the software with support for RLE image files (Utah Raster -Toolkit format) disabled, because the RLE support won't compile without the -Utah library. If you have URT version 3.1 or later, you can enable RLE -support as follows: - 1. #define RLE_SUPPORTED in jconfig.h. - 2. Add a -I option to CFLAGS in the Makefile for the directory - containing the URT .h files (typically the "include" - subdirectory of the URT distribution). - 3. Add -L... -lrle to LDLIBS in the Makefile, where ... specifies - the directory containing the URT "librle.a" file (typically the - "lib" subdirectory of the URT distribution). - -Support for 12-bit-deep pixel data: - -The JPEG standard allows either 8-bit or 12-bit data precision. (For color, -this means 8 or 12 bits per channel, of course.) If you need to work with -deeper than 8-bit data, you can compile the IJG code for 12-bit operation. -To do so: - 1. In jmorecfg.h, define BITS_IN_JSAMPLE as 12 rather than 8. - 2. In jconfig.h, undefine BMP_SUPPORTED, RLE_SUPPORTED, and TARGA_SUPPORTED, - because the code for those formats doesn't handle 12-bit data and won't - even compile. (The PPM code does work, as explained below. The GIF - code works too; it scales 8-bit GIF data to and from 12-bit depth - automatically.) - 3. Compile. Don't expect "make test" to pass, since the supplied test - files are for 8-bit data. - -Currently, 12-bit support does not work on 16-bit-int machines. - -Note that a 12-bit version will not read 8-bit JPEG files, nor vice versa; -so you'll want to keep around a regular 8-bit compilation as well. -(Run-time selection of data depth, to allow a single copy that does both, -is possible but would probably slow things down considerably; it's very low -on our to-do list.) - -The PPM reader (rdppm.c) can read 12-bit data from either text-format or -binary-format PPM and PGM files. Binary-format PPM/PGM files which have a -maxval greater than 255 are assumed to use 2 bytes per sample, LSB first -(little-endian order). As of early 1995, 2-byte binary format is not -officially supported by the PBMPLUS library, but it is expected that a -future release of PBMPLUS will support it. Note that the PPM reader will -read files of any maxval regardless of the BITS_IN_JSAMPLE setting; incoming -data is automatically rescaled to either maxval=255 or maxval=4095 as -appropriate for the cjpeg bit depth. - -The PPM writer (wrppm.c) will normally write 2-byte binary PPM or PGM -format, maxval 4095, when compiled with BITS_IN_JSAMPLE=12. Since this -format is not yet widely supported, you can disable it by compiling wrppm.c -with PPM_NORAWWORD defined; then the data is scaled down to 8 bits to make a -standard 1-byte/sample PPM or PGM file. (Yes, this means still another copy -of djpeg to keep around. But hopefully you won't need it for very long. -Poskanzer's supposed to get that new PBMPLUS release out Real Soon Now.) - -Of course, if you are working with 12-bit data, you probably have it stored -in some other, nonstandard format. In that case you'll probably want to -write your own I/O modules to read and write your format. - -Note that a 12-bit version of cjpeg always runs in "-optimize" mode, in -order to generate valid Huffman tables. This is necessary because our -default Huffman tables only cover 8-bit data. - -Removing code: - -If you need to make a smaller version of the JPEG software, some optional -functions can be removed at compile time. See the xxx_SUPPORTED #defines in -jconfig.h and jmorecfg.h. If at all possible, we recommend that you leave in -decoder support for all valid JPEG files, to ensure that you can read anyone's -output. Taking out support for image file formats that you don't use is the -most painless way to make the programs smaller. Another possibility is to -remove some of the DCT methods: in particular, the "IFAST" method may not be -enough faster than the others to be worth keeping on your machine. (If you -do remove ISLOW or IFAST, be sure to redefine JDCT_DEFAULT or JDCT_FASTEST -to a supported method, by adding a #define in jconfig.h.) - - -OPTIMIZATION -============ - -Unless you own a Cray, you'll probably be interested in making the JPEG -software go as fast as possible. This section covers some machine-dependent -optimizations you may want to try. We suggest that before trying any of -this, you first get the basic installation to pass the self-test step. -Repeat the self-test after any optimization to make sure that you haven't -broken anything. - -The integer DCT routines perform a lot of multiplications. These -multiplications must yield 32-bit results, but none of their input values -are more than 16 bits wide. On many machines, notably the 680x0 and 80x86 -CPUs, a 16x16=>32 bit multiply instruction is faster than a full 32x32=>32 -bit multiply. Unfortunately there is no portable way to specify such a -multiplication in C, but some compilers can generate one when you use the -right combination of casts. See the MULTIPLYxxx macro definitions in -jdct.h. If your compiler makes "int" be 32 bits and "short" be 16 bits, -defining SHORTxSHORT_32 is fairly likely to work. When experimenting with -alternate definitions, be sure to test not only whether the code still works -(use the self-test), but also whether it is actually faster --- on some -compilers, alternate definitions may compute the right answer, yet be slower -than the default. Timing cjpeg on a large PGM (grayscale) input file is the -best way to check this, as the DCT will be the largest fraction of the runtime -in that mode. (Note: some of the distributed compiler-specific jconfig files -already contain #define switches to select appropriate MULTIPLYxxx -definitions.) - -If your machine has sufficiently fast floating point hardware, you may find -that the float DCT method is faster than the integer DCT methods, even -after tweaking the integer multiply macros. In that case you may want to -make the float DCT be the default method. (The only objection to this is -that float DCT results may vary slightly across machines.) To do that, add -"#define JDCT_DEFAULT JDCT_FLOAT" to jconfig.h. Even if you don't change -the default, you should redefine JDCT_FASTEST, which is the method selected -by djpeg's -fast switch. Don't forget to update the documentation files -(usage.doc and/or cjpeg.1, djpeg.1) to agree with what you've done. - -If access to "short" arrays is slow on your machine, it may be a win to -define type JCOEF as int rather than short. This will cost a good deal of -memory though, particularly in some multi-pass modes, so don't do it unless -you have memory to burn and short is REALLY slow. - -If your compiler can compile function calls in-line, make sure the INLINE -macro in jmorecfg.h is defined as the keyword that marks a function -inline-able. Some compilers have a switch that tells the compiler to inline -any function it thinks is profitable (e.g., -finline-functions for gcc). -Enabling such a switch is likely to make the compiled code bigger but faster. - -In general, it's worth trying the maximum optimization level of your compiler, -and experimenting with any optional optimizations such as loop unrolling. -(Unfortunately, far too many compilers have optimizer bugs ... be prepared to -back off if the code fails self-test.) If you do any experimentation along -these lines, please report the optimal settings to jpeg-info@uunet.uu.net so -we can mention them in future releases. Be sure to specify your machine and -compiler version. - - -HINTS FOR SPECIFIC SYSTEMS -========================== - -We welcome reports on changes needed for systems not mentioned here. Submit -'em to jpeg-info@uunet.uu.net. Also, if configure or ckconfig.c is wrong -about how to configure the JPEG software for your system, please let us know. - - -Acorn RISC OS: - -(Thanks to Simon Middleton for these hints on compiling with Desktop C.) -After renaming the files according to Acorn conventions, take a copy of -makefile.ansi, change all occurrences of 'libjpeg.a' to 'libjpeg.o' and -change these definitions as indicated: - -CFLAGS= -throwback -IC: -Wn -LDLIBS=C:o.Stubs -SYSDEPMEM=jmemansi.o -LN=Link -AR=LibFile -c -o - -Also add a new line '.c.o:; $(cc) $< $(cflags) -c -o $@'. Remove the -lines '$(RM) libjpeg.o' and '$(AR2) libjpeg.o' and the 'jconfig.h' -dependency section. - -Copy jconfig.doc to jconfig.h. Edit jconfig.h to define TWO_FILE_COMMANDLINE -and CHAR_IS_UNSIGNED. - -Run the makefile using !AMU not !Make. If you want to use the 'clean' and -'test' makefile entries then you will have to fiddle with the syntax a bit -and rename the test files. - - -Amiga: - -SAS C 6.50 reportedly is too buggy to compile the IJG code properly. -A patch to update to 6.51 is available from SAS or AmiNet FTP sites. - -The supplied config files are set up to use jmemname.c as the memory -manager, with temporary files being created on the device named by -"JPEGTMP:". - - -Atari ST/STE/TT: - -Copy the project files makcjpeg.st, makdjpeg.st, maktjpeg.st, and makljpeg.st -to cjpeg.prj, djpeg.prj, jpegtran.prj, and libjpeg.prj respectively. The -project files should work as-is with Pure C. For Turbo C, change library -filenames "pc..." to "tc..." in each project file. Note that libjpeg.prj -selects jmemansi.c as the recommended memory manager. You'll probably want to -adjust the DEFAULT_MAX_MEM setting --- you want it to be a couple hundred K -less than your normal free memory. Put "#define DEFAULT_MAX_MEM nnnn" into -jconfig.h to do this. - -To use the 68881/68882 coprocessor for the floating point DCT, add the -compiler option "-8" to the project files and replace pcfltlib.lib with -pc881lib.lib in cjpeg.prj and djpeg.prj. Or if you don't have a -coprocessor, you may prefer to remove the float DCT code by undefining -DCT_FLOAT_SUPPORTED in jmorecfg.h (since without a coprocessor, the float -code will be too slow to be useful). In that case, you can delete -pcfltlib.lib from the project files. - -Note that you must make libjpeg.lib before making cjpeg.ttp, djpeg.ttp, -or jpegtran.ttp. You'll have to perform the self-test by hand. - -We haven't bothered to include project files for rdjpgcom and wrjpgcom. -Those source files should just be compiled by themselves; they don't -depend on the JPEG library. - -There is a bug in some older versions of the Turbo C library which causes the -space used by temporary files created with "tmpfile()" not to be freed after -an abnormal program exit. If you check your disk afterwards, you will find -cluster chains that are allocated but not used by a file. This should not -happen in cjpeg/djpeg/jpegtran, since we enable a signal catcher to explicitly -close temp files before exiting. But if you use the JPEG library with your -own code, be sure to supply a signal catcher, or else use a different -system-dependent memory manager. - - -Cray: - -Should you be so fortunate as to be running JPEG on a Cray YMP, there is a -compiler bug in old versions of Cray's Standard C (prior to 3.1). If you -still have an old compiler, you'll need to insert a line reading -"#pragma novector" just before the loop - for (i = 1; i <= (int) htbl->bits[l]; i++) - huffsize[p++] = (char) l; -in fix_huff_tbl (in V5beta1, line 204 of jchuff.c and line 176 of jdhuff.c). -[This bug may or may not still occur with the current IJG code, but it's -probably a dead issue anyway...] - - -HP-UX: - -If you have HP-UX 7.05 or later with the "software development" C compiler, -you should run the compiler in ANSI mode. If using the configure script, -say - ./configure CC='cc -Aa' -(or -Ae if you prefer). If configuring by hand, use makefile.ansi and add -"-Aa" to the CFLAGS line in the makefile. - -If you have a pre-7.05 system, or if you are using the non-ANSI C compiler -delivered with a minimum HP-UX system, then you must use makefile.unix -(and do NOT add -Aa); or just run configure without the CC option. - -On HP 9000 series 800 machines, the HP C compiler is buggy in revisions prior -to A.08.07. If you get complaints about "not a typedef name", you'll have to -use makefile.unix, or run configure without the CC option. - - -Macintosh, generic comments: - -The supplied user-interface files (cjpeg.c, djpeg.c, etc) are set up to -provide a Unix-style command line interface. You can use this interface on -the Mac by means of the ccommand() library routine provided by Metrowerks -CodeWarrior or Think C. This is only appropriate for testing the library, -however; to make a user-friendly equivalent of cjpeg/djpeg you'd really want -to develop a Mac-style user interface. There isn't a complete example -available at the moment, but there are some helpful starting points: -1. Sam Bushell's free "To JPEG" applet provides drag-and-drop conversion to -JPEG under System 7 and later. This only illustrates how to use the -compression half of the library, but it does a very nice job of that part. -The CodeWarrior source code is available from http://www.pobox.com/~jsam. -2. Jim Brunner prepared a Mac-style user interface for both compression and -decompression. Unfortunately, it hasn't been updated since IJG v4, and -the library's API has changed considerably since then. Still it may be of -some help, particularly as a guide to compiling the IJG code under Think C. -Jim's code is available from the Info-Mac archives, at sumex-aim.stanford.edu -or mirrors thereof; see file /info-mac/dev/src/jpeg-convert-c.hqx. - -jmemmac.c is the recommended memory manager back end for Macintosh. It uses -NewPtr/DisposePtr instead of malloc/free, and has a Mac-specific -implementation of jpeg_mem_available(). It also creates temporary files that -follow Mac conventions. (That part of the code relies on System-7-or-later OS -functions. See the comments in jmemmac.c if you need to run it on System 6.) -NOTE that USE_MAC_MEMMGR must be defined in jconfig.h to use jmemmac.c. - -You can also use jmemnobs.c, if you don't care about handling images larger -than available memory. If you use any memory manager back end other than -jmemmac.c, we recommend replacing "malloc" and "free" by "NewPtr" and -"DisposePtr", because Mac C libraries often have peculiar implementations of -malloc/free. (For instance, free() may not return the freed space to the -Mac Memory Manager. This is undesirable for the IJG code because jmemmgr.c -already clumps space requests.) - - -Macintosh, Metrowerks CodeWarrior: - -The Unix-command-line-style interface can be used by defining USE_CCOMMAND. -You'll also need to define TWO_FILE_COMMANDLINE to avoid stdin/stdout. -This means that when using the cjpeg/djpeg programs, you'll have to type the -input and output file names in the "Arguments" text-edit box, rather than -using the file radio buttons. (Perhaps USE_FDOPEN or USE_SETMODE would -eliminate the problem, but I haven't heard from anyone who's tried it.) - -On 680x0 Macs, Metrowerks defines type "double" as a 10-byte IEEE extended -float. jmemmgr.c won't like this: it wants sizeof(ALIGN_TYPE) to be a power -of 2. Add "#define ALIGN_TYPE long" to jconfig.h to eliminate the complaint. - -The supplied configuration file jconfig.mac can be used for your jconfig.h; -it includes all the recommended symbol definitions. If you have AppleScript -installed, you can run the supplied script makeproj.mac to create CodeWarrior -project files for the library and the testbed applications, then build the -library and applications. (Thanks to Dan Sears and Don Agro for this nifty -hack, which saves us from trying to maintain CodeWarrior project files as part -of the IJG distribution...) - - -Macintosh, Think C: - -The documentation in Jim Brunner's "JPEG Convert" source code (see above) -includes detailed build instructions for Think C; it's probably somewhat -out of date for the current release, but may be helpful. - -If you want to build the minimal command line version, proceed as follows. -You'll have to prepare project files for the programs; we don't include any -in the distribution since they are not text files. Use the file lists in -any of the supplied makefiles as a guide. Also add the ANSI and Unix C -libraries in a separate segment. You may need to divide the JPEG files into -more than one segment; we recommend dividing compression and decompression -modules. Define USE_CCOMMAND in jconfig.h so that the ccommand() routine is -called. You must also define TWO_FILE_COMMANDLINE because stdin/stdout -don't handle binary data correctly. - -On 680x0 Macs, Think C defines type "double" as a 12-byte IEEE extended float. -jmemmgr.c won't like this: it wants sizeof(ALIGN_TYPE) to be a power of 2. -Add "#define ALIGN_TYPE long" to jconfig.h to eliminate the complaint. - -jconfig.mac should work as a jconfig.h configuration file for Think C, -but the makeproj.mac AppleScript script is specific to CodeWarrior. Sorry. - - -MIPS R3000: - -MIPS's cc version 1.31 has a rather nasty optimization bug. Don't use -O -if you have that compiler version. (Use "cc -V" to check the version.) -Note that the R3000 chip is found in workstations from DEC and others. - - -MS-DOS, generic comments for 16-bit compilers: - -The IJG code is designed to work well in 80x86 "small" or "medium" memory -models (i.e., data pointers are 16 bits unless explicitly declared "far"; -code pointers can be either size). You may be able to use small model to -compile cjpeg or djpeg by itself, but you will probably have to use medium -model for any larger application. This won't make much difference in -performance. You *will* take a noticeable performance hit if you use a -large-data memory model, and you should avoid "huge" model if at all -possible. Be sure that NEED_FAR_POINTERS is defined in jconfig.h if you use -a small-data memory model; be sure it is NOT defined if you use a large-data -model. (The supplied makefiles and jconfig files for Borland and Microsoft C -compile in medium model and define NEED_FAR_POINTERS.) - -The DOS-specific memory manager, jmemdos.c, should be used if possible. -It needs some assembly-code routines which are in jmemdosa.asm; make sure -your makefile assembles that file and includes it in the library. If you -don't have a suitable assembler, you can get pre-assembled object files for -jmemdosa by FTP from ftp.uu.net:/graphics/jpeg/jdosaobj.zip. (DOS-oriented -distributions of the IJG source code often include these object files.) - -When using jmemdos.c, jconfig.h must define USE_MSDOS_MEMMGR and must set -MAX_ALLOC_CHUNK to less than 64K (65520L is a typical value). If your -C library's far-heap malloc() can't allocate blocks that large, reduce -MAX_ALLOC_CHUNK to whatever it can handle. - -If you can't use jmemdos.c for some reason --- for example, because you -don't have an assembler to assemble jmemdosa.asm --- you'll have to fall -back to jmemansi.c or jmemname.c. You'll probably still need to set -MAX_ALLOC_CHUNK in jconfig.h, because most DOS C libraries won't malloc() -more than 64K at a time. IMPORTANT: if you use jmemansi.c or jmemname.c, -you will have to compile in a large-data memory model in order to get the -right stdio library. Too bad. - -wrjpgcom needs to be compiled in large model, because it malloc()s a 64KB -work area to hold the comment text. If your C library's malloc can't -handle that, reduce MAX_COM_LENGTH as necessary in wrjpgcom.c. - -Most MS-DOS compilers treat stdin/stdout as text files, so you must use -two-file command line style. But if your compiler has either fdopen() or -setmode(), you can use one-file style if you like. To do this, define -USE_SETMODE or USE_FDOPEN so that stdin/stdout will be set to binary mode. -(USE_SETMODE seems to work with more DOS compilers than USE_FDOPEN.) You -should test that I/O through stdin/stdout produces the same results as I/O -to explicitly named files... the "make test" procedures in the supplied -makefiles do NOT use stdin/stdout. - - -MS-DOS, generic comments for 32-bit compilers: - -None of the above comments about memory models apply if you are using a -32-bit flat-memory-space environment, such as DJGPP or Watcom C. (And you -should use one if you have it, as performance will be much better than -8086-compatible code!) For flat-memory-space compilers, do NOT define -NEED_FAR_POINTERS, and do NOT use jmemdos.c. Use jmemnobs.c if the -environment supplies adequate virtual memory, otherwise use jmemansi.c or -jmemname.c. - -You'll still need to be careful about binary I/O through stdin/stdout. -See the last paragraph of the previous section. - - -MS-DOS, Borland C: - -Be sure to convert all the source files to DOS text format (CR/LF newlines). -Although Borland C will often work OK with unmodified Unix (LF newlines) -source files, sometimes it will give bogus compile errors. -"Illegal character '#'" is the most common such error. (This is true with -Borland C 3.1, but perhaps is fixed in newer releases.) - -If you want one-file command line style, just undefine TWO_FILE_COMMANDLINE. -jconfig.bcc already includes #define USE_SETMODE to make this work. -(fdopen does not work correctly.) - - -MS-DOS, Microsoft C: - -makefile.mc6 works with Microsoft C, DOS Visual C++, etc. It should only -be used if you want to build a 16-bit (small or medium memory model) program. - -If you want one-file command line style, just undefine TWO_FILE_COMMANDLINE. -jconfig.mc6 already includes #define USE_SETMODE to make this work. -(fdopen does not work correctly.) - -Note that this makefile assumes that the working copy of itself is called -"makefile". If you want to call it something else, say "makefile.mak", -be sure to adjust the dependency line that reads "$(RFILE) : makefile". -Otherwise the make will fail because it doesn't know how to create "makefile". -Worse, some releases of Microsoft's make utilities give an incorrect error -message in this situation. - -Old versions of MS C fail with an "out of macro expansion space" error -because they can't cope with the macro TRACEMS8 (defined in jerror.h). -If this happens to you, the easiest solution is to change TRACEMS8 to -expand to nothing. You'll lose the ability to dump out JPEG coefficient -tables with djpeg -debug -debug, but at least you can compile. - -Original MS C 6.0 is very buggy; it compiles incorrect code unless you turn -off optimization entirely (remove -O from CFLAGS). 6.00A is better, but it -still generates bad code if you enable loop optimizations (-Ol or -Ox). - -MS C 8.0 crashes when compiling jquant1.c with optimization switch /Oo ... -which is on by default. To work around this bug, compile that one file -with /Oo-. - - -Microsoft Windows (all versions), generic comments: - -Some Windows system include files define typedef boolean as "unsigned char". -The IJG code also defines typedef boolean, but we make it "int" by default. -This doesn't affect the IJG programs because we don't import those Windows -include files. But if you use the JPEG library in your own program, and some -of your program's files import one definition of boolean while some import the -other, you can get all sorts of mysterious problems. A good preventive step -is to make the IJG library use "unsigned char" for boolean. To do that, -add something like this to your jconfig.h file: - /* Define "boolean" as unsigned char, not int, per Windows custom */ - #ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ - typedef unsigned char boolean; - #endif - #define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ -(This is already in jconfig.vc, by the way.) - -windef.h contains the declarations - #define far - #define FAR far -Since jmorecfg.h tries to define FAR as empty, you may get a compiler -warning if you include both jpeglib.h and windef.h (which windows.h -includes). To suppress the warning, you can put "#ifndef FAR"/"#endif" -around the line "#define FAR" in jmorecfg.h. - -When using the library in a Windows application, you will almost certainly -want to modify or replace the error handler module jerror.c, since our -default error handler does a couple of inappropriate things: - 1. it tries to write error and warning messages on stderr; - 2. in event of a fatal error, it exits by calling exit(). - -A simple stopgap solution for problem 1 is to replace the line - fprintf(stderr, "%s\n", buffer); -(in output_message in jerror.c) with - MessageBox(GetActiveWindow(),buffer,"JPEG Error",MB_OK|MB_ICONERROR); -It's highly recommended that you at least do that much, since otherwise -error messages will disappear into nowhere. (Beginning with IJG v6b, this -code is already present in jerror.c; just define USE_WINDOWS_MESSAGEBOX in -jconfig.h to enable it.) - -The proper solution for problem 2 is to return control to your calling -application after a library error. This can be done with the setjmp/longjmp -technique discussed in libjpeg.doc and illustrated in example.c. (NOTE: -some older Windows C compilers provide versions of setjmp/longjmp that -don't actually work under Windows. You may need to use the Windows system -functions Catch and Throw instead.) - -The recommended memory manager under Windows is jmemnobs.c; in other words, -let Windows do any virtual memory management needed. You should NOT use -jmemdos.c nor jmemdosa.asm under Windows. - -For Windows 3.1, we recommend compiling in medium or large memory model; -for newer Windows versions, use a 32-bit flat memory model. (See the MS-DOS -sections above for more info about memory models.) In the 16-bit memory -models only, you'll need to put - #define MAX_ALLOC_CHUNK 65520L /* Maximum request to malloc() */ -into jconfig.h to limit allocation chunks to 64Kb. (Without that, you'd -have to use huge memory model, which slows things down unnecessarily.) -jmemnobs.c works without modification in large or flat memory models, but to -use medium model, you need to modify its jpeg_get_large and jpeg_free_large -routines to allocate far memory. In any case, you might like to replace -its calls to malloc and free with direct calls on Windows memory allocation -functions. - -You may also want to modify jdatasrc.c and jdatadst.c to use Windows file -operations rather than fread/fwrite. This is only necessary if your C -compiler doesn't provide a competent implementation of C stdio functions. - -You might want to tweak the RGB_xxx macros in jmorecfg.h so that the library -will accept or deliver color pixels in BGR sample order, not RGB; BGR order -is usually more convenient under Windows. Note that this change will break -the sample applications cjpeg/djpeg, but the library itself works fine. - - -Many people want to convert the IJG library into a DLL. This is reasonably -straightforward, but watch out for the following: - - 1. Don't try to compile as a DLL in small or medium memory model; use -large model, or even better, 32-bit flat model. Many places in the IJG code -assume the address of a local variable is an ordinary (not FAR) pointer; -that isn't true in a medium-model DLL. - - 2. Microsoft C cannot pass file pointers between applications and DLLs. -(See Microsoft Knowledge Base, PSS ID Number Q50336.) So jdatasrc.c and -jdatadst.c don't work if you open a file in your application and then pass -the pointer to the DLL. One workaround is to make jdatasrc.c/jdatadst.c -part of your main application rather than part of the DLL. - - 3. You'll probably need to modify the macros GLOBAL() and EXTERN() to -attach suitable linkage keywords to the exported routine names. Similarly, -you'll want to modify METHODDEF() and JMETHOD() to ensure function pointers -are declared in a way that lets application routines be called back through -the function pointers. These macros are in jmorecfg.h. Typical definitions -for a 16-bit DLL are: - #define GLOBAL(type) type _far _pascal _loadds _export - #define EXTERN(type) extern type _far _pascal _loadds - #define METHODDEF(type) static type _far _pascal - #define JMETHOD(type,methodname,arglist) \ - type (_far _pascal *methodname) arglist -For a 32-bit DLL you may want something like - #define GLOBAL(type) __declspec(dllexport) type - #define EXTERN(type) extern __declspec(dllexport) type -Although not all the GLOBAL routines are actually intended to be called by -the application, the performance cost of making them all DLL entry points is -negligible. - -The unmodified IJG library presents a very C-specific application interface, -so the resulting DLL is only usable from C or C++ applications. There has -been some talk of writing wrapper code that would present a simpler interface -usable from other languages, such as Visual Basic. This is on our to-do list -but hasn't been very high priority --- any volunteers out there? - - -Microsoft Windows, Borland C: - -The provided jconfig.bcc should work OK in a 32-bit Windows environment, -but you'll need to tweak it in a 16-bit environment (you'd need to define -NEED_FAR_POINTERS and MAX_ALLOC_CHUNK). Beware that makefile.bcc will need -alteration if you want to use it for Windows --- in particular, you should -use jmemnobs.c not jmemdos.c under Windows. - -Borland C++ 4.5 fails with an internal compiler error when trying to compile -jdmerge.c in 32-bit mode. If enough people complain, perhaps Borland will fix -it. In the meantime, the simplest known workaround is to add a redundant -definition of the variable range_limit in h2v1_merged_upsample(), at the head -of the block that handles odd image width (about line 268 in v6 jdmerge.c): - /* If image width is odd, do the last output column separately */ - if (cinfo->output_width & 1) { - register JSAMPLE * range_limit = cinfo->sample_range_limit; /* ADD THIS */ - cb = GETJSAMPLE(*inptr1); -Pretty bizarre, especially since the very similar routine h2v2_merged_upsample -doesn't trigger the bug. -Recent reports suggest that this bug does not occur with "bcc32a" (the -Pentium-optimized version of the compiler). - -Another report from a user of Borland C 4.5 was that incorrect code (leading -to a color shift in processed images) was produced if any of the following -optimization switch combinations were used: - -Ot -Og - -Ot -Op - -Ot -Om -So try backing off on optimization if you see such a problem. (Are there -several different releases all numbered "4.5"??) - - -Microsoft Windows, Microsoft Visual C++: - -jconfig.vc should work OK with any Microsoft compiler for a 32-bit memory -model. makefile.vc is intended for command-line use. (If you are using -the Developer Studio environment, you may prefer the DevStudio project -files; see below.) - -Some users feel that it's easier to call the library from C++ code if you -force VC++ to treat the library as C++ code, which you can do by renaming -all the *.c files to *.cpp (and adjusting the makefile to match). This -avoids the need to put extern "C" { ... } around #include "jpeglib.h" in -your C++ application. - - -Microsoft Windows, Microsoft Developer Studio: - -We include makefiles that should work as project files in DevStudio 4.2 or -later. There is a library makefile that builds the IJG library as a static -Win32 library, and an application makefile that builds the sample applications -as Win32 console applications. (Even if you only want the library, we -recommend building the applications so that you can run the self-test.) - -To use: -1. Copy jconfig.vc to jconfig.h, makelib.ds to jpeg.mak, and - makeapps.ds to apps.mak. (Note that the renaming is critical!) -2. Click on the .mak files to construct project workspaces. - (If you are using DevStudio more recent than 4.2, you'll probably - get a message saying that the makefiles are being updated.) -3. Build the library project, then the applications project. -4. Move the application .exe files from `app`\Release to an - appropriate location on your path. -5. To perform the self-test, execute the command line - NMAKE /f makefile.vc test - - -OS/2, Borland C++: - -Watch out for optimization bugs in older Borland compilers; you may need -to back off the optimization switch settings. See the comments in -makefile.bcc. - - -SGI: - -On some SGI systems, you may need to set "AR2= ar -ts" in the Makefile. -If you are using configure, you can do this by saying - ./configure RANLIB='ar -ts' -This change is not needed on all SGIs. Use it only if the make fails at the -stage of linking the completed programs. - -On the MIPS R4000 architecture (Indy, etc.), the compiler option "-mips2" -reportedly speeds up the float DCT method substantially, enough to make it -faster than the default int method (but still slower than the fast int -method). If you use -mips2, you may want to alter the default DCT method to -be float. To do this, put "#define JDCT_DEFAULT JDCT_FLOAT" in jconfig.h. - - -VMS: - -On an Alpha/VMS system with MMS, be sure to use the "/Marco=Alpha=1" -qualifier with MMS when building the JPEG package. - -VAX/VMS v5.5-1 may have problems with the test step of the build procedure -reporting differences when it compares the original and test images. If the -error points to the last block of the files, it is most likely bogus and may -be safely ignored. It seems to be because the files are Stream_LF and -Backup/Compare has difficulty with the (presumably) null padded files. -This problem was not observed on VAX/VMS v6.1 or AXP/VMS v6.1. diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jcapimin.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jcapimin.c deleted file mode 100644 index 493af5c30..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jcapimin.c +++ /dev/null @@ -1,280 +0,0 @@ -/* - * jcapimin.c - * - * Copyright (C) 1994-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains application interface code for the compression half - * of the JPEG library. These are the "minimum" API routines that may be - * needed in either the normal full-compression case or the transcoding-only - * case. - * - * Most of the routines intended to be called directly by an application - * are in this file or in jcapistd.c. But also see jcparam.c for - * parameter-setup helper routines, jcomapi.c for routines shared by - * compression and decompression, and jctrans.c for the transcoding case. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * Initialization of a JPEG compression object. - * The error manager must already be set up (in case memory manager fails). - */ - -GLOBAL(void) -jpeg_CreateCompress (j_compress_ptr cinfo, int version, size_t structsize) -{ - int i; - - /* Guard against version mismatches between library and caller. */ - cinfo->mem = NULL; /* so jpeg_destroy knows mem mgr not called */ - if (version != JPEG_LIB_VERSION) - ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version); - if (structsize != SIZEOF(struct jpeg_compress_struct)) - ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE, - (int) SIZEOF(struct jpeg_compress_struct), (int) structsize); - - /* For debugging purposes, we zero the whole master structure. - * But the application has already set the err pointer, and may have set - * client_data, so we have to save and restore those fields. - * Note: if application hasn't set client_data, tools like Purify may - * complain here. - */ - { - struct jpeg_error_mgr * err = cinfo->err; - void * client_data = cinfo->client_data; /* ignore Purify complaint here */ - MEMZERO(cinfo, SIZEOF(struct jpeg_compress_struct)); - cinfo->err = err; - cinfo->client_data = client_data; - } - cinfo->is_decompressor = FALSE; - - /* Initialize a memory manager instance for this object */ - jinit_memory_mgr((j_common_ptr) cinfo); - - /* Zero out pointers to permanent structures. */ - cinfo->progress = NULL; - cinfo->dest = NULL; - - cinfo->comp_info = NULL; - - for (i = 0; i < NUM_QUANT_TBLS; i++) - cinfo->quant_tbl_ptrs[i] = NULL; - - for (i = 0; i < NUM_HUFF_TBLS; i++) { - cinfo->dc_huff_tbl_ptrs[i] = NULL; - cinfo->ac_huff_tbl_ptrs[i] = NULL; - } - - cinfo->script_space = NULL; - - cinfo->input_gamma = 1.0; /* in case application forgets */ - - /* OK, I'm ready */ - cinfo->global_state = CSTATE_START; -} - - -/* - * Destruction of a JPEG compression object - */ - -GLOBAL(void) -jpeg_destroy_compress (j_compress_ptr cinfo) -{ - jpeg_destroy((j_common_ptr) cinfo); /* use common routine */ -} - - -/* - * Abort processing of a JPEG compression operation, - * but don't destroy the object itself. - */ - -GLOBAL(void) -jpeg_abort_compress (j_compress_ptr cinfo) -{ - jpeg_abort((j_common_ptr) cinfo); /* use common routine */ -} - - -/* - * Forcibly suppress or un-suppress all quantization and Huffman tables. - * Marks all currently defined tables as already written (if suppress) - * or not written (if !suppress). This will control whether they get emitted - * by a subsequent jpeg_start_compress call. - * - * This routine is exported for use by applications that want to produce - * abbreviated JPEG datastreams. It logically belongs in jcparam.c, but - * since it is called by jpeg_start_compress, we put it here --- otherwise - * jcparam.o would be linked whether the application used it or not. - */ - -GLOBAL(void) -jpeg_suppress_tables (j_compress_ptr cinfo, boolean suppress) -{ - int i; - JQUANT_TBL * qtbl; - JHUFF_TBL * htbl; - - for (i = 0; i < NUM_QUANT_TBLS; i++) { - if ((qtbl = cinfo->quant_tbl_ptrs[i]) != NULL) - qtbl->sent_table = suppress; - } - - for (i = 0; i < NUM_HUFF_TBLS; i++) { - if ((htbl = cinfo->dc_huff_tbl_ptrs[i]) != NULL) - htbl->sent_table = suppress; - if ((htbl = cinfo->ac_huff_tbl_ptrs[i]) != NULL) - htbl->sent_table = suppress; - } -} - - -/* - * Finish JPEG compression. - * - * If a multipass operating mode was selected, this may do a great deal of - * work including most of the actual output. - */ - -GLOBAL(void) -jpeg_finish_compress (j_compress_ptr cinfo) -{ - JDIMENSION iMCU_row; - - if (cinfo->global_state == CSTATE_SCANNING || - cinfo->global_state == CSTATE_RAW_OK) { - /* Terminate first pass */ - if (cinfo->next_scanline < cinfo->image_height) - ERREXIT(cinfo, JERR_TOO_LITTLE_DATA); - (*cinfo->master->finish_pass) (cinfo); - } else if (cinfo->global_state != CSTATE_WRCOEFS) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - /* Perform any remaining passes */ - while (! cinfo->master->is_last_pass) { - (*cinfo->master->prepare_for_pass) (cinfo); - for (iMCU_row = 0; iMCU_row < cinfo->total_iMCU_rows; iMCU_row++) { - if (cinfo->progress != NULL) { - cinfo->progress->pass_counter = (long) iMCU_row; - cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows; - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - } - /* We bypass the main controller and invoke coef controller directly; - * all work is being done from the coefficient buffer. - */ - if (! (*cinfo->coef->compress_data) (cinfo, (JSAMPIMAGE) NULL)) - ERREXIT(cinfo, JERR_CANT_SUSPEND); - } - (*cinfo->master->finish_pass) (cinfo); - } - /* Write EOI, do final cleanup */ - (*cinfo->marker->write_file_trailer) (cinfo); - (*cinfo->dest->term_destination) (cinfo); - /* We can use jpeg_abort to release memory and reset global_state */ - jpeg_abort((j_common_ptr) cinfo); -} - - -/* - * Write a special marker. - * This is only recommended for writing COM or APPn markers. - * Must be called after jpeg_start_compress() and before - * first call to jpeg_write_scanlines() or jpeg_write_raw_data(). - */ - -GLOBAL(void) -jpeg_write_marker (j_compress_ptr cinfo, int marker, - const JOCTET *dataptr, unsigned int datalen) -{ - JMETHOD(void, write_marker_byte, (j_compress_ptr info, int val)); - - if (cinfo->next_scanline != 0 || - (cinfo->global_state != CSTATE_SCANNING && - cinfo->global_state != CSTATE_RAW_OK && - cinfo->global_state != CSTATE_WRCOEFS)) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - (*cinfo->marker->write_marker_header) (cinfo, marker, datalen); - write_marker_byte = cinfo->marker->write_marker_byte; /* copy for speed */ - while (datalen--) { - (*write_marker_byte) (cinfo, *dataptr); - dataptr++; - } -} - -/* Same, but piecemeal. */ - -GLOBAL(void) -jpeg_write_m_header (j_compress_ptr cinfo, int marker, unsigned int datalen) -{ - if (cinfo->next_scanline != 0 || - (cinfo->global_state != CSTATE_SCANNING && - cinfo->global_state != CSTATE_RAW_OK && - cinfo->global_state != CSTATE_WRCOEFS)) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - (*cinfo->marker->write_marker_header) (cinfo, marker, datalen); -} - -GLOBAL(void) -jpeg_write_m_byte (j_compress_ptr cinfo, int val) -{ - (*cinfo->marker->write_marker_byte) (cinfo, val); -} - - -/* - * Alternate compression function: just write an abbreviated table file. - * Before calling this, all parameters and a data destination must be set up. - * - * To produce a pair of files containing abbreviated tables and abbreviated - * image data, one would proceed as follows: - * - * initialize JPEG object - * set JPEG parameters - * set destination to table file - * jpeg_write_tables(cinfo); - * set destination to image file - * jpeg_start_compress(cinfo, FALSE); - * write data... - * jpeg_finish_compress(cinfo); - * - * jpeg_write_tables has the side effect of marking all tables written - * (same as jpeg_suppress_tables(..., TRUE)). Thus a subsequent start_compress - * will not re-emit the tables unless it is passed write_all_tables=TRUE. - */ - -GLOBAL(void) -jpeg_write_tables (j_compress_ptr cinfo) -{ - if (cinfo->global_state != CSTATE_START) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - /* (Re)initialize error mgr and destination modules */ - (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); - (*cinfo->dest->init_destination) (cinfo); - /* Initialize the marker writer ... bit of a crock to do it here. */ - jinit_marker_writer(cinfo); - /* Write them tables! */ - (*cinfo->marker->write_tables_only) (cinfo); - /* And clean up. */ - (*cinfo->dest->term_destination) (cinfo); - /* - * In library releases up through v6a, we called jpeg_abort() here to free - * any working memory allocated by the destination manager and marker - * writer. Some applications had a problem with that: they allocated space - * of their own from the library memory manager, and didn't want it to go - * away during write_tables. So now we do nothing. This will cause a - * memory leak if an app calls write_tables repeatedly without doing a full - * compression cycle or otherwise resetting the JPEG object. However, that - * seems less bad than unexpectedly freeing memory in the normal case. - * An app that prefers the old behavior can call jpeg_abort for itself after - * each call to jpeg_write_tables(). - */ -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jcapistd.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jcapistd.c deleted file mode 100644 index fed66caf1..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jcapistd.c +++ /dev/null @@ -1,161 +0,0 @@ -/* - * jcapistd.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains application interface code for the compression half - * of the JPEG library. These are the "standard" API routines that are - * used in the normal full-compression case. They are not used by a - * transcoding-only application. Note that if an application links in - * jpeg_start_compress, it will end up linking in the entire compressor. - * We thus must separate this file from jcapimin.c to avoid linking the - * whole compression library into a transcoder. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * Compression initialization. - * Before calling this, all parameters and a data destination must be set up. - * - * We require a write_all_tables parameter as a failsafe check when writing - * multiple datastreams from the same compression object. Since prior runs - * will have left all the tables marked sent_table=TRUE, a subsequent run - * would emit an abbreviated stream (no tables) by default. This may be what - * is wanted, but for safety's sake it should not be the default behavior: - * programmers should have to make a deliberate choice to emit abbreviated - * images. Therefore the documentation and examples should encourage people - * to pass write_all_tables=TRUE; then it will take active thought to do the - * wrong thing. - */ - -GLOBAL(void) -jpeg_start_compress (j_compress_ptr cinfo, boolean write_all_tables) -{ - if (cinfo->global_state != CSTATE_START) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - if (write_all_tables) - jpeg_suppress_tables(cinfo, FALSE); /* mark all tables to be written */ - - /* (Re)initialize error mgr and destination modules */ - (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); - (*cinfo->dest->init_destination) (cinfo); - /* Perform master selection of active modules */ - jinit_compress_master(cinfo); - /* Set up for the first pass */ - (*cinfo->master->prepare_for_pass) (cinfo); - /* Ready for application to drive first pass through jpeg_write_scanlines - * or jpeg_write_raw_data. - */ - cinfo->next_scanline = 0; - cinfo->global_state = (cinfo->raw_data_in ? CSTATE_RAW_OK : CSTATE_SCANNING); -} - - -/* - * Write some scanlines of data to the JPEG compressor. - * - * The return value will be the number of lines actually written. - * This should be less than the supplied num_lines only in case that - * the data destination module has requested suspension of the compressor, - * or if more than image_height scanlines are passed in. - * - * Note: we warn about excess calls to jpeg_write_scanlines() since - * this likely signals an application programmer error. However, - * excess scanlines passed in the last valid call are *silently* ignored, - * so that the application need not adjust num_lines for end-of-image - * when using a multiple-scanline buffer. - */ - -GLOBAL(JDIMENSION) -jpeg_write_scanlines (j_compress_ptr cinfo, JSAMPARRAY scanlines, - JDIMENSION num_lines) -{ - JDIMENSION row_ctr, rows_left; - - if (cinfo->global_state != CSTATE_SCANNING) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - if (cinfo->next_scanline >= cinfo->image_height) - WARNMS(cinfo, JWRN_TOO_MUCH_DATA); - - /* Call progress monitor hook if present */ - if (cinfo->progress != NULL) { - cinfo->progress->pass_counter = (long) cinfo->next_scanline; - cinfo->progress->pass_limit = (long) cinfo->image_height; - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - } - - /* Give master control module another chance if this is first call to - * jpeg_write_scanlines. This lets output of the frame/scan headers be - * delayed so that application can write COM, etc, markers between - * jpeg_start_compress and jpeg_write_scanlines. - */ - if (cinfo->master->call_pass_startup) - (*cinfo->master->pass_startup) (cinfo); - - /* Ignore any extra scanlines at bottom of image. */ - rows_left = cinfo->image_height - cinfo->next_scanline; - if (num_lines > rows_left) - num_lines = rows_left; - - row_ctr = 0; - (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, num_lines); - cinfo->next_scanline += row_ctr; - return row_ctr; -} - - -/* - * Alternate entry point to write raw data. - * Processes exactly one iMCU row per call, unless suspended. - */ - -GLOBAL(JDIMENSION) -jpeg_write_raw_data (j_compress_ptr cinfo, JSAMPIMAGE data, - JDIMENSION num_lines) -{ - JDIMENSION lines_per_iMCU_row; - - if (cinfo->global_state != CSTATE_RAW_OK) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - if (cinfo->next_scanline >= cinfo->image_height) { - WARNMS(cinfo, JWRN_TOO_MUCH_DATA); - return 0; - } - - /* Call progress monitor hook if present */ - if (cinfo->progress != NULL) { - cinfo->progress->pass_counter = (long) cinfo->next_scanline; - cinfo->progress->pass_limit = (long) cinfo->image_height; - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - } - - /* Give master control module another chance if this is first call to - * jpeg_write_raw_data. This lets output of the frame/scan headers be - * delayed so that application can write COM, etc, markers between - * jpeg_start_compress and jpeg_write_raw_data. - */ - if (cinfo->master->call_pass_startup) - (*cinfo->master->pass_startup) (cinfo); - - /* Verify that at least one iMCU row has been passed. */ - lines_per_iMCU_row = cinfo->max_v_samp_factor * DCTSIZE; - if (num_lines < lines_per_iMCU_row) - ERREXIT(cinfo, JERR_BUFFER_SIZE); - - /* Directly compress the row. */ - if (! (*cinfo->coef->compress_data) (cinfo, data)) { - /* If compressor did not consume the whole row, suspend processing. */ - return 0; - } - - /* OK, we processed one iMCU row. */ - cinfo->next_scanline += lines_per_iMCU_row; - return lines_per_iMCU_row; -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jccoefct.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jccoefct.c deleted file mode 100644 index c713b858a..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jccoefct.c +++ /dev/null @@ -1,449 +0,0 @@ -/* - * jccoefct.c - * - * Copyright (C) 1994-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the coefficient buffer controller for compression. - * This controller is the top level of the JPEG compressor proper. - * The coefficient buffer lies between forward-DCT and entropy encoding steps. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* We use a full-image coefficient buffer when doing Huffman optimization, - * and also for writing multiple-scan JPEG files. In all cases, the DCT - * step is run during the first pass, and subsequent passes need only read - * the buffered coefficients. - */ -#ifdef ENTROPY_OPT_SUPPORTED -#define FULL_COEF_BUFFER_SUPPORTED -#else -#ifdef C_MULTISCAN_FILES_SUPPORTED -#define FULL_COEF_BUFFER_SUPPORTED -#endif -#endif - - -/* Private buffer controller object */ - -typedef struct { - struct jpeg_c_coef_controller pub; /* public fields */ - - JDIMENSION iMCU_row_num; /* iMCU row # within image */ - JDIMENSION mcu_ctr; /* counts MCUs processed in current row */ - int MCU_vert_offset; /* counts MCU rows within iMCU row */ - int MCU_rows_per_iMCU_row; /* number of such rows needed */ - - /* For single-pass compression, it's sufficient to buffer just one MCU - * (although this may prove a bit slow in practice). We allocate a - * workspace of C_MAX_BLOCKS_IN_MCU coefficient blocks, and reuse it for each - * MCU constructed and sent. (On 80x86, the workspace is FAR even though - * it's not really very big; this is to keep the module interfaces unchanged - * when a large coefficient buffer is necessary.) - * In multi-pass modes, this array points to the current MCU's blocks - * within the virtual arrays. - */ - JBLOCKROW MCU_buffer[C_MAX_BLOCKS_IN_MCU]; - - /* In multi-pass modes, we need a virtual block array for each component. */ - jvirt_barray_ptr whole_image[MAX_COMPONENTS]; -} my_coef_controller; - -typedef my_coef_controller * my_coef_ptr; - - -/* Forward declarations */ -METHODDEF(boolean) compress_data - JPP((j_compress_ptr cinfo, JSAMPIMAGE input_buf)); -#ifdef FULL_COEF_BUFFER_SUPPORTED -METHODDEF(boolean) compress_first_pass - JPP((j_compress_ptr cinfo, JSAMPIMAGE input_buf)); -METHODDEF(boolean) compress_output - JPP((j_compress_ptr cinfo, JSAMPIMAGE input_buf)); -#endif - - -LOCAL(void) -start_iMCU_row (j_compress_ptr cinfo) -/* Reset within-iMCU-row counters for a new row */ -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - - /* In an interleaved scan, an MCU row is the same as an iMCU row. - * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows. - * But at the bottom of the image, process only what's left. - */ - if (cinfo->comps_in_scan > 1) { - coef->MCU_rows_per_iMCU_row = 1; - } else { - if (coef->iMCU_row_num < (cinfo->total_iMCU_rows-1)) - coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; - else - coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; - } - - coef->mcu_ctr = 0; - coef->MCU_vert_offset = 0; -} - - -/* - * Initialize for a processing pass. - */ - -METHODDEF(void) -start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - - coef->iMCU_row_num = 0; - start_iMCU_row(cinfo); - - switch (pass_mode) { - case JBUF_PASS_THRU: - if (coef->whole_image[0] != NULL) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - coef->pub.compress_data = compress_data; - break; -#ifdef FULL_COEF_BUFFER_SUPPORTED - case JBUF_SAVE_AND_PASS: - if (coef->whole_image[0] == NULL) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - coef->pub.compress_data = compress_first_pass; - break; - case JBUF_CRANK_DEST: - if (coef->whole_image[0] == NULL) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - coef->pub.compress_data = compress_output; - break; -#endif - default: - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - break; - } -} - - -/* - * Process some data in the single-pass case. - * We process the equivalent of one fully interleaved MCU row ("iMCU" row) - * per call, ie, v_samp_factor block rows for each component in the image. - * Returns TRUE if the iMCU row is completed, FALSE if suspended. - * - * NB: input_buf contains a plane for each component in image, - * which we index according to the component's SOF position. - */ - -METHODDEF(boolean) -compress_data (j_compress_ptr cinfo, JSAMPIMAGE input_buf) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION MCU_col_num; /* index of current MCU within row */ - JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1; - JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; - int blkn, bi, ci, yindex, yoffset, blockcnt; - JDIMENSION ypos, xpos; - jpeg_component_info *compptr; - - /* Loop to write as much as one whole iMCU row */ - for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; - yoffset++) { - for (MCU_col_num = coef->mcu_ctr; MCU_col_num <= last_MCU_col; - MCU_col_num++) { - /* Determine where data comes from in input_buf and do the DCT thing. - * Each call on forward_DCT processes a horizontal row of DCT blocks - * as wide as an MCU; we rely on having allocated the MCU_buffer[] blocks - * sequentially. Dummy blocks at the right or bottom edge are filled in - * specially. The data in them does not matter for image reconstruction, - * so we fill them with values that will encode to the smallest amount of - * data, viz: all zeroes in the AC entries, DC entries equal to previous - * block's DC value. (Thanks to Thomas Kinsman for this idea.) - */ - blkn = 0; - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width - : compptr->last_col_width; - xpos = MCU_col_num * compptr->MCU_sample_width; - ypos = yoffset * DCTSIZE; /* ypos == (yoffset+yindex) * DCTSIZE */ - for (yindex = 0; yindex < compptr->MCU_height; yindex++) { - if (coef->iMCU_row_num < last_iMCU_row || - yoffset+yindex < compptr->last_row_height) { - (*cinfo->fdct->forward_DCT) (cinfo, compptr, - input_buf[compptr->component_index], - coef->MCU_buffer[blkn], - ypos, xpos, (JDIMENSION) blockcnt); - if (blockcnt < compptr->MCU_width) { - /* Create some dummy blocks at the right edge of the image. */ - jzero_far((void FAR *) coef->MCU_buffer[blkn + blockcnt], - (compptr->MCU_width - blockcnt) * SIZEOF(JBLOCK)); - for (bi = blockcnt; bi < compptr->MCU_width; bi++) { - coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn+bi-1][0][0]; - } - } - } else { - /* Create a row of dummy blocks at the bottom of the image. */ - jzero_far((void FAR *) coef->MCU_buffer[blkn], - compptr->MCU_width * SIZEOF(JBLOCK)); - for (bi = 0; bi < compptr->MCU_width; bi++) { - coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn-1][0][0]; - } - } - blkn += compptr->MCU_width; - ypos += DCTSIZE; - } - } - /* Try to write the MCU. In event of a suspension failure, we will - * re-DCT the MCU on restart (a bit inefficient, could be fixed...) - */ - if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) { - /* Suspension forced; update state counters and exit */ - coef->MCU_vert_offset = yoffset; - coef->mcu_ctr = MCU_col_num; - return FALSE; - } - } - /* Completed an MCU row, but perhaps not an iMCU row */ - coef->mcu_ctr = 0; - } - /* Completed the iMCU row, advance counters for next one */ - coef->iMCU_row_num++; - start_iMCU_row(cinfo); - return TRUE; -} - - -#ifdef FULL_COEF_BUFFER_SUPPORTED - -/* - * Process some data in the first pass of a multi-pass case. - * We process the equivalent of one fully interleaved MCU row ("iMCU" row) - * per call, ie, v_samp_factor block rows for each component in the image. - * This amount of data is read from the source buffer, DCT'd and quantized, - * and saved into the virtual arrays. We also generate suitable dummy blocks - * as needed at the right and lower edges. (The dummy blocks are constructed - * in the virtual arrays, which have been padded appropriately.) This makes - * it possible for subsequent passes not to worry about real vs. dummy blocks. - * - * We must also emit the data to the entropy encoder. This is conveniently - * done by calling compress_output() after we've loaded the current strip - * of the virtual arrays. - * - * NB: input_buf contains a plane for each component in image. All - * components are DCT'd and loaded into the virtual arrays in this pass. - * However, it may be that only a subset of the components are emitted to - * the entropy encoder during this first pass; be careful about looking - * at the scan-dependent variables (MCU dimensions, etc). - */ - -METHODDEF(boolean) -compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; - JDIMENSION blocks_across, MCUs_across, MCUindex; - int bi, ci, h_samp_factor, block_row, block_rows, ndummy; - JCOEF lastDC; - jpeg_component_info *compptr; - JBLOCKARRAY buffer; - JBLOCKROW thisblockrow, lastblockrow; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Align the virtual buffer for this component. */ - buffer = (*cinfo->mem->access_virt_barray) - ((j_common_ptr) cinfo, coef->whole_image[ci], - coef->iMCU_row_num * compptr->v_samp_factor, - (JDIMENSION) compptr->v_samp_factor, TRUE); - /* Count non-dummy DCT block rows in this iMCU row. */ - if (coef->iMCU_row_num < last_iMCU_row) - block_rows = compptr->v_samp_factor; - else { - /* NB: can't use last_row_height here, since may not be set! */ - block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor); - if (block_rows == 0) block_rows = compptr->v_samp_factor; - } - blocks_across = compptr->width_in_blocks; - h_samp_factor = compptr->h_samp_factor; - /* Count number of dummy blocks to be added at the right margin. */ - ndummy = (int) (blocks_across % h_samp_factor); - if (ndummy > 0) - ndummy = h_samp_factor - ndummy; - /* Perform DCT for all non-dummy blocks in this iMCU row. Each call - * on forward_DCT processes a complete horizontal row of DCT blocks. - */ - for (block_row = 0; block_row < block_rows; block_row++) { - thisblockrow = buffer[block_row]; - (*cinfo->fdct->forward_DCT) (cinfo, compptr, - input_buf[ci], thisblockrow, - (JDIMENSION) (block_row * DCTSIZE), - (JDIMENSION) 0, blocks_across); - if (ndummy > 0) { - /* Create dummy blocks at the right edge of the image. */ - thisblockrow += blocks_across; /* => first dummy block */ - jzero_far((void FAR *) thisblockrow, ndummy * SIZEOF(JBLOCK)); - lastDC = thisblockrow[-1][0]; - for (bi = 0; bi < ndummy; bi++) { - thisblockrow[bi][0] = lastDC; - } - } - } - /* If at end of image, create dummy block rows as needed. - * The tricky part here is that within each MCU, we want the DC values - * of the dummy blocks to match the last real block's DC value. - * This squeezes a few more bytes out of the resulting file... - */ - if (coef->iMCU_row_num == last_iMCU_row) { - blocks_across += ndummy; /* include lower right corner */ - MCUs_across = blocks_across / h_samp_factor; - for (block_row = block_rows; block_row < compptr->v_samp_factor; - block_row++) { - thisblockrow = buffer[block_row]; - lastblockrow = buffer[block_row-1]; - jzero_far((void FAR *) thisblockrow, - (size_t) (blocks_across * SIZEOF(JBLOCK))); - for (MCUindex = 0; MCUindex < MCUs_across; MCUindex++) { - lastDC = lastblockrow[h_samp_factor-1][0]; - for (bi = 0; bi < h_samp_factor; bi++) { - thisblockrow[bi][0] = lastDC; - } - thisblockrow += h_samp_factor; /* advance to next MCU in row */ - lastblockrow += h_samp_factor; - } - } - } - } - /* NB: compress_output will increment iMCU_row_num if successful. - * A suspension return will result in redoing all the work above next time. - */ - - /* Emit data to the entropy encoder, sharing code with subsequent passes */ - return compress_output(cinfo, input_buf); -} - - -/* - * Process some data in subsequent passes of a multi-pass case. - * We process the equivalent of one fully interleaved MCU row ("iMCU" row) - * per call, ie, v_samp_factor block rows for each component in the scan. - * The data is obtained from the virtual arrays and fed to the entropy coder. - * Returns TRUE if the iMCU row is completed, FALSE if suspended. - * - * NB: input_buf is ignored; it is likely to be a NULL pointer. - */ - -METHODDEF(boolean) -compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION MCU_col_num; /* index of current MCU within row */ - int blkn, ci, xindex, yindex, yoffset; - JDIMENSION start_col; - JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN]; - JBLOCKROW buffer_ptr; - jpeg_component_info *compptr; - - /* Align the virtual buffers for the components used in this scan. - * NB: during first pass, this is safe only because the buffers will - * already be aligned properly, so jmemmgr.c won't need to do any I/O. - */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - buffer[ci] = (*cinfo->mem->access_virt_barray) - ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index], - coef->iMCU_row_num * compptr->v_samp_factor, - (JDIMENSION) compptr->v_samp_factor, FALSE); - } - - /* Loop to process one whole iMCU row */ - for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; - yoffset++) { - for (MCU_col_num = coef->mcu_ctr; MCU_col_num < cinfo->MCUs_per_row; - MCU_col_num++) { - /* Construct list of pointers to DCT blocks belonging to this MCU */ - blkn = 0; /* index of current DCT block within MCU */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - start_col = MCU_col_num * compptr->MCU_width; - for (yindex = 0; yindex < compptr->MCU_height; yindex++) { - buffer_ptr = buffer[ci][yindex+yoffset] + start_col; - for (xindex = 0; xindex < compptr->MCU_width; xindex++) { - coef->MCU_buffer[blkn++] = buffer_ptr++; - } - } - } - /* Try to write the MCU. */ - if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) { - /* Suspension forced; update state counters and exit */ - coef->MCU_vert_offset = yoffset; - coef->mcu_ctr = MCU_col_num; - return FALSE; - } - } - /* Completed an MCU row, but perhaps not an iMCU row */ - coef->mcu_ctr = 0; - } - /* Completed the iMCU row, advance counters for next one */ - coef->iMCU_row_num++; - start_iMCU_row(cinfo); - return TRUE; -} - -#endif /* FULL_COEF_BUFFER_SUPPORTED */ - - -/* - * Initialize coefficient buffer controller. - */ - -GLOBAL(void) -jinit_c_coef_controller (j_compress_ptr cinfo, boolean need_full_buffer) -{ - my_coef_ptr coef; - - coef = (my_coef_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_coef_controller)); - cinfo->coef = (struct jpeg_c_coef_controller *) coef; - coef->pub.start_pass = start_pass_coef; - - /* Create the coefficient buffer. */ - if (need_full_buffer) { -#ifdef FULL_COEF_BUFFER_SUPPORTED - /* Allocate a full-image virtual array for each component, */ - /* padded to a multiple of samp_factor DCT blocks in each direction. */ - int ci; - jpeg_component_info *compptr; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - coef->whole_image[ci] = (*cinfo->mem->request_virt_barray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, - (JDIMENSION) jround_up((long) compptr->width_in_blocks, - (long) compptr->h_samp_factor), - (JDIMENSION) jround_up((long) compptr->height_in_blocks, - (long) compptr->v_samp_factor), - (JDIMENSION) compptr->v_samp_factor); - } -#else - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); -#endif - } else { - /* We only need a single-MCU buffer. */ - JBLOCKROW buffer; - int i; - - buffer = (JBLOCKROW) - (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, - C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); - for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) { - coef->MCU_buffer[i] = buffer + i; - } - coef->whole_image[0] = NULL; /* flag for no virtual arrays */ - } -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jccolor.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jccolor.c deleted file mode 100644 index 266372454..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jccolor.c +++ /dev/null @@ -1,459 +0,0 @@ -/* - * jccolor.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains input colorspace conversion routines. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Private subobject */ - -typedef struct { - struct jpeg_color_converter pub; /* public fields */ - - /* Private state for RGB->YCC conversion */ - INT32 * rgb_ycc_tab; /* => table for RGB to YCbCr conversion */ -} my_color_converter; - -typedef my_color_converter * my_cconvert_ptr; - - -/**************** RGB -> YCbCr conversion: most common case **************/ - -/* - * YCbCr is defined per CCIR 601-1, except that Cb and Cr are - * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5. - * The conversion equations to be implemented are therefore - * Y = 0.29900 * R + 0.58700 * G + 0.11400 * B - * Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE - * Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE - * (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.) - * Note: older versions of the IJG code used a zero offset of MAXJSAMPLE/2, - * rather than CENTERJSAMPLE, for Cb and Cr. This gave equal positive and - * negative swings for Cb/Cr, but meant that grayscale values (Cb=Cr=0) - * were not represented exactly. Now we sacrifice exact representation of - * maximum red and maximum blue in order to get exact grayscales. - * - * To avoid floating-point arithmetic, we represent the fractional constants - * as integers scaled up by 2^16 (about 4 digits precision); we have to divide - * the products by 2^16, with appropriate rounding, to get the correct answer. - * - * For even more speed, we avoid doing any multiplications in the inner loop - * by precalculating the constants times R,G,B for all possible values. - * For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table); - * for 12-bit samples it is still acceptable. It's not very reasonable for - * 16-bit samples, but if you want lossless storage you shouldn't be changing - * colorspace anyway. - * The CENTERJSAMPLE offsets and the rounding fudge-factor of 0.5 are included - * in the tables to save adding them separately in the inner loop. - */ - -#define SCALEBITS 16 /* speediest right-shift on some machines */ -#define CBCR_OFFSET ((INT32) CENTERJSAMPLE << SCALEBITS) -#define ONE_HALF ((INT32) 1 << (SCALEBITS-1)) -#define FIX(x) ((INT32) ((x) * (1L<<SCALEBITS) + 0.5)) - -/* We allocate one big table and divide it up into eight parts, instead of - * doing eight alloc_small requests. This lets us use a single table base - * address, which can be held in a register in the inner loops on many - * machines (more than can hold all eight addresses, anyway). - */ - -#define R_Y_OFF 0 /* offset to R => Y section */ -#define G_Y_OFF (1*(MAXJSAMPLE+1)) /* offset to G => Y section */ -#define B_Y_OFF (2*(MAXJSAMPLE+1)) /* etc. */ -#define R_CB_OFF (3*(MAXJSAMPLE+1)) -#define G_CB_OFF (4*(MAXJSAMPLE+1)) -#define B_CB_OFF (5*(MAXJSAMPLE+1)) -#define R_CR_OFF B_CB_OFF /* B=>Cb, R=>Cr are the same */ -#define G_CR_OFF (6*(MAXJSAMPLE+1)) -#define B_CR_OFF (7*(MAXJSAMPLE+1)) -#define TABLE_SIZE (8*(MAXJSAMPLE+1)) - - -/* - * Initialize for RGB->YCC colorspace conversion. - */ - -METHODDEF(void) -rgb_ycc_start (j_compress_ptr cinfo) -{ - my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; - INT32 * rgb_ycc_tab; - INT32 i; - - /* Allocate and fill in the conversion tables. */ - cconvert->rgb_ycc_tab = rgb_ycc_tab = (INT32 *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (TABLE_SIZE * SIZEOF(INT32))); - - for (i = 0; i <= MAXJSAMPLE; i++) { - rgb_ycc_tab[i+R_Y_OFF] = FIX(0.29900) * i; - rgb_ycc_tab[i+G_Y_OFF] = FIX(0.58700) * i; - rgb_ycc_tab[i+B_Y_OFF] = FIX(0.11400) * i + ONE_HALF; - rgb_ycc_tab[i+R_CB_OFF] = (-FIX(0.16874)) * i; - rgb_ycc_tab[i+G_CB_OFF] = (-FIX(0.33126)) * i; - /* We use a rounding fudge-factor of 0.5-epsilon for Cb and Cr. - * This ensures that the maximum output will round to MAXJSAMPLE - * not MAXJSAMPLE+1, and thus that we don't have to range-limit. - */ - rgb_ycc_tab[i+B_CB_OFF] = FIX(0.50000) * i + CBCR_OFFSET + ONE_HALF-1; -/* B=>Cb and R=>Cr tables are the same - rgb_ycc_tab[i+R_CR_OFF] = FIX(0.50000) * i + CBCR_OFFSET + ONE_HALF-1; -*/ - rgb_ycc_tab[i+G_CR_OFF] = (-FIX(0.41869)) * i; - rgb_ycc_tab[i+B_CR_OFF] = (-FIX(0.08131)) * i; - } -} - - -/* - * Convert some rows of samples to the JPEG colorspace. - * - * Note that we change from the application's interleaved-pixel format - * to our internal noninterleaved, one-plane-per-component format. - * The input buffer is therefore three times as wide as the output buffer. - * - * A starting row offset is provided only for the output buffer. The caller - * can easily adjust the passed input_buf value to accommodate any row - * offset required on that side. - */ - -METHODDEF(void) -rgb_ycc_convert (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPIMAGE output_buf, - JDIMENSION output_row, int num_rows) -{ - my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; - register int r, g, b; - register INT32 * ctab = cconvert->rgb_ycc_tab; - register JSAMPROW inptr; - register JSAMPROW outptr0, outptr1, outptr2; - register JDIMENSION col; - JDIMENSION num_cols = cinfo->image_width; - - while (--num_rows >= 0) { - inptr = *input_buf++; - outptr0 = output_buf[0][output_row]; - outptr1 = output_buf[1][output_row]; - outptr2 = output_buf[2][output_row]; - output_row++; - for (col = 0; col < num_cols; col++) { - r = GETJSAMPLE(inptr[RGB_RED]); - g = GETJSAMPLE(inptr[RGB_GREEN]); - b = GETJSAMPLE(inptr[RGB_BLUE]); - inptr += RGB_PIXELSIZE; - /* If the inputs are 0..MAXJSAMPLE, the outputs of these equations - * must be too; we do not need an explicit range-limiting operation. - * Hence the value being shifted is never negative, and we don't - * need the general RIGHT_SHIFT macro. - */ - /* Y */ - outptr0[col] = (JSAMPLE) - ((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF]) - >> SCALEBITS); - /* Cb */ - outptr1[col] = (JSAMPLE) - ((ctab[r+R_CB_OFF] + ctab[g+G_CB_OFF] + ctab[b+B_CB_OFF]) - >> SCALEBITS); - /* Cr */ - outptr2[col] = (JSAMPLE) - ((ctab[r+R_CR_OFF] + ctab[g+G_CR_OFF] + ctab[b+B_CR_OFF]) - >> SCALEBITS); - } - } -} - - -/**************** Cases other than RGB -> YCbCr **************/ - - -/* - * Convert some rows of samples to the JPEG colorspace. - * This version handles RGB->grayscale conversion, which is the same - * as the RGB->Y portion of RGB->YCbCr. - * We assume rgb_ycc_start has been called (we only use the Y tables). - */ - -METHODDEF(void) -rgb_gray_convert (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPIMAGE output_buf, - JDIMENSION output_row, int num_rows) -{ - my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; - register int r, g, b; - register INT32 * ctab = cconvert->rgb_ycc_tab; - register JSAMPROW inptr; - register JSAMPROW outptr; - register JDIMENSION col; - JDIMENSION num_cols = cinfo->image_width; - - while (--num_rows >= 0) { - inptr = *input_buf++; - outptr = output_buf[0][output_row]; - output_row++; - for (col = 0; col < num_cols; col++) { - r = GETJSAMPLE(inptr[RGB_RED]); - g = GETJSAMPLE(inptr[RGB_GREEN]); - b = GETJSAMPLE(inptr[RGB_BLUE]); - inptr += RGB_PIXELSIZE; - /* Y */ - outptr[col] = (JSAMPLE) - ((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF]) - >> SCALEBITS); - } - } -} - - -/* - * Convert some rows of samples to the JPEG colorspace. - * This version handles Adobe-style CMYK->YCCK conversion, - * where we convert R=1-C, G=1-M, and B=1-Y to YCbCr using the same - * conversion as above, while passing K (black) unchanged. - * We assume rgb_ycc_start has been called. - */ - -METHODDEF(void) -cmyk_ycck_convert (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPIMAGE output_buf, - JDIMENSION output_row, int num_rows) -{ - my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; - register int r, g, b; - register INT32 * ctab = cconvert->rgb_ycc_tab; - register JSAMPROW inptr; - register JSAMPROW outptr0, outptr1, outptr2, outptr3; - register JDIMENSION col; - JDIMENSION num_cols = cinfo->image_width; - - while (--num_rows >= 0) { - inptr = *input_buf++; - outptr0 = output_buf[0][output_row]; - outptr1 = output_buf[1][output_row]; - outptr2 = output_buf[2][output_row]; - outptr3 = output_buf[3][output_row]; - output_row++; - for (col = 0; col < num_cols; col++) { - r = MAXJSAMPLE - GETJSAMPLE(inptr[0]); - g = MAXJSAMPLE - GETJSAMPLE(inptr[1]); - b = MAXJSAMPLE - GETJSAMPLE(inptr[2]); - /* K passes through as-is */ - outptr3[col] = inptr[3]; /* don't need GETJSAMPLE here */ - inptr += 4; - /* If the inputs are 0..MAXJSAMPLE, the outputs of these equations - * must be too; we do not need an explicit range-limiting operation. - * Hence the value being shifted is never negative, and we don't - * need the general RIGHT_SHIFT macro. - */ - /* Y */ - outptr0[col] = (JSAMPLE) - ((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF]) - >> SCALEBITS); - /* Cb */ - outptr1[col] = (JSAMPLE) - ((ctab[r+R_CB_OFF] + ctab[g+G_CB_OFF] + ctab[b+B_CB_OFF]) - >> SCALEBITS); - /* Cr */ - outptr2[col] = (JSAMPLE) - ((ctab[r+R_CR_OFF] + ctab[g+G_CR_OFF] + ctab[b+B_CR_OFF]) - >> SCALEBITS); - } - } -} - - -/* - * Convert some rows of samples to the JPEG colorspace. - * This version handles grayscale output with no conversion. - * The source can be either plain grayscale or YCbCr (since Y == gray). - */ - -METHODDEF(void) -grayscale_convert (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPIMAGE output_buf, - JDIMENSION output_row, int num_rows) -{ - register JSAMPROW inptr; - register JSAMPROW outptr; - register JDIMENSION col; - JDIMENSION num_cols = cinfo->image_width; - int instride = cinfo->input_components; - - while (--num_rows >= 0) { - inptr = *input_buf++; - outptr = output_buf[0][output_row]; - output_row++; - for (col = 0; col < num_cols; col++) { - outptr[col] = inptr[0]; /* don't need GETJSAMPLE() here */ - inptr += instride; - } - } -} - - -/* - * Convert some rows of samples to the JPEG colorspace. - * This version handles multi-component colorspaces without conversion. - * We assume input_components == num_components. - */ - -METHODDEF(void) -null_convert (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPIMAGE output_buf, - JDIMENSION output_row, int num_rows) -{ - register JSAMPROW inptr; - register JSAMPROW outptr; - register JDIMENSION col; - register int ci; - int nc = cinfo->num_components; - JDIMENSION num_cols = cinfo->image_width; - - while (--num_rows >= 0) { - /* It seems fastest to make a separate pass for each component. */ - for (ci = 0; ci < nc; ci++) { - inptr = *input_buf; - outptr = output_buf[ci][output_row]; - for (col = 0; col < num_cols; col++) { - outptr[col] = inptr[ci]; /* don't need GETJSAMPLE() here */ - inptr += nc; - } - } - input_buf++; - output_row++; - } -} - - -/* - * Empty method for start_pass. - */ - -METHODDEF(void) -null_method (j_compress_ptr cinfo) -{ - /* no work needed */ -} - - -/* - * Module initialization routine for input colorspace conversion. - */ - -GLOBAL(void) -jinit_color_converter (j_compress_ptr cinfo) -{ - my_cconvert_ptr cconvert; - - cconvert = (my_cconvert_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_color_converter)); - cinfo->cconvert = (struct jpeg_color_converter *) cconvert; - /* set start_pass to null method until we find out differently */ - cconvert->pub.start_pass = null_method; - - /* Make sure input_components agrees with in_color_space */ - switch (cinfo->in_color_space) { - case JCS_GRAYSCALE: - if (cinfo->input_components != 1) - ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); - break; - - case JCS_RGB: -#if RGB_PIXELSIZE != 3 - if (cinfo->input_components != RGB_PIXELSIZE) - ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); - break; -#endif /* else share code with YCbCr */ - - case JCS_YCbCr: - if (cinfo->input_components != 3) - ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); - break; - - case JCS_CMYK: - case JCS_YCCK: - if (cinfo->input_components != 4) - ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); - break; - - default: /* JCS_UNKNOWN can be anything */ - if (cinfo->input_components < 1) - ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); - break; - } - - /* Check num_components, set conversion method based on requested space */ - switch (cinfo->jpeg_color_space) { - case JCS_GRAYSCALE: - if (cinfo->num_components != 1) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - if (cinfo->in_color_space == JCS_GRAYSCALE) - cconvert->pub.color_convert = grayscale_convert; - else if (cinfo->in_color_space == JCS_RGB) { - cconvert->pub.start_pass = rgb_ycc_start; - cconvert->pub.color_convert = rgb_gray_convert; - } else if (cinfo->in_color_space == JCS_YCbCr) - cconvert->pub.color_convert = grayscale_convert; - else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - case JCS_RGB: - if (cinfo->num_components != 3) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - if (cinfo->in_color_space == JCS_RGB && RGB_PIXELSIZE == 3) - cconvert->pub.color_convert = null_convert; - else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - case JCS_YCbCr: - if (cinfo->num_components != 3) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - if (cinfo->in_color_space == JCS_RGB) { - cconvert->pub.start_pass = rgb_ycc_start; - cconvert->pub.color_convert = rgb_ycc_convert; - } else if (cinfo->in_color_space == JCS_YCbCr) - cconvert->pub.color_convert = null_convert; - else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - case JCS_CMYK: - if (cinfo->num_components != 4) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - if (cinfo->in_color_space == JCS_CMYK) - cconvert->pub.color_convert = null_convert; - else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - case JCS_YCCK: - if (cinfo->num_components != 4) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - if (cinfo->in_color_space == JCS_CMYK) { - cconvert->pub.start_pass = rgb_ycc_start; - cconvert->pub.color_convert = cmyk_ycck_convert; - } else if (cinfo->in_color_space == JCS_YCCK) - cconvert->pub.color_convert = null_convert; - else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - default: /* allow null conversion of JCS_UNKNOWN */ - if (cinfo->jpeg_color_space != cinfo->in_color_space || - cinfo->num_components != cinfo->input_components) - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - cconvert->pub.color_convert = null_convert; - break; - } -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jcdctmgr.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jcdctmgr.c deleted file mode 100644 index e3f90dc39..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jcdctmgr.c +++ /dev/null @@ -1,387 +0,0 @@ -/* - * jcdctmgr.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the forward-DCT management logic. - * This code selects a particular DCT implementation to be used, - * and it performs related housekeeping chores including coefficient - * quantization. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - - -/* Private subobject for this module */ - -typedef struct { - struct jpeg_forward_dct pub; /* public fields */ - - /* Pointer to the DCT routine actually in use */ - forward_DCT_method_ptr do_dct; - - /* The actual post-DCT divisors --- not identical to the quant table - * entries, because of scaling (especially for an unnormalized DCT). - * Each table is given in normal array order. - */ - DCTELEM * divisors[NUM_QUANT_TBLS]; - -#ifdef DCT_FLOAT_SUPPORTED - /* Same as above for the floating-point case. */ - float_DCT_method_ptr do_float_dct; - FAST_FLOAT * float_divisors[NUM_QUANT_TBLS]; -#endif -} my_fdct_controller; - -typedef my_fdct_controller * my_fdct_ptr; - - -/* - * Initialize for a processing pass. - * Verify that all referenced Q-tables are present, and set up - * the divisor table for each one. - * In the current implementation, DCT of all components is done during - * the first pass, even if only some components will be output in the - * first scan. Hence all components should be examined here. - */ - -METHODDEF(void) -start_pass_fdctmgr (j_compress_ptr cinfo) -{ - my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct; - int ci, qtblno, i; - jpeg_component_info *compptr; - JQUANT_TBL * qtbl; - DCTELEM * dtbl; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - qtblno = compptr->quant_tbl_no; - /* Make sure specified quantization table is present */ - if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS || - cinfo->quant_tbl_ptrs[qtblno] == NULL) - ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno); - qtbl = cinfo->quant_tbl_ptrs[qtblno]; - /* Compute divisors for this quant table */ - /* We may do this more than once for same table, but it's not a big deal */ - switch (cinfo->dct_method) { -#ifdef DCT_ISLOW_SUPPORTED - case JDCT_ISLOW: - /* For LL&M IDCT method, divisors are equal to raw quantization - * coefficients multiplied by 8 (to counteract scaling). - */ - if (fdct->divisors[qtblno] == NULL) { - fdct->divisors[qtblno] = (DCTELEM *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - DCTSIZE2 * SIZEOF(DCTELEM)); - } - dtbl = fdct->divisors[qtblno]; - for (i = 0; i < DCTSIZE2; i++) { - dtbl[i] = ((DCTELEM) qtbl->quantval[i]) << 3; - } - break; -#endif -#ifdef DCT_IFAST_SUPPORTED - case JDCT_IFAST: - { - /* For AA&N IDCT method, divisors are equal to quantization - * coefficients scaled by scalefactor[row]*scalefactor[col], where - * scalefactor[0] = 1 - * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 - * We apply a further scale factor of 8. - */ -#define CONST_BITS 14 - static const INT16 aanscales[DCTSIZE2] = { - /* precomputed values scaled up by 14 bits */ - 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, - 22725, 31521, 29692, 26722, 22725, 17855, 12299, 6270, - 21407, 29692, 27969, 25172, 21407, 16819, 11585, 5906, - 19266, 26722, 25172, 22654, 19266, 15137, 10426, 5315, - 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, - 12873, 17855, 16819, 15137, 12873, 10114, 6967, 3552, - 8867, 12299, 11585, 10426, 8867, 6967, 4799, 2446, - 4520, 6270, 5906, 5315, 4520, 3552, 2446, 1247 - }; - SHIFT_TEMPS - - if (fdct->divisors[qtblno] == NULL) { - fdct->divisors[qtblno] = (DCTELEM *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - DCTSIZE2 * SIZEOF(DCTELEM)); - } - dtbl = fdct->divisors[qtblno]; - for (i = 0; i < DCTSIZE2; i++) { - dtbl[i] = (DCTELEM) - DESCALE(MULTIPLY16V16((INT32) qtbl->quantval[i], - (INT32) aanscales[i]), - CONST_BITS-3); - } - } - break; -#endif -#ifdef DCT_FLOAT_SUPPORTED - case JDCT_FLOAT: - { - /* For float AA&N IDCT method, divisors are equal to quantization - * coefficients scaled by scalefactor[row]*scalefactor[col], where - * scalefactor[0] = 1 - * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 - * We apply a further scale factor of 8. - * What's actually stored is 1/divisor so that the inner loop can - * use a multiplication rather than a division. - */ - FAST_FLOAT * fdtbl; - int row, col; - static const double aanscalefactor[DCTSIZE] = { - 1.0, 1.387039845, 1.306562965, 1.175875602, - 1.0, 0.785694958, 0.541196100, 0.275899379 - }; - - if (fdct->float_divisors[qtblno] == NULL) { - fdct->float_divisors[qtblno] = (FAST_FLOAT *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - DCTSIZE2 * SIZEOF(FAST_FLOAT)); - } - fdtbl = fdct->float_divisors[qtblno]; - i = 0; - for (row = 0; row < DCTSIZE; row++) { - for (col = 0; col < DCTSIZE; col++) { - fdtbl[i] = (FAST_FLOAT) - (1.0 / (((double) qtbl->quantval[i] * - aanscalefactor[row] * aanscalefactor[col] * 8.0))); - i++; - } - } - } - break; -#endif - default: - ERREXIT(cinfo, JERR_NOT_COMPILED); - break; - } - } -} - - -/* - * Perform forward DCT on one or more blocks of a component. - * - * The input samples are taken from the sample_data[] array starting at - * position start_row/start_col, and moving to the right for any additional - * blocks. The quantized coefficients are returned in coef_blocks[]. - */ - -METHODDEF(void) -forward_DCT (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY sample_data, JBLOCKROW coef_blocks, - JDIMENSION start_row, JDIMENSION start_col, - JDIMENSION num_blocks) -/* This version is used for integer DCT implementations. */ -{ - /* This routine is heavily used, so it's worth coding it tightly. */ - my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct; - forward_DCT_method_ptr do_dct = fdct->do_dct; - DCTELEM * divisors = fdct->divisors[compptr->quant_tbl_no]; - DCTELEM workspace[DCTSIZE2]; /* work area for FDCT subroutine */ - JDIMENSION bi; - - sample_data += start_row; /* fold in the vertical offset once */ - - for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) { - /* Load data into workspace, applying unsigned->signed conversion */ - { register DCTELEM *workspaceptr; - register JSAMPROW elemptr; - register int elemr; - - workspaceptr = workspace; - for (elemr = 0; elemr < DCTSIZE; elemr++) { - elemptr = sample_data[elemr] + start_col; -#if DCTSIZE == 8 /* unroll the inner loop */ - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; -#else - { register int elemc; - for (elemc = DCTSIZE; elemc > 0; elemc--) { - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - } - } -#endif - } - } - - /* Perform the DCT */ - (*do_dct) (workspace); - - /* Quantize/descale the coefficients, and store into coef_blocks[] */ - { register DCTELEM temp, qval; - register int i; - register JCOEFPTR output_ptr = coef_blocks[bi]; - - for (i = 0; i < DCTSIZE2; i++) { - qval = divisors[i]; - temp = workspace[i]; - /* Divide the coefficient value by qval, ensuring proper rounding. - * Since C does not specify the direction of rounding for negative - * quotients, we have to force the dividend positive for portability. - * - * In most files, at least half of the output values will be zero - * (at default quantization settings, more like three-quarters...) - * so we should ensure that this case is fast. On many machines, - * a comparison is enough cheaper than a divide to make a special test - * a win. Since both inputs will be nonnegative, we need only test - * for a < b to discover whether a/b is 0. - * If your machine's division is fast enough, define FAST_DIVIDE. - */ -#ifdef FAST_DIVIDE -#define DIVIDE_BY(a,b) a /= b -#else -#define DIVIDE_BY(a,b) if (a >= b) a /= b; else a = 0 -#endif - if (temp < 0) { - temp = -temp; - temp += qval>>1; /* for rounding */ - DIVIDE_BY(temp, qval); - temp = -temp; - } else { - temp += qval>>1; /* for rounding */ - DIVIDE_BY(temp, qval); - } - output_ptr[i] = (JCOEF) temp; - } - } - } -} - - -#ifdef DCT_FLOAT_SUPPORTED - -METHODDEF(void) -forward_DCT_float (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY sample_data, JBLOCKROW coef_blocks, - JDIMENSION start_row, JDIMENSION start_col, - JDIMENSION num_blocks) -/* This version is used for floating-point DCT implementations. */ -{ - /* This routine is heavily used, so it's worth coding it tightly. */ - my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct; - float_DCT_method_ptr do_dct = fdct->do_float_dct; - FAST_FLOAT * divisors = fdct->float_divisors[compptr->quant_tbl_no]; - FAST_FLOAT workspace[DCTSIZE2]; /* work area for FDCT subroutine */ - JDIMENSION bi; - - sample_data += start_row; /* fold in the vertical offset once */ - - for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) { - /* Load data into workspace, applying unsigned->signed conversion */ - { register FAST_FLOAT *workspaceptr; - register JSAMPROW elemptr; - register int elemr; - - workspaceptr = workspace; - for (elemr = 0; elemr < DCTSIZE; elemr++) { - elemptr = sample_data[elemr] + start_col; -#if DCTSIZE == 8 /* unroll the inner loop */ - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); -#else - { register int elemc; - for (elemc = DCTSIZE; elemc > 0; elemc--) { - *workspaceptr++ = (FAST_FLOAT) - (GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - } - } -#endif - } - } - - /* Perform the DCT */ - (*do_dct) (workspace); - - /* Quantize/descale the coefficients, and store into coef_blocks[] */ - { register FAST_FLOAT temp; - register int i; - register JCOEFPTR output_ptr = coef_blocks[bi]; - - for (i = 0; i < DCTSIZE2; i++) { - /* Apply the quantization and scaling factor */ - temp = workspace[i] * divisors[i]; - /* Round to nearest integer. - * Since C does not specify the direction of rounding for negative - * quotients, we have to force the dividend positive for portability. - * The maximum coefficient size is +-16K (for 12-bit data), so this - * code should work for either 16-bit or 32-bit ints. - */ - output_ptr[i] = (JCOEF) ((int) (temp + (FAST_FLOAT) 16384.5) - 16384); - } - } - } -} - -#endif /* DCT_FLOAT_SUPPORTED */ - - -/* - * Initialize FDCT manager. - */ - -GLOBAL(void) -jinit_forward_dct (j_compress_ptr cinfo) -{ - my_fdct_ptr fdct; - int i; - - fdct = (my_fdct_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_fdct_controller)); - cinfo->fdct = (struct jpeg_forward_dct *) fdct; - fdct->pub.start_pass = start_pass_fdctmgr; - - switch (cinfo->dct_method) { -#ifdef DCT_ISLOW_SUPPORTED - case JDCT_ISLOW: - fdct->pub.forward_DCT = forward_DCT; - fdct->do_dct = jpeg_fdct_islow; - break; -#endif -#ifdef DCT_IFAST_SUPPORTED - case JDCT_IFAST: - fdct->pub.forward_DCT = forward_DCT; - fdct->do_dct = jpeg_fdct_ifast; - break; -#endif -#ifdef DCT_FLOAT_SUPPORTED - case JDCT_FLOAT: - fdct->pub.forward_DCT = forward_DCT_float; - fdct->do_float_dct = jpeg_fdct_float; - break; -#endif - default: - ERREXIT(cinfo, JERR_NOT_COMPILED); - break; - } - - /* Mark divisor tables unallocated */ - for (i = 0; i < NUM_QUANT_TBLS; i++) { - fdct->divisors[i] = NULL; -#ifdef DCT_FLOAT_SUPPORTED - fdct->float_divisors[i] = NULL; -#endif - } -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jchuff.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jchuff.c deleted file mode 100644 index 16d9366ae..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jchuff.c +++ /dev/null @@ -1,909 +0,0 @@ -/* - * jchuff.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains Huffman entropy encoding routines. - * - * Much of the complexity here has to do with supporting output suspension. - * If the data destination module demands suspension, we want to be able to - * back up to the start of the current MCU. To do this, we copy state - * variables into local working storage, and update them back to the - * permanent JPEG objects only upon successful completion of an MCU. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jchuff.h" /* Declarations shared with jcphuff.c */ - - -/* Expanded entropy encoder object for Huffman encoding. - * - * The savable_state subrecord contains fields that change within an MCU, - * but must not be updated permanently until we complete the MCU. - */ - -typedef struct { - INT32 put_buffer; /* current bit-accumulation buffer */ - int put_bits; /* # of bits now in it */ - int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */ -} savable_state; - -/* This macro is to work around compilers with missing or broken - * structure assignment. You'll need to fix this code if you have - * such a compiler and you change MAX_COMPS_IN_SCAN. - */ - -#ifndef NO_STRUCT_ASSIGN -#define ASSIGN_STATE(dest,src) ((dest) = (src)) -#else -#if MAX_COMPS_IN_SCAN == 4 -#define ASSIGN_STATE(dest,src) \ - ((dest).put_buffer = (src).put_buffer, \ - (dest).put_bits = (src).put_bits, \ - (dest).last_dc_val[0] = (src).last_dc_val[0], \ - (dest).last_dc_val[1] = (src).last_dc_val[1], \ - (dest).last_dc_val[2] = (src).last_dc_val[2], \ - (dest).last_dc_val[3] = (src).last_dc_val[3]) -#endif -#endif - - -typedef struct { - struct jpeg_entropy_encoder pub; /* public fields */ - - savable_state saved; /* Bit buffer & DC state at start of MCU */ - - /* These fields are NOT loaded into local working state. */ - unsigned int restarts_to_go; /* MCUs left in this restart interval */ - int next_restart_num; /* next restart number to write (0-7) */ - - /* Pointers to derived tables (these workspaces have image lifespan) */ - c_derived_tbl * dc_derived_tbls[NUM_HUFF_TBLS]; - c_derived_tbl * ac_derived_tbls[NUM_HUFF_TBLS]; - -#ifdef ENTROPY_OPT_SUPPORTED /* Statistics tables for optimization */ - long * dc_count_ptrs[NUM_HUFF_TBLS]; - long * ac_count_ptrs[NUM_HUFF_TBLS]; -#endif -} huff_entropy_encoder; - -typedef huff_entropy_encoder * huff_entropy_ptr; - -/* Working state while writing an MCU. - * This struct contains all the fields that are needed by subroutines. - */ - -typedef struct { - JOCTET * next_output_byte; /* => next byte to write in buffer */ - size_t free_in_buffer; /* # of byte spaces remaining in buffer */ - savable_state cur; /* Current bit buffer & DC state */ - j_compress_ptr cinfo; /* dump_buffer needs access to this */ -} working_state; - - -/* Forward declarations */ -METHODDEF(boolean) encode_mcu_huff JPP((j_compress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(void) finish_pass_huff JPP((j_compress_ptr cinfo)); -#ifdef ENTROPY_OPT_SUPPORTED -METHODDEF(boolean) encode_mcu_gather JPP((j_compress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(void) finish_pass_gather JPP((j_compress_ptr cinfo)); -#endif - - -/* - * Initialize for a Huffman-compressed scan. - * If gather_statistics is TRUE, we do not output anything during the scan, - * just count the Huffman symbols used and generate Huffman code tables. - */ - -METHODDEF(void) -start_pass_huff (j_compress_ptr cinfo, boolean gather_statistics) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - int ci, dctbl, actbl; - jpeg_component_info * compptr; - - if (gather_statistics) { -#ifdef ENTROPY_OPT_SUPPORTED - entropy->pub.encode_mcu = encode_mcu_gather; - entropy->pub.finish_pass = finish_pass_gather; -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else { - entropy->pub.encode_mcu = encode_mcu_huff; - entropy->pub.finish_pass = finish_pass_huff; - } - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - dctbl = compptr->dc_tbl_no; - actbl = compptr->ac_tbl_no; - if (gather_statistics) { -#ifdef ENTROPY_OPT_SUPPORTED - /* Check for invalid table indexes */ - /* (make_c_derived_tbl does this in the other path) */ - if (dctbl < 0 || dctbl >= NUM_HUFF_TBLS) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, dctbl); - if (actbl < 0 || actbl >= NUM_HUFF_TBLS) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, actbl); - /* Allocate and zero the statistics tables */ - /* Note that jpeg_gen_optimal_table expects 257 entries in each table! */ - if (entropy->dc_count_ptrs[dctbl] == NULL) - entropy->dc_count_ptrs[dctbl] = (long *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - 257 * SIZEOF(long)); - MEMZERO(entropy->dc_count_ptrs[dctbl], 257 * SIZEOF(long)); - if (entropy->ac_count_ptrs[actbl] == NULL) - entropy->ac_count_ptrs[actbl] = (long *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - 257 * SIZEOF(long)); - MEMZERO(entropy->ac_count_ptrs[actbl], 257 * SIZEOF(long)); -#endif - } else { - /* Compute derived values for Huffman tables */ - /* We may do this more than once for a table, but it's not expensive */ - jpeg_make_c_derived_tbl(cinfo, TRUE, dctbl, - & entropy->dc_derived_tbls[dctbl]); - jpeg_make_c_derived_tbl(cinfo, FALSE, actbl, - & entropy->ac_derived_tbls[actbl]); - } - /* Initialize DC predictions to 0 */ - entropy->saved.last_dc_val[ci] = 0; - } - - /* Initialize bit buffer to empty */ - entropy->saved.put_buffer = 0; - entropy->saved.put_bits = 0; - - /* Initialize restart stuff */ - entropy->restarts_to_go = cinfo->restart_interval; - entropy->next_restart_num = 0; -} - - -/* - * Compute the derived values for a Huffman table. - * This routine also performs some validation checks on the table. - * - * Note this is also used by jcphuff.c. - */ - -GLOBAL(void) -jpeg_make_c_derived_tbl (j_compress_ptr cinfo, boolean isDC, int tblno, - c_derived_tbl ** pdtbl) -{ - JHUFF_TBL *htbl; - c_derived_tbl *dtbl; - int p, i, l, lastp, si, maxsymbol; - char huffsize[257]; - unsigned int huffcode[257]; - unsigned int code; - - /* Note that huffsize[] and huffcode[] are filled in code-length order, - * paralleling the order of the symbols themselves in htbl->huffval[]. - */ - - /* Find the input Huffman table */ - if (tblno < 0 || tblno >= NUM_HUFF_TBLS) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno); - htbl = - isDC ? cinfo->dc_huff_tbl_ptrs[tblno] : cinfo->ac_huff_tbl_ptrs[tblno]; - if (htbl == NULL) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno); - - /* Allocate a workspace if we haven't already done so. */ - if (*pdtbl == NULL) - *pdtbl = (c_derived_tbl *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(c_derived_tbl)); - dtbl = *pdtbl; - - /* Figure C.1: make table of Huffman code length for each symbol */ - - p = 0; - for (l = 1; l <= 16; l++) { - i = (int) htbl->bits[l]; - if (i < 0 || p + i > 256) /* protect against table overrun */ - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - while (i--) - huffsize[p++] = (char) l; - } - huffsize[p] = 0; - lastp = p; - - /* Figure C.2: generate the codes themselves */ - /* We also validate that the counts represent a legal Huffman code tree. */ - - code = 0; - si = huffsize[0]; - p = 0; - while (huffsize[p]) { - while (((int) huffsize[p]) == si) { - huffcode[p++] = code; - code++; - } - /* code is now 1 more than the last code used for codelength si; but - * it must still fit in si bits, since no code is allowed to be all ones. - */ - if (((INT32) code) >= (((INT32) 1) << si)) - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - code <<= 1; - si++; - } - - /* Figure C.3: generate encoding tables */ - /* These are code and size indexed by symbol value */ - - /* Set all codeless symbols to have code length 0; - * this lets us detect duplicate VAL entries here, and later - * allows emit_bits to detect any attempt to emit such symbols. - */ - MEMZERO(dtbl->ehufsi, SIZEOF(dtbl->ehufsi)); - - /* This is also a convenient place to check for out-of-range - * and duplicated VAL entries. We allow 0..255 for AC symbols - * but only 0..15 for DC. (We could constrain them further - * based on data depth and mode, but this seems enough.) - */ - maxsymbol = isDC ? 15 : 255; - - for (p = 0; p < lastp; p++) { - i = htbl->huffval[p]; - if (i < 0 || i > maxsymbol || dtbl->ehufsi[i]) - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - dtbl->ehufco[i] = huffcode[p]; - dtbl->ehufsi[i] = huffsize[p]; - } -} - - -/* Outputting bytes to the file */ - -/* Emit a byte, taking 'action' if must suspend. */ -#define emit_byte(state,val,action) \ - { *(state)->next_output_byte++ = (JOCTET) (val); \ - if (--(state)->free_in_buffer == 0) \ - if (! dump_buffer(state)) \ - { action; } } - - -LOCAL(boolean) -dump_buffer (working_state * state) -/* Empty the output buffer; return TRUE if successful, FALSE if must suspend */ -{ - struct jpeg_destination_mgr * dest = state->cinfo->dest; - - if (! (*dest->empty_output_buffer) (state->cinfo)) - return FALSE; - /* After a successful buffer dump, must reset buffer pointers */ - state->next_output_byte = dest->next_output_byte; - state->free_in_buffer = dest->free_in_buffer; - return TRUE; -} - - -/* Outputting bits to the file */ - -/* Only the right 24 bits of put_buffer are used; the valid bits are - * left-justified in this part. At most 16 bits can be passed to emit_bits - * in one call, and we never retain more than 7 bits in put_buffer - * between calls, so 24 bits are sufficient. - */ - -INLINE -LOCAL(boolean) -emit_bits (working_state * state, unsigned int code, int size) -/* Emit some bits; return TRUE if successful, FALSE if must suspend */ -{ - /* This routine is heavily used, so it's worth coding tightly. */ - register INT32 put_buffer = (INT32) code; - register int put_bits = state->cur.put_bits; - - /* if size is 0, caller used an invalid Huffman table entry */ - if (size == 0) - ERREXIT(state->cinfo, JERR_HUFF_MISSING_CODE); - - put_buffer &= (((INT32) 1)<<size) - 1; /* mask off any extra bits in code */ - - put_bits += size; /* new number of bits in buffer */ - - put_buffer <<= 24 - put_bits; /* align incoming bits */ - - put_buffer |= state->cur.put_buffer; /* and merge with old buffer contents */ - - while (put_bits >= 8) { - int c = (int) ((put_buffer >> 16) & 0xFF); - - emit_byte(state, c, return FALSE); - if (c == 0xFF) { /* need to stuff a zero byte? */ - emit_byte(state, 0, return FALSE); - } - put_buffer <<= 8; - put_bits -= 8; - } - - state->cur.put_buffer = put_buffer; /* update state variables */ - state->cur.put_bits = put_bits; - - return TRUE; -} - - -LOCAL(boolean) -flush_bits (working_state * state) -{ - if (! emit_bits(state, 0x7F, 7)) /* fill any partial byte with ones */ - return FALSE; - state->cur.put_buffer = 0; /* and reset bit-buffer to empty */ - state->cur.put_bits = 0; - return TRUE; -} - - -/* Encode a single block's worth of coefficients */ - -LOCAL(boolean) -encode_one_block (working_state * state, JCOEFPTR block, int last_dc_val, - c_derived_tbl *dctbl, c_derived_tbl *actbl) -{ - register int temp, temp2; - register int nbits; - register int k, r, i; - - /* Encode the DC coefficient difference per section F.1.2.1 */ - - temp = temp2 = block[0] - last_dc_val; - - if (temp < 0) { - temp = -temp; /* temp is abs value of input */ - /* For a negative input, want temp2 = bitwise complement of abs(input) */ - /* This code assumes we are on a two's complement machine */ - temp2--; - } - - /* Find the number of bits needed for the magnitude of the coefficient */ - nbits = 0; - while (temp) { - nbits++; - temp >>= 1; - } - /* Check for out-of-range coefficient values. - * Since we're encoding a difference, the range limit is twice as much. - */ - if (nbits > MAX_COEF_BITS+1) - ERREXIT(state->cinfo, JERR_BAD_DCT_COEF); - - /* Emit the Huffman-coded symbol for the number of bits */ - if (! emit_bits(state, dctbl->ehufco[nbits], dctbl->ehufsi[nbits])) - return FALSE; - - /* Emit that number of bits of the value, if positive, */ - /* or the complement of its magnitude, if negative. */ - if (nbits) /* emit_bits rejects calls with size 0 */ - if (! emit_bits(state, (unsigned int) temp2, nbits)) - return FALSE; - - /* Encode the AC coefficients per section F.1.2.2 */ - - r = 0; /* r = run length of zeros */ - - for (k = 1; k < DCTSIZE2; k++) { - if ((temp = block[jpeg_natural_order[k]]) == 0) { - r++; - } else { - /* if run length > 15, must emit special run-length-16 codes (0xF0) */ - while (r > 15) { - if (! emit_bits(state, actbl->ehufco[0xF0], actbl->ehufsi[0xF0])) - return FALSE; - r -= 16; - } - - temp2 = temp; - if (temp < 0) { - temp = -temp; /* temp is abs value of input */ - /* This code assumes we are on a two's complement machine */ - temp2--; - } - - /* Find the number of bits needed for the magnitude of the coefficient */ - nbits = 1; /* there must be at least one 1 bit */ - while ((temp >>= 1)) - nbits++; - /* Check for out-of-range coefficient values */ - if (nbits > MAX_COEF_BITS) - ERREXIT(state->cinfo, JERR_BAD_DCT_COEF); - - /* Emit Huffman symbol for run length / number of bits */ - i = (r << 4) + nbits; - if (! emit_bits(state, actbl->ehufco[i], actbl->ehufsi[i])) - return FALSE; - - /* Emit that number of bits of the value, if positive, */ - /* or the complement of its magnitude, if negative. */ - if (! emit_bits(state, (unsigned int) temp2, nbits)) - return FALSE; - - r = 0; - } - } - - /* If the last coef(s) were zero, emit an end-of-block code */ - if (r > 0) - if (! emit_bits(state, actbl->ehufco[0], actbl->ehufsi[0])) - return FALSE; - - return TRUE; -} - - -/* - * Emit a restart marker & resynchronize predictions. - */ - -LOCAL(boolean) -emit_restart (working_state * state, int restart_num) -{ - int ci; - - if (! flush_bits(state)) - return FALSE; - - emit_byte(state, 0xFF, return FALSE); - emit_byte(state, JPEG_RST0 + restart_num, return FALSE); - - /* Re-initialize DC predictions to 0 */ - for (ci = 0; ci < state->cinfo->comps_in_scan; ci++) - state->cur.last_dc_val[ci] = 0; - - /* The restart counter is not updated until we successfully write the MCU. */ - - return TRUE; -} - - -/* - * Encode and output one MCU's worth of Huffman-compressed coefficients. - */ - -METHODDEF(boolean) -encode_mcu_huff (j_compress_ptr cinfo, JBLOCKROW *MCU_data) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - working_state state; - int blkn, ci; - jpeg_component_info * compptr; - - /* Load up working state */ - state.next_output_byte = cinfo->dest->next_output_byte; - state.free_in_buffer = cinfo->dest->free_in_buffer; - ASSIGN_STATE(state.cur, entropy->saved); - state.cinfo = cinfo; - - /* Emit restart marker if needed */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) - if (! emit_restart(&state, entropy->next_restart_num)) - return FALSE; - } - - /* Encode the MCU data blocks */ - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - ci = cinfo->MCU_membership[blkn]; - compptr = cinfo->cur_comp_info[ci]; - if (! encode_one_block(&state, - MCU_data[blkn][0], state.cur.last_dc_val[ci], - entropy->dc_derived_tbls[compptr->dc_tbl_no], - entropy->ac_derived_tbls[compptr->ac_tbl_no])) - return FALSE; - /* Update last_dc_val */ - state.cur.last_dc_val[ci] = MCU_data[blkn][0][0]; - } - - /* Completed MCU, so update state */ - cinfo->dest->next_output_byte = state.next_output_byte; - cinfo->dest->free_in_buffer = state.free_in_buffer; - ASSIGN_STATE(entropy->saved, state.cur); - - /* Update restart-interval state too */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) { - entropy->restarts_to_go = cinfo->restart_interval; - entropy->next_restart_num++; - entropy->next_restart_num &= 7; - } - entropy->restarts_to_go--; - } - - return TRUE; -} - - -/* - * Finish up at the end of a Huffman-compressed scan. - */ - -METHODDEF(void) -finish_pass_huff (j_compress_ptr cinfo) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - working_state state; - - /* Load up working state ... flush_bits needs it */ - state.next_output_byte = cinfo->dest->next_output_byte; - state.free_in_buffer = cinfo->dest->free_in_buffer; - ASSIGN_STATE(state.cur, entropy->saved); - state.cinfo = cinfo; - - /* Flush out the last data */ - if (! flush_bits(&state)) - ERREXIT(cinfo, JERR_CANT_SUSPEND); - - /* Update state */ - cinfo->dest->next_output_byte = state.next_output_byte; - cinfo->dest->free_in_buffer = state.free_in_buffer; - ASSIGN_STATE(entropy->saved, state.cur); -} - - -/* - * Huffman coding optimization. - * - * We first scan the supplied data and count the number of uses of each symbol - * that is to be Huffman-coded. (This process MUST agree with the code above.) - * Then we build a Huffman coding tree for the observed counts. - * Symbols which are not needed at all for the particular image are not - * assigned any code, which saves space in the DHT marker as well as in - * the compressed data. - */ - -#ifdef ENTROPY_OPT_SUPPORTED - - -/* Process a single block's worth of coefficients */ - -LOCAL(void) -htest_one_block (j_compress_ptr cinfo, JCOEFPTR block, int last_dc_val, - long dc_counts[], long ac_counts[]) -{ - register int temp; - register int nbits; - register int k, r; - - /* Encode the DC coefficient difference per section F.1.2.1 */ - - temp = block[0] - last_dc_val; - if (temp < 0) - temp = -temp; - - /* Find the number of bits needed for the magnitude of the coefficient */ - nbits = 0; - while (temp) { - nbits++; - temp >>= 1; - } - /* Check for out-of-range coefficient values. - * Since we're encoding a difference, the range limit is twice as much. - */ - if (nbits > MAX_COEF_BITS+1) - ERREXIT(cinfo, JERR_BAD_DCT_COEF); - - /* Count the Huffman symbol for the number of bits */ - dc_counts[nbits]++; - - /* Encode the AC coefficients per section F.1.2.2 */ - - r = 0; /* r = run length of zeros */ - - for (k = 1; k < DCTSIZE2; k++) { - if ((temp = block[jpeg_natural_order[k]]) == 0) { - r++; - } else { - /* if run length > 15, must emit special run-length-16 codes (0xF0) */ - while (r > 15) { - ac_counts[0xF0]++; - r -= 16; - } - - /* Find the number of bits needed for the magnitude of the coefficient */ - if (temp < 0) - temp = -temp; - - /* Find the number of bits needed for the magnitude of the coefficient */ - nbits = 1; /* there must be at least one 1 bit */ - while ((temp >>= 1)) - nbits++; - /* Check for out-of-range coefficient values */ - if (nbits > MAX_COEF_BITS) - ERREXIT(cinfo, JERR_BAD_DCT_COEF); - - /* Count Huffman symbol for run length / number of bits */ - ac_counts[(r << 4) + nbits]++; - - r = 0; - } - } - - /* If the last coef(s) were zero, emit an end-of-block code */ - if (r > 0) - ac_counts[0]++; -} - - -/* - * Trial-encode one MCU's worth of Huffman-compressed coefficients. - * No data is actually output, so no suspension return is possible. - */ - -METHODDEF(boolean) -encode_mcu_gather (j_compress_ptr cinfo, JBLOCKROW *MCU_data) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - int blkn, ci; - jpeg_component_info * compptr; - - /* Take care of restart intervals if needed */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) { - /* Re-initialize DC predictions to 0 */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) - entropy->saved.last_dc_val[ci] = 0; - /* Update restart state */ - entropy->restarts_to_go = cinfo->restart_interval; - } - entropy->restarts_to_go--; - } - - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - ci = cinfo->MCU_membership[blkn]; - compptr = cinfo->cur_comp_info[ci]; - htest_one_block(cinfo, MCU_data[blkn][0], entropy->saved.last_dc_val[ci], - entropy->dc_count_ptrs[compptr->dc_tbl_no], - entropy->ac_count_ptrs[compptr->ac_tbl_no]); - entropy->saved.last_dc_val[ci] = MCU_data[blkn][0][0]; - } - - return TRUE; -} - - -/* - * Generate the best Huffman code table for the given counts, fill htbl. - * Note this is also used by jcphuff.c. - * - * The JPEG standard requires that no symbol be assigned a codeword of all - * one bits (so that padding bits added at the end of a compressed segment - * can't look like a valid code). Because of the canonical ordering of - * codewords, this just means that there must be an unused slot in the - * longest codeword length category. Section K.2 of the JPEG spec suggests - * reserving such a slot by pretending that symbol 256 is a valid symbol - * with count 1. In theory that's not optimal; giving it count zero but - * including it in the symbol set anyway should give a better Huffman code. - * But the theoretically better code actually seems to come out worse in - * practice, because it produces more all-ones bytes (which incur stuffed - * zero bytes in the final file). In any case the difference is tiny. - * - * The JPEG standard requires Huffman codes to be no more than 16 bits long. - * If some symbols have a very small but nonzero probability, the Huffman tree - * must be adjusted to meet the code length restriction. We currently use - * the adjustment method suggested in JPEG section K.2. This method is *not* - * optimal; it may not choose the best possible limited-length code. But - * typically only very-low-frequency symbols will be given less-than-optimal - * lengths, so the code is almost optimal. Experimental comparisons against - * an optimal limited-length-code algorithm indicate that the difference is - * microscopic --- usually less than a hundredth of a percent of total size. - * So the extra complexity of an optimal algorithm doesn't seem worthwhile. - */ - -GLOBAL(void) -jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[]) -{ -#define MAX_CLEN 32 /* assumed maximum initial code length */ - UINT8 bits[MAX_CLEN+1]; /* bits[k] = # of symbols with code length k */ - int codesize[257]; /* codesize[k] = code length of symbol k */ - int others[257]; /* next symbol in current branch of tree */ - int c1, c2; - int p, i, j; - long v; - - /* This algorithm is explained in section K.2 of the JPEG standard */ - - MEMZERO(bits, SIZEOF(bits)); - MEMZERO(codesize, SIZEOF(codesize)); - for (i = 0; i < 257; i++) - others[i] = -1; /* init links to empty */ - - freq[256] = 1; /* make sure 256 has a nonzero count */ - /* Including the pseudo-symbol 256 in the Huffman procedure guarantees - * that no real symbol is given code-value of all ones, because 256 - * will be placed last in the largest codeword category. - */ - - /* Huffman's basic algorithm to assign optimal code lengths to symbols */ - - for (;;) { - /* Find the smallest nonzero frequency, set c1 = its symbol */ - /* In case of ties, take the larger symbol number */ - c1 = -1; - v = 1000000000L; - for (i = 0; i <= 256; i++) { - if (freq[i] && freq[i] <= v) { - v = freq[i]; - c1 = i; - } - } - - /* Find the next smallest nonzero frequency, set c2 = its symbol */ - /* In case of ties, take the larger symbol number */ - c2 = -1; - v = 1000000000L; - for (i = 0; i <= 256; i++) { - if (freq[i] && freq[i] <= v && i != c1) { - v = freq[i]; - c2 = i; - } - } - - /* Done if we've merged everything into one frequency */ - if (c2 < 0) - break; - - /* Else merge the two counts/trees */ - freq[c1] += freq[c2]; - freq[c2] = 0; - - /* Increment the codesize of everything in c1's tree branch */ - codesize[c1]++; - while (others[c1] >= 0) { - c1 = others[c1]; - codesize[c1]++; - } - - others[c1] = c2; /* chain c2 onto c1's tree branch */ - - /* Increment the codesize of everything in c2's tree branch */ - codesize[c2]++; - while (others[c2] >= 0) { - c2 = others[c2]; - codesize[c2]++; - } - } - - /* Now count the number of symbols of each code length */ - for (i = 0; i <= 256; i++) { - if (codesize[i]) { - /* The JPEG standard seems to think that this can't happen, */ - /* but I'm paranoid... */ - if (codesize[i] > MAX_CLEN) - ERREXIT(cinfo, JERR_HUFF_CLEN_OVERFLOW); - - bits[codesize[i]]++; - } - } - - /* JPEG doesn't allow symbols with code lengths over 16 bits, so if the pure - * Huffman procedure assigned any such lengths, we must adjust the coding. - * Here is what the JPEG spec says about how this next bit works: - * Since symbols are paired for the longest Huffman code, the symbols are - * removed from this length category two at a time. The prefix for the pair - * (which is one bit shorter) is allocated to one of the pair; then, - * skipping the BITS entry for that prefix length, a code word from the next - * shortest nonzero BITS entry is converted into a prefix for two code words - * one bit longer. - */ - - for (i = MAX_CLEN; i > 16; i--) { - while (bits[i] > 0) { - j = i - 2; /* find length of new prefix to be used */ - while (bits[j] == 0) - j--; - - bits[i] -= 2; /* remove two symbols */ - bits[i-1]++; /* one goes in this length */ - bits[j+1] += 2; /* two new symbols in this length */ - bits[j]--; /* symbol of this length is now a prefix */ - } - } - - /* Remove the count for the pseudo-symbol 256 from the largest codelength */ - while (bits[i] == 0) /* find largest codelength still in use */ - i--; - bits[i]--; - - /* Return final symbol counts (only for lengths 0..16) */ - MEMCOPY(htbl->bits, bits, SIZEOF(htbl->bits)); - - /* Return a list of the symbols sorted by code length */ - /* It's not real clear to me why we don't need to consider the codelength - * changes made above, but the JPEG spec seems to think this works. - */ - p = 0; - for (i = 1; i <= MAX_CLEN; i++) { - for (j = 0; j <= 255; j++) { - if (codesize[j] == i) { - htbl->huffval[p] = (UINT8) j; - p++; - } - } - } - - /* Set sent_table FALSE so updated table will be written to JPEG file. */ - htbl->sent_table = FALSE; -} - - -/* - * Finish up a statistics-gathering pass and create the new Huffman tables. - */ - -METHODDEF(void) -finish_pass_gather (j_compress_ptr cinfo) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - int ci, dctbl, actbl; - jpeg_component_info * compptr; - JHUFF_TBL **htblptr; - boolean did_dc[NUM_HUFF_TBLS]; - boolean did_ac[NUM_HUFF_TBLS]; - - /* It's important not to apply jpeg_gen_optimal_table more than once - * per table, because it clobbers the input frequency counts! - */ - MEMZERO(did_dc, SIZEOF(did_dc)); - MEMZERO(did_ac, SIZEOF(did_ac)); - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - dctbl = compptr->dc_tbl_no; - actbl = compptr->ac_tbl_no; - if (! did_dc[dctbl]) { - htblptr = & cinfo->dc_huff_tbl_ptrs[dctbl]; - if (*htblptr == NULL) - *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); - jpeg_gen_optimal_table(cinfo, *htblptr, entropy->dc_count_ptrs[dctbl]); - did_dc[dctbl] = TRUE; - } - if (! did_ac[actbl]) { - htblptr = & cinfo->ac_huff_tbl_ptrs[actbl]; - if (*htblptr == NULL) - *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); - jpeg_gen_optimal_table(cinfo, *htblptr, entropy->ac_count_ptrs[actbl]); - did_ac[actbl] = TRUE; - } - } -} - - -#endif /* ENTROPY_OPT_SUPPORTED */ - - -/* - * Module initialization routine for Huffman entropy encoding. - */ - -GLOBAL(void) -jinit_huff_encoder (j_compress_ptr cinfo) -{ - huff_entropy_ptr entropy; - int i; - - entropy = (huff_entropy_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(huff_entropy_encoder)); - cinfo->entropy = (struct jpeg_entropy_encoder *) entropy; - entropy->pub.start_pass = start_pass_huff; - - /* Mark tables unallocated */ - for (i = 0; i < NUM_HUFF_TBLS; i++) { - entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL; -#ifdef ENTROPY_OPT_SUPPORTED - entropy->dc_count_ptrs[i] = entropy->ac_count_ptrs[i] = NULL; -#endif - } -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jchuff.h b/irrlicht-1.6/source/Irrlicht/jpeglib/jchuff.h deleted file mode 100644 index 8c02c09ad..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jchuff.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * jchuff.h - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains declarations for Huffman entropy encoding routines - * that are shared between the sequential encoder (jchuff.c) and the - * progressive encoder (jcphuff.c). No other modules need to see these. - */ - -/* The legal range of a DCT coefficient is - * -1024 .. +1023 for 8-bit data; - * -16384 .. +16383 for 12-bit data. - * Hence the magnitude should always fit in 10 or 14 bits respectively. - */ - -#if BITS_IN_JSAMPLE == 8 -#define MAX_COEF_BITS 10 -#else -#define MAX_COEF_BITS 14 -#endif - -/* Derived data constructed for each Huffman table */ - -typedef struct { - unsigned int ehufco[256]; /* code for each symbol */ - char ehufsi[256]; /* length of code for each symbol */ - /* If no code has been allocated for a symbol S, ehufsi[S] contains 0 */ -} c_derived_tbl; - -/* Short forms of external names for systems with brain-damaged linkers. */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jpeg_make_c_derived_tbl jMkCDerived -#define jpeg_gen_optimal_table jGenOptTbl -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - -/* Expand a Huffman table definition into the derived format */ -EXTERN(void) jpeg_make_c_derived_tbl - JPP((j_compress_ptr cinfo, boolean isDC, int tblno, - c_derived_tbl ** pdtbl)); - -/* Generate an optimal table definition given the specified counts */ -EXTERN(void) jpeg_gen_optimal_table - JPP((j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[])); diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jcinit.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jcinit.c deleted file mode 100644 index 19de8d0e0..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jcinit.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * jcinit.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains initialization logic for the JPEG compressor. - * This routine is in charge of selecting the modules to be executed and - * making an initialization call to each one. - * - * Logically, this code belongs in jcmaster.c. It's split out because - * linking this routine implies linking the entire compression library. - * For a transcoding-only application, we want to be able to use jcmaster.c - * without linking in the whole library. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * Master selection of compression modules. - * This is done once at the start of processing an image. We determine - * which modules will be used and give them appropriate initialization calls. - */ - -GLOBAL(void) -jinit_compress_master (j_compress_ptr cinfo) -{ - /* Initialize master control (includes parameter checking/processing) */ - jinit_c_master_control(cinfo, FALSE /* full compression */); - - /* Preprocessing */ - if (! cinfo->raw_data_in) { - jinit_color_converter(cinfo); - jinit_downsampler(cinfo); - jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */); - } - /* Forward DCT */ - jinit_forward_dct(cinfo); - /* Entropy encoding: either Huffman or arithmetic coding. */ - if (cinfo->arith_code) { - ERREXIT(cinfo, JERR_ARITH_NOTIMPL); - } else { - if (cinfo->progressive_mode) { -#ifdef C_PROGRESSIVE_SUPPORTED - jinit_phuff_encoder(cinfo); -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else - jinit_huff_encoder(cinfo); - } - - /* Need a full-image coefficient buffer in any multi-pass mode. */ - jinit_c_coef_controller(cinfo, - (boolean) (cinfo->num_scans > 1 || cinfo->optimize_coding)); - jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */); - - jinit_marker_writer(cinfo); - - /* We can now tell the memory manager to allocate virtual arrays. */ - (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); - - /* Write the datastream header (SOI) immediately. - * Frame and scan headers are postponed till later. - * This lets application insert special markers after the SOI. - */ - (*cinfo->marker->write_file_header) (cinfo); -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jcmainct.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jcmainct.c deleted file mode 100644 index 14aa4c75c..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jcmainct.c +++ /dev/null @@ -1,293 +0,0 @@ -/* - * jcmainct.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the main buffer controller for compression. - * The main buffer lies between the pre-processor and the JPEG - * compressor proper; it holds downsampled data in the JPEG colorspace. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Note: currently, there is no operating mode in which a full-image buffer - * is needed at this step. If there were, that mode could not be used with - * "raw data" input, since this module is bypassed in that case. However, - * we've left the code here for possible use in special applications. - */ -#undef FULL_MAIN_BUFFER_SUPPORTED - - -/* Private buffer controller object */ - -typedef struct { - struct jpeg_c_main_controller pub; /* public fields */ - - JDIMENSION cur_iMCU_row; /* number of current iMCU row */ - JDIMENSION rowgroup_ctr; /* counts row groups received in iMCU row */ - boolean suspended; /* remember if we suspended output */ - J_BUF_MODE pass_mode; /* current operating mode */ - - /* If using just a strip buffer, this points to the entire set of buffers - * (we allocate one for each component). In the full-image case, this - * points to the currently accessible strips of the virtual arrays. - */ - JSAMPARRAY buffer[MAX_COMPONENTS]; - -#ifdef FULL_MAIN_BUFFER_SUPPORTED - /* If using full-image storage, this array holds pointers to virtual-array - * control blocks for each component. Unused if not full-image storage. - */ - jvirt_sarray_ptr whole_image[MAX_COMPONENTS]; -#endif -} my_main_controller; - -typedef my_main_controller * my_main_ptr; - - -/* Forward declarations */ -METHODDEF(void) process_data_simple_main - JPP((j_compress_ptr cinfo, JSAMPARRAY input_buf, - JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail)); -#ifdef FULL_MAIN_BUFFER_SUPPORTED -METHODDEF(void) process_data_buffer_main - JPP((j_compress_ptr cinfo, JSAMPARRAY input_buf, - JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail)); -#endif - - -/* - * Initialize for a processing pass. - */ - -METHODDEF(void) -start_pass_main (j_compress_ptr cinfo, J_BUF_MODE pass_mode) -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - - /* Do nothing in raw-data mode. */ - if (cinfo->raw_data_in) - return; - - main->cur_iMCU_row = 0; /* initialize counters */ - main->rowgroup_ctr = 0; - main->suspended = FALSE; - main->pass_mode = pass_mode; /* save mode for use by process_data */ - - switch (pass_mode) { - case JBUF_PASS_THRU: -#ifdef FULL_MAIN_BUFFER_SUPPORTED - if (main->whole_image[0] != NULL) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); -#endif - main->pub.process_data = process_data_simple_main; - break; -#ifdef FULL_MAIN_BUFFER_SUPPORTED - case JBUF_SAVE_SOURCE: - case JBUF_CRANK_DEST: - case JBUF_SAVE_AND_PASS: - if (main->whole_image[0] == NULL) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - main->pub.process_data = process_data_buffer_main; - break; -#endif - default: - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - break; - } -} - - -/* - * Process some data. - * This routine handles the simple pass-through mode, - * where we have only a strip buffer. - */ - -METHODDEF(void) -process_data_simple_main (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, - JDIMENSION in_rows_avail) -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - - while (main->cur_iMCU_row < cinfo->total_iMCU_rows) { - /* Read input data if we haven't filled the main buffer yet */ - if (main->rowgroup_ctr < DCTSIZE) - (*cinfo->prep->pre_process_data) (cinfo, - input_buf, in_row_ctr, in_rows_avail, - main->buffer, &main->rowgroup_ctr, - (JDIMENSION) DCTSIZE); - - /* If we don't have a full iMCU row buffered, return to application for - * more data. Note that preprocessor will always pad to fill the iMCU row - * at the bottom of the image. - */ - if (main->rowgroup_ctr != DCTSIZE) - return; - - /* Send the completed row to the compressor */ - if (! (*cinfo->coef->compress_data) (cinfo, main->buffer)) { - /* If compressor did not consume the whole row, then we must need to - * suspend processing and return to the application. In this situation - * we pretend we didn't yet consume the last input row; otherwise, if - * it happened to be the last row of the image, the application would - * think we were done. - */ - if (! main->suspended) { - (*in_row_ctr)--; - main->suspended = TRUE; - } - return; - } - /* We did finish the row. Undo our little suspension hack if a previous - * call suspended; then mark the main buffer empty. - */ - if (main->suspended) { - (*in_row_ctr)++; - main->suspended = FALSE; - } - main->rowgroup_ctr = 0; - main->cur_iMCU_row++; - } -} - - -#ifdef FULL_MAIN_BUFFER_SUPPORTED - -/* - * Process some data. - * This routine handles all of the modes that use a full-size buffer. - */ - -METHODDEF(void) -process_data_buffer_main (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, - JDIMENSION in_rows_avail) -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - int ci; - jpeg_component_info *compptr; - boolean writing = (main->pass_mode != JBUF_CRANK_DEST); - - while (main->cur_iMCU_row < cinfo->total_iMCU_rows) { - /* Realign the virtual buffers if at the start of an iMCU row. */ - if (main->rowgroup_ctr == 0) { - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - main->buffer[ci] = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, main->whole_image[ci], - main->cur_iMCU_row * (compptr->v_samp_factor * DCTSIZE), - (JDIMENSION) (compptr->v_samp_factor * DCTSIZE), writing); - } - /* In a read pass, pretend we just read some source data. */ - if (! writing) { - *in_row_ctr += cinfo->max_v_samp_factor * DCTSIZE; - main->rowgroup_ctr = DCTSIZE; - } - } - - /* If a write pass, read input data until the current iMCU row is full. */ - /* Note: preprocessor will pad if necessary to fill the last iMCU row. */ - if (writing) { - (*cinfo->prep->pre_process_data) (cinfo, - input_buf, in_row_ctr, in_rows_avail, - main->buffer, &main->rowgroup_ctr, - (JDIMENSION) DCTSIZE); - /* Return to application if we need more data to fill the iMCU row. */ - if (main->rowgroup_ctr < DCTSIZE) - return; - } - - /* Emit data, unless this is a sink-only pass. */ - if (main->pass_mode != JBUF_SAVE_SOURCE) { - if (! (*cinfo->coef->compress_data) (cinfo, main->buffer)) { - /* If compressor did not consume the whole row, then we must need to - * suspend processing and return to the application. In this situation - * we pretend we didn't yet consume the last input row; otherwise, if - * it happened to be the last row of the image, the application would - * think we were done. - */ - if (! main->suspended) { - (*in_row_ctr)--; - main->suspended = TRUE; - } - return; - } - /* We did finish the row. Undo our little suspension hack if a previous - * call suspended; then mark the main buffer empty. - */ - if (main->suspended) { - (*in_row_ctr)++; - main->suspended = FALSE; - } - } - - /* If get here, we are done with this iMCU row. Mark buffer empty. */ - main->rowgroup_ctr = 0; - main->cur_iMCU_row++; - } -} - -#endif /* FULL_MAIN_BUFFER_SUPPORTED */ - - -/* - * Initialize main buffer controller. - */ - -GLOBAL(void) -jinit_c_main_controller (j_compress_ptr cinfo, boolean need_full_buffer) -{ - my_main_ptr main; - int ci; - jpeg_component_info *compptr; - - main = (my_main_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_main_controller)); - cinfo->main = (struct jpeg_c_main_controller *) main; - main->pub.start_pass = start_pass_main; - - /* We don't need to create a buffer in raw-data mode. */ - if (cinfo->raw_data_in) - return; - - /* Create the buffer. It holds downsampled data, so each component - * may be of a different size. - */ - if (need_full_buffer) { -#ifdef FULL_MAIN_BUFFER_SUPPORTED - /* Allocate a full-image virtual array for each component */ - /* Note we pad the bottom to a multiple of the iMCU height */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - main->whole_image[ci] = (*cinfo->mem->request_virt_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, - compptr->width_in_blocks * DCTSIZE, - (JDIMENSION) jround_up((long) compptr->height_in_blocks, - (long) compptr->v_samp_factor) * DCTSIZE, - (JDIMENSION) (compptr->v_samp_factor * DCTSIZE)); - } -#else - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); -#endif - } else { -#ifdef FULL_MAIN_BUFFER_SUPPORTED - main->whole_image[0] = NULL; /* flag for no virtual arrays */ -#endif - /* Allocate a strip buffer for each component */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - main->buffer[ci] = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - compptr->width_in_blocks * DCTSIZE, - (JDIMENSION) (compptr->v_samp_factor * DCTSIZE)); - } - } -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jcmarker.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jcmarker.c deleted file mode 100644 index 0d3ca5e55..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jcmarker.c +++ /dev/null @@ -1,664 +0,0 @@ -/* - * jcmarker.c - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to write JPEG datastream markers. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -typedef enum { /* JPEG marker codes */ - M_SOF0 = 0xc0, - M_SOF1 = 0xc1, - M_SOF2 = 0xc2, - M_SOF3 = 0xc3, - - M_SOF5 = 0xc5, - M_SOF6 = 0xc6, - M_SOF7 = 0xc7, - - M_JPG = 0xc8, - M_SOF9 = 0xc9, - M_SOF10 = 0xca, - M_SOF11 = 0xcb, - - M_SOF13 = 0xcd, - M_SOF14 = 0xce, - M_SOF15 = 0xcf, - - M_DHT = 0xc4, - - M_DAC = 0xcc, - - M_RST0 = 0xd0, - M_RST1 = 0xd1, - M_RST2 = 0xd2, - M_RST3 = 0xd3, - M_RST4 = 0xd4, - M_RST5 = 0xd5, - M_RST6 = 0xd6, - M_RST7 = 0xd7, - - M_SOI = 0xd8, - M_EOI = 0xd9, - M_SOS = 0xda, - M_DQT = 0xdb, - M_DNL = 0xdc, - M_DRI = 0xdd, - M_DHP = 0xde, - M_EXP = 0xdf, - - M_APP0 = 0xe0, - M_APP1 = 0xe1, - M_APP2 = 0xe2, - M_APP3 = 0xe3, - M_APP4 = 0xe4, - M_APP5 = 0xe5, - M_APP6 = 0xe6, - M_APP7 = 0xe7, - M_APP8 = 0xe8, - M_APP9 = 0xe9, - M_APP10 = 0xea, - M_APP11 = 0xeb, - M_APP12 = 0xec, - M_APP13 = 0xed, - M_APP14 = 0xee, - M_APP15 = 0xef, - - M_JPG0 = 0xf0, - M_JPG13 = 0xfd, - M_COM = 0xfe, - - M_TEM = 0x01, - - M_ERROR = 0x100 -} JPEG_MARKER; - - -/* Private state */ - -typedef struct { - struct jpeg_marker_writer pub; /* public fields */ - - unsigned int last_restart_interval; /* last DRI value emitted; 0 after SOI */ -} my_marker_writer; - -typedef my_marker_writer * my_marker_ptr; - - -/* - * Basic output routines. - * - * Note that we do not support suspension while writing a marker. - * Therefore, an application using suspension must ensure that there is - * enough buffer space for the initial markers (typ. 600-700 bytes) before - * calling jpeg_start_compress, and enough space to write the trailing EOI - * (a few bytes) before calling jpeg_finish_compress. Multipass compression - * modes are not supported at all with suspension, so those two are the only - * points where markers will be written. - */ - -LOCAL(void) -emit_byte (j_compress_ptr cinfo, int val) -/* Emit a byte */ -{ - struct jpeg_destination_mgr * dest = cinfo->dest; - - *(dest->next_output_byte)++ = (JOCTET) val; - if (--dest->free_in_buffer == 0) { - if (! (*dest->empty_output_buffer) (cinfo)) - ERREXIT(cinfo, JERR_CANT_SUSPEND); - } -} - - -LOCAL(void) -emit_marker (j_compress_ptr cinfo, JPEG_MARKER mark) -/* Emit a marker code */ -{ - emit_byte(cinfo, 0xFF); - emit_byte(cinfo, (int) mark); -} - - -LOCAL(void) -emit_2bytes (j_compress_ptr cinfo, int value) -/* Emit a 2-byte integer; these are always MSB first in JPEG files */ -{ - emit_byte(cinfo, (value >> 8) & 0xFF); - emit_byte(cinfo, value & 0xFF); -} - - -/* - * Routines to write specific marker types. - */ - -LOCAL(int) -emit_dqt (j_compress_ptr cinfo, int index) -/* Emit a DQT marker */ -/* Returns the precision used (0 = 8bits, 1 = 16bits) for baseline checking */ -{ - JQUANT_TBL * qtbl = cinfo->quant_tbl_ptrs[index]; - int prec; - int i; - - if (qtbl == NULL) - ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, index); - - prec = 0; - for (i = 0; i < DCTSIZE2; i++) { - if (qtbl->quantval[i] > 255) - prec = 1; - } - - if (! qtbl->sent_table) { - emit_marker(cinfo, M_DQT); - - emit_2bytes(cinfo, prec ? DCTSIZE2*2 + 1 + 2 : DCTSIZE2 + 1 + 2); - - emit_byte(cinfo, index + (prec<<4)); - - for (i = 0; i < DCTSIZE2; i++) { - /* The table entries must be emitted in zigzag order. */ - unsigned int qval = qtbl->quantval[jpeg_natural_order[i]]; - if (prec) - emit_byte(cinfo, (int) (qval >> 8)); - emit_byte(cinfo, (int) (qval & 0xFF)); - } - - qtbl->sent_table = TRUE; - } - - return prec; -} - - -LOCAL(void) -emit_dht (j_compress_ptr cinfo, int index, boolean is_ac) -/* Emit a DHT marker */ -{ - JHUFF_TBL * htbl; - int length, i; - - if (is_ac) { - htbl = cinfo->ac_huff_tbl_ptrs[index]; - index += 0x10; /* output index has AC bit set */ - } else { - htbl = cinfo->dc_huff_tbl_ptrs[index]; - } - - if (htbl == NULL) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, index); - - if (! htbl->sent_table) { - emit_marker(cinfo, M_DHT); - - length = 0; - for (i = 1; i <= 16; i++) - length += htbl->bits[i]; - - emit_2bytes(cinfo, length + 2 + 1 + 16); - emit_byte(cinfo, index); - - for (i = 1; i <= 16; i++) - emit_byte(cinfo, htbl->bits[i]); - - for (i = 0; i < length; i++) - emit_byte(cinfo, htbl->huffval[i]); - - htbl->sent_table = TRUE; - } -} - - -LOCAL(void) -emit_dac (j_compress_ptr cinfo) -/* Emit a DAC marker */ -/* Since the useful info is so small, we want to emit all the tables in */ -/* one DAC marker. Therefore this routine does its own scan of the table. */ -{ -#ifdef C_ARITH_CODING_SUPPORTED - char dc_in_use[NUM_ARITH_TBLS]; - char ac_in_use[NUM_ARITH_TBLS]; - int length, i; - jpeg_component_info *compptr; - - for (i = 0; i < NUM_ARITH_TBLS; i++) - dc_in_use[i] = ac_in_use[i] = 0; - - for (i = 0; i < cinfo->comps_in_scan; i++) { - compptr = cinfo->cur_comp_info[i]; - dc_in_use[compptr->dc_tbl_no] = 1; - ac_in_use[compptr->ac_tbl_no] = 1; - } - - length = 0; - for (i = 0; i < NUM_ARITH_TBLS; i++) - length += dc_in_use[i] + ac_in_use[i]; - - emit_marker(cinfo, M_DAC); - - emit_2bytes(cinfo, length*2 + 2); - - for (i = 0; i < NUM_ARITH_TBLS; i++) { - if (dc_in_use[i]) { - emit_byte(cinfo, i); - emit_byte(cinfo, cinfo->arith_dc_L[i] + (cinfo->arith_dc_U[i]<<4)); - } - if (ac_in_use[i]) { - emit_byte(cinfo, i + 0x10); - emit_byte(cinfo, cinfo->arith_ac_K[i]); - } - } -#endif /* C_ARITH_CODING_SUPPORTED */ -} - - -LOCAL(void) -emit_dri (j_compress_ptr cinfo) -/* Emit a DRI marker */ -{ - emit_marker(cinfo, M_DRI); - - emit_2bytes(cinfo, 4); /* fixed length */ - - emit_2bytes(cinfo, (int) cinfo->restart_interval); -} - - -LOCAL(void) -emit_sof (j_compress_ptr cinfo, JPEG_MARKER code) -/* Emit a SOF marker */ -{ - int ci; - jpeg_component_info *compptr; - - emit_marker(cinfo, code); - - emit_2bytes(cinfo, 3 * cinfo->num_components + 2 + 5 + 1); /* length */ - - /* Make sure image isn't bigger than SOF field can handle */ - if ((long) cinfo->image_height > 65535L || - (long) cinfo->image_width > 65535L) - ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) 65535); - - emit_byte(cinfo, cinfo->data_precision); - emit_2bytes(cinfo, (int) cinfo->image_height); - emit_2bytes(cinfo, (int) cinfo->image_width); - - emit_byte(cinfo, cinfo->num_components); - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - emit_byte(cinfo, compptr->component_id); - emit_byte(cinfo, (compptr->h_samp_factor << 4) + compptr->v_samp_factor); - emit_byte(cinfo, compptr->quant_tbl_no); - } -} - - -LOCAL(void) -emit_sos (j_compress_ptr cinfo) -/* Emit a SOS marker */ -{ - int i, td, ta; - jpeg_component_info *compptr; - - emit_marker(cinfo, M_SOS); - - emit_2bytes(cinfo, 2 * cinfo->comps_in_scan + 2 + 1 + 3); /* length */ - - emit_byte(cinfo, cinfo->comps_in_scan); - - for (i = 0; i < cinfo->comps_in_scan; i++) { - compptr = cinfo->cur_comp_info[i]; - emit_byte(cinfo, compptr->component_id); - td = compptr->dc_tbl_no; - ta = compptr->ac_tbl_no; - if (cinfo->progressive_mode) { - /* Progressive mode: only DC or only AC tables are used in one scan; - * furthermore, Huffman coding of DC refinement uses no table at all. - * We emit 0 for unused field(s); this is recommended by the P&M text - * but does not seem to be specified in the standard. - */ - if (cinfo->Ss == 0) { - ta = 0; /* DC scan */ - if (cinfo->Ah != 0 && !cinfo->arith_code) - td = 0; /* no DC table either */ - } else { - td = 0; /* AC scan */ - } - } - emit_byte(cinfo, (td << 4) + ta); - } - - emit_byte(cinfo, cinfo->Ss); - emit_byte(cinfo, cinfo->Se); - emit_byte(cinfo, (cinfo->Ah << 4) + cinfo->Al); -} - - -LOCAL(void) -emit_jfif_app0 (j_compress_ptr cinfo) -/* Emit a JFIF-compliant APP0 marker */ -{ - /* - * Length of APP0 block (2 bytes) - * Block ID (4 bytes - ASCII "JFIF") - * Zero byte (1 byte to terminate the ID string) - * Version Major, Minor (2 bytes - major first) - * Units (1 byte - 0x00 = none, 0x01 = inch, 0x02 = cm) - * Xdpu (2 bytes - dots per unit horizontal) - * Ydpu (2 bytes - dots per unit vertical) - * Thumbnail X size (1 byte) - * Thumbnail Y size (1 byte) - */ - - emit_marker(cinfo, M_APP0); - - emit_2bytes(cinfo, 2 + 4 + 1 + 2 + 1 + 2 + 2 + 1 + 1); /* length */ - - emit_byte(cinfo, 0x4A); /* Identifier: ASCII "JFIF" */ - emit_byte(cinfo, 0x46); - emit_byte(cinfo, 0x49); - emit_byte(cinfo, 0x46); - emit_byte(cinfo, 0); - emit_byte(cinfo, cinfo->JFIF_major_version); /* Version fields */ - emit_byte(cinfo, cinfo->JFIF_minor_version); - emit_byte(cinfo, cinfo->density_unit); /* Pixel size information */ - emit_2bytes(cinfo, (int) cinfo->X_density); - emit_2bytes(cinfo, (int) cinfo->Y_density); - emit_byte(cinfo, 0); /* No thumbnail image */ - emit_byte(cinfo, 0); -} - - -LOCAL(void) -emit_adobe_app14 (j_compress_ptr cinfo) -/* Emit an Adobe APP14 marker */ -{ - /* - * Length of APP14 block (2 bytes) - * Block ID (5 bytes - ASCII "Adobe") - * Version Number (2 bytes - currently 100) - * Flags0 (2 bytes - currently 0) - * Flags1 (2 bytes - currently 0) - * Color transform (1 byte) - * - * Although Adobe TN 5116 mentions Version = 101, all the Adobe files - * now in circulation seem to use Version = 100, so that's what we write. - * - * We write the color transform byte as 1 if the JPEG color space is - * YCbCr, 2 if it's YCCK, 0 otherwise. Adobe's definition has to do with - * whether the encoder performed a transformation, which is pretty useless. - */ - - emit_marker(cinfo, M_APP14); - - emit_2bytes(cinfo, 2 + 5 + 2 + 2 + 2 + 1); /* length */ - - emit_byte(cinfo, 0x41); /* Identifier: ASCII "Adobe" */ - emit_byte(cinfo, 0x64); - emit_byte(cinfo, 0x6F); - emit_byte(cinfo, 0x62); - emit_byte(cinfo, 0x65); - emit_2bytes(cinfo, 100); /* Version */ - emit_2bytes(cinfo, 0); /* Flags0 */ - emit_2bytes(cinfo, 0); /* Flags1 */ - switch (cinfo->jpeg_color_space) { - case JCS_YCbCr: - emit_byte(cinfo, 1); /* Color transform = 1 */ - break; - case JCS_YCCK: - emit_byte(cinfo, 2); /* Color transform = 2 */ - break; - default: - emit_byte(cinfo, 0); /* Color transform = 0 */ - break; - } -} - - -/* - * These routines allow writing an arbitrary marker with parameters. - * The only intended use is to emit COM or APPn markers after calling - * write_file_header and before calling write_frame_header. - * Other uses are not guaranteed to produce desirable results. - * Counting the parameter bytes properly is the caller's responsibility. - */ - -METHODDEF(void) -write_marker_header (j_compress_ptr cinfo, int marker, unsigned int datalen) -/* Emit an arbitrary marker header */ -{ - if (datalen > (unsigned int) 65533) /* safety check */ - ERREXIT(cinfo, JERR_BAD_LENGTH); - - emit_marker(cinfo, (JPEG_MARKER) marker); - - emit_2bytes(cinfo, (int) (datalen + 2)); /* total length */ -} - -METHODDEF(void) -write_marker_byte (j_compress_ptr cinfo, int val) -/* Emit one byte of marker parameters following write_marker_header */ -{ - emit_byte(cinfo, val); -} - - -/* - * Write datastream header. - * This consists of an SOI and optional APPn markers. - * We recommend use of the JFIF marker, but not the Adobe marker, - * when using YCbCr or grayscale data. The JFIF marker should NOT - * be used for any other JPEG colorspace. The Adobe marker is helpful - * to distinguish RGB, CMYK, and YCCK colorspaces. - * Note that an application can write additional header markers after - * jpeg_start_compress returns. - */ - -METHODDEF(void) -write_file_header (j_compress_ptr cinfo) -{ - my_marker_ptr marker = (my_marker_ptr) cinfo->marker; - - emit_marker(cinfo, M_SOI); /* first the SOI */ - - /* SOI is defined to reset restart interval to 0 */ - marker->last_restart_interval = 0; - - if (cinfo->write_JFIF_header) /* next an optional JFIF APP0 */ - emit_jfif_app0(cinfo); - if (cinfo->write_Adobe_marker) /* next an optional Adobe APP14 */ - emit_adobe_app14(cinfo); -} - - -/* - * Write frame header. - * This consists of DQT and SOFn markers. - * Note that we do not emit the SOF until we have emitted the DQT(s). - * This avoids compatibility problems with incorrect implementations that - * try to error-check the quant table numbers as soon as they see the SOF. - */ - -METHODDEF(void) -write_frame_header (j_compress_ptr cinfo) -{ - int ci, prec; - boolean is_baseline; - jpeg_component_info *compptr; - - /* Emit DQT for each quantization table. - * Note that emit_dqt() suppresses any duplicate tables. - */ - prec = 0; - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - prec += emit_dqt(cinfo, compptr->quant_tbl_no); - } - /* now prec is nonzero iff there are any 16-bit quant tables. */ - - /* Check for a non-baseline specification. - * Note we assume that Huffman table numbers won't be changed later. - */ - if (cinfo->arith_code || cinfo->progressive_mode || - cinfo->data_precision != 8) { - is_baseline = FALSE; - } else { - is_baseline = TRUE; - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - if (compptr->dc_tbl_no > 1 || compptr->ac_tbl_no > 1) - is_baseline = FALSE; - } - if (prec && is_baseline) { - is_baseline = FALSE; - /* If it's baseline except for quantizer size, warn the user */ - TRACEMS(cinfo, 0, JTRC_16BIT_TABLES); - } - } - - /* Emit the proper SOF marker */ - if (cinfo->arith_code) { - emit_sof(cinfo, M_SOF9); /* SOF code for arithmetic coding */ - } else { - if (cinfo->progressive_mode) - emit_sof(cinfo, M_SOF2); /* SOF code for progressive Huffman */ - else if (is_baseline) - emit_sof(cinfo, M_SOF0); /* SOF code for baseline implementation */ - else - emit_sof(cinfo, M_SOF1); /* SOF code for non-baseline Huffman file */ - } -} - - -/* - * Write scan header. - * This consists of DHT or DAC markers, optional DRI, and SOS. - * Compressed data will be written following the SOS. - */ - -METHODDEF(void) -write_scan_header (j_compress_ptr cinfo) -{ - my_marker_ptr marker = (my_marker_ptr) cinfo->marker; - int i; - jpeg_component_info *compptr; - - if (cinfo->arith_code) { - /* Emit arith conditioning info. We may have some duplication - * if the file has multiple scans, but it's so small it's hardly - * worth worrying about. - */ - emit_dac(cinfo); - } else { - /* Emit Huffman tables. - * Note that emit_dht() suppresses any duplicate tables. - */ - for (i = 0; i < cinfo->comps_in_scan; i++) { - compptr = cinfo->cur_comp_info[i]; - if (cinfo->progressive_mode) { - /* Progressive mode: only DC or only AC tables are used in one scan */ - if (cinfo->Ss == 0) { - if (cinfo->Ah == 0) /* DC needs no table for refinement scan */ - emit_dht(cinfo, compptr->dc_tbl_no, FALSE); - } else { - emit_dht(cinfo, compptr->ac_tbl_no, TRUE); - } - } else { - /* Sequential mode: need both DC and AC tables */ - emit_dht(cinfo, compptr->dc_tbl_no, FALSE); - emit_dht(cinfo, compptr->ac_tbl_no, TRUE); - } - } - } - - /* Emit DRI if required --- note that DRI value could change for each scan. - * We avoid wasting space with unnecessary DRIs, however. - */ - if (cinfo->restart_interval != marker->last_restart_interval) { - emit_dri(cinfo); - marker->last_restart_interval = cinfo->restart_interval; - } - - emit_sos(cinfo); -} - - -/* - * Write datastream trailer. - */ - -METHODDEF(void) -write_file_trailer (j_compress_ptr cinfo) -{ - emit_marker(cinfo, M_EOI); -} - - -/* - * Write an abbreviated table-specification datastream. - * This consists of SOI, DQT and DHT tables, and EOI. - * Any table that is defined and not marked sent_table = TRUE will be - * emitted. Note that all tables will be marked sent_table = TRUE at exit. - */ - -METHODDEF(void) -write_tables_only (j_compress_ptr cinfo) -{ - int i; - - emit_marker(cinfo, M_SOI); - - for (i = 0; i < NUM_QUANT_TBLS; i++) { - if (cinfo->quant_tbl_ptrs[i] != NULL) - (void) emit_dqt(cinfo, i); - } - - if (! cinfo->arith_code) { - for (i = 0; i < NUM_HUFF_TBLS; i++) { - if (cinfo->dc_huff_tbl_ptrs[i] != NULL) - emit_dht(cinfo, i, FALSE); - if (cinfo->ac_huff_tbl_ptrs[i] != NULL) - emit_dht(cinfo, i, TRUE); - } - } - - emit_marker(cinfo, M_EOI); -} - - -/* - * Initialize the marker writer module. - */ - -GLOBAL(void) -jinit_marker_writer (j_compress_ptr cinfo) -{ - my_marker_ptr marker; - - /* Create the subobject */ - marker = (my_marker_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_marker_writer)); - cinfo->marker = (struct jpeg_marker_writer *) marker; - /* Initialize method pointers */ - marker->pub.write_file_header = write_file_header; - marker->pub.write_frame_header = write_frame_header; - marker->pub.write_scan_header = write_scan_header; - marker->pub.write_file_trailer = write_file_trailer; - marker->pub.write_tables_only = write_tables_only; - marker->pub.write_marker_header = write_marker_header; - marker->pub.write_marker_byte = write_marker_byte; - /* Initialize private state */ - marker->last_restart_interval = 0; -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jcmaster.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jcmaster.c deleted file mode 100644 index e61138b1d..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jcmaster.c +++ /dev/null @@ -1,590 +0,0 @@ -/* - * jcmaster.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains master control logic for the JPEG compressor. - * These routines are concerned with parameter validation, initial setup, - * and inter-pass control (determining the number of passes and the work - * to be done in each pass). - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Private state */ - -typedef enum { - main_pass, /* input data, also do first output step */ - huff_opt_pass, /* Huffman code optimization pass */ - output_pass /* data output pass */ -} c_pass_type; - -typedef struct { - struct jpeg_comp_master pub; /* public fields */ - - c_pass_type pass_type; /* the type of the current pass */ - - int pass_number; /* # of passes completed */ - int total_passes; /* total # of passes needed */ - - int scan_number; /* current index in scan_info[] */ -} my_comp_master; - -typedef my_comp_master * my_master_ptr; - - -/* - * Support routines that do various essential calculations. - */ - -LOCAL(void) -initial_setup (j_compress_ptr cinfo) -/* Do computations that are needed before master selection phase */ -{ - int ci; - jpeg_component_info *compptr; - long samplesperrow; - JDIMENSION jd_samplesperrow; - - /* Sanity check on image dimensions */ - if (cinfo->image_height <= 0 || cinfo->image_width <= 0 - || cinfo->num_components <= 0 || cinfo->input_components <= 0) - ERREXIT(cinfo, JERR_EMPTY_IMAGE); - - /* Make sure image isn't bigger than I can handle */ - if ((long) cinfo->image_height > (long) JPEG_MAX_DIMENSION || - (long) cinfo->image_width > (long) JPEG_MAX_DIMENSION) - ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION); - - /* Width of an input scanline must be representable as JDIMENSION. */ - samplesperrow = (long) cinfo->image_width * (long) cinfo->input_components; - jd_samplesperrow = (JDIMENSION) samplesperrow; - if ((long) jd_samplesperrow != samplesperrow) - ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); - - /* For now, precision must match compiled-in value... */ - if (cinfo->data_precision != BITS_IN_JSAMPLE) - ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); - - /* Check that number of components won't exceed internal array sizes */ - if (cinfo->num_components > MAX_COMPONENTS) - ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, - MAX_COMPONENTS); - - /* Compute maximum sampling factors; check factor validity */ - cinfo->max_h_samp_factor = 1; - cinfo->max_v_samp_factor = 1; - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - if (compptr->h_samp_factor<=0 || compptr->h_samp_factor>MAX_SAMP_FACTOR || - compptr->v_samp_factor<=0 || compptr->v_samp_factor>MAX_SAMP_FACTOR) - ERREXIT(cinfo, JERR_BAD_SAMPLING); - cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor, - compptr->h_samp_factor); - cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor, - compptr->v_samp_factor); - } - - /* Compute dimensions of components */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Fill in the correct component_index value; don't rely on application */ - compptr->component_index = ci; - /* For compression, we never do DCT scaling. */ - compptr->DCT_scaled_size = DCTSIZE; - /* Size in DCT blocks */ - compptr->width_in_blocks = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, - (long) (cinfo->max_h_samp_factor * DCTSIZE)); - compptr->height_in_blocks = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, - (long) (cinfo->max_v_samp_factor * DCTSIZE)); - /* Size in samples */ - compptr->downsampled_width = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, - (long) cinfo->max_h_samp_factor); - compptr->downsampled_height = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, - (long) cinfo->max_v_samp_factor); - /* Mark component needed (this flag isn't actually used for compression) */ - compptr->component_needed = TRUE; - } - - /* Compute number of fully interleaved MCU rows (number of times that - * main controller will call coefficient controller). - */ - cinfo->total_iMCU_rows = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height, - (long) (cinfo->max_v_samp_factor*DCTSIZE)); -} - - -#ifdef C_MULTISCAN_FILES_SUPPORTED - -LOCAL(void) -validate_script (j_compress_ptr cinfo) -/* Verify that the scan script in cinfo->scan_info[] is valid; also - * determine whether it uses progressive JPEG, and set cinfo->progressive_mode. - */ -{ - const jpeg_scan_info * scanptr; - int scanno, ncomps, ci, coefi, thisi; - int Ss, Se, Ah, Al; - boolean component_sent[MAX_COMPONENTS]; -#ifdef C_PROGRESSIVE_SUPPORTED - int * last_bitpos_ptr; - int last_bitpos[MAX_COMPONENTS][DCTSIZE2]; - /* -1 until that coefficient has been seen; then last Al for it */ -#endif - - if (cinfo->num_scans <= 0) - ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, 0); - - /* For sequential JPEG, all scans must have Ss=0, Se=DCTSIZE2-1; - * for progressive JPEG, no scan can have this. - */ - scanptr = cinfo->scan_info; - if (scanptr->Ss != 0 || scanptr->Se != DCTSIZE2-1) { -#ifdef C_PROGRESSIVE_SUPPORTED - cinfo->progressive_mode = TRUE; - last_bitpos_ptr = & last_bitpos[0][0]; - for (ci = 0; ci < cinfo->num_components; ci++) - for (coefi = 0; coefi < DCTSIZE2; coefi++) - *last_bitpos_ptr++ = -1; -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else { - cinfo->progressive_mode = FALSE; - for (ci = 0; ci < cinfo->num_components; ci++) - component_sent[ci] = FALSE; - } - - for (scanno = 1; scanno <= cinfo->num_scans; scanptr++, scanno++) { - /* Validate component indexes */ - ncomps = scanptr->comps_in_scan; - if (ncomps <= 0 || ncomps > MAX_COMPS_IN_SCAN) - ERREXIT2(cinfo, JERR_COMPONENT_COUNT, ncomps, MAX_COMPS_IN_SCAN); - for (ci = 0; ci < ncomps; ci++) { - thisi = scanptr->component_index[ci]; - if (thisi < 0 || thisi >= cinfo->num_components) - ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno); - /* Components must appear in SOF order within each scan */ - if (ci > 0 && thisi <= scanptr->component_index[ci-1]) - ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno); - } - /* Validate progression parameters */ - Ss = scanptr->Ss; - Se = scanptr->Se; - Ah = scanptr->Ah; - Al = scanptr->Al; - if (cinfo->progressive_mode) { -#ifdef C_PROGRESSIVE_SUPPORTED - /* The JPEG spec simply gives the ranges 0..13 for Ah and Al, but that - * seems wrong: the upper bound ought to depend on data precision. - * Perhaps they really meant 0..N+1 for N-bit precision. - * Here we allow 0..10 for 8-bit data; Al larger than 10 results in - * out-of-range reconstructed DC values during the first DC scan, - * which might cause problems for some decoders. - */ -#if BITS_IN_JSAMPLE == 8 -#define MAX_AH_AL 10 -#else -#define MAX_AH_AL 13 -#endif - if (Ss < 0 || Ss >= DCTSIZE2 || Se < Ss || Se >= DCTSIZE2 || - Ah < 0 || Ah > MAX_AH_AL || Al < 0 || Al > MAX_AH_AL) - ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); - if (Ss == 0) { - if (Se != 0) /* DC and AC together not OK */ - ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); - } else { - if (ncomps != 1) /* AC scans must be for only one component */ - ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); - } - for (ci = 0; ci < ncomps; ci++) { - last_bitpos_ptr = & last_bitpos[scanptr->component_index[ci]][0]; - if (Ss != 0 && last_bitpos_ptr[0] < 0) /* AC without prior DC scan */ - ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); - for (coefi = Ss; coefi <= Se; coefi++) { - if (last_bitpos_ptr[coefi] < 0) { - /* first scan of this coefficient */ - if (Ah != 0) - ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); - } else { - /* not first scan */ - if (Ah != last_bitpos_ptr[coefi] || Al != Ah-1) - ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); - } - last_bitpos_ptr[coefi] = Al; - } - } -#endif - } else { - /* For sequential JPEG, all progression parameters must be these: */ - if (Ss != 0 || Se != DCTSIZE2-1 || Ah != 0 || Al != 0) - ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); - /* Make sure components are not sent twice */ - for (ci = 0; ci < ncomps; ci++) { - thisi = scanptr->component_index[ci]; - if (component_sent[thisi]) - ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno); - component_sent[thisi] = TRUE; - } - } - } - - /* Now verify that everything got sent. */ - if (cinfo->progressive_mode) { -#ifdef C_PROGRESSIVE_SUPPORTED - /* For progressive mode, we only check that at least some DC data - * got sent for each component; the spec does not require that all bits - * of all coefficients be transmitted. Would it be wiser to enforce - * transmission of all coefficient bits?? - */ - for (ci = 0; ci < cinfo->num_components; ci++) { - if (last_bitpos[ci][0] < 0) - ERREXIT(cinfo, JERR_MISSING_DATA); - } -#endif - } else { - for (ci = 0; ci < cinfo->num_components; ci++) { - if (! component_sent[ci]) - ERREXIT(cinfo, JERR_MISSING_DATA); - } - } -} - -#endif /* C_MULTISCAN_FILES_SUPPORTED */ - - -LOCAL(void) -select_scan_parameters (j_compress_ptr cinfo) -/* Set up the scan parameters for the current scan */ -{ - int ci; - -#ifdef C_MULTISCAN_FILES_SUPPORTED - if (cinfo->scan_info != NULL) { - /* Prepare for current scan --- the script is already validated */ - my_master_ptr master = (my_master_ptr) cinfo->master; - const jpeg_scan_info * scanptr = cinfo->scan_info + master->scan_number; - - cinfo->comps_in_scan = scanptr->comps_in_scan; - for (ci = 0; ci < scanptr->comps_in_scan; ci++) { - cinfo->cur_comp_info[ci] = - &cinfo->comp_info[scanptr->component_index[ci]]; - } - cinfo->Ss = scanptr->Ss; - cinfo->Se = scanptr->Se; - cinfo->Ah = scanptr->Ah; - cinfo->Al = scanptr->Al; - } - else -#endif - { - /* Prepare for single sequential-JPEG scan containing all components */ - if (cinfo->num_components > MAX_COMPS_IN_SCAN) - ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, - MAX_COMPS_IN_SCAN); - cinfo->comps_in_scan = cinfo->num_components; - for (ci = 0; ci < cinfo->num_components; ci++) { - cinfo->cur_comp_info[ci] = &cinfo->comp_info[ci]; - } - cinfo->Ss = 0; - cinfo->Se = DCTSIZE2-1; - cinfo->Ah = 0; - cinfo->Al = 0; - } -} - - -LOCAL(void) -per_scan_setup (j_compress_ptr cinfo) -/* Do computations that are needed before processing a JPEG scan */ -/* cinfo->comps_in_scan and cinfo->cur_comp_info[] are already set */ -{ - int ci, mcublks, tmp; - jpeg_component_info *compptr; - - if (cinfo->comps_in_scan == 1) { - - /* Noninterleaved (single-component) scan */ - compptr = cinfo->cur_comp_info[0]; - - /* Overall image size in MCUs */ - cinfo->MCUs_per_row = compptr->width_in_blocks; - cinfo->MCU_rows_in_scan = compptr->height_in_blocks; - - /* For noninterleaved scan, always one block per MCU */ - compptr->MCU_width = 1; - compptr->MCU_height = 1; - compptr->MCU_blocks = 1; - compptr->MCU_sample_width = DCTSIZE; - compptr->last_col_width = 1; - /* For noninterleaved scans, it is convenient to define last_row_height - * as the number of block rows present in the last iMCU row. - */ - tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor); - if (tmp == 0) tmp = compptr->v_samp_factor; - compptr->last_row_height = tmp; - - /* Prepare array describing MCU composition */ - cinfo->blocks_in_MCU = 1; - cinfo->MCU_membership[0] = 0; - - } else { - - /* Interleaved (multi-component) scan */ - if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN) - ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan, - MAX_COMPS_IN_SCAN); - - /* Overall image size in MCUs */ - cinfo->MCUs_per_row = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width, - (long) (cinfo->max_h_samp_factor*DCTSIZE)); - cinfo->MCU_rows_in_scan = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height, - (long) (cinfo->max_v_samp_factor*DCTSIZE)); - - cinfo->blocks_in_MCU = 0; - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - /* Sampling factors give # of blocks of component in each MCU */ - compptr->MCU_width = compptr->h_samp_factor; - compptr->MCU_height = compptr->v_samp_factor; - compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height; - compptr->MCU_sample_width = compptr->MCU_width * DCTSIZE; - /* Figure number of non-dummy blocks in last MCU column & row */ - tmp = (int) (compptr->width_in_blocks % compptr->MCU_width); - if (tmp == 0) tmp = compptr->MCU_width; - compptr->last_col_width = tmp; - tmp = (int) (compptr->height_in_blocks % compptr->MCU_height); - if (tmp == 0) tmp = compptr->MCU_height; - compptr->last_row_height = tmp; - /* Prepare array describing MCU composition */ - mcublks = compptr->MCU_blocks; - if (cinfo->blocks_in_MCU + mcublks > C_MAX_BLOCKS_IN_MCU) - ERREXIT(cinfo, JERR_BAD_MCU_SIZE); - while (mcublks-- > 0) { - cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci; - } - } - - } - - /* Convert restart specified in rows to actual MCU count. */ - /* Note that count must fit in 16 bits, so we provide limiting. */ - if (cinfo->restart_in_rows > 0) { - long nominal = (long) cinfo->restart_in_rows * (long) cinfo->MCUs_per_row; - cinfo->restart_interval = (unsigned int) MIN(nominal, 65535L); - } -} - - -/* - * Per-pass setup. - * This is called at the beginning of each pass. We determine which modules - * will be active during this pass and give them appropriate start_pass calls. - * We also set is_last_pass to indicate whether any more passes will be - * required. - */ - -METHODDEF(void) -prepare_for_pass (j_compress_ptr cinfo) -{ - my_master_ptr master = (my_master_ptr) cinfo->master; - - switch (master->pass_type) { - case main_pass: - /* Initial pass: will collect input data, and do either Huffman - * optimization or data output for the first scan. - */ - select_scan_parameters(cinfo); - per_scan_setup(cinfo); - if (! cinfo->raw_data_in) { - (*cinfo->cconvert->start_pass) (cinfo); - (*cinfo->downsample->start_pass) (cinfo); - (*cinfo->prep->start_pass) (cinfo, JBUF_PASS_THRU); - } - (*cinfo->fdct->start_pass) (cinfo); - (*cinfo->entropy->start_pass) (cinfo, cinfo->optimize_coding); - (*cinfo->coef->start_pass) (cinfo, - (master->total_passes > 1 ? - JBUF_SAVE_AND_PASS : JBUF_PASS_THRU)); - (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU); - if (cinfo->optimize_coding) { - /* No immediate data output; postpone writing frame/scan headers */ - master->pub.call_pass_startup = FALSE; - } else { - /* Will write frame/scan headers at first jpeg_write_scanlines call */ - master->pub.call_pass_startup = TRUE; - } - break; -#ifdef ENTROPY_OPT_SUPPORTED - case huff_opt_pass: - /* Do Huffman optimization for a scan after the first one. */ - select_scan_parameters(cinfo); - per_scan_setup(cinfo); - if (cinfo->Ss != 0 || cinfo->Ah == 0 || cinfo->arith_code) { - (*cinfo->entropy->start_pass) (cinfo, TRUE); - (*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST); - master->pub.call_pass_startup = FALSE; - break; - } - /* Special case: Huffman DC refinement scans need no Huffman table - * and therefore we can skip the optimization pass for them. - */ - master->pass_type = output_pass; - master->pass_number++; - /*FALLTHROUGH*/ -#endif - case output_pass: - /* Do a data-output pass. */ - /* We need not repeat per-scan setup if prior optimization pass did it. */ - if (! cinfo->optimize_coding) { - select_scan_parameters(cinfo); - per_scan_setup(cinfo); - } - (*cinfo->entropy->start_pass) (cinfo, FALSE); - (*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST); - /* We emit frame/scan headers now */ - if (master->scan_number == 0) - (*cinfo->marker->write_frame_header) (cinfo); - (*cinfo->marker->write_scan_header) (cinfo); - master->pub.call_pass_startup = FALSE; - break; - default: - ERREXIT(cinfo, JERR_NOT_COMPILED); - } - - master->pub.is_last_pass = (master->pass_number == master->total_passes-1); - - /* Set up progress monitor's pass info if present */ - if (cinfo->progress != NULL) { - cinfo->progress->completed_passes = master->pass_number; - cinfo->progress->total_passes = master->total_passes; - } -} - - -/* - * Special start-of-pass hook. - * This is called by jpeg_write_scanlines if call_pass_startup is TRUE. - * In single-pass processing, we need this hook because we don't want to - * write frame/scan headers during jpeg_start_compress; we want to let the - * application write COM markers etc. between jpeg_start_compress and the - * jpeg_write_scanlines loop. - * In multi-pass processing, this routine is not used. - */ - -METHODDEF(void) -pass_startup (j_compress_ptr cinfo) -{ - cinfo->master->call_pass_startup = FALSE; /* reset flag so call only once */ - - (*cinfo->marker->write_frame_header) (cinfo); - (*cinfo->marker->write_scan_header) (cinfo); -} - - -/* - * Finish up at end of pass. - */ - -METHODDEF(void) -finish_pass_master (j_compress_ptr cinfo) -{ - my_master_ptr master = (my_master_ptr) cinfo->master; - - /* The entropy coder always needs an end-of-pass call, - * either to analyze statistics or to flush its output buffer. - */ - (*cinfo->entropy->finish_pass) (cinfo); - - /* Update state for next pass */ - switch (master->pass_type) { - case main_pass: - /* next pass is either output of scan 0 (after optimization) - * or output of scan 1 (if no optimization). - */ - master->pass_type = output_pass; - if (! cinfo->optimize_coding) - master->scan_number++; - break; - case huff_opt_pass: - /* next pass is always output of current scan */ - master->pass_type = output_pass; - break; - case output_pass: - /* next pass is either optimization or output of next scan */ - if (cinfo->optimize_coding) - master->pass_type = huff_opt_pass; - master->scan_number++; - break; - } - - master->pass_number++; -} - - -/* - * Initialize master compression control. - */ - -GLOBAL(void) -jinit_c_master_control (j_compress_ptr cinfo, boolean transcode_only) -{ - my_master_ptr master; - - master = (my_master_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_comp_master)); - cinfo->master = (struct jpeg_comp_master *) master; - master->pub.prepare_for_pass = prepare_for_pass; - master->pub.pass_startup = pass_startup; - master->pub.finish_pass = finish_pass_master; - master->pub.is_last_pass = FALSE; - - /* Validate parameters, determine derived values */ - initial_setup(cinfo); - - if (cinfo->scan_info != NULL) { -#ifdef C_MULTISCAN_FILES_SUPPORTED - validate_script(cinfo); -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else { - cinfo->progressive_mode = FALSE; - cinfo->num_scans = 1; - } - - if (cinfo->progressive_mode) /* TEMPORARY HACK ??? */ - cinfo->optimize_coding = TRUE; /* assume default tables no good for progressive mode */ - - /* Initialize my private state */ - if (transcode_only) { - /* no main pass in transcoding */ - if (cinfo->optimize_coding) - master->pass_type = huff_opt_pass; - else - master->pass_type = output_pass; - } else { - /* for normal compression, first pass is always this type: */ - master->pass_type = main_pass; - } - master->scan_number = 0; - master->pass_number = 0; - if (cinfo->optimize_coding) - master->total_passes = cinfo->num_scans * 2; - else - master->total_passes = cinfo->num_scans; -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jcomapi.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jcomapi.c deleted file mode 100644 index 1b1a340c1..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jcomapi.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * jcomapi.c - * - * Copyright (C) 1994-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains application interface routines that are used for both - * compression and decompression. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * Abort processing of a JPEG compression or decompression operation, - * but don't destroy the object itself. - * - * For this, we merely clean up all the nonpermanent memory pools. - * Note that temp files (virtual arrays) are not allowed to belong to - * the permanent pool, so we will be able to close all temp files here. - * Closing a data source or destination, if necessary, is the application's - * responsibility. - */ - -GLOBAL(void) -jpeg_abort (j_common_ptr cinfo) -{ - int pool; - - /* Do nothing if called on a not-initialized or destroyed JPEG object. */ - if (cinfo->mem == NULL) - return; - - /* Releasing pools in reverse order might help avoid fragmentation - * with some (brain-damaged) malloc libraries. - */ - for (pool = JPOOL_NUMPOOLS-1; pool > JPOOL_PERMANENT; pool--) { - (*cinfo->mem->free_pool) (cinfo, pool); - } - - /* Reset overall state for possible reuse of object */ - if (cinfo->is_decompressor) { - cinfo->global_state = DSTATE_START; - /* Try to keep application from accessing now-deleted marker list. - * A bit kludgy to do it here, but this is the most central place. - */ - ((j_decompress_ptr) cinfo)->marker_list = NULL; - } else { - cinfo->global_state = CSTATE_START; - } -} - - -/* - * Destruction of a JPEG object. - * - * Everything gets deallocated except the master jpeg_compress_struct itself - * and the error manager struct. Both of these are supplied by the application - * and must be freed, if necessary, by the application. (Often they are on - * the stack and so don't need to be freed anyway.) - * Closing a data source or destination, if necessary, is the application's - * responsibility. - */ - -GLOBAL(void) -jpeg_destroy (j_common_ptr cinfo) -{ - /* We need only tell the memory manager to release everything. */ - /* NB: mem pointer is NULL if memory mgr failed to initialize. */ - if (cinfo->mem != NULL) - (*cinfo->mem->self_destruct) (cinfo); - cinfo->mem = NULL; /* be safe if jpeg_destroy is called twice */ - cinfo->global_state = 0; /* mark it destroyed */ -} - - -/* - * Convenience routines for allocating quantization and Huffman tables. - * (Would jutils.c be a more reasonable place to put these?) - */ - -GLOBAL(JQUANT_TBL *) -jpeg_alloc_quant_table (j_common_ptr cinfo) -{ - JQUANT_TBL *tbl; - - tbl = (JQUANT_TBL *) - (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JQUANT_TBL)); - tbl->sent_table = FALSE; /* make sure this is false in any new table */ - return tbl; -} - - -GLOBAL(JHUFF_TBL *) -jpeg_alloc_huff_table (j_common_ptr cinfo) -{ - JHUFF_TBL *tbl; - - tbl = (JHUFF_TBL *) - (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JHUFF_TBL)); - tbl->sent_table = FALSE; /* make sure this is false in any new table */ - return tbl; -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.bcc b/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.bcc deleted file mode 100644 index 6538a0fb8..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.bcc +++ /dev/null @@ -1,48 +0,0 @@ -/* jconfig.bcc --- jconfig.h for Borland C (Turbo C) on MS-DOS or OS/2. */ -/* see jconfig.doc for explanations */ - -#define HAVE_PROTOTYPES -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT -/* #define void char */ -/* #define const */ -#undef CHAR_IS_UNSIGNED -#define HAVE_STDDEF_H -#define HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#ifdef __MSDOS__ -#define NEED_FAR_POINTERS /* for small or medium memory model */ -#endif -#undef NEED_SHORT_EXTERNAL_NAMES -#undef INCOMPLETE_TYPES_BROKEN /* this assumes you have -w-stu in CFLAGS */ - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED - -#ifdef __MSDOS__ -#define USE_MSDOS_MEMMGR /* Define this if you use jmemdos.c */ -#define MAX_ALLOC_CHUNK 65520L /* Maximum request to malloc() */ -#define USE_FMEM /* Borland has _fmemcpy() and _fmemset() */ -#endif - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#define TWO_FILE_COMMANDLINE -#define USE_SETMODE /* Borland has setmode() */ -#ifdef __MSDOS__ -#define NEED_SIGNAL_CATCHER /* Define this if you use jmemdos.c */ -#endif -#undef DONT_USE_B_MODE -#undef PROGRESS_REPORT /* optional */ - -#endif /* JPEG_CJPEG_DJPEG */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.cfg b/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.cfg deleted file mode 100644 index 5bc01139d..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.cfg +++ /dev/null @@ -1,44 +0,0 @@ -/* jconfig.cfg --- source file edited by configure script */ -/* see jconfig.doc for explanations */ - -#undef HAVE_PROTOTYPES -#undef HAVE_UNSIGNED_CHAR -#undef HAVE_UNSIGNED_SHORT -#undef void -#undef const -#undef CHAR_IS_UNSIGNED -#undef HAVE_STDDEF_H -#undef HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#undef NEED_FAR_POINTERS -#undef NEED_SHORT_EXTERNAL_NAMES -/* Define this if you get warnings about undefined structures. */ -#undef INCOMPLETE_TYPES_BROKEN - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED -#undef INLINE -/* These are for configuring the JPEG memory manager. */ -#undef DEFAULT_MAX_MEM -#undef NO_MKTEMP - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#undef TWO_FILE_COMMANDLINE -#undef NEED_SIGNAL_CATCHER -#undef DONT_USE_B_MODE - -/* Define this if you want percent-done progress reports from cjpeg/djpeg. */ -#undef PROGRESS_REPORT - -#endif /* JPEG_CJPEG_DJPEG */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.dj b/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.dj deleted file mode 100644 index 7cd1ed520..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.dj +++ /dev/null @@ -1,38 +0,0 @@ -/* jconfig.dj --- jconfig.h for DJGPP (Delorie's GNU C port) on MS-DOS. */ -/* see jconfig.doc for explanations */ - -#define HAVE_PROTOTYPES -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT -/* #define void char */ -/* #define const */ -#undef CHAR_IS_UNSIGNED -#define HAVE_STDDEF_H -#define HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#undef NEED_FAR_POINTERS /* DJGPP uses flat 32-bit addressing */ -#undef NEED_SHORT_EXTERNAL_NAMES -#undef INCOMPLETE_TYPES_BROKEN - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#undef TWO_FILE_COMMANDLINE /* optional */ -#define USE_SETMODE /* Needed to make one-file style work in DJGPP */ -#undef NEED_SIGNAL_CATCHER /* Define this if you use jmemname.c */ -#undef DONT_USE_B_MODE -#undef PROGRESS_REPORT /* optional */ - -#endif /* JPEG_CJPEG_DJPEG */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.doc b/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.doc deleted file mode 100644 index 6e2552ba9..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.doc +++ /dev/null @@ -1,155 +0,0 @@ -/* - * jconfig.doc - * - * Copyright (C) 1991-1994, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file documents the configuration options that are required to - * customize the JPEG software for a particular system. - * - * The actual configuration options for a particular installation are stored - * in jconfig.h. On many machines, jconfig.h can be generated automatically - * or copied from one of the "canned" jconfig files that we supply. But if - * you need to generate a jconfig.h file by hand, this file tells you how. - * - * DO NOT EDIT THIS FILE --- IT WON'T ACCOMPLISH ANYTHING. - * EDIT A COPY NAMED JCONFIG.H. - */ - - -/* - * These symbols indicate the properties of your machine or compiler. - * #define the symbol if yes, #undef it if no. - */ - -/* Does your compiler support function prototypes? - * (If not, you also need to use ansi2knr, see install.doc) - */ -#define HAVE_PROTOTYPES - -/* Does your compiler support the declaration "unsigned char" ? - * How about "unsigned short" ? - */ -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT - -/* Define "void" as "char" if your compiler doesn't know about type void. - * NOTE: be sure to define void such that "void *" represents the most general - * pointer type, e.g., that returned by malloc(). - */ -/* #define void char */ - -/* Define "const" as empty if your compiler doesn't know the "const" keyword. - */ -/* #define const */ - -/* Define this if an ordinary "char" type is unsigned. - * If you're not sure, leaving it undefined will work at some cost in speed. - * If you defined HAVE_UNSIGNED_CHAR then the speed difference is minimal. - */ -#undef CHAR_IS_UNSIGNED - -/* Define this if your system has an ANSI-conforming <stddef.h> file. - */ -#define HAVE_STDDEF_H - -/* Define this if your system has an ANSI-conforming <stdlib.h> file. - */ -#define HAVE_STDLIB_H - -/* Define this if your system does not have an ANSI/SysV <string.h>, - * but does have a BSD-style <strings.h>. - */ -#undef NEED_BSD_STRINGS - -/* Define this if your system does not provide typedef size_t in any of the - * ANSI-standard places (stddef.h, stdlib.h, or stdio.h), but places it in - * <sys/types.h> instead. - */ -#undef NEED_SYS_TYPES_H - -/* For 80x86 machines, you need to define NEED_FAR_POINTERS, - * unless you are using a large-data memory model or 80386 flat-memory mode. - * On less brain-damaged CPUs this symbol must not be defined. - * (Defining this symbol causes large data structures to be referenced through - * "far" pointers and to be allocated with a special version of malloc.) - */ -#undef NEED_FAR_POINTERS - -/* Define this if your linker needs global names to be unique in less - * than the first 15 characters. - */ -#undef NEED_SHORT_EXTERNAL_NAMES - -/* Although a real ANSI C compiler can deal perfectly well with pointers to - * unspecified structures (see "incomplete types" in the spec), a few pre-ANSI - * and pseudo-ANSI compilers get confused. To keep one of these bozos happy, - * define INCOMPLETE_TYPES_BROKEN. This is not recommended unless you - * actually get "missing structure definition" warnings or errors while - * compiling the JPEG code. - */ -#undef INCOMPLETE_TYPES_BROKEN - - -/* - * The following options affect code selection within the JPEG library, - * but they don't need to be visible to applications using the library. - * To minimize application namespace pollution, the symbols won't be - * defined unless JPEG_INTERNALS has been defined. - */ - -#ifdef JPEG_INTERNALS - -/* Define this if your compiler implements ">>" on signed values as a logical - * (unsigned) shift; leave it undefined if ">>" is a signed (arithmetic) shift, - * which is the normal and rational definition. - */ -#undef RIGHT_SHIFT_IS_UNSIGNED - - -#endif /* JPEG_INTERNALS */ - - -/* - * The remaining options do not affect the JPEG library proper, - * but only the sample applications cjpeg/djpeg (see cjpeg.c, djpeg.c). - * Other applications can ignore these. - */ - -#ifdef JPEG_CJPEG_DJPEG - -/* These defines indicate which image (non-JPEG) file formats are allowed. */ - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -/* Define this if you want to name both input and output files on the command - * line, rather than using stdout and optionally stdin. You MUST do this if - * your system can't cope with binary I/O to stdin/stdout. See comments at - * head of cjpeg.c or djpeg.c. - */ -#undef TWO_FILE_COMMANDLINE - -/* Define this if your system needs explicit cleanup of temporary files. - * This is crucial under MS-DOS, where the temporary "files" may be areas - * of extended memory; on most other systems it's not as important. - */ -#undef NEED_SIGNAL_CATCHER - -/* By default, we open image files with fopen(...,"rb") or fopen(...,"wb"). - * This is necessary on systems that distinguish text files from binary files, - * and is harmless on most systems that don't. If you have one of the rare - * systems that complains about the "b" spec, define this symbol. - */ -#undef DONT_USE_B_MODE - -/* Define this if you want percent-done progress reports from cjpeg/djpeg. - */ -#undef PROGRESS_REPORT - - -#endif /* JPEG_CJPEG_DJPEG */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.h b/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.h deleted file mode 100644 index 2f4da14c5..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.h +++ /dev/null @@ -1,45 +0,0 @@ -/* jconfig.vc --- jconfig.h for Microsoft Visual C++ on Windows 95 or NT. */ -/* see jconfig.doc for explanations */ - -#define HAVE_PROTOTYPES -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT -/* #define void char */ -/* #define const */ -#undef CHAR_IS_UNSIGNED -#define HAVE_STDDEF_H -#define HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#undef NEED_FAR_POINTERS /* we presume a 32-bit flat memory model */ -#undef NEED_SHORT_EXTERNAL_NAMES -#undef INCOMPLETE_TYPES_BROKEN - -/* Define "boolean" as unsigned char, not int, per Windows custom */ -#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ -typedef unsigned char boolean; -#endif -#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ - - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#define TWO_FILE_COMMANDLINE /* optional */ -#define USE_SETMODE /* Microsoft has setmode() */ -#undef NEED_SIGNAL_CATCHER -#undef DONT_USE_B_MODE -#undef PROGRESS_REPORT /* optional */ - -#endif /* JPEG_CJPEG_DJPEG */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.mac b/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.mac deleted file mode 100644 index 1db67f5de..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.mac +++ /dev/null @@ -1,43 +0,0 @@ -/* jconfig.mac --- jconfig.h for CodeWarrior on Apple Macintosh */ -/* see jconfig.doc for explanations */ - -#define HAVE_PROTOTYPES -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT -/* #define void char */ -/* #define const */ -#undef CHAR_IS_UNSIGNED -#define HAVE_STDDEF_H -#define HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#undef NEED_FAR_POINTERS -#undef NEED_SHORT_EXTERNAL_NAMES -#undef INCOMPLETE_TYPES_BROKEN - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED - -#define USE_MAC_MEMMGR /* Define this if you use jmemmac.c */ - -#define ALIGN_TYPE long /* Needed for 680x0 Macs */ - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#define USE_CCOMMAND /* Command line reader for Macintosh */ -#define TWO_FILE_COMMANDLINE /* Binary I/O thru stdin/stdout doesn't work */ - -#undef NEED_SIGNAL_CATCHER -#undef DONT_USE_B_MODE -#undef PROGRESS_REPORT /* optional */ - -#endif /* JPEG_CJPEG_DJPEG */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.manx b/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.manx deleted file mode 100644 index 0dbd0b8f5..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.manx +++ /dev/null @@ -1,43 +0,0 @@ -/* jconfig.manx --- jconfig.h for Amiga systems using Manx Aztec C ver 5.x. */ -/* see jconfig.doc for explanations */ - -#define HAVE_PROTOTYPES -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT -/* #define void char */ -/* #define const */ -#undef CHAR_IS_UNSIGNED -#define HAVE_STDDEF_H -#define HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#undef NEED_FAR_POINTERS -#undef NEED_SHORT_EXTERNAL_NAMES -#undef INCOMPLETE_TYPES_BROKEN - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED - -#define TEMP_DIRECTORY "JPEGTMP:" /* recommended setting for Amiga */ - -#define SHORTxSHORT_32 /* produces better DCT code with Aztec C */ - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#define TWO_FILE_COMMANDLINE -#define NEED_SIGNAL_CATCHER -#undef DONT_USE_B_MODE -#undef PROGRESS_REPORT /* optional */ - -#define signal_catcher _abort /* hack for Aztec C naming requirements */ - -#endif /* JPEG_CJPEG_DJPEG */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.mc6 b/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.mc6 deleted file mode 100644 index 549236522..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.mc6 +++ /dev/null @@ -1,52 +0,0 @@ -/* jconfig.mc6 --- jconfig.h for Microsoft C on MS-DOS, version 6.00A & up. */ -/* see jconfig.doc for explanations */ - -#define HAVE_PROTOTYPES -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT -/* #define void char */ -/* #define const */ -#undef CHAR_IS_UNSIGNED -#define HAVE_STDDEF_H -#define HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#define NEED_FAR_POINTERS /* for small or medium memory model */ -#undef NEED_SHORT_EXTERNAL_NAMES -#undef INCOMPLETE_TYPES_BROKEN - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED - -#define USE_MSDOS_MEMMGR /* Define this if you use jmemdos.c */ - -#define MAX_ALLOC_CHUNK 65520L /* Maximum request to malloc() */ - -#define USE_FMEM /* Microsoft has _fmemcpy() and _fmemset() */ - -#define NEED_FHEAPMIN /* far heap management routines are broken */ - -#define SHORTxLCONST_32 /* enable compiler-specific DCT optimization */ -/* Note: the above define is known to improve the code with Microsoft C 6.00A. - * I do not know whether it is good for later compiler versions. - * Please report any info on this point to jpeg-info@uunet.uu.net. - */ - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#define TWO_FILE_COMMANDLINE -#define USE_SETMODE /* Microsoft has setmode() */ -#define NEED_SIGNAL_CATCHER /* Define this if you use jmemdos.c */ -#undef DONT_USE_B_MODE -#undef PROGRESS_REPORT /* optional */ - -#endif /* JPEG_CJPEG_DJPEG */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.sas b/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.sas deleted file mode 100644 index a802dd34a..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.sas +++ /dev/null @@ -1,43 +0,0 @@ -/* jconfig.sas --- jconfig.h for Amiga systems using SAS C 6.0 and up. */ -/* see jconfig.doc for explanations */ - -#define HAVE_PROTOTYPES -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT -/* #define void char */ -/* #define const */ -#undef CHAR_IS_UNSIGNED -#define HAVE_STDDEF_H -#define HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#undef NEED_FAR_POINTERS -#undef NEED_SHORT_EXTERNAL_NAMES -#undef INCOMPLETE_TYPES_BROKEN - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED - -#define TEMP_DIRECTORY "JPEGTMP:" /* recommended setting for Amiga */ - -#define NO_MKTEMP /* SAS C doesn't have mktemp() */ - -#define SHORTxSHORT_32 /* produces better DCT code with SAS C */ - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#define TWO_FILE_COMMANDLINE -#define NEED_SIGNAL_CATCHER -#undef DONT_USE_B_MODE -#undef PROGRESS_REPORT /* optional */ - -#endif /* JPEG_CJPEG_DJPEG */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.st b/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.st deleted file mode 100644 index 796b3c9cf..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.st +++ /dev/null @@ -1,42 +0,0 @@ -/* jconfig.st --- jconfig.h for Atari ST/STE/TT using Pure C or Turbo C. */ -/* see jconfig.doc for explanations */ - -#define HAVE_PROTOTYPES -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT -/* #define void char */ -/* #define const */ -#undef CHAR_IS_UNSIGNED -#define HAVE_STDDEF_H -#define HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#undef NEED_FAR_POINTERS -#undef NEED_SHORT_EXTERNAL_NAMES -#define INCOMPLETE_TYPES_BROKEN /* suppress undefined-structure warnings */ - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED - -#define ALIGN_TYPE long /* apparently double is a weird size? */ - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#define TWO_FILE_COMMANDLINE /* optional -- undef if you like Unix style */ -/* Note: if you undef TWO_FILE_COMMANDLINE, you may need to define - * USE_SETMODE. Some Atari compilers require it, some do not. - */ -#define NEED_SIGNAL_CATCHER /* needed if you use jmemname.c */ -#undef DONT_USE_B_MODE -#undef PROGRESS_REPORT /* optional */ - -#endif /* JPEG_CJPEG_DJPEG */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.vc b/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.vc deleted file mode 100644 index 2f4da14c5..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.vc +++ /dev/null @@ -1,45 +0,0 @@ -/* jconfig.vc --- jconfig.h for Microsoft Visual C++ on Windows 95 or NT. */ -/* see jconfig.doc for explanations */ - -#define HAVE_PROTOTYPES -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT -/* #define void char */ -/* #define const */ -#undef CHAR_IS_UNSIGNED -#define HAVE_STDDEF_H -#define HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#undef NEED_FAR_POINTERS /* we presume a 32-bit flat memory model */ -#undef NEED_SHORT_EXTERNAL_NAMES -#undef INCOMPLETE_TYPES_BROKEN - -/* Define "boolean" as unsigned char, not int, per Windows custom */ -#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ -typedef unsigned char boolean; -#endif -#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ - - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#define TWO_FILE_COMMANDLINE /* optional */ -#define USE_SETMODE /* Microsoft has setmode() */ -#undef NEED_SIGNAL_CATCHER -#undef DONT_USE_B_MODE -#undef PROGRESS_REPORT /* optional */ - -#endif /* JPEG_CJPEG_DJPEG */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.vms b/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.vms deleted file mode 100644 index eb582dc76..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.vms +++ /dev/null @@ -1,37 +0,0 @@ -/* jconfig.vms --- jconfig.h for use on Digital VMS. */ -/* see jconfig.doc for explanations */ - -#define HAVE_PROTOTYPES -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT -/* #define void char */ -/* #define const */ -#undef CHAR_IS_UNSIGNED -#define HAVE_STDDEF_H -#define HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#undef NEED_FAR_POINTERS -#undef NEED_SHORT_EXTERNAL_NAMES -#undef INCOMPLETE_TYPES_BROKEN - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#define TWO_FILE_COMMANDLINE /* Needed on VMS */ -#undef NEED_SIGNAL_CATCHER -#undef DONT_USE_B_MODE -#undef PROGRESS_REPORT /* optional */ - -#endif /* JPEG_CJPEG_DJPEG */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.wat b/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.wat deleted file mode 100644 index d57ceb983..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jconfig.wat +++ /dev/null @@ -1,38 +0,0 @@ -/* jconfig.wat --- jconfig.h for Watcom C/C++ on MS-DOS or OS/2. */ -/* see jconfig.doc for explanations */ - -#define HAVE_PROTOTYPES -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT -/* #define void char */ -/* #define const */ -#define CHAR_IS_UNSIGNED -#define HAVE_STDDEF_H -#define HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#undef NEED_FAR_POINTERS /* Watcom uses flat 32-bit addressing */ -#undef NEED_SHORT_EXTERNAL_NAMES -#undef INCOMPLETE_TYPES_BROKEN - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#undef TWO_FILE_COMMANDLINE /* optional */ -#define USE_SETMODE /* Needed to make one-file style work in Watcom */ -#undef NEED_SIGNAL_CATCHER /* Define this if you use jmemname.c */ -#undef DONT_USE_B_MODE -#undef PROGRESS_REPORT /* optional */ - -#endif /* JPEG_CJPEG_DJPEG */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jcparam.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jcparam.c deleted file mode 100644 index bbd175c8a..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jcparam.c +++ /dev/null @@ -1,610 +0,0 @@ -/* - * jcparam.c - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains optional default-setting code for the JPEG compressor. - * Applications do not have to use this file, but those that don't use it - * must know a lot more about the innards of the JPEG code. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * Quantization table setup routines - */ - -GLOBAL(void) -jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl, - const unsigned int *basic_table, - int scale_factor, boolean force_baseline) -/* Define a quantization table equal to the basic_table times - * a scale factor (given as a percentage). - * If force_baseline is TRUE, the computed quantization table entries - * are limited to 1..255 for JPEG baseline compatibility. - */ -{ - JQUANT_TBL ** qtblptr; - int i; - long temp; - - /* Safety check to ensure start_compress not called yet. */ - if (cinfo->global_state != CSTATE_START) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - if (which_tbl < 0 || which_tbl >= NUM_QUANT_TBLS) - ERREXIT1(cinfo, JERR_DQT_INDEX, which_tbl); - - qtblptr = & cinfo->quant_tbl_ptrs[which_tbl]; - - if (*qtblptr == NULL) - *qtblptr = jpeg_alloc_quant_table((j_common_ptr) cinfo); - - for (i = 0; i < DCTSIZE2; i++) { - temp = ((long) basic_table[i] * scale_factor + 50L) / 100L; - /* limit the values to the valid range */ - if (temp <= 0L) temp = 1L; - if (temp > 32767L) temp = 32767L; /* max quantizer needed for 12 bits */ - if (force_baseline && temp > 255L) - temp = 255L; /* limit to baseline range if requested */ - (*qtblptr)->quantval[i] = (UINT16) temp; - } - - /* Initialize sent_table FALSE so table will be written to JPEG file. */ - (*qtblptr)->sent_table = FALSE; -} - - -GLOBAL(void) -jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor, - boolean force_baseline) -/* Set or change the 'quality' (quantization) setting, using default tables - * and a straight percentage-scaling quality scale. In most cases it's better - * to use jpeg_set_quality (below); this entry point is provided for - * applications that insist on a linear percentage scaling. - */ -{ - /* These are the sample quantization tables given in JPEG spec section K.1. - * The spec says that the values given produce "good" quality, and - * when divided by 2, "very good" quality. - */ - static const unsigned int std_luminance_quant_tbl[DCTSIZE2] = { - 16, 11, 10, 16, 24, 40, 51, 61, - 12, 12, 14, 19, 26, 58, 60, 55, - 14, 13, 16, 24, 40, 57, 69, 56, - 14, 17, 22, 29, 51, 87, 80, 62, - 18, 22, 37, 56, 68, 109, 103, 77, - 24, 35, 55, 64, 81, 104, 113, 92, - 49, 64, 78, 87, 103, 121, 120, 101, - 72, 92, 95, 98, 112, 100, 103, 99 - }; - static const unsigned int std_chrominance_quant_tbl[DCTSIZE2] = { - 17, 18, 24, 47, 99, 99, 99, 99, - 18, 21, 26, 66, 99, 99, 99, 99, - 24, 26, 56, 99, 99, 99, 99, 99, - 47, 66, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99 - }; - - /* Set up two quantization tables using the specified scaling */ - jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl, - scale_factor, force_baseline); - jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl, - scale_factor, force_baseline); -} - - -GLOBAL(int) -jpeg_quality_scaling (int quality) -/* Convert a user-specified quality rating to a percentage scaling factor - * for an underlying quantization table, using our recommended scaling curve. - * The input 'quality' factor should be 0 (terrible) to 100 (very good). - */ -{ - /* Safety limit on quality factor. Convert 0 to 1 to avoid zero divide. */ - if (quality <= 0) quality = 1; - if (quality > 100) quality = 100; - - /* The basic table is used as-is (scaling 100) for a quality of 50. - * Qualities 50..100 are converted to scaling percentage 200 - 2*Q; - * note that at Q=100 the scaling is 0, which will cause jpeg_add_quant_table - * to make all the table entries 1 (hence, minimum quantization loss). - * Qualities 1..50 are converted to scaling percentage 5000/Q. - */ - if (quality < 50) - quality = 5000 / quality; - else - quality = 200 - quality*2; - - return quality; -} - - -GLOBAL(void) -jpeg_set_quality (j_compress_ptr cinfo, int quality, boolean force_baseline) -/* Set or change the 'quality' (quantization) setting, using default tables. - * This is the standard quality-adjusting entry point for typical user - * interfaces; only those who want detailed control over quantization tables - * would use the preceding three routines directly. - */ -{ - /* Convert user 0-100 rating to percentage scaling */ - quality = jpeg_quality_scaling(quality); - - /* Set up standard quality tables */ - jpeg_set_linear_quality(cinfo, quality, force_baseline); -} - - -/* - * Huffman table setup routines - */ - -LOCAL(void) -add_huff_table (j_compress_ptr cinfo, - JHUFF_TBL **htblptr, const UINT8 *bits, const UINT8 *val) -/* Define a Huffman table */ -{ - int nsymbols, len; - - if (*htblptr == NULL) - *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); - - /* Copy the number-of-symbols-of-each-code-length counts */ - MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits)); - - /* Validate the counts. We do this here mainly so we can copy the right - * number of symbols from the val[] array, without risking marching off - * the end of memory. jchuff.c will do a more thorough test later. - */ - nsymbols = 0; - for (len = 1; len <= 16; len++) - nsymbols += bits[len]; - if (nsymbols < 1 || nsymbols > 256) - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - - MEMCOPY((*htblptr)->huffval, val, nsymbols * SIZEOF(UINT8)); - - /* Initialize sent_table FALSE so table will be written to JPEG file. */ - (*htblptr)->sent_table = FALSE; -} - - -LOCAL(void) -std_huff_tables (j_compress_ptr cinfo) -/* Set up the standard Huffman tables (cf. JPEG standard section K.3) */ -/* IMPORTANT: these are only valid for 8-bit data precision! */ -{ - static const UINT8 bits_dc_luminance[17] = - { /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 }; - static const UINT8 val_dc_luminance[] = - { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; - - static const UINT8 bits_dc_chrominance[17] = - { /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }; - static const UINT8 val_dc_chrominance[] = - { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; - - static const UINT8 bits_ac_luminance[17] = - { /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d }; - static const UINT8 val_ac_luminance[] = - { 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, - 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, - 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, - 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, - 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, - 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, - 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, - 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, - 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, - 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, - 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, - 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, - 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, - 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, - 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, - 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, - 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, - 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, - 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, - 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, - 0xf9, 0xfa }; - - static const UINT8 bits_ac_chrominance[17] = - { /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 }; - static const UINT8 val_ac_chrominance[] = - { 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, - 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, - 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, - 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, - 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, - 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26, - 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, - 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, - 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, - 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, - 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, - 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, - 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, - 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, - 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, - 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, - 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, - 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, - 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, - 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, - 0xf9, 0xfa }; - - add_huff_table(cinfo, &cinfo->dc_huff_tbl_ptrs[0], - bits_dc_luminance, val_dc_luminance); - add_huff_table(cinfo, &cinfo->ac_huff_tbl_ptrs[0], - bits_ac_luminance, val_ac_luminance); - add_huff_table(cinfo, &cinfo->dc_huff_tbl_ptrs[1], - bits_dc_chrominance, val_dc_chrominance); - add_huff_table(cinfo, &cinfo->ac_huff_tbl_ptrs[1], - bits_ac_chrominance, val_ac_chrominance); -} - - -/* - * Default parameter setup for compression. - * - * Applications that don't choose to use this routine must do their - * own setup of all these parameters. Alternately, you can call this - * to establish defaults and then alter parameters selectively. This - * is the recommended approach since, if we add any new parameters, - * your code will still work (they'll be set to reasonable defaults). - */ - -GLOBAL(void) -jpeg_set_defaults (j_compress_ptr cinfo) -{ - int i; - - /* Safety check to ensure start_compress not called yet. */ - if (cinfo->global_state != CSTATE_START) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - /* Allocate comp_info array large enough for maximum component count. - * Array is made permanent in case application wants to compress - * multiple images at same param settings. - */ - if (cinfo->comp_info == NULL) - cinfo->comp_info = (jpeg_component_info *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - MAX_COMPONENTS * SIZEOF(jpeg_component_info)); - - /* Initialize everything not dependent on the color space */ - - cinfo->data_precision = BITS_IN_JSAMPLE; - /* Set up two quantization tables using default quality of 75 */ - jpeg_set_quality(cinfo, 75, TRUE); - /* Set up two Huffman tables */ - std_huff_tables(cinfo); - - /* Initialize default arithmetic coding conditioning */ - for (i = 0; i < NUM_ARITH_TBLS; i++) { - cinfo->arith_dc_L[i] = 0; - cinfo->arith_dc_U[i] = 1; - cinfo->arith_ac_K[i] = 5; - } - - /* Default is no multiple-scan output */ - cinfo->scan_info = NULL; - cinfo->num_scans = 0; - - /* Expect normal source image, not raw downsampled data */ - cinfo->raw_data_in = FALSE; - - /* Use Huffman coding, not arithmetic coding, by default */ - cinfo->arith_code = FALSE; - - /* By default, don't do extra passes to optimize entropy coding */ - cinfo->optimize_coding = FALSE; - /* The standard Huffman tables are only valid for 8-bit data precision. - * If the precision is higher, force optimization on so that usable - * tables will be computed. This test can be removed if default tables - * are supplied that are valid for the desired precision. - */ - if (cinfo->data_precision > 8) - cinfo->optimize_coding = TRUE; - - /* By default, use the simpler non-cosited sampling alignment */ - cinfo->CCIR601_sampling = FALSE; - - /* No input smoothing */ - cinfo->smoothing_factor = 0; - - /* DCT algorithm preference */ - cinfo->dct_method = JDCT_DEFAULT; - - /* No restart markers */ - cinfo->restart_interval = 0; - cinfo->restart_in_rows = 0; - - /* Fill in default JFIF marker parameters. Note that whether the marker - * will actually be written is determined by jpeg_set_colorspace. - * - * By default, the library emits JFIF version code 1.01. - * An application that wants to emit JFIF 1.02 extension markers should set - * JFIF_minor_version to 2. We could probably get away with just defaulting - * to 1.02, but there may still be some decoders in use that will complain - * about that; saying 1.01 should minimize compatibility problems. - */ - cinfo->JFIF_major_version = 1; /* Default JFIF version = 1.01 */ - cinfo->JFIF_minor_version = 1; - cinfo->density_unit = 0; /* Pixel size is unknown by default */ - cinfo->X_density = 1; /* Pixel aspect ratio is square by default */ - cinfo->Y_density = 1; - - /* Choose JPEG colorspace based on input space, set defaults accordingly */ - - jpeg_default_colorspace(cinfo); -} - - -/* - * Select an appropriate JPEG colorspace for in_color_space. - */ - -GLOBAL(void) -jpeg_default_colorspace (j_compress_ptr cinfo) -{ - switch (cinfo->in_color_space) { - case JCS_GRAYSCALE: - jpeg_set_colorspace(cinfo, JCS_GRAYSCALE); - break; - case JCS_RGB: - jpeg_set_colorspace(cinfo, JCS_YCbCr); - break; - case JCS_YCbCr: - jpeg_set_colorspace(cinfo, JCS_YCbCr); - break; - case JCS_CMYK: - jpeg_set_colorspace(cinfo, JCS_CMYK); /* By default, no translation */ - break; - case JCS_YCCK: - jpeg_set_colorspace(cinfo, JCS_YCCK); - break; - case JCS_UNKNOWN: - jpeg_set_colorspace(cinfo, JCS_UNKNOWN); - break; - default: - ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); - } -} - - -/* - * Set the JPEG colorspace, and choose colorspace-dependent default values. - */ - -GLOBAL(void) -jpeg_set_colorspace (j_compress_ptr cinfo, J_COLOR_SPACE colorspace) -{ - jpeg_component_info * compptr; - int ci; - -#define SET_COMP(index,id,hsamp,vsamp,quant,dctbl,actbl) \ - (compptr = &cinfo->comp_info[index], \ - compptr->component_id = (id), \ - compptr->h_samp_factor = (hsamp), \ - compptr->v_samp_factor = (vsamp), \ - compptr->quant_tbl_no = (quant), \ - compptr->dc_tbl_no = (dctbl), \ - compptr->ac_tbl_no = (actbl) ) - - /* Safety check to ensure start_compress not called yet. */ - if (cinfo->global_state != CSTATE_START) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - /* For all colorspaces, we use Q and Huff tables 0 for luminance components, - * tables 1 for chrominance components. - */ - - cinfo->jpeg_color_space = colorspace; - - cinfo->write_JFIF_header = FALSE; /* No marker for non-JFIF colorspaces */ - cinfo->write_Adobe_marker = FALSE; /* write no Adobe marker by default */ - - switch (colorspace) { - case JCS_GRAYSCALE: - cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */ - cinfo->num_components = 1; - /* JFIF specifies component ID 1 */ - SET_COMP(0, 1, 1,1, 0, 0,0); - break; - case JCS_RGB: - cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag RGB */ - cinfo->num_components = 3; - SET_COMP(0, 0x52 /* 'R' */, 1,1, 0, 0,0); - SET_COMP(1, 0x47 /* 'G' */, 1,1, 0, 0,0); - SET_COMP(2, 0x42 /* 'B' */, 1,1, 0, 0,0); - break; - case JCS_YCbCr: - cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */ - cinfo->num_components = 3; - /* JFIF specifies component IDs 1,2,3 */ - /* We default to 2x2 subsamples of chrominance */ - SET_COMP(0, 1, 2,2, 0, 0,0); - SET_COMP(1, 2, 1,1, 1, 1,1); - SET_COMP(2, 3, 1,1, 1, 1,1); - break; - case JCS_CMYK: - cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag CMYK */ - cinfo->num_components = 4; - SET_COMP(0, 0x43 /* 'C' */, 1,1, 0, 0,0); - SET_COMP(1, 0x4D /* 'M' */, 1,1, 0, 0,0); - SET_COMP(2, 0x59 /* 'Y' */, 1,1, 0, 0,0); - SET_COMP(3, 0x4B /* 'K' */, 1,1, 0, 0,0); - break; - case JCS_YCCK: - cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag YCCK */ - cinfo->num_components = 4; - SET_COMP(0, 1, 2,2, 0, 0,0); - SET_COMP(1, 2, 1,1, 1, 1,1); - SET_COMP(2, 3, 1,1, 1, 1,1); - SET_COMP(3, 4, 2,2, 0, 0,0); - break; - case JCS_UNKNOWN: - cinfo->num_components = cinfo->input_components; - if (cinfo->num_components < 1 || cinfo->num_components > MAX_COMPONENTS) - ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, - MAX_COMPONENTS); - for (ci = 0; ci < cinfo->num_components; ci++) { - SET_COMP(ci, ci, 1,1, 0, 0,0); - } - break; - default: - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - } -} - - -#ifdef C_PROGRESSIVE_SUPPORTED - -LOCAL(jpeg_scan_info *) -fill_a_scan (jpeg_scan_info * scanptr, int ci, - int Ss, int Se, int Ah, int Al) -/* Support routine: generate one scan for specified component */ -{ - scanptr->comps_in_scan = 1; - scanptr->component_index[0] = ci; - scanptr->Ss = Ss; - scanptr->Se = Se; - scanptr->Ah = Ah; - scanptr->Al = Al; - scanptr++; - return scanptr; -} - -LOCAL(jpeg_scan_info *) -fill_scans (jpeg_scan_info * scanptr, int ncomps, - int Ss, int Se, int Ah, int Al) -/* Support routine: generate one scan for each component */ -{ - int ci; - - for (ci = 0; ci < ncomps; ci++) { - scanptr->comps_in_scan = 1; - scanptr->component_index[0] = ci; - scanptr->Ss = Ss; - scanptr->Se = Se; - scanptr->Ah = Ah; - scanptr->Al = Al; - scanptr++; - } - return scanptr; -} - -LOCAL(jpeg_scan_info *) -fill_dc_scans (jpeg_scan_info * scanptr, int ncomps, int Ah, int Al) -/* Support routine: generate interleaved DC scan if possible, else N scans */ -{ - int ci; - - if (ncomps <= MAX_COMPS_IN_SCAN) { - /* Single interleaved DC scan */ - scanptr->comps_in_scan = ncomps; - for (ci = 0; ci < ncomps; ci++) - scanptr->component_index[ci] = ci; - scanptr->Ss = scanptr->Se = 0; - scanptr->Ah = Ah; - scanptr->Al = Al; - scanptr++; - } else { - /* Noninterleaved DC scan for each component */ - scanptr = fill_scans(scanptr, ncomps, 0, 0, Ah, Al); - } - return scanptr; -} - - -/* - * Create a recommended progressive-JPEG script. - * cinfo->num_components and cinfo->jpeg_color_space must be correct. - */ - -GLOBAL(void) -jpeg_simple_progression (j_compress_ptr cinfo) -{ - int ncomps = cinfo->num_components; - int nscans; - jpeg_scan_info * scanptr; - - /* Safety check to ensure start_compress not called yet. */ - if (cinfo->global_state != CSTATE_START) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - /* Figure space needed for script. Calculation must match code below! */ - if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) { - /* Custom script for YCbCr color images. */ - nscans = 10; - } else { - /* All-purpose script for other color spaces. */ - if (ncomps > MAX_COMPS_IN_SCAN) - nscans = 6 * ncomps; /* 2 DC + 4 AC scans per component */ - else - nscans = 2 + 4 * ncomps; /* 2 DC scans; 4 AC scans per component */ - } - - /* Allocate space for script. - * We need to put it in the permanent pool in case the application performs - * multiple compressions without changing the settings. To avoid a memory - * leak if jpeg_simple_progression is called repeatedly for the same JPEG - * object, we try to re-use previously allocated space, and we allocate - * enough space to handle YCbCr even if initially asked for grayscale. - */ - if (cinfo->script_space == NULL || cinfo->script_space_size < nscans) { - cinfo->script_space_size = MAX(nscans, 10); - cinfo->script_space = (jpeg_scan_info *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - cinfo->script_space_size * SIZEOF(jpeg_scan_info)); - } - scanptr = cinfo->script_space; - cinfo->scan_info = scanptr; - cinfo->num_scans = nscans; - - if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) { - /* Custom script for YCbCr color images. */ - /* Initial DC scan */ - scanptr = fill_dc_scans(scanptr, ncomps, 0, 1); - /* Initial AC scan: get some luma data out in a hurry */ - scanptr = fill_a_scan(scanptr, 0, 1, 5, 0, 2); - /* Chroma data is too small to be worth expending many scans on */ - scanptr = fill_a_scan(scanptr, 2, 1, 63, 0, 1); - scanptr = fill_a_scan(scanptr, 1, 1, 63, 0, 1); - /* Complete spectral selection for luma AC */ - scanptr = fill_a_scan(scanptr, 0, 6, 63, 0, 2); - /* Refine next bit of luma AC */ - scanptr = fill_a_scan(scanptr, 0, 1, 63, 2, 1); - /* Finish DC successive approximation */ - scanptr = fill_dc_scans(scanptr, ncomps, 1, 0); - /* Finish AC successive approximation */ - scanptr = fill_a_scan(scanptr, 2, 1, 63, 1, 0); - scanptr = fill_a_scan(scanptr, 1, 1, 63, 1, 0); - /* Luma bottom bit comes last since it's usually largest scan */ - scanptr = fill_a_scan(scanptr, 0, 1, 63, 1, 0); - } else { - /* All-purpose script for other color spaces. */ - /* Successive approximation first pass */ - scanptr = fill_dc_scans(scanptr, ncomps, 0, 1); - scanptr = fill_scans(scanptr, ncomps, 1, 5, 0, 2); - scanptr = fill_scans(scanptr, ncomps, 6, 63, 0, 2); - /* Successive approximation second pass */ - scanptr = fill_scans(scanptr, ncomps, 1, 63, 2, 1); - /* Successive approximation final pass */ - scanptr = fill_dc_scans(scanptr, ncomps, 1, 0); - scanptr = fill_scans(scanptr, ncomps, 1, 63, 1, 0); - } -} - -#endif /* C_PROGRESSIVE_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jcphuff.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jcphuff.c deleted file mode 100644 index a4ee850e3..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jcphuff.c +++ /dev/null @@ -1,833 +0,0 @@ -/* - * jcphuff.c - * - * Copyright (C) 1995-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains Huffman entropy encoding routines for progressive JPEG. - * - * We do not support output suspension in this module, since the library - * currently does not allow multiple-scan files to be written with output - * suspension. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jchuff.h" /* Declarations shared with jchuff.c */ - -#ifdef C_PROGRESSIVE_SUPPORTED - -/* Expanded entropy encoder object for progressive Huffman encoding. */ - -typedef struct { - struct jpeg_entropy_encoder pub; /* public fields */ - - /* Mode flag: TRUE for optimization, FALSE for actual data output */ - boolean gather_statistics; - - /* Bit-level coding status. - * next_output_byte/free_in_buffer are local copies of cinfo->dest fields. - */ - JOCTET * next_output_byte; /* => next byte to write in buffer */ - size_t free_in_buffer; /* # of byte spaces remaining in buffer */ - INT32 put_buffer; /* current bit-accumulation buffer */ - int put_bits; /* # of bits now in it */ - j_compress_ptr cinfo; /* link to cinfo (needed for dump_buffer) */ - - /* Coding status for DC components */ - int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */ - - /* Coding status for AC components */ - int ac_tbl_no; /* the table number of the single component */ - unsigned int EOBRUN; /* run length of EOBs */ - unsigned int BE; /* # of buffered correction bits before MCU */ - char * bit_buffer; /* buffer for correction bits (1 per char) */ - /* packing correction bits tightly would save some space but cost time... */ - - unsigned int restarts_to_go; /* MCUs left in this restart interval */ - int next_restart_num; /* next restart number to write (0-7) */ - - /* Pointers to derived tables (these workspaces have image lifespan). - * Since any one scan codes only DC or only AC, we only need one set - * of tables, not one for DC and one for AC. - */ - c_derived_tbl * derived_tbls[NUM_HUFF_TBLS]; - - /* Statistics tables for optimization; again, one set is enough */ - long * count_ptrs[NUM_HUFF_TBLS]; -} phuff_entropy_encoder; - -typedef phuff_entropy_encoder * phuff_entropy_ptr; - -/* MAX_CORR_BITS is the number of bits the AC refinement correction-bit - * buffer can hold. Larger sizes may slightly improve compression, but - * 1000 is already well into the realm of overkill. - * The minimum safe size is 64 bits. - */ - -#define MAX_CORR_BITS 1000 /* Max # of correction bits I can buffer */ - -/* IRIGHT_SHIFT is like RIGHT_SHIFT, but works on int rather than INT32. - * We assume that int right shift is unsigned if INT32 right shift is, - * which should be safe. - */ - -#ifdef RIGHT_SHIFT_IS_UNSIGNED -#define ISHIFT_TEMPS int ishift_temp; -#define IRIGHT_SHIFT(x,shft) \ - ((ishift_temp = (x)) < 0 ? \ - (ishift_temp >> (shft)) | ((~0) << (16-(shft))) : \ - (ishift_temp >> (shft))) -#else -#define ISHIFT_TEMPS -#define IRIGHT_SHIFT(x,shft) ((x) >> (shft)) -#endif - -/* Forward declarations */ -METHODDEF(boolean) encode_mcu_DC_first JPP((j_compress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(boolean) encode_mcu_AC_first JPP((j_compress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(boolean) encode_mcu_DC_refine JPP((j_compress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(boolean) encode_mcu_AC_refine JPP((j_compress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(void) finish_pass_phuff JPP((j_compress_ptr cinfo)); -METHODDEF(void) finish_pass_gather_phuff JPP((j_compress_ptr cinfo)); - - -/* - * Initialize for a Huffman-compressed scan using progressive JPEG. - */ - -METHODDEF(void) -start_pass_phuff (j_compress_ptr cinfo, boolean gather_statistics) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - boolean is_DC_band; - int ci, tbl; - jpeg_component_info * compptr; - - entropy->cinfo = cinfo; - entropy->gather_statistics = gather_statistics; - - is_DC_band = (cinfo->Ss == 0); - - /* We assume jcmaster.c already validated the scan parameters. */ - - /* Select execution routines */ - if (cinfo->Ah == 0) { - if (is_DC_band) - entropy->pub.encode_mcu = encode_mcu_DC_first; - else - entropy->pub.encode_mcu = encode_mcu_AC_first; - } else { - if (is_DC_band) - entropy->pub.encode_mcu = encode_mcu_DC_refine; - else { - entropy->pub.encode_mcu = encode_mcu_AC_refine; - /* AC refinement needs a correction bit buffer */ - if (entropy->bit_buffer == NULL) - entropy->bit_buffer = (char *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - MAX_CORR_BITS * SIZEOF(char)); - } - } - if (gather_statistics) - entropy->pub.finish_pass = finish_pass_gather_phuff; - else - entropy->pub.finish_pass = finish_pass_phuff; - - /* Only DC coefficients may be interleaved, so cinfo->comps_in_scan = 1 - * for AC coefficients. - */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - /* Initialize DC predictions to 0 */ - entropy->last_dc_val[ci] = 0; - /* Get table index */ - if (is_DC_band) { - if (cinfo->Ah != 0) /* DC refinement needs no table */ - continue; - tbl = compptr->dc_tbl_no; - } else { - entropy->ac_tbl_no = tbl = compptr->ac_tbl_no; - } - if (gather_statistics) { - /* Check for invalid table index */ - /* (make_c_derived_tbl does this in the other path) */ - if (tbl < 0 || tbl >= NUM_HUFF_TBLS) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tbl); - /* Allocate and zero the statistics tables */ - /* Note that jpeg_gen_optimal_table expects 257 entries in each table! */ - if (entropy->count_ptrs[tbl] == NULL) - entropy->count_ptrs[tbl] = (long *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - 257 * SIZEOF(long)); - MEMZERO(entropy->count_ptrs[tbl], 257 * SIZEOF(long)); - } else { - /* Compute derived values for Huffman table */ - /* We may do this more than once for a table, but it's not expensive */ - jpeg_make_c_derived_tbl(cinfo, is_DC_band, tbl, - & entropy->derived_tbls[tbl]); - } - } - - /* Initialize AC stuff */ - entropy->EOBRUN = 0; - entropy->BE = 0; - - /* Initialize bit buffer to empty */ - entropy->put_buffer = 0; - entropy->put_bits = 0; - - /* Initialize restart stuff */ - entropy->restarts_to_go = cinfo->restart_interval; - entropy->next_restart_num = 0; -} - - -/* Outputting bytes to the file. - * NB: these must be called only when actually outputting, - * that is, entropy->gather_statistics == FALSE. - */ - -/* Emit a byte */ -#define emit_byte(entropy,val) \ - { *(entropy)->next_output_byte++ = (JOCTET) (val); \ - if (--(entropy)->free_in_buffer == 0) \ - dump_buffer(entropy); } - - -LOCAL(void) -dump_buffer (phuff_entropy_ptr entropy) -/* Empty the output buffer; we do not support suspension in this module. */ -{ - struct jpeg_destination_mgr * dest = entropy->cinfo->dest; - - if (! (*dest->empty_output_buffer) (entropy->cinfo)) - ERREXIT(entropy->cinfo, JERR_CANT_SUSPEND); - /* After a successful buffer dump, must reset buffer pointers */ - entropy->next_output_byte = dest->next_output_byte; - entropy->free_in_buffer = dest->free_in_buffer; -} - - -/* Outputting bits to the file */ - -/* Only the right 24 bits of put_buffer are used; the valid bits are - * left-justified in this part. At most 16 bits can be passed to emit_bits - * in one call, and we never retain more than 7 bits in put_buffer - * between calls, so 24 bits are sufficient. - */ - -INLINE -LOCAL(void) -emit_bits (phuff_entropy_ptr entropy, unsigned int code, int size) -/* Emit some bits, unless we are in gather mode */ -{ - /* This routine is heavily used, so it's worth coding tightly. */ - register INT32 put_buffer = (INT32) code; - register int put_bits = entropy->put_bits; - - /* if size is 0, caller used an invalid Huffman table entry */ - if (size == 0) - ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE); - - if (entropy->gather_statistics) - return; /* do nothing if we're only getting stats */ - - put_buffer &= (((INT32) 1)<<size) - 1; /* mask off any extra bits in code */ - - put_bits += size; /* new number of bits in buffer */ - - put_buffer <<= 24 - put_bits; /* align incoming bits */ - - put_buffer |= entropy->put_buffer; /* and merge with old buffer contents */ - - while (put_bits >= 8) { - int c = (int) ((put_buffer >> 16) & 0xFF); - - emit_byte(entropy, c); - if (c == 0xFF) { /* need to stuff a zero byte? */ - emit_byte(entropy, 0); - } - put_buffer <<= 8; - put_bits -= 8; - } - - entropy->put_buffer = put_buffer; /* update variables */ - entropy->put_bits = put_bits; -} - - -LOCAL(void) -flush_bits (phuff_entropy_ptr entropy) -{ - emit_bits(entropy, 0x7F, 7); /* fill any partial byte with ones */ - entropy->put_buffer = 0; /* and reset bit-buffer to empty */ - entropy->put_bits = 0; -} - - -/* - * Emit (or just count) a Huffman symbol. - */ - -INLINE -LOCAL(void) -emit_symbol (phuff_entropy_ptr entropy, int tbl_no, int symbol) -{ - if (entropy->gather_statistics) - entropy->count_ptrs[tbl_no][symbol]++; - else { - c_derived_tbl * tbl = entropy->derived_tbls[tbl_no]; - emit_bits(entropy, tbl->ehufco[symbol], tbl->ehufsi[symbol]); - } -} - - -/* - * Emit bits from a correction bit buffer. - */ - -LOCAL(void) -emit_buffered_bits (phuff_entropy_ptr entropy, char * bufstart, - unsigned int nbits) -{ - if (entropy->gather_statistics) - return; /* no real work */ - - while (nbits > 0) { - emit_bits(entropy, (unsigned int) (*bufstart), 1); - bufstart++; - nbits--; - } -} - - -/* - * Emit any pending EOBRUN symbol. - */ - -LOCAL(void) -emit_eobrun (phuff_entropy_ptr entropy) -{ - register int temp, nbits; - - if (entropy->EOBRUN > 0) { /* if there is any pending EOBRUN */ - temp = entropy->EOBRUN; - nbits = 0; - while ((temp >>= 1)) - nbits++; - /* safety check: shouldn't happen given limited correction-bit buffer */ - if (nbits > 14) - ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE); - - emit_symbol(entropy, entropy->ac_tbl_no, nbits << 4); - if (nbits) - emit_bits(entropy, entropy->EOBRUN, nbits); - - entropy->EOBRUN = 0; - - /* Emit any buffered correction bits */ - emit_buffered_bits(entropy, entropy->bit_buffer, entropy->BE); - entropy->BE = 0; - } -} - - -/* - * Emit a restart marker & resynchronize predictions. - */ - -LOCAL(void) -emit_restart (phuff_entropy_ptr entropy, int restart_num) -{ - int ci; - - emit_eobrun(entropy); - - if (! entropy->gather_statistics) { - flush_bits(entropy); - emit_byte(entropy, 0xFF); - emit_byte(entropy, JPEG_RST0 + restart_num); - } - - if (entropy->cinfo->Ss == 0) { - /* Re-initialize DC predictions to 0 */ - for (ci = 0; ci < entropy->cinfo->comps_in_scan; ci++) - entropy->last_dc_val[ci] = 0; - } else { - /* Re-initialize all AC-related fields to 0 */ - entropy->EOBRUN = 0; - entropy->BE = 0; - } -} - - -/* - * MCU encoding for DC initial scan (either spectral selection, - * or first pass of successive approximation). - */ - -METHODDEF(boolean) -encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - register int temp, temp2; - register int nbits; - int blkn, ci; - int Al = cinfo->Al; - JBLOCKROW block; - jpeg_component_info * compptr; - ISHIFT_TEMPS - - entropy->next_output_byte = cinfo->dest->next_output_byte; - entropy->free_in_buffer = cinfo->dest->free_in_buffer; - - /* Emit restart marker if needed */ - if (cinfo->restart_interval) - if (entropy->restarts_to_go == 0) - emit_restart(entropy, entropy->next_restart_num); - - /* Encode the MCU data blocks */ - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - block = MCU_data[blkn]; - ci = cinfo->MCU_membership[blkn]; - compptr = cinfo->cur_comp_info[ci]; - - /* Compute the DC value after the required point transform by Al. - * This is simply an arithmetic right shift. - */ - temp2 = IRIGHT_SHIFT((int) ((*block)[0]), Al); - - /* DC differences are figured on the point-transformed values. */ - temp = temp2 - entropy->last_dc_val[ci]; - entropy->last_dc_val[ci] = temp2; - - /* Encode the DC coefficient difference per section G.1.2.1 */ - temp2 = temp; - if (temp < 0) { - temp = -temp; /* temp is abs value of input */ - /* For a negative input, want temp2 = bitwise complement of abs(input) */ - /* This code assumes we are on a two's complement machine */ - temp2--; - } - - /* Find the number of bits needed for the magnitude of the coefficient */ - nbits = 0; - while (temp) { - nbits++; - temp >>= 1; - } - /* Check for out-of-range coefficient values. - * Since we're encoding a difference, the range limit is twice as much. - */ - if (nbits > MAX_COEF_BITS+1) - ERREXIT(cinfo, JERR_BAD_DCT_COEF); - - /* Count/emit the Huffman-coded symbol for the number of bits */ - emit_symbol(entropy, compptr->dc_tbl_no, nbits); - - /* Emit that number of bits of the value, if positive, */ - /* or the complement of its magnitude, if negative. */ - if (nbits) /* emit_bits rejects calls with size 0 */ - emit_bits(entropy, (unsigned int) temp2, nbits); - } - - cinfo->dest->next_output_byte = entropy->next_output_byte; - cinfo->dest->free_in_buffer = entropy->free_in_buffer; - - /* Update restart-interval state too */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) { - entropy->restarts_to_go = cinfo->restart_interval; - entropy->next_restart_num++; - entropy->next_restart_num &= 7; - } - entropy->restarts_to_go--; - } - - return TRUE; -} - - -/* - * MCU encoding for AC initial scan (either spectral selection, - * or first pass of successive approximation). - */ - -METHODDEF(boolean) -encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - register int temp, temp2; - register int nbits; - register int r, k; - int Se = cinfo->Se; - int Al = cinfo->Al; - JBLOCKROW block; - - entropy->next_output_byte = cinfo->dest->next_output_byte; - entropy->free_in_buffer = cinfo->dest->free_in_buffer; - - /* Emit restart marker if needed */ - if (cinfo->restart_interval) - if (entropy->restarts_to_go == 0) - emit_restart(entropy, entropy->next_restart_num); - - /* Encode the MCU data block */ - block = MCU_data[0]; - - /* Encode the AC coefficients per section G.1.2.2, fig. G.3 */ - - r = 0; /* r = run length of zeros */ - - for (k = cinfo->Ss; k <= Se; k++) { - if ((temp = (*block)[jpeg_natural_order[k]]) == 0) { - r++; - continue; - } - /* We must apply the point transform by Al. For AC coefficients this - * is an integer division with rounding towards 0. To do this portably - * in C, we shift after obtaining the absolute value; so the code is - * interwoven with finding the abs value (temp) and output bits (temp2). - */ - if (temp < 0) { - temp = -temp; /* temp is abs value of input */ - temp >>= Al; /* apply the point transform */ - /* For a negative coef, want temp2 = bitwise complement of abs(coef) */ - temp2 = ~temp; - } else { - temp >>= Al; /* apply the point transform */ - temp2 = temp; - } - /* Watch out for case that nonzero coef is zero after point transform */ - if (temp == 0) { - r++; - continue; - } - - /* Emit any pending EOBRUN */ - if (entropy->EOBRUN > 0) - emit_eobrun(entropy); - /* if run length > 15, must emit special run-length-16 codes (0xF0) */ - while (r > 15) { - emit_symbol(entropy, entropy->ac_tbl_no, 0xF0); - r -= 16; - } - - /* Find the number of bits needed for the magnitude of the coefficient */ - nbits = 1; /* there must be at least one 1 bit */ - while ((temp >>= 1)) - nbits++; - /* Check for out-of-range coefficient values */ - if (nbits > MAX_COEF_BITS) - ERREXIT(cinfo, JERR_BAD_DCT_COEF); - - /* Count/emit Huffman symbol for run length / number of bits */ - emit_symbol(entropy, entropy->ac_tbl_no, (r << 4) + nbits); - - /* Emit that number of bits of the value, if positive, */ - /* or the complement of its magnitude, if negative. */ - emit_bits(entropy, (unsigned int) temp2, nbits); - - r = 0; /* reset zero run length */ - } - - if (r > 0) { /* If there are trailing zeroes, */ - entropy->EOBRUN++; /* count an EOB */ - if (entropy->EOBRUN == 0x7FFF) - emit_eobrun(entropy); /* force it out to avoid overflow */ - } - - cinfo->dest->next_output_byte = entropy->next_output_byte; - cinfo->dest->free_in_buffer = entropy->free_in_buffer; - - /* Update restart-interval state too */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) { - entropy->restarts_to_go = cinfo->restart_interval; - entropy->next_restart_num++; - entropy->next_restart_num &= 7; - } - entropy->restarts_to_go--; - } - - return TRUE; -} - - -/* - * MCU encoding for DC successive approximation refinement scan. - * Note: we assume such scans can be multi-component, although the spec - * is not very clear on the point. - */ - -METHODDEF(boolean) -encode_mcu_DC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - register int temp; - int blkn; - int Al = cinfo->Al; - JBLOCKROW block; - - entropy->next_output_byte = cinfo->dest->next_output_byte; - entropy->free_in_buffer = cinfo->dest->free_in_buffer; - - /* Emit restart marker if needed */ - if (cinfo->restart_interval) - if (entropy->restarts_to_go == 0) - emit_restart(entropy, entropy->next_restart_num); - - /* Encode the MCU data blocks */ - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - block = MCU_data[blkn]; - - /* We simply emit the Al'th bit of the DC coefficient value. */ - temp = (*block)[0]; - emit_bits(entropy, (unsigned int) (temp >> Al), 1); - } - - cinfo->dest->next_output_byte = entropy->next_output_byte; - cinfo->dest->free_in_buffer = entropy->free_in_buffer; - - /* Update restart-interval state too */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) { - entropy->restarts_to_go = cinfo->restart_interval; - entropy->next_restart_num++; - entropy->next_restart_num &= 7; - } - entropy->restarts_to_go--; - } - - return TRUE; -} - - -/* - * MCU encoding for AC successive approximation refinement scan. - */ - -METHODDEF(boolean) -encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - register int temp; - register int r, k; - int EOB; - char *BR_buffer; - unsigned int BR; - int Se = cinfo->Se; - int Al = cinfo->Al; - JBLOCKROW block; - int absvalues[DCTSIZE2]; - - entropy->next_output_byte = cinfo->dest->next_output_byte; - entropy->free_in_buffer = cinfo->dest->free_in_buffer; - - /* Emit restart marker if needed */ - if (cinfo->restart_interval) - if (entropy->restarts_to_go == 0) - emit_restart(entropy, entropy->next_restart_num); - - /* Encode the MCU data block */ - block = MCU_data[0]; - - /* It is convenient to make a pre-pass to determine the transformed - * coefficients' absolute values and the EOB position. - */ - EOB = 0; - for (k = cinfo->Ss; k <= Se; k++) { - temp = (*block)[jpeg_natural_order[k]]; - /* We must apply the point transform by Al. For AC coefficients this - * is an integer division with rounding towards 0. To do this portably - * in C, we shift after obtaining the absolute value. - */ - if (temp < 0) - temp = -temp; /* temp is abs value of input */ - temp >>= Al; /* apply the point transform */ - absvalues[k] = temp; /* save abs value for main pass */ - if (temp == 1) - EOB = k; /* EOB = index of last newly-nonzero coef */ - } - - /* Encode the AC coefficients per section G.1.2.3, fig. G.7 */ - - r = 0; /* r = run length of zeros */ - BR = 0; /* BR = count of buffered bits added now */ - BR_buffer = entropy->bit_buffer + entropy->BE; /* Append bits to buffer */ - - for (k = cinfo->Ss; k <= Se; k++) { - if ((temp = absvalues[k]) == 0) { - r++; - continue; - } - - /* Emit any required ZRLs, but not if they can be folded into EOB */ - while (r > 15 && k <= EOB) { - /* emit any pending EOBRUN and the BE correction bits */ - emit_eobrun(entropy); - /* Emit ZRL */ - emit_symbol(entropy, entropy->ac_tbl_no, 0xF0); - r -= 16; - /* Emit buffered correction bits that must be associated with ZRL */ - emit_buffered_bits(entropy, BR_buffer, BR); - BR_buffer = entropy->bit_buffer; /* BE bits are gone now */ - BR = 0; - } - - /* If the coef was previously nonzero, it only needs a correction bit. - * NOTE: a straight translation of the spec's figure G.7 would suggest - * that we also need to test r > 15. But if r > 15, we can only get here - * if k > EOB, which implies that this coefficient is not 1. - */ - if (temp > 1) { - /* The correction bit is the next bit of the absolute value. */ - BR_buffer[BR++] = (char) (temp & 1); - continue; - } - - /* Emit any pending EOBRUN and the BE correction bits */ - emit_eobrun(entropy); - - /* Count/emit Huffman symbol for run length / number of bits */ - emit_symbol(entropy, entropy->ac_tbl_no, (r << 4) + 1); - - /* Emit output bit for newly-nonzero coef */ - temp = ((*block)[jpeg_natural_order[k]] < 0) ? 0 : 1; - emit_bits(entropy, (unsigned int) temp, 1); - - /* Emit buffered correction bits that must be associated with this code */ - emit_buffered_bits(entropy, BR_buffer, BR); - BR_buffer = entropy->bit_buffer; /* BE bits are gone now */ - BR = 0; - r = 0; /* reset zero run length */ - } - - if (r > 0 || BR > 0) { /* If there are trailing zeroes, */ - entropy->EOBRUN++; /* count an EOB */ - entropy->BE += BR; /* concat my correction bits to older ones */ - /* We force out the EOB if we risk either: - * 1. overflow of the EOB counter; - * 2. overflow of the correction bit buffer during the next MCU. - */ - if (entropy->EOBRUN == 0x7FFF || entropy->BE > (MAX_CORR_BITS-DCTSIZE2+1)) - emit_eobrun(entropy); - } - - cinfo->dest->next_output_byte = entropy->next_output_byte; - cinfo->dest->free_in_buffer = entropy->free_in_buffer; - - /* Update restart-interval state too */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) { - entropy->restarts_to_go = cinfo->restart_interval; - entropy->next_restart_num++; - entropy->next_restart_num &= 7; - } - entropy->restarts_to_go--; - } - - return TRUE; -} - - -/* - * Finish up at the end of a Huffman-compressed progressive scan. - */ - -METHODDEF(void) -finish_pass_phuff (j_compress_ptr cinfo) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - - entropy->next_output_byte = cinfo->dest->next_output_byte; - entropy->free_in_buffer = cinfo->dest->free_in_buffer; - - /* Flush out any buffered data */ - emit_eobrun(entropy); - flush_bits(entropy); - - cinfo->dest->next_output_byte = entropy->next_output_byte; - cinfo->dest->free_in_buffer = entropy->free_in_buffer; -} - - -/* - * Finish up a statistics-gathering pass and create the new Huffman tables. - */ - -METHODDEF(void) -finish_pass_gather_phuff (j_compress_ptr cinfo) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - boolean is_DC_band; - int ci, tbl; - jpeg_component_info * compptr; - JHUFF_TBL **htblptr; - boolean did[NUM_HUFF_TBLS]; - - /* Flush out buffered data (all we care about is counting the EOB symbol) */ - emit_eobrun(entropy); - - is_DC_band = (cinfo->Ss == 0); - - /* It's important not to apply jpeg_gen_optimal_table more than once - * per table, because it clobbers the input frequency counts! - */ - MEMZERO(did, SIZEOF(did)); - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - if (is_DC_band) { - if (cinfo->Ah != 0) /* DC refinement needs no table */ - continue; - tbl = compptr->dc_tbl_no; - } else { - tbl = compptr->ac_tbl_no; - } - if (! did[tbl]) { - if (is_DC_band) - htblptr = & cinfo->dc_huff_tbl_ptrs[tbl]; - else - htblptr = & cinfo->ac_huff_tbl_ptrs[tbl]; - if (*htblptr == NULL) - *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); - jpeg_gen_optimal_table(cinfo, *htblptr, entropy->count_ptrs[tbl]); - did[tbl] = TRUE; - } - } -} - - -/* - * Module initialization routine for progressive Huffman entropy encoding. - */ - -GLOBAL(void) -jinit_phuff_encoder (j_compress_ptr cinfo) -{ - phuff_entropy_ptr entropy; - int i; - - entropy = (phuff_entropy_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(phuff_entropy_encoder)); - cinfo->entropy = (struct jpeg_entropy_encoder *) entropy; - entropy->pub.start_pass = start_pass_phuff; - - /* Mark tables unallocated */ - for (i = 0; i < NUM_HUFF_TBLS; i++) { - entropy->derived_tbls[i] = NULL; - entropy->count_ptrs[i] = NULL; - } - entropy->bit_buffer = NULL; /* needed only in AC refinement scan */ -} - -#endif /* C_PROGRESSIVE_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jcprepct.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jcprepct.c deleted file mode 100644 index fdc4bc2d5..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jcprepct.c +++ /dev/null @@ -1,354 +0,0 @@ -/* - * jcprepct.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the compression preprocessing controller. - * This controller manages the color conversion, downsampling, - * and edge expansion steps. - * - * Most of the complexity here is associated with buffering input rows - * as required by the downsampler. See the comments at the head of - * jcsample.c for the downsampler's needs. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* At present, jcsample.c can request context rows only for smoothing. - * In the future, we might also need context rows for CCIR601 sampling - * or other more-complex downsampling procedures. The code to support - * context rows should be compiled only if needed. - */ -#ifdef INPUT_SMOOTHING_SUPPORTED -#define CONTEXT_ROWS_SUPPORTED -#endif - - -/* - * For the simple (no-context-row) case, we just need to buffer one - * row group's worth of pixels for the downsampling step. At the bottom of - * the image, we pad to a full row group by replicating the last pixel row. - * The downsampler's last output row is then replicated if needed to pad - * out to a full iMCU row. - * - * When providing context rows, we must buffer three row groups' worth of - * pixels. Three row groups are physically allocated, but the row pointer - * arrays are made five row groups high, with the extra pointers above and - * below "wrapping around" to point to the last and first real row groups. - * This allows the downsampler to access the proper context rows. - * At the top and bottom of the image, we create dummy context rows by - * copying the first or last real pixel row. This copying could be avoided - * by pointer hacking as is done in jdmainct.c, but it doesn't seem worth the - * trouble on the compression side. - */ - - -/* Private buffer controller object */ - -typedef struct { - struct jpeg_c_prep_controller pub; /* public fields */ - - /* Downsampling input buffer. This buffer holds color-converted data - * until we have enough to do a downsample step. - */ - JSAMPARRAY color_buf[MAX_COMPONENTS]; - - JDIMENSION rows_to_go; /* counts rows remaining in source image */ - int next_buf_row; /* index of next row to store in color_buf */ - -#ifdef CONTEXT_ROWS_SUPPORTED /* only needed for context case */ - int this_row_group; /* starting row index of group to process */ - int next_buf_stop; /* downsample when we reach this index */ -#endif -} my_prep_controller; - -typedef my_prep_controller * my_prep_ptr; - - -/* - * Initialize for a processing pass. - */ - -METHODDEF(void) -start_pass_prep (j_compress_ptr cinfo, J_BUF_MODE pass_mode) -{ - my_prep_ptr prep = (my_prep_ptr) cinfo->prep; - - if (pass_mode != JBUF_PASS_THRU) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - - /* Initialize total-height counter for detecting bottom of image */ - prep->rows_to_go = cinfo->image_height; - /* Mark the conversion buffer empty */ - prep->next_buf_row = 0; -#ifdef CONTEXT_ROWS_SUPPORTED - /* Preset additional state variables for context mode. - * These aren't used in non-context mode, so we needn't test which mode. - */ - prep->this_row_group = 0; - /* Set next_buf_stop to stop after two row groups have been read in. */ - prep->next_buf_stop = 2 * cinfo->max_v_samp_factor; -#endif -} - - -/* - * Expand an image vertically from height input_rows to height output_rows, - * by duplicating the bottom row. - */ - -LOCAL(void) -expand_bottom_edge (JSAMPARRAY image_data, JDIMENSION num_cols, - int input_rows, int output_rows) -{ - register int row; - - for (row = input_rows; row < output_rows; row++) { - jcopy_sample_rows(image_data, input_rows-1, image_data, row, - 1, num_cols); - } -} - - -/* - * Process some data in the simple no-context case. - * - * Preprocessor output data is counted in "row groups". A row group - * is defined to be v_samp_factor sample rows of each component. - * Downsampling will produce this much data from each max_v_samp_factor - * input rows. - */ - -METHODDEF(void) -pre_process_data (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, - JDIMENSION in_rows_avail, - JSAMPIMAGE output_buf, JDIMENSION *out_row_group_ctr, - JDIMENSION out_row_groups_avail) -{ - my_prep_ptr prep = (my_prep_ptr) cinfo->prep; - int numrows, ci; - JDIMENSION inrows; - jpeg_component_info * compptr; - - while (*in_row_ctr < in_rows_avail && - *out_row_group_ctr < out_row_groups_avail) { - /* Do color conversion to fill the conversion buffer. */ - inrows = in_rows_avail - *in_row_ctr; - numrows = cinfo->max_v_samp_factor - prep->next_buf_row; - numrows = (int) MIN((JDIMENSION) numrows, inrows); - (*cinfo->cconvert->color_convert) (cinfo, input_buf + *in_row_ctr, - prep->color_buf, - (JDIMENSION) prep->next_buf_row, - numrows); - *in_row_ctr += numrows; - prep->next_buf_row += numrows; - prep->rows_to_go -= numrows; - /* If at bottom of image, pad to fill the conversion buffer. */ - if (prep->rows_to_go == 0 && - prep->next_buf_row < cinfo->max_v_samp_factor) { - for (ci = 0; ci < cinfo->num_components; ci++) { - expand_bottom_edge(prep->color_buf[ci], cinfo->image_width, - prep->next_buf_row, cinfo->max_v_samp_factor); - } - prep->next_buf_row = cinfo->max_v_samp_factor; - } - /* If we've filled the conversion buffer, empty it. */ - if (prep->next_buf_row == cinfo->max_v_samp_factor) { - (*cinfo->downsample->downsample) (cinfo, - prep->color_buf, (JDIMENSION) 0, - output_buf, *out_row_group_ctr); - prep->next_buf_row = 0; - (*out_row_group_ctr)++; - } - /* If at bottom of image, pad the output to a full iMCU height. - * Note we assume the caller is providing a one-iMCU-height output buffer! - */ - if (prep->rows_to_go == 0 && - *out_row_group_ctr < out_row_groups_avail) { - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - expand_bottom_edge(output_buf[ci], - compptr->width_in_blocks * DCTSIZE, - (int) (*out_row_group_ctr * compptr->v_samp_factor), - (int) (out_row_groups_avail * compptr->v_samp_factor)); - } - *out_row_group_ctr = out_row_groups_avail; - break; /* can exit outer loop without test */ - } - } -} - - -#ifdef CONTEXT_ROWS_SUPPORTED - -/* - * Process some data in the context case. - */ - -METHODDEF(void) -pre_process_context (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, - JDIMENSION in_rows_avail, - JSAMPIMAGE output_buf, JDIMENSION *out_row_group_ctr, - JDIMENSION out_row_groups_avail) -{ - my_prep_ptr prep = (my_prep_ptr) cinfo->prep; - int numrows, ci; - int buf_height = cinfo->max_v_samp_factor * 3; - JDIMENSION inrows; - - while (*out_row_group_ctr < out_row_groups_avail) { - if (*in_row_ctr < in_rows_avail) { - /* Do color conversion to fill the conversion buffer. */ - inrows = in_rows_avail - *in_row_ctr; - numrows = prep->next_buf_stop - prep->next_buf_row; - numrows = (int) MIN((JDIMENSION) numrows, inrows); - (*cinfo->cconvert->color_convert) (cinfo, input_buf + *in_row_ctr, - prep->color_buf, - (JDIMENSION) prep->next_buf_row, - numrows); - /* Pad at top of image, if first time through */ - if (prep->rows_to_go == cinfo->image_height) { - for (ci = 0; ci < cinfo->num_components; ci++) { - int row; - for (row = 1; row <= cinfo->max_v_samp_factor; row++) { - jcopy_sample_rows(prep->color_buf[ci], 0, - prep->color_buf[ci], -row, - 1, cinfo->image_width); - } - } - } - *in_row_ctr += numrows; - prep->next_buf_row += numrows; - prep->rows_to_go -= numrows; - } else { - /* Return for more data, unless we are at the bottom of the image. */ - if (prep->rows_to_go != 0) - break; - /* When at bottom of image, pad to fill the conversion buffer. */ - if (prep->next_buf_row < prep->next_buf_stop) { - for (ci = 0; ci < cinfo->num_components; ci++) { - expand_bottom_edge(prep->color_buf[ci], cinfo->image_width, - prep->next_buf_row, prep->next_buf_stop); - } - prep->next_buf_row = prep->next_buf_stop; - } - } - /* If we've gotten enough data, downsample a row group. */ - if (prep->next_buf_row == prep->next_buf_stop) { - (*cinfo->downsample->downsample) (cinfo, - prep->color_buf, - (JDIMENSION) prep->this_row_group, - output_buf, *out_row_group_ctr); - (*out_row_group_ctr)++; - /* Advance pointers with wraparound as necessary. */ - prep->this_row_group += cinfo->max_v_samp_factor; - if (prep->this_row_group >= buf_height) - prep->this_row_group = 0; - if (prep->next_buf_row >= buf_height) - prep->next_buf_row = 0; - prep->next_buf_stop = prep->next_buf_row + cinfo->max_v_samp_factor; - } - } -} - - -/* - * Create the wrapped-around downsampling input buffer needed for context mode. - */ - -LOCAL(void) -create_context_buffer (j_compress_ptr cinfo) -{ - my_prep_ptr prep = (my_prep_ptr) cinfo->prep; - int rgroup_height = cinfo->max_v_samp_factor; - int ci, i; - jpeg_component_info * compptr; - JSAMPARRAY true_buffer, fake_buffer; - - /* Grab enough space for fake row pointers for all the components; - * we need five row groups' worth of pointers for each component. - */ - fake_buffer = (JSAMPARRAY) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (cinfo->num_components * 5 * rgroup_height) * - SIZEOF(JSAMPROW)); - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Allocate the actual buffer space (3 row groups) for this component. - * We make the buffer wide enough to allow the downsampler to edge-expand - * horizontally within the buffer, if it so chooses. - */ - true_buffer = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) (((long) compptr->width_in_blocks * DCTSIZE * - cinfo->max_h_samp_factor) / compptr->h_samp_factor), - (JDIMENSION) (3 * rgroup_height)); - /* Copy true buffer row pointers into the middle of the fake row array */ - MEMCOPY(fake_buffer + rgroup_height, true_buffer, - 3 * rgroup_height * SIZEOF(JSAMPROW)); - /* Fill in the above and below wraparound pointers */ - for (i = 0; i < rgroup_height; i++) { - fake_buffer[i] = true_buffer[2 * rgroup_height + i]; - fake_buffer[4 * rgroup_height + i] = true_buffer[i]; - } - prep->color_buf[ci] = fake_buffer + rgroup_height; - fake_buffer += 5 * rgroup_height; /* point to space for next component */ - } -} - -#endif /* CONTEXT_ROWS_SUPPORTED */ - - -/* - * Initialize preprocessing controller. - */ - -GLOBAL(void) -jinit_c_prep_controller (j_compress_ptr cinfo, boolean need_full_buffer) -{ - my_prep_ptr prep; - int ci; - jpeg_component_info * compptr; - - if (need_full_buffer) /* safety check */ - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - - prep = (my_prep_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_prep_controller)); - cinfo->prep = (struct jpeg_c_prep_controller *) prep; - prep->pub.start_pass = start_pass_prep; - - /* Allocate the color conversion buffer. - * We make the buffer wide enough to allow the downsampler to edge-expand - * horizontally within the buffer, if it so chooses. - */ - if (cinfo->downsample->need_context_rows) { - /* Set up to provide context rows */ -#ifdef CONTEXT_ROWS_SUPPORTED - prep->pub.pre_process_data = pre_process_context; - create_context_buffer(cinfo); -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else { - /* No context, just make it tall enough for one row group */ - prep->pub.pre_process_data = pre_process_data; - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - prep->color_buf[ci] = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) (((long) compptr->width_in_blocks * DCTSIZE * - cinfo->max_h_samp_factor) / compptr->h_samp_factor), - (JDIMENSION) cinfo->max_v_samp_factor); - } - } -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jcsample.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jcsample.c deleted file mode 100644 index fe29fcab0..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jcsample.c +++ /dev/null @@ -1,519 +0,0 @@ -/* - * jcsample.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains downsampling routines. - * - * Downsampling input data is counted in "row groups". A row group - * is defined to be max_v_samp_factor pixel rows of each component, - * from which the downsampler produces v_samp_factor sample rows. - * A single row group is processed in each call to the downsampler module. - * - * The downsampler is responsible for edge-expansion of its output data - * to fill an integral number of DCT blocks horizontally. The source buffer - * may be modified if it is helpful for this purpose (the source buffer is - * allocated wide enough to correspond to the desired output width). - * The caller (the prep controller) is responsible for vertical padding. - * - * The downsampler may request "context rows" by setting need_context_rows - * during startup. In this case, the input arrays will contain at least - * one row group's worth of pixels above and below the passed-in data; - * the caller will create dummy rows at image top and bottom by replicating - * the first or last real pixel row. - * - * An excellent reference for image resampling is - * Digital Image Warping, George Wolberg, 1990. - * Pub. by IEEE Computer Society Press, Los Alamitos, CA. ISBN 0-8186-8944-7. - * - * The downsampling algorithm used here is a simple average of the source - * pixels covered by the output pixel. The hi-falutin sampling literature - * refers to this as a "box filter". In general the characteristics of a box - * filter are not very good, but for the specific cases we normally use (1:1 - * and 2:1 ratios) the box is equivalent to a "triangle filter" which is not - * nearly so bad. If you intend to use other sampling ratios, you'd be well - * advised to improve this code. - * - * A simple input-smoothing capability is provided. This is mainly intended - * for cleaning up color-dithered GIF input files (if you find it inadequate, - * we suggest using an external filtering program such as pnmconvol). When - * enabled, each input pixel P is replaced by a weighted sum of itself and its - * eight neighbors. P's weight is 1-8*SF and each neighbor's weight is SF, - * where SF = (smoothing_factor / 1024). - * Currently, smoothing is only supported for 2h2v sampling factors. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Pointer to routine to downsample a single component */ -typedef JMETHOD(void, downsample1_ptr, - (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY output_data)); - -/* Private subobject */ - -typedef struct { - struct jpeg_downsampler pub; /* public fields */ - - /* Downsampling method pointers, one per component */ - downsample1_ptr methods[MAX_COMPONENTS]; -} my_downsampler; - -typedef my_downsampler * my_downsample_ptr; - - -/* - * Initialize for a downsampling pass. - */ - -METHODDEF(void) -start_pass_downsample (j_compress_ptr cinfo) -{ - /* no work for now */ -} - - -/* - * Expand a component horizontally from width input_cols to width output_cols, - * by duplicating the rightmost samples. - */ - -LOCAL(void) -expand_right_edge (JSAMPARRAY image_data, int num_rows, - JDIMENSION input_cols, JDIMENSION output_cols) -{ - register JSAMPROW ptr; - register JSAMPLE pixval; - register int count; - int row; - int numcols = (int) (output_cols - input_cols); - - if (numcols > 0) { - for (row = 0; row < num_rows; row++) { - ptr = image_data[row] + input_cols; - pixval = ptr[-1]; /* don't need GETJSAMPLE() here */ - for (count = numcols; count > 0; count--) - *ptr++ = pixval; - } - } -} - - -/* - * Do downsampling for a whole row group (all components). - * - * In this version we simply downsample each component independently. - */ - -METHODDEF(void) -sep_downsample (j_compress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION in_row_index, - JSAMPIMAGE output_buf, JDIMENSION out_row_group_index) -{ - my_downsample_ptr downsample = (my_downsample_ptr) cinfo->downsample; - int ci; - jpeg_component_info * compptr; - JSAMPARRAY in_ptr, out_ptr; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - in_ptr = input_buf[ci] + in_row_index; - out_ptr = output_buf[ci] + (out_row_group_index * compptr->v_samp_factor); - (*downsample->methods[ci]) (cinfo, compptr, in_ptr, out_ptr); - } -} - - -/* - * Downsample pixel values of a single component. - * One row group is processed per call. - * This version handles arbitrary integral sampling ratios, without smoothing. - * Note that this version is not actually used for customary sampling ratios. - */ - -METHODDEF(void) -int_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY output_data) -{ - int inrow, outrow, h_expand, v_expand, numpix, numpix2, h, v; - JDIMENSION outcol, outcol_h; /* outcol_h == outcol*h_expand */ - JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; - JSAMPROW inptr, outptr; - INT32 outvalue; - - h_expand = cinfo->max_h_samp_factor / compptr->h_samp_factor; - v_expand = cinfo->max_v_samp_factor / compptr->v_samp_factor; - numpix = h_expand * v_expand; - numpix2 = numpix/2; - - /* Expand input data enough to let all the output samples be generated - * by the standard loop. Special-casing padded output would be more - * efficient. - */ - expand_right_edge(input_data, cinfo->max_v_samp_factor, - cinfo->image_width, output_cols * h_expand); - - inrow = 0; - for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { - outptr = output_data[outrow]; - for (outcol = 0, outcol_h = 0; outcol < output_cols; - outcol++, outcol_h += h_expand) { - outvalue = 0; - for (v = 0; v < v_expand; v++) { - inptr = input_data[inrow+v] + outcol_h; - for (h = 0; h < h_expand; h++) { - outvalue += (INT32) GETJSAMPLE(*inptr++); - } - } - *outptr++ = (JSAMPLE) ((outvalue + numpix2) / numpix); - } - inrow += v_expand; - } -} - - -/* - * Downsample pixel values of a single component. - * This version handles the special case of a full-size component, - * without smoothing. - */ - -METHODDEF(void) -fullsize_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY output_data) -{ - /* Copy the data */ - jcopy_sample_rows(input_data, 0, output_data, 0, - cinfo->max_v_samp_factor, cinfo->image_width); - /* Edge-expand */ - expand_right_edge(output_data, cinfo->max_v_samp_factor, - cinfo->image_width, compptr->width_in_blocks * DCTSIZE); -} - - -/* - * Downsample pixel values of a single component. - * This version handles the common case of 2:1 horizontal and 1:1 vertical, - * without smoothing. - * - * A note about the "bias" calculations: when rounding fractional values to - * integer, we do not want to always round 0.5 up to the next integer. - * If we did that, we'd introduce a noticeable bias towards larger values. - * Instead, this code is arranged so that 0.5 will be rounded up or down at - * alternate pixel locations (a simple ordered dither pattern). - */ - -METHODDEF(void) -h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY output_data) -{ - int outrow; - JDIMENSION outcol; - JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; - register JSAMPROW inptr, outptr; - register int bias; - - /* Expand input data enough to let all the output samples be generated - * by the standard loop. Special-casing padded output would be more - * efficient. - */ - expand_right_edge(input_data, cinfo->max_v_samp_factor, - cinfo->image_width, output_cols * 2); - - for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { - outptr = output_data[outrow]; - inptr = input_data[outrow]; - bias = 0; /* bias = 0,1,0,1,... for successive samples */ - for (outcol = 0; outcol < output_cols; outcol++) { - *outptr++ = (JSAMPLE) ((GETJSAMPLE(*inptr) + GETJSAMPLE(inptr[1]) - + bias) >> 1); - bias ^= 1; /* 0=>1, 1=>0 */ - inptr += 2; - } - } -} - - -/* - * Downsample pixel values of a single component. - * This version handles the standard case of 2:1 horizontal and 2:1 vertical, - * without smoothing. - */ - -METHODDEF(void) -h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY output_data) -{ - int inrow, outrow; - JDIMENSION outcol; - JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; - register JSAMPROW inptr0, inptr1, outptr; - register int bias; - - /* Expand input data enough to let all the output samples be generated - * by the standard loop. Special-casing padded output would be more - * efficient. - */ - expand_right_edge(input_data, cinfo->max_v_samp_factor, - cinfo->image_width, output_cols * 2); - - inrow = 0; - for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { - outptr = output_data[outrow]; - inptr0 = input_data[inrow]; - inptr1 = input_data[inrow+1]; - bias = 1; /* bias = 1,2,1,2,... for successive samples */ - for (outcol = 0; outcol < output_cols; outcol++) { - *outptr++ = (JSAMPLE) ((GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) + - GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]) - + bias) >> 2); - bias ^= 3; /* 1=>2, 2=>1 */ - inptr0 += 2; inptr1 += 2; - } - inrow += 2; - } -} - - -#ifdef INPUT_SMOOTHING_SUPPORTED - -/* - * Downsample pixel values of a single component. - * This version handles the standard case of 2:1 horizontal and 2:1 vertical, - * with smoothing. One row of context is required. - */ - -METHODDEF(void) -h2v2_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY output_data) -{ - int inrow, outrow; - JDIMENSION colctr; - JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; - register JSAMPROW inptr0, inptr1, above_ptr, below_ptr, outptr; - INT32 membersum, neighsum, memberscale, neighscale; - - /* Expand input data enough to let all the output samples be generated - * by the standard loop. Special-casing padded output would be more - * efficient. - */ - expand_right_edge(input_data - 1, cinfo->max_v_samp_factor + 2, - cinfo->image_width, output_cols * 2); - - /* We don't bother to form the individual "smoothed" input pixel values; - * we can directly compute the output which is the average of the four - * smoothed values. Each of the four member pixels contributes a fraction - * (1-8*SF) to its own smoothed image and a fraction SF to each of the three - * other smoothed pixels, therefore a total fraction (1-5*SF)/4 to the final - * output. The four corner-adjacent neighbor pixels contribute a fraction - * SF to just one smoothed pixel, or SF/4 to the final output; while the - * eight edge-adjacent neighbors contribute SF to each of two smoothed - * pixels, or SF/2 overall. In order to use integer arithmetic, these - * factors are scaled by 2^16 = 65536. - * Also recall that SF = smoothing_factor / 1024. - */ - - memberscale = 16384 - cinfo->smoothing_factor * 80; /* scaled (1-5*SF)/4 */ - neighscale = cinfo->smoothing_factor * 16; /* scaled SF/4 */ - - inrow = 0; - for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { - outptr = output_data[outrow]; - inptr0 = input_data[inrow]; - inptr1 = input_data[inrow+1]; - above_ptr = input_data[inrow-1]; - below_ptr = input_data[inrow+2]; - - /* Special case for first column: pretend column -1 is same as column 0 */ - membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) + - GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]); - neighsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[1]) + - GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[1]) + - GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[2]) + - GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[2]); - neighsum += neighsum; - neighsum += GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[2]) + - GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[2]); - membersum = membersum * memberscale + neighsum * neighscale; - *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16); - inptr0 += 2; inptr1 += 2; above_ptr += 2; below_ptr += 2; - - for (colctr = output_cols - 2; colctr > 0; colctr--) { - /* sum of pixels directly mapped to this output element */ - membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) + - GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]); - /* sum of edge-neighbor pixels */ - neighsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[1]) + - GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[1]) + - GETJSAMPLE(inptr0[-1]) + GETJSAMPLE(inptr0[2]) + - GETJSAMPLE(inptr1[-1]) + GETJSAMPLE(inptr1[2]); - /* The edge-neighbors count twice as much as corner-neighbors */ - neighsum += neighsum; - /* Add in the corner-neighbors */ - neighsum += GETJSAMPLE(above_ptr[-1]) + GETJSAMPLE(above_ptr[2]) + - GETJSAMPLE(below_ptr[-1]) + GETJSAMPLE(below_ptr[2]); - /* form final output scaled up by 2^16 */ - membersum = membersum * memberscale + neighsum * neighscale; - /* round, descale and output it */ - *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16); - inptr0 += 2; inptr1 += 2; above_ptr += 2; below_ptr += 2; - } - - /* Special case for last column */ - membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) + - GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]); - neighsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[1]) + - GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[1]) + - GETJSAMPLE(inptr0[-1]) + GETJSAMPLE(inptr0[1]) + - GETJSAMPLE(inptr1[-1]) + GETJSAMPLE(inptr1[1]); - neighsum += neighsum; - neighsum += GETJSAMPLE(above_ptr[-1]) + GETJSAMPLE(above_ptr[1]) + - GETJSAMPLE(below_ptr[-1]) + GETJSAMPLE(below_ptr[1]); - membersum = membersum * memberscale + neighsum * neighscale; - *outptr = (JSAMPLE) ((membersum + 32768) >> 16); - - inrow += 2; - } -} - - -/* - * Downsample pixel values of a single component. - * This version handles the special case of a full-size component, - * with smoothing. One row of context is required. - */ - -METHODDEF(void) -fullsize_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr, - JSAMPARRAY input_data, JSAMPARRAY output_data) -{ - int outrow; - JDIMENSION colctr; - JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; - register JSAMPROW inptr, above_ptr, below_ptr, outptr; - INT32 membersum, neighsum, memberscale, neighscale; - int colsum, lastcolsum, nextcolsum; - - /* Expand input data enough to let all the output samples be generated - * by the standard loop. Special-casing padded output would be more - * efficient. - */ - expand_right_edge(input_data - 1, cinfo->max_v_samp_factor + 2, - cinfo->image_width, output_cols); - - /* Each of the eight neighbor pixels contributes a fraction SF to the - * smoothed pixel, while the main pixel contributes (1-8*SF). In order - * to use integer arithmetic, these factors are multiplied by 2^16 = 65536. - * Also recall that SF = smoothing_factor / 1024. - */ - - memberscale = 65536L - cinfo->smoothing_factor * 512L; /* scaled 1-8*SF */ - neighscale = cinfo->smoothing_factor * 64; /* scaled SF */ - - for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { - outptr = output_data[outrow]; - inptr = input_data[outrow]; - above_ptr = input_data[outrow-1]; - below_ptr = input_data[outrow+1]; - - /* Special case for first column */ - colsum = GETJSAMPLE(*above_ptr++) + GETJSAMPLE(*below_ptr++) + - GETJSAMPLE(*inptr); - membersum = GETJSAMPLE(*inptr++); - nextcolsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(*below_ptr) + - GETJSAMPLE(*inptr); - neighsum = colsum + (colsum - membersum) + nextcolsum; - membersum = membersum * memberscale + neighsum * neighscale; - *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16); - lastcolsum = colsum; colsum = nextcolsum; - - for (colctr = output_cols - 2; colctr > 0; colctr--) { - membersum = GETJSAMPLE(*inptr++); - above_ptr++; below_ptr++; - nextcolsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(*below_ptr) + - GETJSAMPLE(*inptr); - neighsum = lastcolsum + (colsum - membersum) + nextcolsum; - membersum = membersum * memberscale + neighsum * neighscale; - *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16); - lastcolsum = colsum; colsum = nextcolsum; - } - - /* Special case for last column */ - membersum = GETJSAMPLE(*inptr); - neighsum = lastcolsum + (colsum - membersum) + colsum; - membersum = membersum * memberscale + neighsum * neighscale; - *outptr = (JSAMPLE) ((membersum + 32768) >> 16); - - } -} - -#endif /* INPUT_SMOOTHING_SUPPORTED */ - - -/* - * Module initialization routine for downsampling. - * Note that we must select a routine for each component. - */ - -GLOBAL(void) -jinit_downsampler (j_compress_ptr cinfo) -{ - my_downsample_ptr downsample; - int ci; - jpeg_component_info * compptr; - boolean smoothok = TRUE; - - downsample = (my_downsample_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_downsampler)); - cinfo->downsample = (struct jpeg_downsampler *) downsample; - downsample->pub.start_pass = start_pass_downsample; - downsample->pub.downsample = sep_downsample; - downsample->pub.need_context_rows = FALSE; - - if (cinfo->CCIR601_sampling) - ERREXIT(cinfo, JERR_CCIR601_NOTIMPL); - - /* Verify we can handle the sampling factors, and set up method pointers */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - if (compptr->h_samp_factor == cinfo->max_h_samp_factor && - compptr->v_samp_factor == cinfo->max_v_samp_factor) { -#ifdef INPUT_SMOOTHING_SUPPORTED - if (cinfo->smoothing_factor) { - downsample->methods[ci] = fullsize_smooth_downsample; - downsample->pub.need_context_rows = TRUE; - } else -#endif - downsample->methods[ci] = fullsize_downsample; - } else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor && - compptr->v_samp_factor == cinfo->max_v_samp_factor) { - smoothok = FALSE; - downsample->methods[ci] = h2v1_downsample; - } else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor && - compptr->v_samp_factor * 2 == cinfo->max_v_samp_factor) { -#ifdef INPUT_SMOOTHING_SUPPORTED - if (cinfo->smoothing_factor) { - downsample->methods[ci] = h2v2_smooth_downsample; - downsample->pub.need_context_rows = TRUE; - } else -#endif - downsample->methods[ci] = h2v2_downsample; - } else if ((cinfo->max_h_samp_factor % compptr->h_samp_factor) == 0 && - (cinfo->max_v_samp_factor % compptr->v_samp_factor) == 0) { - smoothok = FALSE; - downsample->methods[ci] = int_downsample; - } else - ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL); - } - -#ifdef INPUT_SMOOTHING_SUPPORTED - if (cinfo->smoothing_factor && !smoothok) - TRACEMS(cinfo, 0, JTRC_SMOOTH_NOTIMPL); -#endif -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jctrans.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jctrans.c deleted file mode 100644 index 8b36e3634..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jctrans.c +++ /dev/null @@ -1,388 +0,0 @@ -/* - * jctrans.c - * - * Copyright (C) 1995-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains library routines for transcoding compression, - * that is, writing raw DCT coefficient arrays to an output JPEG file. - * The routines in jcapimin.c will also be needed by a transcoder. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Forward declarations */ -LOCAL(void) transencode_master_selection - JPP((j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays)); -LOCAL(void) transencode_coef_controller - JPP((j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays)); - - -/* - * Compression initialization for writing raw-coefficient data. - * Before calling this, all parameters and a data destination must be set up. - * Call jpeg_finish_compress() to actually write the data. - * - * The number of passed virtual arrays must match cinfo->num_components. - * Note that the virtual arrays need not be filled or even realized at - * the time write_coefficients is called; indeed, if the virtual arrays - * were requested from this compression object's memory manager, they - * typically will be realized during this routine and filled afterwards. - */ - -GLOBAL(void) -jpeg_write_coefficients (j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays) -{ - if (cinfo->global_state != CSTATE_START) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - /* Mark all tables to be written */ - jpeg_suppress_tables(cinfo, FALSE); - /* (Re)initialize error mgr and destination modules */ - (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); - (*cinfo->dest->init_destination) (cinfo); - /* Perform master selection of active modules */ - transencode_master_selection(cinfo, coef_arrays); - /* Wait for jpeg_finish_compress() call */ - cinfo->next_scanline = 0; /* so jpeg_write_marker works */ - cinfo->global_state = CSTATE_WRCOEFS; -} - - -/* - * Initialize the compression object with default parameters, - * then copy from the source object all parameters needed for lossless - * transcoding. Parameters that can be varied without loss (such as - * scan script and Huffman optimization) are left in their default states. - */ - -GLOBAL(void) -jpeg_copy_critical_parameters (j_decompress_ptr srcinfo, - j_compress_ptr dstinfo) -{ - JQUANT_TBL ** qtblptr; - jpeg_component_info *incomp, *outcomp; - JQUANT_TBL *c_quant, *slot_quant; - int tblno, ci, coefi; - - /* Safety check to ensure start_compress not called yet. */ - if (dstinfo->global_state != CSTATE_START) - ERREXIT1(dstinfo, JERR_BAD_STATE, dstinfo->global_state); - /* Copy fundamental image dimensions */ - dstinfo->image_width = srcinfo->image_width; - dstinfo->image_height = srcinfo->image_height; - dstinfo->input_components = srcinfo->num_components; - dstinfo->in_color_space = srcinfo->jpeg_color_space; - /* Initialize all parameters to default values */ - jpeg_set_defaults(dstinfo); - /* jpeg_set_defaults may choose wrong colorspace, eg YCbCr if input is RGB. - * Fix it to get the right header markers for the image colorspace. - */ - jpeg_set_colorspace(dstinfo, srcinfo->jpeg_color_space); - dstinfo->data_precision = srcinfo->data_precision; - dstinfo->CCIR601_sampling = srcinfo->CCIR601_sampling; - /* Copy the source's quantization tables. */ - for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) { - if (srcinfo->quant_tbl_ptrs[tblno] != NULL) { - qtblptr = & dstinfo->quant_tbl_ptrs[tblno]; - if (*qtblptr == NULL) - *qtblptr = jpeg_alloc_quant_table((j_common_ptr) dstinfo); - MEMCOPY((*qtblptr)->quantval, - srcinfo->quant_tbl_ptrs[tblno]->quantval, - SIZEOF((*qtblptr)->quantval)); - (*qtblptr)->sent_table = FALSE; - } - } - /* Copy the source's per-component info. - * Note we assume jpeg_set_defaults has allocated the dest comp_info array. - */ - dstinfo->num_components = srcinfo->num_components; - if (dstinfo->num_components < 1 || dstinfo->num_components > MAX_COMPONENTS) - ERREXIT2(dstinfo, JERR_COMPONENT_COUNT, dstinfo->num_components, - MAX_COMPONENTS); - for (ci = 0, incomp = srcinfo->comp_info, outcomp = dstinfo->comp_info; - ci < dstinfo->num_components; ci++, incomp++, outcomp++) { - outcomp->component_id = incomp->component_id; - outcomp->h_samp_factor = incomp->h_samp_factor; - outcomp->v_samp_factor = incomp->v_samp_factor; - outcomp->quant_tbl_no = incomp->quant_tbl_no; - /* Make sure saved quantization table for component matches the qtable - * slot. If not, the input file re-used this qtable slot. - * IJG encoder currently cannot duplicate this. - */ - tblno = outcomp->quant_tbl_no; - if (tblno < 0 || tblno >= NUM_QUANT_TBLS || - srcinfo->quant_tbl_ptrs[tblno] == NULL) - ERREXIT1(dstinfo, JERR_NO_QUANT_TABLE, tblno); - slot_quant = srcinfo->quant_tbl_ptrs[tblno]; - c_quant = incomp->quant_table; - if (c_quant != NULL) { - for (coefi = 0; coefi < DCTSIZE2; coefi++) { - if (c_quant->quantval[coefi] != slot_quant->quantval[coefi]) - ERREXIT1(dstinfo, JERR_MISMATCHED_QUANT_TABLE, tblno); - } - } - /* Note: we do not copy the source's Huffman table assignments; - * instead we rely on jpeg_set_colorspace to have made a suitable choice. - */ - } - /* Also copy JFIF version and resolution information, if available. - * Strictly speaking this isn't "critical" info, but it's nearly - * always appropriate to copy it if available. In particular, - * if the application chooses to copy JFIF 1.02 extension markers from - * the source file, we need to copy the version to make sure we don't - * emit a file that has 1.02 extensions but a claimed version of 1.01. - * We will *not*, however, copy version info from mislabeled "2.01" files. - */ - if (srcinfo->saw_JFIF_marker) { - if (srcinfo->JFIF_major_version == 1) { - dstinfo->JFIF_major_version = srcinfo->JFIF_major_version; - dstinfo->JFIF_minor_version = srcinfo->JFIF_minor_version; - } - dstinfo->density_unit = srcinfo->density_unit; - dstinfo->X_density = srcinfo->X_density; - dstinfo->Y_density = srcinfo->Y_density; - } -} - - -/* - * Master selection of compression modules for transcoding. - * This substitutes for jcinit.c's initialization of the full compressor. - */ - -LOCAL(void) -transencode_master_selection (j_compress_ptr cinfo, - jvirt_barray_ptr * coef_arrays) -{ - /* Although we don't actually use input_components for transcoding, - * jcmaster.c's initial_setup will complain if input_components is 0. - */ - cinfo->input_components = 1; - /* Initialize master control (includes parameter checking/processing) */ - jinit_c_master_control(cinfo, TRUE /* transcode only */); - - /* Entropy encoding: either Huffman or arithmetic coding. */ - if (cinfo->arith_code) { - ERREXIT(cinfo, JERR_ARITH_NOTIMPL); - } else { - if (cinfo->progressive_mode) { -#ifdef C_PROGRESSIVE_SUPPORTED - jinit_phuff_encoder(cinfo); -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else - jinit_huff_encoder(cinfo); - } - - /* We need a special coefficient buffer controller. */ - transencode_coef_controller(cinfo, coef_arrays); - - jinit_marker_writer(cinfo); - - /* We can now tell the memory manager to allocate virtual arrays. */ - (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); - - /* Write the datastream header (SOI, JFIF) immediately. - * Frame and scan headers are postponed till later. - * This lets application insert special markers after the SOI. - */ - (*cinfo->marker->write_file_header) (cinfo); -} - - -/* - * The rest of this file is a special implementation of the coefficient - * buffer controller. This is similar to jccoefct.c, but it handles only - * output from presupplied virtual arrays. Furthermore, we generate any - * dummy padding blocks on-the-fly rather than expecting them to be present - * in the arrays. - */ - -/* Private buffer controller object */ - -typedef struct { - struct jpeg_c_coef_controller pub; /* public fields */ - - JDIMENSION iMCU_row_num; /* iMCU row # within image */ - JDIMENSION mcu_ctr; /* counts MCUs processed in current row */ - int MCU_vert_offset; /* counts MCU rows within iMCU row */ - int MCU_rows_per_iMCU_row; /* number of such rows needed */ - - /* Virtual block array for each component. */ - jvirt_barray_ptr * whole_image; - - /* Workspace for constructing dummy blocks at right/bottom edges. */ - JBLOCKROW dummy_buffer[C_MAX_BLOCKS_IN_MCU]; -} my_coef_controller; - -typedef my_coef_controller * my_coef_ptr; - - -LOCAL(void) -start_iMCU_row (j_compress_ptr cinfo) -/* Reset within-iMCU-row counters for a new row */ -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - - /* In an interleaved scan, an MCU row is the same as an iMCU row. - * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows. - * But at the bottom of the image, process only what's left. - */ - if (cinfo->comps_in_scan > 1) { - coef->MCU_rows_per_iMCU_row = 1; - } else { - if (coef->iMCU_row_num < (cinfo->total_iMCU_rows-1)) - coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; - else - coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; - } - - coef->mcu_ctr = 0; - coef->MCU_vert_offset = 0; -} - - -/* - * Initialize for a processing pass. - */ - -METHODDEF(void) -start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - - if (pass_mode != JBUF_CRANK_DEST) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - - coef->iMCU_row_num = 0; - start_iMCU_row(cinfo); -} - - -/* - * Process some data. - * We process the equivalent of one fully interleaved MCU row ("iMCU" row) - * per call, ie, v_samp_factor block rows for each component in the scan. - * The data is obtained from the virtual arrays and fed to the entropy coder. - * Returns TRUE if the iMCU row is completed, FALSE if suspended. - * - * NB: input_buf is ignored; it is likely to be a NULL pointer. - */ - -METHODDEF(boolean) -compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION MCU_col_num; /* index of current MCU within row */ - JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1; - JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; - int blkn, ci, xindex, yindex, yoffset, blockcnt; - JDIMENSION start_col; - JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN]; - JBLOCKROW MCU_buffer[C_MAX_BLOCKS_IN_MCU]; - JBLOCKROW buffer_ptr; - jpeg_component_info *compptr; - - /* Align the virtual buffers for the components used in this scan. */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - buffer[ci] = (*cinfo->mem->access_virt_barray) - ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index], - coef->iMCU_row_num * compptr->v_samp_factor, - (JDIMENSION) compptr->v_samp_factor, FALSE); - } - - /* Loop to process one whole iMCU row */ - for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; - yoffset++) { - for (MCU_col_num = coef->mcu_ctr; MCU_col_num < cinfo->MCUs_per_row; - MCU_col_num++) { - /* Construct list of pointers to DCT blocks belonging to this MCU */ - blkn = 0; /* index of current DCT block within MCU */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - start_col = MCU_col_num * compptr->MCU_width; - blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width - : compptr->last_col_width; - for (yindex = 0; yindex < compptr->MCU_height; yindex++) { - if (coef->iMCU_row_num < last_iMCU_row || - yindex+yoffset < compptr->last_row_height) { - /* Fill in pointers to real blocks in this row */ - buffer_ptr = buffer[ci][yindex+yoffset] + start_col; - for (xindex = 0; xindex < blockcnt; xindex++) - MCU_buffer[blkn++] = buffer_ptr++; - } else { - /* At bottom of image, need a whole row of dummy blocks */ - xindex = 0; - } - /* Fill in any dummy blocks needed in this row. - * Dummy blocks are filled in the same way as in jccoefct.c: - * all zeroes in the AC entries, DC entries equal to previous - * block's DC value. The init routine has already zeroed the - * AC entries, so we need only set the DC entries correctly. - */ - for (; xindex < compptr->MCU_width; xindex++) { - MCU_buffer[blkn] = coef->dummy_buffer[blkn]; - MCU_buffer[blkn][0][0] = MCU_buffer[blkn-1][0][0]; - blkn++; - } - } - } - /* Try to write the MCU. */ - if (! (*cinfo->entropy->encode_mcu) (cinfo, MCU_buffer)) { - /* Suspension forced; update state counters and exit */ - coef->MCU_vert_offset = yoffset; - coef->mcu_ctr = MCU_col_num; - return FALSE; - } - } - /* Completed an MCU row, but perhaps not an iMCU row */ - coef->mcu_ctr = 0; - } - /* Completed the iMCU row, advance counters for next one */ - coef->iMCU_row_num++; - start_iMCU_row(cinfo); - return TRUE; -} - - -/* - * Initialize coefficient buffer controller. - * - * Each passed coefficient array must be the right size for that - * coefficient: width_in_blocks wide and height_in_blocks high, - * with unitheight at least v_samp_factor. - */ - -LOCAL(void) -transencode_coef_controller (j_compress_ptr cinfo, - jvirt_barray_ptr * coef_arrays) -{ - my_coef_ptr coef; - JBLOCKROW buffer; - int i; - - coef = (my_coef_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_coef_controller)); - cinfo->coef = (struct jpeg_c_coef_controller *) coef; - coef->pub.start_pass = start_pass_coef; - coef->pub.compress_data = compress_output; - - /* Save pointer to virtual arrays */ - coef->whole_image = coef_arrays; - - /* Allocate and pre-zero space for dummy DCT blocks. */ - buffer = (JBLOCKROW) - (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, - C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); - jzero_far((void FAR *) buffer, C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); - for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) { - coef->dummy_buffer[i] = buffer + i; - } -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jdapimin.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jdapimin.c deleted file mode 100644 index bd1df927f..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jdapimin.c +++ /dev/null @@ -1,395 +0,0 @@ -/* - * jdapimin.c - * - * Copyright (C) 1994-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains application interface code for the decompression half - * of the JPEG library. These are the "minimum" API routines that may be - * needed in either the normal full-decompression case or the - * transcoding-only case. - * - * Most of the routines intended to be called directly by an application - * are in this file or in jdapistd.c. But also see jcomapi.c for routines - * shared by compression and decompression, and jdtrans.c for the transcoding - * case. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * Initialization of a JPEG decompression object. - * The error manager must already be set up (in case memory manager fails). - */ - -GLOBAL(void) -jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize) -{ - int i; - - /* Guard against version mismatches between library and caller. */ - cinfo->mem = NULL; /* so jpeg_destroy knows mem mgr not called */ - if (version != JPEG_LIB_VERSION) - ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version); - if (structsize != SIZEOF(struct jpeg_decompress_struct)) - ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE, - (int) SIZEOF(struct jpeg_decompress_struct), (int) structsize); - - /* For debugging purposes, we zero the whole master structure. - * But the application has already set the err pointer, and may have set - * client_data, so we have to save and restore those fields. - * Note: if application hasn't set client_data, tools like Purify may - * complain here. - */ - { - struct jpeg_error_mgr * err = cinfo->err; - void * client_data = cinfo->client_data; /* ignore Purify complaint here */ - MEMZERO(cinfo, SIZEOF(struct jpeg_decompress_struct)); - cinfo->err = err; - cinfo->client_data = client_data; - } - cinfo->is_decompressor = TRUE; - - /* Initialize a memory manager instance for this object */ - jinit_memory_mgr((j_common_ptr) cinfo); - - /* Zero out pointers to permanent structures. */ - cinfo->progress = NULL; - cinfo->src = NULL; - - for (i = 0; i < NUM_QUANT_TBLS; i++) - cinfo->quant_tbl_ptrs[i] = NULL; - - for (i = 0; i < NUM_HUFF_TBLS; i++) { - cinfo->dc_huff_tbl_ptrs[i] = NULL; - cinfo->ac_huff_tbl_ptrs[i] = NULL; - } - - /* Initialize marker processor so application can override methods - * for COM, APPn markers before calling jpeg_read_header. - */ - cinfo->marker_list = NULL; - jinit_marker_reader(cinfo); - - /* And initialize the overall input controller. */ - jinit_input_controller(cinfo); - - /* OK, I'm ready */ - cinfo->global_state = DSTATE_START; -} - - -/* - * Destruction of a JPEG decompression object - */ - -GLOBAL(void) -jpeg_destroy_decompress (j_decompress_ptr cinfo) -{ - jpeg_destroy((j_common_ptr) cinfo); /* use common routine */ -} - - -/* - * Abort processing of a JPEG decompression operation, - * but don't destroy the object itself. - */ - -GLOBAL(void) -jpeg_abort_decompress (j_decompress_ptr cinfo) -{ - jpeg_abort((j_common_ptr) cinfo); /* use common routine */ -} - - -/* - * Set default decompression parameters. - */ - -LOCAL(void) -default_decompress_parms (j_decompress_ptr cinfo) -{ - /* Guess the input colorspace, and set output colorspace accordingly. */ - /* (Wish JPEG committee had provided a real way to specify this...) */ - /* Note application may override our guesses. */ - switch (cinfo->num_components) { - case 1: - cinfo->jpeg_color_space = JCS_GRAYSCALE; - cinfo->out_color_space = JCS_GRAYSCALE; - break; - - case 3: - if (cinfo->saw_JFIF_marker) { - cinfo->jpeg_color_space = JCS_YCbCr; /* JFIF implies YCbCr */ - } else if (cinfo->saw_Adobe_marker) { - switch (cinfo->Adobe_transform) { - case 0: - cinfo->jpeg_color_space = JCS_RGB; - break; - case 1: - cinfo->jpeg_color_space = JCS_YCbCr; - break; - default: - WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform); - cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */ - break; - } - } else { - /* Saw no special markers, try to guess from the component IDs */ - int cid0 = cinfo->comp_info[0].component_id; - int cid1 = cinfo->comp_info[1].component_id; - int cid2 = cinfo->comp_info[2].component_id; - - if (cid0 == 1 && cid1 == 2 && cid2 == 3) - cinfo->jpeg_color_space = JCS_YCbCr; /* assume JFIF w/out marker */ - else if (cid0 == 82 && cid1 == 71 && cid2 == 66) - cinfo->jpeg_color_space = JCS_RGB; /* ASCII 'R', 'G', 'B' */ - else { - TRACEMS3(cinfo, 1, JTRC_UNKNOWN_IDS, cid0, cid1, cid2); - cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */ - } - } - /* Always guess RGB is proper output colorspace. */ - cinfo->out_color_space = JCS_RGB; - break; - - case 4: - if (cinfo->saw_Adobe_marker) { - switch (cinfo->Adobe_transform) { - case 0: - cinfo->jpeg_color_space = JCS_CMYK; - break; - case 2: - cinfo->jpeg_color_space = JCS_YCCK; - break; - default: - WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform); - cinfo->jpeg_color_space = JCS_YCCK; /* assume it's YCCK */ - break; - } - } else { - /* No special markers, assume straight CMYK. */ - cinfo->jpeg_color_space = JCS_CMYK; - } - cinfo->out_color_space = JCS_CMYK; - break; - - default: - cinfo->jpeg_color_space = JCS_UNKNOWN; - cinfo->out_color_space = JCS_UNKNOWN; - break; - } - - /* Set defaults for other decompression parameters. */ - cinfo->scale_num = 1; /* 1:1 scaling */ - cinfo->scale_denom = 1; - cinfo->output_gamma = 1.0; - cinfo->buffered_image = FALSE; - cinfo->raw_data_out = FALSE; - cinfo->dct_method = JDCT_DEFAULT; - cinfo->do_fancy_upsampling = TRUE; - cinfo->do_block_smoothing = TRUE; - cinfo->quantize_colors = FALSE; - /* We set these in case application only sets quantize_colors. */ - cinfo->dither_mode = JDITHER_FS; -#ifdef QUANT_2PASS_SUPPORTED - cinfo->two_pass_quantize = TRUE; -#else - cinfo->two_pass_quantize = FALSE; -#endif - cinfo->desired_number_of_colors = 256; - cinfo->colormap = NULL; - /* Initialize for no mode change in buffered-image mode. */ - cinfo->enable_1pass_quant = FALSE; - cinfo->enable_external_quant = FALSE; - cinfo->enable_2pass_quant = FALSE; -} - - -/* - * Decompression startup: read start of JPEG datastream to see what's there. - * Need only initialize JPEG object and supply a data source before calling. - * - * This routine will read as far as the first SOS marker (ie, actual start of - * compressed data), and will save all tables and parameters in the JPEG - * object. It will also initialize the decompression parameters to default - * values, and finally return JPEG_HEADER_OK. On return, the application may - * adjust the decompression parameters and then call jpeg_start_decompress. - * (Or, if the application only wanted to determine the image parameters, - * the data need not be decompressed. In that case, call jpeg_abort or - * jpeg_destroy to release any temporary space.) - * If an abbreviated (tables only) datastream is presented, the routine will - * return JPEG_HEADER_TABLES_ONLY upon reaching EOI. The application may then - * re-use the JPEG object to read the abbreviated image datastream(s). - * It is unnecessary (but OK) to call jpeg_abort in this case. - * The JPEG_SUSPENDED return code only occurs if the data source module - * requests suspension of the decompressor. In this case the application - * should load more source data and then re-call jpeg_read_header to resume - * processing. - * If a non-suspending data source is used and require_image is TRUE, then the - * return code need not be inspected since only JPEG_HEADER_OK is possible. - * - * This routine is now just a front end to jpeg_consume_input, with some - * extra error checking. - */ - -GLOBAL(int) -jpeg_read_header (j_decompress_ptr cinfo, boolean require_image) -{ - int retcode; - - if (cinfo->global_state != DSTATE_START && - cinfo->global_state != DSTATE_INHEADER) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - retcode = jpeg_consume_input(cinfo); - - switch (retcode) { - case JPEG_REACHED_SOS: - retcode = JPEG_HEADER_OK; - break; - case JPEG_REACHED_EOI: - if (require_image) /* Complain if application wanted an image */ - ERREXIT(cinfo, JERR_NO_IMAGE); - /* Reset to start state; it would be safer to require the application to - * call jpeg_abort, but we can't change it now for compatibility reasons. - * A side effect is to free any temporary memory (there shouldn't be any). - */ - jpeg_abort((j_common_ptr) cinfo); /* sets state = DSTATE_START */ - retcode = JPEG_HEADER_TABLES_ONLY; - break; - case JPEG_SUSPENDED: - /* no work */ - break; - } - - return retcode; -} - - -/* - * Consume data in advance of what the decompressor requires. - * This can be called at any time once the decompressor object has - * been created and a data source has been set up. - * - * This routine is essentially a state machine that handles a couple - * of critical state-transition actions, namely initial setup and - * transition from header scanning to ready-for-start_decompress. - * All the actual input is done via the input controller's consume_input - * method. - */ - -GLOBAL(int) -jpeg_consume_input (j_decompress_ptr cinfo) -{ - int retcode = JPEG_SUSPENDED; - - /* NB: every possible DSTATE value should be listed in this switch */ - switch (cinfo->global_state) { - case DSTATE_START: - /* Start-of-datastream actions: reset appropriate modules */ - (*cinfo->inputctl->reset_input_controller) (cinfo); - /* Initialize application's data source module */ - (*cinfo->src->init_source) (cinfo); - cinfo->global_state = DSTATE_INHEADER; - /*FALLTHROUGH*/ - case DSTATE_INHEADER: - retcode = (*cinfo->inputctl->consume_input) (cinfo); - if (retcode == JPEG_REACHED_SOS) { /* Found SOS, prepare to decompress */ - /* Set up default parameters based on header data */ - default_decompress_parms(cinfo); - /* Set global state: ready for start_decompress */ - cinfo->global_state = DSTATE_READY; - } - break; - case DSTATE_READY: - /* Can't advance past first SOS until start_decompress is called */ - retcode = JPEG_REACHED_SOS; - break; - case DSTATE_PRELOAD: - case DSTATE_PRESCAN: - case DSTATE_SCANNING: - case DSTATE_RAW_OK: - case DSTATE_BUFIMAGE: - case DSTATE_BUFPOST: - case DSTATE_STOPPING: - retcode = (*cinfo->inputctl->consume_input) (cinfo); - break; - default: - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - } - return retcode; -} - - -/* - * Have we finished reading the input file? - */ - -GLOBAL(boolean) -jpeg_input_complete (j_decompress_ptr cinfo) -{ - /* Check for valid jpeg object */ - if (cinfo->global_state < DSTATE_START || - cinfo->global_state > DSTATE_STOPPING) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - return cinfo->inputctl->eoi_reached; -} - - -/* - * Is there more than one scan? - */ - -GLOBAL(boolean) -jpeg_has_multiple_scans (j_decompress_ptr cinfo) -{ - /* Only valid after jpeg_read_header completes */ - if (cinfo->global_state < DSTATE_READY || - cinfo->global_state > DSTATE_STOPPING) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - return cinfo->inputctl->has_multiple_scans; -} - - -/* - * Finish JPEG decompression. - * - * This will normally just verify the file trailer and release temp storage. - * - * Returns FALSE if suspended. The return value need be inspected only if - * a suspending data source is used. - */ - -GLOBAL(boolean) -jpeg_finish_decompress (j_decompress_ptr cinfo) -{ - if ((cinfo->global_state == DSTATE_SCANNING || - cinfo->global_state == DSTATE_RAW_OK) && ! cinfo->buffered_image) { - /* Terminate final pass of non-buffered mode */ - if (cinfo->output_scanline < cinfo->output_height) - ERREXIT(cinfo, JERR_TOO_LITTLE_DATA); - (*cinfo->master->finish_output_pass) (cinfo); - cinfo->global_state = DSTATE_STOPPING; - } else if (cinfo->global_state == DSTATE_BUFIMAGE) { - /* Finishing after a buffered-image operation */ - cinfo->global_state = DSTATE_STOPPING; - } else if (cinfo->global_state != DSTATE_STOPPING) { - /* STOPPING = repeat call after a suspension, anything else is error */ - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - } - /* Read until EOI */ - while (! cinfo->inputctl->eoi_reached) { - if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED) - return FALSE; /* Suspend, come back later */ - } - /* Do final cleanup */ - (*cinfo->src->term_source) (cinfo); - /* We can use jpeg_abort to release memory and reset global_state */ - jpeg_abort((j_common_ptr) cinfo); - return TRUE; -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jdapistd.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jdapistd.c deleted file mode 100644 index f6c7fffe1..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jdapistd.c +++ /dev/null @@ -1,275 +0,0 @@ -/* - * jdapistd.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains application interface code for the decompression half - * of the JPEG library. These are the "standard" API routines that are - * used in the normal full-decompression case. They are not used by a - * transcoding-only application. Note that if an application links in - * jpeg_start_decompress, it will end up linking in the entire decompressor. - * We thus must separate this file from jdapimin.c to avoid linking the - * whole decompression library into a transcoder. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Forward declarations */ -LOCAL(boolean) output_pass_setup JPP((j_decompress_ptr cinfo)); - - -/* - * Decompression initialization. - * jpeg_read_header must be completed before calling this. - * - * If a multipass operating mode was selected, this will do all but the - * last pass, and thus may take a great deal of time. - * - * Returns FALSE if suspended. The return value need be inspected only if - * a suspending data source is used. - */ - -GLOBAL(boolean) -jpeg_start_decompress (j_decompress_ptr cinfo) -{ - if (cinfo->global_state == DSTATE_READY) { - /* First call: initialize master control, select active modules */ - jinit_master_decompress(cinfo); - if (cinfo->buffered_image) { - /* No more work here; expecting jpeg_start_output next */ - cinfo->global_state = DSTATE_BUFIMAGE; - return TRUE; - } - cinfo->global_state = DSTATE_PRELOAD; - } - if (cinfo->global_state == DSTATE_PRELOAD) { - /* If file has multiple scans, absorb them all into the coef buffer */ - if (cinfo->inputctl->has_multiple_scans) { -#ifdef D_MULTISCAN_FILES_SUPPORTED - for (;;) { - int retcode; - /* Call progress monitor hook if present */ - if (cinfo->progress != NULL) - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - /* Absorb some more input */ - retcode = (*cinfo->inputctl->consume_input) (cinfo); - if (retcode == JPEG_SUSPENDED) - return FALSE; - if (retcode == JPEG_REACHED_EOI) - break; - /* Advance progress counter if appropriate */ - if (cinfo->progress != NULL && - (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) { - if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) { - /* jdmaster underestimated number of scans; ratchet up one scan */ - cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows; - } - } - } -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif /* D_MULTISCAN_FILES_SUPPORTED */ - } - cinfo->output_scan_number = cinfo->input_scan_number; - } else if (cinfo->global_state != DSTATE_PRESCAN) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - /* Perform any dummy output passes, and set up for the final pass */ - return output_pass_setup(cinfo); -} - - -/* - * Set up for an output pass, and perform any dummy pass(es) needed. - * Common subroutine for jpeg_start_decompress and jpeg_start_output. - * Entry: global_state = DSTATE_PRESCAN only if previously suspended. - * Exit: If done, returns TRUE and sets global_state for proper output mode. - * If suspended, returns FALSE and sets global_state = DSTATE_PRESCAN. - */ - -LOCAL(boolean) -output_pass_setup (j_decompress_ptr cinfo) -{ - if (cinfo->global_state != DSTATE_PRESCAN) { - /* First call: do pass setup */ - (*cinfo->master->prepare_for_output_pass) (cinfo); - cinfo->output_scanline = 0; - cinfo->global_state = DSTATE_PRESCAN; - } - /* Loop over any required dummy passes */ - while (cinfo->master->is_dummy_pass) { -#ifdef QUANT_2PASS_SUPPORTED - /* Crank through the dummy pass */ - while (cinfo->output_scanline < cinfo->output_height) { - JDIMENSION last_scanline; - /* Call progress monitor hook if present */ - if (cinfo->progress != NULL) { - cinfo->progress->pass_counter = (long) cinfo->output_scanline; - cinfo->progress->pass_limit = (long) cinfo->output_height; - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - } - /* Process some data */ - last_scanline = cinfo->output_scanline; - (*cinfo->main->process_data) (cinfo, (JSAMPARRAY) NULL, - &cinfo->output_scanline, (JDIMENSION) 0); - if (cinfo->output_scanline == last_scanline) - return FALSE; /* No progress made, must suspend */ - } - /* Finish up dummy pass, and set up for another one */ - (*cinfo->master->finish_output_pass) (cinfo); - (*cinfo->master->prepare_for_output_pass) (cinfo); - cinfo->output_scanline = 0; -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif /* QUANT_2PASS_SUPPORTED */ - } - /* Ready for application to drive output pass through - * jpeg_read_scanlines or jpeg_read_raw_data. - */ - cinfo->global_state = cinfo->raw_data_out ? DSTATE_RAW_OK : DSTATE_SCANNING; - return TRUE; -} - - -/* - * Read some scanlines of data from the JPEG decompressor. - * - * The return value will be the number of lines actually read. - * This may be less than the number requested in several cases, - * including bottom of image, data source suspension, and operating - * modes that emit multiple scanlines at a time. - * - * Note: we warn about excess calls to jpeg_read_scanlines() since - * this likely signals an application programmer error. However, - * an oversize buffer (max_lines > scanlines remaining) is not an error. - */ - -GLOBAL(JDIMENSION) -jpeg_read_scanlines (j_decompress_ptr cinfo, JSAMPARRAY scanlines, - JDIMENSION max_lines) -{ - JDIMENSION row_ctr; - - if (cinfo->global_state != DSTATE_SCANNING) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - if (cinfo->output_scanline >= cinfo->output_height) { - WARNMS(cinfo, JWRN_TOO_MUCH_DATA); - return 0; - } - - /* Call progress monitor hook if present */ - if (cinfo->progress != NULL) { - cinfo->progress->pass_counter = (long) cinfo->output_scanline; - cinfo->progress->pass_limit = (long) cinfo->output_height; - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - } - - /* Process some data */ - row_ctr = 0; - (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, max_lines); - cinfo->output_scanline += row_ctr; - return row_ctr; -} - - -/* - * Alternate entry point to read raw data. - * Processes exactly one iMCU row per call, unless suspended. - */ - -GLOBAL(JDIMENSION) -jpeg_read_raw_data (j_decompress_ptr cinfo, JSAMPIMAGE data, - JDIMENSION max_lines) -{ - JDIMENSION lines_per_iMCU_row; - - if (cinfo->global_state != DSTATE_RAW_OK) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - if (cinfo->output_scanline >= cinfo->output_height) { - WARNMS(cinfo, JWRN_TOO_MUCH_DATA); - return 0; - } - - /* Call progress monitor hook if present */ - if (cinfo->progress != NULL) { - cinfo->progress->pass_counter = (long) cinfo->output_scanline; - cinfo->progress->pass_limit = (long) cinfo->output_height; - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - } - - /* Verify that at least one iMCU row can be returned. */ - lines_per_iMCU_row = cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size; - if (max_lines < lines_per_iMCU_row) - ERREXIT(cinfo, JERR_BUFFER_SIZE); - - /* Decompress directly into user's buffer. */ - if (! (*cinfo->coef->decompress_data) (cinfo, data)) - return 0; /* suspension forced, can do nothing more */ - - /* OK, we processed one iMCU row. */ - cinfo->output_scanline += lines_per_iMCU_row; - return lines_per_iMCU_row; -} - - -/* Additional entry points for buffered-image mode. */ - -#ifdef D_MULTISCAN_FILES_SUPPORTED - -/* - * Initialize for an output pass in buffered-image mode. - */ - -GLOBAL(boolean) -jpeg_start_output (j_decompress_ptr cinfo, int scan_number) -{ - if (cinfo->global_state != DSTATE_BUFIMAGE && - cinfo->global_state != DSTATE_PRESCAN) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - /* Limit scan number to valid range */ - if (scan_number <= 0) - scan_number = 1; - if (cinfo->inputctl->eoi_reached && - scan_number > cinfo->input_scan_number) - scan_number = cinfo->input_scan_number; - cinfo->output_scan_number = scan_number; - /* Perform any dummy output passes, and set up for the real pass */ - return output_pass_setup(cinfo); -} - - -/* - * Finish up after an output pass in buffered-image mode. - * - * Returns FALSE if suspended. The return value need be inspected only if - * a suspending data source is used. - */ - -GLOBAL(boolean) -jpeg_finish_output (j_decompress_ptr cinfo) -{ - if ((cinfo->global_state == DSTATE_SCANNING || - cinfo->global_state == DSTATE_RAW_OK) && cinfo->buffered_image) { - /* Terminate this pass. */ - /* We do not require the whole pass to have been completed. */ - (*cinfo->master->finish_output_pass) (cinfo); - cinfo->global_state = DSTATE_BUFPOST; - } else if (cinfo->global_state != DSTATE_BUFPOST) { - /* BUFPOST = repeat call after a suspension, anything else is error */ - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - } - /* Read markers looking for SOS or EOI */ - while (cinfo->input_scan_number <= cinfo->output_scan_number && - ! cinfo->inputctl->eoi_reached) { - if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED) - return FALSE; /* Suspend, come back later */ - } - cinfo->global_state = DSTATE_BUFIMAGE; - return TRUE; -} - -#endif /* D_MULTISCAN_FILES_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jdatadst.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jdatadst.c deleted file mode 100644 index 2ece4e95d..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jdatadst.c +++ /dev/null @@ -1,151 +0,0 @@ -/* - * jdatadst.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains compression data destination routines for the case of - * emitting JPEG data to a file (or any stdio stream). While these routines - * are sufficient for most applications, some will want to use a different - * destination manager. - * IMPORTANT: we assume that fwrite() will correctly transcribe an array of - * JOCTETs into 8-bit-wide elements on external storage. If char is wider - * than 8 bits on your machine, you may need to do some tweaking. - */ - -/* this is not a core library module, so it doesn't define JPEG_INTERNALS */ -#include "jinclude.h" -#include "jpeglib.h" -#include "jerror.h" - - -/* Expanded data destination object for stdio output */ - -typedef struct { - struct jpeg_destination_mgr pub; /* public fields */ - - FILE * outfile; /* target stream */ - JOCTET * buffer; /* start of buffer */ -} my_destination_mgr; - -typedef my_destination_mgr * my_dest_ptr; - -#define OUTPUT_BUF_SIZE 4096 /* choose an efficiently fwrite'able size */ - - -/* - * Initialize destination --- called by jpeg_start_compress - * before any data is actually written. - */ - -METHODDEF(void) -init_destination (j_compress_ptr cinfo) -{ - my_dest_ptr dest = (my_dest_ptr) cinfo->dest; - - /* Allocate the output buffer --- it will be released when done with image */ - dest->buffer = (JOCTET *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - OUTPUT_BUF_SIZE * SIZEOF(JOCTET)); - - dest->pub.next_output_byte = dest->buffer; - dest->pub.free_in_buffer = OUTPUT_BUF_SIZE; -} - - -/* - * Empty the output buffer --- called whenever buffer fills up. - * - * In typical applications, this should write the entire output buffer - * (ignoring the current state of next_output_byte & free_in_buffer), - * reset the pointer & count to the start of the buffer, and return TRUE - * indicating that the buffer has been dumped. - * - * In applications that need to be able to suspend compression due to output - * overrun, a FALSE return indicates that the buffer cannot be emptied now. - * In this situation, the compressor will return to its caller (possibly with - * an indication that it has not accepted all the supplied scanlines). The - * application should resume compression after it has made more room in the - * output buffer. Note that there are substantial restrictions on the use of - * suspension --- see the documentation. - * - * When suspending, the compressor will back up to a convenient restart point - * (typically the start of the current MCU). next_output_byte & free_in_buffer - * indicate where the restart point will be if the current call returns FALSE. - * Data beyond this point will be regenerated after resumption, so do not - * write it out when emptying the buffer externally. - */ - -METHODDEF(boolean) -empty_output_buffer (j_compress_ptr cinfo) -{ - my_dest_ptr dest = (my_dest_ptr) cinfo->dest; - - if (JFWRITE(dest->outfile, dest->buffer, OUTPUT_BUF_SIZE) != - (size_t) OUTPUT_BUF_SIZE) - ERREXIT(cinfo, JERR_FILE_WRITE); - - dest->pub.next_output_byte = dest->buffer; - dest->pub.free_in_buffer = OUTPUT_BUF_SIZE; - - return TRUE; -} - - -/* - * Terminate destination --- called by jpeg_finish_compress - * after all data has been written. Usually needs to flush buffer. - * - * NB: *not* called by jpeg_abort or jpeg_destroy; surrounding - * application must deal with any cleanup that should happen even - * for error exit. - */ - -METHODDEF(void) -term_destination (j_compress_ptr cinfo) -{ - my_dest_ptr dest = (my_dest_ptr) cinfo->dest; - size_t datacount = OUTPUT_BUF_SIZE - dest->pub.free_in_buffer; - - /* Write any data remaining in the buffer */ - if (datacount > 0) { - if (JFWRITE(dest->outfile, dest->buffer, datacount) != datacount) - ERREXIT(cinfo, JERR_FILE_WRITE); - } - fflush(dest->outfile); - /* Make sure we wrote the output file OK */ - if (ferror(dest->outfile)) - ERREXIT(cinfo, JERR_FILE_WRITE); -} - - -/* - * Prepare for output to a stdio stream. - * The caller must have already opened the stream, and is responsible - * for closing it after finishing compression. - */ - -GLOBAL(void) -jpeg_stdio_dest (j_compress_ptr cinfo, FILE * outfile) -{ - my_dest_ptr dest; - - /* The destination object is made permanent so that multiple JPEG images - * can be written to the same file without re-executing jpeg_stdio_dest. - * This makes it dangerous to use this manager and a different destination - * manager serially with the same JPEG object, because their private object - * sizes may be different. Caveat programmer. - */ - if (cinfo->dest == NULL) { /* first time for this JPEG object? */ - cinfo->dest = (struct jpeg_destination_mgr *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - SIZEOF(my_destination_mgr)); - } - - dest = (my_dest_ptr) cinfo->dest; - dest->pub.init_destination = init_destination; - dest->pub.empty_output_buffer = empty_output_buffer; - dest->pub.term_destination = term_destination; - dest->outfile = outfile; -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jdatasrc.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jdatasrc.c deleted file mode 100644 index 29b698328..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jdatasrc.c +++ /dev/null @@ -1,212 +0,0 @@ -/* - * jdatasrc.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains decompression data source routines for the case of - * reading JPEG data from a file (or any stdio stream). While these routines - * are sufficient for most applications, some will want to use a different - * source manager. - * IMPORTANT: we assume that fread() will correctly transcribe an array of - * JOCTETs from 8-bit-wide elements on external storage. If char is wider - * than 8 bits on your machine, you may need to do some tweaking. - */ - -/* this is not a core library module, so it doesn't define JPEG_INTERNALS */ -#include "jinclude.h" -#include "jpeglib.h" -#include "jerror.h" - - -/* Expanded data source object for stdio input */ - -typedef struct { - struct jpeg_source_mgr pub; /* public fields */ - - FILE * infile; /* source stream */ - JOCTET * buffer; /* start of buffer */ - boolean start_of_file; /* have we gotten any data yet? */ -} my_source_mgr; - -typedef my_source_mgr * my_src_ptr; - -#define INPUT_BUF_SIZE 4096 /* choose an efficiently fread'able size */ - - -/* - * Initialize source --- called by jpeg_read_header - * before any data is actually read. - */ - -METHODDEF(void) -init_source (j_decompress_ptr cinfo) -{ - my_src_ptr src = (my_src_ptr) cinfo->src; - - /* We reset the empty-input-file flag for each image, - * but we don't clear the input buffer. - * This is correct behavior for reading a series of images from one source. - */ - src->start_of_file = TRUE; -} - - -/* - * Fill the input buffer --- called whenever buffer is emptied. - * - * In typical applications, this should read fresh data into the buffer - * (ignoring the current state of next_input_byte & bytes_in_buffer), - * reset the pointer & count to the start of the buffer, and return TRUE - * indicating that the buffer has been reloaded. It is not necessary to - * fill the buffer entirely, only to obtain at least one more byte. - * - * There is no such thing as an EOF return. If the end of the file has been - * reached, the routine has a choice of ERREXIT() or inserting fake data into - * the buffer. In most cases, generating a warning message and inserting a - * fake EOI marker is the best course of action --- this will allow the - * decompressor to output however much of the image is there. However, - * the resulting error message is misleading if the real problem is an empty - * input file, so we handle that case specially. - * - * In applications that need to be able to suspend compression due to input - * not being available yet, a FALSE return indicates that no more data can be - * obtained right now, but more may be forthcoming later. In this situation, - * the decompressor will return to its caller (with an indication of the - * number of scanlines it has read, if any). The application should resume - * decompression after it has loaded more data into the input buffer. Note - * that there are substantial restrictions on the use of suspension --- see - * the documentation. - * - * When suspending, the decompressor will back up to a convenient restart point - * (typically the start of the current MCU). next_input_byte & bytes_in_buffer - * indicate where the restart point will be if the current call returns FALSE. - * Data beyond this point must be rescanned after resumption, so move it to - * the front of the buffer rather than discarding it. - */ - -METHODDEF(boolean) -fill_input_buffer (j_decompress_ptr cinfo) -{ - my_src_ptr src = (my_src_ptr) cinfo->src; - size_t nbytes; - - nbytes = JFREAD(src->infile, src->buffer, INPUT_BUF_SIZE); - - if (nbytes <= 0) { - if (src->start_of_file) /* Treat empty input file as fatal error */ - ERREXIT(cinfo, JERR_INPUT_EMPTY); - WARNMS(cinfo, JWRN_JPEG_EOF); - /* Insert a fake EOI marker */ - src->buffer[0] = (JOCTET) 0xFF; - src->buffer[1] = (JOCTET) JPEG_EOI; - nbytes = 2; - } - - src->pub.next_input_byte = src->buffer; - src->pub.bytes_in_buffer = nbytes; - src->start_of_file = FALSE; - - return TRUE; -} - - -/* - * Skip data --- used to skip over a potentially large amount of - * uninteresting data (such as an APPn marker). - * - * Writers of suspendable-input applications must note that skip_input_data - * is not granted the right to give a suspension return. If the skip extends - * beyond the data currently in the buffer, the buffer can be marked empty so - * that the next read will cause a fill_input_buffer call that can suspend. - * Arranging for additional bytes to be discarded before reloading the input - * buffer is the application writer's problem. - */ - -METHODDEF(void) -skip_input_data (j_decompress_ptr cinfo, long num_bytes) -{ - my_src_ptr src = (my_src_ptr) cinfo->src; - - /* Just a dumb implementation for now. Could use fseek() except - * it doesn't work on pipes. Not clear that being smart is worth - * any trouble anyway --- large skips are infrequent. - */ - if (num_bytes > 0) { - while (num_bytes > (long) src->pub.bytes_in_buffer) { - num_bytes -= (long) src->pub.bytes_in_buffer; - (void) fill_input_buffer(cinfo); - /* note we assume that fill_input_buffer will never return FALSE, - * so suspension need not be handled. - */ - } - src->pub.next_input_byte += (size_t) num_bytes; - src->pub.bytes_in_buffer -= (size_t) num_bytes; - } -} - - -/* - * An additional method that can be provided by data source modules is the - * resync_to_restart method for error recovery in the presence of RST markers. - * For the moment, this source module just uses the default resync method - * provided by the JPEG library. That method assumes that no backtracking - * is possible. - */ - - -/* - * Terminate source --- called by jpeg_finish_decompress - * after all data has been read. Often a no-op. - * - * NB: *not* called by jpeg_abort or jpeg_destroy; surrounding - * application must deal with any cleanup that should happen even - * for error exit. - */ - -METHODDEF(void) -term_source (j_decompress_ptr cinfo) -{ - /* no work necessary here */ -} - - -/* - * Prepare for input from a stdio stream. - * The caller must have already opened the stream, and is responsible - * for closing it after finishing decompression. - */ - -GLOBAL(void) -jpeg_stdio_src (j_decompress_ptr cinfo, FILE * infile) -{ - my_src_ptr src; - - /* The source object and input buffer are made permanent so that a series - * of JPEG images can be read from the same file by calling jpeg_stdio_src - * only before the first one. (If we discarded the buffer at the end of - * one image, we'd likely lose the start of the next one.) - * This makes it unsafe to use this manager and a different source - * manager serially with the same JPEG object. Caveat programmer. - */ - if (cinfo->src == NULL) { /* first time for this JPEG object? */ - cinfo->src = (struct jpeg_source_mgr *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - SIZEOF(my_source_mgr)); - src = (my_src_ptr) cinfo->src; - src->buffer = (JOCTET *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - INPUT_BUF_SIZE * SIZEOF(JOCTET)); - } - - src = (my_src_ptr) cinfo->src; - src->pub.init_source = init_source; - src->pub.fill_input_buffer = fill_input_buffer; - src->pub.skip_input_data = skip_input_data; - src->pub.resync_to_restart = jpeg_resync_to_restart; /* use default method */ - src->pub.term_source = term_source; - src->infile = infile; - src->pub.bytes_in_buffer = 0; /* forces fill_input_buffer on first read */ - src->pub.next_input_byte = NULL; /* until buffer loaded */ -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jdcoefct.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jdcoefct.c deleted file mode 100644 index 992bd105b..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jdcoefct.c +++ /dev/null @@ -1,736 +0,0 @@ -/* - * jdcoefct.c - * - * Copyright (C) 1994-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the coefficient buffer controller for decompression. - * This controller is the top level of the JPEG decompressor proper. - * The coefficient buffer lies between entropy decoding and inverse-DCT steps. - * - * In buffered-image mode, this controller is the interface between - * input-oriented processing and output-oriented processing. - * Also, the input side (only) is used when reading a file for transcoding. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - -/* Block smoothing is only applicable for progressive JPEG, so: */ -#ifndef D_PROGRESSIVE_SUPPORTED -#undef BLOCK_SMOOTHING_SUPPORTED -#endif - -/* Private buffer controller object */ - -typedef struct { - struct jpeg_d_coef_controller pub; /* public fields */ - - /* These variables keep track of the current location of the input side. */ - /* cinfo->input_iMCU_row is also used for this. */ - JDIMENSION MCU_ctr; /* counts MCUs processed in current row */ - int MCU_vert_offset; /* counts MCU rows within iMCU row */ - int MCU_rows_per_iMCU_row; /* number of such rows needed */ - - /* The output side's location is represented by cinfo->output_iMCU_row. */ - - /* In single-pass modes, it's sufficient to buffer just one MCU. - * We allocate a workspace of D_MAX_BLOCKS_IN_MCU coefficient blocks, - * and let the entropy decoder write into that workspace each time. - * (On 80x86, the workspace is FAR even though it's not really very big; - * this is to keep the module interfaces unchanged when a large coefficient - * buffer is necessary.) - * In multi-pass modes, this array points to the current MCU's blocks - * within the virtual arrays; it is used only by the input side. - */ - JBLOCKROW MCU_buffer[D_MAX_BLOCKS_IN_MCU]; - -#ifdef D_MULTISCAN_FILES_SUPPORTED - /* In multi-pass modes, we need a virtual block array for each component. */ - jvirt_barray_ptr whole_image[MAX_COMPONENTS]; -#endif - -#ifdef BLOCK_SMOOTHING_SUPPORTED - /* When doing block smoothing, we latch coefficient Al values here */ - int * coef_bits_latch; -#define SAVED_COEFS 6 /* we save coef_bits[0..5] */ -#endif -} my_coef_controller; - -typedef my_coef_controller * my_coef_ptr; - -/* Forward declarations */ -METHODDEF(int) decompress_onepass - JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf)); -#ifdef D_MULTISCAN_FILES_SUPPORTED -METHODDEF(int) decompress_data - JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf)); -#endif -#ifdef BLOCK_SMOOTHING_SUPPORTED -LOCAL(boolean) smoothing_ok JPP((j_decompress_ptr cinfo)); -METHODDEF(int) decompress_smooth_data - JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf)); -#endif - - -LOCAL(void) -start_iMCU_row (j_decompress_ptr cinfo) -/* Reset within-iMCU-row counters for a new row (input side) */ -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - - /* In an interleaved scan, an MCU row is the same as an iMCU row. - * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows. - * But at the bottom of the image, process only what's left. - */ - if (cinfo->comps_in_scan > 1) { - coef->MCU_rows_per_iMCU_row = 1; - } else { - if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1)) - coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; - else - coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; - } - - coef->MCU_ctr = 0; - coef->MCU_vert_offset = 0; -} - - -/* - * Initialize for an input processing pass. - */ - -METHODDEF(void) -start_input_pass (j_decompress_ptr cinfo) -{ - cinfo->input_iMCU_row = 0; - start_iMCU_row(cinfo); -} - - -/* - * Initialize for an output processing pass. - */ - -METHODDEF(void) -start_output_pass (j_decompress_ptr cinfo) -{ -#ifdef BLOCK_SMOOTHING_SUPPORTED - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - - /* If multipass, check to see whether to use block smoothing on this pass */ - if (coef->pub.coef_arrays != NULL) { - if (cinfo->do_block_smoothing && smoothing_ok(cinfo)) - coef->pub.decompress_data = decompress_smooth_data; - else - coef->pub.decompress_data = decompress_data; - } -#endif - cinfo->output_iMCU_row = 0; -} - - -/* - * Decompress and return some data in the single-pass case. - * Always attempts to emit one fully interleaved MCU row ("iMCU" row). - * Input and output must run in lockstep since we have only a one-MCU buffer. - * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED. - * - * NB: output_buf contains a plane for each component in image, - * which we index according to the component's SOF position. - */ - -METHODDEF(int) -decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION MCU_col_num; /* index of current MCU within row */ - JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1; - JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; - int blkn, ci, xindex, yindex, yoffset, useful_width; - JSAMPARRAY output_ptr; - JDIMENSION start_col, output_col; - jpeg_component_info *compptr; - inverse_DCT_method_ptr inverse_DCT; - - /* Loop to process as much as one whole iMCU row */ - for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; - yoffset++) { - for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col; - MCU_col_num++) { - /* Try to fetch an MCU. Entropy decoder expects buffer to be zeroed. */ - jzero_far((void FAR *) coef->MCU_buffer[0], - (size_t) (cinfo->blocks_in_MCU * SIZEOF(JBLOCK))); - if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) { - /* Suspension forced; update state counters and exit */ - coef->MCU_vert_offset = yoffset; - coef->MCU_ctr = MCU_col_num; - return JPEG_SUSPENDED; - } - /* Determine where data should go in output_buf and do the IDCT thing. - * We skip dummy blocks at the right and bottom edges (but blkn gets - * incremented past them!). Note the inner loop relies on having - * allocated the MCU_buffer[] blocks sequentially. - */ - blkn = 0; /* index of current DCT block within MCU */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - /* Don't bother to IDCT an uninteresting component. */ - if (! compptr->component_needed) { - blkn += compptr->MCU_blocks; - continue; - } - inverse_DCT = cinfo->idct->inverse_DCT[compptr->component_index]; - useful_width = (MCU_col_num < last_MCU_col) ? compptr->MCU_width - : compptr->last_col_width; - output_ptr = output_buf[compptr->component_index] + - yoffset * compptr->DCT_scaled_size; - start_col = MCU_col_num * compptr->MCU_sample_width; - for (yindex = 0; yindex < compptr->MCU_height; yindex++) { - if (cinfo->input_iMCU_row < last_iMCU_row || - yoffset+yindex < compptr->last_row_height) { - output_col = start_col; - for (xindex = 0; xindex < useful_width; xindex++) { - (*inverse_DCT) (cinfo, compptr, - (JCOEFPTR) coef->MCU_buffer[blkn+xindex], - output_ptr, output_col); - output_col += compptr->DCT_scaled_size; - } - } - blkn += compptr->MCU_width; - output_ptr += compptr->DCT_scaled_size; - } - } - } - /* Completed an MCU row, but perhaps not an iMCU row */ - coef->MCU_ctr = 0; - } - /* Completed the iMCU row, advance counters for next one */ - cinfo->output_iMCU_row++; - if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { - start_iMCU_row(cinfo); - return JPEG_ROW_COMPLETED; - } - /* Completed the scan */ - (*cinfo->inputctl->finish_input_pass) (cinfo); - return JPEG_SCAN_COMPLETED; -} - - -/* - * Dummy consume-input routine for single-pass operation. - */ - -METHODDEF(int) -dummy_consume_data (j_decompress_ptr cinfo) -{ - return JPEG_SUSPENDED; /* Always indicate nothing was done */ -} - - -#ifdef D_MULTISCAN_FILES_SUPPORTED - -/* - * Consume input data and store it in the full-image coefficient buffer. - * We read as much as one fully interleaved MCU row ("iMCU" row) per call, - * ie, v_samp_factor block rows for each component in the scan. - * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED. - */ - -METHODDEF(int) -consume_data (j_decompress_ptr cinfo) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION MCU_col_num; /* index of current MCU within row */ - int blkn, ci, xindex, yindex, yoffset; - JDIMENSION start_col; - JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN]; - JBLOCKROW buffer_ptr; - jpeg_component_info *compptr; - - /* Align the virtual buffers for the components used in this scan. */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - buffer[ci] = (*cinfo->mem->access_virt_barray) - ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index], - cinfo->input_iMCU_row * compptr->v_samp_factor, - (JDIMENSION) compptr->v_samp_factor, TRUE); - /* Note: entropy decoder expects buffer to be zeroed, - * but this is handled automatically by the memory manager - * because we requested a pre-zeroed array. - */ - } - - /* Loop to process one whole iMCU row */ - for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; - yoffset++) { - for (MCU_col_num = coef->MCU_ctr; MCU_col_num < cinfo->MCUs_per_row; - MCU_col_num++) { - /* Construct list of pointers to DCT blocks belonging to this MCU */ - blkn = 0; /* index of current DCT block within MCU */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - start_col = MCU_col_num * compptr->MCU_width; - for (yindex = 0; yindex < compptr->MCU_height; yindex++) { - buffer_ptr = buffer[ci][yindex+yoffset] + start_col; - for (xindex = 0; xindex < compptr->MCU_width; xindex++) { - coef->MCU_buffer[blkn++] = buffer_ptr++; - } - } - } - /* Try to fetch the MCU. */ - if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) { - /* Suspension forced; update state counters and exit */ - coef->MCU_vert_offset = yoffset; - coef->MCU_ctr = MCU_col_num; - return JPEG_SUSPENDED; - } - } - /* Completed an MCU row, but perhaps not an iMCU row */ - coef->MCU_ctr = 0; - } - /* Completed the iMCU row, advance counters for next one */ - if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { - start_iMCU_row(cinfo); - return JPEG_ROW_COMPLETED; - } - /* Completed the scan */ - (*cinfo->inputctl->finish_input_pass) (cinfo); - return JPEG_SCAN_COMPLETED; -} - - -/* - * Decompress and return some data in the multi-pass case. - * Always attempts to emit one fully interleaved MCU row ("iMCU" row). - * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED. - * - * NB: output_buf contains a plane for each component in image. - */ - -METHODDEF(int) -decompress_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; - JDIMENSION block_num; - int ci, block_row, block_rows; - JBLOCKARRAY buffer; - JBLOCKROW buffer_ptr; - JSAMPARRAY output_ptr; - JDIMENSION output_col; - jpeg_component_info *compptr; - inverse_DCT_method_ptr inverse_DCT; - - /* Force some input to be done if we are getting ahead of the input. */ - while (cinfo->input_scan_number < cinfo->output_scan_number || - (cinfo->input_scan_number == cinfo->output_scan_number && - cinfo->input_iMCU_row <= cinfo->output_iMCU_row)) { - if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED) - return JPEG_SUSPENDED; - } - - /* OK, output from the virtual arrays. */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Don't bother to IDCT an uninteresting component. */ - if (! compptr->component_needed) - continue; - /* Align the virtual buffer for this component. */ - buffer = (*cinfo->mem->access_virt_barray) - ((j_common_ptr) cinfo, coef->whole_image[ci], - cinfo->output_iMCU_row * compptr->v_samp_factor, - (JDIMENSION) compptr->v_samp_factor, FALSE); - /* Count non-dummy DCT block rows in this iMCU row. */ - if (cinfo->output_iMCU_row < last_iMCU_row) - block_rows = compptr->v_samp_factor; - else { - /* NB: can't use last_row_height here; it is input-side-dependent! */ - block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor); - if (block_rows == 0) block_rows = compptr->v_samp_factor; - } - inverse_DCT = cinfo->idct->inverse_DCT[ci]; - output_ptr = output_buf[ci]; - /* Loop over all DCT blocks to be processed. */ - for (block_row = 0; block_row < block_rows; block_row++) { - buffer_ptr = buffer[block_row]; - output_col = 0; - for (block_num = 0; block_num < compptr->width_in_blocks; block_num++) { - (*inverse_DCT) (cinfo, compptr, (JCOEFPTR) buffer_ptr, - output_ptr, output_col); - buffer_ptr++; - output_col += compptr->DCT_scaled_size; - } - output_ptr += compptr->DCT_scaled_size; - } - } - - if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows) - return JPEG_ROW_COMPLETED; - return JPEG_SCAN_COMPLETED; -} - -#endif /* D_MULTISCAN_FILES_SUPPORTED */ - - -#ifdef BLOCK_SMOOTHING_SUPPORTED - -/* - * This code applies interblock smoothing as described by section K.8 - * of the JPEG standard: the first 5 AC coefficients are estimated from - * the DC values of a DCT block and its 8 neighboring blocks. - * We apply smoothing only for progressive JPEG decoding, and only if - * the coefficients it can estimate are not yet known to full precision. - */ - -/* Natural-order array positions of the first 5 zigzag-order coefficients */ -#define Q01_POS 1 -#define Q10_POS 8 -#define Q20_POS 16 -#define Q11_POS 9 -#define Q02_POS 2 - -/* - * Determine whether block smoothing is applicable and safe. - * We also latch the current states of the coef_bits[] entries for the - * AC coefficients; otherwise, if the input side of the decompressor - * advances into a new scan, we might think the coefficients are known - * more accurately than they really are. - */ - -LOCAL(boolean) -smoothing_ok (j_decompress_ptr cinfo) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - boolean smoothing_useful = FALSE; - int ci, coefi; - jpeg_component_info *compptr; - JQUANT_TBL * qtable; - int * coef_bits; - int * coef_bits_latch; - - if (! cinfo->progressive_mode || cinfo->coef_bits == NULL) - return FALSE; - - /* Allocate latch area if not already done */ - if (coef->coef_bits_latch == NULL) - coef->coef_bits_latch = (int *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - cinfo->num_components * - (SAVED_COEFS * SIZEOF(int))); - coef_bits_latch = coef->coef_bits_latch; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* All components' quantization values must already be latched. */ - if ((qtable = compptr->quant_table) == NULL) - return FALSE; - /* Verify DC & first 5 AC quantizers are nonzero to avoid zero-divide. */ - if (qtable->quantval[0] == 0 || - qtable->quantval[Q01_POS] == 0 || - qtable->quantval[Q10_POS] == 0 || - qtable->quantval[Q20_POS] == 0 || - qtable->quantval[Q11_POS] == 0 || - qtable->quantval[Q02_POS] == 0) - return FALSE; - /* DC values must be at least partly known for all components. */ - coef_bits = cinfo->coef_bits[ci]; - if (coef_bits[0] < 0) - return FALSE; - /* Block smoothing is helpful if some AC coefficients remain inaccurate. */ - for (coefi = 1; coefi <= 5; coefi++) { - coef_bits_latch[coefi] = coef_bits[coefi]; - if (coef_bits[coefi] != 0) - smoothing_useful = TRUE; - } - coef_bits_latch += SAVED_COEFS; - } - - return smoothing_useful; -} - - -/* - * Variant of decompress_data for use when doing block smoothing. - */ - -METHODDEF(int) -decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; - JDIMENSION block_num, last_block_column; - int ci, block_row, block_rows, access_rows; - JBLOCKARRAY buffer; - JBLOCKROW buffer_ptr, prev_block_row, next_block_row; - JSAMPARRAY output_ptr; - JDIMENSION output_col; - jpeg_component_info *compptr; - inverse_DCT_method_ptr inverse_DCT; - boolean first_row, last_row; - JBLOCK workspace; - int *coef_bits; - JQUANT_TBL *quanttbl; - INT32 Q00,Q01,Q02,Q10,Q11,Q20, num; - int DC1,DC2,DC3,DC4,DC5,DC6,DC7,DC8,DC9; - int Al, pred; - - /* Force some input to be done if we are getting ahead of the input. */ - while (cinfo->input_scan_number <= cinfo->output_scan_number && - ! cinfo->inputctl->eoi_reached) { - if (cinfo->input_scan_number == cinfo->output_scan_number) { - /* If input is working on current scan, we ordinarily want it to - * have completed the current row. But if input scan is DC, - * we want it to keep one row ahead so that next block row's DC - * values are up to date. - */ - JDIMENSION delta = (cinfo->Ss == 0) ? 1 : 0; - if (cinfo->input_iMCU_row > cinfo->output_iMCU_row+delta) - break; - } - if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED) - return JPEG_SUSPENDED; - } - - /* OK, output from the virtual arrays. */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Don't bother to IDCT an uninteresting component. */ - if (! compptr->component_needed) - continue; - /* Count non-dummy DCT block rows in this iMCU row. */ - if (cinfo->output_iMCU_row < last_iMCU_row) { - block_rows = compptr->v_samp_factor; - access_rows = block_rows * 2; /* this and next iMCU row */ - last_row = FALSE; - } else { - /* NB: can't use last_row_height here; it is input-side-dependent! */ - block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor); - if (block_rows == 0) block_rows = compptr->v_samp_factor; - access_rows = block_rows; /* this iMCU row only */ - last_row = TRUE; - } - /* Align the virtual buffer for this component. */ - if (cinfo->output_iMCU_row > 0) { - access_rows += compptr->v_samp_factor; /* prior iMCU row too */ - buffer = (*cinfo->mem->access_virt_barray) - ((j_common_ptr) cinfo, coef->whole_image[ci], - (cinfo->output_iMCU_row - 1) * compptr->v_samp_factor, - (JDIMENSION) access_rows, FALSE); - buffer += compptr->v_samp_factor; /* point to current iMCU row */ - first_row = FALSE; - } else { - buffer = (*cinfo->mem->access_virt_barray) - ((j_common_ptr) cinfo, coef->whole_image[ci], - (JDIMENSION) 0, (JDIMENSION) access_rows, FALSE); - first_row = TRUE; - } - /* Fetch component-dependent info */ - coef_bits = coef->coef_bits_latch + (ci * SAVED_COEFS); - quanttbl = compptr->quant_table; - Q00 = quanttbl->quantval[0]; - Q01 = quanttbl->quantval[Q01_POS]; - Q10 = quanttbl->quantval[Q10_POS]; - Q20 = quanttbl->quantval[Q20_POS]; - Q11 = quanttbl->quantval[Q11_POS]; - Q02 = quanttbl->quantval[Q02_POS]; - inverse_DCT = cinfo->idct->inverse_DCT[ci]; - output_ptr = output_buf[ci]; - /* Loop over all DCT blocks to be processed. */ - for (block_row = 0; block_row < block_rows; block_row++) { - buffer_ptr = buffer[block_row]; - if (first_row && block_row == 0) - prev_block_row = buffer_ptr; - else - prev_block_row = buffer[block_row-1]; - if (last_row && block_row == block_rows-1) - next_block_row = buffer_ptr; - else - next_block_row = buffer[block_row+1]; - /* We fetch the surrounding DC values using a sliding-register approach. - * Initialize all nine here so as to do the right thing on narrow pics. - */ - DC1 = DC2 = DC3 = (int) prev_block_row[0][0]; - DC4 = DC5 = DC6 = (int) buffer_ptr[0][0]; - DC7 = DC8 = DC9 = (int) next_block_row[0][0]; - output_col = 0; - last_block_column = compptr->width_in_blocks - 1; - for (block_num = 0; block_num <= last_block_column; block_num++) { - /* Fetch current DCT block into workspace so we can modify it. */ - jcopy_block_row(buffer_ptr, (JBLOCKROW) workspace, (JDIMENSION) 1); - /* Update DC values */ - if (block_num < last_block_column) { - DC3 = (int) prev_block_row[1][0]; - DC6 = (int) buffer_ptr[1][0]; - DC9 = (int) next_block_row[1][0]; - } - /* Compute coefficient estimates per K.8. - * An estimate is applied only if coefficient is still zero, - * and is not known to be fully accurate. - */ - /* AC01 */ - if ((Al=coef_bits[1]) != 0 && workspace[1] == 0) { - num = 36 * Q00 * (DC4 - DC6); - if (num >= 0) { - pred = (int) (((Q01<<7) + num) / (Q01<<8)); - if (Al > 0 && pred >= (1<<Al)) - pred = (1<<Al)-1; - } else { - pred = (int) (((Q01<<7) - num) / (Q01<<8)); - if (Al > 0 && pred >= (1<<Al)) - pred = (1<<Al)-1; - pred = -pred; - } - workspace[1] = (JCOEF) pred; - } - /* AC10 */ - if ((Al=coef_bits[2]) != 0 && workspace[8] == 0) { - num = 36 * Q00 * (DC2 - DC8); - if (num >= 0) { - pred = (int) (((Q10<<7) + num) / (Q10<<8)); - if (Al > 0 && pred >= (1<<Al)) - pred = (1<<Al)-1; - } else { - pred = (int) (((Q10<<7) - num) / (Q10<<8)); - if (Al > 0 && pred >= (1<<Al)) - pred = (1<<Al)-1; - pred = -pred; - } - workspace[8] = (JCOEF) pred; - } - /* AC20 */ - if ((Al=coef_bits[3]) != 0 && workspace[16] == 0) { - num = 9 * Q00 * (DC2 + DC8 - 2*DC5); - if (num >= 0) { - pred = (int) (((Q20<<7) + num) / (Q20<<8)); - if (Al > 0 && pred >= (1<<Al)) - pred = (1<<Al)-1; - } else { - pred = (int) (((Q20<<7) - num) / (Q20<<8)); - if (Al > 0 && pred >= (1<<Al)) - pred = (1<<Al)-1; - pred = -pred; - } - workspace[16] = (JCOEF) pred; - } - /* AC11 */ - if ((Al=coef_bits[4]) != 0 && workspace[9] == 0) { - num = 5 * Q00 * (DC1 - DC3 - DC7 + DC9); - if (num >= 0) { - pred = (int) (((Q11<<7) + num) / (Q11<<8)); - if (Al > 0 && pred >= (1<<Al)) - pred = (1<<Al)-1; - } else { - pred = (int) (((Q11<<7) - num) / (Q11<<8)); - if (Al > 0 && pred >= (1<<Al)) - pred = (1<<Al)-1; - pred = -pred; - } - workspace[9] = (JCOEF) pred; - } - /* AC02 */ - if ((Al=coef_bits[5]) != 0 && workspace[2] == 0) { - num = 9 * Q00 * (DC4 + DC6 - 2*DC5); - if (num >= 0) { - pred = (int) (((Q02<<7) + num) / (Q02<<8)); - if (Al > 0 && pred >= (1<<Al)) - pred = (1<<Al)-1; - } else { - pred = (int) (((Q02<<7) - num) / (Q02<<8)); - if (Al > 0 && pred >= (1<<Al)) - pred = (1<<Al)-1; - pred = -pred; - } - workspace[2] = (JCOEF) pred; - } - /* OK, do the IDCT */ - (*inverse_DCT) (cinfo, compptr, (JCOEFPTR) workspace, - output_ptr, output_col); - /* Advance for next column */ - DC1 = DC2; DC2 = DC3; - DC4 = DC5; DC5 = DC6; - DC7 = DC8; DC8 = DC9; - buffer_ptr++, prev_block_row++, next_block_row++; - output_col += compptr->DCT_scaled_size; - } - output_ptr += compptr->DCT_scaled_size; - } - } - - if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows) - return JPEG_ROW_COMPLETED; - return JPEG_SCAN_COMPLETED; -} - -#endif /* BLOCK_SMOOTHING_SUPPORTED */ - - -/* - * Initialize coefficient buffer controller. - */ - -GLOBAL(void) -jinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer) -{ - my_coef_ptr coef; - - coef = (my_coef_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_coef_controller)); - cinfo->coef = (struct jpeg_d_coef_controller *) coef; - coef->pub.start_input_pass = start_input_pass; - coef->pub.start_output_pass = start_output_pass; -#ifdef BLOCK_SMOOTHING_SUPPORTED - coef->coef_bits_latch = NULL; -#endif - - /* Create the coefficient buffer. */ - if (need_full_buffer) { -#ifdef D_MULTISCAN_FILES_SUPPORTED - /* Allocate a full-image virtual array for each component, */ - /* padded to a multiple of samp_factor DCT blocks in each direction. */ - /* Note we ask for a pre-zeroed array. */ - int ci, access_rows; - jpeg_component_info *compptr; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - access_rows = compptr->v_samp_factor; -#ifdef BLOCK_SMOOTHING_SUPPORTED - /* If block smoothing could be used, need a bigger window */ - if (cinfo->progressive_mode) - access_rows *= 3; -#endif - coef->whole_image[ci] = (*cinfo->mem->request_virt_barray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, TRUE, - (JDIMENSION) jround_up((long) compptr->width_in_blocks, - (long) compptr->h_samp_factor), - (JDIMENSION) jround_up((long) compptr->height_in_blocks, - (long) compptr->v_samp_factor), - (JDIMENSION) access_rows); - } - coef->pub.consume_data = consume_data; - coef->pub.decompress_data = decompress_data; - coef->pub.coef_arrays = coef->whole_image; /* link to virtual arrays */ -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else { - /* We only need a single-MCU buffer. */ - JBLOCKROW buffer; - int i; - - buffer = (JBLOCKROW) - (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, - D_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); - for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) { - coef->MCU_buffer[i] = buffer + i; - } - coef->pub.consume_data = dummy_consume_data; - coef->pub.decompress_data = decompress_onepass; - coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */ - } -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jdcolor.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jdcolor.c deleted file mode 100644 index fd7b13887..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jdcolor.c +++ /dev/null @@ -1,396 +0,0 @@ -/* - * jdcolor.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains output colorspace conversion routines. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Private subobject */ - -typedef struct { - struct jpeg_color_deconverter pub; /* public fields */ - - /* Private state for YCC->RGB conversion */ - int * Cr_r_tab; /* => table for Cr to R conversion */ - int * Cb_b_tab; /* => table for Cb to B conversion */ - INT32 * Cr_g_tab; /* => table for Cr to G conversion */ - INT32 * Cb_g_tab; /* => table for Cb to G conversion */ -} my_color_deconverter; - -typedef my_color_deconverter * my_cconvert_ptr; - - -/**************** YCbCr -> RGB conversion: most common case **************/ - -/* - * YCbCr is defined per CCIR 601-1, except that Cb and Cr are - * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5. - * The conversion equations to be implemented are therefore - * R = Y + 1.40200 * Cr - * G = Y - 0.34414 * Cb - 0.71414 * Cr - * B = Y + 1.77200 * Cb - * where Cb and Cr represent the incoming values less CENTERJSAMPLE. - * (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.) - * - * To avoid floating-point arithmetic, we represent the fractional constants - * as integers scaled up by 2^16 (about 4 digits precision); we have to divide - * the products by 2^16, with appropriate rounding, to get the correct answer. - * Notice that Y, being an integral input, does not contribute any fraction - * so it need not participate in the rounding. - * - * For even more speed, we avoid doing any multiplications in the inner loop - * by precalculating the constants times Cb and Cr for all possible values. - * For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table); - * for 12-bit samples it is still acceptable. It's not very reasonable for - * 16-bit samples, but if you want lossless storage you shouldn't be changing - * colorspace anyway. - * The Cr=>R and Cb=>B values can be rounded to integers in advance; the - * values for the G calculation are left scaled up, since we must add them - * together before rounding. - */ - -#define SCALEBITS 16 /* speediest right-shift on some machines */ -#define ONE_HALF ((INT32) 1 << (SCALEBITS-1)) -#define FIX(x) ((INT32) ((x) * (1L<<SCALEBITS) + 0.5)) - - -/* - * Initialize tables for YCC->RGB colorspace conversion. - */ - -LOCAL(void) -build_ycc_rgb_table (j_decompress_ptr cinfo) -{ - my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; - int i; - INT32 x; - SHIFT_TEMPS - - cconvert->Cr_r_tab = (int *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(int)); - cconvert->Cb_b_tab = (int *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(int)); - cconvert->Cr_g_tab = (INT32 *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(INT32)); - cconvert->Cb_g_tab = (INT32 *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(INT32)); - - for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) { - /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */ - /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */ - /* Cr=>R value is nearest int to 1.40200 * x */ - cconvert->Cr_r_tab[i] = (int) - RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS); - /* Cb=>B value is nearest int to 1.77200 * x */ - cconvert->Cb_b_tab[i] = (int) - RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS); - /* Cr=>G value is scaled-up -0.71414 * x */ - cconvert->Cr_g_tab[i] = (- FIX(0.71414)) * x; - /* Cb=>G value is scaled-up -0.34414 * x */ - /* We also add in ONE_HALF so that need not do it in inner loop */ - cconvert->Cb_g_tab[i] = (- FIX(0.34414)) * x + ONE_HALF; - } -} - - -/* - * Convert some rows of samples to the output colorspace. - * - * Note that we change from noninterleaved, one-plane-per-component format - * to interleaved-pixel format. The output buffer is therefore three times - * as wide as the input buffer. - * A starting row offset is provided only for the input buffer. The caller - * can easily adjust the passed output_buf value to accommodate any row - * offset required on that side. - */ - -METHODDEF(void) -ycc_rgb_convert (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION input_row, - JSAMPARRAY output_buf, int num_rows) -{ - my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; - register int y, cb, cr; - register JSAMPROW outptr; - register JSAMPROW inptr0, inptr1, inptr2; - register JDIMENSION col; - JDIMENSION num_cols = cinfo->output_width; - /* copy these pointers into registers if possible */ - register JSAMPLE * range_limit = cinfo->sample_range_limit; - register int * Crrtab = cconvert->Cr_r_tab; - register int * Cbbtab = cconvert->Cb_b_tab; - register INT32 * Crgtab = cconvert->Cr_g_tab; - register INT32 * Cbgtab = cconvert->Cb_g_tab; - SHIFT_TEMPS - - while (--num_rows >= 0) { - inptr0 = input_buf[0][input_row]; - inptr1 = input_buf[1][input_row]; - inptr2 = input_buf[2][input_row]; - input_row++; - outptr = *output_buf++; - for (col = 0; col < num_cols; col++) { - y = GETJSAMPLE(inptr0[col]); - cb = GETJSAMPLE(inptr1[col]); - cr = GETJSAMPLE(inptr2[col]); - /* Range-limiting is essential due to noise introduced by DCT losses. */ - outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; - outptr[RGB_GREEN] = range_limit[y + - ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], - SCALEBITS))]; - outptr[RGB_BLUE] = range_limit[y + Cbbtab[cb]]; - outptr += RGB_PIXELSIZE; - } - } -} - - -/**************** Cases other than YCbCr -> RGB **************/ - - -/* - * Color conversion for no colorspace change: just copy the data, - * converting from separate-planes to interleaved representation. - */ - -METHODDEF(void) -null_convert (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION input_row, - JSAMPARRAY output_buf, int num_rows) -{ - register JSAMPROW inptr, outptr; - register JDIMENSION count; - register int num_components = cinfo->num_components; - JDIMENSION num_cols = cinfo->output_width; - int ci; - - while (--num_rows >= 0) { - for (ci = 0; ci < num_components; ci++) { - inptr = input_buf[ci][input_row]; - outptr = output_buf[0] + ci; - for (count = num_cols; count > 0; count--) { - *outptr = *inptr++; /* needn't bother with GETJSAMPLE() here */ - outptr += num_components; - } - } - input_row++; - output_buf++; - } -} - - -/* - * Color conversion for grayscale: just copy the data. - * This also works for YCbCr -> grayscale conversion, in which - * we just copy the Y (luminance) component and ignore chrominance. - */ - -METHODDEF(void) -grayscale_convert (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION input_row, - JSAMPARRAY output_buf, int num_rows) -{ - jcopy_sample_rows(input_buf[0], (int) input_row, output_buf, 0, - num_rows, cinfo->output_width); -} - - -/* - * Convert grayscale to RGB: just duplicate the graylevel three times. - * This is provided to support applications that don't want to cope - * with grayscale as a separate case. - */ - -METHODDEF(void) -gray_rgb_convert (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION input_row, - JSAMPARRAY output_buf, int num_rows) -{ - register JSAMPROW inptr, outptr; - register JDIMENSION col; - JDIMENSION num_cols = cinfo->output_width; - - while (--num_rows >= 0) { - inptr = input_buf[0][input_row++]; - outptr = *output_buf++; - for (col = 0; col < num_cols; col++) { - /* We can dispense with GETJSAMPLE() here */ - outptr[RGB_RED] = outptr[RGB_GREEN] = outptr[RGB_BLUE] = inptr[col]; - outptr += RGB_PIXELSIZE; - } - } -} - - -/* - * Adobe-style YCCK->CMYK conversion. - * We convert YCbCr to R=1-C, G=1-M, and B=1-Y using the same - * conversion as above, while passing K (black) unchanged. - * We assume build_ycc_rgb_table has been called. - */ - -METHODDEF(void) -ycck_cmyk_convert (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION input_row, - JSAMPARRAY output_buf, int num_rows) -{ - my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; - register int y, cb, cr; - register JSAMPROW outptr; - register JSAMPROW inptr0, inptr1, inptr2, inptr3; - register JDIMENSION col; - JDIMENSION num_cols = cinfo->output_width; - /* copy these pointers into registers if possible */ - register JSAMPLE * range_limit = cinfo->sample_range_limit; - register int * Crrtab = cconvert->Cr_r_tab; - register int * Cbbtab = cconvert->Cb_b_tab; - register INT32 * Crgtab = cconvert->Cr_g_tab; - register INT32 * Cbgtab = cconvert->Cb_g_tab; - SHIFT_TEMPS - - while (--num_rows >= 0) { - inptr0 = input_buf[0][input_row]; - inptr1 = input_buf[1][input_row]; - inptr2 = input_buf[2][input_row]; - inptr3 = input_buf[3][input_row]; - input_row++; - outptr = *output_buf++; - for (col = 0; col < num_cols; col++) { - y = GETJSAMPLE(inptr0[col]); - cb = GETJSAMPLE(inptr1[col]); - cr = GETJSAMPLE(inptr2[col]); - /* Range-limiting is essential due to noise introduced by DCT losses. */ - outptr[0] = range_limit[MAXJSAMPLE - (y + Crrtab[cr])]; /* red */ - outptr[1] = range_limit[MAXJSAMPLE - (y + /* green */ - ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], - SCALEBITS)))]; - outptr[2] = range_limit[MAXJSAMPLE - (y + Cbbtab[cb])]; /* blue */ - /* K passes through unchanged */ - outptr[3] = inptr3[col]; /* don't need GETJSAMPLE here */ - outptr += 4; - } - } -} - - -/* - * Empty method for start_pass. - */ - -METHODDEF(void) -start_pass_dcolor (j_decompress_ptr cinfo) -{ - /* no work needed */ -} - - -/* - * Module initialization routine for output colorspace conversion. - */ - -GLOBAL(void) -jinit_color_deconverter (j_decompress_ptr cinfo) -{ - my_cconvert_ptr cconvert; - int ci; - - cconvert = (my_cconvert_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_color_deconverter)); - cinfo->cconvert = (struct jpeg_color_deconverter *) cconvert; - cconvert->pub.start_pass = start_pass_dcolor; - - /* Make sure num_components agrees with jpeg_color_space */ - switch (cinfo->jpeg_color_space) { - case JCS_GRAYSCALE: - if (cinfo->num_components != 1) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - break; - - case JCS_RGB: - case JCS_YCbCr: - if (cinfo->num_components != 3) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - break; - - case JCS_CMYK: - case JCS_YCCK: - if (cinfo->num_components != 4) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - break; - - default: /* JCS_UNKNOWN can be anything */ - if (cinfo->num_components < 1) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - break; - } - - /* Set out_color_components and conversion method based on requested space. - * Also clear the component_needed flags for any unused components, - * so that earlier pipeline stages can avoid useless computation. - */ - - switch (cinfo->out_color_space) { - case JCS_GRAYSCALE: - cinfo->out_color_components = 1; - if (cinfo->jpeg_color_space == JCS_GRAYSCALE || - cinfo->jpeg_color_space == JCS_YCbCr) { - cconvert->pub.color_convert = grayscale_convert; - /* For color->grayscale conversion, only the Y (0) component is needed */ - for (ci = 1; ci < cinfo->num_components; ci++) - cinfo->comp_info[ci].component_needed = FALSE; - } else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - case JCS_RGB: - cinfo->out_color_components = RGB_PIXELSIZE; - if (cinfo->jpeg_color_space == JCS_YCbCr) { - cconvert->pub.color_convert = ycc_rgb_convert; - build_ycc_rgb_table(cinfo); - } else if (cinfo->jpeg_color_space == JCS_GRAYSCALE) { - cconvert->pub.color_convert = gray_rgb_convert; - } else if (cinfo->jpeg_color_space == JCS_RGB && RGB_PIXELSIZE == 3) { - cconvert->pub.color_convert = null_convert; - } else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - case JCS_CMYK: - cinfo->out_color_components = 4; - if (cinfo->jpeg_color_space == JCS_YCCK) { - cconvert->pub.color_convert = ycck_cmyk_convert; - build_ycc_rgb_table(cinfo); - } else if (cinfo->jpeg_color_space == JCS_CMYK) { - cconvert->pub.color_convert = null_convert; - } else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - default: - /* Permit null conversion to same output space */ - if (cinfo->out_color_space == cinfo->jpeg_color_space) { - cinfo->out_color_components = cinfo->num_components; - cconvert->pub.color_convert = null_convert; - } else /* unsupported non-null conversion */ - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - } - - if (cinfo->quantize_colors) - cinfo->output_components = 1; /* single colormapped output component */ - else - cinfo->output_components = cinfo->out_color_components; -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jdct.h b/irrlicht-1.6/source/Irrlicht/jpeglib/jdct.h deleted file mode 100644 index b664cab0d..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jdct.h +++ /dev/null @@ -1,176 +0,0 @@ -/* - * jdct.h - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This include file contains common declarations for the forward and - * inverse DCT modules. These declarations are private to the DCT managers - * (jcdctmgr.c, jddctmgr.c) and the individual DCT algorithms. - * The individual DCT algorithms are kept in separate files to ease - * machine-dependent tuning (e.g., assembly coding). - */ - - -/* - * A forward DCT routine is given a pointer to a work area of type DCTELEM[]; - * the DCT is to be performed in-place in that buffer. Type DCTELEM is int - * for 8-bit samples, INT32 for 12-bit samples. (NOTE: Floating-point DCT - * implementations use an array of type FAST_FLOAT, instead.) - * The DCT inputs are expected to be signed (range +-CENTERJSAMPLE). - * The DCT outputs are returned scaled up by a factor of 8; they therefore - * have a range of +-8K for 8-bit data, +-128K for 12-bit data. This - * convention improves accuracy in integer implementations and saves some - * work in floating-point ones. - * Quantization of the output coefficients is done by jcdctmgr.c. - */ - -#if BITS_IN_JSAMPLE == 8 -typedef int DCTELEM; /* 16 or 32 bits is fine */ -#else -typedef INT32 DCTELEM; /* must have 32 bits */ -#endif - -typedef JMETHOD(void, forward_DCT_method_ptr, (DCTELEM * data)); -typedef JMETHOD(void, float_DCT_method_ptr, (FAST_FLOAT * data)); - - -/* - * An inverse DCT routine is given a pointer to the input JBLOCK and a pointer - * to an output sample array. The routine must dequantize the input data as - * well as perform the IDCT; for dequantization, it uses the multiplier table - * pointed to by compptr->dct_table. The output data is to be placed into the - * sample array starting at a specified column. (Any row offset needed will - * be applied to the array pointer before it is passed to the IDCT code.) - * Note that the number of samples emitted by the IDCT routine is - * DCT_scaled_size * DCT_scaled_size. - */ - -/* typedef inverse_DCT_method_ptr is declared in jpegint.h */ - -/* - * Each IDCT routine has its own ideas about the best dct_table element type. - */ - -typedef MULTIPLIER ISLOW_MULT_TYPE; /* short or int, whichever is faster */ -#if BITS_IN_JSAMPLE == 8 -typedef MULTIPLIER IFAST_MULT_TYPE; /* 16 bits is OK, use short if faster */ -#define IFAST_SCALE_BITS 2 /* fractional bits in scale factors */ -#else -typedef INT32 IFAST_MULT_TYPE; /* need 32 bits for scaled quantizers */ -#define IFAST_SCALE_BITS 13 /* fractional bits in scale factors */ -#endif -typedef FAST_FLOAT FLOAT_MULT_TYPE; /* preferred floating type */ - - -/* - * Each IDCT routine is responsible for range-limiting its results and - * converting them to unsigned form (0..MAXJSAMPLE). The raw outputs could - * be quite far out of range if the input data is corrupt, so a bulletproof - * range-limiting step is required. We use a mask-and-table-lookup method - * to do the combined operations quickly. See the comments with - * prepare_range_limit_table (in jdmaster.c) for more info. - */ - -#define IDCT_range_limit(cinfo) ((cinfo)->sample_range_limit + CENTERJSAMPLE) - -#define RANGE_MASK (MAXJSAMPLE * 4 + 3) /* 2 bits wider than legal samples */ - - -/* Short forms of external names for systems with brain-damaged linkers. */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jpeg_fdct_islow jFDislow -#define jpeg_fdct_ifast jFDifast -#define jpeg_fdct_float jFDfloat -#define jpeg_idct_islow jRDislow -#define jpeg_idct_ifast jRDifast -#define jpeg_idct_float jRDfloat -#define jpeg_idct_4x4 jRD4x4 -#define jpeg_idct_2x2 jRD2x2 -#define jpeg_idct_1x1 jRD1x1 -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - -/* Extern declarations for the forward and inverse DCT routines. */ - -EXTERN(void) jpeg_fdct_islow JPP((DCTELEM * data)); -EXTERN(void) jpeg_fdct_ifast JPP((DCTELEM * data)); -EXTERN(void) jpeg_fdct_float JPP((FAST_FLOAT * data)); - -EXTERN(void) jpeg_idct_islow - JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); -EXTERN(void) jpeg_idct_ifast - JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); -EXTERN(void) jpeg_idct_float - JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); -EXTERN(void) jpeg_idct_4x4 - JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); -EXTERN(void) jpeg_idct_2x2 - JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); -EXTERN(void) jpeg_idct_1x1 - JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); - - -/* - * Macros for handling fixed-point arithmetic; these are used by many - * but not all of the DCT/IDCT modules. - * - * All values are expected to be of type INT32. - * Fractional constants are scaled left by CONST_BITS bits. - * CONST_BITS is defined within each module using these macros, - * and may differ from one module to the next. - */ - -#define ONE ((INT32) 1) -#define CONST_SCALE (ONE << CONST_BITS) - -/* Convert a positive real constant to an integer scaled by CONST_SCALE. - * Caution: some C compilers fail to reduce "FIX(constant)" at compile time, - * thus causing a lot of useless floating-point operations at run time. - */ - -#define FIX(x) ((INT32) ((x) * CONST_SCALE + 0.5)) - -/* Descale and correctly round an INT32 value that's scaled by N bits. - * We assume RIGHT_SHIFT rounds towards minus infinity, so adding - * the fudge factor is correct for either sign of X. - */ - -#define DESCALE(x,n) RIGHT_SHIFT((x) + (ONE << ((n)-1)), n) - -/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. - * This macro is used only when the two inputs will actually be no more than - * 16 bits wide, so that a 16x16->32 bit multiply can be used instead of a - * full 32x32 multiply. This provides a useful speedup on many machines. - * Unfortunately there is no way to specify a 16x16->32 multiply portably - * in C, but some C compilers will do the right thing if you provide the - * correct combination of casts. - */ - -#ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */ -#define MULTIPLY16C16(var,const) (((INT16) (var)) * ((INT16) (const))) -#endif -#ifdef SHORTxLCONST_32 /* known to work with Microsoft C 6.0 */ -#define MULTIPLY16C16(var,const) (((INT16) (var)) * ((INT32) (const))) -#endif - -#ifndef MULTIPLY16C16 /* default definition */ -#define MULTIPLY16C16(var,const) ((var) * (const)) -#endif - -/* Same except both inputs are variables. */ - -#ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */ -#define MULTIPLY16V16(var1,var2) (((INT16) (var1)) * ((INT16) (var2))) -#endif - -#ifndef MULTIPLY16V16 /* default definition */ -#define MULTIPLY16V16(var1,var2) ((var1) * (var2)) -#endif diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jddctmgr.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jddctmgr.c deleted file mode 100644 index 0e44eb14a..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jddctmgr.c +++ /dev/null @@ -1,269 +0,0 @@ -/* - * jddctmgr.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the inverse-DCT management logic. - * This code selects a particular IDCT implementation to be used, - * and it performs related housekeeping chores. No code in this file - * is executed per IDCT step, only during output pass setup. - * - * Note that the IDCT routines are responsible for performing coefficient - * dequantization as well as the IDCT proper. This module sets up the - * dequantization multiplier table needed by the IDCT routine. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - - -/* - * The decompressor input side (jdinput.c) saves away the appropriate - * quantization table for each component at the start of the first scan - * involving that component. (This is necessary in order to correctly - * decode files that reuse Q-table slots.) - * When we are ready to make an output pass, the saved Q-table is converted - * to a multiplier table that will actually be used by the IDCT routine. - * The multiplier table contents are IDCT-method-dependent. To support - * application changes in IDCT method between scans, we can remake the - * multiplier tables if necessary. - * In buffered-image mode, the first output pass may occur before any data - * has been seen for some components, and thus before their Q-tables have - * been saved away. To handle this case, multiplier tables are preset - * to zeroes; the result of the IDCT will be a neutral gray level. - */ - - -/* Private subobject for this module */ - -typedef struct { - struct jpeg_inverse_dct pub; /* public fields */ - - /* This array contains the IDCT method code that each multiplier table - * is currently set up for, or -1 if it's not yet set up. - * The actual multiplier tables are pointed to by dct_table in the - * per-component comp_info structures. - */ - int cur_method[MAX_COMPONENTS]; -} my_idct_controller; - -typedef my_idct_controller * my_idct_ptr; - - -/* Allocated multiplier tables: big enough for any supported variant */ - -typedef union { - ISLOW_MULT_TYPE islow_array[DCTSIZE2]; -#ifdef DCT_IFAST_SUPPORTED - IFAST_MULT_TYPE ifast_array[DCTSIZE2]; -#endif -#ifdef DCT_FLOAT_SUPPORTED - FLOAT_MULT_TYPE float_array[DCTSIZE2]; -#endif -} multiplier_table; - - -/* The current scaled-IDCT routines require ISLOW-style multiplier tables, - * so be sure to compile that code if either ISLOW or SCALING is requested. - */ -#ifdef DCT_ISLOW_SUPPORTED -#define PROVIDE_ISLOW_TABLES -#else -#ifdef IDCT_SCALING_SUPPORTED -#define PROVIDE_ISLOW_TABLES -#endif -#endif - - -/* - * Prepare for an output pass. - * Here we select the proper IDCT routine for each component and build - * a matching multiplier table. - */ - -METHODDEF(void) -start_pass (j_decompress_ptr cinfo) -{ - my_idct_ptr idct = (my_idct_ptr) cinfo->idct; - int ci, i; - jpeg_component_info *compptr; - int method = 0; - inverse_DCT_method_ptr method_ptr = NULL; - JQUANT_TBL * qtbl; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Select the proper IDCT routine for this component's scaling */ - switch (compptr->DCT_scaled_size) { -#ifdef IDCT_SCALING_SUPPORTED - case 1: - method_ptr = jpeg_idct_1x1; - method = JDCT_ISLOW; /* jidctred uses islow-style table */ - break; - case 2: - method_ptr = jpeg_idct_2x2; - method = JDCT_ISLOW; /* jidctred uses islow-style table */ - break; - case 4: - method_ptr = jpeg_idct_4x4; - method = JDCT_ISLOW; /* jidctred uses islow-style table */ - break; -#endif - case DCTSIZE: - switch (cinfo->dct_method) { -#ifdef DCT_ISLOW_SUPPORTED - case JDCT_ISLOW: - method_ptr = jpeg_idct_islow; - method = JDCT_ISLOW; - break; -#endif -#ifdef DCT_IFAST_SUPPORTED - case JDCT_IFAST: - method_ptr = jpeg_idct_ifast; - method = JDCT_IFAST; - break; -#endif -#ifdef DCT_FLOAT_SUPPORTED - case JDCT_FLOAT: - method_ptr = jpeg_idct_float; - method = JDCT_FLOAT; - break; -#endif - default: - ERREXIT(cinfo, JERR_NOT_COMPILED); - break; - } - break; - default: - ERREXIT1(cinfo, JERR_BAD_DCTSIZE, compptr->DCT_scaled_size); - break; - } - idct->pub.inverse_DCT[ci] = method_ptr; - /* Create multiplier table from quant table. - * However, we can skip this if the component is uninteresting - * or if we already built the table. Also, if no quant table - * has yet been saved for the component, we leave the - * multiplier table all-zero; we'll be reading zeroes from the - * coefficient controller's buffer anyway. - */ - if (! compptr->component_needed || idct->cur_method[ci] == method) - continue; - qtbl = compptr->quant_table; - if (qtbl == NULL) /* happens if no data yet for component */ - continue; - idct->cur_method[ci] = method; - switch (method) { -#ifdef PROVIDE_ISLOW_TABLES - case JDCT_ISLOW: - { - /* For LL&M IDCT method, multipliers are equal to raw quantization - * coefficients, but are stored as ints to ensure access efficiency. - */ - ISLOW_MULT_TYPE * ismtbl = (ISLOW_MULT_TYPE *) compptr->dct_table; - for (i = 0; i < DCTSIZE2; i++) { - ismtbl[i] = (ISLOW_MULT_TYPE) qtbl->quantval[i]; - } - } - break; -#endif -#ifdef DCT_IFAST_SUPPORTED - case JDCT_IFAST: - { - /* For AA&N IDCT method, multipliers are equal to quantization - * coefficients scaled by scalefactor[row]*scalefactor[col], where - * scalefactor[0] = 1 - * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 - * For integer operation, the multiplier table is to be scaled by - * IFAST_SCALE_BITS. - */ - IFAST_MULT_TYPE * ifmtbl = (IFAST_MULT_TYPE *) compptr->dct_table; -#define CONST_BITS 14 - static const INT16 aanscales[DCTSIZE2] = { - /* precomputed values scaled up by 14 bits */ - 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, - 22725, 31521, 29692, 26722, 22725, 17855, 12299, 6270, - 21407, 29692, 27969, 25172, 21407, 16819, 11585, 5906, - 19266, 26722, 25172, 22654, 19266, 15137, 10426, 5315, - 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, - 12873, 17855, 16819, 15137, 12873, 10114, 6967, 3552, - 8867, 12299, 11585, 10426, 8867, 6967, 4799, 2446, - 4520, 6270, 5906, 5315, 4520, 3552, 2446, 1247 - }; - SHIFT_TEMPS - - for (i = 0; i < DCTSIZE2; i++) { - ifmtbl[i] = (IFAST_MULT_TYPE) - DESCALE(MULTIPLY16V16((INT32) qtbl->quantval[i], - (INT32) aanscales[i]), - CONST_BITS-IFAST_SCALE_BITS); - } - } - break; -#endif -#ifdef DCT_FLOAT_SUPPORTED - case JDCT_FLOAT: - { - /* For float AA&N IDCT method, multipliers are equal to quantization - * coefficients scaled by scalefactor[row]*scalefactor[col], where - * scalefactor[0] = 1 - * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 - */ - FLOAT_MULT_TYPE * fmtbl = (FLOAT_MULT_TYPE *) compptr->dct_table; - int row, col; - static const double aanscalefactor[DCTSIZE] = { - 1.0, 1.387039845, 1.306562965, 1.175875602, - 1.0, 0.785694958, 0.541196100, 0.275899379 - }; - - i = 0; - for (row = 0; row < DCTSIZE; row++) { - for (col = 0; col < DCTSIZE; col++) { - fmtbl[i] = (FLOAT_MULT_TYPE) - ((double) qtbl->quantval[i] * - aanscalefactor[row] * aanscalefactor[col]); - i++; - } - } - } - break; -#endif - default: - ERREXIT(cinfo, JERR_NOT_COMPILED); - break; - } - } -} - - -/* - * Initialize IDCT manager. - */ - -GLOBAL(void) -jinit_inverse_dct (j_decompress_ptr cinfo) -{ - my_idct_ptr idct; - int ci; - jpeg_component_info *compptr; - - idct = (my_idct_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_idct_controller)); - cinfo->idct = (struct jpeg_inverse_dct *) idct; - idct->pub.start_pass = start_pass; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Allocate and pre-zero a multiplier table for each component */ - compptr->dct_table = - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(multiplier_table)); - MEMZERO(compptr->dct_table, SIZEOF(multiplier_table)); - /* Mark multiplier table not yet set up for any method */ - idct->cur_method[ci] = -1; - } -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jdhuff.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jdhuff.c deleted file mode 100644 index b2ad66d42..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jdhuff.c +++ /dev/null @@ -1,651 +0,0 @@ -/* - * jdhuff.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains Huffman entropy decoding routines. - * - * Much of the complexity here has to do with supporting input suspension. - * If the data source module demands suspension, we want to be able to back - * up to the start of the current MCU. To do this, we copy state variables - * into local working storage, and update them back to the permanent - * storage only upon successful completion of an MCU. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdhuff.h" /* Declarations shared with jdphuff.c */ - - -/* - * Expanded entropy decoder object for Huffman decoding. - * - * The savable_state subrecord contains fields that change within an MCU, - * but must not be updated permanently until we complete the MCU. - */ - -typedef struct { - int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */ -} savable_state; - -/* This macro is to work around compilers with missing or broken - * structure assignment. You'll need to fix this code if you have - * such a compiler and you change MAX_COMPS_IN_SCAN. - */ - -#ifndef NO_STRUCT_ASSIGN -#define ASSIGN_STATE(dest,src) ((dest) = (src)) -#else -#if MAX_COMPS_IN_SCAN == 4 -#define ASSIGN_STATE(dest,src) \ - ((dest).last_dc_val[0] = (src).last_dc_val[0], \ - (dest).last_dc_val[1] = (src).last_dc_val[1], \ - (dest).last_dc_val[2] = (src).last_dc_val[2], \ - (dest).last_dc_val[3] = (src).last_dc_val[3]) -#endif -#endif - - -typedef struct { - struct jpeg_entropy_decoder pub; /* public fields */ - - /* These fields are loaded into local variables at start of each MCU. - * In case of suspension, we exit WITHOUT updating them. - */ - bitread_perm_state bitstate; /* Bit buffer at start of MCU */ - savable_state saved; /* Other state at start of MCU */ - - /* These fields are NOT loaded into local working state. */ - unsigned int restarts_to_go; /* MCUs left in this restart interval */ - - /* Pointers to derived tables (these workspaces have image lifespan) */ - d_derived_tbl * dc_derived_tbls[NUM_HUFF_TBLS]; - d_derived_tbl * ac_derived_tbls[NUM_HUFF_TBLS]; - - /* Precalculated info set up by start_pass for use in decode_mcu: */ - - /* Pointers to derived tables to be used for each block within an MCU */ - d_derived_tbl * dc_cur_tbls[D_MAX_BLOCKS_IN_MCU]; - d_derived_tbl * ac_cur_tbls[D_MAX_BLOCKS_IN_MCU]; - /* Whether we care about the DC and AC coefficient values for each block */ - boolean dc_needed[D_MAX_BLOCKS_IN_MCU]; - boolean ac_needed[D_MAX_BLOCKS_IN_MCU]; -} huff_entropy_decoder; - -typedef huff_entropy_decoder * huff_entropy_ptr; - - -/* - * Initialize for a Huffman-compressed scan. - */ - -METHODDEF(void) -start_pass_huff_decoder (j_decompress_ptr cinfo) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - int ci, blkn, dctbl, actbl; - jpeg_component_info * compptr; - - /* Check that the scan parameters Ss, Se, Ah/Al are OK for sequential JPEG. - * This ought to be an error condition, but we make it a warning because - * there are some baseline files out there with all zeroes in these bytes. - */ - if (cinfo->Ss != 0 || cinfo->Se != DCTSIZE2-1 || - cinfo->Ah != 0 || cinfo->Al != 0) - WARNMS(cinfo, JWRN_NOT_SEQUENTIAL); - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - dctbl = compptr->dc_tbl_no; - actbl = compptr->ac_tbl_no; - /* Compute derived values for Huffman tables */ - /* We may do this more than once for a table, but it's not expensive */ - jpeg_make_d_derived_tbl(cinfo, TRUE, dctbl, - & entropy->dc_derived_tbls[dctbl]); - jpeg_make_d_derived_tbl(cinfo, FALSE, actbl, - & entropy->ac_derived_tbls[actbl]); - /* Initialize DC predictions to 0 */ - entropy->saved.last_dc_val[ci] = 0; - } - - /* Precalculate decoding info for each block in an MCU of this scan */ - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - ci = cinfo->MCU_membership[blkn]; - compptr = cinfo->cur_comp_info[ci]; - /* Precalculate which table to use for each block */ - entropy->dc_cur_tbls[blkn] = entropy->dc_derived_tbls[compptr->dc_tbl_no]; - entropy->ac_cur_tbls[blkn] = entropy->ac_derived_tbls[compptr->ac_tbl_no]; - /* Decide whether we really care about the coefficient values */ - if (compptr->component_needed) { - entropy->dc_needed[blkn] = TRUE; - /* we don't need the ACs if producing a 1/8th-size image */ - entropy->ac_needed[blkn] = (compptr->DCT_scaled_size > 1); - } else { - entropy->dc_needed[blkn] = entropy->ac_needed[blkn] = FALSE; - } - } - - /* Initialize bitread state variables */ - entropy->bitstate.bits_left = 0; - entropy->bitstate.get_buffer = 0; /* unnecessary, but keeps Purify quiet */ - entropy->pub.insufficient_data = FALSE; - - /* Initialize restart counter */ - entropy->restarts_to_go = cinfo->restart_interval; -} - - -/* - * Compute the derived values for a Huffman table. - * This routine also performs some validation checks on the table. - * - * Note this is also used by jdphuff.c. - */ - -GLOBAL(void) -jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno, - d_derived_tbl ** pdtbl) -{ - JHUFF_TBL *htbl; - d_derived_tbl *dtbl; - int p, i, l, si, numsymbols; - int lookbits, ctr; - char huffsize[257]; - unsigned int huffcode[257]; - unsigned int code; - - /* Note that huffsize[] and huffcode[] are filled in code-length order, - * paralleling the order of the symbols themselves in htbl->huffval[]. - */ - - /* Find the input Huffman table */ - if (tblno < 0 || tblno >= NUM_HUFF_TBLS) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno); - htbl = - isDC ? cinfo->dc_huff_tbl_ptrs[tblno] : cinfo->ac_huff_tbl_ptrs[tblno]; - if (htbl == NULL) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno); - - /* Allocate a workspace if we haven't already done so. */ - if (*pdtbl == NULL) - *pdtbl = (d_derived_tbl *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(d_derived_tbl)); - dtbl = *pdtbl; - dtbl->pub = htbl; /* fill in back link */ - - /* Figure C.1: make table of Huffman code length for each symbol */ - - p = 0; - for (l = 1; l <= 16; l++) { - i = (int) htbl->bits[l]; - if (i < 0 || p + i > 256) /* protect against table overrun */ - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - while (i--) - huffsize[p++] = (char) l; - } - huffsize[p] = 0; - numsymbols = p; - - /* Figure C.2: generate the codes themselves */ - /* We also validate that the counts represent a legal Huffman code tree. */ - - code = 0; - si = huffsize[0]; - p = 0; - while (huffsize[p]) { - while (((int) huffsize[p]) == si) { - huffcode[p++] = code; - code++; - } - /* code is now 1 more than the last code used for codelength si; but - * it must still fit in si bits, since no code is allowed to be all ones. - */ - if (((INT32) code) >= (((INT32) 1) << si)) - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - code <<= 1; - si++; - } - - /* Figure F.15: generate decoding tables for bit-sequential decoding */ - - p = 0; - for (l = 1; l <= 16; l++) { - if (htbl->bits[l]) { - /* valoffset[l] = huffval[] index of 1st symbol of code length l, - * minus the minimum code of length l - */ - dtbl->valoffset[l] = (INT32) p - (INT32) huffcode[p]; - p += htbl->bits[l]; - dtbl->maxcode[l] = huffcode[p-1]; /* maximum code of length l */ - } else { - dtbl->maxcode[l] = -1; /* -1 if no codes of this length */ - } - } - dtbl->maxcode[17] = 0xFFFFFL; /* ensures jpeg_huff_decode terminates */ - - /* Compute lookahead tables to speed up decoding. - * First we set all the table entries to 0, indicating "too long"; - * then we iterate through the Huffman codes that are short enough and - * fill in all the entries that correspond to bit sequences starting - * with that code. - */ - - MEMZERO(dtbl->look_nbits, SIZEOF(dtbl->look_nbits)); - - p = 0; - for (l = 1; l <= HUFF_LOOKAHEAD; l++) { - for (i = 1; i <= (int) htbl->bits[l]; i++, p++) { - /* l = current code's length, p = its index in huffcode[] & huffval[]. */ - /* Generate left-justified code followed by all possible bit sequences */ - lookbits = huffcode[p] << (HUFF_LOOKAHEAD-l); - for (ctr = 1 << (HUFF_LOOKAHEAD-l); ctr > 0; ctr--) { - dtbl->look_nbits[lookbits] = l; - dtbl->look_sym[lookbits] = htbl->huffval[p]; - lookbits++; - } - } - } - - /* Validate symbols as being reasonable. - * For AC tables, we make no check, but accept all byte values 0..255. - * For DC tables, we require the symbols to be in range 0..15. - * (Tighter bounds could be applied depending on the data depth and mode, - * but this is sufficient to ensure safe decoding.) - */ - if (isDC) { - for (i = 0; i < numsymbols; i++) { - int sym = htbl->huffval[i]; - if (sym < 0 || sym > 15) - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - } - } -} - - -/* - * Out-of-line code for bit fetching (shared with jdphuff.c). - * See jdhuff.h for info about usage. - * Note: current values of get_buffer and bits_left are passed as parameters, - * but are returned in the corresponding fields of the state struct. - * - * On most machines MIN_GET_BITS should be 25 to allow the full 32-bit width - * of get_buffer to be used. (On machines with wider words, an even larger - * buffer could be used.) However, on some machines 32-bit shifts are - * quite slow and take time proportional to the number of places shifted. - * (This is true with most PC compilers, for instance.) In this case it may - * be a win to set MIN_GET_BITS to the minimum value of 15. This reduces the - * average shift distance at the cost of more calls to jpeg_fill_bit_buffer. - */ - -#ifdef SLOW_SHIFT_32 -#define MIN_GET_BITS 15 /* minimum allowable value */ -#else -#define MIN_GET_BITS (BIT_BUF_SIZE-7) -#endif - - -GLOBAL(boolean) -jpeg_fill_bit_buffer (bitread_working_state * state, - register bit_buf_type get_buffer, register int bits_left, - int nbits) -/* Load up the bit buffer to a depth of at least nbits */ -{ - /* Copy heavily used state fields into locals (hopefully registers) */ - register const JOCTET * next_input_byte = state->next_input_byte; - register size_t bytes_in_buffer = state->bytes_in_buffer; - j_decompress_ptr cinfo = state->cinfo; - - /* Attempt to load at least MIN_GET_BITS bits into get_buffer. */ - /* (It is assumed that no request will be for more than that many bits.) */ - /* We fail to do so only if we hit a marker or are forced to suspend. */ - - if (cinfo->unread_marker == 0) { /* cannot advance past a marker */ - while (bits_left < MIN_GET_BITS) { - register int c; - - /* Attempt to read a byte */ - if (bytes_in_buffer == 0) { - if (! (*cinfo->src->fill_input_buffer) (cinfo)) - return FALSE; - next_input_byte = cinfo->src->next_input_byte; - bytes_in_buffer = cinfo->src->bytes_in_buffer; - } - bytes_in_buffer--; - c = GETJOCTET(*next_input_byte++); - - /* If it's 0xFF, check and discard stuffed zero byte */ - if (c == 0xFF) { - /* Loop here to discard any padding FF's on terminating marker, - * so that we can save a valid unread_marker value. NOTE: we will - * accept multiple FF's followed by a 0 as meaning a single FF data - * byte. This data pattern is not valid according to the standard. - */ - do { - if (bytes_in_buffer == 0) { - if (! (*cinfo->src->fill_input_buffer) (cinfo)) - return FALSE; - next_input_byte = cinfo->src->next_input_byte; - bytes_in_buffer = cinfo->src->bytes_in_buffer; - } - bytes_in_buffer--; - c = GETJOCTET(*next_input_byte++); - } while (c == 0xFF); - - if (c == 0) { - /* Found FF/00, which represents an FF data byte */ - c = 0xFF; - } else { - /* Oops, it's actually a marker indicating end of compressed data. - * Save the marker code for later use. - * Fine point: it might appear that we should save the marker into - * bitread working state, not straight into permanent state. But - * once we have hit a marker, we cannot need to suspend within the - * current MCU, because we will read no more bytes from the data - * source. So it is OK to update permanent state right away. - */ - cinfo->unread_marker = c; - /* See if we need to insert some fake zero bits. */ - goto no_more_bytes; - } - } - - /* OK, load c into get_buffer */ - get_buffer = (get_buffer << 8) | c; - bits_left += 8; - } /* end while */ - } else { - no_more_bytes: - /* We get here if we've read the marker that terminates the compressed - * data segment. There should be enough bits in the buffer register - * to satisfy the request; if so, no problem. - */ - if (nbits > bits_left) { - /* Uh-oh. Report corrupted data to user and stuff zeroes into - * the data stream, so that we can produce some kind of image. - * We use a nonvolatile flag to ensure that only one warning message - * appears per data segment. - */ - if (! cinfo->entropy->insufficient_data) { - WARNMS(cinfo, JWRN_HIT_MARKER); - cinfo->entropy->insufficient_data = TRUE; - } - /* Fill the buffer with zero bits */ - get_buffer <<= MIN_GET_BITS - bits_left; - bits_left = MIN_GET_BITS; - } - } - - /* Unload the local registers */ - state->next_input_byte = next_input_byte; - state->bytes_in_buffer = bytes_in_buffer; - state->get_buffer = get_buffer; - state->bits_left = bits_left; - - return TRUE; -} - - -/* - * Out-of-line code for Huffman code decoding. - * See jdhuff.h for info about usage. - */ - -GLOBAL(int) -jpeg_huff_decode (bitread_working_state * state, - register bit_buf_type get_buffer, register int bits_left, - d_derived_tbl * htbl, int min_bits) -{ - register int l = min_bits; - register INT32 code; - - /* HUFF_DECODE has determined that the code is at least min_bits */ - /* bits long, so fetch that many bits in one swoop. */ - - CHECK_BIT_BUFFER(*state, l, return -1); - code = GET_BITS(l); - - /* Collect the rest of the Huffman code one bit at a time. */ - /* This is per Figure F.16 in the JPEG spec. */ - - while (code > htbl->maxcode[l]) { - code <<= 1; - CHECK_BIT_BUFFER(*state, 1, return -1); - code |= GET_BITS(1); - l++; - } - - /* Unload the local registers */ - state->get_buffer = get_buffer; - state->bits_left = bits_left; - - /* With garbage input we may reach the sentinel value l = 17. */ - - if (l > 16) { - WARNMS(state->cinfo, JWRN_HUFF_BAD_CODE); - return 0; /* fake a zero as the safest result */ - } - - return htbl->pub->huffval[ (int) (code + htbl->valoffset[l]) ]; -} - - -/* - * Figure F.12: extend sign bit. - * On some machines, a shift and add will be faster than a table lookup. - */ - -#ifdef AVOID_TABLES - -#define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) + (((-1)<<(s)) + 1) : (x)) - -#else - -#define HUFF_EXTEND(x,s) ((x) < extend_test[s] ? (x) + extend_offset[s] : (x)) - -static const int extend_test[16] = /* entry n is 2**(n-1) */ - { 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, - 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000 }; - -static const int extend_offset[16] = /* entry n is (-1 << n) + 1 */ - { 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1, - ((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1, - ((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1, - ((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 }; - -#endif /* AVOID_TABLES */ - - -/* - * Check for a restart marker & resynchronize decoder. - * Returns FALSE if must suspend. - */ - -LOCAL(boolean) -process_restart (j_decompress_ptr cinfo) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - int ci; - - /* Throw away any unused bits remaining in bit buffer; */ - /* include any full bytes in next_marker's count of discarded bytes */ - cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8; - entropy->bitstate.bits_left = 0; - - /* Advance past the RSTn marker */ - if (! (*cinfo->marker->read_restart_marker) (cinfo)) - return FALSE; - - /* Re-initialize DC predictions to 0 */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) - entropy->saved.last_dc_val[ci] = 0; - - /* Reset restart counter */ - entropy->restarts_to_go = cinfo->restart_interval; - - /* Reset out-of-data flag, unless read_restart_marker left us smack up - * against a marker. In that case we will end up treating the next data - * segment as empty, and we can avoid producing bogus output pixels by - * leaving the flag set. - */ - if (cinfo->unread_marker == 0) - entropy->pub.insufficient_data = FALSE; - - return TRUE; -} - - -/* - * Decode and return one MCU's worth of Huffman-compressed coefficients. - * The coefficients are reordered from zigzag order into natural array order, - * but are not dequantized. - * - * The i'th block of the MCU is stored into the block pointed to by - * MCU_data[i]. WE ASSUME THIS AREA HAS BEEN ZEROED BY THE CALLER. - * (Wholesale zeroing is usually a little faster than retail...) - * - * Returns FALSE if data source requested suspension. In that case no - * changes have been made to permanent state. (Exception: some output - * coefficients may already have been assigned. This is harmless for - * this module, since we'll just re-assign them on the next call.) - */ - -METHODDEF(boolean) -decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - int blkn; - BITREAD_STATE_VARS; - savable_state state; - - /* Process restart marker if needed; may have to suspend */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) - if (! process_restart(cinfo)) - return FALSE; - } - - /* If we've run out of data, just leave the MCU set to zeroes. - * This way, we return uniform gray for the remainder of the segment. - */ - if (! entropy->pub.insufficient_data) { - - /* Load up working state */ - BITREAD_LOAD_STATE(cinfo,entropy->bitstate); - ASSIGN_STATE(state, entropy->saved); - - /* Outer loop handles each block in the MCU */ - - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - JBLOCKROW block = MCU_data[blkn]; - d_derived_tbl * dctbl = entropy->dc_cur_tbls[blkn]; - d_derived_tbl * actbl = entropy->ac_cur_tbls[blkn]; - register int s, k, r; - - /* Decode a single block's worth of coefficients */ - - /* Section F.2.2.1: decode the DC coefficient difference */ - HUFF_DECODE(s, br_state, dctbl, return FALSE, label1); - if (s) { - CHECK_BIT_BUFFER(br_state, s, return FALSE); - r = GET_BITS(s); - s = HUFF_EXTEND(r, s); - } - - if (entropy->dc_needed[blkn]) { - /* Convert DC difference to actual value, update last_dc_val */ - int ci = cinfo->MCU_membership[blkn]; - s += state.last_dc_val[ci]; - state.last_dc_val[ci] = s; - /* Output the DC coefficient (assumes jpeg_natural_order[0] = 0) */ - (*block)[0] = (JCOEF) s; - } - - if (entropy->ac_needed[blkn]) { - - /* Section F.2.2.2: decode the AC coefficients */ - /* Since zeroes are skipped, output area must be cleared beforehand */ - for (k = 1; k < DCTSIZE2; k++) { - HUFF_DECODE(s, br_state, actbl, return FALSE, label2); - - r = s >> 4; - s &= 15; - - if (s) { - k += r; - CHECK_BIT_BUFFER(br_state, s, return FALSE); - r = GET_BITS(s); - s = HUFF_EXTEND(r, s); - /* Output coefficient in natural (dezigzagged) order. - * Note: the extra entries in jpeg_natural_order[] will save us - * if k >= DCTSIZE2, which could happen if the data is corrupted. - */ - (*block)[jpeg_natural_order[k]] = (JCOEF) s; - } else { - if (r != 15) - break; - k += 15; - } - } - - } else { - - /* Section F.2.2.2: decode the AC coefficients */ - /* In this path we just discard the values */ - for (k = 1; k < DCTSIZE2; k++) { - HUFF_DECODE(s, br_state, actbl, return FALSE, label3); - - r = s >> 4; - s &= 15; - - if (s) { - k += r; - CHECK_BIT_BUFFER(br_state, s, return FALSE); - DROP_BITS(s); - } else { - if (r != 15) - break; - k += 15; - } - } - - } - } - - /* Completed MCU, so update state */ - BITREAD_SAVE_STATE(cinfo,entropy->bitstate); - ASSIGN_STATE(entropy->saved, state); - } - - /* Account for restart interval (no-op if not using restarts) */ - entropy->restarts_to_go--; - - return TRUE; -} - - -/* - * Module initialization routine for Huffman entropy decoding. - */ - -GLOBAL(void) -jinit_huff_decoder (j_decompress_ptr cinfo) -{ - huff_entropy_ptr entropy; - int i; - - entropy = (huff_entropy_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(huff_entropy_decoder)); - cinfo->entropy = (struct jpeg_entropy_decoder *) entropy; - entropy->pub.start_pass = start_pass_huff_decoder; - entropy->pub.decode_mcu = decode_mcu; - - /* Mark tables unallocated */ - for (i = 0; i < NUM_HUFF_TBLS; i++) { - entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL; - } -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jdhuff.h b/irrlicht-1.6/source/Irrlicht/jpeglib/jdhuff.h deleted file mode 100644 index 12c074770..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jdhuff.h +++ /dev/null @@ -1,201 +0,0 @@ -/* - * jdhuff.h - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains declarations for Huffman entropy decoding routines - * that are shared between the sequential decoder (jdhuff.c) and the - * progressive decoder (jdphuff.c). No other modules need to see these. - */ - -/* Short forms of external names for systems with brain-damaged linkers. */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jpeg_make_d_derived_tbl jMkDDerived -#define jpeg_fill_bit_buffer jFilBitBuf -#define jpeg_huff_decode jHufDecode -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - - -/* Derived data constructed for each Huffman table */ - -#define HUFF_LOOKAHEAD 8 /* # of bits of lookahead */ - -typedef struct { - /* Basic tables: (element [0] of each array is unused) */ - INT32 maxcode[18]; /* largest code of length k (-1 if none) */ - /* (maxcode[17] is a sentinel to ensure jpeg_huff_decode terminates) */ - INT32 valoffset[17]; /* huffval[] offset for codes of length k */ - /* valoffset[k] = huffval[] index of 1st symbol of code length k, less - * the smallest code of length k; so given a code of length k, the - * corresponding symbol is huffval[code + valoffset[k]] - */ - - /* Link to public Huffman table (needed only in jpeg_huff_decode) */ - JHUFF_TBL *pub; - - /* Lookahead tables: indexed by the next HUFF_LOOKAHEAD bits of - * the input data stream. If the next Huffman code is no more - * than HUFF_LOOKAHEAD bits long, we can obtain its length and - * the corresponding symbol directly from these tables. - */ - int look_nbits[1<<HUFF_LOOKAHEAD]; /* # bits, or 0 if too long */ - UINT8 look_sym[1<<HUFF_LOOKAHEAD]; /* symbol, or unused */ -} d_derived_tbl; - -/* Expand a Huffman table definition into the derived format */ -EXTERN(void) jpeg_make_d_derived_tbl - JPP((j_decompress_ptr cinfo, boolean isDC, int tblno, - d_derived_tbl ** pdtbl)); - - -/* - * Fetching the next N bits from the input stream is a time-critical operation - * for the Huffman decoders. We implement it with a combination of inline - * macros and out-of-line subroutines. Note that N (the number of bits - * demanded at one time) never exceeds 15 for JPEG use. - * - * We read source bytes into get_buffer and dole out bits as needed. - * If get_buffer already contains enough bits, they are fetched in-line - * by the macros CHECK_BIT_BUFFER and GET_BITS. When there aren't enough - * bits, jpeg_fill_bit_buffer is called; it will attempt to fill get_buffer - * as full as possible (not just to the number of bits needed; this - * prefetching reduces the overhead cost of calling jpeg_fill_bit_buffer). - * Note that jpeg_fill_bit_buffer may return FALSE to indicate suspension. - * On TRUE return, jpeg_fill_bit_buffer guarantees that get_buffer contains - * at least the requested number of bits --- dummy zeroes are inserted if - * necessary. - */ - -typedef INT32 bit_buf_type; /* type of bit-extraction buffer */ -#define BIT_BUF_SIZE 32 /* size of buffer in bits */ - -/* If long is > 32 bits on your machine, and shifting/masking longs is - * reasonably fast, making bit_buf_type be long and setting BIT_BUF_SIZE - * appropriately should be a win. Unfortunately we can't define the size - * with something like #define BIT_BUF_SIZE (sizeof(bit_buf_type)*8) - * because not all machines measure sizeof in 8-bit bytes. - */ - -typedef struct { /* Bitreading state saved across MCUs */ - bit_buf_type get_buffer; /* current bit-extraction buffer */ - int bits_left; /* # of unused bits in it */ -} bitread_perm_state; - -typedef struct { /* Bitreading working state within an MCU */ - /* Current data source location */ - /* We need a copy, rather than munging the original, in case of suspension */ - const JOCTET * next_input_byte; /* => next byte to read from source */ - size_t bytes_in_buffer; /* # of bytes remaining in source buffer */ - /* Bit input buffer --- note these values are kept in register variables, - * not in this struct, inside the inner loops. - */ - bit_buf_type get_buffer; /* current bit-extraction buffer */ - int bits_left; /* # of unused bits in it */ - /* Pointer needed by jpeg_fill_bit_buffer. */ - j_decompress_ptr cinfo; /* back link to decompress master record */ -} bitread_working_state; - -/* Macros to declare and load/save bitread local variables. */ -#define BITREAD_STATE_VARS \ - register bit_buf_type get_buffer; \ - register int bits_left; \ - bitread_working_state br_state - -#define BITREAD_LOAD_STATE(cinfop,permstate) \ - br_state.cinfo = cinfop; \ - br_state.next_input_byte = cinfop->src->next_input_byte; \ - br_state.bytes_in_buffer = cinfop->src->bytes_in_buffer; \ - get_buffer = permstate.get_buffer; \ - bits_left = permstate.bits_left; - -#define BITREAD_SAVE_STATE(cinfop,permstate) \ - cinfop->src->next_input_byte = br_state.next_input_byte; \ - cinfop->src->bytes_in_buffer = br_state.bytes_in_buffer; \ - permstate.get_buffer = get_buffer; \ - permstate.bits_left = bits_left - -/* - * These macros provide the in-line portion of bit fetching. - * Use CHECK_BIT_BUFFER to ensure there are N bits in get_buffer - * before using GET_BITS, PEEK_BITS, or DROP_BITS. - * The variables get_buffer and bits_left are assumed to be locals, - * but the state struct might not be (jpeg_huff_decode needs this). - * CHECK_BIT_BUFFER(state,n,action); - * Ensure there are N bits in get_buffer; if suspend, take action. - * val = GET_BITS(n); - * Fetch next N bits. - * val = PEEK_BITS(n); - * Fetch next N bits without removing them from the buffer. - * DROP_BITS(n); - * Discard next N bits. - * The value N should be a simple variable, not an expression, because it - * is evaluated multiple times. - */ - -#define CHECK_BIT_BUFFER(state,nbits,action) \ - { if (bits_left < (nbits)) { \ - if (! jpeg_fill_bit_buffer(&(state),get_buffer,bits_left,nbits)) \ - { action; } \ - get_buffer = (state).get_buffer; bits_left = (state).bits_left; } } - -#define GET_BITS(nbits) \ - (((int) (get_buffer >> (bits_left -= (nbits)))) & ((1<<(nbits))-1)) - -#define PEEK_BITS(nbits) \ - (((int) (get_buffer >> (bits_left - (nbits)))) & ((1<<(nbits))-1)) - -#define DROP_BITS(nbits) \ - (bits_left -= (nbits)) - -/* Load up the bit buffer to a depth of at least nbits */ -EXTERN(boolean) jpeg_fill_bit_buffer - JPP((bitread_working_state * state, register bit_buf_type get_buffer, - register int bits_left, int nbits)); - - -/* - * Code for extracting next Huffman-coded symbol from input bit stream. - * Again, this is time-critical and we make the main paths be macros. - * - * We use a lookahead table to process codes of up to HUFF_LOOKAHEAD bits - * without looping. Usually, more than 95% of the Huffman codes will be 8 - * or fewer bits long. The few overlength codes are handled with a loop, - * which need not be inline code. - * - * Notes about the HUFF_DECODE macro: - * 1. Near the end of the data segment, we may fail to get enough bits - * for a lookahead. In that case, we do it the hard way. - * 2. If the lookahead table contains no entry, the next code must be - * more than HUFF_LOOKAHEAD bits long. - * 3. jpeg_huff_decode returns -1 if forced to suspend. - */ - -#define HUFF_DECODE(result,state,htbl,failaction,slowlabel) \ -{ register int nb, look; \ - if (bits_left < HUFF_LOOKAHEAD) { \ - if (! jpeg_fill_bit_buffer(&state,get_buffer,bits_left, 0)) {failaction;} \ - get_buffer = state.get_buffer; bits_left = state.bits_left; \ - if (bits_left < HUFF_LOOKAHEAD) { \ - nb = 1; goto slowlabel; \ - } \ - } \ - look = PEEK_BITS(HUFF_LOOKAHEAD); \ - if ((nb = htbl->look_nbits[look]) != 0) { \ - DROP_BITS(nb); \ - result = htbl->look_sym[look]; \ - } else { \ - nb = HUFF_LOOKAHEAD+1; \ -slowlabel: \ - if ((result=jpeg_huff_decode(&state,get_buffer,bits_left,htbl,nb)) < 0) \ - { failaction; } \ - get_buffer = state.get_buffer; bits_left = state.bits_left; \ - } \ -} - -/* Out-of-line case for Huffman code fetching */ -EXTERN(int) jpeg_huff_decode - JPP((bitread_working_state * state, register bit_buf_type get_buffer, - register int bits_left, d_derived_tbl * htbl, int min_bits)); diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jdinput.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jdinput.c deleted file mode 100644 index 2d5c7470b..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jdinput.c +++ /dev/null @@ -1,381 +0,0 @@ -/* - * jdinput.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains input control logic for the JPEG decompressor. - * These routines are concerned with controlling the decompressor's input - * processing (marker reading and coefficient decoding). The actual input - * reading is done in jdmarker.c, jdhuff.c, and jdphuff.c. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Private state */ - -typedef struct { - struct jpeg_input_controller pub; /* public fields */ - - boolean inheaders; /* TRUE until first SOS is reached */ -} my_input_controller; - -typedef my_input_controller * my_inputctl_ptr; - - -/* Forward declarations */ -METHODDEF(int) consume_markers JPP((j_decompress_ptr cinfo)); - - -/* - * Routines to calculate various quantities related to the size of the image. - */ - -LOCAL(void) -initial_setup (j_decompress_ptr cinfo) -/* Called once, when first SOS marker is reached */ -{ - int ci; - jpeg_component_info *compptr; - - /* Make sure image isn't bigger than I can handle */ - if ((long) cinfo->image_height > (long) JPEG_MAX_DIMENSION || - (long) cinfo->image_width > (long) JPEG_MAX_DIMENSION) - ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION); - - /* For now, precision must match compiled-in value... */ - if (cinfo->data_precision != BITS_IN_JSAMPLE) - ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); - - /* Check that number of components won't exceed internal array sizes */ - if (cinfo->num_components > MAX_COMPONENTS) - ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, - MAX_COMPONENTS); - - /* Compute maximum sampling factors; check factor validity */ - cinfo->max_h_samp_factor = 1; - cinfo->max_v_samp_factor = 1; - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - if (compptr->h_samp_factor<=0 || compptr->h_samp_factor>MAX_SAMP_FACTOR || - compptr->v_samp_factor<=0 || compptr->v_samp_factor>MAX_SAMP_FACTOR) - ERREXIT(cinfo, JERR_BAD_SAMPLING); - cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor, - compptr->h_samp_factor); - cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor, - compptr->v_samp_factor); - } - - /* We initialize DCT_scaled_size and min_DCT_scaled_size to DCTSIZE. - * In the full decompressor, this will be overridden by jdmaster.c; - * but in the transcoder, jdmaster.c is not used, so we must do it here. - */ - cinfo->min_DCT_scaled_size = DCTSIZE; - - /* Compute dimensions of components */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - compptr->DCT_scaled_size = DCTSIZE; - /* Size in DCT blocks */ - compptr->width_in_blocks = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, - (long) (cinfo->max_h_samp_factor * DCTSIZE)); - compptr->height_in_blocks = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, - (long) (cinfo->max_v_samp_factor * DCTSIZE)); - /* downsampled_width and downsampled_height will also be overridden by - * jdmaster.c if we are doing full decompression. The transcoder library - * doesn't use these values, but the calling application might. - */ - /* Size in samples */ - compptr->downsampled_width = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, - (long) cinfo->max_h_samp_factor); - compptr->downsampled_height = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, - (long) cinfo->max_v_samp_factor); - /* Mark component needed, until color conversion says otherwise */ - compptr->component_needed = TRUE; - /* Mark no quantization table yet saved for component */ - compptr->quant_table = NULL; - } - - /* Compute number of fully interleaved MCU rows. */ - cinfo->total_iMCU_rows = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height, - (long) (cinfo->max_v_samp_factor*DCTSIZE)); - - /* Decide whether file contains multiple scans */ - if (cinfo->comps_in_scan < cinfo->num_components || cinfo->progressive_mode) - cinfo->inputctl->has_multiple_scans = TRUE; - else - cinfo->inputctl->has_multiple_scans = FALSE; -} - - -LOCAL(void) -per_scan_setup (j_decompress_ptr cinfo) -/* Do computations that are needed before processing a JPEG scan */ -/* cinfo->comps_in_scan and cinfo->cur_comp_info[] were set from SOS marker */ -{ - int ci, mcublks, tmp; - jpeg_component_info *compptr; - - if (cinfo->comps_in_scan == 1) { - - /* Noninterleaved (single-component) scan */ - compptr = cinfo->cur_comp_info[0]; - - /* Overall image size in MCUs */ - cinfo->MCUs_per_row = compptr->width_in_blocks; - cinfo->MCU_rows_in_scan = compptr->height_in_blocks; - - /* For noninterleaved scan, always one block per MCU */ - compptr->MCU_width = 1; - compptr->MCU_height = 1; - compptr->MCU_blocks = 1; - compptr->MCU_sample_width = compptr->DCT_scaled_size; - compptr->last_col_width = 1; - /* For noninterleaved scans, it is convenient to define last_row_height - * as the number of block rows present in the last iMCU row. - */ - tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor); - if (tmp == 0) tmp = compptr->v_samp_factor; - compptr->last_row_height = tmp; - - /* Prepare array describing MCU composition */ - cinfo->blocks_in_MCU = 1; - cinfo->MCU_membership[0] = 0; - - } else { - - /* Interleaved (multi-component) scan */ - if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN) - ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan, - MAX_COMPS_IN_SCAN); - - /* Overall image size in MCUs */ - cinfo->MCUs_per_row = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width, - (long) (cinfo->max_h_samp_factor*DCTSIZE)); - cinfo->MCU_rows_in_scan = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height, - (long) (cinfo->max_v_samp_factor*DCTSIZE)); - - cinfo->blocks_in_MCU = 0; - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - /* Sampling factors give # of blocks of component in each MCU */ - compptr->MCU_width = compptr->h_samp_factor; - compptr->MCU_height = compptr->v_samp_factor; - compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height; - compptr->MCU_sample_width = compptr->MCU_width * compptr->DCT_scaled_size; - /* Figure number of non-dummy blocks in last MCU column & row */ - tmp = (int) (compptr->width_in_blocks % compptr->MCU_width); - if (tmp == 0) tmp = compptr->MCU_width; - compptr->last_col_width = tmp; - tmp = (int) (compptr->height_in_blocks % compptr->MCU_height); - if (tmp == 0) tmp = compptr->MCU_height; - compptr->last_row_height = tmp; - /* Prepare array describing MCU composition */ - mcublks = compptr->MCU_blocks; - if (cinfo->blocks_in_MCU + mcublks > D_MAX_BLOCKS_IN_MCU) - ERREXIT(cinfo, JERR_BAD_MCU_SIZE); - while (mcublks-- > 0) { - cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci; - } - } - - } -} - - -/* - * Save away a copy of the Q-table referenced by each component present - * in the current scan, unless already saved during a prior scan. - * - * In a multiple-scan JPEG file, the encoder could assign different components - * the same Q-table slot number, but change table definitions between scans - * so that each component uses a different Q-table. (The IJG encoder is not - * currently capable of doing this, but other encoders might.) Since we want - * to be able to dequantize all the components at the end of the file, this - * means that we have to save away the table actually used for each component. - * We do this by copying the table at the start of the first scan containing - * the component. - * The JPEG spec prohibits the encoder from changing the contents of a Q-table - * slot between scans of a component using that slot. If the encoder does so - * anyway, this decoder will simply use the Q-table values that were current - * at the start of the first scan for the component. - * - * The decompressor output side looks only at the saved quant tables, - * not at the current Q-table slots. - */ - -LOCAL(void) -latch_quant_tables (j_decompress_ptr cinfo) -{ - int ci, qtblno; - jpeg_component_info *compptr; - JQUANT_TBL * qtbl; - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - /* No work if we already saved Q-table for this component */ - if (compptr->quant_table != NULL) - continue; - /* Make sure specified quantization table is present */ - qtblno = compptr->quant_tbl_no; - if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS || - cinfo->quant_tbl_ptrs[qtblno] == NULL) - ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno); - /* OK, save away the quantization table */ - qtbl = (JQUANT_TBL *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(JQUANT_TBL)); - MEMCOPY(qtbl, cinfo->quant_tbl_ptrs[qtblno], SIZEOF(JQUANT_TBL)); - compptr->quant_table = qtbl; - } -} - - -/* - * Initialize the input modules to read a scan of compressed data. - * The first call to this is done by jdmaster.c after initializing - * the entire decompressor (during jpeg_start_decompress). - * Subsequent calls come from consume_markers, below. - */ - -METHODDEF(void) -start_input_pass (j_decompress_ptr cinfo) -{ - per_scan_setup(cinfo); - latch_quant_tables(cinfo); - (*cinfo->entropy->start_pass) (cinfo); - (*cinfo->coef->start_input_pass) (cinfo); - cinfo->inputctl->consume_input = cinfo->coef->consume_data; -} - - -/* - * Finish up after inputting a compressed-data scan. - * This is called by the coefficient controller after it's read all - * the expected data of the scan. - */ - -METHODDEF(void) -finish_input_pass (j_decompress_ptr cinfo) -{ - cinfo->inputctl->consume_input = consume_markers; -} - - -/* - * Read JPEG markers before, between, or after compressed-data scans. - * Change state as necessary when a new scan is reached. - * Return value is JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI. - * - * The consume_input method pointer points either here or to the - * coefficient controller's consume_data routine, depending on whether - * we are reading a compressed data segment or inter-segment markers. - */ - -METHODDEF(int) -consume_markers (j_decompress_ptr cinfo) -{ - my_inputctl_ptr inputctl = (my_inputctl_ptr) cinfo->inputctl; - int val; - - if (inputctl->pub.eoi_reached) /* After hitting EOI, read no further */ - return JPEG_REACHED_EOI; - - val = (*cinfo->marker->read_markers) (cinfo); - - switch (val) { - case JPEG_REACHED_SOS: /* Found SOS */ - if (inputctl->inheaders) { /* 1st SOS */ - initial_setup(cinfo); - inputctl->inheaders = FALSE; - /* Note: start_input_pass must be called by jdmaster.c - * before any more input can be consumed. jdapimin.c is - * responsible for enforcing this sequencing. - */ - } else { /* 2nd or later SOS marker */ - if (! inputctl->pub.has_multiple_scans) - ERREXIT(cinfo, JERR_EOI_EXPECTED); /* Oops, I wasn't expecting this! */ - start_input_pass(cinfo); - } - break; - case JPEG_REACHED_EOI: /* Found EOI */ - inputctl->pub.eoi_reached = TRUE; - if (inputctl->inheaders) { /* Tables-only datastream, apparently */ - if (cinfo->marker->saw_SOF) - ERREXIT(cinfo, JERR_SOF_NO_SOS); - } else { - /* Prevent infinite loop in coef ctlr's decompress_data routine - * if user set output_scan_number larger than number of scans. - */ - if (cinfo->output_scan_number > cinfo->input_scan_number) - cinfo->output_scan_number = cinfo->input_scan_number; - } - break; - case JPEG_SUSPENDED: - break; - } - - return val; -} - - -/* - * Reset state to begin a fresh datastream. - */ - -METHODDEF(void) -reset_input_controller (j_decompress_ptr cinfo) -{ - my_inputctl_ptr inputctl = (my_inputctl_ptr) cinfo->inputctl; - - inputctl->pub.consume_input = consume_markers; - inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */ - inputctl->pub.eoi_reached = FALSE; - inputctl->inheaders = TRUE; - /* Reset other modules */ - (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); - (*cinfo->marker->reset_marker_reader) (cinfo); - /* Reset progression state -- would be cleaner if entropy decoder did this */ - cinfo->coef_bits = NULL; -} - - -/* - * Initialize the input controller module. - * This is called only once, when the decompression object is created. - */ - -GLOBAL(void) -jinit_input_controller (j_decompress_ptr cinfo) -{ - my_inputctl_ptr inputctl; - - /* Create subobject in permanent pool */ - inputctl = (my_inputctl_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - SIZEOF(my_input_controller)); - cinfo->inputctl = (struct jpeg_input_controller *) inputctl; - /* Initialize method pointers */ - inputctl->pub.consume_input = consume_markers; - inputctl->pub.reset_input_controller = reset_input_controller; - inputctl->pub.start_input_pass = start_input_pass; - inputctl->pub.finish_input_pass = finish_input_pass; - /* Initialize state: can't use reset_input_controller since we don't - * want to try to reset other modules yet. - */ - inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */ - inputctl->pub.eoi_reached = FALSE; - inputctl->inheaders = TRUE; -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jdmainct.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jdmainct.c deleted file mode 100644 index 6b0f06f5f..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jdmainct.c +++ /dev/null @@ -1,512 +0,0 @@ -/* - * jdmainct.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the main buffer controller for decompression. - * The main buffer lies between the JPEG decompressor proper and the - * post-processor; it holds downsampled data in the JPEG colorspace. - * - * Note that this code is bypassed in raw-data mode, since the application - * supplies the equivalent of the main buffer in that case. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * In the current system design, the main buffer need never be a full-image - * buffer; any full-height buffers will be found inside the coefficient or - * postprocessing controllers. Nonetheless, the main controller is not - * trivial. Its responsibility is to provide context rows for upsampling/ - * rescaling, and doing this in an efficient fashion is a bit tricky. - * - * Postprocessor input data is counted in "row groups". A row group - * is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size) - * sample rows of each component. (We require DCT_scaled_size values to be - * chosen such that these numbers are integers. In practice DCT_scaled_size - * values will likely be powers of two, so we actually have the stronger - * condition that DCT_scaled_size / min_DCT_scaled_size is an integer.) - * Upsampling will typically produce max_v_samp_factor pixel rows from each - * row group (times any additional scale factor that the upsampler is - * applying). - * - * The coefficient controller will deliver data to us one iMCU row at a time; - * each iMCU row contains v_samp_factor * DCT_scaled_size sample rows, or - * exactly min_DCT_scaled_size row groups. (This amount of data corresponds - * to one row of MCUs when the image is fully interleaved.) Note that the - * number of sample rows varies across components, but the number of row - * groups does not. Some garbage sample rows may be included in the last iMCU - * row at the bottom of the image. - * - * Depending on the vertical scaling algorithm used, the upsampler may need - * access to the sample row(s) above and below its current input row group. - * The upsampler is required to set need_context_rows TRUE at global selection - * time if so. When need_context_rows is FALSE, this controller can simply - * obtain one iMCU row at a time from the coefficient controller and dole it - * out as row groups to the postprocessor. - * - * When need_context_rows is TRUE, this controller guarantees that the buffer - * passed to postprocessing contains at least one row group's worth of samples - * above and below the row group(s) being processed. Note that the context - * rows "above" the first passed row group appear at negative row offsets in - * the passed buffer. At the top and bottom of the image, the required - * context rows are manufactured by duplicating the first or last real sample - * row; this avoids having special cases in the upsampling inner loops. - * - * The amount of context is fixed at one row group just because that's a - * convenient number for this controller to work with. The existing - * upsamplers really only need one sample row of context. An upsampler - * supporting arbitrary output rescaling might wish for more than one row - * group of context when shrinking the image; tough, we don't handle that. - * (This is justified by the assumption that downsizing will be handled mostly - * by adjusting the DCT_scaled_size values, so that the actual scale factor at - * the upsample step needn't be much less than one.) - * - * To provide the desired context, we have to retain the last two row groups - * of one iMCU row while reading in the next iMCU row. (The last row group - * can't be processed until we have another row group for its below-context, - * and so we have to save the next-to-last group too for its above-context.) - * We could do this most simply by copying data around in our buffer, but - * that'd be very slow. We can avoid copying any data by creating a rather - * strange pointer structure. Here's how it works. We allocate a workspace - * consisting of M+2 row groups (where M = min_DCT_scaled_size is the number - * of row groups per iMCU row). We create two sets of redundant pointers to - * the workspace. Labeling the physical row groups 0 to M+1, the synthesized - * pointer lists look like this: - * M+1 M-1 - * master pointer --> 0 master pointer --> 0 - * 1 1 - * ... ... - * M-3 M-3 - * M-2 M - * M-1 M+1 - * M M-2 - * M+1 M-1 - * 0 0 - * We read alternate iMCU rows using each master pointer; thus the last two - * row groups of the previous iMCU row remain un-overwritten in the workspace. - * The pointer lists are set up so that the required context rows appear to - * be adjacent to the proper places when we pass the pointer lists to the - * upsampler. - * - * The above pictures describe the normal state of the pointer lists. - * At top and bottom of the image, we diddle the pointer lists to duplicate - * the first or last sample row as necessary (this is cheaper than copying - * sample rows around). - * - * This scheme breaks down if M < 2, ie, min_DCT_scaled_size is 1. In that - * situation each iMCU row provides only one row group so the buffering logic - * must be different (eg, we must read two iMCU rows before we can emit the - * first row group). For now, we simply do not support providing context - * rows when min_DCT_scaled_size is 1. That combination seems unlikely to - * be worth providing --- if someone wants a 1/8th-size preview, they probably - * want it quick and dirty, so a context-free upsampler is sufficient. - */ - - -/* Private buffer controller object */ - -typedef struct { - struct jpeg_d_main_controller pub; /* public fields */ - - /* Pointer to allocated workspace (M or M+2 row groups). */ - JSAMPARRAY buffer[MAX_COMPONENTS]; - - boolean buffer_full; /* Have we gotten an iMCU row from decoder? */ - JDIMENSION rowgroup_ctr; /* counts row groups output to postprocessor */ - - /* Remaining fields are only used in the context case. */ - - /* These are the master pointers to the funny-order pointer lists. */ - JSAMPIMAGE xbuffer[2]; /* pointers to weird pointer lists */ - - int whichptr; /* indicates which pointer set is now in use */ - int context_state; /* process_data state machine status */ - JDIMENSION rowgroups_avail; /* row groups available to postprocessor */ - JDIMENSION iMCU_row_ctr; /* counts iMCU rows to detect image top/bot */ -} my_main_controller; - -typedef my_main_controller * my_main_ptr; - -/* context_state values: */ -#define CTX_PREPARE_FOR_IMCU 0 /* need to prepare for MCU row */ -#define CTX_PROCESS_IMCU 1 /* feeding iMCU to postprocessor */ -#define CTX_POSTPONED_ROW 2 /* feeding postponed row group */ - - -/* Forward declarations */ -METHODDEF(void) process_data_simple_main - JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf, - JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)); -METHODDEF(void) process_data_context_main - JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf, - JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)); -#ifdef QUANT_2PASS_SUPPORTED -METHODDEF(void) process_data_crank_post - JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf, - JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)); -#endif - - -LOCAL(void) -alloc_funny_pointers (j_decompress_ptr cinfo) -/* Allocate space for the funny pointer lists. - * This is done only once, not once per pass. - */ -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - int ci, rgroup; - int M = cinfo->min_DCT_scaled_size; - jpeg_component_info *compptr; - JSAMPARRAY xbuf; - - /* Get top-level space for component array pointers. - * We alloc both arrays with one call to save a few cycles. - */ - main->xbuffer[0] = (JSAMPIMAGE) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - cinfo->num_components * 2 * SIZEOF(JSAMPARRAY)); - main->xbuffer[1] = main->xbuffer[0] + cinfo->num_components; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / - cinfo->min_DCT_scaled_size; /* height of a row group of component */ - /* Get space for pointer lists --- M+4 row groups in each list. - * We alloc both pointer lists with one call to save a few cycles. - */ - xbuf = (JSAMPARRAY) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - 2 * (rgroup * (M + 4)) * SIZEOF(JSAMPROW)); - xbuf += rgroup; /* want one row group at negative offsets */ - main->xbuffer[0][ci] = xbuf; - xbuf += rgroup * (M + 4); - main->xbuffer[1][ci] = xbuf; - } -} - - -LOCAL(void) -make_funny_pointers (j_decompress_ptr cinfo) -/* Create the funny pointer lists discussed in the comments above. - * The actual workspace is already allocated (in main->buffer), - * and the space for the pointer lists is allocated too. - * This routine just fills in the curiously ordered lists. - * This will be repeated at the beginning of each pass. - */ -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - int ci, i, rgroup; - int M = cinfo->min_DCT_scaled_size; - jpeg_component_info *compptr; - JSAMPARRAY buf, xbuf0, xbuf1; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / - cinfo->min_DCT_scaled_size; /* height of a row group of component */ - xbuf0 = main->xbuffer[0][ci]; - xbuf1 = main->xbuffer[1][ci]; - /* First copy the workspace pointers as-is */ - buf = main->buffer[ci]; - for (i = 0; i < rgroup * (M + 2); i++) { - xbuf0[i] = xbuf1[i] = buf[i]; - } - /* In the second list, put the last four row groups in swapped order */ - for (i = 0; i < rgroup * 2; i++) { - xbuf1[rgroup*(M-2) + i] = buf[rgroup*M + i]; - xbuf1[rgroup*M + i] = buf[rgroup*(M-2) + i]; - } - /* The wraparound pointers at top and bottom will be filled later - * (see set_wraparound_pointers, below). Initially we want the "above" - * pointers to duplicate the first actual data line. This only needs - * to happen in xbuffer[0]. - */ - for (i = 0; i < rgroup; i++) { - xbuf0[i - rgroup] = xbuf0[0]; - } - } -} - - -LOCAL(void) -set_wraparound_pointers (j_decompress_ptr cinfo) -/* Set up the "wraparound" pointers at top and bottom of the pointer lists. - * This changes the pointer list state from top-of-image to the normal state. - */ -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - int ci, i, rgroup; - int M = cinfo->min_DCT_scaled_size; - jpeg_component_info *compptr; - JSAMPARRAY xbuf0, xbuf1; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / - cinfo->min_DCT_scaled_size; /* height of a row group of component */ - xbuf0 = main->xbuffer[0][ci]; - xbuf1 = main->xbuffer[1][ci]; - for (i = 0; i < rgroup; i++) { - xbuf0[i - rgroup] = xbuf0[rgroup*(M+1) + i]; - xbuf1[i - rgroup] = xbuf1[rgroup*(M+1) + i]; - xbuf0[rgroup*(M+2) + i] = xbuf0[i]; - xbuf1[rgroup*(M+2) + i] = xbuf1[i]; - } - } -} - - -LOCAL(void) -set_bottom_pointers (j_decompress_ptr cinfo) -/* Change the pointer lists to duplicate the last sample row at the bottom - * of the image. whichptr indicates which xbuffer holds the final iMCU row. - * Also sets rowgroups_avail to indicate number of nondummy row groups in row. - */ -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - int ci, i, rgroup, iMCUheight, rows_left; - jpeg_component_info *compptr; - JSAMPARRAY xbuf; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Count sample rows in one iMCU row and in one row group */ - iMCUheight = compptr->v_samp_factor * compptr->DCT_scaled_size; - rgroup = iMCUheight / cinfo->min_DCT_scaled_size; - /* Count nondummy sample rows remaining for this component */ - rows_left = (int) (compptr->downsampled_height % (JDIMENSION) iMCUheight); - if (rows_left == 0) rows_left = iMCUheight; - /* Count nondummy row groups. Should get same answer for each component, - * so we need only do it once. - */ - if (ci == 0) { - main->rowgroups_avail = (JDIMENSION) ((rows_left-1) / rgroup + 1); - } - /* Duplicate the last real sample row rgroup*2 times; this pads out the - * last partial rowgroup and ensures at least one full rowgroup of context. - */ - xbuf = main->xbuffer[main->whichptr][ci]; - for (i = 0; i < rgroup * 2; i++) { - xbuf[rows_left + i] = xbuf[rows_left-1]; - } - } -} - - -/* - * Initialize for a processing pass. - */ - -METHODDEF(void) -start_pass_main (j_decompress_ptr cinfo, J_BUF_MODE pass_mode) -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - - switch (pass_mode) { - case JBUF_PASS_THRU: - if (cinfo->upsample->need_context_rows) { - main->pub.process_data = process_data_context_main; - make_funny_pointers(cinfo); /* Create the xbuffer[] lists */ - main->whichptr = 0; /* Read first iMCU row into xbuffer[0] */ - main->context_state = CTX_PREPARE_FOR_IMCU; - main->iMCU_row_ctr = 0; - } else { - /* Simple case with no context needed */ - main->pub.process_data = process_data_simple_main; - } - main->buffer_full = FALSE; /* Mark buffer empty */ - main->rowgroup_ctr = 0; - break; -#ifdef QUANT_2PASS_SUPPORTED - case JBUF_CRANK_DEST: - /* For last pass of 2-pass quantization, just crank the postprocessor */ - main->pub.process_data = process_data_crank_post; - break; -#endif - default: - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - break; - } -} - - -/* - * Process some data. - * This handles the simple case where no context is required. - */ - -METHODDEF(void) -process_data_simple_main (j_decompress_ptr cinfo, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - JDIMENSION rowgroups_avail; - - /* Read input data if we haven't filled the main buffer yet */ - if (! main->buffer_full) { - if (! (*cinfo->coef->decompress_data) (cinfo, main->buffer)) - return; /* suspension forced, can do nothing more */ - main->buffer_full = TRUE; /* OK, we have an iMCU row to work with */ - } - - /* There are always min_DCT_scaled_size row groups in an iMCU row. */ - rowgroups_avail = (JDIMENSION) cinfo->min_DCT_scaled_size; - /* Note: at the bottom of the image, we may pass extra garbage row groups - * to the postprocessor. The postprocessor has to check for bottom - * of image anyway (at row resolution), so no point in us doing it too. - */ - - /* Feed the postprocessor */ - (*cinfo->post->post_process_data) (cinfo, main->buffer, - &main->rowgroup_ctr, rowgroups_avail, - output_buf, out_row_ctr, out_rows_avail); - - /* Has postprocessor consumed all the data yet? If so, mark buffer empty */ - if (main->rowgroup_ctr >= rowgroups_avail) { - main->buffer_full = FALSE; - main->rowgroup_ctr = 0; - } -} - - -/* - * Process some data. - * This handles the case where context rows must be provided. - */ - -METHODDEF(void) -process_data_context_main (j_decompress_ptr cinfo, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - - /* Read input data if we haven't filled the main buffer yet */ - if (! main->buffer_full) { - if (! (*cinfo->coef->decompress_data) (cinfo, - main->xbuffer[main->whichptr])) - return; /* suspension forced, can do nothing more */ - main->buffer_full = TRUE; /* OK, we have an iMCU row to work with */ - main->iMCU_row_ctr++; /* count rows received */ - } - - /* Postprocessor typically will not swallow all the input data it is handed - * in one call (due to filling the output buffer first). Must be prepared - * to exit and restart. This switch lets us keep track of how far we got. - * Note that each case falls through to the next on successful completion. - */ - switch (main->context_state) { - case CTX_POSTPONED_ROW: - /* Call postprocessor using previously set pointers for postponed row */ - (*cinfo->post->post_process_data) (cinfo, main->xbuffer[main->whichptr], - &main->rowgroup_ctr, main->rowgroups_avail, - output_buf, out_row_ctr, out_rows_avail); - if (main->rowgroup_ctr < main->rowgroups_avail) - return; /* Need to suspend */ - main->context_state = CTX_PREPARE_FOR_IMCU; - if (*out_row_ctr >= out_rows_avail) - return; /* Postprocessor exactly filled output buf */ - /*FALLTHROUGH*/ - case CTX_PREPARE_FOR_IMCU: - /* Prepare to process first M-1 row groups of this iMCU row */ - main->rowgroup_ctr = 0; - main->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size - 1); - /* Check for bottom of image: if so, tweak pointers to "duplicate" - * the last sample row, and adjust rowgroups_avail to ignore padding rows. - */ - if (main->iMCU_row_ctr == cinfo->total_iMCU_rows) - set_bottom_pointers(cinfo); - main->context_state = CTX_PROCESS_IMCU; - /*FALLTHROUGH*/ - case CTX_PROCESS_IMCU: - /* Call postprocessor using previously set pointers */ - (*cinfo->post->post_process_data) (cinfo, main->xbuffer[main->whichptr], - &main->rowgroup_ctr, main->rowgroups_avail, - output_buf, out_row_ctr, out_rows_avail); - if (main->rowgroup_ctr < main->rowgroups_avail) - return; /* Need to suspend */ - /* After the first iMCU, change wraparound pointers to normal state */ - if (main->iMCU_row_ctr == 1) - set_wraparound_pointers(cinfo); - /* Prepare to load new iMCU row using other xbuffer list */ - main->whichptr ^= 1; /* 0=>1 or 1=>0 */ - main->buffer_full = FALSE; - /* Still need to process last row group of this iMCU row, */ - /* which is saved at index M+1 of the other xbuffer */ - main->rowgroup_ctr = (JDIMENSION) (cinfo->min_DCT_scaled_size + 1); - main->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size + 2); - main->context_state = CTX_POSTPONED_ROW; - } -} - - -/* - * Process some data. - * Final pass of two-pass quantization: just call the postprocessor. - * Source data will be the postprocessor controller's internal buffer. - */ - -#ifdef QUANT_2PASS_SUPPORTED - -METHODDEF(void) -process_data_crank_post (j_decompress_ptr cinfo, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -{ - (*cinfo->post->post_process_data) (cinfo, (JSAMPIMAGE) NULL, - (JDIMENSION *) NULL, (JDIMENSION) 0, - output_buf, out_row_ctr, out_rows_avail); -} - -#endif /* QUANT_2PASS_SUPPORTED */ - - -/* - * Initialize main buffer controller. - */ - -GLOBAL(void) -jinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer) -{ - my_main_ptr main; - int ci, rgroup, ngroups; - jpeg_component_info *compptr; - - main = (my_main_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_main_controller)); - cinfo->main = (struct jpeg_d_main_controller *) main; - main->pub.start_pass = start_pass_main; - - if (need_full_buffer) /* shouldn't happen */ - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - - /* Allocate the workspace. - * ngroups is the number of row groups we need. - */ - if (cinfo->upsample->need_context_rows) { - if (cinfo->min_DCT_scaled_size < 2) /* unsupported, see comments above */ - ERREXIT(cinfo, JERR_NOTIMPL); - alloc_funny_pointers(cinfo); /* Alloc space for xbuffer[] lists */ - ngroups = cinfo->min_DCT_scaled_size + 2; - } else { - ngroups = cinfo->min_DCT_scaled_size; - } - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / - cinfo->min_DCT_scaled_size; /* height of a row group of component */ - main->buffer[ci] = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - compptr->width_in_blocks * compptr->DCT_scaled_size, - (JDIMENSION) (rgroup * ngroups)); - } -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jdmarker.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jdmarker.c deleted file mode 100644 index 9811761d3..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jdmarker.c +++ /dev/null @@ -1,1360 +0,0 @@ -/* - * jdmarker.c - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to decode JPEG datastream markers. - * Most of the complexity arises from our desire to support input - * suspension: if not all of the data for a marker is available, - * we must exit back to the application. On resumption, we reprocess - * the marker. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -typedef enum { /* JPEG marker codes */ - M_SOF0 = 0xc0, - M_SOF1 = 0xc1, - M_SOF2 = 0xc2, - M_SOF3 = 0xc3, - - M_SOF5 = 0xc5, - M_SOF6 = 0xc6, - M_SOF7 = 0xc7, - - M_JPG = 0xc8, - M_SOF9 = 0xc9, - M_SOF10 = 0xca, - M_SOF11 = 0xcb, - - M_SOF13 = 0xcd, - M_SOF14 = 0xce, - M_SOF15 = 0xcf, - - M_DHT = 0xc4, - - M_DAC = 0xcc, - - M_RST0 = 0xd0, - M_RST1 = 0xd1, - M_RST2 = 0xd2, - M_RST3 = 0xd3, - M_RST4 = 0xd4, - M_RST5 = 0xd5, - M_RST6 = 0xd6, - M_RST7 = 0xd7, - - M_SOI = 0xd8, - M_EOI = 0xd9, - M_SOS = 0xda, - M_DQT = 0xdb, - M_DNL = 0xdc, - M_DRI = 0xdd, - M_DHP = 0xde, - M_EXP = 0xdf, - - M_APP0 = 0xe0, - M_APP1 = 0xe1, - M_APP2 = 0xe2, - M_APP3 = 0xe3, - M_APP4 = 0xe4, - M_APP5 = 0xe5, - M_APP6 = 0xe6, - M_APP7 = 0xe7, - M_APP8 = 0xe8, - M_APP9 = 0xe9, - M_APP10 = 0xea, - M_APP11 = 0xeb, - M_APP12 = 0xec, - M_APP13 = 0xed, - M_APP14 = 0xee, - M_APP15 = 0xef, - - M_JPG0 = 0xf0, - M_JPG13 = 0xfd, - M_COM = 0xfe, - - M_TEM = 0x01, - - M_ERROR = 0x100 -} JPEG_MARKER; - - -/* Private state */ - -typedef struct { - struct jpeg_marker_reader pub; /* public fields */ - - /* Application-overridable marker processing methods */ - jpeg_marker_parser_method process_COM; - jpeg_marker_parser_method process_APPn[16]; - - /* Limit on marker data length to save for each marker type */ - unsigned int length_limit_COM; - unsigned int length_limit_APPn[16]; - - /* Status of COM/APPn marker saving */ - jpeg_saved_marker_ptr cur_marker; /* NULL if not processing a marker */ - unsigned int bytes_read; /* data bytes read so far in marker */ - /* Note: cur_marker is not linked into marker_list until it's all read. */ -} my_marker_reader; - -typedef my_marker_reader * my_marker_ptr; - - -/* - * Macros for fetching data from the data source module. - * - * At all times, cinfo->src->next_input_byte and ->bytes_in_buffer reflect - * the current restart point; we update them only when we have reached a - * suitable place to restart if a suspension occurs. - */ - -/* Declare and initialize local copies of input pointer/count */ -#define INPUT_VARS(cinfo) \ - struct jpeg_source_mgr * datasrc = (cinfo)->src; \ - const JOCTET * next_input_byte = datasrc->next_input_byte; \ - size_t bytes_in_buffer = datasrc->bytes_in_buffer - -/* Unload the local copies --- do this only at a restart boundary */ -#define INPUT_SYNC(cinfo) \ - ( datasrc->next_input_byte = next_input_byte, \ - datasrc->bytes_in_buffer = bytes_in_buffer ) - -/* Reload the local copies --- used only in MAKE_BYTE_AVAIL */ -#define INPUT_RELOAD(cinfo) \ - ( next_input_byte = datasrc->next_input_byte, \ - bytes_in_buffer = datasrc->bytes_in_buffer ) - -/* Internal macro for INPUT_BYTE and INPUT_2BYTES: make a byte available. - * Note we do *not* do INPUT_SYNC before calling fill_input_buffer, - * but we must reload the local copies after a successful fill. - */ -#define MAKE_BYTE_AVAIL(cinfo,action) \ - if (bytes_in_buffer == 0) { \ - if (! (*datasrc->fill_input_buffer) (cinfo)) \ - { action; } \ - INPUT_RELOAD(cinfo); \ - } - -/* Read a byte into variable V. - * If must suspend, take the specified action (typically "return FALSE"). - */ -#define INPUT_BYTE(cinfo,V,action) \ - MAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \ - bytes_in_buffer--; \ - V = GETJOCTET(*next_input_byte++); ) - -/* As above, but read two bytes interpreted as an unsigned 16-bit integer. - * V should be declared unsigned int or perhaps INT32. - */ -#define INPUT_2BYTES(cinfo,V,action) \ - MAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \ - bytes_in_buffer--; \ - V = ((unsigned int) GETJOCTET(*next_input_byte++)) << 8; \ - MAKE_BYTE_AVAIL(cinfo,action); \ - bytes_in_buffer--; \ - V += GETJOCTET(*next_input_byte++); ) - - -/* - * Routines to process JPEG markers. - * - * Entry condition: JPEG marker itself has been read and its code saved - * in cinfo->unread_marker; input restart point is just after the marker. - * - * Exit: if return TRUE, have read and processed any parameters, and have - * updated the restart point to point after the parameters. - * If return FALSE, was forced to suspend before reaching end of - * marker parameters; restart point has not been moved. Same routine - * will be called again after application supplies more input data. - * - * This approach to suspension assumes that all of a marker's parameters - * can fit into a single input bufferload. This should hold for "normal" - * markers. Some COM/APPn markers might have large parameter segments - * that might not fit. If we are simply dropping such a marker, we use - * skip_input_data to get past it, and thereby put the problem on the - * source manager's shoulders. If we are saving the marker's contents - * into memory, we use a slightly different convention: when forced to - * suspend, the marker processor updates the restart point to the end of - * what it's consumed (ie, the end of the buffer) before returning FALSE. - * On resumption, cinfo->unread_marker still contains the marker code, - * but the data source will point to the next chunk of marker data. - * The marker processor must retain internal state to deal with this. - * - * Note that we don't bother to avoid duplicate trace messages if a - * suspension occurs within marker parameters. Other side effects - * require more care. - */ - - -LOCAL(boolean) -get_soi (j_decompress_ptr cinfo) -/* Process an SOI marker */ -{ - int i; - - TRACEMS(cinfo, 1, JTRC_SOI); - - if (cinfo->marker->saw_SOI) - ERREXIT(cinfo, JERR_SOI_DUPLICATE); - - /* Reset all parameters that are defined to be reset by SOI */ - - for (i = 0; i < NUM_ARITH_TBLS; i++) { - cinfo->arith_dc_L[i] = 0; - cinfo->arith_dc_U[i] = 1; - cinfo->arith_ac_K[i] = 5; - } - cinfo->restart_interval = 0; - - /* Set initial assumptions for colorspace etc */ - - cinfo->jpeg_color_space = JCS_UNKNOWN; - cinfo->CCIR601_sampling = FALSE; /* Assume non-CCIR sampling??? */ - - cinfo->saw_JFIF_marker = FALSE; - cinfo->JFIF_major_version = 1; /* set default JFIF APP0 values */ - cinfo->JFIF_minor_version = 1; - cinfo->density_unit = 0; - cinfo->X_density = 1; - cinfo->Y_density = 1; - cinfo->saw_Adobe_marker = FALSE; - cinfo->Adobe_transform = 0; - - cinfo->marker->saw_SOI = TRUE; - - return TRUE; -} - - -LOCAL(boolean) -get_sof (j_decompress_ptr cinfo, boolean is_prog, boolean is_arith) -/* Process a SOFn marker */ -{ - INT32 length; - int c, ci; - jpeg_component_info * compptr; - INPUT_VARS(cinfo); - - cinfo->progressive_mode = is_prog; - cinfo->arith_code = is_arith; - - INPUT_2BYTES(cinfo, length, return FALSE); - - INPUT_BYTE(cinfo, cinfo->data_precision, return FALSE); - INPUT_2BYTES(cinfo, cinfo->image_height, return FALSE); - INPUT_2BYTES(cinfo, cinfo->image_width, return FALSE); - INPUT_BYTE(cinfo, cinfo->num_components, return FALSE); - - length -= 8; - - TRACEMS4(cinfo, 1, JTRC_SOF, cinfo->unread_marker, - (int) cinfo->image_width, (int) cinfo->image_height, - cinfo->num_components); - - if (cinfo->marker->saw_SOF) - ERREXIT(cinfo, JERR_SOF_DUPLICATE); - - /* We don't support files in which the image height is initially specified */ - /* as 0 and is later redefined by DNL. As long as we have to check that, */ - /* might as well have a general sanity check. */ - if (cinfo->image_height <= 0 || cinfo->image_width <= 0 - || cinfo->num_components <= 0) - ERREXIT(cinfo, JERR_EMPTY_IMAGE); - - if (length != (cinfo->num_components * 3)) - ERREXIT(cinfo, JERR_BAD_LENGTH); - - if (cinfo->comp_info == NULL) /* do only once, even if suspend */ - cinfo->comp_info = (jpeg_component_info *) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - cinfo->num_components * SIZEOF(jpeg_component_info)); - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - compptr->component_index = ci; - INPUT_BYTE(cinfo, compptr->component_id, return FALSE); - INPUT_BYTE(cinfo, c, return FALSE); - compptr->h_samp_factor = (c >> 4) & 15; - compptr->v_samp_factor = (c ) & 15; - INPUT_BYTE(cinfo, compptr->quant_tbl_no, return FALSE); - - TRACEMS4(cinfo, 1, JTRC_SOF_COMPONENT, - compptr->component_id, compptr->h_samp_factor, - compptr->v_samp_factor, compptr->quant_tbl_no); - } - - cinfo->marker->saw_SOF = TRUE; - - INPUT_SYNC(cinfo); - return TRUE; -} - - -LOCAL(boolean) -get_sos (j_decompress_ptr cinfo) -/* Process a SOS marker */ -{ - INT32 length; - int i, ci, n, c, cc; - jpeg_component_info * compptr; - INPUT_VARS(cinfo); - - if (! cinfo->marker->saw_SOF) - ERREXIT(cinfo, JERR_SOS_NO_SOF); - - INPUT_2BYTES(cinfo, length, return FALSE); - - INPUT_BYTE(cinfo, n, return FALSE); /* Number of components */ - - TRACEMS1(cinfo, 1, JTRC_SOS, n); - - if (length != (n * 2 + 6) || n < 1 || n > MAX_COMPS_IN_SCAN) - ERREXIT(cinfo, JERR_BAD_LENGTH); - - cinfo->comps_in_scan = n; - - /* Collect the component-spec parameters */ - - for (i = 0; i < n; i++) { - INPUT_BYTE(cinfo, cc, return FALSE); - INPUT_BYTE(cinfo, c, return FALSE); - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - if (cc == compptr->component_id) - goto id_found; - } - - ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, cc); - - id_found: - - cinfo->cur_comp_info[i] = compptr; - compptr->dc_tbl_no = (c >> 4) & 15; - compptr->ac_tbl_no = (c ) & 15; - - TRACEMS3(cinfo, 1, JTRC_SOS_COMPONENT, cc, - compptr->dc_tbl_no, compptr->ac_tbl_no); - } - - /* Collect the additional scan parameters Ss, Se, Ah/Al. */ - INPUT_BYTE(cinfo, c, return FALSE); - cinfo->Ss = c; - INPUT_BYTE(cinfo, c, return FALSE); - cinfo->Se = c; - INPUT_BYTE(cinfo, c, return FALSE); - cinfo->Ah = (c >> 4) & 15; - cinfo->Al = (c ) & 15; - - TRACEMS4(cinfo, 1, JTRC_SOS_PARAMS, cinfo->Ss, cinfo->Se, - cinfo->Ah, cinfo->Al); - - /* Prepare to scan data & restart markers */ - cinfo->marker->next_restart_num = 0; - - /* Count another SOS marker */ - cinfo->input_scan_number++; - - INPUT_SYNC(cinfo); - return TRUE; -} - - -#ifdef D_ARITH_CODING_SUPPORTED - -LOCAL(boolean) -get_dac (j_decompress_ptr cinfo) -/* Process a DAC marker */ -{ - INT32 length; - int index, val; - INPUT_VARS(cinfo); - - INPUT_2BYTES(cinfo, length, return FALSE); - length -= 2; - - while (length > 0) { - INPUT_BYTE(cinfo, index, return FALSE); - INPUT_BYTE(cinfo, val, return FALSE); - - length -= 2; - - TRACEMS2(cinfo, 1, JTRC_DAC, index, val); - - if (index < 0 || index >= (2*NUM_ARITH_TBLS)) - ERREXIT1(cinfo, JERR_DAC_INDEX, index); - - if (index >= NUM_ARITH_TBLS) { /* define AC table */ - cinfo->arith_ac_K[index-NUM_ARITH_TBLS] = (UINT8) val; - } else { /* define DC table */ - cinfo->arith_dc_L[index] = (UINT8) (val & 0x0F); - cinfo->arith_dc_U[index] = (UINT8) (val >> 4); - if (cinfo->arith_dc_L[index] > cinfo->arith_dc_U[index]) - ERREXIT1(cinfo, JERR_DAC_VALUE, val); - } - } - - if (length != 0) - ERREXIT(cinfo, JERR_BAD_LENGTH); - - INPUT_SYNC(cinfo); - return TRUE; -} - -#else /* ! D_ARITH_CODING_SUPPORTED */ - -#define get_dac(cinfo) skip_variable(cinfo) - -#endif /* D_ARITH_CODING_SUPPORTED */ - - -LOCAL(boolean) -get_dht (j_decompress_ptr cinfo) -/* Process a DHT marker */ -{ - INT32 length; - UINT8 bits[17]; - UINT8 huffval[256]; - int i, index, count; - JHUFF_TBL **htblptr; - INPUT_VARS(cinfo); - - INPUT_2BYTES(cinfo, length, return FALSE); - length -= 2; - - while (length > 16) { - INPUT_BYTE(cinfo, index, return FALSE); - - TRACEMS1(cinfo, 1, JTRC_DHT, index); - - bits[0] = 0; - count = 0; - for (i = 1; i <= 16; i++) { - INPUT_BYTE(cinfo, bits[i], return FALSE); - count += bits[i]; - } - - length -= 1 + 16; - - TRACEMS8(cinfo, 2, JTRC_HUFFBITS, - bits[1], bits[2], bits[3], bits[4], - bits[5], bits[6], bits[7], bits[8]); - TRACEMS8(cinfo, 2, JTRC_HUFFBITS, - bits[9], bits[10], bits[11], bits[12], - bits[13], bits[14], bits[15], bits[16]); - - /* Here we just do minimal validation of the counts to avoid walking - * off the end of our table space. jdhuff.c will check more carefully. - */ - if (count > 256 || ((INT32) count) > length) - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - - for (i = 0; i < count; i++) - INPUT_BYTE(cinfo, huffval[i], return FALSE); - - length -= count; - - if (index & 0x10) { /* AC table definition */ - index -= 0x10; - htblptr = &cinfo->ac_huff_tbl_ptrs[index]; - } else { /* DC table definition */ - htblptr = &cinfo->dc_huff_tbl_ptrs[index]; - } - - if (index < 0 || index >= NUM_HUFF_TBLS) - ERREXIT1(cinfo, JERR_DHT_INDEX, index); - - if (*htblptr == NULL) - *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); - - MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits)); - MEMCOPY((*htblptr)->huffval, huffval, SIZEOF((*htblptr)->huffval)); - } - - if (length != 0) - ERREXIT(cinfo, JERR_BAD_LENGTH); - - INPUT_SYNC(cinfo); - return TRUE; -} - - -LOCAL(boolean) -get_dqt (j_decompress_ptr cinfo) -/* Process a DQT marker */ -{ - INT32 length; - int n, i, prec; - unsigned int tmp; - JQUANT_TBL *quant_ptr; - INPUT_VARS(cinfo); - - INPUT_2BYTES(cinfo, length, return FALSE); - length -= 2; - - while (length > 0) { - INPUT_BYTE(cinfo, n, return FALSE); - prec = n >> 4; - n &= 0x0F; - - TRACEMS2(cinfo, 1, JTRC_DQT, n, prec); - - if (n >= NUM_QUANT_TBLS) - ERREXIT1(cinfo, JERR_DQT_INDEX, n); - - if (cinfo->quant_tbl_ptrs[n] == NULL) - cinfo->quant_tbl_ptrs[n] = jpeg_alloc_quant_table((j_common_ptr) cinfo); - quant_ptr = cinfo->quant_tbl_ptrs[n]; - - for (i = 0; i < DCTSIZE2; i++) { - if (prec) - INPUT_2BYTES(cinfo, tmp, return FALSE); - else - INPUT_BYTE(cinfo, tmp, return FALSE); - /* We convert the zigzag-order table to natural array order. */ - quant_ptr->quantval[jpeg_natural_order[i]] = (UINT16) tmp; - } - - if (cinfo->err->trace_level >= 2) { - for (i = 0; i < DCTSIZE2; i += 8) { - TRACEMS8(cinfo, 2, JTRC_QUANTVALS, - quant_ptr->quantval[i], quant_ptr->quantval[i+1], - quant_ptr->quantval[i+2], quant_ptr->quantval[i+3], - quant_ptr->quantval[i+4], quant_ptr->quantval[i+5], - quant_ptr->quantval[i+6], quant_ptr->quantval[i+7]); - } - } - - length -= DCTSIZE2+1; - if (prec) length -= DCTSIZE2; - } - - if (length != 0) - ERREXIT(cinfo, JERR_BAD_LENGTH); - - INPUT_SYNC(cinfo); - return TRUE; -} - - -LOCAL(boolean) -get_dri (j_decompress_ptr cinfo) -/* Process a DRI marker */ -{ - INT32 length; - unsigned int tmp; - INPUT_VARS(cinfo); - - INPUT_2BYTES(cinfo, length, return FALSE); - - if (length != 4) - ERREXIT(cinfo, JERR_BAD_LENGTH); - - INPUT_2BYTES(cinfo, tmp, return FALSE); - - TRACEMS1(cinfo, 1, JTRC_DRI, tmp); - - cinfo->restart_interval = tmp; - - INPUT_SYNC(cinfo); - return TRUE; -} - - -/* - * Routines for processing APPn and COM markers. - * These are either saved in memory or discarded, per application request. - * APP0 and APP14 are specially checked to see if they are - * JFIF and Adobe markers, respectively. - */ - -#define APP0_DATA_LEN 14 /* Length of interesting data in APP0 */ -#define APP14_DATA_LEN 12 /* Length of interesting data in APP14 */ -#define APPN_DATA_LEN 14 /* Must be the largest of the above!! */ - - -LOCAL(void) -examine_app0 (j_decompress_ptr cinfo, JOCTET FAR * data, - unsigned int datalen, INT32 remaining) -/* Examine first few bytes from an APP0. - * Take appropriate action if it is a JFIF marker. - * datalen is # of bytes at data[], remaining is length of rest of marker data. - */ -{ - INT32 totallen = (INT32) datalen + remaining; - - if (datalen >= APP0_DATA_LEN && - GETJOCTET(data[0]) == 0x4A && - GETJOCTET(data[1]) == 0x46 && - GETJOCTET(data[2]) == 0x49 && - GETJOCTET(data[3]) == 0x46 && - GETJOCTET(data[4]) == 0) { - /* Found JFIF APP0 marker: save info */ - cinfo->saw_JFIF_marker = TRUE; - cinfo->JFIF_major_version = GETJOCTET(data[5]); - cinfo->JFIF_minor_version = GETJOCTET(data[6]); - cinfo->density_unit = GETJOCTET(data[7]); - cinfo->X_density = (GETJOCTET(data[8]) << 8) + GETJOCTET(data[9]); - cinfo->Y_density = (GETJOCTET(data[10]) << 8) + GETJOCTET(data[11]); - /* Check version. - * Major version must be 1, anything else signals an incompatible change. - * (We used to treat this as an error, but now it's a nonfatal warning, - * because some bozo at Hijaak couldn't read the spec.) - * Minor version should be 0..2, but process anyway if newer. - */ - if (cinfo->JFIF_major_version != 1) - WARNMS2(cinfo, JWRN_JFIF_MAJOR, - cinfo->JFIF_major_version, cinfo->JFIF_minor_version); - /* Generate trace messages */ - TRACEMS5(cinfo, 1, JTRC_JFIF, - cinfo->JFIF_major_version, cinfo->JFIF_minor_version, - cinfo->X_density, cinfo->Y_density, cinfo->density_unit); - /* Validate thumbnail dimensions and issue appropriate messages */ - if (GETJOCTET(data[12]) | GETJOCTET(data[13])) - TRACEMS2(cinfo, 1, JTRC_JFIF_THUMBNAIL, - GETJOCTET(data[12]), GETJOCTET(data[13])); - totallen -= APP0_DATA_LEN; - if (totallen != - ((INT32)GETJOCTET(data[12]) * (INT32)GETJOCTET(data[13]) * (INT32) 3)) - TRACEMS1(cinfo, 1, JTRC_JFIF_BADTHUMBNAILSIZE, (int) totallen); - } else if (datalen >= 6 && - GETJOCTET(data[0]) == 0x4A && - GETJOCTET(data[1]) == 0x46 && - GETJOCTET(data[2]) == 0x58 && - GETJOCTET(data[3]) == 0x58 && - GETJOCTET(data[4]) == 0) { - /* Found JFIF "JFXX" extension APP0 marker */ - /* The library doesn't actually do anything with these, - * but we try to produce a helpful trace message. - */ - switch (GETJOCTET(data[5])) { - case 0x10: - TRACEMS1(cinfo, 1, JTRC_THUMB_JPEG, (int) totallen); - break; - case 0x11: - TRACEMS1(cinfo, 1, JTRC_THUMB_PALETTE, (int) totallen); - break; - case 0x13: - TRACEMS1(cinfo, 1, JTRC_THUMB_RGB, (int) totallen); - break; - default: - TRACEMS2(cinfo, 1, JTRC_JFIF_EXTENSION, - GETJOCTET(data[5]), (int) totallen); - break; - } - } else { - /* Start of APP0 does not match "JFIF" or "JFXX", or too short */ - TRACEMS1(cinfo, 1, JTRC_APP0, (int) totallen); - } -} - - -LOCAL(void) -examine_app14 (j_decompress_ptr cinfo, JOCTET FAR * data, - unsigned int datalen, INT32 remaining) -/* Examine first few bytes from an APP14. - * Take appropriate action if it is an Adobe marker. - * datalen is # of bytes at data[], remaining is length of rest of marker data. - */ -{ - unsigned int version, flags0, flags1, transform; - - if (datalen >= APP14_DATA_LEN && - GETJOCTET(data[0]) == 0x41 && - GETJOCTET(data[1]) == 0x64 && - GETJOCTET(data[2]) == 0x6F && - GETJOCTET(data[3]) == 0x62 && - GETJOCTET(data[4]) == 0x65) { - /* Found Adobe APP14 marker */ - version = (GETJOCTET(data[5]) << 8) + GETJOCTET(data[6]); - flags0 = (GETJOCTET(data[7]) << 8) + GETJOCTET(data[8]); - flags1 = (GETJOCTET(data[9]) << 8) + GETJOCTET(data[10]); - transform = GETJOCTET(data[11]); - TRACEMS4(cinfo, 1, JTRC_ADOBE, version, flags0, flags1, transform); - cinfo->saw_Adobe_marker = TRUE; - cinfo->Adobe_transform = (UINT8) transform; - } else { - /* Start of APP14 does not match "Adobe", or too short */ - TRACEMS1(cinfo, 1, JTRC_APP14, (int) (datalen + remaining)); - } -} - - -METHODDEF(boolean) -get_interesting_appn (j_decompress_ptr cinfo) -/* Process an APP0 or APP14 marker without saving it */ -{ - INT32 length; - JOCTET b[APPN_DATA_LEN]; - unsigned int i, numtoread; - INPUT_VARS(cinfo); - - INPUT_2BYTES(cinfo, length, return FALSE); - length -= 2; - - /* get the interesting part of the marker data */ - if (length >= APPN_DATA_LEN) - numtoread = APPN_DATA_LEN; - else if (length > 0) - numtoread = (unsigned int) length; - else - numtoread = 0; - for (i = 0; i < numtoread; i++) - INPUT_BYTE(cinfo, b[i], return FALSE); - length -= numtoread; - - /* process it */ - switch (cinfo->unread_marker) { - case M_APP0: - examine_app0(cinfo, (JOCTET FAR *) b, numtoread, length); - break; - case M_APP14: - examine_app14(cinfo, (JOCTET FAR *) b, numtoread, length); - break; - default: - /* can't get here unless jpeg_save_markers chooses wrong processor */ - ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker); - break; - } - - /* skip any remaining data -- could be lots */ - INPUT_SYNC(cinfo); - if (length > 0) - (*cinfo->src->skip_input_data) (cinfo, (long) length); - - return TRUE; -} - - -#ifdef SAVE_MARKERS_SUPPORTED - -METHODDEF(boolean) -save_marker (j_decompress_ptr cinfo) -/* Save an APPn or COM marker into the marker list */ -{ - my_marker_ptr marker = (my_marker_ptr) cinfo->marker; - jpeg_saved_marker_ptr cur_marker = marker->cur_marker; - unsigned int bytes_read, data_length; - JOCTET FAR * data; - INT32 length = 0; - INPUT_VARS(cinfo); - - if (cur_marker == NULL) { - /* begin reading a marker */ - INPUT_2BYTES(cinfo, length, return FALSE); - length -= 2; - if (length >= 0) { /* watch out for bogus length word */ - /* figure out how much we want to save */ - unsigned int limit; - if (cinfo->unread_marker == (int) M_COM) - limit = marker->length_limit_COM; - else - limit = marker->length_limit_APPn[cinfo->unread_marker - (int) M_APP0]; - if ((unsigned int) length < limit) - limit = (unsigned int) length; - /* allocate and initialize the marker item */ - cur_marker = (jpeg_saved_marker_ptr) - (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(struct jpeg_marker_struct) + limit); - cur_marker->next = NULL; - cur_marker->marker = (UINT8) cinfo->unread_marker; - cur_marker->original_length = (unsigned int) length; - cur_marker->data_length = limit; - /* data area is just beyond the jpeg_marker_struct */ - data = cur_marker->data = (JOCTET FAR *) (cur_marker + 1); - marker->cur_marker = cur_marker; - marker->bytes_read = 0; - bytes_read = 0; - data_length = limit; - } else { - /* deal with bogus length word */ - bytes_read = data_length = 0; - data = NULL; - } - } else { - /* resume reading a marker */ - bytes_read = marker->bytes_read; - data_length = cur_marker->data_length; - data = cur_marker->data + bytes_read; - } - - while (bytes_read < data_length) { - INPUT_SYNC(cinfo); /* move the restart point to here */ - marker->bytes_read = bytes_read; - /* If there's not at least one byte in buffer, suspend */ - MAKE_BYTE_AVAIL(cinfo, return FALSE); - /* Copy bytes with reasonable rapidity */ - while (bytes_read < data_length && bytes_in_buffer > 0) { - *data++ = *next_input_byte++; - bytes_in_buffer--; - bytes_read++; - } - } - - /* Done reading what we want to read */ - if (cur_marker != NULL) { /* will be NULL if bogus length word */ - /* Add new marker to end of list */ - if (cinfo->marker_list == NULL) { - cinfo->marker_list = cur_marker; - } else { - jpeg_saved_marker_ptr prev = cinfo->marker_list; - while (prev->next != NULL) - prev = prev->next; - prev->next = cur_marker; - } - /* Reset pointer & calc remaining data length */ - data = cur_marker->data; - length = cur_marker->original_length - data_length; - } - /* Reset to initial state for next marker */ - marker->cur_marker = NULL; - - /* Process the marker if interesting; else just make a generic trace msg */ - switch (cinfo->unread_marker) { - case M_APP0: - examine_app0(cinfo, data, data_length, length); - break; - case M_APP14: - examine_app14(cinfo, data, data_length, length); - break; - default: - TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker, - (int) (data_length + length)); - break; - } - - /* skip any remaining data -- could be lots */ - INPUT_SYNC(cinfo); /* do before skip_input_data */ - if (length > 0) - (*cinfo->src->skip_input_data) (cinfo, (long) length); - - return TRUE; -} - -#endif /* SAVE_MARKERS_SUPPORTED */ - - -METHODDEF(boolean) -skip_variable (j_decompress_ptr cinfo) -/* Skip over an unknown or uninteresting variable-length marker */ -{ - INT32 length; - INPUT_VARS(cinfo); - - INPUT_2BYTES(cinfo, length, return FALSE); - length -= 2; - - TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker, (int) length); - - INPUT_SYNC(cinfo); /* do before skip_input_data */ - if (length > 0) - (*cinfo->src->skip_input_data) (cinfo, (long) length); - - return TRUE; -} - - -/* - * Find the next JPEG marker, save it in cinfo->unread_marker. - * Returns FALSE if had to suspend before reaching a marker; - * in that case cinfo->unread_marker is unchanged. - * - * Note that the result might not be a valid marker code, - * but it will never be 0 or FF. - */ - -LOCAL(boolean) -next_marker (j_decompress_ptr cinfo) -{ - int c; - INPUT_VARS(cinfo); - - for (;;) { - INPUT_BYTE(cinfo, c, return FALSE); - /* Skip any non-FF bytes. - * This may look a bit inefficient, but it will not occur in a valid file. - * We sync after each discarded byte so that a suspending data source - * can discard the byte from its buffer. - */ - while (c != 0xFF) { - cinfo->marker->discarded_bytes++; - INPUT_SYNC(cinfo); - INPUT_BYTE(cinfo, c, return FALSE); - } - /* This loop swallows any duplicate FF bytes. Extra FFs are legal as - * pad bytes, so don't count them in discarded_bytes. We assume there - * will not be so many consecutive FF bytes as to overflow a suspending - * data source's input buffer. - */ - do { - INPUT_BYTE(cinfo, c, return FALSE); - } while (c == 0xFF); - if (c != 0) - break; /* found a valid marker, exit loop */ - /* Reach here if we found a stuffed-zero data sequence (FF/00). - * Discard it and loop back to try again. - */ - cinfo->marker->discarded_bytes += 2; - INPUT_SYNC(cinfo); - } - - if (cinfo->marker->discarded_bytes != 0) { - WARNMS2(cinfo, JWRN_EXTRANEOUS_DATA, cinfo->marker->discarded_bytes, c); - cinfo->marker->discarded_bytes = 0; - } - - cinfo->unread_marker = c; - - INPUT_SYNC(cinfo); - return TRUE; -} - - -LOCAL(boolean) -first_marker (j_decompress_ptr cinfo) -/* Like next_marker, but used to obtain the initial SOI marker. */ -/* For this marker, we do not allow preceding garbage or fill; otherwise, - * we might well scan an entire input file before realizing it ain't JPEG. - * If an application wants to process non-JFIF files, it must seek to the - * SOI before calling the JPEG library. - */ -{ - int c, c2; - INPUT_VARS(cinfo); - - INPUT_BYTE(cinfo, c, return FALSE); - INPUT_BYTE(cinfo, c2, return FALSE); - if (c != 0xFF || c2 != (int) M_SOI) - ERREXIT2(cinfo, JERR_NO_SOI, c, c2); - - cinfo->unread_marker = c2; - - INPUT_SYNC(cinfo); - return TRUE; -} - - -/* - * Read markers until SOS or EOI. - * - * Returns same codes as are defined for jpeg_consume_input: - * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI. - */ - -METHODDEF(int) -read_markers (j_decompress_ptr cinfo) -{ - /* Outer loop repeats once for each marker. */ - for (;;) { - /* Collect the marker proper, unless we already did. */ - /* NB: first_marker() enforces the requirement that SOI appear first. */ - if (cinfo->unread_marker == 0) { - if (! cinfo->marker->saw_SOI) { - if (! first_marker(cinfo)) - return JPEG_SUSPENDED; - } else { - if (! next_marker(cinfo)) - return JPEG_SUSPENDED; - } - } - /* At this point cinfo->unread_marker contains the marker code and the - * input point is just past the marker proper, but before any parameters. - * A suspension will cause us to return with this state still true. - */ - switch (cinfo->unread_marker) { - case M_SOI: - if (! get_soi(cinfo)) - return JPEG_SUSPENDED; - break; - - case M_SOF0: /* Baseline */ - case M_SOF1: /* Extended sequential, Huffman */ - if (! get_sof(cinfo, FALSE, FALSE)) - return JPEG_SUSPENDED; - break; - - case M_SOF2: /* Progressive, Huffman */ - if (! get_sof(cinfo, TRUE, FALSE)) - return JPEG_SUSPENDED; - break; - - case M_SOF9: /* Extended sequential, arithmetic */ - if (! get_sof(cinfo, FALSE, TRUE)) - return JPEG_SUSPENDED; - break; - - case M_SOF10: /* Progressive, arithmetic */ - if (! get_sof(cinfo, TRUE, TRUE)) - return JPEG_SUSPENDED; - break; - - /* Currently unsupported SOFn types */ - case M_SOF3: /* Lossless, Huffman */ - case M_SOF5: /* Differential sequential, Huffman */ - case M_SOF6: /* Differential progressive, Huffman */ - case M_SOF7: /* Differential lossless, Huffman */ - case M_JPG: /* Reserved for JPEG extensions */ - case M_SOF11: /* Lossless, arithmetic */ - case M_SOF13: /* Differential sequential, arithmetic */ - case M_SOF14: /* Differential progressive, arithmetic */ - case M_SOF15: /* Differential lossless, arithmetic */ - ERREXIT1(cinfo, JERR_SOF_UNSUPPORTED, cinfo->unread_marker); - break; - - case M_SOS: - if (! get_sos(cinfo)) - return JPEG_SUSPENDED; - cinfo->unread_marker = 0; /* processed the marker */ - return JPEG_REACHED_SOS; - - case M_EOI: - TRACEMS(cinfo, 1, JTRC_EOI); - cinfo->unread_marker = 0; /* processed the marker */ - return JPEG_REACHED_EOI; - - case M_DAC: - if (! get_dac(cinfo)) - return JPEG_SUSPENDED; - break; - - case M_DHT: - if (! get_dht(cinfo)) - return JPEG_SUSPENDED; - break; - - case M_DQT: - if (! get_dqt(cinfo)) - return JPEG_SUSPENDED; - break; - - case M_DRI: - if (! get_dri(cinfo)) - return JPEG_SUSPENDED; - break; - - case M_APP0: - case M_APP1: - case M_APP2: - case M_APP3: - case M_APP4: - case M_APP5: - case M_APP6: - case M_APP7: - case M_APP8: - case M_APP9: - case M_APP10: - case M_APP11: - case M_APP12: - case M_APP13: - case M_APP14: - case M_APP15: - if (! (*((my_marker_ptr) cinfo->marker)->process_APPn[ - cinfo->unread_marker - (int) M_APP0]) (cinfo)) - return JPEG_SUSPENDED; - break; - - case M_COM: - if (! (*((my_marker_ptr) cinfo->marker)->process_COM) (cinfo)) - return JPEG_SUSPENDED; - break; - - case M_RST0: /* these are all parameterless */ - case M_RST1: - case M_RST2: - case M_RST3: - case M_RST4: - case M_RST5: - case M_RST6: - case M_RST7: - case M_TEM: - TRACEMS1(cinfo, 1, JTRC_PARMLESS_MARKER, cinfo->unread_marker); - break; - - case M_DNL: /* Ignore DNL ... perhaps the wrong thing */ - if (! skip_variable(cinfo)) - return JPEG_SUSPENDED; - break; - - default: /* must be DHP, EXP, JPGn, or RESn */ - /* For now, we treat the reserved markers as fatal errors since they are - * likely to be used to signal incompatible JPEG Part 3 extensions. - * Once the JPEG 3 version-number marker is well defined, this code - * ought to change! - */ - ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker); - break; - } - /* Successfully processed marker, so reset state variable */ - cinfo->unread_marker = 0; - } /* end loop */ -} - - -/* - * Read a restart marker, which is expected to appear next in the datastream; - * if the marker is not there, take appropriate recovery action. - * Returns FALSE if suspension is required. - * - * This is called by the entropy decoder after it has read an appropriate - * number of MCUs. cinfo->unread_marker may be nonzero if the entropy decoder - * has already read a marker from the data source. Under normal conditions - * cinfo->unread_marker will be reset to 0 before returning; if not reset, - * it holds a marker which the decoder will be unable to read past. - */ - -METHODDEF(boolean) -read_restart_marker (j_decompress_ptr cinfo) -{ - /* Obtain a marker unless we already did. */ - /* Note that next_marker will complain if it skips any data. */ - if (cinfo->unread_marker == 0) { - if (! next_marker(cinfo)) - return FALSE; - } - - if (cinfo->unread_marker == - ((int) M_RST0 + cinfo->marker->next_restart_num)) { - /* Normal case --- swallow the marker and let entropy decoder continue */ - TRACEMS1(cinfo, 3, JTRC_RST, cinfo->marker->next_restart_num); - cinfo->unread_marker = 0; - } else { - /* Uh-oh, the restart markers have been messed up. */ - /* Let the data source manager determine how to resync. */ - if (! (*cinfo->src->resync_to_restart) (cinfo, - cinfo->marker->next_restart_num)) - return FALSE; - } - - /* Update next-restart state */ - cinfo->marker->next_restart_num = (cinfo->marker->next_restart_num + 1) & 7; - - return TRUE; -} - - -/* - * This is the default resync_to_restart method for data source managers - * to use if they don't have any better approach. Some data source managers - * may be able to back up, or may have additional knowledge about the data - * which permits a more intelligent recovery strategy; such managers would - * presumably supply their own resync method. - * - * read_restart_marker calls resync_to_restart if it finds a marker other than - * the restart marker it was expecting. (This code is *not* used unless - * a nonzero restart interval has been declared.) cinfo->unread_marker is - * the marker code actually found (might be anything, except 0 or FF). - * The desired restart marker number (0..7) is passed as a parameter. - * This routine is supposed to apply whatever error recovery strategy seems - * appropriate in order to position the input stream to the next data segment. - * Note that cinfo->unread_marker is treated as a marker appearing before - * the current data-source input point; usually it should be reset to zero - * before returning. - * Returns FALSE if suspension is required. - * - * This implementation is substantially constrained by wanting to treat the - * input as a data stream; this means we can't back up. Therefore, we have - * only the following actions to work with: - * 1. Simply discard the marker and let the entropy decoder resume at next - * byte of file. - * 2. Read forward until we find another marker, discarding intervening - * data. (In theory we could look ahead within the current bufferload, - * without having to discard data if we don't find the desired marker. - * This idea is not implemented here, in part because it makes behavior - * dependent on buffer size and chance buffer-boundary positions.) - * 3. Leave the marker unread (by failing to zero cinfo->unread_marker). - * This will cause the entropy decoder to process an empty data segment, - * inserting dummy zeroes, and then we will reprocess the marker. - * - * #2 is appropriate if we think the desired marker lies ahead, while #3 is - * appropriate if the found marker is a future restart marker (indicating - * that we have missed the desired restart marker, probably because it got - * corrupted). - * We apply #2 or #3 if the found marker is a restart marker no more than - * two counts behind or ahead of the expected one. We also apply #2 if the - * found marker is not a legal JPEG marker code (it's certainly bogus data). - * If the found marker is a restart marker more than 2 counts away, we do #1 - * (too much risk that the marker is erroneous; with luck we will be able to - * resync at some future point). - * For any valid non-restart JPEG marker, we apply #3. This keeps us from - * overrunning the end of a scan. An implementation limited to single-scan - * files might find it better to apply #2 for markers other than EOI, since - * any other marker would have to be bogus data in that case. - */ - -GLOBAL(boolean) -jpeg_resync_to_restart (j_decompress_ptr cinfo, int desired) -{ - int marker = cinfo->unread_marker; - int action = 1; - - /* Always put up a warning. */ - WARNMS2(cinfo, JWRN_MUST_RESYNC, marker, desired); - - /* Outer loop handles repeated decision after scanning forward. */ - for (;;) { - if (marker < (int) M_SOF0) - action = 2; /* invalid marker */ - else if (marker < (int) M_RST0 || marker > (int) M_RST7) - action = 3; /* valid non-restart marker */ - else { - if (marker == ((int) M_RST0 + ((desired+1) & 7)) || - marker == ((int) M_RST0 + ((desired+2) & 7))) - action = 3; /* one of the next two expected restarts */ - else if (marker == ((int) M_RST0 + ((desired-1) & 7)) || - marker == ((int) M_RST0 + ((desired-2) & 7))) - action = 2; /* a prior restart, so advance */ - else - action = 1; /* desired restart or too far away */ - } - TRACEMS2(cinfo, 4, JTRC_RECOVERY_ACTION, marker, action); - switch (action) { - case 1: - /* Discard marker and let entropy decoder resume processing. */ - cinfo->unread_marker = 0; - return TRUE; - case 2: - /* Scan to the next marker, and repeat the decision loop. */ - if (! next_marker(cinfo)) - return FALSE; - marker = cinfo->unread_marker; - break; - case 3: - /* Return without advancing past this marker. */ - /* Entropy decoder will be forced to process an empty segment. */ - return TRUE; - } - } /* end loop */ -} - - -/* - * Reset marker processing state to begin a fresh datastream. - */ - -METHODDEF(void) -reset_marker_reader (j_decompress_ptr cinfo) -{ - my_marker_ptr marker = (my_marker_ptr) cinfo->marker; - - cinfo->comp_info = NULL; /* until allocated by get_sof */ - cinfo->input_scan_number = 0; /* no SOS seen yet */ - cinfo->unread_marker = 0; /* no pending marker */ - marker->pub.saw_SOI = FALSE; /* set internal state too */ - marker->pub.saw_SOF = FALSE; - marker->pub.discarded_bytes = 0; - marker->cur_marker = NULL; -} - - -/* - * Initialize the marker reader module. - * This is called only once, when the decompression object is created. - */ - -GLOBAL(void) -jinit_marker_reader (j_decompress_ptr cinfo) -{ - my_marker_ptr marker; - int i; - - /* Create subobject in permanent pool */ - marker = (my_marker_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - SIZEOF(my_marker_reader)); - cinfo->marker = (struct jpeg_marker_reader *) marker; - /* Initialize public method pointers */ - marker->pub.reset_marker_reader = reset_marker_reader; - marker->pub.read_markers = read_markers; - marker->pub.read_restart_marker = read_restart_marker; - /* Initialize COM/APPn processing. - * By default, we examine and then discard APP0 and APP14, - * but simply discard COM and all other APPn. - */ - marker->process_COM = skip_variable; - marker->length_limit_COM = 0; - for (i = 0; i < 16; i++) { - marker->process_APPn[i] = skip_variable; - marker->length_limit_APPn[i] = 0; - } - marker->process_APPn[0] = get_interesting_appn; - marker->process_APPn[14] = get_interesting_appn; - /* Reset marker processing state */ - reset_marker_reader(cinfo); -} - - -/* - * Control saving of COM and APPn markers into marker_list. - */ - -#ifdef SAVE_MARKERS_SUPPORTED - -GLOBAL(void) -jpeg_save_markers (j_decompress_ptr cinfo, int marker_code, - unsigned int length_limit) -{ - my_marker_ptr marker = (my_marker_ptr) cinfo->marker; - long maxlength; - jpeg_marker_parser_method processor; - - /* Length limit mustn't be larger than what we can allocate - * (should only be a concern in a 16-bit environment). - */ - maxlength = cinfo->mem->max_alloc_chunk - SIZEOF(struct jpeg_marker_struct); - if (((long) length_limit) > maxlength) - length_limit = (unsigned int) maxlength; - - /* Choose processor routine to use. - * APP0/APP14 have special requirements. - */ - if (length_limit) { - processor = save_marker; - /* If saving APP0/APP14, save at least enough for our internal use. */ - if (marker_code == (int) M_APP0 && length_limit < APP0_DATA_LEN) - length_limit = APP0_DATA_LEN; - else if (marker_code == (int) M_APP14 && length_limit < APP14_DATA_LEN) - length_limit = APP14_DATA_LEN; - } else { - processor = skip_variable; - /* If discarding APP0/APP14, use our regular on-the-fly processor. */ - if (marker_code == (int) M_APP0 || marker_code == (int) M_APP14) - processor = get_interesting_appn; - } - - if (marker_code == (int) M_COM) { - marker->process_COM = processor; - marker->length_limit_COM = length_limit; - } else if (marker_code >= (int) M_APP0 && marker_code <= (int) M_APP15) { - marker->process_APPn[marker_code - (int) M_APP0] = processor; - marker->length_limit_APPn[marker_code - (int) M_APP0] = length_limit; - } else - ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, marker_code); -} - -#endif /* SAVE_MARKERS_SUPPORTED */ - - -/* - * Install a special processing method for COM or APPn markers. - */ - -GLOBAL(void) -jpeg_set_marker_processor (j_decompress_ptr cinfo, int marker_code, - jpeg_marker_parser_method routine) -{ - my_marker_ptr marker = (my_marker_ptr) cinfo->marker; - - if (marker_code == (int) M_COM) - marker->process_COM = routine; - else if (marker_code >= (int) M_APP0 && marker_code <= (int) M_APP15) - marker->process_APPn[marker_code - (int) M_APP0] = routine; - else - ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, marker_code); -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jdmaster.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jdmaster.c deleted file mode 100644 index eda4b3fa7..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jdmaster.c +++ /dev/null @@ -1,557 +0,0 @@ -/* - * jdmaster.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains master control logic for the JPEG decompressor. - * These routines are concerned with selecting the modules to be executed - * and with determining the number of passes and the work to be done in each - * pass. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Private state */ - -typedef struct { - struct jpeg_decomp_master pub; /* public fields */ - - int pass_number; /* # of passes completed */ - - boolean using_merged_upsample; /* TRUE if using merged upsample/cconvert */ - - /* Saved references to initialized quantizer modules, - * in case we need to switch modes. - */ - struct jpeg_color_quantizer * quantizer_1pass; - struct jpeg_color_quantizer * quantizer_2pass; -} my_decomp_master; - -typedef my_decomp_master * my_master_ptr; - - -/* - * Determine whether merged upsample/color conversion should be used. - * CRUCIAL: this must match the actual capabilities of jdmerge.c! - */ - -LOCAL(boolean) -use_merged_upsample (j_decompress_ptr cinfo) -{ -#ifdef UPSAMPLE_MERGING_SUPPORTED - /* Merging is the equivalent of plain box-filter upsampling */ - if (cinfo->do_fancy_upsampling || cinfo->CCIR601_sampling) - return FALSE; - /* jdmerge.c only supports YCC=>RGB color conversion */ - if (cinfo->jpeg_color_space != JCS_YCbCr || cinfo->num_components != 3 || - cinfo->out_color_space != JCS_RGB || - cinfo->out_color_components != RGB_PIXELSIZE) - return FALSE; - /* and it only handles 2h1v or 2h2v sampling ratios */ - if (cinfo->comp_info[0].h_samp_factor != 2 || - cinfo->comp_info[1].h_samp_factor != 1 || - cinfo->comp_info[2].h_samp_factor != 1 || - cinfo->comp_info[0].v_samp_factor > 2 || - cinfo->comp_info[1].v_samp_factor != 1 || - cinfo->comp_info[2].v_samp_factor != 1) - return FALSE; - /* furthermore, it doesn't work if we've scaled the IDCTs differently */ - if (cinfo->comp_info[0].DCT_scaled_size != cinfo->min_DCT_scaled_size || - cinfo->comp_info[1].DCT_scaled_size != cinfo->min_DCT_scaled_size || - cinfo->comp_info[2].DCT_scaled_size != cinfo->min_DCT_scaled_size) - return FALSE; - /* ??? also need to test for upsample-time rescaling, when & if supported */ - return TRUE; /* by golly, it'll work... */ -#else - return FALSE; -#endif -} - - -/* - * Compute output image dimensions and related values. - * NOTE: this is exported for possible use by application. - * Hence it mustn't do anything that can't be done twice. - * Also note that it may be called before the master module is initialized! - */ - -GLOBAL(void) -jpeg_calc_output_dimensions (j_decompress_ptr cinfo) -/* Do computations that are needed before master selection phase */ -{ -#ifdef IDCT_SCALING_SUPPORTED - int ci; - jpeg_component_info *compptr; -#endif - - /* Prevent application from calling me at wrong times */ - if (cinfo->global_state != DSTATE_READY) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - -#ifdef IDCT_SCALING_SUPPORTED - - /* Compute actual output image dimensions and DCT scaling choices. */ - if (cinfo->scale_num * 8 <= cinfo->scale_denom) { - /* Provide 1/8 scaling */ - cinfo->output_width = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width, 8L); - cinfo->output_height = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height, 8L); - cinfo->min_DCT_scaled_size = 1; - } else if (cinfo->scale_num * 4 <= cinfo->scale_denom) { - /* Provide 1/4 scaling */ - cinfo->output_width = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width, 4L); - cinfo->output_height = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height, 4L); - cinfo->min_DCT_scaled_size = 2; - } else if (cinfo->scale_num * 2 <= cinfo->scale_denom) { - /* Provide 1/2 scaling */ - cinfo->output_width = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width, 2L); - cinfo->output_height = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height, 2L); - cinfo->min_DCT_scaled_size = 4; - } else { - /* Provide 1/1 scaling */ - cinfo->output_width = cinfo->image_width; - cinfo->output_height = cinfo->image_height; - cinfo->min_DCT_scaled_size = DCTSIZE; - } - /* In selecting the actual DCT scaling for each component, we try to - * scale up the chroma components via IDCT scaling rather than upsampling. - * This saves time if the upsampler gets to use 1:1 scaling. - * Note this code assumes that the supported DCT scalings are powers of 2. - */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - int ssize = cinfo->min_DCT_scaled_size; - while (ssize < DCTSIZE && - (compptr->h_samp_factor * ssize * 2 <= - cinfo->max_h_samp_factor * cinfo->min_DCT_scaled_size) && - (compptr->v_samp_factor * ssize * 2 <= - cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size)) { - ssize = ssize * 2; - } - compptr->DCT_scaled_size = ssize; - } - - /* Recompute downsampled dimensions of components; - * application needs to know these if using raw downsampled data. - */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Size in samples, after IDCT scaling */ - compptr->downsampled_width = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width * - (long) (compptr->h_samp_factor * compptr->DCT_scaled_size), - (long) (cinfo->max_h_samp_factor * DCTSIZE)); - compptr->downsampled_height = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height * - (long) (compptr->v_samp_factor * compptr->DCT_scaled_size), - (long) (cinfo->max_v_samp_factor * DCTSIZE)); - } - -#else /* !IDCT_SCALING_SUPPORTED */ - - /* Hardwire it to "no scaling" */ - cinfo->output_width = cinfo->image_width; - cinfo->output_height = cinfo->image_height; - /* jdinput.c has already initialized DCT_scaled_size to DCTSIZE, - * and has computed unscaled downsampled_width and downsampled_height. - */ - -#endif /* IDCT_SCALING_SUPPORTED */ - - /* Report number of components in selected colorspace. */ - /* Probably this should be in the color conversion module... */ - switch (cinfo->out_color_space) { - case JCS_GRAYSCALE: - cinfo->out_color_components = 1; - break; - case JCS_RGB: -#if RGB_PIXELSIZE != 3 - cinfo->out_color_components = RGB_PIXELSIZE; - break; -#endif /* else share code with YCbCr */ - case JCS_YCbCr: - cinfo->out_color_components = 3; - break; - case JCS_CMYK: - case JCS_YCCK: - cinfo->out_color_components = 4; - break; - default: /* else must be same colorspace as in file */ - cinfo->out_color_components = cinfo->num_components; - break; - } - cinfo->output_components = (cinfo->quantize_colors ? 1 : - cinfo->out_color_components); - - /* See if upsampler will want to emit more than one row at a time */ - if (use_merged_upsample(cinfo)) - cinfo->rec_outbuf_height = cinfo->max_v_samp_factor; - else - cinfo->rec_outbuf_height = 1; -} - - -/* - * Several decompression processes need to range-limit values to the range - * 0..MAXJSAMPLE; the input value may fall somewhat outside this range - * due to noise introduced by quantization, roundoff error, etc. These - * processes are inner loops and need to be as fast as possible. On most - * machines, particularly CPUs with pipelines or instruction prefetch, - * a (subscript-check-less) C table lookup - * x = sample_range_limit[x]; - * is faster than explicit tests - * if (x < 0) x = 0; - * else if (x > MAXJSAMPLE) x = MAXJSAMPLE; - * These processes all use a common table prepared by the routine below. - * - * For most steps we can mathematically guarantee that the initial value - * of x is within MAXJSAMPLE+1 of the legal range, so a table running from - * -(MAXJSAMPLE+1) to 2*MAXJSAMPLE+1 is sufficient. But for the initial - * limiting step (just after the IDCT), a wildly out-of-range value is - * possible if the input data is corrupt. To avoid any chance of indexing - * off the end of memory and getting a bad-pointer trap, we perform the - * post-IDCT limiting thus: - * x = range_limit[x & MASK]; - * where MASK is 2 bits wider than legal sample data, ie 10 bits for 8-bit - * samples. Under normal circumstances this is more than enough range and - * a correct output will be generated; with bogus input data the mask will - * cause wraparound, and we will safely generate a bogus-but-in-range output. - * For the post-IDCT step, we want to convert the data from signed to unsigned - * representation by adding CENTERJSAMPLE at the same time that we limit it. - * So the post-IDCT limiting table ends up looking like this: - * CENTERJSAMPLE,CENTERJSAMPLE+1,...,MAXJSAMPLE, - * MAXJSAMPLE (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times), - * 0 (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times), - * 0,1,...,CENTERJSAMPLE-1 - * Negative inputs select values from the upper half of the table after - * masking. - * - * We can save some space by overlapping the start of the post-IDCT table - * with the simpler range limiting table. The post-IDCT table begins at - * sample_range_limit + CENTERJSAMPLE. - * - * Note that the table is allocated in near data space on PCs; it's small - * enough and used often enough to justify this. - */ - -LOCAL(void) -prepare_range_limit_table (j_decompress_ptr cinfo) -/* Allocate and fill in the sample_range_limit table */ -{ - JSAMPLE * table; - int i; - - table = (JSAMPLE *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (5 * (MAXJSAMPLE+1) + CENTERJSAMPLE) * SIZEOF(JSAMPLE)); - table += (MAXJSAMPLE+1); /* allow negative subscripts of simple table */ - cinfo->sample_range_limit = table; - /* First segment of "simple" table: limit[x] = 0 for x < 0 */ - MEMZERO(table - (MAXJSAMPLE+1), (MAXJSAMPLE+1) * SIZEOF(JSAMPLE)); - /* Main part of "simple" table: limit[x] = x */ - for (i = 0; i <= MAXJSAMPLE; i++) - table[i] = (JSAMPLE) i; - table += CENTERJSAMPLE; /* Point to where post-IDCT table starts */ - /* End of simple table, rest of first half of post-IDCT table */ - for (i = CENTERJSAMPLE; i < 2*(MAXJSAMPLE+1); i++) - table[i] = MAXJSAMPLE; - /* Second half of post-IDCT table */ - MEMZERO(table + (2 * (MAXJSAMPLE+1)), - (2 * (MAXJSAMPLE+1) - CENTERJSAMPLE) * SIZEOF(JSAMPLE)); - MEMCOPY(table + (4 * (MAXJSAMPLE+1) - CENTERJSAMPLE), - cinfo->sample_range_limit, CENTERJSAMPLE * SIZEOF(JSAMPLE)); -} - - -/* - * Master selection of decompression modules. - * This is done once at jpeg_start_decompress time. We determine - * which modules will be used and give them appropriate initialization calls. - * We also initialize the decompressor input side to begin consuming data. - * - * Since jpeg_read_header has finished, we know what is in the SOF - * and (first) SOS markers. We also have all the application parameter - * settings. - */ - -LOCAL(void) -master_selection (j_decompress_ptr cinfo) -{ - my_master_ptr master = (my_master_ptr) cinfo->master; - boolean use_c_buffer; - long samplesperrow; - JDIMENSION jd_samplesperrow; - - /* Initialize dimensions and other stuff */ - jpeg_calc_output_dimensions(cinfo); - prepare_range_limit_table(cinfo); - - /* Width of an output scanline must be representable as JDIMENSION. */ - samplesperrow = (long) cinfo->output_width * (long) cinfo->out_color_components; - jd_samplesperrow = (JDIMENSION) samplesperrow; - if ((long) jd_samplesperrow != samplesperrow) - ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); - - /* Initialize my private state */ - master->pass_number = 0; - master->using_merged_upsample = use_merged_upsample(cinfo); - - /* Color quantizer selection */ - master->quantizer_1pass = NULL; - master->quantizer_2pass = NULL; - /* No mode changes if not using buffered-image mode. */ - if (! cinfo->quantize_colors || ! cinfo->buffered_image) { - cinfo->enable_1pass_quant = FALSE; - cinfo->enable_external_quant = FALSE; - cinfo->enable_2pass_quant = FALSE; - } - if (cinfo->quantize_colors) { - if (cinfo->raw_data_out) - ERREXIT(cinfo, JERR_NOTIMPL); - /* 2-pass quantizer only works in 3-component color space. */ - if (cinfo->out_color_components != 3) { - cinfo->enable_1pass_quant = TRUE; - cinfo->enable_external_quant = FALSE; - cinfo->enable_2pass_quant = FALSE; - cinfo->colormap = NULL; - } else if (cinfo->colormap != NULL) { - cinfo->enable_external_quant = TRUE; - } else if (cinfo->two_pass_quantize) { - cinfo->enable_2pass_quant = TRUE; - } else { - cinfo->enable_1pass_quant = TRUE; - } - - if (cinfo->enable_1pass_quant) { -#ifdef QUANT_1PASS_SUPPORTED - jinit_1pass_quantizer(cinfo); - master->quantizer_1pass = cinfo->cquantize; -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } - - /* We use the 2-pass code to map to external colormaps. */ - if (cinfo->enable_2pass_quant || cinfo->enable_external_quant) { -#ifdef QUANT_2PASS_SUPPORTED - jinit_2pass_quantizer(cinfo); - master->quantizer_2pass = cinfo->cquantize; -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } - /* If both quantizers are initialized, the 2-pass one is left active; - * this is necessary for starting with quantization to an external map. - */ - } - - /* Post-processing: in particular, color conversion first */ - if (! cinfo->raw_data_out) { - if (master->using_merged_upsample) { -#ifdef UPSAMPLE_MERGING_SUPPORTED - jinit_merged_upsampler(cinfo); /* does color conversion too */ -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else { - jinit_color_deconverter(cinfo); - jinit_upsampler(cinfo); - } - jinit_d_post_controller(cinfo, cinfo->enable_2pass_quant); - } - /* Inverse DCT */ - jinit_inverse_dct(cinfo); - /* Entropy decoding: either Huffman or arithmetic coding. */ - if (cinfo->arith_code) { - ERREXIT(cinfo, JERR_ARITH_NOTIMPL); - } else { - if (cinfo->progressive_mode) { -#ifdef D_PROGRESSIVE_SUPPORTED - jinit_phuff_decoder(cinfo); -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else - jinit_huff_decoder(cinfo); - } - - /* Initialize principal buffer controllers. */ - use_c_buffer = cinfo->inputctl->has_multiple_scans || cinfo->buffered_image; - jinit_d_coef_controller(cinfo, use_c_buffer); - - if (! cinfo->raw_data_out) - jinit_d_main_controller(cinfo, FALSE /* never need full buffer here */); - - /* We can now tell the memory manager to allocate virtual arrays. */ - (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); - - /* Initialize input side of decompressor to consume first scan. */ - (*cinfo->inputctl->start_input_pass) (cinfo); - -#ifdef D_MULTISCAN_FILES_SUPPORTED - /* If jpeg_start_decompress will read the whole file, initialize - * progress monitoring appropriately. The input step is counted - * as one pass. - */ - if (cinfo->progress != NULL && ! cinfo->buffered_image && - cinfo->inputctl->has_multiple_scans) { - int nscans; - /* Estimate number of scans to set pass_limit. */ - if (cinfo->progressive_mode) { - /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */ - nscans = 2 + 3 * cinfo->num_components; - } else { - /* For a nonprogressive multiscan file, estimate 1 scan per component. */ - nscans = cinfo->num_components; - } - cinfo->progress->pass_counter = 0L; - cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans; - cinfo->progress->completed_passes = 0; - cinfo->progress->total_passes = (cinfo->enable_2pass_quant ? 3 : 2); - /* Count the input pass as done */ - master->pass_number++; - } -#endif /* D_MULTISCAN_FILES_SUPPORTED */ -} - - -/* - * Per-pass setup. - * This is called at the beginning of each output pass. We determine which - * modules will be active during this pass and give them appropriate - * start_pass calls. We also set is_dummy_pass to indicate whether this - * is a "real" output pass or a dummy pass for color quantization. - * (In the latter case, jdapistd.c will crank the pass to completion.) - */ - -METHODDEF(void) -prepare_for_output_pass (j_decompress_ptr cinfo) -{ - my_master_ptr master = (my_master_ptr) cinfo->master; - - if (master->pub.is_dummy_pass) { -#ifdef QUANT_2PASS_SUPPORTED - /* Final pass of 2-pass quantization */ - master->pub.is_dummy_pass = FALSE; - (*cinfo->cquantize->start_pass) (cinfo, FALSE); - (*cinfo->post->start_pass) (cinfo, JBUF_CRANK_DEST); - (*cinfo->main->start_pass) (cinfo, JBUF_CRANK_DEST); -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif /* QUANT_2PASS_SUPPORTED */ - } else { - if (cinfo->quantize_colors && cinfo->colormap == NULL) { - /* Select new quantization method */ - if (cinfo->two_pass_quantize && cinfo->enable_2pass_quant) { - cinfo->cquantize = master->quantizer_2pass; - master->pub.is_dummy_pass = TRUE; - } else if (cinfo->enable_1pass_quant) { - cinfo->cquantize = master->quantizer_1pass; - } else { - ERREXIT(cinfo, JERR_MODE_CHANGE); - } - } - (*cinfo->idct->start_pass) (cinfo); - (*cinfo->coef->start_output_pass) (cinfo); - if (! cinfo->raw_data_out) { - if (! master->using_merged_upsample) - (*cinfo->cconvert->start_pass) (cinfo); - (*cinfo->upsample->start_pass) (cinfo); - if (cinfo->quantize_colors) - (*cinfo->cquantize->start_pass) (cinfo, master->pub.is_dummy_pass); - (*cinfo->post->start_pass) (cinfo, - (master->pub.is_dummy_pass ? JBUF_SAVE_AND_PASS : JBUF_PASS_THRU)); - (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU); - } - } - - /* Set up progress monitor's pass info if present */ - if (cinfo->progress != NULL) { - cinfo->progress->completed_passes = master->pass_number; - cinfo->progress->total_passes = master->pass_number + - (master->pub.is_dummy_pass ? 2 : 1); - /* In buffered-image mode, we assume one more output pass if EOI not - * yet reached, but no more passes if EOI has been reached. - */ - if (cinfo->buffered_image && ! cinfo->inputctl->eoi_reached) { - cinfo->progress->total_passes += (cinfo->enable_2pass_quant ? 2 : 1); - } - } -} - - -/* - * Finish up at end of an output pass. - */ - -METHODDEF(void) -finish_output_pass (j_decompress_ptr cinfo) -{ - my_master_ptr master = (my_master_ptr) cinfo->master; - - if (cinfo->quantize_colors) - (*cinfo->cquantize->finish_pass) (cinfo); - master->pass_number++; -} - - -#ifdef D_MULTISCAN_FILES_SUPPORTED - -/* - * Switch to a new external colormap between output passes. - */ - -GLOBAL(void) -jpeg_new_colormap (j_decompress_ptr cinfo) -{ - my_master_ptr master = (my_master_ptr) cinfo->master; - - /* Prevent application from calling me at wrong times */ - if (cinfo->global_state != DSTATE_BUFIMAGE) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - if (cinfo->quantize_colors && cinfo->enable_external_quant && - cinfo->colormap != NULL) { - /* Select 2-pass quantizer for external colormap use */ - cinfo->cquantize = master->quantizer_2pass; - /* Notify quantizer of colormap change */ - (*cinfo->cquantize->new_color_map) (cinfo); - master->pub.is_dummy_pass = FALSE; /* just in case */ - } else - ERREXIT(cinfo, JERR_MODE_CHANGE); -} - -#endif /* D_MULTISCAN_FILES_SUPPORTED */ - - -/* - * Initialize master decompression control and select active modules. - * This is performed at the start of jpeg_start_decompress. - */ - -GLOBAL(void) -jinit_master_decompress (j_decompress_ptr cinfo) -{ - my_master_ptr master; - - master = (my_master_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_decomp_master)); - cinfo->master = (struct jpeg_decomp_master *) master; - master->pub.prepare_for_output_pass = prepare_for_output_pass; - master->pub.finish_output_pass = finish_output_pass; - - master->pub.is_dummy_pass = FALSE; - - master_selection(cinfo); -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jdmerge.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jdmerge.c deleted file mode 100644 index 9e3a595de..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jdmerge.c +++ /dev/null @@ -1,400 +0,0 @@ -/* - * jdmerge.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains code for merged upsampling/color conversion. - * - * This file combines functions from jdsample.c and jdcolor.c; - * read those files first to understand what's going on. - * - * When the chroma components are to be upsampled by simple replication - * (ie, box filtering), we can save some work in color conversion by - * calculating all the output pixels corresponding to a pair of chroma - * samples at one time. In the conversion equations - * R = Y + K1 * Cr - * G = Y + K2 * Cb + K3 * Cr - * B = Y + K4 * Cb - * only the Y term varies among the group of pixels corresponding to a pair - * of chroma samples, so the rest of the terms can be calculated just once. - * At typical sampling ratios, this eliminates half or three-quarters of the - * multiplications needed for color conversion. - * - * This file currently provides implementations for the following cases: - * YCbCr => RGB color conversion only. - * Sampling ratios of 2h1v or 2h2v. - * No scaling needed at upsample time. - * Corner-aligned (non-CCIR601) sampling alignment. - * Other special cases could be added, but in most applications these are - * the only common cases. (For uncommon cases we fall back on the more - * general code in jdsample.c and jdcolor.c.) - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - -#ifdef UPSAMPLE_MERGING_SUPPORTED - - -/* Private subobject */ - -typedef struct { - struct jpeg_upsampler pub; /* public fields */ - - /* Pointer to routine to do actual upsampling/conversion of one row group */ - JMETHOD(void, upmethod, (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, - JSAMPARRAY output_buf)); - - /* Private state for YCC->RGB conversion */ - int * Cr_r_tab; /* => table for Cr to R conversion */ - int * Cb_b_tab; /* => table for Cb to B conversion */ - INT32 * Cr_g_tab; /* => table for Cr to G conversion */ - INT32 * Cb_g_tab; /* => table for Cb to G conversion */ - - /* For 2:1 vertical sampling, we produce two output rows at a time. - * We need a "spare" row buffer to hold the second output row if the - * application provides just a one-row buffer; we also use the spare - * to discard the dummy last row if the image height is odd. - */ - JSAMPROW spare_row; - boolean spare_full; /* T if spare buffer is occupied */ - - JDIMENSION out_row_width; /* samples per output row */ - JDIMENSION rows_to_go; /* counts rows remaining in image */ -} my_upsampler; - -typedef my_upsampler * my_upsample_ptr; - -#define SCALEBITS 16 /* speediest right-shift on some machines */ -#define ONE_HALF ((INT32) 1 << (SCALEBITS-1)) -#define FIX(x) ((INT32) ((x) * (1L<<SCALEBITS) + 0.5)) - - -/* - * Initialize tables for YCC->RGB colorspace conversion. - * This is taken directly from jdcolor.c; see that file for more info. - */ - -LOCAL(void) -build_ycc_rgb_table (j_decompress_ptr cinfo) -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - int i; - INT32 x; - SHIFT_TEMPS - - upsample->Cr_r_tab = (int *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(int)); - upsample->Cb_b_tab = (int *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(int)); - upsample->Cr_g_tab = (INT32 *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(INT32)); - upsample->Cb_g_tab = (INT32 *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(INT32)); - - for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) { - /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */ - /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */ - /* Cr=>R value is nearest int to 1.40200 * x */ - upsample->Cr_r_tab[i] = (int) - RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS); - /* Cb=>B value is nearest int to 1.77200 * x */ - upsample->Cb_b_tab[i] = (int) - RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS); - /* Cr=>G value is scaled-up -0.71414 * x */ - upsample->Cr_g_tab[i] = (- FIX(0.71414)) * x; - /* Cb=>G value is scaled-up -0.34414 * x */ - /* We also add in ONE_HALF so that need not do it in inner loop */ - upsample->Cb_g_tab[i] = (- FIX(0.34414)) * x + ONE_HALF; - } -} - - -/* - * Initialize for an upsampling pass. - */ - -METHODDEF(void) -start_pass_merged_upsample (j_decompress_ptr cinfo) -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - - /* Mark the spare buffer empty */ - upsample->spare_full = FALSE; - /* Initialize total-height counter for detecting bottom of image */ - upsample->rows_to_go = cinfo->output_height; -} - - -/* - * Control routine to do upsampling (and color conversion). - * - * The control routine just handles the row buffering considerations. - */ - -METHODDEF(void) -merged_2v_upsample (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -/* 2:1 vertical sampling case: may need a spare row. */ -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - JSAMPROW work_ptrs[2]; - JDIMENSION num_rows; /* number of rows returned to caller */ - - if (upsample->spare_full) { - /* If we have a spare row saved from a previous cycle, just return it. */ - jcopy_sample_rows(& upsample->spare_row, 0, output_buf + *out_row_ctr, 0, - 1, upsample->out_row_width); - num_rows = 1; - upsample->spare_full = FALSE; - } else { - /* Figure number of rows to return to caller. */ - num_rows = 2; - /* Not more than the distance to the end of the image. */ - if (num_rows > upsample->rows_to_go) - num_rows = upsample->rows_to_go; - /* And not more than what the client can accept: */ - out_rows_avail -= *out_row_ctr; - if (num_rows > out_rows_avail) - num_rows = out_rows_avail; - /* Create output pointer array for upsampler. */ - work_ptrs[0] = output_buf[*out_row_ctr]; - if (num_rows > 1) { - work_ptrs[1] = output_buf[*out_row_ctr + 1]; - } else { - work_ptrs[1] = upsample->spare_row; - upsample->spare_full = TRUE; - } - /* Now do the upsampling. */ - (*upsample->upmethod) (cinfo, input_buf, *in_row_group_ctr, work_ptrs); - } - - /* Adjust counts */ - *out_row_ctr += num_rows; - upsample->rows_to_go -= num_rows; - /* When the buffer is emptied, declare this input row group consumed */ - if (! upsample->spare_full) - (*in_row_group_ctr)++; -} - - -METHODDEF(void) -merged_1v_upsample (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -/* 1:1 vertical sampling case: much easier, never need a spare row. */ -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - - /* Just do the upsampling. */ - (*upsample->upmethod) (cinfo, input_buf, *in_row_group_ctr, - output_buf + *out_row_ctr); - /* Adjust counts */ - (*out_row_ctr)++; - (*in_row_group_ctr)++; -} - - -/* - * These are the routines invoked by the control routines to do - * the actual upsampling/conversion. One row group is processed per call. - * - * Note: since we may be writing directly into application-supplied buffers, - * we have to be honest about the output width; we can't assume the buffer - * has been rounded up to an even width. - */ - - -/* - * Upsample and color convert for the case of 2:1 horizontal and 1:1 vertical. - */ - -METHODDEF(void) -h2v1_merged_upsample (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, - JSAMPARRAY output_buf) -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - register int y, cred, cgreen, cblue; - int cb, cr; - register JSAMPROW outptr; - JSAMPROW inptr0, inptr1, inptr2; - JDIMENSION col; - /* copy these pointers into registers if possible */ - register JSAMPLE * range_limit = cinfo->sample_range_limit; - int * Crrtab = upsample->Cr_r_tab; - int * Cbbtab = upsample->Cb_b_tab; - INT32 * Crgtab = upsample->Cr_g_tab; - INT32 * Cbgtab = upsample->Cb_g_tab; - SHIFT_TEMPS - - inptr0 = input_buf[0][in_row_group_ctr]; - inptr1 = input_buf[1][in_row_group_ctr]; - inptr2 = input_buf[2][in_row_group_ctr]; - outptr = output_buf[0]; - /* Loop for each pair of output pixels */ - for (col = cinfo->output_width >> 1; col > 0; col--) { - /* Do the chroma part of the calculation */ - cb = GETJSAMPLE(*inptr1++); - cr = GETJSAMPLE(*inptr2++); - cred = Crrtab[cr]; - cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); - cblue = Cbbtab[cb]; - /* Fetch 2 Y values and emit 2 pixels */ - y = GETJSAMPLE(*inptr0++); - outptr[RGB_RED] = range_limit[y + cred]; - outptr[RGB_GREEN] = range_limit[y + cgreen]; - outptr[RGB_BLUE] = range_limit[y + cblue]; - outptr += RGB_PIXELSIZE; - y = GETJSAMPLE(*inptr0++); - outptr[RGB_RED] = range_limit[y + cred]; - outptr[RGB_GREEN] = range_limit[y + cgreen]; - outptr[RGB_BLUE] = range_limit[y + cblue]; - outptr += RGB_PIXELSIZE; - } - /* If image width is odd, do the last output column separately */ - if (cinfo->output_width & 1) { - cb = GETJSAMPLE(*inptr1); - cr = GETJSAMPLE(*inptr2); - cred = Crrtab[cr]; - cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); - cblue = Cbbtab[cb]; - y = GETJSAMPLE(*inptr0); - outptr[RGB_RED] = range_limit[y + cred]; - outptr[RGB_GREEN] = range_limit[y + cgreen]; - outptr[RGB_BLUE] = range_limit[y + cblue]; - } -} - - -/* - * Upsample and color convert for the case of 2:1 horizontal and 2:1 vertical. - */ - -METHODDEF(void) -h2v2_merged_upsample (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, - JSAMPARRAY output_buf) -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - register int y, cred, cgreen, cblue; - int cb, cr; - register JSAMPROW outptr0, outptr1; - JSAMPROW inptr00, inptr01, inptr1, inptr2; - JDIMENSION col; - /* copy these pointers into registers if possible */ - register JSAMPLE * range_limit = cinfo->sample_range_limit; - int * Crrtab = upsample->Cr_r_tab; - int * Cbbtab = upsample->Cb_b_tab; - INT32 * Crgtab = upsample->Cr_g_tab; - INT32 * Cbgtab = upsample->Cb_g_tab; - SHIFT_TEMPS - - inptr00 = input_buf[0][in_row_group_ctr*2]; - inptr01 = input_buf[0][in_row_group_ctr*2 + 1]; - inptr1 = input_buf[1][in_row_group_ctr]; - inptr2 = input_buf[2][in_row_group_ctr]; - outptr0 = output_buf[0]; - outptr1 = output_buf[1]; - /* Loop for each group of output pixels */ - for (col = cinfo->output_width >> 1; col > 0; col--) { - /* Do the chroma part of the calculation */ - cb = GETJSAMPLE(*inptr1++); - cr = GETJSAMPLE(*inptr2++); - cred = Crrtab[cr]; - cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); - cblue = Cbbtab[cb]; - /* Fetch 4 Y values and emit 4 pixels */ - y = GETJSAMPLE(*inptr00++); - outptr0[RGB_RED] = range_limit[y + cred]; - outptr0[RGB_GREEN] = range_limit[y + cgreen]; - outptr0[RGB_BLUE] = range_limit[y + cblue]; - outptr0 += RGB_PIXELSIZE; - y = GETJSAMPLE(*inptr00++); - outptr0[RGB_RED] = range_limit[y + cred]; - outptr0[RGB_GREEN] = range_limit[y + cgreen]; - outptr0[RGB_BLUE] = range_limit[y + cblue]; - outptr0 += RGB_PIXELSIZE; - y = GETJSAMPLE(*inptr01++); - outptr1[RGB_RED] = range_limit[y + cred]; - outptr1[RGB_GREEN] = range_limit[y + cgreen]; - outptr1[RGB_BLUE] = range_limit[y + cblue]; - outptr1 += RGB_PIXELSIZE; - y = GETJSAMPLE(*inptr01++); - outptr1[RGB_RED] = range_limit[y + cred]; - outptr1[RGB_GREEN] = range_limit[y + cgreen]; - outptr1[RGB_BLUE] = range_limit[y + cblue]; - outptr1 += RGB_PIXELSIZE; - } - /* If image width is odd, do the last output column separately */ - if (cinfo->output_width & 1) { - cb = GETJSAMPLE(*inptr1); - cr = GETJSAMPLE(*inptr2); - cred = Crrtab[cr]; - cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); - cblue = Cbbtab[cb]; - y = GETJSAMPLE(*inptr00); - outptr0[RGB_RED] = range_limit[y + cred]; - outptr0[RGB_GREEN] = range_limit[y + cgreen]; - outptr0[RGB_BLUE] = range_limit[y + cblue]; - y = GETJSAMPLE(*inptr01); - outptr1[RGB_RED] = range_limit[y + cred]; - outptr1[RGB_GREEN] = range_limit[y + cgreen]; - outptr1[RGB_BLUE] = range_limit[y + cblue]; - } -} - - -/* - * Module initialization routine for merged upsampling/color conversion. - * - * NB: this is called under the conditions determined by use_merged_upsample() - * in jdmaster.c. That routine MUST correspond to the actual capabilities - * of this module; no safety checks are made here. - */ - -GLOBAL(void) -jinit_merged_upsampler (j_decompress_ptr cinfo) -{ - my_upsample_ptr upsample; - - upsample = (my_upsample_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_upsampler)); - cinfo->upsample = (struct jpeg_upsampler *) upsample; - upsample->pub.start_pass = start_pass_merged_upsample; - upsample->pub.need_context_rows = FALSE; - - upsample->out_row_width = cinfo->output_width * cinfo->out_color_components; - - if (cinfo->max_v_samp_factor == 2) { - upsample->pub.upsample = merged_2v_upsample; - upsample->upmethod = h2v2_merged_upsample; - /* Allocate a spare row buffer */ - upsample->spare_row = (JSAMPROW) - (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (size_t) (upsample->out_row_width * SIZEOF(JSAMPLE))); - } else { - upsample->pub.upsample = merged_1v_upsample; - upsample->upmethod = h2v1_merged_upsample; - /* No spare row needed */ - upsample->spare_row = NULL; - } - - build_ycc_rgb_table(cinfo); -} - -#endif /* UPSAMPLE_MERGING_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jdphuff.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jdphuff.c deleted file mode 100644 index 24047432c..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jdphuff.c +++ /dev/null @@ -1,668 +0,0 @@ -/* - * jdphuff.c - * - * Copyright (C) 1995-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains Huffman entropy decoding routines for progressive JPEG. - * - * Much of the complexity here has to do with supporting input suspension. - * If the data source module demands suspension, we want to be able to back - * up to the start of the current MCU. To do this, we copy state variables - * into local working storage, and update them back to the permanent - * storage only upon successful completion of an MCU. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdhuff.h" /* Declarations shared with jdhuff.c */ - - -#ifdef D_PROGRESSIVE_SUPPORTED - -/* - * Expanded entropy decoder object for progressive Huffman decoding. - * - * The savable_state subrecord contains fields that change within an MCU, - * but must not be updated permanently until we complete the MCU. - */ - -typedef struct { - unsigned int EOBRUN; /* remaining EOBs in EOBRUN */ - int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */ -} savable_state; - -/* This macro is to work around compilers with missing or broken - * structure assignment. You'll need to fix this code if you have - * such a compiler and you change MAX_COMPS_IN_SCAN. - */ - -#ifndef NO_STRUCT_ASSIGN -#define ASSIGN_STATE(dest,src) ((dest) = (src)) -#else -#if MAX_COMPS_IN_SCAN == 4 -#define ASSIGN_STATE(dest,src) \ - ((dest).EOBRUN = (src).EOBRUN, \ - (dest).last_dc_val[0] = (src).last_dc_val[0], \ - (dest).last_dc_val[1] = (src).last_dc_val[1], \ - (dest).last_dc_val[2] = (src).last_dc_val[2], \ - (dest).last_dc_val[3] = (src).last_dc_val[3]) -#endif -#endif - - -typedef struct { - struct jpeg_entropy_decoder pub; /* public fields */ - - /* These fields are loaded into local variables at start of each MCU. - * In case of suspension, we exit WITHOUT updating them. - */ - bitread_perm_state bitstate; /* Bit buffer at start of MCU */ - savable_state saved; /* Other state at start of MCU */ - - /* These fields are NOT loaded into local working state. */ - unsigned int restarts_to_go; /* MCUs left in this restart interval */ - - /* Pointers to derived tables (these workspaces have image lifespan) */ - d_derived_tbl * derived_tbls[NUM_HUFF_TBLS]; - - d_derived_tbl * ac_derived_tbl; /* active table during an AC scan */ -} phuff_entropy_decoder; - -typedef phuff_entropy_decoder * phuff_entropy_ptr; - -/* Forward declarations */ -METHODDEF(boolean) decode_mcu_DC_first JPP((j_decompress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(boolean) decode_mcu_AC_first JPP((j_decompress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(boolean) decode_mcu_DC_refine JPP((j_decompress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(boolean) decode_mcu_AC_refine JPP((j_decompress_ptr cinfo, - JBLOCKROW *MCU_data)); - - -/* - * Initialize for a Huffman-compressed scan. - */ - -METHODDEF(void) -start_pass_phuff_decoder (j_decompress_ptr cinfo) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - boolean is_DC_band, bad; - int ci, coefi, tbl; - int *coef_bit_ptr; - jpeg_component_info * compptr; - - is_DC_band = (cinfo->Ss == 0); - - /* Validate scan parameters */ - bad = FALSE; - if (is_DC_band) { - if (cinfo->Se != 0) - bad = TRUE; - } else { - /* need not check Ss/Se < 0 since they came from unsigned bytes */ - if (cinfo->Ss > cinfo->Se || cinfo->Se >= DCTSIZE2) - bad = TRUE; - /* AC scans may have only one component */ - if (cinfo->comps_in_scan != 1) - bad = TRUE; - } - if (cinfo->Ah != 0) { - /* Successive approximation refinement scan: must have Al = Ah-1. */ - if (cinfo->Al != cinfo->Ah-1) - bad = TRUE; - } - if (cinfo->Al > 13) /* need not check for < 0 */ - bad = TRUE; - /* Arguably the maximum Al value should be less than 13 for 8-bit precision, - * but the spec doesn't say so, and we try to be liberal about what we - * accept. Note: large Al values could result in out-of-range DC - * coefficients during early scans, leading to bizarre displays due to - * overflows in the IDCT math. But we won't crash. - */ - if (bad) - ERREXIT4(cinfo, JERR_BAD_PROGRESSION, - cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al); - /* Update progression status, and verify that scan order is legal. - * Note that inter-scan inconsistencies are treated as warnings - * not fatal errors ... not clear if this is right way to behave. - */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - int cindex = cinfo->cur_comp_info[ci]->component_index; - coef_bit_ptr = & cinfo->coef_bits[cindex][0]; - if (!is_DC_band && coef_bit_ptr[0] < 0) /* AC without prior DC scan */ - WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, 0); - for (coefi = cinfo->Ss; coefi <= cinfo->Se; coefi++) { - int expected = (coef_bit_ptr[coefi] < 0) ? 0 : coef_bit_ptr[coefi]; - if (cinfo->Ah != expected) - WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, coefi); - coef_bit_ptr[coefi] = cinfo->Al; - } - } - - /* Select MCU decoding routine */ - if (cinfo->Ah == 0) { - if (is_DC_band) - entropy->pub.decode_mcu = decode_mcu_DC_first; - else - entropy->pub.decode_mcu = decode_mcu_AC_first; - } else { - if (is_DC_band) - entropy->pub.decode_mcu = decode_mcu_DC_refine; - else - entropy->pub.decode_mcu = decode_mcu_AC_refine; - } - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - /* Make sure requested tables are present, and compute derived tables. - * We may build same derived table more than once, but it's not expensive. - */ - if (is_DC_band) { - if (cinfo->Ah == 0) { /* DC refinement needs no table */ - tbl = compptr->dc_tbl_no; - jpeg_make_d_derived_tbl(cinfo, TRUE, tbl, - & entropy->derived_tbls[tbl]); - } - } else { - tbl = compptr->ac_tbl_no; - jpeg_make_d_derived_tbl(cinfo, FALSE, tbl, - & entropy->derived_tbls[tbl]); - /* remember the single active table */ - entropy->ac_derived_tbl = entropy->derived_tbls[tbl]; - } - /* Initialize DC predictions to 0 */ - entropy->saved.last_dc_val[ci] = 0; - } - - /* Initialize bitread state variables */ - entropy->bitstate.bits_left = 0; - entropy->bitstate.get_buffer = 0; /* unnecessary, but keeps Purify quiet */ - entropy->pub.insufficient_data = FALSE; - - /* Initialize private state variables */ - entropy->saved.EOBRUN = 0; - - /* Initialize restart counter */ - entropy->restarts_to_go = cinfo->restart_interval; -} - - -/* - * Figure F.12: extend sign bit. - * On some machines, a shift and add will be faster than a table lookup. - */ - -#ifdef AVOID_TABLES - -#define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) + (((-1)<<(s)) + 1) : (x)) - -#else - -#define HUFF_EXTEND(x,s) ((x) < extend_test[s] ? (x) + extend_offset[s] : (x)) - -static const int extend_test[16] = /* entry n is 2**(n-1) */ - { 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, - 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000 }; - -static const int extend_offset[16] = /* entry n is (-1 << n) + 1 */ - { 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1, - ((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1, - ((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1, - ((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 }; - -#endif /* AVOID_TABLES */ - - -/* - * Check for a restart marker & resynchronize decoder. - * Returns FALSE if must suspend. - */ - -LOCAL(boolean) -process_restart (j_decompress_ptr cinfo) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - int ci; - - /* Throw away any unused bits remaining in bit buffer; */ - /* include any full bytes in next_marker's count of discarded bytes */ - cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8; - entropy->bitstate.bits_left = 0; - - /* Advance past the RSTn marker */ - if (! (*cinfo->marker->read_restart_marker) (cinfo)) - return FALSE; - - /* Re-initialize DC predictions to 0 */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) - entropy->saved.last_dc_val[ci] = 0; - /* Re-init EOB run count, too */ - entropy->saved.EOBRUN = 0; - - /* Reset restart counter */ - entropy->restarts_to_go = cinfo->restart_interval; - - /* Reset out-of-data flag, unless read_restart_marker left us smack up - * against a marker. In that case we will end up treating the next data - * segment as empty, and we can avoid producing bogus output pixels by - * leaving the flag set. - */ - if (cinfo->unread_marker == 0) - entropy->pub.insufficient_data = FALSE; - - return TRUE; -} - - -/* - * Huffman MCU decoding. - * Each of these routines decodes and returns one MCU's worth of - * Huffman-compressed coefficients. - * The coefficients are reordered from zigzag order into natural array order, - * but are not dequantized. - * - * The i'th block of the MCU is stored into the block pointed to by - * MCU_data[i]. WE ASSUME THIS AREA IS INITIALLY ZEROED BY THE CALLER. - * - * We return FALSE if data source requested suspension. In that case no - * changes have been made to permanent state. (Exception: some output - * coefficients may already have been assigned. This is harmless for - * spectral selection, since we'll just re-assign them on the next call. - * Successive approximation AC refinement has to be more careful, however.) - */ - -/* - * MCU decoding for DC initial scan (either spectral selection, - * or first pass of successive approximation). - */ - -METHODDEF(boolean) -decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - int Al = cinfo->Al; - register int s, r; - int blkn, ci; - JBLOCKROW block; - BITREAD_STATE_VARS; - savable_state state; - d_derived_tbl * tbl; - jpeg_component_info * compptr; - - /* Process restart marker if needed; may have to suspend */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) - if (! process_restart(cinfo)) - return FALSE; - } - - /* If we've run out of data, just leave the MCU set to zeroes. - * This way, we return uniform gray for the remainder of the segment. - */ - if (! entropy->pub.insufficient_data) { - - /* Load up working state */ - BITREAD_LOAD_STATE(cinfo,entropy->bitstate); - ASSIGN_STATE(state, entropy->saved); - - /* Outer loop handles each block in the MCU */ - - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - block = MCU_data[blkn]; - ci = cinfo->MCU_membership[blkn]; - compptr = cinfo->cur_comp_info[ci]; - tbl = entropy->derived_tbls[compptr->dc_tbl_no]; - - /* Decode a single block's worth of coefficients */ - - /* Section F.2.2.1: decode the DC coefficient difference */ - HUFF_DECODE(s, br_state, tbl, return FALSE, label1); - if (s) { - CHECK_BIT_BUFFER(br_state, s, return FALSE); - r = GET_BITS(s); - s = HUFF_EXTEND(r, s); - } - - /* Convert DC difference to actual value, update last_dc_val */ - s += state.last_dc_val[ci]; - state.last_dc_val[ci] = s; - /* Scale and output the coefficient (assumes jpeg_natural_order[0]=0) */ - (*block)[0] = (JCOEF) (s << Al); - } - - /* Completed MCU, so update state */ - BITREAD_SAVE_STATE(cinfo,entropy->bitstate); - ASSIGN_STATE(entropy->saved, state); - } - - /* Account for restart interval (no-op if not using restarts) */ - entropy->restarts_to_go--; - - return TRUE; -} - - -/* - * MCU decoding for AC initial scan (either spectral selection, - * or first pass of successive approximation). - */ - -METHODDEF(boolean) -decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - int Se = cinfo->Se; - int Al = cinfo->Al; - register int s, k, r; - unsigned int EOBRUN; - JBLOCKROW block; - BITREAD_STATE_VARS; - d_derived_tbl * tbl; - - /* Process restart marker if needed; may have to suspend */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) - if (! process_restart(cinfo)) - return FALSE; - } - - /* If we've run out of data, just leave the MCU set to zeroes. - * This way, we return uniform gray for the remainder of the segment. - */ - if (! entropy->pub.insufficient_data) { - - /* Load up working state. - * We can avoid loading/saving bitread state if in an EOB run. - */ - EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we need */ - - /* There is always only one block per MCU */ - - if (EOBRUN > 0) /* if it's a band of zeroes... */ - EOBRUN--; /* ...process it now (we do nothing) */ - else { - BITREAD_LOAD_STATE(cinfo,entropy->bitstate); - block = MCU_data[0]; - tbl = entropy->ac_derived_tbl; - - for (k = cinfo->Ss; k <= Se; k++) { - HUFF_DECODE(s, br_state, tbl, return FALSE, label2); - r = s >> 4; - s &= 15; - if (s) { - k += r; - CHECK_BIT_BUFFER(br_state, s, return FALSE); - r = GET_BITS(s); - s = HUFF_EXTEND(r, s); - /* Scale and output coefficient in natural (dezigzagged) order */ - (*block)[jpeg_natural_order[k]] = (JCOEF) (s << Al); - } else { - if (r == 15) { /* ZRL */ - k += 15; /* skip 15 zeroes in band */ - } else { /* EOBr, run length is 2^r + appended bits */ - EOBRUN = 1 << r; - if (r) { /* EOBr, r > 0 */ - CHECK_BIT_BUFFER(br_state, r, return FALSE); - r = GET_BITS(r); - EOBRUN += r; - } - EOBRUN--; /* this band is processed at this moment */ - break; /* force end-of-band */ - } - } - } - - BITREAD_SAVE_STATE(cinfo,entropy->bitstate); - } - - /* Completed MCU, so update state */ - entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we need */ - } - - /* Account for restart interval (no-op if not using restarts) */ - entropy->restarts_to_go--; - - return TRUE; -} - - -/* - * MCU decoding for DC successive approximation refinement scan. - * Note: we assume such scans can be multi-component, although the spec - * is not very clear on the point. - */ - -METHODDEF(boolean) -decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - int p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */ - int blkn; - JBLOCKROW block; - BITREAD_STATE_VARS; - - /* Process restart marker if needed; may have to suspend */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) - if (! process_restart(cinfo)) - return FALSE; - } - - /* Not worth the cycles to check insufficient_data here, - * since we will not change the data anyway if we read zeroes. - */ - - /* Load up working state */ - BITREAD_LOAD_STATE(cinfo,entropy->bitstate); - - /* Outer loop handles each block in the MCU */ - - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - block = MCU_data[blkn]; - - /* Encoded data is simply the next bit of the two's-complement DC value */ - CHECK_BIT_BUFFER(br_state, 1, return FALSE); - if (GET_BITS(1)) - (*block)[0] |= p1; - /* Note: since we use |=, repeating the assignment later is safe */ - } - - /* Completed MCU, so update state */ - BITREAD_SAVE_STATE(cinfo,entropy->bitstate); - - /* Account for restart interval (no-op if not using restarts) */ - entropy->restarts_to_go--; - - return TRUE; -} - - -/* - * MCU decoding for AC successive approximation refinement scan. - */ - -METHODDEF(boolean) -decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - int Se = cinfo->Se; - int p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */ - int m1 = (-1) << cinfo->Al; /* -1 in the bit position being coded */ - register int s, k, r; - unsigned int EOBRUN; - JBLOCKROW block; - JCOEFPTR thiscoef; - BITREAD_STATE_VARS; - d_derived_tbl * tbl; - int num_newnz; - int newnz_pos[DCTSIZE2]; - - /* Process restart marker if needed; may have to suspend */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) - if (! process_restart(cinfo)) - return FALSE; - } - - /* If we've run out of data, don't modify the MCU. - */ - if (! entropy->pub.insufficient_data) { - - /* Load up working state */ - BITREAD_LOAD_STATE(cinfo,entropy->bitstate); - EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we need */ - - /* There is always only one block per MCU */ - block = MCU_data[0]; - tbl = entropy->ac_derived_tbl; - - /* If we are forced to suspend, we must undo the assignments to any newly - * nonzero coefficients in the block, because otherwise we'd get confused - * next time about which coefficients were already nonzero. - * But we need not undo addition of bits to already-nonzero coefficients; - * instead, we can test the current bit to see if we already did it. - */ - num_newnz = 0; - - /* initialize coefficient loop counter to start of band */ - k = cinfo->Ss; - - if (EOBRUN == 0) { - for (; k <= Se; k++) { - HUFF_DECODE(s, br_state, tbl, goto undoit, label3); - r = s >> 4; - s &= 15; - if (s) { - if (s != 1) /* size of new coef should always be 1 */ - WARNMS(cinfo, JWRN_HUFF_BAD_CODE); - CHECK_BIT_BUFFER(br_state, 1, goto undoit); - if (GET_BITS(1)) - s = p1; /* newly nonzero coef is positive */ - else - s = m1; /* newly nonzero coef is negative */ - } else { - if (r != 15) { - EOBRUN = 1 << r; /* EOBr, run length is 2^r + appended bits */ - if (r) { - CHECK_BIT_BUFFER(br_state, r, goto undoit); - r = GET_BITS(r); - EOBRUN += r; - } - break; /* rest of block is handled by EOB logic */ - } - /* note s = 0 for processing ZRL */ - } - /* Advance over already-nonzero coefs and r still-zero coefs, - * appending correction bits to the nonzeroes. A correction bit is 1 - * if the absolute value of the coefficient must be increased. - */ - do { - thiscoef = *block + jpeg_natural_order[k]; - if (*thiscoef != 0) { - CHECK_BIT_BUFFER(br_state, 1, goto undoit); - if (GET_BITS(1)) { - if ((*thiscoef & p1) == 0) { /* do nothing if already set it */ - if (*thiscoef >= 0) - *thiscoef += p1; - else - *thiscoef += m1; - } - } - } else { - if (--r < 0) - break; /* reached target zero coefficient */ - } - k++; - } while (k <= Se); - if (s) { - int pos = jpeg_natural_order[k]; - /* Output newly nonzero coefficient */ - (*block)[pos] = (JCOEF) s; - /* Remember its position in case we have to suspend */ - newnz_pos[num_newnz++] = pos; - } - } - } - - if (EOBRUN > 0) { - /* Scan any remaining coefficient positions after the end-of-band - * (the last newly nonzero coefficient, if any). Append a correction - * bit to each already-nonzero coefficient. A correction bit is 1 - * if the absolute value of the coefficient must be increased. - */ - for (; k <= Se; k++) { - thiscoef = *block + jpeg_natural_order[k]; - if (*thiscoef != 0) { - CHECK_BIT_BUFFER(br_state, 1, goto undoit); - if (GET_BITS(1)) { - if ((*thiscoef & p1) == 0) { /* do nothing if already changed it */ - if (*thiscoef >= 0) - *thiscoef += p1; - else - *thiscoef += m1; - } - } - } - } - /* Count one block completed in EOB run */ - EOBRUN--; - } - - /* Completed MCU, so update state */ - BITREAD_SAVE_STATE(cinfo,entropy->bitstate); - entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we need */ - } - - /* Account for restart interval (no-op if not using restarts) */ - entropy->restarts_to_go--; - - return TRUE; - -undoit: - /* Re-zero any output coefficients that we made newly nonzero */ - while (num_newnz > 0) - (*block)[newnz_pos[--num_newnz]] = 0; - - return FALSE; -} - - -/* - * Module initialization routine for progressive Huffman entropy decoding. - */ - -GLOBAL(void) -jinit_phuff_decoder (j_decompress_ptr cinfo) -{ - phuff_entropy_ptr entropy; - int *coef_bit_ptr; - int ci, i; - - entropy = (phuff_entropy_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(phuff_entropy_decoder)); - cinfo->entropy = (struct jpeg_entropy_decoder *) entropy; - entropy->pub.start_pass = start_pass_phuff_decoder; - - /* Mark derived tables unallocated */ - for (i = 0; i < NUM_HUFF_TBLS; i++) { - entropy->derived_tbls[i] = NULL; - } - - /* Create progression status table */ - cinfo->coef_bits = (int (*)[DCTSIZE2]) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - cinfo->num_components*DCTSIZE2*SIZEOF(int)); - coef_bit_ptr = & cinfo->coef_bits[0][0]; - for (ci = 0; ci < cinfo->num_components; ci++) - for (i = 0; i < DCTSIZE2; i++) - *coef_bit_ptr++ = -1; -} - -#endif /* D_PROGRESSIVE_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jdpostct.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jdpostct.c deleted file mode 100644 index 7ba9eed52..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jdpostct.c +++ /dev/null @@ -1,290 +0,0 @@ -/* - * jdpostct.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the decompression postprocessing controller. - * This controller manages the upsampling, color conversion, and color - * quantization/reduction steps; specifically, it controls the buffering - * between upsample/color conversion and color quantization/reduction. - * - * If no color quantization/reduction is required, then this module has no - * work to do, and it just hands off to the upsample/color conversion code. - * An integrated upsample/convert/quantize process would replace this module - * entirely. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Private buffer controller object */ - -typedef struct { - struct jpeg_d_post_controller pub; /* public fields */ - - /* Color quantization source buffer: this holds output data from - * the upsample/color conversion step to be passed to the quantizer. - * For two-pass color quantization, we need a full-image buffer; - * for one-pass operation, a strip buffer is sufficient. - */ - jvirt_sarray_ptr whole_image; /* virtual array, or NULL if one-pass */ - JSAMPARRAY buffer; /* strip buffer, or current strip of virtual */ - JDIMENSION strip_height; /* buffer size in rows */ - /* for two-pass mode only: */ - JDIMENSION starting_row; /* row # of first row in current strip */ - JDIMENSION next_row; /* index of next row to fill/empty in strip */ -} my_post_controller; - -typedef my_post_controller * my_post_ptr; - - -/* Forward declarations */ -METHODDEF(void) post_process_1pass - JPP((j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail)); -#ifdef QUANT_2PASS_SUPPORTED -METHODDEF(void) post_process_prepass - JPP((j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail)); -METHODDEF(void) post_process_2pass - JPP((j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail)); -#endif - - -/* - * Initialize for a processing pass. - */ - -METHODDEF(void) -start_pass_dpost (j_decompress_ptr cinfo, J_BUF_MODE pass_mode) -{ - my_post_ptr post = (my_post_ptr) cinfo->post; - - switch (pass_mode) { - case JBUF_PASS_THRU: - if (cinfo->quantize_colors) { - /* Single-pass processing with color quantization. */ - post->pub.post_process_data = post_process_1pass; - /* We could be doing buffered-image output before starting a 2-pass - * color quantization; in that case, jinit_d_post_controller did not - * allocate a strip buffer. Use the virtual-array buffer as workspace. - */ - if (post->buffer == NULL) { - post->buffer = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, post->whole_image, - (JDIMENSION) 0, post->strip_height, TRUE); - } - } else { - /* For single-pass processing without color quantization, - * I have no work to do; just call the upsampler directly. - */ - post->pub.post_process_data = cinfo->upsample->upsample; - } - break; -#ifdef QUANT_2PASS_SUPPORTED - case JBUF_SAVE_AND_PASS: - /* First pass of 2-pass quantization */ - if (post->whole_image == NULL) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - post->pub.post_process_data = post_process_prepass; - break; - case JBUF_CRANK_DEST: - /* Second pass of 2-pass quantization */ - if (post->whole_image == NULL) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - post->pub.post_process_data = post_process_2pass; - break; -#endif /* QUANT_2PASS_SUPPORTED */ - default: - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - break; - } - post->starting_row = post->next_row = 0; -} - - -/* - * Process some data in the one-pass (strip buffer) case. - * This is used for color precision reduction as well as one-pass quantization. - */ - -METHODDEF(void) -post_process_1pass (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -{ - my_post_ptr post = (my_post_ptr) cinfo->post; - JDIMENSION num_rows, max_rows; - - /* Fill the buffer, but not more than what we can dump out in one go. */ - /* Note we rely on the upsampler to detect bottom of image. */ - max_rows = out_rows_avail - *out_row_ctr; - if (max_rows > post->strip_height) - max_rows = post->strip_height; - num_rows = 0; - (*cinfo->upsample->upsample) (cinfo, - input_buf, in_row_group_ctr, in_row_groups_avail, - post->buffer, &num_rows, max_rows); - /* Quantize and emit data. */ - (*cinfo->cquantize->color_quantize) (cinfo, - post->buffer, output_buf + *out_row_ctr, (int) num_rows); - *out_row_ctr += num_rows; -} - - -#ifdef QUANT_2PASS_SUPPORTED - -/* - * Process some data in the first pass of 2-pass quantization. - */ - -METHODDEF(void) -post_process_prepass (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -{ - my_post_ptr post = (my_post_ptr) cinfo->post; - JDIMENSION old_next_row, num_rows; - - /* Reposition virtual buffer if at start of strip. */ - if (post->next_row == 0) { - post->buffer = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, post->whole_image, - post->starting_row, post->strip_height, TRUE); - } - - /* Upsample some data (up to a strip height's worth). */ - old_next_row = post->next_row; - (*cinfo->upsample->upsample) (cinfo, - input_buf, in_row_group_ctr, in_row_groups_avail, - post->buffer, &post->next_row, post->strip_height); - - /* Allow quantizer to scan new data. No data is emitted, */ - /* but we advance out_row_ctr so outer loop can tell when we're done. */ - if (post->next_row > old_next_row) { - num_rows = post->next_row - old_next_row; - (*cinfo->cquantize->color_quantize) (cinfo, post->buffer + old_next_row, - (JSAMPARRAY) NULL, (int) num_rows); - *out_row_ctr += num_rows; - } - - /* Advance if we filled the strip. */ - if (post->next_row >= post->strip_height) { - post->starting_row += post->strip_height; - post->next_row = 0; - } -} - - -/* - * Process some data in the second pass of 2-pass quantization. - */ - -METHODDEF(void) -post_process_2pass (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -{ - my_post_ptr post = (my_post_ptr) cinfo->post; - JDIMENSION num_rows, max_rows; - - /* Reposition virtual buffer if at start of strip. */ - if (post->next_row == 0) { - post->buffer = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, post->whole_image, - post->starting_row, post->strip_height, FALSE); - } - - /* Determine number of rows to emit. */ - num_rows = post->strip_height - post->next_row; /* available in strip */ - max_rows = out_rows_avail - *out_row_ctr; /* available in output area */ - if (num_rows > max_rows) - num_rows = max_rows; - /* We have to check bottom of image here, can't depend on upsampler. */ - max_rows = cinfo->output_height - post->starting_row; - if (num_rows > max_rows) - num_rows = max_rows; - - /* Quantize and emit data. */ - (*cinfo->cquantize->color_quantize) (cinfo, - post->buffer + post->next_row, output_buf + *out_row_ctr, - (int) num_rows); - *out_row_ctr += num_rows; - - /* Advance if we filled the strip. */ - post->next_row += num_rows; - if (post->next_row >= post->strip_height) { - post->starting_row += post->strip_height; - post->next_row = 0; - } -} - -#endif /* QUANT_2PASS_SUPPORTED */ - - -/* - * Initialize postprocessing controller. - */ - -GLOBAL(void) -jinit_d_post_controller (j_decompress_ptr cinfo, boolean need_full_buffer) -{ - my_post_ptr post; - - post = (my_post_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_post_controller)); - cinfo->post = (struct jpeg_d_post_controller *) post; - post->pub.start_pass = start_pass_dpost; - post->whole_image = NULL; /* flag for no virtual arrays */ - post->buffer = NULL; /* flag for no strip buffer */ - - /* Create the quantization buffer, if needed */ - if (cinfo->quantize_colors) { - /* The buffer strip height is max_v_samp_factor, which is typically - * an efficient number of rows for upsampling to return. - * (In the presence of output rescaling, we might want to be smarter?) - */ - post->strip_height = (JDIMENSION) cinfo->max_v_samp_factor; - if (need_full_buffer) { - /* Two-pass color quantization: need full-image storage. */ - /* We round up the number of rows to a multiple of the strip height. */ -#ifdef QUANT_2PASS_SUPPORTED - post->whole_image = (*cinfo->mem->request_virt_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, - cinfo->output_width * cinfo->out_color_components, - (JDIMENSION) jround_up((long) cinfo->output_height, - (long) post->strip_height), - post->strip_height); -#else - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); -#endif /* QUANT_2PASS_SUPPORTED */ - } else { - /* One-pass color quantization: just make a strip buffer. */ - post->buffer = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - cinfo->output_width * cinfo->out_color_components, - post->strip_height); - } - } -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jdsample.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jdsample.c deleted file mode 100644 index e0d9040a7..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jdsample.c +++ /dev/null @@ -1,478 +0,0 @@ -/* - * jdsample.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains upsampling routines. - * - * Upsampling input data is counted in "row groups". A row group - * is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size) - * sample rows of each component. Upsampling will normally produce - * max_v_samp_factor pixel rows from each row group (but this could vary - * if the upsampler is applying a scale factor of its own). - * - * An excellent reference for image resampling is - * Digital Image Warping, George Wolberg, 1990. - * Pub. by IEEE Computer Society Press, Los Alamitos, CA. ISBN 0-8186-8944-7. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Pointer to routine to upsample a single component */ -typedef JMETHOD(void, upsample1_ptr, - (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)); - -/* Private subobject */ - -typedef struct { - struct jpeg_upsampler pub; /* public fields */ - - /* Color conversion buffer. When using separate upsampling and color - * conversion steps, this buffer holds one upsampled row group until it - * has been color converted and output. - * Note: we do not allocate any storage for component(s) which are full-size, - * ie do not need rescaling. The corresponding entry of color_buf[] is - * simply set to point to the input data array, thereby avoiding copying. - */ - JSAMPARRAY color_buf[MAX_COMPONENTS]; - - /* Per-component upsampling method pointers */ - upsample1_ptr methods[MAX_COMPONENTS]; - - int next_row_out; /* counts rows emitted from color_buf */ - JDIMENSION rows_to_go; /* counts rows remaining in image */ - - /* Height of an input row group for each component. */ - int rowgroup_height[MAX_COMPONENTS]; - - /* These arrays save pixel expansion factors so that int_expand need not - * recompute them each time. They are unused for other upsampling methods. - */ - UINT8 h_expand[MAX_COMPONENTS]; - UINT8 v_expand[MAX_COMPONENTS]; -} my_upsampler; - -typedef my_upsampler * my_upsample_ptr; - - -/* - * Initialize for an upsampling pass. - */ - -METHODDEF(void) -start_pass_upsample (j_decompress_ptr cinfo) -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - - /* Mark the conversion buffer empty */ - upsample->next_row_out = cinfo->max_v_samp_factor; - /* Initialize total-height counter for detecting bottom of image */ - upsample->rows_to_go = cinfo->output_height; -} - - -/* - * Control routine to do upsampling (and color conversion). - * - * In this version we upsample each component independently. - * We upsample one row group into the conversion buffer, then apply - * color conversion a row at a time. - */ - -METHODDEF(void) -sep_upsample (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - int ci; - jpeg_component_info * compptr; - JDIMENSION num_rows; - - /* Fill the conversion buffer, if it's empty */ - if (upsample->next_row_out >= cinfo->max_v_samp_factor) { - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Invoke per-component upsample method. Notice we pass a POINTER - * to color_buf[ci], so that fullsize_upsample can change it. - */ - (*upsample->methods[ci]) (cinfo, compptr, - input_buf[ci] + (*in_row_group_ctr * upsample->rowgroup_height[ci]), - upsample->color_buf + ci); - } - upsample->next_row_out = 0; - } - - /* Color-convert and emit rows */ - - /* How many we have in the buffer: */ - num_rows = (JDIMENSION) (cinfo->max_v_samp_factor - upsample->next_row_out); - /* Not more than the distance to the end of the image. Need this test - * in case the image height is not a multiple of max_v_samp_factor: - */ - if (num_rows > upsample->rows_to_go) - num_rows = upsample->rows_to_go; - /* And not more than what the client can accept: */ - out_rows_avail -= *out_row_ctr; - if (num_rows > out_rows_avail) - num_rows = out_rows_avail; - - (*cinfo->cconvert->color_convert) (cinfo, upsample->color_buf, - (JDIMENSION) upsample->next_row_out, - output_buf + *out_row_ctr, - (int) num_rows); - - /* Adjust counts */ - *out_row_ctr += num_rows; - upsample->rows_to_go -= num_rows; - upsample->next_row_out += num_rows; - /* When the buffer is emptied, declare this input row group consumed */ - if (upsample->next_row_out >= cinfo->max_v_samp_factor) - (*in_row_group_ctr)++; -} - - -/* - * These are the routines invoked by sep_upsample to upsample pixel values - * of a single component. One row group is processed per call. - */ - - -/* - * For full-size components, we just make color_buf[ci] point at the - * input buffer, and thus avoid copying any data. Note that this is - * safe only because sep_upsample doesn't declare the input row group - * "consumed" until we are done color converting and emitting it. - */ - -METHODDEF(void) -fullsize_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) -{ - *output_data_ptr = input_data; -} - - -/* - * This is a no-op version used for "uninteresting" components. - * These components will not be referenced by color conversion. - */ - -METHODDEF(void) -noop_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) -{ - *output_data_ptr = NULL; /* safety check */ -} - - -/* - * This version handles any integral sampling ratios. - * This is not used for typical JPEG files, so it need not be fast. - * Nor, for that matter, is it particularly accurate: the algorithm is - * simple replication of the input pixel onto the corresponding output - * pixels. The hi-falutin sampling literature refers to this as a - * "box filter". A box filter tends to introduce visible artifacts, - * so if you are actually going to use 3:1 or 4:1 sampling ratios - * you would be well advised to improve this code. - */ - -METHODDEF(void) -int_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - JSAMPARRAY output_data = *output_data_ptr; - register JSAMPROW inptr, outptr; - register JSAMPLE invalue; - register int h; - JSAMPROW outend; - int h_expand, v_expand; - int inrow, outrow; - - h_expand = upsample->h_expand[compptr->component_index]; - v_expand = upsample->v_expand[compptr->component_index]; - - inrow = outrow = 0; - while (outrow < cinfo->max_v_samp_factor) { - /* Generate one output row with proper horizontal expansion */ - inptr = input_data[inrow]; - outptr = output_data[outrow]; - outend = outptr + cinfo->output_width; - while (outptr < outend) { - invalue = *inptr++; /* don't need GETJSAMPLE() here */ - for (h = h_expand; h > 0; h--) { - *outptr++ = invalue; - } - } - /* Generate any additional output rows by duplicating the first one */ - if (v_expand > 1) { - jcopy_sample_rows(output_data, outrow, output_data, outrow+1, - v_expand-1, cinfo->output_width); - } - inrow++; - outrow += v_expand; - } -} - - -/* - * Fast processing for the common case of 2:1 horizontal and 1:1 vertical. - * It's still a box filter. - */ - -METHODDEF(void) -h2v1_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) -{ - JSAMPARRAY output_data = *output_data_ptr; - register JSAMPROW inptr, outptr; - register JSAMPLE invalue; - JSAMPROW outend; - int inrow; - - for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) { - inptr = input_data[inrow]; - outptr = output_data[inrow]; - outend = outptr + cinfo->output_width; - while (outptr < outend) { - invalue = *inptr++; /* don't need GETJSAMPLE() here */ - *outptr++ = invalue; - *outptr++ = invalue; - } - } -} - - -/* - * Fast processing for the common case of 2:1 horizontal and 2:1 vertical. - * It's still a box filter. - */ - -METHODDEF(void) -h2v2_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) -{ - JSAMPARRAY output_data = *output_data_ptr; - register JSAMPROW inptr, outptr; - register JSAMPLE invalue; - JSAMPROW outend; - int inrow, outrow; - - inrow = outrow = 0; - while (outrow < cinfo->max_v_samp_factor) { - inptr = input_data[inrow]; - outptr = output_data[outrow]; - outend = outptr + cinfo->output_width; - while (outptr < outend) { - invalue = *inptr++; /* don't need GETJSAMPLE() here */ - *outptr++ = invalue; - *outptr++ = invalue; - } - jcopy_sample_rows(output_data, outrow, output_data, outrow+1, - 1, cinfo->output_width); - inrow++; - outrow += 2; - } -} - - -/* - * Fancy processing for the common case of 2:1 horizontal and 1:1 vertical. - * - * The upsampling algorithm is linear interpolation between pixel centers, - * also known as a "triangle filter". This is a good compromise between - * speed and visual quality. The centers of the output pixels are 1/4 and 3/4 - * of the way between input pixel centers. - * - * A note about the "bias" calculations: when rounding fractional values to - * integer, we do not want to always round 0.5 up to the next integer. - * If we did that, we'd introduce a noticeable bias towards larger values. - * Instead, this code is arranged so that 0.5 will be rounded up or down at - * alternate pixel locations (a simple ordered dither pattern). - */ - -METHODDEF(void) -h2v1_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) -{ - JSAMPARRAY output_data = *output_data_ptr; - register JSAMPROW inptr, outptr; - register int invalue; - register JDIMENSION colctr; - int inrow; - - for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) { - inptr = input_data[inrow]; - outptr = output_data[inrow]; - /* Special case for first column */ - invalue = GETJSAMPLE(*inptr++); - *outptr++ = (JSAMPLE) invalue; - *outptr++ = (JSAMPLE) ((invalue * 3 + GETJSAMPLE(*inptr) + 2) >> 2); - - for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) { - /* General case: 3/4 * nearer pixel + 1/4 * further pixel */ - invalue = GETJSAMPLE(*inptr++) * 3; - *outptr++ = (JSAMPLE) ((invalue + GETJSAMPLE(inptr[-2]) + 1) >> 2); - *outptr++ = (JSAMPLE) ((invalue + GETJSAMPLE(*inptr) + 2) >> 2); - } - - /* Special case for last column */ - invalue = GETJSAMPLE(*inptr); - *outptr++ = (JSAMPLE) ((invalue * 3 + GETJSAMPLE(inptr[-1]) + 1) >> 2); - *outptr++ = (JSAMPLE) invalue; - } -} - - -/* - * Fancy processing for the common case of 2:1 horizontal and 2:1 vertical. - * Again a triangle filter; see comments for h2v1 case, above. - * - * It is OK for us to reference the adjacent input rows because we demanded - * context from the main buffer controller (see initialization code). - */ - -METHODDEF(void) -h2v2_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) -{ - JSAMPARRAY output_data = *output_data_ptr; - register JSAMPROW inptr0, inptr1, outptr; -#if BITS_IN_JSAMPLE == 8 - register int thiscolsum, lastcolsum, nextcolsum; -#else - register INT32 thiscolsum, lastcolsum, nextcolsum; -#endif - register JDIMENSION colctr; - int inrow, outrow, v; - - inrow = outrow = 0; - while (outrow < cinfo->max_v_samp_factor) { - for (v = 0; v < 2; v++) { - /* inptr0 points to nearest input row, inptr1 points to next nearest */ - inptr0 = input_data[inrow]; - if (v == 0) /* next nearest is row above */ - inptr1 = input_data[inrow-1]; - else /* next nearest is row below */ - inptr1 = input_data[inrow+1]; - outptr = output_data[outrow++]; - - /* Special case for first column */ - thiscolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++); - nextcolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++); - *outptr++ = (JSAMPLE) ((thiscolsum * 4 + 8) >> 4); - *outptr++ = (JSAMPLE) ((thiscolsum * 3 + nextcolsum + 7) >> 4); - lastcolsum = thiscolsum; thiscolsum = nextcolsum; - - for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) { - /* General case: 3/4 * nearer pixel + 1/4 * further pixel in each */ - /* dimension, thus 9/16, 3/16, 3/16, 1/16 overall */ - nextcolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++); - *outptr++ = (JSAMPLE) ((thiscolsum * 3 + lastcolsum + 8) >> 4); - *outptr++ = (JSAMPLE) ((thiscolsum * 3 + nextcolsum + 7) >> 4); - lastcolsum = thiscolsum; thiscolsum = nextcolsum; - } - - /* Special case for last column */ - *outptr++ = (JSAMPLE) ((thiscolsum * 3 + lastcolsum + 8) >> 4); - *outptr++ = (JSAMPLE) ((thiscolsum * 4 + 7) >> 4); - } - inrow++; - } -} - - -/* - * Module initialization routine for upsampling. - */ - -GLOBAL(void) -jinit_upsampler (j_decompress_ptr cinfo) -{ - my_upsample_ptr upsample; - int ci; - jpeg_component_info * compptr; - boolean need_buffer, do_fancy; - int h_in_group, v_in_group, h_out_group, v_out_group; - - upsample = (my_upsample_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_upsampler)); - cinfo->upsample = (struct jpeg_upsampler *) upsample; - upsample->pub.start_pass = start_pass_upsample; - upsample->pub.upsample = sep_upsample; - upsample->pub.need_context_rows = FALSE; /* until we find out differently */ - - if (cinfo->CCIR601_sampling) /* this isn't supported */ - ERREXIT(cinfo, JERR_CCIR601_NOTIMPL); - - /* jdmainct.c doesn't support context rows when min_DCT_scaled_size = 1, - * so don't ask for it. - */ - do_fancy = cinfo->do_fancy_upsampling && cinfo->min_DCT_scaled_size > 1; - - /* Verify we can handle the sampling factors, select per-component methods, - * and create storage as needed. - */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Compute size of an "input group" after IDCT scaling. This many samples - * are to be converted to max_h_samp_factor * max_v_samp_factor pixels. - */ - h_in_group = (compptr->h_samp_factor * compptr->DCT_scaled_size) / - cinfo->min_DCT_scaled_size; - v_in_group = (compptr->v_samp_factor * compptr->DCT_scaled_size) / - cinfo->min_DCT_scaled_size; - h_out_group = cinfo->max_h_samp_factor; - v_out_group = cinfo->max_v_samp_factor; - upsample->rowgroup_height[ci] = v_in_group; /* save for use later */ - need_buffer = TRUE; - if (! compptr->component_needed) { - /* Don't bother to upsample an uninteresting component. */ - upsample->methods[ci] = noop_upsample; - need_buffer = FALSE; - } else if (h_in_group == h_out_group && v_in_group == v_out_group) { - /* Fullsize components can be processed without any work. */ - upsample->methods[ci] = fullsize_upsample; - need_buffer = FALSE; - } else if (h_in_group * 2 == h_out_group && - v_in_group == v_out_group) { - /* Special cases for 2h1v upsampling */ - if (do_fancy && compptr->downsampled_width > 2) - upsample->methods[ci] = h2v1_fancy_upsample; - else - upsample->methods[ci] = h2v1_upsample; - } else if (h_in_group * 2 == h_out_group && - v_in_group * 2 == v_out_group) { - /* Special cases for 2h2v upsampling */ - if (do_fancy && compptr->downsampled_width > 2) { - upsample->methods[ci] = h2v2_fancy_upsample; - upsample->pub.need_context_rows = TRUE; - } else - upsample->methods[ci] = h2v2_upsample; - } else if ((h_out_group % h_in_group) == 0 && - (v_out_group % v_in_group) == 0) { - /* Generic integral-factors upsampling method */ - upsample->methods[ci] = int_upsample; - upsample->h_expand[ci] = (UINT8) (h_out_group / h_in_group); - upsample->v_expand[ci] = (UINT8) (v_out_group / v_in_group); - } else - ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL); - if (need_buffer) { - upsample->color_buf[ci] = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) jround_up((long) cinfo->output_width, - (long) cinfo->max_h_samp_factor), - (JDIMENSION) cinfo->max_v_samp_factor); - } - } -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jdtrans.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jdtrans.c deleted file mode 100644 index 12c193c88..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jdtrans.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - * jdtrans.c - * - * Copyright (C) 1995-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains library routines for transcoding decompression, - * that is, reading raw DCT coefficient arrays from an input JPEG file. - * The routines in jdapimin.c will also be needed by a transcoder. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Forward declarations */ -LOCAL(void) transdecode_master_selection JPP((j_decompress_ptr cinfo)); - - -/* - * Read the coefficient arrays from a JPEG file. - * jpeg_read_header must be completed before calling this. - * - * The entire image is read into a set of virtual coefficient-block arrays, - * one per component. The return value is a pointer to the array of - * virtual-array descriptors. These can be manipulated directly via the - * JPEG memory manager, or handed off to jpeg_write_coefficients(). - * To release the memory occupied by the virtual arrays, call - * jpeg_finish_decompress() when done with the data. - * - * An alternative usage is to simply obtain access to the coefficient arrays - * during a buffered-image-mode decompression operation. This is allowed - * after any jpeg_finish_output() call. The arrays can be accessed until - * jpeg_finish_decompress() is called. (Note that any call to the library - * may reposition the arrays, so don't rely on access_virt_barray() results - * to stay valid across library calls.) - * - * Returns NULL if suspended. This case need be checked only if - * a suspending data source is used. - */ - -GLOBAL(jvirt_barray_ptr *) -jpeg_read_coefficients (j_decompress_ptr cinfo) -{ - if (cinfo->global_state == DSTATE_READY) { - /* First call: initialize active modules */ - transdecode_master_selection(cinfo); - cinfo->global_state = DSTATE_RDCOEFS; - } - if (cinfo->global_state == DSTATE_RDCOEFS) { - /* Absorb whole file into the coef buffer */ - for (;;) { - int retcode; - /* Call progress monitor hook if present */ - if (cinfo->progress != NULL) - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - /* Absorb some more input */ - retcode = (*cinfo->inputctl->consume_input) (cinfo); - if (retcode == JPEG_SUSPENDED) - return NULL; - if (retcode == JPEG_REACHED_EOI) - break; - /* Advance progress counter if appropriate */ - if (cinfo->progress != NULL && - (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) { - if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) { - /* startup underestimated number of scans; ratchet up one scan */ - cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows; - } - } - } - /* Set state so that jpeg_finish_decompress does the right thing */ - cinfo->global_state = DSTATE_STOPPING; - } - /* At this point we should be in state DSTATE_STOPPING if being used - * standalone, or in state DSTATE_BUFIMAGE if being invoked to get access - * to the coefficients during a full buffered-image-mode decompression. - */ - if ((cinfo->global_state == DSTATE_STOPPING || - cinfo->global_state == DSTATE_BUFIMAGE) && cinfo->buffered_image) { - return cinfo->coef->coef_arrays; - } - /* Oops, improper usage */ - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - return NULL; /* keep compiler happy */ -} - - -/* - * Master selection of decompression modules for transcoding. - * This substitutes for jdmaster.c's initialization of the full decompressor. - */ - -LOCAL(void) -transdecode_master_selection (j_decompress_ptr cinfo) -{ - /* This is effectively a buffered-image operation. */ - cinfo->buffered_image = TRUE; - - /* Entropy decoding: either Huffman or arithmetic coding. */ - if (cinfo->arith_code) { - ERREXIT(cinfo, JERR_ARITH_NOTIMPL); - } else { - if (cinfo->progressive_mode) { -#ifdef D_PROGRESSIVE_SUPPORTED - jinit_phuff_decoder(cinfo); -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else - jinit_huff_decoder(cinfo); - } - - /* Always get a full-image coefficient buffer. */ - jinit_d_coef_controller(cinfo, TRUE); - - /* We can now tell the memory manager to allocate virtual arrays. */ - (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); - - /* Initialize input side of decompressor to consume first scan. */ - (*cinfo->inputctl->start_input_pass) (cinfo); - - /* Initialize progress monitoring. */ - if (cinfo->progress != NULL) { - int nscans; - /* Estimate number of scans to set pass_limit. */ - if (cinfo->progressive_mode) { - /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */ - nscans = 2 + 3 * cinfo->num_components; - } else if (cinfo->inputctl->has_multiple_scans) { - /* For a nonprogressive multiscan file, estimate 1 scan per component. */ - nscans = cinfo->num_components; - } else { - nscans = 1; - } - cinfo->progress->pass_counter = 0L; - cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans; - cinfo->progress->completed_passes = 0; - cinfo->progress->total_passes = 1; - } -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jerror.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jerror.c deleted file mode 100644 index c98aed76e..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jerror.c +++ /dev/null @@ -1,252 +0,0 @@ -/* - * jerror.c - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains simple error-reporting and trace-message routines. - * These are suitable for Unix-like systems and others where writing to - * stderr is the right thing to do. Many applications will want to replace - * some or all of these routines. - * - * If you define USE_WINDOWS_MESSAGEBOX in jconfig.h or in the makefile, - * you get a Windows-specific hack to display error messages in a dialog box. - * It ain't much, but it beats dropping error messages into the bit bucket, - * which is what happens to output to stderr under most Windows C compilers. - * - * These routines are used by both the compression and decompression code. - */ - -/* this is not a core library module, so it doesn't define JPEG_INTERNALS */ -#include "jinclude.h" -#include "jpeglib.h" -#include "jversion.h" -#include "jerror.h" - -#ifdef USE_WINDOWS_MESSAGEBOX -#include <windows.h> -#endif - -#ifndef EXIT_FAILURE /* define exit() codes if not provided */ -#define EXIT_FAILURE 1 -#endif - - -/* - * Create the message string table. - * We do this from the master message list in jerror.h by re-reading - * jerror.h with a suitable definition for macro JMESSAGE. - * The message table is made an external symbol just in case any applications - * want to refer to it directly. - */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jpeg_std_message_table jMsgTable -#endif - -#define JMESSAGE(code,string) string , - -const char * const jpeg_std_message_table[] = { -#include "jerror.h" - NULL -}; - - -/* - * Error exit handler: must not return to caller. - * - * Applications may override this if they want to get control back after - * an error. Typically one would longjmp somewhere instead of exiting. - * The setjmp buffer can be made a private field within an expanded error - * handler object. Note that the info needed to generate an error message - * is stored in the error object, so you can generate the message now or - * later, at your convenience. - * You should make sure that the JPEG object is cleaned up (with jpeg_abort - * or jpeg_destroy) at some point. - */ - -METHODDEF(void) -error_exit (j_common_ptr cinfo) -{ - /* Always display the message */ - (*cinfo->err->output_message) (cinfo); - - /* Let the memory manager delete any temp files before we die */ - jpeg_destroy(cinfo); - - exit(EXIT_FAILURE); -} - - -/* - * Actual output of an error or trace message. - * Applications may override this method to send JPEG messages somewhere - * other than stderr. - * - * On Windows, printing to stderr is generally completely useless, - * so we provide optional code to produce an error-dialog popup. - * Most Windows applications will still prefer to override this routine, - * but if they don't, it'll do something at least marginally useful. - * - * NOTE: to use the library in an environment that doesn't support the - * C stdio library, you may have to delete the call to fprintf() entirely, - * not just not use this routine. - */ - -METHODDEF(void) -output_message (j_common_ptr cinfo) -{ - char buffer[JMSG_LENGTH_MAX]; - - /* Create the message */ - (*cinfo->err->format_message) (cinfo, buffer); - -#ifdef USE_WINDOWS_MESSAGEBOX - /* Display it in a message dialog box */ - MessageBox(GetActiveWindow(), buffer, "JPEG Library Error", - MB_OK | MB_ICONERROR); -#else - /* Send it to stderr, adding a newline */ - fprintf(stderr, "%s\n", buffer); -#endif -} - - -/* - * Decide whether to emit a trace or warning message. - * msg_level is one of: - * -1: recoverable corrupt-data warning, may want to abort. - * 0: important advisory messages (always display to user). - * 1: first level of tracing detail. - * 2,3,...: successively more detailed tracing messages. - * An application might override this method if it wanted to abort on warnings - * or change the policy about which messages to display. - */ - -METHODDEF(void) -emit_message (j_common_ptr cinfo, int msg_level) -{ - struct jpeg_error_mgr * err = cinfo->err; - - if (msg_level < 0) { - /* It's a warning message. Since corrupt files may generate many warnings, - * the policy implemented here is to show only the first warning, - * unless trace_level >= 3. - */ - if (err->num_warnings == 0 || err->trace_level >= 3) - (*err->output_message) (cinfo); - /* Always count warnings in num_warnings. */ - err->num_warnings++; - } else { - /* It's a trace message. Show it if trace_level >= msg_level. */ - if (err->trace_level >= msg_level) - (*err->output_message) (cinfo); - } -} - - -/* - * Format a message string for the most recent JPEG error or message. - * The message is stored into buffer, which should be at least JMSG_LENGTH_MAX - * characters. Note that no '\n' character is added to the string. - * Few applications should need to override this method. - */ - -METHODDEF(void) -format_message (j_common_ptr cinfo, char * buffer) -{ - struct jpeg_error_mgr * err = cinfo->err; - int msg_code = err->msg_code; - const char * msgtext = NULL; - const char * msgptr; - char ch; - boolean isstring; - - /* Look up message string in proper table */ - if (msg_code > 0 && msg_code <= err->last_jpeg_message) { - msgtext = err->jpeg_message_table[msg_code]; - } else if (err->addon_message_table != NULL && - msg_code >= err->first_addon_message && - msg_code <= err->last_addon_message) { - msgtext = err->addon_message_table[msg_code - err->first_addon_message]; - } - - /* Defend against bogus message number */ - if (msgtext == NULL) { - err->msg_parm.i[0] = msg_code; - msgtext = err->jpeg_message_table[0]; - } - - /* Check for string parameter, as indicated by %s in the message text */ - isstring = FALSE; - msgptr = msgtext; - while ((ch = *msgptr++) != '\0') { - if (ch == '%') { - if (*msgptr == 's') isstring = TRUE; - break; - } - } - - /* Format the message into the passed buffer */ - if (isstring) - sprintf(buffer, msgtext, err->msg_parm.s); - else - sprintf(buffer, msgtext, - err->msg_parm.i[0], err->msg_parm.i[1], - err->msg_parm.i[2], err->msg_parm.i[3], - err->msg_parm.i[4], err->msg_parm.i[5], - err->msg_parm.i[6], err->msg_parm.i[7]); -} - - -/* - * Reset error state variables at start of a new image. - * This is called during compression startup to reset trace/error - * processing to default state, without losing any application-specific - * method pointers. An application might possibly want to override - * this method if it has additional error processing state. - */ - -METHODDEF(void) -reset_error_mgr (j_common_ptr cinfo) -{ - cinfo->err->num_warnings = 0; - /* trace_level is not reset since it is an application-supplied parameter */ - cinfo->err->msg_code = 0; /* may be useful as a flag for "no error" */ -} - - -/* - * Fill in the standard error-handling methods in a jpeg_error_mgr object. - * Typical call is: - * struct jpeg_compress_struct cinfo; - * struct jpeg_error_mgr err; - * - * cinfo.err = jpeg_std_error(&err); - * after which the application may override some of the methods. - */ - -GLOBAL(struct jpeg_error_mgr *) -jpeg_std_error (struct jpeg_error_mgr * err) -{ - err->error_exit = error_exit; - err->emit_message = emit_message; - err->output_message = output_message; - err->format_message = format_message; - err->reset_error_mgr = reset_error_mgr; - - err->trace_level = 0; /* default = no tracing */ - err->num_warnings = 0; /* no warnings emitted yet */ - err->msg_code = 0; /* may be useful as a flag for "no error" */ - - /* Initialize message table pointers */ - err->jpeg_message_table = jpeg_std_message_table; - err->last_jpeg_message = (int) JMSG_LASTMSGCODE - 1; - - err->addon_message_table = NULL; - err->first_addon_message = 0; /* for safety */ - err->last_addon_message = 0; - - return err; -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jerror.h b/irrlicht-1.6/source/Irrlicht/jpeglib/jerror.h deleted file mode 100644 index 79084f2e0..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jerror.h +++ /dev/null @@ -1,291 +0,0 @@ -/* - * jerror.h - * - * Copyright (C) 1994-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file defines the error and message codes for the JPEG library. - * Edit this file to add new codes, or to translate the message strings to - * some other language. - * A set of error-reporting macros are defined too. Some applications using - * the JPEG library may wish to include this file to get the error codes - * and/or the macros. - */ - -/* - * To define the enum list of message codes, include this file without - * defining macro JMESSAGE. To create a message string table, include it - * again with a suitable JMESSAGE definition (see jerror.c for an example). - */ -#ifndef JMESSAGE -#ifndef JERROR_H -/* First time through, define the enum list */ -#define JMAKE_ENUM_LIST -#else -/* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */ -#define JMESSAGE(code,string) -#endif /* JERROR_H */ -#endif /* JMESSAGE */ - -#ifdef JMAKE_ENUM_LIST - -typedef enum { - -#define JMESSAGE(code,string) code , - -#endif /* JMAKE_ENUM_LIST */ - -JMESSAGE(JMSG_NOMESSAGE, "Bogus message code %d") /* Must be first entry! */ - -/* For maintenance convenience, list is alphabetical by message code name */ -JMESSAGE(JERR_ARITH_NOTIMPL, - "Sorry, there are legal restrictions on arithmetic coding") -JMESSAGE(JERR_BAD_ALIGN_TYPE, "ALIGN_TYPE is wrong, please fix") -JMESSAGE(JERR_BAD_ALLOC_CHUNK, "MAX_ALLOC_CHUNK is wrong, please fix") -JMESSAGE(JERR_BAD_BUFFER_MODE, "Bogus buffer control mode") -JMESSAGE(JERR_BAD_COMPONENT_ID, "Invalid component ID %d in SOS") -JMESSAGE(JERR_BAD_DCT_COEF, "DCT coefficient out of range") -JMESSAGE(JERR_BAD_DCTSIZE, "IDCT output block size %d not supported") -JMESSAGE(JERR_BAD_HUFF_TABLE, "Bogus Huffman table definition") -JMESSAGE(JERR_BAD_IN_COLORSPACE, "Bogus input colorspace") -JMESSAGE(JERR_BAD_J_COLORSPACE, "Bogus JPEG colorspace") -JMESSAGE(JERR_BAD_LENGTH, "Bogus marker length") -JMESSAGE(JERR_BAD_LIB_VERSION, - "Wrong JPEG library version: library is %d, caller expects %d") -JMESSAGE(JERR_BAD_MCU_SIZE, "Sampling factors too large for interleaved scan") -JMESSAGE(JERR_BAD_POOL_ID, "Invalid memory pool code %d") -JMESSAGE(JERR_BAD_PRECISION, "Unsupported JPEG data precision %d") -JMESSAGE(JERR_BAD_PROGRESSION, - "Invalid progressive parameters Ss=%d Se=%d Ah=%d Al=%d") -JMESSAGE(JERR_BAD_PROG_SCRIPT, - "Invalid progressive parameters at scan script entry %d") -JMESSAGE(JERR_BAD_SAMPLING, "Bogus sampling factors") -JMESSAGE(JERR_BAD_SCAN_SCRIPT, "Invalid scan script at entry %d") -JMESSAGE(JERR_BAD_STATE, "Improper call to JPEG library in state %d") -JMESSAGE(JERR_BAD_STRUCT_SIZE, - "JPEG parameter struct mismatch: library thinks size is %u, caller expects %u") -JMESSAGE(JERR_BAD_VIRTUAL_ACCESS, "Bogus virtual array access") -JMESSAGE(JERR_BUFFER_SIZE, "Buffer passed to JPEG library is too small") -JMESSAGE(JERR_CANT_SUSPEND, "Suspension not allowed here") -JMESSAGE(JERR_CCIR601_NOTIMPL, "CCIR601 sampling not implemented yet") -JMESSAGE(JERR_COMPONENT_COUNT, "Too many color components: %d, max %d") -JMESSAGE(JERR_CONVERSION_NOTIMPL, "Unsupported color conversion request") -JMESSAGE(JERR_DAC_INDEX, "Bogus DAC index %d") -JMESSAGE(JERR_DAC_VALUE, "Bogus DAC value 0x%x") -JMESSAGE(JERR_DHT_INDEX, "Bogus DHT index %d") -JMESSAGE(JERR_DQT_INDEX, "Bogus DQT index %d") -JMESSAGE(JERR_EMPTY_IMAGE, "Empty JPEG image (DNL not supported)") -JMESSAGE(JERR_EMS_READ, "Read from EMS failed") -JMESSAGE(JERR_EMS_WRITE, "Write to EMS failed") -JMESSAGE(JERR_EOI_EXPECTED, "Didn't expect more than one scan") -JMESSAGE(JERR_FILE_READ, "Input file read error") -JMESSAGE(JERR_FILE_WRITE, "Output file write error --- out of disk space?") -JMESSAGE(JERR_FRACT_SAMPLE_NOTIMPL, "Fractional sampling not implemented yet") -JMESSAGE(JERR_HUFF_CLEN_OVERFLOW, "Huffman code size table overflow") -JMESSAGE(JERR_HUFF_MISSING_CODE, "Missing Huffman code table entry") -JMESSAGE(JERR_IMAGE_TOO_BIG, "Maximum supported image dimension is %u pixels") -JMESSAGE(JERR_INPUT_EMPTY, "Empty input file") -JMESSAGE(JERR_INPUT_EOF, "Premature end of input file") -JMESSAGE(JERR_MISMATCHED_QUANT_TABLE, - "Cannot transcode due to multiple use of quantization table %d") -JMESSAGE(JERR_MISSING_DATA, "Scan script does not transmit all data") -JMESSAGE(JERR_MODE_CHANGE, "Invalid color quantization mode change") -JMESSAGE(JERR_NOTIMPL, "Not implemented yet") -JMESSAGE(JERR_NOT_COMPILED, "Requested feature was omitted at compile time") -JMESSAGE(JERR_NO_BACKING_STORE, "Backing store not supported") -JMESSAGE(JERR_NO_HUFF_TABLE, "Huffman table 0x%02x was not defined") -JMESSAGE(JERR_NO_IMAGE, "JPEG datastream contains no image") -JMESSAGE(JERR_NO_QUANT_TABLE, "Quantization table 0x%02x was not defined") -JMESSAGE(JERR_NO_SOI, "Not a JPEG file: starts with 0x%02x 0x%02x") -JMESSAGE(JERR_OUT_OF_MEMORY, "Insufficient memory (case %d)") -JMESSAGE(JERR_QUANT_COMPONENTS, - "Cannot quantize more than %d color components") -JMESSAGE(JERR_QUANT_FEW_COLORS, "Cannot quantize to fewer than %d colors") -JMESSAGE(JERR_QUANT_MANY_COLORS, "Cannot quantize to more than %d colors") -JMESSAGE(JERR_SOF_DUPLICATE, "Invalid JPEG file structure: two SOF markers") -JMESSAGE(JERR_SOF_NO_SOS, "Invalid JPEG file structure: missing SOS marker") -JMESSAGE(JERR_SOF_UNSUPPORTED, "Unsupported JPEG process: SOF type 0x%02x") -JMESSAGE(JERR_SOI_DUPLICATE, "Invalid JPEG file structure: two SOI markers") -JMESSAGE(JERR_SOS_NO_SOF, "Invalid JPEG file structure: SOS before SOF") -JMESSAGE(JERR_TFILE_CREATE, "Failed to create temporary file %s") -JMESSAGE(JERR_TFILE_READ, "Read failed on temporary file") -JMESSAGE(JERR_TFILE_SEEK, "Seek failed on temporary file") -JMESSAGE(JERR_TFILE_WRITE, - "Write failed on temporary file --- out of disk space?") -JMESSAGE(JERR_TOO_LITTLE_DATA, "Application transferred too few scanlines") -JMESSAGE(JERR_UNKNOWN_MARKER, "Unsupported marker type 0x%02x") -JMESSAGE(JERR_VIRTUAL_BUG, "Virtual array controller messed up") -JMESSAGE(JERR_WIDTH_OVERFLOW, "Image too wide for this implementation") -JMESSAGE(JERR_XMS_READ, "Read from XMS failed") -JMESSAGE(JERR_XMS_WRITE, "Write to XMS failed") -JMESSAGE(JMSG_COPYRIGHT, JCOPYRIGHT) -JMESSAGE(JMSG_VERSION, JVERSION) -JMESSAGE(JTRC_16BIT_TABLES, - "Caution: quantization tables are too coarse for baseline JPEG") -JMESSAGE(JTRC_ADOBE, - "Adobe APP14 marker: version %d, flags 0x%04x 0x%04x, transform %d") -JMESSAGE(JTRC_APP0, "Unknown APP0 marker (not JFIF), length %u") -JMESSAGE(JTRC_APP14, "Unknown APP14 marker (not Adobe), length %u") -JMESSAGE(JTRC_DAC, "Define Arithmetic Table 0x%02x: 0x%02x") -JMESSAGE(JTRC_DHT, "Define Huffman Table 0x%02x") -JMESSAGE(JTRC_DQT, "Define Quantization Table %d precision %d") -JMESSAGE(JTRC_DRI, "Define Restart Interval %u") -JMESSAGE(JTRC_EMS_CLOSE, "Freed EMS handle %u") -JMESSAGE(JTRC_EMS_OPEN, "Obtained EMS handle %u") -JMESSAGE(JTRC_EOI, "End Of Image") -JMESSAGE(JTRC_HUFFBITS, " %3d %3d %3d %3d %3d %3d %3d %3d") -JMESSAGE(JTRC_JFIF, "JFIF APP0 marker: version %d.%02d, density %dx%d %d") -JMESSAGE(JTRC_JFIF_BADTHUMBNAILSIZE, - "Warning: thumbnail image size does not match data length %u") -JMESSAGE(JTRC_JFIF_EXTENSION, - "JFIF extension marker: type 0x%02x, length %u") -JMESSAGE(JTRC_JFIF_THUMBNAIL, " with %d x %d thumbnail image") -JMESSAGE(JTRC_MISC_MARKER, "Miscellaneous marker 0x%02x, length %u") -JMESSAGE(JTRC_PARMLESS_MARKER, "Unexpected marker 0x%02x") -JMESSAGE(JTRC_QUANTVALS, " %4u %4u %4u %4u %4u %4u %4u %4u") -JMESSAGE(JTRC_QUANT_3_NCOLORS, "Quantizing to %d = %d*%d*%d colors") -JMESSAGE(JTRC_QUANT_NCOLORS, "Quantizing to %d colors") -JMESSAGE(JTRC_QUANT_SELECTED, "Selected %d colors for quantization") -JMESSAGE(JTRC_RECOVERY_ACTION, "At marker 0x%02x, recovery action %d") -JMESSAGE(JTRC_RST, "RST%d") -JMESSAGE(JTRC_SMOOTH_NOTIMPL, - "Smoothing not supported with nonstandard sampling ratios") -JMESSAGE(JTRC_SOF, "Start Of Frame 0x%02x: width=%u, height=%u, components=%d") -JMESSAGE(JTRC_SOF_COMPONENT, " Component %d: %dhx%dv q=%d") -JMESSAGE(JTRC_SOI, "Start of Image") -JMESSAGE(JTRC_SOS, "Start Of Scan: %d components") -JMESSAGE(JTRC_SOS_COMPONENT, " Component %d: dc=%d ac=%d") -JMESSAGE(JTRC_SOS_PARAMS, " Ss=%d, Se=%d, Ah=%d, Al=%d") -JMESSAGE(JTRC_TFILE_CLOSE, "Closed temporary file %s") -JMESSAGE(JTRC_TFILE_OPEN, "Opened temporary file %s") -JMESSAGE(JTRC_THUMB_JPEG, - "JFIF extension marker: JPEG-compressed thumbnail image, length %u") -JMESSAGE(JTRC_THUMB_PALETTE, - "JFIF extension marker: palette thumbnail image, length %u") -JMESSAGE(JTRC_THUMB_RGB, - "JFIF extension marker: RGB thumbnail image, length %u") -JMESSAGE(JTRC_UNKNOWN_IDS, - "Unrecognized component IDs %d %d %d, assuming YCbCr") -JMESSAGE(JTRC_XMS_CLOSE, "Freed XMS handle %u") -JMESSAGE(JTRC_XMS_OPEN, "Obtained XMS handle %u") -JMESSAGE(JWRN_ADOBE_XFORM, "Unknown Adobe color transform code %d") -JMESSAGE(JWRN_BOGUS_PROGRESSION, - "Inconsistent progression sequence for component %d coefficient %d") -JMESSAGE(JWRN_EXTRANEOUS_DATA, - "Corrupt JPEG data: %u extraneous bytes before marker 0x%02x") -JMESSAGE(JWRN_HIT_MARKER, "Corrupt JPEG data: premature end of data segment") -JMESSAGE(JWRN_HUFF_BAD_CODE, "Corrupt JPEG data: bad Huffman code") -JMESSAGE(JWRN_JFIF_MAJOR, "Warning: unknown JFIF revision number %d.%02d") -JMESSAGE(JWRN_JPEG_EOF, "Premature end of JPEG file") -JMESSAGE(JWRN_MUST_RESYNC, - "Corrupt JPEG data: found marker 0x%02x instead of RST%d") -JMESSAGE(JWRN_NOT_SEQUENTIAL, "Invalid SOS parameters for sequential JPEG") -JMESSAGE(JWRN_TOO_MUCH_DATA, "Application transferred too many scanlines") - -#ifdef JMAKE_ENUM_LIST - - JMSG_LASTMSGCODE -} J_MESSAGE_CODE; - -#undef JMAKE_ENUM_LIST -#endif /* JMAKE_ENUM_LIST */ - -/* Zap JMESSAGE macro so that future re-inclusions do nothing by default */ -#undef JMESSAGE - - -#ifndef JERROR_H -#define JERROR_H - -/* Macros to simplify using the error and trace message stuff */ -/* The first parameter is either type of cinfo pointer */ - -/* Fatal errors (print message and exit) */ -#define ERREXIT(cinfo,code) \ - ((cinfo)->err->msg_code = (code), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXIT1(cinfo,code,p1) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXIT2(cinfo,code,p1,p2) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXIT3(cinfo,code,p1,p2,p3) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (cinfo)->err->msg_parm.i[2] = (p3), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXIT4(cinfo,code,p1,p2,p3,p4) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (cinfo)->err->msg_parm.i[2] = (p3), \ - (cinfo)->err->msg_parm.i[3] = (p4), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXITS(cinfo,code,str) \ - ((cinfo)->err->msg_code = (code), \ - strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) - -#define MAKESTMT(stuff) do { stuff } while (0) - -/* Nonfatal errors (we can keep going, but the data is probably corrupt) */ -#define WARNMS(cinfo,code) \ - ((cinfo)->err->msg_code = (code), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) -#define WARNMS1(cinfo,code,p1) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) -#define WARNMS2(cinfo,code,p1,p2) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) - -/* Informational/debugging messages */ -#define TRACEMS(cinfo,lvl,code) \ - ((cinfo)->err->msg_code = (code), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) -#define TRACEMS1(cinfo,lvl,code,p1) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) -#define TRACEMS2(cinfo,lvl,code,p1,p2) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) -#define TRACEMS3(cinfo,lvl,code,p1,p2,p3) \ - MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ - _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); \ - (cinfo)->err->msg_code = (code); \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) -#define TRACEMS4(cinfo,lvl,code,p1,p2,p3,p4) \ - MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ - _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ - (cinfo)->err->msg_code = (code); \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) -#define TRACEMS5(cinfo,lvl,code,p1,p2,p3,p4,p5) \ - MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ - _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ - _mp[4] = (p5); \ - (cinfo)->err->msg_code = (code); \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) -#define TRACEMS8(cinfo,lvl,code,p1,p2,p3,p4,p5,p6,p7,p8) \ - MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ - _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ - _mp[4] = (p5); _mp[5] = (p6); _mp[6] = (p7); _mp[7] = (p8); \ - (cinfo)->err->msg_code = (code); \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) -#define TRACEMSS(cinfo,lvl,code,str) \ - ((cinfo)->err->msg_code = (code), \ - strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) - -#endif /* JERROR_H */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jfdctflt.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jfdctflt.c deleted file mode 100644 index 7ccfb3802..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jfdctflt.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - * jfdctflt.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a floating-point implementation of the - * forward DCT (Discrete Cosine Transform). - * - * This implementation should be more accurate than either of the integer - * DCT implementations. However, it may not give the same results on all - * machines because of differences in roundoff behavior. Speed will depend - * on the hardware's floating point capacity. - * - * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT - * on each column. Direct algorithms are also available, but they are - * much more complex and seem not to be any faster when reduced to code. - * - * This implementation is based on Arai, Agui, and Nakajima's algorithm for - * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in - * Japanese, but the algorithm is described in the Pennebaker & Mitchell - * JPEG textbook (see REFERENCES section in file README). The following code - * is based directly on figure 4-8 in P&M. - * While an 8-point DCT cannot be done in less than 11 multiplies, it is - * possible to arrange the computation so that many of the multiplies are - * simple scalings of the final outputs. These multiplies can then be - * folded into the multiplications or divisions by the JPEG quantization - * table entries. The AA&N method leaves only 5 multiplies and 29 adds - * to be done in the DCT itself. - * The primary disadvantage of this method is that with a fixed-point - * implementation, accuracy is lost due to imprecise representation of the - * scaled quantization values. However, that problem does not arise if - * we use floating point arithmetic. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - -#ifdef DCT_FLOAT_SUPPORTED - - -/* - * This module is specialized to the case DCTSIZE = 8. - */ - -#if DCTSIZE != 8 - Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ -#endif - - -/* - * Perform the forward DCT on one block of samples. - */ - -GLOBAL(void) -jpeg_fdct_float (FAST_FLOAT * data) -{ - FAST_FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; - FAST_FLOAT tmp10, tmp11, tmp12, tmp13; - FAST_FLOAT z1, z2, z3, z4, z5, z11, z13; - FAST_FLOAT *dataptr; - int ctr; - - /* Pass 1: process rows. */ - - dataptr = data; - for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { - tmp0 = dataptr[0] + dataptr[7]; - tmp7 = dataptr[0] - dataptr[7]; - tmp1 = dataptr[1] + dataptr[6]; - tmp6 = dataptr[1] - dataptr[6]; - tmp2 = dataptr[2] + dataptr[5]; - tmp5 = dataptr[2] - dataptr[5]; - tmp3 = dataptr[3] + dataptr[4]; - tmp4 = dataptr[3] - dataptr[4]; - - /* Even part */ - - tmp10 = tmp0 + tmp3; /* phase 2 */ - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - dataptr[0] = tmp10 + tmp11; /* phase 3 */ - dataptr[4] = tmp10 - tmp11; - - z1 = (tmp12 + tmp13) * ((FAST_FLOAT) 0.707106781); /* c4 */ - dataptr[2] = tmp13 + z1; /* phase 5 */ - dataptr[6] = tmp13 - z1; - - /* Odd part */ - - tmp10 = tmp4 + tmp5; /* phase 2 */ - tmp11 = tmp5 + tmp6; - tmp12 = tmp6 + tmp7; - - /* The rotator is modified from fig 4-8 to avoid extra negations. */ - z5 = (tmp10 - tmp12) * ((FAST_FLOAT) 0.382683433); /* c6 */ - z2 = ((FAST_FLOAT) 0.541196100) * tmp10 + z5; /* c2-c6 */ - z4 = ((FAST_FLOAT) 1.306562965) * tmp12 + z5; /* c2+c6 */ - z3 = tmp11 * ((FAST_FLOAT) 0.707106781); /* c4 */ - - z11 = tmp7 + z3; /* phase 5 */ - z13 = tmp7 - z3; - - dataptr[5] = z13 + z2; /* phase 6 */ - dataptr[3] = z13 - z2; - dataptr[1] = z11 + z4; - dataptr[7] = z11 - z4; - - dataptr += DCTSIZE; /* advance pointer to next row */ - } - - /* Pass 2: process columns. */ - - dataptr = data; - for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { - tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7]; - tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7]; - tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6]; - tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6]; - tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5]; - tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5]; - tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4]; - tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4]; - - /* Even part */ - - tmp10 = tmp0 + tmp3; /* phase 2 */ - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - dataptr[DCTSIZE*0] = tmp10 + tmp11; /* phase 3 */ - dataptr[DCTSIZE*4] = tmp10 - tmp11; - - z1 = (tmp12 + tmp13) * ((FAST_FLOAT) 0.707106781); /* c4 */ - dataptr[DCTSIZE*2] = tmp13 + z1; /* phase 5 */ - dataptr[DCTSIZE*6] = tmp13 - z1; - - /* Odd part */ - - tmp10 = tmp4 + tmp5; /* phase 2 */ - tmp11 = tmp5 + tmp6; - tmp12 = tmp6 + tmp7; - - /* The rotator is modified from fig 4-8 to avoid extra negations. */ - z5 = (tmp10 - tmp12) * ((FAST_FLOAT) 0.382683433); /* c6 */ - z2 = ((FAST_FLOAT) 0.541196100) * tmp10 + z5; /* c2-c6 */ - z4 = ((FAST_FLOAT) 1.306562965) * tmp12 + z5; /* c2+c6 */ - z3 = tmp11 * ((FAST_FLOAT) 0.707106781); /* c4 */ - - z11 = tmp7 + z3; /* phase 5 */ - z13 = tmp7 - z3; - - dataptr[DCTSIZE*5] = z13 + z2; /* phase 6 */ - dataptr[DCTSIZE*3] = z13 - z2; - dataptr[DCTSIZE*1] = z11 + z4; - dataptr[DCTSIZE*7] = z11 - z4; - - dataptr++; /* advance pointer to next column */ - } -} - -#endif /* DCT_FLOAT_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jfdctfst.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jfdctfst.c deleted file mode 100644 index 005a74fe8..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jfdctfst.c +++ /dev/null @@ -1,224 +0,0 @@ -/* - * jfdctfst.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a fast, not so accurate integer implementation of the - * forward DCT (Discrete Cosine Transform). - * - * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT - * on each column. Direct algorithms are also available, but they are - * much more complex and seem not to be any faster when reduced to code. - * - * This implementation is based on Arai, Agui, and Nakajima's algorithm for - * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in - * Japanese, but the algorithm is described in the Pennebaker & Mitchell - * JPEG textbook (see REFERENCES section in file README). The following code - * is based directly on figure 4-8 in P&M. - * While an 8-point DCT cannot be done in less than 11 multiplies, it is - * possible to arrange the computation so that many of the multiplies are - * simple scalings of the final outputs. These multiplies can then be - * folded into the multiplications or divisions by the JPEG quantization - * table entries. The AA&N method leaves only 5 multiplies and 29 adds - * to be done in the DCT itself. - * The primary disadvantage of this method is that with fixed-point math, - * accuracy is lost due to imprecise representation of the scaled - * quantization values. The smaller the quantization table entry, the less - * precise the scaled value, so this implementation does worse with high- - * quality-setting files than with low-quality ones. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - -#ifdef DCT_IFAST_SUPPORTED - - -/* - * This module is specialized to the case DCTSIZE = 8. - */ - -#if DCTSIZE != 8 - Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ -#endif - - -/* Scaling decisions are generally the same as in the LL&M algorithm; - * see jfdctint.c for more details. However, we choose to descale - * (right shift) multiplication products as soon as they are formed, - * rather than carrying additional fractional bits into subsequent additions. - * This compromises accuracy slightly, but it lets us save a few shifts. - * More importantly, 16-bit arithmetic is then adequate (for 8-bit samples) - * everywhere except in the multiplications proper; this saves a good deal - * of work on 16-bit-int machines. - * - * Again to save a few shifts, the intermediate results between pass 1 and - * pass 2 are not upscaled, but are represented only to integral precision. - * - * A final compromise is to represent the multiplicative constants to only - * 8 fractional bits, rather than 13. This saves some shifting work on some - * machines, and may also reduce the cost of multiplication (since there - * are fewer one-bits in the constants). - */ - -#define CONST_BITS 8 - - -/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus - * causing a lot of useless floating-point operations at run time. - * To get around this we use the following pre-calculated constants. - * If you change CONST_BITS you may want to add appropriate values. - * (With a reasonable C compiler, you can just rely on the FIX() macro...) - */ - -#if CONST_BITS == 8 -#define FIX_0_382683433 ((INT32) 98) /* FIX(0.382683433) */ -#define FIX_0_541196100 ((INT32) 139) /* FIX(0.541196100) */ -#define FIX_0_707106781 ((INT32) 181) /* FIX(0.707106781) */ -#define FIX_1_306562965 ((INT32) 334) /* FIX(1.306562965) */ -#else -#define FIX_0_382683433 FIX(0.382683433) -#define FIX_0_541196100 FIX(0.541196100) -#define FIX_0_707106781 FIX(0.707106781) -#define FIX_1_306562965 FIX(1.306562965) -#endif - - -/* We can gain a little more speed, with a further compromise in accuracy, - * by omitting the addition in a descaling shift. This yields an incorrectly - * rounded result half the time... - */ - -#ifndef USE_ACCURATE_ROUNDING -#undef DESCALE -#define DESCALE(x,n) RIGHT_SHIFT(x, n) -#endif - - -/* Multiply a DCTELEM variable by an INT32 constant, and immediately - * descale to yield a DCTELEM result. - */ - -#define MULTIPLY(var,const) ((DCTELEM) DESCALE((var) * (const), CONST_BITS)) - - -/* - * Perform the forward DCT on one block of samples. - */ - -GLOBAL(void) -jpeg_fdct_ifast (DCTELEM * data) -{ - DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; - DCTELEM tmp10, tmp11, tmp12, tmp13; - DCTELEM z1, z2, z3, z4, z5, z11, z13; - DCTELEM *dataptr; - int ctr; - SHIFT_TEMPS - - /* Pass 1: process rows. */ - - dataptr = data; - for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { - tmp0 = dataptr[0] + dataptr[7]; - tmp7 = dataptr[0] - dataptr[7]; - tmp1 = dataptr[1] + dataptr[6]; - tmp6 = dataptr[1] - dataptr[6]; - tmp2 = dataptr[2] + dataptr[5]; - tmp5 = dataptr[2] - dataptr[5]; - tmp3 = dataptr[3] + dataptr[4]; - tmp4 = dataptr[3] - dataptr[4]; - - /* Even part */ - - tmp10 = tmp0 + tmp3; /* phase 2 */ - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - dataptr[0] = tmp10 + tmp11; /* phase 3 */ - dataptr[4] = tmp10 - tmp11; - - z1 = MULTIPLY(tmp12 + tmp13, FIX_0_707106781); /* c4 */ - dataptr[2] = tmp13 + z1; /* phase 5 */ - dataptr[6] = tmp13 - z1; - - /* Odd part */ - - tmp10 = tmp4 + tmp5; /* phase 2 */ - tmp11 = tmp5 + tmp6; - tmp12 = tmp6 + tmp7; - - /* The rotator is modified from fig 4-8 to avoid extra negations. */ - z5 = MULTIPLY(tmp10 - tmp12, FIX_0_382683433); /* c6 */ - z2 = MULTIPLY(tmp10, FIX_0_541196100) + z5; /* c2-c6 */ - z4 = MULTIPLY(tmp12, FIX_1_306562965) + z5; /* c2+c6 */ - z3 = MULTIPLY(tmp11, FIX_0_707106781); /* c4 */ - - z11 = tmp7 + z3; /* phase 5 */ - z13 = tmp7 - z3; - - dataptr[5] = z13 + z2; /* phase 6 */ - dataptr[3] = z13 - z2; - dataptr[1] = z11 + z4; - dataptr[7] = z11 - z4; - - dataptr += DCTSIZE; /* advance pointer to next row */ - } - - /* Pass 2: process columns. */ - - dataptr = data; - for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { - tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7]; - tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7]; - tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6]; - tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6]; - tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5]; - tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5]; - tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4]; - tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4]; - - /* Even part */ - - tmp10 = tmp0 + tmp3; /* phase 2 */ - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - dataptr[DCTSIZE*0] = tmp10 + tmp11; /* phase 3 */ - dataptr[DCTSIZE*4] = tmp10 - tmp11; - - z1 = MULTIPLY(tmp12 + tmp13, FIX_0_707106781); /* c4 */ - dataptr[DCTSIZE*2] = tmp13 + z1; /* phase 5 */ - dataptr[DCTSIZE*6] = tmp13 - z1; - - /* Odd part */ - - tmp10 = tmp4 + tmp5; /* phase 2 */ - tmp11 = tmp5 + tmp6; - tmp12 = tmp6 + tmp7; - - /* The rotator is modified from fig 4-8 to avoid extra negations. */ - z5 = MULTIPLY(tmp10 - tmp12, FIX_0_382683433); /* c6 */ - z2 = MULTIPLY(tmp10, FIX_0_541196100) + z5; /* c2-c6 */ - z4 = MULTIPLY(tmp12, FIX_1_306562965) + z5; /* c2+c6 */ - z3 = MULTIPLY(tmp11, FIX_0_707106781); /* c4 */ - - z11 = tmp7 + z3; /* phase 5 */ - z13 = tmp7 - z3; - - dataptr[DCTSIZE*5] = z13 + z2; /* phase 6 */ - dataptr[DCTSIZE*3] = z13 - z2; - dataptr[DCTSIZE*1] = z11 + z4; - dataptr[DCTSIZE*7] = z11 - z4; - - dataptr++; /* advance pointer to next column */ - } -} - -#endif /* DCT_IFAST_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jfdctint.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jfdctint.c deleted file mode 100644 index d62692743..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jfdctint.c +++ /dev/null @@ -1,283 +0,0 @@ -/* - * jfdctint.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a slow-but-accurate integer implementation of the - * forward DCT (Discrete Cosine Transform). - * - * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT - * on each column. Direct algorithms are also available, but they are - * much more complex and seem not to be any faster when reduced to code. - * - * This implementation is based on an algorithm described in - * C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT - * Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics, - * Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991. - * The primary algorithm described there uses 11 multiplies and 29 adds. - * We use their alternate method with 12 multiplies and 32 adds. - * The advantage of this method is that no data path contains more than one - * multiplication; this allows a very simple and accurate implementation in - * scaled fixed-point arithmetic, with a minimal number of shifts. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - -#ifdef DCT_ISLOW_SUPPORTED - - -/* - * This module is specialized to the case DCTSIZE = 8. - */ - -#if DCTSIZE != 8 - Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ -#endif - - -/* - * The poop on this scaling stuff is as follows: - * - * Each 1-D DCT step produces outputs which are a factor of sqrt(N) - * larger than the true DCT outputs. The final outputs are therefore - * a factor of N larger than desired; since N=8 this can be cured by - * a simple right shift at the end of the algorithm. The advantage of - * this arrangement is that we save two multiplications per 1-D DCT, - * because the y0 and y4 outputs need not be divided by sqrt(N). - * In the IJG code, this factor of 8 is removed by the quantization step - * (in jcdctmgr.c), NOT in this module. - * - * We have to do addition and subtraction of the integer inputs, which - * is no problem, and multiplication by fractional constants, which is - * a problem to do in integer arithmetic. We multiply all the constants - * by CONST_SCALE and convert them to integer constants (thus retaining - * CONST_BITS bits of precision in the constants). After doing a - * multiplication we have to divide the product by CONST_SCALE, with proper - * rounding, to produce the correct output. This division can be done - * cheaply as a right shift of CONST_BITS bits. We postpone shifting - * as long as possible so that partial sums can be added together with - * full fractional precision. - * - * The outputs of the first pass are scaled up by PASS1_BITS bits so that - * they are represented to better-than-integral precision. These outputs - * require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word - * with the recommended scaling. (For 12-bit sample data, the intermediate - * array is INT32 anyway.) - * - * To avoid overflow of the 32-bit intermediate results in pass 2, we must - * have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26. Error analysis - * shows that the values given below are the most effective. - */ - -#if BITS_IN_JSAMPLE == 8 -#define CONST_BITS 13 -#define PASS1_BITS 2 -#else -#define CONST_BITS 13 -#define PASS1_BITS 1 /* lose a little precision to avoid overflow */ -#endif - -/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus - * causing a lot of useless floating-point operations at run time. - * To get around this we use the following pre-calculated constants. - * If you change CONST_BITS you may want to add appropriate values. - * (With a reasonable C compiler, you can just rely on the FIX() macro...) - */ - -#if CONST_BITS == 13 -#define FIX_0_298631336 ((INT32) 2446) /* FIX(0.298631336) */ -#define FIX_0_390180644 ((INT32) 3196) /* FIX(0.390180644) */ -#define FIX_0_541196100 ((INT32) 4433) /* FIX(0.541196100) */ -#define FIX_0_765366865 ((INT32) 6270) /* FIX(0.765366865) */ -#define FIX_0_899976223 ((INT32) 7373) /* FIX(0.899976223) */ -#define FIX_1_175875602 ((INT32) 9633) /* FIX(1.175875602) */ -#define FIX_1_501321110 ((INT32) 12299) /* FIX(1.501321110) */ -#define FIX_1_847759065 ((INT32) 15137) /* FIX(1.847759065) */ -#define FIX_1_961570560 ((INT32) 16069) /* FIX(1.961570560) */ -#define FIX_2_053119869 ((INT32) 16819) /* FIX(2.053119869) */ -#define FIX_2_562915447 ((INT32) 20995) /* FIX(2.562915447) */ -#define FIX_3_072711026 ((INT32) 25172) /* FIX(3.072711026) */ -#else -#define FIX_0_298631336 FIX(0.298631336) -#define FIX_0_390180644 FIX(0.390180644) -#define FIX_0_541196100 FIX(0.541196100) -#define FIX_0_765366865 FIX(0.765366865) -#define FIX_0_899976223 FIX(0.899976223) -#define FIX_1_175875602 FIX(1.175875602) -#define FIX_1_501321110 FIX(1.501321110) -#define FIX_1_847759065 FIX(1.847759065) -#define FIX_1_961570560 FIX(1.961570560) -#define FIX_2_053119869 FIX(2.053119869) -#define FIX_2_562915447 FIX(2.562915447) -#define FIX_3_072711026 FIX(3.072711026) -#endif - - -/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. - * For 8-bit samples with the recommended scaling, all the variable - * and constant values involved are no more than 16 bits wide, so a - * 16x16->32 bit multiply can be used instead of a full 32x32 multiply. - * For 12-bit samples, a full 32-bit multiplication will be needed. - */ - -#if BITS_IN_JSAMPLE == 8 -#define MULTIPLY(var,const) MULTIPLY16C16(var,const) -#else -#define MULTIPLY(var,const) ((var) * (const)) -#endif - - -/* - * Perform the forward DCT on one block of samples. - */ - -GLOBAL(void) -jpeg_fdct_islow (DCTELEM * data) -{ - INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; - INT32 tmp10, tmp11, tmp12, tmp13; - INT32 z1, z2, z3, z4, z5; - DCTELEM *dataptr; - int ctr; - SHIFT_TEMPS - - /* Pass 1: process rows. */ - /* Note results are scaled up by sqrt(8) compared to a true DCT; */ - /* furthermore, we scale the results by 2**PASS1_BITS. */ - - dataptr = data; - for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { - tmp0 = dataptr[0] + dataptr[7]; - tmp7 = dataptr[0] - dataptr[7]; - tmp1 = dataptr[1] + dataptr[6]; - tmp6 = dataptr[1] - dataptr[6]; - tmp2 = dataptr[2] + dataptr[5]; - tmp5 = dataptr[2] - dataptr[5]; - tmp3 = dataptr[3] + dataptr[4]; - tmp4 = dataptr[3] - dataptr[4]; - - /* Even part per LL&M figure 1 --- note that published figure is faulty; - * rotator "sqrt(2)*c1" should be "sqrt(2)*c6". - */ - - tmp10 = tmp0 + tmp3; - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - dataptr[0] = (DCTELEM) ((tmp10 + tmp11) << PASS1_BITS); - dataptr[4] = (DCTELEM) ((tmp10 - tmp11) << PASS1_BITS); - - z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); - dataptr[2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865), - CONST_BITS-PASS1_BITS); - dataptr[6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065), - CONST_BITS-PASS1_BITS); - - /* Odd part per figure 8 --- note paper omits factor of sqrt(2). - * cK represents cos(K*pi/16). - * i0..i3 in the paper are tmp4..tmp7 here. - */ - - z1 = tmp4 + tmp7; - z2 = tmp5 + tmp6; - z3 = tmp4 + tmp6; - z4 = tmp5 + tmp7; - z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ - - tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ - tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ - tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ - tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ - z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ - z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ - z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ - z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ - - z3 += z5; - z4 += z5; - - dataptr[7] = (DCTELEM) DESCALE(tmp4 + z1 + z3, CONST_BITS-PASS1_BITS); - dataptr[5] = (DCTELEM) DESCALE(tmp5 + z2 + z4, CONST_BITS-PASS1_BITS); - dataptr[3] = (DCTELEM) DESCALE(tmp6 + z2 + z3, CONST_BITS-PASS1_BITS); - dataptr[1] = (DCTELEM) DESCALE(tmp7 + z1 + z4, CONST_BITS-PASS1_BITS); - - dataptr += DCTSIZE; /* advance pointer to next row */ - } - - /* Pass 2: process columns. - * We remove the PASS1_BITS scaling, but leave the results scaled up - * by an overall factor of 8. - */ - - dataptr = data; - for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { - tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7]; - tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7]; - tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6]; - tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6]; - tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5]; - tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5]; - tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4]; - tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4]; - - /* Even part per LL&M figure 1 --- note that published figure is faulty; - * rotator "sqrt(2)*c1" should be "sqrt(2)*c6". - */ - - tmp10 = tmp0 + tmp3; - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - dataptr[DCTSIZE*0] = (DCTELEM) DESCALE(tmp10 + tmp11, PASS1_BITS); - dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(tmp10 - tmp11, PASS1_BITS); - - z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); - dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865), - CONST_BITS+PASS1_BITS); - dataptr[DCTSIZE*6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065), - CONST_BITS+PASS1_BITS); - - /* Odd part per figure 8 --- note paper omits factor of sqrt(2). - * cK represents cos(K*pi/16). - * i0..i3 in the paper are tmp4..tmp7 here. - */ - - z1 = tmp4 + tmp7; - z2 = tmp5 + tmp6; - z3 = tmp4 + tmp6; - z4 = tmp5 + tmp7; - z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ - - tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ - tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ - tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ - tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ - z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ - z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ - z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ - z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ - - z3 += z5; - z4 += z5; - - dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp4 + z1 + z3, - CONST_BITS+PASS1_BITS); - dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp5 + z2 + z4, - CONST_BITS+PASS1_BITS); - dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp6 + z2 + z3, - CONST_BITS+PASS1_BITS); - dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp7 + z1 + z4, - CONST_BITS+PASS1_BITS); - - dataptr++; /* advance pointer to next column */ - } -} - -#endif /* DCT_ISLOW_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jidctflt.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jidctflt.c deleted file mode 100644 index 5fea54c23..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jidctflt.c +++ /dev/null @@ -1,242 +0,0 @@ -/* - * jidctflt.c - * - * Copyright (C) 1994-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a floating-point implementation of the - * inverse DCT (Discrete Cosine Transform). In the IJG code, this routine - * must also perform dequantization of the input coefficients. - * - * This implementation should be more accurate than either of the integer - * IDCT implementations. However, it may not give the same results on all - * machines because of differences in roundoff behavior. Speed will depend - * on the hardware's floating point capacity. - * - * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT - * on each row (or vice versa, but it's more convenient to emit a row at - * a time). Direct algorithms are also available, but they are much more - * complex and seem not to be any faster when reduced to code. - * - * This implementation is based on Arai, Agui, and Nakajima's algorithm for - * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in - * Japanese, but the algorithm is described in the Pennebaker & Mitchell - * JPEG textbook (see REFERENCES section in file README). The following code - * is based directly on figure 4-8 in P&M. - * While an 8-point DCT cannot be done in less than 11 multiplies, it is - * possible to arrange the computation so that many of the multiplies are - * simple scalings of the final outputs. These multiplies can then be - * folded into the multiplications or divisions by the JPEG quantization - * table entries. The AA&N method leaves only 5 multiplies and 29 adds - * to be done in the DCT itself. - * The primary disadvantage of this method is that with a fixed-point - * implementation, accuracy is lost due to imprecise representation of the - * scaled quantization values. However, that problem does not arise if - * we use floating point arithmetic. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - -#ifdef DCT_FLOAT_SUPPORTED - - -/* - * This module is specialized to the case DCTSIZE = 8. - */ - -#if DCTSIZE != 8 - Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ -#endif - - -/* Dequantize a coefficient by multiplying it by the multiplier-table - * entry; produce a float result. - */ - -#define DEQUANTIZE(coef,quantval) (((FAST_FLOAT) (coef)) * (quantval)) - - -/* - * Perform dequantization and inverse DCT on one block of coefficients. - */ - -GLOBAL(void) -jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, - JSAMPARRAY output_buf, JDIMENSION output_col) -{ - FAST_FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; - FAST_FLOAT tmp10, tmp11, tmp12, tmp13; - FAST_FLOAT z5, z10, z11, z12, z13; - JCOEFPTR inptr; - FLOAT_MULT_TYPE * quantptr; - FAST_FLOAT * wsptr; - JSAMPROW outptr; - JSAMPLE *range_limit = IDCT_range_limit(cinfo); - int ctr; - FAST_FLOAT workspace[DCTSIZE2]; /* buffers data between passes */ - SHIFT_TEMPS - - /* Pass 1: process columns from input, store into work array. */ - - inptr = coef_block; - quantptr = (FLOAT_MULT_TYPE *) compptr->dct_table; - wsptr = workspace; - for (ctr = DCTSIZE; ctr > 0; ctr--) { - /* Due to quantization, we will usually find that many of the input - * coefficients are zero, especially the AC terms. We can exploit this - * by short-circuiting the IDCT calculation for any column in which all - * the AC terms are zero. In that case each output is equal to the - * DC coefficient (with scale factor as needed). - * With typical images and quantization tables, half or more of the - * column DCT calculations can be simplified this way. - */ - - if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && - inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 && - inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 && - inptr[DCTSIZE*7] == 0) { - /* AC terms all zero */ - FAST_FLOAT dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); - - wsptr[DCTSIZE*0] = dcval; - wsptr[DCTSIZE*1] = dcval; - wsptr[DCTSIZE*2] = dcval; - wsptr[DCTSIZE*3] = dcval; - wsptr[DCTSIZE*4] = dcval; - wsptr[DCTSIZE*5] = dcval; - wsptr[DCTSIZE*6] = dcval; - wsptr[DCTSIZE*7] = dcval; - - inptr++; /* advance pointers to next column */ - quantptr++; - wsptr++; - continue; - } - - /* Even part */ - - tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); - tmp1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); - tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); - tmp3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); - - tmp10 = tmp0 + tmp2; /* phase 3 */ - tmp11 = tmp0 - tmp2; - - tmp13 = tmp1 + tmp3; /* phases 5-3 */ - tmp12 = (tmp1 - tmp3) * ((FAST_FLOAT) 1.414213562) - tmp13; /* 2*c4 */ - - tmp0 = tmp10 + tmp13; /* phase 2 */ - tmp3 = tmp10 - tmp13; - tmp1 = tmp11 + tmp12; - tmp2 = tmp11 - tmp12; - - /* Odd part */ - - tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); - tmp5 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); - tmp6 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); - tmp7 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); - - z13 = tmp6 + tmp5; /* phase 6 */ - z10 = tmp6 - tmp5; - z11 = tmp4 + tmp7; - z12 = tmp4 - tmp7; - - tmp7 = z11 + z13; /* phase 5 */ - tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562); /* 2*c4 */ - - z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */ - tmp10 = ((FAST_FLOAT) 1.082392200) * z12 - z5; /* 2*(c2-c6) */ - tmp12 = ((FAST_FLOAT) -2.613125930) * z10 + z5; /* -2*(c2+c6) */ - - tmp6 = tmp12 - tmp7; /* phase 2 */ - tmp5 = tmp11 - tmp6; - tmp4 = tmp10 + tmp5; - - wsptr[DCTSIZE*0] = tmp0 + tmp7; - wsptr[DCTSIZE*7] = tmp0 - tmp7; - wsptr[DCTSIZE*1] = tmp1 + tmp6; - wsptr[DCTSIZE*6] = tmp1 - tmp6; - wsptr[DCTSIZE*2] = tmp2 + tmp5; - wsptr[DCTSIZE*5] = tmp2 - tmp5; - wsptr[DCTSIZE*4] = tmp3 + tmp4; - wsptr[DCTSIZE*3] = tmp3 - tmp4; - - inptr++; /* advance pointers to next column */ - quantptr++; - wsptr++; - } - - /* Pass 2: process rows from work array, store into output array. */ - /* Note that we must descale the results by a factor of 8 == 2**3. */ - - wsptr = workspace; - for (ctr = 0; ctr < DCTSIZE; ctr++) { - outptr = output_buf[ctr] + output_col; - /* Rows of zeroes can be exploited in the same way as we did with columns. - * However, the column calculation has created many nonzero AC terms, so - * the simplification applies less often (typically 5% to 10% of the time). - * And testing floats for zero is relatively expensive, so we don't bother. - */ - - /* Even part */ - - tmp10 = wsptr[0] + wsptr[4]; - tmp11 = wsptr[0] - wsptr[4]; - - tmp13 = wsptr[2] + wsptr[6]; - tmp12 = (wsptr[2] - wsptr[6]) * ((FAST_FLOAT) 1.414213562) - tmp13; - - tmp0 = tmp10 + tmp13; - tmp3 = tmp10 - tmp13; - tmp1 = tmp11 + tmp12; - tmp2 = tmp11 - tmp12; - - /* Odd part */ - - z13 = wsptr[5] + wsptr[3]; - z10 = wsptr[5] - wsptr[3]; - z11 = wsptr[1] + wsptr[7]; - z12 = wsptr[1] - wsptr[7]; - - tmp7 = z11 + z13; - tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562); - - z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */ - tmp10 = ((FAST_FLOAT) 1.082392200) * z12 - z5; /* 2*(c2-c6) */ - tmp12 = ((FAST_FLOAT) -2.613125930) * z10 + z5; /* -2*(c2+c6) */ - - tmp6 = tmp12 - tmp7; - tmp5 = tmp11 - tmp6; - tmp4 = tmp10 + tmp5; - - /* Final output stage: scale down by a factor of 8 and range-limit */ - - outptr[0] = range_limit[(int) DESCALE((INT32) (tmp0 + tmp7), 3) - & RANGE_MASK]; - outptr[7] = range_limit[(int) DESCALE((INT32) (tmp0 - tmp7), 3) - & RANGE_MASK]; - outptr[1] = range_limit[(int) DESCALE((INT32) (tmp1 + tmp6), 3) - & RANGE_MASK]; - outptr[6] = range_limit[(int) DESCALE((INT32) (tmp1 - tmp6), 3) - & RANGE_MASK]; - outptr[2] = range_limit[(int) DESCALE((INT32) (tmp2 + tmp5), 3) - & RANGE_MASK]; - outptr[5] = range_limit[(int) DESCALE((INT32) (tmp2 - tmp5), 3) - & RANGE_MASK]; - outptr[4] = range_limit[(int) DESCALE((INT32) (tmp3 + tmp4), 3) - & RANGE_MASK]; - outptr[3] = range_limit[(int) DESCALE((INT32) (tmp3 - tmp4), 3) - & RANGE_MASK]; - - wsptr += DCTSIZE; /* advance pointer to next row */ - } -} - -#endif /* DCT_FLOAT_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jidctfst.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jidctfst.c deleted file mode 100644 index 078b8c444..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jidctfst.c +++ /dev/null @@ -1,368 +0,0 @@ -/* - * jidctfst.c - * - * Copyright (C) 1994-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a fast, not so accurate integer implementation of the - * inverse DCT (Discrete Cosine Transform). In the IJG code, this routine - * must also perform dequantization of the input coefficients. - * - * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT - * on each row (or vice versa, but it's more convenient to emit a row at - * a time). Direct algorithms are also available, but they are much more - * complex and seem not to be any faster when reduced to code. - * - * This implementation is based on Arai, Agui, and Nakajima's algorithm for - * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in - * Japanese, but the algorithm is described in the Pennebaker & Mitchell - * JPEG textbook (see REFERENCES section in file README). The following code - * is based directly on figure 4-8 in P&M. - * While an 8-point DCT cannot be done in less than 11 multiplies, it is - * possible to arrange the computation so that many of the multiplies are - * simple scalings of the final outputs. These multiplies can then be - * folded into the multiplications or divisions by the JPEG quantization - * table entries. The AA&N method leaves only 5 multiplies and 29 adds - * to be done in the DCT itself. - * The primary disadvantage of this method is that with fixed-point math, - * accuracy is lost due to imprecise representation of the scaled - * quantization values. The smaller the quantization table entry, the less - * precise the scaled value, so this implementation does worse with high- - * quality-setting files than with low-quality ones. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - -#ifdef DCT_IFAST_SUPPORTED - - -/* - * This module is specialized to the case DCTSIZE = 8. - */ - -#if DCTSIZE != 8 - Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ -#endif - - -/* Scaling decisions are generally the same as in the LL&M algorithm; - * see jidctint.c for more details. However, we choose to descale - * (right shift) multiplication products as soon as they are formed, - * rather than carrying additional fractional bits into subsequent additions. - * This compromises accuracy slightly, but it lets us save a few shifts. - * More importantly, 16-bit arithmetic is then adequate (for 8-bit samples) - * everywhere except in the multiplications proper; this saves a good deal - * of work on 16-bit-int machines. - * - * The dequantized coefficients are not integers because the AA&N scaling - * factors have been incorporated. We represent them scaled up by PASS1_BITS, - * so that the first and second IDCT rounds have the same input scaling. - * For 8-bit JSAMPLEs, we choose IFAST_SCALE_BITS = PASS1_BITS so as to - * avoid a descaling shift; this compromises accuracy rather drastically - * for small quantization table entries, but it saves a lot of shifts. - * For 12-bit JSAMPLEs, there's no hope of using 16x16 multiplies anyway, - * so we use a much larger scaling factor to preserve accuracy. - * - * A final compromise is to represent the multiplicative constants to only - * 8 fractional bits, rather than 13. This saves some shifting work on some - * machines, and may also reduce the cost of multiplication (since there - * are fewer one-bits in the constants). - */ - -#if BITS_IN_JSAMPLE == 8 -#define CONST_BITS 8 -#define PASS1_BITS 2 -#else -#define CONST_BITS 8 -#define PASS1_BITS 1 /* lose a little precision to avoid overflow */ -#endif - -/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus - * causing a lot of useless floating-point operations at run time. - * To get around this we use the following pre-calculated constants. - * If you change CONST_BITS you may want to add appropriate values. - * (With a reasonable C compiler, you can just rely on the FIX() macro...) - */ - -#if CONST_BITS == 8 -#define FIX_1_082392200 ((INT32) 277) /* FIX(1.082392200) */ -#define FIX_1_414213562 ((INT32) 362) /* FIX(1.414213562) */ -#define FIX_1_847759065 ((INT32) 473) /* FIX(1.847759065) */ -#define FIX_2_613125930 ((INT32) 669) /* FIX(2.613125930) */ -#else -#define FIX_1_082392200 FIX(1.082392200) -#define FIX_1_414213562 FIX(1.414213562) -#define FIX_1_847759065 FIX(1.847759065) -#define FIX_2_613125930 FIX(2.613125930) -#endif - - -/* We can gain a little more speed, with a further compromise in accuracy, - * by omitting the addition in a descaling shift. This yields an incorrectly - * rounded result half the time... - */ - -#ifndef USE_ACCURATE_ROUNDING -#undef DESCALE -#define DESCALE(x,n) RIGHT_SHIFT(x, n) -#endif - - -/* Multiply a DCTELEM variable by an INT32 constant, and immediately - * descale to yield a DCTELEM result. - */ - -#define MULTIPLY(var,const) ((DCTELEM) DESCALE((var) * (const), CONST_BITS)) - - -/* Dequantize a coefficient by multiplying it by the multiplier-table - * entry; produce a DCTELEM result. For 8-bit data a 16x16->16 - * multiplication will do. For 12-bit data, the multiplier table is - * declared INT32, so a 32-bit multiply will be used. - */ - -#if BITS_IN_JSAMPLE == 8 -#define DEQUANTIZE(coef,quantval) (((IFAST_MULT_TYPE) (coef)) * (quantval)) -#else -#define DEQUANTIZE(coef,quantval) \ - DESCALE((coef)*(quantval), IFAST_SCALE_BITS-PASS1_BITS) -#endif - - -/* Like DESCALE, but applies to a DCTELEM and produces an int. - * We assume that int right shift is unsigned if INT32 right shift is. - */ - -#ifdef RIGHT_SHIFT_IS_UNSIGNED -#define ISHIFT_TEMPS DCTELEM ishift_temp; -#if BITS_IN_JSAMPLE == 8 -#define DCTELEMBITS 16 /* DCTELEM may be 16 or 32 bits */ -#else -#define DCTELEMBITS 32 /* DCTELEM must be 32 bits */ -#endif -#define IRIGHT_SHIFT(x,shft) \ - ((ishift_temp = (x)) < 0 ? \ - (ishift_temp >> (shft)) | ((~((DCTELEM) 0)) << (DCTELEMBITS-(shft))) : \ - (ishift_temp >> (shft))) -#else -#define ISHIFT_TEMPS -#define IRIGHT_SHIFT(x,shft) ((x) >> (shft)) -#endif - -#ifdef USE_ACCURATE_ROUNDING -#define IDESCALE(x,n) ((int) IRIGHT_SHIFT((x) + (1 << ((n)-1)), n)) -#else -#define IDESCALE(x,n) ((int) IRIGHT_SHIFT(x, n)) -#endif - - -/* - * Perform dequantization and inverse DCT on one block of coefficients. - */ - -GLOBAL(void) -jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, - JSAMPARRAY output_buf, JDIMENSION output_col) -{ - DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; - DCTELEM tmp10, tmp11, tmp12, tmp13; - DCTELEM z5, z10, z11, z12, z13; - JCOEFPTR inptr; - IFAST_MULT_TYPE * quantptr; - int * wsptr; - JSAMPROW outptr; - JSAMPLE *range_limit = IDCT_range_limit(cinfo); - int ctr; - int workspace[DCTSIZE2]; /* buffers data between passes */ - SHIFT_TEMPS /* for DESCALE */ - ISHIFT_TEMPS /* for IDESCALE */ - - /* Pass 1: process columns from input, store into work array. */ - - inptr = coef_block; - quantptr = (IFAST_MULT_TYPE *) compptr->dct_table; - wsptr = workspace; - for (ctr = DCTSIZE; ctr > 0; ctr--) { - /* Due to quantization, we will usually find that many of the input - * coefficients are zero, especially the AC terms. We can exploit this - * by short-circuiting the IDCT calculation for any column in which all - * the AC terms are zero. In that case each output is equal to the - * DC coefficient (with scale factor as needed). - * With typical images and quantization tables, half or more of the - * column DCT calculations can be simplified this way. - */ - - if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && - inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 && - inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 && - inptr[DCTSIZE*7] == 0) { - /* AC terms all zero */ - int dcval = (int) DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); - - wsptr[DCTSIZE*0] = dcval; - wsptr[DCTSIZE*1] = dcval; - wsptr[DCTSIZE*2] = dcval; - wsptr[DCTSIZE*3] = dcval; - wsptr[DCTSIZE*4] = dcval; - wsptr[DCTSIZE*5] = dcval; - wsptr[DCTSIZE*6] = dcval; - wsptr[DCTSIZE*7] = dcval; - - inptr++; /* advance pointers to next column */ - quantptr++; - wsptr++; - continue; - } - - /* Even part */ - - tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); - tmp1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); - tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); - tmp3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); - - tmp10 = tmp0 + tmp2; /* phase 3 */ - tmp11 = tmp0 - tmp2; - - tmp13 = tmp1 + tmp3; /* phases 5-3 */ - tmp12 = MULTIPLY(tmp1 - tmp3, FIX_1_414213562) - tmp13; /* 2*c4 */ - - tmp0 = tmp10 + tmp13; /* phase 2 */ - tmp3 = tmp10 - tmp13; - tmp1 = tmp11 + tmp12; - tmp2 = tmp11 - tmp12; - - /* Odd part */ - - tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); - tmp5 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); - tmp6 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); - tmp7 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); - - z13 = tmp6 + tmp5; /* phase 6 */ - z10 = tmp6 - tmp5; - z11 = tmp4 + tmp7; - z12 = tmp4 - tmp7; - - tmp7 = z11 + z13; /* phase 5 */ - tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */ - - z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */ - tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */ - tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */ - - tmp6 = tmp12 - tmp7; /* phase 2 */ - tmp5 = tmp11 - tmp6; - tmp4 = tmp10 + tmp5; - - wsptr[DCTSIZE*0] = (int) (tmp0 + tmp7); - wsptr[DCTSIZE*7] = (int) (tmp0 - tmp7); - wsptr[DCTSIZE*1] = (int) (tmp1 + tmp6); - wsptr[DCTSIZE*6] = (int) (tmp1 - tmp6); - wsptr[DCTSIZE*2] = (int) (tmp2 + tmp5); - wsptr[DCTSIZE*5] = (int) (tmp2 - tmp5); - wsptr[DCTSIZE*4] = (int) (tmp3 + tmp4); - wsptr[DCTSIZE*3] = (int) (tmp3 - tmp4); - - inptr++; /* advance pointers to next column */ - quantptr++; - wsptr++; - } - - /* Pass 2: process rows from work array, store into output array. */ - /* Note that we must descale the results by a factor of 8 == 2**3, */ - /* and also undo the PASS1_BITS scaling. */ - - wsptr = workspace; - for (ctr = 0; ctr < DCTSIZE; ctr++) { - outptr = output_buf[ctr] + output_col; - /* Rows of zeroes can be exploited in the same way as we did with columns. - * However, the column calculation has created many nonzero AC terms, so - * the simplification applies less often (typically 5% to 10% of the time). - * On machines with very fast multiplication, it's possible that the - * test takes more time than it's worth. In that case this section - * may be commented out. - */ - -#ifndef NO_ZERO_ROW_TEST - if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 && - wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) { - /* AC terms all zero */ - JSAMPLE dcval = range_limit[IDESCALE(wsptr[0], PASS1_BITS+3) - & RANGE_MASK]; - - outptr[0] = dcval; - outptr[1] = dcval; - outptr[2] = dcval; - outptr[3] = dcval; - outptr[4] = dcval; - outptr[5] = dcval; - outptr[6] = dcval; - outptr[7] = dcval; - - wsptr += DCTSIZE; /* advance pointer to next row */ - continue; - } -#endif - - /* Even part */ - - tmp10 = ((DCTELEM) wsptr[0] + (DCTELEM) wsptr[4]); - tmp11 = ((DCTELEM) wsptr[0] - (DCTELEM) wsptr[4]); - - tmp13 = ((DCTELEM) wsptr[2] + (DCTELEM) wsptr[6]); - tmp12 = MULTIPLY((DCTELEM) wsptr[2] - (DCTELEM) wsptr[6], FIX_1_414213562) - - tmp13; - - tmp0 = tmp10 + tmp13; - tmp3 = tmp10 - tmp13; - tmp1 = tmp11 + tmp12; - tmp2 = tmp11 - tmp12; - - /* Odd part */ - - z13 = (DCTELEM) wsptr[5] + (DCTELEM) wsptr[3]; - z10 = (DCTELEM) wsptr[5] - (DCTELEM) wsptr[3]; - z11 = (DCTELEM) wsptr[1] + (DCTELEM) wsptr[7]; - z12 = (DCTELEM) wsptr[1] - (DCTELEM) wsptr[7]; - - tmp7 = z11 + z13; /* phase 5 */ - tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */ - - z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */ - tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */ - tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */ - - tmp6 = tmp12 - tmp7; /* phase 2 */ - tmp5 = tmp11 - tmp6; - tmp4 = tmp10 + tmp5; - - /* Final output stage: scale down by a factor of 8 and range-limit */ - - outptr[0] = range_limit[IDESCALE(tmp0 + tmp7, PASS1_BITS+3) - & RANGE_MASK]; - outptr[7] = range_limit[IDESCALE(tmp0 - tmp7, PASS1_BITS+3) - & RANGE_MASK]; - outptr[1] = range_limit[IDESCALE(tmp1 + tmp6, PASS1_BITS+3) - & RANGE_MASK]; - outptr[6] = range_limit[IDESCALE(tmp1 - tmp6, PASS1_BITS+3) - & RANGE_MASK]; - outptr[2] = range_limit[IDESCALE(tmp2 + tmp5, PASS1_BITS+3) - & RANGE_MASK]; - outptr[5] = range_limit[IDESCALE(tmp2 - tmp5, PASS1_BITS+3) - & RANGE_MASK]; - outptr[4] = range_limit[IDESCALE(tmp3 + tmp4, PASS1_BITS+3) - & RANGE_MASK]; - outptr[3] = range_limit[IDESCALE(tmp3 - tmp4, PASS1_BITS+3) - & RANGE_MASK]; - - wsptr += DCTSIZE; /* advance pointer to next row */ - } -} - -#endif /* DCT_IFAST_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jidctint.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jidctint.c deleted file mode 100644 index 4f47fe83c..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jidctint.c +++ /dev/null @@ -1,389 +0,0 @@ -/* - * jidctint.c - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a slow-but-accurate integer implementation of the - * inverse DCT (Discrete Cosine Transform). In the IJG code, this routine - * must also perform dequantization of the input coefficients. - * - * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT - * on each row (or vice versa, but it's more convenient to emit a row at - * a time). Direct algorithms are also available, but they are much more - * complex and seem not to be any faster when reduced to code. - * - * This implementation is based on an algorithm described in - * C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT - * Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics, - * Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991. - * The primary algorithm described there uses 11 multiplies and 29 adds. - * We use their alternate method with 12 multiplies and 32 adds. - * The advantage of this method is that no data path contains more than one - * multiplication; this allows a very simple and accurate implementation in - * scaled fixed-point arithmetic, with a minimal number of shifts. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - -#ifdef DCT_ISLOW_SUPPORTED - - -/* - * This module is specialized to the case DCTSIZE = 8. - */ - -#if DCTSIZE != 8 - Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ -#endif - - -/* - * The poop on this scaling stuff is as follows: - * - * Each 1-D IDCT step produces outputs which are a factor of sqrt(N) - * larger than the true IDCT outputs. The final outputs are therefore - * a factor of N larger than desired; since N=8 this can be cured by - * a simple right shift at the end of the algorithm. The advantage of - * this arrangement is that we save two multiplications per 1-D IDCT, - * because the y0 and y4 inputs need not be divided by sqrt(N). - * - * We have to do addition and subtraction of the integer inputs, which - * is no problem, and multiplication by fractional constants, which is - * a problem to do in integer arithmetic. We multiply all the constants - * by CONST_SCALE and convert them to integer constants (thus retaining - * CONST_BITS bits of precision in the constants). After doing a - * multiplication we have to divide the product by CONST_SCALE, with proper - * rounding, to produce the correct output. This division can be done - * cheaply as a right shift of CONST_BITS bits. We postpone shifting - * as long as possible so that partial sums can be added together with - * full fractional precision. - * - * The outputs of the first pass are scaled up by PASS1_BITS bits so that - * they are represented to better-than-integral precision. These outputs - * require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word - * with the recommended scaling. (To scale up 12-bit sample data further, an - * intermediate INT32 array would be needed.) - * - * To avoid overflow of the 32-bit intermediate results in pass 2, we must - * have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26. Error analysis - * shows that the values given below are the most effective. - */ - -#if BITS_IN_JSAMPLE == 8 -#define CONST_BITS 13 -#define PASS1_BITS 2 -#else -#define CONST_BITS 13 -#define PASS1_BITS 1 /* lose a little precision to avoid overflow */ -#endif - -/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus - * causing a lot of useless floating-point operations at run time. - * To get around this we use the following pre-calculated constants. - * If you change CONST_BITS you may want to add appropriate values. - * (With a reasonable C compiler, you can just rely on the FIX() macro...) - */ - -#if CONST_BITS == 13 -#define FIX_0_298631336 ((INT32) 2446) /* FIX(0.298631336) */ -#define FIX_0_390180644 ((INT32) 3196) /* FIX(0.390180644) */ -#define FIX_0_541196100 ((INT32) 4433) /* FIX(0.541196100) */ -#define FIX_0_765366865 ((INT32) 6270) /* FIX(0.765366865) */ -#define FIX_0_899976223 ((INT32) 7373) /* FIX(0.899976223) */ -#define FIX_1_175875602 ((INT32) 9633) /* FIX(1.175875602) */ -#define FIX_1_501321110 ((INT32) 12299) /* FIX(1.501321110) */ -#define FIX_1_847759065 ((INT32) 15137) /* FIX(1.847759065) */ -#define FIX_1_961570560 ((INT32) 16069) /* FIX(1.961570560) */ -#define FIX_2_053119869 ((INT32) 16819) /* FIX(2.053119869) */ -#define FIX_2_562915447 ((INT32) 20995) /* FIX(2.562915447) */ -#define FIX_3_072711026 ((INT32) 25172) /* FIX(3.072711026) */ -#else -#define FIX_0_298631336 FIX(0.298631336) -#define FIX_0_390180644 FIX(0.390180644) -#define FIX_0_541196100 FIX(0.541196100) -#define FIX_0_765366865 FIX(0.765366865) -#define FIX_0_899976223 FIX(0.899976223) -#define FIX_1_175875602 FIX(1.175875602) -#define FIX_1_501321110 FIX(1.501321110) -#define FIX_1_847759065 FIX(1.847759065) -#define FIX_1_961570560 FIX(1.961570560) -#define FIX_2_053119869 FIX(2.053119869) -#define FIX_2_562915447 FIX(2.562915447) -#define FIX_3_072711026 FIX(3.072711026) -#endif - - -/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. - * For 8-bit samples with the recommended scaling, all the variable - * and constant values involved are no more than 16 bits wide, so a - * 16x16->32 bit multiply can be used instead of a full 32x32 multiply. - * For 12-bit samples, a full 32-bit multiplication will be needed. - */ - -#if BITS_IN_JSAMPLE == 8 -#define MULTIPLY(var,const) MULTIPLY16C16(var,const) -#else -#define MULTIPLY(var,const) ((var) * (const)) -#endif - - -/* Dequantize a coefficient by multiplying it by the multiplier-table - * entry; produce an int result. In this module, both inputs and result - * are 16 bits or less, so either int or short multiply will work. - */ - -#define DEQUANTIZE(coef,quantval) (((ISLOW_MULT_TYPE) (coef)) * (quantval)) - - -/* - * Perform dequantization and inverse DCT on one block of coefficients. - */ - -GLOBAL(void) -jpeg_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, - JSAMPARRAY output_buf, JDIMENSION output_col) -{ - INT32 tmp0, tmp1, tmp2, tmp3; - INT32 tmp10, tmp11, tmp12, tmp13; - INT32 z1, z2, z3, z4, z5; - JCOEFPTR inptr; - ISLOW_MULT_TYPE * quantptr; - int * wsptr; - JSAMPROW outptr; - JSAMPLE *range_limit = IDCT_range_limit(cinfo); - int ctr; - int workspace[DCTSIZE2]; /* buffers data between passes */ - SHIFT_TEMPS - - /* Pass 1: process columns from input, store into work array. */ - /* Note results are scaled up by sqrt(8) compared to a true IDCT; */ - /* furthermore, we scale the results by 2**PASS1_BITS. */ - - inptr = coef_block; - quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; - wsptr = workspace; - for (ctr = DCTSIZE; ctr > 0; ctr--) { - /* Due to quantization, we will usually find that many of the input - * coefficients are zero, especially the AC terms. We can exploit this - * by short-circuiting the IDCT calculation for any column in which all - * the AC terms are zero. In that case each output is equal to the - * DC coefficient (with scale factor as needed). - * With typical images and quantization tables, half or more of the - * column DCT calculations can be simplified this way. - */ - - if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && - inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 && - inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 && - inptr[DCTSIZE*7] == 0) { - /* AC terms all zero */ - int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS; - - wsptr[DCTSIZE*0] = dcval; - wsptr[DCTSIZE*1] = dcval; - wsptr[DCTSIZE*2] = dcval; - wsptr[DCTSIZE*3] = dcval; - wsptr[DCTSIZE*4] = dcval; - wsptr[DCTSIZE*5] = dcval; - wsptr[DCTSIZE*6] = dcval; - wsptr[DCTSIZE*7] = dcval; - - inptr++; /* advance pointers to next column */ - quantptr++; - wsptr++; - continue; - } - - /* Even part: reverse the even part of the forward DCT. */ - /* The rotator is sqrt(2)*c(-6). */ - - z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); - z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); - - z1 = MULTIPLY(z2 + z3, FIX_0_541196100); - tmp2 = z1 + MULTIPLY(z3, - FIX_1_847759065); - tmp3 = z1 + MULTIPLY(z2, FIX_0_765366865); - - z2 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); - z3 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); - - tmp0 = (z2 + z3) << CONST_BITS; - tmp1 = (z2 - z3) << CONST_BITS; - - tmp10 = tmp0 + tmp3; - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - /* Odd part per figure 8; the matrix is unitary and hence its - * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively. - */ - - tmp0 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); - tmp1 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); - tmp2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); - tmp3 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); - - z1 = tmp0 + tmp3; - z2 = tmp1 + tmp2; - z3 = tmp0 + tmp2; - z4 = tmp1 + tmp3; - z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ - - tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ - tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ - tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ - tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ - z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ - z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ - z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ - z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ - - z3 += z5; - z4 += z5; - - tmp0 += z1 + z3; - tmp1 += z2 + z4; - tmp2 += z2 + z3; - tmp3 += z1 + z4; - - /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ - - wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp3, CONST_BITS-PASS1_BITS); - wsptr[DCTSIZE*7] = (int) DESCALE(tmp10 - tmp3, CONST_BITS-PASS1_BITS); - wsptr[DCTSIZE*1] = (int) DESCALE(tmp11 + tmp2, CONST_BITS-PASS1_BITS); - wsptr[DCTSIZE*6] = (int) DESCALE(tmp11 - tmp2, CONST_BITS-PASS1_BITS); - wsptr[DCTSIZE*2] = (int) DESCALE(tmp12 + tmp1, CONST_BITS-PASS1_BITS); - wsptr[DCTSIZE*5] = (int) DESCALE(tmp12 - tmp1, CONST_BITS-PASS1_BITS); - wsptr[DCTSIZE*3] = (int) DESCALE(tmp13 + tmp0, CONST_BITS-PASS1_BITS); - wsptr[DCTSIZE*4] = (int) DESCALE(tmp13 - tmp0, CONST_BITS-PASS1_BITS); - - inptr++; /* advance pointers to next column */ - quantptr++; - wsptr++; - } - - /* Pass 2: process rows from work array, store into output array. */ - /* Note that we must descale the results by a factor of 8 == 2**3, */ - /* and also undo the PASS1_BITS scaling. */ - - wsptr = workspace; - for (ctr = 0; ctr < DCTSIZE; ctr++) { - outptr = output_buf[ctr] + output_col; - /* Rows of zeroes can be exploited in the same way as we did with columns. - * However, the column calculation has created many nonzero AC terms, so - * the simplification applies less often (typically 5% to 10% of the time). - * On machines with very fast multiplication, it's possible that the - * test takes more time than it's worth. In that case this section - * may be commented out. - */ - -#ifndef NO_ZERO_ROW_TEST - if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 && - wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) { - /* AC terms all zero */ - JSAMPLE dcval = range_limit[(int) DESCALE((INT32) wsptr[0], PASS1_BITS+3) - & RANGE_MASK]; - - outptr[0] = dcval; - outptr[1] = dcval; - outptr[2] = dcval; - outptr[3] = dcval; - outptr[4] = dcval; - outptr[5] = dcval; - outptr[6] = dcval; - outptr[7] = dcval; - - wsptr += DCTSIZE; /* advance pointer to next row */ - continue; - } -#endif - - /* Even part: reverse the even part of the forward DCT. */ - /* The rotator is sqrt(2)*c(-6). */ - - z2 = (INT32) wsptr[2]; - z3 = (INT32) wsptr[6]; - - z1 = MULTIPLY(z2 + z3, FIX_0_541196100); - tmp2 = z1 + MULTIPLY(z3, - FIX_1_847759065); - tmp3 = z1 + MULTIPLY(z2, FIX_0_765366865); - - tmp0 = ((INT32) wsptr[0] + (INT32) wsptr[4]) << CONST_BITS; - tmp1 = ((INT32) wsptr[0] - (INT32) wsptr[4]) << CONST_BITS; - - tmp10 = tmp0 + tmp3; - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - /* Odd part per figure 8; the matrix is unitary and hence its - * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively. - */ - - tmp0 = (INT32) wsptr[7]; - tmp1 = (INT32) wsptr[5]; - tmp2 = (INT32) wsptr[3]; - tmp3 = (INT32) wsptr[1]; - - z1 = tmp0 + tmp3; - z2 = tmp1 + tmp2; - z3 = tmp0 + tmp2; - z4 = tmp1 + tmp3; - z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ - - tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ - tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ - tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ - tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ - z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ - z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ - z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ - z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ - - z3 += z5; - z4 += z5; - - tmp0 += z1 + z3; - tmp1 += z2 + z4; - tmp2 += z2 + z3; - tmp3 += z1 + z4; - - /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ - - outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp3, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - outptr[7] = range_limit[(int) DESCALE(tmp10 - tmp3, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - outptr[1] = range_limit[(int) DESCALE(tmp11 + tmp2, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - outptr[6] = range_limit[(int) DESCALE(tmp11 - tmp2, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - outptr[2] = range_limit[(int) DESCALE(tmp12 + tmp1, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - outptr[5] = range_limit[(int) DESCALE(tmp12 - tmp1, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - outptr[3] = range_limit[(int) DESCALE(tmp13 + tmp0, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - outptr[4] = range_limit[(int) DESCALE(tmp13 - tmp0, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - - wsptr += DCTSIZE; /* advance pointer to next row */ - } -} - -#endif /* DCT_ISLOW_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jidctred.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jidctred.c deleted file mode 100644 index 911899b8d..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jidctred.c +++ /dev/null @@ -1,398 +0,0 @@ -/* - * jidctred.c - * - * Copyright (C) 1994-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains inverse-DCT routines that produce reduced-size output: - * either 4x4, 2x2, or 1x1 pixels from an 8x8 DCT block. - * - * The implementation is based on the Loeffler, Ligtenberg and Moschytz (LL&M) - * algorithm used in jidctint.c. We simply replace each 8-to-8 1-D IDCT step - * with an 8-to-4 step that produces the four averages of two adjacent outputs - * (or an 8-to-2 step producing two averages of four outputs, for 2x2 output). - * These steps were derived by computing the corresponding values at the end - * of the normal LL&M code, then simplifying as much as possible. - * - * 1x1 is trivial: just take the DC coefficient divided by 8. - * - * See jidctint.c for additional comments. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - -#ifdef IDCT_SCALING_SUPPORTED - - -/* - * This module is specialized to the case DCTSIZE = 8. - */ - -#if DCTSIZE != 8 - Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ -#endif - - -/* Scaling is the same as in jidctint.c. */ - -#if BITS_IN_JSAMPLE == 8 -#define CONST_BITS 13 -#define PASS1_BITS 2 -#else -#define CONST_BITS 13 -#define PASS1_BITS 1 /* lose a little precision to avoid overflow */ -#endif - -/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus - * causing a lot of useless floating-point operations at run time. - * To get around this we use the following pre-calculated constants. - * If you change CONST_BITS you may want to add appropriate values. - * (With a reasonable C compiler, you can just rely on the FIX() macro...) - */ - -#if CONST_BITS == 13 -#define FIX_0_211164243 ((INT32) 1730) /* FIX(0.211164243) */ -#define FIX_0_509795579 ((INT32) 4176) /* FIX(0.509795579) */ -#define FIX_0_601344887 ((INT32) 4926) /* FIX(0.601344887) */ -#define FIX_0_720959822 ((INT32) 5906) /* FIX(0.720959822) */ -#define FIX_0_765366865 ((INT32) 6270) /* FIX(0.765366865) */ -#define FIX_0_850430095 ((INT32) 6967) /* FIX(0.850430095) */ -#define FIX_0_899976223 ((INT32) 7373) /* FIX(0.899976223) */ -#define FIX_1_061594337 ((INT32) 8697) /* FIX(1.061594337) */ -#define FIX_1_272758580 ((INT32) 10426) /* FIX(1.272758580) */ -#define FIX_1_451774981 ((INT32) 11893) /* FIX(1.451774981) */ -#define FIX_1_847759065 ((INT32) 15137) /* FIX(1.847759065) */ -#define FIX_2_172734803 ((INT32) 17799) /* FIX(2.172734803) */ -#define FIX_2_562915447 ((INT32) 20995) /* FIX(2.562915447) */ -#define FIX_3_624509785 ((INT32) 29692) /* FIX(3.624509785) */ -#else -#define FIX_0_211164243 FIX(0.211164243) -#define FIX_0_509795579 FIX(0.509795579) -#define FIX_0_601344887 FIX(0.601344887) -#define FIX_0_720959822 FIX(0.720959822) -#define FIX_0_765366865 FIX(0.765366865) -#define FIX_0_850430095 FIX(0.850430095) -#define FIX_0_899976223 FIX(0.899976223) -#define FIX_1_061594337 FIX(1.061594337) -#define FIX_1_272758580 FIX(1.272758580) -#define FIX_1_451774981 FIX(1.451774981) -#define FIX_1_847759065 FIX(1.847759065) -#define FIX_2_172734803 FIX(2.172734803) -#define FIX_2_562915447 FIX(2.562915447) -#define FIX_3_624509785 FIX(3.624509785) -#endif - - -/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. - * For 8-bit samples with the recommended scaling, all the variable - * and constant values involved are no more than 16 bits wide, so a - * 16x16->32 bit multiply can be used instead of a full 32x32 multiply. - * For 12-bit samples, a full 32-bit multiplication will be needed. - */ - -#if BITS_IN_JSAMPLE == 8 -#define MULTIPLY(var,const) MULTIPLY16C16(var,const) -#else -#define MULTIPLY(var,const) ((var) * (const)) -#endif - - -/* Dequantize a coefficient by multiplying it by the multiplier-table - * entry; produce an int result. In this module, both inputs and result - * are 16 bits or less, so either int or short multiply will work. - */ - -#define DEQUANTIZE(coef,quantval) (((ISLOW_MULT_TYPE) (coef)) * (quantval)) - - -/* - * Perform dequantization and inverse DCT on one block of coefficients, - * producing a reduced-size 4x4 output block. - */ - -GLOBAL(void) -jpeg_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, - JSAMPARRAY output_buf, JDIMENSION output_col) -{ - INT32 tmp0, tmp2, tmp10, tmp12; - INT32 z1, z2, z3, z4; - JCOEFPTR inptr; - ISLOW_MULT_TYPE * quantptr; - int * wsptr; - JSAMPROW outptr; - JSAMPLE *range_limit = IDCT_range_limit(cinfo); - int ctr; - int workspace[DCTSIZE*4]; /* buffers data between passes */ - SHIFT_TEMPS - - /* Pass 1: process columns from input, store into work array. */ - - inptr = coef_block; - quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; - wsptr = workspace; - for (ctr = DCTSIZE; ctr > 0; inptr++, quantptr++, wsptr++, ctr--) { - /* Don't bother to process column 4, because second pass won't use it */ - if (ctr == DCTSIZE-4) - continue; - if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && - inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*5] == 0 && - inptr[DCTSIZE*6] == 0 && inptr[DCTSIZE*7] == 0) { - /* AC terms all zero; we need not examine term 4 for 4x4 output */ - int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS; - - wsptr[DCTSIZE*0] = dcval; - wsptr[DCTSIZE*1] = dcval; - wsptr[DCTSIZE*2] = dcval; - wsptr[DCTSIZE*3] = dcval; - - continue; - } - - /* Even part */ - - tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); - tmp0 <<= (CONST_BITS+1); - - z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); - z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); - - tmp2 = MULTIPLY(z2, FIX_1_847759065) + MULTIPLY(z3, - FIX_0_765366865); - - tmp10 = tmp0 + tmp2; - tmp12 = tmp0 - tmp2; - - /* Odd part */ - - z1 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); - z2 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); - z3 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); - z4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); - - tmp0 = MULTIPLY(z1, - FIX_0_211164243) /* sqrt(2) * (c3-c1) */ - + MULTIPLY(z2, FIX_1_451774981) /* sqrt(2) * (c3+c7) */ - + MULTIPLY(z3, - FIX_2_172734803) /* sqrt(2) * (-c1-c5) */ - + MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * (c5+c7) */ - - tmp2 = MULTIPLY(z1, - FIX_0_509795579) /* sqrt(2) * (c7-c5) */ - + MULTIPLY(z2, - FIX_0_601344887) /* sqrt(2) * (c5-c1) */ - + MULTIPLY(z3, FIX_0_899976223) /* sqrt(2) * (c3-c7) */ - + MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */ - - /* Final output stage */ - - wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp2, CONST_BITS-PASS1_BITS+1); - wsptr[DCTSIZE*3] = (int) DESCALE(tmp10 - tmp2, CONST_BITS-PASS1_BITS+1); - wsptr[DCTSIZE*1] = (int) DESCALE(tmp12 + tmp0, CONST_BITS-PASS1_BITS+1); - wsptr[DCTSIZE*2] = (int) DESCALE(tmp12 - tmp0, CONST_BITS-PASS1_BITS+1); - } - - /* Pass 2: process 4 rows from work array, store into output array. */ - - wsptr = workspace; - for (ctr = 0; ctr < 4; ctr++) { - outptr = output_buf[ctr] + output_col; - /* It's not clear whether a zero row test is worthwhile here ... */ - -#ifndef NO_ZERO_ROW_TEST - if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && - wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) { - /* AC terms all zero */ - JSAMPLE dcval = range_limit[(int) DESCALE((INT32) wsptr[0], PASS1_BITS+3) - & RANGE_MASK]; - - outptr[0] = dcval; - outptr[1] = dcval; - outptr[2] = dcval; - outptr[3] = dcval; - - wsptr += DCTSIZE; /* advance pointer to next row */ - continue; - } -#endif - - /* Even part */ - - tmp0 = ((INT32) wsptr[0]) << (CONST_BITS+1); - - tmp2 = MULTIPLY((INT32) wsptr[2], FIX_1_847759065) - + MULTIPLY((INT32) wsptr[6], - FIX_0_765366865); - - tmp10 = tmp0 + tmp2; - tmp12 = tmp0 - tmp2; - - /* Odd part */ - - z1 = (INT32) wsptr[7]; - z2 = (INT32) wsptr[5]; - z3 = (INT32) wsptr[3]; - z4 = (INT32) wsptr[1]; - - tmp0 = MULTIPLY(z1, - FIX_0_211164243) /* sqrt(2) * (c3-c1) */ - + MULTIPLY(z2, FIX_1_451774981) /* sqrt(2) * (c3+c7) */ - + MULTIPLY(z3, - FIX_2_172734803) /* sqrt(2) * (-c1-c5) */ - + MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * (c5+c7) */ - - tmp2 = MULTIPLY(z1, - FIX_0_509795579) /* sqrt(2) * (c7-c5) */ - + MULTIPLY(z2, - FIX_0_601344887) /* sqrt(2) * (c5-c1) */ - + MULTIPLY(z3, FIX_0_899976223) /* sqrt(2) * (c3-c7) */ - + MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */ - - /* Final output stage */ - - outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp2, - CONST_BITS+PASS1_BITS+3+1) - & RANGE_MASK]; - outptr[3] = range_limit[(int) DESCALE(tmp10 - tmp2, - CONST_BITS+PASS1_BITS+3+1) - & RANGE_MASK]; - outptr[1] = range_limit[(int) DESCALE(tmp12 + tmp0, - CONST_BITS+PASS1_BITS+3+1) - & RANGE_MASK]; - outptr[2] = range_limit[(int) DESCALE(tmp12 - tmp0, - CONST_BITS+PASS1_BITS+3+1) - & RANGE_MASK]; - - wsptr += DCTSIZE; /* advance pointer to next row */ - } -} - - -/* - * Perform dequantization and inverse DCT on one block of coefficients, - * producing a reduced-size 2x2 output block. - */ - -GLOBAL(void) -jpeg_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, - JSAMPARRAY output_buf, JDIMENSION output_col) -{ - INT32 tmp0, tmp10, z1; - JCOEFPTR inptr; - ISLOW_MULT_TYPE * quantptr; - int * wsptr; - JSAMPROW outptr; - JSAMPLE *range_limit = IDCT_range_limit(cinfo); - int ctr; - int workspace[DCTSIZE*2]; /* buffers data between passes */ - SHIFT_TEMPS - - /* Pass 1: process columns from input, store into work array. */ - - inptr = coef_block; - quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; - wsptr = workspace; - for (ctr = DCTSIZE; ctr > 0; inptr++, quantptr++, wsptr++, ctr--) { - /* Don't bother to process columns 2,4,6 */ - if (ctr == DCTSIZE-2 || ctr == DCTSIZE-4 || ctr == DCTSIZE-6) - continue; - if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*3] == 0 && - inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*7] == 0) { - /* AC terms all zero; we need not examine terms 2,4,6 for 2x2 output */ - int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS; - - wsptr[DCTSIZE*0] = dcval; - wsptr[DCTSIZE*1] = dcval; - - continue; - } - - /* Even part */ - - z1 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); - tmp10 = z1 << (CONST_BITS+2); - - /* Odd part */ - - z1 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); - tmp0 = MULTIPLY(z1, - FIX_0_720959822); /* sqrt(2) * (c7-c5+c3-c1) */ - z1 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); - tmp0 += MULTIPLY(z1, FIX_0_850430095); /* sqrt(2) * (-c1+c3+c5+c7) */ - z1 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); - tmp0 += MULTIPLY(z1, - FIX_1_272758580); /* sqrt(2) * (-c1+c3-c5-c7) */ - z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); - tmp0 += MULTIPLY(z1, FIX_3_624509785); /* sqrt(2) * (c1+c3+c5+c7) */ - - /* Final output stage */ - - wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp0, CONST_BITS-PASS1_BITS+2); - wsptr[DCTSIZE*1] = (int) DESCALE(tmp10 - tmp0, CONST_BITS-PASS1_BITS+2); - } - - /* Pass 2: process 2 rows from work array, store into output array. */ - - wsptr = workspace; - for (ctr = 0; ctr < 2; ctr++) { - outptr = output_buf[ctr] + output_col; - /* It's not clear whether a zero row test is worthwhile here ... */ - -#ifndef NO_ZERO_ROW_TEST - if (wsptr[1] == 0 && wsptr[3] == 0 && wsptr[5] == 0 && wsptr[7] == 0) { - /* AC terms all zero */ - JSAMPLE dcval = range_limit[(int) DESCALE((INT32) wsptr[0], PASS1_BITS+3) - & RANGE_MASK]; - - outptr[0] = dcval; - outptr[1] = dcval; - - wsptr += DCTSIZE; /* advance pointer to next row */ - continue; - } -#endif - - /* Even part */ - - tmp10 = ((INT32) wsptr[0]) << (CONST_BITS+2); - - /* Odd part */ - - tmp0 = MULTIPLY((INT32) wsptr[7], - FIX_0_720959822) /* sqrt(2) * (c7-c5+c3-c1) */ - + MULTIPLY((INT32) wsptr[5], FIX_0_850430095) /* sqrt(2) * (-c1+c3+c5+c7) */ - + MULTIPLY((INT32) wsptr[3], - FIX_1_272758580) /* sqrt(2) * (-c1+c3-c5-c7) */ - + MULTIPLY((INT32) wsptr[1], FIX_3_624509785); /* sqrt(2) * (c1+c3+c5+c7) */ - - /* Final output stage */ - - outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp0, - CONST_BITS+PASS1_BITS+3+2) - & RANGE_MASK]; - outptr[1] = range_limit[(int) DESCALE(tmp10 - tmp0, - CONST_BITS+PASS1_BITS+3+2) - & RANGE_MASK]; - - wsptr += DCTSIZE; /* advance pointer to next row */ - } -} - - -/* - * Perform dequantization and inverse DCT on one block of coefficients, - * producing a reduced-size 1x1 output block. - */ - -GLOBAL(void) -jpeg_idct_1x1 (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, - JSAMPARRAY output_buf, JDIMENSION output_col) -{ - int dcval; - ISLOW_MULT_TYPE * quantptr; - JSAMPLE *range_limit = IDCT_range_limit(cinfo); - SHIFT_TEMPS - - /* We hardly need an inverse DCT routine for this: just take the - * average pixel value, which is one-eighth of the DC coefficient. - */ - quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; - dcval = DEQUANTIZE(coef_block[0], quantptr[0]); - dcval = (int) DESCALE((INT32) dcval, 3); - - output_buf[0][output_col] = range_limit[dcval & RANGE_MASK]; -} - -#endif /* IDCT_SCALING_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jinclude.h b/irrlicht-1.6/source/Irrlicht/jpeglib/jinclude.h deleted file mode 100644 index 5ff60fedf..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jinclude.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * jinclude.h - * - * Copyright (C) 1991-1994, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file exists to provide a single place to fix any problems with - * including the wrong system include files. (Common problems are taken - * care of by the standard jconfig symbols, but on really weird systems - * you may have to edit this file.) - * - * NOTE: this file is NOT intended to be included by applications using the - * JPEG library. Most applications need only include jpeglib.h. - */ - - -/* Include auto-config file to find out which system include files we need. */ - -#include "jconfig.h" /* auto configuration options */ -#define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */ - -/* - * We need the NULL macro and size_t typedef. - * On an ANSI-conforming system it is sufficient to include <stddef.h>. - * Otherwise, we get them from <stdlib.h> or <stdio.h>; we may have to - * pull in <sys/types.h> as well. - * Note that the core JPEG library does not require <stdio.h>; - * only the default error handler and data source/destination modules do. - * But we must pull it in because of the references to FILE in jpeglib.h. - * You can remove those references if you want to compile without <stdio.h>. - */ - -#ifdef HAVE_STDDEF_H -#include <stddef.h> -#endif - -#ifdef HAVE_STDLIB_H -#include <stdlib.h> -#endif - -#ifdef NEED_SYS_TYPES_H -#include <sys/types.h> -#endif - -#include <stdio.h> - -/* - * We need memory copying and zeroing functions, plus strncpy(). - * ANSI and System V implementations declare these in <string.h>. - * BSD doesn't have the mem() functions, but it does have bcopy()/bzero(). - * Some systems may declare memset and memcpy in <memory.h>. - * - * NOTE: we assume the size parameters to these functions are of type size_t. - * Change the casts in these macros if not! - */ - -#ifdef NEED_BSD_STRINGS - -#include <strings.h> -#define MEMZERO(target,size) bzero((void *)(target), (size_t)(size)) -#define MEMCOPY(dest,src,size) bcopy((const void *)(src), (void *)(dest), (size_t)(size)) - -#else /* not BSD, assume ANSI/SysV string lib */ - -#include <string.h> -#define MEMZERO(target,size) memset((void *)(target), 0, (size_t)(size)) -#define MEMCOPY(dest,src,size) memcpy((void *)(dest), (const void *)(src), (size_t)(size)) - -#endif - -/* - * In ANSI C, and indeed any rational implementation, size_t is also the - * type returned by sizeof(). However, it seems there are some irrational - * implementations out there, in which sizeof() returns an int even though - * size_t is defined as long or unsigned long. To ensure consistent results - * we always use this SIZEOF() macro in place of using sizeof() directly. - */ - -#define SIZEOF(object) ((size_t) sizeof(object)) - -/* - * The modules that use fread() and fwrite() always invoke them through - * these macros. On some systems you may need to twiddle the argument casts. - * CAUTION: argument order is different from underlying functions! - */ - -#define JFREAD(file,buf,sizeofbuf) \ - ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) -#define JFWRITE(file,buf,sizeofbuf) \ - ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jmemansi.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jmemansi.c deleted file mode 100644 index b5da4743f..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jmemansi.c +++ /dev/null @@ -1,167 +0,0 @@ -/* - * jmemansi.c - * - * Copyright (C) 1992-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file provides a simple generic implementation of the system- - * dependent portion of the JPEG memory manager. This implementation - * assumes that you have the ANSI-standard library routine tmpfile(). - * Also, the problem of determining the amount of memory available - * is shoved onto the user. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jmemsys.h" /* import the system-dependent declarations */ - -#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare malloc(),free() */ -extern void * malloc JPP((size_t size)); -extern void free JPP((void *ptr)); -#endif - -#ifndef SEEK_SET /* pre-ANSI systems may not define this; */ -#define SEEK_SET 0 /* if not, assume 0 is correct */ -#endif - - -/* - * Memory allocation and freeing are controlled by the regular library - * routines malloc() and free(). - */ - -GLOBAL(void *) -jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void *) malloc(sizeofobject); -} - -GLOBAL(void) -jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) -{ - free(object); -} - - -/* - * "Large" objects are treated the same as "small" ones. - * NB: although we include FAR keywords in the routine declarations, - * this file won't actually work in 80x86 small/medium model; at least, - * you probably won't be able to process useful-size images in only 64KB. - */ - -GLOBAL(void FAR *) -jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void FAR *) malloc(sizeofobject); -} - -GLOBAL(void) -jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) -{ - free(object); -} - - -/* - * This routine computes the total memory space available for allocation. - * It's impossible to do this in a portable way; our current solution is - * to make the user tell us (with a default value set at compile time). - * If you can actually get the available space, it's a good idea to subtract - * a slop factor of 5% or so. - */ - -#ifndef DEFAULT_MAX_MEM /* so can override from makefile */ -#define DEFAULT_MAX_MEM 1000000L /* default: one megabyte */ -#endif - -GLOBAL(long) -jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, - long max_bytes_needed, long already_allocated) -{ - return cinfo->mem->max_memory_to_use - already_allocated; -} - - -/* - * Backing store (temporary file) management. - * Backing store objects are only used when the value returned by - * jpeg_mem_available is less than the total space needed. You can dispense - * with these routines if you have plenty of virtual memory; see jmemnobs.c. - */ - - -METHODDEF(void) -read_backing_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - if (fseek(info->temp_file, file_offset, SEEK_SET)) - ERREXIT(cinfo, JERR_TFILE_SEEK); - if (JFREAD(info->temp_file, buffer_address, byte_count) - != (size_t) byte_count) - ERREXIT(cinfo, JERR_TFILE_READ); -} - - -METHODDEF(void) -write_backing_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - if (fseek(info->temp_file, file_offset, SEEK_SET)) - ERREXIT(cinfo, JERR_TFILE_SEEK); - if (JFWRITE(info->temp_file, buffer_address, byte_count) - != (size_t) byte_count) - ERREXIT(cinfo, JERR_TFILE_WRITE); -} - - -METHODDEF(void) -close_backing_store (j_common_ptr cinfo, backing_store_ptr info) -{ - fclose(info->temp_file); - /* Since this implementation uses tmpfile() to create the file, - * no explicit file deletion is needed. - */ -} - - -/* - * Initial opening of a backing-store object. - * - * This version uses tmpfile(), which constructs a suitable file name - * behind the scenes. We don't have to use info->temp_name[] at all; - * indeed, we can't even find out the actual name of the temp file. - */ - -GLOBAL(void) -jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, - long total_bytes_needed) -{ - if ((info->temp_file = tmpfile()) == NULL) - ERREXITS(cinfo, JERR_TFILE_CREATE, ""); - info->read_backing_store = read_backing_store; - info->write_backing_store = write_backing_store; - info->close_backing_store = close_backing_store; -} - - -/* - * These routines take care of any system-dependent initialization and - * cleanup required. - */ - -GLOBAL(long) -jpeg_mem_init (j_common_ptr cinfo) -{ - return DEFAULT_MAX_MEM; /* default for max_memory_to_use */ -} - -GLOBAL(void) -jpeg_mem_term (j_common_ptr cinfo) -{ - /* no work */ -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jmemdos.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jmemdos.c deleted file mode 100644 index 0955047ec..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jmemdos.c +++ /dev/null @@ -1,638 +0,0 @@ -/* - * jmemdos.c - * - * Copyright (C) 1992-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file provides an MS-DOS-compatible implementation of the system- - * dependent portion of the JPEG memory manager. Temporary data can be - * stored in extended or expanded memory as well as in regular DOS files. - * - * If you use this file, you must be sure that NEED_FAR_POINTERS is defined - * if you compile in a small-data memory model; it should NOT be defined if - * you use a large-data memory model. This file is not recommended if you - * are using a flat-memory-space 386 environment such as DJGCC or Watcom C. - * Also, this code will NOT work if struct fields are aligned on greater than - * 2-byte boundaries. - * - * Based on code contributed by Ge' Weijers. - */ - -/* - * If you have both extended and expanded memory, you may want to change the - * order in which they are tried in jopen_backing_store. On a 286 machine - * expanded memory is usually faster, since extended memory access involves - * an expensive protected-mode-and-back switch. On 386 and better, extended - * memory is usually faster. As distributed, the code tries extended memory - * first (what? not everyone has a 386? :-). - * - * You can disable use of extended/expanded memory entirely by altering these - * definitions or overriding them from the Makefile (eg, -DEMS_SUPPORTED=0). - */ - -#ifndef XMS_SUPPORTED -#define XMS_SUPPORTED 1 -#endif -#ifndef EMS_SUPPORTED -#define EMS_SUPPORTED 1 -#endif - - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jmemsys.h" /* import the system-dependent declarations */ - -#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare these */ -extern void * malloc JPP((size_t size)); -extern void free JPP((void *ptr)); -extern char * getenv JPP((const char * name)); -#endif - -#ifdef NEED_FAR_POINTERS - -#ifdef __TURBOC__ -/* These definitions work for Borland C (Turbo C) */ -#include <alloc.h> /* need farmalloc(), farfree() */ -#define far_malloc(x) farmalloc(x) -#define far_free(x) farfree(x) -#else -/* These definitions work for Microsoft C and compatible compilers */ -#include <malloc.h> /* need _fmalloc(), _ffree() */ -#define far_malloc(x) _fmalloc(x) -#define far_free(x) _ffree(x) -#endif - -#else /* not NEED_FAR_POINTERS */ - -#define far_malloc(x) malloc(x) -#define far_free(x) free(x) - -#endif /* NEED_FAR_POINTERS */ - -#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ -#define READ_BINARY "r" -#else -#define READ_BINARY "rb" -#endif - -#ifndef USE_MSDOS_MEMMGR /* make sure user got configuration right */ - You forgot to define USE_MSDOS_MEMMGR in jconfig.h. /* deliberate syntax error */ -#endif - -#if MAX_ALLOC_CHUNK >= 65535L /* make sure jconfig.h got this right */ - MAX_ALLOC_CHUNK should be less than 64K. /* deliberate syntax error */ -#endif - - -/* - * Declarations for assembly-language support routines (see jmemdosa.asm). - * - * The functions are declared "far" as are all their pointer arguments; - * this ensures the assembly source code will work regardless of the - * compiler memory model. We assume "short" is 16 bits, "long" is 32. - */ - -typedef void far * XMSDRIVER; /* actually a pointer to code */ -typedef struct { /* registers for calling XMS driver */ - unsigned short ax, dx, bx; - void far * ds_si; - } XMScontext; -typedef struct { /* registers for calling EMS driver */ - unsigned short ax, dx, bx; - void far * ds_si; - } EMScontext; - -extern short far jdos_open JPP((short far * handle, char far * filename)); -extern short far jdos_close JPP((short handle)); -extern short far jdos_seek JPP((short handle, long offset)); -extern short far jdos_read JPP((short handle, void far * buffer, - unsigned short count)); -extern short far jdos_write JPP((short handle, void far * buffer, - unsigned short count)); -extern void far jxms_getdriver JPP((XMSDRIVER far *)); -extern void far jxms_calldriver JPP((XMSDRIVER, XMScontext far *)); -extern short far jems_available JPP((void)); -extern void far jems_calldriver JPP((EMScontext far *)); - - -/* - * Selection of a file name for a temporary file. - * This is highly system-dependent, and you may want to customize it. - */ - -static int next_file_num; /* to distinguish among several temp files */ - -LOCAL(void) -select_file_name (char * fname) -{ - const char * env; - char * ptr; - FILE * tfile; - - /* Keep generating file names till we find one that's not in use */ - for (;;) { - /* Get temp directory name from environment TMP or TEMP variable; - * if none, use "." - */ - if ((env = (const char *) getenv("TMP")) == NULL) - if ((env = (const char *) getenv("TEMP")) == NULL) - env = "."; - if (*env == '\0') /* null string means "." */ - env = "."; - ptr = fname; /* copy name to fname */ - while (*env != '\0') - *ptr++ = *env++; - if (ptr[-1] != '\\' && ptr[-1] != '/') - *ptr++ = '\\'; /* append backslash if not in env variable */ - /* Append a suitable file name */ - next_file_num++; /* advance counter */ - sprintf(ptr, "JPG%03d.TMP", next_file_num); - /* Probe to see if file name is already in use */ - if ((tfile = fopen(fname, READ_BINARY)) == NULL) - break; - fclose(tfile); /* oops, it's there; close tfile & try again */ - } -} - - -/* - * Near-memory allocation and freeing are controlled by the regular library - * routines malloc() and free(). - */ - -GLOBAL(void *) -jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void *) malloc(sizeofobject); -} - -GLOBAL(void) -jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) -{ - free(object); -} - - -/* - * "Large" objects are allocated in far memory, if possible - */ - -GLOBAL(void FAR *) -jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void FAR *) far_malloc(sizeofobject); -} - -GLOBAL(void) -jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) -{ - far_free(object); -} - - -/* - * This routine computes the total memory space available for allocation. - * It's impossible to do this in a portable way; our current solution is - * to make the user tell us (with a default value set at compile time). - * If you can actually get the available space, it's a good idea to subtract - * a slop factor of 5% or so. - */ - -#ifndef DEFAULT_MAX_MEM /* so can override from makefile */ -#define DEFAULT_MAX_MEM 300000L /* for total usage about 450K */ -#endif - -GLOBAL(long) -jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, - long max_bytes_needed, long already_allocated) -{ - return cinfo->mem->max_memory_to_use - already_allocated; -} - - -/* - * Backing store (temporary file) management. - * Backing store objects are only used when the value returned by - * jpeg_mem_available is less than the total space needed. You can dispense - * with these routines if you have plenty of virtual memory; see jmemnobs.c. - */ - -/* - * For MS-DOS we support three types of backing storage: - * 1. Conventional DOS files. We access these by direct DOS calls rather - * than via the stdio package. This provides a bit better performance, - * but the real reason is that the buffers to be read or written are FAR. - * The stdio library for small-data memory models can't cope with that. - * 2. Extended memory, accessed per the XMS V2.0 specification. - * 3. Expanded memory, accessed per the LIM/EMS 4.0 specification. - * You'll need copies of those specs to make sense of the related code. - * The specs are available by Internet FTP from the SIMTEL archives - * (oak.oakland.edu and its various mirror sites). See files - * pub/msdos/microsoft/xms20.arc and pub/msdos/info/limems41.zip. - */ - - -/* - * Access methods for a DOS file. - */ - - -METHODDEF(void) -read_file_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - if (jdos_seek(info->handle.file_handle, file_offset)) - ERREXIT(cinfo, JERR_TFILE_SEEK); - /* Since MAX_ALLOC_CHUNK is less than 64K, byte_count will be too. */ - if (byte_count > 65535L) /* safety check */ - ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK); - if (jdos_read(info->handle.file_handle, buffer_address, - (unsigned short) byte_count)) - ERREXIT(cinfo, JERR_TFILE_READ); -} - - -METHODDEF(void) -write_file_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - if (jdos_seek(info->handle.file_handle, file_offset)) - ERREXIT(cinfo, JERR_TFILE_SEEK); - /* Since MAX_ALLOC_CHUNK is less than 64K, byte_count will be too. */ - if (byte_count > 65535L) /* safety check */ - ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK); - if (jdos_write(info->handle.file_handle, buffer_address, - (unsigned short) byte_count)) - ERREXIT(cinfo, JERR_TFILE_WRITE); -} - - -METHODDEF(void) -close_file_store (j_common_ptr cinfo, backing_store_ptr info) -{ - jdos_close(info->handle.file_handle); /* close the file */ - remove(info->temp_name); /* delete the file */ -/* If your system doesn't have remove(), try unlink() instead. - * remove() is the ANSI-standard name for this function, but - * unlink() was more common in pre-ANSI systems. - */ - TRACEMSS(cinfo, 1, JTRC_TFILE_CLOSE, info->temp_name); -} - - -LOCAL(boolean) -open_file_store (j_common_ptr cinfo, backing_store_ptr info, - long total_bytes_needed) -{ - short handle; - - select_file_name(info->temp_name); - if (jdos_open((short far *) & handle, (char far *) info->temp_name)) { - /* might as well exit since jpeg_open_backing_store will fail anyway */ - ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name); - return FALSE; - } - info->handle.file_handle = handle; - info->read_backing_store = read_file_store; - info->write_backing_store = write_file_store; - info->close_backing_store = close_file_store; - TRACEMSS(cinfo, 1, JTRC_TFILE_OPEN, info->temp_name); - return TRUE; /* succeeded */ -} - - -/* - * Access methods for extended memory. - */ - -#if XMS_SUPPORTED - -static XMSDRIVER xms_driver; /* saved address of XMS driver */ - -typedef union { /* either long offset or real-mode pointer */ - long offset; - void far * ptr; - } XMSPTR; - -typedef struct { /* XMS move specification structure */ - long length; - XMSH src_handle; - XMSPTR src; - XMSH dst_handle; - XMSPTR dst; - } XMSspec; - -#define ODD(X) (((X) & 1L) != 0) - - -METHODDEF(void) -read_xms_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - XMScontext ctx; - XMSspec spec; - char endbuffer[2]; - - /* The XMS driver can't cope with an odd length, so handle the last byte - * specially if byte_count is odd. We don't expect this to be common. - */ - - spec.length = byte_count & (~ 1L); - spec.src_handle = info->handle.xms_handle; - spec.src.offset = file_offset; - spec.dst_handle = 0; - spec.dst.ptr = buffer_address; - - ctx.ds_si = (void far *) & spec; - ctx.ax = 0x0b00; /* EMB move */ - jxms_calldriver(xms_driver, (XMScontext far *) & ctx); - if (ctx.ax != 1) - ERREXIT(cinfo, JERR_XMS_READ); - - if (ODD(byte_count)) { - read_xms_store(cinfo, info, (void FAR *) endbuffer, - file_offset + byte_count - 1L, 2L); - ((char FAR *) buffer_address)[byte_count - 1L] = endbuffer[0]; - } -} - - -METHODDEF(void) -write_xms_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - XMScontext ctx; - XMSspec spec; - char endbuffer[2]; - - /* The XMS driver can't cope with an odd length, so handle the last byte - * specially if byte_count is odd. We don't expect this to be common. - */ - - spec.length = byte_count & (~ 1L); - spec.src_handle = 0; - spec.src.ptr = buffer_address; - spec.dst_handle = info->handle.xms_handle; - spec.dst.offset = file_offset; - - ctx.ds_si = (void far *) & spec; - ctx.ax = 0x0b00; /* EMB move */ - jxms_calldriver(xms_driver, (XMScontext far *) & ctx); - if (ctx.ax != 1) - ERREXIT(cinfo, JERR_XMS_WRITE); - - if (ODD(byte_count)) { - read_xms_store(cinfo, info, (void FAR *) endbuffer, - file_offset + byte_count - 1L, 2L); - endbuffer[0] = ((char FAR *) buffer_address)[byte_count - 1L]; - write_xms_store(cinfo, info, (void FAR *) endbuffer, - file_offset + byte_count - 1L, 2L); - } -} - - -METHODDEF(void) -close_xms_store (j_common_ptr cinfo, backing_store_ptr info) -{ - XMScontext ctx; - - ctx.dx = info->handle.xms_handle; - ctx.ax = 0x0a00; - jxms_calldriver(xms_driver, (XMScontext far *) & ctx); - TRACEMS1(cinfo, 1, JTRC_XMS_CLOSE, info->handle.xms_handle); - /* we ignore any error return from the driver */ -} - - -LOCAL(boolean) -open_xms_store (j_common_ptr cinfo, backing_store_ptr info, - long total_bytes_needed) -{ - XMScontext ctx; - - /* Get address of XMS driver */ - jxms_getdriver((XMSDRIVER far *) & xms_driver); - if (xms_driver == NULL) - return FALSE; /* no driver to be had */ - - /* Get version number, must be >= 2.00 */ - ctx.ax = 0x0000; - jxms_calldriver(xms_driver, (XMScontext far *) & ctx); - if (ctx.ax < (unsigned short) 0x0200) - return FALSE; - - /* Try to get space (expressed in kilobytes) */ - ctx.dx = (unsigned short) ((total_bytes_needed + 1023L) >> 10); - ctx.ax = 0x0900; - jxms_calldriver(xms_driver, (XMScontext far *) & ctx); - if (ctx.ax != 1) - return FALSE; - - /* Succeeded, save the handle and away we go */ - info->handle.xms_handle = ctx.dx; - info->read_backing_store = read_xms_store; - info->write_backing_store = write_xms_store; - info->close_backing_store = close_xms_store; - TRACEMS1(cinfo, 1, JTRC_XMS_OPEN, ctx.dx); - return TRUE; /* succeeded */ -} - -#endif /* XMS_SUPPORTED */ - - -/* - * Access methods for expanded memory. - */ - -#if EMS_SUPPORTED - -/* The EMS move specification structure requires word and long fields aligned - * at odd byte boundaries. Some compilers will align struct fields at even - * byte boundaries. While it's usually possible to force byte alignment, - * that causes an overall performance penalty and may pose problems in merging - * JPEG into a larger application. Instead we accept some rather dirty code - * here. Note this code would fail if the hardware did not allow odd-byte - * word & long accesses, but all 80x86 CPUs do. - */ - -typedef void far * EMSPTR; - -typedef union { /* EMS move specification structure */ - long length; /* It's easy to access first 4 bytes */ - char bytes[18]; /* Misaligned fields in here! */ - } EMSspec; - -/* Macros for accessing misaligned fields */ -#define FIELD_AT(spec,offset,type) (*((type *) &(spec.bytes[offset]))) -#define SRC_TYPE(spec) FIELD_AT(spec,4,char) -#define SRC_HANDLE(spec) FIELD_AT(spec,5,EMSH) -#define SRC_OFFSET(spec) FIELD_AT(spec,7,unsigned short) -#define SRC_PAGE(spec) FIELD_AT(spec,9,unsigned short) -#define SRC_PTR(spec) FIELD_AT(spec,7,EMSPTR) -#define DST_TYPE(spec) FIELD_AT(spec,11,char) -#define DST_HANDLE(spec) FIELD_AT(spec,12,EMSH) -#define DST_OFFSET(spec) FIELD_AT(spec,14,unsigned short) -#define DST_PAGE(spec) FIELD_AT(spec,16,unsigned short) -#define DST_PTR(spec) FIELD_AT(spec,14,EMSPTR) - -#define EMSPAGESIZE 16384L /* gospel, see the EMS specs */ - -#define HIBYTE(W) (((W) >> 8) & 0xFF) -#define LOBYTE(W) ((W) & 0xFF) - - -METHODDEF(void) -read_ems_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - EMScontext ctx; - EMSspec spec; - - spec.length = byte_count; - SRC_TYPE(spec) = 1; - SRC_HANDLE(spec) = info->handle.ems_handle; - SRC_PAGE(spec) = (unsigned short) (file_offset / EMSPAGESIZE); - SRC_OFFSET(spec) = (unsigned short) (file_offset % EMSPAGESIZE); - DST_TYPE(spec) = 0; - DST_HANDLE(spec) = 0; - DST_PTR(spec) = buffer_address; - - ctx.ds_si = (void far *) & spec; - ctx.ax = 0x5700; /* move memory region */ - jems_calldriver((EMScontext far *) & ctx); - if (HIBYTE(ctx.ax) != 0) - ERREXIT(cinfo, JERR_EMS_READ); -} - - -METHODDEF(void) -write_ems_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - EMScontext ctx; - EMSspec spec; - - spec.length = byte_count; - SRC_TYPE(spec) = 0; - SRC_HANDLE(spec) = 0; - SRC_PTR(spec) = buffer_address; - DST_TYPE(spec) = 1; - DST_HANDLE(spec) = info->handle.ems_handle; - DST_PAGE(spec) = (unsigned short) (file_offset / EMSPAGESIZE); - DST_OFFSET(spec) = (unsigned short) (file_offset % EMSPAGESIZE); - - ctx.ds_si = (void far *) & spec; - ctx.ax = 0x5700; /* move memory region */ - jems_calldriver((EMScontext far *) & ctx); - if (HIBYTE(ctx.ax) != 0) - ERREXIT(cinfo, JERR_EMS_WRITE); -} - - -METHODDEF(void) -close_ems_store (j_common_ptr cinfo, backing_store_ptr info) -{ - EMScontext ctx; - - ctx.ax = 0x4500; - ctx.dx = info->handle.ems_handle; - jems_calldriver((EMScontext far *) & ctx); - TRACEMS1(cinfo, 1, JTRC_EMS_CLOSE, info->handle.ems_handle); - /* we ignore any error return from the driver */ -} - - -LOCAL(boolean) -open_ems_store (j_common_ptr cinfo, backing_store_ptr info, - long total_bytes_needed) -{ - EMScontext ctx; - - /* Is EMS driver there? */ - if (! jems_available()) - return FALSE; - - /* Get status, make sure EMS is OK */ - ctx.ax = 0x4000; - jems_calldriver((EMScontext far *) & ctx); - if (HIBYTE(ctx.ax) != 0) - return FALSE; - - /* Get version, must be >= 4.0 */ - ctx.ax = 0x4600; - jems_calldriver((EMScontext far *) & ctx); - if (HIBYTE(ctx.ax) != 0 || LOBYTE(ctx.ax) < 0x40) - return FALSE; - - /* Try to allocate requested space */ - ctx.ax = 0x4300; - ctx.bx = (unsigned short) ((total_bytes_needed + EMSPAGESIZE-1L) / EMSPAGESIZE); - jems_calldriver((EMScontext far *) & ctx); - if (HIBYTE(ctx.ax) != 0) - return FALSE; - - /* Succeeded, save the handle and away we go */ - info->handle.ems_handle = ctx.dx; - info->read_backing_store = read_ems_store; - info->write_backing_store = write_ems_store; - info->close_backing_store = close_ems_store; - TRACEMS1(cinfo, 1, JTRC_EMS_OPEN, ctx.dx); - return TRUE; /* succeeded */ -} - -#endif /* EMS_SUPPORTED */ - - -/* - * Initial opening of a backing-store object. - */ - -GLOBAL(void) -jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, - long total_bytes_needed) -{ - /* Try extended memory, then expanded memory, then regular file. */ -#if XMS_SUPPORTED - if (open_xms_store(cinfo, info, total_bytes_needed)) - return; -#endif -#if EMS_SUPPORTED - if (open_ems_store(cinfo, info, total_bytes_needed)) - return; -#endif - if (open_file_store(cinfo, info, total_bytes_needed)) - return; - ERREXITS(cinfo, JERR_TFILE_CREATE, ""); -} - - -/* - * These routines take care of any system-dependent initialization and - * cleanup required. - */ - -GLOBAL(long) -jpeg_mem_init (j_common_ptr cinfo) -{ - next_file_num = 0; /* initialize temp file name generator */ - return DEFAULT_MAX_MEM; /* default for max_memory_to_use */ -} - -GLOBAL(void) -jpeg_mem_term (j_common_ptr cinfo) -{ - /* Microsoft C, at least in v6.00A, will not successfully reclaim freed - * blocks of size > 32Kbytes unless we give it a kick in the rear, like so: - */ -#ifdef NEED_FHEAPMIN - _fheapmin(); -#endif -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jmemdosa.asm b/irrlicht-1.6/source/Irrlicht/jpeglib/jmemdosa.asm deleted file mode 100644 index c6ec48b34..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jmemdosa.asm +++ /dev/null @@ -1,379 +0,0 @@ -; -; jmemdosa.asm -; -; Copyright (C) 1992, Thomas G. Lane. -; This file is part of the Independent JPEG Group's software. -; For conditions of distribution and use, see the accompanying README file. -; -; This file contains low-level interface routines to support the MS-DOS -; backing store manager (jmemdos.c). Routines are provided to access disk -; files through direct DOS calls, and to access XMS and EMS drivers. -; -; This file should assemble with Microsoft's MASM or any compatible -; assembler (including Borland's Turbo Assembler). If you haven't got -; a compatible assembler, better fall back to jmemansi.c or jmemname.c. -; -; To minimize dependence on the C compiler's register usage conventions, -; we save and restore all 8086 registers, even though most compilers only -; require SI,DI,DS to be preserved. Also, we use only 16-bit-wide return -; values, which everybody returns in AX. -; -; Based on code contributed by Ge' Weijers. -; - -JMEMDOSA_TXT segment byte public 'CODE' - - assume cs:JMEMDOSA_TXT - - public _jdos_open - public _jdos_close - public _jdos_seek - public _jdos_read - public _jdos_write - public _jxms_getdriver - public _jxms_calldriver - public _jems_available - public _jems_calldriver - -; -; short far jdos_open (short far * handle, char far * filename) -; -; Create and open a temporary file -; -_jdos_open proc far - push bp ; linkage - mov bp,sp - push si ; save all registers for safety - push di - push bx - push cx - push dx - push es - push ds - mov cx,0 ; normal file attributes - lds dx,dword ptr [bp+10] ; get filename pointer - mov ah,3ch ; create file - int 21h - jc open_err ; if failed, return error code - lds bx,dword ptr [bp+6] ; get handle pointer - mov word ptr [bx],ax ; save the handle - xor ax,ax ; return zero for OK -open_err: pop ds ; restore registers and exit - pop es - pop dx - pop cx - pop bx - pop di - pop si - pop bp - ret -_jdos_open endp - - -; -; short far jdos_close (short handle) -; -; Close the file handle -; -_jdos_close proc far - push bp ; linkage - mov bp,sp - push si ; save all registers for safety - push di - push bx - push cx - push dx - push es - push ds - mov bx,word ptr [bp+6] ; file handle - mov ah,3eh ; close file - int 21h - jc close_err ; if failed, return error code - xor ax,ax ; return zero for OK -close_err: pop ds ; restore registers and exit - pop es - pop dx - pop cx - pop bx - pop di - pop si - pop bp - ret -_jdos_close endp - - -; -; short far jdos_seek (short handle, long offset) -; -; Set file position -; -_jdos_seek proc far - push bp ; linkage - mov bp,sp - push si ; save all registers for safety - push di - push bx - push cx - push dx - push es - push ds - mov bx,word ptr [bp+6] ; file handle - mov dx,word ptr [bp+8] ; LS offset - mov cx,word ptr [bp+10] ; MS offset - mov ax,4200h ; absolute seek - int 21h - jc seek_err ; if failed, return error code - xor ax,ax ; return zero for OK -seek_err: pop ds ; restore registers and exit - pop es - pop dx - pop cx - pop bx - pop di - pop si - pop bp - ret -_jdos_seek endp - - -; -; short far jdos_read (short handle, void far * buffer, unsigned short count) -; -; Read from file -; -_jdos_read proc far - push bp ; linkage - mov bp,sp - push si ; save all registers for safety - push di - push bx - push cx - push dx - push es - push ds - mov bx,word ptr [bp+6] ; file handle - lds dx,dword ptr [bp+8] ; buffer address - mov cx,word ptr [bp+12] ; number of bytes - mov ah,3fh ; read file - int 21h - jc read_err ; if failed, return error code - cmp ax,word ptr [bp+12] ; make sure all bytes were read - je read_ok - mov ax,1 ; else return 1 for not OK - jmp short read_err -read_ok: xor ax,ax ; return zero for OK -read_err: pop ds ; restore registers and exit - pop es - pop dx - pop cx - pop bx - pop di - pop si - pop bp - ret -_jdos_read endp - - -; -; short far jdos_write (short handle, void far * buffer, unsigned short count) -; -; Write to file -; -_jdos_write proc far - push bp ; linkage - mov bp,sp - push si ; save all registers for safety - push di - push bx - push cx - push dx - push es - push ds - mov bx,word ptr [bp+6] ; file handle - lds dx,dword ptr [bp+8] ; buffer address - mov cx,word ptr [bp+12] ; number of bytes - mov ah,40h ; write file - int 21h - jc write_err ; if failed, return error code - cmp ax,word ptr [bp+12] ; make sure all bytes written - je write_ok - mov ax,1 ; else return 1 for not OK - jmp short write_err -write_ok: xor ax,ax ; return zero for OK -write_err: pop ds ; restore registers and exit - pop es - pop dx - pop cx - pop bx - pop di - pop si - pop bp - ret -_jdos_write endp - - -; -; void far jxms_getdriver (XMSDRIVER far *) -; -; Get the address of the XMS driver, or NULL if not available -; -_jxms_getdriver proc far - push bp ; linkage - mov bp,sp - push si ; save all registers for safety - push di - push bx - push cx - push dx - push es - push ds - mov ax,4300h ; call multiplex interrupt with - int 2fh ; a magic cookie, hex 4300 - cmp al,80h ; AL should contain hex 80 - je xmsavail - xor dx,dx ; no XMS driver available - xor ax,ax ; return a nil pointer - jmp short xmsavail_done -xmsavail: mov ax,4310h ; fetch driver address with - int 2fh ; another magic cookie - mov dx,es ; copy address to dx:ax - mov ax,bx -xmsavail_done: les bx,dword ptr [bp+6] ; get pointer to return value - mov word ptr es:[bx],ax - mov word ptr es:[bx+2],dx - pop ds ; restore registers and exit - pop es - pop dx - pop cx - pop bx - pop di - pop si - pop bp - ret -_jxms_getdriver endp - - -; -; void far jxms_calldriver (XMSDRIVER, XMScontext far *) -; -; The XMScontext structure contains values for the AX,DX,BX,SI,DS registers. -; These are loaded, the XMS call is performed, and the new values of the -; AX,DX,BX registers are written back to the context structure. -; -_jxms_calldriver proc far - push bp ; linkage - mov bp,sp - push si ; save all registers for safety - push di - push bx - push cx - push dx - push es - push ds - les bx,dword ptr [bp+10] ; get XMScontext pointer - mov ax,word ptr es:[bx] ; load registers - mov dx,word ptr es:[bx+2] - mov si,word ptr es:[bx+6] - mov ds,word ptr es:[bx+8] - mov bx,word ptr es:[bx+4] - call dword ptr [bp+6] ; call the driver - mov cx,bx ; save returned BX for a sec - les bx,dword ptr [bp+10] ; get XMScontext pointer - mov word ptr es:[bx],ax ; put back ax,dx,bx - mov word ptr es:[bx+2],dx - mov word ptr es:[bx+4],cx - pop ds ; restore registers and exit - pop es - pop dx - pop cx - pop bx - pop di - pop si - pop bp - ret -_jxms_calldriver endp - - -; -; short far jems_available (void) -; -; Have we got an EMS driver? (this comes straight from the EMS 4.0 specs) -; -_jems_available proc far - push si ; save all registers for safety - push di - push bx - push cx - push dx - push es - push ds - mov ax,3567h ; get interrupt vector 67h - int 21h - push cs - pop ds - mov di,000ah ; check offs 10 in returned seg - lea si,ASCII_device_name ; against literal string - mov cx,8 - cld - repe cmpsb - jne no_ems - mov ax,1 ; match, it's there - jmp short avail_done -no_ems: xor ax,ax ; it's not there -avail_done: pop ds ; restore registers and exit - pop es - pop dx - pop cx - pop bx - pop di - pop si - ret - -ASCII_device_name db "EMMXXXX0" - -_jems_available endp - - -; -; void far jems_calldriver (EMScontext far *) -; -; The EMScontext structure contains values for the AX,DX,BX,SI,DS registers. -; These are loaded, the EMS trap is performed, and the new values of the -; AX,DX,BX registers are written back to the context structure. -; -_jems_calldriver proc far - push bp ; linkage - mov bp,sp - push si ; save all registers for safety - push di - push bx - push cx - push dx - push es - push ds - les bx,dword ptr [bp+6] ; get EMScontext pointer - mov ax,word ptr es:[bx] ; load registers - mov dx,word ptr es:[bx+2] - mov si,word ptr es:[bx+6] - mov ds,word ptr es:[bx+8] - mov bx,word ptr es:[bx+4] - int 67h ; call the EMS driver - mov cx,bx ; save returned BX for a sec - les bx,dword ptr [bp+6] ; get EMScontext pointer - mov word ptr es:[bx],ax ; put back ax,dx,bx - mov word ptr es:[bx+2],dx - mov word ptr es:[bx+4],cx - pop ds ; restore registers and exit - pop es - pop dx - pop cx - pop bx - pop di - pop si - pop bp - ret -_jems_calldriver endp - -JMEMDOSA_TXT ends - - end diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jmemmac.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jmemmac.c deleted file mode 100644 index a6f043ed4..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jmemmac.c +++ /dev/null @@ -1,289 +0,0 @@ -/* - * jmemmac.c - * - * Copyright (C) 1992-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * jmemmac.c provides an Apple Macintosh implementation of the system- - * dependent portion of the JPEG memory manager. - * - * If you use jmemmac.c, then you must define USE_MAC_MEMMGR in the - * JPEG_INTERNALS part of jconfig.h. - * - * jmemmac.c uses the Macintosh toolbox routines NewPtr and DisposePtr - * instead of malloc and free. It accurately determines the amount of - * memory available by using CompactMem. Notice that if left to its - * own devices, this code can chew up all available space in the - * application's zone, with the exception of the rather small "slop" - * factor computed in jpeg_mem_available(). The application can ensure - * that more space is left over by reducing max_memory_to_use. - * - * Large images are swapped to disk using temporary files and System 7.0+'s - * temporary folder functionality. - * - * Note that jmemmac.c depends on two features of MacOS that were first - * introduced in System 7: FindFolder and the FSSpec-based calls. - * If your application uses jmemmac.c and is run under System 6 or earlier, - * and the jpeg library decides it needs a temporary file, it will abort, - * printing error messages about requiring System 7. (If no temporary files - * are created, it will run fine.) - * - * If you want to use jmemmac.c in an application that might be used with - * System 6 or earlier, then you should remove dependencies on FindFolder - * and the FSSpec calls. You will need to replace FindFolder with some - * other mechanism for finding a place to put temporary files, and you - * should replace the FSSpec calls with their HFS equivalents: - * - * FSpDelete -> HDelete - * FSpGetFInfo -> HGetFInfo - * FSpCreate -> HCreate - * FSpOpenDF -> HOpen *** Note: not HOpenDF *** - * FSMakeFSSpec -> (fill in spec by hand.) - * - * (Use HOpen instead of HOpenDF. HOpen is just a glue-interface to PBHOpen, - * which is on all HFS macs. HOpenDF is a System 7 addition which avoids the - * ages-old problem of names starting with a period.) - * - * Contributed by Sam Bushell (jsam@iagu.on.net) and - * Dan Gildor (gyld@in-touch.com). - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jmemsys.h" /* import the system-dependent declarations */ - -#ifndef USE_MAC_MEMMGR /* make sure user got configuration right */ - You forgot to define USE_MAC_MEMMGR in jconfig.h. /* deliberate syntax error */ -#endif - -#include <Memory.h> /* we use the MacOS memory manager */ -#include <Files.h> /* we use the MacOS File stuff */ -#include <Folders.h> /* we use the MacOS HFS stuff */ -#include <Script.h> /* for smSystemScript */ -#include <Gestalt.h> /* we use Gestalt to test for specific functionality */ - -#ifndef TEMP_FILE_NAME /* can override from jconfig.h or Makefile */ -#define TEMP_FILE_NAME "JPG%03d.TMP" -#endif - -static int next_file_num; /* to distinguish among several temp files */ - - -/* - * Memory allocation and freeing are controlled by the MacOS library - * routines NewPtr() and DisposePtr(), which allocate fixed-address - * storage. Unfortunately, the IJG library isn't smart enough to cope - * with relocatable storage. - */ - -GLOBAL(void *) -jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void *) NewPtr(sizeofobject); -} - -GLOBAL(void) -jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) -{ - DisposePtr((Ptr) object); -} - - -/* - * "Large" objects are treated the same as "small" ones. - * NB: we include FAR keywords in the routine declarations simply for - * consistency with the rest of the IJG code; FAR should expand to empty - * on rational architectures like the Mac. - */ - -GLOBAL(void FAR *) -jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void FAR *) NewPtr(sizeofobject); -} - -GLOBAL(void) -jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) -{ - DisposePtr((Ptr) object); -} - - -/* - * This routine computes the total memory space available for allocation. - */ - -GLOBAL(long) -jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, - long max_bytes_needed, long already_allocated) -{ - long limit = cinfo->mem->max_memory_to_use - already_allocated; - long slop, mem; - - /* Don't ask for more than what application has told us we may use */ - if (max_bytes_needed > limit && limit > 0) - max_bytes_needed = limit; - /* Find whether there's a big enough free block in the heap. - * CompactMem tries to create a contiguous block of the requested size, - * and then returns the size of the largest free block (which could be - * much more or much less than we asked for). - * We add some slop to ensure we don't use up all available memory. - */ - slop = max_bytes_needed / 16 + 32768L; - mem = CompactMem(max_bytes_needed + slop) - slop; - if (mem < 0) - mem = 0; /* sigh, couldn't even get the slop */ - /* Don't take more than the application says we can have */ - if (mem > limit && limit > 0) - mem = limit; - return mem; -} - - -/* - * Backing store (temporary file) management. - * Backing store objects are only used when the value returned by - * jpeg_mem_available is less than the total space needed. You can dispense - * with these routines if you have plenty of virtual memory; see jmemnobs.c. - */ - - -METHODDEF(void) -read_backing_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - long bytes = byte_count; - long retVal; - - if ( SetFPos ( info->temp_file, fsFromStart, file_offset ) != noErr ) - ERREXIT(cinfo, JERR_TFILE_SEEK); - - retVal = FSRead ( info->temp_file, &bytes, - (unsigned char *) buffer_address ); - if ( retVal != noErr || bytes != byte_count ) - ERREXIT(cinfo, JERR_TFILE_READ); -} - - -METHODDEF(void) -write_backing_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - long bytes = byte_count; - long retVal; - - if ( SetFPos ( info->temp_file, fsFromStart, file_offset ) != noErr ) - ERREXIT(cinfo, JERR_TFILE_SEEK); - - retVal = FSWrite ( info->temp_file, &bytes, - (unsigned char *) buffer_address ); - if ( retVal != noErr || bytes != byte_count ) - ERREXIT(cinfo, JERR_TFILE_WRITE); -} - - -METHODDEF(void) -close_backing_store (j_common_ptr cinfo, backing_store_ptr info) -{ - FSClose ( info->temp_file ); - FSpDelete ( &(info->tempSpec) ); -} - - -/* - * Initial opening of a backing-store object. - * - * This version uses FindFolder to find the Temporary Items folder, - * and puts the temporary file in there. - */ - -GLOBAL(void) -jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, - long total_bytes_needed) -{ - short tmpRef, vRefNum; - long dirID; - FInfo finderInfo; - FSSpec theSpec; - Str255 fName; - OSErr osErr; - long gestaltResponse = 0; - - /* Check that FSSpec calls are available. */ - osErr = Gestalt( gestaltFSAttr, &gestaltResponse ); - if ( ( osErr != noErr ) - || !( gestaltResponse & (1<<gestaltHasFSSpecCalls) ) ) - ERREXITS(cinfo, JERR_TFILE_CREATE, "- System 7.0 or later required"); - /* TO DO: add a proper error message to jerror.h. */ - - /* Check that FindFolder is available. */ - osErr = Gestalt( gestaltFindFolderAttr, &gestaltResponse ); - if ( ( osErr != noErr ) - || !( gestaltResponse & (1<<gestaltFindFolderPresent) ) ) - ERREXITS(cinfo, JERR_TFILE_CREATE, "- System 7.0 or later required."); - /* TO DO: add a proper error message to jerror.h. */ - - osErr = FindFolder ( kOnSystemDisk, kTemporaryFolderType, kCreateFolder, - &vRefNum, &dirID ); - if ( osErr != noErr ) - ERREXITS(cinfo, JERR_TFILE_CREATE, "- temporary items folder unavailable"); - /* TO DO: Try putting the temp files somewhere else. */ - - /* Keep generating file names till we find one that's not in use */ - for (;;) { - next_file_num++; /* advance counter */ - - sprintf(info->temp_name, TEMP_FILE_NAME, next_file_num); - strcpy ( (Ptr)fName+1, info->temp_name ); - *fName = strlen (info->temp_name); - osErr = FSMakeFSSpec ( vRefNum, dirID, fName, &theSpec ); - - if ( (osErr = FSpGetFInfo ( &theSpec, &finderInfo ) ) != noErr ) - break; - } - - osErr = FSpCreate ( &theSpec, '????', '????', smSystemScript ); - if ( osErr != noErr ) - ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name); - - osErr = FSpOpenDF ( &theSpec, fsRdWrPerm, &(info->temp_file) ); - if ( osErr != noErr ) - ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name); - - info->tempSpec = theSpec; - - info->read_backing_store = read_backing_store; - info->write_backing_store = write_backing_store; - info->close_backing_store = close_backing_store; - TRACEMSS(cinfo, 1, JTRC_TFILE_OPEN, info->temp_name); -} - - -/* - * These routines take care of any system-dependent initialization and - * cleanup required. - */ - -GLOBAL(long) -jpeg_mem_init (j_common_ptr cinfo) -{ - next_file_num = 0; - - /* max_memory_to_use will be initialized to FreeMem()'s result; - * the calling application might later reduce it, for example - * to leave room to invoke multiple JPEG objects. - * Note that FreeMem returns the total number of free bytes; - * it may not be possible to allocate a single block of this size. - */ - return FreeMem(); -} - -GLOBAL(void) -jpeg_mem_term (j_common_ptr cinfo) -{ - /* no work */ -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jmemmgr.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jmemmgr.c deleted file mode 100644 index b636f1be5..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jmemmgr.c +++ /dev/null @@ -1,1118 +0,0 @@ -/* - * jmemmgr.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the JPEG system-independent memory management - * routines. This code is usable across a wide variety of machines; most - * of the system dependencies have been isolated in a separate file. - * The major functions provided here are: - * * pool-based allocation and freeing of memory; - * * policy decisions about how to divide available memory among the - * virtual arrays; - * * control logic for swapping virtual arrays between main memory and - * backing storage. - * The separate system-dependent file provides the actual backing-storage - * access code, and it contains the policy decision about how much total - * main memory to use. - * This file is system-dependent in the sense that some of its functions - * are unnecessary in some systems. For example, if there is enough virtual - * memory so that backing storage will never be used, much of the virtual - * array control logic could be removed. (Of course, if you have that much - * memory then you shouldn't care about a little bit of unused code...) - */ - -#define JPEG_INTERNALS -#define AM_MEMORY_MANAGER /* we define jvirt_Xarray_control structs */ -#include "jinclude.h" -#include "jpeglib.h" -#include "jmemsys.h" /* import the system-dependent declarations */ - -#ifndef NO_GETENV -#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare getenv() */ -extern char * getenv JPP((const char * name)); -#endif -#endif - - -/* - * Some important notes: - * The allocation routines provided here must never return NULL. - * They should exit to error_exit if unsuccessful. - * - * It's not a good idea to try to merge the sarray and barray routines, - * even though they are textually almost the same, because samples are - * usually stored as bytes while coefficients are shorts or ints. Thus, - * in machines where byte pointers have a different representation from - * word pointers, the resulting machine code could not be the same. - */ - - -/* - * Many machines require storage alignment: longs must start on 4-byte - * boundaries, doubles on 8-byte boundaries, etc. On such machines, malloc() - * always returns pointers that are multiples of the worst-case alignment - * requirement, and we had better do so too. - * There isn't any really portable way to determine the worst-case alignment - * requirement. This module assumes that the alignment requirement is - * multiples of sizeof(ALIGN_TYPE). - * By default, we define ALIGN_TYPE as double. This is necessary on some - * workstations (where doubles really do need 8-byte alignment) and will work - * fine on nearly everything. If your machine has lesser alignment needs, - * you can save a few bytes by making ALIGN_TYPE smaller. - * The only place I know of where this will NOT work is certain Macintosh - * 680x0 compilers that define double as a 10-byte IEEE extended float. - * Doing 10-byte alignment is counterproductive because longwords won't be - * aligned well. Put "#define ALIGN_TYPE long" in jconfig.h if you have - * such a compiler. - */ - -#ifndef ALIGN_TYPE /* so can override from jconfig.h */ -#define ALIGN_TYPE double -#endif - - -/* - * We allocate objects from "pools", where each pool is gotten with a single - * request to jpeg_get_small() or jpeg_get_large(). There is no per-object - * overhead within a pool, except for alignment padding. Each pool has a - * header with a link to the next pool of the same class. - * Small and large pool headers are identical except that the latter's - * link pointer must be FAR on 80x86 machines. - * Notice that the "real" header fields are union'ed with a dummy ALIGN_TYPE - * field. This forces the compiler to make SIZEOF(small_pool_hdr) a multiple - * of the alignment requirement of ALIGN_TYPE. - */ - -typedef union small_pool_struct * small_pool_ptr; - -typedef union small_pool_struct { - struct { - small_pool_ptr next; /* next in list of pools */ - size_t bytes_used; /* how many bytes already used within pool */ - size_t bytes_left; /* bytes still available in this pool */ - } hdr; - ALIGN_TYPE dummy; /* included in union to ensure alignment */ -} small_pool_hdr; - -typedef union large_pool_struct FAR * large_pool_ptr; - -typedef union large_pool_struct { - struct { - large_pool_ptr next; /* next in list of pools */ - size_t bytes_used; /* how many bytes already used within pool */ - size_t bytes_left; /* bytes still available in this pool */ - } hdr; - ALIGN_TYPE dummy; /* included in union to ensure alignment */ -} large_pool_hdr; - - -/* - * Here is the full definition of a memory manager object. - */ - -typedef struct { - struct jpeg_memory_mgr pub; /* public fields */ - - /* Each pool identifier (lifetime class) names a linked list of pools. */ - small_pool_ptr small_list[JPOOL_NUMPOOLS]; - large_pool_ptr large_list[JPOOL_NUMPOOLS]; - - /* Since we only have one lifetime class of virtual arrays, only one - * linked list is necessary (for each datatype). Note that the virtual - * array control blocks being linked together are actually stored somewhere - * in the small-pool list. - */ - jvirt_sarray_ptr virt_sarray_list; - jvirt_barray_ptr virt_barray_list; - - /* This counts total space obtained from jpeg_get_small/large */ - long total_space_allocated; - - /* alloc_sarray and alloc_barray set this value for use by virtual - * array routines. - */ - JDIMENSION last_rowsperchunk; /* from most recent alloc_sarray/barray */ -} my_memory_mgr; - -typedef my_memory_mgr * my_mem_ptr; - - -/* - * The control blocks for virtual arrays. - * Note that these blocks are allocated in the "small" pool area. - * System-dependent info for the associated backing store (if any) is hidden - * inside the backing_store_info struct. - */ - -struct jvirt_sarray_control { - JSAMPARRAY mem_buffer; /* => the in-memory buffer */ - JDIMENSION rows_in_array; /* total virtual array height */ - JDIMENSION samplesperrow; /* width of array (and of memory buffer) */ - JDIMENSION maxaccess; /* max rows accessed by access_virt_sarray */ - JDIMENSION rows_in_mem; /* height of memory buffer */ - JDIMENSION rowsperchunk; /* allocation chunk size in mem_buffer */ - JDIMENSION cur_start_row; /* first logical row # in the buffer */ - JDIMENSION first_undef_row; /* row # of first uninitialized row */ - boolean pre_zero; /* pre-zero mode requested? */ - boolean dirty; /* do current buffer contents need written? */ - boolean b_s_open; /* is backing-store data valid? */ - jvirt_sarray_ptr next; /* link to next virtual sarray control block */ - backing_store_info b_s_info; /* System-dependent control info */ -}; - -struct jvirt_barray_control { - JBLOCKARRAY mem_buffer; /* => the in-memory buffer */ - JDIMENSION rows_in_array; /* total virtual array height */ - JDIMENSION blocksperrow; /* width of array (and of memory buffer) */ - JDIMENSION maxaccess; /* max rows accessed by access_virt_barray */ - JDIMENSION rows_in_mem; /* height of memory buffer */ - JDIMENSION rowsperchunk; /* allocation chunk size in mem_buffer */ - JDIMENSION cur_start_row; /* first logical row # in the buffer */ - JDIMENSION first_undef_row; /* row # of first uninitialized row */ - boolean pre_zero; /* pre-zero mode requested? */ - boolean dirty; /* do current buffer contents need written? */ - boolean b_s_open; /* is backing-store data valid? */ - jvirt_barray_ptr next; /* link to next virtual barray control block */ - backing_store_info b_s_info; /* System-dependent control info */ -}; - - -#ifdef MEM_STATS /* optional extra stuff for statistics */ - -LOCAL(void) -print_mem_stats (j_common_ptr cinfo, int pool_id) -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - small_pool_ptr shdr_ptr; - large_pool_ptr lhdr_ptr; - - /* Since this is only a debugging stub, we can cheat a little by using - * fprintf directly rather than going through the trace message code. - * This is helpful because message parm array can't handle longs. - */ - fprintf(stderr, "Freeing pool %d, total space = %ld\n", - pool_id, mem->total_space_allocated); - - for (lhdr_ptr = mem->large_list[pool_id]; lhdr_ptr != NULL; - lhdr_ptr = lhdr_ptr->hdr.next) { - fprintf(stderr, " Large chunk used %ld\n", - (long) lhdr_ptr->hdr.bytes_used); - } - - for (shdr_ptr = mem->small_list[pool_id]; shdr_ptr != NULL; - shdr_ptr = shdr_ptr->hdr.next) { - fprintf(stderr, " Small chunk used %ld free %ld\n", - (long) shdr_ptr->hdr.bytes_used, - (long) shdr_ptr->hdr.bytes_left); - } -} - -#endif /* MEM_STATS */ - - -LOCAL(void) -out_of_memory (j_common_ptr cinfo, int which) -/* Report an out-of-memory error and stop execution */ -/* If we compiled MEM_STATS support, report alloc requests before dying */ -{ -#ifdef MEM_STATS - cinfo->err->trace_level = 2; /* force self_destruct to report stats */ -#endif - ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, which); -} - - -/* - * Allocation of "small" objects. - * - * For these, we use pooled storage. When a new pool must be created, - * we try to get enough space for the current request plus a "slop" factor, - * where the slop will be the amount of leftover space in the new pool. - * The speed vs. space tradeoff is largely determined by the slop values. - * A different slop value is provided for each pool class (lifetime), - * and we also distinguish the first pool of a class from later ones. - * NOTE: the values given work fairly well on both 16- and 32-bit-int - * machines, but may be too small if longs are 64 bits or more. - */ - -static const size_t first_pool_slop[JPOOL_NUMPOOLS] = -{ - 1600, /* first PERMANENT pool */ - 16000 /* first IMAGE pool */ -}; - -static const size_t extra_pool_slop[JPOOL_NUMPOOLS] = -{ - 0, /* additional PERMANENT pools */ - 5000 /* additional IMAGE pools */ -}; - -#define MIN_SLOP 50 /* greater than 0 to avoid futile looping */ - - -METHODDEF(void *) -alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject) -/* Allocate a "small" object */ -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - small_pool_ptr hdr_ptr, prev_hdr_ptr; - char * data_ptr; - size_t odd_bytes, min_request, slop; - - /* Check for unsatisfiable request (do now to ensure no overflow below) */ - if (sizeofobject > (size_t) (MAX_ALLOC_CHUNK-SIZEOF(small_pool_hdr))) - out_of_memory(cinfo, 1); /* request exceeds malloc's ability */ - - /* Round up the requested size to a multiple of SIZEOF(ALIGN_TYPE) */ - odd_bytes = sizeofobject % SIZEOF(ALIGN_TYPE); - if (odd_bytes > 0) - sizeofobject += SIZEOF(ALIGN_TYPE) - odd_bytes; - - /* See if space is available in any existing pool */ - if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS) - ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ - prev_hdr_ptr = NULL; - hdr_ptr = mem->small_list[pool_id]; - while (hdr_ptr != NULL) { - if (hdr_ptr->hdr.bytes_left >= sizeofobject) - break; /* found pool with enough space */ - prev_hdr_ptr = hdr_ptr; - hdr_ptr = hdr_ptr->hdr.next; - } - - /* Time to make a new pool? */ - if (hdr_ptr == NULL) { - /* min_request is what we need now, slop is what will be leftover */ - min_request = sizeofobject + SIZEOF(small_pool_hdr); - if (prev_hdr_ptr == NULL) /* first pool in class? */ - slop = first_pool_slop[pool_id]; - else - slop = extra_pool_slop[pool_id]; - /* Don't ask for more than MAX_ALLOC_CHUNK */ - if (slop > (size_t) (MAX_ALLOC_CHUNK-min_request)) - slop = (size_t) (MAX_ALLOC_CHUNK-min_request); - /* Try to get space, if fail reduce slop and try again */ - for (;;) { - hdr_ptr = (small_pool_ptr) jpeg_get_small(cinfo, min_request + slop); - if (hdr_ptr != NULL) - break; - slop /= 2; - if (slop < MIN_SLOP) /* give up when it gets real small */ - out_of_memory(cinfo, 2); /* jpeg_get_small failed */ - } - mem->total_space_allocated += min_request + slop; - /* Success, initialize the new pool header and add to end of list */ - hdr_ptr->hdr.next = NULL; - hdr_ptr->hdr.bytes_used = 0; - hdr_ptr->hdr.bytes_left = sizeofobject + slop; - if (prev_hdr_ptr == NULL) /* first pool in class? */ - mem->small_list[pool_id] = hdr_ptr; - else - prev_hdr_ptr->hdr.next = hdr_ptr; - } - - /* OK, allocate the object from the current pool */ - data_ptr = (char *) (hdr_ptr + 1); /* point to first data byte in pool */ - data_ptr += hdr_ptr->hdr.bytes_used; /* point to place for object */ - hdr_ptr->hdr.bytes_used += sizeofobject; - hdr_ptr->hdr.bytes_left -= sizeofobject; - - return (void *) data_ptr; -} - - -/* - * Allocation of "large" objects. - * - * The external semantics of these are the same as "small" objects, - * except that FAR pointers are used on 80x86. However the pool - * management heuristics are quite different. We assume that each - * request is large enough that it may as well be passed directly to - * jpeg_get_large; the pool management just links everything together - * so that we can free it all on demand. - * Note: the major use of "large" objects is in JSAMPARRAY and JBLOCKARRAY - * structures. The routines that create these structures (see below) - * deliberately bunch rows together to ensure a large request size. - */ - -METHODDEF(void FAR *) -alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject) -/* Allocate a "large" object */ -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - large_pool_ptr hdr_ptr; - size_t odd_bytes; - - /* Check for unsatisfiable request (do now to ensure no overflow below) */ - if (sizeofobject > (size_t) (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr))) - out_of_memory(cinfo, 3); /* request exceeds malloc's ability */ - - /* Round up the requested size to a multiple of SIZEOF(ALIGN_TYPE) */ - odd_bytes = sizeofobject % SIZEOF(ALIGN_TYPE); - if (odd_bytes > 0) - sizeofobject += SIZEOF(ALIGN_TYPE) - odd_bytes; - - /* Always make a new pool */ - if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS) - ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ - - hdr_ptr = (large_pool_ptr) jpeg_get_large(cinfo, sizeofobject + - SIZEOF(large_pool_hdr)); - if (hdr_ptr == NULL) - out_of_memory(cinfo, 4); /* jpeg_get_large failed */ - mem->total_space_allocated += sizeofobject + SIZEOF(large_pool_hdr); - - /* Success, initialize the new pool header and add to list */ - hdr_ptr->hdr.next = mem->large_list[pool_id]; - /* We maintain space counts in each pool header for statistical purposes, - * even though they are not needed for allocation. - */ - hdr_ptr->hdr.bytes_used = sizeofobject; - hdr_ptr->hdr.bytes_left = 0; - mem->large_list[pool_id] = hdr_ptr; - - return (void FAR *) (hdr_ptr + 1); /* point to first data byte in pool */ -} - - -/* - * Creation of 2-D sample arrays. - * The pointers are in near heap, the samples themselves in FAR heap. - * - * To minimize allocation overhead and to allow I/O of large contiguous - * blocks, we allocate the sample rows in groups of as many rows as possible - * without exceeding MAX_ALLOC_CHUNK total bytes per allocation request. - * NB: the virtual array control routines, later in this file, know about - * this chunking of rows. The rowsperchunk value is left in the mem manager - * object so that it can be saved away if this sarray is the workspace for - * a virtual array. - */ - -METHODDEF(JSAMPARRAY) -alloc_sarray (j_common_ptr cinfo, int pool_id, - JDIMENSION samplesperrow, JDIMENSION numrows) -/* Allocate a 2-D sample array */ -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - JSAMPARRAY result; - JSAMPROW workspace; - JDIMENSION rowsperchunk, currow, i; - long ltemp; - - /* Calculate max # of rows allowed in one allocation chunk */ - ltemp = (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)) / - ((long) samplesperrow * SIZEOF(JSAMPLE)); - if (ltemp <= 0) - ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); - if (ltemp < (long) numrows) - rowsperchunk = (JDIMENSION) ltemp; - else - rowsperchunk = numrows; - mem->last_rowsperchunk = rowsperchunk; - - /* Get space for row pointers (small object) */ - result = (JSAMPARRAY) alloc_small(cinfo, pool_id, - (size_t) (numrows * SIZEOF(JSAMPROW))); - - /* Get the rows themselves (large objects) */ - currow = 0; - while (currow < numrows) { - rowsperchunk = MIN(rowsperchunk, numrows - currow); - workspace = (JSAMPROW) alloc_large(cinfo, pool_id, - (size_t) ((size_t) rowsperchunk * (size_t) samplesperrow - * SIZEOF(JSAMPLE))); - for (i = rowsperchunk; i > 0; i--) { - result[currow++] = workspace; - workspace += samplesperrow; - } - } - - return result; -} - - -/* - * Creation of 2-D coefficient-block arrays. - * This is essentially the same as the code for sample arrays, above. - */ - -METHODDEF(JBLOCKARRAY) -alloc_barray (j_common_ptr cinfo, int pool_id, - JDIMENSION blocksperrow, JDIMENSION numrows) -/* Allocate a 2-D coefficient-block array */ -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - JBLOCKARRAY result; - JBLOCKROW workspace; - JDIMENSION rowsperchunk, currow, i; - long ltemp; - - /* Calculate max # of rows allowed in one allocation chunk */ - ltemp = (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)) / - ((long) blocksperrow * SIZEOF(JBLOCK)); - if (ltemp <= 0) - ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); - if (ltemp < (long) numrows) - rowsperchunk = (JDIMENSION) ltemp; - else - rowsperchunk = numrows; - mem->last_rowsperchunk = rowsperchunk; - - /* Get space for row pointers (small object) */ - result = (JBLOCKARRAY) alloc_small(cinfo, pool_id, - (size_t) (numrows * SIZEOF(JBLOCKROW))); - - /* Get the rows themselves (large objects) */ - currow = 0; - while (currow < numrows) { - rowsperchunk = MIN(rowsperchunk, numrows - currow); - workspace = (JBLOCKROW) alloc_large(cinfo, pool_id, - (size_t) ((size_t) rowsperchunk * (size_t) blocksperrow - * SIZEOF(JBLOCK))); - for (i = rowsperchunk; i > 0; i--) { - result[currow++] = workspace; - workspace += blocksperrow; - } - } - - return result; -} - - -/* - * About virtual array management: - * - * The above "normal" array routines are only used to allocate strip buffers - * (as wide as the image, but just a few rows high). Full-image-sized buffers - * are handled as "virtual" arrays. The array is still accessed a strip at a - * time, but the memory manager must save the whole array for repeated - * accesses. The intended implementation is that there is a strip buffer in - * memory (as high as is possible given the desired memory limit), plus a - * backing file that holds the rest of the array. - * - * The request_virt_array routines are told the total size of the image and - * the maximum number of rows that will be accessed at once. The in-memory - * buffer must be at least as large as the maxaccess value. - * - * The request routines create control blocks but not the in-memory buffers. - * That is postponed until realize_virt_arrays is called. At that time the - * total amount of space needed is known (approximately, anyway), so free - * memory can be divided up fairly. - * - * The access_virt_array routines are responsible for making a specific strip - * area accessible (after reading or writing the backing file, if necessary). - * Note that the access routines are told whether the caller intends to modify - * the accessed strip; during a read-only pass this saves having to rewrite - * data to disk. The access routines are also responsible for pre-zeroing - * any newly accessed rows, if pre-zeroing was requested. - * - * In current usage, the access requests are usually for nonoverlapping - * strips; that is, successive access start_row numbers differ by exactly - * num_rows = maxaccess. This means we can get good performance with simple - * buffer dump/reload logic, by making the in-memory buffer be a multiple - * of the access height; then there will never be accesses across bufferload - * boundaries. The code will still work with overlapping access requests, - * but it doesn't handle bufferload overlaps very efficiently. - */ - - -METHODDEF(jvirt_sarray_ptr) -request_virt_sarray (j_common_ptr cinfo, int pool_id, boolean pre_zero, - JDIMENSION samplesperrow, JDIMENSION numrows, - JDIMENSION maxaccess) -/* Request a virtual 2-D sample array */ -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - jvirt_sarray_ptr result; - - /* Only IMAGE-lifetime virtual arrays are currently supported */ - if (pool_id != JPOOL_IMAGE) - ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ - - /* get control block */ - result = (jvirt_sarray_ptr) alloc_small(cinfo, pool_id, - SIZEOF(struct jvirt_sarray_control)); - - result->mem_buffer = NULL; /* marks array not yet realized */ - result->rows_in_array = numrows; - result->samplesperrow = samplesperrow; - result->maxaccess = maxaccess; - result->pre_zero = pre_zero; - result->b_s_open = FALSE; /* no associated backing-store object */ - result->next = mem->virt_sarray_list; /* add to list of virtual arrays */ - mem->virt_sarray_list = result; - - return result; -} - - -METHODDEF(jvirt_barray_ptr) -request_virt_barray (j_common_ptr cinfo, int pool_id, boolean pre_zero, - JDIMENSION blocksperrow, JDIMENSION numrows, - JDIMENSION maxaccess) -/* Request a virtual 2-D coefficient-block array */ -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - jvirt_barray_ptr result; - - /* Only IMAGE-lifetime virtual arrays are currently supported */ - if (pool_id != JPOOL_IMAGE) - ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ - - /* get control block */ - result = (jvirt_barray_ptr) alloc_small(cinfo, pool_id, - SIZEOF(struct jvirt_barray_control)); - - result->mem_buffer = NULL; /* marks array not yet realized */ - result->rows_in_array = numrows; - result->blocksperrow = blocksperrow; - result->maxaccess = maxaccess; - result->pre_zero = pre_zero; - result->b_s_open = FALSE; /* no associated backing-store object */ - result->next = mem->virt_barray_list; /* add to list of virtual arrays */ - mem->virt_barray_list = result; - - return result; -} - - -METHODDEF(void) -realize_virt_arrays (j_common_ptr cinfo) -/* Allocate the in-memory buffers for any unrealized virtual arrays */ -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - long space_per_minheight, maximum_space, avail_mem; - long minheights, max_minheights; - jvirt_sarray_ptr sptr; - jvirt_barray_ptr bptr; - - /* Compute the minimum space needed (maxaccess rows in each buffer) - * and the maximum space needed (full image height in each buffer). - * These may be of use to the system-dependent jpeg_mem_available routine. - */ - space_per_minheight = 0; - maximum_space = 0; - for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) { - if (sptr->mem_buffer == NULL) { /* if not realized yet */ - space_per_minheight += (long) sptr->maxaccess * - (long) sptr->samplesperrow * SIZEOF(JSAMPLE); - maximum_space += (long) sptr->rows_in_array * - (long) sptr->samplesperrow * SIZEOF(JSAMPLE); - } - } - for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) { - if (bptr->mem_buffer == NULL) { /* if not realized yet */ - space_per_minheight += (long) bptr->maxaccess * - (long) bptr->blocksperrow * SIZEOF(JBLOCK); - maximum_space += (long) bptr->rows_in_array * - (long) bptr->blocksperrow * SIZEOF(JBLOCK); - } - } - - if (space_per_minheight <= 0) - return; /* no unrealized arrays, no work */ - - /* Determine amount of memory to actually use; this is system-dependent. */ - avail_mem = jpeg_mem_available(cinfo, space_per_minheight, maximum_space, - mem->total_space_allocated); - - /* If the maximum space needed is available, make all the buffers full - * height; otherwise parcel it out with the same number of minheights - * in each buffer. - */ - if (avail_mem >= maximum_space) - max_minheights = 1000000000L; - else { - max_minheights = avail_mem / space_per_minheight; - /* If there doesn't seem to be enough space, try to get the minimum - * anyway. This allows a "stub" implementation of jpeg_mem_available(). - */ - if (max_minheights <= 0) - max_minheights = 1; - } - - /* Allocate the in-memory buffers and initialize backing store as needed. */ - - for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) { - if (sptr->mem_buffer == NULL) { /* if not realized yet */ - minheights = ((long) sptr->rows_in_array - 1L) / sptr->maxaccess + 1L; - if (minheights <= max_minheights) { - /* This buffer fits in memory */ - sptr->rows_in_mem = sptr->rows_in_array; - } else { - /* It doesn't fit in memory, create backing store. */ - sptr->rows_in_mem = (JDIMENSION) (max_minheights * sptr->maxaccess); - jpeg_open_backing_store(cinfo, & sptr->b_s_info, - (long) sptr->rows_in_array * - (long) sptr->samplesperrow * - (long) SIZEOF(JSAMPLE)); - sptr->b_s_open = TRUE; - } - sptr->mem_buffer = alloc_sarray(cinfo, JPOOL_IMAGE, - sptr->samplesperrow, sptr->rows_in_mem); - sptr->rowsperchunk = mem->last_rowsperchunk; - sptr->cur_start_row = 0; - sptr->first_undef_row = 0; - sptr->dirty = FALSE; - } - } - - for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) { - if (bptr->mem_buffer == NULL) { /* if not realized yet */ - minheights = ((long) bptr->rows_in_array - 1L) / bptr->maxaccess + 1L; - if (minheights <= max_minheights) { - /* This buffer fits in memory */ - bptr->rows_in_mem = bptr->rows_in_array; - } else { - /* It doesn't fit in memory, create backing store. */ - bptr->rows_in_mem = (JDIMENSION) (max_minheights * bptr->maxaccess); - jpeg_open_backing_store(cinfo, & bptr->b_s_info, - (long) bptr->rows_in_array * - (long) bptr->blocksperrow * - (long) SIZEOF(JBLOCK)); - bptr->b_s_open = TRUE; - } - bptr->mem_buffer = alloc_barray(cinfo, JPOOL_IMAGE, - bptr->blocksperrow, bptr->rows_in_mem); - bptr->rowsperchunk = mem->last_rowsperchunk; - bptr->cur_start_row = 0; - bptr->first_undef_row = 0; - bptr->dirty = FALSE; - } - } -} - - -LOCAL(void) -do_sarray_io (j_common_ptr cinfo, jvirt_sarray_ptr ptr, boolean writing) -/* Do backing store read or write of a virtual sample array */ -{ - long bytesperrow, file_offset, byte_count, rows, thisrow, i; - - bytesperrow = (long) ptr->samplesperrow * SIZEOF(JSAMPLE); - file_offset = ptr->cur_start_row * bytesperrow; - /* Loop to read or write each allocation chunk in mem_buffer */ - for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) { - /* One chunk, but check for short chunk at end of buffer */ - rows = MIN((long) ptr->rowsperchunk, (long) ptr->rows_in_mem - i); - /* Transfer no more than is currently defined */ - thisrow = (long) ptr->cur_start_row + i; - rows = MIN(rows, (long) ptr->first_undef_row - thisrow); - /* Transfer no more than fits in file */ - rows = MIN(rows, (long) ptr->rows_in_array - thisrow); - if (rows <= 0) /* this chunk might be past end of file! */ - break; - byte_count = rows * bytesperrow; - if (writing) - (*ptr->b_s_info.write_backing_store) (cinfo, & ptr->b_s_info, - (void FAR *) ptr->mem_buffer[i], - file_offset, byte_count); - else - (*ptr->b_s_info.read_backing_store) (cinfo, & ptr->b_s_info, - (void FAR *) ptr->mem_buffer[i], - file_offset, byte_count); - file_offset += byte_count; - } -} - - -LOCAL(void) -do_barray_io (j_common_ptr cinfo, jvirt_barray_ptr ptr, boolean writing) -/* Do backing store read or write of a virtual coefficient-block array */ -{ - long bytesperrow, file_offset, byte_count, rows, thisrow, i; - - bytesperrow = (long) ptr->blocksperrow * SIZEOF(JBLOCK); - file_offset = ptr->cur_start_row * bytesperrow; - /* Loop to read or write each allocation chunk in mem_buffer */ - for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) { - /* One chunk, but check for short chunk at end of buffer */ - rows = MIN((long) ptr->rowsperchunk, (long) ptr->rows_in_mem - i); - /* Transfer no more than is currently defined */ - thisrow = (long) ptr->cur_start_row + i; - rows = MIN(rows, (long) ptr->first_undef_row - thisrow); - /* Transfer no more than fits in file */ - rows = MIN(rows, (long) ptr->rows_in_array - thisrow); - if (rows <= 0) /* this chunk might be past end of file! */ - break; - byte_count = rows * bytesperrow; - if (writing) - (*ptr->b_s_info.write_backing_store) (cinfo, & ptr->b_s_info, - (void FAR *) ptr->mem_buffer[i], - file_offset, byte_count); - else - (*ptr->b_s_info.read_backing_store) (cinfo, & ptr->b_s_info, - (void FAR *) ptr->mem_buffer[i], - file_offset, byte_count); - file_offset += byte_count; - } -} - - -METHODDEF(JSAMPARRAY) -access_virt_sarray (j_common_ptr cinfo, jvirt_sarray_ptr ptr, - JDIMENSION start_row, JDIMENSION num_rows, - boolean writable) -/* Access the part of a virtual sample array starting at start_row */ -/* and extending for num_rows rows. writable is true if */ -/* caller intends to modify the accessed area. */ -{ - JDIMENSION end_row = start_row + num_rows; - JDIMENSION undef_row; - - /* debugging check */ - if (end_row > ptr->rows_in_array || num_rows > ptr->maxaccess || - ptr->mem_buffer == NULL) - ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); - - /* Make the desired part of the virtual array accessible */ - if (start_row < ptr->cur_start_row || - end_row > ptr->cur_start_row+ptr->rows_in_mem) { - if (! ptr->b_s_open) - ERREXIT(cinfo, JERR_VIRTUAL_BUG); - /* Flush old buffer contents if necessary */ - if (ptr->dirty) { - do_sarray_io(cinfo, ptr, TRUE); - ptr->dirty = FALSE; - } - /* Decide what part of virtual array to access. - * Algorithm: if target address > current window, assume forward scan, - * load starting at target address. If target address < current window, - * assume backward scan, load so that target area is top of window. - * Note that when switching from forward write to forward read, will have - * start_row = 0, so the limiting case applies and we load from 0 anyway. - */ - if (start_row > ptr->cur_start_row) { - ptr->cur_start_row = start_row; - } else { - /* use long arithmetic here to avoid overflow & unsigned problems */ - long ltemp; - - ltemp = (long) end_row - (long) ptr->rows_in_mem; - if (ltemp < 0) - ltemp = 0; /* don't fall off front end of file */ - ptr->cur_start_row = (JDIMENSION) ltemp; - } - /* Read in the selected part of the array. - * During the initial write pass, we will do no actual read - * because the selected part is all undefined. - */ - do_sarray_io(cinfo, ptr, FALSE); - } - /* Ensure the accessed part of the array is defined; prezero if needed. - * To improve locality of access, we only prezero the part of the array - * that the caller is about to access, not the entire in-memory array. - */ - if (ptr->first_undef_row < end_row) { - if (ptr->first_undef_row < start_row) { - if (writable) /* writer skipped over a section of array */ - ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); - undef_row = start_row; /* but reader is allowed to read ahead */ - } else { - undef_row = ptr->first_undef_row; - } - if (writable) - ptr->first_undef_row = end_row; - if (ptr->pre_zero) { - size_t bytesperrow = (size_t) ptr->samplesperrow * SIZEOF(JSAMPLE); - undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */ - end_row -= ptr->cur_start_row; - while (undef_row < end_row) { - jzero_far((void FAR *) ptr->mem_buffer[undef_row], bytesperrow); - undef_row++; - } - } else { - if (! writable) /* reader looking at undefined data */ - ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); - } - } - /* Flag the buffer dirty if caller will write in it */ - if (writable) - ptr->dirty = TRUE; - /* Return address of proper part of the buffer */ - return ptr->mem_buffer + (start_row - ptr->cur_start_row); -} - - -METHODDEF(JBLOCKARRAY) -access_virt_barray (j_common_ptr cinfo, jvirt_barray_ptr ptr, - JDIMENSION start_row, JDIMENSION num_rows, - boolean writable) -/* Access the part of a virtual block array starting at start_row */ -/* and extending for num_rows rows. writable is true if */ -/* caller intends to modify the accessed area. */ -{ - JDIMENSION end_row = start_row + num_rows; - JDIMENSION undef_row; - - /* debugging check */ - if (end_row > ptr->rows_in_array || num_rows > ptr->maxaccess || - ptr->mem_buffer == NULL) - ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); - - /* Make the desired part of the virtual array accessible */ - if (start_row < ptr->cur_start_row || - end_row > ptr->cur_start_row+ptr->rows_in_mem) { - if (! ptr->b_s_open) - ERREXIT(cinfo, JERR_VIRTUAL_BUG); - /* Flush old buffer contents if necessary */ - if (ptr->dirty) { - do_barray_io(cinfo, ptr, TRUE); - ptr->dirty = FALSE; - } - /* Decide what part of virtual array to access. - * Algorithm: if target address > current window, assume forward scan, - * load starting at target address. If target address < current window, - * assume backward scan, load so that target area is top of window. - * Note that when switching from forward write to forward read, will have - * start_row = 0, so the limiting case applies and we load from 0 anyway. - */ - if (start_row > ptr->cur_start_row) { - ptr->cur_start_row = start_row; - } else { - /* use long arithmetic here to avoid overflow & unsigned problems */ - long ltemp; - - ltemp = (long) end_row - (long) ptr->rows_in_mem; - if (ltemp < 0) - ltemp = 0; /* don't fall off front end of file */ - ptr->cur_start_row = (JDIMENSION) ltemp; - } - /* Read in the selected part of the array. - * During the initial write pass, we will do no actual read - * because the selected part is all undefined. - */ - do_barray_io(cinfo, ptr, FALSE); - } - /* Ensure the accessed part of the array is defined; prezero if needed. - * To improve locality of access, we only prezero the part of the array - * that the caller is about to access, not the entire in-memory array. - */ - if (ptr->first_undef_row < end_row) { - if (ptr->first_undef_row < start_row) { - if (writable) /* writer skipped over a section of array */ - ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); - undef_row = start_row; /* but reader is allowed to read ahead */ - } else { - undef_row = ptr->first_undef_row; - } - if (writable) - ptr->first_undef_row = end_row; - if (ptr->pre_zero) { - size_t bytesperrow = (size_t) ptr->blocksperrow * SIZEOF(JBLOCK); - undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */ - end_row -= ptr->cur_start_row; - while (undef_row < end_row) { - jzero_far((void FAR *) ptr->mem_buffer[undef_row], bytesperrow); - undef_row++; - } - } else { - if (! writable) /* reader looking at undefined data */ - ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); - } - } - /* Flag the buffer dirty if caller will write in it */ - if (writable) - ptr->dirty = TRUE; - /* Return address of proper part of the buffer */ - return ptr->mem_buffer + (start_row - ptr->cur_start_row); -} - - -/* - * Release all objects belonging to a specified pool. - */ - -METHODDEF(void) -free_pool (j_common_ptr cinfo, int pool_id) -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - small_pool_ptr shdr_ptr; - large_pool_ptr lhdr_ptr; - size_t space_freed; - - if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS) - ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ - -#ifdef MEM_STATS - if (cinfo->err->trace_level > 1) - print_mem_stats(cinfo, pool_id); /* print pool's memory usage statistics */ -#endif - - /* If freeing IMAGE pool, close any virtual arrays first */ - if (pool_id == JPOOL_IMAGE) { - jvirt_sarray_ptr sptr; - jvirt_barray_ptr bptr; - - for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) { - if (sptr->b_s_open) { /* there may be no backing store */ - sptr->b_s_open = FALSE; /* prevent recursive close if error */ - (*sptr->b_s_info.close_backing_store) (cinfo, & sptr->b_s_info); - } - } - mem->virt_sarray_list = NULL; - for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) { - if (bptr->b_s_open) { /* there may be no backing store */ - bptr->b_s_open = FALSE; /* prevent recursive close if error */ - (*bptr->b_s_info.close_backing_store) (cinfo, & bptr->b_s_info); - } - } - mem->virt_barray_list = NULL; - } - - /* Release large objects */ - lhdr_ptr = mem->large_list[pool_id]; - mem->large_list[pool_id] = NULL; - - while (lhdr_ptr != NULL) { - large_pool_ptr next_lhdr_ptr = lhdr_ptr->hdr.next; - space_freed = lhdr_ptr->hdr.bytes_used + - lhdr_ptr->hdr.bytes_left + - SIZEOF(large_pool_hdr); - jpeg_free_large(cinfo, (void FAR *) lhdr_ptr, space_freed); - mem->total_space_allocated -= space_freed; - lhdr_ptr = next_lhdr_ptr; - } - - /* Release small objects */ - shdr_ptr = mem->small_list[pool_id]; - mem->small_list[pool_id] = NULL; - - while (shdr_ptr != NULL) { - small_pool_ptr next_shdr_ptr = shdr_ptr->hdr.next; - space_freed = shdr_ptr->hdr.bytes_used + - shdr_ptr->hdr.bytes_left + - SIZEOF(small_pool_hdr); - jpeg_free_small(cinfo, (void *) shdr_ptr, space_freed); - mem->total_space_allocated -= space_freed; - shdr_ptr = next_shdr_ptr; - } -} - - -/* - * Close up shop entirely. - * Note that this cannot be called unless cinfo->mem is non-NULL. - */ - -METHODDEF(void) -self_destruct (j_common_ptr cinfo) -{ - int pool; - - /* Close all backing store, release all memory. - * Releasing pools in reverse order might help avoid fragmentation - * with some (brain-damaged) malloc libraries. - */ - for (pool = JPOOL_NUMPOOLS-1; pool >= JPOOL_PERMANENT; pool--) { - free_pool(cinfo, pool); - } - - /* Release the memory manager control block too. */ - jpeg_free_small(cinfo, (void *) cinfo->mem, SIZEOF(my_memory_mgr)); - cinfo->mem = NULL; /* ensures I will be called only once */ - - jpeg_mem_term(cinfo); /* system-dependent cleanup */ -} - - -/* - * Memory manager initialization. - * When this is called, only the error manager pointer is valid in cinfo! - */ - -GLOBAL(void) -jinit_memory_mgr (j_common_ptr cinfo) -{ - my_mem_ptr mem; - long max_to_use; - int pool; - size_t test_mac; - - cinfo->mem = NULL; /* for safety if init fails */ - - /* Check for configuration errors. - * SIZEOF(ALIGN_TYPE) should be a power of 2; otherwise, it probably - * doesn't reflect any real hardware alignment requirement. - * The test is a little tricky: for X>0, X and X-1 have no one-bits - * in common if and only if X is a power of 2, ie has only one one-bit. - * Some compilers may give an "unreachable code" warning here; ignore it. - */ - if ((SIZEOF(ALIGN_TYPE) & (SIZEOF(ALIGN_TYPE)-1)) != 0) - ERREXIT(cinfo, JERR_BAD_ALIGN_TYPE); - /* MAX_ALLOC_CHUNK must be representable as type size_t, and must be - * a multiple of SIZEOF(ALIGN_TYPE). - * Again, an "unreachable code" warning may be ignored here. - * But a "constant too large" warning means you need to fix MAX_ALLOC_CHUNK. - */ - test_mac = (size_t) MAX_ALLOC_CHUNK; - if ((long) test_mac != MAX_ALLOC_CHUNK || - (MAX_ALLOC_CHUNK % SIZEOF(ALIGN_TYPE)) != 0) - ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK); - - max_to_use = jpeg_mem_init(cinfo); /* system-dependent initialization */ - - /* Attempt to allocate memory manager's control block */ - mem = (my_mem_ptr) jpeg_get_small(cinfo, SIZEOF(my_memory_mgr)); - - if (mem == NULL) { - jpeg_mem_term(cinfo); /* system-dependent cleanup */ - ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 0); - } - - /* OK, fill in the method pointers */ - mem->pub.alloc_small = alloc_small; - mem->pub.alloc_large = alloc_large; - mem->pub.alloc_sarray = alloc_sarray; - mem->pub.alloc_barray = alloc_barray; - mem->pub.request_virt_sarray = request_virt_sarray; - mem->pub.request_virt_barray = request_virt_barray; - mem->pub.realize_virt_arrays = realize_virt_arrays; - mem->pub.access_virt_sarray = access_virt_sarray; - mem->pub.access_virt_barray = access_virt_barray; - mem->pub.free_pool = free_pool; - mem->pub.self_destruct = self_destruct; - - /* Make MAX_ALLOC_CHUNK accessible to other modules */ - mem->pub.max_alloc_chunk = MAX_ALLOC_CHUNK; - - /* Initialize working state */ - mem->pub.max_memory_to_use = max_to_use; - - for (pool = JPOOL_NUMPOOLS-1; pool >= JPOOL_PERMANENT; pool--) { - mem->small_list[pool] = NULL; - mem->large_list[pool] = NULL; - } - mem->virt_sarray_list = NULL; - mem->virt_barray_list = NULL; - - mem->total_space_allocated = SIZEOF(my_memory_mgr); - - /* Declare ourselves open for business */ - cinfo->mem = & mem->pub; - - /* Check for an environment variable JPEGMEM; if found, override the - * default max_memory setting from jpeg_mem_init. Note that the - * surrounding application may again override this value. - * If your system doesn't support getenv(), define NO_GETENV to disable - * this feature. - */ -#ifndef NO_GETENV - { char * memenv; - - if ((memenv = getenv("JPEGMEM")) != NULL) { - char ch = 'x'; - - if (sscanf(memenv, "%ld%c", &max_to_use, &ch) > 0) { - if (ch == 'm' || ch == 'M') - max_to_use *= 1000L; - mem->pub.max_memory_to_use = max_to_use * 1000L; - } - } - } -#endif - -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jmemname.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jmemname.c deleted file mode 100644 index e28b212f4..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jmemname.c +++ /dev/null @@ -1,276 +0,0 @@ -/* - * jmemname.c - * - * Copyright (C) 1992-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file provides a generic implementation of the system-dependent - * portion of the JPEG memory manager. This implementation assumes that - * you must explicitly construct a name for each temp file. - * Also, the problem of determining the amount of memory available - * is shoved onto the user. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jmemsys.h" /* import the system-dependent declarations */ - -#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare malloc(),free() */ -extern void * malloc JPP((size_t size)); -extern void free JPP((void *ptr)); -#endif - -#ifndef SEEK_SET /* pre-ANSI systems may not define this; */ -#define SEEK_SET 0 /* if not, assume 0 is correct */ -#endif - -#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ -#define READ_BINARY "r" -#define RW_BINARY "w+" -#else -#ifdef VMS /* VMS is very nonstandard */ -#define READ_BINARY "rb", "ctx=stm" -#define RW_BINARY "w+b", "ctx=stm" -#else /* standard ANSI-compliant case */ -#define READ_BINARY "rb" -#define RW_BINARY "w+b" -#endif -#endif - - -/* - * Selection of a file name for a temporary file. - * This is system-dependent! - * - * The code as given is suitable for most Unix systems, and it is easily - * modified for most non-Unix systems. Some notes: - * 1. The temp file is created in the directory named by TEMP_DIRECTORY. - * The default value is /usr/tmp, which is the conventional place for - * creating large temp files on Unix. On other systems you'll probably - * want to change the file location. You can do this by editing the - * #define, or (preferred) by defining TEMP_DIRECTORY in jconfig.h. - * - * 2. If you need to change the file name as well as its location, - * you can override the TEMP_FILE_NAME macro. (Note that this is - * actually a printf format string; it must contain %s and %d.) - * Few people should need to do this. - * - * 3. mktemp() is used to ensure that multiple processes running - * simultaneously won't select the same file names. If your system - * doesn't have mktemp(), define NO_MKTEMP to do it the hard way. - * (If you don't have <errno.h>, also define NO_ERRNO_H.) - * - * 4. You probably want to define NEED_SIGNAL_CATCHER so that cjpeg.c/djpeg.c - * will cause the temp files to be removed if you stop the program early. - */ - -#ifndef TEMP_DIRECTORY /* can override from jconfig.h or Makefile */ -#define TEMP_DIRECTORY "/usr/tmp/" /* recommended setting for Unix */ -#endif - -static int next_file_num; /* to distinguish among several temp files */ - -#ifdef NO_MKTEMP - -#ifndef TEMP_FILE_NAME /* can override from jconfig.h or Makefile */ -#define TEMP_FILE_NAME "%sJPG%03d.TMP" -#endif - -#ifndef NO_ERRNO_H -#include <errno.h> /* to define ENOENT */ -#endif - -/* ANSI C specifies that errno is a macro, but on older systems it's more - * likely to be a plain int variable. And not all versions of errno.h - * bother to declare it, so we have to in order to be most portable. Thus: - */ -#ifndef errno -extern int errno; -#endif - - -LOCAL(void) -select_file_name (char * fname) -{ - FILE * tfile; - - /* Keep generating file names till we find one that's not in use */ - for (;;) { - next_file_num++; /* advance counter */ - sprintf(fname, TEMP_FILE_NAME, TEMP_DIRECTORY, next_file_num); - if ((tfile = fopen(fname, READ_BINARY)) == NULL) { - /* fopen could have failed for a reason other than the file not - * being there; for example, file there but unreadable. - * If <errno.h> isn't available, then we cannot test the cause. - */ -#ifdef ENOENT - if (errno != ENOENT) - continue; -#endif - break; - } - fclose(tfile); /* oops, it's there; close tfile & try again */ - } -} - -#else /* ! NO_MKTEMP */ - -/* Note that mktemp() requires the initial filename to end in six X's */ -#ifndef TEMP_FILE_NAME /* can override from jconfig.h or Makefile */ -#define TEMP_FILE_NAME "%sJPG%dXXXXXX" -#endif - -LOCAL(void) -select_file_name (char * fname) -{ - next_file_num++; /* advance counter */ - sprintf(fname, TEMP_FILE_NAME, TEMP_DIRECTORY, next_file_num); - mktemp(fname); /* make sure file name is unique */ - /* mktemp replaces the trailing XXXXXX with a unique string of characters */ -} - -#endif /* NO_MKTEMP */ - - -/* - * Memory allocation and freeing are controlled by the regular library - * routines malloc() and free(). - */ - -GLOBAL(void *) -jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void *) malloc(sizeofobject); -} - -GLOBAL(void) -jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) -{ - free(object); -} - - -/* - * "Large" objects are treated the same as "small" ones. - * NB: although we include FAR keywords in the routine declarations, - * this file won't actually work in 80x86 small/medium model; at least, - * you probably won't be able to process useful-size images in only 64KB. - */ - -GLOBAL(void FAR *) -jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void FAR *) malloc(sizeofobject); -} - -GLOBAL(void) -jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) -{ - free(object); -} - - -/* - * This routine computes the total memory space available for allocation. - * It's impossible to do this in a portable way; our current solution is - * to make the user tell us (with a default value set at compile time). - * If you can actually get the available space, it's a good idea to subtract - * a slop factor of 5% or so. - */ - -#ifndef DEFAULT_MAX_MEM /* so can override from makefile */ -#define DEFAULT_MAX_MEM 1000000L /* default: one megabyte */ -#endif - -GLOBAL(long) -jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, - long max_bytes_needed, long already_allocated) -{ - return cinfo->mem->max_memory_to_use - already_allocated; -} - - -/* - * Backing store (temporary file) management. - * Backing store objects are only used when the value returned by - * jpeg_mem_available is less than the total space needed. You can dispense - * with these routines if you have plenty of virtual memory; see jmemnobs.c. - */ - - -METHODDEF(void) -read_backing_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - if (fseek(info->temp_file, file_offset, SEEK_SET)) - ERREXIT(cinfo, JERR_TFILE_SEEK); - if (JFREAD(info->temp_file, buffer_address, byte_count) - != (size_t) byte_count) - ERREXIT(cinfo, JERR_TFILE_READ); -} - - -METHODDEF(void) -write_backing_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - if (fseek(info->temp_file, file_offset, SEEK_SET)) - ERREXIT(cinfo, JERR_TFILE_SEEK); - if (JFWRITE(info->temp_file, buffer_address, byte_count) - != (size_t) byte_count) - ERREXIT(cinfo, JERR_TFILE_WRITE); -} - - -METHODDEF(void) -close_backing_store (j_common_ptr cinfo, backing_store_ptr info) -{ - fclose(info->temp_file); /* close the file */ - unlink(info->temp_name); /* delete the file */ -/* If your system doesn't have unlink(), use remove() instead. - * remove() is the ANSI-standard name for this function, but if - * your system was ANSI you'd be using jmemansi.c, right? - */ - TRACEMSS(cinfo, 1, JTRC_TFILE_CLOSE, info->temp_name); -} - - -/* - * Initial opening of a backing-store object. - */ - -GLOBAL(void) -jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, - long total_bytes_needed) -{ - select_file_name(info->temp_name); - if ((info->temp_file = fopen(info->temp_name, RW_BINARY)) == NULL) - ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name); - info->read_backing_store = read_backing_store; - info->write_backing_store = write_backing_store; - info->close_backing_store = close_backing_store; - TRACEMSS(cinfo, 1, JTRC_TFILE_OPEN, info->temp_name); -} - - -/* - * These routines take care of any system-dependent initialization and - * cleanup required. - */ - -GLOBAL(long) -jpeg_mem_init (j_common_ptr cinfo) -{ - next_file_num = 0; /* initialize temp file name generator */ - return DEFAULT_MAX_MEM; /* default for max_memory_to_use */ -} - -GLOBAL(void) -jpeg_mem_term (j_common_ptr cinfo) -{ - /* no work */ -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jmemnobs.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jmemnobs.c deleted file mode 100644 index 6aa1e9295..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jmemnobs.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * jmemnobs.c - * - * Copyright (C) 1992-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file provides a really simple implementation of the system- - * dependent portion of the JPEG memory manager. This implementation - * assumes that no backing-store files are needed: all required space - * can be obtained from malloc(). - * This is very portable in the sense that it'll compile on almost anything, - * but you'd better have lots of main memory (or virtual memory) if you want - * to process big images. - * Note that the max_memory_to_use option is ignored by this implementation. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jmemsys.h" /* import the system-dependent declarations */ - -#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare malloc(),free() */ -extern void * malloc JPP((size_t size)); -extern void free JPP((void *ptr)); -#endif - - -/* - * Memory allocation and freeing are controlled by the regular library - * routines malloc() and free(). - */ - -GLOBAL(void *) -jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void *) malloc(sizeofobject); -} - -GLOBAL(void) -jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) -{ - free(object); -} - - -/* - * "Large" objects are treated the same as "small" ones. - * NB: although we include FAR keywords in the routine declarations, - * this file won't actually work in 80x86 small/medium model; at least, - * you probably won't be able to process useful-size images in only 64KB. - */ - -GLOBAL(void FAR *) -jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void FAR *) malloc(sizeofobject); -} - -GLOBAL(void) -jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) -{ - free(object); -} - - -/* - * This routine computes the total memory space available for allocation. - * Here we always say, "we got all you want bud!" - */ - -GLOBAL(long) -jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, - long max_bytes_needed, long already_allocated) -{ - return max_bytes_needed; -} - - -/* - * Backing store (temporary file) management. - * Since jpeg_mem_available always promised the moon, - * this should never be called and we can just error out. - */ - -GLOBAL(void) -jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, - long total_bytes_needed) -{ - ERREXIT(cinfo, JERR_NO_BACKING_STORE); -} - - -/* - * These routines take care of any system-dependent initialization and - * cleanup required. Here, there isn't any. - */ - -GLOBAL(long) -jpeg_mem_init (j_common_ptr cinfo) -{ - return 0; /* just set max_memory_to_use to 0 */ -} - -GLOBAL(void) -jpeg_mem_term (j_common_ptr cinfo) -{ - /* no work */ -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jmemsys.h b/irrlicht-1.6/source/Irrlicht/jpeglib/jmemsys.h deleted file mode 100644 index 2a8796119..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jmemsys.h +++ /dev/null @@ -1,198 +0,0 @@ -/* - * jmemsys.h - * - * Copyright (C) 1992-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This include file defines the interface between the system-independent - * and system-dependent portions of the JPEG memory manager. No other - * modules need include it. (The system-independent portion is jmemmgr.c; - * there are several different versions of the system-dependent portion.) - * - * This file works as-is for the system-dependent memory managers supplied - * in the IJG distribution. You may need to modify it if you write a - * custom memory manager. If system-dependent changes are needed in - * this file, the best method is to #ifdef them based on a configuration - * symbol supplied in jconfig.h, as we have done with USE_MSDOS_MEMMGR - * and USE_MAC_MEMMGR. - */ - - -/* Short forms of external names for systems with brain-damaged linkers. */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jpeg_get_small jGetSmall -#define jpeg_free_small jFreeSmall -#define jpeg_get_large jGetLarge -#define jpeg_free_large jFreeLarge -#define jpeg_mem_available jMemAvail -#define jpeg_open_backing_store jOpenBackStore -#define jpeg_mem_init jMemInit -#define jpeg_mem_term jMemTerm -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - - -/* - * These two functions are used to allocate and release small chunks of - * memory. (Typically the total amount requested through jpeg_get_small is - * no more than 20K or so; this will be requested in chunks of a few K each.) - * Behavior should be the same as for the standard library functions malloc - * and free; in particular, jpeg_get_small must return NULL on failure. - * On most systems, these ARE malloc and free. jpeg_free_small is passed the - * size of the object being freed, just in case it's needed. - * On an 80x86 machine using small-data memory model, these manage near heap. - */ - -EXTERN(void *) jpeg_get_small JPP((j_common_ptr cinfo, size_t sizeofobject)); -EXTERN(void) jpeg_free_small JPP((j_common_ptr cinfo, void * object, - size_t sizeofobject)); - -/* - * These two functions are used to allocate and release large chunks of - * memory (up to the total free space designated by jpeg_mem_available). - * The interface is the same as above, except that on an 80x86 machine, - * far pointers are used. On most other machines these are identical to - * the jpeg_get/free_small routines; but we keep them separate anyway, - * in case a different allocation strategy is desirable for large chunks. - */ - -EXTERN(void FAR *) jpeg_get_large JPP((j_common_ptr cinfo, - size_t sizeofobject)); -EXTERN(void) jpeg_free_large JPP((j_common_ptr cinfo, void FAR * object, - size_t sizeofobject)); - -/* - * The macro MAX_ALLOC_CHUNK designates the maximum number of bytes that may - * be requested in a single call to jpeg_get_large (and jpeg_get_small for that - * matter, but that case should never come into play). This macro is needed - * to model the 64Kb-segment-size limit of far addressing on 80x86 machines. - * On those machines, we expect that jconfig.h will provide a proper value. - * On machines with 32-bit flat address spaces, any large constant may be used. - * - * NB: jmemmgr.c expects that MAX_ALLOC_CHUNK will be representable as type - * size_t and will be a multiple of sizeof(align_type). - */ - -#ifndef MAX_ALLOC_CHUNK /* may be overridden in jconfig.h */ -#define MAX_ALLOC_CHUNK 1000000000L -#endif - -/* - * This routine computes the total space still available for allocation by - * jpeg_get_large. If more space than this is needed, backing store will be - * used. NOTE: any memory already allocated must not be counted. - * - * There is a minimum space requirement, corresponding to the minimum - * feasible buffer sizes; jmemmgr.c will request that much space even if - * jpeg_mem_available returns zero. The maximum space needed, enough to hold - * all working storage in memory, is also passed in case it is useful. - * Finally, the total space already allocated is passed. If no better - * method is available, cinfo->mem->max_memory_to_use - already_allocated - * is often a suitable calculation. - * - * It is OK for jpeg_mem_available to underestimate the space available - * (that'll just lead to more backing-store access than is really necessary). - * However, an overestimate will lead to failure. Hence it's wise to subtract - * a slop factor from the true available space. 5% should be enough. - * - * On machines with lots of virtual memory, any large constant may be returned. - * Conversely, zero may be returned to always use the minimum amount of memory. - */ - -EXTERN(long) jpeg_mem_available JPP((j_common_ptr cinfo, - long min_bytes_needed, - long max_bytes_needed, - long already_allocated)); - - -/* - * This structure holds whatever state is needed to access a single - * backing-store object. The read/write/close method pointers are called - * by jmemmgr.c to manipulate the backing-store object; all other fields - * are private to the system-dependent backing store routines. - */ - -#define TEMP_NAME_LENGTH 64 /* max length of a temporary file's name */ - - -#ifdef USE_MSDOS_MEMMGR /* DOS-specific junk */ - -typedef unsigned short XMSH; /* type of extended-memory handles */ -typedef unsigned short EMSH; /* type of expanded-memory handles */ - -typedef union { - short file_handle; /* DOS file handle if it's a temp file */ - XMSH xms_handle; /* handle if it's a chunk of XMS */ - EMSH ems_handle; /* handle if it's a chunk of EMS */ -} handle_union; - -#endif /* USE_MSDOS_MEMMGR */ - -#ifdef USE_MAC_MEMMGR /* Mac-specific junk */ -#include <Files.h> -#endif /* USE_MAC_MEMMGR */ - - -typedef struct backing_store_struct * backing_store_ptr; - -typedef struct backing_store_struct { - /* Methods for reading/writing/closing this backing-store object */ - JMETHOD(void, read_backing_store, (j_common_ptr cinfo, - backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count)); - JMETHOD(void, write_backing_store, (j_common_ptr cinfo, - backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count)); - JMETHOD(void, close_backing_store, (j_common_ptr cinfo, - backing_store_ptr info)); - - /* Private fields for system-dependent backing-store management */ -#ifdef USE_MSDOS_MEMMGR - /* For the MS-DOS manager (jmemdos.c), we need: */ - handle_union handle; /* reference to backing-store storage object */ - char temp_name[TEMP_NAME_LENGTH]; /* name if it's a file */ -#else -#ifdef USE_MAC_MEMMGR - /* For the Mac manager (jmemmac.c), we need: */ - short temp_file; /* file reference number to temp file */ - FSSpec tempSpec; /* the FSSpec for the temp file */ - char temp_name[TEMP_NAME_LENGTH]; /* name if it's a file */ -#else - /* For a typical implementation with temp files, we need: */ - FILE * temp_file; /* stdio reference to temp file */ - char temp_name[TEMP_NAME_LENGTH]; /* name of temp file */ -#endif -#endif -} backing_store_info; - - -/* - * Initial opening of a backing-store object. This must fill in the - * read/write/close pointers in the object. The read/write routines - * may take an error exit if the specified maximum file size is exceeded. - * (If jpeg_mem_available always returns a large value, this routine can - * just take an error exit.) - */ - -EXTERN(void) jpeg_open_backing_store JPP((j_common_ptr cinfo, - backing_store_ptr info, - long total_bytes_needed)); - - -/* - * These routines take care of any system-dependent initialization and - * cleanup required. jpeg_mem_init will be called before anything is - * allocated (and, therefore, nothing in cinfo is of use except the error - * manager pointer). It should return a suitable default value for - * max_memory_to_use; this may subsequently be overridden by the surrounding - * application. (Note that max_memory_to_use is only important if - * jpeg_mem_available chooses to consult it ... no one else will.) - * jpeg_mem_term may assume that all requested memory has been freed and that - * all opened backing-store objects have been closed. - */ - -EXTERN(long) jpeg_mem_init JPP((j_common_ptr cinfo)); -EXTERN(void) jpeg_mem_term JPP((j_common_ptr cinfo)); diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jmorecfg.h b/irrlicht-1.6/source/Irrlicht/jpeglib/jmorecfg.h deleted file mode 100644 index c856e2260..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jmorecfg.h +++ /dev/null @@ -1,363 +0,0 @@ -/* - * jmorecfg.h - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains additional configuration options that customize the - * JPEG software for special applications or support machine-dependent - * optimizations. Most users will not need to touch this file. - */ - - -/* - * Define BITS_IN_JSAMPLE as either - * 8 for 8-bit sample values (the usual setting) - * 12 for 12-bit sample values - * Only 8 and 12 are legal data precisions for lossy JPEG according to the - * JPEG standard, and the IJG code does not support anything else! - * We do not support run-time selection of data precision, sorry. - */ - -#define BITS_IN_JSAMPLE 8 /* use 8 or 12 */ - - -/* - * Maximum number of components (color channels) allowed in JPEG image. - * To meet the letter of the JPEG spec, set this to 255. However, darn - * few applications need more than 4 channels (maybe 5 for CMYK + alpha - * mask). We recommend 10 as a reasonable compromise; use 4 if you are - * really short on memory. (Each allowed component costs a hundred or so - * bytes of storage, whether actually used in an image or not.) - */ - -#define MAX_COMPONENTS 10 /* maximum number of image components */ - - -/* - * Basic data types. - * You may need to change these if you have a machine with unusual data - * type sizes; for example, "char" not 8 bits, "short" not 16 bits, - * or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits, - * but it had better be at least 16. - */ - -/* Representation of a single sample (pixel element value). - * We frequently allocate large arrays of these, so it's important to keep - * them small. But if you have memory to burn and access to char or short - * arrays is very slow on your hardware, you might want to change these. - */ - -#if BITS_IN_JSAMPLE == 8 -/* JSAMPLE should be the smallest type that will hold the values 0..255. - * You can use a signed char by having GETJSAMPLE mask it with 0xFF. - */ - -#ifdef HAVE_UNSIGNED_CHAR - -typedef unsigned char JSAMPLE; -#define GETJSAMPLE(value) ((int) (value)) - -#else /* not HAVE_UNSIGNED_CHAR */ - -typedef char JSAMPLE; -#ifdef CHAR_IS_UNSIGNED -#define GETJSAMPLE(value) ((int) (value)) -#else -#define GETJSAMPLE(value) ((int) (value) & 0xFF) -#endif /* CHAR_IS_UNSIGNED */ - -#endif /* HAVE_UNSIGNED_CHAR */ - -#define MAXJSAMPLE 255 -#define CENTERJSAMPLE 128 - -#endif /* BITS_IN_JSAMPLE == 8 */ - - -#if BITS_IN_JSAMPLE == 12 -/* JSAMPLE should be the smallest type that will hold the values 0..4095. - * On nearly all machines "short" will do nicely. - */ - -typedef short JSAMPLE; -#define GETJSAMPLE(value) ((int) (value)) - -#define MAXJSAMPLE 4095 -#define CENTERJSAMPLE 2048 - -#endif /* BITS_IN_JSAMPLE == 12 */ - - -/* Representation of a DCT frequency coefficient. - * This should be a signed value of at least 16 bits; "short" is usually OK. - * Again, we allocate large arrays of these, but you can change to int - * if you have memory to burn and "short" is really slow. - */ - -typedef short JCOEF; - - -/* Compressed datastreams are represented as arrays of JOCTET. - * These must be EXACTLY 8 bits wide, at least once they are written to - * external storage. Note that when using the stdio data source/destination - * managers, this is also the data type passed to fread/fwrite. - */ - -#ifdef HAVE_UNSIGNED_CHAR - -typedef unsigned char JOCTET; -#define GETJOCTET(value) (value) - -#else /* not HAVE_UNSIGNED_CHAR */ - -typedef char JOCTET; -#ifdef CHAR_IS_UNSIGNED -#define GETJOCTET(value) (value) -#else -#define GETJOCTET(value) ((value) & 0xFF) -#endif /* CHAR_IS_UNSIGNED */ - -#endif /* HAVE_UNSIGNED_CHAR */ - - -/* These typedefs are used for various table entries and so forth. - * They must be at least as wide as specified; but making them too big - * won't cost a huge amount of memory, so we don't provide special - * extraction code like we did for JSAMPLE. (In other words, these - * typedefs live at a different point on the speed/space tradeoff curve.) - */ - -/* UINT8 must hold at least the values 0..255. */ - -#ifdef HAVE_UNSIGNED_CHAR -typedef unsigned char UINT8; -#else /* not HAVE_UNSIGNED_CHAR */ -#ifdef CHAR_IS_UNSIGNED -typedef char UINT8; -#else /* not CHAR_IS_UNSIGNED */ -typedef short UINT8; -#endif /* CHAR_IS_UNSIGNED */ -#endif /* HAVE_UNSIGNED_CHAR */ - -/* UINT16 must hold at least the values 0..65535. */ - -#ifdef HAVE_UNSIGNED_SHORT -typedef unsigned short UINT16; -#else /* not HAVE_UNSIGNED_SHORT */ -typedef unsigned int UINT16; -#endif /* HAVE_UNSIGNED_SHORT */ - -/* INT16 must hold at least the values -32768..32767. */ - -#ifndef XMD_H /* X11/xmd.h correctly defines INT16 */ -typedef short INT16; -#endif - -/* INT32 must hold at least signed 32-bit values. */ - -#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */ -typedef long INT32; -#endif - -/* Datatype used for image dimensions. The JPEG standard only supports - * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore - * "unsigned int" is sufficient on all machines. However, if you need to - * handle larger images and you don't mind deviating from the spec, you - * can change this datatype. - */ - -typedef unsigned int JDIMENSION; - -#define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */ - - -/* These macros are used in all function definitions and extern declarations. - * You could modify them if you need to change function linkage conventions; - * in particular, you'll need to do that to make the library a Windows DLL. - * Another application is to make all functions global for use with debuggers - * or code profilers that require it. - */ - -/* a function called through method pointers: */ -#define METHODDEF(type) static type -/* a function used only in its module: */ -#define LOCAL(type) static type -/* a function referenced thru EXTERNs: */ -#define GLOBAL(type) type -/* a reference to a GLOBAL function: */ -#define EXTERN(type) extern type - - -/* This macro is used to declare a "method", that is, a function pointer. - * We want to supply prototype parameters if the compiler can cope. - * Note that the arglist parameter must be parenthesized! - * Again, you can customize this if you need special linkage keywords. - */ - -#ifdef HAVE_PROTOTYPES -#define JMETHOD(type,methodname,arglist) type (*methodname) arglist -#else -#define JMETHOD(type,methodname,arglist) type (*methodname) () -#endif - - -/* Here is the pseudo-keyword for declaring pointers that must be "far" - * on 80x86 machines. Most of the specialized coding for 80x86 is handled - * by just saying "FAR *" where such a pointer is needed. In a few places - * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol. - */ - -#ifdef NEED_FAR_POINTERS -#define FAR far -#else -#define FAR -#endif - - -/* - * On a few systems, type boolean and/or its values FALSE, TRUE may appear - * in standard header files. Or you may have conflicts with application- - * specific header files that you want to include together with these files. - * Defining HAVE_BOOLEAN before including jpeglib.h should make it work. - */ - -#ifndef HAVE_BOOLEAN -typedef int boolean; -#endif -#ifndef FALSE /* in case these macros already exist */ -#define FALSE 0 /* values of boolean */ -#endif -#ifndef TRUE -#define TRUE 1 -#endif - - -/* - * The remaining options affect code selection within the JPEG library, - * but they don't need to be visible to most applications using the library. - * To minimize application namespace pollution, the symbols won't be - * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined. - */ - -#ifdef JPEG_INTERNALS -#define JPEG_INTERNAL_OPTIONS -#endif - -#ifdef JPEG_INTERNAL_OPTIONS - - -/* - * These defines indicate whether to include various optional functions. - * Undefining some of these symbols will produce a smaller but less capable - * library. Note that you can leave certain source files out of the - * compilation/linking process if you've #undef'd the corresponding symbols. - * (You may HAVE to do that if your compiler doesn't like null source files.) - */ - -/* Arithmetic coding is unsupported for legal reasons. Complaints to IBM. */ - -/* Capability options common to encoder and decoder: */ - -#define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */ -#define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */ -#define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */ - -/* Encoder capability options: */ - -#undef C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ -#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ -#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ -#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */ -/* Note: if you selected 12-bit data precision, it is dangerous to turn off - * ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit - * precision, so jchuff.c normally uses entropy optimization to compute - * usable tables for higher precision. If you don't want to do optimization, - * you'll have to supply different default Huffman tables. - * The exact same statements apply for progressive JPEG: the default tables - * don't work for progressive mode. (This may get fixed, however.) - */ -#define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */ - -/* Decoder capability options: */ - -#undef D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ -#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ -#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ -#define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */ -#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */ -#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */ -#undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */ -#define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */ -#define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */ -#define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */ - -/* more capability options later, no doubt */ - - -/* - * Ordering of RGB data in scanlines passed to or from the application. - * If your application wants to deal with data in the order B,G,R, just - * change these macros. You can also deal with formats such as R,G,B,X - * (one extra byte per pixel) by changing RGB_PIXELSIZE. Note that changing - * the offsets will also change the order in which colormap data is organized. - * RESTRICTIONS: - * 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats. - * 2. These macros only affect RGB<=>YCbCr color conversion, so they are not - * useful if you are using JPEG color spaces other than YCbCr or grayscale. - * 3. The color quantizer modules will not behave desirably if RGB_PIXELSIZE - * is not 3 (they don't understand about dummy color components!). So you - * can't use color quantization if you change that value. - */ - -#define RGB_RED 0 /* Offset of Red in an RGB scanline element */ -#define RGB_GREEN 1 /* Offset of Green */ -#define RGB_BLUE 2 /* Offset of Blue */ -#define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */ - - -/* Definitions for speed-related optimizations. */ - - -/* If your compiler supports inline functions, define INLINE - * as the inline keyword; otherwise define it as empty. - */ - -#ifndef INLINE -#ifdef __GNUC__ /* for instance, GNU C knows about inline */ -#define INLINE __inline__ -#endif -#ifndef INLINE -#define INLINE /* default is to define it as empty */ -#endif -#endif - - -/* On some machines (notably 68000 series) "int" is 32 bits, but multiplying - * two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER - * as short on such a machine. MULTIPLIER must be at least 16 bits wide. - */ - -#ifndef MULTIPLIER -#define MULTIPLIER int /* type for fastest integer multiply */ -#endif - - -/* FAST_FLOAT should be either float or double, whichever is done faster - * by your compiler. (Note that this type is only used in the floating point - * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.) - * Typically, float is faster in ANSI C compilers, while double is faster in - * pre-ANSI compilers (because they insist on converting to double anyway). - * The code below therefore chooses float if we have ANSI-style prototypes. - */ - -#ifndef FAST_FLOAT -#ifdef HAVE_PROTOTYPES -#define FAST_FLOAT float -#else -#define FAST_FLOAT double -#endif -#endif - -#endif /* JPEG_INTERNAL_OPTIONS */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jpegint.h b/irrlicht-1.6/source/Irrlicht/jpeglib/jpegint.h deleted file mode 100644 index 685a3610b..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jpegint.h +++ /dev/null @@ -1,392 +0,0 @@ -/* - * jpegint.h - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file provides common declarations for the various JPEG modules. - * These declarations are considered internal to the JPEG library; most - * applications using the library shouldn't need to include this file. - */ - - -/* Declarations for both compression & decompression */ - -typedef enum { /* Operating modes for buffer controllers */ - JBUF_PASS_THRU, /* Plain stripwise operation */ - /* Remaining modes require a full-image buffer to have been created */ - JBUF_SAVE_SOURCE, /* Run source subobject only, save output */ - JBUF_CRANK_DEST, /* Run dest subobject only, using saved data */ - JBUF_SAVE_AND_PASS /* Run both subobjects, save output */ -} J_BUF_MODE; - -/* Values of global_state field (jdapi.c has some dependencies on ordering!) */ -#define CSTATE_START 100 /* after create_compress */ -#define CSTATE_SCANNING 101 /* start_compress done, write_scanlines OK */ -#define CSTATE_RAW_OK 102 /* start_compress done, write_raw_data OK */ -#define CSTATE_WRCOEFS 103 /* jpeg_write_coefficients done */ -#define DSTATE_START 200 /* after create_decompress */ -#define DSTATE_INHEADER 201 /* reading header markers, no SOS yet */ -#define DSTATE_READY 202 /* found SOS, ready for start_decompress */ -#define DSTATE_PRELOAD 203 /* reading multiscan file in start_decompress*/ -#define DSTATE_PRESCAN 204 /* performing dummy pass for 2-pass quant */ -#define DSTATE_SCANNING 205 /* start_decompress done, read_scanlines OK */ -#define DSTATE_RAW_OK 206 /* start_decompress done, read_raw_data OK */ -#define DSTATE_BUFIMAGE 207 /* expecting jpeg_start_output */ -#define DSTATE_BUFPOST 208 /* looking for SOS/EOI in jpeg_finish_output */ -#define DSTATE_RDCOEFS 209 /* reading file in jpeg_read_coefficients */ -#define DSTATE_STOPPING 210 /* looking for EOI in jpeg_finish_decompress */ - - -/* Declarations for compression modules */ - -/* Master control module */ -struct jpeg_comp_master { - JMETHOD(void, prepare_for_pass, (j_compress_ptr cinfo)); - JMETHOD(void, pass_startup, (j_compress_ptr cinfo)); - JMETHOD(void, finish_pass, (j_compress_ptr cinfo)); - - /* State variables made visible to other modules */ - boolean call_pass_startup; /* True if pass_startup must be called */ - boolean is_last_pass; /* True during last pass */ -}; - -/* Main buffer control (downsampled-data buffer) */ -struct jpeg_c_main_controller { - JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode)); - JMETHOD(void, process_data, (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, - JDIMENSION in_rows_avail)); -}; - -/* Compression preprocessing (downsampling input buffer control) */ -struct jpeg_c_prep_controller { - JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode)); - JMETHOD(void, pre_process_data, (j_compress_ptr cinfo, - JSAMPARRAY input_buf, - JDIMENSION *in_row_ctr, - JDIMENSION in_rows_avail, - JSAMPIMAGE output_buf, - JDIMENSION *out_row_group_ctr, - JDIMENSION out_row_groups_avail)); -}; - -/* Coefficient buffer control */ -struct jpeg_c_coef_controller { - JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode)); - JMETHOD(boolean, compress_data, (j_compress_ptr cinfo, - JSAMPIMAGE input_buf)); -}; - -/* Colorspace conversion */ -struct jpeg_color_converter { - JMETHOD(void, start_pass, (j_compress_ptr cinfo)); - JMETHOD(void, color_convert, (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPIMAGE output_buf, - JDIMENSION output_row, int num_rows)); -}; - -/* Downsampling */ -struct jpeg_downsampler { - JMETHOD(void, start_pass, (j_compress_ptr cinfo)); - JMETHOD(void, downsample, (j_compress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION in_row_index, - JSAMPIMAGE output_buf, - JDIMENSION out_row_group_index)); - - boolean need_context_rows; /* TRUE if need rows above & below */ -}; - -/* Forward DCT (also controls coefficient quantization) */ -struct jpeg_forward_dct { - JMETHOD(void, start_pass, (j_compress_ptr cinfo)); - /* perhaps this should be an array??? */ - JMETHOD(void, forward_DCT, (j_compress_ptr cinfo, - jpeg_component_info * compptr, - JSAMPARRAY sample_data, JBLOCKROW coef_blocks, - JDIMENSION start_row, JDIMENSION start_col, - JDIMENSION num_blocks)); -}; - -/* Entropy encoding */ -struct jpeg_entropy_encoder { - JMETHOD(void, start_pass, (j_compress_ptr cinfo, boolean gather_statistics)); - JMETHOD(boolean, encode_mcu, (j_compress_ptr cinfo, JBLOCKROW *MCU_data)); - JMETHOD(void, finish_pass, (j_compress_ptr cinfo)); -}; - -/* Marker writing */ -struct jpeg_marker_writer { - JMETHOD(void, write_file_header, (j_compress_ptr cinfo)); - JMETHOD(void, write_frame_header, (j_compress_ptr cinfo)); - JMETHOD(void, write_scan_header, (j_compress_ptr cinfo)); - JMETHOD(void, write_file_trailer, (j_compress_ptr cinfo)); - JMETHOD(void, write_tables_only, (j_compress_ptr cinfo)); - /* These routines are exported to allow insertion of extra markers */ - /* Probably only COM and APPn markers should be written this way */ - JMETHOD(void, write_marker_header, (j_compress_ptr cinfo, int marker, - unsigned int datalen)); - JMETHOD(void, write_marker_byte, (j_compress_ptr cinfo, int val)); -}; - - -/* Declarations for decompression modules */ - -/* Master control module */ -struct jpeg_decomp_master { - JMETHOD(void, prepare_for_output_pass, (j_decompress_ptr cinfo)); - JMETHOD(void, finish_output_pass, (j_decompress_ptr cinfo)); - - /* State variables made visible to other modules */ - boolean is_dummy_pass; /* True during 1st pass for 2-pass quant */ -}; - -/* Input control module */ -struct jpeg_input_controller { - JMETHOD(int, consume_input, (j_decompress_ptr cinfo)); - JMETHOD(void, reset_input_controller, (j_decompress_ptr cinfo)); - JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo)); - JMETHOD(void, finish_input_pass, (j_decompress_ptr cinfo)); - - /* State variables made visible to other modules */ - boolean has_multiple_scans; /* True if file has multiple scans */ - boolean eoi_reached; /* True when EOI has been consumed */ -}; - -/* Main buffer control (downsampled-data buffer) */ -struct jpeg_d_main_controller { - JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)); - JMETHOD(void, process_data, (j_decompress_ptr cinfo, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail)); -}; - -/* Coefficient buffer control */ -struct jpeg_d_coef_controller { - JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo)); - JMETHOD(int, consume_data, (j_decompress_ptr cinfo)); - JMETHOD(void, start_output_pass, (j_decompress_ptr cinfo)); - JMETHOD(int, decompress_data, (j_decompress_ptr cinfo, - JSAMPIMAGE output_buf)); - /* Pointer to array of coefficient virtual arrays, or NULL if none */ - jvirt_barray_ptr *coef_arrays; -}; - -/* Decompression postprocessing (color quantization buffer control) */ -struct jpeg_d_post_controller { - JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)); - JMETHOD(void, post_process_data, (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, - JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, - JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail)); -}; - -/* Marker reading & parsing */ -struct jpeg_marker_reader { - JMETHOD(void, reset_marker_reader, (j_decompress_ptr cinfo)); - /* Read markers until SOS or EOI. - * Returns same codes as are defined for jpeg_consume_input: - * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI. - */ - JMETHOD(int, read_markers, (j_decompress_ptr cinfo)); - /* Read a restart marker --- exported for use by entropy decoder only */ - jpeg_marker_parser_method read_restart_marker; - - /* State of marker reader --- nominally internal, but applications - * supplying COM or APPn handlers might like to know the state. - */ - boolean saw_SOI; /* found SOI? */ - boolean saw_SOF; /* found SOF? */ - int next_restart_num; /* next restart number expected (0-7) */ - unsigned int discarded_bytes; /* # of bytes skipped looking for a marker */ -}; - -/* Entropy decoding */ -struct jpeg_entropy_decoder { - JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); - JMETHOD(boolean, decode_mcu, (j_decompress_ptr cinfo, - JBLOCKROW *MCU_data)); - - /* This is here to share code between baseline and progressive decoders; */ - /* other modules probably should not use it */ - boolean insufficient_data; /* set TRUE after emitting warning */ -}; - -/* Inverse DCT (also performs dequantization) */ -typedef JMETHOD(void, inverse_DCT_method_ptr, - (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, - JSAMPARRAY output_buf, JDIMENSION output_col)); - -struct jpeg_inverse_dct { - JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); - /* It is useful to allow each component to have a separate IDCT method. */ - inverse_DCT_method_ptr inverse_DCT[MAX_COMPONENTS]; -}; - -/* Upsampling (note that upsampler must also call color converter) */ -struct jpeg_upsampler { - JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); - JMETHOD(void, upsample, (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, - JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, - JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail)); - - boolean need_context_rows; /* TRUE if need rows above & below */ -}; - -/* Colorspace conversion */ -struct jpeg_color_deconverter { - JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); - JMETHOD(void, color_convert, (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION input_row, - JSAMPARRAY output_buf, int num_rows)); -}; - -/* Color quantization or color precision reduction */ -struct jpeg_color_quantizer { - JMETHOD(void, start_pass, (j_decompress_ptr cinfo, boolean is_pre_scan)); - JMETHOD(void, color_quantize, (j_decompress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPARRAY output_buf, - int num_rows)); - JMETHOD(void, finish_pass, (j_decompress_ptr cinfo)); - JMETHOD(void, new_color_map, (j_decompress_ptr cinfo)); -}; - - -/* Miscellaneous useful macros */ - -#undef MAX -#define MAX(a,b) ((a) > (b) ? (a) : (b)) -#undef MIN -#define MIN(a,b) ((a) < (b) ? (a) : (b)) - - -/* We assume that right shift corresponds to signed division by 2 with - * rounding towards minus infinity. This is correct for typical "arithmetic - * shift" instructions that shift in copies of the sign bit. But some - * C compilers implement >> with an unsigned shift. For these machines you - * must define RIGHT_SHIFT_IS_UNSIGNED. - * RIGHT_SHIFT provides a proper signed right shift of an INT32 quantity. - * It is only applied with constant shift counts. SHIFT_TEMPS must be - * included in the variables of any routine using RIGHT_SHIFT. - */ - -#ifdef RIGHT_SHIFT_IS_UNSIGNED -#define SHIFT_TEMPS INT32 shift_temp; -#define RIGHT_SHIFT(x,shft) \ - ((shift_temp = (x)) < 0 ? \ - (shift_temp >> (shft)) | ((~((INT32) 0)) << (32-(shft))) : \ - (shift_temp >> (shft))) -#else -#define SHIFT_TEMPS -#define RIGHT_SHIFT(x,shft) ((x) >> (shft)) -#endif - - -/* Short forms of external names for systems with brain-damaged linkers. */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jinit_compress_master jICompress -#define jinit_c_master_control jICMaster -#define jinit_c_main_controller jICMainC -#define jinit_c_prep_controller jICPrepC -#define jinit_c_coef_controller jICCoefC -#define jinit_color_converter jICColor -#define jinit_downsampler jIDownsampler -#define jinit_forward_dct jIFDCT -#define jinit_huff_encoder jIHEncoder -#define jinit_phuff_encoder jIPHEncoder -#define jinit_marker_writer jIMWriter -#define jinit_master_decompress jIDMaster -#define jinit_d_main_controller jIDMainC -#define jinit_d_coef_controller jIDCoefC -#define jinit_d_post_controller jIDPostC -#define jinit_input_controller jIInCtlr -#define jinit_marker_reader jIMReader -#define jinit_huff_decoder jIHDecoder -#define jinit_phuff_decoder jIPHDecoder -#define jinit_inverse_dct jIIDCT -#define jinit_upsampler jIUpsampler -#define jinit_color_deconverter jIDColor -#define jinit_1pass_quantizer jI1Quant -#define jinit_2pass_quantizer jI2Quant -#define jinit_merged_upsampler jIMUpsampler -#define jinit_memory_mgr jIMemMgr -#define jdiv_round_up jDivRound -#define jround_up jRound -#define jcopy_sample_rows jCopySamples -#define jcopy_block_row jCopyBlocks -#define jzero_far jZeroFar -#define jpeg_zigzag_order jZIGTable -#define jpeg_natural_order jZAGTable -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - - -/* Compression module initialization routines */ -EXTERN(void) jinit_compress_master JPP((j_compress_ptr cinfo)); -EXTERN(void) jinit_c_master_control JPP((j_compress_ptr cinfo, - boolean transcode_only)); -EXTERN(void) jinit_c_main_controller JPP((j_compress_ptr cinfo, - boolean need_full_buffer)); -EXTERN(void) jinit_c_prep_controller JPP((j_compress_ptr cinfo, - boolean need_full_buffer)); -EXTERN(void) jinit_c_coef_controller JPP((j_compress_ptr cinfo, - boolean need_full_buffer)); -EXTERN(void) jinit_color_converter JPP((j_compress_ptr cinfo)); -EXTERN(void) jinit_downsampler JPP((j_compress_ptr cinfo)); -EXTERN(void) jinit_forward_dct JPP((j_compress_ptr cinfo)); -EXTERN(void) jinit_huff_encoder JPP((j_compress_ptr cinfo)); -EXTERN(void) jinit_phuff_encoder JPP((j_compress_ptr cinfo)); -EXTERN(void) jinit_marker_writer JPP((j_compress_ptr cinfo)); -/* Decompression module initialization routines */ -EXTERN(void) jinit_master_decompress JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_d_main_controller JPP((j_decompress_ptr cinfo, - boolean need_full_buffer)); -EXTERN(void) jinit_d_coef_controller JPP((j_decompress_ptr cinfo, - boolean need_full_buffer)); -EXTERN(void) jinit_d_post_controller JPP((j_decompress_ptr cinfo, - boolean need_full_buffer)); -EXTERN(void) jinit_input_controller JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_marker_reader JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_huff_decoder JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_phuff_decoder JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_inverse_dct JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_upsampler JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_color_deconverter JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_1pass_quantizer JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_2pass_quantizer JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_merged_upsampler JPP((j_decompress_ptr cinfo)); -/* Memory manager initialization */ -EXTERN(void) jinit_memory_mgr JPP((j_common_ptr cinfo)); - -/* Utility routines in jutils.c */ -EXTERN(long) jdiv_round_up JPP((long a, long b)); -EXTERN(long) jround_up JPP((long a, long b)); -EXTERN(void) jcopy_sample_rows JPP((JSAMPARRAY input_array, int source_row, - JSAMPARRAY output_array, int dest_row, - int num_rows, JDIMENSION num_cols)); -EXTERN(void) jcopy_block_row JPP((JBLOCKROW input_row, JBLOCKROW output_row, - JDIMENSION num_blocks)); -EXTERN(void) jzero_far JPP((void FAR * target, size_t bytestozero)); -/* Constant tables in jutils.c */ -#if 0 /* This table is not actually needed in v6a */ -extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */ -#endif -extern const int jpeg_natural_order[]; /* zigzag coef order to natural order */ - -/* Suppress undefined-structure complaints if necessary. */ - -#ifdef INCOMPLETE_TYPES_BROKEN -#ifndef AM_MEMORY_MANAGER /* only jmemmgr.c defines these */ -struct jvirt_sarray_control { long dummy; }; -struct jvirt_barray_control { long dummy; }; -#endif -#endif /* INCOMPLETE_TYPES_BROKEN */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jpeglib.h b/irrlicht-1.6/source/Irrlicht/jpeglib/jpeglib.h deleted file mode 100644 index b9356f399..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jpeglib.h +++ /dev/null @@ -1,1096 +0,0 @@ -/* - * jpeglib.h - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file defines the application interface for the JPEG library. - * Most applications using the library need only include this file, - * and perhaps jerror.h if they want to know the exact error codes. - */ - -#ifndef JPEGLIB_H -#define JPEGLIB_H - -/* - * First we include the configuration files that record how this - * installation of the JPEG library is set up. jconfig.h can be - * generated automatically for many systems. jmorecfg.h contains - * manual configuration options that most people need not worry about. - */ - -#ifndef JCONFIG_INCLUDED /* in case jinclude.h already did */ -#include "jconfig.h" /* widely used configuration options */ -#endif -#include "jmorecfg.h" /* seldom changed options */ - - -/* Version ID for the JPEG library. - * Might be useful for tests like "#if JPEG_LIB_VERSION >= 60". - */ - -#define JPEG_LIB_VERSION 62 /* Version 6b */ - - -/* Various constants determining the sizes of things. - * All of these are specified by the JPEG standard, so don't change them - * if you want to be compatible. - */ - -#define DCTSIZE 8 /* The basic DCT block is 8x8 samples */ -#define DCTSIZE2 64 /* DCTSIZE squared; # of elements in a block */ -#define NUM_QUANT_TBLS 4 /* Quantization tables are numbered 0..3 */ -#define NUM_HUFF_TBLS 4 /* Huffman tables are numbered 0..3 */ -#define NUM_ARITH_TBLS 16 /* Arith-coding tables are numbered 0..15 */ -#define MAX_COMPS_IN_SCAN 4 /* JPEG limit on # of components in one scan */ -#define MAX_SAMP_FACTOR 4 /* JPEG limit on sampling factors */ -/* Unfortunately, some bozo at Adobe saw no reason to be bound by the standard; - * the PostScript DCT filter can emit files with many more than 10 blocks/MCU. - * If you happen to run across such a file, you can up D_MAX_BLOCKS_IN_MCU - * to handle it. We even let you do this from the jconfig.h file. However, - * we strongly discourage changing C_MAX_BLOCKS_IN_MCU; just because Adobe - * sometimes emits noncompliant files doesn't mean you should too. - */ -#define C_MAX_BLOCKS_IN_MCU 10 /* compressor's limit on blocks per MCU */ -#ifndef D_MAX_BLOCKS_IN_MCU -#define D_MAX_BLOCKS_IN_MCU 10 /* decompressor's limit on blocks per MCU */ -#endif - - -/* Data structures for images (arrays of samples and of DCT coefficients). - * On 80x86 machines, the image arrays are too big for near pointers, - * but the pointer arrays can fit in near memory. - */ - -typedef JSAMPLE FAR *JSAMPROW; /* ptr to one image row of pixel samples. */ -typedef JSAMPROW *JSAMPARRAY; /* ptr to some rows (a 2-D sample array) */ -typedef JSAMPARRAY *JSAMPIMAGE; /* a 3-D sample array: top index is color */ - -typedef JCOEF JBLOCK[DCTSIZE2]; /* one block of coefficients */ -typedef JBLOCK FAR *JBLOCKROW; /* pointer to one row of coefficient blocks */ -typedef JBLOCKROW *JBLOCKARRAY; /* a 2-D array of coefficient blocks */ -typedef JBLOCKARRAY *JBLOCKIMAGE; /* a 3-D array of coefficient blocks */ - -typedef JCOEF FAR *JCOEFPTR; /* useful in a couple of places */ - - -/* Types for JPEG compression parameters and working tables. */ - - -/* DCT coefficient quantization tables. */ - -typedef struct { - /* This array gives the coefficient quantizers in natural array order - * (not the zigzag order in which they are stored in a JPEG DQT marker). - * CAUTION: IJG versions prior to v6a kept this array in zigzag order. - */ - UINT16 quantval[DCTSIZE2]; /* quantization step for each coefficient */ - /* This field is used only during compression. It's initialized FALSE when - * the table is created, and set TRUE when it's been output to the file. - * You could suppress output of a table by setting this to TRUE. - * (See jpeg_suppress_tables for an example.) - */ - boolean sent_table; /* TRUE when table has been output */ -} JQUANT_TBL; - - -/* Huffman coding tables. */ - -typedef struct { - /* These two fields directly represent the contents of a JPEG DHT marker */ - UINT8 bits[17]; /* bits[k] = # of symbols with codes of */ - /* length k bits; bits[0] is unused */ - UINT8 huffval[256]; /* The symbols, in order of incr code length */ - /* This field is used only during compression. It's initialized FALSE when - * the table is created, and set TRUE when it's been output to the file. - * You could suppress output of a table by setting this to TRUE. - * (See jpeg_suppress_tables for an example.) - */ - boolean sent_table; /* TRUE when table has been output */ -} JHUFF_TBL; - - -/* Basic info about one component (color channel). */ - -typedef struct { - /* These values are fixed over the whole image. */ - /* For compression, they must be supplied by parameter setup; */ - /* for decompression, they are read from the SOF marker. */ - int component_id; /* identifier for this component (0..255) */ - int component_index; /* its index in SOF or cinfo->comp_info[] */ - int h_samp_factor; /* horizontal sampling factor (1..4) */ - int v_samp_factor; /* vertical sampling factor (1..4) */ - int quant_tbl_no; /* quantization table selector (0..3) */ - /* These values may vary between scans. */ - /* For compression, they must be supplied by parameter setup; */ - /* for decompression, they are read from the SOS marker. */ - /* The decompressor output side may not use these variables. */ - int dc_tbl_no; /* DC entropy table selector (0..3) */ - int ac_tbl_no; /* AC entropy table selector (0..3) */ - - /* Remaining fields should be treated as private by applications. */ - - /* These values are computed during compression or decompression startup: */ - /* Component's size in DCT blocks. - * Any dummy blocks added to complete an MCU are not counted; therefore - * these values do not depend on whether a scan is interleaved or not. - */ - JDIMENSION width_in_blocks; - JDIMENSION height_in_blocks; - /* Size of a DCT block in samples. Always DCTSIZE for compression. - * For decompression this is the size of the output from one DCT block, - * reflecting any scaling we choose to apply during the IDCT step. - * Values of 1,2,4,8 are likely to be supported. Note that different - * components may receive different IDCT scalings. - */ - int DCT_scaled_size; - /* The downsampled dimensions are the component's actual, unpadded number - * of samples at the main buffer (preprocessing/compression interface), thus - * downsampled_width = ceil(image_width * Hi/Hmax) - * and similarly for height. For decompression, IDCT scaling is included, so - * downsampled_width = ceil(image_width * Hi/Hmax * DCT_scaled_size/DCTSIZE) - */ - JDIMENSION downsampled_width; /* actual width in samples */ - JDIMENSION downsampled_height; /* actual height in samples */ - /* This flag is used only for decompression. In cases where some of the - * components will be ignored (eg grayscale output from YCbCr image), - * we can skip most computations for the unused components. - */ - boolean component_needed; /* do we need the value of this component? */ - - /* These values are computed before starting a scan of the component. */ - /* The decompressor output side may not use these variables. */ - int MCU_width; /* number of blocks per MCU, horizontally */ - int MCU_height; /* number of blocks per MCU, vertically */ - int MCU_blocks; /* MCU_width * MCU_height */ - int MCU_sample_width; /* MCU width in samples, MCU_width*DCT_scaled_size */ - int last_col_width; /* # of non-dummy blocks across in last MCU */ - int last_row_height; /* # of non-dummy blocks down in last MCU */ - - /* Saved quantization table for component; NULL if none yet saved. - * See jdinput.c comments about the need for this information. - * This field is currently used only for decompression. - */ - JQUANT_TBL * quant_table; - - /* Private per-component storage for DCT or IDCT subsystem. */ - void * dct_table; -} jpeg_component_info; - - -/* The script for encoding a multiple-scan file is an array of these: */ - -typedef struct { - int comps_in_scan; /* number of components encoded in this scan */ - int component_index[MAX_COMPS_IN_SCAN]; /* their SOF/comp_info[] indexes */ - int Ss, Se; /* progressive JPEG spectral selection parms */ - int Ah, Al; /* progressive JPEG successive approx. parms */ -} jpeg_scan_info; - -/* The decompressor can save APPn and COM markers in a list of these: */ - -typedef struct jpeg_marker_struct FAR * jpeg_saved_marker_ptr; - -struct jpeg_marker_struct { - jpeg_saved_marker_ptr next; /* next in list, or NULL */ - UINT8 marker; /* marker code: JPEG_COM, or JPEG_APP0+n */ - unsigned int original_length; /* # bytes of data in the file */ - unsigned int data_length; /* # bytes of data saved at data[] */ - JOCTET FAR * data; /* the data contained in the marker */ - /* the marker length word is not counted in data_length or original_length */ -}; - -/* Known color spaces. */ - -typedef enum { - JCS_UNKNOWN, /* error/unspecified */ - JCS_GRAYSCALE, /* monochrome */ - JCS_RGB, /* red/green/blue */ - JCS_YCbCr, /* Y/Cb/Cr (also known as YUV) */ - JCS_CMYK, /* C/M/Y/K */ - JCS_YCCK /* Y/Cb/Cr/K */ -} J_COLOR_SPACE; - -/* DCT/IDCT algorithm options. */ - -typedef enum { - JDCT_ISLOW, /* slow but accurate integer algorithm */ - JDCT_IFAST, /* faster, less accurate integer method */ - JDCT_FLOAT /* floating-point: accurate, fast on fast HW */ -} J_DCT_METHOD; - -#ifndef JDCT_DEFAULT /* may be overridden in jconfig.h */ -#define JDCT_DEFAULT JDCT_ISLOW -#endif -#ifndef JDCT_FASTEST /* may be overridden in jconfig.h */ -#define JDCT_FASTEST JDCT_IFAST -#endif - -/* Dithering options for decompression. */ - -typedef enum { - JDITHER_NONE, /* no dithering */ - JDITHER_ORDERED, /* simple ordered dither */ - JDITHER_FS /* Floyd-Steinberg error diffusion dither */ -} J_DITHER_MODE; - - -/* Common fields between JPEG compression and decompression master structs. */ - -#define jpeg_common_fields \ - struct jpeg_error_mgr * err; /* Error handler module */\ - struct jpeg_memory_mgr * mem; /* Memory manager module */\ - struct jpeg_progress_mgr * progress; /* Progress monitor, or NULL if none */\ - void * client_data; /* Available for use by application */\ - boolean is_decompressor; /* So common code can tell which is which */\ - int global_state /* For checking call sequence validity */ - -/* Routines that are to be used by both halves of the library are declared - * to receive a pointer to this structure. There are no actual instances of - * jpeg_common_struct, only of jpeg_compress_struct and jpeg_decompress_struct. - */ -struct jpeg_common_struct { - jpeg_common_fields; /* Fields common to both master struct types */ - /* Additional fields follow in an actual jpeg_compress_struct or - * jpeg_decompress_struct. All three structs must agree on these - * initial fields! (This would be a lot cleaner in C++.) - */ -}; - -typedef struct jpeg_common_struct * j_common_ptr; -typedef struct jpeg_compress_struct * j_compress_ptr; -typedef struct jpeg_decompress_struct * j_decompress_ptr; - - -/* Master record for a compression instance */ - -struct jpeg_compress_struct { - jpeg_common_fields; /* Fields shared with jpeg_decompress_struct */ - - /* Destination for compressed data */ - struct jpeg_destination_mgr * dest; - - /* Description of source image --- these fields must be filled in by - * outer application before starting compression. in_color_space must - * be correct before you can even call jpeg_set_defaults(). - */ - - JDIMENSION image_width; /* input image width */ - JDIMENSION image_height; /* input image height */ - int input_components; /* # of color components in input image */ - J_COLOR_SPACE in_color_space; /* colorspace of input image */ - - double input_gamma; /* image gamma of input image */ - - /* Compression parameters --- these fields must be set before calling - * jpeg_start_compress(). We recommend calling jpeg_set_defaults() to - * initialize everything to reasonable defaults, then changing anything - * the application specifically wants to change. That way you won't get - * burnt when new parameters are added. Also note that there are several - * helper routines to simplify changing parameters. - */ - - int data_precision; /* bits of precision in image data */ - - int num_components; /* # of color components in JPEG image */ - J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */ - - jpeg_component_info * comp_info; - /* comp_info[i] describes component that appears i'th in SOF */ - - JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]; - /* ptrs to coefficient quantization tables, or NULL if not defined */ - - JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]; - JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]; - /* ptrs to Huffman coding tables, or NULL if not defined */ - - UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */ - UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */ - UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */ - - int num_scans; /* # of entries in scan_info array */ - const jpeg_scan_info * scan_info; /* script for multi-scan file, or NULL */ - /* The default value of scan_info is NULL, which causes a single-scan - * sequential JPEG file to be emitted. To create a multi-scan file, - * set num_scans and scan_info to point to an array of scan definitions. - */ - - boolean raw_data_in; /* TRUE=caller supplies downsampled data */ - boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ - boolean optimize_coding; /* TRUE=optimize entropy encoding parms */ - boolean CCIR601_sampling; /* TRUE=first samples are cosited */ - int smoothing_factor; /* 1..100, or 0 for no input smoothing */ - J_DCT_METHOD dct_method; /* DCT algorithm selector */ - - /* The restart interval can be specified in absolute MCUs by setting - * restart_interval, or in MCU rows by setting restart_in_rows - * (in which case the correct restart_interval will be figured - * for each scan). - */ - unsigned int restart_interval; /* MCUs per restart, or 0 for no restart */ - int restart_in_rows; /* if > 0, MCU rows per restart interval */ - - /* Parameters controlling emission of special markers. */ - - boolean write_JFIF_header; /* should a JFIF marker be written? */ - UINT8 JFIF_major_version; /* What to write for the JFIF version number */ - UINT8 JFIF_minor_version; - /* These three values are not used by the JPEG code, merely copied */ - /* into the JFIF APP0 marker. density_unit can be 0 for unknown, */ - /* 1 for dots/inch, or 2 for dots/cm. Note that the pixel aspect */ - /* ratio is defined by X_density/Y_density even when density_unit=0. */ - UINT8 density_unit; /* JFIF code for pixel size units */ - UINT16 X_density; /* Horizontal pixel density */ - UINT16 Y_density; /* Vertical pixel density */ - boolean write_Adobe_marker; /* should an Adobe marker be written? */ - - /* State variable: index of next scanline to be written to - * jpeg_write_scanlines(). Application may use this to control its - * processing loop, e.g., "while (next_scanline < image_height)". - */ - - JDIMENSION next_scanline; /* 0 .. image_height-1 */ - - /* Remaining fields are known throughout compressor, but generally - * should not be touched by a surrounding application. - */ - - /* - * These fields are computed during compression startup - */ - boolean progressive_mode; /* TRUE if scan script uses progressive mode */ - int max_h_samp_factor; /* largest h_samp_factor */ - int max_v_samp_factor; /* largest v_samp_factor */ - - JDIMENSION total_iMCU_rows; /* # of iMCU rows to be input to coef ctlr */ - /* The coefficient controller receives data in units of MCU rows as defined - * for fully interleaved scans (whether the JPEG file is interleaved or not). - * There are v_samp_factor * DCTSIZE sample rows of each component in an - * "iMCU" (interleaved MCU) row. - */ - - /* - * These fields are valid during any one scan. - * They describe the components and MCUs actually appearing in the scan. - */ - int comps_in_scan; /* # of JPEG components in this scan */ - jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]; - /* *cur_comp_info[i] describes component that appears i'th in SOS */ - - JDIMENSION MCUs_per_row; /* # of MCUs across the image */ - JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */ - - int blocks_in_MCU; /* # of DCT blocks per MCU */ - int MCU_membership[C_MAX_BLOCKS_IN_MCU]; - /* MCU_membership[i] is index in cur_comp_info of component owning */ - /* i'th block in an MCU */ - - int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */ - - /* - * Links to compression subobjects (methods and private variables of modules) - */ - struct jpeg_comp_master * master; - struct jpeg_c_main_controller * main; - struct jpeg_c_prep_controller * prep; - struct jpeg_c_coef_controller * coef; - struct jpeg_marker_writer * marker; - struct jpeg_color_converter * cconvert; - struct jpeg_downsampler * downsample; - struct jpeg_forward_dct * fdct; - struct jpeg_entropy_encoder * entropy; - jpeg_scan_info * script_space; /* workspace for jpeg_simple_progression */ - int script_space_size; -}; - - -/* Master record for a decompression instance */ - -struct jpeg_decompress_struct { - jpeg_common_fields; /* Fields shared with jpeg_compress_struct */ - - /* Source of compressed data */ - struct jpeg_source_mgr * src; - - /* Basic description of image --- filled in by jpeg_read_header(). */ - /* Application may inspect these values to decide how to process image. */ - - JDIMENSION image_width; /* nominal image width (from SOF marker) */ - JDIMENSION image_height; /* nominal image height */ - int num_components; /* # of color components in JPEG image */ - J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */ - - /* Decompression processing parameters --- these fields must be set before - * calling jpeg_start_decompress(). Note that jpeg_read_header() initializes - * them to default values. - */ - - J_COLOR_SPACE out_color_space; /* colorspace for output */ - - unsigned int scale_num, scale_denom; /* fraction by which to scale image */ - - double output_gamma; /* image gamma wanted in output */ - - boolean buffered_image; /* TRUE=multiple output passes */ - boolean raw_data_out; /* TRUE=downsampled data wanted */ - - J_DCT_METHOD dct_method; /* IDCT algorithm selector */ - boolean do_fancy_upsampling; /* TRUE=apply fancy upsampling */ - boolean do_block_smoothing; /* TRUE=apply interblock smoothing */ - - boolean quantize_colors; /* TRUE=colormapped output wanted */ - /* the following are ignored if not quantize_colors: */ - J_DITHER_MODE dither_mode; /* type of color dithering to use */ - boolean two_pass_quantize; /* TRUE=use two-pass color quantization */ - int desired_number_of_colors; /* max # colors to use in created colormap */ - /* these are significant only in buffered-image mode: */ - boolean enable_1pass_quant; /* enable future use of 1-pass quantizer */ - boolean enable_external_quant;/* enable future use of external colormap */ - boolean enable_2pass_quant; /* enable future use of 2-pass quantizer */ - - /* Description of actual output image that will be returned to application. - * These fields are computed by jpeg_start_decompress(). - * You can also use jpeg_calc_output_dimensions() to determine these values - * in advance of calling jpeg_start_decompress(). - */ - - JDIMENSION output_width; /* scaled image width */ - JDIMENSION output_height; /* scaled image height */ - int out_color_components; /* # of color components in out_color_space */ - int output_components; /* # of color components returned */ - /* output_components is 1 (a colormap index) when quantizing colors; - * otherwise it equals out_color_components. - */ - int rec_outbuf_height; /* min recommended height of scanline buffer */ - /* If the buffer passed to jpeg_read_scanlines() is less than this many rows - * high, space and time will be wasted due to unnecessary data copying. - * Usually rec_outbuf_height will be 1 or 2, at most 4. - */ - - /* When quantizing colors, the output colormap is described by these fields. - * The application can supply a colormap by setting colormap non-NULL before - * calling jpeg_start_decompress; otherwise a colormap is created during - * jpeg_start_decompress or jpeg_start_output. - * The map has out_color_components rows and actual_number_of_colors columns. - */ - int actual_number_of_colors; /* number of entries in use */ - JSAMPARRAY colormap; /* The color map as a 2-D pixel array */ - - /* State variables: these variables indicate the progress of decompression. - * The application may examine these but must not modify them. - */ - - /* Row index of next scanline to be read from jpeg_read_scanlines(). - * Application may use this to control its processing loop, e.g., - * "while (output_scanline < output_height)". - */ - JDIMENSION output_scanline; /* 0 .. output_height-1 */ - - /* Current input scan number and number of iMCU rows completed in scan. - * These indicate the progress of the decompressor input side. - */ - int input_scan_number; /* Number of SOS markers seen so far */ - JDIMENSION input_iMCU_row; /* Number of iMCU rows completed */ - - /* The "output scan number" is the notional scan being displayed by the - * output side. The decompressor will not allow output scan/row number - * to get ahead of input scan/row, but it can fall arbitrarily far behind. - */ - int output_scan_number; /* Nominal scan number being displayed */ - JDIMENSION output_iMCU_row; /* Number of iMCU rows read */ - - /* Current progression status. coef_bits[c][i] indicates the precision - * with which component c's DCT coefficient i (in zigzag order) is known. - * It is -1 when no data has yet been received, otherwise it is the point - * transform (shift) value for the most recent scan of the coefficient - * (thus, 0 at completion of the progression). - * This pointer is NULL when reading a non-progressive file. - */ - int (*coef_bits)[DCTSIZE2]; /* -1 or current Al value for each coef */ - - /* Internal JPEG parameters --- the application usually need not look at - * these fields. Note that the decompressor output side may not use - * any parameters that can change between scans. - */ - - /* Quantization and Huffman tables are carried forward across input - * datastreams when processing abbreviated JPEG datastreams. - */ - - JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]; - /* ptrs to coefficient quantization tables, or NULL if not defined */ - - JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]; - JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]; - /* ptrs to Huffman coding tables, or NULL if not defined */ - - /* These parameters are never carried across datastreams, since they - * are given in SOF/SOS markers or defined to be reset by SOI. - */ - - int data_precision; /* bits of precision in image data */ - - jpeg_component_info * comp_info; - /* comp_info[i] describes component that appears i'th in SOF */ - - boolean progressive_mode; /* TRUE if SOFn specifies progressive mode */ - boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ - - UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */ - UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */ - UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */ - - unsigned int restart_interval; /* MCUs per restart interval, or 0 for no restart */ - - /* These fields record data obtained from optional markers recognized by - * the JPEG library. - */ - boolean saw_JFIF_marker; /* TRUE iff a JFIF APP0 marker was found */ - /* Data copied from JFIF marker; only valid if saw_JFIF_marker is TRUE: */ - UINT8 JFIF_major_version; /* JFIF version number */ - UINT8 JFIF_minor_version; - UINT8 density_unit; /* JFIF code for pixel size units */ - UINT16 X_density; /* Horizontal pixel density */ - UINT16 Y_density; /* Vertical pixel density */ - boolean saw_Adobe_marker; /* TRUE iff an Adobe APP14 marker was found */ - UINT8 Adobe_transform; /* Color transform code from Adobe marker */ - - boolean CCIR601_sampling; /* TRUE=first samples are cosited */ - - /* Aside from the specific data retained from APPn markers known to the - * library, the uninterpreted contents of any or all APPn and COM markers - * can be saved in a list for examination by the application. - */ - jpeg_saved_marker_ptr marker_list; /* Head of list of saved markers */ - - /* Remaining fields are known throughout decompressor, but generally - * should not be touched by a surrounding application. - */ - - /* - * These fields are computed during decompression startup - */ - int max_h_samp_factor; /* largest h_samp_factor */ - int max_v_samp_factor; /* largest v_samp_factor */ - - int min_DCT_scaled_size; /* smallest DCT_scaled_size of any component */ - - JDIMENSION total_iMCU_rows; /* # of iMCU rows in image */ - /* The coefficient controller's input and output progress is measured in - * units of "iMCU" (interleaved MCU) rows. These are the same as MCU rows - * in fully interleaved JPEG scans, but are used whether the scan is - * interleaved or not. We define an iMCU row as v_samp_factor DCT block - * rows of each component. Therefore, the IDCT output contains - * v_samp_factor*DCT_scaled_size sample rows of a component per iMCU row. - */ - - JSAMPLE * sample_range_limit; /* table for fast range-limiting */ - - /* - * These fields are valid during any one scan. - * They describe the components and MCUs actually appearing in the scan. - * Note that the decompressor output side must not use these fields. - */ - int comps_in_scan; /* # of JPEG components in this scan */ - jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]; - /* *cur_comp_info[i] describes component that appears i'th in SOS */ - - JDIMENSION MCUs_per_row; /* # of MCUs across the image */ - JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */ - - int blocks_in_MCU; /* # of DCT blocks per MCU */ - int MCU_membership[D_MAX_BLOCKS_IN_MCU]; - /* MCU_membership[i] is index in cur_comp_info of component owning */ - /* i'th block in an MCU */ - - int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */ - - /* This field is shared between entropy decoder and marker parser. - * It is either zero or the code of a JPEG marker that has been - * read from the data source, but has not yet been processed. - */ - int unread_marker; - - /* - * Links to decompression subobjects (methods, private variables of modules) - */ - struct jpeg_decomp_master * master; - struct jpeg_d_main_controller * main; - struct jpeg_d_coef_controller * coef; - struct jpeg_d_post_controller * post; - struct jpeg_input_controller * inputctl; - struct jpeg_marker_reader * marker; - struct jpeg_entropy_decoder * entropy; - struct jpeg_inverse_dct * idct; - struct jpeg_upsampler * upsample; - struct jpeg_color_deconverter * cconvert; - struct jpeg_color_quantizer * cquantize; -}; - - -/* "Object" declarations for JPEG modules that may be supplied or called - * directly by the surrounding application. - * As with all objects in the JPEG library, these structs only define the - * publicly visible methods and state variables of a module. Additional - * private fields may exist after the public ones. - */ - - -/* Error handler object */ - -struct jpeg_error_mgr { - /* Error exit handler: does not return to caller */ - JMETHOD(void, error_exit, (j_common_ptr cinfo)); - /* Conditionally emit a trace or warning message */ - JMETHOD(void, emit_message, (j_common_ptr cinfo, int msg_level)); - /* Routine that actually outputs a trace or error message */ - JMETHOD(void, output_message, (j_common_ptr cinfo)); - /* Format a message string for the most recent JPEG error or message */ - JMETHOD(void, format_message, (j_common_ptr cinfo, char * buffer)); -#define JMSG_LENGTH_MAX 200 /* recommended size of format_message buffer */ - /* Reset error state variables at start of a new image */ - JMETHOD(void, reset_error_mgr, (j_common_ptr cinfo)); - - /* The message ID code and any parameters are saved here. - * A message can have one string parameter or up to 8 int parameters. - */ - int msg_code; -#define JMSG_STR_PARM_MAX 80 - union { - int i[8]; - char s[JMSG_STR_PARM_MAX]; - } msg_parm; - - /* Standard state variables for error facility */ - - int trace_level; /* max msg_level that will be displayed */ - - /* For recoverable corrupt-data errors, we emit a warning message, - * but keep going unless emit_message chooses to abort. emit_message - * should count warnings in num_warnings. The surrounding application - * can check for bad data by seeing if num_warnings is nonzero at the - * end of processing. - */ - long num_warnings; /* number of corrupt-data warnings */ - - /* These fields point to the table(s) of error message strings. - * An application can change the table pointer to switch to a different - * message list (typically, to change the language in which errors are - * reported). Some applications may wish to add additional error codes - * that will be handled by the JPEG library error mechanism; the second - * table pointer is used for this purpose. - * - * First table includes all errors generated by JPEG library itself. - * Error code 0 is reserved for a "no such error string" message. - */ - const char * const * jpeg_message_table; /* Library errors */ - int last_jpeg_message; /* Table contains strings 0..last_jpeg_message */ - /* Second table can be added by application (see cjpeg/djpeg for example). - * It contains strings numbered first_addon_message..last_addon_message. - */ - const char * const * addon_message_table; /* Non-library errors */ - int first_addon_message; /* code for first string in addon table */ - int last_addon_message; /* code for last string in addon table */ -}; - - -/* Progress monitor object */ - -struct jpeg_progress_mgr { - JMETHOD(void, progress_monitor, (j_common_ptr cinfo)); - - long pass_counter; /* work units completed in this pass */ - long pass_limit; /* total number of work units in this pass */ - int completed_passes; /* passes completed so far */ - int total_passes; /* total number of passes expected */ -}; - - -/* Data destination object for compression */ - -struct jpeg_destination_mgr { - JOCTET * next_output_byte; /* => next byte to write in buffer */ - size_t free_in_buffer; /* # of byte spaces remaining in buffer */ - - JMETHOD(void, init_destination, (j_compress_ptr cinfo)); - JMETHOD(boolean, empty_output_buffer, (j_compress_ptr cinfo)); - JMETHOD(void, term_destination, (j_compress_ptr cinfo)); -}; - - -/* Data source object for decompression */ - -struct jpeg_source_mgr { - const JOCTET * next_input_byte; /* => next byte to read from buffer */ - size_t bytes_in_buffer; /* # of bytes remaining in buffer */ - - JMETHOD(void, init_source, (j_decompress_ptr cinfo)); - JMETHOD(boolean, fill_input_buffer, (j_decompress_ptr cinfo)); - JMETHOD(void, skip_input_data, (j_decompress_ptr cinfo, long num_bytes)); - JMETHOD(boolean, resync_to_restart, (j_decompress_ptr cinfo, int desired)); - JMETHOD(void, term_source, (j_decompress_ptr cinfo)); -}; - - -/* Memory manager object. - * Allocates "small" objects (a few K total), "large" objects (tens of K), - * and "really big" objects (virtual arrays with backing store if needed). - * The memory manager does not allow individual objects to be freed; rather, - * each created object is assigned to a pool, and whole pools can be freed - * at once. This is faster and more convenient than remembering exactly what - * to free, especially where malloc()/free() are not too speedy. - * NB: alloc routines never return NULL. They exit to error_exit if not - * successful. - */ - -#define JPOOL_PERMANENT 0 /* lasts until master record is destroyed */ -#define JPOOL_IMAGE 1 /* lasts until done with image/datastream */ -#define JPOOL_NUMPOOLS 2 - -typedef struct jvirt_sarray_control * jvirt_sarray_ptr; -typedef struct jvirt_barray_control * jvirt_barray_ptr; - - -struct jpeg_memory_mgr { - /* Method pointers */ - JMETHOD(void *, alloc_small, (j_common_ptr cinfo, int pool_id, - size_t sizeofobject)); - JMETHOD(void FAR *, alloc_large, (j_common_ptr cinfo, int pool_id, - size_t sizeofobject)); - JMETHOD(JSAMPARRAY, alloc_sarray, (j_common_ptr cinfo, int pool_id, - JDIMENSION samplesperrow, - JDIMENSION numrows)); - JMETHOD(JBLOCKARRAY, alloc_barray, (j_common_ptr cinfo, int pool_id, - JDIMENSION blocksperrow, - JDIMENSION numrows)); - JMETHOD(jvirt_sarray_ptr, request_virt_sarray, (j_common_ptr cinfo, - int pool_id, - boolean pre_zero, - JDIMENSION samplesperrow, - JDIMENSION numrows, - JDIMENSION maxaccess)); - JMETHOD(jvirt_barray_ptr, request_virt_barray, (j_common_ptr cinfo, - int pool_id, - boolean pre_zero, - JDIMENSION blocksperrow, - JDIMENSION numrows, - JDIMENSION maxaccess)); - JMETHOD(void, realize_virt_arrays, (j_common_ptr cinfo)); - JMETHOD(JSAMPARRAY, access_virt_sarray, (j_common_ptr cinfo, - jvirt_sarray_ptr ptr, - JDIMENSION start_row, - JDIMENSION num_rows, - boolean writable)); - JMETHOD(JBLOCKARRAY, access_virt_barray, (j_common_ptr cinfo, - jvirt_barray_ptr ptr, - JDIMENSION start_row, - JDIMENSION num_rows, - boolean writable)); - JMETHOD(void, free_pool, (j_common_ptr cinfo, int pool_id)); - JMETHOD(void, self_destruct, (j_common_ptr cinfo)); - - /* Limit on memory allocation for this JPEG object. (Note that this is - * merely advisory, not a guaranteed maximum; it only affects the space - * used for virtual-array buffers.) May be changed by outer application - * after creating the JPEG object. - */ - long max_memory_to_use; - - /* Maximum allocation request accepted by alloc_large. */ - long max_alloc_chunk; -}; - - -/* Routine signature for application-supplied marker processing methods. - * Need not pass marker code since it is stored in cinfo->unread_marker. - */ -typedef JMETHOD(boolean, jpeg_marker_parser_method, (j_decompress_ptr cinfo)); - - -/* Declarations for routines called by application. - * The JPP macro hides prototype parameters from compilers that can't cope. - * Note JPP requires double parentheses. - */ - -#ifdef HAVE_PROTOTYPES -#define JPP(arglist) arglist -#else -#define JPP(arglist) () -#endif - - -/* Short forms of external names for systems with brain-damaged linkers. - * We shorten external names to be unique in the first six letters, which - * is good enough for all known systems. - * (If your compiler itself needs names to be unique in less than 15 - * characters, you are out of luck. Get a better compiler.) - */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jpeg_std_error jStdError -#define jpeg_CreateCompress jCreaCompress -#define jpeg_CreateDecompress jCreaDecompress -#define jpeg_destroy_compress jDestCompress -#define jpeg_destroy_decompress jDestDecompress -#define jpeg_stdio_dest jStdDest -#define jpeg_stdio_src jStdSrc -#define jpeg_set_defaults jSetDefaults -#define jpeg_set_colorspace jSetColorspace -#define jpeg_default_colorspace jDefColorspace -#define jpeg_set_quality jSetQuality -#define jpeg_set_linear_quality jSetLQuality -#define jpeg_add_quant_table jAddQuantTable -#define jpeg_quality_scaling jQualityScaling -#define jpeg_simple_progression jSimProgress -#define jpeg_suppress_tables jSuppressTables -#define jpeg_alloc_quant_table jAlcQTable -#define jpeg_alloc_huff_table jAlcHTable -#define jpeg_start_compress jStrtCompress -#define jpeg_write_scanlines jWrtScanlines -#define jpeg_finish_compress jFinCompress -#define jpeg_write_raw_data jWrtRawData -#define jpeg_write_marker jWrtMarker -#define jpeg_write_m_header jWrtMHeader -#define jpeg_write_m_byte jWrtMByte -#define jpeg_write_tables jWrtTables -#define jpeg_read_header jReadHeader -#define jpeg_start_decompress jStrtDecompress -#define jpeg_read_scanlines jReadScanlines -#define jpeg_finish_decompress jFinDecompress -#define jpeg_read_raw_data jReadRawData -#define jpeg_has_multiple_scans jHasMultScn -#define jpeg_start_output jStrtOutput -#define jpeg_finish_output jFinOutput -#define jpeg_input_complete jInComplete -#define jpeg_new_colormap jNewCMap -#define jpeg_consume_input jConsumeInput -#define jpeg_calc_output_dimensions jCalcDimensions -#define jpeg_save_markers jSaveMarkers -#define jpeg_set_marker_processor jSetMarker -#define jpeg_read_coefficients jReadCoefs -#define jpeg_write_coefficients jWrtCoefs -#define jpeg_copy_critical_parameters jCopyCrit -#define jpeg_abort_compress jAbrtCompress -#define jpeg_abort_decompress jAbrtDecompress -#define jpeg_abort jAbort -#define jpeg_destroy jDestroy -#define jpeg_resync_to_restart jResyncRestart -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - - -/* Default error-management setup */ -EXTERN(struct jpeg_error_mgr *) jpeg_std_error - JPP((struct jpeg_error_mgr * err)); - -/* Initialization of JPEG compression objects. - * jpeg_create_compress() and jpeg_create_decompress() are the exported - * names that applications should call. These expand to calls on - * jpeg_CreateCompress and jpeg_CreateDecompress with additional information - * passed for version mismatch checking. - * NB: you must set up the error-manager BEFORE calling jpeg_create_xxx. - */ -#define jpeg_create_compress(cinfo) \ - jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, \ - (size_t) sizeof(struct jpeg_compress_struct)) -#define jpeg_create_decompress(cinfo) \ - jpeg_CreateDecompress((cinfo), JPEG_LIB_VERSION, \ - (size_t) sizeof(struct jpeg_decompress_struct)) -EXTERN(void) jpeg_CreateCompress JPP((j_compress_ptr cinfo, - int version, size_t structsize)); -EXTERN(void) jpeg_CreateDecompress JPP((j_decompress_ptr cinfo, - int version, size_t structsize)); -/* Destruction of JPEG compression objects */ -EXTERN(void) jpeg_destroy_compress JPP((j_compress_ptr cinfo)); -EXTERN(void) jpeg_destroy_decompress JPP((j_decompress_ptr cinfo)); - -/* Standard data source and destination managers: stdio streams. */ -/* Caller is responsible for opening the file before and closing after. */ -EXTERN(void) jpeg_stdio_dest JPP((j_compress_ptr cinfo, FILE * outfile)); -EXTERN(void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FILE * infile)); - -/* Default parameter setup for compression */ -EXTERN(void) jpeg_set_defaults JPP((j_compress_ptr cinfo)); -/* Compression parameter setup aids */ -EXTERN(void) jpeg_set_colorspace JPP((j_compress_ptr cinfo, - J_COLOR_SPACE colorspace)); -EXTERN(void) jpeg_default_colorspace JPP((j_compress_ptr cinfo)); -EXTERN(void) jpeg_set_quality JPP((j_compress_ptr cinfo, int quality, - boolean force_baseline)); -EXTERN(void) jpeg_set_linear_quality JPP((j_compress_ptr cinfo, - int scale_factor, - boolean force_baseline)); -EXTERN(void) jpeg_add_quant_table JPP((j_compress_ptr cinfo, int which_tbl, - const unsigned int *basic_table, - int scale_factor, - boolean force_baseline)); -EXTERN(int) jpeg_quality_scaling JPP((int quality)); -EXTERN(void) jpeg_simple_progression JPP((j_compress_ptr cinfo)); -EXTERN(void) jpeg_suppress_tables JPP((j_compress_ptr cinfo, - boolean suppress)); -EXTERN(JQUANT_TBL *) jpeg_alloc_quant_table JPP((j_common_ptr cinfo)); -EXTERN(JHUFF_TBL *) jpeg_alloc_huff_table JPP((j_common_ptr cinfo)); - -/* Main entry points for compression */ -EXTERN(void) jpeg_start_compress JPP((j_compress_ptr cinfo, - boolean write_all_tables)); -EXTERN(JDIMENSION) jpeg_write_scanlines JPP((j_compress_ptr cinfo, - JSAMPARRAY scanlines, - JDIMENSION num_lines)); -EXTERN(void) jpeg_finish_compress JPP((j_compress_ptr cinfo)); - -/* Replaces jpeg_write_scanlines when writing raw downsampled data. */ -EXTERN(JDIMENSION) jpeg_write_raw_data JPP((j_compress_ptr cinfo, - JSAMPIMAGE data, - JDIMENSION num_lines)); - -/* Write a special marker. See libjpeg.doc concerning safe usage. */ -EXTERN(void) jpeg_write_marker - JPP((j_compress_ptr cinfo, int marker, - const JOCTET * dataptr, unsigned int datalen)); -/* Same, but piecemeal. */ -EXTERN(void) jpeg_write_m_header - JPP((j_compress_ptr cinfo, int marker, unsigned int datalen)); -EXTERN(void) jpeg_write_m_byte - JPP((j_compress_ptr cinfo, int val)); - -/* Alternate compression function: just write an abbreviated table file */ -EXTERN(void) jpeg_write_tables JPP((j_compress_ptr cinfo)); - -/* Decompression startup: read start of JPEG datastream to see what's there */ -EXTERN(int) jpeg_read_header JPP((j_decompress_ptr cinfo, - boolean require_image)); -/* Return value is one of: */ -#define JPEG_SUSPENDED 0 /* Suspended due to lack of input data */ -#define JPEG_HEADER_OK 1 /* Found valid image datastream */ -#define JPEG_HEADER_TABLES_ONLY 2 /* Found valid table-specs-only datastream */ -/* If you pass require_image = TRUE (normal case), you need not check for - * a TABLES_ONLY return code; an abbreviated file will cause an error exit. - * JPEG_SUSPENDED is only possible if you use a data source module that can - * give a suspension return (the stdio source module doesn't). - */ - -/* Main entry points for decompression */ -EXTERN(boolean) jpeg_start_decompress JPP((j_decompress_ptr cinfo)); -EXTERN(JDIMENSION) jpeg_read_scanlines JPP((j_decompress_ptr cinfo, - JSAMPARRAY scanlines, - JDIMENSION max_lines)); -EXTERN(boolean) jpeg_finish_decompress JPP((j_decompress_ptr cinfo)); - -/* Replaces jpeg_read_scanlines when reading raw downsampled data. */ -EXTERN(JDIMENSION) jpeg_read_raw_data JPP((j_decompress_ptr cinfo, - JSAMPIMAGE data, - JDIMENSION max_lines)); - -/* Additional entry points for buffered-image mode. */ -EXTERN(boolean) jpeg_has_multiple_scans JPP((j_decompress_ptr cinfo)); -EXTERN(boolean) jpeg_start_output JPP((j_decompress_ptr cinfo, - int scan_number)); -EXTERN(boolean) jpeg_finish_output JPP((j_decompress_ptr cinfo)); -EXTERN(boolean) jpeg_input_complete JPP((j_decompress_ptr cinfo)); -EXTERN(void) jpeg_new_colormap JPP((j_decompress_ptr cinfo)); -EXTERN(int) jpeg_consume_input JPP((j_decompress_ptr cinfo)); -/* Return value is one of: */ -/* #define JPEG_SUSPENDED 0 Suspended due to lack of input data */ -#define JPEG_REACHED_SOS 1 /* Reached start of new scan */ -#define JPEG_REACHED_EOI 2 /* Reached end of image */ -#define JPEG_ROW_COMPLETED 3 /* Completed one iMCU row */ -#define JPEG_SCAN_COMPLETED 4 /* Completed last iMCU row of a scan */ - -/* Precalculate output dimensions for current decompression parameters. */ -EXTERN(void) jpeg_calc_output_dimensions JPP((j_decompress_ptr cinfo)); - -/* Control saving of COM and APPn markers into marker_list. */ -EXTERN(void) jpeg_save_markers - JPP((j_decompress_ptr cinfo, int marker_code, - unsigned int length_limit)); - -/* Install a special processing method for COM or APPn markers. */ -EXTERN(void) jpeg_set_marker_processor - JPP((j_decompress_ptr cinfo, int marker_code, - jpeg_marker_parser_method routine)); - -/* Read or write raw DCT coefficients --- useful for lossless transcoding. */ -EXTERN(jvirt_barray_ptr *) jpeg_read_coefficients JPP((j_decompress_ptr cinfo)); -EXTERN(void) jpeg_write_coefficients JPP((j_compress_ptr cinfo, - jvirt_barray_ptr * coef_arrays)); -EXTERN(void) jpeg_copy_critical_parameters JPP((j_decompress_ptr srcinfo, - j_compress_ptr dstinfo)); - -/* If you choose to abort compression or decompression before completing - * jpeg_finish_(de)compress, then you need to clean up to release memory, - * temporary files, etc. You can just call jpeg_destroy_(de)compress - * if you're done with the JPEG object, but if you want to clean it up and - * reuse it, call this: - */ -EXTERN(void) jpeg_abort_compress JPP((j_compress_ptr cinfo)); -EXTERN(void) jpeg_abort_decompress JPP((j_decompress_ptr cinfo)); - -/* Generic versions of jpeg_abort and jpeg_destroy that work on either - * flavor of JPEG object. These may be more convenient in some places. - */ -EXTERN(void) jpeg_abort JPP((j_common_ptr cinfo)); -EXTERN(void) jpeg_destroy JPP((j_common_ptr cinfo)); - -/* Default restart-marker-resync procedure for use by data source modules */ -EXTERN(boolean) jpeg_resync_to_restart JPP((j_decompress_ptr cinfo, - int desired)); - - -/* These marker codes are exported since applications and data source modules - * are likely to want to use them. - */ - -#define JPEG_RST0 0xD0 /* RST0 marker code */ -#define JPEG_EOI 0xD9 /* EOI marker code */ -#define JPEG_APP0 0xE0 /* APP0 marker code */ -#define JPEG_COM 0xFE /* COM marker code */ - - -/* If we have a brain-damaged compiler that emits warnings (or worse, errors) - * for structure definitions that are never filled in, keep it quiet by - * supplying dummy definitions for the various substructures. - */ - -#ifdef INCOMPLETE_TYPES_BROKEN -#ifndef JPEG_INTERNALS /* will be defined in jpegint.h */ -struct jvirt_sarray_control { long dummy; }; -struct jvirt_barray_control { long dummy; }; -struct jpeg_comp_master { long dummy; }; -struct jpeg_c_main_controller { long dummy; }; -struct jpeg_c_prep_controller { long dummy; }; -struct jpeg_c_coef_controller { long dummy; }; -struct jpeg_marker_writer { long dummy; }; -struct jpeg_color_converter { long dummy; }; -struct jpeg_downsampler { long dummy; }; -struct jpeg_forward_dct { long dummy; }; -struct jpeg_entropy_encoder { long dummy; }; -struct jpeg_decomp_master { long dummy; }; -struct jpeg_d_main_controller { long dummy; }; -struct jpeg_d_coef_controller { long dummy; }; -struct jpeg_d_post_controller { long dummy; }; -struct jpeg_input_controller { long dummy; }; -struct jpeg_marker_reader { long dummy; }; -struct jpeg_entropy_decoder { long dummy; }; -struct jpeg_inverse_dct { long dummy; }; -struct jpeg_upsampler { long dummy; }; -struct jpeg_color_deconverter { long dummy; }; -struct jpeg_color_quantizer { long dummy; }; -#endif /* JPEG_INTERNALS */ -#endif /* INCOMPLETE_TYPES_BROKEN */ - - -/* - * The JPEG library modules define JPEG_INTERNALS before including this file. - * The internal structure declarations are read only when that is true. - * Applications using the library should not include jpegint.h, but may wish - * to include jerror.h. - */ - -#ifdef JPEG_INTERNALS -#include "jpegint.h" /* fetch private declarations */ -#include "jerror.h" /* fetch error codes too */ -#endif - -#endif /* JPEGLIB_H */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jpegtran.1 b/irrlicht-1.6/source/Irrlicht/jpeglib/jpegtran.1 deleted file mode 100644 index ba3c2b3a8..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jpegtran.1 +++ /dev/null @@ -1,238 +0,0 @@ -.TH JPEGTRAN 1 "3 August 1997" -.SH NAME -jpegtran \- lossless transformation of JPEG files -.SH SYNOPSIS -.B jpegtran -[ -.I options -] -[ -.I filename -] -.LP -.SH DESCRIPTION -.LP -.B jpegtran -performs various useful transformations of JPEG files. -It can translate the coded representation from one variant of JPEG to another, -for example from baseline JPEG to progressive JPEG or vice versa. It can also -perform some rearrangements of the image data, for example turning an image -from landscape to portrait format by rotation. -.PP -.B jpegtran -works by rearranging the compressed data (DCT coefficients), without -ever fully decoding the image. Therefore, its transformations are lossless: -there is no image degradation at all, which would not be true if you used -.B djpeg -followed by -.B cjpeg -to accomplish the same conversion. But by the same token, -.B jpegtran -cannot perform lossy operations such as changing the image quality. -.PP -.B jpegtran -reads the named JPEG/JFIF file, or the standard input if no file is -named, and produces a JPEG/JFIF file on the standard output. -.SH OPTIONS -All switch names may be abbreviated; for example, -.B \-optimize -may be written -.B \-opt -or -.BR \-o . -Upper and lower case are equivalent. -British spellings are also accepted (e.g., -.BR \-optimise ), -though for brevity these are not mentioned below. -.PP -To specify the coded JPEG representation used in the output file, -.B jpegtran -accepts a subset of the switches recognized by -.BR cjpeg : -.TP -.B \-optimize -Perform optimization of entropy encoding parameters. -.TP -.B \-progressive -Create progressive JPEG file. -.TP -.BI \-restart " N" -Emit a JPEG restart marker every N MCU rows, or every N MCU blocks if "B" is -attached to the number. -.TP -.BI \-scans " file" -Use the scan script given in the specified text file. -.PP -See -.BR cjpeg (1) -for more details about these switches. -If you specify none of these switches, you get a plain baseline-JPEG output -file. The quality setting and so forth are determined by the input file. -.PP -The image can be losslessly transformed by giving one of these switches: -.TP -.B \-flip horizontal -Mirror image horizontally (left-right). -.TP -.B \-flip vertical -Mirror image vertically (top-bottom). -.TP -.B \-rotate 90 -Rotate image 90 degrees clockwise. -.TP -.B \-rotate 180 -Rotate image 180 degrees. -.TP -.B \-rotate 270 -Rotate image 270 degrees clockwise (or 90 ccw). -.TP -.B \-transpose -Transpose image (across UL-to-LR axis). -.TP -.B \-transverse -Transverse transpose (across UR-to-LL axis). -.PP -The transpose transformation has no restrictions regarding image dimensions. -The other transformations operate rather oddly if the image dimensions are not -a multiple of the iMCU size (usually 8 or 16 pixels), because they can only -transform complete blocks of DCT coefficient data in the desired way. -.PP -.BR jpegtran 's -default behavior when transforming an odd-size image is designed -to preserve exact reversibility and mathematical consistency of the -transformation set. As stated, transpose is able to flip the entire image -area. Horizontal mirroring leaves any partial iMCU column at the right edge -untouched, but is able to flip all rows of the image. Similarly, vertical -mirroring leaves any partial iMCU row at the bottom edge untouched, but is -able to flip all columns. The other transforms can be built up as sequences -of transpose and flip operations; for consistency, their actions on edge -pixels are defined to be the same as the end result of the corresponding -transpose-and-flip sequence. -.PP -For practical use, you may prefer to discard any untransformable edge pixels -rather than having a strange-looking strip along the right and/or bottom edges -of a transformed image. To do this, add the -.B \-trim -switch: -.TP -.B \-trim -Drop non-transformable edge blocks. -.PP -Obviously, a transformation with -.B \-trim -is not reversible, so strictly speaking -.B jpegtran -with this switch is not lossless. Also, the expected mathematical -equivalences between the transformations no longer hold. For example, -.B \-rot 270 -trim -trims only the bottom edge, but -.B \-rot 90 -trim -followed by -.B \-rot 180 -trim -trims both edges. -.PP -Another not-strictly-lossless transformation switch is: -.TP -.B \-grayscale -Force grayscale output. -.PP -This option discards the chrominance channels if the input image is YCbCr -(ie, a standard color JPEG), resulting in a grayscale JPEG file. The -luminance channel is preserved exactly, so this is a better method of reducing -to grayscale than decompression, conversion, and recompression. This switch -is particularly handy for fixing a monochrome picture that was mistakenly -encoded as a color JPEG. (In such a case, the space savings from getting rid -of the near-empty chroma channels won't be large; but the decoding time for -a grayscale JPEG is substantially less than that for a color JPEG.) -.PP -.B jpegtran -also recognizes these switches that control what to do with "extra" markers, -such as comment blocks: -.TP -.B \-copy none -Copy no extra markers from source file. This setting suppresses all -comments and other excess baggage present in the source file. -.TP -.B \-copy comments -Copy only comment markers. This setting copies comments from the source file, -but discards any other inessential data. -.TP -.B \-copy all -Copy all extra markers. This setting preserves miscellaneous markers -found in the source file, such as JFIF thumbnails and Photoshop settings. -In some files these extra markers can be sizable. -.PP -The default behavior is -.BR "\-copy comments" . -(Note: in IJG releases v6 and v6a, -.B jpegtran -always did the equivalent of -.BR "\-copy none" .) -.PP -Additional switches recognized by jpegtran are: -.TP -.BI \-maxmemory " N" -Set limit for amount of memory to use in processing large images. Value is -in thousands of bytes, or millions of bytes if "M" is attached to the -number. For example, -.B \-max 4m -selects 4000000 bytes. If more space is needed, temporary files will be used. -.TP -.BI \-outfile " name" -Send output image to the named file, not to standard output. -.TP -.B \-verbose -Enable debug printout. More -.BR \-v 's -give more output. Also, version information is printed at startup. -.TP -.B \-debug -Same as -.BR \-verbose . -.SH EXAMPLES -.LP -This example converts a baseline JPEG file to progressive form: -.IP -.B jpegtran \-progressive -.I foo.jpg -.B > -.I fooprog.jpg -.PP -This example rotates an image 90 degrees clockwise, discarding any -unrotatable edge pixels: -.IP -.B jpegtran \-rot 90 -trim -.I foo.jpg -.B > -.I foo90.jpg -.SH ENVIRONMENT -.TP -.B JPEGMEM -If this environment variable is set, its value is the default memory limit. -The value is specified as described for the -.B \-maxmemory -switch. -.B JPEGMEM -overrides the default value specified when the program was compiled, and -itself is overridden by an explicit -.BR \-maxmemory . -.SH SEE ALSO -.BR cjpeg (1), -.BR djpeg (1), -.BR rdjpgcom (1), -.BR wrjpgcom (1) -.br -Wallace, Gregory K. "The JPEG Still Picture Compression Standard", -Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44. -.SH AUTHOR -Independent JPEG Group -.SH BUGS -Arithmetic coding is not supported for legal reasons. -.PP -The transform options can't transform odd-size images perfectly. Use -.B \-trim -if you don't like the results without it. -.PP -The entire image is read into memory and then written out again, even in -cases where this isn't really necessary. Expect swapping on large images, -especially when using the more complex transform options. diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jpegtran.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jpegtran.c deleted file mode 100644 index 719aaa739..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jpegtran.c +++ /dev/null @@ -1,504 +0,0 @@ -/* - * jpegtran.c - * - * Copyright (C) 1995-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a command-line user interface for JPEG transcoding. - * It is very similar to cjpeg.c, but provides lossless transcoding between - * different JPEG file formats. It also provides some lossless and sort-of- - * lossless transformations of JPEG data. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ -#include "transupp.h" /* Support routines for jpegtran */ -#include "jversion.h" /* for version message */ - -#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ -#ifdef __MWERKS__ -#include <SIOUX.h> /* Metrowerks needs this */ -#include <console.h> /* ... and this */ -#endif -#ifdef THINK_C -#include <console.h> /* Think declares it here */ -#endif -#endif - - -/* - * Argument-parsing code. - * The switch parser is designed to be useful with DOS-style command line - * syntax, ie, intermixed switches and file names, where only the switches - * to the left of a given file name affect processing of that file. - * The main program in this file doesn't actually use this capability... - */ - - -static const char * progname; /* program name for error messages */ -static char * outfilename; /* for -outfile switch */ -static JCOPY_OPTION copyoption; /* -copy switch */ -static jpeg_transform_info transformoption; /* image transformation options */ - - -LOCAL(void) -usage (void) -/* complain about bad command line */ -{ - fprintf(stderr, "usage: %s [switches] ", progname); -#ifdef TWO_FILE_COMMANDLINE - fprintf(stderr, "inputfile outputfile\n"); -#else - fprintf(stderr, "[inputfile]\n"); -#endif - - fprintf(stderr, "Switches (names may be abbreviated):\n"); - fprintf(stderr, " -copy none Copy no extra markers from source file\n"); - fprintf(stderr, " -copy comments Copy only comment markers (default)\n"); - fprintf(stderr, " -copy all Copy all extra markers\n"); -#ifdef ENTROPY_OPT_SUPPORTED - fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but slow compression)\n"); -#endif -#ifdef C_PROGRESSIVE_SUPPORTED - fprintf(stderr, " -progressive Create progressive JPEG file\n"); -#endif -#if TRANSFORMS_SUPPORTED - fprintf(stderr, "Switches for modifying the image:\n"); - fprintf(stderr, " -grayscale Reduce to grayscale (omit color data)\n"); - fprintf(stderr, " -flip [horizontal|vertical] Mirror image (left-right or top-bottom)\n"); - fprintf(stderr, " -rotate [90|180|270] Rotate image (degrees clockwise)\n"); - fprintf(stderr, " -transpose Transpose image\n"); - fprintf(stderr, " -transverse Transverse transpose image\n"); - fprintf(stderr, " -trim Drop non-transformable edge blocks\n"); -#endif /* TRANSFORMS_SUPPORTED */ - fprintf(stderr, "Switches for advanced users:\n"); - fprintf(stderr, " -restart N Set restart interval in rows, or in blocks with B\n"); - fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n"); - fprintf(stderr, " -outfile name Specify name for output file\n"); - fprintf(stderr, " -verbose or -debug Emit debug output\n"); - fprintf(stderr, "Switches for wizards:\n"); -#ifdef C_ARITH_CODING_SUPPORTED - fprintf(stderr, " -arithmetic Use arithmetic coding\n"); -#endif -#ifdef C_MULTISCAN_FILES_SUPPORTED - fprintf(stderr, " -scans file Create multi-scan JPEG per script file\n"); -#endif - exit(EXIT_FAILURE); -} - - -LOCAL(void) -select_transform (JXFORM_CODE transform) -/* Silly little routine to detect multiple transform options, - * which we can't handle. - */ -{ -#if TRANSFORMS_SUPPORTED - if (transformoption.transform == JXFORM_NONE || - transformoption.transform == transform) { - transformoption.transform = transform; - } else { - fprintf(stderr, "%s: can only do one image transformation at a time\n", - progname); - usage(); - } -#else - fprintf(stderr, "%s: sorry, image transformation was not compiled\n", - progname); - exit(EXIT_FAILURE); -#endif -} - - -LOCAL(int) -parse_switches (j_compress_ptr cinfo, int argc, char **argv, - int last_file_arg_seen, boolean for_real) -/* Parse optional switches. - * Returns argv[] index of first file-name argument (== argc if none). - * Any file names with indexes <= last_file_arg_seen are ignored; - * they have presumably been processed in a previous iteration. - * (Pass 0 for last_file_arg_seen on the first or only iteration.) - * for_real is FALSE on the first (dummy) pass; we may skip any expensive - * processing. - */ -{ - int argn; - char * arg; - boolean simple_progressive; - char * scansarg = NULL; /* saves -scans parm if any */ - - /* Set up default JPEG parameters. */ - simple_progressive = FALSE; - outfilename = NULL; - copyoption = JCOPYOPT_DEFAULT; - transformoption.transform = JXFORM_NONE; - transformoption.trim = FALSE; - transformoption.force_grayscale = FALSE; - cinfo->err->trace_level = 0; - - /* Scan command line options, adjust parameters */ - - for (argn = 1; argn < argc; argn++) { - arg = argv[argn]; - if (*arg != '-') { - /* Not a switch, must be a file name argument */ - if (argn <= last_file_arg_seen) { - outfilename = NULL; /* -outfile applies to just one input file */ - continue; /* ignore this name if previously processed */ - } - break; /* else done parsing switches */ - } - arg++; /* advance past switch marker character */ - - if (keymatch(arg, "arithmetic", 1)) { - /* Use arithmetic coding. */ -#ifdef C_ARITH_CODING_SUPPORTED - cinfo->arith_code = TRUE; -#else - fprintf(stderr, "%s: sorry, arithmetic coding not supported\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "copy", 1)) { - /* Select which extra markers to copy. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (keymatch(argv[argn], "none", 1)) { - copyoption = JCOPYOPT_NONE; - } else if (keymatch(argv[argn], "comments", 1)) { - copyoption = JCOPYOPT_COMMENTS; - } else if (keymatch(argv[argn], "all", 1)) { - copyoption = JCOPYOPT_ALL; - } else - usage(); - - } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) { - /* Enable debug printouts. */ - /* On first -d, print version identification */ - static boolean printed_version = FALSE; - - if (! printed_version) { - fprintf(stderr, "Independent JPEG Group's JPEGTRAN, version %s\n%s\n", - JVERSION, JCOPYRIGHT); - printed_version = TRUE; - } - cinfo->err->trace_level++; - - } else if (keymatch(arg, "flip", 1)) { - /* Mirror left-right or top-bottom. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (keymatch(argv[argn], "horizontal", 1)) - select_transform(JXFORM_FLIP_H); - else if (keymatch(argv[argn], "vertical", 1)) - select_transform(JXFORM_FLIP_V); - else - usage(); - - } else if (keymatch(arg, "grayscale", 1) || keymatch(arg, "greyscale",1)) { - /* Force to grayscale. */ -#if TRANSFORMS_SUPPORTED - transformoption.force_grayscale = TRUE; -#else - select_transform(JXFORM_NONE); /* force an error */ -#endif - - } else if (keymatch(arg, "maxmemory", 3)) { - /* Maximum memory in Kb (or Mb with 'm'). */ - long lval; - char ch = 'x'; - - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) - usage(); - if (ch == 'm' || ch == 'M') - lval *= 1000L; - cinfo->mem->max_memory_to_use = lval * 1000L; - - } else if (keymatch(arg, "optimize", 1) || keymatch(arg, "optimise", 1)) { - /* Enable entropy parm optimization. */ -#ifdef ENTROPY_OPT_SUPPORTED - cinfo->optimize_coding = TRUE; -#else - fprintf(stderr, "%s: sorry, entropy optimization was not compiled\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "outfile", 4)) { - /* Set output file name. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - outfilename = argv[argn]; /* save it away for later use */ - - } else if (keymatch(arg, "progressive", 1)) { - /* Select simple progressive mode. */ -#ifdef C_PROGRESSIVE_SUPPORTED - simple_progressive = TRUE; - /* We must postpone execution until num_components is known. */ -#else - fprintf(stderr, "%s: sorry, progressive output was not compiled\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "restart", 1)) { - /* Restart interval in MCU rows (or in MCUs with 'b'). */ - long lval; - char ch = 'x'; - - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) - usage(); - if (lval < 0 || lval > 65535L) - usage(); - if (ch == 'b' || ch == 'B') { - cinfo->restart_interval = (unsigned int) lval; - cinfo->restart_in_rows = 0; /* else prior '-restart n' overrides me */ - } else { - cinfo->restart_in_rows = (int) lval; - /* restart_interval will be computed during startup */ - } - - } else if (keymatch(arg, "rotate", 2)) { - /* Rotate 90, 180, or 270 degrees (measured clockwise). */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (keymatch(argv[argn], "90", 2)) - select_transform(JXFORM_ROT_90); - else if (keymatch(argv[argn], "180", 3)) - select_transform(JXFORM_ROT_180); - else if (keymatch(argv[argn], "270", 3)) - select_transform(JXFORM_ROT_270); - else - usage(); - - } else if (keymatch(arg, "scans", 1)) { - /* Set scan script. */ -#ifdef C_MULTISCAN_FILES_SUPPORTED - if (++argn >= argc) /* advance to next argument */ - usage(); - scansarg = argv[argn]; - /* We must postpone reading the file in case -progressive appears. */ -#else - fprintf(stderr, "%s: sorry, multi-scan output was not compiled\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "transpose", 1)) { - /* Transpose (across UL-to-LR axis). */ - select_transform(JXFORM_TRANSPOSE); - - } else if (keymatch(arg, "transverse", 6)) { - /* Transverse transpose (across UR-to-LL axis). */ - select_transform(JXFORM_TRANSVERSE); - - } else if (keymatch(arg, "trim", 3)) { - /* Trim off any partial edge MCUs that the transform can't handle. */ - transformoption.trim = TRUE; - - } else { - usage(); /* bogus switch */ - } - } - - /* Post-switch-scanning cleanup */ - - if (for_real) { - -#ifdef C_PROGRESSIVE_SUPPORTED - if (simple_progressive) /* process -progressive; -scans can override */ - jpeg_simple_progression(cinfo); -#endif - -#ifdef C_MULTISCAN_FILES_SUPPORTED - if (scansarg != NULL) /* process -scans if it was present */ - if (! read_scan_script(cinfo, scansarg)) - usage(); -#endif - } - - return argn; /* return index of next arg (file name) */ -} - - -/* - * The main program. - */ - -int -main (int argc, char **argv) -{ - struct jpeg_decompress_struct srcinfo; - struct jpeg_compress_struct dstinfo; - struct jpeg_error_mgr jsrcerr, jdsterr; -#ifdef PROGRESS_REPORT - struct cdjpeg_progress_mgr progress; -#endif - jvirt_barray_ptr * src_coef_arrays; - jvirt_barray_ptr * dst_coef_arrays; - int file_index; - FILE * input_file; - FILE * output_file; - - /* On Mac, fetch a command line. */ -#ifdef USE_CCOMMAND - argc = ccommand(&argv); -#endif - - progname = argv[0]; - if (progname == NULL || progname[0] == 0) - progname = "jpegtran"; /* in case C library doesn't provide it */ - - /* Initialize the JPEG decompression object with default error handling. */ - srcinfo.err = jpeg_std_error(&jsrcerr); - jpeg_create_decompress(&srcinfo); - /* Initialize the JPEG compression object with default error handling. */ - dstinfo.err = jpeg_std_error(&jdsterr); - jpeg_create_compress(&dstinfo); - - /* Now safe to enable signal catcher. - * Note: we assume only the decompression object will have virtual arrays. - */ -#ifdef NEED_SIGNAL_CATCHER - enable_signal_catcher((j_common_ptr) &srcinfo); -#endif - - /* Scan command line to find file names. - * It is convenient to use just one switch-parsing routine, but the switch - * values read here are mostly ignored; we will rescan the switches after - * opening the input file. Also note that most of the switches affect the - * destination JPEG object, so we parse into that and then copy over what - * needs to affects the source too. - */ - - file_index = parse_switches(&dstinfo, argc, argv, 0, FALSE); - jsrcerr.trace_level = jdsterr.trace_level; - srcinfo.mem->max_memory_to_use = dstinfo.mem->max_memory_to_use; - -#ifdef TWO_FILE_COMMANDLINE - /* Must have either -outfile switch or explicit output file name */ - if (outfilename == NULL) { - if (file_index != argc-2) { - fprintf(stderr, "%s: must name one input and one output file\n", - progname); - usage(); - } - outfilename = argv[file_index+1]; - } else { - if (file_index != argc-1) { - fprintf(stderr, "%s: must name one input and one output file\n", - progname); - usage(); - } - } -#else - /* Unix style: expect zero or one file name */ - if (file_index < argc-1) { - fprintf(stderr, "%s: only one input file\n", progname); - usage(); - } -#endif /* TWO_FILE_COMMANDLINE */ - - /* Open the input file. */ - if (file_index < argc) { - if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, argv[file_index]); - exit(EXIT_FAILURE); - } - } else { - /* default input file is stdin */ - input_file = read_stdin(); - } - - /* Open the output file. */ - if (outfilename != NULL) { - if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, outfilename); - exit(EXIT_FAILURE); - } - } else { - /* default output file is stdout */ - output_file = write_stdout(); - } - -#ifdef PROGRESS_REPORT - start_progress_monitor((j_common_ptr) &dstinfo, &progress); -#endif - - /* Specify data source for decompression */ - jpeg_stdio_src(&srcinfo, input_file); - - /* Enable saving of extra markers that we want to copy */ - jcopy_markers_setup(&srcinfo, copyoption); - - /* Read file header */ - (void) jpeg_read_header(&srcinfo, TRUE); - - /* Any space needed by a transform option must be requested before - * jpeg_read_coefficients so that memory allocation will be done right. - */ -#if TRANSFORMS_SUPPORTED - jtransform_request_workspace(&srcinfo, &transformoption); -#endif - - /* Read source file as DCT coefficients */ - src_coef_arrays = jpeg_read_coefficients(&srcinfo); - - /* Initialize destination compression parameters from source values */ - jpeg_copy_critical_parameters(&srcinfo, &dstinfo); - - /* Adjust destination parameters if required by transform options; - * also find out which set of coefficient arrays will hold the output. - */ -#if TRANSFORMS_SUPPORTED - dst_coef_arrays = jtransform_adjust_parameters(&srcinfo, &dstinfo, - src_coef_arrays, - &transformoption); -#else - dst_coef_arrays = src_coef_arrays; -#endif - - /* Adjust default compression parameters by re-parsing the options */ - file_index = parse_switches(&dstinfo, argc, argv, 0, TRUE); - - /* Specify data destination for compression */ - jpeg_stdio_dest(&dstinfo, output_file); - - /* Start compressor (note no image data is actually written here) */ - jpeg_write_coefficients(&dstinfo, dst_coef_arrays); - - /* Copy to the output file any extra markers that we want to preserve */ - jcopy_markers_execute(&srcinfo, &dstinfo, copyoption); - - /* Execute image transformation, if any */ -#if TRANSFORMS_SUPPORTED - jtransform_execute_transformation(&srcinfo, &dstinfo, - src_coef_arrays, - &transformoption); -#endif - - /* Finish compression and release memory */ - jpeg_finish_compress(&dstinfo); - jpeg_destroy_compress(&dstinfo); - (void) jpeg_finish_decompress(&srcinfo); - jpeg_destroy_decompress(&srcinfo); - - /* Close files, if we opened them */ - if (input_file != stdin) - fclose(input_file); - if (output_file != stdout) - fclose(output_file); - -#ifdef PROGRESS_REPORT - end_progress_monitor((j_common_ptr) &dstinfo); -#endif - - /* All done. */ - exit(jsrcerr.num_warnings + jdsterr.num_warnings ?EXIT_WARNING:EXIT_SUCCESS); - return 0; /* suppress no-return-value warnings */ -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jquant1.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jquant1.c deleted file mode 100644 index aaa34a189..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jquant1.c +++ /dev/null @@ -1,856 +0,0 @@ -/* - * jquant1.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains 1-pass color quantization (color mapping) routines. - * These routines provide mapping to a fixed color map using equally spaced - * color values. Optional Floyd-Steinberg or ordered dithering is available. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - -#ifdef QUANT_1PASS_SUPPORTED - - -/* - * The main purpose of 1-pass quantization is to provide a fast, if not very - * high quality, colormapped output capability. A 2-pass quantizer usually - * gives better visual quality; however, for quantized grayscale output this - * quantizer is perfectly adequate. Dithering is highly recommended with this - * quantizer, though you can turn it off if you really want to. - * - * In 1-pass quantization the colormap must be chosen in advance of seeing the - * image. We use a map consisting of all combinations of Ncolors[i] color - * values for the i'th component. The Ncolors[] values are chosen so that - * their product, the total number of colors, is no more than that requested. - * (In most cases, the product will be somewhat less.) - * - * Since the colormap is orthogonal, the representative value for each color - * component can be determined without considering the other components; - * then these indexes can be combined into a colormap index by a standard - * N-dimensional-array-subscript calculation. Most of the arithmetic involved - * can be precalculated and stored in the lookup table colorindex[]. - * colorindex[i][j] maps pixel value j in component i to the nearest - * representative value (grid plane) for that component; this index is - * multiplied by the array stride for component i, so that the - * index of the colormap entry closest to a given pixel value is just - * sum( colorindex[component-number][pixel-component-value] ) - * Aside from being fast, this scheme allows for variable spacing between - * representative values with no additional lookup cost. - * - * If gamma correction has been applied in color conversion, it might be wise - * to adjust the color grid spacing so that the representative colors are - * equidistant in linear space. At this writing, gamma correction is not - * implemented by jdcolor, so nothing is done here. - */ - - -/* Declarations for ordered dithering. - * - * We use a standard 16x16 ordered dither array. The basic concept of ordered - * dithering is described in many references, for instance Dale Schumacher's - * chapter II.2 of Graphics Gems II (James Arvo, ed. Academic Press, 1991). - * In place of Schumacher's comparisons against a "threshold" value, we add a - * "dither" value to the input pixel and then round the result to the nearest - * output value. The dither value is equivalent to (0.5 - threshold) times - * the distance between output values. For ordered dithering, we assume that - * the output colors are equally spaced; if not, results will probably be - * worse, since the dither may be too much or too little at a given point. - * - * The normal calculation would be to form pixel value + dither, range-limit - * this to 0..MAXJSAMPLE, and then index into the colorindex table as usual. - * We can skip the separate range-limiting step by extending the colorindex - * table in both directions. - */ - -#define ODITHER_SIZE 16 /* dimension of dither matrix */ -/* NB: if ODITHER_SIZE is not a power of 2, ODITHER_MASK uses will break */ -#define ODITHER_CELLS (ODITHER_SIZE*ODITHER_SIZE) /* # cells in matrix */ -#define ODITHER_MASK (ODITHER_SIZE-1) /* mask for wrapping around counters */ - -typedef int ODITHER_MATRIX[ODITHER_SIZE][ODITHER_SIZE]; -typedef int (*ODITHER_MATRIX_PTR)[ODITHER_SIZE]; - -static const UINT8 base_dither_matrix[ODITHER_SIZE][ODITHER_SIZE] = { - /* Bayer's order-4 dither array. Generated by the code given in - * Stephen Hawley's article "Ordered Dithering" in Graphics Gems I. - * The values in this array must range from 0 to ODITHER_CELLS-1. - */ - { 0,192, 48,240, 12,204, 60,252, 3,195, 51,243, 15,207, 63,255 }, - { 128, 64,176,112,140, 76,188,124,131, 67,179,115,143, 79,191,127 }, - { 32,224, 16,208, 44,236, 28,220, 35,227, 19,211, 47,239, 31,223 }, - { 160, 96,144, 80,172,108,156, 92,163, 99,147, 83,175,111,159, 95 }, - { 8,200, 56,248, 4,196, 52,244, 11,203, 59,251, 7,199, 55,247 }, - { 136, 72,184,120,132, 68,180,116,139, 75,187,123,135, 71,183,119 }, - { 40,232, 24,216, 36,228, 20,212, 43,235, 27,219, 39,231, 23,215 }, - { 168,104,152, 88,164,100,148, 84,171,107,155, 91,167,103,151, 87 }, - { 2,194, 50,242, 14,206, 62,254, 1,193, 49,241, 13,205, 61,253 }, - { 130, 66,178,114,142, 78,190,126,129, 65,177,113,141, 77,189,125 }, - { 34,226, 18,210, 46,238, 30,222, 33,225, 17,209, 45,237, 29,221 }, - { 162, 98,146, 82,174,110,158, 94,161, 97,145, 81,173,109,157, 93 }, - { 10,202, 58,250, 6,198, 54,246, 9,201, 57,249, 5,197, 53,245 }, - { 138, 74,186,122,134, 70,182,118,137, 73,185,121,133, 69,181,117 }, - { 42,234, 26,218, 38,230, 22,214, 41,233, 25,217, 37,229, 21,213 }, - { 170,106,154, 90,166,102,150, 86,169,105,153, 89,165,101,149, 85 } -}; - - -/* Declarations for Floyd-Steinberg dithering. - * - * Errors are accumulated into the array fserrors[], at a resolution of - * 1/16th of a pixel count. The error at a given pixel is propagated - * to its not-yet-processed neighbors using the standard F-S fractions, - * ... (here) 7/16 - * 3/16 5/16 1/16 - * We work left-to-right on even rows, right-to-left on odd rows. - * - * We can get away with a single array (holding one row's worth of errors) - * by using it to store the current row's errors at pixel columns not yet - * processed, but the next row's errors at columns already processed. We - * need only a few extra variables to hold the errors immediately around the - * current column. (If we are lucky, those variables are in registers, but - * even if not, they're probably cheaper to access than array elements are.) - * - * The fserrors[] array is indexed [component#][position]. - * We provide (#columns + 2) entries per component; the extra entry at each - * end saves us from special-casing the first and last pixels. - * - * Note: on a wide image, we might not have enough room in a PC's near data - * segment to hold the error array; so it is allocated with alloc_large. - */ - -#if BITS_IN_JSAMPLE == 8 -typedef INT16 FSERROR; /* 16 bits should be enough */ -typedef int LOCFSERROR; /* use 'int' for calculation temps */ -#else -typedef INT32 FSERROR; /* may need more than 16 bits */ -typedef INT32 LOCFSERROR; /* be sure calculation temps are big enough */ -#endif - -typedef FSERROR FAR *FSERRPTR; /* pointer to error array (in FAR storage!) */ - - -/* Private subobject */ - -#define MAX_Q_COMPS 4 /* max components I can handle */ - -typedef struct { - struct jpeg_color_quantizer pub; /* public fields */ - - /* Initially allocated colormap is saved here */ - JSAMPARRAY sv_colormap; /* The color map as a 2-D pixel array */ - int sv_actual; /* number of entries in use */ - - JSAMPARRAY colorindex; /* Precomputed mapping for speed */ - /* colorindex[i][j] = index of color closest to pixel value j in component i, - * premultiplied as described above. Since colormap indexes must fit into - * JSAMPLEs, the entries of this array will too. - */ - boolean is_padded; /* is the colorindex padded for odither? */ - - int Ncolors[MAX_Q_COMPS]; /* # of values alloced to each component */ - - /* Variables for ordered dithering */ - int row_index; /* cur row's vertical index in dither matrix */ - ODITHER_MATRIX_PTR odither[MAX_Q_COMPS]; /* one dither array per component */ - - /* Variables for Floyd-Steinberg dithering */ - FSERRPTR fserrors[MAX_Q_COMPS]; /* accumulated errors */ - boolean on_odd_row; /* flag to remember which row we are on */ -} my_cquantizer; - -typedef my_cquantizer * my_cquantize_ptr; - - -/* - * Policy-making subroutines for create_colormap and create_colorindex. - * These routines determine the colormap to be used. The rest of the module - * only assumes that the colormap is orthogonal. - * - * * select_ncolors decides how to divvy up the available colors - * among the components. - * * output_value defines the set of representative values for a component. - * * largest_input_value defines the mapping from input values to - * representative values for a component. - * Note that the latter two routines may impose different policies for - * different components, though this is not currently done. - */ - - -LOCAL(int) -select_ncolors (j_decompress_ptr cinfo, int Ncolors[]) -/* Determine allocation of desired colors to components, */ -/* and fill in Ncolors[] array to indicate choice. */ -/* Return value is total number of colors (product of Ncolors[] values). */ -{ - int nc = cinfo->out_color_components; /* number of color components */ - int max_colors = cinfo->desired_number_of_colors; - int total_colors, iroot, i, j; - boolean changed; - long temp; - static const int RGB_order[3] = { RGB_GREEN, RGB_RED, RGB_BLUE }; - - /* We can allocate at least the nc'th root of max_colors per component. */ - /* Compute floor(nc'th root of max_colors). */ - iroot = 1; - do { - iroot++; - temp = iroot; /* set temp = iroot ** nc */ - for (i = 1; i < nc; i++) - temp *= iroot; - } while (temp <= (long) max_colors); /* repeat till iroot exceeds root */ - iroot--; /* now iroot = floor(root) */ - - /* Must have at least 2 color values per component */ - if (iroot < 2) - ERREXIT1(cinfo, JERR_QUANT_FEW_COLORS, (int) temp); - - /* Initialize to iroot color values for each component */ - total_colors = 1; - for (i = 0; i < nc; i++) { - Ncolors[i] = iroot; - total_colors *= iroot; - } - /* We may be able to increment the count for one or more components without - * exceeding max_colors, though we know not all can be incremented. - * Sometimes, the first component can be incremented more than once! - * (Example: for 16 colors, we start at 2*2*2, go to 3*2*2, then 4*2*2.) - * In RGB colorspace, try to increment G first, then R, then B. - */ - do { - changed = FALSE; - for (i = 0; i < nc; i++) { - j = (cinfo->out_color_space == JCS_RGB ? RGB_order[i] : i); - /* calculate new total_colors if Ncolors[j] is incremented */ - temp = total_colors / Ncolors[j]; - temp *= Ncolors[j]+1; /* done in long arith to avoid oflo */ - if (temp > (long) max_colors) - break; /* won't fit, done with this pass */ - Ncolors[j]++; /* OK, apply the increment */ - total_colors = (int) temp; - changed = TRUE; - } - } while (changed); - - return total_colors; -} - - -LOCAL(int) -output_value (j_decompress_ptr cinfo, int ci, int j, int maxj) -/* Return j'th output value, where j will range from 0 to maxj */ -/* The output values must fall in 0..MAXJSAMPLE in increasing order */ -{ - /* We always provide values 0 and MAXJSAMPLE for each component; - * any additional values are equally spaced between these limits. - * (Forcing the upper and lower values to the limits ensures that - * dithering can't produce a color outside the selected gamut.) - */ - return (int) (((INT32) j * MAXJSAMPLE + maxj/2) / maxj); -} - - -LOCAL(int) -largest_input_value (j_decompress_ptr cinfo, int ci, int j, int maxj) -/* Return largest input value that should map to j'th output value */ -/* Must have largest(j=0) >= 0, and largest(j=maxj) >= MAXJSAMPLE */ -{ - /* Breakpoints are halfway between values returned by output_value */ - return (int) (((INT32) (2*j + 1) * MAXJSAMPLE + maxj) / (2*maxj)); -} - - -/* - * Create the colormap. - */ - -LOCAL(void) -create_colormap (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - JSAMPARRAY colormap; /* Created colormap */ - int total_colors; /* Number of distinct output colors */ - int i,j,k, nci, blksize, blkdist, ptr, val; - - /* Select number of colors for each component */ - total_colors = select_ncolors(cinfo, cquantize->Ncolors); - - /* Report selected color counts */ - if (cinfo->out_color_components == 3) - TRACEMS4(cinfo, 1, JTRC_QUANT_3_NCOLORS, - total_colors, cquantize->Ncolors[0], - cquantize->Ncolors[1], cquantize->Ncolors[2]); - else - TRACEMS1(cinfo, 1, JTRC_QUANT_NCOLORS, total_colors); - - /* Allocate and fill in the colormap. */ - /* The colors are ordered in the map in standard row-major order, */ - /* i.e. rightmost (highest-indexed) color changes most rapidly. */ - - colormap = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) total_colors, (JDIMENSION) cinfo->out_color_components); - - /* blksize is number of adjacent repeated entries for a component */ - /* blkdist is distance between groups of identical entries for a component */ - blkdist = total_colors; - - for (i = 0; i < cinfo->out_color_components; i++) { - /* fill in colormap entries for i'th color component */ - nci = cquantize->Ncolors[i]; /* # of distinct values for this color */ - blksize = blkdist / nci; - for (j = 0; j < nci; j++) { - /* Compute j'th output value (out of nci) for component */ - val = output_value(cinfo, i, j, nci-1); - /* Fill in all colormap entries that have this value of this component */ - for (ptr = j * blksize; ptr < total_colors; ptr += blkdist) { - /* fill in blksize entries beginning at ptr */ - for (k = 0; k < blksize; k++) - colormap[i][ptr+k] = (JSAMPLE) val; - } - } - blkdist = blksize; /* blksize of this color is blkdist of next */ - } - - /* Save the colormap in private storage, - * where it will survive color quantization mode changes. - */ - cquantize->sv_colormap = colormap; - cquantize->sv_actual = total_colors; -} - - -/* - * Create the color index table. - */ - -LOCAL(void) -create_colorindex (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - JSAMPROW indexptr; - int i,j,k, nci, blksize, val, pad; - - /* For ordered dither, we pad the color index tables by MAXJSAMPLE in - * each direction (input index values can be -MAXJSAMPLE .. 2*MAXJSAMPLE). - * This is not necessary in the other dithering modes. However, we - * flag whether it was done in case user changes dithering mode. - */ - if (cinfo->dither_mode == JDITHER_ORDERED) { - pad = MAXJSAMPLE*2; - cquantize->is_padded = TRUE; - } else { - pad = 0; - cquantize->is_padded = FALSE; - } - - cquantize->colorindex = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) (MAXJSAMPLE+1 + pad), - (JDIMENSION) cinfo->out_color_components); - - /* blksize is number of adjacent repeated entries for a component */ - blksize = cquantize->sv_actual; - - for (i = 0; i < cinfo->out_color_components; i++) { - /* fill in colorindex entries for i'th color component */ - nci = cquantize->Ncolors[i]; /* # of distinct values for this color */ - blksize = blksize / nci; - - /* adjust colorindex pointers to provide padding at negative indexes. */ - if (pad) - cquantize->colorindex[i] += MAXJSAMPLE; - - /* in loop, val = index of current output value, */ - /* and k = largest j that maps to current val */ - indexptr = cquantize->colorindex[i]; - val = 0; - k = largest_input_value(cinfo, i, 0, nci-1); - for (j = 0; j <= MAXJSAMPLE; j++) { - while (j > k) /* advance val if past boundary */ - k = largest_input_value(cinfo, i, ++val, nci-1); - /* premultiply so that no multiplication needed in main processing */ - indexptr[j] = (JSAMPLE) (val * blksize); - } - /* Pad at both ends if necessary */ - if (pad) - for (j = 1; j <= MAXJSAMPLE; j++) { - indexptr[-j] = indexptr[0]; - indexptr[MAXJSAMPLE+j] = indexptr[MAXJSAMPLE]; - } - } -} - - -/* - * Create an ordered-dither array for a component having ncolors - * distinct output values. - */ - -LOCAL(ODITHER_MATRIX_PTR) -make_odither_array (j_decompress_ptr cinfo, int ncolors) -{ - ODITHER_MATRIX_PTR odither; - int j,k; - INT32 num,den; - - odither = (ODITHER_MATRIX_PTR) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(ODITHER_MATRIX)); - /* The inter-value distance for this color is MAXJSAMPLE/(ncolors-1). - * Hence the dither value for the matrix cell with fill order f - * (f=0..N-1) should be (N-1-2*f)/(2*N) * MAXJSAMPLE/(ncolors-1). - * On 16-bit-int machine, be careful to avoid overflow. - */ - den = 2 * ODITHER_CELLS * ((INT32) (ncolors - 1)); - for (j = 0; j < ODITHER_SIZE; j++) { - for (k = 0; k < ODITHER_SIZE; k++) { - num = ((INT32) (ODITHER_CELLS-1 - 2*((int)base_dither_matrix[j][k]))) - * MAXJSAMPLE; - /* Ensure round towards zero despite C's lack of consistency - * about rounding negative values in integer division... - */ - odither[j][k] = (int) (num<0 ? -((-num)/den) : num/den); - } - } - return odither; -} - - -/* - * Create the ordered-dither tables. - * Components having the same number of representative colors may - * share a dither table. - */ - -LOCAL(void) -create_odither_tables (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - ODITHER_MATRIX_PTR odither; - int i, j, nci; - - for (i = 0; i < cinfo->out_color_components; i++) { - nci = cquantize->Ncolors[i]; /* # of distinct values for this color */ - odither = NULL; /* search for matching prior component */ - for (j = 0; j < i; j++) { - if (nci == cquantize->Ncolors[j]) { - odither = cquantize->odither[j]; - break; - } - } - if (odither == NULL) /* need a new table? */ - odither = make_odither_array(cinfo, nci); - cquantize->odither[i] = odither; - } -} - - -/* - * Map some rows of pixels to the output colormapped representation. - */ - -METHODDEF(void) -color_quantize (j_decompress_ptr cinfo, JSAMPARRAY input_buf, - JSAMPARRAY output_buf, int num_rows) -/* General case, no dithering */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - JSAMPARRAY colorindex = cquantize->colorindex; - register int pixcode, ci; - register JSAMPROW ptrin, ptrout; - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - register int nc = cinfo->out_color_components; - - for (row = 0; row < num_rows; row++) { - ptrin = input_buf[row]; - ptrout = output_buf[row]; - for (col = width; col > 0; col--) { - pixcode = 0; - for (ci = 0; ci < nc; ci++) { - pixcode += GETJSAMPLE(colorindex[ci][GETJSAMPLE(*ptrin++)]); - } - *ptrout++ = (JSAMPLE) pixcode; - } - } -} - - -METHODDEF(void) -color_quantize3 (j_decompress_ptr cinfo, JSAMPARRAY input_buf, - JSAMPARRAY output_buf, int num_rows) -/* Fast path for out_color_components==3, no dithering */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - register int pixcode; - register JSAMPROW ptrin, ptrout; - JSAMPROW colorindex0 = cquantize->colorindex[0]; - JSAMPROW colorindex1 = cquantize->colorindex[1]; - JSAMPROW colorindex2 = cquantize->colorindex[2]; - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - - for (row = 0; row < num_rows; row++) { - ptrin = input_buf[row]; - ptrout = output_buf[row]; - for (col = width; col > 0; col--) { - pixcode = GETJSAMPLE(colorindex0[GETJSAMPLE(*ptrin++)]); - pixcode += GETJSAMPLE(colorindex1[GETJSAMPLE(*ptrin++)]); - pixcode += GETJSAMPLE(colorindex2[GETJSAMPLE(*ptrin++)]); - *ptrout++ = (JSAMPLE) pixcode; - } - } -} - - -METHODDEF(void) -quantize_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf, - JSAMPARRAY output_buf, int num_rows) -/* General case, with ordered dithering */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - register JSAMPROW input_ptr; - register JSAMPROW output_ptr; - JSAMPROW colorindex_ci; - int * dither; /* points to active row of dither matrix */ - int row_index, col_index; /* current indexes into dither matrix */ - int nc = cinfo->out_color_components; - int ci; - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - - for (row = 0; row < num_rows; row++) { - /* Initialize output values to 0 so can process components separately */ - jzero_far((void FAR *) output_buf[row], - (size_t) (width * SIZEOF(JSAMPLE))); - row_index = cquantize->row_index; - for (ci = 0; ci < nc; ci++) { - input_ptr = input_buf[row] + ci; - output_ptr = output_buf[row]; - colorindex_ci = cquantize->colorindex[ci]; - dither = cquantize->odither[ci][row_index]; - col_index = 0; - - for (col = width; col > 0; col--) { - /* Form pixel value + dither, range-limit to 0..MAXJSAMPLE, - * select output value, accumulate into output code for this pixel. - * Range-limiting need not be done explicitly, as we have extended - * the colorindex table to produce the right answers for out-of-range - * inputs. The maximum dither is +- MAXJSAMPLE; this sets the - * required amount of padding. - */ - *output_ptr += colorindex_ci[GETJSAMPLE(*input_ptr)+dither[col_index]]; - input_ptr += nc; - output_ptr++; - col_index = (col_index + 1) & ODITHER_MASK; - } - } - /* Advance row index for next row */ - row_index = (row_index + 1) & ODITHER_MASK; - cquantize->row_index = row_index; - } -} - - -METHODDEF(void) -quantize3_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf, - JSAMPARRAY output_buf, int num_rows) -/* Fast path for out_color_components==3, with ordered dithering */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - register int pixcode; - register JSAMPROW input_ptr; - register JSAMPROW output_ptr; - JSAMPROW colorindex0 = cquantize->colorindex[0]; - JSAMPROW colorindex1 = cquantize->colorindex[1]; - JSAMPROW colorindex2 = cquantize->colorindex[2]; - int * dither0; /* points to active row of dither matrix */ - int * dither1; - int * dither2; - int row_index, col_index; /* current indexes into dither matrix */ - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - - for (row = 0; row < num_rows; row++) { - row_index = cquantize->row_index; - input_ptr = input_buf[row]; - output_ptr = output_buf[row]; - dither0 = cquantize->odither[0][row_index]; - dither1 = cquantize->odither[1][row_index]; - dither2 = cquantize->odither[2][row_index]; - col_index = 0; - - for (col = width; col > 0; col--) { - pixcode = GETJSAMPLE(colorindex0[GETJSAMPLE(*input_ptr++) + - dither0[col_index]]); - pixcode += GETJSAMPLE(colorindex1[GETJSAMPLE(*input_ptr++) + - dither1[col_index]]); - pixcode += GETJSAMPLE(colorindex2[GETJSAMPLE(*input_ptr++) + - dither2[col_index]]); - *output_ptr++ = (JSAMPLE) pixcode; - col_index = (col_index + 1) & ODITHER_MASK; - } - row_index = (row_index + 1) & ODITHER_MASK; - cquantize->row_index = row_index; - } -} - - -METHODDEF(void) -quantize_fs_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf, - JSAMPARRAY output_buf, int num_rows) -/* General case, with Floyd-Steinberg dithering */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - register LOCFSERROR cur; /* current error or pixel value */ - LOCFSERROR belowerr; /* error for pixel below cur */ - LOCFSERROR bpreverr; /* error for below/prev col */ - LOCFSERROR bnexterr; /* error for below/next col */ - LOCFSERROR delta; - register FSERRPTR errorptr; /* => fserrors[] at column before current */ - register JSAMPROW input_ptr; - register JSAMPROW output_ptr; - JSAMPROW colorindex_ci; - JSAMPROW colormap_ci; - int pixcode; - int nc = cinfo->out_color_components; - int dir; /* 1 for left-to-right, -1 for right-to-left */ - int dirnc; /* dir * nc */ - int ci; - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - JSAMPLE *range_limit = cinfo->sample_range_limit; - SHIFT_TEMPS - - for (row = 0; row < num_rows; row++) { - /* Initialize output values to 0 so can process components separately */ - jzero_far((void FAR *) output_buf[row], - (size_t) (width * SIZEOF(JSAMPLE))); - for (ci = 0; ci < nc; ci++) { - input_ptr = input_buf[row] + ci; - output_ptr = output_buf[row]; - if (cquantize->on_odd_row) { - /* work right to left in this row */ - input_ptr += (width-1) * nc; /* so point to rightmost pixel */ - output_ptr += width-1; - dir = -1; - dirnc = -nc; - errorptr = cquantize->fserrors[ci] + (width+1); /* => entry after last column */ - } else { - /* work left to right in this row */ - dir = 1; - dirnc = nc; - errorptr = cquantize->fserrors[ci]; /* => entry before first column */ - } - colorindex_ci = cquantize->colorindex[ci]; - colormap_ci = cquantize->sv_colormap[ci]; - /* Preset error values: no error propagated to first pixel from left */ - cur = 0; - /* and no error propagated to row below yet */ - belowerr = bpreverr = 0; - - for (col = width; col > 0; col--) { - /* cur holds the error propagated from the previous pixel on the - * current line. Add the error propagated from the previous line - * to form the complete error correction term for this pixel, and - * round the error term (which is expressed * 16) to an integer. - * RIGHT_SHIFT rounds towards minus infinity, so adding 8 is correct - * for either sign of the error value. - * Note: errorptr points to *previous* column's array entry. - */ - cur = RIGHT_SHIFT(cur + errorptr[dir] + 8, 4); - /* Form pixel value + error, and range-limit to 0..MAXJSAMPLE. - * The maximum error is +- MAXJSAMPLE; this sets the required size - * of the range_limit array. - */ - cur += GETJSAMPLE(*input_ptr); - cur = GETJSAMPLE(range_limit[cur]); - /* Select output value, accumulate into output code for this pixel */ - pixcode = GETJSAMPLE(colorindex_ci[cur]); - *output_ptr += (JSAMPLE) pixcode; - /* Compute actual representation error at this pixel */ - /* Note: we can do this even though we don't have the final */ - /* pixel code, because the colormap is orthogonal. */ - cur -= GETJSAMPLE(colormap_ci[pixcode]); - /* Compute error fractions to be propagated to adjacent pixels. - * Add these into the running sums, and simultaneously shift the - * next-line error sums left by 1 column. - */ - bnexterr = cur; - delta = cur * 2; - cur += delta; /* form error * 3 */ - errorptr[0] = (FSERROR) (bpreverr + cur); - cur += delta; /* form error * 5 */ - bpreverr = belowerr + cur; - belowerr = bnexterr; - cur += delta; /* form error * 7 */ - /* At this point cur contains the 7/16 error value to be propagated - * to the next pixel on the current line, and all the errors for the - * next line have been shifted over. We are therefore ready to move on. - */ - input_ptr += dirnc; /* advance input ptr to next column */ - output_ptr += dir; /* advance output ptr to next column */ - errorptr += dir; /* advance errorptr to current column */ - } - /* Post-loop cleanup: we must unload the final error value into the - * final fserrors[] entry. Note we need not unload belowerr because - * it is for the dummy column before or after the actual array. - */ - errorptr[0] = (FSERROR) bpreverr; /* unload prev err into array */ - } - cquantize->on_odd_row = (cquantize->on_odd_row ? FALSE : TRUE); - } -} - - -/* - * Allocate workspace for Floyd-Steinberg errors. - */ - -LOCAL(void) -alloc_fs_workspace (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - size_t arraysize; - int i; - - arraysize = (size_t) ((cinfo->output_width + 2) * SIZEOF(FSERROR)); - for (i = 0; i < cinfo->out_color_components; i++) { - cquantize->fserrors[i] = (FSERRPTR) - (*cinfo->mem->alloc_large)((j_common_ptr) cinfo, JPOOL_IMAGE, arraysize); - } -} - - -/* - * Initialize for one-pass color quantization. - */ - -METHODDEF(void) -start_pass_1_quant (j_decompress_ptr cinfo, boolean is_pre_scan) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - size_t arraysize; - int i; - - /* Install my colormap. */ - cinfo->colormap = cquantize->sv_colormap; - cinfo->actual_number_of_colors = cquantize->sv_actual; - - /* Initialize for desired dithering mode. */ - switch (cinfo->dither_mode) { - case JDITHER_NONE: - if (cinfo->out_color_components == 3) - cquantize->pub.color_quantize = color_quantize3; - else - cquantize->pub.color_quantize = color_quantize; - break; - case JDITHER_ORDERED: - if (cinfo->out_color_components == 3) - cquantize->pub.color_quantize = quantize3_ord_dither; - else - cquantize->pub.color_quantize = quantize_ord_dither; - cquantize->row_index = 0; /* initialize state for ordered dither */ - /* If user changed to ordered dither from another mode, - * we must recreate the color index table with padding. - * This will cost extra space, but probably isn't very likely. - */ - if (! cquantize->is_padded) - create_colorindex(cinfo); - /* Create ordered-dither tables if we didn't already. */ - if (cquantize->odither[0] == NULL) - create_odither_tables(cinfo); - break; - case JDITHER_FS: - cquantize->pub.color_quantize = quantize_fs_dither; - cquantize->on_odd_row = FALSE; /* initialize state for F-S dither */ - /* Allocate Floyd-Steinberg workspace if didn't already. */ - if (cquantize->fserrors[0] == NULL) - alloc_fs_workspace(cinfo); - /* Initialize the propagated errors to zero. */ - arraysize = (size_t) ((cinfo->output_width + 2) * SIZEOF(FSERROR)); - for (i = 0; i < cinfo->out_color_components; i++) - jzero_far((void FAR *) cquantize->fserrors[i], arraysize); - break; - default: - ERREXIT(cinfo, JERR_NOT_COMPILED); - break; - } -} - - -/* - * Finish up at the end of the pass. - */ - -METHODDEF(void) -finish_pass_1_quant (j_decompress_ptr cinfo) -{ - /* no work in 1-pass case */ -} - - -/* - * Switch to a new external colormap between output passes. - * Shouldn't get to this module! - */ - -METHODDEF(void) -new_color_map_1_quant (j_decompress_ptr cinfo) -{ - ERREXIT(cinfo, JERR_MODE_CHANGE); -} - - -/* - * Module initialization routine for 1-pass color quantization. - */ - -GLOBAL(void) -jinit_1pass_quantizer (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize; - - cquantize = (my_cquantize_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_cquantizer)); - cinfo->cquantize = (struct jpeg_color_quantizer *) cquantize; - cquantize->pub.start_pass = start_pass_1_quant; - cquantize->pub.finish_pass = finish_pass_1_quant; - cquantize->pub.new_color_map = new_color_map_1_quant; - cquantize->fserrors[0] = NULL; /* Flag FS workspace not allocated */ - cquantize->odither[0] = NULL; /* Also flag odither arrays not allocated */ - - /* Make sure my internal arrays won't overflow */ - if (cinfo->out_color_components > MAX_Q_COMPS) - ERREXIT1(cinfo, JERR_QUANT_COMPONENTS, MAX_Q_COMPS); - /* Make sure colormap indexes can be represented by JSAMPLEs */ - if (cinfo->desired_number_of_colors > (MAXJSAMPLE+1)) - ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXJSAMPLE+1); - - /* Create the colormap and color index table. */ - create_colormap(cinfo); - create_colorindex(cinfo); - - /* Allocate Floyd-Steinberg workspace now if requested. - * We do this now since it is FAR storage and may affect the memory - * manager's space calculations. If the user changes to FS dither - * mode in a later pass, we will allocate the space then, and will - * possibly overrun the max_memory_to_use setting. - */ - if (cinfo->dither_mode == JDITHER_FS) - alloc_fs_workspace(cinfo); -} - -#endif /* QUANT_1PASS_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jquant2.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jquant2.c deleted file mode 100644 index 87a3920b0..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jquant2.c +++ /dev/null @@ -1,1310 +0,0 @@ -/* - * jquant2.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains 2-pass color quantization (color mapping) routines. - * These routines provide selection of a custom color map for an image, - * followed by mapping of the image to that color map, with optional - * Floyd-Steinberg dithering. - * It is also possible to use just the second pass to map to an arbitrary - * externally-given color map. - * - * Note: ordered dithering is not supported, since there isn't any fast - * way to compute intercolor distances; it's unclear that ordered dither's - * fundamental assumptions even hold with an irregularly spaced color map. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - -#ifdef QUANT_2PASS_SUPPORTED - - -/* - * This module implements the well-known Heckbert paradigm for color - * quantization. Most of the ideas used here can be traced back to - * Heckbert's seminal paper - * Heckbert, Paul. "Color Image Quantization for Frame Buffer Display", - * Proc. SIGGRAPH '82, Computer Graphics v.16 #3 (July 1982), pp 297-304. - * - * In the first pass over the image, we accumulate a histogram showing the - * usage count of each possible color. To keep the histogram to a reasonable - * size, we reduce the precision of the input; typical practice is to retain - * 5 or 6 bits per color, so that 8 or 4 different input values are counted - * in the same histogram cell. - * - * Next, the color-selection step begins with a box representing the whole - * color space, and repeatedly splits the "largest" remaining box until we - * have as many boxes as desired colors. Then the mean color in each - * remaining box becomes one of the possible output colors. - * - * The second pass over the image maps each input pixel to the closest output - * color (optionally after applying a Floyd-Steinberg dithering correction). - * This mapping is logically trivial, but making it go fast enough requires - * considerable care. - * - * Heckbert-style quantizers vary a good deal in their policies for choosing - * the "largest" box and deciding where to cut it. The particular policies - * used here have proved out well in experimental comparisons, but better ones - * may yet be found. - * - * In earlier versions of the IJG code, this module quantized in YCbCr color - * space, processing the raw upsampled data without a color conversion step. - * This allowed the color conversion math to be done only once per colormap - * entry, not once per pixel. However, that optimization precluded other - * useful optimizations (such as merging color conversion with upsampling) - * and it also interfered with desired capabilities such as quantizing to an - * externally-supplied colormap. We have therefore abandoned that approach. - * The present code works in the post-conversion color space, typically RGB. - * - * To improve the visual quality of the results, we actually work in scaled - * RGB space, giving G distances more weight than R, and R in turn more than - * B. To do everything in integer math, we must use integer scale factors. - * The 2/3/1 scale factors used here correspond loosely to the relative - * weights of the colors in the NTSC grayscale equation. - * If you want to use this code to quantize a non-RGB color space, you'll - * probably need to change these scale factors. - */ - -#define R_SCALE 2 /* scale R distances by this much */ -#define G_SCALE 3 /* scale G distances by this much */ -#define B_SCALE 1 /* and B by this much */ - -/* Relabel R/G/B as components 0/1/2, respecting the RGB ordering defined - * in jmorecfg.h. As the code stands, it will do the right thing for R,G,B - * and B,G,R orders. If you define some other weird order in jmorecfg.h, - * you'll get compile errors until you extend this logic. In that case - * you'll probably want to tweak the histogram sizes too. - */ - -#if RGB_RED == 0 -#define C0_SCALE R_SCALE -#endif -#if RGB_BLUE == 0 -#define C0_SCALE B_SCALE -#endif -#if RGB_GREEN == 1 -#define C1_SCALE G_SCALE -#endif -#if RGB_RED == 2 -#define C2_SCALE R_SCALE -#endif -#if RGB_BLUE == 2 -#define C2_SCALE B_SCALE -#endif - - -/* - * First we have the histogram data structure and routines for creating it. - * - * The number of bits of precision can be adjusted by changing these symbols. - * We recommend keeping 6 bits for G and 5 each for R and B. - * If you have plenty of memory and cycles, 6 bits all around gives marginally - * better results; if you are short of memory, 5 bits all around will save - * some space but degrade the results. - * To maintain a fully accurate histogram, we'd need to allocate a "long" - * (preferably unsigned long) for each cell. In practice this is overkill; - * we can get by with 16 bits per cell. Few of the cell counts will overflow, - * and clamping those that do overflow to the maximum value will give close- - * enough results. This reduces the recommended histogram size from 256Kb - * to 128Kb, which is a useful savings on PC-class machines. - * (In the second pass the histogram space is re-used for pixel mapping data; - * in that capacity, each cell must be able to store zero to the number of - * desired colors. 16 bits/cell is plenty for that too.) - * Since the JPEG code is intended to run in small memory model on 80x86 - * machines, we can't just allocate the histogram in one chunk. Instead - * of a true 3-D array, we use a row of pointers to 2-D arrays. Each - * pointer corresponds to a C0 value (typically 2^5 = 32 pointers) and - * each 2-D array has 2^6*2^5 = 2048 or 2^6*2^6 = 4096 entries. Note that - * on 80x86 machines, the pointer row is in near memory but the actual - * arrays are in far memory (same arrangement as we use for image arrays). - */ - -#define MAXNUMCOLORS (MAXJSAMPLE+1) /* maximum size of colormap */ - -/* These will do the right thing for either R,G,B or B,G,R color order, - * but you may not like the results for other color orders. - */ -#define HIST_C0_BITS 5 /* bits of precision in R/B histogram */ -#define HIST_C1_BITS 6 /* bits of precision in G histogram */ -#define HIST_C2_BITS 5 /* bits of precision in B/R histogram */ - -/* Number of elements along histogram axes. */ -#define HIST_C0_ELEMS (1<<HIST_C0_BITS) -#define HIST_C1_ELEMS (1<<HIST_C1_BITS) -#define HIST_C2_ELEMS (1<<HIST_C2_BITS) - -/* These are the amounts to shift an input value to get a histogram index. */ -#define C0_SHIFT (BITS_IN_JSAMPLE-HIST_C0_BITS) -#define C1_SHIFT (BITS_IN_JSAMPLE-HIST_C1_BITS) -#define C2_SHIFT (BITS_IN_JSAMPLE-HIST_C2_BITS) - - -typedef UINT16 histcell; /* histogram cell; prefer an unsigned type */ - -typedef histcell FAR * histptr; /* for pointers to histogram cells */ - -typedef histcell hist1d[HIST_C2_ELEMS]; /* typedefs for the array */ -typedef hist1d FAR * hist2d; /* type for the 2nd-level pointers */ -typedef hist2d * hist3d; /* type for top-level pointer */ - - -/* Declarations for Floyd-Steinberg dithering. - * - * Errors are accumulated into the array fserrors[], at a resolution of - * 1/16th of a pixel count. The error at a given pixel is propagated - * to its not-yet-processed neighbors using the standard F-S fractions, - * ... (here) 7/16 - * 3/16 5/16 1/16 - * We work left-to-right on even rows, right-to-left on odd rows. - * - * We can get away with a single array (holding one row's worth of errors) - * by using it to store the current row's errors at pixel columns not yet - * processed, but the next row's errors at columns already processed. We - * need only a few extra variables to hold the errors immediately around the - * current column. (If we are lucky, those variables are in registers, but - * even if not, they're probably cheaper to access than array elements are.) - * - * The fserrors[] array has (#columns + 2) entries; the extra entry at - * each end saves us from special-casing the first and last pixels. - * Each entry is three values long, one value for each color component. - * - * Note: on a wide image, we might not have enough room in a PC's near data - * segment to hold the error array; so it is allocated with alloc_large. - */ - -#if BITS_IN_JSAMPLE == 8 -typedef INT16 FSERROR; /* 16 bits should be enough */ -typedef int LOCFSERROR; /* use 'int' for calculation temps */ -#else -typedef INT32 FSERROR; /* may need more than 16 bits */ -typedef INT32 LOCFSERROR; /* be sure calculation temps are big enough */ -#endif - -typedef FSERROR FAR *FSERRPTR; /* pointer to error array (in FAR storage!) */ - - -/* Private subobject */ - -typedef struct { - struct jpeg_color_quantizer pub; /* public fields */ - - /* Space for the eventually created colormap is stashed here */ - JSAMPARRAY sv_colormap; /* colormap allocated at init time */ - int desired; /* desired # of colors = size of colormap */ - - /* Variables for accumulating image statistics */ - hist3d histogram; /* pointer to the histogram */ - - boolean needs_zeroed; /* TRUE if next pass must zero histogram */ - - /* Variables for Floyd-Steinberg dithering */ - FSERRPTR fserrors; /* accumulated errors */ - boolean on_odd_row; /* flag to remember which row we are on */ - int * error_limiter; /* table for clamping the applied error */ -} my_cquantizer; - -typedef my_cquantizer * my_cquantize_ptr; - - -/* - * Prescan some rows of pixels. - * In this module the prescan simply updates the histogram, which has been - * initialized to zeroes by start_pass. - * An output_buf parameter is required by the method signature, but no data - * is actually output (in fact the buffer controller is probably passing a - * NULL pointer). - */ - -METHODDEF(void) -prescan_quantize (j_decompress_ptr cinfo, JSAMPARRAY input_buf, - JSAMPARRAY output_buf, int num_rows) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - register JSAMPROW ptr; - register histptr histp; - register hist3d histogram = cquantize->histogram; - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - - for (row = 0; row < num_rows; row++) { - ptr = input_buf[row]; - for (col = width; col > 0; col--) { - /* get pixel value and index into the histogram */ - histp = & histogram[GETJSAMPLE(ptr[0]) >> C0_SHIFT] - [GETJSAMPLE(ptr[1]) >> C1_SHIFT] - [GETJSAMPLE(ptr[2]) >> C2_SHIFT]; - /* increment, check for overflow and undo increment if so. */ - if (++(*histp) <= 0) - (*histp)--; - ptr += 3; - } - } -} - - -/* - * Next we have the really interesting routines: selection of a colormap - * given the completed histogram. - * These routines work with a list of "boxes", each representing a rectangular - * subset of the input color space (to histogram precision). - */ - -typedef struct { - /* The bounds of the box (inclusive); expressed as histogram indexes */ - int c0min, c0max; - int c1min, c1max; - int c2min, c2max; - /* The volume (actually 2-norm) of the box */ - INT32 volume; - /* The number of nonzero histogram cells within this box */ - long colorcount; -} box; - -typedef box * boxptr; - - -LOCAL(boxptr) -find_biggest_color_pop (boxptr boxlist, int numboxes) -/* Find the splittable box with the largest color population */ -/* Returns NULL if no splittable boxes remain */ -{ - register boxptr boxp; - register int i; - register long maxc = 0; - boxptr which = NULL; - - for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) { - if (boxp->colorcount > maxc && boxp->volume > 0) { - which = boxp; - maxc = boxp->colorcount; - } - } - return which; -} - - -LOCAL(boxptr) -find_biggest_volume (boxptr boxlist, int numboxes) -/* Find the splittable box with the largest (scaled) volume */ -/* Returns NULL if no splittable boxes remain */ -{ - register boxptr boxp; - register int i; - register INT32 maxv = 0; - boxptr which = NULL; - - for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) { - if (boxp->volume > maxv) { - which = boxp; - maxv = boxp->volume; - } - } - return which; -} - - -LOCAL(void) -update_box (j_decompress_ptr cinfo, boxptr boxp) -/* Shrink the min/max bounds of a box to enclose only nonzero elements, */ -/* and recompute its volume and population */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - hist3d histogram = cquantize->histogram; - histptr histp; - int c0,c1,c2; - int c0min,c0max,c1min,c1max,c2min,c2max; - INT32 dist0,dist1,dist2; - long ccount; - - c0min = boxp->c0min; c0max = boxp->c0max; - c1min = boxp->c1min; c1max = boxp->c1max; - c2min = boxp->c2min; c2max = boxp->c2max; - - if (c0max > c0min) - for (c0 = c0min; c0 <= c0max; c0++) - for (c1 = c1min; c1 <= c1max; c1++) { - histp = & histogram[c0][c1][c2min]; - for (c2 = c2min; c2 <= c2max; c2++) - if (*histp++ != 0) { - boxp->c0min = c0min = c0; - goto have_c0min; - } - } - have_c0min: - if (c0max > c0min) - for (c0 = c0max; c0 >= c0min; c0--) - for (c1 = c1min; c1 <= c1max; c1++) { - histp = & histogram[c0][c1][c2min]; - for (c2 = c2min; c2 <= c2max; c2++) - if (*histp++ != 0) { - boxp->c0max = c0max = c0; - goto have_c0max; - } - } - have_c0max: - if (c1max > c1min) - for (c1 = c1min; c1 <= c1max; c1++) - for (c0 = c0min; c0 <= c0max; c0++) { - histp = & histogram[c0][c1][c2min]; - for (c2 = c2min; c2 <= c2max; c2++) - if (*histp++ != 0) { - boxp->c1min = c1min = c1; - goto have_c1min; - } - } - have_c1min: - if (c1max > c1min) - for (c1 = c1max; c1 >= c1min; c1--) - for (c0 = c0min; c0 <= c0max; c0++) { - histp = & histogram[c0][c1][c2min]; - for (c2 = c2min; c2 <= c2max; c2++) - if (*histp++ != 0) { - boxp->c1max = c1max = c1; - goto have_c1max; - } - } - have_c1max: - if (c2max > c2min) - for (c2 = c2min; c2 <= c2max; c2++) - for (c0 = c0min; c0 <= c0max; c0++) { - histp = & histogram[c0][c1min][c2]; - for (c1 = c1min; c1 <= c1max; c1++, histp += HIST_C2_ELEMS) - if (*histp != 0) { - boxp->c2min = c2min = c2; - goto have_c2min; - } - } - have_c2min: - if (c2max > c2min) - for (c2 = c2max; c2 >= c2min; c2--) - for (c0 = c0min; c0 <= c0max; c0++) { - histp = & histogram[c0][c1min][c2]; - for (c1 = c1min; c1 <= c1max; c1++, histp += HIST_C2_ELEMS) - if (*histp != 0) { - boxp->c2max = c2max = c2; - goto have_c2max; - } - } - have_c2max: - - /* Update box volume. - * We use 2-norm rather than real volume here; this biases the method - * against making long narrow boxes, and it has the side benefit that - * a box is splittable iff norm > 0. - * Since the differences are expressed in histogram-cell units, - * we have to shift back to JSAMPLE units to get consistent distances; - * after which, we scale according to the selected distance scale factors. - */ - dist0 = ((c0max - c0min) << C0_SHIFT) * C0_SCALE; - dist1 = ((c1max - c1min) << C1_SHIFT) * C1_SCALE; - dist2 = ((c2max - c2min) << C2_SHIFT) * C2_SCALE; - boxp->volume = dist0*dist0 + dist1*dist1 + dist2*dist2; - - /* Now scan remaining volume of box and compute population */ - ccount = 0; - for (c0 = c0min; c0 <= c0max; c0++) - for (c1 = c1min; c1 <= c1max; c1++) { - histp = & histogram[c0][c1][c2min]; - for (c2 = c2min; c2 <= c2max; c2++, histp++) - if (*histp != 0) { - ccount++; - } - } - boxp->colorcount = ccount; -} - - -LOCAL(int) -median_cut (j_decompress_ptr cinfo, boxptr boxlist, int numboxes, - int desired_colors) -/* Repeatedly select and split the largest box until we have enough boxes */ -{ - int n,lb; - int c0,c1,c2,cmax; - register boxptr b1,b2; - - while (numboxes < desired_colors) { - /* Select box to split. - * Current algorithm: by population for first half, then by volume. - */ - if (numboxes*2 <= desired_colors) { - b1 = find_biggest_color_pop(boxlist, numboxes); - } else { - b1 = find_biggest_volume(boxlist, numboxes); - } - if (b1 == NULL) /* no splittable boxes left! */ - break; - b2 = &boxlist[numboxes]; /* where new box will go */ - /* Copy the color bounds to the new box. */ - b2->c0max = b1->c0max; b2->c1max = b1->c1max; b2->c2max = b1->c2max; - b2->c0min = b1->c0min; b2->c1min = b1->c1min; b2->c2min = b1->c2min; - /* Choose which axis to split the box on. - * Current algorithm: longest scaled axis. - * See notes in update_box about scaling distances. - */ - c0 = ((b1->c0max - b1->c0min) << C0_SHIFT) * C0_SCALE; - c1 = ((b1->c1max - b1->c1min) << C1_SHIFT) * C1_SCALE; - c2 = ((b1->c2max - b1->c2min) << C2_SHIFT) * C2_SCALE; - /* We want to break any ties in favor of green, then red, blue last. - * This code does the right thing for R,G,B or B,G,R color orders only. - */ -#if RGB_RED == 0 - cmax = c1; n = 1; - if (c0 > cmax) { cmax = c0; n = 0; } - if (c2 > cmax) { n = 2; } -#else - cmax = c1; n = 1; - if (c2 > cmax) { cmax = c2; n = 2; } - if (c0 > cmax) { n = 0; } -#endif - /* Choose split point along selected axis, and update box bounds. - * Current algorithm: split at halfway point. - * (Since the box has been shrunk to minimum volume, - * any split will produce two nonempty subboxes.) - * Note that lb value is max for lower box, so must be < old max. - */ - switch (n) { - case 0: - lb = (b1->c0max + b1->c0min) / 2; - b1->c0max = lb; - b2->c0min = lb+1; - break; - case 1: - lb = (b1->c1max + b1->c1min) / 2; - b1->c1max = lb; - b2->c1min = lb+1; - break; - case 2: - lb = (b1->c2max + b1->c2min) / 2; - b1->c2max = lb; - b2->c2min = lb+1; - break; - } - /* Update stats for boxes */ - update_box(cinfo, b1); - update_box(cinfo, b2); - numboxes++; - } - return numboxes; -} - - -LOCAL(void) -compute_color (j_decompress_ptr cinfo, boxptr boxp, int icolor) -/* Compute representative color for a box, put it in colormap[icolor] */ -{ - /* Current algorithm: mean weighted by pixels (not colors) */ - /* Note it is important to get the rounding correct! */ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - hist3d histogram = cquantize->histogram; - histptr histp; - int c0,c1,c2; - int c0min,c0max,c1min,c1max,c2min,c2max; - long count; - long total = 0; - long c0total = 0; - long c1total = 0; - long c2total = 0; - - c0min = boxp->c0min; c0max = boxp->c0max; - c1min = boxp->c1min; c1max = boxp->c1max; - c2min = boxp->c2min; c2max = boxp->c2max; - - for (c0 = c0min; c0 <= c0max; c0++) - for (c1 = c1min; c1 <= c1max; c1++) { - histp = & histogram[c0][c1][c2min]; - for (c2 = c2min; c2 <= c2max; c2++) { - if ((count = *histp++) != 0) { - total += count; - c0total += ((c0 << C0_SHIFT) + ((1<<C0_SHIFT)>>1)) * count; - c1total += ((c1 << C1_SHIFT) + ((1<<C1_SHIFT)>>1)) * count; - c2total += ((c2 << C2_SHIFT) + ((1<<C2_SHIFT)>>1)) * count; - } - } - } - - cinfo->colormap[0][icolor] = (JSAMPLE) ((c0total + (total>>1)) / total); - cinfo->colormap[1][icolor] = (JSAMPLE) ((c1total + (total>>1)) / total); - cinfo->colormap[2][icolor] = (JSAMPLE) ((c2total + (total>>1)) / total); -} - - -LOCAL(void) -select_colors (j_decompress_ptr cinfo, int desired_colors) -/* Master routine for color selection */ -{ - boxptr boxlist; - int numboxes; - int i; - - /* Allocate workspace for box list */ - boxlist = (boxptr) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, desired_colors * SIZEOF(box)); - /* Initialize one box containing whole space */ - numboxes = 1; - boxlist[0].c0min = 0; - boxlist[0].c0max = MAXJSAMPLE >> C0_SHIFT; - boxlist[0].c1min = 0; - boxlist[0].c1max = MAXJSAMPLE >> C1_SHIFT; - boxlist[0].c2min = 0; - boxlist[0].c2max = MAXJSAMPLE >> C2_SHIFT; - /* Shrink it to actually-used volume and set its statistics */ - update_box(cinfo, & boxlist[0]); - /* Perform median-cut to produce final box list */ - numboxes = median_cut(cinfo, boxlist, numboxes, desired_colors); - /* Compute the representative color for each box, fill colormap */ - for (i = 0; i < numboxes; i++) - compute_color(cinfo, & boxlist[i], i); - cinfo->actual_number_of_colors = numboxes; - TRACEMS1(cinfo, 1, JTRC_QUANT_SELECTED, numboxes); -} - - -/* - * These routines are concerned with the time-critical task of mapping input - * colors to the nearest color in the selected colormap. - * - * We re-use the histogram space as an "inverse color map", essentially a - * cache for the results of nearest-color searches. All colors within a - * histogram cell will be mapped to the same colormap entry, namely the one - * closest to the cell's center. This may not be quite the closest entry to - * the actual input color, but it's almost as good. A zero in the cache - * indicates we haven't found the nearest color for that cell yet; the array - * is cleared to zeroes before starting the mapping pass. When we find the - * nearest color for a cell, its colormap index plus one is recorded in the - * cache for future use. The pass2 scanning routines call fill_inverse_cmap - * when they need to use an unfilled entry in the cache. - * - * Our method of efficiently finding nearest colors is based on the "locally - * sorted search" idea described by Heckbert and on the incremental distance - * calculation described by Spencer W. Thomas in chapter III.1 of Graphics - * Gems II (James Arvo, ed. Academic Press, 1991). Thomas points out that - * the distances from a given colormap entry to each cell of the histogram can - * be computed quickly using an incremental method: the differences between - * distances to adjacent cells themselves differ by a constant. This allows a - * fairly fast implementation of the "brute force" approach of computing the - * distance from every colormap entry to every histogram cell. Unfortunately, - * it needs a work array to hold the best-distance-so-far for each histogram - * cell (because the inner loop has to be over cells, not colormap entries). - * The work array elements have to be INT32s, so the work array would need - * 256Kb at our recommended precision. This is not feasible in DOS machines. - * - * To get around these problems, we apply Thomas' method to compute the - * nearest colors for only the cells within a small subbox of the histogram. - * The work array need be only as big as the subbox, so the memory usage - * problem is solved. Furthermore, we need not fill subboxes that are never - * referenced in pass2; many images use only part of the color gamut, so a - * fair amount of work is saved. An additional advantage of this - * approach is that we can apply Heckbert's locality criterion to quickly - * eliminate colormap entries that are far away from the subbox; typically - * three-fourths of the colormap entries are rejected by Heckbert's criterion, - * and we need not compute their distances to individual cells in the subbox. - * The speed of this approach is heavily influenced by the subbox size: too - * small means too much overhead, too big loses because Heckbert's criterion - * can't eliminate as many colormap entries. Empirically the best subbox - * size seems to be about 1/512th of the histogram (1/8th in each direction). - * - * Thomas' article also describes a refined method which is asymptotically - * faster than the brute-force method, but it is also far more complex and - * cannot efficiently be applied to small subboxes. It is therefore not - * useful for programs intended to be portable to DOS machines. On machines - * with plenty of memory, filling the whole histogram in one shot with Thomas' - * refined method might be faster than the present code --- but then again, - * it might not be any faster, and it's certainly more complicated. - */ - - -/* log2(histogram cells in update box) for each axis; this can be adjusted */ -#define BOX_C0_LOG (HIST_C0_BITS-3) -#define BOX_C1_LOG (HIST_C1_BITS-3) -#define BOX_C2_LOG (HIST_C2_BITS-3) - -#define BOX_C0_ELEMS (1<<BOX_C0_LOG) /* # of hist cells in update box */ -#define BOX_C1_ELEMS (1<<BOX_C1_LOG) -#define BOX_C2_ELEMS (1<<BOX_C2_LOG) - -#define BOX_C0_SHIFT (C0_SHIFT + BOX_C0_LOG) -#define BOX_C1_SHIFT (C1_SHIFT + BOX_C1_LOG) -#define BOX_C2_SHIFT (C2_SHIFT + BOX_C2_LOG) - - -/* - * The next three routines implement inverse colormap filling. They could - * all be folded into one big routine, but splitting them up this way saves - * some stack space (the mindist[] and bestdist[] arrays need not coexist) - * and may allow some compilers to produce better code by registerizing more - * inner-loop variables. - */ - -LOCAL(int) -find_nearby_colors (j_decompress_ptr cinfo, int minc0, int minc1, int minc2, - JSAMPLE colorlist[]) -/* Locate the colormap entries close enough to an update box to be candidates - * for the nearest entry to some cell(s) in the update box. The update box - * is specified by the center coordinates of its first cell. The number of - * candidate colormap entries is returned, and their colormap indexes are - * placed in colorlist[]. - * This routine uses Heckbert's "locally sorted search" criterion to select - * the colors that need further consideration. - */ -{ - int numcolors = cinfo->actual_number_of_colors; - int maxc0, maxc1, maxc2; - int centerc0, centerc1, centerc2; - int i, x, ncolors; - INT32 minmaxdist, min_dist, max_dist, tdist; - INT32 mindist[MAXNUMCOLORS]; /* min distance to colormap entry i */ - - /* Compute true coordinates of update box's upper corner and center. - * Actually we compute the coordinates of the center of the upper-corner - * histogram cell, which are the upper bounds of the volume we care about. - * Note that since ">>" rounds down, the "center" values may be closer to - * min than to max; hence comparisons to them must be "<=", not "<". - */ - maxc0 = minc0 + ((1 << BOX_C0_SHIFT) - (1 << C0_SHIFT)); - centerc0 = (minc0 + maxc0) >> 1; - maxc1 = minc1 + ((1 << BOX_C1_SHIFT) - (1 << C1_SHIFT)); - centerc1 = (minc1 + maxc1) >> 1; - maxc2 = minc2 + ((1 << BOX_C2_SHIFT) - (1 << C2_SHIFT)); - centerc2 = (minc2 + maxc2) >> 1; - - /* For each color in colormap, find: - * 1. its minimum squared-distance to any point in the update box - * (zero if color is within update box); - * 2. its maximum squared-distance to any point in the update box. - * Both of these can be found by considering only the corners of the box. - * We save the minimum distance for each color in mindist[]; - * only the smallest maximum distance is of interest. - */ - minmaxdist = 0x7FFFFFFFL; - - for (i = 0; i < numcolors; i++) { - /* We compute the squared-c0-distance term, then add in the other two. */ - x = GETJSAMPLE(cinfo->colormap[0][i]); - if (x < minc0) { - tdist = (x - minc0) * C0_SCALE; - min_dist = tdist*tdist; - tdist = (x - maxc0) * C0_SCALE; - max_dist = tdist*tdist; - } else if (x > maxc0) { - tdist = (x - maxc0) * C0_SCALE; - min_dist = tdist*tdist; - tdist = (x - minc0) * C0_SCALE; - max_dist = tdist*tdist; - } else { - /* within cell range so no contribution to min_dist */ - min_dist = 0; - if (x <= centerc0) { - tdist = (x - maxc0) * C0_SCALE; - max_dist = tdist*tdist; - } else { - tdist = (x - minc0) * C0_SCALE; - max_dist = tdist*tdist; - } - } - - x = GETJSAMPLE(cinfo->colormap[1][i]); - if (x < minc1) { - tdist = (x - minc1) * C1_SCALE; - min_dist += tdist*tdist; - tdist = (x - maxc1) * C1_SCALE; - max_dist += tdist*tdist; - } else if (x > maxc1) { - tdist = (x - maxc1) * C1_SCALE; - min_dist += tdist*tdist; - tdist = (x - minc1) * C1_SCALE; - max_dist += tdist*tdist; - } else { - /* within cell range so no contribution to min_dist */ - if (x <= centerc1) { - tdist = (x - maxc1) * C1_SCALE; - max_dist += tdist*tdist; - } else { - tdist = (x - minc1) * C1_SCALE; - max_dist += tdist*tdist; - } - } - - x = GETJSAMPLE(cinfo->colormap[2][i]); - if (x < minc2) { - tdist = (x - minc2) * C2_SCALE; - min_dist += tdist*tdist; - tdist = (x - maxc2) * C2_SCALE; - max_dist += tdist*tdist; - } else if (x > maxc2) { - tdist = (x - maxc2) * C2_SCALE; - min_dist += tdist*tdist; - tdist = (x - minc2) * C2_SCALE; - max_dist += tdist*tdist; - } else { - /* within cell range so no contribution to min_dist */ - if (x <= centerc2) { - tdist = (x - maxc2) * C2_SCALE; - max_dist += tdist*tdist; - } else { - tdist = (x - minc2) * C2_SCALE; - max_dist += tdist*tdist; - } - } - - mindist[i] = min_dist; /* save away the results */ - if (max_dist < minmaxdist) - minmaxdist = max_dist; - } - - /* Now we know that no cell in the update box is more than minmaxdist - * away from some colormap entry. Therefore, only colors that are - * within minmaxdist of some part of the box need be considered. - */ - ncolors = 0; - for (i = 0; i < numcolors; i++) { - if (mindist[i] <= minmaxdist) - colorlist[ncolors++] = (JSAMPLE) i; - } - return ncolors; -} - - -LOCAL(void) -find_best_colors (j_decompress_ptr cinfo, int minc0, int minc1, int minc2, - int numcolors, JSAMPLE colorlist[], JSAMPLE bestcolor[]) -/* Find the closest colormap entry for each cell in the update box, - * given the list of candidate colors prepared by find_nearby_colors. - * Return the indexes of the closest entries in the bestcolor[] array. - * This routine uses Thomas' incremental distance calculation method to - * find the distance from a colormap entry to successive cells in the box. - */ -{ - int ic0, ic1, ic2; - int i, icolor; - register INT32 * bptr; /* pointer into bestdist[] array */ - JSAMPLE * cptr; /* pointer into bestcolor[] array */ - INT32 dist0, dist1; /* initial distance values */ - register INT32 dist2; /* current distance in inner loop */ - INT32 xx0, xx1; /* distance increments */ - register INT32 xx2; - INT32 inc0, inc1, inc2; /* initial values for increments */ - /* This array holds the distance to the nearest-so-far color for each cell */ - INT32 bestdist[BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS]; - - /* Initialize best-distance for each cell of the update box */ - bptr = bestdist; - for (i = BOX_C0_ELEMS*BOX_C1_ELEMS*BOX_C2_ELEMS-1; i >= 0; i--) - *bptr++ = 0x7FFFFFFFL; - - /* For each color selected by find_nearby_colors, - * compute its distance to the center of each cell in the box. - * If that's less than best-so-far, update best distance and color number. - */ - - /* Nominal steps between cell centers ("x" in Thomas article) */ -#define STEP_C0 ((1 << C0_SHIFT) * C0_SCALE) -#define STEP_C1 ((1 << C1_SHIFT) * C1_SCALE) -#define STEP_C2 ((1 << C2_SHIFT) * C2_SCALE) - - for (i = 0; i < numcolors; i++) { - icolor = GETJSAMPLE(colorlist[i]); - /* Compute (square of) distance from minc0/c1/c2 to this color */ - inc0 = (minc0 - GETJSAMPLE(cinfo->colormap[0][icolor])) * C0_SCALE; - dist0 = inc0*inc0; - inc1 = (minc1 - GETJSAMPLE(cinfo->colormap[1][icolor])) * C1_SCALE; - dist0 += inc1*inc1; - inc2 = (minc2 - GETJSAMPLE(cinfo->colormap[2][icolor])) * C2_SCALE; - dist0 += inc2*inc2; - /* Form the initial difference increments */ - inc0 = inc0 * (2 * STEP_C0) + STEP_C0 * STEP_C0; - inc1 = inc1 * (2 * STEP_C1) + STEP_C1 * STEP_C1; - inc2 = inc2 * (2 * STEP_C2) + STEP_C2 * STEP_C2; - /* Now loop over all cells in box, updating distance per Thomas method */ - bptr = bestdist; - cptr = bestcolor; - xx0 = inc0; - for (ic0 = BOX_C0_ELEMS-1; ic0 >= 0; ic0--) { - dist1 = dist0; - xx1 = inc1; - for (ic1 = BOX_C1_ELEMS-1; ic1 >= 0; ic1--) { - dist2 = dist1; - xx2 = inc2; - for (ic2 = BOX_C2_ELEMS-1; ic2 >= 0; ic2--) { - if (dist2 < *bptr) { - *bptr = dist2; - *cptr = (JSAMPLE) icolor; - } - dist2 += xx2; - xx2 += 2 * STEP_C2 * STEP_C2; - bptr++; - cptr++; - } - dist1 += xx1; - xx1 += 2 * STEP_C1 * STEP_C1; - } - dist0 += xx0; - xx0 += 2 * STEP_C0 * STEP_C0; - } - } -} - - -LOCAL(void) -fill_inverse_cmap (j_decompress_ptr cinfo, int c0, int c1, int c2) -/* Fill the inverse-colormap entries in the update box that contains */ -/* histogram cell c0/c1/c2. (Only that one cell MUST be filled, but */ -/* we can fill as many others as we wish.) */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - hist3d histogram = cquantize->histogram; - int minc0, minc1, minc2; /* lower left corner of update box */ - int ic0, ic1, ic2; - register JSAMPLE * cptr; /* pointer into bestcolor[] array */ - register histptr cachep; /* pointer into main cache array */ - /* This array lists the candidate colormap indexes. */ - JSAMPLE colorlist[MAXNUMCOLORS]; - int numcolors; /* number of candidate colors */ - /* This array holds the actually closest colormap index for each cell. */ - JSAMPLE bestcolor[BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS]; - - /* Convert cell coordinates to update box ID */ - c0 >>= BOX_C0_LOG; - c1 >>= BOX_C1_LOG; - c2 >>= BOX_C2_LOG; - - /* Compute true coordinates of update box's origin corner. - * Actually we compute the coordinates of the center of the corner - * histogram cell, which are the lower bounds of the volume we care about. - */ - minc0 = (c0 << BOX_C0_SHIFT) + ((1 << C0_SHIFT) >> 1); - minc1 = (c1 << BOX_C1_SHIFT) + ((1 << C1_SHIFT) >> 1); - minc2 = (c2 << BOX_C2_SHIFT) + ((1 << C2_SHIFT) >> 1); - - /* Determine which colormap entries are close enough to be candidates - * for the nearest entry to some cell in the update box. - */ - numcolors = find_nearby_colors(cinfo, minc0, minc1, minc2, colorlist); - - /* Determine the actually nearest colors. */ - find_best_colors(cinfo, minc0, minc1, minc2, numcolors, colorlist, - bestcolor); - - /* Save the best color numbers (plus 1) in the main cache array */ - c0 <<= BOX_C0_LOG; /* convert ID back to base cell indexes */ - c1 <<= BOX_C1_LOG; - c2 <<= BOX_C2_LOG; - cptr = bestcolor; - for (ic0 = 0; ic0 < BOX_C0_ELEMS; ic0++) { - for (ic1 = 0; ic1 < BOX_C1_ELEMS; ic1++) { - cachep = & histogram[c0+ic0][c1+ic1][c2]; - for (ic2 = 0; ic2 < BOX_C2_ELEMS; ic2++) { - *cachep++ = (histcell) (GETJSAMPLE(*cptr++) + 1); - } - } - } -} - - -/* - * Map some rows of pixels to the output colormapped representation. - */ - -METHODDEF(void) -pass2_no_dither (j_decompress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPARRAY output_buf, int num_rows) -/* This version performs no dithering */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - hist3d histogram = cquantize->histogram; - register JSAMPROW inptr, outptr; - register histptr cachep; - register int c0, c1, c2; - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - - for (row = 0; row < num_rows; row++) { - inptr = input_buf[row]; - outptr = output_buf[row]; - for (col = width; col > 0; col--) { - /* get pixel value and index into the cache */ - c0 = GETJSAMPLE(*inptr++) >> C0_SHIFT; - c1 = GETJSAMPLE(*inptr++) >> C1_SHIFT; - c2 = GETJSAMPLE(*inptr++) >> C2_SHIFT; - cachep = & histogram[c0][c1][c2]; - /* If we have not seen this color before, find nearest colormap entry */ - /* and update the cache */ - if (*cachep == 0) - fill_inverse_cmap(cinfo, c0,c1,c2); - /* Now emit the colormap index for this cell */ - *outptr++ = (JSAMPLE) (*cachep - 1); - } - } -} - - -METHODDEF(void) -pass2_fs_dither (j_decompress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPARRAY output_buf, int num_rows) -/* This version performs Floyd-Steinberg dithering */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - hist3d histogram = cquantize->histogram; - register LOCFSERROR cur0, cur1, cur2; /* current error or pixel value */ - LOCFSERROR belowerr0, belowerr1, belowerr2; /* error for pixel below cur */ - LOCFSERROR bpreverr0, bpreverr1, bpreverr2; /* error for below/prev col */ - register FSERRPTR errorptr; /* => fserrors[] at column before current */ - JSAMPROW inptr; /* => current input pixel */ - JSAMPROW outptr; /* => current output pixel */ - histptr cachep; - int dir; /* +1 or -1 depending on direction */ - int dir3; /* 3*dir, for advancing inptr & errorptr */ - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - JSAMPLE *range_limit = cinfo->sample_range_limit; - int *error_limit = cquantize->error_limiter; - JSAMPROW colormap0 = cinfo->colormap[0]; - JSAMPROW colormap1 = cinfo->colormap[1]; - JSAMPROW colormap2 = cinfo->colormap[2]; - SHIFT_TEMPS - - for (row = 0; row < num_rows; row++) { - inptr = input_buf[row]; - outptr = output_buf[row]; - if (cquantize->on_odd_row) { - /* work right to left in this row */ - inptr += (width-1) * 3; /* so point to rightmost pixel */ - outptr += width-1; - dir = -1; - dir3 = -3; - errorptr = cquantize->fserrors + (width+1)*3; /* => entry after last column */ - cquantize->on_odd_row = FALSE; /* flip for next time */ - } else { - /* work left to right in this row */ - dir = 1; - dir3 = 3; - errorptr = cquantize->fserrors; /* => entry before first real column */ - cquantize->on_odd_row = TRUE; /* flip for next time */ - } - /* Preset error values: no error propagated to first pixel from left */ - cur0 = cur1 = cur2 = 0; - /* and no error propagated to row below yet */ - belowerr0 = belowerr1 = belowerr2 = 0; - bpreverr0 = bpreverr1 = bpreverr2 = 0; - - for (col = width; col > 0; col--) { - /* curN holds the error propagated from the previous pixel on the - * current line. Add the error propagated from the previous line - * to form the complete error correction term for this pixel, and - * round the error term (which is expressed * 16) to an integer. - * RIGHT_SHIFT rounds towards minus infinity, so adding 8 is correct - * for either sign of the error value. - * Note: errorptr points to *previous* column's array entry. - */ - cur0 = RIGHT_SHIFT(cur0 + errorptr[dir3+0] + 8, 4); - cur1 = RIGHT_SHIFT(cur1 + errorptr[dir3+1] + 8, 4); - cur2 = RIGHT_SHIFT(cur2 + errorptr[dir3+2] + 8, 4); - /* Limit the error using transfer function set by init_error_limit. - * See comments with init_error_limit for rationale. - */ - cur0 = error_limit[cur0]; - cur1 = error_limit[cur1]; - cur2 = error_limit[cur2]; - /* Form pixel value + error, and range-limit to 0..MAXJSAMPLE. - * The maximum error is +- MAXJSAMPLE (or less with error limiting); - * this sets the required size of the range_limit array. - */ - cur0 += GETJSAMPLE(inptr[0]); - cur1 += GETJSAMPLE(inptr[1]); - cur2 += GETJSAMPLE(inptr[2]); - cur0 = GETJSAMPLE(range_limit[cur0]); - cur1 = GETJSAMPLE(range_limit[cur1]); - cur2 = GETJSAMPLE(range_limit[cur2]); - /* Index into the cache with adjusted pixel value */ - cachep = & histogram[cur0>>C0_SHIFT][cur1>>C1_SHIFT][cur2>>C2_SHIFT]; - /* If we have not seen this color before, find nearest colormap */ - /* entry and update the cache */ - if (*cachep == 0) - fill_inverse_cmap(cinfo, cur0>>C0_SHIFT,cur1>>C1_SHIFT,cur2>>C2_SHIFT); - /* Now emit the colormap index for this cell */ - { register int pixcode = *cachep - 1; - *outptr = (JSAMPLE) pixcode; - /* Compute representation error for this pixel */ - cur0 -= GETJSAMPLE(colormap0[pixcode]); - cur1 -= GETJSAMPLE(colormap1[pixcode]); - cur2 -= GETJSAMPLE(colormap2[pixcode]); - } - /* Compute error fractions to be propagated to adjacent pixels. - * Add these into the running sums, and simultaneously shift the - * next-line error sums left by 1 column. - */ - { register LOCFSERROR bnexterr, delta; - - bnexterr = cur0; /* Process component 0 */ - delta = cur0 * 2; - cur0 += delta; /* form error * 3 */ - errorptr[0] = (FSERROR) (bpreverr0 + cur0); - cur0 += delta; /* form error * 5 */ - bpreverr0 = belowerr0 + cur0; - belowerr0 = bnexterr; - cur0 += delta; /* form error * 7 */ - bnexterr = cur1; /* Process component 1 */ - delta = cur1 * 2; - cur1 += delta; /* form error * 3 */ - errorptr[1] = (FSERROR) (bpreverr1 + cur1); - cur1 += delta; /* form error * 5 */ - bpreverr1 = belowerr1 + cur1; - belowerr1 = bnexterr; - cur1 += delta; /* form error * 7 */ - bnexterr = cur2; /* Process component 2 */ - delta = cur2 * 2; - cur2 += delta; /* form error * 3 */ - errorptr[2] = (FSERROR) (bpreverr2 + cur2); - cur2 += delta; /* form error * 5 */ - bpreverr2 = belowerr2 + cur2; - belowerr2 = bnexterr; - cur2 += delta; /* form error * 7 */ - } - /* At this point curN contains the 7/16 error value to be propagated - * to the next pixel on the current line, and all the errors for the - * next line have been shifted over. We are therefore ready to move on. - */ - inptr += dir3; /* Advance pixel pointers to next column */ - outptr += dir; - errorptr += dir3; /* advance errorptr to current column */ - } - /* Post-loop cleanup: we must unload the final error values into the - * final fserrors[] entry. Note we need not unload belowerrN because - * it is for the dummy column before or after the actual array. - */ - errorptr[0] = (FSERROR) bpreverr0; /* unload prev errs into array */ - errorptr[1] = (FSERROR) bpreverr1; - errorptr[2] = (FSERROR) bpreverr2; - } -} - - -/* - * Initialize the error-limiting transfer function (lookup table). - * The raw F-S error computation can potentially compute error values of up to - * +- MAXJSAMPLE. But we want the maximum correction applied to a pixel to be - * much less, otherwise obviously wrong pixels will be created. (Typical - * effects include weird fringes at color-area boundaries, isolated bright - * pixels in a dark area, etc.) The standard advice for avoiding this problem - * is to ensure that the "corners" of the color cube are allocated as output - * colors; then repeated errors in the same direction cannot cause cascading - * error buildup. However, that only prevents the error from getting - * completely out of hand; Aaron Giles reports that error limiting improves - * the results even with corner colors allocated. - * A simple clamping of the error values to about +- MAXJSAMPLE/8 works pretty - * well, but the smoother transfer function used below is even better. Thanks - * to Aaron Giles for this idea. - */ - -LOCAL(void) -init_error_limit (j_decompress_ptr cinfo) -/* Allocate and fill in the error_limiter table */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - int * table; - int in, out; - - table = (int *) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE*2+1) * SIZEOF(int)); - table += MAXJSAMPLE; /* so can index -MAXJSAMPLE .. +MAXJSAMPLE */ - cquantize->error_limiter = table; - -#define STEPSIZE ((MAXJSAMPLE+1)/16) - /* Map errors 1:1 up to +- MAXJSAMPLE/16 */ - out = 0; - for (in = 0; in < STEPSIZE; in++, out++) { - table[in] = out; table[-in] = -out; - } - /* Map errors 1:2 up to +- 3*MAXJSAMPLE/16 */ - for (; in < STEPSIZE*3; in++, out += (in&1) ? 0 : 1) { - table[in] = out; table[-in] = -out; - } - /* Clamp the rest to final out value (which is (MAXJSAMPLE+1)/8) */ - for (; in <= MAXJSAMPLE; in++) { - table[in] = out; table[-in] = -out; - } -#undef STEPSIZE -} - - -/* - * Finish up at the end of each pass. - */ - -METHODDEF(void) -finish_pass1 (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - - /* Select the representative colors and fill in cinfo->colormap */ - cinfo->colormap = cquantize->sv_colormap; - select_colors(cinfo, cquantize->desired); - /* Force next pass to zero the color index table */ - cquantize->needs_zeroed = TRUE; -} - - -METHODDEF(void) -finish_pass2 (j_decompress_ptr cinfo) -{ - /* no work */ -} - - -/* - * Initialize for each processing pass. - */ - -METHODDEF(void) -start_pass_2_quant (j_decompress_ptr cinfo, boolean is_pre_scan) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - hist3d histogram = cquantize->histogram; - int i; - - /* Only F-S dithering or no dithering is supported. */ - /* If user asks for ordered dither, give him F-S. */ - if (cinfo->dither_mode != JDITHER_NONE) - cinfo->dither_mode = JDITHER_FS; - - if (is_pre_scan) { - /* Set up method pointers */ - cquantize->pub.color_quantize = prescan_quantize; - cquantize->pub.finish_pass = finish_pass1; - cquantize->needs_zeroed = TRUE; /* Always zero histogram */ - } else { - /* Set up method pointers */ - if (cinfo->dither_mode == JDITHER_FS) - cquantize->pub.color_quantize = pass2_fs_dither; - else - cquantize->pub.color_quantize = pass2_no_dither; - cquantize->pub.finish_pass = finish_pass2; - - /* Make sure color count is acceptable */ - i = cinfo->actual_number_of_colors; - if (i < 1) - ERREXIT1(cinfo, JERR_QUANT_FEW_COLORS, 1); - if (i > MAXNUMCOLORS) - ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXNUMCOLORS); - - if (cinfo->dither_mode == JDITHER_FS) { - size_t arraysize = (size_t) ((cinfo->output_width + 2) * - (3 * SIZEOF(FSERROR))); - /* Allocate Floyd-Steinberg workspace if we didn't already. */ - if (cquantize->fserrors == NULL) - cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large) - ((j_common_ptr) cinfo, JPOOL_IMAGE, arraysize); - /* Initialize the propagated errors to zero. */ - jzero_far((void FAR *) cquantize->fserrors, arraysize); - /* Make the error-limit table if we didn't already. */ - if (cquantize->error_limiter == NULL) - init_error_limit(cinfo); - cquantize->on_odd_row = FALSE; - } - - } - /* Zero the histogram or inverse color map, if necessary */ - if (cquantize->needs_zeroed) { - for (i = 0; i < HIST_C0_ELEMS; i++) { - jzero_far((void FAR *) histogram[i], - HIST_C1_ELEMS*HIST_C2_ELEMS * SIZEOF(histcell)); - } - cquantize->needs_zeroed = FALSE; - } -} - - -/* - * Switch to a new external colormap between output passes. - */ - -METHODDEF(void) -new_color_map_2_quant (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - - /* Reset the inverse color map */ - cquantize->needs_zeroed = TRUE; -} - - -/* - * Module initialization routine for 2-pass color quantization. - */ - -GLOBAL(void) -jinit_2pass_quantizer (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize; - int i; - - cquantize = (my_cquantize_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_cquantizer)); - cinfo->cquantize = (struct jpeg_color_quantizer *) cquantize; - cquantize->pub.start_pass = start_pass_2_quant; - cquantize->pub.new_color_map = new_color_map_2_quant; - cquantize->fserrors = NULL; /* flag optional arrays not allocated */ - cquantize->error_limiter = NULL; - - /* Make sure jdmaster didn't give me a case I can't handle */ - if (cinfo->out_color_components != 3) - ERREXIT(cinfo, JERR_NOTIMPL); - - /* Allocate the histogram/inverse colormap storage */ - cquantize->histogram = (hist3d) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, HIST_C0_ELEMS * SIZEOF(hist2d)); - for (i = 0; i < HIST_C0_ELEMS; i++) { - cquantize->histogram[i] = (hist2d) (*cinfo->mem->alloc_large) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - HIST_C1_ELEMS*HIST_C2_ELEMS * SIZEOF(histcell)); - } - cquantize->needs_zeroed = TRUE; /* histogram is garbage now */ - - /* Allocate storage for the completed colormap, if required. - * We do this now since it is FAR storage and may affect - * the memory manager's space calculations. - */ - if (cinfo->enable_2pass_quant) { - /* Make sure color count is acceptable */ - int desired = cinfo->desired_number_of_colors; - /* Lower bound on # of colors ... somewhat arbitrary as long as > 0 */ - if (desired < 8) - ERREXIT1(cinfo, JERR_QUANT_FEW_COLORS, 8); - /* Make sure colormap indexes can be represented by JSAMPLEs */ - if (desired > MAXNUMCOLORS) - ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXNUMCOLORS); - cquantize->sv_colormap = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo,JPOOL_IMAGE, (JDIMENSION) desired, (JDIMENSION) 3); - cquantize->desired = desired; - } else - cquantize->sv_colormap = NULL; - - /* Only F-S dithering or no dithering is supported. */ - /* If user asks for ordered dither, give him F-S. */ - if (cinfo->dither_mode != JDITHER_NONE) - cinfo->dither_mode = JDITHER_FS; - - /* Allocate Floyd-Steinberg workspace if necessary. - * This isn't really needed until pass 2, but again it is FAR storage. - * Although we will cope with a later change in dither_mode, - * we do not promise to honor max_memory_to_use if dither_mode changes. - */ - if (cinfo->dither_mode == JDITHER_FS) { - cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (size_t) ((cinfo->output_width + 2) * (3 * SIZEOF(FSERROR)))); - /* Might as well create the error-limiting table too. */ - init_error_limit(cinfo); - } -} - -#endif /* QUANT_2PASS_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jutils.c b/irrlicht-1.6/source/Irrlicht/jpeglib/jutils.c deleted file mode 100644 index 286cda207..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jutils.c +++ /dev/null @@ -1,179 +0,0 @@ -/* - * jutils.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains tables and miscellaneous utility routines needed - * for both compression and decompression. - * Note we prefix all global names with "j" to minimize conflicts with - * a surrounding application. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * jpeg_zigzag_order[i] is the zigzag-order position of the i'th element - * of a DCT block read in natural order (left to right, top to bottom). - */ - -#if 0 /* This table is not actually needed in v6a */ - -const int jpeg_zigzag_order[DCTSIZE2] = { - 0, 1, 5, 6, 14, 15, 27, 28, - 2, 4, 7, 13, 16, 26, 29, 42, - 3, 8, 12, 17, 25, 30, 41, 43, - 9, 11, 18, 24, 31, 40, 44, 53, - 10, 19, 23, 32, 39, 45, 52, 54, - 20, 22, 33, 38, 46, 51, 55, 60, - 21, 34, 37, 47, 50, 56, 59, 61, - 35, 36, 48, 49, 57, 58, 62, 63 -}; - -#endif - -/* - * jpeg_natural_order[i] is the natural-order position of the i'th element - * of zigzag order. - * - * When reading corrupted data, the Huffman decoders could attempt - * to reference an entry beyond the end of this array (if the decoded - * zero run length reaches past the end of the block). To prevent - * wild stores without adding an inner-loop test, we put some extra - * "63"s after the real entries. This will cause the extra coefficient - * to be stored in location 63 of the block, not somewhere random. - * The worst case would be a run-length of 15, which means we need 16 - * fake entries. - */ - -const int jpeg_natural_order[DCTSIZE2+16] = { - 0, 1, 8, 16, 9, 2, 3, 10, - 17, 24, 32, 25, 18, 11, 4, 5, - 12, 19, 26, 33, 40, 48, 41, 34, - 27, 20, 13, 6, 7, 14, 21, 28, - 35, 42, 49, 56, 57, 50, 43, 36, - 29, 22, 15, 23, 30, 37, 44, 51, - 58, 59, 52, 45, 38, 31, 39, 46, - 53, 60, 61, 54, 47, 55, 62, 63, - 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */ - 63, 63, 63, 63, 63, 63, 63, 63 -}; - - -/* - * Arithmetic utilities - */ - -GLOBAL(long) -jdiv_round_up (long a, long b) -/* Compute a/b rounded up to next integer, ie, ceil(a/b) */ -/* Assumes a >= 0, b > 0 */ -{ - return (a + b - 1L) / b; -} - - -GLOBAL(long) -jround_up (long a, long b) -/* Compute a rounded up to next multiple of b, ie, ceil(a/b)*b */ -/* Assumes a >= 0, b > 0 */ -{ - a += b - 1L; - return a - (a % b); -} - - -/* On normal machines we can apply MEMCOPY() and MEMZERO() to sample arrays - * and coefficient-block arrays. This won't work on 80x86 because the arrays - * are FAR and we're assuming a small-pointer memory model. However, some - * DOS compilers provide far-pointer versions of memcpy() and memset() even - * in the small-model libraries. These will be used if USE_FMEM is defined. - * Otherwise, the routines below do it the hard way. (The performance cost - * is not all that great, because these routines aren't very heavily used.) - */ - -#ifndef NEED_FAR_POINTERS /* normal case, same as regular macros */ -#define FMEMCOPY(dest,src,size) MEMCOPY(dest,src,size) -#define FMEMZERO(target,size) MEMZERO(target,size) -#else /* 80x86 case, define if we can */ -#ifdef USE_FMEM -#define FMEMCOPY(dest,src,size) _fmemcpy((void FAR *)(dest), (const void FAR *)(src), (size_t)(size)) -#define FMEMZERO(target,size) _fmemset((void FAR *)(target), 0, (size_t)(size)) -#endif -#endif - - -GLOBAL(void) -jcopy_sample_rows (JSAMPARRAY input_array, int source_row, - JSAMPARRAY output_array, int dest_row, - int num_rows, JDIMENSION num_cols) -/* Copy some rows of samples from one place to another. - * num_rows rows are copied from input_array[source_row++] - * to output_array[dest_row++]; these areas may overlap for duplication. - * The source and destination arrays must be at least as wide as num_cols. - */ -{ - register JSAMPROW inptr, outptr; -#ifdef FMEMCOPY - register size_t count = (size_t) (num_cols * SIZEOF(JSAMPLE)); -#else - register JDIMENSION count; -#endif - register int row; - - input_array += source_row; - output_array += dest_row; - - for (row = num_rows; row > 0; row--) { - inptr = *input_array++; - outptr = *output_array++; -#ifdef FMEMCOPY - FMEMCOPY(outptr, inptr, count); -#else - for (count = num_cols; count > 0; count--) - *outptr++ = *inptr++; /* needn't bother with GETJSAMPLE() here */ -#endif - } -} - - -GLOBAL(void) -jcopy_block_row (JBLOCKROW input_row, JBLOCKROW output_row, - JDIMENSION num_blocks) -/* Copy a row of coefficient blocks from one place to another. */ -{ -#ifdef FMEMCOPY - FMEMCOPY(output_row, input_row, num_blocks * (DCTSIZE2 * SIZEOF(JCOEF))); -#else - register JCOEFPTR inptr, outptr; - register long count; - - inptr = (JCOEFPTR) input_row; - outptr = (JCOEFPTR) output_row; - for (count = (long) num_blocks * DCTSIZE2; count > 0; count--) { - *outptr++ = *inptr++; - } -#endif -} - - -GLOBAL(void) -jzero_far (void FAR * target, size_t bytestozero) -/* Zero out a chunk of FAR memory. */ -/* This might be sample-array data, block-array data, or alloc_large data. */ -{ -#ifdef FMEMZERO - FMEMZERO(target, bytestozero); -#else - register char FAR * ptr = (char FAR *) target; - register size_t count; - - for (count = bytestozero; count > 0; count--) { - *ptr++ = 0; - } -#endif -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/jversion.h b/irrlicht-1.6/source/Irrlicht/jpeglib/jversion.h deleted file mode 100644 index dadd453a4..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/jversion.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * jversion.h - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains software version identification. - */ - - -#define JVERSION "6b 27-Mar-1998" - -#define JCOPYRIGHT "Copyright (C) 1998, Thomas G. Lane" diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/libjpeg.doc b/irrlicht-1.6/source/Irrlicht/jpeglib/libjpeg.doc deleted file mode 100644 index f7410515d..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/libjpeg.doc +++ /dev/null @@ -1,3006 +0,0 @@ -USING THE IJG JPEG LIBRARY - -Copyright (C) 1994-1998, Thomas G. Lane. -This file is part of the Independent JPEG Group's software. -For conditions of distribution and use, see the accompanying README file. - - -This file describes how to use the IJG JPEG library within an application -program. Read it if you want to write a program that uses the library. - -The file example.c provides heavily commented skeleton code for calling the -JPEG library. Also see jpeglib.h (the include file to be used by application -programs) for full details about data structures and function parameter lists. -The library source code, of course, is the ultimate reference. - -Note that there have been *major* changes from the application interface -presented by IJG version 4 and earlier versions. The old design had several -inherent limitations, and it had accumulated a lot of cruft as we added -features while trying to minimize application-interface changes. We have -sacrificed backward compatibility in the version 5 rewrite, but we think the -improvements justify this. - - -TABLE OF CONTENTS ------------------ - -Overview: - Functions provided by the library - Outline of typical usage -Basic library usage: - Data formats - Compression details - Decompression details - Mechanics of usage: include files, linking, etc -Advanced features: - Compression parameter selection - Decompression parameter selection - Special color spaces - Error handling - Compressed data handling (source and destination managers) - I/O suspension - Progressive JPEG support - Buffered-image mode - Abbreviated datastreams and multiple images - Special markers - Raw (downsampled) image data - Really raw data: DCT coefficients - Progress monitoring - Memory management - Memory usage - Library compile-time options - Portability considerations - Notes for MS-DOS implementors - -You should read at least the overview and basic usage sections before trying -to program with the library. The sections on advanced features can be read -if and when you need them. - - -OVERVIEW -======== - -Functions provided by the library ---------------------------------- - -The IJG JPEG library provides C code to read and write JPEG-compressed image -files. The surrounding application program receives or supplies image data a -scanline at a time, using a straightforward uncompressed image format. All -details of color conversion and other preprocessing/postprocessing can be -handled by the library. - -The library includes a substantial amount of code that is not covered by the -JPEG standard but is necessary for typical applications of JPEG. These -functions preprocess the image before JPEG compression or postprocess it after -decompression. They include colorspace conversion, downsampling/upsampling, -and color quantization. The application indirectly selects use of this code -by specifying the format in which it wishes to supply or receive image data. -For example, if colormapped output is requested, then the decompression -library automatically invokes color quantization. - -A wide range of quality vs. speed tradeoffs are possible in JPEG processing, -and even more so in decompression postprocessing. The decompression library -provides multiple implementations that cover most of the useful tradeoffs, -ranging from very-high-quality down to fast-preview operation. On the -compression side we have generally not provided low-quality choices, since -compression is normally less time-critical. It should be understood that the -low-quality modes may not meet the JPEG standard's accuracy requirements; -nonetheless, they are useful for viewers. - -A word about functions *not* provided by the library. We handle a subset of -the ISO JPEG standard; most baseline, extended-sequential, and progressive -JPEG processes are supported. (Our subset includes all features now in common -use.) Unsupported ISO options include: - * Hierarchical storage - * Lossless JPEG - * Arithmetic entropy coding (unsupported for legal reasons) - * DNL marker - * Nonintegral subsampling ratios -We support both 8- and 12-bit data precision, but this is a compile-time -choice rather than a run-time choice; hence it is difficult to use both -precisions in a single application. - -By itself, the library handles only interchange JPEG datastreams --- in -particular the widely used JFIF file format. The library can be used by -surrounding code to process interchange or abbreviated JPEG datastreams that -are embedded in more complex file formats. (For example, this library is -used by the free LIBTIFF library to support JPEG compression in TIFF.) - - -Outline of typical usage ------------------------- - -The rough outline of a JPEG compression operation is: - - Allocate and initialize a JPEG compression object - Specify the destination for the compressed data (eg, a file) - Set parameters for compression, including image size & colorspace - jpeg_start_compress(...); - while (scan lines remain to be written) - jpeg_write_scanlines(...); - jpeg_finish_compress(...); - Release the JPEG compression object - -A JPEG compression object holds parameters and working state for the JPEG -library. We make creation/destruction of the object separate from starting -or finishing compression of an image; the same object can be re-used for a -series of image compression operations. This makes it easy to re-use the -same parameter settings for a sequence of images. Re-use of a JPEG object -also has important implications for processing abbreviated JPEG datastreams, -as discussed later. - -The image data to be compressed is supplied to jpeg_write_scanlines() from -in-memory buffers. If the application is doing file-to-file compression, -reading image data from the source file is the application's responsibility. -The library emits compressed data by calling a "data destination manager", -which typically will write the data into a file; but the application can -provide its own destination manager to do something else. - -Similarly, the rough outline of a JPEG decompression operation is: - - Allocate and initialize a JPEG decompression object - Specify the source of the compressed data (eg, a file) - Call jpeg_read_header() to obtain image info - Set parameters for decompression - jpeg_start_decompress(...); - while (scan lines remain to be read) - jpeg_read_scanlines(...); - jpeg_finish_decompress(...); - Release the JPEG decompression object - -This is comparable to the compression outline except that reading the -datastream header is a separate step. This is helpful because information -about the image's size, colorspace, etc is available when the application -selects decompression parameters. For example, the application can choose an -output scaling ratio that will fit the image into the available screen size. - -The decompression library obtains compressed data by calling a data source -manager, which typically will read the data from a file; but other behaviors -can be obtained with a custom source manager. Decompressed data is delivered -into in-memory buffers passed to jpeg_read_scanlines(). - -It is possible to abort an incomplete compression or decompression operation -by calling jpeg_abort(); or, if you do not need to retain the JPEG object, -simply release it by calling jpeg_destroy(). - -JPEG compression and decompression objects are two separate struct types. -However, they share some common fields, and certain routines such as -jpeg_destroy() can work on either type of object. - -The JPEG library has no static variables: all state is in the compression -or decompression object. Therefore it is possible to process multiple -compression and decompression operations concurrently, using multiple JPEG -objects. - -Both compression and decompression can be done in an incremental memory-to- -memory fashion, if suitable source/destination managers are used. See the -section on "I/O suspension" for more details. - - -BASIC LIBRARY USAGE -=================== - -Data formats ------------- - -Before diving into procedural details, it is helpful to understand the -image data format that the JPEG library expects or returns. - -The standard input image format is a rectangular array of pixels, with each -pixel having the same number of "component" or "sample" values (color -channels). You must specify how many components there are and the colorspace -interpretation of the components. Most applications will use RGB data -(three components per pixel) or grayscale data (one component per pixel). -PLEASE NOTE THAT RGB DATA IS THREE SAMPLES PER PIXEL, GRAYSCALE ONLY ONE. -A remarkable number of people manage to miss this, only to find that their -programs don't work with grayscale JPEG files. - -There is no provision for colormapped input. JPEG files are always full-color -or full grayscale (or sometimes another colorspace such as CMYK). You can -feed in a colormapped image by expanding it to full-color format. However -JPEG often doesn't work very well with source data that has been colormapped, -because of dithering noise. This is discussed in more detail in the JPEG FAQ -and the other references mentioned in the README file. - -Pixels are stored by scanlines, with each scanline running from left to -right. The component values for each pixel are adjacent in the row; for -example, R,G,B,R,G,B,R,G,B,... for 24-bit RGB color. Each scanline is an -array of data type JSAMPLE --- which is typically "unsigned char", unless -you've changed jmorecfg.h. (You can also change the RGB pixel layout, say -to B,G,R order, by modifying jmorecfg.h. But see the restrictions listed in -that file before doing so.) - -A 2-D array of pixels is formed by making a list of pointers to the starts of -scanlines; so the scanlines need not be physically adjacent in memory. Even -if you process just one scanline at a time, you must make a one-element -pointer array to conform to this structure. Pointers to JSAMPLE rows are of -type JSAMPROW, and the pointer to the pointer array is of type JSAMPARRAY. - -The library accepts or supplies one or more complete scanlines per call. -It is not possible to process part of a row at a time. Scanlines are always -processed top-to-bottom. You can process an entire image in one call if you -have it all in memory, but usually it's simplest to process one scanline at -a time. - -For best results, source data values should have the precision specified by -BITS_IN_JSAMPLE (normally 8 bits). For instance, if you choose to compress -data that's only 6 bits/channel, you should left-justify each value in a -byte before passing it to the compressor. If you need to compress data -that has more than 8 bits/channel, compile with BITS_IN_JSAMPLE = 12. -(See "Library compile-time options", later.) - - -The data format returned by the decompressor is the same in all details, -except that colormapped output is supported. (Again, a JPEG file is never -colormapped. But you can ask the decompressor to perform on-the-fly color -quantization to deliver colormapped output.) If you request colormapped -output then the returned data array contains a single JSAMPLE per pixel; -its value is an index into a color map. The color map is represented as -a 2-D JSAMPARRAY in which each row holds the values of one color component, -that is, colormap[i][j] is the value of the i'th color component for pixel -value (map index) j. Note that since the colormap indexes are stored in -JSAMPLEs, the maximum number of colors is limited by the size of JSAMPLE -(ie, at most 256 colors for an 8-bit JPEG library). - - -Compression details -------------------- - -Here we revisit the JPEG compression outline given in the overview. - -1. Allocate and initialize a JPEG compression object. - -A JPEG compression object is a "struct jpeg_compress_struct". (It also has -a bunch of subsidiary structures which are allocated via malloc(), but the -application doesn't control those directly.) This struct can be just a local -variable in the calling routine, if a single routine is going to execute the -whole JPEG compression sequence. Otherwise it can be static or allocated -from malloc(). - -You will also need a structure representing a JPEG error handler. The part -of this that the library cares about is a "struct jpeg_error_mgr". If you -are providing your own error handler, you'll typically want to embed the -jpeg_error_mgr struct in a larger structure; this is discussed later under -"Error handling". For now we'll assume you are just using the default error -handler. The default error handler will print JPEG error/warning messages -on stderr, and it will call exit() if a fatal error occurs. - -You must initialize the error handler structure, store a pointer to it into -the JPEG object's "err" field, and then call jpeg_create_compress() to -initialize the rest of the JPEG object. - -Typical code for this step, if you are using the default error handler, is - - struct jpeg_compress_struct cinfo; - struct jpeg_error_mgr jerr; - ... - cinfo.err = jpeg_std_error(&jerr); - jpeg_create_compress(&cinfo); - -jpeg_create_compress allocates a small amount of memory, so it could fail -if you are out of memory. In that case it will exit via the error handler; -that's why the error handler must be initialized first. - - -2. Specify the destination for the compressed data (eg, a file). - -As previously mentioned, the JPEG library delivers compressed data to a -"data destination" module. The library includes one data destination -module which knows how to write to a stdio stream. You can use your own -destination module if you want to do something else, as discussed later. - -If you use the standard destination module, you must open the target stdio -stream beforehand. Typical code for this step looks like: - - FILE * outfile; - ... - if ((outfile = fopen(filename, "wb")) == NULL) { - fprintf(stderr, "can't open %s\n", filename); - exit(1); - } - jpeg_stdio_dest(&cinfo, outfile); - -where the last line invokes the standard destination module. - -WARNING: it is critical that the binary compressed data be delivered to the -output file unchanged. On non-Unix systems the stdio library may perform -newline translation or otherwise corrupt binary data. To suppress this -behavior, you may need to use a "b" option to fopen (as shown above), or use -setmode() or another routine to put the stdio stream in binary mode. See -cjpeg.c and djpeg.c for code that has been found to work on many systems. - -You can select the data destination after setting other parameters (step 3), -if that's more convenient. You may not change the destination between -calling jpeg_start_compress() and jpeg_finish_compress(). - - -3. Set parameters for compression, including image size & colorspace. - -You must supply information about the source image by setting the following -fields in the JPEG object (cinfo structure): - - image_width Width of image, in pixels - image_height Height of image, in pixels - input_components Number of color channels (samples per pixel) - in_color_space Color space of source image - -The image dimensions are, hopefully, obvious. JPEG supports image dimensions -of 1 to 64K pixels in either direction. The input color space is typically -RGB or grayscale, and input_components is 3 or 1 accordingly. (See "Special -color spaces", later, for more info.) The in_color_space field must be -assigned one of the J_COLOR_SPACE enum constants, typically JCS_RGB or -JCS_GRAYSCALE. - -JPEG has a large number of compression parameters that determine how the -image is encoded. Most applications don't need or want to know about all -these parameters. You can set all the parameters to reasonable defaults by -calling jpeg_set_defaults(); then, if there are particular values you want -to change, you can do so after that. The "Compression parameter selection" -section tells about all the parameters. - -You must set in_color_space correctly before calling jpeg_set_defaults(), -because the defaults depend on the source image colorspace. However the -other three source image parameters need not be valid until you call -jpeg_start_compress(). There's no harm in calling jpeg_set_defaults() more -than once, if that happens to be convenient. - -Typical code for a 24-bit RGB source image is - - cinfo.image_width = Width; /* image width and height, in pixels */ - cinfo.image_height = Height; - cinfo.input_components = 3; /* # of color components per pixel */ - cinfo.in_color_space = JCS_RGB; /* colorspace of input image */ - - jpeg_set_defaults(&cinfo); - /* Make optional parameter settings here */ - - -4. jpeg_start_compress(...); - -After you have established the data destination and set all the necessary -source image info and other parameters, call jpeg_start_compress() to begin -a compression cycle. This will initialize internal state, allocate working -storage, and emit the first few bytes of the JPEG datastream header. - -Typical code: - - jpeg_start_compress(&cinfo, TRUE); - -The "TRUE" parameter ensures that a complete JPEG interchange datastream -will be written. This is appropriate in most cases. If you think you might -want to use an abbreviated datastream, read the section on abbreviated -datastreams, below. - -Once you have called jpeg_start_compress(), you may not alter any JPEG -parameters or other fields of the JPEG object until you have completed -the compression cycle. - - -5. while (scan lines remain to be written) - jpeg_write_scanlines(...); - -Now write all the required image data by calling jpeg_write_scanlines() -one or more times. You can pass one or more scanlines in each call, up -to the total image height. In most applications it is convenient to pass -just one or a few scanlines at a time. The expected format for the passed -data is discussed under "Data formats", above. - -Image data should be written in top-to-bottom scanline order. The JPEG spec -contains some weasel wording about how top and bottom are application-defined -terms (a curious interpretation of the English language...) but if you want -your files to be compatible with everyone else's, you WILL use top-to-bottom -order. If the source data must be read in bottom-to-top order, you can use -the JPEG library's virtual array mechanism to invert the data efficiently. -Examples of this can be found in the sample application cjpeg. - -The library maintains a count of the number of scanlines written so far -in the next_scanline field of the JPEG object. Usually you can just use -this variable as the loop counter, so that the loop test looks like -"while (cinfo.next_scanline < cinfo.image_height)". - -Code for this step depends heavily on the way that you store the source data. -example.c shows the following code for the case of a full-size 2-D source -array containing 3-byte RGB pixels: - - JSAMPROW row_pointer[1]; /* pointer to a single row */ - int row_stride; /* physical row width in buffer */ - - row_stride = image_width * 3; /* JSAMPLEs per row in image_buffer */ - - while (cinfo.next_scanline < cinfo.image_height) { - row_pointer[0] = & image_buffer[cinfo.next_scanline * row_stride]; - jpeg_write_scanlines(&cinfo, row_pointer, 1); - } - -jpeg_write_scanlines() returns the number of scanlines actually written. -This will normally be equal to the number passed in, so you can usually -ignore the return value. It is different in just two cases: - * If you try to write more scanlines than the declared image height, - the additional scanlines are ignored. - * If you use a suspending data destination manager, output buffer overrun - will cause the compressor to return before accepting all the passed lines. - This feature is discussed under "I/O suspension", below. The normal - stdio destination manager will NOT cause this to happen. -In any case, the return value is the same as the change in the value of -next_scanline. - - -6. jpeg_finish_compress(...); - -After all the image data has been written, call jpeg_finish_compress() to -complete the compression cycle. This step is ESSENTIAL to ensure that the -last bufferload of data is written to the data destination. -jpeg_finish_compress() also releases working memory associated with the JPEG -object. - -Typical code: - - jpeg_finish_compress(&cinfo); - -If using the stdio destination manager, don't forget to close the output -stdio stream (if necessary) afterwards. - -If you have requested a multi-pass operating mode, such as Huffman code -optimization, jpeg_finish_compress() will perform the additional passes using -data buffered by the first pass. In this case jpeg_finish_compress() may take -quite a while to complete. With the default compression parameters, this will -not happen. - -It is an error to call jpeg_finish_compress() before writing the necessary -total number of scanlines. If you wish to abort compression, call -jpeg_abort() as discussed below. - -After completing a compression cycle, you may dispose of the JPEG object -as discussed next, or you may use it to compress another image. In that case -return to step 2, 3, or 4 as appropriate. If you do not change the -destination manager, the new datastream will be written to the same target. -If you do not change any JPEG parameters, the new datastream will be written -with the same parameters as before. Note that you can change the input image -dimensions freely between cycles, but if you change the input colorspace, you -should call jpeg_set_defaults() to adjust for the new colorspace; and then -you'll need to repeat all of step 3. - - -7. Release the JPEG compression object. - -When you are done with a JPEG compression object, destroy it by calling -jpeg_destroy_compress(). This will free all subsidiary memory (regardless of -the previous state of the object). Or you can call jpeg_destroy(), which -works for either compression or decompression objects --- this may be more -convenient if you are sharing code between compression and decompression -cases. (Actually, these routines are equivalent except for the declared type -of the passed pointer. To avoid gripes from ANSI C compilers, jpeg_destroy() -should be passed a j_common_ptr.) - -If you allocated the jpeg_compress_struct structure from malloc(), freeing -it is your responsibility --- jpeg_destroy() won't. Ditto for the error -handler structure. - -Typical code: - - jpeg_destroy_compress(&cinfo); - - -8. Aborting. - -If you decide to abort a compression cycle before finishing, you can clean up -in either of two ways: - -* If you don't need the JPEG object any more, just call - jpeg_destroy_compress() or jpeg_destroy() to release memory. This is - legitimate at any point after calling jpeg_create_compress() --- in fact, - it's safe even if jpeg_create_compress() fails. - -* If you want to re-use the JPEG object, call jpeg_abort_compress(), or call - jpeg_abort() which works on both compression and decompression objects. - This will return the object to an idle state, releasing any working memory. - jpeg_abort() is allowed at any time after successful object creation. - -Note that cleaning up the data destination, if required, is your -responsibility; neither of these routines will call term_destination(). -(See "Compressed data handling", below, for more about that.) - -jpeg_destroy() and jpeg_abort() are the only safe calls to make on a JPEG -object that has reported an error by calling error_exit (see "Error handling" -for more info). The internal state of such an object is likely to be out of -whack. Either of these two routines will return the object to a known state. - - -Decompression details ---------------------- - -Here we revisit the JPEG decompression outline given in the overview. - -1. Allocate and initialize a JPEG decompression object. - -This is just like initialization for compression, as discussed above, -except that the object is a "struct jpeg_decompress_struct" and you -call jpeg_create_decompress(). Error handling is exactly the same. - -Typical code: - - struct jpeg_decompress_struct cinfo; - struct jpeg_error_mgr jerr; - ... - cinfo.err = jpeg_std_error(&jerr); - jpeg_create_decompress(&cinfo); - -(Both here and in the IJG code, we usually use variable name "cinfo" for -both compression and decompression objects.) - - -2. Specify the source of the compressed data (eg, a file). - -As previously mentioned, the JPEG library reads compressed data from a "data -source" module. The library includes one data source module which knows how -to read from a stdio stream. You can use your own source module if you want -to do something else, as discussed later. - -If you use the standard source module, you must open the source stdio stream -beforehand. Typical code for this step looks like: - - FILE * infile; - ... - if ((infile = fopen(filename, "rb")) == NULL) { - fprintf(stderr, "can't open %s\n", filename); - exit(1); - } - jpeg_stdio_src(&cinfo, infile); - -where the last line invokes the standard source module. - -WARNING: it is critical that the binary compressed data be read unchanged. -On non-Unix systems the stdio library may perform newline translation or -otherwise corrupt binary data. To suppress this behavior, you may need to use -a "b" option to fopen (as shown above), or use setmode() or another routine to -put the stdio stream in binary mode. See cjpeg.c and djpeg.c for code that -has been found to work on many systems. - -You may not change the data source between calling jpeg_read_header() and -jpeg_finish_decompress(). If you wish to read a series of JPEG images from -a single source file, you should repeat the jpeg_read_header() to -jpeg_finish_decompress() sequence without reinitializing either the JPEG -object or the data source module; this prevents buffered input data from -being discarded. - - -3. Call jpeg_read_header() to obtain image info. - -Typical code for this step is just - - jpeg_read_header(&cinfo, TRUE); - -This will read the source datastream header markers, up to the beginning -of the compressed data proper. On return, the image dimensions and other -info have been stored in the JPEG object. The application may wish to -consult this information before selecting decompression parameters. - -More complex code is necessary if - * A suspending data source is used --- in that case jpeg_read_header() - may return before it has read all the header data. See "I/O suspension", - below. The normal stdio source manager will NOT cause this to happen. - * Abbreviated JPEG files are to be processed --- see the section on - abbreviated datastreams. Standard applications that deal only in - interchange JPEG files need not be concerned with this case either. - -It is permissible to stop at this point if you just wanted to find out the -image dimensions and other header info for a JPEG file. In that case, -call jpeg_destroy() when you are done with the JPEG object, or call -jpeg_abort() to return it to an idle state before selecting a new data -source and reading another header. - - -4. Set parameters for decompression. - -jpeg_read_header() sets appropriate default decompression parameters based on -the properties of the image (in particular, its colorspace). However, you -may well want to alter these defaults before beginning the decompression. -For example, the default is to produce full color output from a color file. -If you want colormapped output you must ask for it. Other options allow the -returned image to be scaled and allow various speed/quality tradeoffs to be -selected. "Decompression parameter selection", below, gives details. - -If the defaults are appropriate, nothing need be done at this step. - -Note that all default values are set by each call to jpeg_read_header(). -If you reuse a decompression object, you cannot expect your parameter -settings to be preserved across cycles, as you can for compression. -You must set desired parameter values each time. - - -5. jpeg_start_decompress(...); - -Once the parameter values are satisfactory, call jpeg_start_decompress() to -begin decompression. This will initialize internal state, allocate working -memory, and prepare for returning data. - -Typical code is just - - jpeg_start_decompress(&cinfo); - -If you have requested a multi-pass operating mode, such as 2-pass color -quantization, jpeg_start_decompress() will do everything needed before data -output can begin. In this case jpeg_start_decompress() may take quite a while -to complete. With a single-scan (non progressive) JPEG file and default -decompression parameters, this will not happen; jpeg_start_decompress() will -return quickly. - -After this call, the final output image dimensions, including any requested -scaling, are available in the JPEG object; so is the selected colormap, if -colormapped output has been requested. Useful fields include - - output_width image width and height, as scaled - output_height - out_color_components # of color components in out_color_space - output_components # of color components returned per pixel - colormap the selected colormap, if any - actual_number_of_colors number of entries in colormap - -output_components is 1 (a colormap index) when quantizing colors; otherwise it -equals out_color_components. It is the number of JSAMPLE values that will be -emitted per pixel in the output arrays. - -Typically you will need to allocate data buffers to hold the incoming image. -You will need output_width * output_components JSAMPLEs per scanline in your -output buffer, and a total of output_height scanlines will be returned. - -Note: if you are using the JPEG library's internal memory manager to allocate -data buffers (as djpeg does), then the manager's protocol requires that you -request large buffers *before* calling jpeg_start_decompress(). This is a -little tricky since the output_XXX fields are not normally valid then. You -can make them valid by calling jpeg_calc_output_dimensions() after setting the -relevant parameters (scaling, output color space, and quantization flag). - - -6. while (scan lines remain to be read) - jpeg_read_scanlines(...); - -Now you can read the decompressed image data by calling jpeg_read_scanlines() -one or more times. At each call, you pass in the maximum number of scanlines -to be read (ie, the height of your working buffer); jpeg_read_scanlines() -will return up to that many lines. The return value is the number of lines -actually read. The format of the returned data is discussed under "Data -formats", above. Don't forget that grayscale and color JPEGs will return -different data formats! - -Image data is returned in top-to-bottom scanline order. If you must write -out the image in bottom-to-top order, you can use the JPEG library's virtual -array mechanism to invert the data efficiently. Examples of this can be -found in the sample application djpeg. - -The library maintains a count of the number of scanlines returned so far -in the output_scanline field of the JPEG object. Usually you can just use -this variable as the loop counter, so that the loop test looks like -"while (cinfo.output_scanline < cinfo.output_height)". (Note that the test -should NOT be against image_height, unless you never use scaling. The -image_height field is the height of the original unscaled image.) -The return value always equals the change in the value of output_scanline. - -If you don't use a suspending data source, it is safe to assume that -jpeg_read_scanlines() reads at least one scanline per call, until the -bottom of the image has been reached. - -If you use a buffer larger than one scanline, it is NOT safe to assume that -jpeg_read_scanlines() fills it. (The current implementation returns only a -few scanlines per call, no matter how large a buffer you pass.) So you must -always provide a loop that calls jpeg_read_scanlines() repeatedly until the -whole image has been read. - - -7. jpeg_finish_decompress(...); - -After all the image data has been read, call jpeg_finish_decompress() to -complete the decompression cycle. This causes working memory associated -with the JPEG object to be released. - -Typical code: - - jpeg_finish_decompress(&cinfo); - -If using the stdio source manager, don't forget to close the source stdio -stream if necessary. - -It is an error to call jpeg_finish_decompress() before reading the correct -total number of scanlines. If you wish to abort decompression, call -jpeg_abort() as discussed below. - -After completing a decompression cycle, you may dispose of the JPEG object as -discussed next, or you may use it to decompress another image. In that case -return to step 2 or 3 as appropriate. If you do not change the source -manager, the next image will be read from the same source. - - -8. Release the JPEG decompression object. - -When you are done with a JPEG decompression object, destroy it by calling -jpeg_destroy_decompress() or jpeg_destroy(). The previous discussion of -destroying compression objects applies here too. - -Typical code: - - jpeg_destroy_decompress(&cinfo); - - -9. Aborting. - -You can abort a decompression cycle by calling jpeg_destroy_decompress() or -jpeg_destroy() if you don't need the JPEG object any more, or -jpeg_abort_decompress() or jpeg_abort() if you want to reuse the object. -The previous discussion of aborting compression cycles applies here too. - - -Mechanics of usage: include files, linking, etc ------------------------------------------------ - -Applications using the JPEG library should include the header file jpeglib.h -to obtain declarations of data types and routines. Before including -jpeglib.h, include system headers that define at least the typedefs FILE and -size_t. On ANSI-conforming systems, including <stdio.h> is sufficient; on -older Unix systems, you may need <sys/types.h> to define size_t. - -If the application needs to refer to individual JPEG library error codes, also -include jerror.h to define those symbols. - -jpeglib.h indirectly includes the files jconfig.h and jmorecfg.h. If you are -installing the JPEG header files in a system directory, you will want to -install all four files: jpeglib.h, jerror.h, jconfig.h, jmorecfg.h. - -The most convenient way to include the JPEG code into your executable program -is to prepare a library file ("libjpeg.a", or a corresponding name on non-Unix -machines) and reference it at your link step. If you use only half of the -library (only compression or only decompression), only that much code will be -included from the library, unless your linker is hopelessly brain-damaged. -The supplied makefiles build libjpeg.a automatically (see install.doc). - -While you can build the JPEG library as a shared library if the whim strikes -you, we don't really recommend it. The trouble with shared libraries is that -at some point you'll probably try to substitute a new version of the library -without recompiling the calling applications. That generally doesn't work -because the parameter struct declarations usually change with each new -version. In other words, the library's API is *not* guaranteed binary -compatible across versions; we only try to ensure source-code compatibility. -(In hindsight, it might have been smarter to hide the parameter structs from -applications and introduce a ton of access functions instead. Too late now, -however.) - -On some systems your application may need to set up a signal handler to ensure -that temporary files are deleted if the program is interrupted. This is most -critical if you are on MS-DOS and use the jmemdos.c memory manager back end; -it will try to grab extended memory for temp files, and that space will NOT be -freed automatically. See cjpeg.c or djpeg.c for an example signal handler. - -It may be worth pointing out that the core JPEG library does not actually -require the stdio library: only the default source/destination managers and -error handler need it. You can use the library in a stdio-less environment -if you replace those modules and use jmemnobs.c (or another memory manager of -your own devising). More info about the minimum system library requirements -may be found in jinclude.h. - - -ADVANCED FEATURES -================= - -Compression parameter selection -------------------------------- - -This section describes all the optional parameters you can set for JPEG -compression, as well as the "helper" routines provided to assist in this -task. Proper setting of some parameters requires detailed understanding -of the JPEG standard; if you don't know what a parameter is for, it's best -not to mess with it! See REFERENCES in the README file for pointers to -more info about JPEG. - -It's a good idea to call jpeg_set_defaults() first, even if you plan to set -all the parameters; that way your code is more likely to work with future JPEG -libraries that have additional parameters. For the same reason, we recommend -you use a helper routine where one is provided, in preference to twiddling -cinfo fields directly. - -The helper routines are: - -jpeg_set_defaults (j_compress_ptr cinfo) - This routine sets all JPEG parameters to reasonable defaults, using - only the input image's color space (field in_color_space, which must - already be set in cinfo). Many applications will only need to use - this routine and perhaps jpeg_set_quality(). - -jpeg_set_colorspace (j_compress_ptr cinfo, J_COLOR_SPACE colorspace) - Sets the JPEG file's colorspace (field jpeg_color_space) as specified, - and sets other color-space-dependent parameters appropriately. See - "Special color spaces", below, before using this. A large number of - parameters, including all per-component parameters, are set by this - routine; if you want to twiddle individual parameters you should call - jpeg_set_colorspace() before rather than after. - -jpeg_default_colorspace (j_compress_ptr cinfo) - Selects an appropriate JPEG colorspace based on cinfo->in_color_space, - and calls jpeg_set_colorspace(). This is actually a subroutine of - jpeg_set_defaults(). It's broken out in case you want to change - just the colorspace-dependent JPEG parameters. - -jpeg_set_quality (j_compress_ptr cinfo, int quality, boolean force_baseline) - Constructs JPEG quantization tables appropriate for the indicated - quality setting. The quality value is expressed on the 0..100 scale - recommended by IJG (cjpeg's "-quality" switch uses this routine). - Note that the exact mapping from quality values to tables may change - in future IJG releases as more is learned about DCT quantization. - If the force_baseline parameter is TRUE, then the quantization table - entries are constrained to the range 1..255 for full JPEG baseline - compatibility. In the current implementation, this only makes a - difference for quality settings below 25, and it effectively prevents - very small/low quality files from being generated. The IJG decoder - is capable of reading the non-baseline files generated at low quality - settings when force_baseline is FALSE, but other decoders may not be. - -jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor, - boolean force_baseline) - Same as jpeg_set_quality() except that the generated tables are the - sample tables given in the JPEC spec section K.1, multiplied by the - specified scale factor (which is expressed as a percentage; thus - scale_factor = 100 reproduces the spec's tables). Note that larger - scale factors give lower quality. This entry point is useful for - conforming to the Adobe PostScript DCT conventions, but we do not - recommend linear scaling as a user-visible quality scale otherwise. - force_baseline again constrains the computed table entries to 1..255. - -int jpeg_quality_scaling (int quality) - Converts a value on the IJG-recommended quality scale to a linear - scaling percentage. Note that this routine may change or go away - in future releases --- IJG may choose to adopt a scaling method that - can't be expressed as a simple scalar multiplier, in which case the - premise of this routine collapses. Caveat user. - -jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl, - const unsigned int *basic_table, - int scale_factor, boolean force_baseline) - Allows an arbitrary quantization table to be created. which_tbl - indicates which table slot to fill. basic_table points to an array - of 64 unsigned ints given in normal array order. These values are - multiplied by scale_factor/100 and then clamped to the range 1..65535 - (or to 1..255 if force_baseline is TRUE). - CAUTION: prior to library version 6a, jpeg_add_quant_table expected - the basic table to be given in JPEG zigzag order. If you need to - write code that works with either older or newer versions of this - routine, you must check the library version number. Something like - "#if JPEG_LIB_VERSION >= 61" is the right test. - -jpeg_simple_progression (j_compress_ptr cinfo) - Generates a default scan script for writing a progressive-JPEG file. - This is the recommended method of creating a progressive file, - unless you want to make a custom scan sequence. You must ensure that - the JPEG color space is set correctly before calling this routine. - - -Compression parameters (cinfo fields) include: - -J_DCT_METHOD dct_method - Selects the algorithm used for the DCT step. Choices are: - JDCT_ISLOW: slow but accurate integer algorithm - JDCT_IFAST: faster, less accurate integer method - JDCT_FLOAT: floating-point method - JDCT_DEFAULT: default method (normally JDCT_ISLOW) - JDCT_FASTEST: fastest method (normally JDCT_IFAST) - The FLOAT method is very slightly more accurate than the ISLOW method, - but may give different results on different machines due to varying - roundoff behavior. The integer methods should give the same results - on all machines. On machines with sufficiently fast FP hardware, the - floating-point method may also be the fastest. The IFAST method is - considerably less accurate than the other two; its use is not - recommended if high quality is a concern. JDCT_DEFAULT and - JDCT_FASTEST are macros configurable by each installation. - -J_COLOR_SPACE jpeg_color_space -int num_components - The JPEG color space and corresponding number of components; see - "Special color spaces", below, for more info. We recommend using - jpeg_set_color_space() if you want to change these. - -boolean optimize_coding - TRUE causes the compressor to compute optimal Huffman coding tables - for the image. This requires an extra pass over the data and - therefore costs a good deal of space and time. The default is - FALSE, which tells the compressor to use the supplied or default - Huffman tables. In most cases optimal tables save only a few percent - of file size compared to the default tables. Note that when this is - TRUE, you need not supply Huffman tables at all, and any you do - supply will be overwritten. - -unsigned int restart_interval -int restart_in_rows - To emit restart markers in the JPEG file, set one of these nonzero. - Set restart_interval to specify the exact interval in MCU blocks. - Set restart_in_rows to specify the interval in MCU rows. (If - restart_in_rows is not 0, then restart_interval is set after the - image width in MCUs is computed.) Defaults are zero (no restarts). - One restart marker per MCU row is often a good choice. - NOTE: the overhead of restart markers is higher in grayscale JPEG - files than in color files, and MUCH higher in progressive JPEGs. - If you use restarts, you may want to use larger intervals in those - cases. - -const jpeg_scan_info * scan_info -int num_scans - By default, scan_info is NULL; this causes the compressor to write a - single-scan sequential JPEG file. If not NULL, scan_info points to - an array of scan definition records of length num_scans. The - compressor will then write a JPEG file having one scan for each scan - definition record. This is used to generate noninterleaved or - progressive JPEG files. The library checks that the scan array - defines a valid JPEG scan sequence. (jpeg_simple_progression creates - a suitable scan definition array for progressive JPEG.) This is - discussed further under "Progressive JPEG support". - -int smoothing_factor - If non-zero, the input image is smoothed; the value should be 1 for - minimal smoothing to 100 for maximum smoothing. Consult jcsample.c - for details of the smoothing algorithm. The default is zero. - -boolean write_JFIF_header - If TRUE, a JFIF APP0 marker is emitted. jpeg_set_defaults() and - jpeg_set_colorspace() set this TRUE if a JFIF-legal JPEG color space - (ie, YCbCr or grayscale) is selected, otherwise FALSE. - -UINT8 JFIF_major_version -UINT8 JFIF_minor_version - The version number to be written into the JFIF marker. - jpeg_set_defaults() initializes the version to 1.01 (major=minor=1). - You should set it to 1.02 (major=1, minor=2) if you plan to write - any JFIF 1.02 extension markers. - -UINT8 density_unit -UINT16 X_density -UINT16 Y_density - The resolution information to be written into the JFIF marker; - not used otherwise. density_unit may be 0 for unknown, - 1 for dots/inch, or 2 for dots/cm. The default values are 0,1,1 - indicating square pixels of unknown size. - -boolean write_Adobe_marker - If TRUE, an Adobe APP14 marker is emitted. jpeg_set_defaults() and - jpeg_set_colorspace() set this TRUE if JPEG color space RGB, CMYK, - or YCCK is selected, otherwise FALSE. It is generally a bad idea - to set both write_JFIF_header and write_Adobe_marker. In fact, - you probably shouldn't change the default settings at all --- the - default behavior ensures that the JPEG file's color space can be - recognized by the decoder. - -JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS] - Pointers to coefficient quantization tables, one per table slot, - or NULL if no table is defined for a slot. Usually these should - be set via one of the above helper routines; jpeg_add_quant_table() - is general enough to define any quantization table. The other - routines will set up table slot 0 for luminance quality and table - slot 1 for chrominance. - -JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS] -JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS] - Pointers to Huffman coding tables, one per table slot, or NULL if - no table is defined for a slot. Slots 0 and 1 are filled with the - JPEG sample tables by jpeg_set_defaults(). If you need to allocate - more table structures, jpeg_alloc_huff_table() may be used. - Note that optimal Huffman tables can be computed for an image - by setting optimize_coding, as discussed above; there's seldom - any need to mess with providing your own Huffman tables. - -There are some additional cinfo fields which are not documented here -because you currently can't change them; for example, you can't set -arith_code TRUE because arithmetic coding is unsupported. - - -Per-component parameters are stored in the struct cinfo.comp_info[i] for -component number i. Note that components here refer to components of the -JPEG color space, *not* the source image color space. A suitably large -comp_info[] array is allocated by jpeg_set_defaults(); if you choose not -to use that routine, it's up to you to allocate the array. - -int component_id - The one-byte identifier code to be recorded in the JPEG file for - this component. For the standard color spaces, we recommend you - leave the default values alone. - -int h_samp_factor -int v_samp_factor - Horizontal and vertical sampling factors for the component; must - be 1..4 according to the JPEG standard. Note that larger sampling - factors indicate a higher-resolution component; many people find - this behavior quite unintuitive. The default values are 2,2 for - luminance components and 1,1 for chrominance components, except - for grayscale where 1,1 is used. - -int quant_tbl_no - Quantization table number for component. The default value is - 0 for luminance components and 1 for chrominance components. - -int dc_tbl_no -int ac_tbl_no - DC and AC entropy coding table numbers. The default values are - 0 for luminance components and 1 for chrominance components. - -int component_index - Must equal the component's index in comp_info[]. (Beginning in - release v6, the compressor library will fill this in automatically; - you don't have to.) - - -Decompression parameter selection ---------------------------------- - -Decompression parameter selection is somewhat simpler than compression -parameter selection, since all of the JPEG internal parameters are -recorded in the source file and need not be supplied by the application. -(Unless you are working with abbreviated files, in which case see -"Abbreviated datastreams", below.) Decompression parameters control -the postprocessing done on the image to deliver it in a format suitable -for the application's use. Many of the parameters control speed/quality -tradeoffs, in which faster decompression may be obtained at the price of -a poorer-quality image. The defaults select the highest quality (slowest) -processing. - -The following fields in the JPEG object are set by jpeg_read_header() and -may be useful to the application in choosing decompression parameters: - -JDIMENSION image_width Width and height of image -JDIMENSION image_height -int num_components Number of color components -J_COLOR_SPACE jpeg_color_space Colorspace of image -boolean saw_JFIF_marker TRUE if a JFIF APP0 marker was seen - UINT8 JFIF_major_version Version information from JFIF marker - UINT8 JFIF_minor_version - UINT8 density_unit Resolution data from JFIF marker - UINT16 X_density - UINT16 Y_density -boolean saw_Adobe_marker TRUE if an Adobe APP14 marker was seen - UINT8 Adobe_transform Color transform code from Adobe marker - -The JPEG color space, unfortunately, is something of a guess since the JPEG -standard proper does not provide a way to record it. In practice most files -adhere to the JFIF or Adobe conventions, and the decoder will recognize these -correctly. See "Special color spaces", below, for more info. - - -The decompression parameters that determine the basic properties of the -returned image are: - -J_COLOR_SPACE out_color_space - Output color space. jpeg_read_header() sets an appropriate default - based on jpeg_color_space; typically it will be RGB or grayscale. - The application can change this field to request output in a different - colorspace. For example, set it to JCS_GRAYSCALE to get grayscale - output from a color file. (This is useful for previewing: grayscale - output is faster than full color since the color components need not - be processed.) Note that not all possible color space transforms are - currently implemented; you may need to extend jdcolor.c if you want an - unusual conversion. - -unsigned int scale_num, scale_denom - Scale the image by the fraction scale_num/scale_denom. Default is - 1/1, or no scaling. Currently, the only supported scaling ratios - are 1/1, 1/2, 1/4, and 1/8. (The library design allows for arbitrary - scaling ratios but this is not likely to be implemented any time soon.) - Smaller scaling ratios permit significantly faster decoding since - fewer pixels need be processed and a simpler IDCT method can be used. - -boolean quantize_colors - If set TRUE, colormapped output will be delivered. Default is FALSE, - meaning that full-color output will be delivered. - -The next three parameters are relevant only if quantize_colors is TRUE. - -int desired_number_of_colors - Maximum number of colors to use in generating a library-supplied color - map (the actual number of colors is returned in a different field). - Default 256. Ignored when the application supplies its own color map. - -boolean two_pass_quantize - If TRUE, an extra pass over the image is made to select a custom color - map for the image. This usually looks a lot better than the one-size- - fits-all colormap that is used otherwise. Default is TRUE. Ignored - when the application supplies its own color map. - -J_DITHER_MODE dither_mode - Selects color dithering method. Supported values are: - JDITHER_NONE no dithering: fast, very low quality - JDITHER_ORDERED ordered dither: moderate speed and quality - JDITHER_FS Floyd-Steinberg dither: slow, high quality - Default is JDITHER_FS. (At present, ordered dither is implemented - only in the single-pass, standard-colormap case. If you ask for - ordered dither when two_pass_quantize is TRUE or when you supply - an external color map, you'll get F-S dithering.) - -When quantize_colors is TRUE, the target color map is described by the next -two fields. colormap is set to NULL by jpeg_read_header(). The application -can supply a color map by setting colormap non-NULL and setting -actual_number_of_colors to the map size. Otherwise, jpeg_start_decompress() -selects a suitable color map and sets these two fields itself. -[Implementation restriction: at present, an externally supplied colormap is -only accepted for 3-component output color spaces.] - -JSAMPARRAY colormap - The color map, represented as a 2-D pixel array of out_color_components - rows and actual_number_of_colors columns. Ignored if not quantizing. - CAUTION: if the JPEG library creates its own colormap, the storage - pointed to by this field is released by jpeg_finish_decompress(). - Copy the colormap somewhere else first, if you want to save it. - -int actual_number_of_colors - The number of colors in the color map. - -Additional decompression parameters that the application may set include: - -J_DCT_METHOD dct_method - Selects the algorithm used for the DCT step. Choices are the same - as described above for compression. - -boolean do_fancy_upsampling - If TRUE, do careful upsampling of chroma components. If FALSE, - a faster but sloppier method is used. Default is TRUE. The visual - impact of the sloppier method is often very small. - -boolean do_block_smoothing - If TRUE, interblock smoothing is applied in early stages of decoding - progressive JPEG files; if FALSE, not. Default is TRUE. Early - progression stages look "fuzzy" with smoothing, "blocky" without. - In any case, block smoothing ceases to be applied after the first few - AC coefficients are known to full accuracy, so it is relevant only - when using buffered-image mode for progressive images. - -boolean enable_1pass_quant -boolean enable_external_quant -boolean enable_2pass_quant - These are significant only in buffered-image mode, which is - described in its own section below. - - -The output image dimensions are given by the following fields. These are -computed from the source image dimensions and the decompression parameters -by jpeg_start_decompress(). You can also call jpeg_calc_output_dimensions() -to obtain the values that will result from the current parameter settings. -This can be useful if you are trying to pick a scaling ratio that will get -close to a desired target size. It's also important if you are using the -JPEG library's memory manager to allocate output buffer space, because you -are supposed to request such buffers *before* jpeg_start_decompress(). - -JDIMENSION output_width Actual dimensions of output image. -JDIMENSION output_height -int out_color_components Number of color components in out_color_space. -int output_components Number of color components returned. -int rec_outbuf_height Recommended height of scanline buffer. - -When quantizing colors, output_components is 1, indicating a single color map -index per pixel. Otherwise it equals out_color_components. The output arrays -are required to be output_width * output_components JSAMPLEs wide. - -rec_outbuf_height is the recommended minimum height (in scanlines) of the -buffer passed to jpeg_read_scanlines(). If the buffer is smaller, the -library will still work, but time will be wasted due to unnecessary data -copying. In high-quality modes, rec_outbuf_height is always 1, but some -faster, lower-quality modes set it to larger values (typically 2 to 4). -If you are going to ask for a high-speed processing mode, you may as well -go to the trouble of honoring rec_outbuf_height so as to avoid data copying. -(An output buffer larger than rec_outbuf_height lines is OK, but won't -provide any material speed improvement over that height.) - - -Special color spaces --------------------- - -The JPEG standard itself is "color blind" and doesn't specify any particular -color space. It is customary to convert color data to a luminance/chrominance -color space before compressing, since this permits greater compression. The -existing de-facto JPEG file format standards specify YCbCr or grayscale data -(JFIF), or grayscale, RGB, YCbCr, CMYK, or YCCK (Adobe). For special -applications such as multispectral images, other color spaces can be used, -but it must be understood that such files will be unportable. - -The JPEG library can handle the most common colorspace conversions (namely -RGB <=> YCbCr and CMYK <=> YCCK). It can also deal with data of an unknown -color space, passing it through without conversion. If you deal extensively -with an unusual color space, you can easily extend the library to understand -additional color spaces and perform appropriate conversions. - -For compression, the source data's color space is specified by field -in_color_space. This is transformed to the JPEG file's color space given -by jpeg_color_space. jpeg_set_defaults() chooses a reasonable JPEG color -space depending on in_color_space, but you can override this by calling -jpeg_set_colorspace(). Of course you must select a supported transformation. -jccolor.c currently supports the following transformations: - RGB => YCbCr - RGB => GRAYSCALE - YCbCr => GRAYSCALE - CMYK => YCCK -plus the null transforms: GRAYSCALE => GRAYSCALE, RGB => RGB, -YCbCr => YCbCr, CMYK => CMYK, YCCK => YCCK, and UNKNOWN => UNKNOWN. - -The de-facto file format standards (JFIF and Adobe) specify APPn markers that -indicate the color space of the JPEG file. It is important to ensure that -these are written correctly, or omitted if the JPEG file's color space is not -one of the ones supported by the de-facto standards. jpeg_set_colorspace() -will set the compression parameters to include or omit the APPn markers -properly, so long as it is told the truth about the JPEG color space. -For example, if you are writing some random 3-component color space without -conversion, don't try to fake out the library by setting in_color_space and -jpeg_color_space to JCS_YCbCr; use JCS_UNKNOWN. You may want to write an -APPn marker of your own devising to identify the colorspace --- see "Special -markers", below. - -When told that the color space is UNKNOWN, the library will default to using -luminance-quality compression parameters for all color components. You may -well want to change these parameters. See the source code for -jpeg_set_colorspace(), in jcparam.c, for details. - -For decompression, the JPEG file's color space is given in jpeg_color_space, -and this is transformed to the output color space out_color_space. -jpeg_read_header's setting of jpeg_color_space can be relied on if the file -conforms to JFIF or Adobe conventions, but otherwise it is no better than a -guess. If you know the JPEG file's color space for certain, you can override -jpeg_read_header's guess by setting jpeg_color_space. jpeg_read_header also -selects a default output color space based on (its guess of) jpeg_color_space; -set out_color_space to override this. Again, you must select a supported -transformation. jdcolor.c currently supports - YCbCr => GRAYSCALE - YCbCr => RGB - GRAYSCALE => RGB - YCCK => CMYK -as well as the null transforms. (Since GRAYSCALE=>RGB is provided, an -application can force grayscale JPEGs to look like color JPEGs if it only -wants to handle one case.) - -The two-pass color quantizer, jquant2.c, is specialized to handle RGB data -(it weights distances appropriately for RGB colors). You'll need to modify -the code if you want to use it for non-RGB output color spaces. Note that -jquant2.c is used to map to an application-supplied colormap as well as for -the normal two-pass colormap selection process. - -CAUTION: it appears that Adobe Photoshop writes inverted data in CMYK JPEG -files: 0 represents 100% ink coverage, rather than 0% ink as you'd expect. -This is arguably a bug in Photoshop, but if you need to work with Photoshop -CMYK files, you will have to deal with it in your application. We cannot -"fix" this in the library by inverting the data during the CMYK<=>YCCK -transform, because that would break other applications, notably Ghostscript. -Photoshop versions prior to 3.0 write EPS files containing JPEG-encoded CMYK -data in the same inverted-YCCK representation used in bare JPEG files, but -the surrounding PostScript code performs an inversion using the PS image -operator. I am told that Photoshop 3.0 will write uninverted YCCK in -EPS/JPEG files, and will omit the PS-level inversion. (But the data -polarity used in bare JPEG files will not change in 3.0.) In either case, -the JPEG library must not invert the data itself, or else Ghostscript would -read these EPS files incorrectly. - - -Error handling --------------- - -When the default error handler is used, any error detected inside the JPEG -routines will cause a message to be printed on stderr, followed by exit(). -You can supply your own error handling routines to override this behavior -and to control the treatment of nonfatal warnings and trace/debug messages. -The file example.c illustrates the most common case, which is to have the -application regain control after an error rather than exiting. - -The JPEG library never writes any message directly; it always goes through -the error handling routines. Three classes of messages are recognized: - * Fatal errors: the library cannot continue. - * Warnings: the library can continue, but the data is corrupt, and a - damaged output image is likely to result. - * Trace/informational messages. These come with a trace level indicating - the importance of the message; you can control the verbosity of the - program by adjusting the maximum trace level that will be displayed. - -You may, if you wish, simply replace the entire JPEG error handling module -(jerror.c) with your own code. However, you can avoid code duplication by -only replacing some of the routines depending on the behavior you need. -This is accomplished by calling jpeg_std_error() as usual, but then overriding -some of the method pointers in the jpeg_error_mgr struct, as illustrated by -example.c. - -All of the error handling routines will receive a pointer to the JPEG object -(a j_common_ptr which points to either a jpeg_compress_struct or a -jpeg_decompress_struct; if you need to tell which, test the is_decompressor -field). This struct includes a pointer to the error manager struct in its -"err" field. Frequently, custom error handler routines will need to access -additional data which is not known to the JPEG library or the standard error -handler. The most convenient way to do this is to embed either the JPEG -object or the jpeg_error_mgr struct in a larger structure that contains -additional fields; then casting the passed pointer provides access to the -additional fields. Again, see example.c for one way to do it. (Beginning -with IJG version 6b, there is also a void pointer "client_data" in each -JPEG object, which the application can also use to find related data. -The library does not touch client_data at all.) - -The individual methods that you might wish to override are: - -error_exit (j_common_ptr cinfo) - Receives control for a fatal error. Information sufficient to - generate the error message has been stored in cinfo->err; call - output_message to display it. Control must NOT return to the caller; - generally this routine will exit() or longjmp() somewhere. - Typically you would override this routine to get rid of the exit() - default behavior. Note that if you continue processing, you should - clean up the JPEG object with jpeg_abort() or jpeg_destroy(). - -output_message (j_common_ptr cinfo) - Actual output of any JPEG message. Override this to send messages - somewhere other than stderr. Note that this method does not know - how to generate a message, only where to send it. - -format_message (j_common_ptr cinfo, char * buffer) - Constructs a readable error message string based on the error info - stored in cinfo->err. This method is called by output_message. Few - applications should need to override this method. One possible - reason for doing so is to implement dynamic switching of error message - language. - -emit_message (j_common_ptr cinfo, int msg_level) - Decide whether or not to emit a warning or trace message; if so, - calls output_message. The main reason for overriding this method - would be to abort on warnings. msg_level is -1 for warnings, - 0 and up for trace messages. - -Only error_exit() and emit_message() are called from the rest of the JPEG -library; the other two are internal to the error handler. - -The actual message texts are stored in an array of strings which is pointed to -by the field err->jpeg_message_table. The messages are numbered from 0 to -err->last_jpeg_message, and it is these code numbers that are used in the -JPEG library code. You could replace the message texts (for instance, with -messages in French or German) by changing the message table pointer. See -jerror.h for the default texts. CAUTION: this table will almost certainly -change or grow from one library version to the next. - -It may be useful for an application to add its own message texts that are -handled by the same mechanism. The error handler supports a second "add-on" -message table for this purpose. To define an addon table, set the pointer -err->addon_message_table and the message numbers err->first_addon_message and -err->last_addon_message. If you number the addon messages beginning at 1000 -or so, you won't have to worry about conflicts with the library's built-in -messages. See the sample applications cjpeg/djpeg for an example of using -addon messages (the addon messages are defined in cderror.h). - -Actual invocation of the error handler is done via macros defined in jerror.h: - ERREXITn(...) for fatal errors - WARNMSn(...) for corrupt-data warnings - TRACEMSn(...) for trace and informational messages. -These macros store the message code and any additional parameters into the -error handler struct, then invoke the error_exit() or emit_message() method. -The variants of each macro are for varying numbers of additional parameters. -The additional parameters are inserted into the generated message using -standard printf() format codes. - -See jerror.h and jerror.c for further details. - - -Compressed data handling (source and destination managers) ----------------------------------------------------------- - -The JPEG compression library sends its compressed data to a "destination -manager" module. The default destination manager just writes the data to a -stdio stream, but you can provide your own manager to do something else. -Similarly, the decompression library calls a "source manager" to obtain the -compressed data; you can provide your own source manager if you want the data -to come from somewhere other than a stdio stream. - -In both cases, compressed data is processed a bufferload at a time: the -destination or source manager provides a work buffer, and the library invokes -the manager only when the buffer is filled or emptied. (You could define a -one-character buffer to force the manager to be invoked for each byte, but -that would be rather inefficient.) The buffer's size and location are -controlled by the manager, not by the library. For example, if you desired to -decompress a JPEG datastream that was all in memory, you could just make the -buffer pointer and length point to the original data in memory. Then the -buffer-reload procedure would be invoked only if the decompressor ran off the -end of the datastream, which would indicate an erroneous datastream. - -The work buffer is defined as an array of datatype JOCTET, which is generally -"char" or "unsigned char". On a machine where char is not exactly 8 bits -wide, you must define JOCTET as a wider data type and then modify the data -source and destination modules to transcribe the work arrays into 8-bit units -on external storage. - -A data destination manager struct contains a pointer and count defining the -next byte to write in the work buffer and the remaining free space: - - JOCTET * next_output_byte; /* => next byte to write in buffer */ - size_t free_in_buffer; /* # of byte spaces remaining in buffer */ - -The library increments the pointer and decrements the count until the buffer -is filled. The manager's empty_output_buffer method must reset the pointer -and count. The manager is expected to remember the buffer's starting address -and total size in private fields not visible to the library. - -A data destination manager provides three methods: - -init_destination (j_compress_ptr cinfo) - Initialize destination. This is called by jpeg_start_compress() - before any data is actually written. It must initialize - next_output_byte and free_in_buffer. free_in_buffer must be - initialized to a positive value. - -empty_output_buffer (j_compress_ptr cinfo) - This is called whenever the buffer has filled (free_in_buffer - reaches zero). In typical applications, it should write out the - *entire* buffer (use the saved start address and buffer length; - ignore the current state of next_output_byte and free_in_buffer). - Then reset the pointer & count to the start of the buffer, and - return TRUE indicating that the buffer has been dumped. - free_in_buffer must be set to a positive value when TRUE is - returned. A FALSE return should only be used when I/O suspension is - desired (this operating mode is discussed in the next section). - -term_destination (j_compress_ptr cinfo) - Terminate destination --- called by jpeg_finish_compress() after all - data has been written. In most applications, this must flush any - data remaining in the buffer. Use either next_output_byte or - free_in_buffer to determine how much data is in the buffer. - -term_destination() is NOT called by jpeg_abort() or jpeg_destroy(). If you -want the destination manager to be cleaned up during an abort, you must do it -yourself. - -You will also need code to create a jpeg_destination_mgr struct, fill in its -method pointers, and insert a pointer to the struct into the "dest" field of -the JPEG compression object. This can be done in-line in your setup code if -you like, but it's probably cleaner to provide a separate routine similar to -the jpeg_stdio_dest() routine of the supplied destination manager. - -Decompression source managers follow a parallel design, but with some -additional frammishes. The source manager struct contains a pointer and count -defining the next byte to read from the work buffer and the number of bytes -remaining: - - const JOCTET * next_input_byte; /* => next byte to read from buffer */ - size_t bytes_in_buffer; /* # of bytes remaining in buffer */ - -The library increments the pointer and decrements the count until the buffer -is emptied. The manager's fill_input_buffer method must reset the pointer and -count. In most applications, the manager must remember the buffer's starting -address and total size in private fields not visible to the library. - -A data source manager provides five methods: - -init_source (j_decompress_ptr cinfo) - Initialize source. This is called by jpeg_read_header() before any - data is actually read. Unlike init_destination(), it may leave - bytes_in_buffer set to 0 (in which case a fill_input_buffer() call - will occur immediately). - -fill_input_buffer (j_decompress_ptr cinfo) - This is called whenever bytes_in_buffer has reached zero and more - data is wanted. In typical applications, it should read fresh data - into the buffer (ignoring the current state of next_input_byte and - bytes_in_buffer), reset the pointer & count to the start of the - buffer, and return TRUE indicating that the buffer has been reloaded. - It is not necessary to fill the buffer entirely, only to obtain at - least one more byte. bytes_in_buffer MUST be set to a positive value - if TRUE is returned. A FALSE return should only be used when I/O - suspension is desired (this mode is discussed in the next section). - -skip_input_data (j_decompress_ptr cinfo, long num_bytes) - Skip num_bytes worth of data. The buffer pointer and count should - be advanced over num_bytes input bytes, refilling the buffer as - needed. This is used to skip over a potentially large amount of - uninteresting data (such as an APPn marker). In some applications - it may be possible to optimize away the reading of the skipped data, - but it's not clear that being smart is worth much trouble; large - skips are uncommon. bytes_in_buffer may be zero on return. - A zero or negative skip count should be treated as a no-op. - -resync_to_restart (j_decompress_ptr cinfo, int desired) - This routine is called only when the decompressor has failed to find - a restart (RSTn) marker where one is expected. Its mission is to - find a suitable point for resuming decompression. For most - applications, we recommend that you just use the default resync - procedure, jpeg_resync_to_restart(). However, if you are able to back - up in the input data stream, or if you have a-priori knowledge about - the likely location of restart markers, you may be able to do better. - Read the read_restart_marker() and jpeg_resync_to_restart() routines - in jdmarker.c if you think you'd like to implement your own resync - procedure. - -term_source (j_decompress_ptr cinfo) - Terminate source --- called by jpeg_finish_decompress() after all - data has been read. Often a no-op. - -For both fill_input_buffer() and skip_input_data(), there is no such thing -as an EOF return. If the end of the file has been reached, the routine has -a choice of exiting via ERREXIT() or inserting fake data into the buffer. -In most cases, generating a warning message and inserting a fake EOI marker -is the best course of action --- this will allow the decompressor to output -however much of the image is there. In pathological cases, the decompressor -may swallow the EOI and again demand data ... just keep feeding it fake EOIs. -jdatasrc.c illustrates the recommended error recovery behavior. - -term_source() is NOT called by jpeg_abort() or jpeg_destroy(). If you want -the source manager to be cleaned up during an abort, you must do it yourself. - -You will also need code to create a jpeg_source_mgr struct, fill in its method -pointers, and insert a pointer to the struct into the "src" field of the JPEG -decompression object. This can be done in-line in your setup code if you -like, but it's probably cleaner to provide a separate routine similar to the -jpeg_stdio_src() routine of the supplied source manager. - -For more information, consult the stdio source and destination managers -in jdatasrc.c and jdatadst.c. - - -I/O suspension --------------- - -Some applications need to use the JPEG library as an incremental memory-to- -memory filter: when the compressed data buffer is filled or emptied, they want -control to return to the outer loop, rather than expecting that the buffer can -be emptied or reloaded within the data source/destination manager subroutine. -The library supports this need by providing an "I/O suspension" mode, which we -describe in this section. - -The I/O suspension mode is not a panacea: nothing is guaranteed about the -maximum amount of time spent in any one call to the library, so it will not -eliminate response-time problems in single-threaded applications. If you -need guaranteed response time, we suggest you "bite the bullet" and implement -a real multi-tasking capability. - -To use I/O suspension, cooperation is needed between the calling application -and the data source or destination manager; you will always need a custom -source/destination manager. (Please read the previous section if you haven't -already.) The basic idea is that the empty_output_buffer() or -fill_input_buffer() routine is a no-op, merely returning FALSE to indicate -that it has done nothing. Upon seeing this, the JPEG library suspends -operation and returns to its caller. The surrounding application is -responsible for emptying or refilling the work buffer before calling the -JPEG library again. - -Compression suspension: - -For compression suspension, use an empty_output_buffer() routine that returns -FALSE; typically it will not do anything else. This will cause the -compressor to return to the caller of jpeg_write_scanlines(), with the return -value indicating that not all the supplied scanlines have been accepted. -The application must make more room in the output buffer, adjust the output -buffer pointer/count appropriately, and then call jpeg_write_scanlines() -again, pointing to the first unconsumed scanline. - -When forced to suspend, the compressor will backtrack to a convenient stopping -point (usually the start of the current MCU); it will regenerate some output -data when restarted. Therefore, although empty_output_buffer() is only -called when the buffer is filled, you should NOT write out the entire buffer -after a suspension. Write only the data up to the current position of -next_output_byte/free_in_buffer. The data beyond that point will be -regenerated after resumption. - -Because of the backtracking behavior, a good-size output buffer is essential -for efficiency; you don't want the compressor to suspend often. (In fact, an -overly small buffer could lead to infinite looping, if a single MCU required -more data than would fit in the buffer.) We recommend a buffer of at least -several Kbytes. You may want to insert explicit code to ensure that you don't -call jpeg_write_scanlines() unless there is a reasonable amount of space in -the output buffer; in other words, flush the buffer before trying to compress -more data. - -The compressor does not allow suspension while it is trying to write JPEG -markers at the beginning and end of the file. This means that: - * At the beginning of a compression operation, there must be enough free - space in the output buffer to hold the header markers (typically 600 or - so bytes). The recommended buffer size is bigger than this anyway, so - this is not a problem as long as you start with an empty buffer. However, - this restriction might catch you if you insert large special markers, such - as a JFIF thumbnail image, without flushing the buffer afterwards. - * When you call jpeg_finish_compress(), there must be enough space in the - output buffer to emit any buffered data and the final EOI marker. In the - current implementation, half a dozen bytes should suffice for this, but - for safety's sake we recommend ensuring that at least 100 bytes are free - before calling jpeg_finish_compress(). - -A more significant restriction is that jpeg_finish_compress() cannot suspend. -This means you cannot use suspension with multi-pass operating modes, namely -Huffman code optimization and multiple-scan output. Those modes write the -whole file during jpeg_finish_compress(), which will certainly result in -buffer overrun. (Note that this restriction applies only to compression, -not decompression. The decompressor supports input suspension in all of its -operating modes.) - -Decompression suspension: - -For decompression suspension, use a fill_input_buffer() routine that simply -returns FALSE (except perhaps during error recovery, as discussed below). -This will cause the decompressor to return to its caller with an indication -that suspension has occurred. This can happen at four places: - * jpeg_read_header(): will return JPEG_SUSPENDED. - * jpeg_start_decompress(): will return FALSE, rather than its usual TRUE. - * jpeg_read_scanlines(): will return the number of scanlines already - completed (possibly 0). - * jpeg_finish_decompress(): will return FALSE, rather than its usual TRUE. -The surrounding application must recognize these cases, load more data into -the input buffer, and repeat the call. In the case of jpeg_read_scanlines(), -increment the passed pointers past any scanlines successfully read. - -Just as with compression, the decompressor will typically backtrack to a -convenient restart point before suspending. When fill_input_buffer() is -called, next_input_byte/bytes_in_buffer point to the current restart point, -which is where the decompressor will backtrack to if FALSE is returned. -The data beyond that position must NOT be discarded if you suspend; it needs -to be re-read upon resumption. In most implementations, you'll need to shift -this data down to the start of your work buffer and then load more data after -it. Again, this behavior means that a several-Kbyte work buffer is essential -for decent performance; furthermore, you should load a reasonable amount of -new data before resuming decompression. (If you loaded, say, only one new -byte each time around, you could waste a LOT of cycles.) - -The skip_input_data() source manager routine requires special care in a -suspension scenario. This routine is NOT granted the ability to suspend the -decompressor; it can decrement bytes_in_buffer to zero, but no more. If the -requested skip distance exceeds the amount of data currently in the input -buffer, then skip_input_data() must set bytes_in_buffer to zero and record the -additional skip distance somewhere else. The decompressor will immediately -call fill_input_buffer(), which should return FALSE, which will cause a -suspension return. The surrounding application must then arrange to discard -the recorded number of bytes before it resumes loading the input buffer. -(Yes, this design is rather baroque, but it avoids complexity in the far more -common case where a non-suspending source manager is used.) - -If the input data has been exhausted, we recommend that you emit a warning -and insert dummy EOI markers just as a non-suspending data source manager -would do. This can be handled either in the surrounding application logic or -within fill_input_buffer(); the latter is probably more efficient. If -fill_input_buffer() knows that no more data is available, it can set the -pointer/count to point to a dummy EOI marker and then return TRUE just as -though it had read more data in a non-suspending situation. - -The decompressor does not attempt to suspend within standard JPEG markers; -instead it will backtrack to the start of the marker and reprocess the whole -marker next time. Hence the input buffer must be large enough to hold the -longest standard marker in the file. Standard JPEG markers should normally -not exceed a few hundred bytes each (DHT tables are typically the longest). -We recommend at least a 2K buffer for performance reasons, which is much -larger than any correct marker is likely to be. For robustness against -damaged marker length counts, you may wish to insert a test in your -application for the case that the input buffer is completely full and yet -the decoder has suspended without consuming any data --- otherwise, if this -situation did occur, it would lead to an endless loop. (The library can't -provide this test since it has no idea whether "the buffer is full", or -even whether there is a fixed-size input buffer.) - -The input buffer would need to be 64K to allow for arbitrary COM or APPn -markers, but these are handled specially: they are either saved into allocated -memory, or skipped over by calling skip_input_data(). In the former case, -suspension is handled correctly, and in the latter case, the problem of -buffer overrun is placed on skip_input_data's shoulders, as explained above. -Note that if you provide your own marker handling routine for large markers, -you should consider how to deal with buffer overflow. - -Multiple-buffer management: - -In some applications it is desirable to store the compressed data in a linked -list of buffer areas, so as to avoid data copying. This can be handled by -having empty_output_buffer() or fill_input_buffer() set the pointer and count -to reference the next available buffer; FALSE is returned only if no more -buffers are available. Although seemingly straightforward, there is a -pitfall in this approach: the backtrack that occurs when FALSE is returned -could back up into an earlier buffer. For example, when fill_input_buffer() -is called, the current pointer & count indicate the backtrack restart point. -Since fill_input_buffer() will set the pointer and count to refer to a new -buffer, the restart position must be saved somewhere else. Suppose a second -call to fill_input_buffer() occurs in the same library call, and no -additional input data is available, so fill_input_buffer must return FALSE. -If the JPEG library has not moved the pointer/count forward in the current -buffer, then *the correct restart point is the saved position in the prior -buffer*. Prior buffers may be discarded only after the library establishes -a restart point within a later buffer. Similar remarks apply for output into -a chain of buffers. - -The library will never attempt to backtrack over a skip_input_data() call, -so any skipped data can be permanently discarded. You still have to deal -with the case of skipping not-yet-received data, however. - -It's much simpler to use only a single buffer; when fill_input_buffer() is -called, move any unconsumed data (beyond the current pointer/count) down to -the beginning of this buffer and then load new data into the remaining buffer -space. This approach requires a little more data copying but is far easier -to get right. - - -Progressive JPEG support ------------------------- - -Progressive JPEG rearranges the stored data into a series of scans of -increasing quality. In situations where a JPEG file is transmitted across a -slow communications link, a decoder can generate a low-quality image very -quickly from the first scan, then gradually improve the displayed quality as -more scans are received. The final image after all scans are complete is -identical to that of a regular (sequential) JPEG file of the same quality -setting. Progressive JPEG files are often slightly smaller than equivalent -sequential JPEG files, but the possibility of incremental display is the main -reason for using progressive JPEG. - -The IJG encoder library generates progressive JPEG files when given a -suitable "scan script" defining how to divide the data into scans. -Creation of progressive JPEG files is otherwise transparent to the encoder. -Progressive JPEG files can also be read transparently by the decoder library. -If the decoding application simply uses the library as defined above, it -will receive a final decoded image without any indication that the file was -progressive. Of course, this approach does not allow incremental display. -To perform incremental display, an application needs to use the decoder -library's "buffered-image" mode, in which it receives a decoded image -multiple times. - -Each displayed scan requires about as much work to decode as a full JPEG -image of the same size, so the decoder must be fairly fast in relation to the -data transmission rate in order to make incremental display useful. However, -it is possible to skip displaying the image and simply add the incoming bits -to the decoder's coefficient buffer. This is fast because only Huffman -decoding need be done, not IDCT, upsampling, colorspace conversion, etc. -The IJG decoder library allows the application to switch dynamically between -displaying the image and simply absorbing the incoming bits. A properly -coded application can automatically adapt the number of display passes to -suit the time available as the image is received. Also, a final -higher-quality display cycle can be performed from the buffered data after -the end of the file is reached. - -Progressive compression: - -To create a progressive JPEG file (or a multiple-scan sequential JPEG file), -set the scan_info cinfo field to point to an array of scan descriptors, and -perform compression as usual. Instead of constructing your own scan list, -you can call the jpeg_simple_progression() helper routine to create a -recommended progression sequence; this method should be used by all -applications that don't want to get involved in the nitty-gritty of -progressive scan sequence design. (If you want to provide user control of -scan sequences, you may wish to borrow the scan script reading code found -in rdswitch.c, so that you can read scan script files just like cjpeg's.) -When scan_info is not NULL, the compression library will store DCT'd data -into a buffer array as jpeg_write_scanlines() is called, and will emit all -the requested scans during jpeg_finish_compress(). This implies that -multiple-scan output cannot be created with a suspending data destination -manager, since jpeg_finish_compress() does not support suspension. We -should also note that the compressor currently forces Huffman optimization -mode when creating a progressive JPEG file, because the default Huffman -tables are unsuitable for progressive files. - -Progressive decompression: - -When buffered-image mode is not used, the decoder library will read all of -a multi-scan file during jpeg_start_decompress(), so that it can provide a -final decoded image. (Here "multi-scan" means either progressive or -multi-scan sequential.) This makes multi-scan files transparent to the -decoding application. However, existing applications that used suspending -input with version 5 of the IJG library will need to be modified to check -for a suspension return from jpeg_start_decompress(). - -To perform incremental display, an application must use the library's -buffered-image mode. This is described in the next section. - - -Buffered-image mode -------------------- - -In buffered-image mode, the library stores the partially decoded image in a -coefficient buffer, from which it can be read out as many times as desired. -This mode is typically used for incremental display of progressive JPEG files, -but it can be used with any JPEG file. Each scan of a progressive JPEG file -adds more data (more detail) to the buffered image. The application can -display in lockstep with the source file (one display pass per input scan), -or it can allow input processing to outrun display processing. By making -input and display processing run independently, it is possible for the -application to adapt progressive display to a wide range of data transmission -rates. - -The basic control flow for buffered-image decoding is - - jpeg_create_decompress() - set data source - jpeg_read_header() - set overall decompression parameters - cinfo.buffered_image = TRUE; /* select buffered-image mode */ - jpeg_start_decompress() - for (each output pass) { - adjust output decompression parameters if required - jpeg_start_output() /* start a new output pass */ - for (all scanlines in image) { - jpeg_read_scanlines() - display scanlines - } - jpeg_finish_output() /* terminate output pass */ - } - jpeg_finish_decompress() - jpeg_destroy_decompress() - -This differs from ordinary unbuffered decoding in that there is an additional -level of looping. The application can choose how many output passes to make -and how to display each pass. - -The simplest approach to displaying progressive images is to do one display -pass for each scan appearing in the input file. In this case the outer loop -condition is typically - while (! jpeg_input_complete(&cinfo)) -and the start-output call should read - jpeg_start_output(&cinfo, cinfo.input_scan_number); -The second parameter to jpeg_start_output() indicates which scan of the input -file is to be displayed; the scans are numbered starting at 1 for this -purpose. (You can use a loop counter starting at 1 if you like, but using -the library's input scan counter is easier.) The library automatically reads -data as necessary to complete each requested scan, and jpeg_finish_output() -advances to the next scan or end-of-image marker (hence input_scan_number -will be incremented by the time control arrives back at jpeg_start_output()). -With this technique, data is read from the input file only as needed, and -input and output processing run in lockstep. - -After reading the final scan and reaching the end of the input file, the -buffered image remains available; it can be read additional times by -repeating the jpeg_start_output()/jpeg_read_scanlines()/jpeg_finish_output() -sequence. For example, a useful technique is to use fast one-pass color -quantization for display passes made while the image is arriving, followed by -a final display pass using two-pass quantization for highest quality. This -is done by changing the library parameters before the final output pass. -Changing parameters between passes is discussed in detail below. - -In general the last scan of a progressive file cannot be recognized as such -until after it is read, so a post-input display pass is the best approach if -you want special processing in the final pass. - -When done with the image, be sure to call jpeg_finish_decompress() to release -the buffered image (or just use jpeg_destroy_decompress()). - -If input data arrives faster than it can be displayed, the application can -cause the library to decode input data in advance of what's needed to produce -output. This is done by calling the routine jpeg_consume_input(). -The return value is one of the following: - JPEG_REACHED_SOS: reached an SOS marker (the start of a new scan) - JPEG_REACHED_EOI: reached the EOI marker (end of image) - JPEG_ROW_COMPLETED: completed reading one MCU row of compressed data - JPEG_SCAN_COMPLETED: completed reading last MCU row of current scan - JPEG_SUSPENDED: suspended before completing any of the above -(JPEG_SUSPENDED can occur only if a suspending data source is used.) This -routine can be called at any time after initializing the JPEG object. It -reads some additional data and returns when one of the indicated significant -events occurs. (If called after the EOI marker is reached, it will -immediately return JPEG_REACHED_EOI without attempting to read more data.) - -The library's output processing will automatically call jpeg_consume_input() -whenever the output processing overtakes the input; thus, simple lockstep -display requires no direct calls to jpeg_consume_input(). But by adding -calls to jpeg_consume_input(), you can absorb data in advance of what is -being displayed. This has two benefits: - * You can limit buildup of unprocessed data in your input buffer. - * You can eliminate extra display passes by paying attention to the - state of the library's input processing. - -The first of these benefits only requires interspersing calls to -jpeg_consume_input() with your display operations and any other processing -you may be doing. To avoid wasting cycles due to backtracking, it's best to -call jpeg_consume_input() only after a hundred or so new bytes have arrived. -This is discussed further under "I/O suspension", above. (Note: the JPEG -library currently is not thread-safe. You must not call jpeg_consume_input() -from one thread of control if a different library routine is working on the -same JPEG object in another thread.) - -When input arrives fast enough that more than one new scan is available -before you start a new output pass, you may as well skip the output pass -corresponding to the completed scan. This occurs for free if you pass -cinfo.input_scan_number as the target scan number to jpeg_start_output(). -The input_scan_number field is simply the index of the scan currently being -consumed by the input processor. You can ensure that this is up-to-date by -emptying the input buffer just before calling jpeg_start_output(): call -jpeg_consume_input() repeatedly until it returns JPEG_SUSPENDED or -JPEG_REACHED_EOI. - -The target scan number passed to jpeg_start_output() is saved in the -cinfo.output_scan_number field. The library's output processing calls -jpeg_consume_input() whenever the current input scan number and row within -that scan is less than or equal to the current output scan number and row. -Thus, input processing can "get ahead" of the output processing but is not -allowed to "fall behind". You can achieve several different effects by -manipulating this interlock rule. For example, if you pass a target scan -number greater than the current input scan number, the output processor will -wait until that scan starts to arrive before producing any output. (To avoid -an infinite loop, the target scan number is automatically reset to the last -scan number when the end of image is reached. Thus, if you specify a large -target scan number, the library will just absorb the entire input file and -then perform an output pass. This is effectively the same as what -jpeg_start_decompress() does when you don't select buffered-image mode.) -When you pass a target scan number equal to the current input scan number, -the image is displayed no faster than the current input scan arrives. The -final possibility is to pass a target scan number less than the current input -scan number; this disables the input/output interlock and causes the output -processor to simply display whatever it finds in the image buffer, without -waiting for input. (However, the library will not accept a target scan -number less than one, so you can't avoid waiting for the first scan.) - -When data is arriving faster than the output display processing can advance -through the image, jpeg_consume_input() will store data into the buffered -image beyond the point at which the output processing is reading data out -again. If the input arrives fast enough, it may "wrap around" the buffer to -the point where the input is more than one whole scan ahead of the output. -If the output processing simply proceeds through its display pass without -paying attention to the input, the effect seen on-screen is that the lower -part of the image is one or more scans better in quality than the upper part. -Then, when the next output scan is started, you have a choice of what target -scan number to use. The recommended choice is to use the current input scan -number at that time, which implies that you've skipped the output scans -corresponding to the input scans that were completed while you processed the -previous output scan. In this way, the decoder automatically adapts its -speed to the arriving data, by skipping output scans as necessary to keep up -with the arriving data. - -When using this strategy, you'll want to be sure that you perform a final -output pass after receiving all the data; otherwise your last display may not -be full quality across the whole screen. So the right outer loop logic is -something like this: - do { - absorb any waiting input by calling jpeg_consume_input() - final_pass = jpeg_input_complete(&cinfo); - adjust output decompression parameters if required - jpeg_start_output(&cinfo, cinfo.input_scan_number); - ... - jpeg_finish_output() - } while (! final_pass); -rather than quitting as soon as jpeg_input_complete() returns TRUE. This -arrangement makes it simple to use higher-quality decoding parameters -for the final pass. But if you don't want to use special parameters for -the final pass, the right loop logic is like this: - for (;;) { - absorb any waiting input by calling jpeg_consume_input() - jpeg_start_output(&cinfo, cinfo.input_scan_number); - ... - jpeg_finish_output() - if (jpeg_input_complete(&cinfo) && - cinfo.input_scan_number == cinfo.output_scan_number) - break; - } -In this case you don't need to know in advance whether an output pass is to -be the last one, so it's not necessary to have reached EOF before starting -the final output pass; rather, what you want to test is whether the output -pass was performed in sync with the final input scan. This form of the loop -will avoid an extra output pass whenever the decoder is able (or nearly able) -to keep up with the incoming data. - -When the data transmission speed is high, you might begin a display pass, -then find that much or all of the file has arrived before you can complete -the pass. (You can detect this by noting the JPEG_REACHED_EOI return code -from jpeg_consume_input(), or equivalently by testing jpeg_input_complete().) -In this situation you may wish to abort the current display pass and start a -new one using the newly arrived information. To do so, just call -jpeg_finish_output() and then start a new pass with jpeg_start_output(). - -A variant strategy is to abort and restart display if more than one complete -scan arrives during an output pass; this can be detected by noting -JPEG_REACHED_SOS returns and/or examining cinfo.input_scan_number. This -idea should be employed with caution, however, since the display process -might never get to the bottom of the image before being aborted, resulting -in the lower part of the screen being several passes worse than the upper. -In most cases it's probably best to abort an output pass only if the whole -file has arrived and you want to begin the final output pass immediately. - -When receiving data across a communication link, we recommend always using -the current input scan number for the output target scan number; if a -higher-quality final pass is to be done, it should be started (aborting any -incomplete output pass) as soon as the end of file is received. However, -many other strategies are possible. For example, the application can examine -the parameters of the current input scan and decide whether to display it or -not. If the scan contains only chroma data, one might choose not to use it -as the target scan, expecting that the scan will be small and will arrive -quickly. To skip to the next scan, call jpeg_consume_input() until it -returns JPEG_REACHED_SOS or JPEG_REACHED_EOI. Or just use the next higher -number as the target scan for jpeg_start_output(); but that method doesn't -let you inspect the next scan's parameters before deciding to display it. - - -In buffered-image mode, jpeg_start_decompress() never performs input and -thus never suspends. An application that uses input suspension with -buffered-image mode must be prepared for suspension returns from these -routines: -* jpeg_start_output() performs input only if you request 2-pass quantization - and the target scan isn't fully read yet. (This is discussed below.) -* jpeg_read_scanlines(), as always, returns the number of scanlines that it - was able to produce before suspending. -* jpeg_finish_output() will read any markers following the target scan, - up to the end of the file or the SOS marker that begins another scan. - (But it reads no input if jpeg_consume_input() has already reached the - end of the file or a SOS marker beyond the target output scan.) -* jpeg_finish_decompress() will read until the end of file, and thus can - suspend if the end hasn't already been reached (as can be tested by - calling jpeg_input_complete()). -jpeg_start_output(), jpeg_finish_output(), and jpeg_finish_decompress() -all return TRUE if they completed their tasks, FALSE if they had to suspend. -In the event of a FALSE return, the application must load more input data -and repeat the call. Applications that use non-suspending data sources need -not check the return values of these three routines. - - -It is possible to change decoding parameters between output passes in the -buffered-image mode. The decoder library currently supports only very -limited changes of parameters. ONLY THE FOLLOWING parameter changes are -allowed after jpeg_start_decompress() is called: -* dct_method can be changed before each call to jpeg_start_output(). - For example, one could use a fast DCT method for early scans, changing - to a higher quality method for the final scan. -* dither_mode can be changed before each call to jpeg_start_output(); - of course this has no impact if not using color quantization. Typically - one would use ordered dither for initial passes, then switch to - Floyd-Steinberg dither for the final pass. Caution: changing dither mode - can cause more memory to be allocated by the library. Although the amount - of memory involved is not large (a scanline or so), it may cause the - initial max_memory_to_use specification to be exceeded, which in the worst - case would result in an out-of-memory failure. -* do_block_smoothing can be changed before each call to jpeg_start_output(). - This setting is relevant only when decoding a progressive JPEG image. - During the first DC-only scan, block smoothing provides a very "fuzzy" look - instead of the very "blocky" look seen without it; which is better seems a - matter of personal taste. But block smoothing is nearly always a win - during later stages, especially when decoding a successive-approximation - image: smoothing helps to hide the slight blockiness that otherwise shows - up on smooth gradients until the lowest coefficient bits are sent. -* Color quantization mode can be changed under the rules described below. - You *cannot* change between full-color and quantized output (because that - would alter the required I/O buffer sizes), but you can change which - quantization method is used. - -When generating color-quantized output, changing quantization method is a -very useful way of switching between high-speed and high-quality display. -The library allows you to change among its three quantization methods: -1. Single-pass quantization to a fixed color cube. - Selected by cinfo.two_pass_quantize = FALSE and cinfo.colormap = NULL. -2. Single-pass quantization to an application-supplied colormap. - Selected by setting cinfo.colormap to point to the colormap (the value of - two_pass_quantize is ignored); also set cinfo.actual_number_of_colors. -3. Two-pass quantization to a colormap chosen specifically for the image. - Selected by cinfo.two_pass_quantize = TRUE and cinfo.colormap = NULL. - (This is the default setting selected by jpeg_read_header, but it is - probably NOT what you want for the first pass of progressive display!) -These methods offer successively better quality and lesser speed. However, -only the first method is available for quantizing in non-RGB color spaces. - -IMPORTANT: because the different quantizer methods have very different -working-storage requirements, the library requires you to indicate which -one(s) you intend to use before you call jpeg_start_decompress(). (If we did -not require this, the max_memory_to_use setting would be a complete fiction.) -You do this by setting one or more of these three cinfo fields to TRUE: - enable_1pass_quant Fixed color cube colormap - enable_external_quant Externally-supplied colormap - enable_2pass_quant Two-pass custom colormap -All three are initialized FALSE by jpeg_read_header(). But -jpeg_start_decompress() automatically sets TRUE the one selected by the -current two_pass_quantize and colormap settings, so you only need to set the -enable flags for any other quantization methods you plan to change to later. - -After setting the enable flags correctly at jpeg_start_decompress() time, you -can change to any enabled quantization method by setting two_pass_quantize -and colormap properly just before calling jpeg_start_output(). The following -special rules apply: -1. You must explicitly set cinfo.colormap to NULL when switching to 1-pass - or 2-pass mode from a different mode, or when you want the 2-pass - quantizer to be re-run to generate a new colormap. -2. To switch to an external colormap, or to change to a different external - colormap than was used on the prior pass, you must call - jpeg_new_colormap() after setting cinfo.colormap. -NOTE: if you want to use the same colormap as was used in the prior pass, -you should not do either of these things. This will save some nontrivial -switchover costs. -(These requirements exist because cinfo.colormap will always be non-NULL -after completing a prior output pass, since both the 1-pass and 2-pass -quantizers set it to point to their output colormaps. Thus you have to -do one of these two things to notify the library that something has changed. -Yup, it's a bit klugy, but it's necessary to do it this way for backwards -compatibility.) - -Note that in buffered-image mode, the library generates any requested colormap -during jpeg_start_output(), not during jpeg_start_decompress(). - -When using two-pass quantization, jpeg_start_output() makes a pass over the -buffered image to determine the optimum color map; it therefore may take a -significant amount of time, whereas ordinarily it does little work. The -progress monitor hook is called during this pass, if defined. It is also -important to realize that if the specified target scan number is greater than -or equal to the current input scan number, jpeg_start_output() will attempt -to consume input as it makes this pass. If you use a suspending data source, -you need to check for a FALSE return from jpeg_start_output() under these -conditions. The combination of 2-pass quantization and a not-yet-fully-read -target scan is the only case in which jpeg_start_output() will consume input. - - -Application authors who support buffered-image mode may be tempted to use it -for all JPEG images, even single-scan ones. This will work, but it is -inefficient: there is no need to create an image-sized coefficient buffer for -single-scan images. Requesting buffered-image mode for such an image wastes -memory. Worse, it can cost time on large images, since the buffered data has -to be swapped out or written to a temporary file. If you are concerned about -maximum performance on baseline JPEG files, you should use buffered-image -mode only when the incoming file actually has multiple scans. This can be -tested by calling jpeg_has_multiple_scans(), which will return a correct -result at any time after jpeg_read_header() completes. - -It is also worth noting that when you use jpeg_consume_input() to let input -processing get ahead of output processing, the resulting pattern of access to -the coefficient buffer is quite nonsequential. It's best to use the memory -manager jmemnobs.c if you can (ie, if you have enough real or virtual main -memory). If not, at least make sure that max_memory_to_use is set as high as -possible. If the JPEG memory manager has to use a temporary file, you will -probably see a lot of disk traffic and poor performance. (This could be -improved with additional work on the memory manager, but we haven't gotten -around to it yet.) - -In some applications it may be convenient to use jpeg_consume_input() for all -input processing, including reading the initial markers; that is, you may -wish to call jpeg_consume_input() instead of jpeg_read_header() during -startup. This works, but note that you must check for JPEG_REACHED_SOS and -JPEG_REACHED_EOI return codes as the equivalent of jpeg_read_header's codes. -Once the first SOS marker has been reached, you must call -jpeg_start_decompress() before jpeg_consume_input() will consume more input; -it'll just keep returning JPEG_REACHED_SOS until you do. If you read a -tables-only file this way, jpeg_consume_input() will return JPEG_REACHED_EOI -without ever returning JPEG_REACHED_SOS; be sure to check for this case. -If this happens, the decompressor will not read any more input until you call -jpeg_abort() to reset it. It is OK to call jpeg_consume_input() even when not -using buffered-image mode, but in that case it's basically a no-op after the -initial markers have been read: it will just return JPEG_SUSPENDED. - - -Abbreviated datastreams and multiple images -------------------------------------------- - -A JPEG compression or decompression object can be reused to process multiple -images. This saves a small amount of time per image by eliminating the -"create" and "destroy" operations, but that isn't the real purpose of the -feature. Rather, reuse of an object provides support for abbreviated JPEG -datastreams. Object reuse can also simplify processing a series of images in -a single input or output file. This section explains these features. - -A JPEG file normally contains several hundred bytes worth of quantization -and Huffman tables. In a situation where many images will be stored or -transmitted with identical tables, this may represent an annoying overhead. -The JPEG standard therefore permits tables to be omitted. The standard -defines three classes of JPEG datastreams: - * "Interchange" datastreams contain an image and all tables needed to decode - the image. These are the usual kind of JPEG file. - * "Abbreviated image" datastreams contain an image, but are missing some or - all of the tables needed to decode that image. - * "Abbreviated table specification" (henceforth "tables-only") datastreams - contain only table specifications. -To decode an abbreviated image, it is necessary to load the missing table(s) -into the decoder beforehand. This can be accomplished by reading a separate -tables-only file. A variant scheme uses a series of images in which the first -image is an interchange (complete) datastream, while subsequent ones are -abbreviated and rely on the tables loaded by the first image. It is assumed -that once the decoder has read a table, it will remember that table until a -new definition for the same table number is encountered. - -It is the application designer's responsibility to figure out how to associate -the correct tables with an abbreviated image. While abbreviated datastreams -can be useful in a closed environment, their use is strongly discouraged in -any situation where data exchange with other applications might be needed. -Caveat designer. - -The JPEG library provides support for reading and writing any combination of -tables-only datastreams and abbreviated images. In both compression and -decompression objects, a quantization or Huffman table will be retained for -the lifetime of the object, unless it is overwritten by a new table definition. - - -To create abbreviated image datastreams, it is only necessary to tell the -compressor not to emit some or all of the tables it is using. Each -quantization and Huffman table struct contains a boolean field "sent_table", -which normally is initialized to FALSE. For each table used by the image, the -header-writing process emits the table and sets sent_table = TRUE unless it is -already TRUE. (In normal usage, this prevents outputting the same table -definition multiple times, as would otherwise occur because the chroma -components typically share tables.) Thus, setting this field to TRUE before -calling jpeg_start_compress() will prevent the table from being written at -all. - -If you want to create a "pure" abbreviated image file containing no tables, -just call "jpeg_suppress_tables(&cinfo, TRUE)" after constructing all the -tables. If you want to emit some but not all tables, you'll need to set the -individual sent_table fields directly. - -To create an abbreviated image, you must also call jpeg_start_compress() -with a second parameter of FALSE, not TRUE. Otherwise jpeg_start_compress() -will force all the sent_table fields to FALSE. (This is a safety feature to -prevent abbreviated images from being created accidentally.) - -To create a tables-only file, perform the same parameter setup that you -normally would, but instead of calling jpeg_start_compress() and so on, call -jpeg_write_tables(&cinfo). This will write an abbreviated datastream -containing only SOI, DQT and/or DHT markers, and EOI. All the quantization -and Huffman tables that are currently defined in the compression object will -be emitted unless their sent_tables flag is already TRUE, and then all the -sent_tables flags will be set TRUE. - -A sure-fire way to create matching tables-only and abbreviated image files -is to proceed as follows: - - create JPEG compression object - set JPEG parameters - set destination to tables-only file - jpeg_write_tables(&cinfo); - set destination to image file - jpeg_start_compress(&cinfo, FALSE); - write data... - jpeg_finish_compress(&cinfo); - -Since the JPEG parameters are not altered between writing the table file and -the abbreviated image file, the same tables are sure to be used. Of course, -you can repeat the jpeg_start_compress() ... jpeg_finish_compress() sequence -many times to produce many abbreviated image files matching the table file. - -You cannot suppress output of the computed Huffman tables when Huffman -optimization is selected. (If you could, there'd be no way to decode the -image...) Generally, you don't want to set optimize_coding = TRUE when -you are trying to produce abbreviated files. - -In some cases you might want to compress an image using tables which are -not stored in the application, but are defined in an interchange or -tables-only file readable by the application. This can be done by setting up -a JPEG decompression object to read the specification file, then copying the -tables into your compression object. See jpeg_copy_critical_parameters() -for an example of copying quantization tables. - - -To read abbreviated image files, you simply need to load the proper tables -into the decompression object before trying to read the abbreviated image. -If the proper tables are stored in the application program, you can just -allocate the table structs and fill in their contents directly. For example, -to load a fixed quantization table into table slot "n": - - if (cinfo.quant_tbl_ptrs[n] == NULL) - cinfo.quant_tbl_ptrs[n] = jpeg_alloc_quant_table((j_common_ptr) &cinfo); - quant_ptr = cinfo.quant_tbl_ptrs[n]; /* quant_ptr is JQUANT_TBL* */ - for (i = 0; i < 64; i++) { - /* Qtable[] is desired quantization table, in natural array order */ - quant_ptr->quantval[i] = Qtable[i]; - } - -Code to load a fixed Huffman table is typically (for AC table "n"): - - if (cinfo.ac_huff_tbl_ptrs[n] == NULL) - cinfo.ac_huff_tbl_ptrs[n] = jpeg_alloc_huff_table((j_common_ptr) &cinfo); - huff_ptr = cinfo.ac_huff_tbl_ptrs[n]; /* huff_ptr is JHUFF_TBL* */ - for (i = 1; i <= 16; i++) { - /* counts[i] is number of Huffman codes of length i bits, i=1..16 */ - huff_ptr->bits[i] = counts[i]; - } - for (i = 0; i < 256; i++) { - /* symbols[] is the list of Huffman symbols, in code-length order */ - huff_ptr->huffval[i] = symbols[i]; - } - -(Note that trying to set cinfo.quant_tbl_ptrs[n] to point directly at a -constant JQUANT_TBL object is not safe. If the incoming file happened to -contain a quantization table definition, your master table would get -overwritten! Instead allocate a working table copy and copy the master table -into it, as illustrated above. Ditto for Huffman tables, of course.) - -You might want to read the tables from a tables-only file, rather than -hard-wiring them into your application. The jpeg_read_header() call is -sufficient to read a tables-only file. You must pass a second parameter of -FALSE to indicate that you do not require an image to be present. Thus, the -typical scenario is - - create JPEG decompression object - set source to tables-only file - jpeg_read_header(&cinfo, FALSE); - set source to abbreviated image file - jpeg_read_header(&cinfo, TRUE); - set decompression parameters - jpeg_start_decompress(&cinfo); - read data... - jpeg_finish_decompress(&cinfo); - -In some cases, you may want to read a file without knowing whether it contains -an image or just tables. In that case, pass FALSE and check the return value -from jpeg_read_header(): it will be JPEG_HEADER_OK if an image was found, -JPEG_HEADER_TABLES_ONLY if only tables were found. (A third return value, -JPEG_SUSPENDED, is possible when using a suspending data source manager.) -Note that jpeg_read_header() will not complain if you read an abbreviated -image for which you haven't loaded the missing tables; the missing-table check -occurs later, in jpeg_start_decompress(). - - -It is possible to read a series of images from a single source file by -repeating the jpeg_read_header() ... jpeg_finish_decompress() sequence, -without releasing/recreating the JPEG object or the data source module. -(If you did reinitialize, any partial bufferload left in the data source -buffer at the end of one image would be discarded, causing you to lose the -start of the next image.) When you use this method, stored tables are -automatically carried forward, so some of the images can be abbreviated images -that depend on tables from earlier images. - -If you intend to write a series of images into a single destination file, -you might want to make a specialized data destination module that doesn't -flush the output buffer at term_destination() time. This would speed things -up by some trifling amount. Of course, you'd need to remember to flush the -buffer after the last image. You can make the later images be abbreviated -ones by passing FALSE to jpeg_start_compress(). - - -Special markers ---------------- - -Some applications may need to insert or extract special data in the JPEG -datastream. The JPEG standard provides marker types "COM" (comment) and -"APP0" through "APP15" (application) to hold application-specific data. -Unfortunately, the use of these markers is not specified by the standard. -COM markers are fairly widely used to hold user-supplied text. The JFIF file -format spec uses APP0 markers with specified initial strings to hold certain -data. Adobe applications use APP14 markers beginning with the string "Adobe" -for miscellaneous data. Other APPn markers are rarely seen, but might -contain almost anything. - -If you wish to store user-supplied text, we recommend you use COM markers -and place readable 7-bit ASCII text in them. Newline conventions are not -standardized --- expect to find LF (Unix style), CR/LF (DOS style), or CR -(Mac style). A robust COM reader should be able to cope with random binary -garbage, including nulls, since some applications generate COM markers -containing non-ASCII junk. (But yours should not be one of them.) - -For program-supplied data, use an APPn marker, and be sure to begin it with an -identifying string so that you can tell whether the marker is actually yours. -It's probably best to avoid using APP0 or APP14 for any private markers. -(NOTE: the upcoming SPIFF standard will use APP8 markers; we recommend you -not use APP8 markers for any private purposes, either.) - -Keep in mind that at most 65533 bytes can be put into one marker, but you -can have as many markers as you like. - -By default, the IJG compression library will write a JFIF APP0 marker if the -selected JPEG colorspace is grayscale or YCbCr, or an Adobe APP14 marker if -the selected colorspace is RGB, CMYK, or YCCK. You can disable this, but -we don't recommend it. The decompression library will recognize JFIF and -Adobe markers and will set the JPEG colorspace properly when one is found. - - -You can write special markers immediately following the datastream header by -calling jpeg_write_marker() after jpeg_start_compress() and before the first -call to jpeg_write_scanlines(). When you do this, the markers appear after -the SOI and the JFIF APP0 and Adobe APP14 markers (if written), but before -all else. Specify the marker type parameter as "JPEG_COM" for COM or -"JPEG_APP0 + n" for APPn. (Actually, jpeg_write_marker will let you write -any marker type, but we don't recommend writing any other kinds of marker.) -For example, to write a user comment string pointed to by comment_text: - jpeg_write_marker(cinfo, JPEG_COM, comment_text, strlen(comment_text)); - -If it's not convenient to store all the marker data in memory at once, -you can instead call jpeg_write_m_header() followed by multiple calls to -jpeg_write_m_byte(). If you do it this way, it's your responsibility to -call jpeg_write_m_byte() exactly the number of times given in the length -parameter to jpeg_write_m_header(). (This method lets you empty the -output buffer partway through a marker, which might be important when -using a suspending data destination module. In any case, if you are using -a suspending destination, you should flush its buffer after inserting -any special markers. See "I/O suspension".) - -Or, if you prefer to synthesize the marker byte sequence yourself, -you can just cram it straight into the data destination module. - -If you are writing JFIF 1.02 extension markers (thumbnail images), don't -forget to set cinfo.JFIF_minor_version = 2 so that the encoder will write the -correct JFIF version number in the JFIF header marker. The library's default -is to write version 1.01, but that's wrong if you insert any 1.02 extension -markers. (We could probably get away with just defaulting to 1.02, but there -used to be broken decoders that would complain about unknown minor version -numbers. To reduce compatibility risks it's safest not to write 1.02 unless -you are actually using 1.02 extensions.) - - -When reading, two methods of handling special markers are available: -1. You can ask the library to save the contents of COM and/or APPn markers -into memory, and then examine them at your leisure afterwards. -2. You can supply your own routine to process COM and/or APPn markers -on-the-fly as they are read. -The first method is simpler to use, especially if you are using a suspending -data source; writing a marker processor that copes with input suspension is -not easy (consider what happens if the marker is longer than your available -input buffer). However, the second method conserves memory since the marker -data need not be kept around after it's been processed. - -For either method, you'd normally set up marker handling after creating a -decompression object and before calling jpeg_read_header(), because the -markers of interest will typically be near the head of the file and so will -be scanned by jpeg_read_header. Once you've established a marker handling -method, it will be used for the life of that decompression object -(potentially many datastreams), unless you change it. Marker handling is -determined separately for COM markers and for each APPn marker code. - - -To save the contents of special markers in memory, call - jpeg_save_markers(cinfo, marker_code, length_limit) -where marker_code is the marker type to save, JPEG_COM or JPEG_APP0+n. -(To arrange to save all the special marker types, you need to call this -routine 17 times, for COM and APP0-APP15.) If the incoming marker is longer -than length_limit data bytes, only length_limit bytes will be saved; this -parameter allows you to avoid chewing up memory when you only need to see the -first few bytes of a potentially large marker. If you want to save all the -data, set length_limit to 0xFFFF; that is enough since marker lengths are only -16 bits. As a special case, setting length_limit to 0 prevents that marker -type from being saved at all. (That is the default behavior, in fact.) - -After jpeg_read_header() completes, you can examine the special markers by -following the cinfo->marker_list pointer chain. All the special markers in -the file appear in this list, in order of their occurrence in the file (but -omitting any markers of types you didn't ask for). Both the original data -length and the saved data length are recorded for each list entry; the latter -will not exceed length_limit for the particular marker type. Note that these -lengths exclude the marker length word, whereas the stored representation -within the JPEG file includes it. (Hence the maximum data length is really -only 65533.) - -It is possible that additional special markers appear in the file beyond the -SOS marker at which jpeg_read_header stops; if so, the marker list will be -extended during reading of the rest of the file. This is not expected to be -common, however. If you are short on memory you may want to reset the length -limit to zero for all marker types after finishing jpeg_read_header, to -ensure that the max_memory_to_use setting cannot be exceeded due to addition -of later markers. - -The marker list remains stored until you call jpeg_finish_decompress or -jpeg_abort, at which point the memory is freed and the list is set to empty. -(jpeg_destroy also releases the storage, of course.) - -Note that the library is internally interested in APP0 and APP14 markers; -if you try to set a small nonzero length limit on these types, the library -will silently force the length up to the minimum it wants. (But you can set -a zero length limit to prevent them from being saved at all.) Also, in a -16-bit environment, the maximum length limit may be constrained to less than -65533 by malloc() limitations. It is therefore best not to assume that the -effective length limit is exactly what you set it to be. - - -If you want to supply your own marker-reading routine, you do it by calling -jpeg_set_marker_processor(). A marker processor routine must have the -signature - boolean jpeg_marker_parser_method (j_decompress_ptr cinfo) -Although the marker code is not explicitly passed, the routine can find it -in cinfo->unread_marker. At the time of call, the marker proper has been -read from the data source module. The processor routine is responsible for -reading the marker length word and the remaining parameter bytes, if any. -Return TRUE to indicate success. (FALSE should be returned only if you are -using a suspending data source and it tells you to suspend. See the standard -marker processors in jdmarker.c for appropriate coding methods if you need to -use a suspending data source.) - -If you override the default APP0 or APP14 processors, it is up to you to -recognize JFIF and Adobe markers if you want colorspace recognition to occur -properly. We recommend copying and extending the default processors if you -want to do that. (A better idea is to save these marker types for later -examination by calling jpeg_save_markers(); that method doesn't interfere -with the library's own processing of these markers.) - -jpeg_set_marker_processor() and jpeg_save_markers() are mutually exclusive ---- if you call one it overrides any previous call to the other, for the -particular marker type specified. - -A simple example of an external COM processor can be found in djpeg.c. -Also, see jpegtran.c for an example of using jpeg_save_markers. - - -Raw (downsampled) image data ----------------------------- - -Some applications need to supply already-downsampled image data to the JPEG -compressor, or to receive raw downsampled data from the decompressor. The -library supports this requirement by allowing the application to write or -read raw data, bypassing the normal preprocessing or postprocessing steps. -The interface is different from the standard one and is somewhat harder to -use. If your interest is merely in bypassing color conversion, we recommend -that you use the standard interface and simply set jpeg_color_space = -in_color_space (or jpeg_color_space = out_color_space for decompression). -The mechanism described in this section is necessary only to supply or -receive downsampled image data, in which not all components have the same -dimensions. - - -To compress raw data, you must supply the data in the colorspace to be used -in the JPEG file (please read the earlier section on Special color spaces) -and downsampled to the sampling factors specified in the JPEG parameters. -You must supply the data in the format used internally by the JPEG library, -namely a JSAMPIMAGE array. This is an array of pointers to two-dimensional -arrays, each of type JSAMPARRAY. Each 2-D array holds the values for one -color component. This structure is necessary since the components are of -different sizes. If the image dimensions are not a multiple of the MCU size, -you must also pad the data correctly (usually, this is done by replicating -the last column and/or row). The data must be padded to a multiple of a DCT -block in each component: that is, each downsampled row must contain a -multiple of 8 valid samples, and there must be a multiple of 8 sample rows -for each component. (For applications such as conversion of digital TV -images, the standard image size is usually a multiple of the DCT block size, -so that no padding need actually be done.) - -The procedure for compression of raw data is basically the same as normal -compression, except that you call jpeg_write_raw_data() in place of -jpeg_write_scanlines(). Before calling jpeg_start_compress(), you must do -the following: - * Set cinfo->raw_data_in to TRUE. (It is set FALSE by jpeg_set_defaults().) - This notifies the library that you will be supplying raw data. - * Ensure jpeg_color_space is correct --- an explicit jpeg_set_colorspace() - call is a good idea. Note that since color conversion is bypassed, - in_color_space is ignored, except that jpeg_set_defaults() uses it to - choose the default jpeg_color_space setting. - * Ensure the sampling factors, cinfo->comp_info[i].h_samp_factor and - cinfo->comp_info[i].v_samp_factor, are correct. Since these indicate the - dimensions of the data you are supplying, it's wise to set them - explicitly, rather than assuming the library's defaults are what you want. - -To pass raw data to the library, call jpeg_write_raw_data() in place of -jpeg_write_scanlines(). The two routines work similarly except that -jpeg_write_raw_data takes a JSAMPIMAGE data array rather than JSAMPARRAY. -The scanlines count passed to and returned from jpeg_write_raw_data is -measured in terms of the component with the largest v_samp_factor. - -jpeg_write_raw_data() processes one MCU row per call, which is to say -v_samp_factor*DCTSIZE sample rows of each component. The passed num_lines -value must be at least max_v_samp_factor*DCTSIZE, and the return value will -be exactly that amount (or possibly some multiple of that amount, in future -library versions). This is true even on the last call at the bottom of the -image; don't forget to pad your data as necessary. - -The required dimensions of the supplied data can be computed for each -component as - cinfo->comp_info[i].width_in_blocks*DCTSIZE samples per row - cinfo->comp_info[i].height_in_blocks*DCTSIZE rows in image -after jpeg_start_compress() has initialized those fields. If the valid data -is smaller than this, it must be padded appropriately. For some sampling -factors and image sizes, additional dummy DCT blocks are inserted to make -the image a multiple of the MCU dimensions. The library creates such dummy -blocks itself; it does not read them from your supplied data. Therefore you -need never pad by more than DCTSIZE samples. An example may help here. -Assume 2h2v downsampling of YCbCr data, that is - cinfo->comp_info[0].h_samp_factor = 2 for Y - cinfo->comp_info[0].v_samp_factor = 2 - cinfo->comp_info[1].h_samp_factor = 1 for Cb - cinfo->comp_info[1].v_samp_factor = 1 - cinfo->comp_info[2].h_samp_factor = 1 for Cr - cinfo->comp_info[2].v_samp_factor = 1 -and suppose that the nominal image dimensions (cinfo->image_width and -cinfo->image_height) are 101x101 pixels. Then jpeg_start_compress() will -compute downsampled_width = 101 and width_in_blocks = 13 for Y, -downsampled_width = 51 and width_in_blocks = 7 for Cb and Cr (and the same -for the height fields). You must pad the Y data to at least 13*8 = 104 -columns and rows, the Cb/Cr data to at least 7*8 = 56 columns and rows. The -MCU height is max_v_samp_factor = 2 DCT rows so you must pass at least 16 -scanlines on each call to jpeg_write_raw_data(), which is to say 16 actual -sample rows of Y and 8 each of Cb and Cr. A total of 7 MCU rows are needed, -so you must pass a total of 7*16 = 112 "scanlines". The last DCT block row -of Y data is dummy, so it doesn't matter what you pass for it in the data -arrays, but the scanlines count must total up to 112 so that all of the Cb -and Cr data gets passed. - -Output suspension is supported with raw-data compression: if the data -destination module suspends, jpeg_write_raw_data() will return 0. -In this case the same data rows must be passed again on the next call. - - -Decompression with raw data output implies bypassing all postprocessing: -you cannot ask for rescaling or color quantization, for instance. More -seriously, you must deal with the color space and sampling factors present in -the incoming file. If your application only handles, say, 2h1v YCbCr data, -you must check for and fail on other color spaces or other sampling factors. -The library will not convert to a different color space for you. - -To obtain raw data output, set cinfo->raw_data_out = TRUE before -jpeg_start_decompress() (it is set FALSE by jpeg_read_header()). Be sure to -verify that the color space and sampling factors are ones you can handle. -Then call jpeg_read_raw_data() in place of jpeg_read_scanlines(). The -decompression process is otherwise the same as usual. - -jpeg_read_raw_data() returns one MCU row per call, and thus you must pass a -buffer of at least max_v_samp_factor*DCTSIZE scanlines (scanline counting is -the same as for raw-data compression). The buffer you pass must be large -enough to hold the actual data plus padding to DCT-block boundaries. As with -compression, any entirely dummy DCT blocks are not processed so you need not -allocate space for them, but the total scanline count includes them. The -above example of computing buffer dimensions for raw-data compression is -equally valid for decompression. - -Input suspension is supported with raw-data decompression: if the data source -module suspends, jpeg_read_raw_data() will return 0. You can also use -buffered-image mode to read raw data in multiple passes. - - -Really raw data: DCT coefficients ---------------------------------- - -It is possible to read or write the contents of a JPEG file as raw DCT -coefficients. This facility is mainly intended for use in lossless -transcoding between different JPEG file formats. Other possible applications -include lossless cropping of a JPEG image, lossless reassembly of a -multi-strip or multi-tile TIFF/JPEG file into a single JPEG datastream, etc. - -To read the contents of a JPEG file as DCT coefficients, open the file and do -jpeg_read_header() as usual. But instead of calling jpeg_start_decompress() -and jpeg_read_scanlines(), call jpeg_read_coefficients(). This will read the -entire image into a set of virtual coefficient-block arrays, one array per -component. The return value is a pointer to an array of virtual-array -descriptors. Each virtual array can be accessed directly using the JPEG -memory manager's access_virt_barray method (see Memory management, below, -and also read structure.doc's discussion of virtual array handling). Or, -for simple transcoding to a different JPEG file format, the array list can -just be handed directly to jpeg_write_coefficients(). - -Each block in the block arrays contains quantized coefficient values in -normal array order (not JPEG zigzag order). The block arrays contain only -DCT blocks containing real data; any entirely-dummy blocks added to fill out -interleaved MCUs at the right or bottom edges of the image are discarded -during reading and are not stored in the block arrays. (The size of each -block array can be determined from the width_in_blocks and height_in_blocks -fields of the component's comp_info entry.) This is also the data format -expected by jpeg_write_coefficients(). - -When you are done using the virtual arrays, call jpeg_finish_decompress() -to release the array storage and return the decompression object to an idle -state; or just call jpeg_destroy() if you don't need to reuse the object. - -If you use a suspending data source, jpeg_read_coefficients() will return -NULL if it is forced to suspend; a non-NULL return value indicates successful -completion. You need not test for a NULL return value when using a -non-suspending data source. - -It is also possible to call jpeg_read_coefficients() to obtain access to the -decoder's coefficient arrays during a normal decode cycle in buffered-image -mode. This frammish might be useful for progressively displaying an incoming -image and then re-encoding it without loss. To do this, decode in buffered- -image mode as discussed previously, then call jpeg_read_coefficients() after -the last jpeg_finish_output() call. The arrays will be available for your use -until you call jpeg_finish_decompress(). - - -To write the contents of a JPEG file as DCT coefficients, you must provide -the DCT coefficients stored in virtual block arrays. You can either pass -block arrays read from an input JPEG file by jpeg_read_coefficients(), or -allocate virtual arrays from the JPEG compression object and fill them -yourself. In either case, jpeg_write_coefficients() is substituted for -jpeg_start_compress() and jpeg_write_scanlines(). Thus the sequence is - * Create compression object - * Set all compression parameters as necessary - * Request virtual arrays if needed - * jpeg_write_coefficients() - * jpeg_finish_compress() - * Destroy or re-use compression object -jpeg_write_coefficients() is passed a pointer to an array of virtual block -array descriptors; the number of arrays is equal to cinfo.num_components. - -The virtual arrays need only have been requested, not realized, before -jpeg_write_coefficients() is called. A side-effect of -jpeg_write_coefficients() is to realize any virtual arrays that have been -requested from the compression object's memory manager. Thus, when obtaining -the virtual arrays from the compression object, you should fill the arrays -after calling jpeg_write_coefficients(). The data is actually written out -when you call jpeg_finish_compress(); jpeg_write_coefficients() only writes -the file header. - -When writing raw DCT coefficients, it is crucial that the JPEG quantization -tables and sampling factors match the way the data was encoded, or the -resulting file will be invalid. For transcoding from an existing JPEG file, -we recommend using jpeg_copy_critical_parameters(). This routine initializes -all the compression parameters to default values (like jpeg_set_defaults()), -then copies the critical information from a source decompression object. -The decompression object should have just been used to read the entire -JPEG input file --- that is, it should be awaiting jpeg_finish_decompress(). - -jpeg_write_coefficients() marks all tables stored in the compression object -as needing to be written to the output file (thus, it acts like -jpeg_start_compress(cinfo, TRUE)). This is for safety's sake, to avoid -emitting abbreviated JPEG files by accident. If you really want to emit an -abbreviated JPEG file, call jpeg_suppress_tables(), or set the tables' -individual sent_table flags, between calling jpeg_write_coefficients() and -jpeg_finish_compress(). - - -Progress monitoring -------------------- - -Some applications may need to regain control from the JPEG library every so -often. The typical use of this feature is to produce a percent-done bar or -other progress display. (For a simple example, see cjpeg.c or djpeg.c.) -Although you do get control back frequently during the data-transferring pass -(the jpeg_read_scanlines or jpeg_write_scanlines loop), any additional passes -will occur inside jpeg_finish_compress or jpeg_start_decompress; those -routines may take a long time to execute, and you don't get control back -until they are done. - -You can define a progress-monitor routine which will be called periodically -by the library. No guarantees are made about how often this call will occur, -so we don't recommend you use it for mouse tracking or anything like that. -At present, a call will occur once per MCU row, scanline, or sample row -group, whichever unit is convenient for the current processing mode; so the -wider the image, the longer the time between calls. During the data -transferring pass, only one call occurs per call of jpeg_read_scanlines or -jpeg_write_scanlines, so don't pass a large number of scanlines at once if -you want fine resolution in the progress count. (If you really need to use -the callback mechanism for time-critical tasks like mouse tracking, you could -insert additional calls inside some of the library's inner loops.) - -To establish a progress-monitor callback, create a struct jpeg_progress_mgr, -fill in its progress_monitor field with a pointer to your callback routine, -and set cinfo->progress to point to the struct. The callback will be called -whenever cinfo->progress is non-NULL. (This pointer is set to NULL by -jpeg_create_compress or jpeg_create_decompress; the library will not change -it thereafter. So if you allocate dynamic storage for the progress struct, -make sure it will live as long as the JPEG object does. Allocating from the -JPEG memory manager with lifetime JPOOL_PERMANENT will work nicely.) You -can use the same callback routine for both compression and decompression. - -The jpeg_progress_mgr struct contains four fields which are set by the library: - long pass_counter; /* work units completed in this pass */ - long pass_limit; /* total number of work units in this pass */ - int completed_passes; /* passes completed so far */ - int total_passes; /* total number of passes expected */ -During any one pass, pass_counter increases from 0 up to (not including) -pass_limit; the step size is usually but not necessarily 1. The pass_limit -value may change from one pass to another. The expected total number of -passes is in total_passes, and the number of passes already completed is in -completed_passes. Thus the fraction of work completed may be estimated as - completed_passes + (pass_counter/pass_limit) - -------------------------------------------- - total_passes -ignoring the fact that the passes may not be equal amounts of work. - -When decompressing, pass_limit can even change within a pass, because it -depends on the number of scans in the JPEG file, which isn't always known in -advance. The computed fraction-of-work-done may jump suddenly (if the library -discovers it has overestimated the number of scans) or even decrease (in the -opposite case). It is not wise to put great faith in the work estimate. - -When using the decompressor's buffered-image mode, the progress monitor work -estimate is likely to be completely unhelpful, because the library has no way -to know how many output passes will be demanded of it. Currently, the library -sets total_passes based on the assumption that there will be one more output -pass if the input file end hasn't yet been read (jpeg_input_complete() isn't -TRUE), but no more output passes if the file end has been reached when the -output pass is started. This means that total_passes will rise as additional -output passes are requested. If you have a way of determining the input file -size, estimating progress based on the fraction of the file that's been read -will probably be more useful than using the library's value. - - -Memory management ------------------ - -This section covers some key facts about the JPEG library's built-in memory -manager. For more info, please read structure.doc's section about the memory -manager, and consult the source code if necessary. - -All memory and temporary file allocation within the library is done via the -memory manager. If necessary, you can replace the "back end" of the memory -manager to control allocation yourself (for example, if you don't want the -library to use malloc() and free() for some reason). - -Some data is allocated "permanently" and will not be freed until the JPEG -object is destroyed. Most data is allocated "per image" and is freed by -jpeg_finish_compress, jpeg_finish_decompress, or jpeg_abort. You can call the -memory manager yourself to allocate structures that will automatically be -freed at these times. Typical code for this is - ptr = (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, size); -Use JPOOL_PERMANENT to get storage that lasts as long as the JPEG object. -Use alloc_large instead of alloc_small for anything bigger than a few Kbytes. -There are also alloc_sarray and alloc_barray routines that automatically -build 2-D sample or block arrays. - -The library's minimum space requirements to process an image depend on the -image's width, but not on its height, because the library ordinarily works -with "strip" buffers that are as wide as the image but just a few rows high. -Some operating modes (eg, two-pass color quantization) require full-image -buffers. Such buffers are treated as "virtual arrays": only the current strip -need be in memory, and the rest can be swapped out to a temporary file. - -If you use the simplest memory manager back end (jmemnobs.c), then no -temporary files are used; virtual arrays are simply malloc()'d. Images bigger -than memory can be processed only if your system supports virtual memory. -The other memory manager back ends support temporary files of various flavors -and thus work in machines without virtual memory. They may also be useful on -Unix machines if you need to process images that exceed available swap space. - -When using temporary files, the library will make the in-memory buffers for -its virtual arrays just big enough to stay within a "maximum memory" setting. -Your application can set this limit by setting cinfo->mem->max_memory_to_use -after creating the JPEG object. (Of course, there is still a minimum size for -the buffers, so the max-memory setting is effective only if it is bigger than -the minimum space needed.) If you allocate any large structures yourself, you -must allocate them before jpeg_start_compress() or jpeg_start_decompress() in -order to have them counted against the max memory limit. Also keep in mind -that space allocated with alloc_small() is ignored, on the assumption that -it's too small to be worth worrying about; so a reasonable safety margin -should be left when setting max_memory_to_use. - -If you use the jmemname.c or jmemdos.c memory manager back end, it is -important to clean up the JPEG object properly to ensure that the temporary -files get deleted. (This is especially crucial with jmemdos.c, where the -"temporary files" may be extended-memory segments; if they are not freed, -DOS will require a reboot to recover the memory.) Thus, with these memory -managers, it's a good idea to provide a signal handler that will trap any -early exit from your program. The handler should call either jpeg_abort() -or jpeg_destroy() for any active JPEG objects. A handler is not needed with -jmemnobs.c, and shouldn't be necessary with jmemansi.c or jmemmac.c either, -since the C library is supposed to take care of deleting files made with -tmpfile(). - - -Memory usage ------------- - -Working memory requirements while performing compression or decompression -depend on image dimensions, image characteristics (such as colorspace and -JPEG process), and operating mode (application-selected options). - -As of v6b, the decompressor requires: - 1. About 24K in more-or-less-fixed-size data. This varies a bit depending - on operating mode and image characteristics (particularly color vs. - grayscale), but it doesn't depend on image dimensions. - 2. Strip buffers (of size proportional to the image width) for IDCT and - upsampling results. The worst case for commonly used sampling factors - is about 34 bytes * width in pixels for a color image. A grayscale image - only needs about 8 bytes per pixel column. - 3. A full-image DCT coefficient buffer is needed to decode a multi-scan JPEG - file (including progressive JPEGs), or whenever you select buffered-image - mode. This takes 2 bytes/coefficient. At typical 2x2 sampling, that's - 3 bytes per pixel for a color image. Worst case (1x1 sampling) requires - 6 bytes/pixel. For grayscale, figure 2 bytes/pixel. - 4. To perform 2-pass color quantization, the decompressor also needs a - 128K color lookup table and a full-image pixel buffer (3 bytes/pixel). -This does not count any memory allocated by the application, such as a -buffer to hold the final output image. - -The above figures are valid for 8-bit JPEG data precision and a machine with -32-bit ints. For 12-bit JPEG data, double the size of the strip buffers and -quantization pixel buffer. The "fixed-size" data will be somewhat smaller -with 16-bit ints, larger with 64-bit ints. Also, CMYK or other unusual -color spaces will require different amounts of space. - -The full-image coefficient and pixel buffers, if needed at all, do not -have to be fully RAM resident; you can have the library use temporary -files instead when the total memory usage would exceed a limit you set. -(But if your OS supports virtual memory, it's probably better to just use -jmemnobs and let the OS do the swapping.) - -The compressor's memory requirements are similar, except that it has no need -for color quantization. Also, it needs a full-image DCT coefficient buffer -if Huffman-table optimization is asked for, even if progressive mode is not -requested. - -If you need more detailed information about memory usage in a particular -situation, you can enable the MEM_STATS code in jmemmgr.c. - - -Library compile-time options ----------------------------- - -A number of compile-time options are available by modifying jmorecfg.h. - -The JPEG standard provides for both the baseline 8-bit DCT process and -a 12-bit DCT process. The IJG code supports 12-bit lossy JPEG if you define -BITS_IN_JSAMPLE as 12 rather than 8. Note that this causes JSAMPLE to be -larger than a char, so it affects the surrounding application's image data. -The sample applications cjpeg and djpeg can support 12-bit mode only for PPM -and GIF file formats; you must disable the other file formats to compile a -12-bit cjpeg or djpeg. (install.doc has more information about that.) -At present, a 12-bit library can handle *only* 12-bit images, not both -precisions. (If you need to include both 8- and 12-bit libraries in a single -application, you could probably do it by defining NEED_SHORT_EXTERNAL_NAMES -for just one of the copies. You'd have to access the 8-bit and 12-bit copies -from separate application source files. This is untested ... if you try it, -we'd like to hear whether it works!) - -Note that a 12-bit library always compresses in Huffman optimization mode, -in order to generate valid Huffman tables. This is necessary because our -default Huffman tables only cover 8-bit data. If you need to output 12-bit -files in one pass, you'll have to supply suitable default Huffman tables. -You may also want to supply your own DCT quantization tables; the existing -quality-scaling code has been developed for 8-bit use, and probably doesn't -generate especially good tables for 12-bit. - -The maximum number of components (color channels) in the image is determined -by MAX_COMPONENTS. The JPEG standard allows up to 255 components, but we -expect that few applications will need more than four or so. - -On machines with unusual data type sizes, you may be able to improve -performance or reduce memory space by tweaking the various typedefs in -jmorecfg.h. In particular, on some RISC CPUs, access to arrays of "short"s -is quite slow; consider trading memory for speed by making JCOEF, INT16, and -UINT16 be "int" or "unsigned int". UINT8 is also a candidate to become int. -You probably don't want to make JSAMPLE be int unless you have lots of memory -to burn. - -You can reduce the size of the library by compiling out various optional -functions. To do this, undefine xxx_SUPPORTED symbols as necessary. - -You can also save a few K by not having text error messages in the library; -the standard error message table occupies about 5Kb. This is particularly -reasonable for embedded applications where there's no good way to display -a message anyway. To do this, remove the creation of the message table -(jpeg_std_message_table[]) from jerror.c, and alter format_message to do -something reasonable without it. You could output the numeric value of the -message code number, for example. If you do this, you can also save a couple -more K by modifying the TRACEMSn() macros in jerror.h to expand to nothing; -you don't need trace capability anyway, right? - - -Portability considerations --------------------------- - -The JPEG library has been written to be extremely portable; the sample -applications cjpeg and djpeg are slightly less so. This section summarizes -the design goals in this area. (If you encounter any bugs that cause the -library to be less portable than is claimed here, we'd appreciate hearing -about them.) - -The code works fine on ANSI C, C++, and pre-ANSI C compilers, using any of -the popular system include file setups, and some not-so-popular ones too. -See install.doc for configuration procedures. - -The code is not dependent on the exact sizes of the C data types. As -distributed, we make the assumptions that - char is at least 8 bits wide - short is at least 16 bits wide - int is at least 16 bits wide - long is at least 32 bits wide -(These are the minimum requirements of the ANSI C standard.) Wider types will -work fine, although memory may be used inefficiently if char is much larger -than 8 bits or short is much bigger than 16 bits. The code should work -equally well with 16- or 32-bit ints. - -In a system where these assumptions are not met, you may be able to make the -code work by modifying the typedefs in jmorecfg.h. However, you will probably -have difficulty if int is less than 16 bits wide, since references to plain -int abound in the code. - -char can be either signed or unsigned, although the code runs faster if an -unsigned char type is available. If char is wider than 8 bits, you will need -to redefine JOCTET and/or provide custom data source/destination managers so -that JOCTET represents exactly 8 bits of data on external storage. - -The JPEG library proper does not assume ASCII representation of characters. -But some of the image file I/O modules in cjpeg/djpeg do have ASCII -dependencies in file-header manipulation; so does cjpeg's select_file_type() -routine. - -The JPEG library does not rely heavily on the C library. In particular, C -stdio is used only by the data source/destination modules and the error -handler, all of which are application-replaceable. (cjpeg/djpeg are more -heavily dependent on stdio.) malloc and free are called only from the memory -manager "back end" module, so you can use a different memory allocator by -replacing that one file. - -The code generally assumes that C names must be unique in the first 15 -characters. However, global function names can be made unique in the -first 6 characters by defining NEED_SHORT_EXTERNAL_NAMES. - -More info about porting the code may be gleaned by reading jconfig.doc, -jmorecfg.h, and jinclude.h. - - -Notes for MS-DOS implementors ------------------------------ - -The IJG code is designed to work efficiently in 80x86 "small" or "medium" -memory models (i.e., data pointers are 16 bits unless explicitly declared -"far"; code pointers can be either size). You may be able to use small -model to compile cjpeg or djpeg by itself, but you will probably have to use -medium model for any larger application. This won't make much difference in -performance. You *will* take a noticeable performance hit if you use a -large-data memory model (perhaps 10%-25%), and you should avoid "huge" model -if at all possible. - -The JPEG library typically needs 2Kb-3Kb of stack space. It will also -malloc about 20K-30K of near heap space while executing (and lots of far -heap, but that doesn't count in this calculation). This figure will vary -depending on selected operating mode, and to a lesser extent on image size. -There is also about 5Kb-6Kb of constant data which will be allocated in the -near data segment (about 4Kb of this is the error message table). -Thus you have perhaps 20K available for other modules' static data and near -heap space before you need to go to a larger memory model. The C library's -static data will account for several K of this, but that still leaves a good -deal for your needs. (If you are tight on space, you could reduce the sizes -of the I/O buffers allocated by jdatasrc.c and jdatadst.c, say from 4K to -1K. Another possibility is to move the error message table to far memory; -this should be doable with only localized hacking on jerror.c.) - -About 2K of the near heap space is "permanent" memory that will not be -released until you destroy the JPEG object. This is only an issue if you -save a JPEG object between compression or decompression operations. - -Far data space may also be a tight resource when you are dealing with large -images. The most memory-intensive case is decompression with two-pass color -quantization, or single-pass quantization to an externally supplied color -map. This requires a 128Kb color lookup table plus strip buffers amounting -to about 40 bytes per column for typical sampling ratios (eg, about 25600 -bytes for a 640-pixel-wide image). You may not be able to process wide -images if you have large data structures of your own. - -Of course, all of these concerns vanish if you use a 32-bit flat-memory-model -compiler, such as DJGPP or Watcom C. We highly recommend flat model if you -can use it; the JPEG library is significantly faster in flat model. diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/ltconfig b/irrlicht-1.6/source/Irrlicht/jpeglib/ltconfig deleted file mode 100644 index 679dd73d5..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/ltconfig +++ /dev/null @@ -1,1512 +0,0 @@ -#! /bin/sh - -# ltconfig - Create a system-specific libtool. -# Copyright (C) 1996-1998 Free Software Foundation, Inc. -# Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 -# -# This file is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# A lot of this script is taken from autoconf-2.10. - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -if test "${CDPATH+set}" = set; then CDPATH=; export CDPATH; fi - -echo=echo -if test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then : -else - # The Solaris and AIX default echo program unquotes backslashes. - # This makes it impossible to quote backslashes using - # echo "$something" | sed 's/\\/\\\\/g' - # So, we emulate echo with printf '%s\n' - echo="printf %s\\n" - if test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then : - else - # Oops. We have no working printf. Try to find a not-so-buggy echo. - echo=echo - IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:" - for dir in $PATH /usr/ucb; do - if test -f $dir/echo && test "X`$dir/echo '\t'`" = 'X\t'; then - echo="$dir/echo" - break - fi - done - IFS="$save_ifs" - fi -fi - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -Xsed='sed -e s/^X//' -sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g' - -# Same as above, but do not quote variable references. -double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g' - -# The name of this program. -progname=`$echo "X$0" | $Xsed -e 's%^.*/%%'` - -# Constants: -PROGRAM=ltconfig -PACKAGE=libtool -VERSION=1.2 -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.c 1>&5' -ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.c $LIBS 1>&5' -rm="rm -f" - -help="Try \`$progname --help' for more information." - -# Global variables: -can_build_shared=yes -enable_shared=yes -# All known linkers require a `.a' archive for static linking. -enable_static=yes -ltmain= -silent= -srcdir= -ac_config_guess= -ac_config_sub= -host= -nonopt= -verify_host=yes -with_gcc=no -with_gnu_ld=no - -old_AR="$AR" -old_CC="$CC" -old_CFLAGS="$CFLAGS" -old_CPPFLAGS="$CPPFLAGS" -old_LD="$LD" -old_LN_S="$LN_S" -old_NM="$NM" -old_RANLIB="$RANLIB" - -# Parse the command line options. -args= -prev= -for option -do - case "$option" in - -*=*) optarg=`echo "$option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; - *) optarg= ;; - esac - - # If the previous option needs an argument, assign it. - if test -n "$prev"; then - eval "$prev=\$option" - prev= - continue - fi - - case "$option" in - --help) cat <<EOM -Usage: $progname [OPTION]... LTMAIN [HOST] - -Generate a system-specific libtool script. - - --disable-shared do not build shared libraries - --disable-static do not build static libraries - --help display this help and exit - --no-verify do not verify that HOST is a valid host type - --quiet same as \`--silent' - --silent do not print informational messages - --srcdir=DIR find \`config.guess' in DIR - --version output version information and exit - --with-gcc assume that the GNU C compiler will be used - --with-gnu-ld assume that the C compiler uses the GNU linker - -LTMAIN is the \`ltmain.sh' shell script fragment that provides basic libtool -functionality. - -HOST is the canonical host system name [default=guessed]. -EOM - exit 0 - ;; - - --disable-shared) enable_shared=no ;; - - --disable-static) enable_static=no ;; - - --quiet | --silent) silent=yes ;; - - --srcdir) prev=srcdir ;; - --srcdir=*) srcdir="$optarg" ;; - - --no-verify) verify_host=no ;; - - --version) echo "$PROGRAM (GNU $PACKAGE) $VERSION"; exit 0 ;; - - --with-gcc) with_gcc=yes ;; - --with-gnu-ld) with_gnu_ld=yes ;; - - -*) - echo "$progname: unrecognized option \`$option'" 1>&2 - echo "$help" 1>&2 - exit 1 - ;; - - *) - if test -z "$ltmain"; then - ltmain="$option" - elif test -z "$host"; then -# This generates an unnecessary warning for sparc-sun-solaris4.1.3_U1 -# if test -n "`echo $option| sed 's/[-a-z0-9.]//g'`"; then -# echo "$progname: warning \`$option' is not a valid host type" 1>&2 -# fi - host="$option" - else - echo "$progname: too many arguments" 1>&2 - echo "$help" 1>&2 - exit 1 - fi ;; - esac -done - -if test -z "$ltmain"; then - echo "$progname: you must specify a LTMAIN file" 1>&2 - echo "$help" 1>&2 - exit 1 -fi - -if test -f "$ltmain"; then : -else - echo "$progname: \`$ltmain' does not exist" 1>&2 - echo "$help" 1>&2 - exit 1 -fi - -# Quote any args containing shell metacharacters. -ltconfig_args= -for arg -do - case "$arg" in - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) - ltconfig_args="$ltconfig_args '$arg'" ;; - *) ltconfig_args="$ltconfig_args $arg" ;; - esac -done - -# A relevant subset of AC_INIT. - -# File descriptor usage: -# 0 standard input -# 1 file creation -# 2 errors and warnings -# 3 some systems may open it to /dev/tty -# 4 used on the Kubota Titan -# 5 compiler messages saved in config.log -# 6 checking for... messages and results -if test "$silent" = yes; then - exec 6>/dev/null -else - exec 6>&1 -fi -exec 5>>./config.log - -# NLS nuisances. -# Only set LANG and LC_ALL to C if already set. -# These must not be set unconditionally because not all systems understand -# e.g. LANG=C (notably SCO). -if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi -if test "${LANG+set}" = set; then LANG=C; export LANG; fi - -if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then - # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. - if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then - ac_n= ac_c=' -' ac_t=' ' - else - ac_n=-n ac_c= ac_t= - fi -else - ac_n= ac_c='\c' ac_t= -fi - -if test -z "$srcdir"; then - # Assume the source directory is the same one as the path to ltmain.sh. - srcdir=`$echo "$ltmain" | $Xsed -e 's%/[^/]*$%%'` - test "$srcdir" = "$ltmain" && srcdir=. -fi - -trap "$rm conftest*; exit 1" 1 2 15 -if test "$verify_host" = yes; then - # Check for config.guess and config.sub. - ac_aux_dir= - for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do - if test -f $ac_dir/config.guess; then - ac_aux_dir=$ac_dir - break - fi - done - if test -z "$ac_aux_dir"; then - echo "$progname: cannot find config.guess in $srcdir $srcdir/.. $srcdir/../.." 1>&2 - echo "$help" 1>&2 - exit 1 - fi - ac_config_guess=$ac_aux_dir/config.guess - ac_config_sub=$ac_aux_dir/config.sub - - # Make sure we can run config.sub. - if $ac_config_sub sun4 >/dev/null 2>&1; then : - else - echo "$progname: cannot run $ac_config_sub" 1>&2 - echo "$help" 1>&2 - exit 1 - fi - - echo $ac_n "checking host system type""... $ac_c" 1>&6 - - host_alias=$host - case "$host_alias" in - "") - if host_alias=`$ac_config_guess`; then : - else - echo "$progname: cannot guess host type; you must specify one" 1>&2 - echo "$help" 1>&2 - exit 1 - fi ;; - esac - host=`$ac_config_sub $host_alias` - echo "$ac_t$host" 1>&6 - - # Make sure the host verified. - test -z "$host" && exit 1 - -elif test -z "$host"; then - echo "$progname: you must specify a host type if you use \`--no-verify'" 1>&2 - echo "$help" 1>&2 - exit 1 -else - host_alias=$host -fi - -# Transform linux* to *-*-linux-gnu*, to support old configure scripts. -case "$host_os" in -linux-gnu*) ;; -linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'` -esac - -host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` - -case "$host_os" in -aix3*) - # AIX sometimes has problems with the GCC collect2 program. For some - # reason, if we set the COLLECT_NAMES environment variable, the problems - # vanish in a puff of smoke. - if test "${COLLECT_NAMES+set}" != set; then - COLLECT_NAMES= - export COLLECT_NAMES - fi - ;; -esac - -# Determine commands to create old-style static archives. -old_archive_cmds='$AR cru $oldlib$oldobjs' -old_postinstall_cmds='chmod 644 $oldlib' -old_postuninstall_cmds= - -# Set a sane default for `AR'. -test -z "$AR" && AR=ar - -# If RANLIB is not set, then run the test. -if test "${RANLIB+set}" != "set"; then - result=no - - echo $ac_n "checking for ranlib... $ac_c" 1>&6 - IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:" - for dir in $PATH; do - test -z "$dir" && dir=. - if test -f $dir/ranlib; then - RANLIB="ranlib" - result="ranlib" - break - fi - done - IFS="$save_ifs" - - echo "$ac_t$result" 1>&6 -fi - -if test -n "$RANLIB"; then - old_archive_cmds="$old_archive_cmds;\$RANLIB \$oldlib" - old_postinstall_cmds="\$RANLIB \$oldlib;$old_postinstall_cmds" -fi - -# Check to see if we are using GCC. -if test "$with_gcc" != yes || test -z "$CC"; then - # If CC is not set, then try to find GCC or a usable CC. - if test -z "$CC"; then - echo $ac_n "checking for gcc... $ac_c" 1>&6 - IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:" - for dir in $PATH; do - IFS="$save_ifs" - test -z "$dir" && dir=. - if test -f $dir/gcc; then - CC="gcc" - break - fi - done - IFS="$save_ifs" - - if test -n "$CC"; then - echo "$ac_t$CC" 1>&6 - else - echo "$ac_t"no 1>&6 - fi - fi - - # Not "gcc", so try "cc", rejecting "/usr/ucb/cc". - if test -z "$CC"; then - echo $ac_n "checking for cc... $ac_c" 1>&6 - IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:" - cc_rejected=no - for dir in $PATH; do - test -z "$dir" && dir=. - if test -f $dir/cc; then - if test "$dir/cc" = "/usr/ucb/cc"; then - cc_rejected=yes - continue - fi - CC="cc" - break - fi - done - IFS="$save_ifs" - if test $cc_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $CC - shift - if test $# -gt 0; then - # We chose a different compiler from the bogus one. - # However, it has the same name, so the bogon will be chosen - # first if we set CC to just the name; use the full file name. - shift - set dummy "$dir/cc" "$@" - shift - CC="$@" - fi - fi - - if test -n "$CC"; then - echo "$ac_t$CC" 1>&6 - else - echo "$ac_t"no 1>&6 - fi - - if test -z "$CC"; then - echo "$progname: error: no acceptable cc found in \$PATH" 1>&2 - exit 1 - fi - fi - - # Now see if the compiler is really GCC. - with_gcc=no - echo $ac_n "checking whether we are using GNU C... $ac_c" 1>&6 - echo "$progname:424: checking whether we are using GNU C" >&5 - - $rm conftest.c - cat > conftest.c <<EOF -#ifdef __GNUC__ - yes; -#endif -EOF - if { ac_try='${CC-cc} -E conftest.c'; { (eval echo $progname:432: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then - with_gcc=yes - fi - $rm conftest.c - echo "$ac_t$with_gcc" 1>&6 -fi - -# Allow CC to be a program name with arguments. -set dummy $CC -compiler="$2" - -echo $ac_n "checking for $compiler option to produce PIC... $ac_c" 1>&6 -pic_flag= -special_shlib_compile_flags= -wl= -link_static_flag= -no_builtin_flag= - -if test "$with_gcc" = yes; then - wl='-Wl,' - link_static_flag='-static' - no_builtin_flag=' -fno-builtin' - - case "$host_os" in - aix3* | aix4* | irix5* | irix6* | osf3* | osf4*) - # PIC is the default for these OSes. - ;; - os2*) - # We can build DLLs from non-PIC. - ;; - amigaos*) - # FIXME: we need at least 68020 code to build shared libraries, but - # adding the `-m68020' flag to GCC prevents building anything better, - # like `-m68040'. - pic_flag='-m68020 -resident32 -malways-restore-a4' - ;; - *) - pic_flag='-fPIC' - ;; - esac -else - # PORTME Check for PIC flags for the system compiler. - case "$host_os" in - aix3* | aix4*) - # All AIX code is PIC. - link_static_flag='-bnso -bI:/lib/syscalls.exp' - ;; - - hpux9* | hpux10*) - # Is there a better link_static_flag that works with the bundled CC? - wl='-Wl,' - link_static_flag="${wl}-a ${wl}archive" - pic_flag='+Z' - ;; - - irix5* | irix6*) - wl='-Wl,' - link_static_flag='-non_shared' - # PIC (with -KPIC) is the default. - ;; - - os2*) - # We can build DLLs from non-PIC. - ;; - - osf3* | osf4*) - # All OSF/1 code is PIC. - wl='-Wl,' - link_static_flag='-non_shared' - ;; - - sco3.2v5*) - pic_flag='-Kpic' - link_static_flag='-dn' - special_shlib_compile_flags='-belf' - ;; - - solaris2*) - pic_flag='-KPIC' - link_static_flag='-Bstatic' - wl='-Wl,' - ;; - - sunos4*) - pic_flag='-PIC' - link_static_flag='-Bstatic' - wl='-Qoption ld ' - ;; - - sysv4.2uw2*) - pic_flag='-KPIC' - link_static_flag='-Bstatic' - wl='-Wl,' - ;; - - uts4*) - pic_flag='-pic' - link_static_flag='-Bstatic' - ;; - - *) - can_build_shared=no - ;; - esac -fi - -if test -n "$pic_flag"; then - echo "$ac_t$pic_flag" 1>&6 - - # Check to make sure the pic_flag actually works. - echo $ac_n "checking if $compiler PIC flag $pic_flag works... $ac_c" 1>&6 - $rm conftest* - echo > conftest.c - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $pic_flag -DPIC" - echo "$progname:547: checking if $compiler PIC flag $pic_flag works" >&5 - if { (eval echo $progname:548: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.o; then - # Append any warnings to the config.log. - cat conftest.err 1>&5 - - # On HP-UX, both CC and GCC only warn that PIC is supported... then they - # create non-PIC objects. So, if there were any warnings, we assume that - # PIC is not supported. - if test -s conftest.err; then - echo "$ac_t"no 1>&6 - can_build_shared=no - pic_flag= - else - echo "$ac_t"yes 1>&6 - pic_flag=" $pic_flag" - fi - else - # Append any errors to the config.log. - cat conftest.err 1>&5 - can_build_shared=no - pic_flag= - echo "$ac_t"no 1>&6 - fi - CFLAGS="$save_CFLAGS" - $rm conftest* -else - echo "$ac_t"none 1>&6 -fi - -# Check for any special shared library compilation flags. -if test -n "$special_shlib_compile_flags"; then - echo "$progname: warning: \`$CC' requires \`$special_shlib_compile_flags' to build shared libraries" 1>&2 - if echo "$old_CC $old_CFLAGS " | egrep -e "[ ]$special_shlib_compile_flags[ ]" >/dev/null; then : - else - echo "$progname: add \`$special_shlib_compile_flags' to the CC or CFLAGS env variable and reconfigure" 1>&2 - can_build_shared=no - fi -fi - -echo $ac_n "checking if $compiler static flag $link_static_flag works... $ac_c" 1>&6 -$rm conftest* -echo 'main(){return(0);}' > conftest.c -save_LDFLAGS="$LDFLAGS" -LDFLAGS="$LDFLAGS $link_static_flag" -echo "$progname:591: checking if $compiler static flag $link_static_flag works" >&5 -if { (eval echo $progname:592: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then - echo "$ac_t$link_static_flag" 1>&6 -else - echo "$ac_t"none 1>&6 - link_static_flag= -fi -LDFLAGS="$save_LDFLAGS" -$rm conftest* - -if test -z "$LN_S"; then - # Check to see if we can use ln -s, or we need hard links. - echo $ac_n "checking whether ln -s works... $ac_c" 1>&6 - $rm conftestdata - if ln -s X conftestdata 2>/dev/null; then - $rm conftestdata - LN_S="ln -s" - else - LN_S=ln - fi - if test "$LN_S" = "ln -s"; then - echo "$ac_t"yes 1>&6 - else - echo "$ac_t"no 1>&6 - fi -fi - -# Make sure LD is an absolute path. -if test -z "$LD"; then - ac_prog=ld - if test "$with_gcc" = yes; then - # Check if gcc -print-prog-name=ld gives a path. - echo $ac_n "checking for ld used by GCC... $ac_c" 1>&6 - echo "$progname:624: checking for ld used by GCC" >&5 - ac_prog=`($CC -print-prog-name=ld) 2>&5` - case "$ac_prog" in - # Accept absolute paths. - /* | [A-Za-z]:\\*) - test -z "$LD" && LD="$ac_prog" - ;; - "") - # If it fails, then pretend we are not using GCC. - ac_prog=ld - ;; - *) - # If it is relative, then search for the first ld in PATH. - with_gnu_ld=unknown - ;; - esac - elif test "$with_gnu_ld" = yes; then - echo $ac_n "checking for GNU ld... $ac_c" 1>&6 - echo "$progname:642: checking for GNU ld" >&5 - else - echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6 - echo "$progname:645: checking for non-GNU ld" >&5 - fi - - if test -z "$LD"; then - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do - test -z "$ac_dir" && ac_dir=. - if test -f "$ac_dir/$ac_prog"; then - LD="$ac_dir/$ac_prog" - # Check to see if the program is GNU ld. I'd rather use --version, - # but apparently some GNU ld's only accept -v. - # Break only if it was the GNU/non-GNU ld that we prefer. - if "$LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then - test "$with_gnu_ld" != no && break - else - test "$with_gnu_ld" != yes && break - fi - fi - done - IFS="$ac_save_ifs" - fi - - if test -n "$LD"; then - echo "$ac_t$LD" 1>&6 - else - echo "$ac_t"no 1>&6 - fi - - if test -z "$LD"; then - echo "$progname: error: no acceptable ld found in \$PATH" 1>&2 - exit 1 - fi -fi - -# Check to see if it really is or is not GNU ld. -echo $ac_n "checking if the linker ($LD) is GNU ld... $ac_c" 1>&6 -# I'd rather use --version here, but apparently some GNU ld's only accept -v. -if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then - with_gnu_ld=yes -else - with_gnu_ld=no -fi -echo "$ac_t$with_gnu_ld" 1>&6 - -# See if the linker supports building shared libraries. -echo $ac_n "checking whether the linker ($LD) supports shared libraries... $ac_c" 1>&6 - -allow_undefined_flag= -no_undefined_flag= -archive_cmds= -old_archive_from_new_cmds= -export_dynamic_flag_spec= -hardcode_libdir_flag_spec= -hardcode_libdir_separator= -hardcode_direct=no -hardcode_minus_L=no -hardcode_shlibpath_var=unsupported -runpath_var= - -case "$host_os" in -amigaos* | sunos4*) - # On these operating systems, we should treat GNU ld like the system ld. - gnu_ld_acts_native=yes - ;; -*) - gnu_ld_acts_native=no - ;; -esac - -ld_shlibs=yes -if test "$with_gnu_ld" = yes && test "$gnu_ld_acts_native" != yes; then - - # See if GNU ld supports shared libraries. - if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then - archive_cmds='$CC -shared ${wl}-soname $wl$soname -o $lib$libobjs' - runpath_var=LD_RUN_PATH - ld_shlibs=yes - else - ld_shlibs=no - fi - - if test "$ld_shlibs" = yes; then - hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir' - export_dynamic_flag_spec='${wl}--export-dynamic' - fi -else - # PORTME fill in a description of your system's linker (not GNU ld) - case "$host_os" in - aix3*) - allow_undefined_flag=unsupported - archive_cmds='$NM$libobjs | $global_symbol_pipe | sed '\''s/.* //'\'' > $lib.exp;$LD -o $objdir/$soname$libobjs -bE:$lib.exp -T512 -H512 -bM:SRE;$AR cru $lib $objdir/$soname' - # Note: this linker hardcodes the directories in LIBPATH if there - # are no directories specified by -L. - hardcode_minus_L=yes - if test "$with_gcc" = yes && test -z "$link_static_flag"; then - # Neither direct hardcoding nor static linking is supported with a - # broken collect2. - hardcode_direct=unsupported - fi - ;; - - aix4*) - allow_undefined_flag=unsupported - archive_cmds='$NM$libobjs | $global_symbol_pipe | sed '\''s/.* //'\'' > $lib.exp;$CC -o $objdir/$soname$libobjs ${wl}-bE:$lib.exp ${wl}-bM:SRE ${wl}-bnoentry;$AR cru $lib $objdir/$soname' - hardcode_direct=yes - hardcode_minus_L=yes - ;; - - amigaos*) - archive_cmds='$rm $objdir/a2ixlibrary.data;$echo "#define NAME $libname" > $objdir/a2ixlibrary.data;$echo "#define LIBRARY_ID 1" >> $objdir/a2ixlibrary.data;$echo "#define VERSION $major" >> $objdir/a2ixlibrary.data;$echo "#define REVISION $revision" >> $objdir/a2ixlibrary.data;$AR cru $lib$libobjs;$RANLIB $lib;(cd $objdir && a2ixlibrary -32)' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - ;; - - # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor - # support. Future versions do this automatically, but an explicit c++rt0.o - # does not break anything, and helps significantly (at the cost of a little - # extra space). - freebsd2.2*) - archive_cmds='$LD -Bshareable -o $lib$libobjs /usr/lib/c++rt0.o' - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - hardcode_minus_L=yes - hardcode_shlibpath_var=no - ;; - - # Unfortunately, older versions of FreeBSD 2 do not have this feature. - freebsd2*) - archive_cmds='$LD -Bshareable -o $lib$libobjs' - hardcode_direct=yes - hardcode_minus_L=yes - hardcode_shlibpath_var=no - ;; - - # FreeBSD 3, at last, uses gcc -shared to do shared libraries. - freebsd3*) - archive_cmds='$CC -shared -o $lib$libobjs' - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - hardcode_minus_L=yes - hardcode_shlibpath_var=no - ;; - - hpux9*) - archive_cmds='$rm $objdir/$soname;$LD -b +s +b $install_libdir -o $objdir/$soname$libobjs;mv $objdir/$soname $lib' - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_direct=yes - hardcode_minus_L=yes - export_dynamic_flag_spec='${wl}-E' - ;; - - hpux10*) - archive_cmds='$LD -b +h $soname +s +b $install_libdir -o $lib$libobjs' - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_direct=yes - hardcode_minus_L=yes - export_dynamic_flag_spec='${wl}-E' - ;; - - irix5* | irix6*) - archive_cmds='$LD -shared -o $lib -soname $soname -set_version $verstring$libobjs' - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - ;; - - netbsd*) - # Tested with NetBSD 1.2 ld - archive_cmds='$LD -Bshareable -o $lib$libobjs' - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; - - openbsd*) - archive_cmds='$LD -Bshareable -o $lib$libobjs' - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; - - os2*) - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - allow_undefined_flag=unsupported - archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $objdir/$libname.def;$echo "DESCRIPTION \"$libname\"" >> $objdir/$libname.def;$echo DATA >> $objdir/$libname.def;$echo " SINGLE NONSHARED" >> $objdir/$libname.def;$echo EXPORTS >> $objdir/$libname.def;emxexp$libobjs >> $objdir/$libname.def;$CC -Zdll -Zcrtdll -o $lib$libobjs $objdir/$libname.def' - old_archive_from_new_cmds='emximp -o $objdir/$libname.a $objdir/$libname.def' - ;; - - osf3* | osf4*) - allow_undefined_flag=' -expect_unresolved \*' - archive_cmds='$LD -shared${allow_undefined_flag} -o $lib -soname $soname -set_version $verstring$libobjs$deplibs' - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - ;; - - sco3.2v5*) - archive_cmds='$LD -G -o $lib$libobjs' - hardcode_direct=yes - ;; - - solaris2*) - no_undefined_flag=' -z text' - archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib$libobjs' - hardcode_libdir_flag_spec='-R$libdir' - hardcode_shlibpath_var=no - - # Solaris 2 before 2.5 hardcodes -L paths. - case "$host_os" in - solaris2.[0-4]*) - hardcode_minus_L=yes - ;; - esac - ;; - - sunos4*) - if test "$with_gcc" = yes; then - archive_cmds='$CC -shared -o $lib$libobjs' - else - archive_cmds='$LD -assert pure-text -Bstatic -o $lib$libobjs' - fi - - if test "$with_gnu_ld" = yes; then - export_dynamic_flag_spec='${wl}-export-dynamic' - fi - hardcode_libdir_flag_spec='-L$libdir' - hardcode_direct=yes - hardcode_minus_L=yes - hardcode_shlibpath_var=no - ;; - - uts4*) - archive_cmds='$LD -G -h $soname -o $lib$libobjs' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_direct=no - hardcode_minus_L=no - hardcode_shlibpath_var=no - ;; - - *) - ld_shlibs=no - can_build_shared=no - ;; - esac -fi -echo "$ac_t$ld_shlibs" 1>&6 - -if test -z "$NM"; then - echo $ac_n "checking for BSD-compatible nm... $ac_c" 1>&6 - case "$NM" in - /* | [A-Za-z]:\\*) ;; # Let the user override the test with a path. - *) - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in /usr/ucb /usr/ccs/bin $PATH /bin; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/nm; then - # Check to see if the nm accepts a BSD-compat flag. - # Adding the `sed 1q' prevents false positives on HP-UX, which says: - # nm: unknown option "B" ignored - if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then - NM="$ac_dir/nm -B" - elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then - NM="$ac_dir/nm -p" - else - NM="$ac_dir/nm" - fi - break - fi - done - IFS="$ac_save_ifs" - test -z "$NM" && NM=nm - ;; - esac - echo "$ac_t$NM" 1>&6 -fi - -# Check for command to grab the raw symbol name followed by C symbol from nm. -echo $ac_n "checking command to parse $NM output... $ac_c" 1>&6 - -# These are sane defaults that work on at least a few old systems. -# [They come from Ultrix. What could be older than Ultrix?!! ;)] - -# Character class describing NM global symbol codes. -symcode='[BCDEGRSTU]' - -# Regexp to match symbols that can be accessed directly from C. -sympat='\([_A-Za-z][_A-Za-z0-9]*\)' - -# Transform the above into a raw symbol and a C symbol. -symxfrm='\1 \1' - -# Define system-specific variables. -case "$host_os" in -aix*) - symcode='[BCDTU]' - ;; -irix*) - # Cannot use undefined symbols on IRIX because inlined functions mess us up. - symcode='[BCDEGRST]' - ;; -solaris2*) - symcode='[BDTU]' - ;; -esac - -# If we're using GNU nm, then use its standard symbol codes. -if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then - symcode='[ABCDGISTUW]' -fi - -# Write the raw and C identifiers. -global_symbol_pipe="sed -n -e 's/^.* $symcode $sympat$/$symxfrm/p'" - -# Check to see that the pipe works correctly. -pipe_works=no -$rm conftest* -cat > conftest.c <<EOF -#ifdef __cplusplus -extern "C" { -#endif -char nm_test_var; -void nm_test_func(){} -#ifdef __cplusplus -} -#endif -main(){nm_test_var='a';nm_test_func();return(0);} -EOF - -echo "$progname:971: checking if global_symbol_pipe works" >&5 -if { (eval echo $progname:972: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } && test -s conftest.o; then - # Now try to grab the symbols. - nlist=conftest.nm - if { echo "$progname:975: eval \"$NM conftest.o | $global_symbol_pipe > $nlist\"" >&5; eval "$NM conftest.o | $global_symbol_pipe > $nlist 2>&5"; } && test -s "$nlist"; then - - # Try sorting and uniquifying the output. - if sort "$nlist" | uniq > "$nlist"T; then - mv -f "$nlist"T "$nlist" - wcout=`wc "$nlist" 2>/dev/null` - count=`$echo "X$wcout" | $Xsed -e 's/^[ ]*\([0-9][0-9]*\).*$/\1/'` - (test "$count" -ge 0) 2>/dev/null || count=-1 - else - rm -f "$nlist"T - count=-1 - fi - - # Make sure that we snagged all the symbols we need. - if egrep ' nm_test_var$' "$nlist" >/dev/null; then - if egrep ' nm_test_func$' "$nlist" >/dev/null; then - cat <<EOF > conftest.c -#ifdef __cplusplus -extern "C" { -#endif - -EOF - # Now generate the symbol file. - sed 's/^.* \(.*\)$/extern char \1;/' < "$nlist" >> conftest.c - - cat <<EOF >> conftest.c -#if defined (__STDC__) && __STDC__ -# define __ptr_t void * -#else -# define __ptr_t char * -#endif - -/* The number of symbols in dld_preloaded_symbols, -1 if unsorted. */ -int dld_preloaded_symbol_count = $count; - -/* The mapping between symbol names and symbols. */ -struct { - char *name; - __ptr_t address; -} -dld_preloaded_symbols[] = -{ -EOF - sed 's/^\(.*\) \(.*\)$/ {"\1", (__ptr_t) \&\2},/' < "$nlist" >> conftest.c - cat <<\EOF >> conftest.c - {0, (__ptr_t) 0} -}; - -#ifdef __cplusplus -} -#endif -EOF - # Now try linking the two files. - mv conftest.o conftestm.o - save_LIBS="$LIBS" - save_CFLAGS="$CFLAGS" - LIBS='conftestm.o' - CFLAGS="$CFLAGS$no_builtin_flag" - if { (eval echo $progname:1033: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then - pipe_works=yes - else - echo "$progname: failed program was:" >&5 - cat conftest.c >&5 - fi - LIBS="$save_LIBS" - else - echo "cannot find nm_test_func in $nlist" >&5 - fi - else - echo "cannot find nm_test_var in $nlist" >&5 - fi - else - echo "cannot run $global_symbol_pipe" >&5 - fi -else - echo "$progname: failed program was:" >&5 - cat conftest.c >&5 -fi -$rm conftest* - -# Do not use the global_symbol_pipe unless it works. -echo "$ac_t$pipe_works" 1>&6 -test "$pipe_works" = yes || global_symbol_pipe= - -# Check hardcoding attributes. -echo $ac_n "checking how to hardcode library paths into programs... $ac_c" 1>&6 -hardcode_action= -if test -n "$hardcode_libdir_flag_spec" || \ - test -n "$runpath_var"; then - - # We can hardcode non-existant directories. - if test "$hardcode_direct" != no && \ - test "$hardcode_minus_L" != no && \ - test "$hardcode_shlibpath_var" != no; then - - # Linking always hardcodes the temporary library directory. - hardcode_action=relink - else - # We can link without hardcoding, and we can hardcode nonexisting dirs. - hardcode_action=immediate - fi -elif test "$hardcode_direct" != yes && \ - test "$hardcode_minus_L" != yes && \ - test "$hardcode_shlibpath_var" != yes; then - # We cannot hardcode anything. - hardcode_action=unsupported -else - # We can only hardcode existing directories. - hardcode_action=relink -fi -echo "$ac_t$hardcode_action" 1>&6 -test "$hardcode_action" = unsupported && can_build_shared=no - - -reload_flag= -reload_cmds='$LD$reload_flag -o $output$reload_objs' -echo $ac_n "checking for $LD option to reload object files... $ac_c" 1>&6 -# PORTME Some linker may need a different reload flag. -reload_flag='-r' -echo "$ac_t$reload_flag" -test -n "$reload_flag" && reload_flag=" $reload_flag" - -# PORTME Fill in your ld.so characteristics -library_names_spec= -libname_spec='lib$name' -soname_spec= -postinstall_cmds= -postuninstall_cmds= -finish_cmds= -finish_eval= -shlibpath_var= -version_type=none -dynamic_linker="$host_os ld.so" - -echo $ac_n "checking dynamic linker characteristics... $ac_c" 1>&6 -case "$host_os" in -aix3* | aix4*) - version_type=linux - library_names_spec='${libname}${release}.so.$versuffix $libname.a' - shlibpath_var=LIBPATH - - # AIX has no versioning support, so we append a major version to the name. - soname_spec='${libname}${release}.so.$major' - ;; - -amigaos*) - library_names_spec='$libname.ixlibrary $libname.a' - # Create ${libname}_ixlibrary.a entries in /sys/libs. - finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "(cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a)"; (cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a) || exit 1; done' - ;; - -freebsd2* | freebsd3*) - version_type=sunos - library_names_spec='${libname}${release}.so.$versuffix $libname.so' - finish_cmds='PATH="$PATH:/sbin" ldconfig -m $libdir' - shlibpath_var=LD_LIBRARY_PATH - ;; - -gnu*) - version_type=sunos - library_names_spec='${libname}${release}.so.$versuffix' - shlibpath_var=LD_LIBRARY_PATH - ;; - -hpux9* | hpux10*) - # Give a soname corresponding to the major version so that dld.sl refuses to - # link against other versions. - dynamic_linker="$host_os dld.sl" - version_type=sunos - shlibpath_var=SHLIB_PATH - library_names_spec='${libname}${release}.sl.$versuffix ${libname}${release}.sl.$major $libname.sl' - soname_spec='${libname}${release}.sl.$major' - # HP-UX runs *really* slowly unless shared libraries are mode 555. - postinstall_cmds='chmod 555 $lib' - ;; - -irix5* | irix6*) - version_type=osf - soname_spec='${libname}${release}.so' - library_names_spec='${libname}${release}.so.$versuffix $libname.so' - shlibpath_var=LD_LIBRARY_PATH - ;; - -# No shared lib support for Linux oldld, aout, or coff. -linux-gnuoldld* | linux-gnuaout* | linux-gnucoff*) - dynamic_linker=no - ;; - -# This must be Linux ELF. -linux-gnu*) - version_type=linux - library_names_spec='${libname}${release}.so.$versuffix ${libname}${release}.so.$major $libname.so' - soname_spec='${libname}${release}.so.$major' - finish_cmds='PATH="$PATH:/sbin" ldconfig -n $libdir' - shlibpath_var=LD_LIBRARY_PATH - - if test -f /lib/ld.so.1; then - dynamic_linker='GNU ld.so' - else - # Only the GNU ld.so supports shared libraries on MkLinux. - case "$host_cpu" in - powerpc*) dynamic_linker=no ;; - *) dynamic_linker='Linux ld.so' ;; - esac - fi - ;; - -netbsd* | openbsd*) - version_type=sunos - library_names_spec='${libname}${release}.so.$versuffix' - finish_cmds='PATH="$PATH:/sbin" ldconfig -m $libdir' - shlibpath_var=LD_LIBRARY_PATH - ;; - -os2*) - libname_spec='$name' - library_names_spec='$libname.dll $libname.a' - dynamic_linker='OS/2 ld.exe' - shlibpath_var=LIBPATH - ;; - -osf3* | osf4*) - version_type=osf - soname_spec='${libname}${release}.so' - library_names_spec='${libname}${release}.so.$versuffix $libname.so' - shlibpath_var=LD_LIBRARY_PATH - ;; - -sco3.2v5*) - version_type=osf - soname_spec='${libname}${release}.so.$major' - library_names_spec='${libname}${release}.so.$versuffix ${libname}${release}.so.$major $libname.so' - shlibpath_var=LD_LIBRARY_PATH - ;; - -solaris2*) - version_type=linux - library_names_spec='${libname}${release}.so.$versuffix ${libname}${release}.so.$major $libname.so' - soname_spec='${libname}${release}.so.$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -sunos4*) - version_type=sunos - library_names_spec='${libname}${release}.so.$versuffix' - finish_cmds='PATH="$PATH:/usr/etc" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - ;; - -sysv4.2uw2*) - version_type=linux - library_names_spec='${libname}${release}.so.$versuffix ${libname}${release}.so.$major $libname.so' - soname_spec='${libname}${release}.so.$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -uts4*) - version_type=linux - library_names_spec='${libname}${release}.so.$versuffix ${libname}${release}.so.$major $libname.so' - soname_spec='${libname}${release}.so.$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -*) - dynamic_linker=no - ;; -esac -echo "$ac_t$dynamic_linker" -test "$dynamic_linker" = no && can_build_shared=no - -# Report the final consequences. -echo "checking if libtool supports shared libraries... $can_build_shared" 1>&6 - -echo $ac_n "checking whether to build shared libraries... $ac_c" 1>&6 -test "$can_build_shared" = "no" && enable_shared=no - -# On AIX, shared libraries and static libraries use the same namespace, and -# are all built from PIC. -case "$host_os" in -aix*) - test "$enable_shared" = yes && enable_static=no - if test -n "$RANLIB"; then - archive_cmds="$archive_cmds;\$RANLIB \$lib" - postinstall_cmds='$RANLIB $lib' - fi - ;; -esac - -echo "$ac_t$enable_shared" 1>&6 - -# Make sure either enable_shared or enable_static is yes. -test "$enable_shared" = yes || enable_static=yes - -echo "checking whether to build static libraries... $enable_static" 1>&6 - -echo $ac_n "checking for objdir... $ac_c" 1>&6 -rm -f .libs 2>/dev/null -mkdir .libs 2>/dev/null -if test -d .libs; then - objdir=.libs -else - # MS-DOS does not allow filenames that begin with a dot. - objdir=_libs -fi -rmdir .libs 2>/dev/null -echo "$ac_t$objdir" 1>&6 - -# Copy echo and quote the copy, instead of the original, because it is -# used later. -ltecho="$echo" - -# Now quote all the things that may contain metacharacters. -for var in ltecho old_CC old_CFLAGS old_CPPFLAGS old_LD old_NM old_RANLIB \ - old_LN_S AR CC LD LN_S NM reload_flag reload_cmds wl pic_flag \ - link_static_flag no_builtin_flag export_dynamic_flag_spec \ - libname_spec library_names_spec soname_spec RANLIB \ - old_archive_cmds old_archive_from_new_cmds old_postinstall_cmds \ - old_postuninstall_cmds archive_cmds postinstall_cmds postuninstall_cmds \ - allow_undefined_flag no_undefined_flag \ - finish_cmds finish_eval global_symbol_pipe \ - hardcode_libdir_flag_spec hardcode_libdir_separator; do - - case "$var" in - reload_cmds | old_archive_cmds | old_archive_from_new_cmds | \ - old_postinstall_cmds | old_postuninstall_cmds | archive_cmds | \ - postinstall_cmds | postuninstall_cmds | finish_cmds) - # Double-quote double-evaled strings. - eval "$var=\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\"\`" - ;; - *) - eval "$var=\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`" - ;; - esac -done - -ofile=libtool -trap "$rm $ofile; exit 1" 1 2 15 -echo creating $ofile -$rm $ofile -cat <<EOF > $ofile -#! /bin/sh - -# libtool - Provide generalized library-building support services. -# Generated automatically by $PROGRAM - GNU $PACKAGE $VERSION -# NOTE: Changes made to this file will be lost: look at ltconfig or ltmain.sh. -# -# Copyright (C) 1996-1998 Free Software Foundation, Inc. -# Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# This program was configured as follows, -# on host `(hostname || uname -n) 2>/dev/null | sed 1q`: -# -# CC="$old_CC" CFLAGS="$old_CFLAGS" CPPFLAGS="$old_CPPFLAGS" \\ -# LD="$old_LD" NM="$old_NM" RANLIB="$old_RANLIB" LN_S="$old_LN_S" \\ -# $0$ltconfig_args -# -# Compiler and other test output produced by $progname, useful for -# debugging $progname, is in ./config.log if it exists. - -# Sed that helps us avoid accidentally triggering echo(1) options like -n. -Xsed="sed -e s/^X//" - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -if test "\${CDPATH+set}" = set; then CDPATH=; export CDPATH; fi - -# An echo program that does not interpret backslashes. -echo="$ltecho" - -# The version of $progname that generated this script. -LTCONFIG_VERSION="$VERSION" - -# Shell to use when invoking shell scripts. -SHELL=${CONFIG_SHELL-/bin/sh} - -# Whether or not to build libtool libraries. -build_libtool_libs=$enable_shared - -# Whether or not to build old-style libraries. -build_old_libs=$enable_static - -# The host system. -host_alias="$host_alias" -host="$host" - -# The archiver. -AR="$AR" - -# The default C compiler. -CC="$CC" - -# The linker used to build libraries. -LD="$LD" - -# Whether we need hard or soft links. -LN_S="$LN_S" - -# A BSD-compatible nm program. -NM="$NM" - -# The name of the directory that contains temporary libtool files. -objdir="$objdir" - -# How to create reloadable object files. -reload_flag="$reload_flag" -reload_cmds="$reload_cmds" - -# How to pass a linker flag through the compiler. -wl="$wl" - -# Additional compiler flags for building library objects. -pic_flag="$pic_flag" - -# Compiler flag to prevent dynamic linking. -link_static_flag="$link_static_flag" - -# Compiler flag to turn off builtin functions. -no_builtin_flag="$no_builtin_flag" - -# Compiler flag to allow reflexive dlopens. -export_dynamic_flag_spec="$export_dynamic_flag_spec" - -# Library versioning type. -version_type=$version_type - -# Format of library name prefix. -libname_spec="$libname_spec" - -# List of archive names. First name is the real one, the rest are links. -# The last name is the one that the linker finds with -lNAME. -library_names_spec="$library_names_spec" - -# The coded name of the library, if different from the real name. -soname_spec="$soname_spec" - -# Commands used to build and install an old-style archive. -RANLIB="$RANLIB" -old_archive_cmds="$old_archive_cmds" -old_postinstall_cmds="$old_postinstall_cmds" -old_postuninstall_cmds="$old_postuninstall_cmds" - -# Create an old-style archive from a shared archive. -old_archive_from_new_cmds="$old_archive_from_new_cmds" - -# Commands used to build and install a shared archive. -archive_cmds="$archive_cmds" -postinstall_cmds="$postinstall_cmds" -postuninstall_cmds="$postuninstall_cmds" - -# Flag that allows shared libraries with undefined symbols to be built. -allow_undefined_flag="$allow_undefined_flag" - -# Flag that forces no undefined symbols. -no_undefined_flag="$no_undefined_flag" - -# Commands used to finish a libtool library installation in a directory. -finish_cmds="$finish_cmds" - -# Same as above, but a single script fragment to be evaled but not shown. -finish_eval="$finish_eval" - -# Take the output of nm and produce a listing of raw symbols and C names. -global_symbol_pipe="$global_symbol_pipe" - -# This is the shared library runtime path variable. -runpath_var=$runpath_var - -# This is the shared library path variable. -shlibpath_var=$shlibpath_var - -# How to hardcode a shared library path into an executable. -hardcode_action=$hardcode_action - -# Flag to hardcode \$libdir into a binary during linking. -# This must work even if \$libdir does not exist. -hardcode_libdir_flag_spec="$hardcode_libdir_flag_spec" - -# Whether we need a single -rpath flag with a separated argument. -hardcode_libdir_separator="$hardcode_libdir_separator" - -# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the -# resulting binary. -hardcode_direct=$hardcode_direct - -# Set to yes if using the -LDIR flag during linking hardcodes DIR into the -# resulting binary. -hardcode_minus_L=$hardcode_minus_L - -# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into -# the resulting binary. -hardcode_shlibpath_var=$hardcode_shlibpath_var - -EOF - -case "$host_os" in -aix3*) - cat <<\EOF >> $ofile -# AIX sometimes has problems with the GCC collect2 program. For some -# reason, if we set the COLLECT_NAMES environment variable, the problems -# vanish in a puff of smoke. -if test "${COLLECT_NAMES+set}" != set; then - COLLECT_NAMES= - export COLLECT_NAMES -fi - -EOF - ;; -esac - -# Append the ltmain.sh script. -cat "$ltmain" >> $ofile || (rm -f $ofile; exit 1) - -chmod +x $ofile -exit 0 - -# Local Variables: -# mode:shell-script -# sh-indentation:2 -# End: diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/ltmain.sh b/irrlicht-1.6/source/Irrlicht/jpeglib/ltmain.sh deleted file mode 100644 index fe2d8508f..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/ltmain.sh +++ /dev/null @@ -1,2453 +0,0 @@ -# ltmain.sh - Provide generalized library-building support services. -# NOTE: Changing this file will not affect anything until you rerun ltconfig. -# -# Copyright (C) 1996-1998 Free Software Foundation, Inc. -# Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# The name of this program. -progname=`$echo "$0" | sed 's%^.*/%%'` -modename="$progname" - -# Constants. -PROGRAM=ltmain.sh -PACKAGE=libtool -VERSION=1.2 - -default_mode= -help="Try \`$progname --help' for more information." -magic="%%%MAGIC variable%%%" -mkdir="mkdir" -mv="mv -f" -rm="rm -f" - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -Xsed='sed -e s/^X//' -sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g' - -# NLS nuisances. -# Only set LANG and LC_ALL to C if already set. -# These must not be set unconditionally because not all systems understand -# e.g. LANG=C (notably SCO). -if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi -if test "${LANG+set}" = set; then LANG=C; export LANG; fi - -if test "$LTCONFIG_VERSION" != "$VERSION"; then - echo "$modename: ltconfig version \`$LTCONFIG_VERSION' does not match $PROGRAM version \`$VERSION'" 1>&2 - echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 - exit 1 -fi - -if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then - echo "$modename: not configured to build any kind of library" 1>&2 - echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 - exit 1 -fi - -# Global variables. -mode=$default_mode -nonopt= -prev= -prevopt= -run= -show="$echo" -show_help= -execute_dlfiles= - -# Parse our command line options once, thoroughly. -while test $# -gt 0 -do - arg="$1" - shift - - case "$arg" in - -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;; - *) optarg= ;; - esac - - # If the previous option needs an argument, assign it. - if test -n "$prev"; then - case "$prev" in - execute_dlfiles) - eval "$prev=\"\$$prev \$arg\"" - ;; - *) - eval "$prev=\$arg" - ;; - esac - - prev= - prevopt= - continue - fi - - # Have we seen a non-optional argument yet? - case "$arg" in - --help) - show_help=yes - ;; - - --version) - echo "$PROGRAM (GNU $PACKAGE) $VERSION" - exit 0 - ;; - - --dry-run | -n) - run=: - ;; - - --features) - echo "host: $host" - if test "$build_libtool_libs" = yes; then - echo "enable shared libraries" - else - echo "disable shared libraries" - fi - if test "$build_old_libs" = yes; then - echo "enable static libraries" - else - echo "disable static libraries" - fi - exit 0 - ;; - - --finish) mode="finish" ;; - - --mode) prevopt="--mode" prev=mode ;; - --mode=*) mode="$optarg" ;; - - --quiet | --silent) - show=: - ;; - - -dlopen) - prevopt="-dlopen" - prev=execute_dlfiles - ;; - - -*) - $echo "$modename: unrecognized option \`$arg'" 1>&2 - $echo "$help" 1>&2 - exit 1 - ;; - - *) - nonopt="$arg" - break - ;; - esac -done - -if test -n "$prevopt"; then - $echo "$modename: option \`$prevopt' requires an argument" 1>&2 - $echo "$help" 1>&2 - exit 1 -fi - -if test -z "$show_help"; then - - # Infer the operation mode. - if test -z "$mode"; then - case "$nonopt" in - *cc | *++ | gcc* | *-gcc*) - mode=link - for arg - do - case "$arg" in - -c) - mode=compile - break - ;; - esac - done - ;; - *db | *dbx) - mode=execute - ;; - *install*|cp|mv) - mode=install - ;; - *rm) - mode=uninstall - ;; - *) - # If we have no mode, but dlfiles were specified, then do execute mode. - test -n "$execute_dlfiles" && mode=execute - - # Just use the default operation mode. - if test -z "$mode"; then - if test -n "$nonopt"; then - $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2 - else - $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2 - fi - fi - ;; - esac - fi - - # Only execute mode is allowed to have -dlopen flags. - if test -n "$execute_dlfiles" && test "$mode" != execute; then - $echo "$modename: unrecognized option \`-dlopen'" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - # Change the help message to a mode-specific one. - generic_help="$help" - help="Try \`$modename --help --mode=$mode' for more information." - - # These modes are in order of execution frequency so that they run quickly. - case "$mode" in - # libtool compile mode - compile) - modename="$modename: compile" - # Get the compilation command and the source file. - base_compile= - lastarg= - srcfile="$nonopt" - suppress_output= - - for arg - do - # Accept any command-line options. - case "$arg" in - -o) - $echo "$modename: you cannot specify the output filename with \`-o'" 1>&2 - $echo "$help" 1>&2 - exit 1 - ;; - - -static) - build_libtool_libs=no - build_old_libs=yes - continue - ;; - esac - - # Accept the current argument as the source file. - lastarg="$srcfile" - srcfile="$arg" - - # Aesthetically quote the previous argument. - - # Backslashify any backslashes, double quotes, and dollar signs. - # These are the only characters that are still specially - # interpreted inside of double-quoted scrings. - lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"` - - # Double-quote args containing other shell metacharacters. - # Many Bourne shells cannot handle close brackets correctly in scan - # sets, so we specify it separately. - case "$lastarg" in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) - lastarg="\"$lastarg\"" - ;; - esac - - # Add the previous argument to base_compile. - if test -z "$base_compile"; then - base_compile="$lastarg" - else - base_compile="$base_compile $lastarg" - fi - done - - # Get the name of the library object. - libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'` - - # Recognize several different file suffixes. - xform='[cCFSfms]' - case "$libobj" in - *.ada) xform=ada ;; - *.adb) xform=adb ;; - *.ads) xform=ads ;; - *.asm) xform=asm ;; - *.c++) xform=c++ ;; - *.cc) xform=cc ;; - *.cpp) xform=cpp ;; - *.cxx) xform=cxx ;; - *.f90) xform=f90 ;; - *.for) xform=for ;; - esac - - libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"` - - case "$libobj" in - *.lo) obj=`$echo "X$libobj" | $Xsed -e 's/\.lo$/.o/'` ;; - *) - $echo "$modename: cannot determine name of library object from \`$srcfile'" 1>&2 - exit 1 - ;; - esac - - if test -z "$base_compile"; then - $echo "$modename: you must specify a compilation command" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - # Delete any leftover library objects. - if test "$build_old_libs" = yes; then - $run $rm $obj $libobj - trap "$run $rm $obj $libobj; exit 1" 1 2 15 - else - $run $rm $libobj - trap "$run $rm $libobj; exit 1" 1 2 15 - fi - - # Only build a PIC object if we are building libtool libraries. - if test "$build_libtool_libs" = yes; then - # Without this assignment, base_compile gets emptied. - fbsd_hideous_sh_bug=$base_compile - - # All platforms use -DPIC, to notify preprocessed assembler code. - $show "$base_compile$pic_flag -DPIC $srcfile" - if $run eval "$base_compile\$pic_flag -DPIC \$srcfile"; then : - else - test -n "$obj" && $run $rm $obj - exit 1 - fi - - # If we have no pic_flag, then copy the object into place and finish. - if test -z "$pic_flag"; then - $show "$LN_S $obj $libobj" - $run $LN_S $obj $libobj - exit $? - fi - - # Just move the object, then go on to compile the next one - $show "$mv $obj $libobj" - $run $mv $obj $libobj || exit 1 - - # Allow error messages only from the first compilation. - suppress_output=' >/dev/null 2>&1' - fi - - # Only build a position-dependent object if we build old libraries. - if test "$build_old_libs" = yes; then - # Suppress compiler output if we already did a PIC compilation. - $show "$base_compile $srcfile$suppress_output" - if $run eval "$base_compile \$srcfile$suppress_output"; then : - else - $run $rm $obj $libobj - exit 1 - fi - fi - - # Create an invalid libtool object if no PIC, so that we do not - # accidentally link it into a program. - if test "$build_libtool_libs" != yes; then - $show "echo timestamp > $libobj" - $run eval "echo timestamp > \$libobj" || exit $? - fi - - exit 0 - ;; - - # libtool link mode - link) - modename="$modename: link" - CC="$nonopt" - allow_undefined=yes - compile_command="$CC" - finalize_command="$CC" - - compile_shlibpath= - finalize_shlibpath= - deplibs= - dlfiles= - dlprefiles= - export_dynamic=no - hardcode_libdirs= - libobjs= - link_against_libtool_libs= - ltlibs= - objs= - prev= - prevarg= - release= - rpath= - perm_rpath= - temp_rpath= - vinfo= - - # We need to know -static, to get the right output filenames. - for arg - do - case "$arg" in - -all-static | -static) - if test "X$arg" = "X-all-static" && test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then - $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2 - fi - build_libtool_libs=no - build_old_libs=yes - break - ;; - esac - done - - # See if our shared archives depend on static archives. - test -n "$old_archive_from_new_cmds" && build_old_libs=yes - - # Go through the arguments, transforming them on the way. - for arg - do - # If the previous option needs an argument, assign it. - if test -n "$prev"; then - case "$prev" in - output) - compile_command="$compile_command @OUTPUT@" - finalize_command="$finalize_command @OUTPUT@" - ;; - esac - - case "$prev" in - dlfiles|dlprefiles) - case "$arg" in - *.la | *.lo) ;; # We handle these cases below. - *) - dlprefiles="$dlprefiles $arg" - test "$prev" = dlfiles && dlfiles="$dlfiles $arg" - prev= - ;; - esac - ;; - release) - release="-$arg" - prev= - continue - ;; - rpath) - rpath="$rpath $arg" - prev= - continue - ;; - *) - eval "$prev=\"\$arg\"" - prev= - continue - ;; - esac - fi - - prevarg="$arg" - - case "$arg" in - -all-static) - if test -n "$link_static_flag"; then - compile_command="$compile_command $link_static_flag" - finalize_command="$finalize_command $link_static_flag" - fi - continue - ;; - - -allow-undefined) - # FIXME: remove this flag sometime in the future. - $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2 - continue - ;; - - -dlopen) - prev=dlfiles - continue - ;; - - -dlpreopen) - prev=dlprefiles - continue - ;; - - -export-dynamic) - if test "$export_dynamic" != yes; then - export_dynamic=yes - if test -n "$export_dynamic_flag_spec"; then - eval arg=\"$export_dynamic_flag_spec\" - else - arg= - fi - - # Add the symbol object into the linking commands. - compile_command="$compile_command @SYMFILE@" - finalize_command="$finalize_command @SYMFILE@" - fi - ;; - - -L*) - dir=`$echo "X$arg" | $Xsed -e 's%^-L\(.*\)$%\1%'` - case "$dir" in - /* | [A-Za-z]:\\*) - # Add the corresponding hardcode_libdir_flag, if it is not identical. - ;; - *) - $echo "$modename: \`-L$dir' cannot specify a relative directory" 1>&2 - exit 1 - ;; - esac - deplibs="$deplibs $arg" - ;; - - -l*) deplibs="$deplibs $arg" ;; - - -no-undefined) - allow_undefined=no - continue - ;; - - -o) prev=output ;; - - -release) - prev=release - continue - ;; - - -rpath) - prev=rpath - continue - ;; - - -static) - # If we have no pic_flag, then this is the same as -all-static. - if test -z "$pic_flag" && test -n "$link_static_flag"; then - compile_command="$compile_command $link_static_flag" - finalize_command="$finalize_command $link_static_flag" - fi - continue - ;; - - -version-info) - prev=vinfo - continue - ;; - - # Some other compiler flag. - -* | +*) - # Unknown arguments in both finalize_command and compile_command need - # to be aesthetically quoted because they are evaled later. - arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - case "$arg" in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) - arg="\"$arg\"" - ;; - esac - ;; - - *.o | *.a) - # A standard object. - objs="$objs $arg" - ;; - - *.lo) - # A library object. - if test "$prev" = dlfiles; then - dlfiles="$dlfiles $arg" - if test "$build_libtool_libs" = yes; then - prev= - continue - else - # If libtool objects are unsupported, then we need to preload. - prev=dlprefiles - fi - fi - - if test "$prev" = dlprefiles; then - # Preload the old-style object. - dlprefiles="$dlprefiles "`$echo "X$arg" | $Xsed -e 's/\.lo$/\.o/'` - prev= - fi - libobjs="$libobjs $arg" - ;; - - *.la) - # A libtool-controlled library. - - dlname= - libdir= - library_names= - old_library= - - # Check to see that this really is a libtool archive. - if (sed -e '2q' $arg | egrep '^# Generated by ltmain\.sh') >/dev/null 2>&1; then : - else - $echo "$modename: \`$arg' is not a valid libtool archive" 1>&2 - exit 1 - fi - - # If there is no directory component, then add one. - case "$arg" in - */* | *\\*) . $arg ;; - *) . ./$arg ;; - esac - - if test -z "$libdir"; then - $echo "$modename: \`$arg' contains no -rpath information" 1>&2 - exit 1 - fi - - # Get the name of the library we link against. - linklib= - for l in $old_library $library_names; do - linklib="$l" - done - - if test -z "$linklib"; then - $echo "$modename: cannot find name of link library for \`$arg'" 1>&2 - exit 1 - fi - - # Find the relevant object directory and library name. - name=`$echo "X$arg" | $Xsed -e 's%^.*/%%' -e 's/\.la$//' -e 's/^lib//'` - dir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` - if test "X$dir" = "X$arg"; then - dir="$objdir" - else - dir="$dir/$objdir" - fi - - # This library was specified with -dlopen. - if test "$prev" = dlfiles; then - dlfiles="$dlfiles $arg" - if test -z "$dlname"; then - # If there is no dlname, we need to preload. - prev=dlprefiles - else - # We should not create a dependency on this library, but we - # may need any libraries it requires. - compile_command="$compile_command$dependency_libs" - finalize_command="$finalize_command$dependency_libs" - prev= - continue - fi - fi - - # The library was specified with -dlpreopen. - if test "$prev" = dlprefiles; then - # Prefer using a static library (so that no silly _DYNAMIC symbols - # are required to link). - if test -n "$old_library"; then - dlprefiles="$dlprefiles $dir/$old_library" - else - dlprefiles="$dlprefiles $dir/$linklib" - fi - prev= - fi - - if test "$build_libtool_libs" = yes && test -n "$library_names"; then - link_against_libtool_libs="$link_against_libtool_libs $arg" - if test -n "$shlibpath_var"; then - # Make sure the rpath contains only unique directories. - case "$temp_rpath " in - *" $dir "*) ;; - *) temp_rpath="$temp_rpath $dir" ;; - esac - fi - - # This is the magic to use -rpath. - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - if test -z "$hardcode_libdirs"; then - # Put the magic libdir with the hardcode flag. - hardcode_libdirs="$libdir" - libdir="@HARDCODE_LIBDIRS@" - else - # Just accumulate the unique libdirs. - case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" - ;; - esac - libdir= - fi - fi - - if test -n "$libdir"; then - eval flag=\"$hardcode_libdir_flag_spec\" - - compile_command="$compile_command $flag" - finalize_command="$finalize_command $flag" - fi - elif test -n "$runpath_var"; then - # Do the same for the permanent run path. - case "$perm_rpath " in - *" $libdir "*) ;; - *) perm_rpath="$perm_rpath $libdir" ;; - esac - fi - - - case "$hardcode_action" in - immediate) - if test "$hardcode_direct" = no; then - compile_command="$compile_command $dir/$linklib" - elif test "$hardcode_minus_L" = no; then - compile_command="$compile_command -L$dir -l$name" - elif test "$hardcode_shlibpath_var" = no; then - compile_shlibpath="$compile_shlibpath$dir:" - compile_command="$compile_command -l$name" - fi - ;; - - relink) - # We need an absolute path. - case "$dir" in - /* | [A-Za-z]:\\*) ;; - *) - absdir=`cd "$dir" && pwd` - if test -z "$absdir"; then - $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2 - exit 1 - fi - dir="$absdir" - ;; - esac - - if test "$hardcode_direct" = yes; then - compile_command="$compile_command $dir/$linklib" - elif test "$hardcode_minus_L" = yes; then - compile_command="$compile_command -L$dir -l$name" - elif test "$hardcode_shlibpath_var" = yes; then - compile_shlibpath="$compile_shlibpath$dir:" - compile_command="$compile_command -l$name" - fi - ;; - - *) - $echo "$modename: \`$hardcode_action' is an unknown hardcode action" 1>&2 - exit 1 - ;; - esac - - # Finalize command for both is simple: just hardcode it. - if test "$hardcode_direct" = yes; then - finalize_command="$finalize_command $libdir/$linklib" - elif test "$hardcode_minus_L" = yes; then - finalize_command="$finalize_command -L$libdir -l$name" - elif test "$hardcode_shlibpath_var" = yes; then - finalize_shlibpath="$finalize_shlibpath$libdir:" - finalize_command="$finalize_command -l$name" - else - # We cannot seem to hardcode it, guess we'll fake it. - finalize_command="$finalize_command -L$libdir -l$name" - fi - else - # Transform directly to old archives if we don't build new libraries. - if test -n "$pic_flag" && test -z "$old_library"; then - $echo "$modename: cannot find static library for \`$arg'" 1>&2 - exit 1 - fi - - # Here we assume that one of hardcode_direct or hardcode_minus_L - # is not unsupported. This is valid on all known static and - # shared platforms. - if test "$hardcode_direct" != unsupported; then - test -n "$old_library" && linklib="$old_library" - compile_command="$compile_command $dir/$linklib" - finalize_command="$finalize_command $dir/$linklib" - else - compile_command="$compile_command -L$dir -l$name" - finalize_command="$finalize_command -L$dir -l$name" - fi - fi - - # Add in any libraries that this one depends upon. - compile_command="$compile_command$dependency_libs" - finalize_command="$finalize_command$dependency_libs" - continue - ;; - - # Some other compiler argument. - *) - # Unknown arguments in both finalize_command and compile_command need - # to be aesthetically quoted because they are evaled later. - arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - case "$arg" in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) - arg="\"$arg\"" - ;; - esac - ;; - esac - - # Now actually substitute the argument into the commands. - if test -n "$arg"; then - compile_command="$compile_command $arg" - finalize_command="$finalize_command $arg" - fi - done - - if test -n "$prev"; then - $echo "$modename: the \`$prevarg' option requires an argument" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - if test -n "$vinfo" && test -n "$release"; then - $echo "$modename: you cannot specify both \`-version-info' and \`-release'" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - oldlib= - oldobjs= - case "$output" in - "") - $echo "$modename: you must specify an output file" 1>&2 - $echo "$help" 1>&2 - exit 1 - ;; - - */* | *\\*) - $echo "$modename: output file \`$output' must have no directory components" 1>&2 - exit 1 - ;; - - *.a) - # Now set the variables for building old libraries. - build_libtool_libs=no - build_old_libs=yes - oldlib="$output" - $show "$rm $oldlib" - $run $rm $oldlib - ;; - - *.la) - # Make sure we only generate libraries of the form `libNAME.la'. - case "$output" in - lib*) ;; - *) - $echo "$modename: libtool library \`$arg' must begin with \`lib'" 1>&2 - $echo "$help" 1>&2 - exit 1 - ;; - esac - - name=`$echo "X$output" | $Xsed -e 's/\.la$//' -e 's/^lib//'` - eval libname=\"$libname_spec\" - - # All the library-specific variables (install_libdir is set above). - library_names= - old_library= - dlname= - current=0 - revision=0 - age=0 - - if test -n "$objs"; then - $echo "$modename: cannot build libtool library \`$output' from non-libtool objects:$objs" 2>&1 - exit 1 - fi - - # How the heck are we supposed to write a wrapper for a shared library? - if test -n "$link_against_libtool_libs"; then - $echo "$modename: libtool library \`$output' may not depend on uninstalled libraries:$link_against_libtool_libs" 1>&2 - exit 1 - fi - - if test -n "$dlfiles$dlprefiles"; then - $echo "$modename: warning: \`-dlopen' is ignored while creating libtool libraries" 1>&2 - # Nullify the symbol file. - compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` - finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` - fi - - if test -z "$rpath"; then - $echo "$modename: you must specify an installation directory with \`-rpath'" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - set dummy $rpath - if test $# -gt 2; then - $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2 - fi - install_libdir="$2" - - # Parse the version information argument. - IFS="${IFS= }"; save_ifs="$IFS"; IFS=':' - set dummy $vinfo - IFS="$save_ifs" - - if test -n "$5"; then - $echo "$modename: too many parameters to \`-version-info'" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - test -n "$2" && current="$2" - test -n "$3" && revision="$3" - test -n "$4" && age="$4" - - # Check that each of the things are valid numbers. - case "$current" in - 0 | [1-9] | [1-9][0-9]*) ;; - *) - $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2 - $echo "$modename: \`$vinfo' is not valid version information" 1>&2 - exit 1 - ;; - esac - - case "$revision" in - 0 | [1-9] | [1-9][0-9]*) ;; - *) - $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2 - $echo "$modename: \`$vinfo' is not valid version information" 1>&2 - exit 1 - ;; - esac - - case "$age" in - 0 | [1-9] | [1-9][0-9]*) ;; - *) - $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2 - $echo "$modename: \`$vinfo' is not valid version information" 1>&2 - exit 1 - ;; - esac - - if test $age -gt $current; then - $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2 - $echo "$modename: \`$vinfo' is not valid version information" 1>&2 - exit 1 - fi - - # Calculate the version variables. - version_vars="version_type current age revision" - case "$version_type" in - none) ;; - - linux) - version_vars="$version_vars major versuffix" - major=`expr $current - $age` - versuffix="$major.$age.$revision" - ;; - - osf) - version_vars="$version_vars versuffix verstring" - major=`expr $current - $age` - versuffix="$current.$age.$revision" - verstring="$versuffix" - - # Add in all the interfaces that we are compatible with. - loop=$age - while test $loop != 0; do - iface=`expr $current - $loop` - loop=`expr $loop - 1` - verstring="$verstring:${iface}.0" - done - - # Make executables depend on our current version. - verstring="$verstring:${current}.0" - ;; - - sunos) - version_vars="$version_vars major versuffix" - major="$current" - versuffix="$current.$revision" - ;; - - *) - $echo "$modename: unknown library version type \`$version_type'" 1>&2 - echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 - exit 1 - ;; - esac - - # Create the output directory, or remove our outputs if we need to. - if test -d $objdir; then - $show "$rm $objdir/$output $objdir/$libname.* $objdir/${libname}${release}.*" - $run $rm $objdir/$output $objdir/$libname.* $objdir/${libname}${release}.* - else - $show "$mkdir $objdir" - $run $mkdir $objdir - status=$? - if test $status -eq 0 || test -d $objdir; then : - else - exit $status - fi - fi - - # Check to see if the archive will have undefined symbols. - if test "$allow_undefined" = yes; then - if test "$allow_undefined_flag" = unsupported; then - $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2 - build_libtool_libs=no - build_old_libs=yes - fi - else - # Don't allow undefined symbols. - allow_undefined_flag="$no_undefined_flag" - fi - - # Add libc to deplibs on all systems. - dependency_libs="$deplibs" - deplibs="$deplibs -lc" - - if test "$build_libtool_libs" = yes; then - # Get the real and link names of the library. - eval library_names=\"$library_names_spec\" - set dummy $library_names - realname="$2" - shift; shift - - if test -n "$soname_spec"; then - eval soname=\"$soname_spec\" - else - soname="$realname" - fi - - lib="$objdir/$realname" - for link - do - linknames="$linknames $link" - done - - # Use standard objects if they are PIC. - test -z "$pic_flag" && libobjs=`$echo "X$libobjs " | $Xsed -e 's/\.lo /.o /g' -e 's/ $//g'` - - # Do each of the archive commands. - eval cmds=\"$archive_cmds\" - IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - - # Create links to the real library. - for linkname in $linknames; do - $show "(cd $objdir && $LN_S $realname $linkname)" - $run eval '(cd $objdir && $LN_S $realname $linkname)' || exit $? - done - - # If -export-dynamic was specified, set the dlname. - if test "$export_dynamic" = yes; then - # On all known operating systems, these are identical. - dlname="$soname" - fi - fi - - # Now set the variables for building old libraries. - oldlib="$objdir/$libname.a" - ;; - - *.lo | *.o) - if test -n "$link_against_libtool_libs"; then - $echo "$modename: error: cannot link libtool libraries into reloadable objects" 1>&2 - exit 1 - fi - - if test -n "$deplibs"; then - $echo "$modename: warning: \`-l' and \`-L' are ignored while creating objects" 1>&2 - fi - - if test -n "$dlfiles$dlprefiles"; then - $echo "$modename: warning: \`-dlopen' is ignored while creating objects" 1>&2 - # Nullify the symbol file. - compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` - finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` - fi - - if test -n "$rpath"; then - $echo "$modename: warning: \`-rpath' is ignored while creating objects" 1>&2 - fi - - if test -n "$vinfo"; then - $echo "$modename: warning: \`-version-info' is ignored while creating objects" 1>&2 - fi - - if test -n "$release"; then - $echo "$modename: warning: \`-release' is ignored while creating objects" 1>&2 - fi - - case "$output" in - *.lo) - if test -n "$objs"; then - $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2 - exit 1 - fi - libobj="$output" - obj=`$echo "X$output" | $Xsed -e 's/\.lo$/.o/'` - ;; - *) - libobj= - obj="$output" - ;; - esac - - # Delete the old objects. - $run $rm $obj $libobj - - # Create the old-style object. - reload_objs="$objs"`$echo "X$libobjs " | $Xsed -e 's/[^ ]*\.a //g' -e 's/\.lo /.o /g' -e 's/ $//g'` - - output="$obj" - eval cmds=\"$reload_cmds\" - IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - - # Exit if we aren't doing a library object file. - test -z "$libobj" && exit 0 - - if test "$build_libtool_libs" != yes; then - # Create an invalid libtool object if no PIC, so that we don't - # accidentally link it into a program. - $show "echo timestamp > $libobj" - $run eval "echo timestamp > $libobj" || exit $? - exit 0 - fi - - if test -n "$pic_flag"; then - # Only do commands if we really have different PIC objects. - reload_objs="$libobjs" - output="$libobj" - eval cmds=\"$reload_cmds\" - IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - else - # Just create a symlink. - $show "$LN_S $obj $libobj" - $run $LN_S $obj $libobj || exit 1 - fi - - exit 0 - ;; - - *) - if test -n "$vinfo"; then - $echo "$modename: warning: \`-version-info' is ignored while linking programs" 1>&2 - fi - - if test -n "$release"; then - $echo "$modename: warning: \`-release' is ignored while creating objects" 1>&2 - fi - - if test -n "$rpath"; then - # If the user specified any rpath flags, then add them. - for libdir in $rpath; do - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - if test -z "$hardcode_libdirs"; then - # Put the magic libdir with the hardcode flag. - hardcode_libdirs="$libdir" - libdir="@HARDCODE_LIBDIRS@" - else - # Just accumulate the unique libdirs. - case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" - ;; - esac - libdir= - fi - fi - - if test -n "$libdir"; then - eval flag=\"$hardcode_libdir_flag_spec\" - - compile_command="$compile_command $flag" - finalize_command="$finalize_command $flag" - fi - elif test -n "$runpath_var"; then - case "$perm_rpath " in - *" $libdir "*) ;; - *) perm_rpath="$perm_rpath $libdir" ;; - esac - fi - done - fi - - # Substitute the hardcoded libdirs into the compile commands. - if test -n "$hardcode_libdir_separator"; then - compile_command=`$echo "X$compile_command" | $Xsed -e "s%@HARDCODE_LIBDIRS@%$hardcode_libdirs%g"` - finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@HARDCODE_LIBDIRS@%$hardcode_libdirs%g"` - fi - - if test -n "$libobjs" && test "$build_old_libs" = yes; then - # Transform all the library objects into standard objects. - compile_command=`$echo "X$compile_command " | $Xsed -e 's/\.lo /.o /g' -e 's/ $//'` - finalize_command=`$echo "X$finalize_command " | $Xsed -e 's/\.lo /.o /g' -e 's/ $//'` - fi - - if test "$export_dynamic" = yes && test -n "$NM" && test -n "$global_symbol_pipe"; then - dlsyms="${output}S.c" - else - dlsyms= - fi - - if test -n "$dlsyms"; then - # Add our own program objects to the preloaded list. - dlprefiles=`$echo "X$objs$dlprefiles " | $Xsed -e 's/\.lo /.o /g' -e 's/ $//'` - - # Discover the nlist of each of the dlfiles. - nlist="$objdir/${output}.nm" - - if test -d $objdir; then - $show "$rm $nlist ${nlist}T" - $run $rm "$nlist" "${nlist}T" - else - $show "$mkdir $objdir" - $run $mkdir $objdir - status=$? - if test $status -eq 0 || test -d $objdir; then : - else - exit $status - fi - fi - - for arg in $dlprefiles; do - $show "extracting global C symbols from \`$arg'" - $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" - done - - # Parse the name list into a source file. - $show "creating $objdir/$dlsyms" - if test -z "$run"; then - # Make sure we at least have an empty file. - test -f "$nlist" || : > "$nlist" - - # Try sorting and uniquifying the output. - if sort "$nlist" | uniq > "$nlist"T; then - mv -f "$nlist"T "$nlist" - wcout=`wc "$nlist" 2>/dev/null` - count=`echo "X$wcout" | $Xsed -e 's/^[ ]*\([0-9][0-9]*\).*$/\1/'` - (test "$count" -ge 0) 2>/dev/null || count=-1 - else - $rm "$nlist"T - count=-1 - fi - - case "$dlsyms" in - "") ;; - *.c) - $echo > "$objdir/$dlsyms" "\ -/* $dlsyms - symbol resolution table for \`$output' dlsym emulation. */ -/* Generated by $PROGRAM - GNU $PACKAGE $VERSION */ - -#ifdef __cplusplus -extern \"C\" { -#endif - -/* Prevent the only kind of declaration conflicts we can make. */ -#define dld_preloaded_symbol_count some_other_symbol -#define dld_preloaded_symbols some_other_symbol - -/* External symbol declarations for the compiler. */\ -" - - if test -f "$nlist"; then - sed -e 's/^.* \(.*\)$/extern char \1;/' < "$nlist" >> "$objdir/$dlsyms" - else - echo '/* NONE */' >> "$objdir/$dlsyms" - fi - - $echo >> "$objdir/$dlsyms" "\ - -#undef dld_preloaded_symbol_count -#undef dld_preloaded_symbols - -#if defined (__STDC__) && __STDC__ -# define __ptr_t void * -#else -# define __ptr_t char * -#endif - -/* The number of symbols in dld_preloaded_symbols, -1 if unsorted. */ -int dld_preloaded_symbol_count = $count; - -/* The mapping between symbol names and symbols. */ -struct { - char *name; - __ptr_t address; -} -dld_preloaded_symbols[] = -{\ -" - - if test -f "$nlist"; then - sed 's/^\(.*\) \(.*\)$/ {"\1", (__ptr_t) \&\2},/' < "$nlist" >> "$objdir/$dlsyms" - fi - - $echo >> "$objdir/$dlsyms" "\ - {0, (__ptr_t) 0} -}; - -#ifdef __cplusplus -} -#endif\ -" - ;; - - *) - $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2 - exit 1 - ;; - esac - fi - - # Now compile the dynamic symbol file. - $show "(cd $objdir && $CC -c$no_builtin_flag \"$dlsyms\")" - $run eval '(cd $objdir && $CC -c$no_builtin_flag "$dlsyms")' || exit $? - - # Transform the symbol file into the correct name. - compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$objdir/${output}S.o%"` - finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$objdir/${output}S.o%"` - elif test "$export_dynamic" != yes; then - test -n "$dlfiles$dlprefiles" && $echo "$modename: warning: \`-dlopen' and \`-dlpreopen' are ignored without \`-export-dynamic'" 1>&2 - else - # We keep going just in case the user didn't refer to - # dld_preloaded_symbols. The linker will fail if global_symbol_pipe - # really was required. - $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2 - - # Nullify the symbol file. - compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` - finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` - fi - - if test -z "$link_against_libtool_libs" || test "$build_libtool_libs" != yes; then - # Replace the output file specification. - compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` - finalize_command=`$echo "X$finalize_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` - - # We have no uninstalled library dependencies, so finalize right now. - $show "$compile_command" - $run eval "$compile_command" - exit $? - fi - - # Replace the output file specification. - compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$objdir/$output"'%g'` - finalize_command=`$echo "X$finalize_command" | $Xsed -e 's%@OUTPUT@%'"$objdir/$output"'T%g'` - - # Create the binary in the object directory, then wrap it. - if test -d $objdir; then : - else - $show "$mkdir $objdir" - $run $mkdir $objdir - status=$? - if test $status -eq 0 || test -d $objdir; then : - else - exit $status - fi - fi - - if test -n "$shlibpath_var"; then - # We should set the shlibpath_var - rpath= - for dir in $temp_rpath; do - case "$dir" in - /* | [A-Za-z]:\\*) - # Absolute path. - rpath="$rpath$dir:" - ;; - *) - # Relative path: add a thisdir entry. - rpath="$rpath\$thisdir/$dir:" - ;; - esac - done - temp_rpath="$rpath" - fi - - # Delete the old output file. - $run $rm $output - - if test -n "$compile_shlibpath"; then - compile_command="$shlibpath_var=\"$compile_shlibpath\$$shlibpath_var\" $compile_command" - fi - if test -n "$finalize_shlibpath"; then - finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" - fi - - if test -n "$runpath_var" && test -n "$perm_rpath"; then - # We should set the runpath_var. - rpath= - for dir in $perm_rpath; do - rpath="$rpath$dir:" - done - compile_command="$runpath_var=\"$rpath\$$runpath_var\" $compile_command" - finalize_command="$runpath_var=\"$rpath\$$runpath_var\" $finalize_command" - fi - - case "$hardcode_action" in - relink) - # AGH! Flame the AIX and HP-UX people for me, will ya? - $echo "$modename: warning: using a buggy system linker" 1>&2 - $echo "$modename: relinking will be required before \`$output' can be installed" 1>&2 - ;; - esac - - $show "$compile_command" - $run eval "$compile_command" || exit $? - - # Now create the wrapper script. - $show "creating $output" - - # Quote the finalize command for shipping. - finalize_command=`$echo "X$finalize_command" | $Xsed -e "$sed_quote_subst"` - - # Quote $echo for shipping. - qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"` - - # Only actually do things if our run command is non-null. - if test -z "$run"; then - $rm $output - trap "$rm $output; exit 1" 1 2 15 - - $echo > $output "\ -#! /bin/sh - -# $output - temporary wrapper script for $objdir/$output -# Generated by ltmain.sh - GNU $PACKAGE $VERSION -# -# The $output program cannot be directly executed until all the libtool -# libraries that it depends on are installed. -# -# This wrapper script should never be moved out of \``pwd`'. -# If it is, it will not operate correctly. - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -Xsed='sed -e s/^X//' -sed_quote_subst='$sed_quote_subst' - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -if test \"\${CDPATH+set}\" = set; then CDPATH=; export CDPATH; fi - -# This environment variable determines our operation mode. -if test \"\$libtool_install_magic\" = \"$magic\"; then - # install mode needs the following variables: - link_against_libtool_libs='$link_against_libtool_libs' - finalize_command=\"$finalize_command\" -else - # When we are sourced in execute mode, \$file and \$echo are already set. - if test \"\$libtool_execute_magic\" = \"$magic\"; then : - else - echo=\"$qecho\" - file=\"\$0\" - fi\ -" - $echo >> $output "\ - - # Find the directory that this script lives in. - thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\` - test \"x\$thisdir\" = \"x\$file\" && thisdir=. - - # Follow symbolic links until we get to the real thisdir. - file=\`ls -ld \"\$file\" | sed -n 's/.*-> //p'\` - while test -n \"\$file\"; do - destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` - - # If there was a directory component, then change thisdir. - if test \"x\$destdir\" != \"x\$file\"; then - case \"\$destdir\" in - /* | [A-Za-z]:\\*) thisdir=\"\$destdir\" ;; - *) thisdir=\"\$thisdir/\$destdir\" ;; - esac - fi - - file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\` - file=\`ls -ld \"\$thisdir/\$file\" | sed -n 's/.*-> //p'\` - done - - # Try to get the absolute directory name. - absdir=\`cd \"\$thisdir\" && pwd\` - test -n \"\$absdir\" && thisdir=\"\$absdir\" - - progdir=\"\$thisdir/$objdir\" - program='$output' - - if test -f \"\$progdir/\$program\"; then" - - # Export our shlibpath_var if we have one. - if test -n "$shlibpath_var" && test -n "$temp_rpath"; then - $echo >> $output "\ - # Add our own library path to $shlibpath_var - $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" - - # Some systems cannot cope with colon-terminated $shlibpath_var - $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/:*\$//'\` - - export $shlibpath_var -" - fi - - $echo >> $output "\ - if test \"\$libtool_execute_magic\" != \"$magic\"; then - # Run the actual program with our arguments. - - # Export the path to the program. - PATH=\"\$progdir:\$PATH\" - export PATH - - exec \$program \${1+\"\$@\"} - - \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\" - exit 1 - fi - else - # The program doesn't exist. - \$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2 - \$echo \"This script is just a wrapper for \$program.\" 1>&2 - echo \"See the $PACKAGE documentation for more information.\" 1>&2 - exit 1 - fi -fi\ -" - chmod +x $output - fi - exit 0 - ;; - esac - - # See if we need to build an old-fashioned archive. - if test "$build_old_libs" = "yes"; then - # Transform .lo files to .o files. - oldobjs="$objs"`$echo "X$libobjs " | $Xsed -e 's/[^ ]*\.a //g' -e 's/\.lo /.o /g' -e 's/ $//g'` - - # Do each command in the archive commands. - if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then - eval cmds=\"$old_archive_from_new_cmds\" - else - eval cmds=\"$old_archive_cmds\" - fi - IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - fi - - # Now create the libtool archive. - case "$output" in - *.la) - old_library= - test "$build_old_libs" = yes && old_library="$libname.a" - - $show "creating $output" - - # Only create the output if not a dry run. - if test -z "$run"; then - $echo > $output "\ -# $output - a libtool library file -# Generated by ltmain.sh - GNU $PACKAGE $VERSION - -# The name that we can dlopen(3). -dlname='$dlname' - -# Names of this library. -library_names='$library_names' - -# The name of the static archive. -old_library='$old_library' - -# Libraries that this one depends upon. -dependency_libs='$dependency_libs' - -# Version information for $libname. -current=$current -age=$age -revision=$revision - -# Directory that this library needs to be installed in: -libdir='$install_libdir'\ -" - fi - - # Do a symbolic link so that the libtool archive can be found in - # LD_LIBRARY_PATH before the program is installed. - $show "(cd $objdir && $LN_S ../$output $output)" - $run eval "(cd $objdir && $LN_S ../$output $output)" || exit 1 - ;; - esac - exit 0 - ;; - - # libtool install mode - install) - modename="$modename: install" - - # There may be an optional /bin/sh argument at the beginning of - # install_prog (especially on Windows NT). - if test "$nonopt" = "$SHELL"; then - # Aesthetically quote it. - arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"` - case "$arg" in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) - arg="\"$arg\"" - ;; - esac - install_prog="$arg " - arg="$1" - shift - else - install_prog= - arg="$nonopt" - fi - - # The real first argument should be the name of the installation program. - # Aesthetically quote it. - arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - case "$arg" in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) - arg="\"$arg\"" - ;; - esac - install_prog="$install_prog$arg" - - # We need to accept at least all the BSD install flags. - dest= - files= - opts= - prev= - install_type= - isdir= - stripme= - for arg - do - if test -n "$dest"; then - files="$files $dest" - dest="$arg" - continue - fi - - case "$arg" in - -d) isdir=yes ;; - -f) prev="-f" ;; - -g) prev="-g" ;; - -m) prev="-m" ;; - -o) prev="-o" ;; - -s) - stripme=" -s" - continue - ;; - -*) ;; - - *) - # If the previous option needed an argument, then skip it. - if test -n "$prev"; then - prev= - else - dest="$arg" - continue - fi - ;; - esac - - # Aesthetically quote the argument. - arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - case "$arg" in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) - arg="\"$arg\"" - ;; - esac - install_prog="$install_prog $arg" - done - - if test -z "$install_prog"; then - $echo "$modename: you must specify an install program" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - if test -n "$prev"; then - $echo "$modename: the \`$prev' option requires an argument" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - if test -z "$files"; then - if test -z "$dest"; then - $echo "$modename: no file or destination specified" 1>&2 - else - $echo "$modename: you must specify a destination" 1>&2 - fi - $echo "$help" 1>&2 - exit 1 - fi - - # Strip any trailing slash from the destination. - dest=`$echo "X$dest" | $Xsed -e 's%/$%%'` - - # Check to see that the destination is a directory. - test -d "$dest" && isdir=yes - if test -n "$isdir"; then - destdir="$dest" - destname= - else - destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'` - test "X$destdir" = "X$dest" && destdir=. - destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'` - - # Not a directory, so check to see that there is only one file specified. - set dummy $files - if test $# -gt 2; then - $echo "$modename: \`$dest' is not a directory" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - fi - case "$destdir" in - /* | [A-Za-z]:\\*) ;; - *) - for file in $files; do - case "$file" in - *.lo) ;; - *) - $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2 - $echo "$help" 1>&2 - exit 1 - ;; - esac - done - ;; - esac - - # This variable tells wrapper scripts just to set variables rather - # than running their programs. - libtool_install_magic="$magic" - - staticlibs= - future_libdirs= - current_libdirs= - for file in $files; do - - # Do each installation. - case "$file" in - *.a) - # Do the static libraries later. - staticlibs="$staticlibs $file" - ;; - - *.la) - # Check to see that this really is a libtool archive. - if (sed -e '2q' $file | egrep '^# Generated by ltmain\.sh') >/dev/null 2>&1; then : - else - $echo "$modename: \`$file' is not a valid libtool archive" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - library_names= - old_library= - # If there is no directory component, then add one. - case "$file" in - */* | *\\*) . $file ;; - *) . ./$file ;; - esac - - # Add the libdir to current_libdirs if it is the destination. - if test "X$destdir" = "X$libdir"; then - case "$current_libdirs " in - *" $libdir "*) ;; - *) current_libdirs="$current_libdirs $libdir" ;; - esac - else - # Note the libdir as a future libdir. - case "$future_libdirs " in - *" $libdir "*) ;; - *) future_libdirs="$future_libdirs $libdir" ;; - esac - fi - - dir="`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/" - test "X$dir" = "X$file/" && dir= - dir="$dir$objdir" - - # See the names of the shared library. - set dummy $library_names - if test -n "$2"; then - realname="$2" - shift - shift - - # Install the shared library and build the symlinks. - $show "$install_prog $dir/$realname $destdir/$realname" - $run eval "$install_prog $dir/$realname $destdir/$realname" || exit $? - test "X$dlname" = "X$realname" && dlname= - - if test $# -gt 0; then - # Delete the old symlinks. - rmcmd="$rm" - for linkname - do - rmcmd="$rmcmd $destdir/$linkname" - done - $show "$rmcmd" - $run $rmcmd - - # ... and create new ones. - for linkname - do - test "X$dlname" = "X$linkname" && dlname= - $show "(cd $destdir && $LN_S $realname $linkname)" - $run eval "(cd $destdir && $LN_S $realname $linkname)" - done - fi - - if test -n "$dlname"; then - # Install the dynamically-loadable library. - $show "$install_prog $dir/$dlname $destdir/$dlname" - $run eval "$install_prog $dir/$dlname $destdir/$dlname" || exit $? - fi - - # Do each command in the postinstall commands. - lib="$destdir/$realname" - eval cmds=\"$postinstall_cmds\" - IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - fi - - # Install the pseudo-library for information purposes. - name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - $show "$install_prog $file $destdir/$name" - $run eval "$install_prog $file $destdir/$name" || exit $? - - # Maybe install the static library, too. - test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" - ;; - - *.lo) - # Install (i.e. copy) a libtool object. - - # Figure out destination file name, if it wasn't already specified. - if test -n "$destname"; then - destfile="$destdir/$destname" - else - destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - destfile="$destdir/$destfile" - fi - - # Deduce the name of the destination old-style object file. - case "$destfile" in - *.lo) - staticdest=`$echo "X$destfile" | $Xsed -e 's/\.lo$/\.o/'` - ;; - *.o) - staticdest="$destfile" - destfile= - ;; - *) - $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2 - $echo "$help" 1>&2 - exit 1 - ;; - esac - - # Install the libtool object if requested. - if test -n "$destfile"; then - $show "$install_prog $file $destfile" - $run eval "$install_prog $file $destfile" || exit $? - fi - - # Install the old object if enabled. - if test "$build_old_libs" = yes; then - # Deduce the name of the old-style object file. - staticobj=`$echo "X$file" | $Xsed -e 's/\.lo$/\.o/'` - - $show "$install_prog $staticobj $staticdest" - $run eval "$install_prog \$staticobj \$staticdest" || exit $? - fi - exit 0 - ;; - - *) - # Do a test to see if this is really a libtool program. - if (sed -e '4q' $file | egrep '^# Generated by ltmain\.sh') >/dev/null 2>&1; then - link_against_libtool_libs= - finalize_command= - - # If there is no directory component, then add one. - case "$file" in - */* | *\\*) . $file ;; - *) . ./$file ;; - esac - - # Check the variables that should have been set. - if test -z "$link_against_libtool_libs" || test -z "$finalize_command"; then - $echo "$modename: invalid libtool wrapper script \`$file'" 1>&2 - exit 1 - fi - - finalize=yes - for lib in $link_against_libtool_libs; do - # Check to see that each library is installed. - libdir= - if test -f "$lib"; then - # If there is no directory component, then add one. - case "$lib" in - */* | *\\*) . $lib ;; - *) . ./$lib ;; - esac - fi - libfile="$libdir/`$echo "X$lib" | $Xsed -e 's%^.*/%%g'`" - if test -z "$libdir"; then - $echo "$modename: warning: \`$lib' contains no -rpath information" 1>&2 - elif test -f "$libfile"; then : - else - $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2 - finalize=no - fi - done - - if test "$hardcode_action" = relink; then - if test "$finalize" = yes; then - $echo "$modename: warning: relinking \`$file' on behalf of your buggy system linker" 1>&2 - $show "$finalize_command" - if $run eval "$finalize_command"; then : - else - $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 - continue - fi - file="$objdir/$file"T - else - $echo "$modename: warning: cannot relink \`$file' on behalf of your buggy system linker" 1>&2 - fi - else - # Install the binary that we compiled earlier. - file=`$echo "X$file" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` - fi - fi - - $show "$install_prog$stripme $file $dest" - $run eval "$install_prog\$stripme \$file \$dest" || exit $? - ;; - esac - done - - for file in $staticlibs; do - name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - - # Set up the ranlib parameters. - oldlib="$destdir/$name" - - $show "$install_prog $file $oldlib" - $run eval "$install_prog \$file \$oldlib" || exit $? - - # Do each command in the postinstall commands. - eval cmds=\"$old_postinstall_cmds\" - IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - done - - if test -n "$future_libdirs"; then - $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2 - fi - - if test -n "$current_libdirs"; then - # Maybe just do a dry run. - test -n "$run" && current_libdirs=" -n$current_libdirs" - exec $SHELL $0 --finish$current_libdirs - exit 1 - fi - - exit 0 - ;; - - # libtool finish mode - finish) - modename="$modename: finish" - libdirs="$nonopt" - - if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then - for dir - do - libdirs="$libdirs $dir" - done - - for libdir in $libdirs; do - if test -n "$finish_cmds"; then - # Do each command in the finish commands. - eval cmds=\"$finish_cmds\" - IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" - done - IFS="$save_ifs" - fi - if test -n "$finish_eval"; then - # Do the single finish_eval. - eval cmds=\"$finish_eval\" - $run eval "$cmds" - fi - done - fi - - echo "------------------------------------------------------------------------------" - echo "Libraries have been installed in:" - for libdir in $libdirs; do - echo " $libdir" - done - echo - echo "To link against installed libraries in a given directory, LIBDIR," - echo "you must use the \`-LLIBDIR' flag during linking." - echo - echo " You will also need to do one of the following:" - if test -n "$shlibpath_var"; then - echo " - add LIBDIR to the \`$shlibpath_var' environment variable" - echo " during execution" - fi - if test -n "$runpath_var"; then - echo " - add LIBDIR to the \`$runpath_var' environment variable" - echo " during linking" - fi - if test -n "$hardcode_libdir_flag_spec"; then - libdir=LIBDIR - eval flag=\"$hardcode_libdir_flag_spec\" - - echo " - use the \`$flag' linker flag" - fi - if test -f /etc/ld.so.conf; then - echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" - fi - echo - echo "See any operating system documentation about shared libraries for" - echo "more information, such as the ld(1) and ld.so(8) manual pages." - echo "------------------------------------------------------------------------------" - exit 0 - ;; - - # libtool execute mode - execute) - modename="$modename: execute" - - # The first argument is the command name. - cmd="$nonopt" - if test -z "$cmd"; then - $echo "$modename: you must specify a COMMAND" 1>&2 - $echo "$help" - exit 1 - fi - - # Handle -dlopen flags immediately. - for file in $execute_dlfiles; do - if test -f "$file"; then : - else - $echo "$modename: \`$file' is not a file" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - dir= - case "$file" in - *.la) - # Check to see that this really is a libtool archive. - if (sed -e '2q' $file | egrep '^# Generated by ltmain\.sh') >/dev/null 2>&1; then : - else - $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - # Read the libtool library. - dlname= - library_names= - - # If there is no directory component, then add one. - case "$file" in - */* | *\\*) . $file ;; - *) . ./$file ;; - esac - - # Skip this library if it cannot be dlopened. - if test -z "$dlname"; then - # Warn if it was a shared library. - test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'" - continue - fi - - dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` - test "X$dir" = "X$file" && dir=. - - if test -f "$dir/$objdir/$dlname"; then - dir="$dir/$objdir" - else - $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2 - exit 1 - fi - ;; - - *.lo) - # Just add the directory containing the .lo file. - dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` - test "X$dir" = "X$file" && dir=. - ;; - - *) - $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2 - continue - ;; - esac - - # Get the absolute pathname. - absdir=`cd "$dir" && pwd` - test -n "$absdir" && dir="$absdir" - - # Now add the directory to shlibpath_var. - if eval "test -z \"\$$shlibpath_var\""; then - eval "$shlibpath_var=\"\$dir\"" - else - eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" - fi - done - - # This variable tells wrapper scripts just to set shlibpath_var - # rather than running their programs. - libtool_execute_magic="$magic" - - # Check if any of the arguments is a wrapper script. - args= - for file - do - case "$file" in - -*) ;; - *) - # Do a test to see if this is really a libtool program. - if (sed -e '4q' $file | egrep '^# Generated by ltmain\.sh') >/dev/null 2>&1; then - # If there is no directory component, then add one. - case "$file" in - */* | *\\*) . $file ;; - *) . ./$file ;; - esac - - # Transform arg to wrapped name. - file="$progdir/$program" - fi - ;; - esac - # Quote arguments (to preserve shell metacharacters). - file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"` - args="$args \"$file\"" - done - - if test -z "$run"; then - # Export the shlibpath_var. - eval "export $shlibpath_var" - - # Now actually exec the command. - eval "exec \$cmd$args" - - $echo "$modename: cannot exec \$cmd$args" - exit 1 - else - # Display what would be done. - eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\"" - $echo "export $shlibpath_var" - $echo "$cmd$args" - exit 0 - fi - ;; - - # libtool uninstall mode - uninstall) - modename="$modename: uninstall" - rm="$nonopt" - files= - - for arg - do - case "$arg" in - -*) rm="$rm $arg" ;; - *) files="$files $arg" ;; - esac - done - - if test -z "$rm"; then - $echo "$modename: you must specify an RM program" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - for file in $files; do - dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` - test "X$dir" = "X$file" && dir=. - name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - - rmfiles="$file" - - case "$name" in - *.la) - # Possibly a libtool archive, so verify it. - if (sed -e '2q' $file | egrep '^# Generated by ltmain\.sh') >/dev/null 2>&1; then - . $dir/$name - - # Delete the libtool libraries and symlinks. - for n in $library_names; do - rmfiles="$rmfiles $dir/$n" - test "X$n" = "X$dlname" && dlname= - done - test -n "$dlname" && rmfiles="$rmfiles $dir/$dlname" - test -n "$old_library" && rmfiles="$rmfiles $dir/$old_library" - - $show "$rm $rmfiles" - $run $rm $rmfiles - - if test -n "$library_names"; then - # Do each command in the postuninstall commands. - eval cmds=\"$postuninstall_cmds\" - IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" - done - IFS="$save_ifs" - fi - - if test -n "$old_library"; then - # Do each command in the old_postuninstall commands. - eval cmds=\"$old_postuninstall_cmds\" - IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" - done - IFS="$save_ifs" - fi - - # FIXME: should reinstall the best remaining shared library. - fi - ;; - - *.lo) - if test "$build_old_libs" = yes; then - oldobj=`$echo "X$name" | $Xsed -e 's/\.lo$/\.o/'` - rmfiles="$rmfiles $dir/$oldobj" - fi - $show "$rm $rmfiles" - $run $rm $rmfiles - ;; - - *) - $show "$rm $rmfiles" - $run $rm $rmfiles - ;; - esac - done - exit 0 - ;; - - "") - $echo "$modename: you must specify a MODE" 1>&2 - $echo "$generic_help" 1>&2 - exit 1 - ;; - esac - - $echo "$modename: invalid operation mode \`$mode'" 1>&2 - $echo "$generic_help" 1>&2 - exit 1 -fi # test -z "$show_help" - -# We need to display help for each of the modes. -case "$mode" in -"") $echo \ -"Usage: $modename [OPTION]... [MODE-ARG]... - -Provide generalized library-building support services. - --n, --dry-run display commands without modifying any files - --features display configuration information and exit - --finish same as \`--mode=finish' - --help display this help message and exit - --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS] - --quiet same as \`--silent' - --silent don't print informational messages - --version print version information - -MODE must be one of the following: - - compile compile a source file into a libtool object - execute automatically set library path, then run a program - finish complete the installation of libtool libraries - install install libraries or executables - link create a library or an executable - uninstall remove libraries from an installed directory - -MODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for -a more detailed description of MODE." - exit 0 - ;; - -compile) - $echo \ -"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE - -Compile a source file into a libtool library object. - -COMPILE-COMMAND is a command to be used in creating a \`standard' object file -from the given SOURCEFILE. - -The output file name is determined by removing the directory component from -SOURCEFILE, then substituting the C source code suffix \`.c' with the -library object suffix, \`.lo'." - ;; - -execute) - $echo \ -"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]... - -Automatically set library path, then run a program. - -This mode accepts the following additional options: - - -dlopen FILE add the directory containing FILE to the library path - -This mode sets the library path environment variable according to \`-dlopen' -flags. - -If any of the ARGS are libtool executable wrappers, then they are translated -into their corresponding uninstalled binary, and any of their required library -directories are added to the library path. - -Then, COMMAND is executed, with ARGS as arguments." - ;; - -finish) - $echo \ -"Usage: $modename [OPTION]... --mode=finish [LIBDIR]... - -Complete the installation of libtool libraries. - -Each LIBDIR is a directory that contains libtool libraries. - -The commands that this mode executes may require superuser privileges. Use -the \`--dry-run' option if you just want to see what would be executed." - ;; - -install) - $echo \ -"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND... - -Install executables or libraries. - -INSTALL-COMMAND is the installation command. The first component should be -either the \`install' or \`cp' program. - -The rest of the components are interpreted as arguments to that command (only -BSD-compatible install options are recognized)." - ;; - -link) - $echo \ -"Usage: $modename [OPTION]... --mode=link LINK-COMMAND... - -Link object files or libraries together to form another library, or to -create an executable program. - -LINK-COMMAND is a command using the C compiler that you would use to create -a program from several object files. - -The following components of LINK-COMMAND are treated specially: - - -all-static do not do any dynamic linking at all - -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime - -dlpreopen FILE link in FILE and add its symbols to dld_preloaded_symbols - -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) - -LLIBDIR search LIBDIR for required installed libraries - -lNAME OUTPUT-FILE requires the installed library libNAME - -no-undefined declare that a library does not refer to external symbols - -o OUTPUT-FILE create OUTPUT-FILE from the specified objects - -release RELEASE specify package release information - -rpath LIBDIR the created library will eventually be installed in LIBDIR - -static do not do any dynamic linking of libtool libraries - -version-info CURRENT[:REVISION[:AGE]] - specify library version info [each variable defaults to 0] - -All other options (arguments beginning with \`-') are ignored. - -Every other argument is treated as a filename. Files ending in \`.la' are -treated as uninstalled libtool libraries, other files are standard or library -object files. - -If the OUTPUT-FILE ends in \`.la', then a libtool library is created, only -library objects (\`.lo' files) may be specified, and \`-rpath' is required. - -If OUTPUT-FILE ends in \`.a', then a standard library is created using \`ar' -and \`ranlib'. - -If OUTPUT-FILE ends in \`.lo' or \`.o', then a reloadable object file is -created, otherwise an executable program is created." - ;; - -uninstall) - $echo -"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... - -Remove libraries from an installation directory. - -RM is the name of the program to use to delete files associated with each FILE -(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed -to RM. - -If FILE is a libtool library, all the files associated with it are deleted. -Otherwise, only FILE itself is deleted using RM." - ;; - -*) - $echo "$modename: invalid operation mode \`$mode'" 1>&2 - $echo "$help" 1>&2 - exit 1 - ;; -esac - -echo -$echo "Try \`$modename --help' for more information about other modes." - -exit 0 - -# Local Variables: -# mode:shell-script -# sh-indentation:2 -# End: diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/makcjpeg.st b/irrlicht-1.6/source/Irrlicht/jpeglib/makcjpeg.st deleted file mode 100644 index 06bdf56b1..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/makcjpeg.st +++ /dev/null @@ -1,38 +0,0 @@ -; Project file for Independent JPEG Group's software -; -; This project file is for Atari ST/STE/TT systems using Pure C or Turbo C. -; Thanks to Frank Moehle (Frank.Moehle@arbi.informatik.uni-oldenburg.de), -; Dr. B. Setzepfandt (bernd@gina.uni-muenster.de), -; and Guido Vollbeding (guivol@esc.de). -; -; To use this file, rename it to cjpeg.prj. -; If you are using Turbo C, change filenames beginning with "pc..." to "tc..." -; Read installation instructions before trying to make the program! -; -; -; * * * Output file * * * -cjpeg.ttp -; -; * * * COMPILER OPTIONS * * * -.C[-P] ; absolute calls -.C[-M] ; and no string merging, folks -.C[-w-cln] ; no "constant is long" warnings -.C[-w-par] ; no "parameter xxxx unused" -.C[-w-rch] ; no "unreachable code" -.C[-wsig] ; warn if significant digits may be lost -= -; * * * * List of modules * * * * -pcstart.o -cjpeg.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h,jversion.h) -cdjpeg.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) -rdswitch.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) -rdppm.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) -rdgif.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) -rdtarga.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) -rdbmp.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) -rdrle.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) -libjpeg.lib ; built by libjpeg.prj -pcfltlib.lib ; floating point library -; the float library can be omitted if you've turned off DCT_FLOAT_SUPPORTED -pcstdlib.lib ; standard library -pcextlib.lib ; extended library diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/makdjpeg.st b/irrlicht-1.6/source/Irrlicht/jpeglib/makdjpeg.st deleted file mode 100644 index 873fd0f33..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/makdjpeg.st +++ /dev/null @@ -1,38 +0,0 @@ -; Project file for Independent JPEG Group's software -; -; This project file is for Atari ST/STE/TT systems using Pure C or Turbo C. -; Thanks to Frank Moehle (Frank.Moehle@arbi.informatik.uni-oldenburg.de), -; Dr. B. Setzepfandt (bernd@gina.uni-muenster.de), -; and Guido Vollbeding (guivol@esc.de). -; -; To use this file, rename it to djpeg.prj. -; If you are using Turbo C, change filenames beginning with "pc..." to "tc..." -; Read installation instructions before trying to make the program! -; -; -; * * * Output file * * * -djpeg.ttp -; -; * * * COMPILER OPTIONS * * * -.C[-P] ; absolute calls -.C[-M] ; and no string merging, folks -.C[-w-cln] ; no "constant is long" warnings -.C[-w-par] ; no "parameter xxxx unused" -.C[-w-rch] ; no "unreachable code" -.C[-wsig] ; warn if significant digits may be lost -= -; * * * * List of modules * * * * -pcstart.o -djpeg.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h,jversion.h) -cdjpeg.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) -rdcolmap.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) -wrppm.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) -wrgif.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) -wrtarga.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) -wrbmp.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) -wrrle.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) -libjpeg.lib ; built by libjpeg.prj -pcfltlib.lib ; floating point library -; the float library can be omitted if you've turned off DCT_FLOAT_SUPPORTED -pcstdlib.lib ; standard library -pcextlib.lib ; extended library diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/makeapps.ds b/irrlicht-1.6/source/Irrlicht/jpeglib/makeapps.ds deleted file mode 100644 index 8535d4d5a..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/makeapps.ds +++ /dev/null @@ -1,828 +0,0 @@ -# Microsoft Developer Studio Generated NMAKE File, Format Version 4.20 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -!IF "$(CFG)" == "" -CFG=cjpeg - Win32 -!MESSAGE No configuration specified. Defaulting to cjpeg - Win32. -!ENDIF - -!IF "$(CFG)" != "cjpeg - Win32" && "$(CFG)" != "djpeg - Win32" &&\ - "$(CFG)" != "jpegtran - Win32" && "$(CFG)" != "rdjpgcom - Win32" &&\ - "$(CFG)" != "wrjpgcom - Win32" -!MESSAGE Invalid configuration "$(CFG)" specified. -!MESSAGE You can specify a configuration when running NMAKE on this makefile -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "apps.mak" CFG="cjpeg - Win32" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "cjpeg - Win32" (based on "Win32 (x86) Console Application") -!MESSAGE "djpeg - Win32" (based on "Win32 (x86) Console Application") -!MESSAGE "jpegtran - Win32" (based on "Win32 (x86) Console Application") -!MESSAGE "rdjpgcom - Win32" (based on "Win32 (x86) Console Application") -!MESSAGE "wrjpgcom - Win32" (based on "Win32 (x86) Console Application") -!MESSAGE -!ERROR An invalid configuration is specified. -!ENDIF - -!IF "$(OS)" == "Windows_NT" -NULL= -!ELSE -NULL=nul -!ENDIF -################################################################################ -# Begin Project -# PROP Target_Last_Scanned "cjpeg - Win32" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "cjpeg - Win32" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "cjpeg\Release" -# PROP BASE Intermediate_Dir "cjpeg\Release" -# PROP BASE Target_Dir "cjpeg" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "cjpeg\Release" -# PROP Intermediate_Dir "cjpeg\Release" -# PROP Target_Dir "cjpeg" -OUTDIR=.\cjpeg\Release -INTDIR=.\cjpeg\Release - -ALL : "$(OUTDIR)\cjpeg.exe" - -CLEAN : - -@erase "$(INTDIR)\cjpeg.obj" - -@erase "$(INTDIR)\rdppm.obj" - -@erase "$(INTDIR)\rdgif.obj" - -@erase "$(INTDIR)\rdtarga.obj" - -@erase "$(INTDIR)\rdrle.obj" - -@erase "$(INTDIR)\rdbmp.obj" - -@erase "$(INTDIR)\rdswitch.obj" - -@erase "$(INTDIR)\cdjpeg.obj" - -@erase "$(OUTDIR)\cjpeg.exe" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c -# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c -CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE"\ - /Fp"$(INTDIR)/cjpeg.pch" /YX /Fo"$(INTDIR)/" /c -CPP_OBJS=.\cjpeg\Release/ -CPP_SBRS=.\. -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -BSC32_FLAGS=/nologo /o"$(OUTDIR)/cjpeg.bsc" -BSC32_SBRS= \ - -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -LINK32_FLAGS=Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib\ - comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib\ - odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no\ - /pdb:"$(OUTDIR)/cjpeg.pdb" /machine:I386 /out:"$(OUTDIR)/cjpeg.exe" -LINK32_OBJS= \ - "$(INTDIR)\cjpeg.obj" \ - "$(INTDIR)\rdppm.obj" \ - "$(INTDIR)\rdgif.obj" \ - "$(INTDIR)\rdtarga.obj" \ - "$(INTDIR)\rdrle.obj" \ - "$(INTDIR)\rdbmp.obj" \ - "$(INTDIR)\rdswitch.obj" \ - "$(INTDIR)\cdjpeg.obj" \ - - -"$(OUTDIR)\cjpeg.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) - $(LINK32) @<< - $(LINK32_FLAGS) $(LINK32_OBJS) -<< - -!ELSEIF "$(CFG)" == "djpeg - Win32" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "djpeg\Release" -# PROP BASE Intermediate_Dir "djpeg\Release" -# PROP BASE Target_Dir "djpeg" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "djpeg\Release" -# PROP Intermediate_Dir "djpeg\Release" -# PROP Target_Dir "djpeg" -OUTDIR=.\djpeg\Release -INTDIR=.\djpeg\Release - -ALL : "$(OUTDIR)\djpeg.exe" - -CLEAN : - -@erase "$(INTDIR)\djpeg.obj" - -@erase "$(INTDIR)\wrppm.obj" - -@erase "$(INTDIR)\wrgif.obj" - -@erase "$(INTDIR)\wrtarga.obj" - -@erase "$(INTDIR)\wrrle.obj" - -@erase "$(INTDIR)\wrbmp.obj" - -@erase "$(INTDIR)\rdcolmap.obj" - -@erase "$(INTDIR)\cdjpeg.obj" - -@erase "$(OUTDIR)\djpeg.exe" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c -# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c -CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE"\ - /Fp"$(INTDIR)/djpeg.pch" /YX /Fo"$(INTDIR)/" /c -CPP_OBJS=.\djpeg\Release/ -CPP_SBRS=.\. -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -BSC32_FLAGS=/nologo /o"$(OUTDIR)/djpeg.bsc" -BSC32_SBRS= \ - -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -LINK32_FLAGS=Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib\ - comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib\ - odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no\ - /pdb:"$(OUTDIR)/djpeg.pdb" /machine:I386 /out:"$(OUTDIR)/djpeg.exe" -LINK32_OBJS= \ - "$(INTDIR)\djpeg.obj" \ - "$(INTDIR)\wrppm.obj" \ - "$(INTDIR)\wrgif.obj" \ - "$(INTDIR)\wrtarga.obj" \ - "$(INTDIR)\wrrle.obj" \ - "$(INTDIR)\wrbmp.obj" \ - "$(INTDIR)\rdcolmap.obj" \ - "$(INTDIR)\cdjpeg.obj" \ - - -"$(OUTDIR)\djpeg.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) - $(LINK32) @<< - $(LINK32_FLAGS) $(LINK32_OBJS) -<< - -!ELSEIF "$(CFG)" == "jpegtran - Win32" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "jpegtran\Release" -# PROP BASE Intermediate_Dir "jpegtran\Release" -# PROP BASE Target_Dir "jpegtran" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "jpegtran\Release" -# PROP Intermediate_Dir "jpegtran\Release" -# PROP Target_Dir "jpegtran" -OUTDIR=.\jpegtran\Release -INTDIR=.\jpegtran\Release - -ALL : "$(OUTDIR)\jpegtran.exe" - -CLEAN : - -@erase "$(INTDIR)\jpegtran.obj" - -@erase "$(INTDIR)\rdswitch.obj" - -@erase "$(INTDIR)\cdjpeg.obj" - -@erase "$(INTDIR)\transupp.obj" - -@erase "$(OUTDIR)\jpegtran.exe" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c -# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c -CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE"\ - /Fp"$(INTDIR)/jpegtran.pch" /YX /Fo"$(INTDIR)/" /c -CPP_OBJS=.\jpegtran\Release/ -CPP_SBRS=.\. -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -BSC32_FLAGS=/nologo /o"$(OUTDIR)/jpegtran.bsc" -BSC32_SBRS= \ - -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -LINK32_FLAGS=Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib\ - comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib\ - odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no\ - /pdb:"$(OUTDIR)/jpegtran.pdb" /machine:I386 /out:"$(OUTDIR)/jpegtran.exe" -LINK32_OBJS= \ - "$(INTDIR)\jpegtran.obj" \ - "$(INTDIR)\rdswitch.obj" \ - "$(INTDIR)\cdjpeg.obj" \ - "$(INTDIR)\transupp.obj" \ - - -"$(OUTDIR)\jpegtran.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) - $(LINK32) @<< - $(LINK32_FLAGS) $(LINK32_OBJS) -<< - -!ELSEIF "$(CFG)" == "rdjpgcom - Win32" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "rdjpgcom\Release" -# PROP BASE Intermediate_Dir "rdjpgcom\Release" -# PROP BASE Target_Dir "rdjpgcom" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "rdjpgcom\Release" -# PROP Intermediate_Dir "rdjpgcom\Release" -# PROP Target_Dir "rdjpgcom" -OUTDIR=.\rdjpgcom\Release -INTDIR=.\rdjpgcom\Release - -ALL : "$(OUTDIR)\rdjpgcom.exe" - -CLEAN : - -@erase "$(INTDIR)\rdjpgcom.obj" - -@erase "$(OUTDIR)\rdjpgcom.exe" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c -# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c -CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE"\ - /Fp"$(INTDIR)/rdjpgcom.pch" /YX /Fo"$(INTDIR)/" /c -CPP_OBJS=.\rdjpgcom\Release/ -CPP_SBRS=.\. -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -BSC32_FLAGS=/nologo /o"$(OUTDIR)/rdjpgcom.bsc" -BSC32_SBRS= \ - -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -LINK32_FLAGS=Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib\ - comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib\ - odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no\ - /pdb:"$(OUTDIR)/rdjpgcom.pdb" /machine:I386 /out:"$(OUTDIR)/rdjpgcom.exe" -LINK32_OBJS= \ - "$(INTDIR)\rdjpgcom.obj" - -"$(OUTDIR)\rdjpgcom.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) - $(LINK32) @<< - $(LINK32_FLAGS) $(LINK32_OBJS) -<< - -!ELSEIF "$(CFG)" == "wrjpgcom - Win32" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "wrjpgcom\Release" -# PROP BASE Intermediate_Dir "wrjpgcom\Release" -# PROP BASE Target_Dir "wrjpgcom" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "wrjpgcom\Release" -# PROP Intermediate_Dir "wrjpgcom\Release" -# PROP Target_Dir "wrjpgcom" -OUTDIR=.\wrjpgcom\Release -INTDIR=.\wrjpgcom\Release - -ALL : "$(OUTDIR)\wrjpgcom.exe" - -CLEAN : - -@erase "$(INTDIR)\wrjpgcom.obj" - -@erase "$(OUTDIR)\wrjpgcom.exe" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c -# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c -CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE"\ - /Fp"$(INTDIR)/wrjpgcom.pch" /YX /Fo"$(INTDIR)/" /c -CPP_OBJS=.\wrjpgcom\Release/ -CPP_SBRS=.\. -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -BSC32_FLAGS=/nologo /o"$(OUTDIR)/wrjpgcom.bsc" -BSC32_SBRS= \ - -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -LINK32_FLAGS=Release\jpeg.lib kernel32.lib user32.lib gdi32.lib winspool.lib\ - comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib\ - odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no\ - /pdb:"$(OUTDIR)/wrjpgcom.pdb" /machine:I386 /out:"$(OUTDIR)/wrjpgcom.exe" -LINK32_OBJS= \ - "$(INTDIR)\wrjpgcom.obj" - -"$(OUTDIR)\wrjpgcom.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) - $(LINK32) @<< - $(LINK32_FLAGS) $(LINK32_OBJS) -<< - -!ENDIF - -.c{$(CPP_OBJS)}.obj: - $(CPP) $(CPP_PROJ) $< - -.cpp{$(CPP_OBJS)}.obj: - $(CPP) $(CPP_PROJ) $< - -.cxx{$(CPP_OBJS)}.obj: - $(CPP) $(CPP_PROJ) $< - -.c{$(CPP_SBRS)}.sbr: - $(CPP) $(CPP_PROJ) $< - -.cpp{$(CPP_SBRS)}.sbr: - $(CPP) $(CPP_PROJ) $< - -.cxx{$(CPP_SBRS)}.sbr: - $(CPP) $(CPP_PROJ) $< - -################################################################################ -# Begin Target - -# Name "cjpeg - Win32" - -!IF "$(CFG)" == "cjpeg - Win32" - -!ENDIF - -################################################################################ -# Begin Source File - -SOURCE="cjpeg.c" -DEP_CPP_CJPEG=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - "jversion.h"\ - - -"$(INTDIR)\cjpeg.obj" : $(SOURCE) $(DEP_CPP_CJPEG) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="cdjpeg.c" -DEP_CPP_CDJPE=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - - -"$(INTDIR)\cdjpeg.obj" : $(SOURCE) $(DEP_CPP_CDJPE) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="rdswitch.c" -DEP_CPP_RDSWI=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - - -"$(INTDIR)\rdswitch.obj" : $(SOURCE) $(DEP_CPP_RDSWI) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="rdppm.c" -DEP_CPP_RDPPM=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - - -"$(INTDIR)\rdppm.obj" : $(SOURCE) $(DEP_CPP_RDPPM) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="rdgif.c" -DEP_CPP_RDGIF=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - - -"$(INTDIR)\rdgif.obj" : $(SOURCE) $(DEP_CPP_RDGIF) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="rdtarga.c" -DEP_CPP_RDTAR=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - - -"$(INTDIR)\rdtarga.obj" : $(SOURCE) $(DEP_CPP_RDTAR) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="rdbmp.c" -DEP_CPP_RDBMP=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - - -"$(INTDIR)\rdbmp.obj" : $(SOURCE) $(DEP_CPP_RDBMP) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="rdrle.c" -DEP_CPP_RDRLE=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - - -"$(INTDIR)\rdrle.obj" : $(SOURCE) $(DEP_CPP_RDRLE) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -# End Target -################################################################################ -# Begin Target - -# Name "djpeg - Win32" - -!IF "$(CFG)" == "djpeg - Win32" - -!ENDIF - -################################################################################ -# Begin Source File - -SOURCE="djpeg.c" -DEP_CPP_DJPEG=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - "jversion.h"\ - - -"$(INTDIR)\djpeg.obj" : $(SOURCE) $(DEP_CPP_DJPEG) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="cdjpeg.c" -DEP_CPP_CDJPE=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - - -"$(INTDIR)\cdjpeg.obj" : $(SOURCE) $(DEP_CPP_CDJPE) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="rdcolmap.c" -DEP_CPP_RDCOL=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - - -"$(INTDIR)\rdcolmap.obj" : $(SOURCE) $(DEP_CPP_RDCOL) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="wrppm.c" -DEP_CPP_WRPPM=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - - -"$(INTDIR)\wrppm.obj" : $(SOURCE) $(DEP_CPP_WRPPM) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="wrgif.c" -DEP_CPP_WRGIF=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - - -"$(INTDIR)\wrgif.obj" : $(SOURCE) $(DEP_CPP_WRGIF) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="wrtarga.c" -DEP_CPP_WRTAR=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - - -"$(INTDIR)\wrtarga.obj" : $(SOURCE) $(DEP_CPP_WRTAR) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="wrbmp.c" -DEP_CPP_WRBMP=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - - -"$(INTDIR)\wrbmp.obj" : $(SOURCE) $(DEP_CPP_WRBMP) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="wrrle.c" -DEP_CPP_WRRLE=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - - -"$(INTDIR)\wrrle.obj" : $(SOURCE) $(DEP_CPP_WRRLE) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -# End Target -################################################################################ -# Begin Target - -# Name "jpegtran - Win32" - -!IF "$(CFG)" == "jpegtran - Win32" - -!ENDIF - -################################################################################ -# Begin Source File - -SOURCE="jpegtran.c" -DEP_CPP_JPEGT=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - "transupp.h"\ - "jversion.h"\ - - -"$(INTDIR)\jpegtran.obj" : $(SOURCE) $(DEP_CPP_JPEGT) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="cdjpeg.c" -DEP_CPP_CDJPE=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - - -"$(INTDIR)\cdjpeg.obj" : $(SOURCE) $(DEP_CPP_CDJPE) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="rdswitch.c" -DEP_CPP_RDSWI=\ - "cdjpeg.h"\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - "cderror.h"\ - - -"$(INTDIR)\rdswitch.obj" : $(SOURCE) $(DEP_CPP_RDSWI) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="transupp.c" -DEP_CPP_TRANS=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - "transupp.h"\ - - -"$(INTDIR)\transupp.obj" : $(SOURCE) $(DEP_CPP_TRANS) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -# End Target -################################################################################ -# Begin Target - -# Name "rdjpgcom - Win32" - -!IF "$(CFG)" == "rdjpgcom - Win32" - -!ENDIF - -################################################################################ -# Begin Source File - -SOURCE="rdjpgcom.c" -DEP_CPP_RDJPG=\ - "jinclude.h"\ - "jconfig.h"\ - - -"$(INTDIR)\rdjpgcom.obj" : $(SOURCE) $(DEP_CPP_RDJPG) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -# End Target -################################################################################ -# Begin Target - -# Name "wrjpgcom - Win32" - -!IF "$(CFG)" == "wrjpgcom - Win32" - -!ENDIF - -################################################################################ -# Begin Source File - -SOURCE="wrjpgcom.c" -DEP_CPP_WRJPG=\ - "jinclude.h"\ - "jconfig.h"\ - - -"$(INTDIR)\wrjpgcom.obj" : $(SOURCE) $(DEP_CPP_WRJPG) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -# End Target -# End Project -################################################################################ - diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/makefile.ansi b/irrlicht-1.6/source/Irrlicht/jpeglib/makefile.ansi deleted file mode 100644 index 39e84626d..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/makefile.ansi +++ /dev/null @@ -1,214 +0,0 @@ -# Makefile for Independent JPEG Group's software - -# This makefile is suitable for Unix-like systems with ANSI-capable compilers. -# If you have a non-ANSI compiler, makefile.unix is a better starting point. - -# Read installation instructions before saying "make" !! - -# The name of your C compiler: -CC= cc - -# You may need to adjust these cc options: -CFLAGS= -O -# Generally, we recommend defining any configuration symbols in jconfig.h, -# NOT via -D switches here. - -# Link-time cc options: -LDFLAGS= - -# To link any special libraries, add the necessary -l commands here. -LDLIBS= - -# Put here the object file name for the correct system-dependent memory -# manager file. For Unix this is usually jmemnobs.o, but you may want -# to use jmemansi.o or jmemname.o if you have limited swap space. -SYSDEPMEM= jmemnobs.o - -# miscellaneous OS-dependent stuff -# linker -LN= $(CC) -# file deletion command -RM= rm -f -# library (.a) file creation command -AR= ar rc -# second step in .a creation (use "touch" if not needed) -AR2= ranlib - -# End of configurable options. - - -# source files: JPEG library proper -LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ - jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ - jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ - jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ - jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ - jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ - jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ - jquant2.c jutils.c jmemmgr.c -# memmgr back ends: compile only one of these into a working library -SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c -# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom -APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ - rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ - rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c -SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) -# files included by source files -INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ - jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h -# documentation, test, and support files -DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ - wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ - coderules.doc filelist.doc change.log -MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ - makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds \ - makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ - maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ - makvms.opt -CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ - jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ - jconfig.vms -CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh -OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm -TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \ - testimgp.jpg -DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ - $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) -# library object files common to compression and decompression -COMOBJECTS= jcomapi.o jutils.o jerror.o jmemmgr.o $(SYSDEPMEM) -# compression library object files -CLIBOBJECTS= jcapimin.o jcapistd.o jctrans.o jcparam.o jdatadst.o jcinit.o \ - jcmaster.o jcmarker.o jcmainct.o jcprepct.o jccoefct.o jccolor.o \ - jcsample.o jchuff.o jcphuff.o jcdctmgr.o jfdctfst.o jfdctflt.o \ - jfdctint.o -# decompression library object files -DLIBOBJECTS= jdapimin.o jdapistd.o jdtrans.o jdatasrc.o jdmaster.o \ - jdinput.o jdmarker.o jdhuff.o jdphuff.o jdmainct.o jdcoefct.o \ - jdpostct.o jddctmgr.o jidctfst.o jidctflt.o jidctint.o jidctred.o \ - jdsample.o jdcolor.o jquant1.o jquant2.o jdmerge.o -# These objectfiles are included in libjpeg.a -LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) -# object files for sample applications (excluding library files) -COBJECTS= cjpeg.o rdppm.o rdgif.o rdtarga.o rdrle.o rdbmp.o rdswitch.o \ - cdjpeg.o -DOBJECTS= djpeg.o wrppm.o wrgif.o wrtarga.o wrrle.o wrbmp.o rdcolmap.o \ - cdjpeg.o -TROBJECTS= jpegtran.o rdswitch.o cdjpeg.o transupp.o - - -all: libjpeg.a cjpeg djpeg jpegtran rdjpgcom wrjpgcom - -libjpeg.a: $(LIBOBJECTS) - $(RM) libjpeg.a - $(AR) libjpeg.a $(LIBOBJECTS) - $(AR2) libjpeg.a - -cjpeg: $(COBJECTS) libjpeg.a - $(LN) $(LDFLAGS) -o cjpeg $(COBJECTS) libjpeg.a $(LDLIBS) - -djpeg: $(DOBJECTS) libjpeg.a - $(LN) $(LDFLAGS) -o djpeg $(DOBJECTS) libjpeg.a $(LDLIBS) - -jpegtran: $(TROBJECTS) libjpeg.a - $(LN) $(LDFLAGS) -o jpegtran $(TROBJECTS) libjpeg.a $(LDLIBS) - -rdjpgcom: rdjpgcom.o - $(LN) $(LDFLAGS) -o rdjpgcom rdjpgcom.o $(LDLIBS) - -wrjpgcom: wrjpgcom.o - $(LN) $(LDFLAGS) -o wrjpgcom wrjpgcom.o $(LDLIBS) - -jconfig.h: jconfig.doc - echo You must prepare a system-dependent jconfig.h file. - echo Please read the installation directions in install.doc. - exit 1 - -clean: - $(RM) *.o cjpeg djpeg jpegtran libjpeg.a rdjpgcom wrjpgcom - $(RM) core testout* - -test: cjpeg djpeg jpegtran - $(RM) testout* - ./djpeg -dct int -ppm -outfile testout.ppm testorig.jpg - ./djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg - ./cjpeg -dct int -outfile testout.jpg testimg.ppm - ./djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg - ./cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm - ./jpegtran -outfile testoutt.jpg testprog.jpg - cmp testimg.ppm testout.ppm - cmp testimg.bmp testout.bmp - cmp testimg.jpg testout.jpg - cmp testimg.ppm testoutp.ppm - cmp testimgp.jpg testoutp.jpg - cmp testorig.jpg testoutt.jpg - - -jcapimin.o: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcapistd.o: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccoefct.o: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccolor.o: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcdctmgr.o: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jchuff.o: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcinit.o: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmainct.o: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmarker.o: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmaster.o: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcomapi.o: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcparam.o: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcphuff.o: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcprepct.o: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcsample.o: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jctrans.o: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapimin.o: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapistd.o: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdatadst.o: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdatasrc.o: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdcoefct.o: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdcolor.o: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jddctmgr.o: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jdhuff.o: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdinput.o: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmainct.o: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmarker.o: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmaster.o: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmerge.o: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdphuff.o: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdpostct.o: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdsample.o: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdtrans.o: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jerror.o: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h -jfdctflt.o: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctfst.o: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctint.o: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctflt.o: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctfst.o: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctint.o: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctred.o: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jquant1.o: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jquant2.o: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jutils.o: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jmemmgr.o: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemansi.o: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemname.o: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemnobs.o: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemdos.o: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemmac.o: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -cjpeg.o: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -djpeg.o: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -jpegtran.o: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h -rdjpgcom.o: rdjpgcom.c jinclude.h jconfig.h -wrjpgcom.o: wrjpgcom.c jinclude.h jconfig.h -cdjpeg.o: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdcolmap.o: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdswitch.o: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -transupp.o: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h -rdppm.o: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrppm.o: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdgif.o: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrgif.o: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdtarga.o: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrtarga.o: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdbmp.o: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrbmp.o: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdrle.o: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrrle.o: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/makefile.bcc b/irrlicht-1.6/source/Irrlicht/jpeglib/makefile.bcc deleted file mode 100644 index 92e321856..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/makefile.bcc +++ /dev/null @@ -1,285 +0,0 @@ -# Makefile for Independent JPEG Group's software - -# This makefile is suitable for Borland C on MS-DOS or OS/2. -# It works with Borland C++ for DOS, revision 3.0 or later, -# and has been tested with Borland C++ for OS/2. -# Watch out for optimization bugs in the OS/2 compilers --- see notes below! -# Thanks to Tom Wright and Ge' Weijers (original DOS) and -# Ken Porter (OS/2) for this file. - -# Read installation instructions before saying "make" !! - -# Are we under DOS or OS/2? -!if !$d(DOS) && !$d(OS2) -!if $d(__OS2__) -OS2=1 -!else -DOS=1 -!endif -!endif - -# The name of your C compiler: -CC= bcc - -# You may need to adjust these cc options: -!if $d(DOS) -CFLAGS= -O2 -mm -w-par -w-stu -w-ccc -w-rch -!else -CFLAGS= -O1 -w-par -w-stu -w-ccc -w-rch -!endif -# -O2 enables full code optimization (for pre-3.0 Borland C++, use -O -G -Z). -# -O2 is buggy in Borland OS/2 C++ revision 2.0, so use -O1 there for now. -# If you have Borland OS/2 C++ revision 1.0, use -O or no optimization at all. -# -mm selects medium memory model (near data, far code pointers; DOS only!) -# -w-par suppresses warnings about unused function parameters -# -w-stu suppresses warnings about incomplete structures -# -w-ccc suppresses warnings about compile-time-constant conditions -# -w-rch suppresses warnings about unreachable code -# Generally, we recommend defining any configuration symbols in jconfig.h, -# NOT via -D switches here. - -# Link-time cc options: -!if $d(DOS) -LDFLAGS= -mm -# memory model option here must match CFLAGS! -!else -LDFLAGS= -# -lai full-screen app -# -lc case-significant link -!endif - -# Put here the object file name for the correct system-dependent memory -# manager file. -# For DOS, we recommend jmemdos.c and jmemdosa.asm. -# For OS/2, we recommend jmemnobs.c (flat memory!) -# SYSDEPMEMLIB must list the same files with "+" signs for the librarian. -!if $d(DOS) -SYSDEPMEM= jmemdos.obj jmemdosa.obj -SYSDEPMEMLIB= +jmemdos.obj +jmemdosa.obj -!else -SYSDEPMEM= jmemnobs.obj -SYSDEPMEMLIB= +jmemnobs.obj -!endif - -# End of configurable options. - - -# source files: JPEG library proper -LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ - jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ - jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ - jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ - jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ - jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ - jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ - jquant2.c jutils.c jmemmgr.c -# memmgr back ends: compile only one of these into a working library -SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c -# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom -APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ - rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ - rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c -SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) -# files included by source files -INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ - jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h -# documentation, test, and support files -DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ - wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ - coderules.doc filelist.doc change.log -MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ - makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds \ - makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ - maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ - makvms.opt -CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ - jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ - jconfig.vms -CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh -OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm -TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \ - testimgp.jpg -DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ - $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) -# library object files common to compression and decompression -COMOBJECTS= jcomapi.obj jutils.obj jerror.obj jmemmgr.obj $(SYSDEPMEM) -# compression library object files -CLIBOBJECTS= jcapimin.obj jcapistd.obj jctrans.obj jcparam.obj jdatadst.obj \ - jcinit.obj jcmaster.obj jcmarker.obj jcmainct.obj jcprepct.obj \ - jccoefct.obj jccolor.obj jcsample.obj jchuff.obj jcphuff.obj \ - jcdctmgr.obj jfdctfst.obj jfdctflt.obj jfdctint.obj -# decompression library object files -DLIBOBJECTS= jdapimin.obj jdapistd.obj jdtrans.obj jdatasrc.obj \ - jdmaster.obj jdinput.obj jdmarker.obj jdhuff.obj jdphuff.obj \ - jdmainct.obj jdcoefct.obj jdpostct.obj jddctmgr.obj jidctfst.obj \ - jidctflt.obj jidctint.obj jidctred.obj jdsample.obj jdcolor.obj \ - jquant1.obj jquant2.obj jdmerge.obj -# These objectfiles are included in libjpeg.lib -LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) -# object files for sample applications (excluding library files) -COBJECTS= cjpeg.obj rdppm.obj rdgif.obj rdtarga.obj rdrle.obj rdbmp.obj \ - rdswitch.obj cdjpeg.obj -DOBJECTS= djpeg.obj wrppm.obj wrgif.obj wrtarga.obj wrrle.obj wrbmp.obj \ - rdcolmap.obj cdjpeg.obj -TROBJECTS= jpegtran.obj rdswitch.obj cdjpeg.obj transupp.obj - - -all: libjpeg.lib cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe - -libjpeg.lib: $(LIBOBJECTS) - - del libjpeg.lib - tlib libjpeg.lib /E /C @&&| -+jcapimin.obj +jcapistd.obj +jctrans.obj +jcparam.obj +jdatadst.obj & -+jcinit.obj +jcmaster.obj +jcmarker.obj +jcmainct.obj +jcprepct.obj & -+jccoefct.obj +jccolor.obj +jcsample.obj +jchuff.obj +jcphuff.obj & -+jcdctmgr.obj +jfdctfst.obj +jfdctflt.obj +jfdctint.obj +jdapimin.obj & -+jdapistd.obj +jdtrans.obj +jdatasrc.obj +jdmaster.obj +jdinput.obj & -+jdmarker.obj +jdhuff.obj +jdphuff.obj +jdmainct.obj +jdcoefct.obj & -+jdpostct.obj +jddctmgr.obj +jidctfst.obj +jidctflt.obj +jidctint.obj & -+jidctred.obj +jdsample.obj +jdcolor.obj +jquant1.obj +jquant2.obj & -+jdmerge.obj +jcomapi.obj +jutils.obj +jerror.obj +jmemmgr.obj & -$(SYSDEPMEMLIB) -| - -cjpeg.exe: $(COBJECTS) libjpeg.lib - $(CC) $(LDFLAGS) -ecjpeg.exe $(COBJECTS) libjpeg.lib - -djpeg.exe: $(DOBJECTS) libjpeg.lib - $(CC) $(LDFLAGS) -edjpeg.exe $(DOBJECTS) libjpeg.lib - -jpegtran.exe: $(TROBJECTS) libjpeg.lib - $(CC) $(LDFLAGS) -ejpegtran.exe $(TROBJECTS) libjpeg.lib - -rdjpgcom.exe: rdjpgcom.c -!if $d(DOS) - $(CC) -ms -O rdjpgcom.c -!else - $(CC) $(CFLAGS) rdjpgcom.c -!endif - -# On DOS, wrjpgcom needs large model so it can malloc a 64K chunk -wrjpgcom.exe: wrjpgcom.c -!if $d(DOS) - $(CC) -ml -O wrjpgcom.c -!else - $(CC) $(CFLAGS) wrjpgcom.c -!endif - -# This "{}" syntax allows Borland Make to "batch" source files. -# In this way, each run of the compiler can build many modules. -.c.obj: - $(CC) $(CFLAGS) -c{ $<} - -jconfig.h: jconfig.doc - echo You must prepare a system-dependent jconfig.h file. - echo Please read the installation directions in install.doc. - exit 1 - -clean: - - del *.obj - - del libjpeg.lib - - del cjpeg.exe - - del djpeg.exe - - del jpegtran.exe - - del rdjpgcom.exe - - del wrjpgcom.exe - - del testout*.* - -test: cjpeg.exe djpeg.exe jpegtran.exe - - del testout*.* - djpeg -dct int -ppm -outfile testout.ppm testorig.jpg - djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg - cjpeg -dct int -outfile testout.jpg testimg.ppm - djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg - cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm - jpegtran -outfile testoutt.jpg testprog.jpg -!if $d(DOS) - fc /b testimg.ppm testout.ppm - fc /b testimg.bmp testout.bmp - fc /b testimg.jpg testout.jpg - fc /b testimg.ppm testoutp.ppm - fc /b testimgp.jpg testoutp.jpg - fc /b testorig.jpg testoutt.jpg -!else - echo n > n.tmp - comp testimg.ppm testout.ppm < n.tmp - comp testimg.bmp testout.bmp < n.tmp - comp testimg.jpg testout.jpg < n.tmp - comp testimg.ppm testoutp.ppm < n.tmp - comp testimgp.jpg testoutp.jpg < n.tmp - comp testorig.jpg testoutt.jpg < n.tmp - del n.tmp -!endif - - -jcapimin.obj: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcapistd.obj: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccoefct.obj: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccolor.obj: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcdctmgr.obj: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jchuff.obj: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcinit.obj: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmainct.obj: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmarker.obj: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmaster.obj: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcomapi.obj: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcparam.obj: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcphuff.obj: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcprepct.obj: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcsample.obj: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jctrans.obj: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapimin.obj: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapistd.obj: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdatadst.obj: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdatasrc.obj: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdcoefct.obj: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdcolor.obj: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jddctmgr.obj: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jdhuff.obj: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdinput.obj: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmainct.obj: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmarker.obj: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmaster.obj: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmerge.obj: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdphuff.obj: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdpostct.obj: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdsample.obj: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdtrans.obj: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jerror.obj: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h -jfdctflt.obj: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctfst.obj: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctint.obj: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctflt.obj: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctfst.obj: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctint.obj: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctred.obj: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jquant1.obj: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jquant2.obj: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jutils.obj: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jmemmgr.obj: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemansi.obj: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemname.obj: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemnobs.obj: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemdos.obj: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemmac.obj: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -cjpeg.obj: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -djpeg.obj: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -jpegtran.obj: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h -rdjpgcom.obj: rdjpgcom.c jinclude.h jconfig.h -wrjpgcom.obj: wrjpgcom.c jinclude.h jconfig.h -cdjpeg.obj: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdcolmap.obj: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdswitch.obj: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -transupp.obj: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h -rdppm.obj: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrppm.obj: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdgif.obj: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrgif.obj: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdtarga.obj: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrtarga.obj: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdbmp.obj: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrbmp.obj: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdrle.obj: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrrle.obj: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -jmemdosa.obj: jmemdosa.asm - tasm /mx jmemdosa.asm diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/makefile.cfg b/irrlicht-1.6/source/Irrlicht/jpeglib/makefile.cfg deleted file mode 100644 index 4e54bb01c..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/makefile.cfg +++ /dev/null @@ -1,319 +0,0 @@ -# Makefile for Independent JPEG Group's software - -# makefile.cfg is edited by configure to produce a custom Makefile. - -# Read installation instructions before saying "make" !! - -# For compiling with source and object files in different directories. -srcdir = @srcdir@ -VPATH = @srcdir@ - -# Where to install the programs and man pages. -prefix = @prefix@ -exec_prefix = @exec_prefix@ -bindir = $(exec_prefix)/bin -libdir = $(exec_prefix)/lib -includedir = $(prefix)/include -binprefix = -manprefix = -manext = 1 -mandir = $(prefix)/man/man$(manext) - -# The name of your C compiler: -CC= @CC@ - -# You may need to adjust these cc options: -CFLAGS= @CFLAGS@ @CPPFLAGS@ @INCLUDEFLAGS@ -# Generally, we recommend defining any configuration symbols in jconfig.h, -# NOT via -D switches here. -# However, any special defines for ansi2knr.c may be included here: -ANSI2KNRFLAGS= @ANSI2KNRFLAGS@ - -# Link-time cc options: -LDFLAGS= @LDFLAGS@ - -# To link any special libraries, add the necessary -l commands here. -LDLIBS= @LIBS@ - -# If using GNU libtool, LIBTOOL references it; if not, LIBTOOL is empty. -LIBTOOL = @LIBTOOL@ -# $(O) expands to "lo" if using libtool, plain "o" if not. -# Similarly, $(A) expands to "la" or "a". -O = @O@ -A = @A@ - -# Library version ID; libtool uses this for the shared library version number. -# Note: we suggest this match the macro of the same name in jpeglib.h. -JPEG_LIB_VERSION = @JPEG_LIB_VERSION@ - -# Put here the object file name for the correct system-dependent memory -# manager file. For Unix this is usually jmemnobs.o, but you may want -# to use jmemansi.o or jmemname.o if you have limited swap space. -SYSDEPMEM= @MEMORYMGR@ - -# miscellaneous OS-dependent stuff -SHELL= /bin/sh -# linker -LN= @LN@ -# file deletion command -RM= rm -f -# directory creation command -MKDIR= mkdir -# library (.a) file creation command -AR= ar rc -# second step in .a creation (use "touch" if not needed) -AR2= @RANLIB@ -# installation program -INSTALL= @INSTALL@ -INSTALL_PROGRAM= @INSTALL_PROGRAM@ -INSTALL_LIB= @INSTALL_LIB@ -INSTALL_DATA= @INSTALL_DATA@ - -# End of configurable options. - - -# source files: JPEG library proper -LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ - jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ - jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ - jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ - jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ - jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ - jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ - jquant2.c jutils.c jmemmgr.c -# memmgr back ends: compile only one of these into a working library -SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c -# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom -APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ - rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ - rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c -SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) -# files included by source files -INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ - jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h -# documentation, test, and support files -DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ - wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ - coderules.doc filelist.doc change.log -MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ - makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds \ - makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ - maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ - makvms.opt -CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ - jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ - jconfig.vms -CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh -OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm -TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \ - testimgp.jpg -DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ - $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) -# library object files common to compression and decompression -COMOBJECTS= jcomapi.$(O) jutils.$(O) jerror.$(O) jmemmgr.$(O) $(SYSDEPMEM) -# compression library object files -CLIBOBJECTS= jcapimin.$(O) jcapistd.$(O) jctrans.$(O) jcparam.$(O) \ - jdatadst.$(O) jcinit.$(O) jcmaster.$(O) jcmarker.$(O) jcmainct.$(O) \ - jcprepct.$(O) jccoefct.$(O) jccolor.$(O) jcsample.$(O) jchuff.$(O) \ - jcphuff.$(O) jcdctmgr.$(O) jfdctfst.$(O) jfdctflt.$(O) \ - jfdctint.$(O) -# decompression library object files -DLIBOBJECTS= jdapimin.$(O) jdapistd.$(O) jdtrans.$(O) jdatasrc.$(O) \ - jdmaster.$(O) jdinput.$(O) jdmarker.$(O) jdhuff.$(O) jdphuff.$(O) \ - jdmainct.$(O) jdcoefct.$(O) jdpostct.$(O) jddctmgr.$(O) \ - jidctfst.$(O) jidctflt.$(O) jidctint.$(O) jidctred.$(O) \ - jdsample.$(O) jdcolor.$(O) jquant1.$(O) jquant2.$(O) jdmerge.$(O) -# These objectfiles are included in libjpeg.a -LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) -# object files for sample applications (excluding library files) -COBJECTS= cjpeg.$(O) rdppm.$(O) rdgif.$(O) rdtarga.$(O) rdrle.$(O) \ - rdbmp.$(O) rdswitch.$(O) cdjpeg.$(O) -DOBJECTS= djpeg.$(O) wrppm.$(O) wrgif.$(O) wrtarga.$(O) wrrle.$(O) \ - wrbmp.$(O) rdcolmap.$(O) cdjpeg.$(O) -TROBJECTS= jpegtran.$(O) rdswitch.$(O) cdjpeg.$(O) transupp.$(O) - - -all: @A2K_DEPS@ libjpeg.$(A) cjpeg djpeg jpegtran rdjpgcom wrjpgcom - -# Special compilation rules to support ansi2knr and libtool. -.SUFFIXES: .lo .la - -# How to compile with libtool. -@COM_LT@.c.lo: -@COM_LT@ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c $(srcdir)/$*.c - -# How to use ansi2knr, when not using libtool. -@COM_A2K@.c.o: -@COM_A2K@ ./ansi2knr $(srcdir)/$*.c knr/$*.c -@COM_A2K@ $(CC) $(CFLAGS) -c knr/$*.c -@COM_A2K@ $(RM) knr/$*.c - -# How to use ansi2knr AND libtool. -@COM_A2K@.c.lo: -@COM_A2K@ ./ansi2knr $(srcdir)/$*.c knr/$*.c -@COM_A2K@ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c knr/$*.c -@COM_A2K@ $(RM) knr/$*.c - -ansi2knr: ansi2knr.c - $(CC) $(CFLAGS) $(ANSI2KNRFLAGS) -o ansi2knr $(srcdir)/ansi2knr.c - $(MKDIR) knr - -# the library: - -# without libtool: -libjpeg.a: @A2K_DEPS@ $(LIBOBJECTS) - $(RM) libjpeg.a - $(AR) libjpeg.a $(LIBOBJECTS) - $(AR2) libjpeg.a - -# with libtool: -libjpeg.la: @A2K_DEPS@ $(LIBOBJECTS) - $(LIBTOOL) --mode=link $(CC) -o libjpeg.la $(LIBOBJECTS) \ - -rpath $(libdir) -version-info $(JPEG_LIB_VERSION) - -# sample programs: - -cjpeg: $(COBJECTS) libjpeg.$(A) - $(LN) $(LDFLAGS) -o cjpeg $(COBJECTS) libjpeg.$(A) $(LDLIBS) - -djpeg: $(DOBJECTS) libjpeg.$(A) - $(LN) $(LDFLAGS) -o djpeg $(DOBJECTS) libjpeg.$(A) $(LDLIBS) - -jpegtran: $(TROBJECTS) libjpeg.$(A) - $(LN) $(LDFLAGS) -o jpegtran $(TROBJECTS) libjpeg.$(A) $(LDLIBS) - -rdjpgcom: rdjpgcom.$(O) - $(LN) $(LDFLAGS) -o rdjpgcom rdjpgcom.$(O) $(LDLIBS) - -wrjpgcom: wrjpgcom.$(O) - $(LN) $(LDFLAGS) -o wrjpgcom wrjpgcom.$(O) $(LDLIBS) - -# Installation rules: - -install: cjpeg djpeg jpegtran rdjpgcom wrjpgcom @FORCE_INSTALL_LIB@ - $(INSTALL_PROGRAM) cjpeg $(bindir)/$(binprefix)cjpeg - $(INSTALL_PROGRAM) djpeg $(bindir)/$(binprefix)djpeg - $(INSTALL_PROGRAM) jpegtran $(bindir)/$(binprefix)jpegtran - $(INSTALL_PROGRAM) rdjpgcom $(bindir)/$(binprefix)rdjpgcom - $(INSTALL_PROGRAM) wrjpgcom $(bindir)/$(binprefix)wrjpgcom - $(INSTALL_DATA) $(srcdir)/cjpeg.1 $(mandir)/$(manprefix)cjpeg.$(manext) - $(INSTALL_DATA) $(srcdir)/djpeg.1 $(mandir)/$(manprefix)djpeg.$(manext) - $(INSTALL_DATA) $(srcdir)/jpegtran.1 $(mandir)/$(manprefix)jpegtran.$(manext) - $(INSTALL_DATA) $(srcdir)/rdjpgcom.1 $(mandir)/$(manprefix)rdjpgcom.$(manext) - $(INSTALL_DATA) $(srcdir)/wrjpgcom.1 $(mandir)/$(manprefix)wrjpgcom.$(manext) - -install-lib: libjpeg.$(A) install-headers - $(INSTALL_LIB) libjpeg.$(A) $(libdir)/$(binprefix)libjpeg.$(A) - -install-headers: jconfig.h - $(INSTALL_DATA) jconfig.h $(includedir)/jconfig.h - $(INSTALL_DATA) $(srcdir)/jpeglib.h $(includedir)/jpeglib.h - $(INSTALL_DATA) $(srcdir)/jmorecfg.h $(includedir)/jmorecfg.h - $(INSTALL_DATA) $(srcdir)/jerror.h $(includedir)/jerror.h - -clean: - $(RM) *.o *.lo libjpeg.a libjpeg.la - $(RM) cjpeg djpeg jpegtran rdjpgcom wrjpgcom - $(RM) ansi2knr core testout* config.log config.status - $(RM) -r knr .libs _libs - -distclean: clean - $(RM) Makefile jconfig.h libtool config.cache - -test: cjpeg djpeg jpegtran - $(RM) testout* - ./djpeg -dct int -ppm -outfile testout.ppm $(srcdir)/testorig.jpg - ./djpeg -dct int -bmp -colors 256 -outfile testout.bmp $(srcdir)/testorig.jpg - ./cjpeg -dct int -outfile testout.jpg $(srcdir)/testimg.ppm - ./djpeg -dct int -ppm -outfile testoutp.ppm $(srcdir)/testprog.jpg - ./cjpeg -dct int -progressive -opt -outfile testoutp.jpg $(srcdir)/testimg.ppm - ./jpegtran -outfile testoutt.jpg $(srcdir)/testprog.jpg - cmp $(srcdir)/testimg.ppm testout.ppm - cmp $(srcdir)/testimg.bmp testout.bmp - cmp $(srcdir)/testimg.jpg testout.jpg - cmp $(srcdir)/testimg.ppm testoutp.ppm - cmp $(srcdir)/testimgp.jpg testoutp.jpg - cmp $(srcdir)/testorig.jpg testoutt.jpg - -check: test - -# Mistake catcher: - -jconfig.h: jconfig.doc - echo You must prepare a system-dependent jconfig.h file. - echo Please read the installation directions in install.doc. - exit 1 - -# GNU Make likes to know which target names are not really files to be made: -.PHONY: all install install-lib install-headers clean distclean test check - - -jcapimin.$(O): jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcapistd.$(O): jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccoefct.$(O): jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccolor.$(O): jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcdctmgr.$(O): jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jchuff.$(O): jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcinit.$(O): jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmainct.$(O): jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmarker.$(O): jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmaster.$(O): jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcomapi.$(O): jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcparam.$(O): jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcphuff.$(O): jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcprepct.$(O): jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcsample.$(O): jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jctrans.$(O): jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapimin.$(O): jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapistd.$(O): jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdatadst.$(O): jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdatasrc.$(O): jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdcoefct.$(O): jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdcolor.$(O): jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jddctmgr.$(O): jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jdhuff.$(O): jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdinput.$(O): jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmainct.$(O): jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmarker.$(O): jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmaster.$(O): jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmerge.$(O): jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdphuff.$(O): jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdpostct.$(O): jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdsample.$(O): jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdtrans.$(O): jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jerror.$(O): jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h -jfdctflt.$(O): jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctfst.$(O): jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctint.$(O): jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctflt.$(O): jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctfst.$(O): jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctint.$(O): jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctred.$(O): jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jquant1.$(O): jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jquant2.$(O): jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jutils.$(O): jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jmemmgr.$(O): jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemansi.$(O): jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemname.$(O): jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemnobs.$(O): jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemdos.$(O): jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemmac.$(O): jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -cjpeg.$(O): cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -djpeg.$(O): djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -jpegtran.$(O): jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h -rdjpgcom.$(O): rdjpgcom.c jinclude.h jconfig.h -wrjpgcom.$(O): wrjpgcom.c jinclude.h jconfig.h -cdjpeg.$(O): cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdcolmap.$(O): rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdswitch.$(O): rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -transupp.$(O): transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h -rdppm.$(O): rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrppm.$(O): wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdgif.$(O): rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrgif.$(O): wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdtarga.$(O): rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrtarga.$(O): wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdbmp.$(O): rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrbmp.$(O): wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdrle.$(O): rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrrle.$(O): wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/makefile.dj b/irrlicht-1.6/source/Irrlicht/jpeglib/makefile.dj deleted file mode 100644 index 4355ce22c..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/makefile.dj +++ /dev/null @@ -1,220 +0,0 @@ -# Makefile for Independent JPEG Group's software - -# This makefile is for DJGPP (Delorie's GNU C port on MS-DOS), v2.0 or later. -# Thanks to Frank J. Donahoe for this version. - -# Read installation instructions before saying "make" !! - -# The name of your C compiler: -CC= gcc - -# You may need to adjust these cc options: -CFLAGS= -O2 -Wall -I. -# Generally, we recommend defining any configuration symbols in jconfig.h, -# NOT via -D switches here. - -# Link-time cc options: -LDFLAGS= -s - -# To link any special libraries, add the necessary -l commands here. -LDLIBS= - -# Put here the object file name for the correct system-dependent memory -# manager file. For DJGPP this is usually jmemnobs.o, but you could -# use jmemname.o if you want to use named temp files instead of swap space. -SYSDEPMEM= jmemnobs.o - -# miscellaneous OS-dependent stuff -# linker -LN= $(CC) -# file deletion command -RM= del -# library (.a) file creation command -AR= ar rc -# second step in .a creation (use "touch" if not needed) -AR2= ranlib - -# End of configurable options. - - -# source files: JPEG library proper -LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ - jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ - jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ - jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ - jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ - jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ - jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ - jquant2.c jutils.c jmemmgr.c -# memmgr back ends: compile only one of these into a working library -SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c -# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom -APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ - rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ - rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c -SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) -# files included by source files -INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ - jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h -# documentation, test, and support files -DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ - wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ - coderules.doc filelist.doc change.log -MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ - makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds \ - makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ - maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ - makvms.opt -CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ - jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ - jconfig.vms -CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh -OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm -TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \ - testimgp.jpg -DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ - $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) -# library object files common to compression and decompression -COMOBJECTS= jcomapi.o jutils.o jerror.o jmemmgr.o $(SYSDEPMEM) -# compression library object files -CLIBOBJECTS= jcapimin.o jcapistd.o jctrans.o jcparam.o jdatadst.o jcinit.o \ - jcmaster.o jcmarker.o jcmainct.o jcprepct.o jccoefct.o jccolor.o \ - jcsample.o jchuff.o jcphuff.o jcdctmgr.o jfdctfst.o jfdctflt.o \ - jfdctint.o -# decompression library object files -DLIBOBJECTS= jdapimin.o jdapistd.o jdtrans.o jdatasrc.o jdmaster.o \ - jdinput.o jdmarker.o jdhuff.o jdphuff.o jdmainct.o jdcoefct.o \ - jdpostct.o jddctmgr.o jidctfst.o jidctflt.o jidctint.o jidctred.o \ - jdsample.o jdcolor.o jquant1.o jquant2.o jdmerge.o -# These objectfiles are included in libjpeg.a -LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) -# object files for sample applications (excluding library files) -COBJECTS= cjpeg.o rdppm.o rdgif.o rdtarga.o rdrle.o rdbmp.o rdswitch.o \ - cdjpeg.o -DOBJECTS= djpeg.o wrppm.o wrgif.o wrtarga.o wrrle.o wrbmp.o rdcolmap.o \ - cdjpeg.o -TROBJECTS= jpegtran.o rdswitch.o cdjpeg.o transupp.o - - -all: libjpeg.a cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe - -libjpeg.a: $(LIBOBJECTS) - $(RM) libjpeg.a - $(AR) libjpeg.a $(LIBOBJECTS) - $(AR2) libjpeg.a - -cjpeg.exe: $(COBJECTS) libjpeg.a - $(LN) $(LDFLAGS) -o cjpeg.exe $(COBJECTS) libjpeg.a $(LDLIBS) - -djpeg.exe: $(DOBJECTS) libjpeg.a - $(LN) $(LDFLAGS) -o djpeg.exe $(DOBJECTS) libjpeg.a $(LDLIBS) - -jpegtran.exe: $(TROBJECTS) libjpeg.a - $(LN) $(LDFLAGS) -o jpegtran.exe $(TROBJECTS) libjpeg.a $(LDLIBS) - -rdjpgcom.exe: rdjpgcom.o - $(LN) $(LDFLAGS) -o rdjpgcom.exe rdjpgcom.o $(LDLIBS) - -wrjpgcom.exe: wrjpgcom.o - $(LN) $(LDFLAGS) -o wrjpgcom.exe wrjpgcom.o $(LDLIBS) - -jconfig.h: jconfig.doc - echo You must prepare a system-dependent jconfig.h file. - echo Please read the installation directions in install.doc. - exit 1 - -clean: - $(RM) *.o - $(RM) cjpeg.exe - $(RM) djpeg.exe - $(RM) jpegtran.exe - $(RM) rdjpgcom.exe - $(RM) wrjpgcom.exe - $(RM) libjpeg.a - $(RM) testout*.* - -test: cjpeg.exe djpeg.exe jpegtran.exe - $(RM) testout*.* - ./djpeg -dct int -ppm -outfile testout.ppm testorig.jpg - ./djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg - ./cjpeg -dct int -outfile testout.jpg testimg.ppm - ./djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg - ./cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm - ./jpegtran -outfile testoutt.jpg testprog.jpg - fc /b testimg.ppm testout.ppm - fc /b testimg.bmp testout.bmp - fc /b testimg.jpg testout.jpg - fc /b testimg.ppm testoutp.ppm - fc /b testimgp.jpg testoutp.jpg - fc /b testorig.jpg testoutt.jpg - - -jcapimin.o: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcapistd.o: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccoefct.o: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccolor.o: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcdctmgr.o: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jchuff.o: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcinit.o: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmainct.o: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmarker.o: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmaster.o: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcomapi.o: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcparam.o: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcphuff.o: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcprepct.o: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcsample.o: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jctrans.o: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapimin.o: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapistd.o: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdatadst.o: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdatasrc.o: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdcoefct.o: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdcolor.o: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jddctmgr.o: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jdhuff.o: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdinput.o: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmainct.o: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmarker.o: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmaster.o: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmerge.o: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdphuff.o: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdpostct.o: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdsample.o: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdtrans.o: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jerror.o: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h -jfdctflt.o: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctfst.o: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctint.o: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctflt.o: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctfst.o: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctint.o: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctred.o: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jquant1.o: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jquant2.o: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jutils.o: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jmemmgr.o: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemansi.o: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemname.o: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemnobs.o: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemdos.o: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemmac.o: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -cjpeg.o: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -djpeg.o: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -jpegtran.o: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h -rdjpgcom.o: rdjpgcom.c jinclude.h jconfig.h -wrjpgcom.o: wrjpgcom.c jinclude.h jconfig.h -cdjpeg.o: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdcolmap.o: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdswitch.o: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -transupp.o: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h -rdppm.o: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrppm.o: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdgif.o: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrgif.o: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdtarga.o: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrtarga.o: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdbmp.o: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrbmp.o: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdrle.o: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrrle.o: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/makefile.manx b/irrlicht-1.6/source/Irrlicht/jpeglib/makefile.manx deleted file mode 100644 index 7cbc752c9..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/makefile.manx +++ /dev/null @@ -1,214 +0,0 @@ -# Makefile for Independent JPEG Group's software - -# This makefile is for Amiga systems using Manx Aztec C ver 5.x. -# Thanks to D.J. James (djjames@cup.portal.com) for this version. - -# Read installation instructions before saying "make" !! - -# The name of your C compiler: -CC= cc - -# You may need to adjust these cc options: -# Uncomment for generic 68000 code (will work on any Amiga) -ARCHFLAGS= -sn - -# Uncomment for 68020/68030 code (faster, but won't run on 68000 CPU) -#ARCHFLAGS= -c2 - -CFLAGS= -MC -MD $(ARCHFLAGS) -spfam -r4 - -# Link-time cc options: -LDFLAGS= -g - -# To link any special libraries, add the necessary -l commands here. -LDLIBS= -lml -lcl - -# Put here the object file name for the correct system-dependent memory -# manager file. For Amiga we recommend jmemname.o. -SYSDEPMEM= jmemname.o - -# miscellaneous OS-dependent stuff -# linker -LN= ln -# file deletion command -RM= delete quiet -# library (.lib) file creation command -AR= lb - -# End of configurable options. - - -# source files: JPEG library proper -LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ - jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ - jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ - jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ - jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ - jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ - jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ - jquant2.c jutils.c jmemmgr.c -# memmgr back ends: compile only one of these into a working library -SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c -# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom -APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ - rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ - rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c -SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) -# files included by source files -INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ - jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h -# documentation, test, and support files -DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ - wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ - coderules.doc filelist.doc change.log -MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ - makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds \ - makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ - maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ - makvms.opt -CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ - jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ - jconfig.vms -CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh -OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm -TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \ - testimgp.jpg -DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ - $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) -# library object files common to compression and decompression -COMOBJECTS= jcomapi.o jutils.o jerror.o jmemmgr.o $(SYSDEPMEM) -# compression library object files -CLIBOBJECTS= jcapimin.o jcapistd.o jctrans.o jcparam.o jdatadst.o jcinit.o \ - jcmaster.o jcmarker.o jcmainct.o jcprepct.o jccoefct.o jccolor.o \ - jcsample.o jchuff.o jcphuff.o jcdctmgr.o jfdctfst.o jfdctflt.o \ - jfdctint.o -# decompression library object files -DLIBOBJECTS= jdapimin.o jdapistd.o jdtrans.o jdatasrc.o jdmaster.o \ - jdinput.o jdmarker.o jdhuff.o jdphuff.o jdmainct.o jdcoefct.o \ - jdpostct.o jddctmgr.o jidctfst.o jidctflt.o jidctint.o jidctred.o \ - jdsample.o jdcolor.o jquant1.o jquant2.o jdmerge.o -# These objectfiles are included in libjpeg.lib -LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) -# object files for sample applications (excluding library files) -COBJECTS= cjpeg.o rdppm.o rdgif.o rdtarga.o rdrle.o rdbmp.o rdswitch.o \ - cdjpeg.o -DOBJECTS= djpeg.o wrppm.o wrgif.o wrtarga.o wrrle.o wrbmp.o rdcolmap.o \ - cdjpeg.o -TROBJECTS= jpegtran.o rdswitch.o cdjpeg.o transupp.o - - -all: libjpeg.lib cjpeg djpeg jpegtran rdjpgcom wrjpgcom - -libjpeg.lib: $(LIBOBJECTS) - -$(RM) libjpeg.lib - $(AR) libjpeg.lib $(LIBOBJECTS) - -cjpeg: $(COBJECTS) libjpeg.lib - $(LN) $(LDFLAGS) -o cjpeg $(COBJECTS) libjpeg.lib $(LDLIBS) - -djpeg: $(DOBJECTS) libjpeg.lib - $(LN) $(LDFLAGS) -o djpeg $(DOBJECTS) libjpeg.lib $(LDLIBS) - -jpegtran: $(TROBJECTS) libjpeg.lib - $(LN) $(LDFLAGS) -o jpegtran $(TROBJECTS) libjpeg.lib $(LDLIBS) - -rdjpgcom: rdjpgcom.o - $(LN) $(LDFLAGS) -o rdjpgcom rdjpgcom.o $(LDLIBS) - -wrjpgcom: wrjpgcom.o - $(LN) $(LDFLAGS) -o wrjpgcom wrjpgcom.o $(LDLIBS) - -jconfig.h: jconfig.doc - echo You must prepare a system-dependent jconfig.h file. - echo Please read the installation directions in install.doc. - exit 1 - -clean: - -$(RM) *.o cjpeg djpeg jpegtran libjpeg.lib rdjpgcom wrjpgcom - -$(RM) core testout*.* - -test: cjpeg djpeg jpegtran - -$(RM) testout*.* - djpeg -dct int -ppm -outfile testout.ppm testorig.jpg - djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg - cjpeg -dct int -outfile testout.jpg testimg.ppm - djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg - cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm - jpegtran -outfile testoutt.jpg testprog.jpg - cmp testimg.ppm testout.ppm - cmp testimg.bmp testout.bmp - cmp testimg.jpg testout.jpg - cmp testimg.ppm testoutp.ppm - cmp testimgp.jpg testoutp.jpg - cmp testorig.jpg testoutt.jpg - - -jcapimin.o: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcapistd.o: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccoefct.o: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccolor.o: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcdctmgr.o: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jchuff.o: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcinit.o: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmainct.o: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmarker.o: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmaster.o: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcomapi.o: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcparam.o: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcphuff.o: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcprepct.o: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcsample.o: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jctrans.o: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapimin.o: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapistd.o: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdatadst.o: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdatasrc.o: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdcoefct.o: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdcolor.o: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jddctmgr.o: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jdhuff.o: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdinput.o: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmainct.o: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmarker.o: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmaster.o: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmerge.o: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdphuff.o: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdpostct.o: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdsample.o: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdtrans.o: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jerror.o: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h -jfdctflt.o: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctfst.o: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctint.o: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctflt.o: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctfst.o: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctint.o: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctred.o: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jquant1.o: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jquant2.o: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jutils.o: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jmemmgr.o: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemansi.o: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemname.o: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemnobs.o: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemdos.o: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemmac.o: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -cjpeg.o: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -djpeg.o: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -jpegtran.o: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h -rdjpgcom.o: rdjpgcom.c jinclude.h jconfig.h -wrjpgcom.o: wrjpgcom.c jinclude.h jconfig.h -cdjpeg.o: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdcolmap.o: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdswitch.o: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -transupp.o: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h -rdppm.o: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrppm.o: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdgif.o: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrgif.o: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdtarga.o: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrtarga.o: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdbmp.o: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrbmp.o: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdrle.o: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrrle.o: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/makefile.mc6 b/irrlicht-1.6/source/Irrlicht/jpeglib/makefile.mc6 deleted file mode 100644 index 1185fb4a7..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/makefile.mc6 +++ /dev/null @@ -1,249 +0,0 @@ -# Makefile for Independent JPEG Group's software - -# This makefile is for Microsoft C for MS-DOS, version 6.00A and up. -# Use NMAKE, not Microsoft's brain-damaged MAKE. -# Thanks to Alan Wright and Chris Turner of Olivetti Research Ltd. - -# Read installation instructions before saying "nmake" !! - -# You may need to adjust these compiler options: -CFLAGS = -AM -Oecigt -Gs -W3 -# -AM medium memory model (or use -AS for small model, if you remove features) -# -Oecigt -Gs maximum safe optimisation (-Ol has bugs in MSC 6.00A) -# -W3 warning level 3 -# You might also want to add -G2 if you have an 80286, etc. -# Generally, we recommend defining any configuration symbols in jconfig.h, -# NOT via -D switches here. - -# Jan-Herman Buining suggests the following switches for MS C 8.0 and a 486: -# CFLAGS = /AM /f- /FPi87 /G3 /Gs /Gy /Ob1 /Oc /Oe /Og /Oi /Ol /On /Oo /Ot \ -# /OV4 /W3 -# except for jquant1.c, which must be compiled with /Oo- to avoid a compiler -# crash. - -# Ingar Steinsland suggests the following switches when building -# a 16-bit Windows DLL: -# CFLAGS = -ALw -Gsw -Zpe -W3 -O2 -Zi -Zd - -# Put here the object file name for the correct system-dependent memory -# manager file. For DOS, we recommend jmemdos.c and jmemdosa.asm. -# (But not for Windows; see install.doc if you use this makefile for Windows.) -SYSDEPMEM= jmemdos.obj jmemdosa.obj -# SYSDEPMEMLIB must list the same files with "+" signs for the librarian. -SYSDEPMEMLIB= +jmemdos.obj +jmemdosa.obj - -# End of configurable options. - - -# source files: JPEG library proper -LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ - jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ - jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ - jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ - jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ - jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ - jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ - jquant2.c jutils.c jmemmgr.c -# memmgr back ends: compile only one of these into a working library -SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c -# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom -APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ - rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ - rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c -SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) -# files included by source files -INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ - jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h -# documentation, test, and support files -DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ - wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ - coderules.doc filelist.doc change.log -MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ - makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds \ - makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ - maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ - makvms.opt -CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ - jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ - jconfig.vms -CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh -OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm -TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \ - testimgp.jpg -DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ - $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) -# library object files common to compression and decompression -COMOBJECTS= jcomapi.obj jutils.obj jerror.obj jmemmgr.obj $(SYSDEPMEM) -# compression library object files -CLIBOBJECTS= jcapimin.obj jcapistd.obj jctrans.obj jcparam.obj jdatadst.obj \ - jcinit.obj jcmaster.obj jcmarker.obj jcmainct.obj jcprepct.obj \ - jccoefct.obj jccolor.obj jcsample.obj jchuff.obj jcphuff.obj \ - jcdctmgr.obj jfdctfst.obj jfdctflt.obj jfdctint.obj -# decompression library object files -DLIBOBJECTS= jdapimin.obj jdapistd.obj jdtrans.obj jdatasrc.obj \ - jdmaster.obj jdinput.obj jdmarker.obj jdhuff.obj jdphuff.obj \ - jdmainct.obj jdcoefct.obj jdpostct.obj jddctmgr.obj jidctfst.obj \ - jidctflt.obj jidctint.obj jidctred.obj jdsample.obj jdcolor.obj \ - jquant1.obj jquant2.obj jdmerge.obj -# These objectfiles are included in libjpeg.lib -LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) -# object files for sample applications (excluding library files) -COBJECTS= cjpeg.obj rdppm.obj rdgif.obj rdtarga.obj rdrle.obj rdbmp.obj \ - rdswitch.obj cdjpeg.obj -DOBJECTS= djpeg.obj wrppm.obj wrgif.obj wrtarga.obj wrrle.obj wrbmp.obj \ - rdcolmap.obj cdjpeg.obj -TROBJECTS= jpegtran.obj rdswitch.obj cdjpeg.obj transupp.obj - -# need linker response file because file list > 128 chars -RFILE = libjpeg.ans - - -all: libjpeg.lib cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe - -libjpeg.lib: $(LIBOBJECTS) $(RFILE) - del libjpeg.lib - lib @$(RFILE) - -# linker response file for building libjpeg.lib -$(RFILE) : makefile - del $(RFILE) - echo libjpeg.lib >$(RFILE) -# silly want-to-create-it prompt: - echo y >>$(RFILE) - echo +jcapimin.obj +jcapistd.obj +jctrans.obj +jcparam.obj & >>$(RFILE) - echo +jdatadst.obj +jcinit.obj +jcmaster.obj +jcmarker.obj & >>$(RFILE) - echo +jcmainct.obj +jcprepct.obj +jccoefct.obj & >>$(RFILE) - echo +jccolor.obj +jcsample.obj +jchuff.obj +jcphuff.obj & >>$(RFILE) - echo +jcdctmgr.obj +jfdctfst.obj +jfdctflt.obj & >>$(RFILE) - echo +jfdctint.obj +jdapimin.obj +jdapistd.obj & >>$(RFILE) - echo +jdtrans.obj +jdatasrc.obj +jdmaster.obj +jdinput.obj & >>$(RFILE) - echo +jdmarker.obj +jdhuff.obj +jdphuff.obj +jdmainct.obj & >>$(RFILE) - echo +jdcoefct.obj +jdpostct.obj +jddctmgr.obj & >>$(RFILE) - echo +jidctfst.obj +jidctflt.obj +jidctint.obj & >>$(RFILE) - echo +jidctred.obj +jdsample.obj +jdcolor.obj +jquant1.obj & >>$(RFILE) - echo +jquant2.obj +jdmerge.obj +jcomapi.obj +jutils.obj & >>$(RFILE) - echo +jerror.obj +jmemmgr.obj & >>$(RFILE) - echo $(SYSDEPMEMLIB) ; >>$(RFILE) - -cjpeg.exe: $(COBJECTS) libjpeg.lib - echo $(COBJECTS) >cjpeg.lst - link /STACK:4096 /EXEPACK @cjpeg.lst, cjpeg.exe, , libjpeg.lib, ; - del cjpeg.lst - -djpeg.exe: $(DOBJECTS) libjpeg.lib - echo $(DOBJECTS) >djpeg.lst - link /STACK:4096 /EXEPACK @djpeg.lst, djpeg.exe, , libjpeg.lib, ; - del djpeg.lst - -jpegtran.exe: $(TROBJECTS) libjpeg.lib - link /STACK:4096 /EXEPACK $(TROBJECTS), jpegtran.exe, , libjpeg.lib, ; - -rdjpgcom.exe: rdjpgcom.c - $(CC) -AS -O -W3 rdjpgcom.c - -# wrjpgcom needs large model so it can malloc a 64K chunk -wrjpgcom.exe: wrjpgcom.c - $(CC) -AL -O -W3 wrjpgcom.c - -jconfig.h: jconfig.doc - echo You must prepare a system-dependent jconfig.h file. - echo Please read the installation directions in install.doc. - exit 1 - -clean: - del *.obj - del libjpeg.lib - del cjpeg.exe - del djpeg.exe - del jpegtran.exe - del rdjpgcom.exe - del wrjpgcom.exe - del testout*.* - -test: cjpeg.exe djpeg.exe jpegtran.exe - del testout*.* - djpeg -dct int -ppm -outfile testout.ppm testorig.jpg - djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg - cjpeg -dct int -outfile testout.jpg testimg.ppm - djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg - cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm - jpegtran -outfile testoutt.jpg testprog.jpg - fc /b testimg.ppm testout.ppm - fc /b testimg.bmp testout.bmp - fc /b testimg.jpg testout.jpg - fc /b testimg.ppm testoutp.ppm - fc /b testimgp.jpg testoutp.jpg - fc /b testorig.jpg testoutt.jpg - - -jcapimin.obj: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcapistd.obj: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccoefct.obj: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccolor.obj: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcdctmgr.obj: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jchuff.obj: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcinit.obj: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmainct.obj: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmarker.obj: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmaster.obj: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcomapi.obj: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcparam.obj: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcphuff.obj: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcprepct.obj: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcsample.obj: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jctrans.obj: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapimin.obj: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapistd.obj: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdatadst.obj: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdatasrc.obj: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdcoefct.obj: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdcolor.obj: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jddctmgr.obj: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jdhuff.obj: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdinput.obj: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmainct.obj: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmarker.obj: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmaster.obj: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmerge.obj: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdphuff.obj: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdpostct.obj: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdsample.obj: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdtrans.obj: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jerror.obj: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h -jfdctflt.obj: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctfst.obj: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctint.obj: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctflt.obj: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctfst.obj: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctint.obj: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctred.obj: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jquant1.obj: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jquant2.obj: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jutils.obj: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jmemmgr.obj: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemansi.obj: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemname.obj: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemnobs.obj: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemdos.obj: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemmac.obj: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -cjpeg.obj: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -djpeg.obj: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -jpegtran.obj: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h -rdjpgcom.obj: rdjpgcom.c jinclude.h jconfig.h -wrjpgcom.obj: wrjpgcom.c jinclude.h jconfig.h -cdjpeg.obj: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdcolmap.obj: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdswitch.obj: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -transupp.obj: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h -rdppm.obj: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrppm.obj: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdgif.obj: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrgif.obj: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdtarga.obj: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrtarga.obj: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdbmp.obj: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrbmp.obj: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdrle.obj: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrrle.obj: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -jmemdosa.obj : jmemdosa.asm - masm /mx $*; diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/makefile.mms b/irrlicht-1.6/source/Irrlicht/jpeglib/makefile.mms deleted file mode 100644 index 4ce8b8990..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/makefile.mms +++ /dev/null @@ -1,218 +0,0 @@ -# Makefile for Independent JPEG Group's software - -# This makefile is for use with MMS on Digital VMS systems. -# Thanks to Rick Dyson (dyson@iowasp.physics.uiowa.edu) -# and Tim Bell (tbell@netcom.com) for their help. - -# Read installation instructions before saying "MMS" !! - -# You may need to adjust these cc options: -CFLAGS= $(CFLAGS) /NoDebug /Optimize -# Generally, we recommend defining any configuration symbols in jconfig.h, -# NOT via /Define switches here. -.ifdef ALPHA -OPT= -.else -OPT= ,Sys$Disk:[]MAKVMS.OPT/Option -.endif - -# Put here the object file name for the correct system-dependent memory -# manager file. For Unix this is usually jmemnobs.o, but you may want -# to use jmemansi.o or jmemname.o if you have limited swap space. -SYSDEPMEM= jmemnobs.obj - -# End of configurable options. - - -# source files: JPEG library proper -LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ - jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ - jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ - jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ - jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ - jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ - jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ - jquant2.c jutils.c jmemmgr.c -# memmgr back ends: compile only one of these into a working library -SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c -# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom -APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ - rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ - rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c -SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) -# files included by source files -INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ - jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h -# documentation, test, and support files -DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ - wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ - coderules.doc filelist.doc change.log -MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ - makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds \ - makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ - maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ - makvms.opt -CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ - jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ - jconfig.vms -CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh -OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm -TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \ - testimgp.jpg -DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ - $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) -# library object files common to compression and decompression -COMOBJECTS= jcomapi.obj jutils.obj jerror.obj jmemmgr.obj $(SYSDEPMEM) -# compression library object files -CLIBOBJECTS= jcapimin.obj jcapistd.obj jctrans.obj jcparam.obj jdatadst.obj \ - jcinit.obj jcmaster.obj jcmarker.obj jcmainct.obj jcprepct.obj \ - jccoefct.obj jccolor.obj jcsample.obj jchuff.obj jcphuff.obj \ - jcdctmgr.obj jfdctfst.obj jfdctflt.obj jfdctint.obj -# decompression library object files -DLIBOBJECTS= jdapimin.obj jdapistd.obj jdtrans.obj jdatasrc.obj \ - jdmaster.obj jdinput.obj jdmarker.obj jdhuff.obj jdphuff.obj \ - jdmainct.obj jdcoefct.obj jdpostct.obj jddctmgr.obj jidctfst.obj \ - jidctflt.obj jidctint.obj jidctred.obj jdsample.obj jdcolor.obj \ - jquant1.obj jquant2.obj jdmerge.obj -# These objectfiles are included in libjpeg.olb -LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) -# object files for sample applications (excluding library files) -COBJECTS= cjpeg.obj rdppm.obj rdgif.obj rdtarga.obj rdrle.obj rdbmp.obj \ - rdswitch.obj cdjpeg.obj -DOBJECTS= djpeg.obj wrppm.obj wrgif.obj wrtarga.obj wrrle.obj wrbmp.obj \ - rdcolmap.obj cdjpeg.obj -TROBJECTS= jpegtran.obj rdswitch.obj cdjpeg.obj transupp.obj -# objectfile lists with commas --- what a crock -COBJLIST= cjpeg.obj,rdppm.obj,rdgif.obj,rdtarga.obj,rdrle.obj,rdbmp.obj,\ - rdswitch.obj,cdjpeg.obj -DOBJLIST= djpeg.obj,wrppm.obj,wrgif.obj,wrtarga.obj,wrrle.obj,wrbmp.obj,\ - rdcolmap.obj,cdjpeg.obj -TROBJLIST= jpegtran.obj,rdswitch.obj,cdjpeg.obj,transupp.obj -LIBOBJLIST= jcapimin.obj,jcapistd.obj,jctrans.obj,jcparam.obj,jdatadst.obj,\ - jcinit.obj,jcmaster.obj,jcmarker.obj,jcmainct.obj,jcprepct.obj,\ - jccoefct.obj,jccolor.obj,jcsample.obj,jchuff.obj,jcphuff.obj,\ - jcdctmgr.obj,jfdctfst.obj,jfdctflt.obj,jfdctint.obj,jdapimin.obj,\ - jdapistd.obj,jdtrans.obj,jdatasrc.obj,jdmaster.obj,jdinput.obj,\ - jdmarker.obj,jdhuff.obj,jdphuff.obj,jdmainct.obj,jdcoefct.obj,\ - jdpostct.obj,jddctmgr.obj,jidctfst.obj,jidctflt.obj,jidctint.obj,\ - jidctred.obj,jdsample.obj,jdcolor.obj,jquant1.obj,jquant2.obj,\ - jdmerge.obj,jcomapi.obj,jutils.obj,jerror.obj,jmemmgr.obj,$(SYSDEPMEM) - - -.first - @- Define /NoLog Sys Sys$Library - -ALL : libjpeg.olb cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe - @ Continue - -libjpeg.olb : $(LIBOBJECTS) - Library /Create libjpeg.olb $(LIBOBJLIST) - -cjpeg.exe : $(COBJECTS) libjpeg.olb - $(LINK) $(LFLAGS) /Executable = cjpeg.exe $(COBJLIST),libjpeg.olb/Library$(OPT) - -djpeg.exe : $(DOBJECTS) libjpeg.olb - $(LINK) $(LFLAGS) /Executable = djpeg.exe $(DOBJLIST),libjpeg.olb/Library$(OPT) - -jpegtran.exe : $(TROBJECTS) libjpeg.olb - $(LINK) $(LFLAGS) /Executable = jpegtran.exe $(TROBJLIST),libjpeg.olb/Library$(OPT) - -rdjpgcom.exe : rdjpgcom.obj - $(LINK) $(LFLAGS) /Executable = rdjpgcom.exe rdjpgcom.obj$(OPT) - -wrjpgcom.exe : wrjpgcom.obj - $(LINK) $(LFLAGS) /Executable = wrjpgcom.exe wrjpgcom.obj$(OPT) - -jconfig.h : jconfig.vms - @- Copy jconfig.vms jconfig.h - -clean : - @- Set Protection = Owner:RWED *.*;-1 - @- Set Protection = Owner:RWED *.OBJ - - Purge /NoLog /NoConfirm *.* - - Delete /NoLog /NoConfirm *.OBJ; - -test : cjpeg.exe djpeg.exe jpegtran.exe - mcr sys$disk:[]djpeg -dct int -ppm -outfile testout.ppm testorig.jpg - mcr sys$disk:[]djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg - mcr sys$disk:[]cjpeg -dct int -outfile testout.jpg testimg.ppm - mcr sys$disk:[]djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg - mcr sys$disk:[]cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm - mcr sys$disk:[]jpegtran -outfile testoutt.jpg testprog.jpg - - Backup /Compare/Log testimg.ppm testout.ppm - - Backup /Compare/Log testimg.bmp testout.bmp - - Backup /Compare/Log testimg.jpg testout.jpg - - Backup /Compare/Log testimg.ppm testoutp.ppm - - Backup /Compare/Log testimgp.jpg testoutp.jpg - - Backup /Compare/Log testorig.jpg testoutt.jpg - - -jcapimin.obj : jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcapistd.obj : jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccoefct.obj : jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccolor.obj : jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcdctmgr.obj : jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jchuff.obj : jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcinit.obj : jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmainct.obj : jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmarker.obj : jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmaster.obj : jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcomapi.obj : jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcparam.obj : jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcphuff.obj : jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcprepct.obj : jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcsample.obj : jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jctrans.obj : jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapimin.obj : jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapistd.obj : jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdatadst.obj : jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdatasrc.obj : jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdcoefct.obj : jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdcolor.obj : jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jddctmgr.obj : jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jdhuff.obj : jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdinput.obj : jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmainct.obj : jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmarker.obj : jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmaster.obj : jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmerge.obj : jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdphuff.obj : jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdpostct.obj : jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdsample.obj : jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdtrans.obj : jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jerror.obj : jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h -jfdctflt.obj : jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctfst.obj : jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctint.obj : jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctflt.obj : jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctfst.obj : jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctint.obj : jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctred.obj : jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jquant1.obj : jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jquant2.obj : jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jutils.obj : jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jmemmgr.obj : jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemansi.obj : jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemname.obj : jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemnobs.obj : jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemdos.obj : jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemmac.obj : jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -cjpeg.obj : cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -djpeg.obj : djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -jpegtran.obj : jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h -rdjpgcom.obj : rdjpgcom.c jinclude.h jconfig.h -wrjpgcom.obj : wrjpgcom.c jinclude.h jconfig.h -cdjpeg.obj : cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdcolmap.obj : rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdswitch.obj : rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -transupp.obj : transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h -rdppm.obj : rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrppm.obj : wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdgif.obj : rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrgif.obj : wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdtarga.obj : rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrtarga.obj : wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdbmp.obj : rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrbmp.obj : wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdrle.obj : rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrrle.obj : wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/makefile.sas b/irrlicht-1.6/source/Irrlicht/jpeglib/makefile.sas deleted file mode 100644 index d26793d8f..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/makefile.sas +++ /dev/null @@ -1,252 +0,0 @@ -# Makefile for Independent JPEG Group's software - -# This makefile is for Amiga systems using SAS C 6.0 and up. -# Thanks to Ed Hanway, Mark Rinfret, and Jim Zepeda. - -# Read installation instructions before saying "make" !! - -# The name of your C compiler: -CC= sc - -# You may need to adjust these cc options: -# Uncomment the following lines for generic 680x0 version -ARCHFLAGS= cpu=any -SUFFIX= - -# Uncomment the following lines for 68030-only version -#ARCHFLAGS= cpu=68030 -#SUFFIX=.030 - -CFLAGS= nostackcheck data=near parms=register optimize $(ARCHFLAGS) \ - ignore=104 ignore=304 ignore=306 -# ignore=104 disables warnings for mismatched const qualifiers -# ignore=304 disables warnings for variables being optimized out -# ignore=306 disables warnings for the inlining of functions -# Generally, we recommend defining any configuration symbols in jconfig.h, -# NOT via define switches here. - -# Link-time cc options: -LDFLAGS= SC SD ND BATCH - -# To link any special libraries, add the necessary commands here. -LDLIBS= LIB:scm.lib LIB:sc.lib - -# Put here the object file name for the correct system-dependent memory -# manager file. For Amiga we recommend jmemname.o. -SYSDEPMEM= jmemname.o - -# miscellaneous OS-dependent stuff -# linker -LN= slink -# file deletion command -RM= delete quiet -# library (.lib) file creation command -AR= oml - -# End of configurable options. - - -# source files: JPEG library proper -LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ - jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ - jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ - jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ - jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ - jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ - jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ - jquant2.c jutils.c jmemmgr.c -# memmgr back ends: compile only one of these into a working library -SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c -# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom -APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ - rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ - rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c -SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) -# files included by source files -INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ - jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h -# documentation, test, and support files -DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ - wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ - coderules.doc filelist.doc change.log -MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ - makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds \ - makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ - maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ - makvms.opt -CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ - jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ - jconfig.vms -CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh -OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm -TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \ - testimgp.jpg -DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ - $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) -# library object files common to compression and decompression -COMOBJECTS= jcomapi.o jutils.o jerror.o jmemmgr.o $(SYSDEPMEM) -# compression library object files -CLIBOBJECTS= jcapimin.o jcapistd.o jctrans.o jcparam.o jdatadst.o jcinit.o \ - jcmaster.o jcmarker.o jcmainct.o jcprepct.o jccoefct.o jccolor.o \ - jcsample.o jchuff.o jcphuff.o jcdctmgr.o jfdctfst.o jfdctflt.o \ - jfdctint.o -# decompression library object files -DLIBOBJECTS= jdapimin.o jdapistd.o jdtrans.o jdatasrc.o jdmaster.o \ - jdinput.o jdmarker.o jdhuff.o jdphuff.o jdmainct.o jdcoefct.o \ - jdpostct.o jddctmgr.o jidctfst.o jidctflt.o jidctint.o jidctred.o \ - jdsample.o jdcolor.o jquant1.o jquant2.o jdmerge.o -# These objectfiles are included in libjpeg.lib -LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) -# object files for sample applications (excluding library files) -COBJECTS= cjpeg.o rdppm.o rdgif.o rdtarga.o rdrle.o rdbmp.o rdswitch.o \ - cdjpeg.o -DOBJECTS= djpeg.o wrppm.o wrgif.o wrtarga.o wrrle.o wrbmp.o rdcolmap.o \ - cdjpeg.o -TROBJECTS= jpegtran.o rdswitch.o cdjpeg.o transupp.o - - -all: libjpeg.lib cjpeg$(SUFFIX) djpeg$(SUFFIX) jpegtran$(SUFFIX) rdjpgcom$(SUFFIX) wrjpgcom$(SUFFIX) - -# note: do several AR steps to avoid command line length limitations - -libjpeg.lib: $(LIBOBJECTS) - -$(RM) libjpeg.lib - $(AR) libjpeg.lib r $(CLIBOBJECTS) - $(AR) libjpeg.lib r $(DLIBOBJECTS) - $(AR) libjpeg.lib r $(COMOBJECTS) - -cjpeg$(SUFFIX): $(COBJECTS) libjpeg.lib - $(LN) <WITH < -$(LDFLAGS) -TO cjpeg$(SUFFIX) -FROM LIB:c.o $(COBJECTS) -LIB libjpeg.lib $(LDLIBS) -< - -djpeg$(SUFFIX): $(DOBJECTS) libjpeg.lib - $(LN) <WITH < -$(LDFLAGS) -TO djpeg$(SUFFIX) -FROM LIB:c.o $(DOBJECTS) -LIB libjpeg.lib $(LDLIBS) -< - -jpegtran$(SUFFIX): $(TROBJECTS) libjpeg.lib - $(LN) <WITH < -$(LDFLAGS) -TO jpegtran$(SUFFIX) -FROM LIB:c.o $(TROBJECTS) -LIB libjpeg.lib $(LDLIBS) -< - -rdjpgcom$(SUFFIX): rdjpgcom.o - $(LN) <WITH < -$(LDFLAGS) -TO rdjpgcom$(SUFFIX) -FROM LIB:c.o rdjpgcom.o -LIB $(LDLIBS) -< - -wrjpgcom$(SUFFIX): wrjpgcom.o - $(LN) <WITH < -$(LDFLAGS) -TO wrjpgcom$(SUFFIX) -FROM LIB:c.o wrjpgcom.o -LIB $(LDLIBS) -< - -jconfig.h: jconfig.doc - echo You must prepare a system-dependent jconfig.h file. - echo Please read the installation directions in install.doc. - exit 1 - -clean: - -$(RM) *.o cjpeg djpeg jpegtran cjpeg.030 djpeg.030 jpegtran.030 - -$(RM) rdjpgcom wrjpgcom rdjpgcom.030 wrjpgcom.030 - -$(RM) libjpeg.lib core testout*.* - -test: cjpeg djpeg jpegtran - -$(RM) testout*.* - djpeg -dct int -ppm -outfile testout.ppm testorig.jpg - djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg - cjpeg -dct int -outfile testout.jpg testimg.ppm - djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg - cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm - jpegtran -outfile testoutt.jpg testprog.jpg - cmp testimg.ppm testout.ppm - cmp testimg.bmp testout.bmp - cmp testimg.jpg testout.jpg - cmp testimg.ppm testoutp.ppm - cmp testimgp.jpg testoutp.jpg - cmp testorig.jpg testoutt.jpg - - -jcapimin.o: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcapistd.o: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccoefct.o: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccolor.o: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcdctmgr.o: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jchuff.o: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcinit.o: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmainct.o: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmarker.o: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmaster.o: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcomapi.o: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcparam.o: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcphuff.o: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcprepct.o: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcsample.o: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jctrans.o: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapimin.o: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapistd.o: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdatadst.o: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdatasrc.o: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdcoefct.o: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdcolor.o: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jddctmgr.o: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jdhuff.o: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdinput.o: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmainct.o: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmarker.o: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmaster.o: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmerge.o: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdphuff.o: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdpostct.o: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdsample.o: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdtrans.o: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jerror.o: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h -jfdctflt.o: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctfst.o: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctint.o: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctflt.o: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctfst.o: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctint.o: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctred.o: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jquant1.o: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jquant2.o: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jutils.o: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jmemmgr.o: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemansi.o: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemname.o: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemnobs.o: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemdos.o: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemmac.o: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -cjpeg.o: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -djpeg.o: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -jpegtran.o: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h -rdjpgcom.o: rdjpgcom.c jinclude.h jconfig.h -wrjpgcom.o: wrjpgcom.c jinclude.h jconfig.h -cdjpeg.o: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdcolmap.o: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdswitch.o: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -transupp.o: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h -rdppm.o: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrppm.o: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdgif.o: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrgif.o: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdtarga.o: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrtarga.o: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdbmp.o: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrbmp.o: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdrle.o: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrrle.o: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/makefile.unix b/irrlicht-1.6/source/Irrlicht/jpeglib/makefile.unix deleted file mode 100644 index 069ca7185..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/makefile.unix +++ /dev/null @@ -1,228 +0,0 @@ -# Makefile for Independent JPEG Group's software - -# This makefile is suitable for Unix-like systems with non-ANSI compilers. -# If you have an ANSI compiler, makefile.ansi is a better starting point. - -# Read installation instructions before saying "make" !! - -# The name of your C compiler: -CC= cc - -# You may need to adjust these cc options: -CFLAGS= -O -# Generally, we recommend defining any configuration symbols in jconfig.h, -# NOT via -D switches here. -# However, any special defines for ansi2knr.c may be included here: -ANSI2KNRFLAGS= - -# Link-time cc options: -LDFLAGS= - -# To link any special libraries, add the necessary -l commands here. -LDLIBS= - -# Put here the object file name for the correct system-dependent memory -# manager file. For Unix this is usually jmemnobs.o, but you may want -# to use jmemansi.o or jmemname.o if you have limited swap space. -SYSDEPMEM= jmemnobs.o - -# miscellaneous OS-dependent stuff -# linker -LN= $(CC) -# file deletion command -RM= rm -f -# file rename command -MV= mv -# library (.a) file creation command -AR= ar rc -# second step in .a creation (use "touch" if not needed) -AR2= ranlib - -# End of configurable options. - - -# source files: JPEG library proper -LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ - jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ - jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ - jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ - jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ - jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ - jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ - jquant2.c jutils.c jmemmgr.c -# memmgr back ends: compile only one of these into a working library -SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c -# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom -APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ - rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ - rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c -SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) -# files included by source files -INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ - jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h -# documentation, test, and support files -DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ - wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ - coderules.doc filelist.doc change.log -MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ - makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds \ - makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ - maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ - makvms.opt -CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ - jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ - jconfig.vms -CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh -OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm -TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \ - testimgp.jpg -DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ - $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) -# library object files common to compression and decompression -COMOBJECTS= jcomapi.o jutils.o jerror.o jmemmgr.o $(SYSDEPMEM) -# compression library object files -CLIBOBJECTS= jcapimin.o jcapistd.o jctrans.o jcparam.o jdatadst.o jcinit.o \ - jcmaster.o jcmarker.o jcmainct.o jcprepct.o jccoefct.o jccolor.o \ - jcsample.o jchuff.o jcphuff.o jcdctmgr.o jfdctfst.o jfdctflt.o \ - jfdctint.o -# decompression library object files -DLIBOBJECTS= jdapimin.o jdapistd.o jdtrans.o jdatasrc.o jdmaster.o \ - jdinput.o jdmarker.o jdhuff.o jdphuff.o jdmainct.o jdcoefct.o \ - jdpostct.o jddctmgr.o jidctfst.o jidctflt.o jidctint.o jidctred.o \ - jdsample.o jdcolor.o jquant1.o jquant2.o jdmerge.o -# These objectfiles are included in libjpeg.a -LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) -# object files for sample applications (excluding library files) -COBJECTS= cjpeg.o rdppm.o rdgif.o rdtarga.o rdrle.o rdbmp.o rdswitch.o \ - cdjpeg.o -DOBJECTS= djpeg.o wrppm.o wrgif.o wrtarga.o wrrle.o wrbmp.o rdcolmap.o \ - cdjpeg.o -TROBJECTS= jpegtran.o rdswitch.o cdjpeg.o transupp.o - - -all: ansi2knr libjpeg.a cjpeg djpeg jpegtran rdjpgcom wrjpgcom - -# This rule causes ansi2knr to be invoked. -.c.o: - ./ansi2knr $*.c T$*.c - $(CC) $(CFLAGS) -c T$*.c - $(RM) T$*.c $*.o - $(MV) T$*.o $*.o - -ansi2knr: ansi2knr.c - $(CC) $(CFLAGS) $(ANSI2KNRFLAGS) -o ansi2knr ansi2knr.c - -libjpeg.a: ansi2knr $(LIBOBJECTS) - $(RM) libjpeg.a - $(AR) libjpeg.a $(LIBOBJECTS) - $(AR2) libjpeg.a - -cjpeg: ansi2knr $(COBJECTS) libjpeg.a - $(LN) $(LDFLAGS) -o cjpeg $(COBJECTS) libjpeg.a $(LDLIBS) - -djpeg: ansi2knr $(DOBJECTS) libjpeg.a - $(LN) $(LDFLAGS) -o djpeg $(DOBJECTS) libjpeg.a $(LDLIBS) - -jpegtran: ansi2knr $(TROBJECTS) libjpeg.a - $(LN) $(LDFLAGS) -o jpegtran $(TROBJECTS) libjpeg.a $(LDLIBS) - -rdjpgcom: rdjpgcom.o - $(LN) $(LDFLAGS) -o rdjpgcom rdjpgcom.o $(LDLIBS) - -wrjpgcom: wrjpgcom.o - $(LN) $(LDFLAGS) -o wrjpgcom wrjpgcom.o $(LDLIBS) - -jconfig.h: jconfig.doc - echo You must prepare a system-dependent jconfig.h file. - echo Please read the installation directions in install.doc. - exit 1 - -clean: - $(RM) *.o cjpeg djpeg jpegtran libjpeg.a rdjpgcom wrjpgcom - $(RM) ansi2knr core testout* - -test: cjpeg djpeg jpegtran - $(RM) testout* - ./djpeg -dct int -ppm -outfile testout.ppm testorig.jpg - ./djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg - ./cjpeg -dct int -outfile testout.jpg testimg.ppm - ./djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg - ./cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm - ./jpegtran -outfile testoutt.jpg testprog.jpg - cmp testimg.ppm testout.ppm - cmp testimg.bmp testout.bmp - cmp testimg.jpg testout.jpg - cmp testimg.ppm testoutp.ppm - cmp testimgp.jpg testoutp.jpg - cmp testorig.jpg testoutt.jpg - - -jcapimin.o: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcapistd.o: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccoefct.o: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccolor.o: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcdctmgr.o: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jchuff.o: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcinit.o: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmainct.o: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmarker.o: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmaster.o: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcomapi.o: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcparam.o: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcphuff.o: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcprepct.o: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcsample.o: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jctrans.o: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapimin.o: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapistd.o: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdatadst.o: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdatasrc.o: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdcoefct.o: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdcolor.o: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jddctmgr.o: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jdhuff.o: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdinput.o: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmainct.o: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmarker.o: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmaster.o: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmerge.o: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdphuff.o: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdpostct.o: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdsample.o: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdtrans.o: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jerror.o: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h -jfdctflt.o: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctfst.o: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctint.o: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctflt.o: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctfst.o: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctint.o: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctred.o: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jquant1.o: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jquant2.o: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jutils.o: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jmemmgr.o: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemansi.o: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemname.o: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemnobs.o: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemdos.o: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemmac.o: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -cjpeg.o: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -djpeg.o: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -jpegtran.o: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h -rdjpgcom.o: rdjpgcom.c jinclude.h jconfig.h -wrjpgcom.o: wrjpgcom.c jinclude.h jconfig.h -cdjpeg.o: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdcolmap.o: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdswitch.o: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -transupp.o: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h -rdppm.o: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrppm.o: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdgif.o: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrgif.o: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdtarga.o: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrtarga.o: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdbmp.o: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrbmp.o: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdrle.o: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrrle.o: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/makefile.vc b/irrlicht-1.6/source/Irrlicht/jpeglib/makefile.vc deleted file mode 100644 index da851be56..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/makefile.vc +++ /dev/null @@ -1,211 +0,0 @@ -# Makefile for Independent JPEG Group's software - -# This makefile is for Microsoft Visual C++ on Windows NT (and 95?). -# It builds the IJG library as a statically linkable library (.LIB), -# and builds the sample applications as console-mode apps. -# Thanks to Xingong Chang, Raymond Everly and others. - -# Read installation instructions before saying "nmake" !! -# To build an optimized library without debug info, say "nmake nodebug=1". - -# Pull in standard variable definitions -!include <win32.mak> - -# You may want to adjust these compiler options: -CFLAGS= $(cflags) $(cdebug) $(cvars) -I. -# Generally, we recommend defining any configuration symbols in jconfig.h, -# NOT via -D switches here. - -# Link-time options: -LDFLAGS= $(ldebug) $(conlflags) - -# To link any special libraries, add the necessary commands here. -LDLIBS= $(conlibs) - -# Put here the object file name for the correct system-dependent memory -# manager file. For NT we suggest jmemnobs.obj, which expects the OS to -# provide adequate virtual memory. -SYSDEPMEM= jmemnobs.obj - -# miscellaneous OS-dependent stuff -# file deletion command -RM= del - -# End of configurable options. - - -# source files: JPEG library proper -LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ - jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ - jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ - jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ - jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ - jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ - jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ - jquant2.c jutils.c jmemmgr.c -# memmgr back ends: compile only one of these into a working library -SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c -# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom -APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c \ - rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c \ - rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c -SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) -# files included by source files -INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ - jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h -# documentation, test, and support files -DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ - wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ - coderules.doc filelist.doc change.log -MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ - makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds \ - makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st \ - maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms \ - makvms.opt -CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \ - jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \ - jconfig.vms -CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh -OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm -TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \ - testimgp.jpg -DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ - $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) -# library object files common to compression and decompression -COMOBJECTS= jcomapi.obj jutils.obj jerror.obj jmemmgr.obj $(SYSDEPMEM) -# compression library object files -CLIBOBJECTS= jcapimin.obj jcapistd.obj jctrans.obj jcparam.obj jdatadst.obj \ - jcinit.obj jcmaster.obj jcmarker.obj jcmainct.obj jcprepct.obj \ - jccoefct.obj jccolor.obj jcsample.obj jchuff.obj jcphuff.obj \ - jcdctmgr.obj jfdctfst.obj jfdctflt.obj jfdctint.obj -# decompression library object files -DLIBOBJECTS= jdapimin.obj jdapistd.obj jdtrans.obj jdatasrc.obj \ - jdmaster.obj jdinput.obj jdmarker.obj jdhuff.obj jdphuff.obj \ - jdmainct.obj jdcoefct.obj jdpostct.obj jddctmgr.obj jidctfst.obj \ - jidctflt.obj jidctint.obj jidctred.obj jdsample.obj jdcolor.obj \ - jquant1.obj jquant2.obj jdmerge.obj -# These objectfiles are included in libjpeg.lib -LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) -# object files for sample applications (excluding library files) -COBJECTS= cjpeg.obj rdppm.obj rdgif.obj rdtarga.obj rdrle.obj rdbmp.obj \ - rdswitch.obj cdjpeg.obj -DOBJECTS= djpeg.obj wrppm.obj wrgif.obj wrtarga.obj wrrle.obj wrbmp.obj \ - rdcolmap.obj cdjpeg.obj -TROBJECTS= jpegtran.obj rdswitch.obj cdjpeg.obj transupp.obj - -# Template command for compiling .c to .obj -.c.obj: - $(cc) $(CFLAGS) $*.c - - -all: libjpeg.lib cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe - -libjpeg.lib: $(LIBOBJECTS) - $(RM) libjpeg.lib - lib -out:libjpeg.lib $(LIBOBJECTS) - -cjpeg.exe: $(COBJECTS) libjpeg.lib - $(link) $(LDFLAGS) -out:cjpeg.exe $(COBJECTS) libjpeg.lib $(LDLIBS) - -djpeg.exe: $(DOBJECTS) libjpeg.lib - $(link) $(LDFLAGS) -out:djpeg.exe $(DOBJECTS) libjpeg.lib $(LDLIBS) - -jpegtran.exe: $(TROBJECTS) libjpeg.lib - $(link) $(LDFLAGS) -out:jpegtran.exe $(TROBJECTS) libjpeg.lib $(LDLIBS) - -rdjpgcom.exe: rdjpgcom.obj - $(link) $(LDFLAGS) -out:rdjpgcom.exe rdjpgcom.obj $(LDLIBS) - -wrjpgcom.exe: wrjpgcom.obj - $(link) $(LDFLAGS) -out:wrjpgcom.exe wrjpgcom.obj $(LDLIBS) - - -clean: - $(RM) *.obj *.exe libjpeg.lib - $(RM) testout* - -test: cjpeg.exe djpeg.exe jpegtran.exe - $(RM) testout* - .\djpeg -dct int -ppm -outfile testout.ppm testorig.jpg - .\djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg - .\cjpeg -dct int -outfile testout.jpg testimg.ppm - .\djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg - .\cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm - .\jpegtran -outfile testoutt.jpg testprog.jpg - fc /b testimg.ppm testout.ppm - fc /b testimg.bmp testout.bmp - fc /b testimg.jpg testout.jpg - fc /b testimg.ppm testoutp.ppm - fc /b testimgp.jpg testoutp.jpg - fc /b testorig.jpg testoutt.jpg - - -jcapimin.obj: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcapistd.obj: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccoefct.obj: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccolor.obj: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcdctmgr.obj: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jchuff.obj: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcinit.obj: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmainct.obj: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmarker.obj: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmaster.obj: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcomapi.obj: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcparam.obj: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcphuff.obj: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcprepct.obj: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcsample.obj: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jctrans.obj: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapimin.obj: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapistd.obj: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdatadst.obj: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdatasrc.obj: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdcoefct.obj: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdcolor.obj: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jddctmgr.obj: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jdhuff.obj: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdinput.obj: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmainct.obj: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmarker.obj: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmaster.obj: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmerge.obj: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdphuff.obj: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdpostct.obj: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdsample.obj: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdtrans.obj: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jerror.obj: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h -jfdctflt.obj: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctfst.obj: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctint.obj: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctflt.obj: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctfst.obj: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctint.obj: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctred.obj: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jquant1.obj: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jquant2.obj: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jutils.obj: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jmemmgr.obj: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemansi.obj: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemname.obj: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemnobs.obj: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemdos.obj: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemmac.obj: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -cjpeg.obj: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -djpeg.obj: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -jpegtran.obj: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h -rdjpgcom.obj: rdjpgcom.c jinclude.h jconfig.h -wrjpgcom.obj: wrjpgcom.c jinclude.h jconfig.h -cdjpeg.obj: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdcolmap.obj: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdswitch.obj: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -transupp.obj: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h -rdppm.obj: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrppm.obj: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdgif.obj: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrgif.obj: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdtarga.obj: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrtarga.obj: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdbmp.obj: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrbmp.obj: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdrle.obj: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrrle.obj: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/makefile.vms b/irrlicht-1.6/source/Irrlicht/jpeglib/makefile.vms deleted file mode 100644 index 711f8524e..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/makefile.vms +++ /dev/null @@ -1,142 +0,0 @@ -$! Makefile for Independent JPEG Group's software -$! -$! This is a command procedure for Digital VMS systems that do not have MMS. -$! It builds the JPEG software by brute force, recompiling everything whether -$! or not it is necessary. It then runs the basic self-test. -$! Thanks to Rick Dyson (dyson@iowasp.physics.uiowa.edu) -$! and Tim Bell (tbell@netcom.com) for their help. -$! -$! Read installation instructions before running this!! -$! -$ If F$Mode () .eqs. "INTERACTIVE" -$ Then -$ VERIFY = F$Verify (0) -$ Else -$ VERIFY = F$Verify (1) -$ EndIf -$ On Control_Y Then GoTo End -$ On Error Then GoTo End -$ -$ If F$GetSyi ("HW_MODEL") .gt. 1023 -$ Then -$ OPT = "" -$ Else -$ OPT = ",Sys$Disk:[]makvms.opt/Option" -$ EndIf -$ -$ DoCompile := CC /NoDebug /Optimize /NoList -$! -$ DoCompile jcapimin.c -$ DoCompile jcapistd.c -$ DoCompile jctrans.c -$ DoCompile jcparam.c -$ DoCompile jdatadst.c -$ DoCompile jcinit.c -$ DoCompile jcmaster.c -$ DoCompile jcmarker.c -$ DoCompile jcmainct.c -$ DoCompile jcprepct.c -$ DoCompile jccoefct.c -$ DoCompile jccolor.c -$ DoCompile jcsample.c -$ DoCompile jchuff.c -$ DoCompile jcphuff.c -$ DoCompile jcdctmgr.c -$ DoCompile jfdctfst.c -$ DoCompile jfdctflt.c -$ DoCompile jfdctint.c -$ DoCompile jdapimin.c -$ DoCompile jdapistd.c -$ DoCompile jdtrans.c -$ DoCompile jdatasrc.c -$ DoCompile jdmaster.c -$ DoCompile jdinput.c -$ DoCompile jdmarker.c -$ DoCompile jdhuff.c -$ DoCompile jdphuff.c -$ DoCompile jdmainct.c -$ DoCompile jdcoefct.c -$ DoCompile jdpostct.c -$ DoCompile jddctmgr.c -$ DoCompile jidctfst.c -$ DoCompile jidctflt.c -$ DoCompile jidctint.c -$ DoCompile jidctred.c -$ DoCompile jdsample.c -$ DoCompile jdcolor.c -$ DoCompile jquant1.c -$ DoCompile jquant2.c -$ DoCompile jdmerge.c -$ DoCompile jcomapi.c -$ DoCompile jutils.c -$ DoCompile jerror.c -$ DoCompile jmemmgr.c -$ DoCompile jmemnobs.c -$! -$ Library /Create libjpeg.olb jcapimin.obj,jcapistd.obj,jctrans.obj, - - jcparam.obj,jdatadst.obj,jcinit.obj,jcmaster.obj,jcmarker.obj, - - jcmainct.obj,jcprepct.obj,jccoefct.obj,jccolor.obj,jcsample.obj, - - jchuff.obj,jcphuff.obj,jcdctmgr.obj,jfdctfst.obj,jfdctflt.obj, - - jfdctint.obj,jdapimin.obj,jdapistd.obj,jdtrans.obj,jdatasrc.obj, - - jdmaster.obj,jdinput.obj,jdmarker.obj,jdhuff.obj,jdphuff.obj, - - jdmainct.obj,jdcoefct.obj,jdpostct.obj,jddctmgr.obj,jidctfst.obj, - - jidctflt.obj,jidctint.obj,jidctred.obj,jdsample.obj,jdcolor.obj, - - jquant1.obj,jquant2.obj,jdmerge.obj,jcomapi.obj,jutils.obj, - - jerror.obj,jmemmgr.obj,jmemnobs.obj -$! -$ DoCompile cjpeg.c -$ DoCompile rdppm.c -$ DoCompile rdgif.c -$ DoCompile rdtarga.c -$ DoCompile rdrle.c -$ DoCompile rdbmp.c -$ DoCompile rdswitch.c -$ DoCompile cdjpeg.c -$! -$ Link /NoMap /Executable = cjpeg.exe cjpeg.obj,rdppm.obj,rdgif.obj, - - rdtarga.obj,rdrle.obj,rdbmp.obj,rdswitch.obj,cdjpeg.obj,libjpeg.olb/Library'OPT' -$! -$ DoCompile djpeg.c -$ DoCompile wrppm.c -$ DoCompile wrgif.c -$ DoCompile wrtarga.c -$ DoCompile wrrle.c -$ DoCompile wrbmp.c -$ DoCompile rdcolmap.c -$ DoCompile cdjpeg.c -$! -$ Link /NoMap /Executable = djpeg.exe djpeg.obj,wrppm.obj,wrgif.obj, - - wrtarga.obj,wrrle.obj,wrbmp.obj,rdcolmap.obj,cdjpeg.obj,libjpeg.olb/Library'OPT' -$! -$ DoCompile jpegtran.c -$ DoCompile rdswitch.c -$ DoCompile cdjpeg.c -$ DoCompile transupp.c -$! -$ Link /NoMap /Executable = jpegtran.exe jpegtran.obj,rdswitch.obj, - - cdjpeg.obj,transupp.obj,libjpeg.olb/Library'OPT' -$! -$ DoCompile rdjpgcom.c -$ Link /NoMap /Executable = rdjpgcom.exe rdjpgcom.obj'OPT' -$! -$ DoCompile wrjpgcom.c -$ Link /NoMap /Executable = wrjpgcom.exe wrjpgcom.obj'OPT' -$! -$! Run the self-test -$! -$ mcr sys$disk:[]djpeg -dct int -ppm -outfile testout.ppm testorig.jpg -$ mcr sys$disk:[]djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg -$ mcr sys$disk:[]cjpeg -dct int -outfile testout.jpg testimg.ppm -$ mcr sys$disk:[]djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg -$ mcr sys$disk:[]cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm -$ mcr sys$disk:[]jpegtran -outfile testoutt.jpg testprog.jpg -$ Backup /Compare/Log testimg.ppm testout.ppm -$ Backup /Compare/Log testimg.bmp testout.bmp -$ Backup /Compare/Log testimg.jpg testout.jpg -$ Backup /Compare/Log testimg.ppm testoutp.ppm -$ Backup /Compare/Log testimgp.jpg testoutp.jpg -$ Backup /Compare/Log testorig.jpg testoutt.jpg -$! -$End: -$ If Verify Then Set Verify -$ Exit diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/makefile.wat b/irrlicht-1.6/source/Irrlicht/jpeglib/makefile.wat deleted file mode 100644 index c0570dc52..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/makefile.wat +++ /dev/null @@ -1,233 +0,0 @@ -# Makefile for Independent JPEG Group's software - -# This makefile is suitable for Watcom C/C++ 10.0 on MS-DOS (using -# dos4g extender), OS/2, and Windows NT console mode. -# Thanks to Janos Haide, jhaide@btrvtech.com. - -# Read installation instructions before saying "wmake" !! - -# Uncomment line for desired system -SYSTEM=DOS -#SYSTEM=OS2 -#SYSTEM=NT - -# The name of your C compiler: -CC= wcl386 - -# You may need to adjust these cc options: -CFLAGS= -4r -ort -wx -zq -bt=$(SYSTEM) -# Caution: avoid -ol or -ox; these generate bad code with 10.0 or 10.0a. -# Generally, we recommend defining any configuration symbols in jconfig.h, -# NOT via -D switches here. - -# Link-time cc options: -!ifeq SYSTEM DOS -LDFLAGS= -zq -l=dos4g -!else ifeq SYSTEM OS2 -LDFLAGS= -zq -l=os2v2 -!else ifeq SYSTEM NT -LDFLAGS= -zq -l=nt -!endif - -# Put here the object file name for the correct system-dependent memory -# manager file. jmemnobs should work fine for dos4g or OS/2 environment. -SYSDEPMEM= jmemnobs.obj - -# End of configurable options. - - -# source files: JPEG library proper -LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c & - jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c & - jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c & - jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c & - jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c & - jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c & - jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c & - jquant2.c jutils.c jmemmgr.c -# memmgr back ends: compile only one of these into a working library -SYSDEPSOURCES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c -# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom -APPSOURCES= cjpeg.c djpeg.c jpegtran.c rdjpgcom.c wrjpgcom.c cdjpeg.c & - rdcolmap.c rdswitch.c transupp.c rdppm.c wrppm.c rdgif.c wrgif.c & - rdtarga.c wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c -SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES) -# files included by source files -INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h & - jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h transupp.h -# documentation, test, and support files -DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 & - wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc & - coderules.doc filelist.doc change.log -MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc & - makefile.mc6 makefile.dj makefile.wat makefile.vc makelib.ds & - makeapps.ds makeproj.mac makcjpeg.st makdjpeg.st makljpeg.st & - maktjpeg.st makefile.manx makefile.sas makefile.mms makefile.vms & - makvms.opt -CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat & - jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas & - jconfig.vms -CONFIGUREFILES= config.guess config.sub install-sh ltconfig ltmain.sh -OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm -TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg & - testimgp.jpg -DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) & - $(CONFIGUREFILES) $(OTHERFILES) $(TESTFILES) -# library object files common to compression and decompression -COMOBJECTS= jcomapi.obj jutils.obj jerror.obj jmemmgr.obj $(SYSDEPMEM) -# compression library object files -CLIBOBJECTS= jcapimin.obj jcapistd.obj jctrans.obj jcparam.obj jdatadst.obj & - jcinit.obj jcmaster.obj jcmarker.obj jcmainct.obj jcprepct.obj & - jccoefct.obj jccolor.obj jcsample.obj jchuff.obj jcphuff.obj & - jcdctmgr.obj jfdctfst.obj jfdctflt.obj jfdctint.obj -# decompression library object files -DLIBOBJECTS= jdapimin.obj jdapistd.obj jdtrans.obj jdatasrc.obj & - jdmaster.obj jdinput.obj jdmarker.obj jdhuff.obj jdphuff.obj & - jdmainct.obj jdcoefct.obj jdpostct.obj jddctmgr.obj jidctfst.obj & - jidctflt.obj jidctint.obj jidctred.obj jdsample.obj jdcolor.obj & - jquant1.obj jquant2.obj jdmerge.obj -# These objectfiles are included in libjpeg.lib -LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) -# object files for sample applications (excluding library files) -COBJECTS= cjpeg.obj rdppm.obj rdgif.obj rdtarga.obj rdrle.obj rdbmp.obj & - rdswitch.obj cdjpeg.obj -DOBJECTS= djpeg.obj wrppm.obj wrgif.obj wrtarga.obj wrrle.obj wrbmp.obj & - rdcolmap.obj cdjpeg.obj -TROBJECTS= jpegtran.obj rdswitch.obj cdjpeg.obj transupp.obj - - -all: libjpeg.lib cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe - -libjpeg.lib: $(LIBOBJECTS) - - del libjpeg.lib - * wlib -n libjpeg.lib $(LIBOBJECTS) - -cjpeg.exe: $(COBJECTS) libjpeg.lib - $(CC) $(LDFLAGS) $(COBJECTS) libjpeg.lib - -djpeg.exe: $(DOBJECTS) libjpeg.lib - $(CC) $(LDFLAGS) $(DOBJECTS) libjpeg.lib - -jpegtran.exe: $(TROBJECTS) libjpeg.lib - $(CC) $(LDFLAGS) $(TROBJECTS) libjpeg.lib - -rdjpgcom.exe: rdjpgcom.c - $(CC) $(CFLAGS) $(LDFLAGS) rdjpgcom.c - -wrjpgcom.exe: wrjpgcom.c - $(CC) $(CFLAGS) $(LDFLAGS) wrjpgcom.c - -.c.obj: - $(CC) $(CFLAGS) -c $< - -jconfig.h: jconfig.doc - echo You must prepare a system-dependent jconfig.h file. - echo Please read the installation directions in install.doc. - exit 1 - -clean: .SYMBOLIC - - del *.obj - - del libjpeg.lib - - del cjpeg.exe - - del djpeg.exe - - del jpegtran.exe - - del rdjpgcom.exe - - del wrjpgcom.exe - - del testout*.* - -test: cjpeg.exe djpeg.exe jpegtran.exe .SYMBOLIC - - del testout*.* - djpeg -dct int -ppm -outfile testout.ppm testorig.jpg - djpeg -dct int -bmp -colors 256 -outfile testout.bmp testorig.jpg - cjpeg -dct int -outfile testout.jpg testimg.ppm - djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg - cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm - jpegtran -outfile testoutt.jpg testprog.jpg -!ifeq SYSTEM DOS - fc /b testimg.ppm testout.ppm - fc /b testimg.bmp testout.bmp - fc /b testimg.jpg testout.jpg - fc /b testimg.ppm testoutp.ppm - fc /b testimgp.jpg testoutp.jpg - fc /b testorig.jpg testoutt.jpg -!else - echo n > n.tmp - comp testimg.ppm testout.ppm < n.tmp - comp testimg.bmp testout.bmp < n.tmp - comp testimg.jpg testout.jpg < n.tmp - comp testimg.ppm testoutp.ppm < n.tmp - comp testimgp.jpg testoutp.jpg < n.tmp - comp testorig.jpg testoutt.jpg < n.tmp - del n.tmp -!endif - - -jcapimin.obj: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcapistd.obj: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccoefct.obj: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jccolor.obj: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcdctmgr.obj: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jchuff.obj: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcinit.obj: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmainct.obj: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmarker.obj: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcmaster.obj: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcomapi.obj: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcparam.obj: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcphuff.obj: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h -jcprepct.obj: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jcsample.obj: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jctrans.obj: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapimin.obj: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdapistd.obj: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdatadst.obj: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdatasrc.obj: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h -jdcoefct.obj: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdcolor.obj: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jddctmgr.obj: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jdhuff.obj: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdinput.obj: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmainct.obj: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmarker.obj: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmaster.obj: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdmerge.obj: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdphuff.obj: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h -jdpostct.obj: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdsample.obj: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jdtrans.obj: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jerror.obj: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h -jfdctflt.obj: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctfst.obj: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jfdctint.obj: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctflt.obj: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctfst.obj: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctint.obj: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jidctred.obj: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h -jquant1.obj: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jquant2.obj: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jutils.obj: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h -jmemmgr.obj: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemansi.obj: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemname.obj: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemnobs.obj: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemdos.obj: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -jmemmac.obj: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h -cjpeg.obj: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -djpeg.obj: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h -jpegtran.obj: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h transupp.h jversion.h -rdjpgcom.obj: rdjpgcom.c jinclude.h jconfig.h -wrjpgcom.obj: wrjpgcom.c jinclude.h jconfig.h -cdjpeg.obj: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdcolmap.obj: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdswitch.obj: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -transupp.obj: transupp.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h transupp.h -rdppm.obj: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrppm.obj: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdgif.obj: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrgif.obj: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdtarga.obj: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrtarga.obj: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdbmp.obj: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrbmp.obj: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -rdrle.obj: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h -wrrle.obj: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/makelib.ds b/irrlicht-1.6/source/Irrlicht/jpeglib/makelib.ds deleted file mode 100644 index 78d0ddf0b..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/makelib.ds +++ /dev/null @@ -1,1046 +0,0 @@ -# Microsoft Developer Studio Generated NMAKE File, Format Version 4.20 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -!IF "$(CFG)" == "" -CFG=jpeg - Win32 -!MESSAGE No configuration specified. Defaulting to jpeg - Win32. -!ENDIF - -!IF "$(CFG)" != "jpeg - Win32" -!MESSAGE Invalid configuration "$(CFG)" specified. -!MESSAGE You can specify a configuration when running NMAKE on this makefile -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "jpeg.mak" CFG="jpeg - Win32" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "jpeg - Win32" (based on "Win32 (x86) Static Library") -!MESSAGE -!ERROR An invalid configuration is specified. -!ENDIF - -!IF "$(OS)" == "Windows_NT" -NULL= -!ELSE -NULL=nul -!ENDIF -################################################################################ -# Begin Project -# PROP Target_Last_Scanned "jpeg - Win32" -CPP=cl.exe - -!IF "$(CFG)" == "jpeg - Win32" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -OUTDIR=.\Release -INTDIR=.\Release - -ALL : "$(OUTDIR)\jpeg.lib" - -CLEAN : - -@erase "$(INTDIR)\jcapimin.obj" - -@erase "$(INTDIR)\jcapistd.obj" - -@erase "$(INTDIR)\jctrans.obj" - -@erase "$(INTDIR)\jcparam.obj" - -@erase "$(INTDIR)\jdatadst.obj" - -@erase "$(INTDIR)\jcinit.obj" - -@erase "$(INTDIR)\jcmaster.obj" - -@erase "$(INTDIR)\jcmarker.obj" - -@erase "$(INTDIR)\jcmainct.obj" - -@erase "$(INTDIR)\jcprepct.obj" - -@erase "$(INTDIR)\jccoefct.obj" - -@erase "$(INTDIR)\jccolor.obj" - -@erase "$(INTDIR)\jcsample.obj" - -@erase "$(INTDIR)\jchuff.obj" - -@erase "$(INTDIR)\jcphuff.obj" - -@erase "$(INTDIR)\jcdctmgr.obj" - -@erase "$(INTDIR)\jfdctfst.obj" - -@erase "$(INTDIR)\jfdctflt.obj" - -@erase "$(INTDIR)\jfdctint.obj" - -@erase "$(INTDIR)\jdapimin.obj" - -@erase "$(INTDIR)\jdapistd.obj" - -@erase "$(INTDIR)\jdtrans.obj" - -@erase "$(INTDIR)\jdatasrc.obj" - -@erase "$(INTDIR)\jdmaster.obj" - -@erase "$(INTDIR)\jdinput.obj" - -@erase "$(INTDIR)\jdmarker.obj" - -@erase "$(INTDIR)\jdhuff.obj" - -@erase "$(INTDIR)\jdphuff.obj" - -@erase "$(INTDIR)\jdmainct.obj" - -@erase "$(INTDIR)\jdcoefct.obj" - -@erase "$(INTDIR)\jdpostct.obj" - -@erase "$(INTDIR)\jddctmgr.obj" - -@erase "$(INTDIR)\jidctfst.obj" - -@erase "$(INTDIR)\jidctflt.obj" - -@erase "$(INTDIR)\jidctint.obj" - -@erase "$(INTDIR)\jidctred.obj" - -@erase "$(INTDIR)\jdsample.obj" - -@erase "$(INTDIR)\jdcolor.obj" - -@erase "$(INTDIR)\jquant1.obj" - -@erase "$(INTDIR)\jquant2.obj" - -@erase "$(INTDIR)\jdmerge.obj" - -@erase "$(INTDIR)\jcomapi.obj" - -@erase "$(INTDIR)\jutils.obj" - -@erase "$(INTDIR)\jerror.obj" - -@erase "$(INTDIR)\jmemmgr.obj" - -@erase "$(INTDIR)\jmemnobs.obj" - -@erase "$(OUTDIR)\jpeg.lib" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c -CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS"\ - /Fp"$(INTDIR)/jpeg.pch" /YX /Fo"$(INTDIR)/" /c -CPP_OBJS=.\Release/ -CPP_SBRS=.\. -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -BSC32_FLAGS=/nologo /o"$(OUTDIR)/jpeg.bsc" -BSC32_SBRS= \ - -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo -LIB32_FLAGS=/nologo /out:"$(OUTDIR)/jpeg.lib" -LIB32_OBJS= \ - "$(INTDIR)\jcapimin.obj" \ - "$(INTDIR)\jcapistd.obj" \ - "$(INTDIR)\jctrans.obj" \ - "$(INTDIR)\jcparam.obj" \ - "$(INTDIR)\jdatadst.obj" \ - "$(INTDIR)\jcinit.obj" \ - "$(INTDIR)\jcmaster.obj" \ - "$(INTDIR)\jcmarker.obj" \ - "$(INTDIR)\jcmainct.obj" \ - "$(INTDIR)\jcprepct.obj" \ - "$(INTDIR)\jccoefct.obj" \ - "$(INTDIR)\jccolor.obj" \ - "$(INTDIR)\jcsample.obj" \ - "$(INTDIR)\jchuff.obj" \ - "$(INTDIR)\jcphuff.obj" \ - "$(INTDIR)\jcdctmgr.obj" \ - "$(INTDIR)\jfdctfst.obj" \ - "$(INTDIR)\jfdctflt.obj" \ - "$(INTDIR)\jfdctint.obj" \ - "$(INTDIR)\jdapimin.obj" \ - "$(INTDIR)\jdapistd.obj" \ - "$(INTDIR)\jdtrans.obj" \ - "$(INTDIR)\jdatasrc.obj" \ - "$(INTDIR)\jdmaster.obj" \ - "$(INTDIR)\jdinput.obj" \ - "$(INTDIR)\jdmarker.obj" \ - "$(INTDIR)\jdhuff.obj" \ - "$(INTDIR)\jdphuff.obj" \ - "$(INTDIR)\jdmainct.obj" \ - "$(INTDIR)\jdcoefct.obj" \ - "$(INTDIR)\jdpostct.obj" \ - "$(INTDIR)\jddctmgr.obj" \ - "$(INTDIR)\jidctfst.obj" \ - "$(INTDIR)\jidctflt.obj" \ - "$(INTDIR)\jidctint.obj" \ - "$(INTDIR)\jidctred.obj" \ - "$(INTDIR)\jdsample.obj" \ - "$(INTDIR)\jdcolor.obj" \ - "$(INTDIR)\jquant1.obj" \ - "$(INTDIR)\jquant2.obj" \ - "$(INTDIR)\jdmerge.obj" \ - "$(INTDIR)\jcomapi.obj" \ - "$(INTDIR)\jutils.obj" \ - "$(INTDIR)\jerror.obj" \ - "$(INTDIR)\jmemmgr.obj" \ - "$(INTDIR)\jmemnobs.obj" - -"$(OUTDIR)\jpeg.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS) - $(LIB32) @<< - $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS) -<< - -!ENDIF - -.c{$(CPP_OBJS)}.obj: - $(CPP) $(CPP_PROJ) $< - -.cpp{$(CPP_OBJS)}.obj: - $(CPP) $(CPP_PROJ) $< - -.cxx{$(CPP_OBJS)}.obj: - $(CPP) $(CPP_PROJ) $< - -.c{$(CPP_SBRS)}.sbr: - $(CPP) $(CPP_PROJ) $< - -.cpp{$(CPP_SBRS)}.sbr: - $(CPP) $(CPP_PROJ) $< - -.cxx{$(CPP_SBRS)}.sbr: - $(CPP) $(CPP_PROJ) $< - -################################################################################ -# Begin Target - -# Name "jpeg - Win32" - -!IF "$(CFG)" == "jpeg - Win32" - -!ENDIF - -################################################################################ -# Begin Source File - -SOURCE="jcapimin.c" -DEP_CPP_JCAPI=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jcapimin.obj" : $(SOURCE) $(DEP_CPP_JCAPI) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jcapistd.c" -DEP_CPP_JCAPIS=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jcapistd.obj" : $(SOURCE) $(DEP_CPP_JCAPIS) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jccoefct.c" -DEP_CPP_JCCOE=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jccoefct.obj" : $(SOURCE) $(DEP_CPP_JCCOE) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jccolor.c" -DEP_CPP_JCCOL=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jccolor.obj" : $(SOURCE) $(DEP_CPP_JCCOL) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jcdctmgr.c" -DEP_CPP_JCDCT=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - "jdct.h"\ - - -"$(INTDIR)\jcdctmgr.obj" : $(SOURCE) $(DEP_CPP_JCDCT) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jchuff.c" -DEP_CPP_JCHUF=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - "jchuff.h"\ - - -"$(INTDIR)\jchuff.obj" : $(SOURCE) $(DEP_CPP_JCHUF) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jcinit.c" -DEP_CPP_JCINI=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jcinit.obj" : $(SOURCE) $(DEP_CPP_JCINI) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jcmainct.c" -DEP_CPP_JCMAI=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jcmainct.obj" : $(SOURCE) $(DEP_CPP_JCMAI) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jcmarker.c" -DEP_CPP_JCMAR=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jcmarker.obj" : $(SOURCE) $(DEP_CPP_JCMAR) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jcmaster.c" -DEP_CPP_JCMAS=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jcmaster.obj" : $(SOURCE) $(DEP_CPP_JCMAS) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jcomapi.c" -DEP_CPP_JCOMA=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jcomapi.obj" : $(SOURCE) $(DEP_CPP_JCOMA) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jcparam.c" -DEP_CPP_JCPAR=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jcparam.obj" : $(SOURCE) $(DEP_CPP_JCPAR) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jcphuff.c" -DEP_CPP_JCPHU=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - "jchuff.h"\ - - -"$(INTDIR)\jcphuff.obj" : $(SOURCE) $(DEP_CPP_JCPHU) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jcprepct.c" -DEP_CPP_JCPRE=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jcprepct.obj" : $(SOURCE) $(DEP_CPP_JCPRE) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jcsample.c" -DEP_CPP_JCSAM=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jcsample.obj" : $(SOURCE) $(DEP_CPP_JCSAM) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jctrans.c" -DEP_CPP_JCTRA=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jctrans.obj" : $(SOURCE) $(DEP_CPP_JCTRA) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jdapimin.c" -DEP_CPP_JDAPI=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jdapimin.obj" : $(SOURCE) $(DEP_CPP_JDAPI) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jdapistd.c" -DEP_CPP_JDAPIS=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jdapistd.obj" : $(SOURCE) $(DEP_CPP_JDAPIS) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jdatadst.c" -DEP_CPP_JDATA=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - - -"$(INTDIR)\jdatadst.obj" : $(SOURCE) $(DEP_CPP_JDATA) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jdatasrc.c" -DEP_CPP_JDATAS=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jerror.h"\ - - -"$(INTDIR)\jdatasrc.obj" : $(SOURCE) $(DEP_CPP_JDATAS) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jdcoefct.c" -DEP_CPP_JDCOE=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jdcoefct.obj" : $(SOURCE) $(DEP_CPP_JDCOE) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jdcolor.c" -DEP_CPP_JDCOL=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jdcolor.obj" : $(SOURCE) $(DEP_CPP_JDCOL) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jddctmgr.c" -DEP_CPP_JDDCT=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - "jdct.h"\ - - -"$(INTDIR)\jddctmgr.obj" : $(SOURCE) $(DEP_CPP_JDDCT) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jdhuff.c" -DEP_CPP_JDHUF=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - "jdhuff.h"\ - - -"$(INTDIR)\jdhuff.obj" : $(SOURCE) $(DEP_CPP_JDHUF) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jdinput.c" -DEP_CPP_JDINP=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jdinput.obj" : $(SOURCE) $(DEP_CPP_JDINP) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jdmainct.c" -DEP_CPP_JDMAI=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jdmainct.obj" : $(SOURCE) $(DEP_CPP_JDMAI) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jdmarker.c" -DEP_CPP_JDMAR=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jdmarker.obj" : $(SOURCE) $(DEP_CPP_JDMAR) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jdmaster.c" -DEP_CPP_JDMAS=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jdmaster.obj" : $(SOURCE) $(DEP_CPP_JDMAS) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jdmerge.c" -DEP_CPP_JDMER=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jdmerge.obj" : $(SOURCE) $(DEP_CPP_JDMER) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jdphuff.c" -DEP_CPP_JDPHU=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - "jdhuff.h"\ - - -"$(INTDIR)\jdphuff.obj" : $(SOURCE) $(DEP_CPP_JDPHU) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jdpostct.c" -DEP_CPP_JDPOS=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jdpostct.obj" : $(SOURCE) $(DEP_CPP_JDPOS) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jdsample.c" -DEP_CPP_JDSAM=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jdsample.obj" : $(SOURCE) $(DEP_CPP_JDSAM) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jdtrans.c" -DEP_CPP_JDTRA=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jdtrans.obj" : $(SOURCE) $(DEP_CPP_JDTRA) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jerror.c" -DEP_CPP_JERRO=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jversion.h"\ - "jerror.h"\ - - -"$(INTDIR)\jerror.obj" : $(SOURCE) $(DEP_CPP_JERRO) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jfdctflt.c" -DEP_CPP_JFDCT=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - "jdct.h"\ - - -"$(INTDIR)\jfdctflt.obj" : $(SOURCE) $(DEP_CPP_JFDCT) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jfdctfst.c" -DEP_CPP_JFDCTF=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - "jdct.h"\ - - -"$(INTDIR)\jfdctfst.obj" : $(SOURCE) $(DEP_CPP_JFDCTF) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jfdctint.c" -DEP_CPP_JFDCTI=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - "jdct.h"\ - - -"$(INTDIR)\jfdctint.obj" : $(SOURCE) $(DEP_CPP_JFDCTI) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jidctflt.c" -DEP_CPP_JIDCT=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - "jdct.h"\ - - -"$(INTDIR)\jidctflt.obj" : $(SOURCE) $(DEP_CPP_JIDCT) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jidctfst.c" -DEP_CPP_JIDCTF=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - "jdct.h"\ - - -"$(INTDIR)\jidctfst.obj" : $(SOURCE) $(DEP_CPP_JIDCTF) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jidctint.c" -DEP_CPP_JIDCTI=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - "jdct.h"\ - - -"$(INTDIR)\jidctint.obj" : $(SOURCE) $(DEP_CPP_JIDCTI) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jidctred.c" -DEP_CPP_JIDCTR=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - "jdct.h"\ - - -"$(INTDIR)\jidctred.obj" : $(SOURCE) $(DEP_CPP_JIDCTR) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jquant1.c" -DEP_CPP_JQUAN=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jquant1.obj" : $(SOURCE) $(DEP_CPP_JQUAN) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jquant2.c" -DEP_CPP_JQUANT=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jquant2.obj" : $(SOURCE) $(DEP_CPP_JQUANT) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jutils.c" -DEP_CPP_JUTIL=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - - -"$(INTDIR)\jutils.obj" : $(SOURCE) $(DEP_CPP_JUTIL) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jmemmgr.c" -DEP_CPP_JMEMM=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - "jmemsys.h"\ - - -"$(INTDIR)\jmemmgr.obj" : $(SOURCE) $(DEP_CPP_JMEMM) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -################################################################################ -# Begin Source File - -SOURCE="jmemnobs.c" -DEP_CPP_JMEMN=\ - "jinclude.h"\ - "jconfig.h"\ - "jpeglib.h"\ - "jmorecfg.h"\ - "jpegint.h"\ - "jerror.h"\ - "jmemsys.h"\ - - -"$(INTDIR)\jmemnobs.obj" : $(SOURCE) $(DEP_CPP_JMEMN) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -# End Source File -# End Target -# End Project -################################################################################ - diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/makeproj.mac b/irrlicht-1.6/source/Irrlicht/jpeglib/makeproj.mac deleted file mode 100644 index cd466da5c..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/makeproj.mac +++ /dev/null @@ -1,213 +0,0 @@ --- --- makeproj.mac --- --- This AppleScript builds Code Warrior PRO Release 2 project files for the --- libjpeg library as well as the test programs 'cjpeg', 'djpeg', 'jpegtran'. --- (We'd distribute real project files, except they're not text --- and would create maintenance headaches.) --- --- The script then compiles and links the library and the test programs. --- NOTE: if you haven't already created a 'jconfig.h' file, the script --- automatically copies 'jconfig.mac' to 'jconfig.h'. --- --- To use this script, you must have AppleScript 1.1 or later installed --- and a suitable AppleScript editor like Script Editor or Script Debugger --- (http://www.latenightsw.com). Open this file with your AppleScript --- editor and execute the "run" command to build the projects. --- --- Thanks to Dan Sears and Don Agro for this script. --- Questions about this script can be addressed to dogpark@interlog.com --- - -on run - - choose folder with prompt ">>> Select IJG source folder <<<" - set ijg_folder to result - - choose folder with prompt ">>> Select MetroWerks folder <<<" - set cw_folder to result - - -- if jconfig.h doesn't already exist, copy jconfig.mac - - tell application "Finder" - if not (exists file "jconfig.h" of ijg_folder) then - duplicate {file "jconfig.mac" of folder ijg_folder} - select file "jconfig.mac copy" of folder ijg_folder - set name of selection to "jconfig.h" - end if - end tell - - tell application "CodeWarrior IDE 2.1" - with timeout of 10000 seconds - - -- create libjpeg project - - activate - Create Project (ijg_folder as string) & "libjpeg.proj" - Set Preferences of panel "Target Settings" to {Target Name:"libjpeg"} - Set Preferences of panel "PPC Project" to {File Name:"libjpeg"} - Set Preferences of panel "Target Settings" to {Linker:"MacOS PPC Linker"} - Set Preferences of panel "PPC Project" to {Project Type:library} - Set Preferences of panel "C/C++ Compiler" to {ANSI Strict:true} - Set Preferences of panel "C/C++ Compiler" to {Enums Always Ints:true} - Set Preferences of panel "PPC Codegen" to {Struct Alignment:PowerPC} - Set Preferences of panel "PPC Linker" to {Generate SYM File:false} - - Add Files (ijg_folder as string) & "jcapimin.c" To Segment 1 - Add Files (ijg_folder as string) & "jcapistd.c" To Segment 1 - Add Files (ijg_folder as string) & "jctrans.c" To Segment 1 - Add Files (ijg_folder as string) & "jcparam.c" To Segment 1 - Add Files (ijg_folder as string) & "jdatadst.c" To Segment 1 - Add Files (ijg_folder as string) & "jcinit.c" To Segment 1 - Add Files (ijg_folder as string) & "jcmaster.c" To Segment 1 - Add Files (ijg_folder as string) & "jcmarker.c" To Segment 1 - Add Files (ijg_folder as string) & "jcmainct.c" To Segment 1 - Add Files (ijg_folder as string) & "jcprepct.c" To Segment 1 - Add Files (ijg_folder as string) & "jccoefct.c" To Segment 1 - Add Files (ijg_folder as string) & "jccolor.c" To Segment 1 - Add Files (ijg_folder as string) & "jcsample.c" To Segment 1 - Add Files (ijg_folder as string) & "jchuff.c" To Segment 1 - Add Files (ijg_folder as string) & "jcphuff.c" To Segment 1 - Add Files (ijg_folder as string) & "jcdctmgr.c" To Segment 1 - Add Files (ijg_folder as string) & "jfdctfst.c" To Segment 1 - Add Files (ijg_folder as string) & "jfdctflt.c" To Segment 1 - Add Files (ijg_folder as string) & "jfdctint.c" To Segment 1 - Add Files (ijg_folder as string) & "jdapimin.c" To Segment 1 - Add Files (ijg_folder as string) & "jdapistd.c" To Segment 1 - Add Files (ijg_folder as string) & "jdtrans.c" To Segment 1 - Add Files (ijg_folder as string) & "jdatasrc.c" To Segment 1 - Add Files (ijg_folder as string) & "jdmaster.c" To Segment 1 - Add Files (ijg_folder as string) & "jdinput.c" To Segment 1 - Add Files (ijg_folder as string) & "jdmarker.c" To Segment 1 - Add Files (ijg_folder as string) & "jdhuff.c" To Segment 1 - Add Files (ijg_folder as string) & "jdphuff.c" To Segment 1 - Add Files (ijg_folder as string) & "jdmainct.c" To Segment 1 - Add Files (ijg_folder as string) & "jdcoefct.c" To Segment 1 - Add Files (ijg_folder as string) & "jdpostct.c" To Segment 1 - Add Files (ijg_folder as string) & "jddctmgr.c" To Segment 1 - Add Files (ijg_folder as string) & "jidctfst.c" To Segment 1 - Add Files (ijg_folder as string) & "jidctflt.c" To Segment 1 - Add Files (ijg_folder as string) & "jidctint.c" To Segment 1 - Add Files (ijg_folder as string) & "jidctred.c" To Segment 1 - Add Files (ijg_folder as string) & "jdsample.c" To Segment 1 - Add Files (ijg_folder as string) & "jdcolor.c" To Segment 1 - Add Files (ijg_folder as string) & "jquant1.c" To Segment 1 - Add Files (ijg_folder as string) & "jquant2.c" To Segment 1 - Add Files (ijg_folder as string) & "jdmerge.c" To Segment 1 - Add Files (ijg_folder as string) & "jcomapi.c" To Segment 1 - Add Files (ijg_folder as string) & "jutils.c" To Segment 1 - Add Files (ijg_folder as string) & "jerror.c" To Segment 1 - Add Files (ijg_folder as string) & "jmemmgr.c" To Segment 1 - Add Files (ijg_folder as string) & "jmemmac.c" To Segment 1 - - -- compile and link the library - - Make Project - Close Project - - -- create cjpeg project - - activate - Create Project (ijg_folder as string) & "cjpeg.proj" - Set Preferences of panel "Target Settings" to {Target Name:"cjpeg"} - Set Preferences of panel "PPC Project" to {File Name:"cjpeg"} - Set Preferences of panel "Target Settings" to {Linker:"MacOS PPC Linker"} - Set Preferences of panel "C/C++ Compiler" to {ANSI Strict:true} - Set Preferences of panel "C/C++ Compiler" to {Enums Always Ints:true} - Set Preferences of panel "PPC Codegen" to {Struct Alignment:PowerPC} - Set Preferences of panel "PPC Linker" to {Generate SYM File:false} - - Add Files (ijg_folder as string) & "cjpeg.c" To Segment 1 - Add Files (ijg_folder as string) & "rdppm.c" To Segment 1 - Add Files (ijg_folder as string) & "rdgif.c" To Segment 1 - Add Files (ijg_folder as string) & "rdtarga.c" To Segment 1 - Add Files (ijg_folder as string) & "rdrle.c" To Segment 1 - Add Files (ijg_folder as string) & "rdbmp.c" To Segment 1 - Add Files (ijg_folder as string) & "rdswitch.c" To Segment 1 - Add Files (ijg_folder as string) & "cdjpeg.c" To Segment 1 - - Add Files (ijg_folder as string) & "libjpeg" To Segment 2 - - Add Files (cw_folder as string) & "Metrowerks CodeWarrior:Metrowerks Standard Library:MSL C:Bin:MSL C.PPC.Lib" To Segment 3 - Add Files (cw_folder as string) & "Metrowerks CodeWarrior:Metrowerks Standard Library:MSL C:Bin:MSL SIOUX.PPC.Lib" To Segment 3 - Add Files (cw_folder as string) & "Metrowerks CodeWarrior:MacOS Support:Libraries:Runtime:Runtime PPC:MSL RuntimePPC.Lib" To Segment 3 - - Add Files (cw_folder as string) & "Metrowerks CodeWarrior:MacOS Support:Libraries:MacOS Common:InterfaceLib" To Segment 4 - Add Files (cw_folder as string) & "Metrowerks CodeWarrior:MacOS Support:Libraries:MacOS Common:MathLib" To Segment 4 - - -- compile and link cjpeg - - Make Project - Close Project - - -- create djpeg project - - activate - Create Project (ijg_folder as string) & "djpeg.proj" - Set Preferences of panel "Target Settings" to {Target Name:"djpeg"} - Set Preferences of panel "PPC Project" to {File Name:"djpeg"} - Set Preferences of panel "Target Settings" to {Linker:"MacOS PPC Linker"} - Set Preferences of panel "C/C++ Compiler" to {ANSI Strict:true} - Set Preferences of panel "C/C++ Compiler" to {Enums Always Ints:true} - Set Preferences of panel "PPC Codegen" to {Struct Alignment:PowerPC} - Set Preferences of panel "PPC Linker" to {Generate SYM File:false} - - Add Files (ijg_folder as string) & "djpeg.c" To Segment 1 - Add Files (ijg_folder as string) & "wrppm.c" To Segment 1 - Add Files (ijg_folder as string) & "wrgif.c" To Segment 1 - Add Files (ijg_folder as string) & "wrtarga.c" To Segment 1 - Add Files (ijg_folder as string) & "wrrle.c" To Segment 1 - Add Files (ijg_folder as string) & "wrbmp.c" To Segment 1 - Add Files (ijg_folder as string) & "rdcolmap.c" To Segment 1 - Add Files (ijg_folder as string) & "cdjpeg.c" To Segment 1 - - Add Files (ijg_folder as string) & "libjpeg" To Segment 2 - - Add Files (cw_folder as string) & "Metrowerks CodeWarrior:Metrowerks Standard Library:MSL C:Bin:MSL C.PPC.Lib" To Segment 3 - Add Files (cw_folder as string) & "Metrowerks CodeWarrior:Metrowerks Standard Library:MSL C:Bin:MSL SIOUX.PPC.Lib" To Segment 3 - Add Files (cw_folder as string) & "Metrowerks CodeWarrior:MacOS Support:Libraries:Runtime:Runtime PPC:MSL RuntimePPC.Lib" To Segment 3 - - Add Files (cw_folder as string) & "Metrowerks CodeWarrior:MacOS Support:Libraries:MacOS Common:InterfaceLib" To Segment 4 - Add Files (cw_folder as string) & "Metrowerks CodeWarrior:MacOS Support:Libraries:MacOS Common:MathLib" To Segment 4 - - -- compile and link djpeg - - Make Project - Close Project - - -- create jpegtran project - - activate - Create Project (ijg_folder as string) & "jpegtran.proj" - Set Preferences of panel "Target Settings" to {Target Name:"jpegtran"} - Set Preferences of panel "PPC Project" to {File Name:"jpegtran"} - Set Preferences of panel "Target Settings" to {Linker:"MacOS PPC Linker"} - Set Preferences of panel "C/C++ Compiler" to {ANSI Strict:true} - Set Preferences of panel "C/C++ Compiler" to {Enums Always Ints:true} - Set Preferences of panel "PPC Codegen" to {Struct Alignment:PowerPC} - Set Preferences of panel "PPC Linker" to {Generate SYM File:false} - - Add Files (ijg_folder as string) & "jpegtran.c" To Segment 1 - Add Files (ijg_folder as string) & "rdswitch.c" To Segment 1 - Add Files (ijg_folder as string) & "cdjpeg.c" To Segment 1 - Add Files (ijg_folder as string) & "transupp.c" To Segment 1 - - Add Files (ijg_folder as string) & "libjpeg" To Segment 2 - - Add Files (cw_folder as string) & "Metrowerks CodeWarrior:Metrowerks Standard Library:MSL C:Bin:MSL C.PPC.Lib" To Segment 3 - Add Files (cw_folder as string) & "Metrowerks CodeWarrior:Metrowerks Standard Library:MSL C:Bin:MSL SIOUX.PPC.Lib" To Segment 3 - Add Files (cw_folder as string) & "Metrowerks CodeWarrior:MacOS Support:Libraries:Runtime:Runtime PPC:MSL RuntimePPC.Lib" To Segment 3 - - Add Files (cw_folder as string) & "Metrowerks CodeWarrior:MacOS Support:Libraries:MacOS Common:InterfaceLib" To Segment 4 - Add Files (cw_folder as string) & "Metrowerks CodeWarrior:MacOS Support:Libraries:MacOS Common:MathLib" To Segment 4 - - -- compile and link jpegtran - - Make Project - Close Project - - quit - - end timeout - end tell -end run diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/makljpeg.st b/irrlicht-1.6/source/Irrlicht/jpeglib/makljpeg.st deleted file mode 100644 index 96bfb659f..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/makljpeg.st +++ /dev/null @@ -1,70 +0,0 @@ -; Project file for Independent JPEG Group's software -; -; This project file is for Atari ST/STE/TT systems using Pure C or Turbo C. -; Thanks to Frank Moehle (Frank.Moehle@arbi.informatik.uni-oldenburg.de), -; Dr. B. Setzepfandt (bernd@gina.uni-muenster.de), -; and Guido Vollbeding (guivol@esc.de). -; -; To use this file, rename it to libjpeg.prj. -; Read installation instructions before trying to make the program! -; -; -; * * * Output file * * * -libjpeg.lib -; -; * * * COMPILER OPTIONS * * * -.C[-P] ; absolute calls -.C[-M] ; and no string merging, folks -.C[-w-cln] ; no "constant is long" warnings -.C[-w-par] ; no "parameter xxxx unused" -.C[-w-rch] ; no "unreachable code" -.C[-wsig] ; warn if significant digits may be lost -.L[-J] ; link new Obj-format (so we get a library) -= -; * * * * List of modules * * * * -jcapimin.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jcapistd.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jccoefct.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jccolor.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jcdctmgr.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) -jchuff.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jchuff.h) -jcinit.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jcmainct.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jcmarker.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jcmaster.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jcomapi.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jcparam.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jcphuff.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jchuff.h) -jcprepct.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jcsample.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jctrans.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jdapimin.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jdapistd.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jdatadst.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h) -jdatasrc.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h) -jdcoefct.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jdcolor.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jddctmgr.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) -jdhuff.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdhuff.h) -jdinput.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jdmainct.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jdmarker.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jdmaster.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jdmerge.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jdphuff.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdhuff.h) -jdpostct.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jdsample.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jdtrans.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jerror.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jversion.h,jerror.h) -jfdctflt.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) -jfdctfst.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) -jfdctint.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) -jidctflt.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) -jidctfst.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) -jidctint.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) -jidctred.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jdct.h) -jquant1.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jquant2.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jutils.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h) -jmemmgr.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jmemsys.h) -jmemansi.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,jmemsys.h) diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/maktjpeg.st b/irrlicht-1.6/source/Irrlicht/jpeglib/maktjpeg.st deleted file mode 100644 index ced1951bc..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/maktjpeg.st +++ /dev/null @@ -1,32 +0,0 @@ -; Project file for Independent JPEG Group's software -; -; This project file is for Atari ST/STE/TT systems using Pure C or Turbo C. -; Thanks to Frank Moehle (Frank.Moehle@arbi.informatik.uni-oldenburg.de), -; Dr. B. Setzepfandt (bernd@gina.uni-muenster.de), -; and Guido Vollbeding (guivol@esc.de). -; -; To use this file, rename it to jpegtran.prj. -; If you are using Turbo C, change filenames beginning with "pc..." to "tc..." -; Read installation instructions before trying to make the program! -; -; -; * * * Output file * * * -jpegtran.ttp -; -; * * * COMPILER OPTIONS * * * -.C[-P] ; absolute calls -.C[-M] ; and no string merging, folks -.C[-w-cln] ; no "constant is long" warnings -.C[-w-par] ; no "parameter xxxx unused" -.C[-w-rch] ; no "unreachable code" -.C[-wsig] ; warn if significant digits may be lost -= -; * * * * List of modules * * * * -pcstart.o -jpegtran.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h,transupp.h,jversion.h) -cdjpeg.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) -rdswitch.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) -transupp.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,transupp.h) -libjpeg.lib ; built by libjpeg.prj -pcstdlib.lib ; standard library -pcextlib.lib ; extended library diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/makvms.opt b/irrlicht-1.6/source/Irrlicht/jpeglib/makvms.opt deleted file mode 100644 index 26db71422..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/makvms.opt +++ /dev/null @@ -1,4 +0,0 @@ -! A pointer to the VAX/VMS C Run-Time Shareable Library. -! This file is needed by makefile.mms and makefile.vms, -! but only for the older VAX C compiler. DEC C does not need it. -Sys$Library:VAXCRTL.EXE /Share diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/rdbmp.c b/irrlicht-1.6/source/Irrlicht/jpeglib/rdbmp.c deleted file mode 100644 index 4f61bcf73..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/rdbmp.c +++ /dev/null @@ -1,439 +0,0 @@ -/* - * rdbmp.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to read input images in Microsoft "BMP" - * format (MS Windows 3.x, OS/2 1.x, and OS/2 2.x flavors). - * Currently, only 8-bit and 24-bit images are supported, not 1-bit or - * 4-bit (feeding such low-depth images into JPEG would be silly anyway). - * Also, we don't support RLE-compressed files. - * - * These routines may need modification for non-Unix environments or - * specialized applications. As they stand, they assume input from - * an ordinary stdio stream. They further assume that reading begins - * at the start of the file; start_input may need work if the - * user interface has already read some data (e.g., to determine that - * the file is indeed BMP format). - * - * This code contributed by James Arthur Boucher. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef BMP_SUPPORTED - - -/* Macros to deal with unsigned chars as efficiently as compiler allows */ - -#ifdef HAVE_UNSIGNED_CHAR -typedef unsigned char U_CHAR; -#define UCH(x) ((int) (x)) -#else /* !HAVE_UNSIGNED_CHAR */ -#ifdef CHAR_IS_UNSIGNED -typedef char U_CHAR; -#define UCH(x) ((int) (x)) -#else -typedef char U_CHAR; -#define UCH(x) ((int) (x) & 0xFF) -#endif -#endif /* HAVE_UNSIGNED_CHAR */ - - -#define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len))) - - -/* Private version of data source object */ - -typedef struct _bmp_source_struct * bmp_source_ptr; - -typedef struct _bmp_source_struct { - struct cjpeg_source_struct pub; /* public fields */ - - j_compress_ptr cinfo; /* back link saves passing separate parm */ - - JSAMPARRAY colormap; /* BMP colormap (converted to my format) */ - - jvirt_sarray_ptr whole_image; /* Needed to reverse row order */ - JDIMENSION source_row; /* Current source row number */ - JDIMENSION row_width; /* Physical width of scanlines in file */ - - int bits_per_pixel; /* remembers 8- or 24-bit format */ -} bmp_source_struct; - - -LOCAL(int) -read_byte (bmp_source_ptr sinfo) -/* Read next byte from BMP file */ -{ - register FILE *infile = sinfo->pub.input_file; - register int c; - - if ((c = getc(infile)) == EOF) - ERREXIT(sinfo->cinfo, JERR_INPUT_EOF); - return c; -} - - -LOCAL(void) -read_colormap (bmp_source_ptr sinfo, int cmaplen, int mapentrysize) -/* Read the colormap from a BMP file */ -{ - int i; - - switch (mapentrysize) { - case 3: - /* BGR format (occurs in OS/2 files) */ - for (i = 0; i < cmaplen; i++) { - sinfo->colormap[2][i] = (JSAMPLE) read_byte(sinfo); - sinfo->colormap[1][i] = (JSAMPLE) read_byte(sinfo); - sinfo->colormap[0][i] = (JSAMPLE) read_byte(sinfo); - } - break; - case 4: - /* BGR0 format (occurs in MS Windows files) */ - for (i = 0; i < cmaplen; i++) { - sinfo->colormap[2][i] = (JSAMPLE) read_byte(sinfo); - sinfo->colormap[1][i] = (JSAMPLE) read_byte(sinfo); - sinfo->colormap[0][i] = (JSAMPLE) read_byte(sinfo); - (void) read_byte(sinfo); - } - break; - default: - ERREXIT(sinfo->cinfo, JERR_BMP_BADCMAP); - break; - } -} - - -/* - * Read one row of pixels. - * The image has been read into the whole_image array, but is otherwise - * unprocessed. We must read it out in top-to-bottom row order, and if - * it is an 8-bit image, we must expand colormapped pixels to 24bit format. - */ - -METHODDEF(JDIMENSION) -get_8bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading 8-bit colormap indexes */ -{ - bmp_source_ptr source = (bmp_source_ptr) sinfo; - register JSAMPARRAY colormap = source->colormap; - JSAMPARRAY image_ptr; - register int t; - register JSAMPROW inptr, outptr; - register JDIMENSION col; - - /* Fetch next row from virtual array */ - source->source_row--; - image_ptr = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, source->whole_image, - source->source_row, (JDIMENSION) 1, FALSE); - - /* Expand the colormap indexes to real data */ - inptr = image_ptr[0]; - outptr = source->pub.buffer[0]; - for (col = cinfo->image_width; col > 0; col--) { - t = GETJSAMPLE(*inptr++); - *outptr++ = colormap[0][t]; /* can omit GETJSAMPLE() safely */ - *outptr++ = colormap[1][t]; - *outptr++ = colormap[2][t]; - } - - return 1; -} - - -METHODDEF(JDIMENSION) -get_24bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading 24-bit pixels */ -{ - bmp_source_ptr source = (bmp_source_ptr) sinfo; - JSAMPARRAY image_ptr; - register JSAMPROW inptr, outptr; - register JDIMENSION col; - - /* Fetch next row from virtual array */ - source->source_row--; - image_ptr = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, source->whole_image, - source->source_row, (JDIMENSION) 1, FALSE); - - /* Transfer data. Note source values are in BGR order - * (even though Microsoft's own documents say the opposite). - */ - inptr = image_ptr[0]; - outptr = source->pub.buffer[0]; - for (col = cinfo->image_width; col > 0; col--) { - outptr[2] = *inptr++; /* can omit GETJSAMPLE() safely */ - outptr[1] = *inptr++; - outptr[0] = *inptr++; - outptr += 3; - } - - return 1; -} - - -/* - * This method loads the image into whole_image during the first call on - * get_pixel_rows. The get_pixel_rows pointer is then adjusted to call - * get_8bit_row or get_24bit_row on subsequent calls. - */ - -METHODDEF(JDIMENSION) -preload_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - bmp_source_ptr source = (bmp_source_ptr) sinfo; - register FILE *infile = source->pub.input_file; - register int c; - register JSAMPROW out_ptr; - JSAMPARRAY image_ptr; - JDIMENSION row, col; - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; - - /* Read the data into a virtual array in input-file row order. */ - for (row = 0; row < cinfo->image_height; row++) { - if (progress != NULL) { - progress->pub.pass_counter = (long) row; - progress->pub.pass_limit = (long) cinfo->image_height; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } - image_ptr = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, source->whole_image, - row, (JDIMENSION) 1, TRUE); - out_ptr = image_ptr[0]; - for (col = source->row_width; col > 0; col--) { - /* inline copy of read_byte() for speed */ - if ((c = getc(infile)) == EOF) - ERREXIT(cinfo, JERR_INPUT_EOF); - *out_ptr++ = (JSAMPLE) c; - } - } - if (progress != NULL) - progress->completed_extra_passes++; - - /* Set up to read from the virtual array in top-to-bottom order */ - switch (source->bits_per_pixel) { - case 8: - source->pub.get_pixel_rows = get_8bit_row; - break; - case 24: - source->pub.get_pixel_rows = get_24bit_row; - break; - default: - ERREXIT(cinfo, JERR_BMP_BADDEPTH); - } - source->source_row = cinfo->image_height; - - /* And read the first row */ - return (*source->pub.get_pixel_rows) (cinfo, sinfo); -} - - -/* - * Read the file header; return image size and component count. - */ - -METHODDEF(void) -start_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - bmp_source_ptr source = (bmp_source_ptr) sinfo; - U_CHAR bmpfileheader[14]; - U_CHAR bmpinfoheader[64]; -#define GET_2B(array,offset) ((unsigned int) UCH(array[offset]) + \ - (((unsigned int) UCH(array[offset+1])) << 8)) -#define GET_4B(array,offset) ((INT32) UCH(array[offset]) + \ - (((INT32) UCH(array[offset+1])) << 8) + \ - (((INT32) UCH(array[offset+2])) << 16) + \ - (((INT32) UCH(array[offset+3])) << 24)) - INT32 bfOffBits; - INT32 headerSize; - INT32 biWidth = 0; /* initialize to avoid compiler warning */ - INT32 biHeight = 0; - unsigned int biPlanes; - INT32 biCompression; - INT32 biXPelsPerMeter,biYPelsPerMeter; - INT32 biClrUsed = 0; - int mapentrysize = 0; /* 0 indicates no colormap */ - INT32 bPad; - JDIMENSION row_width; - - /* Read and verify the bitmap file header */ - if (! ReadOK(source->pub.input_file, bmpfileheader, 14)) - ERREXIT(cinfo, JERR_INPUT_EOF); - if (GET_2B(bmpfileheader,0) != 0x4D42) /* 'BM' */ - ERREXIT(cinfo, JERR_BMP_NOT); - bfOffBits = (INT32) GET_4B(bmpfileheader,10); - /* We ignore the remaining fileheader fields */ - - /* The infoheader might be 12 bytes (OS/2 1.x), 40 bytes (Windows), - * or 64 bytes (OS/2 2.x). Check the first 4 bytes to find out which. - */ - if (! ReadOK(source->pub.input_file, bmpinfoheader, 4)) - ERREXIT(cinfo, JERR_INPUT_EOF); - headerSize = (INT32) GET_4B(bmpinfoheader,0); - if (headerSize < 12 || headerSize > 64) - ERREXIT(cinfo, JERR_BMP_BADHEADER); - if (! ReadOK(source->pub.input_file, bmpinfoheader+4, headerSize-4)) - ERREXIT(cinfo, JERR_INPUT_EOF); - - switch ((int) headerSize) { - case 12: - /* Decode OS/2 1.x header (Microsoft calls this a BITMAPCOREHEADER) */ - biWidth = (INT32) GET_2B(bmpinfoheader,4); - biHeight = (INT32) GET_2B(bmpinfoheader,6); - biPlanes = GET_2B(bmpinfoheader,8); - source->bits_per_pixel = (int) GET_2B(bmpinfoheader,10); - - switch (source->bits_per_pixel) { - case 8: /* colormapped image */ - mapentrysize = 3; /* OS/2 uses RGBTRIPLE colormap */ - TRACEMS2(cinfo, 1, JTRC_BMP_OS2_MAPPED, (int) biWidth, (int) biHeight); - break; - case 24: /* RGB image */ - TRACEMS2(cinfo, 1, JTRC_BMP_OS2, (int) biWidth, (int) biHeight); - break; - default: - ERREXIT(cinfo, JERR_BMP_BADDEPTH); - break; - } - if (biPlanes != 1) - ERREXIT(cinfo, JERR_BMP_BADPLANES); - break; - case 40: - case 64: - /* Decode Windows 3.x header (Microsoft calls this a BITMAPINFOHEADER) */ - /* or OS/2 2.x header, which has additional fields that we ignore */ - biWidth = GET_4B(bmpinfoheader,4); - biHeight = GET_4B(bmpinfoheader,8); - biPlanes = GET_2B(bmpinfoheader,12); - source->bits_per_pixel = (int) GET_2B(bmpinfoheader,14); - biCompression = GET_4B(bmpinfoheader,16); - biXPelsPerMeter = GET_4B(bmpinfoheader,24); - biYPelsPerMeter = GET_4B(bmpinfoheader,28); - biClrUsed = GET_4B(bmpinfoheader,32); - /* biSizeImage, biClrImportant fields are ignored */ - - switch (source->bits_per_pixel) { - case 8: /* colormapped image */ - mapentrysize = 4; /* Windows uses RGBQUAD colormap */ - TRACEMS2(cinfo, 1, JTRC_BMP_MAPPED, (int) biWidth, (int) biHeight); - break; - case 24: /* RGB image */ - TRACEMS2(cinfo, 1, JTRC_BMP, (int) biWidth, (int) biHeight); - break; - default: - ERREXIT(cinfo, JERR_BMP_BADDEPTH); - break; - } - if (biPlanes != 1) - ERREXIT(cinfo, JERR_BMP_BADPLANES); - if (biCompression != 0) - ERREXIT(cinfo, JERR_BMP_COMPRESSED); - - if (biXPelsPerMeter > 0 && biYPelsPerMeter > 0) { - /* Set JFIF density parameters from the BMP data */ - cinfo->X_density = (UINT16) (biXPelsPerMeter/100); /* 100 cm per meter */ - cinfo->Y_density = (UINT16) (biYPelsPerMeter/100); - cinfo->density_unit = 2; /* dots/cm */ - } - break; - default: - ERREXIT(cinfo, JERR_BMP_BADHEADER); - break; - } - - /* Compute distance to bitmap data --- will adjust for colormap below */ - bPad = bfOffBits - (headerSize + 14); - - /* Read the colormap, if any */ - if (mapentrysize > 0) { - if (biClrUsed <= 0) - biClrUsed = 256; /* assume it's 256 */ - else if (biClrUsed > 256) - ERREXIT(cinfo, JERR_BMP_BADCMAP); - /* Allocate space to store the colormap */ - source->colormap = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) biClrUsed, (JDIMENSION) 3); - /* and read it from the file */ - read_colormap(source, (int) biClrUsed, mapentrysize); - /* account for size of colormap */ - bPad -= biClrUsed * mapentrysize; - } - - /* Skip any remaining pad bytes */ - if (bPad < 0) /* incorrect bfOffBits value? */ - ERREXIT(cinfo, JERR_BMP_BADHEADER); - while (--bPad >= 0) { - (void) read_byte(source); - } - - /* Compute row width in file, including padding to 4-byte boundary */ - if (source->bits_per_pixel == 24) - row_width = (JDIMENSION) (biWidth * 3); - else - row_width = (JDIMENSION) biWidth; - while ((row_width & 3) != 0) row_width++; - source->row_width = row_width; - - /* Allocate space for inversion array, prepare for preload pass */ - source->whole_image = (*cinfo->mem->request_virt_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, - row_width, (JDIMENSION) biHeight, (JDIMENSION) 1); - source->pub.get_pixel_rows = preload_image; - if (cinfo->progress != NULL) { - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; - progress->total_extra_passes++; /* count file input as separate pass */ - } - - /* Allocate one-row buffer for returned data */ - source->pub.buffer = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) (biWidth * 3), (JDIMENSION) 1); - source->pub.buffer_height = 1; - - cinfo->in_color_space = JCS_RGB; - cinfo->input_components = 3; - cinfo->data_precision = 8; - cinfo->image_width = (JDIMENSION) biWidth; - cinfo->image_height = (JDIMENSION) biHeight; -} - - -/* - * Finish up at the end of the file. - */ - -METHODDEF(void) -finish_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - /* no work */ -} - - -/* - * The module selection routine for BMP format input. - */ - -GLOBAL(cjpeg_source_ptr) -jinit_read_bmp (j_compress_ptr cinfo) -{ - bmp_source_ptr source; - - /* Create module interface object */ - source = (bmp_source_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(bmp_source_struct)); - source->cinfo = cinfo; /* make back link for subroutines */ - /* Fill in method ptrs, except get_pixel_rows which start_input sets */ - source->pub.start_input = start_input_bmp; - source->pub.finish_input = finish_input_bmp; - - return (cjpeg_source_ptr) source; -} - -#endif /* BMP_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/rdcolmap.c b/irrlicht-1.6/source/Irrlicht/jpeglib/rdcolmap.c deleted file mode 100644 index eebf8346c..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/rdcolmap.c +++ /dev/null @@ -1,253 +0,0 @@ -/* - * rdcolmap.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file implements djpeg's "-map file" switch. It reads a source image - * and constructs a colormap to be supplied to the JPEG decompressor. - * - * Currently, these file formats are supported for the map file: - * GIF: the contents of the GIF's global colormap are used. - * PPM (either text or raw flavor): the entire file is read and - * each unique pixel value is entered in the map. - * Note that reading a large PPM file will be horrendously slow. - * Typically, a PPM-format map file should contain just one pixel - * of each desired color. Such a file can be extracted from an - * ordinary image PPM file with ppmtomap(1). - * - * Rescaling a PPM that has a maxval unequal to MAXJSAMPLE is not - * currently implemented. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef QUANT_2PASS_SUPPORTED /* otherwise can't quantize to supplied map */ - -/* Portions of this code are based on the PBMPLUS library, which is: -** -** Copyright (C) 1988 by Jef Poskanzer. -** -** Permission to use, copy, modify, and distribute this software and its -** documentation for any purpose and without fee is hereby granted, provided -** that the above copyright notice appear in all copies and that both that -** copyright notice and this permission notice appear in supporting -** documentation. This software is provided "as is" without express or -** implied warranty. -*/ - - -/* - * Add a (potentially) new color to the color map. - */ - -LOCAL(void) -add_map_entry (j_decompress_ptr cinfo, int R, int G, int B) -{ - JSAMPROW colormap0 = cinfo->colormap[0]; - JSAMPROW colormap1 = cinfo->colormap[1]; - JSAMPROW colormap2 = cinfo->colormap[2]; - int ncolors = cinfo->actual_number_of_colors; - int index; - - /* Check for duplicate color. */ - for (index = 0; index < ncolors; index++) { - if (GETJSAMPLE(colormap0[index]) == R && - GETJSAMPLE(colormap1[index]) == G && - GETJSAMPLE(colormap2[index]) == B) - return; /* color is already in map */ - } - - /* Check for map overflow. */ - if (ncolors >= (MAXJSAMPLE+1)) - ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, (MAXJSAMPLE+1)); - - /* OK, add color to map. */ - colormap0[ncolors] = (JSAMPLE) R; - colormap1[ncolors] = (JSAMPLE) G; - colormap2[ncolors] = (JSAMPLE) B; - cinfo->actual_number_of_colors++; -} - - -/* - * Extract color map from a GIF file. - */ - -LOCAL(void) -read_gif_map (j_decompress_ptr cinfo, FILE * infile) -{ - int header[13]; - int i, colormaplen; - int R, G, B; - - /* Initial 'G' has already been read by read_color_map */ - /* Read the rest of the GIF header and logical screen descriptor */ - for (i = 1; i < 13; i++) { - if ((header[i] = getc(infile)) == EOF) - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - } - - /* Verify GIF Header */ - if (header[1] != 'I' || header[2] != 'F') - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - - /* There must be a global color map. */ - if ((header[10] & 0x80) == 0) - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - - /* OK, fetch it. */ - colormaplen = 2 << (header[10] & 0x07); - - for (i = 0; i < colormaplen; i++) { - R = getc(infile); - G = getc(infile); - B = getc(infile); - if (R == EOF || G == EOF || B == EOF) - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - add_map_entry(cinfo, - R << (BITS_IN_JSAMPLE-8), - G << (BITS_IN_JSAMPLE-8), - B << (BITS_IN_JSAMPLE-8)); - } -} - - -/* Support routines for reading PPM */ - - -LOCAL(int) -pbm_getc (FILE * infile) -/* Read next char, skipping over any comments */ -/* A comment/newline sequence is returned as a newline */ -{ - register int ch; - - ch = getc(infile); - if (ch == '#') { - do { - ch = getc(infile); - } while (ch != '\n' && ch != EOF); - } - return ch; -} - - -LOCAL(unsigned int) -read_pbm_integer (j_decompress_ptr cinfo, FILE * infile) -/* Read an unsigned decimal integer from the PPM file */ -/* Swallows one trailing character after the integer */ -/* Note that on a 16-bit-int machine, only values up to 64k can be read. */ -/* This should not be a problem in practice. */ -{ - register int ch; - register unsigned int val; - - /* Skip any leading whitespace */ - do { - ch = pbm_getc(infile); - if (ch == EOF) - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - } while (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'); - - if (ch < '0' || ch > '9') - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - - val = ch - '0'; - while ((ch = pbm_getc(infile)) >= '0' && ch <= '9') { - val *= 10; - val += ch - '0'; - } - return val; -} - - -/* - * Extract color map from a PPM file. - */ - -LOCAL(void) -read_ppm_map (j_decompress_ptr cinfo, FILE * infile) -{ - int c; - unsigned int w, h, maxval, row, col; - int R, G, B; - - /* Initial 'P' has already been read by read_color_map */ - c = getc(infile); /* save format discriminator for a sec */ - - /* while we fetch the remaining header info */ - w = read_pbm_integer(cinfo, infile); - h = read_pbm_integer(cinfo, infile); - maxval = read_pbm_integer(cinfo, infile); - - if (w <= 0 || h <= 0 || maxval <= 0) /* error check */ - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - - /* For now, we don't support rescaling from an unusual maxval. */ - if (maxval != (unsigned int) MAXJSAMPLE) - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - - switch (c) { - case '3': /* it's a text-format PPM file */ - for (row = 0; row < h; row++) { - for (col = 0; col < w; col++) { - R = read_pbm_integer(cinfo, infile); - G = read_pbm_integer(cinfo, infile); - B = read_pbm_integer(cinfo, infile); - add_map_entry(cinfo, R, G, B); - } - } - break; - - case '6': /* it's a raw-format PPM file */ - for (row = 0; row < h; row++) { - for (col = 0; col < w; col++) { - R = getc(infile); - G = getc(infile); - B = getc(infile); - if (R == EOF || G == EOF || B == EOF) - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - add_map_entry(cinfo, R, G, B); - } - } - break; - - default: - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - break; - } -} - - -/* - * Main entry point from djpeg.c. - * Input: opened input file (from file name argument on command line). - * Output: colormap and actual_number_of_colors fields are set in cinfo. - */ - -GLOBAL(void) -read_color_map (j_decompress_ptr cinfo, FILE * infile) -{ - /* Allocate space for a color map of maximum supported size. */ - cinfo->colormap = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) (MAXJSAMPLE+1), (JDIMENSION) 3); - cinfo->actual_number_of_colors = 0; /* initialize map to empty */ - - /* Read first byte to determine file format */ - switch (getc(infile)) { - case 'G': - read_gif_map(cinfo, infile); - break; - case 'P': - read_ppm_map(cinfo, infile); - break; - default: - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - break; - } -} - -#endif /* QUANT_2PASS_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/rdgif.c b/irrlicht-1.6/source/Irrlicht/jpeglib/rdgif.c deleted file mode 100644 index b0757e718..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/rdgif.c +++ /dev/null @@ -1,38 +0,0 @@ -/* - * rdgif.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to read input images in GIF format. - * - ***************************************************************************** - * NOTE: to avoid entanglements with Unisys' patent on LZW compression, * - * the ability to read GIF files has been removed from the IJG distribution. * - * Sorry about that. * - ***************************************************************************** - * - * We are required to state that - * "The Graphics Interchange Format(c) is the Copyright property of - * CompuServe Incorporated. GIF(sm) is a Service Mark property of - * CompuServe Incorporated." - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef GIF_SUPPORTED - -/* - * The module selection routine for GIF format input. - */ - -GLOBAL(cjpeg_source_ptr) -jinit_read_gif (j_compress_ptr cinfo) -{ - fprintf(stderr, "GIF input is unsupported for legal reasons. Sorry.\n"); - exit(EXIT_FAILURE); - return NULL; /* keep compiler happy */ -} - -#endif /* GIF_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/rdjpgcom.1 b/irrlicht-1.6/source/Irrlicht/jpeglib/rdjpgcom.1 deleted file mode 100644 index dd837a8de..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/rdjpgcom.1 +++ /dev/null @@ -1,54 +0,0 @@ -.TH RDJPGCOM 1 "11 October 1997" -.SH NAME -rdjpgcom \- display text comments from a JPEG file -.SH SYNOPSIS -.B rdjpgcom -[ -.B \-verbose -] -[ -.I filename -] -.LP -.SH DESCRIPTION -.LP -.B rdjpgcom -reads the named JPEG/JFIF file, or the standard input if no file is named, -and prints any text comments found in the file on the standard output. -.PP -The JPEG standard allows "comment" (COM) blocks to occur within a JPEG file. -Although the standard doesn't actually define what COM blocks are for, they -are widely used to hold user-supplied text strings. This lets you add -annotations, titles, index terms, etc to your JPEG files, and later retrieve -them as text. COM blocks do not interfere with the image stored in the JPEG -file. The maximum size of a COM block is 64K, but you can have as many of -them as you like in one JPEG file. -.SH OPTIONS -.TP -.B \-verbose -Causes -.B rdjpgcom -to also display the JPEG image dimensions. -.PP -Switch names may be abbreviated, and are not case sensitive. -.SH HINTS -.B rdjpgcom -does not depend on the IJG JPEG library. Its source code is intended as an -illustration of the minimum amount of code required to parse a JPEG file -header correctly. -.PP -In -.B \-verbose -mode, -.B rdjpgcom -will also attempt to print the contents of any "APP12" markers as text. -Some digital cameras produce APP12 markers containing useful textual -information. If you like, you can modify the source code to print -other APPn marker types as well. -.SH SEE ALSO -.BR cjpeg (1), -.BR djpeg (1), -.BR jpegtran (1), -.BR wrjpgcom (1) -.SH AUTHOR -Independent JPEG Group diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/rdjpgcom.c b/irrlicht-1.6/source/Irrlicht/jpeglib/rdjpgcom.c deleted file mode 100644 index c8b94bb8a..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/rdjpgcom.c +++ /dev/null @@ -1,496 +0,0 @@ -/* - * rdjpgcom.c - * - * Copyright (C) 1994-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a very simple stand-alone application that displays - * the text in COM (comment) markers in a JFIF file. - * This may be useful as an example of the minimum logic needed to parse - * JPEG markers. - */ - -#define JPEG_CJPEG_DJPEG /* to get the command-line config symbols */ -#include "jinclude.h" /* get auto-config symbols, <stdio.h> */ - -#include <ctype.h> /* to declare isupper(), tolower() */ -#ifdef USE_SETMODE -#include <fcntl.h> /* to declare setmode()'s parameter macros */ -/* If you have setmode() but not <io.h>, just delete this line: */ -#include <io.h> /* to declare setmode() */ -#endif - -#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ -#ifdef __MWERKS__ -#include <SIOUX.h> /* Metrowerks needs this */ -#include <console.h> /* ... and this */ -#endif -#ifdef THINK_C -#include <console.h> /* Think declares it here */ -#endif -#endif - -#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ -#define READ_BINARY "r" -#else -#ifdef VMS /* VMS is very nonstandard */ -#define READ_BINARY "rb", "ctx=stm" -#else /* standard ANSI-compliant case */ -#define READ_BINARY "rb" -#endif -#endif - -#ifndef EXIT_FAILURE /* define exit() codes if not provided */ -#define EXIT_FAILURE 1 -#endif -#ifndef EXIT_SUCCESS -#ifdef VMS -#define EXIT_SUCCESS 1 /* VMS is very nonstandard */ -#else -#define EXIT_SUCCESS 0 -#endif -#endif - - -/* - * These macros are used to read the input file. - * To reuse this code in another application, you might need to change these. - */ - -static FILE * infile; /* input JPEG file */ - -/* Return next input byte, or EOF if no more */ -#define NEXTBYTE() getc(infile) - - -/* Error exit handler */ -#define ERREXIT(msg) (fprintf(stderr, "%s\n", msg), exit(EXIT_FAILURE)) - - -/* Read one byte, testing for EOF */ -static int -read_1_byte (void) -{ - int c; - - c = NEXTBYTE(); - if (c == EOF) - ERREXIT("Premature EOF in JPEG file"); - return c; -} - -/* Read 2 bytes, convert to unsigned int */ -/* All 2-byte quantities in JPEG markers are MSB first */ -static unsigned int -read_2_bytes (void) -{ - int c1, c2; - - c1 = NEXTBYTE(); - if (c1 == EOF) - ERREXIT("Premature EOF in JPEG file"); - c2 = NEXTBYTE(); - if (c2 == EOF) - ERREXIT("Premature EOF in JPEG file"); - return (((unsigned int) c1) << 8) + ((unsigned int) c2); -} - - -/* - * JPEG markers consist of one or more 0xFF bytes, followed by a marker - * code byte (which is not an FF). Here are the marker codes of interest - * in this program. (See jdmarker.c for a more complete list.) - */ - -#define M_SOF0 0xC0 /* Start Of Frame N */ -#define M_SOF1 0xC1 /* N indicates which compression process */ -#define M_SOF2 0xC2 /* Only SOF0-SOF2 are now in common use */ -#define M_SOF3 0xC3 -#define M_SOF5 0xC5 /* NB: codes C4 and CC are NOT SOF markers */ -#define M_SOF6 0xC6 -#define M_SOF7 0xC7 -#define M_SOF9 0xC9 -#define M_SOF10 0xCA -#define M_SOF11 0xCB -#define M_SOF13 0xCD -#define M_SOF14 0xCE -#define M_SOF15 0xCF -#define M_SOI 0xD8 /* Start Of Image (beginning of datastream) */ -#define M_EOI 0xD9 /* End Of Image (end of datastream) */ -#define M_SOS 0xDA /* Start Of Scan (begins compressed data) */ -#define M_APP0 0xE0 /* Application-specific marker, type N */ -#define M_APP12 0xEC /* (we don't bother to list all 16 APPn's) */ -#define M_COM 0xFE /* COMment */ - - -/* - * Find the next JPEG marker and return its marker code. - * We expect at least one FF byte, possibly more if the compressor used FFs - * to pad the file. - * There could also be non-FF garbage between markers. The treatment of such - * garbage is unspecified; we choose to skip over it but emit a warning msg. - * NB: this routine must not be used after seeing SOS marker, since it will - * not deal correctly with FF/00 sequences in the compressed image data... - */ - -static int -next_marker (void) -{ - int c; - int discarded_bytes = 0; - - /* Find 0xFF byte; count and skip any non-FFs. */ - c = read_1_byte(); - while (c != 0xFF) { - discarded_bytes++; - c = read_1_byte(); - } - /* Get marker code byte, swallowing any duplicate FF bytes. Extra FFs - * are legal as pad bytes, so don't count them in discarded_bytes. - */ - do { - c = read_1_byte(); - } while (c == 0xFF); - - if (discarded_bytes != 0) { - fprintf(stderr, "Warning: garbage data found in JPEG file\n"); - } - - return c; -} - - -/* - * Read the initial marker, which should be SOI. - * For a JFIF file, the first two bytes of the file should be literally - * 0xFF M_SOI. To be more general, we could use next_marker, but if the - * input file weren't actually JPEG at all, next_marker might read the whole - * file and then return a misleading error message... - */ - -static int -first_marker (void) -{ - int c1, c2; - - c1 = NEXTBYTE(); - c2 = NEXTBYTE(); - if (c1 != 0xFF || c2 != M_SOI) - ERREXIT("Not a JPEG file"); - return c2; -} - - -/* - * Most types of marker are followed by a variable-length parameter segment. - * This routine skips over the parameters for any marker we don't otherwise - * want to process. - * Note that we MUST skip the parameter segment explicitly in order not to - * be fooled by 0xFF bytes that might appear within the parameter segment; - * such bytes do NOT introduce new markers. - */ - -static void -skip_variable (void) -/* Skip over an unknown or uninteresting variable-length marker */ -{ - unsigned int length; - - /* Get the marker parameter length count */ - length = read_2_bytes(); - /* Length includes itself, so must be at least 2 */ - if (length < 2) - ERREXIT("Erroneous JPEG marker length"); - length -= 2; - /* Skip over the remaining bytes */ - while (length > 0) { - (void) read_1_byte(); - length--; - } -} - - -/* - * Process a COM marker. - * We want to print out the marker contents as legible text; - * we must guard against non-text junk and varying newline representations. - */ - -static void -process_COM (void) -{ - unsigned int length; - int ch; - int lastch = 0; - - /* Get the marker parameter length count */ - length = read_2_bytes(); - /* Length includes itself, so must be at least 2 */ - if (length < 2) - ERREXIT("Erroneous JPEG marker length"); - length -= 2; - - while (length > 0) { - ch = read_1_byte(); - /* Emit the character in a readable form. - * Nonprintables are converted to \nnn form, - * while \ is converted to \\. - * Newlines in CR, CR/LF, or LF form will be printed as one newline. - */ - if (ch == '\r') { - printf("\n"); - } else if (ch == '\n') { - if (lastch != '\r') - printf("\n"); - } else if (ch == '\\') { - printf("\\\\"); - } else if (isprint(ch)) { - putc(ch, stdout); - } else { - printf("\\%03o", ch); - } - lastch = ch; - length--; - } - printf("\n"); -} - - -/* - * Process a SOFn marker. - * This code is only needed if you want to know the image dimensions... - */ - -static void -process_SOFn (int marker) -{ - unsigned int length; - unsigned int image_height, image_width; - int data_precision, num_components; - const char * process; - int ci; - - length = read_2_bytes(); /* usual parameter length count */ - - data_precision = read_1_byte(); - image_height = read_2_bytes(); - image_width = read_2_bytes(); - num_components = read_1_byte(); - - switch (marker) { - case M_SOF0: process = "Baseline"; break; - case M_SOF1: process = "Extended sequential"; break; - case M_SOF2: process = "Progressive"; break; - case M_SOF3: process = "Lossless"; break; - case M_SOF5: process = "Differential sequential"; break; - case M_SOF6: process = "Differential progressive"; break; - case M_SOF7: process = "Differential lossless"; break; - case M_SOF9: process = "Extended sequential, arithmetic coding"; break; - case M_SOF10: process = "Progressive, arithmetic coding"; break; - case M_SOF11: process = "Lossless, arithmetic coding"; break; - case M_SOF13: process = "Differential sequential, arithmetic coding"; break; - case M_SOF14: process = "Differential progressive, arithmetic coding"; break; - case M_SOF15: process = "Differential lossless, arithmetic coding"; break; - default: process = "Unknown"; break; - } - - printf("JPEG image is %uw * %uh, %d color components, %d bits per sample\n", - image_width, image_height, num_components, data_precision); - printf("JPEG process: %s\n", process); - - if (length != (unsigned int) (8 + num_components * 3)) - ERREXIT("Bogus SOF marker length"); - - for (ci = 0; ci < num_components; ci++) { - (void) read_1_byte(); /* Component ID code */ - (void) read_1_byte(); /* H, V sampling factors */ - (void) read_1_byte(); /* Quantization table number */ - } -} - - -/* - * Parse the marker stream until SOS or EOI is seen; - * display any COM markers. - * While the companion program wrjpgcom will always insert COM markers before - * SOFn, other implementations might not, so we scan to SOS before stopping. - * If we were only interested in the image dimensions, we would stop at SOFn. - * (Conversely, if we only cared about COM markers, there would be no need - * for special code to handle SOFn; we could treat it like other markers.) - */ - -static int -scan_JPEG_header (int verbose) -{ - int marker; - - /* Expect SOI at start of file */ - if (first_marker() != M_SOI) - ERREXIT("Expected SOI marker first"); - - /* Scan miscellaneous markers until we reach SOS. */ - for (;;) { - marker = next_marker(); - switch (marker) { - /* Note that marker codes 0xC4, 0xC8, 0xCC are not, and must not be, - * treated as SOFn. C4 in particular is actually DHT. - */ - case M_SOF0: /* Baseline */ - case M_SOF1: /* Extended sequential, Huffman */ - case M_SOF2: /* Progressive, Huffman */ - case M_SOF3: /* Lossless, Huffman */ - case M_SOF5: /* Differential sequential, Huffman */ - case M_SOF6: /* Differential progressive, Huffman */ - case M_SOF7: /* Differential lossless, Huffman */ - case M_SOF9: /* Extended sequential, arithmetic */ - case M_SOF10: /* Progressive, arithmetic */ - case M_SOF11: /* Lossless, arithmetic */ - case M_SOF13: /* Differential sequential, arithmetic */ - case M_SOF14: /* Differential progressive, arithmetic */ - case M_SOF15: /* Differential lossless, arithmetic */ - if (verbose) - process_SOFn(marker); - else - skip_variable(); - break; - - case M_SOS: /* stop before hitting compressed data */ - return marker; - - case M_EOI: /* in case it's a tables-only JPEG stream */ - return marker; - - case M_COM: - process_COM(); - break; - - case M_APP12: - /* Some digital camera makers put useful textual information into - * APP12 markers, so we print those out too when in -verbose mode. - */ - if (verbose) { - printf("APP12 contains:\n"); - process_COM(); - } else - skip_variable(); - break; - - default: /* Anything else just gets skipped */ - skip_variable(); /* we assume it has a parameter count... */ - break; - } - } /* end loop */ -} - - -/* Command line parsing code */ - -static const char * progname; /* program name for error messages */ - - -static void -usage (void) -/* complain about bad command line */ -{ - fprintf(stderr, "rdjpgcom displays any textual comments in a JPEG file.\n"); - - fprintf(stderr, "Usage: %s [switches] [inputfile]\n", progname); - - fprintf(stderr, "Switches (names may be abbreviated):\n"); - fprintf(stderr, " -verbose Also display dimensions of JPEG image\n"); - - exit(EXIT_FAILURE); -} - - -static int -keymatch (char * arg, const char * keyword, int minchars) -/* Case-insensitive matching of (possibly abbreviated) keyword switches. */ -/* keyword is the constant keyword (must be lower case already), */ -/* minchars is length of minimum legal abbreviation. */ -{ - register int ca, ck; - register int nmatched = 0; - - while ((ca = *arg++) != '\0') { - if ((ck = *keyword++) == '\0') - return 0; /* arg longer than keyword, no good */ - if (isupper(ca)) /* force arg to lcase (assume ck is already) */ - ca = tolower(ca); - if (ca != ck) - return 0; /* no good */ - nmatched++; /* count matched characters */ - } - /* reached end of argument; fail if it's too short for unique abbrev */ - if (nmatched < minchars) - return 0; - return 1; /* A-OK */ -} - - -/* - * The main program. - */ - -int -main (int argc, char **argv) -{ - int argn; - char * arg; - int verbose = 0; - - /* On Mac, fetch a command line. */ -#ifdef USE_CCOMMAND - argc = ccommand(&argv); -#endif - - progname = argv[0]; - if (progname == NULL || progname[0] == 0) - progname = "rdjpgcom"; /* in case C library doesn't provide it */ - - /* Parse switches, if any */ - for (argn = 1; argn < argc; argn++) { - arg = argv[argn]; - if (arg[0] != '-') - break; /* not switch, must be file name */ - arg++; /* advance over '-' */ - if (keymatch(arg, "verbose", 1)) { - verbose++; - } else - usage(); - } - - /* Open the input file. */ - /* Unix style: expect zero or one file name */ - if (argn < argc-1) { - fprintf(stderr, "%s: only one input file\n", progname); - usage(); - } - if (argn < argc) { - if ((infile = fopen(argv[argn], READ_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]); - exit(EXIT_FAILURE); - } - } else { - /* default input file is stdin */ -#ifdef USE_SETMODE /* need to hack file mode? */ - setmode(fileno(stdin), O_BINARY); -#endif -#ifdef USE_FDOPEN /* need to re-open in binary mode? */ - if ((infile = fdopen(fileno(stdin), READ_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open stdin\n", progname); - exit(EXIT_FAILURE); - } -#else - infile = stdin; -#endif - } - - /* Scan the JPEG headers. */ - (void) scan_JPEG_header(verbose); - - /* All done. */ - exit(EXIT_SUCCESS); - return 0; /* suppress no-return-value warnings */ -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/rdppm.c b/irrlicht-1.6/source/Irrlicht/jpeglib/rdppm.c deleted file mode 100644 index bec0bc06d..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/rdppm.c +++ /dev/null @@ -1,458 +0,0 @@ -/* - * rdppm.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to read input images in PPM/PGM format. - * The extended 2-byte-per-sample raw PPM/PGM formats are supported. - * The PBMPLUS library is NOT required to compile this software - * (but it is highly useful as a set of PPM image manipulation programs). - * - * These routines may need modification for non-Unix environments or - * specialized applications. As they stand, they assume input from - * an ordinary stdio stream. They further assume that reading begins - * at the start of the file; start_input may need work if the - * user interface has already read some data (e.g., to determine that - * the file is indeed PPM format). - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef PPM_SUPPORTED - - -/* Portions of this code are based on the PBMPLUS library, which is: -** -** Copyright (C) 1988 by Jef Poskanzer. -** -** Permission to use, copy, modify, and distribute this software and its -** documentation for any purpose and without fee is hereby granted, provided -** that the above copyright notice appear in all copies and that both that -** copyright notice and this permission notice appear in supporting -** documentation. This software is provided "as is" without express or -** implied warranty. -*/ - - -/* Macros to deal with unsigned chars as efficiently as compiler allows */ - -#ifdef HAVE_UNSIGNED_CHAR -typedef unsigned char U_CHAR; -#define UCH(x) ((int) (x)) -#else /* !HAVE_UNSIGNED_CHAR */ -#ifdef CHAR_IS_UNSIGNED -typedef char U_CHAR; -#define UCH(x) ((int) (x)) -#else -typedef char U_CHAR; -#define UCH(x) ((int) (x) & 0xFF) -#endif -#endif /* HAVE_UNSIGNED_CHAR */ - - -#define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len))) - - -/* - * On most systems, reading individual bytes with getc() is drastically less - * efficient than buffering a row at a time with fread(). On PCs, we must - * allocate the buffer in near data space, because we are assuming small-data - * memory model, wherein fread() can't reach far memory. If you need to - * process very wide images on a PC, you might have to compile in large-memory - * model, or else replace fread() with a getc() loop --- which will be much - * slower. - */ - - -/* Private version of data source object */ - -typedef struct { - struct cjpeg_source_struct pub; /* public fields */ - - U_CHAR *iobuffer; /* non-FAR pointer to I/O buffer */ - JSAMPROW pixrow; /* FAR pointer to same */ - size_t buffer_width; /* width of I/O buffer */ - JSAMPLE *rescale; /* => maxval-remapping array, or NULL */ -} ppm_source_struct; - -typedef ppm_source_struct * ppm_source_ptr; - - -LOCAL(int) -pbm_getc (FILE * infile) -/* Read next char, skipping over any comments */ -/* A comment/newline sequence is returned as a newline */ -{ - register int ch; - - ch = getc(infile); - if (ch == '#') { - do { - ch = getc(infile); - } while (ch != '\n' && ch != EOF); - } - return ch; -} - - -LOCAL(unsigned int) -read_pbm_integer (j_compress_ptr cinfo, FILE * infile) -/* Read an unsigned decimal integer from the PPM file */ -/* Swallows one trailing character after the integer */ -/* Note that on a 16-bit-int machine, only values up to 64k can be read. */ -/* This should not be a problem in practice. */ -{ - register int ch; - register unsigned int val; - - /* Skip any leading whitespace */ - do { - ch = pbm_getc(infile); - if (ch == EOF) - ERREXIT(cinfo, JERR_INPUT_EOF); - } while (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'); - - if (ch < '0' || ch > '9') - ERREXIT(cinfo, JERR_PPM_NONNUMERIC); - - val = ch - '0'; - while ((ch = pbm_getc(infile)) >= '0' && ch <= '9') { - val *= 10; - val += ch - '0'; - } - return val; -} - - -/* - * Read one row of pixels. - * - * We provide several different versions depending on input file format. - * In all cases, input is scaled to the size of JSAMPLE. - * - * A really fast path is provided for reading byte/sample raw files with - * maxval = MAXJSAMPLE, which is the normal case for 8-bit data. - */ - - -METHODDEF(JDIMENSION) -get_text_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading text-format PGM files with any maxval */ -{ - ppm_source_ptr source = (ppm_source_ptr) sinfo; - FILE * infile = source->pub.input_file; - register JSAMPROW ptr; - register JSAMPLE *rescale = source->rescale; - JDIMENSION col; - - ptr = source->pub.buffer[0]; - for (col = cinfo->image_width; col > 0; col--) { - *ptr++ = rescale[read_pbm_integer(cinfo, infile)]; - } - return 1; -} - - -METHODDEF(JDIMENSION) -get_text_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading text-format PPM files with any maxval */ -{ - ppm_source_ptr source = (ppm_source_ptr) sinfo; - FILE * infile = source->pub.input_file; - register JSAMPROW ptr; - register JSAMPLE *rescale = source->rescale; - JDIMENSION col; - - ptr = source->pub.buffer[0]; - for (col = cinfo->image_width; col > 0; col--) { - *ptr++ = rescale[read_pbm_integer(cinfo, infile)]; - *ptr++ = rescale[read_pbm_integer(cinfo, infile)]; - *ptr++ = rescale[read_pbm_integer(cinfo, infile)]; - } - return 1; -} - - -METHODDEF(JDIMENSION) -get_scaled_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading raw-byte-format PGM files with any maxval */ -{ - ppm_source_ptr source = (ppm_source_ptr) sinfo; - register JSAMPROW ptr; - register U_CHAR * bufferptr; - register JSAMPLE *rescale = source->rescale; - JDIMENSION col; - - if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) - ERREXIT(cinfo, JERR_INPUT_EOF); - ptr = source->pub.buffer[0]; - bufferptr = source->iobuffer; - for (col = cinfo->image_width; col > 0; col--) { - *ptr++ = rescale[UCH(*bufferptr++)]; - } - return 1; -} - - -METHODDEF(JDIMENSION) -get_scaled_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading raw-byte-format PPM files with any maxval */ -{ - ppm_source_ptr source = (ppm_source_ptr) sinfo; - register JSAMPROW ptr; - register U_CHAR * bufferptr; - register JSAMPLE *rescale = source->rescale; - JDIMENSION col; - - if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) - ERREXIT(cinfo, JERR_INPUT_EOF); - ptr = source->pub.buffer[0]; - bufferptr = source->iobuffer; - for (col = cinfo->image_width; col > 0; col--) { - *ptr++ = rescale[UCH(*bufferptr++)]; - *ptr++ = rescale[UCH(*bufferptr++)]; - *ptr++ = rescale[UCH(*bufferptr++)]; - } - return 1; -} - - -METHODDEF(JDIMENSION) -get_raw_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading raw-byte-format files with maxval = MAXJSAMPLE. - * In this case we just read right into the JSAMPLE buffer! - * Note that same code works for PPM and PGM files. - */ -{ - ppm_source_ptr source = (ppm_source_ptr) sinfo; - - if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) - ERREXIT(cinfo, JERR_INPUT_EOF); - return 1; -} - - -METHODDEF(JDIMENSION) -get_word_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading raw-word-format PGM files with any maxval */ -{ - ppm_source_ptr source = (ppm_source_ptr) sinfo; - register JSAMPROW ptr; - register U_CHAR * bufferptr; - register JSAMPLE *rescale = source->rescale; - JDIMENSION col; - - if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) - ERREXIT(cinfo, JERR_INPUT_EOF); - ptr = source->pub.buffer[0]; - bufferptr = source->iobuffer; - for (col = cinfo->image_width; col > 0; col--) { - register int temp; - temp = UCH(*bufferptr++); - temp |= UCH(*bufferptr++) << 8; - *ptr++ = rescale[temp]; - } - return 1; -} - - -METHODDEF(JDIMENSION) -get_word_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading raw-word-format PPM files with any maxval */ -{ - ppm_source_ptr source = (ppm_source_ptr) sinfo; - register JSAMPROW ptr; - register U_CHAR * bufferptr; - register JSAMPLE *rescale = source->rescale; - JDIMENSION col; - - if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) - ERREXIT(cinfo, JERR_INPUT_EOF); - ptr = source->pub.buffer[0]; - bufferptr = source->iobuffer; - for (col = cinfo->image_width; col > 0; col--) { - register int temp; - temp = UCH(*bufferptr++); - temp |= UCH(*bufferptr++) << 8; - *ptr++ = rescale[temp]; - temp = UCH(*bufferptr++); - temp |= UCH(*bufferptr++) << 8; - *ptr++ = rescale[temp]; - temp = UCH(*bufferptr++); - temp |= UCH(*bufferptr++) << 8; - *ptr++ = rescale[temp]; - } - return 1; -} - - -/* - * Read the file header; return image size and component count. - */ - -METHODDEF(void) -start_input_ppm (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - ppm_source_ptr source = (ppm_source_ptr) sinfo; - int c; - unsigned int w, h, maxval; - boolean need_iobuffer, use_raw_buffer, need_rescale; - - if (getc(source->pub.input_file) != 'P') - ERREXIT(cinfo, JERR_PPM_NOT); - - c = getc(source->pub.input_file); /* subformat discriminator character */ - - /* detect unsupported variants (ie, PBM) before trying to read header */ - switch (c) { - case '2': /* it's a text-format PGM file */ - case '3': /* it's a text-format PPM file */ - case '5': /* it's a raw-format PGM file */ - case '6': /* it's a raw-format PPM file */ - break; - default: - ERREXIT(cinfo, JERR_PPM_NOT); - break; - } - - /* fetch the remaining header info */ - w = read_pbm_integer(cinfo, source->pub.input_file); - h = read_pbm_integer(cinfo, source->pub.input_file); - maxval = read_pbm_integer(cinfo, source->pub.input_file); - - if (w <= 0 || h <= 0 || maxval <= 0) /* error check */ - ERREXIT(cinfo, JERR_PPM_NOT); - - cinfo->data_precision = BITS_IN_JSAMPLE; /* we always rescale data to this */ - cinfo->image_width = (JDIMENSION) w; - cinfo->image_height = (JDIMENSION) h; - - /* initialize flags to most common settings */ - need_iobuffer = TRUE; /* do we need an I/O buffer? */ - use_raw_buffer = FALSE; /* do we map input buffer onto I/O buffer? */ - need_rescale = TRUE; /* do we need a rescale array? */ - - switch (c) { - case '2': /* it's a text-format PGM file */ - cinfo->input_components = 1; - cinfo->in_color_space = JCS_GRAYSCALE; - TRACEMS2(cinfo, 1, JTRC_PGM_TEXT, w, h); - source->pub.get_pixel_rows = get_text_gray_row; - need_iobuffer = FALSE; - break; - - case '3': /* it's a text-format PPM file */ - cinfo->input_components = 3; - cinfo->in_color_space = JCS_RGB; - TRACEMS2(cinfo, 1, JTRC_PPM_TEXT, w, h); - source->pub.get_pixel_rows = get_text_rgb_row; - need_iobuffer = FALSE; - break; - - case '5': /* it's a raw-format PGM file */ - cinfo->input_components = 1; - cinfo->in_color_space = JCS_GRAYSCALE; - TRACEMS2(cinfo, 1, JTRC_PGM, w, h); - if (maxval > 255) { - source->pub.get_pixel_rows = get_word_gray_row; - } else if (maxval == MAXJSAMPLE && SIZEOF(JSAMPLE) == SIZEOF(U_CHAR)) { - source->pub.get_pixel_rows = get_raw_row; - use_raw_buffer = TRUE; - need_rescale = FALSE; - } else { - source->pub.get_pixel_rows = get_scaled_gray_row; - } - break; - - case '6': /* it's a raw-format PPM file */ - cinfo->input_components = 3; - cinfo->in_color_space = JCS_RGB; - TRACEMS2(cinfo, 1, JTRC_PPM, w, h); - if (maxval > 255) { - source->pub.get_pixel_rows = get_word_rgb_row; - } else if (maxval == MAXJSAMPLE && SIZEOF(JSAMPLE) == SIZEOF(U_CHAR)) { - source->pub.get_pixel_rows = get_raw_row; - use_raw_buffer = TRUE; - need_rescale = FALSE; - } else { - source->pub.get_pixel_rows = get_scaled_rgb_row; - } - break; - } - - /* Allocate space for I/O buffer: 1 or 3 bytes or words/pixel. */ - if (need_iobuffer) { - source->buffer_width = (size_t) w * cinfo->input_components * - ((maxval<=255) ? SIZEOF(U_CHAR) : (2*SIZEOF(U_CHAR))); - source->iobuffer = (U_CHAR *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - source->buffer_width); - } - - /* Create compressor input buffer. */ - if (use_raw_buffer) { - /* For unscaled raw-input case, we can just map it onto the I/O buffer. */ - /* Synthesize a JSAMPARRAY pointer structure */ - /* Cast here implies near->far pointer conversion on PCs */ - source->pixrow = (JSAMPROW) source->iobuffer; - source->pub.buffer = & source->pixrow; - source->pub.buffer_height = 1; - } else { - /* Need to translate anyway, so make a separate sample buffer. */ - source->pub.buffer = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) w * cinfo->input_components, (JDIMENSION) 1); - source->pub.buffer_height = 1; - } - - /* Compute the rescaling array if required. */ - if (need_rescale) { - INT32 val, half_maxval; - - /* On 16-bit-int machines we have to be careful of maxval = 65535 */ - source->rescale = (JSAMPLE *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (size_t) (((long) maxval + 1L) * SIZEOF(JSAMPLE))); - half_maxval = maxval / 2; - for (val = 0; val <= (INT32) maxval; val++) { - /* The multiplication here must be done in 32 bits to avoid overflow */ - source->rescale[val] = (JSAMPLE) ((val*MAXJSAMPLE + half_maxval)/maxval); - } - } -} - - -/* - * Finish up at the end of the file. - */ - -METHODDEF(void) -finish_input_ppm (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - /* no work */ -} - - -/* - * The module selection routine for PPM format input. - */ - -GLOBAL(cjpeg_source_ptr) -jinit_read_ppm (j_compress_ptr cinfo) -{ - ppm_source_ptr source; - - /* Create module interface object */ - source = (ppm_source_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(ppm_source_struct)); - /* Fill in method ptrs, except get_pixel_rows which start_input sets */ - source->pub.start_input = start_input_ppm; - source->pub.finish_input = finish_input_ppm; - - return (cjpeg_source_ptr) source; -} - -#endif /* PPM_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/rdrle.c b/irrlicht-1.6/source/Irrlicht/jpeglib/rdrle.c deleted file mode 100644 index df871e00a..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/rdrle.c +++ /dev/null @@ -1,387 +0,0 @@ -/* - * rdrle.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to read input images in Utah RLE format. - * The Utah Raster Toolkit library is required (version 3.1 or later). - * - * These routines may need modification for non-Unix environments or - * specialized applications. As they stand, they assume input from - * an ordinary stdio stream. They further assume that reading begins - * at the start of the file; start_input may need work if the - * user interface has already read some data (e.g., to determine that - * the file is indeed RLE format). - * - * Based on code contributed by Mike Lijewski, - * with updates from Robert Hutchinson. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef RLE_SUPPORTED - -/* rle.h is provided by the Utah Raster Toolkit. */ - -#include <rle.h> - -/* - * We assume that JSAMPLE has the same representation as rle_pixel, - * to wit, "unsigned char". Hence we can't cope with 12- or 16-bit samples. - */ - -#if BITS_IN_JSAMPLE != 8 - Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */ -#endif - -/* - * We support the following types of RLE files: - * - * GRAYSCALE - 8 bits, no colormap - * MAPPEDGRAY - 8 bits, 1 channel colomap - * PSEUDOCOLOR - 8 bits, 3 channel colormap - * TRUECOLOR - 24 bits, 3 channel colormap - * DIRECTCOLOR - 24 bits, no colormap - * - * For now, we ignore any alpha channel in the image. - */ - -typedef enum - { GRAYSCALE, MAPPEDGRAY, PSEUDOCOLOR, TRUECOLOR, DIRECTCOLOR } rle_kind; - - -/* - * Since RLE stores scanlines bottom-to-top, we have to invert the image - * to conform to JPEG's top-to-bottom order. To do this, we read the - * incoming image into a virtual array on the first get_pixel_rows call, - * then fetch the required row from the virtual array on subsequent calls. - */ - -typedef struct _rle_source_struct * rle_source_ptr; - -typedef struct _rle_source_struct { - struct cjpeg_source_struct pub; /* public fields */ - - rle_kind visual; /* actual type of input file */ - jvirt_sarray_ptr image; /* virtual array to hold the image */ - JDIMENSION row; /* current row # in the virtual array */ - rle_hdr header; /* Input file information */ - rle_pixel** rle_row; /* holds a row returned by rle_getrow() */ - -} rle_source_struct; - - -/* - * Read the file header; return image size and component count. - */ - -METHODDEF(void) -start_input_rle (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - rle_source_ptr source = (rle_source_ptr) sinfo; - JDIMENSION width, height; -#ifdef PROGRESS_REPORT - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; -#endif - - /* Use RLE library routine to get the header info */ - source->header = *rle_hdr_init(NULL); - source->header.rle_file = source->pub.input_file; - switch (rle_get_setup(&(source->header))) { - case RLE_SUCCESS: - /* A-OK */ - break; - case RLE_NOT_RLE: - ERREXIT(cinfo, JERR_RLE_NOT); - break; - case RLE_NO_SPACE: - ERREXIT(cinfo, JERR_RLE_MEM); - break; - case RLE_EMPTY: - ERREXIT(cinfo, JERR_RLE_EMPTY); - break; - case RLE_EOF: - ERREXIT(cinfo, JERR_RLE_EOF); - break; - default: - ERREXIT(cinfo, JERR_RLE_BADERROR); - break; - } - - /* Figure out what we have, set private vars and return values accordingly */ - - width = source->header.xmax - source->header.xmin + 1; - height = source->header.ymax - source->header.ymin + 1; - source->header.xmin = 0; /* realign horizontally */ - source->header.xmax = width-1; - - cinfo->image_width = width; - cinfo->image_height = height; - cinfo->data_precision = 8; /* we can only handle 8 bit data */ - - if (source->header.ncolors == 1 && source->header.ncmap == 0) { - source->visual = GRAYSCALE; - TRACEMS2(cinfo, 1, JTRC_RLE_GRAY, width, height); - } else if (source->header.ncolors == 1 && source->header.ncmap == 1) { - source->visual = MAPPEDGRAY; - TRACEMS3(cinfo, 1, JTRC_RLE_MAPGRAY, width, height, - 1 << source->header.cmaplen); - } else if (source->header.ncolors == 1 && source->header.ncmap == 3) { - source->visual = PSEUDOCOLOR; - TRACEMS3(cinfo, 1, JTRC_RLE_MAPPED, width, height, - 1 << source->header.cmaplen); - } else if (source->header.ncolors == 3 && source->header.ncmap == 3) { - source->visual = TRUECOLOR; - TRACEMS3(cinfo, 1, JTRC_RLE_FULLMAP, width, height, - 1 << source->header.cmaplen); - } else if (source->header.ncolors == 3 && source->header.ncmap == 0) { - source->visual = DIRECTCOLOR; - TRACEMS2(cinfo, 1, JTRC_RLE, width, height); - } else - ERREXIT(cinfo, JERR_RLE_UNSUPPORTED); - - if (source->visual == GRAYSCALE || source->visual == MAPPEDGRAY) { - cinfo->in_color_space = JCS_GRAYSCALE; - cinfo->input_components = 1; - } else { - cinfo->in_color_space = JCS_RGB; - cinfo->input_components = 3; - } - - /* - * A place to hold each scanline while it's converted. - * (GRAYSCALE scanlines don't need converting) - */ - if (source->visual != GRAYSCALE) { - source->rle_row = (rle_pixel**) (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) width, (JDIMENSION) cinfo->input_components); - } - - /* request a virtual array to hold the image */ - source->image = (*cinfo->mem->request_virt_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, - (JDIMENSION) (width * source->header.ncolors), - (JDIMENSION) height, (JDIMENSION) 1); - -#ifdef PROGRESS_REPORT - if (progress != NULL) { - /* count file input as separate pass */ - progress->total_extra_passes++; - } -#endif - - source->pub.buffer_height = 1; -} - - -/* - * Read one row of pixels. - * Called only after load_image has read the image into the virtual array. - * Used for GRAYSCALE, MAPPEDGRAY, TRUECOLOR, and DIRECTCOLOR images. - */ - -METHODDEF(JDIMENSION) -get_rle_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - rle_source_ptr source = (rle_source_ptr) sinfo; - - source->row--; - source->pub.buffer = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, source->image, source->row, (JDIMENSION) 1, FALSE); - - return 1; -} - -/* - * Read one row of pixels. - * Called only after load_image has read the image into the virtual array. - * Used for PSEUDOCOLOR images. - */ - -METHODDEF(JDIMENSION) -get_pseudocolor_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - rle_source_ptr source = (rle_source_ptr) sinfo; - JSAMPROW src_row, dest_row; - JDIMENSION col; - rle_map *colormap; - int val; - - colormap = source->header.cmap; - dest_row = source->pub.buffer[0]; - source->row--; - src_row = * (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, source->image, source->row, (JDIMENSION) 1, FALSE); - - for (col = cinfo->image_width; col > 0; col--) { - val = GETJSAMPLE(*src_row++); - *dest_row++ = (JSAMPLE) (colormap[val ] >> 8); - *dest_row++ = (JSAMPLE) (colormap[val + 256] >> 8); - *dest_row++ = (JSAMPLE) (colormap[val + 512] >> 8); - } - - return 1; -} - - -/* - * Load the image into a virtual array. We have to do this because RLE - * files start at the lower left while the JPEG standard has them starting - * in the upper left. This is called the first time we want to get a row - * of input. What we do is load the RLE data into the array and then call - * the appropriate routine to read one row from the array. Before returning, - * we set source->pub.get_pixel_rows so that subsequent calls go straight to - * the appropriate row-reading routine. - */ - -METHODDEF(JDIMENSION) -load_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - rle_source_ptr source = (rle_source_ptr) sinfo; - JDIMENSION row, col; - JSAMPROW scanline, red_ptr, green_ptr, blue_ptr; - rle_pixel **rle_row; - rle_map *colormap; - char channel; -#ifdef PROGRESS_REPORT - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; -#endif - - colormap = source->header.cmap; - rle_row = source->rle_row; - - /* Read the RLE data into our virtual array. - * We assume here that (a) rle_pixel is represented the same as JSAMPLE, - * and (b) we are not on a machine where FAR pointers differ from regular. - */ - RLE_CLR_BIT(source->header, RLE_ALPHA); /* don't read the alpha channel */ - -#ifdef PROGRESS_REPORT - if (progress != NULL) { - progress->pub.pass_limit = cinfo->image_height; - progress->pub.pass_counter = 0; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } -#endif - - switch (source->visual) { - - case GRAYSCALE: - case PSEUDOCOLOR: - for (row = 0; row < cinfo->image_height; row++) { - rle_row = (rle_pixel **) (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, source->image, row, (JDIMENSION) 1, TRUE); - rle_getrow(&source->header, rle_row); -#ifdef PROGRESS_REPORT - if (progress != NULL) { - progress->pub.pass_counter++; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } -#endif - } - break; - - case MAPPEDGRAY: - case TRUECOLOR: - for (row = 0; row < cinfo->image_height; row++) { - scanline = * (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, source->image, row, (JDIMENSION) 1, TRUE); - rle_row = source->rle_row; - rle_getrow(&source->header, rle_row); - - for (col = 0; col < cinfo->image_width; col++) { - for (channel = 0; channel < source->header.ncolors; channel++) { - *scanline++ = (JSAMPLE) - (colormap[GETJSAMPLE(rle_row[channel][col]) + 256 * channel] >> 8); - } - } - -#ifdef PROGRESS_REPORT - if (progress != NULL) { - progress->pub.pass_counter++; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } -#endif - } - break; - - case DIRECTCOLOR: - for (row = 0; row < cinfo->image_height; row++) { - scanline = * (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, source->image, row, (JDIMENSION) 1, TRUE); - rle_getrow(&source->header, rle_row); - - red_ptr = rle_row[0]; - green_ptr = rle_row[1]; - blue_ptr = rle_row[2]; - - for (col = cinfo->image_width; col > 0; col--) { - *scanline++ = *red_ptr++; - *scanline++ = *green_ptr++; - *scanline++ = *blue_ptr++; - } - -#ifdef PROGRESS_REPORT - if (progress != NULL) { - progress->pub.pass_counter++; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } -#endif - } - } - -#ifdef PROGRESS_REPORT - if (progress != NULL) - progress->completed_extra_passes++; -#endif - - /* Set up to call proper row-extraction routine in future */ - if (source->visual == PSEUDOCOLOR) { - source->pub.buffer = source->rle_row; - source->pub.get_pixel_rows = get_pseudocolor_row; - } else { - source->pub.get_pixel_rows = get_rle_row; - } - source->row = cinfo->image_height; - - /* And fetch the topmost (bottommost) row */ - return (*source->pub.get_pixel_rows) (cinfo, sinfo); -} - - -/* - * Finish up at the end of the file. - */ - -METHODDEF(void) -finish_input_rle (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - /* no work */ -} - - -/* - * The module selection routine for RLE format input. - */ - -GLOBAL(cjpeg_source_ptr) -jinit_read_rle (j_compress_ptr cinfo) -{ - rle_source_ptr source; - - /* Create module interface object */ - source = (rle_source_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(rle_source_struct)); - /* Fill in method ptrs */ - source->pub.start_input = start_input_rle; - source->pub.finish_input = finish_input_rle; - source->pub.get_pixel_rows = load_image; - - return (cjpeg_source_ptr) source; -} - -#endif /* RLE_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/rdswitch.c b/irrlicht-1.6/source/Irrlicht/jpeglib/rdswitch.c deleted file mode 100644 index b915ad9d3..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/rdswitch.c +++ /dev/null @@ -1,332 +0,0 @@ -/* - * rdswitch.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to process some of cjpeg's more complicated - * command-line switches. Switches processed here are: - * -qtables file Read quantization tables from text file - * -scans file Read scan script from text file - * -qslots N[,N,...] Set component quantization table selectors - * -sample HxV[,HxV,...] Set component sampling factors - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ -#include <ctype.h> /* to declare isdigit(), isspace() */ - - -LOCAL(int) -text_getc (FILE * file) -/* Read next char, skipping over any comments (# to end of line) */ -/* A comment/newline sequence is returned as a newline */ -{ - register int ch; - - ch = getc(file); - if (ch == '#') { - do { - ch = getc(file); - } while (ch != '\n' && ch != EOF); - } - return ch; -} - - -LOCAL(boolean) -read_text_integer (FILE * file, long * result, int * termchar) -/* Read an unsigned decimal integer from a file, store it in result */ -/* Reads one trailing character after the integer; returns it in termchar */ -{ - register int ch; - register long val; - - /* Skip any leading whitespace, detect EOF */ - do { - ch = text_getc(file); - if (ch == EOF) { - *termchar = ch; - return FALSE; - } - } while (isspace(ch)); - - if (! isdigit(ch)) { - *termchar = ch; - return FALSE; - } - - val = ch - '0'; - while ((ch = text_getc(file)) != EOF) { - if (! isdigit(ch)) - break; - val *= 10; - val += ch - '0'; - } - *result = val; - *termchar = ch; - return TRUE; -} - - -GLOBAL(boolean) -read_quant_tables (j_compress_ptr cinfo, char * filename, - int scale_factor, boolean force_baseline) -/* Read a set of quantization tables from the specified file. - * The file is plain ASCII text: decimal numbers with whitespace between. - * Comments preceded by '#' may be included in the file. - * There may be one to NUM_QUANT_TBLS tables in the file, each of 64 values. - * The tables are implicitly numbered 0,1,etc. - * NOTE: does not affect the qslots mapping, which will default to selecting - * table 0 for luminance (or primary) components, 1 for chrominance components. - * You must use -qslots if you want a different component->table mapping. - */ -{ - FILE * fp; - int tblno, i, termchar; - long val; - unsigned int table[DCTSIZE2]; - - if ((fp = fopen(filename, "r")) == NULL) { - fprintf(stderr, "Can't open table file %s\n", filename); - return FALSE; - } - tblno = 0; - - while (read_text_integer(fp, &val, &termchar)) { /* read 1st element of table */ - if (tblno >= NUM_QUANT_TBLS) { - fprintf(stderr, "Too many tables in file %s\n", filename); - fclose(fp); - return FALSE; - } - table[0] = (unsigned int) val; - for (i = 1; i < DCTSIZE2; i++) { - if (! read_text_integer(fp, &val, &termchar)) { - fprintf(stderr, "Invalid table data in file %s\n", filename); - fclose(fp); - return FALSE; - } - table[i] = (unsigned int) val; - } - jpeg_add_quant_table(cinfo, tblno, table, scale_factor, force_baseline); - tblno++; - } - - if (termchar != EOF) { - fprintf(stderr, "Non-numeric data in file %s\n", filename); - fclose(fp); - return FALSE; - } - - fclose(fp); - return TRUE; -} - - -#ifdef C_MULTISCAN_FILES_SUPPORTED - -LOCAL(boolean) -read_scan_integer (FILE * file, long * result, int * termchar) -/* Variant of read_text_integer that always looks for a non-space termchar; - * this simplifies parsing of punctuation in scan scripts. - */ -{ - register int ch; - - if (! read_text_integer(file, result, termchar)) - return FALSE; - ch = *termchar; - while (ch != EOF && isspace(ch)) - ch = text_getc(file); - if (isdigit(ch)) { /* oops, put it back */ - if (ungetc(ch, file) == EOF) - return FALSE; - ch = ' '; - } else { - /* Any separators other than ';' and ':' are ignored; - * this allows user to insert commas, etc, if desired. - */ - if (ch != EOF && ch != ';' && ch != ':') - ch = ' '; - } - *termchar = ch; - return TRUE; -} - - -GLOBAL(boolean) -read_scan_script (j_compress_ptr cinfo, char * filename) -/* Read a scan script from the specified text file. - * Each entry in the file defines one scan to be emitted. - * Entries are separated by semicolons ';'. - * An entry contains one to four component indexes, - * optionally followed by a colon ':' and four progressive-JPEG parameters. - * The component indexes denote which component(s) are to be transmitted - * in the current scan. The first component has index 0. - * Sequential JPEG is used if the progressive-JPEG parameters are omitted. - * The file is free format text: any whitespace may appear between numbers - * and the ':' and ';' punctuation marks. Also, other punctuation (such - * as commas or dashes) can be placed between numbers if desired. - * Comments preceded by '#' may be included in the file. - * Note: we do very little validity checking here; - * jcmaster.c will validate the script parameters. - */ -{ - FILE * fp; - int scanno, ncomps, termchar; - long val; - jpeg_scan_info * scanptr; -#define MAX_SCANS 100 /* quite arbitrary limit */ - jpeg_scan_info scans[MAX_SCANS]; - - if ((fp = fopen(filename, "r")) == NULL) { - fprintf(stderr, "Can't open scan definition file %s\n", filename); - return FALSE; - } - scanptr = scans; - scanno = 0; - - while (read_scan_integer(fp, &val, &termchar)) { - if (scanno >= MAX_SCANS) { - fprintf(stderr, "Too many scans defined in file %s\n", filename); - fclose(fp); - return FALSE; - } - scanptr->component_index[0] = (int) val; - ncomps = 1; - while (termchar == ' ') { - if (ncomps >= MAX_COMPS_IN_SCAN) { - fprintf(stderr, "Too many components in one scan in file %s\n", - filename); - fclose(fp); - return FALSE; - } - if (! read_scan_integer(fp, &val, &termchar)) - goto bogus; - scanptr->component_index[ncomps] = (int) val; - ncomps++; - } - scanptr->comps_in_scan = ncomps; - if (termchar == ':') { - if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ') - goto bogus; - scanptr->Ss = (int) val; - if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ') - goto bogus; - scanptr->Se = (int) val; - if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ') - goto bogus; - scanptr->Ah = (int) val; - if (! read_scan_integer(fp, &val, &termchar)) - goto bogus; - scanptr->Al = (int) val; - } else { - /* set non-progressive parameters */ - scanptr->Ss = 0; - scanptr->Se = DCTSIZE2-1; - scanptr->Ah = 0; - scanptr->Al = 0; - } - if (termchar != ';' && termchar != EOF) { -bogus: - fprintf(stderr, "Invalid scan entry format in file %s\n", filename); - fclose(fp); - return FALSE; - } - scanptr++, scanno++; - } - - if (termchar != EOF) { - fprintf(stderr, "Non-numeric data in file %s\n", filename); - fclose(fp); - return FALSE; - } - - if (scanno > 0) { - /* Stash completed scan list in cinfo structure. - * NOTE: for cjpeg's use, JPOOL_IMAGE is the right lifetime for this data, - * but if you want to compress multiple images you'd want JPOOL_PERMANENT. - */ - scanptr = (jpeg_scan_info *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - scanno * SIZEOF(jpeg_scan_info)); - MEMCOPY(scanptr, scans, scanno * SIZEOF(jpeg_scan_info)); - cinfo->scan_info = scanptr; - cinfo->num_scans = scanno; - } - - fclose(fp); - return TRUE; -} - -#endif /* C_MULTISCAN_FILES_SUPPORTED */ - - -GLOBAL(boolean) -set_quant_slots (j_compress_ptr cinfo, char *arg) -/* Process a quantization-table-selectors parameter string, of the form - * N[,N,...] - * If there are more components than parameters, the last value is replicated. - */ -{ - int val = 0; /* default table # */ - int ci; - char ch; - - for (ci = 0; ci < MAX_COMPONENTS; ci++) { - if (*arg) { - ch = ','; /* if not set by sscanf, will be ',' */ - if (sscanf(arg, "%d%c", &val, &ch) < 1) - return FALSE; - if (ch != ',') /* syntax check */ - return FALSE; - if (val < 0 || val >= NUM_QUANT_TBLS) { - fprintf(stderr, "JPEG quantization tables are numbered 0..%d\n", - NUM_QUANT_TBLS-1); - return FALSE; - } - cinfo->comp_info[ci].quant_tbl_no = val; - while (*arg && *arg++ != ',') /* advance to next segment of arg string */ - ; - } else { - /* reached end of parameter, set remaining components to last table */ - cinfo->comp_info[ci].quant_tbl_no = val; - } - } - return TRUE; -} - - -GLOBAL(boolean) -set_sample_factors (j_compress_ptr cinfo, char *arg) -/* Process a sample-factors parameter string, of the form - * HxV[,HxV,...] - * If there are more components than parameters, "1x1" is assumed for the rest. - */ -{ - int ci, val1, val2; - char ch1, ch2; - - for (ci = 0; ci < MAX_COMPONENTS; ci++) { - if (*arg) { - ch2 = ','; /* if not set by sscanf, will be ',' */ - if (sscanf(arg, "%d%c%d%c", &val1, &ch1, &val2, &ch2) < 3) - return FALSE; - if ((ch1 != 'x' && ch1 != 'X') || ch2 != ',') /* syntax check */ - return FALSE; - if (val1 <= 0 || val1 > 4 || val2 <= 0 || val2 > 4) { - fprintf(stderr, "JPEG sampling factors must be 1..4\n"); - return FALSE; - } - cinfo->comp_info[ci].h_samp_factor = val1; - cinfo->comp_info[ci].v_samp_factor = val2; - while (*arg && *arg++ != ',') /* advance to next segment of arg string */ - ; - } else { - /* reached end of parameter, set remaining components to 1x1 sampling */ - cinfo->comp_info[ci].h_samp_factor = 1; - cinfo->comp_info[ci].v_samp_factor = 1; - } - } - return TRUE; -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/rdtarga.c b/irrlicht-1.6/source/Irrlicht/jpeglib/rdtarga.c deleted file mode 100644 index d7ffc33eb..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/rdtarga.c +++ /dev/null @@ -1,500 +0,0 @@ -/* - * rdtarga.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to read input images in Targa format. - * - * These routines may need modification for non-Unix environments or - * specialized applications. As they stand, they assume input from - * an ordinary stdio stream. They further assume that reading begins - * at the start of the file; start_input may need work if the - * user interface has already read some data (e.g., to determine that - * the file is indeed Targa format). - * - * Based on code contributed by Lee Daniel Crocker. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef TARGA_SUPPORTED - - -/* Macros to deal with unsigned chars as efficiently as compiler allows */ - -#ifdef HAVE_UNSIGNED_CHAR -typedef unsigned char U_CHAR; -#define UCH(x) ((int) (x)) -#else /* !HAVE_UNSIGNED_CHAR */ -#ifdef CHAR_IS_UNSIGNED -typedef char U_CHAR; -#define UCH(x) ((int) (x)) -#else -typedef char U_CHAR; -#define UCH(x) ((int) (x) & 0xFF) -#endif -#endif /* HAVE_UNSIGNED_CHAR */ - - -#define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len))) - - -/* Private version of data source object */ - -typedef struct _tga_source_struct * tga_source_ptr; - -typedef struct _tga_source_struct { - struct cjpeg_source_struct pub; /* public fields */ - - j_compress_ptr cinfo; /* back link saves passing separate parm */ - - JSAMPARRAY colormap; /* Targa colormap (converted to my format) */ - - jvirt_sarray_ptr whole_image; /* Needed if funny input row order */ - JDIMENSION current_row; /* Current logical row number to read */ - - /* Pointer to routine to extract next Targa pixel from input file */ - JMETHOD(void, read_pixel, (tga_source_ptr sinfo)); - - /* Result of read_pixel is delivered here: */ - U_CHAR tga_pixel[4]; - - int pixel_size; /* Bytes per Targa pixel (1 to 4) */ - - /* State info for reading RLE-coded pixels; both counts must be init to 0 */ - int block_count; /* # of pixels remaining in RLE block */ - int dup_pixel_count; /* # of times to duplicate previous pixel */ - - /* This saves the correct pixel-row-expansion method for preload_image */ - JMETHOD(JDIMENSION, get_pixel_rows, (j_compress_ptr cinfo, - cjpeg_source_ptr sinfo)); -} tga_source_struct; - - -/* For expanding 5-bit pixel values to 8-bit with best rounding */ - -static const UINT8 c5to8bits[32] = { - 0, 8, 16, 25, 33, 41, 49, 58, - 66, 74, 82, 90, 99, 107, 115, 123, - 132, 140, 148, 156, 165, 173, 181, 189, - 197, 206, 214, 222, 230, 239, 247, 255 -}; - - - -LOCAL(int) -read_byte (tga_source_ptr sinfo) -/* Read next byte from Targa file */ -{ - register FILE *infile = sinfo->pub.input_file; - register int c; - - if ((c = getc(infile)) == EOF) - ERREXIT(sinfo->cinfo, JERR_INPUT_EOF); - return c; -} - - -LOCAL(void) -read_colormap (tga_source_ptr sinfo, int cmaplen, int mapentrysize) -/* Read the colormap from a Targa file */ -{ - int i; - - /* Presently only handles 24-bit BGR format */ - if (mapentrysize != 24) - ERREXIT(sinfo->cinfo, JERR_TGA_BADCMAP); - - for (i = 0; i < cmaplen; i++) { - sinfo->colormap[2][i] = (JSAMPLE) read_byte(sinfo); - sinfo->colormap[1][i] = (JSAMPLE) read_byte(sinfo); - sinfo->colormap[0][i] = (JSAMPLE) read_byte(sinfo); - } -} - - -/* - * read_pixel methods: get a single pixel from Targa file into tga_pixel[] - */ - -METHODDEF(void) -read_non_rle_pixel (tga_source_ptr sinfo) -/* Read one Targa pixel from the input file; no RLE expansion */ -{ - register FILE *infile = sinfo->pub.input_file; - register int i; - - for (i = 0; i < sinfo->pixel_size; i++) { - sinfo->tga_pixel[i] = (U_CHAR) getc(infile); - } -} - - -METHODDEF(void) -read_rle_pixel (tga_source_ptr sinfo) -/* Read one Targa pixel from the input file, expanding RLE data as needed */ -{ - register FILE *infile = sinfo->pub.input_file; - register int i; - - /* Duplicate previously read pixel? */ - if (sinfo->dup_pixel_count > 0) { - sinfo->dup_pixel_count--; - return; - } - - /* Time to read RLE block header? */ - if (--sinfo->block_count < 0) { /* decrement pixels remaining in block */ - i = read_byte(sinfo); - if (i & 0x80) { /* Start of duplicate-pixel block? */ - sinfo->dup_pixel_count = i & 0x7F; /* number of dups after this one */ - sinfo->block_count = 0; /* then read new block header */ - } else { - sinfo->block_count = i & 0x7F; /* number of pixels after this one */ - } - } - - /* Read next pixel */ - for (i = 0; i < sinfo->pixel_size; i++) { - sinfo->tga_pixel[i] = (U_CHAR) getc(infile); - } -} - - -/* - * Read one row of pixels. - * - * We provide several different versions depending on input file format. - */ - - -METHODDEF(JDIMENSION) -get_8bit_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading 8-bit grayscale pixels */ -{ - tga_source_ptr source = (tga_source_ptr) sinfo; - register JSAMPROW ptr; - register JDIMENSION col; - - ptr = source->pub.buffer[0]; - for (col = cinfo->image_width; col > 0; col--) { - (*source->read_pixel) (source); /* Load next pixel into tga_pixel */ - *ptr++ = (JSAMPLE) UCH(source->tga_pixel[0]); - } - return 1; -} - -METHODDEF(JDIMENSION) -get_8bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading 8-bit colormap indexes */ -{ - tga_source_ptr source = (tga_source_ptr) sinfo; - register int t; - register JSAMPROW ptr; - register JDIMENSION col; - register JSAMPARRAY colormap = source->colormap; - - ptr = source->pub.buffer[0]; - for (col = cinfo->image_width; col > 0; col--) { - (*source->read_pixel) (source); /* Load next pixel into tga_pixel */ - t = UCH(source->tga_pixel[0]); - *ptr++ = colormap[0][t]; - *ptr++ = colormap[1][t]; - *ptr++ = colormap[2][t]; - } - return 1; -} - -METHODDEF(JDIMENSION) -get_16bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading 16-bit pixels */ -{ - tga_source_ptr source = (tga_source_ptr) sinfo; - register int t; - register JSAMPROW ptr; - register JDIMENSION col; - - ptr = source->pub.buffer[0]; - for (col = cinfo->image_width; col > 0; col--) { - (*source->read_pixel) (source); /* Load next pixel into tga_pixel */ - t = UCH(source->tga_pixel[0]); - t += UCH(source->tga_pixel[1]) << 8; - /* We expand 5 bit data to 8 bit sample width. - * The format of the 16-bit (LSB first) input word is - * xRRRRRGGGGGBBBBB - */ - ptr[2] = (JSAMPLE) c5to8bits[t & 0x1F]; - t >>= 5; - ptr[1] = (JSAMPLE) c5to8bits[t & 0x1F]; - t >>= 5; - ptr[0] = (JSAMPLE) c5to8bits[t & 0x1F]; - ptr += 3; - } - return 1; -} - -METHODDEF(JDIMENSION) -get_24bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading 24-bit pixels */ -{ - tga_source_ptr source = (tga_source_ptr) sinfo; - register JSAMPROW ptr; - register JDIMENSION col; - - ptr = source->pub.buffer[0]; - for (col = cinfo->image_width; col > 0; col--) { - (*source->read_pixel) (source); /* Load next pixel into tga_pixel */ - *ptr++ = (JSAMPLE) UCH(source->tga_pixel[2]); /* change BGR to RGB order */ - *ptr++ = (JSAMPLE) UCH(source->tga_pixel[1]); - *ptr++ = (JSAMPLE) UCH(source->tga_pixel[0]); - } - return 1; -} - -/* - * Targa also defines a 32-bit pixel format with order B,G,R,A. - * We presently ignore the attribute byte, so the code for reading - * these pixels is identical to the 24-bit routine above. - * This works because the actual pixel length is only known to read_pixel. - */ - -#define get_32bit_row get_24bit_row - - -/* - * This method is for re-reading the input data in standard top-down - * row order. The entire image has already been read into whole_image - * with proper conversion of pixel format, but it's in a funny row order. - */ - -METHODDEF(JDIMENSION) -get_memory_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - tga_source_ptr source = (tga_source_ptr) sinfo; - JDIMENSION source_row; - - /* Compute row of source that maps to current_row of normal order */ - /* For now, assume image is bottom-up and not interlaced. */ - /* NEEDS WORK to support interlaced images! */ - source_row = cinfo->image_height - source->current_row - 1; - - /* Fetch that row from virtual array */ - source->pub.buffer = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, source->whole_image, - source_row, (JDIMENSION) 1, FALSE); - - source->current_row++; - return 1; -} - - -/* - * This method loads the image into whole_image during the first call on - * get_pixel_rows. The get_pixel_rows pointer is then adjusted to call - * get_memory_row on subsequent calls. - */ - -METHODDEF(JDIMENSION) -preload_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - tga_source_ptr source = (tga_source_ptr) sinfo; - JDIMENSION row; - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; - - /* Read the data into a virtual array in input-file row order. */ - for (row = 0; row < cinfo->image_height; row++) { - if (progress != NULL) { - progress->pub.pass_counter = (long) row; - progress->pub.pass_limit = (long) cinfo->image_height; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } - source->pub.buffer = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, source->whole_image, row, (JDIMENSION) 1, TRUE); - (*source->get_pixel_rows) (cinfo, sinfo); - } - if (progress != NULL) - progress->completed_extra_passes++; - - /* Set up to read from the virtual array in unscrambled order */ - source->pub.get_pixel_rows = get_memory_row; - source->current_row = 0; - /* And read the first row */ - return get_memory_row(cinfo, sinfo); -} - - -/* - * Read the file header; return image size and component count. - */ - -METHODDEF(void) -start_input_tga (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - tga_source_ptr source = (tga_source_ptr) sinfo; - U_CHAR targaheader[18]; - int idlen, cmaptype, subtype, flags, interlace_type, components; - unsigned int width, height, maplen; - boolean is_bottom_up; - -#define GET_2B(offset) ((unsigned int) UCH(targaheader[offset]) + \ - (((unsigned int) UCH(targaheader[offset+1])) << 8)) - - if (! ReadOK(source->pub.input_file, targaheader, 18)) - ERREXIT(cinfo, JERR_INPUT_EOF); - - /* Pretend "15-bit" pixels are 16-bit --- we ignore attribute bit anyway */ - if (targaheader[16] == 15) - targaheader[16] = 16; - - idlen = UCH(targaheader[0]); - cmaptype = UCH(targaheader[1]); - subtype = UCH(targaheader[2]); - maplen = GET_2B(5); - width = GET_2B(12); - height = GET_2B(14); - source->pixel_size = UCH(targaheader[16]) >> 3; - flags = UCH(targaheader[17]); /* Image Descriptor byte */ - - is_bottom_up = ((flags & 0x20) == 0); /* bit 5 set => top-down */ - interlace_type = flags >> 6; /* bits 6/7 are interlace code */ - - if (cmaptype > 1 || /* cmaptype must be 0 or 1 */ - source->pixel_size < 1 || source->pixel_size > 4 || - (UCH(targaheader[16]) & 7) != 0 || /* bits/pixel must be multiple of 8 */ - interlace_type != 0) /* currently don't allow interlaced image */ - ERREXIT(cinfo, JERR_TGA_BADPARMS); - - if (subtype > 8) { - /* It's an RLE-coded file */ - source->read_pixel = read_rle_pixel; - source->block_count = source->dup_pixel_count = 0; - subtype -= 8; - } else { - /* Non-RLE file */ - source->read_pixel = read_non_rle_pixel; - } - - /* Now should have subtype 1, 2, or 3 */ - components = 3; /* until proven different */ - cinfo->in_color_space = JCS_RGB; - - switch (subtype) { - case 1: /* Colormapped image */ - if (source->pixel_size == 1 && cmaptype == 1) - source->get_pixel_rows = get_8bit_row; - else - ERREXIT(cinfo, JERR_TGA_BADPARMS); - TRACEMS2(cinfo, 1, JTRC_TGA_MAPPED, width, height); - break; - case 2: /* RGB image */ - switch (source->pixel_size) { - case 2: - source->get_pixel_rows = get_16bit_row; - break; - case 3: - source->get_pixel_rows = get_24bit_row; - break; - case 4: - source->get_pixel_rows = get_32bit_row; - break; - default: - ERREXIT(cinfo, JERR_TGA_BADPARMS); - break; - } - TRACEMS2(cinfo, 1, JTRC_TGA, width, height); - break; - case 3: /* Grayscale image */ - components = 1; - cinfo->in_color_space = JCS_GRAYSCALE; - if (source->pixel_size == 1) - source->get_pixel_rows = get_8bit_gray_row; - else - ERREXIT(cinfo, JERR_TGA_BADPARMS); - TRACEMS2(cinfo, 1, JTRC_TGA_GRAY, width, height); - break; - default: - ERREXIT(cinfo, JERR_TGA_BADPARMS); - break; - } - - if (is_bottom_up) { - /* Create a virtual array to buffer the upside-down image. */ - source->whole_image = (*cinfo->mem->request_virt_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, - (JDIMENSION) width * components, (JDIMENSION) height, (JDIMENSION) 1); - if (cinfo->progress != NULL) { - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; - progress->total_extra_passes++; /* count file input as separate pass */ - } - /* source->pub.buffer will point to the virtual array. */ - source->pub.buffer_height = 1; /* in case anyone looks at it */ - source->pub.get_pixel_rows = preload_image; - } else { - /* Don't need a virtual array, but do need a one-row input buffer. */ - source->whole_image = NULL; - source->pub.buffer = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) width * components, (JDIMENSION) 1); - source->pub.buffer_height = 1; - source->pub.get_pixel_rows = source->get_pixel_rows; - } - - while (idlen--) /* Throw away ID field */ - (void) read_byte(source); - - if (maplen > 0) { - if (maplen > 256 || GET_2B(3) != 0) - ERREXIT(cinfo, JERR_TGA_BADCMAP); - /* Allocate space to store the colormap */ - source->colormap = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, (JDIMENSION) maplen, (JDIMENSION) 3); - /* and read it from the file */ - read_colormap(source, (int) maplen, UCH(targaheader[7])); - } else { - if (cmaptype) /* but you promised a cmap! */ - ERREXIT(cinfo, JERR_TGA_BADPARMS); - source->colormap = NULL; - } - - cinfo->input_components = components; - cinfo->data_precision = 8; - cinfo->image_width = width; - cinfo->image_height = height; -} - - -/* - * Finish up at the end of the file. - */ - -METHODDEF(void) -finish_input_tga (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - /* no work */ -} - - -/* - * The module selection routine for Targa format input. - */ - -GLOBAL(cjpeg_source_ptr) -jinit_read_targa (j_compress_ptr cinfo) -{ - tga_source_ptr source; - - /* Create module interface object */ - source = (tga_source_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(tga_source_struct)); - source->cinfo = cinfo; /* make back link for subroutines */ - /* Fill in method ptrs, except get_pixel_rows which start_input sets */ - source->pub.start_input = start_input_tga; - source->pub.finish_input = finish_input_tga; - - return (cjpeg_source_ptr) source; -} - -#endif /* TARGA_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/structure.doc b/irrlicht-1.6/source/Irrlicht/jpeglib/structure.doc deleted file mode 100644 index 4179e485f..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/structure.doc +++ /dev/null @@ -1,948 +0,0 @@ -IJG JPEG LIBRARY: SYSTEM ARCHITECTURE - -Copyright (C) 1991-1995, Thomas G. Lane. -This file is part of the Independent JPEG Group's software. -For conditions of distribution and use, see the accompanying README file. - - -This file provides an overview of the architecture of the IJG JPEG software; -that is, the functions of the various modules in the system and the interfaces -between modules. For more precise details about any data structure or calling -convention, see the include files and comments in the source code. - -We assume that the reader is already somewhat familiar with the JPEG standard. -The README file includes references for learning about JPEG. The file -libjpeg.doc describes the library from the viewpoint of an application -programmer using the library; it's best to read that file before this one. -Also, the file coderules.doc describes the coding style conventions we use. - -In this document, JPEG-specific terminology follows the JPEG standard: - A "component" means a color channel, e.g., Red or Luminance. - A "sample" is a single component value (i.e., one number in the image data). - A "coefficient" is a frequency coefficient (a DCT transform output number). - A "block" is an 8x8 group of samples or coefficients. - An "MCU" (minimum coded unit) is an interleaved set of blocks of size - determined by the sampling factors, or a single block in a - noninterleaved scan. -We do not use the terms "pixel" and "sample" interchangeably. When we say -pixel, we mean an element of the full-size image, while a sample is an element -of the downsampled image. Thus the number of samples may vary across -components while the number of pixels does not. (This terminology is not used -rigorously throughout the code, but it is used in places where confusion would -otherwise result.) - - -*** System features *** - -The IJG distribution contains two parts: - * A subroutine library for JPEG compression and decompression. - * cjpeg/djpeg, two sample applications that use the library to transform - JFIF JPEG files to and from several other image formats. -cjpeg/djpeg are of no great intellectual complexity: they merely add a simple -command-line user interface and I/O routines for several uncompressed image -formats. This document concentrates on the library itself. - -We desire the library to be capable of supporting all JPEG baseline, extended -sequential, and progressive DCT processes. Hierarchical processes are not -supported. - -The library does not support the lossless (spatial) JPEG process. Lossless -JPEG shares little or no code with lossy JPEG, and would normally be used -without the extensive pre- and post-processing provided by this library. -We feel that lossless JPEG is better handled by a separate library. - -Within these limits, any set of compression parameters allowed by the JPEG -spec should be readable for decompression. (We can be more restrictive about -what formats we can generate.) Although the system design allows for all -parameter values, some uncommon settings are not yet implemented and may -never be; nonintegral sampling ratios are the prime example. Furthermore, -we treat 8-bit vs. 12-bit data precision as a compile-time switch, not a -run-time option, because most machines can store 8-bit pixels much more -compactly than 12-bit. - -For legal reasons, JPEG arithmetic coding is not currently supported, but -extending the library to include it would be straightforward. - -By itself, the library handles only interchange JPEG datastreams --- in -particular the widely used JFIF file format. The library can be used by -surrounding code to process interchange or abbreviated JPEG datastreams that -are embedded in more complex file formats. (For example, libtiff uses this -library to implement JPEG compression within the TIFF file format.) - -The library includes a substantial amount of code that is not covered by the -JPEG standard but is necessary for typical applications of JPEG. These -functions preprocess the image before JPEG compression or postprocess it after -decompression. They include colorspace conversion, downsampling/upsampling, -and color quantization. This code can be omitted if not needed. - -A wide range of quality vs. speed tradeoffs are possible in JPEG processing, -and even more so in decompression postprocessing. The decompression library -provides multiple implementations that cover most of the useful tradeoffs, -ranging from very-high-quality down to fast-preview operation. On the -compression side we have generally not provided low-quality choices, since -compression is normally less time-critical. It should be understood that the -low-quality modes may not meet the JPEG standard's accuracy requirements; -nonetheless, they are useful for viewers. - - -*** Portability issues *** - -Portability is an essential requirement for the library. The key portability -issues that show up at the level of system architecture are: - -1. Memory usage. We want the code to be able to run on PC-class machines -with limited memory. Images should therefore be processed sequentially (in -strips), to avoid holding the whole image in memory at once. Where a -full-image buffer is necessary, we should be able to use either virtual memory -or temporary files. - -2. Near/far pointer distinction. To run efficiently on 80x86 machines, the -code should distinguish "small" objects (kept in near data space) from -"large" ones (kept in far data space). This is an annoying restriction, but -fortunately it does not impact code quality for less brain-damaged machines, -and the source code clutter turns out to be minimal with sufficient use of -pointer typedefs. - -3. Data precision. We assume that "char" is at least 8 bits, "short" and -"int" at least 16, "long" at least 32. The code will work fine with larger -data sizes, although memory may be used inefficiently in some cases. However, -the JPEG compressed datastream must ultimately appear on external storage as a -sequence of 8-bit bytes if it is to conform to the standard. This may pose a -problem on machines where char is wider than 8 bits. The library represents -compressed data as an array of values of typedef JOCTET. If no data type -exactly 8 bits wide is available, custom data source and data destination -modules must be written to unpack and pack the chosen JOCTET datatype into -8-bit external representation. - - -*** System overview *** - -The compressor and decompressor are each divided into two main sections: -the JPEG compressor or decompressor proper, and the preprocessing or -postprocessing functions. The interface between these two sections is the -image data that the official JPEG spec regards as its input or output: this -data is in the colorspace to be used for compression, and it is downsampled -to the sampling factors to be used. The preprocessing and postprocessing -steps are responsible for converting a normal image representation to or from -this form. (Those few applications that want to deal with YCbCr downsampled -data can skip the preprocessing or postprocessing step.) - -Looking more closely, the compressor library contains the following main -elements: - - Preprocessing: - * Color space conversion (e.g., RGB to YCbCr). - * Edge expansion and downsampling. Optionally, this step can do simple - smoothing --- this is often helpful for low-quality source data. - JPEG proper: - * MCU assembly, DCT, quantization. - * Entropy coding (sequential or progressive, Huffman or arithmetic). - -In addition to these modules we need overall control, marker generation, -and support code (memory management & error handling). There is also a -module responsible for physically writing the output data --- typically -this is just an interface to fwrite(), but some applications may need to -do something else with the data. - -The decompressor library contains the following main elements: - - JPEG proper: - * Entropy decoding (sequential or progressive, Huffman or arithmetic). - * Dequantization, inverse DCT, MCU disassembly. - Postprocessing: - * Upsampling. Optionally, this step may be able to do more general - rescaling of the image. - * Color space conversion (e.g., YCbCr to RGB). This step may also - provide gamma adjustment [ currently it does not ]. - * Optional color quantization (e.g., reduction to 256 colors). - * Optional color precision reduction (e.g., 24-bit to 15-bit color). - [This feature is not currently implemented.] - -We also need overall control, marker parsing, and a data source module. -The support code (memory management & error handling) can be shared with -the compression half of the library. - -There may be several implementations of each of these elements, particularly -in the decompressor, where a wide range of speed/quality tradeoffs is very -useful. It must be understood that some of the best speedups involve -merging adjacent steps in the pipeline. For example, upsampling, color space -conversion, and color quantization might all be done at once when using a -low-quality ordered-dither technique. The system architecture is designed to -allow such merging where appropriate. - - -Note: it is convenient to regard edge expansion (padding to block boundaries) -as a preprocessing/postprocessing function, even though the JPEG spec includes -it in compression/decompression. We do this because downsampling/upsampling -can be simplified a little if they work on padded data: it's not necessary to -have special cases at the right and bottom edges. Therefore the interface -buffer is always an integral number of blocks wide and high, and we expect -compression preprocessing to pad the source data properly. Padding will occur -only to the next block (8-sample) boundary. In an interleaved-scan situation, -additional dummy blocks may be used to fill out MCUs, but the MCU assembly and -disassembly logic will create or discard these blocks internally. (This is -advantageous for speed reasons, since we avoid DCTing the dummy blocks. -It also permits a small reduction in file size, because the compressor can -choose dummy block contents so as to minimize their size in compressed form. -Finally, it makes the interface buffer specification independent of whether -the file is actually interleaved or not.) Applications that wish to deal -directly with the downsampled data must provide similar buffering and padding -for odd-sized images. - - -*** Poor man's object-oriented programming *** - -It should be clear by now that we have a lot of quasi-independent processing -steps, many of which have several possible behaviors. To avoid cluttering the -code with lots of switch statements, we use a simple form of object-style -programming to separate out the different possibilities. - -For example, two different color quantization algorithms could be implemented -as two separate modules that present the same external interface; at runtime, -the calling code will access the proper module indirectly through an "object". - -We can get the limited features we need while staying within portable C. -The basic tool is a function pointer. An "object" is just a struct -containing one or more function pointer fields, each of which corresponds to -a method name in real object-oriented languages. During initialization we -fill in the function pointers with references to whichever module we have -determined we need to use in this run. Then invocation of the module is done -by indirecting through a function pointer; on most machines this is no more -expensive than a switch statement, which would be the only other way of -making the required run-time choice. The really significant benefit, of -course, is keeping the source code clean and well structured. - -We can also arrange to have private storage that varies between different -implementations of the same kind of object. We do this by making all the -module-specific object structs be separately allocated entities, which will -be accessed via pointers in the master compression or decompression struct. -The "public" fields or methods for a given kind of object are specified by -a commonly known struct. But a module's initialization code can allocate -a larger struct that contains the common struct as its first member, plus -additional private fields. With appropriate pointer casting, the module's -internal functions can access these private fields. (For a simple example, -see jdatadst.c, which implements the external interface specified by struct -jpeg_destination_mgr, but adds extra fields.) - -(Of course this would all be a lot easier if we were using C++, but we are -not yet prepared to assume that everyone has a C++ compiler.) - -An important benefit of this scheme is that it is easy to provide multiple -versions of any method, each tuned to a particular case. While a lot of -precalculation might be done to select an optimal implementation of a method, -the cost per invocation is constant. For example, the upsampling step might -have a "generic" method, plus one or more "hardwired" methods for the most -popular sampling factors; the hardwired methods would be faster because they'd -use straight-line code instead of for-loops. The cost to determine which -method to use is paid only once, at startup, and the selection criteria are -hidden from the callers of the method. - -This plan differs a little bit from usual object-oriented structures, in that -only one instance of each object class will exist during execution. The -reason for having the class structure is that on different runs we may create -different instances (choose to execute different modules). You can think of -the term "method" as denoting the common interface presented by a particular -set of interchangeable functions, and "object" as denoting a group of related -methods, or the total shared interface behavior of a group of modules. - - -*** Overall control structure *** - -We previously mentioned the need for overall control logic in the compression -and decompression libraries. In IJG implementations prior to v5, overall -control was mostly provided by "pipeline control" modules, which proved to be -large, unwieldy, and hard to understand. To improve the situation, the -control logic has been subdivided into multiple modules. The control modules -consist of: - -1. Master control for module selection and initialization. This has two -responsibilities: - - 1A. Startup initialization at the beginning of image processing. - The individual processing modules to be used in this run are selected - and given initialization calls. - - 1B. Per-pass control. This determines how many passes will be performed - and calls each active processing module to configure itself - appropriately at the beginning of each pass. End-of-pass processing, - where necessary, is also invoked from the master control module. - - Method selection is partially distributed, in that a particular processing - module may contain several possible implementations of a particular method, - which it will select among when given its initialization call. The master - control code need only be concerned with decisions that affect more than - one module. - -2. Data buffering control. A separate control module exists for each - inter-processing-step data buffer. This module is responsible for - invoking the processing steps that write or read that data buffer. - -Each buffer controller sees the world as follows: - -input data => processing step A => buffer => processing step B => output data - | | | - ------------------ controller ------------------ - -The controller knows the dataflow requirements of steps A and B: how much data -they want to accept in one chunk and how much they output in one chunk. Its -function is to manage its buffer and call A and B at the proper times. - -A data buffer control module may itself be viewed as a processing step by a -higher-level control module; thus the control modules form a binary tree with -elementary processing steps at the leaves of the tree. - -The control modules are objects. A considerable amount of flexibility can -be had by replacing implementations of a control module. For example: -* Merging of adjacent steps in the pipeline is done by replacing a control - module and its pair of processing-step modules with a single processing- - step module. (Hence the possible merges are determined by the tree of - control modules.) -* In some processing modes, a given interstep buffer need only be a "strip" - buffer large enough to accommodate the desired data chunk sizes. In other - modes, a full-image buffer is needed and several passes are required. - The control module determines which kind of buffer is used and manipulates - virtual array buffers as needed. One or both processing steps may be - unaware of the multi-pass behavior. - -In theory, we might be able to make all of the data buffer controllers -interchangeable and provide just one set of implementations for all. In -practice, each one contains considerable special-case processing for its -particular job. The buffer controller concept should be regarded as an -overall system structuring principle, not as a complete description of the -task performed by any one controller. - - -*** Compression object structure *** - -Here is a sketch of the logical structure of the JPEG compression library: - - |-- Colorspace conversion - |-- Preprocessing controller --| - | |-- Downsampling -Main controller --| - | |-- Forward DCT, quantize - |-- Coefficient controller --| - |-- Entropy encoding - -This sketch also describes the flow of control (subroutine calls) during -typical image data processing. Each of the components shown in the diagram is -an "object" which may have several different implementations available. One -or more source code files contain the actual implementation(s) of each object. - -The objects shown above are: - -* Main controller: buffer controller for the subsampled-data buffer, which - holds the preprocessed input data. This controller invokes preprocessing to - fill the subsampled-data buffer, and JPEG compression to empty it. There is - usually no need for a full-image buffer here; a strip buffer is adequate. - -* Preprocessing controller: buffer controller for the downsampling input data - buffer, which lies between colorspace conversion and downsampling. Note - that a unified conversion/downsampling module would probably replace this - controller entirely. - -* Colorspace conversion: converts application image data into the desired - JPEG color space; also changes the data from pixel-interleaved layout to - separate component planes. Processes one pixel row at a time. - -* Downsampling: performs reduction of chroma components as required. - Optionally may perform pixel-level smoothing as well. Processes a "row - group" at a time, where a row group is defined as Vmax pixel rows of each - component before downsampling, and Vk sample rows afterwards (remember Vk - differs across components). Some downsampling or smoothing algorithms may - require context rows above and below the current row group; the - preprocessing controller is responsible for supplying these rows via proper - buffering. The downsampler is responsible for edge expansion at the right - edge (i.e., extending each sample row to a multiple of 8 samples); but the - preprocessing controller is responsible for vertical edge expansion (i.e., - duplicating the bottom sample row as needed to make a multiple of 8 rows). - -* Coefficient controller: buffer controller for the DCT-coefficient data. - This controller handles MCU assembly, including insertion of dummy DCT - blocks when needed at the right or bottom edge. When performing - Huffman-code optimization or emitting a multiscan JPEG file, this - controller is responsible for buffering the full image. The equivalent of - one fully interleaved MCU row of subsampled data is processed per call, - even when the JPEG file is noninterleaved. - -* Forward DCT and quantization: Perform DCT, quantize, and emit coefficients. - Works on one or more DCT blocks at a time. (Note: the coefficients are now - emitted in normal array order, which the entropy encoder is expected to - convert to zigzag order as necessary. Prior versions of the IJG code did - the conversion to zigzag order within the quantization step.) - -* Entropy encoding: Perform Huffman or arithmetic entropy coding and emit the - coded data to the data destination module. Works on one MCU per call. - For progressive JPEG, the same DCT blocks are fed to the entropy coder - during each pass, and the coder must emit the appropriate subset of - coefficients. - -In addition to the above objects, the compression library includes these -objects: - -* Master control: determines the number of passes required, controls overall - and per-pass initialization of the other modules. - -* Marker writing: generates JPEG markers (except for RSTn, which is emitted - by the entropy encoder when needed). - -* Data destination manager: writes the output JPEG datastream to its final - destination (e.g., a file). The destination manager supplied with the - library knows how to write to a stdio stream; for other behaviors, the - surrounding application may provide its own destination manager. - -* Memory manager: allocates and releases memory, controls virtual arrays - (with backing store management, where required). - -* Error handler: performs formatting and output of error and trace messages; - determines handling of nonfatal errors. The surrounding application may - override some or all of this object's methods to change error handling. - -* Progress monitor: supports output of "percent-done" progress reports. - This object represents an optional callback to the surrounding application: - if wanted, it must be supplied by the application. - -The error handler, destination manager, and progress monitor objects are -defined as separate objects in order to simplify application-specific -customization of the JPEG library. A surrounding application may override -individual methods or supply its own all-new implementation of one of these -objects. The object interfaces for these objects are therefore treated as -part of the application interface of the library, whereas the other objects -are internal to the library. - -The error handler and memory manager are shared by JPEG compression and -decompression; the progress monitor, if used, may be shared as well. - - -*** Decompression object structure *** - -Here is a sketch of the logical structure of the JPEG decompression library: - - |-- Entropy decoding - |-- Coefficient controller --| - | |-- Dequantize, Inverse DCT -Main controller --| - | |-- Upsampling - |-- Postprocessing controller --| |-- Colorspace conversion - |-- Color quantization - |-- Color precision reduction - -As before, this diagram also represents typical control flow. The objects -shown are: - -* Main controller: buffer controller for the subsampled-data buffer, which - holds the output of JPEG decompression proper. This controller's primary - task is to feed the postprocessing procedure. Some upsampling algorithms - may require context rows above and below the current row group; when this - is true, the main controller is responsible for managing its buffer so as - to make context rows available. In the current design, the main buffer is - always a strip buffer; a full-image buffer is never required. - -* Coefficient controller: buffer controller for the DCT-coefficient data. - This controller handles MCU disassembly, including deletion of any dummy - DCT blocks at the right or bottom edge. When reading a multiscan JPEG - file, this controller is responsible for buffering the full image. - (Buffering DCT coefficients, rather than samples, is necessary to support - progressive JPEG.) The equivalent of one fully interleaved MCU row of - subsampled data is processed per call, even when the source JPEG file is - noninterleaved. - -* Entropy decoding: Read coded data from the data source module and perform - Huffman or arithmetic entropy decoding. Works on one MCU per call. - For progressive JPEG decoding, the coefficient controller supplies the prior - coefficients of each MCU (initially all zeroes), which the entropy decoder - modifies in each scan. - -* Dequantization and inverse DCT: like it says. Note that the coefficients - buffered by the coefficient controller have NOT been dequantized; we - merge dequantization and inverse DCT into a single step for speed reasons. - When scaled-down output is asked for, simplified DCT algorithms may be used - that emit only 1x1, 2x2, or 4x4 samples per DCT block, not the full 8x8. - Works on one DCT block at a time. - -* Postprocessing controller: buffer controller for the color quantization - input buffer, when quantization is in use. (Without quantization, this - controller just calls the upsampler.) For two-pass quantization, this - controller is responsible for buffering the full-image data. - -* Upsampling: restores chroma components to full size. (May support more - general output rescaling, too. Note that if undersized DCT outputs have - been emitted by the DCT module, this module must adjust so that properly - sized outputs are created.) Works on one row group at a time. This module - also calls the color conversion module, so its top level is effectively a - buffer controller for the upsampling->color conversion buffer. However, in - all but the highest-quality operating modes, upsampling and color - conversion are likely to be merged into a single step. - -* Colorspace conversion: convert from JPEG color space to output color space, - and change data layout from separate component planes to pixel-interleaved. - Works on one pixel row at a time. - -* Color quantization: reduce the data to colormapped form, using either an - externally specified colormap or an internally generated one. This module - is not used for full-color output. Works on one pixel row at a time; may - require two passes to generate a color map. Note that the output will - always be a single component representing colormap indexes. In the current - design, the output values are JSAMPLEs, so an 8-bit compilation cannot - quantize to more than 256 colors. This is unlikely to be a problem in - practice. - -* Color reduction: this module handles color precision reduction, e.g., - generating 15-bit color (5 bits/primary) from JPEG's 24-bit output. - Not quite clear yet how this should be handled... should we merge it with - colorspace conversion??? - -Note that some high-speed operating modes might condense the entire -postprocessing sequence to a single module (upsample, color convert, and -quantize in one step). - -In addition to the above objects, the decompression library includes these -objects: - -* Master control: determines the number of passes required, controls overall - and per-pass initialization of the other modules. This is subdivided into - input and output control: jdinput.c controls only input-side processing, - while jdmaster.c handles overall initialization and output-side control. - -* Marker reading: decodes JPEG markers (except for RSTn). - -* Data source manager: supplies the input JPEG datastream. The source - manager supplied with the library knows how to read from a stdio stream; - for other behaviors, the surrounding application may provide its own source - manager. - -* Memory manager: same as for compression library. - -* Error handler: same as for compression library. - -* Progress monitor: same as for compression library. - -As with compression, the data source manager, error handler, and progress -monitor are candidates for replacement by a surrounding application. - - -*** Decompression input and output separation *** - -To support efficient incremental display of progressive JPEG files, the -decompressor is divided into two sections that can run independently: - -1. Data input includes marker parsing, entropy decoding, and input into the - coefficient controller's DCT coefficient buffer. Note that this - processing is relatively cheap and fast. - -2. Data output reads from the DCT coefficient buffer and performs the IDCT - and all postprocessing steps. - -For a progressive JPEG file, the data input processing is allowed to get -arbitrarily far ahead of the data output processing. (This occurs only -if the application calls jpeg_consume_input(); otherwise input and output -run in lockstep, since the input section is called only when the output -section needs more data.) In this way the application can avoid making -extra display passes when data is arriving faster than the display pass -can run. Furthermore, it is possible to abort an output pass without -losing anything, since the coefficient buffer is read-only as far as the -output section is concerned. See libjpeg.doc for more detail. - -A full-image coefficient array is only created if the JPEG file has multiple -scans (or if the application specifies buffered-image mode anyway). When -reading a single-scan file, the coefficient controller normally creates only -a one-MCU buffer, so input and output processing must run in lockstep in this -case. jpeg_consume_input() is effectively a no-op in this situation. - -The main impact of dividing the decompressor in this fashion is that we must -be very careful with shared variables in the cinfo data structure. Each -variable that can change during the course of decompression must be -classified as belonging to data input or data output, and each section must -look only at its own variables. For example, the data output section may not -depend on any of the variables that describe the current scan in the JPEG -file, because these may change as the data input section advances into a new -scan. - -The progress monitor is (somewhat arbitrarily) defined to treat input of the -file as one pass when buffered-image mode is not used, and to ignore data -input work completely when buffered-image mode is used. Note that the -library has no reliable way to predict the number of passes when dealing -with a progressive JPEG file, nor can it predict the number of output passes -in buffered-image mode. So the work estimate is inherently bogus anyway. - -No comparable division is currently made in the compression library, because -there isn't any real need for it. - - -*** Data formats *** - -Arrays of pixel sample values use the following data structure: - - typedef something JSAMPLE; a pixel component value, 0..MAXJSAMPLE - typedef JSAMPLE *JSAMPROW; ptr to a row of samples - typedef JSAMPROW *JSAMPARRAY; ptr to a list of rows - typedef JSAMPARRAY *JSAMPIMAGE; ptr to a list of color-component arrays - -The basic element type JSAMPLE will typically be one of unsigned char, -(signed) char, or short. Short will be used if samples wider than 8 bits are -to be supported (this is a compile-time option). Otherwise, unsigned char is -used if possible. If the compiler only supports signed chars, then it is -necessary to mask off the value when reading. Thus, all reads of JSAMPLE -values must be coded as "GETJSAMPLE(value)", where the macro will be defined -as "((value) & 0xFF)" on signed-char machines and "((int) (value))" elsewhere. - -With these conventions, JSAMPLE values can be assumed to be >= 0. This helps -simplify correct rounding during downsampling, etc. The JPEG standard's -specification that sample values run from -128..127 is accommodated by -subtracting 128 just as the sample value is copied into the source array for -the DCT step (this will be an array of signed ints). Similarly, during -decompression the output of the IDCT step will be immediately shifted back to -0..255. (NB: different values are required when 12-bit samples are in use. -The code is written in terms of MAXJSAMPLE and CENTERJSAMPLE, which will be -defined as 255 and 128 respectively in an 8-bit implementation, and as 4095 -and 2048 in a 12-bit implementation.) - -We use a pointer per row, rather than a two-dimensional JSAMPLE array. This -choice costs only a small amount of memory and has several benefits: -* Code using the data structure doesn't need to know the allocated width of - the rows. This simplifies edge expansion/compression, since we can work - in an array that's wider than the logical picture width. -* Indexing doesn't require multiplication; this is a performance win on many - machines. -* Arrays with more than 64K total elements can be supported even on machines - where malloc() cannot allocate chunks larger than 64K. -* The rows forming a component array may be allocated at different times - without extra copying. This trick allows some speedups in smoothing steps - that need access to the previous and next rows. - -Note that each color component is stored in a separate array; we don't use the -traditional layout in which the components of a pixel are stored together. -This simplifies coding of modules that work on each component independently, -because they don't need to know how many components there are. Furthermore, -we can read or write each component to a temporary file independently, which -is helpful when dealing with noninterleaved JPEG files. - -In general, a specific sample value is accessed by code such as - GETJSAMPLE(image[colorcomponent][row][col]) -where col is measured from the image left edge, but row is measured from the -first sample row currently in memory. Either of the first two indexings can -be precomputed by copying the relevant pointer. - - -Since most image-processing applications prefer to work on images in which -the components of a pixel are stored together, the data passed to or from the -surrounding application uses the traditional convention: a single pixel is -represented by N consecutive JSAMPLE values, and an image row is an array of -(# of color components)*(image width) JSAMPLEs. One or more rows of data can -be represented by a pointer of type JSAMPARRAY in this scheme. This scheme is -converted to component-wise storage inside the JPEG library. (Applications -that want to skip JPEG preprocessing or postprocessing will have to contend -with component-wise storage.) - - -Arrays of DCT-coefficient values use the following data structure: - - typedef short JCOEF; a 16-bit signed integer - typedef JCOEF JBLOCK[DCTSIZE2]; an 8x8 block of coefficients - typedef JBLOCK *JBLOCKROW; ptr to one horizontal row of 8x8 blocks - typedef JBLOCKROW *JBLOCKARRAY; ptr to a list of such rows - typedef JBLOCKARRAY *JBLOCKIMAGE; ptr to a list of color component arrays - -The underlying type is at least a 16-bit signed integer; while "short" is big -enough on all machines of interest, on some machines it is preferable to use -"int" for speed reasons, despite the storage cost. Coefficients are grouped -into 8x8 blocks (but we always use #defines DCTSIZE and DCTSIZE2 rather than -"8" and "64"). - -The contents of a coefficient block may be in either "natural" or zigzagged -order, and may be true values or divided by the quantization coefficients, -depending on where the block is in the processing pipeline. In the current -library, coefficient blocks are kept in natural order everywhere; the entropy -codecs zigzag or dezigzag the data as it is written or read. The blocks -contain quantized coefficients everywhere outside the DCT/IDCT subsystems. -(This latter decision may need to be revisited to support variable -quantization a la JPEG Part 3.) - -Notice that the allocation unit is now a row of 8x8 blocks, corresponding to -eight rows of samples. Otherwise the structure is much the same as for -samples, and for the same reasons. - -On machines where malloc() can't handle a request bigger than 64Kb, this data -structure limits us to rows of less than 512 JBLOCKs, or a picture width of -4000+ pixels. This seems an acceptable restriction. - - -On 80x86 machines, the bottom-level pointer types (JSAMPROW and JBLOCKROW) -must be declared as "far" pointers, but the upper levels can be "near" -(implying that the pointer lists are allocated in the DS segment). -We use a #define symbol FAR, which expands to the "far" keyword when -compiling on 80x86 machines and to nothing elsewhere. - - -*** Suspendable processing *** - -In some applications it is desirable to use the JPEG library as an -incremental, memory-to-memory filter. In this situation the data source or -destination may be a limited-size buffer, and we can't rely on being able to -empty or refill the buffer at arbitrary times. Instead the application would -like to have control return from the library at buffer overflow/underrun, and -then resume compression or decompression at a later time. - -This scenario is supported for simple cases. (For anything more complex, we -recommend that the application "bite the bullet" and develop real multitasking -capability.) The libjpeg.doc file goes into more detail about the usage and -limitations of this capability; here we address the implications for library -structure. - -The essence of the problem is that the entropy codec (coder or decoder) must -be prepared to stop at arbitrary times. In turn, the controllers that call -the entropy codec must be able to stop before having produced or consumed all -the data that they normally would handle in one call. That part is reasonably -straightforward: we make the controller call interfaces include "progress -counters" which indicate the number of data chunks successfully processed, and -we require callers to test the counter rather than just assume all of the data -was processed. - -Rather than trying to restart at an arbitrary point, the current Huffman -codecs are designed to restart at the beginning of the current MCU after a -suspension due to buffer overflow/underrun. At the start of each call, the -codec's internal state is loaded from permanent storage (in the JPEG object -structures) into local variables. On successful completion of the MCU, the -permanent state is updated. (This copying is not very expensive, and may even -lead to *improved* performance if the local variables can be registerized.) -If a suspension occurs, the codec simply returns without updating the state, -thus effectively reverting to the start of the MCU. Note that this implies -leaving some data unprocessed in the source/destination buffer (ie, the -compressed partial MCU). The data source/destination module interfaces are -specified so as to make this possible. This also implies that the data buffer -must be large enough to hold a worst-case compressed MCU; a couple thousand -bytes should be enough. - -In a successive-approximation AC refinement scan, the progressive Huffman -decoder has to be able to undo assignments of newly nonzero coefficients if it -suspends before the MCU is complete, since decoding requires distinguishing -previously-zero and previously-nonzero coefficients. This is a bit tedious -but probably won't have much effect on performance. Other variants of Huffman -decoding need not worry about this, since they will just store the same values -again if forced to repeat the MCU. - -This approach would probably not work for an arithmetic codec, since its -modifiable state is quite large and couldn't be copied cheaply. Instead it -would have to suspend and resume exactly at the point of the buffer end. - -The JPEG marker reader is designed to cope with suspension at an arbitrary -point. It does so by backing up to the start of the marker parameter segment, -so the data buffer must be big enough to hold the largest marker of interest. -Again, a couple KB should be adequate. (A special "skip" convention is used -to bypass COM and APPn markers, so these can be larger than the buffer size -without causing problems; otherwise a 64K buffer would be needed in the worst -case.) - -The JPEG marker writer currently does *not* cope with suspension. I feel that -this is not necessary; it is much easier simply to require the application to -ensure there is enough buffer space before starting. (An empty 2K buffer is -more than sufficient for the header markers; and ensuring there are a dozen or -two bytes available before calling jpeg_finish_compress() will suffice for the -trailer.) This would not work for writing multi-scan JPEG files, but -we simply do not intend to support that capability with suspension. - - -*** Memory manager services *** - -The JPEG library's memory manager controls allocation and deallocation of -memory, and it manages large "virtual" data arrays on machines where the -operating system does not provide virtual memory. Note that the same -memory manager serves both compression and decompression operations. - -In all cases, allocated objects are tied to a particular compression or -decompression master record, and they will be released when that master -record is destroyed. - -The memory manager does not provide explicit deallocation of objects. -Instead, objects are created in "pools" of free storage, and a whole pool -can be freed at once. This approach helps prevent storage-leak bugs, and -it speeds up operations whenever malloc/free are slow (as they often are). -The pools can be regarded as lifetime identifiers for objects. Two -pools/lifetimes are defined: - * JPOOL_PERMANENT lasts until master record is destroyed - * JPOOL_IMAGE lasts until done with image (JPEG datastream) -Permanent lifetime is used for parameters and tables that should be carried -across from one datastream to another; this includes all application-visible -parameters. Image lifetime is used for everything else. (A third lifetime, -JPOOL_PASS = one processing pass, was originally planned. However it was -dropped as not being worthwhile. The actual usage patterns are such that the -peak memory usage would be about the same anyway; and having per-pass storage -substantially complicates the virtual memory allocation rules --- see below.) - -The memory manager deals with three kinds of object: -1. "Small" objects. Typically these require no more than 10K-20K total. -2. "Large" objects. These may require tens to hundreds of K depending on - image size. Semantically they behave the same as small objects, but we - distinguish them for two reasons: - * On MS-DOS machines, large objects are referenced by FAR pointers, - small objects by NEAR pointers. - * Pool allocation heuristics may differ for large and small objects. - Note that individual "large" objects cannot exceed the size allowed by - type size_t, which may be 64K or less on some machines. -3. "Virtual" objects. These are large 2-D arrays of JSAMPLEs or JBLOCKs - (typically large enough for the entire image being processed). The - memory manager provides stripwise access to these arrays. On machines - without virtual memory, the rest of the array may be swapped out to a - temporary file. - -(Note: JSAMPARRAY and JBLOCKARRAY data structures are a combination of large -objects for the data proper and small objects for the row pointers. For -convenience and speed, the memory manager provides single routines to create -these structures. Similarly, virtual arrays include a small control block -and a JSAMPARRAY or JBLOCKARRAY working buffer, all created with one call.) - -In the present implementation, virtual arrays are only permitted to have image -lifespan. (Permanent lifespan would not be reasonable, and pass lifespan is -not very useful since a virtual array's raison d'etre is to store data for -multiple passes through the image.) We also expect that only "small" objects -will be given permanent lifespan, though this restriction is not required by -the memory manager. - -In a non-virtual-memory machine, some performance benefit can be gained by -making the in-memory buffers for virtual arrays be as large as possible. -(For small images, the buffers might fit entirely in memory, so blind -swapping would be very wasteful.) The memory manager will adjust the height -of the buffers to fit within a prespecified maximum memory usage. In order -to do this in a reasonably optimal fashion, the manager needs to allocate all -of the virtual arrays at once. Therefore, there isn't a one-step allocation -routine for virtual arrays; instead, there is a "request" routine that simply -allocates the control block, and a "realize" routine (called just once) that -determines space allocation and creates all of the actual buffers. The -realize routine must allow for space occupied by non-virtual large objects. -(We don't bother to factor in the space needed for small objects, on the -grounds that it isn't worth the trouble.) - -To support all this, we establish the following protocol for doing business -with the memory manager: - 1. Modules must request virtual arrays (which may have only image lifespan) - during the initial setup phase, i.e., in their jinit_xxx routines. - 2. All "large" objects (including JSAMPARRAYs and JBLOCKARRAYs) must also be - allocated during initial setup. - 3. realize_virt_arrays will be called at the completion of initial setup. - The above conventions ensure that sufficient information is available - for it to choose a good size for virtual array buffers. -Small objects of any lifespan may be allocated at any time. We expect that -the total space used for small objects will be small enough to be negligible -in the realize_virt_arrays computation. - -In a virtual-memory machine, we simply pretend that the available space is -infinite, thus causing realize_virt_arrays to decide that it can allocate all -the virtual arrays as full-size in-memory buffers. The overhead of the -virtual-array access protocol is very small when no swapping occurs. - -A virtual array can be specified to be "pre-zeroed"; when this flag is set, -never-yet-written sections of the array are set to zero before being made -available to the caller. If this flag is not set, never-written sections -of the array contain garbage. (This feature exists primarily because the -equivalent logic would otherwise be needed in jdcoefct.c for progressive -JPEG mode; we may as well make it available for possible other uses.) - -The first write pass on a virtual array is required to occur in top-to-bottom -order; read passes, as well as any write passes after the first one, may -access the array in any order. This restriction exists partly to simplify -the virtual array control logic, and partly because some file systems may not -support seeking beyond the current end-of-file in a temporary file. The main -implication of this restriction is that rearrangement of rows (such as -converting top-to-bottom data order to bottom-to-top) must be handled while -reading data out of the virtual array, not while putting it in. - - -*** Memory manager internal structure *** - -To isolate system dependencies as much as possible, we have broken the -memory manager into two parts. There is a reasonably system-independent -"front end" (jmemmgr.c) and a "back end" that contains only the code -likely to change across systems. All of the memory management methods -outlined above are implemented by the front end. The back end provides -the following routines for use by the front end (none of these routines -are known to the rest of the JPEG code): - -jpeg_mem_init, jpeg_mem_term system-dependent initialization/shutdown - -jpeg_get_small, jpeg_free_small interface to malloc and free library routines - (or their equivalents) - -jpeg_get_large, jpeg_free_large interface to FAR malloc/free in MSDOS machines; - else usually the same as - jpeg_get_small/jpeg_free_small - -jpeg_mem_available estimate available memory - -jpeg_open_backing_store create a backing-store object - -read_backing_store, manipulate a backing-store object -write_backing_store, -close_backing_store - -On some systems there will be more than one type of backing-store object -(specifically, in MS-DOS a backing store file might be an area of extended -memory as well as a disk file). jpeg_open_backing_store is responsible for -choosing how to implement a given object. The read/write/close routines -are method pointers in the structure that describes a given object; this -lets them be different for different object types. - -It may be necessary to ensure that backing store objects are explicitly -released upon abnormal program termination. For example, MS-DOS won't free -extended memory by itself. To support this, we will expect the main program -or surrounding application to arrange to call self_destruct (typically via -jpeg_destroy) upon abnormal termination. This may require a SIGINT signal -handler or equivalent. We don't want to have the back end module install its -own signal handler, because that would pre-empt the surrounding application's -ability to control signal handling. - -The IJG distribution includes several memory manager back end implementations. -Usually the same back end should be suitable for all applications on a given -system, but it is possible for an application to supply its own back end at -need. - - -*** Implications of DNL marker *** - -Some JPEG files may use a DNL marker to postpone definition of the image -height (this would be useful for a fax-like scanner's output, for instance). -In these files the SOF marker claims the image height is 0, and you only -find out the true image height at the end of the first scan. - -We could read these files as follows: -1. Upon seeing zero image height, replace it by 65535 (the maximum allowed). -2. When the DNL is found, update the image height in the global image - descriptor. -This implies that control modules must avoid making copies of the image -height, and must re-test for termination after each MCU row. This would -be easy enough to do. - -In cases where image-size data structures are allocated, this approach will -result in very inefficient use of virtual memory or much-larger-than-necessary -temporary files. This seems acceptable for something that probably won't be a -mainstream usage. People might have to forgo use of memory-hogging options -(such as two-pass color quantization or noninterleaved JPEG files) if they -want efficient conversion of such files. (One could improve efficiency by -demanding a user-supplied upper bound for the height, less than 65536; in most -cases it could be much less.) - -The standard also permits the SOF marker to overestimate the image height, -with a DNL to give the true, smaller height at the end of the first scan. -This would solve the space problems if the overestimate wasn't too great. -However, it implies that you don't even know whether DNL will be used. - -This leads to a couple of very serious objections: -1. Testing for a DNL marker must occur in the inner loop of the decompressor's - Huffman decoder; this implies a speed penalty whether the feature is used - or not. -2. There is no way to hide the last-minute change in image height from an - application using the decoder. Thus *every* application using the IJG - library would suffer a complexity penalty whether it cared about DNL or - not. -We currently do not support DNL because of these problems. - -A different approach is to insist that DNL-using files be preprocessed by a -separate program that reads ahead to the DNL, then goes back and fixes the SOF -marker. This is a much simpler solution and is probably far more efficient. -Even if one wants piped input, buffering the first scan of the JPEG file needs -a lot smaller temp file than is implied by the maximum-height method. For -this approach we'd simply treat DNL as a no-op in the decompressor (at most, -check that it matches the SOF image height). - -We will not worry about making the compressor capable of outputting DNL. -Something similar to the first scheme above could be applied if anyone ever -wants to make that work. diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/testimg.bmp b/irrlicht-1.6/source/Irrlicht/jpeglib/testimg.bmp deleted file mode 100644 index 8603d1548..000000000 Binary files a/irrlicht-1.6/source/Irrlicht/jpeglib/testimg.bmp and /dev/null differ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/testimg.jpg b/irrlicht-1.6/source/Irrlicht/jpeglib/testimg.jpg deleted file mode 100644 index b34ca5d31..000000000 Binary files a/irrlicht-1.6/source/Irrlicht/jpeglib/testimg.jpg and /dev/null differ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/testimg.ppm b/irrlicht-1.6/source/Irrlicht/jpeglib/testimg.ppm deleted file mode 100644 index 9d81ce24a..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/testimg.ppm +++ /dev/null @@ -1,4 +0,0 @@ -P6 -227 149 -255 -0/-0/-10.21/51.51.62/62/83/83/:3-:3-:3-:3-:3-:3-:2/91.91.80-80-91.91.:2/80-80-80-80-80-80-80-80-6.+6.+6.+5-*5-*4,)4,)4,)4,)4,)4,)4,)4,)4,)4,)2-)/*$/,%/,%0-&1.'2/(30)30)63,63,74-85.85.96/:70:7.A:0B<0D>2F@4IA4JB5KC6KC6MD5MD5OC3NB2OC3OC3PD4RE5R?1Y?2b@4nB5}E6H8G9F7G:G9E:G;G>G?H@E@FLCLDKEICIBD>B=A;A:@:?<??@@>?<A7=/@.@.?-?-@-?-@-@,A,A-B,@*A)@*A,>-?/?/>.>,=+<+<+?+?+=*=*=*>+?,@/?6>5=2?1B3D3D4D4?0A2F8H;H9oA2T8*C3&=5295495473271160050-50-72/72/72/61.61-50,50,41,//-.0-//-//-0/-0/-2.-2.-5,-4+,4*+3)*7(+=.1E69P:<jBC|IHMMOOW[dnot{~sy`aTKvPDhSJgOG^MH^TQbfdo|}{|lfgUXWEQNEUR[UQbUQb0/-0/-10.10.40-51.62/62/83/83/:3-:3-:3-:3-:3-:3-91.91.80-80-80-80-91.91.80-80-80-80-80-80-80-80-6.+6.+5-*5-*5-*4,)4,)4,)5-*5-*5-*5-*5-*5-*5-*3.*0+%0-&0-&1.'2/(30)41*41*63,63,74-74-85.96/:70:7.@9/A;/C=1E?3H@3IA4JB5JB5LC4LC4MA1MA1MA1NB2OC3QD4P>0U?1^A3jC4xD6E4E5C3C4A4A4B7D:E<F=C@EIBICIDHDGBD@C?C;A:@:?<??@A>@<@6>/@.?-?-?-?,?-@-@,@+A-A+@*A)@*A,>-?/>.>.>,=+<+<+?+>*=*=*=*>+?,@/@5>5>3>1A3D4C4D5A2C6F8I;G:l@3S9*B4)>63:6595484382271161.61.72/72/72/61.61-50,50,41,//-.0-//-//-0/-0/-2.-2.-3--5,-4*+3)*5)+<-0C47N8:d>=vEAJINLTVajl}r{{ou[[QHuOCiOFeOG_PH_RN_[Yfnot~ojkY][LVSJXSZVRaXQa/.,/.,0/-10.40-40-51.51.72.72.72.72.92,92,92,92,91.80.7/-7/-7/-7/-80.91/80.80.80.80.80.80.80.80.6.,5-+5-+5-+4,*4,*4,*4,*5-+5-+5-+5-+5-+5-+5-+3.*2-'1.'2/(30)30)41*41*52+63,63,63,74-85.96/96/:7.?8.@:.B<0D>2G?4H@5H@3H@3I@1I@1K?1K?1K?/L@0MA1NB2MA1QA1YB2dC2qC3|C2B2A0<-:+;.=2@6D:F=D>CE@FBGBFDFCEAD?D;@:?;@=@@@A=@;@5=.@-@-?,?-?->,@,?-@-@,A+A,?*@*@+>->.>.>.=+=+=+=+>,>,<+<+=,=,?+?.A6?5>3>2A4C5D5C5D8F;I=J=G;h@4Q:,B5,?74=77<66:4494183072/72/62/62/62/51.52-41,41,21,.0-,1-.0-.0-//-//-0/-2.-5//4..5,-4*+4*+9-/>24I56[97l?9|E@IDOM[`fvmw}}u~fmTVMEvLAkMAeOFcQHcMH^NK\[[eqty|xzlfiXZ[MVSLZU[ZT`[S`.-+/.,/.,0/-3/,40-40-40-61-61-61-61-81+81+81+81+7/-7/-6.,6.,6.,6.,7/-7/-80.80.80.80.80.80.80.80.5-+5-+5-+4,*4,*4,*3+)3+)6.,6.,6.,6.,6.,6.,6.,4/,30+30)30)41*41*52+52+52+52+52+63,74-85.85.96/96->7-?9-@:.B<0E=2E=2F>1F>1G=1G>/H<.I=/I=/J>.L@0JA0KD2NE4UD4^D3iD2sB1~A/?-9)9'9*<-@3E8H<F>DCACBCDCCDBC@C?A;@:?;@>@A@B=@9@3=-@,@,@,>,?,?,?+@-?,@+@*@+@*@)?*>,>.>.=-=+=+<*<*=+=+<*<*<+>,>-?-A6?5>2@4B6C8C7B7F<J?L@K>|F:b@4L:.A7-@85>96=77<74:5294183083062/62/62/32.52-21,21,12--2.-2./1./1.00.00.10.10.5106005//5,-4+,6,-:01D22T71c;3qA7{E;HDRU_lis}yx}ow`fQRLEyL@pL@hPEgQFfLC^GBVMLZ^^fjnquyxx}wzvwzokoa`bTWYLTTL]WY]V]]V^------.-+/.,0/-10.3/,40-3/,3/,4/+4/+4/+4/+6/)6/)4/,4/,3.+3.+3.+3.+4/,4/,50-50-50-50-50-50-50-50-3.+3.+2-*2-*2-*1,)1,)1,)4/,4/,4/,4/,4/,4/,4/,4/,41,41,41,41,41,52-52-52-52-52-63.63.74/85096196/<5-=6,?8.@9/B:/C;0C;0C;.D:.D:.F:.G;-H<.I=/J>0I@1JG6MH5RG5YF5bE3jD1uB/}>,;):):*=,B2F8J=I?GBDCDBEBBBAA=@<>:?:<<>?>B>C:A5?0?-?,?,?,>->->-?->.?-?,?+?,?+>*>*>,?.>->->-=,=,=,=,=,=,=,<,>->.?.B4A4@1@3A7C9B8A7C;H?LCJ@tE;Z>2E9-<5+@93@85?75>63=52<4194083/62/43/43/23.32.12-12-02--2.,2.-2.-2./1./1.00.10.3205105104..2,,4+,7./=/.N5.Y9.e=1n@3sB;yKKZegpzxu{ks_dTTOGLBwNAmNBhMAeJA`GBYGFXKKWMPU]cc`fbbia`f\Z`TW[MUXMXXP^YV`WX`WZ,,,,,,.-+.-+/.,0/-3/,3/,2.+2.+3.*3.*3.*3.*5.(5-*3.+3.+2-*1,)1,)2-*3.+3.+3.+3.+3.+3.+3.+3.+3.+3.+2-*2-*2-*2-*1,)1,)1,)0+(3.+3.+3.+3.+3.+3.+3.+3.+41,41,41,41,41,41,41,41,41,52-52-63.74/85085085.;4,<5+=6,>7-@7.A9.A9.A9.C9/C9-E9-F:.G;/H<.J>0HA1JG6IH6NG5VF6\E3dC2n@0v>-{<+;);*=,@1F5J:J=H@EAFAE@CA@>>?:<;<:;<=@=C=C8@2>,?,@,?+?+?->,>,?,>-?,?,>,?+>*>)?*>+>->->-=,=,=,<+=,<+<+<+<-=,>/?.B4A2@2B5C9C:B:A;A9I@NGNEoG=S?4A;/96-@93A75?74>63<4194083/74/43/43/34/23.23.02-02-.3--3/-3/.3/.3/02/02/11/11/21/32032040/2.-1-,4..8.,G4-O4)X8+`<0e?6mGFyYdku||w|nudh[[RMLB~OArL@hI=cH>`HB^ECX@BO;@FBGJDMJJQJJQIIQFKQEOUIVWO^YS`YS`XU++++++,,,---/.,/.,0/-0/-1-*1-*1-*1-*2-)2-)2-)2-)2-*2,,1++1++1++1++2,,2,,1++1++1++1++1++1++1++1++2,,2,,2,,1++1++1++0**0**3--3--3--3--3--3--3--3.+41,41,41,30+30+30+30+30+41,41,52-63.74/74/85085.:3+;4,<5-=6.?6/?6-?6-?7,B8.B8.E8/E9-G;/H<0J>2H@3HE6GF4KE5QD4XC2_B2f?.n=,v=,|:*9);*=.B2F7F8F<F>F>E>D@C?@@>>::;:<<A<C;D6@/=)?-@-@-?,>.>.=->-=.?.?-?-?,>*?*>)>+>->-=,=.=.<-<-<-=-;,<,</>.=0?/C2B1A1B6C:C<C=C=FAQJXRXQsRIWI>CC7<?6>93@72>71=60:5/94.83/63.43.43.34/13.13..3-.3-.3--3/-3/-3/-3/.3/.3/02/02/00.11/22021/0/-/.,2.-4/,?0+D0)K3)T8-Z<4dFFu]js~tzmpceVSLCK?qI<gG;cE>_FB]DBW?AN;?H:BE>HGDMHGQIGQHJRGNVKUXM^ZOaYNaXO++++++,,,,,,.,-/.,0/-0/-1-*1-*1-*1-*2-)2-)2-)2-*2,,1++1++0**0**1++1++2,,0**0**0**0**0**0**0**0**2,,2,,2,,1++1++0**0**0**2,,2,,2,,2,,2,,2,,2,,2,,3/,30+30+30+30+30+30+30+41,41,52-63.63.74/85085092,:3+;4,<5->5.>5.>5.>5,B8/B8.E8/E8/G:1I=1J>2I?3FC4FC4JB5OA4TA2\@2b>0j<-q<.w9*}8)8(:,=/B4B5F:E;F>G?G@FACAB@;;;;>;B;D:D4@->(A-A-@,@.@.?-?->/>.@.?.?->+?*>)>+>->->-=,=.<-<-=-=-<.<.<.</>/>1?1D2C1B4C6C;D>D>EAPL[Te\f]u_T[UIGMACI?<92?82>71;6094.74-63.43.43.34.24/13./4..3-.3-.3--3/-3/-3/-3/.3/.3/02/02///-00.22022010.0/-0/-3/,8,,;,)C0*K70S<6^IHtbnzƄzrxikWWIDE=nG<dD<aC>^CAY@CV@DP>EKGQRKWUQ^WU`XS_UR^TT^SY_S^[LaZJaZJ,-/,-/,-/,.-------.-+.-+/.,/.,1-*0,)0,)0,)/+(/+(/+*/+*/+*/+*/+*/+*/+*0,+/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*0,+0,+1-,1-,2.-1-,1-,1-,1-,1-,1-,1-,1-,0,)1-*2.+3/,3/,3/,3/,3/,3/,3/,3/,3/,40-51.62/74/80-92,:3-;4.=4/>5.>5.>5.?4.?5,B5-C6.D7/F90G:1F<2G?4H@5J@6P?5T>3X<1^90b6+m9.t8-|8+9,;/=0?1>0A3A4C8E:G=G>E?C@@?BADAE>D8B1A.B,A.@-?,>.=-=->.?/<,=,<->-=,=+=*>*<+<+=-<,<,<,:-;-=/</</=0>3@2A5A4E5D4E9I>G@D>EAMGZRf_qfsh~rdjj^V^SIQFLLBJF=B>5<8/95,74+63,33+43.34.14-14-02-/1,,1+,1+-2.-2.-2.-2./1./1./1./1.02/02/11/11/11/11/11/40/4+0;/3A32C4/J;6]OOymyϐكtzjn_bZ[LItHBdA>]>>X?BUAIVLU\U`bbqnn}xv|rulyoguh_k_W_P]\Hb\Fc]G,-/,-/,-/,-/------.,-.-+/.,.-+0,)0,)/+(/+(/+(/+(.*).*).*).*)/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*0,+0,+0,+1-,1-,1-,1-,1-,1-,1-,1-,1-,1-,0,+0,)1-*2.+3/,3/,2.+2.+2.+2.+2.+2.+3/,40-51.62/80.91.:2/;4.=4/>50>50=4-?4.?4.A4.B5-C6.E80G:2H;3H>5H>5L=6O>6Q=4V;2Z90_7/h70p7.w7-9-9.<1<1=1@3A3B5D8E:F<E=D=D@E@FAG>F8C2B-B-C.B-@.?-?-?->.>.=,>,=-=,=+>+>*=,<+=+<,<,<,;+;-<-</=/=1=1>2@6A7B6G9E7G<J@IBGALFTNd\qf~oo|mmseZfZNXMLNAKI=EC7@=4=:188.44,11)23-23-03,/2+/1,.0+.0+.0+/1.-2./1./1./1./1./1./1.02/02/11/11/11/11/11/2015+49-7<23?53H?:^VTxr|ʐԄyqykthn\_XZqSUjRWjT^hZgmfvvrt~~vyrqfteZeT[ZE`Z@b\D,-/,-/,-/,-/,-/,.-------.-+.-+.-+-,*/+(.*'.*'.*',+),*+,*+,*++)*+)*+)*+)*-+,-+,-+,-+,-+,-+,-+,-+,,*+,*+-+,-+,-+,.,-.,-.,-.,-.,-.,-/-./-./-./-./.,0,+0,+1-,2.-2.-2.-2.-1-,1-,1-,1-,1-,2.-3/.40/51.80.91.:2/;30=31=4/=4/=4/?40?4.A4.A4.C60D71F93G:4H;5J;6K<7N=6P;6S:5V72[6.c60k6.t5,}7/9/;0<0<1?3@4@3@3C6D8E:D:F@H@IBI?E:C3B.A.B/A.?.>->->->/?0<-=-<.=.>-=,<+=+<*<*<,;+;-<-:-;-<0<0<2>3?4A8C:D9J=H;H>KDKFLGSM`Vsgqz{wsocqbXcUNRDMN@HI;DD8@@49;.46+/1&01)01)/0*/0*./*./*//-//-//-.0-//-//-//-//-//-//-00.00.00.00.00.00.00.1/26+97+98/4;63HE>_^Yzz|DŽ}{|}}wq~n}n~~o~y|{j{i\hTXX@]Y<_[@-.0-.0-.0-.0-.0-.0.......-+.-+-,*-,*.*'.*'.*'.*),*++)*+)*+)*+)**()*()*(),*+,*+,*+,*+,*+,*+,*+,*+,*+,*+,*+,*+,*+-+,-+,-+,-+,.,-.,-.,-.,-/-./-./-./+*0,+1-,1-,1-,1-,0,+0,+0,+0,+0,+0,+1-,2.-3/.40/91/:20;31<41=31=31=31=4/>3/>3/@2/@3-A4.C60D71E82F93H94I:5J;6L:6N94Q83T50^72e60o6/x8/90:/<1>1?4?4?2?1A2B5D7E:G>H@JAI>F:B5A0@.A-A-?->,>,>,=.>.<,=,=.=-=,=+=-<,;););+;+;,;,;-;,;/<1<1>5@7C:D<E<L@H<G>JCLIQL]Vj^oyzxm{jbm]SZJQUFKO@EI:@D6;=057,13(01)/0(./).-(.-).-)/.,0/-/.,/.,/.,/.,/.,..,/.,..,0/-//-0/-//-//-//-//-2-17,:6*83-1961HJ?bfX{z}|k|iXfOSV;ZV9^Z=+/2+/2+/2+/2-.0-.0......------.-+-,*-,*,+),+),+),*+,*+,*++)*+)**()*()*(),*+,*+,*+,*+,*+,*+,*+,*+,*+,*+,*+,*+,*++)*+)*+)*,*+-+,-+,.,-.,-/-./-./-./+*0,+0,+0,+0,+0,+/+*.*)/+*/+*/+*/+*0,+1-,3/.40/901:20;31<42=32=31<20<20=20=2.?1.?1.@2/A30B5/C60D63C84D95E:6G96H94K84N50X72_60i70r7/}:1<1>2>2@6?5?5?3@3C5C6E8E;G=H>G=D8A5?0@/@-@-?.>-=,<,=/=/<.;-</<.<-<,<,<,;+:*:*:*:+:+:,:.:0<1=4?6B9D=F@H?KAH=G?LEPLXQf]vhw~}tqjue\eRV_LNUCEL:?F6<@27:/68-01)00(.-(/,'/+(/+*1-,2.-1-,1-,1-,1-,1-,/.,1-,/.,2.-0/-2.-0/-0/-0/-0/-2-18,:5)51++66,GL8`hQzp{xgzdTbIQT9VU9XW;,03,03,03,03./1./1//////....../.,.-+.-+.-+-,*-,*-+,-+,-+,,*++)**()*()*()+)*+)*+)*+)*+)*+)*+)*+)*,*+,*++)*+)*+)**()*()*(),*+,*+,*+-+,.,-.,-/-./-./+*/+*0,+0,+/+*/+*.*)-)(0,+0,+/+*0,+1-,2.-3/.40/:12:12;31<42=32<21<20;1/=20<1/>0->0-?1.@2/A4.?4.@51@72@93A:4B94C84F74H5/Q51X5/a6/l8-u9.</>0=1?5>5?5?4B4B4C4D4B5D8E:E;B7?4>1>0?.?+=,=,<+<+<.<.;-<-<.;-;,<,;+;+:*:*9):):+9*9-9-<1<3?6A8C<F?IBICJAG>HCNJVR`Zper}~~yup{jdp\]iSR^JJS@BK:>E5:@29<134,22*1.)/,'/))0**1++2,,1++1++1++1++1++0,+0,+0,+1-,1-,1-,1-,/.,/.,/.,2,.8*75(13+(56&EK1\gGudyťέɭʰ˱Ȭ{wrdx]Q_ENR7QQ5SR6,03,03,03,03./1./1./1./1/////////////.,/.,.-+.-+/-..,-.,--+,,*++)*+)**()+)*+)*+)*+)*+)*+)*+)*+)*+)*+)*+)**()*()*())'()'(+)*+)*,*+-+,.,-.,-/-./-./+*/+*/+*/+*/+*.*)-)(,('0,+0,+0,+0,+1-,2.-40/40/:12;23;23<34=32<21<21;10<1/<1/>0/=/.>0->0-?1.>3/=60;60;83<94=:5>93@72C60G4.O4+Y4+d5+n8,x:-;.;.<4<5>3@3A2B1A2@0>1@4B7B9@6>5=2?2?-?->,=+;*;*<-<-;.;.;-;-;.:-:,;,9)9):)9(9*9*~8,~8,<1=4@7B9E>IAKFMFIAH@JFSO]Xhb{ny~wxnjxadr[ZhQQ]IITCCL;>D6<?467/44,30+0+'1()1()2)*4+,2)*2)*2)*2)*2)*0**0**0**1++1++0,+0,+0,+0,+0,+1+-6)25)-4-%46!AH&Wc;qWm}ȔНӫҮѭ˥{{tqk_sWM]BIO3JM0KK/./1,01./1./1.0/.0/.0////00.00.00.0/-0/-0/+/.,1-,2.-1-,1-,0,+/+,,*++)*+)*+)*+)*+)*+)*+)*+)*+),+)*+),+)*-(,*(),())'()'((&'*()+)*,*+,+)-+,.-+/.,/.,-,*-,*/+*/+*.*)-)(,(',('1-,2-*2-*2-*3.+4/,50-61.;31;31<42<42=31<20;1/;1/<1/<1/=/.=/.=/,>0-?1.=2.=4-=6.;819919:29:2;81?6/C2+J1,T2)^3*g7+o9-u=.z</=2=3?2@2@3@1?1=/</>2B6C7B7?4>2>1>/=.=-<,=,=,=.>/<.<.</;.:-:-:,;,:+:+:*~;*~;+|:*}9,|:.>2>5@6C:G=JBNEOGICIDPJ\Tg`uiu~zytoi}bby]\pUUgOO\HGRAAH8=A388.85.7/,3+)2()2()3)*4*+0*,/+*0*,0**0*,0*,2),2),3*-1+-1+-1+-0,-0,-0,-1+/4)/4*+4-%46!?F%T`8m|Qgtz~z{Ĉːəǝƚ~xvolfZnSJZ?GM3FJ1DF./0+.0+/0+01,01,01,12-21-32.43/43/62/51.41,3/,4/,50-50-4/,3.+2,,1-,0,+0,+.,-.,---/--/,,.++-*).))+.)/.)-/(/.)-/)-.)-.*+.*+/+*/+*-,*.-)--+-.)./*./*------.,-/-./.,0/-2.+2.+2-*4,)5-*6.+8/*:1,:1*;2+=4-=4->50>50>50=4/<3.;2-=2.<1-<1/;0.=/.>0/>0/@1.A0)@2);4*77-39-28.56.:3-?-)F*'L)'S*&Z/(`5,d<0k@0yA0@/A1B3@3=0;/8-;/=.A1B2C2A0>.;,;0:2;1=0?0?/?.>.@1?0>1<0;/:.:-;-{9+~@3w<.q7)w>-w>-v;-}?2{;/@4E9I?LAMBPCNEKISPbYpa}jq|~u{ouiib_[zXZsUZnSWeNPWEJK=C?6@93;0.6**3')3'+3'+1&*,*-)+***,*(),'+.(,1(-2'-3(.3(.3(02(00)10)1/*1/*0/)-1++0-(//#<?*V\@pzXgusvwvu{}|{~}~|yurmh|cYkUMZFIQ<CH4?B//0*01+01+01+12,12,21,32-43.43.74/74/63.52-50,50,7/,7/,6.,6.,3.+2-*0,+0,+0,-/-./-0--/-,1+*/)*.)(-.)//(//(//(//)-/)-.*+.*+/+*/+*.-).-)./*./*./)./*.....0....../.,/.,1-*3.+5-*5.(7.)8/(:/);0*<2)=3*>5,>5,>5.>5.>5.=4-<3.<3.=2.<1-;0.;0.=/.=/.>0/@1.C0*C0)A2+>4+:6-95,:3-<1-?-+D*)I*(N+'T/)Z5-_:1e>/pA/xA-A0@2?4=3:2;19.</>.@0A1A1A/?1;2;2<2=0>0@/?/?.@1>/=0<.;.;,:,;,x8,x<1s9-n9+s>.s>.r8*u:,}=1A5E:I=K@NAPCNEJHSRf]wfpww}ovei``YZY{X\wXZnSSaJNUCFH;C@7<737/-3*+2)*1(+.(*,*+**,+),+),-(,/)-2(02(02(02(02(10)1/*1-*3-*3-*12-12.-0,)--%8:,SXBox]iolnpppw{xwy||{xuqnh{eYjWMZHEL<@D5;=/12,12,12,12,23-23-43.43.54/54/85085085074/72.61-80-80-7/,6.+4/,3.+2,,1-,1-./-.0.1/-0--/,,.+*/+)./(/1'//)-/)-/)-/)-.*+.*+0,+0,+/.*/.*/.)0/*0/*0/+//-///0./0./0/-/.,1-*2-*6.+70*90+:1*<1+=3*>4+?5,?6-?6-@7.@7.?6/>5.=4-=4-=2.<1-;0.;0.;0.;0.<1/?1.C2+E0+H/+K--L,/K+.I*/E+.A-,@.*A.(E.(M.)X1*b3-g5,j:,o;-w;0=4<6<5:4:4<2=2>2?3A2A3B5C5?2=/>1>.>/>,=.<,;.<,:-:*;,<)~=+{<+}=1z<1v:/u;/x@1x@1v<.v;-?5B8F=H?JAKANCNFJHTQf\vent{}yximae\a\`]`[|]UrVPhPFYEBP?:D93:2.3,*/)*,)**(0'(1&*1&*1&*0'*1(+0*.0+//*.-+.,+0+,0)-0(-1(-1)-01/23/..*'**"57*PUAmv[|ik~jjnn~mqx|zxvvuwyy}}ywtpmh|cYkUMZHDH9=?299-23-23-34.34.34.45/54/54/650761961:72:72961940940:2/91.91.80-50-4/,4..4..3/03/01/01/20.1..0--/-+.0)02).0*.0*.0*.0*,/+,/+*1-,1-,0/+0/+10+10+10+10,11/1111/010.10.2.+3.+3.*92,92,;2+<3,>4+@6-@6-A7.B8/A8/B90A8/A81@70>5.>5.=2.=2.<1/;0.;0.<1/=20=2.B3.E2.L..R+0V'/U&.P'/I).C/.<1+;2)?2)G0(R/)_.*d/)i9/k;/u<3}<6;8;9;7:6>8@8B9B9C7B7A7A5@1A/@.@.>-<,;+:+8*9*:*:)<){=(x>(x>*>1{7.z7.z<1v;-w=/|A3{@2B7E:H=J?J@MBODQHSJ\Qh[tbgm~v|~}yqoiifgfeggde_~_Zw[PhPK^JBP?8D62:/.4*,/(+*%2&&5%(4%(2&(1'(/)+/+,.,-+++*+-*+-(,-(,/',/',/*+-.*+1++0+'.+"88,PUAiqYvc{hyh|il}mykzmrtq}p}p}s~v~x}x|x}zzwuqnje|bWkRN[GDF9?=1:8,45/45/45/560560560761761872872;83<94<94<94<73<73<41<41;30;3083072/61.61.5106216213122011/00./1-.2,04+.4+.4+.2,.2,,2,,2,,3/.3/,3/,3/,21,21,32-32.32032032032051051.61.61-;4.<5/=4-?6-A7.B8/E8/C9/D:1D:1E;2D:1C90B8/@5/@5/>3/>3/=2.=2.=20=20>31>31@51E31M02T,4X)3W(2R)1K,1B30:6-77+:6*B4)M2)X/)^/)f:1j;3s<7z=:<:<;;;::;7>8A8B9C:C:@9@7C2C1B0?/=.<.:-9-7+8+9+:+~=+x>*v?*x>*9-|/'8/>4w4+s5*}A6}C7E:G<I>J?KBMDQGWJ|aNzjQpYu]|biu|~{}zwzpzlxlwkumrlmgkd`rX[iRR[HHL=@@4;7,70&5*$6('5''3''1'&.)&+*(++)+-*',('+*)+*)+***,+),+),-)*,#$2*'50*86*BC5UZFfpWn}^teqbuexiwkshtiwkznxlwmxnys{u{w|wyuzwwtsomhd{_WkPN[GCC7>:195,560560671671782782872872983:94=:5>;6>;6>;6>95>95?74?74>63=52;63:5294194184184395484373243151240/6-06-.6-06-.4..4..4..4/,40-40-40-51.32-32-43.43.43/431542540841850940:5/=60>7/@7.A8/C90D:0G:1H;2F<3F<3F<3F<3E;2C90B71A60@51@51?40>3/>31?42@53?53@72C52I35P16T/6S.5P05J22C52=90<:-=:+C7)I6(Q3)W2)]2+d3,l50v64}77877766~75}:4}<6}>5?9@8?9A8B3C1B1@0=/;.:.9-9,9,:,<,|=,y>,x?,|=,5*2,LEXQA8|90F;K=yH:zJ<{M>|N?}OBQEUJ_LrkOosR|uXw]ybiszz|~{y~vpoppp{pwmskj~bfv\_hSV[GOM>GA3@6*=0';,'9+(6+'3+(/,',-'+.').().(+-(-,*/+*3)*4(*7'*7'(3($<3,E>4IG8QR@]bKgqVjyZn]k\l]pbqeodoerfumrjqitnxrzvyvyvvtwvurokjfc|^UlON\ECC7@91;4,671782782782893893983:94:94;:5>;6?<7?<7?<7@;7@;7B:7B:7A96@85=84=84<73<73<73<74<74<74;639529338308/09/.8/080.80.80.61.61-61-61-52-52-63.63.74/74/540540841952:63<94=84@93@70A8/C90D:0G:1H<0I=1I=1J=4J=4J=4I<3F<3D:1B8/A7.A81@70@72?61?61@72@72A83?74@85B86D97G96H96H96H94E80E8/E9-E9+G9,I9*K9+Q7*Z/&d/'n3-z6398;9;:=;A>@:=6<3:3<4=7@7A5B3@2?2=1<0;/</~<.|=.{=.|>/|>/}>/=/9/1+<8lf~yZTC<LAN@tJ<qM=pQ?qR@tS@zWD[J~eOmsOo{Uy[u_ocmfqkwowz~~yvrrrrr|sxptpmiiedx\]kQV^GMP;ED0B;+@3+?2,;0*70*30)00(./'./)/0*2/*6,+:*+>(+C&+E$+C&(F5-LC4VQ>[YD`bJgmQiwVj{Wl[gWfWl\oananbrfskojoirnwtyxxwuvssuvsrnlicb{[TmMM]CGH:E<5@707827828938938939:4:94:94;:5<;6?<7@=8@=8@=8A<8A<8C;8C;8C;8B:7?:6>95>95=84>95>95>95>95=85<73:51;30:0.:0.91.91.91/91.91.72.61-61-63.63.63.74/74/74/540651952;83<94?:4B;5B;3A8/B:/C9/E;/H<0I=1J>2J>2K>5K>5J=4J=4F<3E;2C90B8/B92B92A83@72@72A83B94A:4?82@93B;5D=7F=6G<6K<5N;4M6.N6,Q6+Q6+Q7*P9+P9)V6'f6*r6,~;3@9D@HDJGLFQJLDD;;07-7-91=4>5>7=6<5<5=4}=3z>3x@3vA3x@3z>3<3:37331(&=;|zhcG@K@xH:nM<jQ=fT>hV>lX@t[E`LhPysQwUt\l^__V\Q[T\ouzx̆|~}xvrtuuussr|nyju{amoWgbN_TBUE5R</O4-M1-I0,D/*>/(9/&7.'6/'81):/)=.+A,+F)+H(+K'+H)'TB4YQ<d^FgeLilOnuVm{Xl~XkZgVgVm]pbqbrduitlokojrmwvyxwytusuuusqokiea|[TmMM]BMN@KB9F=69:49:49:49:49:4:;5=<7=<7=<7=<7@=8@=8A>9B?:D?;D?;E@<E@<E@:D?9D?9C>8E>8D=7B;5B;5B;5B;5B:7B;5A:4A:4A83A83A83@72@64>71>71>71<71<71;60:5/85.85.74/74/961961961:70<71=82A:2B;1C:1D<1F<2J>2K?3L@2N@3N@5N@7N@7L?6K>5I<3H;2E;2E;2B90A8/@91?80?80?80@93@93<5/MD=M@:K:3T@9R62O0+a<6\3-`5.`4+^/'^/%f6,m=1q=0I=G;I?KAF>>7=6D;NDPEVJYKOBA5;0>69898655284?8|@6r>1rB4oA2q=0v:07243-1',HIbaEDWUyvVOF<VFmR=i[AibFjeHj`En^D|dLjTbLm]nhX];L-E+H0L@YI\[enr{|ۀ}ۃ؉vwxxxwyxo~mxioabYUM{IBxA>u:<i.2d02a11P&'G%#L0-M51G4.E2,D1-F1.F.,G+*K--Q6/YH4`W:f_BgdEkoNu|Zu]oYlWlZp]rasbudwfvhrjsosqqostwxz|yzxysrmjkfidazZTmMO_DNO?SK@PG>9:49:49:49:4:;5;<6>=8?>9>=8>=8A>9A>9B?:C@;D?;D?;FA=E@<E@:E@:D?9D?9E>8E>8E>8E>8E>8D=5C<6C<4D;4C:1B92B92B92B92A83A83@93@93>71<71;60;6096/85.74/74/96196/96/:70<71>:1A:0B<0C;0E;/I=1J>0L@2L@2N@3N@3N@5N@7M?6J=4I<3H;2E;2E;2C:1B90@91@91@91@91A:4B92D93I81L/+V.,j76u99{;;ECD?H@IAG>IBNHPLOGD7B4B6C8>37-7-=0C5?0@0E3G6F6H:NELMHL@D9;98>:@8x>3o>0zI;LA?8,+).9DLWKNMM>=@?`\YQ@5TDyaIe[@^]?ihIslOvgJ~dKcNdX_[UZAN,E%D&H'I.N3N<RIZP^Q]S]Xbbifljnmqqrutxwyw||yzvxqtkrfnak_k`nS_KUGQDKEIm69HT1-M0*H1+J6/K81K:2O>6UE8[O5cZ9gaAifEnrOz]zbt^r_p_p`q`udwdwdwfsixrzxyx~}zzromhhd`y[TmMNaERSAVPBUOC8938938939:4;<6<=7?>9@?:@?:@?:C@;C@;C@;C@;D?;D?;FA;FA;FA;E@:E@:E@:G@8F?7JA:I@9H?8G>5F=6E<3F<3E;1D:1D:1D:1D:1D;4D;4D;4C<4?80?80<71;60:5/:5/94.94.96/96/:5/;7.>7/@9/B90C;0E;1F<0I=1K?1M?2M@0NA1M@0P?5M?4L>3K=2I<3H;2E;1D:0C:1C:1A:0A:0?;2@<3@<3D;4UD<R3.j23AGLWU`]f_bB>I?LANBRJUROSLK@4B0@0?1;.7+8+=/E6>+7$:'>-A/C2D:02:BDLLRMRKLA>71{8/v6,x2*1-37=GGWM[FI53:931NKc]J?[J}cLj_CgdEtoOpQhJhNhYbbQZDQ7I1J2N/M*H2O0K1J5L4M2K3L7P@XC[F]IaNcQeUhVkSjRiOiNiNlPoSsVuha|[tUlYldrR]r-2^&'Y0,W:4Q?5B:-:8)>B1LN9VO3aV6e_?heDquTe~iwdxiuerdrcveyhzizjv~zypmg~b^wYTmMPcGSXDXUDYVG7827828939:4;<6=>8@?:A@;BA<BA<DA<DA<DA<DA<E@<E@<GB<GB<GB<FA;FA;FB9HA9HA9LC<KB9JA8I@7H>5G=3F<2E;1D:0D:0E;1E;2D;2E<3E<5E<5@91?80=82<71;60:5/:5/:5/96/96-;7.;7,?8.@:.C;0D</F<0F=.J>0K?/M@0M@0M@/M@0O?2O>4L>3K=2J<3G:1E;1D:0D;2D;2B;1@<1@<3A=4B>5F<3S81[*&:?T`TeUfUcJO30:/>0A3F=IGBH>@B7F5B3@3?3>3B4D6G5B/<);(<(:(6&3(979=7>7<<BJLTSXS?74*,%61HKOWAQ3@:9.*8474E@]UWKWFwW@veI~pSpQfJdKo[uiSWDP;J9I=N@Q:L4H?S9M4K3K1J/I0N6S3T4V6W7W9Z=\>^@aCf@f?e?g?hCmErIsOuQuUvSqTnaxfvWb}15j0/X1*P8,G>/>A.;D/?G/PK._T8g`CokN||`rv}qzq|s|szozm}ouzsqh|c]tXSlNPdHRZCWYDYZH671671782893:;5<=7?>9@?:BA<BA<DA<DA<DA<EB=FA=FA=FC<FC<GB<HC=HD;HD;JC;JC9LC:KB9KA8J@6J=4I=1H<0G;/E;/E;/E;/E;1E;1E;1D;2D;2@9/@9/@91?80<71;60;60:5/;7.;7.;7.<8-?8.A;/C;0D</G=1G>/K?1M@0M@0NA0O?/O?0O?2N=3N=3J<1I;0G;/D:0D:0D<1D<1B;1@<1A=2A?3B?6K=4\5.w32LS]iM_@Q6E&+1)7(:&<)@3D=>?;;?5B4@2?2@5C9H;J<>/?/=+;)9):,;/<1FADA>?797<BELNROC>KCTLSMKJ?B5>274.7.1+:484@9[PUC{N9bIkP`F[FfTrdmhEK:D9C<DBHFKGLFMJSBM9I5H2G/F2L8R9V9X:X:Z;]=_@bAeCiDkDmBmCoCoBqBoGp@hGmMpIhOk[rcsYc?D`&$Q+"V@3VO=IL7@D-RJ3eYCujV{gyýþyvi{e\sYTmORfJQ[BUZCW\F560560671782893:;5=<7>=8@?:@?:C@;DA<EB=EB=GB>GB>GD=GD=HC=ID>IE<IE<KD:LE;LC:KC8LB8KA5L@4K?3J>2I=1G=1G=1F<0F<0E;1E;1D;2C:1A:0A:0@91@91=82<71;60;60;7.;7.;7,<8-?9-A;/D</E=0H?0J>0L?/M@0NA0NA0O?/O?/O?2N=3M<2L;1I;0G;/F90C9/C;0B<0B;1@<1@>2A?3B?6N;4m84FEY_WbCQ8F3;++1'8%:!9 ;&>.:2717,:-9-7,:1B8E;E:>2?0<,6'6)>0D;G=8-@6D?BB=A9>27.075GBSLNG=910/2671(</,"713,7/g\l\WCZCV?R=\LlagbTTEK=F;@=>A>GBOMWWNRDM:G5F2F.D1G7N8S8T8V9W;\>aAeCk;e<h>j?m>n>o=m:jHr;a?dKnKnNmUoZnrajILt:8\6-P9+PC2UM:^QAreU|nʿ~m~k`t[WnRVjNS`FV`EX`H560560560560671893:94;:5=<7>=8A>9C@;DA<FC>HC?HC?GD=HE>ID>ID>JF=JF=MF<MF<ME:LD9MC9MC7NB6MA3N@3MA3JA2JA2I@1H?0G=1F<0D<1D<1C:1C:1A:2@91?82?82<71<71<8/<8-<8-<8-@:.A;/D</E=0H?0K?1M@0NA0P@0P@0O@-O?/O=1O=1M=0L</I;0F:.E8/C9/B:/A;/A:0?;0?=1@>2@@4P91r1/JKSV>D0603//1)1!9#=!;< =#;%6%6)8-6,4,81@:C<@6B7A4</8+:0C8D=@7>->-5+*&"%%+*1.4)*.+3,4,3,2,0-2+2%6&2&7,6.>7`UqeSVBM:WIf[d_RTCIFM@D??@<@8@7FAMLJN@K9H7H5H3E6G;M8P7R6R6U6X9];a<g>k?m@qBtBuBuBtBpFmAaEeKjKkVt_z]tj~p~ow^aCAg6/hB7sUJye\}vŽ˺tqexb\sW[oS[jM\iK]gL561561561560561671872983<;6=<7@=8B?:DA<FC<GD=HE>HE>HE>HE<JF=JF;KG;KG;NH:MG;MG;ME:MD;MD;MD=NC?NC=MC7MD5KB3JA2H>2G=1E=2D;2C:1C:3A:2A:4@93?74<73<71>7/>7/<8/=90>:1A:2C<2D=3H@5I?3L@2MA1NA0P@0O@-O@-L?/L>1M=0L;1J91I81E80C90@9/>:/;;/<<0=>0>?1A?0S8-<7\[ZY86.*1+.%2#9&B*F,D'A&A&<#9#9*;0:07.<4C<E;@5=0</;.<0E9LAE<8,6$:(;.3,+*(+&+%'**.+2,4,3*3)2(3%:*2?06)8-?5A6l`gYRBOAcZhbRRAFBJ>D;=<<@9>48,6.94HH@E;D:H:I8G;I?NAU?V<T9T8U9Z:^;c>i>l>o>p>q@r@tAqCjMmSsJh@`Tsge]w_xh{p}qxgg^X{ZQ~wļ«zxl{hbu_`rXbpVboScmT21/320431651875984984984;:5<;6==5??7AA9CC9EE;EE;HH@HH>HH<JH;KJ8LK7ML8NK8MJ9JF:GD;JFCNIMNIPGDOD?ENE>LC4J@4KA5MC9LB8F=4B90E<5C:5@93?74@85?75<74<42C:5B94A96>95?:7>:7?;8@<9B?:D@7G@6J@4L@0O@-O@+L?,G@.F?/I;0K81M53K65J88F;9B?:6904</9D4:A/69$?=(bC1j^JA7,5)7+5'7&=+8$<&@*@)=)9&6%6%6'7)8*<.@2B4B2A1>,=,<,=/C4F8>12&9+8*8+8-7-5.3/1-.,.-0,1,5*7):):(9&33 8'7'6(B5SINCSK\W]ZPR>C9??GAFCDAA?9<3;/</<0L@KCGC>?<A?G?I;GDQCQDRDU@V<U<ZBdFkAj;g:g<mCsIyKzMyMtPsOpMiMjYxg_GlWw_y^n{a^xpĻʻyxr}op{k}sxlv}k0./1/0320542653762873872:94;:5==5??7AA7CC9DD8EE;HH>HH>HH<JH9KJ6LK6MM5NM8KJ8KI=KJEPPRWU`YXjVTjRO`OIKMD?H?:F=8G>9H?:F=8B;5D:8A96?74?74@85@85=85;62=4/=4/=52<74=96>:9=<:>=9B?:D?9G@6J@4M@0O@-P?+L@*B?,B?.F<0H:1J65I56F35@65@<9:=6;>5@@4E<-J9)^B4L>QB;-2#6&:'7$9%>*;%<(?+@-=,9*6(7)9):*9);+>.A1B/@.?,:(<+E6H9?18+6)7+7,9.;-</:.8/4-1-.+.+0+4)7(:':$<'6#8%=*;*5&:/F<F?IDOMPQGI;@:ACHBEDCBA>8;1:-<-=.E5L?NEGC?>?B?F@JCJCLDPFTBS>S>XBaFhCi?i@jBpFvJzK{JzHtKpQs\z_{XwNqEkDlEiKg_pnukLI~t̲ų~/.,0/-10.21/43/540762761:94::2<<4>>6@@6BB8CC9DD:IF=IG;JH;LI8MJ7NL7NL7OL9KI:NKBTRS_^fihxmmlkkh`YiYQ\OGRH@KH>GG=EE<A@:<C:;?:7<74<73=82>93>:1=9083-94.;60<92=:3>;4?<5@<3E>4G?4I?3L@0O?0P?/P?-L?,<;&:=(?<+A;-B71A62>42;30=84B;5H94N2.Y,)l/.;=FE;02$1 9'<)7$8"<&;&=)A-A/>.<-:-</<.<.9+9+<+>->-<,?-8(>.L=G:6*2&9.6,6+8,:.:/8.6/3,0-.+.+1)2'6&8"7!8$5#9'>/=.6)9,A7<5>8EAKIJJCC?ACCCAD?B==4:.8*:*;+8)D8NEIE@@>ABIHPAG@ICOGTEU@U?XA_DfCiCkFpIwK{L|JzFxHwKtNtZ|aUvCdIkTv?\I`{||aC;|nճξ/.,/.,0/-10,21-32.54/650880991;;3==5??5AA7BB8CC9HE<JF;KH9MJ9PK8OM8QL8OL;LJ>QPL^]bmlzzz{urke_{YSmTLdMEZG@PB<HD?F@;?<87;63;60<8/=9.;8/:70991;;3>;2?=1@<1?;/A;-F?/H?.K?/M@/O?0O?/P>0L?/@=*?>,@=.?;/?;2>93=:5:94<94D95M51V-+j)-288C>C7.7(:(?-?,9&8#;&:&<)>,@/>/=0=1>2?3=29.8*9+:,:,9*;,;-B4E9>31'2(9/5+4*6-7-7.6,3,1*0,.+/)0(2&4$6 5204$<.=/9.=2D:5-60;5D@MIKIC?=8@9A8>4</:+8*9+;-4&?3H@HCB@@DFLNU?E?EBMHUHWBW@XA^AcCfFmIrMyO|L{IyDvN~R}KrMoVuUuMjFcKf>Vdtӏd92lJ>ynХ10,10,0/+0/+10,21,43.54/77/880991;;3==3??5AA7DA8IE:LF:NH:PJ:RK9RM:SL:QK=OJDVTUfdqwxÏƎ{wpmid_[~UPnNJaKGXEBM?=B;7895296/85,85,671783891;;1></?<+B=*C<)G?,J?+K@,LA/M@0M?2L@4K>5L?6K>5F<3B92=82:946;47<59<5>:1H4-Y2-w78?D>E9<;0<+@.A/@-<);'>*8$:'<+=.<-;.<0=3?6>3:/7,7,8+8+8+7+A5C88.1&3)7-5+4+3)4-6,5,5+1*/*/,/*/)0'2#4!541/2"6)9-:0?6E=F>@7<5@9KDNGE>;1=1<0</;,9*:+<-?09-<2@:C?CBDHJOOV?E>CBLIUJYFXCYC]@_BdElJsNzO|LyIvJwTT}JqImStVtNiD^F]Xk󝞎HFk.)kc͖ɿȾȿ65143.32.10+10+21,32-43.66.77/880::2<<2>>4@@6B@4JD8ME8OH8RK;TK:TM;SL<RKAQLIZW^li|~ؚ̙ޙڔԌɆ~xvnkfe]ZwVTiMKYDAJ><?;:8;74762555457664872<:.?<+C>*F@*G?*H@+IA,IB0IA4HB6HA9G@:K=<I;;C9:=77875384/83/917<574+C1']80~C=GC>?51;/<+?-?->,>*?+?-8%9(:+9-9,:.:0<4>5;4918.8.9/8.6,7-C9@70&,#7/<42*3,2(2+3*3+2+/*-*/*.)0)1(4$5"6 57#3#3$3&5)8,<1?6YQRJHAC;E<I?E;>1:*;(:*:):(:+>0A3A6<3<6A=EEGHIMLPBF@CCIKTNYJZF\F_A_BaEiJpNwOzNxLvQ{RyOvOtVy]{SoD^TlQddt`dMMjgΏX<94;8185052+41*41*52+63,74-85.96/;81=:1?<3A>5C?4JB7MC7PG8SJ;WK;UL=UK?SJCSJK]WcnlŚڟꢩ뙛啘ݔ֐ʉzyrqfc~XVkPN\IGRFCLCBJ??K==G;:@;9:<94?;/C=-E@,F@*FA+EB/EC4CC7BC;AC>@ACB<FD>LCANEEOCHNAIL>HI>GDCHAA=2L:.gF7OAI<?28)>/>,>*?+@,@-?-<*8'8)9*9,8-8.91;5:4:3818192:2706/<5>5912(4*;2<33*1*1'1*2)1)/)-(,(-)/)1)3(5'6%7!7 9%8%6%4%4(7+8.7/NGXPZSQIG>D9@7>/<*<&<(:'9(;*>0A4D;@7@:FCIHHGGJIKFHBDDILSQZO]L]K`D^DaFfIlNuOxOxPwVxUvTvYx]{ZwQkI`WkUgM^^mKZTaTaXaefȃ~嫧@=6=:3:7074-52+52+52+63,74-74-96/;81=:1?<3@=4B>3JB7MC7RF8VJ:WK;XL<WK?TICSJM^Xfpm˜㣭ꝡᙛ֕̒ĉyyji`]|XUpRPhOMeNJcKG^FBS@=H?:>?:6@<1A>/C@/CB0BC3BD7?D=>D@<ED;BJ>CVCIaLRhU\o\br`dobbjd`afXWaJDlG>SEXFJ7@+>+A.@/A-@-A.A/=+7&7(8+8+8-6-7/81;4727272829494836/A:8/3*8/=5=5915,2)0'0(0)/)-),(,(-)/)2)4)5'7&7$8#7"8%7$6&7)9+7+4*4+NGd\`YOFA7;29->)>'<&;%9&9*</>2D9A9E?KHLIGDEEHGIICDEHMSSZR\O^OaH^G`GdIiNrQxRyTzUuZw^}^|UpMgOiYn[mctM^TeO`UgL_R_^_vqלB>5A=4@<3>:1<8/:6-84+73*62)62)73*84+;60>93A<6E>6I@7MC7RF8UI9WJ:XK;ZLA[NHTIMXR`gd|~ʗ㞪쩫蟡ڙҍtrhe]ZXR~XQzYQvVOnMH_C?M?:@?;:B?8>>4@B5BE:?D=<B>:CB>FH?LUDVnQfaristvxo^l[cWYWUVMM?@.9$:$<(=*?,@.@-?-=,;,6'6(6*7-7-8/91838495:693616183:3C<=670@7[Rlc]T?63)2)2*/)*&(%(&+(-+0,2+1'0#1"4$:(;&<(<)<*:,9+8,7-@881GAc^XQB<@;4*:&<$<&<&:(:+<0>2>4C;PJXROJ?:?:HDHGGEJKPTRWNVKXL\RfOfKeJfMlQsRvRvWvXuXu[w\xZsWnVkbuVg\m[lFXDXQeVefgieʏ網C?6B>3A=4?;2=90;7.:6-95,73*73*73*84+:5/=82@;5D=5H?6LB6QE7TH8VI8WJ9YK>ZMEUJNWQ_eby{ɔ⛦뢣㘘،ɀuqiec^`W`V]TVPtMIbFCTBAIAAC<<:AB=FEACD?A?@DBEOMRWVdchqu}}}{p`uYiVaQUHF@4;)<&='8$7%8&9(8'9(7(6(3%4(7-:2<3=5<5<5>9<7<7>9B=C=B<A;@:B9@78/1(6+I>[O@66,+#)#-)/-,+((0.4/616.3)2&2%6&:';'<(:(9*7)5)4(9/5-=6PJTQLHB?1(;(=&<';'9(8(:,:/>4B8OFWPRID=C;HCLHJFMLSRTWPVNVOZVfUhSiRkRmSqStRuMmUt\z_{\vUoRiReUfRbZhZhN^ScYiS^`_^W}٩EA6EA5C?4A=2?;0=9.<8-;7,84+84+73*84+:5/=82?:4C<4G>5JB7ND8RF6TG6WG7YI<YJCWKKXP]b^ysuܘ뙗Ӄxusmk`i]cZ]WVRwNKhEDV@@L85<A<@KABL@BQ>BZEJpW]csrz{vpcTnG\K\HP<<5.9*<'<%;';):);*<,<-<-<.6*8.<1?5A8>7<3:4714.3-93A;E?B<=5<44,4+7-2', 6*G:K>@64--),*,,,,*,*)/+2.5.4+1(1'3'7(:):(:);*:*8+8,4+<4:5<7ONYWEE3/;,<(;*:)9)8(8*8,=3A6JAUKRGG>D:G>KDICLISPSTPSMSNWXdZh[pZrVnRlQlQpGmPvZ}[{VrTkWk\mYhZham`k]gfnfm\_]W{OFmfݺIE9HD8FB6D@4B>3@<1?;0>:/:6-95,95,95,:5/<71>93@;5E>6I@7LD7OF5RE4UE5WG8WI>XMKXNW^Zqppԕ革ꗖ⌋ׂ}yumpgf`_ZYXQQuGGcA>Q=5DH8BT=C`@EnCJOU]dfxknoi`WxIg;U2HAPEM;<71?0@,:$6"5$5$5&7(8+;-</@6@7@6?6=5936.4,.(-'.(3-:4<4815-5-,")7,B6?04%.F7I<H?<7-*#%')/2-./.2.3,1*0*/)0'7*9+:+<->/?0@3@36*LBJE50GFZ\IKA?</;+:*:*:*:*9+9*<0>2F9OBPDH<C7C7H?F?JEPKROMLKMKPX`[gaqauXmOgMgNkOuRyUwTqTm[pcujxguboamdlflhjghfa^TeG<^UͫNH:MG9LF8JD6HB6F@4D=3C<2?80>7/=6.=6.=60>71@93?:4C>8EA8KC8NE6QD3RE2VF6VH;ZMGVMR[Whlk~Β㚦铕⊌نу{umkde_aY[RQsNHbWFY_CQmBLEMMTU][bZhRpRuTuPlJbBW8J.?8ECKGK>>>6F:H6?+>-=-<->/?0B4D7E:E9B7>5;26-5,3+3*1*4-7.90807/6.5,/&5+7+2#1"9)>-;)<-D7JAD?64*-*-/26755301,0*/,0-0+8191:1;2<0=0?0>17+WLaZ;6;:PQFHPQ<4:/8,9,:-<.;-;,:-<.A3H9I;D6@2>0F<E<IBPIRMNKKKLOZ`^hfrhx]qPeMeNkVzTxRrTm]qhxjweret_m`kkrrujfd\la}fVXH9kXJ|rQK=PJ<OI;MG9KE9IC7G@6G@6B;3A:2@91?80?82?82A:4@;5B?8EB9KE9MF6PE3RE2UF3UH7YLCUKLZScii|ȓޚ리횞蕙㒔ޒډ|sxoumpigj_}y_xWjP_O\S\T]PWHR@Q?RCRDPCK@D9<46JLIJAA7495A8D8>1E6E6F7E8F8G:G<G=>3;18/4,3*4+4,6-81<4=4<3905-5,7-.$;0=.1"-7&=):&9'8):/=9@@<>37,/,.+**)+(/,448899757473717-6*5(5&5(PEmcHA42CC>BVVA<>48.6+:-</>/=.9+<-?0A2A2@.=.<-C6D9H?PGRLOINLON^cagitnzduVjQiUoWvVtXp^pnywksXa`m`mbos}숊́|thyjskXON:_VGqgSM=RL<QK=OI;MG9KE7JD8IC7E>4D=3B;3A:2@93A:4A96@;7A@;CC;IE9MG7OG2RF0UF1UH5WK?RHFXR^jg}Ēژ礧흤蛢晞⒚ۋ҆ʃ„ymczXiQ_MYIRAI=A=;>8C9H:I8F3C0@1TIG?;76488:;9874:/<.;.:.8+7*4'2&4*3*3(3)3*5,6.8/=3=2;18/7-6,4*3)3&3%4%6&=)>*9$2:&4%1'51<<=@7=37-1-.--/.439:;=9=2603011/1*2(1%3$1$=1j_TL95@?:=RSJHC=:36.8.;0<0=/;*?-@.?-;*;(;+<,>0>2D8LBPHNFLINLaeafhro{hxZkUjZrYs]tarjt}wy_dgtm|eulw좟Ĕ|hjUHQ<WUFth\ۿVO?TN>SK>PJ<OG:LF8LD7JD8H@5F@4E<3B;1B92A:2C:3A<6C@9DD:JF:MG7OG2QF0TH2UH5UI=QGEWQ]jh~œؙ矠뤩蔡唟ߔו͚e]pQcIWBN>F<A<<?8A4E4I4I3F.B,?-SED<97>>DF@D8=65B;D8C8A5>29,6)2'2(3(4*5,5.4.4.4,B7=17,6,9-9-5)1%8(2 1!9(8'4"7%C07&8*6,5.3/53:9?>LKHFBB>=<=7:26,1+1)/,./.1+4*5)7(0!.dY]S@:DC;;MMRQHE;66/8.9/;-:+<,@-A.<)8%9&<)?.7)7+>1G:K@IAIBJEa_^`djnwku]iXe]m^sbtdolr~qsryyaqXfЮ]jPDR9QT?jbUXO@WP@WN?UN>TK<RK;RI:PH;MC7KC6KA5H@3H>2G?2H>2F@4GC:GE9JG8NI6RJ5UJ4UJ4VK9XNDULMZTbkh{~Ñט磤쥨ﭩ▟֦ζgzL]ER>M;G<D=B@@@@>?<=EB:4D9F:1)JEJICE>B;?<?=><=<;B;?7D;MAK>=06)9,7+6,5-2*/*/+2/5.A59+1$3&9+;-8&2245!4"4"4%5'5)0&2)5)6*4(3&3'4)2)3.5233/2-2-4.5-3+/+,/-5.9,7(4%-3"XHYN;3NI41HHOPJJC@;6808,9+<+<*;(9&;(<)=)=+<,8,;0=1?3?3@4@5A7japic_mjqqadgmpylzhxdobidjlnqoqoy{}Zlcwbp}u]rQJY:LR8snZ˷YPAXO@XO@VM>UL=TK<SJ;RI:NE6MD5LC4KB3JA2JA2JA2IA4GC8HD9LF8OH6RJ5SK4VK7TK:XNEULMYUckh{}Ӗ៞쟝ퟧ袥襤ꩣᣜбqTbCO<F8A7?:=<?@AAC<C9?AD;;B?@=31OPCF?D;B8?8;89:8;7E?=5<4G>LAC5:,9+7*7+6-4-2.3/5384>2;-6)5&5'5'5"49$9"9%:&<+<,8,4*3.5-7+7)6&4"4!4"2$2&0+.,,-,/-2.3+.,-0.2.4*5'8'9'?.*D5>1F>VPB?BAUVRRKHC>=59.9+8(;*;(:'<)>+?-@/>.:,;0=0>1?0?1B3C5i\mdb[kfolbakltxq~o|ir]fY`bfqpzxvwx~Rd[p]njkZtON_;SZ;us\ĸ\PB[OA[OAYM?XL>WK=VJ<VJ<SG9RF8QE7OC5OC5OC5OC5MC7JC9JF;MG9PI7SK6VK5VK7TK:WMCVMNZWbkiy{ˑ֘ޙ㘙隝蜤㜢᝙㛙▛ߚڤбrYqBSAL>D=?==<?=?>A>C<C8=?AA@C?<896WWBC>B;?9<686696;6HA;15+A5K>H:=/8)6)7)7,6.507195=93*5*6*6*5*7):*>,4!44!6"8)8)3(-%@;>8=3<.9)7$7"7#7%3$/&.'.*.-//./,)0+5-5,3&4%9&>*A/1 SE;0A;C?JITUUTSQOMJCC;<28+6&7&7%7&:'<*>-=,=,:,;/<.=/=.?0C4E7\Qg]aYlgpma`fgjqR^^khqem`geiqqxwtunuJ]Rh[m񜡣a`UoHOd=W`Aww]\PB\PB[OAZN@YM?YM?XL>XL>UI;TH:SG9RF8RF8RF8RF8PF:LE;KG<OI;RK9TL7WL6WL8WK;VLBUMK\V`jh~yyΓҕ֕ۖ㘛蘞욢훣뜥蘢ߖڕՔՓ֑֒҅}sfVzGa<KAJBCCAB?AA?C>E=F?F:>?@EDA<61>:ZYAB@C=@:=8997<8A8E;:.2(</E7E6>/9(8)9)8.:/8091;7>81+2*3,5,5-7.9.=/7(:)<+<,;.;0<695C@@<@7=19*9%:&;%<(7'1%1%1(3,1,/*2*5,7+7)5'7%;(>*;(<,^PF<3/.,@@WXusrojg^YPGA75(. 8'8(8&;)<,=-=,<-;.<.</<-;->.B3F7MA`Wa[pltr`a]a]dHTYegrgoelkpsvvvpsenDXKbXk뒖_zYQlCSh?\gEy|_\PB\PB[OA[OAZN@YM?YM?YM?WK=VJ<UI;UI;TH:UI;UI;SI=OG<OI=QI<SL:UM8XM7YL9XL<UKAUKI\U]hexut|~ŽÏȐϐԒܓߕޕܒ֎ΉDžŁ}~}tpg\NvAc:U9KAGECGAGCEEAG<J=JBI>@@?IE>82,C<UPDCAC?@>??=@<D;F<=28*5)9*=-=-;+<):*;*;/;/8/8/83:59552202132402+0'1'7-:07.4-40:;?@8;76715,4&5"7#:%=)8&4&5'8,:09/8->1;-8'7%9'<)<):(>-:*>2C:/-::245653;6C>KCQISHTHUG?0?.<,=->-?.?/>0<.<.<.=,<,=.A3D6LAbXc]nlrr`c`e`gkvozkv`h_flqx{y|ms^jAWC]Uh懍g]YtI^uIhwPfǻ伺޺޼[OA[OA[OAZN@ZN@YM?YM?YM?XL>XL>WK=VJ<VJ<WK=WK=XL>QI>QI>SK>UL;XM9XM7YL9XM;WK?ULGYSWe^nnjut~}ȍώԏՏӐӋʃ|u|ovioljlcyYvPoBd7V4L8H@EFBJCJEGGCJ=N>LCICCA>ID;44,I@LFBA?=;;<;@=E?G<G:8*8(8*9(9'8&:(;(;)=,<.;.8.6.6/5032./,00247774521.*4/6232/1/46=:D06023/3,5)7'9(<(8$6$6(:,>2A5A5A6G8A1;(9&<)=*<*8&:+7)0'C<2/?A/2*,1/5.81908.5*2&1#E5A2=.:*9)9+:,:,;/=0>/<.<+<,>/A2SGg^c_jinochjqoxq{t~mubkdnrzx~quipWfAY@[Qf~ykm]oZy`r֭ӦЧӫԮֱں[N>[N>[N>[N>ZM=ZM=ZM=ZM=YL<YL<XK;XK;XK;YL<YL<YM?SI?TJ>UL=XL<YN:ZM:ZM:YN<YM?ULEXOR_Wbd_sjfsoyy|~~ƈˉ̉ʈȃ|}vwpqklfgl``qV^N^J^@X6K3F9C?BD@HBICFIBJ=N>NAEFDA=HB:/7,OFB<=8641051>8E;F9D59(:(:*:'8%9&:':&9&:):,9+7+5+3+3-*+*--3/4173738588;8<9>9A9D7F6H5E+5-2124/6-8*;+=,5&8*;/=2>4=4>5A6J<G7A1<,9)9'8*9)2'9/@8D>0/..46663-7.90:1;1;0:0;/L?F:@19*6)6(7*8*;-=/>0=/<+<+<.=0KAdZc^kiosinrzvfpoyryjslvwv}hocnRbB[<YKat{z}k{fhṷշˮȤÓș˝ˡΧҰٻǾ[N>ZM=ZM=ZM=ZM=ZM=YL<YL<ZM=YL<YL<XK;XK;YL<ZM=ZL?VJ>VJ>XL>YN<ZM<ZM:ZM:ZM<[OAWMDWML\RZ^Xfb]qjfspwvxx|{~ňȉǂ}yzuxqvotkpgzaQZHEEHHOBN:F6A9@==A=D?EBCHAK=M?M?BGDA<G?9.:/UK>583/,*&/*:3C9C6>/;*;)<):';(<);'8%5$7%8)7*5*3*3)2*33588<4:-2(-(-+1-3)0&1)6,?*A 9/"0(.,10/1,3+5)6*6+90=6>7:4715092H=K<E7=/6(3%6)8-4*6-C<8221 89631(4)4)5)6+6*5+7+YNRFH;@2;/;.<1<19-;/=0=.;,9*9,:-<2YQb]ppvymrq|r}zyhqepq|ukt^jOaA^8WG^ntn~ghqͭܽٻԴ̩Ÿ~đřȡΪҵνȷZM=ZM=ZM=ZM=ZM=ZM=ZM=ZM=XK;XK;XK;YL<YL<ZM=ZM=ZM=ZL?ZL?ZM=[N=]M=^O<\O<\O>YM=WMCWLHXNOZPX]Ub`Yia\rjfokspvq{u~ɊLj~yrrtl\HLB9A:C@@?:;<>DE><=<>=@ABICMANAL>>@9?6>3</<0D8MD61;62.3.C;?36'>,7%:'<);(9%9&:':(:'9(6(2$."/%7.=582400-**&(%'%'%'&*!)".'7(>!;61'8#,#++---+(-)416264666512./,,/,92:191SK"+#F>.&.(<7E@:7/*.*51<7>4<.5)3&5*;.;08.bXZOC:6,:/8-3'6*0%2&2&4%6':*<.=1:0C;\Wppsvx|yq||wt}s{r~r}mxgs`nI\>\>[AVekzm}f~cjw|vzqyo|rvuwy§̹Կ̺ZM=ZM=ZM=ZM=ZM=ZM=ZM=ZM=XK;XK;XK;YL<YL<ZM=ZM=ZM=ZL?ZM=\L=]M=]N;^O<\O<\O>]P@[OC[NFYNJZPQ\SX_U^_Wfd\tibngqjxpyĊď~tnqujW{=A5+5+<3@8>8?:A==;;<;@>B@IAI@KAF<9=4<1;/:,:+A5JAG@A=6351@9C89+5#8';(=*=*;(;(:(9(9(6&2%2%5*8.80911&/%.%,&+'+),+-.*-%+$.'7$;7300.93<*1(,.002+.:>7=4:26/40325872-;582E?E?/+2."51?:E@=83-2,60:1:.9*5'5(9+<0<29/cYXN@84+91:06,9/5+4*4*5)6)5(6(6);0B9YTljqtx||v|yv~usp}kwdq_nI]>\>\CYehwozbu\x]ckppmp]l]h\g^k_qeyizktv|}ƷǿϼƷ\L<\L<\L<\L<\L<\L<\L<\L<ZJ:ZJ:ZJ:[K;[K;\L<\L<\L<\L=\L=]K=]M=]N;^O<^O<\O<_RA]QA\PD[NFZOK[PN]QS]RZ_SgcXvh]kbskv}}vpuviRt<D5-4+<0C7E9C8?9=<:>:A=E@GAH@E@B;6909+9*8(9*?3F<D>9674;7C=OEH<3#9(:';)=+=,<+:)9)7)2#/#4*=3?6914+4&5&2%/$,$+%+(+(+-(+&/(6%:733%70;5A8C;D<E5>,62</;.9-7.3.1/1420,=964;9mjCA/-/,:7@<A;<67.5-5+6*6'6%6'8);.<1<1;1`YTM<30(;3>6;3=6=8<7=6<2;19.6*6);/@6TMgeorz~||yxwsn}gv`p[mG^<Z>\FZ`a~evZiQhOmRtX{]}^x\qX`zM_PaUeYn`ug}j~mrtxyyz~ǹ˸ȶ[K;[K;[K;[K;[K;[K;[K;[K;ZJ:ZJ:ZJ:[K;[K;\L<\L<\L<]K=]K=]L<^M=^M;^O<^O<^O<^Q@^Q@]OB[OC\NE[NF\OI]OO^P_bTmdY{i^pg|t{{zxucMlFRA@A=E;H;G;E9A:@A<A=D?GAHAF@A?<?6<19+:*9)8*>0D:<731;9A?D?SLUJ:+9)7$7%;)=,=,9*8)4&2&2)9/>7>65./&6)6)4*1'.)-)*(**),','1)9&<!;=%A6H(6.<P\`lP\<I9G)8*8-90:2701+*(%0-722/C@spVS>;GD=:<9:5807-6*4&3#5#6$8&;,</9-:/<2XQMG700)<7A:;5<5>9=9?9@8?5<2:.9-9,=1NHc_no|~yyyxtn}et^nVhE\8V<ZH\YZlRcrG\tB\yCdzIl}PtVvXrXoWmZl\obuh{loqpqtuvvvwz|{|ȷǸ[K;[K;[K;[K;[K;[K;[K;[K;ZJ:ZJ:ZJ:[K;[K;\L<\L<\L<]L<^K<^K<^M=^M;_N<^O<^O<^O<^N>^N>\O?^NA]OB^PE^OJbNYbQdcTqdZ}lexrwv}‰΂wlXwD_BTDPJPIHE>E<F<D>BB@C@GBHDGCDA=?7@7=/:+:*9)8*;.?6FA=;BBAA;6JBXLK>@28(3#8(<-:*7)8+0%3)8/;4:5600+,'0,1-10312537486;-5,6.=0C-F)G+N3R9L3?@M_llzWfCS>P3D3A3>6<99834*/$2*.(72YT\ZXVA?HFB@<7706-8-9+7'5#8#9$:(=-;,6)7.=5NGEA501->9@:815120215283:2:/9.:.6*8+IB_Ynl}v}w~yxsk}dv^pSeF]8V=ZL]TRz_BWh<Yq?[vCfyKn~QtVxZy_wayexhzm|qrrporttttrtw{xxZJ:ZJ:ZJ:ZJ:ZJ:ZJ:ZJ:ZJ:ZJ:ZJ:ZJ:[K;[K;\L<\L<]L<^K<^K<^K<_L=^M;_N<^O<^O<]N;]N;^O<_O?_O?`P@aQAbPFbNPcN]_Pe`Usgato{t}qv̋ۂrduPd;R3L<QERDK?@@>C?EBEFBDAECFDEEAB:?4?3;-8(9(9)8*:-;3IE??=>782/A:ZPh[PCA35%6'9+9+7+8,0&6-;4;440/,-+--493;3=3=1>0=1=1>0A1B4K5N0N-O1X>_3HO\an_nWfP`DX8JAQ:G2:/22-8-;+:*:/2(JBkcLGPK;9;9LJ@<707-</<+:);(;&:%<)>-9)3':/D;GAC=722.;7:62.2-,-,,./3171:1<1>26)4)B:XRjh|}v}xzxqi{bt]oQcI`:X?[O_QNqX:Sf8]uEa|InSvY{]~`gll}m|o}ponllqqrroprtvtwï̫̾ZK8ZK8ZK8ZK8ZK8ZK8ZK8ZK8ZK8ZK8ZK8[L9[L9\M:\M:]L:^K<`J<^K<_L=^M;_N<^O<^O<^O:_P;`O;aP>aP>aP>aP<bOAeMMdMW`O_aUmgbuq|vsu͆~qyclP[;M*F2Q<S<M<E@ECDBCCEBCADBDDBC>@8>3>19+7':)<*<,=1?7=:9903/24294MElah[QC</:-:.7*6+8/4,7/93621//,1/152C0E-F*B%@#= 9 8'A+E.M/P+P)T2`AhCX`mhuVeKZL\BU2C@R7C-1((.$8&?&@'?.:,YM]QG>D>63;7UQF@918-:,9(9(=)?'<&;&=*7(3(=4LFGAE@963073510+1-,/+-./1/4/81;1>29.3(;2NHa^yzz|{xn~ew^pZlL`Ia9W=YM]JGhQ1Qd6\tDf~Nu[chjnsttr}pnmllnnoolknrttwƯν̻ʤ[J8ZK8[J8ZK8[J8ZK8[J8ZK8[J8ZK8[J8[L9\K9\M:]L:]L:^K<^K<^K<^M=^M=^O<^O<\O<`Q>aR=aR?bQ?bQ?aP>aO;bL>hOKgNRbP\cWkjfuv}|xzƄ}uzlmY[DL/I5R<U<N?LCKBH=@AC@A@AA?C?A9>4=0?1;+8(<,?.@1A7C=7485..30:60'5)UGwj[PC7<0;07*6+:0708263320112364<%6#9"9"9!865629%B(G&J'M3\Ehbu`lWcQ]P]MZ@M2==F7;/./(5';(?&>%9'8+VJ;2?8412/C@WSHA916*6(5%5$:(<(:&7%9*4&1%?5RJIAHB;62.411/-+22,/+.+-++-*1*4,8,=12(7.IB\Xww}vj|_sXlTiD\D^6U:VLZHC^K-Mc5Uo?b}Jt\glnrvzwr~m|i}ggikmmlh~ijosrxũʵ¶Ş]K7\K7]K7\K7]K7\K7]K7\K7^L8]L8^L8]L8^L8]L8^L8]L:]J<]K=^L>\L<\L<[N=]P?^SA`SB_R?`P@bQAcRBdQBdNAdLBjMIhKMdPYf[lnkw{Ђy~sqjba^JW>Q:L?NCQ@K<G>F<B<?<=<:>9=4;0:,6&A0<,6(A5F==57285715.6-8*<*:'6%;0SLZOE98*>.B3:-3+GB//5:6=,7BM'3&2)2(2'"*'/'/&)+7 .&7-A#;Xr-D]l_iZcU\PWHM?@84>7A7?17&2!6#;'<)8-7/E?;7316454DCLHKED;:04)5(4)5*</9,/#(-$9/C;H?PFE=700*0,211314/101010.0.2-5-9/=02%>1=3_Ysqxh}_w[uUoLfEc:Y;[?Y]i@;VF-L^6YuBgMw]}cgjnonm~l}i|h}feflmlk~gfgimrv|z]K7]K7]K7]K7]K7]K7]K7]K7^L8^L8^L8^L8^L8^L8^L8^K:\K;^L>_M?^N>[N=[N=\Q?^RB_SC]QA]OB_OB`NDbPFcOHeNHiMJgNQeS_g_tnny~ʣxy|{vji`]aOZFRHSIVEP?J;E9?:<::=8?7>4</<,<+?-8(:,A6<461<7505-5*4(8&:&;%9'6.A;MDI<>/8(8);.;4JF016;6A.<@N'4$,%(),+,*+((((+,$'%(%,;D'4CAR&6jubjZaW]OSBC<8>68,D5H6>,/)((-%:6TPHG5445==WUGBG?A99/3)6,7/70=3915.2-4.83?9E=J@A86-0*0,210303021201/00.1-4-9-=13$</=2^Wvstf|\vXtQoIh@a:Z?_I`S\{?7RF.M_9ZvCeKsYx_wb{f}i}j|i|i|h{e{d{d}c~e|j}l}l}i|e}ccchkps|xdppR^^]L8]L8]L8]L8]L8]L8]L8]L8]L8]L8]L8]L8]L8]L8]L8]L8^K:_N>aP@`P@]P?\O>[O?[RC[QE[QG\OG\OI_PMcQOfTTgUUgUUgV\h]nlisv|ˊԘנʪ}π䄆vsjegS\GQFOHREQAK=E7=7:99<7@7A4?0>->-<+:,B6H?;20):26/6.7,8,7(8&9&:*4-4.A9OCH:5%2#@2>5HD135;7@4@ES2?)0#&$'13-/''&%12)*8:+1)13=R^=K[g^fV\OTMREI:;74?96,?2B5=17-3),#' %/*EC::,,35AB^]?:C;A9=39/=4@8@;@<=;>;A?>>::?=IDB9<45,2+1-311202020201/00.1-4-9->24%8+;0[Tzw~rdy[tTqNmFg=_=\EbTgAHp;3SH2Qa<]xEfNrZu^t_xc{g{gyfyfycxbybya|bzczf{h{h{e{a{`}``jnstwuynolSeYAPM2A>^M9^M9^M9^M9^M9^M9^M9^M9^M9^M9^M9^M9^M9^M9^M9^M9^L8`N:aP<`Q>]P?ZN>YOCXPEXOH[QO_UTbXYeX_iYcl\fk^glaildqokrty~ʅڌᎇןӭijy{ށzwsrcgU\MTGPCM>G<B6;8897<7@6A4A1?.:*>-=0F:RGH?5.1)9181;0=1;-6'6&8+5-2+=4NBK=:,8*B67.>:/0164<8BNZLU>E38$&/1,,22**/.::37,29@EMXcMW=CADBF>A9=8988978391:2A:NHVSNNC@7295KIMLQRYZRQYV51>6B9@7?5B9C<@;?@8=9=?C:?58>=MJ93603+3,4.30210102/201/0/.0-4-8-?36'5(9.VO|yzocwXqOlFh@c9\?^KdZh35g;0WO8WgCa{KjPsYt\u^wbyezfwdvawav`x`x`{azczfzgzfzbz`z]|]~_gntsuqtiidQcUDSL8G@^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M9]K5_M5`P9_P;\O>ZN@XOFXQKYPQ`W\g`hnfsshysg{sg}qh}ol}pqrwv}z҄响㝌ڠulnqvlvismllgi^`RWFM<B7=5;7898=7A7B5B0@/7)@3:0;1RH\QMC;0907-9/>3=16*4'6*3,70=5E9F9B3A2>20&720/.1.47?PX]dZ_OS.103,-EE66,,-.>@2537bh=B*2-4&*;=@E6:379=7;/043;;GFRS`cilek^a@>E@^[hgopjjKK=;40>7D<C;>5<4:1415;-7,6.8,4,39<JK3/3.3+3,5.404/2102/2/1.0/.0-3-7-?38*2%8-NG|ywl|atTnHg>b:_6\AaNeWap/+_?0[W>^lIe}MkSt\u_v_xcycxbu`u`u_v_w_x`{azbzd{e|d|`y^yZ{\}^agmpsr{nrjexe[k^RbU_N<_N<_N<_N<_N<_N<_N<_N<_N<_N<_N<_N<_N<_N<_N<_N:^L4_N4`N8^O:[N>YOEZSMZTT_Zahbprmzu{u{qzpvpqtrxt}wz~τڋޖܙ͛~yl[Q>MBQIWRWUSRKM>C4:9<9;;9=8@8B6A0?/9,A65+.$I?g\dZUI<26)3):0;06,3)6-1*71;29/>0F5B39+1(4-31-.*.17EJV[]b\a9<9<+,JK89//57()'+XZ>B9=6:#(+<>AE49,21705(.37KNaehncl`i`lbkLLNJ\ZVTMMHF423/A<KDOHJC@8:36..-2:-:*7'4)40:>CJJ1.3,3,5,4-4/4/3/02/2.1-0../-2-7-=1;-1$7,C=yv|qhx_rRlDc9^6]6\FcN`IMe5+VD0[Y@^lIe|NkRt[w_x`{dzcv`s]r\s\t]v^w_{azbybzb|b{_x[xYzY{Z~_ekmsus|rupnlfwe_P=_P=_P=_P=_P=_P=_P=_P=^O<^O<^O<^O<^O<^O<^O<_N:aP6aP6aO9^O<[OA[RK\VV_Zakgvso}z~|}w{uxvsys}x{~ĄɍΔ͚ǠɭŦmfJE2A4@4B9HDNNJK?C=?;=<;=:@8@5>1=0:0?64,1'I?cVh[eWOB>24)7,905,2+600,4/7/7.>1C4>04%4*0+3/..-.1478BEMRY^FKQW37FJ8<AE7:.005HK7;7:#%;=8;;><A6<-6)21;<DLS]eksjs`jZgXh[fddZVWT@=104433C@JERKSLJA?7938133.70>0=*7.:;ECHAB1/4-4-5,4-3,4/4002/2.1-0../-2-7-:/>01%7,;5sqvi}at[pPjCb7`7a;_LfO[~86]=0NF1VX@ZeEcxMjRr[v^ya{dxas]pYpWqXqXt\u]y_x`x_y^z^y\xYxWyV{X_dhloqmxjqij~cbv]_P=_P=_P=_P=_P=_P=_P=_P=^O<^O<^O<^O<^O<^O<^O<_N:cQ9cQ9aP<]P@ZPG\TR_Zaa_mtryx~~yyyuwww|x}ĂąȸоѻЬoT\GG5>0G?WQWVNO@C=?<==;=:=5:19080<5:3=5OEXM]OeXcUL>:-8.914-2,60402-5.<3C7C4:-3%5,.&0-/,3154-.24BFX]W\ouDJHM<C[`ou=B}mqQT>@02:=HK9>7?=F7B-8>J]gmwjrcn]g^kao]nYe\]PIJG74/0540.95D?JDIA@86/4/7166'/0<2=+60:>E?A443.5.6-4,3*3,4/4101/2.1-0../-2-7-9.?20%6,61popcx\pXnOiBb9a<dAbRgQWd/'WD3GG/RT<U^?btLiQq[v_zb|dx_rZnUnUnUoVrZt\w]w]w[x[y[wXvWvUwTyXzZ~_cd~f{fr]iX`vRZoPRgH\L<^N>`P@`P@_O?_O?_O?aQAbRB_O?]M=]M=aQAcSCbRB`Q>dS?aP>]P@^QI[QPZSZeapsqyxz|~}xzrslotwv{̀ʋƖäƳ̰ϬϧϣУ˜˜Ѩg^FzgueH?QNccKL?A89:::97561;6815.B;<3I?XKOAdVcTXIG9:/6-7/6/4/0-2,70=4<07)5(7,/$/&/)1-2040516479JNY]NS8=6<X`~~ougoipfl\aX[Z_UZDK8B7A2>+90>=HS_`igrepbmcn`o]gSSF@854111/.3194D=B:?7<4908193667<4;4;4<6;59331/3,5.7.5+3+2,2,201203/2.1//0.3.7.?58,6,/&;7XW{me|\rPhGeCe;d9`NlRd=?P, C;&CG.KM5Y_CZjEcxMqZxbx`t\rYqYlSmRnSoTrXtZu]u[tXtWvXwWvWvUuTtS{[{]z^u[mUb~MXrCSj>AW0?U/<R,[K;^N>`P@`P@`P@_O?`P@aQAbRB`P@_O?`P@bRBcSCbRB`P@fVG_QF\OG^TSaZad`omkvwwy{}}x|qukplonquv|~ՉӘΨǸźαתۥޥݢۤأѠǛӼ}dŋw}mVJa[rpZ[KL?@=>>@;;6664=883?86.>3K@H;]Mo``QH:5)0&6-5-0)5195=7<38.5)4*5*7.5+2+0+0,2,4.5287>@JLW[^b\d]eaiS[NVQY_gjqflZ`NT4:,5*6-9'5!-'67CPZZdbldmencm[hQZEE<7646355302/62>9>7;4:3818295:69;7:7:797965312,3,6-7,6,2+1,1,201203/2.1//0.3.7.<3=28.1*74Z[s}fz^vWoOiFf?b<c@cOhKVx;8L2#<:#<B(EG/OS8VdA`rJnXu_v]tXqVpTkOkPlQmRpVrXs[sYtXuWuWuWtTrQqRpQnPlNhLbFXu?Ni6F]/@W+@W-@W-AX.YL<[N>^QA^QA^QA^QA_RB`SCaTD`SC_RB`SCaTDaTD`SC^PCbUM\QM[QRcYbkdtqmvuy{y{y~x|nsei`gjnru}}ׇݗ۩ػؿۧϡÜkpo`RG]Umiuu__JL@DAD>@8:66=:;6A:707,>3=/F8j\i[[MB62(4+6-2,52A>GC=62)1'2'0%4*1).)/)2,7/=4B9-(43DCVX^bZaS[Q[FQHSOY\fmvntY_>D.5-42<2>+9'46EKWISPWW_^fck`iRYBI977175<8;;955160:3;290907183:6<8999997988874402+6-7-8,6,2)0)0,10121302/1//0.3.6.90D9804./._blwbxWsPmLlCf:];_IfSgDJl;4O>,=<':?(ED/FH0Q\<YkEg|Qr[tZqUmRkOiMiKiLkPmTnUpXqWuYuWtUrTpRmMkMjLeGaE[AUt;Li3E`-AX*>U'B\/E_2Ic6WJ:ZM=\O?^QA]P@^QA_RBaTD`SC`SC`SCaTDaTD`SC_RB\PDZOMZQVbXcjcsqmvuxzz|w|symrbi]daglrx{ʉߕ夡䶵۪ө¡vqrcbWi`rmut[]LNCG@D<?;<:8<8E?C;:0:/6)1#I;aRk\SE:,4'6+4-42MKZXKF803*4+2(.&,%,%-%1)6,;0?4/'4,:6CBFHEIGNMVQ]VbXb\egpmuYa;@17.4-6+4%2(4=IS_?IAIGLQVY`X]GM685373;8@>@?=;957282918080717396:7:7;9:7:8:6845.3+6,7-8,6,2)0)/+0/222312010/0.3.6.8/F<913.,,fjygtbyTqKkGj>c6Y=^QhXeBBgC7[N;GF1AC-JH3EE-LU6Sc>btLlUpXnRkPiKgIhJhKjMkPmToWpVtXsUqSoPjMgJeHdG`D]AWy=Rq8Mi6Lf6Ne7Of8Lf7Oi9Sm>UH8WJ:[N>\O?]P@]P@_RBaTD_RB`SCaTDaTD`SC_RB_RB^QIVMR_Xhnf{tpxtxwxzy{syjr`g[c_gjrv|ƀΓ䭮绽߹׶еƱy|qvksimeoi扄~sredWYMNDE@@:7;7B=E?<3=3B51#0"I;XKN@=/8*6*3*42UUkh]XD>;3;2804-2,1+0)0'/$/$0#9,4'3):5CAEGBG@HDOOZVaVa^igoYaBG:<5738283=9CHSV_6?4;6;ADJOIM;A135195<8<9;9:77370;2;1:09082736475:8;8:8:9;7956/3,7-8.9-7*3)1)0)1-323322011/0.3.6.7/C:701-13jpqzft]tPmCf=d9c8^EdZmV[wE>dJ=aYFTO;KI4PI6GE.GP3L\8ZlFf|NmSmRlMhJfHgHgIiLjOlSnVoUtVsUnRjLfKcHaF_FZBX|?St;Pn8Ok:Rl=Wn@ZqCUo?Vq>WqARE5UH8XK;ZM=[N>\O?^QA`SC`SCaTDaTDaTD`SC`SCbUEaVP^Vcje|yu}yzyxyvyswjrcj[c]ehpv~ǁшәݣ௳㻿þŹx{tyvquleleoga[`[smyu{|yrpccSTHGC?>:<6A;:1C:TJ>26)9,=.?/B1C5@17-2/LM_]WSD?:48170939292:19/9,8+8)(3"@2I>D@;:7;:@7AHRV_Yb^g`iU[AE@>?;ACGJLTQYT]V^4:/5/37:=A;?4812429586422020404.<4=4<3;2837343438898889997755/3,7-8,:+7*2(0(0(1,424332111/1.3.6.91<3710-@CnukubqRiHf;a4^6b>dNi\iGFjF:]L<]VCXQ>RJ7OG4ID.DJ.GU2Sc>^sHgMjOjKgGgFfGfHgJiNkRmUmUqUoQjNgKcH`E_F^G\E[~DWxAVr?Uo@YpB]rG^uG[sCYtAXs@NB2QE5UI9WK;XL<ZN>\P@^RBaUEbVFbVFaUE_SCaUEfZJh]Yngwup|x{ywxvwpujoah^f_gempx}͉؏ؙ֪֡۴ߺɼĻqqqtpopfewhenj_Yd_ZTf`snzv{wwshfZWRNHB=6D=;4G=\R;0<07+6(>.D3B3A1A386>>CCB@=7817/7/:393:3;3>5A5E8G6-;%J8L==50+009>AJKTU`Ze]eYaLR>@4/7/;9@@CHDJBI?F5;26368<7914/2142095740.,*0,3.3,=5=4=4<3:59565655757576866542.1+7.9-:+7*4&1&1(1,425342211/1.3.6.;34+:520UXpxcnZiI`Ef8b/]5bBhLePYj5/^G7XK:UN;[P>VI8M@0JC0@F,AO.K[6Xj@bxGfJhIfFeDcBcEeHgLhOiRkSnRlPhNdJaH_F_H_H_H_H]~G]yF]wH`wKcxOczN]uC[vAZu@JC3MF6QH9TK<WK=YM?\O?^QAdWFeXGdXHbVF_UIaWMg^UlcfwryuxvtsrrtulpbgZa_eflmsv|ȁӏݗޛՠөڮݱݲ۴ڶ۵ֳѮɫΤ~|xdbgiefcYZj[X{c_yVPc]NFUM`Xkcwrzzwnja\TOGBOIB=G@WO,"1'4'>.E6>-2"7'E7E?973.50;5=5<4=4;4925.4+5)8+<,?-S>G2<):-=2;57443KNMRPUTYY]VXMOD@5+7+7/52242618.64>3;5?9B4>+5(3/9-35759./*+0.515/<4=4=4=4;6:676664635253455411-0(8,:+:+8(4&3$3&4*5052423/2/2,4,6.=4/&>935bgoy[iNcC]Eh:e0]6aGhJ]CFR,#VI8SL:OH6[O?UI9F?-HF1>B'@J(IU1Sd:_rEe}IgJeHcCaBbCcEeHfMhPiQlPkMfJcIaG`F`H`I^G^F_}G`|Ia{Kd{Mf|Nf~N]xC]z@^{CDB6FD8JF;PG>RH>WI>]M>_O?`Q>aR?`SB_VGbYRgb_ojnso~wqzt|yywppgg`a\_`bfhopyz̄֍ߖ眙栞ݡף٤ڦإץԤӥѣ͢ɢȟÙ|rn}igld^`fZZkYUrWP}WNWORIZPXPZSkdyr|uqus_]PLEAZT712*6*7(7'7&9(;+<.?18.<2?4;05(3':/@590907.7+7):*?,A/=.@4E:G<C;<42,+&<7EBOLVSYVXROIC:;*:(8,5../*2(3'6->+?*?)?(?&?$<$<$8'9+<,9+5.545;984:3;4;5:595735435465454535/5,5)8,9*9(9&8&7%6%4&5-4/504.5,5+5*7,907/:6?BmwbsSjIcKj6[6_<g>cNjIV^$"D, ?:'HE4PM<PI9EB1>C/?G/BH&EK%KS.S]8[kDavKd~NdJbF`Ba@cBeFhJlPmQlLiHgGfHfJeIcHaGdJdIbGc~GdJdHe~Ga}C[{<\=_B=?4?A6FC<JE?PE?TG>[K>]M=`O;`Q<^SA^VIc[Xhcinlysotpvptppmgfaa]^\\edkjtr}{φٍ易囖ٜ՝֞מ֝՜ԛўќ͜ʛǚēxtk|mdif]^f[YiZSoWM{UJVKVK\RYRXRfaqjvo~wusgdUSZU2,/%7)7&7%8&8';*;-=/9,9,:,:,9+9+8+8,;1908.8,9*9(:&9&6*80=5@8A9?7<4914->6H@OGQINFC;7*7%8$7)4,//+3)7(:+@*A)A&A#@!<=:: 9%;);-9197:;;94:5;4;5:595735235465464716/5,5)9*9*9(9&9&8%8%6%5+3+4,5*5*6(7)7*;14,54TYes[pGbIhAd;`3[;aMmLb8?S*$A5'69(;<,B@1DA0@?-=B.>G,=CKP'\b<eoJhvRezQd~OdLaFaAa@c@gDiHkMlNlKjGhHfFgJfIfJdHfKdIdHdFeGeGfEb~A]>_?bB69.:<1??7DA:KB;OE<VH=YL<^O<\O<\SB^WMc]]helom{sqsoqkjfc`\[ZZ\]\_hjnowx҆؊܏ݓӓГГҔѓѓВΕ͓ǔĔzr|ewu^fi[[d[Vd[RfXKrVHTHZQ`Y\YYWcbkiokvq}ynhaX4+2&8):'9&9%9&;(:+:,:-5)5'8*>/>/6(/":.8-7,8,:+:)9&7$5)6,8.:0=3@6A7B8:1@6E;F<H>G=@67+6%6&7,4/03-5+9*<';'=%=#;!:77686$8*;2<6=8;::94:5;4;59585735236475565616/5,4(8)9)9'8%8%7$7$6%5'4)5*6(6(7(6)7+<21+88kr]nPi<[Hl7]>e5[>bVq?Qa#(L/);7+07'37&9<)@=*A<(@>)BB&?FXa4s~Tdw`hSa}LaG`C`?a@c@hEjJkMlNnMkHhHgGhKhKfLdJeKdJcFdGfHfGeFbBcDeEhH25*58-;<4A>7G@:KB;RE<VJ<XL<YM=YQD^WOc^bigronrormjg`^WWTUWX\_aclnrs{|΂Ոيی܍׏ҏΏώЏюЎύΏʎƏxo_p|Y`lXYd[T^_Q_\IjWF}SEUL\YY[X\cgkkplxs}vzs~{ka<28);(:';&:%:&:'9)8*:.6*5'8)>.>.8(/!6)5)4(6)9+<+=*;):-:/909/:1;1<3=3D<E;A9=3<4A7@8;15'5)5.31/5+6)7):&9&;&;'<&<%:$:#:"7#7%7,;5>9?8:8794:5;4;59585735447476665726/5,5*8*8(8(8&7&7$6$6$5%6(7'9(9(:(9):+:13.HKoyVjD_<_Ag3\8b>cMlOe0=J C1-11'.6'4=,=B.B@+B<$E>$HE$U\0p~Mr|mjW_{J]~E_Ca@bAfCkJlLmOmOoNlIiIhHiLiLhNgMfLdJdGeHgHhIfGdDgHiIlL-3'36+891<;6B=9G@:MD=QG=SI=SK>UNDZUQa^eigumklkjhb`XVPPQQXY`cfjorux|Ђֆه؊ً֋ϋ͉̊ЉшъщЌϋȍ~wmYjSZnVTc\RZaOZ_HeZDxUBLDTRSWRY^dejkluqunoh~v{~l`?28(;(='='<';':'8(7):/8.8,9+:+:*9)7(9+7+8,7+7*8*<,>-<0=0<2;/:08,7-5*@7@5=49.80;1:25,/%0)2025/8-9+;,<-?.?/@/@/A/?-?.@)9)8+70:6=8=774394:5;6:79585654448485676726/6,5*8*9(9(9&9&8&7&8&8%:&;'=(=(=*=,<.7/;8^eaqPi<[Ai4_4`1YKlYq>NZ%-C),:2/-0)08+7@/:B+<<"A<UH(`[5{Slwo[aK^F`DcBeDjGoNpPoSoSoNlIiIgGiLiLiOhNfJeIdHeIgIhHgGeDiIiKlN+1%.4*470893>:7B=:HA;KD<NH<NG=OJDWSR_^ffeugggfba[YQQNORS[^eilouwz|փ؆ن׈ՉӇˆȆ˅΅Ѕ҇҇ЍҌˍ{v|jzVcPVnUQd^P[eMXbIb^EsXCOEWRUZSZ\caggjpoyrqh|tsjxm\Q;+5#;'=(=(<(;(;)9*7*5+7-:.:,:)8':)=,=.@2A4>18*4&8)<,:,:,;/;-:/9+5+5(6,;/>4?3?6>37.,#+%-*02391;0<0?0?0@1@1@0=/<-9,9*7/</;0:3:6;69554294:5:6:79585654459596776746/6-6*7+8)8)9'8'8%7'9%9$<%=&?'@(@*?.;061HIfrOdHf7[Am/]7a4XPjUfm19E(*E697325406906=-3;#38CCja:TwΗǓ}vbeQ`F`BcBgFmJrOrRqUpToNlKhHfFhKiLiNiOgKfJeIfIhIiHiGfCjJkMnP(0#+1'/4-350764<85@=8C>8IE<HE<KHCRPQ[[eabtbb|``_^ZXTTTT\]gipsvx{~ۃބ݄؃օԆу˂ȃ˂̓хԈՈӍҋȋ|wpveo~U[|PQnUNf_O]eMZdIaaGq]ETF]TZ[VZ[a]daellzsrjxoYP[PD85':):'<&='=(;*:*8*6*0'3)8,;,;*;(;(<);*C4K=H:=/4&5';,9)9)9+9)8+8)7+7)6+<.?4@3@6A5:11)0.14496>4>1>0@/?.</</907-5,2+2*12:3;5;59575565758697:6:7877767465:5:7:8774706-6*7*8*8*9(9(9&8(9&9":">$?%@(@*=-;196U\^qGc?a:a7g3b8`FdNa@IS12A64@:<:46?56<7179+4="9CSZ.PqŊˎ̒Í}{egQ_E^@c@iDoJsPsSqUoSnNkJgGeEgJhKiNiNfKdIdIeHgJhIiHfEjLlNoQ&.!(0%-2+13.331764:95<;6GD=DD<GFBOOQZZd_ap^`y\\~`_\ZYX\\ggqsz|܁ႅ䅆ㄅჃہՃ҃΄̃Ʉ̃΅Ӈ֊׌ԍЌċxsnuqbevWUtSLjVKf_MbfM_eIcbFp^FzQ?[MZSSRVZW\Y`cermnfqhD;A71%4&C29%:&;'<):+:,8,7,,#0%6)<,@->*;'7$4#B2OAN@B47)7)>/;+:*8(7'6'6(8*8+;.;/9-6*7,<1<271888=:A9B4A/<,;,:/;19384857563657376;9<69453376;9869796:7877767465:5:7:8995827/7+8+:*9+;*:*:(:*;(9":"=$>%?(?+<.81<?\fQhIf9]=h.]<h;\\pLV^..G83BC><89?48E26C41=:)>E&FU*bs?aˌɋËz{efPZ|@^?a>hCoJrOrRpTnRnNjIfFdDfIhKiNiNfKeJdGeFgHhGhGeDkLmOpR(0!'/"(-&).(.0-3317839:4==5?@8DE@JLKORYVXeZ\s]^}YX[Y^]eennwx؄⌌솇䂂܀ւӃ΀ȁǃ˄ΆЈӋҌϊŊ}xwozkegf]Xm[Qm[Mi\Lf^Kd_IeaHhaGo_FoP;UA]OaYYXQTS[\`heYPD<707/:1=/;+9(:&9(:)8)8*5,5,/%3)8,>/@/@-=*9'9)0"WJK?/#=1</8(;+:)9(8'7&6&5&4&7);.>2<07,8->4C<BE9?2<4?2@-;-:2=7>5;687899:97877;=<<::8785747575979899::9;9<9<8<7;6:8:9:;9;5907,8+9)9+:):):(;*<)9#=':#49%D3?61,^eVgIb<\1X0Y6cBiYoFQo33N3,B?6>C<@78@-1L/3K2.A9&DJ(Zn=~_włʌ~nfRXvBY{?]>cAiDnImLlNkOlNiIfDcBcBfIhKfLdJgMhNgKfHeEfEjIkJqQrStU*0")/#).').(-/,130561782;<4>?7AD=HJGOPTSUaXYkZ\u\Z^]dbkjut~·ߋ鍍년 ؀~Ҁς̅Ɇȇˉ΋ό΍̎Ȋ|x{stknlb`e]Re`Me^Kf^Kh]Ki\Ij^Hk_Gn^Ew_G[CYFZLVPRSQXX_USLE>9606/909,9(8&8&8(8)7)6*4,5,0'5)9+=-A/@-<*9(8)<.REH<4(:-:,4&=,<+;*;*:)9)8)6(7*8,7,3)1'1(7.<5DG8>/9/:0=.;1<6?5:3622:8EBIFDC?>:7989796858598988788999:9;9<9<7;6:596888;8:59/7+8*:*:*;*;*<)<+<)9$?):%5:';/:2<=^gPdA[8W6[;`>dIe?L?>_:2G;/:>08>2F<:R>=N0.S8/VK5ciEx[p}Ɓ}xr^YuETp=\{B_@b@iCmHlKkLiMiMgGeCcBcDgJiLhNgMiOiMiKgGgFfElImLpQoRtU-1"-1#,/&,.)//-11/34/45-9;0<>1@B7EHAKMLQRWUUaVWi\Yt^]fdpnzx΍ߐꐎ튉燄߁|}ȀÆLjƊʌɌɌŌ|v{pujpndbi_Vc]M_aL_aKc^Jg\Jl[In\Ho]Gq]EwaIxX?S=VDXOUSOTMS><<784716/6.7+7(7&8$8&8'6)5*3,5,3(6(9)<+?-?-<+8(5'J=F:A5</6(;+6&:):):):*8)7)6(3'9-7,3*3*3+6/:3<8<=4907183<4<7@=C7;AANKYUZUQLB>84627272728596;8;877888:8;8<8<8<8;58475777:7:48/7,8+:+;+<+<+<)<+<)9&@*9$6$;+0'40PT[iJ`:U7V@]HfHdNa89e?6R@2DA09=,57)>6+K9/E-#R=,g]B_t{z{xm\uKHb5Nh8[xB_}?c@hDlGjIhJgLfKdDdCcDeFhKkNkOjNiOiOiMhJgHhHlKoMsVsWvY24&04&01)01+12-23.34.46+9;-;>-?A3DF9IJDMONRQWSS]XVd\Zoda~nlzwÌ֑㔑ꓐ뎋≅ق||~Ë}{vyn~rgmmaak^Vi[Pc\J]`K]aJc^Jh[JmZKqZJtZIv[FsWAxR;Q=YF[PTPFI>A2/5/51605.5+6)8)7$8$8&9'6)6*3,6-6)8'7&:(>+?-;+8)4'UI<18,B45%=+=+8(8'9(:)9)7)6(3'6*3)2)4,:3>7?9=:45596;5;2:397=<@UVbbmjidVQA<634/61717182859697:878898;9<8<8<8<7<5:686797<7<49/9,9*;*;)<)<+=);*<(:'@,8&8';-+"54`gTdG\<U=XG_OdO_SZvGAXH9KD2FE1BE0=?*:8#;3?3PG*nkHfttsx}l[K_:AW0Lc7Wr?_{@d@iCkFiHgGdHeJbBcBdEgHjMlOmQnRjPjNjLhJgGiGmKpOvWvZx\78(68*66,56.56056067/68+;>-=@-@C.DG4IK>MNFQPNRRRVUSYX]a_lkius}njӕᔑ␍܋ӄā}||~zxsznzrfjm_^j[Ti[PjZKfZJb_Lb_Le^Li\Kn[Lr[Kw\K{ZG~UAR=RAVFRHG@88331-3/5/5.3,3)5(9(8$9$:&:'8)7*5,7-;+:)6%8';+=.;.7,90\T=55+A53$:(?+:):*:+:,;-:-8-7-3*1)1+71<7>:;77475;<<?69155:BFMOxwqn`[JC832.73@:939172726273767668797;8<8>8>7=7;7;797:::=:=7;2;/8*:*;*<)<*<(;););(=*8'9*8-/)@ChrM^H[DYH[O^T]TWXUdM?OL9LG4JE1FD-?B'=D#>H#KV.\g<xTfmnr}udRcC?P0BS1Oa9Vl=b{BeBiCjEiFeFbHcGbBfCgHiJkNmPnRoSjNkOjMiKiIjInKrOvWvXwY?=.=>.==1==3==5;<4;=2;=/?B/@D-CG.FJ3KL:NOAQQIRRHYWJZZN_^\gerqn{yďяӍϊǃ~yzwyv{v|y|}}x|tzrvksrffm_\j\Sk[NlZLl[Kk[Ki]Mg^Mi]Mj]Mn]Ms^Mz]MZI`OVGN@J=@76.1+1+516/5.4-2)4'6&;(9$;$;&;':)9*7,9->,;(5#5#9)<.;/7-?7[TIA:0@36&3 <)9'7'7'7(7)7*7,7-<3:293<7>:=9854196<9::8:>@PPbcppheTP=61+40;7=:;7;5:294837373556669697;8<8>7=7=6:8<898:;:>:>7<2</8):););(<(;':&:(<)9(;)9*6*>8TXepK\I]J\M[QZVVZR`RPI7HM9NI5H@+;567>O%Lf6lTw\edfkt|mn}\Q`C<J09F,AP1O_;Wj=czDeBjDkFiFeFaFcGcCiFjKlMlOlOmQnRmQmOmPlLkJmJrNsQ{]{]z\DA0DB3DB6CC9CC;CC;BB6BC3DF0EH-GJ-JM2ON9RQ?TREUSD\ZC\\D\]Oaaaihxrq{z~È{ystoomplrnvpwrwrtoskzrinmb`l_Wj\Qk[Lm\Lo\Mo\Kq[Mq[No\Nm]Nl_Om`Os`Oz_NZM_SPEB8;26-1(2)5,706/4-3,4*5(7%9%:"="=$>'<);*9,;-@-<(5!3!8(<.:/5-93NITMB9B5?.1<(<,9+7*6)7+9.;1;3D=A<?;>;=;;:8885859574;:JJ\[dcc_=9824.81A=E@=;42;5;3949484847777697:6;8<8>7=7=6:7:6989;9>9>6<1<.8););(;';(:':'9&>+7%=+9)2'PKkm\fP^J\HWKSRS[RcQjUJM8DL7JB/H9$B7FH#Up=gV~oqh}YYcd|_XfCGT89E-6B*:D,=J0JX7Wh>e|FhClElFiGcFaGaGfFlImNnOlOkNkOmQpTqSpSpPoNqNtRwU|^z^y]IC3JD6IE9IE:IG;IG;HF9HG5IH3JJ2LL2NN4RP;TQ>XRDYTA]Y>[Z>\YH^[Tdahnk~xs}x{}|}wunoikgiejfmhmimh|lfrkbgj`^g]Th\Nh[Kk\In]Kq_Kq_Kp]Lp]Np]Op]Ns]Ow]N~]N\LXLUHF<9/7-7/6-6-6-6/4-4,4,7,7)6'6$:$<$<&=';);*:,<-A/<'3!3 9'=.;/8.2*A;[TI@D7F72>,F7B5@3?2?3A7E<F?@;=9:764546597<9?9=6:5@:MHQL@9)#-&5->7@;>9;8;;==9696968695:699::88888;8;9<8;7:7:6:6888:8=8=5<1;-9(;*;);(;';&:(:'?-5"=.8*/&\Xy|X_XdQ[KRLOVP`UgUnVPW8?J*<;C=UQ+lvDf~vs|anMu~Q^u}V[b@;D)4<%5=(=D2<E29C+CP2Ue>g{HiFlGmGjGfGbGcGhJlMoPnPlMiKjJjLsTsUsSrQrOsRwUzZvZu[sYRK;RK;RJ=RJ=RJ=RJ=RJ=RK;UN<VO=WP>XQ?YR@[TD\UE\UEb[HaZHaYLbYRe][kaiqftuj{zn|pss|puj{mbre]jc`k`_g_\c_Z^^ZY^YUaZRbZOe[Og[Ki\Kk\Ik\Gm]Fm]Fj^HicMqfTqZJuOBWJ\PYLZLN=E4<,7(8-80411-6/7.7.7.7.7+6)7)8)8)9)9)9+9+8+;,;+>-9(1 2!9*</9.5+5-:0C8K>H9=,2#PFJ@F<D;G?G@C><:7487::::776493=7F>B9:/4(1&5);/?3:0<3?7?:=;;9899:7:8:8:999797959540516576899:9:9;;>9;99=:A=B;A6?1:)<+=*<(:&:%8&8&A0<-/#/&LJmoloVZLNNOQMUOXO]RaTjSWZ/:M7FTa)~Poyxs~ahL\mCYdBT]BHP9?D0:=,@C2<@1:>0<C3:C0AN2Rd>]sBgHpKoKlGjIiKgJlPmSoSlPmMkJmJmIqLqMrNrPtRvUyYz^ycmZbOWN?WN?WN?WN?WN?WN?WN?WN?XO@YPAYPA[RC\SD]TE^UF_VGd[JcZIcYMcYOf[Uj_]nbdpdhreltgpvirvirsfmm`gg[_bXY^[VZZRYVOWTKXTIXTH\VH^WGcZKcZIf[Ig\Hi]Gj^Fk_Gh`IcbMngTv\MSFVMVORJQEH9C0=,9)8,8062406.8.8.8.7-8-7,7+7+7+7+7+8+8+8+:,<.>.9(1 2 :)>.<.:-4*4);0E:OBQCOCF?@;<5;4=7=88633777879787797=9B:A7?4:,6'5&8)=-@1A4@6@7=8:777567:6:6<7:89879595:592:3:5;6;8;89999:;;;<=?=A;?6=2;-;+=*=+<);(:&8%:%9'8)5*<5QPee^aMMNLTMYP\Q^S^S_VfQ`_/Sg*^r3zOn|pbjHauBTe;JX7FP7?H59?158-:</AB4=?4:=2=A3:C0@M3Rd>^tEgHqMpLnHkHkLhKmQnTmSmQkLkHlHmHpJpJpLsQuTxXxXx^mXbQYH]TE]TE]TE]TE]TE]TE]TE]TE[RC\SD]TE^UF_VG`WHaXIaXGe]Je]Hd[Jd[Le[Qf[Uh]Yh][i]]j^^k__k__i^\f[YbWS_VQZVMWTKUQHRNCQMBSOCWQCXRB^WG^WEaYFc[Fg\Hi^Hk`JhbLbaMngUy_PXN[UVQIEE@@7>1;/8+8+9,;/:/8.7-7-9.8-7,7,7+7+7+7+8+8+8+9+;,>0>.:(2 3:&>,>.?08+2(4*<0F9M?ND:643204297=<<<;<9<5:27265899<:@:8-:+6'4%5%8(<+=.D5C6B8=79464557969696977779595:3:3;4;6<6;8:999889:<<@>B=?9:17+7(;,<+<+;):(9&7%9&z6#y6%9,F=SOWTPOIFMHSLYP^SaWaW_VePsrFzVn{|[[o<?R$AS+AP/?L2:C06<.69058/9;.@A3=?49<1=A39B/@M3Qc=`vGiJsOrNpJmJmNkNpTqUoSnPlKlIlHnIpLpLpNuSxXy[uWqX_JVEOx>aXIaXIaXIaXIaXIaXIaXIaXI_VG`WH`WHaXIbYJcZKd[Ld[Je]Hf^Gf^Ig_Lg^Of\Pf\Rf\Sh]Wh]Wh]Wh^Ug]Te[QdZPc[N]YMZVJVRFRNBPL@PM>TN@UO?WQAYTA[VC]XDaZGd]Jf_LfaMdcQleUv\O[Qb\ZXFD<:<8;6:08-8):*?.?/9-7,8-9-8-8,8,7+7+8+8+8+8+8+9+;,?1>.9'3 38"=)@.?-:+7*5*7+:.</:26524123488;<=?<>7<380625587765615(7'6&7&7&9(:):*A1B4A7?8;5957687687878868694:4;492:2:4;7:8:89799<:@<C=A;;26+6'7(;*;););(:&8$7#9%=*v5#5'E:PHMGLGQLPJULZO^RaVaVaWgT_xtsYN`8/A->3B%:F.=F3;A3:=2:=4<=599-?@2<>39<1<@29B/?L2Pb<awHjKtPsOrLoLoPmOpTsUpRoPmJmHnJpKqMrNtSyX{]w[mSeM[FS|BNw=cZKcZKcZKcZKcZKcZKcZKcZKcZKcZKd[Ld[Le\Mf]Nf]Nf]Lf^Gg_Hh`IiaLiaNi`Oh_Pg^Oj`Ti`Qi`Qh_Nh_Nh`Mh`MhaNd^N`ZL[UGVPBPM>NK:NK:NK:PM<RO>TQ@VS@XWC[ZF]\H^]Kb`Qf^QmWJ[Ricc`MMBC;=8984709+=)C+B+;+7)8*:+9+9*9*8)8)8)8)9)9)9)9);,?1>0:(6"47 =&B-;*;,:,9-8.:0<0:49<4<3928384838256<494:7:9<76210(6(:(:(:(:(:(9&7&:+;/>3?7=8;896876666667484:3:3<3:2;2<5=7=:><=;>=@<B<B:=57-5(7(:*;)<);*:(9&8%7$8%@-u4"{3%G:QINFNGWNULXLZN\N]R`UaWhWfzj]kHDS42@&$2-:&0;*5=.9?3<?4=?4:;3::099->?1;=28;0;?18A.>K1Pb<bxIkLuQtPsMqNqRoQrSrSrQpMmKmIpLsOtQvSxY{^z_qVdJYC]JW~GRyBe\Me\Me\Me\Me\Me\Me\Me\Me\Mf]Nf]Nf]Ng^Og^Oh_Ph_Ng_Jh`IiaLjbMjbOjbOjaPjaPjaPiaNh`Mh`Kh`Kh`IiaJjbKf_Mb]J^XHXRBSM=MJ9KH7IH6KJ8LK9LM;NO=PQ?QTASVESVE[YL^VIcQEzXNhaeaVUQR@C:>8770;.?+C*A(;*7(8)9*9*9*9*8)8)9)9)9)9)9)9);,?1=/<)9$65;"A*B.@/;,7*2(4+;0=85:3<6=8>:>;>:=9<587:9>=>=>962/0'9+>*>*>*=)<(:'8%6%7);0=3<5<7;8;787757585:4;4<4=4>5?7A:A;A>A?@=B??:@8=38-5(5'8(<*<(<)<(:&9'7%6$6%}:)t3!~9*OAYNRGOEVJYN[MZM[M\Q_T`WgW~xXy^r|ZU`B;E,/;%0;*0<.3=24<16<2<?6@A9?A6<<077+89+>?1:<17:/:>07@-=J0Oa;bxIkLuQuQtNqNrSpRrQsPrOpKnJpLsOvRyX{Zz]x]qWgO]EXB`NYISzCg^Og^Og^Og^Og^Og^Og^Og^Og^Og^Og^Oh_Ph_Ph_Ph_Pi`OjaPjbOjbOjbOi`Oi`OiaNiaNiaNh`Kh`Kh`Ih`IhaGhaGhaGf_Le^Kb[I\WDWR?PM:LI8IH6IH6GH6GJ9GK:HL;IM<HO?JN?PQCXRF[OCiRDYMVLSLZYIJ?B9972;1?-B*<$:)7(8):*9*:*:*:*9):):):):):):);,=0=/=,<)8 49 A)C-A/=/6+/%0'6.:8596>;A@CAEBC@A??1266:<=;;9714.4)<->+>+@,>+>(;':'7%7'8+8.7094=9>;:79595:4;4;4=4>4B7C9C<B;A=?<=;>9<3:/8+6(7'8):):(=)<*<):'9(7&6%}6$x3#x5%B2UEWKPCPDZLYMZN\Q\Q[T\U[VbUkbEV`=JS4=G,6?*2=,4>35?66=68?8=B;CF=EG<CD6@>/;9*78*=>0:<17:/:>06?,=J0N`:awHkLuQuQtNrOrSpPqOrNqMpLoKrNuTyX`~az]qUfL_G]E^IbPYISzCh_Ph_Ph_Ph_Ph_Ph_Ph_Ph_Pg^Oh_Ph_Ph_Ph_Ph_Pi`Qi`QmdUlcTjaRi`Qh_Pg^Og^Mh`MiaNiaLiaLiaLh`Ih`IhaGh`IgaKf_Le^Kb[H\WDUR?PM<ML:EF4DG4DH7DH7BI9BK:BK:CJ:IK>SQDSPAXL<eK:tE5H>YSRODE::75;3>/=)8":)8'9(;*;*;*;*;*:):):):):):):);,;0:.<,>+9#37?'9#;)>0<18.7/<5?==B?DCEDC@?;7501./,51:6<6:28.8,:+=->+?,@-@-A+>*=*;*:(7(5)5+90?9C>=7;5;5<4<5=4>5@5D9D:C;A9?:;685937-8(5'6':)<*:)8&=*<+<*<)~:'|8%{6&{6&y1#8*G8SCPBL=RE_SWLYN[R]T]V\VYT^QaX;EM(6@8A&>G2<E43=2-7.1817>6BE<GJ?HI;BC1?>*;:&78(=>09;069.:>06?,<I/N`:awHjKuQtPtNrOrSpPqMqLqLpKpLsOwV{\edx\jP]EYA^HePcQZJSzCi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi_Sj`Wj`Wj`Wj`Wj`Vj`Vj`TjaRjaRjaPjaPjbOjbOjbOjbMjbMg_Jg_Jf^Ie_Ib]IZXCSP=ML:HI7EH7AE6@D5?E7?G8?G8>F7GK=IK=AE4KJ6\Q;aE/J9j]g`USFEA@A=>5=0=-4%5&6'7(7(8);,=.<-<-<-<-;,;,;,<-2(7.;/:)7"579"A-;+6)4*6/<7C?HEDEEHCC:661808.4+9/9.8.8-9,:+<+<+=+=*>+?,@-A,A-@-;*:(7(6)6+8-;3<4=6=6?8A7A9B6@6@5H=E;A8;25/3-1*2+9-;*9+:*:););+<+9'}8(|9(|9(|9({8'y6&x3$w- A4OCMAL@QEUJRG\R\RUMTLZUXSWTgZ]T5IQ*AK(BK,>H/7@+2=-4?14<1HPCZ^PW[JMO:DF.AA'==%:;)>?1;=2:=2;?14=*;H.Pb<cyJlMuQsOrLpMrSqQpLqKrNrNsPvU{\bfx^jO`G^EaJfPhTdS[LTyEi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi_Sj_Yj_[j_[j_Yj_Yj`Wj`Vj`Tj`TjaRjaRjaRjaRjaRjaPjaPh`Mh`Kg_Jg_Jd]J^YEUR?ON:IJ:EH7BD6@D5?E7>F7>F7=E6@F8>E5>F1HL5MI0U?'Q:sbcX_ZUTGG@>A=?9:09+=,=.>-;-;+9+:*:,:+:,:+:,:+:,;.?5B:B7=/6#1125#6(;/A8E?IDJFKHCAEDB><39/=0?1=0?1>2>0>/=/>.@.?,=*;*<+=,?+>+>,>,@.=-:,8,8+8-:09/<2<2?5A7C9C9D9E8B6A4=3:06/5.4,7,:.=,;,;+:*;*<*<,~;*|;){9)y:)x9(w8'u6'w4$4'D7NCK?J>QDTIRGSJXOUOVP]XWRSOcT]W5Xc9_jBZfBIT66C)4@*<H4OXGYbQ_fTW\FJN7BE*??#<<"9:(=>0:<19<1<@25>+;H.Pb<dzKlMuQtPrLqNrSqQsOrLpLqMtQxW|_c{aoUcJ]DaJeNeNcOdS[LTyEi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`Qi_Uj_[j^^j^^j_]j_Yj`Wj`Vj`Tj`Tj`Tj`Tj`Tj`Tj`Tj`Vj`TlaOk`LiaNiaNf_La\HYVCSR>MK<HI9DF8AE6AE6?F6>D6<D5=F57@-@H1IK3F?%W?'ZCs`VJbZebTSFHGHCD;67+:*:,:*9,8)6)6'8+7)7+7)7+8*8,8.3-5/6-3(0"/1 3$A2C7G?LFLGJFFBD@CADA@:;1</A1E4E3D3D4B2A0@0A/~A.@.:*9+:);*<+<+=*<*?.=-;+9*8+9-;.9/:.90;0>3?3A4A3A4;,:,8-7+6+6,7.:/;/<,;-;,:+;+;+<,};+z;*z;,w9*v8)u7(t6)v4&;1F<NBJ=H<OBSHRIOITOSQVS]ZYU[Tl[}X~^alxRLX46D#=J.LZ@eqYeoW]eMPU>EI0?C(=@#:<$89';<.8:/9<1=A36?,<I/Pb<dzKmNvRtPsMqNrSpPuQpLnLpOuVy\}`|`pUfM\E\EeMiQfN_HcRZLSxEi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`QjaRjaRjaRjaRjaRjaRjaRj`Vk`\k__k`^k`\k`ZkaXkaWkaUkaUkaUkaUkaUkaWkaWkaXkaWnbRmbPjbOjbOhaNe^K_ZGYVERO>MK<GH:DF8CE7BD6@D5<C3<H49B-FJ3LF0O:%qL9cO^NA5SLc_^^SUJODHAA919-7+7+8-:/;0:0>4>4>4>4?5?5?5>7?;B>D>F=F<I>M@PDSHPGMGIEGBC?A=B=FBD??7=0>.C0G3I6F4E3C3B1A0}@.zA.|?-:,8,9+:,:,;-;+;+:+:)8)8*9,;/=/<0:/8.9/:.:.:,9+8*7)7(6)6*7+8-9/<0<.<-;,9*:*~9*}:*};+|:,z;,y;,w9*s8*q6(r7)u5)D8H=K?H:I<ODTKTLQLTPQOSO\X_Xh^~jpfuWYh?CR+?O*P`<crQetU\iKNX=CL1?E+>B)=A(;='78(:;-79.9<1=A37@-<I/Oa;bxIlMvRuQtNrOrSoPqOoMoMsRz]|az^u[cJ^E[D_HgOjPfL`HbQY~KRwDi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`QjaRjaRjaRjaRjaRjaRjaRj`Tk`Zk`\k`ZkaXkaWkaUkbSkbSkbSkbSkbSkaUkaWkaWkaXkaWocUnbRkbQkbQkbQhaOd]M`ZJXRBRO>NK<IG8GE6DE5BC3>B1=I1?G/LG1S>+g=-ZL_S>43+?9XUigdeRUJNNPIAF<@6>4@6D:G=G>JAJAJBJBKCKCKDKESRTTSRROSLSLULUNLHIFEBC@B@C@EBFDJFE@>7=2?2B1E3G4E3C3B3@0?1~?0z?/|>/:.9.9.9.;-;-;-;-9*9*9+:*:+;-<.;/;/9-9-:,9,8+8*8*8)8)8(8)9*:,:-;-:-:,9+8*}8)}7+|8+{9+z8,y9-x:-v8+q5*o5)q7+t9+H;I<I=I;K?RFWMXOQMUQRPVQ`YbWg[zdnrQZi@JY0AR(IZ0Wi?dvNj|VXiEL[:?L.:D)<D,>C-<A-:=,89+:;-68-8;0>B47@-;H.L^8_uFiJtPtPtNrOsTpQnMmLpPwY|az`rXiQZA\EaIeMgMgKhJfLcPY{IRtBi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`QkbSkbSkbSkbSkbSkbSkbSkaUlbYlbYlbYlbVlbVlcRlcRldQldQldQlcRlcTlbVlbXlbXlbXocUnbRkbQlcRlcRkbQg`Pd]M^WGYSCSM?MJ;KH9GE6EB3?B/;H.?H-OC-a=-E:XRNJ,+:9=;SRpnvvehX^^_UQPFG@C:D=G>GAG?HCJBHDJCJFKDKGKGHHGIHHGGHDHDGBFBBAABBABBCBB@A>A?JGC?<6>3@3A0A0C3A2@1?1=1<0<1=1=1;1;1:3;1;1</<1=/</=-<-;,:,9*8+7):.8.9-:/;.=.</>.9)9(:*:+;,;+;,:+:,9+7)~6({5){5){5)z6)x6*x8,w9,s8*p4)o5)r:-v<0M@K<J<M=QCVHXMWNNITOVR\Ue\{^PfVF`^GEO->N)?O(J\2_rEk~QexKXj@M_7@Q-6E&7D*=F1=D4:>07;-8:,:;-68-8;0>B47@-9F,I[5[qBeFrNsOsMrOsTpQmLoOsUx\z`s[iQ`HYB^GeMgMfJeGgGhLaNXzHQsAi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`QkbSkbSkbSkbSkbSkbSkbSkbSlbXlbVlbVlcRlcRldOldOldMldMldMldOldQlcRlcTlbVlbVocUmaSkbSlcTmdUlcTi`Qf_Ob[K^WGXQARL<OI9JG6IC3AC.:G+@F*U@+xG9PLHH8<39AE?@JIb`qpnpbeZ\QNLDD?B;D?E>B>@9C?C=C@D?CAD@ECDCADADDFGHIHJIIIGHACADBEBEAA@>=:=:FF=<83;2@4?1>0@1</<0;1:08193:4;4;3<3:4<3<3}=1}=3|<0|<0|=.|=.{<-|:,{9)z8*{7*:.9.9-9.9.;.<.=-9):):*;*;+<*;+~;*8*8,~6*}5)|4(z4(z4*y5*u2)v6,v8-r6+o3)o5*s:/x@3PBN?N=Q@VFXIUJRIOITNTO\VfZn[JPK7EK1AN0KZ9WgC`rJgyOdzLVl>G]/AV-7H$1@!6B*=F5<D98=67:39;.;<.68-9<1?C57@-7D*FX2Vl=a}BoKqMsMrOtUqRoPqQuWvZsYjRbJ[E^H`IcKeKfJfHfFeI`MWyGPr@i`Qi`Qi`Qi`Qi`Qi`Qi`Qi`QkbSkbSkbSkbSkbSkbSkbSkbSlbVlcTlcTlcRldQldOldOldMldMldOldOldQlcRlcTlcTlcTnbTmaSmaSmaSmdUlcTjaRg`Pd]M`YIZSCUN>PK8MH5ID1DC.@F*DD([B,TG\X>A/3IN?E;>;<FGZ[efY[GHJGEBB?B>FBFBB>>7D=D=D@EAEBECDEDF?C@DBEEEGGFFBC>?BD@C>A=>>>A?C@ECBB9850;4?6>3=/?2</:0:081838394;592:2:2;2~<0~<0|<0|<0x8,y9-z:.z:.{<-{<-z;,z;,};/9/7.7,6*5*7*7(8*9*;+<-<-=,~<,};+}9,}7-|6,y5*z4*x4)x4)x5,r2(u5+v8-r6+n4)n5*t;0xB6UGPBO@SDWIVJRGNGTNUNRKXMdSeZDGK2=J,IX9ZkIgxTcxQYnESh=Nc8J_4:L&0?,95>)=C5<B8:<79<5;=2;=079.9<1?C58?-8B)EU1Uh;azCnMrNrNrQsSqRrUuXv[tZoUfN^H[DdNaK`HcIfJgKeEaE`MWyGPr@i`Qi`Qi`QjaRjaRkbSkbSkbSjaRjaRjaRjaRjaRjaRjaRjaRkbSkbSkbSkbSkbQkbQkbQkbQlcRlcRlcRlcRlcTlcTlcTnbTk]Pp`QtdWrdWnbVj`Th`ShbTgaSgaQc]M[VCVQ=SN8NH2GA)KG,I?$bI3gWxmleYWOOBEBEDGFHHKJKLMKMEEDEEDFEFBC=C<F<D8E9E<E?D@CCAD?CBFBDCDDEDEFDEDDDCCB@@??>?>@=@=C?B?>:9370:0=2>3>2?2?3=2;393938192;0<.<.;-;/:.:.:.~:-~:-~:-~:-};/};/};/};/}90}90~80~8.7.7.7.~8,8,~8,}9,|8-{9-z8,x8,x8,x8.x8.w7-v8-v6,t6+s5*q5+m1'r6,n4)m3(o6+m4)q8-I=SHSJRGRHPHQJQKRLTMTK[NcQo_HYU:MV7O_;j~YbxQYoHUjCRg@Mb;IY5CR17D&4>#2:#6;'<>0@B5@@6<>358-39-4:.7:/9=/;?.=B,<E(S_;arFnRsUrQrSsSrUuZ~e~epYbK^G^H^G`IbKdMfNeMcK`H^G_LTvDKm;i`Qi`Qi`QjaRjaRkbSkbSkbSjaRjaRjaRjaRjaRjaRjaRjaRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTnbTrbSqaRrbUqcVrfZogZmeXjdVgcWkhYoiYlgThcOc^H[U=RL4PJ0H>%Q?)kP=XGNBE=D?WVTTQQPONMMMLJKJTTHG=>=:B@EAB;>4D9E9F=G>FBDDAEAEBFCDCDDEDCFDFDFDEAD@B?A>A=A=A=C?E?C<>6:090:/<0<0A2~@3~>4<3:3918190;.<-;,;,;-:,:,:,9-9-9-9-~:/~:/~:/~:/}90}90}90}90}90}90|90|90|90z:0z:0y9/y9/y9/w9.w9.w8/w8/t8.s7-r6,r6,p6+p6+k1&q7,m4)l3(o6+l3(p7,~H>RISLQJPJQLPMQNSOOGSH[K{ePsiPhkLfqQgxT^tMXnGPf?La:K_:K\:GV7CP4<F-8@)6;'7:)<=/?@2>>2;=04:03;05;16<0:</<?.>A,>D*Q[9^mDkRpRpSqRsSsVx^|exakT`I]F]F\E`IaJcLeNdMbK`I^I]LRtBIk9i`Qi`Qi`QjaRjaRkbSkbSkbSjaRjaRjaRjaRjaRjaRjaRjaRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTnbTqdTo_Pm]Pm_RqeYog\ldYhbVfbWpl`{xi~{jyizubpiVe`JTT<FF.C>(MB.S@/U8(]7*l=3n70u91~;5@:IBPJXPZR^YSNGEB?DBFCD@@:A;C<E>G@GCFFEFDFCDCDCDCDDEEEECECDBDBD?C>C=C=C=C>E@E?B<>5:18-9,;-@2@1~>2=1:19181:0;.;,;,;,:,:,:.:.9-9-~:/~:/~:/~:/~:/~:/}90}90}90}90|90{8/{8/{8/{;1{;1z:0y;0x:/x:/x:/x:/t8.t8.s7-s7-r6,q5+o5*o5*j1&o6+m4)k2'l6*i3'm7+}G=PIPIPJQLRMSNUPVPWO[P~^OtbNoiQorUlwYfwUQeBK_:EY6DU3EV6GV9GT8ER8?I0<D-9>*7;*:<.<>0;=/9;.6<25=26<26<0:</<>0=@-=C)MW5Zi@f|MlNnQqRuUtWz`w`nWcL\E\E\EZC_HaJbKdMcLaJ_H]H[}JPr@Gi7i`Qi`Qi`QjaRjaRkbSkbSkbSjaRjaRjaRjaRjaRjaRjaRjaRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTnbTrdWoaTm_Rk_SkaWlcZle[jf]jf]xtix~r}zg`cNOT>DG2FE1HC0F=,L<,VC4P9+R6*V4*Y5)\6+a9/e=1m=1KBSJUONKFDABDCFF@>A?B>E@ECFDEDEDDDCDCDDDDDEDEBFCFBEAD>E>D<D<D=E>D<F?F>A8;18,9+<-@0@1~?0=/:1:/9/:.:-;,;,:+:,:,9-9-9-9-~:/~:/~:/~:/~:/~:/}90|90}90{8/{8/{8/{8/x8.{;1y;0y;0y;0x:/x:/x:/v:/s7-s7-s7-r6,q5+o5*o5*m4)j1&o6+l3(h2&k5)h2&l6*|F<OGOJPKRMSNVPWPZQ]RaUy_PiZGd_IdhO\fKN]@EU8AQ4=M0<K.?M3CQ7FR:GS;BL4>G2:A/9=,9=.9=.8<-7;-7=36=56;46<2:<1;=/<?,<A*JS4Ve>bxIjLnQsTwWxZ{ar[eN\EZC\E\EZC_H`IaJbKaJ`I^G]HY{HNp>Eg5haQhaQhaQibRibRjcSjcSjcSibRibRibRibRibRibRibRibRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTlcTrfXth\sg[mcYjaXle]snhzwp~wz{kcfSOR?GJ7EH5BE2BE2EH5KL<JH9GD5D>0A9,A7+@6*F4(S5*qB8PHPKIGGIEIBE@B@BBACBEAEADADADDDFDFDFDDEDEDDCFBFAF>E=E=F=E=F>A:C;E=B9>39-;.</?0?/>.=-;/:-:-;.:-;-:,:,:,9+9-9-~:/~:/~:/~:/}:1}:1}:1}:1|91z:1|91y90y90x8/x8/v7.y:1y:1x90v:0v:0u9/u9/t:/r7/q6.q6.p5-o4,n3+n3+m4+j1(m7-j4*h2(j4*f2'j6+}D;NGNHQJTLUOWPYR[Q{YMv\OkZJ]UBYXDY^HOYA?K3:H/7E.4B+5A+8D.=I3CL7EN9BK6?H5<E2:A/8?/7>.5<,4:,5<45<56;56;49;0:</;>-;@)GP1Ra:`vGiKoRuVyYy[x`nW`IZ}C[~D^G^G]F`IaJbKbKaJ`I_H^IW|ILp@Bf6haQhaQhaQibRibRjcSjcSjcSibRibRibRibRibRibRibRibRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTlcTkaUndZpf\lcZkd\rmg|ľrfcTPQ?FI8>E3;D1:F28E38E38C2:B3<B4@C8CE:GE9>4(P:/e?6EAPOX[QVCIFJEFFFEDEBDBD?CADDDFDFDFDCDCDCDCEAFAF@F=E<F<G=E=?8@9C:C9A7=0=/=.>/?/>.=-<-;-:-;.:,:,:,:,9+:+9-~8,~:/~:/~:/~:/}:1}:1}:1}:1z:1z:1y90y90x8/v7.v7.t8.w8/u9/u9/s9.t8.s9.r8-r8-q6.q6.p5-o4,n3+m4+l3*j4*h2(l6,i3)f2'h4)e1&i5*{B9MGMHPJTLVOXNYO|\Qs\Nk[L`WFVSBPSBJQ?@I64@,3<+2;*09(09(2;*5>-9B1<E4?H7?H5>G4:F2:C25@/3>-1<,3:33954954928919;.;>-;@*CL/O^7]sDiMpSwYyYwYqYfOZ}CX{A\E]F]F^G`I`I`I`I`I_H^G]JV{HJn@Ae7haQhaQhaQibRibRjcSjcSjcSibRibRibRibRibRibRibRibRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTlbVj`VjaXkdZkg^upjμzym]_YIKL:@E1;D/>J6=H7=F5;C4;>5:;3983880==3C<2N71a84HH]_`dWZQSNOMKKJHGFDDABBCDDFDFCECEBDBBCBDCD@D?F?E<F<G=E=@:@:B:C:C:@4;/9+=/>.>-=,<,;,;,<-:,:,:,9+9-9-~8.}9.~:/~:/}:1}:1}:1}:1}:1}:1z:1y:1x90x90w8/t8.s7-r8-t8.s9.r8-q8-r8-p7,p7,p7,o6-o6-n5,n5,m4+l3*k2)i3)g1'k7,h4)e1&h4)b0%f4)zA8MGMHPJULXNYOxZOr\Nk^N^WGRPAKN=CJ:9B12:+08)17+17-06,/5+/5)08+2:+4<-9D4;F5=H7<I7;F56C13@,1>-.800621622717829;0:<.:?)?H+KY5[qChLqVw[wYsVgP^IUx@WzB[~F[~F[~F]H_J_J_J_J^I^I]H]JUvIJk@@a6haQhaQhaQibRibRjcSjcSjcSibRibRibRibRibRibRibRibRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTlbVpg^ng_lgatqj}ub^\GKM7CH2AI2AI4@G5BD7AA7B=9C97?:69<5>?7B71J.+d66QRginm\\ZWVSQNLKHHCDBCCFDFDFCECEBDBBBBDCCBC?D>E>F<F<E=C=A9B:D;E:A6:-5&</=.=-=,<,<,<*<-:,:,:,:+9-~8,}9.}9.~:/~:/}:1}:1}:1}:1}:1{;1y:1w;1x90u9/t8.s9.r8-q7,r8-q8-p7,n8,p7,m7+o6+o6+o6-o6-n5,m4+l3*j4*i3)h4)f2'k7,h4)c1&e3(b0%e3(xB8MGOIRJUMXOzZOq[Mh\LZTDIJ:?C4>D69A208+/7*6<247058157247025.06,08-19,6A3:E5=J9>K9<I77F32A,1>-,6..400511606718:/:<.:?+<E*IW4YoAgMpVv\uXpU`IX{CSv>WzB[~FY|DY|D\G_J_J^I^I^I]H]H]LStIHhA?]7icSicSicSicSicSicSicSicSicSicSicSicSicSicSicSjcSkbSkbSkbSlcTlcTmdUmdUmdUmdUmdUmdUmdUmdUmdUmdUldWibZgd]vsnʵƶibbFEH-DH/CG0FE1GD5F<3C60F42H:9>=9>?:B:7I75cGFjjœ譩ҋtn]XSPONJLFKFKEGIKDF;>>@GIDG:=@@@@A@B>C>B<A;A9C>A9@9A9B8@5:.8*=0>/>.>-=,<+=*<,:+9-9-~8,~8.|8-|8-|8-|90|90|90|90z:1z:1z:1z:1y=5w<4w;3u:2t91q8/p7.p7.o6-m7-m7-l8-m7-l8-m7-m7-i2+m6/p92o81k4-g2*g2*h3+e0(i7.d2)]-#`0&_/%b2(s>6OJPKQJRJ}YMv_QfYITN>DE5>E5:C25@04</3;04:04:068378366446135016//6..6+.9+2=-6C2:G6:I68G44C.1?.*4+,2.-2..3-45/79.:</:?+6>&DR1WlChRs]w_rWkR[~DXyDTu@Tu@WxCZ{F[|GZ{F^JbNbN^J\}H_K`L^~MTsJFd@<W4icSicSicSicSicSicSicSicSicSicSicSicSicSicSicSicSkbSkbSkbSlcTlcTmdUmdUmdUmdUmdUmdUmdUmdUmdUmdUldYgd]onjͲcgjKLQ3GJ/EC.GB/H>2I:3L95K<9?:7BA?MHE]RPyjgβſ쳪͂|c^VVRSHMADDEEEHHJKEF<><>AC????A@A@B>B=A<@9A<@;@9B:C;A6;18-=0>/>.>-=,<+<,<,:+9-9-~8,}9.|8-|8-|8-|90|90|90|90z:1{;2{;2z;2w<4u<3u:2s:1r90n8.o6-m7-m7-l8-l8-l8-l8-j8-l8-l8-k6.n70o81n91l7/i4,g2*e3*c1(d4*_/%^.$b2(^.$`0&p>5JERLXR~XOrVKdRDQJ:>?/:A16A05@03>04<14<15;17:379477577557246116//6./7,.9+1<.4A08E49H58G44E24B1.8/.5..3--2+23+46+8:-9=,7?(DQ3WlEhUt`wbpYgPY|DWxCTu@Tu@VwBYzEYzEYzE[|G_K_K\}H[|G^J^J^{MSnKF_A9R4icSicSicSicSicSicSicSicSicSicSicSicSicSicSicSicSkbSkbSkbSlcTlcTmdUmdUmdUmdUmdUmdUmdUmdUneVneVlfZed_y{xشğl`gEQX7DG,DC.JD4LD7KA8I>:C;9SJKia_wvecBEDIRVUTMKDACAFEEFDDCD=?>@@?@?B@B?B=A:@:@:B:E<D<B7<29.<0=0>/>.=-~<,=-=-9-9-~:/}9.}9.|8-{8/{8/}:1}:1{;2{;2{;2{;2z;4x<4t;2q;1r90o9/n8.l8-l6,k7,l8-j8-j8-j8-j8-i9-j8-j8-n91m80m80m80m80i7.f4+c1(d2)a1']-#_0&c4*\-#_0&sD<}PJVP~YQpTI^J?OC7?<-46(2;*0;+1<.2=/4<14<15;17:379479668357257227007/08-.9+0;-2?.6C27E48G48G49F54>33:2/4-,2(/0(13(57*6:)6>'DQ5YmJkZwfwflZ_KWxCWuCTr@Tr@VtBXvDYwEYwEZxF]{I_}K]{I]{I_}K^|JZwKPgJAW@3I2icSicSicSicSicSicSicSicSicSicSicSicSicSicSicSicSjcSkbSkbSlcTlcTmdUmdUmdUmdUmdUmdUneVneVneVneVmg[jkfڴefmLMQ6FH0HJ5KI:HD9D@7OGDj`_収cd@?PKTMPHF@GBMJKH@?>>???>A?A?B?B=B=>9@:C=E?E>A9=5;2<1=0>/>.=/~<,=-=-9-9-~:/}9.}9.|8-{8/{8/~;2~;2|<3{;2{;2{;2z;4x<4r90o9/o9/m9.l8-k7,j6+h6+i7,i7,i7,h8,h8,h8,h8,h8,m;2l7/j5-i7.j8/j8/f4+a1'e5+a2(].$a2(b3)Y* a2(yNE\VvWRiNGWC:I<3@:.:;-8<.08)/:*3;.4</5=25;169069079468368349238139/19.19..9+/:,0=,2?.5B17E4;H6<I89C87?428.-3'.0%/1$24&48'4<'ER8]pPrd{nwifXU|ESsATr@Sq?Sq?Tr@UsAVtBVtBWuC[yG]{I\zH^|J_}K\zHWrIJ^E<M;.?-gdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSicSjcSkbSkbSlcTlcTmdUmdUmdUmdUmdUmdUneVneVofWofWng]qqoҭ}bY]BGL5FK7FJ9CG9AC8c^X}z騤hcLAPDYN[QQHD=A<DA@=@>@?A@C?C?C?C=?;A<E@E@C>@9>5=3<1<2=1=0=1~<.=/=/~:/~:/~:/}9.|90{8/{8/{8/|<3|<3|<3{;2z;4y:3y:3w;3n70m80l7/l7/k6.h6-h6-h6-i7.h8.h8.g8.g8.g8.g8.h8.k92h6/f4-g5.i70h70e4-b1*c2+b3+_0(]1(]1(V*!b6-{ULtYRaNHN?8A7.=6,;9-9;.9<139-3;.5;/6<06<07:/58-47.69049238139/39/2:/19.19,.9+.9+/:,0;-3>.6C2:E5<G7=E8:B55;/06(02%/1$13%15$2:%GS;buWwk|rqg\QJp=Oo>Qn>Qn>Qn>Qn>Qn>Sp@Sp@WtD[xH]zJ]zJ_|L_|LZwGRlECU?6D7(6)gdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSicSjcSkbSkbSlcTlcTmdUmdUmdUmdUmdUneVneVofWpgXpgXng]lnmz׹ĥregOMP;GK:FM=GOBKQG{{sžؓeSJ:TFWIF;@8KEC>C?B?C@C>C>D>B=B<C?DAD?A==8;5<4;3<2=3=2=1~<0=1=/~:/~:/~:/}9.|90{8/{8/{8/|<3{;2{;2z:1y:3x92w81u91n70l7/l7/j8/i7.i7.h6-g7-g7-g7-f7-f7-f7-f7-f7-f7-h70h6/g5.g5.g6/h70g6/f5.a2*e6.^2)\0'`4+a5,i=4uSJXG@E>6<5/95,;8/8:/57,36+69.5;/7:/69.69.58-57,36+28,19,28.19,19.19,19,19,.9+.9+.9+/:,0;+3>.6A17B2<D5:C28?/5;-46)24'13%04%07%HT>ex\umtlf_RwKBh9Kk<Nk;Pm=Pm=Nk;Nk;Ol<Qn>VsCZwG]zJ^{K_|L_|LVsCNg@<J9/:2$.&gdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSicSjcSkbSkbSlcTlcTmdUmdUmdUmdUmdUneVneVofWpgXqhYoh^hikmtzƯ}un[ZWFPQCSVK[bZeld񪔼o[VDRCPDLAJAG?E?E@E@E>D=C<B<C?E@EAC==9;5;5<6<3=4<5=4<3~<0=1=1~:/~:/~:/}9.|90{8/{8/{8/{;2{;2y:3x92w81v70v70s7/n70j8/j8/j8/j8/h8.h8.h8.g7-f7-f7-f7-d8-d8-d8-f7-g6/h70i81i81h70i81j;3l=5g80k<4b6-a5,oC:xLCtI@nMDC9056.45/8918;247.14+25,58-58-57,46+46+46+46)37)/7(.9)08+.9).9+.9)08)08)19*08)08+/7*08+19,3;.4<-9B1:C0;B0:A1:<.68*24&/3$29'IU?cu[mgfbWyTInE?d8Hg;Li;Nk=Nk=Li;Li;Mj<Ol>UrDYvH[xJ]zL^{M\yKQn@G_;6B4+4/#)%gdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSicSjcSjcSjbUlbVlbVmcWmdUmdUmdUleUmfVngWogZnh\oh^mjekormtzη|ubb_NXZL]cWmwn|}̻pQDSFSHC:J@H@G>F>E=D<C;C;G>G>G>C;>5:2:3>6=5=4=5=4<3;0;1;1~:/~:/~:1}90|90{8/{8/{8/z:1z:1x92w81v70u6/u6/q6.m80k90j8/j8/i9/i9/i9/h8.g7-f7-g7-f7-f7-f7-f7-f7-f5.j81m;4k:3j92j:0m>4oC8l@5oD;d<2c=2zVJdZyWMbLA>:13814927<54:0/5+25,9<336+25*24)03(13(25*46+47,.6),7)/7*-8*/7*/7*/7*/7*19,08+08-/7,/7,/7,08-08+7?09B1<E4=D4;A38<.26'-4$2;*JVBcr[h|a]vXOmKFfAAa:Hd;Kh<Nk?Nk?Kh<Jg9Li=Nk=TqEWtHZwK[xL]zNZvMNjAC[;2>4*00!''heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVjdVjdVjdXldYlcZmeZmeXmfVg`NjeRnkXol]he\feasqrԶ|qtY_dMbkXr}lا`XD=NEMCF<D9E<I@KAH@G<G8H8J8H8E5B4B5C5B5B6@4>3<2:1919191~:1|91{80z7/z7/w7.v6-w7.w7.w8/w8/v7.u6-q5+n3+l7/i81i81h70h70g6/g6/g6/f5.g6/i70i81h70g6/e4-e3,h3-j5/m80k90j:0i;.i=0kA3gB2jI:dH:v_O~k\xjoRJ=79.4:04:039/39/39/28.28.17-17-36-06,25,/5+14+/5+/4-.5-/4-.5-/4-/4-/4-/4-05./4-/4-.3,.3,/4-/4-/6.1;23=26@58B79D67B45@03>-4?.DQ=WeN[kQPbHEX<@T8BW6Ic>Ke>Kf=Kf=Je<Je:Lg>Oj?UpGYtK\vO]wP]wRWqNHb?;O6&1+&+.$),heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVjcYkdZlc\md[meZmfVidQjhSmjWjk[gg_lll~ЯvkqUYaI_kUto~uKAM@K>L@K>E9=4?6E9F7J7L:J7F6C2C6E7C7B8A7>5<4:39193~92}:2z:1z:1y90x8/v7.v7.u6-v7.t8.t8.t8.r6,o5*m4+l7/i81j81h70i70h70g6/g6/e3,e3,g5.h6/j81j81j81k92k60l71k90k;1k;/j>1j@0iD2gH6kP=gRAufSuesrKL<69.39/39/39/28.28.28.17-17-17-17-06,06,/5+/5+/5+/4./4./4./4./4./4./4./4.05//4..3-.3-.3-.3-/4./6/.80/:21=34@66B66B66B45B16C1CP>P]IR`IIW@AO6BP7EU:Jb@Jd?Ke@Ke>Ic<Hc:Id;Je<SnEXrK\vQ]wT[tTTmOC\>6I5&1-',0$)-heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVjcYkdZlc\md[meZmfVmhUkiTmjWjk[kkcwwwۿʫyuy`kpZt{i؞L=RBL;@1G;YMUJ@4D7H:K=I;B7?3@7E;@9A9A8?6~>5}=4<4}=4z;4x<4w;3w;3u:2t91t91t91r90r90r90r90o9/n8.l6,k5+l7/j81l71j81k60i70i70h6/g5.g5.f5.g6/h70i81k:3k:3l;4j;3i:0h<1k?2jC4iD2fE2fI7lVAjYGujVm{mEF658-28.28.28.17-17-17-06,17-17-17-06,06,/5+/5+/5+/4./4./4./4./4./4./4./4./4./4..3--2,-2,.3-/4..5.+5-+6.-9//;12>24@46B47D38E3?L:ER>CQ:;I28F->L3DT9J_@Jb@LdBKc?Ia=G`9F_8G`9RkDXpL]uS^vVZqTPgK=T8.A.&1-',0%*.heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVjcYkdZlc\md[meZmfVniVljUlkWlm]pqiؼǫ}ſñpP@O?XJM?E9G<A6E;I?G=@9<4=6A<?;@<@:}@;z?9y@9x?8x?8v=4v=4v=4u<3s=3r<2r<2q;1o;0o;0o;0n:/k9.j8-j8-i7.m82n72m61l71l71k60i70i70l:3j92h70f7/f7/f7/h91f:1j?6f>4e=1f>2hC3iE5fG3cG2cJ6hV@i\IskVozpq_9=,47,28.17-17-17-06,06,06,17-17-17-06,06,/5+/5+/5+.3-.3-.3-.3-.3-.3-.3-.3-.3-.3--2,-2,-2,-2,.3--4-*4,)4,*6,+7-.:.1=14@25A36C2:G5<I78E12?+2@)8F/>N4DX<E]=K`AJb@K`?G_;H^:F^:SiEXpN`uV^uXZnSLcI9M4):(%.+%*.$)-heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVjcYkdZlc\md[meZmfVlgTkiTnmYop`tumؿʱ½ŜbPJ:L<P@L>@7C;F?D=>;:7:8>;=;?<@=}@=xA<tB;rC;rC;q?6s>6s>6r=5r=5r=5p>5o=4n>4m=3l<2k;1j;1i:0i:0j:0n72p62p62m61m61l71i70i70l;4k:3h91e90e90e90e:1d<2fB6cA5cC4dD5dG5dI6bI3_I2^L6eV?jbMrmWor[`L3:(28,28.17-17-17-06,06,06,17-17-17-06,06,/5+/5+/5+.3-.3-.3-.3-.3-.3-.3-.3--2,-2,,1+,1+,1+,1+-2,,3,,6.+5-*4+*4++5,.8-0;-2=/2=-5@/6A05A-1=)1=)5A-8F/=O5@T8FY=H\@J]?I^=K^>K`?TgG[pQcvZauZYkSJ]G6G4&4%$-*$),"'*heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVjcYkdZlc\md[meZlfVjgTkjUlnYorasvmθκƶøͧkX[GWEL;D:D<E>E?A>=::9;9=<?=?=}@;wB<rC;oD;oD;p?8q?6q?6q?6q?6p>5o?5o?5o@6n?5m>4k<2h<1h<1h<1l<2o83q62p62p62m61l71j81i81h70g80e90e:1d<2e?4f@5dB6^B4aG8cL:dM;cM8`K6]K3]M4]Q9bX?mhRss[nv{eFO:4=*39-28.28.28.17-17-17-06,17-17-17-06,06,/5+/5+/5+-2,-2,-2,-2,-2,-2,-2,-2,-2,,1++0*+0*+0*+0*,1+,3,.5.,6.*4+*4+*4++5,-7,.9+-8*0;+4?/5@/4?.3?+3>-3@,7F/9K3@O8BT:GW<H[?M]BM`DUeJ\oSdtZ`rZXgRGXE4B1$2%$-*$),"'*heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVjdVjdVjcYkdZlc\md[lfZlfVliVlkVkmXkn]lrhy}оλwbQ:\HN>J=I>I@G@D>=::7=9>:?9A:xA:tD:pF:pE<p?8q?8q?8q?8q?8q?8p?8p?8qB:pA9n?7l=5i=4j>5j>5n=6o83r73p62p62n72l71j81i81d8/d90c;1d>3d@4cA5cA5_C5ZE4_N<gVBhWCcS<^O8[O5\R7]V<]Y>nlUtv^|kcmU2>(6B.3;.39/39/39/28.28.28.17-17-17-17-06,06,/5+/5+/5+-2,-2,-2,-2,-2,-2,-2,-2,,1+,1++0**/)*/)+0*,1++2+-4-+5-*4,*4,+5,+5,,6+-7,,6+/:,2=/6A17B27B15@04?.2?-4C.:G3=L5AO8DT:JX?L\BTbI\kTcqZ^mXUbPDRA2>0#/%&/,&,,$**heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVjdVjdVjcYkdZlc\md[lfZlfVolYmlWjlWgkZflbr{x׭oYWDQ@O>OAOBK@C<<5>7?6?8A7{B7uD6qE8qE8p?8q?8s>8q?8q?8q?8q?8p?8sB;qB:o@8m>6l=5j>5m>6o>7o83q73o83m82m82i81h91f:1f;2d>3d@4bB5`C5]A3\@2WB1TG4[S>f^Gi^HbX?ZS9ZS7\W:ZV;XW;kmUsw^u}fUaI&28D03;.4:04:039/39/39/28.28.17-17-17-06,06,/5+/5+/5+-2,-2,-2,-2,-2,-2,-2,-2,,1++0*+0**/)*/)+0*+0*,1++2+)3+*4,+5-+5,,6--7.-7,,6+.8-2<16A39D69D47B46A10;+2?-5B09F2<I5@N7FT=JX?R`I[hTanZ\iWQ^MBN@/;/",#+1-(.,&,,heVheVheVheVheVheVheVheVifWifWifWifWifWifWifWifWkeWkeWkdZle[md]ne\mg[mgWqn[kmWknYkr`jrgpyvѺibKO9T?ZFRAJ:M?<0=0>2=/x=/t?/sB3tD6r=5r=7t=8s>8u@:u@:t?9q?8sA:q@9q@9q@9p?8n?7o>7o>7k92m82l:3l;4l;4h<3g<3c=2c?3^>1dG9cG9T=-N9(M8'@1WQ;PN7KI0OK2]Y>ieJeaDVU7XX<]`CosZzfdlU=I1-9#2>*4</5;14:04:04:039/39/39/39/39/39/28.17-17-17-06,16016005/05//4./4./4./4.,1+,1+,1+,1+,1+,1++0*+0*.5.-4--4-,3,-4--4,.5-.5-+2*-4,07/5=29A6=E8?G<?J<7B25@/3>-1=)2>*9E/BN8IU?O[GVbN]hWYdTLWI<F;/9.)3*)/+(.*'-+heVheVheVheVheVheVheVheVifWifWifWifWifWifWifWifWkeWkeWkdZle[md]ne\mg[khWonZjlVknYkr`jtiq|x౗u\[CZBYCVCR@G5F6E4D3|C2wB0s@/o>/u@8s>8u>9u@:t?9o=6p>7sA:q?8p?8p?8n?7o>7m>6n=6m>6k<4l=5m>6k?6j?6gA6eA5bB5dG9[A2^G7^I8N=+F7$G8%>6!LL4GK2DG,DD*MM1\[?baC`aBYY=dgJsw^sy_X`I:D,/;%7C/6>16<26<26<25;15;15;15;15;15;15;14:04:039/39/39/27127127116016016005/05/.3-.3--2,-2,,1+,1++0*+0**1**1*)0))0))0)*1*+2*,3+.5--4,.5-07/4;39A6?F>BJ?;F8:E57B14?.3?+6B.<H2@L6LXDS_KYdTWbRLVK=G<1;2+5,+2+*0,)/+heVheVheVheVheVheVheVheVifWifWifWifWifWifWifWifWkeWkeWlcZmd[md]ne\mg[khWmlXimVjoYktaiuiq}y㿧jYBQ;[F]IS?F2u>)r>)s@+tD0vE4q?4n<3q<4tB9sA8o?5qA7xH>n>4m>4m>4k?4l=3j>3l=3j>3g?5gA6gA6gC7eC7cC6`C5^D5bK;UB1ZI7`S@RG3C;&E=(FA+AE,BH.AE*<@%?B%NN2_`AijKaaEnqTvzagmSJO94<%4=(=F38>28>48>48>47=37=37=36<28>48>47=37=37=36<26<26<25:449349349338238238227105/05//4..3--2,,1++0*+0*).().().().().(*/)+0*,1+160/4.,1+,1+/4.6;4=B<AH@@K=>K:<I78E34A-2?+3A*5C,DQ=KXDQ^MQ^MHTH<H<2>4.8/-4--4-,3,gdUgdUheVheVheVheVifWifWifWifWifWifWifWifWifWifWkeWkeWlcZmd[md]mf\mg[jiWkmXimVjoYjs`hthm|wڻּҽz{R>tJ4uH3vI4zM8}P;yL7nA.e7'{M@sD:qB8sD:oC8g;0d8-g=1i?3i?3i?3g?3f>2f>2f>2e?2b@4bB5`C5_C5_C5[D4ZE4WD3XI6OB/\T?oiSc^HMK4IG0IK3>D*?H-@F*<B&<A#FI,XY:deFmmQxx\tv^[_F@C.6;%8@+<C19?39?59?58>48>47=37=37=39?58>48>48>48>48>48>48>47<67<67<66;56;56;55:45:438238216005//4.-2,,1+,1++0*+0**/)*/)+0*,1+-2,-2,05/.3-+0*+0*-2.2718=9;B:@K=@M;@M;=J68E13@,1?(0>'<I5BO;HUCIVEDPB;G;2>4.:0,6..5.-4-gdUgdUgdUheVheVifWifWifWifWifWifWifWifWifWifWifWkeWldWlcZmd[md]mf\mg[jiWkmXinWiqZgs_drejytܿչйѾϴuawVCjI6lI6rM;uP>mF7iB3gB2jE5nI9nJ:oK;oK;eA1cB1cB1cB1cB1cB1bC1`C3]F6\G6\G6ZG6ZG6WH5TG4RG3PH3NH2fdM~~frrZVX@JL4GM3<E*<F+?H+AG+AF(DG*MN/TU6xw[{z^nnVUU=CB.?A,>A.:>-;>39?59?58>48>47=37=37=38>48>48>48>48>48>48>48>49>89>89>88=78=78=77<67<66;55:449338227105//4./4.-2.-2.,1-+0,+0,,1--2.-2.,1-,1-,1-,1-.210513764;4;G9=L9@O<@O:<K67F/4C,2A*6E.:I4@O<BP??M>8F71?2-9-,6--4,,3+fcTfcTgdUheVheVifWjgXjgXifWifWifWifWifWifWifWifWldWldWlcZmd[md]mf\mg[jiWkmXinWiqZgs_bpcgxrڽѵ˴˺ҿһsrb|]K}^LtUCaD2W:(Y<*[>,X=*`E2`E2`E2_F2`G3`G3`G3]H3\K7\M:\M:YL9XM9UM8RL6QL6NL5QQ9ikS|gmqXSY?FL2>G,<F+<F+?H+DJ.EJ,DG*HI*LM.yx\tsWfdMTR;LI6KJ6FE3<=-<?49?59?59?58>48>48>48>47=37=38>48>48>48>49?59?5:?9:?9:?9:?99>89>89>88=78=78=77<66;55:4493382382/40.3/-2.,1-+0,+0,+0,+0,+0,,1--10.21/32/32/32-4-3?17F3=L7@O:?N7<K49H18G05D-8G0<K6>M:<J97E61?2-9-+5,-4,,3+fcTfcTgdUheVheVifWjgXjgXifWifWifWifWifWifWifWifWldWldWlcZmd[md]mf\mg[jiWjlWhmVhrZfs_cqdhysչ̳İĴɿʴxt^GeO8bL5\H0^J2\J2\J2]K3]K3^L4^L4\M6YN8WO:WO:VP:UO9SN8PN7NN6MO7PT;`fLfoTU^CEO4AK0<F+?I.?I.CL/HN2HM/FI,OP1YX:qmRjfKa\F[V@YTATQ>MJ9BC3=@5;A7;A7;A7:@6:@6:@69?58>48>48>49?59?5:@6:@6:@6;@:;@:;@::?9:?99>89>89>8:?9:?99>89>88=78=77<67<6495273162/40-2.,1-+/.+/.,0/,0/-10.21.23.23-12+1-+9*/@-6H2;M7=O7<N4:L2:L25G/7I1:L6<M::K96G70@3-;.,6--4,,3+cdRcdRdeSefTgeVhfWigXigXhfWifWifWifWifWifWifWkeWkeWkeWldYle[md]mf\kg[jiWikVhmWhrZgt`dqgj{uѸDZžƾüÞu`P7RB)XH/XH.[M3[M3ZN4ZN4[O5[O5\P6[Q8UO7TO9TO9QO8PN7NN6KM5IM4JN5LR8S\APY<@I,;F(AL.?J,DM0EN1JQ2MR4JM0LL0YY=kjNhdIb^E^ZA_ZD`[GZUAQO:KJ8AB4@B5@B5>A6>A6>A6=@7=@79?59?59?5:@6:@6:B7:B7:B7;@9;@9;@::?8:?99>79>89>7;@:;@9;@:;@9:?9:?8:?9:?98?87=94;4382160/4..3/.3/.21.21,2.,2.+2++2*,4))6%$6)=!2F+8L1;O6;M5;M5;M58J29K3;M5<N6<N87H51B0.<--7,.5--4,]eN^fO_gP`hQdiUfiVgjWijXfgUhgUheVheVjdVkeWkeYlfXlfXkhYmg[kg\mf^jf[ieYgeVghVfkUenYbo]dqhsҾϼ·ƏlUN2WN1TK.SJ+WN1WN1UN1UN1TO2TO2TN4SO4QM2RN5QO6PP6MO7KO6HM6GL5JP6FO4AJ-=F'>H&DK*FM+EL*PV4PT3KN/HK,TT8bbFccIZZ@[Y@\ZA][B][B[Y@XV=US:SQ8HF1GD1DA0A?0@>1>>2??5>@5;>59?59?59A69A48C58C58C5:B79A69@88@58?79A69@8:B7:A9:B79@8:B7;B:<D9=D<>E=8B:8B:7A88@56>14</39/271.40/51-7/-9-.;)0@&6G'7M';V+:W+;U0;T4;R8=P:>O<>P::L6@R8EW=FY=DX=@T;5H2+<),6+,3++2*ZgM[hN\hP]iQbjSckTglXhkXghVghVifWifWkeWlfXmeZmgYmgYkhYkg[kg\jf]jf[hfZefVhiWglVfo\erajwnz˹ʿNjlRM0SN0QK+QK+UO/UO/TO1TO1SO2SO2QP4QP4QM2PO3PN5NQ6MO7JP6HM6EM5HQ6EN1BK.?I'BI(FM+JP,KQ-NR/PT1VZ7^bA_bCY\?TW<UU=VV>WU>XV=YW>XV=XW;WV:XT9QK3OI3LG4ID1DA2B@3A?3>@5<=59?59?59A67B48C57D37D3:B79A69A68@58@59A69A6:B7:B7:B7:B7:B7;C8<D9=E:<F;=G?<H><F;;F6<D5:B39?38=67>74>63=40>-3C)9M*BY/Ga1Op;Ln;Li=Fa>BY?<R=;L::K8=O9DV<K^BM`BL`DH\@:Q71D.+5*+2*)0(ZgM[hN\hP^jRbjSdlUglXilYijXijXkhYkhYlfXmgYnf[nhZmgYkhYkg[jf[jf]ieZhfZfgWhiWejTdmZgtco|s˸öƉjPK.QL.QK+QK+TN.UO/TO1UP2TP3SO2QP4PO3QM2ON2PN5MP5MO7JP6IN7FN6HQ6FO2CL/CM+FM,JQ/OU1SY5QY2W_8jpJy[qvVY^@KO4MP5QQ9QQ9RP9SQ8TR9UT8YU:ZV;XR:VP:RM:NI6HE6DB5CA5?A6<=59?5:@69A67B47B47D37D3:B7:B79A69A69A69A6:B7:B7:B7:B7:B7:B7;C8<D9>F;<F;?IA>J@?I>>I9?G8>F7>D8=B;>E>9C;6@74B19I/BV3Pg=XrB^J[}JXuIMhECZ@9O:6G54E2<N8EW=NaESfHSgKNbF@W=6I3/9./6.-4,ZgM[hN\hP^jRblTemVhmYinZklZklZlj[liZnhZnhZog\oi[liZkhYjfZjf[ie\ieZhfZfgWfgUbgQajWerao|s~Ҿ˸Ƴþ÷ǹɊmPJ0RM0SL/SM-TN.UO/UP2UP2TP3SO2PO3ON2PL1NM1OM4LO4LN6JP6JO8HP8JS8GP3GP3IS1MT3OV4V\8\d=grHtUislnuTZaBRV;LN6NN6MM5NL5OM6RP7WS:YU<ZT>XR<TO<QL9KH9GE8EC7@B7=>6:@6:@69A67B47B46C26C2;C8:B79A69A69A69A6:B7;C8;C8:B7:B7;C8;C8=E:>F;=G<=G?<H>>H=>I9?G8>F7>D8=B;=D=9C;6@74B19I/DX5Ri?[uEZ{FWyFTqEIdA=T:2H3/@.->+6H2@R8L_CReGSgKOcG@W=6I30:/07/-4,YgMZhN\hP^jRblTemVinZjo[mn\lm[mk\mj[nhZnhZoi]oi[liZkhYjfZieZie\ieZig[ghXghVchRajWerao|s{ѿɶıþʾŸ̌oRL2TO2TM0UN1TN.UO/VQ3VQ3UQ4SO2ON2NM1PL1NM1NL3KN3LN6KQ7KP9JR:LU:IR5JS6OY7SZ9T[9]c?fnGcszpr{\\bFLP7KM5LK6KI4LJ5PK5TN8VP:WQ;VP:SN;QL9LI:IG:GE9CE:=>6:@6:@69A67B47B46C26C2;C8;C8:B79A69A6:B7;C8;C8;C8;C8;C8;C8<D9=E:>F;=G<=G?<H>=G<=H8>F7=E6=C7=B;:A:7A95?64B19I/BV3Ne;Uo?Tu@RtAPmAE`=9P6-C.+<*+<)1C-<N4H[?PcERfJNbF@W=5H2,6++2*'.& \ No newline at end of file diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/testimgp.jpg b/irrlicht-1.6/source/Irrlicht/jpeglib/testimgp.jpg deleted file mode 100644 index 8cbb658bb..000000000 Binary files a/irrlicht-1.6/source/Irrlicht/jpeglib/testimgp.jpg and /dev/null differ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/testorig.jpg b/irrlicht-1.6/source/Irrlicht/jpeglib/testorig.jpg deleted file mode 100644 index 9816a0c62..000000000 Binary files a/irrlicht-1.6/source/Irrlicht/jpeglib/testorig.jpg and /dev/null differ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/testprog.jpg b/irrlicht-1.6/source/Irrlicht/jpeglib/testprog.jpg deleted file mode 100644 index 920fee2e3..000000000 Binary files a/irrlicht-1.6/source/Irrlicht/jpeglib/testprog.jpg and /dev/null differ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/transupp.c b/irrlicht-1.6/source/Irrlicht/jpeglib/transupp.c deleted file mode 100644 index 53a99400d..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/transupp.c +++ /dev/null @@ -1,928 +0,0 @@ -/* - * transupp.c - * - * Copyright (C) 1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains image transformation routines and other utility code - * used by the jpegtran sample application. These are NOT part of the core - * JPEG library. But we keep these routines separate from jpegtran.c to - * ease the task of maintaining jpegtran-like programs that have other user - * interfaces. - */ - -/* Although this file really shouldn't have access to the library internals, - * it's helpful to let it call jround_up() and jcopy_block_row(). - */ -#define JPEG_INTERNALS - -#include "jinclude.h" -#include "jpeglib.h" -#include "transupp.h" /* My own external interface */ - - -#if TRANSFORMS_SUPPORTED - -/* - * Lossless image transformation routines. These routines work on DCT - * coefficient arrays and thus do not require any lossy decompression - * or recompression of the image. - * Thanks to Guido Vollbeding for the initial design and code of this feature. - * - * Horizontal flipping is done in-place, using a single top-to-bottom - * pass through the virtual source array. It will thus be much the - * fastest option for images larger than main memory. - * - * The other routines require a set of destination virtual arrays, so they - * need twice as much memory as jpegtran normally does. The destination - * arrays are always written in normal scan order (top to bottom) because - * the virtual array manager expects this. The source arrays will be scanned - * in the corresponding order, which means multiple passes through the source - * arrays for most of the transforms. That could result in much thrashing - * if the image is larger than main memory. - * - * Some notes about the operating environment of the individual transform - * routines: - * 1. Both the source and destination virtual arrays are allocated from the - * source JPEG object, and therefore should be manipulated by calling the - * source's memory manager. - * 2. The destination's component count should be used. It may be smaller - * than the source's when forcing to grayscale. - * 3. Likewise the destination's sampling factors should be used. When - * forcing to grayscale the destination's sampling factors will be all 1, - * and we may as well take that as the effective iMCU size. - * 4. When "trim" is in effect, the destination's dimensions will be the - * trimmed values but the source's will be untrimmed. - * 5. All the routines assume that the source and destination buffers are - * padded out to a full iMCU boundary. This is true, although for the - * source buffer it is an undocumented property of jdcoefct.c. - * Notes 2,3,4 boil down to this: generally we should use the destination's - * dimensions and ignore the source's. - */ - - -LOCAL(void) -do_flip_h (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - jvirt_barray_ptr *src_coef_arrays) -/* Horizontal flip; done in-place, so no separate dest array is required */ -{ - JDIMENSION MCU_cols, comp_width, blk_x, blk_y; - int ci, k, offset_y; - JBLOCKARRAY buffer; - JCOEFPTR ptr1, ptr2; - JCOEF temp1, temp2; - jpeg_component_info *compptr; - - /* Horizontal mirroring of DCT blocks is accomplished by swapping - * pairs of blocks in-place. Within a DCT block, we perform horizontal - * mirroring by changing the signs of odd-numbered columns. - * Partial iMCUs at the right edge are left untouched. - */ - MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); - - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - comp_width = MCU_cols * compptr->h_samp_factor; - for (blk_y = 0; blk_y < compptr->height_in_blocks; - blk_y += compptr->v_samp_factor) { - buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], blk_y, - (JDIMENSION) compptr->v_samp_factor, TRUE); - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - for (blk_x = 0; blk_x * 2 < comp_width; blk_x++) { - ptr1 = buffer[offset_y][blk_x]; - ptr2 = buffer[offset_y][comp_width - blk_x - 1]; - /* this unrolled loop doesn't need to know which row it's on... */ - for (k = 0; k < DCTSIZE2; k += 2) { - temp1 = *ptr1; /* swap even column */ - temp2 = *ptr2; - *ptr1++ = temp2; - *ptr2++ = temp1; - temp1 = *ptr1; /* swap odd column with sign change */ - temp2 = *ptr2; - *ptr1++ = -temp2; - *ptr2++ = -temp1; - } - } - } - } - } -} - - -LOCAL(void) -do_flip_v (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - jvirt_barray_ptr *src_coef_arrays, - jvirt_barray_ptr *dst_coef_arrays) -/* Vertical flip */ -{ - JDIMENSION MCU_rows, comp_height, dst_blk_x, dst_blk_y; - int ci, i, j, offset_y; - JBLOCKARRAY src_buffer, dst_buffer; - JBLOCKROW src_row_ptr, dst_row_ptr; - JCOEFPTR src_ptr, dst_ptr; - jpeg_component_info *compptr; - - /* We output into a separate array because we can't touch different - * rows of the source virtual array simultaneously. Otherwise, this - * is a pretty straightforward analog of horizontal flip. - * Within a DCT block, vertical mirroring is done by changing the signs - * of odd-numbered rows. - * Partial iMCUs at the bottom edge are copied verbatim. - */ - MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE); - - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - comp_height = MCU_rows * compptr->v_samp_factor; - for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; - dst_blk_y += compptr->v_samp_factor) { - dst_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, - (JDIMENSION) compptr->v_samp_factor, TRUE); - if (dst_blk_y < comp_height) { - /* Row is within the mirrorable area. */ - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], - comp_height - dst_blk_y - (JDIMENSION) compptr->v_samp_factor, - (JDIMENSION) compptr->v_samp_factor, FALSE); - } else { - /* Bottom-edge blocks will be copied verbatim. */ - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_y, - (JDIMENSION) compptr->v_samp_factor, FALSE); - } - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - if (dst_blk_y < comp_height) { - /* Row is within the mirrorable area. */ - dst_row_ptr = dst_buffer[offset_y]; - src_row_ptr = src_buffer[compptr->v_samp_factor - offset_y - 1]; - for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; - dst_blk_x++) { - dst_ptr = dst_row_ptr[dst_blk_x]; - src_ptr = src_row_ptr[dst_blk_x]; - for (i = 0; i < DCTSIZE; i += 2) { - /* copy even row */ - for (j = 0; j < DCTSIZE; j++) - *dst_ptr++ = *src_ptr++; - /* copy odd row with sign change */ - for (j = 0; j < DCTSIZE; j++) - *dst_ptr++ = - *src_ptr++; - } - } - } else { - /* Just copy row verbatim. */ - jcopy_block_row(src_buffer[offset_y], dst_buffer[offset_y], - compptr->width_in_blocks); - } - } - } - } -} - - -LOCAL(void) -do_transpose (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - jvirt_barray_ptr *src_coef_arrays, - jvirt_barray_ptr *dst_coef_arrays) -/* Transpose source into destination */ -{ - JDIMENSION dst_blk_x, dst_blk_y; - int ci, i, j, offset_x, offset_y; - JBLOCKARRAY src_buffer, dst_buffer; - JCOEFPTR src_ptr, dst_ptr; - jpeg_component_info *compptr; - - /* Transposing pixels within a block just requires transposing the - * DCT coefficients. - * Partial iMCUs at the edges require no special treatment; we simply - * process all the available DCT blocks for every component. - */ - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; - dst_blk_y += compptr->v_samp_factor) { - dst_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, - (JDIMENSION) compptr->v_samp_factor, TRUE); - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; - dst_blk_x += compptr->h_samp_factor) { - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_x, - (JDIMENSION) compptr->h_samp_factor, FALSE); - for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) { - src_ptr = src_buffer[offset_x][dst_blk_y + offset_y]; - dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; - for (i = 0; i < DCTSIZE; i++) - for (j = 0; j < DCTSIZE; j++) - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - } - } - } - } - } -} - - -LOCAL(void) -do_rot_90 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - jvirt_barray_ptr *src_coef_arrays, - jvirt_barray_ptr *dst_coef_arrays) -/* 90 degree rotation is equivalent to - * 1. Transposing the image; - * 2. Horizontal mirroring. - * These two steps are merged into a single processing routine. - */ -{ - JDIMENSION MCU_cols, comp_width, dst_blk_x, dst_blk_y; - int ci, i, j, offset_x, offset_y; - JBLOCKARRAY src_buffer, dst_buffer; - JCOEFPTR src_ptr, dst_ptr; - jpeg_component_info *compptr; - - /* Because of the horizontal mirror step, we can't process partial iMCUs - * at the (output) right edge properly. They just get transposed and - * not mirrored. - */ - MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); - - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - comp_width = MCU_cols * compptr->h_samp_factor; - for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; - dst_blk_y += compptr->v_samp_factor) { - dst_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, - (JDIMENSION) compptr->v_samp_factor, TRUE); - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; - dst_blk_x += compptr->h_samp_factor) { - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_x, - (JDIMENSION) compptr->h_samp_factor, FALSE); - for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) { - src_ptr = src_buffer[offset_x][dst_blk_y + offset_y]; - if (dst_blk_x < comp_width) { - /* Block is within the mirrorable area. */ - dst_ptr = dst_buffer[offset_y] - [comp_width - dst_blk_x - offset_x - 1]; - for (i = 0; i < DCTSIZE; i++) { - for (j = 0; j < DCTSIZE; j++) - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - i++; - for (j = 0; j < DCTSIZE; j++) - dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; - } - } else { - /* Edge blocks are transposed but not mirrored. */ - dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; - for (i = 0; i < DCTSIZE; i++) - for (j = 0; j < DCTSIZE; j++) - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - } - } - } - } - } - } -} - - -LOCAL(void) -do_rot_270 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - jvirt_barray_ptr *src_coef_arrays, - jvirt_barray_ptr *dst_coef_arrays) -/* 270 degree rotation is equivalent to - * 1. Horizontal mirroring; - * 2. Transposing the image. - * These two steps are merged into a single processing routine. - */ -{ - JDIMENSION MCU_rows, comp_height, dst_blk_x, dst_blk_y; - int ci, i, j, offset_x, offset_y; - JBLOCKARRAY src_buffer, dst_buffer; - JCOEFPTR src_ptr, dst_ptr; - jpeg_component_info *compptr; - - /* Because of the horizontal mirror step, we can't process partial iMCUs - * at the (output) bottom edge properly. They just get transposed and - * not mirrored. - */ - MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE); - - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - comp_height = MCU_rows * compptr->v_samp_factor; - for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; - dst_blk_y += compptr->v_samp_factor) { - dst_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, - (JDIMENSION) compptr->v_samp_factor, TRUE); - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; - dst_blk_x += compptr->h_samp_factor) { - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_x, - (JDIMENSION) compptr->h_samp_factor, FALSE); - for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) { - dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; - if (dst_blk_y < comp_height) { - /* Block is within the mirrorable area. */ - src_ptr = src_buffer[offset_x] - [comp_height - dst_blk_y - offset_y - 1]; - for (i = 0; i < DCTSIZE; i++) { - for (j = 0; j < DCTSIZE; j++) { - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - j++; - dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; - } - } - } else { - /* Edge blocks are transposed but not mirrored. */ - src_ptr = src_buffer[offset_x][dst_blk_y + offset_y]; - for (i = 0; i < DCTSIZE; i++) - for (j = 0; j < DCTSIZE; j++) - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - } - } - } - } - } - } -} - - -LOCAL(void) -do_rot_180 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - jvirt_barray_ptr *src_coef_arrays, - jvirt_barray_ptr *dst_coef_arrays) -/* 180 degree rotation is equivalent to - * 1. Vertical mirroring; - * 2. Horizontal mirroring. - * These two steps are merged into a single processing routine. - */ -{ - JDIMENSION MCU_cols, MCU_rows, comp_width, comp_height, dst_blk_x, dst_blk_y; - int ci, i, j, offset_y; - JBLOCKARRAY src_buffer, dst_buffer; - JBLOCKROW src_row_ptr, dst_row_ptr; - JCOEFPTR src_ptr, dst_ptr; - jpeg_component_info *compptr; - - MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); - MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE); - - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - comp_width = MCU_cols * compptr->h_samp_factor; - comp_height = MCU_rows * compptr->v_samp_factor; - for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; - dst_blk_y += compptr->v_samp_factor) { - dst_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, - (JDIMENSION) compptr->v_samp_factor, TRUE); - if (dst_blk_y < comp_height) { - /* Row is within the vertically mirrorable area. */ - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], - comp_height - dst_blk_y - (JDIMENSION) compptr->v_samp_factor, - (JDIMENSION) compptr->v_samp_factor, FALSE); - } else { - /* Bottom-edge rows are only mirrored horizontally. */ - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_y, - (JDIMENSION) compptr->v_samp_factor, FALSE); - } - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - if (dst_blk_y < comp_height) { - /* Row is within the mirrorable area. */ - dst_row_ptr = dst_buffer[offset_y]; - src_row_ptr = src_buffer[compptr->v_samp_factor - offset_y - 1]; - /* Process the blocks that can be mirrored both ways. */ - for (dst_blk_x = 0; dst_blk_x < comp_width; dst_blk_x++) { - dst_ptr = dst_row_ptr[dst_blk_x]; - src_ptr = src_row_ptr[comp_width - dst_blk_x - 1]; - for (i = 0; i < DCTSIZE; i += 2) { - /* For even row, negate every odd column. */ - for (j = 0; j < DCTSIZE; j += 2) { - *dst_ptr++ = *src_ptr++; - *dst_ptr++ = - *src_ptr++; - } - /* For odd row, negate every even column. */ - for (j = 0; j < DCTSIZE; j += 2) { - *dst_ptr++ = - *src_ptr++; - *dst_ptr++ = *src_ptr++; - } - } - } - /* Any remaining right-edge blocks are only mirrored vertically. */ - for (; dst_blk_x < compptr->width_in_blocks; dst_blk_x++) { - dst_ptr = dst_row_ptr[dst_blk_x]; - src_ptr = src_row_ptr[dst_blk_x]; - for (i = 0; i < DCTSIZE; i += 2) { - for (j = 0; j < DCTSIZE; j++) - *dst_ptr++ = *src_ptr++; - for (j = 0; j < DCTSIZE; j++) - *dst_ptr++ = - *src_ptr++; - } - } - } else { - /* Remaining rows are just mirrored horizontally. */ - dst_row_ptr = dst_buffer[offset_y]; - src_row_ptr = src_buffer[offset_y]; - /* Process the blocks that can be mirrored. */ - for (dst_blk_x = 0; dst_blk_x < comp_width; dst_blk_x++) { - dst_ptr = dst_row_ptr[dst_blk_x]; - src_ptr = src_row_ptr[comp_width - dst_blk_x - 1]; - for (i = 0; i < DCTSIZE2; i += 2) { - *dst_ptr++ = *src_ptr++; - *dst_ptr++ = - *src_ptr++; - } - } - /* Any remaining right-edge blocks are only copied. */ - for (; dst_blk_x < compptr->width_in_blocks; dst_blk_x++) { - dst_ptr = dst_row_ptr[dst_blk_x]; - src_ptr = src_row_ptr[dst_blk_x]; - for (i = 0; i < DCTSIZE2; i++) - *dst_ptr++ = *src_ptr++; - } - } - } - } - } -} - - -LOCAL(void) -do_transverse (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - jvirt_barray_ptr *src_coef_arrays, - jvirt_barray_ptr *dst_coef_arrays) -/* Transverse transpose is equivalent to - * 1. 180 degree rotation; - * 2. Transposition; - * or - * 1. Horizontal mirroring; - * 2. Transposition; - * 3. Horizontal mirroring. - * These steps are merged into a single processing routine. - */ -{ - JDIMENSION MCU_cols, MCU_rows, comp_width, comp_height, dst_blk_x, dst_blk_y; - int ci, i, j, offset_x, offset_y; - JBLOCKARRAY src_buffer, dst_buffer; - JCOEFPTR src_ptr, dst_ptr; - jpeg_component_info *compptr; - - MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); - MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE); - - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - comp_width = MCU_cols * compptr->h_samp_factor; - comp_height = MCU_rows * compptr->v_samp_factor; - for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; - dst_blk_y += compptr->v_samp_factor) { - dst_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, - (JDIMENSION) compptr->v_samp_factor, TRUE); - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; - dst_blk_x += compptr->h_samp_factor) { - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_x, - (JDIMENSION) compptr->h_samp_factor, FALSE); - for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) { - if (dst_blk_y < comp_height) { - src_ptr = src_buffer[offset_x] - [comp_height - dst_blk_y - offset_y - 1]; - if (dst_blk_x < comp_width) { - /* Block is within the mirrorable area. */ - dst_ptr = dst_buffer[offset_y] - [comp_width - dst_blk_x - offset_x - 1]; - for (i = 0; i < DCTSIZE; i++) { - for (j = 0; j < DCTSIZE; j++) { - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - j++; - dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; - } - i++; - for (j = 0; j < DCTSIZE; j++) { - dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; - j++; - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - } - } - } else { - /* Right-edge blocks are mirrored in y only */ - dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; - for (i = 0; i < DCTSIZE; i++) { - for (j = 0; j < DCTSIZE; j++) { - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - j++; - dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; - } - } - } - } else { - src_ptr = src_buffer[offset_x][dst_blk_y + offset_y]; - if (dst_blk_x < comp_width) { - /* Bottom-edge blocks are mirrored in x only */ - dst_ptr = dst_buffer[offset_y] - [comp_width - dst_blk_x - offset_x - 1]; - for (i = 0; i < DCTSIZE; i++) { - for (j = 0; j < DCTSIZE; j++) - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - i++; - for (j = 0; j < DCTSIZE; j++) - dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; - } - } else { - /* At lower right corner, just transpose, no mirroring */ - dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; - for (i = 0; i < DCTSIZE; i++) - for (j = 0; j < DCTSIZE; j++) - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - } - } - } - } - } - } - } -} - - -/* Request any required workspace. - * - * We allocate the workspace virtual arrays from the source decompression - * object, so that all the arrays (both the original data and the workspace) - * will be taken into account while making memory management decisions. - * Hence, this routine must be called after jpeg_read_header (which reads - * the image dimensions) and before jpeg_read_coefficients (which realizes - * the source's virtual arrays). - */ - -GLOBAL(void) -jtransform_request_workspace (j_decompress_ptr srcinfo, - jpeg_transform_info *info) -{ - jvirt_barray_ptr *coef_arrays = NULL; - jpeg_component_info *compptr; - int ci; - - if (info->force_grayscale && - srcinfo->jpeg_color_space == JCS_YCbCr && - srcinfo->num_components == 3) { - /* We'll only process the first component */ - info->num_components = 1; - } else { - /* Process all the components */ - info->num_components = srcinfo->num_components; - } - - switch (info->transform) { - case JXFORM_NONE: - case JXFORM_FLIP_H: - /* Don't need a workspace array */ - break; - case JXFORM_FLIP_V: - case JXFORM_ROT_180: - /* Need workspace arrays having same dimensions as source image. - * Note that we allocate arrays padded out to the next iMCU boundary, - * so that transform routines need not worry about missing edge blocks. - */ - coef_arrays = (jvirt_barray_ptr *) - (*srcinfo->mem->alloc_small) ((j_common_ptr) srcinfo, JPOOL_IMAGE, - SIZEOF(jvirt_barray_ptr) * info->num_components); - for (ci = 0; ci < info->num_components; ci++) { - compptr = srcinfo->comp_info + ci; - coef_arrays[ci] = (*srcinfo->mem->request_virt_barray) - ((j_common_ptr) srcinfo, JPOOL_IMAGE, FALSE, - (JDIMENSION) jround_up((long) compptr->width_in_blocks, - (long) compptr->h_samp_factor), - (JDIMENSION) jround_up((long) compptr->height_in_blocks, - (long) compptr->v_samp_factor), - (JDIMENSION) compptr->v_samp_factor); - } - break; - case JXFORM_TRANSPOSE: - case JXFORM_TRANSVERSE: - case JXFORM_ROT_90: - case JXFORM_ROT_270: - /* Need workspace arrays having transposed dimensions. - * Note that we allocate arrays padded out to the next iMCU boundary, - * so that transform routines need not worry about missing edge blocks. - */ - coef_arrays = (jvirt_barray_ptr *) - (*srcinfo->mem->alloc_small) ((j_common_ptr) srcinfo, JPOOL_IMAGE, - SIZEOF(jvirt_barray_ptr) * info->num_components); - for (ci = 0; ci < info->num_components; ci++) { - compptr = srcinfo->comp_info + ci; - coef_arrays[ci] = (*srcinfo->mem->request_virt_barray) - ((j_common_ptr) srcinfo, JPOOL_IMAGE, FALSE, - (JDIMENSION) jround_up((long) compptr->height_in_blocks, - (long) compptr->v_samp_factor), - (JDIMENSION) jround_up((long) compptr->width_in_blocks, - (long) compptr->h_samp_factor), - (JDIMENSION) compptr->h_samp_factor); - } - break; - } - info->workspace_coef_arrays = coef_arrays; -} - - -/* Transpose destination image parameters */ - -LOCAL(void) -transpose_critical_parameters (j_compress_ptr dstinfo) -{ - int tblno, i, j, ci, itemp; - jpeg_component_info *compptr; - JQUANT_TBL *qtblptr; - JDIMENSION dtemp; - UINT16 qtemp; - - /* Transpose basic image dimensions */ - dtemp = dstinfo->image_width; - dstinfo->image_width = dstinfo->image_height; - dstinfo->image_height = dtemp; - - /* Transpose sampling factors */ - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - itemp = compptr->h_samp_factor; - compptr->h_samp_factor = compptr->v_samp_factor; - compptr->v_samp_factor = itemp; - } - - /* Transpose quantization tables */ - for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) { - qtblptr = dstinfo->quant_tbl_ptrs[tblno]; - if (qtblptr != NULL) { - for (i = 0; i < DCTSIZE; i++) { - for (j = 0; j < i; j++) { - qtemp = qtblptr->quantval[i*DCTSIZE+j]; - qtblptr->quantval[i*DCTSIZE+j] = qtblptr->quantval[j*DCTSIZE+i]; - qtblptr->quantval[j*DCTSIZE+i] = qtemp; - } - } - } - } -} - - -/* Trim off any partial iMCUs on the indicated destination edge */ - -LOCAL(void) -trim_right_edge (j_compress_ptr dstinfo) -{ - int ci, max_h_samp_factor; - JDIMENSION MCU_cols; - - /* We have to compute max_h_samp_factor ourselves, - * because it hasn't been set yet in the destination - * (and we don't want to use the source's value). - */ - max_h_samp_factor = 1; - for (ci = 0; ci < dstinfo->num_components; ci++) { - int h_samp_factor = dstinfo->comp_info[ci].h_samp_factor; - max_h_samp_factor = MAX(max_h_samp_factor, h_samp_factor); - } - MCU_cols = dstinfo->image_width / (max_h_samp_factor * DCTSIZE); - if (MCU_cols > 0) /* can't trim to 0 pixels */ - dstinfo->image_width = MCU_cols * (max_h_samp_factor * DCTSIZE); -} - -LOCAL(void) -trim_bottom_edge (j_compress_ptr dstinfo) -{ - int ci, max_v_samp_factor; - JDIMENSION MCU_rows; - - /* We have to compute max_v_samp_factor ourselves, - * because it hasn't been set yet in the destination - * (and we don't want to use the source's value). - */ - max_v_samp_factor = 1; - for (ci = 0; ci < dstinfo->num_components; ci++) { - int v_samp_factor = dstinfo->comp_info[ci].v_samp_factor; - max_v_samp_factor = MAX(max_v_samp_factor, v_samp_factor); - } - MCU_rows = dstinfo->image_height / (max_v_samp_factor * DCTSIZE); - if (MCU_rows > 0) /* can't trim to 0 pixels */ - dstinfo->image_height = MCU_rows * (max_v_samp_factor * DCTSIZE); -} - - -/* Adjust output image parameters as needed. - * - * This must be called after jpeg_copy_critical_parameters() - * and before jpeg_write_coefficients(). - * - * The return value is the set of virtual coefficient arrays to be written - * (either the ones allocated by jtransform_request_workspace, or the - * original source data arrays). The caller will need to pass this value - * to jpeg_write_coefficients(). - */ - -GLOBAL(jvirt_barray_ptr *) -jtransform_adjust_parameters (j_decompress_ptr srcinfo, - j_compress_ptr dstinfo, - jvirt_barray_ptr *src_coef_arrays, - jpeg_transform_info *info) -{ - /* If force-to-grayscale is requested, adjust destination parameters */ - if (info->force_grayscale) { - /* We use jpeg_set_colorspace to make sure subsidiary settings get fixed - * properly. Among other things, the target h_samp_factor & v_samp_factor - * will get set to 1, which typically won't match the source. - * In fact we do this even if the source is already grayscale; that - * provides an easy way of coercing a grayscale JPEG with funny sampling - * factors to the customary 1,1. (Some decoders fail on other factors.) - */ - if ((dstinfo->jpeg_color_space == JCS_YCbCr && - dstinfo->num_components == 3) || - (dstinfo->jpeg_color_space == JCS_GRAYSCALE && - dstinfo->num_components == 1)) { - /* We have to preserve the source's quantization table number. */ - int sv_quant_tbl_no = dstinfo->comp_info[0].quant_tbl_no; - jpeg_set_colorspace(dstinfo, JCS_GRAYSCALE); - dstinfo->comp_info[0].quant_tbl_no = sv_quant_tbl_no; - } else { - /* Sorry, can't do it */ - ERREXIT(dstinfo, JERR_CONVERSION_NOTIMPL); - } - } - - /* Correct the destination's image dimensions etc if necessary */ - switch (info->transform) { - case JXFORM_NONE: - /* Nothing to do */ - break; - case JXFORM_FLIP_H: - if (info->trim) - trim_right_edge(dstinfo); - break; - case JXFORM_FLIP_V: - if (info->trim) - trim_bottom_edge(dstinfo); - break; - case JXFORM_TRANSPOSE: - transpose_critical_parameters(dstinfo); - /* transpose does NOT have to trim anything */ - break; - case JXFORM_TRANSVERSE: - transpose_critical_parameters(dstinfo); - if (info->trim) { - trim_right_edge(dstinfo); - trim_bottom_edge(dstinfo); - } - break; - case JXFORM_ROT_90: - transpose_critical_parameters(dstinfo); - if (info->trim) - trim_right_edge(dstinfo); - break; - case JXFORM_ROT_180: - if (info->trim) { - trim_right_edge(dstinfo); - trim_bottom_edge(dstinfo); - } - break; - case JXFORM_ROT_270: - transpose_critical_parameters(dstinfo); - if (info->trim) - trim_bottom_edge(dstinfo); - break; - } - - /* Return the appropriate output data set */ - if (info->workspace_coef_arrays != NULL) - return info->workspace_coef_arrays; - return src_coef_arrays; -} - - -/* Execute the actual transformation, if any. - * - * This must be called *after* jpeg_write_coefficients, because it depends - * on jpeg_write_coefficients to have computed subsidiary values such as - * the per-component width and height fields in the destination object. - * - * Note that some transformations will modify the source data arrays! - */ - -GLOBAL(void) -jtransform_execute_transformation (j_decompress_ptr srcinfo, - j_compress_ptr dstinfo, - jvirt_barray_ptr *src_coef_arrays, - jpeg_transform_info *info) -{ - jvirt_barray_ptr *dst_coef_arrays = info->workspace_coef_arrays; - - switch (info->transform) { - case JXFORM_NONE: - break; - case JXFORM_FLIP_H: - do_flip_h(srcinfo, dstinfo, src_coef_arrays); - break; - case JXFORM_FLIP_V: - do_flip_v(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); - break; - case JXFORM_TRANSPOSE: - do_transpose(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); - break; - case JXFORM_TRANSVERSE: - do_transverse(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); - break; - case JXFORM_ROT_90: - do_rot_90(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); - break; - case JXFORM_ROT_180: - do_rot_180(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); - break; - case JXFORM_ROT_270: - do_rot_270(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); - break; - } -} - -#endif /* TRANSFORMS_SUPPORTED */ - - -/* Setup decompression object to save desired markers in memory. - * This must be called before jpeg_read_header() to have the desired effect. - */ - -GLOBAL(void) -jcopy_markers_setup (j_decompress_ptr srcinfo, JCOPY_OPTION option) -{ -#ifdef SAVE_MARKERS_SUPPORTED - int m; - - /* Save comments except under NONE option */ - if (option != JCOPYOPT_NONE) { - jpeg_save_markers(srcinfo, JPEG_COM, 0xFFFF); - } - /* Save all types of APPn markers iff ALL option */ - if (option == JCOPYOPT_ALL) { - for (m = 0; m < 16; m++) - jpeg_save_markers(srcinfo, JPEG_APP0 + m, 0xFFFF); - } -#endif /* SAVE_MARKERS_SUPPORTED */ -} - -/* Copy markers saved in the given source object to the destination object. - * This should be called just after jpeg_start_compress() or - * jpeg_write_coefficients(). - * Note that those routines will have written the SOI, and also the - * JFIF APP0 or Adobe APP14 markers if selected. - */ - -GLOBAL(void) -jcopy_markers_execute (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - JCOPY_OPTION option) -{ - jpeg_saved_marker_ptr marker; - - /* In the current implementation, we don't actually need to examine the - * option flag here; we just copy everything that got saved. - * But to avoid confusion, we do not output JFIF and Adobe APP14 markers - * if the encoder library already wrote one. - */ - for (marker = srcinfo->marker_list; marker != NULL; marker = marker->next) { - if (dstinfo->write_JFIF_header && - marker->marker == JPEG_APP0 && - marker->data_length >= 5 && - GETJOCTET(marker->data[0]) == 0x4A && - GETJOCTET(marker->data[1]) == 0x46 && - GETJOCTET(marker->data[2]) == 0x49 && - GETJOCTET(marker->data[3]) == 0x46 && - GETJOCTET(marker->data[4]) == 0) - continue; /* reject duplicate JFIF */ - if (dstinfo->write_Adobe_marker && - marker->marker == JPEG_APP0+14 && - marker->data_length >= 5 && - GETJOCTET(marker->data[0]) == 0x41 && - GETJOCTET(marker->data[1]) == 0x64 && - GETJOCTET(marker->data[2]) == 0x6F && - GETJOCTET(marker->data[3]) == 0x62 && - GETJOCTET(marker->data[4]) == 0x65) - continue; /* reject duplicate Adobe */ -#ifdef NEED_FAR_POINTERS - /* We could use jpeg_write_marker if the data weren't FAR... */ - { - unsigned int i; - jpeg_write_m_header(dstinfo, marker->marker, marker->data_length); - for (i = 0; i < marker->data_length; i++) - jpeg_write_m_byte(dstinfo, marker->data[i]); - } -#else - jpeg_write_marker(dstinfo, marker->marker, - marker->data, marker->data_length); -#endif - } -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/transupp.h b/irrlicht-1.6/source/Irrlicht/jpeglib/transupp.h deleted file mode 100644 index eb0b05566..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/transupp.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * transupp.h - * - * Copyright (C) 1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains declarations for image transformation routines and - * other utility code used by the jpegtran sample application. These are - * NOT part of the core JPEG library. But we keep these routines separate - * from jpegtran.c to ease the task of maintaining jpegtran-like programs - * that have other user interfaces. - * - * NOTE: all the routines declared here have very specific requirements - * about when they are to be executed during the reading and writing of the - * source and destination files. See the comments in transupp.c, or see - * jpegtran.c for an example of correct usage. - */ - -/* If you happen not to want the image transform support, disable it here */ -#ifndef TRANSFORMS_SUPPORTED -#define TRANSFORMS_SUPPORTED 1 /* 0 disables transform code */ -#endif - -/* Short forms of external names for systems with brain-damaged linkers. */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jtransform_request_workspace jTrRequest -#define jtransform_adjust_parameters jTrAdjust -#define jtransform_execute_transformation jTrExec -#define jcopy_markers_setup jCMrkSetup -#define jcopy_markers_execute jCMrkExec -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - - -/* - * Codes for supported types of image transformations. - */ - -typedef enum { - JXFORM_NONE, /* no transformation */ - JXFORM_FLIP_H, /* horizontal flip */ - JXFORM_FLIP_V, /* vertical flip */ - JXFORM_TRANSPOSE, /* transpose across UL-to-LR axis */ - JXFORM_TRANSVERSE, /* transpose across UR-to-LL axis */ - JXFORM_ROT_90, /* 90-degree clockwise rotation */ - JXFORM_ROT_180, /* 180-degree rotation */ - JXFORM_ROT_270 /* 270-degree clockwise (or 90 ccw) */ -} JXFORM_CODE; - -/* - * Although rotating and flipping data expressed as DCT coefficients is not - * hard, there is an asymmetry in the JPEG format specification for images - * whose dimensions aren't multiples of the iMCU size. The right and bottom - * image edges are padded out to the next iMCU boundary with junk data; but - * no padding is possible at the top and left edges. If we were to flip - * the whole image including the pad data, then pad garbage would become - * visible at the top and/or left, and real pixels would disappear into the - * pad margins --- perhaps permanently, since encoders & decoders may not - * bother to preserve DCT blocks that appear to be completely outside the - * nominal image area. So, we have to exclude any partial iMCUs from the - * basic transformation. - * - * Transpose is the only transformation that can handle partial iMCUs at the - * right and bottom edges completely cleanly. flip_h can flip partial iMCUs - * at the bottom, but leaves any partial iMCUs at the right edge untouched. - * Similarly flip_v leaves any partial iMCUs at the bottom edge untouched. - * The other transforms are defined as combinations of these basic transforms - * and process edge blocks in a way that preserves the equivalence. - * - * The "trim" option causes untransformable partial iMCUs to be dropped; - * this is not strictly lossless, but it usually gives the best-looking - * result for odd-size images. Note that when this option is active, - * the expected mathematical equivalences between the transforms may not hold. - * (For example, -rot 270 -trim trims only the bottom edge, but -rot 90 -trim - * followed by -rot 180 -trim trims both edges.) - * - * We also offer a "force to grayscale" option, which simply discards the - * chrominance channels of a YCbCr image. This is lossless in the sense that - * the luminance channel is preserved exactly. It's not the same kind of - * thing as the rotate/flip transformations, but it's convenient to handle it - * as part of this package, mainly because the transformation routines have to - * be aware of the option to know how many components to work on. - */ - -typedef struct { - /* Options: set by caller */ - JXFORM_CODE transform; /* image transform operator */ - boolean trim; /* if TRUE, trim partial MCUs as needed */ - boolean force_grayscale; /* if TRUE, convert color image to grayscale */ - - /* Internal workspace: caller should not touch these */ - int num_components; /* # of components in workspace */ - jvirt_barray_ptr * workspace_coef_arrays; /* workspace for transformations */ -} jpeg_transform_info; - - -#if TRANSFORMS_SUPPORTED - -/* Request any required workspace */ -EXTERN(void) jtransform_request_workspace - JPP((j_decompress_ptr srcinfo, jpeg_transform_info *info)); -/* Adjust output image parameters */ -EXTERN(jvirt_barray_ptr *) jtransform_adjust_parameters - JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - jvirt_barray_ptr *src_coef_arrays, - jpeg_transform_info *info)); -/* Execute the actual transformation, if any */ -EXTERN(void) jtransform_execute_transformation - JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - jvirt_barray_ptr *src_coef_arrays, - jpeg_transform_info *info)); - -#endif /* TRANSFORMS_SUPPORTED */ - - -/* - * Support for copying optional markers from source to destination file. - */ - -typedef enum { - JCOPYOPT_NONE, /* copy no optional markers */ - JCOPYOPT_COMMENTS, /* copy only comment (COM) markers */ - JCOPYOPT_ALL /* copy all optional markers */ -} JCOPY_OPTION; - -#define JCOPYOPT_DEFAULT JCOPYOPT_COMMENTS /* recommended default */ - -/* Setup decompression object to save desired markers in memory */ -EXTERN(void) jcopy_markers_setup - JPP((j_decompress_ptr srcinfo, JCOPY_OPTION option)); -/* Copy markers saved in the given source object to the destination object */ -EXTERN(void) jcopy_markers_execute - JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - JCOPY_OPTION option)); diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/usage.doc b/irrlicht-1.6/source/Irrlicht/jpeglib/usage.doc deleted file mode 100644 index 4c1a1c23d..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/usage.doc +++ /dev/null @@ -1,562 +0,0 @@ -USAGE instructions for the Independent JPEG Group's JPEG software -================================================================= - -This file describes usage of the JPEG conversion programs cjpeg and djpeg, -as well as the utility programs jpegtran, rdjpgcom and wrjpgcom. (See -the other documentation files if you wish to use the JPEG library within -your own programs.) - -If you are on a Unix machine you may prefer to read the Unix-style manual -pages in files cjpeg.1, djpeg.1, jpegtran.1, rdjpgcom.1, wrjpgcom.1. - - -INTRODUCTION - -These programs implement JPEG image compression and decompression. JPEG -(pronounced "jay-peg") is a standardized compression method for full-color -and gray-scale images. JPEG is designed to handle "real-world" scenes, -for example scanned photographs. Cartoons, line drawings, and other -non-realistic images are not JPEG's strong suit; on that sort of material -you may get poor image quality and/or little compression. - -JPEG is lossy, meaning that the output image is not necessarily identical to -the input image. Hence you should not use JPEG if you have to have identical -output bits. However, on typical real-world images, very good compression -levels can be obtained with no visible change, and amazingly high compression -is possible if you can tolerate a low-quality image. You can trade off image -quality against file size by adjusting the compressor's "quality" setting. - - -GENERAL USAGE - -We provide two programs, cjpeg to compress an image file into JPEG format, -and djpeg to decompress a JPEG file back into a conventional image format. - -On Unix-like systems, you say: - cjpeg [switches] [imagefile] >jpegfile -or - djpeg [switches] [jpegfile] >imagefile -The programs read the specified input file, or standard input if none is -named. They always write to standard output (with trace/error messages to -standard error). These conventions are handy for piping images between -programs. - -On most non-Unix systems, you say: - cjpeg [switches] imagefile jpegfile -or - djpeg [switches] jpegfile imagefile -i.e., both the input and output files are named on the command line. This -style is a little more foolproof, and it loses no functionality if you don't -have pipes. (You can get this style on Unix too, if you prefer, by defining -TWO_FILE_COMMANDLINE when you compile the programs; see install.doc.) - -You can also say: - cjpeg [switches] -outfile jpegfile imagefile -or - djpeg [switches] -outfile imagefile jpegfile -This syntax works on all systems, so it is useful for scripts. - -The currently supported image file formats are: PPM (PBMPLUS color format), -PGM (PBMPLUS gray-scale format), BMP, Targa, and RLE (Utah Raster Toolkit -format). (RLE is supported only if the URT library is available.) -cjpeg recognizes the input image format automatically, with the exception -of some Targa-format files. You have to tell djpeg which format to generate. - -JPEG files are in the defacto standard JFIF file format. There are other, -less widely used JPEG-based file formats, but we don't support them. - -All switch names may be abbreviated; for example, -grayscale may be written --gray or -gr. Most of the "basic" switches can be abbreviated to as little as -one letter. Upper and lower case are equivalent (-BMP is the same as -bmp). -British spellings are also accepted (e.g., -greyscale), though for brevity -these are not mentioned below. - - -CJPEG DETAILS - -The basic command line switches for cjpeg are: - - -quality N Scale quantization tables to adjust image quality. - Quality is 0 (worst) to 100 (best); default is 75. - (See below for more info.) - - -grayscale Create monochrome JPEG file from color input. - Be sure to use this switch when compressing a grayscale - BMP file, because cjpeg isn't bright enough to notice - whether a BMP file uses only shades of gray. By - saying -grayscale, you'll get a smaller JPEG file that - takes less time to process. - - -optimize Perform optimization of entropy encoding parameters. - Without this, default encoding parameters are used. - -optimize usually makes the JPEG file a little smaller, - but cjpeg runs somewhat slower and needs much more - memory. Image quality and speed of decompression are - unaffected by -optimize. - - -progressive Create progressive JPEG file (see below). - - -targa Input file is Targa format. Targa files that contain - an "identification" field will not be automatically - recognized by cjpeg; for such files you must specify - -targa to make cjpeg treat the input as Targa format. - For most Targa files, you won't need this switch. - -The -quality switch lets you trade off compressed file size against quality of -the reconstructed image: the higher the quality setting, the larger the JPEG -file, and the closer the output image will be to the original input. Normally -you want to use the lowest quality setting (smallest file) that decompresses -into something visually indistinguishable from the original image. For this -purpose the quality setting should be between 50 and 95; the default of 75 is -often about right. If you see defects at -quality 75, then go up 5 or 10 -counts at a time until you are happy with the output image. (The optimal -setting will vary from one image to another.) - --quality 100 will generate a quantization table of all 1's, minimizing loss -in the quantization step (but there is still information loss in subsampling, -as well as roundoff error). This setting is mainly of interest for -experimental purposes. Quality values above about 95 are NOT recommended for -normal use; the compressed file size goes up dramatically for hardly any gain -in output image quality. - -In the other direction, quality values below 50 will produce very small files -of low image quality. Settings around 5 to 10 might be useful in preparing an -index of a large image library, for example. Try -quality 2 (or so) for some -amusing Cubist effects. (Note: quality values below about 25 generate 2-byte -quantization tables, which are considered optional in the JPEG standard. -cjpeg emits a warning message when you give such a quality value, because some -other JPEG programs may be unable to decode the resulting file. Use -baseline -if you need to ensure compatibility at low quality values.) - -The -progressive switch creates a "progressive JPEG" file. In this type of -JPEG file, the data is stored in multiple scans of increasing quality. If the -file is being transmitted over a slow communications link, the decoder can use -the first scan to display a low-quality image very quickly, and can then -improve the display with each subsequent scan. The final image is exactly -equivalent to a standard JPEG file of the same quality setting, and the total -file size is about the same --- often a little smaller. CAUTION: progressive -JPEG is not yet widely implemented, so many decoders will be unable to view a -progressive JPEG file at all. - -Switches for advanced users: - - -dct int Use integer DCT method (default). - -dct fast Use fast integer DCT (less accurate). - -dct float Use floating-point DCT method. - The float method is very slightly more accurate than - the int method, but is much slower unless your machine - has very fast floating-point hardware. Also note that - results of the floating-point method may vary slightly - across machines, while the integer methods should give - the same results everywhere. The fast integer method - is much less accurate than the other two. - - -restart N Emit a JPEG restart marker every N MCU rows, or every - N MCU blocks if "B" is attached to the number. - -restart 0 (the default) means no restart markers. - - -smooth N Smooth the input image to eliminate dithering noise. - N, ranging from 1 to 100, indicates the strength of - smoothing. 0 (the default) means no smoothing. - - -maxmemory N Set limit for amount of memory to use in processing - large images. Value is in thousands of bytes, or - millions of bytes if "M" is attached to the number. - For example, -max 4m selects 4000000 bytes. If more - space is needed, temporary files will be used. - - -verbose Enable debug printout. More -v's give more printout. - or -debug Also, version information is printed at startup. - -The -restart option inserts extra markers that allow a JPEG decoder to -resynchronize after a transmission error. Without restart markers, any damage -to a compressed file will usually ruin the image from the point of the error -to the end of the image; with restart markers, the damage is usually confined -to the portion of the image up to the next restart marker. Of course, the -restart markers occupy extra space. We recommend -restart 1 for images that -will be transmitted across unreliable networks such as Usenet. - -The -smooth option filters the input to eliminate fine-scale noise. This is -often useful when converting dithered images to JPEG: a moderate smoothing -factor of 10 to 50 gets rid of dithering patterns in the input file, resulting -in a smaller JPEG file and a better-looking image. Too large a smoothing -factor will visibly blur the image, however. - -Switches for wizards: - - -baseline Force baseline-compatible quantization tables to be - generated. This clamps quantization values to 8 bits - even at low quality settings. (This switch is poorly - named, since it does not ensure that the output is - actually baseline JPEG. For example, you can use - -baseline and -progressive together.) - - -qtables file Use the quantization tables given in the specified - text file. - - -qslots N[,...] Select which quantization table to use for each color - component. - - -sample HxV[,...] Set JPEG sampling factors for each color component. - - -scans file Use the scan script given in the specified text file. - -The "wizard" switches are intended for experimentation with JPEG. If you -don't know what you are doing, DON'T USE THEM. These switches are documented -further in the file wizard.doc. - - -DJPEG DETAILS - -The basic command line switches for djpeg are: - - -colors N Reduce image to at most N colors. This reduces the - or -quantize N number of colors used in the output image, so that it - can be displayed on a colormapped display or stored in - a colormapped file format. For example, if you have - an 8-bit display, you'd need to reduce to 256 or fewer - colors. (-colors is the recommended name, -quantize - is provided only for backwards compatibility.) - - -fast Select recommended processing options for fast, low - quality output. (The default options are chosen for - highest quality output.) Currently, this is equivalent - to "-dct fast -nosmooth -onepass -dither ordered". - - -grayscale Force gray-scale output even if JPEG file is color. - Useful for viewing on monochrome displays; also, - djpeg runs noticeably faster in this mode. - - -scale M/N Scale the output image by a factor M/N. Currently - the scale factor must be 1/1, 1/2, 1/4, or 1/8. - Scaling is handy if the image is larger than your - screen; also, djpeg runs much faster when scaling - down the output. - - -bmp Select BMP output format (Windows flavor). 8-bit - colormapped format is emitted if -colors or -grayscale - is specified, or if the JPEG file is gray-scale; - otherwise, 24-bit full-color format is emitted. - - -gif Select GIF output format. Since GIF does not support - more than 256 colors, -colors 256 is assumed (unless - you specify a smaller number of colors). If you - specify -fast, the default number of colors is 216. - - -os2 Select BMP output format (OS/2 1.x flavor). 8-bit - colormapped format is emitted if -colors or -grayscale - is specified, or if the JPEG file is gray-scale; - otherwise, 24-bit full-color format is emitted. - - -pnm Select PBMPLUS (PPM/PGM) output format (this is the - default format). PGM is emitted if the JPEG file is - gray-scale or if -grayscale is specified; otherwise - PPM is emitted. - - -rle Select RLE output format. (Requires URT library.) - - -targa Select Targa output format. Gray-scale format is - emitted if the JPEG file is gray-scale or if - -grayscale is specified; otherwise, colormapped format - is emitted if -colors is specified; otherwise, 24-bit - full-color format is emitted. - -Switches for advanced users: - - -dct int Use integer DCT method (default). - -dct fast Use fast integer DCT (less accurate). - -dct float Use floating-point DCT method. - The float method is very slightly more accurate than - the int method, but is much slower unless your machine - has very fast floating-point hardware. Also note that - results of the floating-point method may vary slightly - across machines, while the integer methods should give - the same results everywhere. The fast integer method - is much less accurate than the other two. - - -dither fs Use Floyd-Steinberg dithering in color quantization. - -dither ordered Use ordered dithering in color quantization. - -dither none Do not use dithering in color quantization. - By default, Floyd-Steinberg dithering is applied when - quantizing colors; this is slow but usually produces - the best results. Ordered dither is a compromise - between speed and quality; no dithering is fast but - usually looks awful. Note that these switches have - no effect unless color quantization is being done. - Ordered dither is only available in -onepass mode. - - -map FILE Quantize to the colors used in the specified image - file. This is useful for producing multiple files - with identical color maps, or for forcing a predefined - set of colors to be used. The FILE must be a GIF - or PPM file. This option overrides -colors and - -onepass. - - -nosmooth Use a faster, lower-quality upsampling routine. - - -onepass Use one-pass instead of two-pass color quantization. - The one-pass method is faster and needs less memory, - but it produces a lower-quality image. -onepass is - ignored unless you also say -colors N. Also, - the one-pass method is always used for gray-scale - output (the two-pass method is no improvement then). - - -maxmemory N Set limit for amount of memory to use in processing - large images. Value is in thousands of bytes, or - millions of bytes if "M" is attached to the number. - For example, -max 4m selects 4000000 bytes. If more - space is needed, temporary files will be used. - - -verbose Enable debug printout. More -v's give more printout. - or -debug Also, version information is printed at startup. - - -HINTS FOR CJPEG - -Color GIF files are not the ideal input for JPEG; JPEG is really intended for -compressing full-color (24-bit) images. In particular, don't try to convert -cartoons, line drawings, and other images that have only a few distinct -colors. GIF works great on these, JPEG does not. If you want to convert a -GIF to JPEG, you should experiment with cjpeg's -quality and -smooth options -to get a satisfactory conversion. -smooth 10 or so is often helpful. - -Avoid running an image through a series of JPEG compression/decompression -cycles. Image quality loss will accumulate; after ten or so cycles the image -may be noticeably worse than it was after one cycle. It's best to use a -lossless format while manipulating an image, then convert to JPEG format when -you are ready to file the image away. - -The -optimize option to cjpeg is worth using when you are making a "final" -version for posting or archiving. It's also a win when you are using low -quality settings to make very small JPEG files; the percentage improvement -is often a lot more than it is on larger files. (At present, -optimize -mode is always selected when generating progressive JPEG files.) - -GIF input files are no longer supported, to avoid the Unisys LZW patent. -Use a Unisys-licensed program if you need to read a GIF file. (Conversion -of GIF files to JPEG is usually a bad idea anyway.) - - -HINTS FOR DJPEG - -To get a quick preview of an image, use the -grayscale and/or -scale switches. -"-grayscale -scale 1/8" is the fastest case. - -Several options are available that trade off image quality to gain speed. -"-fast" turns on the recommended settings. - -"-dct fast" and/or "-nosmooth" gain speed at a small sacrifice in quality. -When producing a color-quantized image, "-onepass -dither ordered" is fast but -much lower quality than the default behavior. "-dither none" may give -acceptable results in two-pass mode, but is seldom tolerable in one-pass mode. - -If you are fortunate enough to have very fast floating point hardware, -"-dct float" may be even faster than "-dct fast". But on most machines -"-dct float" is slower than "-dct int"; in this case it is not worth using, -because its theoretical accuracy advantage is too small to be significant -in practice. - -Two-pass color quantization requires a good deal of memory; on MS-DOS machines -it may run out of memory even with -maxmemory 0. In that case you can still -decompress, with some loss of image quality, by specifying -onepass for -one-pass quantization. - -To avoid the Unisys LZW patent, djpeg produces uncompressed GIF files. These -are larger than they should be, but are readable by standard GIF decoders. - - -HINTS FOR BOTH PROGRAMS - -If more space is needed than will fit in the available main memory (as -determined by -maxmemory), temporary files will be used. (MS-DOS versions -will try to get extended or expanded memory first.) The temporary files are -often rather large: in typical cases they occupy three bytes per pixel, for -example 3*800*600 = 1.44Mb for an 800x600 image. If you don't have enough -free disk space, leave out -progressive and -optimize (for cjpeg) or specify --onepass (for djpeg). - -On MS-DOS, the temporary files are created in the directory named by the TMP -or TEMP environment variable, or in the current directory if neither of those -exist. Amiga implementations put the temp files in the directory named by -JPEGTMP:, so be sure to assign JPEGTMP: to a disk partition with adequate free -space. - -The default memory usage limit (-maxmemory) is set when the software is -compiled. If you get an "insufficient memory" error, try specifying a smaller --maxmemory value, even -maxmemory 0 to use the absolute minimum space. You -may want to recompile with a smaller default value if this happens often. - -On machines that have "environment" variables, you can define the environment -variable JPEGMEM to set the default memory limit. The value is specified as -described for the -maxmemory switch. JPEGMEM overrides the default value -specified when the program was compiled, and itself is overridden by an -explicit -maxmemory switch. - -On MS-DOS machines, -maxmemory is the amount of main (conventional) memory to -use. (Extended or expanded memory is also used if available.) Most -DOS-specific versions of this software do their own memory space estimation -and do not need you to specify -maxmemory. - - -JPEGTRAN - -jpegtran performs various useful transformations of JPEG files. -It can translate the coded representation from one variant of JPEG to another, -for example from baseline JPEG to progressive JPEG or vice versa. It can also -perform some rearrangements of the image data, for example turning an image -from landscape to portrait format by rotation. - -jpegtran works by rearranging the compressed data (DCT coefficients), without -ever fully decoding the image. Therefore, its transformations are lossless: -there is no image degradation at all, which would not be true if you used -djpeg followed by cjpeg to accomplish the same conversion. But by the same -token, jpegtran cannot perform lossy operations such as changing the image -quality. - -jpegtran uses a command line syntax similar to cjpeg or djpeg. -On Unix-like systems, you say: - jpegtran [switches] [inputfile] >outputfile -On most non-Unix systems, you say: - jpegtran [switches] inputfile outputfile -where both the input and output files are JPEG files. - -To specify the coded JPEG representation used in the output file, -jpegtran accepts a subset of the switches recognized by cjpeg: - -optimize Perform optimization of entropy encoding parameters. - -progressive Create progressive JPEG file. - -restart N Emit a JPEG restart marker every N MCU rows, or every - N MCU blocks if "B" is attached to the number. - -scans file Use the scan script given in the specified text file. -See the previous discussion of cjpeg for more details about these switches. -If you specify none of these switches, you get a plain baseline-JPEG output -file. The quality setting and so forth are determined by the input file. - -The image can be losslessly transformed by giving one of these switches: - -flip horizontal Mirror image horizontally (left-right). - -flip vertical Mirror image vertically (top-bottom). - -rotate 90 Rotate image 90 degrees clockwise. - -rotate 180 Rotate image 180 degrees. - -rotate 270 Rotate image 270 degrees clockwise (or 90 ccw). - -transpose Transpose image (across UL-to-LR axis). - -transverse Transverse transpose (across UR-to-LL axis). - -The transpose transformation has no restrictions regarding image dimensions. -The other transformations operate rather oddly if the image dimensions are not -a multiple of the iMCU size (usually 8 or 16 pixels), because they can only -transform complete blocks of DCT coefficient data in the desired way. - -jpegtran's default behavior when transforming an odd-size image is designed -to preserve exact reversibility and mathematical consistency of the -transformation set. As stated, transpose is able to flip the entire image -area. Horizontal mirroring leaves any partial iMCU column at the right edge -untouched, but is able to flip all rows of the image. Similarly, vertical -mirroring leaves any partial iMCU row at the bottom edge untouched, but is -able to flip all columns. The other transforms can be built up as sequences -of transpose and flip operations; for consistency, their actions on edge -pixels are defined to be the same as the end result of the corresponding -transpose-and-flip sequence. - -For practical use, you may prefer to discard any untransformable edge pixels -rather than having a strange-looking strip along the right and/or bottom edges -of a transformed image. To do this, add the -trim switch: - -trim Drop non-transformable edge blocks. -Obviously, a transformation with -trim is not reversible, so strictly speaking -jpegtran with this switch is not lossless. Also, the expected mathematical -equivalences between the transformations no longer hold. For example, -"-rot 270 -trim" trims only the bottom edge, but "-rot 90 -trim" followed by -"-rot 180 -trim" trims both edges. - -Another not-strictly-lossless transformation switch is: - -grayscale Force grayscale output. -This option discards the chrominance channels if the input image is YCbCr -(ie, a standard color JPEG), resulting in a grayscale JPEG file. The -luminance channel is preserved exactly, so this is a better method of reducing -to grayscale than decompression, conversion, and recompression. This switch -is particularly handy for fixing a monochrome picture that was mistakenly -encoded as a color JPEG. (In such a case, the space savings from getting rid -of the near-empty chroma channels won't be large; but the decoding time for -a grayscale JPEG is substantially less than that for a color JPEG.) - -jpegtran also recognizes these switches that control what to do with "extra" -markers, such as comment blocks: - -copy none Copy no extra markers from source file. This setting - suppresses all comments and other excess baggage - present in the source file. - -copy comments Copy only comment markers. This setting copies - comments from the source file, but discards - any other inessential data. - -copy all Copy all extra markers. This setting preserves - miscellaneous markers found in the source file, such - as JFIF thumbnails and Photoshop settings. In some - files these extra markers can be sizable. -The default behavior is -copy comments. (Note: in IJG releases v6 and v6a, -jpegtran always did the equivalent of -copy none.) - -Additional switches recognized by jpegtran are: - -outfile filename - -maxmemory N - -verbose - -debug -These work the same as in cjpeg or djpeg. - - -THE COMMENT UTILITIES - -The JPEG standard allows "comment" (COM) blocks to occur within a JPEG file. -Although the standard doesn't actually define what COM blocks are for, they -are widely used to hold user-supplied text strings. This lets you add -annotations, titles, index terms, etc to your JPEG files, and later retrieve -them as text. COM blocks do not interfere with the image stored in the JPEG -file. The maximum size of a COM block is 64K, but you can have as many of -them as you like in one JPEG file. - -We provide two utility programs to display COM block contents and add COM -blocks to a JPEG file. - -rdjpgcom searches a JPEG file and prints the contents of any COM blocks on -standard output. The command line syntax is - rdjpgcom [-verbose] [inputfilename] -The switch "-verbose" (or just "-v") causes rdjpgcom to also display the JPEG -image dimensions. If you omit the input file name from the command line, -the JPEG file is read from standard input. (This may not work on some -operating systems, if binary data can't be read from stdin.) - -wrjpgcom adds a COM block, containing text you provide, to a JPEG file. -Ordinarily, the COM block is added after any existing COM blocks, but you -can delete the old COM blocks if you wish. wrjpgcom produces a new JPEG -file; it does not modify the input file. DO NOT try to overwrite the input -file by directing wrjpgcom's output back into it; on most systems this will -just destroy your file. - -The command line syntax for wrjpgcom is similar to cjpeg's. On Unix-like -systems, it is - wrjpgcom [switches] [inputfilename] -The output file is written to standard output. The input file comes from -the named file, or from standard input if no input file is named. - -On most non-Unix systems, the syntax is - wrjpgcom [switches] inputfilename outputfilename -where both input and output file names must be given explicitly. - -wrjpgcom understands three switches: - -replace Delete any existing COM blocks from the file. - -comment "Comment text" Supply new COM text on command line. - -cfile name Read text for new COM block from named file. -(Switch names can be abbreviated.) If you have only one line of comment text -to add, you can provide it on the command line with -comment. The comment -text must be surrounded with quotes so that it is treated as a single -argument. Longer comments can be read from a text file. - -If you give neither -comment nor -cfile, then wrjpgcom will read the comment -text from standard input. (In this case an input image file name MUST be -supplied, so that the source JPEG file comes from somewhere else.) You can -enter multiple lines, up to 64KB worth. Type an end-of-file indicator -(usually control-D or control-Z) to terminate the comment text entry. - -wrjpgcom will not add a COM block if the provided comment string is empty. -Therefore -replace -comment "" can be used to delete all COM blocks from a -file. - -These utility programs do not depend on the IJG JPEG library. In -particular, the source code for rdjpgcom is intended as an illustration of -the minimum amount of code required to parse a JPEG file header correctly. diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/wizard.doc b/irrlicht-1.6/source/Irrlicht/jpeglib/wizard.doc deleted file mode 100644 index 02418ba2b..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/wizard.doc +++ /dev/null @@ -1,211 +0,0 @@ -Advanced usage instructions for the Independent JPEG Group's JPEG software -========================================================================== - -This file describes cjpeg's "switches for wizards". - -The "wizard" switches are intended for experimentation with JPEG by persons -who are reasonably knowledgeable about the JPEG standard. If you don't know -what you are doing, DON'T USE THESE SWITCHES. You'll likely produce files -with worse image quality and/or poorer compression than you'd get from the -default settings. Furthermore, these switches must be used with caution -when making files intended for general use, because not all JPEG decoders -will support unusual JPEG parameter settings. - - -Quantization Table Adjustment ------------------------------ - -Ordinarily, cjpeg starts with a default set of tables (the same ones given -as examples in the JPEG standard) and scales them up or down according to -the -quality setting. The details of the scaling algorithm can be found in -jcparam.c. At very low quality settings, some quantization table entries -can get scaled up to values exceeding 255. Although 2-byte quantization -values are supported by the IJG software, this feature is not in baseline -JPEG and is not supported by all implementations. If you need to ensure -wide compatibility of low-quality files, you can constrain the scaled -quantization values to no more than 255 by giving the -baseline switch. -Note that use of -baseline will result in poorer quality for the same file -size, since more bits than necessary are expended on higher AC coefficients. - -You can substitute a different set of quantization values by using the --qtables switch: - - -qtables file Use the quantization tables given in the named file. - -The specified file should be a text file containing decimal quantization -values. The file should contain one to four tables, each of 64 elements. -The tables are implicitly numbered 0,1,etc. in order of appearance. Table -entries appear in normal array order (NOT in the zigzag order in which they -will be stored in the JPEG file). - -Quantization table files are free format, in that arbitrary whitespace can -appear between numbers. Also, comments can be included: a comment starts -with '#' and extends to the end of the line. Here is an example file that -duplicates the default quantization tables: - - # Quantization tables given in JPEG spec, section K.1 - - # This is table 0 (the luminance table): - 16 11 10 16 24 40 51 61 - 12 12 14 19 26 58 60 55 - 14 13 16 24 40 57 69 56 - 14 17 22 29 51 87 80 62 - 18 22 37 56 68 109 103 77 - 24 35 55 64 81 104 113 92 - 49 64 78 87 103 121 120 101 - 72 92 95 98 112 100 103 99 - - # This is table 1 (the chrominance table): - 17 18 24 47 99 99 99 99 - 18 21 26 66 99 99 99 99 - 24 26 56 99 99 99 99 99 - 47 66 99 99 99 99 99 99 - 99 99 99 99 99 99 99 99 - 99 99 99 99 99 99 99 99 - 99 99 99 99 99 99 99 99 - 99 99 99 99 99 99 99 99 - -If the -qtables switch is used without -quality, then the specified tables -are used exactly as-is. If both -qtables and -quality are used, then the -tables taken from the file are scaled in the same fashion that the default -tables would be scaled for that quality setting. If -baseline appears, then -the quantization values are constrained to the range 1-255. - -By default, cjpeg will use quantization table 0 for luminance components and -table 1 for chrominance components. To override this choice, use the -qslots -switch: - - -qslots N[,...] Select which quantization table to use for - each color component. - -The -qslots switch specifies a quantization table number for each color -component, in the order in which the components appear in the JPEG SOF marker. -For example, to create a separate table for each of Y,Cb,Cr, you could -provide a -qtables file that defines three quantization tables and say -"-qslots 0,1,2". If -qslots gives fewer table numbers than there are color -components, then the last table number is repeated as necessary. - - -Sampling Factor Adjustment --------------------------- - -By default, cjpeg uses 2:1 horizontal and vertical downsampling when -compressing YCbCr data, and no downsampling for all other color spaces. -You can override this default with the -sample switch: - - -sample HxV[,...] Set JPEG sampling factors for each color - component. - -The -sample switch specifies the JPEG sampling factors for each color -component, in the order in which they appear in the JPEG SOF marker. -If you specify fewer HxV pairs than there are components, the remaining -components are set to 1x1 sampling. For example, the default YCbCr setting -is equivalent to "-sample 2x2,1x1,1x1", which can be abbreviated to -"-sample 2x2". - -There are still some JPEG decoders in existence that support only 2x1 -sampling (also called 4:2:2 sampling). Compatibility with such decoders can -be achieved by specifying "-sample 2x1". This is not recommended unless -really necessary, since it increases file size and encoding/decoding time -with very little quality gain. - - -Multiple Scan / Progression Control ------------------------------------ - -By default, cjpeg emits a single-scan sequential JPEG file. The --progressive switch generates a progressive JPEG file using a default series -of progression parameters. You can create multiple-scan sequential JPEG -files or progressive JPEG files with custom progression parameters by using -the -scans switch: - - -scans file Use the scan sequence given in the named file. - -The specified file should be a text file containing a "scan script". -The script specifies the contents and ordering of the scans to be emitted. -Each entry in the script defines one scan. A scan definition specifies -the components to be included in the scan, and for progressive JPEG it also -specifies the progression parameters Ss,Se,Ah,Al for the scan. Scan -definitions are separated by semicolons (';'). A semicolon after the last -scan definition is optional. - -Each scan definition contains one to four component indexes, optionally -followed by a colon (':') and the four progressive-JPEG parameters. The -component indexes denote which color component(s) are to be transmitted in -the scan. Components are numbered in the order in which they appear in the -JPEG SOF marker, with the first component being numbered 0. (Note that these -indexes are not the "component ID" codes assigned to the components, just -positional indexes.) - -The progression parameters for each scan are: - Ss Zigzag index of first coefficient included in scan - Se Zigzag index of last coefficient included in scan - Ah Zero for first scan of a coefficient, else Al of prior scan - Al Successive approximation low bit position for scan -If the progression parameters are omitted, the values 0,63,0,0 are used, -producing a sequential JPEG file. cjpeg automatically determines whether -the script represents a progressive or sequential file, by observing whether -Ss and Se values other than 0 and 63 appear. (The -progressive switch is -not needed to specify this; in fact, it is ignored when -scans appears.) -The scan script must meet the JPEG restrictions on progression sequences. -(cjpeg checks that the spec's requirements are obeyed.) - -Scan script files are free format, in that arbitrary whitespace can appear -between numbers and around punctuation. Also, comments can be included: a -comment starts with '#' and extends to the end of the line. For additional -legibility, commas or dashes can be placed between values. (Actually, any -single punctuation character other than ':' or ';' can be inserted.) For -example, the following two scan definitions are equivalent: - 0 1 2: 0 63 0 0; - 0,1,2 : 0-63, 0,0 ; - -Here is an example of a scan script that generates a partially interleaved -sequential JPEG file: - - 0; # Y only in first scan - 1 2; # Cb and Cr in second scan - -Here is an example of a progressive scan script using only spectral selection -(no successive approximation): - - # Interleaved DC scan for Y,Cb,Cr: - 0,1,2: 0-0, 0, 0 ; - # AC scans: - 0: 1-2, 0, 0 ; # First two Y AC coefficients - 0: 3-5, 0, 0 ; # Three more - 1: 1-63, 0, 0 ; # All AC coefficients for Cb - 2: 1-63, 0, 0 ; # All AC coefficients for Cr - 0: 6-9, 0, 0 ; # More Y coefficients - 0: 10-63, 0, 0 ; # Remaining Y coefficients - -Here is an example of a successive-approximation script. This is equivalent -to the default script used by "cjpeg -progressive" for YCbCr images: - - # Initial DC scan for Y,Cb,Cr (lowest bit not sent) - 0,1,2: 0-0, 0, 1 ; - # First AC scan: send first 5 Y AC coefficients, minus 2 lowest bits: - 0: 1-5, 0, 2 ; - # Send all Cr,Cb AC coefficients, minus lowest bit: - # (chroma data is usually too small to be worth subdividing further; - # but note we send Cr first since eye is least sensitive to Cb) - 2: 1-63, 0, 1 ; - 1: 1-63, 0, 1 ; - # Send remaining Y AC coefficients, minus 2 lowest bits: - 0: 6-63, 0, 2 ; - # Send next-to-lowest bit of all Y AC coefficients: - 0: 1-63, 2, 1 ; - # At this point we've sent all but the lowest bit of all coefficients. - # Send lowest bit of DC coefficients - 0,1,2: 0-0, 1, 0 ; - # Send lowest bit of AC coefficients - 2: 1-63, 1, 0 ; - 1: 1-63, 1, 0 ; - # Y AC lowest bit scan is last; it's usually the largest scan - 0: 1-63, 1, 0 ; - -It may be worth pointing out that this script is tuned for quality settings -of around 50 to 75. For lower quality settings, you'd probably want to use -a script with fewer stages of successive approximation (otherwise the -initial scans will be really bad). For higher quality settings, you might -want to use more stages of successive approximation (so that the initial -scans are not too large). diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/wrbmp.c b/irrlicht-1.6/source/Irrlicht/jpeglib/wrbmp.c deleted file mode 100644 index 2b8146e2c..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/wrbmp.c +++ /dev/null @@ -1,442 +0,0 @@ -/* - * wrbmp.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to write output images in Microsoft "BMP" - * format (MS Windows 3.x and OS/2 1.x flavors). - * Either 8-bit colormapped or 24-bit full-color format can be written. - * No compression is supported. - * - * These routines may need modification for non-Unix environments or - * specialized applications. As they stand, they assume output to - * an ordinary stdio stream. - * - * This code contributed by James Arthur Boucher. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef BMP_SUPPORTED - - -/* - * To support 12-bit JPEG data, we'd have to scale output down to 8 bits. - * This is not yet implemented. - */ - -#if BITS_IN_JSAMPLE != 8 - Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */ -#endif - -/* - * Since BMP stores scanlines bottom-to-top, we have to invert the image - * from JPEG's top-to-bottom order. To do this, we save the outgoing data - * in a virtual array during put_pixel_row calls, then actually emit the - * BMP file during finish_output. The virtual array contains one JSAMPLE per - * pixel if the output is grayscale or colormapped, three if it is full color. - */ - -/* Private version of data destination object */ - -typedef struct { - struct djpeg_dest_struct pub; /* public fields */ - - boolean is_os2; /* saves the OS2 format request flag */ - - jvirt_sarray_ptr whole_image; /* needed to reverse row order */ - JDIMENSION data_width; /* JSAMPLEs per row */ - JDIMENSION row_width; /* physical width of one row in the BMP file */ - int pad_bytes; /* number of padding bytes needed per row */ - JDIMENSION cur_output_row; /* next row# to write to virtual array */ -} bmp_dest_struct; - -typedef bmp_dest_struct * bmp_dest_ptr; - - -/* Forward declarations */ -LOCAL(void) write_colormap - JPP((j_decompress_ptr cinfo, bmp_dest_ptr dest, - int map_colors, int map_entry_size)); - - -/* - * Write some pixel data. - * In this module rows_supplied will always be 1. - */ - -METHODDEF(void) -put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -/* This version is for writing 24-bit pixels */ -{ - bmp_dest_ptr dest = (bmp_dest_ptr) dinfo; - JSAMPARRAY image_ptr; - register JSAMPROW inptr, outptr; - register JDIMENSION col; - int pad; - - /* Access next row in virtual array */ - image_ptr = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, dest->whole_image, - dest->cur_output_row, (JDIMENSION) 1, TRUE); - dest->cur_output_row++; - - /* Transfer data. Note destination values must be in BGR order - * (even though Microsoft's own documents say the opposite). - */ - inptr = dest->pub.buffer[0]; - outptr = image_ptr[0]; - for (col = cinfo->output_width; col > 0; col--) { - outptr[2] = *inptr++; /* can omit GETJSAMPLE() safely */ - outptr[1] = *inptr++; - outptr[0] = *inptr++; - outptr += 3; - } - - /* Zero out the pad bytes. */ - pad = dest->pad_bytes; - while (--pad >= 0) - *outptr++ = 0; -} - -METHODDEF(void) -put_gray_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -/* This version is for grayscale OR quantized color output */ -{ - bmp_dest_ptr dest = (bmp_dest_ptr) dinfo; - JSAMPARRAY image_ptr; - register JSAMPROW inptr, outptr; - register JDIMENSION col; - int pad; - - /* Access next row in virtual array */ - image_ptr = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, dest->whole_image, - dest->cur_output_row, (JDIMENSION) 1, TRUE); - dest->cur_output_row++; - - /* Transfer data. */ - inptr = dest->pub.buffer[0]; - outptr = image_ptr[0]; - for (col = cinfo->output_width; col > 0; col--) { - *outptr++ = *inptr++; /* can omit GETJSAMPLE() safely */ - } - - /* Zero out the pad bytes. */ - pad = dest->pad_bytes; - while (--pad >= 0) - *outptr++ = 0; -} - - -/* - * Startup: normally writes the file header. - * In this module we may as well postpone everything until finish_output. - */ - -METHODDEF(void) -start_output_bmp (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - /* no work here */ -} - - -/* - * Finish up at the end of the file. - * - * Here is where we really output the BMP file. - * - * First, routines to write the Windows and OS/2 variants of the file header. - */ - -LOCAL(void) -write_bmp_header (j_decompress_ptr cinfo, bmp_dest_ptr dest) -/* Write a Windows-style BMP file header, including colormap if needed */ -{ - char bmpfileheader[14]; - char bmpinfoheader[40]; -#define PUT_2B(array,offset,value) \ - (array[offset] = (char) ((value) & 0xFF), \ - array[offset+1] = (char) (((value) >> 8) & 0xFF)) -#define PUT_4B(array,offset,value) \ - (array[offset] = (char) ((value) & 0xFF), \ - array[offset+1] = (char) (((value) >> 8) & 0xFF), \ - array[offset+2] = (char) (((value) >> 16) & 0xFF), \ - array[offset+3] = (char) (((value) >> 24) & 0xFF)) - INT32 headersize, bfSize; - int bits_per_pixel, cmap_entries; - - /* Compute colormap size and total file size */ - if (cinfo->out_color_space == JCS_RGB) { - if (cinfo->quantize_colors) { - /* Colormapped RGB */ - bits_per_pixel = 8; - cmap_entries = 256; - } else { - /* Unquantized, full color RGB */ - bits_per_pixel = 24; - cmap_entries = 0; - } - } else { - /* Grayscale output. We need to fake a 256-entry colormap. */ - bits_per_pixel = 8; - cmap_entries = 256; - } - /* File size */ - headersize = 14 + 40 + cmap_entries * 4; /* Header and colormap */ - bfSize = headersize + (INT32) dest->row_width * (INT32) cinfo->output_height; - - /* Set unused fields of header to 0 */ - MEMZERO(bmpfileheader, SIZEOF(bmpfileheader)); - MEMZERO(bmpinfoheader, SIZEOF(bmpinfoheader)); - - /* Fill the file header */ - bmpfileheader[0] = 0x42; /* first 2 bytes are ASCII 'B', 'M' */ - bmpfileheader[1] = 0x4D; - PUT_4B(bmpfileheader, 2, bfSize); /* bfSize */ - /* we leave bfReserved1 & bfReserved2 = 0 */ - PUT_4B(bmpfileheader, 10, headersize); /* bfOffBits */ - - /* Fill the info header (Microsoft calls this a BITMAPINFOHEADER) */ - PUT_2B(bmpinfoheader, 0, 40); /* biSize */ - PUT_4B(bmpinfoheader, 4, cinfo->output_width); /* biWidth */ - PUT_4B(bmpinfoheader, 8, cinfo->output_height); /* biHeight */ - PUT_2B(bmpinfoheader, 12, 1); /* biPlanes - must be 1 */ - PUT_2B(bmpinfoheader, 14, bits_per_pixel); /* biBitCount */ - /* we leave biCompression = 0, for none */ - /* we leave biSizeImage = 0; this is correct for uncompressed data */ - if (cinfo->density_unit == 2) { /* if have density in dots/cm, then */ - PUT_4B(bmpinfoheader, 24, (INT32) (cinfo->X_density*100)); /* XPels/M */ - PUT_4B(bmpinfoheader, 28, (INT32) (cinfo->Y_density*100)); /* XPels/M */ - } - PUT_2B(bmpinfoheader, 32, cmap_entries); /* biClrUsed */ - /* we leave biClrImportant = 0 */ - - if (JFWRITE(dest->pub.output_file, bmpfileheader, 14) != (size_t) 14) - ERREXIT(cinfo, JERR_FILE_WRITE); - if (JFWRITE(dest->pub.output_file, bmpinfoheader, 40) != (size_t) 40) - ERREXIT(cinfo, JERR_FILE_WRITE); - - if (cmap_entries > 0) - write_colormap(cinfo, dest, cmap_entries, 4); -} - - -LOCAL(void) -write_os2_header (j_decompress_ptr cinfo, bmp_dest_ptr dest) -/* Write an OS2-style BMP file header, including colormap if needed */ -{ - char bmpfileheader[14]; - char bmpcoreheader[12]; - INT32 headersize, bfSize; - int bits_per_pixel, cmap_entries; - - /* Compute colormap size and total file size */ - if (cinfo->out_color_space == JCS_RGB) { - if (cinfo->quantize_colors) { - /* Colormapped RGB */ - bits_per_pixel = 8; - cmap_entries = 256; - } else { - /* Unquantized, full color RGB */ - bits_per_pixel = 24; - cmap_entries = 0; - } - } else { - /* Grayscale output. We need to fake a 256-entry colormap. */ - bits_per_pixel = 8; - cmap_entries = 256; - } - /* File size */ - headersize = 14 + 12 + cmap_entries * 3; /* Header and colormap */ - bfSize = headersize + (INT32) dest->row_width * (INT32) cinfo->output_height; - - /* Set unused fields of header to 0 */ - MEMZERO(bmpfileheader, SIZEOF(bmpfileheader)); - MEMZERO(bmpcoreheader, SIZEOF(bmpcoreheader)); - - /* Fill the file header */ - bmpfileheader[0] = 0x42; /* first 2 bytes are ASCII 'B', 'M' */ - bmpfileheader[1] = 0x4D; - PUT_4B(bmpfileheader, 2, bfSize); /* bfSize */ - /* we leave bfReserved1 & bfReserved2 = 0 */ - PUT_4B(bmpfileheader, 10, headersize); /* bfOffBits */ - - /* Fill the info header (Microsoft calls this a BITMAPCOREHEADER) */ - PUT_2B(bmpcoreheader, 0, 12); /* bcSize */ - PUT_2B(bmpcoreheader, 4, cinfo->output_width); /* bcWidth */ - PUT_2B(bmpcoreheader, 6, cinfo->output_height); /* bcHeight */ - PUT_2B(bmpcoreheader, 8, 1); /* bcPlanes - must be 1 */ - PUT_2B(bmpcoreheader, 10, bits_per_pixel); /* bcBitCount */ - - if (JFWRITE(dest->pub.output_file, bmpfileheader, 14) != (size_t) 14) - ERREXIT(cinfo, JERR_FILE_WRITE); - if (JFWRITE(dest->pub.output_file, bmpcoreheader, 12) != (size_t) 12) - ERREXIT(cinfo, JERR_FILE_WRITE); - - if (cmap_entries > 0) - write_colormap(cinfo, dest, cmap_entries, 3); -} - - -/* - * Write the colormap. - * Windows uses BGR0 map entries; OS/2 uses BGR entries. - */ - -LOCAL(void) -write_colormap (j_decompress_ptr cinfo, bmp_dest_ptr dest, - int map_colors, int map_entry_size) -{ - JSAMPARRAY colormap = cinfo->colormap; - int num_colors = cinfo->actual_number_of_colors; - FILE * outfile = dest->pub.output_file; - int i; - - if (colormap != NULL) { - if (cinfo->out_color_components == 3) { - /* Normal case with RGB colormap */ - for (i = 0; i < num_colors; i++) { - putc(GETJSAMPLE(colormap[2][i]), outfile); - putc(GETJSAMPLE(colormap[1][i]), outfile); - putc(GETJSAMPLE(colormap[0][i]), outfile); - if (map_entry_size == 4) - putc(0, outfile); - } - } else { - /* Grayscale colormap (only happens with grayscale quantization) */ - for (i = 0; i < num_colors; i++) { - putc(GETJSAMPLE(colormap[0][i]), outfile); - putc(GETJSAMPLE(colormap[0][i]), outfile); - putc(GETJSAMPLE(colormap[0][i]), outfile); - if (map_entry_size == 4) - putc(0, outfile); - } - } - } else { - /* If no colormap, must be grayscale data. Generate a linear "map". */ - for (i = 0; i < 256; i++) { - putc(i, outfile); - putc(i, outfile); - putc(i, outfile); - if (map_entry_size == 4) - putc(0, outfile); - } - } - /* Pad colormap with zeros to ensure specified number of colormap entries */ - if (i > map_colors) - ERREXIT1(cinfo, JERR_TOO_MANY_COLORS, i); - for (; i < map_colors; i++) { - putc(0, outfile); - putc(0, outfile); - putc(0, outfile); - if (map_entry_size == 4) - putc(0, outfile); - } -} - - -METHODDEF(void) -finish_output_bmp (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - bmp_dest_ptr dest = (bmp_dest_ptr) dinfo; - register FILE * outfile = dest->pub.output_file; - JSAMPARRAY image_ptr; - register JSAMPROW data_ptr; - JDIMENSION row; - register JDIMENSION col; - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; - - /* Write the header and colormap */ - if (dest->is_os2) - write_os2_header(cinfo, dest); - else - write_bmp_header(cinfo, dest); - - /* Write the file body from our virtual array */ - for (row = cinfo->output_height; row > 0; row--) { - if (progress != NULL) { - progress->pub.pass_counter = (long) (cinfo->output_height - row); - progress->pub.pass_limit = (long) cinfo->output_height; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } - image_ptr = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, dest->whole_image, row-1, (JDIMENSION) 1, FALSE); - data_ptr = image_ptr[0]; - for (col = dest->row_width; col > 0; col--) { - putc(GETJSAMPLE(*data_ptr), outfile); - data_ptr++; - } - } - if (progress != NULL) - progress->completed_extra_passes++; - - /* Make sure we wrote the output file OK */ - fflush(outfile); - if (ferror(outfile)) - ERREXIT(cinfo, JERR_FILE_WRITE); -} - - -/* - * The module selection routine for BMP format output. - */ - -GLOBAL(djpeg_dest_ptr) -jinit_write_bmp (j_decompress_ptr cinfo, boolean is_os2) -{ - bmp_dest_ptr dest; - JDIMENSION row_width; - - /* Create module interface object, fill in method pointers */ - dest = (bmp_dest_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(bmp_dest_struct)); - dest->pub.start_output = start_output_bmp; - dest->pub.finish_output = finish_output_bmp; - dest->is_os2 = is_os2; - - if (cinfo->out_color_space == JCS_GRAYSCALE) { - dest->pub.put_pixel_rows = put_gray_rows; - } else if (cinfo->out_color_space == JCS_RGB) { - if (cinfo->quantize_colors) - dest->pub.put_pixel_rows = put_gray_rows; - else - dest->pub.put_pixel_rows = put_pixel_rows; - } else { - ERREXIT(cinfo, JERR_BMP_COLORSPACE); - } - - /* Calculate output image dimensions so we can allocate space */ - jpeg_calc_output_dimensions(cinfo); - - /* Determine width of rows in the BMP file (padded to 4-byte boundary). */ - row_width = cinfo->output_width * cinfo->output_components; - dest->data_width = row_width; - while ((row_width & 3) != 0) row_width++; - dest->row_width = row_width; - dest->pad_bytes = (int) (row_width - dest->data_width); - - /* Allocate space for inversion array, prepare for write pass */ - dest->whole_image = (*cinfo->mem->request_virt_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, - row_width, cinfo->output_height, (JDIMENSION) 1); - dest->cur_output_row = 0; - if (cinfo->progress != NULL) { - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; - progress->total_extra_passes++; /* count file input as separate pass */ - } - - /* Create decompressor output buffer. */ - dest->pub.buffer = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, row_width, (JDIMENSION) 1); - dest->pub.buffer_height = 1; - - return (djpeg_dest_ptr) dest; -} - -#endif /* BMP_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/wrgif.c b/irrlicht-1.6/source/Irrlicht/jpeglib/wrgif.c deleted file mode 100644 index 13f953b56..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/wrgif.c +++ /dev/null @@ -1,399 +0,0 @@ -/* - * wrgif.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to write output images in GIF format. - * - ************************************************************************** - * NOTE: to avoid entanglements with Unisys' patent on LZW compression, * - * this code has been modified to output "uncompressed GIF" files. * - * There is no trace of the LZW algorithm in this file. * - ************************************************************************** - * - * These routines may need modification for non-Unix environments or - * specialized applications. As they stand, they assume output to - * an ordinary stdio stream. - */ - -/* - * This code is loosely based on ppmtogif from the PBMPLUS distribution - * of Feb. 1991. That file contains the following copyright notice: - * Based on GIFENCODE by David Rowley <mgardi@watdscu.waterloo.edu>. - * Lempel-Ziv compression based on "compress" by Spencer W. Thomas et al. - * Copyright (C) 1989 by Jef Poskanzer. - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose and without fee is hereby granted, provided - * that the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation. This software is provided "as is" without express or - * implied warranty. - * - * We are also required to state that - * "The Graphics Interchange Format(c) is the Copyright property of - * CompuServe Incorporated. GIF(sm) is a Service Mark property of - * CompuServe Incorporated." - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef GIF_SUPPORTED - - -/* Private version of data destination object */ - -typedef struct { - struct djpeg_dest_struct pub; /* public fields */ - - j_decompress_ptr cinfo; /* back link saves passing separate parm */ - - /* State for packing variable-width codes into a bitstream */ - int n_bits; /* current number of bits/code */ - int maxcode; /* maximum code, given n_bits */ - INT32 cur_accum; /* holds bits not yet output */ - int cur_bits; /* # of bits in cur_accum */ - - /* State for GIF code assignment */ - int ClearCode; /* clear code (doesn't change) */ - int EOFCode; /* EOF code (ditto) */ - int code_counter; /* counts output symbols */ - - /* GIF data packet construction buffer */ - int bytesinpkt; /* # of bytes in current packet */ - char packetbuf[256]; /* workspace for accumulating packet */ - -} gif_dest_struct; - -typedef gif_dest_struct * gif_dest_ptr; - -/* Largest value that will fit in N bits */ -#define MAXCODE(n_bits) ((1 << (n_bits)) - 1) - - -/* - * Routines to package finished data bytes into GIF data blocks. - * A data block consists of a count byte (1..255) and that many data bytes. - */ - -LOCAL(void) -flush_packet (gif_dest_ptr dinfo) -/* flush any accumulated data */ -{ - if (dinfo->bytesinpkt > 0) { /* never write zero-length packet */ - dinfo->packetbuf[0] = (char) dinfo->bytesinpkt++; - if (JFWRITE(dinfo->pub.output_file, dinfo->packetbuf, dinfo->bytesinpkt) - != (size_t) dinfo->bytesinpkt) - ERREXIT(dinfo->cinfo, JERR_FILE_WRITE); - dinfo->bytesinpkt = 0; - } -} - - -/* Add a character to current packet; flush to disk if necessary */ -#define CHAR_OUT(dinfo,c) \ - { (dinfo)->packetbuf[++(dinfo)->bytesinpkt] = (char) (c); \ - if ((dinfo)->bytesinpkt >= 255) \ - flush_packet(dinfo); \ - } - - -/* Routine to convert variable-width codes into a byte stream */ - -LOCAL(void) -output (gif_dest_ptr dinfo, int code) -/* Emit a code of n_bits bits */ -/* Uses cur_accum and cur_bits to reblock into 8-bit bytes */ -{ - dinfo->cur_accum |= ((INT32) code) << dinfo->cur_bits; - dinfo->cur_bits += dinfo->n_bits; - - while (dinfo->cur_bits >= 8) { - CHAR_OUT(dinfo, dinfo->cur_accum & 0xFF); - dinfo->cur_accum >>= 8; - dinfo->cur_bits -= 8; - } -} - - -/* The pseudo-compression algorithm. - * - * In this module we simply output each pixel value as a separate symbol; - * thus, no compression occurs. In fact, there is expansion of one bit per - * pixel, because we use a symbol width one bit wider than the pixel width. - * - * GIF ordinarily uses variable-width symbols, and the decoder will expect - * to ratchet up the symbol width after a fixed number of symbols. - * To simplify the logic and keep the expansion penalty down, we emit a - * GIF Clear code to reset the decoder just before the width would ratchet up. - * Thus, all the symbols in the output file will have the same bit width. - * Note that emitting the Clear codes at the right times is a mere matter of - * counting output symbols and is in no way dependent on the LZW patent. - * - * With a small basic pixel width (low color count), Clear codes will be - * needed very frequently, causing the file to expand even more. So this - * simplistic approach wouldn't work too well on bilevel images, for example. - * But for output of JPEG conversions the pixel width will usually be 8 bits - * (129 to 256 colors), so the overhead added by Clear symbols is only about - * one symbol in every 256. - */ - -LOCAL(void) -compress_init (gif_dest_ptr dinfo, int i_bits) -/* Initialize pseudo-compressor */ -{ - /* init all the state variables */ - dinfo->n_bits = i_bits; - dinfo->maxcode = MAXCODE(dinfo->n_bits); - dinfo->ClearCode = (1 << (i_bits - 1)); - dinfo->EOFCode = dinfo->ClearCode + 1; - dinfo->code_counter = dinfo->ClearCode + 2; - /* init output buffering vars */ - dinfo->bytesinpkt = 0; - dinfo->cur_accum = 0; - dinfo->cur_bits = 0; - /* GIF specifies an initial Clear code */ - output(dinfo, dinfo->ClearCode); -} - - -LOCAL(void) -compress_pixel (gif_dest_ptr dinfo, int c) -/* Accept and "compress" one pixel value. - * The given value must be less than n_bits wide. - */ -{ - /* Output the given pixel value as a symbol. */ - output(dinfo, c); - /* Issue Clear codes often enough to keep the reader from ratcheting up - * its symbol size. - */ - if (dinfo->code_counter < dinfo->maxcode) { - dinfo->code_counter++; - } else { - output(dinfo, dinfo->ClearCode); - dinfo->code_counter = dinfo->ClearCode + 2; /* reset the counter */ - } -} - - -LOCAL(void) -compress_term (gif_dest_ptr dinfo) -/* Clean up at end */ -{ - /* Send an EOF code */ - output(dinfo, dinfo->EOFCode); - /* Flush the bit-packing buffer */ - if (dinfo->cur_bits > 0) { - CHAR_OUT(dinfo, dinfo->cur_accum & 0xFF); - } - /* Flush the packet buffer */ - flush_packet(dinfo); -} - - -/* GIF header construction */ - - -LOCAL(void) -put_word (gif_dest_ptr dinfo, unsigned int w) -/* Emit a 16-bit word, LSB first */ -{ - putc(w & 0xFF, dinfo->pub.output_file); - putc((w >> 8) & 0xFF, dinfo->pub.output_file); -} - - -LOCAL(void) -put_3bytes (gif_dest_ptr dinfo, int val) -/* Emit 3 copies of same byte value --- handy subr for colormap construction */ -{ - putc(val, dinfo->pub.output_file); - putc(val, dinfo->pub.output_file); - putc(val, dinfo->pub.output_file); -} - - -LOCAL(void) -emit_header (gif_dest_ptr dinfo, int num_colors, JSAMPARRAY colormap) -/* Output the GIF file header, including color map */ -/* If colormap==NULL, synthesize a gray-scale colormap */ -{ - int BitsPerPixel, ColorMapSize, InitCodeSize, FlagByte; - int cshift = dinfo->cinfo->data_precision - 8; - int i; - - if (num_colors > 256) - ERREXIT1(dinfo->cinfo, JERR_TOO_MANY_COLORS, num_colors); - /* Compute bits/pixel and related values */ - BitsPerPixel = 1; - while (num_colors > (1 << BitsPerPixel)) - BitsPerPixel++; - ColorMapSize = 1 << BitsPerPixel; - if (BitsPerPixel <= 1) - InitCodeSize = 2; - else - InitCodeSize = BitsPerPixel; - /* - * Write the GIF header. - * Note that we generate a plain GIF87 header for maximum compatibility. - */ - putc('G', dinfo->pub.output_file); - putc('I', dinfo->pub.output_file); - putc('F', dinfo->pub.output_file); - putc('8', dinfo->pub.output_file); - putc('7', dinfo->pub.output_file); - putc('a', dinfo->pub.output_file); - /* Write the Logical Screen Descriptor */ - put_word(dinfo, (unsigned int) dinfo->cinfo->output_width); - put_word(dinfo, (unsigned int) dinfo->cinfo->output_height); - FlagByte = 0x80; /* Yes, there is a global color table */ - FlagByte |= (BitsPerPixel-1) << 4; /* color resolution */ - FlagByte |= (BitsPerPixel-1); /* size of global color table */ - putc(FlagByte, dinfo->pub.output_file); - putc(0, dinfo->pub.output_file); /* Background color index */ - putc(0, dinfo->pub.output_file); /* Reserved (aspect ratio in GIF89) */ - /* Write the Global Color Map */ - /* If the color map is more than 8 bits precision, */ - /* we reduce it to 8 bits by shifting */ - for (i=0; i < ColorMapSize; i++) { - if (i < num_colors) { - if (colormap != NULL) { - if (dinfo->cinfo->out_color_space == JCS_RGB) { - /* Normal case: RGB color map */ - putc(GETJSAMPLE(colormap[0][i]) >> cshift, dinfo->pub.output_file); - putc(GETJSAMPLE(colormap[1][i]) >> cshift, dinfo->pub.output_file); - putc(GETJSAMPLE(colormap[2][i]) >> cshift, dinfo->pub.output_file); - } else { - /* Grayscale "color map": possible if quantizing grayscale image */ - put_3bytes(dinfo, GETJSAMPLE(colormap[0][i]) >> cshift); - } - } else { - /* Create a gray-scale map of num_colors values, range 0..255 */ - put_3bytes(dinfo, (i * 255 + (num_colors-1)/2) / (num_colors-1)); - } - } else { - /* fill out the map to a power of 2 */ - put_3bytes(dinfo, 0); - } - } - /* Write image separator and Image Descriptor */ - putc(',', dinfo->pub.output_file); /* separator */ - put_word(dinfo, 0); /* left/top offset */ - put_word(dinfo, 0); - put_word(dinfo, (unsigned int) dinfo->cinfo->output_width); /* image size */ - put_word(dinfo, (unsigned int) dinfo->cinfo->output_height); - /* flag byte: not interlaced, no local color map */ - putc(0x00, dinfo->pub.output_file); - /* Write Initial Code Size byte */ - putc(InitCodeSize, dinfo->pub.output_file); - - /* Initialize for "compression" of image data */ - compress_init(dinfo, InitCodeSize+1); -} - - -/* - * Startup: write the file header. - */ - -METHODDEF(void) -start_output_gif (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - gif_dest_ptr dest = (gif_dest_ptr) dinfo; - - if (cinfo->quantize_colors) - emit_header(dest, cinfo->actual_number_of_colors, cinfo->colormap); - else - emit_header(dest, 256, (JSAMPARRAY) NULL); -} - - -/* - * Write some pixel data. - * In this module rows_supplied will always be 1. - */ - -METHODDEF(void) -put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -{ - gif_dest_ptr dest = (gif_dest_ptr) dinfo; - register JSAMPROW ptr; - register JDIMENSION col; - - ptr = dest->pub.buffer[0]; - for (col = cinfo->output_width; col > 0; col--) { - compress_pixel(dest, GETJSAMPLE(*ptr++)); - } -} - - -/* - * Finish up at the end of the file. - */ - -METHODDEF(void) -finish_output_gif (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - gif_dest_ptr dest = (gif_dest_ptr) dinfo; - - /* Flush "compression" mechanism */ - compress_term(dest); - /* Write a zero-length data block to end the series */ - putc(0, dest->pub.output_file); - /* Write the GIF terminator mark */ - putc(';', dest->pub.output_file); - /* Make sure we wrote the output file OK */ - fflush(dest->pub.output_file); - if (ferror(dest->pub.output_file)) - ERREXIT(cinfo, JERR_FILE_WRITE); -} - - -/* - * The module selection routine for GIF format output. - */ - -GLOBAL(djpeg_dest_ptr) -jinit_write_gif (j_decompress_ptr cinfo) -{ - gif_dest_ptr dest; - - /* Create module interface object, fill in method pointers */ - dest = (gif_dest_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(gif_dest_struct)); - dest->cinfo = cinfo; /* make back link for subroutines */ - dest->pub.start_output = start_output_gif; - dest->pub.put_pixel_rows = put_pixel_rows; - dest->pub.finish_output = finish_output_gif; - - if (cinfo->out_color_space != JCS_GRAYSCALE && - cinfo->out_color_space != JCS_RGB) - ERREXIT(cinfo, JERR_GIF_COLORSPACE); - - /* Force quantization if color or if > 8 bits input */ - if (cinfo->out_color_space != JCS_GRAYSCALE || cinfo->data_precision > 8) { - /* Force quantization to at most 256 colors */ - cinfo->quantize_colors = TRUE; - if (cinfo->desired_number_of_colors > 256) - cinfo->desired_number_of_colors = 256; - } - - /* Calculate output image dimensions so we can allocate space */ - jpeg_calc_output_dimensions(cinfo); - - if (cinfo->output_components != 1) /* safety check: just one component? */ - ERREXIT(cinfo, JERR_GIF_BUG); - - /* Create decompressor output buffer. */ - dest->pub.buffer = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, cinfo->output_width, (JDIMENSION) 1); - dest->pub.buffer_height = 1; - - return (djpeg_dest_ptr) dest; -} - -#endif /* GIF_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/wrjpgcom.1 b/irrlicht-1.6/source/Irrlicht/jpeglib/wrjpgcom.1 deleted file mode 100644 index 44dad355d..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/wrjpgcom.1 +++ /dev/null @@ -1,103 +0,0 @@ -.TH WRJPGCOM 1 "15 June 1995" -.SH NAME -wrjpgcom \- insert text comments into a JPEG file -.SH SYNOPSIS -.B wrjpgcom -[ -.B \-replace -] -[ -.BI \-comment " text" -] -[ -.BI \-cfile " name" -] -[ -.I filename -] -.LP -.SH DESCRIPTION -.LP -.B wrjpgcom -reads the named JPEG/JFIF file, or the standard input if no file is named, -and generates a new JPEG/JFIF file on standard output. A comment block is -added to the file. -.PP -The JPEG standard allows "comment" (COM) blocks to occur within a JPEG file. -Although the standard doesn't actually define what COM blocks are for, they -are widely used to hold user-supplied text strings. This lets you add -annotations, titles, index terms, etc to your JPEG files, and later retrieve -them as text. COM blocks do not interfere with the image stored in the JPEG -file. The maximum size of a COM block is 64K, but you can have as many of -them as you like in one JPEG file. -.PP -.B wrjpgcom -adds a COM block, containing text you provide, to a JPEG file. -Ordinarily, the COM block is added after any existing COM blocks; but you -can delete the old COM blocks if you wish. -.SH OPTIONS -Switch names may be abbreviated, and are not case sensitive. -.TP -.B \-replace -Delete any existing COM blocks from the file. -.TP -.BI \-comment " text" -Supply text for new COM block on command line. -.TP -.BI \-cfile " name" -Read text for new COM block from named file. -.PP -If you have only one line of comment text to add, you can provide it on the -command line with -.BR \-comment . -The comment text must be surrounded with quotes so that it is treated as a -single argument. Longer comments can be read from a text file. -.PP -If you give neither -.B \-comment -nor -.BR \-cfile , -then -.B wrjpgcom -will read the comment text from standard input. (In this case an input image -file name MUST be supplied, so that the source JPEG file comes from somewhere -else.) You can enter multiple lines, up to 64KB worth. Type an end-of-file -indicator (usually control-D) to terminate the comment text entry. -.PP -.B wrjpgcom -will not add a COM block if the provided comment string is empty. Therefore -\fB\-replace \-comment ""\fR can be used to delete all COM blocks from a file. -.SH EXAMPLES -.LP -Add a short comment to in.jpg, producing out.jpg: -.IP -.B wrjpgcom \-c -\fI"View of my back yard" in.jpg -.B > -.I out.jpg -.PP -Attach a long comment previously stored in comment.txt: -.IP -.B wrjpgcom -.I in.jpg -.B < -.I comment.txt -.B > -.I out.jpg -.PP -or equivalently -.IP -.B wrjpgcom -.B -cfile -.I comment.txt -.B < -.I in.jpg -.B > -.I out.jpg -.SH SEE ALSO -.BR cjpeg (1), -.BR djpeg (1), -.BR jpegtran (1), -.BR rdjpgcom (1) -.SH AUTHOR -Independent JPEG Group diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/wrjpgcom.c b/irrlicht-1.6/source/Irrlicht/jpeglib/wrjpgcom.c deleted file mode 100644 index 7d10ee66e..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/wrjpgcom.c +++ /dev/null @@ -1,583 +0,0 @@ -/* - * wrjpgcom.c - * - * Copyright (C) 1994-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a very simple stand-alone application that inserts - * user-supplied text as a COM (comment) marker in a JFIF file. - * This may be useful as an example of the minimum logic needed to parse - * JPEG markers. - */ - -#define JPEG_CJPEG_DJPEG /* to get the command-line config symbols */ -#include "jinclude.h" /* get auto-config symbols, <stdio.h> */ - -#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare malloc() */ -extern void * malloc (); -#endif -#include <ctype.h> /* to declare isupper(), tolower() */ -#ifdef USE_SETMODE -#include <fcntl.h> /* to declare setmode()'s parameter macros */ -/* If you have setmode() but not <io.h>, just delete this line: */ -#include <io.h> /* to declare setmode() */ -#endif - -#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ -#ifdef __MWERKS__ -#include <SIOUX.h> /* Metrowerks needs this */ -#include <console.h> /* ... and this */ -#endif -#ifdef THINK_C -#include <console.h> /* Think declares it here */ -#endif -#endif - -#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ -#define READ_BINARY "r" -#define WRITE_BINARY "w" -#else -#ifdef VMS /* VMS is very nonstandard */ -#define READ_BINARY "rb", "ctx=stm" -#define WRITE_BINARY "wb", "ctx=stm" -#else /* standard ANSI-compliant case */ -#define READ_BINARY "rb" -#define WRITE_BINARY "wb" -#endif -#endif - -#ifndef EXIT_FAILURE /* define exit() codes if not provided */ -#define EXIT_FAILURE 1 -#endif -#ifndef EXIT_SUCCESS -#ifdef VMS -#define EXIT_SUCCESS 1 /* VMS is very nonstandard */ -#else -#define EXIT_SUCCESS 0 -#endif -#endif - -/* Reduce this value if your malloc() can't allocate blocks up to 64K. - * On DOS, compiling in large model is usually a better solution. - */ - -#ifndef MAX_COM_LENGTH -#define MAX_COM_LENGTH 65000L /* must be <= 65533 in any case */ -#endif - - -/* - * These macros are used to read the input file and write the output file. - * To reuse this code in another application, you might need to change these. - */ - -static FILE * infile; /* input JPEG file */ - -/* Return next input byte, or EOF if no more */ -#define NEXTBYTE() getc(infile) - -static FILE * outfile; /* output JPEG file */ - -/* Emit an output byte */ -#define PUTBYTE(x) putc((x), outfile) - - -/* Error exit handler */ -#define ERREXIT(msg) (fprintf(stderr, "%s\n", msg), exit(EXIT_FAILURE)) - - -/* Read one byte, testing for EOF */ -static int -read_1_byte (void) -{ - int c; - - c = NEXTBYTE(); - if (c == EOF) - ERREXIT("Premature EOF in JPEG file"); - return c; -} - -/* Read 2 bytes, convert to unsigned int */ -/* All 2-byte quantities in JPEG markers are MSB first */ -static unsigned int -read_2_bytes (void) -{ - int c1, c2; - - c1 = NEXTBYTE(); - if (c1 == EOF) - ERREXIT("Premature EOF in JPEG file"); - c2 = NEXTBYTE(); - if (c2 == EOF) - ERREXIT("Premature EOF in JPEG file"); - return (((unsigned int) c1) << 8) + ((unsigned int) c2); -} - - -/* Routines to write data to output file */ - -static void -write_1_byte (int c) -{ - PUTBYTE(c); -} - -static void -write_2_bytes (unsigned int val) -{ - PUTBYTE((val >> 8) & 0xFF); - PUTBYTE(val & 0xFF); -} - -static void -write_marker (int marker) -{ - PUTBYTE(0xFF); - PUTBYTE(marker); -} - -static void -copy_rest_of_file (void) -{ - int c; - - while ((c = NEXTBYTE()) != EOF) - PUTBYTE(c); -} - - -/* - * JPEG markers consist of one or more 0xFF bytes, followed by a marker - * code byte (which is not an FF). Here are the marker codes of interest - * in this program. (See jdmarker.c for a more complete list.) - */ - -#define M_SOF0 0xC0 /* Start Of Frame N */ -#define M_SOF1 0xC1 /* N indicates which compression process */ -#define M_SOF2 0xC2 /* Only SOF0-SOF2 are now in common use */ -#define M_SOF3 0xC3 -#define M_SOF5 0xC5 /* NB: codes C4 and CC are NOT SOF markers */ -#define M_SOF6 0xC6 -#define M_SOF7 0xC7 -#define M_SOF9 0xC9 -#define M_SOF10 0xCA -#define M_SOF11 0xCB -#define M_SOF13 0xCD -#define M_SOF14 0xCE -#define M_SOF15 0xCF -#define M_SOI 0xD8 /* Start Of Image (beginning of datastream) */ -#define M_EOI 0xD9 /* End Of Image (end of datastream) */ -#define M_SOS 0xDA /* Start Of Scan (begins compressed data) */ -#define M_COM 0xFE /* COMment */ - - -/* - * Find the next JPEG marker and return its marker code. - * We expect at least one FF byte, possibly more if the compressor used FFs - * to pad the file. (Padding FFs will NOT be replicated in the output file.) - * There could also be non-FF garbage between markers. The treatment of such - * garbage is unspecified; we choose to skip over it but emit a warning msg. - * NB: this routine must not be used after seeing SOS marker, since it will - * not deal correctly with FF/00 sequences in the compressed image data... - */ - -static int -next_marker (void) -{ - int c; - int discarded_bytes = 0; - - /* Find 0xFF byte; count and skip any non-FFs. */ - c = read_1_byte(); - while (c != 0xFF) { - discarded_bytes++; - c = read_1_byte(); - } - /* Get marker code byte, swallowing any duplicate FF bytes. Extra FFs - * are legal as pad bytes, so don't count them in discarded_bytes. - */ - do { - c = read_1_byte(); - } while (c == 0xFF); - - if (discarded_bytes != 0) { - fprintf(stderr, "Warning: garbage data found in JPEG file\n"); - } - - return c; -} - - -/* - * Read the initial marker, which should be SOI. - * For a JFIF file, the first two bytes of the file should be literally - * 0xFF M_SOI. To be more general, we could use next_marker, but if the - * input file weren't actually JPEG at all, next_marker might read the whole - * file and then return a misleading error message... - */ - -static int -first_marker (void) -{ - int c1, c2; - - c1 = NEXTBYTE(); - c2 = NEXTBYTE(); - if (c1 != 0xFF || c2 != M_SOI) - ERREXIT("Not a JPEG file"); - return c2; -} - - -/* - * Most types of marker are followed by a variable-length parameter segment. - * This routine skips over the parameters for any marker we don't otherwise - * want to process. - * Note that we MUST skip the parameter segment explicitly in order not to - * be fooled by 0xFF bytes that might appear within the parameter segment; - * such bytes do NOT introduce new markers. - */ - -static void -copy_variable (void) -/* Copy an unknown or uninteresting variable-length marker */ -{ - unsigned int length; - - /* Get the marker parameter length count */ - length = read_2_bytes(); - write_2_bytes(length); - /* Length includes itself, so must be at least 2 */ - if (length < 2) - ERREXIT("Erroneous JPEG marker length"); - length -= 2; - /* Skip over the remaining bytes */ - while (length > 0) { - write_1_byte(read_1_byte()); - length--; - } -} - -static void -skip_variable (void) -/* Skip over an unknown or uninteresting variable-length marker */ -{ - unsigned int length; - - /* Get the marker parameter length count */ - length = read_2_bytes(); - /* Length includes itself, so must be at least 2 */ - if (length < 2) - ERREXIT("Erroneous JPEG marker length"); - length -= 2; - /* Skip over the remaining bytes */ - while (length > 0) { - (void) read_1_byte(); - length--; - } -} - - -/* - * Parse the marker stream until SOFn or EOI is seen; - * copy data to output, but discard COM markers unless keep_COM is true. - */ - -static int -scan_JPEG_header (int keep_COM) -{ - int marker; - - /* Expect SOI at start of file */ - if (first_marker() != M_SOI) - ERREXIT("Expected SOI marker first"); - write_marker(M_SOI); - - /* Scan miscellaneous markers until we reach SOFn. */ - for (;;) { - marker = next_marker(); - switch (marker) { - /* Note that marker codes 0xC4, 0xC8, 0xCC are not, and must not be, - * treated as SOFn. C4 in particular is actually DHT. - */ - case M_SOF0: /* Baseline */ - case M_SOF1: /* Extended sequential, Huffman */ - case M_SOF2: /* Progressive, Huffman */ - case M_SOF3: /* Lossless, Huffman */ - case M_SOF5: /* Differential sequential, Huffman */ - case M_SOF6: /* Differential progressive, Huffman */ - case M_SOF7: /* Differential lossless, Huffman */ - case M_SOF9: /* Extended sequential, arithmetic */ - case M_SOF10: /* Progressive, arithmetic */ - case M_SOF11: /* Lossless, arithmetic */ - case M_SOF13: /* Differential sequential, arithmetic */ - case M_SOF14: /* Differential progressive, arithmetic */ - case M_SOF15: /* Differential lossless, arithmetic */ - return marker; - - case M_SOS: /* should not see compressed data before SOF */ - ERREXIT("SOS without prior SOFn"); - break; - - case M_EOI: /* in case it's a tables-only JPEG stream */ - return marker; - - case M_COM: /* Existing COM: conditionally discard */ - if (keep_COM) { - write_marker(marker); - copy_variable(); - } else { - skip_variable(); - } - break; - - default: /* Anything else just gets copied */ - write_marker(marker); - copy_variable(); /* we assume it has a parameter count... */ - break; - } - } /* end loop */ -} - - -/* Command line parsing code */ - -static const char * progname; /* program name for error messages */ - - -static void -usage (void) -/* complain about bad command line */ -{ - fprintf(stderr, "wrjpgcom inserts a textual comment in a JPEG file.\n"); - fprintf(stderr, "You can add to or replace any existing comment(s).\n"); - - fprintf(stderr, "Usage: %s [switches] ", progname); -#ifdef TWO_FILE_COMMANDLINE - fprintf(stderr, "inputfile outputfile\n"); -#else - fprintf(stderr, "[inputfile]\n"); -#endif - - fprintf(stderr, "Switches (names may be abbreviated):\n"); - fprintf(stderr, " -replace Delete any existing comments\n"); - fprintf(stderr, " -comment \"text\" Insert comment with given text\n"); - fprintf(stderr, " -cfile name Read comment from named file\n"); - fprintf(stderr, "Notice that you must put quotes around the comment text\n"); - fprintf(stderr, "when you use -comment.\n"); - fprintf(stderr, "If you do not give either -comment or -cfile on the command line,\n"); - fprintf(stderr, "then the comment text is read from standard input.\n"); - fprintf(stderr, "It can be multiple lines, up to %u characters total.\n", - (unsigned int) MAX_COM_LENGTH); -#ifndef TWO_FILE_COMMANDLINE - fprintf(stderr, "You must specify an input JPEG file name when supplying\n"); - fprintf(stderr, "comment text from standard input.\n"); -#endif - - exit(EXIT_FAILURE); -} - - -static int -keymatch (char * arg, const char * keyword, int minchars) -/* Case-insensitive matching of (possibly abbreviated) keyword switches. */ -/* keyword is the constant keyword (must be lower case already), */ -/* minchars is length of minimum legal abbreviation. */ -{ - register int ca, ck; - register int nmatched = 0; - - while ((ca = *arg++) != '\0') { - if ((ck = *keyword++) == '\0') - return 0; /* arg longer than keyword, no good */ - if (isupper(ca)) /* force arg to lcase (assume ck is already) */ - ca = tolower(ca); - if (ca != ck) - return 0; /* no good */ - nmatched++; /* count matched characters */ - } - /* reached end of argument; fail if it's too short for unique abbrev */ - if (nmatched < minchars) - return 0; - return 1; /* A-OK */ -} - - -/* - * The main program. - */ - -int -main (int argc, char **argv) -{ - int argn; - char * arg; - int keep_COM = 1; - char * comment_arg = NULL; - FILE * comment_file = NULL; - unsigned int comment_length = 0; - int marker; - - /* On Mac, fetch a command line. */ -#ifdef USE_CCOMMAND - argc = ccommand(&argv); -#endif - - progname = argv[0]; - if (progname == NULL || progname[0] == 0) - progname = "wrjpgcom"; /* in case C library doesn't provide it */ - - /* Parse switches, if any */ - for (argn = 1; argn < argc; argn++) { - arg = argv[argn]; - if (arg[0] != '-') - break; /* not switch, must be file name */ - arg++; /* advance over '-' */ - if (keymatch(arg, "replace", 1)) { - keep_COM = 0; - } else if (keymatch(arg, "cfile", 2)) { - if (++argn >= argc) usage(); - if ((comment_file = fopen(argv[argn], "r")) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]); - exit(EXIT_FAILURE); - } - } else if (keymatch(arg, "comment", 1)) { - if (++argn >= argc) usage(); - comment_arg = argv[argn]; - /* If the comment text starts with '"', then we are probably running - * under MS-DOG and must parse out the quoted string ourselves. Sigh. - */ - if (comment_arg[0] == '"') { - comment_arg = (char *) malloc((size_t) MAX_COM_LENGTH); - if (comment_arg == NULL) - ERREXIT("Insufficient memory"); - strcpy(comment_arg, argv[argn]+1); - for (;;) { - comment_length = (unsigned int) strlen(comment_arg); - if (comment_length > 0 && comment_arg[comment_length-1] == '"') { - comment_arg[comment_length-1] = '\0'; /* zap terminating quote */ - break; - } - if (++argn >= argc) - ERREXIT("Missing ending quote mark"); - strcat(comment_arg, " "); - strcat(comment_arg, argv[argn]); - } - } - comment_length = (unsigned int) strlen(comment_arg); - } else - usage(); - } - - /* Cannot use both -comment and -cfile. */ - if (comment_arg != NULL && comment_file != NULL) - usage(); - /* If there is neither -comment nor -cfile, we will read the comment text - * from stdin; in this case there MUST be an input JPEG file name. - */ - if (comment_arg == NULL && comment_file == NULL && argn >= argc) - usage(); - - /* Open the input file. */ - if (argn < argc) { - if ((infile = fopen(argv[argn], READ_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]); - exit(EXIT_FAILURE); - } - } else { - /* default input file is stdin */ -#ifdef USE_SETMODE /* need to hack file mode? */ - setmode(fileno(stdin), O_BINARY); -#endif -#ifdef USE_FDOPEN /* need to re-open in binary mode? */ - if ((infile = fdopen(fileno(stdin), READ_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open stdin\n", progname); - exit(EXIT_FAILURE); - } -#else - infile = stdin; -#endif - } - - /* Open the output file. */ -#ifdef TWO_FILE_COMMANDLINE - /* Must have explicit output file name */ - if (argn != argc-2) { - fprintf(stderr, "%s: must name one input and one output file\n", - progname); - usage(); - } - if ((outfile = fopen(argv[argn+1], WRITE_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, argv[argn+1]); - exit(EXIT_FAILURE); - } -#else - /* Unix style: expect zero or one file name */ - if (argn < argc-1) { - fprintf(stderr, "%s: only one input file\n", progname); - usage(); - } - /* default output file is stdout */ -#ifdef USE_SETMODE /* need to hack file mode? */ - setmode(fileno(stdout), O_BINARY); -#endif -#ifdef USE_FDOPEN /* need to re-open in binary mode? */ - if ((outfile = fdopen(fileno(stdout), WRITE_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open stdout\n", progname); - exit(EXIT_FAILURE); - } -#else - outfile = stdout; -#endif -#endif /* TWO_FILE_COMMANDLINE */ - - /* Collect comment text from comment_file or stdin, if necessary */ - if (comment_arg == NULL) { - FILE * src_file; - int c; - - comment_arg = (char *) malloc((size_t) MAX_COM_LENGTH); - if (comment_arg == NULL) - ERREXIT("Insufficient memory"); - comment_length = 0; - src_file = (comment_file != NULL ? comment_file : stdin); - while ((c = getc(src_file)) != EOF) { - if (comment_length >= (unsigned int) MAX_COM_LENGTH) { - fprintf(stderr, "Comment text may not exceed %u bytes\n", - (unsigned int) MAX_COM_LENGTH); - exit(EXIT_FAILURE); - } - comment_arg[comment_length++] = (char) c; - } - if (comment_file != NULL) - fclose(comment_file); - } - - /* Copy JPEG headers until SOFn marker; - * we will insert the new comment marker just before SOFn. - * This (a) causes the new comment to appear after, rather than before, - * existing comments; and (b) ensures that comments come after any JFIF - * or JFXX markers, as required by the JFIF specification. - */ - marker = scan_JPEG_header(keep_COM); - /* Insert the new COM marker, but only if nonempty text has been supplied */ - if (comment_length > 0) { - write_marker(M_COM); - write_2_bytes(comment_length + 2); - while (comment_length > 0) { - write_1_byte(*comment_arg++); - comment_length--; - } - } - /* Duplicate the remainder of the source file. - * Note that any COM markers occuring after SOF will not be touched. - */ - write_marker(marker); - copy_rest_of_file(); - - /* All done. */ - exit(EXIT_SUCCESS); - return 0; /* suppress no-return-value warnings */ -} diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/wrppm.c b/irrlicht-1.6/source/Irrlicht/jpeglib/wrppm.c deleted file mode 100644 index cfd416022..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/wrppm.c +++ /dev/null @@ -1,268 +0,0 @@ -/* - * wrppm.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to write output images in PPM/PGM format. - * The extended 2-byte-per-sample raw PPM/PGM formats are supported. - * The PBMPLUS library is NOT required to compile this software - * (but it is highly useful as a set of PPM image manipulation programs). - * - * These routines may need modification for non-Unix environments or - * specialized applications. As they stand, they assume output to - * an ordinary stdio stream. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef PPM_SUPPORTED - - -/* - * For 12-bit JPEG data, we either downscale the values to 8 bits - * (to write standard byte-per-sample PPM/PGM files), or output - * nonstandard word-per-sample PPM/PGM files. Downscaling is done - * if PPM_NORAWWORD is defined (this can be done in the Makefile - * or in jconfig.h). - * (When the core library supports data precision reduction, a cleaner - * implementation will be to ask for that instead.) - */ - -#if BITS_IN_JSAMPLE == 8 -#define PUTPPMSAMPLE(ptr,v) *ptr++ = (char) (v) -#define BYTESPERSAMPLE 1 -#define PPM_MAXVAL 255 -#else -#ifdef PPM_NORAWWORD -#define PUTPPMSAMPLE(ptr,v) *ptr++ = (char) ((v) >> (BITS_IN_JSAMPLE-8)) -#define BYTESPERSAMPLE 1 -#define PPM_MAXVAL 255 -#else -/* The word-per-sample format always puts the LSB first. */ -#define PUTPPMSAMPLE(ptr,v) \ - { register int val_ = v; \ - *ptr++ = (char) (val_ & 0xFF); \ - *ptr++ = (char) ((val_ >> 8) & 0xFF); \ - } -#define BYTESPERSAMPLE 2 -#define PPM_MAXVAL ((1<<BITS_IN_JSAMPLE)-1) -#endif -#endif - - -/* - * When JSAMPLE is the same size as char, we can just fwrite() the - * decompressed data to the PPM or PGM file. On PCs, in order to make this - * work the output buffer must be allocated in near data space, because we are - * assuming small-data memory model wherein fwrite() can't reach far memory. - * If you need to process very wide images on a PC, you might have to compile - * in large-memory model, or else replace fwrite() with a putc() loop --- - * which will be much slower. - */ - - -/* Private version of data destination object */ - -typedef struct { - struct djpeg_dest_struct pub; /* public fields */ - - /* Usually these two pointers point to the same place: */ - char *iobuffer; /* fwrite's I/O buffer */ - JSAMPROW pixrow; /* decompressor output buffer */ - size_t buffer_width; /* width of I/O buffer */ - JDIMENSION samples_per_row; /* JSAMPLEs per output row */ -} ppm_dest_struct; - -typedef ppm_dest_struct * ppm_dest_ptr; - - -/* - * Write some pixel data. - * In this module rows_supplied will always be 1. - * - * put_pixel_rows handles the "normal" 8-bit case where the decompressor - * output buffer is physically the same as the fwrite buffer. - */ - -METHODDEF(void) -put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -{ - ppm_dest_ptr dest = (ppm_dest_ptr) dinfo; - - (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); -} - - -/* - * This code is used when we have to copy the data and apply a pixel - * format translation. Typically this only happens in 12-bit mode. - */ - -METHODDEF(void) -copy_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -{ - ppm_dest_ptr dest = (ppm_dest_ptr) dinfo; - register char * bufferptr; - register JSAMPROW ptr; - register JDIMENSION col; - - ptr = dest->pub.buffer[0]; - bufferptr = dest->iobuffer; - for (col = dest->samples_per_row; col > 0; col--) { - PUTPPMSAMPLE(bufferptr, GETJSAMPLE(*ptr++)); - } - (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); -} - - -/* - * Write some pixel data when color quantization is in effect. - * We have to demap the color index values to straight data. - */ - -METHODDEF(void) -put_demapped_rgb (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -{ - ppm_dest_ptr dest = (ppm_dest_ptr) dinfo; - register char * bufferptr; - register int pixval; - register JSAMPROW ptr; - register JSAMPROW color_map0 = cinfo->colormap[0]; - register JSAMPROW color_map1 = cinfo->colormap[1]; - register JSAMPROW color_map2 = cinfo->colormap[2]; - register JDIMENSION col; - - ptr = dest->pub.buffer[0]; - bufferptr = dest->iobuffer; - for (col = cinfo->output_width; col > 0; col--) { - pixval = GETJSAMPLE(*ptr++); - PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map0[pixval])); - PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map1[pixval])); - PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map2[pixval])); - } - (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); -} - - -METHODDEF(void) -put_demapped_gray (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -{ - ppm_dest_ptr dest = (ppm_dest_ptr) dinfo; - register char * bufferptr; - register JSAMPROW ptr; - register JSAMPROW color_map = cinfo->colormap[0]; - register JDIMENSION col; - - ptr = dest->pub.buffer[0]; - bufferptr = dest->iobuffer; - for (col = cinfo->output_width; col > 0; col--) { - PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map[GETJSAMPLE(*ptr++)])); - } - (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); -} - - -/* - * Startup: write the file header. - */ - -METHODDEF(void) -start_output_ppm (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - ppm_dest_ptr dest = (ppm_dest_ptr) dinfo; - - /* Emit file header */ - switch (cinfo->out_color_space) { - case JCS_GRAYSCALE: - /* emit header for raw PGM format */ - fprintf(dest->pub.output_file, "P5\n%ld %ld\n%d\n", - (long) cinfo->output_width, (long) cinfo->output_height, - PPM_MAXVAL); - break; - case JCS_RGB: - /* emit header for raw PPM format */ - fprintf(dest->pub.output_file, "P6\n%ld %ld\n%d\n", - (long) cinfo->output_width, (long) cinfo->output_height, - PPM_MAXVAL); - break; - default: - ERREXIT(cinfo, JERR_PPM_COLORSPACE); - } -} - - -/* - * Finish up at the end of the file. - */ - -METHODDEF(void) -finish_output_ppm (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - /* Make sure we wrote the output file OK */ - fflush(dinfo->output_file); - if (ferror(dinfo->output_file)) - ERREXIT(cinfo, JERR_FILE_WRITE); -} - - -/* - * The module selection routine for PPM format output. - */ - -GLOBAL(djpeg_dest_ptr) -jinit_write_ppm (j_decompress_ptr cinfo) -{ - ppm_dest_ptr dest; - - /* Create module interface object, fill in method pointers */ - dest = (ppm_dest_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(ppm_dest_struct)); - dest->pub.start_output = start_output_ppm; - dest->pub.finish_output = finish_output_ppm; - - /* Calculate output image dimensions so we can allocate space */ - jpeg_calc_output_dimensions(cinfo); - - /* Create physical I/O buffer. Note we make this near on a PC. */ - dest->samples_per_row = cinfo->output_width * cinfo->out_color_components; - dest->buffer_width = dest->samples_per_row * (BYTESPERSAMPLE * SIZEOF(char)); - dest->iobuffer = (char *) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, dest->buffer_width); - - if (cinfo->quantize_colors || BITS_IN_JSAMPLE != 8 || - SIZEOF(JSAMPLE) != SIZEOF(char)) { - /* When quantizing, we need an output buffer for colormap indexes - * that's separate from the physical I/O buffer. We also need a - * separate buffer if pixel format translation must take place. - */ - dest->pub.buffer = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - cinfo->output_width * cinfo->output_components, (JDIMENSION) 1); - dest->pub.buffer_height = 1; - if (! cinfo->quantize_colors) - dest->pub.put_pixel_rows = copy_pixel_rows; - else if (cinfo->out_color_space == JCS_GRAYSCALE) - dest->pub.put_pixel_rows = put_demapped_gray; - else - dest->pub.put_pixel_rows = put_demapped_rgb; - } else { - /* We will fwrite() directly from decompressor output buffer. */ - /* Synthesize a JSAMPARRAY pointer structure */ - /* Cast here implies near->far pointer conversion on PCs */ - dest->pixrow = (JSAMPROW) dest->iobuffer; - dest->pub.buffer = & dest->pixrow; - dest->pub.buffer_height = 1; - dest->pub.put_pixel_rows = put_pixel_rows; - } - - return (djpeg_dest_ptr) dest; -} - -#endif /* PPM_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/wrrle.c b/irrlicht-1.6/source/Irrlicht/jpeglib/wrrle.c deleted file mode 100644 index 7a00c0dd1..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/wrrle.c +++ /dev/null @@ -1,305 +0,0 @@ -/* - * wrrle.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to write output images in RLE format. - * The Utah Raster Toolkit library is required (version 3.1 or later). - * - * These routines may need modification for non-Unix environments or - * specialized applications. As they stand, they assume output to - * an ordinary stdio stream. - * - * Based on code contributed by Mike Lijewski, - * with updates from Robert Hutchinson. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef RLE_SUPPORTED - -/* rle.h is provided by the Utah Raster Toolkit. */ - -#include <rle.h> - -/* - * We assume that JSAMPLE has the same representation as rle_pixel, - * to wit, "unsigned char". Hence we can't cope with 12- or 16-bit samples. - */ - -#if BITS_IN_JSAMPLE != 8 - Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */ -#endif - - -/* - * Since RLE stores scanlines bottom-to-top, we have to invert the image - * from JPEG's top-to-bottom order. To do this, we save the outgoing data - * in a virtual array during put_pixel_row calls, then actually emit the - * RLE file during finish_output. - */ - - -/* - * For now, if we emit an RLE color map then it is always 256 entries long, - * though not all of the entries need be used. - */ - -#define CMAPBITS 8 -#define CMAPLENGTH (1<<(CMAPBITS)) - -typedef struct { - struct djpeg_dest_struct pub; /* public fields */ - - jvirt_sarray_ptr image; /* virtual array to store the output image */ - rle_map *colormap; /* RLE-style color map, or NULL if none */ - rle_pixel **rle_row; /* To pass rows to rle_putrow() */ - -} rle_dest_struct; - -typedef rle_dest_struct * rle_dest_ptr; - -/* Forward declarations */ -METHODDEF(void) rle_put_pixel_rows - JPP((j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied)); - - -/* - * Write the file header. - * - * In this module it's easier to wait till finish_output to write anything. - */ - -METHODDEF(void) -start_output_rle (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - rle_dest_ptr dest = (rle_dest_ptr) dinfo; - size_t cmapsize; - int i, ci; -#ifdef PROGRESS_REPORT - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; -#endif - - /* - * Make sure the image can be stored in RLE format. - * - * - RLE stores image dimensions as *signed* 16 bit integers. JPEG - * uses unsigned, so we have to check the width. - * - * - Colorspace is expected to be grayscale or RGB. - * - * - The number of channels (components) is expected to be 1 (grayscale/ - * pseudocolor) or 3 (truecolor/directcolor). - * (could be 2 or 4 if using an alpha channel, but we aren't) - */ - - if (cinfo->output_width > 32767 || cinfo->output_height > 32767) - ERREXIT2(cinfo, JERR_RLE_DIMENSIONS, cinfo->output_width, - cinfo->output_height); - - if (cinfo->out_color_space != JCS_GRAYSCALE && - cinfo->out_color_space != JCS_RGB) - ERREXIT(cinfo, JERR_RLE_COLORSPACE); - - if (cinfo->output_components != 1 && cinfo->output_components != 3) - ERREXIT1(cinfo, JERR_RLE_TOOMANYCHANNELS, cinfo->num_components); - - /* Convert colormap, if any, to RLE format. */ - - dest->colormap = NULL; - - if (cinfo->quantize_colors) { - /* Allocate storage for RLE-style cmap, zero any extra entries */ - cmapsize = cinfo->out_color_components * CMAPLENGTH * SIZEOF(rle_map); - dest->colormap = (rle_map *) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, cmapsize); - MEMZERO(dest->colormap, cmapsize); - - /* Save away data in RLE format --- note 8-bit left shift! */ - /* Shifting would need adjustment for JSAMPLEs wider than 8 bits. */ - for (ci = 0; ci < cinfo->out_color_components; ci++) { - for (i = 0; i < cinfo->actual_number_of_colors; i++) { - dest->colormap[ci * CMAPLENGTH + i] = - GETJSAMPLE(cinfo->colormap[ci][i]) << 8; - } - } - } - - /* Set the output buffer to the first row */ - dest->pub.buffer = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, dest->image, (JDIMENSION) 0, (JDIMENSION) 1, TRUE); - dest->pub.buffer_height = 1; - - dest->pub.put_pixel_rows = rle_put_pixel_rows; - -#ifdef PROGRESS_REPORT - if (progress != NULL) { - progress->total_extra_passes++; /* count file writing as separate pass */ - } -#endif -} - - -/* - * Write some pixel data. - * - * This routine just saves the data away in a virtual array. - */ - -METHODDEF(void) -rle_put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -{ - rle_dest_ptr dest = (rle_dest_ptr) dinfo; - - if (cinfo->output_scanline < cinfo->output_height) { - dest->pub.buffer = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, dest->image, - cinfo->output_scanline, (JDIMENSION) 1, TRUE); - } -} - -/* - * Finish up at the end of the file. - * - * Here is where we really output the RLE file. - */ - -METHODDEF(void) -finish_output_rle (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - rle_dest_ptr dest = (rle_dest_ptr) dinfo; - rle_hdr header; /* Output file information */ - rle_pixel **rle_row, *red, *green, *blue; - JSAMPROW output_row; - char cmapcomment[80]; - int row, col; - int ci; -#ifdef PROGRESS_REPORT - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; -#endif - - /* Initialize the header info */ - header = *rle_hdr_init(NULL); - header.rle_file = dest->pub.output_file; - header.xmin = 0; - header.xmax = cinfo->output_width - 1; - header.ymin = 0; - header.ymax = cinfo->output_height - 1; - header.alpha = 0; - header.ncolors = cinfo->output_components; - for (ci = 0; ci < cinfo->output_components; ci++) { - RLE_SET_BIT(header, ci); - } - if (cinfo->quantize_colors) { - header.ncmap = cinfo->out_color_components; - header.cmaplen = CMAPBITS; - header.cmap = dest->colormap; - /* Add a comment to the output image with the true colormap length. */ - sprintf(cmapcomment, "color_map_length=%d", cinfo->actual_number_of_colors); - rle_putcom(cmapcomment, &header); - } - - /* Emit the RLE header and color map (if any) */ - rle_put_setup(&header); - - /* Now output the RLE data from our virtual array. - * We assume here that (a) rle_pixel is represented the same as JSAMPLE, - * and (b) we are not on a machine where FAR pointers differ from regular. - */ - -#ifdef PROGRESS_REPORT - if (progress != NULL) { - progress->pub.pass_limit = cinfo->output_height; - progress->pub.pass_counter = 0; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } -#endif - - if (cinfo->output_components == 1) { - for (row = cinfo->output_height-1; row >= 0; row--) { - rle_row = (rle_pixel **) (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, dest->image, - (JDIMENSION) row, (JDIMENSION) 1, FALSE); - rle_putrow(rle_row, (int) cinfo->output_width, &header); -#ifdef PROGRESS_REPORT - if (progress != NULL) { - progress->pub.pass_counter++; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } -#endif - } - } else { - for (row = cinfo->output_height-1; row >= 0; row--) { - rle_row = (rle_pixel **) dest->rle_row; - output_row = * (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, dest->image, - (JDIMENSION) row, (JDIMENSION) 1, FALSE); - red = rle_row[0]; - green = rle_row[1]; - blue = rle_row[2]; - for (col = cinfo->output_width; col > 0; col--) { - *red++ = GETJSAMPLE(*output_row++); - *green++ = GETJSAMPLE(*output_row++); - *blue++ = GETJSAMPLE(*output_row++); - } - rle_putrow(rle_row, (int) cinfo->output_width, &header); -#ifdef PROGRESS_REPORT - if (progress != NULL) { - progress->pub.pass_counter++; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } -#endif - } - } - -#ifdef PROGRESS_REPORT - if (progress != NULL) - progress->completed_extra_passes++; -#endif - - /* Emit file trailer */ - rle_puteof(&header); - fflush(dest->pub.output_file); - if (ferror(dest->pub.output_file)) - ERREXIT(cinfo, JERR_FILE_WRITE); -} - - -/* - * The module selection routine for RLE format output. - */ - -GLOBAL(djpeg_dest_ptr) -jinit_write_rle (j_decompress_ptr cinfo) -{ - rle_dest_ptr dest; - - /* Create module interface object, fill in method pointers */ - dest = (rle_dest_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(rle_dest_struct)); - dest->pub.start_output = start_output_rle; - dest->pub.finish_output = finish_output_rle; - - /* Calculate output image dimensions so we can allocate space */ - jpeg_calc_output_dimensions(cinfo); - - /* Allocate a work array for output to the RLE library. */ - dest->rle_row = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - cinfo->output_width, (JDIMENSION) cinfo->output_components); - - /* Allocate a virtual array to hold the image. */ - dest->image = (*cinfo->mem->request_virt_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, - (JDIMENSION) (cinfo->output_width * cinfo->output_components), - cinfo->output_height, (JDIMENSION) 1); - - return (djpeg_dest_ptr) dest; -} - -#endif /* RLE_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/jpeglib/wrtarga.c b/irrlicht-1.6/source/Irrlicht/jpeglib/wrtarga.c deleted file mode 100644 index 65662738d..000000000 --- a/irrlicht-1.6/source/Irrlicht/jpeglib/wrtarga.c +++ /dev/null @@ -1,253 +0,0 @@ -/* - * wrtarga.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to write output images in Targa format. - * - * These routines may need modification for non-Unix environments or - * specialized applications. As they stand, they assume output to - * an ordinary stdio stream. - * - * Based on code contributed by Lee Daniel Crocker. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef TARGA_SUPPORTED - - -/* - * To support 12-bit JPEG data, we'd have to scale output down to 8 bits. - * This is not yet implemented. - */ - -#if BITS_IN_JSAMPLE != 8 - Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */ -#endif - -/* - * The output buffer needs to be writable by fwrite(). On PCs, we must - * allocate the buffer in near data space, because we are assuming small-data - * memory model, wherein fwrite() can't reach far memory. If you need to - * process very wide images on a PC, you might have to compile in large-memory - * model, or else replace fwrite() with a putc() loop --- which will be much - * slower. - */ - - -/* Private version of data destination object */ - -typedef struct { - struct djpeg_dest_struct pub; /* public fields */ - - char *iobuffer; /* physical I/O buffer */ - JDIMENSION buffer_width; /* width of one row */ -} tga_dest_struct; - -typedef tga_dest_struct * tga_dest_ptr; - - -LOCAL(void) -write_header (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, int num_colors) -/* Create and write a Targa header */ -{ - char targaheader[18]; - - /* Set unused fields of header to 0 */ - MEMZERO(targaheader, SIZEOF(targaheader)); - - if (num_colors > 0) { - targaheader[1] = 1; /* color map type 1 */ - targaheader[5] = (char) (num_colors & 0xFF); - targaheader[6] = (char) (num_colors >> 8); - targaheader[7] = 24; /* 24 bits per cmap entry */ - } - - targaheader[12] = (char) (cinfo->output_width & 0xFF); - targaheader[13] = (char) (cinfo->output_width >> 8); - targaheader[14] = (char) (cinfo->output_height & 0xFF); - targaheader[15] = (char) (cinfo->output_height >> 8); - targaheader[17] = 0x20; /* Top-down, non-interlaced */ - - if (cinfo->out_color_space == JCS_GRAYSCALE) { - targaheader[2] = 3; /* image type = uncompressed gray-scale */ - targaheader[16] = 8; /* bits per pixel */ - } else { /* must be RGB */ - if (num_colors > 0) { - targaheader[2] = 1; /* image type = colormapped RGB */ - targaheader[16] = 8; - } else { - targaheader[2] = 2; /* image type = uncompressed RGB */ - targaheader[16] = 24; - } - } - - if (JFWRITE(dinfo->output_file, targaheader, 18) != (size_t) 18) - ERREXIT(cinfo, JERR_FILE_WRITE); -} - - -/* - * Write some pixel data. - * In this module rows_supplied will always be 1. - */ - -METHODDEF(void) -put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -/* used for unquantized full-color output */ -{ - tga_dest_ptr dest = (tga_dest_ptr) dinfo; - register JSAMPROW inptr; - register char * outptr; - register JDIMENSION col; - - inptr = dest->pub.buffer[0]; - outptr = dest->iobuffer; - for (col = cinfo->output_width; col > 0; col--) { - outptr[0] = (char) GETJSAMPLE(inptr[2]); /* RGB to BGR order */ - outptr[1] = (char) GETJSAMPLE(inptr[1]); - outptr[2] = (char) GETJSAMPLE(inptr[0]); - inptr += 3, outptr += 3; - } - (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); -} - -METHODDEF(void) -put_gray_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -/* used for grayscale OR quantized color output */ -{ - tga_dest_ptr dest = (tga_dest_ptr) dinfo; - register JSAMPROW inptr; - register char * outptr; - register JDIMENSION col; - - inptr = dest->pub.buffer[0]; - outptr = dest->iobuffer; - for (col = cinfo->output_width; col > 0; col--) { - *outptr++ = (char) GETJSAMPLE(*inptr++); - } - (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); -} - - -/* - * Write some demapped pixel data when color quantization is in effect. - * For Targa, this is only applied to grayscale data. - */ - -METHODDEF(void) -put_demapped_gray (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -{ - tga_dest_ptr dest = (tga_dest_ptr) dinfo; - register JSAMPROW inptr; - register char * outptr; - register JSAMPROW color_map0 = cinfo->colormap[0]; - register JDIMENSION col; - - inptr = dest->pub.buffer[0]; - outptr = dest->iobuffer; - for (col = cinfo->output_width; col > 0; col--) { - *outptr++ = (char) GETJSAMPLE(color_map0[GETJSAMPLE(*inptr++)]); - } - (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); -} - - -/* - * Startup: write the file header. - */ - -METHODDEF(void) -start_output_tga (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - tga_dest_ptr dest = (tga_dest_ptr) dinfo; - int num_colors, i; - FILE *outfile; - - if (cinfo->out_color_space == JCS_GRAYSCALE) { - /* Targa doesn't have a mapped grayscale format, so we will */ - /* demap quantized gray output. Never emit a colormap. */ - write_header(cinfo, dinfo, 0); - if (cinfo->quantize_colors) - dest->pub.put_pixel_rows = put_demapped_gray; - else - dest->pub.put_pixel_rows = put_gray_rows; - } else if (cinfo->out_color_space == JCS_RGB) { - if (cinfo->quantize_colors) { - /* We only support 8-bit colormap indexes, so only 256 colors */ - num_colors = cinfo->actual_number_of_colors; - if (num_colors > 256) - ERREXIT1(cinfo, JERR_TOO_MANY_COLORS, num_colors); - write_header(cinfo, dinfo, num_colors); - /* Write the colormap. Note Targa uses BGR byte order */ - outfile = dest->pub.output_file; - for (i = 0; i < num_colors; i++) { - putc(GETJSAMPLE(cinfo->colormap[2][i]), outfile); - putc(GETJSAMPLE(cinfo->colormap[1][i]), outfile); - putc(GETJSAMPLE(cinfo->colormap[0][i]), outfile); - } - dest->pub.put_pixel_rows = put_gray_rows; - } else { - write_header(cinfo, dinfo, 0); - dest->pub.put_pixel_rows = put_pixel_rows; - } - } else { - ERREXIT(cinfo, JERR_TGA_COLORSPACE); - } -} - - -/* - * Finish up at the end of the file. - */ - -METHODDEF(void) -finish_output_tga (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - /* Make sure we wrote the output file OK */ - fflush(dinfo->output_file); - if (ferror(dinfo->output_file)) - ERREXIT(cinfo, JERR_FILE_WRITE); -} - - -/* - * The module selection routine for Targa format output. - */ - -GLOBAL(djpeg_dest_ptr) -jinit_write_targa (j_decompress_ptr cinfo) -{ - tga_dest_ptr dest; - - /* Create module interface object, fill in method pointers */ - dest = (tga_dest_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(tga_dest_struct)); - dest->pub.start_output = start_output_tga; - dest->pub.finish_output = finish_output_tga; - - /* Calculate output image dimensions so we can allocate space */ - jpeg_calc_output_dimensions(cinfo); - - /* Create I/O buffer. Note we make this near on a PC. */ - dest->buffer_width = cinfo->output_width * cinfo->output_components; - dest->iobuffer = (char *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (size_t) (dest->buffer_width * SIZEOF(char))); - - /* Create decompressor output buffer. */ - dest->pub.buffer = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, dest->buffer_width, (JDIMENSION) 1); - dest->pub.buffer_height = 1; - - return (djpeg_dest_ptr) dest; -} - -#endif /* TARGA_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/ANNOUNCE b/irrlicht-1.6/source/Irrlicht/libpng/ANNOUNCE deleted file mode 100644 index 561a5e26c..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/ANNOUNCE +++ /dev/null @@ -1,49 +0,0 @@ - -Libpng 1.2.18 - May 15, 2007 - -This is a public release of libpng, intended for use in production codes. - -Files available for download: - -Source files with LF line endings (for Unix/Linux) and with a -"configure" script - - libpng-1.2.18.tar.gz - libpng-1.2.18.tar.bz2 - -Source files with LF line endings (for Unix/Linux) without the -"configure" script - - libpng-1.2.18-no-config.tar.gz - libpng-1.2.18-no-config.tar.bz2 - -Source files with CRLF line endings (for Windows), without the -"configure" script - - lpng1218.zip - lpng1218.tar.bz2 - -Project files - - libpng-1.2.18-project-netware.zip - libpng-1.2.18-project-wince.zip - -Other information: - - libpng-1.2.18-README.txt - libpng-1.2.18-KNOWNBUGS.txt - libpng-1.2.18-LICENSE.txt - libpng-1.2.18-Y2K-compliance.txt - -Changes since the last public release (1.2.17): - -version 1.2.18 [May 15, 2007] - - Reverted the recent change to symbol-handling in configure script - -Send comments/corrections/commendations to png-mng-implement at lists.sf.net -(subscription required; visit -https://lists.sourceforge.net/lists/listinfo/png-mng-implement -to subscribe) or to glennrp at users.sourceforge.net - -Glenn R-P diff --git a/irrlicht-1.6/source/Irrlicht/libpng/CHANGES b/irrlicht-1.6/source/Irrlicht/libpng/CHANGES deleted file mode 100644 index e3f4f688e..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/CHANGES +++ /dev/null @@ -1,1738 +0,0 @@ - -CHANGES - changes for libpng - -version 0.2 - added reader into png.h - fixed small problems in stub file - -version 0.3 - added pull reader - split up pngwrite.c to several files - added pnglib.txt - added example.c - cleaned up writer, adding a few new transformations - fixed some bugs in writer - interfaced with zlib 0.5 - added K&R support - added check for 64 KB blocks for 16 bit machines - -version 0.4 - cleaned up code and commented code - simplified time handling into png_time - created png_color_16 and png_color_8 to handle color needs - cleaned up color type defines - fixed various bugs - made various names more consistent - interfaced with zlib 0.71 - cleaned up zTXt reader and writer (using zlib's Reset functions) - split transformations into pngrtran.c and pngwtran.c - -version 0.5 - interfaced with zlib 0.8 - fixed many reading and writing bugs - saved using 3 spaces instead of tabs - -version 0.6 - added png_large_malloc() and png_large_free() - added png_size_t - cleaned up some compiler warnings - added png_start_read_image() - -version 0.7 - cleaned up lots of bugs - finished dithering and other stuff - added test program - changed name from pnglib to libpng - -version 0.71 [June, 1995] - changed pngtest.png for zlib 0.93 - fixed error in libpng.txt and example.c - -version 0.8 - cleaned up some bugs - added png_set_filler() - split up pngstub.c into pngmem.c, pngio.c, and pngerror.c - added #define's to remove unwanted code - moved png_info_init() to png.c - added old_size into png_realloc() - added functions to manually set filtering and compression info - changed compression parameters based on image type - optimized filter selection code - added version info - changed external functions passing floats to doubles (k&r problems?) - put all the configurable stuff in pngconf.h - enabled png_set_shift to work with paletted images on read - added png_read_update_info() - updates info structure with - transformations - -version 0.81 [August, 1995] - incorporated Tim Wegner's medium model code (thanks, Tim) - -version 0.82 [September, 1995] - [unspecified changes] - -version 0.85 [December, 1995] - added more medium model code (almost everything's a far) - added i/o, error, and memory callback functions - fixed some bugs (16 bit, 4 bit interlaced, etc.) - added first run progressive reader (barely tested) - -version 0.86 [January, 1996] - fixed bugs - improved documentation - -version 0.87 [January, 1996] - fixed medium model bugs - fixed other bugs introduced in 0.85 and 0.86 - added some minor documentation - -version 0.88 [January, 1996] - fixed progressive bugs - replaced tabs with spaces - cleaned up documentation - added callbacks for read/write and warning/error functions - -version 0.89 [July, 1996] - added new initialization API to make libpng work better with shared libs - we now have png_create_read_struct(), png_create_write_struct(), - png_create_info_struct(), png_destroy_read_struct(), and - png_destroy_write_struct() instead of the separate calls to - malloc and png_read_init(), png_info_init(), and png_write_init() - changed warning/error callback functions to fix bug - this means you - should use the new initialization API if you were using the old - png_set_message_fn() calls, and that the old API no longer exists - so that people are aware that they need to change their code - changed filter selection API to allow selection of multiple filters - since it didn't work in previous versions of libpng anyways - optimized filter selection code - fixed png_set_background() to allow using an arbitrary RGB color for - paletted images - fixed gamma and background correction for paletted images, so - png_correct_palette is not needed unless you are correcting an - external palette (you will need to #define PNG_CORRECT_PALETTE_SUPPORTED - in pngconf.h) - if nobody uses this, it may disappear in the future. - fixed bug with Borland 64K memory allocation (Alexander Lehmann) - fixed bug in interlace handling (Smarasderagd, I think) - added more error checking for writing and image to reduce invalid files - separated read and write functions so that they won't both be linked - into a binary when only reading or writing functionality is used - new pngtest image also has interlacing and zTXt - updated documentation to reflect new API - -version 0.90 [January, 1997] - made CRC errors/warnings on critical and ancillary chunks configurable - libpng will use the zlib CRC routines by (compile-time) default - changed DOS small/medium model memory support - needs zlib 1.04 (Tim Wegner) - added external C++ wrapper statements to png.h (Gilles Dauphin) - allow PNG file to be read when some or all of file signature has already - been read from the beginning of the stream. ****This affects the size - of info_struct and invalidates all programs that use a shared libpng**** - fixed png_filler() declarations - fixed? background color conversions - fixed order of error function pointers to match documentation - current chunk name is now available in png_struct to reduce the number - of nearly identical error messages (will simplify multi-lingual - support when available) - try to get ready for unknown-chunk callback functions: - - previously read critical chunks are flagged, so the chunk handling - routines can determine if the chunk is in the right place - - all chunk handling routines have the same prototypes, so we will - be able to handle all chunks via a callback mechanism - try to fix Linux "setjmp" buffer size problems - removed png_large_malloc, png_large_free, and png_realloc functions. - -version 0.95 [March, 1997] - fixed bug in pngwutil.c allocating "up_row" twice and "avg_row" never - fixed bug in PNG file signature compares when start != 0 - changed parameter type of png_set_filler(...filler...) from png_byte - to png_uint_32 - added test for MACOS to ensure that both math.h and fp.h are not #included - added macros for libpng to be compiled as a Windows DLL (Andreas Kupries) - added "packswap" transformation, which changes the endianness of - packed-pixel bytes (Kevin Bracey) - added "strip_alpha" transformation, which removes the alpha channel of - input images without using it (not necessarily a good idea) - added "swap_alpha" transformation, which puts the alpha channel in front - of the color bytes instead of after - removed all implicit variable tests which assume NULL == 0 (I think) - changed several variables to "png_size_t" to show 16/32-bit limitations - added new pCAL chunk read/write support - added experimental filter selection weighting (Greg Roelofs) - removed old png_set_rgbx() and png_set_xrgb() functions that have been - obsolete for about 2 years now (use png_set_filler() instead) - added macros to read 16- and 32-bit ints directly from buffer, to be - used only on those systems that support it (namely PowerPC and 680x0) - With some testing, this may become the default for MACOS/PPC systems. - only calculate CRC on data if we are going to use it - added macros for zTXt compression type PNG_zTXt_COMPRESSION_??? - added macros for simple libpng debugging output selectable at compile time - removed PNG_READ_END_MODE in progressive reader (Smarasderagd) - more description of info_struct in libpng.txt and png.h - more instructions in example.c - more chunk types tested in pngtest.c - renamed pngrcb.c to pngset.c, and all png_read_<chunk> functions to be - png_set_<chunk>. We now have corresponding png_get_<chunk> - functions in pngget.c to get information in info_ptr. This isolates - the application from the internal organization of png_info_struct - (good for shared library implementations). - -version 0.96 [May, 1997] - fixed serious bug with < 8bpp images introduced in 0.95 - fixed 256-color transparency bug (Greg Roelofs) - fixed up documentation (Greg Roelofs, Laszlo Nyul) - fixed "error" in pngconf.h for Linux setjmp() behaviour - fixed DOS medium model support (Tim Wegner) - fixed png_check_keyword() for case with error in static string text - added read of CRC after IEND chunk for embedded PNGs (Laszlo Nyul) - added typecasts to quiet compiler errors - added more debugging info - -version 0.97 [January, 1998] - removed PNG_USE_OWN_CRC capability - relocated png_set_crc_action from pngrutil.c to pngrtran.c - fixed typecasts of "new_key", etc. (Andreas Dilger) - added RFC 1152 [sic] date support - fixed bug in gamma handling of 4-bit grayscale - added 2-bit grayscale gamma handling (Glenn R-P) - added more typecasts. 65536L becomes (png_uint_32)65536L, etc. (Glenn R-P) - minor corrections in libpng.txt - added simple sRGB support (Glenn R-P) - easier conditional compiling, e.g. define PNG_READ/WRITE_NOT_FULLY_SUPPORTED; - all configurable options can be selected from command-line instead - of having to edit pngconf.h (Glenn R-P) - fixed memory leak in pngwrite.c (free info_ptr->text) (Glenn R-P) - added more conditions for png_do_background, to avoid changing - black pixels to background when a background is supplied and - no pixels are transparent - repaired PNG_NO_STDIO behaviour - tested NODIV support and made it default behaviour (Greg Roelofs) - added "-m" option and PNGTEST_DEBUG_MEMORY to pngtest (John Bowler) - regularized version numbering scheme and bumped shared-library major - version number to 2 to avoid problems with libpng 0.89 apps (Greg Roelofs) - -version 0.98 [January, 1998] - cleaned up some typos in libpng.txt and in code documentation - fixed memory leaks in pCAL chunk processing (Glenn R-P and John Bowler) - cosmetic change "display_gamma" to "screen_gamma" in pngrtran.c - changed recommendation about file_gamma for PC images to .51 from .45, - in example.c and libpng.txt, added comments to distinguish between - screen_gamma, viewing_gamma, and display_gamma. - changed all references to RFC1152 to read RFC1123 and changed the - PNG_TIME_RFC1152_SUPPORTED macro to PNG_TIME_RFC1123_SUPPORTED - added png_invert_alpha capability (Glenn R-P -- suggestion by Jon Vincent) - changed srgb_intent from png_byte to int to avoid compiler bugs - -version 0.99 [January 30, 1998] - free info_ptr->text instead of end_info_ptr->text in pngread.c (John Bowler) - fixed a longstanding "packswap" bug in pngtrans.c - fixed some inconsistencies in pngconf.h that prevented compiling with - PNG_READ_GAMMA_SUPPORTED and PNG_READ_hIST_SUPPORTED undefined - fixed some typos and made other minor rearrangement of libpng.txt (Andreas) - changed recommendation about file_gamma for PC images to .50 from .51 in - example.c and libpng.txt, and changed file_gamma for sRGB images to .45 - added a number of functions to access information from the png structure - png_get_image_height(), etc. (Glenn R-P, suggestion by Brad Pettit) - added TARGET_MACOS similar to zlib-1.0.8 - define PNG_ALWAYS_EXTERN when __MWERKS__ && WIN32 are defined - added type casting to all png_malloc() function calls -version 0.99a [January 31, 1998] - Added type casts and parentheses to all returns that return a value.(Tim W.) -version 0.99b [February 4, 1998] - Added type cast png_uint_32 on malloc function calls where needed. - Changed type of num_hist from png_uint_32 to int (same as num_palette). - Added checks for rowbytes overflow, in case png_size_t is less than 32 bits. - Renamed makefile.elf to makefile.lnx. -version 0.99c [February 7, 1998] - More type casting. Removed erroneous overflow test in pngmem.c. - Added png_buffered_memcpy() and png_buffered_memset(), apply them to rowbytes. - Added UNIX manual pages libpng.3 (incorporating libpng.txt) and png.5. -version 0.99d [February 11, 1998] - Renamed "far_to_near()" "png_far_to_near()" - Revised libpng.3 - Version 99c "buffered" operations didn't work as intended. Replaced them - with png_memcpy_check() and png_memset_check(). - Added many "if (png_ptr == NULL) return" to quell compiler warnings about - unused png_ptr, mostly in pngget.c and pngset.c. - Check for overlength tRNS chunk present when indexed-color PLTE is read. - Cleaned up spelling errors in libpng.3/libpng.txt - Corrected a problem with png_get_tRNS() which returned undefined trans array -version 0.99e [February 28, 1998] - Corrected png_get_tRNS() again. - Add parentheses for easier reading of pngget.c, fixed "||" should be "&&". - Touched up example.c to make more of it compileable, although the entire - file still can't be compiled (Willem van Schaik) - Fixed a bug in png_do_shift() (Bryan Tsai) - Added a space in png.h prototype for png_write_chunk_start() - Replaced pngtest.png with one created with zlib 1.1.1 - Changed pngtest to report PASS even when file size is different (Jean-loup G.) - Corrected some logic errors in png_do_invert_alpha() (Chris Patterson) -version 0.99f [March 5, 1998] - Corrected a bug in pngpread() introduced in version 99c (Kevin Bracey) - Moved makefiles into a "scripts" directory, and added INSTALL instruction file - Added makefile.os2 and pngos2.def (A. Zabolotny) and makefile.s2x (W. Sebok) - Added pointers to "note on libpng versions" in makefile.lnx and README - Added row callback feature when reading and writing nonprogressive rows - and added a test of this feature in pngtest.c - Added user transform callbacks, with test of the feature in pngtest.c -version 0.99g [March 6, 1998, morning] - Minor changes to pngtest.c to suppress compiler warnings. - Removed "beta" language from documentation. -version 0.99h [March 6, 1998, evening] - Minor changes to previous minor changes to pngtest.c - Changed PNG_READ_NOT_FULLY_SUPPORTED to PNG_READ_TRANSFORMS_NOT_SUPPORTED - and added PNG_PROGRESSIVE_READ_NOT_SUPPORTED macro - Added user transform capability - -version 1.00 [March 7, 1998] - Changed several typedefs in pngrutil.c - Added makefile.wat (Pawel Mrochen), updated makefile.tc3 (Willem van Schaik) - replaced "while(1)" with "for(;;)" - added PNGARG() to prototypes in pngtest.c and removed some prototypes - updated some of the makefiles (Tom Lane) - changed some typedefs (s_start, etc.) in pngrutil.c - fixed dimensions of "short_months" array in pngwrite.c - Replaced ansi2knr.c with the one from jpeg-v6 - -version 1.0.0 [March 8, 1998] - Changed name from 1.00 to 1.0.0 (Adam Costello) - Added smakefile.ppc (with SCOPTIONS.ppc) for Amiga PPC (Andreas Kleinert) -version 1.0.0a [March 9, 1998] - Fixed three bugs in pngrtran.c to make gamma+background handling consistent - (Greg Roelofs) - Changed format of the PNG_LIBPNG_VER integer to xyyzz instead of xyz - for major, minor, and bugfix releases. This is 10001. (Adam Costello, - Tom Lane) - Make months range from 1-12 in png_convert_to_rfc1123 -version 1.0.0b [March 13, 1998] - Quieted compiler complaints about two empty "for" loops in pngrutil.c - Minor changes to makefile.s2x - Removed #ifdef/#endif around a png_free() in pngread.c - -version 1.0.1 [March 14, 1998] - Changed makefile.s2x to reduce security risk of using a relative pathname - Fixed some typos in the documentation (Greg). - Fixed a problem with value of "channels" returned by png_read_update_info() -version 1.0.1a [April 21, 1998] - Optimized Paeth calculations by replacing abs() function calls with intrinsics - plus other loop optimizations. Improves avg decoding speed by about 20%. - Commented out i386istic "align" compiler flags in makefile.lnx. - Reduced the default warning level in some makefiles, to make them consistent. - Removed references to IJG and JPEG in the ansi2knr.c copyright statement. - Fixed a bug in png_do_strip_filler with XXRRGGBB => RRGGBB transformation. - Added grayscale and 16-bit capability to png_do_read_filler(). - Fixed a bug in pngset.c, introduced in version 0.99c, that sets rowbytes - too large when writing an image with bit_depth < 8 (Bob Dellaca). - Corrected some bugs in the experimental weighted filtering heuristics. - Moved a misplaced pngrutil code block that truncates tRNS if it has more - than num_palette entries -- test was done before num_palette was defined. - Fixed a png_convert_to_rfc1123() bug that converts day 31 to 0 (Steve Eddins). - Changed compiler flags in makefile.wat for better optimization (Pawel Mrochen). -version 1.0.1b [May 2, 1998] - Relocated png_do_gray_to_rgb() within png_do_read_transformations() (Greg). - Relocated the png_composite macros from pngrtran.c to png.h (Greg). - Added makefile.sco (contributed by Mike Hopkirk). - Fixed two bugs (missing definitions of "istop") introduced in libpng-1.0.1a. - Fixed a bug in pngrtran.c that would set channels=5 under some circumstances. - More work on the Paeth-filtering, achieving imperceptible speedup (A Kleinert). - More work on loop optimization which may help when compiled with C++ compilers. - Added warnings when people try to use transforms they've defined out. - Collapsed 4 "i" and "c" loops into single "i" loops in pngrtran and pngwtran. - Revised paragraph about png_set_expand() in libpng.txt and libpng.3 (Greg) -version 1.0.1c [May 11, 1998] - Fixed a bug in pngrtran.c (introduced in libpng-1.0.1a) where the masks for - filler bytes should have been 0xff instead of 0xf. - Added max_pixel_depth=32 in pngrutil.c when using FILLER with palette images. - Moved PNG_WRITE_WEIGHTED_FILTER_SUPPORTED and PNG_WRITE_FLUSH_SUPPORTED - out of the PNG_WRITE_TRANSFORMS_NOT_SUPPORTED block of pngconf.h - Added "PNG_NO_WRITE_TRANSFORMS" etc., as alternatives for *_NOT_SUPPORTED, - for consistency, in pngconf.h - Added individual "ifndef PNG_NO_[CAPABILITY]" in pngconf.h to make it easier - to remove unwanted capabilities via the compile line - Made some corrections to grammar (which, it's) in documentation (Greg). - Corrected example.c, use of row_pointers in png_write_image(). -version 1.0.1d [May 24, 1998] - Corrected several statements that used side effects illegally in pngrutil.c - and pngtrans.c, that were introduced in version 1.0.1b - Revised png_read_rows() to avoid repeated if-testing for NULL (A Kleinert) - More corrections to example.c, use of row_pointers in png_write_image() - and png_read_rows(). - Added pngdll.mak and pngdef.pas to scripts directory, contributed by - Bob Dellaca, to make a png32bd.dll with Borland C++ 4.5 - Fixed error in example.c with png_set_text: num_text is 3, not 2 (Guido V.) - Changed several loops from count-down to count-up, for consistency. -version 1.0.1e [June 6, 1998] - Revised libpng.txt and libpng.3 description of png_set_read|write_fn(), and - added warnings when people try to set png_read_fn and png_write_fn in - the same structure. - Added a test such that png_do_gamma will be done when num_trans==0 - for truecolor images that have defined a background. This corrects an - error that was introduced in libpng-0.90 that can cause gamma processing - to be skipped. - Added tests in png.h to include "trans" and "trans_values" in structures - when PNG_READ_BACKGROUND_SUPPORTED or PNG_READ_EXPAND_SUPPORTED is defined. - Add png_free(png_ptr->time_buffer) in png_destroy_read_struct() - Moved png_convert_to_rfc_1123() from pngwrite.c to png.c - Added capability for user-provided malloc_fn() and free_fn() functions, - and revised pngtest.c to demonstrate their use, replacing the - PNGTEST_DEBUG_MEM feature. - Added makefile.w32, for Microsoft C++ 4.0 and later (Tim Wegner). - -version 1.0.2 [June 14, 1998] - Fixed two bugs in makefile.bor . -version 1.0.2a [December 30, 1998] - Replaced and extended code that was removed from png_set_filler() in 1.0.1a. - Fixed a bug in png_do_filler() that made it fail to write filler bytes in - the left-most pixel of each row (Kevin Bracey). - Changed "static pngcharp tIME_string" to "static char tIME_string[30]" - in pngtest.c (Duncan Simpson). - Fixed a bug in pngtest.c that caused pngtest to try to write a tIME chunk - even when no tIME chunk was present in the source file. - Fixed a problem in pngrutil.c: gray_to_rgb didn't always work with 16-bit. - Fixed a problem in png_read_push_finish_row(), which would not skip some - passes that it should skip, for images that are less than 3 pixels high. - Interchanged the order of calls to png_do_swap() and png_do_shift() - in pngwtran.c (John Cromer). - Added #ifdef PNG_DEBUG/#endif surrounding use of PNG_DEBUG in png.h . - Changed "bad adaptive filter type" from error to warning in pngrutil.c . - Fixed a documentation error about default filtering with 8-bit indexed-color. - Separated the PNG_NO_STDIO macro into PNG_NO_STDIO and PNG_NO_CONSOLE_IO - (L. Peter Deutsch). - Added png_set_rgb_to_gray() and png_get_rgb_to_gray_status() functions. - Added png_get_copyright() and png_get_header_version() functions. - Revised comments on png_set_progressive_read_fn() in libpng.txt and example.c - Added information about debugging in libpng.txt and libpng.3 . - Changed "ln -sf" to "ln -s -f" in makefile.s2x, makefile.lnx, and makefile.sco. - Removed lines after Dynamic Dependencies" in makefile.aco . - Revised makefile.dec to make a shared library (Jeremie Petit). - Removed trailing blanks from all files. -version 1.0.2a [January 6, 1999] - Removed misplaced #endif and #ifdef PNG_NO_EXTERN near the end of png.h - Added "if" tests to silence complaints about unused png_ptr in png.h and png.c - Changed "check_if_png" function in example.c to return true (nonzero) if PNG. - Changed libpng.txt to demonstrate png_sig_cmp() instead of png_check_sig() - which is obsolete. - -version 1.0.3 [January 14, 1999] - Added makefile.hux, for Hewlett Packard HPUX 10.20 and 11.00 (Jim Rice) - Added a statement of Y2K compliance in png.h, libpng.3, and Y2KINFO. -version 1.0.3a [August 12, 1999] - Added check for PNG_READ_INTERLACE_SUPPORTED in pngread.c; issue a warning - if an attempt is made to read an interlaced image when it's not supported. - Added check if png_ptr->trans is defined before freeing it in pngread.c - Modified the Y2K statement to include versions back to version 0.71 - Fixed a bug in the check for valid IHDR bit_depth/color_types in pngrutil.c - Modified makefile.wat (added -zp8 flag, ".symbolic", changed some comments) - Replaced leading blanks with tab characters in makefile.hux - Changed "dworkin.wustl.edu" to "ccrc.wustl.edu" in various documents. - Changed (float)red and (float)green to (double)red, (double)green - in png_set_rgb_to_gray() to avoid "promotion" problems in AIX. - Fixed a bug in pngconf.h that omitted <stdio.h> when PNG_DEBUG==0 (K Bracey). - Reformatted libpng.3 and libpngpf.3 with proper fonts (script by J. vanZandt). - Updated documentation to refer to the PNG-1.2 specification. - Removed ansi2knr.c and left pointers to the latest source for ansi2knr.c - in makefile.knr, INSTALL, and README (L. Peter Deutsch) - Fixed bugs in calculation of the length of rowbytes when adding alpha - channels to 16-bit images, in pngrtran.c (Chris Nokleberg) - Added function png_set_user_transform_info() to store user_transform_ptr, - user_depth, and user_channels into the png_struct, and a function - png_get_user_transform_ptr() to retrieve the pointer (Chris Nokleberg) - Added function png_set_empty_plte_permitted() to make libpng useable - in MNG applications. - Corrected the typedef for png_free_ptr in png.h (Jesse Jones). - Correct gamma with srgb is 45455 instead of 45000 in pngrutil.c, to be - consistent with PNG-1.2, and allow variance of 500 before complaining. - Added assembler code contributed by Intel in file pngvcrd.c and modified - makefile.w32 to use it (Nirav Chhatrapati, INTEL Corporation, Gilles Vollant) - Changed "ln -s -f" to "ln -f -s" in the makefiles to make Solaris happy. - Added some aliases for png_set_expand() in pngrtran.c, namely - png_set_expand_PLTE(), png_set_expand_depth(), and png_set_expand_tRNS() - (Greg Roelofs, in "PNG: The Definitive Guide"). - Added makefile.beo for BEOS on X86, contributed by Sander Stok. -version 1.0.3b [August 26, 1999] - Replaced 2147483647L several places with PNG_MAX_UINT macro, defined in png.h - Changed leading blanks to tabs in all makefiles. - Define PNG_USE_PNGVCRD in makefile.w32, to get MMX assembler code. - Made alternate versions of png_set_expand() in pngrtran.c, namely - png_set_gray_1_2_4_to_8, png_set_palette_to_rgb, and png_set_tRNS_to_alpha - (Greg Roelofs, in "PNG: The Definitive Guide"). Deleted the 1.0.3a aliases. - Relocated start of 'extern "C"' block in png.h so it doesn't include pngconf.h - Revised calculation of num_blocks in pngmem.c to avoid a potentially - negative shift distance, whose results are undefined in the C language. - Added a check in pngset.c to prevent writing multiple tIME chunks. - Added a check in pngwrite.c to detect invalid small window_bits sizes. -version 1.0.3d [September 4, 1999] - Fixed type casting of igamma in pngrutil.c - Added new png_expand functions to scripts/pngdef.pas and pngos2.def - Added a demo read_user_transform_fn that examines the row filters in pngtest.c - -version 1.0.4 [September 24, 1999] - Define PNG_ALWAYS_EXTERN in pngconf.h if __STDC__ is defined - Delete #define PNG_INTERNAL and include "png.h" from pngasmrd.h - Made several minor corrections to pngtest.c - Renamed the makefiles with longer but more user friendly extensions. - Copied the PNG copyright and license to a separate LICENSE file. - Revised documentation, png.h, and example.c to remove reference to - "viewing_gamma" which no longer appears in the PNG specification. - Revised pngvcrd.c to use MMX code for interlacing only on the final pass. - Updated pngvcrd.c to use the faster C filter algorithms from libpng-1.0.1a - Split makefile.win32vc into two versions, makefile.vcawin32 (uses MMX - assembler code) and makefile.vcwin32 (doesn't). - Added a CPU timing report to pngtest.c (enabled by defining PNGTEST_TIMING) - Added a copy of pngnow.png to the distribution. -version 1.0.4a [September 25, 1999] - Increase max_pixel_depth in pngrutil.c if a user transform needs it. - Changed several division operations to right-shifts in pngvcrd.c -version 1.0.4b [September 30, 1999] - Added parentheses in line 3732 of pngvcrd.c - Added a comment in makefile.linux warning about buggy -O3 in pgcc 2.95.1 -version 1.0.4c [October 1, 1999] - Added a "png_check_version" function in png.c and pngtest.c that will generate - a helpful compiler error if an old png.h is found in the search path. - Changed type of png_user_transform_depth|channels from int to png_byte. -version 1.0.4d [October 6, 1999] - Changed 0.45 to 0.45455 in png_set_sRGB() - Removed unused PLTE entries from pngnow.png - Re-enabled some parts of pngvcrd.c (png_combine_row) that work properly. -version 1.0.4e [October 10, 1999] - Fixed sign error in pngvcrd.c (Greg Roelofs) - Replaced some instances of memcpy with simple assignments in pngvcrd (GR-P) -version 1.0.4f [October 15, 1999] - Surrounded example.c code with #if 0 .. #endif to prevent people from - inadvertently trying to compile it. - Changed png_get_header_version() from a function to a macro in png.h - Added type casting mostly in pngrtran.c and pngwtran.c - Removed some pointless "ptr = NULL" in pngmem.c - Added a "contrib" directory containing the source code from Greg's book. - -version 1.0.5 [October 15, 1999] - Minor editing of the INSTALL and README files. -version 1.0.5a [October 23, 1999] - Added contrib/pngsuite and contrib/pngminus (Willem van Schaik) - Fixed a typo in the png_set_sRGB() function call in example.c (Jan Nijtmans) - Further optimization and bugfix of pngvcrd.c - Revised pngset.c so that it does not allocate or free memory in the user's - text_ptr structure. Instead, it makes its own copy. - Created separate write_end_info_struct in pngtest.c for a more severe test. - Added code in pngwrite.c to free info_ptr->text[i].key to stop a memory leak. -version 1.0.5b [November 23, 1999] - Moved PNG_FLAG_HAVE_CHUNK_HEADER, PNG_FLAG_BACKGROUND_IS_GRAY and - PNG_FLAG_WROTE_tIME from flags to mode. - Added png_write_info_before_PLTE() function. - Fixed some typecasting in contrib/gregbook/*.c - Updated scripts/makevms.com and added makevms.com to contrib/gregbook - and contrib/pngminus (Martin Zinser) -version 1.0.5c [November 26, 1999] - Moved png_get_header_version from png.h to png.c, to accommodate ansi2knr. - Removed all global arrays (according to PNG_NO_GLOBAL_ARRAYS macro), to - accommodate making DLL's: Moved usr_png_ver from global variable to function - png_get_header_ver() in png.c. Moved png_sig to png_sig_bytes in png.c and - eliminated use of png_sig in pngwutil.c. Moved the various png_CHNK arrays - into pngtypes.h. Eliminated use of global png_pass arrays. Declared the - png_CHNK and png_pass arrays to be "const". Made the global arrays - available to applications (although none are used in libpng itself) when - PNG_NO_GLOBAL_ARRAYS is not defined or when PNG_GLOBAL_ARRAYS is defined. - Removed some extraneous "-I" from contrib/pngminus/makefile.std - Changed the PNG_sRGB_INTENT macros in png.h to be consistent with PNG-1.2. - Change PNG_SRGB_INTENT to PNG_sRGB_INTENT in libpng.txt and libpng.3 -version 1.0.5d [November 29, 1999] - Add type cast (png_const_charp) two places in png.c - Eliminated pngtypes.h; use macros instead to declare PNG_CHNK arrays. - Renamed "PNG_GLOBAL_ARRAYS" to "PNG_USE_GLOBAL_ARRAYS" and made available - to applications a macro "PNG_USE_LOCAL_ARRAYS". - #ifdef out all the new declarations when PNG_USE_GLOBAL_ARRAYS is defined. - Added PNG_EXPORT_VAR macro to accommodate making DLL's. -version 1.0.5e [November 30, 1999] - Added iCCP, iTXt, and sPLT support; added "lang" member to the png_text - structure; refactored the inflate/deflate support to make adding new chunks - with trailing compressed parts easier in the future, and added new functions - png_free_iCCP, png_free_pCAL, png_free_sPLT, png_free_text, png_get_iCCP, - png_get_spalettes, png_set_iCCP, png_set_spalettes (Eric S. Raymond). - NOTE: Applications that write text chunks MUST define png_text->lang - before calling png_set_text(). It must be set to NULL if you want to - write tEXt or zTXt chunks. If you want your application to be able to - run with older versions of libpng, use - - #ifdef PNG_iTXt_SUPPORTED - png_text[i].lang = NULL; - #endif - - Changed png_get_oFFs() and png_set_oFFs() to use signed rather than unsigned - offsets (Eric S. Raymond). - Combined PNG_READ_cHNK_SUPPORTED and PNG_WRITE_cHNK_SUPPORTED macros into - PNG_cHNK_SUPPORTED and combined the three types of PNG_text_SUPPORTED - macros, leaving the separate macros also available. - Removed comments on #endifs at the end of many short, non-nested #if-blocks. -version 1.0.5f [December 6, 1999] - Changed makefile.solaris to issue a warning about potential problems when - the ucb "ld" is in the path ahead of the ccs "ld". - Removed "- [date]" from the "synopsis" line in libpng.3 and libpngpf.3. - Added sCAL chunk support (Eric S. Raymond). -version 1.0.5g [December 7, 1999] - Fixed "png_free_spallettes" typo in png.h - Added code to handle new chunks in pngpread.c - Moved PNG_CHNK string macro definitions outside of PNG_NO_EXTERN block - Added "translated_key" to png_text structure and png_write_iTXt(). - Added code in pngwrite.c to work around a newly discovered zlib bug. -version 1.0.5h [December 10, 1999] - NOTE: regarding the note for version 1.0.5e, the following must also - be included in your code: - png_text[i].translated_key = NULL; - Unknown chunk handling is now supported. - Option to eliminate all floating point support was added. Some new - fixed-point functions such as png_set_gAMA_fixed() were added. - Expanded tabs and removed trailing blanks in source files. -version 1.0.5i [December 13, 1999] - Added some type casts to silence compiler warnings. - Renamed "png_free_spalette" to "png_free_spalettes" for consistency. - Removed leading blanks from a #define in pngvcrd.c - Added some parameters to the new png_set_keep_unknown_chunks() function. - Added a test for up->location != 0 in the first instance of writing - unknown chunks in pngwrite.c - Changed "num" to "i" in png_free_spalettes() and png_free_unknowns() to - prevent recursion. - Added png_free_hIST() function. - Various patches to fix bugs in the sCAL and integer cHRM processing, - and to add some convenience macros for use with sCAL. -version 1.0.5j [December 21, 1999] - Changed "unit" parameter of png_write_sCAL from png_byte to int, to work - around buggy compilers. - Added new type "png_fixed_point" for integers that hold float*100000 values - Restored backward compatibility of tEXt/zTXt chunk processing: - Restored the first four members of png_text to the same order as v.1.0.5d. - Added members "lang_key" and "itxt_length" to png_text struct. Set - text_length=0 when "text" contains iTXt data. Use the "compression" - member to distinguish among tEXt/zTXt/iTXt types. Added - PNG_ITXT_COMPRESSION_NONE (1) and PNG_ITXT_COMPRESSION_zTXt(2) macros. - The "Note" above, about backward incompatibility of libpng-1.0.5e, no - longer applies. - Fixed png_read|write_iTXt() to read|write parameters in the right order, - and to write the iTXt chunk after IDAT if it appears in the end_ptr. - Added pnggccrd.c, version of pngvcrd.c Intel assembler for gcc (Greg Roelofs) - Reversed the order of trying to write floating-point and fixed-point gAMA. -version 1.0.5k [December 27, 1999] - Added many parentheses, e.g., "if (a && b & c)" becomes "if (a && (b & c))" - Added png_handle_as_unknown() function (Glenn) - Added png_free_chunk_list() function and chunk_list and num_chunk_list members - of png_ptr. - Eliminated erroneous warnings about multiple sPLT chunks and sPLT-after-PLTE. - Fixed a libpng-1.0.5h bug in pngrutil.c that was issuing erroneous warnings - about ignoring incorrect gAMA with sRGB (gAMA was in fact not ignored) - Added png_free_tRNS(); png_set_tRNS() now malloc's its own trans array (ESR). - Define png_get_int_32 when oFFs chunk is supported as well as when pCAL is. - Changed type of proflen from png_int_32 to png_uint_32 in png_get_iCCP(). -version 1.0.5l [January 1, 2000] - Added functions png_set_read_user_chunk_fn() and png_get_user_chunk_ptr() - for setting a callback function to handle unknown chunks and for - retrieving the associated user pointer (Glenn). -version 1.0.5m [January 7, 2000] - Added high-level functions png_read_png(), png_write_png(), png_free_pixels(). -version 1.0.5n [January 9, 2000] - Added png_free_PLTE() function, and modified png_set_PLTE() to malloc its - own memory for info_ptr->palette. This makes it safe for the calling - application to free its copy of the palette any time after it calls - png_set_PLTE(). -version 1.0.5o [January 20, 2000] - Cosmetic changes only (removed some trailing blanks and TABs) -version 1.0.5p [January 31, 2000] - Renamed pngdll.mak to makefile.bd32 - Cosmetic changes in pngtest.c -version 1.0.5q [February 5, 2000] - Relocated the makefile.solaris warning about PATH problems. - Fixed pngvcrd.c bug by pushing/popping registers in mmxsupport (Bruce Oberg) - Revised makefile.gcmmx - Added PNG_SETJMP_SUPPORTED, PNG_SETJMP_NOT_SUPPORTED, and PNG_ABORT() macros -version 1.0.5r [February 7, 2000] - Removed superfluous prototype for png_get_itxt from png.h - Fixed a bug in pngrtran.c that improperly expanded the background color. - Return *num_text=0 from png_get_text() when appropriate, and fix documentation - of png_get_text() in libpng.txt/libpng.3. -version 1.0.5s [February 18, 2000] - Added "png_jmp_env()" macro to pngconf.h, to help people migrate to the - new error handler that's planned for the next libpng release, and changed - example.c, pngtest.c, and contrib programs to use this macro. - Revised some of the DLL-export macros in pngconf.h (Greg Roelofs) - Fixed a bug in png_read_png() that caused it to fail to expand some images - that it should have expanded. - Fixed some mistakes in the unused and undocumented INCH_CONVERSIONS functions - in pngget.c - Changed the allocation of palette, history, and trans arrays back to - the version 1.0.5 method (linking instead of copying) which restores - backward compatibility with version 1.0.5. Added some remarks about - that in example.c. Added "free_me" member to info_ptr and png_ptr - and added png_free_data() function. - Updated makefile.linux and makefile.gccmmx to make directories conditionally. - Made cosmetic changes to pngasmrd.h - Added png_set_rows() and png_get_rows(), for use with png_read|write_png(). - Modified png_read_png() to allocate info_ptr->row_pointers only if it - hasn't already been allocated. -version 1.0.5t [March 4, 2000] - Changed png_jmp_env() migration aiding macro to png_jmpbuf(). - Fixed "interlace" typo (should be "interlaced") in contrib/gregbook/read2-x.c - Fixed bug with use of PNG_BEFORE_IHDR bit in png_ptr->mode, introduced when - PNG_FLAG_HAVE_CHUNK_HEADER was moved into png_ptr->mode in version 1.0.5b - Files in contrib/gregbook were revised to use png_jmpbuf() and to select - a 24-bit visual if one is available, and to allow abbreviated options. - Files in contrib/pngminus were revised to use the png_jmpbuf() macro. - Removed spaces in makefile.linux and makefile.gcmmx, introduced in 1.0.5s -version 1.0.5u [March 5, 2000] - Simplified the code that detects old png.h in png.c and pngtest.c - Renamed png_spalette (_p, _pp) to png_sPLT_t (_tp, _tpp) - Increased precision of rgb_to_gray calculations from 8 to 15 bits and - added png_set_rgb_to_gray_fixed() function. - Added makefile.bc32 (32-bit Borland C++, C mode) -version 1.0.5v [March 11, 2000] - Added some parentheses to the png_jmpbuf macro definition. - Updated references to the zlib home page, which has moved to freesoftware.com. - Corrected bugs in documentation regarding png_read_row() and png_write_row(). - Updated documentation of png_rgb_to_gray calculations in libpng.3/libpng.txt. - Renamed makefile.borland,turboc3 back to makefile.bor,tc3 as in version 1.0.3, - revised borland makefiles; added makefile.ibmvac3 and makefile.gcc (Cosmin) - -version 1.0.6 [March 20, 2000] - Minor revisions of makefile.bor, libpng.txt, and gregbook/rpng2-win.c - Added makefile.sggcc (SGI IRIX with gcc) -version 1.0.6d [April 7, 2000] - Changed sprintf() to strcpy() in png_write_sCAL_s() to work without STDIO - Added data_length parameter to png_decompress_chunk() function - Revised documentation to remove reference to abandoned png_free_chnk functions - Fixed an error in png_rgb_to_gray_fixed() - Revised example.c, usage of png_destroy_write_struct(). - Renamed makefile.ibmvac3 to makefile.ibmc, added libpng.icc IBM project file - Added a check for info_ptr->free_me&PNG_FREE_TEXT when freeing text in png.c - Simplify png_sig_bytes() function to remove use of non-ISO-C strdup(). -version 1.0.6e [April 9, 2000] - Added png_data_freer() function. - In the code that checks for over-length tRNS chunks, added check of - info_ptr->num_trans as well as png_ptr->num_trans (Matthias Benckmann) - Minor revisions of libpng.txt/libpng.3. - Check for existing data and free it if the free_me flag is set, in png_set_*() - and png_handle_*(). - Only define PNG_WEIGHTED_FILTERS_SUPPORTED when PNG_FLOATING_POINT_SUPPORTED - is defined. - Changed several instances of PNG_NO_CONSOLE_ID to PNG_NO_STDIO in pngrutil.c - and mentioned the purposes of the two macros in libpng.txt/libpng.3. -version 1.0.6f [April 14, 2000] - Revised png_set_iCCP() and png_set_rows() to avoid prematurely freeing data. - Add checks in png_set_text() for NULL members of the input text structure. - Revised libpng.txt/libpng.3. - Removed superfluous prototype for png_set_itxt from png.h - Removed "else" from pngread.c, after png_error(), and changed "0" to "length". - Changed several png_errors about malformed ancillary chunks to png_warnings. -version 1.0.6g [April 24, 2000] - Added png_pass-* arrays to pnggccrd.c when PNG_USE_LOCAL_ARRAYS is defined. - Relocated paragraph about png_set_background() in libpng.3/libpng.txt - and other revisions (Matthias Benckmann) - Relocated info_ptr->free_me, png_ptr->free_me, and other info_ptr and - png_ptr members to restore binary compatibility with libpng-1.0.5 - (breaks compatibility with libpng-1.0.6). -version 1.0.6h [April 24, 2000] - Changed shared library so-number pattern from 2.x.y.z to xy.z (this builds - libpng.so.10 & libpng.so.10.6h instead of libpng.so.2 & libpng.so.2.1.0.6h) - This is a temporary change for test purposes. -version 1.0.6i [May 2, 2000] - Rearranged some members at the end of png_info and png_struct, to put - unknown_chunks_num and free_me within the original size of the png_structs - and free_me, png_read_user_fn, and png_free_fn within the original png_info, - because some old applications allocate the structs directly instead of - using png_create_*(). - Added documentation of user memory functions in libpng.txt/libpng.3 - Modified png_read_png so that it will use user_allocated row_pointers - if present, unless free_me directs that it be freed, and added description - of the use of png_set_rows() and png_get_rows() in libpng.txt/libpng.3. - Added PNG_LEGACY_SUPPORTED macro, and #ifdef out all new (since version - 1.00) members of png_struct and png_info, to regain binary compatibility - when you define this macro. Capabilities lost in this event - are user transforms (new in version 1.0.0),the user transform pointer - (new in version 1.0.2), rgb_to_gray (new in 1.0.5), iCCP, sCAL, sPLT, - the high-level interface, and unknown chunks support (all new in 1.0.6). - This was necessary because of old applications that allocate the structs - directly as authors were instructed to do in libpng-0.88 and earlier, - instead of using png_create_*(). - Added modes PNG_CREATED_READ_STRUCT and PNG_CREATED_WRITE_STRUCT which - can be used to detect codes that directly allocate the structs, and - code to check these modes in png_read_init() and png_write_init() and - generate a libpng error if the modes aren't set and PNG_LEGACY_SUPPORTED - was not defined. - Added makefile.intel and updated makefile.watcom (Pawel Mrochen) -version 1.0.6j [May 3, 2000] - Overloaded png_read_init() and png_write_init() with macros that convert - calls to png_read_init_2() or png_write_init_2() that check the version - and structure sizes. -version 1.0.7beta11 [May 7, 2000] - Removed the new PNG_CREATED_READ_STRUCT and PNG_CREATED_WRITE_STRUCT modes - which are no longer used. - Eliminated the three new members of png_text when PNG_LEGACY_SUPPORTED is - defined or when neither PNG_READ_iTXt_SUPPORTED nor PNG_WRITE_iTXT_SUPPORTED - is defined. - Made PNG_NO_READ|WRITE_iTXt the default setting, to avoid memory - overrun when old applications fill the info_ptr->text structure directly. - Added PNGAPI macro, and added it to the definitions of all exported functions. - Relocated version macro definitions ahead of the includes of zlib.h and - pngconf.h in png.h. -version 1.0.7beta12 [May 12, 2000] - Revised pngset.c to avoid a problem with expanding the png_debug macro. - Deleted some extraneous defines from pngconf.h - Made PNG_NO_CONSOLE_IO the default condition when PNG_BUILD_DLL is defined. - Use MSC _RPTn debugging instead of fprintf if _MSC_VER is defined. - Added png_access_version_number() function. - Check for mask&PNG_FREE_CHNK (for TEXT, SCAL, PCAL) in png_free_data(). - Expanded libpng.3/libpng.txt information about png_data_freer(). -version 1.0.7beta14 [May 17, 2000] (beta13 was not published) - Changed pnggccrd.c and pngvcrd.c to handle bad adaptive filter types as - warnings instead of errors, as pngrutil.c does. - Set the PNG_INFO_IDAT valid flag in png_set_rows() so png_write_png() - will actually write IDATs. - Made the default PNG_USE_LOCAL_ARRAYS depend on PNG_DLL instead of WIN32. - Make png_free_data() ignore its final parameter except when freeing data - that can have multiple instances (text, sPLT, unknowns). - Fixed a new bug in png_set_rows(). - Removed info_ptr->valid tests from png_free_data(), as in version 1.0.5. - Added png_set_invalid() function. - Fixed incorrect illustrations of png_destroy_write_struct() in example.c. -version 1.0.7beta15 [May 30, 2000] - Revised the deliberately erroneous Linux setjmp code in pngconf.h to produce - fewer error messages. - Rearranged checks for Z_OK to check the most likely path first in pngpread.c - and pngwutil.c. - Added checks in pngtest.c for png_create_*() returning NULL, and mentioned - in libpng.txt/libpng.3 the need for applications to check this. - Changed names of png_default_*() functions in pngtest to pngtest_*(). - Changed return type of png_get_x|y_offset_*() from png_uint_32 to png_int_32. - Fixed some bugs in the unused PNG_INCH_CONVERSIONS functions in pngget.c - Set each pointer to NULL after freeing it in png_free_data(). - Worked around a problem in pngconf.h; AIX's strings.h defines an "index" - macro that conflicts with libpng's png_color_16.index. (Dimitri Papadapoulos) - Added "msvc" directory with MSVC++ project files (Simon-Pierre Cadieux). -version 1.0.7beta16 [June 4, 2000] - Revised the workaround of AIX string.h "index" bug. - Added a check for overlength PLTE chunk in pngrutil.c. - Added PNG_NO_POINTER_INDEXING macro to use array-indexing instead of pointer - indexing in pngrutil.c and pngwutil.c to accommodate a buggy compiler. - Added a warning in png_decompress_chunk() when it runs out of data, e.g. - when it tries to read an erroneous PhotoShop iCCP chunk. - Added PNG_USE_DLL macro. - Revised the copyright/disclaimer/license notice. - Added contrib/msvctest directory -version 1.0.7rc1 [June 9, 2000] - Corrected the definition of PNG_TRANSFORM_INVERT_ALPHA (0x0400 not 0x0200) - Added contrib/visupng directory (Willem van Schaik) -version 1.0.7beta18 [June 23, 2000] - Revised PNGAPI definition, and pngvcrd.c to work with __GCC__ - and do not redefine PNGAPI if it is passed in via a compiler directive. - Revised visupng/PngFile.c to remove returns from within the Try block. - Removed leading underscores from "_PNG_H" and "_PNG_SAVE_BSD_SOURCE" macros. - Updated contrib/visupng/cexcept.h to version 1.0.0. - Fixed bugs in pngwrite.c and pngwutil.c that prevented writing iCCP chunks. -version 1.0.7rc2 [June 28, 2000] - Updated license to include disclaimers required by UCITA. - Fixed "DJBPP" typo in pnggccrd.c introduced in beta18. - -version 1.0.7 [July 1, 2000] - Revised the definition of "trans_values" in libpng.3/libpng.txt -version 1.0.8beta1 [July 8, 2000] - Added png_free(png_ptr, key) two places in pngpread.c to stop memory leaks. - Changed PNG_NO_STDIO to PNG_NO_CONSOLE_IO, several places in pngrutil.c and - pngwutil.c. - Changed PNG_EXPORT_VAR to use PNG_IMPEXP, in pngconf.h. - Removed unused "#include <assert.h>" from png.c - Added WindowsCE support. - Revised pnggccrd.c to work with gcc-2.95.2 and in the Cygwin environment. -version 1.0.8beta2 [July 10, 2000] - Added project files to the wince directory and made further revisions - of pngtest.c, pngrio.c, and pngwio.c in support of WindowsCE. -version 1.0.8beta3 [July 11, 2000] - Only set the PNG_FLAG_FREE_TRNS or PNG_FREE_TRNS flag in png_handle_tRNS() - for indexed-color input files to avoid potential double-freeing trans array - under some unusual conditions; problem was introduced in version 1.0.6f. - Further revisions to pngtest.c and files in the wince subdirectory. -version 1.0.8beta4 [July 14, 2000] - Added the files pngbar.png and pngbar.jpg to the distribution. - Added makefile.cygwin, and cygwin support in pngconf.h - Added PNG_NO_ZALLOC_ZERO macro (makes png_zalloc skip zeroing memory) -version 1.0.8rc1 [July 16, 2000] - Revised png_debug() macros and statements to eliminate compiler warnings. - -version 1.0.8 [July 24, 2000] - Added png_flush() in pngwrite.c, after png_write_IEND(). - Updated makefile.hpux to build a shared library. -version 1.0.9beta1 [November 10, 2000] - Fixed typo in scripts/makefile.hpux - Updated makevms.com in scripts and contrib/* and contrib/* (Martin Zinser) - Fixed seqence-point bug in contrib/pngminus/png2pnm (Martin Zinser) - Changed "cdrom.com" in documentation to "libpng.org" - Revised pnggccrd.c to get it all working, and updated makefile.gcmmx (Greg). - Changed type of "params" from voidp to png_voidp in png_read|write_png(). - Make sure PNGAPI and PNG_IMPEXP are defined in pngconf.h. - Revised the 3 instances of WRITEFILE in pngtest.c. - Relocated "msvc" and "wince" project subdirectories into "dll" subdirectory. - Updated png.rc in dll/msvc project - Revised makefile.dec to define and use LIBPATH and INCPATH - Increased size of global png_libpng_ver[] array from 12 to 18 chars. - Made global png_libpng_ver[], png_sig[] and png_pass_*[] arrays const. - Removed duplicate png_crc_finish() from png_handle_bKGD() function. - Added a warning when application calls png_read_update_info() multiple times. - Revised makefile.cygwin - Fixed bugs in iCCP support in pngrutil.c and pngwutil.c. - Replaced png_set_empty_plte_permitted() with png_permit_mng_features(). -version 1.0.9beta2 [November 19, 2000] - Renamed the "dll" subdirectory "projects". - Added borland project files to "projects" subdirectory. - Set VS_FF_PRERELEASE and VS_FF_PATCHED flags in msvc/png.rc when appropriate. - Add error message in png_set_compression_buffer_size() when malloc fails. -version 1.0.9beta3 [November 23, 2000] - Revised PNG_LIBPNG_BUILD_TYPE macro in png.h, used in the msvc project. - Removed the png_flush() in pngwrite.c that crashes some applications - that don't set png_output_flush_fn. - Added makefile.macosx and makefile.aix to scripts directory. -version 1.0.9beta4 [December 1, 2000] - Change png_chunk_warning to png_warning in png_check_keyword(). - Increased the first part of msg buffer from 16 to 18 in png_chunk_error(). -version 1.0.9beta5 [December 15, 2000] - Added support for filter method 64 (for PNG datastreams embedded in MNG). -version 1.0.9beta6 [December 18, 2000] - Revised png_set_filter() to accept filter method 64 when appropriate. - Added new PNG_HAVE_PNG_SIGNATURE bit to png_ptr->mode and use it to - help prevent applications from using MNG features in PNG datastreams. - Added png_permit_mng_features() function. - Revised libpng.3/libpng.txt. Changed "filter type" to "filter method". -version 1.0.9rc1 [December 23, 2000] - Revised test for PNG_HAVE_PNG_SIGNATURE in pngrutil.c - Fixed error handling of unknown compression type in png_decompress_chunk(). - In pngconf.h, define __cdecl when _MSC_VER is defined. -version 1.0.9beta7 [December 28, 2000] - Changed PNG_TEXT_COMPRESSION_zTXt to PNG_COMPRESSION_TYPE_BASE several places. - Revised memory management in png_set_hIST and png_handle_hIST in a backward - compatible manner. PLTE and tRNS were revised similarly. - Revised the iCCP chunk reader to ignore trailing garbage. -version 1.0.9beta8 [January 12, 2001] - Moved pngasmrd.h into pngconf.h. - Improved handling of out-of-spec garbage iCCP chunks generated by PhotoShop. -version 1.0.9beta9 [January 15, 2001] - Added png_set_invalid, png_permit_mng_features, and png_mmx_supported to - wince and msvc project module definition files. - Minor revision of makefile.cygwin. - Fixed bug with progressive reading of narrow interlaced images in pngpread.c -version 1.0.9beta10 [January 16, 2001] - Do not typedef png_FILE_p in pngconf.h when PNG_NO_STDIO is defined. - Fixed "png_mmx_supported" typo in project definition files. -version 1.0.9beta11 [January 19, 2001] - Updated makefile.sgi to make shared library. - Removed png_mmx_support() function and disabled PNG_MNG_FEATURES_SUPPORTED - by default, for the benefit of DLL forward compatibility. These will - be re-enabled in version 1.2.0. -version 1.0.9rc2 [January 22, 2001] - Revised cygwin support. - -version 1.0.9 [January 31, 2001] - Added check of cygwin's ALL_STATIC in pngconf.h - Added "-nommx" parameter to contrib/gregbook/rpng2-win and rpng2-x demos. -version 1.0.10beta1 [March 14, 2001] - Revised makefile.dec, makefile.sgi, and makefile.sggcc; added makefile.hpgcc. - Reformatted libpng.3 to eliminate bad line breaks. - Added checks for _mmx_supported in the read_filter_row function of pnggccrd.c - Added prototype for png_mmx_support() near the top of pnggccrd.c - Moved some error checking from png_handle_IHDR to png_set_IHDR. - Added PNG_NO_READ_SUPPORTED and PNG_NO_WRITE_SUPPORTED macros. - Revised png_mmx_support() function in pnggccrd.c - Restored version 1.0.8 PNG_WRITE_EMPTY_PLTE_SUPPORTED behavior in pngwutil.c - Fixed memory leak in contrib/visupng/PngFile.c - Fixed bugs in png_combine_row() in pnggccrd.c and pngvcrd.c (C version) - Added warnings when retrieving or setting gamma=0. - Increased the first part of msg buffer from 16 to 18 in png_chunk_warning(). -version 1.0.10rc1 [March 23, 2001] - Changed all instances of memcpy, strcpy, and strlen to png_memcpy, png_strcpy, - and png_strlen. - Revised png_mmx_supported() function in pnggccrd.c to return proper value. - Fixed bug in progressive reading (pngpread.c) with small images (height < 8). - -version 1.0.10 [March 30, 2001] - Deleted extraneous space (introduced in 1.0.9) from line 42 of makefile.cygwin - Added beos project files (Chris Herborth) -version 1.0.11beta1 [April 3, 2001] - Added type casts on several png_malloc() calls (Dimitri Papadapoulos). - Removed a no-longer needed AIX work-around from pngconf.h - Changed several "//" single-line comments to C-style in pnggccrd.c -version 1.0.11beta2 [April 11, 2001] - Removed PNGAPI from several functions whose prototypes did not have PNGAPI. - Updated scripts/pngos2.def -version 1.0.11beta3 [April 14, 2001] - Added checking the results of many instances of png_malloc() for NULL -version 1.0.11beta4 [April 20, 2001] - Undid the changes from version 1.0.11beta3. Added a check for NULL return - from user's malloc_fn(). - Removed some useless type casts of the NULL pointer. - Added makefile.netbsd - -version 1.0.11 [April 27, 2001] - Revised makefile.netbsd -version 1.0.12beta1 [May 14, 2001] - Test for Windows platform in pngconf.h when including malloc.h (Emmanuel Blot) - Updated makefile.cygwin and handling of Cygwin's ALL_STATIC in pngconf.h - Added some never-to-be-executed code in pnggccrd.c to quiet compiler warnings. - Eliminated the png_error about apps using png_read|write_init(). Instead, - libpng will reallocate the png_struct and info_struct if they are too small. - This retains future binary compatibility for old applications written for - libpng-0.88 and earlier. -version 1.2.0beta1 [May 6, 2001] - Bumped DLLNUM to 2. - Re-enabled PNG_MNG_FEATURES_SUPPORTED and enabled PNG_ASSEMBLER_CODE_SUPPORTED - by default. - Added runtime selection of MMX features. - Added png_set_strip_error_numbers function and related macros. -version 1.2.0beta2 [May 7, 2001] - Finished merging 1.2.0beta1 with version 1.0.11 - Added a check for attempts to read or write PLTE in grayscale PNG datastreams. -version 1.2.0beta3 [May 17, 2001] - Enabled user memory function by default. - Modified png_create_struct so it passes user mem_ptr to user memory allocator. - Increased png_mng_features flag from png_byte to png_uint_32. - Bumped shared-library (so-number) and dll-number to 3. -version 1.2.0beta4 [June 23, 2001] - Check for missing profile length field in iCCP chunk and free chunk_data - in case of truncated iCCP chunk. - Bumped shared-library number to 3 in makefile.sgi and makefile.sggcc - Bumped dll-number from 2 to 3 in makefile.cygwin - Revised contrib/gregbook/rpng*-x.c to avoid a memory leak and to exit cleanly - if user attempts to run it on an 8-bit display. - Updated contrib/gregbook - Use png_malloc instead of png_zalloc to allocate palette in pngset.c - Updated makefile.ibmc - Added some typecasts to eliminate gcc 3.0 warnings. Changed prototypes - of png_write_oFFS width and height from png_uint_32 to png_int_32. - Updated example.c - Revised prototypes for png_debug_malloc and png_debug_free in pngtest.c -version 1.2.0beta5 [August 8, 2001] - Revised contrib/gregbook - Revised makefile.gcmmx - Revised pnggccrd.c to conditionally compile some thread-unsafe code only - when PNG_THREAD_UNSAFE_OK is defined. - Added tests to prevent pngwutil.c from writing a bKGD or tRNS chunk with - value exceeding 2^bit_depth-1 - Revised makefile.sgi and makefile.sggcc - Replaced calls to fprintf(stderr,...) with png_warning() in pnggccrd.c - Removed restriction that do_invert_mono only operate on 1-bit opaque files - -version 1.2.0 [September 1, 2001] - Changed a png_warning() to png_debug() in pnggccrd.c - Fixed contrib/gregbook/rpng-x.c, rpng2-x.c to avoid crash with XFreeGC(). -version 1.2.1beta1 [October 19, 2001] - Revised makefile.std in contrib/pngminus - Include background_1 in png_struct regardless of gamma support. - Revised makefile.netbsd and makefile.macosx, added makefile.darwin. - Revised example.c to provide more details about using row_callback(). -version 1.2.1beta2 [October 25, 2001] - Added type cast to each NULL appearing in a function call, except for - WINCE functions. - Added makefile.so9. -version 1.2.1beta3 [October 27, 2001] - Removed type casts from all NULLs. - Simplified png_create_struct_2(). -version 1.2.1beta4 [November 7, 2001] - Revised png_create_info_struct() and png_creat_struct_2(). - Added error message if png_write_info() was omitted. - Type cast NULLs appearing in function calls when _NO_PROTO or - PNG_TYPECAST_NULL is defined. -version 1.2.1rc1 [November 24, 2001] - Type cast NULLs appearing in function calls except when PNG_NO_TYPECAST_NULL - is defined. - Changed typecast of "size" argument to png_size_t in pngmem.c calls to - the user malloc_fn, to agree with the prototype in png.h - Added a pop/push operation to pnggccrd.c, to preserve Eflag (Maxim Sobolev) - Updated makefile.sgi to recognize LIBPATH and INCPATH. - Updated various makefiles so "make clean" does not remove previous major - version of the shared library. -version 1.2.1rc2 [December 4, 2001] - Always allocate 256-entry internal palette, hist, and trans arrays, to - avoid out-of-bounds memory reference caused by invalid PNG datastreams. - Added a check for prefix_length > data_length in iCCP chunk handler. - -version 1.2.1 [December 7, 2001] - None. -version 1.2.2beta1 [February 22, 2002] - Fixed a bug with reading the length of iCCP profiles (Larry Reeves). - Revised makefile.linux, makefile.gcmmx, and makefile.sgi to generate - libpng.a, libpng12.so (not libpng.so.3), and libpng12/png.h - Revised makefile.darwin to remove "-undefined suppress" option. - Added checks for gamma and chromaticity values over 21474.83, which exceed - the limit for PNG unsigned 32-bit integers when encoded. - Revised calls to png_create_read_struct() and png_create_write_struct() - for simpler debugging. - Revised png_zalloc() so zlib handles errors (uses PNG_FLAG_MALLOC_NULL_MEM_OK) -version 1.2.2beta2 [February 23, 2002] - Check chunk_length and idat_size for invalid (over PNG_MAX_UINT) lengths. - Check for invalid image dimensions in png_get_IHDR. - Added missing "fi;" in the install target of the SGI makefiles. - Added install-static to all makefiles that make shared libraries. - Always do gamma compensation when image is partially transparent. -version 1.2.2beta3 [March 7, 2002] - Compute background.gray and background_1.gray even when color_type is RGB - in case image gets reduced to gray later. - Modified shared-library makefiles to install pkgconfig/libpngNN.pc. - Export (with PNGAPI) png_zalloc, png_zfree, and png_handle_as_unknown - Removed unused png_write_destroy_info prototype from png.h - Eliminated incorrect use of width_mmx from pnggccrd.c in pixel_bytes == 8 case - Added install-shared target to all makefiles that make shared libraries. - Stopped a double free of palette, hist, and trans when not using free_me. - Added makefile.32sunu for Sun Ultra 32 and makefile.64sunu for Sun Ultra 64. -version 1.2.2beta4 [March 8, 2002] - Compute background.gray and background_1.gray even when color_type is RGB - in case image gets reduced to gray later (Jason Summers). - Relocated a misplaced /bin/rm in the "install-shared" makefile targets - Added PNG_1_0_X macro which can be used to build a 1.0.x-compatible library. -version 1.2.2beta5 [March 26, 2002] - Added missing PNGAPI to several function definitions. - Check for invalid bit_depth or color_type in png_get_IHDR(), and - check for missing PLTE or IHDR in png_push_read_chunk() (Matthias Clasen). - Revised iTXt support to accept NULL for lang and lang_key. - Compute gamma for color components of background even when color_type is gray. - Changed "()" to "{}" in scripts/libpng.pc.in. - Revised makefiles to put png.h and pngconf.h only in $prefix/include/libpngNN - Revised makefiles to make symlink to libpng.so.NN in addition to libpngNN.so -version 1.2.2beta6 [March 31, 2002] -version 1.0.13beta1 [March 31, 2002] - Prevent png_zalloc() from trying to memset memory that it failed to acquire. - Add typecasts of PNG_MAX_UINT in pngset_cHRM_fixed() (Matt Holgate). - Ensure that the right function (user or default) is used to free the - png_struct after an error in png_create_read_struct_2(). -version 1.2.2rc1 [April 7, 2002] -version 1.0.13rc1 [April 7, 2002] - Save the ebx register in pnggccrd.c (Sami Farin) - Add "mem_ptr = png_ptr->mem_ptr" in png_destroy_write_struct() (Paul Gardner). - Updated makefiles to put headers in include/libpng and remove old include/*.h. - -version 1.2.2 [April 15, 2002] -version 1.0.13 [April 15, 2002] - Revised description of png_set_filter() in libpng.3/libpng.txt. - Revised makefile.netbsd and added makefile.neNNbsd and makefile.freebsd -version 1.0.13patch01 [April 17, 2002] -version 1.2.2patch01 [April 17, 2002] - Changed ${PNGMAJ}.${PNGVER} bug to ${PNGVER} in makefile.sgi and makefile.sggcc - Fixed VER -> PNGVER typo in makefile.macosx and added install-static to install - Added install: target to makefile.32sunu and makefile.64sunu -version 1.0.13patch03 [April 18, 2002] -version 1.2.2patch03 [April 18, 2002] - Revised 15 makefiles to link libpng.a to libpngNN.a and the include libpng - subdirectory to libpngNN subdirectory without the full pathname. - Moved generation of libpng.pc from "install" to "all" in 15 makefiles. -version 1.2.3rc1 [April 28, 2002] - Added install-man target to 15 makefiles (Dimitri Papadopolous-Orfanos). - Added $(DESTDIR) feature to 24 makefiles (Tim Mooney) - Fixed bug with $prefix, should be $(prefix) in makefile.hpux. - Updated cygwin-specific portion of pngconf.h and revised makefile.cygwin - Added a link from libpngNN.pc to libpng.pc in 15 makefiles. - Added links from include/libpngNN/*.h to include/*.h in 24 makefiles. - Revised makefile.darwin to make relative links without full pathname. - Added setjmp() at the end of png_create_*_struct_2() in case user forgets - to put one in their application. - Restored png_zalloc() and png_zfree() prototypes to version 1.2.1 and - removed them from module definition files. -version 1.2.3rc2 [May 1, 2002] - Fixed bug in reporting number of channels in pngget.c and pngset.c, - that was introduced in version 1.2.2beta5. - Exported png_zalloc(), png_zfree(), png_default_read(), png_default_write(), - png_default_flush(), and png_push_fill_buffer() and included them in - module definition files. - Added "libpng.pc" dependency to the "install-shared" target in 15 makefiles. -version 1.2.3rc3 [May 1, 2002] - Revised prototype for png_default_flush() - Remove old libpng.pc and libpngNN.pc before installing new ones. -version 1.2.3rc4 [May 2, 2002] - Typos in *.def files (png_default_read|write -> png_default_read|write_data) - In makefiles, changed rm libpng.NN.pc to rm libpngNN.pc - Added libpng-config and libpngNN-config and modified makefiles to install them. - Changed $(MANPATH) to $(DESTDIR)$(MANPATH) in makefiles - Added "Win32 DLL VB" configuration to projects/msvc/libpng.dsp -version 1.2.3rc5 [May 11, 2002] - Changed "error" and "message" in prototypes to "error_message" and - "warning_message" to avoid namespace conflict. - Revised 15 makefiles to build libpng-config from libpng-config-*.in - Once more restored png_zalloc and png_zfree to regular nonexported form. - Restored png_default_read|write_data, png_default_flush, png_read_fill_buffer - to nonexported form, but with PNGAPI, and removed them from module def files. -version 1.2.3rc6 [May 14, 2002] - Removed "PNGAPI" from png_zalloc() and png_zfree() in png.c - Changed "Gz" to "Gd" in projects/msvc/libpng.dsp and zlib.dsp. - Removed leftover libpng-config "sed" script from four makefiles. - Revised libpng-config creating script in 16 makefiles. - -version 1.2.3 [May 22, 2002] - Revised libpng-config target in makefile.cygwin. - Removed description of png_set_mem_fn() from documentation. - Revised makefile.freebsd. - Minor cosmetic changes to 15 makefiles, e.g., $(DI) = $(DESTDIR)/$(INCDIR). - Revised projects/msvc/README.txt - Changed -lpng to -lpngNN in LDFLAGS in several makefiles. -version 1.2.4beta1 [May 24, 2002] - Added libpng.pc and libpng-config to "all:" target in 16 makefiles. - Fixed bug in 16 makefiles: $(DESTDIR)/$(LIBPATH) to $(DESTDIR)$(LIBPATH) - Added missing "\" before closing double quote in makefile.gcmmx. - Plugged various memory leaks; added png_malloc_warn() and png_set_text_2() - functions. -version 1.2.4beta2 [June 25, 2002] - Plugged memory leak of png_ptr->current_text (Matt Holgate). - Check for buffer overflow before reading CRC in pngpread.c (Warwick Allison) - Added -soname to the loader flags in makefile.dec, makefile.sgi, and - makefile.sggcc. - Added "test-installed" target to makefile.linux, makefile.gcmmx, - makefile.sgi, and makefile.sggcc. -version 1.2.4beta3 [June 28, 2002] - Plugged memory leak of row_buf in pngtest.c when there is a png_error(). - Detect buffer overflow in pngpread.c when IDAT is corrupted with extra data. - Added "test-installed" target to makefile.32sunu, makefile.64sunu, - makefile.beos, makefile.darwin, makefile.dec, makefile.macosx, - makefile.solaris, makefile.hpux, makefile.hpgcc, and makefile.so9. -version 1.2.4rc1 and 1.0.14rc1 [July 2, 2002] - Added "test-installed" target to makefile.cygwin and makefile.sco. - Revised pnggccrd.c to be able to back out version 1.0.x via PNG_1_0_X macro. - -version 1.2.4 and 1.0.14 [July 8, 2002] - Changed png_warning() to png_error() when width is too large to process. -version 1.2.4patch01 [July 20, 2002] - Revised makefile.cygwin to use DLL number 12 instead of 13. -version 1.2.5beta1 [August 6, 2002] - Added code to contrib/gregbook/readpng2.c to ignore unused chunks. - Replaced toucan.png in contrib/gregbook (it has been corrupt since 1.0.11) - Removed some stray *.o files from contrib/gregbook. - Changed png_error() to png_warning() about "Too much data" in pngpread.c - and about "Extra compressed data" in pngrutil.c. - Prevent png_ptr->pass from exceeding 7 in png_push_finish_row(). - Updated makefile.hpgcc - Updated png.c and pnggccrd.c handling of return from png_mmx_support() -version 1.2.5beta2 [August 15, 2002] - Only issue png_warning() about "Too much data" in pngpread.c when avail_in - is nonzero. - Updated makefiles to install a separate libpng.so.3 with its own rpath. -version 1.2.5rc1 and 1.0.15rc1 [August 24, 2002] - Revised makefiles to not remove previous minor versions of shared libraries. -version 1.2.5rc2 and 1.0.15rc2 [September 16, 2002] - Revised 13 makefiles to remove "-lz" and "-L$(ZLIBLIB)", etc., from shared - library loader directive. - Added missing "$OBJSDLL" line to makefile.gcmmx. - Added missing "; fi" to makefile.32sunu. -version 1.2.5rc3 and 1.0.15rc3 [September 18, 2002] - Revised libpng-config script. - -version 1.2.5 and 1.0.15 [October 3, 2002] - Revised makefile.macosx, makefile.darwin, makefile.hpgcc, and makefile.hpux, - and makefile.aix. - Relocated two misplaced PNGAPI lines in pngtest.c -version 1.2.6beta1 [October 22, 2002] - Commented out warning about uninitialized mmx_support in pnggccrd.c. - Changed "IBMCPP__" flag to "__IBMCPP__" in pngconf.h. - Relocated two more misplaced PNGAPI lines in pngtest.c - Fixed memory overrun bug in png_do_read_filler() with 16-bit datastreams, - introduced in version 1.0.2. - Revised makefile.macosx, makefile.dec, makefile.aix, and makefile.32sunu. -version 1.2.6beta2 [November 1, 2002] - Added libpng-config "--ldopts" output. - Added "AR=ar" and "ARFLAGS=rc" and changed "ar rc" to "$(AR) $(ARFLAGS)" - in makefiles. -version 1.2.6beta3 [July 18, 2004] - Reverted makefile changes from version 1.2.6beta2 and some of the changes - from version 1.2.6beta1; these will be postponed until version 1.2.7. - Version 1.2.6 is going to be a simple bugfix release. - Changed the one instance of "ln -sf" to "ln -f -s" in each Sun makefile. - Fixed potential overrun in pngerror.c by using strncpy instead of memcpy. - Added "#!/bin/sh" at the top of configure, for recognition of the - 'x' flag under Cygwin (Cosmin). - Optimized vacuous tests that silence compiler warnings, in png.c (Cosmin). - Added support for PNG_USER_CONFIG, in pngconf.h (Cosmin). - Fixed the special memory handler for Borland C under DOS, in pngmem.c - (Cosmin). - Removed some spurious assignments in pngrutil.c (Cosmin). - Replaced 65536 with 65536L, and 0xffff with 0xffffL, to silence warnings - on 16-bit platforms (Cosmin). - Enclosed shift op expressions in parentheses, to silence warnings (Cosmin). - Used proper type png_fixed_point, to avoid problems on 16-bit platforms, - in png_handle_sRGB() (Cosmin). - Added compression_type to png_struct, and optimized the window size - inside the deflate stream (Cosmin). - Fixed definition of isnonalpha(), in pngerror.c and pngrutil.c (Cosmin). - Fixed handling of unknown chunks that come after IDAT (Cosmin). - Allowed png_error() and png_warning() to work even if png_ptr == NULL - (Cosmin). - Replaced row_info->rowbytes with row_bytes in png_write_find_filter() - (Cosmin). - Fixed definition of PNG_LIBPNG_VER_DLLNUM (Simon-Pierre). - Used PNG_LIBPNG_VER and PNG_LIBPNG_VER_STRING instead of the hardcoded - values in png.c (Simon-Pierre, Cosmin). - Initialized png_libpng_ver[] with PNG_LIBPNG_VER_STRING (Simon-Pierre). - Replaced PNG_LIBPNG_VER_MAJOR with PNG_LIBPNG_VER_DLLNUM in png.rc - (Simon-Pierre). - Moved the definition of PNG_HEADER_VERSION_STRING near the definitions - of the other PNG_LIBPNG_VER_... symbols in png.h (Cosmin). - Relocated #ifndef PNGAPI guards in pngconf.h (Simon-Pierre, Cosmin). - Updated scripts/makefile.vc(a)win32 (Cosmin). - Updated the MSVC project (Simon-Pierre, Cosmin). - Updated the Borland C++ Builder project (Cosmin). - Avoided access to asm_flags in pngvcrd.c, if PNG_1_0_X is defined (Cosmin). - Commented out warning about uninitialized mmx_support in pngvcrd.c (Cosmin). - Removed scripts/makefile.bd32 and scripts/pngdef.pas (Cosmin). - Added extra guard around inclusion of Turbo C memory headers, in pngconf.h - (Cosmin). - Renamed projects/msvc/ to projects/visualc6/, and projects/borland/ to - projects/cbuilder5/ (Cosmin). - Moved projects/visualc6/png32ms.def to scripts/pngw32.def, - and projects/visualc6/png.rc to scripts/pngw32.rc (Cosmin). - Added projects/visualc6/pngtest.dsp; removed contrib/msvctest/ (Cosmin). - Changed line endings to DOS style in cbuilder5 and visualc6 files, even - in the tar.* distributions (Cosmin). - Updated contrib/visupng/VisualPng.dsp (Cosmin). - Updated contrib/visupng/cexcept.h to version 2.0.0 (Cosmin). - Added a separate distribution with "configure" and supporting files (Junichi). -version 1.2.6beta4 [July 28, 2004] - Added user ability to change png_size_t via a PNG_SIZE_T macro. - Added png_sizeof() and png_convert_size() functions. - Added PNG_SIZE_MAX (maximum value of a png_size_t variable. - Added check in png_malloc_default() for (size_t)size != (png_uint_32)size - which would indicate an overflow. - Changed sPLT failure action from png_error to png_warning and abandon chunk. - Changed sCAL and iCCP failures from png_error to png_warning and abandon. - Added png_get_uint_31(png_ptr, buf) function. - Added PNG_UINT_32_MAX macro. - Renamed PNG_MAX_UINT to PNG_UINT_31_MAX. - Made png_zalloc() issue a png_warning and return NULL on potential - overflow. - Turn on PNG_NO_ZALLOC_ZERO by default in version 1.2.x - Revised "clobber list" in pnggccrd.c so it will compile under gcc-3.4. - Revised Borland portion of png_malloc() to return NULL or issue - png_error() according to setting of PNG_FLAG_MALLOC_NULL_MEM_OK. - Added PNG_NO_SEQUENTIAL_READ_SUPPORTED macro to conditionally remove - sequential read support. - Added some "#if PNG_WRITE_SUPPORTED" blocks. - #ifdef'ed out some redundancy in png_malloc_default(). - Use png_malloc instead of png_zalloc to allocate the pallete. -version 1.0.16rc1 and 1.2.6rc1 [August 4, 2004] - Fixed buffer overflow vulnerability in png_handle_tRNS() - Fixed integer arithmetic overflow vulnerability in png_read_png(). - Fixed some harmless bugs in png_handle_sBIT, etc, that would cause - duplicate chunk types to go undetected. - Fixed some timestamps in the -config version - Rearranged order of processing of color types in png_handle_tRNS(). - Added ROWBYTES macro to calculate rowbytes without integer overflow. - Updated makefile.darwin and removed makefile.macosx from scripts directory. - Imposed default one million column, one-million row limits on the image - dimensions, and added png_set_user_limits() function to override them. - Revised use of PNG_SET_USER_LIMITS_SUPPORTED macro. - Fixed wrong cast of returns from png_get_user_width|height_max(). - Changed some "keep the compiler happy" from empty statements to returns, - Revised libpng.txt to remove 1.2.x stuff from the 1.0.x distribution -version 1.0.16rc2 and 1.2.6rc2 [August 7, 2004] - Revised makefile.darwin and makefile.solaris. Removed makefile.macosx. - Revised pngtest's png_debug_malloc() to use png_malloc() instead of - png_malloc_default() which is not supposed to be exported. - Fixed off-by-one error in one of the conversions to PNG_ROWBYTES() in - pngpread.c. Bug was introduced in 1.2.6rc1. - Fixed bug in RGB to RGBX transformation introduced in 1.2.6rc1. - Fixed old bug in RGB to Gray transformation. - Fixed problem with 64-bit compilers by casting arguments to abs() - to png_int_32. - Changed "ln -sf" to "ln -f -s" in three makefiles (solaris, sco, so9). - Changed "HANDLE_CHUNK_*" to "PNG_HANDLE_CHUNK_*" (Cosmin) - Added "-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)" to 15 *NIX makefiles. - Added code to update the row_info->colortype in png_do_read_filler() (MSB). -version 1.0.16rc3 and 1.2.6rc3 [August 9, 2004] - Eliminated use of "abs()" in testing cHRM and gAMA values, to avoid - trouble with some 64-bit compilers. Created PNG_OUT_OF_RANGE() macro. - Revised documentation of png_set_keep_unknown_chunks(). - Check handle_as_unknown status in pngpread.c, as in pngread.c previously. - Moved "PNG_HANDLE_CHUNK_*" macros out of PNG_INTERNAL section of png.h - Added "rim" definitions for CONST4 and CONST6 in pnggccrd.c -version 1.0.16rc4 and 1.2.6rc4 [August 10, 2004] - Fixed mistake in pngtest.c introduced in 1.2.6rc2 (declaration of - "pinfo" was out of place). -version 1.0.16rc5 and 1.2.6rc5 [August 10, 2004] - Moved "PNG_HANDLE_CHUNK_*" macros out of PNG_ASSEMBLER_CODE_SUPPORTED - section of png.h where they were inadvertently placed in version rc3. - -version 1.2.6 and 1.0.16 [August 15, 2004] - Revised pngtest so memory allocation testing is only done when PNG_DEBUG==1. -version 1.2.7beta1 [August 26, 2004] - Removed unused pngasmrd.h file. - Removed references to uu.net for archived files. Added references to - PNG Spec (second edition) and the PNG ISO/IEC Standard. - Added "test-dd" target in 15 makefiles, to run pngtest in DESTDIR. - Fixed bug with "optimized window size" in the IDAT datastream, that - causes libpng to write PNG files with incorrect zlib header bytes. -version 1.2.7beta2 [August 28, 2004] - Fixed bug with sCAL chunk and big-endian machines (David Munro). - Undid new code added in 1.2.6rc2 to update the color_type in - png_set_filler(). - Added png_set_add_alpha() that updates color type. -version 1.0.17rc1 and 1.2.7rc1 [September 4, 2004] - Revised png_set_strip_filler() to not remove alpha if color_type has alpha. - -version 1.2.7 and 1.0.17 [September 12, 2004] - Added makefile.hp64 - Changed projects/msvc/png32ms.def to scripts/png32ms.def in makefile.cygwin -version 1.2.8beta1 [November 1, 2004] - Fixed bug in png_text_compress() that would fail to complete a large block. - Fixed bug, introduced in libpng-1.2.7, that overruns a buffer during - strip alpha operation in png_do_strip_filler(). - Added PNG_1_2_X definition in pngconf.h - #ifdef out png_info_init in png.c and png_read_init in pngread.c (as of 1.3.0) -version 1.2.8beta2 [November 2, 2004] - Reduce color_type to a nonalpha type after strip alpha operation in - png_do_strip_filler(). -version 1.2.8beta3 [November 3, 2004] - Revised definitions of PNG_MAX_UINT_32, PNG_MAX_SIZE, and PNG_MAXSUM -version 1.2.8beta4 [November 12, 2004] - Fixed (again) definition of PNG_LIBPNG_VER_DLLNUM in png.h (Cosmin). - Added PNG_LIBPNG_BUILD_PRIVATE in png.h (Cosmin). - Set png_ptr->zstream.data_type to Z_BINARY, to avoid unnecessary detection - of data type in deflate (Cosmin). - Deprecated but continue to support SPECIALBUILD and PRIVATEBUILD in favor of - PNG_LIBPNG_BUILD_SPECIAL_STRING and PNG_LIBPNG_BUILD_PRIVATE_STRING. -version 1.2.8beta5 [November 20, 2004] - Use png_ptr->flags instead of png_ptr->transformations to pass - PNG_STRIP_ALPHA info to png_do_strip_filler(), to preserve ABI - compatibility. - Revised handling of SPECIALBUILD, PRIVATEBUILD, - PNG_LIBPNG_BUILD_SPECIAL_STRING and PNG_LIBPNG_BUILD_PRIVATE_STRING. -version 1.2.8rc1 [November 24, 2004] - Moved handling of BUILD macros from pngconf.h to png.h - Added definition of PNG_LIBPNG_BASE_TYPE in png.h, inadvertently - omitted from beta5. - Revised scripts/pngw32.rc - Despammed mailing addresses by masking "@" with "at". - Inadvertently installed a supposedly faster test version of pngrutil.c -version 1.2.8rc2 [November 26, 2004] - Added two missing "\" in png.h - Change tests in pngread.c and pngpread.c to - if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA)) - png_do_read_transformations(png_ptr); -version 1.2.8rc3 [November 28, 2004] - Reverted pngrutil.c to version libpng-1.2.8beta5. - Added scripts/makefile.elf with supporting code in pngconf.h for symbol - versioning (John Bowler). -version 1.2.8rc4 [November 29, 2004] - Added projects/visualc7 (Simon-pierre). -version 1.2.8rc5 [November 29, 2004] - Fixed new typo in scripts/pngw32.rc - -version 1.2.8 [December 3, 2004] - Removed projects/visualc7, added projects/visualc71. - -version 1.2.9beta1 [February 21, 2006] - - Initialized some structure members in pngwutil.c to avoid gcc-4.0.0 complaints - Revised man page and libpng.txt to make it clear that one should not call - png_read_end or png_write_end after png_read_png or png_write_png. - Updated references to png-mng-implement mailing list. - Fixed an incorrect typecast in pngrutil.c - Added PNG_NO_READ_SUPPORTED conditional for making a write-only library. - Added PNG_NO_WRITE_INTERLACING_SUPPORTED conditional. - Optimized alpha-inversion loops in pngwtran.c - Moved test for nonzero gamma outside of png_build_gamma_table() in pngrtran.c - Make sure num_trans is <= 256 before copying data in png_set_tRNS(). - Make sure num_palette is <= 256 before copying data in png_set_PLTE(). - Interchanged order of write_swap_alpha and write_invert_alpha transforms. - Added parentheses in the definition of PNG_LIBPNG_BUILD_TYPE (Cosmin). - Optimized zlib window flag (CINFO) in contrib/pngsuite/*.png (Cosmin). - Updated scripts/makefile.bc32 for Borland C++ 5.6 (Cosmin). - Exported png_get_uint_32, png_save_uint_32, png_get_uint_16, png_save_uint_16, - png_get_int_32, png_save_int_32, png_get_uint_31 (Cosmin). - Added type cast (png_byte) in png_write_sCAL() (Cosmin). - Fixed scripts/makefile.cygwin (Christian Biesinger, Cosmin). - Default iTXt support was inadvertently enabled. - -version 1.2.9beta2 [February 21, 2006] - - Check for png_rgb_to_gray and png_gray_to_rgb read transformations before - checking for png_read_dither in pngrtran.c - Revised checking of chromaticity limits to accommodate extended RGB - colorspace (John Denker). - Changed line endings in some of the project files to CRLF, even in the - "Unix" tar distributions (Cosmin). - Made png_get_int_32 and png_save_int_32 always available (Cosmin). - Updated scripts/pngos2.def, scripts/pngw32.def and projects/wince/png32ce.def - with the newly exported functions. - Eliminated distributions without the "configure" script. - Updated INSTALL instructions. - -version 1.2.9beta3 [February 24, 2006] - - Fixed CRCRLF line endings in contrib/visupng/VisualPng.dsp - Made libpng.pc respect EXEC_PREFIX (D. P. Kreil, J. Bowler) - Removed reference to pngasmrd.h from Makefile.am - Renamed CHANGES to ChangeLog. - Renamed LICENSE to COPYING. - Renamed ANNOUNCE to NEWS. - Created AUTHORS file. - -version 1.2.9beta4 [March 3, 2006] - - Changed definition of PKGCONFIG from $prefix/lib to $libdir in configure.ac - Reverted to filenames LICENSE and ANNOUNCE; removed AUTHORS and COPYING. - Removed newline from the end of some error and warning messages. - Removed test for sqrt() from configure.ac and configure. - Made swap tables in pngtrans.c PNG_CONST (Carlo Bramix). - Disabled default iTXt support that was inadvertently enabled in - libpng-1.2.9beta1. - Added "OS2" to list of systems that don't need underscores, in pnggccrd.c - Removed libpng version and date from *.c files. - -version 1.2.9beta5 [March 4, 2006] - Removed trailing blanks from source files. - Put version and date of latest change in each source file, and changed - copyright year accordingly. - More cleanup of configure.ac, Makefile.ac, and associated scripts. - Restored scripts/makefile.elf which was inadvertently deleted. - -version 1.2.9beta6 [March 6, 2006] - Fixed typo (18) in configuration files. - -version 1.2.9beta7 [March 7, 2006] - Removed libpng.vers and libpng.sym from libpng12_la_SOURCES in Makefile.am - Fixed inconsistent #ifdef's around png_sig_bytes() and png_set_sCAL_s() - in png.h. - Updated makefile.elf as suggested by debian. - Made cosmetic changes to some makefiles, adding LN_SF and other macros. - Made some makefiles accept "exec_prefix". - -version 1.2.9beta8 [March 9, 2006] - Fixed some "#if defined (..." which should be "#if defined(..." - Bug introduced in libpng-1.2.8. - Fixed inconsistency in definition of png_default_read_data() - Restored blank that was lost from makefile.sggcc "clean" target in beta7. - Revised calculation of "current" and "major" for irix in ltmain.sh - Changed "mkdir" to "MKDIR_P" in some makefiles. - Separated PNG_EXPAND and PNG_EXPAND_tRNS. - Added png_set_expand_gray_1_2_4_to_8() and deprecated - png_set_gray_1_2_4_to_8() which also expands tRNS to alpha. - -version 1.2.9beta9 [March 10, 2006] - Include "config.h" in pngconf.h when available. - Added some checks for NULL png_ptr or NULL info_ptr (timeless) - -version 1.2.9beta10 [March 20, 2006] - Removed extra CR from contrib/visualpng/VisualPng.dsw (Cosmin) - Made pnggccrd.c PIC-compliant (Christian Aichinger). - Added makefile.mingw (Wolfgang Glas). - Revised pngconf.h MMX checking. - -version 1.2.9beta11 [March 22, 2006] - Fixed out-of-order declaration in pngwrite.c that was introduced in beta9 - Simplified some makefiles by using LIBSO, LIBSOMAJ, and LIBSOVER macros. - -version 1.2.9rc1 [March 31, 2006] - Defined PNG_USER_PRIVATEBUILD when including "pngusr.h" (Cosmin). - Removed nonsensical assertion check from pngtest.c (Cosmin). - -version 1.2.9 [April 14, 2006] - Revised makefile.beos and added "none" selector in ltmain.sh - -version 1.2.10beta1 [April 15, 2006] - Renamed "config.h" to "png_conf.h" and revised Makefile.am to add - -DPNG_BUILDING_LIBPNG to compile directive, and modified pngconf.h - to include png_conf.h only when PNG_BUILDING_LIBPNG is defined. - -version 1.2.10beta2 [April 15, 2006] - Manually updated Makefile.in and configure. Changed png_conf.h.in - back to config.h. - -version 1.2.10beta3 [April 15, 2006] - Change png_conf.h back to config.h in pngconf.h. - -version 1.2.10beta4 [April 16, 2006] - Change PNG_BUILDING_LIBPNG to PNG_CONFIGURE_LIBPNG in config/Makefile*. - -version 1.2.10beta5 [April 16, 2006] - Added a configure check for compiling assembler code in pnggccrd.c - -version 1.2.10beta6 [April 17, 2006] - Revised the configure check for pnggccrd.c - Moved -DPNG_CONFIGURE_LIBPNG into @LIBPNG_DEFINES@ - Added @LIBPNG_DEFINES@ to arguments when building libpng.sym - -version 1.2.10beta7 [April 18, 2006] - Change "exec_prefix=$prefix" to "exec_prefix=$(prefix)" in makefiles. - -version 1.2.10rc1 [April 19, 2006] - Ensure pngconf.h doesn't define both PNG_USE_PNGGCCRD and PNG_USE_PNGVCRD - Fixed "LN_FS" typo in makefile.sco and makefile.solaris. - -version 1.2.10rc2 [April 20, 2006] - Added a backslash between -DPNG_CONFIGURE_LIBPNG and -DPNG_NO_ASSEMBLER_CODE - in configure.ac and configure - Made the configure warning about versioned symbols less arrogant. - -version 1.2.10rc3 [April 21, 2006] - Added a note in libpng.txt that png_set_sig_bytes(8) can be used when - writing an embedded PNG without the 8-byte signature. - Revised makefiles and configure to avoid making links to libpng.so.* - -version 1.2.10 [April 23, 2006] - Reverted configure to "rc2" state. - -version 1.2.11beta1 [May 31, 2006] - scripts/libpng.pc.in contained "configure" style version info and would - not work with makefiles. - The shared-library makefiles were linking to libpng.so.0 instead of - libpng.so.3 compatibility as the library. - -version 1.2.11beta2 [June 2, 2006] - Increased sprintf buffer from 50 to 52 chars in pngrutil.c to avoid - buffer overflow. - Fixed bug in example.c (png_set_palette_rgb -> png_set_palette_to_rgb) - -version 1.2.11beta3 [June 5, 2006] - Prepended "#! /bin/sh" to ltmail.sh and contrib/pngminus/*.sh (Cosmin). - Removed the accidental leftover Makefile.in~ (Cosmin). - Avoided potential buffer overflow and optimized buffer in - png_write_sCAL(), png_write_sCAL_s() (Cosmin). - Removed the include directories and libraries from CFLAGS and LDFLAGS - in scripts/makefile.gcc (Nelson A. de Oliveira, Cosmin). - -version 1.2.11beta4 [June 6, 2006] - Allow zero-length IDAT chunks after the entire zlib datastream, but not - after another intervening chunk type. - -version 1.0.19rc1, 1.2.11rc1 [June 13, 2006] - Deleted extraneous square brackets from [config.h] in configure.ac - -version 1.0.19rc2, 1.2.11rc2 [June 14, 2006] - Added prototypes for PNG_INCH_CONVERSIONS functions to png.h - Revised INSTALL and autogen.sh - Fixed typo in several makefiles (-W1 should be -Wl) - Added typedef for png_int_32 and png_uint_32 on 64-bit systems. - -version 1.0.19rc3, 1.2.11rc3 [June 15, 2006] - Removed the new typedefs for 64-bit systems (delay until version 1.4.0) - Added one zero element to png_gamma_shift[] array in pngrtran.c to avoid - reading out of bounds. - -version 1.0.19rc4, 1.2.11rc4 [June 15, 2006] - Really removed the new typedefs for 64-bit systems. - -version 1.0.19rc5, 1.2.11rc5 [June 22, 2006] - Removed png_sig_bytes entry from scripts/pngw32.def - -version 1.0.19, 1.2.11 [June 26, 2006] - None. - -version 1.0.20, 1.2.12 [June 27, 2006] - Really increased sprintf buffer from 50 to 52 chars in pngrutil.c to avoid - buffer overflow. - -version 1.2.13beta1 [October 2, 2006] - Removed AC_FUNC_MALLOC from configure.ac - Work around Intel-Mac compiler bug by setting PNG_NO_MMX_CODE in pngconf.h - Change "logical" to "bitwise" throughout documentation. - Detect and fix attempt to write wrong iCCP profile length. - -version 1.0.21, 1.2.13 [November 14, 2006] - Fix potential buffer overflow in sPLT chunk handler. - Fix Makefile.am to not try to link to noexistent files. - Check all exported functions for NULL png_ptr. - -version 1.2.14beta1 [November 17, 2006] - Relocated three misplaced tests for NULL png_ptr. - Built Makefile.in with automake-1.9.6 instead of 1.9.2. - Build configure with autoconf-2.60 instead of 2.59 - -version 1.2.14beta2 [November 17, 2006] - Added some typecasts in png_zalloc(). - -version 1.2.14rc1 [November 20, 2006] - Changed "strtod" to "png_strtod" in pngrutil.c - -version 1.0.22, 1.2.14 [November 27, 2006] - Added missing "$(srcdir)" in Makefile.am and Makefile.in - -version 1.2.15beta1 [December 3, 2006] - Generated configure with autoconf-2.61 instead of 2.60 - Revised configure.ac to update libpng.pc and libpng-config. - -version 1.2.15beta2 [December 3, 2006] - Always export MMX asm functions, just stubs if not building pnggccrd.c - -version 1.2.15beta3 [December 4, 2006] - Add "png_bytep" typecast to profile while calculating length in pngwutil.c - -version 1.2.15beta4 [December 7, 2006] - Added scripts/CMakeLists.txt - Changed PNG_NO_ASSEMBLER_CODE to PNG_NO_MMX_CODE in scripts, like 1.4.0beta - -version 1.2.15beta5 [December 7, 2006] - Changed some instances of PNG_ASSEMBLER_* to PNG_MMX_* in pnggccrd.c - Revised scripts/CMakeLists.txt - -version 1.2.15beta6 [December 13, 2006] - Revised scripts/CMakeLists.txt and configure.ac - -version 1.2.15rc1 [December 18, 2006] - Revised scripts/CMakeLists.txt - -version 1.2.15rc2 [December 21, 2006] - Added conditional #undef jmpbuf in pngtest.c to undo #define in AIX headers. - Added scripts/makefile.nommx - -version 1.2.15rc3 [December 25, 2006] - Fixed shared library numbering error that was intruduced in 1.2.15beta6. - -version 1.2.15rc4 [December 27, 2006] - Fixed handling of rgb_to_gray when png_ptr->color.gray isn't set. - -version 1.2.15rc5 [December 31, 2006] - Revised handling of rgb_to_gray. - -version 1.2.15 [January 5, 2007] - Added some (unsigned long) typecasts in pngtest.c to avoid printing errors. - -version 1.2.16beta1 [January 6, 2007] - Fix bugs in makefile.nommx - -version 1.2.16beta2 [January 16, 2007] - Revised scripts/CMakeLists.txt - -version 1.2.16 [January 31, 2007] - No changes. - -version 1.2.17beta1 [March 6, 2007] - Revised scripts/CMakeLists.txt to install both shared and static libraries. - Deleted a redundant line from pngset.c. - -version 1.2.17beta2 [April 26, 2007] - Relocated misplaced test for png_ptr == NULL in pngpread.c - Change "==" to "&" for testing PNG_RGB_TO_GRAY_ERR & PNG_RGB_TO_GRAY_WARN - flags. - Changed remaining instances of PNG_ASSEMBLER_* to PNG_MMX_* - Added pngerror() when write_IHDR fails in deflateInit2(). - Added "const" to some array declarations. - Mention examples of libpng usage in the libpng*.txt and libpng.3 documents. - -version 1.2.17rc1 [May 4, 2007] - No changes. - -version 1.2.17rc2 [May 8, 2007] - Moved several PNG_HAVE_* macros out of PNG_INTERNAL because applications - calling set_unknown_chunk_location() need them. - Changed transformation flag from PNG_EXPAND_tRNS to PNG_EXPAND in - png_set_expand_gray_1_2_4_to_8(). - Added png_ptr->unknown_chunk to hold working unknown chunk data, so it - can be free'ed in case of error. Revised unknown chunk handling in - pngrutil.c and pngpread.c to use this structure. - -version 1.2.17rc3 [May 8, 2007] - Revised symbol-handling in configure script. - -version 1.2.17rc4 [May 10, 2007] - Revised unknown chunk handling to avoid storing unknown critical chunks. - -version 1.0.25 [May 15, 2007] -version 1.2.17 [May 15, 2007] - Added "png_ptr->num_trans=0" before error return in png_handle_tRNS, - to eliminate a vulnerability (CVE-2007-2554, CERT VU#684664) - -version 1.0.26 [May 15, 2007] -version 1.2.18 [May 15, 2007] - Reverted the libpng-1.2.17rc3 change to symbol-handling in configure script - -Send comments/corrections/commendations to png-mng-implement at lists.sf.net -(subscription required; visit -https://lists.sourceforge.net/lists/listinfo/png-mng-implement -to subscribe) -or to glennrp at users.sourceforge.net - -Glenn R-P diff --git a/irrlicht-1.6/source/Irrlicht/libpng/INSTALL b/irrlicht-1.6/source/Irrlicht/libpng/INSTALL deleted file mode 100644 index cd0583c2e..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/INSTALL +++ /dev/null @@ -1,206 +0,0 @@ - -Installing libpng version 1.2.18 - May 15, 2007 - -On Unix/Linux and similar systems, you can simply type - - ./configure [--prefix=/path] - make check - make install - -and ignore the rest of this document. - -If configure does not work on your system and you have a reasonably -up-to-date set of tools, running ./autogen.sh before running ./configure -may fix the problem. You can also run the individual commands in -autogen.sh with the --force option, if supported by your version of -the tools. If you run 'libtoolize --force', though, this will replace -the distributed, patched, version of ltmain.sh with an unpatched version -and your shared library builds may fail to produce libraries with the -correct version numbers. - -Instead, you can use one of the custom-built makefiles in the -"scripts" directory - - cp scripts/makefile.system makefile - make test - make install - -Or you can use one of the "projects" in the "projects" directory. - -If you want to use "cmake" (see www.cmake.org), copy CMakeLists.txt -from the "scripts" directory to this directory and type - - cmake . [-DPNG_MMX=YES] -DCMAKE_INSTALL_PREFIX=/path - make - make install - -Before installing libpng, you must first install zlib, if it -is not already on your system. zlib can usually be found -wherever you got libpng. zlib can be placed in another directory, -at the same level as libpng. - -If your system already has a preinstalled zlib you will still need -to have access to the zlib.h and zconf.h include files that -correspond to the version of zlib that's installed. - -You can rename the directories that you downloaded (they -might be called "libpng-1.2.18" or "lpng109" and "zlib-1.2.1" -or "zlib121") so that you have directories called "zlib" and "libpng". - -Your directory structure should look like this: - - .. (the parent directory) - libpng (this directory) - INSTALL (this file) - README - *.h - *.c - contrib - gregbook - pngminus - pngsuite - visupng - projects - beos - c5builder (Borland) - visualc6 (msvc) - netware.txt - wince.txt - scripts - makefile.* - pngtest.png - etc. - zlib - README - *.h - *.c - contrib - etc. - -If the line endings in the files look funny, you may wish to get the other -distribution of libpng. It is available in both tar.gz (UNIX style line -endings) and zip (DOS style line endings) formats. - -If you are building libpng with MSVC, you can enter the -libpng projects\visualc6 directory and follow the instructions in -projects\visualc6\README.txt. - -You can build libpng for WindowsCE by downloading and installing -the projects\wince directory as instructed in the projects\wince.txt file, and -then following the instructions in the README* files. Similarly, you can -build libpng for Netware or Beos as instructed in projects\netware.txt -or projects\beos. - -Else enter the zlib directory and follow the instructions in zlib/README, -then come back here and run "configure" or choose the appropriate -makefile.sys in the scripts directory. - -The files that are presently available in the scripts directory -include - - CMakeLists.txt => "cmake" script - makefile.std => Generic UNIX makefile (cc, creates static libpng.a) - makefile.elf => Linux/ELF makefile symbol versioning, - gcc, creates libpng12.so.0.1.2.18) - makefile.linux => Linux/ELF makefile - (gcc, creates libpng12.so.0.1.2.18) - makefile.gcmmx => Linux/ELF makefile - (gcc, creates libpng12.so.0.1.2.18, - uses assembler code tuned for Intel MMX platform) - makefile.nommx => Linux/ELF makefile - (gcc, creates libpng12.so.0.1.2.18 - does not use Intel MMX assembler code) - makefile.gcc => Generic makefile (gcc, creates static libpng.a) - makefile.knr => Archaic UNIX Makefile that converts files with - ansi2knr (Requires ansi2knr.c from - ftp://ftp.cs.wisc.edu/ghost) - makefile.aix => AIX/gcc makefile - makefile.cygwin => Cygwin/gcc makefile - makefile.darwin => Darwin makefile, can use on MacosX - makefile.dec => DEC Alpha UNIX makefile - makefile.freebsd => FreeBSD makefile - makefile.hpgcc => HPUX makefile using gcc - makefile.hpux => HPUX (10.20 and 11.00) makefile - makefile.hp64 => HPUX (10.20 and 11.00) makefile, 64-bit - makefile.ibmc => IBM C/C++ version 3.x for Win32 and OS/2 (static) - makefile.intel => Intel C/C++ version 4.0 and later - libpng.icc => Project file for IBM VisualAge/C++ version 4.0 or later - makefile.netbsd => NetBSD/cc makefile, uses PNGGCCRD, makes libpng.so. - makefile.ne12bsd => NetBSD/cc makefile, uses PNGGCCRD, - makes libpng12.so - makefile.openbsd => OpenBSD makefile - makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib) - makefile.sggcc => Silicon Graphics (gcc, - creates libpng12.so.0.1.2.18) - makefile.sunos => Sun makefile - makefile.solaris => Solaris 2.X makefile (gcc, - creates libpng12.so.0.1.2.18) - makefile.so9 => Solaris 9 makefile (gcc, - creates libpng12.so.0.1.2.18) - makefile.32sunu => Sun Ultra 32-bit makefile - makefile.64sunu => Sun Ultra 64-bit makefile - makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc - makefile.mips => MIPS makefile - makefile.acorn => Acorn makefile - makefile.amiga => Amiga makefile - smakefile.ppc => AMIGA smakefile for SAS C V6.58/7.00 PPC compiler - (Requires SCOPTIONS, copied from scripts/SCOPTIONS.ppc) - makefile.atari => Atari makefile - makefile.beos => BEOS makefile for X86 - makefile.bor => Borland makefile (uses bcc) - makefile.bc32 => 32-bit Borland C++ (all modules compiled in C mode) - makefile.tc3 => Turbo C 3.0 makefile - makefile.dj2 => DJGPP 2 makefile - makefile.msc => Microsoft C makefile - makefile.vcawin32 => makefile for Microsoft Visual C++ 5.0 and later (uses - assembler code tuned for Intel MMX platform) - makefile.vcwin32 => makefile for Microsoft Visual C++ 4.0 and later (does - not use assembler code) - makefile.os2 => OS/2 Makefile (gcc and emx, requires pngos2.def) - pngos2.def => OS/2 module definition file used by makefile.os2 - makefile.watcom => Watcom 10a+ Makefile, 32-bit flat memory model - makevms.com => VMS build script - descrip.mms => VMS makefile for MMS or MMK - SCOPTIONS.ppc => Used with smakefile.ppc - -Copy the file (or files) that you need from the -scripts directory into this directory, for example - - MSDOS example: copy scripts\makefile.msc makefile - UNIX example: cp scripts/makefile.std makefile - -Read the makefile to see if you need to change any source or -target directories to match your preferences. - -Then read pngconf.h to see if you want to make any configuration -changes. - -Then just run "make" which will create the libpng library in -this directory and "make test" which will run a quick test that reads -the "pngtest.png" file and writes a "pngout.png" file that should be -identical to it. Look for "9782 zero samples" in the output of the -test. For more confidence, you can run another test by typing -"pngtest pngnow.png" and looking for "289 zero samples" in the output. -Also, you can run "pngtest -m contrib/pngsuite/*.png" and compare -your output with the result shown in contrib/pngsuite/README. - -Most of the makefiles will allow you to run "make install" to -put the library in its final resting place (if you want to -do that, run "make install" in the zlib directory first if necessary). -Some also allow you to run "make test-installed" after you have -run "make install". - -If you encounter a compiler error message complaining about the -lines - __png.h__ already includes setjmp.h; - __dont__ include it again.; -This means you have compiled another module that includes setjmp.h, -which is hazardous because the two modules might not include exactly -the same setjmp.h. If you are sure that you know what you are doing -and that they are exactly the same, then you can comment out or -delete the two lines. Better yet, use the cexcept interface -instead, as demonstrated in contrib/visupng of the libpng distribution. - -Further information can be found in the README and libpng.txt -files, in the individual makefiles, in png.h, and the manual pages -libpng.3 and png.5. diff --git a/irrlicht-1.6/source/Irrlicht/libpng/KNOWNBUG b/irrlicht-1.6/source/Irrlicht/libpng/KNOWNBUG deleted file mode 100644 index 975f67a68..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/KNOWNBUG +++ /dev/null @@ -1,28 +0,0 @@ - -Known bugs in libpng version 1.2.18 - -1. April 22, 2001: pnggccrd.c has been reported to crash on NetBSD when - reading interlaced PNG files, when assembler code is enabled but running - on a non-MMX i386 platform. - - STATUS: Under investigation. The change to pnggccrd.c in libpng-1.2.1 - fixed a problem under FreeBSD but not the problem with NetBSD, which - still fails as of libpng-1.2.2rc1. - -2. February 23, 2006: The custom makefiles don't build libpng with -lz. - - STATUS: This is a subject of debate. The change will probably be made - as a part of a major overhaul of the makefiles in libpng version 1.3.0. - -3. February 24, 2006: The Makefile generated by the "configure" script - fails to install symbolic links - libpng12.so => libpng12.so.0.1.2.9betaN - that are generated by the custom makefiles. - - STATUS: For now, system library builders should use the custom makefiles. - -4. March 2007: Building 1.2.16 with PNG_ASSEMBLER_CODE_SUPPORTED; - PNG_MMX_CODE_SUPPORTED results in multiple definitions of png_combine_row, - png_do_read_interlace, and png_read_filter_row - - STATUS: Investigating. diff --git a/irrlicht-1.6/source/Irrlicht/libpng/LICENSE b/irrlicht-1.6/source/Irrlicht/libpng/LICENSE deleted file mode 100644 index 09bcaf96d..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/LICENSE +++ /dev/null @@ -1,109 +0,0 @@ - -This copy of the libpng notices is provided for your convenience. In case of -any discrepancy between this copy and the notices in the file png.h that is -included in the libpng distribution, the latter shall prevail. - -COPYRIGHT NOTICE, DISCLAIMER, and LICENSE: - -If you modify libpng you may insert additional notices immediately following -this sentence. - -libpng versions 1.2.6, August 15, 2004, through 1.2.18, May 15, 2007, are -Copyright (c) 2004, 2006-2007 Glenn Randers-Pehrson, and are -distributed according to the same disclaimer and license as libpng-1.2.5 -with the following individual added to the list of Contributing Authors - - Cosmin Truta - -libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are -Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are -distributed according to the same disclaimer and license as libpng-1.0.6 -with the following individuals added to the list of Contributing Authors - - Simon-Pierre Cadieux - Eric S. Raymond - Gilles Vollant - -and with the following additions to the disclaimer: - - There is no warranty against interference with your enjoyment of the - library or against infringement. There is no warranty that our - efforts or the library will fulfill any of your particular purposes - or needs. This library is provided with all faults, and the entire - risk of satisfactory quality, performance, accuracy, and effort is with - the user. - -libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are -Copyright (c) 1998, 1999 Glenn Randers-Pehrson, and are -distributed according to the same disclaimer and license as libpng-0.96, -with the following individuals added to the list of Contributing Authors: - - Tom Lane - Glenn Randers-Pehrson - Willem van Schaik - -libpng versions 0.89, June 1996, through 0.96, May 1997, are -Copyright (c) 1996, 1997 Andreas Dilger -Distributed according to the same disclaimer and license as libpng-0.88, -with the following individuals added to the list of Contributing Authors: - - John Bowler - Kevin Bracey - Sam Bushell - Magnus Holmgren - Greg Roelofs - Tom Tanner - -libpng versions 0.5, May 1995, through 0.88, January 1996, are -Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. - -For the purposes of this copyright and license, "Contributing Authors" -is defined as the following set of individuals: - - Andreas Dilger - Dave Martindale - Guy Eric Schalnat - Paul Schmidt - Tim Wegner - -The PNG Reference Library is supplied "AS IS". The Contributing Authors -and Group 42, Inc. disclaim all warranties, expressed or implied, -including, without limitation, the warranties of merchantability and of -fitness for any purpose. The Contributing Authors and Group 42, Inc. -assume no liability for direct, indirect, incidental, special, exemplary, -or consequential damages, which may result from the use of the PNG -Reference Library, even if advised of the possibility of such damage. - -Permission is hereby granted to use, copy, modify, and distribute this -source code, or portions hereof, for any purpose, without fee, subject -to the following restrictions: - -1. The origin of this source code must not be misrepresented. - -2. Altered versions must be plainly marked as such and must not - be misrepresented as being the original source. - -3. This Copyright notice may not be removed or altered from any - source or altered source distribution. - -The Contributing Authors and Group 42, Inc. specifically permit, without -fee, and encourage the use of this source code as a component to -supporting the PNG file format in commercial products. If you use this -source code in a product, acknowledgment is not required but would be -appreciated. - - -A "png_get_copyright" function is available, for convenient use in "about" -boxes and the like: - - printf("%s",png_get_copyright(NULL)); - -Also, the PNG logo (in PNG format, of course) is supplied in the -files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31). - -Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a -certification mark of the Open Source Initiative. - -Glenn Randers-Pehrson -glennrp at users.sourceforge.net -May 15, 2007 diff --git a/irrlicht-1.6/source/Irrlicht/libpng/README b/irrlicht-1.6/source/Irrlicht/libpng/README deleted file mode 100644 index 13160763d..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/README +++ /dev/null @@ -1,263 +0,0 @@ -README for libpng version 1.2.18 - May 15, 2007 (shared library 12.0) -See the note about version numbers near the top of png.h - -See INSTALL for instructions on how to install libpng. - -Libpng comes in several distribution formats. Get libpng-*.tar.gz -or libpng-*.tar.bz2 if you want UNIX-style line endings in the text -files, or lpng*.zip if you want DOS-style line endings. - -Version 0.89 was the first official release of libpng. Don't let the -fact that it's the first release fool you. The libpng library has been in -extensive use and testing since mid-1995. By late 1997 it had -finally gotten to the stage where there hadn't been significant -changes to the API in some time, and people have a bad feeling about -libraries with versions < 1.0. Version 1.0.0 was released in -March 1998. - -**** -Note that some of the changes to the png_info structure render this -version of the library binary incompatible with libpng-0.89 or -earlier versions if you are using a shared library. The type of the -"filler" parameter for png_set_filler() has changed from png_byte to -png_uint_32, which will affect shared-library applications that use -this function. - -To avoid problems with changes to the internals of png_info_struct, -new APIs have been made available in 0.95 to avoid direct application -access to info_ptr. These functions are the png_set_<chunk> and -png_get_<chunk> functions. These functions should be used when -accessing/storing the info_struct data, rather than manipulating it -directly, to avoid such problems in the future. - -It is important to note that the APIs do not make current programs -that access the info struct directly incompatible with the new -library. However, it is strongly suggested that new programs use -the new APIs (as shown in example.c and pngtest.c), and older programs -be converted to the new format, to facilitate upgrades in the future. -**** - -Additions since 0.90 include the ability to compile libpng as a -Windows DLL, and new APIs for accessing data in the info struct. -Experimental functions include the ability to set weighting and cost -factors for row filter selection, direct reads of integers from buffers -on big-endian processors that support misaligned data access, faster -methods of doing alpha composition, and more accurate 16->8 bit color -conversion. - -The additions since 0.89 include the ability to read from a PNG stream -which has had some (or all) of the signature bytes read by the calling -application. This also allows the reading of embedded PNG streams that -do not have the PNG file signature. As well, it is now possible to set -the library action on the detection of chunk CRC errors. It is possible -to set different actions based on whether the CRC error occurred in a -critical or an ancillary chunk. - -The changes made to the library, and bugs fixed are based on discussions -on the PNG-implement mailing list -and not on material submitted privately to Guy, Andreas, or Glenn. They will -forward any good suggestions to the list. - -For a detailed description on using libpng, read libpng.txt. For -examples of libpng in a program, see example.c and pngtest.c. For usage -information and restrictions (what little they are) on libpng, see -png.h. For a description on using zlib (the compression library used by -libpng) and zlib's restrictions, see zlib.h - -I have included a general makefile, as well as several machine and -compiler specific ones, but you may have to modify one for your own needs. - -You should use zlib 1.0.4 or later to run this, but it MAY work with -versions as old as zlib 0.95. Even so, there are bugs in older zlib -versions which can cause the output of invalid compression streams for -some images. You will definitely need zlib 1.0.4 or later if you are -taking advantage of the MS-DOS "far" structure allocation for the small -and medium memory models. You should also note that zlib is a -compression library that is useful for more things than just PNG files. -You can use zlib as a drop-in replacement for fread() and fwrite() if -you are so inclined. - -zlib should be available at the same place that libpng is, or at. -ftp://ftp.info-zip.org/pub/infozip/zlib - -You may also want a copy of the PNG specification. It is available -as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find -these at http://www.libpng.org/pub/png/documents/ - -This code is currently being archived at libpng.sf.net in the -[DOWNLOAD] area, and on CompuServe, Lib 20 (PNG SUPPORT) -at GO GRAPHSUP. If you can't find it in any of those places, -e-mail me, and I'll help you find it. - -If you have any code changes, requests, problems, etc., please e-mail -them to me. Also, I'd appreciate any make files or project files, -and any modifications you needed to make to get libpng to compile, -along with a #define variable to tell what compiler/system you are on. -If you needed to add transformations to libpng, or wish libpng would -provide the image in a different way, drop me a note (and code, if -possible), so I can consider supporting the transformation. -Finally, if you get any warning messages when compiling libpng -(note: not zlib), and they are easy to fix, I'd appreciate the -fix. Please mention "libpng" somewhere in the subject line. Thanks. - -This release was created and will be supported by myself (of course -based in a large way on Guy's and Andreas' earlier work), and the PNG group. - -Send comments/corrections/commendations to png-mng-implement at lists.sf.net -(subscription required; visit -https://lists.sourceforge.net/lists/listinfo/png-mng-implement -to subscribe) or to glennrp at users.sourceforge.net - -You can't reach Guy, the original libpng author, at the addresses -given in previous versions of this document. He and Andreas will read mail -addressed to the png-implement list, however. - -Please do not send general questions about PNG. Send them to -the (png-list at ccrc.wustl.edu, subscription required, write to -majordomo at ccrc.wustl.edu with "subscribe png-list" in your message). -On the other hand, -please do not send libpng questions to that address, send them to me -or to the png-implement list. I'll -get them in the end anyway. If you have a question about something -in the PNG specification that is related to using libpng, send it -to me. Send me any questions that start with "I was using libpng, -and ...". If in doubt, send questions to me. I'll bounce them -to others, if necessary. - -Please do not send suggestions on how to change PNG. We have -been discussing PNG for nine years now, and it is official and -finished. If you have suggestions for libpng, however, I'll -gladly listen. Even if your suggestion is not used immediately, -it may be used later. - -Files in this distribution: - - ANNOUNCE => Announcement of this version, with recent changes - CHANGES => Description of changes between libpng versions - KNOWNBUG => List of known bugs and deficiencies - LICENSE => License to use and redistribute libpng - README => This file - TODO => Things not implemented in the current library - Y2KINFO => Statement of Y2K compliance - example.c => Example code for using libpng functions - libpng.3 => manual page for libpng (includes libpng.txt) - libpng.txt => Description of libpng and its functions - libpngpf.3 => manual page for libpng's private functions - png.5 => manual page for the PNG format - png.c => Basic interface functions common to library - png.h => Library function and interface declarations - pngconf.h => System specific library configuration - pngasmrd.h => Header file for assembler-coded functions - pngerror.c => Error/warning message I/O functions - pngget.c => Functions for retrieving info from struct - pngmem.c => Memory handling functions - pngbar.png => PNG logo, 88x31 - pngnow.png => PNG logo, 98x31 - pngpread.c => Progressive reading functions - pngread.c => Read data/helper high-level functions - pngrio.c => Lowest-level data read I/O functions - pngrtran.c => Read data transformation functions - pngrutil.c => Read data utility functions - pngset.c => Functions for storing data into the info_struct - pngtest.c => Library test program - pngtest.png => Library test sample image - pngtrans.c => Common data transformation functions - pngwio.c => Lowest-level write I/O functions - pngwrite.c => High-level write functions - pngwtran.c => Write data transformations - pngwutil.c => Write utility functions - contrib => Contributions - gregbook => source code for PNG reading and writing, from - Greg Roelofs' "PNG: The Definitive Guide", - O'Reilly, 1999 - msvctest => Builds and runs pngtest using a MSVC workspace - pngminus => Simple pnm2png and png2pnm programs - pngsuite => Test images - visupng => Contains a MSVC workspace for VisualPng - projects => Contains project files and workspaces for building DLL - beos => Contains a Beos workspace for building libpng - c5builder => Contains a Borland workspace for building libpng - and zlib - visualc6 => Contains a Microsoft Visual C++ (MSVC) workspace - for building libpng and zlib - netware.txt => Contains instructions for downloading a set of - project files for building libpng and zlib on - Netware. - wince.txt => Contains instructions for downloading a Microsoft - Visual C++ (Windows CD Toolkit) workspace for - building libpng and zlib on WindowsCE - scripts => Directory containing scripts for building libpng: - descrip.mms => VMS makefile for MMS or MMK - makefile.std => Generic UNIX makefile (cc, creates static libpng.a) - makefile.elf => Linux/ELF makefile symbol versioning, - gcc, creates libpng12.so.0.1.2.18) - makefile.linux => Linux/ELF makefile - (gcc, creates libpng12.so.0.1.2.18) - makefile.gcmmx => Linux/ELF makefile - (gcc, creates libpng12.so.0.1.2.18, - uses assembler code tuned for Intel MMX platform) - makefile.gcc => Generic makefile (gcc, creates static libpng.a) - makefile.knr => Archaic UNIX Makefile that converts files with - ansi2knr (Requires ansi2knr.c from - ftp://ftp.cs.wisc.edu/ghost) - makefile.aix => AIX makefile - makefile.cygwin => Cygwin/gcc makefile - makefile.darwin => Darwin makefile - makefile.dec => DEC Alpha UNIX makefile - makefile.freebsd => FreeBSD makefile - makefile.hpgcc => HPUX makefile using gcc - makefile.hpux => HPUX (10.20 and 11.00) makefile - makefile.hp64 => HPUX (10.20 and 11.00) makefile, 64 bit - makefile.ibmc => IBM C/C++ version 3.x for Win32 and OS/2 (static) - makefile.intel => Intel C/C++ version 4.0 and later - libpng.icc => Project file, IBM VisualAge/C++ 4.0 or later - makefile.netbsd => NetBSD/cc makefile, PNGGCCRD, makes libpng.so. - makefile.ne12bsd => NetBSD/cc makefile, PNGGCCRD, makes libpng12.so - makefile.openbsd => OpenBSD makefile - makefile.sgi => Silicon Graphics IRIX (cc, creates static lib) - makefile.sggcc => Silicon Graphics - (gcc, creates libpng12.so.0.1.2.18) - makefile.sunos => Sun makefile - makefile.solaris => Solaris 2.X makefile - (gcc, creates libpng12.so.0.1.2.18) - makefile.so9 => Solaris 9 makefile - (gcc, creates libpng12.so.0.1.2.18) - makefile.32sunu => Sun Ultra 32-bit makefile - makefile.64sunu => Sun Ultra 64-bit makefile - makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc - makefile.mips => MIPS makefile - makefile.acorn => Acorn makefile - makefile.amiga => Amiga makefile - smakefile.ppc => AMIGA smakefile for SAS C V6.58/7.00 PPC - compiler (Requires SCOPTIONS, copied from - scripts/SCOPTIONS.ppc) - makefile.atari => Atari makefile - makefile.beos => BEOS makefile for X86 - makefile.bor => Borland makefile (uses bcc) - makefile.bc32 => 32-bit Borland C++ (all modules compiled in C mode) - makefile.tc3 => Turbo C 3.0 makefile - makefile.dj2 => DJGPP 2 makefile - makefile.msc => Microsoft C makefile - makefile.vcawin32=> makefile for Microsoft Visual C++ 5.0 and - later (uses assembler code tuned for Intel MMX - platform) - makefile.vcwin32 => makefile for Microsoft Visual C++ 4.0 and - later (does not use assembler code) - makefile.os2 => OS/2 Makefile (gcc and emx, requires pngos2.def) - pngos2.def => OS/2 module definition file used by makefile.os2 - makefile.watcom => Watcom 10a+ Makefile, 32-bit flat memory model - makevms.com => VMS build script - SCOPTIONS.ppc => Used with smakefile.ppc - -Good luck, and happy coding. - --Glenn Randers-Pehrson (current maintainer) - Internet: glennrp at users.sourceforge.net - --Andreas Eric Dilger (former maintainer, 1996-1997) - Internet: adilger at enel.ucalgary.ca - Web: http://www-mddsp.enel.ucalgary.ca/People/adilger/ - --Guy Eric Schalnat (original author and former maintainer, 1995-1996) - (formerly of Group 42, Inc) - Internet: gschal at infinet.com diff --git a/irrlicht-1.6/source/Irrlicht/libpng/TODO b/irrlicht-1.6/source/Irrlicht/libpng/TODO deleted file mode 100644 index 90f945c69..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/TODO +++ /dev/null @@ -1,24 +0,0 @@ -TODO - list of things to do for libpng: - -Final bug fixes. -Improve API by hiding the png_struct and png_info structs. -Finish work on the no-floating-point version (including gamma compensation) -Better C++ wrapper/full C++ implementation? -Fix problem with C++ and EXTERN "C". -cHRM transformation. -Improve setjmp/longjmp usage or remove it in favor of returning error codes. -Add "grayscale->palette" transformation and "palette->grayscale" detection. -Improved dithering. -Multi-lingual error and warning message support. -Complete sRGB transformation (presently it simply uses gamma=0.45455). -Man pages for function calls. -Better documentation. -Better filter selection - (counting huffman bits/precompression? filter inertia? filter costs?). -Histogram creation. -Text conversion between different code pages (Latin-1 -> Mac and DOS). -Should we always malloc 2^bit_depth PLTE/tRNS/hIST entries for safety? -Build gamma tables using fixed point (and do away with floating point entirely). -Use greater precision when changing to linear gamma for compositing against - background and doing rgb-to-gray transformation. -Investigate pre-incremented loop counters and other loop constructions. diff --git a/irrlicht-1.6/source/Irrlicht/libpng/Y2KINFO b/irrlicht-1.6/source/Irrlicht/libpng/Y2KINFO deleted file mode 100644 index a2991231f..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/Y2KINFO +++ /dev/null @@ -1,55 +0,0 @@ - Y2K compliance in libpng: - ========================= - - May 15, 2007 - - Since the PNG Development group is an ad-hoc body, we can't make - an official declaration. - - This is your unofficial assurance that libpng from version 0.71 and - upward through 1.2.18 are Y2K compliant. It is my belief that earlier - versions were also Y2K compliant. - - Libpng only has three year fields. One is a 2-byte unsigned integer - that will hold years up to 65535. The other two hold the date in text - format, and will hold years up to 9999. - - The integer is - "png_uint_16 year" in png_time_struct. - - The strings are - "png_charp time_buffer" in png_struct and - "near_time_buffer", which is a local character string in png.c. - - There are seven time-related functions: - - png_convert_to_rfc_1123() in png.c - (formerly png_convert_to_rfc_1152() in error) - png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c - png_convert_from_time_t() in pngwrite.c - png_get_tIME() in pngget.c - png_handle_tIME() in pngrutil.c, called in pngread.c - png_set_tIME() in pngset.c - png_write_tIME() in pngwutil.c, called in pngwrite.c - - All appear to handle dates properly in a Y2K environment. The - png_convert_from_time_t() function calls gmtime() to convert from system - clock time, which returns (year - 1900), which we properly convert to - the full 4-digit year. There is a possibility that applications using - libpng are not passing 4-digit years into the png_convert_to_rfc_1123() - function, or that they are incorrectly passing only a 2-digit year - instead of "year - 1900" into the png_convert_from_struct_tm() function, - but this is not under our control. The libpng documentation has always - stated that it works with 4-digit years, and the APIs have been - documented as such. - - The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned - integer to hold the year, and can hold years as large as 65535. - - zlib, upon which libpng depends, is also Y2K compliant. It contains - no date-related code. - - - Glenn Randers-Pehrson - libpng maintainer - PNG Development Group diff --git a/irrlicht-1.6/source/Irrlicht/libpng/configure b/irrlicht-1.6/source/Irrlicht/libpng/configure deleted file mode 100644 index 0766c27b2..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/configure +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -echo " - There is no \"configure\" script in this distribution of - libpng-1.2.18. - - Instead, please copy the appropriate makefile for your system from the - \"scripts\" directory. Read the INSTALL file for more details. - - Update, July 2004: you can get a \"configure\" based distribution - from the libpng distribution sites. Download the file - libpng-1.2.18.tar.gz or libpng-1.2.18.tar.bz2 -" - diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/LICENSE b/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/LICENSE deleted file mode 100644 index f47b7c412..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/LICENSE +++ /dev/null @@ -1,26 +0,0 @@ - --------------------------------------------------------------------------- - - Copyright (c) 1998-2001 Greg Roelofs. All rights reserved. - - This software is provided "as is," without warranty of any kind, - express or implied. In no event shall the author or contributors - be held liable for any damages arising in any way from the use of - this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute - it freely, subject to the following restrictions: - - 1. Redistributions of source code must retain the above copyright - notice, disclaimer, and this list of conditions. - 2. Redistributions in binary form must reproduce the above copyright - notice, disclaimer, and this list of conditions in the documenta- - tion and/or other materials provided with the distribution. - 3. All advertising materials mentioning features or use of this - software must display the following acknowledgment: - - This product includes software developed by Greg Roelofs - and contributors for the book, "PNG: The Definitive Guide," - published by O'Reilly and Associates. - - --------------------------------------------------------------------------- diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/Makefile.sgi b/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/Makefile.sgi deleted file mode 100644 index f8f22f92f..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/Makefile.sgi +++ /dev/null @@ -1,104 +0,0 @@ -# Sample makefile for rpng-x / rpng2-x / wpng for SGI using cc and make. -# Greg Roelofs -# Last modified: 7 March 2002 -# -# The programs built by this makefile are described in the book, -# "PNG: The Definitive Guide," by Greg Roelofs (O'Reilly and -# Associates, 1999). Go buy a copy, eh? Buy some for friends -# and family, too. (Not that this is a blatant plug or anything.) -# -# Invoke this makefile from a shell prompt in the usual way; for example: -# -# make -f Makefile.sgi -# -# This makefile assumes libpng and zlib have already been built or downloaded -# and are both installed in /usr/local/{include,lib} (as indicated by the -# PNG* and Z* macros below). Edit as appropriate--choose only ONE each of -# the PNGINC, PNGLIB, ZINC and ZLIB lines. -# -# This makefile builds dynamically linked executables (against libpng and zlib, -# that is), but that can be changed by uncommenting the appropriate PNGLIB and -# ZLIB lines. - - -# macros -------------------------------------------------------------------- - -PNGINC = -I/usr/local/include/libpng12 -PNGLIB = -L/usr/local/lib -lpng12 # dynamically linked against libpng -#PNGLIB = /usr/local/lib/libpng12.a # statically linked against libpng -# or: -#PNGINC = -I../.. -#PNGLIB = -L../.. -lpng -#PNGLIB = ../../libpng.a - -ZINC = -I/usr/local/include -ZLIB = -L/usr/local/lib -lz # dynamically linked against zlib -#ZLIB = /usr/local/lib/libz.a # statically linked against zlib -#ZINC = -I../zlib -#ZLIB = -L../zlib -lz -#ZLIB = ../../../zlib/libz.a - -XINC = -I/usr/include/X11 # old-style, stock X distributions -XLIB = -L/usr/lib/X11 -lX11 -#XINC = -I/usr/openwin/include # Sun workstations (OpenWindows) -#XLIB = -L/usr/openwin/lib -lX11 -#XINC = -I/usr/X11R6/include # new X distributions (XFree86, etc.) -#XLIB = -L/usr/X11R6/lib -lX11 - -INCS = $(PNGINC) $(ZINC) $(XINC) -RLIBS = $(PNGLIB) $(ZLIB) $(XLIB) -lm -WLIBS = $(PNGLIB) $(ZLIB) - -CC = cc -LD = cc -RM = rm -f -# ABI must be the same as that used to build libpng. -ABI= -CFLAGS = $(ABI) -O -fullwarn $(INCS) -LDFLAGS = $(ABI) -O = .o -E = - -RPNG = rpng-x -RPNG2 = rpng2-x -WPNG = wpng - -ROBJS = $(RPNG)$(O) readpng$(O) -ROBJS2 = $(RPNG2)$(O) readpng2$(O) -WOBJS = $(WPNG)$(O) writepng$(O) - -EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E) - - -# implicit make rules ------------------------------------------------------- - -.c$(O): - $(CC) -c $(CFLAGS) $< - - -# dependencies -------------------------------------------------------------- - -all: $(EXES) - -$(RPNG)$(E): $(ROBJS) - $(LD) $(LDFLAGS) -o $@ $(ROBJS) $(RLIBS) - -$(RPNG2)$(E): $(ROBJS2) - $(LD) $(LDFLAGS) -o $@ $(ROBJS2) $(RLIBS) - -$(WPNG)$(E): $(WOBJS) - $(LD) $(LDFLAGS) -o $@ $(WOBJS) $(WLIBS) - -$(RPNG)$(O): $(RPNG).c readpng.h -$(RPNG2)$(O): $(RPNG2).c readpng2.h -$(WPNG)$(O): $(WPNG).c writepng.h - -readpng$(O): readpng.c readpng.h -readpng2$(O): readpng2.c readpng2.h -writepng$(O): writepng.c writepng.h - - -# maintenance --------------------------------------------------------------- - -clean: - $(RM) $(EXES) $(ROBJS) $(ROBJS2) $(WOBJS) diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/Makefile.unx b/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/Makefile.unx deleted file mode 100644 index 3d055d2a0..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/Makefile.unx +++ /dev/null @@ -1,104 +0,0 @@ -# Sample makefile for rpng-x / rpng2-x / wpng using gcc and make. -# Greg Roelofs -# Last modified: 7 March 2002 -# -# The programs built by this makefile are described in the book, -# "PNG: The Definitive Guide," by Greg Roelofs (O'Reilly and -# Associates, 1999). Go buy a copy, eh? Buy some for friends -# and family, too. (Not that this is a blatant plug or anything.) -# -# Invoke this makefile from a shell prompt in the usual way; for example: -# -# make -f Makefile.unx -# -# This makefile assumes libpng and zlib have already been built or downloaded -# and are both installed in /usr/local/{include,lib} (as indicated by the -# PNG* and Z* macros below). Edit as appropriate--choose only ONE each of -# the PNGINC, PNGLIB, ZINC and ZLIB lines. -# -# This makefile builds statically linked executables (against libpng and zlib, -# that is), but that can be changed by uncommenting the appropriate PNGLIB and -# ZLIB lines. - - -# macros -------------------------------------------------------------------- - -PNGINC = -I/usr/local/include/libpng12 -#PNGLIB = -L/usr/local/lib -lpng12 # dynamically linked against libpng -PNGLIB = /usr/local/lib/libpng12.a # statically linked against libpng -# or: -#PNGINC = -I../libpng -#PNGLIB = -L../libpng -lpng -#PNGLIB = ../libpng/libpng.a - -ZINC = -I/usr/local/include -#ZLIB = -L/usr/local/lib -lz # dynamically linked against zlib -ZLIB = /usr/local/lib/libz.a # statically linked against zlib -#ZINC = -I../zlib -#ZLIB = -L../zlib -lz -#ZLIB = ../zlib/libz.a - -#XINC = -I/usr/include # old-style, stock X distributions -#XLIB = -L/usr/lib/X11 -lX11 -#XINC = -I/usr/openwin/include # Sun workstations (OpenWindows) -#XLIB = -L/usr/openwin/lib -lX11 -XINC = -I/usr/X11R6/include # new X distributions (XFree86, etc.) -XLIB = -L/usr/X11R6/lib -lX11 - -INCS = $(PNGINC) $(ZINC) $(XINC) -RLIBS = $(PNGLIB) $(ZLIB) $(XLIB) -lm -WLIBS = $(PNGLIB) $(ZLIB) - -CC = gcc -LD = gcc -RM = rm -f -CFLAGS = -O -Wall $(INCS) -# [note that -Wall is a gcc-specific compilation flag ("most warnings on")] -# [-ansi, -pedantic and -W can also be used] -LDFLAGS = -O = .o -E = - -RPNG = rpng-x -RPNG2 = rpng2-x -WPNG = wpng - -ROBJS = $(RPNG)$(O) readpng$(O) -ROBJS2 = $(RPNG2)$(O) readpng2$(O) -WOBJS = $(WPNG)$(O) writepng$(O) - -EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E) - - -# implicit make rules ------------------------------------------------------- - -.c$(O): - $(CC) -c $(CFLAGS) $< - - -# dependencies -------------------------------------------------------------- - -all: $(EXES) - -$(RPNG)$(E): $(ROBJS) - $(LD) $(LDFLAGS) -o $@ $(ROBJS) $(RLIBS) - -$(RPNG2)$(E): $(ROBJS2) - $(LD) $(LDFLAGS) -o $@ $(ROBJS2) $(RLIBS) - -$(WPNG)$(E): $(WOBJS) - $(LD) $(LDFLAGS) -o $@ $(WOBJS) $(WLIBS) - -$(RPNG)$(O): $(RPNG).c readpng.h -$(RPNG2)$(O): $(RPNG2).c readpng2.h -$(WPNG)$(O): $(WPNG).c writepng.h - -readpng$(O): readpng.c readpng.h -readpng2$(O): readpng2.c readpng2.h -writepng$(O): writepng.c writepng.h - - -# maintenance --------------------------------------------------------------- - -clean: - $(RM) $(EXES) $(ROBJS) $(ROBJS2) $(WOBJS) diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/Makefile.w32 b/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/Makefile.w32 deleted file mode 100644 index ceb6a51bc..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/Makefile.w32 +++ /dev/null @@ -1,112 +0,0 @@ -# Sample makefile for rpng-win / rpng2-win / wpng using MSVC and NMAKE. -# Greg Roelofs -# Last modified: 16 February 1999 -# -# The programs built by this makefile are described in the book, -# "PNG: The Definitive Guide," by Greg Roelofs (O'Reilly and -# Associates, 1999). Go buy a copy, eh? Buy some for friends -# and family, too. (Not that this is a blatant plug or anything.) -# -# Invoke this makefile from a DOS prompt window via: -# -# %devstudio%\vc\bin\vcvars32.bat -# nmake -nologo -f Makefile.w32 -# -# where %devstudio% is the installation directory for MSVC / DevStudio. If -# you get "environment out of space" errors, create a desktop shortcut with -# "c:\windows\command.com /e:4096" as the program command line and set the -# working directory to this directory. Then double-click to open the new -# DOS-prompt window with a bigger environment and retry the commands above. -# -# This makefile assumes libpng and zlib have already been built or downloaded -# and are in subdirectories at the same level as the current subdirectory -# (as indicated by the PNGPATH and ZPATH macros below). Edit as appropriate. -# -# Note that the names of the dynamic and static libpng and zlib libraries -# used below may change in later releases of the libraries. This makefile -# builds statically linked executables, but that can be changed by uncom- -# menting the appropriate PNGLIB and ZLIB lines. - -!include <ntwin32.mak> - - -# macros -------------------------------------------------------------------- - -PNGPATH = ../libpng -PNGINC = -I$(PNGPATH) -#PNGLIB = $(PNGPATH)/pngdll.lib -PNGLIB = $(PNGPATH)/libpng.lib - -ZPATH = ../zlib -ZINC = -I$(ZPATH) -#ZLIB = $(ZPATH)/zlibdll.lib -ZLIB = $(ZPATH)/zlibstat.lib - -WINLIBS = -defaultlib:user32.lib gdi32.lib -# ["real" apps may also need comctl32.lib, comdlg32.lib, winmm.lib, etc.] - -INCS = $(PNGINC) $(ZINC) -RLIBS = $(PNGLIB) $(ZLIB) $(WINLIBS) -WLIBS = $(PNGLIB) $(ZLIB) - -CC = cl -LD = link -RM = del -CFLAGS = -nologo -O -W3 $(INCS) $(cvars) -# [note that -Wall is an MSVC-specific compilation flag ("all warnings on")] -# [see %devstudio%\vc\include\win32.mak for cvars macro definition] -O = .obj -E = .exe - -RLDFLAGS = -nologo -subsystem:windows -WLDFLAGS = -nologo - -RPNG = rpng-win -RPNG2 = rpng2-win -WPNG = wpng - -ROBJS = $(RPNG)$(O) readpng$(O) -ROBJS2 = $(RPNG2)$(O) readpng2$(O) -WOBJS = $(WPNG)$(O) writepng$(O) - -EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E) - - -# implicit make rules ------------------------------------------------------- - -.c$(O): - $(CC) -c $(CFLAGS) $< - - -# dependencies -------------------------------------------------------------- - -all: $(EXES) - -$(RPNG)$(E): $(ROBJS) - $(LD) $(RLDFLAGS) -out:$@ $(ROBJS) $(RLIBS) - -$(RPNG2)$(E): $(ROBJS2) - $(LD) $(RLDFLAGS) -out:$@ $(ROBJS2) $(RLIBS) - -$(WPNG)$(E): $(WOBJS) - $(LD) $(WLDFLAGS) -out:$@ $(WOBJS) $(WLIBS) - -$(RPNG)$(O): $(RPNG).c readpng.h -$(RPNG2)$(O): $(RPNG2).c readpng2.h -$(WPNG)$(O): $(WPNG).c writepng.h - -readpng$(O): readpng.c readpng.h -readpng2$(O): readpng2.c readpng2.h -writepng$(O): writepng.c writepng.h - - -# maintenance --------------------------------------------------------------- - -clean: -# ideally we could just do this: -# $(RM) $(EXES) $(ROBJS) $(ROBJS2) $(WOBJS) -# ...but the Windows "DEL" command is none too bright, so: - $(RM) r*$(E) - $(RM) w*$(E) - $(RM) r*$(O) - $(RM) w*$(O) diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/README b/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/README deleted file mode 100644 index d083c7618..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/README +++ /dev/null @@ -1,185 +0,0 @@ - =========================== - PNG: The Definitive Guide - =========================== - - Source Code - -Chapters 13, 14 and 15 of "PNG: The Definitive Guide" discuss three free, -cross-platform demo programs that show how to use the libpng reference -library: rpng, rpng2 and wpng. rpng and rpng2 are viewers; the first is -a very simple example that that shows how a standard file-viewer might use -libpng, while the second is designed to process streaming data and shows -how a web browser might be written. wpng is a simple command-line program -that reads binary PGM and PPM files (the ``raw'' grayscale and RGB subsets -of PBMPLUS/NetPBM) and converts them to PNG. - -The source code for all three demo programs currently compiles under -Unix, OpenVMS, and 32-bit Windows. (Special thanks to Martin Zinser, -zinser@decus.de, for making the necessary changes for OpenVMS and for -providing an appropriate build script.) Build instructions can be found -below. - -Files: - - README this file - LICENSE terms of distribution and reuse (BSD-like) - - Makefile.unx Unix makefile - Makefile.w32 Windows (MSVC) makefile - makevms.com OpenVMS build script - - rpng-win.c Windows front end for the basic viewer - rpng-x.c X Window System (Unix, OpenVMS) front end - readpng.c generic back end for the basic viewer - readpng.h header file for the basic viewer - - rpng2-win.c Windows front end for the progressive viewer - rpng2-x.c X front end for the progressive viewer - readpng2.c generic back end for the progressive viewer - readpng2.h header file for the progressive viewer - - wpng.c generic (text) front end for the converter - writepng.c generic back end for the converter - writepng.h header file for the converter - - toucan.png transparent PNG for testing (by Stefan Schneider) - -Note that, although the programs are designed to be functional, their -primary purpose is to illustrate how to use libpng to add PNG support to -other programs. As such, their user interfaces are crude and definitely -are not intended for everyday use. - -Please see http://www.libpng.org/pub/png/pngbook.html for further infor- -mation and links to the latest version of the source code, and Chapters -13-15 of the book for detailed discussion of the three programs. - -Greg Roelofs -newt@pobox.com -30 June 2001 - - -BUILD INSTRUCTIONS - - - Prerequisites (in order of compilation): - - - zlib http://www.gzip.org/zlib/ - - libpng http://www.libpng.org/pub/png/libpng.html - - pngbook http://www.libpng.org/pub/png/book/sources.html - - The pngbook demo programs are explicitly designed to demonstrate proper - coding techniques for using the libpng reference library. As a result, - you need to download and build both zlib (on which libpng depends) and - libpng. A common build setup is to place the zlib, libpng and pngbook - subdirectory trees ("folders") in the same parent directory. Then the - libpng build can refer to files in ../zlib (or ..\zlib or [-.zlib]), - and similarly for the pngbook build. - - Note that all three packages are designed to be built from a command - line by default; those who wish to use a graphical or other integrated - development environments are on their own. - - - - Unix: - - Unpack the latest pngbook sources (which should correspond to this - README file) into a directory and change into that directory. - - Copy Makefile.unx to Makefile and edit the PNG* and Z* variables - appropriately (possibly also the X* variables if necessary). - - make - - There is no "install" target, so copy the three executables somewhere - in your path or run them from the current directory. All three will - print a basic usage screen when run without any command-line arguments; - see the book for more details. - - - - Windows: - - Unpack the latest pngbook sources (which should correspond to this - README file) into a folder, open a "DOS shell" or "command prompt" - or equivalent command-line window, and cd into the folder where you - unpacked the source code. - - For MSVC, set up the necessary environment variables by invoking - - %devstudio%\vc\bin\vcvars32.bat - - where where %devstudio% is the installation directory for MSVC / - DevStudio. If you get "environment out of space" errors under 95/98, - create a desktop shortcut with "c:\windows\command.com /e:4096" as - the program command line and set the working directory to the pngbook - directory. Then double-click to open the new DOS-prompt window with - a bigger environment and retry the commands above. - - Copy Makefile.w32 to Makefile and edit the PNGPATH and ZPATH variables - appropriately (possibly also the "INC" and "LIB" variables if needed). - Note that the names of the dynamic and static libpng and zlib libraries - used in the makefile may change in later releases of the libraries. - Also note that, as of libpng version 1.0.5, MSVC DLL builds do not work. - This makefile therefore builds statically linked executables, but if - the DLL problems ever get fixed, uncommenting the appropriate PNGLIB - and ZLIB lines will build dynamically linked executables instead. - - Do the build by typing - - nmake - - The result should be three executables: rpng-win.exe, rpng2-win.exe, - and wpng.exe. Copy them somewhere in your PATH or run them from the - current folder. Like the Unix versions, the two windowed programs - (rpng and rpng2) now display a usage screen in a console window when - invoked without command-line arguments; this is new behavior as of - the June 2001 release. Note that the programs use the Unix-style "-" - character to specify options, instead of the more common DOS/Windows - "/" character. (For example: "rpng2-win -bgpat 4 foo.png", not - "rpng2-win /bgpat 4 foo.png") - - - - OpenVMS: - - Unpack the pngbook sources into a subdirectory and change into that - subdirectory. - - Edit makevms.com appropriately, specifically the zpath and pngpath - variables. - - @makevms - - To run the programs, they probably first need to be set up as "foreign - symbols," with "disk" and "dir" set appropriately: - - $ rpng == "$disk:[dir]rpng-x.exe" - $ rpng2 == "$disk:[dir]rpng2-x.exe" - $ wpng == "$disk:[dir]wpng.exe" - - All three will print a basic usage screen when run without any command- - line arguments; see the book for more details. Note that the options - style is Unix-like, i.e., preceded by "-" rather than "/". - - -RUNNING THE PROGRAMS: (VERY) BRIEF INTRO - - rpng is a simple PNG viewer that can display transparent PNGs with a - specified background color; for example, - - rpng -bgcolor #ff0000 toucan.png - - would display the image with a red background. rpng2 is a progressive - viewer that simulates a web browser in some respects; it can display - images against either a background color or a dynamically generated - background image. For example: - - rpng2 -bgpat 16 toucan.png - - wpng is a purely command-line image converter from binary PBMPLUS/NetPBM - format (.pgm or .ppm) to PNG; for example, - - wpng -time < toucan.ppm > toucan.png - - would convert the specified PPM file (using redirection) to PNG, auto- - matically setting the PNG modification-time chunk. - - All options can be abbreviated to the shortest unique value; for example, - "-bgc" for -bgcolor (versus "-bgp" for -bgpat), or "-g" for -gamma. diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/makevms.com b/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/makevms.com deleted file mode 100644 index ae1b999d1..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/makevms.com +++ /dev/null @@ -1,132 +0,0 @@ -$!------------------------------------------------------------------------------ -$! make "PNG: The Definitive Guide" demo programs (for X) under OpenVMS -$! -$! Script created by Martin Zinser for libpng; modified by Greg Roelofs -$! for standalone pngbook source distribution. -$! -$! -$! Set locations where zlib and libpng sources live. -$! -$ zpath = "" -$ pngpath = "" -$! -$ if f$search("[---.zlib]zlib.h").nes."" then zpath = "[---.zlib]" -$ if f$search("[--]png.h").nes."" then pngpath = "[--]" -$! -$ if f$search("[-.zlib]zlib.h").nes."" then zpath = "[-.zlib]" -$ if f$search("[-.libpng]png.h").nes."" then pngpath = "[-.libpng]" -$! -$ if zpath .eqs. "" -$ then -$ write sys$output "zlib include not found. Exiting..." -$ exit 2 -$ endif -$! -$ if pngpath .eqs. "" -$ then -$ write sys$output "libpng include not found. Exiting..." -$ exit 2 -$ endif -$! -$! Look for the compiler used. -$! -$ ccopt="/include=(''zpath',''pngpath')" -$ if f$getsyi("HW_MODEL").ge.1024 -$ then -$ ccopt = "/prefix=all"+ccopt -$ comp = "__decc__=1" -$ if f$trnlnm("SYS").eqs."" then define sys sys$library: -$ else -$ if f$search("SYS$SYSTEM:DECC$COMPILER.EXE").eqs."" -$ then -$ if f$trnlnm("SYS").eqs."" then define sys sys$library: -$ if f$search("SYS$SYSTEM:VAXC.EXE").eqs."" -$ then -$ comp = "__gcc__=1" -$ CC :== GCC -$ else -$ comp = "__vaxc__=1" -$ endif -$ else -$ if f$trnlnm("SYS").eqs."" then define sys decc$library_include: -$ ccopt = "/decc/prefix=all"+ccopt -$ comp = "__decc__=1" -$ endif -$ endif -$ open/write lopt lib.opt -$ write lopt "''pngpath'libpng.olb/lib" -$ write lopt "''zpath'libz.olb/lib" -$ close lopt -$ open/write xopt x11.opt -$ write xopt "sys$library:decw$xlibshr.exe/share" -$ close xopt -$! -$! Build 'em. -$! -$ write sys$output "Compiling PNG book programs ..." -$ CALL MAKE readpng.OBJ "cc ''CCOPT' readpng" - - readpng.c readpng.h -$ CALL MAKE readpng2.OBJ "cc ''CCOPT' readpng2" - - readpng2.c readpng2.h -$ CALL MAKE writepng.OBJ "cc ''CCOPT' writepng" - - writepng.c writepng.h -$ write sys$output "Building rpng-x..." -$ CALL MAKE rpng-x.OBJ "cc ''CCOPT' rpng-x" - - rpng-x.c readpng.h -$ call make rpng-x.exe - - "LINK rpng-x,readpng,lib.opt/opt,x11.opt/opt" - - rpng-x.obj readpng.obj -$ write sys$output "Building rpng2-x..." -$ CALL MAKE rpng2-x.OBJ "cc ''CCOPT' rpng2-x" - - rpng2-x.c readpng2.h -$ call make rpng2-x.exe - - "LINK rpng2-x,readpng2,lib.opt/opt,x11.opt/opt" - - rpng2-x.obj readpng2.obj -$ write sys$output "Building wpng..." -$ CALL MAKE wpng.OBJ "cc ''CCOPT' wpng" - - wpng.c writepng.h -$ call make wpng.exe - - "LINK wpng,writepng,lib.opt/opt" - - wpng.obj writepng.obj -$ exit -$! -$! -$MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES -$ V = 'F$Verify(0) -$! P1 = What we are trying to make -$! P2 = Command to make it -$! P3 - P8 What it depends on -$ -$ If F$Search(P1) .Eqs. "" Then Goto Makeit -$ Time = F$CvTime(F$File(P1,"RDT")) -$arg=3 -$Loop: -$ Argument = P'arg -$ If Argument .Eqs. "" Then Goto Exit -$ El=0 -$Loop2: -$ File = F$Element(El," ",Argument) -$ If File .Eqs. " " Then Goto Endl -$ AFile = "" -$Loop3: -$ OFile = AFile -$ AFile = F$Search(File) -$ If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl -$ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit -$ Goto Loop3 -$NextEL: -$ El = El + 1 -$ Goto Loop2 -$EndL: -$ arg=arg+1 -$ If arg .Le. 8 Then Goto Loop -$ Goto Exit -$ -$Makeit: -$ VV=F$VERIFY(0) -$ write sys$output P2 -$ 'P2 -$ VV='F$Verify(VV) -$Exit: -$ If V Then Set Verify -$ENDSUBROUTINE diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/readpng.c b/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/readpng.c deleted file mode 100644 index 35d49e9c9..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/readpng.c +++ /dev/null @@ -1,280 +0,0 @@ -/*--------------------------------------------------------------------------- - - rpng - simple PNG display program readpng.c - - --------------------------------------------------------------------------- - - Copyright (c) 1998-2000 Greg Roelofs. All rights reserved. - - This software is provided "as is," without warranty of any kind, - express or implied. In no event shall the author or contributors - be held liable for any damages arising in any way from the use of - this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute - it freely, subject to the following restrictions: - - 1. Redistributions of source code must retain the above copyright - notice, disclaimer, and this list of conditions. - 2. Redistributions in binary form must reproduce the above copyright - notice, disclaimer, and this list of conditions in the documenta- - tion and/or other materials provided with the distribution. - 3. All advertising materials mentioning features or use of this - software must display the following acknowledgment: - - This product includes software developed by Greg Roelofs - and contributors for the book, "PNG: The Definitive Guide," - published by O'Reilly and Associates. - - ---------------------------------------------------------------------------*/ - -#include <stdio.h> -#include <stdlib.h> - -#include "png.h" /* libpng header; includes zlib.h */ -#include "readpng.h" /* typedefs, common macros, public prototypes */ - -/* future versions of libpng will provide this macro: */ -#ifndef png_jmpbuf -# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) -#endif - - -static png_structp png_ptr = NULL; -static png_infop info_ptr = NULL; - -png_uint_32 width, height; -int bit_depth, color_type; -uch *image_data = NULL; - - -void readpng_version_info(void) -{ - fprintf(stderr, " Compiled with libpng %s; using libpng %s.\n", - PNG_LIBPNG_VER_STRING, png_libpng_ver); - fprintf(stderr, " Compiled with zlib %s; using zlib %s.\n", - ZLIB_VERSION, zlib_version); -} - - -/* return value = 0 for success, 1 for bad sig, 2 for bad IHDR, 4 for no mem */ - -int readpng_init(FILE *infile, ulg *pWidth, ulg *pHeight) -{ - uch sig[8]; - - - /* first do a quick check that the file really is a PNG image; could - * have used slightly more general png_sig_cmp() function instead */ - - fread(sig, 1, 8, infile); - if (!png_check_sig(sig, 8)) - return 1; /* bad signature */ - - - /* could pass pointers to user-defined error handlers instead of NULLs: */ - - png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (!png_ptr) - return 4; /* out of memory */ - - info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) { - png_destroy_read_struct(&png_ptr, NULL, NULL); - return 4; /* out of memory */ - } - - - /* we could create a second info struct here (end_info), but it's only - * useful if we want to keep pre- and post-IDAT chunk info separated - * (mainly for PNG-aware image editors and converters) */ - - - /* setjmp() must be called in every function that calls a PNG-reading - * libpng function */ - - if (setjmp(png_jmpbuf(png_ptr))) { - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - return 2; - } - - - png_init_io(png_ptr, infile); - png_set_sig_bytes(png_ptr, 8); /* we already read the 8 signature bytes */ - - png_read_info(png_ptr, info_ptr); /* read all PNG info up to image data */ - - - /* alternatively, could make separate calls to png_get_image_width(), - * etc., but want bit_depth and color_type for later [don't care about - * compression_type and filter_type => NULLs] */ - - png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, - NULL, NULL, NULL); - *pWidth = width; - *pHeight = height; - - - /* OK, that's all we need for now; return happy */ - - return 0; -} - - - - -/* returns 0 if succeeds, 1 if fails due to no bKGD chunk, 2 if libpng error; - * scales values to 8-bit if necessary */ - -int readpng_get_bgcolor(uch *red, uch *green, uch *blue) -{ - png_color_16p pBackground; - - - /* setjmp() must be called in every function that calls a PNG-reading - * libpng function */ - - if (setjmp(png_jmpbuf(png_ptr))) { - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - return 2; - } - - - if (!png_get_valid(png_ptr, info_ptr, PNG_INFO_bKGD)) - return 1; - - /* it is not obvious from the libpng documentation, but this function - * takes a pointer to a pointer, and it always returns valid red, green - * and blue values, regardless of color_type: */ - - png_get_bKGD(png_ptr, info_ptr, &pBackground); - - - /* however, it always returns the raw bKGD data, regardless of any - * bit-depth transformations, so check depth and adjust if necessary */ - - if (bit_depth == 16) { - *red = pBackground->red >> 8; - *green = pBackground->green >> 8; - *blue = pBackground->blue >> 8; - } else if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) { - if (bit_depth == 1) - *red = *green = *blue = pBackground->gray? 255 : 0; - else if (bit_depth == 2) - *red = *green = *blue = (255/3) * pBackground->gray; - else /* bit_depth == 4 */ - *red = *green = *blue = (255/15) * pBackground->gray; - } else { - *red = (uch)pBackground->red; - *green = (uch)pBackground->green; - *blue = (uch)pBackground->blue; - } - - return 0; -} - - - - -/* display_exponent == LUT_exponent * CRT_exponent */ - -uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes) -{ - double gamma; - png_uint_32 i, rowbytes; - png_bytepp row_pointers = NULL; - - - /* setjmp() must be called in every function that calls a PNG-reading - * libpng function */ - - if (setjmp(png_jmpbuf(png_ptr))) { - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - return NULL; - } - - - /* expand palette images to RGB, low-bit-depth grayscale images to 8 bits, - * transparency chunks to full alpha channel; strip 16-bit-per-sample - * images to 8 bits per sample; and convert grayscale to RGB[A] */ - - if (color_type == PNG_COLOR_TYPE_PALETTE) - png_set_expand(png_ptr); - if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) - png_set_expand(png_ptr); - if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) - png_set_expand(png_ptr); - if (bit_depth == 16) - png_set_strip_16(png_ptr); - if (color_type == PNG_COLOR_TYPE_GRAY || - color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_gray_to_rgb(png_ptr); - - - /* unlike the example in the libpng documentation, we have *no* idea where - * this file may have come from--so if it doesn't have a file gamma, don't - * do any correction ("do no harm") */ - - if (png_get_gAMA(png_ptr, info_ptr, &gamma)) - png_set_gamma(png_ptr, display_exponent, gamma); - - - /* all transformations have been registered; now update info_ptr data, - * get rowbytes and channels, and allocate image memory */ - - png_read_update_info(png_ptr, info_ptr); - - *pRowbytes = rowbytes = png_get_rowbytes(png_ptr, info_ptr); - *pChannels = (int)png_get_channels(png_ptr, info_ptr); - - if ((image_data = (uch *)malloc(rowbytes*height)) == NULL) { - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - return NULL; - } - if ((row_pointers = (png_bytepp)malloc(height*sizeof(png_bytep))) == NULL) { - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - free(image_data); - image_data = NULL; - return NULL; - } - - Trace((stderr, "readpng_get_image: channels = %d, rowbytes = %ld, height = %ld\n", *pChannels, rowbytes, height)); - - - /* set the individual row_pointers to point at the correct offsets */ - - for (i = 0; i < height; ++i) - row_pointers[i] = image_data + i*rowbytes; - - - /* now we can go ahead and just read the whole image */ - - png_read_image(png_ptr, row_pointers); - - - /* and we're done! (png_read_end() can be omitted if no processing of - * post-IDAT text/time/etc. is desired) */ - - free(row_pointers); - row_pointers = NULL; - - png_read_end(png_ptr, NULL); - - return image_data; -} - - -void readpng_cleanup(int free_image_data) -{ - if (free_image_data && image_data) { - free(image_data); - image_data = NULL; - } - - if (png_ptr && info_ptr) { - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - png_ptr = NULL; - info_ptr = NULL; - } -} diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/readpng.h b/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/readpng.h deleted file mode 100644 index 6e378de9d..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/readpng.h +++ /dev/null @@ -1,64 +0,0 @@ -/*--------------------------------------------------------------------------- - - rpng - simple PNG display program readpng.h - - --------------------------------------------------------------------------- - - Copyright (c) 1998-2000 Greg Roelofs. All rights reserved. - - This software is provided "as is," without warranty of any kind, - express or implied. In no event shall the author or contributors - be held liable for any damages arising in any way from the use of - this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute - it freely, subject to the following restrictions: - - 1. Redistributions of source code must retain the above copyright - notice, disclaimer, and this list of conditions. - 2. Redistributions in binary form must reproduce the above copyright - notice, disclaimer, and this list of conditions in the documenta- - tion and/or other materials provided with the distribution. - 3. All advertising materials mentioning features or use of this - software must display the following acknowledgment: - - This product includes software developed by Greg Roelofs - and contributors for the book, "PNG: The Definitive Guide," - published by O'Reilly and Associates. - - ---------------------------------------------------------------------------*/ - -#ifndef TRUE -# define TRUE 1 -# define FALSE 0 -#endif - -#ifndef MAX -# define MAX(a,b) ((a) > (b)? (a) : (b)) -# define MIN(a,b) ((a) < (b)? (a) : (b)) -#endif - -#ifdef DEBUG -# define Trace(x) {fprintf x ; fflush(stderr); fflush(stdout);} -#else -# define Trace(x) ; -#endif - -typedef unsigned char uch; -typedef unsigned short ush; -typedef unsigned long ulg; - - -/* prototypes for public functions in readpng.c */ - -void readpng_version_info(void); - -int readpng_init(FILE *infile, ulg *pWidth, ulg *pHeight); - -int readpng_get_bgcolor(uch *bg_red, uch *bg_green, uch *bg_blue); - -uch *readpng_get_image(double display_exponent, int *pChannels, - ulg *pRowbytes); - -void readpng_cleanup(int free_image_data); diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/readpng2.c b/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/readpng2.c deleted file mode 100644 index 2f723be72..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/readpng2.c +++ /dev/null @@ -1,624 +0,0 @@ -/*--------------------------------------------------------------------------- - - rpng2 - progressive-model PNG display program readpng2.c - - --------------------------------------------------------------------------- - - Changelog: - - 1.01: initial public release - - 1.02: added code to skip unused chunks (GR-P) - - --------------------------------------------------------------------------- - - Copyright (c) 1998-2002 Greg Roelofs. All rights reserved. - - This software is provided "as is," without warranty of any kind, - express or implied. In no event shall the author or contributors - be held liable for any damages arising in any way from the use of - this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute - it freely, subject to the following restrictions: - - 1. Redistributions of source code must retain the above copyright - notice, disclaimer, and this list of conditions. - 2. Redistributions in binary form must reproduce the above copyright - notice, disclaimer, and this list of conditions in the documenta- - tion and/or other materials provided with the distribution. - 3. All advertising materials mentioning features or use of this - software must display the following acknowledgment: - - This product includes software developed by Greg Roelofs - and contributors for the book, "PNG: The Definitive Guide," - published by O'Reilly and Associates. - - ---------------------------------------------------------------------------*/ - - -#include <stdlib.h> /* for exit() prototype */ - -#include "png.h" /* libpng header; includes zlib.h and setjmp.h */ -#include "readpng2.h" /* typedefs, common macros, public prototypes */ - - -/* local prototypes */ - -static void readpng2_info_callback(png_structp png_ptr, png_infop info_ptr); -static void readpng2_row_callback(png_structp png_ptr, png_bytep new_row, - png_uint_32 row_num, int pass); -static void readpng2_end_callback(png_structp png_ptr, png_infop info_ptr); -static void readpng2_error_handler(png_structp png_ptr, png_const_charp msg); - - - - -void readpng2_version_info(void) -{ -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && \ - (defined(__i386__) || defined(_M_IX86)) && \ - defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) - /* - * WARNING: This preprocessor approach means that the following code - * cannot be used with a libpng DLL older than 1.2.0--the - * compiled-in symbols for the new functions will not exist. - * (Could use dlopen() and dlsym() on Unix and corresponding - * calls for Windows, but not portable...) - */ - { - int mmxsupport = png_mmx_support(); - if (mmxsupport < 0) - fprintf(stderr, " Compiled with libpng %s; using libpng %s " - "without MMX support.\n", PNG_LIBPNG_VER_STRING, png_libpng_ver); - else { - int compilerID; - png_uint_32 mmx_mask = png_get_mmx_flagmask( - PNG_SELECT_READ | PNG_SELECT_WRITE, &compilerID); - - fprintf(stderr, " Compiled with libpng %s; using libpng %s " - "with MMX support\n (%s version).", PNG_LIBPNG_VER_STRING, - png_libpng_ver, compilerID == 1? "MSVC++" : - (compilerID == 2? "GNU C" : "unknown")); - fprintf(stderr, " Processor %s MMX instructions.\n", - mmxsupport? "supports" : "does not support"); - if (mmxsupport > 0) { - int num_optims = 0; - - fprintf(stderr, - " Potential MMX optimizations supported by libpng:\n"); - if (mmx_mask & PNG_ASM_FLAG_MMX_READ_FILTER_SUB) - ++num_optims; - if (mmx_mask & PNG_ASM_FLAG_MMX_READ_FILTER_UP) - ++num_optims; - if (mmx_mask & PNG_ASM_FLAG_MMX_READ_FILTER_AVG) - ++num_optims; - if (mmx_mask & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH) - ++num_optims; - if (num_optims) - fprintf(stderr, - " decoding %s row filters (reading)\n", - (num_optims == 4)? "all non-trivial" : "some"); - if (mmx_mask & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) { - fprintf(stderr, " combining rows (reading)\n"); - ++num_optims; - } - if (mmx_mask & PNG_ASM_FLAG_MMX_READ_INTERLACE) { - fprintf(stderr, - " expanding interlacing (reading)\n"); - ++num_optims; - } - mmx_mask &= ~( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ - | PNG_ASM_FLAG_MMX_READ_INTERLACE \ - | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ - | PNG_ASM_FLAG_MMX_READ_FILTER_UP \ - | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ - | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ); - if (mmx_mask) { - fprintf(stderr, " other (unknown)\n"); - ++num_optims; - } - if (num_optims == 0) - fprintf(stderr, " (none)\n"); - } - } - } -#else - fprintf(stderr, " Compiled with libpng %s; using libpng %s " - "without MMX support.\n", PNG_LIBPNG_VER_STRING, png_libpng_ver); -#endif - - fprintf(stderr, " Compiled with zlib %s; using zlib %s.\n", - ZLIB_VERSION, zlib_version); -} - - - - -int readpng2_check_sig(uch *sig, int num) -{ - return png_check_sig(sig, num); -} - - - - -/* returns 0 for success, 2 for libpng problem, 4 for out of memory */ - -int readpng2_init(mainprog_info *mainprog_ptr) -{ - png_structp png_ptr; /* note: temporary variables! */ - png_infop info_ptr; - - - /* could also replace libpng warning-handler (final NULL), but no need: */ - - png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, mainprog_ptr, - readpng2_error_handler, NULL); - if (!png_ptr) - return 4; /* out of memory */ - - info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) { - png_destroy_read_struct(&png_ptr, NULL, NULL); - return 4; /* out of memory */ - } - - - /* we could create a second info struct here (end_info), but it's only - * useful if we want to keep pre- and post-IDAT chunk info separated - * (mainly for PNG-aware image editors and converters) */ - - - /* setjmp() must be called in every function that calls a PNG-reading - * libpng function, unless an alternate error handler was installed-- - * but compatible error handlers must either use longjmp() themselves - * (as in this program) or exit immediately, so here we are: */ - - if (setjmp(mainprog_ptr->jmpbuf)) { - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - return 2; - } - - /* prepare the reader to ignore all recognized chunks whose data isn't - * going to be used, i.e., all chunks recognized by libpng except for - * IHDR, PLTE, IDAT, IEND, tRNS, bKGD, gAMA, and sRGB : */ - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - { -#ifndef HANDLE_CHUNK_NEVER -/* prior to libpng-1.2.5, this macro was internal, so we define it here. */ -# define HANDLE_CHUNK_NEVER 1 -#endif - /* these byte strings were copied from png.h. - * If a future libpng version recognizes more chunks, add them - * to this list. If a future version of readpng2.c recognizes - * more chunks, delete them from this list. */ - png_byte png_chunk_types_to_ignore[]= - { 99, 72, 82, 77, '\0', /* cHRM */ - 104, 73, 83, 84, '\0', /* hIST */ - 105, 67, 67, 80, '\0', /* iCCP */ - 105, 84, 88, 116, '\0', /* iTXt */ - 111, 70, 70, 115, '\0', /* oFFs */ - 112, 67, 65, 76, '\0', /* pCAL */ - 115, 67, 65, 76, '\0', /* sCAL */ - 112, 72, 89, 115, '\0', /* pHYs */ - 115, 66, 73, 84, '\0', /* sBIT */ - 115, 80, 76, 84, '\0', /* sPLT */ - 116, 69, 88, 116, '\0', /* tEXt */ - 116, 73, 77, 69, '\0', /* tIME */ - 122, 84, 88, 116, '\0'}; /* zTXt */ -#define NUM_PNG_CHUNK_TYPES_TO_IGNORE 13 - - png_set_keep_unknown_chunks(png_ptr, HANDLE_CHUNK_NEVER, - png_chunk_types_to_ignore, NUM_PNG_CHUNK_TYPES_TO_IGNORE); - } -#endif - - /* instead of doing png_init_io() here, now we set up our callback - * functions for progressive decoding */ - - png_set_progressive_read_fn(png_ptr, mainprog_ptr, - readpng2_info_callback, readpng2_row_callback, readpng2_end_callback); - - - /* - * may as well enable or disable MMX routines here, if supported; - * - * to enable all: mask = png_get_mmx_flagmask ( - * PNG_SELECT_READ | PNG_SELECT_WRITE, &compilerID); - * flags = png_get_asm_flags (png_ptr); - * flags |= mask; - * png_set_asm_flags (png_ptr, flags); - * - * to disable all: mask = png_get_mmx_flagmask ( - * PNG_SELECT_READ | PNG_SELECT_WRITE, &compilerID); - * flags = png_get_asm_flags (png_ptr); - * flags &= ~mask; - * png_set_asm_flags (png_ptr, flags); - */ - -#if (defined(__i386__) || defined(_M_IX86)) && \ - defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) - /* - * WARNING: This preprocessor approach means that the following code - * cannot be used with a libpng DLL older than 1.2.0--the - * compiled-in symbols for the new functions will not exist. - * (Could use dlopen() and dlsym() on Unix and corresponding - * calls for Windows, but not portable...) - */ - { -#ifdef PNG_ASSEMBLER_CODE_SUPPORTED - png_uint_32 mmx_disable_mask = 0; - png_uint_32 asm_flags, mmx_mask; - int compilerID; - - if (mainprog_ptr->nommxfilters) - mmx_disable_mask |= ( PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ - | PNG_ASM_FLAG_MMX_READ_FILTER_UP \ - | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ - | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ); - if (mainprog_ptr->nommxcombine) - mmx_disable_mask |= PNG_ASM_FLAG_MMX_READ_COMBINE_ROW; - if (mainprog_ptr->nommxinterlace) - mmx_disable_mask |= PNG_ASM_FLAG_MMX_READ_INTERLACE; - asm_flags = png_get_asm_flags(png_ptr); - png_set_asm_flags(png_ptr, asm_flags & ~mmx_disable_mask); - - - /* Now query libpng's asm settings, just for yuks. Note that this - * differs from the querying of its *potential* MMX capabilities - * in readpng2_version_info(); this is true runtime verification. */ - - asm_flags = png_get_asm_flags(png_ptr); - mmx_mask = png_get_mmx_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE, - &compilerID); - if (asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_COMPILED) - fprintf(stderr, - " MMX support (%s version) is compiled into libpng\n", - compilerID == 1? "MSVC++" : - (compilerID == 2? "GNU C" : "unknown")); - else - fprintf(stderr, " MMX support is not compiled into libpng\n"); - fprintf(stderr, " MMX instructions are %ssupported by CPU\n", - (asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU)? "" : "not "); - fprintf(stderr, " MMX read support for combining rows is %sabled\n", - (asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW)? "en" : "dis"); - fprintf(stderr, - " MMX read support for expanding interlacing is %sabled\n", - (asm_flags & PNG_ASM_FLAG_MMX_READ_INTERLACE)? "en" : "dis"); - fprintf(stderr, " MMX read support for \"sub\" filter is %sabled\n", - (asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB)? "en" : "dis"); - fprintf(stderr, " MMX read support for \"up\" filter is %sabled\n", - (asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP)? "en" : "dis"); - fprintf(stderr, " MMX read support for \"avg\" filter is %sabled\n", - (asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG)? "en" : "dis"); - fprintf(stderr, " MMX read support for \"Paeth\" filter is %sabled\n", - (asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH)? "en" : "dis"); - asm_flags &= (mmx_mask & ~( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ - | PNG_ASM_FLAG_MMX_READ_INTERLACE \ - | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ - | PNG_ASM_FLAG_MMX_READ_FILTER_UP \ - | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ - | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH )); - if (asm_flags) - fprintf(stderr, - " additional MMX support is also enabled (0x%02lx)\n", - asm_flags); -#else /* !PNG_ASSEMBLER_CODE_SUPPORTED */ - fprintf(stderr, " MMX querying is disabled in libpng.\n"); -#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ - } -#endif - - - /* make sure we save our pointers for use in readpng2_decode_data() */ - - mainprog_ptr->png_ptr = png_ptr; - mainprog_ptr->info_ptr = info_ptr; - - - /* and that's all there is to initialization */ - - return 0; -} - - - - -/* returns 0 for success, 2 for libpng (longjmp) problem */ - -int readpng2_decode_data(mainprog_info *mainprog_ptr, uch *rawbuf, ulg length) -{ - png_structp png_ptr = (png_structp)mainprog_ptr->png_ptr; - png_infop info_ptr = (png_infop)mainprog_ptr->info_ptr; - - - /* setjmp() must be called in every function that calls a PNG-reading - * libpng function */ - - if (setjmp(mainprog_ptr->jmpbuf)) { - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - mainprog_ptr->png_ptr = NULL; - mainprog_ptr->info_ptr = NULL; - return 2; - } - - - /* hand off the next chunk of input data to libpng for decoding */ - - png_process_data(png_ptr, info_ptr, rawbuf, length); - - return 0; -} - - - - -static void readpng2_info_callback(png_structp png_ptr, png_infop info_ptr) -{ - mainprog_info *mainprog_ptr; - int color_type, bit_depth; - double gamma; - - - /* setjmp() doesn't make sense here, because we'd either have to exit(), - * longjmp() ourselves, or return control to libpng, which doesn't want - * to see us again. By not doing anything here, libpng will instead jump - * to readpng2_decode_data(), which can return an error value to the main - * program. */ - - - /* retrieve the pointer to our special-purpose struct, using the png_ptr - * that libpng passed back to us (i.e., not a global this time--there's - * no real difference for a single image, but for a multithreaded browser - * decoding several PNG images at the same time, one needs to avoid mixing - * up different images' structs) */ - - mainprog_ptr = png_get_progressive_ptr(png_ptr); - - if (mainprog_ptr == NULL) { /* we be hosed */ - fprintf(stderr, - "readpng2 error: main struct not recoverable in info_callback.\n"); - fflush(stderr); - return; - /* - * Alternatively, we could call our error-handler just like libpng - * does, which would effectively terminate the program. Since this - * can only happen if png_ptr gets redirected somewhere odd or the - * main PNG struct gets wiped, we're probably toast anyway. (If - * png_ptr itself is NULL, we would not have been called.) - */ - } - - - /* this is just like in the non-progressive case */ - - png_get_IHDR(png_ptr, info_ptr, &mainprog_ptr->width, - &mainprog_ptr->height, &bit_depth, &color_type, NULL, NULL, NULL); - - - /* since we know we've read all of the PNG file's "header" (i.e., up - * to IDAT), we can check for a background color here */ - - if (mainprog_ptr->need_bgcolor && - png_get_valid(png_ptr, info_ptr, PNG_INFO_bKGD)) - { - png_color_16p pBackground; - - /* it is not obvious from the libpng documentation, but this function - * takes a pointer to a pointer, and it always returns valid red, - * green and blue values, regardless of color_type: */ - png_get_bKGD(png_ptr, info_ptr, &pBackground); - - /* however, it always returns the raw bKGD data, regardless of any - * bit-depth transformations, so check depth and adjust if necessary */ - if (bit_depth == 16) { - mainprog_ptr->bg_red = pBackground->red >> 8; - mainprog_ptr->bg_green = pBackground->green >> 8; - mainprog_ptr->bg_blue = pBackground->blue >> 8; - } else if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) { - if (bit_depth == 1) - mainprog_ptr->bg_red = mainprog_ptr->bg_green = - mainprog_ptr->bg_blue = pBackground->gray? 255 : 0; - else if (bit_depth == 2) - mainprog_ptr->bg_red = mainprog_ptr->bg_green = - mainprog_ptr->bg_blue = (255/3) * pBackground->gray; - else /* bit_depth == 4 */ - mainprog_ptr->bg_red = mainprog_ptr->bg_green = - mainprog_ptr->bg_blue = (255/15) * pBackground->gray; - } else { - mainprog_ptr->bg_red = (uch)pBackground->red; - mainprog_ptr->bg_green = (uch)pBackground->green; - mainprog_ptr->bg_blue = (uch)pBackground->blue; - } - } - - - /* as before, let libpng expand palette images to RGB, low-bit-depth - * grayscale images to 8 bits, transparency chunks to full alpha channel; - * strip 16-bit-per-sample images to 8 bits per sample; and convert - * grayscale to RGB[A] */ - - if (color_type == PNG_COLOR_TYPE_PALETTE) - png_set_expand(png_ptr); - if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) - png_set_expand(png_ptr); - if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) - png_set_expand(png_ptr); - if (bit_depth == 16) - png_set_strip_16(png_ptr); - if (color_type == PNG_COLOR_TYPE_GRAY || - color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_gray_to_rgb(png_ptr); - - - /* Unlike the basic viewer, which was designed to operate on local files, - * this program is intended to simulate a web browser--even though we - * actually read from a local file, too. But because we are pretending - * that most of the images originate on the Internet, we follow the recom- - * mendation of the sRGB proposal and treat unlabelled images (no gAMA - * chunk) as existing in the sRGB color space. That is, we assume that - * such images have a file gamma of 0.45455, which corresponds to a PC-like - * display system. This change in assumptions will have no effect on a - * PC-like system, but on a Mac, SGI, NeXT or other system with a non- - * identity lookup table, it will darken unlabelled images, which effec- - * tively favors images from PC-like systems over those originating on - * the local platform. Note that mainprog_ptr->display_exponent is the - * "gamma" value for the entire display system, i.e., the product of - * LUT_exponent and CRT_exponent. */ - - if (png_get_gAMA(png_ptr, info_ptr, &gamma)) - png_set_gamma(png_ptr, mainprog_ptr->display_exponent, gamma); - else - png_set_gamma(png_ptr, mainprog_ptr->display_exponent, 0.45455); - - - /* we'll let libpng expand interlaced images, too */ - - mainprog_ptr->passes = png_set_interlace_handling(png_ptr); - - - /* all transformations have been registered; now update info_ptr data and - * then get rowbytes and channels */ - - png_read_update_info(png_ptr, info_ptr); - - mainprog_ptr->rowbytes = (int)png_get_rowbytes(png_ptr, info_ptr); - mainprog_ptr->channels = png_get_channels(png_ptr, info_ptr); - - - /* Call the main program to allocate memory for the image buffer and - * initialize windows and whatnot. (The old-style function-pointer - * invocation is used for compatibility with a few supposedly ANSI - * compilers that nevertheless barf on "fn_ptr()"-style syntax.) */ - - (*mainprog_ptr->mainprog_init)(); - - - /* and that takes care of initialization */ - - return; -} - - - - - -static void readpng2_row_callback(png_structp png_ptr, png_bytep new_row, - png_uint_32 row_num, int pass) -{ - mainprog_info *mainprog_ptr; - - - /* first check whether the row differs from the previous pass; if not, - * nothing to combine or display */ - - if (!new_row) - return; - - - /* retrieve the pointer to our special-purpose struct so we can access - * the old rows and image-display callback function */ - - mainprog_ptr = png_get_progressive_ptr(png_ptr); - - - /* save the pass number for optional use by the front end */ - - mainprog_ptr->pass = pass; - - - /* have libpng either combine the new row data with the existing row data - * from previous passes (if interlaced) or else just copy the new row - * into the main program's image buffer */ - - png_progressive_combine_row(png_ptr, mainprog_ptr->row_pointers[row_num], - new_row); - - - /* finally, call the display routine in the main program with the number - * of the row we just updated */ - - (*mainprog_ptr->mainprog_display_row)(row_num); - - - /* and we're ready for more */ - - return; -} - - - - - -static void readpng2_end_callback(png_structp png_ptr, png_infop info_ptr) -{ - mainprog_info *mainprog_ptr; - - - /* retrieve the pointer to our special-purpose struct */ - - mainprog_ptr = png_get_progressive_ptr(png_ptr); - - - /* let the main program know that it should flush any buffered image - * data to the display now and set a "done" flag or whatever, but note - * that it SHOULD NOT DESTROY THE PNG STRUCTS YET--in other words, do - * NOT call readpng2_cleanup() either here or in the finish_display() - * routine; wait until control returns to the main program via - * readpng2_decode_data() */ - - (*mainprog_ptr->mainprog_finish_display)(); - - - /* all done */ - - return; -} - - - - - -void readpng2_cleanup(mainprog_info *mainprog_ptr) -{ - png_structp png_ptr = (png_structp)mainprog_ptr->png_ptr; - png_infop info_ptr = (png_infop)mainprog_ptr->info_ptr; - - if (png_ptr && info_ptr) - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - - mainprog_ptr->png_ptr = NULL; - mainprog_ptr->info_ptr = NULL; -} - - - - - -static void readpng2_error_handler(png_structp png_ptr, png_const_charp msg) -{ - mainprog_info *mainprog_ptr; - - /* This function, aside from the extra step of retrieving the "error - * pointer" (below) and the fact that it exists within the application - * rather than within libpng, is essentially identical to libpng's - * default error handler. The second point is critical: since both - * setjmp() and longjmp() are called from the same code, they are - * guaranteed to have compatible notions of how big a jmp_buf is, - * regardless of whether _BSD_SOURCE or anything else has (or has not) - * been defined. */ - - fprintf(stderr, "readpng2 libpng error: %s\n", msg); - fflush(stderr); - - mainprog_ptr = png_get_error_ptr(png_ptr); - if (mainprog_ptr == NULL) { /* we are completely hosed now */ - fprintf(stderr, - "readpng2 severe error: jmpbuf not recoverable; terminating.\n"); - fflush(stderr); - exit(99); - } - - longjmp(mainprog_ptr->jmpbuf, 1); -} diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/readpng2.h b/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/readpng2.h deleted file mode 100644 index 2ed70d47e..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/readpng2.h +++ /dev/null @@ -1,91 +0,0 @@ -/*--------------------------------------------------------------------------- - - rpng2 - progressive-model PNG display program readpng2.h - - --------------------------------------------------------------------------- - - Copyright (c) 1998-2001 Greg Roelofs. All rights reserved. - - This software is provided "as is," without warranty of any kind, - express or implied. In no event shall the author or contributors - be held liable for any damages arising in any way from the use of - this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute - it freely, subject to the following restrictions: - - 1. Redistributions of source code must retain the above copyright - notice, disclaimer, and this list of conditions. - 2. Redistributions in binary form must reproduce the above copyright - notice, disclaimer, and this list of conditions in the documenta- - tion and/or other materials provided with the distribution. - 3. All advertising materials mentioning features or use of this - software must display the following acknowledgment: - - This product includes software developed by Greg Roelofs - and contributors for the book, "PNG: The Definitive Guide," - published by O'Reilly and Associates. - - ---------------------------------------------------------------------------*/ - -#ifndef TRUE -# define TRUE 1 -# define FALSE 0 -#endif - -#ifndef MAX -# define MAX(a,b) ((a) > (b)? (a) : (b)) -# define MIN(a,b) ((a) < (b)? (a) : (b)) -#endif - -#ifdef DEBUG -# define Trace(x) {fprintf x ; fflush(stderr); fflush(stdout);} -#else -# define Trace(x) ; -#endif - -typedef unsigned char uch; -typedef unsigned short ush; -typedef unsigned long ulg; - -typedef struct _mainprog_info { - double display_exponent; - ulg width; - ulg height; - void *png_ptr; - void *info_ptr; - void (*mainprog_init)(void); - void (*mainprog_display_row)(ulg row_num); - void (*mainprog_finish_display)(void); - uch *image_data; - uch **row_pointers; - jmp_buf jmpbuf; - int passes; /* not used */ - int pass; - int rowbytes; - int channels; - int need_bgcolor; -#if (defined(__i386__) || defined(_M_IX86)) - int nommxfilters; - int nommxcombine; - int nommxinterlace; -#endif - int done; - uch bg_red; - uch bg_green; - uch bg_blue; -} mainprog_info; - - -/* prototypes for public functions in readpng2.c */ - -void readpng2_version_info(void); - -int readpng2_check_sig(uch *sig, int num); - -int readpng2_init(mainprog_info *mainprog_ptr); - -int readpng2_decode_data(mainprog_info *mainprog_ptr, uch *rawbuf, ulg length); - -void readpng2_cleanup(mainprog_info *mainprog_ptr); diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/rpng-win.c b/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/rpng-win.c deleted file mode 100644 index b35e3ab5f..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/rpng-win.c +++ /dev/null @@ -1,642 +0,0 @@ -/*--------------------------------------------------------------------------- - - rpng - simple PNG display program rpng-win.c - - This program decodes and displays PNG images, with gamma correction and - optionally with a user-specified background color (in case the image has - transparency). It is very nearly the most basic PNG viewer possible. - This version is for 32-bit Windows; it may compile under 16-bit Windows - with a little tweaking (or maybe not). - - to do: - - handle quoted command-line args (especially filenames with spaces) - - have minimum window width: oh well - - use %.1023s to simplify truncation of title-bar string? - - --------------------------------------------------------------------------- - - Changelog: - - 1.00: initial public release - - 1.01: modified to allow abbreviated options; fixed long/ulong mis- - match; switched to png_jmpbuf() macro - - 1.02: added extra set of parentheses to png_jmpbuf() macro; fixed - command-line parsing bug - - 1.10: enabled "message window"/console (thanks to David Geldreich) - - --------------------------------------------------------------------------- - - Copyright (c) 1998-2001 Greg Roelofs. All rights reserved. - - This software is provided "as is," without warranty of any kind, - express or implied. In no event shall the author or contributors - be held liable for any damages arising in any way from the use of - this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute - it freely, subject to the following restrictions: - - 1. Redistributions of source code must retain the above copyright - notice, disclaimer, and this list of conditions. - 2. Redistributions in binary form must reproduce the above copyright - notice, disclaimer, and this list of conditions in the documenta- - tion and/or other materials provided with the distribution. - 3. All advertising materials mentioning features or use of this - software must display the following acknowledgment: - - This product includes software developed by Greg Roelofs - and contributors for the book, "PNG: The Definitive Guide," - published by O'Reilly and Associates. - - ---------------------------------------------------------------------------*/ - -#define PROGNAME "rpng-win" -#define LONGNAME "Simple PNG Viewer for Windows" -#define VERSION "1.20 of 28 May 2001" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> -#include <windows.h> -#include <conio.h> /* only for _getch() */ - -/* #define DEBUG : this enables the Trace() macros */ - -#include "readpng.h" /* typedefs, common macros, readpng prototypes */ - - -/* could just include png.h, but this macro is the only thing we need - * (name and typedefs changed to local versions); note that side effects - * only happen with alpha (which could easily be avoided with - * "ush acopy = (alpha);") */ - -#define alpha_composite(composite, fg, alpha, bg) { \ - ush temp = ((ush)(fg)*(ush)(alpha) + \ - (ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \ - (composite) = (uch)((temp + (temp >> 8)) >> 8); \ -} - - -/* local prototypes */ -static int rpng_win_create_window(HINSTANCE hInst, int showmode); -static int rpng_win_display_image(void); -static void rpng_win_cleanup(void); -LRESULT CALLBACK rpng_win_wndproc(HWND, UINT, WPARAM, LPARAM); - - -static char titlebar[1024], *window_name = titlebar; -static char *progname = PROGNAME; -static char *appname = LONGNAME; -static char *icon_name = PROGNAME; /* GRR: not (yet) used */ -static char *filename; -static FILE *infile; - -static char *bgstr; -static uch bg_red=0, bg_green=0, bg_blue=0; - -static double display_exponent; - -static ulg image_width, image_height, image_rowbytes; -static int image_channels; -static uch *image_data; - -/* Windows-specific variables */ -static ulg wimage_rowbytes; -static uch *dib; -static uch *wimage_data; -static BITMAPINFOHEADER *bmih; - -static HWND global_hwnd; - - - - -int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode) -{ - char *args[1024]; /* arbitrary limit, but should suffice */ - char *p, *q, **argv = args; - int argc = 0; - int rc, alen, flen; - int error = 0; - int have_bg = FALSE; - double LUT_exponent; /* just the lookup table */ - double CRT_exponent = 2.2; /* just the monitor */ - double default_display_exponent; /* whole display system */ - MSG msg; - - - filename = (char *)NULL; - - - /* First reenable console output, which normally goes to the bit bucket - * for windowed apps. Closing the console window will terminate the - * app. Thanks to David.Geldreich@realviz.com for supplying the magical - * incantation. */ - - AllocConsole(); - freopen("CONOUT$", "a", stderr); - freopen("CONOUT$", "a", stdout); - - - /* Next set the default value for our display-system exponent, i.e., - * the product of the CRT exponent and the exponent corresponding to - * the frame-buffer's lookup table (LUT), if any. This is not an - * exhaustive list of LUT values (e.g., OpenStep has a lot of weird - * ones), but it should cover 99% of the current possibilities. And - * yes, these ifdefs are completely wasted in a Windows program... */ - -#if defined(NeXT) - LUT_exponent = 1.0 / 2.2; - /* - if (some_next_function_that_returns_gamma(&next_gamma)) - LUT_exponent = 1.0 / next_gamma; - */ -#elif defined(sgi) - LUT_exponent = 1.0 / 1.7; - /* there doesn't seem to be any documented function to get the - * "gamma" value, so we do it the hard way */ - infile = fopen("/etc/config/system.glGammaVal", "r"); - if (infile) { - double sgi_gamma; - - fgets(tmpline, 80, infile); - fclose(infile); - sgi_gamma = atof(tmpline); - if (sgi_gamma > 0.0) - LUT_exponent = 1.0 / sgi_gamma; - } -#elif defined(Macintosh) - LUT_exponent = 1.8 / 2.61; - /* - if (some_mac_function_that_returns_gamma(&mac_gamma)) - LUT_exponent = mac_gamma / 2.61; - */ -#else - LUT_exponent = 1.0; /* assume no LUT: most PCs */ -#endif - - /* the defaults above give 1.0, 1.3, 1.5 and 2.2, respectively: */ - default_display_exponent = LUT_exponent * CRT_exponent; - - - /* If the user has set the SCREEN_GAMMA environment variable as suggested - * (somewhat imprecisely) in the libpng documentation, use that; otherwise - * use the default value we just calculated. Either way, the user may - * override this via a command-line option. */ - - if ((p = getenv("SCREEN_GAMMA")) != NULL) - display_exponent = atof(p); - else - display_exponent = default_display_exponent; - - - /* Windows really hates command lines, so we have to set up our own argv. - * Note that we do NOT bother with quoted arguments here, so don't use - * filenames with spaces in 'em! */ - - argv[argc++] = PROGNAME; - p = cmd; - for (;;) { - if (*p == ' ') - while (*++p == ' ') - ; - /* now p points at the first non-space after some spaces */ - if (*p == '\0') - break; /* nothing after the spaces: done */ - argv[argc++] = q = p; - while (*q && *q != ' ') - ++q; - /* now q points at a space or the end of the string */ - if (*q == '\0') - break; /* last argv already terminated; quit */ - *q = '\0'; /* change space to terminator */ - p = q + 1; - } - argv[argc] = NULL; /* terminate the argv array itself */ - - - /* Now parse the command line for options and the PNG filename. */ - - while (*++argv && !error) { - if (!strncmp(*argv, "-gamma", 2)) { - if (!*++argv) - ++error; - else { - display_exponent = atof(*argv); - if (display_exponent <= 0.0) - ++error; - } - } else if (!strncmp(*argv, "-bgcolor", 2)) { - if (!*++argv) - ++error; - else { - bgstr = *argv; - if (strlen(bgstr) != 7 || bgstr[0] != '#') - ++error; - else - have_bg = TRUE; - } - } else { - if (**argv != '-') { - filename = *argv; - if (argv[1]) /* shouldn't be any more args after filename */ - ++error; - } else - ++error; /* not expecting any other options */ - } - } - - if (!filename) { - ++error; - } else if (!(infile = fopen(filename, "rb"))) { - fprintf(stderr, PROGNAME ": can't open PNG file [%s]\n", filename); - ++error; - } else { - if ((rc = readpng_init(infile, &image_width, &image_height)) != 0) { - switch (rc) { - case 1: - fprintf(stderr, PROGNAME - ": [%s] is not a PNG file: incorrect signature\n", - filename); - break; - case 2: - fprintf(stderr, PROGNAME - ": [%s] has bad IHDR (libpng longjmp)\n", - filename); - break; - case 4: - fprintf(stderr, PROGNAME ": insufficient memory\n"); - break; - default: - fprintf(stderr, PROGNAME - ": unknown readpng_init() error\n"); - break; - } - ++error; - } - if (error) - fclose(infile); - } - - - /* usage screen */ - - if (error) { - int ch; - - fprintf(stderr, "\n%s %s: %s\n\n", PROGNAME, VERSION, appname); - readpng_version_info(); - fprintf(stderr, "\n" - "Usage: %s [-gamma exp] [-bgcolor bg] file.png\n" - " exp \ttransfer-function exponent (``gamma'') of the display\n" - "\t\t system in floating-point format (e.g., ``%.1f''); equal\n" - "\t\t to the product of the lookup-table exponent (varies)\n" - "\t\t and the CRT exponent (usually 2.2); must be positive\n" - " bg \tdesired background color in 7-character hex RGB format\n" - "\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n" - "\t\t used with transparent images\n" - "\nPress Q, Esc or mouse button 1 after image is displayed to quit.\n" - "Press Q or Esc to quit this usage screen.\n" - "\n", PROGNAME, default_display_exponent); - do - ch = _getch(); - while (ch != 'q' && ch != 'Q' && ch != 0x1B); - exit(1); - } else { - fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname); - fprintf(stderr, - "\n [console window: closing this window will terminate %s]\n\n", - PROGNAME); - } - - - /* set the title-bar string, but make sure buffer doesn't overflow */ - - alen = strlen(appname); - flen = strlen(filename); - if (alen + flen + 3 > 1023) - sprintf(titlebar, "%s: ...%s", appname, filename+(alen+flen+6-1023)); - else - sprintf(titlebar, "%s: %s", appname, filename); - - - /* if the user didn't specify a background color on the command line, - * check for one in the PNG file--if not, the initialized values of 0 - * (black) will be used */ - - if (have_bg) - sscanf(bgstr+1, "%2x%2x%2x", &bg_red, &bg_green, &bg_blue); - else if (readpng_get_bgcolor(&bg_red, &bg_green, &bg_blue) > 1) { - readpng_cleanup(TRUE); - fprintf(stderr, PROGNAME - ": libpng error while checking for background color\n"); - exit(2); - } - - - /* do the basic Windows initialization stuff, make the window and fill it - * with the background color */ - - if (rpng_win_create_window(hInst, showmode)) - exit(2); - - - /* decode the image, all at once */ - - Trace((stderr, "calling readpng_get_image()\n")) - image_data = readpng_get_image(display_exponent, &image_channels, - &image_rowbytes); - Trace((stderr, "done with readpng_get_image()\n")) - - - /* done with PNG file, so clean up to minimize memory usage (but do NOT - * nuke image_data!) */ - - readpng_cleanup(FALSE); - fclose(infile); - - if (!image_data) { - fprintf(stderr, PROGNAME ": unable to decode PNG image\n"); - exit(3); - } - - - /* display image (composite with background if requested) */ - - Trace((stderr, "calling rpng_win_display_image()\n")) - if (rpng_win_display_image()) { - free(image_data); - exit(4); - } - Trace((stderr, "done with rpng_win_display_image()\n")) - - - /* wait for the user to tell us when to quit */ - - printf( - "Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n"); - fflush(stdout); - - while (GetMessage(&msg, NULL, 0, 0)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - - - /* OK, we're done: clean up all image and Windows resources and go away */ - - rpng_win_cleanup(); - - return msg.wParam; -} - - - - - -static int rpng_win_create_window(HINSTANCE hInst, int showmode) -{ - uch *dest; - int extra_width, extra_height; - ulg i, j; - WNDCLASSEX wndclass; - - -/*--------------------------------------------------------------------------- - Allocate memory for the display-specific version of the image (round up - to multiple of 4 for Windows DIB). - ---------------------------------------------------------------------------*/ - - wimage_rowbytes = ((3*image_width + 3L) >> 2) << 2; - - if (!(dib = (uch *)malloc(sizeof(BITMAPINFOHEADER) + - wimage_rowbytes*image_height))) - { - return 4; /* fail */ - } - -/*--------------------------------------------------------------------------- - Initialize the DIB. Negative height means to use top-down BMP ordering - (must be uncompressed, but that's what we want). Bit count of 1, 4 or 8 - implies a colormap of RGBX quads, but 24-bit BMPs just use B,G,R values - directly => wimage_data begins immediately after BMP header. - ---------------------------------------------------------------------------*/ - - memset(dib, 0, sizeof(BITMAPINFOHEADER)); - bmih = (BITMAPINFOHEADER *)dib; - bmih->biSize = sizeof(BITMAPINFOHEADER); - bmih->biWidth = image_width; - bmih->biHeight = -((long)image_height); - bmih->biPlanes = 1; - bmih->biBitCount = 24; - bmih->biCompression = 0; - wimage_data = dib + sizeof(BITMAPINFOHEADER); - -/*--------------------------------------------------------------------------- - Fill in background color (black by default); data are in BGR order. - ---------------------------------------------------------------------------*/ - - for (j = 0; j < image_height; ++j) { - dest = wimage_data + j*wimage_rowbytes; - for (i = image_width; i > 0; --i) { - *dest++ = bg_blue; - *dest++ = bg_green; - *dest++ = bg_red; - } - } - -/*--------------------------------------------------------------------------- - Set the window parameters. - ---------------------------------------------------------------------------*/ - - memset(&wndclass, 0, sizeof(wndclass)); - - wndclass.cbSize = sizeof(wndclass); - wndclass.style = CS_HREDRAW | CS_VREDRAW; - wndclass.lpfnWndProc = rpng_win_wndproc; - wndclass.hInstance = hInst; - wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); - wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); - wndclass.hbrBackground = (HBRUSH)GetStockObject(DKGRAY_BRUSH); - wndclass.lpszMenuName = NULL; - wndclass.lpszClassName = progname; - wndclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION); - - RegisterClassEx(&wndclass); - -/*--------------------------------------------------------------------------- - Finally, create the window. - ---------------------------------------------------------------------------*/ - - extra_width = 2*(GetSystemMetrics(SM_CXBORDER) + - GetSystemMetrics(SM_CXDLGFRAME)); - extra_height = 2*(GetSystemMetrics(SM_CYBORDER) + - GetSystemMetrics(SM_CYDLGFRAME)) + - GetSystemMetrics(SM_CYCAPTION); - - global_hwnd = CreateWindow(progname, titlebar, WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, CW_USEDEFAULT, image_width+extra_width, - image_height+extra_height, NULL, NULL, hInst, NULL); - - ShowWindow(global_hwnd, showmode); - UpdateWindow(global_hwnd); - - return 0; - -} /* end function rpng_win_create_window() */ - - - - - -static int rpng_win_display_image() -{ - uch *src, *dest; - uch r, g, b, a; - ulg i, row, lastrow; - RECT rect; - - - Trace((stderr, "beginning display loop (image_channels == %d)\n", - image_channels)) - Trace((stderr, "(width = %ld, rowbytes = %ld, wimage_rowbytes = %d)\n", - image_width, image_rowbytes, wimage_rowbytes)) - - -/*--------------------------------------------------------------------------- - Blast image data to buffer. This whole routine takes place before the - message loop begins, so there's no real point in any pseudo-progressive - display... - ---------------------------------------------------------------------------*/ - - for (lastrow = row = 0; row < image_height; ++row) { - src = image_data + row*image_rowbytes; - dest = wimage_data + row*wimage_rowbytes; - if (image_channels == 3) { - for (i = image_width; i > 0; --i) { - r = *src++; - g = *src++; - b = *src++; - *dest++ = b; - *dest++ = g; /* note reverse order */ - *dest++ = r; - } - } else /* if (image_channels == 4) */ { - for (i = image_width; i > 0; --i) { - r = *src++; - g = *src++; - b = *src++; - a = *src++; - if (a == 255) { - *dest++ = b; - *dest++ = g; - *dest++ = r; - } else if (a == 0) { - *dest++ = bg_blue; - *dest++ = bg_green; - *dest++ = bg_red; - } else { - /* this macro (copied from png.h) composites the - * foreground and background values and puts the - * result into the first argument; there are no - * side effects with the first argument */ - alpha_composite(*dest++, b, a, bg_blue); - alpha_composite(*dest++, g, a, bg_green); - alpha_composite(*dest++, r, a, bg_red); - } - } - } - /* display after every 16 lines */ - if (((row+1) & 0xf) == 0) { - rect.left = 0L; - rect.top = (LONG)lastrow; - rect.right = (LONG)image_width; /* possibly off by one? */ - rect.bottom = (LONG)lastrow + 16L; /* possibly off by one? */ - InvalidateRect(global_hwnd, &rect, FALSE); - UpdateWindow(global_hwnd); /* similar to XFlush() */ - lastrow = row + 1; - } - } - - Trace((stderr, "calling final image-flush routine\n")) - if (lastrow < image_height) { - rect.left = 0L; - rect.top = (LONG)lastrow; - rect.right = (LONG)image_width; /* possibly off by one? */ - rect.bottom = (LONG)image_height; /* possibly off by one? */ - InvalidateRect(global_hwnd, &rect, FALSE); - UpdateWindow(global_hwnd); /* similar to XFlush() */ - } - -/* - last param determines whether or not background is wiped before paint - InvalidateRect(global_hwnd, NULL, TRUE); - UpdateWindow(global_hwnd); - */ - - return 0; -} - - - - - -static void rpng_win_cleanup() -{ - if (image_data) { - free(image_data); - image_data = NULL; - } - - if (dib) { - free(dib); - dib = NULL; - } -} - - - - - -LRESULT CALLBACK rpng_win_wndproc(HWND hwnd, UINT iMsg, WPARAM wP, LPARAM lP) -{ - HDC hdc; - PAINTSTRUCT ps; - int rc; - - switch (iMsg) { - case WM_CREATE: - /* one-time processing here, if any */ - return 0; - - case WM_PAINT: - hdc = BeginPaint(hwnd, &ps); - /* dest */ - rc = StretchDIBits(hdc, 0, 0, image_width, image_height, - /* source */ - 0, 0, image_width, image_height, - wimage_data, (BITMAPINFO *)bmih, - /* iUsage: no clue */ - 0, SRCCOPY); - EndPaint(hwnd, &ps); - return 0; - - /* wait for the user to tell us when to quit */ - case WM_CHAR: - switch (wP) { /* only need one, so ignore repeat count */ - case 'q': - case 'Q': - case 0x1B: /* Esc key */ - PostQuitMessage(0); - } - return 0; - - case WM_LBUTTONDOWN: /* another way of quitting */ - case WM_DESTROY: - PostQuitMessage(0); - return 0; - } - - return DefWindowProc(hwnd, iMsg, wP, lP); -} diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/rpng-x.c b/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/rpng-x.c deleted file mode 100644 index 062339780..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/rpng-x.c +++ /dev/null @@ -1,858 +0,0 @@ -/*--------------------------------------------------------------------------- - - rpng - simple PNG display program rpng-x.c - - This program decodes and displays PNG images, with gamma correction and - optionally with a user-specified background color (in case the image has - transparency). It is very nearly the most basic PNG viewer possible. - This version is for the X Window System (tested by author under Unix and - by Martin Zinser under OpenVMS; may work under OS/2 with some tweaking). - - to do: - - 8-bit support - - use %.1023s to simplify truncation of title-bar string? - - --------------------------------------------------------------------------- - - Changelog: - - 1.01: initial public release - - 1.02: modified to allow abbreviated options; fixed long/ulong mis- - match; switched to png_jmpbuf() macro - - 1.10: added support for non-default visuals; fixed X pixel-conversion - - 1.11: added extra set of parentheses to png_jmpbuf() macro; fixed - command-line parsing bug - - 1.12: fixed small X memory leak (thanks to Francois Petitjean) - - 1.13: fixed XFreeGC() crash bug - - --------------------------------------------------------------------------- - - Copyright (c) 1998-2001 Greg Roelofs. All rights reserved. - - This software is provided "as is," without warranty of any kind, - express or implied. In no event shall the author or contributors - be held liable for any damages arising in any way from the use of - this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute - it freely, subject to the following restrictions: - - 1. Redistributions of source code must retain the above copyright - notice, disclaimer, and this list of conditions. - 2. Redistributions in binary form must reproduce the above copyright - notice, disclaimer, and this list of conditions in the documenta- - tion and/or other materials provided with the distribution. - 3. All advertising materials mentioning features or use of this - software must display the following acknowledgment: - - This product includes software developed by Greg Roelofs - and contributors for the book, "PNG: The Definitive Guide," - published by O'Reilly and Associates. - - ---------------------------------------------------------------------------*/ - -#define PROGNAME "rpng-x" -#define LONGNAME "Simple PNG Viewer for X" -#define VERSION "1.13 of 16 August 2001" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> -#include <X11/Xlib.h> -#include <X11/Xutil.h> -#include <X11/Xos.h> -#include <X11/keysym.h> - -/* #define DEBUG : this enables the Trace() macros */ - -#include "readpng.h" /* typedefs, common macros, readpng prototypes */ - - -/* could just include png.h, but this macro is the only thing we need - * (name and typedefs changed to local versions); note that side effects - * only happen with alpha (which could easily be avoided with - * "ush acopy = (alpha);") */ - -#define alpha_composite(composite, fg, alpha, bg) { \ - ush temp = ((ush)(fg)*(ush)(alpha) + \ - (ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \ - (composite) = (uch)((temp + (temp >> 8)) >> 8); \ -} - - -/* local prototypes */ -static int rpng_x_create_window(void); -static int rpng_x_display_image(void); -static void rpng_x_cleanup(void); -static int rpng_x_msb(ulg u32val); - - -static char titlebar[1024], *window_name = titlebar; -static char *appname = LONGNAME; -static char *icon_name = PROGNAME; -static char *filename; -static FILE *infile; - -static char *bgstr; -static uch bg_red=0, bg_green=0, bg_blue=0; - -static double display_exponent; - -static ulg image_width, image_height, image_rowbytes; -static int image_channels; -static uch *image_data; - -/* X-specific variables */ -static char *displayname; -static XImage *ximage; -static Display *display; -static int depth; -static Visual *visual; -static XVisualInfo *visual_list; -static int RShift, GShift, BShift; -static ulg RMask, GMask, BMask; -static Window window; -static GC gc; -static Colormap colormap; - -static int have_nondefault_visual = FALSE; -static int have_colormap = FALSE; -static int have_window = FALSE; -static int have_gc = FALSE; -/* -ulg numcolors=0, pixels[256]; -ush reds[256], greens[256], blues[256]; - */ - - - - -int main(int argc, char **argv) -{ -#ifdef sgi - char tmpline[80]; -#endif - char *p; - int rc, alen, flen; - int error = 0; - int have_bg = FALSE; - double LUT_exponent; /* just the lookup table */ - double CRT_exponent = 2.2; /* just the monitor */ - double default_display_exponent; /* whole display system */ - XEvent e; - KeySym k; - - - displayname = (char *)NULL; - filename = (char *)NULL; - - - /* First set the default value for our display-system exponent, i.e., - * the product of the CRT exponent and the exponent corresponding to - * the frame-buffer's lookup table (LUT), if any. This is not an - * exhaustive list of LUT values (e.g., OpenStep has a lot of weird - * ones), but it should cover 99% of the current possibilities. */ - -#if defined(NeXT) - LUT_exponent = 1.0 / 2.2; - /* - if (some_next_function_that_returns_gamma(&next_gamma)) - LUT_exponent = 1.0 / next_gamma; - */ -#elif defined(sgi) - LUT_exponent = 1.0 / 1.7; - /* there doesn't seem to be any documented function to get the - * "gamma" value, so we do it the hard way */ - infile = fopen("/etc/config/system.glGammaVal", "r"); - if (infile) { - double sgi_gamma; - - fgets(tmpline, 80, infile); - fclose(infile); - sgi_gamma = atof(tmpline); - if (sgi_gamma > 0.0) - LUT_exponent = 1.0 / sgi_gamma; - } -#elif defined(Macintosh) - LUT_exponent = 1.8 / 2.61; - /* - if (some_mac_function_that_returns_gamma(&mac_gamma)) - LUT_exponent = mac_gamma / 2.61; - */ -#else - LUT_exponent = 1.0; /* assume no LUT: most PCs */ -#endif - - /* the defaults above give 1.0, 1.3, 1.5 and 2.2, respectively: */ - default_display_exponent = LUT_exponent * CRT_exponent; - - - /* If the user has set the SCREEN_GAMMA environment variable as suggested - * (somewhat imprecisely) in the libpng documentation, use that; otherwise - * use the default value we just calculated. Either way, the user may - * override this via a command-line option. */ - - if ((p = getenv("SCREEN_GAMMA")) != NULL) - display_exponent = atof(p); - else - display_exponent = default_display_exponent; - - - /* Now parse the command line for options and the PNG filename. */ - - while (*++argv && !error) { - if (!strncmp(*argv, "-display", 2)) { - if (!*++argv) - ++error; - else - displayname = *argv; - } else if (!strncmp(*argv, "-gamma", 2)) { - if (!*++argv) - ++error; - else { - display_exponent = atof(*argv); - if (display_exponent <= 0.0) - ++error; - } - } else if (!strncmp(*argv, "-bgcolor", 2)) { - if (!*++argv) - ++error; - else { - bgstr = *argv; - if (strlen(bgstr) != 7 || bgstr[0] != '#') - ++error; - else - have_bg = TRUE; - } - } else { - if (**argv != '-') { - filename = *argv; - if (argv[1]) /* shouldn't be any more args after filename */ - ++error; - } else - ++error; /* not expecting any other options */ - } - } - - if (!filename) { - ++error; - } else if (!(infile = fopen(filename, "rb"))) { - fprintf(stderr, PROGNAME ": can't open PNG file [%s]\n", filename); - ++error; - } else { - if ((rc = readpng_init(infile, &image_width, &image_height)) != 0) { - switch (rc) { - case 1: - fprintf(stderr, PROGNAME - ": [%s] is not a PNG file: incorrect signature\n", - filename); - break; - case 2: - fprintf(stderr, PROGNAME - ": [%s] has bad IHDR (libpng longjmp)\n", - filename); - break; - case 4: - fprintf(stderr, PROGNAME ": insufficient memory\n"); - break; - default: - fprintf(stderr, PROGNAME - ": unknown readpng_init() error\n"); - break; - } - ++error; - } else { - display = XOpenDisplay(displayname); - if (!display) { - readpng_cleanup(TRUE); - fprintf(stderr, PROGNAME ": can't open X display [%s]\n", - displayname? displayname : "default"); - ++error; - } - } - if (error) - fclose(infile); - } - - - /* usage screen */ - - if (error) { - fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname); - readpng_version_info(); - fprintf(stderr, "\n" - "Usage: %s [-display xdpy] [-gamma exp] [-bgcolor bg] file.png\n" - " xdpy\tname of the target X display (e.g., ``hostname:0'')\n" - " exp \ttransfer-function exponent (``gamma'') of the display\n" - "\t\t system in floating-point format (e.g., ``%.1f''); equal\n" - "\t\t to the product of the lookup-table exponent (varies)\n" - "\t\t and the CRT exponent (usually 2.2); must be positive\n" - " bg \tdesired background color in 7-character hex RGB format\n" - "\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n" - "\t\t used with transparent images\n" - "\nPress Q, Esc or mouse button 1 (within image window, after image\n" - "is displayed) to quit.\n" - "\n", PROGNAME, default_display_exponent); - exit(1); - } - - - /* set the title-bar string, but make sure buffer doesn't overflow */ - - alen = strlen(appname); - flen = strlen(filename); - if (alen + flen + 3 > 1023) - sprintf(titlebar, "%s: ...%s", appname, filename+(alen+flen+6-1023)); - else - sprintf(titlebar, "%s: %s", appname, filename); - - - /* if the user didn't specify a background color on the command line, - * check for one in the PNG file--if not, the initialized values of 0 - * (black) will be used */ - - if (have_bg) { - unsigned r, g, b; /* this approach quiets compiler warnings */ - - sscanf(bgstr+1, "%2x%2x%2x", &r, &g, &b); - bg_red = (uch)r; - bg_green = (uch)g; - bg_blue = (uch)b; - } else if (readpng_get_bgcolor(&bg_red, &bg_green, &bg_blue) > 1) { - readpng_cleanup(TRUE); - fprintf(stderr, PROGNAME - ": libpng error while checking for background color\n"); - exit(2); - } - - - /* do the basic X initialization stuff, make the window and fill it - * with the background color */ - - if (rpng_x_create_window()) - exit(2); - - - /* decode the image, all at once */ - - Trace((stderr, "calling readpng_get_image()\n")) - image_data = readpng_get_image(display_exponent, &image_channels, - &image_rowbytes); - Trace((stderr, "done with readpng_get_image()\n")) - - - /* done with PNG file, so clean up to minimize memory usage (but do NOT - * nuke image_data!) */ - - readpng_cleanup(FALSE); - fclose(infile); - - if (!image_data) { - fprintf(stderr, PROGNAME ": unable to decode PNG image\n"); - exit(3); - } - - - /* display image (composite with background if requested) */ - - Trace((stderr, "calling rpng_x_display_image()\n")) - if (rpng_x_display_image()) { - free(image_data); - exit(4); - } - Trace((stderr, "done with rpng_x_display_image()\n")) - - - /* wait for the user to tell us when to quit */ - - printf( - "Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n"); - fflush(stdout); - - do - XNextEvent(display, &e); - while (!(e.type == ButtonPress && e.xbutton.button == Button1) && - !(e.type == KeyPress && /* v--- or 1 for shifted keys */ - ((k = XLookupKeysym(&e.xkey, 0)) == XK_q || k == XK_Escape) )); - - - /* OK, we're done: clean up all image and X resources and go away */ - - rpng_x_cleanup(); - - return 0; -} - - - - - -static int rpng_x_create_window(void) -{ - uch *xdata; - int need_colormap = FALSE; - int screen, pad; - ulg bg_pixel = 0L; - ulg attrmask; - Window root; - XEvent e; - XGCValues gcvalues; - XSetWindowAttributes attr; - XSizeHints *size_hints; - XTextProperty windowName, *pWindowName = &windowName; - XTextProperty iconName, *pIconName = &iconName; - XVisualInfo visual_info; - XWMHints *wm_hints; - - - screen = DefaultScreen(display); - depth = DisplayPlanes(display, screen); - root = RootWindow(display, screen); - -#ifdef DEBUG - XSynchronize(display, True); -#endif - -#if 0 -/* GRR: add 8-bit support */ - if (/* depth != 8 && */ depth != 16 && depth != 24 && depth != 32) { - fprintf(stderr, - "screen depth %d not supported (only 16-, 24- or 32-bit TrueColor)\n", - depth); - return 2; - } - - XMatchVisualInfo(display, screen, depth, - (depth == 8)? PseudoColor : TrueColor, &visual_info); - visual = visual_info.visual; -#else - if (depth != 16 && depth != 24 && depth != 32) { - int visuals_matched = 0; - - Trace((stderr, "default depth is %d: checking other visuals\n", - depth)) - - /* 24-bit first */ - visual_info.screen = screen; - visual_info.depth = 24; - visual_list = XGetVisualInfo(display, - VisualScreenMask | VisualDepthMask, &visual_info, &visuals_matched); - if (visuals_matched == 0) { -/* GRR: add 15-, 16- and 32-bit TrueColor visuals (also DirectColor?) */ - fprintf(stderr, "default screen depth %d not supported, and no" - " 24-bit visuals found\n", depth); - return 2; - } - Trace((stderr, "XGetVisualInfo() returned %d 24-bit visuals\n", - visuals_matched)) - visual = visual_list[0].visual; - depth = visual_list[0].depth; -/* - colormap_size = visual_list[0].colormap_size; - visual_class = visual->class; - visualID = XVisualIDFromVisual(visual); - */ - have_nondefault_visual = TRUE; - need_colormap = TRUE; - } else { - XMatchVisualInfo(display, screen, depth, TrueColor, &visual_info); - visual = visual_info.visual; - } -#endif - - RMask = visual->red_mask; - GMask = visual->green_mask; - BMask = visual->blue_mask; - -/* GRR: add/check 8-bit support */ - if (depth == 8 || need_colormap) { - colormap = XCreateColormap(display, root, visual, AllocNone); - if (!colormap) { - fprintf(stderr, "XCreateColormap() failed\n"); - return 2; - } - have_colormap = TRUE; - } - if (depth == 15 || depth == 16) { - RShift = 15 - rpng_x_msb(RMask); /* these are right-shifts */ - GShift = 15 - rpng_x_msb(GMask); - BShift = 15 - rpng_x_msb(BMask); - } else if (depth > 16) { -#define NO_24BIT_MASKS -#ifdef NO_24BIT_MASKS - RShift = rpng_x_msb(RMask) - 7; /* these are left-shifts */ - GShift = rpng_x_msb(GMask) - 7; - BShift = rpng_x_msb(BMask) - 7; -#else - RShift = 7 - rpng_x_msb(RMask); /* these are right-shifts, too */ - GShift = 7 - rpng_x_msb(GMask); - BShift = 7 - rpng_x_msb(BMask); -#endif - } - if (depth >= 15 && (RShift < 0 || GShift < 0 || BShift < 0)) { - fprintf(stderr, "rpng internal logic error: negative X shift(s)!\n"); - return 2; - } - -/*--------------------------------------------------------------------------- - Finally, create the window. - ---------------------------------------------------------------------------*/ - - attr.backing_store = Always; - attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask; - attrmask = CWBackingStore | CWEventMask; - if (have_nondefault_visual) { - attr.colormap = colormap; - attr.background_pixel = 0; - attr.border_pixel = 1; - attrmask |= CWColormap | CWBackPixel | CWBorderPixel; - } - - window = XCreateWindow(display, root, 0, 0, image_width, image_height, 0, - depth, InputOutput, visual, attrmask, &attr); - - if (window == None) { - fprintf(stderr, "XCreateWindow() failed\n"); - return 2; - } else - have_window = TRUE; - - if (depth == 8) - XSetWindowColormap(display, window, colormap); - - if (!XStringListToTextProperty(&window_name, 1, pWindowName)) - pWindowName = NULL; - if (!XStringListToTextProperty(&icon_name, 1, pIconName)) - pIconName = NULL; - - /* OK if either hints allocation fails; XSetWMProperties() allows NULLs */ - - if ((size_hints = XAllocSizeHints()) != NULL) { - /* window will not be resizable */ - size_hints->flags = PMinSize | PMaxSize; - size_hints->min_width = size_hints->max_width = (int)image_width; - size_hints->min_height = size_hints->max_height = (int)image_height; - } - - if ((wm_hints = XAllocWMHints()) != NULL) { - wm_hints->initial_state = NormalState; - wm_hints->input = True; - /* wm_hints->icon_pixmap = icon_pixmap; */ - wm_hints->flags = StateHint | InputHint /* | IconPixmapHint */ ; - } - - XSetWMProperties(display, window, pWindowName, pIconName, NULL, 0, - size_hints, wm_hints, NULL); - - /* various properties and hints no longer needed; free memory */ - if (pWindowName) - XFree(pWindowName->value); - if (pIconName) - XFree(pIconName->value); - if (size_hints) - XFree(size_hints); - if (wm_hints) - XFree(wm_hints); - - XMapWindow(display, window); - - gc = XCreateGC(display, window, 0, &gcvalues); - have_gc = TRUE; - -/*--------------------------------------------------------------------------- - Fill window with the specified background color. - ---------------------------------------------------------------------------*/ - - if (depth == 24 || depth == 32) { - bg_pixel = ((ulg)bg_red << RShift) | - ((ulg)bg_green << GShift) | - ((ulg)bg_blue << BShift); - } else if (depth == 16) { - bg_pixel = ((((ulg)bg_red << 8) >> RShift) & RMask) | - ((((ulg)bg_green << 8) >> GShift) & GMask) | - ((((ulg)bg_blue << 8) >> BShift) & BMask); - } else /* depth == 8 */ { - - /* GRR: add 8-bit support */ - - } - - XSetForeground(display, gc, bg_pixel); - XFillRectangle(display, window, gc, 0, 0, image_width, image_height); - -/*--------------------------------------------------------------------------- - Wait for first Expose event to do any drawing, then flush. - ---------------------------------------------------------------------------*/ - - do - XNextEvent(display, &e); - while (e.type != Expose || e.xexpose.count); - - XFlush(display); - -/*--------------------------------------------------------------------------- - Allocate memory for the X- and display-specific version of the image. - ---------------------------------------------------------------------------*/ - - if (depth == 24 || depth == 32) { - xdata = (uch *)malloc(4*image_width*image_height); - pad = 32; - } else if (depth == 16) { - xdata = (uch *)malloc(2*image_width*image_height); - pad = 16; - } else /* depth == 8 */ { - xdata = (uch *)malloc(image_width*image_height); - pad = 8; - } - - if (!xdata) { - fprintf(stderr, PROGNAME ": unable to allocate image memory\n"); - return 4; - } - - ximage = XCreateImage(display, visual, depth, ZPixmap, 0, - (char *)xdata, image_width, image_height, pad, 0); - - if (!ximage) { - fprintf(stderr, PROGNAME ": XCreateImage() failed\n"); - free(xdata); - return 3; - } - - /* to avoid testing the byte order every pixel (or doubling the size of - * the drawing routine with a giant if-test), we arbitrarily set the byte - * order to MSBFirst and let Xlib worry about inverting things on little- - * endian machines (like Linux/x86, old VAXen, etc.)--this is not the most - * efficient approach (the giant if-test would be better), but in the - * interest of clarity, we take the easy way out... */ - - ximage->byte_order = MSBFirst; - - return 0; - -} /* end function rpng_x_create_window() */ - - - - - -static int rpng_x_display_image(void) -{ - uch *src; - char *dest; - uch r, g, b, a; - ulg i, row, lastrow = 0; - ulg pixel; - int ximage_rowbytes = ximage->bytes_per_line; -/* int bpp = ximage->bits_per_pixel; */ - - - Trace((stderr, "beginning display loop (image_channels == %d)\n", - image_channels)) - Trace((stderr, " (width = %ld, rowbytes = %ld, ximage_rowbytes = %d)\n", - image_width, image_rowbytes, ximage_rowbytes)) - Trace((stderr, " (bpp = %d)\n", ximage->bits_per_pixel)) - Trace((stderr, " (byte_order = %s)\n", ximage->byte_order == MSBFirst? - "MSBFirst" : (ximage->byte_order == LSBFirst? "LSBFirst" : "unknown"))) - - if (depth == 24 || depth == 32) { - ulg red, green, blue; - - for (lastrow = row = 0; row < image_height; ++row) { - src = image_data + row*image_rowbytes; - dest = ximage->data + row*ximage_rowbytes; - if (image_channels == 3) { - for (i = image_width; i > 0; --i) { - red = *src++; - green = *src++; - blue = *src++; -#ifdef NO_24BIT_MASKS - pixel = (red << RShift) | - (green << GShift) | - (blue << BShift); - /* recall that we set ximage->byte_order = MSBFirst above */ - /* GRR BUG: this assumes bpp == 32, but may be 24: */ - *dest++ = (char)((pixel >> 24) & 0xff); - *dest++ = (char)((pixel >> 16) & 0xff); - *dest++ = (char)((pixel >> 8) & 0xff); - *dest++ = (char)( pixel & 0xff); -#else - red = (RShift < 0)? red << (-RShift) : red >> RShift; - green = (GShift < 0)? green << (-GShift) : green >> GShift; - blue = (BShift < 0)? blue << (-BShift) : blue >> BShift; - pixel = (red & RMask) | (green & GMask) | (blue & BMask); - /* recall that we set ximage->byte_order = MSBFirst above */ - *dest++ = (char)((pixel >> 24) & 0xff); - *dest++ = (char)((pixel >> 16) & 0xff); - *dest++ = (char)((pixel >> 8) & 0xff); - *dest++ = (char)( pixel & 0xff); -#endif - } - } else /* if (image_channels == 4) */ { - for (i = image_width; i > 0; --i) { - r = *src++; - g = *src++; - b = *src++; - a = *src++; - if (a == 255) { - red = r; - green = g; - blue = b; - } else if (a == 0) { - red = bg_red; - green = bg_green; - blue = bg_blue; - } else { - /* this macro (from png.h) composites the foreground - * and background values and puts the result into the - * first argument */ - alpha_composite(red, r, a, bg_red); - alpha_composite(green, g, a, bg_green); - alpha_composite(blue, b, a, bg_blue); - } - pixel = (red << RShift) | - (green << GShift) | - (blue << BShift); - /* recall that we set ximage->byte_order = MSBFirst above */ - *dest++ = (char)((pixel >> 24) & 0xff); - *dest++ = (char)((pixel >> 16) & 0xff); - *dest++ = (char)((pixel >> 8) & 0xff); - *dest++ = (char)( pixel & 0xff); - } - } - /* display after every 16 lines */ - if (((row+1) & 0xf) == 0) { - XPutImage(display, window, gc, ximage, 0, (int)lastrow, 0, - (int)lastrow, image_width, 16); - XFlush(display); - lastrow = row + 1; - } - } - - } else if (depth == 16) { - ush red, green, blue; - - for (lastrow = row = 0; row < image_height; ++row) { - src = image_data + row*image_rowbytes; - dest = ximage->data + row*ximage_rowbytes; - if (image_channels == 3) { - for (i = image_width; i > 0; --i) { - red = ((ush)(*src) << 8); - ++src; - green = ((ush)(*src) << 8); - ++src; - blue = ((ush)(*src) << 8); - ++src; - pixel = ((red >> RShift) & RMask) | - ((green >> GShift) & GMask) | - ((blue >> BShift) & BMask); - /* recall that we set ximage->byte_order = MSBFirst above */ - *dest++ = (char)((pixel >> 8) & 0xff); - *dest++ = (char)( pixel & 0xff); - } - } else /* if (image_channels == 4) */ { - for (i = image_width; i > 0; --i) { - r = *src++; - g = *src++; - b = *src++; - a = *src++; - if (a == 255) { - red = ((ush)r << 8); - green = ((ush)g << 8); - blue = ((ush)b << 8); - } else if (a == 0) { - red = ((ush)bg_red << 8); - green = ((ush)bg_green << 8); - blue = ((ush)bg_blue << 8); - } else { - /* this macro (from png.h) composites the foreground - * and background values and puts the result back into - * the first argument (== fg byte here: safe) */ - alpha_composite(r, r, a, bg_red); - alpha_composite(g, g, a, bg_green); - alpha_composite(b, b, a, bg_blue); - red = ((ush)r << 8); - green = ((ush)g << 8); - blue = ((ush)b << 8); - } - pixel = ((red >> RShift) & RMask) | - ((green >> GShift) & GMask) | - ((blue >> BShift) & BMask); - /* recall that we set ximage->byte_order = MSBFirst above */ - *dest++ = (char)((pixel >> 8) & 0xff); - *dest++ = (char)( pixel & 0xff); - } - } - /* display after every 16 lines */ - if (((row+1) & 0xf) == 0) { - XPutImage(display, window, gc, ximage, 0, (int)lastrow, 0, - (int)lastrow, image_width, 16); - XFlush(display); - lastrow = row + 1; - } - } - - } else /* depth == 8 */ { - - /* GRR: add 8-bit support */ - - } - - Trace((stderr, "calling final XPutImage()\n")) - if (lastrow < image_height) { - XPutImage(display, window, gc, ximage, 0, (int)lastrow, 0, - (int)lastrow, image_width, image_height-lastrow); - XFlush(display); - } - - return 0; -} - - - - -static void rpng_x_cleanup(void) -{ - if (image_data) { - free(image_data); - image_data = NULL; - } - - if (ximage) { - if (ximage->data) { - free(ximage->data); /* we allocated it, so we free it */ - ximage->data = (char *)NULL; /* instead of XDestroyImage() */ - } - XDestroyImage(ximage); - ximage = NULL; - } - - if (have_gc) - XFreeGC(display, gc); - - if (have_window) - XDestroyWindow(display, window); - - if (have_colormap) - XFreeColormap(display, colormap); - - if (have_nondefault_visual) - XFree(visual_list); -} - - - - - -static int rpng_x_msb(ulg u32val) -{ - int i; - - for (i = 31; i >= 0; --i) { - if (u32val & 0x80000000L) - break; - u32val <<= 1; - } - return i; -} diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/rpng2-win.c b/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/rpng2-win.c deleted file mode 100644 index 46f219184..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/rpng2-win.c +++ /dev/null @@ -1,1166 +0,0 @@ -/*--------------------------------------------------------------------------- - - rpng2 - progressive-model PNG display program rpng2-win.c - - This program decodes and displays PNG files progressively, as if it were - a web browser (though the front end is only set up to read from files). - It supports gamma correction, user-specified background colors, and user- - specified background patterns (for transparent images). This version is - for 32-bit Windows; it may compile under 16-bit Windows with a little - tweaking (or maybe not). Thanks to Adam Costello and Pieter S. van der - Meulen for the "diamond" and "radial waves" patterns, respectively. - - to do: - - handle quoted command-line args (especially filenames with spaces) - - finish resizable checkerboard-gradient (sizes 4-128?) - - use %.1023s to simplify truncation of title-bar string? - - have minimum window width: oh well - - --------------------------------------------------------------------------- - - Changelog: - - 1.01: initial public release - - 1.02: fixed cut-and-paste error in usage screen (oops...) - - 1.03: modified to allow abbreviated options - - 1.04: removed bogus extra argument from usage fprintf() [Glenn R-P?]; - fixed command-line parsing bug - - 1.10: enabled "message window"/console (thanks to David Geldreich) - - 1.20: added runtime MMX-enabling/disabling and new -mmx* options - - 1.21: made minor tweak to usage screen to fit within 25-line console - - --------------------------------------------------------------------------- - - Copyright (c) 1998-2001 Greg Roelofs. All rights reserved. - - This software is provided "as is," without warranty of any kind, - express or implied. In no event shall the author or contributors - be held liable for any damages arising in any way from the use of - this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute - it freely, subject to the following restrictions: - - 1. Redistributions of source code must retain the above copyright - notice, disclaimer, and this list of conditions. - 2. Redistributions in binary form must reproduce the above copyright - notice, disclaimer, and this list of conditions in the documenta- - tion and/or other materials provided with the distribution. - 3. All advertising materials mentioning features or use of this - software must display the following acknowledgment: - - This product includes software developed by Greg Roelofs - and contributors for the book, "PNG: The Definitive Guide," - published by O'Reilly and Associates. - - ---------------------------------------------------------------------------*/ - -#define PROGNAME "rpng2-win" -#define LONGNAME "Progressive PNG Viewer for Windows" -#define VERSION "1.21 of 29 June 2001" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <setjmp.h> /* for jmpbuf declaration in readpng2.h */ -#include <time.h> -#include <math.h> /* only for PvdM background code */ -#include <windows.h> -#include <conio.h> /* only for _getch() */ - -/* all for PvdM background code: */ -#ifndef PI -# define PI 3.141592653589793238 -#endif -#define PI_2 (PI*0.5) -#define INV_PI_360 (360.0 / PI) -#define MAX(a,b) (a>b?a:b) -#define MIN(a,b) (a<b?a:b) -#define CLIP(a,min,max) MAX(min,MIN((a),max)) -#define ABS(a) ((a)<0?-(a):(a)) -#define CLIP8P(c) MAX(0,(MIN((c),255))) /* 8-bit pos. integer (uch) */ -#define ROUNDF(f) ((int)(f + 0.5)) - -#define rgb1_max bg_freq -#define rgb1_min bg_gray -#define rgb2_max bg_bsat -#define rgb2_min bg_brot - -/* #define DEBUG */ /* this enables the Trace() macros */ - -#include "readpng2.h" /* typedefs, common macros, readpng2 prototypes */ - - -/* could just include png.h, but this macro is the only thing we need - * (name and typedefs changed to local versions); note that side effects - * only happen with alpha (which could easily be avoided with - * "ush acopy = (alpha);") */ - -#define alpha_composite(composite, fg, alpha, bg) { \ - ush temp = ((ush)(fg)*(ush)(alpha) + \ - (ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \ - (composite) = (uch)((temp + (temp >> 8)) >> 8); \ -} - - -#define INBUFSIZE 4096 /* with pseudo-timing on (1 sec delay/block), this - * block size corresponds roughly to a download - * speed 10% faster than theoretical 33.6K maximum - * (assuming 8 data bits, 1 stop bit and no other - * overhead) */ - -/* local prototypes */ -static void rpng2_win_init(void); -static int rpng2_win_create_window(void); -static int rpng2_win_load_bg_image(void); -static void rpng2_win_display_row(ulg row); -static void rpng2_win_finish_display(void); -static void rpng2_win_cleanup(void); -LRESULT CALLBACK rpng2_win_wndproc(HWND, UINT, WPARAM, LPARAM); - - -static char titlebar[1024], *window_name = titlebar; -static char *progname = PROGNAME; -static char *appname = LONGNAME; -static char *icon_name = PROGNAME; /* GRR: not (yet) used */ -static char *filename; -static FILE *infile; - -static mainprog_info rpng2_info; - -static uch inbuf[INBUFSIZE]; -static int incount; - -static int pat = 6; /* must be less than num_bgpat */ -static int bg_image = 0; -static int bgscale = 16; -static ulg bg_rowbytes; -static uch *bg_data; - -static struct rgb_color { - uch r, g, b; -} rgb[] = { - { 0, 0, 0}, /* 0: black */ - {255, 255, 255}, /* 1: white */ - {173, 132, 57}, /* 2: tan */ - { 64, 132, 0}, /* 3: medium green */ - {189, 117, 1}, /* 4: gold */ - {253, 249, 1}, /* 5: yellow */ - { 0, 0, 255}, /* 6: blue */ - { 0, 0, 120}, /* 7: medium blue */ - {255, 0, 255}, /* 8: magenta */ - { 64, 0, 64}, /* 9: dark magenta */ - {255, 0, 0}, /* 10: red */ - { 64, 0, 0}, /* 11: dark red */ - {255, 127, 0}, /* 12: orange */ - {192, 96, 0}, /* 13: darker orange */ - { 24, 60, 0}, /* 14: dark green-yellow */ - { 85, 125, 200} /* 15: ice blue */ -}; -/* not used for now, but should be for error-checking: -static int num_rgb = sizeof(rgb) / sizeof(struct rgb_color); - */ - -/* - This whole struct is a fairly cheesy way to keep the number of - command-line options to a minimum. The radial-waves background - type is a particularly poor fit to the integer elements of the - struct...but a few macros and a little fixed-point math will do - wonders for ya. - - type bits: - F E D C B A 9 8 7 6 5 4 3 2 1 0 - | | | | | - | | +-+-+-- 0 = sharp-edged checkerboard - | | 1 = soft diamonds - | | 2 = radial waves - | | 3-7 = undefined - | +-- gradient #2 inverted? - +-- alternating columns inverted? - */ -static struct background_pattern { - ush type; - int rgb1_max, rgb1_min; /* or bg_freq, bg_gray */ - int rgb2_max, rgb2_min; /* or bg_bsat, bg_brot (both scaled by 10)*/ -} bg[] = { - {0+8, 2,0, 1,15}, /* checkered: tan/black vs. white/ice blue */ - {0+24, 2,0, 1,0}, /* checkered: tan/black vs. white/black */ - {0+8, 4,5, 0,2}, /* checkered: gold/yellow vs. black/tan */ - {0+8, 4,5, 0,6}, /* checkered: gold/yellow vs. black/blue */ - {0, 7,0, 8,9}, /* checkered: deep blue/black vs. magenta */ - {0+8, 13,0, 5,14}, /* checkered: orange/black vs. yellow */ - {0+8, 12,0, 10,11}, /* checkered: orange/black vs. red */ - {1, 7,0, 8,0}, /* diamonds: deep blue/black vs. magenta */ - {1, 12,0, 11,0}, /* diamonds: orange vs. dark red */ - {1, 10,0, 7,0}, /* diamonds: red vs. medium blue */ - {1, 4,0, 5,0}, /* diamonds: gold vs. yellow */ - {1, 3,0, 0,0}, /* diamonds: medium green vs. black */ - {2, 16, 100, 20, 0}, /* radial: ~hard radial color-beams */ - {2, 18, 100, 10, 2}, /* radial: soft, curved radial color-beams */ - {2, 16, 256, 100, 250}, /* radial: very tight spiral */ - {2, 10000, 256, 11, 0} /* radial: dipole-moire' (almost fractal) */ -}; -static int num_bgpat = sizeof(bg) / sizeof(struct background_pattern); - - -/* Windows-specific global variables (could go in struct, but messy...) */ -static ulg wimage_rowbytes; -static uch *dib; -static uch *wimage_data; -static BITMAPINFOHEADER *bmih; - -static HWND global_hwnd; -static HINSTANCE global_hInst; -static int global_showmode; - - - - -int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode) -{ - char *args[1024]; /* arbitrary limit, but should suffice */ - char **argv = args; - char *p, *q, *bgstr = NULL; - int argc = 0; - int rc, alen, flen; - int error = 0; - int timing = FALSE; - int have_bg = FALSE; - double LUT_exponent; /* just the lookup table */ - double CRT_exponent = 2.2; /* just the monitor */ - double default_display_exponent; /* whole display system */ - MSG msg; - - - /* First initialize a few things, just to be sure--memset takes care of - * default background color (black), booleans (FALSE), pointers (NULL), - * etc. */ - - global_hInst = hInst; - global_showmode = showmode; - filename = (char *)NULL; - memset(&rpng2_info, 0, sizeof(mainprog_info)); - - - /* Next reenable console output, which normally goes to the bit bucket - * for windowed apps. Closing the console window will terminate the - * app. Thanks to David.Geldreich@realviz.com for supplying the magical - * incantation. */ - - AllocConsole(); - freopen("CONOUT$", "a", stderr); - freopen("CONOUT$", "a", stdout); - - - /* Set the default value for our display-system exponent, i.e., the - * product of the CRT exponent and the exponent corresponding to - * the frame-buffer's lookup table (LUT), if any. This is not an - * exhaustive list of LUT values (e.g., OpenStep has a lot of weird - * ones), but it should cover 99% of the current possibilities. And - * yes, these ifdefs are completely wasted in a Windows program... */ - -#if defined(NeXT) - /* third-party utilities can modify the default LUT exponent */ - LUT_exponent = 1.0 / 2.2; - /* - if (some_next_function_that_returns_gamma(&next_gamma)) - LUT_exponent = 1.0 / next_gamma; - */ -#elif defined(sgi) - LUT_exponent = 1.0 / 1.7; - /* there doesn't seem to be any documented function to - * get the "gamma" value, so we do it the hard way */ - infile = fopen("/etc/config/system.glGammaVal", "r"); - if (infile) { - double sgi_gamma; - - fgets(tmpline, 80, infile); - fclose(infile); - sgi_gamma = atof(tmpline); - if (sgi_gamma > 0.0) - LUT_exponent = 1.0 / sgi_gamma; - } -#elif defined(Macintosh) - LUT_exponent = 1.8 / 2.61; - /* - if (some_mac_function_that_returns_gamma(&mac_gamma)) - LUT_exponent = mac_gamma / 2.61; - */ -#else - LUT_exponent = 1.0; /* assume no LUT: most PCs */ -#endif - - /* the defaults above give 1.0, 1.3, 1.5 and 2.2, respectively: */ - default_display_exponent = LUT_exponent * CRT_exponent; - - - /* If the user has set the SCREEN_GAMMA environment variable as suggested - * (somewhat imprecisely) in the libpng documentation, use that; otherwise - * use the default value we just calculated. Either way, the user may - * override this via a command-line option. */ - - if ((p = getenv("SCREEN_GAMMA")) != NULL) - rpng2_info.display_exponent = atof(p); - else - rpng2_info.display_exponent = default_display_exponent; - - - /* Windows really hates command lines, so we have to set up our own argv. - * Note that we do NOT bother with quoted arguments here, so don't use - * filenames with spaces in 'em! */ - - argv[argc++] = PROGNAME; - p = cmd; - for (;;) { - if (*p == ' ') - while (*++p == ' ') - ; - /* now p points at the first non-space after some spaces */ - if (*p == '\0') - break; /* nothing after the spaces: done */ - argv[argc++] = q = p; - while (*q && *q != ' ') - ++q; - /* now q points at a space or the end of the string */ - if (*q == '\0') - break; /* last argv already terminated; quit */ - *q = '\0'; /* change space to terminator */ - p = q + 1; - } - argv[argc] = NULL; /* terminate the argv array itself */ - - - /* Now parse the command line for options and the PNG filename. */ - - while (*++argv && !error) { - if (!strncmp(*argv, "-gamma", 2)) { - if (!*++argv) - ++error; - else { - rpng2_info.display_exponent = atof(*argv); - if (rpng2_info.display_exponent <= 0.0) - ++error; - } - } else if (!strncmp(*argv, "-bgcolor", 4)) { - if (!*++argv) - ++error; - else { - bgstr = *argv; - if (strlen(bgstr) != 7 || bgstr[0] != '#') - ++error; - else { - have_bg = TRUE; - bg_image = FALSE; - } - } - } else if (!strncmp(*argv, "-bgpat", 4)) { - if (!*++argv) - ++error; - else { - pat = atoi(*argv) - 1; - if (pat < 0 || pat >= num_bgpat) - ++error; - else { - bg_image = TRUE; - have_bg = FALSE; - } - } - } else if (!strncmp(*argv, "-timing", 2)) { - timing = TRUE; -#if (defined(__i386__) || defined(_M_IX86)) - } else if (!strncmp(*argv, "-nommxfilters", 7)) { - rpng2_info.nommxfilters = TRUE; - } else if (!strncmp(*argv, "-nommxcombine", 7)) { - rpng2_info.nommxcombine = TRUE; - } else if (!strncmp(*argv, "-nommxinterlace", 7)) { - rpng2_info.nommxinterlace = TRUE; - } else if (!strcmp(*argv, "-nommx")) { - rpng2_info.nommxfilters = TRUE; - rpng2_info.nommxcombine = TRUE; - rpng2_info.nommxinterlace = TRUE; -#endif - } else { - if (**argv != '-') { - filename = *argv; - if (argv[1]) /* shouldn't be any more args after filename */ - ++error; - } else - ++error; /* not expecting any other options */ - } - } - - if (!filename) { - ++error; - } else if (!(infile = fopen(filename, "rb"))) { - fprintf(stderr, PROGNAME ": can't open PNG file [%s]\n", filename); - ++error; - } else { - incount = fread(inbuf, 1, INBUFSIZE, infile); - if (incount < 8 || !readpng2_check_sig(inbuf, 8)) { - fprintf(stderr, PROGNAME - ": [%s] is not a PNG file: incorrect signature\n", - filename); - ++error; - } else if ((rc = readpng2_init(&rpng2_info)) != 0) { - switch (rc) { - case 2: - fprintf(stderr, PROGNAME - ": [%s] has bad IHDR (libpng longjmp)\n", - filename); - break; - case 4: - fprintf(stderr, PROGNAME ": insufficient memory\n"); - break; - default: - fprintf(stderr, PROGNAME - ": unknown readpng2_init() error\n"); - break; - } - ++error; - } - if (error) - fclose(infile); - } - - - /* usage screen */ - - if (error) { - int ch; - - fprintf(stderr, "\n%s %s: %s\n\n", PROGNAME, VERSION, appname); - readpng2_version_info(); - fprintf(stderr, "\n" - "Usage: %s [-gamma exp] [-bgcolor bg | -bgpat pat] [-timing]\n" -#if (defined(__i386__) || defined(_M_IX86)) - " %*s [[-nommxfilters] [-nommxcombine] [-nommxinterlace] | -nommx]\n" -#endif - " %*s file.png\n\n" - " exp \ttransfer-function exponent (``gamma'') of the display\n" - "\t\t system in floating-point format (e.g., ``%.1f''); equal\n" - "\t\t to the product of the lookup-table exponent (varies)\n" - "\t\t and the CRT exponent (usually 2.2); must be positive\n" - " bg \tdesired background color in 7-character hex RGB format\n" - "\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n" - "\t\t used with transparent images; overrides -bgpat option\n" - " pat \tdesired background pattern number (1-%d); used with\n" - "\t\t transparent images; overrides -bgcolor option\n" - " -timing\tenables delay for every block read, to simulate modem\n" - "\t\t download of image (~36 Kbps)\n" -#if (defined(__i386__) || defined(_M_IX86)) - " -nommx*\tdisable optimized MMX routines for decoding row filters,\n" - "\t\t combining rows, and expanding interlacing, respectively\n" -#endif - "\nPress Q, Esc or mouse button 1 after image is displayed to quit.\n" - "Press Q or Esc to quit this usage screen. ", - PROGNAME, -#if (defined(__i386__) || defined(_M_IX86)) - strlen(PROGNAME), " ", -#endif - strlen(PROGNAME), " ", default_display_exponent, num_bgpat); - fflush(stderr); - do - ch = _getch(); - while (ch != 'q' && ch != 'Q' && ch != 0x1B); - exit(1); - } else { - fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname); - fprintf(stderr, - "\n [console window: closing this window will terminate %s]\n\n", - PROGNAME); - fflush(stderr); - } - - - /* set the title-bar string, but make sure buffer doesn't overflow */ - - alen = strlen(appname); - flen = strlen(filename); - if (alen + flen + 3 > 1023) - sprintf(titlebar, "%s: ...%s", appname, filename+(alen+flen+6-1023)); - else - sprintf(titlebar, "%s: %s", appname, filename); - - - /* set some final rpng2_info variables before entering main data loop */ - - if (have_bg) { - unsigned r, g, b; /* this approach quiets compiler warnings */ - - sscanf(bgstr+1, "%2x%2x%2x", &r, &g, &b); - rpng2_info.bg_red = (uch)r; - rpng2_info.bg_green = (uch)g; - rpng2_info.bg_blue = (uch)b; - } else - rpng2_info.need_bgcolor = TRUE; - - rpng2_info.done = FALSE; - rpng2_info.mainprog_init = rpng2_win_init; - rpng2_info.mainprog_display_row = rpng2_win_display_row; - rpng2_info.mainprog_finish_display = rpng2_win_finish_display; - - - /* OK, this is the fun part: call readpng2_decode_data() at the start of - * the loop to deal with our first buffer of data (read in above to verify - * that the file is a PNG image), then loop through the file and continue - * calling the same routine to handle each chunk of data. It in turn - * passes the data to libpng, which will invoke one or more of our call- - * backs as decoded data become available. We optionally call Sleep() for - * one second per iteration to simulate downloading the image via an analog - * modem. */ - - for (;;) { - Trace((stderr, "about to call readpng2_decode_data()\n")) - if (readpng2_decode_data(&rpng2_info, inbuf, incount)) - ++error; - Trace((stderr, "done with readpng2_decode_data()\n")) - if (error || feof(infile) || rpng2_info.done) - break; - if (timing) - Sleep(1000L); - incount = fread(inbuf, 1, INBUFSIZE, infile); - } - - - /* clean up PNG stuff and report any decoding errors */ - - fclose(infile); - Trace((stderr, "about to call readpng2_cleanup()\n")) - readpng2_cleanup(&rpng2_info); - - if (error) { - fprintf(stderr, PROGNAME ": libpng error while decoding PNG image\n"); - exit(3); - } - - - /* wait for the user to tell us when to quit */ - - while (GetMessage(&msg, NULL, 0, 0)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - - - /* we're done: clean up all image and Windows resources and go away */ - - Trace((stderr, "about to call rpng2_win_cleanup()\n")) - rpng2_win_cleanup(); - - return msg.wParam; -} - - - - - -/* this function is called by readpng2_info_callback() in readpng2.c, which - * in turn is called by libpng after all of the pre-IDAT chunks have been - * read and processed--i.e., we now have enough info to finish initializing */ - -static void rpng2_win_init() -{ - ulg i; - ulg rowbytes = rpng2_info.rowbytes; - - Trace((stderr, "beginning rpng2_win_init()\n")) - Trace((stderr, " rowbytes = %ld\n", rpng2_info.rowbytes)) - Trace((stderr, " width = %ld\n", rpng2_info.width)) - Trace((stderr, " height = %ld\n", rpng2_info.height)) - - rpng2_info.image_data = (uch *)malloc(rowbytes * rpng2_info.height); - if (!rpng2_info.image_data) { - readpng2_cleanup(&rpng2_info); - return; - } - - rpng2_info.row_pointers = (uch **)malloc(rpng2_info.height * sizeof(uch *)); - if (!rpng2_info.row_pointers) { - free(rpng2_info.image_data); - rpng2_info.image_data = NULL; - readpng2_cleanup(&rpng2_info); - return; - } - - for (i = 0; i < rpng2_info.height; ++i) - rpng2_info.row_pointers[i] = rpng2_info.image_data + i*rowbytes; - -/*--------------------------------------------------------------------------- - Do the basic Windows initialization stuff, make the window, and fill it - with the user-specified, file-specified or default background color. - ---------------------------------------------------------------------------*/ - - if (rpng2_win_create_window()) { - readpng2_cleanup(&rpng2_info); - return; - } -} - - - - - -static int rpng2_win_create_window() -{ - uch bg_red = rpng2_info.bg_red; - uch bg_green = rpng2_info.bg_green; - uch bg_blue = rpng2_info.bg_blue; - uch *dest; - int extra_width, extra_height; - ulg i, j; - WNDCLASSEX wndclass; - RECT rect; - - -/*--------------------------------------------------------------------------- - Allocate memory for the display-specific version of the image (round up - to multiple of 4 for Windows DIB). - ---------------------------------------------------------------------------*/ - - wimage_rowbytes = ((3*rpng2_info.width + 3L) >> 2) << 2; - - if (!(dib = (uch *)malloc(sizeof(BITMAPINFOHEADER) + - wimage_rowbytes*rpng2_info.height))) - { - return 4; /* fail */ - } - -/*--------------------------------------------------------------------------- - Initialize the DIB. Negative height means to use top-down BMP ordering - (must be uncompressed, but that's what we want). Bit count of 1, 4 or 8 - implies a colormap of RGBX quads, but 24-bit BMPs just use B,G,R values - directly => wimage_data begins immediately after BMP header. - ---------------------------------------------------------------------------*/ - - memset(dib, 0, sizeof(BITMAPINFOHEADER)); - bmih = (BITMAPINFOHEADER *)dib; - bmih->biSize = sizeof(BITMAPINFOHEADER); - bmih->biWidth = rpng2_info.width; - bmih->biHeight = -((long)rpng2_info.height); - bmih->biPlanes = 1; - bmih->biBitCount = 24; - bmih->biCompression = 0; - wimage_data = dib + sizeof(BITMAPINFOHEADER); - -/*--------------------------------------------------------------------------- - Fill window with the specified background color (default is black), but - defer loading faked "background image" until window is displayed (may be - slow to compute). Data are in BGR order. - ---------------------------------------------------------------------------*/ - - if (bg_image) { /* just fill with black for now */ - memset(wimage_data, 0, wimage_rowbytes*rpng2_info.height); - } else { - for (j = 0; j < rpng2_info.height; ++j) { - dest = wimage_data + j*wimage_rowbytes; - for (i = rpng2_info.width; i > 0; --i) { - *dest++ = bg_blue; - *dest++ = bg_green; - *dest++ = bg_red; - } - } - } - -/*--------------------------------------------------------------------------- - Set the window parameters. - ---------------------------------------------------------------------------*/ - - memset(&wndclass, 0, sizeof(wndclass)); - - wndclass.cbSize = sizeof(wndclass); - wndclass.style = CS_HREDRAW | CS_VREDRAW; - wndclass.lpfnWndProc = rpng2_win_wndproc; - wndclass.hInstance = global_hInst; - wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); - wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); - wndclass.hbrBackground = (HBRUSH)GetStockObject(DKGRAY_BRUSH); - wndclass.lpszMenuName = NULL; - wndclass.lpszClassName = progname; - wndclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION); - - RegisterClassEx(&wndclass); - -/*--------------------------------------------------------------------------- - Finally, create the window. - ---------------------------------------------------------------------------*/ - - extra_width = 2*(GetSystemMetrics(SM_CXBORDER) + - GetSystemMetrics(SM_CXDLGFRAME)); - extra_height = 2*(GetSystemMetrics(SM_CYBORDER) + - GetSystemMetrics(SM_CYDLGFRAME)) + - GetSystemMetrics(SM_CYCAPTION); - - global_hwnd = CreateWindow(progname, titlebar, WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, CW_USEDEFAULT, rpng2_info.width+extra_width, - rpng2_info.height+extra_height, NULL, NULL, global_hInst, NULL); - - ShowWindow(global_hwnd, global_showmode); - UpdateWindow(global_hwnd); - -/*--------------------------------------------------------------------------- - Now compute the background image and display it. If it fails (memory - allocation), revert to a plain background color. - ---------------------------------------------------------------------------*/ - - if (bg_image) { - static const char *msg = "Computing background image..."; - int x, y, len = strlen(msg); - HDC hdc = GetDC(global_hwnd); - TEXTMETRIC tm; - - GetTextMetrics(hdc, &tm); - x = (rpng2_info.width - len*tm.tmAveCharWidth)/2; - y = (rpng2_info.height - tm.tmHeight)/2; - SetBkMode(hdc, TRANSPARENT); - SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT)); - /* this can still begin out of bounds even if x is positive (???): */ - TextOut(hdc, ((x < 0)? 0 : x), ((y < 0)? 0 : y), msg, len); - ReleaseDC(global_hwnd, hdc); - - rpng2_win_load_bg_image(); /* resets bg_image if fails */ - } - - if (!bg_image) { - for (j = 0; j < rpng2_info.height; ++j) { - dest = wimage_data + j*wimage_rowbytes; - for (i = rpng2_info.width; i > 0; --i) { - *dest++ = bg_blue; - *dest++ = bg_green; - *dest++ = bg_red; - } - } - } - - rect.left = 0L; - rect.top = 0L; - rect.right = (LONG)rpng2_info.width; /* possibly off by one? */ - rect.bottom = (LONG)rpng2_info.height; /* possibly off by one? */ - InvalidateRect(global_hwnd, &rect, FALSE); - UpdateWindow(global_hwnd); /* similar to XFlush() */ - - return 0; - -} /* end function rpng2_win_create_window() */ - - - - - -static int rpng2_win_load_bg_image() -{ - uch *src, *dest; - uch r1, r2, g1, g2, b1, b2; - uch r1_inv, r2_inv, g1_inv, g2_inv, b1_inv, b2_inv; - int k, hmax, max; - int xidx, yidx, yidx_max = (bgscale-1); - int even_odd_vert, even_odd_horiz, even_odd; - int invert_gradient2 = (bg[pat].type & 0x08); - int invert_column; - ulg i, row; - -/*--------------------------------------------------------------------------- - Allocate buffer for fake background image to be used with transparent - images; if this fails, revert to plain background color. - ---------------------------------------------------------------------------*/ - - bg_rowbytes = 3 * rpng2_info.width; - bg_data = (uch *)malloc(bg_rowbytes * rpng2_info.height); - if (!bg_data) { - fprintf(stderr, PROGNAME - ": unable to allocate memory for background image\n"); - bg_image = 0; - return 1; - } - -/*--------------------------------------------------------------------------- - Vertical gradients (ramps) in NxN squares, alternating direction and - colors (N == bgscale). - ---------------------------------------------------------------------------*/ - - if ((bg[pat].type & 0x07) == 0) { - uch r1_min = rgb[bg[pat].rgb1_min].r; - uch g1_min = rgb[bg[pat].rgb1_min].g; - uch b1_min = rgb[bg[pat].rgb1_min].b; - uch r2_min = rgb[bg[pat].rgb2_min].r; - uch g2_min = rgb[bg[pat].rgb2_min].g; - uch b2_min = rgb[bg[pat].rgb2_min].b; - int r1_diff = rgb[bg[pat].rgb1_max].r - r1_min; - int g1_diff = rgb[bg[pat].rgb1_max].g - g1_min; - int b1_diff = rgb[bg[pat].rgb1_max].b - b1_min; - int r2_diff = rgb[bg[pat].rgb2_max].r - r2_min; - int g2_diff = rgb[bg[pat].rgb2_max].g - g2_min; - int b2_diff = rgb[bg[pat].rgb2_max].b - b2_min; - - for (row = 0; row < rpng2_info.height; ++row) { - yidx = row % bgscale; - even_odd_vert = (row / bgscale) & 1; - - r1 = r1_min + (r1_diff * yidx) / yidx_max; - g1 = g1_min + (g1_diff * yidx) / yidx_max; - b1 = b1_min + (b1_diff * yidx) / yidx_max; - r1_inv = r1_min + (r1_diff * (yidx_max-yidx)) / yidx_max; - g1_inv = g1_min + (g1_diff * (yidx_max-yidx)) / yidx_max; - b1_inv = b1_min + (b1_diff * (yidx_max-yidx)) / yidx_max; - - r2 = r2_min + (r2_diff * yidx) / yidx_max; - g2 = g2_min + (g2_diff * yidx) / yidx_max; - b2 = b2_min + (b2_diff * yidx) / yidx_max; - r2_inv = r2_min + (r2_diff * (yidx_max-yidx)) / yidx_max; - g2_inv = g2_min + (g2_diff * (yidx_max-yidx)) / yidx_max; - b2_inv = b2_min + (b2_diff * (yidx_max-yidx)) / yidx_max; - - dest = bg_data + row*bg_rowbytes; - for (i = 0; i < rpng2_info.width; ++i) { - even_odd_horiz = (i / bgscale) & 1; - even_odd = even_odd_vert ^ even_odd_horiz; - invert_column = - (even_odd_horiz && (bg[pat].type & 0x10)); - if (even_odd == 0) { /* gradient #1 */ - if (invert_column) { - *dest++ = r1_inv; - *dest++ = g1_inv; - *dest++ = b1_inv; - } else { - *dest++ = r1; - *dest++ = g1; - *dest++ = b1; - } - } else { /* gradient #2 */ - if ((invert_column && invert_gradient2) || - (!invert_column && !invert_gradient2)) - { - *dest++ = r2; /* not inverted or */ - *dest++ = g2; /* doubly inverted */ - *dest++ = b2; - } else { - *dest++ = r2_inv; - *dest++ = g2_inv; /* singly inverted */ - *dest++ = b2_inv; - } - } - } - } - -/*--------------------------------------------------------------------------- - Soft gradient-diamonds with scale = bgscale. Code contributed by Adam - M. Costello. - ---------------------------------------------------------------------------*/ - - } else if ((bg[pat].type & 0x07) == 1) { - - hmax = (bgscale-1)/2; /* half the max weight of a color */ - max = 2*hmax; /* the max weight of a color */ - - r1 = rgb[bg[pat].rgb1_max].r; - g1 = rgb[bg[pat].rgb1_max].g; - b1 = rgb[bg[pat].rgb1_max].b; - r2 = rgb[bg[pat].rgb2_max].r; - g2 = rgb[bg[pat].rgb2_max].g; - b2 = rgb[bg[pat].rgb2_max].b; - - for (row = 0; row < rpng2_info.height; ++row) { - yidx = row % bgscale; - if (yidx > hmax) - yidx = bgscale-1 - yidx; - dest = bg_data + row*bg_rowbytes; - for (i = 0; i < rpng2_info.width; ++i) { - xidx = i % bgscale; - if (xidx > hmax) - xidx = bgscale-1 - xidx; - k = xidx + yidx; - *dest++ = (k*r1 + (max-k)*r2) / max; - *dest++ = (k*g1 + (max-k)*g2) / max; - *dest++ = (k*b1 + (max-k)*b2) / max; - } - } - -/*--------------------------------------------------------------------------- - Radial "starburst" with azimuthal sinusoids; [eventually number of sinu- - soids will equal bgscale?]. This one is slow but very cool. Code con- - tributed by Pieter S. van der Meulen (originally in Smalltalk). - ---------------------------------------------------------------------------*/ - - } else if ((bg[pat].type & 0x07) == 2) { - uch ch; - int ii, x, y, hw, hh, grayspot; - double freq, rotate, saturate, gray, intensity; - double angle=0.0, aoffset=0.0, maxDist, dist; - double red=0.0, green=0.0, blue=0.0, hue, s, v, f, p, q, t; - - fprintf(stderr, "%s: computing radial background...", - PROGNAME); - fflush(stderr); - - hh = rpng2_info.height / 2; - hw = rpng2_info.width / 2; - - /* variables for radial waves: - * aoffset: number of degrees to rotate hue [CURRENTLY NOT USED] - * freq: number of color beams originating from the center - * grayspot: size of the graying center area (anti-alias) - * rotate: rotation of the beams as a function of radius - * saturate: saturation of beams' shape azimuthally - */ - angle = CLIP(angle, 0.0, 360.0); - grayspot = CLIP(bg[pat].bg_gray, 1, (hh + hw)); - freq = MAX((double)bg[pat].bg_freq, 0.0); - saturate = (double)bg[pat].bg_bsat * 0.1; - rotate = (double)bg[pat].bg_brot * 0.1; - gray = 0.0; - intensity = 0.0; - maxDist = (double)((hw*hw) + (hh*hh)); - - for (row = 0; row < rpng2_info.height; ++row) { - y = row - hh; - dest = bg_data + row*bg_rowbytes; - for (i = 0; i < rpng2_info.width; ++i) { - x = i - hw; - angle = (x == 0)? PI_2 : atan((double)y / (double)x); - gray = (double)MAX(ABS(y), ABS(x)) / grayspot; - gray = MIN(1.0, gray); - dist = (double)((x*x) + (y*y)) / maxDist; - intensity = cos((angle+(rotate*dist*PI)) * freq) * - gray * saturate; - intensity = (MAX(MIN(intensity,1.0),-1.0) + 1.0) * 0.5; - hue = (angle + PI) * INV_PI_360 + aoffset; - s = gray * ((double)(ABS(x)+ABS(y)) / (double)(hw + hh)); - s = MIN(MAX(s,0.0), 1.0); - v = MIN(MAX(intensity,0.0), 1.0); - - if (s == 0.0) { - ch = (uch)(v * 255.0); - *dest++ = ch; - *dest++ = ch; - *dest++ = ch; - } else { - if ((hue < 0.0) || (hue >= 360.0)) - hue -= (((int)(hue / 360.0)) * 360.0); - hue /= 60.0; - ii = (int)hue; - f = hue - (double)ii; - p = (1.0 - s) * v; - q = (1.0 - (s * f)) * v; - t = (1.0 - (s * (1.0 - f))) * v; - if (ii == 0) { red = v; green = t; blue = p; } - else if (ii == 1) { red = q; green = v; blue = p; } - else if (ii == 2) { red = p; green = v; blue = t; } - else if (ii == 3) { red = p; green = q; blue = v; } - else if (ii == 4) { red = t; green = p; blue = v; } - else if (ii == 5) { red = v; green = p; blue = q; } - *dest++ = (uch)(red * 255.0); - *dest++ = (uch)(green * 255.0); - *dest++ = (uch)(blue * 255.0); - } - } - } - fprintf(stderr, "done.\n"); - fflush(stderr); - } - -/*--------------------------------------------------------------------------- - Blast background image to display buffer before beginning PNG decode; - calling function will handle invalidation and UpdateWindow() call. - ---------------------------------------------------------------------------*/ - - for (row = 0; row < rpng2_info.height; ++row) { - src = bg_data + row*bg_rowbytes; - dest = wimage_data + row*wimage_rowbytes; - for (i = rpng2_info.width; i > 0; --i) { - r1 = *src++; - g1 = *src++; - b1 = *src++; - *dest++ = b1; - *dest++ = g1; /* note reverse order */ - *dest++ = r1; - } - } - - return 0; - -} /* end function rpng2_win_load_bg_image() */ - - - - - -static void rpng2_win_display_row(ulg row) -{ - uch bg_red = rpng2_info.bg_red; - uch bg_green = rpng2_info.bg_green; - uch bg_blue = rpng2_info.bg_blue; - uch *src, *src2=NULL, *dest; - uch r, g, b, a; - ulg i; - static int rows=0; - static ulg firstrow; - -/*--------------------------------------------------------------------------- - rows and firstrow simply track how many rows (and which ones) have not - yet been displayed; alternatively, we could call InvalidateRect() for - every row and not bother with the records-keeping. - ---------------------------------------------------------------------------*/ - - Trace((stderr, "beginning rpng2_win_display_row()\n")) - - if (rows == 0) - firstrow = row; /* first row not yet displayed */ - - ++rows; /* count of rows received but not yet displayed */ - -/*--------------------------------------------------------------------------- - Aside from the use of the rpng2_info struct and the lack of an outer - loop (over rows), this routine is identical to rpng_win_display_image() - in the non-progressive version of the program. - ---------------------------------------------------------------------------*/ - - src = rpng2_info.image_data + row*rpng2_info.rowbytes; - if (bg_image) - src2 = bg_data + row*bg_rowbytes; - dest = wimage_data + row*wimage_rowbytes; - - if (rpng2_info.channels == 3) { - for (i = rpng2_info.width; i > 0; --i) { - r = *src++; - g = *src++; - b = *src++; - *dest++ = b; - *dest++ = g; /* note reverse order */ - *dest++ = r; - } - } else /* if (rpng2_info.channels == 4) */ { - for (i = rpng2_info.width; i > 0; --i) { - r = *src++; - g = *src++; - b = *src++; - a = *src++; - if (bg_image) { - bg_red = *src2++; - bg_green = *src2++; - bg_blue = *src2++; - } - if (a == 255) { - *dest++ = b; - *dest++ = g; - *dest++ = r; - } else if (a == 0) { - *dest++ = bg_blue; - *dest++ = bg_green; - *dest++ = bg_red; - } else { - /* this macro (copied from png.h) composites the - * foreground and background values and puts the - * result into the first argument; there are no - * side effects with the first argument */ - alpha_composite(*dest++, b, a, bg_blue); - alpha_composite(*dest++, g, a, bg_green); - alpha_composite(*dest++, r, a, bg_red); - } - } - } - -/*--------------------------------------------------------------------------- - Display after every 16 rows or when on last row. (Region may include - previously displayed lines due to interlacing--i.e., not contiguous.) - ---------------------------------------------------------------------------*/ - - if ((rows & 0xf) == 0 || row == rpng2_info.height-1) { - RECT rect; - - rect.left = 0L; - rect.top = (LONG)firstrow; - rect.right = (LONG)rpng2_info.width; /* possibly off by one? */ - rect.bottom = (LONG)row + 1L; /* possibly off by one? */ - InvalidateRect(global_hwnd, &rect, FALSE); - UpdateWindow(global_hwnd); /* similar to XFlush() */ - rows = 0; - } - -} /* end function rpng2_win_display_row() */ - - - - - -static void rpng2_win_finish_display() -{ - Trace((stderr, "beginning rpng2_win_finish_display()\n")) - - /* last row has already been displayed by rpng2_win_display_row(), so - * we have nothing to do here except set a flag and let the user know - * that the image is done */ - - rpng2_info.done = TRUE; - printf( - "Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n"); - fflush(stdout); -} - - - - - -static void rpng2_win_cleanup() -{ - if (bg_image && bg_data) { - free(bg_data); - bg_data = NULL; - } - - if (rpng2_info.image_data) { - free(rpng2_info.image_data); - rpng2_info.image_data = NULL; - } - - if (rpng2_info.row_pointers) { - free(rpng2_info.row_pointers); - rpng2_info.row_pointers = NULL; - } - - if (dib) { - free(dib); - dib = NULL; - } -} - - - - - -LRESULT CALLBACK rpng2_win_wndproc(HWND hwnd, UINT iMsg, WPARAM wP, LPARAM lP) -{ - HDC hdc; - PAINTSTRUCT ps; - int rc; - - switch (iMsg) { - case WM_CREATE: - /* one-time processing here, if any */ - return 0; - - case WM_PAINT: - hdc = BeginPaint(hwnd, &ps); - rc = StretchDIBits(hdc, 0, 0, rpng2_info.width, rpng2_info.height, - 0, 0, rpng2_info.width, rpng2_info.height, - wimage_data, (BITMAPINFO *)bmih, - 0, SRCCOPY); - EndPaint(hwnd, &ps); - return 0; - - /* wait for the user to tell us when to quit */ - case WM_CHAR: - switch (wP) { /* only need one, so ignore repeat count */ - case 'q': - case 'Q': - case 0x1B: /* Esc key */ - PostQuitMessage(0); - } - return 0; - - case WM_LBUTTONDOWN: /* another way of quitting */ - case WM_DESTROY: - PostQuitMessage(0); - return 0; - } - - return DefWindowProc(hwnd, iMsg, wP, lP); -} diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/rpng2-x.c b/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/rpng2-x.c deleted file mode 100644 index 2e30bd1c0..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/rpng2-x.c +++ /dev/null @@ -1,1408 +0,0 @@ -/*--------------------------------------------------------------------------- - - rpng2 - progressive-model PNG display program rpng2-x.c - - This program decodes and displays PNG files progressively, as if it were - a web browser (though the front end is only set up to read from files). - It supports gamma correction, user-specified background colors, and user- - specified background patterns (for transparent images). This version is - for the X Window System (tested by the author under Unix and by Martin - Zinser under OpenVMS; may work under OS/2 with a little tweaking). - - Thanks to Adam Costello and Pieter S. van der Meulen for the "diamond" - and "radial waves" patterns, respectively. - - to do: - - 8-bit support - - finish resizable checkerboard-gradient (sizes 4-128?) - - use %.1023s to simplify truncation of title-bar string? - - --------------------------------------------------------------------------- - - Changelog: - - 1.01: initial public release - - 1.02: modified to allow abbreviated options; fixed char/uchar mismatch - - 1.10: added support for non-default visuals; fixed X pixel-conversion - - 1.11: added -usleep option for demos; fixed command-line parsing bug - - 1.12: added -pause option for demos and testing - - 1.20: added runtime MMX-enabling/disabling and new -mmx* options - - 1.21: fixed small X memory leak (thanks to Francois Petitjean) - - 1.22: fixed XFreeGC() crash bug - - --------------------------------------------------------------------------- - - Copyright (c) 1998-2001 Greg Roelofs. All rights reserved. - - This software is provided "as is," without warranty of any kind, - express or implied. In no event shall the author or contributors - be held liable for any damages arising in any way from the use of - this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute - it freely, subject to the following restrictions: - - 1. Redistributions of source code must retain the above copyright - notice, disclaimer, and this list of conditions. - 2. Redistributions in binary form must reproduce the above copyright - notice, disclaimer, and this list of conditions in the documenta- - tion and/or other materials provided with the distribution. - 3. All advertising materials mentioning features or use of this - software must display the following acknowledgment: - - This product includes software developed by Greg Roelofs - and contributors for the book, "PNG: The Definitive Guide," - published by O'Reilly and Associates. - - ---------------------------------------------------------------------------*/ - -#define PROGNAME "rpng2-x" -#define LONGNAME "Progressive PNG Viewer for X" -#define VERSION "1.22 of 16 August 2001" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <setjmp.h> /* for jmpbuf declaration in readpng2.h */ -#include <time.h> -#include <math.h> /* only for PvdM background code */ -#include <X11/Xlib.h> -#include <X11/Xutil.h> -#include <X11/Xos.h> -#include <X11/keysym.h> /* defines XK_* macros */ - -#ifdef VMS -# include <unistd.h> -#endif - -/* all for PvdM background code: */ -#ifndef PI -# define PI 3.141592653589793238 -#endif -#define PI_2 (PI*0.5) -#define INV_PI_360 (360.0 / PI) -#define MAX(a,b) (a>b?a:b) -#define MIN(a,b) (a<b?a:b) -#define CLIP(a,min,max) MAX(min,MIN((a),max)) -#define ABS(a) ((a)<0?-(a):(a)) -#define CLIP8P(c) MAX(0,(MIN((c),255))) /* 8-bit pos. integer (uch) */ -#define ROUNDF(f) ((int)(f + 0.5)) - -#define rgb1_max bg_freq -#define rgb1_min bg_gray -#define rgb2_max bg_bsat -#define rgb2_min bg_brot - -/* #define DEBUG */ /* this enables the Trace() macros */ - -#include "readpng2.h" /* typedefs, common macros, readpng2 prototypes */ - - -/* could just include png.h, but this macro is the only thing we need - * (name and typedefs changed to local versions); note that side effects - * only happen with alpha (which could easily be avoided with - * "ush acopy = (alpha);") */ - -#define alpha_composite(composite, fg, alpha, bg) { \ - ush temp = ((ush)(fg)*(ush)(alpha) + \ - (ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \ - (composite) = (uch)((temp + (temp >> 8)) >> 8); \ -} - - -#define INBUFSIZE 4096 /* with pseudo-timing on (1 sec delay/block), this - * block size corresponds roughly to a download - * speed 10% faster than theoretical 33.6K maximum - * (assuming 8 data bits, 1 stop bit and no other - * overhead) */ - -/* local prototypes */ -static void rpng2_x_init(void); -static int rpng2_x_create_window(void); -static int rpng2_x_load_bg_image(void); -static void rpng2_x_display_row(ulg row); -static void rpng2_x_finish_display(void); -static void rpng2_x_cleanup(void); -static int rpng2_x_msb(ulg u32val); - - -static char titlebar[1024], *window_name = titlebar; -static char *appname = LONGNAME; -static char *icon_name = PROGNAME; -static char *filename; -static FILE *infile; - -static mainprog_info rpng2_info; - -static uch inbuf[INBUFSIZE]; -static int incount; - -static int pat = 6; /* must be less than num_bgpat */ -static int bg_image = 0; -static int bgscale = 16; -static ulg bg_rowbytes; -static uch *bg_data; - -int pause_after_pass = FALSE; -int demo_timing = FALSE; -ulg usleep_duration = 0L; - -static struct rgb_color { - uch r, g, b; -} rgb[] = { - { 0, 0, 0}, /* 0: black */ - {255, 255, 255}, /* 1: white */ - {173, 132, 57}, /* 2: tan */ - { 64, 132, 0}, /* 3: medium green */ - {189, 117, 1}, /* 4: gold */ - {253, 249, 1}, /* 5: yellow */ - { 0, 0, 255}, /* 6: blue */ - { 0, 0, 120}, /* 7: medium blue */ - {255, 0, 255}, /* 8: magenta */ - { 64, 0, 64}, /* 9: dark magenta */ - {255, 0, 0}, /* 10: red */ - { 64, 0, 0}, /* 11: dark red */ - {255, 127, 0}, /* 12: orange */ - {192, 96, 0}, /* 13: darker orange */ - { 24, 60, 0}, /* 14: dark green-yellow */ - { 85, 125, 200} /* 15: ice blue */ -}; -/* not used for now, but should be for error-checking: -static int num_rgb = sizeof(rgb) / sizeof(struct rgb_color); - */ - -/* - This whole struct is a fairly cheesy way to keep the number of - command-line options to a minimum. The radial-waves background - type is a particularly poor fit to the integer elements of the - struct...but a few macros and a little fixed-point math will do - wonders for ya. - - type bits: - F E D C B A 9 8 7 6 5 4 3 2 1 0 - | | | | | - | | +-+-+-- 0 = sharp-edged checkerboard - | | 1 = soft diamonds - | | 2 = radial waves - | | 3-7 = undefined - | +-- gradient #2 inverted? - +-- alternating columns inverted? - */ -static struct background_pattern { - ush type; - int rgb1_max, rgb1_min; /* or bg_freq, bg_gray */ - int rgb2_max, rgb2_min; /* or bg_bsat, bg_brot (both scaled by 10)*/ -} bg[] = { - {0+8, 2,0, 1,15}, /* checkered: tan/black vs. white/ice blue */ - {0+24, 2,0, 1,0}, /* checkered: tan/black vs. white/black */ - {0+8, 4,5, 0,2}, /* checkered: gold/yellow vs. black/tan */ - {0+8, 4,5, 0,6}, /* checkered: gold/yellow vs. black/blue */ - {0, 7,0, 8,9}, /* checkered: deep blue/black vs. magenta */ - {0+8, 13,0, 5,14}, /* checkered: orange/black vs. yellow */ - {0+8, 12,0, 10,11}, /* checkered: orange/black vs. red */ - {1, 7,0, 8,0}, /* diamonds: deep blue/black vs. magenta */ - {1, 12,0, 11,0}, /* diamonds: orange vs. dark red */ - {1, 10,0, 7,0}, /* diamonds: red vs. medium blue */ - {1, 4,0, 5,0}, /* diamonds: gold vs. yellow */ - {1, 3,0, 0,0}, /* diamonds: medium green vs. black */ - {2, 16, 100, 20, 0}, /* radial: ~hard radial color-beams */ - {2, 18, 100, 10, 2}, /* radial: soft, curved radial color-beams */ - {2, 16, 256, 100, 250}, /* radial: very tight spiral */ - {2, 10000, 256, 11, 0} /* radial: dipole-moire' (almost fractal) */ -}; -static int num_bgpat = sizeof(bg) / sizeof(struct background_pattern); - - -/* X-specific variables */ -static char *displayname; -static XImage *ximage; -static Display *display; -static int depth; -static Visual *visual; -static XVisualInfo *visual_list; -static int RShift, GShift, BShift; -static ulg RMask, GMask, BMask; -static Window window; -static GC gc; -static Colormap colormap; - -static int have_nondefault_visual = FALSE; -static int have_colormap = FALSE; -static int have_window = FALSE; -static int have_gc = FALSE; - - - - -int main(int argc, char **argv) -{ -#ifdef sgi - char tmpline[80]; -#endif - char *p, *bgstr = NULL; - int rc, alen, flen; - int error = 0; - int timing = FALSE; - int have_bg = FALSE; - double LUT_exponent; /* just the lookup table */ - double CRT_exponent = 2.2; /* just the monitor */ - double default_display_exponent; /* whole display system */ - XEvent e; - KeySym k; - - - /* First initialize a few things, just to be sure--memset takes care of - * default background color (black), booleans (FALSE), pointers (NULL), - * etc. */ - - displayname = (char *)NULL; - filename = (char *)NULL; - memset(&rpng2_info, 0, sizeof(mainprog_info)); - - - /* Set the default value for our display-system exponent, i.e., the - * product of the CRT exponent and the exponent corresponding to - * the frame-buffer's lookup table (LUT), if any. This is not an - * exhaustive list of LUT values (e.g., OpenStep has a lot of weird - * ones), but it should cover 99% of the current possibilities. */ - -#if defined(NeXT) - /* third-party utilities can modify the default LUT exponent */ - LUT_exponent = 1.0 / 2.2; - /* - if (some_next_function_that_returns_gamma(&next_gamma)) - LUT_exponent = 1.0 / next_gamma; - */ -#elif defined(sgi) - LUT_exponent = 1.0 / 1.7; - /* there doesn't seem to be any documented function to - * get the "gamma" value, so we do it the hard way */ - infile = fopen("/etc/config/system.glGammaVal", "r"); - if (infile) { - double sgi_gamma; - - fgets(tmpline, 80, infile); - fclose(infile); - sgi_gamma = atof(tmpline); - if (sgi_gamma > 0.0) - LUT_exponent = 1.0 / sgi_gamma; - } -#elif defined(Macintosh) - LUT_exponent = 1.8 / 2.61; - /* - if (some_mac_function_that_returns_gamma(&mac_gamma)) - LUT_exponent = mac_gamma / 2.61; - */ -#else - LUT_exponent = 1.0; /* assume no LUT: most PCs */ -#endif - - /* the defaults above give 1.0, 1.3, 1.5 and 2.2, respectively: */ - default_display_exponent = LUT_exponent * CRT_exponent; - - - /* If the user has set the SCREEN_GAMMA environment variable as suggested - * (somewhat imprecisely) in the libpng documentation, use that; otherwise - * use the default value we just calculated. Either way, the user may - * override this via a command-line option. */ - - if ((p = getenv("SCREEN_GAMMA")) != NULL) - rpng2_info.display_exponent = atof(p); - else - rpng2_info.display_exponent = default_display_exponent; - - - /* Now parse the command line for options and the PNG filename. */ - - while (*++argv && !error) { - if (!strncmp(*argv, "-display", 2)) { - if (!*++argv) - ++error; - else - displayname = *argv; - } else if (!strncmp(*argv, "-gamma", 2)) { - if (!*++argv) - ++error; - else { - rpng2_info.display_exponent = atof(*argv); - if (rpng2_info.display_exponent <= 0.0) - ++error; - } - } else if (!strncmp(*argv, "-bgcolor", 4)) { - if (!*++argv) - ++error; - else { - bgstr = *argv; - if (strlen(bgstr) != 7 || bgstr[0] != '#') - ++error; - else { - have_bg = TRUE; - bg_image = FALSE; - } - } - } else if (!strncmp(*argv, "-bgpat", 4)) { - if (!*++argv) - ++error; - else { - pat = atoi(*argv) - 1; - if (pat < 0 || pat >= num_bgpat) - ++error; - else { - bg_image = TRUE; - have_bg = FALSE; - } - } - } else if (!strncmp(*argv, "-usleep", 2)) { - if (!*++argv) - ++error; - else { - usleep_duration = (ulg)atol(*argv); - demo_timing = TRUE; - } - } else if (!strncmp(*argv, "-pause", 2)) { - pause_after_pass = TRUE; - } else if (!strncmp(*argv, "-timing", 2)) { - timing = TRUE; -#if (defined(__i386__) || defined(_M_IX86)) - } else if (!strncmp(*argv, "-nommxfilters", 7)) { - rpng2_info.nommxfilters = TRUE; - } else if (!strncmp(*argv, "-nommxcombine", 7)) { - rpng2_info.nommxcombine = TRUE; - } else if (!strncmp(*argv, "-nommxinterlace", 7)) { - rpng2_info.nommxinterlace = TRUE; - } else if (!strcmp(*argv, "-nommx")) { - rpng2_info.nommxfilters = TRUE; - rpng2_info.nommxcombine = TRUE; - rpng2_info.nommxinterlace = TRUE; -#endif - } else { - if (**argv != '-') { - filename = *argv; - if (argv[1]) /* shouldn't be any more args after filename */ - ++error; - } else - ++error; /* not expecting any other options */ - } - } - - if (!filename) { - ++error; - } else if (!(infile = fopen(filename, "rb"))) { - fprintf(stderr, PROGNAME ": can't open PNG file [%s]\n", filename); - ++error; - } else { - incount = fread(inbuf, 1, INBUFSIZE, infile); - if (incount < 8 || !readpng2_check_sig(inbuf, 8)) { - fprintf(stderr, PROGNAME - ": [%s] is not a PNG file: incorrect signature\n", - filename); - ++error; - } else if ((rc = readpng2_init(&rpng2_info)) != 0) { - switch (rc) { - case 2: - fprintf(stderr, PROGNAME - ": [%s] has bad IHDR (libpng longjmp)\n", - filename); - break; - case 4: - fprintf(stderr, PROGNAME ": insufficient memory\n"); - break; - default: - fprintf(stderr, PROGNAME - ": unknown readpng2_init() error\n"); - break; - } - ++error; - } else { - display = XOpenDisplay(displayname); - if (!display) { - readpng2_cleanup(&rpng2_info); - fprintf(stderr, PROGNAME ": can't open X display [%s]\n", - displayname? displayname : "default"); - ++error; - } - } - if (error) - fclose(infile); - } - - - /* usage screen */ - - if (error) { - fprintf(stderr, "\n%s %s: %s\n\n", PROGNAME, VERSION, appname); - readpng2_version_info(); - fprintf(stderr, "\n" - "Usage: %s [-display xdpy] [-gamma exp] [-bgcolor bg | -bgpat pat]\n" -#if (defined(__i386__) || defined(_M_IX86)) - " %*s [[-nommxfilters] [-nommxcombine] [-nommxinterlace] | -nommx]\n" -#endif - " %*s [-usleep dur | -timing] [-pause] file.png\n\n" - " xdpy\tname of the target X display (e.g., ``hostname:0'')\n" - " exp \ttransfer-function exponent (``gamma'') of the display\n" - "\t\t system in floating-point format (e.g., ``%.1f''); equal\n" - "\t\t to the product of the lookup-table exponent (varies)\n" - "\t\t and the CRT exponent (usually 2.2); must be positive\n" - " bg \tdesired background color in 7-character hex RGB format\n" - "\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n" - "\t\t used with transparent images; overrides -bgpat\n" - " pat \tdesired background pattern number (1-%d); used with\n" - "\t\t transparent images; overrides -bgcolor\n" -#if (defined(__i386__) || defined(_M_IX86)) - " -nommx*\tdisable optimized MMX routines for decoding row filters,\n" - "\t\t combining rows, and expanding interlacing, respectively\n" -#endif - " dur \tduration in microseconds to wait after displaying each\n" - "\t\t row (for demo purposes)\n" - " -timing\tenables delay for every block read, to simulate modem\n" - "\t\t download of image (~36 Kbps)\n" - " -pause\tpauses after displaying each pass until key pressed\n" - "\nPress Q, Esc or mouse button 1 (within image window, after image\n" - "is displayed) to quit.\n" - "\n", PROGNAME, -#if (defined(__i386__) || defined(_M_IX86)) - strlen(PROGNAME), " ", -#endif - strlen(PROGNAME), " ", default_display_exponent, num_bgpat); - exit(1); - } - - - /* set the title-bar string, but make sure buffer doesn't overflow */ - - alen = strlen(appname); - flen = strlen(filename); - if (alen + flen + 3 > 1023) - sprintf(titlebar, "%s: ...%s", appname, filename+(alen+flen+6-1023)); - else - sprintf(titlebar, "%s: %s", appname, filename); - - - /* set some final rpng2_info variables before entering main data loop */ - - if (have_bg) { - unsigned r, g, b; /* this approach quiets compiler warnings */ - - sscanf(bgstr+1, "%2x%2x%2x", &r, &g, &b); - rpng2_info.bg_red = (uch)r; - rpng2_info.bg_green = (uch)g; - rpng2_info.bg_blue = (uch)b; - } else - rpng2_info.need_bgcolor = TRUE; - - rpng2_info.done = FALSE; - rpng2_info.mainprog_init = rpng2_x_init; - rpng2_info.mainprog_display_row = rpng2_x_display_row; - rpng2_info.mainprog_finish_display = rpng2_x_finish_display; - - - /* OK, this is the fun part: call readpng2_decode_data() at the start of - * the loop to deal with our first buffer of data (read in above to verify - * that the file is a PNG image), then loop through the file and continue - * calling the same routine to handle each chunk of data. It in turn - * passes the data to libpng, which will invoke one or more of our call- - * backs as decoded data become available. We optionally call sleep() for - * one second per iteration to simulate downloading the image via an analog - * modem. */ - - for (;;) { - Trace((stderr, "about to call readpng2_decode_data()\n")) - if (readpng2_decode_data(&rpng2_info, inbuf, incount)) - ++error; - Trace((stderr, "done with readpng2_decode_data()\n")) - if (error || feof(infile) || rpng2_info.done) - break; - if (timing) - sleep(1); - incount = fread(inbuf, 1, INBUFSIZE, infile); - } - - - /* clean up PNG stuff and report any decoding errors */ - - fclose(infile); - Trace((stderr, "about to call readpng2_cleanup()\n")) - readpng2_cleanup(&rpng2_info); - - if (error) { - fprintf(stderr, PROGNAME ": libpng error while decoding PNG image\n"); - exit(3); - } - - - /* wait for the user to tell us when to quit */ - - do - XNextEvent(display, &e); - while (!(e.type == ButtonPress && e.xbutton.button == Button1) && - !(e.type == KeyPress && /* v--- or 1 for shifted keys */ - ((k = XLookupKeysym(&e.xkey, 0)) == XK_q || k == XK_Escape) )); - - - /* we're done: clean up all image and X resources and go away */ - - Trace((stderr, "about to call rpng2_x_cleanup()\n")) - rpng2_x_cleanup(); - - return 0; -} - - - - - -/* this function is called by readpng2_info_callback() in readpng2.c, which - * in turn is called by libpng after all of the pre-IDAT chunks have been - * read and processed--i.e., we now have enough info to finish initializing */ - -static void rpng2_x_init(void) -{ - ulg i; - ulg rowbytes = rpng2_info.rowbytes; - - Trace((stderr, "beginning rpng2_x_init()\n")) - Trace((stderr, " rowbytes = %ld\n", rpng2_info.rowbytes)) - Trace((stderr, " width = %ld\n", rpng2_info.width)) - Trace((stderr, " height = %ld\n", rpng2_info.height)) - - rpng2_info.image_data = (uch *)malloc(rowbytes * rpng2_info.height); - if (!rpng2_info.image_data) { - readpng2_cleanup(&rpng2_info); - return; - } - - rpng2_info.row_pointers = (uch **)malloc(rpng2_info.height * sizeof(uch *)); - if (!rpng2_info.row_pointers) { - free(rpng2_info.image_data); - rpng2_info.image_data = NULL; - readpng2_cleanup(&rpng2_info); - return; - } - - for (i = 0; i < rpng2_info.height; ++i) - rpng2_info.row_pointers[i] = rpng2_info.image_data + i*rowbytes; - - - /* do the basic X initialization stuff, make the window, and fill it with - * the user-specified, file-specified or default background color or - * pattern */ - - if (rpng2_x_create_window()) { - - /* GRR TEMPORARY HACK: this is fundamentally no different from cases - * above; libpng should longjmp() back to us when png_ptr goes away. - * If we/it segfault instead, seems like a libpng bug... */ - - /* we're here via libpng callback, so if window fails, clean and bail */ -printf("readpng2_cleanup.\n"); - readpng2_cleanup(&rpng2_info); - rpng2_x_cleanup(); - exit(2); - } -} - - - - - -static int rpng2_x_create_window(void) -{ - ulg bg_red = rpng2_info.bg_red; - ulg bg_green = rpng2_info.bg_green; - ulg bg_blue = rpng2_info.bg_blue; - ulg bg_pixel = 0L; - ulg attrmask; - int need_colormap = FALSE; - int screen, pad; - uch *xdata; - Window root; - XEvent e; - XGCValues gcvalues; - XSetWindowAttributes attr; - XSizeHints *size_hints; - XTextProperty windowName, *pWindowName = &windowName; - XTextProperty iconName, *pIconName = &iconName; - XVisualInfo visual_info; - XWMHints *wm_hints; - - - Trace((stderr, "beginning rpng2_x_create_window()\n")) - - screen = DefaultScreen(display); - depth = DisplayPlanes(display, screen); - root = RootWindow(display, screen); - -#ifdef DEBUG - XSynchronize(display, True); -#endif - - if (depth != 16 && depth != 24 && depth != 32) { - int visuals_matched = 0; - - Trace((stderr, "default depth is %d: checking other visuals\n", - depth)) - - /* 24-bit first */ - visual_info.screen = screen; - visual_info.depth = 24; - visual_list = XGetVisualInfo(display, - VisualScreenMask | VisualDepthMask, &visual_info, &visuals_matched); - if (visuals_matched == 0) { -/* GRR: add 15-, 16- and 32-bit TrueColor visuals (also DirectColor?) */ - fprintf(stderr, "default screen depth %d not supported, and no" - " 24-bit visuals found\n", depth); - return 2; - } - Trace((stderr, "XGetVisualInfo() returned %d 24-bit visuals\n", - visuals_matched)) - visual = visual_list[0].visual; - depth = visual_list[0].depth; -/* - colormap_size = visual_list[0].colormap_size; - visual_class = visual->class; - visualID = XVisualIDFromVisual(visual); - */ - have_nondefault_visual = TRUE; - need_colormap = TRUE; - } else { - XMatchVisualInfo(display, screen, depth, TrueColor, &visual_info); - visual = visual_info.visual; - } - - RMask = visual->red_mask; - GMask = visual->green_mask; - BMask = visual->blue_mask; - -/* GRR: add/check 8-bit support */ - if (depth == 8 || need_colormap) { - colormap = XCreateColormap(display, root, visual, AllocNone); - if (!colormap) { - fprintf(stderr, "XCreateColormap() failed\n"); - return 2; - } - have_colormap = TRUE; - if (depth == 8) - bg_image = FALSE; /* gradient just wastes palette entries */ - } - if (depth == 15 || depth == 16) { - RShift = 15 - rpng2_x_msb(RMask); /* these are right-shifts */ - GShift = 15 - rpng2_x_msb(GMask); - BShift = 15 - rpng2_x_msb(BMask); - } else if (depth > 16) { - RShift = rpng2_x_msb(RMask) - 7; /* these are left-shifts */ - GShift = rpng2_x_msb(GMask) - 7; - BShift = rpng2_x_msb(BMask) - 7; - } - if (depth >= 15 && (RShift < 0 || GShift < 0 || BShift < 0)) { - fprintf(stderr, "rpng2 internal logic error: negative X shift(s)!\n"); - return 2; - } - -/*--------------------------------------------------------------------------- - Finally, create the window. - ---------------------------------------------------------------------------*/ - - attr.backing_store = Always; - attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask; - attrmask = CWBackingStore | CWEventMask; - if (have_nondefault_visual) { - attr.colormap = colormap; - attr.background_pixel = 0; - attr.border_pixel = 1; - attrmask |= CWColormap | CWBackPixel | CWBorderPixel; - } - - window = XCreateWindow(display, root, 0, 0, rpng2_info.width, - rpng2_info.height, 0, depth, InputOutput, visual, attrmask, &attr); - - if (window == None) { - fprintf(stderr, "XCreateWindow() failed\n"); - return 2; - } else - have_window = TRUE; - - if (depth == 8) - XSetWindowColormap(display, window, colormap); - - if (!XStringListToTextProperty(&window_name, 1, pWindowName)) - pWindowName = NULL; - if (!XStringListToTextProperty(&icon_name, 1, pIconName)) - pIconName = NULL; - - /* OK if either hints allocation fails; XSetWMProperties() allows NULLs */ - - if ((size_hints = XAllocSizeHints()) != NULL) { - /* window will not be resizable */ - size_hints->flags = PMinSize | PMaxSize; - size_hints->min_width = size_hints->max_width = (int)rpng2_info.width; - size_hints->min_height = size_hints->max_height = - (int)rpng2_info.height; - } - - if ((wm_hints = XAllocWMHints()) != NULL) { - wm_hints->initial_state = NormalState; - wm_hints->input = True; - /* wm_hints->icon_pixmap = icon_pixmap; */ - wm_hints->flags = StateHint | InputHint /* | IconPixmapHint */ ; - } - - XSetWMProperties(display, window, pWindowName, pIconName, NULL, 0, - size_hints, wm_hints, NULL); - - /* various properties and hints no longer needed; free memory */ - if (pWindowName) - XFree(pWindowName->value); - if (pIconName) - XFree(pIconName->value); - if (size_hints) - XFree(size_hints); - if (wm_hints) - XFree(wm_hints); - - XMapWindow(display, window); - - gc = XCreateGC(display, window, 0, &gcvalues); - have_gc = TRUE; - -/*--------------------------------------------------------------------------- - Allocate memory for the X- and display-specific version of the image. - ---------------------------------------------------------------------------*/ - - if (depth == 24 || depth == 32) { - xdata = (uch *)malloc(4*rpng2_info.width*rpng2_info.height); - pad = 32; - } else if (depth == 16) { - xdata = (uch *)malloc(2*rpng2_info.width*rpng2_info.height); - pad = 16; - } else /* depth == 8 */ { - xdata = (uch *)malloc(rpng2_info.width*rpng2_info.height); - pad = 8; - } - - if (!xdata) { - fprintf(stderr, PROGNAME ": unable to allocate image memory\n"); - return 4; - } - - ximage = XCreateImage(display, visual, depth, ZPixmap, 0, - (char *)xdata, rpng2_info.width, rpng2_info.height, pad, 0); - - if (!ximage) { - fprintf(stderr, PROGNAME ": XCreateImage() failed\n"); - free(xdata); - return 3; - } - - /* to avoid testing the byte order every pixel (or doubling the size of - * the drawing routine with a giant if-test), we arbitrarily set the byte - * order to MSBFirst and let Xlib worry about inverting things on little- - * endian machines (e.g., Linux/x86, old VAXen, etc.)--this is not the - * most efficient approach (the giant if-test would be better), but in - * the interest of clarity, we'll take the easy way out... */ - - ximage->byte_order = MSBFirst; - -/*--------------------------------------------------------------------------- - Fill window with the specified background color (default is black) or - faked "background image" (but latter is disabled if 8-bit; gradients - just waste palette entries). - ---------------------------------------------------------------------------*/ - - if (bg_image) - rpng2_x_load_bg_image(); /* resets bg_image if fails */ - - if (!bg_image) { - if (depth == 24 || depth == 32) { - bg_pixel = (bg_red << RShift) | - (bg_green << GShift) | - (bg_blue << BShift); - } else if (depth == 16) { - bg_pixel = (((bg_red << 8) >> RShift) & RMask) | - (((bg_green << 8) >> GShift) & GMask) | - (((bg_blue << 8) >> BShift) & BMask); - } else /* depth == 8 */ { - - /* GRR: add 8-bit support */ - - } - XSetForeground(display, gc, bg_pixel); - XFillRectangle(display, window, gc, 0, 0, rpng2_info.width, - rpng2_info.height); - } - -/*--------------------------------------------------------------------------- - Wait for first Expose event to do any drawing, then flush and return. - ---------------------------------------------------------------------------*/ - - do - XNextEvent(display, &e); - while (e.type != Expose || e.xexpose.count); - - XFlush(display); - - return 0; - -} /* end function rpng2_x_create_window() */ - - - - - -static int rpng2_x_load_bg_image(void) -{ - uch *src; - char *dest; - uch r1, r2, g1, g2, b1, b2; - uch r1_inv, r2_inv, g1_inv, g2_inv, b1_inv, b2_inv; - int k, hmax, max; - int xidx, yidx, yidx_max = (bgscale-1); - int even_odd_vert, even_odd_horiz, even_odd; - int invert_gradient2 = (bg[pat].type & 0x08); - int invert_column; - int ximage_rowbytes = ximage->bytes_per_line; - ulg i, row; - ulg pixel; - -/*--------------------------------------------------------------------------- - Allocate buffer for fake background image to be used with transparent - images; if this fails, revert to plain background color. - ---------------------------------------------------------------------------*/ - - bg_rowbytes = 3 * rpng2_info.width; - bg_data = (uch *)malloc(bg_rowbytes * rpng2_info.height); - if (!bg_data) { - fprintf(stderr, PROGNAME - ": unable to allocate memory for background image\n"); - bg_image = 0; - return 1; - } - -/*--------------------------------------------------------------------------- - Vertical gradients (ramps) in NxN squares, alternating direction and - colors (N == bgscale). - ---------------------------------------------------------------------------*/ - - if ((bg[pat].type & 0x07) == 0) { - uch r1_min = rgb[bg[pat].rgb1_min].r; - uch g1_min = rgb[bg[pat].rgb1_min].g; - uch b1_min = rgb[bg[pat].rgb1_min].b; - uch r2_min = rgb[bg[pat].rgb2_min].r; - uch g2_min = rgb[bg[pat].rgb2_min].g; - uch b2_min = rgb[bg[pat].rgb2_min].b; - int r1_diff = rgb[bg[pat].rgb1_max].r - r1_min; - int g1_diff = rgb[bg[pat].rgb1_max].g - g1_min; - int b1_diff = rgb[bg[pat].rgb1_max].b - b1_min; - int r2_diff = rgb[bg[pat].rgb2_max].r - r2_min; - int g2_diff = rgb[bg[pat].rgb2_max].g - g2_min; - int b2_diff = rgb[bg[pat].rgb2_max].b - b2_min; - - for (row = 0; row < rpng2_info.height; ++row) { - yidx = (int)(row % bgscale); - even_odd_vert = (int)((row / bgscale) & 1); - - r1 = r1_min + (r1_diff * yidx) / yidx_max; - g1 = g1_min + (g1_diff * yidx) / yidx_max; - b1 = b1_min + (b1_diff * yidx) / yidx_max; - r1_inv = r1_min + (r1_diff * (yidx_max-yidx)) / yidx_max; - g1_inv = g1_min + (g1_diff * (yidx_max-yidx)) / yidx_max; - b1_inv = b1_min + (b1_diff * (yidx_max-yidx)) / yidx_max; - - r2 = r2_min + (r2_diff * yidx) / yidx_max; - g2 = g2_min + (g2_diff * yidx) / yidx_max; - b2 = b2_min + (b2_diff * yidx) / yidx_max; - r2_inv = r2_min + (r2_diff * (yidx_max-yidx)) / yidx_max; - g2_inv = g2_min + (g2_diff * (yidx_max-yidx)) / yidx_max; - b2_inv = b2_min + (b2_diff * (yidx_max-yidx)) / yidx_max; - - dest = (char *)bg_data + row*bg_rowbytes; - for (i = 0; i < rpng2_info.width; ++i) { - even_odd_horiz = (int)((i / bgscale) & 1); - even_odd = even_odd_vert ^ even_odd_horiz; - invert_column = - (even_odd_horiz && (bg[pat].type & 0x10)); - if (even_odd == 0) { /* gradient #1 */ - if (invert_column) { - *dest++ = r1_inv; - *dest++ = g1_inv; - *dest++ = b1_inv; - } else { - *dest++ = r1; - *dest++ = g1; - *dest++ = b1; - } - } else { /* gradient #2 */ - if ((invert_column && invert_gradient2) || - (!invert_column && !invert_gradient2)) - { - *dest++ = r2; /* not inverted or */ - *dest++ = g2; /* doubly inverted */ - *dest++ = b2; - } else { - *dest++ = r2_inv; - *dest++ = g2_inv; /* singly inverted */ - *dest++ = b2_inv; - } - } - } - } - -/*--------------------------------------------------------------------------- - Soft gradient-diamonds with scale = bgscale. Code contributed by Adam - M. Costello. - ---------------------------------------------------------------------------*/ - - } else if ((bg[pat].type & 0x07) == 1) { - - hmax = (bgscale-1)/2; /* half the max weight of a color */ - max = 2*hmax; /* the max weight of a color */ - - r1 = rgb[bg[pat].rgb1_max].r; - g1 = rgb[bg[pat].rgb1_max].g; - b1 = rgb[bg[pat].rgb1_max].b; - r2 = rgb[bg[pat].rgb2_max].r; - g2 = rgb[bg[pat].rgb2_max].g; - b2 = rgb[bg[pat].rgb2_max].b; - - for (row = 0; row < rpng2_info.height; ++row) { - yidx = (int)(row % bgscale); - if (yidx > hmax) - yidx = bgscale-1 - yidx; - dest = (char *)bg_data + row*bg_rowbytes; - for (i = 0; i < rpng2_info.width; ++i) { - xidx = (int)(i % bgscale); - if (xidx > hmax) - xidx = bgscale-1 - xidx; - k = xidx + yidx; - *dest++ = (k*r1 + (max-k)*r2) / max; - *dest++ = (k*g1 + (max-k)*g2) / max; - *dest++ = (k*b1 + (max-k)*b2) / max; - } - } - -/*--------------------------------------------------------------------------- - Radial "starburst" with azimuthal sinusoids; [eventually number of sinu- - soids will equal bgscale?]. This one is slow but very cool. Code con- - tributed by Pieter S. van der Meulen (originally in Smalltalk). - ---------------------------------------------------------------------------*/ - - } else if ((bg[pat].type & 0x07) == 2) { - uch ch; - int ii, x, y, hw, hh, grayspot; - double freq, rotate, saturate, gray, intensity; - double angle=0.0, aoffset=0.0, maxDist, dist; - double red=0.0, green=0.0, blue=0.0, hue, s, v, f, p, q, t; - - fprintf(stderr, "%s: computing radial background...", - PROGNAME); - fflush(stderr); - - hh = (int)(rpng2_info.height / 2); - hw = (int)(rpng2_info.width / 2); - - /* variables for radial waves: - * aoffset: number of degrees to rotate hue [CURRENTLY NOT USED] - * freq: number of color beams originating from the center - * grayspot: size of the graying center area (anti-alias) - * rotate: rotation of the beams as a function of radius - * saturate: saturation of beams' shape azimuthally - */ - angle = CLIP(angle, 0.0, 360.0); - grayspot = CLIP(bg[pat].bg_gray, 1, (hh + hw)); - freq = MAX((double)bg[pat].bg_freq, 0.0); - saturate = (double)bg[pat].bg_bsat * 0.1; - rotate = (double)bg[pat].bg_brot * 0.1; - gray = 0.0; - intensity = 0.0; - maxDist = (double)((hw*hw) + (hh*hh)); - - for (row = 0; row < rpng2_info.height; ++row) { - y = (int)(row - hh); - dest = (char *)bg_data + row*bg_rowbytes; - for (i = 0; i < rpng2_info.width; ++i) { - x = (int)(i - hw); - angle = (x == 0)? PI_2 : atan((double)y / (double)x); - gray = (double)MAX(ABS(y), ABS(x)) / grayspot; - gray = MIN(1.0, gray); - dist = (double)((x*x) + (y*y)) / maxDist; - intensity = cos((angle+(rotate*dist*PI)) * freq) * - gray * saturate; - intensity = (MAX(MIN(intensity,1.0),-1.0) + 1.0) * 0.5; - hue = (angle + PI) * INV_PI_360 + aoffset; - s = gray * ((double)(ABS(x)+ABS(y)) / (double)(hw + hh)); - s = MIN(MAX(s,0.0), 1.0); - v = MIN(MAX(intensity,0.0), 1.0); - - if (s == 0.0) { - ch = (uch)(v * 255.0); - *dest++ = ch; - *dest++ = ch; - *dest++ = ch; - } else { - if ((hue < 0.0) || (hue >= 360.0)) - hue -= (((int)(hue / 360.0)) * 360.0); - hue /= 60.0; - ii = (int)hue; - f = hue - (double)ii; - p = (1.0 - s) * v; - q = (1.0 - (s * f)) * v; - t = (1.0 - (s * (1.0 - f))) * v; - if (ii == 0) { red = v; green = t; blue = p; } - else if (ii == 1) { red = q; green = v; blue = p; } - else if (ii == 2) { red = p; green = v; blue = t; } - else if (ii == 3) { red = p; green = q; blue = v; } - else if (ii == 4) { red = t; green = p; blue = v; } - else if (ii == 5) { red = v; green = p; blue = q; } - *dest++ = (uch)(red * 255.0); - *dest++ = (uch)(green * 255.0); - *dest++ = (uch)(blue * 255.0); - } - } - } - fprintf(stderr, "done.\n"); - fflush(stderr); - } - -/*--------------------------------------------------------------------------- - Blast background image to display buffer before beginning PNG decode. - ---------------------------------------------------------------------------*/ - - if (depth == 24 || depth == 32) { - ulg red, green, blue; - - for (row = 0; row < rpng2_info.height; ++row) { - src = bg_data + row*bg_rowbytes; - dest = ximage->data + row*ximage_rowbytes; - for (i = rpng2_info.width; i > 0; --i) { - red = *src++; - green = *src++; - blue = *src++; - pixel = (red << RShift) | - (green << GShift) | - (blue << BShift); - /* recall that we set ximage->byte_order = MSBFirst above */ - /* GRR BUG: this assumes bpp == 32, but may be 24: */ - *dest++ = (char)((pixel >> 24) & 0xff); - *dest++ = (char)((pixel >> 16) & 0xff); - *dest++ = (char)((pixel >> 8) & 0xff); - *dest++ = (char)( pixel & 0xff); - } - } - - } else if (depth == 16) { - ush red, green, blue; - - for (row = 0; row < rpng2_info.height; ++row) { - src = bg_data + row*bg_rowbytes; - dest = ximage->data + row*ximage_rowbytes; - for (i = rpng2_info.width; i > 0; --i) { - red = ((ush)(*src) << 8); ++src; - green = ((ush)(*src) << 8); ++src; - blue = ((ush)(*src) << 8); ++src; - pixel = ((red >> RShift) & RMask) | - ((green >> GShift) & GMask) | - ((blue >> BShift) & BMask); - /* recall that we set ximage->byte_order = MSBFirst above */ - *dest++ = (char)((pixel >> 8) & 0xff); - *dest++ = (char)( pixel & 0xff); - } - } - - } else /* depth == 8 */ { - - /* GRR: add 8-bit support */ - - } - - XPutImage(display, window, gc, ximage, 0, 0, 0, 0, rpng2_info.width, - rpng2_info.height); - - return 0; - -} /* end function rpng2_x_load_bg_image() */ - - - - - -static void rpng2_x_display_row(ulg row) -{ - uch bg_red = rpng2_info.bg_red; - uch bg_green = rpng2_info.bg_green; - uch bg_blue = rpng2_info.bg_blue; - uch *src, *src2=NULL; - char *dest; - uch r, g, b, a; - int ximage_rowbytes = ximage->bytes_per_line; - ulg i, pixel; - static int rows=0, prevpass=(-1); - static ulg firstrow; - -/*--------------------------------------------------------------------------- - rows and firstrow simply track how many rows (and which ones) have not - yet been displayed; alternatively, we could call XPutImage() for every - row and not bother with the records-keeping. - ---------------------------------------------------------------------------*/ - - Trace((stderr, "beginning rpng2_x_display_row()\n")) - - if (rpng2_info.pass != prevpass) { - if (pause_after_pass && rpng2_info.pass > 0) { - XEvent e; - KeySym k; - - fprintf(stderr, - "%s: end of pass %d of 7; click in image window to continue\n", - PROGNAME, prevpass + 1); - do - XNextEvent(display, &e); - while (!(e.type == ButtonPress && e.xbutton.button == Button1) - && !(e.type == KeyPress && - ((k = XLookupKeysym(&e.xkey, 0)) == XK_q - || k == XK_Escape) )) ; - } - fprintf(stderr, "%s: pass %d of 7\r", PROGNAME, rpng2_info.pass + 1); - fflush(stderr); - prevpass = rpng2_info.pass; - } - - if (rows == 0) - firstrow = row; /* first row that is not yet displayed */ - - ++rows; /* count of rows received but not yet displayed */ - -/*--------------------------------------------------------------------------- - Aside from the use of the rpng2_info struct, the lack of an outer loop - (over rows) and moving the XPutImage() call outside the "if (depth)" - tests, this routine is identical to rpng_x_display_image() in the non- - progressive version of the program. - ---------------------------------------------------------------------------*/ - - if (depth == 24 || depth == 32) { - ulg red, green, blue; - - src = rpng2_info.image_data + row*rpng2_info.rowbytes; - if (bg_image) - src2 = bg_data + row*bg_rowbytes; - dest = ximage->data + row*ximage_rowbytes; - if (rpng2_info.channels == 3) { - for (i = rpng2_info.width; i > 0; --i) { - red = *src++; - green = *src++; - blue = *src++; - pixel = (red << RShift) | - (green << GShift) | - (blue << BShift); - /* recall that we set ximage->byte_order = MSBFirst above */ - /* GRR BUG: this assumes bpp == 32, but may be 24: */ - *dest++ = (char)((pixel >> 24) & 0xff); - *dest++ = (char)((pixel >> 16) & 0xff); - *dest++ = (char)((pixel >> 8) & 0xff); - *dest++ = (char)( pixel & 0xff); - } - } else /* if (rpng2_info.channels == 4) */ { - for (i = rpng2_info.width; i > 0; --i) { - r = *src++; - g = *src++; - b = *src++; - a = *src++; - if (bg_image) { - bg_red = *src2++; - bg_green = *src2++; - bg_blue = *src2++; - } - if (a == 255) { - red = r; - green = g; - blue = b; - } else if (a == 0) { - red = bg_red; - green = bg_green; - blue = bg_blue; - } else { - /* this macro (from png.h) composites the foreground - * and background values and puts the result into the - * first argument */ - alpha_composite(red, r, a, bg_red); - alpha_composite(green, g, a, bg_green); - alpha_composite(blue, b, a, bg_blue); - } - pixel = (red << RShift) | - (green << GShift) | - (blue << BShift); - /* recall that we set ximage->byte_order = MSBFirst above */ - /* GRR BUG: this assumes bpp == 32, but may be 24: */ - *dest++ = (char)((pixel >> 24) & 0xff); - *dest++ = (char)((pixel >> 16) & 0xff); - *dest++ = (char)((pixel >> 8) & 0xff); - *dest++ = (char)( pixel & 0xff); - } - } - - } else if (depth == 16) { - ush red, green, blue; - - src = rpng2_info.row_pointers[row]; - if (bg_image) - src2 = bg_data + row*bg_rowbytes; - dest = ximage->data + row*ximage_rowbytes; - if (rpng2_info.channels == 3) { - for (i = rpng2_info.width; i > 0; --i) { - red = ((ush)(*src) << 8); - ++src; - green = ((ush)(*src) << 8); - ++src; - blue = ((ush)(*src) << 8); - ++src; - pixel = ((red >> RShift) & RMask) | - ((green >> GShift) & GMask) | - ((blue >> BShift) & BMask); - /* recall that we set ximage->byte_order = MSBFirst above */ - *dest++ = (char)((pixel >> 8) & 0xff); - *dest++ = (char)( pixel & 0xff); - } - } else /* if (rpng2_info.channels == 4) */ { - for (i = rpng2_info.width; i > 0; --i) { - r = *src++; - g = *src++; - b = *src++; - a = *src++; - if (bg_image) { - bg_red = *src2++; - bg_green = *src2++; - bg_blue = *src2++; - } - if (a == 255) { - red = ((ush)r << 8); - green = ((ush)g << 8); - blue = ((ush)b << 8); - } else if (a == 0) { - red = ((ush)bg_red << 8); - green = ((ush)bg_green << 8); - blue = ((ush)bg_blue << 8); - } else { - /* this macro (from png.h) composites the foreground - * and background values and puts the result back into - * the first argument (== fg byte here: safe) */ - alpha_composite(r, r, a, bg_red); - alpha_composite(g, g, a, bg_green); - alpha_composite(b, b, a, bg_blue); - red = ((ush)r << 8); - green = ((ush)g << 8); - blue = ((ush)b << 8); - } - pixel = ((red >> RShift) & RMask) | - ((green >> GShift) & GMask) | - ((blue >> BShift) & BMask); - /* recall that we set ximage->byte_order = MSBFirst above */ - *dest++ = (char)((pixel >> 8) & 0xff); - *dest++ = (char)( pixel & 0xff); - } - } - - } else /* depth == 8 */ { - - /* GRR: add 8-bit support */ - - } - - -/*--------------------------------------------------------------------------- - Display after every 16 rows or when on one of last two rows. (Region - may include previously displayed lines due to interlacing--i.e., not - contiguous. Also, second-to-last row is final one in interlaced images - with odd number of rows.) For demos, flush (and delay) after every 16th - row so "sparse" passes don't go twice as fast. - ---------------------------------------------------------------------------*/ - - if (demo_timing && (row - firstrow >= 16 || row >= rpng2_info.height-2)) { - XPutImage(display, window, gc, ximage, 0, (int)firstrow, 0, - (int)firstrow, rpng2_info.width, row - firstrow + 1); - XFlush(display); - rows = 0; - usleep(usleep_duration); - } else - if (!demo_timing && ((rows & 0xf) == 0 || row >= rpng2_info.height-2)) { - XPutImage(display, window, gc, ximage, 0, (int)firstrow, 0, - (int)firstrow, rpng2_info.width, row - firstrow + 1); - XFlush(display); - rows = 0; - } - -} - - - - - -static void rpng2_x_finish_display(void) -{ - Trace((stderr, "beginning rpng2_x_finish_display()\n")) - - /* last row has already been displayed by rpng2_x_display_row(), so we - * have nothing to do here except set a flag and let the user know that - * the image is done */ - - rpng2_info.done = TRUE; - printf( - "Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n"); - fflush(stdout); -} - - - - - -static void rpng2_x_cleanup(void) -{ - if (bg_image && bg_data) { - free(bg_data); - bg_data = NULL; - } - - if (rpng2_info.image_data) { - free(rpng2_info.image_data); - rpng2_info.image_data = NULL; - } - - if (rpng2_info.row_pointers) { - free(rpng2_info.row_pointers); - rpng2_info.row_pointers = NULL; - } - - if (ximage) { - if (ximage->data) { - free(ximage->data); /* we allocated it, so we free it */ - ximage->data = (char *)NULL; /* instead of XDestroyImage() */ - } - XDestroyImage(ximage); - ximage = NULL; - } - - if (have_gc) - XFreeGC(display, gc); - - if (have_window) - XDestroyWindow(display, window); - - if (have_colormap) - XFreeColormap(display, colormap); - - if (have_nondefault_visual) - XFree(visual_list); -} - - - - - -static int rpng2_x_msb(ulg u32val) -{ - int i; - - for (i = 31; i >= 0; --i) { - if (u32val & 0x80000000L) - break; - u32val <<= 1; - } - return i; -} diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/toucan.png b/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/toucan.png deleted file mode 100644 index 03960d493..000000000 Binary files a/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/toucan.png and /dev/null differ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/wpng.c b/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/wpng.c deleted file mode 100644 index 7aaee1174..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/wpng.c +++ /dev/null @@ -1,816 +0,0 @@ -/*--------------------------------------------------------------------------- - - wpng - simple PNG-writing program wpng.c - - This program converts certain NetPBM binary files (grayscale and RGB, - maxval = 255) to PNG. Non-interlaced PNGs are written progressively; - interlaced PNGs are read and written in one memory-intensive blast. - Thanks to Jean-loup Gailly for providing the necessary trick to read - interactive text from the keyboard while stdin is redirected. - - NOTE: includes provisional support for PNM type "8" (portable alphamap) - images, presumed to be a 32-bit interleaved RGBA format; no pro- - vision for possible interleaved grayscale+alpha (16-bit) format. - THIS IS UNLIKELY TO BECOME AN OFFICIAL NETPBM ALPHA FORMAT! - - to do: - - delete output file if quit before calling any writepng routines - - process backspace with -text option under DOS/Win? (currently get ^H) - - --------------------------------------------------------------------------- - - Changelog: - - 1.01: initial public release - - 1.02: modified to allow abbreviated options - - 1.03: removed extraneous character from usage screen; fixed bug in - command-line parsing - - --------------------------------------------------------------------------- - - Copyright (c) 1998-2000 Greg Roelofs. All rights reserved. - - This software is provided "as is," without warranty of any kind, - express or implied. In no event shall the author or contributors - be held liable for any damages arising in any way from the use of - this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute - it freely, subject to the following restrictions: - - 1. Redistributions of source code must retain the above copyright - notice, disclaimer, and this list of conditions. - 2. Redistributions in binary form must reproduce the above copyright - notice, disclaimer, and this list of conditions in the documenta- - tion and/or other materials provided with the distribution. - 3. All advertising materials mentioning features or use of this - software must display the following acknowledgment: - - This product includes software developed by Greg Roelofs - and contributors for the book, "PNG: The Definitive Guide," - published by O'Reilly and Associates. - - ---------------------------------------------------------------------------*/ - -#define PROGNAME "wpng" -#define VERSION "1.03 of 19 March 2000" -#define APPNAME "Simple PGM/PPM/PAM to PNG Converter" - -#if defined(__MSDOS__) || defined(__OS2__) -# define DOS_OS2_W32 -#elif defined(_WIN32) || defined(__WIN32__) -# define DOS_OS2_W32 -#endif - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <setjmp.h> /* for jmpbuf declaration in writepng.h */ -#include <time.h> - -#ifdef DOS_OS2_W32 -# include <io.h> /* for isatty(), setmode() prototypes */ -# include <fcntl.h> /* O_BINARY for fdopen() without text translation */ -# ifdef __EMX__ -# ifndef getch -# define getch() _read_kbd(0, 1, 0) /* need getche() */ -# endif -# else /* !__EMX__ */ -# ifdef __GO32__ -# include <pc.h> -# define getch() getkey() /* GRR: need getche() */ -# else -# include <conio.h> /* for getche() console input */ -# endif -# endif /* ?__EMX__ */ -# define FGETS(buf,len,stream) dos_kbd_gets(buf,len) -#else -# include <unistd.h> /* for isatty() prototype */ -# define FGETS fgets -#endif - -/* #define DEBUG : this enables the Trace() macros */ - -/* #define FORBID_LATIN1_CTRL : this requires the user to re-enter any - text that includes control characters discouraged by the PNG spec; text - that includes an escape character (27) must be re-entered regardless */ - -#include "writepng.h" /* typedefs, common macros, writepng prototypes */ - - - -/* local prototypes */ - -static int wpng_isvalid_latin1(uch *p, int len); -static void wpng_cleanup(void); - -#ifdef DOS_OS2_W32 - static char *dos_kbd_gets(char *buf, int len); -#endif - - - -static mainprog_info wpng_info; /* lone global */ - - - -int main(int argc, char **argv) -{ -#ifndef DOS_OS2_W32 - FILE *keybd; -#endif -#ifdef sgi - FILE *tmpfile; /* or we could just use keybd, since no overlap */ - char tmpline[80]; -#endif - char *inname = NULL, outname[256]; - char *p, pnmchar, pnmline[256]; - char *bgstr, *textbuf = NULL; - ulg rowbytes; - int rc, len = 0; - int error = 0; - int text = FALSE; - int maxval; - double LUT_exponent; /* just the lookup table */ - double CRT_exponent = 2.2; /* just the monitor */ - double default_display_exponent; /* whole display system */ - double default_gamma = 0.0; - - - wpng_info.infile = NULL; - wpng_info.outfile = NULL; - wpng_info.image_data = NULL; - wpng_info.row_pointers = NULL; - wpng_info.filter = FALSE; - wpng_info.interlaced = FALSE; - wpng_info.have_bg = FALSE; - wpng_info.have_time = FALSE; - wpng_info.have_text = 0; - wpng_info.gamma = 0.0; - - - /* First get the default value for our display-system exponent, i.e., - * the product of the CRT exponent and the exponent corresponding to - * the frame-buffer's lookup table (LUT), if any. If the PNM image - * looks correct on the user's display system, its file gamma is the - * inverse of this value. (Note that this is not an exhaustive list - * of LUT values--e.g., OpenStep has a lot of weird ones--but it should - * cover 99% of the current possibilities. This section must ensure - * that default_display_exponent is positive.) */ - -#if defined(NeXT) - /* third-party utilities can modify the default LUT exponent */ - LUT_exponent = 1.0 / 2.2; - /* - if (some_next_function_that_returns_gamma(&next_gamma)) - LUT_exponent = 1.0 / next_gamma; - */ -#elif defined(sgi) - LUT_exponent = 1.0 / 1.7; - /* there doesn't seem to be any documented function to - * get the "gamma" value, so we do it the hard way */ - tmpfile = fopen("/etc/config/system.glGammaVal", "r"); - if (tmpfile) { - double sgi_gamma; - - fgets(tmpline, 80, tmpfile); - fclose(tmpfile); - sgi_gamma = atof(tmpline); - if (sgi_gamma > 0.0) - LUT_exponent = 1.0 / sgi_gamma; - } -#elif defined(Macintosh) - LUT_exponent = 1.8 / 2.61; - /* - if (some_mac_function_that_returns_gamma(&mac_gamma)) - LUT_exponent = mac_gamma / 2.61; - */ -#else - LUT_exponent = 1.0; /* assume no LUT: most PCs */ -#endif - - /* the defaults above give 1.0, 1.3, 1.5 and 2.2, respectively: */ - default_display_exponent = LUT_exponent * CRT_exponent; - - - /* If the user has set the SCREEN_GAMMA environment variable as suggested - * (somewhat imprecisely) in the libpng documentation, use that; otherwise - * use the default value we just calculated. Either way, the user may - * override this via a command-line option. */ - - if ((p = getenv("SCREEN_GAMMA")) != NULL) { - double exponent = atof(p); - - if (exponent > 0.0) - default_gamma = 1.0 / exponent; - } - - if (default_gamma == 0.0) - default_gamma = 1.0 / default_display_exponent; - - - /* Now parse the command line for options and the PNM filename. */ - - while (*++argv && !error) { - if (!strncmp(*argv, "-i", 2)) { - wpng_info.interlaced = TRUE; - } else if (!strncmp(*argv, "-time", 3)) { - wpng_info.modtime = time(NULL); - wpng_info.have_time = TRUE; - } else if (!strncmp(*argv, "-text", 3)) { - text = TRUE; - } else if (!strncmp(*argv, "-gamma", 2)) { - if (!*++argv) - ++error; - else { - wpng_info.gamma = atof(*argv); - if (wpng_info.gamma <= 0.0) - ++error; - else if (wpng_info.gamma > 1.01) - fprintf(stderr, PROGNAME - " warning: file gammas are usually less than 1.0\n"); - } - } else if (!strncmp(*argv, "-bgcolor", 4)) { - if (!*++argv) - ++error; - else { - bgstr = *argv; - if (strlen(bgstr) != 7 || bgstr[0] != '#') - ++error; - else { - unsigned r, g, b; /* this way quiets compiler warnings */ - - sscanf(bgstr+1, "%2x%2x%2x", &r, &g, &b); - wpng_info.bg_red = (uch)r; - wpng_info.bg_green = (uch)g; - wpng_info.bg_blue = (uch)b; - wpng_info.have_bg = TRUE; - } - } - } else { - if (**argv != '-') { - inname = *argv; - if (argv[1]) /* shouldn't be any more args after filename */ - ++error; - } else - ++error; /* not expecting any other options */ - } - } - - - /* open the input and output files, or register an error and abort */ - - if (!inname) { - if (isatty(0)) { - fprintf(stderr, PROGNAME - ": must give input filename or provide image data via stdin\n"); - ++error; - } else { -#ifdef DOS_OS2_W32 - /* some buggy C libraries require BOTH setmode() and fdopen(bin) */ - setmode(fileno(stdin), O_BINARY); - setmode(fileno(stdout), O_BINARY); -#endif - if ((wpng_info.infile = fdopen(fileno(stdin), "rb")) == NULL) { - fprintf(stderr, PROGNAME - ": unable to reopen stdin in binary mode\n"); - ++error; - } else - if ((wpng_info.outfile = fdopen(fileno(stdout), "wb")) == NULL) { - fprintf(stderr, PROGNAME - ": unable to reopen stdout in binary mode\n"); - fclose(wpng_info.infile); - ++error; - } else - wpng_info.filter = TRUE; - } - } else if ((len = strlen(inname)) > 250) { - fprintf(stderr, PROGNAME ": input filename is too long [%d chars]\n", - len); - ++error; - } else if (!(wpng_info.infile = fopen(inname, "rb"))) { - fprintf(stderr, PROGNAME ": can't open input file [%s]\n", inname); - ++error; - } - - if (!error) { - fgets(pnmline, 256, wpng_info.infile); - if (pnmline[0] != 'P' || ((pnmchar = pnmline[1]) != '5' && - pnmchar != '6' && pnmchar != '8')) - { - fprintf(stderr, PROGNAME - ": input file [%s] is not a binary PGM, PPM or PAM file\n", - inname); - ++error; - } else { - wpng_info.pnmtype = (int)(pnmchar - '0'); - if (wpng_info.pnmtype != 8) - wpng_info.have_bg = FALSE; /* no need for bg if opaque */ - do { - fgets(pnmline, 256, wpng_info.infile); /* lose any comments */ - } while (pnmline[0] == '#'); - sscanf(pnmline, "%ld %ld", &wpng_info.width, &wpng_info.height); - do { - fgets(pnmline, 256, wpng_info.infile); /* more comment lines */ - } while (pnmline[0] == '#'); - sscanf(pnmline, "%d", &maxval); - if (wpng_info.width <= 0L || wpng_info.height <= 0L || - maxval != 255) - { - fprintf(stderr, PROGNAME - ": only positive width/height, maxval == 255 allowed \n"); - ++error; - } - wpng_info.sample_depth = 8; /* <==> maxval 255 */ - - if (!wpng_info.filter) { - /* make outname from inname */ - if ((p = strrchr(inname, '.')) == NULL || - (p - inname) != (len - 4)) - { - strcpy(outname, inname); - strcpy(outname+len, ".png"); - } else { - len -= 4; - strncpy(outname, inname, len); - strcpy(outname+len, ".png"); - } - /* check if outname already exists; if not, open */ - if ((wpng_info.outfile = fopen(outname, "rb")) != NULL) { - fprintf(stderr, PROGNAME ": output file exists [%s]\n", - outname); - fclose(wpng_info.outfile); - ++error; - } else if (!(wpng_info.outfile = fopen(outname, "wb"))) { - fprintf(stderr, PROGNAME ": can't open output file [%s]\n", - outname); - ++error; - } - } - } - if (error) { - fclose(wpng_info.infile); - wpng_info.infile = NULL; - if (wpng_info.filter) { - fclose(wpng_info.outfile); - wpng_info.outfile = NULL; - } - } - } - - - /* if we had any errors, print usage and die horrible death...arrr! */ - - if (error) { - fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, APPNAME); - writepng_version_info(); - fprintf(stderr, "\n" -"Usage: %s [-gamma exp] [-bgcolor bg] [-text] [-time] [-interlace] pnmfile\n" -"or: ... | %s [-gamma exp] [-bgcolor bg] [-text] [-time] [-interlace] | ...\n" - " exp \ttransfer-function exponent (``gamma'') of the image in\n" - "\t\t floating-point format (e.g., ``%.5f''); if image looks\n" - "\t\t correct on given display system, image gamma is equal to\n" - "\t\t inverse of display-system exponent, i.e., 1 / (LUT * CRT)\n" - "\t\t (where LUT = lookup-table exponent and CRT = CRT exponent;\n" - "\t\t first varies, second is usually 2.2, all are positive)\n" - " bg \tdesired background color for alpha-channel images, in\n" - "\t\t 7-character hex RGB format (e.g., ``#ff7700'' for orange:\n" - "\t\t same as HTML colors)\n" - " -text\tprompt interactively for text info (tEXt chunks)\n" - " -time\tinclude a tIME chunk (last modification time)\n" - " -interlace\twrite interlaced PNG image\n" - "\n" -"pnmfile or stdin must be a binary PGM (`P5'), PPM (`P6') or (extremely\n" -"unofficial and unsupported!) PAM (`P8') file. Currently it is required\n" -"to have maxval == 255 (i.e., no scaling). If pnmfile is specified, it\n" -"is converted to the corresponding PNG file with the same base name but a\n" -"``.png'' extension; files read from stdin are converted and sent to stdout.\n" -"The conversion is progressive (low memory usage) unless interlacing is\n" -"requested; in that case the whole image will be buffered in memory and\n" -"written in one call.\n" - "\n", PROGNAME, PROGNAME, default_gamma); - exit(1); - } - - - /* prepare the text buffers for libpng's use; note that even though - * PNG's png_text struct includes a length field, we don't have to fill - * it out */ - - if (text && -#ifndef DOS_OS2_W32 - (keybd = fdopen(fileno(stderr), "r")) != NULL && -#endif - (textbuf = (char *)malloc((5 + 9)*75)) != NULL) - { - int i, valid, result; - - fprintf(stderr, - "Enter text info (no more than 72 characters per line);\n"); - fprintf(stderr, "to skip a field, hit the <Enter> key.\n"); - /* note: just <Enter> leaves len == 1 */ - - do { - valid = TRUE; - p = textbuf + TEXT_TITLE_OFFSET; - fprintf(stderr, " Title: "); - fflush(stderr); - if (FGETS(p, 74, keybd) && (len = strlen(p)) > 1) { - if (p[len-1] == '\n') - p[--len] = '\0'; - wpng_info.title = p; - wpng_info.have_text |= TEXT_TITLE; - if ((result = wpng_isvalid_latin1((uch *)p, len)) >= 0) { - fprintf(stderr, " " PROGNAME " warning: character code" - " %u is %sdiscouraged by the PNG\n specification " - "[first occurrence was at character position #%d]\n", - (unsigned)p[result], (p[result] == 27)? "strongly " : "", - result+1); - fflush(stderr); -#ifdef FORBID_LATIN1_CTRL - wpng_info.have_text &= ~TEXT_TITLE; - valid = FALSE; -#else - if (p[result] == 27) { /* escape character */ - wpng_info.have_text &= ~TEXT_TITLE; - valid = FALSE; - } -#endif - } - } - } while (!valid); - - do { - valid = TRUE; - p = textbuf + TEXT_AUTHOR_OFFSET; - fprintf(stderr, " Author: "); - fflush(stderr); - if (FGETS(p, 74, keybd) && (len = strlen(p)) > 1) { - if (p[len-1] == '\n') - p[--len] = '\0'; - wpng_info.author = p; - wpng_info.have_text |= TEXT_AUTHOR; - if ((result = wpng_isvalid_latin1((uch *)p, len)) >= 0) { - fprintf(stderr, " " PROGNAME " warning: character code" - " %u is %sdiscouraged by the PNG\n specification " - "[first occurrence was at character position #%d]\n", - (unsigned)p[result], (p[result] == 27)? "strongly " : "", - result+1); - fflush(stderr); -#ifdef FORBID_LATIN1_CTRL - wpng_info.have_text &= ~TEXT_AUTHOR; - valid = FALSE; -#else - if (p[result] == 27) { /* escape character */ - wpng_info.have_text &= ~TEXT_AUTHOR; - valid = FALSE; - } -#endif - } - } - } while (!valid); - - do { - valid = TRUE; - p = textbuf + TEXT_DESC_OFFSET; - fprintf(stderr, " Description (up to 9 lines):\n"); - for (i = 1; i < 10; ++i) { - fprintf(stderr, " [%d] ", i); - fflush(stderr); - if (FGETS(p, 74, keybd) && (len = strlen(p)) > 1) - p += len; /* now points at NULL; char before is newline */ - else - break; - } - if ((len = p - (textbuf + TEXT_DESC_OFFSET)) > 1) { - if (p[-1] == '\n') { - p[-1] = '\0'; - --len; - } - wpng_info.desc = textbuf + TEXT_DESC_OFFSET; - wpng_info.have_text |= TEXT_DESC; - p = textbuf + TEXT_DESC_OFFSET; - if ((result = wpng_isvalid_latin1((uch *)p, len)) >= 0) { - fprintf(stderr, " " PROGNAME " warning: character code" - " %u is %sdiscouraged by the PNG\n specification " - "[first occurrence was at character position #%d]\n", - (unsigned)p[result], (p[result] == 27)? "strongly " : "", - result+1); - fflush(stderr); -#ifdef FORBID_LATIN1_CTRL - wpng_info.have_text &= ~TEXT_DESC; - valid = FALSE; -#else - if (p[result] == 27) { /* escape character */ - wpng_info.have_text &= ~TEXT_DESC; - valid = FALSE; - } -#endif - } - } - } while (!valid); - - do { - valid = TRUE; - p = textbuf + TEXT_COPY_OFFSET; - fprintf(stderr, " Copyright: "); - fflush(stderr); - if (FGETS(p, 74, keybd) && (len = strlen(p)) > 1) { - if (p[len-1] == '\n') - p[--len] = '\0'; - wpng_info.copyright = p; - wpng_info.have_text |= TEXT_COPY; - if ((result = wpng_isvalid_latin1((uch *)p, len)) >= 0) { - fprintf(stderr, " " PROGNAME " warning: character code" - " %u is %sdiscouraged by the PNG\n specification " - "[first occurrence was at character position #%d]\n", - (unsigned)p[result], (p[result] == 27)? "strongly " : "", - result+1); - fflush(stderr); -#ifdef FORBID_LATIN1_CTRL - wpng_info.have_text &= ~TEXT_COPY; - valid = FALSE; -#else - if (p[result] == 27) { /* escape character */ - wpng_info.have_text &= ~TEXT_COPY; - valid = FALSE; - } -#endif - } - } - } while (!valid); - - do { - valid = TRUE; - p = textbuf + TEXT_EMAIL_OFFSET; - fprintf(stderr, " E-mail: "); - fflush(stderr); - if (FGETS(p, 74, keybd) && (len = strlen(p)) > 1) { - if (p[len-1] == '\n') - p[--len] = '\0'; - wpng_info.email = p; - wpng_info.have_text |= TEXT_EMAIL; - if ((result = wpng_isvalid_latin1((uch *)p, len)) >= 0) { - fprintf(stderr, " " PROGNAME " warning: character code" - " %u is %sdiscouraged by the PNG\n specification " - "[first occurrence was at character position #%d]\n", - (unsigned)p[result], (p[result] == 27)? "strongly " : "", - result+1); - fflush(stderr); -#ifdef FORBID_LATIN1_CTRL - wpng_info.have_text &= ~TEXT_EMAIL; - valid = FALSE; -#else - if (p[result] == 27) { /* escape character */ - wpng_info.have_text &= ~TEXT_EMAIL; - valid = FALSE; - } -#endif - } - } - } while (!valid); - - do { - valid = TRUE; - p = textbuf + TEXT_URL_OFFSET; - fprintf(stderr, " URL: "); - fflush(stderr); - if (FGETS(p, 74, keybd) && (len = strlen(p)) > 1) { - if (p[len-1] == '\n') - p[--len] = '\0'; - wpng_info.url = p; - wpng_info.have_text |= TEXT_URL; - if ((result = wpng_isvalid_latin1((uch *)p, len)) >= 0) { - fprintf(stderr, " " PROGNAME " warning: character code" - " %u is %sdiscouraged by the PNG\n specification " - "[first occurrence was at character position #%d]\n", - (unsigned)p[result], (p[result] == 27)? "strongly " : "", - result+1); - fflush(stderr); -#ifdef FORBID_LATIN1_CTRL - wpng_info.have_text &= ~TEXT_URL; - valid = FALSE; -#else - if (p[result] == 27) { /* escape character */ - wpng_info.have_text &= ~TEXT_URL; - valid = FALSE; - } -#endif - } - } - } while (!valid); - -#ifndef DOS_OS2_W32 - fclose(keybd); -#endif - - } else if (text) { - fprintf(stderr, PROGNAME ": unable to allocate memory for text\n"); - text = FALSE; - wpng_info.have_text = 0; - } - - - /* allocate libpng stuff, initialize transformations, write pre-IDAT data */ - - if ((rc = writepng_init(&wpng_info)) != 0) { - switch (rc) { - case 2: - fprintf(stderr, PROGNAME - ": libpng initialization problem (longjmp)\n"); - break; - case 4: - fprintf(stderr, PROGNAME ": insufficient memory\n"); - break; - case 11: - fprintf(stderr, PROGNAME - ": internal logic error (unexpected PNM type)\n"); - break; - default: - fprintf(stderr, PROGNAME - ": unknown writepng_init() error\n"); - break; - } - exit(rc); - } - - - /* free textbuf, since it's a completely local variable and all text info - * has just been written to the PNG file */ - - if (text && textbuf) { - free(textbuf); - textbuf = NULL; - } - - - /* calculate rowbytes on basis of image type; note that this becomes much - * more complicated if we choose to support PBM type, ASCII PNM types, or - * 16-bit-per-sample binary data [currently not an official NetPBM type] */ - - if (wpng_info.pnmtype == 5) - rowbytes = wpng_info.width; - else if (wpng_info.pnmtype == 6) - rowbytes = wpng_info.width * 3; - else /* if (wpng_info.pnmtype == 8) */ - rowbytes = wpng_info.width * 4; - - - /* read and write the image, either in its entirety (if writing interlaced - * PNG) or row by row (if non-interlaced) */ - - fprintf(stderr, "Encoding image data...\n"); - fflush(stderr); - - if (wpng_info.interlaced) { - long i; - ulg bytes; - ulg image_bytes = rowbytes * wpng_info.height; /* overflow? */ - - wpng_info.image_data = (uch *)malloc(image_bytes); - wpng_info.row_pointers = (uch **)malloc(wpng_info.height*sizeof(uch *)); - if (wpng_info.image_data == NULL || wpng_info.row_pointers == NULL) { - fprintf(stderr, PROGNAME ": insufficient memory for image data\n"); - writepng_cleanup(&wpng_info); - wpng_cleanup(); - exit(5); - } - for (i = 0; i < wpng_info.height; ++i) - wpng_info.row_pointers[i] = wpng_info.image_data + i*rowbytes; - bytes = fread(wpng_info.image_data, 1, image_bytes, wpng_info.infile); - if (bytes != image_bytes) { - fprintf(stderr, PROGNAME ": expected %lu bytes, got %lu bytes\n", - image_bytes, bytes); - fprintf(stderr, " (continuing anyway)\n"); - } - if (writepng_encode_image(&wpng_info) != 0) { - fprintf(stderr, PROGNAME - ": libpng problem (longjmp) while writing image data\n"); - writepng_cleanup(&wpng_info); - wpng_cleanup(); - exit(2); - } - - } else /* not interlaced: write progressively (row by row) */ { - long j; - ulg bytes; - - wpng_info.image_data = (uch *)malloc(rowbytes); - if (wpng_info.image_data == NULL) { - fprintf(stderr, PROGNAME ": insufficient memory for row data\n"); - writepng_cleanup(&wpng_info); - wpng_cleanup(); - exit(5); - } - error = 0; - for (j = wpng_info.height; j > 0L; --j) { - bytes = fread(wpng_info.image_data, 1, rowbytes, wpng_info.infile); - if (bytes != rowbytes) { - fprintf(stderr, PROGNAME - ": expected %lu bytes, got %lu bytes (row %ld)\n", rowbytes, - bytes, wpng_info.height-j); - ++error; - break; - } - if (writepng_encode_row(&wpng_info) != 0) { - fprintf(stderr, PROGNAME - ": libpng problem (longjmp) while writing row %ld\n", - wpng_info.height-j); - ++error; - break; - } - } - if (error) { - writepng_cleanup(&wpng_info); - wpng_cleanup(); - exit(2); - } - if (writepng_encode_finish(&wpng_info) != 0) { - fprintf(stderr, PROGNAME ": error on final libpng call\n"); - writepng_cleanup(&wpng_info); - wpng_cleanup(); - exit(2); - } - } - - - /* OK, we're done (successfully): clean up all resources and quit */ - - fprintf(stderr, "Done.\n"); - fflush(stderr); - - writepng_cleanup(&wpng_info); - wpng_cleanup(); - - return 0; -} - - - - - -static int wpng_isvalid_latin1(uch *p, int len) -{ - int i, result = -1; - - for (i = 0; i < len; ++i) { - if (p[i] == 10 || (p[i] > 31 && p[i] < 127) || p[i] > 160) - continue; /* character is completely OK */ - if (result < 0 || (p[result] != 27 && p[i] == 27)) - result = i; /* mark location of first questionable one */ - } /* or of first escape character (bad) */ - - return result; -} - - - - - -static void wpng_cleanup(void) -{ - if (wpng_info.outfile) { - fclose(wpng_info.outfile); - wpng_info.outfile = NULL; - } - - if (wpng_info.infile) { - fclose(wpng_info.infile); - wpng_info.infile = NULL; - } - - if (wpng_info.image_data) { - free(wpng_info.image_data); - wpng_info.image_data = NULL; - } - - if (wpng_info.row_pointers) { - free(wpng_info.row_pointers); - wpng_info.row_pointers = NULL; - } -} - - - - -#ifdef DOS_OS2_W32 - -static char *dos_kbd_gets(char *buf, int len) -{ - int ch, count=0; - - do { - buf[count++] = ch = getche(); - } while (ch != '\r' && count < len-1); - - buf[count--] = '\0'; /* terminate string */ - if (buf[count] == '\r') /* Enter key makes CR, so change to newline */ - buf[count] = '\n'; - - fprintf(stderr, "\n"); /* Enter key does *not* cause a newline */ - fflush(stderr); - - return buf; -} - -#endif /* DOS_OS2_W32 */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/writepng.c b/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/writepng.c deleted file mode 100644 index 7e1e43641..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/writepng.c +++ /dev/null @@ -1,368 +0,0 @@ -/*--------------------------------------------------------------------------- - - wpng - simple PNG-writing program writepng.c - - --------------------------------------------------------------------------- - - Copyright (c) 1998-2000 Greg Roelofs. All rights reserved. - - This software is provided "as is," without warranty of any kind, - express or implied. In no event shall the author or contributors - be held liable for any damages arising in any way from the use of - this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute - it freely, subject to the following restrictions: - - 1. Redistributions of source code must retain the above copyright - notice, disclaimer, and this list of conditions. - 2. Redistributions in binary form must reproduce the above copyright - notice, disclaimer, and this list of conditions in the documenta- - tion and/or other materials provided with the distribution. - 3. All advertising materials mentioning features or use of this - software must display the following acknowledgment: - - This product includes software developed by Greg Roelofs - and contributors for the book, "PNG: The Definitive Guide," - published by O'Reilly and Associates. - - ---------------------------------------------------------------------------*/ - - -#include <stdlib.h> /* for exit() prototype */ - -#include "png.h" /* libpng header; includes zlib.h and setjmp.h */ -#include "writepng.h" /* typedefs, common macros, public prototypes */ - - -/* local prototype */ - -static void writepng_error_handler(png_structp png_ptr, png_const_charp msg); - - - -void writepng_version_info(void) -{ - fprintf(stderr, " Compiled with libpng %s; using libpng %s.\n", - PNG_LIBPNG_VER_STRING, png_libpng_ver); - fprintf(stderr, " Compiled with zlib %s; using zlib %s.\n", - ZLIB_VERSION, zlib_version); -} - - - - -/* returns 0 for success, 2 for libpng problem, 4 for out of memory, 11 for - * unexpected pnmtype; note that outfile might be stdout */ - -int writepng_init(mainprog_info *mainprog_ptr) -{ - png_structp png_ptr; /* note: temporary variables! */ - png_infop info_ptr; - int color_type, interlace_type; - - - /* could also replace libpng warning-handler (final NULL), but no need: */ - - png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, mainprog_ptr, - writepng_error_handler, NULL); - if (!png_ptr) - return 4; /* out of memory */ - - info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) { - png_destroy_write_struct(&png_ptr, NULL); - return 4; /* out of memory */ - } - - - /* setjmp() must be called in every function that calls a PNG-writing - * libpng function, unless an alternate error handler was installed-- - * but compatible error handlers must either use longjmp() themselves - * (as in this program) or exit immediately, so here we go: */ - - if (setjmp(mainprog_ptr->jmpbuf)) { - png_destroy_write_struct(&png_ptr, &info_ptr); - return 2; - } - - - /* make sure outfile is (re)opened in BINARY mode */ - - png_init_io(png_ptr, mainprog_ptr->outfile); - - - /* set the compression levels--in general, always want to leave filtering - * turned on (except for palette images) and allow all of the filters, - * which is the default; want 32K zlib window, unless entire image buffer - * is 16K or smaller (unknown here)--also the default; usually want max - * compression (NOT the default); and remaining compression flags should - * be left alone */ - - png_set_compression_level(png_ptr, Z_BEST_COMPRESSION); -/* - >> this is default for no filtering; Z_FILTERED is default otherwise: - png_set_compression_strategy(png_ptr, Z_DEFAULT_STRATEGY); - >> these are all defaults: - png_set_compression_mem_level(png_ptr, 8); - png_set_compression_window_bits(png_ptr, 15); - png_set_compression_method(png_ptr, 8); - */ - - - /* set the image parameters appropriately */ - - if (mainprog_ptr->pnmtype == 5) - color_type = PNG_COLOR_TYPE_GRAY; - else if (mainprog_ptr->pnmtype == 6) - color_type = PNG_COLOR_TYPE_RGB; - else if (mainprog_ptr->pnmtype == 8) - color_type = PNG_COLOR_TYPE_RGB_ALPHA; - else { - png_destroy_write_struct(&png_ptr, &info_ptr); - return 11; - } - - interlace_type = mainprog_ptr->interlaced? PNG_INTERLACE_ADAM7 : - PNG_INTERLACE_NONE; - - png_set_IHDR(png_ptr, info_ptr, mainprog_ptr->width, mainprog_ptr->height, - mainprog_ptr->sample_depth, color_type, interlace_type, - PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); - - if (mainprog_ptr->gamma > 0.0) - png_set_gAMA(png_ptr, info_ptr, mainprog_ptr->gamma); - - if (mainprog_ptr->have_bg) { /* we know it's RGBA, not gray+alpha */ - png_color_16 background; - - background.red = mainprog_ptr->bg_red; - background.green = mainprog_ptr->bg_green; - background.blue = mainprog_ptr->bg_blue; - png_set_bKGD(png_ptr, info_ptr, &background); - } - - if (mainprog_ptr->have_time) { - png_time modtime; - - png_convert_from_time_t(&modtime, mainprog_ptr->modtime); - png_set_tIME(png_ptr, info_ptr, &modtime); - } - - if (mainprog_ptr->have_text) { - png_text text[6]; - int num_text = 0; - - if (mainprog_ptr->have_text & TEXT_TITLE) { - text[num_text].compression = PNG_TEXT_COMPRESSION_NONE; - text[num_text].key = "Title"; - text[num_text].text = mainprog_ptr->title; - ++num_text; - } - if (mainprog_ptr->have_text & TEXT_AUTHOR) { - text[num_text].compression = PNG_TEXT_COMPRESSION_NONE; - text[num_text].key = "Author"; - text[num_text].text = mainprog_ptr->author; - ++num_text; - } - if (mainprog_ptr->have_text & TEXT_DESC) { - text[num_text].compression = PNG_TEXT_COMPRESSION_NONE; - text[num_text].key = "Description"; - text[num_text].text = mainprog_ptr->desc; - ++num_text; - } - if (mainprog_ptr->have_text & TEXT_COPY) { - text[num_text].compression = PNG_TEXT_COMPRESSION_NONE; - text[num_text].key = "Copyright"; - text[num_text].text = mainprog_ptr->copyright; - ++num_text; - } - if (mainprog_ptr->have_text & TEXT_EMAIL) { - text[num_text].compression = PNG_TEXT_COMPRESSION_NONE; - text[num_text].key = "E-mail"; - text[num_text].text = mainprog_ptr->email; - ++num_text; - } - if (mainprog_ptr->have_text & TEXT_URL) { - text[num_text].compression = PNG_TEXT_COMPRESSION_NONE; - text[num_text].key = "URL"; - text[num_text].text = mainprog_ptr->url; - ++num_text; - } - png_set_text(png_ptr, info_ptr, text, num_text); - } - - - /* write all chunks up to (but not including) first IDAT */ - - png_write_info(png_ptr, info_ptr); - - - /* if we wanted to write any more text info *after* the image data, we - * would set up text struct(s) here and call png_set_text() again, with - * just the new data; png_set_tIME() could also go here, but it would - * have no effect since we already called it above (only one tIME chunk - * allowed) */ - - - /* set up the transformations: for now, just pack low-bit-depth pixels - * into bytes (one, two or four pixels per byte) */ - - png_set_packing(png_ptr); -/* png_set_shift(png_ptr, &sig_bit); to scale low-bit-depth values */ - - - /* make sure we save our pointers for use in writepng_encode_image() */ - - mainprog_ptr->png_ptr = png_ptr; - mainprog_ptr->info_ptr = info_ptr; - - - /* OK, that's all we need to do for now; return happy */ - - return 0; -} - - - - - -/* returns 0 for success, 2 for libpng (longjmp) problem */ - -int writepng_encode_image(mainprog_info *mainprog_ptr) -{ - png_structp png_ptr = (png_structp)mainprog_ptr->png_ptr; - png_infop info_ptr = (png_infop)mainprog_ptr->info_ptr; - - - /* as always, setjmp() must be called in every function that calls a - * PNG-writing libpng function */ - - if (setjmp(mainprog_ptr->jmpbuf)) { - png_destroy_write_struct(&png_ptr, &info_ptr); - mainprog_ptr->png_ptr = NULL; - mainprog_ptr->info_ptr = NULL; - return 2; - } - - - /* and now we just write the whole image; libpng takes care of interlacing - * for us */ - - png_write_image(png_ptr, mainprog_ptr->row_pointers); - - - /* since that's it, we also close out the end of the PNG file now--if we - * had any text or time info to write after the IDATs, second argument - * would be info_ptr, but we optimize slightly by sending NULL pointer: */ - - png_write_end(png_ptr, NULL); - - return 0; -} - - - - - -/* returns 0 if succeeds, 2 if libpng problem */ - -int writepng_encode_row(mainprog_info *mainprog_ptr) /* NON-interlaced only! */ -{ - png_structp png_ptr = (png_structp)mainprog_ptr->png_ptr; - png_infop info_ptr = (png_infop)mainprog_ptr->info_ptr; - - - /* as always, setjmp() must be called in every function that calls a - * PNG-writing libpng function */ - - if (setjmp(mainprog_ptr->jmpbuf)) { - png_destroy_write_struct(&png_ptr, &info_ptr); - mainprog_ptr->png_ptr = NULL; - mainprog_ptr->info_ptr = NULL; - return 2; - } - - - /* image_data points at our one row of image data */ - - png_write_row(png_ptr, mainprog_ptr->image_data); - - return 0; -} - - - - - -/* returns 0 if succeeds, 2 if libpng problem */ - -int writepng_encode_finish(mainprog_info *mainprog_ptr) /* NON-interlaced! */ -{ - png_structp png_ptr = (png_structp)mainprog_ptr->png_ptr; - png_infop info_ptr = (png_infop)mainprog_ptr->info_ptr; - - - /* as always, setjmp() must be called in every function that calls a - * PNG-writing libpng function */ - - if (setjmp(mainprog_ptr->jmpbuf)) { - png_destroy_write_struct(&png_ptr, &info_ptr); - mainprog_ptr->png_ptr = NULL; - mainprog_ptr->info_ptr = NULL; - return 2; - } - - - /* close out PNG file; if we had any text or time info to write after - * the IDATs, second argument would be info_ptr: */ - - png_write_end(png_ptr, NULL); - - return 0; -} - - - - - -void writepng_cleanup(mainprog_info *mainprog_ptr) -{ - png_structp png_ptr = (png_structp)mainprog_ptr->png_ptr; - png_infop info_ptr = (png_infop)mainprog_ptr->info_ptr; - - if (png_ptr && info_ptr) - png_destroy_write_struct(&png_ptr, &info_ptr); -} - - - - - -static void writepng_error_handler(png_structp png_ptr, png_const_charp msg) -{ - mainprog_info *mainprog_ptr; - - /* This function, aside from the extra step of retrieving the "error - * pointer" (below) and the fact that it exists within the application - * rather than within libpng, is essentially identical to libpng's - * default error handler. The second point is critical: since both - * setjmp() and longjmp() are called from the same code, they are - * guaranteed to have compatible notions of how big a jmp_buf is, - * regardless of whether _BSD_SOURCE or anything else has (or has not) - * been defined. */ - - fprintf(stderr, "writepng libpng error: %s\n", msg); - fflush(stderr); - - mainprog_ptr = png_get_error_ptr(png_ptr); - if (mainprog_ptr == NULL) { /* we are completely hosed now */ - fprintf(stderr, - "writepng severe error: jmpbuf not recoverable; terminating.\n"); - fflush(stderr); - exit(99); - } - - longjmp(mainprog_ptr->jmpbuf, 1); -} diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/writepng.h b/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/writepng.h deleted file mode 100644 index 26d7117ac..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/gregbook/writepng.h +++ /dev/null @@ -1,109 +0,0 @@ -/*--------------------------------------------------------------------------- - - wpng - simple PNG-writing program writepng.h - - --------------------------------------------------------------------------- - - Copyright (c) 1998-2000 Greg Roelofs. All rights reserved. - - This software is provided "as is," without warranty of any kind, - express or implied. In no event shall the author or contributors - be held liable for any damages arising in any way from the use of - this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute - it freely, subject to the following restrictions: - - 1. Redistributions of source code must retain the above copyright - notice, disclaimer, and this list of conditions. - 2. Redistributions in binary form must reproduce the above copyright - notice, disclaimer, and this list of conditions in the documenta- - tion and/or other materials provided with the distribution. - 3. All advertising materials mentioning features or use of this - software must display the following acknowledgment: - - This product includes software developed by Greg Roelofs - and contributors for the book, "PNG: The Definitive Guide," - published by O'Reilly and Associates. - - ---------------------------------------------------------------------------*/ - -#ifndef TRUE -# define TRUE 1 -# define FALSE 0 -#endif - -#ifndef MAX -# define MAX(a,b) ((a) > (b)? (a) : (b)) -# define MIN(a,b) ((a) < (b)? (a) : (b)) -#endif - -#ifdef DEBUG -# define Trace(x) {fprintf x ; fflush(stderr); fflush(stdout);} -#else -# define Trace(x) ; -#endif - -#define TEXT_TITLE 0x01 -#define TEXT_AUTHOR 0x02 -#define TEXT_DESC 0x04 -#define TEXT_COPY 0x08 -#define TEXT_EMAIL 0x10 -#define TEXT_URL 0x20 - -#define TEXT_TITLE_OFFSET 0 -#define TEXT_AUTHOR_OFFSET 72 -#define TEXT_COPY_OFFSET (2*72) -#define TEXT_EMAIL_OFFSET (3*72) -#define TEXT_URL_OFFSET (4*72) -#define TEXT_DESC_OFFSET (5*72) - -typedef unsigned char uch; -typedef unsigned short ush; -typedef unsigned long ulg; - -typedef struct _mainprog_info { - double gamma; - long width; - long height; - time_t modtime; - FILE *infile; - FILE *outfile; - void *png_ptr; - void *info_ptr; - uch *image_data; - uch **row_pointers; - char *title; - char *author; - char *desc; - char *copyright; - char *email; - char *url; - int filter; /* command-line-filter flag, not PNG row filter! */ - int pnmtype; - int sample_depth; - int interlaced; - int have_bg; - int have_time; - int have_text; - jmp_buf jmpbuf; - uch bg_red; - uch bg_green; - uch bg_blue; -} mainprog_info; - - -/* prototypes for public functions in writepng.c */ - -void writepng_version_info(void); - -int writepng_init(mainprog_info *mainprog_ptr); - -int writepng_encode_image(mainprog_info *mainprog_ptr); - -int writepng_encode_row(mainprog_info *mainprog_ptr); - -int writepng_encode_finish(mainprog_info *mainprog_ptr); - -void writepng_cleanup(mainprog_info *mainprog_ptr); diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngminus/README b/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngminus/README deleted file mode 100644 index b0516ec5e..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngminus/README +++ /dev/null @@ -1,153 +0,0 @@ -PngMinus --------- -(copyright Willem van Schaik, 1999) - - -License -------- - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and -that both that copyright notice and this permission notice appear in -supporting documentation. This software is provided "as is" without -express or implied warranty. - - -Some history ------------- -Soon after the creation of PNG in 1995, the need was felt for a set of -pnmtopng / pngtopnm utilities. Independantly Alexander Lehmann and I -(Willem van Schaik) started such a project. Luckily we discovered this -and merged the two together into pnmtopng.tar.gz, which is available -from a/o ftp://ftp.simplesystems.org/pub/libpng/png/. - -These two utilities have many, many options and make use of most of the -features of PNG, like gamma, alpha, sbit, text-chunks, etc. This makes -the utilities quite complex and by now not anymore very maintainable. -When we wrote these programs, libpng was still in an early stage. -Therefore, lots of the functionality that we put in our software can now -be done using transform-functions in libpng. - -Finally, to compile these programs, you need to have installed and -compiled three libraries: libpng, zlib and netpbm. Especially the latter -makes the whole setup a bit bulky. But that's unavoidable given the many -features of pnmtopng. - - -What now --------- -At this moment libpng is in a very stable state and can do much of the -work done in pnmtopng. Also, pnmtopng needs to be upgraded to the new -interface of libpng. Hence, it is time for a rewrite from the ground up -of pnmtopng and pngtopnm. This will happen in the near future (stay -tuned). The new package will get a different name to distinguish it from -the old one: PngPlus. - -To experiment a bit with the new interface of libpng, I started off with -a small prototype that contains only the basic functionality. It doesn't -have any of the options to read or write special chunks and it will do -no gamma correction. But this makes it also a simple program that is -quite easy to understand and can serve well as a template for other -software developments. (By now there are of course a couple of programs, -like Greg Roelofs' rpng/wpng, that can be used just as good.) - - -Can and can not ---------------- -As this is the small brother of the future PngPlus, I called this fellow -PngMinus. Because I started this development in good-old Turbo-C, I -avoided the use the netpbm library, which requires DOS extenders. Again, -another reason to call it PngMinus (minus netpbm :-). So, part of the -program are some elementary routines to read / write pgm- and ppm-files. -It does not read b&w pbm-files. - -The downside of this approach is that you can not use them on images -that require blocks of memory bigger than 64k (the DOS version). For -larger images you will get an out-of-memory error. - -As said before, PngMinus doesn't correct for gamma. When reading -png-files you can do this just as well by piping the output of png2pnm -to pnmgamma, one of the standard PbmPlus tools. This same scenario will -most probably also be followed in the full-blown future PngPlus, with -the addition of course of the possibility to create gamma-chunks when -writing png-files. - -On the other hand it supports alpha-channels. When reading a png-image -you can write the alpha-channel into a pgm-file. And when creating an -RGB+A png-image, you just combine a ppm-file with a corresponding -pgm-file containing the alpha-channel. When reading, transparency chunks -are converted into an alpha-channel and from there on treated the same -way. - -Finally you can opt for writing ascii or binary pgm- and ppm-files. When -the bit-depth is 16, the format will always be ascii. - - -Using it --------- -To distinguish them from pnmtopng and PngPlus, the utilities are named -png2pnm and pnm2png (2 instead of to). The input- and output-files can -be given as parameters or through redirection. Therefore the programs -can be part of a pipe. - -To list the options type "png2pnm -h" or "pnm2png -h". - - -Just like Scandinavian furniture --------------------------------- -You have to put it together yourself. I did test the software under -MS-DOS with Turbo-C 3.0 and under RedHat Linux 4.2 with gcc. In both -cases I used libpng-1.0.4 and zlib-1.1.3. Later versions should be OK, -however some older libpng versions have a bug in pngmem.c when using -Turbo-C 3.0 (see below). - -You can build it using one of the two makefiles (make -f makefile.###) -or use the batch/script files pngminus.bat / pngminus.sh. This assumes -that you have built the libraries in ../libpng and ../zlib. Using Linux, -make sure that you have built libpng with makefile.std and not -makefile.linux (also called .lnx in earlier versions of libpng). The -latter creates a .so shared-library, while the PngMinus makefile assumes -a normal .a static library. - -If you create a ../pngsuite directory and then store the basn####.png -files from PngSuite (http://www.schaik.com/pngsuite/) in there, you can -test in one go the proper functioning of PngMinus, see png2pnm.bat and -pnm2png.bat (or the .sh versions). - - -Warranty -------- -Please, remember that this was just a small experiment to learn a few -things. It will have many unforeseen features <vbg>. Who said bugs? Use -it when you are in need for something simple or when you want to start -developing your own stuff. - - -The Turbo bug -------------- -** pngmem.old - hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L); - hptr += 16L; -** pngmem.c - hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L); - hptr = hptr + 16L; -** - -** pngmem.old - png_ptr->offset_table_ptr[i] = (png_bytep)hptr; - hptr += (png_uint_32)65536L; -** pngmem.c - png_ptr->offset_table_ptr[i] = (png_bytep)hptr; - hptr = hptr + 65536L; -** - - -The end -------- -Willem van Schaik -mailto:willem@schaik.com -http://www.schaik.com/png/ -------- -Oct 1999 - diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngminus/makefile.std b/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngminus/makefile.std deleted file mode 100644 index afe15c7c7..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngminus/makefile.std +++ /dev/null @@ -1,65 +0,0 @@ -# Makefile for PngMinus (png2pnm and pnm2png) -# Linux / Unix - -#CC=cc -CC=gcc -LD=$(CC) - -RM=rm -f - -#PNGPATH = /usr/local -#PNGINC = -I$(PNGPATH)/include/libpng12 -#PNGLIB = -L$(PNGPATH)/lib -lpng12 -#PNGLIBS = $(PNGPATH)/lib/libpng12.a -PNGINC = -I../.. -PNGLIB = -L../.. -lpng -PNGLIBS = ../../libpng.a - -#ZPATH = /usr/local -#ZINC = -I$(ZPATH)/include -#ZLIB = -L$(ZPATH)/lib -lz -#ZLIBS = $(ZPATH)/lib/libz.a -ZINC = -I../../../zlib -ZLIB = -L../../../zlib -lz -ZLIBS = ../../../zlib/libz.a - -CFLAGS=-O3 $(PNGINC) $(ZINC) -LDFLAGS=$(PNGLIB) $(ZLIB) -LDFLAGSS=$(PNGLIBS) $(ZLIBS) -C=.c -O=.o -L=.a -E= - -# dependencies - -#all: png2pnm$(E) pnm2png$(E) -all: png2pnm$(E) pnm2png$(E) png2pnm-static$(E) pnm2png-static$(E) - -png2pnm$(O): png2pnm$(C) - $(CC) -c $(CFLAGS) png2pnm$(C) - -png2pnm$(E): png2pnm$(O) - $(LD) -o png2pnm$(E) png2pnm$(O) $(LDFLAGS) -lm - -png2pnm-static$(E): png2pnm$(O) - $(LD) -o png2pnm-static$(E) png2pnm$(O) $(LDFLAGSS) -lm - -pnm2png$(O): pnm2png$(C) - $(CC) -c $(CFLAGS) pnm2png$(C) - -pnm2png$(E): pnm2png$(O) - $(LD) -o pnm2png$(E) pnm2png$(O) $(LDFLAGS) -lm - -pnm2png-static$(E): pnm2png$(O) - $(LD) -o pnm2png-static$(E) pnm2png$(O) $(LDFLAGSS) -lm - -clean: - $(RM) png2pnm$(O) - $(RM) pnm2png$(O) - $(RM) png2pnm$(E) - $(RM) pnm2png$(E) - $(RM) png2pnm-static$(E) - $(RM) pnm2png-static$(E) - -# End of makefile for png2pnm / pnm2png diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngminus/makefile.tc3 b/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngminus/makefile.tc3 deleted file mode 100644 index 01062ccd5..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngminus/makefile.tc3 +++ /dev/null @@ -1,38 +0,0 @@ -# Makefile for PngMinus (png2pnm and pnm2png) -# TurboC++ 3.0 - -CC=tcc -Ic:\tc3\inc -LD=tcc -Lc:\tc3\lib -LB=tlib -RM=del -CP=copy -MODEL=l -CCFLAGS=-O -m$(MODEL) -I..\libpng -I..\zlib -LDFLAGS=-m$(MODEL) -L..\libpng -L..\zlib -C=.c -O=.obj -L=.lib -E=.exe - -# dependencies - -all: png2pnm$(E) pnm2png$(E) - -png2pnm$(O): png2pnm$(C) - $(CC) -c $(CCFLAGS) png2pnm$(C) - -png2pnm$(E): png2pnm$(O) - $(LD) $(LDFLAGS) png2pnm$(O) libpng$(L) zlib$(L) - -pnm2png$(O): pnm2png$(C) - $(CC) -c $(CCFLAGS) pnm2png$(C) - -pnm2png$(E): pnm2png$(O) - $(LD) $(LDFLAGS) pnm2png$(O) libpng$(L) zlib$(L) - -clean: - $(RM) *$(O) - $(RM) *$(E) - -# End of makefile for png2pnm / pnm2png - diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngminus/makevms.com b/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngminus/makevms.com deleted file mode 100644 index 96c3147cc..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngminus/makevms.com +++ /dev/null @@ -1,92 +0,0 @@ -$!------------------------------------------------------------------------------ -$! make Contrib programs of libpng under OpenVMS -$! -$! -$! Look for the compiler used -$! -$ zlibsrc = "[---.zlib]" -$ ccopt="/include=(''zlibsrc',[--])" -$ if f$getsyi("HW_MODEL").ge.1024 -$ then -$ ccopt = "/prefix=all"+ccopt -$ comp = "__decc__=1" -$ if f$trnlnm("SYS").eqs."" then define sys sys$library: -$ else -$ if f$search("SYS$SYSTEM:DECC$COMPILER.EXE").eqs."" -$ then -$ if f$trnlnm("SYS").eqs."" then define sys sys$library: -$ if f$search("SYS$SYSTEM:VAXC.EXE").eqs."" -$ then -$ comp = "__gcc__=1" -$ CC :== GCC -$ else -$ comp = "__vaxc__=1" -$ endif -$ else -$ if f$trnlnm("SYS").eqs."" then define sys decc$library_include: -$ ccopt = "/decc/prefix=all"+ccopt -$ comp = "__decc__=1" -$ endif -$ endif -$ open/write lopt lib.opt -$ write lopt "[--]libpng.olb/lib" -$ write lopt "''zlibsrc'libz.olb/lib" -$ close lopt -$ open/write xopt x11.opt -$ write xopt "sys$library:decw$xlibshr.exe/share" -$ close xopt -$ write sys$output "Compiling PNG contrib programs ..." -$ write sys$output "Building pnm2png..." -$ CALL MAKE pnm2png.OBJ "cc ''CCOPT' pnm2png" - - pnm2png.c -$ call make pnm2png.exe - - "LINK pnm2png,lib.opt/opt" - - pnm2png.obj -$ write sys$output "Building png2pnm..." -$ CALL MAKE png2pnm.OBJ "cc ''CCOPT' png2pnm" - - png2pnm.c -$ call make png2pnm.exe - - "LINK png2pnm,lib.opt/opt" - - png2pnm.obj -$ exit -$! -$! -$MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES -$ V = 'F$Verify(0) -$! P1 = What we are trying to make -$! P2 = Command to make it -$! P3 - P8 What it depends on -$ -$ If F$Search(P1) .Eqs. "" Then Goto Makeit -$ Time = F$CvTime(F$File(P1,"RDT")) -$arg=3 -$Loop: -$ Argument = P'arg -$ If Argument .Eqs. "" Then Goto Exit -$ El=0 -$Loop2: -$ File = F$Element(El," ",Argument) -$ If File .Eqs. " " Then Goto Endl -$ AFile = "" -$Loop3: -$ OFile = AFile -$ AFile = F$Search(File) -$ If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl -$ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit -$ Goto Loop3 -$NextEL: -$ El = El + 1 -$ Goto Loop2 -$EndL: -$ arg=arg+1 -$ If arg .Le. 8 Then Goto Loop -$ Goto Exit -$ -$Makeit: -$ VV=F$VERIFY(0) -$ write sys$output P2 -$ 'P2 -$ VV='F$Verify(VV) -$Exit: -$ If V Then Set Verify -$ENDSUBROUTINE diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngminus/png2pnm.bat b/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngminus/png2pnm.bat deleted file mode 100644 index 85abe3cbb..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngminus/png2pnm.bat +++ /dev/null @@ -1,41 +0,0 @@ -REM -- grayscale -png2pnm.exe -noraw ..\pngsuite\basn0g01.png basn0g01.pgm -png2pnm.exe -noraw ..\pngsuite\basn0g02.png basn0g02.pgm -png2pnm.exe -noraw ..\pngsuite\basn0g04.png basn0g04.pgm -png2pnm.exe -noraw ..\pngsuite\basn0g08.png basn0g08.pgm -png2pnm.exe -noraw ..\pngsuite\basn0g16.png basn0g16.pgm -REM -- full-color -png2pnm.exe -noraw ..\pngsuite\basn2c08.png basn2c08.ppm -png2pnm.exe -noraw ..\pngsuite\basn2c16.png basn2c16.ppm -REM -- palletted -png2pnm.exe -noraw ..\pngsuite\basn3p01.png basn3p01.ppm -png2pnm.exe -noraw ..\pngsuite\basn3p02.png basn3p02.ppm -png2pnm.exe -noraw ..\pngsuite\basn3p04.png basn3p04.ppm -png2pnm.exe -noraw ..\pngsuite\basn3p08.png basn3p08.ppm -REM -- gray with alpha-channel -png2pnm.exe -noraw ..\pngsuite\basn4a08.png basn4a08.pgm -png2pnm.exe -noraw ..\pngsuite\basn4a16.png basn4a16.pgm -REM -- color with alpha-channel -png2pnm.exe -noraw -alpha basn6a08.pgm ..\pngsuite\basn6a08.png basn6a08.ppm -png2pnm.exe -noraw -alpha basn6a16.pgm ..\pngsuite\basn6a16.png basn6a16.ppm -REM -- grayscale -png2pnm.exe -raw ..\pngsuite\basn0g01.png rawn0g01.pgm -png2pnm.exe -raw ..\pngsuite\basn0g02.png rawn0g02.pgm -png2pnm.exe -raw ..\pngsuite\basn0g04.png rawn0g04.pgm -png2pnm.exe -raw ..\pngsuite\basn0g08.png rawn0g08.pgm -png2pnm.exe -raw ..\pngsuite\basn0g16.png rawn0g16.pgm -REM -- full-color -png2pnm.exe -raw ..\pngsuite\basn2c08.png rawn2c08.ppm -png2pnm.exe -raw ..\pngsuite\basn2c16.png rawn2c16.ppm -REM -- palletted -png2pnm.exe -raw ..\pngsuite\basn3p01.png rawn3p01.ppm -png2pnm.exe -raw ..\pngsuite\basn3p02.png rawn3p02.ppm -png2pnm.exe -raw ..\pngsuite\basn3p04.png rawn3p04.ppm -png2pnm.exe -raw ..\pngsuite\basn3p08.png rawn3p08.ppm -REM -- gray with alpha-channel -png2pnm.exe -raw ..\pngsuite\basn4a08.png rawn4a08.pgm -png2pnm.exe -raw ..\pngsuite\basn4a16.png rawn4a16.pgm -REM -- color with alpha-channel -png2pnm.exe -noraw -alpha rawn6a08.pgm ..\pngsuite\basn6a08.png rawn6a08.ppm -png2pnm.exe -noraw -alpha rawn6a16.pgm ..\pngsuite\basn6a16.png rawn6a16.ppm - diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngminus/png2pnm.c b/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngminus/png2pnm.c deleted file mode 100644 index 6ed477bfe..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngminus/png2pnm.c +++ /dev/null @@ -1,430 +0,0 @@ -/* - * png2pnm.c --- conversion from PNG-file to PGM/PPM-file - * copyright (C) 1999 by Willem van Schaik <willem@schaik.com> - * - * version 1.0 - 1999.10.15 - First version. - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear in - * supporting documentation. This software is provided "as is" without - * express or implied warranty. - */ - -#include <stdio.h> -#include <stdlib.h> -#ifdef __TURBOC__ -#include <mem.h> -#include <fcntl.h> -#endif - -#ifndef BOOL -#define BOOL unsigned char -#endif -#ifndef TRUE -#define TRUE (BOOL) 1 -#endif -#ifndef FALSE -#define FALSE (BOOL) 0 -#endif - -#ifdef __TURBOC__ -#define STDIN 0 -#define STDOUT 1 -#define STDERR 2 -#endif - -/* to make png2pnm verbose so we can find problems (needs to be before png.h) */ -#ifndef PNG_DEBUG -#define PNG_DEBUG 0 -#endif - -#include "png.h" - -/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */ -#ifndef png_jmpbuf -# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) -#endif - -/* function prototypes */ - -int main (int argc, char *argv[]); -void usage (); -BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL alpha); - -/* - * main - */ - -int main(int argc, char *argv[]) -{ - FILE *fp_rd = stdin; - FILE *fp_wr = stdout; - FILE *fp_al = NULL; - BOOL raw = TRUE; - BOOL alpha = FALSE; - int argi; - - for (argi = 1; argi < argc; argi++) - { - if (argv[argi][0] == '-') - { - switch (argv[argi][1]) - { - case 'n': - raw = FALSE; - break; - case 'r': - raw = TRUE; - break; - case 'a': - alpha = TRUE; - argi++; - if ((fp_al = fopen (argv[argi], "wb")) == NULL) - { - fprintf (stderr, "PNM2PNG\n"); - fprintf (stderr, "Error: can not create alpha-channel file %s\n", argv[argi]); - exit (1); - } - break; - case 'h': - case '?': - usage(); - exit(0); - break; - default: - fprintf (stderr, "PNG2PNM\n"); - fprintf (stderr, "Error: unknown option %s\n", argv[argi]); - usage(); - exit(1); - break; - } /* end switch */ - } - else if (fp_rd == stdin) - { - if ((fp_rd = fopen (argv[argi], "rb")) == NULL) - { - fprintf (stderr, "PNG2PNM\n"); - fprintf (stderr, "Error: file %s does not exist\n", argv[argi]); - exit (1); - } - } - else if (fp_wr == stdout) - { - if ((fp_wr = fopen (argv[argi], "wb")) == NULL) - { - fprintf (stderr, "PNG2PNM\n"); - fprintf (stderr, "Error: can not create file %s\n", argv[argi]); - exit (1); - } - } - else - { - fprintf (stderr, "PNG2PNM\n"); - fprintf (stderr, "Error: too many parameters\n"); - usage(); - exit(1); - } - } /* end for */ - -#ifdef __TURBOC__ - /* set stdin/stdout if required to binary */ - if (fp_rd == stdin) - { - setmode (STDIN, O_BINARY); - } - if ((raw) && (fp_wr == stdout)) - { - setmode (STDOUT, O_BINARY); - } -#endif - - /* call the conversion program itself */ - if (png2pnm (fp_rd, fp_wr, fp_al, raw, alpha) == FALSE) - { - fprintf (stderr, "PNG2PNM\n"); - fprintf (stderr, "Error: unsuccessful convertion of PNG-image\n"); - exit(1); - } - - /* close input file */ - fclose (fp_rd); - /* close output file */ - fclose (fp_wr); - /* close alpha file */ - if (alpha) - fclose (fp_al); - - return 0; -} - -/* - * usage - */ - -void usage() -{ - fprintf (stderr, "PNG2PNM\n"); - fprintf (stderr, " by Willem van Schaik, 1999\n"); -#ifdef __TURBOC__ - fprintf (stderr, " for Turbo-C and Borland-C compilers\n"); -#else - fprintf (stderr, " for Linux (and Unix) compilers\n"); -#endif - fprintf (stderr, "Usage: png2pnm [options] <file>.png [<file>.pnm]\n"); - fprintf (stderr, " or: ... | png2pnm [options]\n"); - fprintf (stderr, "Options:\n"); - fprintf (stderr, " -r[aw] write pnm-file in binary format (P4/P5/P6) (default)\n"); - fprintf (stderr, " -n[oraw] write pnm-file in ascii format (P1/P2/P3)\n"); - fprintf (stderr, " -a[lpha] <file>.pgm write PNG alpha channel as pgm-file\n"); - fprintf (stderr, " -h | -? print this help-information\n"); -} - -/* - * png2pnm - */ - -BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL alpha) -{ - png_struct *png_ptr = NULL; - png_info *info_ptr = NULL; - png_byte buf[8]; - png_byte *png_pixels = NULL; - png_byte **row_pointers = NULL; - png_byte *pix_ptr = NULL; - png_uint_32 row_bytes; - - png_uint_32 width; - png_uint_32 height; - int bit_depth; - int channels; - int color_type; - int alpha_present; - int row, col; - int ret; - int i; - long dep_16; - - /* read and check signature in PNG file */ - ret = fread (buf, 1, 8, png_file); - if (ret != 8) - return FALSE; - - ret = png_check_sig (buf, 8); - if (!ret) - return FALSE; - - /* create png and info structures */ - - png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, - NULL, NULL, NULL); - if (!png_ptr) - return FALSE; /* out of memory */ - - info_ptr = png_create_info_struct (png_ptr); - if (!info_ptr) - { - png_destroy_read_struct (&png_ptr, NULL, NULL); - return FALSE; /* out of memory */ - } - - if (setjmp (png_jmpbuf(png_ptr))) - { - png_destroy_read_struct (&png_ptr, &info_ptr, NULL); - return FALSE; - } - - /* set up the input control for C streams */ - png_init_io (png_ptr, png_file); - png_set_sig_bytes (png_ptr, 8); /* we already read the 8 signature bytes */ - - /* read the file information */ - png_read_info (png_ptr, info_ptr); - - /* get size and bit-depth of the PNG-image */ - png_get_IHDR (png_ptr, info_ptr, - &width, &height, &bit_depth, &color_type, - NULL, NULL, NULL); - - /* set-up the transformations */ - - /* transform paletted images into full-color rgb */ - if (color_type == PNG_COLOR_TYPE_PALETTE) - png_set_expand (png_ptr); - /* expand images to bit-depth 8 (only applicable for grayscale images) */ - if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) - png_set_expand (png_ptr); - /* transform transparency maps into full alpha-channel */ - if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS)) - png_set_expand (png_ptr); - -#ifdef NJET - /* downgrade 16-bit images to 8 bit */ - if (bit_depth == 16) - png_set_strip_16 (png_ptr); - /* transform grayscale images into full-color */ - if (color_type == PNG_COLOR_TYPE_GRAY || - color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_gray_to_rgb (png_ptr); - /* only if file has a file gamma, we do a correction */ - if (png_get_gAMA (png_ptr, info_ptr, &file_gamma)) - png_set_gamma (png_ptr, (double) 2.2, file_gamma); -#endif - - /* all transformations have been registered; now update info_ptr data, - * get rowbytes and channels, and allocate image memory */ - - png_read_update_info (png_ptr, info_ptr); - - /* get the new color-type and bit-depth (after expansion/stripping) */ - png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, - NULL, NULL, NULL); - - /* check for 16-bit files */ - if (bit_depth == 16) - { - raw = FALSE; -#ifdef __TURBOC__ - pnm_file->flags &= ~((unsigned) _F_BIN); -#endif - } - - /* calculate new number of channels and store alpha-presence */ - if (color_type == PNG_COLOR_TYPE_GRAY) - channels = 1; - else if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - channels = 2; - else if (color_type == PNG_COLOR_TYPE_RGB) - channels = 3; - else if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) - channels = 4; - else - channels = 0; /* should never happen */ - alpha_present = (channels - 1) % 2; - - /* check if alpha is expected to be present in file */ - if (alpha && !alpha_present) - { - fprintf (stderr, "PNG2PNM\n"); - fprintf (stderr, "Error: PNG-file doesn't contain alpha channel\n"); - exit (1); - } - - /* row_bytes is the width x number of channels x (bit-depth / 8) */ - row_bytes = png_get_rowbytes (png_ptr, info_ptr); - - if ((png_pixels = (png_byte *) malloc (row_bytes * height * sizeof (png_byte))) == NULL) { - png_destroy_read_struct (&png_ptr, &info_ptr, NULL); - return FALSE; - } - - if ((row_pointers = (png_byte **) malloc (height * sizeof (png_bytep))) == NULL) - { - png_destroy_read_struct (&png_ptr, &info_ptr, NULL); - free (png_pixels); - png_pixels = NULL; - return FALSE; - } - - /* set the individual row_pointers to point at the correct offsets */ - for (i = 0; i < (height); i++) - row_pointers[i] = png_pixels + i * row_bytes; - - /* now we can go ahead and just read the whole image */ - png_read_image (png_ptr, row_pointers); - - /* read rest of file, and get additional chunks in info_ptr - REQUIRED */ - png_read_end (png_ptr, info_ptr); - - /* clean up after the read, and free any memory allocated - REQUIRED */ - png_destroy_read_struct (&png_ptr, &info_ptr, (png_infopp) NULL); - - /* write header of PNM file */ - - if ((color_type == PNG_COLOR_TYPE_GRAY) || - (color_type == PNG_COLOR_TYPE_GRAY_ALPHA)) - { - fprintf (pnm_file, "%s\n", (raw) ? "P5" : "P2"); - fprintf (pnm_file, "%d %d\n", (int) width, (int) height); - fprintf (pnm_file, "%ld\n", ((1L << (int) bit_depth) - 1L)); - } - else if ((color_type == PNG_COLOR_TYPE_RGB) || - (color_type == PNG_COLOR_TYPE_RGB_ALPHA)) - { - fprintf (pnm_file, "%s\n", (raw) ? "P6" : "P3"); - fprintf (pnm_file, "%d %d\n", (int) width, (int) height); - fprintf (pnm_file, "%ld\n", ((1L << (int) bit_depth) - 1L)); - } - - /* write header of PGM file with alpha channel */ - - if ((alpha) && - ((color_type == PNG_COLOR_TYPE_GRAY_ALPHA) || - (color_type == PNG_COLOR_TYPE_RGB_ALPHA))) - { - fprintf (alpha_file, "%s\n", (raw) ? "P5" : "P2"); - fprintf (alpha_file, "%d %d\n", (int) width, (int) height); - fprintf (alpha_file, "%ld\n", ((1L << (int) bit_depth) - 1L)); - } - - /* write data to PNM file */ - pix_ptr = png_pixels; - - for (row = 0; row < height; row++) - { - for (col = 0; col < width; col++) - { - for (i = 0; i < (channels - alpha_present); i++) - { - if (raw) - fputc ((int) *pix_ptr++ , pnm_file); - else - if (bit_depth == 16){ - dep_16 = (long) *pix_ptr++; - fprintf (pnm_file, "%ld ", (dep_16 << 8) + ((long) *pix_ptr++)); - } - else - fprintf (pnm_file, "%ld ", (long) *pix_ptr++); - } - if (alpha_present) - { - if (!alpha) - { - pix_ptr++; /* alpha */ - if (bit_depth == 16) - pix_ptr++; - } - else /* output alpha-channel as pgm file */ - { - if (raw) - fputc ((int) *pix_ptr++ , alpha_file); - else - if (bit_depth == 16){ - dep_16 = (long) *pix_ptr++; - fprintf (alpha_file, "%ld ", (dep_16 << 8) + (long) *pix_ptr++); - } - else - fprintf (alpha_file, "%ld ", (long) *pix_ptr++); - } - } /* if alpha_present */ - - if (!raw) - if (col % 4 == 3) - fprintf (pnm_file, "\n"); - } /* end for col */ - - if (!raw) - if (col % 4 != 0) - fprintf (pnm_file, "\n"); - } /* end for row */ - - if (row_pointers != (unsigned char**) NULL) - free (row_pointers); - if (png_pixels != (unsigned char*) NULL) - free (png_pixels); - - return TRUE; - -} /* end of source */ - diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngminus/png2pnm.sh b/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngminus/png2pnm.sh deleted file mode 100644 index ee39664db..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngminus/png2pnm.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh -# -- grayscale -./png2pnm -noraw ../pngsuite/basn0g01.png basn0g01.pgm -./png2pnm -noraw ../pngsuite/basn0g02.png basn0g02.pgm -./png2pnm -noraw ../pngsuite/basn0g04.png basn0g04.pgm -./png2pnm -noraw ../pngsuite/basn0g08.png basn0g08.pgm -./png2pnm -noraw ../pngsuite/basn0g16.png basn0g16.pgm -# -- full-color -./png2pnm -noraw ../pngsuite/basn2c08.png basn2c08.ppm -./png2pnm -noraw ../pngsuite/basn2c16.png basn2c16.ppm -# -- palletted -./png2pnm -noraw ../pngsuite/basn3p01.png basn3p01.ppm -./png2pnm -noraw ../pngsuite/basn3p02.png basn3p02.ppm -./png2pnm -noraw ../pngsuite/basn3p04.png basn3p04.ppm -./png2pnm -noraw ../pngsuite/basn3p08.png basn3p08.ppm -# -- gray with alpha-channel -./png2pnm -noraw ../pngsuite/basn4a08.png basn4a08.pgm -./png2pnm -noraw ../pngsuite/basn4a16.png basn4a16.pgm -# -- color with alpha-channel -./png2pnm -noraw -alpha basn6a08.pgm ../pngsuite/basn6a08.png basn6a08.ppm -./png2pnm -noraw -alpha basn6a16.pgm ../pngsuite/basn6a16.png basn6a16.ppm -# -- grayscale -./png2pnm -raw ../pngsuite/basn0g01.png rawn0g01.pgm -./png2pnm -raw ../pngsuite/basn0g02.png rawn0g02.pgm -./png2pnm -raw ../pngsuite/basn0g04.png rawn0g04.pgm -./png2pnm -raw ../pngsuite/basn0g08.png rawn0g08.pgm -./png2pnm -raw ../pngsuite/basn0g16.png rawn0g16.pgm -# -- full-color -./png2pnm -raw ../pngsuite/basn2c08.png rawn2c08.ppm -./png2pnm -raw ../pngsuite/basn2c16.png rawn2c16.ppm -# -- palletted -./png2pnm -raw ../pngsuite/basn3p01.png rawn3p01.ppm -./png2pnm -raw ../pngsuite/basn3p02.png rawn3p02.ppm -./png2pnm -raw ../pngsuite/basn3p04.png rawn3p04.ppm -./png2pnm -raw ../pngsuite/basn3p08.png rawn3p08.ppm -# -- gray with alpha-channel -./png2pnm -raw ../pngsuite/basn4a08.png rawn4a08.pgm -./png2pnm -raw ../pngsuite/basn4a16.png rawn4a16.pgm -# -- color with alpha-channel -./png2pnm -noraw -alpha rawn6a08.pgm ../pngsuite/basn6a08.png rawn6a08.ppm -./png2pnm -noraw -alpha rawn6a16.pgm ../pngsuite/basn6a16.png rawn6a16.ppm - diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngminus/pngminus.bat b/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngminus/pngminus.bat deleted file mode 100644 index 5f8d2d490..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngminus/pngminus.bat +++ /dev/null @@ -1,4 +0,0 @@ -make -f makefile.tc3 -call png2pnm.bat -call pnm2png.bat - diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngminus/pngminus.sh b/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngminus/pngminus.sh deleted file mode 100644 index adcef553b..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngminus/pngminus.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -make -f makefile.std -sh png2pnm.sh -sh pnm2png.sh - diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngminus/pnm2png.bat b/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngminus/pnm2png.bat deleted file mode 100644 index 5b9977a98..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngminus/pnm2png.bat +++ /dev/null @@ -1,41 +0,0 @@ -REM -- grayscale -pnm2png.exe basn0g01.pgm basn0g01.png -pnm2png.exe basn0g02.pgm basn0g02.png -pnm2png.exe basn0g04.pgm basn0g04.png -pnm2png.exe basn0g08.pgm basn0g08.png -pnm2png.exe basn0g16.pgm basn0g16.png -REM -- full-color -pnm2png.exe basn2c08.ppm basn2c08.png -pnm2png.exe basn2c16.ppm basn2c16.png -REM -- palletted -pnm2png.exe basn3p01.ppm basn3p01.png -pnm2png.exe basn3p02.ppm basn3p02.png -pnm2png.exe basn3p04.ppm basn3p04.png -pnm2png.exe basn3p08.ppm basn3p08.png -REM -- gray with alpha-channel -pnm2png.exe -alpha basn6a08.pgm basn4a08.pgm basn4a08.png -pnm2png.exe -alpha basn6a16.pgm basn4a16.pgm basn4a16.png -REM -- color with alpha-channel -pnm2png.exe -alpha basn6a08.pgm basn6a08.ppm basn6a08.png -pnm2png.exe -alpha basn6a16.pgm basn6a16.ppm basn6a16.png -REM -- grayscale -pnm2png.exe rawn0g01.pgm rawn0g01.png -pnm2png.exe rawn0g02.pgm rawn0g02.png -pnm2png.exe rawn0g04.pgm rawn0g04.png -pnm2png.exe rawn0g08.pgm rawn0g08.png -pnm2png.exe rawn0g16.pgm rawn0g16.png -REM -- full-color -pnm2png.exe rawn2c08.ppm rawn2c08.png -pnm2png.exe rawn2c16.ppm rawn2c16.png -REM -- palletted -pnm2png.exe rawn3p01.ppm rawn3p01.png -pnm2png.exe rawn3p02.ppm rawn3p02.png -pnm2png.exe rawn3p04.ppm rawn3p04.png -pnm2png.exe rawn3p08.ppm rawn3p08.png -REM -- gray with alpha-channel -pnm2png.exe -alpha rawn6a08.pgm rawn4a08.pgm rawn4a08.png -pnm2png.exe -alpha rawn6a16.pgm rawn4a16.pgm rawn4a16.png -REM -- color with alpha-channel -pnm2png.exe -alpha rawn6a08.pgm rawn6a08.ppm rawn6a08.png -pnm2png.exe -alpha rawn6a16.pgm rawn6a16.ppm rawn6a16.png - diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngminus/pnm2png.c b/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngminus/pnm2png.c deleted file mode 100644 index 2f321cc36..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngminus/pnm2png.c +++ /dev/null @@ -1,533 +0,0 @@ -/* - * pnm2png.c --- conversion from PBM/PGM/PPM-file to PNG-file - * copyright (C) 1999 by Willem van Schaik <willem@schaik.com> - * - * version 1.0 - 1999.10.15 - First version. - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear in - * supporting documentation. This software is provided "as is" without - * express or implied warranty. - */ - -#include <stdio.h> -#include <stdlib.h> -#ifdef __TURBOC__ -#include <mem.h> -#include <fcntl.h> -#endif - -#ifndef BOOL -#define BOOL unsigned char -#endif -#ifndef TRUE -#define TRUE (BOOL) 1 -#endif -#ifndef FALSE -#define FALSE (BOOL) 0 -#endif - -#define STDIN 0 -#define STDOUT 1 -#define STDERR 2 - -/* to make pnm2png verbose so we can find problems (needs to be before png.h) */ -#ifndef PNG_DEBUG -#define PNG_DEBUG 0 -#endif - -#include "png.h" - -/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */ -#ifndef png_jmpbuf -# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) -#endif - -/* function prototypes */ - -int main (int argc, char *argv[]); -void usage (); -BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace, BOOL alpha); -void get_token(FILE *pnm_file, char *token); -png_uint_32 get_data (FILE *pnm_file, int depth); -png_uint_32 get_value (FILE *pnm_file, int depth); - -/* - * main - */ - -int main(int argc, char *argv[]) -{ - FILE *fp_rd = stdin; - FILE *fp_al = NULL; - FILE *fp_wr = stdout; - BOOL interlace = FALSE; - BOOL alpha = FALSE; - int argi; - - for (argi = 1; argi < argc; argi++) - { - if (argv[argi][0] == '-') - { - switch (argv[argi][1]) - { - case 'i': - interlace = TRUE; - break; - case 'a': - alpha = TRUE; - argi++; - if ((fp_al = fopen (argv[argi], "rb")) == NULL) - { - fprintf (stderr, "PNM2PNG\n"); - fprintf (stderr, "Error: alpha-channel file %s does not exist\n", - argv[argi]); - exit (1); - } - break; - case 'h': - case '?': - usage(); - exit(0); - break; - default: - fprintf (stderr, "PNM2PNG\n"); - fprintf (stderr, "Error: unknown option %s\n", argv[argi]); - usage(); - exit(1); - break; - } /* end switch */ - } - else if (fp_rd == stdin) - { - if ((fp_rd = fopen (argv[argi], "rb")) == NULL) - { - fprintf (stderr, "PNM2PNG\n"); - fprintf (stderr, "Error: file %s does not exist\n", argv[argi]); - exit (1); - } - } - else if (fp_wr == stdout) - { - if ((fp_wr = fopen (argv[argi], "wb")) == NULL) - { - fprintf (stderr, "PNM2PNG\n"); - fprintf (stderr, "Error: can not create PNG-file %s\n", argv[argi]); - exit (1); - } - } - else - { - fprintf (stderr, "PNM2PNG\n"); - fprintf (stderr, "Error: too many parameters\n"); - usage(); - exit (1); - } - } /* end for */ - -#ifdef __TURBOC__ - /* set stdin/stdout to binary, we're reading the PNM always! in binary format */ - if (fp_rd == stdin) - { - setmode (STDIN, O_BINARY); - } - if (fp_wr == stdout) - { - setmode (STDOUT, O_BINARY); - } -#endif - - /* call the conversion program itself */ - if (pnm2png (fp_rd, fp_wr, fp_al, interlace, alpha) == FALSE) - { - fprintf (stderr, "PNM2PNG\n"); - fprintf (stderr, "Error: unsuccessful converting to PNG-image\n"); - exit (1); - } - - /* close input file */ - fclose (fp_rd); - /* close output file */ - fclose (fp_wr); - /* close alpha file */ - if (alpha) - fclose (fp_al); - - return 0; -} - -/* - * usage - */ - -void usage() -{ - fprintf (stderr, "PNM2PNG\n"); - fprintf (stderr, " by Willem van Schaik, 1999\n"); -#ifdef __TURBOC__ - fprintf (stderr, " for Turbo-C and Borland-C compilers\n"); -#else - fprintf (stderr, " for Linux (and Unix) compilers\n"); -#endif - fprintf (stderr, "Usage: pnm2png [options] <file>.<pnm> [<file>.png]\n"); - fprintf (stderr, " or: ... | pnm2png [options]\n"); - fprintf (stderr, "Options:\n"); - fprintf (stderr, " -i[nterlace] write png-file with interlacing on\n"); - fprintf (stderr, " -a[lpha] <file>.pgm read PNG alpha channel as pgm-file\n"); - fprintf (stderr, " -h | -? print this help-information\n"); -} - -/* - * pnm2png - */ - -BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace, BOOL alpha) -{ - png_struct *png_ptr = NULL; - png_info *info_ptr = NULL; - png_byte *png_pixels = NULL; - png_byte **row_pointers = NULL; - png_byte *pix_ptr = NULL; - png_uint_32 row_bytes; - - char type_token[16]; - char width_token[16]; - char height_token[16]; - char maxval_token[16]; - int color_type; - png_uint_32 width, alpha_width; - png_uint_32 height, alpha_height; - png_uint_32 maxval; - int bit_depth = 0; - int channels; - int alpha_depth = 0; - int alpha_present; - int row, col; - BOOL raw, alpha_raw = FALSE; - png_uint_32 tmp16; - int i; - - /* read header of PNM file */ - - get_token(pnm_file, type_token); - if (type_token[0] != 'P') - { - return FALSE; - } - else if ((type_token[1] == '1') || (type_token[1] == '4')) - { - raw = (type_token[1] == '4'); - color_type = PNG_COLOR_TYPE_GRAY; - bit_depth = 1; - } - else if ((type_token[1] == '2') || (type_token[1] == '5')) - { - raw = (type_token[1] == '5'); - color_type = PNG_COLOR_TYPE_GRAY; - get_token(pnm_file, width_token); - sscanf (width_token, "%lu", &width); - get_token(pnm_file, height_token); - sscanf (height_token, "%lu", &height); - get_token(pnm_file, maxval_token); - sscanf (maxval_token, "%lu", &maxval); - if (maxval <= 1) - bit_depth = 1; - else if (maxval <= 3) - bit_depth = 2; - else if (maxval <= 15) - bit_depth = 4; - else if (maxval <= 255) - bit_depth = 8; - else /* if (maxval <= 65535) */ - bit_depth = 16; - } - else if ((type_token[1] == '3') || (type_token[1] == '6')) - { - raw = (type_token[1] == '6'); - color_type = PNG_COLOR_TYPE_RGB; - get_token(pnm_file, width_token); - sscanf (width_token, "%lu", &width); - get_token(pnm_file, height_token); - sscanf (height_token, "%lu", &height); - get_token(pnm_file, maxval_token); - sscanf (maxval_token, "%lu", &maxval); - if (maxval <= 1) - bit_depth = 1; - else if (maxval <= 3) - bit_depth = 2; - else if (maxval <= 15) - bit_depth = 4; - else if (maxval <= 255) - bit_depth = 8; - else /* if (maxval <= 65535) */ - bit_depth = 16; - } - else - { - return FALSE; - } - - /* read header of PGM file with alpha channel */ - - if (alpha) - { - if (color_type == PNG_COLOR_TYPE_GRAY) - color_type = PNG_COLOR_TYPE_GRAY_ALPHA; - if (color_type == PNG_COLOR_TYPE_RGB) - color_type = PNG_COLOR_TYPE_RGB_ALPHA; - - get_token(alpha_file, type_token); - if (type_token[0] != 'P') - { - return FALSE; - } - else if ((type_token[1] == '2') || (type_token[1] == '5')) - { - alpha_raw = (type_token[1] == '5'); - get_token(alpha_file, width_token); - sscanf (width_token, "%lu", &alpha_width); - if (alpha_width != width) - return FALSE; - get_token(alpha_file, height_token); - sscanf (height_token, "%lu", &alpha_height); - if (alpha_height != height) - return FALSE; - get_token(alpha_file, maxval_token); - sscanf (maxval_token, "%lu", &maxval); - if (maxval <= 1) - alpha_depth = 1; - else if (maxval <= 3) - alpha_depth = 2; - else if (maxval <= 15) - alpha_depth = 4; - else if (maxval <= 255) - alpha_depth = 8; - else /* if (maxval <= 65535) */ - alpha_depth = 16; - if (alpha_depth != bit_depth) - return FALSE; - } - else - { - return FALSE; - } - } /* end if alpha */ - - /* calculate the number of channels and store alpha-presence */ - if (color_type == PNG_COLOR_TYPE_GRAY) - channels = 1; - else if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - channels = 2; - else if (color_type == PNG_COLOR_TYPE_RGB) - channels = 3; - else if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) - channels = 4; - else - channels = 0; /* should not happen */ - - alpha_present = (channels - 1) % 2; - - /* row_bytes is the width x number of channels x (bit-depth / 8) */ - row_bytes = width * channels * ((bit_depth <= 8) ? 1 : 2); - - if ((png_pixels = (png_byte *) malloc (row_bytes * height * sizeof (png_byte))) == NULL) - return FALSE; - - /* read data from PNM file */ - pix_ptr = png_pixels; - - for (row = 0; row < height; row++) - { - for (col = 0; col < width; col++) - { - for (i = 0; i < (channels - alpha_present); i++) - { - if (raw) - *pix_ptr++ = get_data (pnm_file, bit_depth); - else - if (bit_depth <= 8) - *pix_ptr++ = get_value (pnm_file, bit_depth); - else - { - tmp16 = get_value (pnm_file, bit_depth); - *pix_ptr = (png_byte) ((tmp16 >> 8) & 0xFF); - pix_ptr++; - *pix_ptr = (png_byte) (tmp16 & 0xFF); - pix_ptr++; - } - } - - if (alpha) /* read alpha-channel from pgm file */ - { - if (alpha_raw) - *pix_ptr++ = get_data (alpha_file, alpha_depth); - else - if (alpha_depth <= 8) - *pix_ptr++ = get_value (alpha_file, bit_depth); - else - { - tmp16 = get_value (alpha_file, bit_depth); - *pix_ptr++ = (png_byte) ((tmp16 >> 8) & 0xFF); - *pix_ptr++ = (png_byte) (tmp16 & 0xFF); - } - } /* if alpha */ - - } /* end for col */ - } /* end for row */ - - /* prepare the standard PNG structures */ - png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (!png_ptr) - { - return FALSE; - } - info_ptr = png_create_info_struct (png_ptr); - if (!info_ptr) - { - png_destroy_write_struct (&png_ptr, (png_infopp) NULL); - return FALSE; - } - - /* setjmp() must be called in every function that calls a PNG-reading libpng function */ - if (setjmp (png_jmpbuf(png_ptr))) - { - png_destroy_write_struct (&png_ptr, (png_infopp) NULL); - return FALSE; - } - - /* initialize the png structure */ - png_init_io (png_ptr, png_file); - - /* we're going to write more or less the same PNG as the input file */ - png_set_IHDR (png_ptr, info_ptr, width, height, bit_depth, color_type, - (!interlace) ? PNG_INTERLACE_NONE : PNG_INTERLACE_ADAM7, - PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); - - /* write the file header information */ - png_write_info (png_ptr, info_ptr); - - /* if needed we will allocate memory for an new array of row-pointers */ - if (row_pointers == (unsigned char**) NULL) - { - if ((row_pointers = (png_byte **) malloc (height * sizeof (png_bytep))) == NULL) - { - png_destroy_write_struct (&png_ptr, (png_infopp) NULL); - return FALSE; - } - } - - /* set the individual row_pointers to point at the correct offsets */ - for (i = 0; i < (height); i++) - row_pointers[i] = png_pixels + i * row_bytes; - - /* write out the entire image data in one call */ - png_write_image (png_ptr, row_pointers); - - /* write the additional chuncks to the PNG file (not really needed) */ - png_write_end (png_ptr, info_ptr); - - /* clean up after the write, and free any memory allocated */ - png_destroy_write_struct (&png_ptr, (png_infopp) NULL); - - if (row_pointers != (unsigned char**) NULL) - free (row_pointers); - if (png_pixels != (unsigned char*) NULL) - free (png_pixels); - - return TRUE; -} /* end of pnm2png */ - -/* - * get_token() - gets the first string after whitespace - */ - -void get_token(FILE *pnm_file, char *token) -{ - int i = 0; - - /* remove white-space */ - do - { - token[i] = (unsigned char) fgetc (pnm_file); - } - while ((token[i] == '\n') || (token[i] == '\r') || (token[i] == ' ')); - - /* read string */ - do - { - i++; - token[i] = (unsigned char) fgetc (pnm_file); - } - while ((token[i] != '\n') && (token[i] != '\r') && (token[i] != ' ')); - - token[i] = '\0'; - - return; -} - -/* - * get_data() - takes first byte and converts into next pixel value, - * taking as much bits as defined by bit-depth and - * using the bit-depth to fill up a byte (0Ah -> AAh) - */ - -png_uint_32 get_data (FILE *pnm_file, int depth) -{ - static int bits_left = 0; - static int old_value = 0; - static int mask = 0; - int i; - png_uint_32 ret_value; - - if (mask == 0) - for (i = 0; i < depth; i++) - mask = (mask >> 1) | 0x80; - - if (bits_left <= 0) - { - old_value = fgetc (pnm_file); - bits_left = 8; - } - - ret_value = old_value & mask; - for (i = 1; i < (8 / depth); i++) - ret_value = ret_value || (ret_value >> depth); - - old_value = (old_value << depth) & 0xFF; - bits_left -= depth; - - return ret_value; -} - -/* - * get_value() - takes first (numeric) string and converts into number, - * using the bit-depth to fill up a byte (0Ah -> AAh) - */ - -png_uint_32 get_value (FILE *pnm_file, int depth) -{ - static png_uint_32 mask = 0; - png_byte token[16]; - png_uint_32 ret_value; - int i = 0; - - if (mask == 0) - for (i = 0; i < depth; i++) - mask = (mask << 1) | 0x01; - - get_token (pnm_file, (char *) token); - sscanf ((const char *) token, "%lu", &ret_value); - - ret_value &= mask; - - if (depth < 8) - for (i = 0; i < (8 / depth); i++) - ret_value = (ret_value << depth) || ret_value; - - return ret_value; -} - -/* end of source */ - diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngminus/pnm2png.sh b/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngminus/pnm2png.sh deleted file mode 100644 index 975f04743..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngminus/pnm2png.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh -# -- grayscale -./pnm2png basn0g01.pgm basn0g01.png -./pnm2png basn0g02.pgm basn0g02.png -./pnm2png basn0g04.pgm basn0g04.png -./pnm2png basn0g08.pgm basn0g08.png -./pnm2png basn0g16.pgm basn0g16.png -# -- full-color -./pnm2png basn2c08.ppm basn2c08.png -./pnm2png basn2c16.ppm basn2c16.png -# -- palletted -./pnm2png basn3p01.ppm basn3p01.png -./pnm2png basn3p02.ppm basn3p02.png -./pnm2png basn3p04.ppm basn3p04.png -./pnm2png basn3p08.ppm basn3p08.png -# -- gray with alpha-channel -./pnm2png -alpha basn6a08.pgm basn4a08.pgm basn4a08.png -./pnm2png -alpha basn6a16.pgm basn4a16.pgm basn4a16.png -# -- color with alpha-channel -./pnm2png -alpha basn6a08.pgm basn6a08.ppm basn6a08.png -./pnm2png -alpha basn6a16.pgm basn6a16.ppm basn6a16.png -# -- grayscale -./pnm2png rawn0g01.pgm rawn0g01.png -./pnm2png rawn0g02.pgm rawn0g02.png -./pnm2png rawn0g04.pgm rawn0g04.png -./pnm2png rawn0g08.pgm rawn0g08.png -./pnm2png rawn0g16.pgm rawn0g16.png -# -- full-color -./pnm2png rawn2c08.ppm rawn2c08.png -./pnm2png rawn2c16.ppm rawn2c16.png -# -- palletted -./pnm2png rawn3p01.ppm rawn3p01.png -./pnm2png rawn3p02.ppm rawn3p02.png -./pnm2png rawn3p04.ppm rawn3p04.png -./pnm2png rawn3p08.ppm rawn3p08.png -# -- gray with alpha-channel -./pnm2png -alpha rawn6a08.pgm rawn4a08.pgm rawn4a08.png -./pnm2png -alpha rawn6a16.pgm rawn4a16.pgm rawn4a16.png -# -- color with alpha-channel -./pnm2png -alpha rawn6a08.pgm rawn6a08.ppm rawn6a08.png -./pnm2png -alpha rawn6a16.pgm rawn6a16.ppm rawn6a16.png - diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn0g01.png b/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn0g01.png deleted file mode 100644 index e31e1c7a6..000000000 Binary files a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn0g01.png and /dev/null differ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn0g02.png b/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn0g02.png deleted file mode 100644 index 68809dd8f..000000000 Binary files a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn0g02.png and /dev/null differ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn0g04.png b/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn0g04.png deleted file mode 100644 index 6fa089cb8..000000000 Binary files a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn0g04.png and /dev/null differ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn0g08.png b/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn0g08.png deleted file mode 100644 index bf522eef0..000000000 Binary files a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn0g08.png and /dev/null differ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn0g16.png b/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn0g16.png deleted file mode 100644 index 318ebcadf..000000000 Binary files a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn0g16.png and /dev/null differ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn2c08.png b/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn2c08.png deleted file mode 100644 index 21d2f91a8..000000000 Binary files a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn2c08.png and /dev/null differ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn2c16.png b/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn2c16.png deleted file mode 100644 index 1bd4a4d0e..000000000 Binary files a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn2c16.png and /dev/null differ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn3p01.png b/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn3p01.png deleted file mode 100644 index a21db5977..000000000 Binary files a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn3p01.png and /dev/null differ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn3p02.png b/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn3p02.png deleted file mode 100644 index 1d0ab6197..000000000 Binary files a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn3p02.png and /dev/null differ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn3p04.png b/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn3p04.png deleted file mode 100644 index 6dc6eac83..000000000 Binary files a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn3p04.png and /dev/null differ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn3p08.png b/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn3p08.png deleted file mode 100644 index 0e07f483c..000000000 Binary files a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn3p08.png and /dev/null differ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn4a08.png b/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn4a08.png deleted file mode 100644 index 3bb0dd06b..000000000 Binary files a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn4a08.png and /dev/null differ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn4a16.png b/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn4a16.png deleted file mode 100644 index 6dbee9fbd..000000000 Binary files a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn4a16.png and /dev/null differ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn6a08.png b/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn6a08.png deleted file mode 100644 index 610623085..000000000 Binary files a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn6a08.png and /dev/null differ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn6a16.png b/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn6a16.png deleted file mode 100644 index a9bf3cb46..000000000 Binary files a/irrlicht-1.6/source/Irrlicht/libpng/contrib/pngsuite/basn6a16.png and /dev/null differ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/visupng/PngFile.c b/irrlicht-1.6/source/Irrlicht/libpng/contrib/visupng/PngFile.c deleted file mode 100644 index 94c8fa600..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/visupng/PngFile.c +++ /dev/null @@ -1,439 +0,0 @@ -//------------------------------------- -// PNGFILE.C -- Image File Functions -//------------------------------------- - -// Copyright 2000, Willem van Schaik. For conditions of distribution and -// use, see the copyright/license/disclaimer notice in png.h - -#include <windows.h> -#include <commdlg.h> -#include <stdio.h> -#include <stdlib.h> - -#include "png.h" -#include "pngfile.h" -#include "cexcept.h" - -define_exception_type(const char *); -extern struct exception_context the_exception_context[1]; -struct exception_context the_exception_context[1]; -png_const_charp msg; - -static OPENFILENAME ofn; - -static png_structp png_ptr = NULL; -static png_infop info_ptr = NULL; - - -// cexcept interface - -static void -png_cexcept_error(png_structp png_ptr, png_const_charp msg) -{ - if(png_ptr) - ; -#ifndef PNG_NO_CONSOLE_IO - fprintf(stderr, "libpng error: %s\n", msg); -#endif - { - Throw msg; - } -} - -// Windows open-file functions - -void PngFileInitialize (HWND hwnd) -{ - static TCHAR szFilter[] = TEXT ("PNG Files (*.PNG)\0*.png\0") - TEXT ("All Files (*.*)\0*.*\0\0"); - - ofn.lStructSize = sizeof (OPENFILENAME); - ofn.hwndOwner = hwnd; - ofn.hInstance = NULL; - ofn.lpstrFilter = szFilter; - ofn.lpstrCustomFilter = NULL; - ofn.nMaxCustFilter = 0; - ofn.nFilterIndex = 0; - ofn.lpstrFile = NULL; // Set in Open and Close functions - ofn.nMaxFile = MAX_PATH; - ofn.lpstrFileTitle = NULL; // Set in Open and Close functions - ofn.nMaxFileTitle = MAX_PATH; - ofn.lpstrInitialDir = NULL; - ofn.lpstrTitle = NULL; - ofn.Flags = 0; // Set in Open and Close functions - ofn.nFileOffset = 0; - ofn.nFileExtension = 0; - ofn.lpstrDefExt = TEXT ("png"); - ofn.lCustData = 0; - ofn.lpfnHook = NULL; - ofn.lpTemplateName = NULL; -} - -BOOL PngFileOpenDlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName) -{ - ofn.hwndOwner = hwnd; - ofn.lpstrFile = pstrFileName; - ofn.lpstrFileTitle = pstrTitleName; - ofn.Flags = OFN_HIDEREADONLY; - - return GetOpenFileName (&ofn); -} - -BOOL PngFileSaveDlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName) -{ - ofn.hwndOwner = hwnd; - ofn.lpstrFile = pstrFileName; - ofn.lpstrFileTitle = pstrTitleName; - ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; - - return GetSaveFileName (&ofn); -} - -// PNG image handler functions - -BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData, - int *piWidth, int *piHeight, int *piChannels, png_color *pBkgColor) -{ - static FILE *pfFile; - png_byte pbSig[8]; - int iBitDepth; - int iColorType; - double dGamma; - png_color_16 *pBackground; - png_uint_32 ulChannels; - png_uint_32 ulRowBytes; - png_byte *pbImageData = *ppbImageData; - static png_byte **ppbRowPointers = NULL; - int i; - - // open the PNG input file - - if (!pstrFileName) - { - *ppbImageData = pbImageData = NULL; - return FALSE; - } - - if (!(pfFile = fopen(pstrFileName, "rb"))) - { - *ppbImageData = pbImageData = NULL; - return FALSE; - } - - // first check the eight byte PNG signature - - fread(pbSig, 1, 8, pfFile); - if (!png_check_sig(pbSig, 8)) - { - *ppbImageData = pbImageData = NULL; - return FALSE; - } - - // create the two png(-info) structures - - png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, - (png_error_ptr)png_cexcept_error, (png_error_ptr)NULL); - if (!png_ptr) - { - *ppbImageData = pbImageData = NULL; - return FALSE; - } - - info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - png_destroy_read_struct(&png_ptr, NULL, NULL); - *ppbImageData = pbImageData = NULL; - return FALSE; - } - - Try - { - - // initialize the png structure - -#if !defined(PNG_NO_STDIO) - png_init_io(png_ptr, pfFile); -#else - png_set_read_fn(png_ptr, (png_voidp)pfFile, png_read_data); -#endif - - png_set_sig_bytes(png_ptr, 8); - - // read all PNG info up to image data - - png_read_info(png_ptr, info_ptr); - - // get width, height, bit-depth and color-type - - png_get_IHDR(png_ptr, info_ptr, piWidth, piHeight, &iBitDepth, - &iColorType, NULL, NULL, NULL); - - // expand images of all color-type and bit-depth to 3x8 bit RGB images - // let the library process things like alpha, transparency, background - - if (iBitDepth == 16) - png_set_strip_16(png_ptr); - if (iColorType == PNG_COLOR_TYPE_PALETTE) - png_set_expand(png_ptr); - if (iBitDepth < 8) - png_set_expand(png_ptr); - if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) - png_set_expand(png_ptr); - if (iColorType == PNG_COLOR_TYPE_GRAY || - iColorType == PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_gray_to_rgb(png_ptr); - - // set the background color to draw transparent and alpha images over. - if (png_get_bKGD(png_ptr, info_ptr, &pBackground)) - { - png_set_background(png_ptr, pBackground, PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); - pBkgColor->red = (byte) pBackground->red; - pBkgColor->green = (byte) pBackground->green; - pBkgColor->blue = (byte) pBackground->blue; - } - else - { - pBkgColor = NULL; - } - - // if required set gamma conversion - if (png_get_gAMA(png_ptr, info_ptr, &dGamma)) - png_set_gamma(png_ptr, (double) 2.2, dGamma); - - // after the transformations have been registered update info_ptr data - - png_read_update_info(png_ptr, info_ptr); - - // get again width, height and the new bit-depth and color-type - - png_get_IHDR(png_ptr, info_ptr, piWidth, piHeight, &iBitDepth, - &iColorType, NULL, NULL, NULL); - - - // row_bytes is the width x number of channels - - ulRowBytes = png_get_rowbytes(png_ptr, info_ptr); - ulChannels = png_get_channels(png_ptr, info_ptr); - - *piChannels = ulChannels; - - // now we can allocate memory to store the image - - if (pbImageData) - { - free (pbImageData); - pbImageData = NULL; - } - if ((pbImageData = (png_byte *) malloc(ulRowBytes * (*piHeight) - * sizeof(png_byte))) == NULL) - { - png_error(png_ptr, "Visual PNG: out of memory"); - } - *ppbImageData = pbImageData; - - // and allocate memory for an array of row-pointers - - if ((ppbRowPointers = (png_bytepp) malloc((*piHeight) - * sizeof(png_bytep))) == NULL) - { - png_error(png_ptr, "Visual PNG: out of memory"); - } - - // set the individual row-pointers to point at the correct offsets - - for (i = 0; i < (*piHeight); i++) - ppbRowPointers[i] = pbImageData + i * ulRowBytes; - - // now we can go ahead and just read the whole image - - png_read_image(png_ptr, ppbRowPointers); - - // read the additional chunks in the PNG file (not really needed) - - png_read_end(png_ptr, NULL); - - // and we're done - - free (ppbRowPointers); - ppbRowPointers = NULL; - - // yepp, done - } - - Catch (msg) - { - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - - *ppbImageData = pbImageData = NULL; - - if(ppbRowPointers) - free (ppbRowPointers); - - fclose(pfFile); - - return FALSE; - } - - fclose (pfFile); - - return TRUE; -} - - -BOOL PngSaveImage (PTSTR pstrFileName, png_byte *pDiData, - int iWidth, int iHeight, png_color bkgColor) -{ - const int ciBitDepth = 8; - const int ciChannels = 3; - - static FILE *pfFile; - png_uint_32 ulRowBytes; - static png_byte **ppbRowPointers = NULL; - int i; - - // open the PNG output file - - if (!pstrFileName) - return FALSE; - - if (!(pfFile = fopen(pstrFileName, "wb"))) - return FALSE; - - // prepare the standard PNG structures - - png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, - (png_error_ptr)png_cexcept_error, (png_error_ptr)NULL); - if (!png_ptr) - { - fclose(pfFile); - return FALSE; - } - - info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) { - fclose(pfFile); - png_destroy_write_struct(&png_ptr, (png_infopp) NULL); - return FALSE; - } - - Try - { - // initialize the png structure - -#if !defined(PNG_NO_STDIO) - png_init_io(png_ptr, pfFile); -#else - png_set_write_fn(png_ptr, (png_voidp)pfFile, png_write_data, png_flush); -#endif - - // we're going to write a very simple 3x8 bit RGB image - - png_set_IHDR(png_ptr, info_ptr, iWidth, iHeight, ciBitDepth, - PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, - PNG_FILTER_TYPE_BASE); - - // write the file header information - - png_write_info(png_ptr, info_ptr); - - // swap the BGR pixels in the DiData structure to RGB - - png_set_bgr(png_ptr); - - // row_bytes is the width x number of channels - - ulRowBytes = iWidth * ciChannels; - - // we can allocate memory for an array of row-pointers - - if ((ppbRowPointers = (png_bytepp) malloc(iHeight * sizeof(png_bytep))) == NULL) - Throw "Visualpng: Out of memory"; - - // set the individual row-pointers to point at the correct offsets - - for (i = 0; i < iHeight; i++) - ppbRowPointers[i] = pDiData + i * (((ulRowBytes + 3) >> 2) << 2); - - // write out the entire image data in one call - - png_write_image (png_ptr, ppbRowPointers); - - // write the additional chunks to the PNG file (not really needed) - - png_write_end(png_ptr, info_ptr); - - // and we're done - - free (ppbRowPointers); - ppbRowPointers = NULL; - - // clean up after the write, and free any memory allocated - - png_destroy_write_struct(&png_ptr, (png_infopp) NULL); - - // yepp, done - } - - Catch (msg) - { - png_destroy_write_struct(&png_ptr, (png_infopp) NULL); - - if(ppbRowPointers) - free (ppbRowPointers); - - fclose(pfFile); - - return FALSE; - } - - fclose (pfFile); - - return TRUE; -} - -#ifdef PNG_NO_STDIO - -static void -png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_size_t check; - - /* fread() returns 0 on error, so it is OK to store this in a png_size_t - * instead of an int, which is what fread() actually returns. - */ - check = (png_size_t)fread(data, (png_size_t)1, length, - (FILE *)png_ptr->io_ptr); - - if (check != length) - { - png_error(png_ptr, "Read Error"); - } -} - -static void -png_write_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_uint_32 check; - - check = fwrite(data, 1, length, (FILE *)(png_ptr->io_ptr)); - if (check != length) - { - png_error(png_ptr, "Write Error"); - } -} - -static void -png_flush(png_structp png_ptr) -{ - FILE *io_ptr; - io_ptr = (FILE *)CVT_PTR((png_ptr->io_ptr)); - if (io_ptr != NULL) - fflush(io_ptr); -} - -#endif - -//----------------- -// end of source -//----------------- diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/visupng/PngFile.h b/irrlicht-1.6/source/Irrlicht/libpng/contrib/visupng/PngFile.h deleted file mode 100644 index f46cd59e9..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/visupng/PngFile.h +++ /dev/null @@ -1,27 +0,0 @@ -//------------------------------------------ -// PNGFILE.H -- Header File for pngfile.c -//------------------------------------------ - -// Copyright 2000, Willem van Schaik. For conditions of distribution and -// use, see the copyright/license/disclaimer notice in png.h - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <windows.h> - -void PngFileInitialize (HWND hwnd) ; -BOOL PngFileOpenDlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName) ; -BOOL PngFileSaveDlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName) ; - -BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData, - int *piWidth, int *piHeight, int *piChannels, png_color *pBkgColor); -BOOL PngSaveImage (PTSTR pstrFileName, png_byte *pDiData, - int iWidth, int iHeight, png_color BkgColor); - -#if defined(PNG_NO_STDIO) -static void png_read_data(png_structp png_ptr, png_bytep data, png_size_t length); -static void png_write_data(png_structp png_ptr, png_bytep data, png_size_t length); -static void png_flush(png_structp png_ptr); -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/visupng/README.txt b/irrlicht-1.6/source/Irrlicht/libpng/contrib/visupng/README.txt deleted file mode 100644 index 71504738d..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/visupng/README.txt +++ /dev/null @@ -1,58 +0,0 @@ -Microsoft Developer Studio Build File, Format Version 6.00 for VisualPng ------------------------------------------------------------------------- - -Copyright 2000, Willem van Schaik. For conditions of distribution and -use, see the copyright/license/disclaimer notice in png.h - -As a PNG .dll demo VisualPng is finished. More features would only hinder -the program's objective. However, further extensions (like support for other -graphics formats) are in development. To get these, or for pre-compiled -binaries, go to "http://www.schaik.com/png/visualpng.html". - ------------------------------------------------------------------------- - -Assumes that - - libpng DLLs and LIBs are in ..\..\projects\msvc\win32\libpng - zlib DLLs and LIBs are in ..\..\projects\msvc\win32\zlib - libpng header files are in ..\..\..\libpng - zlib header files are in ..\..\..\zlib - the pngsuite images are in ..\pngsuite - -To build: - -1) On the main menu Select "Build|Set Active configuration". - Choose the configuration that corresponds to the library you want to test. - This library must have been built using the libpng MS project located in - the "..\..\mscv" subdirectory. - -2) Select "Build|Clean" - -3) Select "Build|Rebuild All" - -4) After compiling and linking VisualPng will be started to view an image - from the PngSuite directory. Press Ctrl-N (and Ctrl-V) for other images. - - -To install: - -When distributing VisualPng (or a further development) the following options -are available: - -1) Build the program with the configuration "Win32 LIB" and you only need to - include the executable from the ./lib directory in your distribution. - -2) Build the program with the configuration "Win32 DLL" and you need to put - in your distribution the executable from the ./dll directory and the dll's - libpng1.dll, zlib.dll and msvcrt.dll. These need to be in the user's PATH. - - -Willem van Schaik -Calgary, June 6th 2000 - -P.S. VisualPng was written based on preliminary work of: - - - Simon-Pierre Cadieux - - Glenn Randers-Pehrson - - Greg Roelofs - diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/visupng/VisualPng.c b/irrlicht-1.6/source/Irrlicht/libpng/contrib/visupng/VisualPng.c deleted file mode 100644 index df3e4cdab..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/visupng/VisualPng.c +++ /dev/null @@ -1,961 +0,0 @@ -//------------------------------------ -// VisualPng.C -- Shows a PNG image -//------------------------------------ - -// Copyright 2000, Willem van Schaik. For conditions of distribution and -// use, see the copyright/license/disclaimer notice in png.h - -// switches - -// defines - -#define PROGNAME "VisualPng" -#define LONGNAME "Win32 Viewer for PNG-files" -#define VERSION "1.0 of 2000 June 07" - -// constants - -#define MARGIN 8 - -// standard includes - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <windows.h> - -// application includes - -#include "png.h" -#include "pngfile.h" -#include "resource.h" - -// macros - -// function prototypes - -LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM); -BOOL CALLBACK AboutDlgProc (HWND, UINT, WPARAM, LPARAM) ; - -BOOL CenterAbout (HWND hwndChild, HWND hwndParent); - -BOOL BuildPngList (PTSTR pstrPathName, TCHAR **ppFileList, int *pFileCount, - int *pFileIndex); - -BOOL SearchPngList (TCHAR *pFileList, int FileCount, int *pFileIndex, - PTSTR pstrPrevName, PTSTR pstrNextName); - -BOOL LoadImageFile(HWND hwnd, PTSTR pstrPathName, - png_byte **ppbImage, int *pxImgSize, int *pyImgSize, int *piChannels, - png_color *pBkgColor); - -BOOL DisplayImage (HWND hwnd, BYTE **ppDib, - BYTE **ppDiData, int cxWinSize, int cyWinSize, - BYTE *pbImage, int cxImgSize, int cyImgSize, int cImgChannels, - BOOL bStretched); - -BOOL InitBitmap ( - BYTE *pDiData, int cxWinSize, int cyWinSize); - -BOOL FillBitmap ( - BYTE *pDiData, int cxWinSize, int cyWinSize, - BYTE *pbImage, int cxImgSize, int cyImgSize, int cImgChannels, - BOOL bStretched); - -// a few global variables - -static char *szProgName = PROGNAME; -static char *szAppName = LONGNAME; -static char *szIconName = PROGNAME; -static char szCmdFileName [MAX_PATH]; - -// MAIN routine - -int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, - PSTR szCmdLine, int iCmdShow) -{ - HACCEL hAccel; - HWND hwnd; - MSG msg; - WNDCLASS wndclass; - int ixBorders, iyBorders; - - wndclass.style = CS_HREDRAW | CS_VREDRAW; - wndclass.lpfnWndProc = WndProc; - wndclass.cbClsExtra = 0; - wndclass.cbWndExtra = 0; - wndclass.hInstance = hInstance; - wndclass.hIcon = LoadIcon (hInstance, szIconName) ; - wndclass.hCursor = LoadCursor (NULL, IDC_ARROW); - wndclass.hbrBackground = NULL; // (HBRUSH) GetStockObject (GRAY_BRUSH); - wndclass.lpszMenuName = szProgName; - wndclass.lpszClassName = szProgName; - - if (!RegisterClass (&wndclass)) - { - MessageBox (NULL, TEXT ("Error: this program requires Windows NT!"), - szProgName, MB_ICONERROR); - return 0; - } - - // if filename given on commandline, store it - if ((szCmdLine != NULL) && (*szCmdLine != '\0')) - if (szCmdLine[0] == '"') - strncpy (szCmdFileName, szCmdLine + 1, strlen(szCmdLine) - 2); - else - strcpy (szCmdFileName, szCmdLine); - else - strcpy (szCmdFileName, ""); - - // calculate size of window-borders - ixBorders = 2 * (GetSystemMetrics (SM_CXBORDER) + - GetSystemMetrics (SM_CXDLGFRAME)); - iyBorders = 2 * (GetSystemMetrics (SM_CYBORDER) + - GetSystemMetrics (SM_CYDLGFRAME)) + - GetSystemMetrics (SM_CYCAPTION) + - GetSystemMetrics (SM_CYMENUSIZE) + - 1; /* WvS: don't ask me why? */ - - hwnd = CreateWindow (szProgName, szAppName, - WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, CW_USEDEFAULT, - 512 + 2 * MARGIN + ixBorders, 384 + 2 * MARGIN + iyBorders, -// CW_USEDEFAULT, CW_USEDEFAULT, - NULL, NULL, hInstance, NULL); - - ShowWindow (hwnd, iCmdShow); - UpdateWindow (hwnd); - - hAccel = LoadAccelerators (hInstance, szProgName); - - while (GetMessage (&msg, NULL, 0, 0)) - { - if (!TranslateAccelerator (hwnd, hAccel, &msg)) - { - TranslateMessage (&msg); - DispatchMessage (&msg); - } - } - return msg.wParam; -} - -LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, - LPARAM lParam) -{ - static HINSTANCE hInstance ; - static HDC hdc; - static PAINTSTRUCT ps; - static HMENU hMenu; - - static BITMAPFILEHEADER *pbmfh; - static BITMAPINFOHEADER *pbmih; - static BYTE *pbImage; - static int cxWinSize, cyWinSize; - static int cxImgSize, cyImgSize; - static int cImgChannels; - static png_color bkgColor = {127, 127, 127}; - - static BOOL bStretched = TRUE; - - static BYTE *pDib = NULL; - static BYTE *pDiData = NULL; - - static TCHAR szImgPathName [MAX_PATH]; - static TCHAR szTitleName [MAX_PATH]; - - static TCHAR *pPngFileList = NULL; - static int iPngFileCount; - static int iPngFileIndex; - - BOOL bOk; - - switch (message) - { - case WM_CREATE: - hInstance = ((LPCREATESTRUCT) lParam)->hInstance ; - PngFileInitialize (hwnd); - - strcpy (szImgPathName, ""); - - // in case we process file given on command-line - - if (szCmdFileName[0] != '\0') - { - strcpy (szImgPathName, szCmdFileName); - - // read the other png-files in the directory for later - // next/previous commands - - BuildPngList (szImgPathName, &pPngFileList, &iPngFileCount, - &iPngFileIndex); - - // load the image from file - - if (!LoadImageFile (hwnd, szImgPathName, - &pbImage, &cxImgSize, &cyImgSize, &cImgChannels, &bkgColor)) - return 0; - - // invalidate the client area for later update - - InvalidateRect (hwnd, NULL, TRUE); - - // display the PNG into the DIBitmap - - DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize, - pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched); - } - - return 0; - - case WM_SIZE: - cxWinSize = LOWORD (lParam); - cyWinSize = HIWORD (lParam); - - // invalidate the client area for later update - - InvalidateRect (hwnd, NULL, TRUE); - - // display the PNG into the DIBitmap - - DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize, - pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched); - - return 0; - - case WM_INITMENUPOPUP: - hMenu = GetMenu (hwnd); - - if (pbImage) - EnableMenuItem (hMenu, IDM_FILE_SAVE, MF_ENABLED); - else - EnableMenuItem (hMenu, IDM_FILE_SAVE, MF_GRAYED); - - return 0; - - case WM_COMMAND: - hMenu = GetMenu (hwnd); - - switch (LOWORD (wParam)) - { - case IDM_FILE_OPEN: - - // show the File Open dialog box - - if (!PngFileOpenDlg (hwnd, szImgPathName, szTitleName)) - return 0; - - // read the other png-files in the directory for later - // next/previous commands - - BuildPngList (szImgPathName, &pPngFileList, &iPngFileCount, - &iPngFileIndex); - - // load the image from file - - if (!LoadImageFile (hwnd, szImgPathName, - &pbImage, &cxImgSize, &cyImgSize, &cImgChannels, &bkgColor)) - return 0; - - // invalidate the client area for later update - - InvalidateRect (hwnd, NULL, TRUE); - - // display the PNG into the DIBitmap - - DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize, - pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched); - - return 0; - - case IDM_FILE_SAVE: - - // show the File Save dialog box - - if (!PngFileSaveDlg (hwnd, szImgPathName, szTitleName)) - return 0; - - // save the PNG to a disk file - - SetCursor (LoadCursor (NULL, IDC_WAIT)); - ShowCursor (TRUE); - - bOk = PngSaveImage (szImgPathName, pDiData, cxWinSize, cyWinSize, - bkgColor); - - ShowCursor (FALSE); - SetCursor (LoadCursor (NULL, IDC_ARROW)); - - if (!bOk) - MessageBox (hwnd, TEXT ("Error in saving the PNG image"), - szProgName, MB_ICONEXCLAMATION | MB_OK); - return 0; - - case IDM_FILE_NEXT: - - // read next entry in the directory - - if (SearchPngList (pPngFileList, iPngFileCount, &iPngFileIndex, - NULL, szImgPathName)) - { - if (strcmp (szImgPathName, "") == 0) - return 0; - - // load the image from file - - if (!LoadImageFile (hwnd, szImgPathName, &pbImage, - &cxImgSize, &cyImgSize, &cImgChannels, &bkgColor)) - return 0; - - // invalidate the client area for later update - - InvalidateRect (hwnd, NULL, TRUE); - - // display the PNG into the DIBitmap - - DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize, - pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched); - } - - return 0; - - case IDM_FILE_PREVIOUS: - - // read previous entry in the directory - - if (SearchPngList (pPngFileList, iPngFileCount, &iPngFileIndex, - szImgPathName, NULL)) - { - - if (strcmp (szImgPathName, "") == 0) - return 0; - - // load the image from file - - if (!LoadImageFile (hwnd, szImgPathName, &pbImage, &cxImgSize, - &cyImgSize, &cImgChannels, &bkgColor)) - return 0; - - // invalidate the client area for later update - - InvalidateRect (hwnd, NULL, TRUE); - - // display the PNG into the DIBitmap - - DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize, - pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched); - } - - return 0; - - case IDM_FILE_EXIT: - - // more cleanup needed... - - // free image buffer - - if (pDib != NULL) - { - free (pDib); - pDib = NULL; - } - - // free file-list - - if (pPngFileList != NULL) - { - free (pPngFileList); - pPngFileList = NULL; - } - - // let's go ... - - exit (0); - - return 0; - - case IDM_OPTIONS_STRETCH: - bStretched = !bStretched; - if (bStretched) - CheckMenuItem (hMenu, IDM_OPTIONS_STRETCH, MF_CHECKED); - else - CheckMenuItem (hMenu, IDM_OPTIONS_STRETCH, MF_UNCHECKED); - - // invalidate the client area for later update - - InvalidateRect (hwnd, NULL, TRUE); - - // display the PNG into the DIBitmap - - DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize, - pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched); - - return 0; - - case IDM_HELP_ABOUT: - DialogBox (hInstance, TEXT ("AboutBox"), hwnd, AboutDlgProc) ; - return 0; - - } // end switch - - break; - - case WM_PAINT: - hdc = BeginPaint (hwnd, &ps); - - if (pDib) - SetDIBitsToDevice (hdc, 0, 0, cxWinSize, cyWinSize, 0, 0, - 0, cyWinSize, pDiData, (BITMAPINFO *) pDib, DIB_RGB_COLORS); - - EndPaint (hwnd, &ps); - return 0; - - case WM_DESTROY: - if (pbmfh) - { - free (pbmfh); - pbmfh = NULL; - } - - PostQuitMessage (0); - return 0; - } - - return DefWindowProc (hwnd, message, wParam, lParam); -} - -BOOL CALLBACK AboutDlgProc (HWND hDlg, UINT message, - WPARAM wParam, LPARAM lParam) -{ - switch (message) - { - case WM_INITDIALOG : - ShowWindow (hDlg, SW_HIDE); - CenterAbout (hDlg, GetWindow (hDlg, GW_OWNER)); - ShowWindow (hDlg, SW_SHOW); - return TRUE ; - - case WM_COMMAND : - switch (LOWORD (wParam)) - { - case IDOK : - case IDCANCEL : - EndDialog (hDlg, 0) ; - return TRUE ; - } - break ; - } - return FALSE ; -} - -//--------------- -// CenterAbout -//--------------- - -BOOL CenterAbout (HWND hwndChild, HWND hwndParent) -{ - RECT rChild, rParent, rWorkArea; - int wChild, hChild, wParent, hParent; - int xNew, yNew; - BOOL bResult; - - // Get the Height and Width of the child window - GetWindowRect (hwndChild, &rChild); - wChild = rChild.right - rChild.left; - hChild = rChild.bottom - rChild.top; - - // Get the Height and Width of the parent window - GetWindowRect (hwndParent, &rParent); - wParent = rParent.right - rParent.left; - hParent = rParent.bottom - rParent.top; - - // Get the limits of the 'workarea' - bResult = SystemParametersInfo( - SPI_GETWORKAREA, // system parameter to query or set - sizeof(RECT), - &rWorkArea, - 0); - if (!bResult) { - rWorkArea.left = rWorkArea.top = 0; - rWorkArea.right = GetSystemMetrics(SM_CXSCREEN); - rWorkArea.bottom = GetSystemMetrics(SM_CYSCREEN); - } - - // Calculate new X position, then adjust for workarea - xNew = rParent.left + ((wParent - wChild) /2); - if (xNew < rWorkArea.left) { - xNew = rWorkArea.left; - } else if ((xNew+wChild) > rWorkArea.right) { - xNew = rWorkArea.right - wChild; - } - - // Calculate new Y position, then adjust for workarea - yNew = rParent.top + ((hParent - hChild) /2); - if (yNew < rWorkArea.top) { - yNew = rWorkArea.top; - } else if ((yNew+hChild) > rWorkArea.bottom) { - yNew = rWorkArea.bottom - hChild; - } - - // Set it, and return - return SetWindowPos (hwndChild, NULL, xNew, yNew, 0, 0, SWP_NOSIZE | - SWP_NOZORDER); -} - -//---------------- -// BuildPngList -//---------------- - -BOOL BuildPngList (PTSTR pstrPathName, TCHAR **ppFileList, int *pFileCount, - int *pFileIndex) -{ - static TCHAR szImgPathName [MAX_PATH]; - static TCHAR szImgFileName [MAX_PATH]; - static TCHAR szImgFindName [MAX_PATH]; - - WIN32_FIND_DATA finddata; - HANDLE hFind; - - static TCHAR szTmp [MAX_PATH]; - BOOL bOk; - int i, ii; - int j, jj; - - // free previous file-list - - if (*ppFileList != NULL) - { - free (*ppFileList); - *ppFileList = NULL; - } - - // extract foldername, filename and search-name - - strcpy (szImgPathName, pstrPathName); - strcpy (szImgFileName, strrchr (pstrPathName, '\\') + 1); - - strcpy (szImgFindName, szImgPathName); - *(strrchr (szImgFindName, '\\') + 1) = '\0'; - strcat (szImgFindName, "*.png"); - - // first cycle: count number of files in directory for memory allocation - - *pFileCount = 0; - - hFind = FindFirstFile(szImgFindName, &finddata); - bOk = (hFind != (HANDLE) -1); - - while (bOk) - { - *pFileCount += 1; - bOk = FindNextFile(hFind, &finddata); - } - FindClose(hFind); - - // allocation memory for file-list - - *ppFileList = (TCHAR *) malloc (*pFileCount * MAX_PATH); - - // second cycle: read directory and store filenames in file-list - - hFind = FindFirstFile(szImgFindName, &finddata); - bOk = (hFind != (HANDLE) -1); - - i = 0; - ii = 0; - while (bOk) - { - strcpy (*ppFileList + ii, szImgPathName); - strcpy (strrchr(*ppFileList + ii, '\\') + 1, finddata.cFileName); - - if (strcmp(pstrPathName, *ppFileList + ii) == 0) - *pFileIndex = i; - - ii += MAX_PATH; - i++; - - bOk = FindNextFile(hFind, &finddata); - } - FindClose(hFind); - - // finally we must sort the file-list - - for (i = 0; i < *pFileCount - 1; i++) - { - ii = i * MAX_PATH; - for (j = i+1; j < *pFileCount; j++) - { - jj = j * MAX_PATH; - if (strcmp (*ppFileList + ii, *ppFileList + jj) > 0) - { - strcpy (szTmp, *ppFileList + jj); - strcpy (*ppFileList + jj, *ppFileList + ii); - strcpy (*ppFileList + ii, szTmp); - - // check if this was the current image that we moved - - if (*pFileIndex == i) - *pFileIndex = j; - else - if (*pFileIndex == j) - *pFileIndex = i; - } - } - } - - return TRUE; -} - -//---------------- -// SearchPngList -//---------------- - -BOOL SearchPngList ( - TCHAR *pFileList, int FileCount, int *pFileIndex, - PTSTR pstrPrevName, PTSTR pstrNextName) -{ - if (FileCount > 0) - { - // get previous entry - - if (pstrPrevName != NULL) - { - if (*pFileIndex > 0) - *pFileIndex -= 1; - else - *pFileIndex = FileCount - 1; - - strcpy (pstrPrevName, pFileList + (*pFileIndex * MAX_PATH)); - } - - // get next entry - - if (pstrNextName != NULL) - { - if (*pFileIndex < FileCount - 1) - *pFileIndex += 1; - else - *pFileIndex = 0; - - strcpy (pstrNextName, pFileList + (*pFileIndex * MAX_PATH)); - } - - return TRUE; - } - else - { - return FALSE; - } -} - -//----------------- -// LoadImageFile -//----------------- - -BOOL LoadImageFile (HWND hwnd, PTSTR pstrPathName, - png_byte **ppbImage, int *pxImgSize, int *pyImgSize, - int *piChannels, png_color *pBkgColor) -{ - static TCHAR szTmp [MAX_PATH]; - - // if there's an existing PNG, free the memory - - if (*ppbImage) - { - free (*ppbImage); - *ppbImage = NULL; - } - - // Load the entire PNG into memory - - SetCursor (LoadCursor (NULL, IDC_WAIT)); - ShowCursor (TRUE); - - PngLoadImage (pstrPathName, ppbImage, pxImgSize, pyImgSize, piChannels, - pBkgColor); - - ShowCursor (FALSE); - SetCursor (LoadCursor (NULL, IDC_ARROW)); - - if (*ppbImage != NULL) - { - sprintf (szTmp, "VisualPng - %s", strrchr(pstrPathName, '\\') + 1); - SetWindowText (hwnd, szTmp); - } - else - { - MessageBox (hwnd, TEXT ("Error in loading the PNG image"), - szProgName, MB_ICONEXCLAMATION | MB_OK); - return FALSE; - } - - return TRUE; -} - -//---------------- -// DisplayImage -//---------------- - -BOOL DisplayImage (HWND hwnd, BYTE **ppDib, - BYTE **ppDiData, int cxWinSize, int cyWinSize, - BYTE *pbImage, int cxImgSize, int cyImgSize, int cImgChannels, - BOOL bStretched) -{ - BYTE *pDib = *ppDib; - BYTE *pDiData = *ppDiData; - // BITMAPFILEHEADER *pbmfh; - BITMAPINFOHEADER *pbmih; - WORD wDIRowBytes; - png_color bkgBlack = {0, 0, 0}; - png_color bkgGray = {127, 127, 127}; - png_color bkgWhite = {255, 255, 255}; - - // allocate memory for the Device Independant bitmap - - wDIRowBytes = (WORD) ((3 * cxWinSize + 3L) >> 2) << 2; - - if (pDib) - { - free (pDib); - pDib = NULL; - } - - if (!(pDib = (BYTE *) malloc (sizeof(BITMAPINFOHEADER) + - wDIRowBytes * cyWinSize))) - { - MessageBox (hwnd, TEXT ("Error in displaying the PNG image"), - szProgName, MB_ICONEXCLAMATION | MB_OK); - *ppDib = pDib = NULL; - return FALSE; - } - *ppDib = pDib; - memset (pDib, 0, sizeof(BITMAPINFOHEADER)); - - // initialize the dib-structure - - pbmih = (BITMAPINFOHEADER *) pDib; - pbmih->biSize = sizeof(BITMAPINFOHEADER); - pbmih->biWidth = cxWinSize; - pbmih->biHeight = -((long) cyWinSize); - pbmih->biPlanes = 1; - pbmih->biBitCount = 24; - pbmih->biCompression = 0; - pDiData = pDib + sizeof(BITMAPINFOHEADER); - *ppDiData = pDiData; - - // first fill bitmap with gray and image border - - InitBitmap (pDiData, cxWinSize, cyWinSize); - - // then fill bitmap with image - - if (pbImage) - { - FillBitmap ( - pDiData, cxWinSize, cyWinSize, - pbImage, cxImgSize, cyImgSize, cImgChannels, - bStretched); - } - - return TRUE; -} - -//-------------- -// InitBitmap -//-------------- - -BOOL InitBitmap (BYTE *pDiData, int cxWinSize, int cyWinSize) -{ - BYTE *dst; - int x, y, col; - - // initialize the background with gray - - dst = pDiData; - for (y = 0; y < cyWinSize; y++) - { - col = 0; - for (x = 0; x < cxWinSize; x++) - { - // fill with GRAY - *dst++ = 127; - *dst++ = 127; - *dst++ = 127; - col += 3; - } - // rows start on 4 byte boundaries - while ((col % 4) != 0) - { - dst++; - col++; - } - } - - return TRUE; -} - -//-------------- -// FillBitmap -//-------------- - -BOOL FillBitmap ( - BYTE *pDiData, int cxWinSize, int cyWinSize, - BYTE *pbImage, int cxImgSize, int cyImgSize, int cImgChannels, - BOOL bStretched) -{ - BYTE *pStretchedImage; - BYTE *pImg; - BYTE *src, *dst; - BYTE r, g, b, a; - const int cDIChannels = 3; - WORD wImgRowBytes; - WORD wDIRowBytes; - int cxNewSize, cyNewSize; - int cxImgPos, cyImgPos; - int xImg, yImg; - int xWin, yWin; - int xOld, yOld; - int xNew, yNew; - - if (bStretched) - { - cxNewSize = cxWinSize - 2 * MARGIN; - cyNewSize = cyWinSize - 2 * MARGIN; - - // stretch the image to it's window determined size - - // the following two are the same, but the first has side-effects - // because of rounding -// if ((cyNewSize / cxNewSize) > (cyImgSize / cxImgSize)) - if ((cyNewSize * cxImgSize) > (cyImgSize * cxNewSize)) - { - cyNewSize = cxNewSize * cyImgSize / cxImgSize; - cxImgPos = MARGIN; - cyImgPos = (cyWinSize - cyNewSize) / 2; - } - else - { - cxNewSize = cyNewSize * cxImgSize / cyImgSize; - cyImgPos = MARGIN; - cxImgPos = (cxWinSize - cxNewSize) / 2; - } - - pStretchedImage = malloc (cImgChannels * cxNewSize * cyNewSize); - pImg = pStretchedImage; - - for (yNew = 0; yNew < cyNewSize; yNew++) - { - yOld = yNew * cyImgSize / cyNewSize; - for (xNew = 0; xNew < cxNewSize; xNew++) - { - xOld = xNew * cxImgSize / cxNewSize; - - r = *(pbImage + cImgChannels * ((yOld * cxImgSize) + xOld) + 0); - g = *(pbImage + cImgChannels * ((yOld * cxImgSize) + xOld) + 1); - b = *(pbImage + cImgChannels * ((yOld * cxImgSize) + xOld) + 2); - *pImg++ = r; - *pImg++ = g; - *pImg++ = b; - if (cImgChannels == 4) - { - a = *(pbImage + cImgChannels * ((yOld * cxImgSize) + xOld) - + 3); - *pImg++ = a; - } - } - } - - // calculate row-bytes - - wImgRowBytes = cImgChannels * cxNewSize; - wDIRowBytes = (WORD) ((cDIChannels * cxWinSize + 3L) >> 2) << 2; - - // copy image to screen - - for (yImg = 0, yWin = cyImgPos; yImg < cyNewSize; yImg++, yWin++) - { - if (yWin >= cyWinSize - cyImgPos) - break; - src = pStretchedImage + yImg * wImgRowBytes; - dst = pDiData + yWin * wDIRowBytes + cxImgPos * cDIChannels; - - for (xImg = 0, xWin = cxImgPos; xImg < cxNewSize; xImg++, xWin++) - { - if (xWin >= cxWinSize - cxImgPos) - break; - r = *src++; - g = *src++; - b = *src++; - *dst++ = b; /* note the reverse order */ - *dst++ = g; - *dst++ = r; - if (cImgChannels == 4) - { - a = *src++; - } - } - } - - // free memory - - if (pStretchedImage != NULL) - { - free (pStretchedImage); - pStretchedImage = NULL; - } - - } - - // process the image not-stretched - - else - { - // calculate the central position - - cxImgPos = (cxWinSize - cxImgSize) / 2; - cyImgPos = (cyWinSize - cyImgSize) / 2; - - // check for image larger than window - - if (cxImgPos < MARGIN) - cxImgPos = MARGIN; - if (cyImgPos < MARGIN) - cyImgPos = MARGIN; - - // calculate both row-bytes - - wImgRowBytes = cImgChannels * cxImgSize; - wDIRowBytes = (WORD) ((cDIChannels * cxWinSize + 3L) >> 2) << 2; - - // copy image to screen - - for (yImg = 0, yWin = cyImgPos; yImg < cyImgSize; yImg++, yWin++) - { - if (yWin >= cyWinSize - MARGIN) - break; - src = pbImage + yImg * wImgRowBytes; - dst = pDiData + yWin * wDIRowBytes + cxImgPos * cDIChannels; - - for (xImg = 0, xWin = cxImgPos; xImg < cxImgSize; xImg++, xWin++) - { - if (xWin >= cxWinSize - MARGIN) - break; - r = *src++; - g = *src++; - b = *src++; - *dst++ = b; /* note the reverse order */ - *dst++ = g; - *dst++ = r; - if (cImgChannels == 4) - { - a = *src++; - } - } - } - } - - return TRUE; -} - -//----------------- -// end of source -//----------------- diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/visupng/VisualPng.dsp b/irrlicht-1.6/source/Irrlicht/libpng/contrib/visupng/VisualPng.dsp deleted file mode 100644 index 53ef5a2bc..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/visupng/VisualPng.dsp +++ /dev/null @@ -1,147 +0,0 @@ -# Microsoft Developer Studio Project File - Name="VisualPng" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Application" 0x0101 - -CFG=VisualPng - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "VisualPng.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "VisualPng.mak" CFG="VisualPng - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "VisualPng - Win32 Release" (based on "Win32 (x86) Application") -!MESSAGE "VisualPng - Win32 Debug" (based on "Win32 (x86) Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "VisualPng - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Ignore_Export_Lib 0 -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /c -# SUBTRACT BASE CPP /YX -# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /c -# SUBTRACT CPP /YX -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 -# ADD LINK32 ..\..\projects\visualc6\Win32_LIB_Release\libpng.lib ..\..\..\zlib\projects\visualc6\Win32_LIB_Release\zlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 -# Begin Special Build Tool -OutDir=.\Release -SOURCE="$(InputPath)" -PostBuild_Cmds=$(outdir)\VisualPng.exe ..\..\contrib\pngsuite\basn6a16.png -# End Special Build Tool - -!ELSEIF "$(CFG)" == "VisualPng - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Ignore_Export_Lib 0 -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /GZ /c -# SUBTRACT BASE CPP /YX -# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept -# ADD LINK32 ..\..\projects\visualc6\Win32_LIB_Release\libpng.lib ..\..\..\zlib\projects\visualc6\Win32_LIB_Release\zlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"msvcrt.lib" /pdbtype:sept -# Begin Special Build Tool -OutDir=.\Debug -SOURCE="$(InputPath)" -PostBuild_Cmds=$(outdir)\VisualPng.exe ..\..\contrib\pngsuite\basn6a16.png -# End Special Build Tool - -!ENDIF - -# Begin Target - -# Name "VisualPng - Win32 Release" -# Name "VisualPng - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\PngFile.c -# End Source File -# Begin Source File - -SOURCE=.\VisualPng.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=.\cexcept.h -# End Source File -# Begin Source File - -SOURCE=.\PngFile.h -# End Source File -# Begin Source File - -SOURCE=.\resource.h -# End Source File -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" -# Begin Source File - -SOURCE=.\VisualPng.ico -# End Source File -# Begin Source File - -SOURCE=.\VisualPng.rc -# End Source File -# End Group -# End Target -# End Project diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/visupng/VisualPng.dsw b/irrlicht-1.6/source/Irrlicht/libpng/contrib/visupng/VisualPng.dsw deleted file mode 100644 index a30e1cc1c..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/visupng/VisualPng.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "VisualPng"=.\VisualPng.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/visupng/VisualPng.ico b/irrlicht-1.6/source/Irrlicht/libpng/contrib/visupng/VisualPng.ico deleted file mode 100644 index 68aa3719f..000000000 Binary files a/irrlicht-1.6/source/Irrlicht/libpng/contrib/visupng/VisualPng.ico and /dev/null differ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/visupng/VisualPng.png b/irrlicht-1.6/source/Irrlicht/libpng/contrib/visupng/VisualPng.png deleted file mode 100644 index c6aa80a9b..000000000 Binary files a/irrlicht-1.6/source/Irrlicht/libpng/contrib/visupng/VisualPng.png and /dev/null differ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/visupng/VisualPng.rc b/irrlicht-1.6/source/Irrlicht/libpng/contrib/visupng/VisualPng.rc deleted file mode 100644 index 6e0623a73..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/visupng/VisualPng.rc +++ /dev/null @@ -1,152 +0,0 @@ -//Microsoft Developer Studio generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE DISCARDABLE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE DISCARDABLE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE DISCARDABLE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -VISUALPNG MENU DISCARDABLE -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&Open Image...\tCtrl+O", IDM_FILE_OPEN - MENUITEM "Save &As...", IDM_FILE_SAVE - MENUITEM SEPARATOR - MENUITEM "&Next Image\tCtrl+N", IDM_FILE_NEXT - MENUITEM "Pre&vious Image\tCtrl+V", IDM_FILE_PREVIOUS - MENUITEM SEPARATOR - MENUITEM "E&xit\tAlt+X", IDM_FILE_EXIT - END - POPUP "&Options" - BEGIN - MENUITEM "&Stretch", IDM_OPTIONS_STRETCH, CHECKED - END - POPUP "&Help" - BEGIN - MENUITEM "&About", IDM_HELP_ABOUT - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Accelerator -// - -VISUALPNG ACCELERATORS DISCARDABLE -BEGIN - "N", IDM_FILE_NEXT, VIRTKEY, CONTROL, NOINVERT - "O", IDM_FILE_OPEN, VIRTKEY, CONTROL, NOINVERT - "P", IDM_FILE_PREVIOUS, VIRTKEY, CONTROL, NOINVERT - "V", IDM_FILE_PREVIOUS, VIRTKEY, CONTROL, NOINVERT - "X", IDM_FILE_EXIT, VIRTKEY, ALT, NOINVERT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -VISUALPNG ICON DISCARDABLE "VisualPng.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -ABOUTBOX DIALOG DISCARDABLE 0, 0, 186, 94 -STYLE DS_MODALFRAME | WS_POPUP -FONT 8, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "OK",IDOK,68,67,50,14 - CTEXT "VisualPng 1.0 - June 2000",IDC_STATIC,49,14,88,8 - LTEXT "a PNG image viewer",IDC_STATIC,60,30,66,8 - LTEXT "(c) Willem van Schaik, 2000",IDC_STATIC,48,52,90,8 - LTEXT "to demonstrate the use of libpng in Visual C", - IDC_STATIC,25,38,136,8 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO DISCARDABLE -BEGIN - "ABOUTBOX", DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 179 - TOPMARGIN, 7 - BOTTOMMARGIN, 87 - END -END -#endif // APSTUDIO_INVOKED - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/visupng/cexcept.h b/irrlicht-1.6/source/Irrlicht/libpng/contrib/visupng/cexcept.h deleted file mode 100644 index a1a4f8328..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/visupng/cexcept.h +++ /dev/null @@ -1,243 +0,0 @@ -/*=== -cexcept.h 2.0.0 (2001-Jul-12-Thu) -Adam M. Costello <amc@cs.berkeley.edu> - -An interface for exception-handling in ANSI C (C89 and subsequent ISO -standards), developed jointly with Cosmin Truta <cosmin@cs.toronto.edu>. - - Copyright (c) 2001 Adam M. Costello and Cosmin Truta. Everyone - is hereby granted permission to do whatever they like with this - file, provided that if they modify it they take reasonable steps to - avoid confusing or misleading people about the authors, version, - and terms of use of the derived file. The copyright holders make - no guarantees regarding this file, and are not responsible for any - damage resulting from its use. - -Only user-defined exceptions are supported, not "real" exceptions like -division by zero or memory segmentation violations. - -If this interface is used by multiple .c files, they shouldn't include -this header file directly. Instead, create a wrapper header file that -includes this header file and then invokes the define_exception_type -macro (see below), and let your .c files include that header file. - -The interface consists of one type, one well-known name, and six macros. - - -define_exception_type(type_name); - - This macro is used like an external declaration. It specifies - the type of object that gets copied from the exception thrower to - the exception catcher. The type_name can be any type that can be - assigned to, that is, a non-constant arithmetic type, struct, union, - or pointer. Examples: - - define_exception_type(int); - - enum exception { out_of_memory, bad_arguments, disk_full }; - define_exception_type(enum exception); - - struct exception { int code; const char *msg; }; - define_exception_type(struct exception); - - Because throwing an exception causes the object to be copied (not - just once, but twice), programmers may wish to consider size when - choosing the exception type. - - -struct exception_context; - - This type may be used after the define_exception_type() macro has - been invoked. A struct exception_context must be known to both - the thrower and the catcher. It is expected that there be one - context for each thread that uses exceptions. It would certainly - be dangerous for multiple threads to access the same context. - One thread can use multiple contexts, but that is likely to be - confusing and not typically useful. The application can allocate - this structure in any way it pleases--automatic, static, or dynamic. - The application programmer should pretend not to know the structure - members, which are subject to change. - - -struct exception_context *the_exception_context; - - The Try/Catch and Throw statements (described below) implicitly - refer to a context, using the name the_exception_context. It is - the application's responsibility to make sure that this name yields - the address of a mutable (non-constant) struct exception_context - wherever those statements are used. Subject to that constraint, the - application may declare a variable of this name anywhere it likes - (inside a function, in a parameter list, or externally), and may - use whatever storage class specifiers (static, extern, etc) or type - qualifiers (const, volatile, etc) it likes. Examples: - - static struct exception_context - * const the_exception_context = &foo; - - { struct exception_context *the_exception_context = bar; ... } - - int blah(struct exception_context *the_exception_context, ...); - - extern struct exception_context the_exception_context[1]; - - The last example illustrates a trick that avoids creating a pointer - object separate from the structure object. - - The name could even be a macro, for example: - - struct exception_context ec_array[numthreads]; - #define the_exception_context (ec_array + thread_id) - - Be aware that the_exception_context is used several times by the - Try/Catch/Throw macros, so it shouldn't be expensive or have side - effects. The expansion must be a drop-in replacement for an - identifier, so it's safest to put parentheses around it. - - -void init_exception_context(struct exception_context *ec); - - For context structures allocated statically (by an external - definition or using the "static" keyword), the implicit - initialization to all zeros is sufficient, but contexts allocated - by other means must be initialized using this macro before they - are used by a Try/Catch statement. It does no harm to initialize - a context more than once (by using this macro on a statically - allocated context, or using this macro twice on the same context), - but a context must not be re-initialized after it has been used by a - Try/Catch statement. - - -Try statement -Catch (expression) statement - - The Try/Catch/Throw macros are capitalized in order to avoid - confusion with the C++ keywords, which have subtly different - semantics. - - A Try/Catch statement has a syntax similar to an if/else statement, - except that the parenthesized expression goes after the second - keyword rather than the first. As with if/else, there are two - clauses, each of which may be a simple statement ending with a - semicolon or a brace-enclosed compound statement. But whereas - the else clause is optional, the Catch clause is required. The - expression must be a modifiable lvalue (something capable of being - assigned to) of the same type (disregarding type qualifiers) that - was passed to define_exception_type(). - - If a Throw that uses the same exception context as the Try/Catch is - executed within the Try clause (typically within a function called - by the Try clause), and the exception is not caught by a nested - Try/Catch statement, then a copy of the exception will be assigned - to the expression, and control will jump to the Catch clause. If no - such Throw is executed, then the assignment is not performed, and - the Catch clause is not executed. - - The expression is not evaluated unless and until the exception is - caught, which is significant if it has side effects, for example: - - Try foo(); - Catch (p[++i].e) { ... } - - IMPORTANT: Jumping into or out of a Try clause (for example via - return, break, continue, goto, longjmp) is forbidden--the compiler - will not complain, but bad things will happen at run-time. Jumping - into or out of a Catch clause is okay, and so is jumping around - inside a Try clause. In many cases where one is tempted to return - from a Try clause, it will suffice to use Throw, and then return - from the Catch clause. Another option is to set a flag variable and - use goto to jump to the end of the Try clause, then check the flag - after the Try/Catch statement. - - IMPORTANT: The values of any non-volatile automatic variables - changed within the Try clause are undefined after an exception is - caught. Therefore, variables modified inside the Try block whose - values are needed later outside the Try block must either use static - storage or be declared with the "volatile" type qualifier. - - -Throw expression; - - A Throw statement is very much like a return statement, except that - the expression is required. Whereas return jumps back to the place - where the current function was called, Throw jumps back to the Catch - clause of the innermost enclosing Try clause. The expression must - be compatible with the type passed to define_exception_type(). The - exception must be caught, otherwise the program may crash. - - Slight limitation: If the expression is a comma-expression it must - be enclosed in parentheses. - - -Try statement -Catch_anonymous statement - - When the value of the exception is not needed, a Try/Catch statement - can use Catch_anonymous instead of Catch (expression). - - -Everything below this point is for the benefit of the compiler. The -application programmer should pretend not to know any of it, because it -is subject to change. - -===*/ - - -#ifndef CEXCEPT_H -#define CEXCEPT_H - - -#include <setjmp.h> - -#define define_exception_type(etype) \ -struct exception_context { \ - jmp_buf *penv; \ - int caught; \ - volatile struct { etype etmp; } v; \ -} - -/* etmp must be volatile because the application might use automatic */ -/* storage for the_exception_context, and etmp is modified between */ -/* the calls to setjmp() and longjmp(). A wrapper struct is used to */ -/* avoid warnings about a duplicate volatile qualifier in case etype */ -/* already includes it. */ - -#define init_exception_context(ec) ((void)((ec)->penv = 0)) - -#define Try \ - { \ - jmp_buf *exception__prev, exception__env; \ - exception__prev = the_exception_context->penv; \ - the_exception_context->penv = &exception__env; \ - if (setjmp(exception__env) == 0) { \ - if (&exception__prev) - -#define exception__catch(action) \ - else { } \ - the_exception_context->caught = 0; \ - } \ - else { \ - the_exception_context->caught = 1; \ - } \ - the_exception_context->penv = exception__prev; \ - } \ - if (!the_exception_context->caught || action) { } \ - else - -#define Catch(e) exception__catch(((e) = the_exception_context->v.etmp, 0)) -#define Catch_anonymous exception__catch(0) - -/* Try ends with if(), and Catch begins and ends with else. This */ -/* ensures that the Try/Catch syntax is really the same as the */ -/* if/else syntax. */ -/* */ -/* We use &exception__prev instead of 1 to appease compilers that */ -/* warn about constant expressions inside if(). Most compilers */ -/* should still recognize that &exception__prev is never zero and */ -/* avoid generating test code. */ - -#define Throw \ - for (;; longjmp(*the_exception_context->penv, 1)) \ - the_exception_context->v.etmp = - - -#endif /* CEXCEPT_H */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/contrib/visupng/resource.h b/irrlicht-1.6/source/Irrlicht/libpng/contrib/visupng/resource.h deleted file mode 100644 index e222d3522..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/contrib/visupng/resource.h +++ /dev/null @@ -1,23 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by VisualPng.rc -// -#define IDM_FILE_OPEN 40001 -#define IDM_FILE_SAVE 40002 -#define IDM_FILE_NEXT 40003 -#define IDM_FILE_PREVIOUS 40004 -#define IDM_FILE_EXIT 40005 -#define IDM_OPTIONS_BACKGROUND 40006 -#define IDM_OPTIONS_STRETCH 40007 -#define IDM_HELP_ABOUT 40008 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 113 -#define _APS_NEXT_COMMAND_VALUE 40009 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/irrlicht-1.6/source/Irrlicht/libpng/example.c b/irrlicht-1.6/source/Irrlicht/libpng/example.c deleted file mode 100644 index 2db293a30..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/example.c +++ /dev/null @@ -1,814 +0,0 @@ - -#if 0 /* in case someone actually tries to compile this */ - -/* example.c - an example of using libpng - * Last changed in libpng 1.2.1 December 7, 2001. - * This file has been placed in the public domain by the authors. - * Maintained 1998-2007 Glenn Randers-Pehrson - * Maintained 1996, 1997 Andreas Dilger) - * Written 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -/* This is an example of how to use libpng to read and write PNG files. - * The file libpng.txt is much more verbose then this. If you have not - * read it, do so first. This was designed to be a starting point of an - * implementation. This is not officially part of libpng, is hereby placed - * in the public domain, and therefore does not require a copyright notice. - * - * This file does not currently compile, because it is missing certain - * parts, like allocating memory to hold an image. You will have to - * supply these parts to get it to compile. For an example of a minimal - * working PNG reader/writer, see pngtest.c, included in this distribution; - * see also the programs in the contrib directory. - */ - -#include "png.h" - - /* The png_jmpbuf() macro, used in error handling, became available in - * libpng version 1.0.6. If you want to be able to run your code with older - * versions of libpng, you must define the macro yourself (but only if it - * is not already defined by libpng!). - */ - -#ifndef png_jmpbuf -# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) -#endif - -/* Check to see if a file is a PNG file using png_sig_cmp(). png_sig_cmp() - * returns zero if the image is a PNG and nonzero if it isn't a PNG. - * - * The function check_if_png() shown here, but not used, returns nonzero (true) - * if the file can be opened and is a PNG, 0 (false) otherwise. - * - * If this call is successful, and you are going to keep the file open, - * you should call png_set_sig_bytes(png_ptr, PNG_BYTES_TO_CHECK); once - * you have created the png_ptr, so that libpng knows your application - * has read that many bytes from the start of the file. Make sure you - * don't call png_set_sig_bytes() with more than 8 bytes read or give it - * an incorrect number of bytes read, or you will either have read too - * many bytes (your fault), or you are telling libpng to read the wrong - * number of magic bytes (also your fault). - * - * Many applications already read the first 2 or 4 bytes from the start - * of the image to determine the file type, so it would be easiest just - * to pass the bytes to png_sig_cmp() or even skip that if you know - * you have a PNG file, and call png_set_sig_bytes(). - */ -#define PNG_BYTES_TO_CHECK 4 -int check_if_png(char *file_name, FILE **fp) -{ - char buf[PNG_BYTES_TO_CHECK]; - - /* Open the prospective PNG file. */ - if ((*fp = fopen(file_name, "rb")) == NULL) - return 0; - - /* Read in some of the signature bytes */ - if (fread(buf, 1, PNG_BYTES_TO_CHECK, *fp) != PNG_BYTES_TO_CHECK) - return 0; - - /* Compare the first PNG_BYTES_TO_CHECK bytes of the signature. - Return nonzero (true) if they match */ - - return(!png_sig_cmp(buf, (png_size_t)0, PNG_BYTES_TO_CHECK)); -} - -/* Read a PNG file. You may want to return an error code if the read - * fails (depending upon the failure). There are two "prototypes" given - * here - one where we are given the filename, and we need to open the - * file, and the other where we are given an open file (possibly with - * some or all of the magic bytes read - see comments above). - */ -#ifdef open_file /* prototype 1 */ -void read_png(char *file_name) /* We need to open the file */ -{ - png_structp png_ptr; - png_infop info_ptr; - unsigned int sig_read = 0; - png_uint_32 width, height; - int bit_depth, color_type, interlace_type; - FILE *fp; - - if ((fp = fopen(file_name, "rb")) == NULL) - return (ERROR); -#else no_open_file /* prototype 2 */ -void read_png(FILE *fp, unsigned int sig_read) /* file is already open */ -{ - png_structp png_ptr; - png_infop info_ptr; - png_uint_32 width, height; - int bit_depth, color_type, interlace_type; -#endif no_open_file /* only use one prototype! */ - - /* Create and initialize the png_struct with the desired error handler - * functions. If you want to use the default stderr and longjump method, - * you can supply NULL for the last three parameters. We also supply the - * the compiler header file version, so that we know if the application - * was compiled with a compatible version of the library. REQUIRED - */ - png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, - png_voidp user_error_ptr, user_error_fn, user_warning_fn); - - if (png_ptr == NULL) - { - fclose(fp); - return (ERROR); - } - - /* Allocate/initialize the memory for image information. REQUIRED. */ - info_ptr = png_create_info_struct(png_ptr); - if (info_ptr == NULL) - { - fclose(fp); - png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL); - return (ERROR); - } - - /* Set error handling if you are using the setjmp/longjmp method (this is - * the normal method of doing things with libpng). REQUIRED unless you - * set up your own error handlers in the png_create_read_struct() earlier. - */ - - if (setjmp(png_jmpbuf(png_ptr))) - { - /* Free all of the memory associated with the png_ptr and info_ptr */ - png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL); - fclose(fp); - /* If we get here, we had a problem reading the file */ - return (ERROR); - } - - /* One of the following I/O initialization methods is REQUIRED */ -#ifdef streams /* PNG file I/O method 1 */ - /* Set up the input control if you are using standard C streams */ - png_init_io(png_ptr, fp); - -#else no_streams /* PNG file I/O method 2 */ - /* If you are using replacement read functions, instead of calling - * png_init_io() here you would call: - */ - png_set_read_fn(png_ptr, (void *)user_io_ptr, user_read_fn); - /* where user_io_ptr is a structure you want available to the callbacks */ -#endif no_streams /* Use only one I/O method! */ - - /* If we have already read some of the signature */ - png_set_sig_bytes(png_ptr, sig_read); - -#ifdef hilevel - /* - * If you have enough memory to read in the entire image at once, - * and you need to specify only transforms that can be controlled - * with one of the PNG_TRANSFORM_* bits (this presently excludes - * dithering, filling, setting background, and doing gamma - * adjustment), then you can read the entire image (including - * pixels) into the info structure with this call: - */ - png_read_png(png_ptr, info_ptr, png_transforms, png_voidp_NULL); -#else - /* OK, you're doing it the hard way, with the lower-level functions */ - - /* The call to png_read_info() gives us all of the information from the - * PNG file before the first IDAT (image data chunk). REQUIRED - */ - png_read_info(png_ptr, info_ptr); - - png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, - &interlace_type, int_p_NULL, int_p_NULL); - -/* Set up the data transformations you want. Note that these are all - * optional. Only call them if you want/need them. Many of the - * transformations only work on specific types of images, and many - * are mutually exclusive. - */ - - /* tell libpng to strip 16 bit/color files down to 8 bits/color */ - png_set_strip_16(png_ptr); - - /* Strip alpha bytes from the input data without combining with the - * background (not recommended). - */ - png_set_strip_alpha(png_ptr); - - /* Extract multiple pixels with bit depths of 1, 2, and 4 from a single - * byte into separate bytes (useful for paletted and grayscale images). - */ - png_set_packing(png_ptr); - - /* Change the order of packed pixels to least significant bit first - * (not useful if you are using png_set_packing). */ - png_set_packswap(png_ptr); - - /* Expand paletted colors into true RGB triplets */ - if (color_type == PNG_COLOR_TYPE_PALETTE) - png_set_palette_to_rgb(png_ptr); - - /* Expand grayscale images to the full 8 bits from 1, 2, or 4 bits/pixel */ - if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) - png_set_gray_1_2_4_to_8(png_ptr); - - /* Expand paletted or RGB images with transparency to full alpha channels - * so the data will be available as RGBA quartets. - */ - if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) - png_set_tRNS_to_alpha(png_ptr); - - /* Set the background color to draw transparent and alpha images over. - * It is possible to set the red, green, and blue components directly - * for paletted images instead of supplying a palette index. Note that - * even if the PNG file supplies a background, you are not required to - * use it - you should use the (solid) application background if it has one. - */ - - png_color_16 my_background, *image_background; - - if (png_get_bKGD(png_ptr, info_ptr, &image_background)) - png_set_background(png_ptr, image_background, - PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); - else - png_set_background(png_ptr, &my_background, - PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); - - /* Some suggestions as to how to get a screen gamma value */ - - /* Note that screen gamma is the display_exponent, which includes - * the CRT_exponent and any correction for viewing conditions */ - if (/* We have a user-defined screen gamma value */) - { - screen_gamma = user-defined screen_gamma; - } - /* This is one way that applications share the same screen gamma value */ - else if ((gamma_str = getenv("SCREEN_GAMMA")) != NULL) - { - screen_gamma = atof(gamma_str); - } - /* If we don't have another value */ - else - { - screen_gamma = 2.2; /* A good guess for a PC monitors in a dimly - lit room */ - screen_gamma = 1.7 or 1.0; /* A good guess for Mac systems */ - } - - /* Tell libpng to handle the gamma conversion for you. The final call - * is a good guess for PC generated images, but it should be configurable - * by the user at run time by the user. It is strongly suggested that - * your application support gamma correction. - */ - - int intent; - - if (png_get_sRGB(png_ptr, info_ptr, &intent)) - png_set_gamma(png_ptr, screen_gamma, 0.45455); - else - { - double image_gamma; - if (png_get_gAMA(png_ptr, info_ptr, &image_gamma)) - png_set_gamma(png_ptr, screen_gamma, image_gamma); - else - png_set_gamma(png_ptr, screen_gamma, 0.45455); - } - - /* Dither RGB files down to 8 bit palette or reduce palettes - * to the number of colors available on your screen. - */ - if (color_type & PNG_COLOR_MASK_COLOR) - { - int num_palette; - png_colorp palette; - - /* This reduces the image to the application supplied palette */ - if (/* we have our own palette */) - { - /* An array of colors to which the image should be dithered */ - png_color std_color_cube[MAX_SCREEN_COLORS]; - - png_set_dither(png_ptr, std_color_cube, MAX_SCREEN_COLORS, - MAX_SCREEN_COLORS, png_uint_16p_NULL, 0); - } - /* This reduces the image to the palette supplied in the file */ - else if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette)) - { - png_uint_16p histogram = NULL; - - png_get_hIST(png_ptr, info_ptr, &histogram); - - png_set_dither(png_ptr, palette, num_palette, - max_screen_colors, histogram, 0); - } - } - - /* invert monochrome files to have 0 as white and 1 as black */ - png_set_invert_mono(png_ptr); - - /* If you want to shift the pixel values from the range [0,255] or - * [0,65535] to the original [0,7] or [0,31], or whatever range the - * colors were originally in: - */ - if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT)) - { - png_color_8p sig_bit; - - png_get_sBIT(png_ptr, info_ptr, &sig_bit); - png_set_shift(png_ptr, sig_bit); - } - - /* flip the RGB pixels to BGR (or RGBA to BGRA) */ - if (color_type & PNG_COLOR_MASK_COLOR) - png_set_bgr(png_ptr); - - /* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */ - png_set_swap_alpha(png_ptr); - - /* swap bytes of 16 bit files to least significant byte first */ - png_set_swap(png_ptr); - - /* Add filler (or alpha) byte (before/after each RGB triplet) */ - png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER); - - /* Turn on interlace handling. REQUIRED if you are not using - * png_read_image(). To see how to handle interlacing passes, - * see the png_read_row() method below: - */ - number_passes = png_set_interlace_handling(png_ptr); - - /* Optional call to gamma correct and add the background to the palette - * and update info structure. REQUIRED if you are expecting libpng to - * update the palette for you (ie you selected such a transform above). - */ - png_read_update_info(png_ptr, info_ptr); - - /* Allocate the memory to hold the image using the fields of info_ptr. */ - - /* The easiest way to read the image: */ - png_bytep row_pointers[height]; - - for (row = 0; row < height; row++) - { - row_pointers[row] = png_malloc(png_ptr, png_get_rowbytes(png_ptr, - info_ptr)); - } - - /* Now it's time to read the image. One of these methods is REQUIRED */ -#ifdef entire /* Read the entire image in one go */ - png_read_image(png_ptr, row_pointers); - -#else no_entire /* Read the image one or more scanlines at a time */ - /* The other way to read images - deal with interlacing: */ - - for (pass = 0; pass < number_passes; pass++) - { -#ifdef single /* Read the image a single row at a time */ - for (y = 0; y < height; y++) - { - png_read_rows(png_ptr, &row_pointers[y], png_bytepp_NULL, 1); - } - -#else no_single /* Read the image several rows at a time */ - for (y = 0; y < height; y += number_of_rows) - { -#ifdef sparkle /* Read the image using the "sparkle" effect. */ - png_read_rows(png_ptr, &row_pointers[y], png_bytepp_NULL, - number_of_rows); -#else no_sparkle /* Read the image using the "rectangle" effect */ - png_read_rows(png_ptr, png_bytepp_NULL, &row_pointers[y], - number_of_rows); -#endif no_sparkle /* use only one of these two methods */ - } - - /* if you want to display the image after every pass, do - so here */ -#endif no_single /* use only one of these two methods */ - } -#endif no_entire /* use only one of these two methods */ - - /* read rest of file, and get additional chunks in info_ptr - REQUIRED */ - png_read_end(png_ptr, info_ptr); -#endif hilevel - - /* At this point you have read the entire image */ - - /* clean up after the read, and free any memory allocated - REQUIRED */ - png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL); - - /* close the file */ - fclose(fp); - - /* that's it */ - return (OK); -} - -/* progressively read a file */ - -int -initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr) -{ - /* Create and initialize the png_struct with the desired error handler - * functions. If you want to use the default stderr and longjump method, - * you can supply NULL for the last three parameters. We also check that - * the library version is compatible in case we are using dynamically - * linked libraries. - */ - *png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, - png_voidp user_error_ptr, user_error_fn, user_warning_fn); - - if (*png_ptr == NULL) - { - *info_ptr = NULL; - return (ERROR); - } - - *info_ptr = png_create_info_struct(png_ptr); - - if (*info_ptr == NULL) - { - png_destroy_read_struct(png_ptr, info_ptr, png_infopp_NULL); - return (ERROR); - } - - if (setjmp(png_jmpbuf((*png_ptr)))) - { - png_destroy_read_struct(png_ptr, info_ptr, png_infopp_NULL); - return (ERROR); - } - - /* This one's new. You will need to provide all three - * function callbacks, even if you aren't using them all. - * If you aren't using all functions, you can specify NULL - * parameters. Even when all three functions are NULL, - * you need to call png_set_progressive_read_fn(). - * These functions shouldn't be dependent on global or - * static variables if you are decoding several images - * simultaneously. You should store stream specific data - * in a separate struct, given as the second parameter, - * and retrieve the pointer from inside the callbacks using - * the function png_get_progressive_ptr(png_ptr). - */ - png_set_progressive_read_fn(*png_ptr, (void *)stream_data, - info_callback, row_callback, end_callback); - - return (OK); -} - -int -process_data(png_structp *png_ptr, png_infop *info_ptr, - png_bytep buffer, png_uint_32 length) -{ - if (setjmp(png_jmpbuf((*png_ptr)))) - { - /* Free the png_ptr and info_ptr memory on error */ - png_destroy_read_struct(png_ptr, info_ptr, png_infopp_NULL); - return (ERROR); - } - - /* This one's new also. Simply give it chunks of data as - * they arrive from the data stream (in order, of course). - * On Segmented machines, don't give it any more than 64K. - * The library seems to run fine with sizes of 4K, although - * you can give it much less if necessary (I assume you can - * give it chunks of 1 byte, but I haven't tried with less - * than 256 bytes yet). When this function returns, you may - * want to display any rows that were generated in the row - * callback, if you aren't already displaying them there. - */ - png_process_data(*png_ptr, *info_ptr, buffer, length); - return (OK); -} - -info_callback(png_structp png_ptr, png_infop info) -{ -/* do any setup here, including setting any of the transformations - * mentioned in the Reading PNG files section. For now, you _must_ - * call either png_start_read_image() or png_read_update_info() - * after all the transformations are set (even if you don't set - * any). You may start getting rows before png_process_data() - * returns, so this is your last chance to prepare for that. - */ -} - -row_callback(png_structp png_ptr, png_bytep new_row, - png_uint_32 row_num, int pass) -{ -/* - * This function is called for every row in the image. If the - * image is interlaced, and you turned on the interlace handler, - * this function will be called for every row in every pass. - * - * In this function you will receive a pointer to new row data from - * libpng called new_row that is to replace a corresponding row (of - * the same data format) in a buffer allocated by your application. - * - * The new row data pointer new_row may be NULL, indicating there is - * no new data to be replaced (in cases of interlace loading). - * - * If new_row is not NULL then you need to call - * png_progressive_combine_row() to replace the corresponding row as - * shown below: - */ - /* Check if row_num is in bounds. */ - if((row_num >= 0) && (row_num < height)) - { - /* Get pointer to corresponding row in our - * PNG read buffer. - */ - png_bytep old_row = ((png_bytep *)our_data)[row_num]; - - /* If both rows are allocated then copy the new row - * data to the corresponding row data. - */ - if((old_row != NULL) && (new_row != NULL)) - png_progressive_combine_row(png_ptr, old_row, new_row); - } -/* - * The rows and passes are called in order, so you don't really - * need the row_num and pass, but I'm supplying them because it - * may make your life easier. - * - * For the non-NULL rows of interlaced images, you must call - * png_progressive_combine_row() passing in the new row and the - * old row, as demonstrated above. You can call this function for - * NULL rows (it will just return) and for non-interlaced images - * (it just does the png_memcpy for you) if it will make the code - * easier. Thus, you can just do this for all cases: - */ - - png_progressive_combine_row(png_ptr, old_row, new_row); - -/* where old_row is what was displayed for previous rows. Note - * that the first pass (pass == 0 really) will completely cover - * the old row, so the rows do not have to be initialized. After - * the first pass (and only for interlaced images), you will have - * to pass the current row as new_row, and the function will combine - * the old row and the new row. - */ -} - -end_callback(png_structp png_ptr, png_infop info) -{ -/* this function is called when the whole image has been read, - * including any chunks after the image (up to and including - * the IEND). You will usually have the same info chunk as you - * had in the header, although some data may have been added - * to the comments and time fields. - * - * Most people won't do much here, perhaps setting a flag that - * marks the image as finished. - */ -} - -/* write a png file */ -void write_png(char *file_name /* , ... other image information ... */) -{ - FILE *fp; - png_structp png_ptr; - png_infop info_ptr; - png_colorp palette; - - /* open the file */ - fp = fopen(file_name, "wb"); - if (fp == NULL) - return (ERROR); - - /* Create and initialize the png_struct with the desired error handler - * functions. If you want to use the default stderr and longjump method, - * you can supply NULL for the last three parameters. We also check that - * the library version is compatible with the one used at compile time, - * in case we are using dynamically linked libraries. REQUIRED. - */ - png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, - png_voidp user_error_ptr, user_error_fn, user_warning_fn); - - if (png_ptr == NULL) - { - fclose(fp); - return (ERROR); - } - - /* Allocate/initialize the image information data. REQUIRED */ - info_ptr = png_create_info_struct(png_ptr); - if (info_ptr == NULL) - { - fclose(fp); - png_destroy_write_struct(&png_ptr, png_infopp_NULL); - return (ERROR); - } - - /* Set error handling. REQUIRED if you aren't supplying your own - * error handling functions in the png_create_write_struct() call. - */ - if (setjmp(png_jmpbuf(png_ptr))) - { - /* If we get here, we had a problem reading the file */ - fclose(fp); - png_destroy_write_struct(&png_ptr, &info_ptr); - return (ERROR); - } - - /* One of the following I/O initialization functions is REQUIRED */ -#ifdef streams /* I/O initialization method 1 */ - /* set up the output control if you are using standard C streams */ - png_init_io(png_ptr, fp); -#else no_streams /* I/O initialization method 2 */ - /* If you are using replacement read functions, instead of calling - * png_init_io() here you would call */ - png_set_write_fn(png_ptr, (void *)user_io_ptr, user_write_fn, - user_IO_flush_function); - /* where user_io_ptr is a structure you want available to the callbacks */ -#endif no_streams /* only use one initialization method */ - -#ifdef hilevel - /* This is the easy way. Use it if you already have all the - * image info living info in the structure. You could "|" many - * PNG_TRANSFORM flags into the png_transforms integer here. - */ - png_write_png(png_ptr, info_ptr, png_transforms, png_voidp_NULL); -#else - /* This is the hard way */ - - /* Set the image information here. Width and height are up to 2^31, - * bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on - * the color_type selected. color_type is one of PNG_COLOR_TYPE_GRAY, - * PNG_COLOR_TYPE_GRAY_ALPHA, PNG_COLOR_TYPE_PALETTE, PNG_COLOR_TYPE_RGB, - * or PNG_COLOR_TYPE_RGB_ALPHA. interlace is either PNG_INTERLACE_NONE or - * PNG_INTERLACE_ADAM7, and the compression_type and filter_type MUST - * currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE. REQUIRED - */ - png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, PNG_COLOR_TYPE_???, - PNG_INTERLACE_????, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); - - /* set the palette if there is one. REQUIRED for indexed-color images */ - palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH - * png_sizeof (png_color)); - /* ... set palette colors ... */ - png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH); - /* You must not free palette here, because png_set_PLTE only makes a link to - the palette that you malloced. Wait until you are about to destroy - the png structure. */ - - /* optional significant bit chunk */ - /* if we are dealing with a grayscale image then */ - sig_bit.gray = true_bit_depth; - /* otherwise, if we are dealing with a color image then */ - sig_bit.red = true_red_bit_depth; - sig_bit.green = true_green_bit_depth; - sig_bit.blue = true_blue_bit_depth; - /* if the image has an alpha channel then */ - sig_bit.alpha = true_alpha_bit_depth; - png_set_sBIT(png_ptr, info_ptr, sig_bit); - - - /* Optional gamma chunk is strongly suggested if you have any guess - * as to the correct gamma of the image. - */ - png_set_gAMA(png_ptr, info_ptr, gamma); - - /* Optionally write comments into the image */ - text_ptr[0].key = "Title"; - text_ptr[0].text = "Mona Lisa"; - text_ptr[0].compression = PNG_TEXT_COMPRESSION_NONE; - text_ptr[1].key = "Author"; - text_ptr[1].text = "Leonardo DaVinci"; - text_ptr[1].compression = PNG_TEXT_COMPRESSION_NONE; - text_ptr[2].key = "Description"; - text_ptr[2].text = "<long text>"; - text_ptr[2].compression = PNG_TEXT_COMPRESSION_zTXt; -#ifdef PNG_iTXt_SUPPORTED - text_ptr[0].lang = NULL; - text_ptr[1].lang = NULL; - text_ptr[2].lang = NULL; -#endif - png_set_text(png_ptr, info_ptr, text_ptr, 3); - - /* other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs, */ - /* note that if sRGB is present the gAMA and cHRM chunks must be ignored - * on read and must be written in accordance with the sRGB profile */ - - /* Write the file header information. REQUIRED */ - png_write_info(png_ptr, info_ptr); - - /* If you want, you can write the info in two steps, in case you need to - * write your private chunk ahead of PLTE: - * - * png_write_info_before_PLTE(write_ptr, write_info_ptr); - * write_my_chunk(); - * png_write_info(png_ptr, info_ptr); - * - * However, given the level of known- and unknown-chunk support in 1.1.0 - * and up, this should no longer be necessary. - */ - - /* Once we write out the header, the compression type on the text - * chunks gets changed to PNG_TEXT_COMPRESSION_NONE_WR or - * PNG_TEXT_COMPRESSION_zTXt_WR, so it doesn't get written out again - * at the end. - */ - - /* set up the transformations you want. Note that these are - * all optional. Only call them if you want them. - */ - - /* invert monochrome pixels */ - png_set_invert_mono(png_ptr); - - /* Shift the pixels up to a legal bit depth and fill in - * as appropriate to correctly scale the image. - */ - png_set_shift(png_ptr, &sig_bit); - - /* pack pixels into bytes */ - png_set_packing(png_ptr); - - /* swap location of alpha bytes from ARGB to RGBA */ - png_set_swap_alpha(png_ptr); - - /* Get rid of filler (OR ALPHA) bytes, pack XRGB/RGBX/ARGB/RGBA into - * RGB (4 channels -> 3 channels). The second parameter is not used. - */ - png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); - - /* flip BGR pixels to RGB */ - png_set_bgr(png_ptr); - - /* swap bytes of 16-bit files to most significant byte first */ - png_set_swap(png_ptr); - - /* swap bits of 1, 2, 4 bit packed pixel formats */ - png_set_packswap(png_ptr); - - /* turn on interlace handling if you are not using png_write_image() */ - if (interlacing) - number_passes = png_set_interlace_handling(png_ptr); - else - number_passes = 1; - - /* The easiest way to write the image (you may have a different memory - * layout, however, so choose what fits your needs best). You need to - * use the first method if you aren't handling interlacing yourself. - */ - png_uint_32 k, height, width; - png_byte image[height][width*bytes_per_pixel]; - png_bytep row_pointers[height]; - - if (height > PNG_UINT_32_MAX/png_sizeof(png_bytep)) - png_error (png_ptr, "Image is too tall to process in memory"); - - for (k = 0; k < height; k++) - row_pointers[k] = image + k*width*bytes_per_pixel; - - /* One of the following output methods is REQUIRED */ -#ifdef entire /* write out the entire image data in one call */ - png_write_image(png_ptr, row_pointers); - - /* the other way to write the image - deal with interlacing */ - -#else no_entire /* write out the image data by one or more scanlines */ - /* The number of passes is either 1 for non-interlaced images, - * or 7 for interlaced images. - */ - for (pass = 0; pass < number_passes; pass++) - { - /* Write a few rows at a time. */ - png_write_rows(png_ptr, &row_pointers[first_row], number_of_rows); - - /* If you are only writing one row at a time, this works */ - for (y = 0; y < height; y++) - { - png_write_rows(png_ptr, &row_pointers[y], 1); - } - } -#endif no_entire /* use only one output method */ - - /* You can write optional chunks like tEXt, zTXt, and tIME at the end - * as well. Shouldn't be necessary in 1.1.0 and up as all the public - * chunks are supported and you can use png_set_unknown_chunks() to - * register unknown chunks into the info structure to be written out. - */ - - /* It is REQUIRED to call this to finish writing the rest of the file */ - png_write_end(png_ptr, info_ptr); -#endif hilevel - - /* If you png_malloced a palette, free it here (don't free info_ptr->palette, - as recommended in versions 1.0.5m and earlier of this example; if - libpng mallocs info_ptr->palette, libpng will free it). If you - allocated it with malloc() instead of png_malloc(), use free() instead - of png_free(). */ - png_free(png_ptr, palette); - palette=NULL; - - /* Similarly, if you png_malloced any data that you passed in with - png_set_something(), such as a hist or trans array, free it here, - when you can be sure that libpng is through with it. */ - png_free(png_ptr, trans); - trans=NULL; - - /* clean up after the write, and free any memory allocated */ - png_destroy_write_struct(&png_ptr, &info_ptr); - - /* close the file */ - fclose(fp); - - /* that's it */ - return (OK); -} - -#endif /* if 0 */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/libpng-1.2.18.txt b/irrlicht-1.6/source/Irrlicht/libpng/libpng-1.2.18.txt deleted file mode 100644 index 04c5e88c6..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/libpng-1.2.18.txt +++ /dev/null @@ -1,2976 +0,0 @@ -libpng.txt - A description on how to use and modify libpng - - libpng version 1.2.18 - May 15, 2007 - Updated and distributed by Glenn Randers-Pehrson - <glennrp at users.sourceforge.net> - Copyright (c) 1998-2007 Glenn Randers-Pehrson - For conditions of distribution and use, see copyright - notice in png.h. - - based on: - - libpng 1.0 beta 6 version 0.96 May 28, 1997 - Updated and distributed by Andreas Dilger - Copyright (c) 1996, 1997 Andreas Dilger - - libpng 1.0 beta 2 - version 0.88 January 26, 1996 - For conditions of distribution and use, see copyright - notice in png.h. Copyright (c) 1995, 1996 Guy Eric - Schalnat, Group 42, Inc. - - Updated/rewritten per request in the libpng FAQ - Copyright (c) 1995, 1996 Frank J. T. Wojcik - December 18, 1995 & January 20, 1996 - -I. Introduction - -This file describes how to use and modify the PNG reference library -(known as libpng) for your own use. There are five sections to this -file: introduction, structures, reading, writing, and modification and -configuration notes for various special platforms. In addition to this -file, example.c is a good starting point for using the library, as -it is heavily commented and should include everything most people -will need. We assume that libpng is already installed; see the -INSTALL file for instructions on how to install libpng. - -For examples of libpng usage, see the files "example.c", "pngtest.c", -and the files in the "contrib" directory, all of which are included in the -libpng distribution. - -Libpng was written as a companion to the PNG specification, as a way -of reducing the amount of time and effort it takes to support the PNG -file format in application programs. - -The PNG specification (second edition), November 2003, is available as -a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2003 (E)) at -<http://www.w3.org/TR/2003/REC-PNG-20031110/ -The W3C and ISO documents have identical technical content. - -The PNG-1.2 specification is available at -<http://www.libpng.org/pub/png/documents/> - -The PNG-1.0 specification is available -as RFC 2083 <http://www.libpng.org/pub/png/documents/> and as a -W3C Recommendation <http://www.w3.org/TR/REC.png.html>. Some -additional chunks are described in the special-purpose public chunks -documents at <http://www.libpng.org/pub/png/documents/>. - -Other information -about PNG, and the latest version of libpng, can be found at the PNG home -page, <http://www.libpng.org/pub/png/>. - -Most users will not have to modify the library significantly; advanced -users may want to modify it more. All attempts were made to make it as -complete as possible, while keeping the code easy to understand. -Currently, this library only supports C. Support for other languages -is being considered. - -Libpng has been designed to handle multiple sessions at one time, -to be easily modifiable, to be portable to the vast majority of -machines (ANSI, K&R, 16-, 32-, and 64-bit) available, and to be easy -to use. The ultimate goal of libpng is to promote the acceptance of -the PNG file format in whatever way possible. While there is still -work to be done (see the TODO file), libpng should cover the -majority of the needs of its users. - -Libpng uses zlib for its compression and decompression of PNG files. -Further information about zlib, and the latest version of zlib, can -be found at the zlib home page, <http://www.info-zip.org/pub/infozip/zlib/>. -The zlib compression utility is a general purpose utility that is -useful for more than PNG files, and can be used without libpng. -See the documentation delivered with zlib for more details. -You can usually find the source files for the zlib utility wherever you -find the libpng source files. - -Libpng is thread safe, provided the threads are using different -instances of the structures. Each thread should have its own -png_struct and png_info instances, and thus its own image. -Libpng does not protect itself against two threads using the -same instance of a structure. Note: thread safety may be defeated -by use of some of the MMX assembler code in pnggccrd.c, which is only -compiled when the user defines PNG_THREAD_UNSAFE_OK. - -II. Structures - -There are two main structures that are important to libpng, png_struct -and png_info. The first, png_struct, is an internal structure that -will not, for the most part, be used by a user except as the first -variable passed to every libpng function call. - -The png_info structure is designed to provide information about the -PNG file. At one time, the fields of png_info were intended to be -directly accessible to the user. However, this tended to cause problems -with applications using dynamically loaded libraries, and as a result -a set of interface functions for png_info (the png_get_*() and png_set_*() -functions) was developed. The fields of png_info are still available for -older applications, but it is suggested that applications use the new -interfaces if at all possible. - -Applications that do make direct access to the members of png_struct (except -for png_ptr->jmpbuf) must be recompiled whenever the library is updated, -and applications that make direct access to the members of png_info must -be recompiled if they were compiled or loaded with libpng version 1.0.6, -in which the members were in a different order. In version 1.0.7, the -members of the png_info structure reverted to the old order, as they were -in versions 0.97c through 1.0.5. Starting with version 2.0.0, both -structures are going to be hidden, and the contents of the structures will -only be accessible through the png_get/png_set functions. - -The png.h header file is an invaluable reference for programming with libpng. -And while I'm on the topic, make sure you include the libpng header file: - -#include <png.h> - -III. Reading - -We'll now walk you through the possible functions to call when reading -in a PNG file sequentially, briefly explaining the syntax and purpose -of each one. See example.c and png.h for more detail. While -progressive reading is covered in the next section, you will still -need some of the functions discussed in this section to read a PNG -file. - -Setup - -You will want to do the I/O initialization(*) before you get into libpng, -so if it doesn't work, you don't have much to undo. Of course, you -will also want to insure that you are, in fact, dealing with a PNG -file. Libpng provides a simple check to see if a file is a PNG file. -To use it, pass in the first 1 to 8 bytes of the file to the function -png_sig_cmp(), and it will return 0 if the bytes match the corresponding -bytes of the PNG signature, or nonzero otherwise. Of course, the more bytes -you pass in, the greater the accuracy of the prediction. - -If you are intending to keep the file pointer open for use in libpng, -you must ensure you don't read more than 8 bytes from the beginning -of the file, and you also have to make a call to png_set_sig_bytes_read() -with the number of bytes you read from the beginning. Libpng will -then only check the bytes (if any) that your program didn't read. - -(*): If you are not using the standard I/O functions, you will need -to replace them with custom functions. See the discussion under -Customizing libpng. - - - FILE *fp = fopen(file_name, "rb"); - if (!fp) - { - return (ERROR); - } - fread(header, 1, number, fp); - is_png = !png_sig_cmp(header, 0, number); - if (!is_png) - { - return (NOT_PNG); - } - - -Next, png_struct and png_info need to be allocated and initialized. In -order to ensure that the size of these structures is correct even with a -dynamically linked libpng, there are functions to initialize and -allocate the structures. We also pass the library version, optional -pointers to error handling functions, and a pointer to a data struct for -use by the error functions, if necessary (the pointer and functions can -be NULL if the default error handlers are to be used). See the section -on Changes to Libpng below regarding the old initialization functions. -The structure allocation functions quietly return NULL if they fail to -create the structure, so your application should check for that. - - png_structp png_ptr = png_create_read_struct - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn); - if (!png_ptr) - return (ERROR); - - png_infop info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - png_destroy_read_struct(&png_ptr, - (png_infopp)NULL, (png_infopp)NULL); - return (ERROR); - } - - png_infop end_info = png_create_info_struct(png_ptr); - if (!end_info) - { - png_destroy_read_struct(&png_ptr, &info_ptr, - (png_infopp)NULL); - return (ERROR); - } - -If you want to use your own memory allocation routines, -define PNG_USER_MEM_SUPPORTED and use -png_create_read_struct_2() instead of png_create_read_struct(): - - png_structp png_ptr = png_create_read_struct_2 - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn, (png_voidp) - user_mem_ptr, user_malloc_fn, user_free_fn); - -The error handling routines passed to png_create_read_struct() -and the memory alloc/free routines passed to png_create_struct_2() -are only necessary if you are not using the libpng supplied error -handling and memory alloc/free functions. - -When libpng encounters an error, it expects to longjmp back -to your routine. Therefore, you will need to call setjmp and pass -your png_jmpbuf(png_ptr). If you read the file from different -routines, you will need to update the jmpbuf field every time you enter -a new routine that will call a png_*() function. - -See your documentation of setjmp/longjmp for your compiler for more -information on setjmp/longjmp. See the discussion on libpng error -handling in the Customizing Libpng section below for more information -on the libpng error handling. If an error occurs, and libpng longjmp's -back to your setjmp, you will want to call png_destroy_read_struct() to -free any memory. - - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, - &end_info); - fclose(fp); - return (ERROR); - } - -If you would rather avoid the complexity of setjmp/longjmp issues, -you can compile libpng with PNG_SETJMP_NOT_SUPPORTED, in which case -errors will result in a call to PNG_ABORT() which defaults to abort(). - -Now you need to set up the input code. The default for libpng is to -use the C function fread(). If you use this, you will need to pass a -valid FILE * in the function png_init_io(). Be sure that the file is -opened in binary mode. If you wish to handle reading data in another -way, you need not call the png_init_io() function, but you must then -implement the libpng I/O methods discussed in the Customizing Libpng -section below. - - png_init_io(png_ptr, fp); - -If you had previously opened the file and read any of the signature from -the beginning in order to see if this was a PNG file, you need to let -libpng know that there are some bytes missing from the start of the file. - - png_set_sig_bytes(png_ptr, number); - -Setting up callback code - -You can set up a callback function to handle any unknown chunks in the -input stream. You must supply the function - - read_chunk_callback(png_ptr ptr, - png_unknown_chunkp chunk); - { - /* The unknown chunk structure contains your - chunk data: */ - png_byte name[5]; - png_byte *data; - png_size_t size; - /* Note that libpng has already taken care of - the CRC handling */ - - /* put your code here. Return one of the - following: */ - - return (-n); /* chunk had an error */ - return (0); /* did not recognize */ - return (n); /* success */ - } - -(You can give your function another name that you like instead of -"read_chunk_callback") - -To inform libpng about your function, use - - png_set_read_user_chunk_fn(png_ptr, user_chunk_ptr, - read_chunk_callback); - -This names not only the callback function, but also a user pointer that -you can retrieve with - - png_get_user_chunk_ptr(png_ptr); - -At this point, you can set up a callback function that will be -called after each row has been read, which you can use to control -a progress meter or the like. It's demonstrated in pngtest.c. -You must supply a function - - void read_row_callback(png_ptr ptr, png_uint_32 row, - int pass); - { - /* put your code here */ - } - -(You can give it another name that you like instead of "read_row_callback") - -To inform libpng about your function, use - - png_set_read_status_fn(png_ptr, read_row_callback); - -Width and height limits - -The PNG specification allows the width and height of an image to be as -large as 2^31-1 (0x7fffffff), or about 2.147 billion rows and columns. -Since very few applications really need to process such large images, -we have imposed an arbitrary 1-million limit on rows and columns. -Larger images will be rejected immediately with a png_error() call. If -you wish to override this limit, you can use - - png_set_user_limits(png_ptr, width_max, height_max); - -to set your own limits, or use width_max = height_max = 0x7fffffffL -to allow all valid dimensions (libpng may reject some very large images -anyway because of potential buffer overflow conditions). - -You should put this statement after you create the PNG structure and -before calling png_read_info(), png_read_png(), or png_process_data(). -If you need to retrieve the limits that are being applied, use - - width_max = png_get_user_width_max(png_ptr); - height_max = png_get_user_height_max(png_ptr); - -Unknown-chunk handling - -Now you get to set the way the library processes unknown chunks in the -input PNG stream. Both known and unknown chunks will be read. Normal -behavior is that known chunks will be parsed into information in -various info_ptr members; unknown chunks will be discarded. To change -this, you can call: - - png_set_keep_unknown_chunks(png_ptr, keep, - chunk_list, num_chunks); - keep - 0: do not handle as unknown - 1: do not keep - 2: keep only if safe-to-copy - 3: keep even if unsafe-to-copy - You can use these definitions: - PNG_HANDLE_CHUNK_AS_DEFAULT 0 - PNG_HANDLE_CHUNK_NEVER 1 - PNG_HANDLE_CHUNK_IF_SAFE 2 - PNG_HANDLE_CHUNK_ALWAYS 3 - chunk_list - list of chunks affected (a byte string, - five bytes per chunk, NULL or '\0' if - num_chunks is 0) - num_chunks - number of chunks affected; if 0, all - unknown chunks are affected. If nonzero, - only the chunks in the list are affected - -Unknown chunks declared in this way will be saved as raw data onto a -list of png_unknown_chunk structures. If a chunk that is normally -known to libpng is named in the list, it will be handled as unknown, -according to the "keep" directive. If a chunk is named in successive -instances of png_set_keep_unknown_chunks(), the final instance will -take precedence. The IHDR and IEND chunks should not be named in -chunk_list; if they are, libpng will process them normally anyway. - -The high-level read interface - -At this point there are two ways to proceed; through the high-level -read interface, or through a sequence of low-level read operations. -You can use the high-level interface if (a) you are willing to read -the entire image into memory, and (b) the input transformations -you want to do are limited to the following set: - - PNG_TRANSFORM_IDENTITY No transformation - PNG_TRANSFORM_STRIP_16 Strip 16-bit samples to - 8 bits - PNG_TRANSFORM_STRIP_ALPHA Discard the alpha channel - PNG_TRANSFORM_PACKING Expand 1, 2 and 4-bit - samples to bytes - PNG_TRANSFORM_PACKSWAP Change order of packed - pixels to LSB first - PNG_TRANSFORM_EXPAND Perform set_expand() - PNG_TRANSFORM_INVERT_MONO Invert monochrome images - PNG_TRANSFORM_SHIFT Normalize pixels to the - sBIT depth - PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA - to BGRA - PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA - to AG - PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity - to transparency - PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples - -(This excludes setting a background color, doing gamma transformation, -dithering, and setting filler.) If this is the case, simply do this: - - png_read_png(png_ptr, info_ptr, png_transforms, NULL) - -where png_transforms is an integer containing the bitwise OR of -some set of transformation flags. This call is equivalent to png_read_info(), -followed the set of transformations indicated by the transform mask, -then png_read_image(), and finally png_read_end(). - -(The final parameter of this call is not yet used. Someday it might point -to transformation parameters required by some future input transform.) - -You must use png_transforms and not call any png_set_transform() functions -when you use png_read_png(). - -After you have called png_read_png(), you can retrieve the image data -with - - row_pointers = png_get_rows(png_ptr, info_ptr); - -where row_pointers is an array of pointers to the pixel data for each row: - - png_bytep row_pointers[height]; - -If you know your image size and pixel size ahead of time, you can allocate -row_pointers prior to calling png_read_png() with - - if (height > PNG_UINT_32_MAX/png_sizeof(png_byte)) - png_error (png_ptr, - "Image is too tall to process in memory"); - if (width > PNG_UINT_32_MAX/pixel_size) - png_error (png_ptr, - "Image is too wide to process in memory"); - row_pointers = png_malloc(png_ptr, - height*png_sizeof(png_bytep)); - for (int i=0; i<height, i++) - row_pointers[i]=png_malloc(png_ptr, - width*pixel_size); - png_set_rows(png_ptr, info_ptr, &row_pointers); - -Alternatively you could allocate your image in one big block and define -row_pointers[i] to point into the proper places in your block. - -If you use png_set_rows(), the application is responsible for freeing -row_pointers (and row_pointers[i], if they were separately allocated). - -If you don't allocate row_pointers ahead of time, png_read_png() will -do it, and it'll be free'ed when you call png_destroy_*(). - -The low-level read interface - -If you are going the low-level route, you are now ready to read all -the file information up to the actual image data. You do this with a -call to png_read_info(). - - png_read_info(png_ptr, info_ptr); - -This will process all chunks up to but not including the image data. - -Querying the info structure - -Functions are used to get the information from the info_ptr once it -has been read. Note that these fields may not be completely filled -in until png_read_end() has read the chunk data following the image. - - png_get_IHDR(png_ptr, info_ptr, &width, &height, - &bit_depth, &color_type, &interlace_type, - &compression_type, &filter_method); - - width - holds the width of the image - in pixels (up to 2^31). - height - holds the height of the image - in pixels (up to 2^31). - bit_depth - holds the bit depth of one of the - image channels. (valid values are - 1, 2, 4, 8, 16 and depend also on - the color_type. See also - significant bits (sBIT) below). - color_type - describes which color/alpha channels - are present. - PNG_COLOR_TYPE_GRAY - (bit depths 1, 2, 4, 8, 16) - PNG_COLOR_TYPE_GRAY_ALPHA - (bit depths 8, 16) - PNG_COLOR_TYPE_PALETTE - (bit depths 1, 2, 4, 8) - PNG_COLOR_TYPE_RGB - (bit_depths 8, 16) - PNG_COLOR_TYPE_RGB_ALPHA - (bit_depths 8, 16) - - PNG_COLOR_MASK_PALETTE - PNG_COLOR_MASK_COLOR - PNG_COLOR_MASK_ALPHA - - filter_method - (must be PNG_FILTER_TYPE_BASE - for PNG 1.0, and can also be - PNG_INTRAPIXEL_DIFFERENCING if - the PNG datastream is embedded in - a MNG-1.0 datastream) - compression_type - (must be PNG_COMPRESSION_TYPE_BASE - for PNG 1.0) - interlace_type - (PNG_INTERLACE_NONE or - PNG_INTERLACE_ADAM7) - Any or all of interlace_type, compression_type, of - filter_method can be NULL if you are - not interested in their values. - - channels = png_get_channels(png_ptr, info_ptr); - channels - number of channels of info for the - color type (valid values are 1 (GRAY, - PALETTE), 2 (GRAY_ALPHA), 3 (RGB), - 4 (RGB_ALPHA or RGB + filler byte)) - rowbytes = png_get_rowbytes(png_ptr, info_ptr); - rowbytes - number of bytes needed to hold a row - - signature = png_get_signature(png_ptr, info_ptr); - signature - holds the signature read from the - file (if any). The data is kept in - the same offset it would be if the - whole signature were read (i.e. if an - application had already read in 4 - bytes of signature before starting - libpng, the remaining 4 bytes would - be in signature[4] through signature[7] - (see png_set_sig_bytes())). - - - width = png_get_image_width(png_ptr, - info_ptr); - height = png_get_image_height(png_ptr, - info_ptr); - bit_depth = png_get_bit_depth(png_ptr, - info_ptr); - color_type = png_get_color_type(png_ptr, - info_ptr); - filter_method = png_get_filter_type(png_ptr, - info_ptr); - compression_type = png_get_compression_type(png_ptr, - info_ptr); - interlace_type = png_get_interlace_type(png_ptr, - info_ptr); - - -These are also important, but their validity depends on whether the chunk -has been read. The png_get_valid(png_ptr, info_ptr, PNG_INFO_<chunk>) and -png_get_<chunk>(png_ptr, info_ptr, ...) functions return non-zero if the -data has been read, or zero if it is missing. The parameters to the -png_get_<chunk> are set directly if they are simple data types, or a pointer -into the info_ptr is returned for any complex types. - - png_get_PLTE(png_ptr, info_ptr, &palette, - &num_palette); - palette - the palette for the file - (array of png_color) - num_palette - number of entries in the palette - - png_get_gAMA(png_ptr, info_ptr, &gamma); - gamma - the gamma the file is written - at (PNG_INFO_gAMA) - - png_get_sRGB(png_ptr, info_ptr, &srgb_intent); - srgb_intent - the rendering intent (PNG_INFO_sRGB) - The presence of the sRGB chunk - means that the pixel data is in the - sRGB color space. This chunk also - implies specific values of gAMA and - cHRM. - - png_get_iCCP(png_ptr, info_ptr, &name, - &compression_type, &profile, &proflen); - name - The profile name. - compression - The compression type; always - PNG_COMPRESSION_TYPE_BASE for PNG 1.0. - You may give NULL to this argument to - ignore it. - profile - International Color Consortium color - profile data. May contain NULs. - proflen - length of profile data in bytes. - - png_get_sBIT(png_ptr, info_ptr, &sig_bit); - sig_bit - the number of significant bits for - (PNG_INFO_sBIT) each of the gray, - red, green, and blue channels, - whichever are appropriate for the - given color type (png_color_16) - - png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans, - &trans_values); - trans - array of transparent entries for - palette (PNG_INFO_tRNS) - trans_values - graylevel or color sample values of - the single transparent color for - non-paletted images (PNG_INFO_tRNS) - num_trans - number of transparent entries - (PNG_INFO_tRNS) - - png_get_hIST(png_ptr, info_ptr, &hist); - (PNG_INFO_hIST) - hist - histogram of palette (array of - png_uint_16) - - png_get_tIME(png_ptr, info_ptr, &mod_time); - mod_time - time image was last modified - (PNG_VALID_tIME) - - png_get_bKGD(png_ptr, info_ptr, &background); - background - background color (PNG_VALID_bKGD) - valid 16-bit red, green and blue - values, regardless of color_type - - num_comments = png_get_text(png_ptr, info_ptr, - &text_ptr, &num_text); - num_comments - number of comments - text_ptr - array of png_text holding image - comments - text_ptr[i].compression - type of compression used - on "text" PNG_TEXT_COMPRESSION_NONE - PNG_TEXT_COMPRESSION_zTXt - PNG_ITXT_COMPRESSION_NONE - PNG_ITXT_COMPRESSION_zTXt - text_ptr[i].key - keyword for comment. Must contain - 1-79 characters. - text_ptr[i].text - text comments for current - keyword. Can be empty. - text_ptr[i].text_length - length of text string, - after decompression, 0 for iTXt - text_ptr[i].itxt_length - length of itxt string, - after decompression, 0 for tEXt/zTXt - text_ptr[i].lang - language of comment (empty - string for unknown). - text_ptr[i].lang_key - keyword in UTF-8 - (empty string for unknown). - num_text - number of comments (same as - num_comments; you can put NULL here - to avoid the duplication) - Note while png_set_text() will accept text, language, - and translated keywords that can be NULL pointers, the - structure returned by png_get_text will always contain - regular zero-terminated C strings. They might be - empty strings but they will never be NULL pointers. - - num_spalettes = png_get_sPLT(png_ptr, info_ptr, - &palette_ptr); - palette_ptr - array of palette structures holding - contents of one or more sPLT chunks - read. - num_spalettes - number of sPLT chunks read. - - png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y, - &unit_type); - offset_x - positive offset from the left edge - of the screen - offset_y - positive offset from the top edge - of the screen - unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER - - png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y, - &unit_type); - res_x - pixels/unit physical resolution in - x direction - res_y - pixels/unit physical resolution in - x direction - unit_type - PNG_RESOLUTION_UNKNOWN, - PNG_RESOLUTION_METER - - png_get_sCAL(png_ptr, info_ptr, &unit, &width, - &height) - unit - physical scale units (an integer) - width - width of a pixel in physical scale units - height - height of a pixel in physical scale units - (width and height are doubles) - - png_get_sCAL_s(png_ptr, info_ptr, &unit, &width, - &height) - unit - physical scale units (an integer) - width - width of a pixel in physical scale units - height - height of a pixel in physical scale units - (width and height are strings like "2.54") - - num_unknown_chunks = png_get_unknown_chunks(png_ptr, - info_ptr, &unknowns) - unknowns - array of png_unknown_chunk - structures holding unknown chunks - unknowns[i].name - name of unknown chunk - unknowns[i].data - data of unknown chunk - unknowns[i].size - size of unknown chunk's data - unknowns[i].location - position of chunk in file - - The value of "i" corresponds to the order in which the - chunks were read from the PNG file or inserted with the - png_set_unknown_chunks() function. - -The data from the pHYs chunk can be retrieved in several convenient -forms: - - res_x = png_get_x_pixels_per_meter(png_ptr, - info_ptr) - res_y = png_get_y_pixels_per_meter(png_ptr, - info_ptr) - res_x_and_y = png_get_pixels_per_meter(png_ptr, - info_ptr) - res_x = png_get_x_pixels_per_inch(png_ptr, - info_ptr) - res_y = png_get_y_pixels_per_inch(png_ptr, - info_ptr) - res_x_and_y = png_get_pixels_per_inch(png_ptr, - info_ptr) - aspect_ratio = png_get_pixel_aspect_ratio(png_ptr, - info_ptr) - - (Each of these returns 0 [signifying "unknown"] if - the data is not present or if res_x is 0; - res_x_and_y is 0 if res_x != res_y) - -The data from the oFFs chunk can be retrieved in several convenient -forms: - - x_offset = png_get_x_offset_microns(png_ptr, info_ptr); - y_offset = png_get_y_offset_microns(png_ptr, info_ptr); - x_offset = png_get_x_offset_inches(png_ptr, info_ptr); - y_offset = png_get_y_offset_inches(png_ptr, info_ptr); - - (Each of these returns 0 [signifying "unknown" if both - x and y are 0] if the data is not present or if the - chunk is present but the unit is the pixel) - -For more information, see the png_info definition in png.h and the -PNG specification for chunk contents. Be careful with trusting -rowbytes, as some of the transformations could increase the space -needed to hold a row (expand, filler, gray_to_rgb, etc.). -See png_read_update_info(), below. - -A quick word about text_ptr and num_text. PNG stores comments in -keyword/text pairs, one pair per chunk, with no limit on the number -of text chunks, and a 2^31 byte limit on their size. While there are -suggested keywords, there is no requirement to restrict the use to these -strings. It is strongly suggested that keywords and text be sensible -to humans (that's the point), so don't use abbreviations. Non-printing -symbols are not allowed. See the PNG specification for more details. -There is also no requirement to have text after the keyword. - -Keywords should be limited to 79 Latin-1 characters without leading or -trailing spaces, but non-consecutive spaces are allowed within the -keyword. It is possible to have the same keyword any number of times. -The text_ptr is an array of png_text structures, each holding a -pointer to a language string, a pointer to a keyword and a pointer to -a text string. The text string, language code, and translated -keyword may be empty or NULL pointers. The keyword/text -pairs are put into the array in the order that they are received. -However, some or all of the text chunks may be after the image, so, to -make sure you have read all the text chunks, don't mess with these -until after you read the stuff after the image. This will be -mentioned again below in the discussion that goes with png_read_end(). - -Input transformations - -After you've read the header information, you can set up the library -to handle any special transformations of the image data. The various -ways to transform the data will be described in the order that they -should occur. This is important, as some of these change the color -type and/or bit depth of the data, and some others only work on -certain color types and bit depths. Even though each transformation -checks to see if it has data that it can do something with, you should -make sure to only enable a transformation if it will be valid for the -data. For example, don't swap red and blue on grayscale data. - -The colors used for the background and transparency values should be -supplied in the same format/depth as the current image data. They -are stored in the same format/depth as the image data in a bKGD or tRNS -chunk, so this is what libpng expects for this data. The colors are -transformed to keep in sync with the image data when an application -calls the png_read_update_info() routine (see below). - -Data will be decoded into the supplied row buffers packed into bytes -unless the library has been told to transform it into another format. -For example, 4 bit/pixel paletted or grayscale data will be returned -2 pixels/byte with the leftmost pixel in the high-order bits of the -byte, unless png_set_packing() is called. 8-bit RGB data will be stored -in RGB RGB RGB format unless png_set_filler() or png_set_add_alpha() -is called to insert filler bytes, either before or after each RGB triplet. -16-bit RGB data will be returned RRGGBB RRGGBB, with the most significant -byte of the color value first, unless png_set_strip_16() is called to -transform it to regular RGB RGB triplets, or png_set_filler() or -png_set_add alpha() is called to insert filler bytes, either before or -after each RRGGBB triplet. Similarly, 8-bit or 16-bit grayscale data can -be modified with -png_set_filler(), png_set_add_alpha(), or png_set_strip_16(). - -The following code transforms grayscale images of less than 8 to 8 bits, -changes paletted images to RGB, and adds a full alpha channel if there is -transparency information in a tRNS chunk. This is most useful on -grayscale images with bit depths of 2 or 4 or if there is a multiple-image -viewing application that wishes to treat all images in the same way. - - if (color_type == PNG_COLOR_TYPE_PALETTE) - png_set_palette_to_rgb(png_ptr); - - if (color_type == PNG_COLOR_TYPE_GRAY && - bit_depth < 8) png_set_expand_gray_1_2_4_to_8(png_ptr); - - if (png_get_valid(png_ptr, info_ptr, - PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png_ptr); - -These three functions are actually aliases for png_set_expand(), added -in libpng version 1.0.4, with the function names expanded to improve code -readability. In some future version they may actually do different -things. - -As of libpng version 1.2.9, png_set_expand_gray_1_2_4_to_8() was -added. It expands the sample depth without changing tRNS to alpha. -At the same time, png_set_gray_1_2_4_to_8() was deprecated, and it -will be removed from a future version. - -PNG can have files with 16 bits per channel. If you only can handle -8 bits per channel, this will strip the pixels down to 8 bit. - - if (bit_depth == 16) - png_set_strip_16(png_ptr); - -If, for some reason, you don't need the alpha channel on an image, -and you want to remove it rather than combining it with the background -(but the image author certainly had in mind that you *would* combine -it with the background, so that's what you should probably do): - - if (color_type & PNG_COLOR_MASK_ALPHA) - png_set_strip_alpha(png_ptr); - -In PNG files, the alpha channel in an image -is the level of opacity. If you need the alpha channel in an image to -be the level of transparency instead of opacity, you can invert the -alpha channel (or the tRNS chunk data) after it's read, so that 0 is -fully opaque and 255 (in 8-bit or paletted images) or 65535 (in 16-bit -images) is fully transparent, with - - png_set_invert_alpha(png_ptr); - -PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as -they can, resulting in, for example, 8 pixels per byte for 1 bit -files. This code expands to 1 pixel per byte without changing the -values of the pixels: - - if (bit_depth < 8) - png_set_packing(png_ptr); - -PNG files have possible bit depths of 1, 2, 4, 8, and 16. All pixels -stored in a PNG image have been "scaled" or "shifted" up to the next -higher possible bit depth (e.g. from 5 bits/sample in the range [0,31] to -8 bits/sample in the range [0, 255]). However, it is also possible to -convert the PNG pixel data back to the original bit depth of the image. -This call reduces the pixels back down to the original bit depth: - - png_color_8p sig_bit; - - if (png_get_sBIT(png_ptr, info_ptr, &sig_bit)) - png_set_shift(png_ptr, sig_bit); - -PNG files store 3-color pixels in red, green, blue order. This code -changes the storage of the pixels to blue, green, red: - - if (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_RGB_ALPHA) - png_set_bgr(png_ptr); - -PNG files store RGB pixels packed into 3 or 6 bytes. This code expands them -into 4 or 8 bytes for windowing systems that need them in this format: - - if (color_type == PNG_COLOR_TYPE_RGB) - png_set_filler(png_ptr, filler, PNG_FILLER_BEFORE); - -where "filler" is the 8 or 16-bit number to fill with, and the location is -either PNG_FILLER_BEFORE or PNG_FILLER_AFTER, depending upon whether -you want the filler before the RGB or after. This transformation -does not affect images that already have full alpha channels. To add an -opaque alpha channel, use filler=0xff or 0xffff and PNG_FILLER_AFTER which -will generate RGBA pixels. - -Note that png_set_filler() does not change the color type. If you want -to do that, you can add a true alpha channel with - - if (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_GRAY) - png_set_add_alpha(png_ptr, filler, PNG_FILLER_AFTER); - -where "filler" contains the alpha value to assign to each pixel. -This function was added in libpng-1.2.7. - -If you are reading an image with an alpha channel, and you need the -data as ARGB instead of the normal PNG format RGBA: - - if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) - png_set_swap_alpha(png_ptr); - -For some uses, you may want a grayscale image to be represented as -RGB. This code will do that conversion: - - if (color_type == PNG_COLOR_TYPE_GRAY || - color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_gray_to_rgb(png_ptr); - -Conversely, you can convert an RGB or RGBA image to grayscale or grayscale -with alpha. - - if (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_RGB_ALPHA) - png_set_rgb_to_gray_fixed(png_ptr, error_action, - int red_weight, int green_weight); - - error_action = 1: silently do the conversion - error_action = 2: issue a warning if the original - image has any pixel where - red != green or red != blue - error_action = 3: issue an error and abort the - conversion if the original - image has any pixel where - red != green or red != blue - - red_weight: weight of red component times 100000 - green_weight: weight of green component times 100000 - If either weight is negative, default - weights (21268, 71514) are used. - -If you have set error_action = 1 or 2, you can -later check whether the image really was gray, after processing -the image rows, with the png_get_rgb_to_gray_status(png_ptr) function. -It will return a png_byte that is zero if the image was gray or -1 if there were any non-gray pixels. bKGD and sBIT data -will be silently converted to grayscale, using the green channel -data, regardless of the error_action setting. - -With red_weight+green_weight<=100000, -the normalized graylevel is computed: - - int rw = red_weight * 65536; - int gw = green_weight * 65536; - int bw = 65536 - (rw + gw); - gray = (rw*red + gw*green + bw*blue)/65536; - -The default values approximate those recommended in the Charles -Poynton's Color FAQ, <http://www.inforamp.net/~poynton/> -Copyright (c) 1998-01-04 Charles Poynton <poynton at inforamp.net> - - Y = 0.212671 * R + 0.715160 * G + 0.072169 * B - -Libpng approximates this with - - Y = 0.21268 * R + 0.7151 * G + 0.07217 * B - -which can be expressed with integers as - - Y = (6969 * R + 23434 * G + 2365 * B)/32768 - -The calculation is done in a linear colorspace, if the image gamma -is known. - -If you have a grayscale and you are using png_set_expand_depth(), -png_set_expand(), or png_set_gray_to_rgb to change to truecolor or to -a higher bit-depth, you must either supply the background color as a gray -value at the original file bit-depth (need_expand = 1) or else supply the -background color as an RGB triplet at the final, expanded bit depth -(need_expand = 0). Similarly, if you are reading a paletted image, you -must either supply the background color as a palette index (need_expand = 1) -or as an RGB triplet that may or may not be in the palette (need_expand = 0). - - png_color_16 my_background; - png_color_16p image_background; - - if (png_get_bKGD(png_ptr, info_ptr, &image_background)) - png_set_background(png_ptr, image_background, - PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); - else - png_set_background(png_ptr, &my_background, - PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); - -The png_set_background() function tells libpng to composite images -with alpha or simple transparency against the supplied background -color. If the PNG file contains a bKGD chunk (PNG_INFO_bKGD valid), -you may use this color, or supply another color more suitable for -the current display (e.g., the background color from a web page). You -need to tell libpng whether the color is in the gamma space of the -display (PNG_BACKGROUND_GAMMA_SCREEN for colors you supply), the file -(PNG_BACKGROUND_GAMMA_FILE for colors from the bKGD chunk), or one -that is neither of these gammas (PNG_BACKGROUND_GAMMA_UNIQUE - I don't -know why anyone would use this, but it's here). - -To properly display PNG images on any kind of system, the application needs -to know what the display gamma is. Ideally, the user will know this, and -the application will allow them to set it. One method of allowing the user -to set the display gamma separately for each system is to check for a -SCREEN_GAMMA or DISPLAY_GAMMA environment variable, which will hopefully be -correctly set. - -Note that display_gamma is the overall gamma correction required to produce -pleasing results, which depends on the lighting conditions in the surrounding -environment. In a dim or brightly lit room, no compensation other than -the physical gamma exponent of the monitor is needed, while in a dark room -a slightly smaller exponent is better. - - double gamma, screen_gamma; - - if (/* We have a user-defined screen - gamma value */) - { - screen_gamma = user_defined_screen_gamma; - } - /* One way that applications can share the same - screen gamma value */ - else if ((gamma_str = getenv("SCREEN_GAMMA")) - != NULL) - { - screen_gamma = (double)atof(gamma_str); - } - /* If we don't have another value */ - else - { - screen_gamma = 2.2; /* A good guess for a - PC monitor in a bright office or a dim room */ - screen_gamma = 2.0; /* A good guess for a - PC monitor in a dark room */ - screen_gamma = 1.7 or 1.0; /* A good - guess for Mac systems */ - } - -The png_set_gamma() function handles gamma transformations of the data. -Pass both the file gamma and the current screen_gamma. If the file does -not have a gamma value, you can pass one anyway if you have an idea what -it is (usually 0.45455 is a good guess for GIF images on PCs). Note -that file gammas are inverted from screen gammas. See the discussions -on gamma in the PNG specification for an excellent description of what -gamma is, and why all applications should support it. It is strongly -recommended that PNG viewers support gamma correction. - - if (png_get_gAMA(png_ptr, info_ptr, &gamma)) - png_set_gamma(png_ptr, screen_gamma, gamma); - else - png_set_gamma(png_ptr, screen_gamma, 0.45455); - -If you need to reduce an RGB file to a paletted file, or if a paletted -file has more entries then will fit on your screen, png_set_dither() -will do that. Note that this is a simple match dither that merely -finds the closest color available. This should work fairly well with -optimized palettes, and fairly badly with linear color cubes. If you -pass a palette that is larger then maximum_colors, the file will -reduce the number of colors in the palette so it will fit into -maximum_colors. If there is a histogram, it will use it to make -more intelligent choices when reducing the palette. If there is no -histogram, it may not do as good a job. - - if (color_type & PNG_COLOR_MASK_COLOR) - { - if (png_get_valid(png_ptr, info_ptr, - PNG_INFO_PLTE)) - { - png_uint_16p histogram = NULL; - - png_get_hIST(png_ptr, info_ptr, - &histogram); - png_set_dither(png_ptr, palette, num_palette, - max_screen_colors, histogram, 1); - } - else - { - png_color std_color_cube[MAX_SCREEN_COLORS] = - { ... colors ... }; - - png_set_dither(png_ptr, std_color_cube, - MAX_SCREEN_COLORS, MAX_SCREEN_COLORS, - NULL,0); - } - } - -PNG files describe monochrome as black being zero and white being one. -The following code will reverse this (make black be one and white be -zero): - - if (bit_depth == 1 && color_type == PNG_COLOR_TYPE_GRAY) - png_set_invert_mono(png_ptr); - -This function can also be used to invert grayscale and gray-alpha images: - - if (color_type == PNG_COLOR_TYPE_GRAY || - color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_invert_mono(png_ptr); - -PNG files store 16 bit pixels in network byte order (big-endian, -ie. most significant bits first). This code changes the storage to the -other way (little-endian, i.e. least significant bits first, the -way PCs store them): - - if (bit_depth == 16) - png_set_swap(png_ptr); - -If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you -need to change the order the pixels are packed into bytes, you can use: - - if (bit_depth < 8) - png_set_packswap(png_ptr); - -Finally, you can write your own transformation function if none of -the existing ones meets your needs. This is done by setting a callback -with - - png_set_read_user_transform_fn(png_ptr, - read_transform_fn); - -You must supply the function - - void read_transform_fn(png_ptr ptr, row_info_ptr - row_info, png_bytep data) - -See pngtest.c for a working example. Your function will be called -after all of the other transformations have been processed. - -You can also set up a pointer to a user structure for use by your -callback function, and you can inform libpng that your transform -function will change the number of channels or bit depth with the -function - - png_set_user_transform_info(png_ptr, user_ptr, - user_depth, user_channels); - -The user's application, not libpng, is responsible for allocating and -freeing any memory required for the user structure. - -You can retrieve the pointer via the function -png_get_user_transform_ptr(). For example: - - voidp read_user_transform_ptr = - png_get_user_transform_ptr(png_ptr); - -The last thing to handle is interlacing; this is covered in detail below, -but you must call the function here if you want libpng to handle expansion -of the interlaced image. - - number_of_passes = png_set_interlace_handling(png_ptr); - -After setting the transformations, libpng can update your png_info -structure to reflect any transformations you've requested with this -call. This is most useful to update the info structure's rowbytes -field so you can use it to allocate your image memory. This function -will also update your palette with the correct screen_gamma and -background if these have been given with the calls above. - - png_read_update_info(png_ptr, info_ptr); - -After you call png_read_update_info(), you can allocate any -memory you need to hold the image. The row data is simply -raw byte data for all forms of images. As the actual allocation -varies among applications, no example will be given. If you -are allocating one large chunk, you will need to build an -array of pointers to each row, as it will be needed for some -of the functions below. - -Reading image data - -After you've allocated memory, you can read the image data. -The simplest way to do this is in one function call. If you are -allocating enough memory to hold the whole image, you can just -call png_read_image() and libpng will read in all the image data -and put it in the memory area supplied. You will need to pass in -an array of pointers to each row. - -This function automatically handles interlacing, so you don't need -to call png_set_interlace_handling() or call this function multiple -times, or any of that other stuff necessary with png_read_rows(). - - png_read_image(png_ptr, row_pointers); - -where row_pointers is: - - png_bytep row_pointers[height]; - -You can point to void or char or whatever you use for pixels. - -If you don't want to read in the whole image at once, you can -use png_read_rows() instead. If there is no interlacing (check -interlace_type == PNG_INTERLACE_NONE), this is simple: - - png_read_rows(png_ptr, row_pointers, NULL, - number_of_rows); - -where row_pointers is the same as in the png_read_image() call. - -If you are doing this just one row at a time, you can do this with -a single row_pointer instead of an array of row_pointers: - - png_bytep row_pointer = row; - png_read_row(png_ptr, row_pointer, NULL); - -If the file is interlaced (interlace_type != 0 in the IHDR chunk), things -get somewhat harder. The only current (PNG Specification version 1.2) -interlacing type for PNG is (interlace_type == PNG_INTERLACE_ADAM7) -is a somewhat complicated 2D interlace scheme, known as Adam7, that -breaks down an image into seven smaller images of varying size, based -on an 8x8 grid. - -libpng can fill out those images or it can give them to you "as is". -If you want them filled out, there are two ways to do that. The one -mentioned in the PNG specification is to expand each pixel to cover -those pixels that have not been read yet (the "rectangle" method). -This results in a blocky image for the first pass, which gradually -smooths out as more pixels are read. The other method is the "sparkle" -method, where pixels are drawn only in their final locations, with the -rest of the image remaining whatever colors they were initialized to -before the start of the read. The first method usually looks better, -but tends to be slower, as there are more pixels to put in the rows. - -If you don't want libpng to handle the interlacing details, just call -png_read_rows() seven times to read in all seven images. Each of the -images is a valid image by itself, or they can all be combined on an -8x8 grid to form a single image (although if you intend to combine them -you would be far better off using the libpng interlace handling). - -The first pass will return an image 1/8 as wide as the entire image -(every 8th column starting in column 0) and 1/8 as high as the original -(every 8th row starting in row 0), the second will be 1/8 as wide -(starting in column 4) and 1/8 as high (also starting in row 0). The -third pass will be 1/4 as wide (every 4th pixel starting in column 0) and -1/8 as high (every 8th row starting in row 4), and the fourth pass will -be 1/4 as wide and 1/4 as high (every 4th column starting in column 2, -and every 4th row starting in row 0). The fifth pass will return an -image 1/2 as wide, and 1/4 as high (starting at column 0 and row 2), -while the sixth pass will be 1/2 as wide and 1/2 as high as the original -(starting in column 1 and row 0). The seventh and final pass will be as -wide as the original, and 1/2 as high, containing all of the odd -numbered scanlines. Phew! - -If you want libpng to expand the images, call this before calling -png_start_read_image() or png_read_update_info(): - - if (interlace_type == PNG_INTERLACE_ADAM7) - number_of_passes - = png_set_interlace_handling(png_ptr); - -This will return the number of passes needed. Currently, this -is seven, but may change if another interlace type is added. -This function can be called even if the file is not interlaced, -where it will return one pass. - -If you are not going to display the image after each pass, but are -going to wait until the entire image is read in, use the sparkle -effect. This effect is faster and the end result of either method -is exactly the same. If you are planning on displaying the image -after each pass, the "rectangle" effect is generally considered the -better looking one. - -If you only want the "sparkle" effect, just call png_read_rows() as -normal, with the third parameter NULL. Make sure you make pass over -the image number_of_passes times, and you don't change the data in the -rows between calls. You can change the locations of the data, just -not the data. Each pass only writes the pixels appropriate for that -pass, and assumes the data from previous passes is still valid. - - png_read_rows(png_ptr, row_pointers, NULL, - number_of_rows); - -If you only want the first effect (the rectangles), do the same as -before except pass the row buffer in the third parameter, and leave -the second parameter NULL. - - png_read_rows(png_ptr, NULL, row_pointers, - number_of_rows); - -Finishing a sequential read - -After you are finished reading the image through the -low-level interface, you can finish reading the file. If you are -interested in comments or time, which may be stored either before or -after the image data, you should pass the separate png_info struct if -you want to keep the comments from before and after the image -separate. If you are not interested, you can pass NULL. - - png_read_end(png_ptr, end_info); - -When you are done, you can free all memory allocated by libpng like this: - - png_destroy_read_struct(&png_ptr, &info_ptr, - &end_info); - -It is also possible to individually free the info_ptr members that -point to libpng-allocated storage with the following function: - - png_free_data(png_ptr, info_ptr, mask, seq) - mask - identifies data to be freed, a mask - containing the bitwise OR of one or - more of - PNG_FREE_PLTE, PNG_FREE_TRNS, - PNG_FREE_HIST, PNG_FREE_ICCP, - PNG_FREE_PCAL, PNG_FREE_ROWS, - PNG_FREE_SCAL, PNG_FREE_SPLT, - PNG_FREE_TEXT, PNG_FREE_UNKN, - or simply PNG_FREE_ALL - seq - sequence number of item to be freed - (-1 for all items) - -This function may be safely called when the relevant storage has -already been freed, or has not yet been allocated, or was allocated -by the user and not by libpng, and will in those -cases do nothing. The "seq" parameter is ignored if only one item -of the selected data type, such as PLTE, is allowed. If "seq" is not --1, and multiple items are allowed for the data type identified in -the mask, such as text or sPLT, only the n'th item in the structure -is freed, where n is "seq". - -The default behavior is only to free data that was allocated internally -by libpng. This can be changed, so that libpng will not free the data, -or so that it will free data that was allocated by the user with png_malloc() -or png_zalloc() and passed in via a png_set_*() function, with - - png_data_freer(png_ptr, info_ptr, freer, mask) - mask - which data elements are affected - same choices as in png_free_data() - freer - one of - PNG_DESTROY_WILL_FREE_DATA - PNG_SET_WILL_FREE_DATA - PNG_USER_WILL_FREE_DATA - -This function only affects data that has already been allocated. -You can call this function after reading the PNG data but before calling -any png_set_*() functions, to control whether the user or the png_set_*() -function is responsible for freeing any existing data that might be present, -and again after the png_set_*() functions to control whether the user -or png_destroy_*() is supposed to free the data. When the user assumes -responsibility for libpng-allocated data, the application must use -png_free() to free it, and when the user transfers responsibility to libpng -for data that the user has allocated, the user must have used png_malloc() -or png_zalloc() to allocate it. - -If you allocated your row_pointers in a single block, as suggested above in -the description of the high level read interface, you must not transfer -responsibility for freeing it to the png_set_rows or png_read_destroy function, -because they would also try to free the individual row_pointers[i]. - -If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword -separately, do not transfer responsibility for freeing text_ptr to libpng, -because when libpng fills a png_text structure it combines these members with -the key member, and png_free_data() will free only text_ptr.key. Similarly, -if you transfer responsibility for free'ing text_ptr from libpng to your -application, your application must not separately free those members. - -The png_free_data() function will turn off the "valid" flag for anything -it frees. If you need to turn the flag off for a chunk that was freed by your -application instead of by libpng, you can use - - png_set_invalid(png_ptr, info_ptr, mask); - mask - identifies the chunks to be made invalid, - containing the bitwise OR of one or - more of - PNG_INFO_gAMA, PNG_INFO_sBIT, - PNG_INFO_cHRM, PNG_INFO_PLTE, - PNG_INFO_tRNS, PNG_INFO_bKGD, - PNG_INFO_hIST, PNG_INFO_pHYs, - PNG_INFO_oFFs, PNG_INFO_tIME, - PNG_INFO_pCAL, PNG_INFO_sRGB, - PNG_INFO_iCCP, PNG_INFO_sPLT, - PNG_INFO_sCAL, PNG_INFO_IDAT - -For a more compact example of reading a PNG image, see the file example.c. - -Reading PNG files progressively - -The progressive reader is slightly different then the non-progressive -reader. Instead of calling png_read_info(), png_read_rows(), and -png_read_end(), you make one call to png_process_data(), which calls -callbacks when it has the info, a row, or the end of the image. You -set up these callbacks with png_set_progressive_read_fn(). You don't -have to worry about the input/output functions of libpng, as you are -giving the library the data directly in png_process_data(). I will -assume that you have read the section on reading PNG files above, -so I will only highlight the differences (although I will show -all of the code). - -png_structp png_ptr; -png_infop info_ptr; - - /* An example code fragment of how you would - initialize the progressive reader in your - application. */ - int - initialize_png_reader() - { - png_ptr = png_create_read_struct - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn); - if (!png_ptr) - return (ERROR); - info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - png_destroy_read_struct(&png_ptr, (png_infopp)NULL, - (png_infopp)NULL); - return (ERROR); - } - - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, - (png_infopp)NULL); - return (ERROR); - } - - /* This one's new. You can provide functions - to be called when the header info is valid, - when each row is completed, and when the image - is finished. If you aren't using all functions, - you can specify NULL parameters. Even when all - three functions are NULL, you need to call - png_set_progressive_read_fn(). You can use - any struct as the user_ptr (cast to a void pointer - for the function call), and retrieve the pointer - from inside the callbacks using the function - - png_get_progressive_ptr(png_ptr); - - which will return a void pointer, which you have - to cast appropriately. - */ - png_set_progressive_read_fn(png_ptr, (void *)user_ptr, - info_callback, row_callback, end_callback); - - return 0; - } - - /* A code fragment that you call as you receive blocks - of data */ - int - process_data(png_bytep buffer, png_uint_32 length) - { - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, - (png_infopp)NULL); - return (ERROR); - } - - /* This one's new also. Simply give it a chunk - of data from the file stream (in order, of - course). On machines with segmented memory - models machines, don't give it any more than - 64K. The library seems to run fine with sizes - of 4K. Although you can give it much less if - necessary (I assume you can give it chunks of - 1 byte, I haven't tried less then 256 bytes - yet). When this function returns, you may - want to display any rows that were generated - in the row callback if you don't already do - so there. - */ - png_process_data(png_ptr, info_ptr, buffer, length); - return 0; - } - - /* This function is called (as set by - png_set_progressive_read_fn() above) when enough data - has been supplied so all of the header has been - read. - */ - void - info_callback(png_structp png_ptr, png_infop info) - { - /* Do any setup here, including setting any of - the transformations mentioned in the Reading - PNG files section. For now, you _must_ call - either png_start_read_image() or - png_read_update_info() after all the - transformations are set (even if you don't set - any). You may start getting rows before - png_process_data() returns, so this is your - last chance to prepare for that. - */ - } - - /* This function is called when each row of image - data is complete */ - void - row_callback(png_structp png_ptr, png_bytep new_row, - png_uint_32 row_num, int pass) - { - /* If the image is interlaced, and you turned - on the interlace handler, this function will - be called for every row in every pass. Some - of these rows will not be changed from the - previous pass. When the row is not changed, - the new_row variable will be NULL. The rows - and passes are called in order, so you don't - really need the row_num and pass, but I'm - supplying them because it may make your life - easier. - - For the non-NULL rows of interlaced images, - you must call png_progressive_combine_row() - passing in the row and the old row. You can - call this function for NULL rows (it will just - return) and for non-interlaced images (it just - does the memcpy for you) if it will make the - code easier. Thus, you can just do this for - all cases: - */ - - png_progressive_combine_row(png_ptr, old_row, - new_row); - - /* where old_row is what was displayed for - previously for the row. Note that the first - pass (pass == 0, really) will completely cover - the old row, so the rows do not have to be - initialized. After the first pass (and only - for interlaced images), you will have to pass - the current row, and the function will combine - the old row and the new row. - */ - } - - void - end_callback(png_structp png_ptr, png_infop info) - { - /* This function is called after the whole image - has been read, including any chunks after the - image (up to and including the IEND). You - will usually have the same info chunk as you - had in the header, although some data may have - been added to the comments and time fields. - - Most people won't do much here, perhaps setting - a flag that marks the image as finished. - */ - } - - - -IV. Writing - -Much of this is very similar to reading. However, everything of -importance is repeated here, so you won't have to constantly look -back up in the reading section to understand writing. - -Setup - -You will want to do the I/O initialization before you get into libpng, -so if it doesn't work, you don't have anything to undo. If you are not -using the standard I/O functions, you will need to replace them with -custom writing functions. See the discussion under Customizing libpng. - - FILE *fp = fopen(file_name, "wb"); - if (!fp) - { - return (ERROR); - } - -Next, png_struct and png_info need to be allocated and initialized. -As these can be both relatively large, you may not want to store these -on the stack, unless you have stack space to spare. Of course, you -will want to check if they return NULL. If you are also reading, -you won't want to name your read structure and your write structure -both "png_ptr"; you can call them anything you like, such as -"read_ptr" and "write_ptr". Look at pngtest.c, for example. - - png_structp png_ptr = png_create_write_struct - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn); - if (!png_ptr) - return (ERROR); - - png_infop info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - png_destroy_write_struct(&png_ptr, - (png_infopp)NULL); - return (ERROR); - } - -If you want to use your own memory allocation routines, -define PNG_USER_MEM_SUPPORTED and use -png_create_write_struct_2() instead of png_create_write_struct(): - - png_structp png_ptr = png_create_write_struct_2 - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn, (png_voidp) - user_mem_ptr, user_malloc_fn, user_free_fn); - -After you have these structures, you will need to set up the -error handling. When libpng encounters an error, it expects to -longjmp() back to your routine. Therefore, you will need to call -setjmp() and pass the png_jmpbuf(png_ptr). If you -write the file from different routines, you will need to update -the png_jmpbuf(png_ptr) every time you enter a new routine that will -call a png_*() function. See your documentation of setjmp/longjmp -for your compiler for more information on setjmp/longjmp. See -the discussion on libpng error handling in the Customizing Libpng -section below for more information on the libpng error handling. - - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_write_struct(&png_ptr, &info_ptr); - fclose(fp); - return (ERROR); - } - ... - return; - -If you would rather avoid the complexity of setjmp/longjmp issues, -you can compile libpng with PNG_SETJMP_NOT_SUPPORTED, in which case -errors will result in a call to PNG_ABORT() which defaults to abort(). - -Now you need to set up the output code. The default for libpng is to -use the C function fwrite(). If you use this, you will need to pass a -valid FILE * in the function png_init_io(). Be sure that the file is -opened in binary mode. Again, if you wish to handle writing data in -another way, see the discussion on libpng I/O handling in the Customizing -Libpng section below. - - png_init_io(png_ptr, fp); - -If you are embedding your PNG into a datastream such as MNG, and don't -want libpng to write the 8-byte signature, or if you have already -written the signature in your application, use - - png_set_sig_bytes(png_ptr, 8); - -to inform libpng that it should not write a signature. - -Write callbacks - -At this point, you can set up a callback function that will be -called after each row has been written, which you can use to control -a progress meter or the like. It's demonstrated in pngtest.c. -You must supply a function - - void write_row_callback(png_ptr, png_uint_32 row, - int pass); - { - /* put your code here */ - } - -(You can give it another name that you like instead of "write_row_callback") - -To inform libpng about your function, use - - png_set_write_status_fn(png_ptr, write_row_callback); - -You now have the option of modifying how the compression library will -run. The following functions are mainly for testing, but may be useful -in some cases, like if you need to write PNG files extremely fast and -are willing to give up some compression, or if you want to get the -maximum possible compression at the expense of slower writing. If you -have no special needs in this area, let the library do what it wants by -not calling this function at all, as it has been tuned to deliver a good -speed/compression ratio. The second parameter to png_set_filter() is -the filter method, for which the only valid values are 0 (as of the -July 1999 PNG specification, version 1.2) or 64 (if you are writing -a PNG datastream that is to be embedded in a MNG datastream). The third -parameter is a flag that indicates which filter type(s) are to be tested -for each scanline. See the PNG specification for details on the specific filter -types. - - - /* turn on or off filtering, and/or choose - specific filters. You can use either a single - PNG_FILTER_VALUE_NAME or the bitwise OR of one - or more PNG_FILTER_NAME masks. */ - png_set_filter(png_ptr, 0, - PNG_FILTER_NONE | PNG_FILTER_VALUE_NONE | - PNG_FILTER_SUB | PNG_FILTER_VALUE_SUB | - PNG_FILTER_UP | PNG_FILTER_VALUE_UP | - PNG_FILTER_AVE | PNG_FILTER_VALUE_AVE | - PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH| - PNG_ALL_FILTERS); - -If an application -wants to start and stop using particular filters during compression, -it should start out with all of the filters (to ensure that the previous -row of pixels will be stored in case it's needed later), and then add -and remove them after the start of compression. - -If you are writing a PNG datastream that is to be embedded in a MNG -datastream, the second parameter can be either 0 or 64. - -The png_set_compression_*() functions interface to the zlib compression -library, and should mostly be ignored unless you really know what you are -doing. The only generally useful call is png_set_compression_level() -which changes how much time zlib spends on trying to compress the image -data. See the Compression Library (zlib.h and algorithm.txt, distributed -with zlib) for details on the compression levels. - - /* set the zlib compression level */ - png_set_compression_level(png_ptr, - Z_BEST_COMPRESSION); - - /* set other zlib parameters */ - png_set_compression_mem_level(png_ptr, 8); - png_set_compression_strategy(png_ptr, - Z_DEFAULT_STRATEGY); - png_set_compression_window_bits(png_ptr, 15); - png_set_compression_method(png_ptr, 8); - png_set_compression_buffer_size(png_ptr, 8192) - -extern PNG_EXPORT(void,png_set_zbuf_size) - -Setting the contents of info for output - -You now need to fill in the png_info structure with all the data you -wish to write before the actual image. Note that the only thing you -are allowed to write after the image is the text chunks and the time -chunk (as of PNG Specification 1.2, anyway). See png_write_end() and -the latest PNG specification for more information on that. If you -wish to write them before the image, fill them in now, and flag that -data as being valid. If you want to wait until after the data, don't -fill them until png_write_end(). For all the fields in png_info and -their data types, see png.h. For explanations of what the fields -contain, see the PNG specification. - -Some of the more important parts of the png_info are: - - png_set_IHDR(png_ptr, info_ptr, width, height, - bit_depth, color_type, interlace_type, - compression_type, filter_method) - width - holds the width of the image - in pixels (up to 2^31). - height - holds the height of the image - in pixels (up to 2^31). - bit_depth - holds the bit depth of one of the - image channels. - (valid values are 1, 2, 4, 8, 16 - and depend also on the - color_type. See also significant - bits (sBIT) below). - color_type - describes which color/alpha - channels are present. - PNG_COLOR_TYPE_GRAY - (bit depths 1, 2, 4, 8, 16) - PNG_COLOR_TYPE_GRAY_ALPHA - (bit depths 8, 16) - PNG_COLOR_TYPE_PALETTE - (bit depths 1, 2, 4, 8) - PNG_COLOR_TYPE_RGB - (bit_depths 8, 16) - PNG_COLOR_TYPE_RGB_ALPHA - (bit_depths 8, 16) - - PNG_COLOR_MASK_PALETTE - PNG_COLOR_MASK_COLOR - PNG_COLOR_MASK_ALPHA - - interlace_type - PNG_INTERLACE_NONE or - PNG_INTERLACE_ADAM7 - compression_type - (must be - PNG_COMPRESSION_TYPE_DEFAULT) - filter_method - (must be PNG_FILTER_TYPE_DEFAULT - or, if you are writing a PNG to - be embedded in a MNG datastream, - can also be - PNG_INTRAPIXEL_DIFFERENCING) - - png_set_PLTE(png_ptr, info_ptr, palette, - num_palette); - palette - the palette for the file - (array of png_color) - num_palette - number of entries in the palette - - png_set_gAMA(png_ptr, info_ptr, gamma); - gamma - the gamma the image was created - at (PNG_INFO_gAMA) - - png_set_sRGB(png_ptr, info_ptr, srgb_intent); - srgb_intent - the rendering intent - (PNG_INFO_sRGB) The presence of - the sRGB chunk means that the pixel - data is in the sRGB color space. - This chunk also implies specific - values of gAMA and cHRM. Rendering - intent is the CSS-1 property that - has been defined by the International - Color Consortium - (http://www.color.org). - It can be one of - PNG_sRGB_INTENT_SATURATION, - PNG_sRGB_INTENT_PERCEPTUAL, - PNG_sRGB_INTENT_ABSOLUTE, or - PNG_sRGB_INTENT_RELATIVE. - - - png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, - srgb_intent); - srgb_intent - the rendering intent - (PNG_INFO_sRGB) The presence of the - sRGB chunk means that the pixel - data is in the sRGB color space. - This function also causes gAMA and - cHRM chunks with the specific values - that are consistent with sRGB to be - written. - - png_set_iCCP(png_ptr, info_ptr, name, compression_type, - profile, proflen); - name - The profile name. - compression - The compression type; always - PNG_COMPRESSION_TYPE_BASE for PNG 1.0. - You may give NULL to this argument to - ignore it. - profile - International Color Consortium color - profile data. May contain NULs. - proflen - length of profile data in bytes. - - png_set_sBIT(png_ptr, info_ptr, sig_bit); - sig_bit - the number of significant bits for - (PNG_INFO_sBIT) each of the gray, red, - green, and blue channels, whichever are - appropriate for the given color type - (png_color_16) - - png_set_tRNS(png_ptr, info_ptr, trans, num_trans, - trans_values); - trans - array of transparent entries for - palette (PNG_INFO_tRNS) - trans_values - graylevel or color sample values of - the single transparent color for - non-paletted images (PNG_INFO_tRNS) - num_trans - number of transparent entries - (PNG_INFO_tRNS) - - png_set_hIST(png_ptr, info_ptr, hist); - (PNG_INFO_hIST) - hist - histogram of palette (array of - png_uint_16) - - png_set_tIME(png_ptr, info_ptr, mod_time); - mod_time - time image was last modified - (PNG_VALID_tIME) - - png_set_bKGD(png_ptr, info_ptr, background); - background - background color (PNG_VALID_bKGD) - - png_set_text(png_ptr, info_ptr, text_ptr, num_text); - text_ptr - array of png_text holding image - comments - text_ptr[i].compression - type of compression used - on "text" PNG_TEXT_COMPRESSION_NONE - PNG_TEXT_COMPRESSION_zTXt - PNG_ITXT_COMPRESSION_NONE - PNG_ITXT_COMPRESSION_zTXt - text_ptr[i].key - keyword for comment. Must contain - 1-79 characters. - text_ptr[i].text - text comments for current - keyword. Can be NULL or empty. - text_ptr[i].text_length - length of text string, - after decompression, 0 for iTXt - text_ptr[i].itxt_length - length of itxt string, - after decompression, 0 for tEXt/zTXt - text_ptr[i].lang - language of comment (NULL or - empty for unknown). - text_ptr[i].translated_keyword - keyword in UTF-8 (NULL - or empty for unknown). - num_text - number of comments - - png_set_sPLT(png_ptr, info_ptr, &palette_ptr, - num_spalettes); - palette_ptr - array of png_sPLT_struct structures - to be added to the list of palettes - in the info structure. - num_spalettes - number of palette structures to be - added. - - png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y, - unit_type); - offset_x - positive offset from the left - edge of the screen - offset_y - positive offset from the top - edge of the screen - unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER - - png_set_pHYs(png_ptr, info_ptr, res_x, res_y, - unit_type); - res_x - pixels/unit physical resolution - in x direction - res_y - pixels/unit physical resolution - in y direction - unit_type - PNG_RESOLUTION_UNKNOWN, - PNG_RESOLUTION_METER - - png_set_sCAL(png_ptr, info_ptr, unit, width, height) - unit - physical scale units (an integer) - width - width of a pixel in physical scale units - height - height of a pixel in physical scale units - (width and height are doubles) - - png_set_sCAL_s(png_ptr, info_ptr, unit, width, height) - unit - physical scale units (an integer) - width - width of a pixel in physical scale units - height - height of a pixel in physical scale units - (width and height are strings like "2.54") - - png_set_unknown_chunks(png_ptr, info_ptr, &unknowns, - num_unknowns) - unknowns - array of png_unknown_chunk - structures holding unknown chunks - unknowns[i].name - name of unknown chunk - unknowns[i].data - data of unknown chunk - unknowns[i].size - size of unknown chunk's data - unknowns[i].location - position to write chunk in file - 0: do not write chunk - PNG_HAVE_IHDR: before PLTE - PNG_HAVE_PLTE: before IDAT - PNG_AFTER_IDAT: after IDAT - -The "location" member is set automatically according to -what part of the output file has already been written. -You can change its value after calling png_set_unknown_chunks() -as demonstrated in pngtest.c. Within each of the "locations", -the chunks are sequenced according to their position in the -structure (that is, the value of "i", which is the order in which -the chunk was either read from the input file or defined with -png_set_unknown_chunks). - -A quick word about text and num_text. text is an array of png_text -structures. num_text is the number of valid structures in the array. -Each png_text structure holds a language code, a keyword, a text value, -and a compression type. - -The compression types have the same valid numbers as the compression -types of the image data. Currently, the only valid number is zero. -However, you can store text either compressed or uncompressed, unlike -images, which always have to be compressed. So if you don't want the -text compressed, set the compression type to PNG_TEXT_COMPRESSION_NONE. -Because tEXt and zTXt chunks don't have a language field, if you -specify PNG_TEXT_COMPRESSION_NONE or PNG_TEXT_COMPRESSION_zTXt -any language code or translated keyword will not be written out. - -Until text gets around 1000 bytes, it is not worth compressing it. -After the text has been written out to the file, the compression type -is set to PNG_TEXT_COMPRESSION_NONE_WR or PNG_TEXT_COMPRESSION_zTXt_WR, -so that it isn't written out again at the end (in case you are calling -png_write_end() with the same struct. - -The keywords that are given in the PNG Specification are: - - Title Short (one line) title or - caption for image - Author Name of image's creator - Description Description of image (possibly long) - Copyright Copyright notice - Creation Time Time of original image creation - (usually RFC 1123 format, see below) - Software Software used to create the image - Disclaimer Legal disclaimer - Warning Warning of nature of content - Source Device used to create the image - Comment Miscellaneous comment; conversion - from other image format - -The keyword-text pairs work like this. Keywords should be short -simple descriptions of what the comment is about. Some typical -keywords are found in the PNG specification, as is some recommendations -on keywords. You can repeat keywords in a file. You can even write -some text before the image and some after. For example, you may want -to put a description of the image before the image, but leave the -disclaimer until after, so viewers working over modem connections -don't have to wait for the disclaimer to go over the modem before -they start seeing the image. Finally, keywords should be full -words, not abbreviations. Keywords and text are in the ISO 8859-1 -(Latin-1) character set (a superset of regular ASCII) and can not -contain NUL characters, and should not contain control or other -unprintable characters. To make the comments widely readable, stick -with basic ASCII, and avoid machine specific character set extensions -like the IBM-PC character set. The keyword must be present, but -you can leave off the text string on non-compressed pairs. -Compressed pairs must have a text string, as only the text string -is compressed anyway, so the compression would be meaningless. - -PNG supports modification time via the png_time structure. Two -conversion routines are provided, png_convert_from_time_t() for -time_t and png_convert_from_struct_tm() for struct tm. The -time_t routine uses gmtime(). You don't have to use either of -these, but if you wish to fill in the png_time structure directly, -you should provide the time in universal time (GMT) if possible -instead of your local time. Note that the year number is the full -year (e.g. 1998, rather than 98 - PNG is year 2000 compliant!), and -that months start with 1. - -If you want to store the time of the original image creation, you should -use a plain tEXt chunk with the "Creation Time" keyword. This is -necessary because the "creation time" of a PNG image is somewhat vague, -depending on whether you mean the PNG file, the time the image was -created in a non-PNG format, a still photo from which the image was -scanned, or possibly the subject matter itself. In order to facilitate -machine-readable dates, it is recommended that the "Creation Time" -tEXt chunk use RFC 1123 format dates (e.g. "22 May 1997 18:07:10 GMT"), -although this isn't a requirement. Unlike the tIME chunk, the -"Creation Time" tEXt chunk is not expected to be automatically changed -by the software. To facilitate the use of RFC 1123 dates, a function -png_convert_to_rfc1123(png_timep) is provided to convert from PNG -time to an RFC 1123 format string. - -Writing unknown chunks - -You can use the png_set_unknown_chunks function to queue up chunks -for writing. You give it a chunk name, raw data, and a size; that's -all there is to it. The chunks will be written by the next following -png_write_info_before_PLTE, png_write_info, or png_write_end function. -Any chunks previously read into the info structure's unknown-chunk -list will also be written out in a sequence that satisfies the PNG -specification's ordering rules. - -The high-level write interface - -At this point there are two ways to proceed; through the high-level -write interface, or through a sequence of low-level write operations. -You can use the high-level interface if your image data is present -in the info structure. All defined output -transformations are permitted, enabled by the following masks. - - PNG_TRANSFORM_IDENTITY No transformation - PNG_TRANSFORM_PACKING Pack 1, 2 and 4-bit samples - PNG_TRANSFORM_PACKSWAP Change order of packed - pixels to LSB first - PNG_TRANSFORM_INVERT_MONO Invert monochrome images - PNG_TRANSFORM_SHIFT Normalize pixels to the - sBIT depth - PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA - to BGRA - PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA - to AG - PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity - to transparency - PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples - PNG_TRANSFORM_STRIP_FILLER Strip out filler bytes. - -If you have valid image data in the info structure (you can use -png_set_rows() to put image data in the info structure), simply do this: - - png_write_png(png_ptr, info_ptr, png_transforms, NULL) - -where png_transforms is an integer containing the bitwise OR of some set of -transformation flags. This call is equivalent to png_write_info(), -followed the set of transformations indicated by the transform mask, -then png_write_image(), and finally png_write_end(). - -(The final parameter of this call is not yet used. Someday it might point -to transformation parameters required by some future output transform.) - -You must use png_transforms and not call any png_set_transform() functions -when you use png_write_png(). - -The low-level write interface - -If you are going the low-level route instead, you are now ready to -write all the file information up to the actual image data. You do -this with a call to png_write_info(). - - png_write_info(png_ptr, info_ptr); - -Note that there is one transformation you may need to do before -png_write_info(). In PNG files, the alpha channel in an image is the -level of opacity. If your data is supplied as a level of -transparency, you can invert the alpha channel before you write it, so -that 0 is fully transparent and 255 (in 8-bit or paletted images) or -65535 (in 16-bit images) is fully opaque, with - - png_set_invert_alpha(png_ptr); - -This must appear before png_write_info() instead of later with the -other transformations because in the case of paletted images the tRNS -chunk data has to be inverted before the tRNS chunk is written. If -your image is not a paletted image, the tRNS data (which in such cases -represents a single color to be rendered as transparent) won't need to -be changed, and you can safely do this transformation after your -png_write_info() call. - -If you need to write a private chunk that you want to appear before -the PLTE chunk when PLTE is present, you can write the PNG info in -two steps, and insert code to write your own chunk between them: - - png_write_info_before_PLTE(png_ptr, info_ptr); - png_set_unknown_chunks(png_ptr, info_ptr, ...); - png_write_info(png_ptr, info_ptr); - -After you've written the file information, you can set up the library -to handle any special transformations of the image data. The various -ways to transform the data will be described in the order that they -should occur. This is important, as some of these change the color -type and/or bit depth of the data, and some others only work on -certain color types and bit depths. Even though each transformation -checks to see if it has data that it can do something with, you should -make sure to only enable a transformation if it will be valid for the -data. For example, don't swap red and blue on grayscale data. - -PNG files store RGB pixels packed into 3 or 6 bytes. This code tells -the library to strip input data that has 4 or 8 bytes per pixel down -to 3 or 6 bytes (or strip 2 or 4-byte grayscale+filler data to 1 or 2 -bytes per pixel). - - png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); - -where the 0 is unused, and the location is either PNG_FILLER_BEFORE or -PNG_FILLER_AFTER, depending upon whether the filler byte in the pixel -is stored XRGB or RGBX. - -PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as -they can, resulting in, for example, 8 pixels per byte for 1 bit files. -If the data is supplied at 1 pixel per byte, use this code, which will -correctly pack the pixels into a single byte: - - png_set_packing(png_ptr); - -PNG files reduce possible bit depths to 1, 2, 4, 8, and 16. If your -data is of another bit depth, you can write an sBIT chunk into the -file so that decoders can recover the original data if desired. - - /* Set the true bit depth of the image data */ - if (color_type & PNG_COLOR_MASK_COLOR) - { - sig_bit.red = true_bit_depth; - sig_bit.green = true_bit_depth; - sig_bit.blue = true_bit_depth; - } - else - { - sig_bit.gray = true_bit_depth; - } - if (color_type & PNG_COLOR_MASK_ALPHA) - { - sig_bit.alpha = true_bit_depth; - } - - png_set_sBIT(png_ptr, info_ptr, &sig_bit); - -If the data is stored in the row buffer in a bit depth other than -one supported by PNG (e.g. 3 bit data in the range 0-7 for a 4-bit PNG), -this will scale the values to appear to be the correct bit depth as -is required by PNG. - - png_set_shift(png_ptr, &sig_bit); - -PNG files store 16 bit pixels in network byte order (big-endian, -ie. most significant bits first). This code would be used if they are -supplied the other way (little-endian, i.e. least significant bits -first, the way PCs store them): - - if (bit_depth > 8) - png_set_swap(png_ptr); - -If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you -need to change the order the pixels are packed into bytes, you can use: - - if (bit_depth < 8) - png_set_packswap(png_ptr); - -PNG files store 3 color pixels in red, green, blue order. This code -would be used if they are supplied as blue, green, red: - - png_set_bgr(png_ptr); - -PNG files describe monochrome as black being zero and white being -one. This code would be used if the pixels are supplied with this reversed -(black being one and white being zero): - - png_set_invert_mono(png_ptr); - -Finally, you can write your own transformation function if none of -the existing ones meets your needs. This is done by setting a callback -with - - png_set_write_user_transform_fn(png_ptr, - write_transform_fn); - -You must supply the function - - void write_transform_fn(png_ptr ptr, row_info_ptr - row_info, png_bytep data) - -See pngtest.c for a working example. Your function will be called -before any of the other transformations are processed. - -You can also set up a pointer to a user structure for use by your -callback function. - - png_set_user_transform_info(png_ptr, user_ptr, 0, 0); - -The user_channels and user_depth parameters of this function are ignored -when writing; you can set them to zero as shown. - -You can retrieve the pointer via the function png_get_user_transform_ptr(). -For example: - - voidp write_user_transform_ptr = - png_get_user_transform_ptr(png_ptr); - -It is possible to have libpng flush any pending output, either manually, -or automatically after a certain number of lines have been written. To -flush the output stream a single time call: - - png_write_flush(png_ptr); - -and to have libpng flush the output stream periodically after a certain -number of scanlines have been written, call: - - png_set_flush(png_ptr, nrows); - -Note that the distance between rows is from the last time png_write_flush() -was called, or the first row of the image if it has never been called. -So if you write 50 lines, and then png_set_flush 25, it will flush the -output on the next scanline, and every 25 lines thereafter, unless -png_write_flush() is called before 25 more lines have been written. -If nrows is too small (less than about 10 lines for a 640 pixel wide -RGB image) the image compression may decrease noticeably (although this -may be acceptable for real-time applications). Infrequent flushing will -only degrade the compression performance by a few percent over images -that do not use flushing. - -Writing the image data - -That's it for the transformations. Now you can write the image data. -The simplest way to do this is in one function call. If you have the -whole image in memory, you can just call png_write_image() and libpng -will write the image. You will need to pass in an array of pointers to -each row. This function automatically handles interlacing, so you don't -need to call png_set_interlace_handling() or call this function multiple -times, or any of that other stuff necessary with png_write_rows(). - - png_write_image(png_ptr, row_pointers); - -where row_pointers is: - - png_byte *row_pointers[height]; - -You can point to void or char or whatever you use for pixels. - -If you don't want to write the whole image at once, you can -use png_write_rows() instead. If the file is not interlaced, -this is simple: - - png_write_rows(png_ptr, row_pointers, - number_of_rows); - -row_pointers is the same as in the png_write_image() call. - -If you are just writing one row at a time, you can do this with -a single row_pointer instead of an array of row_pointers: - - png_bytep row_pointer = row; - - png_write_row(png_ptr, row_pointer); - -When the file is interlaced, things can get a good deal more -complicated. The only currently (as of the PNG Specification -version 1.2, dated July 1999) defined interlacing scheme for PNG files -is the "Adam7" interlace scheme, that breaks down an -image into seven smaller images of varying size. libpng will build -these images for you, or you can do them yourself. If you want to -build them yourself, see the PNG specification for details of which -pixels to write when. - -If you don't want libpng to handle the interlacing details, just -use png_set_interlace_handling() and call png_write_rows() the -correct number of times to write all seven sub-images. - -If you want libpng to build the sub-images, call this before you start -writing any rows: - - number_of_passes = - png_set_interlace_handling(png_ptr); - -This will return the number of passes needed. Currently, this -is seven, but may change if another interlace type is added. - -Then write the complete image number_of_passes times. - - png_write_rows(png_ptr, row_pointers, - number_of_rows); - -As some of these rows are not used, and thus return immediately, -you may want to read about interlacing in the PNG specification, -and only update the rows that are actually used. - -Finishing a sequential write - -After you are finished writing the image, you should finish writing -the file. If you are interested in writing comments or time, you should -pass an appropriately filled png_info pointer. If you are not interested, -you can pass NULL. - - png_write_end(png_ptr, info_ptr); - -When you are done, you can free all memory used by libpng like this: - - png_destroy_write_struct(&png_ptr, &info_ptr); - -It is also possible to individually free the info_ptr members that -point to libpng-allocated storage with the following function: - - png_free_data(png_ptr, info_ptr, mask, seq) - mask - identifies data to be freed, a mask - containing the bitwise OR of one or - more of - PNG_FREE_PLTE, PNG_FREE_TRNS, - PNG_FREE_HIST, PNG_FREE_ICCP, - PNG_FREE_PCAL, PNG_FREE_ROWS, - PNG_FREE_SCAL, PNG_FREE_SPLT, - PNG_FREE_TEXT, PNG_FREE_UNKN, - or simply PNG_FREE_ALL - seq - sequence number of item to be freed - (-1 for all items) - -This function may be safely called when the relevant storage has -already been freed, or has not yet been allocated, or was allocated -by the user and not by libpng, and will in those -cases do nothing. The "seq" parameter is ignored if only one item -of the selected data type, such as PLTE, is allowed. If "seq" is not --1, and multiple items are allowed for the data type identified in -the mask, such as text or sPLT, only the n'th item in the structure -is freed, where n is "seq". - -If you allocated data such as a palette that you passed -in to libpng with png_set_*, you must not free it until just before the call to -png_destroy_write_struct(). - -The default behavior is only to free data that was allocated internally -by libpng. This can be changed, so that libpng will not free the data, -or so that it will free data that was allocated by the user with png_malloc() -or png_zalloc() and passed in via a png_set_*() function, with - - png_data_freer(png_ptr, info_ptr, freer, mask) - mask - which data elements are affected - same choices as in png_free_data() - freer - one of - PNG_DESTROY_WILL_FREE_DATA - PNG_SET_WILL_FREE_DATA - PNG_USER_WILL_FREE_DATA - -For example, to transfer responsibility for some data from a read structure -to a write structure, you could use - - png_data_freer(read_ptr, read_info_ptr, - PNG_USER_WILL_FREE_DATA, - PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST) - png_data_freer(write_ptr, write_info_ptr, - PNG_DESTROY_WILL_FREE_DATA, - PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST) - -thereby briefly reassigning responsibility for freeing to the user but -immediately afterwards reassigning it once more to the write_destroy -function. Having done this, it would then be safe to destroy the read -structure and continue to use the PLTE, tRNS, and hIST data in the write -structure. - -This function only affects data that has already been allocated. -You can call this function before calling after the png_set_*() functions -to control whether the user or png_destroy_*() is supposed to free the data. -When the user assumes responsibility for libpng-allocated data, the -application must use -png_free() to free it, and when the user transfers responsibility to libpng -for data that the user has allocated, the user must have used png_malloc() -or png_zalloc() to allocate it. - -If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword -separately, do not transfer responsibility for freeing text_ptr to libpng, -because when libpng fills a png_text structure it combines these members with -the key member, and png_free_data() will free only text_ptr.key. Similarly, -if you transfer responsibility for free'ing text_ptr from libpng to your -application, your application must not separately free those members. -For a more compact example of writing a PNG image, see the file example.c. - -V. Modifying/Customizing libpng: - -There are three issues here. The first is changing how libpng does -standard things like memory allocation, input/output, and error handling. -The second deals with more complicated things like adding new chunks, -adding new transformations, and generally changing how libpng works. -Both of those are compile-time issues; that is, they are generally -determined at the time the code is written, and there is rarely a need -to provide the user with a means of changing them. The third is a -run-time issue: choosing between and/or tuning one or more alternate -versions of computationally intensive routines; specifically, optimized -assembly-language (and therefore compiler- and platform-dependent) -versions. - -Memory allocation, input/output, and error handling - -All of the memory allocation, input/output, and error handling in libpng -goes through callbacks that are user-settable. The default routines are -in pngmem.c, pngrio.c, pngwio.c, and pngerror.c, respectively. To change -these functions, call the appropriate png_set_*_fn() function. - -Memory allocation is done through the functions png_malloc() -and png_free(). These currently just call the standard C functions. If -your pointers can't access more then 64K at a time, you will want to set -MAXSEG_64K in zlib.h. Since it is unlikely that the method of handling -memory allocation on a platform will change between applications, these -functions must be modified in the library at compile time. If you prefer -to use a different method of allocating and freeing data, you can use -png_create_read_struct_2() or png_create_write_struct_2() to register -your own functions as described above. -These functions also provide a void pointer that can be retrieved via - - mem_ptr=png_get_mem_ptr(png_ptr); - -Your replacement memory functions must have prototypes as follows: - - png_voidp malloc_fn(png_structp png_ptr, - png_size_t size); - void free_fn(png_structp png_ptr, png_voidp ptr); - -Your malloc_fn() must return NULL in case of failure. The png_malloc() -function will normally call png_error() if it receives a NULL from the -system memory allocator or from your replacement malloc_fn(). - -Input/Output in libpng is done through png_read() and png_write(), -which currently just call fread() and fwrite(). The FILE * is stored in -png_struct and is initialized via png_init_io(). If you wish to change -the method of I/O, the library supplies callbacks that you can set -through the function png_set_read_fn() and png_set_write_fn() at run -time, instead of calling the png_init_io() function. These functions -also provide a void pointer that can be retrieved via the function -png_get_io_ptr(). For example: - - png_set_read_fn(png_structp read_ptr, - voidp read_io_ptr, png_rw_ptr read_data_fn) - - png_set_write_fn(png_structp write_ptr, - voidp write_io_ptr, png_rw_ptr write_data_fn, - png_flush_ptr output_flush_fn); - - voidp read_io_ptr = png_get_io_ptr(read_ptr); - voidp write_io_ptr = png_get_io_ptr(write_ptr); - -The replacement I/O functions must have prototypes as follows: - - void user_read_data(png_structp png_ptr, - png_bytep data, png_size_t length); - void user_write_data(png_structp png_ptr, - png_bytep data, png_size_t length); - void user_flush_data(png_structp png_ptr); - -Supplying NULL for the read, write, or flush functions sets them back -to using the default C stream functions. It is an error to read from -a write stream, and vice versa. - -Error handling in libpng is done through png_error() and png_warning(). -Errors handled through png_error() are fatal, meaning that png_error() -should never return to its caller. Currently, this is handled via -setjmp() and longjmp() (unless you have compiled libpng with -PNG_SETJMP_NOT_SUPPORTED, in which case it is handled via PNG_ABORT()), -but you could change this to do things like exit() if you should wish. - -On non-fatal errors, png_warning() is called -to print a warning message, and then control returns to the calling code. -By default png_error() and png_warning() print a message on stderr via -fprintf() unless the library is compiled with PNG_NO_CONSOLE_IO defined -(because you don't want the messages) or PNG_NO_STDIO defined (because -fprintf() isn't available). If you wish to change the behavior of the error -functions, you will need to set up your own message callbacks. These -functions are normally supplied at the time that the png_struct is created. -It is also possible to redirect errors and warnings to your own replacement -functions after png_create_*_struct() has been called by calling: - - png_set_error_fn(png_structp png_ptr, - png_voidp error_ptr, png_error_ptr error_fn, - png_error_ptr warning_fn); - - png_voidp error_ptr = png_get_error_ptr(png_ptr); - -If NULL is supplied for either error_fn or warning_fn, then the libpng -default function will be used, calling fprintf() and/or longjmp() if a -problem is encountered. The replacement error functions should have -parameters as follows: - - void user_error_fn(png_structp png_ptr, - png_const_charp error_msg); - void user_warning_fn(png_structp png_ptr, - png_const_charp warning_msg); - -The motivation behind using setjmp() and longjmp() is the C++ throw and -catch exception handling methods. This makes the code much easier to write, -as there is no need to check every return code of every function call. -However, there are some uncertainties about the status of local variables -after a longjmp, so the user may want to be careful about doing anything after -setjmp returns non-zero besides returning itself. Consult your compiler -documentation for more details. For an alternative approach, you may wish -to use the "cexcept" facility (see http://cexcept.sourceforge.net). - -Custom chunks - -If you need to read or write custom chunks, you may need to get deeper -into the libpng code. The library now has mechanisms for storing -and writing chunks of unknown type; you can even declare callbacks -for custom chunks. However, this may not be good enough if the -library code itself needs to know about interactions between your -chunk and existing `intrinsic' chunks. - -If you need to write a new intrinsic chunk, first read the PNG -specification. Acquire a first level of -understanding of how it works. Pay particular attention to the -sections that describe chunk names, and look at how other chunks were -designed, so you can do things similarly. Second, check out the -sections of libpng that read and write chunks. Try to find a chunk -that is similar to yours and use it as a template. More details can -be found in the comments inside the code. It is best to handle unknown -chunks in a generic method, via callback functions, instead of by -modifying libpng functions. - -If you wish to write your own transformation for the data, look through -the part of the code that does the transformations, and check out some of -the simpler ones to get an idea of how they work. Try to find a similar -transformation to the one you want to add and copy off of it. More details -can be found in the comments inside the code itself. - -Configuring for 16 bit platforms - -You will want to look into zconf.h to tell zlib (and thus libpng) that -it cannot allocate more then 64K at a time. Even if you can, the memory -won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K. - -Configuring for DOS - -For DOS users who only have access to the lower 640K, you will -have to limit zlib's memory usage via a png_set_compression_mem_level() -call. See zlib.h or zconf.h in the zlib library for more information. - -Configuring for Medium Model - -Libpng's support for medium model has been tested on most of the popular -compilers. Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets -defined, and FAR gets defined to far in pngconf.h, and you should be -all set. Everything in the library (except for zlib's structure) is -expecting far data. You must use the typedefs with the p or pp on -the end for pointers (or at least look at them and be careful). Make -note that the rows of data are defined as png_bytepp, which is an -unsigned char far * far *. - -Configuring for gui/windowing platforms: - -You will need to write new error and warning functions that use the GUI -interface, as described previously, and set them to be the error and -warning functions at the time that png_create_*_struct() is called, -in order to have them available during the structure initialization. -They can be changed later via png_set_error_fn(). On some compilers, -you may also have to change the memory allocators (png_malloc, etc.). - -Configuring for compiler xxx: - -All includes for libpng are in pngconf.h. If you need to add/change/delete -an include, this is the place to do it. The includes that are not -needed outside libpng are protected by the PNG_INTERNAL definition, -which is only defined for those routines inside libpng itself. The -files in libpng proper only include png.h, which includes pngconf.h. - -Configuring zlib: - -There are special functions to configure the compression. Perhaps the -most useful one changes the compression level, which currently uses -input compression values in the range 0 - 9. The library normally -uses the default compression level (Z_DEFAULT_COMPRESSION = 6). Tests -have shown that for a large majority of images, compression values in -the range 3-6 compress nearly as well as higher levels, and do so much -faster. For online applications it may be desirable to have maximum speed -(Z_BEST_SPEED = 1). With versions of zlib after v0.99, you can also -specify no compression (Z_NO_COMPRESSION = 0), but this would create -files larger than just storing the raw bitmap. You can specify the -compression level by calling: - - png_set_compression_level(png_ptr, level); - -Another useful one is to reduce the memory level used by the library. -The memory level defaults to 8, but it can be lowered if you are -short on memory (running DOS, for example, where you only have 640K). -Note that the memory level does have an effect on compression; among -other things, lower levels will result in sections of incompressible -data being emitted in smaller stored blocks, with a correspondingly -larger relative overhead of up to 15% in the worst case. - - png_set_compression_mem_level(png_ptr, level); - -The other functions are for configuring zlib. They are not recommended -for normal use and may result in writing an invalid PNG file. See -zlib.h for more information on what these mean. - - png_set_compression_strategy(png_ptr, - strategy); - png_set_compression_window_bits(png_ptr, - window_bits); - png_set_compression_method(png_ptr, method); - png_set_compression_buffer_size(png_ptr, size); - -Controlling row filtering - -If you want to control whether libpng uses filtering or not, which -filters are used, and how it goes about picking row filters, you -can call one of these functions. The selection and configuration -of row filters can have a significant impact on the size and -encoding speed and a somewhat lesser impact on the decoding speed -of an image. Filtering is enabled by default for RGB and grayscale -images (with and without alpha), but not for paletted images nor -for any images with bit depths less than 8 bits/pixel. - -The 'method' parameter sets the main filtering method, which is -currently only '0' in the PNG 1.2 specification. The 'filters' -parameter sets which filter(s), if any, should be used for each -scanline. Possible values are PNG_ALL_FILTERS and PNG_NO_FILTERS -to turn filtering on and off, respectively. - -Individual filter types are PNG_FILTER_NONE, PNG_FILTER_SUB, -PNG_FILTER_UP, PNG_FILTER_AVG, PNG_FILTER_PAETH, which can be bitwise -ORed together with '|' to specify one or more filters to use. -These filters are described in more detail in the PNG specification. -If you intend to change the filter type during the course of writing -the image, you should start with flags set for all of the filters -you intend to use so that libpng can initialize its internal -structures appropriately for all of the filter types. (Note that this -means the first row must always be adaptively filtered, because libpng -currently does not allocate the filter buffers until png_write_row() -is called for the first time.) - - filters = PNG_FILTER_NONE | PNG_FILTER_SUB - PNG_FILTER_UP | PNG_FILTER_AVE | - PNG_FILTER_PAETH | PNG_ALL_FILTERS; - - png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, - filters); - The second parameter can also be - PNG_INTRAPIXEL_DIFFERENCING if you are - writing a PNG to be embedded in a MNG - datastream. This parameter must be the - same as the value of filter_method used - in png_set_IHDR(). - -It is also possible to influence how libpng chooses from among the -available filters. This is done in one or both of two ways - by -telling it how important it is to keep the same filter for successive -rows, and by telling it the relative computational costs of the filters. - - double weights[3] = {1.5, 1.3, 1.1}, - costs[PNG_FILTER_VALUE_LAST] = - {1.0, 1.3, 1.3, 1.5, 1.7}; - - png_set_filter_heuristics(png_ptr, - PNG_FILTER_HEURISTIC_WEIGHTED, 3, - weights, costs); - -The weights are multiplying factors that indicate to libpng that the -row filter should be the same for successive rows unless another row filter -is that many times better than the previous filter. In the above example, -if the previous 3 filters were SUB, SUB, NONE, the SUB filter could have a -"sum of absolute differences" 1.5 x 1.3 times higher than other filters -and still be chosen, while the NONE filter could have a sum 1.1 times -higher than other filters and still be chosen. Unspecified weights are -taken to be 1.0, and the specified weights should probably be declining -like those above in order to emphasize recent filters over older filters. - -The filter costs specify for each filter type a relative decoding cost -to be considered when selecting row filters. This means that filters -with higher costs are less likely to be chosen over filters with lower -costs, unless their "sum of absolute differences" is that much smaller. -The costs do not necessarily reflect the exact computational speeds of -the various filters, since this would unduly influence the final image -size. - -Note that the numbers above were invented purely for this example and -are given only to help explain the function usage. Little testing has -been done to find optimum values for either the costs or the weights. - -Removing unwanted object code - -There are a bunch of #define's in pngconf.h that control what parts of -libpng are compiled. All the defines end in _SUPPORTED. If you are -never going to use a capability, you can change the #define to #undef -before recompiling libpng and save yourself code and data space, or -you can turn off individual capabilities with defines that begin with -PNG_NO_. - -You can also turn all of the transforms and ancillary chunk capabilities -off en masse with compiler directives that define -PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS, -or all four, -along with directives to turn on any of the capabilities that you do -want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable -the extra transformations but still leave the library fully capable of reading -and writing PNG files with all known public chunks -Use of the PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive -produces a library that is incapable of reading or writing ancillary chunks. -If you are not using the progressive reading capability, you can -turn that off with PNG_NO_PROGRESSIVE_READ (don't confuse -this with the INTERLACING capability, which you'll still have). - -All the reading and writing specific code are in separate files, so the -linker should only grab the files it needs. However, if you want to -make sure, or if you are building a stand alone library, all the -reading files start with pngr and all the writing files start with -pngw. The files that don't match either (like png.c, pngtrans.c, etc.) -are used for both reading and writing, and always need to be included. -The progressive reader is in pngpread.c - -If you are creating or distributing a dynamically linked library (a .so -or DLL file), you should not remove or disable any parts of the library, -as this will cause applications linked with different versions of the -library to fail if they call functions not available in your library. -The size of the library itself should not be an issue, because only -those sections that are actually used will be loaded into memory. - -Requesting debug printout - -The macro definition PNG_DEBUG can be used to request debugging -printout. Set it to an integer value in the range 0 to 3. Higher -numbers result in increasing amounts of debugging information. The -information is printed to the "stderr" file, unless another file -name is specified in the PNG_DEBUG_FILE macro definition. - -When PNG_DEBUG > 0, the following functions (macros) become available: - - png_debug(level, message) - png_debug1(level, message, p1) - png_debug2(level, message, p1, p2) - -in which "level" is compared to PNG_DEBUG to decide whether to print -the message, "message" is the formatted string to be printed, -and p1 and p2 are parameters that are to be embedded in the string -according to printf-style formatting directives. For example, - - png_debug1(2, "foo=%d\n", foo); - -is expanded to - - if(PNG_DEBUG > 2) - fprintf(PNG_DEBUG_FILE, "foo=%d\n", foo); - -When PNG_DEBUG is defined but is zero, the macros aren't defined, but you -can still use PNG_DEBUG to control your own debugging: - - #ifdef PNG_DEBUG - fprintf(stderr, ... - #endif - -When PNG_DEBUG = 1, the macros are defined, but only png_debug statements -having level = 0 will be printed. There aren't any such statements in -this version of libpng, but if you insert some they will be printed. - -VI. Runtime optimization - -A new feature in libpng 1.2.0 is the ability to dynamically switch between -standard and optimized versions of some routines. Currently these are -limited to three computationally intensive tasks when reading PNG files: -decoding row filters, expanding interlacing, and combining interlaced or -transparent row data with previous row data. Currently the optimized -versions are available only for x86 (Intel, AMD, etc.) platforms with -MMX support, though this may change in future versions. (For example, -the non-MMX assembler optimizations for zlib might become similarly -runtime-selectable in future releases, in which case libpng could be -extended to support them. Alternatively, the compile-time choice of -floating-point versus integer routines for gamma correction might become -runtime-selectable.) - -Because such optimizations tend to be very platform- and compiler-dependent, -both in how they are written and in how they perform, the new runtime code -in libpng has been written to allow programs to query, enable, and disable -either specific optimizations or all such optimizations. For example, to -enable all possible optimizations (bearing in mind that some "optimizations" -may actually run more slowly in rare cases): - - #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) - png_uint_32 mask, flags; - - flags = png_get_asm_flags(png_ptr); - mask = png_get_asm_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE); - png_set_asm_flags(png_ptr, flags | mask); - #endif - -To enable only optimizations relevant to reading PNGs, use PNG_SELECT_READ -by itself when calling png_get_asm_flagmask(); similarly for optimizing -only writing. To disable all optimizations: - - #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) - flags = png_get_asm_flags(png_ptr); - mask = png_get_asm_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE); - png_set_asm_flags(png_ptr, flags & ~mask); - #endif - -To enable or disable only MMX-related features, use png_get_mmx_flagmask() -in place of png_get_asm_flagmask(). The mmx version takes one additional -parameter: - - #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) - int selection = PNG_SELECT_READ | PNG_SELECT_WRITE; - int compilerID; - - mask = png_get_mmx_flagmask(selection, &compilerID); - #endif - -On return, compilerID will indicate which version of the MMX assembler -optimizations was compiled. Currently two flavors exist: Microsoft -Visual C++ (compilerID == 1) and GNU C (a.k.a. gcc/gas, compilerID == 2). -On non-x86 platforms or on systems compiled without MMX optimizations, a -value of -1 is used. - -Note that both png_get_asm_flagmask() and png_get_mmx_flagmask() return -all valid, settable optimization bits for the version of the library that's -currently in use. In the case of shared (dynamically linked) libraries, -this may include optimizations that did not exist at the time the code was -written and compiled. It is also possible, of course, to enable only known, -specific optimizations; for example: - - #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) - flags = PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ - | PNG_ASM_FLAG_MMX_READ_INTERLACE \ - | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ - | PNG_ASM_FLAG_MMX_READ_FILTER_UP \ - | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ - | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ; - png_set_asm_flags(png_ptr, flags); - #endif - -This method would enable only the MMX read-optimizations available at the -time of libpng 1.2.0's release, regardless of whether a later version of -the DLL were actually being used. (Also note that these functions did not -exist in versions older than 1.2.0, so any attempt to run a dynamically -linked app on such an older version would fail.) - -To determine whether the processor supports MMX instructions at all, use -the png_mmx_support() function: - - #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) - mmxsupport = png_mmx_support(); - #endif - -It returns -1 if MMX support is not compiled into libpng, 0 if MMX code -is compiled but MMX is not supported by the processor, or 1 if MMX support -is fully available. Note that png_mmx_support(), png_get_mmx_flagmask(), -and png_get_asm_flagmask() all may be called without allocating and ini- -tializing any PNG structures (for example, as part of a usage screen or -"about" box). - -The following code can be used to prevent an application from using the -thread_unsafe features, even if libpng was built with PNG_THREAD_UNSAFE_OK -defined: - -#if defined(PNG_USE_PNGGCCRD) && defined(PNG_ASSEMBLER_CODE_SUPPORTED) \ - && defined(PNG_THREAD_UNSAFE_OK) - /* Disable thread-unsafe features of pnggccrd */ - if (png_access_version_number() >= 10200) - { - png_uint_32 mmx_disable_mask = 0; - png_uint_32 asm_flags; - - mmx_disable_mask |= ( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ - | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ - | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ - | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ); - asm_flags = png_get_asm_flags(png_ptr); - png_set_asm_flags(png_ptr, asm_flags & ~mmx_disable_mask); - } -#endif - -For more extensive examples of runtime querying, enabling and disabling -of optimized features, see contrib/gregbook/readpng2.c in the libpng -source-code distribution. - -VII. MNG support - -The MNG specification (available at http://www.libpng.org/pub/mng) allows -certain extensions to PNG for PNG images that are embedded in MNG datastreams. -Libpng can support some of these extensions. To enable them, use the -png_permit_mng_features() function: - - feature_set = png_permit_mng_features(png_ptr, mask) - mask is a png_uint_32 containing the bitwise OR of the - features you want to enable. These include - PNG_FLAG_MNG_EMPTY_PLTE - PNG_FLAG_MNG_FILTER_64 - PNG_ALL_MNG_FEATURES - feature_set is a png_uint_32 that is the bitwise AND of - your mask with the set of MNG features that is - supported by the version of libpng that you are using. - -It is an error to use this function when reading or writing a standalone -PNG file with the PNG 8-byte signature. The PNG datastream must be wrapped -in a MNG datastream. As a minimum, it must have the MNG 8-byte signature -and the MHDR and MEND chunks. Libpng does not provide support for these -or any other MNG chunks; your application must provide its own support for -them. You may wish to consider using libmng (available at -http://www.libmng.com) instead. - -VIII. Changes to Libpng from version 0.88 - -It should be noted that versions of libpng later than 0.96 are not -distributed by the original libpng author, Guy Schalnat, nor by -Andreas Dilger, who had taken over from Guy during 1996 and 1997, and -distributed versions 0.89 through 0.96, but rather by another member -of the original PNG Group, Glenn Randers-Pehrson. Guy and Andreas are -still alive and well, but they have moved on to other things. - -The old libpng functions png_read_init(), png_write_init(), -png_info_init(), png_read_destroy(), and png_write_destroy() have been -moved to PNG_INTERNAL in version 0.95 to discourage their use. These -functions will be removed from libpng version 2.0.0. - -The preferred method of creating and initializing the libpng structures is -via the png_create_read_struct(), png_create_write_struct(), and -png_create_info_struct() because they isolate the size of the structures -from the application, allow version error checking, and also allow the -use of custom error handling routines during the initialization, which -the old functions do not. The functions png_read_destroy() and -png_write_destroy() do not actually free the memory that libpng -allocated for these structs, but just reset the data structures, so they -can be used instead of png_destroy_read_struct() and -png_destroy_write_struct() if you feel there is too much system overhead -allocating and freeing the png_struct for each image read. - -Setting the error callbacks via png_set_message_fn() before -png_read_init() as was suggested in libpng-0.88 is no longer supported -because this caused applications that do not use custom error functions -to fail if the png_ptr was not initialized to zero. It is still possible -to set the error callbacks AFTER png_read_init(), or to change them with -png_set_error_fn(), which is essentially the same function, but with a new -name to force compilation errors with applications that try to use the old -method. - -Starting with version 1.0.7, you can find out which version of the library -you are using at run-time: - - png_uint_32 libpng_vn = png_access_version_number(); - -The number libpng_vn is constructed from the major version, minor -version with leading zero, and release number with leading zero, -(e.g., libpng_vn for version 1.0.7 is 10007). - -You can also check which version of png.h you used when compiling your -application: - - png_uint_32 application_vn = PNG_LIBPNG_VER; - -IX. Y2K Compliance in libpng - -May 15, 2007 - -Since the PNG Development group is an ad-hoc body, we can't make -an official declaration. - -This is your unofficial assurance that libpng from version 0.71 and -upward through 1.2.18 are Y2K compliant. It is my belief that earlier -versions were also Y2K compliant. - -Libpng only has three year fields. One is a 2-byte unsigned integer that -will hold years up to 65535. The other two hold the date in text -format, and will hold years up to 9999. - -The integer is - "png_uint_16 year" in png_time_struct. - -The strings are - "png_charp time_buffer" in png_struct and - "near_time_buffer", which is a local character string in png.c. - -There are seven time-related functions: - - png_convert_to_rfc_1123() in png.c - (formerly png_convert_to_rfc_1152() in error) - png_convert_from_struct_tm() in pngwrite.c, called - in pngwrite.c - png_convert_from_time_t() in pngwrite.c - png_get_tIME() in pngget.c - png_handle_tIME() in pngrutil.c, called in pngread.c - png_set_tIME() in pngset.c - png_write_tIME() in pngwutil.c, called in pngwrite.c - -All appear to handle dates properly in a Y2K environment. The -png_convert_from_time_t() function calls gmtime() to convert from system -clock time, which returns (year - 1900), which we properly convert to -the full 4-digit year. There is a possibility that applications using -libpng are not passing 4-digit years into the png_convert_to_rfc_1123() -function, or that they are incorrectly passing only a 2-digit year -instead of "year - 1900" into the png_convert_from_struct_tm() function, -but this is not under our control. The libpng documentation has always -stated that it works with 4-digit years, and the APIs have been -documented as such. - -The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned -integer to hold the year, and can hold years as large as 65535. - -zlib, upon which libpng depends, is also Y2K compliant. It contains -no date-related code. - - - Glenn Randers-Pehrson - libpng maintainer - PNG Development Group diff --git a/irrlicht-1.6/source/Irrlicht/libpng/libpng.3 b/irrlicht-1.6/source/Irrlicht/libpng/libpng.3 deleted file mode 100644 index 0507b48ee..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/libpng.3 +++ /dev/null @@ -1,3707 +0,0 @@ -.TH LIBPNG 3 "May 15, 2007" -.SH NAME -libpng \- Portable Network Graphics (PNG) Reference Library 1.2.18 -.SH SYNOPSIS -\fB -#include <png.h>\fP - -\fBpng_uint_32 png_access_version_number \fI(void\fP\fB);\fP - -\fBint png_check_sig (png_bytep \fP\fIsig\fP\fB, int \fInum\fP\fB);\fP - -\fBvoid png_chunk_error (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fIerror\fP\fB);\fP - -\fBvoid png_chunk_warning (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fImessage\fP\fB);\fP - -\fBvoid png_convert_from_struct_tm (png_timep \fP\fIptime\fP\fB, struct tm FAR * \fIttime\fP\fB);\fP - -\fBvoid png_convert_from_time_t (png_timep \fP\fIptime\fP\fB, time_t \fIttime\fP\fB);\fP - -\fBpng_charp png_convert_to_rfc1123 (png_structp \fP\fIpng_ptr\fP\fB, png_timep \fIptime\fP\fB);\fP - -\fBpng_infop png_create_info_struct (png_structp \fIpng_ptr\fP\fB);\fP - -\fBpng_structp png_create_read_struct (png_const_charp \fP\fIuser_png_ver\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fIwarn_fn\fP\fB);\fP - -\fBpng_structp png_create_read_struct_2(png_const_charp \fP\fIuser_png_ver\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fP\fIwarn_fn\fP\fB, png_voidp \fP\fImem_ptr\fP\fB, png_malloc_ptr \fP\fImalloc_fn\fP\fB, png_free_ptr \fIfree_fn\fP\fB);\fP - -\fBpng_structp png_create_write_struct (png_const_charp \fP\fIuser_png_ver\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fIwarn_fn\fP\fB);\fP - -\fBpng_structp png_create_write_struct_2(png_const_charp \fP\fIuser_png_ver\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fP\fIwarn_fn\fP\fB, png_voidp \fP\fImem_ptr\fP\fB, png_malloc_ptr \fP\fImalloc_fn\fP\fB, png_free_ptr \fIfree_fn\fP\fB);\fP - -\fBint png_debug(int \fP\fIlevel\fP\fB, png_const_charp \fImessage\fP\fB);\fP - -\fBint png_debug1(int \fP\fIlevel\fP\fB, png_const_charp \fP\fImessage\fP\fB, \fIp1\fP\fB);\fP - -\fBint png_debug2(int \fP\fIlevel\fP\fB, png_const_charp \fP\fImessage\fP\fB, \fP\fIp1\fP\fB, \fIp2\fP\fB);\fP - -\fBvoid png_destroy_info_struct (png_structp \fP\fIpng_ptr\fP\fB, png_infopp \fIinfo_ptr_ptr\fP\fB);\fP - -\fBvoid png_destroy_read_struct (png_structpp \fP\fIpng_ptr_ptr\fP\fB, png_infopp \fP\fIinfo_ptr_ptr\fP\fB, png_infopp \fIend_info_ptr_ptr\fP\fB);\fP - -\fBvoid png_destroy_write_struct (png_structpp \fP\fIpng_ptr_ptr\fP\fB, png_infopp \fIinfo_ptr_ptr\fP\fB);\fP - -\fBvoid png_error (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fIerror\fP\fB);\fP - -\fBvoid png_free (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fIptr\fP\fB);\fP - -\fBvoid png_free_chunk_list (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_free_default(png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fIptr\fP\fB);\fP - -\fBvoid png_free_data (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fInum\fP\fB);\fP - -\fBpng_byte png_get_bit_depth (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBpng_uint_32 png_get_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_16p \fI*background\fP\fB);\fP - -\fBpng_byte png_get_channels (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBpng_uint_32 png_get_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fP\fI*white_x\fP\fB, double \fP\fI*white_y\fP\fB, double \fP\fI*red_x\fP\fB, double \fP\fI*red_y\fP\fB, double \fP\fI*green_x\fP\fB, double \fP\fI*green_y\fP\fB, double \fP\fI*blue_x\fP\fB, double \fI*blue_y\fP\fB);\fP - -\fBpng_uint_32 png_get_cHRM_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*white_x\fP\fB, png_uint_32 \fP\fI*white_y\fP\fB, png_uint_32 \fP\fI*red_x\fP\fB, png_uint_32 \fP\fI*red_y\fP\fB, png_uint_32 \fP\fI*green_x\fP\fB, png_uint_32 \fP\fI*green_y\fP\fB, png_uint_32 \fP\fI*blue_x\fP\fB, png_uint_32 \fI*blue_y\fP\fB);\fP - -\fBpng_byte png_get_color_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBpng_byte png_get_compression_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBpng_byte png_get_copyright (png_structp \fIpng_ptr\fP\fB);\fP - -\fBpng_voidp png_get_error_ptr (png_structp \fIpng_ptr\fP\fB);\fP - -\fBpng_byte png_get_filter_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBpng_uint_32 png_get_gAMA (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fI*file_gamma\fP\fB);\fP - -\fBpng_uint_32 png_get_gAMA_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fI*int_file_gamma\fP\fB);\fP - -\fBpng_byte png_get_header_ver (png_structp \fIpng_ptr\fP\fB);\fP - -\fBpng_byte png_get_header_version (png_structp \fIpng_ptr\fP\fB);\fP - -\fBpng_uint_32 png_get_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_16p \fI*hist\fP\fB);\fP - -\fBpng_uint_32 png_get_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charpp \fP\fIname\fP\fB, int \fP\fI*compression_type\fP\fB, png_charpp \fP\fIprofile\fP\fB, png_uint_32 \fI*proflen\fP\fB);\fP - -\fBpng_uint_32 png_get_IHDR (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*width\fP\fB, png_uint_32 \fP\fI*height\fP\fB, int \fP\fI*bit_depth\fP\fB, int \fP\fI*color_type\fP\fB, int \fP\fI*interlace_type\fP\fB, int \fP\fI*compression_type\fP\fB, int \fI*filter_type\fP\fB);\fP - -\fBpng_uint_32 png_get_image_height (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBpng_uint_32 png_get_image_width (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fB#if !defined(PNG_1_0_X) png_int_32 png_get_int_32 (png_bytep buf); \fI#endif - -\fBpng_byte png_get_interlace_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBpng_voidp png_get_io_ptr (png_structp \fIpng_ptr\fP\fB);\fP - -\fBpng_byte png_get_libpng_ver (png_structp \fIpng_ptr\fP\fB);\fP - -\fBpng_voidp png_get_mem_ptr(png_structp \fIpng_ptr\fP\fB);\fP - -\fBpng_uint_32 png_get_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*offset_x\fP\fB, png_uint_32 \fP\fI*offset_y\fP\fB, int \fI*unit_type\fP\fB);\fP - -\fBpng_uint_32 png_get_pCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charp \fP\fI*purpose\fP\fB, png_int_32 \fP\fI*X0\fP\fB, png_int_32 \fP\fI*X1\fP\fB, int \fP\fI*type\fP\fB, int \fP\fI*nparams\fP\fB, png_charp \fP\fI*units\fP\fB, png_charpp \fI*params\fP\fB);\fP - -\fBpng_uint_32 png_get_pHYs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*res_x\fP\fB, png_uint_32 \fP\fI*res_y\fP\fB, int \fI*unit_type\fP\fB);\fP - -\fBfloat png_get_pixel_aspect_ratio (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBpng_uint_32 png_get_pixels_per_meter (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBpng_voidp png_get_progressive_ptr (png_structp \fIpng_ptr\fP\fB);\fP - -\fBpng_uint_32 png_get_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_colorp \fP\fI*palette\fP\fB, int \fI*num_palette\fP\fB);\fP - -\fBpng_byte png_get_rgb_to_gray_status (png_structp png_ptr) png_uint_32 png_get_rowbytes (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBpng_bytepp png_get_rows (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBpng_uint_32 png_get_sBIT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_8p \fI*sig_bit\fP\fB);\fP - -\fBpng_bytep png_get_signature (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBpng_uint_32 png_get_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_spalette_p \fI*splt_ptr\fP\fB);\fP - -\fBpng_uint_32 png_get_sRGB (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fI*intent\fP\fB);\fP - -\fBpng_uint_32 png_get_text (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_textp \fP\fI*text_ptr\fP\fB, int \fI*num_text\fP\fB);\fP - -\fBpng_uint_32 png_get_tIME (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_timep \fI*mod_time\fP\fB);\fP - -\fBpng_uint_32 png_get_tRNS (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytep \fP\fI*trans\fP\fB, int \fP\fI*num_trans\fP\fB, png_color_16p \fI*trans_values\fP\fB);\fP - -\fB#if !defined(PNG_1_0_X) png_uint_16 png_get_uint_16 (png_bytep \fIbuf\fP\fB);\fP - -\fBpng_uint_32 png_get_uint_31 (png_bytep \fIbuf\fP\fB);\fP - -\fBpng_uint_32 png_get_uint_32 (png_bytep buf); \fI#endif - -\fBpng_uint_32 png_get_unknown_chunks (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_unknown_chunkpp \fIunknowns\fP\fB);\fP - -\fBpng_voidp png_get_user_chunk_ptr (png_structp \fIpng_ptr\fP\fB);\fP - -\fBpng_uint_32 png_get_user_height_max( png_structp \fIpng_ptr\fP\fB);\fP - -\fBpng_voidp png_get_user_transform_ptr (png_structp \fIpng_ptr\fP\fB);\fP - -\fBpng_uint_32 png_get_user_width_max (png_structp \fIpng_ptr\fP\fB);\fP - -\fBpng_uint_32 png_get_valid (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIflag\fP\fB);\fP - -\fBpng_int_32 png_get_x_offset_microns (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBpng_int_32 png_get_x_offset_pixels (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBpng_uint_32 png_get_x_pixels_per_meter (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBpng_int_32 png_get_y_offset_microns (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBpng_int_32 png_get_y_offset_pixels (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBpng_uint_32 png_get_y_pixels_per_meter (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBpng_uint_32 png_get_compression_buffer_size (png_structp \fIpng_ptr\fP\fB);\fP - -\fBint png_handle_as_unknown (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIchunk_name\fP\fB);\fP - -\fBvoid png_init_io (png_structp \fP\fIpng_ptr\fP\fB, FILE \fI*fp\fP\fB);\fP - -\fBDEPRECATED: void png_info_init (png_infop \fIinfo_ptr\fP\fB);\fP - -\fBDEPRECATED: void png_info_init_2 (png_infopp \fP\fIptr_ptr\fP\fB, png_size_t \fIpng_info_struct_size\fP\fB);\fP - -\fBpng_voidp png_malloc (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIsize\fP\fB);\fP - -\fBpng_voidp png_malloc_default(png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIsize\fP\fB);\fP - -\fBvoidp png_memcpy (png_voidp \fP\fIs1\fP\fB, png_voidp \fP\fIs2\fP\fB, png_size_t \fIsize\fP\fB);\fP - -\fBpng_voidp png_memcpy_check (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIs1\fP\fB, png_voidp \fP\fIs2\fP\fB, png_uint_32 \fIsize\fP\fB);\fP - -\fBvoidp png_memset (png_voidp \fP\fIs1\fP\fB, int \fP\fIvalue\fP\fB, png_size_t \fIsize\fP\fB);\fP - -\fBpng_voidp png_memset_check (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIs1\fP\fB, int \fP\fIvalue\fP\fB, png_uint_32 \fIsize\fP\fB);\fP - -\fBDEPRECATED: void png_permit_empty_plte (png_structp \fP\fIpng_ptr\fP\fB, int \fIempty_plte_permitted\fP\fB);\fP - -\fBvoid png_process_data (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytep \fP\fIbuffer\fP\fB, png_size_t \fIbuffer_size\fP\fB);\fP - -\fBvoid png_progressive_combine_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIold_row\fP\fB, png_bytep \fInew_row\fP\fB);\fP - -\fBvoid png_read_destroy (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_infop \fIend_info_ptr\fP\fB);\fP - -\fBvoid png_read_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBvoid png_read_image (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fIimage\fP\fB);\fP - -\fBDEPRECATED: void png_read_init (png_structp \fIpng_ptr\fP\fB);\fP - -\fBDEPRECATED: void png_read_init_2 (png_structpp \fP\fIptr_ptr\fP\fB, png_const_charp \fP\fIuser_png_ver\fP\fB, png_size_t \fP\fIpng_struct_size\fP\fB, png_size_t \fIpng_info_size\fP\fB);\fP - -\fBvoid png_read_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBvoid png_read_png (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fItransforms\fP\fB, png_voidp \fIparams\fP\fB);\fP - -\fBvoid png_read_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fIdisplay_row\fP\fB);\fP - -\fBvoid png_read_rows (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fP\fIrow\fP\fB, png_bytepp \fP\fIdisplay_row\fP\fB, png_uint_32 \fInum_rows\fP\fB);\fP - -\fBvoid png_read_update_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fB#if !defined(PNG_1_0_X) png_save_int_32 (png_bytep \fP\fIbuf\fP\fB, png_int_32 \fIi\fP\fB);\fP - -\fBvoid png_save_uint_16 (png_bytep \fP\fIbuf\fP\fB, unsigned int \fIi\fP\fB);\fP - -\fBvoid png_save_uint_32 (png_bytep \fP\fIbuf\fP\fB, png_uint_32 \fIi\fP\fB);\fP - -\fBvoid png_set_add_alpha (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIfiller\fP\fB, int flags); \fI#endif - -\fBvoid png_set_background (png_structp \fP\fIpng_ptr\fP\fB, png_color_16p \fP\fIbackground_color\fP\fB, int \fP\fIbackground_gamma_code\fP\fB, int \fP\fIneed_expand\fP\fB, double \fIbackground_gamma\fP\fB);\fP - -\fBvoid png_set_bgr (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_set_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_16p \fIbackground\fP\fB);\fP - -\fBvoid png_set_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fP\fIwhite_x\fP\fB, double \fP\fIwhite_y\fP\fB, double \fP\fIred_x\fP\fB, double \fP\fIred_y\fP\fB, double \fP\fIgreen_x\fP\fB, double \fP\fIgreen_y\fP\fB, double \fP\fIblue_x\fP\fB, double \fIblue_y\fP\fB);\fP - -\fBvoid png_set_cHRM_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fIwhite_x\fP\fB, png_uint_32 \fP\fIwhite_y\fP\fB, png_uint_32 \fP\fIred_x\fP\fB, png_uint_32 \fP\fIred_y\fP\fB, png_uint_32 \fP\fIgreen_x\fP\fB, png_uint_32 \fP\fIgreen_y\fP\fB, png_uint_32 \fP\fIblue_x\fP\fB, png_uint_32 \fIblue_y\fP\fB);\fP - -\fBvoid png_set_compression_level (png_structp \fP\fIpng_ptr\fP\fB, int \fIlevel\fP\fB);\fP - -\fBvoid png_set_compression_mem_level (png_structp \fP\fIpng_ptr\fP\fB, int \fImem_level\fP\fB);\fP - -\fBvoid png_set_compression_method (png_structp \fP\fIpng_ptr\fP\fB, int \fImethod\fP\fB);\fP - -\fBvoid png_set_compression_strategy (png_structp \fP\fIpng_ptr\fP\fB, int \fIstrategy\fP\fB);\fP - -\fBvoid png_set_compression_window_bits (png_structp \fP\fIpng_ptr\fP\fB, int \fIwindow_bits\fP\fB);\fP - -\fBvoid png_set_crc_action (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIcrit_action\fP\fB, int \fIancil_action\fP\fB);\fP - -\fBvoid png_set_dither (png_structp \fP\fIpng_ptr\fP\fB, png_colorp \fP\fIpalette\fP\fB, int \fP\fInum_palette\fP\fB, int \fP\fImaximum_colors\fP\fB, png_uint_16p \fP\fIhistogram\fP\fB, int \fIfull_dither\fP\fB);\fP - -\fBvoid png_set_error_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fIwarning_fn\fP\fB);\fP - -\fBvoid png_set_expand (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_set_expand_gray_1_2_4_to_8(png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_set_filler (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIfiller\fP\fB, int \fIflags\fP\fB);\fP - -\fBvoid png_set_filter (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fImethod\fP\fB, int \fIfilters\fP\fB);\fP - -\fBvoid png_set_filter_heuristics (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIheuristic_method\fP\fB, int \fP\fInum_weights\fP\fB, png_doublep \fP\fIfilter_weights\fP\fB, png_doublep \fIfilter_costs\fP\fB);\fP - -\fBvoid png_set_flush (png_structp \fP\fIpng_ptr\fP\fB, int \fInrows\fP\fB);\fP - -\fBvoid png_set_gamma (png_structp \fP\fIpng_ptr\fP\fB, double \fP\fIscreen_gamma\fP\fB, double \fIdefault_file_gamma\fP\fB);\fP - -\fBvoid png_set_gAMA (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fIfile_gamma\fP\fB);\fP - -\fBvoid png_set_gAMA_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIfile_gamma\fP\fB);\fP - -\fBvoid png_set_gray_1_2_4_to_8(png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_set_gray_to_rgb (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_set_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_16p \fIhist\fP\fB);\fP - -\fBvoid png_set_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charp \fP\fIname\fP\fB, int \fP\fIcompression_type\fP\fB, png_charp \fP\fIprofile\fP\fB, png_uint_32 \fIproflen\fP\fB);\fP - -\fBint png_set_interlace_handling (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_set_invalid (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fImask\fP\fB);\fP - -\fBvoid png_set_invert_alpha (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_set_invert_mono (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_set_IHDR (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fIwidth\fP\fB, png_uint_32 \fP\fIheight\fP\fB, int \fP\fIbit_depth\fP\fB, int \fP\fIcolor_type\fP\fB, int \fP\fIinterlace_type\fP\fB, int \fP\fIcompression_type\fP\fB, int \fIfilter_type\fP\fB);\fP - -\fBvoid png_set_keep_unknown_chunks (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIkeep\fP\fB, png_bytep \fP\fIchunk_list\fP\fB, int \fInum_chunks\fP\fB);\fP - -\fBvoid png_set_mem_fn(png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fImem_ptr\fP\fB, png_malloc_ptr \fP\fImalloc_fn\fP\fB, png_free_ptr \fIfree_fn\fP\fB);\fP - -\fBvoid png_set_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fIoffset_x\fP\fB, png_uint_32 \fP\fIoffset_y\fP\fB, int \fIunit_type\fP\fB);\fP - -\fBvoid png_set_packing (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_set_packswap (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_set_palette_to_rgb(png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_set_pCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charp \fP\fIpurpose\fP\fB, png_int_32 \fP\fIX0\fP\fB, png_int_32 \fP\fIX1\fP\fB, int \fP\fItype\fP\fB, int \fP\fInparams\fP\fB, png_charp \fP\fIunits\fP\fB, png_charpp \fIparams\fP\fB);\fP - -\fBvoid png_set_pHYs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fIres_x\fP\fB, png_uint_32 \fP\fIres_y\fP\fB, int \fIunit_type\fP\fB);\fP - -\fBvoid png_set_progressive_read_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIprogressive_ptr\fP\fB, png_progressive_info_ptr \fP\fIinfo_fn\fP\fB, png_progressive_row_ptr \fP\fIrow_fn\fP\fB, png_progressive_end_ptr \fIend_fn\fP\fB);\fP - -\fBvoid png_set_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_colorp \fP\fIpalette\fP\fB, int \fInum_palette\fP\fB);\fP - -\fBvoid png_set_read_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIio_ptr\fP\fB, png_rw_ptr \fIread_data_fn\fP\fB);\fP - -\fBvoid png_set_read_status_fn (png_structp \fP\fIpng_ptr\fP\fB, png_read_status_ptr \fIread_row_fn\fP\fB);\fP - -\fBvoid png_set_read_user_transform_fn (png_structp \fP\fIpng_ptr\fP\fB, png_user_transform_ptr \fIread_user_transform_fn\fP\fB);\fP - -\fBvoid png_set_rgb_to_gray (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIerror_action\fP\fB, double \fP\fIred\fP\fB, double \fIgreen\fP\fB);\fP - -\fBvoid png_set_rgb_to_gray_fixed (png_structp \fP\fIpng_ptr\fP\fB, int error_action png_fixed_point \fP\fIred\fP\fB, png_fixed_point \fIgreen\fP\fB);\fP - -\fBvoid png_set_rows (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytepp \fIrow_pointers\fP\fB);\fP - -\fBvoid png_set_sBIT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_8p \fIsig_bit\fP\fB);\fP - -\fBvoid png_set_sCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charp \fP\fIunit\fP\fB, double \fP\fIwidth\fP\fB, double \fIheight\fP\fB);\fP - -\fBvoid png_set_shift (png_structp \fP\fIpng_ptr\fP\fB, png_color_8p \fItrue_bits\fP\fB);\fP - -\fBvoid png_set_sig_bytes (png_structp \fP\fIpng_ptr\fP\fB, int \fInum_bytes\fP\fB);\fP - -\fBvoid png_set_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_spalette_p \fP\fIsplt_ptr\fP\fB, int \fInum_spalettes\fP\fB);\fP - -\fBvoid png_set_sRGB (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fIintent\fP\fB);\fP - -\fBvoid png_set_sRGB_gAMA_and_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fIintent\fP\fB);\fP - -\fBvoid png_set_strip_16 (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_set_strip_alpha (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_set_swap (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_set_swap_alpha (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_set_text (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_textp \fP\fItext_ptr\fP\fB, int \fInum_text\fP\fB);\fP - -\fBvoid png_set_tIME (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_timep \fImod_time\fP\fB);\fP - -\fBvoid png_set_tRNS (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytep \fP\fItrans\fP\fB, int \fP\fInum_trans\fP\fB, png_color_16p \fItrans_values\fP\fB);\fP - -\fBvoid png_set_tRNS_to_alpha(png_structp \fIpng_ptr\fP\fB);\fP - -\fBpng_uint_32 png_set_unknown_chunks (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_unknown_chunkp \fP\fIunknowns\fP\fB, int \fP\fInum\fP\fB, int \fIlocation\fP\fB);\fP - -\fBvoid png_set_unknown_chunk_location(png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fIchunk\fP\fB, int \fIlocation\fP\fB);\fP - -\fBvoid png_set_read_user_chunk_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIuser_chunk_ptr\fP\fB, png_user_chunk_ptr \fIread_user_chunk_fn\fP\fB);\fP - -\fBvoid png_set_user_limits (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIuser_width_max\fP\fB, png_uint_32 \fIuser_height_max\fP\fB);\fP - -\fBvoid png_set_user_transform_info (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIuser_transform_ptr\fP\fB, int \fP\fIuser_transform_depth\fP\fB, int \fIuser_transform_channels\fP\fB);\fP - -\fBvoid png_set_write_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIio_ptr\fP\fB, png_rw_ptr \fP\fIwrite_data_fn\fP\fB, png_flush_ptr \fIoutput_flush_fn\fP\fB);\fP - -\fBvoid png_set_write_status_fn (png_structp \fP\fIpng_ptr\fP\fB, png_write_status_ptr \fIwrite_row_fn\fP\fB);\fP - -\fBvoid png_set_write_user_transform_fn (png_structp \fP\fIpng_ptr\fP\fB, png_user_transform_ptr \fIwrite_user_transform_fn\fP\fB);\fP - -\fBvoid png_set_compression_buffer_size(png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIsize\fP\fB);\fP - -\fBint png_sig_cmp (png_bytep \fP\fIsig\fP\fB, png_size_t \fP\fIstart\fP\fB, png_size_t \fInum_to_check\fP\fB);\fP - -\fBvoid png_start_read_image (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_warning (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fImessage\fP\fB);\fP - -\fBvoid png_write_chunk (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIchunk_name\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP - -\fBvoid png_write_chunk_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP - -\fBvoid png_write_chunk_end (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_write_chunk_start (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIchunk_name\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_write_destroy (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_write_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBvoid png_write_flush (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_write_image (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fIimage\fP\fB);\fP - -\fBDEPRECATED: void png_write_init (png_structp \fIpng_ptr\fP\fB);\fP - -\fBDEPRECATED: void png_write_init_2 (png_structpp \fP\fIptr_ptr\fP\fB, png_const_charp \fP\fIuser_png_ver\fP\fB, png_size_t \fP\fIpng_struct_size\fP\fB, png_size_t \fIpng_info_size\fP\fB);\fP - -\fBvoid png_write_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBvoid png_write_info_before_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBvoid png_write_png (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fItransforms\fP\fB, png_voidp \fIparams\fP\fB);\fP - -\fBvoid png_write_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fBvoid png_write_rows (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fP\fIrow\fP\fB, png_uint_32 \fInum_rows\fP\fB);\fP - -\fBvoidpf png_zalloc (voidpf \fP\fIpng_ptr\fP\fB, uInt \fP\fIitems\fP\fB, uInt \fIsize\fP\fB);\fP - -\fBvoid png_zfree (voidpf \fP\fIpng_ptr\fP\fB, voidpf \fIptr\fP\fB);\fP - -.SH DESCRIPTION -The -.I libpng -library supports encoding, decoding, and various manipulations of -the Portable Network Graphics (PNG) format image files. It uses the -.IR zlib(3) -compression library. -Following is a copy of the libpng.txt file that accompanies libpng. -.SH LIBPNG.TXT -libpng.txt - A description on how to use and modify libpng - - libpng version 1.2.18 - May 15, 2007 - Updated and distributed by Glenn Randers-Pehrson - <glennrp at users.sourceforge.net> - Copyright (c) 1998-2007 Glenn Randers-Pehrson - For conditions of distribution and use, see copyright - notice in png.h. - - based on: - - libpng 1.0 beta 6 version 0.96 May 28, 1997 - Updated and distributed by Andreas Dilger - Copyright (c) 1996, 1997 Andreas Dilger - - libpng 1.0 beta 2 - version 0.88 January 26, 1996 - For conditions of distribution and use, see copyright - notice in png.h. Copyright (c) 1995, 1996 Guy Eric - Schalnat, Group 42, Inc. - - Updated/rewritten per request in the libpng FAQ - Copyright (c) 1995, 1996 Frank J. T. Wojcik - December 18, 1995 & January 20, 1996 - -.SH I. Introduction - -This file describes how to use and modify the PNG reference library -(known as libpng) for your own use. There are five sections to this -file: introduction, structures, reading, writing, and modification and -configuration notes for various special platforms. In addition to this -file, example.c is a good starting point for using the library, as -it is heavily commented and should include everything most people -will need. We assume that libpng is already installed; see the -INSTALL file for instructions on how to install libpng. - -For examples of libpng usage, see the files "example.c", "pngtest.c", -and the files in the "contrib" directory, all of which are included in the -libpng distribution. - -Libpng was written as a companion to the PNG specification, as a way -of reducing the amount of time and effort it takes to support the PNG -file format in application programs. - -The PNG specification (second edition), November 2003, is available as -a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2003 (E)) at -<http://www.w3.org/TR/2003/REC-PNG-20031110/ -The W3C and ISO documents have identical technical content. - -The PNG-1.2 specification is available at -<http://www.libpng.org/pub/png/documents/> - -The PNG-1.0 specification is available -as RFC 2083 <http://www.libpng.org/pub/png/documents/> and as a -W3C Recommendation <http://www.w3.org/TR/REC.png.html>. Some -additional chunks are described in the special-purpose public chunks -documents at <http://www.libpng.org/pub/png/documents/>. - -Other information -about PNG, and the latest version of libpng, can be found at the PNG home -page, <http://www.libpng.org/pub/png/>. - -Most users will not have to modify the library significantly; advanced -users may want to modify it more. All attempts were made to make it as -complete as possible, while keeping the code easy to understand. -Currently, this library only supports C. Support for other languages -is being considered. - -Libpng has been designed to handle multiple sessions at one time, -to be easily modifiable, to be portable to the vast majority of -machines (ANSI, K&R, 16-, 32-, and 64-bit) available, and to be easy -to use. The ultimate goal of libpng is to promote the acceptance of -the PNG file format in whatever way possible. While there is still -work to be done (see the TODO file), libpng should cover the -majority of the needs of its users. - -Libpng uses zlib for its compression and decompression of PNG files. -Further information about zlib, and the latest version of zlib, can -be found at the zlib home page, <http://www.info-zip.org/pub/infozip/zlib/>. -The zlib compression utility is a general purpose utility that is -useful for more than PNG files, and can be used without libpng. -See the documentation delivered with zlib for more details. -You can usually find the source files for the zlib utility wherever you -find the libpng source files. - -Libpng is thread safe, provided the threads are using different -instances of the structures. Each thread should have its own -png_struct and png_info instances, and thus its own image. -Libpng does not protect itself against two threads using the -same instance of a structure. Note: thread safety may be defeated -by use of some of the MMX assembler code in pnggccrd.c, which is only -compiled when the user defines PNG_THREAD_UNSAFE_OK. - -.SH II. Structures - -There are two main structures that are important to libpng, png_struct -and png_info. The first, png_struct, is an internal structure that -will not, for the most part, be used by a user except as the first -variable passed to every libpng function call. - -The png_info structure is designed to provide information about the -PNG file. At one time, the fields of png_info were intended to be -directly accessible to the user. However, this tended to cause problems -with applications using dynamically loaded libraries, and as a result -a set of interface functions for png_info (the png_get_*() and png_set_*() -functions) was developed. The fields of png_info are still available for -older applications, but it is suggested that applications use the new -interfaces if at all possible. - -Applications that do make direct access to the members of png_struct (except -for png_ptr->jmpbuf) must be recompiled whenever the library is updated, -and applications that make direct access to the members of png_info must -be recompiled if they were compiled or loaded with libpng version 1.0.6, -in which the members were in a different order. In version 1.0.7, the -members of the png_info structure reverted to the old order, as they were -in versions 0.97c through 1.0.5. Starting with version 2.0.0, both -structures are going to be hidden, and the contents of the structures will -only be accessible through the png_get/png_set functions. - -The png.h header file is an invaluable reference for programming with libpng. -And while I'm on the topic, make sure you include the libpng header file: - -#include <png.h> - -.SH III. Reading - -We'll now walk you through the possible functions to call when reading -in a PNG file sequentially, briefly explaining the syntax and purpose -of each one. See example.c and png.h for more detail. While -progressive reading is covered in the next section, you will still -need some of the functions discussed in this section to read a PNG -file. - -.SS Setup - -You will want to do the I/O initialization(*) before you get into libpng, -so if it doesn't work, you don't have much to undo. Of course, you -will also want to insure that you are, in fact, dealing with a PNG -file. Libpng provides a simple check to see if a file is a PNG file. -To use it, pass in the first 1 to 8 bytes of the file to the function -png_sig_cmp(), and it will return 0 if the bytes match the corresponding -bytes of the PNG signature, or nonzero otherwise. Of course, the more bytes -you pass in, the greater the accuracy of the prediction. - -If you are intending to keep the file pointer open for use in libpng, -you must ensure you don't read more than 8 bytes from the beginning -of the file, and you also have to make a call to png_set_sig_bytes_read() -with the number of bytes you read from the beginning. Libpng will -then only check the bytes (if any) that your program didn't read. - -(*): If you are not using the standard I/O functions, you will need -to replace them with custom functions. See the discussion under -Customizing libpng. - - - FILE *fp = fopen(file_name, "rb"); - if (!fp) - { - return (ERROR); - } - fread(header, 1, number, fp); - is_png = !png_sig_cmp(header, 0, number); - if (!is_png) - { - return (NOT_PNG); - } - - -Next, png_struct and png_info need to be allocated and initialized. In -order to ensure that the size of these structures is correct even with a -dynamically linked libpng, there are functions to initialize and -allocate the structures. We also pass the library version, optional -pointers to error handling functions, and a pointer to a data struct for -use by the error functions, if necessary (the pointer and functions can -be NULL if the default error handlers are to be used). See the section -on Changes to Libpng below regarding the old initialization functions. -The structure allocation functions quietly return NULL if they fail to -create the structure, so your application should check for that. - - png_structp png_ptr = png_create_read_struct - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn); - if (!png_ptr) - return (ERROR); - - png_infop info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - png_destroy_read_struct(&png_ptr, - (png_infopp)NULL, (png_infopp)NULL); - return (ERROR); - } - - png_infop end_info = png_create_info_struct(png_ptr); - if (!end_info) - { - png_destroy_read_struct(&png_ptr, &info_ptr, - (png_infopp)NULL); - return (ERROR); - } - -If you want to use your own memory allocation routines, -define PNG_USER_MEM_SUPPORTED and use -png_create_read_struct_2() instead of png_create_read_struct(): - - png_structp png_ptr = png_create_read_struct_2 - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn, (png_voidp) - user_mem_ptr, user_malloc_fn, user_free_fn); - -The error handling routines passed to png_create_read_struct() -and the memory alloc/free routines passed to png_create_struct_2() -are only necessary if you are not using the libpng supplied error -handling and memory alloc/free functions. - -When libpng encounters an error, it expects to longjmp back -to your routine. Therefore, you will need to call setjmp and pass -your png_jmpbuf(png_ptr). If you read the file from different -routines, you will need to update the jmpbuf field every time you enter -a new routine that will call a png_*() function. - -See your documentation of setjmp/longjmp for your compiler for more -information on setjmp/longjmp. See the discussion on libpng error -handling in the Customizing Libpng section below for more information -on the libpng error handling. If an error occurs, and libpng longjmp's -back to your setjmp, you will want to call png_destroy_read_struct() to -free any memory. - - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, - &end_info); - fclose(fp); - return (ERROR); - } - -If you would rather avoid the complexity of setjmp/longjmp issues, -you can compile libpng with PNG_SETJMP_NOT_SUPPORTED, in which case -errors will result in a call to PNG_ABORT() which defaults to abort(). - -Now you need to set up the input code. The default for libpng is to -use the C function fread(). If you use this, you will need to pass a -valid FILE * in the function png_init_io(). Be sure that the file is -opened in binary mode. If you wish to handle reading data in another -way, you need not call the png_init_io() function, but you must then -implement the libpng I/O methods discussed in the Customizing Libpng -section below. - - png_init_io(png_ptr, fp); - -If you had previously opened the file and read any of the signature from -the beginning in order to see if this was a PNG file, you need to let -libpng know that there are some bytes missing from the start of the file. - - png_set_sig_bytes(png_ptr, number); - -.SS Setting up callback code - -You can set up a callback function to handle any unknown chunks in the -input stream. You must supply the function - - read_chunk_callback(png_ptr ptr, - png_unknown_chunkp chunk); - { - /* The unknown chunk structure contains your - chunk data: */ - png_byte name[5]; - png_byte *data; - png_size_t size; - /* Note that libpng has already taken care of - the CRC handling */ - - /* put your code here. Return one of the - following: */ - - return (-n); /* chunk had an error */ - return (0); /* did not recognize */ - return (n); /* success */ - } - -(You can give your function another name that you like instead of -"read_chunk_callback") - -To inform libpng about your function, use - - png_set_read_user_chunk_fn(png_ptr, user_chunk_ptr, - read_chunk_callback); - -This names not only the callback function, but also a user pointer that -you can retrieve with - - png_get_user_chunk_ptr(png_ptr); - -At this point, you can set up a callback function that will be -called after each row has been read, which you can use to control -a progress meter or the like. It's demonstrated in pngtest.c. -You must supply a function - - void read_row_callback(png_ptr ptr, png_uint_32 row, - int pass); - { - /* put your code here */ - } - -(You can give it another name that you like instead of "read_row_callback") - -To inform libpng about your function, use - - png_set_read_status_fn(png_ptr, read_row_callback); - -.SS Width and height limits - -The PNG specification allows the width and height of an image to be as -large as 2^31-1 (0x7fffffff), or about 2.147 billion rows and columns. -Since very few applications really need to process such large images, -we have imposed an arbitrary 1-million limit on rows and columns. -Larger images will be rejected immediately with a png_error() call. If -you wish to override this limit, you can use - - png_set_user_limits(png_ptr, width_max, height_max); - -to set your own limits, or use width_max = height_max = 0x7fffffffL -to allow all valid dimensions (libpng may reject some very large images -anyway because of potential buffer overflow conditions). - -You should put this statement after you create the PNG structure and -before calling png_read_info(), png_read_png(), or png_process_data(). -If you need to retrieve the limits that are being applied, use - - width_max = png_get_user_width_max(png_ptr); - height_max = png_get_user_height_max(png_ptr); - -.SS Unknown-chunk handling - -Now you get to set the way the library processes unknown chunks in the -input PNG stream. Both known and unknown chunks will be read. Normal -behavior is that known chunks will be parsed into information in -various info_ptr members; unknown chunks will be discarded. To change -this, you can call: - - png_set_keep_unknown_chunks(png_ptr, keep, - chunk_list, num_chunks); - keep - 0: do not handle as unknown - 1: do not keep - 2: keep only if safe-to-copy - 3: keep even if unsafe-to-copy - You can use these definitions: - PNG_HANDLE_CHUNK_AS_DEFAULT 0 - PNG_HANDLE_CHUNK_NEVER 1 - PNG_HANDLE_CHUNK_IF_SAFE 2 - PNG_HANDLE_CHUNK_ALWAYS 3 - chunk_list - list of chunks affected (a byte string, - five bytes per chunk, NULL or '\0' if - num_chunks is 0) - num_chunks - number of chunks affected; if 0, all - unknown chunks are affected. If nonzero, - only the chunks in the list are affected - -Unknown chunks declared in this way will be saved as raw data onto a -list of png_unknown_chunk structures. If a chunk that is normally -known to libpng is named in the list, it will be handled as unknown, -according to the "keep" directive. If a chunk is named in successive -instances of png_set_keep_unknown_chunks(), the final instance will -take precedence. The IHDR and IEND chunks should not be named in -chunk_list; if they are, libpng will process them normally anyway. - -.SS The high-level read interface - -At this point there are two ways to proceed; through the high-level -read interface, or through a sequence of low-level read operations. -You can use the high-level interface if (a) you are willing to read -the entire image into memory, and (b) the input transformations -you want to do are limited to the following set: - - PNG_TRANSFORM_IDENTITY No transformation - PNG_TRANSFORM_STRIP_16 Strip 16-bit samples to - 8 bits - PNG_TRANSFORM_STRIP_ALPHA Discard the alpha channel - PNG_TRANSFORM_PACKING Expand 1, 2 and 4-bit - samples to bytes - PNG_TRANSFORM_PACKSWAP Change order of packed - pixels to LSB first - PNG_TRANSFORM_EXPAND Perform set_expand() - PNG_TRANSFORM_INVERT_MONO Invert monochrome images - PNG_TRANSFORM_SHIFT Normalize pixels to the - sBIT depth - PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA - to BGRA - PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA - to AG - PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity - to transparency - PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples - -(This excludes setting a background color, doing gamma transformation, -dithering, and setting filler.) If this is the case, simply do this: - - png_read_png(png_ptr, info_ptr, png_transforms, NULL) - -where png_transforms is an integer containing the bitwise OR of -some set of transformation flags. This call is equivalent to png_read_info(), -followed the set of transformations indicated by the transform mask, -then png_read_image(), and finally png_read_end(). - -(The final parameter of this call is not yet used. Someday it might point -to transformation parameters required by some future input transform.) - -You must use png_transforms and not call any png_set_transform() functions -when you use png_read_png(). - -After you have called png_read_png(), you can retrieve the image data -with - - row_pointers = png_get_rows(png_ptr, info_ptr); - -where row_pointers is an array of pointers to the pixel data for each row: - - png_bytep row_pointers[height]; - -If you know your image size and pixel size ahead of time, you can allocate -row_pointers prior to calling png_read_png() with - - if (height > PNG_UINT_32_MAX/png_sizeof(png_byte)) - png_error (png_ptr, - "Image is too tall to process in memory"); - if (width > PNG_UINT_32_MAX/pixel_size) - png_error (png_ptr, - "Image is too wide to process in memory"); - row_pointers = png_malloc(png_ptr, - height*png_sizeof(png_bytep)); - for (int i=0; i<height, i++) - row_pointers[i]=png_malloc(png_ptr, - width*pixel_size); - png_set_rows(png_ptr, info_ptr, &row_pointers); - -Alternatively you could allocate your image in one big block and define -row_pointers[i] to point into the proper places in your block. - -If you use png_set_rows(), the application is responsible for freeing -row_pointers (and row_pointers[i], if they were separately allocated). - -If you don't allocate row_pointers ahead of time, png_read_png() will -do it, and it'll be free'ed when you call png_destroy_*(). - -.SS The low-level read interface - -If you are going the low-level route, you are now ready to read all -the file information up to the actual image data. You do this with a -call to png_read_info(). - - png_read_info(png_ptr, info_ptr); - -This will process all chunks up to but not including the image data. - -.SS Querying the info structure - -Functions are used to get the information from the info_ptr once it -has been read. Note that these fields may not be completely filled -in until png_read_end() has read the chunk data following the image. - - png_get_IHDR(png_ptr, info_ptr, &width, &height, - &bit_depth, &color_type, &interlace_type, - &compression_type, &filter_method); - - width - holds the width of the image - in pixels (up to 2^31). - height - holds the height of the image - in pixels (up to 2^31). - bit_depth - holds the bit depth of one of the - image channels. (valid values are - 1, 2, 4, 8, 16 and depend also on - the color_type. See also - significant bits (sBIT) below). - color_type - describes which color/alpha channels - are present. - PNG_COLOR_TYPE_GRAY - (bit depths 1, 2, 4, 8, 16) - PNG_COLOR_TYPE_GRAY_ALPHA - (bit depths 8, 16) - PNG_COLOR_TYPE_PALETTE - (bit depths 1, 2, 4, 8) - PNG_COLOR_TYPE_RGB - (bit_depths 8, 16) - PNG_COLOR_TYPE_RGB_ALPHA - (bit_depths 8, 16) - - PNG_COLOR_MASK_PALETTE - PNG_COLOR_MASK_COLOR - PNG_COLOR_MASK_ALPHA - - filter_method - (must be PNG_FILTER_TYPE_BASE - for PNG 1.0, and can also be - PNG_INTRAPIXEL_DIFFERENCING if - the PNG datastream is embedded in - a MNG-1.0 datastream) - compression_type - (must be PNG_COMPRESSION_TYPE_BASE - for PNG 1.0) - interlace_type - (PNG_INTERLACE_NONE or - PNG_INTERLACE_ADAM7) - Any or all of interlace_type, compression_type, of - filter_method can be NULL if you are - not interested in their values. - - channels = png_get_channels(png_ptr, info_ptr); - channels - number of channels of info for the - color type (valid values are 1 (GRAY, - PALETTE), 2 (GRAY_ALPHA), 3 (RGB), - 4 (RGB_ALPHA or RGB + filler byte)) - rowbytes = png_get_rowbytes(png_ptr, info_ptr); - rowbytes - number of bytes needed to hold a row - - signature = png_get_signature(png_ptr, info_ptr); - signature - holds the signature read from the - file (if any). The data is kept in - the same offset it would be if the - whole signature were read (i.e. if an - application had already read in 4 - bytes of signature before starting - libpng, the remaining 4 bytes would - be in signature[4] through signature[7] - (see png_set_sig_bytes())). - - - width = png_get_image_width(png_ptr, - info_ptr); - height = png_get_image_height(png_ptr, - info_ptr); - bit_depth = png_get_bit_depth(png_ptr, - info_ptr); - color_type = png_get_color_type(png_ptr, - info_ptr); - filter_method = png_get_filter_type(png_ptr, - info_ptr); - compression_type = png_get_compression_type(png_ptr, - info_ptr); - interlace_type = png_get_interlace_type(png_ptr, - info_ptr); - - -These are also important, but their validity depends on whether the chunk -has been read. The png_get_valid(png_ptr, info_ptr, PNG_INFO_<chunk>) and -png_get_<chunk>(png_ptr, info_ptr, ...) functions return non-zero if the -data has been read, or zero if it is missing. The parameters to the -png_get_<chunk> are set directly if they are simple data types, or a pointer -into the info_ptr is returned for any complex types. - - png_get_PLTE(png_ptr, info_ptr, &palette, - &num_palette); - palette - the palette for the file - (array of png_color) - num_palette - number of entries in the palette - - png_get_gAMA(png_ptr, info_ptr, &gamma); - gamma - the gamma the file is written - at (PNG_INFO_gAMA) - - png_get_sRGB(png_ptr, info_ptr, &srgb_intent); - srgb_intent - the rendering intent (PNG_INFO_sRGB) - The presence of the sRGB chunk - means that the pixel data is in the - sRGB color space. This chunk also - implies specific values of gAMA and - cHRM. - - png_get_iCCP(png_ptr, info_ptr, &name, - &compression_type, &profile, &proflen); - name - The profile name. - compression - The compression type; always - PNG_COMPRESSION_TYPE_BASE for PNG 1.0. - You may give NULL to this argument to - ignore it. - profile - International Color Consortium color - profile data. May contain NULs. - proflen - length of profile data in bytes. - - png_get_sBIT(png_ptr, info_ptr, &sig_bit); - sig_bit - the number of significant bits for - (PNG_INFO_sBIT) each of the gray, - red, green, and blue channels, - whichever are appropriate for the - given color type (png_color_16) - - png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans, - &trans_values); - trans - array of transparent entries for - palette (PNG_INFO_tRNS) - trans_values - graylevel or color sample values of - the single transparent color for - non-paletted images (PNG_INFO_tRNS) - num_trans - number of transparent entries - (PNG_INFO_tRNS) - - png_get_hIST(png_ptr, info_ptr, &hist); - (PNG_INFO_hIST) - hist - histogram of palette (array of - png_uint_16) - - png_get_tIME(png_ptr, info_ptr, &mod_time); - mod_time - time image was last modified - (PNG_VALID_tIME) - - png_get_bKGD(png_ptr, info_ptr, &background); - background - background color (PNG_VALID_bKGD) - valid 16-bit red, green and blue - values, regardless of color_type - - num_comments = png_get_text(png_ptr, info_ptr, - &text_ptr, &num_text); - num_comments - number of comments - text_ptr - array of png_text holding image - comments - text_ptr[i].compression - type of compression used - on "text" PNG_TEXT_COMPRESSION_NONE - PNG_TEXT_COMPRESSION_zTXt - PNG_ITXT_COMPRESSION_NONE - PNG_ITXT_COMPRESSION_zTXt - text_ptr[i].key - keyword for comment. Must contain - 1-79 characters. - text_ptr[i].text - text comments for current - keyword. Can be empty. - text_ptr[i].text_length - length of text string, - after decompression, 0 for iTXt - text_ptr[i].itxt_length - length of itxt string, - after decompression, 0 for tEXt/zTXt - text_ptr[i].lang - language of comment (empty - string for unknown). - text_ptr[i].lang_key - keyword in UTF-8 - (empty string for unknown). - num_text - number of comments (same as - num_comments; you can put NULL here - to avoid the duplication) - Note while png_set_text() will accept text, language, - and translated keywords that can be NULL pointers, the - structure returned by png_get_text will always contain - regular zero-terminated C strings. They might be - empty strings but they will never be NULL pointers. - - num_spalettes = png_get_sPLT(png_ptr, info_ptr, - &palette_ptr); - palette_ptr - array of palette structures holding - contents of one or more sPLT chunks - read. - num_spalettes - number of sPLT chunks read. - - png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y, - &unit_type); - offset_x - positive offset from the left edge - of the screen - offset_y - positive offset from the top edge - of the screen - unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER - - png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y, - &unit_type); - res_x - pixels/unit physical resolution in - x direction - res_y - pixels/unit physical resolution in - x direction - unit_type - PNG_RESOLUTION_UNKNOWN, - PNG_RESOLUTION_METER - - png_get_sCAL(png_ptr, info_ptr, &unit, &width, - &height) - unit - physical scale units (an integer) - width - width of a pixel in physical scale units - height - height of a pixel in physical scale units - (width and height are doubles) - - png_get_sCAL_s(png_ptr, info_ptr, &unit, &width, - &height) - unit - physical scale units (an integer) - width - width of a pixel in physical scale units - height - height of a pixel in physical scale units - (width and height are strings like "2.54") - - num_unknown_chunks = png_get_unknown_chunks(png_ptr, - info_ptr, &unknowns) - unknowns - array of png_unknown_chunk - structures holding unknown chunks - unknowns[i].name - name of unknown chunk - unknowns[i].data - data of unknown chunk - unknowns[i].size - size of unknown chunk's data - unknowns[i].location - position of chunk in file - - The value of "i" corresponds to the order in which the - chunks were read from the PNG file or inserted with the - png_set_unknown_chunks() function. - -The data from the pHYs chunk can be retrieved in several convenient -forms: - - res_x = png_get_x_pixels_per_meter(png_ptr, - info_ptr) - res_y = png_get_y_pixels_per_meter(png_ptr, - info_ptr) - res_x_and_y = png_get_pixels_per_meter(png_ptr, - info_ptr) - res_x = png_get_x_pixels_per_inch(png_ptr, - info_ptr) - res_y = png_get_y_pixels_per_inch(png_ptr, - info_ptr) - res_x_and_y = png_get_pixels_per_inch(png_ptr, - info_ptr) - aspect_ratio = png_get_pixel_aspect_ratio(png_ptr, - info_ptr) - - (Each of these returns 0 [signifying "unknown"] if - the data is not present or if res_x is 0; - res_x_and_y is 0 if res_x != res_y) - -The data from the oFFs chunk can be retrieved in several convenient -forms: - - x_offset = png_get_x_offset_microns(png_ptr, info_ptr); - y_offset = png_get_y_offset_microns(png_ptr, info_ptr); - x_offset = png_get_x_offset_inches(png_ptr, info_ptr); - y_offset = png_get_y_offset_inches(png_ptr, info_ptr); - - (Each of these returns 0 [signifying "unknown" if both - x and y are 0] if the data is not present or if the - chunk is present but the unit is the pixel) - -For more information, see the png_info definition in png.h and the -PNG specification for chunk contents. Be careful with trusting -rowbytes, as some of the transformations could increase the space -needed to hold a row (expand, filler, gray_to_rgb, etc.). -See png_read_update_info(), below. - -A quick word about text_ptr and num_text. PNG stores comments in -keyword/text pairs, one pair per chunk, with no limit on the number -of text chunks, and a 2^31 byte limit on their size. While there are -suggested keywords, there is no requirement to restrict the use to these -strings. It is strongly suggested that keywords and text be sensible -to humans (that's the point), so don't use abbreviations. Non-printing -symbols are not allowed. See the PNG specification for more details. -There is also no requirement to have text after the keyword. - -Keywords should be limited to 79 Latin-1 characters without leading or -trailing spaces, but non-consecutive spaces are allowed within the -keyword. It is possible to have the same keyword any number of times. -The text_ptr is an array of png_text structures, each holding a -pointer to a language string, a pointer to a keyword and a pointer to -a text string. The text string, language code, and translated -keyword may be empty or NULL pointers. The keyword/text -pairs are put into the array in the order that they are received. -However, some or all of the text chunks may be after the image, so, to -make sure you have read all the text chunks, don't mess with these -until after you read the stuff after the image. This will be -mentioned again below in the discussion that goes with png_read_end(). - -.SS Input transformations - -After you've read the header information, you can set up the library -to handle any special transformations of the image data. The various -ways to transform the data will be described in the order that they -should occur. This is important, as some of these change the color -type and/or bit depth of the data, and some others only work on -certain color types and bit depths. Even though each transformation -checks to see if it has data that it can do something with, you should -make sure to only enable a transformation if it will be valid for the -data. For example, don't swap red and blue on grayscale data. - -The colors used for the background and transparency values should be -supplied in the same format/depth as the current image data. They -are stored in the same format/depth as the image data in a bKGD or tRNS -chunk, so this is what libpng expects for this data. The colors are -transformed to keep in sync with the image data when an application -calls the png_read_update_info() routine (see below). - -Data will be decoded into the supplied row buffers packed into bytes -unless the library has been told to transform it into another format. -For example, 4 bit/pixel paletted or grayscale data will be returned -2 pixels/byte with the leftmost pixel in the high-order bits of the -byte, unless png_set_packing() is called. 8-bit RGB data will be stored -in RGB RGB RGB format unless png_set_filler() or png_set_add_alpha() -is called to insert filler bytes, either before or after each RGB triplet. -16-bit RGB data will be returned RRGGBB RRGGBB, with the most significant -byte of the color value first, unless png_set_strip_16() is called to -transform it to regular RGB RGB triplets, or png_set_filler() or -png_set_add alpha() is called to insert filler bytes, either before or -after each RRGGBB triplet. Similarly, 8-bit or 16-bit grayscale data can -be modified with -png_set_filler(), png_set_add_alpha(), or png_set_strip_16(). - -The following code transforms grayscale images of less than 8 to 8 bits, -changes paletted images to RGB, and adds a full alpha channel if there is -transparency information in a tRNS chunk. This is most useful on -grayscale images with bit depths of 2 or 4 or if there is a multiple-image -viewing application that wishes to treat all images in the same way. - - if (color_type == PNG_COLOR_TYPE_PALETTE) - png_set_palette_to_rgb(png_ptr); - - if (color_type == PNG_COLOR_TYPE_GRAY && - bit_depth < 8) png_set_expand_gray_1_2_4_to_8(png_ptr); - - if (png_get_valid(png_ptr, info_ptr, - PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png_ptr); - -These three functions are actually aliases for png_set_expand(), added -in libpng version 1.0.4, with the function names expanded to improve code -readability. In some future version they may actually do different -things. - -As of libpng version 1.2.9, png_set_expand_gray_1_2_4_to_8() was -added. It expands the sample depth without changing tRNS to alpha. -At the same time, png_set_gray_1_2_4_to_8() was deprecated, and it -will be removed from a future version. - -PNG can have files with 16 bits per channel. If you only can handle -8 bits per channel, this will strip the pixels down to 8 bit. - - if (bit_depth == 16) - png_set_strip_16(png_ptr); - -If, for some reason, you don't need the alpha channel on an image, -and you want to remove it rather than combining it with the background -(but the image author certainly had in mind that you *would* combine -it with the background, so that's what you should probably do): - - if (color_type & PNG_COLOR_MASK_ALPHA) - png_set_strip_alpha(png_ptr); - -In PNG files, the alpha channel in an image -is the level of opacity. If you need the alpha channel in an image to -be the level of transparency instead of opacity, you can invert the -alpha channel (or the tRNS chunk data) after it's read, so that 0 is -fully opaque and 255 (in 8-bit or paletted images) or 65535 (in 16-bit -images) is fully transparent, with - - png_set_invert_alpha(png_ptr); - -PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as -they can, resulting in, for example, 8 pixels per byte for 1 bit -files. This code expands to 1 pixel per byte without changing the -values of the pixels: - - if (bit_depth < 8) - png_set_packing(png_ptr); - -PNG files have possible bit depths of 1, 2, 4, 8, and 16. All pixels -stored in a PNG image have been "scaled" or "shifted" up to the next -higher possible bit depth (e.g. from 5 bits/sample in the range [0,31] to -8 bits/sample in the range [0, 255]). However, it is also possible to -convert the PNG pixel data back to the original bit depth of the image. -This call reduces the pixels back down to the original bit depth: - - png_color_8p sig_bit; - - if (png_get_sBIT(png_ptr, info_ptr, &sig_bit)) - png_set_shift(png_ptr, sig_bit); - -PNG files store 3-color pixels in red, green, blue order. This code -changes the storage of the pixels to blue, green, red: - - if (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_RGB_ALPHA) - png_set_bgr(png_ptr); - -PNG files store RGB pixels packed into 3 or 6 bytes. This code expands them -into 4 or 8 bytes for windowing systems that need them in this format: - - if (color_type == PNG_COLOR_TYPE_RGB) - png_set_filler(png_ptr, filler, PNG_FILLER_BEFORE); - -where "filler" is the 8 or 16-bit number to fill with, and the location is -either PNG_FILLER_BEFORE or PNG_FILLER_AFTER, depending upon whether -you want the filler before the RGB or after. This transformation -does not affect images that already have full alpha channels. To add an -opaque alpha channel, use filler=0xff or 0xffff and PNG_FILLER_AFTER which -will generate RGBA pixels. - -Note that png_set_filler() does not change the color type. If you want -to do that, you can add a true alpha channel with - - if (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_GRAY) - png_set_add_alpha(png_ptr, filler, PNG_FILLER_AFTER); - -where "filler" contains the alpha value to assign to each pixel. -This function was added in libpng-1.2.7. - -If you are reading an image with an alpha channel, and you need the -data as ARGB instead of the normal PNG format RGBA: - - if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) - png_set_swap_alpha(png_ptr); - -For some uses, you may want a grayscale image to be represented as -RGB. This code will do that conversion: - - if (color_type == PNG_COLOR_TYPE_GRAY || - color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_gray_to_rgb(png_ptr); - -Conversely, you can convert an RGB or RGBA image to grayscale or grayscale -with alpha. - - if (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_RGB_ALPHA) - png_set_rgb_to_gray_fixed(png_ptr, error_action, - int red_weight, int green_weight); - - error_action = 1: silently do the conversion - error_action = 2: issue a warning if the original - image has any pixel where - red != green or red != blue - error_action = 3: issue an error and abort the - conversion if the original - image has any pixel where - red != green or red != blue - - red_weight: weight of red component times 100000 - green_weight: weight of green component times 100000 - If either weight is negative, default - weights (21268, 71514) are used. - -If you have set error_action = 1 or 2, you can -later check whether the image really was gray, after processing -the image rows, with the png_get_rgb_to_gray_status(png_ptr) function. -It will return a png_byte that is zero if the image was gray or -1 if there were any non-gray pixels. bKGD and sBIT data -will be silently converted to grayscale, using the green channel -data, regardless of the error_action setting. - -With red_weight+green_weight<=100000, -the normalized graylevel is computed: - - int rw = red_weight * 65536; - int gw = green_weight * 65536; - int bw = 65536 - (rw + gw); - gray = (rw*red + gw*green + bw*blue)/65536; - -The default values approximate those recommended in the Charles -Poynton's Color FAQ, <http://www.inforamp.net/~poynton/> -Copyright (c) 1998-01-04 Charles Poynton <poynton at inforamp.net> - - Y = 0.212671 * R + 0.715160 * G + 0.072169 * B - -Libpng approximates this with - - Y = 0.21268 * R + 0.7151 * G + 0.07217 * B - -which can be expressed with integers as - - Y = (6969 * R + 23434 * G + 2365 * B)/32768 - -The calculation is done in a linear colorspace, if the image gamma -is known. - -If you have a grayscale and you are using png_set_expand_depth(), -png_set_expand(), or png_set_gray_to_rgb to change to truecolor or to -a higher bit-depth, you must either supply the background color as a gray -value at the original file bit-depth (need_expand = 1) or else supply the -background color as an RGB triplet at the final, expanded bit depth -(need_expand = 0). Similarly, if you are reading a paletted image, you -must either supply the background color as a palette index (need_expand = 1) -or as an RGB triplet that may or may not be in the palette (need_expand = 0). - - png_color_16 my_background; - png_color_16p image_background; - - if (png_get_bKGD(png_ptr, info_ptr, &image_background)) - png_set_background(png_ptr, image_background, - PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); - else - png_set_background(png_ptr, &my_background, - PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); - -The png_set_background() function tells libpng to composite images -with alpha or simple transparency against the supplied background -color. If the PNG file contains a bKGD chunk (PNG_INFO_bKGD valid), -you may use this color, or supply another color more suitable for -the current display (e.g., the background color from a web page). You -need to tell libpng whether the color is in the gamma space of the -display (PNG_BACKGROUND_GAMMA_SCREEN for colors you supply), the file -(PNG_BACKGROUND_GAMMA_FILE for colors from the bKGD chunk), or one -that is neither of these gammas (PNG_BACKGROUND_GAMMA_UNIQUE - I don't -know why anyone would use this, but it's here). - -To properly display PNG images on any kind of system, the application needs -to know what the display gamma is. Ideally, the user will know this, and -the application will allow them to set it. One method of allowing the user -to set the display gamma separately for each system is to check for a -SCREEN_GAMMA or DISPLAY_GAMMA environment variable, which will hopefully be -correctly set. - -Note that display_gamma is the overall gamma correction required to produce -pleasing results, which depends on the lighting conditions in the surrounding -environment. In a dim or brightly lit room, no compensation other than -the physical gamma exponent of the monitor is needed, while in a dark room -a slightly smaller exponent is better. - - double gamma, screen_gamma; - - if (/* We have a user-defined screen - gamma value */) - { - screen_gamma = user_defined_screen_gamma; - } - /* One way that applications can share the same - screen gamma value */ - else if ((gamma_str = getenv("SCREEN_GAMMA")) - != NULL) - { - screen_gamma = (double)atof(gamma_str); - } - /* If we don't have another value */ - else - { - screen_gamma = 2.2; /* A good guess for a - PC monitor in a bright office or a dim room */ - screen_gamma = 2.0; /* A good guess for a - PC monitor in a dark room */ - screen_gamma = 1.7 or 1.0; /* A good - guess for Mac systems */ - } - -The png_set_gamma() function handles gamma transformations of the data. -Pass both the file gamma and the current screen_gamma. If the file does -not have a gamma value, you can pass one anyway if you have an idea what -it is (usually 0.45455 is a good guess for GIF images on PCs). Note -that file gammas are inverted from screen gammas. See the discussions -on gamma in the PNG specification for an excellent description of what -gamma is, and why all applications should support it. It is strongly -recommended that PNG viewers support gamma correction. - - if (png_get_gAMA(png_ptr, info_ptr, &gamma)) - png_set_gamma(png_ptr, screen_gamma, gamma); - else - png_set_gamma(png_ptr, screen_gamma, 0.45455); - -If you need to reduce an RGB file to a paletted file, or if a paletted -file has more entries then will fit on your screen, png_set_dither() -will do that. Note that this is a simple match dither that merely -finds the closest color available. This should work fairly well with -optimized palettes, and fairly badly with linear color cubes. If you -pass a palette that is larger then maximum_colors, the file will -reduce the number of colors in the palette so it will fit into -maximum_colors. If there is a histogram, it will use it to make -more intelligent choices when reducing the palette. If there is no -histogram, it may not do as good a job. - - if (color_type & PNG_COLOR_MASK_COLOR) - { - if (png_get_valid(png_ptr, info_ptr, - PNG_INFO_PLTE)) - { - png_uint_16p histogram = NULL; - - png_get_hIST(png_ptr, info_ptr, - &histogram); - png_set_dither(png_ptr, palette, num_palette, - max_screen_colors, histogram, 1); - } - else - { - png_color std_color_cube[MAX_SCREEN_COLORS] = - { ... colors ... }; - - png_set_dither(png_ptr, std_color_cube, - MAX_SCREEN_COLORS, MAX_SCREEN_COLORS, - NULL,0); - } - } - -PNG files describe monochrome as black being zero and white being one. -The following code will reverse this (make black be one and white be -zero): - - if (bit_depth == 1 && color_type == PNG_COLOR_TYPE_GRAY) - png_set_invert_mono(png_ptr); - -This function can also be used to invert grayscale and gray-alpha images: - - if (color_type == PNG_COLOR_TYPE_GRAY || - color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_invert_mono(png_ptr); - -PNG files store 16 bit pixels in network byte order (big-endian, -ie. most significant bits first). This code changes the storage to the -other way (little-endian, i.e. least significant bits first, the -way PCs store them): - - if (bit_depth == 16) - png_set_swap(png_ptr); - -If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you -need to change the order the pixels are packed into bytes, you can use: - - if (bit_depth < 8) - png_set_packswap(png_ptr); - -Finally, you can write your own transformation function if none of -the existing ones meets your needs. This is done by setting a callback -with - - png_set_read_user_transform_fn(png_ptr, - read_transform_fn); - -You must supply the function - - void read_transform_fn(png_ptr ptr, row_info_ptr - row_info, png_bytep data) - -See pngtest.c for a working example. Your function will be called -after all of the other transformations have been processed. - -You can also set up a pointer to a user structure for use by your -callback function, and you can inform libpng that your transform -function will change the number of channels or bit depth with the -function - - png_set_user_transform_info(png_ptr, user_ptr, - user_depth, user_channels); - -The user's application, not libpng, is responsible for allocating and -freeing any memory required for the user structure. - -You can retrieve the pointer via the function -png_get_user_transform_ptr(). For example: - - voidp read_user_transform_ptr = - png_get_user_transform_ptr(png_ptr); - -The last thing to handle is interlacing; this is covered in detail below, -but you must call the function here if you want libpng to handle expansion -of the interlaced image. - - number_of_passes = png_set_interlace_handling(png_ptr); - -After setting the transformations, libpng can update your png_info -structure to reflect any transformations you've requested with this -call. This is most useful to update the info structure's rowbytes -field so you can use it to allocate your image memory. This function -will also update your palette with the correct screen_gamma and -background if these have been given with the calls above. - - png_read_update_info(png_ptr, info_ptr); - -After you call png_read_update_info(), you can allocate any -memory you need to hold the image. The row data is simply -raw byte data for all forms of images. As the actual allocation -varies among applications, no example will be given. If you -are allocating one large chunk, you will need to build an -array of pointers to each row, as it will be needed for some -of the functions below. - -.SS Reading image data - -After you've allocated memory, you can read the image data. -The simplest way to do this is in one function call. If you are -allocating enough memory to hold the whole image, you can just -call png_read_image() and libpng will read in all the image data -and put it in the memory area supplied. You will need to pass in -an array of pointers to each row. - -This function automatically handles interlacing, so you don't need -to call png_set_interlace_handling() or call this function multiple -times, or any of that other stuff necessary with png_read_rows(). - - png_read_image(png_ptr, row_pointers); - -where row_pointers is: - - png_bytep row_pointers[height]; - -You can point to void or char or whatever you use for pixels. - -If you don't want to read in the whole image at once, you can -use png_read_rows() instead. If there is no interlacing (check -interlace_type == PNG_INTERLACE_NONE), this is simple: - - png_read_rows(png_ptr, row_pointers, NULL, - number_of_rows); - -where row_pointers is the same as in the png_read_image() call. - -If you are doing this just one row at a time, you can do this with -a single row_pointer instead of an array of row_pointers: - - png_bytep row_pointer = row; - png_read_row(png_ptr, row_pointer, NULL); - -If the file is interlaced (interlace_type != 0 in the IHDR chunk), things -get somewhat harder. The only current (PNG Specification version 1.2) -interlacing type for PNG is (interlace_type == PNG_INTERLACE_ADAM7) -is a somewhat complicated 2D interlace scheme, known as Adam7, that -breaks down an image into seven smaller images of varying size, based -on an 8x8 grid. - -libpng can fill out those images or it can give them to you "as is". -If you want them filled out, there are two ways to do that. The one -mentioned in the PNG specification is to expand each pixel to cover -those pixels that have not been read yet (the "rectangle" method). -This results in a blocky image for the first pass, which gradually -smooths out as more pixels are read. The other method is the "sparkle" -method, where pixels are drawn only in their final locations, with the -rest of the image remaining whatever colors they were initialized to -before the start of the read. The first method usually looks better, -but tends to be slower, as there are more pixels to put in the rows. - -If you don't want libpng to handle the interlacing details, just call -png_read_rows() seven times to read in all seven images. Each of the -images is a valid image by itself, or they can all be combined on an -8x8 grid to form a single image (although if you intend to combine them -you would be far better off using the libpng interlace handling). - -The first pass will return an image 1/8 as wide as the entire image -(every 8th column starting in column 0) and 1/8 as high as the original -(every 8th row starting in row 0), the second will be 1/8 as wide -(starting in column 4) and 1/8 as high (also starting in row 0). The -third pass will be 1/4 as wide (every 4th pixel starting in column 0) and -1/8 as high (every 8th row starting in row 4), and the fourth pass will -be 1/4 as wide and 1/4 as high (every 4th column starting in column 2, -and every 4th row starting in row 0). The fifth pass will return an -image 1/2 as wide, and 1/4 as high (starting at column 0 and row 2), -while the sixth pass will be 1/2 as wide and 1/2 as high as the original -(starting in column 1 and row 0). The seventh and final pass will be as -wide as the original, and 1/2 as high, containing all of the odd -numbered scanlines. Phew! - -If you want libpng to expand the images, call this before calling -png_start_read_image() or png_read_update_info(): - - if (interlace_type == PNG_INTERLACE_ADAM7) - number_of_passes - = png_set_interlace_handling(png_ptr); - -This will return the number of passes needed. Currently, this -is seven, but may change if another interlace type is added. -This function can be called even if the file is not interlaced, -where it will return one pass. - -If you are not going to display the image after each pass, but are -going to wait until the entire image is read in, use the sparkle -effect. This effect is faster and the end result of either method -is exactly the same. If you are planning on displaying the image -after each pass, the "rectangle" effect is generally considered the -better looking one. - -If you only want the "sparkle" effect, just call png_read_rows() as -normal, with the third parameter NULL. Make sure you make pass over -the image number_of_passes times, and you don't change the data in the -rows between calls. You can change the locations of the data, just -not the data. Each pass only writes the pixels appropriate for that -pass, and assumes the data from previous passes is still valid. - - png_read_rows(png_ptr, row_pointers, NULL, - number_of_rows); - -If you only want the first effect (the rectangles), do the same as -before except pass the row buffer in the third parameter, and leave -the second parameter NULL. - - png_read_rows(png_ptr, NULL, row_pointers, - number_of_rows); - -.SS Finishing a sequential read - -After you are finished reading the image through the -low-level interface, you can finish reading the file. If you are -interested in comments or time, which may be stored either before or -after the image data, you should pass the separate png_info struct if -you want to keep the comments from before and after the image -separate. If you are not interested, you can pass NULL. - - png_read_end(png_ptr, end_info); - -When you are done, you can free all memory allocated by libpng like this: - - png_destroy_read_struct(&png_ptr, &info_ptr, - &end_info); - -It is also possible to individually free the info_ptr members that -point to libpng-allocated storage with the following function: - - png_free_data(png_ptr, info_ptr, mask, seq) - mask - identifies data to be freed, a mask - containing the bitwise OR of one or - more of - PNG_FREE_PLTE, PNG_FREE_TRNS, - PNG_FREE_HIST, PNG_FREE_ICCP, - PNG_FREE_PCAL, PNG_FREE_ROWS, - PNG_FREE_SCAL, PNG_FREE_SPLT, - PNG_FREE_TEXT, PNG_FREE_UNKN, - or simply PNG_FREE_ALL - seq - sequence number of item to be freed - (-1 for all items) - -This function may be safely called when the relevant storage has -already been freed, or has not yet been allocated, or was allocated -by the user and not by libpng, and will in those -cases do nothing. The "seq" parameter is ignored if only one item -of the selected data type, such as PLTE, is allowed. If "seq" is not --1, and multiple items are allowed for the data type identified in -the mask, such as text or sPLT, only the n'th item in the structure -is freed, where n is "seq". - -The default behavior is only to free data that was allocated internally -by libpng. This can be changed, so that libpng will not free the data, -or so that it will free data that was allocated by the user with png_malloc() -or png_zalloc() and passed in via a png_set_*() function, with - - png_data_freer(png_ptr, info_ptr, freer, mask) - mask - which data elements are affected - same choices as in png_free_data() - freer - one of - PNG_DESTROY_WILL_FREE_DATA - PNG_SET_WILL_FREE_DATA - PNG_USER_WILL_FREE_DATA - -This function only affects data that has already been allocated. -You can call this function after reading the PNG data but before calling -any png_set_*() functions, to control whether the user or the png_set_*() -function is responsible for freeing any existing data that might be present, -and again after the png_set_*() functions to control whether the user -or png_destroy_*() is supposed to free the data. When the user assumes -responsibility for libpng-allocated data, the application must use -png_free() to free it, and when the user transfers responsibility to libpng -for data that the user has allocated, the user must have used png_malloc() -or png_zalloc() to allocate it. - -If you allocated your row_pointers in a single block, as suggested above in -the description of the high level read interface, you must not transfer -responsibility for freeing it to the png_set_rows or png_read_destroy function, -because they would also try to free the individual row_pointers[i]. - -If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword -separately, do not transfer responsibility for freeing text_ptr to libpng, -because when libpng fills a png_text structure it combines these members with -the key member, and png_free_data() will free only text_ptr.key. Similarly, -if you transfer responsibility for free'ing text_ptr from libpng to your -application, your application must not separately free those members. - -The png_free_data() function will turn off the "valid" flag for anything -it frees. If you need to turn the flag off for a chunk that was freed by your -application instead of by libpng, you can use - - png_set_invalid(png_ptr, info_ptr, mask); - mask - identifies the chunks to be made invalid, - containing the bitwise OR of one or - more of - PNG_INFO_gAMA, PNG_INFO_sBIT, - PNG_INFO_cHRM, PNG_INFO_PLTE, - PNG_INFO_tRNS, PNG_INFO_bKGD, - PNG_INFO_hIST, PNG_INFO_pHYs, - PNG_INFO_oFFs, PNG_INFO_tIME, - PNG_INFO_pCAL, PNG_INFO_sRGB, - PNG_INFO_iCCP, PNG_INFO_sPLT, - PNG_INFO_sCAL, PNG_INFO_IDAT - -For a more compact example of reading a PNG image, see the file example.c. - -.SS Reading PNG files progressively - -The progressive reader is slightly different then the non-progressive -reader. Instead of calling png_read_info(), png_read_rows(), and -png_read_end(), you make one call to png_process_data(), which calls -callbacks when it has the info, a row, or the end of the image. You -set up these callbacks with png_set_progressive_read_fn(). You don't -have to worry about the input/output functions of libpng, as you are -giving the library the data directly in png_process_data(). I will -assume that you have read the section on reading PNG files above, -so I will only highlight the differences (although I will show -all of the code). - -png_structp png_ptr; -png_infop info_ptr; - - /* An example code fragment of how you would - initialize the progressive reader in your - application. */ - int - initialize_png_reader() - { - png_ptr = png_create_read_struct - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn); - if (!png_ptr) - return (ERROR); - info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - png_destroy_read_struct(&png_ptr, (png_infopp)NULL, - (png_infopp)NULL); - return (ERROR); - } - - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, - (png_infopp)NULL); - return (ERROR); - } - - /* This one's new. You can provide functions - to be called when the header info is valid, - when each row is completed, and when the image - is finished. If you aren't using all functions, - you can specify NULL parameters. Even when all - three functions are NULL, you need to call - png_set_progressive_read_fn(). You can use - any struct as the user_ptr (cast to a void pointer - for the function call), and retrieve the pointer - from inside the callbacks using the function - - png_get_progressive_ptr(png_ptr); - - which will return a void pointer, which you have - to cast appropriately. - */ - png_set_progressive_read_fn(png_ptr, (void *)user_ptr, - info_callback, row_callback, end_callback); - - return 0; - } - - /* A code fragment that you call as you receive blocks - of data */ - int - process_data(png_bytep buffer, png_uint_32 length) - { - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, - (png_infopp)NULL); - return (ERROR); - } - - /* This one's new also. Simply give it a chunk - of data from the file stream (in order, of - course). On machines with segmented memory - models machines, don't give it any more than - 64K. The library seems to run fine with sizes - of 4K. Although you can give it much less if - necessary (I assume you can give it chunks of - 1 byte, I haven't tried less then 256 bytes - yet). When this function returns, you may - want to display any rows that were generated - in the row callback if you don't already do - so there. - */ - png_process_data(png_ptr, info_ptr, buffer, length); - return 0; - } - - /* This function is called (as set by - png_set_progressive_read_fn() above) when enough data - has been supplied so all of the header has been - read. - */ - void - info_callback(png_structp png_ptr, png_infop info) - { - /* Do any setup here, including setting any of - the transformations mentioned in the Reading - PNG files section. For now, you _must_ call - either png_start_read_image() or - png_read_update_info() after all the - transformations are set (even if you don't set - any). You may start getting rows before - png_process_data() returns, so this is your - last chance to prepare for that. - */ - } - - /* This function is called when each row of image - data is complete */ - void - row_callback(png_structp png_ptr, png_bytep new_row, - png_uint_32 row_num, int pass) - { - /* If the image is interlaced, and you turned - on the interlace handler, this function will - be called for every row in every pass. Some - of these rows will not be changed from the - previous pass. When the row is not changed, - the new_row variable will be NULL. The rows - and passes are called in order, so you don't - really need the row_num and pass, but I'm - supplying them because it may make your life - easier. - - For the non-NULL rows of interlaced images, - you must call png_progressive_combine_row() - passing in the row and the old row. You can - call this function for NULL rows (it will just - return) and for non-interlaced images (it just - does the memcpy for you) if it will make the - code easier. Thus, you can just do this for - all cases: - */ - - png_progressive_combine_row(png_ptr, old_row, - new_row); - - /* where old_row is what was displayed for - previously for the row. Note that the first - pass (pass == 0, really) will completely cover - the old row, so the rows do not have to be - initialized. After the first pass (and only - for interlaced images), you will have to pass - the current row, and the function will combine - the old row and the new row. - */ - } - - void - end_callback(png_structp png_ptr, png_infop info) - { - /* This function is called after the whole image - has been read, including any chunks after the - image (up to and including the IEND). You - will usually have the same info chunk as you - had in the header, although some data may have - been added to the comments and time fields. - - Most people won't do much here, perhaps setting - a flag that marks the image as finished. - */ - } - - - -.SH IV. Writing - -Much of this is very similar to reading. However, everything of -importance is repeated here, so you won't have to constantly look -back up in the reading section to understand writing. - -.SS Setup - -You will want to do the I/O initialization before you get into libpng, -so if it doesn't work, you don't have anything to undo. If you are not -using the standard I/O functions, you will need to replace them with -custom writing functions. See the discussion under Customizing libpng. - - FILE *fp = fopen(file_name, "wb"); - if (!fp) - { - return (ERROR); - } - -Next, png_struct and png_info need to be allocated and initialized. -As these can be both relatively large, you may not want to store these -on the stack, unless you have stack space to spare. Of course, you -will want to check if they return NULL. If you are also reading, -you won't want to name your read structure and your write structure -both "png_ptr"; you can call them anything you like, such as -"read_ptr" and "write_ptr". Look at pngtest.c, for example. - - png_structp png_ptr = png_create_write_struct - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn); - if (!png_ptr) - return (ERROR); - - png_infop info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - png_destroy_write_struct(&png_ptr, - (png_infopp)NULL); - return (ERROR); - } - -If you want to use your own memory allocation routines, -define PNG_USER_MEM_SUPPORTED and use -png_create_write_struct_2() instead of png_create_write_struct(): - - png_structp png_ptr = png_create_write_struct_2 - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn, (png_voidp) - user_mem_ptr, user_malloc_fn, user_free_fn); - -After you have these structures, you will need to set up the -error handling. When libpng encounters an error, it expects to -longjmp() back to your routine. Therefore, you will need to call -setjmp() and pass the png_jmpbuf(png_ptr). If you -write the file from different routines, you will need to update -the png_jmpbuf(png_ptr) every time you enter a new routine that will -call a png_*() function. See your documentation of setjmp/longjmp -for your compiler for more information on setjmp/longjmp. See -the discussion on libpng error handling in the Customizing Libpng -section below for more information on the libpng error handling. - - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_write_struct(&png_ptr, &info_ptr); - fclose(fp); - return (ERROR); - } - ... - return; - -If you would rather avoid the complexity of setjmp/longjmp issues, -you can compile libpng with PNG_SETJMP_NOT_SUPPORTED, in which case -errors will result in a call to PNG_ABORT() which defaults to abort(). - -Now you need to set up the output code. The default for libpng is to -use the C function fwrite(). If you use this, you will need to pass a -valid FILE * in the function png_init_io(). Be sure that the file is -opened in binary mode. Again, if you wish to handle writing data in -another way, see the discussion on libpng I/O handling in the Customizing -Libpng section below. - - png_init_io(png_ptr, fp); - -If you are embedding your PNG into a datastream such as MNG, and don't -want libpng to write the 8-byte signature, or if you have already -written the signature in your application, use - - png_set_sig_bytes(png_ptr, 8); - -to inform libpng that it should not write a signature. - -.SS Write callbacks - -At this point, you can set up a callback function that will be -called after each row has been written, which you can use to control -a progress meter or the like. It's demonstrated in pngtest.c. -You must supply a function - - void write_row_callback(png_ptr, png_uint_32 row, - int pass); - { - /* put your code here */ - } - -(You can give it another name that you like instead of "write_row_callback") - -To inform libpng about your function, use - - png_set_write_status_fn(png_ptr, write_row_callback); - -You now have the option of modifying how the compression library will -run. The following functions are mainly for testing, but may be useful -in some cases, like if you need to write PNG files extremely fast and -are willing to give up some compression, or if you want to get the -maximum possible compression at the expense of slower writing. If you -have no special needs in this area, let the library do what it wants by -not calling this function at all, as it has been tuned to deliver a good -speed/compression ratio. The second parameter to png_set_filter() is -the filter method, for which the only valid values are 0 (as of the -July 1999 PNG specification, version 1.2) or 64 (if you are writing -a PNG datastream that is to be embedded in a MNG datastream). The third -parameter is a flag that indicates which filter type(s) are to be tested -for each scanline. See the PNG specification for details on the specific filter -types. - - - /* turn on or off filtering, and/or choose - specific filters. You can use either a single - PNG_FILTER_VALUE_NAME or the bitwise OR of one - or more PNG_FILTER_NAME masks. */ - png_set_filter(png_ptr, 0, - PNG_FILTER_NONE | PNG_FILTER_VALUE_NONE | - PNG_FILTER_SUB | PNG_FILTER_VALUE_SUB | - PNG_FILTER_UP | PNG_FILTER_VALUE_UP | - PNG_FILTER_AVE | PNG_FILTER_VALUE_AVE | - PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH| - PNG_ALL_FILTERS); - -If an application -wants to start and stop using particular filters during compression, -it should start out with all of the filters (to ensure that the previous -row of pixels will be stored in case it's needed later), and then add -and remove them after the start of compression. - -If you are writing a PNG datastream that is to be embedded in a MNG -datastream, the second parameter can be either 0 or 64. - -The png_set_compression_*() functions interface to the zlib compression -library, and should mostly be ignored unless you really know what you are -doing. The only generally useful call is png_set_compression_level() -which changes how much time zlib spends on trying to compress the image -data. See the Compression Library (zlib.h and algorithm.txt, distributed -with zlib) for details on the compression levels. - - /* set the zlib compression level */ - png_set_compression_level(png_ptr, - Z_BEST_COMPRESSION); - - /* set other zlib parameters */ - png_set_compression_mem_level(png_ptr, 8); - png_set_compression_strategy(png_ptr, - Z_DEFAULT_STRATEGY); - png_set_compression_window_bits(png_ptr, 15); - png_set_compression_method(png_ptr, 8); - png_set_compression_buffer_size(png_ptr, 8192) - -extern PNG_EXPORT(void,png_set_zbuf_size) - -.SS Setting the contents of info for output - -You now need to fill in the png_info structure with all the data you -wish to write before the actual image. Note that the only thing you -are allowed to write after the image is the text chunks and the time -chunk (as of PNG Specification 1.2, anyway). See png_write_end() and -the latest PNG specification for more information on that. If you -wish to write them before the image, fill them in now, and flag that -data as being valid. If you want to wait until after the data, don't -fill them until png_write_end(). For all the fields in png_info and -their data types, see png.h. For explanations of what the fields -contain, see the PNG specification. - -Some of the more important parts of the png_info are: - - png_set_IHDR(png_ptr, info_ptr, width, height, - bit_depth, color_type, interlace_type, - compression_type, filter_method) - width - holds the width of the image - in pixels (up to 2^31). - height - holds the height of the image - in pixels (up to 2^31). - bit_depth - holds the bit depth of one of the - image channels. - (valid values are 1, 2, 4, 8, 16 - and depend also on the - color_type. See also significant - bits (sBIT) below). - color_type - describes which color/alpha - channels are present. - PNG_COLOR_TYPE_GRAY - (bit depths 1, 2, 4, 8, 16) - PNG_COLOR_TYPE_GRAY_ALPHA - (bit depths 8, 16) - PNG_COLOR_TYPE_PALETTE - (bit depths 1, 2, 4, 8) - PNG_COLOR_TYPE_RGB - (bit_depths 8, 16) - PNG_COLOR_TYPE_RGB_ALPHA - (bit_depths 8, 16) - - PNG_COLOR_MASK_PALETTE - PNG_COLOR_MASK_COLOR - PNG_COLOR_MASK_ALPHA - - interlace_type - PNG_INTERLACE_NONE or - PNG_INTERLACE_ADAM7 - compression_type - (must be - PNG_COMPRESSION_TYPE_DEFAULT) - filter_method - (must be PNG_FILTER_TYPE_DEFAULT - or, if you are writing a PNG to - be embedded in a MNG datastream, - can also be - PNG_INTRAPIXEL_DIFFERENCING) - - png_set_PLTE(png_ptr, info_ptr, palette, - num_palette); - palette - the palette for the file - (array of png_color) - num_palette - number of entries in the palette - - png_set_gAMA(png_ptr, info_ptr, gamma); - gamma - the gamma the image was created - at (PNG_INFO_gAMA) - - png_set_sRGB(png_ptr, info_ptr, srgb_intent); - srgb_intent - the rendering intent - (PNG_INFO_sRGB) The presence of - the sRGB chunk means that the pixel - data is in the sRGB color space. - This chunk also implies specific - values of gAMA and cHRM. Rendering - intent is the CSS-1 property that - has been defined by the International - Color Consortium - (http://www.color.org). - It can be one of - PNG_sRGB_INTENT_SATURATION, - PNG_sRGB_INTENT_PERCEPTUAL, - PNG_sRGB_INTENT_ABSOLUTE, or - PNG_sRGB_INTENT_RELATIVE. - - - png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, - srgb_intent); - srgb_intent - the rendering intent - (PNG_INFO_sRGB) The presence of the - sRGB chunk means that the pixel - data is in the sRGB color space. - This function also causes gAMA and - cHRM chunks with the specific values - that are consistent with sRGB to be - written. - - png_set_iCCP(png_ptr, info_ptr, name, compression_type, - profile, proflen); - name - The profile name. - compression - The compression type; always - PNG_COMPRESSION_TYPE_BASE for PNG 1.0. - You may give NULL to this argument to - ignore it. - profile - International Color Consortium color - profile data. May contain NULs. - proflen - length of profile data in bytes. - - png_set_sBIT(png_ptr, info_ptr, sig_bit); - sig_bit - the number of significant bits for - (PNG_INFO_sBIT) each of the gray, red, - green, and blue channels, whichever are - appropriate for the given color type - (png_color_16) - - png_set_tRNS(png_ptr, info_ptr, trans, num_trans, - trans_values); - trans - array of transparent entries for - palette (PNG_INFO_tRNS) - trans_values - graylevel or color sample values of - the single transparent color for - non-paletted images (PNG_INFO_tRNS) - num_trans - number of transparent entries - (PNG_INFO_tRNS) - - png_set_hIST(png_ptr, info_ptr, hist); - (PNG_INFO_hIST) - hist - histogram of palette (array of - png_uint_16) - - png_set_tIME(png_ptr, info_ptr, mod_time); - mod_time - time image was last modified - (PNG_VALID_tIME) - - png_set_bKGD(png_ptr, info_ptr, background); - background - background color (PNG_VALID_bKGD) - - png_set_text(png_ptr, info_ptr, text_ptr, num_text); - text_ptr - array of png_text holding image - comments - text_ptr[i].compression - type of compression used - on "text" PNG_TEXT_COMPRESSION_NONE - PNG_TEXT_COMPRESSION_zTXt - PNG_ITXT_COMPRESSION_NONE - PNG_ITXT_COMPRESSION_zTXt - text_ptr[i].key - keyword for comment. Must contain - 1-79 characters. - text_ptr[i].text - text comments for current - keyword. Can be NULL or empty. - text_ptr[i].text_length - length of text string, - after decompression, 0 for iTXt - text_ptr[i].itxt_length - length of itxt string, - after decompression, 0 for tEXt/zTXt - text_ptr[i].lang - language of comment (NULL or - empty for unknown). - text_ptr[i].translated_keyword - keyword in UTF-8 (NULL - or empty for unknown). - num_text - number of comments - - png_set_sPLT(png_ptr, info_ptr, &palette_ptr, - num_spalettes); - palette_ptr - array of png_sPLT_struct structures - to be added to the list of palettes - in the info structure. - num_spalettes - number of palette structures to be - added. - - png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y, - unit_type); - offset_x - positive offset from the left - edge of the screen - offset_y - positive offset from the top - edge of the screen - unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER - - png_set_pHYs(png_ptr, info_ptr, res_x, res_y, - unit_type); - res_x - pixels/unit physical resolution - in x direction - res_y - pixels/unit physical resolution - in y direction - unit_type - PNG_RESOLUTION_UNKNOWN, - PNG_RESOLUTION_METER - - png_set_sCAL(png_ptr, info_ptr, unit, width, height) - unit - physical scale units (an integer) - width - width of a pixel in physical scale units - height - height of a pixel in physical scale units - (width and height are doubles) - - png_set_sCAL_s(png_ptr, info_ptr, unit, width, height) - unit - physical scale units (an integer) - width - width of a pixel in physical scale units - height - height of a pixel in physical scale units - (width and height are strings like "2.54") - - png_set_unknown_chunks(png_ptr, info_ptr, &unknowns, - num_unknowns) - unknowns - array of png_unknown_chunk - structures holding unknown chunks - unknowns[i].name - name of unknown chunk - unknowns[i].data - data of unknown chunk - unknowns[i].size - size of unknown chunk's data - unknowns[i].location - position to write chunk in file - 0: do not write chunk - PNG_HAVE_IHDR: before PLTE - PNG_HAVE_PLTE: before IDAT - PNG_AFTER_IDAT: after IDAT - -The "location" member is set automatically according to -what part of the output file has already been written. -You can change its value after calling png_set_unknown_chunks() -as demonstrated in pngtest.c. Within each of the "locations", -the chunks are sequenced according to their position in the -structure (that is, the value of "i", which is the order in which -the chunk was either read from the input file or defined with -png_set_unknown_chunks). - -A quick word about text and num_text. text is an array of png_text -structures. num_text is the number of valid structures in the array. -Each png_text structure holds a language code, a keyword, a text value, -and a compression type. - -The compression types have the same valid numbers as the compression -types of the image data. Currently, the only valid number is zero. -However, you can store text either compressed or uncompressed, unlike -images, which always have to be compressed. So if you don't want the -text compressed, set the compression type to PNG_TEXT_COMPRESSION_NONE. -Because tEXt and zTXt chunks don't have a language field, if you -specify PNG_TEXT_COMPRESSION_NONE or PNG_TEXT_COMPRESSION_zTXt -any language code or translated keyword will not be written out. - -Until text gets around 1000 bytes, it is not worth compressing it. -After the text has been written out to the file, the compression type -is set to PNG_TEXT_COMPRESSION_NONE_WR or PNG_TEXT_COMPRESSION_zTXt_WR, -so that it isn't written out again at the end (in case you are calling -png_write_end() with the same struct. - -The keywords that are given in the PNG Specification are: - - Title Short (one line) title or - caption for image - Author Name of image's creator - Description Description of image (possibly long) - Copyright Copyright notice - Creation Time Time of original image creation - (usually RFC 1123 format, see below) - Software Software used to create the image - Disclaimer Legal disclaimer - Warning Warning of nature of content - Source Device used to create the image - Comment Miscellaneous comment; conversion - from other image format - -The keyword-text pairs work like this. Keywords should be short -simple descriptions of what the comment is about. Some typical -keywords are found in the PNG specification, as is some recommendations -on keywords. You can repeat keywords in a file. You can even write -some text before the image and some after. For example, you may want -to put a description of the image before the image, but leave the -disclaimer until after, so viewers working over modem connections -don't have to wait for the disclaimer to go over the modem before -they start seeing the image. Finally, keywords should be full -words, not abbreviations. Keywords and text are in the ISO 8859-1 -(Latin-1) character set (a superset of regular ASCII) and can not -contain NUL characters, and should not contain control or other -unprintable characters. To make the comments widely readable, stick -with basic ASCII, and avoid machine specific character set extensions -like the IBM-PC character set. The keyword must be present, but -you can leave off the text string on non-compressed pairs. -Compressed pairs must have a text string, as only the text string -is compressed anyway, so the compression would be meaningless. - -PNG supports modification time via the png_time structure. Two -conversion routines are provided, png_convert_from_time_t() for -time_t and png_convert_from_struct_tm() for struct tm. The -time_t routine uses gmtime(). You don't have to use either of -these, but if you wish to fill in the png_time structure directly, -you should provide the time in universal time (GMT) if possible -instead of your local time. Note that the year number is the full -year (e.g. 1998, rather than 98 - PNG is year 2000 compliant!), and -that months start with 1. - -If you want to store the time of the original image creation, you should -use a plain tEXt chunk with the "Creation Time" keyword. This is -necessary because the "creation time" of a PNG image is somewhat vague, -depending on whether you mean the PNG file, the time the image was -created in a non-PNG format, a still photo from which the image was -scanned, or possibly the subject matter itself. In order to facilitate -machine-readable dates, it is recommended that the "Creation Time" -tEXt chunk use RFC 1123 format dates (e.g. "22 May 1997 18:07:10 GMT"), -although this isn't a requirement. Unlike the tIME chunk, the -"Creation Time" tEXt chunk is not expected to be automatically changed -by the software. To facilitate the use of RFC 1123 dates, a function -png_convert_to_rfc1123(png_timep) is provided to convert from PNG -time to an RFC 1123 format string. - -.SS Writing unknown chunks - -You can use the png_set_unknown_chunks function to queue up chunks -for writing. You give it a chunk name, raw data, and a size; that's -all there is to it. The chunks will be written by the next following -png_write_info_before_PLTE, png_write_info, or png_write_end function. -Any chunks previously read into the info structure's unknown-chunk -list will also be written out in a sequence that satisfies the PNG -specification's ordering rules. - -.SS The high-level write interface - -At this point there are two ways to proceed; through the high-level -write interface, or through a sequence of low-level write operations. -You can use the high-level interface if your image data is present -in the info structure. All defined output -transformations are permitted, enabled by the following masks. - - PNG_TRANSFORM_IDENTITY No transformation - PNG_TRANSFORM_PACKING Pack 1, 2 and 4-bit samples - PNG_TRANSFORM_PACKSWAP Change order of packed - pixels to LSB first - PNG_TRANSFORM_INVERT_MONO Invert monochrome images - PNG_TRANSFORM_SHIFT Normalize pixels to the - sBIT depth - PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA - to BGRA - PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA - to AG - PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity - to transparency - PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples - PNG_TRANSFORM_STRIP_FILLER Strip out filler bytes. - -If you have valid image data in the info structure (you can use -png_set_rows() to put image data in the info structure), simply do this: - - png_write_png(png_ptr, info_ptr, png_transforms, NULL) - -where png_transforms is an integer containing the bitwise OR of some set of -transformation flags. This call is equivalent to png_write_info(), -followed the set of transformations indicated by the transform mask, -then png_write_image(), and finally png_write_end(). - -(The final parameter of this call is not yet used. Someday it might point -to transformation parameters required by some future output transform.) - -You must use png_transforms and not call any png_set_transform() functions -when you use png_write_png(). - -.SS The low-level write interface - -If you are going the low-level route instead, you are now ready to -write all the file information up to the actual image data. You do -this with a call to png_write_info(). - - png_write_info(png_ptr, info_ptr); - -Note that there is one transformation you may need to do before -png_write_info(). In PNG files, the alpha channel in an image is the -level of opacity. If your data is supplied as a level of -transparency, you can invert the alpha channel before you write it, so -that 0 is fully transparent and 255 (in 8-bit or paletted images) or -65535 (in 16-bit images) is fully opaque, with - - png_set_invert_alpha(png_ptr); - -This must appear before png_write_info() instead of later with the -other transformations because in the case of paletted images the tRNS -chunk data has to be inverted before the tRNS chunk is written. If -your image is not a paletted image, the tRNS data (which in such cases -represents a single color to be rendered as transparent) won't need to -be changed, and you can safely do this transformation after your -png_write_info() call. - -If you need to write a private chunk that you want to appear before -the PLTE chunk when PLTE is present, you can write the PNG info in -two steps, and insert code to write your own chunk between them: - - png_write_info_before_PLTE(png_ptr, info_ptr); - png_set_unknown_chunks(png_ptr, info_ptr, ...); - png_write_info(png_ptr, info_ptr); - -After you've written the file information, you can set up the library -to handle any special transformations of the image data. The various -ways to transform the data will be described in the order that they -should occur. This is important, as some of these change the color -type and/or bit depth of the data, and some others only work on -certain color types and bit depths. Even though each transformation -checks to see if it has data that it can do something with, you should -make sure to only enable a transformation if it will be valid for the -data. For example, don't swap red and blue on grayscale data. - -PNG files store RGB pixels packed into 3 or 6 bytes. This code tells -the library to strip input data that has 4 or 8 bytes per pixel down -to 3 or 6 bytes (or strip 2 or 4-byte grayscale+filler data to 1 or 2 -bytes per pixel). - - png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); - -where the 0 is unused, and the location is either PNG_FILLER_BEFORE or -PNG_FILLER_AFTER, depending upon whether the filler byte in the pixel -is stored XRGB or RGBX. - -PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as -they can, resulting in, for example, 8 pixels per byte for 1 bit files. -If the data is supplied at 1 pixel per byte, use this code, which will -correctly pack the pixels into a single byte: - - png_set_packing(png_ptr); - -PNG files reduce possible bit depths to 1, 2, 4, 8, and 16. If your -data is of another bit depth, you can write an sBIT chunk into the -file so that decoders can recover the original data if desired. - - /* Set the true bit depth of the image data */ - if (color_type & PNG_COLOR_MASK_COLOR) - { - sig_bit.red = true_bit_depth; - sig_bit.green = true_bit_depth; - sig_bit.blue = true_bit_depth; - } - else - { - sig_bit.gray = true_bit_depth; - } - if (color_type & PNG_COLOR_MASK_ALPHA) - { - sig_bit.alpha = true_bit_depth; - } - - png_set_sBIT(png_ptr, info_ptr, &sig_bit); - -If the data is stored in the row buffer in a bit depth other than -one supported by PNG (e.g. 3 bit data in the range 0-7 for a 4-bit PNG), -this will scale the values to appear to be the correct bit depth as -is required by PNG. - - png_set_shift(png_ptr, &sig_bit); - -PNG files store 16 bit pixels in network byte order (big-endian, -ie. most significant bits first). This code would be used if they are -supplied the other way (little-endian, i.e. least significant bits -first, the way PCs store them): - - if (bit_depth > 8) - png_set_swap(png_ptr); - -If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you -need to change the order the pixels are packed into bytes, you can use: - - if (bit_depth < 8) - png_set_packswap(png_ptr); - -PNG files store 3 color pixels in red, green, blue order. This code -would be used if they are supplied as blue, green, red: - - png_set_bgr(png_ptr); - -PNG files describe monochrome as black being zero and white being -one. This code would be used if the pixels are supplied with this reversed -(black being one and white being zero): - - png_set_invert_mono(png_ptr); - -Finally, you can write your own transformation function if none of -the existing ones meets your needs. This is done by setting a callback -with - - png_set_write_user_transform_fn(png_ptr, - write_transform_fn); - -You must supply the function - - void write_transform_fn(png_ptr ptr, row_info_ptr - row_info, png_bytep data) - -See pngtest.c for a working example. Your function will be called -before any of the other transformations are processed. - -You can also set up a pointer to a user structure for use by your -callback function. - - png_set_user_transform_info(png_ptr, user_ptr, 0, 0); - -The user_channels and user_depth parameters of this function are ignored -when writing; you can set them to zero as shown. - -You can retrieve the pointer via the function png_get_user_transform_ptr(). -For example: - - voidp write_user_transform_ptr = - png_get_user_transform_ptr(png_ptr); - -It is possible to have libpng flush any pending output, either manually, -or automatically after a certain number of lines have been written. To -flush the output stream a single time call: - - png_write_flush(png_ptr); - -and to have libpng flush the output stream periodically after a certain -number of scanlines have been written, call: - - png_set_flush(png_ptr, nrows); - -Note that the distance between rows is from the last time png_write_flush() -was called, or the first row of the image if it has never been called. -So if you write 50 lines, and then png_set_flush 25, it will flush the -output on the next scanline, and every 25 lines thereafter, unless -png_write_flush() is called before 25 more lines have been written. -If nrows is too small (less than about 10 lines for a 640 pixel wide -RGB image) the image compression may decrease noticeably (although this -may be acceptable for real-time applications). Infrequent flushing will -only degrade the compression performance by a few percent over images -that do not use flushing. - -.SS Writing the image data - -That's it for the transformations. Now you can write the image data. -The simplest way to do this is in one function call. If you have the -whole image in memory, you can just call png_write_image() and libpng -will write the image. You will need to pass in an array of pointers to -each row. This function automatically handles interlacing, so you don't -need to call png_set_interlace_handling() or call this function multiple -times, or any of that other stuff necessary with png_write_rows(). - - png_write_image(png_ptr, row_pointers); - -where row_pointers is: - - png_byte *row_pointers[height]; - -You can point to void or char or whatever you use for pixels. - -If you don't want to write the whole image at once, you can -use png_write_rows() instead. If the file is not interlaced, -this is simple: - - png_write_rows(png_ptr, row_pointers, - number_of_rows); - -row_pointers is the same as in the png_write_image() call. - -If you are just writing one row at a time, you can do this with -a single row_pointer instead of an array of row_pointers: - - png_bytep row_pointer = row; - - png_write_row(png_ptr, row_pointer); - -When the file is interlaced, things can get a good deal more -complicated. The only currently (as of the PNG Specification -version 1.2, dated July 1999) defined interlacing scheme for PNG files -is the "Adam7" interlace scheme, that breaks down an -image into seven smaller images of varying size. libpng will build -these images for you, or you can do them yourself. If you want to -build them yourself, see the PNG specification for details of which -pixels to write when. - -If you don't want libpng to handle the interlacing details, just -use png_set_interlace_handling() and call png_write_rows() the -correct number of times to write all seven sub-images. - -If you want libpng to build the sub-images, call this before you start -writing any rows: - - number_of_passes = - png_set_interlace_handling(png_ptr); - -This will return the number of passes needed. Currently, this -is seven, but may change if another interlace type is added. - -Then write the complete image number_of_passes times. - - png_write_rows(png_ptr, row_pointers, - number_of_rows); - -As some of these rows are not used, and thus return immediately, -you may want to read about interlacing in the PNG specification, -and only update the rows that are actually used. - -.SS Finishing a sequential write - -After you are finished writing the image, you should finish writing -the file. If you are interested in writing comments or time, you should -pass an appropriately filled png_info pointer. If you are not interested, -you can pass NULL. - - png_write_end(png_ptr, info_ptr); - -When you are done, you can free all memory used by libpng like this: - - png_destroy_write_struct(&png_ptr, &info_ptr); - -It is also possible to individually free the info_ptr members that -point to libpng-allocated storage with the following function: - - png_free_data(png_ptr, info_ptr, mask, seq) - mask - identifies data to be freed, a mask - containing the bitwise OR of one or - more of - PNG_FREE_PLTE, PNG_FREE_TRNS, - PNG_FREE_HIST, PNG_FREE_ICCP, - PNG_FREE_PCAL, PNG_FREE_ROWS, - PNG_FREE_SCAL, PNG_FREE_SPLT, - PNG_FREE_TEXT, PNG_FREE_UNKN, - or simply PNG_FREE_ALL - seq - sequence number of item to be freed - (-1 for all items) - -This function may be safely called when the relevant storage has -already been freed, or has not yet been allocated, or was allocated -by the user and not by libpng, and will in those -cases do nothing. The "seq" parameter is ignored if only one item -of the selected data type, such as PLTE, is allowed. If "seq" is not --1, and multiple items are allowed for the data type identified in -the mask, such as text or sPLT, only the n'th item in the structure -is freed, where n is "seq". - -If you allocated data such as a palette that you passed -in to libpng with png_set_*, you must not free it until just before the call to -png_destroy_write_struct(). - -The default behavior is only to free data that was allocated internally -by libpng. This can be changed, so that libpng will not free the data, -or so that it will free data that was allocated by the user with png_malloc() -or png_zalloc() and passed in via a png_set_*() function, with - - png_data_freer(png_ptr, info_ptr, freer, mask) - mask - which data elements are affected - same choices as in png_free_data() - freer - one of - PNG_DESTROY_WILL_FREE_DATA - PNG_SET_WILL_FREE_DATA - PNG_USER_WILL_FREE_DATA - -For example, to transfer responsibility for some data from a read structure -to a write structure, you could use - - png_data_freer(read_ptr, read_info_ptr, - PNG_USER_WILL_FREE_DATA, - PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST) - png_data_freer(write_ptr, write_info_ptr, - PNG_DESTROY_WILL_FREE_DATA, - PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST) - -thereby briefly reassigning responsibility for freeing to the user but -immediately afterwards reassigning it once more to the write_destroy -function. Having done this, it would then be safe to destroy the read -structure and continue to use the PLTE, tRNS, and hIST data in the write -structure. - -This function only affects data that has already been allocated. -You can call this function before calling after the png_set_*() functions -to control whether the user or png_destroy_*() is supposed to free the data. -When the user assumes responsibility for libpng-allocated data, the -application must use -png_free() to free it, and when the user transfers responsibility to libpng -for data that the user has allocated, the user must have used png_malloc() -or png_zalloc() to allocate it. - -If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword -separately, do not transfer responsibility for freeing text_ptr to libpng, -because when libpng fills a png_text structure it combines these members with -the key member, and png_free_data() will free only text_ptr.key. Similarly, -if you transfer responsibility for free'ing text_ptr from libpng to your -application, your application must not separately free those members. -For a more compact example of writing a PNG image, see the file example.c. - -.SH V. Modifying/Customizing libpng: - -There are three issues here. The first is changing how libpng does -standard things like memory allocation, input/output, and error handling. -The second deals with more complicated things like adding new chunks, -adding new transformations, and generally changing how libpng works. -Both of those are compile-time issues; that is, they are generally -determined at the time the code is written, and there is rarely a need -to provide the user with a means of changing them. The third is a -run-time issue: choosing between and/or tuning one or more alternate -versions of computationally intensive routines; specifically, optimized -assembly-language (and therefore compiler- and platform-dependent) -versions. - -Memory allocation, input/output, and error handling - -All of the memory allocation, input/output, and error handling in libpng -goes through callbacks that are user-settable. The default routines are -in pngmem.c, pngrio.c, pngwio.c, and pngerror.c, respectively. To change -these functions, call the appropriate png_set_*_fn() function. - -Memory allocation is done through the functions png_malloc() -and png_free(). These currently just call the standard C functions. If -your pointers can't access more then 64K at a time, you will want to set -MAXSEG_64K in zlib.h. Since it is unlikely that the method of handling -memory allocation on a platform will change between applications, these -functions must be modified in the library at compile time. If you prefer -to use a different method of allocating and freeing data, you can use -png_create_read_struct_2() or png_create_write_struct_2() to register -your own functions as described above. -These functions also provide a void pointer that can be retrieved via - - mem_ptr=png_get_mem_ptr(png_ptr); - -Your replacement memory functions must have prototypes as follows: - - png_voidp malloc_fn(png_structp png_ptr, - png_size_t size); - void free_fn(png_structp png_ptr, png_voidp ptr); - -Your malloc_fn() must return NULL in case of failure. The png_malloc() -function will normally call png_error() if it receives a NULL from the -system memory allocator or from your replacement malloc_fn(). - -Input/Output in libpng is done through png_read() and png_write(), -which currently just call fread() and fwrite(). The FILE * is stored in -png_struct and is initialized via png_init_io(). If you wish to change -the method of I/O, the library supplies callbacks that you can set -through the function png_set_read_fn() and png_set_write_fn() at run -time, instead of calling the png_init_io() function. These functions -also provide a void pointer that can be retrieved via the function -png_get_io_ptr(). For example: - - png_set_read_fn(png_structp read_ptr, - voidp read_io_ptr, png_rw_ptr read_data_fn) - - png_set_write_fn(png_structp write_ptr, - voidp write_io_ptr, png_rw_ptr write_data_fn, - png_flush_ptr output_flush_fn); - - voidp read_io_ptr = png_get_io_ptr(read_ptr); - voidp write_io_ptr = png_get_io_ptr(write_ptr); - -The replacement I/O functions must have prototypes as follows: - - void user_read_data(png_structp png_ptr, - png_bytep data, png_size_t length); - void user_write_data(png_structp png_ptr, - png_bytep data, png_size_t length); - void user_flush_data(png_structp png_ptr); - -Supplying NULL for the read, write, or flush functions sets them back -to using the default C stream functions. It is an error to read from -a write stream, and vice versa. - -Error handling in libpng is done through png_error() and png_warning(). -Errors handled through png_error() are fatal, meaning that png_error() -should never return to its caller. Currently, this is handled via -setjmp() and longjmp() (unless you have compiled libpng with -PNG_SETJMP_NOT_SUPPORTED, in which case it is handled via PNG_ABORT()), -but you could change this to do things like exit() if you should wish. - -On non-fatal errors, png_warning() is called -to print a warning message, and then control returns to the calling code. -By default png_error() and png_warning() print a message on stderr via -fprintf() unless the library is compiled with PNG_NO_CONSOLE_IO defined -(because you don't want the messages) or PNG_NO_STDIO defined (because -fprintf() isn't available). If you wish to change the behavior of the error -functions, you will need to set up your own message callbacks. These -functions are normally supplied at the time that the png_struct is created. -It is also possible to redirect errors and warnings to your own replacement -functions after png_create_*_struct() has been called by calling: - - png_set_error_fn(png_structp png_ptr, - png_voidp error_ptr, png_error_ptr error_fn, - png_error_ptr warning_fn); - - png_voidp error_ptr = png_get_error_ptr(png_ptr); - -If NULL is supplied for either error_fn or warning_fn, then the libpng -default function will be used, calling fprintf() and/or longjmp() if a -problem is encountered. The replacement error functions should have -parameters as follows: - - void user_error_fn(png_structp png_ptr, - png_const_charp error_msg); - void user_warning_fn(png_structp png_ptr, - png_const_charp warning_msg); - -The motivation behind using setjmp() and longjmp() is the C++ throw and -catch exception handling methods. This makes the code much easier to write, -as there is no need to check every return code of every function call. -However, there are some uncertainties about the status of local variables -after a longjmp, so the user may want to be careful about doing anything after -setjmp returns non-zero besides returning itself. Consult your compiler -documentation for more details. For an alternative approach, you may wish -to use the "cexcept" facility (see http://cexcept.sourceforge.net). - -.SS Custom chunks - -If you need to read or write custom chunks, you may need to get deeper -into the libpng code. The library now has mechanisms for storing -and writing chunks of unknown type; you can even declare callbacks -for custom chunks. However, this may not be good enough if the -library code itself needs to know about interactions between your -chunk and existing `intrinsic' chunks. - -If you need to write a new intrinsic chunk, first read the PNG -specification. Acquire a first level of -understanding of how it works. Pay particular attention to the -sections that describe chunk names, and look at how other chunks were -designed, so you can do things similarly. Second, check out the -sections of libpng that read and write chunks. Try to find a chunk -that is similar to yours and use it as a template. More details can -be found in the comments inside the code. It is best to handle unknown -chunks in a generic method, via callback functions, instead of by -modifying libpng functions. - -If you wish to write your own transformation for the data, look through -the part of the code that does the transformations, and check out some of -the simpler ones to get an idea of how they work. Try to find a similar -transformation to the one you want to add and copy off of it. More details -can be found in the comments inside the code itself. - -.SS Configuring for 16 bit platforms - -You will want to look into zconf.h to tell zlib (and thus libpng) that -it cannot allocate more then 64K at a time. Even if you can, the memory -won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K. - -.SS Configuring for DOS - -For DOS users who only have access to the lower 640K, you will -have to limit zlib's memory usage via a png_set_compression_mem_level() -call. See zlib.h or zconf.h in the zlib library for more information. - -.SS Configuring for Medium Model - -Libpng's support for medium model has been tested on most of the popular -compilers. Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets -defined, and FAR gets defined to far in pngconf.h, and you should be -all set. Everything in the library (except for zlib's structure) is -expecting far data. You must use the typedefs with the p or pp on -the end for pointers (or at least look at them and be careful). Make -note that the rows of data are defined as png_bytepp, which is an -unsigned char far * far *. - -.SS Configuring for gui/windowing platforms: - -You will need to write new error and warning functions that use the GUI -interface, as described previously, and set them to be the error and -warning functions at the time that png_create_*_struct() is called, -in order to have them available during the structure initialization. -They can be changed later via png_set_error_fn(). On some compilers, -you may also have to change the memory allocators (png_malloc, etc.). - -.SS Configuring for compiler xxx: - -All includes for libpng are in pngconf.h. If you need to add/change/delete -an include, this is the place to do it. The includes that are not -needed outside libpng are protected by the PNG_INTERNAL definition, -which is only defined for those routines inside libpng itself. The -files in libpng proper only include png.h, which includes pngconf.h. - -.SS Configuring zlib: - -There are special functions to configure the compression. Perhaps the -most useful one changes the compression level, which currently uses -input compression values in the range 0 - 9. The library normally -uses the default compression level (Z_DEFAULT_COMPRESSION = 6). Tests -have shown that for a large majority of images, compression values in -the range 3-6 compress nearly as well as higher levels, and do so much -faster. For online applications it may be desirable to have maximum speed -(Z_BEST_SPEED = 1). With versions of zlib after v0.99, you can also -specify no compression (Z_NO_COMPRESSION = 0), but this would create -files larger than just storing the raw bitmap. You can specify the -compression level by calling: - - png_set_compression_level(png_ptr, level); - -Another useful one is to reduce the memory level used by the library. -The memory level defaults to 8, but it can be lowered if you are -short on memory (running DOS, for example, where you only have 640K). -Note that the memory level does have an effect on compression; among -other things, lower levels will result in sections of incompressible -data being emitted in smaller stored blocks, with a correspondingly -larger relative overhead of up to 15% in the worst case. - - png_set_compression_mem_level(png_ptr, level); - -The other functions are for configuring zlib. They are not recommended -for normal use and may result in writing an invalid PNG file. See -zlib.h for more information on what these mean. - - png_set_compression_strategy(png_ptr, - strategy); - png_set_compression_window_bits(png_ptr, - window_bits); - png_set_compression_method(png_ptr, method); - png_set_compression_buffer_size(png_ptr, size); - -.SS Controlling row filtering - -If you want to control whether libpng uses filtering or not, which -filters are used, and how it goes about picking row filters, you -can call one of these functions. The selection and configuration -of row filters can have a significant impact on the size and -encoding speed and a somewhat lesser impact on the decoding speed -of an image. Filtering is enabled by default for RGB and grayscale -images (with and without alpha), but not for paletted images nor -for any images with bit depths less than 8 bits/pixel. - -The 'method' parameter sets the main filtering method, which is -currently only '0' in the PNG 1.2 specification. The 'filters' -parameter sets which filter(s), if any, should be used for each -scanline. Possible values are PNG_ALL_FILTERS and PNG_NO_FILTERS -to turn filtering on and off, respectively. - -Individual filter types are PNG_FILTER_NONE, PNG_FILTER_SUB, -PNG_FILTER_UP, PNG_FILTER_AVG, PNG_FILTER_PAETH, which can be bitwise -ORed together with '|' to specify one or more filters to use. -These filters are described in more detail in the PNG specification. -If you intend to change the filter type during the course of writing -the image, you should start with flags set for all of the filters -you intend to use so that libpng can initialize its internal -structures appropriately for all of the filter types. (Note that this -means the first row must always be adaptively filtered, because libpng -currently does not allocate the filter buffers until png_write_row() -is called for the first time.) - - filters = PNG_FILTER_NONE | PNG_FILTER_SUB - PNG_FILTER_UP | PNG_FILTER_AVE | - PNG_FILTER_PAETH | PNG_ALL_FILTERS; - - png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, - filters); - The second parameter can also be - PNG_INTRAPIXEL_DIFFERENCING if you are - writing a PNG to be embedded in a MNG - datastream. This parameter must be the - same as the value of filter_method used - in png_set_IHDR(). - -It is also possible to influence how libpng chooses from among the -available filters. This is done in one or both of two ways - by -telling it how important it is to keep the same filter for successive -rows, and by telling it the relative computational costs of the filters. - - double weights[3] = {1.5, 1.3, 1.1}, - costs[PNG_FILTER_VALUE_LAST] = - {1.0, 1.3, 1.3, 1.5, 1.7}; - - png_set_filter_heuristics(png_ptr, - PNG_FILTER_HEURISTIC_WEIGHTED, 3, - weights, costs); - -The weights are multiplying factors that indicate to libpng that the -row filter should be the same for successive rows unless another row filter -is that many times better than the previous filter. In the above example, -if the previous 3 filters were SUB, SUB, NONE, the SUB filter could have a -"sum of absolute differences" 1.5 x 1.3 times higher than other filters -and still be chosen, while the NONE filter could have a sum 1.1 times -higher than other filters and still be chosen. Unspecified weights are -taken to be 1.0, and the specified weights should probably be declining -like those above in order to emphasize recent filters over older filters. - -The filter costs specify for each filter type a relative decoding cost -to be considered when selecting row filters. This means that filters -with higher costs are less likely to be chosen over filters with lower -costs, unless their "sum of absolute differences" is that much smaller. -The costs do not necessarily reflect the exact computational speeds of -the various filters, since this would unduly influence the final image -size. - -Note that the numbers above were invented purely for this example and -are given only to help explain the function usage. Little testing has -been done to find optimum values for either the costs or the weights. - -.SS Removing unwanted object code - -There are a bunch of #define's in pngconf.h that control what parts of -libpng are compiled. All the defines end in _SUPPORTED. If you are -never going to use a capability, you can change the #define to #undef -before recompiling libpng and save yourself code and data space, or -you can turn off individual capabilities with defines that begin with -PNG_NO_. - -You can also turn all of the transforms and ancillary chunk capabilities -off en masse with compiler directives that define -PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS, -or all four, -along with directives to turn on any of the capabilities that you do -want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable -the extra transformations but still leave the library fully capable of reading -and writing PNG files with all known public chunks -Use of the PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive -produces a library that is incapable of reading or writing ancillary chunks. -If you are not using the progressive reading capability, you can -turn that off with PNG_NO_PROGRESSIVE_READ (don't confuse -this with the INTERLACING capability, which you'll still have). - -All the reading and writing specific code are in separate files, so the -linker should only grab the files it needs. However, if you want to -make sure, or if you are building a stand alone library, all the -reading files start with pngr and all the writing files start with -pngw. The files that don't match either (like png.c, pngtrans.c, etc.) -are used for both reading and writing, and always need to be included. -The progressive reader is in pngpread.c - -If you are creating or distributing a dynamically linked library (a .so -or DLL file), you should not remove or disable any parts of the library, -as this will cause applications linked with different versions of the -library to fail if they call functions not available in your library. -The size of the library itself should not be an issue, because only -those sections that are actually used will be loaded into memory. - -.SS Requesting debug printout - -The macro definition PNG_DEBUG can be used to request debugging -printout. Set it to an integer value in the range 0 to 3. Higher -numbers result in increasing amounts of debugging information. The -information is printed to the "stderr" file, unless another file -name is specified in the PNG_DEBUG_FILE macro definition. - -When PNG_DEBUG > 0, the following functions (macros) become available: - - png_debug(level, message) - png_debug1(level, message, p1) - png_debug2(level, message, p1, p2) - -in which "level" is compared to PNG_DEBUG to decide whether to print -the message, "message" is the formatted string to be printed, -and p1 and p2 are parameters that are to be embedded in the string -according to printf-style formatting directives. For example, - - png_debug1(2, "foo=%d\n", foo); - -is expanded to - - if(PNG_DEBUG > 2) - fprintf(PNG_DEBUG_FILE, "foo=%d\n", foo); - -When PNG_DEBUG is defined but is zero, the macros aren't defined, but you -can still use PNG_DEBUG to control your own debugging: - - #ifdef PNG_DEBUG - fprintf(stderr, ... - #endif - -When PNG_DEBUG = 1, the macros are defined, but only png_debug statements -having level = 0 will be printed. There aren't any such statements in -this version of libpng, but if you insert some they will be printed. - -.SH VI. Runtime optimization - -A new feature in libpng 1.2.0 is the ability to dynamically switch between -standard and optimized versions of some routines. Currently these are -limited to three computationally intensive tasks when reading PNG files: -decoding row filters, expanding interlacing, and combining interlaced or -transparent row data with previous row data. Currently the optimized -versions are available only for x86 (Intel, AMD, etc.) platforms with -MMX support, though this may change in future versions. (For example, -the non-MMX assembler optimizations for zlib might become similarly -runtime-selectable in future releases, in which case libpng could be -extended to support them. Alternatively, the compile-time choice of -floating-point versus integer routines for gamma correction might become -runtime-selectable.) - -Because such optimizations tend to be very platform- and compiler-dependent, -both in how they are written and in how they perform, the new runtime code -in libpng has been written to allow programs to query, enable, and disable -either specific optimizations or all such optimizations. For example, to -enable all possible optimizations (bearing in mind that some "optimizations" -may actually run more slowly in rare cases): - - #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) - png_uint_32 mask, flags; - - flags = png_get_asm_flags(png_ptr); - mask = png_get_asm_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE); - png_set_asm_flags(png_ptr, flags | mask); - #endif - -To enable only optimizations relevant to reading PNGs, use PNG_SELECT_READ -by itself when calling png_get_asm_flagmask(); similarly for optimizing -only writing. To disable all optimizations: - - #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) - flags = png_get_asm_flags(png_ptr); - mask = png_get_asm_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE); - png_set_asm_flags(png_ptr, flags & ~mask); - #endif - -To enable or disable only MMX-related features, use png_get_mmx_flagmask() -in place of png_get_asm_flagmask(). The mmx version takes one additional -parameter: - - #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) - int selection = PNG_SELECT_READ | PNG_SELECT_WRITE; - int compilerID; - - mask = png_get_mmx_flagmask(selection, &compilerID); - #endif - -On return, compilerID will indicate which version of the MMX assembler -optimizations was compiled. Currently two flavors exist: Microsoft -Visual C++ (compilerID == 1) and GNU C (a.k.a. gcc/gas, compilerID == 2). -On non-x86 platforms or on systems compiled without MMX optimizations, a -value of -1 is used. - -Note that both png_get_asm_flagmask() and png_get_mmx_flagmask() return -all valid, settable optimization bits for the version of the library that's -currently in use. In the case of shared (dynamically linked) libraries, -this may include optimizations that did not exist at the time the code was -written and compiled. It is also possible, of course, to enable only known, -specific optimizations; for example: - - #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) - flags = PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ - | PNG_ASM_FLAG_MMX_READ_INTERLACE \ - | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ - | PNG_ASM_FLAG_MMX_READ_FILTER_UP \ - | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ - | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ; - png_set_asm_flags(png_ptr, flags); - #endif - -This method would enable only the MMX read-optimizations available at the -time of libpng 1.2.0's release, regardless of whether a later version of -the DLL were actually being used. (Also note that these functions did not -exist in versions older than 1.2.0, so any attempt to run a dynamically -linked app on such an older version would fail.) - -To determine whether the processor supports MMX instructions at all, use -the png_mmx_support() function: - - #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) - mmxsupport = png_mmx_support(); - #endif - -It returns -1 if MMX support is not compiled into libpng, 0 if MMX code -is compiled but MMX is not supported by the processor, or 1 if MMX support -is fully available. Note that png_mmx_support(), png_get_mmx_flagmask(), -and png_get_asm_flagmask() all may be called without allocating and ini- -tializing any PNG structures (for example, as part of a usage screen or -"about" box). - -The following code can be used to prevent an application from using the -thread_unsafe features, even if libpng was built with PNG_THREAD_UNSAFE_OK -defined: - -#if defined(PNG_USE_PNGGCCRD) && defined(PNG_ASSEMBLER_CODE_SUPPORTED) \ - && defined(PNG_THREAD_UNSAFE_OK) - /* Disable thread-unsafe features of pnggccrd */ - if (png_access_version_number() >= 10200) - { - png_uint_32 mmx_disable_mask = 0; - png_uint_32 asm_flags; - - mmx_disable_mask |= ( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ - | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ - | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ - | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ); - asm_flags = png_get_asm_flags(png_ptr); - png_set_asm_flags(png_ptr, asm_flags & ~mmx_disable_mask); - } -#endif - -For more extensive examples of runtime querying, enabling and disabling -of optimized features, see contrib/gregbook/readpng2.c in the libpng -source-code distribution. - -.SH VII. MNG support - -The MNG specification (available at http://www.libpng.org/pub/mng) allows -certain extensions to PNG for PNG images that are embedded in MNG datastreams. -Libpng can support some of these extensions. To enable them, use the -png_permit_mng_features() function: - - feature_set = png_permit_mng_features(png_ptr, mask) - mask is a png_uint_32 containing the bitwise OR of the - features you want to enable. These include - PNG_FLAG_MNG_EMPTY_PLTE - PNG_FLAG_MNG_FILTER_64 - PNG_ALL_MNG_FEATURES - feature_set is a png_uint_32 that is the bitwise AND of - your mask with the set of MNG features that is - supported by the version of libpng that you are using. - -It is an error to use this function when reading or writing a standalone -PNG file with the PNG 8-byte signature. The PNG datastream must be wrapped -in a MNG datastream. As a minimum, it must have the MNG 8-byte signature -and the MHDR and MEND chunks. Libpng does not provide support for these -or any other MNG chunks; your application must provide its own support for -them. You may wish to consider using libmng (available at -http://www.libmng.com) instead. - -.SH VIII. Changes to Libpng from version 0.88 - -It should be noted that versions of libpng later than 0.96 are not -distributed by the original libpng author, Guy Schalnat, nor by -Andreas Dilger, who had taken over from Guy during 1996 and 1997, and -distributed versions 0.89 through 0.96, but rather by another member -of the original PNG Group, Glenn Randers-Pehrson. Guy and Andreas are -still alive and well, but they have moved on to other things. - -The old libpng functions png_read_init(), png_write_init(), -png_info_init(), png_read_destroy(), and png_write_destroy() have been -moved to PNG_INTERNAL in version 0.95 to discourage their use. These -functions will be removed from libpng version 2.0.0. - -The preferred method of creating and initializing the libpng structures is -via the png_create_read_struct(), png_create_write_struct(), and -png_create_info_struct() because they isolate the size of the structures -from the application, allow version error checking, and also allow the -use of custom error handling routines during the initialization, which -the old functions do not. The functions png_read_destroy() and -png_write_destroy() do not actually free the memory that libpng -allocated for these structs, but just reset the data structures, so they -can be used instead of png_destroy_read_struct() and -png_destroy_write_struct() if you feel there is too much system overhead -allocating and freeing the png_struct for each image read. - -Setting the error callbacks via png_set_message_fn() before -png_read_init() as was suggested in libpng-0.88 is no longer supported -because this caused applications that do not use custom error functions -to fail if the png_ptr was not initialized to zero. It is still possible -to set the error callbacks AFTER png_read_init(), or to change them with -png_set_error_fn(), which is essentially the same function, but with a new -name to force compilation errors with applications that try to use the old -method. - -Starting with version 1.0.7, you can find out which version of the library -you are using at run-time: - - png_uint_32 libpng_vn = png_access_version_number(); - -The number libpng_vn is constructed from the major version, minor -version with leading zero, and release number with leading zero, -(e.g., libpng_vn for version 1.0.7 is 10007). - -You can also check which version of png.h you used when compiling your -application: - - png_uint_32 application_vn = PNG_LIBPNG_VER; - -.SH IX. Y2K Compliance in libpng - -May 15, 2007 - -Since the PNG Development group is an ad-hoc body, we can't make -an official declaration. - -This is your unofficial assurance that libpng from version 0.71 and -upward through 1.2.18 are Y2K compliant. It is my belief that earlier -versions were also Y2K compliant. - -Libpng only has three year fields. One is a 2-byte unsigned integer that -will hold years up to 65535. The other two hold the date in text -format, and will hold years up to 9999. - -The integer is - "png_uint_16 year" in png_time_struct. - -The strings are - "png_charp time_buffer" in png_struct and - "near_time_buffer", which is a local character string in png.c. - -There are seven time-related functions: - - png_convert_to_rfc_1123() in png.c - (formerly png_convert_to_rfc_1152() in error) - png_convert_from_struct_tm() in pngwrite.c, called - in pngwrite.c - png_convert_from_time_t() in pngwrite.c - png_get_tIME() in pngget.c - png_handle_tIME() in pngrutil.c, called in pngread.c - png_set_tIME() in pngset.c - png_write_tIME() in pngwutil.c, called in pngwrite.c - -All appear to handle dates properly in a Y2K environment. The -png_convert_from_time_t() function calls gmtime() to convert from system -clock time, which returns (year - 1900), which we properly convert to -the full 4-digit year. There is a possibility that applications using -libpng are not passing 4-digit years into the png_convert_to_rfc_1123() -function, or that they are incorrectly passing only a 2-digit year -instead of "year - 1900" into the png_convert_from_struct_tm() function, -but this is not under our control. The libpng documentation has always -stated that it works with 4-digit years, and the APIs have been -documented as such. - -The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned -integer to hold the year, and can hold years as large as 65535. - -zlib, upon which libpng depends, is also Y2K compliant. It contains -no date-related code. - - - Glenn Randers-Pehrson - libpng maintainer - PNG Development Group - -.SH NOTE - -Note about libpng version numbers: - -Due to various miscommunications, unforeseen code incompatibilities -and occasional factors outside the authors' control, version numbering -on the library has not always been consistent and straightforward. -The following table summarizes matters since version 0.89c, which was -the first widely used release: - - source png.h png.h shared-lib - version string int version - ------- ------ ----- ---------- - 0.89c ("beta 3") 0.89 89 1.0.89 - 0.90 ("beta 4") 0.90 90 0.90 - 0.95 ("beta 5") 0.95 95 0.95 - 0.96 ("beta 6") 0.96 96 0.96 - 0.97b ("beta 7") 1.00.97 97 1.0.1 - 0.97c 0.97 97 2.0.97 - 0.98 0.98 98 2.0.98 - 0.99 0.99 98 2.0.99 - 0.99a-m 0.99 99 2.0.99 - 1.00 1.00 100 2.1.0 - 1.0.0 1.0.0 100 2.1.0 - 1.0.0 (from here on, the 100 2.1.0 - 1.0.1 png.h string is 10001 2.1.0 - 1.0.1a-e identical to the 10002 from here on, the - 1.0.2 source version) 10002 shared library is 2.V - 1.0.2a-b 10003 where V is the source - 1.0.1 10001 code version except as - 1.0.1a-e 10002 2.1.0.1a-e noted. - 1.0.2 10002 2.1.0.2 - 1.0.2a-b 10003 2.1.0.2a-b - 1.0.3 10003 2.1.0.3 - 1.0.3a-d 10004 2.1.0.3a-d - 1.0.4 10004 2.1.0.4 - 1.0.4a-f 10005 2.1.0.4a-f - 1.0.5 (+ 2 patches) 10005 2.1.0.5 - 1.0.5a-d 10006 2.1.0.5a-d - 1.0.5e-r 10100 2.1.0.5e-r - 1.0.5s-v 10006 2.1.0.5s-v - 1.0.6 (+ 3 patches) 10006 2.1.0.6 - 1.0.6d-g 10007 2.1.0.6d-g - 1.0.6h 10007 10.6h - 1.0.6i 10007 10.6i - 1.0.6j 10007 2.1.0.6j - 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 - 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 - 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 - 1.0.7 1 10007 2.1.0.7 - 1.0.8beta1-4 1 10008 2.1.0.8beta1-4 - 1.0.8rc1 1 10008 2.1.0.8rc1 - 1.0.8 1 10008 2.1.0.8 - 1.0.9beta1-6 1 10009 2.1.0.9beta1-6 - 1.0.9rc1 1 10009 2.1.0.9rc1 - 1.0.9beta7-10 1 10009 2.1.0.9beta7-10 - 1.0.9rc2 1 10009 2.1.0.9rc2 - 1.0.9 1 10009 2.1.0.9 - 1.0.10beta1 1 10010 2.1.0.10beta1 - 1.0.10rc1 1 10010 2.1.0.10rc1 - 1.0.10 1 10010 2.1.0.10 - 1.0.11beta1-3 1 10011 2.1.0.11beta1-3 - 1.0.11rc1 1 10011 2.1.0.11rc1 - 1.0.11 1 10011 2.1.0.11 - 1.0.12beta1-2 2 10012 2.1.0.12beta1-2 - 1.0.12rc1 2 10012 2.1.0.12rc1 - 1.0.12 2 10012 2.1.0.12 - 1.1.0a-f - 10100 2.1.1.0a-f abandoned - 1.2.0beta1-2 2 10200 2.1.2.0beta1-2 - 1.2.0beta3-5 3 10200 3.1.2.0beta3-5 - 1.2.0rc1 3 10200 3.1.2.0rc1 - 1.2.0 3 10200 3.1.2.0 - 1.2.1beta-4 3 10201 3.1.2.1beta1-4 - 1.2.1rc1-2 3 10201 3.1.2.1rc1-2 - 1.2.1 3 10201 3.1.2.1 - 1.2.2beta1-6 12 10202 12.so.0.1.2.2beta1-6 - 1.0.13beta1 10 10013 10.so.0.1.0.13beta1 - 1.0.13rc1 10 10013 10.so.0.1.0.13rc1 - 1.2.2rc1 12 10202 12.so.0.1.2.2rc1 - 1.0.13 10 10013 10.so.0.1.0.13 - 1.2.2 12 10202 12.so.0.1.2.2 - 1.2.3rc1-6 12 10203 12.so.0.1.2.3rc1-6 - 1.2.3 12 10203 12.so.0.1.2.3 - 1.2.4beta1-3 13 10204 12.so.0.1.2.4beta1-3 - 1.2.4rc1 13 10204 12.so.0.1.2.4rc1 - 1.0.14 10 10014 10.so.0.1.0.14 - 1.2.4 13 10204 12.so.0.1.2.4 - 1.2.5beta1-2 13 10205 12.so.0.1.2.5beta1-2 - 1.0.15rc1 10 10015 10.so.0.1.0.15rc1 - 1.0.15 10 10015 10.so.0.1.0.15 - 1.2.5 13 10205 12.so.0.1.2.5 - 1.2.6beta1-4 13 10206 12.so.0.1.2.6beta1-4 - 1.2.6rc1-5 13 10206 12.so.0.1.2.6rc1-5 - 1.0.16 10 10016 10.so.0.1.0.16 - 1.2.6 13 10206 12.so.0.1.2.6 - 1.2.7beta1-2 13 10207 12.so.0.1.2.7beta1-2 - 1.0.17rc1 10 10017 10.so.0.1.0.17rc1 - 1.2.7rc1 13 10207 12.so.0.1.2.7rc1 - 1.0.17 10 10017 10.so.0.1.0.17 - 1.2.7 13 10207 12.so.0.1.2.7 - 1.2.8beta1-5 13 10208 12.so.0.1.2.8beta1-5 - 1.0.18rc1-5 10 10018 10.so.0.1.0.18rc1-5 - 1.2.8rc1-5 13 10208 12.so.0.1.2.8rc1-5 - 1.0.18 10 10018 10.so.0.1.0.18 - 1.2.8 13 10208 12.so.0.1.2.8 - 1.2.9beta1-3 13 10209 12.so.0.1.2.9beta1-3 - 1.2.9beta4-11 13 10209 12.so.0.9[.0] - 1.2.9rc1 13 10209 12.so.0.9[.0] - 1.2.9 13 10209 12.so.0.9[.0] - 1.2.10beta1-8 13 10210 12.so.0.10[.0] - 1.2.10rc1-3 13 10210 12.so.0.10[.0] - 1.2.10 13 10210 12.so.0.10[.0] - 1.2.11beta1-4 13 10211 12.so.0.11[.0] - 1.0.19rc1-5 10 10019 10.so.0.19[.0] - 1.2.11rc1-5 13 10211 12.so.0.11[.0] - 1.0.19 10 10019 10.so.0.19[.0] - 1.2.11 13 10211 12.so.0.11[.0] - 1.0.20 10 10020 10.so.0.20[.0] - 1.2.12 13 10212 12.so.0.12[.0] - 1.2.13beta1 13 10213 12.so.0.13[.0] - 1.0.21 10 10021 10.so.0.21[.0] - 1.2.13 13 10213 12.so.0.13[.0] - 1.2.14beta1-2 13 10214 12.so.0.14[.0] - 1.0.22rc1 10 10022 10.so.0.22[.0] - 1.2.14rc1 13 10214 12.so.0.14[.0] - 1.2.15beta1-6 13 10215 12.so.0.15[.0] - 1.0.23rc1-5 10 10023 10.so.0.23[.0] - 1.2.15rc1-5 13 10215 12.so.0.15[.0] - 1.0.23 10 10023 10.so.0.23[.0] - 1.2.15 13 10215 12.so.0.15[.0] - 1.2.16beta1-2 13 10216 12.so.0.16[.0] - 1.2.16rc1 13 10216 12.so.0.16[.0] - 1.0.24 10 10024 10.so.0.24[.0] - 1.2.16 13 10216 12.so.0.16[.0] - 1.2.17beta1-2 13 10217 12.so.0.17[.0] - 1.0.25rc1 10 10025 10.so.0.25[.0] - 1.2.17rc1-3 13 10217 12.so.0.17[.0] - 1.0.25 10 10025 10.so.0.25[.0] - 1.2.17 13 10217 12.so.0.17[.0] - 1.0.26 10 10026 10.so.0.26[.0] - 1.2.18 13 10218 12.so.0.18[.0] - -Henceforth the source version will match the shared-library minor -and patch numbers; the shared-library major version number will be -used for changes in backward compatibility, as it is intended. The -PNG_PNGLIB_VER macro, which is not used within libpng but is available -for applications, is an unsigned integer of the form xyyzz corresponding -to the source version x.y.z (leading zeros in y and z). Beta versions -were given the previous public release number plus a letter, until -version 1.0.6j; from then on they were given the upcoming public -release number plus "betaNN" or "rcN". - -.SH "SEE ALSO" -libpngpf(3), png(5) -.LP -.IR libpng : -.IP -http://libpng.sourceforge.net (follow the [DOWNLOAD] link) -http://www.libpng.org/pub/png - -.LP -.IR zlib : -.IP -(generally) at the same location as -.I libpng -or at -.br -ftp://ftp.info-zip.org/pub/infozip/zlib - -.LP -.IR PNG specification: RFC 2083 -.IP -(generally) at the same location as -.I libpng -or at -.br -ftp://ds.internic.net/rfc/rfc2083.txt -.br -or (as a W3C Recommendation) at -.br -http://www.w3.org/TR/REC-png.html - -.LP -In the case of any inconsistency between the PNG specification -and this library, the specification takes precedence. - -.SH AUTHORS -This man page: Glenn Randers-Pehrson -<glennrp at users.sourceforge.net> - -The contributing authors would like to thank all those who helped -with testing, bug fixes, and patience. This wouldn't have been -possible without all of you. - -Thanks to Frank J. T. Wojcik for helping with the documentation. - -Libpng version 1.2.18 - May 15, 2007: -Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc. -Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net). - -Supported by the PNG development group -.br -png-mng-implement at lists.sf.net -(subscription required; visit -png-mng-implement at lists.sourceforge.net (subscription required; visit -https://lists.sourceforge.net/lists/listinfo/png-mng-implement -to subscribe). - -.SH COPYRIGHT NOTICE, DISCLAIMER, and LICENSE: - -(This copy of the libpng notices is provided for your convenience. In case of -any discrepancy between this copy and the notices in the file png.h that is -included in the libpng distribution, the latter shall prevail.) - -If you modify libpng you may insert additional notices immediately following -this sentence. - -libpng versions 1.2.6, August 15, 2004, through 1.2.18, May 15, 2007, are -Copyright (c) 2004,2006-2007 Glenn Randers-Pehrson, and are -distributed according to the same disclaimer and license as libpng-1.2.5 -with the following individual added to the list of Contributing Authors - - Cosmin Truta - -libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are -Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are -distributed according to the same disclaimer and license as libpng-1.0.6 -with the following individuals added to the list of Contributing Authors - - Simon-Pierre Cadieux - Eric S. Raymond - Gilles Vollant - -and with the following additions to the disclaimer: - - There is no warranty against interference with your - enjoyment of the library or against infringement. - There is no warranty that our efforts or the library - will fulfill any of your particular purposes or needs. - This library is provided with all faults, and the entire - risk of satisfactory quality, performance, accuracy, and - effort is with the user. - -libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are -Copyright (c) 1998, 1999 Glenn Randers-Pehrson -Distributed according to the same disclaimer and license as libpng-0.96, -with the following individuals added to the list of Contributing Authors: - - Tom Lane - Glenn Randers-Pehrson - Willem van Schaik - -libpng versions 0.89, June 1996, through 0.96, May 1997, are -Copyright (c) 1996, 1997 Andreas Dilger -Distributed according to the same disclaimer and license as libpng-0.88, -with the following individuals added to the list of Contributing Authors: - - John Bowler - Kevin Bracey - Sam Bushell - Magnus Holmgren - Greg Roelofs - Tom Tanner - -libpng versions 0.5, May 1995, through 0.88, January 1996, are -Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. - -For the purposes of this copyright and license, "Contributing Authors" -is defined as the following set of individuals: - - Andreas Dilger - Dave Martindale - Guy Eric Schalnat - Paul Schmidt - Tim Wegner - -The PNG Reference Library is supplied "AS IS". The Contributing Authors -and Group 42, Inc. disclaim all warranties, expressed or implied, -including, without limitation, the warranties of merchantability and of -fitness for any purpose. The Contributing Authors and Group 42, Inc. -assume no liability for direct, indirect, incidental, special, exemplary, -or consequential damages, which may result from the use of the PNG -Reference Library, even if advised of the possibility of such damage. - -Permission is hereby granted to use, copy, modify, and distribute this -source code, or portions hereof, for any purpose, without fee, subject -to the following restrictions: - -1. The origin of this source code must not be misrepresented. - -2. Altered versions must be plainly marked as such and - must not be misrepresented as being the original source. - -3. This Copyright notice may not be removed or altered from - any source or altered source distribution. - -The Contributing Authors and Group 42, Inc. specifically permit, without -fee, and encourage the use of this source code as a component to -supporting the PNG file format in commercial products. If you use this -source code in a product, acknowledgment is not required but would be -appreciated. - - -A "png_get_copyright" function is available, for convenient use in "about" -boxes and the like: - - printf("%s",png_get_copyright(NULL)); - -Also, the PNG logo (in PNG format, of course) is supplied in the -files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31). - -Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a -certification mark of the Open Source Initiative. - -Glenn Randers-Pehrson -glennrp at users.sourceforge.net -May 15, 2007 - -.\" end of man page - diff --git a/irrlicht-1.6/source/Irrlicht/libpng/libpngpf.3 b/irrlicht-1.6/source/Irrlicht/libpng/libpngpf.3 deleted file mode 100644 index ee75e455f..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/libpngpf.3 +++ /dev/null @@ -1,274 +0,0 @@ -.TH LIBPNGPF 3 "May 15, 2007" -.SH NAME -libpng \- Portable Network Graphics (PNG) Reference Library 1.2.18 -(private functions) -.SH SYNOPSIS -\fB#include <png.h>\fP - -\fBvoid png_build_gamma_table (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_build_grayscale_palette (int \fP\fIbit_depth\fP\fB, png_colorp \fIpalette\fP\fB);\fP - -\fBvoid png_calculate_crc (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIptr\fP\fB, png_size_t \fIlength\fP\fB);\fP - -\fBvoid png_check_chunk_name (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIchunk_name\fP\fB);\fP - -\fBpng_size_t png_check_keyword (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIkey\fP\fB, png_charpp \fInew_key\fP\fB);\fP - -\fBvoid png_combine_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIrow\fP\fB, int \fImask\fP\fB);\fP - -\fBvoid png_correct_palette (png_structp \fP\fIpng_ptr\fP\fB, png_colorp \fP\fIpalette\fP\fB, int \fInum_palette\fP\fB);\fP - -\fBint png_crc_error (png_structp \fIpng_ptr\fP\fB);\fP - -\fBint png_crc_finish (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIskip\fP\fB);\fP - -\fBvoid png_crc_read (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIbuf\fP\fB, png_size_t \fIlength\fP\fB);\fP - -\fBpng_voidp png_create_struct (int \fItype\fP\fB);\fP - -\fBpng_voidp png_create_struct_2 (int \fP\fItype\fP\fB, png_malloc_ptr \fP\fImalloc_fn\fP\fB, png_voidp \fImem_ptr\fP\fB);\fP - -\fBpng_charp png_decompress_chunk (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIcomp_type\fP\fB, png_charp \fP\fIchunkdata\fP\fB, png_size_t \fP\fIchunklength\fP\fB, png_size_t \fP\fIprefix_length\fP\fB, png_size_t \fI*data_length\fP\fB);\fP - -\fBvoid png_destroy_struct (png_voidp \fIstruct_ptr\fP\fB);\fP - -\fBvoid png_destroy_struct_2 (png_voidp \fP\fIstruct_ptr\fP\fB, png_free_ptr \fP\fIfree_fn\fP\fB, png_voidp \fImem_ptr\fP\fB);\fP - -\fBvoid png_do_background (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_color_16p \fP\fItrans_values\fP\fB, png_color_16p \fP\fIbackground\fP\fB, png_color_16p \fP\fIbackground_1\fP\fB, png_bytep \fP\fIgamma_table\fP\fB, png_bytep \fP\fIgamma_from_1\fP\fB, png_bytep \fP\fIgamma_to_1\fP\fB, png_uint_16pp \fP\fIgamma_16\fP\fB, png_uint_16pp \fP\fIgamma_16_from_1\fP\fB, png_uint_16pp \fP\fIgamma_16_to_1\fP\fB, int \fIgamma_shift\fP\fB);\fP - -\fBvoid png_do_bgr (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fBvoid png_do_chop (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fBvoid png_do_dither (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fP\fIpalette_lookup\fP\fB, png_bytep \fIdither_lookup\fP\fB);\fP - -\fBvoid png_do_expand (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_color_16p \fItrans_value\fP\fB);\fP - -\fBvoid png_do_expand_palette (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_colorp \fP\fIpalette\fP\fB, png_bytep \fP\fItrans\fP\fB, int \fInum_trans\fP\fB);\fP - -\fBvoid png_do_gamma (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fP\fIgamma_table\fP\fB, png_uint_16pp \fP\fIgamma_16_table\fP\fB, int \fIgamma_shift\fP\fB);\fP - -\fBvoid png_do_gray_to_rgb (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fBvoid png_do_invert (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fBvoid png_do_pack (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_uint_32 \fIbit_depth\fP\fB);\fP - -\fBvoid png_do_packswap (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fBvoid png_do_read_filler (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_uint_32 \fP\fIfiller\fP\fB, png_uint_32 \fIflags\fP\fB);\fP - -\fBvoid png_do_read_interlace (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, int \fP\fIpass\fP\fB, png_uint_32 \fItransformations\fP\fB);\fP - -\fBvoid png_do_read_invert_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fBvoid png_do_read_swap_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fBvoid png_do_read_transformations (png_structp \fIpng_ptr\fP\fB);\fP - -\fBint png_do_rgb_to_gray (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fBvoid png_do_shift (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_color_8p \fIbit_depth\fP\fB);\fP - -\fBvoid png_do_strip_filler (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_uint_32 \fIflags\fP\fB);\fP - -\fBvoid png_do_swap (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fBvoid png_do_unpack (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fBvoid png_do_unshift (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_color_8p \fIsig_bits\fP\fB);\fP - -\fBvoid png_do_write_interlace (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, int \fIpass\fP\fB);\fP - -\fBvoid png_do_write_invert_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fBvoid png_do_write_swap_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fBvoid png_do_write_transformations (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid *png_far_to_near (png_structp png_ptr,png_voidp \fP\fIptr\fP\fB, int \fIcheck\fP\fB);\fP - -\fBvoid png_flush (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_handle_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_gAMA (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_IEND (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_IHDR (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_iTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_pCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_pHYs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_sBIT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_sCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_sRGB (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_tEXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_tIME (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_tRNS (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_unknown (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_handle_zTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_info_destroy (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBvoid png_init_mmx_flags (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_init_read_transformations (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_process_IDAT_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIbuffer\fP\fB, png_size_t \fIbuffer_length\fP\fB);\fP - -\fBvoid png_process_some_data (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBvoid png_push_check_crc (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_push_crc_finish (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_push_crc_skip (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_push_fill_buffer (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIbuffer\fP\fB, png_size_t \fIlength\fP\fB);\fP - -\fBvoid png_push_handle_tEXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_push_handle_unknown (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_push_handle_zTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP - -\fBvoid png_push_have_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBvoid png_push_have_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBvoid png_push_have_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIrow\fP\fB);\fP - -\fBvoid png_push_process_row (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_push_read_chunk (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBvoid png_push_read_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBvoid png_push_read_IDAT (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_push_read_sig (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBvoid png_push_read_tEXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBvoid png_push_read_zTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBvoid png_push_restore_buffer (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIbuffer\fP\fB, png_size_t \fIbuffer_length\fP\fB);\fP - -\fBvoid png_push_save_buffer (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_read_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP - -\fBvoid png_read_filter_row (png_structp \fP\fIpng_ptr\fP\fB, png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fP\fIprev_row\fP\fB, int \fIfilter\fP\fB);\fP - -\fBvoid png_read_finish_row (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_read_push_finish_row (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_read_start_row (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_read_transform_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP - -\fBvoid png_reset_crc (png_structp \fIpng_ptr\fP\fB);\fP - -\fBint png_set_text_2 (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_textp \fP\fItext_ptr\fP\fB, int \fInum_text\fP\fB);\fP - -\fBvoid png_write_cHRM (png_structp \fP\fIpng_ptr\fP\fB, double \fP\fIwhite_x\fP\fB, double \fP\fIwhite_y\fP\fB, double \fP\fIred_x\fP\fB, double \fP\fIred_y\fP\fB, double \fP\fIgreen_x\fP\fB, double \fP\fIgreen_y\fP\fB, double \fP\fIblue_x\fP\fB, double \fIblue_y\fP\fB);\fP - -\fBvoid png_write_cHRM_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIwhite_x\fP\fB, png_uint_32 \fP\fIwhite_y\fP\fB, png_uint_32 \fP\fIred_x\fP\fB, png_uint_32 \fP\fIred_y\fP\fB, png_uint_32 \fP\fIgreen_x\fP\fB, png_uint_32 \fP\fIgreen_y\fP\fB, png_uint_32 \fP\fIblue_x\fP\fB, png_uint_32 \fIblue_y\fP\fB);\fP - -\fBvoid png_write_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP - -\fBvoid png_write_filtered_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIfiltered_row\fP\fB);\fP - -\fBvoid png_write_find_filter (png_structp \fP\fIpng_ptr\fP\fB, png_row_infop \fIrow_info\fP\fB);\fP - -\fBvoid png_write_finish_row (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_write_gAMA (png_structp \fP\fIpng_ptr\fP\fB, double \fIfile_gamma\fP\fB);\fP - -\fBvoid png_write_gAMA_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIint_file_gamma\fP\fB);\fP - -\fBvoid png_write_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_uint_16p \fP\fIhist\fP\fB, int \fInum_hist\fP\fB);\fP - -\fBvoid png_write_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIname\fP\fB, int \fP\fIcompression_type\fP\fB, png_charp \fP\fIprofile\fP\fB, int \fIproflen\fP\fB);\fP - -\fBvoid png_write_IDAT (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP - -\fBvoid png_write_IEND (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_write_IHDR (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIwidth\fP\fB, png_uint_32 \fP\fIheight\fP\fB, int \fP\fIbit_depth\fP\fB, int \fP\fIcolor_type\fP\fB, int \fP\fIcompression_type\fP\fB, int \fP\fIfilter_type\fP\fB, int \fIinterlace_type\fP\fB);\fP - -\fBvoid png_write_iTXt (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIcompression\fP\fB, png_charp \fP\fIkey\fP\fB, png_charp \fP\fIlang\fP\fB, png_charp \fP\fItranslated_key\fP\fB, png_charp \fItext\fP\fB);\fP - -\fBvoid png_write_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIx_offset\fP\fB, png_uint_32 \fP\fIy_offset\fP\fB, int \fIunit_type\fP\fB);\fP - -\fBvoid png_write_pCAL (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIpurpose\fP\fB, png_int_32 \fP\fIX0\fP\fB, png_int_32 \fP\fIX1\fP\fB, int \fP\fItype\fP\fB, int \fP\fInparams\fP\fB, png_charp \fP\fIunits\fP\fB, png_charpp \fIparams\fP\fB);\fP - -\fBvoid png_write_pHYs (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIx_pixels_per_unit\fP\fB, png_uint_32 \fP\fIy_pixels_per_unit\fP\fB, int \fIunit_type\fP\fB);\fP - -\fBvoid png_write_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_colorp \fP\fIpalette\fP\fB, png_uint_32 \fInum_pal\fP\fB);\fP - -\fBvoid png_write_sBIT (png_structp \fP\fIpng_ptr\fP\fB, png_color_8p \fP\fIsbit\fP\fB, int \fIcolor_type\fP\fB);\fP - -\fBvoid png_write_sCAL (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIunit\fP\fB, double \fP\fIwidth\fP\fB, double \fIheight\fP\fB);\fP - -\fBvoid png_write_sCAL_s (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIunit\fP\fB, png_charp \fP\fIwidth\fP\fB, png_charp \fIheight\fP\fB);\fP - -\fBvoid png_write_sig (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_write_sRGB (png_structp \fP\fIpng_ptr\fP\fB, int \fIintent\fP\fB);\fP - -\fBvoid png_write_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_spalette_p \fIpalette\fP\fB);\fP - -\fBvoid png_write_start_row (png_structp \fIpng_ptr\fP\fB);\fP - -\fBvoid png_write_tEXt (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIkey\fP\fB, png_charp \fP\fItext\fP\fB, png_size_t \fItext_len\fP\fB);\fP - -\fBvoid png_write_tIME (png_structp \fP\fIpng_ptr\fP\fB, png_timep \fImod_time\fP\fB);\fP - -\fBvoid png_write_tRNS (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fItrans\fP\fB, png_color_16p \fP\fIvalues\fP\fB, int \fP\fInumber\fP\fB, int \fIcolor_type\fP\fB);\fP - -\fBvoid png_write_zTXt (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIkey\fP\fB, png_charp \fP\fItext\fP\fB, png_size_t \fP\fItext_len\fP\fB, int \fIcompression\fP\fB);\fP - -\fBvoidpf png_zalloc (voidpf \fP\fIpng_ptr\fP\fB, uInt \fP\fIitems\fP\fB, uInt \fIsize\fP\fB);\fP - -\fBvoid png_zfree (voidpf \fP\fIpng_ptr\fP\fB, voidpf \fIptr\fP\fB);\fP - -\fI\fB - -.SH DESCRIPTION -The functions listed above are used privately by libpng -and are not recommended for use by applications. They are -not "exported" to applications using shared libraries. They -are listed alphabetically here as an aid to libpng maintainers. -See png.h for more information on these functions. - -.SH SEE ALSO -libpng(3), png(5) -.SH AUTHOR -Glenn Randers-Pehrson diff --git a/irrlicht-1.6/source/Irrlicht/libpng/png.5 b/irrlicht-1.6/source/Irrlicht/libpng/png.5 deleted file mode 100644 index 142faf699..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/png.5 +++ /dev/null @@ -1,74 +0,0 @@ -.TH PNG 5 "May 15, 2007" -.SH NAME -png \- Portable Network Graphics (PNG) format -.SH DESCRIPTION -PNG (Portable Network Graphics) is an extensible file format for the -lossless, portable, well-compressed storage of raster images. PNG provides -a patent-free replacement for GIF and can also replace many -common uses of TIFF. Indexed-color, grayscale, and truecolor images are -supported, plus an optional alpha channel. Sample depths range from -1 to 16 bits. -.br - -PNG is designed to work well in online viewing applications, such as the -World Wide Web, so it is fully streamable with a progressive display -option. PNG is robust, providing both full file integrity checking and -fast, simple detection of common transmission errors. Also, PNG can store -gamma and chromaticity data for improved color matching on heterogeneous -platforms. - -.SH "SEE ALSO" -.IR libpng(3), zlib(3), deflate(5), and zlib(5) -.LP -PNG specification (second edition), November 2003: -.IP -.br - <http://www.w3.org/TR/2003/REC-PNG-20031110/ -PNG 1.2 specification, July 1999: -.IP -.br -http://www.libpng.org/pub/png -.LP -PNG 1.0 specification, October 1996: -.IP -.br -RFC 2083 -.IP -.br -ftp://ds.internic.net/rfc/rfc2083.txt -.br -or (as a W3C Recommendation) at -.br -http://www.w3.org/TR/REC-png.html -.SH AUTHORS -This man page: Glenn Randers-Pehrson -.LP -Portable Network Graphics (PNG) Specification (Second Edition) -Information technology - Computer graphics and image processing - -Portable Network Graphics (PNG): Functional specification. -ISO/IEC 15948:2003 (E) (November 10, 2003): David Duce and others. -.LP -Portable Network Graphics (PNG) Specification Version 1.2 (July 8, 1999): -Glenn Randers-Pehrson and others (png-list). -.LP -Portable Network Graphics (PNG) Specification Version 1.0 (October 1, 1996): -Thomas Boutell and others (png-list). -.LP - - -.SH COPYRIGHT NOTICE -.LP -This man page is Copyright (c) 1998-2006 Glenn Randers-Pehrson. See png.h -for conditions of use and distribution. -.LP -The PNG Specification (Second Edition) is -Copyright (c) 2003 W3C. (MIT, ERCIM, Keio), All Rights Reserved. -.LP -The PNG-1.2 specification is copyright (c) 1999 Glenn Randers-Pehrson. -See the specification for conditions of use and distribution. -.LP -The PNG-1.0 specification is copyright (c) 1996 Massachusetts Institute of -Technology. See the specification for conditions of use and distribution. -.LP -.\" end of man page - diff --git a/irrlicht-1.6/source/Irrlicht/libpng/png.c b/irrlicht-1.6/source/Irrlicht/libpng/png.c deleted file mode 100644 index 03ca4a6da..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/png.c +++ /dev/null @@ -1,861 +0,0 @@ - -/* png.c - location for general purpose libpng functions - * - * Last changed in libpng 1.2.17 May 15, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -#define PNG_INTERNAL -#define PNG_NO_EXTERN -#include "png.h" - -/* Generate a compiler error if there is an old png.h in the search path. */ -typedef version_1_2_18 Your_png_h_is_not_version_1_2_18; - -/* Version information for C files. This had better match the version - * string defined in png.h. */ - -#ifdef PNG_USE_GLOBAL_ARRAYS -/* png_libpng_ver was changed to a function in version 1.0.5c */ -const char png_libpng_ver[18] = PNG_LIBPNG_VER_STRING; - -#ifdef PNG_READ_SUPPORTED - -/* png_sig was changed to a function in version 1.0.5c */ -/* Place to hold the signature string for a PNG file. */ -const png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10}; -#endif /* PNG_READ_SUPPORTED */ - -/* Invoke global declarations for constant strings for known chunk types */ -PNG_IHDR; -PNG_IDAT; -PNG_IEND; -PNG_PLTE; -PNG_bKGD; -PNG_cHRM; -PNG_gAMA; -PNG_hIST; -PNG_iCCP; -PNG_iTXt; -PNG_oFFs; -PNG_pCAL; -PNG_sCAL; -PNG_pHYs; -PNG_sBIT; -PNG_sPLT; -PNG_sRGB; -PNG_tEXt; -PNG_tIME; -PNG_tRNS; -PNG_zTXt; - -#ifdef PNG_READ_SUPPORTED -/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - -/* start of interlace block */ -const int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; - -/* offset to next interlace block */ -const int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; - -/* start of interlace block in the y direction */ -const int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; - -/* offset to next interlace block in the y direction */ -const int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; - -/* width of interlace block (used in assembler routines only) */ -#ifdef PNG_HAVE_MMX_COMBINE_ROW -const int FARDATA png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; -#endif - -/* Height of interlace block. This is not currently used - if you need - * it, uncomment it here and in png.h -const int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1}; -*/ - -/* Mask to determine which pixels are valid in a pass */ -const int FARDATA png_pass_mask[] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff}; - -/* Mask to determine which pixels to overwrite while displaying */ -const int FARDATA png_pass_dsp_mask[] - = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; - -#endif /* PNG_READ_SUPPORTED */ -#endif /* PNG_USE_GLOBAL_ARRAYS */ - -/* Tells libpng that we have already handled the first "num_bytes" bytes - * of the PNG file signature. If the PNG data is embedded into another - * stream we can set num_bytes = 8 so that libpng will not attempt to read - * or write any of the magic bytes before it starts on the IHDR. - */ - -#ifdef PNG_READ_SUPPORTED -void PNGAPI -png_set_sig_bytes(png_structp png_ptr, int num_bytes) -{ - if(png_ptr == NULL) return; - png_debug(1, "in png_set_sig_bytes\n"); - if (num_bytes > 8) - png_error(png_ptr, "Too many bytes for PNG signature."); - - png_ptr->sig_bytes = (png_byte)(num_bytes < 0 ? 0 : num_bytes); -} - -/* Checks whether the supplied bytes match the PNG signature. We allow - * checking less than the full 8-byte signature so that those apps that - * already read the first few bytes of a file to determine the file type - * can simply check the remaining bytes for extra assurance. Returns - * an integer less than, equal to, or greater than zero if sig is found, - * respectively, to be less than, to match, or be greater than the correct - * PNG signature (this is the same behaviour as strcmp, memcmp, etc). - */ -int PNGAPI -png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check) -{ - png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10}; - if (num_to_check > 8) - num_to_check = 8; - else if (num_to_check < 1) - return (-1); - - if (start > 7) - return (-1); - - if (start + num_to_check > 8) - num_to_check = 8 - start; - - return ((int)(png_memcmp(&sig[start], &png_signature[start], num_to_check))); -} - -#if defined(PNG_1_0_X) || defined(PNG_1_2_X) -/* (Obsolete) function to check signature bytes. It does not allow one - * to check a partial signature. This function might be removed in the - * future - use png_sig_cmp(). Returns true (nonzero) if the file is a PNG. - */ -int PNGAPI -png_check_sig(png_bytep sig, int num) -{ - return ((int)!png_sig_cmp(sig, (png_size_t)0, (png_size_t)num)); -} -#endif -#endif /* PNG_READ_SUPPORTED */ - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) -/* Function to allocate memory for zlib and clear it to 0. */ -#ifdef PNG_1_0_X -voidpf PNGAPI -#else -voidpf /* private */ -#endif -png_zalloc(voidpf png_ptr, uInt items, uInt size) -{ - png_voidp ptr; - png_structp p=(png_structp)png_ptr; - png_uint_32 save_flags=p->flags; - png_uint_32 num_bytes; - - if(png_ptr == NULL) return (NULL); - if (items > PNG_UINT_32_MAX/size) - { - png_warning (p, "Potential overflow in png_zalloc()"); - return (NULL); - } - num_bytes = (png_uint_32)items * size; - - p->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK; - ptr = (png_voidp)png_malloc((png_structp)png_ptr, num_bytes); - p->flags=save_flags; - -#if defined(PNG_1_0_X) && !defined(PNG_NO_ZALLOC_ZERO) - if (ptr == NULL) - return ((voidpf)ptr); - - if (num_bytes > (png_uint_32)0x8000L) - { - png_memset(ptr, 0, (png_size_t)0x8000L); - png_memset((png_bytep)ptr + (png_size_t)0x8000L, 0, - (png_size_t)(num_bytes - (png_uint_32)0x8000L)); - } - else - { - png_memset(ptr, 0, (png_size_t)num_bytes); - } -#endif - return ((voidpf)ptr); -} - -/* function to free memory for zlib */ -#ifdef PNG_1_0_X -void PNGAPI -#else -void /* private */ -#endif -png_zfree(voidpf png_ptr, voidpf ptr) -{ - png_free((png_structp)png_ptr, (png_voidp)ptr); -} - -/* Reset the CRC variable to 32 bits of 1's. Care must be taken - * in case CRC is > 32 bits to leave the top bits 0. - */ -void /* PRIVATE */ -png_reset_crc(png_structp png_ptr) -{ - png_ptr->crc = crc32(0, Z_NULL, 0); -} - -/* Calculate the CRC over a section of data. We can only pass as - * much data to this routine as the largest single buffer size. We - * also check that this data will actually be used before going to the - * trouble of calculating it. - */ -void /* PRIVATE */ -png_calculate_crc(png_structp png_ptr, png_bytep ptr, png_size_t length) -{ - int need_crc = 1; - - if (png_ptr->chunk_name[0] & 0x20) /* ancillary */ - { - if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) == - (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN)) - need_crc = 0; - } - else /* critical */ - { - if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE) - need_crc = 0; - } - - if (need_crc) - png_ptr->crc = crc32(png_ptr->crc, ptr, (uInt)length); -} - -/* Allocate the memory for an info_struct for the application. We don't - * really need the png_ptr, but it could potentially be useful in the - * future. This should be used in favour of malloc(png_sizeof(png_info)) - * and png_info_init() so that applications that want to use a shared - * libpng don't have to be recompiled if png_info changes size. - */ -png_infop PNGAPI -png_create_info_struct(png_structp png_ptr) -{ - png_infop info_ptr; - - png_debug(1, "in png_create_info_struct\n"); - if(png_ptr == NULL) return (NULL); -#ifdef PNG_USER_MEM_SUPPORTED - info_ptr = (png_infop)png_create_struct_2(PNG_STRUCT_INFO, - png_ptr->malloc_fn, png_ptr->mem_ptr); -#else - info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO); -#endif - if (info_ptr != NULL) - png_info_init_3(&info_ptr, png_sizeof(png_info)); - - return (info_ptr); -} - -/* This function frees the memory associated with a single info struct. - * Normally, one would use either png_destroy_read_struct() or - * png_destroy_write_struct() to free an info struct, but this may be - * useful for some applications. - */ -void PNGAPI -png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr) -{ - png_infop info_ptr = NULL; - if(png_ptr == NULL) return; - - png_debug(1, "in png_destroy_info_struct\n"); - if (info_ptr_ptr != NULL) - info_ptr = *info_ptr_ptr; - - if (info_ptr != NULL) - { - png_info_destroy(png_ptr, info_ptr); - -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)info_ptr, png_ptr->free_fn, - png_ptr->mem_ptr); -#else - png_destroy_struct((png_voidp)info_ptr); -#endif - *info_ptr_ptr = NULL; - } -} - -/* Initialize the info structure. This is now an internal function (0.89) - * and applications using it are urged to use png_create_info_struct() - * instead. - */ -#if defined(PNG_1_0_X) || defined(PNG_1_2_X) -#undef png_info_init -void PNGAPI -png_info_init(png_infop info_ptr) -{ - /* We only come here via pre-1.0.12-compiled applications */ - png_info_init_3(&info_ptr, 0); -} -#endif - -void PNGAPI -png_info_init_3(png_infopp ptr_ptr, png_size_t png_info_struct_size) -{ - png_infop info_ptr = *ptr_ptr; - - if(info_ptr == NULL) return; - - png_debug(1, "in png_info_init_3\n"); - - if(png_sizeof(png_info) > png_info_struct_size) - { - png_destroy_struct(info_ptr); - info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO); - *ptr_ptr = info_ptr; - } - - /* set everything to 0 */ - png_memset(info_ptr, 0, png_sizeof (png_info)); -} - -#ifdef PNG_FREE_ME_SUPPORTED -void PNGAPI -png_data_freer(png_structp png_ptr, png_infop info_ptr, - int freer, png_uint_32 mask) -{ - png_debug(1, "in png_data_freer\n"); - if (png_ptr == NULL || info_ptr == NULL) - return; - if(freer == PNG_DESTROY_WILL_FREE_DATA) - info_ptr->free_me |= mask; - else if(freer == PNG_USER_WILL_FREE_DATA) - info_ptr->free_me &= ~mask; - else - png_warning(png_ptr, - "Unknown freer parameter in png_data_freer."); -} -#endif - -void PNGAPI -png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask, - int num) -{ - png_debug(1, "in png_free_data\n"); - if (png_ptr == NULL || info_ptr == NULL) - return; - -#if defined(PNG_TEXT_SUPPORTED) -/* free text item num or (if num == -1) all text items */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_TEXT) & info_ptr->free_me) -#else -if (mask & PNG_FREE_TEXT) -#endif -{ - if (num != -1) - { - if (info_ptr->text && info_ptr->text[num].key) - { - png_free(png_ptr, info_ptr->text[num].key); - info_ptr->text[num].key = NULL; - } - } - else - { - int i; - for (i = 0; i < info_ptr->num_text; i++) - png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, i); - png_free(png_ptr, info_ptr->text); - info_ptr->text = NULL; - info_ptr->num_text=0; - } -} -#endif - -#if defined(PNG_tRNS_SUPPORTED) -/* free any tRNS entry */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_TRNS) & info_ptr->free_me) -#else -if ((mask & PNG_FREE_TRNS) && (png_ptr->flags & PNG_FLAG_FREE_TRNS)) -#endif -{ - png_free(png_ptr, info_ptr->trans); - info_ptr->valid &= ~PNG_INFO_tRNS; -#ifndef PNG_FREE_ME_SUPPORTED - png_ptr->flags &= ~PNG_FLAG_FREE_TRNS; -#endif - info_ptr->trans = NULL; -} -#endif - -#if defined(PNG_sCAL_SUPPORTED) -/* free any sCAL entry */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_SCAL) & info_ptr->free_me) -#else -if (mask & PNG_FREE_SCAL) -#endif -{ -#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) - png_free(png_ptr, info_ptr->scal_s_width); - png_free(png_ptr, info_ptr->scal_s_height); - info_ptr->scal_s_width = NULL; - info_ptr->scal_s_height = NULL; -#endif - info_ptr->valid &= ~PNG_INFO_sCAL; -} -#endif - -#if defined(PNG_pCAL_SUPPORTED) -/* free any pCAL entry */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_PCAL) & info_ptr->free_me) -#else -if (mask & PNG_FREE_PCAL) -#endif -{ - png_free(png_ptr, info_ptr->pcal_purpose); - png_free(png_ptr, info_ptr->pcal_units); - info_ptr->pcal_purpose = NULL; - info_ptr->pcal_units = NULL; - if (info_ptr->pcal_params != NULL) - { - int i; - for (i = 0; i < (int)info_ptr->pcal_nparams; i++) - { - png_free(png_ptr, info_ptr->pcal_params[i]); - info_ptr->pcal_params[i]=NULL; - } - png_free(png_ptr, info_ptr->pcal_params); - info_ptr->pcal_params = NULL; - } - info_ptr->valid &= ~PNG_INFO_pCAL; -} -#endif - -#if defined(PNG_iCCP_SUPPORTED) -/* free any iCCP entry */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_ICCP) & info_ptr->free_me) -#else -if (mask & PNG_FREE_ICCP) -#endif -{ - png_free(png_ptr, info_ptr->iccp_name); - png_free(png_ptr, info_ptr->iccp_profile); - info_ptr->iccp_name = NULL; - info_ptr->iccp_profile = NULL; - info_ptr->valid &= ~PNG_INFO_iCCP; -} -#endif - -#if defined(PNG_sPLT_SUPPORTED) -/* free a given sPLT entry, or (if num == -1) all sPLT entries */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_SPLT) & info_ptr->free_me) -#else -if (mask & PNG_FREE_SPLT) -#endif -{ - if (num != -1) - { - if(info_ptr->splt_palettes) - { - png_free(png_ptr, info_ptr->splt_palettes[num].name); - png_free(png_ptr, info_ptr->splt_palettes[num].entries); - info_ptr->splt_palettes[num].name = NULL; - info_ptr->splt_palettes[num].entries = NULL; - } - } - else - { - if(info_ptr->splt_palettes_num) - { - int i; - for (i = 0; i < (int)info_ptr->splt_palettes_num; i++) - png_free_data(png_ptr, info_ptr, PNG_FREE_SPLT, i); - - png_free(png_ptr, info_ptr->splt_palettes); - info_ptr->splt_palettes = NULL; - info_ptr->splt_palettes_num = 0; - } - info_ptr->valid &= ~PNG_INFO_sPLT; - } -} -#endif - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - if(png_ptr->unknown_chunk.data) - { - png_free(png_ptr, png_ptr->unknown_chunk.data); - png_ptr->unknown_chunk.data = NULL; - } -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_UNKN) & info_ptr->free_me) -#else -if (mask & PNG_FREE_UNKN) -#endif -{ - if (num != -1) - { - if(info_ptr->unknown_chunks) - { - png_free(png_ptr, info_ptr->unknown_chunks[num].data); - info_ptr->unknown_chunks[num].data = NULL; - } - } - else - { - int i; - - if(info_ptr->unknown_chunks_num) - { - for (i = 0; i < (int)info_ptr->unknown_chunks_num; i++) - png_free_data(png_ptr, info_ptr, PNG_FREE_UNKN, i); - - png_free(png_ptr, info_ptr->unknown_chunks); - info_ptr->unknown_chunks = NULL; - info_ptr->unknown_chunks_num = 0; - } - } -} -#endif - -#if defined(PNG_hIST_SUPPORTED) -/* free any hIST entry */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_HIST) & info_ptr->free_me) -#else -if ((mask & PNG_FREE_HIST) && (png_ptr->flags & PNG_FLAG_FREE_HIST)) -#endif -{ - png_free(png_ptr, info_ptr->hist); - info_ptr->hist = NULL; - info_ptr->valid &= ~PNG_INFO_hIST; -#ifndef PNG_FREE_ME_SUPPORTED - png_ptr->flags &= ~PNG_FLAG_FREE_HIST; -#endif -} -#endif - -/* free any PLTE entry that was internally allocated */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_PLTE) & info_ptr->free_me) -#else -if ((mask & PNG_FREE_PLTE) && (png_ptr->flags & PNG_FLAG_FREE_PLTE)) -#endif -{ - png_zfree(png_ptr, info_ptr->palette); - info_ptr->palette = NULL; - info_ptr->valid &= ~PNG_INFO_PLTE; -#ifndef PNG_FREE_ME_SUPPORTED - png_ptr->flags &= ~PNG_FLAG_FREE_PLTE; -#endif - info_ptr->num_palette = 0; -} - -#if defined(PNG_INFO_IMAGE_SUPPORTED) -/* free any image bits attached to the info structure */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_ROWS) & info_ptr->free_me) -#else -if (mask & PNG_FREE_ROWS) -#endif -{ - if(info_ptr->row_pointers) - { - int row; - for (row = 0; row < (int)info_ptr->height; row++) - { - png_free(png_ptr, info_ptr->row_pointers[row]); - info_ptr->row_pointers[row]=NULL; - } - png_free(png_ptr, info_ptr->row_pointers); - info_ptr->row_pointers=NULL; - } - info_ptr->valid &= ~PNG_INFO_IDAT; -} -#endif - -#ifdef PNG_FREE_ME_SUPPORTED - if(num == -1) - info_ptr->free_me &= ~mask; - else - info_ptr->free_me &= ~(mask & ~PNG_FREE_MUL); -#endif -} - -/* This is an internal routine to free any memory that the info struct is - * pointing to before re-using it or freeing the struct itself. Recall - * that png_free() checks for NULL pointers for us. - */ -void /* PRIVATE */ -png_info_destroy(png_structp png_ptr, png_infop info_ptr) -{ - png_debug(1, "in png_info_destroy\n"); - - png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1); - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - if (png_ptr->num_chunk_list) - { - png_free(png_ptr, png_ptr->chunk_list); - png_ptr->chunk_list=NULL; - png_ptr->num_chunk_list=0; - } -#endif - - png_info_init_3(&info_ptr, png_sizeof(png_info)); -} -#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ - -/* This function returns a pointer to the io_ptr associated with the user - * functions. The application should free any memory associated with this - * pointer before png_write_destroy() or png_read_destroy() are called. - */ -png_voidp PNGAPI -png_get_io_ptr(png_structp png_ptr) -{ - if(png_ptr == NULL) return (NULL); - return (png_ptr->io_ptr); -} - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) -#if !defined(PNG_NO_STDIO) -/* Initialize the default input/output functions for the PNG file. If you - * use your own read or write routines, you can call either png_set_read_fn() - * or png_set_write_fn() instead of png_init_io(). If you have defined - * PNG_NO_STDIO, you must use a function of your own because "FILE *" isn't - * necessarily available. - */ -void PNGAPI -png_init_io(png_structp png_ptr, png_FILE_p fp) -{ - png_debug(1, "in png_init_io\n"); - if(png_ptr == NULL) return; - png_ptr->io_ptr = (png_voidp)fp; -} -#endif - -#if defined(PNG_TIME_RFC1123_SUPPORTED) -/* Convert the supplied time into an RFC 1123 string suitable for use in - * a "Creation Time" or other text-based time string. - */ -png_charp PNGAPI -png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime) -{ - static PNG_CONST char short_months[12][4] = - {"Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; - - if(png_ptr == NULL) return (NULL); - if (png_ptr->time_buffer == NULL) - { - png_ptr->time_buffer = (png_charp)png_malloc(png_ptr, (png_uint_32)(29* - png_sizeof(char))); - } - -#if defined(_WIN32_WCE) - { - wchar_t time_buf[29]; - wsprintf(time_buf, TEXT("%d %S %d %02d:%02d:%02d +0000"), - ptime->day % 32, short_months[(ptime->month - 1) % 12], - ptime->year, ptime->hour % 24, ptime->minute % 60, - ptime->second % 61); - WideCharToMultiByte(CP_ACP, 0, time_buf, -1, png_ptr->time_buffer, 29, - NULL, NULL); - } -#else -#ifdef USE_FAR_KEYWORD - { - char near_time_buf[29]; - sprintf(near_time_buf, "%d %s %d %02d:%02d:%02d +0000", - ptime->day % 32, short_months[(ptime->month - 1) % 12], - ptime->year, ptime->hour % 24, ptime->minute % 60, - ptime->second % 61); - png_memcpy(png_ptr->time_buffer, near_time_buf, - 29*png_sizeof(char)); - } -#else - sprintf(png_ptr->time_buffer, "%d %s %d %02d:%02d:%02d +0000", - ptime->day % 32, short_months[(ptime->month - 1) % 12], - ptime->year, ptime->hour % 24, ptime->minute % 60, - ptime->second % 61); -#endif -#endif /* _WIN32_WCE */ - return ((png_charp)png_ptr->time_buffer); -} -#endif /* PNG_TIME_RFC1123_SUPPORTED */ - -#if 0 -/* Signature string for a PNG file. */ -png_bytep PNGAPI -png_sig_bytes(void) -{ - return ((png_bytep)"\211\120\116\107\015\012\032\012"); -} -#endif -#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ - -png_charp PNGAPI -png_get_copyright(png_structp png_ptr) -{ - if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */ - return ((png_charp) "\n libpng version 1.2.18 - May 15, 2007\n\ - Copyright (c) 1998-2007 Glenn Randers-Pehrson\n\ - Copyright (c) 1996-1997 Andreas Dilger\n\ - Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n"); - return ((png_charp) ""); -} - -/* The following return the library version as a short string in the - * format 1.0.0 through 99.99.99zz. To get the version of *.h files - * used with your application, print out PNG_LIBPNG_VER_STRING, which - * is defined in png.h. - * Note: now there is no difference between png_get_libpng_ver() and - * png_get_header_ver(). Due to the version_nn_nn_nn typedef guard, - * it is guaranteed that png.c uses the correct version of png.h. - */ -png_charp PNGAPI -png_get_libpng_ver(png_structp png_ptr) -{ - /* Version of *.c files used when building libpng */ - if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */ - return ((png_charp) PNG_LIBPNG_VER_STRING); - return ((png_charp) ""); -} - -png_charp PNGAPI -png_get_header_ver(png_structp png_ptr) -{ - /* Version of *.h files used when building libpng */ - if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */ - return ((png_charp) PNG_LIBPNG_VER_STRING); - return ((png_charp) ""); -} - -png_charp PNGAPI -png_get_header_version(png_structp png_ptr) -{ - /* Returns longer string containing both version and date */ - if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */ - return ((png_charp) PNG_HEADER_VERSION_STRING); - return ((png_charp) ""); -} - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED -int PNGAPI -png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name) -{ - /* check chunk_name and return "keep" value if it's on the list, else 0 */ - int i; - png_bytep p; - if((png_ptr == NULL && chunk_name == NULL) || png_ptr->num_chunk_list<=0) - return 0; - p=png_ptr->chunk_list+png_ptr->num_chunk_list*5-5; - for (i = png_ptr->num_chunk_list; i; i--, p-=5) - if (!png_memcmp(chunk_name, p, 4)) - return ((int)*(p+4)); - return 0; -} -#endif - -/* This function, added to libpng-1.0.6g, is untested. */ -int PNGAPI -png_reset_zstream(png_structp png_ptr) -{ - if (png_ptr == NULL) return Z_STREAM_ERROR; - return (inflateReset(&png_ptr->zstream)); -} -#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ - -/* This function was added to libpng-1.0.7 */ -png_uint_32 PNGAPI -png_access_version_number(void) -{ - /* Version of *.c files used when building libpng */ - return((png_uint_32) PNG_LIBPNG_VER); -} - - -#if defined(PNG_READ_SUPPORTED) && defined(PNG_ASSEMBLER_CODE_SUPPORTED) -#if !defined(PNG_1_0_X) -#if defined(PNG_MMX_CODE_SUPPORTED) -/* this INTERNAL function was added to libpng 1.2.0 */ -void /* PRIVATE */ -png_init_mmx_flags (png_structp png_ptr) -{ - if(png_ptr == NULL) return; - png_ptr->mmx_rowbytes_threshold = 0; - png_ptr->mmx_bitdepth_threshold = 0; - -# if (defined(PNG_USE_PNGVCRD) || defined(PNG_USE_PNGGCCRD)) - - png_ptr->asm_flags |= PNG_ASM_FLAG_MMX_SUPPORT_COMPILED; - - if (png_mmx_support() > 0) { - png_ptr->asm_flags |= PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU -# ifdef PNG_HAVE_MMX_COMBINE_ROW - | PNG_ASM_FLAG_MMX_READ_COMBINE_ROW -# endif -# ifdef PNG_HAVE_MMX_READ_INTERLACE - | PNG_ASM_FLAG_MMX_READ_INTERLACE -# endif -# ifndef PNG_HAVE_MMX_READ_FILTER_ROW - ; -# else - | PNG_ASM_FLAG_MMX_READ_FILTER_SUB - | PNG_ASM_FLAG_MMX_READ_FILTER_UP - | PNG_ASM_FLAG_MMX_READ_FILTER_AVG - | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ; - - png_ptr->mmx_rowbytes_threshold = PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT; - png_ptr->mmx_bitdepth_threshold = PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT; -# endif - } else { - png_ptr->asm_flags &= ~( PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU - | PNG_MMX_READ_FLAGS - | PNG_MMX_WRITE_FLAGS ); - } - -# else /* !(PNGVCRD || PNGGCCRD) */ - - /* clear all MMX flags; no support is compiled in */ - png_ptr->asm_flags &= ~( PNG_MMX_FLAGS ); - -# endif /* ?(PNGVCRD || PNGGCCRD) */ -} - -#endif /* !(PNG_MMX_CODE_SUPPORTED) */ - -/* this function was added to libpng 1.2.0 */ -#if !defined(PNG_USE_PNGGCCRD) && \ - !(defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_USE_PNGVCRD)) -int PNGAPI -png_mmx_support(void) -{ - return -1; -} -#endif -#endif /* PNG_1_0_X && PNG_ASSEMBLER_CODE_SUPPORTED */ -#endif /* PNG_READ_SUPPORTED */ - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) -#ifdef PNG_SIZE_T -/* Added at libpng version 1.2.6 */ - PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size)); -png_size_t PNGAPI -png_convert_size(size_t size) -{ - if (size > (png_size_t)-1) - PNG_ABORT(); /* We haven't got access to png_ptr, so no png_error() */ - return ((png_size_t)size); -} -#endif /* PNG_SIZE_T */ -#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/png.h b/irrlicht-1.6/source/Irrlicht/libpng/png.h deleted file mode 100644 index f19cf81c3..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/png.h +++ /dev/null @@ -1,3523 +0,0 @@ - -/* png.h - header file for PNG reference library - * - * libpng version 1.2.18 - May 15, 2007 - * Copyright (c) 1998-2007 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * Authors and maintainers: - * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat - * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger - * libpng versions 0.97, January 1998, through 1.2.18 - May 15, 2007: Glenn - * See also "Contributing Authors", below. - * - * Note about libpng version numbers: - * - * Due to various miscommunications, unforeseen code incompatibilities - * and occasional factors outside the authors' control, version numbering - * on the library has not always been consistent and straightforward. - * The following table summarizes matters since version 0.89c, which was - * the first widely used release: - * - * source png.h png.h shared-lib - * version string int version - * ------- ------ ----- ---------- - * 0.89c "1.0 beta 3" 0.89 89 1.0.89 - * 0.90 "1.0 beta 4" 0.90 90 0.90 [should have been 2.0.90] - * 0.95 "1.0 beta 5" 0.95 95 0.95 [should have been 2.0.95] - * 0.96 "1.0 beta 6" 0.96 96 0.96 [should have been 2.0.96] - * 0.97b "1.00.97 beta 7" 1.00.97 97 1.0.1 [should have been 2.0.97] - * 0.97c 0.97 97 2.0.97 - * 0.98 0.98 98 2.0.98 - * 0.99 0.99 98 2.0.99 - * 0.99a-m 0.99 99 2.0.99 - * 1.00 1.00 100 2.1.0 [100 should be 10000] - * 1.0.0 (from here on, the 100 2.1.0 [100 should be 10000] - * 1.0.1 png.h string is 10001 2.1.0 - * 1.0.1a-e identical to the 10002 from here on, the shared library - * 1.0.2 source version) 10002 is 2.V where V is the source code - * 1.0.2a-b 10003 version, except as noted. - * 1.0.3 10003 - * 1.0.3a-d 10004 - * 1.0.4 10004 - * 1.0.4a-f 10005 - * 1.0.5 (+ 2 patches) 10005 - * 1.0.5a-d 10006 - * 1.0.5e-r 10100 (not source compatible) - * 1.0.5s-v 10006 (not binary compatible) - * 1.0.6 (+ 3 patches) 10006 (still binary incompatible) - * 1.0.6d-f 10007 (still binary incompatible) - * 1.0.6g 10007 - * 1.0.6h 10007 10.6h (testing xy.z so-numbering) - * 1.0.6i 10007 10.6i - * 1.0.6j 10007 2.1.0.6j (incompatible with 1.0.0) - * 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 (binary compatible) - * 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 (binary compatible) - * 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 (binary compatible) - * 1.0.7 1 10007 (still compatible) - * 1.0.8beta1-4 1 10008 2.1.0.8beta1-4 - * 1.0.8rc1 1 10008 2.1.0.8rc1 - * 1.0.8 1 10008 2.1.0.8 - * 1.0.9beta1-6 1 10009 2.1.0.9beta1-6 - * 1.0.9rc1 1 10009 2.1.0.9rc1 - * 1.0.9beta7-10 1 10009 2.1.0.9beta7-10 - * 1.0.9rc2 1 10009 2.1.0.9rc2 - * 1.0.9 1 10009 2.1.0.9 - * 1.0.10beta1 1 10010 2.1.0.10beta1 - * 1.0.10rc1 1 10010 2.1.0.10rc1 - * 1.0.10 1 10010 2.1.0.10 - * 1.0.11beta1-3 1 10011 2.1.0.11beta1-3 - * 1.0.11rc1 1 10011 2.1.0.11rc1 - * 1.0.11 1 10011 2.1.0.11 - * 1.0.12beta1-2 2 10012 2.1.0.12beta1-2 - * 1.0.12rc1 2 10012 2.1.0.12rc1 - * 1.0.12 2 10012 2.1.0.12 - * 1.1.0a-f - 10100 2.1.1.0a-f (branch abandoned) - * 1.2.0beta1-2 2 10200 2.1.2.0beta1-2 - * 1.2.0beta3-5 3 10200 3.1.2.0beta3-5 - * 1.2.0rc1 3 10200 3.1.2.0rc1 - * 1.2.0 3 10200 3.1.2.0 - * 1.2.1beta1-4 3 10201 3.1.2.1beta1-4 - * 1.2.1rc1-2 3 10201 3.1.2.1rc1-2 - * 1.2.1 3 10201 3.1.2.1 - * 1.2.2beta1-6 12 10202 12.so.0.1.2.2beta1-6 - * 1.0.13beta1 10 10013 10.so.0.1.0.13beta1 - * 1.0.13rc1 10 10013 10.so.0.1.0.13rc1 - * 1.2.2rc1 12 10202 12.so.0.1.2.2rc1 - * 1.0.13 10 10013 10.so.0.1.0.13 - * 1.2.2 12 10202 12.so.0.1.2.2 - * 1.2.3rc1-6 12 10203 12.so.0.1.2.3rc1-6 - * 1.2.3 12 10203 12.so.0.1.2.3 - * 1.2.4beta1-3 13 10204 12.so.0.1.2.4beta1-3 - * 1.0.14rc1 13 10014 10.so.0.1.0.14rc1 - * 1.2.4rc1 13 10204 12.so.0.1.2.4rc1 - * 1.0.14 10 10014 10.so.0.1.0.14 - * 1.2.4 13 10204 12.so.0.1.2.4 - * 1.2.5beta1-2 13 10205 12.so.0.1.2.5beta1-2 - * 1.0.15rc1-3 10 10015 10.so.0.1.0.15rc1-3 - * 1.2.5rc1-3 13 10205 12.so.0.1.2.5rc1-3 - * 1.0.15 10 10015 10.so.0.1.0.15 - * 1.2.5 13 10205 12.so.0.1.2.5 - * 1.2.6beta1-4 13 10206 12.so.0.1.2.6beta1-4 - * 1.0.16 10 10016 10.so.0.1.0.16 - * 1.2.6 13 10206 12.so.0.1.2.6 - * 1.2.7beta1-2 13 10207 12.so.0.1.2.7beta1-2 - * 1.0.17rc1 10 10017 10.so.0.1.0.17rc1 - * 1.2.7rc1 13 10207 12.so.0.1.2.7rc1 - * 1.0.17 10 10017 10.so.0.1.0.17 - * 1.2.7 13 10207 12.so.0.1.2.7 - * 1.2.8beta1-5 13 10208 12.so.0.1.2.8beta1-5 - * 1.0.18rc1-5 10 10018 10.so.0.1.0.18rc1-5 - * 1.2.8rc1-5 13 10208 12.so.0.1.2.8rc1-5 - * 1.0.18 10 10018 10.so.0.1.0.18 - * 1.2.8 13 10208 12.so.0.1.2.8 - * 1.2.9beta1-3 13 10209 12.so.0.1.2.9beta1-3 - * 1.2.9beta4-11 13 10209 12.so.0.9[.0] - * 1.2.9rc1 13 10209 12.so.0.9[.0] - * 1.2.9 13 10209 12.so.0.9[.0] - * 1.2.10beta1-8 13 10210 12.so.0.10[.0] - * 1.2.10rc1-3 13 10210 12.so.0.10[.0] - * 1.2.10 13 10210 12.so.0.10[.0] - * 1.2.11beta1-4 13 10211 12.so.0.11[.0] - * 1.0.19rc1-5 10 10019 10.so.0.19[.0] - * 1.2.11rc1-5 13 10211 12.so.0.11[.0] - * 1.0.19 10 10019 10.so.0.19[.0] - * 1.2.11 13 10211 12.so.0.11[.0] - * 1.0.20 10 10020 10.so.0.20[.0] - * 1.2.12 13 10212 12.so.0.12[.0] - * 1.2.13beta1 13 10213 12.so.0.13[.0] - * 1.0.21 10 10021 10.so.0.21[.0] - * 1.2.13 13 10213 12.so.0.13[.0] - * 1.2.14beta1-2 13 10214 12.so.0.14[.0] - * 1.0.22rc1 10 10022 10.so.0.22[.0] - * 1.2.14rc1 13 10214 12.so.0.14[.0] - * 1.0.22 10 10022 10.so.0.22[.0] - * 1.2.14 13 10214 12.so.0.14[.0] - * 1.2.15beta1-6 13 10215 12.so.0.15[.0] - * 1.0.23rc1-5 10 10023 10.so.0.23[.0] - * 1.2.15rc1-5 13 10215 12.so.0.15[.0] - * 1.0.23 10 10023 10.so.0.23[.0] - * 1.2.15 13 10215 12.so.0.15[.0] - * 1.2.16beta1-2 13 10216 12.so.0.16[.0] - * 1.2.16rc1 13 10216 12.so.0.16[.0] - * 1.0.24 10 10024 10.so.0.24[.0] - * 1.2.16 13 10216 12.so.0.16[.0] - * 1.2.17beta1-2 13 10217 12.so.0.17[.0] - * 1.0.25rc1 10 10025 10.so.0.25[.0] - * 1.2.17rc1-3 13 10217 12.so.0.17[.0] - * 1.0.25 10 10025 10.so.0.25[.0] - * 1.2.17 13 10217 12.so.0.17[.0] - * 1.0.26 10 10026 10.so.0.26[.0] - * 1.2.18 13 10218 12.so.0.18[.0] - * - * Henceforth the source version will match the shared-library major - * and minor numbers; the shared-library major version number will be - * used for changes in backward compatibility, as it is intended. The - * PNG_LIBPNG_VER macro, which is not used within libpng but is available - * for applications, is an unsigned integer of the form xyyzz corresponding - * to the source version x.y.z (leading zeros in y and z). Beta versions - * were given the previous public release number plus a letter, until - * version 1.0.6j; from then on they were given the upcoming public - * release number plus "betaNN" or "rcN". - * - * Binary incompatibility exists only when applications make direct access - * to the info_ptr or png_ptr members through png.h, and the compiled - * application is loaded with a different version of the library. - * - * DLLNUM will change each time there are forward or backward changes - * in binary compatibility (e.g., when a new feature is added). - * - * See libpng.txt or libpng.3 for more information. The PNG specification - * is available as a W3C Recommendation and as an ISO Specification, - * <http://www.w3.org/TR/2003/REC-PNG-20031110/ - */ - -/* - * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE: - * - * If you modify libpng you may insert additional notices immediately following - * this sentence. - * - * libpng versions 1.2.6, August 15, 2004, through 1.2.18, May 15, 2007, are - * Copyright (c) 2004, 2006-2007 Glenn Randers-Pehrson, and are - * distributed according to the same disclaimer and license as libpng-1.2.5 - * with the following individual added to the list of Contributing Authors: - * - * Cosmin Truta - * - * libpng versions 1.0.7, July 1, 2000, through 1.2.5, October 3, 2002, are - * Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are - * distributed according to the same disclaimer and license as libpng-1.0.6 - * with the following individuals added to the list of Contributing Authors: - * - * Simon-Pierre Cadieux - * Eric S. Raymond - * Gilles Vollant - * - * and with the following additions to the disclaimer: - * - * There is no warranty against interference with your enjoyment of the - * library or against infringement. There is no warranty that our - * efforts or the library will fulfill any of your particular purposes - * or needs. This library is provided with all faults, and the entire - * risk of satisfactory quality, performance, accuracy, and effort is with - * the user. - * - * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are - * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson, and are - * distributed according to the same disclaimer and license as libpng-0.96, - * with the following individuals added to the list of Contributing Authors: - * - * Tom Lane - * Glenn Randers-Pehrson - * Willem van Schaik - * - * libpng versions 0.89, June 1996, through 0.96, May 1997, are - * Copyright (c) 1996, 1997 Andreas Dilger - * Distributed according to the same disclaimer and license as libpng-0.88, - * with the following individuals added to the list of Contributing Authors: - * - * John Bowler - * Kevin Bracey - * Sam Bushell - * Magnus Holmgren - * Greg Roelofs - * Tom Tanner - * - * libpng versions 0.5, May 1995, through 0.88, January 1996, are - * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. - * - * For the purposes of this copyright and license, "Contributing Authors" - * is defined as the following set of individuals: - * - * Andreas Dilger - * Dave Martindale - * Guy Eric Schalnat - * Paul Schmidt - * Tim Wegner - * - * The PNG Reference Library is supplied "AS IS". The Contributing Authors - * and Group 42, Inc. disclaim all warranties, expressed or implied, - * including, without limitation, the warranties of merchantability and of - * fitness for any purpose. The Contributing Authors and Group 42, Inc. - * assume no liability for direct, indirect, incidental, special, exemplary, - * or consequential damages, which may result from the use of the PNG - * Reference Library, even if advised of the possibility of such damage. - * - * Permission is hereby granted to use, copy, modify, and distribute this - * source code, or portions hereof, for any purpose, without fee, subject - * to the following restrictions: - * - * 1. The origin of this source code must not be misrepresented. - * - * 2. Altered versions must be plainly marked as such and - * must not be misrepresented as being the original source. - * - * 3. This Copyright notice may not be removed or altered from - * any source or altered source distribution. - * - * The Contributing Authors and Group 42, Inc. specifically permit, without - * fee, and encourage the use of this source code as a component to - * supporting the PNG file format in commercial products. If you use this - * source code in a product, acknowledgment is not required but would be - * appreciated. - */ - -/* - * A "png_get_copyright" function is available, for convenient use in "about" - * boxes and the like: - * - * printf("%s",png_get_copyright(NULL)); - * - * Also, the PNG logo (in PNG format, of course) is supplied in the - * files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31). - */ - -/* - * Libpng is OSI Certified Open Source Software. OSI Certified is a - * certification mark of the Open Source Initiative. - */ - -/* - * The contributing authors would like to thank all those who helped - * with testing, bug fixes, and patience. This wouldn't have been - * possible without all of you. - * - * Thanks to Frank J. T. Wojcik for helping with the documentation. - */ - -/* - * Y2K compliance in libpng: - * ========================= - * - * May 15, 2007 - * - * Since the PNG Development group is an ad-hoc body, we can't make - * an official declaration. - * - * This is your unofficial assurance that libpng from version 0.71 and - * upward through 1.2.18 are Y2K compliant. It is my belief that earlier - * versions were also Y2K compliant. - * - * Libpng only has three year fields. One is a 2-byte unsigned integer - * that will hold years up to 65535. The other two hold the date in text - * format, and will hold years up to 9999. - * - * The integer is - * "png_uint_16 year" in png_time_struct. - * - * The strings are - * "png_charp time_buffer" in png_struct and - * "near_time_buffer", which is a local character string in png.c. - * - * There are seven time-related functions: - * png.c: png_convert_to_rfc_1123() in png.c - * (formerly png_convert_to_rfc_1152() in error) - * png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c - * png_convert_from_time_t() in pngwrite.c - * png_get_tIME() in pngget.c - * png_handle_tIME() in pngrutil.c, called in pngread.c - * png_set_tIME() in pngset.c - * png_write_tIME() in pngwutil.c, called in pngwrite.c - * - * All handle dates properly in a Y2K environment. The - * png_convert_from_time_t() function calls gmtime() to convert from system - * clock time, which returns (year - 1900), which we properly convert to - * the full 4-digit year. There is a possibility that applications using - * libpng are not passing 4-digit years into the png_convert_to_rfc_1123() - * function, or that they are incorrectly passing only a 2-digit year - * instead of "year - 1900" into the png_convert_from_struct_tm() function, - * but this is not under our control. The libpng documentation has always - * stated that it works with 4-digit years, and the APIs have been - * documented as such. - * - * The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned - * integer to hold the year, and can hold years as large as 65535. - * - * zlib, upon which libpng depends, is also Y2K compliant. It contains - * no date-related code. - * - * Glenn Randers-Pehrson - * libpng maintainer - * PNG Development Group - */ - -#ifndef PNG_H -#define PNG_H - -/* This is not the place to learn how to use libpng. The file libpng.txt - * describes how to use libpng, and the file example.c summarizes it - * with some code on which to build. This file is useful for looking - * at the actual function definitions and structure components. - */ - -/* Version information for png.h - this should match the version in png.c */ -#define PNG_LIBPNG_VER_STRING "1.2.18" -#define PNG_HEADER_VERSION_STRING \ - " libpng version 1.2.18 - May 15, 2007 (header)\n" - -#define PNG_LIBPNG_VER_SONUM 0 -#define PNG_LIBPNG_VER_DLLNUM 13 - -/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ -#define PNG_LIBPNG_VER_MAJOR 1 -#define PNG_LIBPNG_VER_MINOR 2 -#define PNG_LIBPNG_VER_RELEASE 18 -/* This should match the numeric part of the final component of - * PNG_LIBPNG_VER_STRING, omitting any leading zero: */ - -#define PNG_LIBPNG_VER_BUILD 0 - -/* Release Status */ -#define PNG_LIBPNG_BUILD_ALPHA 1 -#define PNG_LIBPNG_BUILD_BETA 2 -#define PNG_LIBPNG_BUILD_RC 3 -#define PNG_LIBPNG_BUILD_STABLE 4 -#define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7 - -/* Release-Specific Flags */ -#define PNG_LIBPNG_BUILD_PATCH 8 /* Can be OR'ed with - PNG_LIBPNG_BUILD_STABLE only */ -#define PNG_LIBPNG_BUILD_PRIVATE 16 /* Cannot be OR'ed with - PNG_LIBPNG_BUILD_SPECIAL */ -#define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with - PNG_LIBPNG_BUILD_PRIVATE */ - -#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE - -/* Careful here. At one time, Guy wanted to use 082, but that would be octal. - * We must not include leading zeros. - * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only - * version 1.0.0 was mis-numbered 100 instead of 10000). From - * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release */ -#define PNG_LIBPNG_VER 10218 /* 1.2.18 */ - -#ifndef PNG_VERSION_INFO_ONLY -/* include the compression library's header */ -#include "zlib.h" -#endif - -/* include all user configurable info, including optional assembler routines */ -#include "pngconf.h" - -/* - * Added at libpng-1.2.8 */ -/* Ref MSDN: Private as priority over Special - * VS_FF_PRIVATEBUILD File *was not* built using standard release - * procedures. If this value is given, the StringFileInfo block must - * contain a PrivateBuild string. - * - * VS_FF_SPECIALBUILD File *was* built by the original company using - * standard release procedures but is a variation of the standard - * file of the same version number. If this value is given, the - * StringFileInfo block must contain a SpecialBuild string. - */ - -#if defined(PNG_USER_PRIVATEBUILD) -# define PNG_LIBPNG_BUILD_TYPE \ - (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_PRIVATE) -#else -# if defined(PNG_LIBPNG_SPECIALBUILD) -# define PNG_LIBPNG_BUILD_TYPE \ - (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_SPECIAL) -# else -# define PNG_LIBPNG_BUILD_TYPE (PNG_LIBPNG_BUILD_BASE_TYPE) -# endif -#endif - -#ifndef PNG_VERSION_INFO_ONLY - -/* Inhibit C++ name-mangling for libpng functions but not for system calls. */ -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* This file is arranged in several sections. The first section contains - * structure and type definitions. The second section contains the external - * library functions, while the third has the internal library functions, - * which applications aren't expected to use directly. - */ - -#ifndef PNG_NO_TYPECAST_NULL -#define int_p_NULL (int *)NULL -#define png_bytep_NULL (png_bytep)NULL -#define png_bytepp_NULL (png_bytepp)NULL -#define png_doublep_NULL (png_doublep)NULL -#define png_error_ptr_NULL (png_error_ptr)NULL -#define png_flush_ptr_NULL (png_flush_ptr)NULL -#define png_free_ptr_NULL (png_free_ptr)NULL -#define png_infopp_NULL (png_infopp)NULL -#define png_malloc_ptr_NULL (png_malloc_ptr)NULL -#define png_read_status_ptr_NULL (png_read_status_ptr)NULL -#define png_rw_ptr_NULL (png_rw_ptr)NULL -#define png_structp_NULL (png_structp)NULL -#define png_uint_16p_NULL (png_uint_16p)NULL -#define png_voidp_NULL (png_voidp)NULL -#define png_write_status_ptr_NULL (png_write_status_ptr)NULL -#else -#define int_p_NULL NULL -#define png_bytep_NULL NULL -#define png_bytepp_NULL NULL -#define png_doublep_NULL NULL -#define png_error_ptr_NULL NULL -#define png_flush_ptr_NULL NULL -#define png_free_ptr_NULL NULL -#define png_infopp_NULL NULL -#define png_malloc_ptr_NULL NULL -#define png_read_status_ptr_NULL NULL -#define png_rw_ptr_NULL NULL -#define png_structp_NULL NULL -#define png_uint_16p_NULL NULL -#define png_voidp_NULL NULL -#define png_write_status_ptr_NULL NULL -#endif - -/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */ -#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN) -/* Version information for C files, stored in png.c. This had better match - * the version above. - */ -#ifdef PNG_USE_GLOBAL_ARRAYS -PNG_EXPORT_VAR (const char) png_libpng_ver[18]; - /* need room for 99.99.99beta99z */ -#else -#define png_libpng_ver png_get_header_ver(NULL) -#endif - -#ifdef PNG_USE_GLOBAL_ARRAYS -/* This was removed in version 1.0.5c */ -/* Structures to facilitate easy interlacing. See png.c for more details */ -PNG_EXPORT_VAR (const int FARDATA) png_pass_start[7]; -PNG_EXPORT_VAR (const int FARDATA) png_pass_inc[7]; -PNG_EXPORT_VAR (const int FARDATA) png_pass_ystart[7]; -PNG_EXPORT_VAR (const int FARDATA) png_pass_yinc[7]; -PNG_EXPORT_VAR (const int FARDATA) png_pass_mask[7]; -PNG_EXPORT_VAR (const int FARDATA) png_pass_dsp_mask[7]; -#ifdef PNG_USE_PNGGCCRD -PNG_EXPORT_VAR (const int FARDATA) png_pass_width[7]; -#endif -/* This isn't currently used. If you need it, see png.c for more details. -PNG_EXPORT_VAR (const int FARDATA) png_pass_height[7]; -*/ -#endif - -#endif /* PNG_NO_EXTERN */ - -/* Three color definitions. The order of the red, green, and blue, (and the - * exact size) is not important, although the size of the fields need to - * be png_byte or png_uint_16 (as defined below). - */ -typedef struct png_color_struct -{ - png_byte red; - png_byte green; - png_byte blue; -} png_color; -typedef png_color FAR * png_colorp; -typedef png_color FAR * FAR * png_colorpp; - -typedef struct png_color_16_struct -{ - png_byte index; /* used for palette files */ - png_uint_16 red; /* for use in red green blue files */ - png_uint_16 green; - png_uint_16 blue; - png_uint_16 gray; /* for use in grayscale files */ -} png_color_16; -typedef png_color_16 FAR * png_color_16p; -typedef png_color_16 FAR * FAR * png_color_16pp; - -typedef struct png_color_8_struct -{ - png_byte red; /* for use in red green blue files */ - png_byte green; - png_byte blue; - png_byte gray; /* for use in grayscale files */ - png_byte alpha; /* for alpha channel files */ -} png_color_8; -typedef png_color_8 FAR * png_color_8p; -typedef png_color_8 FAR * FAR * png_color_8pp; - -/* - * The following two structures are used for the in-core representation - * of sPLT chunks. - */ -typedef struct png_sPLT_entry_struct -{ - png_uint_16 red; - png_uint_16 green; - png_uint_16 blue; - png_uint_16 alpha; - png_uint_16 frequency; -} png_sPLT_entry; -typedef png_sPLT_entry FAR * png_sPLT_entryp; -typedef png_sPLT_entry FAR * FAR * png_sPLT_entrypp; - -/* When the depth of the sPLT palette is 8 bits, the color and alpha samples - * occupy the LSB of their respective members, and the MSB of each member - * is zero-filled. The frequency member always occupies the full 16 bits. - */ - -typedef struct png_sPLT_struct -{ - png_charp name; /* palette name */ - png_byte depth; /* depth of palette samples */ - png_sPLT_entryp entries; /* palette entries */ - png_int_32 nentries; /* number of palette entries */ -} png_sPLT_t; -typedef png_sPLT_t FAR * png_sPLT_tp; -typedef png_sPLT_t FAR * FAR * png_sPLT_tpp; - -#ifdef PNG_TEXT_SUPPORTED -/* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file, - * and whether that contents is compressed or not. The "key" field - * points to a regular zero-terminated C string. The "text", "lang", and - * "lang_key" fields can be regular C strings, empty strings, or NULL pointers. - * However, the * structure returned by png_get_text() will always contain - * regular zero-terminated C strings (possibly empty), never NULL pointers, - * so they can be safely used in printf() and other string-handling functions. - */ -typedef struct png_text_struct -{ - int compression; /* compression value: - -1: tEXt, none - 0: zTXt, deflate - 1: iTXt, none - 2: iTXt, deflate */ - png_charp key; /* keyword, 1-79 character description of "text" */ - png_charp text; /* comment, may be an empty string (ie "") - or a NULL pointer */ - png_size_t text_length; /* length of the text string */ -#ifdef PNG_iTXt_SUPPORTED - png_size_t itxt_length; /* length of the itxt string */ - png_charp lang; /* language code, 0-79 characters - or a NULL pointer */ - png_charp lang_key; /* keyword translated UTF-8 string, 0 or more - chars or a NULL pointer */ -#endif -} png_text; -typedef png_text FAR * png_textp; -typedef png_text FAR * FAR * png_textpp; -#endif - -/* Supported compression types for text in PNG files (tEXt, and zTXt). - * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */ -#define PNG_TEXT_COMPRESSION_NONE_WR -3 -#define PNG_TEXT_COMPRESSION_zTXt_WR -2 -#define PNG_TEXT_COMPRESSION_NONE -1 -#define PNG_TEXT_COMPRESSION_zTXt 0 -#define PNG_ITXT_COMPRESSION_NONE 1 -#define PNG_ITXT_COMPRESSION_zTXt 2 -#define PNG_TEXT_COMPRESSION_LAST 3 /* Not a valid value */ - -/* png_time is a way to hold the time in an machine independent way. - * Two conversions are provided, both from time_t and struct tm. There - * is no portable way to convert to either of these structures, as far - * as I know. If you know of a portable way, send it to me. As a side - * note - PNG has always been Year 2000 compliant! - */ -typedef struct png_time_struct -{ - png_uint_16 year; /* full year, as in, 1995 */ - png_byte month; /* month of year, 1 - 12 */ - png_byte day; /* day of month, 1 - 31 */ - png_byte hour; /* hour of day, 0 - 23 */ - png_byte minute; /* minute of hour, 0 - 59 */ - png_byte second; /* second of minute, 0 - 60 (for leap seconds) */ -} png_time; -typedef png_time FAR * png_timep; -typedef png_time FAR * FAR * png_timepp; - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -/* png_unknown_chunk is a structure to hold queued chunks for which there is - * no specific support. The idea is that we can use this to queue - * up private chunks for output even though the library doesn't actually - * know about their semantics. - */ -typedef struct png_unknown_chunk_t -{ - png_byte name[5]; - png_byte *data; - png_size_t size; - - /* libpng-using applications should NOT directly modify this byte. */ - png_byte location; /* mode of operation at read time */ -} -png_unknown_chunk; -typedef png_unknown_chunk FAR * png_unknown_chunkp; -typedef png_unknown_chunk FAR * FAR * png_unknown_chunkpp; -#endif - -/* png_info is a structure that holds the information in a PNG file so - * that the application can find out the characteristics of the image. - * If you are reading the file, this structure will tell you what is - * in the PNG file. If you are writing the file, fill in the information - * you want to put into the PNG file, then call png_write_info(). - * The names chosen should be very close to the PNG specification, so - * consult that document for information about the meaning of each field. - * - * With libpng < 0.95, it was only possible to directly set and read the - * the values in the png_info_struct, which meant that the contents and - * order of the values had to remain fixed. With libpng 0.95 and later, - * however, there are now functions that abstract the contents of - * png_info_struct from the application, so this makes it easier to use - * libpng with dynamic libraries, and even makes it possible to use - * libraries that don't have all of the libpng ancillary chunk-handing - * functionality. - * - * In any case, the order of the parameters in png_info_struct should NOT - * be changed for as long as possible to keep compatibility with applications - * that use the old direct-access method with png_info_struct. - * - * The following members may have allocated storage attached that should be - * cleaned up before the structure is discarded: palette, trans, text, - * pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile, - * splt_palettes, scal_unit, row_pointers, and unknowns. By default, these - * are automatically freed when the info structure is deallocated, if they were - * allocated internally by libpng. This behavior can be changed by means - * of the png_data_freer() function. - * - * More allocation details: all the chunk-reading functions that - * change these members go through the corresponding png_set_* - * functions. A function to clear these members is available: see - * png_free_data(). The png_set_* functions do not depend on being - * able to point info structure members to any of the storage they are - * passed (they make their own copies), EXCEPT that the png_set_text - * functions use the same storage passed to them in the text_ptr or - * itxt_ptr structure argument, and the png_set_rows and png_set_unknowns - * functions do not make their own copies. - */ -typedef struct png_info_struct -{ - /* the following are necessary for every PNG file */ - png_uint_32 width; /* width of image in pixels (from IHDR) */ - png_uint_32 height; /* height of image in pixels (from IHDR) */ - png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */ - png_uint_32 rowbytes; /* bytes needed to hold an untransformed row */ - png_colorp palette; /* array of color values (valid & PNG_INFO_PLTE) */ - png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */ - png_uint_16 num_trans; /* number of transparent palette color (tRNS) */ - png_byte bit_depth; /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */ - png_byte color_type; /* see PNG_COLOR_TYPE_ below (from IHDR) */ - /* The following three should have been named *_method not *_type */ - png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */ - png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */ - png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ - - /* The following is informational only on read, and not used on writes. */ - png_byte channels; /* number of data channels per pixel (1, 2, 3, 4) */ - png_byte pixel_depth; /* number of bits per pixel */ - png_byte spare_byte; /* to align the data, and for future use */ - png_byte signature[8]; /* magic bytes read by libpng from start of file */ - - /* The rest of the data is optional. If you are reading, check the - * valid field to see if the information in these are valid. If you - * are writing, set the valid field to those chunks you want written, - * and initialize the appropriate fields below. - */ - -#if defined(PNG_gAMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) - /* The gAMA chunk describes the gamma characteristics of the system - * on which the image was created, normally in the range [1.0, 2.5]. - * Data is valid if (valid & PNG_INFO_gAMA) is non-zero. - */ - float gamma; /* gamma value of image, if (valid & PNG_INFO_gAMA) */ -#endif - -#if defined(PNG_sRGB_SUPPORTED) - /* GR-P, 0.96a */ - /* Data valid if (valid & PNG_INFO_sRGB) non-zero. */ - png_byte srgb_intent; /* sRGB rendering intent [0, 1, 2, or 3] */ -#endif - -#if defined(PNG_TEXT_SUPPORTED) - /* The tEXt, and zTXt chunks contain human-readable textual data in - * uncompressed, compressed, and optionally compressed forms, respectively. - * The data in "text" is an array of pointers to uncompressed, - * null-terminated C strings. Each chunk has a keyword that describes the - * textual data contained in that chunk. Keywords are not required to be - * unique, and the text string may be empty. Any number of text chunks may - * be in an image. - */ - int num_text; /* number of comments read/to write */ - int max_text; /* current size of text array */ - png_textp text; /* array of comments read/to write */ -#endif /* PNG_TEXT_SUPPORTED */ - -#if defined(PNG_tIME_SUPPORTED) - /* The tIME chunk holds the last time the displayed image data was - * modified. See the png_time struct for the contents of this struct. - */ - png_time mod_time; -#endif - -#if defined(PNG_sBIT_SUPPORTED) - /* The sBIT chunk specifies the number of significant high-order bits - * in the pixel data. Values are in the range [1, bit_depth], and are - * only specified for the channels in the pixel data. The contents of - * the low-order bits is not specified. Data is valid if - * (valid & PNG_INFO_sBIT) is non-zero. - */ - png_color_8 sig_bit; /* significant bits in color channels */ -#endif - -#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \ -defined(PNG_READ_BACKGROUND_SUPPORTED) - /* The tRNS chunk supplies transparency data for paletted images and - * other image types that don't need a full alpha channel. There are - * "num_trans" transparency values for a paletted image, stored in the - * same order as the palette colors, starting from index 0. Values - * for the data are in the range [0, 255], ranging from fully transparent - * to fully opaque, respectively. For non-paletted images, there is a - * single color specified that should be treated as fully transparent. - * Data is valid if (valid & PNG_INFO_tRNS) is non-zero. - */ - png_bytep trans; /* transparent values for paletted image */ - png_color_16 trans_values; /* transparent color for non-palette image */ -#endif - -#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - /* The bKGD chunk gives the suggested image background color if the - * display program does not have its own background color and the image - * is needs to composited onto a background before display. The colors - * in "background" are normally in the same color space/depth as the - * pixel data. Data is valid if (valid & PNG_INFO_bKGD) is non-zero. - */ - png_color_16 background; -#endif - -#if defined(PNG_oFFs_SUPPORTED) - /* The oFFs chunk gives the offset in "offset_unit_type" units rightwards - * and downwards from the top-left corner of the display, page, or other - * application-specific co-ordinate space. See the PNG_OFFSET_ defines - * below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero. - */ - png_int_32 x_offset; /* x offset on page */ - png_int_32 y_offset; /* y offset on page */ - png_byte offset_unit_type; /* offset units type */ -#endif - -#if defined(PNG_pHYs_SUPPORTED) - /* The pHYs chunk gives the physical pixel density of the image for - * display or printing in "phys_unit_type" units (see PNG_RESOLUTION_ - * defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero. - */ - png_uint_32 x_pixels_per_unit; /* horizontal pixel density */ - png_uint_32 y_pixels_per_unit; /* vertical pixel density */ - png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */ -#endif - -#if defined(PNG_hIST_SUPPORTED) - /* The hIST chunk contains the relative frequency or importance of the - * various palette entries, so that a viewer can intelligently select a - * reduced-color palette, if required. Data is an array of "num_palette" - * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST) - * is non-zero. - */ - png_uint_16p hist; -#endif - -#ifdef PNG_cHRM_SUPPORTED - /* The cHRM chunk describes the CIE color characteristics of the monitor - * on which the PNG was created. This data allows the viewer to do gamut - * mapping of the input image to ensure that the viewer sees the same - * colors in the image as the creator. Values are in the range - * [0.0, 0.8]. Data valid if (valid & PNG_INFO_cHRM) non-zero. - */ -#ifdef PNG_FLOATING_POINT_SUPPORTED - float x_white; - float y_white; - float x_red; - float y_red; - float x_green; - float y_green; - float x_blue; - float y_blue; -#endif -#endif - -#if defined(PNG_pCAL_SUPPORTED) - /* The pCAL chunk describes a transformation between the stored pixel - * values and original physical data values used to create the image. - * The integer range [0, 2^bit_depth - 1] maps to the floating-point - * range given by [pcal_X0, pcal_X1], and are further transformed by a - * (possibly non-linear) transformation function given by "pcal_type" - * and "pcal_params" into "pcal_units". Please see the PNG_EQUATION_ - * defines below, and the PNG-Group's PNG extensions document for a - * complete description of the transformations and how they should be - * implemented, and for a description of the ASCII parameter strings. - * Data values are valid if (valid & PNG_INFO_pCAL) non-zero. - */ - png_charp pcal_purpose; /* pCAL chunk description string */ - png_int_32 pcal_X0; /* minimum value */ - png_int_32 pcal_X1; /* maximum value */ - png_charp pcal_units; /* Latin-1 string giving physical units */ - png_charpp pcal_params; /* ASCII strings containing parameter values */ - png_byte pcal_type; /* equation type (see PNG_EQUATION_ below) */ - png_byte pcal_nparams; /* number of parameters given in pcal_params */ -#endif - -/* New members added in libpng-1.0.6 */ -#ifdef PNG_FREE_ME_SUPPORTED - png_uint_32 free_me; /* flags items libpng is responsible for freeing */ -#endif - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - /* storage for unknown chunks that the library doesn't recognize. */ - png_unknown_chunkp unknown_chunks; - png_size_t unknown_chunks_num; -#endif - -#if defined(PNG_iCCP_SUPPORTED) - /* iCCP chunk data. */ - png_charp iccp_name; /* profile name */ - png_charp iccp_profile; /* International Color Consortium profile data */ - /* Note to maintainer: should be png_bytep */ - png_uint_32 iccp_proflen; /* ICC profile data length */ - png_byte iccp_compression; /* Always zero */ -#endif - -#if defined(PNG_sPLT_SUPPORTED) - /* data on sPLT chunks (there may be more than one). */ - png_sPLT_tp splt_palettes; - png_uint_32 splt_palettes_num; -#endif - -#if defined(PNG_sCAL_SUPPORTED) - /* The sCAL chunk describes the actual physical dimensions of the - * subject matter of the graphic. The chunk contains a unit specification - * a byte value, and two ASCII strings representing floating-point - * values. The values are width and height corresponsing to one pixel - * in the image. This external representation is converted to double - * here. Data values are valid if (valid & PNG_INFO_sCAL) is non-zero. - */ - png_byte scal_unit; /* unit of physical scale */ -#ifdef PNG_FLOATING_POINT_SUPPORTED - double scal_pixel_width; /* width of one pixel */ - double scal_pixel_height; /* height of one pixel */ -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - png_charp scal_s_width; /* string containing height */ - png_charp scal_s_height; /* string containing width */ -#endif -#endif - -#if defined(PNG_INFO_IMAGE_SUPPORTED) - /* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS) non-zero */ - /* Data valid if (valid & PNG_INFO_IDAT) non-zero */ - png_bytepp row_pointers; /* the image bits */ -#endif - -#if defined(PNG_FIXED_POINT_SUPPORTED) && defined(PNG_gAMA_SUPPORTED) - png_fixed_point int_gamma; /* gamma of image, if (valid & PNG_INFO_gAMA) */ -#endif - -#if defined(PNG_cHRM_SUPPORTED) && defined(PNG_FIXED_POINT_SUPPORTED) - png_fixed_point int_x_white; - png_fixed_point int_y_white; - png_fixed_point int_x_red; - png_fixed_point int_y_red; - png_fixed_point int_x_green; - png_fixed_point int_y_green; - png_fixed_point int_x_blue; - png_fixed_point int_y_blue; -#endif - -} png_info; - -typedef png_info FAR * png_infop; -typedef png_info FAR * FAR * png_infopp; - -/* Maximum positive integer used in PNG is (2^31)-1 */ -#define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL) -#define PNG_UINT_32_MAX ((png_uint_32)(-1)) -#define PNG_SIZE_MAX ((png_size_t)(-1)) -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* PNG_MAX_UINT is deprecated; use PNG_UINT_31_MAX instead. */ -#define PNG_MAX_UINT PNG_UINT_31_MAX -#endif - -/* These describe the color_type field in png_info. */ -/* color type masks */ -#define PNG_COLOR_MASK_PALETTE 1 -#define PNG_COLOR_MASK_COLOR 2 -#define PNG_COLOR_MASK_ALPHA 4 - -/* color types. Note that not all combinations are legal */ -#define PNG_COLOR_TYPE_GRAY 0 -#define PNG_COLOR_TYPE_PALETTE (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE) -#define PNG_COLOR_TYPE_RGB (PNG_COLOR_MASK_COLOR) -#define PNG_COLOR_TYPE_RGB_ALPHA (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA) -#define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA) -/* aliases */ -#define PNG_COLOR_TYPE_RGBA PNG_COLOR_TYPE_RGB_ALPHA -#define PNG_COLOR_TYPE_GA PNG_COLOR_TYPE_GRAY_ALPHA - -/* This is for compression type. PNG 1.0-1.2 only define the single type. */ -#define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */ -#define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE - -/* This is for filter type. PNG 1.0-1.2 only define the single type. */ -#define PNG_FILTER_TYPE_BASE 0 /* Single row per-byte filtering */ -#define PNG_INTRAPIXEL_DIFFERENCING 64 /* Used only in MNG datastreams */ -#define PNG_FILTER_TYPE_DEFAULT PNG_FILTER_TYPE_BASE - -/* These are for the interlacing type. These values should NOT be changed. */ -#define PNG_INTERLACE_NONE 0 /* Non-interlaced image */ -#define PNG_INTERLACE_ADAM7 1 /* Adam7 interlacing */ -#define PNG_INTERLACE_LAST 2 /* Not a valid value */ - -/* These are for the oFFs chunk. These values should NOT be changed. */ -#define PNG_OFFSET_PIXEL 0 /* Offset in pixels */ -#define PNG_OFFSET_MICROMETER 1 /* Offset in micrometers (1/10^6 meter) */ -#define PNG_OFFSET_LAST 2 /* Not a valid value */ - -/* These are for the pCAL chunk. These values should NOT be changed. */ -#define PNG_EQUATION_LINEAR 0 /* Linear transformation */ -#define PNG_EQUATION_BASE_E 1 /* Exponential base e transform */ -#define PNG_EQUATION_ARBITRARY 2 /* Arbitrary base exponential transform */ -#define PNG_EQUATION_HYPERBOLIC 3 /* Hyperbolic sine transformation */ -#define PNG_EQUATION_LAST 4 /* Not a valid value */ - -/* These are for the sCAL chunk. These values should NOT be changed. */ -#define PNG_SCALE_UNKNOWN 0 /* unknown unit (image scale) */ -#define PNG_SCALE_METER 1 /* meters per pixel */ -#define PNG_SCALE_RADIAN 2 /* radians per pixel */ -#define PNG_SCALE_LAST 3 /* Not a valid value */ - -/* These are for the pHYs chunk. These values should NOT be changed. */ -#define PNG_RESOLUTION_UNKNOWN 0 /* pixels/unknown unit (aspect ratio) */ -#define PNG_RESOLUTION_METER 1 /* pixels/meter */ -#define PNG_RESOLUTION_LAST 2 /* Not a valid value */ - -/* These are for the sRGB chunk. These values should NOT be changed. */ -#define PNG_sRGB_INTENT_PERCEPTUAL 0 -#define PNG_sRGB_INTENT_RELATIVE 1 -#define PNG_sRGB_INTENT_SATURATION 2 -#define PNG_sRGB_INTENT_ABSOLUTE 3 -#define PNG_sRGB_INTENT_LAST 4 /* Not a valid value */ - -/* This is for text chunks */ -#define PNG_KEYWORD_MAX_LENGTH 79 - -/* Maximum number of entries in PLTE/sPLT/tRNS arrays */ -#define PNG_MAX_PALETTE_LENGTH 256 - -/* These determine if an ancillary chunk's data has been successfully read - * from the PNG header, or if the application has filled in the corresponding - * data in the info_struct to be written into the output file. The values - * of the PNG_INFO_<chunk> defines should NOT be changed. - */ -#define PNG_INFO_gAMA 0x0001 -#define PNG_INFO_sBIT 0x0002 -#define PNG_INFO_cHRM 0x0004 -#define PNG_INFO_PLTE 0x0008 -#define PNG_INFO_tRNS 0x0010 -#define PNG_INFO_bKGD 0x0020 -#define PNG_INFO_hIST 0x0040 -#define PNG_INFO_pHYs 0x0080 -#define PNG_INFO_oFFs 0x0100 -#define PNG_INFO_tIME 0x0200 -#define PNG_INFO_pCAL 0x0400 -#define PNG_INFO_sRGB 0x0800 /* GR-P, 0.96a */ -#define PNG_INFO_iCCP 0x1000 /* ESR, 1.0.6 */ -#define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */ -#define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */ -#define PNG_INFO_IDAT 0x8000L /* ESR, 1.0.6 */ - -/* This is used for the transformation routines, as some of them - * change these values for the row. It also should enable using - * the routines for other purposes. - */ -typedef struct png_row_info_struct -{ - png_uint_32 width; /* width of row */ - png_uint_32 rowbytes; /* number of bytes in row */ - png_byte color_type; /* color type of row */ - png_byte bit_depth; /* bit depth of row */ - png_byte channels; /* number of channels (1, 2, 3, or 4) */ - png_byte pixel_depth; /* bits per pixel (depth * channels) */ -} png_row_info; - -typedef png_row_info FAR * png_row_infop; -typedef png_row_info FAR * FAR * png_row_infopp; - -/* These are the function types for the I/O functions and for the functions - * that allow the user to override the default I/O functions with his or her - * own. The png_error_ptr type should match that of user-supplied warning - * and error functions, while the png_rw_ptr type should match that of the - * user read/write data functions. - */ -typedef struct png_struct_def png_struct; -typedef png_struct FAR * png_structp; - -typedef void (PNGAPI *png_error_ptr) PNGARG((png_structp, png_const_charp)); -typedef void (PNGAPI *png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t)); -typedef void (PNGAPI *png_flush_ptr) PNGARG((png_structp)); -typedef void (PNGAPI *png_read_status_ptr) PNGARG((png_structp, png_uint_32, - int)); -typedef void (PNGAPI *png_write_status_ptr) PNGARG((png_structp, png_uint_32, - int)); - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -typedef void (PNGAPI *png_progressive_info_ptr) PNGARG((png_structp, png_infop)); -typedef void (PNGAPI *png_progressive_end_ptr) PNGARG((png_structp, png_infop)); -typedef void (PNGAPI *png_progressive_row_ptr) PNGARG((png_structp, png_bytep, - png_uint_32, int)); -#endif - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -typedef void (PNGAPI *png_user_transform_ptr) PNGARG((png_structp, - png_row_infop, png_bytep)); -#endif - -#if defined(PNG_USER_CHUNKS_SUPPORTED) -typedef int (PNGAPI *png_user_chunk_ptr) PNGARG((png_structp, png_unknown_chunkp)); -#endif -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -typedef void (PNGAPI *png_unknown_chunk_ptr) PNGARG((png_structp)); -#endif - -/* Transform masks for the high-level interface */ -#define PNG_TRANSFORM_IDENTITY 0x0000 /* read and write */ -#define PNG_TRANSFORM_STRIP_16 0x0001 /* read only */ -#define PNG_TRANSFORM_STRIP_ALPHA 0x0002 /* read only */ -#define PNG_TRANSFORM_PACKING 0x0004 /* read and write */ -#define PNG_TRANSFORM_PACKSWAP 0x0008 /* read and write */ -#define PNG_TRANSFORM_EXPAND 0x0010 /* read only */ -#define PNG_TRANSFORM_INVERT_MONO 0x0020 /* read and write */ -#define PNG_TRANSFORM_SHIFT 0x0040 /* read and write */ -#define PNG_TRANSFORM_BGR 0x0080 /* read and write */ -#define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */ -#define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */ -#define PNG_TRANSFORM_INVERT_ALPHA 0x0400 /* read and write */ -#define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* WRITE only */ - -/* Flags for MNG supported features */ -#define PNG_FLAG_MNG_EMPTY_PLTE 0x01 -#define PNG_FLAG_MNG_FILTER_64 0x04 -#define PNG_ALL_MNG_FEATURES 0x05 - -typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_size_t)); -typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp)); - -/* The structure that holds the information to read and write PNG files. - * The only people who need to care about what is inside of this are the - * people who will be modifying the library for their own special needs. - * It should NOT be accessed directly by an application, except to store - * the jmp_buf. - */ - -struct png_struct_def -{ -#ifdef PNG_SETJMP_SUPPORTED - jmp_buf jmpbuf; /* used in png_error */ -#endif - png_error_ptr error_fn; /* function for printing errors and aborting */ - png_error_ptr warning_fn; /* function for printing warnings */ - png_voidp error_ptr; /* user supplied struct for error functions */ - png_rw_ptr write_data_fn; /* function for writing output data */ - png_rw_ptr read_data_fn; /* function for reading input data */ - png_voidp io_ptr; /* ptr to application struct for I/O functions */ - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - png_user_transform_ptr read_user_transform_fn; /* user read transform */ -#endif - -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) - png_user_transform_ptr write_user_transform_fn; /* user write transform */ -#endif - -/* These were added in libpng-1.0.2 */ -#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) - png_voidp user_transform_ptr; /* user supplied struct for user transform */ - png_byte user_transform_depth; /* bit depth of user transformed pixels */ - png_byte user_transform_channels; /* channels in user transformed pixels */ -#endif -#endif - - png_uint_32 mode; /* tells us where we are in the PNG file */ - png_uint_32 flags; /* flags indicating various things to libpng */ - png_uint_32 transformations; /* which transformations to perform */ - - z_stream zstream; /* pointer to decompression structure (below) */ - png_bytep zbuf; /* buffer for zlib */ - png_size_t zbuf_size; /* size of zbuf */ - int zlib_level; /* holds zlib compression level */ - int zlib_method; /* holds zlib compression method */ - int zlib_window_bits; /* holds zlib compression window bits */ - int zlib_mem_level; /* holds zlib compression memory level */ - int zlib_strategy; /* holds zlib compression strategy */ - - png_uint_32 width; /* width of image in pixels */ - png_uint_32 height; /* height of image in pixels */ - png_uint_32 num_rows; /* number of rows in current pass */ - png_uint_32 usr_width; /* width of row at start of write */ - png_uint_32 rowbytes; /* size of row in bytes */ - png_uint_32 irowbytes; /* size of current interlaced row in bytes */ - png_uint_32 iwidth; /* width of current interlaced row in pixels */ - png_uint_32 row_number; /* current row in interlace pass */ - png_bytep prev_row; /* buffer to save previous (unfiltered) row */ - png_bytep row_buf; /* buffer to save current (unfiltered) row */ - png_bytep sub_row; /* buffer to save "sub" row when filtering */ - png_bytep up_row; /* buffer to save "up" row when filtering */ - png_bytep avg_row; /* buffer to save "avg" row when filtering */ - png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */ - png_row_info row_info; /* used for transformation routines */ - - png_uint_32 idat_size; /* current IDAT size for read */ - png_uint_32 crc; /* current chunk CRC value */ - png_colorp palette; /* palette from the input file */ - png_uint_16 num_palette; /* number of color entries in palette */ - png_uint_16 num_trans; /* number of transparency values */ - png_byte chunk_name[5]; /* null-terminated name of current chunk */ - png_byte compression; /* file compression type (always 0) */ - png_byte filter; /* file filter type (always 0) */ - png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ - png_byte pass; /* current interlace pass (0 - 6) */ - png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */ - png_byte color_type; /* color type of file */ - png_byte bit_depth; /* bit depth of file */ - png_byte usr_bit_depth; /* bit depth of users row */ - png_byte pixel_depth; /* number of bits per pixel */ - png_byte channels; /* number of channels in file */ - png_byte usr_channels; /* channels at start of write */ - png_byte sig_bytes; /* magic bytes read/written from start of file */ - -#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) -#ifdef PNG_LEGACY_SUPPORTED - png_byte filler; /* filler byte for pixel expansion */ -#else - png_uint_16 filler; /* filler bytes for pixel expansion */ -#endif -#endif - -#if defined(PNG_bKGD_SUPPORTED) - png_byte background_gamma_type; -# ifdef PNG_FLOATING_POINT_SUPPORTED - float background_gamma; -# endif - png_color_16 background; /* background color in screen gamma space */ -#if defined(PNG_READ_GAMMA_SUPPORTED) - png_color_16 background_1; /* background normalized to gamma 1.0 */ -#endif -#endif /* PNG_bKGD_SUPPORTED */ - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) - png_flush_ptr output_flush_fn;/* Function for flushing output */ - png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */ - png_uint_32 flush_rows; /* number of rows written since last flush */ -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - int gamma_shift; /* number of "insignificant" bits 16-bit gamma */ -#ifdef PNG_FLOATING_POINT_SUPPORTED - float gamma; /* file gamma value */ - float screen_gamma; /* screen gamma value (display_exponent) */ -#endif -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - png_bytep gamma_table; /* gamma table for 8-bit depth files */ - png_bytep gamma_from_1; /* converts from 1.0 to screen */ - png_bytep gamma_to_1; /* converts from file to 1.0 */ - png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */ - png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */ - png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */ -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED) - png_color_8 sig_bit; /* significant bits in each available channel */ -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) - png_color_8 shift; /* shift for significant bit tranformation */ -#endif - -#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \ - || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - png_bytep trans; /* transparency values for paletted files */ - png_color_16 trans_values; /* transparency values for non-paletted files */ -#endif - - png_read_status_ptr read_row_fn; /* called after each row is decoded */ - png_write_status_ptr write_row_fn; /* called after each row is encoded */ -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED - png_progressive_info_ptr info_fn; /* called after header data fully read */ - png_progressive_row_ptr row_fn; /* called after each prog. row is decoded */ - png_progressive_end_ptr end_fn; /* called after image is complete */ - png_bytep save_buffer_ptr; /* current location in save_buffer */ - png_bytep save_buffer; /* buffer for previously read data */ - png_bytep current_buffer_ptr; /* current location in current_buffer */ - png_bytep current_buffer; /* buffer for recently used data */ - png_uint_32 push_length; /* size of current input chunk */ - png_uint_32 skip_length; /* bytes to skip in input data */ - png_size_t save_buffer_size; /* amount of data now in save_buffer */ - png_size_t save_buffer_max; /* total size of save_buffer */ - png_size_t buffer_size; /* total amount of available input data */ - png_size_t current_buffer_size; /* amount of data now in current_buffer */ - int process_mode; /* what push library is currently doing */ - int cur_palette; /* current push library palette index */ - -# if defined(PNG_TEXT_SUPPORTED) - png_size_t current_text_size; /* current size of text input data */ - png_size_t current_text_left; /* how much text left to read in input */ - png_charp current_text; /* current text chunk buffer */ - png_charp current_text_ptr; /* current location in current_text */ -# endif /* PNG_PROGRESSIVE_READ_SUPPORTED && PNG_TEXT_SUPPORTED */ - -#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ - -#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) -/* for the Borland special 64K segment handler */ - png_bytepp offset_table_ptr; - png_bytep offset_table; - png_uint_16 offset_table_number; - png_uint_16 offset_table_count; - png_uint_16 offset_table_count_free; -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) - png_bytep palette_lookup; /* lookup table for dithering */ - png_bytep dither_index; /* index translation for palette files */ -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) || defined(PNG_hIST_SUPPORTED) - png_uint_16p hist; /* histogram */ -#endif - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - png_byte heuristic_method; /* heuristic for row filter selection */ - png_byte num_prev_filters; /* number of weights for previous rows */ - png_bytep prev_filters; /* filter type(s) of previous row(s) */ - png_uint_16p filter_weights; /* weight(s) for previous line(s) */ - png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */ - png_uint_16p filter_costs; /* relative filter calculation cost */ - png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */ -#endif - -#if defined(PNG_TIME_RFC1123_SUPPORTED) - png_charp time_buffer; /* String to hold RFC 1123 time text */ -#endif - -/* New members added in libpng-1.0.6 */ - -#ifdef PNG_FREE_ME_SUPPORTED - png_uint_32 free_me; /* flags items libpng is responsible for freeing */ -#endif - -#if defined(PNG_USER_CHUNKS_SUPPORTED) - png_voidp user_chunk_ptr; - png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */ -#endif - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - int num_chunk_list; - png_bytep chunk_list; -#endif - -/* New members added in libpng-1.0.3 */ -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - png_byte rgb_to_gray_status; - /* These were changed from png_byte in libpng-1.0.6 */ - png_uint_16 rgb_to_gray_red_coeff; - png_uint_16 rgb_to_gray_green_coeff; - png_uint_16 rgb_to_gray_blue_coeff; -#endif - -/* New member added in libpng-1.0.4 (renamed in 1.0.9) */ -#if defined(PNG_MNG_FEATURES_SUPPORTED) || \ - defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ - defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) -/* changed from png_byte to png_uint_32 at version 1.2.0 */ -#ifdef PNG_1_0_X - png_byte mng_features_permitted; -#else - png_uint_32 mng_features_permitted; -#endif /* PNG_1_0_X */ -#endif - -/* New member added in libpng-1.0.7 */ -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - png_fixed_point int_gamma; -#endif - -/* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */ -#if defined(PNG_MNG_FEATURES_SUPPORTED) - png_byte filter_type; -#endif - -#if defined(PNG_1_0_X) || (defined(PNG_DEBUG) && defined(PNG_USE_PNGGCCRD)) -/* New member added in libpng-1.0.10, ifdef'ed out in 1.2.0 */ - png_uint_32 row_buf_size; -#endif - -/* New members added in libpng-1.2.0 */ -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) -# if !defined(PNG_1_0_X) -# if defined(PNG_MMX_CODE_SUPPORTED) - png_byte mmx_bitdepth_threshold; - png_uint_32 mmx_rowbytes_threshold; -# endif - png_uint_32 asm_flags; -# endif -#endif - -/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */ -#ifdef PNG_USER_MEM_SUPPORTED - png_voidp mem_ptr; /* user supplied struct for mem functions */ - png_malloc_ptr malloc_fn; /* function for allocating memory */ - png_free_ptr free_fn; /* function for freeing memory */ -#endif - -/* New member added in libpng-1.0.13 and 1.2.0 */ - png_bytep big_row_buf; /* buffer to save current (unfiltered) row */ - -#if defined(PNG_READ_DITHER_SUPPORTED) -/* The following three members were added at version 1.0.14 and 1.2.4 */ - png_bytep dither_sort; /* working sort array */ - png_bytep index_to_palette; /* where the original index currently is */ - /* in the palette */ - png_bytep palette_to_index; /* which original index points to this */ - /* palette color */ -#endif - -/* New members added in libpng-1.0.16 and 1.2.6 */ - png_byte compression_type; - -#ifdef PNG_SET_USER_LIMITS_SUPPORTED - png_uint_32 user_width_max; - png_uint_32 user_height_max; -#endif - -/* New member added in libpng-1.0.25 and 1.2.17 */ -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - /* storage for unknown chunk that the library doesn't recognize. */ - png_unknown_chunk unknown_chunk; -#endif -}; - - -/* This triggers a compiler error in png.c, if png.c and png.h - * do not agree upon the version number. - */ -typedef png_structp version_1_2_18; - -typedef png_struct FAR * FAR * png_structpp; - -/* Here are the function definitions most commonly used. This is not - * the place to find out how to use libpng. See libpng.txt for the - * full explanation, see example.c for the summary. This just provides - * a simple one line description of the use of each function. - */ - -/* Returns the version number of the library */ -extern PNG_EXPORT(png_uint_32,png_access_version_number) PNGARG((void)); - -/* Tell lib we have already handled the first <num_bytes> magic bytes. - * Handling more than 8 bytes from the beginning of the file is an error. - */ -extern PNG_EXPORT(void,png_set_sig_bytes) PNGARG((png_structp png_ptr, - int num_bytes)); - -/* Check sig[start] through sig[start + num_to_check - 1] to see if it's a - * PNG file. Returns zero if the supplied bytes match the 8-byte PNG - * signature, and non-zero otherwise. Having num_to_check == 0 or - * start > 7 will always fail (ie return non-zero). - */ -extern PNG_EXPORT(int,png_sig_cmp) PNGARG((png_bytep sig, png_size_t start, - png_size_t num_to_check)); - -/* Simple signature checking function. This is the same as calling - * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n). - */ -extern PNG_EXPORT(int,png_check_sig) PNGARG((png_bytep sig, int num)); - -/* Allocate and initialize png_ptr struct for reading, and any other memory. */ -extern PNG_EXPORT(png_structp,png_create_read_struct) - PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn)); - -/* Allocate and initialize png_ptr struct for writing, and any other memory */ -extern PNG_EXPORT(png_structp,png_create_write_struct) - PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn)); - -#ifdef PNG_WRITE_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_compression_buffer_size) - PNGARG((png_structp png_ptr)); -#endif - -#ifdef PNG_WRITE_SUPPORTED -extern PNG_EXPORT(void,png_set_compression_buffer_size) - PNGARG((png_structp png_ptr, png_uint_32 size)); -#endif - -/* Reset the compression stream */ -extern PNG_EXPORT(int,png_reset_zstream) PNGARG((png_structp png_ptr)); - -/* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */ -#ifdef PNG_USER_MEM_SUPPORTED -extern PNG_EXPORT(png_structp,png_create_read_struct_2) - PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn)); -extern PNG_EXPORT(png_structp,png_create_write_struct_2) - PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn)); -#endif - -/* Write a PNG chunk - size, type, (optional) data, CRC. */ -extern PNG_EXPORT(void,png_write_chunk) PNGARG((png_structp png_ptr, - png_bytep chunk_name, png_bytep data, png_size_t length)); - -/* Write the start of a PNG chunk - length and chunk name. */ -extern PNG_EXPORT(void,png_write_chunk_start) PNGARG((png_structp png_ptr, - png_bytep chunk_name, png_uint_32 length)); - -/* Write the data of a PNG chunk started with png_write_chunk_start(). */ -extern PNG_EXPORT(void,png_write_chunk_data) PNGARG((png_structp png_ptr, - png_bytep data, png_size_t length)); - -/* Finish a chunk started with png_write_chunk_start() (includes CRC). */ -extern PNG_EXPORT(void,png_write_chunk_end) PNGARG((png_structp png_ptr)); - -/* Allocate and initialize the info structure */ -extern PNG_EXPORT(png_infop,png_create_info_struct) - PNGARG((png_structp png_ptr)); - -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* Initialize the info structure (old interface - DEPRECATED) */ -extern PNG_EXPORT(void,png_info_init) PNGARG((png_infop info_ptr)); -#undef png_info_init -#define png_info_init(info_ptr) png_info_init_3(&info_ptr,\ - png_sizeof(png_info)); -#endif - -extern PNG_EXPORT(void,png_info_init_3) PNGARG((png_infopp info_ptr, - png_size_t png_info_struct_size)); - -/* Writes all the PNG information before the image. */ -extern PNG_EXPORT(void,png_write_info_before_PLTE) PNGARG((png_structp png_ptr, - png_infop info_ptr)); -extern PNG_EXPORT(void,png_write_info) PNGARG((png_structp png_ptr, - png_infop info_ptr)); - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* read the information before the actual image data. */ -extern PNG_EXPORT(void,png_read_info) PNGARG((png_structp png_ptr, - png_infop info_ptr)); -#endif - -#if defined(PNG_TIME_RFC1123_SUPPORTED) -extern PNG_EXPORT(png_charp,png_convert_to_rfc1123) - PNGARG((png_structp png_ptr, png_timep ptime)); -#endif - -#if !defined(_WIN32_WCE) -/* "time.h" functions are not supported on WindowsCE */ -#if defined(PNG_WRITE_tIME_SUPPORTED) -/* convert from a struct tm to png_time */ -extern PNG_EXPORT(void,png_convert_from_struct_tm) PNGARG((png_timep ptime, - struct tm FAR * ttime)); - -/* convert from time_t to png_time. Uses gmtime() */ -extern PNG_EXPORT(void,png_convert_from_time_t) PNGARG((png_timep ptime, - time_t ttime)); -#endif /* PNG_WRITE_tIME_SUPPORTED */ -#endif /* _WIN32_WCE */ - -#if defined(PNG_READ_EXPAND_SUPPORTED) -/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */ -extern PNG_EXPORT(void,png_set_expand) PNGARG((png_structp png_ptr)); -#if !defined(PNG_1_0_X) -extern PNG_EXPORT(void,png_set_expand_gray_1_2_4_to_8) PNGARG((png_structp - png_ptr)); -#endif -extern PNG_EXPORT(void,png_set_palette_to_rgb) PNGARG((png_structp png_ptr)); -extern PNG_EXPORT(void,png_set_tRNS_to_alpha) PNGARG((png_structp png_ptr)); -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* Deprecated */ -extern PNG_EXPORT(void,png_set_gray_1_2_4_to_8) PNGARG((png_structp png_ptr)); -#endif -#endif - -#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -/* Use blue, green, red order for pixels. */ -extern PNG_EXPORT(void,png_set_bgr) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) -/* Expand the grayscale to 24-bit RGB if necessary. */ -extern PNG_EXPORT(void,png_set_gray_to_rgb) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) -/* Reduce RGB to grayscale. */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_rgb_to_gray) PNGARG((png_structp png_ptr, - int error_action, double red, double green )); -#endif -extern PNG_EXPORT(void,png_set_rgb_to_gray_fixed) PNGARG((png_structp png_ptr, - int error_action, png_fixed_point red, png_fixed_point green )); -extern PNG_EXPORT(png_byte,png_get_rgb_to_gray_status) PNGARG((png_structp - png_ptr)); -#endif - -extern PNG_EXPORT(void,png_build_grayscale_palette) PNGARG((int bit_depth, - png_colorp palette)); - -#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) -extern PNG_EXPORT(void,png_set_strip_alpha) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ - defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) -extern PNG_EXPORT(void,png_set_swap_alpha) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ - defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) -extern PNG_EXPORT(void,png_set_invert_alpha) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) -/* Add a filler byte to 8-bit Gray or 24-bit RGB images. */ -extern PNG_EXPORT(void,png_set_filler) PNGARG((png_structp png_ptr, - png_uint_32 filler, int flags)); -/* The values of the PNG_FILLER_ defines should NOT be changed */ -#define PNG_FILLER_BEFORE 0 -#define PNG_FILLER_AFTER 1 -/* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */ -#if !defined(PNG_1_0_X) -extern PNG_EXPORT(void,png_set_add_alpha) PNGARG((png_structp png_ptr, - png_uint_32 filler, int flags)); -#endif -#endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */ - -#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) -/* Swap bytes in 16-bit depth files. */ -extern PNG_EXPORT(void,png_set_swap) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) -/* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */ -extern PNG_EXPORT(void,png_set_packing) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED) -/* Swap packing order of pixels in bytes. */ -extern PNG_EXPORT(void,png_set_packswap) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) -/* Converts files to legal bit depths. */ -extern PNG_EXPORT(void,png_set_shift) PNGARG((png_structp png_ptr, - png_color_8p true_bits)); -#endif - -#if defined(PNG_READ_INTERLACING_SUPPORTED) || \ - defined(PNG_WRITE_INTERLACING_SUPPORTED) -/* Have the code handle the interlacing. Returns the number of passes. */ -extern PNG_EXPORT(int,png_set_interlace_handling) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) -/* Invert monochrome files */ -extern PNG_EXPORT(void,png_set_invert_mono) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) -/* Handle alpha and tRNS by replacing with a background color. */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_background) PNGARG((png_structp png_ptr, - png_color_16p background_color, int background_gamma_code, - int need_expand, double background_gamma)); -#endif -#define PNG_BACKGROUND_GAMMA_UNKNOWN 0 -#define PNG_BACKGROUND_GAMMA_SCREEN 1 -#define PNG_BACKGROUND_GAMMA_FILE 2 -#define PNG_BACKGROUND_GAMMA_UNIQUE 3 -#endif - -#if defined(PNG_READ_16_TO_8_SUPPORTED) -/* strip the second byte of information from a 16-bit depth file. */ -extern PNG_EXPORT(void,png_set_strip_16) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) -/* Turn on dithering, and reduce the palette to the number of colors available. */ -extern PNG_EXPORT(void,png_set_dither) PNGARG((png_structp png_ptr, - png_colorp palette, int num_palette, int maximum_colors, - png_uint_16p histogram, int full_dither)); -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) -/* Handle gamma correction. Screen_gamma=(display_exponent) */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_gamma) PNGARG((png_structp png_ptr, - double screen_gamma, double default_file_gamma)); -#endif -#endif - -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ - defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) -/* Permit or disallow empty PLTE (0: not permitted, 1: permitted) */ -/* Deprecated and will be removed. Use png_permit_mng_features() instead. */ -extern PNG_EXPORT(void,png_permit_empty_plte) PNGARG((png_structp png_ptr, - int empty_plte_permitted)); -#endif -#endif - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -/* Set how many lines between output flushes - 0 for no flushing */ -extern PNG_EXPORT(void,png_set_flush) PNGARG((png_structp png_ptr, int nrows)); -/* Flush the current PNG output buffer */ -extern PNG_EXPORT(void,png_write_flush) PNGARG((png_structp png_ptr)); -#endif - -/* optional update palette with requested transformations */ -extern PNG_EXPORT(void,png_start_read_image) PNGARG((png_structp png_ptr)); - -/* optional call to update the users info structure */ -extern PNG_EXPORT(void,png_read_update_info) PNGARG((png_structp png_ptr, - png_infop info_ptr)); - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* read one or more rows of image data. */ -extern PNG_EXPORT(void,png_read_rows) PNGARG((png_structp png_ptr, - png_bytepp row, png_bytepp display_row, png_uint_32 num_rows)); -#endif - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* read a row of data. */ -extern PNG_EXPORT(void,png_read_row) PNGARG((png_structp png_ptr, - png_bytep row, - png_bytep display_row)); -#endif - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* read the whole image into memory at once. */ -extern PNG_EXPORT(void,png_read_image) PNGARG((png_structp png_ptr, - png_bytepp image)); -#endif - -/* write a row of image data */ -extern PNG_EXPORT(void,png_write_row) PNGARG((png_structp png_ptr, - png_bytep row)); - -/* write a few rows of image data */ -extern PNG_EXPORT(void,png_write_rows) PNGARG((png_structp png_ptr, - png_bytepp row, png_uint_32 num_rows)); - -/* write the image data */ -extern PNG_EXPORT(void,png_write_image) PNGARG((png_structp png_ptr, - png_bytepp image)); - -/* writes the end of the PNG file. */ -extern PNG_EXPORT(void,png_write_end) PNGARG((png_structp png_ptr, - png_infop info_ptr)); - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* read the end of the PNG file. */ -extern PNG_EXPORT(void,png_read_end) PNGARG((png_structp png_ptr, - png_infop info_ptr)); -#endif - -/* free any memory associated with the png_info_struct */ -extern PNG_EXPORT(void,png_destroy_info_struct) PNGARG((png_structp png_ptr, - png_infopp info_ptr_ptr)); - -/* free any memory associated with the png_struct and the png_info_structs */ -extern PNG_EXPORT(void,png_destroy_read_struct) PNGARG((png_structpp - png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)); - -/* free all memory used by the read (old method - NOT DLL EXPORTED) */ -extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr, - png_infop end_info_ptr)); - -/* free any memory associated with the png_struct and the png_info_structs */ -extern PNG_EXPORT(void,png_destroy_write_struct) - PNGARG((png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)); - -/* free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */ -extern void png_write_destroy PNGARG((png_structp png_ptr)); - -/* set the libpng method of handling chunk CRC errors */ -extern PNG_EXPORT(void,png_set_crc_action) PNGARG((png_structp png_ptr, - int crit_action, int ancil_action)); - -/* Values for png_set_crc_action() to say how to handle CRC errors in - * ancillary and critical chunks, and whether to use the data contained - * therein. Note that it is impossible to "discard" data in a critical - * chunk. For versions prior to 0.90, the action was always error/quit, - * whereas in version 0.90 and later, the action for CRC errors in ancillary - * chunks is warn/discard. These values should NOT be changed. - * - * value action:critical action:ancillary - */ -#define PNG_CRC_DEFAULT 0 /* error/quit warn/discard data */ -#define PNG_CRC_ERROR_QUIT 1 /* error/quit error/quit */ -#define PNG_CRC_WARN_DISCARD 2 /* (INVALID) warn/discard data */ -#define PNG_CRC_WARN_USE 3 /* warn/use data warn/use data */ -#define PNG_CRC_QUIET_USE 4 /* quiet/use data quiet/use data */ -#define PNG_CRC_NO_CHANGE 5 /* use current value use current value */ - -/* These functions give the user control over the scan-line filtering in - * libpng and the compression methods used by zlib. These functions are - * mainly useful for testing, as the defaults should work with most users. - * Those users who are tight on memory or want faster performance at the - * expense of compression can modify them. See the compression library - * header file (zlib.h) for an explination of the compression functions. - */ - -/* set the filtering method(s) used by libpng. Currently, the only valid - * value for "method" is 0. - */ -extern PNG_EXPORT(void,png_set_filter) PNGARG((png_structp png_ptr, int method, - int filters)); - -/* Flags for png_set_filter() to say which filters to use. The flags - * are chosen so that they don't conflict with real filter types - * below, in case they are supplied instead of the #defined constants. - * These values should NOT be changed. - */ -#define PNG_NO_FILTERS 0x00 -#define PNG_FILTER_NONE 0x08 -#define PNG_FILTER_SUB 0x10 -#define PNG_FILTER_UP 0x20 -#define PNG_FILTER_AVG 0x40 -#define PNG_FILTER_PAETH 0x80 -#define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \ - PNG_FILTER_AVG | PNG_FILTER_PAETH) - -/* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now. - * These defines should NOT be changed. - */ -#define PNG_FILTER_VALUE_NONE 0 -#define PNG_FILTER_VALUE_SUB 1 -#define PNG_FILTER_VALUE_UP 2 -#define PNG_FILTER_VALUE_AVG 3 -#define PNG_FILTER_VALUE_PAETH 4 -#define PNG_FILTER_VALUE_LAST 5 - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* EXPERIMENTAL */ -/* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_ - * defines, either the default (minimum-sum-of-absolute-differences), or - * the experimental method (weighted-minimum-sum-of-absolute-differences). - * - * Weights are factors >= 1.0, indicating how important it is to keep the - * filter type consistent between rows. Larger numbers mean the current - * filter is that many times as likely to be the same as the "num_weights" - * previous filters. This is cumulative for each previous row with a weight. - * There needs to be "num_weights" values in "filter_weights", or it can be - * NULL if the weights aren't being specified. Weights have no influence on - * the selection of the first row filter. Well chosen weights can (in theory) - * improve the compression for a given image. - * - * Costs are factors >= 1.0 indicating the relative decoding costs of a - * filter type. Higher costs indicate more decoding expense, and are - * therefore less likely to be selected over a filter with lower computational - * costs. There needs to be a value in "filter_costs" for each valid filter - * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't - * setting the costs. Costs try to improve the speed of decompression without - * unduly increasing the compressed image size. - * - * A negative weight or cost indicates the default value is to be used, and - * values in the range [0.0, 1.0) indicate the value is to remain unchanged. - * The default values for both weights and costs are currently 1.0, but may - * change if good general weighting/cost heuristics can be found. If both - * the weights and costs are set to 1.0, this degenerates the WEIGHTED method - * to the UNWEIGHTED method, but with added encoding time/computation. - */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_filter_heuristics) PNGARG((png_structp png_ptr, - int heuristic_method, int num_weights, png_doublep filter_weights, - png_doublep filter_costs)); -#endif -#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */ - -/* Heuristic used for row filter selection. These defines should NOT be - * changed. - */ -#define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */ -#define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */ -#define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */ -#define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */ - -/* Set the library compression level. Currently, valid values range from - * 0 - 9, corresponding directly to the zlib compression levels 0 - 9 - * (0 - no compression, 9 - "maximal" compression). Note that tests have - * shown that zlib compression levels 3-6 usually perform as well as level 9 - * for PNG images, and do considerably fewer caclulations. In the future, - * these values may not correspond directly to the zlib compression levels. - */ -extern PNG_EXPORT(void,png_set_compression_level) PNGARG((png_structp png_ptr, - int level)); - -extern PNG_EXPORT(void,png_set_compression_mem_level) - PNGARG((png_structp png_ptr, int mem_level)); - -extern PNG_EXPORT(void,png_set_compression_strategy) - PNGARG((png_structp png_ptr, int strategy)); - -extern PNG_EXPORT(void,png_set_compression_window_bits) - PNGARG((png_structp png_ptr, int window_bits)); - -extern PNG_EXPORT(void,png_set_compression_method) PNGARG((png_structp png_ptr, - int method)); - -/* These next functions are called for input/output, memory, and error - * handling. They are in the file pngrio.c, pngwio.c, and pngerror.c, - * and call standard C I/O routines such as fread(), fwrite(), and - * fprintf(). These functions can be made to use other I/O routines - * at run time for those applications that need to handle I/O in a - * different manner by calling png_set_???_fn(). See libpng.txt for - * more information. - */ - -#if !defined(PNG_NO_STDIO) -/* Initialize the input/output for the PNG file to the default functions. */ -extern PNG_EXPORT(void,png_init_io) PNGARG((png_structp png_ptr, png_FILE_p fp)); -#endif - -/* Replace the (error and abort), and warning functions with user - * supplied functions. If no messages are to be printed you must still - * write and use replacement functions. The replacement error_fn should - * still do a longjmp to the last setjmp location if you are using this - * method of error handling. If error_fn or warning_fn is NULL, the - * default function will be used. - */ - -extern PNG_EXPORT(void,png_set_error_fn) PNGARG((png_structp png_ptr, - png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn)); - -/* Return the user pointer associated with the error functions */ -extern PNG_EXPORT(png_voidp,png_get_error_ptr) PNGARG((png_structp png_ptr)); - -/* Replace the default data output functions with a user supplied one(s). - * If buffered output is not used, then output_flush_fn can be set to NULL. - * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time - * output_flush_fn will be ignored (and thus can be NULL). - */ -extern PNG_EXPORT(void,png_set_write_fn) PNGARG((png_structp png_ptr, - png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)); - -/* Replace the default data input function with a user supplied one. */ -extern PNG_EXPORT(void,png_set_read_fn) PNGARG((png_structp png_ptr, - png_voidp io_ptr, png_rw_ptr read_data_fn)); - -/* Return the user pointer associated with the I/O functions */ -extern PNG_EXPORT(png_voidp,png_get_io_ptr) PNGARG((png_structp png_ptr)); - -extern PNG_EXPORT(void,png_set_read_status_fn) PNGARG((png_structp png_ptr, - png_read_status_ptr read_row_fn)); - -extern PNG_EXPORT(void,png_set_write_status_fn) PNGARG((png_structp png_ptr, - png_write_status_ptr write_row_fn)); - -#ifdef PNG_USER_MEM_SUPPORTED -/* Replace the default memory allocation functions with user supplied one(s). */ -extern PNG_EXPORT(void,png_set_mem_fn) PNGARG((png_structp png_ptr, - png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)); -/* Return the user pointer associated with the memory functions */ -extern PNG_EXPORT(png_voidp,png_get_mem_ptr) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -extern PNG_EXPORT(void,png_set_read_user_transform_fn) PNGARG((png_structp - png_ptr, png_user_transform_ptr read_user_transform_fn)); -#endif - -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -extern PNG_EXPORT(void,png_set_write_user_transform_fn) PNGARG((png_structp - png_ptr, png_user_transform_ptr write_user_transform_fn)); -#endif - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -extern PNG_EXPORT(void,png_set_user_transform_info) PNGARG((png_structp - png_ptr, png_voidp user_transform_ptr, int user_transform_depth, - int user_transform_channels)); -/* Return the user pointer associated with the user transform functions */ -extern PNG_EXPORT(png_voidp,png_get_user_transform_ptr) - PNGARG((png_structp png_ptr)); -#endif - -#ifdef PNG_USER_CHUNKS_SUPPORTED -extern PNG_EXPORT(void,png_set_read_user_chunk_fn) PNGARG((png_structp png_ptr, - png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn)); -extern PNG_EXPORT(png_voidp,png_get_user_chunk_ptr) PNGARG((png_structp - png_ptr)); -#endif - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -/* Sets the function callbacks for the push reader, and a pointer to a - * user-defined structure available to the callback functions. - */ -extern PNG_EXPORT(void,png_set_progressive_read_fn) PNGARG((png_structp png_ptr, - png_voidp progressive_ptr, - png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, - png_progressive_end_ptr end_fn)); - -/* returns the user pointer associated with the push read functions */ -extern PNG_EXPORT(png_voidp,png_get_progressive_ptr) - PNGARG((png_structp png_ptr)); - -/* function to be called when data becomes available */ -extern PNG_EXPORT(void,png_process_data) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_bytep buffer, png_size_t buffer_size)); - -/* function that combines rows. Not very much different than the - * png_combine_row() call. Is this even used????? - */ -extern PNG_EXPORT(void,png_progressive_combine_row) PNGARG((png_structp png_ptr, - png_bytep old_row, png_bytep new_row)); -#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ - -extern PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr, - png_uint_32 size)); - -#if defined(PNG_1_0_X) -# define png_malloc_warn png_malloc -#else -/* Added at libpng version 1.2.4 */ -extern PNG_EXPORT(png_voidp,png_malloc_warn) PNGARG((png_structp png_ptr, - png_uint_32 size)); -#endif - -/* frees a pointer allocated by png_malloc() */ -extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr)); - -#if defined(PNG_1_0_X) -/* Function to allocate memory for zlib. */ -extern PNG_EXPORT(voidpf,png_zalloc) PNGARG((voidpf png_ptr, uInt items, - uInt size)); - -/* Function to free memory for zlib */ -extern PNG_EXPORT(void,png_zfree) PNGARG((voidpf png_ptr, voidpf ptr)); -#endif - -/* Free data that was allocated internally */ -extern PNG_EXPORT(void,png_free_data) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 free_me, int num)); -#ifdef PNG_FREE_ME_SUPPORTED -/* Reassign responsibility for freeing existing data, whether allocated - * by libpng or by the application */ -extern PNG_EXPORT(void,png_data_freer) PNGARG((png_structp png_ptr, - png_infop info_ptr, int freer, png_uint_32 mask)); -#endif -/* assignments for png_data_freer */ -#define PNG_DESTROY_WILL_FREE_DATA 1 -#define PNG_SET_WILL_FREE_DATA 1 -#define PNG_USER_WILL_FREE_DATA 2 -/* Flags for png_ptr->free_me and info_ptr->free_me */ -#define PNG_FREE_HIST 0x0008 -#define PNG_FREE_ICCP 0x0010 -#define PNG_FREE_SPLT 0x0020 -#define PNG_FREE_ROWS 0x0040 -#define PNG_FREE_PCAL 0x0080 -#define PNG_FREE_SCAL 0x0100 -#define PNG_FREE_UNKN 0x0200 -#define PNG_FREE_LIST 0x0400 -#define PNG_FREE_PLTE 0x1000 -#define PNG_FREE_TRNS 0x2000 -#define PNG_FREE_TEXT 0x4000 -#define PNG_FREE_ALL 0x7fff -#define PNG_FREE_MUL 0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */ - -#ifdef PNG_USER_MEM_SUPPORTED -extern PNG_EXPORT(png_voidp,png_malloc_default) PNGARG((png_structp png_ptr, - png_uint_32 size)); -extern PNG_EXPORT(void,png_free_default) PNGARG((png_structp png_ptr, - png_voidp ptr)); -#endif - -extern PNG_EXPORT(png_voidp,png_memcpy_check) PNGARG((png_structp png_ptr, - png_voidp s1, png_voidp s2, png_uint_32 size)); - -extern PNG_EXPORT(png_voidp,png_memset_check) PNGARG((png_structp png_ptr, - png_voidp s1, int value, png_uint_32 size)); - -#if defined(USE_FAR_KEYWORD) /* memory model conversion function */ -extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr, - int check)); -#endif /* USE_FAR_KEYWORD */ - -/* Fatal error in PNG image of libpng - can't continue */ -extern PNG_EXPORT(void,png_error) PNGARG((png_structp png_ptr, - png_const_charp error_message)); - -/* The same, but the chunk name is prepended to the error string. */ -extern PNG_EXPORT(void,png_chunk_error) PNGARG((png_structp png_ptr, - png_const_charp error_message)); - -/* Non-fatal error in libpng. Can continue, but may have a problem. */ -extern PNG_EXPORT(void,png_warning) PNGARG((png_structp png_ptr, - png_const_charp warning_message)); - -/* Non-fatal error in libpng, chunk name is prepended to message. */ -extern PNG_EXPORT(void,png_chunk_warning) PNGARG((png_structp png_ptr, - png_const_charp warning_message)); - -/* The png_set_<chunk> functions are for storing values in the png_info_struct. - * Similarly, the png_get_<chunk> calls are used to read values from the - * png_info_struct, either storing the parameters in the passed variables, or - * setting pointers into the png_info_struct where the data is stored. The - * png_get_<chunk> functions return a non-zero value if the data was available - * in info_ptr, or return zero and do not change any of the parameters if the - * data was not available. - * - * These functions should be used instead of directly accessing png_info - * to avoid problems with future changes in the size and internal layout of - * png_info_struct. - */ -/* Returns "flag" if chunk data is valid in info_ptr. */ -extern PNG_EXPORT(png_uint_32,png_get_valid) PNGARG((png_structp png_ptr, -png_infop info_ptr, png_uint_32 flag)); - -/* Returns number of bytes needed to hold a transformed row. */ -extern PNG_EXPORT(png_uint_32,png_get_rowbytes) PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -#if defined(PNG_INFO_IMAGE_SUPPORTED) -/* Returns row_pointers, which is an array of pointers to scanlines that was -returned from png_read_png(). */ -extern PNG_EXPORT(png_bytepp,png_get_rows) PNGARG((png_structp png_ptr, -png_infop info_ptr)); -/* Set row_pointers, which is an array of pointers to scanlines for use -by png_write_png(). */ -extern PNG_EXPORT(void,png_set_rows) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_bytepp row_pointers)); -#endif - -/* Returns number of color channels in image. */ -extern PNG_EXPORT(png_byte,png_get_channels) PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -#ifdef PNG_EASY_ACCESS_SUPPORTED -/* Returns image width in pixels. */ -extern PNG_EXPORT(png_uint_32, png_get_image_width) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image height in pixels. */ -extern PNG_EXPORT(png_uint_32, png_get_image_height) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image bit_depth. */ -extern PNG_EXPORT(png_byte, png_get_bit_depth) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image color_type. */ -extern PNG_EXPORT(png_byte, png_get_color_type) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image filter_type. */ -extern PNG_EXPORT(png_byte, png_get_filter_type) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image interlace_type. */ -extern PNG_EXPORT(png_byte, png_get_interlace_type) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image compression_type. */ -extern PNG_EXPORT(png_byte, png_get_compression_type) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image resolution in pixels per meter, from pHYs chunk data. */ -extern PNG_EXPORT(png_uint_32, png_get_pixels_per_meter) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_uint_32, png_get_x_pixels_per_meter) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_uint_32, png_get_y_pixels_per_meter) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns pixel aspect ratio, computed from pHYs chunk data. */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(float, png_get_pixel_aspect_ratio) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -#endif - -/* Returns image x, y offset in pixels or microns, from oFFs chunk data. */ -extern PNG_EXPORT(png_int_32, png_get_x_offset_pixels) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_int_32, png_get_y_offset_pixels) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_int_32, png_get_x_offset_microns) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_int_32, png_get_y_offset_microns) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -#endif /* PNG_EASY_ACCESS_SUPPORTED */ - -/* Returns pointer to signature string read from PNG header */ -extern PNG_EXPORT(png_bytep,png_get_signature) PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -#if defined(PNG_bKGD_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_bKGD) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_color_16p *background)); -#endif - -#if defined(PNG_bKGD_SUPPORTED) -extern PNG_EXPORT(void,png_set_bKGD) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_color_16p background)); -#endif - -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_cHRM) PNGARG((png_structp png_ptr, - png_infop info_ptr, double *white_x, double *white_y, double *red_x, - double *red_y, double *green_x, double *green_y, double *blue_x, - double *blue_y)); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_cHRM_fixed) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_fixed_point *int_white_x, png_fixed_point - *int_white_y, png_fixed_point *int_red_x, png_fixed_point *int_red_y, - png_fixed_point *int_green_x, png_fixed_point *int_green_y, png_fixed_point - *int_blue_x, png_fixed_point *int_blue_y)); -#endif -#endif - -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_cHRM) PNGARG((png_structp png_ptr, - png_infop info_ptr, double white_x, double white_y, double red_x, - double red_y, double green_x, double green_y, double blue_x, double blue_y)); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_cHRM_fixed) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_fixed_point int_white_x, png_fixed_point int_white_y, - png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point - int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, - png_fixed_point int_blue_y)); -#endif -#endif - -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_gAMA) PNGARG((png_structp png_ptr, - png_infop info_ptr, double *file_gamma)); -#endif -extern PNG_EXPORT(png_uint_32,png_get_gAMA_fixed) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_fixed_point *int_file_gamma)); -#endif - -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_gAMA) PNGARG((png_structp png_ptr, - png_infop info_ptr, double file_gamma)); -#endif -extern PNG_EXPORT(void,png_set_gAMA_fixed) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_fixed_point int_file_gamma)); -#endif - -#if defined(PNG_hIST_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_hIST) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_16p *hist)); -#endif - -#if defined(PNG_hIST_SUPPORTED) -extern PNG_EXPORT(void,png_set_hIST) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_16p hist)); -#endif - -extern PNG_EXPORT(png_uint_32,png_get_IHDR) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 *width, png_uint_32 *height, - int *bit_depth, int *color_type, int *interlace_method, - int *compression_method, int *filter_method)); - -extern PNG_EXPORT(void,png_set_IHDR) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, - int color_type, int interlace_method, int compression_method, - int filter_method)); - -#if defined(PNG_oFFs_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_oFFs) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_int_32 *offset_x, png_int_32 *offset_y, - int *unit_type)); -#endif - -#if defined(PNG_oFFs_SUPPORTED) -extern PNG_EXPORT(void,png_set_oFFs) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_int_32 offset_x, png_int_32 offset_y, - int unit_type)); -#endif - -#if defined(PNG_pCAL_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_pCAL) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1, - int *type, int *nparams, png_charp *units, png_charpp *params)); -#endif - -#if defined(PNG_pCAL_SUPPORTED) -extern PNG_EXPORT(void,png_set_pCAL) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1, - int type, int nparams, png_charp units, png_charpp params)); -#endif - -#if defined(PNG_pHYs_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_pHYs) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); -#endif - -#if defined(PNG_pHYs_SUPPORTED) -extern PNG_EXPORT(void,png_set_pHYs) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type)); -#endif - -extern PNG_EXPORT(png_uint_32,png_get_PLTE) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_colorp *palette, int *num_palette)); - -extern PNG_EXPORT(void,png_set_PLTE) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_colorp palette, int num_palette)); - -#if defined(PNG_sBIT_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_sBIT) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_color_8p *sig_bit)); -#endif - -#if defined(PNG_sBIT_SUPPORTED) -extern PNG_EXPORT(void,png_set_sBIT) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_color_8p sig_bit)); -#endif - -#if defined(PNG_sRGB_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_sRGB) PNGARG((png_structp png_ptr, - png_infop info_ptr, int *intent)); -#endif - -#if defined(PNG_sRGB_SUPPORTED) -extern PNG_EXPORT(void,png_set_sRGB) PNGARG((png_structp png_ptr, - png_infop info_ptr, int intent)); -extern PNG_EXPORT(void,png_set_sRGB_gAMA_and_cHRM) PNGARG((png_structp png_ptr, - png_infop info_ptr, int intent)); -#endif - -#if defined(PNG_iCCP_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_iCCP) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_charpp name, int *compression_type, - png_charpp profile, png_uint_32 *proflen)); - /* Note to maintainer: profile should be png_bytepp */ -#endif - -#if defined(PNG_iCCP_SUPPORTED) -extern PNG_EXPORT(void,png_set_iCCP) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_charp name, int compression_type, - png_charp profile, png_uint_32 proflen)); - /* Note to maintainer: profile should be png_bytep */ -#endif - -#if defined(PNG_sPLT_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_sPLT) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_sPLT_tpp entries)); -#endif - -#if defined(PNG_sPLT_SUPPORTED) -extern PNG_EXPORT(void,png_set_sPLT) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_sPLT_tp entries, int nentries)); -#endif - -#if defined(PNG_TEXT_SUPPORTED) -/* png_get_text also returns the number of text chunks in *num_text */ -extern PNG_EXPORT(png_uint_32,png_get_text) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_textp *text_ptr, int *num_text)); -#endif - -/* - * Note while png_set_text() will accept a structure whose text, - * language, and translated keywords are NULL pointers, the structure - * returned by png_get_text will always contain regular - * zero-terminated C strings. They might be empty strings but - * they will never be NULL pointers. - */ - -#if defined(PNG_TEXT_SUPPORTED) -extern PNG_EXPORT(void,png_set_text) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_textp text_ptr, int num_text)); -#endif - -#if defined(PNG_tIME_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_tIME) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_timep *mod_time)); -#endif - -#if defined(PNG_tIME_SUPPORTED) -extern PNG_EXPORT(void,png_set_tIME) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_timep mod_time)); -#endif - -#if defined(PNG_tRNS_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_tRNS) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_bytep *trans, int *num_trans, - png_color_16p *trans_values)); -#endif - -#if defined(PNG_tRNS_SUPPORTED) -extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_bytep trans, int num_trans, - png_color_16p trans_values)); -#endif - -#if defined(PNG_tRNS_SUPPORTED) -#endif - -#if defined(PNG_sCAL_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_sCAL) PNGARG((png_structp png_ptr, - png_infop info_ptr, int *unit, double *width, double *height)); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_sCAL_s) PNGARG((png_structp png_ptr, - png_infop info_ptr, int *unit, png_charpp swidth, png_charpp sheight)); -#endif -#endif -#endif /* PNG_sCAL_SUPPORTED */ - -#if defined(PNG_sCAL_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_sCAL) PNGARG((png_structp png_ptr, - png_infop info_ptr, int unit, double width, double height)); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_sCAL_s) PNGARG((png_structp png_ptr, - png_infop info_ptr, int unit, png_charp swidth, png_charp sheight)); -#endif -#endif -#endif /* PNG_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */ - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -/* provide a list of chunks and how they are to be handled, if the built-in - handling or default unknown chunk handling is not desired. Any chunks not - listed will be handled in the default manner. The IHDR and IEND chunks - must not be listed. - keep = 0: follow default behaviour - = 1: do not keep - = 2: keep only if safe-to-copy - = 3: keep even if unsafe-to-copy -*/ -extern PNG_EXPORT(void, png_set_keep_unknown_chunks) PNGARG((png_structp - png_ptr, int keep, png_bytep chunk_list, int num_chunks)); -extern PNG_EXPORT(void, png_set_unknown_chunks) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns)); -extern PNG_EXPORT(void, png_set_unknown_chunk_location) - PNGARG((png_structp png_ptr, png_infop info_ptr, int chunk, int location)); -extern PNG_EXPORT(png_uint_32,png_get_unknown_chunks) PNGARG((png_structp - png_ptr, png_infop info_ptr, png_unknown_chunkpp entries)); -#endif -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED -PNG_EXPORT(int,png_handle_as_unknown) PNGARG((png_structp png_ptr, png_bytep - chunk_name)); -#endif - -/* Png_free_data() will turn off the "valid" flag for anything it frees. - If you need to turn it off for a chunk that your application has freed, - you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK); */ -extern PNG_EXPORT(void, png_set_invalid) PNGARG((png_structp png_ptr, - png_infop info_ptr, int mask)); - -#if defined(PNG_INFO_IMAGE_SUPPORTED) -/* The "params" pointer is currently not used and is for future expansion. */ -extern PNG_EXPORT(void, png_read_png) PNGARG((png_structp png_ptr, - png_infop info_ptr, - int transforms, - png_voidp params)); -extern PNG_EXPORT(void, png_write_png) PNGARG((png_structp png_ptr, - png_infop info_ptr, - int transforms, - png_voidp params)); -#endif - -/* Define PNG_DEBUG at compile time for debugging information. Higher - * numbers for PNG_DEBUG mean more debugging information. This has - * only been added since version 0.95 so it is not implemented throughout - * libpng yet, but more support will be added as needed. - */ -#ifdef PNG_DEBUG -#if (PNG_DEBUG > 0) -#if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER) -#include <crtdbg.h> -#if (PNG_DEBUG > 1) -#define png_debug(l,m) _RPT0(_CRT_WARN,m) -#define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m,p1) -#define png_debug2(l,m,p1,p2) _RPT2(_CRT_WARN,m,p1,p2) -#endif -#else /* PNG_DEBUG_FILE || !_MSC_VER */ -#ifndef PNG_DEBUG_FILE -#define PNG_DEBUG_FILE stderr -#endif /* PNG_DEBUG_FILE */ -#if (PNG_DEBUG > 1) -#define png_debug(l,m) \ -{ \ - int num_tabs=l; \ - fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ - (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \ -} -#define png_debug1(l,m,p1) \ -{ \ - int num_tabs=l; \ - fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ - (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \ -} -#define png_debug2(l,m,p1,p2) \ -{ \ - int num_tabs=l; \ - fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ - (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \ -} -#endif /* (PNG_DEBUG > 1) */ -#endif /* _MSC_VER */ -#endif /* (PNG_DEBUG > 0) */ -#endif /* PNG_DEBUG */ -#ifndef png_debug -#define png_debug(l, m) -#endif -#ifndef png_debug1 -#define png_debug1(l, m, p1) -#endif -#ifndef png_debug2 -#define png_debug2(l, m, p1, p2) -#endif - -#if 0 -extern PNG_EXPORT(png_bytep,png_sig_bytes) PNGARG((void)); -#endif - -extern PNG_EXPORT(png_charp,png_get_copyright) PNGARG((png_structp png_ptr)); -extern PNG_EXPORT(png_charp,png_get_header_ver) PNGARG((png_structp png_ptr)); -extern PNG_EXPORT(png_charp,png_get_header_version) PNGARG((png_structp png_ptr)); -extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr)); - -#ifdef PNG_MNG_FEATURES_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_permit_mng_features) PNGARG((png_structp - png_ptr, png_uint_32 mng_features_permitted)); -#endif - -/* For use in png_set_keep_unknown, added to version 1.2.6 */ -#define PNG_HANDLE_CHUNK_AS_DEFAULT 0 -#define PNG_HANDLE_CHUNK_NEVER 1 -#define PNG_HANDLE_CHUNK_IF_SAFE 2 -#define PNG_HANDLE_CHUNK_ALWAYS 3 - -/* Added to version 1.2.0 */ -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) -#if defined(PNG_MMX_CODE_SUPPORTED) -#define PNG_ASM_FLAG_MMX_SUPPORT_COMPILED 0x01 /* not user-settable */ -#define PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU 0x02 /* not user-settable */ -#define PNG_ASM_FLAG_MMX_READ_COMBINE_ROW 0x04 -#define PNG_ASM_FLAG_MMX_READ_INTERLACE 0x08 -#define PNG_ASM_FLAG_MMX_READ_FILTER_SUB 0x10 -#define PNG_ASM_FLAG_MMX_READ_FILTER_UP 0x20 -#define PNG_ASM_FLAG_MMX_READ_FILTER_AVG 0x40 -#define PNG_ASM_FLAG_MMX_READ_FILTER_PAETH 0x80 -#define PNG_ASM_FLAGS_INITIALIZED 0x80000000 /* not user-settable */ - -#define PNG_MMX_READ_FLAGS ( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ - | PNG_ASM_FLAG_MMX_READ_INTERLACE \ - | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ - | PNG_ASM_FLAG_MMX_READ_FILTER_UP \ - | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ - | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ) -#define PNG_MMX_WRITE_FLAGS ( 0 ) - -#define PNG_MMX_FLAGS ( PNG_ASM_FLAG_MMX_SUPPORT_COMPILED \ - | PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU \ - | PNG_MMX_READ_FLAGS \ - | PNG_MMX_WRITE_FLAGS ) - -#define PNG_SELECT_READ 1 -#define PNG_SELECT_WRITE 2 -#endif /* PNG_MMX_CODE_SUPPORTED */ - -#if !defined(PNG_1_0_X) -/* pngget.c */ -extern PNG_EXPORT(png_uint_32,png_get_mmx_flagmask) - PNGARG((int flag_select, int *compilerID)); - -/* pngget.c */ -extern PNG_EXPORT(png_uint_32,png_get_asm_flagmask) - PNGARG((int flag_select)); - -/* pngget.c */ -extern PNG_EXPORT(png_uint_32,png_get_asm_flags) - PNGARG((png_structp png_ptr)); - -/* pngget.c */ -extern PNG_EXPORT(png_byte,png_get_mmx_bitdepth_threshold) - PNGARG((png_structp png_ptr)); - -/* pngget.c */ -extern PNG_EXPORT(png_uint_32,png_get_mmx_rowbytes_threshold) - PNGARG((png_structp png_ptr)); - -/* pngset.c */ -extern PNG_EXPORT(void,png_set_asm_flags) - PNGARG((png_structp png_ptr, png_uint_32 asm_flags)); - -/* pngset.c */ -extern PNG_EXPORT(void,png_set_mmx_thresholds) - PNGARG((png_structp png_ptr, png_byte mmx_bitdepth_threshold, - png_uint_32 mmx_rowbytes_threshold)); - -#endif /* PNG_1_0_X */ - -#if !defined(PNG_1_0_X) -/* png.c, pnggccrd.c, or pngvcrd.c */ -extern PNG_EXPORT(int,png_mmx_support) PNGARG((void)); -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ - -/* Strip the prepended error numbers ("#nnn ") from error and warning - * messages before passing them to the error or warning handler. */ -#ifdef PNG_ERROR_NUMBERS_SUPPORTED -extern PNG_EXPORT(void,png_set_strip_error_numbers) PNGARG((png_structp - png_ptr, png_uint_32 strip_mode)); -#endif - -#endif /* PNG_1_0_X */ - -/* Added at libpng-1.2.6 */ -#ifdef PNG_SET_USER_LIMITS_SUPPORTED -extern PNG_EXPORT(void,png_set_user_limits) PNGARG((png_structp - png_ptr, png_uint_32 user_width_max, png_uint_32 user_height_max)); -extern PNG_EXPORT(png_uint_32,png_get_user_width_max) PNGARG((png_structp - png_ptr)); -extern PNG_EXPORT(png_uint_32,png_get_user_height_max) PNGARG((png_structp - png_ptr)); -#endif - -/* Maintainer: Put new public prototypes here ^, in libpng.3, and project defs */ - -#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED -/* With these routines we avoid an integer divide, which will be slower on - * most machines. However, it does take more operations than the corresponding - * divide method, so it may be slower on a few RISC systems. There are two - * shifts (by 8 or 16 bits) and an addition, versus a single integer divide. - * - * Note that the rounding factors are NOT supposed to be the same! 128 and - * 32768 are correct for the NODIV code; 127 and 32767 are correct for the - * standard method. - * - * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ] - */ - - /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */ - -# define png_composite(composite, fg, alpha, bg) \ - { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) * (png_uint_16)(alpha) \ - + (png_uint_16)(bg)*(png_uint_16)(255 - \ - (png_uint_16)(alpha)) + (png_uint_16)128); \ - (composite) = (png_byte)((temp + (temp >> 8)) >> 8); } - -# define png_composite_16(composite, fg, alpha, bg) \ - { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) * (png_uint_32)(alpha) \ - + (png_uint_32)(bg)*(png_uint_32)(65535L - \ - (png_uint_32)(alpha)) + (png_uint_32)32768L); \ - (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); } - -#else /* standard method using integer division */ - -# define png_composite(composite, fg, alpha, bg) \ - (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \ - (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \ - (png_uint_16)127) / 255) - -# define png_composite_16(composite, fg, alpha, bg) \ - (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \ - (png_uint_32)(bg)*(png_uint_32)(65535L - (png_uint_32)(alpha)) + \ - (png_uint_32)32767) / (png_uint_32)65535L) - -#endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */ - -/* Inline macros to do direct reads of bytes from the input buffer. These - * require that you are using an architecture that uses PNG byte ordering - * (MSB first) and supports unaligned data storage. I think that PowerPC - * in big-endian mode and 680x0 are the only ones that will support this. - * The x86 line of processors definitely do not. The png_get_int_32() - * routine also assumes we are using two's complement format for negative - * values, which is almost certainly true. - */ -#if defined(PNG_READ_BIG_ENDIAN_SUPPORTED) -# define png_get_uint_32(buf) ( *((png_uint_32p) (buf))) -# define png_get_uint_16(buf) ( *((png_uint_16p) (buf))) -# define png_get_int_32(buf) ( *((png_int_32p) (buf))) -#else -extern PNG_EXPORT(png_uint_32,png_get_uint_32) PNGARG((png_bytep buf)); -extern PNG_EXPORT(png_uint_16,png_get_uint_16) PNGARG((png_bytep buf)); -extern PNG_EXPORT(png_int_32,png_get_int_32) PNGARG((png_bytep buf)); -#endif /* !PNG_READ_BIG_ENDIAN_SUPPORTED */ -extern PNG_EXPORT(png_uint_32,png_get_uint_31) - PNGARG((png_structp png_ptr, png_bytep buf)); -/* No png_get_int_16 -- may be added if there's a real need for it. */ - -/* Place a 32-bit number into a buffer in PNG byte order (big-endian). - */ -extern PNG_EXPORT(void,png_save_uint_32) - PNGARG((png_bytep buf, png_uint_32 i)); -extern PNG_EXPORT(void,png_save_int_32) - PNGARG((png_bytep buf, png_int_32 i)); - -/* Place a 16-bit number into a buffer in PNG byte order. - * The parameter is declared unsigned int, not png_uint_16, - * just to avoid potential problems on pre-ANSI C compilers. - */ -extern PNG_EXPORT(void,png_save_uint_16) - PNGARG((png_bytep buf, unsigned int i)); -/* No png_save_int_16 -- may be added if there's a real need for it. */ - -/* ************************************************************************* */ - -/* These next functions are used internally in the code. They generally - * shouldn't be used unless you are writing code to add or replace some - * functionality in libpng. More information about most functions can - * be found in the files where the functions are located. - */ - - -/* Various modes of operation, that are visible to applications because - * they are used for unknown chunk location. - */ -#define PNG_HAVE_IHDR 0x01 -#define PNG_HAVE_PLTE 0x02 -#define PNG_HAVE_IDAT 0x04 -#define PNG_AFTER_IDAT 0x08 /* Have complete zlib datastream */ -#define PNG_HAVE_IEND 0x10 - -#if defined(PNG_INTERNAL) - -/* More modes of operation. Note that after an init, mode is set to - * zero automatically when the structure is created. - */ -#define PNG_HAVE_gAMA 0x20 -#define PNG_HAVE_cHRM 0x40 -#define PNG_HAVE_sRGB 0x80 -#define PNG_HAVE_CHUNK_HEADER 0x100 -#define PNG_WROTE_tIME 0x200 -#define PNG_WROTE_INFO_BEFORE_PLTE 0x400 -#define PNG_BACKGROUND_IS_GRAY 0x800 -#define PNG_HAVE_PNG_SIGNATURE 0x1000 -#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */ - -/* flags for the transformations the PNG library does on the image data */ -#define PNG_BGR 0x0001 -#define PNG_INTERLACE 0x0002 -#define PNG_PACK 0x0004 -#define PNG_SHIFT 0x0008 -#define PNG_SWAP_BYTES 0x0010 -#define PNG_INVERT_MONO 0x0020 -#define PNG_DITHER 0x0040 -#define PNG_BACKGROUND 0x0080 -#define PNG_BACKGROUND_EXPAND 0x0100 - /* 0x0200 unused */ -#define PNG_16_TO_8 0x0400 -#define PNG_RGBA 0x0800 -#define PNG_EXPAND 0x1000 -#define PNG_GAMMA 0x2000 -#define PNG_GRAY_TO_RGB 0x4000 -#define PNG_FILLER 0x8000L -#define PNG_PACKSWAP 0x10000L -#define PNG_SWAP_ALPHA 0x20000L -#define PNG_STRIP_ALPHA 0x40000L -#define PNG_INVERT_ALPHA 0x80000L -#define PNG_USER_TRANSFORM 0x100000L -#define PNG_RGB_TO_GRAY_ERR 0x200000L -#define PNG_RGB_TO_GRAY_WARN 0x400000L -#define PNG_RGB_TO_GRAY 0x600000L /* two bits, RGB_TO_GRAY_ERR|WARN */ - /* 0x800000L Unused */ -#define PNG_ADD_ALPHA 0x1000000L /* Added to libpng-1.2.7 */ -#define PNG_EXPAND_tRNS 0x2000000L /* Added to libpng-1.2.9 */ - /* 0x4000000L unused */ - /* 0x8000000L unused */ - /* 0x10000000L unused */ - /* 0x20000000L unused */ - /* 0x40000000L unused */ - -/* flags for png_create_struct */ -#define PNG_STRUCT_PNG 0x0001 -#define PNG_STRUCT_INFO 0x0002 - -/* Scaling factor for filter heuristic weighting calculations */ -#define PNG_WEIGHT_SHIFT 8 -#define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT)) -#define PNG_COST_SHIFT 3 -#define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT)) - -/* flags for the png_ptr->flags rather than declaring a byte for each one */ -#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001 -#define PNG_FLAG_ZLIB_CUSTOM_LEVEL 0x0002 -#define PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL 0x0004 -#define PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS 0x0008 -#define PNG_FLAG_ZLIB_CUSTOM_METHOD 0x0010 -#define PNG_FLAG_ZLIB_FINISHED 0x0020 -#define PNG_FLAG_ROW_INIT 0x0040 -#define PNG_FLAG_FILLER_AFTER 0x0080 -#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100 -#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200 -#define PNG_FLAG_CRC_CRITICAL_USE 0x0400 -#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800 -#define PNG_FLAG_FREE_PLTE 0x1000 -#define PNG_FLAG_FREE_TRNS 0x2000 -#define PNG_FLAG_FREE_HIST 0x4000 -#define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000L -#define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000L -#define PNG_FLAG_LIBRARY_MISMATCH 0x20000L -#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000L -#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000L -#define PNG_FLAG_MALLOC_NULL_MEM_OK 0x100000L -#define PNG_FLAG_ADD_ALPHA 0x200000L /* Added to libpng-1.2.8 */ -#define PNG_FLAG_STRIP_ALPHA 0x400000L /* Added to libpng-1.2.8 */ - /* 0x800000L unused */ - /* 0x1000000L unused */ - /* 0x2000000L unused */ - /* 0x4000000L unused */ - /* 0x8000000L unused */ - /* 0x10000000L unused */ - /* 0x20000000L unused */ - /* 0x40000000L unused */ - -#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \ - PNG_FLAG_CRC_ANCILLARY_NOWARN) - -#define PNG_FLAG_CRC_CRITICAL_MASK (PNG_FLAG_CRC_CRITICAL_USE | \ - PNG_FLAG_CRC_CRITICAL_IGNORE) - -#define PNG_FLAG_CRC_MASK (PNG_FLAG_CRC_ANCILLARY_MASK | \ - PNG_FLAG_CRC_CRITICAL_MASK) - -/* save typing and make code easier to understand */ - -#define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \ - abs((int)((c1).green) - (int)((c2).green)) + \ - abs((int)((c1).blue) - (int)((c2).blue))) - -/* Added to libpng-1.2.6 JB */ -#define PNG_ROWBYTES(pixel_bits, width) \ - ((pixel_bits) >= 8 ? \ - ((width) * (((png_uint_32)(pixel_bits)) >> 3)) : \ - (( ((width) * ((png_uint_32)(pixel_bits))) + 7) >> 3) ) - -/* PNG_OUT_OF_RANGE returns true if value is outside the range - ideal-delta..ideal+delta. Each argument is evaluated twice. - "ideal" and "delta" should be constants, normally simple - integers, "value" a variable. Added to libpng-1.2.6 JB */ -#define PNG_OUT_OF_RANGE(value, ideal, delta) \ - ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) ) - -/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */ -#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN) -/* place to hold the signature string for a PNG file. */ -#ifdef PNG_USE_GLOBAL_ARRAYS - PNG_EXPORT_VAR (const png_byte FARDATA) png_sig[8]; -#else -#if 0 -#define png_sig png_sig_bytes(NULL) -#endif -#endif -#endif /* PNG_NO_EXTERN */ - -/* Constant strings for known chunk types. If you need to add a chunk, - * define the name here, and add an invocation of the macro in png.c and - * wherever it's needed. - */ -#define PNG_IHDR const png_byte png_IHDR[5] = { 73, 72, 68, 82, '\0'} -#define PNG_IDAT const png_byte png_IDAT[5] = { 73, 68, 65, 84, '\0'} -#define PNG_IEND const png_byte png_IEND[5] = { 73, 69, 78, 68, '\0'} -#define PNG_PLTE const png_byte png_PLTE[5] = { 80, 76, 84, 69, '\0'} -#define PNG_bKGD const png_byte png_bKGD[5] = { 98, 75, 71, 68, '\0'} -#define PNG_cHRM const png_byte png_cHRM[5] = { 99, 72, 82, 77, '\0'} -#define PNG_gAMA const png_byte png_gAMA[5] = {103, 65, 77, 65, '\0'} -#define PNG_hIST const png_byte png_hIST[5] = {104, 73, 83, 84, '\0'} -#define PNG_iCCP const png_byte png_iCCP[5] = {105, 67, 67, 80, '\0'} -#define PNG_iTXt const png_byte png_iTXt[5] = {105, 84, 88, 116, '\0'} -#define PNG_oFFs const png_byte png_oFFs[5] = {111, 70, 70, 115, '\0'} -#define PNG_pCAL const png_byte png_pCAL[5] = {112, 67, 65, 76, '\0'} -#define PNG_sCAL const png_byte png_sCAL[5] = {115, 67, 65, 76, '\0'} -#define PNG_pHYs const png_byte png_pHYs[5] = {112, 72, 89, 115, '\0'} -#define PNG_sBIT const png_byte png_sBIT[5] = {115, 66, 73, 84, '\0'} -#define PNG_sPLT const png_byte png_sPLT[5] = {115, 80, 76, 84, '\0'} -#define PNG_sRGB const png_byte png_sRGB[5] = {115, 82, 71, 66, '\0'} -#define PNG_tEXt const png_byte png_tEXt[5] = {116, 69, 88, 116, '\0'} -#define PNG_tIME const png_byte png_tIME[5] = {116, 73, 77, 69, '\0'} -#define PNG_tRNS const png_byte png_tRNS[5] = {116, 82, 78, 83, '\0'} -#define PNG_zTXt const png_byte png_zTXt[5] = {122, 84, 88, 116, '\0'} - -#ifdef PNG_USE_GLOBAL_ARRAYS -PNG_EXPORT_VAR (const png_byte FARDATA) png_IHDR[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_IDAT[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_IEND[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_PLTE[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_bKGD[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_cHRM[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_gAMA[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_hIST[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_iCCP[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_iTXt[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_oFFs[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_pCAL[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_sCAL[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_pHYs[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_sBIT[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_sPLT[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_sRGB[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_tEXt[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_tIME[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_tRNS[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_zTXt[5]; -#endif /* PNG_USE_GLOBAL_ARRAYS */ - -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* Initialize png_ptr struct for reading, and allocate any other memory. - * (old interface - DEPRECATED - use png_create_read_struct instead). - */ -extern PNG_EXPORT(void,png_read_init) PNGARG((png_structp png_ptr)); -#undef png_read_init -#define png_read_init(png_ptr) png_read_init_3(&png_ptr, \ - PNG_LIBPNG_VER_STRING, png_sizeof(png_struct)); -#endif - -extern PNG_EXPORT(void,png_read_init_3) PNGARG((png_structpp ptr_ptr, - png_const_charp user_png_ver, png_size_t png_struct_size)); -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -extern PNG_EXPORT(void,png_read_init_2) PNGARG((png_structp png_ptr, - png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t - png_info_size)); -#endif - -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* Initialize png_ptr struct for writing, and allocate any other memory. - * (old interface - DEPRECATED - use png_create_write_struct instead). - */ -extern PNG_EXPORT(void,png_write_init) PNGARG((png_structp png_ptr)); -#undef png_write_init -#define png_write_init(png_ptr) png_write_init_3(&png_ptr, \ - PNG_LIBPNG_VER_STRING, png_sizeof(png_struct)); -#endif - -extern PNG_EXPORT(void,png_write_init_3) PNGARG((png_structpp ptr_ptr, - png_const_charp user_png_ver, png_size_t png_struct_size)); -extern PNG_EXPORT(void,png_write_init_2) PNGARG((png_structp png_ptr, - png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t - png_info_size)); - -/* Allocate memory for an internal libpng struct */ -PNG_EXTERN png_voidp png_create_struct PNGARG((int type)); - -/* Free memory from internal libpng struct */ -PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr)); - -PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr - malloc_fn, png_voidp mem_ptr)); -PNG_EXTERN void png_destroy_struct_2 PNGARG((png_voidp struct_ptr, - png_free_ptr free_fn, png_voidp mem_ptr)); - -/* Free any memory that info_ptr points to and reset struct. */ -PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr, - png_infop info_ptr)); - -#ifndef PNG_1_0_X -/* Function to allocate memory for zlib. */ -PNG_EXTERN voidpf png_zalloc PNGARG((voidpf png_ptr, uInt items, uInt size)); - -/* Function to free memory for zlib */ -PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr)); - -#ifdef PNG_SIZE_T -/* Function to convert a sizeof an item to png_sizeof item */ - PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size)); -#endif - -/* Next four functions are used internally as callbacks. PNGAPI is required - * but not PNG_EXPORT. PNGAPI added at libpng version 1.2.3. */ - -PNG_EXTERN void PNGAPI png_default_read_data PNGARG((png_structp png_ptr, - png_bytep data, png_size_t length)); - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -PNG_EXTERN void PNGAPI png_push_fill_buffer PNGARG((png_structp png_ptr, - png_bytep buffer, png_size_t length)); -#endif - -PNG_EXTERN void PNGAPI png_default_write_data PNGARG((png_structp png_ptr, - png_bytep data, png_size_t length)); - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -#if !defined(PNG_NO_STDIO) -PNG_EXTERN void PNGAPI png_default_flush PNGARG((png_structp png_ptr)); -#endif -#endif -#else /* PNG_1_0_X */ -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -PNG_EXTERN void png_push_fill_buffer PNGARG((png_structp png_ptr, - png_bytep buffer, png_size_t length)); -#endif -#endif /* PNG_1_0_X */ - -/* Reset the CRC variable */ -PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr)); - -/* Write the "data" buffer to whatever output you are using. */ -PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data, - png_size_t length)); - -/* Read data from whatever input you are using into the "data" buffer */ -PNG_EXTERN void png_read_data PNGARG((png_structp png_ptr, png_bytep data, - png_size_t length)); - -/* Read bytes into buf, and update png_ptr->crc */ -PNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf, - png_size_t length)); - -/* Decompress data in a chunk that uses compression */ -#if defined(PNG_zTXt_SUPPORTED) || defined(PNG_iTXt_SUPPORTED) || \ - defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) -PNG_EXTERN png_charp png_decompress_chunk PNGARG((png_structp png_ptr, - int comp_type, png_charp chunkdata, png_size_t chunklength, - png_size_t prefix_length, png_size_t *data_length)); -#endif - -/* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */ -PNG_EXTERN int png_crc_finish PNGARG((png_structp png_ptr, png_uint_32 skip)); - -/* Read the CRC from the file and compare it to the libpng calculated CRC */ -PNG_EXTERN int png_crc_error PNGARG((png_structp png_ptr)); - -/* Calculate the CRC over a section of data. Note that we are only - * passing a maximum of 64K on systems that have this as a memory limit, - * since this is the maximum buffer size we can specify. - */ -PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr, png_bytep ptr, - png_size_t length)); - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -PNG_EXTERN void png_flush PNGARG((png_structp png_ptr)); -#endif - -/* simple function to write the signature */ -PNG_EXTERN void png_write_sig PNGARG((png_structp png_ptr)); - -/* write various chunks */ - -/* Write the IHDR chunk, and update the png_struct with the necessary - * information. - */ -PNG_EXTERN void png_write_IHDR PNGARG((png_structp png_ptr, png_uint_32 width, - png_uint_32 height, - int bit_depth, int color_type, int compression_method, int filter_method, - int interlace_method)); - -PNG_EXTERN void png_write_PLTE PNGARG((png_structp png_ptr, png_colorp palette, - png_uint_32 num_pal)); - -PNG_EXTERN void png_write_IDAT PNGARG((png_structp png_ptr, png_bytep data, - png_size_t length)); - -PNG_EXTERN void png_write_IEND PNGARG((png_structp png_ptr)); - -#if defined(PNG_WRITE_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -PNG_EXTERN void png_write_gAMA PNGARG((png_structp png_ptr, double file_gamma)); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -PNG_EXTERN void png_write_gAMA_fixed PNGARG((png_structp png_ptr, png_fixed_point - file_gamma)); -#endif -#endif - -#if defined(PNG_WRITE_sBIT_SUPPORTED) -PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr, png_color_8p sbit, - int color_type)); -#endif - -#if defined(PNG_WRITE_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -PNG_EXTERN void png_write_cHRM PNGARG((png_structp png_ptr, - double white_x, double white_y, - double red_x, double red_y, double green_x, double green_y, - double blue_x, double blue_y)); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -PNG_EXTERN void png_write_cHRM_fixed PNGARG((png_structp png_ptr, - png_fixed_point int_white_x, png_fixed_point int_white_y, - png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point - int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, - png_fixed_point int_blue_y)); -#endif -#endif - -#if defined(PNG_WRITE_sRGB_SUPPORTED) -PNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr, - int intent)); -#endif - -#if defined(PNG_WRITE_iCCP_SUPPORTED) -PNG_EXTERN void png_write_iCCP PNGARG((png_structp png_ptr, - png_charp name, int compression_type, - png_charp profile, int proflen)); - /* Note to maintainer: profile should be png_bytep */ -#endif - -#if defined(PNG_WRITE_sPLT_SUPPORTED) -PNG_EXTERN void png_write_sPLT PNGARG((png_structp png_ptr, - png_sPLT_tp palette)); -#endif - -#if defined(PNG_WRITE_tRNS_SUPPORTED) -PNG_EXTERN void png_write_tRNS PNGARG((png_structp png_ptr, png_bytep trans, - png_color_16p values, int number, int color_type)); -#endif - -#if defined(PNG_WRITE_bKGD_SUPPORTED) -PNG_EXTERN void png_write_bKGD PNGARG((png_structp png_ptr, - png_color_16p values, int color_type)); -#endif - -#if defined(PNG_WRITE_hIST_SUPPORTED) -PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, png_uint_16p hist, - int num_hist)); -#endif - -#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \ - defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) -PNG_EXTERN png_size_t png_check_keyword PNGARG((png_structp png_ptr, - png_charp key, png_charpp new_key)); -#endif - -#if defined(PNG_WRITE_tEXt_SUPPORTED) -PNG_EXTERN void png_write_tEXt PNGARG((png_structp png_ptr, png_charp key, - png_charp text, png_size_t text_len)); -#endif - -#if defined(PNG_WRITE_zTXt_SUPPORTED) -PNG_EXTERN void png_write_zTXt PNGARG((png_structp png_ptr, png_charp key, - png_charp text, png_size_t text_len, int compression)); -#endif - -#if defined(PNG_WRITE_iTXt_SUPPORTED) -PNG_EXTERN void png_write_iTXt PNGARG((png_structp png_ptr, - int compression, png_charp key, png_charp lang, png_charp lang_key, - png_charp text)); -#endif - -#if defined(PNG_TEXT_SUPPORTED) /* Added at version 1.0.14 and 1.2.4 */ -PNG_EXTERN int png_set_text_2 PNGARG((png_structp png_ptr, - png_infop info_ptr, png_textp text_ptr, int num_text)); -#endif - -#if defined(PNG_WRITE_oFFs_SUPPORTED) -PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr, - png_int_32 x_offset, png_int_32 y_offset, int unit_type)); -#endif - -#if defined(PNG_WRITE_pCAL_SUPPORTED) -PNG_EXTERN void png_write_pCAL PNGARG((png_structp png_ptr, png_charp purpose, - png_int_32 X0, png_int_32 X1, int type, int nparams, - png_charp units, png_charpp params)); -#endif - -#if defined(PNG_WRITE_pHYs_SUPPORTED) -PNG_EXTERN void png_write_pHYs PNGARG((png_structp png_ptr, - png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit, - int unit_type)); -#endif - -#if defined(PNG_WRITE_tIME_SUPPORTED) -PNG_EXTERN void png_write_tIME PNGARG((png_structp png_ptr, - png_timep mod_time)); -#endif - -#if defined(PNG_WRITE_sCAL_SUPPORTED) -#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) -PNG_EXTERN void png_write_sCAL PNGARG((png_structp png_ptr, - int unit, double width, double height)); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -PNG_EXTERN void png_write_sCAL_s PNGARG((png_structp png_ptr, - int unit, png_charp width, png_charp height)); -#endif -#endif -#endif - -/* Called when finished processing a row of data */ -PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr)); - -/* Internal use only. Called before first row of data */ -PNG_EXTERN void png_write_start_row PNGARG((png_structp png_ptr)); - -#if defined(PNG_READ_GAMMA_SUPPORTED) -PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr)); -#endif - -/* combine a row of data, dealing with alpha, etc. if requested */ -PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row, - int mask)); - -#if defined(PNG_READ_INTERLACING_SUPPORTED) -/* expand an interlaced row */ -/* OLD pre-1.0.9 interface: -PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info, - png_bytep row, int pass, png_uint_32 transformations)); - */ -PNG_EXTERN void png_do_read_interlace PNGARG((png_structp png_ptr)); -#endif - -/* GRR TO DO (2.0 or whenever): simplify other internal calling interfaces */ - -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) -/* grab pixels out of a row for an interlaced pass */ -PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info, - png_bytep row, int pass)); -#endif - -/* unfilter a row */ -PNG_EXTERN void png_read_filter_row PNGARG((png_structp png_ptr, - png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter)); - -/* Choose the best filter to use and filter the row data */ -PNG_EXTERN void png_write_find_filter PNGARG((png_structp png_ptr, - png_row_infop row_info)); - -/* Write out the filtered row. */ -PNG_EXTERN void png_write_filtered_row PNGARG((png_structp png_ptr, - png_bytep filtered_row)); -/* finish a row while reading, dealing with interlacing passes, etc. */ -PNG_EXTERN void png_read_finish_row PNGARG((png_structp png_ptr)); - -/* initialize the row buffers, etc. */ -PNG_EXTERN void png_read_start_row PNGARG((png_structp png_ptr)); -/* optional call to update the users info structure */ -PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr, - png_infop info_ptr)); - -/* these are the functions that do the transformations */ -#if defined(PNG_READ_FILLER_SUPPORTED) -PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info, - png_bytep row, png_uint_32 filler, png_uint_32 flags)); -#endif - -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_read_swap_alpha PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_write_swap_alpha PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_read_invert_alpha PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_write_invert_alpha PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_WRITE_FILLER_SUPPORTED) || \ - defined(PNG_READ_STRIP_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info, - png_bytep row, png_uint_32 flags)); -#endif - -#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) -PNG_EXTERN void png_do_swap PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED) -PNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) -PNG_EXTERN int png_do_rgb_to_gray PNGARG((png_structp png_ptr, png_row_infop - row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) -PNG_EXTERN void png_do_gray_to_rgb PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_READ_PACK_SUPPORTED) -PNG_EXTERN void png_do_unpack PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) -PNG_EXTERN void png_do_unshift PNGARG((png_row_infop row_info, png_bytep row, - png_color_8p sig_bits)); -#endif - -#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) -PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_16_TO_8_SUPPORTED) -PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) -PNG_EXTERN void png_do_dither PNGARG((png_row_infop row_info, - png_bytep row, png_bytep palette_lookup, png_bytep dither_lookup)); - -# if defined(PNG_CORRECT_PALETTE_SUPPORTED) -PNG_EXTERN void png_correct_palette PNGARG((png_structp png_ptr, - png_colorp palette, int num_palette)); -# endif -#endif - -#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -PNG_EXTERN void png_do_bgr PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_WRITE_PACK_SUPPORTED) -PNG_EXTERN void png_do_pack PNGARG((png_row_infop row_info, - png_bytep row, png_uint_32 bit_depth)); -#endif - -#if defined(PNG_WRITE_SHIFT_SUPPORTED) -PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, png_bytep row, - png_color_8p bit_depth)); -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) -#if defined(PNG_READ_GAMMA_SUPPORTED) -PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, - png_color_16p trans_values, png_color_16p background, - png_color_16p background_1, - png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1, - png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1, - png_uint_16pp gamma_16_to_1, int gamma_shift)); -#else -PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, - png_color_16p trans_values, png_color_16p background)); -#endif -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) -PNG_EXTERN void png_do_gamma PNGARG((png_row_infop row_info, png_bytep row, - png_bytep gamma_table, png_uint_16pp gamma_16_table, - int gamma_shift)); -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) -PNG_EXTERN void png_do_expand_palette PNGARG((png_row_infop row_info, - png_bytep row, png_colorp palette, png_bytep trans, int num_trans)); -PNG_EXTERN void png_do_expand PNGARG((png_row_infop row_info, - png_bytep row, png_color_16p trans_value)); -#endif - -/* The following decodes the appropriate chunks, and does error correction, - * then calls the appropriate callback for the chunk if it is valid. - */ - -/* decode the IHDR chunk */ -PNG_EXTERN void png_handle_IHDR PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -PNG_EXTERN void png_handle_PLTE PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -PNG_EXTERN void png_handle_IEND PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); - -#if defined(PNG_READ_bKGD_SUPPORTED) -PNG_EXTERN void png_handle_bKGD PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_cHRM_SUPPORTED) -PNG_EXTERN void png_handle_cHRM PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_gAMA_SUPPORTED) -PNG_EXTERN void png_handle_gAMA PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_hIST_SUPPORTED) -PNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_iCCP_SUPPORTED) -extern void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif /* PNG_READ_iCCP_SUPPORTED */ - -#if defined(PNG_READ_iTXt_SUPPORTED) -PNG_EXTERN void png_handle_iTXt PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_oFFs_SUPPORTED) -PNG_EXTERN void png_handle_oFFs PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_pCAL_SUPPORTED) -PNG_EXTERN void png_handle_pCAL PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_pHYs_SUPPORTED) -PNG_EXTERN void png_handle_pHYs PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_sBIT_SUPPORTED) -PNG_EXTERN void png_handle_sBIT PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_sCAL_SUPPORTED) -PNG_EXTERN void png_handle_sCAL PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_sPLT_SUPPORTED) -extern void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif /* PNG_READ_sPLT_SUPPORTED */ - -#if defined(PNG_READ_sRGB_SUPPORTED) -PNG_EXTERN void png_handle_sRGB PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_tEXt_SUPPORTED) -PNG_EXTERN void png_handle_tEXt PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_tIME_SUPPORTED) -PNG_EXTERN void png_handle_tIME PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_tRNS_SUPPORTED) -PNG_EXTERN void png_handle_tRNS PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_zTXt_SUPPORTED) -PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); - -PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr, - png_bytep chunk_name)); - -/* handle the transformations for reading and writing */ -PNG_EXTERN void png_do_read_transformations PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_do_write_transformations PNGARG((png_structp png_ptr)); - -PNG_EXTERN void png_init_read_transformations PNGARG((png_structp png_ptr)); - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -PNG_EXTERN void png_push_read_chunk PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_push_read_sig PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_push_check_crc PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_push_crc_skip PNGARG((png_structp png_ptr, - png_uint_32 length)); -PNG_EXTERN void png_push_crc_finish PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_push_save_buffer PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_push_restore_buffer PNGARG((png_structp png_ptr, - png_bytep buffer, png_size_t buffer_length)); -PNG_EXTERN void png_push_read_IDAT PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_process_IDAT_data PNGARG((png_structp png_ptr, - png_bytep buffer, png_size_t buffer_length)); -PNG_EXTERN void png_push_process_row PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_push_handle_unknown PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); -PNG_EXTERN void png_push_have_info PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_push_have_end PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_push_have_row PNGARG((png_structp png_ptr, png_bytep row)); -PNG_EXTERN void png_push_read_end PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_process_some_data PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_read_push_finish_row PNGARG((png_structp png_ptr)); -#if defined(PNG_READ_tEXt_SUPPORTED) -PNG_EXTERN void png_push_handle_tEXt PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); -PNG_EXTERN void png_push_read_tEXt PNGARG((png_structp png_ptr, - png_infop info_ptr)); -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) -PNG_EXTERN void png_push_handle_zTXt PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); -PNG_EXTERN void png_push_read_zTXt PNGARG((png_structp png_ptr, - png_infop info_ptr)); -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) -PNG_EXTERN void png_push_handle_iTXt PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); -PNG_EXTERN void png_push_read_iTXt PNGARG((png_structp png_ptr, - png_infop info_ptr)); -#endif - -#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ - -#ifdef PNG_MNG_FEATURES_SUPPORTED -PNG_EXTERN void png_do_read_intrapixel PNGARG((png_row_infop row_info, - png_bytep row)); -PNG_EXTERN void png_do_write_intrapixel PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) -#if defined(PNG_MMX_CODE_SUPPORTED) -/* png.c */ /* PRIVATE */ -PNG_EXTERN void png_init_mmx_flags PNGARG((png_structp png_ptr)); -#endif -#endif - -#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED) -PNG_EXTERN png_uint_32 png_get_pixels_per_inch PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -PNG_EXTERN png_uint_32 png_get_x_pixels_per_inch PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -PNG_EXTERN png_uint_32 png_get_y_pixels_per_inch PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -PNG_EXTERN float png_get_x_offset_inches PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -PNG_EXTERN float png_get_y_offset_inches PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -#if defined(PNG_pHYs_SUPPORTED) -PNG_EXTERN png_uint_32 png_get_pHYs_dpi PNGARG((png_structp png_ptr, -png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); -#endif /* PNG_pHYs_SUPPORTED */ -#endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */ - -/* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */ - -#endif /* PNG_INTERNAL */ - -#ifdef __cplusplus -} -#endif - -#endif /* PNG_VERSION_INFO_ONLY */ -/* do not put anything past this line */ -#endif /* PNG_H */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/pngbar.jpg b/irrlicht-1.6/source/Irrlicht/libpng/pngbar.jpg deleted file mode 100644 index 70ba8d817..000000000 Binary files a/irrlicht-1.6/source/Irrlicht/libpng/pngbar.jpg and /dev/null differ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/pngbar.png b/irrlicht-1.6/source/Irrlicht/libpng/pngbar.png deleted file mode 100644 index 49798c8ed..000000000 Binary files a/irrlicht-1.6/source/Irrlicht/libpng/pngbar.png and /dev/null differ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/pngconf.h b/irrlicht-1.6/source/Irrlicht/libpng/pngconf.h deleted file mode 100644 index 19d5472d2..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/pngconf.h +++ /dev/null @@ -1,1483 +0,0 @@ - -/* pngconf.h - machine configurable file for libpng - * - * libpng version 1.2.18 - May 15, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -/* Any machine specific code is near the front of this file, so if you - * are configuring libpng for a machine, you may want to read the section - * starting here down to where it starts to typedef png_color, png_text, - * and png_info. - */ - -#ifndef PNGCONF_H -#define PNGCONF_H - -#define PNG_1_2_X - -/* - * PNG_USER_CONFIG has to be defined on the compiler command line. This - * includes the resource compiler for Windows DLL configurations. - */ -#ifdef PNG_USER_CONFIG -# ifndef PNG_USER_PRIVATEBUILD -# define PNG_USER_PRIVATEBUILD -# endif -#include "pngusr.h" -#endif - -/* PNG_CONFIGURE_LIBPNG is set by the "configure" script. */ -#ifdef PNG_CONFIGURE_LIBPNG -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#endif - -/* - * Added at libpng-1.2.8 - * - * If you create a private DLL you need to define in "pngusr.h" the followings: - * #define PNG_USER_PRIVATEBUILD <Describes by whom and why this version of - * the DLL was built> - * e.g. #define PNG_USER_PRIVATEBUILD "Build by MyCompany for xyz reasons." - * #define PNG_USER_DLLFNAME_POSTFIX <two-letter postfix that serve to - * distinguish your DLL from those of the official release. These - * correspond to the trailing letters that come after the version - * number and must match your private DLL name> - * e.g. // private DLL "libpng13gx.dll" - * #define PNG_USER_DLLFNAME_POSTFIX "gx" - * - * The following macros are also at your disposal if you want to complete the - * DLL VERSIONINFO structure. - * - PNG_USER_VERSIONINFO_COMMENTS - * - PNG_USER_VERSIONINFO_COMPANYNAME - * - PNG_USER_VERSIONINFO_LEGALTRADEMARKS - */ - -#ifdef __STDC__ -#ifdef SPECIALBUILD -# pragma message("PNG_LIBPNG_SPECIALBUILD (and deprecated SPECIALBUILD)\ - are now LIBPNG reserved macros. Use PNG_USER_PRIVATEBUILD instead.") -#endif - -#ifdef PRIVATEBUILD -# pragma message("PRIVATEBUILD is deprecated.\ - Use PNG_USER_PRIVATEBUILD instead.") -# define PNG_USER_PRIVATEBUILD PRIVATEBUILD -#endif -#endif /* __STDC__ */ - -#ifndef PNG_VERSION_INFO_ONLY - -/* End of material added to libpng-1.2.8 */ - -/* This is the size of the compression buffer, and thus the size of - * an IDAT chunk. Make this whatever size you feel is best for your - * machine. One of these will be allocated per png_struct. When this - * is full, it writes the data to the disk, and does some other - * calculations. Making this an extremely small size will slow - * the library down, but you may want to experiment to determine - * where it becomes significant, if you are concerned with memory - * usage. Note that zlib allocates at least 32Kb also. For readers, - * this describes the size of the buffer available to read the data in. - * Unless this gets smaller than the size of a row (compressed), - * it should not make much difference how big this is. - */ - -#ifndef PNG_ZBUF_SIZE -# define PNG_ZBUF_SIZE 8192 -#endif - -/* Enable if you want a write-only libpng */ - -#ifndef PNG_NO_READ_SUPPORTED -# define PNG_READ_SUPPORTED -#endif - -/* Enable if you want a read-only libpng */ - -#ifndef PNG_NO_WRITE_SUPPORTED -# define PNG_WRITE_SUPPORTED -#endif - -/* Enabled by default in 1.2.0. You can disable this if you don't need to - support PNGs that are embedded in MNG datastreams */ -#if !defined(PNG_1_0_X) && !defined(PNG_NO_MNG_FEATURES) -# ifndef PNG_MNG_FEATURES_SUPPORTED -# define PNG_MNG_FEATURES_SUPPORTED -# endif -#endif - -#ifndef PNG_NO_FLOATING_POINT_SUPPORTED -# ifndef PNG_FLOATING_POINT_SUPPORTED -# define PNG_FLOATING_POINT_SUPPORTED -# endif -#endif - -/* If you are running on a machine where you cannot allocate more - * than 64K of memory at once, uncomment this. While libpng will not - * normally need that much memory in a chunk (unless you load up a very - * large file), zlib needs to know how big of a chunk it can use, and - * libpng thus makes sure to check any memory allocation to verify it - * will fit into memory. -#define PNG_MAX_MALLOC_64K - */ -#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K) -# define PNG_MAX_MALLOC_64K -#endif - -/* Special munging to support doing things the 'cygwin' way: - * 'Normal' png-on-win32 defines/defaults: - * PNG_BUILD_DLL -- building dll - * PNG_USE_DLL -- building an application, linking to dll - * (no define) -- building static library, or building an - * application and linking to the static lib - * 'Cygwin' defines/defaults: - * PNG_BUILD_DLL -- (ignored) building the dll - * (no define) -- (ignored) building an application, linking to the dll - * PNG_STATIC -- (ignored) building the static lib, or building an - * application that links to the static lib. - * ALL_STATIC -- (ignored) building various static libs, or building an - * application that links to the static libs. - * Thus, - * a cygwin user should define either PNG_BUILD_DLL or PNG_STATIC, and - * this bit of #ifdefs will define the 'correct' config variables based on - * that. If a cygwin user *wants* to define 'PNG_USE_DLL' that's okay, but - * unnecessary. - * - * Also, the precedence order is: - * ALL_STATIC (since we can't #undef something outside our namespace) - * PNG_BUILD_DLL - * PNG_STATIC - * (nothing) == PNG_USE_DLL - * - * CYGWIN (2002-01-20): The preceding is now obsolete. With the advent - * of auto-import in binutils, we no longer need to worry about - * __declspec(dllexport) / __declspec(dllimport) and friends. Therefore, - * we don't need to worry about PNG_STATIC or ALL_STATIC when it comes - * to __declspec() stuff. However, we DO need to worry about - * PNG_BUILD_DLL and PNG_STATIC because those change some defaults - * such as CONSOLE_IO and whether GLOBAL_ARRAYS are allowed. - */ -#if defined(__CYGWIN__) -# if defined(ALL_STATIC) -# if defined(PNG_BUILD_DLL) -# undef PNG_BUILD_DLL -# endif -# if defined(PNG_USE_DLL) -# undef PNG_USE_DLL -# endif -# if defined(PNG_DLL) -# undef PNG_DLL -# endif -# if !defined(PNG_STATIC) -# define PNG_STATIC -# endif -# else -# if defined (PNG_BUILD_DLL) -# if defined(PNG_STATIC) -# undef PNG_STATIC -# endif -# if defined(PNG_USE_DLL) -# undef PNG_USE_DLL -# endif -# if !defined(PNG_DLL) -# define PNG_DLL -# endif -# else -# if defined(PNG_STATIC) -# if defined(PNG_USE_DLL) -# undef PNG_USE_DLL -# endif -# if defined(PNG_DLL) -# undef PNG_DLL -# endif -# else -# if !defined(PNG_USE_DLL) -# define PNG_USE_DLL -# endif -# if !defined(PNG_DLL) -# define PNG_DLL -# endif -# endif -# endif -# endif -#endif - -/* This protects us against compilers that run on a windowing system - * and thus don't have or would rather us not use the stdio types: - * stdin, stdout, and stderr. The only one currently used is stderr - * in png_error() and png_warning(). #defining PNG_NO_CONSOLE_IO will - * prevent these from being compiled and used. #defining PNG_NO_STDIO - * will also prevent these, plus will prevent the entire set of stdio - * macros and functions (FILE *, printf, etc.) from being compiled and used, - * unless (PNG_DEBUG > 0) has been #defined. - * - * #define PNG_NO_CONSOLE_IO - * #define PNG_NO_STDIO - */ - -#if defined(_WIN32_WCE) -# include <windows.h> - /* Console I/O functions are not supported on WindowsCE */ -# define PNG_NO_CONSOLE_IO -# ifdef PNG_DEBUG -# undef PNG_DEBUG -# endif -#endif - -#ifdef PNG_BUILD_DLL -# ifndef PNG_CONSOLE_IO_SUPPORTED -# ifndef PNG_NO_CONSOLE_IO -# define PNG_NO_CONSOLE_IO -# endif -# endif -#endif - -# ifdef PNG_NO_STDIO -# ifndef PNG_NO_CONSOLE_IO -# define PNG_NO_CONSOLE_IO -# endif -# ifdef PNG_DEBUG -# if (PNG_DEBUG > 0) -# include <stdio.h> -# endif -# endif -# else -# if !defined(_WIN32_WCE) -/* "stdio.h" functions are not supported on WindowsCE */ -# include <stdio.h> -# endif -# endif - -/* This macro protects us against machines that don't have function - * prototypes (ie K&R style headers). If your compiler does not handle - * function prototypes, define this macro and use the included ansi2knr. - * I've always been able to use _NO_PROTO as the indicator, but you may - * need to drag the empty declaration out in front of here, or change the - * ifdef to suit your own needs. - */ -#ifndef PNGARG - -#ifdef OF /* zlib prototype munger */ -# define PNGARG(arglist) OF(arglist) -#else - -#ifdef _NO_PROTO -# define PNGARG(arglist) () -# ifndef PNG_TYPECAST_NULL -# define PNG_TYPECAST_NULL -# endif -#else -# define PNGARG(arglist) arglist -#endif /* _NO_PROTO */ - -#endif /* OF */ - -#endif /* PNGARG */ - -/* Try to determine if we are compiling on a Mac. Note that testing for - * just __MWERKS__ is not good enough, because the Codewarrior is now used - * on non-Mac platforms. - */ -#ifndef MACOS -# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \ - defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC) -# define MACOS -# endif -#endif - -/* enough people need this for various reasons to include it here */ -#if !defined(MACOS) && !defined(RISCOS) && !defined(_WIN32_WCE) -# include <sys/types.h> -#endif - -#if !defined(PNG_SETJMP_NOT_SUPPORTED) && !defined(PNG_NO_SETJMP_SUPPORTED) -# define PNG_SETJMP_SUPPORTED -#endif - -#ifdef PNG_SETJMP_SUPPORTED -/* This is an attempt to force a single setjmp behaviour on Linux. If - * the X config stuff didn't define _BSD_SOURCE we wouldn't need this. - */ - -# ifdef __linux__ -# ifdef _BSD_SOURCE -# define PNG_SAVE_BSD_SOURCE -# undef _BSD_SOURCE -# endif -# ifdef _SETJMP_H - /* If you encounter a compiler error here, see the explanation - * near the end of INSTALL. - */ - __png.h__ already includes setjmp.h; - __dont__ include it again.; -# endif -# endif /* __linux__ */ - - /* include setjmp.h for error handling */ -# include <setjmp.h> - -# ifdef __linux__ -# ifdef PNG_SAVE_BSD_SOURCE -# define _BSD_SOURCE -# undef PNG_SAVE_BSD_SOURCE -# endif -# endif /* __linux__ */ -#endif /* PNG_SETJMP_SUPPORTED */ - -#ifdef BSD -# include <strings.h> -#else -# include <string.h> -#endif - -/* Other defines for things like memory and the like can go here. */ -#ifdef PNG_INTERNAL - -#include <stdlib.h> - -/* The functions exported by PNG_EXTERN are PNG_INTERNAL functions, which - * aren't usually used outside the library (as far as I know), so it is - * debatable if they should be exported at all. In the future, when it is - * possible to have run-time registry of chunk-handling functions, some of - * these will be made available again. -#define PNG_EXTERN extern - */ -#define PNG_EXTERN - -/* Other defines specific to compilers can go here. Try to keep - * them inside an appropriate ifdef/endif pair for portability. - */ - -#if defined(PNG_FLOATING_POINT_SUPPORTED) -# if defined(MACOS) - /* We need to check that <math.h> hasn't already been included earlier - * as it seems it doesn't agree with <fp.h>, yet we should really use - * <fp.h> if possible. - */ -# if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__) -# include <fp.h> -# endif -# else -# include <math.h> -# endif -# if defined(_AMIGA) && defined(__SASC) && defined(_M68881) - /* Amiga SAS/C: We must include builtin FPU functions when compiling using - * MATH=68881 - */ -# include <m68881.h> -# endif -#endif - -/* Codewarrior on NT has linking problems without this. */ -#if (defined(__MWERKS__) && defined(WIN32)) || defined(__STDC__) -# define PNG_ALWAYS_EXTERN -#endif - -/* This provides the non-ANSI (far) memory allocation routines. */ -#if defined(__TURBOC__) && defined(__MSDOS__) -# include <mem.h> -# include <alloc.h> -#endif - -/* I have no idea why is this necessary... */ -#if defined(_MSC_VER) && (defined(WIN32) || defined(_Windows) || \ - defined(_WINDOWS) || defined(_WIN32) || defined(__WIN32__)) -# include <malloc.h> -#endif - -/* This controls how fine the dithering gets. As this allocates - * a largish chunk of memory (32K), those who are not as concerned - * with dithering quality can decrease some or all of these. - */ -#ifndef PNG_DITHER_RED_BITS -# define PNG_DITHER_RED_BITS 5 -#endif -#ifndef PNG_DITHER_GREEN_BITS -# define PNG_DITHER_GREEN_BITS 5 -#endif -#ifndef PNG_DITHER_BLUE_BITS -# define PNG_DITHER_BLUE_BITS 5 -#endif - -/* This controls how fine the gamma correction becomes when you - * are only interested in 8 bits anyway. Increasing this value - * results in more memory being used, and more pow() functions - * being called to fill in the gamma tables. Don't set this value - * less then 8, and even that may not work (I haven't tested it). - */ - -#ifndef PNG_MAX_GAMMA_8 -# define PNG_MAX_GAMMA_8 11 -#endif - -/* This controls how much a difference in gamma we can tolerate before - * we actually start doing gamma conversion. - */ -#ifndef PNG_GAMMA_THRESHOLD -# define PNG_GAMMA_THRESHOLD 0.05 -#endif - -#endif /* PNG_INTERNAL */ - -/* The following uses const char * instead of char * for error - * and warning message functions, so some compilers won't complain. - * If you do not want to use const, define PNG_NO_CONST here. - */ - -#ifndef PNG_NO_CONST -# define PNG_CONST const -#else -# define PNG_CONST -#endif - -/* The following defines give you the ability to remove code from the - * library that you will not be using. I wish I could figure out how to - * automate this, but I can't do that without making it seriously hard - * on the users. So if you are not using an ability, change the #define - * to and #undef, and that part of the library will not be compiled. If - * your linker can't find a function, you may want to make sure the - * ability is defined here. Some of these depend upon some others being - * defined. I haven't figured out all the interactions here, so you may - * have to experiment awhile to get everything to compile. If you are - * creating or using a shared library, you probably shouldn't touch this, - * as it will affect the size of the structures, and this will cause bad - * things to happen if the library and/or application ever change. - */ - -/* Any features you will not be using can be undef'ed here */ - -/* GR-P, 0.96a: Set "*TRANSFORMS_SUPPORTED as default but allow user - * to turn it off with "*TRANSFORMS_NOT_SUPPORTED" or *PNG_NO_*_TRANSFORMS - * on the compile line, then pick and choose which ones to define without - * having to edit this file. It is safe to use the *TRANSFORMS_NOT_SUPPORTED - * if you only want to have a png-compliant reader/writer but don't need - * any of the extra transformations. This saves about 80 kbytes in a - * typical installation of the library. (PNG_NO_* form added in version - * 1.0.1c, for consistency) - */ - -/* The size of the png_text structure changed in libpng-1.0.6 when - * iTXt support was added. iTXt support was turned off by default through - * libpng-1.2.x, to support old apps that malloc the png_text structure - * instead of calling png_set_text() and letting libpng malloc it. It - * was turned on by default in libpng-1.3.0. - */ - -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -# ifndef PNG_NO_iTXt_SUPPORTED -# define PNG_NO_iTXt_SUPPORTED -# endif -# ifndef PNG_NO_READ_iTXt -# define PNG_NO_READ_iTXt -# endif -# ifndef PNG_NO_WRITE_iTXt -# define PNG_NO_WRITE_iTXt -# endif -#endif - -#if !defined(PNG_NO_iTXt_SUPPORTED) -# if !defined(PNG_READ_iTXt_SUPPORTED) && !defined(PNG_NO_READ_iTXt) -# define PNG_READ_iTXt -# endif -# if !defined(PNG_WRITE_iTXt_SUPPORTED) && !defined(PNG_NO_WRITE_iTXt) -# define PNG_WRITE_iTXt -# endif -#endif - -/* The following support, added after version 1.0.0, can be turned off here en - * masse by defining PNG_LEGACY_SUPPORTED in case you need binary compatibility - * with old applications that require the length of png_struct and png_info - * to remain unchanged. - */ - -#ifdef PNG_LEGACY_SUPPORTED -# define PNG_NO_FREE_ME -# define PNG_NO_READ_UNKNOWN_CHUNKS -# define PNG_NO_WRITE_UNKNOWN_CHUNKS -# define PNG_NO_READ_USER_CHUNKS -# define PNG_NO_READ_iCCP -# define PNG_NO_WRITE_iCCP -# define PNG_NO_READ_iTXt -# define PNG_NO_WRITE_iTXt -# define PNG_NO_READ_sCAL -# define PNG_NO_WRITE_sCAL -# define PNG_NO_READ_sPLT -# define PNG_NO_WRITE_sPLT -# define PNG_NO_INFO_IMAGE -# define PNG_NO_READ_RGB_TO_GRAY -# define PNG_NO_READ_USER_TRANSFORM -# define PNG_NO_WRITE_USER_TRANSFORM -# define PNG_NO_USER_MEM -# define PNG_NO_READ_EMPTY_PLTE -# define PNG_NO_MNG_FEATURES -# define PNG_NO_FIXED_POINT_SUPPORTED -#endif - -/* Ignore attempt to turn off both floating and fixed point support */ -#if !defined(PNG_FLOATING_POINT_SUPPORTED) || \ - !defined(PNG_NO_FIXED_POINT_SUPPORTED) -# define PNG_FIXED_POINT_SUPPORTED -#endif - -#ifndef PNG_NO_FREE_ME -# define PNG_FREE_ME_SUPPORTED -#endif - -#if defined(PNG_READ_SUPPORTED) - -#if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \ - !defined(PNG_NO_READ_TRANSFORMS) -# define PNG_READ_TRANSFORMS_SUPPORTED -#endif - -#ifdef PNG_READ_TRANSFORMS_SUPPORTED -# ifndef PNG_NO_READ_EXPAND -# define PNG_READ_EXPAND_SUPPORTED -# endif -# ifndef PNG_NO_READ_SHIFT -# define PNG_READ_SHIFT_SUPPORTED -# endif -# ifndef PNG_NO_READ_PACK -# define PNG_READ_PACK_SUPPORTED -# endif -# ifndef PNG_NO_READ_BGR -# define PNG_READ_BGR_SUPPORTED -# endif -# ifndef PNG_NO_READ_SWAP -# define PNG_READ_SWAP_SUPPORTED -# endif -# ifndef PNG_NO_READ_PACKSWAP -# define PNG_READ_PACKSWAP_SUPPORTED -# endif -# ifndef PNG_NO_READ_INVERT -# define PNG_READ_INVERT_SUPPORTED -# endif -# ifndef PNG_NO_READ_DITHER -# define PNG_READ_DITHER_SUPPORTED -# endif -# ifndef PNG_NO_READ_BACKGROUND -# define PNG_READ_BACKGROUND_SUPPORTED -# endif -# ifndef PNG_NO_READ_16_TO_8 -# define PNG_READ_16_TO_8_SUPPORTED -# endif -# ifndef PNG_NO_READ_FILLER -# define PNG_READ_FILLER_SUPPORTED -# endif -# ifndef PNG_NO_READ_GAMMA -# define PNG_READ_GAMMA_SUPPORTED -# endif -# ifndef PNG_NO_READ_GRAY_TO_RGB -# define PNG_READ_GRAY_TO_RGB_SUPPORTED -# endif -# ifndef PNG_NO_READ_SWAP_ALPHA -# define PNG_READ_SWAP_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_READ_INVERT_ALPHA -# define PNG_READ_INVERT_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_READ_STRIP_ALPHA -# define PNG_READ_STRIP_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_READ_USER_TRANSFORM -# define PNG_READ_USER_TRANSFORM_SUPPORTED -# endif -# ifndef PNG_NO_READ_RGB_TO_GRAY -# define PNG_READ_RGB_TO_GRAY_SUPPORTED -# endif -#endif /* PNG_READ_TRANSFORMS_SUPPORTED */ - -#if !defined(PNG_NO_PROGRESSIVE_READ) && \ - !defined(PNG_PROGRESSIVE_READ_NOT_SUPPORTED) /* if you don't do progressive */ -# define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */ -#endif /* about interlacing capability! You'll */ - /* still have interlacing unless you change the following line: */ - -#define PNG_READ_INTERLACING_SUPPORTED /* required for PNG-compliant decoders */ - -#ifndef PNG_NO_READ_COMPOSITE_NODIV -# ifndef PNG_NO_READ_COMPOSITED_NODIV /* libpng-1.0.x misspelling */ -# define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel, SGI */ -# endif -#endif - -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* Deprecated, will be removed from version 2.0.0. - Use PNG_MNG_FEATURES_SUPPORTED instead. */ -#ifndef PNG_NO_READ_EMPTY_PLTE -# define PNG_READ_EMPTY_PLTE_SUPPORTED -#endif -#endif - -#endif /* PNG_READ_SUPPORTED */ - -#if defined(PNG_WRITE_SUPPORTED) - -# if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \ - !defined(PNG_NO_WRITE_TRANSFORMS) -# define PNG_WRITE_TRANSFORMS_SUPPORTED -#endif - -#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED -# ifndef PNG_NO_WRITE_SHIFT -# define PNG_WRITE_SHIFT_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_PACK -# define PNG_WRITE_PACK_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_BGR -# define PNG_WRITE_BGR_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_SWAP -# define PNG_WRITE_SWAP_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_PACKSWAP -# define PNG_WRITE_PACKSWAP_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_INVERT -# define PNG_WRITE_INVERT_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_FILLER -# define PNG_WRITE_FILLER_SUPPORTED /* same as WRITE_STRIP_ALPHA */ -# endif -# ifndef PNG_NO_WRITE_SWAP_ALPHA -# define PNG_WRITE_SWAP_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_INVERT_ALPHA -# define PNG_WRITE_INVERT_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_USER_TRANSFORM -# define PNG_WRITE_USER_TRANSFORM_SUPPORTED -# endif -#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */ - -#if !defined(PNG_NO_WRITE_INTERLACING_SUPPORTED) && \ - !defined(PNG_WRITE_INTERLACING_SUPPORTED) -#define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant - encoders, but can cause trouble - if left undefined */ -#endif - -#if !defined(PNG_NO_WRITE_WEIGHTED_FILTER) && \ - !defined(PNG_WRITE_WEIGHTED_FILTER) && \ - defined(PNG_FLOATING_POINT_SUPPORTED) -# define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED -#endif - -#ifndef PNG_NO_WRITE_FLUSH -# define PNG_WRITE_FLUSH_SUPPORTED -#endif - -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* Deprecated, see PNG_MNG_FEATURES_SUPPORTED, above */ -#ifndef PNG_NO_WRITE_EMPTY_PLTE -# define PNG_WRITE_EMPTY_PLTE_SUPPORTED -#endif -#endif - -#endif /* PNG_WRITE_SUPPORTED */ - -#ifndef PNG_1_0_X -# ifndef PNG_NO_ERROR_NUMBERS -# define PNG_ERROR_NUMBERS_SUPPORTED -# endif -#endif /* PNG_1_0_X */ - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) -# ifndef PNG_NO_USER_TRANSFORM_PTR -# define PNG_USER_TRANSFORM_PTR_SUPPORTED -# endif -#endif - -#ifndef PNG_NO_STDIO -# define PNG_TIME_RFC1123_SUPPORTED -#endif - -/* This adds extra functions in pngget.c for accessing data from the - * info pointer (added in version 0.99) - * png_get_image_width() - * png_get_image_height() - * png_get_bit_depth() - * png_get_color_type() - * png_get_compression_type() - * png_get_filter_type() - * png_get_interlace_type() - * png_get_pixel_aspect_ratio() - * png_get_pixels_per_meter() - * png_get_x_offset_pixels() - * png_get_y_offset_pixels() - * png_get_x_offset_microns() - * png_get_y_offset_microns() - */ -#if !defined(PNG_NO_EASY_ACCESS) && !defined(PNG_EASY_ACCESS_SUPPORTED) -# define PNG_EASY_ACCESS_SUPPORTED -#endif - -/* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0 - * even when PNG_USE_PNGVCRD or PNG_USE_PNGGCCRD is not defined. - * - * PNG_NO_ASSEMBLER_CODE disables use of all assembler code and optimized C, - * and removes or includes several functions in the API. - * - * PNG_NO_MMX_CODE disables the use of MMX code without changing the API. - * When MMX code is off, then optimized C replacement functions are used. -*/ -#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_ASSEMBLER_CODE) -# ifndef PNG_ASSEMBLER_CODE_SUPPORTED -# define PNG_ASSEMBLER_CODE_SUPPORTED -# endif -# if (defined(XP_MACOSX) || defined(__x86_64__)) && !defined(PNG_NO_MMX_CODE) - /* work around Intel-Mac compiler bug and x86-64 linking */ -# define PNG_NO_MMX_CODE -# endif -# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) && \ - defined(__MMX__) -# define PNG_MMX_CODE_SUPPORTED -# endif -# if !defined(PNG_USE_PNGGCCRD) && !defined(PNG_NO_MMX_CODE) && \ - !defined(PNG_USE_PNGVCRD) && defined(__MMX__) -# define PNG_USE_PNGGCCRD -# endif -#endif - -/* If you are sure that you don't need thread safety and you are compiling - with PNG_USE_PNGCCRD for an MMX application, you can define this for - faster execution. See pnggccrd.c. -#define PNG_THREAD_UNSAFE_OK -*/ - -#if !defined(PNG_1_0_X) -#if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED) -# define PNG_USER_MEM_SUPPORTED -#endif -#endif /* PNG_1_0_X */ - -/* Added at libpng-1.2.6 */ -#if !defined(PNG_1_0_X) -#ifndef PNG_SET_USER_LIMITS_SUPPORTED -#if !defined(PNG_NO_SET_USER_LIMITS) && !defined(PNG_SET_USER_LIMITS_SUPPORTED) -# define PNG_SET_USER_LIMITS_SUPPORTED -#endif -#endif -#endif /* PNG_1_0_X */ - -/* Added at libpng-1.0.16 and 1.2.6. To accept all valid PNGS no matter - * how large, set these limits to 0x7fffffffL - */ -#ifndef PNG_USER_WIDTH_MAX -# define PNG_USER_WIDTH_MAX 1000000L -#endif -#ifndef PNG_USER_HEIGHT_MAX -# define PNG_USER_HEIGHT_MAX 1000000L -#endif - -/* These are currently experimental features, define them if you want */ - -/* very little testing */ -/* -#ifdef PNG_READ_SUPPORTED -# ifndef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED -# define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED -# endif -#endif -*/ - -/* This is only for PowerPC big-endian and 680x0 systems */ -/* some testing */ -/* -#ifndef PNG_READ_BIG_ENDIAN_SUPPORTED -# define PNG_READ_BIG_ENDIAN_SUPPORTED -#endif -*/ - -/* Buggy compilers (e.g., gcc 2.7.2.2) need this */ -/* -#define PNG_NO_POINTER_INDEXING -*/ - -/* These functions are turned off by default, as they will be phased out. */ -/* -#define PNG_USELESS_TESTS_SUPPORTED -#define PNG_CORRECT_PALETTE_SUPPORTED -*/ - -/* Any chunks you are not interested in, you can undef here. The - * ones that allocate memory may be expecially important (hIST, - * tEXt, zTXt, tRNS, pCAL). Others will just save time and make png_info - * a bit smaller. - */ - -#if defined(PNG_READ_SUPPORTED) && \ - !defined(PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \ - !defined(PNG_NO_READ_ANCILLARY_CHUNKS) -# define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED -#endif - -#if defined(PNG_WRITE_SUPPORTED) && \ - !defined(PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \ - !defined(PNG_NO_WRITE_ANCILLARY_CHUNKS) -# define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED -#endif - -#ifdef PNG_READ_ANCILLARY_CHUNKS_SUPPORTED - -#ifdef PNG_NO_READ_TEXT -# define PNG_NO_READ_iTXt -# define PNG_NO_READ_tEXt -# define PNG_NO_READ_zTXt -#endif -#ifndef PNG_NO_READ_bKGD -# define PNG_READ_bKGD_SUPPORTED -# define PNG_bKGD_SUPPORTED -#endif -#ifndef PNG_NO_READ_cHRM -# define PNG_READ_cHRM_SUPPORTED -# define PNG_cHRM_SUPPORTED -#endif -#ifndef PNG_NO_READ_gAMA -# define PNG_READ_gAMA_SUPPORTED -# define PNG_gAMA_SUPPORTED -#endif -#ifndef PNG_NO_READ_hIST -# define PNG_READ_hIST_SUPPORTED -# define PNG_hIST_SUPPORTED -#endif -#ifndef PNG_NO_READ_iCCP -# define PNG_READ_iCCP_SUPPORTED -# define PNG_iCCP_SUPPORTED -#endif -#ifndef PNG_NO_READ_iTXt -# ifndef PNG_READ_iTXt_SUPPORTED -# define PNG_READ_iTXt_SUPPORTED -# endif -# ifndef PNG_iTXt_SUPPORTED -# define PNG_iTXt_SUPPORTED -# endif -#endif -#ifndef PNG_NO_READ_oFFs -# define PNG_READ_oFFs_SUPPORTED -# define PNG_oFFs_SUPPORTED -#endif -#ifndef PNG_NO_READ_pCAL -# define PNG_READ_pCAL_SUPPORTED -# define PNG_pCAL_SUPPORTED -#endif -#ifndef PNG_NO_READ_sCAL -# define PNG_READ_sCAL_SUPPORTED -# define PNG_sCAL_SUPPORTED -#endif -#ifndef PNG_NO_READ_pHYs -# define PNG_READ_pHYs_SUPPORTED -# define PNG_pHYs_SUPPORTED -#endif -#ifndef PNG_NO_READ_sBIT -# define PNG_READ_sBIT_SUPPORTED -# define PNG_sBIT_SUPPORTED -#endif -#ifndef PNG_NO_READ_sPLT -# define PNG_READ_sPLT_SUPPORTED -# define PNG_sPLT_SUPPORTED -#endif -#ifndef PNG_NO_READ_sRGB -# define PNG_READ_sRGB_SUPPORTED -# define PNG_sRGB_SUPPORTED -#endif -#ifndef PNG_NO_READ_tEXt -# define PNG_READ_tEXt_SUPPORTED -# define PNG_tEXt_SUPPORTED -#endif -#ifndef PNG_NO_READ_tIME -# define PNG_READ_tIME_SUPPORTED -# define PNG_tIME_SUPPORTED -#endif -#ifndef PNG_NO_READ_tRNS -# define PNG_READ_tRNS_SUPPORTED -# define PNG_tRNS_SUPPORTED -#endif -#ifndef PNG_NO_READ_zTXt -# define PNG_READ_zTXt_SUPPORTED -# define PNG_zTXt_SUPPORTED -#endif -#ifndef PNG_NO_READ_UNKNOWN_CHUNKS -# define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED -# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED -# define PNG_UNKNOWN_CHUNKS_SUPPORTED -# endif -# ifndef PNG_NO_HANDLE_AS_UNKNOWN -# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED -# endif -#endif -#if !defined(PNG_NO_READ_USER_CHUNKS) && \ - defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) -# define PNG_READ_USER_CHUNKS_SUPPORTED -# define PNG_USER_CHUNKS_SUPPORTED -# ifdef PNG_NO_READ_UNKNOWN_CHUNKS -# undef PNG_NO_READ_UNKNOWN_CHUNKS -# endif -# ifdef PNG_NO_HANDLE_AS_UNKNOWN -# undef PNG_NO_HANDLE_AS_UNKNOWN -# endif -#endif -#ifndef PNG_NO_READ_OPT_PLTE -# define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */ -#endif /* optional PLTE chunk in RGB and RGBA images */ -#if defined(PNG_READ_iTXt_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) || \ - defined(PNG_READ_zTXt_SUPPORTED) -# define PNG_READ_TEXT_SUPPORTED -# define PNG_TEXT_SUPPORTED -#endif - -#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */ - -#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED - -#ifdef PNG_NO_WRITE_TEXT -# define PNG_NO_WRITE_iTXt -# define PNG_NO_WRITE_tEXt -# define PNG_NO_WRITE_zTXt -#endif -#ifndef PNG_NO_WRITE_bKGD -# define PNG_WRITE_bKGD_SUPPORTED -# ifndef PNG_bKGD_SUPPORTED -# define PNG_bKGD_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_cHRM -# define PNG_WRITE_cHRM_SUPPORTED -# ifndef PNG_cHRM_SUPPORTED -# define PNG_cHRM_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_gAMA -# define PNG_WRITE_gAMA_SUPPORTED -# ifndef PNG_gAMA_SUPPORTED -# define PNG_gAMA_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_hIST -# define PNG_WRITE_hIST_SUPPORTED -# ifndef PNG_hIST_SUPPORTED -# define PNG_hIST_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_iCCP -# define PNG_WRITE_iCCP_SUPPORTED -# ifndef PNG_iCCP_SUPPORTED -# define PNG_iCCP_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_iTXt -# ifndef PNG_WRITE_iTXt_SUPPORTED -# define PNG_WRITE_iTXt_SUPPORTED -# endif -# ifndef PNG_iTXt_SUPPORTED -# define PNG_iTXt_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_oFFs -# define PNG_WRITE_oFFs_SUPPORTED -# ifndef PNG_oFFs_SUPPORTED -# define PNG_oFFs_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_pCAL -# define PNG_WRITE_pCAL_SUPPORTED -# ifndef PNG_pCAL_SUPPORTED -# define PNG_pCAL_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_sCAL -# define PNG_WRITE_sCAL_SUPPORTED -# ifndef PNG_sCAL_SUPPORTED -# define PNG_sCAL_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_pHYs -# define PNG_WRITE_pHYs_SUPPORTED -# ifndef PNG_pHYs_SUPPORTED -# define PNG_pHYs_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_sBIT -# define PNG_WRITE_sBIT_SUPPORTED -# ifndef PNG_sBIT_SUPPORTED -# define PNG_sBIT_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_sPLT -# define PNG_WRITE_sPLT_SUPPORTED -# ifndef PNG_sPLT_SUPPORTED -# define PNG_sPLT_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_sRGB -# define PNG_WRITE_sRGB_SUPPORTED -# ifndef PNG_sRGB_SUPPORTED -# define PNG_sRGB_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_tEXt -# define PNG_WRITE_tEXt_SUPPORTED -# ifndef PNG_tEXt_SUPPORTED -# define PNG_tEXt_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_tIME -# define PNG_WRITE_tIME_SUPPORTED -# ifndef PNG_tIME_SUPPORTED -# define PNG_tIME_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_tRNS -# define PNG_WRITE_tRNS_SUPPORTED -# ifndef PNG_tRNS_SUPPORTED -# define PNG_tRNS_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_zTXt -# define PNG_WRITE_zTXt_SUPPORTED -# ifndef PNG_zTXt_SUPPORTED -# define PNG_zTXt_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS -# define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED -# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED -# define PNG_UNKNOWN_CHUNKS_SUPPORTED -# endif -# ifndef PNG_NO_HANDLE_AS_UNKNOWN -# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED -# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED -# endif -# endif -#endif -#if defined(PNG_WRITE_iTXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \ - defined(PNG_WRITE_zTXt_SUPPORTED) -# define PNG_WRITE_TEXT_SUPPORTED -# ifndef PNG_TEXT_SUPPORTED -# define PNG_TEXT_SUPPORTED -# endif -#endif - -#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */ - -/* Turn this off to disable png_read_png() and - * png_write_png() and leave the row_pointers member - * out of the info structure. - */ -#ifndef PNG_NO_INFO_IMAGE -# define PNG_INFO_IMAGE_SUPPORTED -#endif - -/* need the time information for reading tIME chunks */ -#if defined(PNG_tIME_SUPPORTED) -# if !defined(_WIN32_WCE) - /* "time.h" functions are not supported on WindowsCE */ -# include <time.h> -# endif -#endif - -/* Some typedefs to get us started. These should be safe on most of the - * common platforms. The typedefs should be at least as large as the - * numbers suggest (a png_uint_32 must be at least 32 bits long), but they - * don't have to be exactly that size. Some compilers dislike passing - * unsigned shorts as function parameters, so you may be better off using - * unsigned int for png_uint_16. Likewise, for 64-bit systems, you may - * want to have unsigned int for png_uint_32 instead of unsigned long. - */ - -typedef unsigned int png_uint_32; -typedef int png_int_32; -typedef unsigned short png_uint_16; -typedef short png_int_16; -typedef unsigned char png_byte; - -/* This is usually size_t. It is typedef'ed just in case you need it to - change (I'm not sure if you will or not, so I thought I'd be safe) */ -#ifdef PNG_SIZE_T - typedef PNG_SIZE_T png_size_t; -# define png_sizeof(x) png_convert_size(sizeof (x)) -#else - typedef size_t png_size_t; -# define png_sizeof(x) sizeof (x) -#endif - -/* The following is needed for medium model support. It cannot be in the - * PNG_INTERNAL section. Needs modification for other compilers besides - * MSC. Model independent support declares all arrays and pointers to be - * large using the far keyword. The zlib version used must also support - * model independent data. As of version zlib 1.0.4, the necessary changes - * have been made in zlib. The USE_FAR_KEYWORD define triggers other - * changes that are needed. (Tim Wegner) - */ - -/* Separate compiler dependencies (problem here is that zlib.h always - defines FAR. (SJT) */ -#ifdef __BORLANDC__ -# if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__) -# define LDATA 1 -# else -# define LDATA 0 -# endif - /* GRR: why is Cygwin in here? Cygwin is not Borland C... */ -# if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__) -# define PNG_MAX_MALLOC_64K -# if (LDATA != 1) -# ifndef FAR -# define FAR __far -# endif -# define USE_FAR_KEYWORD -# endif /* LDATA != 1 */ - /* Possibly useful for moving data out of default segment. - * Uncomment it if you want. Could also define FARDATA as - * const if your compiler supports it. (SJT) -# define FARDATA FAR - */ -# endif /* __WIN32__, __FLAT__, __CYGWIN__ */ -#endif /* __BORLANDC__ */ - - -/* Suggest testing for specific compiler first before testing for - * FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM, - * making reliance oncertain keywords suspect. (SJT) - */ - -/* MSC Medium model */ -#if defined(FAR) -# if defined(M_I86MM) -# define USE_FAR_KEYWORD -# define FARDATA FAR -# include <dos.h> -# endif -#endif - -/* SJT: default case */ -#ifndef FAR -# define FAR -#endif - -/* At this point FAR is always defined */ -#ifndef FARDATA -# define FARDATA -#endif - -/* Typedef for floating-point numbers that are converted - to fixed-point with a multiple of 100,000, e.g., int_gamma */ -typedef png_int_32 png_fixed_point; - -/* Add typedefs for pointers */ -typedef void FAR * png_voidp; -typedef png_byte FAR * png_bytep; -typedef png_uint_32 FAR * png_uint_32p; -typedef png_int_32 FAR * png_int_32p; -typedef png_uint_16 FAR * png_uint_16p; -typedef png_int_16 FAR * png_int_16p; -typedef PNG_CONST char FAR * png_const_charp; -typedef char FAR * png_charp; -typedef png_fixed_point FAR * png_fixed_point_p; - -#ifndef PNG_NO_STDIO -#if defined(_WIN32_WCE) -typedef HANDLE png_FILE_p; -#else -typedef FILE * png_FILE_p; -#endif -#endif - -#ifdef PNG_FLOATING_POINT_SUPPORTED -typedef double FAR * png_doublep; -#endif - -/* Pointers to pointers; i.e. arrays */ -typedef png_byte FAR * FAR * png_bytepp; -typedef png_uint_32 FAR * FAR * png_uint_32pp; -typedef png_int_32 FAR * FAR * png_int_32pp; -typedef png_uint_16 FAR * FAR * png_uint_16pp; -typedef png_int_16 FAR * FAR * png_int_16pp; -typedef PNG_CONST char FAR * FAR * png_const_charpp; -typedef char FAR * FAR * png_charpp; -typedef png_fixed_point FAR * FAR * png_fixed_point_pp; -#ifdef PNG_FLOATING_POINT_SUPPORTED -typedef double FAR * FAR * png_doublepp; -#endif - -/* Pointers to pointers to pointers; i.e., pointer to array */ -typedef char FAR * FAR * FAR * png_charppp; - -#if defined(PNG_1_0_X) || defined(PNG_1_2_X) -/* SPC - Is this stuff deprecated? */ -/* It'll be removed as of libpng-1.3.0 - GR-P */ -/* libpng typedefs for types in zlib. If zlib changes - * or another compression library is used, then change these. - * Eliminates need to change all the source files. - */ -typedef charf * png_zcharp; -typedef charf * FAR * png_zcharpp; -typedef z_stream FAR * png_zstreamp; -#endif /* (PNG_1_0_X) || defined(PNG_1_2_X) */ - -/* - * Define PNG_BUILD_DLL if the module being built is a Windows - * LIBPNG DLL. - * - * Define PNG_USE_DLL if you want to *link* to the Windows LIBPNG DLL. - * It is equivalent to Microsoft predefined macro _DLL that is - * automatically defined when you compile using the share - * version of the CRT (C Run-Time library) - * - * The cygwin mods make this behavior a little different: - * Define PNG_BUILD_DLL if you are building a dll for use with cygwin - * Define PNG_STATIC if you are building a static library for use with cygwin, - * -or- if you are building an application that you want to link to the - * static library. - * PNG_USE_DLL is defined by default (no user action needed) unless one of - * the other flags is defined. - */ - -#if !defined(PNG_DLL) && (defined(PNG_BUILD_DLL) || defined(PNG_USE_DLL)) -# define PNG_DLL -#endif -/* If CYGWIN, then disallow GLOBAL ARRAYS unless building a static lib. - * When building a static lib, default to no GLOBAL ARRAYS, but allow - * command-line override - */ -#if defined(__CYGWIN__) -# if !defined(PNG_STATIC) -# if defined(PNG_USE_GLOBAL_ARRAYS) -# undef PNG_USE_GLOBAL_ARRAYS -# endif -# if !defined(PNG_USE_LOCAL_ARRAYS) -# define PNG_USE_LOCAL_ARRAYS -# endif -# else -# if defined(PNG_USE_LOCAL_ARRAYS) || defined(PNG_NO_GLOBAL_ARRAYS) -# if defined(PNG_USE_GLOBAL_ARRAYS) -# undef PNG_USE_GLOBAL_ARRAYS -# endif -# endif -# endif -# if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS) -# define PNG_USE_LOCAL_ARRAYS -# endif -#endif - -/* Do not use global arrays (helps with building DLL's) - * They are no longer used in libpng itself, since version 1.0.5c, - * but might be required for some pre-1.0.5c applications. - */ -#if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS) -# if defined(PNG_NO_GLOBAL_ARRAYS) || (defined(__GNUC__) && defined(PNG_DLL)) -# define PNG_USE_LOCAL_ARRAYS -# else -# define PNG_USE_GLOBAL_ARRAYS -# endif -#endif - -#if defined(__CYGWIN__) -# undef PNGAPI -# define PNGAPI __cdecl -# undef PNG_IMPEXP -# define PNG_IMPEXP -#endif - -/* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall", - * you may get warnings regarding the linkage of png_zalloc and png_zfree. - * Don't ignore those warnings; you must also reset the default calling - * convention in your compiler to match your PNGAPI, and you must build - * zlib and your applications the same way you build libpng. - */ - -#if defined(__MINGW32__) && !defined(PNG_MODULEDEF) -# ifndef PNG_NO_MODULEDEF -# define PNG_NO_MODULEDEF -# endif -#endif - -#if !defined(PNG_IMPEXP) && defined(PNG_BUILD_DLL) && !defined(PNG_NO_MODULEDEF) -# define PNG_IMPEXP -#endif - -#if defined(PNG_DLL) || defined(_DLL) || defined(__DLL__ ) || \ - (( defined(_Windows) || defined(_WINDOWS) || \ - defined(WIN32) || defined(_WIN32) || defined(__WIN32__) )) - -# ifndef PNGAPI -# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800)) -# define PNGAPI __cdecl -# else -# define PNGAPI _cdecl -# endif -# endif - -# if !defined(PNG_IMPEXP) && (!defined(PNG_DLL) || \ - 0 /* WINCOMPILER_WITH_NO_SUPPORT_FOR_DECLIMPEXP */) -# define PNG_IMPEXP -# endif - -# if !defined(PNG_IMPEXP) - -# define PNG_EXPORT_TYPE1(type,symbol) PNG_IMPEXP type PNGAPI symbol -# define PNG_EXPORT_TYPE2(type,symbol) type PNG_IMPEXP PNGAPI symbol - - /* Borland/Microsoft */ -# if defined(_MSC_VER) || defined(__BORLANDC__) -# if (_MSC_VER >= 800) || (__BORLANDC__ >= 0x500) -# define PNG_EXPORT PNG_EXPORT_TYPE1 -# else -# define PNG_EXPORT PNG_EXPORT_TYPE2 -# if defined(PNG_BUILD_DLL) -# define PNG_IMPEXP __export -# else -# define PNG_IMPEXP /*__import */ /* doesn't exist AFAIK in - VC++ */ -# endif /* Exists in Borland C++ for - C++ classes (== huge) */ -# endif -# endif - -# if !defined(PNG_IMPEXP) -# if defined(PNG_BUILD_DLL) -# define PNG_IMPEXP __declspec(dllexport) -# else -# define PNG_IMPEXP __declspec(dllimport) -# endif -# endif -# endif /* PNG_IMPEXP */ -#else /* !(DLL || non-cygwin WINDOWS) */ -# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__) -# ifndef PNGAPI -# define PNGAPI _System -# endif -# else -# if 0 /* ... other platforms, with other meanings */ -# endif -# endif -#endif - -#ifndef PNGAPI -# define PNGAPI -#endif -#ifndef PNG_IMPEXP -# define PNG_IMPEXP -#endif - -#ifdef PNG_BUILDSYMS -# ifndef PNG_EXPORT -# define PNG_EXPORT(type,symbol) PNG_FUNCTION_EXPORT symbol END -# endif -# ifdef PNG_USE_GLOBAL_ARRAYS -# ifndef PNG_EXPORT_VAR -# define PNG_EXPORT_VAR(type) PNG_DATA_EXPORT -# endif -# endif -#endif - -#ifndef PNG_EXPORT -# define PNG_EXPORT(type,symbol) PNG_IMPEXP type PNGAPI symbol -#endif - -#ifdef PNG_USE_GLOBAL_ARRAYS -# ifndef PNG_EXPORT_VAR -# define PNG_EXPORT_VAR(type) extern PNG_IMPEXP type -# endif -#endif - -/* User may want to use these so they are not in PNG_INTERNAL. Any library - * functions that are passed far data must be model independent. - */ - -#ifndef PNG_ABORT -# define PNG_ABORT() abort() -#endif - -#ifdef PNG_SETJMP_SUPPORTED -# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) -#else -# define png_jmpbuf(png_ptr) \ - (LIBPNG_WAS_COMPILED_WITH__PNG_SETJMP_NOT_SUPPORTED) -#endif - -#if defined(USE_FAR_KEYWORD) /* memory model independent fns */ -/* use this to make far-to-near assignments */ -# define CHECK 1 -# define NOCHECK 0 -# define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK)) -# define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK)) -# define png_strcpy _fstrcpy -# define png_strncpy _fstrncpy /* Added to v 1.2.6 */ -# define png_strlen _fstrlen -# define png_memcmp _fmemcmp /* SJT: added */ -# define png_memcpy _fmemcpy -# define png_memset _fmemset -#else /* use the usual functions */ -# define CVT_PTR(ptr) (ptr) -# define CVT_PTR_NOCHECK(ptr) (ptr) -# define png_strcpy strcpy -# define png_strncpy strncpy /* Added to v 1.2.6 */ -# define png_strlen strlen -# define png_memcmp memcmp /* SJT: added */ -# define png_memcpy memcpy -# define png_memset memset -#endif -/* End of memory model independent support */ - -/* Just a little check that someone hasn't tried to define something - * contradictory. - */ -#if (PNG_ZBUF_SIZE > 65536L) && defined(PNG_MAX_MALLOC_64K) -# undef PNG_ZBUF_SIZE -# define PNG_ZBUF_SIZE 65536L -#endif - -#ifdef PNG_READ_SUPPORTED -/* Prior to libpng-1.0.9, this block was in pngasmrd.h */ -#if defined(PNG_INTERNAL) - -/* These are the default thresholds before the MMX code kicks in; if either - * rowbytes or bitdepth is below the threshold, plain C code is used. These - * can be overridden at runtime via the png_set_mmx_thresholds() call in - * libpng 1.2.0 and later. The values below were chosen by Intel. - */ - -#ifndef PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT -# define PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT 128 /* >= */ -#endif -#ifndef PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT -# define PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT 9 /* >= */ -#endif - -/* Set this in the makefile for VC++ on Pentium, not here. */ -/* Platform must be Pentium. Makefile must assemble and load pngvcrd.c . - * MMX will be detected at run time and used if present. - */ -#ifdef PNG_USE_PNGVCRD -# define PNG_HAVE_MMX_COMBINE_ROW -# define PNG_HAVE_MMX_READ_INTERLACE -# define PNG_HAVE_MMX_READ_FILTER_ROW -#endif - -/* Set this in the makefile for gcc/as on Pentium, not here. */ -/* Platform must be Pentium. Makefile must assemble and load pnggccrd.c . - * MMX will be detected at run time and used if present. - */ -#ifdef PNG_USE_PNGGCCRD -# define PNG_HAVE_MMX_COMBINE_ROW -# define PNG_HAVE_MMX_READ_INTERLACE -# define PNG_HAVE_MMX_READ_FILTER_ROW -#endif -/* - see pnggccrd.c for info about what is currently enabled */ - -#endif /* PNG_INTERNAL */ -#endif /* PNG_READ_SUPPORTED */ - -/* Added at libpng-1.2.8 */ -#endif /* PNG_VERSION_INFO_ONLY */ - -#endif /* PNGCONF_H */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/pngerror.c b/irrlicht-1.6/source/Irrlicht/libpng/pngerror.c deleted file mode 100644 index 4857133e8..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/pngerror.c +++ /dev/null @@ -1,320 +0,0 @@ - -/* pngerror.c - stub functions for i/o and memory allocation - * - * Last changed in libpng 1.2.13 November 13, 2006 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2006 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This file provides a location for all error handling. Users who - * need special error handling are expected to write replacement functions - * and use png_set_error_fn() to use those functions. See the instructions - * at each function. - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) -static void /* PRIVATE */ -png_default_error PNGARG((png_structp png_ptr, - png_const_charp error_message)); -static void /* PRIVATE */ -png_default_warning PNGARG((png_structp png_ptr, - png_const_charp warning_message)); - -/* This function is called whenever there is a fatal error. This function - * should not be changed. If there is a need to handle errors differently, - * you should supply a replacement error function and use png_set_error_fn() - * to replace the error function at run-time. - */ -void PNGAPI -png_error(png_structp png_ptr, png_const_charp error_message) -{ -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - char msg[16]; - if (png_ptr != NULL) - { - if (png_ptr->flags& - (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) - { - if (*error_message == '#') - { - int offset; - for (offset=1; offset<15; offset++) - if (*(error_message+offset) == ' ') - break; - if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT) - { - int i; - for (i=0; i<offset-1; i++) - msg[i]=error_message[i+1]; - msg[i]='\0'; - error_message=msg; - } - else - error_message+=offset; - } - else - { - if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT) - { - msg[0]='0'; - msg[1]='\0'; - error_message=msg; - } - } - } - } -#endif - if (png_ptr != NULL && png_ptr->error_fn != NULL) - (*(png_ptr->error_fn))(png_ptr, error_message); - - /* If the custom handler doesn't exist, or if it returns, - use the default handler, which will not return. */ - png_default_error(png_ptr, error_message); -} - -/* This function is called whenever there is a non-fatal error. This function - * should not be changed. If there is a need to handle warnings differently, - * you should supply a replacement warning function and use - * png_set_error_fn() to replace the warning function at run-time. - */ -void PNGAPI -png_warning(png_structp png_ptr, png_const_charp warning_message) -{ - int offset = 0; - if (png_ptr != NULL) - { -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - if (png_ptr->flags& - (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) -#endif - { - if (*warning_message == '#') - { - for (offset=1; offset<15; offset++) - if (*(warning_message+offset) == ' ') - break; - } - } - if (png_ptr != NULL && png_ptr->warning_fn != NULL) - (*(png_ptr->warning_fn))(png_ptr, warning_message+offset); - } - else - png_default_warning(png_ptr, warning_message+offset); -} - -/* These utilities are used internally to build an error message that relates - * to the current chunk. The chunk name comes from png_ptr->chunk_name, - * this is used to prefix the message. The message is limited in length - * to 63 bytes, the name characters are output as hex digits wrapped in [] - * if the character is invalid. - */ -#define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97)) -static PNG_CONST char png_digit[16] = { - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - 'A', 'B', 'C', 'D', 'E', 'F' -}; - -static void /* PRIVATE */ -png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp - error_message) -{ - int iout = 0, iin = 0; - - while (iin < 4) - { - int c = png_ptr->chunk_name[iin++]; - if (isnonalpha(c)) - { - buffer[iout++] = '['; - buffer[iout++] = png_digit[(c & 0xf0) >> 4]; - buffer[iout++] = png_digit[c & 0x0f]; - buffer[iout++] = ']'; - } - else - { - buffer[iout++] = (png_byte)c; - } - } - - if (error_message == NULL) - buffer[iout] = 0; - else - { - buffer[iout++] = ':'; - buffer[iout++] = ' '; - png_strncpy(buffer+iout, error_message, 63); - buffer[iout+63] = 0; - } -} - -void PNGAPI -png_chunk_error(png_structp png_ptr, png_const_charp error_message) -{ - char msg[18+64]; - if (png_ptr == NULL) - png_error(png_ptr, error_message); - else - { - png_format_buffer(png_ptr, msg, error_message); - png_error(png_ptr, msg); - } -} - -void PNGAPI -png_chunk_warning(png_structp png_ptr, png_const_charp warning_message) -{ - char msg[18+64]; - if (png_ptr == NULL) - png_warning(png_ptr, warning_message); - else - { - png_format_buffer(png_ptr, msg, warning_message); - png_warning(png_ptr, msg); - } -} - -/* This is the default error handling function. Note that replacements for - * this function MUST NOT RETURN, or the program will likely crash. This - * function is used by default, or if the program supplies NULL for the - * error function pointer in png_set_error_fn(). - */ -static void /* PRIVATE */ -png_default_error(png_structp png_ptr, png_const_charp error_message) -{ -#ifndef PNG_NO_CONSOLE_IO -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - if (*error_message == '#') - { - int offset; - char error_number[16]; - for (offset=0; offset<15; offset++) - { - error_number[offset] = *(error_message+offset+1); - if (*(error_message+offset) == ' ') - break; - } - if((offset > 1) && (offset < 15)) - { - error_number[offset-1]='\0'; - fprintf(stderr, "libpng error no. %s: %s\n", error_number, - error_message+offset); - } - else - fprintf(stderr, "libpng error: %s, offset=%d\n", error_message,offset); - } - else -#endif - fprintf(stderr, "libpng error: %s\n", error_message); -#endif - -#ifdef PNG_SETJMP_SUPPORTED - if (png_ptr) - { -# ifdef USE_FAR_KEYWORD - { - jmp_buf jmpbuf; - png_memcpy(jmpbuf,png_ptr->jmpbuf,png_sizeof(jmp_buf)); - longjmp(jmpbuf, 1); - } -# else - longjmp(png_ptr->jmpbuf, 1); -# endif - } -#else - PNG_ABORT(); -#endif -#ifdef PNG_NO_CONSOLE_IO - /* make compiler happy */ ; - if (&error_message != NULL) - return; -#endif -} - -/* This function is called when there is a warning, but the library thinks - * it can continue anyway. Replacement functions don't have to do anything - * here if you don't want them to. In the default configuration, png_ptr is - * not used, but it is passed in case it may be useful. - */ -static void /* PRIVATE */ -png_default_warning(png_structp png_ptr, png_const_charp warning_message) -{ -#ifndef PNG_NO_CONSOLE_IO -# ifdef PNG_ERROR_NUMBERS_SUPPORTED - if (*warning_message == '#') - { - int offset; - char warning_number[16]; - for (offset=0; offset<15; offset++) - { - warning_number[offset]=*(warning_message+offset+1); - if (*(warning_message+offset) == ' ') - break; - } - if((offset > 1) && (offset < 15)) - { - warning_number[offset-1]='\0'; - fprintf(stderr, "libpng warning no. %s: %s\n", warning_number, - warning_message+offset); - } - else - fprintf(stderr, "libpng warning: %s\n", warning_message); - } - else -# endif - fprintf(stderr, "libpng warning: %s\n", warning_message); -#else - /* make compiler happy */ ; - if (warning_message) - return; -#endif - /* make compiler happy */ ; - if (png_ptr) - return; -} - -/* This function is called when the application wants to use another method - * of handling errors and warnings. Note that the error function MUST NOT - * return to the calling routine or serious problems will occur. The return - * method used in the default routine calls longjmp(png_ptr->jmpbuf, 1) - */ -void PNGAPI -png_set_error_fn(png_structp png_ptr, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warning_fn) -{ - if (png_ptr == NULL) - return; - png_ptr->error_ptr = error_ptr; - png_ptr->error_fn = error_fn; - png_ptr->warning_fn = warning_fn; -} - - -/* This function returns a pointer to the error_ptr associated with the user - * functions. The application should free any memory associated with this - * pointer before png_write_destroy and png_read_destroy are called. - */ -png_voidp PNGAPI -png_get_error_ptr(png_structp png_ptr) -{ - if (png_ptr == NULL) - return NULL; - return ((png_voidp)png_ptr->error_ptr); -} - - -#ifdef PNG_ERROR_NUMBERS_SUPPORTED -void PNGAPI -png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode) -{ - if(png_ptr != NULL) - { - png_ptr->flags &= - ((~(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode); - } -} -#endif -#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/pnggccrd.c b/irrlicht-1.6/source/Irrlicht/libpng/pnggccrd.c deleted file mode 100644 index 08ab5e258..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/pnggccrd.c +++ /dev/null @@ -1,5420 +0,0 @@ - -/* pnggccrd.c - mixed C/assembler version of utilities to read a PNG file - * - * For Intel x86 CPU (Pentium-MMX or later) and GNU C compiler. - * - * See http://www.intel.com/drg/pentiumII/appnotes/916/916.htm - * and http://www.intel.com/drg/pentiumII/appnotes/923/923.htm - * for Intel's performance analysis of the MMX vs. non-MMX code. - * - * Last changed in libpng 1.2.15 January 5, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson - * Copyright (c) 1998, Intel Corporation - * - * Based on MSVC code contributed by Nirav Chhatrapati, Intel Corp., 1998. - * Interface to libpng contributed by Gilles Vollant, 1999. - * GNU C port by Greg Roelofs, 1999-2001. - * - * Lines 2350-4300 converted in place with intel2gas 1.3.1: - * - * intel2gas -mdI pnggccrd.c.partially-msvc -o pnggccrd.c - * - * and then cleaned up by hand. See http://hermes.terminal.at/intel2gas/ . - * - * NOTE: A sufficiently recent version of GNU as (or as.exe under DOS/Windows) - * is required to assemble the newer MMX instructions such as movq. - * For djgpp, see - * - * ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bnu281b.zip - * - * (or a later version in the same directory). For Linux, check your - * distribution's web site(s) or try these links: - * - * http://rufus.w3.org/linux/RPM/binutils.html - * http://www.debian.org/Packages/stable/devel/binutils.html - * ftp://ftp.slackware.com/pub/linux/slackware/slackware/slakware/d1/ - * binutils.tgz - * - * For other platforms, see the main GNU site: - * - * ftp://ftp.gnu.org/pub/gnu/binutils/ - * - * Version 2.5.2l.15 is definitely too old... - */ - -/* - * TEMPORARY PORTING NOTES AND CHANGELOG (mostly by Greg Roelofs) - * ===================================== - * - * 19991006: - * - fixed sign error in post-MMX cleanup code (16- & 32-bit cases) - * - * 19991007: - * - additional optimizations (possible or definite): - * x [DONE] write MMX code for 64-bit case (pixel_bytes == 8) [not tested] - * - write MMX code for 48-bit case (pixel_bytes == 6) - * - figure out what's up with 24-bit case (pixel_bytes == 3): - * why subtract 8 from width_mmx in the pass 4/5 case? - * (only width_mmx case) (near line 1606) - * x [DONE] replace pixel_bytes within each block with the true - * constant value (or are compilers smart enough to do that?) - * - rewrite all MMX interlacing code so it's aligned with - * the *beginning* of the row buffer, not the end. This - * would not only allow one to eliminate half of the memory - * writes for odd passes (that is, pass == odd), it may also - * eliminate some unaligned-data-access exceptions (assuming - * there's a penalty for not aligning 64-bit accesses on - * 64-bit boundaries). The only catch is that the "leftover" - * pixel(s) at the end of the row would have to be saved, - * but there are enough unused MMX registers in every case, - * so this is not a problem. A further benefit is that the - * post-MMX cleanup code (C code) in at least some of the - * cases could be done within the assembler block. - * x [DONE] the "v3 v2 v1 v0 v7 v6 v5 v4" comments are confusing, - * inconsistent, and don't match the MMX Programmer's Reference - * Manual conventions anyway. They should be changed to - * "b7 b6 b5 b4 b3 b2 b1 b0," where b0 indicates the byte that - * was lowest in memory (e.g., corresponding to a left pixel) - * and b7 is the byte that was highest (e.g., a right pixel). - * - * 19991016: - * - Brennan's Guide notwithstanding, gcc under Linux does *not* - * want globals prefixed by underscores when referencing them-- - * i.e., if the variable is const4, then refer to it as const4, - * not _const4. This seems to be a djgpp-specific requirement. - * Also, such variables apparently *must* be declared outside - * of functions; neither static nor automatic variables work if - * defined within the scope of a single function, but both - * static and truly global (multi-module) variables work fine. - * - * 19991023: - * - fixed png_combine_row() non-MMX replication bug (odd passes only?) - * - switched from string-concatenation-with-macros to cleaner method of - * renaming global variables for djgpp--i.e., always use prefixes in - * inlined assembler code (== strings) and conditionally rename the - * variables, not the other way around. Hence _const4, _mask8_0, etc. - * - * 19991024: - * - fixed mmxsupport()/png_do_read_interlace() first-row bug - * This one was severely weird: even though mmxsupport() doesn't touch - * ebx (where "row" pointer was stored), it nevertheless managed to zero - * the register (even in static/non-fPIC code--see below), which in turn - * caused png_do_read_interlace() to return prematurely on the first row of - * interlaced images (i.e., without expanding the interlaced pixels). - * Inspection of the generated assembly code didn't turn up any clues, - * although it did point at a minor optimization (i.e., get rid of - * mmx_supported_local variable and just use eax). Possibly the CPUID - * instruction is more destructive than it looks? (Not yet checked.) - * - "info gcc" was next to useless, so compared fPIC and non-fPIC assembly - * listings... Apparently register spillage has to do with ebx, since - * it's used to index the global offset table. Commenting it out of the - * input-reg lists in png_combine_row() eliminated compiler barfage, so - * ifdef'd with __PIC__ macro: if defined, use a global for unmask - * - * 19991107: - * - verified CPUID clobberage: 12-char string constant ("GenuineIntel", - * "AuthenticAMD", etc.) placed in ebx:ecx:edx. Still need to polish. - * - * 19991120: - * - made "diff" variable (now "_dif") global to simplify conversion of - * filtering routines (running out of regs, sigh). "diff" is still used - * in interlacing routines, however. - * - fixed up both versions of mmxsupport() (ORIG_THAT_USED_TO_CLOBBER_EBX - * macro determines which is used); original not yet tested. - * - * 20000213: - * - when compiling with gcc, be sure to use -fomit-frame-pointer - * - * 20000319: - * - fixed a register-name typo in png_do_read_interlace(), default (MMX) case, - * pass == 4 or 5, that caused visible corruption of interlaced images - * - * 20000623: - * - Various problems were reported with gcc 2.95.2 in the Cygwin environment, - * many of the form "forbidden register 0 (ax) was spilled for class AREG." - * This is explained at http://gcc.gnu.org/fom_serv/cache/23.html, and - * Chuck Wilson supplied a patch involving dummy output registers. See - * http://sourceforge.net/bugs/?func=detailbug&bug_id=108741&group_id=5624 - * for the original (anonymous) SourceForge bug report. - * - * 20000706: - * - Chuck Wilson passed along these remaining gcc 2.95.2 errors: - * pnggccrd.c: In function `png_combine_row': - * pnggccrd.c:525: more than 10 operands in `asm' - * pnggccrd.c:669: more than 10 operands in `asm' - * pnggccrd.c:828: more than 10 operands in `asm' - * pnggccrd.c:994: more than 10 operands in `asm' - * pnggccrd.c:1177: more than 10 operands in `asm' - * They are all the same problem and can be worked around by using the - * global _unmask variable unconditionally, not just in the -fPIC case. - * Reportedly earlier versions of gcc also have the problem with more than - * 10 operands; they just don't report it. Much strangeness ensues, etc. - * - * 20000729: - * - enabled png_read_filter_row_mmx_up() (shortest remaining unconverted - * MMX routine); began converting png_read_filter_row_mmx_sub() - * - to finish remaining sections: - * - clean up indentation and comments - * - preload local variables - * - add output and input regs (order of former determines numerical - * mapping of latter) - * - avoid all usage of ebx (including bx, bh, bl) register [20000823] - * - remove "$" from addressing of Shift and Mask variables [20000823] - * - * 20000731: - * - global union vars causing segfaults in png_read_filter_row_mmx_sub()? - * - * 20000822: - * - ARGH, stupid png_read_filter_row_mmx_sub() segfault only happens with - * shared-library (-fPIC) version! Code works just fine as part of static - * library. Damn damn damn damn damn, should have tested that sooner. - * ebx is getting clobbered again (explicitly this time); need to save it - * on stack or rewrite asm code to avoid using it altogether. Blargh! - * - * 20000823: - * - first section was trickiest; all remaining sections have ebx -> edx now. - * (-fPIC works again.) Also added missing underscores to various Shift* - * and *Mask* globals and got rid of leading "$" signs. - * - * 20000826: - * - added visual separators to help navigate microscopic printed copies - * (http://pobox.com/~newt/code/gpr-latest.zip, mode 10); started working - * on png_read_filter_row_mmx_avg() - * - * 20000828: - * - finished png_read_filter_row_mmx_avg(): only Paeth left! (930 lines...) - * What the hell, did png_read_filter_row_mmx_paeth(), too. Comments not - * cleaned up/shortened in either routine, but functionality is complete - * and seems to be working fine. - * - * 20000829: - * - ahhh, figured out last(?) bit of gcc/gas asm-fu: if register is listed - * as an input reg (with dummy output variables, etc.), then it *cannot* - * also appear in the clobber list or gcc 2.95.2 will barf. The solution - * is simple enough... - * - * 20000914: - * - bug in png_read_filter_row_mmx_avg(): 16-bit grayscale not handled - * correctly (but 48-bit RGB just fine) - * - * 20000916: - * - fixed bug in png_read_filter_row_mmx_avg(), bpp == 2 case; three errors: - * - "_ShiftBpp.use = 24;" should have been "_ShiftBpp.use = 16;" - * - "_ShiftRem.use = 40;" should have been "_ShiftRem.use = 48;" - * - "psllq _ShiftRem, %%mm2" should have been "psrlq _ShiftRem, %%mm2" - * - * 20010101: - * - added new png_init_mmx_flags() function (here only because it needs to - * call mmxsupport(), which should probably become global png_mmxsupport()); - * modified other MMX routines to run conditionally (png_ptr->asm_flags) - * - * 20010103: - * - renamed mmxsupport() to png_mmx_support(), with auto-set of mmx_supported, - * and made it public; moved png_init_mmx_flags() to png.c as internal func - * - * 20010104: - * - removed dependency on png_read_filter_row_c() (C code already duplicated - * within MMX version of png_read_filter_row()) so no longer necessary to - * compile it into pngrutil.o - * - * 20010310: - * - fixed buffer-overrun bug in png_combine_row() C code (non-MMX) - * - * 20020304: - * - eliminated incorrect use of width_mmx in pixel_bytes == 8 case - * - * 20040724: - * - more tinkering with clobber list at lines 4529 and 5033, to get - * it to compile on gcc-3.4. - * - * STILL TO DO: - * - test png_do_read_interlace() 64-bit case (pixel_bytes == 8) - * - write MMX code for 48-bit case (pixel_bytes == 6) - * - figure out what's up with 24-bit case (pixel_bytes == 3): - * why subtract 8 from width_mmx in the pass 4/5 case? - * (only width_mmx case) (near line 1606) - * - rewrite all MMX interlacing code so it's aligned with beginning - * of the row buffer, not the end (see 19991007 for details) - * x pick one version of mmxsupport() and get rid of the other - * - add error messages to any remaining bogus default cases - * - enable pixel_depth == 8 cases in png_read_filter_row()? (test speed) - * x add support for runtime enable/disable/query of various MMX routines - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_USE_PNGGCCRD) - -int PNGAPI png_mmx_support(void); - -#ifdef PNG_USE_LOCAL_ARRAYS -const static int FARDATA png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; -const static int FARDATA png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; -const static int FARDATA png_pass_width[7] = {8, 4, 4, 2, 2, 1, 1}; -#endif - -#if defined(PNG_MMX_CODE_SUPPORTED) -/* djgpp, Win32, Cygwin, and OS2 add their own underscores to global variables, - * so define them without: */ -#if defined(__DJGPP__) || defined(WIN32) || defined(__CYGWIN__) || \ - defined(__OS2__) -# define _mmx_supported mmx_supported -# define _const4 const4 -# define _const6 const6 -# define _mask8_0 mask8_0 -# define _mask16_1 mask16_1 -# define _mask16_0 mask16_0 -# define _mask24_2 mask24_2 -# define _mask24_1 mask24_1 -# define _mask24_0 mask24_0 -# define _mask32_3 mask32_3 -# define _mask32_2 mask32_2 -# define _mask32_1 mask32_1 -# define _mask32_0 mask32_0 -# define _mask48_5 mask48_5 -# define _mask48_4 mask48_4 -# define _mask48_3 mask48_3 -# define _mask48_2 mask48_2 -# define _mask48_1 mask48_1 -# define _mask48_0 mask48_0 -# define _LBCarryMask LBCarryMask -# define _HBClearMask HBClearMask -# define _ActiveMask ActiveMask -# define _ActiveMask2 ActiveMask2 -# define _ActiveMaskEnd ActiveMaskEnd -# define _ShiftBpp ShiftBpp -# define _ShiftRem ShiftRem -#ifdef PNG_THREAD_UNSAFE_OK -# define _unmask unmask -# define _FullLength FullLength -# define _MMXLength MMXLength -# define _dif dif -# define _patemp patemp -# define _pbtemp pbtemp -# define _pctemp pctemp -#endif -#endif - - -/* These constants are used in the inlined MMX assembly code. - Ignore gcc's "At top level: defined but not used" warnings. */ - -/* GRR 20000706: originally _unmask was needed only when compiling with -fPIC, - * since that case uses the %ebx register for indexing the Global Offset Table - * and there were no other registers available. But gcc 2.95 and later emit - * "more than 10 operands in `asm'" errors when %ebx is used to preload unmask - * in the non-PIC case, so we'll just use the global unconditionally now. - */ -#ifdef PNG_THREAD_UNSAFE_OK -static int _unmask; -#endif - -const static unsigned long long _mask8_0 = 0x0102040810204080LL; - -const static unsigned long long _mask16_1 = 0x0101020204040808LL; -const static unsigned long long _mask16_0 = 0x1010202040408080LL; - -const static unsigned long long _mask24_2 = 0x0101010202020404LL; -const static unsigned long long _mask24_1 = 0x0408080810101020LL; -const static unsigned long long _mask24_0 = 0x2020404040808080LL; - -const static unsigned long long _mask32_3 = 0x0101010102020202LL; -const static unsigned long long _mask32_2 = 0x0404040408080808LL; -const static unsigned long long _mask32_1 = 0x1010101020202020LL; -const static unsigned long long _mask32_0 = 0x4040404080808080LL; - -const static unsigned long long _mask48_5 = 0x0101010101010202LL; -const static unsigned long long _mask48_4 = 0x0202020204040404LL; -const static unsigned long long _mask48_3 = 0x0404080808080808LL; -const static unsigned long long _mask48_2 = 0x1010101010102020LL; -const static unsigned long long _mask48_1 = 0x2020202040404040LL; -const static unsigned long long _mask48_0 = 0x4040808080808080LL; - -const static unsigned long long _const4 = 0x0000000000FFFFFFLL; -//const static unsigned long long _const5 = 0x000000FFFFFF0000LL; // NOT USED -const static unsigned long long _const6 = 0x00000000000000FFLL; - -// These are used in the row-filter routines and should/would be local -// variables if not for gcc addressing limitations. -// WARNING: Their presence probably defeats the thread safety of libpng. - -#ifdef PNG_THREAD_UNSAFE_OK -static png_uint_32 _FullLength; -static png_uint_32 _MMXLength; -static int _dif; -static int _patemp; // temp variables for Paeth routine -static int _pbtemp; -static int _pctemp; -#endif - -void /* PRIVATE */ -png_squelch_warnings(void) -{ -#ifdef PNG_THREAD_UNSAFE_OK - _dif = _dif; - _patemp = _patemp; - _pbtemp = _pbtemp; - _pctemp = _pctemp; - _MMXLength = _MMXLength; -#endif - _const4 = _const4; - _const6 = _const6; - _mask8_0 = _mask8_0; - _mask16_1 = _mask16_1; - _mask16_0 = _mask16_0; - _mask24_2 = _mask24_2; - _mask24_1 = _mask24_1; - _mask24_0 = _mask24_0; - _mask32_3 = _mask32_3; - _mask32_2 = _mask32_2; - _mask32_1 = _mask32_1; - _mask32_0 = _mask32_0; - _mask48_5 = _mask48_5; - _mask48_4 = _mask48_4; - _mask48_3 = _mask48_3; - _mask48_2 = _mask48_2; - _mask48_1 = _mask48_1; - _mask48_0 = _mask48_0; -} -#endif /* PNG_MMX_CODE_SUPPORTED */ - - -static int _mmx_supported = 2; - -/*===========================================================================*/ -/* */ -/* P N G _ C O M B I N E _ R O W */ -/* */ -/*===========================================================================*/ - -#if defined(PNG_HAVE_MMX_COMBINE_ROW) - -#define BPP2 2 -#define BPP3 3 /* bytes per pixel (a.k.a. pixel_bytes) */ -#define BPP4 4 -#define BPP6 6 /* (defined only to help avoid cut-and-paste errors) */ -#define BPP8 8 - -/* Combines the row recently read in with the previous row. - This routine takes care of alpha and transparency if requested. - This routine also handles the two methods of progressive display - of interlaced images, depending on the mask value. - The mask value describes which pixels are to be combined with - the row. The pattern always repeats every 8 pixels, so just 8 - bits are needed. A one indicates the pixel is to be combined; a - zero indicates the pixel is to be skipped. This is in addition - to any alpha or transparency value associated with the pixel. - If you want all pixels to be combined, pass 0xff (255) in mask. */ - -/* Use this routine for the x86 platform - it uses a faster MMX routine - if the machine supports MMX. */ - -void /* PRIVATE */ -png_combine_row(png_structp png_ptr, png_bytep row, int mask) -{ - png_debug(1, "in png_combine_row (pnggccrd.c)\n"); - -#if defined(PNG_MMX_CODE_SUPPORTED) - if (_mmx_supported == 2) { -#if !defined(PNG_1_0_X) - /* this should have happened in png_init_mmx_flags() already */ - png_warning(png_ptr, "asm_flags may not have been initialized"); -#endif - png_mmx_support(); - } -#endif - - if (mask == 0xff) - { - png_debug(2,"mask == 0xff: doing single png_memcpy()\n"); - png_memcpy(row, png_ptr->row_buf + 1, - (png_size_t)PNG_ROWBYTES(png_ptr->row_info.pixel_depth,png_ptr->width)); - } - else /* (png_combine_row() is never called with mask == 0) */ - { - switch (png_ptr->row_info.pixel_depth) - { - case 1: /* png_ptr->row_info.pixel_depth */ - { - png_bytep sp; - png_bytep dp; - int s_inc, s_start, s_end; - int m; - int shift; - png_uint_32 i; - - sp = png_ptr->row_buf + 1; - dp = row; - m = 0x80; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 7; - s_inc = 1; - } - else -#endif - { - s_start = 7; - s_end = 0; - s_inc = -1; - } - - shift = s_start; - - for (i = 0; i < png_ptr->width; i++) - { - if (m & mask) - { - int value; - - value = (*sp >> shift) & 0x1; - *dp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - - case 2: /* png_ptr->row_info.pixel_depth */ - { - png_bytep sp; - png_bytep dp; - int s_start, s_end, s_inc; - int m; - int shift; - png_uint_32 i; - int value; - - sp = png_ptr->row_buf + 1; - dp = row; - m = 0x80; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 6; - s_inc = 2; - } - else -#endif - { - s_start = 6; - s_end = 0; - s_inc = -2; - } - - shift = s_start; - - for (i = 0; i < png_ptr->width; i++) - { - if (m & mask) - { - value = (*sp >> shift) & 0x3; - *dp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - - case 4: /* png_ptr->row_info.pixel_depth */ - { - png_bytep sp; - png_bytep dp; - int s_start, s_end, s_inc; - int m; - int shift; - png_uint_32 i; - int value; - - sp = png_ptr->row_buf + 1; - dp = row; - m = 0x80; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 4; - s_inc = 4; - } - else -#endif - { - s_start = 4; - s_end = 0; - s_inc = -4; - } - shift = s_start; - - for (i = 0; i < png_ptr->width; i++) - { - if (m & mask) - { - value = (*sp >> shift) & 0xf; - *dp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - - case 8: /* png_ptr->row_info.pixel_depth */ - { - png_bytep srcptr; - png_bytep dstptr; - -#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && _mmx_supported */ ) -#else - if (_mmx_supported) -#endif - { - png_uint_32 len; - int diff; - int dummy_value_a; // fix 'forbidden register spilled' error - int dummy_value_d; - int dummy_value_c; - int dummy_value_S; - int dummy_value_D; - _unmask = ~mask; // global variable for -fPIC version - srcptr = png_ptr->row_buf + 1; - dstptr = row; - len = png_ptr->width &~7; // reduce to multiple of 8 - diff = (int) (png_ptr->width & 7); // amount lost - - __asm__ __volatile__ ( - "movd _unmask, %%mm7 \n\t" // load bit pattern - "psubb %%mm6, %%mm6 \n\t" // zero mm6 - "punpcklbw %%mm7, %%mm7 \n\t" - "punpcklwd %%mm7, %%mm7 \n\t" - "punpckldq %%mm7, %%mm7 \n\t" // fill reg with 8 masks - - "movq _mask8_0, %%mm0 \n\t" - "pand %%mm7, %%mm0 \n\t" // nonzero if keep byte - "pcmpeqb %%mm6, %%mm0 \n\t" // zeros->1s, v versa - -// preload "movl len, %%ecx \n\t" // load length of line -// preload "movl srcptr, %%esi \n\t" // load source -// preload "movl dstptr, %%edi \n\t" // load dest - - "cmpl $0, %%ecx \n\t" // len == 0 ? - "je mainloop8end \n\t" - - "mainloop8: \n\t" - "movq (%%esi), %%mm4 \n\t" // *srcptr - "pand %%mm0, %%mm4 \n\t" - "movq %%mm0, %%mm6 \n\t" - "pandn (%%edi), %%mm6 \n\t" // *dstptr - "por %%mm6, %%mm4 \n\t" - "movq %%mm4, (%%edi) \n\t" - "addl $8, %%esi \n\t" // inc by 8 bytes processed - "addl $8, %%edi \n\t" - "subl $8, %%ecx \n\t" // dec by 8 pixels processed - "ja mainloop8 \n\t" - - "mainloop8end: \n\t" -// preload "movl diff, %%ecx \n\t" // (diff is in eax) - "movl %%eax, %%ecx \n\t" - "cmpl $0, %%ecx \n\t" - "jz end8 \n\t" -// preload "movl mask, %%edx \n\t" - "sall $24, %%edx \n\t" // make low byte, high byte - - "secondloop8: \n\t" - "sall %%edx \n\t" // move high bit to CF - "jnc skip8 \n\t" // if CF = 0 - "movb (%%esi), %%al \n\t" - "movb %%al, (%%edi) \n\t" - - "skip8: \n\t" - "incl %%esi \n\t" - "incl %%edi \n\t" - "decl %%ecx \n\t" - "jnz secondloop8 \n\t" - - "end8: \n\t" - "EMMS \n\t" // DONE - - : "=a" (dummy_value_a), // output regs (dummy) - "=d" (dummy_value_d), - "=c" (dummy_value_c), - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "3" (srcptr), // esi // input regs - "4" (dstptr), // edi - "0" (diff), // eax -// was (unmask) "b" RESERVED // ebx // Global Offset Table idx - "2" (len), // ecx - "1" (mask) // edx - -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm4", "%mm6", "%mm7" // clobber list -#endif - ); - } - else /* mmx _not supported - Use modified C routine */ -#endif /* PNG_MMX_CODE_SUPPORTED */ - { - register png_uint_32 i; - png_uint_32 initial_val = png_pass_start[png_ptr->pass]; - /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ - register int stride = png_pass_inc[png_ptr->pass]; - /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ - register int rep_bytes = png_pass_width[png_ptr->pass]; - /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ - png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ - int diff = (int) (png_ptr->width & 7); /* amount lost */ - register png_uint_32 final_val = len; /* GRR bugfix */ - - srcptr = png_ptr->row_buf + 1 + initial_val; - dstptr = row + initial_val; - - for (i = initial_val; i < final_val; i += stride) - { - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - if (diff) /* number of leftover pixels: 3 for pngtest */ - { - final_val+=diff /* *BPP1 */ ; - for (; i < final_val; i += stride) - { - if (rep_bytes > (int)(final_val-i)) - rep_bytes = (int)(final_val-i); - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - } - - } /* end of else (_mmx_supported) */ - - break; - } /* end 8 bpp */ - - case 16: /* png_ptr->row_info.pixel_depth */ - { - png_bytep srcptr; - png_bytep dstptr; - -#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && _mmx_supported */ ) -#else - if (_mmx_supported) -#endif - { - png_uint_32 len; - int diff; - int dummy_value_a; // fix 'forbidden register spilled' error - int dummy_value_d; - int dummy_value_c; - int dummy_value_S; - int dummy_value_D; - _unmask = ~mask; // global variable for -fPIC version - srcptr = png_ptr->row_buf + 1; - dstptr = row; - len = png_ptr->width &~7; // reduce to multiple of 8 - diff = (int) (png_ptr->width & 7); // amount lost // - - __asm__ __volatile__ ( - "movd _unmask, %%mm7 \n\t" // load bit pattern - "psubb %%mm6, %%mm6 \n\t" // zero mm6 - "punpcklbw %%mm7, %%mm7 \n\t" - "punpcklwd %%mm7, %%mm7 \n\t" - "punpckldq %%mm7, %%mm7 \n\t" // fill reg with 8 masks - - "movq _mask16_0, %%mm0 \n\t" - "movq _mask16_1, %%mm1 \n\t" - - "pand %%mm7, %%mm0 \n\t" - "pand %%mm7, %%mm1 \n\t" - - "pcmpeqb %%mm6, %%mm0 \n\t" - "pcmpeqb %%mm6, %%mm1 \n\t" - -// preload "movl len, %%ecx \n\t" // load length of line -// preload "movl srcptr, %%esi \n\t" // load source -// preload "movl dstptr, %%edi \n\t" // load dest - - "cmpl $0, %%ecx \n\t" - "jz mainloop16end \n\t" - - "mainloop16: \n\t" - "movq (%%esi), %%mm4 \n\t" - "pand %%mm0, %%mm4 \n\t" - "movq %%mm0, %%mm6 \n\t" - "movq (%%edi), %%mm7 \n\t" - "pandn %%mm7, %%mm6 \n\t" - "por %%mm6, %%mm4 \n\t" - "movq %%mm4, (%%edi) \n\t" - - "movq 8(%%esi), %%mm5 \n\t" - "pand %%mm1, %%mm5 \n\t" - "movq %%mm1, %%mm7 \n\t" - "movq 8(%%edi), %%mm6 \n\t" - "pandn %%mm6, %%mm7 \n\t" - "por %%mm7, %%mm5 \n\t" - "movq %%mm5, 8(%%edi) \n\t" - - "addl $16, %%esi \n\t" // inc by 16 bytes processed - "addl $16, %%edi \n\t" - "subl $8, %%ecx \n\t" // dec by 8 pixels processed - "ja mainloop16 \n\t" - - "mainloop16end: \n\t" -// preload "movl diff, %%ecx \n\t" // (diff is in eax) - "movl %%eax, %%ecx \n\t" - "cmpl $0, %%ecx \n\t" - "jz end16 \n\t" -// preload "movl mask, %%edx \n\t" - "sall $24, %%edx \n\t" // make low byte, high byte - - "secondloop16: \n\t" - "sall %%edx \n\t" // move high bit to CF - "jnc skip16 \n\t" // if CF = 0 - "movw (%%esi), %%ax \n\t" - "movw %%ax, (%%edi) \n\t" - - "skip16: \n\t" - "addl $2, %%esi \n\t" - "addl $2, %%edi \n\t" - "decl %%ecx \n\t" - "jnz secondloop16 \n\t" - - "end16: \n\t" - "EMMS \n\t" // DONE - - : "=a" (dummy_value_a), // output regs (dummy) - "=c" (dummy_value_c), - "=d" (dummy_value_d), - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "0" (diff), // eax // input regs -// was (unmask) " " RESERVED // ebx // Global Offset Table idx - "1" (len), // ecx - "2" (mask), // edx - "3" (srcptr), // esi - "4" (dstptr) // edi - -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1", "%mm4" // clobber list - , "%mm5", "%mm6", "%mm7" -#endif - ); - } - else /* mmx _not supported - Use modified C routine */ -#endif /* PNG_MMX_CODE_SUPPORTED */ - { - register png_uint_32 i; - png_uint_32 initial_val = BPP2 * png_pass_start[png_ptr->pass]; - /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ - register int stride = BPP2 * png_pass_inc[png_ptr->pass]; - /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ - register int rep_bytes = BPP2 * png_pass_width[png_ptr->pass]; - /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ - png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ - int diff = (int) (png_ptr->width & 7); /* amount lost */ - register png_uint_32 final_val = BPP2 * len; /* GRR bugfix */ - - srcptr = png_ptr->row_buf + 1 + initial_val; - dstptr = row + initial_val; - - for (i = initial_val; i < final_val; i += stride) - { - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - if (diff) /* number of leftover pixels: 3 for pngtest */ - { - final_val+=diff*BPP2; - for (; i < final_val; i += stride) - { - if (rep_bytes > (int)(final_val-i)) - rep_bytes = (int)(final_val-i); - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - } - } /* end of else (_mmx_supported) */ - - break; - } /* end 16 bpp */ - - case 24: /* png_ptr->row_info.pixel_depth */ - { - png_bytep srcptr; - png_bytep dstptr; - -#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && _mmx_supported */ ) -#else - if (_mmx_supported) -#endif - { - png_uint_32 len; - int diff; - int dummy_value_a; // fix 'forbidden register spilled' error - int dummy_value_d; - int dummy_value_c; - int dummy_value_S; - int dummy_value_D; - _unmask = ~mask; // global variable for -fPIC version - srcptr = png_ptr->row_buf + 1; - dstptr = row; - len = png_ptr->width &~7; // reduce to multiple of 8 - diff = (int) (png_ptr->width & 7); // amount lost // - - __asm__ __volatile__ ( - "movd _unmask, %%mm7 \n\t" // load bit pattern - "psubb %%mm6, %%mm6 \n\t" // zero mm6 - "punpcklbw %%mm7, %%mm7 \n\t" - "punpcklwd %%mm7, %%mm7 \n\t" - "punpckldq %%mm7, %%mm7 \n\t" // fill reg with 8 masks - - "movq _mask24_0, %%mm0 \n\t" - "movq _mask24_1, %%mm1 \n\t" - "movq _mask24_2, %%mm2 \n\t" - - "pand %%mm7, %%mm0 \n\t" - "pand %%mm7, %%mm1 \n\t" - "pand %%mm7, %%mm2 \n\t" - - "pcmpeqb %%mm6, %%mm0 \n\t" - "pcmpeqb %%mm6, %%mm1 \n\t" - "pcmpeqb %%mm6, %%mm2 \n\t" - -// preload "movl len, %%ecx \n\t" // load length of line -// preload "movl srcptr, %%esi \n\t" // load source -// preload "movl dstptr, %%edi \n\t" // load dest - - "cmpl $0, %%ecx \n\t" - "jz mainloop24end \n\t" - - "mainloop24: \n\t" - "movq (%%esi), %%mm4 \n\t" - "pand %%mm0, %%mm4 \n\t" - "movq %%mm0, %%mm6 \n\t" - "movq (%%edi), %%mm7 \n\t" - "pandn %%mm7, %%mm6 \n\t" - "por %%mm6, %%mm4 \n\t" - "movq %%mm4, (%%edi) \n\t" - - "movq 8(%%esi), %%mm5 \n\t" - "pand %%mm1, %%mm5 \n\t" - "movq %%mm1, %%mm7 \n\t" - "movq 8(%%edi), %%mm6 \n\t" - "pandn %%mm6, %%mm7 \n\t" - "por %%mm7, %%mm5 \n\t" - "movq %%mm5, 8(%%edi) \n\t" - - "movq 16(%%esi), %%mm6 \n\t" - "pand %%mm2, %%mm6 \n\t" - "movq %%mm2, %%mm4 \n\t" - "movq 16(%%edi), %%mm7 \n\t" - "pandn %%mm7, %%mm4 \n\t" - "por %%mm4, %%mm6 \n\t" - "movq %%mm6, 16(%%edi) \n\t" - - "addl $24, %%esi \n\t" // inc by 24 bytes processed - "addl $24, %%edi \n\t" - "subl $8, %%ecx \n\t" // dec by 8 pixels processed - - "ja mainloop24 \n\t" - - "mainloop24end: \n\t" -// preload "movl diff, %%ecx \n\t" // (diff is in eax) - "movl %%eax, %%ecx \n\t" - "cmpl $0, %%ecx \n\t" - "jz end24 \n\t" -// preload "movl mask, %%edx \n\t" - "sall $24, %%edx \n\t" // make low byte, high byte - - "secondloop24: \n\t" - "sall %%edx \n\t" // move high bit to CF - "jnc skip24 \n\t" // if CF = 0 - "movw (%%esi), %%ax \n\t" - "movw %%ax, (%%edi) \n\t" - "xorl %%eax, %%eax \n\t" - "movb 2(%%esi), %%al \n\t" - "movb %%al, 2(%%edi) \n\t" - - "skip24: \n\t" - "addl $3, %%esi \n\t" - "addl $3, %%edi \n\t" - "decl %%ecx \n\t" - "jnz secondloop24 \n\t" - - "end24: \n\t" - "EMMS \n\t" // DONE - - : "=a" (dummy_value_a), // output regs (dummy) - "=d" (dummy_value_d), - "=c" (dummy_value_c), - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "3" (srcptr), // esi // input regs - "4" (dstptr), // edi - "0" (diff), // eax -// was (unmask) "b" RESERVED // ebx // Global Offset Table idx - "2" (len), // ecx - "1" (mask) // edx - -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1", "%mm2" // clobber list - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - else /* mmx _not supported - Use modified C routine */ -#endif /* PNG_MMX_CODE_SUPPORTED */ - { - register png_uint_32 i; - png_uint_32 initial_val = BPP3 * png_pass_start[png_ptr->pass]; - /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ - register int stride = BPP3 * png_pass_inc[png_ptr->pass]; - /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ - register int rep_bytes = BPP3 * png_pass_width[png_ptr->pass]; - /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ - png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ - int diff = (int) (png_ptr->width & 7); /* amount lost */ - register png_uint_32 final_val = BPP3 * len; /* GRR bugfix */ - - srcptr = png_ptr->row_buf + 1 + initial_val; - dstptr = row + initial_val; - - for (i = initial_val; i < final_val; i += stride) - { - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - if (diff) /* number of leftover pixels: 3 for pngtest */ - { - final_val+=diff*BPP3; - for (; i < final_val; i += stride) - { - if (rep_bytes > (int)(final_val-i)) - rep_bytes = (int)(final_val-i); - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - } - } /* end of else (_mmx_supported) */ - - break; - } /* end 24 bpp */ - - case 32: /* png_ptr->row_info.pixel_depth */ - { - png_bytep srcptr; - png_bytep dstptr; - -#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && _mmx_supported */ ) -#else - if (_mmx_supported) -#endif - { - png_uint_32 len; - int diff; - int dummy_value_a; // fix 'forbidden register spilled' error - int dummy_value_d; - int dummy_value_c; - int dummy_value_S; - int dummy_value_D; - _unmask = ~mask; // global variable for -fPIC version - srcptr = png_ptr->row_buf + 1; - dstptr = row; - len = png_ptr->width &~7; // reduce to multiple of 8 - diff = (int) (png_ptr->width & 7); // amount lost // - - __asm__ __volatile__ ( - "movd _unmask, %%mm7 \n\t" // load bit pattern - "psubb %%mm6, %%mm6 \n\t" // zero mm6 - "punpcklbw %%mm7, %%mm7 \n\t" - "punpcklwd %%mm7, %%mm7 \n\t" - "punpckldq %%mm7, %%mm7 \n\t" // fill reg with 8 masks - - "movq _mask32_0, %%mm0 \n\t" - "movq _mask32_1, %%mm1 \n\t" - "movq _mask32_2, %%mm2 \n\t" - "movq _mask32_3, %%mm3 \n\t" - - "pand %%mm7, %%mm0 \n\t" - "pand %%mm7, %%mm1 \n\t" - "pand %%mm7, %%mm2 \n\t" - "pand %%mm7, %%mm3 \n\t" - - "pcmpeqb %%mm6, %%mm0 \n\t" - "pcmpeqb %%mm6, %%mm1 \n\t" - "pcmpeqb %%mm6, %%mm2 \n\t" - "pcmpeqb %%mm6, %%mm3 \n\t" - -// preload "movl len, %%ecx \n\t" // load length of line -// preload "movl srcptr, %%esi \n\t" // load source -// preload "movl dstptr, %%edi \n\t" // load dest - - "cmpl $0, %%ecx \n\t" // lcr - "jz mainloop32end \n\t" - - "mainloop32: \n\t" - "movq (%%esi), %%mm4 \n\t" - "pand %%mm0, %%mm4 \n\t" - "movq %%mm0, %%mm6 \n\t" - "movq (%%edi), %%mm7 \n\t" - "pandn %%mm7, %%mm6 \n\t" - "por %%mm6, %%mm4 \n\t" - "movq %%mm4, (%%edi) \n\t" - - "movq 8(%%esi), %%mm5 \n\t" - "pand %%mm1, %%mm5 \n\t" - "movq %%mm1, %%mm7 \n\t" - "movq 8(%%edi), %%mm6 \n\t" - "pandn %%mm6, %%mm7 \n\t" - "por %%mm7, %%mm5 \n\t" - "movq %%mm5, 8(%%edi) \n\t" - - "movq 16(%%esi), %%mm6 \n\t" - "pand %%mm2, %%mm6 \n\t" - "movq %%mm2, %%mm4 \n\t" - "movq 16(%%edi), %%mm7 \n\t" - "pandn %%mm7, %%mm4 \n\t" - "por %%mm4, %%mm6 \n\t" - "movq %%mm6, 16(%%edi) \n\t" - - "movq 24(%%esi), %%mm7 \n\t" - "pand %%mm3, %%mm7 \n\t" - "movq %%mm3, %%mm5 \n\t" - "movq 24(%%edi), %%mm4 \n\t" - "pandn %%mm4, %%mm5 \n\t" - "por %%mm5, %%mm7 \n\t" - "movq %%mm7, 24(%%edi) \n\t" - - "addl $32, %%esi \n\t" // inc by 32 bytes processed - "addl $32, %%edi \n\t" - "subl $8, %%ecx \n\t" // dec by 8 pixels processed - "ja mainloop32 \n\t" - - "mainloop32end: \n\t" -// preload "movl diff, %%ecx \n\t" // (diff is in eax) - "movl %%eax, %%ecx \n\t" - "cmpl $0, %%ecx \n\t" - "jz end32 \n\t" -// preload "movl mask, %%edx \n\t" - "sall $24, %%edx \n\t" // low byte => high byte - - "secondloop32: \n\t" - "sall %%edx \n\t" // move high bit to CF - "jnc skip32 \n\t" // if CF = 0 - "movl (%%esi), %%eax \n\t" - "movl %%eax, (%%edi) \n\t" - - "skip32: \n\t" - "addl $4, %%esi \n\t" - "addl $4, %%edi \n\t" - "decl %%ecx \n\t" - "jnz secondloop32 \n\t" - - "end32: \n\t" - "EMMS \n\t" // DONE - - : "=a" (dummy_value_a), // output regs (dummy) - "=d" (dummy_value_d), - "=c" (dummy_value_c), - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "3" (srcptr), // esi // input regs - "4" (dstptr), // edi - "0" (diff), // eax -// was (unmask) "b" RESERVED // ebx // Global Offset Table idx - "2" (len), // ecx - "1" (mask) // edx - -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1", "%mm2", "%mm3" // clobber list - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - else /* mmx _not supported - Use modified C routine */ -#endif /* PNG_MMX_CODE_SUPPORTED */ - { - register png_uint_32 i; - png_uint_32 initial_val = BPP4 * png_pass_start[png_ptr->pass]; - /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ - register int stride = BPP4 * png_pass_inc[png_ptr->pass]; - /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ - register int rep_bytes = BPP4 * png_pass_width[png_ptr->pass]; - /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ - png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ - int diff = (int) (png_ptr->width & 7); /* amount lost */ - register png_uint_32 final_val = BPP4 * len; /* GRR bugfix */ - - srcptr = png_ptr->row_buf + 1 + initial_val; - dstptr = row + initial_val; - - for (i = initial_val; i < final_val; i += stride) - { - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - if (diff) /* number of leftover pixels: 3 for pngtest */ - { - final_val+=diff*BPP4; - for (; i < final_val; i += stride) - { - if (rep_bytes > (int)(final_val-i)) - rep_bytes = (int)(final_val-i); - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - } - } /* end of else (_mmx_supported) */ - - break; - } /* end 32 bpp */ - - case 48: /* png_ptr->row_info.pixel_depth */ - { - png_bytep srcptr; - png_bytep dstptr; - -#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && _mmx_supported */ ) -#else - if (_mmx_supported) -#endif - { - png_uint_32 len; - int diff; - int dummy_value_a; // fix 'forbidden register spilled' error - int dummy_value_d; - int dummy_value_c; - int dummy_value_S; - int dummy_value_D; - _unmask = ~mask; // global variable for -fPIC version - srcptr = png_ptr->row_buf + 1; - dstptr = row; - len = png_ptr->width &~7; // reduce to multiple of 8 - diff = (int) (png_ptr->width & 7); // amount lost // - - __asm__ __volatile__ ( - "movd _unmask, %%mm7 \n\t" // load bit pattern - "psubb %%mm6, %%mm6 \n\t" // zero mm6 - "punpcklbw %%mm7, %%mm7 \n\t" - "punpcklwd %%mm7, %%mm7 \n\t" - "punpckldq %%mm7, %%mm7 \n\t" // fill reg with 8 masks - - "movq _mask48_0, %%mm0 \n\t" - "movq _mask48_1, %%mm1 \n\t" - "movq _mask48_2, %%mm2 \n\t" - "movq _mask48_3, %%mm3 \n\t" - "movq _mask48_4, %%mm4 \n\t" - "movq _mask48_5, %%mm5 \n\t" - - "pand %%mm7, %%mm0 \n\t" - "pand %%mm7, %%mm1 \n\t" - "pand %%mm7, %%mm2 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pand %%mm7, %%mm4 \n\t" - "pand %%mm7, %%mm5 \n\t" - - "pcmpeqb %%mm6, %%mm0 \n\t" - "pcmpeqb %%mm6, %%mm1 \n\t" - "pcmpeqb %%mm6, %%mm2 \n\t" - "pcmpeqb %%mm6, %%mm3 \n\t" - "pcmpeqb %%mm6, %%mm4 \n\t" - "pcmpeqb %%mm6, %%mm5 \n\t" - -// preload "movl len, %%ecx \n\t" // load length of line -// preload "movl srcptr, %%esi \n\t" // load source -// preload "movl dstptr, %%edi \n\t" // load dest - - "cmpl $0, %%ecx \n\t" - "jz mainloop48end \n\t" - - "mainloop48: \n\t" - "movq (%%esi), %%mm7 \n\t" - "pand %%mm0, %%mm7 \n\t" - "movq %%mm0, %%mm6 \n\t" - "pandn (%%edi), %%mm6 \n\t" - "por %%mm6, %%mm7 \n\t" - "movq %%mm7, (%%edi) \n\t" - - "movq 8(%%esi), %%mm6 \n\t" - "pand %%mm1, %%mm6 \n\t" - "movq %%mm1, %%mm7 \n\t" - "pandn 8(%%edi), %%mm7 \n\t" - "por %%mm7, %%mm6 \n\t" - "movq %%mm6, 8(%%edi) \n\t" - - "movq 16(%%esi), %%mm6 \n\t" - "pand %%mm2, %%mm6 \n\t" - "movq %%mm2, %%mm7 \n\t" - "pandn 16(%%edi), %%mm7 \n\t" - "por %%mm7, %%mm6 \n\t" - "movq %%mm6, 16(%%edi) \n\t" - - "movq 24(%%esi), %%mm7 \n\t" - "pand %%mm3, %%mm7 \n\t" - "movq %%mm3, %%mm6 \n\t" - "pandn 24(%%edi), %%mm6 \n\t" - "por %%mm6, %%mm7 \n\t" - "movq %%mm7, 24(%%edi) \n\t" - - "movq 32(%%esi), %%mm6 \n\t" - "pand %%mm4, %%mm6 \n\t" - "movq %%mm4, %%mm7 \n\t" - "pandn 32(%%edi), %%mm7 \n\t" - "por %%mm7, %%mm6 \n\t" - "movq %%mm6, 32(%%edi) \n\t" - - "movq 40(%%esi), %%mm7 \n\t" - "pand %%mm5, %%mm7 \n\t" - "movq %%mm5, %%mm6 \n\t" - "pandn 40(%%edi), %%mm6 \n\t" - "por %%mm6, %%mm7 \n\t" - "movq %%mm7, 40(%%edi) \n\t" - - "addl $48, %%esi \n\t" // inc by 48 bytes processed - "addl $48, %%edi \n\t" - "subl $8, %%ecx \n\t" // dec by 8 pixels processed - - "ja mainloop48 \n\t" - - "mainloop48end: \n\t" -// preload "movl diff, %%ecx \n\t" // (diff is in eax) - "movl %%eax, %%ecx \n\t" - "cmpl $0, %%ecx \n\t" - "jz end48 \n\t" -// preload "movl mask, %%edx \n\t" - "sall $24, %%edx \n\t" // make low byte, high byte - - "secondloop48: \n\t" - "sall %%edx \n\t" // move high bit to CF - "jnc skip48 \n\t" // if CF = 0 - "movl (%%esi), %%eax \n\t" - "movl %%eax, (%%edi) \n\t" - - "skip48: \n\t" - "addl $4, %%esi \n\t" - "addl $4, %%edi \n\t" - "decl %%ecx \n\t" - "jnz secondloop48 \n\t" - - "end48: \n\t" - "EMMS \n\t" // DONE - - : "=a" (dummy_value_a), // output regs (dummy) - "=d" (dummy_value_d), - "=c" (dummy_value_c), - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "3" (srcptr), // esi // input regs - "4" (dstptr), // edi - "0" (diff), // eax -// was (unmask) "b" RESERVED // ebx // Global Offset Table idx - "2" (len), // ecx - "1" (mask) // edx - -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1", "%mm2", "%mm3" // clobber list - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - else /* mmx _not supported - Use modified C routine */ -#endif /* PNG_MMX_CODE_SUPPORTED */ - { - register png_uint_32 i; - png_uint_32 initial_val = BPP6 * png_pass_start[png_ptr->pass]; - /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ - register int stride = BPP6 * png_pass_inc[png_ptr->pass]; - /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ - register int rep_bytes = BPP6 * png_pass_width[png_ptr->pass]; - /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ - png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ - int diff = (int) (png_ptr->width & 7); /* amount lost */ - register png_uint_32 final_val = BPP6 * len; /* GRR bugfix */ - - srcptr = png_ptr->row_buf + 1 + initial_val; - dstptr = row + initial_val; - - for (i = initial_val; i < final_val; i += stride) - { - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - if (diff) /* number of leftover pixels: 3 for pngtest */ - { - final_val+=diff*BPP6; - for (; i < final_val; i += stride) - { - if (rep_bytes > (int)(final_val-i)) - rep_bytes = (int)(final_val-i); - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - } - } /* end of else (_mmx_supported) */ - - break; - } /* end 48 bpp */ - - case 64: /* png_ptr->row_info.pixel_depth */ - { - png_bytep srcptr; - png_bytep dstptr; - register png_uint_32 i; - png_uint_32 initial_val = BPP8 * png_pass_start[png_ptr->pass]; - /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ - register int stride = BPP8 * png_pass_inc[png_ptr->pass]; - /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ - register int rep_bytes = BPP8 * png_pass_width[png_ptr->pass]; - /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ - png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ - int diff = (int) (png_ptr->width & 7); /* amount lost */ - register png_uint_32 final_val = BPP8 * len; /* GRR bugfix */ - - srcptr = png_ptr->row_buf + 1 + initial_val; - dstptr = row + initial_val; - - for (i = initial_val; i < final_val; i += stride) - { - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - if (diff) /* number of leftover pixels: 3 for pngtest */ - { - final_val+=diff*BPP8; - for (; i < final_val; i += stride) - { - if (rep_bytes > (int)(final_val-i)) - rep_bytes = (int)(final_val-i); - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - } - - break; - } /* end 64 bpp */ - - default: /* png_ptr->row_info.pixel_depth != 1,2,4,8,16,24,32,48,64 */ - { - /* this should never happen */ - png_warning(png_ptr, "Invalid row_info.pixel_depth in pnggccrd"); - break; - } - } /* end switch (png_ptr->row_info.pixel_depth) */ - - } /* end if (non-trivial mask) */ - -} /* end png_combine_row() */ - -#endif /* PNG_HAVE_MMX_COMBINE_ROW */ - - - - -/*===========================================================================*/ -/* */ -/* P N G _ D O _ R E A D _ I N T E R L A C E */ -/* */ -/*===========================================================================*/ - -#if defined(PNG_READ_INTERLACING_SUPPORTED) -#if defined(PNG_HAVE_MMX_READ_INTERLACE) - -/* png_do_read_interlace() is called after any 16-bit to 8-bit conversion - * has taken place. [GRR: what other steps come before and/or after?] - */ - -void /* PRIVATE */ -png_do_read_interlace(png_structp png_ptr) -{ - png_row_infop row_info = &(png_ptr->row_info); - png_bytep row = png_ptr->row_buf + 1; - int pass = png_ptr->pass; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - png_uint_32 transformations = png_ptr->transformations; -#endif - - png_debug(1, "in png_do_read_interlace (pnggccrd.c)\n"); - -#if defined(PNG_MMX_CODE_SUPPORTED) - if (_mmx_supported == 2) { -#if !defined(PNG_1_0_X) - /* this should have happened in png_init_mmx_flags() already */ - png_warning(png_ptr, "asm_flags may not have been initialized"); -#endif - png_mmx_support(); - } -#endif - - if (row != NULL && row_info != NULL) - { - png_uint_32 final_width; - - final_width = row_info->width * png_pass_inc[pass]; - - switch (row_info->pixel_depth) - { - case 1: - { - png_bytep sp, dp; - int sshift, dshift; - int s_start, s_end, s_inc; - png_byte v; - png_uint_32 i; - int j; - - sp = row + (png_size_t)((row_info->width - 1) >> 3); - dp = row + (png_size_t)((final_width - 1) >> 3); -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (int)((row_info->width + 7) & 7); - dshift = (int)((final_width + 7) & 7); - s_start = 7; - s_end = 0; - s_inc = -1; - } - else -#endif - { - sshift = 7 - (int)((row_info->width + 7) & 7); - dshift = 7 - (int)((final_width + 7) & 7); - s_start = 0; - s_end = 7; - s_inc = 1; - } - - for (i = row_info->width; i; i--) - { - v = (png_byte)((*sp >> sshift) & 0x1); - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp &= (png_byte)((0x7f7f >> (7 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - - case 2: - { - png_bytep sp, dp; - int sshift, dshift; - int s_start, s_end, s_inc; - png_uint_32 i; - - sp = row + (png_size_t)((row_info->width - 1) >> 2); - dp = row + (png_size_t)((final_width - 1) >> 2); -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (png_size_t)(((row_info->width + 3) & 3) << 1); - dshift = (png_size_t)(((final_width + 3) & 3) << 1); - s_start = 6; - s_end = 0; - s_inc = -2; - } - else -#endif - { - sshift = (png_size_t)((3 - ((row_info->width + 3) & 3)) << 1); - dshift = (png_size_t)((3 - ((final_width + 3) & 3)) << 1); - s_start = 0; - s_end = 6; - s_inc = 2; - } - - for (i = row_info->width; i; i--) - { - png_byte v; - int j; - - v = (png_byte)((*sp >> sshift) & 0x3); - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp &= (png_byte)((0x3f3f >> (6 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - - case 4: - { - png_bytep sp, dp; - int sshift, dshift; - int s_start, s_end, s_inc; - png_uint_32 i; - - sp = row + (png_size_t)((row_info->width - 1) >> 1); - dp = row + (png_size_t)((final_width - 1) >> 1); -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (png_size_t)(((row_info->width + 1) & 1) << 2); - dshift = (png_size_t)(((final_width + 1) & 1) << 2); - s_start = 4; - s_end = 0; - s_inc = -4; - } - else -#endif - { - sshift = (png_size_t)((1 - ((row_info->width + 1) & 1)) << 2); - dshift = (png_size_t)((1 - ((final_width + 1) & 1)) << 2); - s_start = 0; - s_end = 4; - s_inc = 4; - } - - for (i = row_info->width; i; i--) - { - png_byte v; - int j; - - v = (png_byte)((*sp >> sshift) & 0xf); - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp &= (png_byte)((0xf0f >> (4 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - - /*====================================================================*/ - - default: /* 8-bit or larger (this is where the routine is modified) */ - { -#if 0 -// static unsigned long long _const4 = 0x0000000000FFFFFFLL; no good -// static unsigned long long const4 = 0x0000000000FFFFFFLL; no good -// unsigned long long _const4 = 0x0000000000FFFFFFLL; no good -// unsigned long long const4 = 0x0000000000FFFFFFLL; no good -#endif - png_bytep sptr, dp; - png_uint_32 i; - png_size_t pixel_bytes; - int width = (int)row_info->width; - - pixel_bytes = (row_info->pixel_depth >> 3); - - /* point sptr at the last pixel in the pre-expanded row: */ - sptr = row + (width - 1) * pixel_bytes; - - /* point dp at the last pixel position in the expanded row: */ - dp = row + (final_width - 1) * pixel_bytes; - - /* New code by Nirav Chhatrapati - Intel Corporation */ - -#if defined(PNG_MMX_CODE_SUPPORTED) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_INTERLACE) - /* && _mmx_supported */ ) -#else - if (_mmx_supported) -#endif - { - //-------------------------------------------------------------- - if (pixel_bytes == 3) - { - if (((pass == 0) || (pass == 1)) && width) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - int dummy_value_a; - - __asm__ __volatile__ ( - "subl $21, %%edi \n\t" - // (png_pass_inc[pass] - 1)*pixel_bytes - - ".loop3_pass0: \n\t" - "movd (%%esi), %%mm0 \n\t" // x x x x x 2 1 0 - "pand (%3), %%mm0 \n\t" // z z z z z 2 1 0 - "movq %%mm0, %%mm1 \n\t" // z z z z z 2 1 0 - "psllq $16, %%mm0 \n\t" // z z z 2 1 0 z z - "movq %%mm0, %%mm2 \n\t" // z z z 2 1 0 z z - "psllq $24, %%mm0 \n\t" // 2 1 0 z z z z z - "psrlq $8, %%mm1 \n\t" // z z z z z z 2 1 - "por %%mm2, %%mm0 \n\t" // 2 1 0 2 1 0 z z - "por %%mm1, %%mm0 \n\t" // 2 1 0 2 1 0 2 1 - "movq %%mm0, %%mm3 \n\t" // 2 1 0 2 1 0 2 1 - "psllq $16, %%mm0 \n\t" // 0 2 1 0 2 1 z z - "movq %%mm3, %%mm4 \n\t" // 2 1 0 2 1 0 2 1 - "punpckhdq %%mm0, %%mm3 \n\t" // 0 2 1 0 2 1 0 2 - "movq %%mm4, 16(%%edi) \n\t" - "psrlq $32, %%mm0 \n\t" // z z z z 0 2 1 0 - "movq %%mm3, 8(%%edi) \n\t" - "punpckldq %%mm4, %%mm0 \n\t" // 1 0 2 1 0 2 1 0 - "subl $3, %%esi \n\t" - "movq %%mm0, (%%edi) \n\t" - "subl $24, %%edi \n\t" - "decl %%ecx \n\t" - "jnz .loop3_pass0 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D), - "=a" (dummy_value_a) - - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width), // ecx - "3" (&_const4) // %1(?) (0x0000000000FFFFFFLL) - -#if 0 /* %mm0, ..., %mm4 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1", "%mm2" // clobber list - , "%mm3", "%mm4" -#endif - ); - } - else if (((pass == 2) || (pass == 3)) && width) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - int dummy_value_a; - - __asm__ __volatile__ ( - "subl $9, %%edi \n\t" - // (png_pass_inc[pass] - 1)*pixel_bytes - - ".loop3_pass2: \n\t" - "movd (%%esi), %%mm0 \n\t" // x x x x x 2 1 0 - "pand (%3), %%mm0 \n\t" // z z z z z 2 1 0 - "movq %%mm0, %%mm1 \n\t" // z z z z z 2 1 0 - "psllq $16, %%mm0 \n\t" // z z z 2 1 0 z z - "movq %%mm0, %%mm2 \n\t" // z z z 2 1 0 z z - "psllq $24, %%mm0 \n\t" // 2 1 0 z z z z z - "psrlq $8, %%mm1 \n\t" // z z z z z z 2 1 - "por %%mm2, %%mm0 \n\t" // 2 1 0 2 1 0 z z - "por %%mm1, %%mm0 \n\t" // 2 1 0 2 1 0 2 1 - "movq %%mm0, 4(%%edi) \n\t" - "psrlq $16, %%mm0 \n\t" // z z 2 1 0 2 1 0 - "subl $3, %%esi \n\t" - "movd %%mm0, (%%edi) \n\t" - "subl $12, %%edi \n\t" - "decl %%ecx \n\t" - "jnz .loop3_pass2 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D), - "=a" (dummy_value_a) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width), // ecx - "3" (&_const4) // (0x0000000000FFFFFFLL) - -#if 0 /* %mm0, ..., %mm2 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1", "%mm2" // clobber list -#endif - ); - } - else if (width) /* && ((pass == 4) || (pass == 5)) */ - { - int width_mmx = ((width >> 1) << 1) - 8; // GRR: huh? - if (width_mmx < 0) - width_mmx = 0; - width -= width_mmx; // 8 or 9 pix, 24 or 27 bytes - if (width_mmx) - { - // png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; - // sptr points at last pixel in pre-expanded row - // dp points at last pixel position in expanded row - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - int dummy_value_a; - int dummy_value_d; - - __asm__ __volatile__ ( - "subl $3, %%esi \n\t" - "subl $9, %%edi \n\t" - // (png_pass_inc[pass] + 1)*pixel_bytes - - ".loop3_pass4: \n\t" - "movq (%%esi), %%mm0 \n\t" // x x 5 4 3 2 1 0 - "movq %%mm0, %%mm1 \n\t" // x x 5 4 3 2 1 0 - "movq %%mm0, %%mm2 \n\t" // x x 5 4 3 2 1 0 - "psllq $24, %%mm0 \n\t" // 4 3 2 1 0 z z z - "pand (%3), %%mm1 \n\t" // z z z z z 2 1 0 - "psrlq $24, %%mm2 \n\t" // z z z x x 5 4 3 - "por %%mm1, %%mm0 \n\t" // 4 3 2 1 0 2 1 0 - "movq %%mm2, %%mm3 \n\t" // z z z x x 5 4 3 - "psllq $8, %%mm2 \n\t" // z z x x 5 4 3 z - "movq %%mm0, (%%edi) \n\t" - "psrlq $16, %%mm3 \n\t" // z z z z z x x 5 - "pand (%4), %%mm3 \n\t" // z z z z z z z 5 - "por %%mm3, %%mm2 \n\t" // z z x x 5 4 3 5 - "subl $6, %%esi \n\t" - "movd %%mm2, 8(%%edi) \n\t" - "subl $12, %%edi \n\t" - "subl $2, %%ecx \n\t" - "jnz .loop3_pass4 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D), - "=a" (dummy_value_a), - "=d" (dummy_value_d) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx), // ecx - "3" (&_const4), // 0x0000000000FFFFFFLL - "4" (&_const6) // 0x00000000000000FFLL - -#if 0 /* %mm0, ..., %mm3 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list - , "%mm2", "%mm3" -#endif - ); - } - - sptr -= width_mmx*3; - dp -= width_mmx*6; - for (i = width; i; i--) - { - png_byte v[8]; - int j; - - png_memcpy(v, sptr, 3); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 3); - dp -= 3; - } - sptr -= 3; - } - } - } /* end of pixel_bytes == 3 */ - - //-------------------------------------------------------------- - else if (pixel_bytes == 1) - { - if (((pass == 0) || (pass == 1)) && width) - { - int width_mmx = ((width >> 2) << 2); - width -= width_mmx; // 0-3 pixels => 0-3 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $3, %%esi \n\t" - "subl $31, %%edi \n\t" - - ".loop1_pass0: \n\t" - "movd (%%esi), %%mm0 \n\t" // x x x x 3 2 1 0 - "movq %%mm0, %%mm1 \n\t" // x x x x 3 2 1 0 - "punpcklbw %%mm0, %%mm0 \n\t" // 3 3 2 2 1 1 0 0 - "movq %%mm0, %%mm2 \n\t" // 3 3 2 2 1 1 0 0 - "punpcklwd %%mm0, %%mm0 \n\t" // 1 1 1 1 0 0 0 0 - "movq %%mm0, %%mm3 \n\t" // 1 1 1 1 0 0 0 0 - "punpckldq %%mm0, %%mm0 \n\t" // 0 0 0 0 0 0 0 0 - "punpckhdq %%mm3, %%mm3 \n\t" // 1 1 1 1 1 1 1 1 - "movq %%mm0, (%%edi) \n\t" - "punpckhwd %%mm2, %%mm2 \n\t" // 3 3 3 3 2 2 2 2 - "movq %%mm3, 8(%%edi) \n\t" - "movq %%mm2, %%mm4 \n\t" // 3 3 3 3 2 2 2 2 - "punpckldq %%mm2, %%mm2 \n\t" // 2 2 2 2 2 2 2 2 - "punpckhdq %%mm4, %%mm4 \n\t" // 3 3 3 3 3 3 3 3 - "movq %%mm2, 16(%%edi) \n\t" - "subl $4, %%esi \n\t" - "movq %%mm4, 24(%%edi) \n\t" - "subl $32, %%edi \n\t" - "subl $4, %%ecx \n\t" - "jnz .loop1_pass0 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, ..., %mm4 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1", "%mm2" // clobber list - , "%mm3", "%mm4" -#endif - ); - } - - sptr -= width_mmx; - dp -= width_mmx*8; - for (i = width; i; i--) - { - int j; - - /* I simplified this part in version 1.0.4e - * here and in several other instances where - * pixel_bytes == 1 -- GR-P - * - * Original code: - * - * png_byte v[8]; - * png_memcpy(v, sptr, pixel_bytes); - * for (j = 0; j < png_pass_inc[pass]; j++) - * { - * png_memcpy(dp, v, pixel_bytes); - * dp -= pixel_bytes; - * } - * sptr -= pixel_bytes; - * - * Replacement code is in the next three lines: - */ - - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp-- = *sptr; - } - --sptr; - } - } - else if (((pass == 2) || (pass == 3)) && width) - { - int width_mmx = ((width >> 2) << 2); - width -= width_mmx; // 0-3 pixels => 0-3 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $3, %%esi \n\t" - "subl $15, %%edi \n\t" - - ".loop1_pass2: \n\t" - "movd (%%esi), %%mm0 \n\t" // x x x x 3 2 1 0 - "punpcklbw %%mm0, %%mm0 \n\t" // 3 3 2 2 1 1 0 0 - "movq %%mm0, %%mm1 \n\t" // 3 3 2 2 1 1 0 0 - "punpcklwd %%mm0, %%mm0 \n\t" // 1 1 1 1 0 0 0 0 - "punpckhwd %%mm1, %%mm1 \n\t" // 3 3 3 3 2 2 2 2 - "movq %%mm0, (%%edi) \n\t" - "subl $4, %%esi \n\t" - "movq %%mm1, 8(%%edi) \n\t" - "subl $16, %%edi \n\t" - "subl $4, %%ecx \n\t" - "jnz .loop1_pass2 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list -#endif - ); - } - - sptr -= width_mmx; - dp -= width_mmx*4; - for (i = width; i; i--) - { - int j; - - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp-- = *sptr; - } - --sptr; - } - } - else if (width) /* && ((pass == 4) || (pass == 5)) */ - { - int width_mmx = ((width >> 3) << 3); - width -= width_mmx; // 0-3 pixels => 0-3 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $7, %%esi \n\t" - "subl $15, %%edi \n\t" - - ".loop1_pass4: \n\t" - "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 - "movq %%mm0, %%mm1 \n\t" // 7 6 5 4 3 2 1 0 - "punpcklbw %%mm0, %%mm0 \n\t" // 3 3 2 2 1 1 0 0 - "punpckhbw %%mm1, %%mm1 \n\t" // 7 7 6 6 5 5 4 4 - "movq %%mm1, 8(%%edi) \n\t" - "subl $8, %%esi \n\t" - "movq %%mm0, (%%edi) \n\t" - "subl $16, %%edi \n\t" - "subl $8, %%ecx \n\t" - "jnz .loop1_pass4 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (none) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list -#endif - ); - } - - sptr -= width_mmx; - dp -= width_mmx*2; - for (i = width; i; i--) - { - int j; - - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp-- = *sptr; - } - --sptr; - } - } - } /* end of pixel_bytes == 1 */ - - //-------------------------------------------------------------- - else if (pixel_bytes == 2) - { - if (((pass == 0) || (pass == 1)) && width) - { - int width_mmx = ((width >> 1) << 1); - width -= width_mmx; // 0,1 pixels => 0,2 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $2, %%esi \n\t" - "subl $30, %%edi \n\t" - - ".loop2_pass0: \n\t" - "movd (%%esi), %%mm0 \n\t" // x x x x 3 2 1 0 - "punpcklwd %%mm0, %%mm0 \n\t" // 3 2 3 2 1 0 1 0 - "movq %%mm0, %%mm1 \n\t" // 3 2 3 2 1 0 1 0 - "punpckldq %%mm0, %%mm0 \n\t" // 1 0 1 0 1 0 1 0 - "punpckhdq %%mm1, %%mm1 \n\t" // 3 2 3 2 3 2 3 2 - "movq %%mm0, (%%edi) \n\t" - "movq %%mm0, 8(%%edi) \n\t" - "movq %%mm1, 16(%%edi) \n\t" - "subl $4, %%esi \n\t" - "movq %%mm1, 24(%%edi) \n\t" - "subl $32, %%edi \n\t" - "subl $2, %%ecx \n\t" - "jnz .loop2_pass0 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list -#endif - ); - } - - sptr -= (width_mmx*2 - 2); // sign fixed - dp -= (width_mmx*16 - 2); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 2; - png_memcpy(v, sptr, 2); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 2; - png_memcpy(dp, v, 2); - } - } - } - else if (((pass == 2) || (pass == 3)) && width) - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; // 0,1 pixels => 0,2 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $2, %%esi \n\t" - "subl $14, %%edi \n\t" - - ".loop2_pass2: \n\t" - "movd (%%esi), %%mm0 \n\t" // x x x x 3 2 1 0 - "punpcklwd %%mm0, %%mm0 \n\t" // 3 2 3 2 1 0 1 0 - "movq %%mm0, %%mm1 \n\t" // 3 2 3 2 1 0 1 0 - "punpckldq %%mm0, %%mm0 \n\t" // 1 0 1 0 1 0 1 0 - "punpckhdq %%mm1, %%mm1 \n\t" // 3 2 3 2 3 2 3 2 - "movq %%mm0, (%%edi) \n\t" - "subl $4, %%esi \n\t" - "movq %%mm1, 8(%%edi) \n\t" - "subl $16, %%edi \n\t" - "subl $2, %%ecx \n\t" - "jnz .loop2_pass2 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list -#endif - ); - } - - sptr -= (width_mmx*2 - 2); // sign fixed - dp -= (width_mmx*8 - 2); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 2; - png_memcpy(v, sptr, 2); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 2; - png_memcpy(dp, v, 2); - } - } - } - else if (width) // pass == 4 or 5 - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; // 0,1 pixels => 0,2 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $2, %%esi \n\t" - "subl $6, %%edi \n\t" - - ".loop2_pass4: \n\t" - "movd (%%esi), %%mm0 \n\t" // x x x x 3 2 1 0 - "punpcklwd %%mm0, %%mm0 \n\t" // 3 2 3 2 1 0 1 0 - "subl $4, %%esi \n\t" - "movq %%mm0, (%%edi) \n\t" - "subl $8, %%edi \n\t" - "subl $2, %%ecx \n\t" - "jnz .loop2_pass4 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0" // clobber list -#endif - ); - } - - sptr -= (width_mmx*2 - 2); // sign fixed - dp -= (width_mmx*4 - 2); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 2; - png_memcpy(v, sptr, 2); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 2; - png_memcpy(dp, v, 2); - } - } - } - } /* end of pixel_bytes == 2 */ - - //-------------------------------------------------------------- - else if (pixel_bytes == 4) - { - if (((pass == 0) || (pass == 1)) && width) - { - int width_mmx = ((width >> 1) << 1); - width -= width_mmx; // 0,1 pixels => 0,4 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $4, %%esi \n\t" - "subl $60, %%edi \n\t" - - ".loop4_pass0: \n\t" - "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 - "movq %%mm0, %%mm1 \n\t" // 7 6 5 4 3 2 1 0 - "punpckldq %%mm0, %%mm0 \n\t" // 3 2 1 0 3 2 1 0 - "punpckhdq %%mm1, %%mm1 \n\t" // 7 6 5 4 7 6 5 4 - "movq %%mm0, (%%edi) \n\t" - "movq %%mm0, 8(%%edi) \n\t" - "movq %%mm0, 16(%%edi) \n\t" - "movq %%mm0, 24(%%edi) \n\t" - "movq %%mm1, 32(%%edi) \n\t" - "movq %%mm1, 40(%%edi) \n\t" - "movq %%mm1, 48(%%edi) \n\t" - "subl $8, %%esi \n\t" - "movq %%mm1, 56(%%edi) \n\t" - "subl $64, %%edi \n\t" - "subl $2, %%ecx \n\t" - "jnz .loop4_pass0 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list -#endif - ); - } - - sptr -= (width_mmx*4 - 4); // sign fixed - dp -= (width_mmx*32 - 4); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 4; - png_memcpy(v, sptr, 4); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 4; - png_memcpy(dp, v, 4); - } - } - } - else if (((pass == 2) || (pass == 3)) && width) - { - int width_mmx = ((width >> 1) << 1); - width -= width_mmx; // 0,1 pixels => 0,4 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $4, %%esi \n\t" - "subl $28, %%edi \n\t" - - ".loop4_pass2: \n\t" - "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 - "movq %%mm0, %%mm1 \n\t" // 7 6 5 4 3 2 1 0 - "punpckldq %%mm0, %%mm0 \n\t" // 3 2 1 0 3 2 1 0 - "punpckhdq %%mm1, %%mm1 \n\t" // 7 6 5 4 7 6 5 4 - "movq %%mm0, (%%edi) \n\t" - "movq %%mm0, 8(%%edi) \n\t" - "movq %%mm1, 16(%%edi) \n\t" - "movq %%mm1, 24(%%edi) \n\t" - "subl $8, %%esi \n\t" - "subl $32, %%edi \n\t" - "subl $2, %%ecx \n\t" - "jnz .loop4_pass2 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list -#endif - ); - } - - sptr -= (width_mmx*4 - 4); // sign fixed - dp -= (width_mmx*16 - 4); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 4; - png_memcpy(v, sptr, 4); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 4; - png_memcpy(dp, v, 4); - } - } - } - else if (width) // pass == 4 or 5 - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; // 0,1 pixels => 0,4 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $4, %%esi \n\t" - "subl $12, %%edi \n\t" - - ".loop4_pass4: \n\t" - "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 - "movq %%mm0, %%mm1 \n\t" // 7 6 5 4 3 2 1 0 - "punpckldq %%mm0, %%mm0 \n\t" // 3 2 1 0 3 2 1 0 - "punpckhdq %%mm1, %%mm1 \n\t" // 7 6 5 4 7 6 5 4 - "movq %%mm0, (%%edi) \n\t" - "subl $8, %%esi \n\t" - "movq %%mm1, 8(%%edi) \n\t" - "subl $16, %%edi \n\t" - "subl $2, %%ecx \n\t" - "jnz .loop4_pass4 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list -#endif - ); - } - - sptr -= (width_mmx*4 - 4); // sign fixed - dp -= (width_mmx*8 - 4); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 4; - png_memcpy(v, sptr, 4); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 4; - png_memcpy(dp, v, 4); - } - } - } - } /* end of pixel_bytes == 4 */ - - //-------------------------------------------------------------- - else if (pixel_bytes == 8) - { -// GRR TEST: should work, but needs testing (special 64-bit version of rpng2?) - // GRR NOTE: no need to combine passes here! - if (((pass == 0) || (pass == 1)) && width) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - // source is 8-byte RRGGBBAA - // dest is 64-byte RRGGBBAA RRGGBBAA RRGGBBAA RRGGBBAA ... - __asm__ __volatile__ ( - "subl $56, %%edi \n\t" // start of last block - - ".loop8_pass0: \n\t" - "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 - "movq %%mm0, (%%edi) \n\t" - "movq %%mm0, 8(%%edi) \n\t" - "movq %%mm0, 16(%%edi) \n\t" - "movq %%mm0, 24(%%edi) \n\t" - "movq %%mm0, 32(%%edi) \n\t" - "movq %%mm0, 40(%%edi) \n\t" - "movq %%mm0, 48(%%edi) \n\t" - "subl $8, %%esi \n\t" - "movq %%mm0, 56(%%edi) \n\t" - "subl $64, %%edi \n\t" - "decl %%ecx \n\t" - "jnz .loop8_pass0 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width) // ecx - -#if 0 /* %mm0 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0" // clobber list -#endif - ); - } - else if (((pass == 2) || (pass == 3)) && width) - { - // source is 8-byte RRGGBBAA - // dest is 32-byte RRGGBBAA RRGGBBAA RRGGBBAA RRGGBBAA - // (recall that expansion is _in place_: sptr and dp - // both point at locations within same row buffer) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $24, %%edi \n\t" // start of last block - - ".loop8_pass2: \n\t" - "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 - "movq %%mm0, (%%edi) \n\t" - "movq %%mm0, 8(%%edi) \n\t" - "movq %%mm0, 16(%%edi) \n\t" - "subl $8, %%esi \n\t" - "movq %%mm0, 24(%%edi) \n\t" - "subl $32, %%edi \n\t" - "decl %%ecx \n\t" - "jnz .loop8_pass2 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width) // ecx - -#if 0 /* %mm0 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0" // clobber list -#endif - ); - } - } - else if (width) // pass == 4 or 5 - { - // source is 8-byte RRGGBBAA - // dest is 16-byte RRGGBBAA RRGGBBAA - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $8, %%edi \n\t" // start of last block - - ".loop8_pass4: \n\t" - "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 - "movq %%mm0, (%%edi) \n\t" - "subl $8, %%esi \n\t" - "movq %%mm0, 8(%%edi) \n\t" - "subl $16, %%edi \n\t" - "decl %%ecx \n\t" - "jnz .loop8_pass4 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width) // ecx - -#if 0 /* %mm0 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0" // clobber list -#endif - ); - } - } - - } /* end of pixel_bytes == 8 */ - - //-------------------------------------------------------------- - else if (pixel_bytes == 6) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, 6); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 6); - dp -= 6; - } - sptr -= 6; - } - } /* end of pixel_bytes == 6 */ - - //-------------------------------------------------------------- - else - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr-= pixel_bytes; - } - } - } // end of _mmx_supported ======================================== - - else /* MMX not supported: use modified C code - takes advantage - * of inlining of png_memcpy for a constant */ - /* GRR 19991007: does it? or should pixel_bytes in each - * block be replaced with immediate value (e.g., 1)? */ - /* GRR 19991017: replaced with constants in each case */ -#endif /* PNG_MMX_CODE_SUPPORTED */ - { - if (pixel_bytes == 1) - { - for (i = width; i; i--) - { - int j; - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp-- = *sptr; - } - --sptr; - } - } - else if (pixel_bytes == 3) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, 3); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 3); - dp -= 3; - } - sptr -= 3; - } - } - else if (pixel_bytes == 2) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, 2); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 2); - dp -= 2; - } - sptr -= 2; - } - } - else if (pixel_bytes == 4) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, 4); - for (j = 0; j < png_pass_inc[pass]; j++) - { -#ifdef PNG_DEBUG - if (dp < row || dp+3 > row+png_ptr->row_buf_size) - { - printf("dp out of bounds: row=%d, dp=%d, rp=%d\n", - row, dp, row+png_ptr->row_buf_size); - printf("row_buf=%d\n",png_ptr->row_buf_size); - } -#endif - png_memcpy(dp, v, 4); - dp -= 4; - } - sptr -= 4; - } - } - else if (pixel_bytes == 6) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, 6); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 6); - dp -= 6; - } - sptr -= 6; - } - } - else if (pixel_bytes == 8) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, 8); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 8); - dp -= 8; - } - sptr -= 8; - } - } - else /* GRR: should never be reached */ - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr -= pixel_bytes; - } - } - - } /* end if (MMX not supported) */ - break; - } - } /* end switch (row_info->pixel_depth) */ - - row_info->width = final_width; - - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,final_width); - } - -} /* end png_do_read_interlace() */ - -#endif /* PNG_HAVE_MMX_READ_INTERLACE */ -#endif /* PNG_READ_INTERLACING_SUPPORTED */ - - - -#if defined(PNG_HAVE_MMX_READ_FILTER_ROW) -#if defined(PNG_MMX_CODE_SUPPORTED) - -// These variables are utilized in the functions below. They are declared -// globally here to ensure alignment on 8-byte boundaries. - -union uAll { - long long use; - double align; -} _LBCarryMask = {0x0101010101010101LL}, - _HBClearMask = {0x7f7f7f7f7f7f7f7fLL}, - _ActiveMask, _ActiveMask2, _ActiveMaskEnd, _ShiftBpp, _ShiftRem; - -#ifdef PNG_THREAD_UNSAFE_OK -//===========================================================================// -// // -// P N G _ R E A D _ F I L T E R _ R O W _ M M X _ A V G // -// // -//===========================================================================// - -// Optimized code for PNG Average filter decoder - -static void /* PRIVATE */ -png_read_filter_row_mmx_avg(png_row_infop row_info, png_bytep row, - png_bytep prev_row) -{ - int bpp; - int dummy_value_c; // fix 'forbidden register 2 (cx) was spilled' error - int dummy_value_S; - int dummy_value_D; - - bpp = (row_info->pixel_depth + 7) >> 3; // get # bytes per pixel - _FullLength = row_info->rowbytes; // # of bytes to filter - - __asm__ __volatile__ ( - // initialize address pointers and offset -#ifdef __PIC__ - "pushl %%ebx \n\t" // save index to Global Offset Table -#endif -//pre "movl row, %%edi \n\t" // edi: Avg(x) - "xorl %%ebx, %%ebx \n\t" // ebx: x - "movl %%edi, %%edx \n\t" -//pre "movl prev_row, %%esi \n\t" // esi: Prior(x) -//pre "subl bpp, %%edx \n\t" // (bpp is preloaded into ecx) - "subl %%ecx, %%edx \n\t" // edx: Raw(x-bpp) - - "xorl %%eax,%%eax \n\t" - - // Compute the Raw value for the first bpp bytes - // Raw(x) = Avg(x) + (Prior(x)/2) - "avg_rlp: \n\t" - "movb (%%esi,%%ebx,),%%al \n\t" // load al with Prior(x) - "incl %%ebx \n\t" - "shrb %%al \n\t" // divide by 2 - "addb -1(%%edi,%%ebx,),%%al \n\t" // add Avg(x); -1 to offset inc ebx -//pre "cmpl bpp, %%ebx \n\t" // (bpp is preloaded into ecx) - "cmpl %%ecx, %%ebx \n\t" - "movb %%al,-1(%%edi,%%ebx,) \n\t" // write Raw(x); -1 to offset inc ebx - "jb avg_rlp \n\t" // mov does not affect flags - - // get # of bytes to alignment - "movl %%edi, _dif \n\t" // take start of row - "addl %%ebx, _dif \n\t" // add bpp - "addl $0xf, _dif \n\t" // add 7+8 to incr past alignment bdry - "andl $0xfffffff8, _dif \n\t" // mask to alignment boundary - "subl %%edi, _dif \n\t" // subtract from start => value ebx at - "jz avg_go \n\t" // alignment - - // fix alignment - // Compute the Raw value for the bytes up to the alignment boundary - // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) - "xorl %%ecx, %%ecx \n\t" - - "avg_lp1: \n\t" - "xorl %%eax, %%eax \n\t" - "movb (%%esi,%%ebx,), %%cl \n\t" // load cl with Prior(x) - "movb (%%edx,%%ebx,), %%al \n\t" // load al with Raw(x-bpp) - "addw %%cx, %%ax \n\t" - "incl %%ebx \n\t" - "shrw %%ax \n\t" // divide by 2 - "addb -1(%%edi,%%ebx,), %%al \n\t" // add Avg(x); -1 to offset inc ebx - "cmpl _dif, %%ebx \n\t" // check if at alignment boundary - "movb %%al, -1(%%edi,%%ebx,) \n\t" // write Raw(x); -1 to offset inc ebx - "jb avg_lp1 \n\t" // repeat until at alignment boundary - - "avg_go: \n\t" - "movl _FullLength, %%eax \n\t" - "movl %%eax, %%ecx \n\t" - "subl %%ebx, %%eax \n\t" // subtract alignment fix - "andl $0x00000007, %%eax \n\t" // calc bytes over mult of 8 - "subl %%eax, %%ecx \n\t" // drop over bytes from original length - "movl %%ecx, _MMXLength \n\t" -#ifdef __PIC__ - "popl %%ebx \n\t" // restore index to Global Offset Table -#endif - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "0" (bpp), // ecx // input regs - "1" (prev_row), // esi - "2" (row) // edi - - : "%eax", "%edx" // clobber list -#ifndef __PIC__ - , "%ebx" -#endif - // GRR: INCLUDE "memory" as clobbered? (_dif, _MMXLength) - // (seems to work fine without...) - ); - - // now do the math for the rest of the row - switch (bpp) - { - case 3: - { - _ActiveMask.use = 0x0000000000ffffffLL; - _ShiftBpp.use = 24; // == 3 * 8 - _ShiftRem.use = 40; // == 64 - 24 - - __asm__ __volatile__ ( - // re-init address pointers and offset - "movq _ActiveMask, %%mm7 \n\t" - "movl _dif, %%ecx \n\t" // ecx: x = offset to - "movq _LBCarryMask, %%mm5 \n\t" // alignment boundary -// preload "movl row, %%edi \n\t" // edi: Avg(x) - "movq _HBClearMask, %%mm4 \n\t" -// preload "movl prev_row, %%esi \n\t" // esi: Prior(x) - - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm2 \n\t" // load previous aligned 8 bytes - // (correct pos. in loop below) - "avg_3lp: \n\t" - "movq (%%edi,%%ecx,), %%mm0 \n\t" // load mm0 with Avg(x) - "movq %%mm5, %%mm3 \n\t" - "psrlq _ShiftRem, %%mm2 \n\t" // correct position Raw(x-bpp) - // data - "movq (%%esi,%%ecx,), %%mm1 \n\t" // load mm1 with Prior(x) - "movq %%mm7, %%mm6 \n\t" - "pand %%mm1, %%mm3 \n\t" // get lsb for each prev_row byte - "psrlq $1, %%mm1 \n\t" // divide prev_row bytes by 2 - "pand %%mm4, %%mm1 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm0 \n\t" // add (Prev_row/2) to Avg for - // each byte - // add 1st active group (Raw(x-bpp)/2) to average with LBCarry - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting - // LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte - // where both - // lsb's were == 1 (only valid for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) - // for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 1 - // bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to - // Avg for each Active - // byte - // add 2nd active group (Raw(x-bpp)/2) to average with _LBCarry - "psllq _ShiftBpp, %%mm6 \n\t" // shift the mm6 mask to cover - // bytes 3-5 - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "psllq _ShiftBpp, %%mm2 \n\t" // shift data to pos. correctly - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting - // LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte - // where both - // lsb's were == 1 (only valid for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) - // for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 2 - // bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to - // Avg for each Active - // byte - - // add 3rd active group (Raw(x-bpp)/2) to average with _LBCarry - "psllq _ShiftBpp, %%mm6 \n\t" // shift mm6 mask to cover last - // two - // bytes - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "psllq _ShiftBpp, %%mm2 \n\t" // shift data to pos. correctly - // Data only needs to be shifted once here to - // get the correct x-bpp offset. - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting - // LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte - // where both - // lsb's were == 1 (only valid for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) - // for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 2 - // bytes to add to Avg - "addl $8, %%ecx \n\t" - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to - // Avg for each Active - // byte - // now ready to write back to memory - "movq %%mm0, -8(%%edi,%%ecx,) \n\t" - // move updated Raw(x) to use as Raw(x-bpp) for next loop - "cmpl _MMXLength, %%ecx \n\t" - "movq %%mm0, %%mm2 \n\t" // mov updated Raw(x) to mm2 - "jb avg_3lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; // end 3 bpp - - case 6: - case 4: - //case 7: // who wrote this? PNG doesn't support 5 or 7 bytes/pixel - //case 5: // GRR BOGUS - { - _ActiveMask.use = 0xffffffffffffffffLL; // use shift below to clear - // appropriate inactive bytes - _ShiftBpp.use = bpp << 3; - _ShiftRem.use = 64 - _ShiftBpp.use; - - __asm__ __volatile__ ( - "movq _HBClearMask, %%mm4 \n\t" - - // re-init address pointers and offset - "movl _dif, %%ecx \n\t" // ecx: x = offset to - // alignment boundary - - // load _ActiveMask and clear all bytes except for 1st active group - "movq _ActiveMask, %%mm7 \n\t" -// preload "movl row, %%edi \n\t" // edi: Avg(x) - "psrlq _ShiftRem, %%mm7 \n\t" -// preload "movl prev_row, %%esi \n\t" // esi: Prior(x) - "movq %%mm7, %%mm6 \n\t" - "movq _LBCarryMask, %%mm5 \n\t" - "psllq _ShiftBpp, %%mm6 \n\t" // create mask for 2nd active - // group - - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm2 \n\t" // load previous aligned 8 bytes - // (we correct pos. in loop below) - "avg_4lp: \n\t" - "movq (%%edi,%%ecx,), %%mm0 \n\t" - "psrlq _ShiftRem, %%mm2 \n\t" // shift data to pos. correctly - "movq (%%esi,%%ecx,), %%mm1 \n\t" - // add (Prev_row/2) to average - "movq %%mm5, %%mm3 \n\t" - "pand %%mm1, %%mm3 \n\t" // get lsb for each prev_row byte - "psrlq $1, %%mm1 \n\t" // divide prev_row bytes by 2 - "pand %%mm4, %%mm1 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm0 \n\t" // add (Prev_row/2) to Avg for - // each byte - // add 1st active group (Raw(x-bpp)/2) to average with _LBCarry - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting - // LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte - // where both - // lsb's were == 1 (only valid for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) - // for each byte - "pand %%mm7, %%mm2 \n\t" // leave only Active Group 1 - // bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to Avg - // for each Active - // byte - // add 2nd active group (Raw(x-bpp)/2) to average with _LBCarry - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "psllq _ShiftBpp, %%mm2 \n\t" // shift data to pos. correctly - "addl $8, %%ecx \n\t" - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting - // LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte - // where both - // lsb's were == 1 (only valid for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) - // for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 2 - // bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to - // Avg for each Active - // byte - "cmpl _MMXLength, %%ecx \n\t" - // now ready to write back to memory - "movq %%mm0, -8(%%edi,%%ecx,) \n\t" - // prep Raw(x-bpp) for next loop - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "jb avg_4lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; // end 4,6 bpp - - case 2: - { - _ActiveMask.use = 0x000000000000ffffLL; - _ShiftBpp.use = 16; // == 2 * 8 - _ShiftRem.use = 48; // == 64 - 16 - - __asm__ __volatile__ ( - // load _ActiveMask - "movq _ActiveMask, %%mm7 \n\t" - // re-init address pointers and offset - "movl _dif, %%ecx \n\t" // ecx: x = offset to alignment - // boundary - "movq _LBCarryMask, %%mm5 \n\t" -// preload "movl row, %%edi \n\t" // edi: Avg(x) - "movq _HBClearMask, %%mm4 \n\t" -// preload "movl prev_row, %%esi \n\t" // esi: Prior(x) - - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm2 \n\t" // load previous aligned 8 bytes - // (we correct pos. in loop below) - "avg_2lp: \n\t" - "movq (%%edi,%%ecx,), %%mm0 \n\t" - "psrlq _ShiftRem, %%mm2 \n\t" // shift data to pos. correctly - "movq (%%esi,%%ecx,), %%mm1 \n\t" // (GRR BUGFIX: was psllq) - // add (Prev_row/2) to average - "movq %%mm5, %%mm3 \n\t" - "pand %%mm1, %%mm3 \n\t" // get lsb for each prev_row byte - "psrlq $1, %%mm1 \n\t" // divide prev_row bytes by 2 - "pand %%mm4, %%mm1 \n\t" // clear invalid bit 7 of each - // byte - "movq %%mm7, %%mm6 \n\t" - "paddb %%mm1, %%mm0 \n\t" // add (Prev_row/2) to Avg for - // each byte - - // add 1st active group (Raw(x-bpp)/2) to average with _LBCarry - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting - // LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte - // where both - // lsb's were == 1 (only valid - // for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) - // for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 1 - // bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to Avg - // for each Active byte - - // add 2nd active group (Raw(x-bpp)/2) to average with _LBCarry - "psllq _ShiftBpp, %%mm6 \n\t" // shift the mm6 mask to cover - // bytes 2 & 3 - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "psllq _ShiftBpp, %%mm2 \n\t" // shift data to pos. correctly - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting - // LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte - // where both - // lsb's were == 1 (only valid - // for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) - // for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 2 - // bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to - // Avg for each Active byte - - // add 3rd active group (Raw(x-bpp)/2) to average with _LBCarry - "psllq _ShiftBpp, %%mm6 \n\t" // shift the mm6 mask to cover - // bytes 4 & 5 - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "psllq _ShiftBpp, %%mm2 \n\t" // shift data to pos. correctly - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting - // LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte - // where both lsb's were == 1 - // (only valid for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) - // for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 2 - // bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to - // Avg for each Active byte - - // add 4th active group (Raw(x-bpp)/2) to average with _LBCarry - "psllq _ShiftBpp, %%mm6 \n\t" // shift the mm6 mask to cover - // bytes 6 & 7 - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "psllq _ShiftBpp, %%mm2 \n\t" // shift data to pos. correctly - "addl $8, %%ecx \n\t" - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting - // LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte - // where both - // lsb's were == 1 (only valid - // for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) - // for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 2 - // bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to - // Avg for each Active byte - - "cmpl _MMXLength, %%ecx \n\t" - // now ready to write back to memory - "movq %%mm0, -8(%%edi,%%ecx,) \n\t" - // prep Raw(x-bpp) for next loop - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "jb avg_2lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; // end 2 bpp - - case 1: - { - __asm__ __volatile__ ( - // re-init address pointers and offset -#ifdef __PIC__ - "pushl %%ebx \n\t" // save Global Offset Table index -#endif - "movl _dif, %%ebx \n\t" // ebx: x = offset to alignment - // boundary -// preload "movl row, %%edi \n\t" // edi: Avg(x) - "cmpl _FullLength, %%ebx \n\t" // test if offset at end of array - "jnb avg_1end \n\t" - // do Paeth decode for remaining bytes -// preload "movl prev_row, %%esi \n\t" // esi: Prior(x) - "movl %%edi, %%edx \n\t" -// preload "subl bpp, %%edx \n\t" // (bpp is preloaded into ecx) - "subl %%ecx, %%edx \n\t" // edx: Raw(x-bpp) - "xorl %%ecx, %%ecx \n\t" // zero ecx before using cl & cx - // in loop below - "avg_1lp: \n\t" - // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) - "xorl %%eax, %%eax \n\t" - "movb (%%esi,%%ebx,), %%cl \n\t" // load cl with Prior(x) - "movb (%%edx,%%ebx,), %%al \n\t" // load al with Raw(x-bpp) - "addw %%cx, %%ax \n\t" - "incl %%ebx \n\t" - "shrw %%ax \n\t" // divide by 2 - "addb -1(%%edi,%%ebx,), %%al \n\t" // add Avg(x); -1 to offset - // inc ebx - "cmpl _FullLength, %%ebx \n\t" // check if at end of array - "movb %%al, -1(%%edi,%%ebx,) \n\t" // write back Raw(x); - // mov does not affect flags; -1 to offset inc ebx - "jb avg_1lp \n\t" - - "avg_1end: \n\t" -#ifdef __PIC__ - "popl %%ebx \n\t" // Global Offset Table index -#endif - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "0" (bpp), // ecx // input regs - "1" (prev_row), // esi - "2" (row) // edi - - : "%eax", "%edx" // clobber list -#ifndef __PIC__ - , "%ebx" -#endif - ); - } - return; // end 1 bpp - - case 8: - { - __asm__ __volatile__ ( - // re-init address pointers and offset - "movl _dif, %%ecx \n\t" // ecx: x == offset to alignment - "movq _LBCarryMask, %%mm5 \n\t" // boundary -// preload "movl row, %%edi \n\t" // edi: Avg(x) - "movq _HBClearMask, %%mm4 \n\t" -// preload "movl prev_row, %%esi \n\t" // esi: Prior(x) - - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm2 \n\t" // load previous aligned 8 bytes - // (NO NEED to correct pos. in loop below) - - "avg_8lp: \n\t" - "movq (%%edi,%%ecx,), %%mm0 \n\t" - "movq %%mm5, %%mm3 \n\t" - "movq (%%esi,%%ecx,), %%mm1 \n\t" - "addl $8, %%ecx \n\t" - "pand %%mm1, %%mm3 \n\t" // get lsb for each prev_row byte - "psrlq $1, %%mm1 \n\t" // divide prev_row bytes by 2 - "pand %%mm2, %%mm3 \n\t" // get LBCarrys for each byte - // where both lsb's were == 1 - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm1 \n\t" // clear invalid bit 7, each byte - "paddb %%mm3, %%mm0 \n\t" // add LBCarrys to Avg, each byte - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7, each byte - "paddb %%mm1, %%mm0 \n\t" // add (Prev_row/2) to Avg, each - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) to Avg for each - "cmpl _MMXLength, %%ecx \n\t" - "movq %%mm0, -8(%%edi,%%ecx,) \n\t" - "movq %%mm0, %%mm2 \n\t" // reuse as Raw(x-bpp) - "jb avg_8lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm5 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2" - , "%mm3", "%mm4", "%mm5" -#endif - ); - } - break; // end 8 bpp - - default: // bpp greater than 8 (!= 1,2,3,4,[5],6,[7],8) - { - -#ifdef PNG_DEBUG - // GRR: PRINT ERROR HERE: SHOULD NEVER BE REACHED - png_debug(1, - "Internal logic error in pnggccrd (png_read_filter_row_mmx_avg())\n"); -#endif - -#if 0 - __asm__ __volatile__ ( - "movq _LBCarryMask, %%mm5 \n\t" - // re-init address pointers and offset - "movl _dif, %%ebx \n\t" // ebx: x = offset to - // alignment boundary - "movl row, %%edi \n\t" // edi: Avg(x) - "movq _HBClearMask, %%mm4 \n\t" - "movl %%edi, %%edx \n\t" - "movl prev_row, %%esi \n\t" // esi: Prior(x) - "subl bpp, %%edx \n\t" // edx: Raw(x-bpp) - "avg_Alp: \n\t" - "movq (%%edi,%%ebx,), %%mm0 \n\t" - "movq %%mm5, %%mm3 \n\t" - "movq (%%esi,%%ebx,), %%mm1 \n\t" - "pand %%mm1, %%mm3 \n\t" // get lsb for each prev_row byte - "movq (%%edx,%%ebx,), %%mm2 \n\t" - "psrlq $1, %%mm1 \n\t" // divide prev_row bytes by 2 - "pand %%mm2, %%mm3 \n\t" // get LBCarrys for each byte - // where both lsb's were == 1 - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm1 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm3, %%mm0 \n\t" // add LBCarrys to Avg for each - // byte - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm0 \n\t" // add (Prev_row/2) to Avg for - // each byte - "addl $8, %%ebx \n\t" - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) to Avg for each - // byte - "cmpl _MMXLength, %%ebx \n\t" - "movq %%mm0, -8(%%edi,%%ebx,) \n\t" - "jb avg_Alp \n\t" - - : // FIXASM: output regs/vars go here, e.g.: "=m" (memory_var) - - : // FIXASM: input regs, e.g.: "c" (count), "S" (src), "D" (dest) - - : "%ebx", "%edx", "%edi", "%esi" // CHECKASM: clobber list - ); -#endif /* 0 - NEVER REACHED */ - } - break; - - } // end switch (bpp) - - __asm__ __volatile__ ( - // MMX acceleration complete; now do clean-up - // check if any remaining bytes left to decode -#ifdef __PIC__ - "pushl %%ebx \n\t" // save index to Global Offset Table -#endif - "movl _MMXLength, %%ebx \n\t" // ebx: x == offset bytes after MMX -//pre "movl row, %%edi \n\t" // edi: Avg(x) - "cmpl _FullLength, %%ebx \n\t" // test if offset at end of array - "jnb avg_end \n\t" - - // do Avg decode for remaining bytes -//pre "movl prev_row, %%esi \n\t" // esi: Prior(x) - "movl %%edi, %%edx \n\t" -//pre "subl bpp, %%edx \n\t" // (bpp is preloaded into ecx) - "subl %%ecx, %%edx \n\t" // edx: Raw(x-bpp) - "xorl %%ecx, %%ecx \n\t" // zero ecx before using cl & cx below - - "avg_lp2: \n\t" - // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) - "xorl %%eax, %%eax \n\t" - "movb (%%esi,%%ebx,), %%cl \n\t" // load cl with Prior(x) - "movb (%%edx,%%ebx,), %%al \n\t" // load al with Raw(x-bpp) - "addw %%cx, %%ax \n\t" - "incl %%ebx \n\t" - "shrw %%ax \n\t" // divide by 2 - "addb -1(%%edi,%%ebx,), %%al \n\t" // add Avg(x); -1 to offset inc ebx - "cmpl _FullLength, %%ebx \n\t" // check if at end of array - "movb %%al, -1(%%edi,%%ebx,) \n\t" // write back Raw(x) [mov does not - "jb avg_lp2 \n\t" // affect flags; -1 to offset inc ebx] - - "avg_end: \n\t" - "EMMS \n\t" // end MMX; prep for poss. FP instrs. -#ifdef __PIC__ - "popl %%ebx \n\t" // restore index to Global Offset Table -#endif - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "0" (bpp), // ecx // input regs - "1" (prev_row), // esi - "2" (row) // edi - - : "%eax", "%edx" // clobber list -#ifndef __PIC__ - , "%ebx" -#endif - ); - -} /* end png_read_filter_row_mmx_avg() */ -#endif - - - -#ifdef PNG_THREAD_UNSAFE_OK -//===========================================================================// -// // -// P N G _ R E A D _ F I L T E R _ R O W _ M M X _ P A E T H // -// // -//===========================================================================// - -// Optimized code for PNG Paeth filter decoder - -static void /* PRIVATE */ -png_read_filter_row_mmx_paeth(png_row_infop row_info, png_bytep row, - png_bytep prev_row) -{ - int bpp; - int dummy_value_c; // fix 'forbidden register 2 (cx) was spilled' error - int dummy_value_S; - int dummy_value_D; - - bpp = (row_info->pixel_depth + 7) >> 3; // Get # bytes per pixel - _FullLength = row_info->rowbytes; // # of bytes to filter - - __asm__ __volatile__ ( -#ifdef __PIC__ - "pushl %%ebx \n\t" // save index to Global Offset Table -#endif - "xorl %%ebx, %%ebx \n\t" // ebx: x offset -//pre "movl row, %%edi \n\t" - "xorl %%edx, %%edx \n\t" // edx: x-bpp offset -//pre "movl prev_row, %%esi \n\t" - "xorl %%eax, %%eax \n\t" - - // Compute the Raw value for the first bpp bytes - // Note: the formula works out to be always - // Paeth(x) = Raw(x) + Prior(x) where x < bpp - "paeth_rlp: \n\t" - "movb (%%edi,%%ebx,), %%al \n\t" - "addb (%%esi,%%ebx,), %%al \n\t" - "incl %%ebx \n\t" -//pre "cmpl bpp, %%ebx \n\t" (bpp is preloaded into ecx) - "cmpl %%ecx, %%ebx \n\t" - "movb %%al, -1(%%edi,%%ebx,) \n\t" - "jb paeth_rlp \n\t" - // get # of bytes to alignment - "movl %%edi, _dif \n\t" // take start of row - "addl %%ebx, _dif \n\t" // add bpp - "xorl %%ecx, %%ecx \n\t" - "addl $0xf, _dif \n\t" // add 7 + 8 to incr past alignment - // boundary - "andl $0xfffffff8, _dif \n\t" // mask to alignment boundary - "subl %%edi, _dif \n\t" // subtract from start ==> value ebx - // at alignment - "jz paeth_go \n\t" - // fix alignment - - "paeth_lp1: \n\t" - "xorl %%eax, %%eax \n\t" - // pav = p - a = (a + b - c) - a = b - c - "movb (%%esi,%%ebx,), %%al \n\t" // load Prior(x) into al - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "subl %%ecx, %%eax \n\t" // subtract Prior(x-bpp) - "movl %%eax, _patemp \n\t" // Save pav for later use - "xorl %%eax, %%eax \n\t" - // pbv = p - b = (a + b - c) - b = a - c - "movb (%%edi,%%edx,), %%al \n\t" // load Raw(x-bpp) into al - "subl %%ecx, %%eax \n\t" // subtract Prior(x-bpp) - "movl %%eax, %%ecx \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "addl _patemp, %%eax \n\t" // pcv = pav + pbv - // pc = abs(pcv) - "testl $0x80000000, %%eax \n\t" - "jz paeth_pca \n\t" - "negl %%eax \n\t" // reverse sign of neg values - - "paeth_pca: \n\t" - "movl %%eax, _pctemp \n\t" // save pc for later use - // pb = abs(pbv) - "testl $0x80000000, %%ecx \n\t" - "jz paeth_pba \n\t" - "negl %%ecx \n\t" // reverse sign of neg values - - "paeth_pba: \n\t" - "movl %%ecx, _pbtemp \n\t" // save pb for later use - // pa = abs(pav) - "movl _patemp, %%eax \n\t" - "testl $0x80000000, %%eax \n\t" - "jz paeth_paa \n\t" - "negl %%eax \n\t" // reverse sign of neg values - - "paeth_paa: \n\t" - "movl %%eax, _patemp \n\t" // save pa for later use - // test if pa <= pb - "cmpl %%ecx, %%eax \n\t" - "jna paeth_abb \n\t" - // pa > pb; now test if pb <= pc - "cmpl _pctemp, %%ecx \n\t" - "jna paeth_bbc \n\t" - // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "jmp paeth_paeth \n\t" - - "paeth_bbc: \n\t" - // pb <= pc; Raw(x) = Paeth(x) + Prior(x) - "movb (%%esi,%%ebx,), %%cl \n\t" // load Prior(x) into cl - "jmp paeth_paeth \n\t" - - "paeth_abb: \n\t" - // pa <= pb; now test if pa <= pc - "cmpl _pctemp, %%eax \n\t" - "jna paeth_abc \n\t" - // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "jmp paeth_paeth \n\t" - - "paeth_abc: \n\t" - // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) - "movb (%%edi,%%edx,), %%cl \n\t" // load Raw(x-bpp) into cl - - "paeth_paeth: \n\t" - "incl %%ebx \n\t" - "incl %%edx \n\t" - // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 - "addb %%cl, -1(%%edi,%%ebx,) \n\t" - "cmpl _dif, %%ebx \n\t" - "jb paeth_lp1 \n\t" - - "paeth_go: \n\t" - "movl _FullLength, %%ecx \n\t" - "movl %%ecx, %%eax \n\t" - "subl %%ebx, %%eax \n\t" // subtract alignment fix - "andl $0x00000007, %%eax \n\t" // calc bytes over mult of 8 - "subl %%eax, %%ecx \n\t" // drop over bytes from original length - "movl %%ecx, _MMXLength \n\t" -#ifdef __PIC__ - "popl %%ebx \n\t" // restore index to Global Offset Table -#endif - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "0" (bpp), // ecx // input regs - "1" (prev_row), // esi - "2" (row) // edi - - : "%eax", "%edx" // clobber list -#ifndef __PIC__ - , "%ebx" -#endif - ); - - // now do the math for the rest of the row - switch (bpp) - { - case 3: - { - _ActiveMask.use = 0x0000000000ffffffLL; - _ActiveMaskEnd.use = 0xffff000000000000LL; - _ShiftBpp.use = 24; // == bpp(3) * 8 - _ShiftRem.use = 40; // == 64 - 24 - - __asm__ __volatile__ ( - "movl _dif, %%ecx \n\t" -// preload "movl row, %%edi \n\t" -// preload "movl prev_row, %%esi \n\t" - "pxor %%mm0, %%mm0 \n\t" - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm1 \n\t" - "paeth_3lp: \n\t" - "psrlq _ShiftRem, %%mm1 \n\t" // shift last 3 bytes to 1st - // 3 bytes - "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) - "punpcklbw %%mm0, %%mm1 \n\t" // unpack High bytes of a - "movq -8(%%esi,%%ecx,), %%mm3 \n\t" // prep c=Prior(x-bpp) bytes - "punpcklbw %%mm0, %%mm2 \n\t" // unpack High bytes of b - "psrlq _ShiftRem, %%mm3 \n\t" // shift last 3 bytes to 1st - // 3 bytes - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - "punpcklbw %%mm0, %%mm3 \n\t" // unpack High bytes of c - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - "pxor %%mm7, %%mm7 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "paddw %%mm5, %%mm6 \n\t" - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "psubw %%mm0, %%mm4 \n\t" - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pxor %%mm1, %%mm1 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "packuswb %%mm1, %%mm7 \n\t" - "movq (%%esi,%%ecx,), %%mm3 \n\t" // load c=Prior(x-bpp) - "pand _ActiveMask, %%mm7 \n\t" - "movq %%mm3, %%mm2 \n\t" // load b=Prior(x) step 1 - "paddb (%%edi,%%ecx,), %%mm7 \n\t" // add Paeth predictor with Raw(x) - "punpcklbw %%mm0, %%mm3 \n\t" // unpack High bytes of c - "movq %%mm7, (%%edi,%%ecx,) \n\t" // write back updated value - "movq %%mm7, %%mm1 \n\t" // now mm1 will be used as - // Raw(x-bpp) - // now do Paeth for 2nd set of bytes (3-5) - "psrlq _ShiftBpp, %%mm2 \n\t" // load b=Prior(x) step 2 - "punpcklbw %%mm0, %%mm1 \n\t" // unpack High bytes of a - "pxor %%mm7, %%mm7 \n\t" - "punpcklbw %%mm0, %%mm2 \n\t" // unpack High bytes of b - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - "psubw %%mm3, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = - // pav + pbv = pbv + pav - "movq %%mm5, %%mm6 \n\t" - "paddw %%mm4, %%mm6 \n\t" - - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm5, %%mm0 \n\t" // create mask pbv bytes < 0 - "pcmpgtw %%mm4, %%mm7 \n\t" // create mask pav bytes < 0 - "pand %%mm5, %%mm0 \n\t" // only pbv bytes < 0 in mm0 - "pand %%mm4, %%mm7 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm0, %%mm5 \n\t" - "psubw %%mm7, %%mm4 \n\t" - "psubw %%mm0, %%mm5 \n\t" - "psubw %%mm7, %%mm4 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "pxor %%mm1, %%mm1 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "packuswb %%mm1, %%mm7 \n\t" - "movq %%mm2, %%mm3 \n\t" // load c=Prior(x-bpp) step 1 - "pand _ActiveMask, %%mm7 \n\t" - "punpckhbw %%mm0, %%mm2 \n\t" // unpack High bytes of b - "psllq _ShiftBpp, %%mm7 \n\t" // shift bytes to 2nd group of - // 3 bytes - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - "paddb (%%edi,%%ecx,), %%mm7 \n\t" // add Paeth predictor with Raw(x) - "psllq _ShiftBpp, %%mm3 \n\t" // load c=Prior(x-bpp) step 2 - "movq %%mm7, (%%edi,%%ecx,) \n\t" // write back updated value - "movq %%mm7, %%mm1 \n\t" - "punpckhbw %%mm0, %%mm3 \n\t" // unpack High bytes of c - "psllq _ShiftBpp, %%mm1 \n\t" // shift bytes - // now mm1 will be used as Raw(x-bpp) - // now do Paeth for 3rd, and final, set of bytes (6-7) - "pxor %%mm7, %%mm7 \n\t" - "punpckhbw %%mm0, %%mm1 \n\t" // unpack High bytes of a - "psubw %%mm3, %%mm4 \n\t" - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "paddw %%mm5, %%mm6 \n\t" - - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm1, %%mm1 \n\t" - "packuswb %%mm7, %%mm1 \n\t" - // step ecx to next set of 8 bytes and repeat loop til done - "addl $8, %%ecx \n\t" - "pand _ActiveMaskEnd, %%mm1 \n\t" - "paddb -8(%%edi,%%ecx,), %%mm1 \n\t" // add Paeth predictor with - // Raw(x) - - "cmpl _MMXLength, %%ecx \n\t" - "pxor %%mm0, %%mm0 \n\t" // pxor does not affect flags - "movq %%mm1, -8(%%edi,%%ecx,) \n\t" // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - // mm3 ready to be used as Prior(x-bpp) next loop - "jb paeth_3lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; // end 3 bpp - - case 6: - //case 7: // GRR BOGUS - //case 5: // GRR BOGUS - { - _ActiveMask.use = 0x00000000ffffffffLL; - _ActiveMask2.use = 0xffffffff00000000LL; - _ShiftBpp.use = bpp << 3; // == bpp * 8 - _ShiftRem.use = 64 - _ShiftBpp.use; - - __asm__ __volatile__ ( - "movl _dif, %%ecx \n\t" -// preload "movl row, %%edi \n\t" -// preload "movl prev_row, %%esi \n\t" - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm1 \n\t" - "pxor %%mm0, %%mm0 \n\t" - - "paeth_6lp: \n\t" - // must shift to position Raw(x-bpp) data - "psrlq _ShiftRem, %%mm1 \n\t" - // do first set of 4 bytes - "movq -8(%%esi,%%ecx,), %%mm3 \n\t" // read c=Prior(x-bpp) bytes - "punpcklbw %%mm0, %%mm1 \n\t" // unpack Low bytes of a - "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) - "punpcklbw %%mm0, %%mm2 \n\t" // unpack Low bytes of b - // must shift to position Prior(x-bpp) data - "psrlq _ShiftRem, %%mm3 \n\t" - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - "punpcklbw %%mm0, %%mm3 \n\t" // unpack Low bytes of c - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - "pxor %%mm7, %%mm7 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "paddw %%mm5, %%mm6 \n\t" - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "psubw %%mm0, %%mm4 \n\t" - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pxor %%mm1, %%mm1 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "packuswb %%mm1, %%mm7 \n\t" - "movq -8(%%esi,%%ecx,), %%mm3 \n\t" // load c=Prior(x-bpp) - "pand _ActiveMask, %%mm7 \n\t" - "psrlq _ShiftRem, %%mm3 \n\t" - "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) step 1 - "paddb (%%edi,%%ecx,), %%mm7 \n\t" // add Paeth predictor and Raw(x) - "movq %%mm2, %%mm6 \n\t" - "movq %%mm7, (%%edi,%%ecx,) \n\t" // write back updated value - "movq -8(%%edi,%%ecx,), %%mm1 \n\t" - "psllq _ShiftBpp, %%mm6 \n\t" - "movq %%mm7, %%mm5 \n\t" - "psrlq _ShiftRem, %%mm1 \n\t" - "por %%mm6, %%mm3 \n\t" - "psllq _ShiftBpp, %%mm5 \n\t" - "punpckhbw %%mm0, %%mm3 \n\t" // unpack High bytes of c - "por %%mm5, %%mm1 \n\t" - // do second set of 4 bytes - "punpckhbw %%mm0, %%mm2 \n\t" // unpack High bytes of b - "punpckhbw %%mm0, %%mm1 \n\t" // unpack High bytes of a - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - "pxor %%mm7, %%mm7 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "paddw %%mm5, %%mm6 \n\t" - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "psubw %%mm0, %%mm4 \n\t" - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pxor %%mm1, %%mm1 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "pxor %%mm1, %%mm1 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - // step ecx to next set of 8 bytes and repeat loop til done - "addl $8, %%ecx \n\t" - "packuswb %%mm7, %%mm1 \n\t" - "paddb -8(%%edi,%%ecx,), %%mm1 \n\t" // add Paeth predictor with Raw(x) - "cmpl _MMXLength, %%ecx \n\t" - "movq %%mm1, -8(%%edi,%%ecx,) \n\t" // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - "jb paeth_6lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; // end 6 bpp - - case 4: - { - _ActiveMask.use = 0x00000000ffffffffLL; - - __asm__ __volatile__ ( - "movl _dif, %%ecx \n\t" -// preload "movl row, %%edi \n\t" -// preload "movl prev_row, %%esi \n\t" - "pxor %%mm0, %%mm0 \n\t" - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm1 \n\t" // only time should need to read - // a=Raw(x-bpp) bytes - "paeth_4lp: \n\t" - // do first set of 4 bytes - "movq -8(%%esi,%%ecx,), %%mm3 \n\t" // read c=Prior(x-bpp) bytes - "punpckhbw %%mm0, %%mm1 \n\t" // unpack Low bytes of a - "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) - "punpcklbw %%mm0, %%mm2 \n\t" // unpack High bytes of b - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - "punpckhbw %%mm0, %%mm3 \n\t" // unpack High bytes of c - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - "pxor %%mm7, %%mm7 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "paddw %%mm5, %%mm6 \n\t" - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "psubw %%mm0, %%mm4 \n\t" - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pxor %%mm1, %%mm1 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "packuswb %%mm1, %%mm7 \n\t" - "movq (%%esi,%%ecx,), %%mm3 \n\t" // load c=Prior(x-bpp) - "pand _ActiveMask, %%mm7 \n\t" - "movq %%mm3, %%mm2 \n\t" // load b=Prior(x) step 1 - "paddb (%%edi,%%ecx,), %%mm7 \n\t" // add Paeth predictor with Raw(x) - "punpcklbw %%mm0, %%mm3 \n\t" // unpack High bytes of c - "movq %%mm7, (%%edi,%%ecx,) \n\t" // write back updated value - "movq %%mm7, %%mm1 \n\t" // now mm1 will be used as Raw(x-bpp) - // do second set of 4 bytes - "punpckhbw %%mm0, %%mm2 \n\t" // unpack Low bytes of b - "punpcklbw %%mm0, %%mm1 \n\t" // unpack Low bytes of a - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - "pxor %%mm7, %%mm7 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "paddw %%mm5, %%mm6 \n\t" - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "psubw %%mm0, %%mm4 \n\t" - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pxor %%mm1, %%mm1 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "pxor %%mm1, %%mm1 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - // step ecx to next set of 8 bytes and repeat loop til done - "addl $8, %%ecx \n\t" - "packuswb %%mm7, %%mm1 \n\t" - "paddb -8(%%edi,%%ecx,), %%mm1 \n\t" // add predictor with Raw(x) - "cmpl _MMXLength, %%ecx \n\t" - "movq %%mm1, -8(%%edi,%%ecx,) \n\t" // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - "jb paeth_4lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; // end 4 bpp - - case 8: // bpp == 8 - { - _ActiveMask.use = 0x00000000ffffffffLL; - - __asm__ __volatile__ ( - "movl _dif, %%ecx \n\t" -// preload "movl row, %%edi \n\t" -// preload "movl prev_row, %%esi \n\t" - "pxor %%mm0, %%mm0 \n\t" - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm1 \n\t" // only time should need to read - // a=Raw(x-bpp) bytes - "paeth_8lp: \n\t" - // do first set of 4 bytes - "movq -8(%%esi,%%ecx,), %%mm3 \n\t" // read c=Prior(x-bpp) bytes - "punpcklbw %%mm0, %%mm1 \n\t" // unpack Low bytes of a - "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) - "punpcklbw %%mm0, %%mm2 \n\t" // unpack Low bytes of b - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - "punpcklbw %%mm0, %%mm3 \n\t" // unpack Low bytes of c - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - "pxor %%mm7, %%mm7 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "paddw %%mm5, %%mm6 \n\t" - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "psubw %%mm0, %%mm4 \n\t" - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pxor %%mm1, %%mm1 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "packuswb %%mm1, %%mm7 \n\t" - "movq -8(%%esi,%%ecx,), %%mm3 \n\t" // read c=Prior(x-bpp) bytes - "pand _ActiveMask, %%mm7 \n\t" - "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) - "paddb (%%edi,%%ecx,), %%mm7 \n\t" // add Paeth predictor with Raw(x) - "punpckhbw %%mm0, %%mm3 \n\t" // unpack High bytes of c - "movq %%mm7, (%%edi,%%ecx,) \n\t" // write back updated value - "movq -8(%%edi,%%ecx,), %%mm1 \n\t" // read a=Raw(x-bpp) bytes - - // do second set of 4 bytes - "punpckhbw %%mm0, %%mm2 \n\t" // unpack High bytes of b - "punpckhbw %%mm0, %%mm1 \n\t" // unpack High bytes of a - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - "pxor %%mm7, %%mm7 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "paddw %%mm5, %%mm6 \n\t" - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "psubw %%mm0, %%mm4 \n\t" - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pxor %%mm1, %%mm1 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "pxor %%mm1, %%mm1 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - // step ecx to next set of 8 bytes and repeat loop til done - "addl $8, %%ecx \n\t" - "packuswb %%mm7, %%mm1 \n\t" - "paddb -8(%%edi,%%ecx,), %%mm1 \n\t" // add Paeth predictor with Raw(x) - "cmpl _MMXLength, %%ecx \n\t" - "movq %%mm1, -8(%%edi,%%ecx,) \n\t" // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - "jb paeth_8lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; // end 8 bpp - - case 1: // bpp = 1 - case 2: // bpp = 2 - default: // bpp > 8 - { - __asm__ __volatile__ ( -#ifdef __PIC__ - "pushl %%ebx \n\t" // save Global Offset Table index -#endif - "movl _dif, %%ebx \n\t" - "cmpl _FullLength, %%ebx \n\t" - "jnb paeth_dend \n\t" - -// preload "movl row, %%edi \n\t" -// preload "movl prev_row, %%esi \n\t" - // do Paeth decode for remaining bytes - "movl %%ebx, %%edx \n\t" -// preload "subl bpp, %%edx \n\t" // (bpp is preloaded into ecx) - "subl %%ecx, %%edx \n\t" // edx = ebx - bpp - "xorl %%ecx, %%ecx \n\t" // zero ecx before using cl & cx - - "paeth_dlp: \n\t" - "xorl %%eax, %%eax \n\t" - // pav = p - a = (a + b - c) - a = b - c - "movb (%%esi,%%ebx,), %%al \n\t" // load Prior(x) into al - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "subl %%ecx, %%eax \n\t" // subtract Prior(x-bpp) - "movl %%eax, _patemp \n\t" // Save pav for later use - "xorl %%eax, %%eax \n\t" - // pbv = p - b = (a + b - c) - b = a - c - "movb (%%edi,%%edx,), %%al \n\t" // load Raw(x-bpp) into al - "subl %%ecx, %%eax \n\t" // subtract Prior(x-bpp) - "movl %%eax, %%ecx \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "addl _patemp, %%eax \n\t" // pcv = pav + pbv - // pc = abs(pcv) - "testl $0x80000000, %%eax \n\t" - "jz paeth_dpca \n\t" - "negl %%eax \n\t" // reverse sign of neg values - - "paeth_dpca: \n\t" - "movl %%eax, _pctemp \n\t" // save pc for later use - // pb = abs(pbv) - "testl $0x80000000, %%ecx \n\t" - "jz paeth_dpba \n\t" - "negl %%ecx \n\t" // reverse sign of neg values - - "paeth_dpba: \n\t" - "movl %%ecx, _pbtemp \n\t" // save pb for later use - // pa = abs(pav) - "movl _patemp, %%eax \n\t" - "testl $0x80000000, %%eax \n\t" - "jz paeth_dpaa \n\t" - "negl %%eax \n\t" // reverse sign of neg values - - "paeth_dpaa: \n\t" - "movl %%eax, _patemp \n\t" // save pa for later use - // test if pa <= pb - "cmpl %%ecx, %%eax \n\t" - "jna paeth_dabb \n\t" - // pa > pb; now test if pb <= pc - "cmpl _pctemp, %%ecx \n\t" - "jna paeth_dbbc \n\t" - // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "jmp paeth_dpaeth \n\t" - - "paeth_dbbc: \n\t" - // pb <= pc; Raw(x) = Paeth(x) + Prior(x) - "movb (%%esi,%%ebx,), %%cl \n\t" // load Prior(x) into cl - "jmp paeth_dpaeth \n\t" - - "paeth_dabb: \n\t" - // pa <= pb; now test if pa <= pc - "cmpl _pctemp, %%eax \n\t" - "jna paeth_dabc \n\t" - // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "jmp paeth_dpaeth \n\t" - - "paeth_dabc: \n\t" - // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) - "movb (%%edi,%%edx,), %%cl \n\t" // load Raw(x-bpp) into cl - - "paeth_dpaeth: \n\t" - "incl %%ebx \n\t" - "incl %%edx \n\t" - // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 - "addb %%cl, -1(%%edi,%%ebx,) \n\t" - "cmpl _FullLength, %%ebx \n\t" - "jb paeth_dlp \n\t" - - "paeth_dend: \n\t" -#ifdef __PIC__ - "popl %%ebx \n\t" // index to Global Offset Table -#endif - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "0" (bpp), // ecx // input regs - "1" (prev_row), // esi - "2" (row) // edi - - : "%eax", "%edx" // clobber list -#ifndef __PIC__ - , "%ebx" -#endif - ); - } - return; // No need to go further with this one - - } // end switch (bpp) - - __asm__ __volatile__ ( - // MMX acceleration complete; now do clean-up - // check if any remaining bytes left to decode -#ifdef __PIC__ - "pushl %%ebx \n\t" // save index to Global Offset Table -#endif - "movl _MMXLength, %%ebx \n\t" - "cmpl _FullLength, %%ebx \n\t" - "jnb paeth_end \n\t" -//pre "movl row, %%edi \n\t" -//pre "movl prev_row, %%esi \n\t" - // do Paeth decode for remaining bytes - "movl %%ebx, %%edx \n\t" -//pre "subl bpp, %%edx \n\t" // (bpp is preloaded into ecx) - "subl %%ecx, %%edx \n\t" // edx = ebx - bpp - "xorl %%ecx, %%ecx \n\t" // zero ecx before using cl & cx below - - "paeth_lp2: \n\t" - "xorl %%eax, %%eax \n\t" - // pav = p - a = (a + b - c) - a = b - c - "movb (%%esi,%%ebx,), %%al \n\t" // load Prior(x) into al - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "subl %%ecx, %%eax \n\t" // subtract Prior(x-bpp) - "movl %%eax, _patemp \n\t" // Save pav for later use - "xorl %%eax, %%eax \n\t" - // pbv = p - b = (a + b - c) - b = a - c - "movb (%%edi,%%edx,), %%al \n\t" // load Raw(x-bpp) into al - "subl %%ecx, %%eax \n\t" // subtract Prior(x-bpp) - "movl %%eax, %%ecx \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "addl _patemp, %%eax \n\t" // pcv = pav + pbv - // pc = abs(pcv) - "testl $0x80000000, %%eax \n\t" - "jz paeth_pca2 \n\t" - "negl %%eax \n\t" // reverse sign of neg values - - "paeth_pca2: \n\t" - "movl %%eax, _pctemp \n\t" // save pc for later use - // pb = abs(pbv) - "testl $0x80000000, %%ecx \n\t" - "jz paeth_pba2 \n\t" - "negl %%ecx \n\t" // reverse sign of neg values - - "paeth_pba2: \n\t" - "movl %%ecx, _pbtemp \n\t" // save pb for later use - // pa = abs(pav) - "movl _patemp, %%eax \n\t" - "testl $0x80000000, %%eax \n\t" - "jz paeth_paa2 \n\t" - "negl %%eax \n\t" // reverse sign of neg values - - "paeth_paa2: \n\t" - "movl %%eax, _patemp \n\t" // save pa for later use - // test if pa <= pb - "cmpl %%ecx, %%eax \n\t" - "jna paeth_abb2 \n\t" - // pa > pb; now test if pb <= pc - "cmpl _pctemp, %%ecx \n\t" - "jna paeth_bbc2 \n\t" - // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "jmp paeth_paeth2 \n\t" - - "paeth_bbc2: \n\t" - // pb <= pc; Raw(x) = Paeth(x) + Prior(x) - "movb (%%esi,%%ebx,), %%cl \n\t" // load Prior(x) into cl - "jmp paeth_paeth2 \n\t" - - "paeth_abb2: \n\t" - // pa <= pb; now test if pa <= pc - "cmpl _pctemp, %%eax \n\t" - "jna paeth_abc2 \n\t" - // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "jmp paeth_paeth2 \n\t" - - "paeth_abc2: \n\t" - // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) - "movb (%%edi,%%edx,), %%cl \n\t" // load Raw(x-bpp) into cl - - "paeth_paeth2: \n\t" - "incl %%ebx \n\t" - "incl %%edx \n\t" - // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 - "addb %%cl, -1(%%edi,%%ebx,) \n\t" - "cmpl _FullLength, %%ebx \n\t" - "jb paeth_lp2 \n\t" - - "paeth_end: \n\t" - "EMMS \n\t" // end MMX; prep for poss. FP instrs. -#ifdef __PIC__ - "popl %%ebx \n\t" // restore index to Global Offset Table -#endif - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "0" (bpp), // ecx // input regs - "1" (prev_row), // esi - "2" (row) // edi - - : "%eax", "%edx" // clobber list (no input regs!) -#ifndef __PIC__ - , "%ebx" -#endif - ); - -} /* end png_read_filter_row_mmx_paeth() */ -#endif - - - - -#ifdef PNG_THREAD_UNSAFE_OK -//===========================================================================// -// // -// P N G _ R E A D _ F I L T E R _ R O W _ M M X _ S U B // -// // -//===========================================================================// - -// Optimized code for PNG Sub filter decoder - -static void /* PRIVATE */ -png_read_filter_row_mmx_sub(png_row_infop row_info, png_bytep row) -{ - int bpp; - int dummy_value_a; - int dummy_value_D; - - bpp = (row_info->pixel_depth + 7) >> 3; // calc number of bytes per pixel - _FullLength = row_info->rowbytes - bpp; // number of bytes to filter - - __asm__ __volatile__ ( -//pre "movl row, %%edi \n\t" - "movl %%edi, %%esi \n\t" // lp = row -//pre "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp -//irr "xorl %%eax, %%eax \n\t" - // get # of bytes to alignment - "movl %%edi, _dif \n\t" // take start of row - "addl $0xf, _dif \n\t" // add 7 + 8 to incr past - // alignment boundary - "xorl %%ecx, %%ecx \n\t" - "andl $0xfffffff8, _dif \n\t" // mask to alignment boundary - "subl %%edi, _dif \n\t" // subtract from start ==> value - "jz sub_go \n\t" // ecx at alignment - - "sub_lp1: \n\t" // fix alignment - "movb (%%esi,%%ecx,), %%al \n\t" - "addb %%al, (%%edi,%%ecx,) \n\t" - "incl %%ecx \n\t" - "cmpl _dif, %%ecx \n\t" - "jb sub_lp1 \n\t" - - "sub_go: \n\t" - "movl _FullLength, %%eax \n\t" - "movl %%eax, %%edx \n\t" - "subl %%ecx, %%edx \n\t" // subtract alignment fix - "andl $0x00000007, %%edx \n\t" // calc bytes over mult of 8 - "subl %%edx, %%eax \n\t" // drop over bytes from length - "movl %%eax, _MMXLength \n\t" - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%esi", "%ecx", "%edx" // clobber list - -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - - // now do the math for the rest of the row - switch (bpp) - { - case 3: - { - _ActiveMask.use = 0x0000ffffff000000LL; - _ShiftBpp.use = 24; // == 3 * 8 - _ShiftRem.use = 40; // == 64 - 24 - - __asm__ __volatile__ ( -// preload "movl row, %%edi \n\t" - "movq _ActiveMask, %%mm7 \n\t" // load _ActiveMask for 2nd - // active byte group - "movl %%edi, %%esi \n\t" // lp = row -// preload "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp - "movq %%mm7, %%mm6 \n\t" - "movl _dif, %%edx \n\t" - "psllq _ShiftBpp, %%mm6 \n\t" // move mask in mm6 to cover - // 3rd active byte group - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%edx,), %%mm1 \n\t" - - "sub_3lp: \n\t" // shift data for adding first - "psrlq _ShiftRem, %%mm1 \n\t" // bpp bytes (no need for mask; - // shift clears inactive bytes) - // add 1st active group - "movq (%%edi,%%edx,), %%mm0 \n\t" - "paddb %%mm1, %%mm0 \n\t" - - // add 2nd active group - "movq %%mm0, %%mm1 \n\t" // mov updated Raws to mm1 - "psllq _ShiftBpp, %%mm1 \n\t" // shift data to pos. correctly - "pand %%mm7, %%mm1 \n\t" // mask to use 2nd active group - "paddb %%mm1, %%mm0 \n\t" - - // add 3rd active group - "movq %%mm0, %%mm1 \n\t" // mov updated Raws to mm1 - "psllq _ShiftBpp, %%mm1 \n\t" // shift data to pos. correctly - "pand %%mm6, %%mm1 \n\t" // mask to use 3rd active group - "addl $8, %%edx \n\t" - "paddb %%mm1, %%mm0 \n\t" - - "cmpl _MMXLength, %%edx \n\t" - "movq %%mm0, -8(%%edi,%%edx,) \n\t" // write updated Raws to array - "movq %%mm0, %%mm1 \n\t" // prep 1st add at top of loop - "jb sub_3lp \n\t" - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%edx", "%esi" // clobber list -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm6", "%mm7" -#endif - ); - } - break; - - case 1: - { - __asm__ __volatile__ ( - "movl _dif, %%edx \n\t" -// preload "movl row, %%edi \n\t" - "cmpl _FullLength, %%edx \n\t" - "jnb sub_1end \n\t" - "movl %%edi, %%esi \n\t" // lp = row - "xorl %%eax, %%eax \n\t" -// preload "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp - - "sub_1lp: \n\t" - "movb (%%esi,%%edx,), %%al \n\t" - "addb %%al, (%%edi,%%edx,) \n\t" - "incl %%edx \n\t" - "cmpl _FullLength, %%edx \n\t" - "jb sub_1lp \n\t" - - "sub_1end: \n\t" - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%edx", "%esi" // clobber list - ); - } - return; - - case 6: - case 4: - //case 7: // GRR BOGUS - //case 5: // GRR BOGUS - { - _ShiftBpp.use = bpp << 3; - _ShiftRem.use = 64 - _ShiftBpp.use; - - __asm__ __volatile__ ( -// preload "movl row, %%edi \n\t" - "movl _dif, %%edx \n\t" - "movl %%edi, %%esi \n\t" // lp = row -// preload "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp - - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%edx,), %%mm1 \n\t" - - "sub_4lp: \n\t" // shift data for adding first - "psrlq _ShiftRem, %%mm1 \n\t" // bpp bytes (no need for mask; - // shift clears inactive bytes) - "movq (%%edi,%%edx,), %%mm0 \n\t" - "paddb %%mm1, %%mm0 \n\t" - - // add 2nd active group - "movq %%mm0, %%mm1 \n\t" // mov updated Raws to mm1 - "psllq _ShiftBpp, %%mm1 \n\t" // shift data to pos. correctly - "addl $8, %%edx \n\t" - "paddb %%mm1, %%mm0 \n\t" - - "cmpl _MMXLength, %%edx \n\t" - "movq %%mm0, -8(%%edi,%%edx,) \n\t" - "movq %%mm0, %%mm1 \n\t" // prep 1st add at top of loop - "jb sub_4lp \n\t" - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%edx", "%esi" // clobber list -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1" -#endif - ); - } - break; - - case 2: - { - _ActiveMask.use = 0x00000000ffff0000LL; - _ShiftBpp.use = 16; // == 2 * 8 - _ShiftRem.use = 48; // == 64 - 16 - - __asm__ __volatile__ ( - "movq _ActiveMask, %%mm7 \n\t" // load _ActiveMask for 2nd - // active byte group - "movl _dif, %%edx \n\t" - "movq %%mm7, %%mm6 \n\t" -// preload "movl row, %%edi \n\t" - "psllq _ShiftBpp, %%mm6 \n\t" // move mask in mm6 to cover - // 3rd active byte group - "movl %%edi, %%esi \n\t" // lp = row - "movq %%mm6, %%mm5 \n\t" -// preload "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp - "psllq _ShiftBpp, %%mm5 \n\t" // move mask in mm5 to cover - // 4th active byte group - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%edx,), %%mm1 \n\t" - - "sub_2lp: \n\t" // shift data for adding first - "psrlq _ShiftRem, %%mm1 \n\t" // bpp bytes (no need for mask; - // shift clears inactive bytes) - // add 1st active group - "movq (%%edi,%%edx,), %%mm0 \n\t" - "paddb %%mm1, %%mm0 \n\t" - - // add 2nd active group - "movq %%mm0, %%mm1 \n\t" // mov updated Raws to mm1 - "psllq _ShiftBpp, %%mm1 \n\t" // shift data to pos. correctly - "pand %%mm7, %%mm1 \n\t" // mask to use 2nd active group - "paddb %%mm1, %%mm0 \n\t" - - // add 3rd active group - "movq %%mm0, %%mm1 \n\t" // mov updated Raws to mm1 - "psllq _ShiftBpp, %%mm1 \n\t" // shift data to pos. correctly - "pand %%mm6, %%mm1 \n\t" // mask to use 3rd active group - "paddb %%mm1, %%mm0 \n\t" - - // add 4th active group - "movq %%mm0, %%mm1 \n\t" // mov updated Raws to mm1 - "psllq _ShiftBpp, %%mm1 \n\t" // shift data to pos. correctly - "pand %%mm5, %%mm1 \n\t" // mask to use 4th active group - "addl $8, %%edx \n\t" - "paddb %%mm1, %%mm0 \n\t" - "cmpl _MMXLength, %%edx \n\t" - "movq %%mm0, -8(%%edi,%%edx,) \n\t" // write updated Raws to array - "movq %%mm0, %%mm1 \n\t" // prep 1st add at top of loop - "jb sub_2lp \n\t" - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%edx", "%esi" // clobber list -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; - - case 8: - { - __asm__ __volatile__ ( -// preload "movl row, %%edi \n\t" - "movl _dif, %%edx \n\t" - "movl %%edi, %%esi \n\t" // lp = row -// preload "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp - "movl _MMXLength, %%ecx \n\t" - - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%edx,), %%mm7 \n\t" - "andl $0x0000003f, %%ecx \n\t" // calc bytes over mult of 64 - - "sub_8lp: \n\t" - "movq (%%edi,%%edx,), %%mm0 \n\t" // load Sub(x) for 1st 8 bytes - "paddb %%mm7, %%mm0 \n\t" - "movq 8(%%edi,%%edx,), %%mm1 \n\t" // load Sub(x) for 2nd 8 bytes - "movq %%mm0, (%%edi,%%edx,) \n\t" // write Raw(x) for 1st 8 bytes - - // Now mm0 will be used as Raw(x-bpp) for the 2nd group of 8 bytes. - // This will be repeated for each group of 8 bytes with the 8th - // group being used as the Raw(x-bpp) for the 1st group of the - // next loop. - - "paddb %%mm0, %%mm1 \n\t" - "movq 16(%%edi,%%edx,), %%mm2 \n\t" // load Sub(x) for 3rd 8 bytes - "movq %%mm1, 8(%%edi,%%edx,) \n\t" // write Raw(x) for 2nd 8 bytes - "paddb %%mm1, %%mm2 \n\t" - "movq 24(%%edi,%%edx,), %%mm3 \n\t" // load Sub(x) for 4th 8 bytes - "movq %%mm2, 16(%%edi,%%edx,) \n\t" // write Raw(x) for 3rd 8 bytes - "paddb %%mm2, %%mm3 \n\t" - "movq 32(%%edi,%%edx,), %%mm4 \n\t" // load Sub(x) for 5th 8 bytes - "movq %%mm3, 24(%%edi,%%edx,) \n\t" // write Raw(x) for 4th 8 bytes - "paddb %%mm3, %%mm4 \n\t" - "movq 40(%%edi,%%edx,), %%mm5 \n\t" // load Sub(x) for 6th 8 bytes - "movq %%mm4, 32(%%edi,%%edx,) \n\t" // write Raw(x) for 5th 8 bytes - "paddb %%mm4, %%mm5 \n\t" - "movq 48(%%edi,%%edx,), %%mm6 \n\t" // load Sub(x) for 7th 8 bytes - "movq %%mm5, 40(%%edi,%%edx,) \n\t" // write Raw(x) for 6th 8 bytes - "paddb %%mm5, %%mm6 \n\t" - "movq 56(%%edi,%%edx,), %%mm7 \n\t" // load Sub(x) for 8th 8 bytes - "movq %%mm6, 48(%%edi,%%edx,) \n\t" // write Raw(x) for 7th 8 bytes - "addl $64, %%edx \n\t" - "paddb %%mm6, %%mm7 \n\t" - "cmpl %%ecx, %%edx \n\t" - "movq %%mm7, -8(%%edi,%%edx,) \n\t" // write Raw(x) for 8th 8 bytes - "jb sub_8lp \n\t" - - "cmpl _MMXLength, %%edx \n\t" - "jnb sub_8lt8 \n\t" - - "sub_8lpA: \n\t" - "movq (%%edi,%%edx,), %%mm0 \n\t" - "addl $8, %%edx \n\t" - "paddb %%mm7, %%mm0 \n\t" - "cmpl _MMXLength, %%edx \n\t" - "movq %%mm0, -8(%%edi,%%edx,) \n\t" // -8 to offset early addl edx - "movq %%mm0, %%mm7 \n\t" // move calculated Raw(x) data - // to mm1 to be new Raw(x-bpp) - // for next loop - "jb sub_8lpA \n\t" - - "sub_8lt8: \n\t" - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%ecx", "%edx", "%esi" // clobber list -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3", "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; - - default: // bpp greater than 8 bytes GRR BOGUS - { - __asm__ __volatile__ ( - "movl _dif, %%edx \n\t" -// preload "movl row, %%edi \n\t" - "movl %%edi, %%esi \n\t" // lp = row -// preload "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp - - "sub_Alp: \n\t" - "movq (%%edi,%%edx,), %%mm0 \n\t" - "movq (%%esi,%%edx,), %%mm1 \n\t" - "addl $8, %%edx \n\t" - "paddb %%mm1, %%mm0 \n\t" - "cmpl _MMXLength, %%edx \n\t" - "movq %%mm0, -8(%%edi,%%edx,) \n\t" // mov does not affect flags; - // -8 to offset addl edx - "jb sub_Alp \n\t" - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%edx", "%esi" // clobber list -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1" -#endif - ); - } - break; - - } // end switch (bpp) - - __asm__ __volatile__ ( - "movl _MMXLength, %%edx \n\t" -//pre "movl row, %%edi \n\t" - "cmpl _FullLength, %%edx \n\t" - "jnb sub_end \n\t" - - "movl %%edi, %%esi \n\t" // lp = row -//pre "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp - "xorl %%eax, %%eax \n\t" - - "sub_lp2: \n\t" - "movb (%%esi,%%edx,), %%al \n\t" - "addb %%al, (%%edi,%%edx,) \n\t" - "incl %%edx \n\t" - "cmpl _FullLength, %%edx \n\t" - "jb sub_lp2 \n\t" - - "sub_end: \n\t" - "EMMS \n\t" // end MMX instructions - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%edx", "%esi" // clobber list - ); - -} // end of png_read_filter_row_mmx_sub() -#endif - - - - -//===========================================================================// -// // -// P N G _ R E A D _ F I L T E R _ R O W _ M M X _ U P // -// // -//===========================================================================// - -// Optimized code for PNG Up filter decoder - -static void /* PRIVATE */ -png_read_filter_row_mmx_up(png_row_infop row_info, png_bytep row, - png_bytep prev_row) -{ - png_uint_32 len; - int dummy_value_d; // fix 'forbidden register 3 (dx) was spilled' error - int dummy_value_S; - int dummy_value_D; - - len = row_info->rowbytes; // number of bytes to filter - - __asm__ __volatile__ ( -//pre "movl row, %%edi \n\t" - // get # of bytes to alignment -#ifdef __PIC__ - "pushl %%ebx \n\t" -#endif - "movl %%edi, %%ecx \n\t" - "xorl %%ebx, %%ebx \n\t" - "addl $0x7, %%ecx \n\t" - "xorl %%eax, %%eax \n\t" - "andl $0xfffffff8, %%ecx \n\t" -//pre "movl prev_row, %%esi \n\t" - "subl %%edi, %%ecx \n\t" - "jz up_go \n\t" - - "up_lp1: \n\t" // fix alignment - "movb (%%edi,%%ebx,), %%al \n\t" - "addb (%%esi,%%ebx,), %%al \n\t" - "incl %%ebx \n\t" - "cmpl %%ecx, %%ebx \n\t" - "movb %%al, -1(%%edi,%%ebx,) \n\t" // mov does not affect flags; -1 to - "jb up_lp1 \n\t" // offset incl ebx - - "up_go: \n\t" -//pre "movl len, %%edx \n\t" - "movl %%edx, %%ecx \n\t" - "subl %%ebx, %%edx \n\t" // subtract alignment fix - "andl $0x0000003f, %%edx \n\t" // calc bytes over mult of 64 - "subl %%edx, %%ecx \n\t" // drop over bytes from length - - // unrolled loop - use all MMX registers and interleave to reduce - // number of branch instructions (loops) and reduce partial stalls - "up_loop: \n\t" - "movq (%%esi,%%ebx,), %%mm1 \n\t" - "movq (%%edi,%%ebx,), %%mm0 \n\t" - "movq 8(%%esi,%%ebx,), %%mm3 \n\t" - "paddb %%mm1, %%mm0 \n\t" - "movq 8(%%edi,%%ebx,), %%mm2 \n\t" - "movq %%mm0, (%%edi,%%ebx,) \n\t" - "paddb %%mm3, %%mm2 \n\t" - "movq 16(%%esi,%%ebx,), %%mm5 \n\t" - "movq %%mm2, 8(%%edi,%%ebx,) \n\t" - "movq 16(%%edi,%%ebx,), %%mm4 \n\t" - "movq 24(%%esi,%%ebx,), %%mm7 \n\t" - "paddb %%mm5, %%mm4 \n\t" - "movq 24(%%edi,%%ebx,), %%mm6 \n\t" - "movq %%mm4, 16(%%edi,%%ebx,) \n\t" - "paddb %%mm7, %%mm6 \n\t" - "movq 32(%%esi,%%ebx,), %%mm1 \n\t" - "movq %%mm6, 24(%%edi,%%ebx,) \n\t" - "movq 32(%%edi,%%ebx,), %%mm0 \n\t" - "movq 40(%%esi,%%ebx,), %%mm3 \n\t" - "paddb %%mm1, %%mm0 \n\t" - "movq 40(%%edi,%%ebx,), %%mm2 \n\t" - "movq %%mm0, 32(%%edi,%%ebx,) \n\t" - "paddb %%mm3, %%mm2 \n\t" - "movq 48(%%esi,%%ebx,), %%mm5 \n\t" - "movq %%mm2, 40(%%edi,%%ebx,) \n\t" - "movq 48(%%edi,%%ebx,), %%mm4 \n\t" - "movq 56(%%esi,%%ebx,), %%mm7 \n\t" - "paddb %%mm5, %%mm4 \n\t" - "movq 56(%%edi,%%ebx,), %%mm6 \n\t" - "movq %%mm4, 48(%%edi,%%ebx,) \n\t" - "addl $64, %%ebx \n\t" - "paddb %%mm7, %%mm6 \n\t" - "cmpl %%ecx, %%ebx \n\t" - "movq %%mm6, -8(%%edi,%%ebx,) \n\t" // (+56)movq does not affect flags; - "jb up_loop \n\t" // -8 to offset addl ebx - - "cmpl $0, %%edx \n\t" // test for bytes over mult of 64 - "jz up_end \n\t" - - "cmpl $8, %%edx \n\t" // test for less than 8 bytes - "jb up_lt8 \n\t" // [added by lcreeve at netins.net] - - "addl %%edx, %%ecx \n\t" - "andl $0x00000007, %%edx \n\t" // calc bytes over mult of 8 - "subl %%edx, %%ecx \n\t" // drop over bytes from length - "jz up_lt8 \n\t" - - "up_lpA: \n\t" // use MMX regs to update 8 bytes sim. - "movq (%%esi,%%ebx,), %%mm1 \n\t" - "movq (%%edi,%%ebx,), %%mm0 \n\t" - "addl $8, %%ebx \n\t" - "paddb %%mm1, %%mm0 \n\t" - "cmpl %%ecx, %%ebx \n\t" - "movq %%mm0, -8(%%edi,%%ebx,) \n\t" // movq does not affect flags; -8 to - "jb up_lpA \n\t" // offset add ebx - "cmpl $0, %%edx \n\t" // test for bytes over mult of 8 - "jz up_end \n\t" - - "up_lt8: \n\t" - "xorl %%eax, %%eax \n\t" - "addl %%edx, %%ecx \n\t" // move over byte count into counter - - "up_lp2: \n\t" // use x86 regs for remaining bytes - "movb (%%edi,%%ebx,), %%al \n\t" - "addb (%%esi,%%ebx,), %%al \n\t" - "incl %%ebx \n\t" - "cmpl %%ecx, %%ebx \n\t" - "movb %%al, -1(%%edi,%%ebx,) \n\t" // mov does not affect flags; -1 to - "jb up_lp2 \n\t" // offset inc ebx - - "up_end: \n\t" - "EMMS \n\t" // conversion of filtered row complete -#ifdef __PIC__ - "popl %%ebx \n\t" -#endif - - : "=d" (dummy_value_d), // 0 // output regs (dummy) - "=S" (dummy_value_S), // 1 - "=D" (dummy_value_D) // 2 - - : "0" (len), // edx // input regs - "1" (prev_row), // esi - "2" (row) // edi - - : "%eax", "%ecx" // clobber list (no input regs!) -#ifndef __PIC__ - , "%ebx" -#endif - -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - -} // end of png_read_filter_row_mmx_up() - -#endif /* PNG_MMX_CODE_SUPPORTED */ - - - - -/*===========================================================================*/ -/* */ -/* P N G _ R E A D _ F I L T E R _ R O W */ -/* */ -/*===========================================================================*/ - - -/* Optimized png_read_filter_row routines */ - -void /* PRIVATE */ -png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep - row, png_bytep prev_row, int filter) -{ -#ifdef PNG_DEBUG - char filnm[10]; -#endif - -#if defined(PNG_MMX_CODE_SUPPORTED) -/* GRR: these are superseded by png_ptr->asm_flags: */ -#define UseMMX_sub 1 // GRR: converted 20000730 -#define UseMMX_up 1 // GRR: converted 20000729 -#define UseMMX_avg 1 // GRR: converted 20000828 (+ 16-bit bugfix 20000916) -#define UseMMX_paeth 1 // GRR: converted 20000828 - - if (_mmx_supported == 2) { - /* this should have happened in png_init_mmx_flags() already */ -#if !defined(PNG_1_0_X) - png_warning(png_ptr, "asm_flags may not have been initialized"); -#endif - png_mmx_support(); - } -#endif /* PNG_MMX_CODE_SUPPORTED */ - -#ifdef PNG_DEBUG - png_debug(1, "in png_read_filter_row (pnggccrd.c)\n"); - switch (filter) - { - case 0: sprintf(filnm, "none"); - break; - case 1: sprintf(filnm, "sub-%s", -#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB)? "MMX" : -#endif -#endif -"x86"); - break; - case 2: sprintf(filnm, "up-%s", -#ifdef PNG_MMX_CODE_SUPPORTED -#if !defined(PNG_1_0_X) - (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP)? "MMX" : -#endif -#endif - "x86"); - break; - case 3: sprintf(filnm, "avg-%s", -#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG)? "MMX" : -#endif -#endif - "x86"); - break; - case 4: sprintf(filnm, "Paeth-%s", -#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH)? "MMX": -#endif -#endif -"x86"); - break; - default: sprintf(filnm, "unknw"); - break; - } - png_debug2(0, "row_number=%5ld, %5s, ", png_ptr->row_number, filnm); - png_debug1(0, "row=0x%08lx, ", (unsigned long)row); - png_debug2(0, "pixdepth=%2d, bytes=%d, ", (int)row_info->pixel_depth, - (int)((row_info->pixel_depth + 7) >> 3)); - png_debug1(0,"rowbytes=%8ld\n", row_info->rowbytes); -#endif /* PNG_DEBUG */ - - switch (filter) - { - case PNG_FILTER_VALUE_NONE: - break; - - case PNG_FILTER_VALUE_SUB: -#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB) && - (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && - (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) -#else - if (_mmx_supported) -#endif - { - png_read_filter_row_mmx_sub(row_info, row); - } - else -#endif /* PNG_MMX_CODE_SUPPORTED */ - { - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_bytep rp = row + bpp; - png_bytep lp = row; - - for (i = bpp; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*lp++)) & 0xff); - rp++; - } - } /* end !UseMMX_sub */ - break; - - case PNG_FILTER_VALUE_UP: -#if defined(PNG_MMX_CODE_SUPPORTED) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP) && - (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && - (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) -#else - if (_mmx_supported) -#endif - { - png_read_filter_row_mmx_up(row_info, row, prev_row); - } - else -#endif /* PNG_MMX_CODE_SUPPORTED */ - { - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_bytep rp = row; - png_bytep pp = prev_row; - - for (i = 0; i < istop; ++i) - { - *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); - rp++; - } - } /* end !UseMMX_up */ - break; - - case PNG_FILTER_VALUE_AVG: -#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG) && - (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && - (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) -#else - if (_mmx_supported) -#endif - { - png_read_filter_row_mmx_avg(row_info, row, prev_row); - } - else -#endif /* PNG_MMX_CODE_SUPPORTED */ - { - png_uint_32 i; - png_bytep rp = row; - png_bytep pp = prev_row; - png_bytep lp = row; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_uint_32 istop = row_info->rowbytes - bpp; - - for (i = 0; i < bpp; i++) - { - *rp = (png_byte)(((int)(*rp) + - ((int)(*pp++) >> 1)) & 0xff); - rp++; - } - - for (i = 0; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + - ((int)(*pp++ + *lp++) >> 1)) & 0xff); - rp++; - } - } /* end !UseMMX_avg */ - break; - - case PNG_FILTER_VALUE_PAETH: -#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH) && - (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && - (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) -#else - if (_mmx_supported) -#endif - { - png_read_filter_row_mmx_paeth(row_info, row, prev_row); - } - else -#endif /* PNG_MMX_CODE_SUPPORTED */ - { - png_uint_32 i; - png_bytep rp = row; - png_bytep pp = prev_row; - png_bytep lp = row; - png_bytep cp = prev_row; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_uint_32 istop = row_info->rowbytes - bpp; - - for (i = 0; i < bpp; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); - rp++; - } - - for (i = 0; i < istop; i++) /* use leftover rp,pp */ - { - int a, b, c, pa, pb, pc, p; - - a = *lp++; - b = *pp++; - c = *cp++; - - p = b - c; - pc = a - c; - -#ifdef PNG_USE_ABS - pa = abs(p); - pb = abs(pc); - pc = abs(p + pc); -#else - pa = p < 0 ? -p : p; - pb = pc < 0 ? -pc : pc; - pc = (p + pc) < 0 ? -(p + pc) : p + pc; -#endif - - /* - if (pa <= pb && pa <= pc) - p = a; - else if (pb <= pc) - p = b; - else - p = c; - */ - - p = (pa <= pb && pa <= pc) ? a : (pb <= pc) ? b : c; - - *rp = (png_byte)(((int)(*rp) + p) & 0xff); - rp++; - } - } /* end !UseMMX_paeth */ - break; - - default: - png_warning(png_ptr, "Ignoring bad row-filter type"); - *row=0; - break; - } -} - -#endif /* PNG_HAVE_MMX_READ_FILTER_ROW */ - - -/*===========================================================================*/ -/* */ -/* P N G _ M M X _ S U P P O R T */ -/* */ -/*===========================================================================*/ - -/* GRR NOTES: (1) the following code assumes 386 or better (pushfl/popfl) - * (2) all instructions compile with gcc 2.7.2.3 and later - * (3) the function is moved down here to prevent gcc from - * inlining it in multiple places and then barfing be- - * cause the ".NOT_SUPPORTED" label is multiply defined - * [is there a way to signal that a *single* function should - * not be inlined? is there a way to modify the label for - * each inlined instance, e.g., by appending _1, _2, etc.? - * maybe if don't use leading "." in label name? (nope...sigh)] - */ - -int PNGAPI -png_mmx_support(void) -{ -#if defined(PNG_MMX_CODE_SUPPORTED) - int result; - __asm__ __volatile__ ( - "pushl %%ebx \n\t" // ebx gets clobbered by CPUID instruction - "pushl %%ecx \n\t" // so does ecx... - "pushl %%edx \n\t" // ...and edx (but ecx & edx safe on Linux) -// ".byte 0x66 \n\t" // convert 16-bit pushf to 32-bit pushfd -// "pushf \n\t" // 16-bit pushf - "pushfl \n\t" // save Eflag to stack - "popl %%eax \n\t" // get Eflag from stack into eax - "movl %%eax, %%ecx \n\t" // make another copy of Eflag in ecx - "xorl $0x200000, %%eax \n\t" // toggle ID bit in Eflag (i.e., bit 21) - "pushl %%eax \n\t" // save modified Eflag back to stack -// ".byte 0x66 \n\t" // convert 16-bit popf to 32-bit popfd -// "popf \n\t" // 16-bit popf - "popfl \n\t" // restore modified value to Eflag reg - "pushfl \n\t" // save Eflag to stack - "popl %%eax \n\t" // get Eflag from stack - "pushl %%ecx \n\t" // save original Eflag to stack - "popfl \n\t" // restore original Eflag - "xorl %%ecx, %%eax \n\t" // compare new Eflag with original Eflag - "jz 0f \n\t" // if same, CPUID instr. is not supported - - "xorl %%eax, %%eax \n\t" // set eax to zero -// ".byte 0x0f, 0xa2 \n\t" // CPUID instruction (two-byte opcode) - "cpuid \n\t" // get the CPU identification info - "cmpl $1, %%eax \n\t" // make sure eax return non-zero value - "jl 0f \n\t" // if eax is zero, MMX is not supported - - "xorl %%eax, %%eax \n\t" // set eax to zero and... - "incl %%eax \n\t" // ...increment eax to 1. This pair is - // faster than the instruction "mov eax, 1" - "cpuid \n\t" // get the CPU identification info again - "andl $0x800000, %%edx \n\t" // mask out all bits but MMX bit (23) - "cmpl $0, %%edx \n\t" // 0 = MMX not supported - "jz 0f \n\t" // non-zero = yes, MMX IS supported - - "movl $1, %%eax \n\t" // set return value to 1 - "jmp 1f \n\t" // DONE: have MMX support - - "0: \n\t" // .NOT_SUPPORTED: target label for jump instructions - "movl $0, %%eax \n\t" // set return value to 0 - "1: \n\t" // .RETURN: target label for jump instructions - "popl %%edx \n\t" // restore edx - "popl %%ecx \n\t" // restore ecx - "popl %%ebx \n\t" // restore ebx - -// "ret \n\t" // DONE: no MMX support - // (fall through to standard C "ret") - - : "=a" (result) // output list - - : // any variables used on input (none) - - // no clobber list -// , "%ebx", "%ecx", "%edx" // GRR: we handle these manually -// , "memory" // if write to a variable gcc thought was in a reg -// , "cc" // "condition codes" (flag bits) - ); - _mmx_supported = result; -#else - _mmx_supported = 0; -#endif /* PNG_MMX_CODE_SUPPORTED */ - - return _mmx_supported; -} - - -#endif /* PNG_USE_PNGGCCRD */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/pngget.c b/irrlicht-1.6/source/Irrlicht/libpng/pngget.c deleted file mode 100644 index fc41b9b38..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/pngget.c +++ /dev/null @@ -1,955 +0,0 @@ - -/* pngget.c - retrieval of values from info struct - * - * Last changed in libpng 1.2.15 January 5, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) - -png_uint_32 PNGAPI -png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag) -{ - if (png_ptr != NULL && info_ptr != NULL) - return(info_ptr->valid & flag); - else - return(0); -} - -png_uint_32 PNGAPI -png_get_rowbytes(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - return(info_ptr->rowbytes); - else - return(0); -} - -#if defined(PNG_INFO_IMAGE_SUPPORTED) -png_bytepp PNGAPI -png_get_rows(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - return(info_ptr->row_pointers); - else - return(0); -} -#endif - -#ifdef PNG_EASY_ACCESS_SUPPORTED -/* easy access to info, added in libpng-0.99 */ -png_uint_32 PNGAPI -png_get_image_width(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - { - return info_ptr->width; - } - return (0); -} - -png_uint_32 PNGAPI -png_get_image_height(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - { - return info_ptr->height; - } - return (0); -} - -png_byte PNGAPI -png_get_bit_depth(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - { - return info_ptr->bit_depth; - } - return (0); -} - -png_byte PNGAPI -png_get_color_type(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - { - return info_ptr->color_type; - } - return (0); -} - -png_byte PNGAPI -png_get_filter_type(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - { - return info_ptr->filter_type; - } - return (0); -} - -png_byte PNGAPI -png_get_interlace_type(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - { - return info_ptr->interlace_type; - } - return (0); -} - -png_byte PNGAPI -png_get_compression_type(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - { - return info_ptr->compression_type; - } - return (0); -} - -png_uint_32 PNGAPI -png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_pHYs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_pHYs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_x_pixels_per_meter"); - if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER) - return (0); - else return (info_ptr->x_pixels_per_unit); - } -#else - return (0); -#endif - return (0); -} - -png_uint_32 PNGAPI -png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_pHYs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_pHYs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_y_pixels_per_meter"); - if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER) - return (0); - else return (info_ptr->y_pixels_per_unit); - } -#else - return (0); -#endif - return (0); -} - -png_uint_32 PNGAPI -png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_pHYs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_pHYs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_pixels_per_meter"); - if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER || - info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit) - return (0); - else return (info_ptr->x_pixels_per_unit); - } -#else - return (0); -#endif - return (0); -} - -#ifdef PNG_FLOATING_POINT_SUPPORTED -float PNGAPI -png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr) - { - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_pHYs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_pHYs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_aspect_ratio"); - if (info_ptr->x_pixels_per_unit == 0) - return ((float)0.0); - else - return ((float)((float)info_ptr->y_pixels_per_unit - /(float)info_ptr->x_pixels_per_unit)); - } -#else - return (0.0); -#endif - return ((float)0.0); -} -#endif - -png_int_32 PNGAPI -png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_oFFs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_oFFs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns"); - if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) - return (0); - else return (info_ptr->x_offset); - } -#else - return (0); -#endif - return (0); -} - -png_int_32 PNGAPI -png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_oFFs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_oFFs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns"); - if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) - return (0); - else return (info_ptr->y_offset); - } -#else - return (0); -#endif - return (0); -} - -png_int_32 PNGAPI -png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_oFFs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_oFFs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns"); - if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) - return (0); - else return (info_ptr->x_offset); - } -#else - return (0); -#endif - return (0); -} - -png_int_32 PNGAPI -png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_oFFs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_oFFs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns"); - if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) - return (0); - else return (info_ptr->y_offset); - } -#else - return (0); -#endif - return (0); -} - -#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED) -png_uint_32 PNGAPI -png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) -{ - return ((png_uint_32)((float)png_get_pixels_per_meter(png_ptr, info_ptr) - *.0254 +.5)); -} - -png_uint_32 PNGAPI -png_get_x_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) -{ - return ((png_uint_32)((float)png_get_x_pixels_per_meter(png_ptr, info_ptr) - *.0254 +.5)); -} - -png_uint_32 PNGAPI -png_get_y_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) -{ - return ((png_uint_32)((float)png_get_y_pixels_per_meter(png_ptr, info_ptr) - *.0254 +.5)); -} - -float PNGAPI -png_get_x_offset_inches(png_structp png_ptr, png_infop info_ptr) -{ - return ((float)png_get_x_offset_microns(png_ptr, info_ptr) - *.00003937); -} - -float PNGAPI -png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr) -{ - return ((float)png_get_y_offset_microns(png_ptr, info_ptr) - *.00003937); -} - -#if defined(PNG_pHYs_SUPPORTED) -png_uint_32 PNGAPI -png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr, - png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) -{ - png_uint_32 retval = 0; - - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) - { - png_debug1(1, "in %s retrieval function\n", "pHYs"); - if (res_x != NULL) - { - *res_x = info_ptr->x_pixels_per_unit; - retval |= PNG_INFO_pHYs; - } - if (res_y != NULL) - { - *res_y = info_ptr->y_pixels_per_unit; - retval |= PNG_INFO_pHYs; - } - if (unit_type != NULL) - { - *unit_type = (int)info_ptr->phys_unit_type; - retval |= PNG_INFO_pHYs; - if(*unit_type == 1) - { - if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50); - if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50); - } - } - } - return (retval); -} -#endif /* PNG_pHYs_SUPPORTED */ -#endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */ - -/* png_get_channels really belongs in here, too, but it's been around longer */ - -#endif /* PNG_EASY_ACCESS_SUPPORTED */ - -png_byte PNGAPI -png_get_channels(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - return(info_ptr->channels); - else - return (0); -} - -png_bytep PNGAPI -png_get_signature(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - return(info_ptr->signature); - else - return (NULL); -} - -#if defined(PNG_bKGD_SUPPORTED) -png_uint_32 PNGAPI -png_get_bKGD(png_structp png_ptr, png_infop info_ptr, - png_color_16p *background) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD) - && background != NULL) - { - png_debug1(1, "in %s retrieval function\n", "bKGD"); - *background = &(info_ptr->background); - return (PNG_INFO_bKGD); - } - return (0); -} -#endif - -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -png_uint_32 PNGAPI -png_get_cHRM(png_structp png_ptr, png_infop info_ptr, - double *white_x, double *white_y, double *red_x, double *red_y, - double *green_x, double *green_y, double *blue_x, double *blue_y) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) - { - png_debug1(1, "in %s retrieval function\n", "cHRM"); - if (white_x != NULL) - *white_x = (double)info_ptr->x_white; - if (white_y != NULL) - *white_y = (double)info_ptr->y_white; - if (red_x != NULL) - *red_x = (double)info_ptr->x_red; - if (red_y != NULL) - *red_y = (double)info_ptr->y_red; - if (green_x != NULL) - *green_x = (double)info_ptr->x_green; - if (green_y != NULL) - *green_y = (double)info_ptr->y_green; - if (blue_x != NULL) - *blue_x = (double)info_ptr->x_blue; - if (blue_y != NULL) - *blue_y = (double)info_ptr->y_blue; - return (PNG_INFO_cHRM); - } - return (0); -} -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -png_uint_32 PNGAPI -png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr, - png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x, - png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y, - png_fixed_point *blue_x, png_fixed_point *blue_y) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) - { - png_debug1(1, "in %s retrieval function\n", "cHRM"); - if (white_x != NULL) - *white_x = info_ptr->int_x_white; - if (white_y != NULL) - *white_y = info_ptr->int_y_white; - if (red_x != NULL) - *red_x = info_ptr->int_x_red; - if (red_y != NULL) - *red_y = info_ptr->int_y_red; - if (green_x != NULL) - *green_x = info_ptr->int_x_green; - if (green_y != NULL) - *green_y = info_ptr->int_y_green; - if (blue_x != NULL) - *blue_x = info_ptr->int_x_blue; - if (blue_y != NULL) - *blue_y = info_ptr->int_y_blue; - return (PNG_INFO_cHRM); - } - return (0); -} -#endif -#endif - -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -png_uint_32 PNGAPI -png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) - && file_gamma != NULL) - { - png_debug1(1, "in %s retrieval function\n", "gAMA"); - *file_gamma = (double)info_ptr->gamma; - return (PNG_INFO_gAMA); - } - return (0); -} -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -png_uint_32 PNGAPI -png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, - png_fixed_point *int_file_gamma) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) - && int_file_gamma != NULL) - { - png_debug1(1, "in %s retrieval function\n", "gAMA"); - *int_file_gamma = info_ptr->int_gamma; - return (PNG_INFO_gAMA); - } - return (0); -} -#endif -#endif - -#if defined(PNG_sRGB_SUPPORTED) -png_uint_32 PNGAPI -png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB) - && file_srgb_intent != NULL) - { - png_debug1(1, "in %s retrieval function\n", "sRGB"); - *file_srgb_intent = (int)info_ptr->srgb_intent; - return (PNG_INFO_sRGB); - } - return (0); -} -#endif - -#if defined(PNG_iCCP_SUPPORTED) -png_uint_32 PNGAPI -png_get_iCCP(png_structp png_ptr, png_infop info_ptr, - png_charpp name, int *compression_type, - png_charpp profile, png_uint_32 *proflen) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP) - && name != NULL && profile != NULL && proflen != NULL) - { - png_debug1(1, "in %s retrieval function\n", "iCCP"); - *name = info_ptr->iccp_name; - *profile = info_ptr->iccp_profile; - /* compression_type is a dummy so the API won't have to change - if we introduce multiple compression types later. */ - *proflen = (int)info_ptr->iccp_proflen; - *compression_type = (int)info_ptr->iccp_compression; - return (PNG_INFO_iCCP); - } - return (0); -} -#endif - -#if defined(PNG_sPLT_SUPPORTED) -png_uint_32 PNGAPI -png_get_sPLT(png_structp png_ptr, png_infop info_ptr, - png_sPLT_tpp spalettes) -{ - if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL) - *spalettes = info_ptr->splt_palettes; - return ((png_uint_32)info_ptr->splt_palettes_num); -} -#endif - -#if defined(PNG_hIST_SUPPORTED) -png_uint_32 PNGAPI -png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST) - && hist != NULL) - { - png_debug1(1, "in %s retrieval function\n", "hIST"); - *hist = info_ptr->hist; - return (PNG_INFO_hIST); - } - return (0); -} -#endif - -png_uint_32 PNGAPI -png_get_IHDR(png_structp png_ptr, png_infop info_ptr, - png_uint_32 *width, png_uint_32 *height, int *bit_depth, - int *color_type, int *interlace_type, int *compression_type, - int *filter_type) - -{ - if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL && - bit_depth != NULL && color_type != NULL) - { - png_debug1(1, "in %s retrieval function\n", "IHDR"); - *width = info_ptr->width; - *height = info_ptr->height; - *bit_depth = info_ptr->bit_depth; - if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16) - png_error(png_ptr, "Invalid bit depth"); - *color_type = info_ptr->color_type; - if (info_ptr->color_type > 6) - png_error(png_ptr, "Invalid color type"); - if (compression_type != NULL) - *compression_type = info_ptr->compression_type; - if (filter_type != NULL) - *filter_type = info_ptr->filter_type; - if (interlace_type != NULL) - *interlace_type = info_ptr->interlace_type; - - /* check for potential overflow of rowbytes */ - if (*width == 0 || *width > PNG_UINT_31_MAX) - png_error(png_ptr, "Invalid image width"); - if (*height == 0 || *height > PNG_UINT_31_MAX) - png_error(png_ptr, "Invalid image height"); - if (info_ptr->width > (PNG_UINT_32_MAX - >> 3) /* 8-byte RGBA pixels */ - - 64 /* bigrowbuf hack */ - - 1 /* filter byte */ - - 7*8 /* rounding of width to multiple of 8 pixels */ - - 8) /* extra max_pixel_depth pad */ - { - png_warning(png_ptr, - "Width too large for libpng to process image data."); - } - return (1); - } - return (0); -} - -#if defined(PNG_oFFs_SUPPORTED) -png_uint_32 PNGAPI -png_get_oFFs(png_structp png_ptr, png_infop info_ptr, - png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs) - && offset_x != NULL && offset_y != NULL && unit_type != NULL) - { - png_debug1(1, "in %s retrieval function\n", "oFFs"); - *offset_x = info_ptr->x_offset; - *offset_y = info_ptr->y_offset; - *unit_type = (int)info_ptr->offset_unit_type; - return (PNG_INFO_oFFs); - } - return (0); -} -#endif - -#if defined(PNG_pCAL_SUPPORTED) -png_uint_32 PNGAPI -png_get_pCAL(png_structp png_ptr, png_infop info_ptr, - png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, - png_charp *units, png_charpp *params) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL) - && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL && - nparams != NULL && units != NULL && params != NULL) - { - png_debug1(1, "in %s retrieval function\n", "pCAL"); - *purpose = info_ptr->pcal_purpose; - *X0 = info_ptr->pcal_X0; - *X1 = info_ptr->pcal_X1; - *type = (int)info_ptr->pcal_type; - *nparams = (int)info_ptr->pcal_nparams; - *units = info_ptr->pcal_units; - *params = info_ptr->pcal_params; - return (PNG_INFO_pCAL); - } - return (0); -} -#endif - -#if defined(PNG_sCAL_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -png_uint_32 PNGAPI -png_get_sCAL(png_structp png_ptr, png_infop info_ptr, - int *unit, double *width, double *height) -{ - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_sCAL)) - { - *unit = info_ptr->scal_unit; - *width = info_ptr->scal_pixel_width; - *height = info_ptr->scal_pixel_height; - return (PNG_INFO_sCAL); - } - return(0); -} -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -png_uint_32 PNGAPI -png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr, - int *unit, png_charpp width, png_charpp height) -{ - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_sCAL)) - { - *unit = info_ptr->scal_unit; - *width = info_ptr->scal_s_width; - *height = info_ptr->scal_s_height; - return (PNG_INFO_sCAL); - } - return(0); -} -#endif -#endif -#endif - -#if defined(PNG_pHYs_SUPPORTED) -png_uint_32 PNGAPI -png_get_pHYs(png_structp png_ptr, png_infop info_ptr, - png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) -{ - png_uint_32 retval = 0; - - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_pHYs)) - { - png_debug1(1, "in %s retrieval function\n", "pHYs"); - if (res_x != NULL) - { - *res_x = info_ptr->x_pixels_per_unit; - retval |= PNG_INFO_pHYs; - } - if (res_y != NULL) - { - *res_y = info_ptr->y_pixels_per_unit; - retval |= PNG_INFO_pHYs; - } - if (unit_type != NULL) - { - *unit_type = (int)info_ptr->phys_unit_type; - retval |= PNG_INFO_pHYs; - } - } - return (retval); -} -#endif - -png_uint_32 PNGAPI -png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette, - int *num_palette) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE) - && palette != NULL) - { - png_debug1(1, "in %s retrieval function\n", "PLTE"); - *palette = info_ptr->palette; - *num_palette = info_ptr->num_palette; - png_debug1(3, "num_palette = %d\n", *num_palette); - return (PNG_INFO_PLTE); - } - return (0); -} - -#if defined(PNG_sBIT_SUPPORTED) -png_uint_32 PNGAPI -png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT) - && sig_bit != NULL) - { - png_debug1(1, "in %s retrieval function\n", "sBIT"); - *sig_bit = &(info_ptr->sig_bit); - return (PNG_INFO_sBIT); - } - return (0); -} -#endif - -#if defined(PNG_TEXT_SUPPORTED) -png_uint_32 PNGAPI -png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr, - int *num_text) -{ - if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0) - { - png_debug1(1, "in %s retrieval function\n", - (png_ptr->chunk_name[0] == '\0' ? "text" - : (png_const_charp)png_ptr->chunk_name)); - if (text_ptr != NULL) - *text_ptr = info_ptr->text; - if (num_text != NULL) - *num_text = info_ptr->num_text; - return ((png_uint_32)info_ptr->num_text); - } - if (num_text != NULL) - *num_text = 0; - return(0); -} -#endif - -#if defined(PNG_tIME_SUPPORTED) -png_uint_32 PNGAPI -png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME) - && mod_time != NULL) - { - png_debug1(1, "in %s retrieval function\n", "tIME"); - *mod_time = &(info_ptr->mod_time); - return (PNG_INFO_tIME); - } - return (0); -} -#endif - -#if defined(PNG_tRNS_SUPPORTED) -png_uint_32 PNGAPI -png_get_tRNS(png_structp png_ptr, png_infop info_ptr, - png_bytep *trans, int *num_trans, png_color_16p *trans_values) -{ - png_uint_32 retval = 0; - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) - { - png_debug1(1, "in %s retrieval function\n", "tRNS"); - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - if (trans != NULL) - { - *trans = info_ptr->trans; - retval |= PNG_INFO_tRNS; - } - if (trans_values != NULL) - *trans_values = &(info_ptr->trans_values); - } - else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */ - { - if (trans_values != NULL) - { - *trans_values = &(info_ptr->trans_values); - retval |= PNG_INFO_tRNS; - } - if(trans != NULL) - *trans = NULL; - } - if(num_trans != NULL) - { - *num_trans = info_ptr->num_trans; - retval |= PNG_INFO_tRNS; - } - } - return (retval); -} -#endif - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -png_uint_32 PNGAPI -png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr, - png_unknown_chunkpp unknowns) -{ - if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL) - *unknowns = info_ptr->unknown_chunks; - return ((png_uint_32)info_ptr->unknown_chunks_num); -} -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) -png_byte PNGAPI -png_get_rgb_to_gray_status (png_structp png_ptr) -{ - return (png_byte)(png_ptr? png_ptr->rgb_to_gray_status : 0); -} -#endif - -#if defined(PNG_USER_CHUNKS_SUPPORTED) -png_voidp PNGAPI -png_get_user_chunk_ptr(png_structp png_ptr) -{ - return (png_ptr? png_ptr->user_chunk_ptr : NULL); -} -#endif - -#ifdef PNG_WRITE_SUPPORTED -png_uint_32 PNGAPI -png_get_compression_buffer_size(png_structp png_ptr) -{ - return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L); -} -#endif - -#ifdef PNG_ASSEMBLER_CODE_SUPPORTED -#ifndef PNG_1_0_X -/* this function was added to libpng 1.2.0 and should exist by default */ -png_uint_32 PNGAPI -png_get_asm_flags (png_structp png_ptr) -{ -#ifdef PNG_MMX_CODE_SUPPORTED - return (png_uint_32)(png_ptr? png_ptr->asm_flags : 0L); -#else - return (png_ptr? 0L: 0L); -#endif -} - -/* this function was added to libpng 1.2.0 and should exist by default */ -png_uint_32 PNGAPI -png_get_asm_flagmask (int flag_select) -{ -#ifdef PNG_MMX_CODE_SUPPORTED - png_uint_32 settable_asm_flags = 0; - - if (flag_select & PNG_SELECT_READ) - settable_asm_flags |= - PNG_ASM_FLAG_MMX_READ_COMBINE_ROW | - PNG_ASM_FLAG_MMX_READ_INTERLACE | - PNG_ASM_FLAG_MMX_READ_FILTER_SUB | - PNG_ASM_FLAG_MMX_READ_FILTER_UP | - PNG_ASM_FLAG_MMX_READ_FILTER_AVG | - PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ; - /* no non-MMX flags yet */ - -#if 0 - /* GRR: no write-flags yet, either, but someday... */ - if (flag_select & PNG_SELECT_WRITE) - settable_asm_flags |= - PNG_ASM_FLAG_MMX_WRITE_ [whatever] ; -#endif /* 0 */ - - return settable_asm_flags; /* _theoretically_ settable capabilities only */ -#else - return (0L); -#endif /* PNG_MMX_CODE_SUPPORTED */ -} - - - /* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */ -/* this function was added to libpng 1.2.0 */ -png_uint_32 PNGAPI -png_get_mmx_flagmask (int flag_select, int *compilerID) -{ -#if defined(PNG_MMX_CODE_SUPPORTED) - png_uint_32 settable_mmx_flags = 0; - - if (flag_select & PNG_SELECT_READ) - settable_mmx_flags |= - PNG_ASM_FLAG_MMX_READ_COMBINE_ROW | - PNG_ASM_FLAG_MMX_READ_INTERLACE | - PNG_ASM_FLAG_MMX_READ_FILTER_SUB | - PNG_ASM_FLAG_MMX_READ_FILTER_UP | - PNG_ASM_FLAG_MMX_READ_FILTER_AVG | - PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ; -#if 0 - /* GRR: no MMX write support yet, but someday... */ - if (flag_select & PNG_SELECT_WRITE) - settable_mmx_flags |= - PNG_ASM_FLAG_MMX_WRITE_ [whatever] ; -#endif /* 0 */ - - if (compilerID != NULL) { -#ifdef PNG_USE_PNGVCRD - *compilerID = 1; /* MSVC */ -#else -#ifdef PNG_USE_PNGGCCRD - *compilerID = 2; /* gcc/gas */ -#else - *compilerID = -1; /* unknown (i.e., no asm/MMX code compiled) */ -#endif -#endif - } - - return settable_mmx_flags; /* _theoretically_ settable capabilities only */ -#else - return (0L); -#endif /* ?PNG_MMX_CODE_SUPPORTED */ -} - -/* this function was added to libpng 1.2.0 */ -png_byte PNGAPI -png_get_mmx_bitdepth_threshold (png_structp png_ptr) -{ -#if defined(PNG_MMX_CODE_SUPPORTED) - return (png_byte)(png_ptr? png_ptr->mmx_bitdepth_threshold : 0); -#else - return (png_ptr? 0: 0); -#endif /* ?PNG_MMX_CODE_SUPPORTED */ -} - -/* this function was added to libpng 1.2.0 */ -png_uint_32 PNGAPI -png_get_mmx_rowbytes_threshold (png_structp png_ptr) -{ -#if defined(PNG_MMX_CODE_SUPPORTED) - return (png_uint_32)(png_ptr? png_ptr->mmx_rowbytes_threshold : 0L); -#else - return (png_ptr? 0L: 0L); -#endif /* ?PNG_MMX_CODE_SUPPORTED */ -} -#endif /* ?PNG_1_0_X */ -#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ - -#ifdef PNG_SET_USER_LIMITS_SUPPORTED -/* these functions were added to libpng 1.2.6 */ -png_uint_32 PNGAPI -png_get_user_width_max (png_structp png_ptr) -{ - return (png_ptr? png_ptr->user_width_max : 0); -} -png_uint_32 PNGAPI -png_get_user_height_max (png_structp png_ptr) -{ - return (png_ptr? png_ptr->user_height_max : 0); -} -#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ - -#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/pngmem.c b/irrlicht-1.6/source/Irrlicht/libpng/pngmem.c deleted file mode 100644 index 6aa70af4c..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/pngmem.c +++ /dev/null @@ -1,608 +0,0 @@ - -/* pngmem.c - stub functions for memory allocation - * - * Last changed in libpng 1.2.13 November 13, 2006 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2006 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This file provides a location for all memory allocation. Users who - * need special memory handling are expected to supply replacement - * functions for png_malloc() and png_free(), and to use - * png_create_read_struct_2() and png_create_write_struct_2() to - * identify the replacement functions. - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) - -/* Borland DOS special memory handler */ -#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) -/* if you change this, be sure to change the one in png.h also */ - -/* Allocate memory for a png_struct. The malloc and memset can be replaced - by a single call to calloc() if this is thought to improve performance. */ -png_voidp /* PRIVATE */ -png_create_struct(int type) -{ -#ifdef PNG_USER_MEM_SUPPORTED - return (png_create_struct_2(type, png_malloc_ptr_NULL, png_voidp_NULL)); -} - -/* Alternate version of png_create_struct, for use with user-defined malloc. */ -png_voidp /* PRIVATE */ -png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr) -{ -#endif /* PNG_USER_MEM_SUPPORTED */ - png_size_t size; - png_voidp struct_ptr; - - if (type == PNG_STRUCT_INFO) - size = png_sizeof(png_info); - else if (type == PNG_STRUCT_PNG) - size = png_sizeof(png_struct); - else - return (png_get_copyright(NULL)); - -#ifdef PNG_USER_MEM_SUPPORTED - if(malloc_fn != NULL) - { - png_struct dummy_struct; - png_structp png_ptr = &dummy_struct; - png_ptr->mem_ptr=mem_ptr; - struct_ptr = (*(malloc_fn))(png_ptr, (png_uint_32)size); - } - else -#endif /* PNG_USER_MEM_SUPPORTED */ - struct_ptr = (png_voidp)farmalloc(size); - if (struct_ptr != NULL) - png_memset(struct_ptr, 0, size); - return (struct_ptr); -} - -/* Free memory allocated by a png_create_struct() call */ -void /* PRIVATE */ -png_destroy_struct(png_voidp struct_ptr) -{ -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2(struct_ptr, png_free_ptr_NULL, png_voidp_NULL); -} - -/* Free memory allocated by a png_create_struct() call */ -void /* PRIVATE */ -png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, - png_voidp mem_ptr) -{ -#endif - if (struct_ptr != NULL) - { -#ifdef PNG_USER_MEM_SUPPORTED - if(free_fn != NULL) - { - png_struct dummy_struct; - png_structp png_ptr = &dummy_struct; - png_ptr->mem_ptr=mem_ptr; - (*(free_fn))(png_ptr, struct_ptr); - return; - } -#endif /* PNG_USER_MEM_SUPPORTED */ - farfree (struct_ptr); - } -} - -/* Allocate memory. For reasonable files, size should never exceed - * 64K. However, zlib may allocate more then 64K if you don't tell - * it not to. See zconf.h and png.h for more information. zlib does - * need to allocate exactly 64K, so whatever you call here must - * have the ability to do that. - * - * Borland seems to have a problem in DOS mode for exactly 64K. - * It gives you a segment with an offset of 8 (perhaps to store its - * memory stuff). zlib doesn't like this at all, so we have to - * detect and deal with it. This code should not be needed in - * Windows or OS/2 modes, and only in 16 bit mode. This code has - * been updated by Alexander Lehmann for version 0.89 to waste less - * memory. - * - * Note that we can't use png_size_t for the "size" declaration, - * since on some systems a png_size_t is a 16-bit quantity, and as a - * result, we would be truncating potentially larger memory requests - * (which should cause a fatal error) and introducing major problems. - */ - -png_voidp PNGAPI -png_malloc(png_structp png_ptr, png_uint_32 size) -{ - png_voidp ret; - - if (png_ptr == NULL || size == 0) - return (NULL); - -#ifdef PNG_USER_MEM_SUPPORTED - if(png_ptr->malloc_fn != NULL) - ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size)); - else - ret = (png_malloc_default(png_ptr, size)); - if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out of memory!"); - return (ret); -} - -png_voidp PNGAPI -png_malloc_default(png_structp png_ptr, png_uint_32 size) -{ - png_voidp ret; -#endif /* PNG_USER_MEM_SUPPORTED */ - - if (png_ptr == NULL || size == 0) - return (NULL); - -#ifdef PNG_MAX_MALLOC_64K - if (size > (png_uint_32)65536L) - { - png_warning(png_ptr, "Cannot Allocate > 64K"); - ret = NULL; - } - else -#endif - - if (size != (size_t)size) - ret = NULL; - else if (size == (png_uint_32)65536L) - { - if (png_ptr->offset_table == NULL) - { - /* try to see if we need to do any of this fancy stuff */ - ret = farmalloc(size); - if (ret == NULL || ((png_size_t)ret & 0xffff)) - { - int num_blocks; - png_uint_32 total_size; - png_bytep table; - int i; - png_byte huge * hptr; - - if (ret != NULL) - { - farfree(ret); - ret = NULL; - } - - if(png_ptr->zlib_window_bits > 14) - num_blocks = (int)(1 << (png_ptr->zlib_window_bits - 14)); - else - num_blocks = 1; - if (png_ptr->zlib_mem_level >= 7) - num_blocks += (int)(1 << (png_ptr->zlib_mem_level - 7)); - else - num_blocks++; - - total_size = ((png_uint_32)65536L) * (png_uint_32)num_blocks+16; - - table = farmalloc(total_size); - - if (table == NULL) - { -#ifndef PNG_USER_MEM_SUPPORTED - if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out Of Memory."); /* Note "O" and "M" */ - else - png_warning(png_ptr, "Out Of Memory."); -#endif - return (NULL); - } - - if ((png_size_t)table & 0xfff0) - { -#ifndef PNG_USER_MEM_SUPPORTED - if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, - "Farmalloc didn't return normalized pointer"); - else - png_warning(png_ptr, - "Farmalloc didn't return normalized pointer"); -#endif - return (NULL); - } - - png_ptr->offset_table = table; - png_ptr->offset_table_ptr = farmalloc(num_blocks * - png_sizeof (png_bytep)); - - if (png_ptr->offset_table_ptr == NULL) - { -#ifndef PNG_USER_MEM_SUPPORTED - if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out Of memory."); /* Note "O" and "M" */ - else - png_warning(png_ptr, "Out Of memory."); -#endif - return (NULL); - } - - hptr = (png_byte huge *)table; - if ((png_size_t)hptr & 0xf) - { - hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L); - hptr = hptr + 16L; /* "hptr += 16L" fails on Turbo C++ 3.0 */ - } - for (i = 0; i < num_blocks; i++) - { - png_ptr->offset_table_ptr[i] = (png_bytep)hptr; - hptr = hptr + (png_uint_32)65536L; /* "+=" fails on TC++3.0 */ - } - - png_ptr->offset_table_number = num_blocks; - png_ptr->offset_table_count = 0; - png_ptr->offset_table_count_free = 0; - } - } - - if (png_ptr->offset_table_count >= png_ptr->offset_table_number) - { -#ifndef PNG_USER_MEM_SUPPORTED - if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out of Memory."); /* Note "o" and "M" */ - else - png_warning(png_ptr, "Out of Memory."); -#endif - return (NULL); - } - - ret = png_ptr->offset_table_ptr[png_ptr->offset_table_count++]; - } - else - ret = farmalloc(size); - -#ifndef PNG_USER_MEM_SUPPORTED - if (ret == NULL) - { - if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out of memory."); /* Note "o" and "m" */ - else - png_warning(png_ptr, "Out of memory."); /* Note "o" and "m" */ - } -#endif - - return (ret); -} - -/* free a pointer allocated by png_malloc(). In the default - configuration, png_ptr is not used, but is passed in case it - is needed. If ptr is NULL, return without taking any action. */ -void PNGAPI -png_free(png_structp png_ptr, png_voidp ptr) -{ - if (png_ptr == NULL || ptr == NULL) - return; - -#ifdef PNG_USER_MEM_SUPPORTED - if (png_ptr->free_fn != NULL) - { - (*(png_ptr->free_fn))(png_ptr, ptr); - return; - } - else png_free_default(png_ptr, ptr); -} - -void PNGAPI -png_free_default(png_structp png_ptr, png_voidp ptr) -{ -#endif /* PNG_USER_MEM_SUPPORTED */ - - if(png_ptr == NULL) return; - - if (png_ptr->offset_table != NULL) - { - int i; - - for (i = 0; i < png_ptr->offset_table_count; i++) - { - if (ptr == png_ptr->offset_table_ptr[i]) - { - ptr = NULL; - png_ptr->offset_table_count_free++; - break; - } - } - if (png_ptr->offset_table_count_free == png_ptr->offset_table_count) - { - farfree(png_ptr->offset_table); - farfree(png_ptr->offset_table_ptr); - png_ptr->offset_table = NULL; - png_ptr->offset_table_ptr = NULL; - } - } - - if (ptr != NULL) - { - farfree(ptr); - } -} - -#else /* Not the Borland DOS special memory handler */ - -/* Allocate memory for a png_struct or a png_info. The malloc and - memset can be replaced by a single call to calloc() if this is thought - to improve performance noticably. */ -png_voidp /* PRIVATE */ -png_create_struct(int type) -{ -#ifdef PNG_USER_MEM_SUPPORTED - return (png_create_struct_2(type, png_malloc_ptr_NULL, png_voidp_NULL)); -} - -/* Allocate memory for a png_struct or a png_info. The malloc and - memset can be replaced by a single call to calloc() if this is thought - to improve performance noticably. */ -png_voidp /* PRIVATE */ -png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr) -{ -#endif /* PNG_USER_MEM_SUPPORTED */ - png_size_t size; - png_voidp struct_ptr; - - if (type == PNG_STRUCT_INFO) - size = png_sizeof(png_info); - else if (type == PNG_STRUCT_PNG) - size = png_sizeof(png_struct); - else - return (NULL); - -#ifdef PNG_USER_MEM_SUPPORTED - if(malloc_fn != NULL) - { - png_struct dummy_struct; - png_structp png_ptr = &dummy_struct; - png_ptr->mem_ptr=mem_ptr; - struct_ptr = (*(malloc_fn))(png_ptr, size); - if (struct_ptr != NULL) - png_memset(struct_ptr, 0, size); - return (struct_ptr); - } -#endif /* PNG_USER_MEM_SUPPORTED */ - -#if defined(__TURBOC__) && !defined(__FLAT__) - struct_ptr = (png_voidp)farmalloc(size); -#else -# if defined(_MSC_VER) && defined(MAXSEG_64K) - struct_ptr = (png_voidp)halloc(size,1); -# else - struct_ptr = (png_voidp)malloc(size); -# endif -#endif - if (struct_ptr != NULL) - png_memset(struct_ptr, 0, size); - - return (struct_ptr); -} - - -/* Free memory allocated by a png_create_struct() call */ -void /* PRIVATE */ -png_destroy_struct(png_voidp struct_ptr) -{ -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2(struct_ptr, png_free_ptr_NULL, png_voidp_NULL); -} - -/* Free memory allocated by a png_create_struct() call */ -void /* PRIVATE */ -png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, - png_voidp mem_ptr) -{ -#endif /* PNG_USER_MEM_SUPPORTED */ - if (struct_ptr != NULL) - { -#ifdef PNG_USER_MEM_SUPPORTED - if(free_fn != NULL) - { - png_struct dummy_struct; - png_structp png_ptr = &dummy_struct; - png_ptr->mem_ptr=mem_ptr; - (*(free_fn))(png_ptr, struct_ptr); - return; - } -#endif /* PNG_USER_MEM_SUPPORTED */ -#if defined(__TURBOC__) && !defined(__FLAT__) - farfree(struct_ptr); -#else -# if defined(_MSC_VER) && defined(MAXSEG_64K) - hfree(struct_ptr); -# else - free(struct_ptr); -# endif -#endif - } -} - -/* Allocate memory. For reasonable files, size should never exceed - 64K. However, zlib may allocate more then 64K if you don't tell - it not to. See zconf.h and png.h for more information. zlib does - need to allocate exactly 64K, so whatever you call here must - have the ability to do that. */ - -png_voidp PNGAPI -png_malloc(png_structp png_ptr, png_uint_32 size) -{ - png_voidp ret; - -#ifdef PNG_USER_MEM_SUPPORTED - if (png_ptr == NULL || size == 0) - return (NULL); - - if(png_ptr->malloc_fn != NULL) - ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size)); - else - ret = (png_malloc_default(png_ptr, size)); - if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out of Memory!"); - return (ret); -} - -png_voidp PNGAPI -png_malloc_default(png_structp png_ptr, png_uint_32 size) -{ - png_voidp ret; -#endif /* PNG_USER_MEM_SUPPORTED */ - - if (png_ptr == NULL || size == 0) - return (NULL); - -#ifdef PNG_MAX_MALLOC_64K - if (size > (png_uint_32)65536L) - { -#ifndef PNG_USER_MEM_SUPPORTED - if(png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Cannot Allocate > 64K"); - else -#endif - return NULL; - } -#endif - - /* Check for overflow */ -#if defined(__TURBOC__) && !defined(__FLAT__) - if (size != (unsigned long)size) - ret = NULL; - else - ret = farmalloc(size); -#else -# if defined(_MSC_VER) && defined(MAXSEG_64K) - if (size != (unsigned long)size) - ret = NULL; - else - ret = halloc(size, 1); -# else - if (size != (size_t)size) - ret = NULL; - else - ret = malloc((size_t)size); -# endif -#endif - -#ifndef PNG_USER_MEM_SUPPORTED - if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out of Memory"); -#endif - - return (ret); -} - -/* Free a pointer allocated by png_malloc(). If ptr is NULL, return - without taking any action. */ -void PNGAPI -png_free(png_structp png_ptr, png_voidp ptr) -{ - if (png_ptr == NULL || ptr == NULL) - return; - -#ifdef PNG_USER_MEM_SUPPORTED - if (png_ptr->free_fn != NULL) - { - (*(png_ptr->free_fn))(png_ptr, ptr); - return; - } - else png_free_default(png_ptr, ptr); -} -void PNGAPI -png_free_default(png_structp png_ptr, png_voidp ptr) -{ - if (png_ptr == NULL || ptr == NULL) - return; - -#endif /* PNG_USER_MEM_SUPPORTED */ - -#if defined(__TURBOC__) && !defined(__FLAT__) - farfree(ptr); -#else -# if defined(_MSC_VER) && defined(MAXSEG_64K) - hfree(ptr); -# else - free(ptr); -# endif -#endif -} - -#endif /* Not Borland DOS special memory handler */ - -#if defined(PNG_1_0_X) -# define png_malloc_warn png_malloc -#else -/* This function was added at libpng version 1.2.3. The png_malloc_warn() - * function will set up png_malloc() to issue a png_warning and return NULL - * instead of issuing a png_error, if it fails to allocate the requested - * memory. - */ -png_voidp PNGAPI -png_malloc_warn(png_structp png_ptr, png_uint_32 size) -{ - png_voidp ptr; - png_uint_32 save_flags; - if(png_ptr == NULL) return (NULL); - - save_flags=png_ptr->flags; - png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK; - ptr = (png_voidp)png_malloc((png_structp)png_ptr, size); - png_ptr->flags=save_flags; - return(ptr); -} -#endif - -png_voidp PNGAPI -png_memcpy_check (png_structp png_ptr, png_voidp s1, png_voidp s2, - png_uint_32 length) -{ - png_size_t size; - - size = (png_size_t)length; - if ((png_uint_32)size != length) - png_error(png_ptr,"Overflow in png_memcpy_check."); - - return(png_memcpy (s1, s2, size)); -} - -png_voidp PNGAPI -png_memset_check (png_structp png_ptr, png_voidp s1, int value, - png_uint_32 length) -{ - png_size_t size; - - size = (png_size_t)length; - if ((png_uint_32)size != length) - png_error(png_ptr,"Overflow in png_memset_check."); - - return (png_memset (s1, value, size)); - -} - -#ifdef PNG_USER_MEM_SUPPORTED -/* This function is called when the application wants to use another method - * of allocating and freeing memory. - */ -void PNGAPI -png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr - malloc_fn, png_free_ptr free_fn) -{ - if(png_ptr != NULL) { - png_ptr->mem_ptr = mem_ptr; - png_ptr->malloc_fn = malloc_fn; - png_ptr->free_fn = free_fn; - } -} - -/* This function returns a pointer to the mem_ptr associated with the user - * functions. The application should free any memory associated with this - * pointer before png_write_destroy and png_read_destroy are called. - */ -png_voidp PNGAPI -png_get_mem_ptr(png_structp png_ptr) -{ - if(png_ptr == NULL) return (NULL); - return ((png_voidp)png_ptr->mem_ptr); -} -#endif /* PNG_USER_MEM_SUPPORTED */ -#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/pngnow.png b/irrlicht-1.6/source/Irrlicht/libpng/pngnow.png deleted file mode 100644 index 82793ebdd..000000000 Binary files a/irrlicht-1.6/source/Irrlicht/libpng/pngnow.png and /dev/null differ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/pngpread.c b/irrlicht-1.6/source/Irrlicht/libpng/pngpread.c deleted file mode 100644 index 69c5959ab..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/pngpread.c +++ /dev/null @@ -1,1589 +0,0 @@ - -/* pngpread.c - read a png file in push mode - * - * Last changed in libpng 1.2.17 May 15, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -#define PNG_INTERNAL -#include "png.h" - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED - -/* push model modes */ -#define PNG_READ_SIG_MODE 0 -#define PNG_READ_CHUNK_MODE 1 -#define PNG_READ_IDAT_MODE 2 -#define PNG_SKIP_MODE 3 -#define PNG_READ_tEXt_MODE 4 -#define PNG_READ_zTXt_MODE 5 -#define PNG_READ_DONE_MODE 6 -#define PNG_READ_iTXt_MODE 7 -#define PNG_ERROR_MODE 8 - -void PNGAPI -png_process_data(png_structp png_ptr, png_infop info_ptr, - png_bytep buffer, png_size_t buffer_size) -{ - if(png_ptr == NULL) return; - png_push_restore_buffer(png_ptr, buffer, buffer_size); - - while (png_ptr->buffer_size) - { - png_process_some_data(png_ptr, info_ptr); - } -} - -/* What we do with the incoming data depends on what we were previously - * doing before we ran out of data... - */ -void /* PRIVATE */ -png_process_some_data(png_structp png_ptr, png_infop info_ptr) -{ - if(png_ptr == NULL) return; - switch (png_ptr->process_mode) - { - case PNG_READ_SIG_MODE: - { - png_push_read_sig(png_ptr, info_ptr); - break; - } - case PNG_READ_CHUNK_MODE: - { - png_push_read_chunk(png_ptr, info_ptr); - break; - } - case PNG_READ_IDAT_MODE: - { - png_push_read_IDAT(png_ptr); - break; - } -#if defined(PNG_READ_tEXt_SUPPORTED) - case PNG_READ_tEXt_MODE: - { - png_push_read_tEXt(png_ptr, info_ptr); - break; - } -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - case PNG_READ_zTXt_MODE: - { - png_push_read_zTXt(png_ptr, info_ptr); - break; - } -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - case PNG_READ_iTXt_MODE: - { - png_push_read_iTXt(png_ptr, info_ptr); - break; - } -#endif - case PNG_SKIP_MODE: - { - png_push_crc_finish(png_ptr); - break; - } - default: - { - png_ptr->buffer_size = 0; - break; - } - } -} - -/* Read any remaining signature bytes from the stream and compare them with - * the correct PNG signature. It is possible that this routine is called - * with bytes already read from the signature, either because they have been - * checked by the calling application, or because of multiple calls to this - * routine. - */ -void /* PRIVATE */ -png_push_read_sig(png_structp png_ptr, png_infop info_ptr) -{ - png_size_t num_checked = png_ptr->sig_bytes, - num_to_check = 8 - num_checked; - - if (png_ptr->buffer_size < num_to_check) - { - num_to_check = png_ptr->buffer_size; - } - - png_push_fill_buffer(png_ptr, &(info_ptr->signature[num_checked]), - num_to_check); - png_ptr->sig_bytes = (png_byte)(png_ptr->sig_bytes+num_to_check); - - if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check)) - { - if (num_checked < 4 && - png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4)) - png_error(png_ptr, "Not a PNG file"); - else - png_error(png_ptr, "PNG file corrupted by ASCII conversion"); - } - else - { - if (png_ptr->sig_bytes >= 8) - { - png_ptr->process_mode = PNG_READ_CHUNK_MODE; - } - } -} - -void /* PRIVATE */ -png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IHDR; - PNG_IDAT; - PNG_IEND; - PNG_PLTE; -#if defined(PNG_READ_bKGD_SUPPORTED) - PNG_bKGD; -#endif -#if defined(PNG_READ_cHRM_SUPPORTED) - PNG_cHRM; -#endif -#if defined(PNG_READ_gAMA_SUPPORTED) - PNG_gAMA; -#endif -#if defined(PNG_READ_hIST_SUPPORTED) - PNG_hIST; -#endif -#if defined(PNG_READ_iCCP_SUPPORTED) - PNG_iCCP; -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - PNG_iTXt; -#endif -#if defined(PNG_READ_oFFs_SUPPORTED) - PNG_oFFs; -#endif -#if defined(PNG_READ_pCAL_SUPPORTED) - PNG_pCAL; -#endif -#if defined(PNG_READ_pHYs_SUPPORTED) - PNG_pHYs; -#endif -#if defined(PNG_READ_sBIT_SUPPORTED) - PNG_sBIT; -#endif -#if defined(PNG_READ_sCAL_SUPPORTED) - PNG_sCAL; -#endif -#if defined(PNG_READ_sRGB_SUPPORTED) - PNG_sRGB; -#endif -#if defined(PNG_READ_sPLT_SUPPORTED) - PNG_sPLT; -#endif -#if defined(PNG_READ_tEXt_SUPPORTED) - PNG_tEXt; -#endif -#if defined(PNG_READ_tIME_SUPPORTED) - PNG_tIME; -#endif -#if defined(PNG_READ_tRNS_SUPPORTED) - PNG_tRNS; -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - PNG_zTXt; -#endif -#endif /* PNG_USE_LOCAL_ARRAYS */ - /* First we make sure we have enough data for the 4 byte chunk name - * and the 4 byte chunk length before proceeding with decoding the - * chunk data. To fully decode each of these chunks, we also make - * sure we have enough data in the buffer for the 4 byte CRC at the - * end of every chunk (except IDAT, which is handled separately). - */ - if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER)) - { - png_byte chunk_length[4]; - - if (png_ptr->buffer_size < 8) - { - png_push_save_buffer(png_ptr); - return; - } - - png_push_fill_buffer(png_ptr, chunk_length, 4); - png_ptr->push_length = png_get_uint_31(png_ptr,chunk_length); - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); - png_ptr->mode |= PNG_HAVE_CHUNK_HEADER; - } - - if (!png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) - if(png_ptr->mode & PNG_AFTER_IDAT) - png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT; - - if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_IHDR(png_ptr, info_ptr, png_ptr->push_length); - } - else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_IEND(png_ptr, info_ptr, png_ptr->push_length); - - png_ptr->process_mode = PNG_READ_DONE_MODE; - png_push_have_end(png_ptr, info_ptr); - } -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED - else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - png_ptr->mode |= PNG_HAVE_IDAT; - png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length); - if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) - png_ptr->mode |= PNG_HAVE_PLTE; - else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - { - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before IDAT"); - else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - !(png_ptr->mode & PNG_HAVE_PLTE)) - png_error(png_ptr, "Missing PLTE before IDAT"); - } - } -#endif - else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_PLTE(png_ptr, info_ptr, png_ptr->push_length); - } - else if (!png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) - { - /* If we reach an IDAT chunk, this means we have read all of the - * header chunks, and we can start reading the image (or if this - * is called after the image has been read - we have an error). - */ - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before IDAT"); - else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - !(png_ptr->mode & PNG_HAVE_PLTE)) - png_error(png_ptr, "Missing PLTE before IDAT"); - - if (png_ptr->mode & PNG_HAVE_IDAT) - { - if (!(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT)) - if (png_ptr->push_length == 0) - return; - - if (png_ptr->mode & PNG_AFTER_IDAT) - png_error(png_ptr, "Too many IDAT's found"); - } - - png_ptr->idat_size = png_ptr->push_length; - png_ptr->mode |= PNG_HAVE_IDAT; - png_ptr->process_mode = PNG_READ_IDAT_MODE; - png_push_have_info(png_ptr, info_ptr); - png_ptr->zstream.avail_out = (uInt)png_ptr->irowbytes; - png_ptr->zstream.next_out = png_ptr->row_buf; - return; - } -#if defined(PNG_READ_gAMA_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_gAMA(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_sBIT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_sBIT(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_cHRM_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_cHRM(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_sRGB_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_sRGB(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_iCCP_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_iCCP(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_sPLT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_sPLT(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_tRNS_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_tRNS(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_bKGD_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_bKGD(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_hIST_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_hIST(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_pHYs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_pHYs(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_oFFs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_oFFs(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_pCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_pCAL(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_sCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_sCAL(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_tIME_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_tIME(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_tEXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_push_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_push_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_push_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length); - } -#endif - else - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_push_handle_unknown(png_ptr, info_ptr, png_ptr->push_length); - } - - png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER; -} - -void /* PRIVATE */ -png_push_crc_skip(png_structp png_ptr, png_uint_32 skip) -{ - png_ptr->process_mode = PNG_SKIP_MODE; - png_ptr->skip_length = skip; -} - -void /* PRIVATE */ -png_push_crc_finish(png_structp png_ptr) -{ - if (png_ptr->skip_length && png_ptr->save_buffer_size) - { - png_size_t save_size; - - if (png_ptr->skip_length < (png_uint_32)png_ptr->save_buffer_size) - save_size = (png_size_t)png_ptr->skip_length; - else - save_size = png_ptr->save_buffer_size; - - png_calculate_crc(png_ptr, png_ptr->save_buffer_ptr, save_size); - - png_ptr->skip_length -= save_size; - png_ptr->buffer_size -= save_size; - png_ptr->save_buffer_size -= save_size; - png_ptr->save_buffer_ptr += save_size; - } - if (png_ptr->skip_length && png_ptr->current_buffer_size) - { - png_size_t save_size; - - if (png_ptr->skip_length < (png_uint_32)png_ptr->current_buffer_size) - save_size = (png_size_t)png_ptr->skip_length; - else - save_size = png_ptr->current_buffer_size; - - png_calculate_crc(png_ptr, png_ptr->current_buffer_ptr, save_size); - - png_ptr->skip_length -= save_size; - png_ptr->buffer_size -= save_size; - png_ptr->current_buffer_size -= save_size; - png_ptr->current_buffer_ptr += save_size; - } - if (!png_ptr->skip_length) - { - if (png_ptr->buffer_size < 4) - { - png_push_save_buffer(png_ptr); - return; - } - - png_crc_finish(png_ptr, 0); - png_ptr->process_mode = PNG_READ_CHUNK_MODE; - } -} - -void PNGAPI -png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length) -{ - png_bytep ptr; - - if(png_ptr == NULL) return; - ptr = buffer; - if (png_ptr->save_buffer_size) - { - png_size_t save_size; - - if (length < png_ptr->save_buffer_size) - save_size = length; - else - save_size = png_ptr->save_buffer_size; - - png_memcpy(ptr, png_ptr->save_buffer_ptr, save_size); - length -= save_size; - ptr += save_size; - png_ptr->buffer_size -= save_size; - png_ptr->save_buffer_size -= save_size; - png_ptr->save_buffer_ptr += save_size; - } - if (length && png_ptr->current_buffer_size) - { - png_size_t save_size; - - if (length < png_ptr->current_buffer_size) - save_size = length; - else - save_size = png_ptr->current_buffer_size; - - png_memcpy(ptr, png_ptr->current_buffer_ptr, save_size); - png_ptr->buffer_size -= save_size; - png_ptr->current_buffer_size -= save_size; - png_ptr->current_buffer_ptr += save_size; - } -} - -void /* PRIVATE */ -png_push_save_buffer(png_structp png_ptr) -{ - if (png_ptr->save_buffer_size) - { - if (png_ptr->save_buffer_ptr != png_ptr->save_buffer) - { - png_size_t i,istop; - png_bytep sp; - png_bytep dp; - - istop = png_ptr->save_buffer_size; - for (i = 0, sp = png_ptr->save_buffer_ptr, dp = png_ptr->save_buffer; - i < istop; i++, sp++, dp++) - { - *dp = *sp; - } - } - } - if (png_ptr->save_buffer_size + png_ptr->current_buffer_size > - png_ptr->save_buffer_max) - { - png_size_t new_max; - png_bytep old_buffer; - - if (png_ptr->save_buffer_size > PNG_SIZE_MAX - - (png_ptr->current_buffer_size + 256)) - { - png_error(png_ptr, "Potential overflow of save_buffer"); - } - new_max = png_ptr->save_buffer_size + png_ptr->current_buffer_size + 256; - old_buffer = png_ptr->save_buffer; - png_ptr->save_buffer = (png_bytep)png_malloc(png_ptr, - (png_uint_32)new_max); - png_memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size); - png_free(png_ptr, old_buffer); - png_ptr->save_buffer_max = new_max; - } - if (png_ptr->current_buffer_size) - { - png_memcpy(png_ptr->save_buffer + png_ptr->save_buffer_size, - png_ptr->current_buffer_ptr, png_ptr->current_buffer_size); - png_ptr->save_buffer_size += png_ptr->current_buffer_size; - png_ptr->current_buffer_size = 0; - } - png_ptr->save_buffer_ptr = png_ptr->save_buffer; - png_ptr->buffer_size = 0; -} - -void /* PRIVATE */ -png_push_restore_buffer(png_structp png_ptr, png_bytep buffer, - png_size_t buffer_length) -{ - png_ptr->current_buffer = buffer; - png_ptr->current_buffer_size = buffer_length; - png_ptr->buffer_size = buffer_length + png_ptr->save_buffer_size; - png_ptr->current_buffer_ptr = png_ptr->current_buffer; -} - -void /* PRIVATE */ -png_push_read_IDAT(png_structp png_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IDAT; -#endif - if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER)) - { - png_byte chunk_length[4]; - - if (png_ptr->buffer_size < 8) - { - png_push_save_buffer(png_ptr); - return; - } - - png_push_fill_buffer(png_ptr, chunk_length, 4); - png_ptr->push_length = png_get_uint_31(png_ptr,chunk_length); - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); - png_ptr->mode |= PNG_HAVE_CHUNK_HEADER; - - if (png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) - { - png_ptr->process_mode = PNG_READ_CHUNK_MODE; - if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) - png_error(png_ptr, "Not enough compressed data"); - return; - } - - png_ptr->idat_size = png_ptr->push_length; - } - if (png_ptr->idat_size && png_ptr->save_buffer_size) - { - png_size_t save_size; - - if (png_ptr->idat_size < (png_uint_32)png_ptr->save_buffer_size) - { - save_size = (png_size_t)png_ptr->idat_size; - /* check for overflow */ - if((png_uint_32)save_size != png_ptr->idat_size) - png_error(png_ptr, "save_size overflowed in pngpread"); - } - else - save_size = png_ptr->save_buffer_size; - - png_calculate_crc(png_ptr, png_ptr->save_buffer_ptr, save_size); - if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) - png_process_IDAT_data(png_ptr, png_ptr->save_buffer_ptr, save_size); - png_ptr->idat_size -= save_size; - png_ptr->buffer_size -= save_size; - png_ptr->save_buffer_size -= save_size; - png_ptr->save_buffer_ptr += save_size; - } - if (png_ptr->idat_size && png_ptr->current_buffer_size) - { - png_size_t save_size; - - if (png_ptr->idat_size < (png_uint_32)png_ptr->current_buffer_size) - { - save_size = (png_size_t)png_ptr->idat_size; - /* check for overflow */ - if((png_uint_32)save_size != png_ptr->idat_size) - png_error(png_ptr, "save_size overflowed in pngpread"); - } - else - save_size = png_ptr->current_buffer_size; - - png_calculate_crc(png_ptr, png_ptr->current_buffer_ptr, save_size); - if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) - png_process_IDAT_data(png_ptr, png_ptr->current_buffer_ptr, save_size); - - png_ptr->idat_size -= save_size; - png_ptr->buffer_size -= save_size; - png_ptr->current_buffer_size -= save_size; - png_ptr->current_buffer_ptr += save_size; - } - if (!png_ptr->idat_size) - { - if (png_ptr->buffer_size < 4) - { - png_push_save_buffer(png_ptr); - return; - } - - png_crc_finish(png_ptr, 0); - png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER; - png_ptr->mode |= PNG_AFTER_IDAT; - } -} - -void /* PRIVATE */ -png_process_IDAT_data(png_structp png_ptr, png_bytep buffer, - png_size_t buffer_length) -{ - int ret; - - if ((png_ptr->flags & PNG_FLAG_ZLIB_FINISHED) && buffer_length) - png_error(png_ptr, "Extra compression data"); - - png_ptr->zstream.next_in = buffer; - png_ptr->zstream.avail_in = (uInt)buffer_length; - for(;;) - { - ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); - if (ret != Z_OK) - { - if (ret == Z_STREAM_END) - { - if (png_ptr->zstream.avail_in) - png_error(png_ptr, "Extra compressed data"); - if (!(png_ptr->zstream.avail_out)) - { - png_push_process_row(png_ptr); - } - - png_ptr->mode |= PNG_AFTER_IDAT; - png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; - break; - } - else if (ret == Z_BUF_ERROR) - break; - else - png_error(png_ptr, "Decompression Error"); - } - if (!(png_ptr->zstream.avail_out)) - { - if (( -#if defined(PNG_READ_INTERLACING_SUPPORTED) - png_ptr->interlaced && png_ptr->pass > 6) || - (!png_ptr->interlaced && -#endif - png_ptr->row_number == png_ptr->num_rows)) - { - if (png_ptr->zstream.avail_in) - png_warning(png_ptr, "Too much data in IDAT chunks"); - png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; - break; - } - png_push_process_row(png_ptr); - png_ptr->zstream.avail_out = (uInt)png_ptr->irowbytes; - png_ptr->zstream.next_out = png_ptr->row_buf; - } - else - break; - } -} - -void /* PRIVATE */ -png_push_process_row(png_structp png_ptr) -{ - png_ptr->row_info.color_type = png_ptr->color_type; - png_ptr->row_info.width = png_ptr->iwidth; - png_ptr->row_info.channels = png_ptr->channels; - png_ptr->row_info.bit_depth = png_ptr->bit_depth; - png_ptr->row_info.pixel_depth = png_ptr->pixel_depth; - - png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth, - png_ptr->row_info.width); - - png_read_filter_row(png_ptr, &(png_ptr->row_info), - png_ptr->row_buf + 1, png_ptr->prev_row + 1, - (int)(png_ptr->row_buf[0])); - - png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf, - png_ptr->rowbytes + 1); - - if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA)) - png_do_read_transformations(png_ptr); - -#if defined(PNG_READ_INTERLACING_SUPPORTED) - /* blow up interlaced rows to full size */ - if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) - { - if (png_ptr->pass < 6) -/* old interface (pre-1.0.9): - png_do_read_interlace(&(png_ptr->row_info), - png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations); - */ - png_do_read_interlace(png_ptr); - - switch (png_ptr->pass) - { - case 0: - { - int i; - for (i = 0; i < 8 && png_ptr->pass == 0; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); /* updates png_ptr->pass */ - } - if (png_ptr->pass == 2) /* pass 1 might be empty */ - { - for (i = 0; i < 4 && png_ptr->pass == 2; i++) - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - } - if (png_ptr->pass == 4 && png_ptr->height <= 4) - { - for (i = 0; i < 2 && png_ptr->pass == 4; i++) - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - } - if (png_ptr->pass == 6 && png_ptr->height <= 4) - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - break; - } - case 1: - { - int i; - for (i = 0; i < 8 && png_ptr->pass == 1; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } - if (png_ptr->pass == 2) /* skip top 4 generated rows */ - { - for (i = 0; i < 4 && png_ptr->pass == 2; i++) - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - } - break; - } - case 2: - { - int i; - for (i = 0; i < 4 && png_ptr->pass == 2; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } - for (i = 0; i < 4 && png_ptr->pass == 2; i++) - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - if (png_ptr->pass == 4) /* pass 3 might be empty */ - { - for (i = 0; i < 2 && png_ptr->pass == 4; i++) - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - } - break; - } - case 3: - { - int i; - for (i = 0; i < 4 && png_ptr->pass == 3; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } - if (png_ptr->pass == 4) /* skip top two generated rows */ - { - for (i = 0; i < 2 && png_ptr->pass == 4; i++) - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - } - break; - } - case 4: - { - int i; - for (i = 0; i < 2 && png_ptr->pass == 4; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } - for (i = 0; i < 2 && png_ptr->pass == 4; i++) - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - if (png_ptr->pass == 6) /* pass 5 might be empty */ - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - break; - } - case 5: - { - int i; - for (i = 0; i < 2 && png_ptr->pass == 5; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } - if (png_ptr->pass == 6) /* skip top generated row */ - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - break; - } - case 6: - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - if (png_ptr->pass != 6) - break; - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - } - } - else -#endif - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } -} - -void /* PRIVATE */ -png_read_push_finish_row(png_structp png_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* start of interlace block */ - const int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; - - /* offset to next interlace block */ - const int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; - - /* start of interlace block in the y direction */ - const int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; - - /* offset to next interlace block in the y direction */ - const int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; - - /* Width of interlace block. This is not currently used - if you need - * it, uncomment it here and in png.h - const int FARDATA png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; - */ - - /* Height of interlace block. This is not currently used - if you need - * it, uncomment it here and in png.h - const int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1}; - */ -#endif - - png_ptr->row_number++; - if (png_ptr->row_number < png_ptr->num_rows) - return; - - if (png_ptr->interlaced) - { - png_ptr->row_number = 0; - png_memset_check(png_ptr, png_ptr->prev_row, 0, - png_ptr->rowbytes + 1); - do - { - png_ptr->pass++; - if ((png_ptr->pass == 1 && png_ptr->width < 5) || - (png_ptr->pass == 3 && png_ptr->width < 3) || - (png_ptr->pass == 5 && png_ptr->width < 2)) - png_ptr->pass++; - - if (png_ptr->pass > 7) - png_ptr->pass--; - if (png_ptr->pass >= 7) - break; - - png_ptr->iwidth = (png_ptr->width + - png_pass_inc[png_ptr->pass] - 1 - - png_pass_start[png_ptr->pass]) / - png_pass_inc[png_ptr->pass]; - - png_ptr->irowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, - png_ptr->iwidth) + 1; - - if (png_ptr->transformations & PNG_INTERLACE) - break; - - png_ptr->num_rows = (png_ptr->height + - png_pass_yinc[png_ptr->pass] - 1 - - png_pass_ystart[png_ptr->pass]) / - png_pass_yinc[png_ptr->pass]; - - } while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0); - } -} - -#if defined(PNG_READ_tEXt_SUPPORTED) -void /* PRIVATE */ -png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 - length) -{ - if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) - { - png_error(png_ptr, "Out of place tEXt"); - /* to quiet some compiler warnings */ - if(info_ptr == NULL) return; - } - -#ifdef PNG_MAX_MALLOC_64K - png_ptr->skip_length = 0; /* This may not be necessary */ - - if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */ - { - png_warning(png_ptr, "tEXt chunk too large to fit in memory"); - png_ptr->skip_length = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - - png_ptr->current_text = (png_charp)png_malloc(png_ptr, - (png_uint_32)(length+1)); - png_ptr->current_text[length] = '\0'; - png_ptr->current_text_ptr = png_ptr->current_text; - png_ptr->current_text_size = (png_size_t)length; - png_ptr->current_text_left = (png_size_t)length; - png_ptr->process_mode = PNG_READ_tEXt_MODE; -} - -void /* PRIVATE */ -png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr->buffer_size && png_ptr->current_text_left) - { - png_size_t text_size; - - if (png_ptr->buffer_size < png_ptr->current_text_left) - text_size = png_ptr->buffer_size; - else - text_size = png_ptr->current_text_left; - png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size); - png_ptr->current_text_left -= text_size; - png_ptr->current_text_ptr += text_size; - } - if (!(png_ptr->current_text_left)) - { - png_textp text_ptr; - png_charp text; - png_charp key; - int ret; - - if (png_ptr->buffer_size < 4) - { - png_push_save_buffer(png_ptr); - return; - } - - png_push_crc_finish(png_ptr); - -#if defined(PNG_MAX_MALLOC_64K) - if (png_ptr->skip_length) - return; -#endif - - key = png_ptr->current_text; - - for (text = key; *text; text++) - /* empty loop */ ; - - if (text != key + png_ptr->current_text_size) - text++; - - text_ptr = (png_textp)png_malloc(png_ptr, - (png_uint_32)png_sizeof(png_text)); - text_ptr->compression = PNG_TEXT_COMPRESSION_NONE; - text_ptr->key = key; -#ifdef PNG_iTXt_SUPPORTED - text_ptr->lang = NULL; - text_ptr->lang_key = NULL; -#endif - text_ptr->text = text; - - ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1); - - png_free(png_ptr, key); - png_free(png_ptr, text_ptr); - png_ptr->current_text = NULL; - - if (ret) - png_warning(png_ptr, "Insufficient memory to store text chunk."); - } -} -#endif - -#if defined(PNG_READ_zTXt_SUPPORTED) -void /* PRIVATE */ -png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 - length) -{ - if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) - { - png_error(png_ptr, "Out of place zTXt"); - /* to quiet some compiler warnings */ - if(info_ptr == NULL) return; - } - -#ifdef PNG_MAX_MALLOC_64K - /* We can't handle zTXt chunks > 64K, since we don't have enough space - * to be able to store the uncompressed data. Actually, the threshold - * is probably around 32K, but it isn't as definite as 64K is. - */ - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr, "zTXt chunk too large to fit in memory"); - png_push_crc_skip(png_ptr, length); - return; - } -#endif - - png_ptr->current_text = (png_charp)png_malloc(png_ptr, - (png_uint_32)(length+1)); - png_ptr->current_text[length] = '\0'; - png_ptr->current_text_ptr = png_ptr->current_text; - png_ptr->current_text_size = (png_size_t)length; - png_ptr->current_text_left = (png_size_t)length; - png_ptr->process_mode = PNG_READ_zTXt_MODE; -} - -void /* PRIVATE */ -png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr->buffer_size && png_ptr->current_text_left) - { - png_size_t text_size; - - if (png_ptr->buffer_size < (png_uint_32)png_ptr->current_text_left) - text_size = png_ptr->buffer_size; - else - text_size = png_ptr->current_text_left; - png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size); - png_ptr->current_text_left -= text_size; - png_ptr->current_text_ptr += text_size; - } - if (!(png_ptr->current_text_left)) - { - png_textp text_ptr; - png_charp text; - png_charp key; - int ret; - png_size_t text_size, key_size; - - if (png_ptr->buffer_size < 4) - { - png_push_save_buffer(png_ptr); - return; - } - - png_push_crc_finish(png_ptr); - - key = png_ptr->current_text; - - for (text = key; *text; text++) - /* empty loop */ ; - - /* zTXt can't have zero text */ - if (text == key + png_ptr->current_text_size) - { - png_ptr->current_text = NULL; - png_free(png_ptr, key); - return; - } - - text++; - - if (*text != PNG_TEXT_COMPRESSION_zTXt) /* check compression byte */ - { - png_ptr->current_text = NULL; - png_free(png_ptr, key); - return; - } - - text++; - - png_ptr->zstream.next_in = (png_bytep )text; - png_ptr->zstream.avail_in = (uInt)(png_ptr->current_text_size - - (text - key)); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - - key_size = text - key; - text_size = 0; - text = NULL; - ret = Z_STREAM_END; - - while (png_ptr->zstream.avail_in) - { - ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); - if (ret != Z_OK && ret != Z_STREAM_END) - { - inflateReset(&png_ptr->zstream); - png_ptr->zstream.avail_in = 0; - png_ptr->current_text = NULL; - png_free(png_ptr, key); - png_free(png_ptr, text); - return; - } - if (!(png_ptr->zstream.avail_out) || ret == Z_STREAM_END) - { - if (text == NULL) - { - text = (png_charp)png_malloc(png_ptr, - (png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out - + key_size + 1)); - png_memcpy(text + key_size, png_ptr->zbuf, - png_ptr->zbuf_size - png_ptr->zstream.avail_out); - png_memcpy(text, key, key_size); - text_size = key_size + png_ptr->zbuf_size - - png_ptr->zstream.avail_out; - *(text + text_size) = '\0'; - } - else - { - png_charp tmp; - - tmp = text; - text = (png_charp)png_malloc(png_ptr, text_size + - (png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out - + 1)); - png_memcpy(text, tmp, text_size); - png_free(png_ptr, tmp); - png_memcpy(text + text_size, png_ptr->zbuf, - png_ptr->zbuf_size - png_ptr->zstream.avail_out); - text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out; - *(text + text_size) = '\0'; - } - if (ret != Z_STREAM_END) - { - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - } - } - else - { - break; - } - - if (ret == Z_STREAM_END) - break; - } - - inflateReset(&png_ptr->zstream); - png_ptr->zstream.avail_in = 0; - - if (ret != Z_STREAM_END) - { - png_ptr->current_text = NULL; - png_free(png_ptr, key); - png_free(png_ptr, text); - return; - } - - png_ptr->current_text = NULL; - png_free(png_ptr, key); - key = text; - text += key_size; - - text_ptr = (png_textp)png_malloc(png_ptr, - (png_uint_32)png_sizeof(png_text)); - text_ptr->compression = PNG_TEXT_COMPRESSION_zTXt; - text_ptr->key = key; -#ifdef PNG_iTXt_SUPPORTED - text_ptr->lang = NULL; - text_ptr->lang_key = NULL; -#endif - text_ptr->text = text; - - ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1); - - png_free(png_ptr, key); - png_free(png_ptr, text_ptr); - - if (ret) - png_warning(png_ptr, "Insufficient memory to store text chunk."); - } -} -#endif - -#if defined(PNG_READ_iTXt_SUPPORTED) -void /* PRIVATE */ -png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 - length) -{ - if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) - { - png_error(png_ptr, "Out of place iTXt"); - /* to quiet some compiler warnings */ - if(info_ptr == NULL) return; - } - -#ifdef PNG_MAX_MALLOC_64K - png_ptr->skip_length = 0; /* This may not be necessary */ - - if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */ - { - png_warning(png_ptr, "iTXt chunk too large to fit in memory"); - png_ptr->skip_length = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - - png_ptr->current_text = (png_charp)png_malloc(png_ptr, - (png_uint_32)(length+1)); - png_ptr->current_text[length] = '\0'; - png_ptr->current_text_ptr = png_ptr->current_text; - png_ptr->current_text_size = (png_size_t)length; - png_ptr->current_text_left = (png_size_t)length; - png_ptr->process_mode = PNG_READ_iTXt_MODE; -} - -void /* PRIVATE */ -png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr) -{ - - if (png_ptr->buffer_size && png_ptr->current_text_left) - { - png_size_t text_size; - - if (png_ptr->buffer_size < png_ptr->current_text_left) - text_size = png_ptr->buffer_size; - else - text_size = png_ptr->current_text_left; - png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size); - png_ptr->current_text_left -= text_size; - png_ptr->current_text_ptr += text_size; - } - if (!(png_ptr->current_text_left)) - { - png_textp text_ptr; - png_charp key; - int comp_flag; - png_charp lang; - png_charp lang_key; - png_charp text; - int ret; - - if (png_ptr->buffer_size < 4) - { - png_push_save_buffer(png_ptr); - return; - } - - png_push_crc_finish(png_ptr); - -#if defined(PNG_MAX_MALLOC_64K) - if (png_ptr->skip_length) - return; -#endif - - key = png_ptr->current_text; - - for (lang = key; *lang; lang++) - /* empty loop */ ; - - if (lang != key + png_ptr->current_text_size) - lang++; - - comp_flag = *lang++; - lang++; /* skip comp_type, always zero */ - - for (lang_key = lang; *lang_key; lang_key++) - /* empty loop */ ; - lang_key++; /* skip NUL separator */ - - for (text = lang_key; *text; text++) - /* empty loop */ ; - - if (text != key + png_ptr->current_text_size) - text++; - - text_ptr = (png_textp)png_malloc(png_ptr, - (png_uint_32)png_sizeof(png_text)); - text_ptr->compression = comp_flag + 2; - text_ptr->key = key; - text_ptr->lang = lang; - text_ptr->lang_key = lang_key; - text_ptr->text = text; - text_ptr->text_length = 0; - text_ptr->itxt_length = png_strlen(text); - - ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1); - - png_ptr->current_text = NULL; - - png_free(png_ptr, text_ptr); - if (ret) - png_warning(png_ptr, "Insufficient memory to store iTXt chunk."); - } -} -#endif - -/* This function is called when we haven't found a handler for this - * chunk. If there isn't a problem with the chunk itself (ie a bad chunk - * name or a critical chunk), the chunk is (currently) silently ignored. - */ -void /* PRIVATE */ -png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 - length) -{ - png_uint_32 skip=0; - png_check_chunk_name(png_ptr, png_ptr->chunk_name); - - if (!(png_ptr->chunk_name[0] & 0x20)) - { -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != - PNG_HANDLE_CHUNK_ALWAYS -#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) - && png_ptr->read_user_chunk_fn == NULL -#endif - ) -#endif - png_chunk_error(png_ptr, "unknown critical chunk"); - - /* to quiet compiler warnings about unused info_ptr */ - if (info_ptr == NULL) - return; - } - -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - if (png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS) - { -#ifdef PNG_MAX_MALLOC_64K - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr, "unknown chunk too large to fit in memory"); - skip = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - png_strcpy((png_charp)png_ptr->unknown_chunk.name, - (png_charp)png_ptr->chunk_name); - png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr, length); - png_ptr->unknown_chunk.size = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data, length); -#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) - if(png_ptr->read_user_chunk_fn != NULL) - { - /* callback to user unknown chunk handler */ - int ret; - ret = (*(png_ptr->read_user_chunk_fn)) - (png_ptr, &png_ptr->unknown_chunk); - if (ret < 0) - png_chunk_error(png_ptr, "error in user chunk"); - if (ret == 0) - { - if (!(png_ptr->chunk_name[0] & 0x20)) - if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != - PNG_HANDLE_CHUNK_ALWAYS) - png_chunk_error(png_ptr, "unknown critical chunk"); - png_set_unknown_chunks(png_ptr, info_ptr, - &png_ptr->unknown_chunk, 1); - } - } -#else - png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1); -#endif - png_free(png_ptr, png_ptr->unknown_chunk.data); - png_ptr->unknown_chunk.data = NULL; - } - else -#endif - skip=length; - png_push_crc_skip(png_ptr, skip); -} - -void /* PRIVATE */ -png_push_have_info(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr->info_fn != NULL) - (*(png_ptr->info_fn))(png_ptr, info_ptr); -} - -void /* PRIVATE */ -png_push_have_end(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr->end_fn != NULL) - (*(png_ptr->end_fn))(png_ptr, info_ptr); -} - -void /* PRIVATE */ -png_push_have_row(png_structp png_ptr, png_bytep row) -{ - if (png_ptr->row_fn != NULL) - (*(png_ptr->row_fn))(png_ptr, row, png_ptr->row_number, - (int)png_ptr->pass); -} - -void PNGAPI -png_progressive_combine_row (png_structp png_ptr, - png_bytep old_row, png_bytep new_row) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - const int FARDATA png_pass_dsp_mask[7] = - {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; -#endif - if(png_ptr == NULL) return; - if (new_row != NULL) /* new_row must == png_ptr->row_buf here. */ - png_combine_row(png_ptr, old_row, png_pass_dsp_mask[png_ptr->pass]); -} - -void PNGAPI -png_set_progressive_read_fn(png_structp png_ptr, png_voidp progressive_ptr, - png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, - png_progressive_end_ptr end_fn) -{ - if(png_ptr == NULL) return; - png_ptr->info_fn = info_fn; - png_ptr->row_fn = row_fn; - png_ptr->end_fn = end_fn; - - png_set_read_fn(png_ptr, progressive_ptr, png_push_fill_buffer); -} - -png_voidp PNGAPI -png_get_progressive_ptr(png_structp png_ptr) -{ - if(png_ptr == NULL) return (NULL); - return png_ptr->io_ptr; -} -#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/pngread.c b/irrlicht-1.6/source/Irrlicht/libpng/pngread.c deleted file mode 100644 index 0d0a7c93f..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/pngread.c +++ /dev/null @@ -1,1473 +0,0 @@ - -/* pngread.c - read a PNG file - * - * Last changed in libpng 1.2.15 January 5, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This file contains routines that an application calls directly to - * read a PNG file or stream. - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_READ_SUPPORTED) - -/* Create a PNG structure for reading, and allocate any memory needed. */ -png_structp PNGAPI -png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn) -{ - -#ifdef PNG_USER_MEM_SUPPORTED - return (png_create_read_struct_2(user_png_ver, error_ptr, error_fn, - warn_fn, png_voidp_NULL, png_malloc_ptr_NULL, png_free_ptr_NULL)); -} - -/* Alternate create PNG structure for reading, and allocate any memory needed. */ -png_structp PNGAPI -png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn) -{ -#endif /* PNG_USER_MEM_SUPPORTED */ - - png_structp png_ptr; - -#ifdef PNG_SETJMP_SUPPORTED -#ifdef USE_FAR_KEYWORD - jmp_buf jmpbuf; -#endif -#endif - - int i; - - png_debug(1, "in png_create_read_struct\n"); -#ifdef PNG_USER_MEM_SUPPORTED - png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG, - (png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr); -#else - png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); -#endif - if (png_ptr == NULL) - return (NULL); - -#if !defined(PNG_1_0_X) -#ifdef PNG_MMX_CODE_SUPPORTED - png_init_mmx_flags(png_ptr); /* 1.2.0 addition */ -#endif -#endif /* PNG_1_0_X */ - - /* added at libpng-1.2.6 */ -#ifdef PNG_SET_USER_LIMITS_SUPPORTED - png_ptr->user_width_max=PNG_USER_WIDTH_MAX; - png_ptr->user_height_max=PNG_USER_HEIGHT_MAX; -#endif - -#ifdef PNG_SETJMP_SUPPORTED -#ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) -#else - if (setjmp(png_ptr->jmpbuf)) -#endif - { - png_free(png_ptr, png_ptr->zbuf); - png_ptr->zbuf=NULL; -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)png_ptr, - (png_free_ptr)free_fn, (png_voidp)mem_ptr); -#else - png_destroy_struct((png_voidp)png_ptr); -#endif - return (NULL); - } -#ifdef USE_FAR_KEYWORD - png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf)); -#endif -#endif - -#ifdef PNG_USER_MEM_SUPPORTED - png_set_mem_fn(png_ptr, mem_ptr, malloc_fn, free_fn); -#endif - - png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn); - - i=0; - do - { - if(user_png_ver[i] != png_libpng_ver[i]) - png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; - } while (png_libpng_ver[i++]); - - if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) - { - /* Libpng 0.90 and later are binary incompatible with libpng 0.89, so - * we must recompile any applications that use any older library version. - * For versions after libpng 1.0, we will be compatible, so we need - * only check the first digit. - */ - if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] || - (user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) || - (user_png_ver[0] == '0' && user_png_ver[2] < '9')) - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char msg[80]; - if (user_png_ver) - { - sprintf(msg, "Application was compiled with png.h from libpng-%.20s", - user_png_ver); - png_warning(png_ptr, msg); - } - sprintf(msg, "Application is running with png.c from libpng-%.20s", - png_libpng_ver); - png_warning(png_ptr, msg); -#endif -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "Incompatible libpng version in application and library"); - } - } - - /* initialize zbuf - compression buffer */ - png_ptr->zbuf_size = PNG_ZBUF_SIZE; - png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, - (png_uint_32)png_ptr->zbuf_size); - png_ptr->zstream.zalloc = png_zalloc; - png_ptr->zstream.zfree = png_zfree; - png_ptr->zstream.opaque = (voidpf)png_ptr; - - switch (inflateInit(&png_ptr->zstream)) - { - case Z_OK: /* Do nothing */ break; - case Z_MEM_ERROR: - case Z_STREAM_ERROR: png_error(png_ptr, "zlib memory error"); break; - case Z_VERSION_ERROR: png_error(png_ptr, "zlib version error"); break; - default: png_error(png_ptr, "Unknown zlib error"); - } - - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - - png_set_read_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL); - -#ifdef PNG_SETJMP_SUPPORTED -/* Applications that neglect to set up their own setjmp() and then encounter - a png_error() will longjmp here. Since the jmpbuf is then meaningless we - abort instead of returning. */ -#ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) - PNG_ABORT(); - png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf)); -#else - if (setjmp(png_ptr->jmpbuf)) - PNG_ABORT(); -#endif -#endif - return (png_ptr); -} - -#if defined(PNG_1_0_X) || defined(PNG_1_2_X) -/* Initialize PNG structure for reading, and allocate any memory needed. - This interface is deprecated in favour of the png_create_read_struct(), - and it will disappear as of libpng-1.3.0. */ -#undef png_read_init -void PNGAPI -png_read_init(png_structp png_ptr) -{ - /* We only come here via pre-1.0.7-compiled applications */ - png_read_init_2(png_ptr, "1.0.6 or earlier", 0, 0); -} - -void PNGAPI -png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver, - png_size_t png_struct_size, png_size_t png_info_size) -{ - /* We only come here via pre-1.0.12-compiled applications */ - if(png_ptr == NULL) return; -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - if(png_sizeof(png_struct) > png_struct_size || - png_sizeof(png_info) > png_info_size) - { - char msg[80]; - png_ptr->warning_fn=NULL; - if (user_png_ver) - { - sprintf(msg, "Application was compiled with png.h from libpng-%.20s", - user_png_ver); - png_warning(png_ptr, msg); - } - sprintf(msg, "Application is running with png.c from libpng-%.20s", - png_libpng_ver); - png_warning(png_ptr, msg); - } -#endif - if(png_sizeof(png_struct) > png_struct_size) - { - png_ptr->error_fn=NULL; -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "The png struct allocated by the application for reading is too small."); - } - if(png_sizeof(png_info) > png_info_size) - { - png_ptr->error_fn=NULL; -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "The info struct allocated by application for reading is too small."); - } - png_read_init_3(&png_ptr, user_png_ver, png_struct_size); -} -#endif /* PNG_1_0_X || PNG_1_2_X */ - -void PNGAPI -png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, - png_size_t png_struct_size) -{ -#ifdef PNG_SETJMP_SUPPORTED - jmp_buf tmp_jmp; /* to save current jump buffer */ -#endif - - int i=0; - - png_structp png_ptr=*ptr_ptr; - - if(png_ptr == NULL) return; - - do - { - if(user_png_ver[i] != png_libpng_ver[i]) - { -#ifdef PNG_LEGACY_SUPPORTED - png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; -#else - png_ptr->warning_fn=NULL; - png_warning(png_ptr, - "Application uses deprecated png_read_init() and should be recompiled."); - break; -#endif - } - } while (png_libpng_ver[i++]); - - png_debug(1, "in png_read_init_3\n"); - -#ifdef PNG_SETJMP_SUPPORTED - /* save jump buffer and error functions */ - png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf)); -#endif - - if(png_sizeof(png_struct) > png_struct_size) - { - png_destroy_struct(png_ptr); - *ptr_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); - png_ptr = *ptr_ptr; - } - - /* reset all variables to 0 */ - png_memset(png_ptr, 0, png_sizeof (png_struct)); - -#ifdef PNG_SETJMP_SUPPORTED - /* restore jump buffer */ - png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf)); -#endif - - /* added at libpng-1.2.6 */ -#ifdef PNG_SET_USER_LIMITS_SUPPORTED - png_ptr->user_width_max=PNG_USER_WIDTH_MAX; - png_ptr->user_height_max=PNG_USER_HEIGHT_MAX; -#endif - - /* initialize zbuf - compression buffer */ - png_ptr->zbuf_size = PNG_ZBUF_SIZE; - png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, - (png_uint_32)png_ptr->zbuf_size); - png_ptr->zstream.zalloc = png_zalloc; - png_ptr->zstream.zfree = png_zfree; - png_ptr->zstream.opaque = (voidpf)png_ptr; - - switch (inflateInit(&png_ptr->zstream)) - { - case Z_OK: /* Do nothing */ break; - case Z_MEM_ERROR: - case Z_STREAM_ERROR: png_error(png_ptr, "zlib memory"); break; - case Z_VERSION_ERROR: png_error(png_ptr, "zlib version"); break; - default: png_error(png_ptr, "Unknown zlib error"); - } - - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - - png_set_read_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL); -} - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* Read the information before the actual image data. This has been - * changed in v0.90 to allow reading a file that already has the magic - * bytes read from the stream. You can tell libpng how many bytes have - * been read from the beginning of the stream (up to the maximum of 8) - * via png_set_sig_bytes(), and we will only check the remaining bytes - * here. The application can then have access to the signature bytes we - * read if it is determined that this isn't a valid PNG file. - */ -void PNGAPI -png_read_info(png_structp png_ptr, png_infop info_ptr) -{ - if(png_ptr == NULL) return; - png_debug(1, "in png_read_info\n"); - /* If we haven't checked all of the PNG signature bytes, do so now. */ - if (png_ptr->sig_bytes < 8) - { - png_size_t num_checked = png_ptr->sig_bytes, - num_to_check = 8 - num_checked; - - png_read_data(png_ptr, &(info_ptr->signature[num_checked]), num_to_check); - png_ptr->sig_bytes = 8; - - if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check)) - { - if (num_checked < 4 && - png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4)) - png_error(png_ptr, "Not a PNG file"); - else - png_error(png_ptr, "PNG file corrupted by ASCII conversion"); - } - if (num_checked < 3) - png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE; - } - - for(;;) - { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IHDR; - PNG_IDAT; - PNG_IEND; - PNG_PLTE; -#if defined(PNG_READ_bKGD_SUPPORTED) - PNG_bKGD; -#endif -#if defined(PNG_READ_cHRM_SUPPORTED) - PNG_cHRM; -#endif -#if defined(PNG_READ_gAMA_SUPPORTED) - PNG_gAMA; -#endif -#if defined(PNG_READ_hIST_SUPPORTED) - PNG_hIST; -#endif -#if defined(PNG_READ_iCCP_SUPPORTED) - PNG_iCCP; -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - PNG_iTXt; -#endif -#if defined(PNG_READ_oFFs_SUPPORTED) - PNG_oFFs; -#endif -#if defined(PNG_READ_pCAL_SUPPORTED) - PNG_pCAL; -#endif -#if defined(PNG_READ_pHYs_SUPPORTED) - PNG_pHYs; -#endif -#if defined(PNG_READ_sBIT_SUPPORTED) - PNG_sBIT; -#endif -#if defined(PNG_READ_sCAL_SUPPORTED) - PNG_sCAL; -#endif -#if defined(PNG_READ_sPLT_SUPPORTED) - PNG_sPLT; -#endif -#if defined(PNG_READ_sRGB_SUPPORTED) - PNG_sRGB; -#endif -#if defined(PNG_READ_tEXt_SUPPORTED) - PNG_tEXt; -#endif -#if defined(PNG_READ_tIME_SUPPORTED) - PNG_tIME; -#endif -#if defined(PNG_READ_tRNS_SUPPORTED) - PNG_tRNS; -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - PNG_zTXt; -#endif -#endif /* PNG_USE_LOCAL_ARRAYS */ - png_byte chunk_length[4]; - png_uint_32 length; - - png_read_data(png_ptr, chunk_length, 4); - length = png_get_uint_31(png_ptr,chunk_length); - - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); - - png_debug2(0, "Reading %s chunk, length=%lu.\n", png_ptr->chunk_name, - length); - - /* This should be a binary subdivision search or a hash for - * matching the chunk name rather than a linear search. - */ - if (!png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) - if(png_ptr->mode & PNG_AFTER_IDAT) - png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT; - - if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) - png_handle_IHDR(png_ptr, info_ptr, length); - else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4)) - png_handle_IEND(png_ptr, info_ptr, length); -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED - else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name)) - { - if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - png_ptr->mode |= PNG_HAVE_IDAT; - png_handle_unknown(png_ptr, info_ptr, length); - if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) - png_ptr->mode |= PNG_HAVE_PLTE; - else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - { - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before IDAT"); - else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - !(png_ptr->mode & PNG_HAVE_PLTE)) - png_error(png_ptr, "Missing PLTE before IDAT"); - break; - } - } -#endif - else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) - png_handle_PLTE(png_ptr, info_ptr, length); - else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - { - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before IDAT"); - else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - !(png_ptr->mode & PNG_HAVE_PLTE)) - png_error(png_ptr, "Missing PLTE before IDAT"); - - png_ptr->idat_size = length; - png_ptr->mode |= PNG_HAVE_IDAT; - break; - } -#if defined(PNG_READ_bKGD_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4)) - png_handle_bKGD(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_cHRM_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4)) - png_handle_cHRM(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_gAMA_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4)) - png_handle_gAMA(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_hIST_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4)) - png_handle_hIST(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_oFFs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4)) - png_handle_oFFs(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_pCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4)) - png_handle_pCAL(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4)) - png_handle_sCAL(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_pHYs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4)) - png_handle_pHYs(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sBIT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4)) - png_handle_sBIT(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sRGB_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4)) - png_handle_sRGB(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_iCCP_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4)) - png_handle_iCCP(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sPLT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4)) - png_handle_sPLT(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_tEXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4)) - png_handle_tEXt(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_tIME_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4)) - png_handle_tIME(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_tRNS_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4)) - png_handle_tRNS(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4)) - png_handle_zTXt(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4)) - png_handle_iTXt(png_ptr, info_ptr, length); -#endif - else - png_handle_unknown(png_ptr, info_ptr, length); - } -} -#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ - -/* optional call to update the users info_ptr structure */ -void PNGAPI -png_read_update_info(png_structp png_ptr, png_infop info_ptr) -{ - png_debug(1, "in png_read_update_info\n"); - if(png_ptr == NULL) return; - if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) - png_read_start_row(png_ptr); - else - png_warning(png_ptr, - "Ignoring extra png_read_update_info() call; row buffer not reallocated"); - png_read_transform_info(png_ptr, info_ptr); -} - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* Initialize palette, background, etc, after transformations - * are set, but before any reading takes place. This allows - * the user to obtain a gamma-corrected palette, for example. - * If the user doesn't call this, we will do it ourselves. - */ -void PNGAPI -png_start_read_image(png_structp png_ptr) -{ - png_debug(1, "in png_start_read_image\n"); - if(png_ptr == NULL) return; - if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) - png_read_start_row(png_ptr); -} -#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -void PNGAPI -png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IDAT; - const int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; - const int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff}; -#endif - int ret; - if(png_ptr == NULL) return; - png_debug2(1, "in png_read_row (row %lu, pass %d)\n", - png_ptr->row_number, png_ptr->pass); - if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) - png_read_start_row(png_ptr); - if (png_ptr->row_number == 0 && png_ptr->pass == 0) - { - /* check for transforms that have been set but were defined out */ -#if defined(PNG_WRITE_INVERT_SUPPORTED) && !defined(PNG_READ_INVERT_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_MONO) - png_warning(png_ptr, "PNG_READ_INVERT_SUPPORTED is not defined."); -#endif -#if defined(PNG_WRITE_FILLER_SUPPORTED) && !defined(PNG_READ_FILLER_SUPPORTED) - if (png_ptr->transformations & PNG_FILLER) - png_warning(png_ptr, "PNG_READ_FILLER_SUPPORTED is not defined."); -#endif -#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) && !defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - png_warning(png_ptr, "PNG_READ_PACKSWAP_SUPPORTED is not defined."); -#endif -#if defined(PNG_WRITE_PACK_SUPPORTED) && !defined(PNG_READ_PACK_SUPPORTED) - if (png_ptr->transformations & PNG_PACK) - png_warning(png_ptr, "PNG_READ_PACK_SUPPORTED is not defined."); -#endif -#if defined(PNG_WRITE_SHIFT_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) - if (png_ptr->transformations & PNG_SHIFT) - png_warning(png_ptr, "PNG_READ_SHIFT_SUPPORTED is not defined."); -#endif -#if defined(PNG_WRITE_BGR_SUPPORTED) && !defined(PNG_READ_BGR_SUPPORTED) - if (png_ptr->transformations & PNG_BGR) - png_warning(png_ptr, "PNG_READ_BGR_SUPPORTED is not defined."); -#endif -#if defined(PNG_WRITE_SWAP_SUPPORTED) && !defined(PNG_READ_SWAP_SUPPORTED) - if (png_ptr->transformations & PNG_SWAP_BYTES) - png_warning(png_ptr, "PNG_READ_SWAP_SUPPORTED is not defined."); -#endif - } - -#if defined(PNG_READ_INTERLACING_SUPPORTED) - /* if interlaced and we do not need a new row, combine row and return */ - if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) - { - switch (png_ptr->pass) - { - case 0: - if (png_ptr->row_number & 0x07) - { - if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); - png_read_finish_row(png_ptr); - return; - } - break; - case 1: - if ((png_ptr->row_number & 0x07) || png_ptr->width < 5) - { - if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); - png_read_finish_row(png_ptr); - return; - } - break; - case 2: - if ((png_ptr->row_number & 0x07) != 4) - { - if (dsp_row != NULL && (png_ptr->row_number & 4)) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); - png_read_finish_row(png_ptr); - return; - } - break; - case 3: - if ((png_ptr->row_number & 3) || png_ptr->width < 3) - { - if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); - png_read_finish_row(png_ptr); - return; - } - break; - case 4: - if ((png_ptr->row_number & 3) != 2) - { - if (dsp_row != NULL && (png_ptr->row_number & 2)) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); - png_read_finish_row(png_ptr); - return; - } - break; - case 5: - if ((png_ptr->row_number & 1) || png_ptr->width < 2) - { - if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); - png_read_finish_row(png_ptr); - return; - } - break; - case 6: - if (!(png_ptr->row_number & 1)) - { - png_read_finish_row(png_ptr); - return; - } - break; - } - } -#endif - - if (!(png_ptr->mode & PNG_HAVE_IDAT)) - png_error(png_ptr, "Invalid attempt to read row data"); - - png_ptr->zstream.next_out = png_ptr->row_buf; - png_ptr->zstream.avail_out = (uInt)png_ptr->irowbytes; - do - { - if (!(png_ptr->zstream.avail_in)) - { - while (!png_ptr->idat_size) - { - png_byte chunk_length[4]; - - png_crc_finish(png_ptr, 0); - - png_read_data(png_ptr, chunk_length, 4); - png_ptr->idat_size = png_get_uint_31(png_ptr,chunk_length); - - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); - if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - png_error(png_ptr, "Not enough image data"); - } - png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size; - png_ptr->zstream.next_in = png_ptr->zbuf; - if (png_ptr->zbuf_size > png_ptr->idat_size) - png_ptr->zstream.avail_in = (uInt)png_ptr->idat_size; - png_crc_read(png_ptr, png_ptr->zbuf, - (png_size_t)png_ptr->zstream.avail_in); - png_ptr->idat_size -= png_ptr->zstream.avail_in; - } - ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); - if (ret == Z_STREAM_END) - { - if (png_ptr->zstream.avail_out || png_ptr->zstream.avail_in || - png_ptr->idat_size) - png_error(png_ptr, "Extra compressed data"); - png_ptr->mode |= PNG_AFTER_IDAT; - png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; - break; - } - if (ret != Z_OK) - png_error(png_ptr, png_ptr->zstream.msg ? png_ptr->zstream.msg : - "Decompression error"); - - } while (png_ptr->zstream.avail_out); - - png_ptr->row_info.color_type = png_ptr->color_type; - png_ptr->row_info.width = png_ptr->iwidth; - png_ptr->row_info.channels = png_ptr->channels; - png_ptr->row_info.bit_depth = png_ptr->bit_depth; - png_ptr->row_info.pixel_depth = png_ptr->pixel_depth; - png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth, - png_ptr->row_info.width); - - if(png_ptr->row_buf[0]) - png_read_filter_row(png_ptr, &(png_ptr->row_info), - png_ptr->row_buf + 1, png_ptr->prev_row + 1, - (int)(png_ptr->row_buf[0])); - - png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf, - png_ptr->rowbytes + 1); - -#if defined(PNG_MNG_FEATURES_SUPPORTED) - if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING)) - { - /* Intrapixel differencing */ - png_do_read_intrapixel(&(png_ptr->row_info), png_ptr->row_buf + 1); - } -#endif - - - if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA)) - png_do_read_transformations(png_ptr); - -#if defined(PNG_READ_INTERLACING_SUPPORTED) - /* blow up interlaced rows to full size */ - if (png_ptr->interlaced && - (png_ptr->transformations & PNG_INTERLACE)) - { - if (png_ptr->pass < 6) -/* old interface (pre-1.0.9): - png_do_read_interlace(&(png_ptr->row_info), - png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations); - */ - png_do_read_interlace(png_ptr); - - if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); - if (row != NULL) - png_combine_row(png_ptr, row, - png_pass_mask[png_ptr->pass]); - } - else -#endif - { - if (row != NULL) - png_combine_row(png_ptr, row, 0xff); - if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, 0xff); - } - png_read_finish_row(png_ptr); - - if (png_ptr->read_row_fn != NULL) - (*(png_ptr->read_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass); -} -#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* Read one or more rows of image data. If the image is interlaced, - * and png_set_interlace_handling() has been called, the rows need to - * contain the contents of the rows from the previous pass. If the - * image has alpha or transparency, and png_handle_alpha()[*] has been - * called, the rows contents must be initialized to the contents of the - * screen. - * - * "row" holds the actual image, and pixels are placed in it - * as they arrive. If the image is displayed after each pass, it will - * appear to "sparkle" in. "display_row" can be used to display a - * "chunky" progressive image, with finer detail added as it becomes - * available. If you do not want this "chunky" display, you may pass - * NULL for display_row. If you do not want the sparkle display, and - * you have not called png_handle_alpha(), you may pass NULL for rows. - * If you have called png_handle_alpha(), and the image has either an - * alpha channel or a transparency chunk, you must provide a buffer for - * rows. In this case, you do not have to provide a display_row buffer - * also, but you may. If the image is not interlaced, or if you have - * not called png_set_interlace_handling(), the display_row buffer will - * be ignored, so pass NULL to it. - * - * [*] png_handle_alpha() does not exist yet, as of this version of libpng - */ - -void PNGAPI -png_read_rows(png_structp png_ptr, png_bytepp row, - png_bytepp display_row, png_uint_32 num_rows) -{ - png_uint_32 i; - png_bytepp rp; - png_bytepp dp; - - png_debug(1, "in png_read_rows\n"); - if(png_ptr == NULL) return; - rp = row; - dp = display_row; - if (rp != NULL && dp != NULL) - for (i = 0; i < num_rows; i++) - { - png_bytep rptr = *rp++; - png_bytep dptr = *dp++; - - png_read_row(png_ptr, rptr, dptr); - } - else if(rp != NULL) - for (i = 0; i < num_rows; i++) - { - png_bytep rptr = *rp; - png_read_row(png_ptr, rptr, png_bytep_NULL); - rp++; - } - else if(dp != NULL) - for (i = 0; i < num_rows; i++) - { - png_bytep dptr = *dp; - png_read_row(png_ptr, png_bytep_NULL, dptr); - dp++; - } -} -#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* Read the entire image. If the image has an alpha channel or a tRNS - * chunk, and you have called png_handle_alpha()[*], you will need to - * initialize the image to the current image that PNG will be overlaying. - * We set the num_rows again here, in case it was incorrectly set in - * png_read_start_row() by a call to png_read_update_info() or - * png_start_read_image() if png_set_interlace_handling() wasn't called - * prior to either of these functions like it should have been. You can - * only call this function once. If you desire to have an image for - * each pass of a interlaced image, use png_read_rows() instead. - * - * [*] png_handle_alpha() does not exist yet, as of this version of libpng - */ -void PNGAPI -png_read_image(png_structp png_ptr, png_bytepp image) -{ - png_uint_32 i,image_height; - int pass, j; - png_bytepp rp; - - png_debug(1, "in png_read_image\n"); - if(png_ptr == NULL) return; - -#ifdef PNG_READ_INTERLACING_SUPPORTED - pass = png_set_interlace_handling(png_ptr); -#else - if (png_ptr->interlaced) - png_error(png_ptr, - "Cannot read interlaced image -- interlace handler disabled."); - pass = 1; -#endif - - - image_height=png_ptr->height; - png_ptr->num_rows = image_height; /* Make sure this is set correctly */ - - for (j = 0; j < pass; j++) - { - rp = image; - for (i = 0; i < image_height; i++) - { - png_read_row(png_ptr, *rp, png_bytep_NULL); - rp++; - } - } -} -#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* Read the end of the PNG file. Will not read past the end of the - * file, will verify the end is accurate, and will read any comments - * or time information at the end of the file, if info is not NULL. - */ -void PNGAPI -png_read_end(png_structp png_ptr, png_infop info_ptr) -{ - png_byte chunk_length[4]; - png_uint_32 length; - - png_debug(1, "in png_read_end\n"); - if(png_ptr == NULL) return; - png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */ - - do - { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IHDR; - PNG_IDAT; - PNG_IEND; - PNG_PLTE; -#if defined(PNG_READ_bKGD_SUPPORTED) - PNG_bKGD; -#endif -#if defined(PNG_READ_cHRM_SUPPORTED) - PNG_cHRM; -#endif -#if defined(PNG_READ_gAMA_SUPPORTED) - PNG_gAMA; -#endif -#if defined(PNG_READ_hIST_SUPPORTED) - PNG_hIST; -#endif -#if defined(PNG_READ_iCCP_SUPPORTED) - PNG_iCCP; -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - PNG_iTXt; -#endif -#if defined(PNG_READ_oFFs_SUPPORTED) - PNG_oFFs; -#endif -#if defined(PNG_READ_pCAL_SUPPORTED) - PNG_pCAL; -#endif -#if defined(PNG_READ_pHYs_SUPPORTED) - PNG_pHYs; -#endif -#if defined(PNG_READ_sBIT_SUPPORTED) - PNG_sBIT; -#endif -#if defined(PNG_READ_sCAL_SUPPORTED) - PNG_sCAL; -#endif -#if defined(PNG_READ_sPLT_SUPPORTED) - PNG_sPLT; -#endif -#if defined(PNG_READ_sRGB_SUPPORTED) - PNG_sRGB; -#endif -#if defined(PNG_READ_tEXt_SUPPORTED) - PNG_tEXt; -#endif -#if defined(PNG_READ_tIME_SUPPORTED) - PNG_tIME; -#endif -#if defined(PNG_READ_tRNS_SUPPORTED) - PNG_tRNS; -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - PNG_zTXt; -#endif -#endif /* PNG_USE_LOCAL_ARRAYS */ - - png_read_data(png_ptr, chunk_length, 4); - length = png_get_uint_31(png_ptr,chunk_length); - - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); - - png_debug1(0, "Reading %s chunk.\n", png_ptr->chunk_name); - - if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) - png_handle_IHDR(png_ptr, info_ptr, length); - else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4)) - png_handle_IEND(png_ptr, info_ptr, length); -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED - else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name)) - { - if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - { - if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT)) - png_error(png_ptr, "Too many IDAT's found"); - } - png_handle_unknown(png_ptr, info_ptr, length); - if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) - png_ptr->mode |= PNG_HAVE_PLTE; - } -#endif - else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - { - /* Zero length IDATs are legal after the last IDAT has been - * read, but not after other chunks have been read. - */ - if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT)) - png_error(png_ptr, "Too many IDAT's found"); - png_crc_finish(png_ptr, length); - } - else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) - png_handle_PLTE(png_ptr, info_ptr, length); -#if defined(PNG_READ_bKGD_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4)) - png_handle_bKGD(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_cHRM_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4)) - png_handle_cHRM(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_gAMA_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4)) - png_handle_gAMA(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_hIST_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4)) - png_handle_hIST(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_oFFs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4)) - png_handle_oFFs(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_pCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4)) - png_handle_pCAL(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4)) - png_handle_sCAL(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_pHYs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4)) - png_handle_pHYs(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sBIT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4)) - png_handle_sBIT(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sRGB_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4)) - png_handle_sRGB(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_iCCP_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4)) - png_handle_iCCP(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sPLT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4)) - png_handle_sPLT(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_tEXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4)) - png_handle_tEXt(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_tIME_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4)) - png_handle_tIME(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_tRNS_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4)) - png_handle_tRNS(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4)) - png_handle_zTXt(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4)) - png_handle_iTXt(png_ptr, info_ptr, length); -#endif - else - png_handle_unknown(png_ptr, info_ptr, length); - } while (!(png_ptr->mode & PNG_HAVE_IEND)); -} -#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ - -/* free all memory used by the read */ -void PNGAPI -png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, - png_infopp end_info_ptr_ptr) -{ - png_structp png_ptr = NULL; - png_infop info_ptr = NULL, end_info_ptr = NULL; -#ifdef PNG_USER_MEM_SUPPORTED - png_free_ptr free_fn; - png_voidp mem_ptr; -#endif - - png_debug(1, "in png_destroy_read_struct\n"); - if (png_ptr_ptr != NULL) - png_ptr = *png_ptr_ptr; - - if (info_ptr_ptr != NULL) - info_ptr = *info_ptr_ptr; - - if (end_info_ptr_ptr != NULL) - end_info_ptr = *end_info_ptr_ptr; - -#ifdef PNG_USER_MEM_SUPPORTED - free_fn = png_ptr->free_fn; - mem_ptr = png_ptr->mem_ptr; -#endif - - png_read_destroy(png_ptr, info_ptr, end_info_ptr); - - if (info_ptr != NULL) - { -#if defined(PNG_TEXT_SUPPORTED) - png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, -1); -#endif - -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)info_ptr, (png_free_ptr)free_fn, - (png_voidp)mem_ptr); -#else - png_destroy_struct((png_voidp)info_ptr); -#endif - *info_ptr_ptr = NULL; - } - - if (end_info_ptr != NULL) - { -#if defined(PNG_READ_TEXT_SUPPORTED) - png_free_data(png_ptr, end_info_ptr, PNG_FREE_TEXT, -1); -#endif -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)end_info_ptr, (png_free_ptr)free_fn, - (png_voidp)mem_ptr); -#else - png_destroy_struct((png_voidp)end_info_ptr); -#endif - *end_info_ptr_ptr = NULL; - } - - if (png_ptr != NULL) - { -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn, - (png_voidp)mem_ptr); -#else - png_destroy_struct((png_voidp)png_ptr); -#endif - *png_ptr_ptr = NULL; - } -} - -/* free all memory used by the read (old method) */ -void /* PRIVATE */ -png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr) -{ -#ifdef PNG_SETJMP_SUPPORTED - jmp_buf tmp_jmp; -#endif - png_error_ptr error_fn; - png_error_ptr warning_fn; - png_voidp error_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - png_free_ptr free_fn; -#endif - - png_debug(1, "in png_read_destroy\n"); - if (info_ptr != NULL) - png_info_destroy(png_ptr, info_ptr); - - if (end_info_ptr != NULL) - png_info_destroy(png_ptr, end_info_ptr); - - png_free(png_ptr, png_ptr->zbuf); - png_free(png_ptr, png_ptr->big_row_buf); - png_free(png_ptr, png_ptr->prev_row); -#if defined(PNG_READ_DITHER_SUPPORTED) - png_free(png_ptr, png_ptr->palette_lookup); - png_free(png_ptr, png_ptr->dither_index); -#endif -#if defined(PNG_READ_GAMMA_SUPPORTED) - png_free(png_ptr, png_ptr->gamma_table); -#endif -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - png_free(png_ptr, png_ptr->gamma_from_1); - png_free(png_ptr, png_ptr->gamma_to_1); -#endif -#ifdef PNG_FREE_ME_SUPPORTED - if (png_ptr->free_me & PNG_FREE_PLTE) - png_zfree(png_ptr, png_ptr->palette); - png_ptr->free_me &= ~PNG_FREE_PLTE; -#else - if (png_ptr->flags & PNG_FLAG_FREE_PLTE) - png_zfree(png_ptr, png_ptr->palette); - png_ptr->flags &= ~PNG_FLAG_FREE_PLTE; -#endif -#if defined(PNG_tRNS_SUPPORTED) || \ - defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) -#ifdef PNG_FREE_ME_SUPPORTED - if (png_ptr->free_me & PNG_FREE_TRNS) - png_free(png_ptr, png_ptr->trans); - png_ptr->free_me &= ~PNG_FREE_TRNS; -#else - if (png_ptr->flags & PNG_FLAG_FREE_TRNS) - png_free(png_ptr, png_ptr->trans); - png_ptr->flags &= ~PNG_FLAG_FREE_TRNS; -#endif -#endif -#if defined(PNG_READ_hIST_SUPPORTED) -#ifdef PNG_FREE_ME_SUPPORTED - if (png_ptr->free_me & PNG_FREE_HIST) - png_free(png_ptr, png_ptr->hist); - png_ptr->free_me &= ~PNG_FREE_HIST; -#else - if (png_ptr->flags & PNG_FLAG_FREE_HIST) - png_free(png_ptr, png_ptr->hist); - png_ptr->flags &= ~PNG_FLAG_FREE_HIST; -#endif -#endif -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (png_ptr->gamma_16_table != NULL) - { - int i; - int istop = (1 << (8 - png_ptr->gamma_shift)); - for (i = 0; i < istop; i++) - { - png_free(png_ptr, png_ptr->gamma_16_table[i]); - } - png_free(png_ptr, png_ptr->gamma_16_table); - } -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->gamma_16_from_1 != NULL) - { - int i; - int istop = (1 << (8 - png_ptr->gamma_shift)); - for (i = 0; i < istop; i++) - { - png_free(png_ptr, png_ptr->gamma_16_from_1[i]); - } - png_free(png_ptr, png_ptr->gamma_16_from_1); - } - if (png_ptr->gamma_16_to_1 != NULL) - { - int i; - int istop = (1 << (8 - png_ptr->gamma_shift)); - for (i = 0; i < istop; i++) - { - png_free(png_ptr, png_ptr->gamma_16_to_1[i]); - } - png_free(png_ptr, png_ptr->gamma_16_to_1); - } -#endif -#endif -#if defined(PNG_TIME_RFC1123_SUPPORTED) - png_free(png_ptr, png_ptr->time_buffer); -#endif - - inflateEnd(&png_ptr->zstream); -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED - png_free(png_ptr, png_ptr->save_buffer); -#endif - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -#ifdef PNG_TEXT_SUPPORTED - png_free(png_ptr, png_ptr->current_text); -#endif /* PNG_TEXT_SUPPORTED */ -#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ - - /* Save the important info out of the png_struct, in case it is - * being used again. - */ -#ifdef PNG_SETJMP_SUPPORTED - png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf)); -#endif - - error_fn = png_ptr->error_fn; - warning_fn = png_ptr->warning_fn; - error_ptr = png_ptr->error_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - free_fn = png_ptr->free_fn; -#endif - - png_memset(png_ptr, 0, png_sizeof (png_struct)); - - png_ptr->error_fn = error_fn; - png_ptr->warning_fn = warning_fn; - png_ptr->error_ptr = error_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - png_ptr->free_fn = free_fn; -#endif - -#ifdef PNG_SETJMP_SUPPORTED - png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf)); -#endif - -} - -void PNGAPI -png_set_read_status_fn(png_structp png_ptr, png_read_status_ptr read_row_fn) -{ - if(png_ptr == NULL) return; - png_ptr->read_row_fn = read_row_fn; -} - - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -#if defined(PNG_INFO_IMAGE_SUPPORTED) -void PNGAPI -png_read_png(png_structp png_ptr, png_infop info_ptr, - int transforms, - voidp params) -{ - int row; - - if(png_ptr == NULL) return; -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) - /* invert the alpha channel from opacity to transparency - */ - if (transforms & PNG_TRANSFORM_INVERT_ALPHA) - png_set_invert_alpha(png_ptr); -#endif - - /* png_read_info() gives us all of the information from the - * PNG file before the first IDAT (image data chunk). - */ - png_read_info(png_ptr, info_ptr); - if (info_ptr->height > PNG_UINT_32_MAX/png_sizeof(png_bytep)) - png_error(png_ptr,"Image is too high to process with png_read_png()"); - - /* -------------- image transformations start here ------------------- */ - -#if defined(PNG_READ_16_TO_8_SUPPORTED) - /* tell libpng to strip 16 bit/color files down to 8 bits per color - */ - if (transforms & PNG_TRANSFORM_STRIP_16) - png_set_strip_16(png_ptr); -#endif - -#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) - /* Strip alpha bytes from the input data without combining with - * the background (not recommended). - */ - if (transforms & PNG_TRANSFORM_STRIP_ALPHA) - png_set_strip_alpha(png_ptr); -#endif - -#if defined(PNG_READ_PACK_SUPPORTED) && !defined(PNG_READ_EXPAND_SUPPORTED) - /* Extract multiple pixels with bit depths of 1, 2, or 4 from a single - * byte into separate bytes (useful for paletted and grayscale images). - */ - if (transforms & PNG_TRANSFORM_PACKING) - png_set_packing(png_ptr); -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - /* Change the order of packed pixels to least significant bit first - * (not useful if you are using png_set_packing). - */ - if (transforms & PNG_TRANSFORM_PACKSWAP) - png_set_packswap(png_ptr); -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) - /* Expand paletted colors into true RGB triplets - * Expand grayscale images to full 8 bits from 1, 2, or 4 bits/pixel - * Expand paletted or RGB images with transparency to full alpha - * channels so the data will be available as RGBA quartets. - */ - if (transforms & PNG_TRANSFORM_EXPAND) - if ((png_ptr->bit_depth < 8) || - (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) || - (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))) - png_set_expand(png_ptr); -#endif - - /* We don't handle background color or gamma transformation or dithering. - */ - -#if defined(PNG_READ_INVERT_SUPPORTED) - /* invert monochrome files to have 0 as white and 1 as black - */ - if (transforms & PNG_TRANSFORM_INVERT_MONO) - png_set_invert_mono(png_ptr); -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) - /* If you want to shift the pixel values from the range [0,255] or - * [0,65535] to the original [0,7] or [0,31], or whatever range the - * colors were originally in: - */ - if ((transforms & PNG_TRANSFORM_SHIFT) - && png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT)) - { - png_color_8p sig_bit; - - png_get_sBIT(png_ptr, info_ptr, &sig_bit); - png_set_shift(png_ptr, sig_bit); - } -#endif - -#if defined(PNG_READ_BGR_SUPPORTED) - /* flip the RGB pixels to BGR (or RGBA to BGRA) - */ - if (transforms & PNG_TRANSFORM_BGR) - png_set_bgr(png_ptr); -#endif - -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) - /* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) - */ - if (transforms & PNG_TRANSFORM_SWAP_ALPHA) - png_set_swap_alpha(png_ptr); -#endif - -#if defined(PNG_READ_SWAP_SUPPORTED) - /* swap bytes of 16 bit files to least significant byte first - */ - if (transforms & PNG_TRANSFORM_SWAP_ENDIAN) - png_set_swap(png_ptr); -#endif - - /* We don't handle adding filler bytes */ - - /* Optional call to gamma correct and add the background to the palette - * and update info structure. REQUIRED if you are expecting libpng to - * update the palette for you (i.e., you selected such a transform above). - */ - png_read_update_info(png_ptr, info_ptr); - - /* -------------- image transformations end here ------------------- */ - -#ifdef PNG_FREE_ME_SUPPORTED - png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); -#endif - if(info_ptr->row_pointers == NULL) - { - info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr, - info_ptr->height * png_sizeof(png_bytep)); -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_ROWS; -#endif - for (row = 0; row < (int)info_ptr->height; row++) - { - info_ptr->row_pointers[row] = (png_bytep)png_malloc(png_ptr, - png_get_rowbytes(png_ptr, info_ptr)); - } - } - - png_read_image(png_ptr, info_ptr->row_pointers); - info_ptr->valid |= PNG_INFO_IDAT; - - /* read rest of file, and get additional chunks in info_ptr - REQUIRED */ - png_read_end(png_ptr, info_ptr); - - if(transforms == 0 || params == NULL) - /* quiet compiler warnings */ return; - -} -#endif /* PNG_INFO_IMAGE_SUPPORTED */ -#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ -#endif /* PNG_READ_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/pngrio.c b/irrlicht-1.6/source/Irrlicht/libpng/pngrio.c deleted file mode 100644 index 22756832d..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/pngrio.c +++ /dev/null @@ -1,167 +0,0 @@ - -/* pngrio.c - functions for data input - * - * Last changed in libpng 1.2.13 November 13, 2006 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2006 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This file provides a location for all input. Users who need - * special handling are expected to write a function that has the same - * arguments as this and performs a similar function, but that possibly - * has a different input method. Note that you shouldn't change this - * function, but rather write a replacement function and then make - * libpng use it at run time with png_set_read_fn(...). - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_READ_SUPPORTED) - -/* Read the data from whatever input you are using. The default routine - reads from a file pointer. Note that this routine sometimes gets called - with very small lengths, so you should implement some kind of simple - buffering if you are using unbuffered reads. This should never be asked - to read more then 64K on a 16 bit machine. */ -void /* PRIVATE */ -png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_debug1(4,"reading %d bytes\n", (int)length); - if (png_ptr->read_data_fn != NULL) - (*(png_ptr->read_data_fn))(png_ptr, data, length); - else - png_error(png_ptr, "Call to NULL read function"); -} - -#if !defined(PNG_NO_STDIO) -/* This is the function that does the actual reading of data. If you are - not reading from a standard C stream, you should create a replacement - read_data function and use it at run time with png_set_read_fn(), rather - than changing the library. */ -#ifndef USE_FAR_KEYWORD -void PNGAPI -png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_size_t check; - - if(png_ptr == NULL) return; - /* fread() returns 0 on error, so it is OK to store this in a png_size_t - * instead of an int, which is what fread() actually returns. - */ -#if defined(_WIN32_WCE) - if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) - check = 0; -#else - check = (png_size_t)fread(data, (png_size_t)1, length, - (png_FILE_p)png_ptr->io_ptr); -#endif - - if (check != length) - png_error(png_ptr, "Read Error"); -} -#else -/* this is the model-independent version. Since the standard I/O library - can't handle far buffers in the medium and small models, we have to copy - the data. -*/ - -#define NEAR_BUF_SIZE 1024 -#define MIN(a,b) (a <= b ? a : b) - -static void PNGAPI -png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - int check; - png_byte *n_data; - png_FILE_p io_ptr; - - if(png_ptr == NULL) return; - /* Check if data really is near. If so, use usual code. */ - n_data = (png_byte *)CVT_PTR_NOCHECK(data); - io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); - if ((png_bytep)n_data == data) - { -#if defined(_WIN32_WCE) - if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) - check = 0; -#else - check = fread(n_data, 1, length, io_ptr); -#endif - } - else - { - png_byte buf[NEAR_BUF_SIZE]; - png_size_t read, remaining, err; - check = 0; - remaining = length; - do - { - read = MIN(NEAR_BUF_SIZE, remaining); -#if defined(_WIN32_WCE) - if ( !ReadFile((HANDLE)(io_ptr), buf, read, &err, NULL) ) - err = 0; -#else - err = fread(buf, (png_size_t)1, read, io_ptr); -#endif - png_memcpy(data, buf, read); /* copy far buffer to near buffer */ - if(err != read) - break; - else - check += err; - data += read; - remaining -= read; - } - while (remaining != 0); - } - if ((png_uint_32)check != (png_uint_32)length) - png_error(png_ptr, "read Error"); -} -#endif -#endif - -/* This function allows the application to supply a new input function - for libpng if standard C streams aren't being used. - - This function takes as its arguments: - png_ptr - pointer to a png input data structure - io_ptr - pointer to user supplied structure containing info about - the input functions. May be NULL. - read_data_fn - pointer to a new input function that takes as its - arguments a pointer to a png_struct, a pointer to - a location where input data can be stored, and a 32-bit - unsigned int that is the number of bytes to be read. - To exit and output any fatal error messages the new write - function should call png_error(png_ptr, "Error msg"). */ -void PNGAPI -png_set_read_fn(png_structp png_ptr, png_voidp io_ptr, - png_rw_ptr read_data_fn) -{ - if(png_ptr == NULL) return; - png_ptr->io_ptr = io_ptr; - -#if !defined(PNG_NO_STDIO) - if (read_data_fn != NULL) - png_ptr->read_data_fn = read_data_fn; - else - png_ptr->read_data_fn = png_default_read_data; -#else - png_ptr->read_data_fn = read_data_fn; -#endif - - /* It is an error to write to a read device */ - if (png_ptr->write_data_fn != NULL) - { - png_ptr->write_data_fn = NULL; - png_warning(png_ptr, - "It's an error to set both read_data_fn and write_data_fn in the "); - png_warning(png_ptr, - "same structure. Resetting write_data_fn to NULL."); - } - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) - png_ptr->output_flush_fn = NULL; -#endif -} -#endif /* PNG_READ_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/pngrtran.c b/irrlicht-1.6/source/Irrlicht/libpng/pngrtran.c deleted file mode 100644 index 87de5b517..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/pngrtran.c +++ /dev/null @@ -1,4247 +0,0 @@ - -/* pngrtran.c - transforms the data in a row for PNG readers - * - * Last changed in libpng 1.2.15 January 5, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This file contains functions optionally called by an application - * in order to tell libpng how to handle data when reading a PNG. - * Transformations that are used in both reading and writing are - * in pngtrans.c. - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_READ_SUPPORTED) - -/* Set the action on getting a CRC error for an ancillary or critical chunk. */ -void PNGAPI -png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action) -{ - png_debug(1, "in png_set_crc_action\n"); - /* Tell libpng how we react to CRC errors in critical chunks */ - if(png_ptr == NULL) return; - switch (crit_action) - { - case PNG_CRC_NO_CHANGE: /* leave setting as is */ - break; - case PNG_CRC_WARN_USE: /* warn/use data */ - png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; - png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE; - break; - case PNG_CRC_QUIET_USE: /* quiet/use data */ - png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; - png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE | - PNG_FLAG_CRC_CRITICAL_IGNORE; - break; - case PNG_CRC_WARN_DISCARD: /* not a valid action for critical data */ - png_warning(png_ptr, "Can't discard critical data on CRC error."); - case PNG_CRC_ERROR_QUIT: /* error/quit */ - case PNG_CRC_DEFAULT: - default: - png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; - break; - } - - switch (ancil_action) - { - case PNG_CRC_NO_CHANGE: /* leave setting as is */ - break; - case PNG_CRC_WARN_USE: /* warn/use data */ - png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; - png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE; - break; - case PNG_CRC_QUIET_USE: /* quiet/use data */ - png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; - png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE | - PNG_FLAG_CRC_ANCILLARY_NOWARN; - break; - case PNG_CRC_ERROR_QUIT: /* error/quit */ - png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; - png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_NOWARN; - break; - case PNG_CRC_WARN_DISCARD: /* warn/discard data */ - case PNG_CRC_DEFAULT: - default: - png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; - break; - } -} - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ - defined(PNG_FLOATING_POINT_SUPPORTED) -/* handle alpha and tRNS via a background color */ -void PNGAPI -png_set_background(png_structp png_ptr, - png_color_16p background_color, int background_gamma_code, - int need_expand, double background_gamma) -{ - png_debug(1, "in png_set_background\n"); - if(png_ptr == NULL) return; - if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN) - { - png_warning(png_ptr, "Application must supply a known background gamma"); - return; - } - - png_ptr->transformations |= PNG_BACKGROUND; - png_memcpy(&(png_ptr->background), background_color, - png_sizeof(png_color_16)); - png_ptr->background_gamma = (float)background_gamma; - png_ptr->background_gamma_type = (png_byte)(background_gamma_code); - png_ptr->transformations |= (need_expand ? PNG_BACKGROUND_EXPAND : 0); -} -#endif - -#if defined(PNG_READ_16_TO_8_SUPPORTED) -/* strip 16 bit depth files to 8 bit depth */ -void PNGAPI -png_set_strip_16(png_structp png_ptr) -{ - png_debug(1, "in png_set_strip_16\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= PNG_16_TO_8; -} -#endif - -#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) -void PNGAPI -png_set_strip_alpha(png_structp png_ptr) -{ - png_debug(1, "in png_set_strip_alpha\n"); - if(png_ptr == NULL) return; - png_ptr->flags |= PNG_FLAG_STRIP_ALPHA; -} -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) -/* Dither file to 8 bit. Supply a palette, the current number - * of elements in the palette, the maximum number of elements - * allowed, and a histogram if possible. If the current number - * of colors is greater then the maximum number, the palette will be - * modified to fit in the maximum number. "full_dither" indicates - * whether we need a dithering cube set up for RGB images, or if we - * simply are reducing the number of colors in a paletted image. - */ - -typedef struct png_dsort_struct -{ - struct png_dsort_struct FAR * next; - png_byte left; - png_byte right; -} png_dsort; -typedef png_dsort FAR * png_dsortp; -typedef png_dsort FAR * FAR * png_dsortpp; - -void PNGAPI -png_set_dither(png_structp png_ptr, png_colorp palette, - int num_palette, int maximum_colors, png_uint_16p histogram, - int full_dither) -{ - png_debug(1, "in png_set_dither\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= PNG_DITHER; - - if (!full_dither) - { - int i; - - png_ptr->dither_index = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * png_sizeof (png_byte))); - for (i = 0; i < num_palette; i++) - png_ptr->dither_index[i] = (png_byte)i; - } - - if (num_palette > maximum_colors) - { - if (histogram != NULL) - { - /* This is easy enough, just throw out the least used colors. - Perhaps not the best solution, but good enough. */ - - int i; - - /* initialize an array to sort colors */ - png_ptr->dither_sort = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * png_sizeof (png_byte))); - - /* initialize the dither_sort array */ - for (i = 0; i < num_palette; i++) - png_ptr->dither_sort[i] = (png_byte)i; - - /* Find the least used palette entries by starting a - bubble sort, and running it until we have sorted - out enough colors. Note that we don't care about - sorting all the colors, just finding which are - least used. */ - - for (i = num_palette - 1; i >= maximum_colors; i--) - { - int done; /* to stop early if the list is pre-sorted */ - int j; - - done = 1; - for (j = 0; j < i; j++) - { - if (histogram[png_ptr->dither_sort[j]] - < histogram[png_ptr->dither_sort[j + 1]]) - { - png_byte t; - - t = png_ptr->dither_sort[j]; - png_ptr->dither_sort[j] = png_ptr->dither_sort[j + 1]; - png_ptr->dither_sort[j + 1] = t; - done = 0; - } - } - if (done) - break; - } - - /* swap the palette around, and set up a table, if necessary */ - if (full_dither) - { - int j = num_palette; - - /* put all the useful colors within the max, but don't - move the others */ - for (i = 0; i < maximum_colors; i++) - { - if ((int)png_ptr->dither_sort[i] >= maximum_colors) - { - do - j--; - while ((int)png_ptr->dither_sort[j] >= maximum_colors); - palette[i] = palette[j]; - } - } - } - else - { - int j = num_palette; - - /* move all the used colors inside the max limit, and - develop a translation table */ - for (i = 0; i < maximum_colors; i++) - { - /* only move the colors we need to */ - if ((int)png_ptr->dither_sort[i] >= maximum_colors) - { - png_color tmp_color; - - do - j--; - while ((int)png_ptr->dither_sort[j] >= maximum_colors); - - tmp_color = palette[j]; - palette[j] = palette[i]; - palette[i] = tmp_color; - /* indicate where the color went */ - png_ptr->dither_index[j] = (png_byte)i; - png_ptr->dither_index[i] = (png_byte)j; - } - } - - /* find closest color for those colors we are not using */ - for (i = 0; i < num_palette; i++) - { - if ((int)png_ptr->dither_index[i] >= maximum_colors) - { - int min_d, k, min_k, d_index; - - /* find the closest color to one we threw out */ - d_index = png_ptr->dither_index[i]; - min_d = PNG_COLOR_DIST(palette[d_index], palette[0]); - for (k = 1, min_k = 0; k < maximum_colors; k++) - { - int d; - - d = PNG_COLOR_DIST(palette[d_index], palette[k]); - - if (d < min_d) - { - min_d = d; - min_k = k; - } - } - /* point to closest color */ - png_ptr->dither_index[i] = (png_byte)min_k; - } - } - } - png_free(png_ptr, png_ptr->dither_sort); - png_ptr->dither_sort=NULL; - } - else - { - /* This is much harder to do simply (and quickly). Perhaps - we need to go through a median cut routine, but those - don't always behave themselves with only a few colors - as input. So we will just find the closest two colors, - and throw out one of them (chosen somewhat randomly). - [We don't understand this at all, so if someone wants to - work on improving it, be our guest - AED, GRP] - */ - int i; - int max_d; - int num_new_palette; - png_dsortp t; - png_dsortpp hash; - - t=NULL; - - /* initialize palette index arrays */ - png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * png_sizeof (png_byte))); - png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * png_sizeof (png_byte))); - - /* initialize the sort array */ - for (i = 0; i < num_palette; i++) - { - png_ptr->index_to_palette[i] = (png_byte)i; - png_ptr->palette_to_index[i] = (png_byte)i; - } - - hash = (png_dsortpp)png_malloc(png_ptr, (png_uint_32)(769 * - png_sizeof (png_dsortp))); - for (i = 0; i < 769; i++) - hash[i] = NULL; -/* png_memset(hash, 0, 769 * png_sizeof (png_dsortp)); */ - - num_new_palette = num_palette; - - /* initial wild guess at how far apart the farthest pixel - pair we will be eliminating will be. Larger - numbers mean more areas will be allocated, Smaller - numbers run the risk of not saving enough data, and - having to do this all over again. - - I have not done extensive checking on this number. - */ - max_d = 96; - - while (num_new_palette > maximum_colors) - { - for (i = 0; i < num_new_palette - 1; i++) - { - int j; - - for (j = i + 1; j < num_new_palette; j++) - { - int d; - - d = PNG_COLOR_DIST(palette[i], palette[j]); - - if (d <= max_d) - { - - t = (png_dsortp)png_malloc_warn(png_ptr, - (png_uint_32)(png_sizeof(png_dsort))); - if (t == NULL) - break; - t->next = hash[d]; - t->left = (png_byte)i; - t->right = (png_byte)j; - hash[d] = t; - } - } - if (t == NULL) - break; - } - - if (t != NULL) - for (i = 0; i <= max_d; i++) - { - if (hash[i] != NULL) - { - png_dsortp p; - - for (p = hash[i]; p; p = p->next) - { - if ((int)png_ptr->index_to_palette[p->left] - < num_new_palette && - (int)png_ptr->index_to_palette[p->right] - < num_new_palette) - { - int j, next_j; - - if (num_new_palette & 0x01) - { - j = p->left; - next_j = p->right; - } - else - { - j = p->right; - next_j = p->left; - } - - num_new_palette--; - palette[png_ptr->index_to_palette[j]] - = palette[num_new_palette]; - if (!full_dither) - { - int k; - - for (k = 0; k < num_palette; k++) - { - if (png_ptr->dither_index[k] == - png_ptr->index_to_palette[j]) - png_ptr->dither_index[k] = - png_ptr->index_to_palette[next_j]; - if ((int)png_ptr->dither_index[k] == - num_new_palette) - png_ptr->dither_index[k] = - png_ptr->index_to_palette[j]; - } - } - - png_ptr->index_to_palette[png_ptr->palette_to_index - [num_new_palette]] = png_ptr->index_to_palette[j]; - png_ptr->palette_to_index[png_ptr->index_to_palette[j]] - = png_ptr->palette_to_index[num_new_palette]; - - png_ptr->index_to_palette[j] = (png_byte)num_new_palette; - png_ptr->palette_to_index[num_new_palette] = (png_byte)j; - } - if (num_new_palette <= maximum_colors) - break; - } - if (num_new_palette <= maximum_colors) - break; - } - } - - for (i = 0; i < 769; i++) - { - if (hash[i] != NULL) - { - png_dsortp p = hash[i]; - while (p) - { - t = p->next; - png_free(png_ptr, p); - p = t; - } - } - hash[i] = 0; - } - max_d += 96; - } - png_free(png_ptr, hash); - png_free(png_ptr, png_ptr->palette_to_index); - png_free(png_ptr, png_ptr->index_to_palette); - png_ptr->palette_to_index=NULL; - png_ptr->index_to_palette=NULL; - } - num_palette = maximum_colors; - } - if (png_ptr->palette == NULL) - { - png_ptr->palette = palette; - } - png_ptr->num_palette = (png_uint_16)num_palette; - - if (full_dither) - { - int i; - png_bytep distance; - int total_bits = PNG_DITHER_RED_BITS + PNG_DITHER_GREEN_BITS + - PNG_DITHER_BLUE_BITS; - int num_red = (1 << PNG_DITHER_RED_BITS); - int num_green = (1 << PNG_DITHER_GREEN_BITS); - int num_blue = (1 << PNG_DITHER_BLUE_BITS); - png_size_t num_entries = ((png_size_t)1 << total_bits); - - png_ptr->palette_lookup = (png_bytep )png_malloc(png_ptr, - (png_uint_32)(num_entries * png_sizeof (png_byte))); - - png_memset(png_ptr->palette_lookup, 0, num_entries * - png_sizeof (png_byte)); - - distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries * - png_sizeof(png_byte))); - - png_memset(distance, 0xff, num_entries * png_sizeof(png_byte)); - - for (i = 0; i < num_palette; i++) - { - int ir, ig, ib; - int r = (palette[i].red >> (8 - PNG_DITHER_RED_BITS)); - int g = (palette[i].green >> (8 - PNG_DITHER_GREEN_BITS)); - int b = (palette[i].blue >> (8 - PNG_DITHER_BLUE_BITS)); - - for (ir = 0; ir < num_red; ir++) - { - /* int dr = abs(ir - r); */ - int dr = ((ir > r) ? ir - r : r - ir); - int index_r = (ir << (PNG_DITHER_BLUE_BITS + PNG_DITHER_GREEN_BITS)); - - for (ig = 0; ig < num_green; ig++) - { - /* int dg = abs(ig - g); */ - int dg = ((ig > g) ? ig - g : g - ig); - int dt = dr + dg; - int dm = ((dr > dg) ? dr : dg); - int index_g = index_r | (ig << PNG_DITHER_BLUE_BITS); - - for (ib = 0; ib < num_blue; ib++) - { - int d_index = index_g | ib; - /* int db = abs(ib - b); */ - int db = ((ib > b) ? ib - b : b - ib); - int dmax = ((dm > db) ? dm : db); - int d = dmax + dt + db; - - if (d < (int)distance[d_index]) - { - distance[d_index] = (png_byte)d; - png_ptr->palette_lookup[d_index] = (png_byte)i; - } - } - } - } - } - - png_free(png_ptr, distance); - } -} -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) -/* Transform the image from the file_gamma to the screen_gamma. We - * only do transformations on images where the file_gamma and screen_gamma - * are not close reciprocals, otherwise it slows things down slightly, and - * also needlessly introduces small errors. - * - * We will turn off gamma transformation later if no semitransparent entries - * are present in the tRNS array for palette images. We can't do it here - * because we don't necessarily have the tRNS chunk yet. - */ -void PNGAPI -png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma) -{ - png_debug(1, "in png_set_gamma\n"); - if(png_ptr == NULL) return; - if ((fabs(scrn_gamma * file_gamma - 1.0) > PNG_GAMMA_THRESHOLD) || - (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) || - (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)) - png_ptr->transformations |= PNG_GAMMA; - png_ptr->gamma = (float)file_gamma; - png_ptr->screen_gamma = (float)scrn_gamma; -} -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) -/* Expand paletted images to RGB, expand grayscale images of - * less than 8-bit depth to 8-bit depth, and expand tRNS chunks - * to alpha channels. - */ -void PNGAPI -png_set_expand(png_structp png_ptr) -{ - png_debug(1, "in png_set_expand\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); -} - -/* GRR 19990627: the following three functions currently are identical - * to png_set_expand(). However, it is entirely reasonable that someone - * might wish to expand an indexed image to RGB but *not* expand a single, - * fully transparent palette entry to a full alpha channel--perhaps instead - * convert tRNS to the grayscale/RGB format (16-bit RGB value), or replace - * the transparent color with a particular RGB value, or drop tRNS entirely. - * IOW, a future version of the library may make the transformations flag - * a bit more fine-grained, with separate bits for each of these three - * functions. - * - * More to the point, these functions make it obvious what libpng will be - * doing, whereas "expand" can (and does) mean any number of things. - * - * GRP 20060307: In libpng-1.4.0, png_set_gray_1_2_4_to_8() was modified - * to expand only the sample depth but not to expand the tRNS to alpha. - */ - -/* Expand paletted images to RGB. */ -void PNGAPI -png_set_palette_to_rgb(png_structp png_ptr) -{ - png_debug(1, "in png_set_palette_to_rgb\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); -} - -#if !defined(PNG_1_0_X) -/* Expand grayscale images of less than 8-bit depth to 8 bits. */ -void PNGAPI -png_set_expand_gray_1_2_4_to_8(png_structp png_ptr) -{ - png_debug(1, "in png_set_expand_gray_1_2_4_to_8\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= PNG_EXPAND; -} -#endif - -#if defined(PNG_1_0_X) || defined(PNG_1_2_X) -/* Expand grayscale images of less than 8-bit depth to 8 bits. */ -/* Deprecated as of libpng-1.2.9 */ -void PNGAPI -png_set_gray_1_2_4_to_8(png_structp png_ptr) -{ - png_debug(1, "in png_set_gray_1_2_4_to_8\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); -} -#endif - - -/* Expand tRNS chunks to alpha channels. */ -void PNGAPI -png_set_tRNS_to_alpha(png_structp png_ptr) -{ - png_debug(1, "in png_set_expand\n"); - png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); -} -#endif /* defined(PNG_READ_EXPAND_SUPPORTED) */ - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) -void PNGAPI -png_set_gray_to_rgb(png_structp png_ptr) -{ - png_debug(1, "in png_set_gray_to_rgb\n"); - png_ptr->transformations |= PNG_GRAY_TO_RGB; -} -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) -#if defined(PNG_FLOATING_POINT_SUPPORTED) -/* Convert a RGB image to a grayscale of the same width. This allows us, - * for example, to convert a 24 bpp RGB image into an 8 bpp grayscale image. - */ - -void PNGAPI -png_set_rgb_to_gray(png_structp png_ptr, int error_action, double red, - double green) -{ - int red_fixed = (int)((float)red*100000.0 + 0.5); - int green_fixed = (int)((float)green*100000.0 + 0.5); - if(png_ptr == NULL) return; - png_set_rgb_to_gray_fixed(png_ptr, error_action, red_fixed, green_fixed); -} -#endif - -void PNGAPI -png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action, - png_fixed_point red, png_fixed_point green) -{ - png_debug(1, "in png_set_rgb_to_gray\n"); - if(png_ptr == NULL) return; - switch(error_action) - { - case 1: png_ptr->transformations |= PNG_RGB_TO_GRAY; - break; - case 2: png_ptr->transformations |= PNG_RGB_TO_GRAY_WARN; - break; - case 3: png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR; - } - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) -#if defined(PNG_READ_EXPAND_SUPPORTED) - png_ptr->transformations |= PNG_EXPAND; -#else - { - png_warning(png_ptr, "Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED."); - png_ptr->transformations &= ~PNG_RGB_TO_GRAY; - } -#endif - { - png_uint_16 red_int, green_int; - if(red < 0 || green < 0) - { - red_int = 6968; /* .212671 * 32768 + .5 */ - green_int = 23434; /* .715160 * 32768 + .5 */ - } - else if(red + green < 100000L) - { - red_int = (png_uint_16)(((png_uint_32)red*32768L)/100000L); - green_int = (png_uint_16)(((png_uint_32)green*32768L)/100000L); - } - else - { - png_warning(png_ptr, "ignoring out of range rgb_to_gray coefficients"); - red_int = 6968; - green_int = 23434; - } - png_ptr->rgb_to_gray_red_coeff = red_int; - png_ptr->rgb_to_gray_green_coeff = green_int; - png_ptr->rgb_to_gray_blue_coeff = (png_uint_16)(32768-red_int-green_int); - } -} -#endif - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -void PNGAPI -png_set_read_user_transform_fn(png_structp png_ptr, png_user_transform_ptr - read_user_transform_fn) -{ - png_debug(1, "in png_set_read_user_transform_fn\n"); - if(png_ptr == NULL) return; -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - png_ptr->transformations |= PNG_USER_TRANSFORM; - png_ptr->read_user_transform_fn = read_user_transform_fn; -#endif -#ifdef PNG_LEGACY_SUPPORTED - if(read_user_transform_fn) - png_warning(png_ptr, - "This version of libpng does not support user transforms"); -#endif -} -#endif - -/* Initialize everything needed for the read. This includes modifying - * the palette. - */ -void /* PRIVATE */ -png_init_read_transformations(png_structp png_ptr) -{ - png_debug(1, "in png_init_read_transformations\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if(png_ptr != NULL) -#endif - { -#if defined(PNG_READ_BACKGROUND_SUPPORTED) || defined(PNG_READ_SHIFT_SUPPORTED) \ - || defined(PNG_READ_GAMMA_SUPPORTED) - int color_type = png_ptr->color_type; -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED) - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) - /* Detect gray background and attempt to enable optimization - * for gray --> RGB case */ - /* Note: if PNG_BACKGROUND_EXPAND is set and color_type is either RGB or - * RGB_ALPHA (in which case need_expand is superfluous anyway), the - * background color might actually be gray yet not be flagged as such. - * This is not a problem for the current code, which uses - * PNG_BACKGROUND_IS_GRAY only to decide when to do the - * png_do_gray_to_rgb() transformation. - */ - if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) && - !(color_type & PNG_COLOR_MASK_COLOR)) - { - png_ptr->mode |= PNG_BACKGROUND_IS_GRAY; - } else if ((png_ptr->transformations & PNG_BACKGROUND) && - !(png_ptr->transformations & PNG_BACKGROUND_EXPAND) && - (png_ptr->transformations & PNG_GRAY_TO_RGB) && - png_ptr->background.red == png_ptr->background.green && - png_ptr->background.red == png_ptr->background.blue) - { - png_ptr->mode |= PNG_BACKGROUND_IS_GRAY; - png_ptr->background.gray = png_ptr->background.red; - } -#endif - - if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) && - (png_ptr->transformations & PNG_EXPAND)) - { - if (!(color_type & PNG_COLOR_MASK_COLOR)) /* i.e., GRAY or GRAY_ALPHA */ - { - /* expand background and tRNS chunks */ - switch (png_ptr->bit_depth) - { - case 1: - png_ptr->background.gray *= (png_uint_16)0xff; - png_ptr->background.red = png_ptr->background.green - = png_ptr->background.blue = png_ptr->background.gray; - if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) - { - png_ptr->trans_values.gray *= (png_uint_16)0xff; - png_ptr->trans_values.red = png_ptr->trans_values.green - = png_ptr->trans_values.blue = png_ptr->trans_values.gray; - } - break; - case 2: - png_ptr->background.gray *= (png_uint_16)0x55; - png_ptr->background.red = png_ptr->background.green - = png_ptr->background.blue = png_ptr->background.gray; - if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) - { - png_ptr->trans_values.gray *= (png_uint_16)0x55; - png_ptr->trans_values.red = png_ptr->trans_values.green - = png_ptr->trans_values.blue = png_ptr->trans_values.gray; - } - break; - case 4: - png_ptr->background.gray *= (png_uint_16)0x11; - png_ptr->background.red = png_ptr->background.green - = png_ptr->background.blue = png_ptr->background.gray; - if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) - { - png_ptr->trans_values.gray *= (png_uint_16)0x11; - png_ptr->trans_values.red = png_ptr->trans_values.green - = png_ptr->trans_values.blue = png_ptr->trans_values.gray; - } - break; - case 8: - case 16: - png_ptr->background.red = png_ptr->background.green - = png_ptr->background.blue = png_ptr->background.gray; - break; - } - } - else if (color_type == PNG_COLOR_TYPE_PALETTE) - { - png_ptr->background.red = - png_ptr->palette[png_ptr->background.index].red; - png_ptr->background.green = - png_ptr->palette[png_ptr->background.index].green; - png_ptr->background.blue = - png_ptr->palette[png_ptr->background.index].blue; - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_ALPHA) - { -#if defined(PNG_READ_EXPAND_SUPPORTED) - if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) -#endif - { - /* invert the alpha channel (in tRNS) unless the pixels are - going to be expanded, in which case leave it for later */ - int i,istop; - istop=(int)png_ptr->num_trans; - for (i=0; i<istop; i++) - png_ptr->trans[i] = (png_byte)(255 - png_ptr->trans[i]); - } - } -#endif - - } - } -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED) - png_ptr->background_1 = png_ptr->background; -#endif -#if defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) - - if ((color_type == PNG_COLOR_TYPE_PALETTE && png_ptr->num_trans != 0) - && (fabs(png_ptr->screen_gamma * png_ptr->gamma - 1.0) - < PNG_GAMMA_THRESHOLD)) - { - int i,k; - k=0; - for (i=0; i<png_ptr->num_trans; i++) - { - if (png_ptr->trans[i] != 0 && png_ptr->trans[i] != 0xff) - k=1; /* partial transparency is present */ - } - if (k == 0) - png_ptr->transformations &= (~PNG_GAMMA); - } - - if ((png_ptr->transformations & (PNG_GAMMA | PNG_RGB_TO_GRAY)) && - png_ptr->gamma != 0.0) - { - png_build_gamma_table(png_ptr); -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->transformations & PNG_BACKGROUND) - { - if (color_type == PNG_COLOR_TYPE_PALETTE) - { - /* could skip if no transparency and - */ - png_color back, back_1; - png_colorp palette = png_ptr->palette; - int num_palette = png_ptr->num_palette; - int i; - if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_FILE) - { - back.red = png_ptr->gamma_table[png_ptr->background.red]; - back.green = png_ptr->gamma_table[png_ptr->background.green]; - back.blue = png_ptr->gamma_table[png_ptr->background.blue]; - - back_1.red = png_ptr->gamma_to_1[png_ptr->background.red]; - back_1.green = png_ptr->gamma_to_1[png_ptr->background.green]; - back_1.blue = png_ptr->gamma_to_1[png_ptr->background.blue]; - } - else - { - double g, gs; - - switch (png_ptr->background_gamma_type) - { - case PNG_BACKGROUND_GAMMA_SCREEN: - g = (png_ptr->screen_gamma); - gs = 1.0; - break; - case PNG_BACKGROUND_GAMMA_FILE: - g = 1.0 / (png_ptr->gamma); - gs = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); - break; - case PNG_BACKGROUND_GAMMA_UNIQUE: - g = 1.0 / (png_ptr->background_gamma); - gs = 1.0 / (png_ptr->background_gamma * - png_ptr->screen_gamma); - break; - default: - g = 1.0; /* back_1 */ - gs = 1.0; /* back */ - } - - if ( fabs(gs - 1.0) < PNG_GAMMA_THRESHOLD) - { - back.red = (png_byte)png_ptr->background.red; - back.green = (png_byte)png_ptr->background.green; - back.blue = (png_byte)png_ptr->background.blue; - } - else - { - back.red = (png_byte)(pow( - (double)png_ptr->background.red/255, gs) * 255.0 + .5); - back.green = (png_byte)(pow( - (double)png_ptr->background.green/255, gs) * 255.0 + .5); - back.blue = (png_byte)(pow( - (double)png_ptr->background.blue/255, gs) * 255.0 + .5); - } - - back_1.red = (png_byte)(pow( - (double)png_ptr->background.red/255, g) * 255.0 + .5); - back_1.green = (png_byte)(pow( - (double)png_ptr->background.green/255, g) * 255.0 + .5); - back_1.blue = (png_byte)(pow( - (double)png_ptr->background.blue/255, g) * 255.0 + .5); - } - for (i = 0; i < num_palette; i++) - { - if (i < (int)png_ptr->num_trans && png_ptr->trans[i] != 0xff) - { - if (png_ptr->trans[i] == 0) - { - palette[i] = back; - } - else /* if (png_ptr->trans[i] != 0xff) */ - { - png_byte v, w; - - v = png_ptr->gamma_to_1[palette[i].red]; - png_composite(w, v, png_ptr->trans[i], back_1.red); - palette[i].red = png_ptr->gamma_from_1[w]; - - v = png_ptr->gamma_to_1[palette[i].green]; - png_composite(w, v, png_ptr->trans[i], back_1.green); - palette[i].green = png_ptr->gamma_from_1[w]; - - v = png_ptr->gamma_to_1[palette[i].blue]; - png_composite(w, v, png_ptr->trans[i], back_1.blue); - palette[i].blue = png_ptr->gamma_from_1[w]; - } - } - else - { - palette[i].red = png_ptr->gamma_table[palette[i].red]; - palette[i].green = png_ptr->gamma_table[palette[i].green]; - palette[i].blue = png_ptr->gamma_table[palette[i].blue]; - } - } - } - /* if (png_ptr->background_gamma_type!=PNG_BACKGROUND_GAMMA_UNKNOWN) */ - else - /* color_type != PNG_COLOR_TYPE_PALETTE */ - { - double m = (double)(((png_uint_32)1 << png_ptr->bit_depth) - 1); - double g = 1.0; - double gs = 1.0; - - switch (png_ptr->background_gamma_type) - { - case PNG_BACKGROUND_GAMMA_SCREEN: - g = (png_ptr->screen_gamma); - gs = 1.0; - break; - case PNG_BACKGROUND_GAMMA_FILE: - g = 1.0 / (png_ptr->gamma); - gs = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); - break; - case PNG_BACKGROUND_GAMMA_UNIQUE: - g = 1.0 / (png_ptr->background_gamma); - gs = 1.0 / (png_ptr->background_gamma * - png_ptr->screen_gamma); - break; - } - - png_ptr->background_1.gray = (png_uint_16)(pow( - (double)png_ptr->background.gray / m, g) * m + .5); - png_ptr->background.gray = (png_uint_16)(pow( - (double)png_ptr->background.gray / m, gs) * m + .5); - - if ((png_ptr->background.red != png_ptr->background.green) || - (png_ptr->background.red != png_ptr->background.blue) || - (png_ptr->background.red != png_ptr->background.gray)) - { - /* RGB or RGBA with color background */ - png_ptr->background_1.red = (png_uint_16)(pow( - (double)png_ptr->background.red / m, g) * m + .5); - png_ptr->background_1.green = (png_uint_16)(pow( - (double)png_ptr->background.green / m, g) * m + .5); - png_ptr->background_1.blue = (png_uint_16)(pow( - (double)png_ptr->background.blue / m, g) * m + .5); - png_ptr->background.red = (png_uint_16)(pow( - (double)png_ptr->background.red / m, gs) * m + .5); - png_ptr->background.green = (png_uint_16)(pow( - (double)png_ptr->background.green / m, gs) * m + .5); - png_ptr->background.blue = (png_uint_16)(pow( - (double)png_ptr->background.blue / m, gs) * m + .5); - } - else - { - /* GRAY, GRAY ALPHA, RGB, or RGBA with gray background */ - png_ptr->background_1.red = png_ptr->background_1.green - = png_ptr->background_1.blue = png_ptr->background_1.gray; - png_ptr->background.red = png_ptr->background.green - = png_ptr->background.blue = png_ptr->background.gray; - } - } - } - else - /* transformation does not include PNG_BACKGROUND */ -#endif /* PNG_READ_BACKGROUND_SUPPORTED */ - if (color_type == PNG_COLOR_TYPE_PALETTE) - { - png_colorp palette = png_ptr->palette; - int num_palette = png_ptr->num_palette; - int i; - - for (i = 0; i < num_palette; i++) - { - palette[i].red = png_ptr->gamma_table[palette[i].red]; - palette[i].green = png_ptr->gamma_table[palette[i].green]; - palette[i].blue = png_ptr->gamma_table[palette[i].blue]; - } - } - } -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - else -#endif -#endif /* PNG_READ_GAMMA_SUPPORTED && PNG_FLOATING_POINT_SUPPORTED */ -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - /* No GAMMA transformation */ - if ((png_ptr->transformations & PNG_BACKGROUND) && - (color_type == PNG_COLOR_TYPE_PALETTE)) - { - int i; - int istop = (int)png_ptr->num_trans; - png_color back; - png_colorp palette = png_ptr->palette; - - back.red = (png_byte)png_ptr->background.red; - back.green = (png_byte)png_ptr->background.green; - back.blue = (png_byte)png_ptr->background.blue; - - for (i = 0; i < istop; i++) - { - if (png_ptr->trans[i] == 0) - { - palette[i] = back; - } - else if (png_ptr->trans[i] != 0xff) - { - /* The png_composite() macro is defined in png.h */ - png_composite(palette[i].red, palette[i].red, - png_ptr->trans[i], back.red); - png_composite(palette[i].green, palette[i].green, - png_ptr->trans[i], back.green); - png_composite(palette[i].blue, palette[i].blue, - png_ptr->trans[i], back.blue); - } - } - } -#endif /* PNG_READ_BACKGROUND_SUPPORTED */ - -#if defined(PNG_READ_SHIFT_SUPPORTED) - if ((png_ptr->transformations & PNG_SHIFT) && - (color_type == PNG_COLOR_TYPE_PALETTE)) - { - png_uint_16 i; - png_uint_16 istop = png_ptr->num_palette; - int sr = 8 - png_ptr->sig_bit.red; - int sg = 8 - png_ptr->sig_bit.green; - int sb = 8 - png_ptr->sig_bit.blue; - - if (sr < 0 || sr > 8) - sr = 0; - if (sg < 0 || sg > 8) - sg = 0; - if (sb < 0 || sb > 8) - sb = 0; - for (i = 0; i < istop; i++) - { - png_ptr->palette[i].red >>= sr; - png_ptr->palette[i].green >>= sg; - png_ptr->palette[i].blue >>= sb; - } - } -#endif /* PNG_READ_SHIFT_SUPPORTED */ - } -#if !defined(PNG_READ_GAMMA_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) \ - && !defined(PNG_READ_BACKGROUND_SUPPORTED) - if(png_ptr) - return; -#endif -} - -/* Modify the info structure to reflect the transformations. The - * info should be updated so a PNG file could be written with it, - * assuming the transformations result in valid PNG data. - */ -void /* PRIVATE */ -png_read_transform_info(png_structp png_ptr, png_infop info_ptr) -{ - png_debug(1, "in png_read_transform_info\n"); -#if defined(PNG_READ_EXPAND_SUPPORTED) - if (png_ptr->transformations & PNG_EXPAND) - { - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - if (png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND_tRNS)) - info_ptr->color_type = PNG_COLOR_TYPE_RGB_ALPHA; - else - info_ptr->color_type = PNG_COLOR_TYPE_RGB; - info_ptr->bit_depth = 8; - info_ptr->num_trans = 0; - } - else - { - if (png_ptr->num_trans) - { - if (png_ptr->transformations & PNG_EXPAND_tRNS) - info_ptr->color_type |= PNG_COLOR_MASK_ALPHA; - else - info_ptr->color_type |= PNG_COLOR_MASK_COLOR; - } - if (info_ptr->bit_depth < 8) - info_ptr->bit_depth = 8; - info_ptr->num_trans = 0; - } - } -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->transformations & PNG_BACKGROUND) - { - info_ptr->color_type &= ~PNG_COLOR_MASK_ALPHA; - info_ptr->num_trans = 0; - info_ptr->background = png_ptr->background; - } -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (png_ptr->transformations & PNG_GAMMA) - { -#ifdef PNG_FLOATING_POINT_SUPPORTED - info_ptr->gamma = png_ptr->gamma; -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - info_ptr->int_gamma = png_ptr->int_gamma; -#endif - } -#endif - -#if defined(PNG_READ_16_TO_8_SUPPORTED) - if ((png_ptr->transformations & PNG_16_TO_8) && (info_ptr->bit_depth == 16)) - info_ptr->bit_depth = 8; -#endif - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) - if (png_ptr->transformations & PNG_GRAY_TO_RGB) - info_ptr->color_type |= PNG_COLOR_MASK_COLOR; -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - if (png_ptr->transformations & PNG_RGB_TO_GRAY) - info_ptr->color_type &= ~PNG_COLOR_MASK_COLOR; -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) - if (png_ptr->transformations & PNG_DITHER) - { - if (((info_ptr->color_type == PNG_COLOR_TYPE_RGB) || - (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)) && - png_ptr->palette_lookup && info_ptr->bit_depth == 8) - { - info_ptr->color_type = PNG_COLOR_TYPE_PALETTE; - } - } -#endif - -#if defined(PNG_READ_PACK_SUPPORTED) - if ((png_ptr->transformations & PNG_PACK) && (info_ptr->bit_depth < 8)) - info_ptr->bit_depth = 8; -#endif - - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - info_ptr->channels = 1; - else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR) - info_ptr->channels = 3; - else - info_ptr->channels = 1; - -#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) - if (png_ptr->flags & PNG_FLAG_STRIP_ALPHA) - info_ptr->color_type &= ~PNG_COLOR_MASK_ALPHA; -#endif - - if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA) - info_ptr->channels++; - -#if defined(PNG_READ_FILLER_SUPPORTED) - /* STRIP_ALPHA and FILLER allowed: MASK_ALPHA bit stripped above */ - if ((png_ptr->transformations & PNG_FILLER) && - ((info_ptr->color_type == PNG_COLOR_TYPE_RGB) || - (info_ptr->color_type == PNG_COLOR_TYPE_GRAY))) - { - info_ptr->channels++; - /* if adding a true alpha channel not just filler */ -#if !defined(PNG_1_0_X) - if (png_ptr->transformations & PNG_ADD_ALPHA) - info_ptr->color_type |= PNG_COLOR_MASK_ALPHA; -#endif - } -#endif - -#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) && \ -defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - if(png_ptr->transformations & PNG_USER_TRANSFORM) - { - if(info_ptr->bit_depth < png_ptr->user_transform_depth) - info_ptr->bit_depth = png_ptr->user_transform_depth; - if(info_ptr->channels < png_ptr->user_transform_channels) - info_ptr->channels = png_ptr->user_transform_channels; - } -#endif - - info_ptr->pixel_depth = (png_byte)(info_ptr->channels * - info_ptr->bit_depth); - - info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth,info_ptr->width); - -#if !defined(PNG_READ_EXPAND_SUPPORTED) - if(png_ptr) - return; -#endif -} - -/* Transform the row. The order of transformations is significant, - * and is very touchy. If you add a transformation, take care to - * decide how it fits in with the other transformations here. - */ -void /* PRIVATE */ -png_do_read_transformations(png_structp png_ptr) -{ - png_debug(1, "in png_do_read_transformations\n"); -#if !defined(PNG_USELESS_TESTS_SUPPORTED) - if (png_ptr->row_buf == NULL) - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char msg[50]; - - sprintf(msg, "NULL row buffer for row %ld, pass %d", png_ptr->row_number, - png_ptr->pass); - png_error(png_ptr, msg); -#else - png_error(png_ptr, "NULL row buffer"); -#endif - } -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) - if (png_ptr->transformations & PNG_EXPAND) - { - if (png_ptr->row_info.color_type == PNG_COLOR_TYPE_PALETTE) - { - png_do_expand_palette(&(png_ptr->row_info), png_ptr->row_buf + 1, - png_ptr->palette, png_ptr->trans, png_ptr->num_trans); - } - else - { - if (png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND_tRNS)) - png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1, - &(png_ptr->trans_values)); - else - png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1, - NULL); - } - } -#endif - -#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) - if (png_ptr->flags & PNG_FLAG_STRIP_ALPHA) - png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, - PNG_FLAG_FILLER_AFTER | (png_ptr->flags & PNG_FLAG_STRIP_ALPHA)); -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - if (png_ptr->transformations & PNG_RGB_TO_GRAY) - { - int rgb_error = - png_do_rgb_to_gray(png_ptr, &(png_ptr->row_info), png_ptr->row_buf + 1); - if(rgb_error) - { - png_ptr->rgb_to_gray_status=1; - if(png_ptr->transformations & PNG_RGB_TO_GRAY_WARN) - png_warning(png_ptr, "png_do_rgb_to_gray found nongray pixel"); - if(png_ptr->transformations & PNG_RGB_TO_GRAY_ERR) - png_error(png_ptr, "png_do_rgb_to_gray found nongray pixel"); - } - } -#endif - -/* -From Andreas Dilger e-mail to png-implement, 26 March 1998: - - In most cases, the "simple transparency" should be done prior to doing - gray-to-RGB, or you will have to test 3x as many bytes to check if a - pixel is transparent. You would also need to make sure that the - transparency information is upgraded to RGB. - - To summarize, the current flow is: - - Gray + simple transparency -> compare 1 or 2 gray bytes and composite - with background "in place" if transparent, - convert to RGB if necessary - - Gray + alpha -> composite with gray background and remove alpha bytes, - convert to RGB if necessary - - To support RGB backgrounds for gray images we need: - - Gray + simple transparency -> convert to RGB + simple transparency, compare - 3 or 6 bytes and composite with background - "in place" if transparent (3x compare/pixel - compared to doing composite with gray bkgrnd) - - Gray + alpha -> convert to RGB + alpha, composite with background and - remove alpha bytes (3x float operations/pixel - compared with composite on gray background) - - Greg's change will do this. The reason it wasn't done before is for - performance, as this increases the per-pixel operations. If we would check - in advance if the background was gray or RGB, and position the gray-to-RGB - transform appropriately, then it would save a lot of work/time. - */ - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) - /* if gray -> RGB, do so now only if background is non-gray; else do later - * for performance reasons */ - if ((png_ptr->transformations & PNG_GRAY_TO_RGB) && - !(png_ptr->mode & PNG_BACKGROUND_IS_GRAY)) - png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - if ((png_ptr->transformations & PNG_BACKGROUND) && - ((png_ptr->num_trans != 0 ) || - (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) - png_do_background(&(png_ptr->row_info), png_ptr->row_buf + 1, - &(png_ptr->trans_values), &(png_ptr->background) -#if defined(PNG_READ_GAMMA_SUPPORTED) - , &(png_ptr->background_1), - png_ptr->gamma_table, png_ptr->gamma_from_1, - png_ptr->gamma_to_1, png_ptr->gamma_16_table, - png_ptr->gamma_16_from_1, png_ptr->gamma_16_to_1, - png_ptr->gamma_shift -#endif -); -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) - if ((png_ptr->transformations & PNG_GAMMA) && -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - !((png_ptr->transformations & PNG_BACKGROUND) && - ((png_ptr->num_trans != 0) || - (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) && -#endif - (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)) - png_do_gamma(&(png_ptr->row_info), png_ptr->row_buf + 1, - png_ptr->gamma_table, png_ptr->gamma_16_table, - png_ptr->gamma_shift); -#endif - -#if defined(PNG_READ_16_TO_8_SUPPORTED) - if (png_ptr->transformations & PNG_16_TO_8) - png_do_chop(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) - if (png_ptr->transformations & PNG_DITHER) - { - png_do_dither((png_row_infop)&(png_ptr->row_info), png_ptr->row_buf + 1, - png_ptr->palette_lookup, png_ptr->dither_index); - if(png_ptr->row_info.rowbytes == (png_uint_32)0) - png_error(png_ptr, "png_do_dither returned rowbytes=0"); - } -#endif - -#if defined(PNG_READ_INVERT_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_MONO) - png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) - if (png_ptr->transformations & PNG_SHIFT) - png_do_unshift(&(png_ptr->row_info), png_ptr->row_buf + 1, - &(png_ptr->shift)); -#endif - -#if defined(PNG_READ_PACK_SUPPORTED) - if (png_ptr->transformations & PNG_PACK) - png_do_unpack(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_BGR_SUPPORTED) - if (png_ptr->transformations & PNG_BGR) - png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) - /* if gray -> RGB, do so now only if we did not do so above */ - if ((png_ptr->transformations & PNG_GRAY_TO_RGB) && - (png_ptr->mode & PNG_BACKGROUND_IS_GRAY)) - png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_FILLER_SUPPORTED) - if (png_ptr->transformations & PNG_FILLER) - png_do_read_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, - (png_uint_32)png_ptr->filler, png_ptr->flags); -#endif - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_ALPHA) - png_do_read_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) - if (png_ptr->transformations & PNG_SWAP_ALPHA) - png_do_read_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_SWAP_SUPPORTED) - if (png_ptr->transformations & PNG_SWAP_BYTES) - png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - if (png_ptr->transformations & PNG_USER_TRANSFORM) - { - if(png_ptr->read_user_transform_fn != NULL) - (*(png_ptr->read_user_transform_fn)) /* user read transform function */ - (png_ptr, /* png_ptr */ - &(png_ptr->row_info), /* row_info: */ - /* png_uint_32 width; width of row */ - /* png_uint_32 rowbytes; number of bytes in row */ - /* png_byte color_type; color type of pixels */ - /* png_byte bit_depth; bit depth of samples */ - /* png_byte channels; number of channels (1-4) */ - /* png_byte pixel_depth; bits per pixel (depth*channels) */ - png_ptr->row_buf + 1); /* start of pixel data for row */ -#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) - if(png_ptr->user_transform_depth) - png_ptr->row_info.bit_depth = png_ptr->user_transform_depth; - if(png_ptr->user_transform_channels) - png_ptr->row_info.channels = png_ptr->user_transform_channels; -#endif - png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth * - png_ptr->row_info.channels); - png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth, - png_ptr->row_info.width); - } -#endif - -} - -#if defined(PNG_READ_PACK_SUPPORTED) -/* Unpack pixels of 1, 2, or 4 bits per pixel into 1 byte per pixel, - * without changing the actual values. Thus, if you had a row with - * a bit depth of 1, you would end up with bytes that only contained - * the numbers 0 or 1. If you would rather they contain 0 and 255, use - * png_do_shift() after this. - */ -void /* PRIVATE */ -png_do_unpack(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_unpack\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL && row_info->bit_depth < 8) -#else - if (row_info->bit_depth < 8) -#endif - { - png_uint_32 i; - png_uint_32 row_width=row_info->width; - - switch (row_info->bit_depth) - { - case 1: - { - png_bytep sp = row + (png_size_t)((row_width - 1) >> 3); - png_bytep dp = row + (png_size_t)row_width - 1; - png_uint_32 shift = 7 - (int)((row_width + 7) & 0x07); - for (i = 0; i < row_width; i++) - { - *dp = (png_byte)((*sp >> shift) & 0x01); - if (shift == 7) - { - shift = 0; - sp--; - } - else - shift++; - - dp--; - } - break; - } - case 2: - { - - png_bytep sp = row + (png_size_t)((row_width - 1) >> 2); - png_bytep dp = row + (png_size_t)row_width - 1; - png_uint_32 shift = (int)((3 - ((row_width + 3) & 0x03)) << 1); - for (i = 0; i < row_width; i++) - { - *dp = (png_byte)((*sp >> shift) & 0x03); - if (shift == 6) - { - shift = 0; - sp--; - } - else - shift += 2; - - dp--; - } - break; - } - case 4: - { - png_bytep sp = row + (png_size_t)((row_width - 1) >> 1); - png_bytep dp = row + (png_size_t)row_width - 1; - png_uint_32 shift = (int)((1 - ((row_width + 1) & 0x01)) << 2); - for (i = 0; i < row_width; i++) - { - *dp = (png_byte)((*sp >> shift) & 0x0f); - if (shift == 4) - { - shift = 0; - sp--; - } - else - shift = 4; - - dp--; - } - break; - } - } - row_info->bit_depth = 8; - row_info->pixel_depth = (png_byte)(8 * row_info->channels); - row_info->rowbytes = row_width * row_info->channels; - } -} -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) -/* Reverse the effects of png_do_shift. This routine merely shifts the - * pixels back to their significant bits values. Thus, if you have - * a row of bit depth 8, but only 5 are significant, this will shift - * the values back to 0 through 31. - */ -void /* PRIVATE */ -png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits) -{ - png_debug(1, "in png_do_unshift\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && sig_bits != NULL && -#endif - row_info->color_type != PNG_COLOR_TYPE_PALETTE) - { - int shift[4]; - int channels = 0; - int c; - png_uint_16 value = 0; - png_uint_32 row_width = row_info->width; - - if (row_info->color_type & PNG_COLOR_MASK_COLOR) - { - shift[channels++] = row_info->bit_depth - sig_bits->red; - shift[channels++] = row_info->bit_depth - sig_bits->green; - shift[channels++] = row_info->bit_depth - sig_bits->blue; - } - else - { - shift[channels++] = row_info->bit_depth - sig_bits->gray; - } - if (row_info->color_type & PNG_COLOR_MASK_ALPHA) - { - shift[channels++] = row_info->bit_depth - sig_bits->alpha; - } - - for (c = 0; c < channels; c++) - { - if (shift[c] <= 0) - shift[c] = 0; - else - value = 1; - } - - if (!value) - return; - - switch (row_info->bit_depth) - { - case 2: - { - png_bytep bp; - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - - for (bp = row, i = 0; i < istop; i++) - { - *bp >>= 1; - *bp++ &= 0x55; - } - break; - } - case 4: - { - png_bytep bp = row; - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_byte mask = (png_byte)((((int)0xf0 >> shift[0]) & (int)0xf0) | - (png_byte)((int)0xf >> shift[0])); - - for (i = 0; i < istop; i++) - { - *bp >>= shift[0]; - *bp++ &= mask; - } - break; - } - case 8: - { - png_bytep bp = row; - png_uint_32 i; - png_uint_32 istop = row_width * channels; - - for (i = 0; i < istop; i++) - { - *bp++ >>= shift[i%channels]; - } - break; - } - case 16: - { - png_bytep bp = row; - png_uint_32 i; - png_uint_32 istop = channels * row_width; - - for (i = 0; i < istop; i++) - { - value = (png_uint_16)((*bp << 8) + *(bp + 1)); - value >>= shift[i%channels]; - *bp++ = (png_byte)(value >> 8); - *bp++ = (png_byte)(value & 0xff); - } - break; - } - } - } -} -#endif - -#if defined(PNG_READ_16_TO_8_SUPPORTED) -/* chop rows of bit depth 16 down to 8 */ -void /* PRIVATE */ -png_do_chop(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_chop\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL && row_info->bit_depth == 16) -#else - if (row_info->bit_depth == 16) -#endif - { - png_bytep sp = row; - png_bytep dp = row; - png_uint_32 i; - png_uint_32 istop = row_info->width * row_info->channels; - - for (i = 0; i<istop; i++, sp += 2, dp++) - { -#if defined(PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED) - /* This does a more accurate scaling of the 16-bit color - * value, rather than a simple low-byte truncation. - * - * What the ideal calculation should be: - * *dp = (((((png_uint_32)(*sp) << 8) | - * (png_uint_32)(*(sp + 1))) * 255 + 127) / (png_uint_32)65535L; - * - * GRR: no, I think this is what it really should be: - * *dp = (((((png_uint_32)(*sp) << 8) | - * (png_uint_32)(*(sp + 1))) + 128L) / (png_uint_32)257L; - * - * GRR: here's the exact calculation with shifts: - * temp = (((png_uint_32)(*sp) << 8) | (png_uint_32)(*(sp + 1))) + 128L; - * *dp = (temp - (temp >> 8)) >> 8; - * - * Approximate calculation with shift/add instead of multiply/divide: - * *dp = ((((png_uint_32)(*sp) << 8) | - * (png_uint_32)((int)(*(sp + 1)) - *sp)) + 128) >> 8; - * - * What we actually do to avoid extra shifting and conversion: - */ - - *dp = *sp + ((((int)(*(sp + 1)) - *sp) > 128) ? 1 : 0); -#else - /* Simply discard the low order byte */ - *dp = *sp; -#endif - } - row_info->bit_depth = 8; - row_info->pixel_depth = (png_byte)(8 * row_info->channels); - row_info->rowbytes = row_info->width * row_info->channels; - } -} -#endif - -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) -void /* PRIVATE */ -png_do_read_swap_alpha(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_read_swap_alpha\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif - { - png_uint_32 row_width = row_info->width; - if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - /* This converts from RGBA to ARGB */ - if (row_info->bit_depth == 8) - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_byte save; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - save = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = save; - } - } - /* This converts from RRGGBBAA to AARRGGBB */ - else - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_byte save[2]; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - save[0] = *(--sp); - save[1] = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = save[0]; - *(--dp) = save[1]; - } - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - { - /* This converts from GA to AG */ - if (row_info->bit_depth == 8) - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_byte save; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - save = *(--sp); - *(--dp) = *(--sp); - *(--dp) = save; - } - } - /* This converts from GGAA to AAGG */ - else - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_byte save[2]; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - save[0] = *(--sp); - save[1] = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = save[0]; - *(--dp) = save[1]; - } - } - } - } -} -#endif - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) -void /* PRIVATE */ -png_do_read_invert_alpha(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_read_invert_alpha\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif - { - png_uint_32 row_width = row_info->width; - if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - /* This inverts the alpha channel in RGBA */ - if (row_info->bit_depth == 8) - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - *(--dp) = (png_byte)(255 - *(--sp)); - -/* This does nothing: - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - We can replace it with: -*/ - sp-=3; - dp=sp; - } - } - /* This inverts the alpha channel in RRGGBBAA */ - else - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - *(--dp) = (png_byte)(255 - *(--sp)); - *(--dp) = (png_byte)(255 - *(--sp)); - -/* This does nothing: - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - We can replace it with: -*/ - sp-=6; - dp=sp; - } - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - { - /* This inverts the alpha channel in GA */ - if (row_info->bit_depth == 8) - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - *(--dp) = (png_byte)(255 - *(--sp)); - *(--dp) = *(--sp); - } - } - /* This inverts the alpha channel in GGAA */ - else - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - *(--dp) = (png_byte)(255 - *(--sp)); - *(--dp) = (png_byte)(255 - *(--sp)); -/* - *(--dp) = *(--sp); - *(--dp) = *(--sp); -*/ - sp-=2; - dp=sp; - } - } - } - } -} -#endif - -#if defined(PNG_READ_FILLER_SUPPORTED) -/* Add filler channel if we have RGB color */ -void /* PRIVATE */ -png_do_read_filler(png_row_infop row_info, png_bytep row, - png_uint_32 filler, png_uint_32 flags) -{ - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - png_byte hi_filler = (png_byte)((filler>>8) & 0xff); - png_byte lo_filler = (png_byte)(filler & 0xff); - - png_debug(1, "in png_do_read_filler\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - row_info->color_type == PNG_COLOR_TYPE_GRAY) - { - if(row_info->bit_depth == 8) - { - /* This changes the data from G to GX */ - if (flags & PNG_FLAG_FILLER_AFTER) - { - png_bytep sp = row + (png_size_t)row_width; - png_bytep dp = sp + (png_size_t)row_width; - for (i = 1; i < row_width; i++) - { - *(--dp) = lo_filler; - *(--dp) = *(--sp); - } - *(--dp) = lo_filler; - row_info->channels = 2; - row_info->pixel_depth = 16; - row_info->rowbytes = row_width * 2; - } - /* This changes the data from G to XG */ - else - { - png_bytep sp = row + (png_size_t)row_width; - png_bytep dp = sp + (png_size_t)row_width; - for (i = 0; i < row_width; i++) - { - *(--dp) = *(--sp); - *(--dp) = lo_filler; - } - row_info->channels = 2; - row_info->pixel_depth = 16; - row_info->rowbytes = row_width * 2; - } - } - else if(row_info->bit_depth == 16) - { - /* This changes the data from GG to GGXX */ - if (flags & PNG_FLAG_FILLER_AFTER) - { - png_bytep sp = row + (png_size_t)row_width * 2; - png_bytep dp = sp + (png_size_t)row_width * 2; - for (i = 1; i < row_width; i++) - { - *(--dp) = hi_filler; - *(--dp) = lo_filler; - *(--dp) = *(--sp); - *(--dp) = *(--sp); - } - *(--dp) = hi_filler; - *(--dp) = lo_filler; - row_info->channels = 2; - row_info->pixel_depth = 32; - row_info->rowbytes = row_width * 4; - } - /* This changes the data from GG to XXGG */ - else - { - png_bytep sp = row + (png_size_t)row_width * 2; - png_bytep dp = sp + (png_size_t)row_width * 2; - for (i = 0; i < row_width; i++) - { - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = hi_filler; - *(--dp) = lo_filler; - } - row_info->channels = 2; - row_info->pixel_depth = 32; - row_info->rowbytes = row_width * 4; - } - } - } /* COLOR_TYPE == GRAY */ - else if (row_info->color_type == PNG_COLOR_TYPE_RGB) - { - if(row_info->bit_depth == 8) - { - /* This changes the data from RGB to RGBX */ - if (flags & PNG_FLAG_FILLER_AFTER) - { - png_bytep sp = row + (png_size_t)row_width * 3; - png_bytep dp = sp + (png_size_t)row_width; - for (i = 1; i < row_width; i++) - { - *(--dp) = lo_filler; - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - } - *(--dp) = lo_filler; - row_info->channels = 4; - row_info->pixel_depth = 32; - row_info->rowbytes = row_width * 4; - } - /* This changes the data from RGB to XRGB */ - else - { - png_bytep sp = row + (png_size_t)row_width * 3; - png_bytep dp = sp + (png_size_t)row_width; - for (i = 0; i < row_width; i++) - { - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = lo_filler; - } - row_info->channels = 4; - row_info->pixel_depth = 32; - row_info->rowbytes = row_width * 4; - } - } - else if(row_info->bit_depth == 16) - { - /* This changes the data from RRGGBB to RRGGBBXX */ - if (flags & PNG_FLAG_FILLER_AFTER) - { - png_bytep sp = row + (png_size_t)row_width * 6; - png_bytep dp = sp + (png_size_t)row_width * 2; - for (i = 1; i < row_width; i++) - { - *(--dp) = hi_filler; - *(--dp) = lo_filler; - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - } - *(--dp) = hi_filler; - *(--dp) = lo_filler; - row_info->channels = 4; - row_info->pixel_depth = 64; - row_info->rowbytes = row_width * 8; - } - /* This changes the data from RRGGBB to XXRRGGBB */ - else - { - png_bytep sp = row + (png_size_t)row_width * 6; - png_bytep dp = sp + (png_size_t)row_width * 2; - for (i = 0; i < row_width; i++) - { - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = hi_filler; - *(--dp) = lo_filler; - } - row_info->channels = 4; - row_info->pixel_depth = 64; - row_info->rowbytes = row_width * 8; - } - } - } /* COLOR_TYPE == RGB */ -} -#endif - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) -/* expand grayscale files to RGB, with or without alpha */ -void /* PRIVATE */ -png_do_gray_to_rgb(png_row_infop row_info, png_bytep row) -{ - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - png_debug(1, "in png_do_gray_to_rgb\n"); - if (row_info->bit_depth >= 8 && -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - !(row_info->color_type & PNG_COLOR_MASK_COLOR)) - { - if (row_info->color_type == PNG_COLOR_TYPE_GRAY) - { - if (row_info->bit_depth == 8) - { - png_bytep sp = row + (png_size_t)row_width - 1; - png_bytep dp = sp + (png_size_t)row_width * 2; - for (i = 0; i < row_width; i++) - { - *(dp--) = *sp; - *(dp--) = *sp; - *(dp--) = *(sp--); - } - } - else - { - png_bytep sp = row + (png_size_t)row_width * 2 - 1; - png_bytep dp = sp + (png_size_t)row_width * 4; - for (i = 0; i < row_width; i++) - { - *(dp--) = *sp; - *(dp--) = *(sp - 1); - *(dp--) = *sp; - *(dp--) = *(sp - 1); - *(dp--) = *(sp--); - *(dp--) = *(sp--); - } - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - { - if (row_info->bit_depth == 8) - { - png_bytep sp = row + (png_size_t)row_width * 2 - 1; - png_bytep dp = sp + (png_size_t)row_width * 2; - for (i = 0; i < row_width; i++) - { - *(dp--) = *(sp--); - *(dp--) = *sp; - *(dp--) = *sp; - *(dp--) = *(sp--); - } - } - else - { - png_bytep sp = row + (png_size_t)row_width * 4 - 1; - png_bytep dp = sp + (png_size_t)row_width * 4; - for (i = 0; i < row_width; i++) - { - *(dp--) = *(sp--); - *(dp--) = *(sp--); - *(dp--) = *sp; - *(dp--) = *(sp - 1); - *(dp--) = *sp; - *(dp--) = *(sp - 1); - *(dp--) = *(sp--); - *(dp--) = *(sp--); - } - } - } - row_info->channels += (png_byte)2; - row_info->color_type |= PNG_COLOR_MASK_COLOR; - row_info->pixel_depth = (png_byte)(row_info->channels * - row_info->bit_depth); - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); - } -} -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) -/* reduce RGB files to grayscale, with or without alpha - * using the equation given in Poynton's ColorFAQ at - * <http://www.inforamp.net/~poynton/> - * Copyright (c) 1998-01-04 Charles Poynton poynton at inforamp.net - * - * Y = 0.212671 * R + 0.715160 * G + 0.072169 * B - * - * We approximate this with - * - * Y = 0.21268 * R + 0.7151 * G + 0.07217 * B - * - * which can be expressed with integers as - * - * Y = (6969 * R + 23434 * G + 2365 * B)/32768 - * - * The calculation is to be done in a linear colorspace. - * - * Other integer coefficents can be used via png_set_rgb_to_gray(). - */ -int /* PRIVATE */ -png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row) - -{ - png_uint_32 i; - - png_uint_32 row_width = row_info->width; - int rgb_error = 0; - - png_debug(1, "in png_do_rgb_to_gray\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - (row_info->color_type & PNG_COLOR_MASK_COLOR)) - { - png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff; - png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff; - png_uint_32 bc = png_ptr->rgb_to_gray_blue_coeff; - - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - { - if (row_info->bit_depth == 8) - { -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL) - { - png_bytep sp = row; - png_bytep dp = row; - - for (i = 0; i < row_width; i++) - { - png_byte red = png_ptr->gamma_to_1[*(sp++)]; - png_byte green = png_ptr->gamma_to_1[*(sp++)]; - png_byte blue = png_ptr->gamma_to_1[*(sp++)]; - if(red != green || red != blue) - { - rgb_error |= 1; - *(dp++) = png_ptr->gamma_from_1[ - (rc*red+gc*green+bc*blue)>>15]; - } - else - *(dp++) = *(sp-1); - } - } - else -#endif - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_byte red = *(sp++); - png_byte green = *(sp++); - png_byte blue = *(sp++); - if(red != green || red != blue) - { - rgb_error |= 1; - *(dp++) = (png_byte)((rc*red+gc*green+bc*blue)>>15); - } - else - *(dp++) = *(sp-1); - } - } - } - - else /* RGB bit_depth == 16 */ - { -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->gamma_16_to_1 != NULL && - png_ptr->gamma_16_from_1 != NULL) - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 red, green, blue, w; - - red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - - if(red == green && red == blue) - w = red; - else - { - png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff) >> - png_ptr->gamma_shift][red>>8]; - png_uint_16 green_1 = png_ptr->gamma_16_to_1[(green&0xff) >> - png_ptr->gamma_shift][green>>8]; - png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >> - png_ptr->gamma_shift][blue>>8]; - png_uint_16 gray16 = (png_uint_16)((rc*red_1 + gc*green_1 - + bc*blue_1)>>15); - w = png_ptr->gamma_16_from_1[(gray16&0xff) >> - png_ptr->gamma_shift][gray16 >> 8]; - rgb_error |= 1; - } - - *(dp++) = (png_byte)((w>>8) & 0xff); - *(dp++) = (png_byte)(w & 0xff); - } - } - else -#endif - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 red, green, blue, gray16; - - red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - - if(red != green || red != blue) - rgb_error |= 1; - gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15); - *(dp++) = (png_byte)((gray16>>8) & 0xff); - *(dp++) = (png_byte)(gray16 & 0xff); - } - } - } - } - if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - if (row_info->bit_depth == 8) - { -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL) - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_byte red = png_ptr->gamma_to_1[*(sp++)]; - png_byte green = png_ptr->gamma_to_1[*(sp++)]; - png_byte blue = png_ptr->gamma_to_1[*(sp++)]; - if(red != green || red != blue) - rgb_error |= 1; - *(dp++) = png_ptr->gamma_from_1 - [(rc*red + gc*green + bc*blue)>>15]; - *(dp++) = *(sp++); /* alpha */ - } - } - else -#endif - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_byte red = *(sp++); - png_byte green = *(sp++); - png_byte blue = *(sp++); - if(red != green || red != blue) - rgb_error |= 1; - *(dp++) = (png_byte)((rc*red + gc*green + bc*blue)>>15); - *(dp++) = *(sp++); /* alpha */ - } - } - } - else /* RGBA bit_depth == 16 */ - { -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->gamma_16_to_1 != NULL && - png_ptr->gamma_16_from_1 != NULL) - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 red, green, blue, w; - - red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - - if(red == green && red == blue) - w = red; - else - { - png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff) >> - png_ptr->gamma_shift][red>>8]; - png_uint_16 green_1 = png_ptr->gamma_16_to_1[(green&0xff) >> - png_ptr->gamma_shift][green>>8]; - png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >> - png_ptr->gamma_shift][blue>>8]; - png_uint_16 gray16 = (png_uint_16)((rc * red_1 - + gc * green_1 + bc * blue_1)>>15); - w = png_ptr->gamma_16_from_1[(gray16&0xff) >> - png_ptr->gamma_shift][gray16 >> 8]; - rgb_error |= 1; - } - - *(dp++) = (png_byte)((w>>8) & 0xff); - *(dp++) = (png_byte)(w & 0xff); - *(dp++) = *(sp++); /* alpha */ - *(dp++) = *(sp++); - } - } - else -#endif - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 red, green, blue, gray16; - red = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; - green = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; - blue = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; - if(red != green || red != blue) - rgb_error |= 1; - gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15); - *(dp++) = (png_byte)((gray16>>8) & 0xff); - *(dp++) = (png_byte)(gray16 & 0xff); - *(dp++) = *(sp++); /* alpha */ - *(dp++) = *(sp++); - } - } - } - } - row_info->channels -= (png_byte)2; - row_info->color_type &= ~PNG_COLOR_MASK_COLOR; - row_info->pixel_depth = (png_byte)(row_info->channels * - row_info->bit_depth); - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); - } - return rgb_error; -} -#endif - -/* Build a grayscale palette. Palette is assumed to be 1 << bit_depth - * large of png_color. This lets grayscale images be treated as - * paletted. Most useful for gamma correction and simplification - * of code. - */ -void PNGAPI -png_build_grayscale_palette(int bit_depth, png_colorp palette) -{ - int num_palette; - int color_inc; - int i; - int v; - - png_debug(1, "in png_do_build_grayscale_palette\n"); - if (palette == NULL) - return; - - switch (bit_depth) - { - case 1: - num_palette = 2; - color_inc = 0xff; - break; - case 2: - num_palette = 4; - color_inc = 0x55; - break; - case 4: - num_palette = 16; - color_inc = 0x11; - break; - case 8: - num_palette = 256; - color_inc = 1; - break; - default: - num_palette = 0; - color_inc = 0; - break; - } - - for (i = 0, v = 0; i < num_palette; i++, v += color_inc) - { - palette[i].red = (png_byte)v; - palette[i].green = (png_byte)v; - palette[i].blue = (png_byte)v; - } -} - -/* This function is currently unused. Do we really need it? */ -#if defined(PNG_READ_DITHER_SUPPORTED) && defined(PNG_CORRECT_PALETTE_SUPPORTED) -void /* PRIVATE */ -png_correct_palette(png_structp png_ptr, png_colorp palette, - int num_palette) -{ - png_debug(1, "in png_correct_palette\n"); -#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ - defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) - if (png_ptr->transformations & (PNG_GAMMA | PNG_BACKGROUND)) - { - png_color back, back_1; - - if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_FILE) - { - back.red = png_ptr->gamma_table[png_ptr->background.red]; - back.green = png_ptr->gamma_table[png_ptr->background.green]; - back.blue = png_ptr->gamma_table[png_ptr->background.blue]; - - back_1.red = png_ptr->gamma_to_1[png_ptr->background.red]; - back_1.green = png_ptr->gamma_to_1[png_ptr->background.green]; - back_1.blue = png_ptr->gamma_to_1[png_ptr->background.blue]; - } - else - { - double g; - - g = 1.0 / (png_ptr->background_gamma * png_ptr->screen_gamma); - - if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_SCREEN || - fabs(g - 1.0) < PNG_GAMMA_THRESHOLD) - { - back.red = png_ptr->background.red; - back.green = png_ptr->background.green; - back.blue = png_ptr->background.blue; - } - else - { - back.red = - (png_byte)(pow((double)png_ptr->background.red/255, g) * - 255.0 + 0.5); - back.green = - (png_byte)(pow((double)png_ptr->background.green/255, g) * - 255.0 + 0.5); - back.blue = - (png_byte)(pow((double)png_ptr->background.blue/255, g) * - 255.0 + 0.5); - } - - g = 1.0 / png_ptr->background_gamma; - - back_1.red = - (png_byte)(pow((double)png_ptr->background.red/255, g) * - 255.0 + 0.5); - back_1.green = - (png_byte)(pow((double)png_ptr->background.green/255, g) * - 255.0 + 0.5); - back_1.blue = - (png_byte)(pow((double)png_ptr->background.blue/255, g) * - 255.0 + 0.5); - } - - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - png_uint_32 i; - - for (i = 0; i < (png_uint_32)num_palette; i++) - { - if (i < png_ptr->num_trans && png_ptr->trans[i] == 0) - { - palette[i] = back; - } - else if (i < png_ptr->num_trans && png_ptr->trans[i] != 0xff) - { - png_byte v, w; - - v = png_ptr->gamma_to_1[png_ptr->palette[i].red]; - png_composite(w, v, png_ptr->trans[i], back_1.red); - palette[i].red = png_ptr->gamma_from_1[w]; - - v = png_ptr->gamma_to_1[png_ptr->palette[i].green]; - png_composite(w, v, png_ptr->trans[i], back_1.green); - palette[i].green = png_ptr->gamma_from_1[w]; - - v = png_ptr->gamma_to_1[png_ptr->palette[i].blue]; - png_composite(w, v, png_ptr->trans[i], back_1.blue); - palette[i].blue = png_ptr->gamma_from_1[w]; - } - else - { - palette[i].red = png_ptr->gamma_table[palette[i].red]; - palette[i].green = png_ptr->gamma_table[palette[i].green]; - palette[i].blue = png_ptr->gamma_table[palette[i].blue]; - } - } - } - else - { - int i; - - for (i = 0; i < num_palette; i++) - { - if (palette[i].red == (png_byte)png_ptr->trans_values.gray) - { - palette[i] = back; - } - else - { - palette[i].red = png_ptr->gamma_table[palette[i].red]; - palette[i].green = png_ptr->gamma_table[palette[i].green]; - palette[i].blue = png_ptr->gamma_table[palette[i].blue]; - } - } - } - } - else -#endif -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (png_ptr->transformations & PNG_GAMMA) - { - int i; - - for (i = 0; i < num_palette; i++) - { - palette[i].red = png_ptr->gamma_table[palette[i].red]; - palette[i].green = png_ptr->gamma_table[palette[i].green]; - palette[i].blue = png_ptr->gamma_table[palette[i].blue]; - } - } -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - else -#endif -#endif -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->transformations & PNG_BACKGROUND) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - png_color back; - - back.red = (png_byte)png_ptr->background.red; - back.green = (png_byte)png_ptr->background.green; - back.blue = (png_byte)png_ptr->background.blue; - - for (i = 0; i < (int)png_ptr->num_trans; i++) - { - if (png_ptr->trans[i] == 0) - { - palette[i].red = back.red; - palette[i].green = back.green; - palette[i].blue = back.blue; - } - else if (png_ptr->trans[i] != 0xff) - { - png_composite(palette[i].red, png_ptr->palette[i].red, - png_ptr->trans[i], back.red); - png_composite(palette[i].green, png_ptr->palette[i].green, - png_ptr->trans[i], back.green); - png_composite(palette[i].blue, png_ptr->palette[i].blue, - png_ptr->trans[i], back.blue); - } - } - } - else /* assume grayscale palette (what else could it be?) */ - { - int i; - - for (i = 0; i < num_palette; i++) - { - if (i == (png_byte)png_ptr->trans_values.gray) - { - palette[i].red = (png_byte)png_ptr->background.red; - palette[i].green = (png_byte)png_ptr->background.green; - palette[i].blue = (png_byte)png_ptr->background.blue; - } - } - } - } -#endif -} -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) -/* Replace any alpha or transparency with the supplied background color. - * "background" is already in the screen gamma, while "background_1" is - * at a gamma of 1.0. Paletted files have already been taken care of. - */ -void /* PRIVATE */ -png_do_background(png_row_infop row_info, png_bytep row, - png_color_16p trans_values, png_color_16p background -#if defined(PNG_READ_GAMMA_SUPPORTED) - , png_color_16p background_1, - png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1, - png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1, - png_uint_16pp gamma_16_to_1, int gamma_shift -#endif - ) -{ - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width=row_info->width; - int shift; - - png_debug(1, "in png_do_background\n"); - if (background != NULL && -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - (!(row_info->color_type & PNG_COLOR_MASK_ALPHA) || - (row_info->color_type != PNG_COLOR_TYPE_PALETTE && trans_values))) - { - switch (row_info->color_type) - { - case PNG_COLOR_TYPE_GRAY: - { - switch (row_info->bit_depth) - { - case 1: - { - sp = row; - shift = 7; - for (i = 0; i < row_width; i++) - { - if ((png_uint_16)((*sp >> shift) & 0x01) - == trans_values->gray) - { - *sp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff); - *sp |= (png_byte)(background->gray << shift); - } - if (!shift) - { - shift = 7; - sp++; - } - else - shift--; - } - break; - } - case 2: - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_table != NULL) - { - sp = row; - shift = 6; - for (i = 0; i < row_width; i++) - { - if ((png_uint_16)((*sp >> shift) & 0x03) - == trans_values->gray) - { - *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); - *sp |= (png_byte)(background->gray << shift); - } - else - { - png_byte p = (png_byte)((*sp >> shift) & 0x03); - png_byte g = (png_byte)((gamma_table [p | (p << 2) | - (p << 4) | (p << 6)] >> 6) & 0x03); - *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); - *sp |= (png_byte)(g << shift); - } - if (!shift) - { - shift = 6; - sp++; - } - else - shift -= 2; - } - } - else -#endif - { - sp = row; - shift = 6; - for (i = 0; i < row_width; i++) - { - if ((png_uint_16)((*sp >> shift) & 0x03) - == trans_values->gray) - { - *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); - *sp |= (png_byte)(background->gray << shift); - } - if (!shift) - { - shift = 6; - sp++; - } - else - shift -= 2; - } - } - break; - } - case 4: - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_table != NULL) - { - sp = row; - shift = 4; - for (i = 0; i < row_width; i++) - { - if ((png_uint_16)((*sp >> shift) & 0x0f) - == trans_values->gray) - { - *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); - *sp |= (png_byte)(background->gray << shift); - } - else - { - png_byte p = (png_byte)((*sp >> shift) & 0x0f); - png_byte g = (png_byte)((gamma_table[p | - (p << 4)] >> 4) & 0x0f); - *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); - *sp |= (png_byte)(g << shift); - } - if (!shift) - { - shift = 4; - sp++; - } - else - shift -= 4; - } - } - else -#endif - { - sp = row; - shift = 4; - for (i = 0; i < row_width; i++) - { - if ((png_uint_16)((*sp >> shift) & 0x0f) - == trans_values->gray) - { - *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); - *sp |= (png_byte)(background->gray << shift); - } - if (!shift) - { - shift = 4; - sp++; - } - else - shift -= 4; - } - } - break; - } - case 8: - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_table != NULL) - { - sp = row; - for (i = 0; i < row_width; i++, sp++) - { - if (*sp == trans_values->gray) - { - *sp = (png_byte)background->gray; - } - else - { - *sp = gamma_table[*sp]; - } - } - } - else -#endif - { - sp = row; - for (i = 0; i < row_width; i++, sp++) - { - if (*sp == trans_values->gray) - { - *sp = (png_byte)background->gray; - } - } - } - break; - } - case 16: - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_16 != NULL) - { - sp = row; - for (i = 0; i < row_width; i++, sp += 2) - { - png_uint_16 v; - - v = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - if (v == trans_values->gray) - { - /* background is already in screen gamma */ - *sp = (png_byte)((background->gray >> 8) & 0xff); - *(sp + 1) = (png_byte)(background->gray & 0xff); - } - else - { - v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - } - } - } - else -#endif - { - sp = row; - for (i = 0; i < row_width; i++, sp += 2) - { - png_uint_16 v; - - v = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - if (v == trans_values->gray) - { - *sp = (png_byte)((background->gray >> 8) & 0xff); - *(sp + 1) = (png_byte)(background->gray & 0xff); - } - } - } - break; - } - } - break; - } - case PNG_COLOR_TYPE_RGB: - { - if (row_info->bit_depth == 8) - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_table != NULL) - { - sp = row; - for (i = 0; i < row_width; i++, sp += 3) - { - if (*sp == trans_values->red && - *(sp + 1) == trans_values->green && - *(sp + 2) == trans_values->blue) - { - *sp = (png_byte)background->red; - *(sp + 1) = (png_byte)background->green; - *(sp + 2) = (png_byte)background->blue; - } - else - { - *sp = gamma_table[*sp]; - *(sp + 1) = gamma_table[*(sp + 1)]; - *(sp + 2) = gamma_table[*(sp + 2)]; - } - } - } - else -#endif - { - sp = row; - for (i = 0; i < row_width; i++, sp += 3) - { - if (*sp == trans_values->red && - *(sp + 1) == trans_values->green && - *(sp + 2) == trans_values->blue) - { - *sp = (png_byte)background->red; - *(sp + 1) = (png_byte)background->green; - *(sp + 2) = (png_byte)background->blue; - } - } - } - } - else /* if (row_info->bit_depth == 16) */ - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_16 != NULL) - { - sp = row; - for (i = 0; i < row_width; i++, sp += 6) - { - png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - png_uint_16 g = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); - png_uint_16 b = (png_uint_16)(((*(sp+4)) << 8) + *(sp+5)); - if (r == trans_values->red && g == trans_values->green && - b == trans_values->blue) - { - /* background is already in screen gamma */ - *sp = (png_byte)((background->red >> 8) & 0xff); - *(sp + 1) = (png_byte)(background->red & 0xff); - *(sp + 2) = (png_byte)((background->green >> 8) & 0xff); - *(sp + 3) = (png_byte)(background->green & 0xff); - *(sp + 4) = (png_byte)((background->blue >> 8) & 0xff); - *(sp + 5) = (png_byte)(background->blue & 0xff); - } - else - { - png_uint_16 v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)]; - *(sp + 2) = (png_byte)((v >> 8) & 0xff); - *(sp + 3) = (png_byte)(v & 0xff); - v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)]; - *(sp + 4) = (png_byte)((v >> 8) & 0xff); - *(sp + 5) = (png_byte)(v & 0xff); - } - } - } - else -#endif - { - sp = row; - for (i = 0; i < row_width; i++, sp += 6) - { - png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp+1)); - png_uint_16 g = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); - png_uint_16 b = (png_uint_16)(((*(sp+4)) << 8) + *(sp+5)); - - if (r == trans_values->red && g == trans_values->green && - b == trans_values->blue) - { - *sp = (png_byte)((background->red >> 8) & 0xff); - *(sp + 1) = (png_byte)(background->red & 0xff); - *(sp + 2) = (png_byte)((background->green >> 8) & 0xff); - *(sp + 3) = (png_byte)(background->green & 0xff); - *(sp + 4) = (png_byte)((background->blue >> 8) & 0xff); - *(sp + 5) = (png_byte)(background->blue & 0xff); - } - } - } - } - break; - } - case PNG_COLOR_TYPE_GRAY_ALPHA: - { - if (row_info->bit_depth == 8) - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_to_1 != NULL && gamma_from_1 != NULL && - gamma_table != NULL) - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 2, dp++) - { - png_uint_16 a = *(sp + 1); - - if (a == 0xff) - { - *dp = gamma_table[*sp]; - } - else if (a == 0) - { - /* background is already in screen gamma */ - *dp = (png_byte)background->gray; - } - else - { - png_byte v, w; - - v = gamma_to_1[*sp]; - png_composite(w, v, a, background_1->gray); - *dp = gamma_from_1[w]; - } - } - } - else -#endif - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 2, dp++) - { - png_byte a = *(sp + 1); - - if (a == 0xff) - { - *dp = *sp; - } -#if defined(PNG_READ_GAMMA_SUPPORTED) - else if (a == 0) - { - *dp = (png_byte)background->gray; - } - else - { - png_composite(*dp, *sp, a, background_1->gray); - } -#else - *dp = (png_byte)background->gray; -#endif - } - } - } - else /* if (png_ptr->bit_depth == 16) */ - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_16 != NULL && gamma_16_from_1 != NULL && - gamma_16_to_1 != NULL) - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 4, dp += 2) - { - png_uint_16 a = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); - - if (a == (png_uint_16)0xffff) - { - png_uint_16 v; - - v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; - *dp = (png_byte)((v >> 8) & 0xff); - *(dp + 1) = (png_byte)(v & 0xff); - } -#if defined(PNG_READ_GAMMA_SUPPORTED) - else if (a == 0) -#else - else -#endif - { - /* background is already in screen gamma */ - *dp = (png_byte)((background->gray >> 8) & 0xff); - *(dp + 1) = (png_byte)(background->gray & 0xff); - } -#if defined(PNG_READ_GAMMA_SUPPORTED) - else - { - png_uint_16 g, v, w; - - g = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp]; - png_composite_16(v, g, a, background_1->gray); - w = gamma_16_from_1[(v&0xff) >> gamma_shift][v >> 8]; - *dp = (png_byte)((w >> 8) & 0xff); - *(dp + 1) = (png_byte)(w & 0xff); - } -#endif - } - } - else -#endif - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 4, dp += 2) - { - png_uint_16 a = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); - if (a == (png_uint_16)0xffff) - { - png_memcpy(dp, sp, 2); - } -#if defined(PNG_READ_GAMMA_SUPPORTED) - else if (a == 0) -#else - else -#endif - { - *dp = (png_byte)((background->gray >> 8) & 0xff); - *(dp + 1) = (png_byte)(background->gray & 0xff); - } -#if defined(PNG_READ_GAMMA_SUPPORTED) - else - { - png_uint_16 g, v; - - g = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - png_composite_16(v, g, a, background_1->gray); - *dp = (png_byte)((v >> 8) & 0xff); - *(dp + 1) = (png_byte)(v & 0xff); - } -#endif - } - } - } - break; - } - case PNG_COLOR_TYPE_RGB_ALPHA: - { - if (row_info->bit_depth == 8) - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_to_1 != NULL && gamma_from_1 != NULL && - gamma_table != NULL) - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 4, dp += 3) - { - png_byte a = *(sp + 3); - - if (a == 0xff) - { - *dp = gamma_table[*sp]; - *(dp + 1) = gamma_table[*(sp + 1)]; - *(dp + 2) = gamma_table[*(sp + 2)]; - } - else if (a == 0) - { - /* background is already in screen gamma */ - *dp = (png_byte)background->red; - *(dp + 1) = (png_byte)background->green; - *(dp + 2) = (png_byte)background->blue; - } - else - { - png_byte v, w; - - v = gamma_to_1[*sp]; - png_composite(w, v, a, background_1->red); - *dp = gamma_from_1[w]; - v = gamma_to_1[*(sp + 1)]; - png_composite(w, v, a, background_1->green); - *(dp + 1) = gamma_from_1[w]; - v = gamma_to_1[*(sp + 2)]; - png_composite(w, v, a, background_1->blue); - *(dp + 2) = gamma_from_1[w]; - } - } - } - else -#endif - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 4, dp += 3) - { - png_byte a = *(sp + 3); - - if (a == 0xff) - { - *dp = *sp; - *(dp + 1) = *(sp + 1); - *(dp + 2) = *(sp + 2); - } - else if (a == 0) - { - *dp = (png_byte)background->red; - *(dp + 1) = (png_byte)background->green; - *(dp + 2) = (png_byte)background->blue; - } - else - { - png_composite(*dp, *sp, a, background->red); - png_composite(*(dp + 1), *(sp + 1), a, - background->green); - png_composite(*(dp + 2), *(sp + 2), a, - background->blue); - } - } - } - } - else /* if (row_info->bit_depth == 16) */ - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_16 != NULL && gamma_16_from_1 != NULL && - gamma_16_to_1 != NULL) - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 8, dp += 6) - { - png_uint_16 a = (png_uint_16)(((png_uint_16)(*(sp + 6)) - << 8) + (png_uint_16)(*(sp + 7))); - if (a == (png_uint_16)0xffff) - { - png_uint_16 v; - - v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; - *dp = (png_byte)((v >> 8) & 0xff); - *(dp + 1) = (png_byte)(v & 0xff); - v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)]; - *(dp + 2) = (png_byte)((v >> 8) & 0xff); - *(dp + 3) = (png_byte)(v & 0xff); - v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)]; - *(dp + 4) = (png_byte)((v >> 8) & 0xff); - *(dp + 5) = (png_byte)(v & 0xff); - } - else if (a == 0) - { - /* background is already in screen gamma */ - *dp = (png_byte)((background->red >> 8) & 0xff); - *(dp + 1) = (png_byte)(background->red & 0xff); - *(dp + 2) = (png_byte)((background->green >> 8) & 0xff); - *(dp + 3) = (png_byte)(background->green & 0xff); - *(dp + 4) = (png_byte)((background->blue >> 8) & 0xff); - *(dp + 5) = (png_byte)(background->blue & 0xff); - } - else - { - png_uint_16 v, w, x; - - v = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp]; - png_composite_16(w, v, a, background_1->red); - x = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8]; - *dp = (png_byte)((x >> 8) & 0xff); - *(dp + 1) = (png_byte)(x & 0xff); - v = gamma_16_to_1[*(sp + 3) >> gamma_shift][*(sp + 2)]; - png_composite_16(w, v, a, background_1->green); - x = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8]; - *(dp + 2) = (png_byte)((x >> 8) & 0xff); - *(dp + 3) = (png_byte)(x & 0xff); - v = gamma_16_to_1[*(sp + 5) >> gamma_shift][*(sp + 4)]; - png_composite_16(w, v, a, background_1->blue); - x = gamma_16_from_1[(w & 0xff) >> gamma_shift][w >> 8]; - *(dp + 4) = (png_byte)((x >> 8) & 0xff); - *(dp + 5) = (png_byte)(x & 0xff); - } - } - } - else -#endif - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 8, dp += 6) - { - png_uint_16 a = (png_uint_16)(((png_uint_16)(*(sp + 6)) - << 8) + (png_uint_16)(*(sp + 7))); - if (a == (png_uint_16)0xffff) - { - png_memcpy(dp, sp, 6); - } - else if (a == 0) - { - *dp = (png_byte)((background->red >> 8) & 0xff); - *(dp + 1) = (png_byte)(background->red & 0xff); - *(dp + 2) = (png_byte)((background->green >> 8) & 0xff); - *(dp + 3) = (png_byte)(background->green & 0xff); - *(dp + 4) = (png_byte)((background->blue >> 8) & 0xff); - *(dp + 5) = (png_byte)(background->blue & 0xff); - } - else - { - png_uint_16 v; - - png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - png_uint_16 g = (png_uint_16)(((*(sp + 2)) << 8) - + *(sp + 3)); - png_uint_16 b = (png_uint_16)(((*(sp + 4)) << 8) - + *(sp + 5)); - - png_composite_16(v, r, a, background->red); - *dp = (png_byte)((v >> 8) & 0xff); - *(dp + 1) = (png_byte)(v & 0xff); - png_composite_16(v, g, a, background->green); - *(dp + 2) = (png_byte)((v >> 8) & 0xff); - *(dp + 3) = (png_byte)(v & 0xff); - png_composite_16(v, b, a, background->blue); - *(dp + 4) = (png_byte)((v >> 8) & 0xff); - *(dp + 5) = (png_byte)(v & 0xff); - } - } - } - } - break; - } - } - - if (row_info->color_type & PNG_COLOR_MASK_ALPHA) - { - row_info->color_type &= ~PNG_COLOR_MASK_ALPHA; - row_info->channels--; - row_info->pixel_depth = (png_byte)(row_info->channels * - row_info->bit_depth); - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); - } - } -} -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) -/* Gamma correct the image, avoiding the alpha channel. Make sure - * you do this after you deal with the transparency issue on grayscale - * or RGB images. If your bit depth is 8, use gamma_table, if it - * is 16, use gamma_16_table and gamma_shift. Build these with - * build_gamma_table(). - */ -void /* PRIVATE */ -png_do_gamma(png_row_infop row_info, png_bytep row, - png_bytep gamma_table, png_uint_16pp gamma_16_table, - int gamma_shift) -{ - png_bytep sp; - png_uint_32 i; - png_uint_32 row_width=row_info->width; - - png_debug(1, "in png_do_gamma\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - ((row_info->bit_depth <= 8 && gamma_table != NULL) || - (row_info->bit_depth == 16 && gamma_16_table != NULL))) - { - switch (row_info->color_type) - { - case PNG_COLOR_TYPE_RGB: - { - if (row_info->bit_depth == 8) - { - sp = row; - for (i = 0; i < row_width; i++) - { - *sp = gamma_table[*sp]; - sp++; - *sp = gamma_table[*sp]; - sp++; - *sp = gamma_table[*sp]; - sp++; - } - } - else /* if (row_info->bit_depth == 16) */ - { - sp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 v; - - v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - } - } - break; - } - case PNG_COLOR_TYPE_RGB_ALPHA: - { - if (row_info->bit_depth == 8) - { - sp = row; - for (i = 0; i < row_width; i++) - { - *sp = gamma_table[*sp]; - sp++; - *sp = gamma_table[*sp]; - sp++; - *sp = gamma_table[*sp]; - sp++; - sp++; - } - } - else /* if (row_info->bit_depth == 16) */ - { - sp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 4; - } - } - break; - } - case PNG_COLOR_TYPE_GRAY_ALPHA: - { - if (row_info->bit_depth == 8) - { - sp = row; - for (i = 0; i < row_width; i++) - { - *sp = gamma_table[*sp]; - sp += 2; - } - } - else /* if (row_info->bit_depth == 16) */ - { - sp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 4; - } - } - break; - } - case PNG_COLOR_TYPE_GRAY: - { - if (row_info->bit_depth == 2) - { - sp = row; - for (i = 0; i < row_width; i += 4) - { - int a = *sp & 0xc0; - int b = *sp & 0x30; - int c = *sp & 0x0c; - int d = *sp & 0x03; - - *sp = (png_byte)( - ((((int)gamma_table[a|(a>>2)|(a>>4)|(a>>6)]) ) & 0xc0)| - ((((int)gamma_table[(b<<2)|b|(b>>2)|(b>>4)])>>2) & 0x30)| - ((((int)gamma_table[(c<<4)|(c<<2)|c|(c>>2)])>>4) & 0x0c)| - ((((int)gamma_table[(d<<6)|(d<<4)|(d<<2)|d])>>6) )); - sp++; - } - } - if (row_info->bit_depth == 4) - { - sp = row; - for (i = 0; i < row_width; i += 2) - { - int msb = *sp & 0xf0; - int lsb = *sp & 0x0f; - - *sp = (png_byte)((((int)gamma_table[msb | (msb >> 4)]) & 0xf0) - | (((int)gamma_table[(lsb << 4) | lsb]) >> 4)); - sp++; - } - } - else if (row_info->bit_depth == 8) - { - sp = row; - for (i = 0; i < row_width; i++) - { - *sp = gamma_table[*sp]; - sp++; - } - } - else if (row_info->bit_depth == 16) - { - sp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - } - } - break; - } - } - } -} -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) -/* Expands a palette row to an RGB or RGBA row depending - * upon whether you supply trans and num_trans. - */ -void /* PRIVATE */ -png_do_expand_palette(png_row_infop row_info, png_bytep row, - png_colorp palette, png_bytep trans, int num_trans) -{ - int shift, value; - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width=row_info->width; - - png_debug(1, "in png_do_expand_palette\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - row_info->color_type == PNG_COLOR_TYPE_PALETTE) - { - if (row_info->bit_depth < 8) - { - switch (row_info->bit_depth) - { - case 1: - { - sp = row + (png_size_t)((row_width - 1) >> 3); - dp = row + (png_size_t)row_width - 1; - shift = 7 - (int)((row_width + 7) & 0x07); - for (i = 0; i < row_width; i++) - { - if ((*sp >> shift) & 0x01) - *dp = 1; - else - *dp = 0; - if (shift == 7) - { - shift = 0; - sp--; - } - else - shift++; - - dp--; - } - break; - } - case 2: - { - sp = row + (png_size_t)((row_width - 1) >> 2); - dp = row + (png_size_t)row_width - 1; - shift = (int)((3 - ((row_width + 3) & 0x03)) << 1); - for (i = 0; i < row_width; i++) - { - value = (*sp >> shift) & 0x03; - *dp = (png_byte)value; - if (shift == 6) - { - shift = 0; - sp--; - } - else - shift += 2; - - dp--; - } - break; - } - case 4: - { - sp = row + (png_size_t)((row_width - 1) >> 1); - dp = row + (png_size_t)row_width - 1; - shift = (int)((row_width & 0x01) << 2); - for (i = 0; i < row_width; i++) - { - value = (*sp >> shift) & 0x0f; - *dp = (png_byte)value; - if (shift == 4) - { - shift = 0; - sp--; - } - else - shift += 4; - - dp--; - } - break; - } - } - row_info->bit_depth = 8; - row_info->pixel_depth = 8; - row_info->rowbytes = row_width; - } - switch (row_info->bit_depth) - { - case 8: - { - if (trans != NULL) - { - sp = row + (png_size_t)row_width - 1; - dp = row + (png_size_t)(row_width << 2) - 1; - - for (i = 0; i < row_width; i++) - { - if ((int)(*sp) >= num_trans) - *dp-- = 0xff; - else - *dp-- = trans[*sp]; - *dp-- = palette[*sp].blue; - *dp-- = palette[*sp].green; - *dp-- = palette[*sp].red; - sp--; - } - row_info->bit_depth = 8; - row_info->pixel_depth = 32; - row_info->rowbytes = row_width * 4; - row_info->color_type = 6; - row_info->channels = 4; - } - else - { - sp = row + (png_size_t)row_width - 1; - dp = row + (png_size_t)(row_width * 3) - 1; - - for (i = 0; i < row_width; i++) - { - *dp-- = palette[*sp].blue; - *dp-- = palette[*sp].green; - *dp-- = palette[*sp].red; - sp--; - } - row_info->bit_depth = 8; - row_info->pixel_depth = 24; - row_info->rowbytes = row_width * 3; - row_info->color_type = 2; - row_info->channels = 3; - } - break; - } - } - } -} - -/* If the bit depth < 8, it is expanded to 8. Also, if the already - * expanded transparency value is supplied, an alpha channel is built. - */ -void /* PRIVATE */ -png_do_expand(png_row_infop row_info, png_bytep row, - png_color_16p trans_value) -{ - int shift, value; - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width=row_info->width; - - png_debug(1, "in png_do_expand\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif - { - if (row_info->color_type == PNG_COLOR_TYPE_GRAY) - { - png_uint_16 gray = (png_uint_16)(trans_value ? trans_value->gray : 0); - - if (row_info->bit_depth < 8) - { - switch (row_info->bit_depth) - { - case 1: - { - gray = (png_uint_16)(gray*0xff); - sp = row + (png_size_t)((row_width - 1) >> 3); - dp = row + (png_size_t)row_width - 1; - shift = 7 - (int)((row_width + 7) & 0x07); - for (i = 0; i < row_width; i++) - { - if ((*sp >> shift) & 0x01) - *dp = 0xff; - else - *dp = 0; - if (shift == 7) - { - shift = 0; - sp--; - } - else - shift++; - - dp--; - } - break; - } - case 2: - { - gray = (png_uint_16)(gray*0x55); - sp = row + (png_size_t)((row_width - 1) >> 2); - dp = row + (png_size_t)row_width - 1; - shift = (int)((3 - ((row_width + 3) & 0x03)) << 1); - for (i = 0; i < row_width; i++) - { - value = (*sp >> shift) & 0x03; - *dp = (png_byte)(value | (value << 2) | (value << 4) | - (value << 6)); - if (shift == 6) - { - shift = 0; - sp--; - } - else - shift += 2; - - dp--; - } - break; - } - case 4: - { - gray = (png_uint_16)(gray*0x11); - sp = row + (png_size_t)((row_width - 1) >> 1); - dp = row + (png_size_t)row_width - 1; - shift = (int)((1 - ((row_width + 1) & 0x01)) << 2); - for (i = 0; i < row_width; i++) - { - value = (*sp >> shift) & 0x0f; - *dp = (png_byte)(value | (value << 4)); - if (shift == 4) - { - shift = 0; - sp--; - } - else - shift = 4; - - dp--; - } - break; - } - } - row_info->bit_depth = 8; - row_info->pixel_depth = 8; - row_info->rowbytes = row_width; - } - - if (trans_value != NULL) - { - if (row_info->bit_depth == 8) - { - sp = row + (png_size_t)row_width - 1; - dp = row + (png_size_t)(row_width << 1) - 1; - for (i = 0; i < row_width; i++) - { - if (*sp == gray) - *dp-- = 0; - else - *dp-- = 0xff; - *dp-- = *sp--; - } - } - else if (row_info->bit_depth == 16) - { - sp = row + row_info->rowbytes - 1; - dp = row + (row_info->rowbytes << 1) - 1; - for (i = 0; i < row_width; i++) - { - if (((png_uint_16)*(sp) | - ((png_uint_16)*(sp - 1) << 8)) == gray) - { - *dp-- = 0; - *dp-- = 0; - } - else - { - *dp-- = 0xff; - *dp-- = 0xff; - } - *dp-- = *sp--; - *dp-- = *sp--; - } - } - row_info->color_type = PNG_COLOR_TYPE_GRAY_ALPHA; - row_info->channels = 2; - row_info->pixel_depth = (png_byte)(row_info->bit_depth << 1); - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, - row_width); - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_RGB && trans_value) - { - if (row_info->bit_depth == 8) - { - sp = row + (png_size_t)row_info->rowbytes - 1; - dp = row + (png_size_t)(row_width << 2) - 1; - for (i = 0; i < row_width; i++) - { - if (*(sp - 2) == trans_value->red && - *(sp - 1) == trans_value->green && - *(sp - 0) == trans_value->blue) - *dp-- = 0; - else - *dp-- = 0xff; - *dp-- = *sp--; - *dp-- = *sp--; - *dp-- = *sp--; - } - } - else if (row_info->bit_depth == 16) - { - sp = row + row_info->rowbytes - 1; - dp = row + (png_size_t)(row_width << 3) - 1; - for (i = 0; i < row_width; i++) - { - if ((((png_uint_16)*(sp - 4) | - ((png_uint_16)*(sp - 5) << 8)) == trans_value->red) && - (((png_uint_16)*(sp - 2) | - ((png_uint_16)*(sp - 3) << 8)) == trans_value->green) && - (((png_uint_16)*(sp - 0) | - ((png_uint_16)*(sp - 1) << 8)) == trans_value->blue)) - { - *dp-- = 0; - *dp-- = 0; - } - else - { - *dp-- = 0xff; - *dp-- = 0xff; - } - *dp-- = *sp--; - *dp-- = *sp--; - *dp-- = *sp--; - *dp-- = *sp--; - *dp-- = *sp--; - *dp-- = *sp--; - } - } - row_info->color_type = PNG_COLOR_TYPE_RGB_ALPHA; - row_info->channels = 4; - row_info->pixel_depth = (png_byte)(row_info->bit_depth << 2); - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); - } - } -} -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) -void /* PRIVATE */ -png_do_dither(png_row_infop row_info, png_bytep row, - png_bytep palette_lookup, png_bytep dither_lookup) -{ - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width=row_info->width; - - png_debug(1, "in png_do_dither\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif - { - if (row_info->color_type == PNG_COLOR_TYPE_RGB && - palette_lookup && row_info->bit_depth == 8) - { - int r, g, b, p; - sp = row; - dp = row; - for (i = 0; i < row_width; i++) - { - r = *sp++; - g = *sp++; - b = *sp++; - - /* this looks real messy, but the compiler will reduce - it down to a reasonable formula. For example, with - 5 bits per color, we get: - p = (((r >> 3) & 0x1f) << 10) | - (((g >> 3) & 0x1f) << 5) | - ((b >> 3) & 0x1f); - */ - p = (((r >> (8 - PNG_DITHER_RED_BITS)) & - ((1 << PNG_DITHER_RED_BITS) - 1)) << - (PNG_DITHER_GREEN_BITS + PNG_DITHER_BLUE_BITS)) | - (((g >> (8 - PNG_DITHER_GREEN_BITS)) & - ((1 << PNG_DITHER_GREEN_BITS) - 1)) << - (PNG_DITHER_BLUE_BITS)) | - ((b >> (8 - PNG_DITHER_BLUE_BITS)) & - ((1 << PNG_DITHER_BLUE_BITS) - 1)); - - *dp++ = palette_lookup[p]; - } - row_info->color_type = PNG_COLOR_TYPE_PALETTE; - row_info->channels = 1; - row_info->pixel_depth = row_info->bit_depth; - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); - } - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA && - palette_lookup != NULL && row_info->bit_depth == 8) - { - int r, g, b, p; - sp = row; - dp = row; - for (i = 0; i < row_width; i++) - { - r = *sp++; - g = *sp++; - b = *sp++; - sp++; - - p = (((r >> (8 - PNG_DITHER_RED_BITS)) & - ((1 << PNG_DITHER_RED_BITS) - 1)) << - (PNG_DITHER_GREEN_BITS + PNG_DITHER_BLUE_BITS)) | - (((g >> (8 - PNG_DITHER_GREEN_BITS)) & - ((1 << PNG_DITHER_GREEN_BITS) - 1)) << - (PNG_DITHER_BLUE_BITS)) | - ((b >> (8 - PNG_DITHER_BLUE_BITS)) & - ((1 << PNG_DITHER_BLUE_BITS) - 1)); - - *dp++ = palette_lookup[p]; - } - row_info->color_type = PNG_COLOR_TYPE_PALETTE; - row_info->channels = 1; - row_info->pixel_depth = row_info->bit_depth; - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); - } - else if (row_info->color_type == PNG_COLOR_TYPE_PALETTE && - dither_lookup && row_info->bit_depth == 8) - { - sp = row; - for (i = 0; i < row_width; i++, sp++) - { - *sp = dither_lookup[*sp]; - } - } - } -} -#endif - -#ifdef PNG_FLOATING_POINT_SUPPORTED -#if defined(PNG_READ_GAMMA_SUPPORTED) -const static int png_gamma_shift[] = - {0x10, 0x21, 0x42, 0x84, 0x110, 0x248, 0x550, 0xff0, 0x00}; - -/* We build the 8- or 16-bit gamma tables here. Note that for 16-bit - * tables, we don't make a full table if we are reducing to 8-bit in - * the future. Note also how the gamma_16 tables are segmented so that - * we don't need to allocate > 64K chunks for a full 16-bit table. - */ -void /* PRIVATE */ -png_build_gamma_table(png_structp png_ptr) -{ - png_debug(1, "in png_build_gamma_table\n"); - - if (png_ptr->bit_depth <= 8) - { - int i; - double g; - - if (png_ptr->screen_gamma > .000001) - g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); - else - g = 1.0; - - png_ptr->gamma_table = (png_bytep)png_malloc(png_ptr, - (png_uint_32)256); - - for (i = 0; i < 256; i++) - { - png_ptr->gamma_table[i] = (png_byte)(pow((double)i / 255.0, - g) * 255.0 + .5); - } - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ - defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - if (png_ptr->transformations & ((PNG_BACKGROUND) | PNG_RGB_TO_GRAY)) - { - - g = 1.0 / (png_ptr->gamma); - - png_ptr->gamma_to_1 = (png_bytep)png_malloc(png_ptr, - (png_uint_32)256); - - for (i = 0; i < 256; i++) - { - png_ptr->gamma_to_1[i] = (png_byte)(pow((double)i / 255.0, - g) * 255.0 + .5); - } - - - png_ptr->gamma_from_1 = (png_bytep)png_malloc(png_ptr, - (png_uint_32)256); - - if(png_ptr->screen_gamma > 0.000001) - g = 1.0 / png_ptr->screen_gamma; - else - g = png_ptr->gamma; /* probably doing rgb_to_gray */ - - for (i = 0; i < 256; i++) - { - png_ptr->gamma_from_1[i] = (png_byte)(pow((double)i / 255.0, - g) * 255.0 + .5); - - } - } -#endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_RGB_TO_GRAY_SUPPORTED */ - } - else - { - double g; - int i, j, shift, num; - int sig_bit; - png_uint_32 ig; - - if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) - { - sig_bit = (int)png_ptr->sig_bit.red; - if ((int)png_ptr->sig_bit.green > sig_bit) - sig_bit = png_ptr->sig_bit.green; - if ((int)png_ptr->sig_bit.blue > sig_bit) - sig_bit = png_ptr->sig_bit.blue; - } - else - { - sig_bit = (int)png_ptr->sig_bit.gray; - } - - if (sig_bit > 0) - shift = 16 - sig_bit; - else - shift = 0; - - if (png_ptr->transformations & PNG_16_TO_8) - { - if (shift < (16 - PNG_MAX_GAMMA_8)) - shift = (16 - PNG_MAX_GAMMA_8); - } - - if (shift > 8) - shift = 8; - if (shift < 0) - shift = 0; - - png_ptr->gamma_shift = (png_byte)shift; - - num = (1 << (8 - shift)); - - if (png_ptr->screen_gamma > .000001) - g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); - else - g = 1.0; - - png_ptr->gamma_16_table = (png_uint_16pp)png_malloc(png_ptr, - (png_uint_32)(num * png_sizeof (png_uint_16p))); - - if (png_ptr->transformations & (PNG_16_TO_8 | PNG_BACKGROUND)) - { - double fin, fout; - png_uint_32 last, max; - - for (i = 0; i < num; i++) - { - png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(256 * png_sizeof (png_uint_16))); - } - - g = 1.0 / g; - last = 0; - for (i = 0; i < 256; i++) - { - fout = ((double)i + 0.5) / 256.0; - fin = pow(fout, g); - max = (png_uint_32)(fin * (double)((png_uint_32)num << 8)); - while (last <= max) - { - png_ptr->gamma_16_table[(int)(last & (0xff >> shift))] - [(int)(last >> (8 - shift))] = (png_uint_16)( - (png_uint_16)i | ((png_uint_16)i << 8)); - last++; - } - } - while (last < ((png_uint_32)num << 8)) - { - png_ptr->gamma_16_table[(int)(last & (0xff >> shift))] - [(int)(last >> (8 - shift))] = (png_uint_16)65535L; - last++; - } - } - else - { - for (i = 0; i < num; i++) - { - png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(256 * png_sizeof (png_uint_16))); - - ig = (((png_uint_32)i * (png_uint_32)png_gamma_shift[shift]) >> 4); - for (j = 0; j < 256; j++) - { - png_ptr->gamma_16_table[i][j] = - (png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) / - 65535.0, g) * 65535.0 + .5); - } - } - } - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ - defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - if (png_ptr->transformations & (PNG_BACKGROUND | PNG_RGB_TO_GRAY)) - { - - g = 1.0 / (png_ptr->gamma); - - png_ptr->gamma_16_to_1 = (png_uint_16pp)png_malloc(png_ptr, - (png_uint_32)(num * png_sizeof (png_uint_16p ))); - - for (i = 0; i < num; i++) - { - png_ptr->gamma_16_to_1[i] = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(256 * png_sizeof (png_uint_16))); - - ig = (((png_uint_32)i * - (png_uint_32)png_gamma_shift[shift]) >> 4); - for (j = 0; j < 256; j++) - { - png_ptr->gamma_16_to_1[i][j] = - (png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) / - 65535.0, g) * 65535.0 + .5); - } - } - - if(png_ptr->screen_gamma > 0.000001) - g = 1.0 / png_ptr->screen_gamma; - else - g = png_ptr->gamma; /* probably doing rgb_to_gray */ - - png_ptr->gamma_16_from_1 = (png_uint_16pp)png_malloc(png_ptr, - (png_uint_32)(num * png_sizeof (png_uint_16p))); - - for (i = 0; i < num; i++) - { - png_ptr->gamma_16_from_1[i] = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(256 * png_sizeof (png_uint_16))); - - ig = (((png_uint_32)i * - (png_uint_32)png_gamma_shift[shift]) >> 4); - for (j = 0; j < 256; j++) - { - png_ptr->gamma_16_from_1[i][j] = - (png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) / - 65535.0, g) * 65535.0 + .5); - } - } - } -#endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_RGB_TO_GRAY_SUPPORTED */ - } -} -#endif -/* To do: install integer version of png_build_gamma_table here */ -#endif - -#if defined(PNG_MNG_FEATURES_SUPPORTED) -/* undoes intrapixel differencing */ -void /* PRIVATE */ -png_do_read_intrapixel(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_read_intrapixel\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - (row_info->color_type & PNG_COLOR_MASK_COLOR)) - { - int bytes_per_pixel; - png_uint_32 row_width = row_info->width; - if (row_info->bit_depth == 8) - { - png_bytep rp; - png_uint_32 i; - - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - bytes_per_pixel = 3; - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - bytes_per_pixel = 4; - else - return; - - for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) - { - *(rp) = (png_byte)((256 + *rp + *(rp+1))&0xff); - *(rp+2) = (png_byte)((256 + *(rp+2) + *(rp+1))&0xff); - } - } - else if (row_info->bit_depth == 16) - { - png_bytep rp; - png_uint_32 i; - - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - bytes_per_pixel = 6; - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - bytes_per_pixel = 8; - else - return; - - for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) - { - png_uint_32 s0 = (*(rp ) << 8) | *(rp+1); - png_uint_32 s1 = (*(rp+2) << 8) | *(rp+3); - png_uint_32 s2 = (*(rp+4) << 8) | *(rp+5); - png_uint_32 red = (png_uint_32)((s0+s1+65536L) & 0xffffL); - png_uint_32 blue = (png_uint_32)((s2+s1+65536L) & 0xffffL); - *(rp ) = (png_byte)((red >> 8) & 0xff); - *(rp+1) = (png_byte)(red & 0xff); - *(rp+4) = (png_byte)((blue >> 8) & 0xff); - *(rp+5) = (png_byte)(blue & 0xff); - } - } - } -} -#endif /* PNG_MNG_FEATURES_SUPPORTED */ -#endif /* PNG_READ_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/pngrutil.c b/irrlicht-1.6/source/Irrlicht/libpng/pngrutil.c deleted file mode 100644 index 9860768d7..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/pngrutil.c +++ /dev/null @@ -1,3132 +0,0 @@ - -/* pngrutil.c - utilities to read a PNG file - * - * Last changed in libpng 1.2.17 May 15, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This file contains routines that are only called from within - * libpng itself during the course of reading an image. - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_READ_SUPPORTED) - -#ifdef PNG_FLOATING_POINT_SUPPORTED -# if defined(_WIN32_WCE) -/* strtod() function is not supported on WindowsCE */ -__inline double png_strtod(png_structp png_ptr, const char *nptr, char **endptr) -{ - double result = 0; - int len; - wchar_t *str, *end; - - len = MultiByteToWideChar(CP_ACP, 0, nptr, -1, NULL, 0); - str = (wchar_t *)png_malloc(png_ptr, len * sizeof(wchar_t)); - if ( NULL != str ) - { - MultiByteToWideChar(CP_ACP, 0, nptr, -1, str, len); - result = wcstod(str, &end); - len = WideCharToMultiByte(CP_ACP, 0, end, -1, NULL, 0, NULL, NULL); - *endptr = (char *)nptr + (png_strlen(nptr) - len + 1); - png_free(str); - } - return result; -} -# else -# define png_strtod(p,a,b) strtod(a,b) -# endif -#endif - -png_uint_32 PNGAPI -png_get_uint_31(png_structp png_ptr, png_bytep buf) -{ - png_uint_32 i = png_get_uint_32(buf); - if (i > PNG_UINT_31_MAX) - png_error(png_ptr, "PNG unsigned integer out of range."); - return (i); -} -#ifndef PNG_READ_BIG_ENDIAN_SUPPORTED -/* Grab an unsigned 32-bit integer from a buffer in big-endian format. */ -png_uint_32 PNGAPI -png_get_uint_32(png_bytep buf) -{ - png_uint_32 i = ((png_uint_32)(*buf) << 24) + - ((png_uint_32)(*(buf + 1)) << 16) + - ((png_uint_32)(*(buf + 2)) << 8) + - (png_uint_32)(*(buf + 3)); - - return (i); -} - -/* Grab a signed 32-bit integer from a buffer in big-endian format. The - * data is stored in the PNG file in two's complement format, and it is - * assumed that the machine format for signed integers is the same. */ -png_int_32 PNGAPI -png_get_int_32(png_bytep buf) -{ - png_int_32 i = ((png_int_32)(*buf) << 24) + - ((png_int_32)(*(buf + 1)) << 16) + - ((png_int_32)(*(buf + 2)) << 8) + - (png_int_32)(*(buf + 3)); - - return (i); -} - -/* Grab an unsigned 16-bit integer from a buffer in big-endian format. */ -png_uint_16 PNGAPI -png_get_uint_16(png_bytep buf) -{ - png_uint_16 i = (png_uint_16)(((png_uint_16)(*buf) << 8) + - (png_uint_16)(*(buf + 1))); - - return (i); -} -#endif /* PNG_READ_BIG_ENDIAN_SUPPORTED */ - -/* Read data, and (optionally) run it through the CRC. */ -void /* PRIVATE */ -png_crc_read(png_structp png_ptr, png_bytep buf, png_size_t length) -{ - if(png_ptr == NULL) return; - png_read_data(png_ptr, buf, length); - png_calculate_crc(png_ptr, buf, length); -} - -/* Optionally skip data and then check the CRC. Depending on whether we - are reading a ancillary or critical chunk, and how the program has set - things up, we may calculate the CRC on the data and print a message. - Returns '1' if there was a CRC error, '0' otherwise. */ -int /* PRIVATE */ -png_crc_finish(png_structp png_ptr, png_uint_32 skip) -{ - png_size_t i; - png_size_t istop = png_ptr->zbuf_size; - - for (i = (png_size_t)skip; i > istop; i -= istop) - { - png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size); - } - if (i) - { - png_crc_read(png_ptr, png_ptr->zbuf, i); - } - - if (png_crc_error(png_ptr)) - { - if (((png_ptr->chunk_name[0] & 0x20) && /* Ancillary */ - !(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)) || - (!(png_ptr->chunk_name[0] & 0x20) && /* Critical */ - (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_USE))) - { - png_chunk_warning(png_ptr, "CRC error"); - } - else - { - png_chunk_error(png_ptr, "CRC error"); - } - return (1); - } - - return (0); -} - -/* Compare the CRC stored in the PNG file with that calculated by libpng from - the data it has read thus far. */ -int /* PRIVATE */ -png_crc_error(png_structp png_ptr) -{ - png_byte crc_bytes[4]; - png_uint_32 crc; - int need_crc = 1; - - if (png_ptr->chunk_name[0] & 0x20) /* ancillary */ - { - if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) == - (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN)) - need_crc = 0; - } - else /* critical */ - { - if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE) - need_crc = 0; - } - - png_read_data(png_ptr, crc_bytes, 4); - - if (need_crc) - { - crc = png_get_uint_32(crc_bytes); - return ((int)(crc != png_ptr->crc)); - } - else - return (0); -} - -#if defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_READ_iTXt_SUPPORTED) || \ - defined(PNG_READ_iCCP_SUPPORTED) -/* - * Decompress trailing data in a chunk. The assumption is that chunkdata - * points at an allocated area holding the contents of a chunk with a - * trailing compressed part. What we get back is an allocated area - * holding the original prefix part and an uncompressed version of the - * trailing part (the malloc area passed in is freed). - */ -png_charp /* PRIVATE */ -png_decompress_chunk(png_structp png_ptr, int comp_type, - png_charp chunkdata, png_size_t chunklength, - png_size_t prefix_size, png_size_t *newlength) -{ - const static char msg[] = "Error decoding compressed text"; - png_charp text; - png_size_t text_size; - - if (comp_type == PNG_COMPRESSION_TYPE_BASE) - { - int ret = Z_OK; - png_ptr->zstream.next_in = (png_bytep)(chunkdata + prefix_size); - png_ptr->zstream.avail_in = (uInt)(chunklength - prefix_size); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - - text_size = 0; - text = NULL; - - while (png_ptr->zstream.avail_in) - { - ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); - if (ret != Z_OK && ret != Z_STREAM_END) - { - if (png_ptr->zstream.msg != NULL) - png_warning(png_ptr, png_ptr->zstream.msg); - else - png_warning(png_ptr, msg); - inflateReset(&png_ptr->zstream); - png_ptr->zstream.avail_in = 0; - - if (text == NULL) - { - text_size = prefix_size + png_sizeof(msg) + 1; - text = (png_charp)png_malloc_warn(png_ptr, text_size); - if (text == NULL) - { - png_free(png_ptr,chunkdata); - png_error(png_ptr,"Not enough memory to decompress chunk"); - } - png_memcpy(text, chunkdata, prefix_size); - } - - text[text_size - 1] = 0x00; - - /* Copy what we can of the error message into the text chunk */ - text_size = (png_size_t)(chunklength - (text - chunkdata) - 1); - text_size = png_sizeof(msg) > text_size ? text_size : - png_sizeof(msg); - png_memcpy(text + prefix_size, msg, text_size + 1); - break; - } - if (!png_ptr->zstream.avail_out || ret == Z_STREAM_END) - { - if (text == NULL) - { - text_size = prefix_size + - png_ptr->zbuf_size - png_ptr->zstream.avail_out; - text = (png_charp)png_malloc_warn(png_ptr, text_size + 1); - if (text == NULL) - { - png_free(png_ptr,chunkdata); - png_error(png_ptr,"Not enough memory to decompress chunk."); - } - png_memcpy(text + prefix_size, png_ptr->zbuf, - text_size - prefix_size); - png_memcpy(text, chunkdata, prefix_size); - *(text + text_size) = 0x00; - } - else - { - png_charp tmp; - - tmp = text; - text = (png_charp)png_malloc_warn(png_ptr, - (png_uint_32)(text_size + - png_ptr->zbuf_size - png_ptr->zstream.avail_out + 1)); - if (text == NULL) - { - png_free(png_ptr, tmp); - png_free(png_ptr, chunkdata); - png_error(png_ptr,"Not enough memory to decompress chunk.."); - } - png_memcpy(text, tmp, text_size); - png_free(png_ptr, tmp); - png_memcpy(text + text_size, png_ptr->zbuf, - (png_ptr->zbuf_size - png_ptr->zstream.avail_out)); - text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out; - *(text + text_size) = 0x00; - } - if (ret == Z_STREAM_END) - break; - else - { - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - } - } - } - if (ret != Z_STREAM_END) - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char umsg[52]; - - if (ret == Z_BUF_ERROR) - sprintf(umsg,"Buffer error in compressed datastream in %s chunk", - png_ptr->chunk_name); - else if (ret == Z_DATA_ERROR) - sprintf(umsg,"Data error in compressed datastream in %s chunk", - png_ptr->chunk_name); - else - sprintf(umsg,"Incomplete compressed datastream in %s chunk", - png_ptr->chunk_name); - png_warning(png_ptr, umsg); -#else - png_warning(png_ptr, - "Incomplete compressed datastream in chunk other than IDAT"); -#endif - text_size=prefix_size; - if (text == NULL) - { - text = (png_charp)png_malloc_warn(png_ptr, text_size+1); - if (text == NULL) - { - png_free(png_ptr, chunkdata); - png_error(png_ptr,"Not enough memory for text."); - } - png_memcpy(text, chunkdata, prefix_size); - } - *(text + text_size) = 0x00; - } - - inflateReset(&png_ptr->zstream); - png_ptr->zstream.avail_in = 0; - - png_free(png_ptr, chunkdata); - chunkdata = text; - *newlength=text_size; - } - else /* if (comp_type != PNG_COMPRESSION_TYPE_BASE) */ - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char umsg[50]; - - sprintf(umsg, "Unknown zTXt compression type %d", comp_type); - png_warning(png_ptr, umsg); -#else - png_warning(png_ptr, "Unknown zTXt compression type"); -#endif - - *(chunkdata + prefix_size) = 0x00; - *newlength=prefix_size; - } - - return chunkdata; -} -#endif - -/* read and check the IDHR chunk */ -void /* PRIVATE */ -png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_byte buf[13]; - png_uint_32 width, height; - int bit_depth, color_type, compression_type, filter_type; - int interlace_type; - - png_debug(1, "in png_handle_IHDR\n"); - - if (png_ptr->mode & PNG_HAVE_IHDR) - png_error(png_ptr, "Out of place IHDR"); - - /* check the length */ - if (length != 13) - png_error(png_ptr, "Invalid IHDR chunk"); - - png_ptr->mode |= PNG_HAVE_IHDR; - - png_crc_read(png_ptr, buf, 13); - png_crc_finish(png_ptr, 0); - - width = png_get_uint_31(png_ptr, buf); - height = png_get_uint_31(png_ptr, buf + 4); - bit_depth = buf[8]; - color_type = buf[9]; - compression_type = buf[10]; - filter_type = buf[11]; - interlace_type = buf[12]; - - /* set internal variables */ - png_ptr->width = width; - png_ptr->height = height; - png_ptr->bit_depth = (png_byte)bit_depth; - png_ptr->interlaced = (png_byte)interlace_type; - png_ptr->color_type = (png_byte)color_type; -#if defined(PNG_MNG_FEATURES_SUPPORTED) - png_ptr->filter_type = (png_byte)filter_type; -#endif - png_ptr->compression_type = (png_byte)compression_type; - - /* find number of channels */ - switch (png_ptr->color_type) - { - case PNG_COLOR_TYPE_GRAY: - case PNG_COLOR_TYPE_PALETTE: - png_ptr->channels = 1; - break; - case PNG_COLOR_TYPE_RGB: - png_ptr->channels = 3; - break; - case PNG_COLOR_TYPE_GRAY_ALPHA: - png_ptr->channels = 2; - break; - case PNG_COLOR_TYPE_RGB_ALPHA: - png_ptr->channels = 4; - break; - } - - /* set up other useful info */ - png_ptr->pixel_depth = (png_byte)(png_ptr->bit_depth * - png_ptr->channels); - png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth,png_ptr->width); - png_debug1(3,"bit_depth = %d\n", png_ptr->bit_depth); - png_debug1(3,"channels = %d\n", png_ptr->channels); - png_debug1(3,"rowbytes = %lu\n", png_ptr->rowbytes); - png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, - color_type, interlace_type, compression_type, filter_type); -} - -/* read and check the palette */ -void /* PRIVATE */ -png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_color palette[PNG_MAX_PALETTE_LENGTH]; - int num, i; -#ifndef PNG_NO_POINTER_INDEXING - png_colorp pal_ptr; -#endif - - png_debug(1, "in png_handle_PLTE\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before PLTE"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid PLTE after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->mode & PNG_HAVE_PLTE) - png_error(png_ptr, "Duplicate PLTE chunk"); - - png_ptr->mode |= PNG_HAVE_PLTE; - - if (!(png_ptr->color_type&PNG_COLOR_MASK_COLOR)) - { - png_warning(png_ptr, - "Ignoring PLTE chunk in grayscale PNG"); - png_crc_finish(png_ptr, length); - return; - } -#if !defined(PNG_READ_OPT_PLTE_SUPPORTED) - if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE) - { - png_crc_finish(png_ptr, length); - return; - } -#endif - - if (length > 3*PNG_MAX_PALETTE_LENGTH || length % 3) - { - if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE) - { - png_warning(png_ptr, "Invalid palette chunk"); - png_crc_finish(png_ptr, length); - return; - } - else - { - png_error(png_ptr, "Invalid palette chunk"); - } - } - - num = (int)length / 3; - -#ifndef PNG_NO_POINTER_INDEXING - for (i = 0, pal_ptr = palette; i < num; i++, pal_ptr++) - { - png_byte buf[3]; - - png_crc_read(png_ptr, buf, 3); - pal_ptr->red = buf[0]; - pal_ptr->green = buf[1]; - pal_ptr->blue = buf[2]; - } -#else - for (i = 0; i < num; i++) - { - png_byte buf[3]; - - png_crc_read(png_ptr, buf, 3); - /* don't depend upon png_color being any order */ - palette[i].red = buf[0]; - palette[i].green = buf[1]; - palette[i].blue = buf[2]; - } -#endif - - /* If we actually NEED the PLTE chunk (ie for a paletted image), we do - whatever the normal CRC configuration tells us. However, if we - have an RGB image, the PLTE can be considered ancillary, so - we will act as though it is. */ -#if !defined(PNG_READ_OPT_PLTE_SUPPORTED) - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) -#endif - { - png_crc_finish(png_ptr, 0); - } -#if !defined(PNG_READ_OPT_PLTE_SUPPORTED) - else if (png_crc_error(png_ptr)) /* Only if we have a CRC error */ - { - /* If we don't want to use the data from an ancillary chunk, - we have two options: an error abort, or a warning and we - ignore the data in this chunk (which should be OK, since - it's considered ancillary for a RGB or RGBA image). */ - if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_USE)) - { - if (png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) - { - png_chunk_error(png_ptr, "CRC error"); - } - else - { - png_chunk_warning(png_ptr, "CRC error"); - return; - } - } - /* Otherwise, we (optionally) emit a warning and use the chunk. */ - else if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)) - { - png_chunk_warning(png_ptr, "CRC error"); - } - } -#endif - - png_set_PLTE(png_ptr, info_ptr, palette, num); - -#if defined(PNG_READ_tRNS_SUPPORTED) - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) - { - if (png_ptr->num_trans > (png_uint_16)num) - { - png_warning(png_ptr, "Truncating incorrect tRNS chunk length"); - png_ptr->num_trans = (png_uint_16)num; - } - if (info_ptr->num_trans > (png_uint_16)num) - { - png_warning(png_ptr, "Truncating incorrect info tRNS chunk length"); - info_ptr->num_trans = (png_uint_16)num; - } - } - } -#endif - -} - -void /* PRIVATE */ -png_handle_IEND(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_debug(1, "in png_handle_IEND\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR) || !(png_ptr->mode & PNG_HAVE_IDAT)) - { - png_error(png_ptr, "No image in file"); - } - - png_ptr->mode |= (PNG_AFTER_IDAT | PNG_HAVE_IEND); - - if (length != 0) - { - png_warning(png_ptr, "Incorrect IEND chunk length"); - } - png_crc_finish(png_ptr, length); - - if (&info_ptr == NULL) /* quiet compiler warnings about unused info_ptr */ - return; -} - -#if defined(PNG_READ_gAMA_SUPPORTED) -void /* PRIVATE */ -png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_fixed_point igamma; -#ifdef PNG_FLOATING_POINT_SUPPORTED - float file_gamma; -#endif - png_byte buf[4]; - - png_debug(1, "in png_handle_gAMA\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before gAMA"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid gAMA after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->mode & PNG_HAVE_PLTE) - /* Should be an error, but we can cope with it */ - png_warning(png_ptr, "Out of place gAMA chunk"); - - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) -#if defined(PNG_READ_sRGB_SUPPORTED) - && !(info_ptr->valid & PNG_INFO_sRGB) -#endif - ) - { - png_warning(png_ptr, "Duplicate gAMA chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (length != 4) - { - png_warning(png_ptr, "Incorrect gAMA chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, 4); - if (png_crc_finish(png_ptr, 0)) - return; - - igamma = (png_fixed_point)png_get_uint_32(buf); - /* check for zero gamma */ - if (igamma == 0) - { - png_warning(png_ptr, - "Ignoring gAMA chunk with gamma=0"); - return; - } - -#if defined(PNG_READ_sRGB_SUPPORTED) - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)) - if (PNG_OUT_OF_RANGE(igamma, 45500L, 500)) - { - png_warning(png_ptr, - "Ignoring incorrect gAMA value when sRGB is also present"); -#ifndef PNG_NO_CONSOLE_IO - fprintf(stderr, "gamma = (%d/100000)\n", (int)igamma); -#endif - return; - } -#endif /* PNG_READ_sRGB_SUPPORTED */ - -#ifdef PNG_FLOATING_POINT_SUPPORTED - file_gamma = (float)igamma / (float)100000.0; -# ifdef PNG_READ_GAMMA_SUPPORTED - png_ptr->gamma = file_gamma; -# endif - png_set_gAMA(png_ptr, info_ptr, file_gamma); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - png_set_gAMA_fixed(png_ptr, info_ptr, igamma); -#endif -} -#endif - -#if defined(PNG_READ_sBIT_SUPPORTED) -void /* PRIVATE */ -png_handle_sBIT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_size_t truelen; - png_byte buf[4]; - - png_debug(1, "in png_handle_sBIT\n"); - - buf[0] = buf[1] = buf[2] = buf[3] = 0; - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before sBIT"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid sBIT after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->mode & PNG_HAVE_PLTE) - { - /* Should be an error, but we can cope with it */ - png_warning(png_ptr, "Out of place sBIT chunk"); - } - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)) - { - png_warning(png_ptr, "Duplicate sBIT chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - truelen = 3; - else - truelen = (png_size_t)png_ptr->channels; - - if (length != truelen || length > 4) - { - png_warning(png_ptr, "Incorrect sBIT chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, truelen); - if (png_crc_finish(png_ptr, 0)) - return; - - if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) - { - png_ptr->sig_bit.red = buf[0]; - png_ptr->sig_bit.green = buf[1]; - png_ptr->sig_bit.blue = buf[2]; - png_ptr->sig_bit.alpha = buf[3]; - } - else - { - png_ptr->sig_bit.gray = buf[0]; - png_ptr->sig_bit.red = buf[0]; - png_ptr->sig_bit.green = buf[0]; - png_ptr->sig_bit.blue = buf[0]; - png_ptr->sig_bit.alpha = buf[1]; - } - png_set_sBIT(png_ptr, info_ptr, &(png_ptr->sig_bit)); -} -#endif - -#if defined(PNG_READ_cHRM_SUPPORTED) -void /* PRIVATE */ -png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_byte buf[4]; -#ifdef PNG_FLOATING_POINT_SUPPORTED - float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y; -#endif - png_fixed_point int_x_white, int_y_white, int_x_red, int_y_red, int_x_green, - int_y_green, int_x_blue, int_y_blue; - - png_uint_32 uint_x, uint_y; - - png_debug(1, "in png_handle_cHRM\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before cHRM"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid cHRM after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->mode & PNG_HAVE_PLTE) - /* Should be an error, but we can cope with it */ - png_warning(png_ptr, "Missing PLTE before cHRM"); - - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM) -#if defined(PNG_READ_sRGB_SUPPORTED) - && !(info_ptr->valid & PNG_INFO_sRGB) -#endif - ) - { - png_warning(png_ptr, "Duplicate cHRM chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (length != 32) - { - png_warning(png_ptr, "Incorrect cHRM chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, 4); - uint_x = png_get_uint_32(buf); - - png_crc_read(png_ptr, buf, 4); - uint_y = png_get_uint_32(buf); - - if (uint_x > 80000L || uint_y > 80000L || - uint_x + uint_y > 100000L) - { - png_warning(png_ptr, "Invalid cHRM white point"); - png_crc_finish(png_ptr, 24); - return; - } - int_x_white = (png_fixed_point)uint_x; - int_y_white = (png_fixed_point)uint_y; - - png_crc_read(png_ptr, buf, 4); - uint_x = png_get_uint_32(buf); - - png_crc_read(png_ptr, buf, 4); - uint_y = png_get_uint_32(buf); - - if (uint_x + uint_y > 100000L) - { - png_warning(png_ptr, "Invalid cHRM red point"); - png_crc_finish(png_ptr, 16); - return; - } - int_x_red = (png_fixed_point)uint_x; - int_y_red = (png_fixed_point)uint_y; - - png_crc_read(png_ptr, buf, 4); - uint_x = png_get_uint_32(buf); - - png_crc_read(png_ptr, buf, 4); - uint_y = png_get_uint_32(buf); - - if (uint_x + uint_y > 100000L) - { - png_warning(png_ptr, "Invalid cHRM green point"); - png_crc_finish(png_ptr, 8); - return; - } - int_x_green = (png_fixed_point)uint_x; - int_y_green = (png_fixed_point)uint_y; - - png_crc_read(png_ptr, buf, 4); - uint_x = png_get_uint_32(buf); - - png_crc_read(png_ptr, buf, 4); - uint_y = png_get_uint_32(buf); - - if (uint_x + uint_y > 100000L) - { - png_warning(png_ptr, "Invalid cHRM blue point"); - png_crc_finish(png_ptr, 0); - return; - } - int_x_blue = (png_fixed_point)uint_x; - int_y_blue = (png_fixed_point)uint_y; - -#ifdef PNG_FLOATING_POINT_SUPPORTED - white_x = (float)int_x_white / (float)100000.0; - white_y = (float)int_y_white / (float)100000.0; - red_x = (float)int_x_red / (float)100000.0; - red_y = (float)int_y_red / (float)100000.0; - green_x = (float)int_x_green / (float)100000.0; - green_y = (float)int_y_green / (float)100000.0; - blue_x = (float)int_x_blue / (float)100000.0; - blue_y = (float)int_y_blue / (float)100000.0; -#endif - -#if defined(PNG_READ_sRGB_SUPPORTED) - if ((info_ptr != NULL) && (info_ptr->valid & PNG_INFO_sRGB)) - { - if (PNG_OUT_OF_RANGE(int_x_white, 31270, 1000) || - PNG_OUT_OF_RANGE(int_y_white, 32900, 1000) || - PNG_OUT_OF_RANGE(int_x_red, 64000L, 1000) || - PNG_OUT_OF_RANGE(int_y_red, 33000, 1000) || - PNG_OUT_OF_RANGE(int_x_green, 30000, 1000) || - PNG_OUT_OF_RANGE(int_y_green, 60000L, 1000) || - PNG_OUT_OF_RANGE(int_x_blue, 15000, 1000) || - PNG_OUT_OF_RANGE(int_y_blue, 6000, 1000)) - { - png_warning(png_ptr, - "Ignoring incorrect cHRM value when sRGB is also present"); -#ifndef PNG_NO_CONSOLE_IO -#ifdef PNG_FLOATING_POINT_SUPPORTED - fprintf(stderr,"wx=%f, wy=%f, rx=%f, ry=%f\n", - white_x, white_y, red_x, red_y); - fprintf(stderr,"gx=%f, gy=%f, bx=%f, by=%f\n", - green_x, green_y, blue_x, blue_y); -#else - fprintf(stderr,"wx=%ld, wy=%ld, rx=%ld, ry=%ld\n", - int_x_white, int_y_white, int_x_red, int_y_red); - fprintf(stderr,"gx=%ld, gy=%ld, bx=%ld, by=%ld\n", - int_x_green, int_y_green, int_x_blue, int_y_blue); -#endif -#endif /* PNG_NO_CONSOLE_IO */ - } - png_crc_finish(png_ptr, 0); - return; - } -#endif /* PNG_READ_sRGB_SUPPORTED */ - -#ifdef PNG_FLOATING_POINT_SUPPORTED - png_set_cHRM(png_ptr, info_ptr, - white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - png_set_cHRM_fixed(png_ptr, info_ptr, - int_x_white, int_y_white, int_x_red, int_y_red, int_x_green, - int_y_green, int_x_blue, int_y_blue); -#endif - if (png_crc_finish(png_ptr, 0)) - return; -} -#endif - -#if defined(PNG_READ_sRGB_SUPPORTED) -void /* PRIVATE */ -png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - int intent; - png_byte buf[1]; - - png_debug(1, "in png_handle_sRGB\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before sRGB"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid sRGB after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->mode & PNG_HAVE_PLTE) - /* Should be an error, but we can cope with it */ - png_warning(png_ptr, "Out of place sRGB chunk"); - - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)) - { - png_warning(png_ptr, "Duplicate sRGB chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (length != 1) - { - png_warning(png_ptr, "Incorrect sRGB chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, 1); - if (png_crc_finish(png_ptr, 0)) - return; - - intent = buf[0]; - /* check for bad intent */ - if (intent >= PNG_sRGB_INTENT_LAST) - { - png_warning(png_ptr, "Unknown sRGB intent"); - return; - } - -#if defined(PNG_READ_gAMA_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED) - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)) - { - png_fixed_point igamma; -#ifdef PNG_FIXED_POINT_SUPPORTED - igamma=info_ptr->int_gamma; -#else -# ifdef PNG_FLOATING_POINT_SUPPORTED - igamma=(png_fixed_point)(info_ptr->gamma * 100000.); -# endif -#endif - if (PNG_OUT_OF_RANGE(igamma, 45500L, 500)) - { - png_warning(png_ptr, - "Ignoring incorrect gAMA value when sRGB is also present"); -#ifndef PNG_NO_CONSOLE_IO -# ifdef PNG_FIXED_POINT_SUPPORTED - fprintf(stderr,"incorrect gamma=(%d/100000)\n",(int)png_ptr->int_gamma); -# else -# ifdef PNG_FLOATING_POINT_SUPPORTED - fprintf(stderr,"incorrect gamma=%f\n",png_ptr->gamma); -# endif -# endif -#endif - } - } -#endif /* PNG_READ_gAMA_SUPPORTED */ - -#ifdef PNG_READ_cHRM_SUPPORTED -#ifdef PNG_FIXED_POINT_SUPPORTED - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) - if (PNG_OUT_OF_RANGE(info_ptr->int_x_white, 31270, 1000) || - PNG_OUT_OF_RANGE(info_ptr->int_y_white, 32900, 1000) || - PNG_OUT_OF_RANGE(info_ptr->int_x_red, 64000L, 1000) || - PNG_OUT_OF_RANGE(info_ptr->int_y_red, 33000, 1000) || - PNG_OUT_OF_RANGE(info_ptr->int_x_green, 30000, 1000) || - PNG_OUT_OF_RANGE(info_ptr->int_y_green, 60000L, 1000) || - PNG_OUT_OF_RANGE(info_ptr->int_x_blue, 15000, 1000) || - PNG_OUT_OF_RANGE(info_ptr->int_y_blue, 6000, 1000)) - { - png_warning(png_ptr, - "Ignoring incorrect cHRM value when sRGB is also present"); - } -#endif /* PNG_FIXED_POINT_SUPPORTED */ -#endif /* PNG_READ_cHRM_SUPPORTED */ - - png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, intent); -} -#endif /* PNG_READ_sRGB_SUPPORTED */ - -#if defined(PNG_READ_iCCP_SUPPORTED) -void /* PRIVATE */ -png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -/* Note: this does not properly handle chunks that are > 64K under DOS */ -{ - png_charp chunkdata; - png_byte compression_type; - png_bytep pC; - png_charp profile; - png_uint_32 skip = 0; - png_uint_32 profile_size, profile_length; - png_size_t slength, prefix_length, data_length; - - png_debug(1, "in png_handle_iCCP\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before iCCP"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid iCCP after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->mode & PNG_HAVE_PLTE) - /* Should be an error, but we can cope with it */ - png_warning(png_ptr, "Out of place iCCP chunk"); - - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)) - { - png_warning(png_ptr, "Duplicate iCCP chunk"); - png_crc_finish(png_ptr, length); - return; - } - -#ifdef PNG_MAX_MALLOC_64K - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr, "iCCP chunk too large to fit in memory"); - skip = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - - chunkdata = (png_charp)png_malloc(png_ptr, length + 1); - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunkdata, slength); - - if (png_crc_finish(png_ptr, skip)) - { - png_free(png_ptr, chunkdata); - return; - } - - chunkdata[slength] = 0x00; - - for (profile = chunkdata; *profile; profile++) - /* empty loop to find end of name */ ; - - ++profile; - - /* there should be at least one zero (the compression type byte) - following the separator, and we should be on it */ - if ( profile >= chunkdata + slength) - { - png_free(png_ptr, chunkdata); - png_warning(png_ptr, "Malformed iCCP chunk"); - return; - } - - /* compression_type should always be zero */ - compression_type = *profile++; - if (compression_type) - { - png_warning(png_ptr, "Ignoring nonzero compression type in iCCP chunk"); - compression_type=0x00; /* Reset it to zero (libpng-1.0.6 through 1.0.8 - wrote nonzero) */ - } - - prefix_length = profile - chunkdata; - chunkdata = png_decompress_chunk(png_ptr, compression_type, chunkdata, - slength, prefix_length, &data_length); - - profile_length = data_length - prefix_length; - - if ( prefix_length > data_length || profile_length < 4) - { - png_free(png_ptr, chunkdata); - png_warning(png_ptr, "Profile size field missing from iCCP chunk"); - return; - } - - /* Check the profile_size recorded in the first 32 bits of the ICC profile */ - pC = (png_bytep)(chunkdata+prefix_length); - profile_size = ((*(pC ))<<24) | - ((*(pC+1))<<16) | - ((*(pC+2))<< 8) | - ((*(pC+3)) ); - - if(profile_size < profile_length) - profile_length = profile_size; - - if(profile_size > profile_length) - { - png_free(png_ptr, chunkdata); - png_warning(png_ptr, "Ignoring truncated iCCP profile."); - return; - } - - png_set_iCCP(png_ptr, info_ptr, chunkdata, compression_type, - chunkdata + prefix_length, profile_length); - png_free(png_ptr, chunkdata); -} -#endif /* PNG_READ_iCCP_SUPPORTED */ - -#if defined(PNG_READ_sPLT_SUPPORTED) -void /* PRIVATE */ -png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -/* Note: this does not properly handle chunks that are > 64K under DOS */ -{ - png_bytep chunkdata; - png_bytep entry_start; - png_sPLT_t new_palette; -#ifdef PNG_NO_POINTER_INDEXING - png_sPLT_entryp pp; -#endif - int data_length, entry_size, i; - png_uint_32 skip = 0; - png_size_t slength; - - png_debug(1, "in png_handle_sPLT\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before sPLT"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid sPLT after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - -#ifdef PNG_MAX_MALLOC_64K - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr, "sPLT chunk too large to fit in memory"); - skip = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - - chunkdata = (png_bytep)png_malloc(png_ptr, length + 1); - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunkdata, slength); - - if (png_crc_finish(png_ptr, skip)) - { - png_free(png_ptr, chunkdata); - return; - } - - chunkdata[slength] = 0x00; - - for (entry_start = chunkdata; *entry_start; entry_start++) - /* empty loop to find end of name */ ; - ++entry_start; - - /* a sample depth should follow the separator, and we should be on it */ - if (entry_start > chunkdata + slength) - { - png_free(png_ptr, chunkdata); - png_warning(png_ptr, "malformed sPLT chunk"); - return; - } - - new_palette.depth = *entry_start++; - entry_size = (new_palette.depth == 8 ? 6 : 10); - data_length = (slength - (entry_start - chunkdata)); - - /* integrity-check the data length */ - if (data_length % entry_size) - { - png_free(png_ptr, chunkdata); - png_warning(png_ptr, "sPLT chunk has bad length"); - return; - } - - new_palette.nentries = (png_int_32) ( data_length / entry_size); - if ((png_uint_32) new_palette.nentries > (png_uint_32) (PNG_SIZE_MAX / - png_sizeof(png_sPLT_entry))) - { - png_warning(png_ptr, "sPLT chunk too long"); - return; - } - new_palette.entries = (png_sPLT_entryp)png_malloc_warn( - png_ptr, new_palette.nentries * png_sizeof(png_sPLT_entry)); - if (new_palette.entries == NULL) - { - png_warning(png_ptr, "sPLT chunk requires too much memory"); - return; - } - -#ifndef PNG_NO_POINTER_INDEXING - for (i = 0; i < new_palette.nentries; i++) - { - png_sPLT_entryp pp = new_palette.entries + i; - - if (new_palette.depth == 8) - { - pp->red = *entry_start++; - pp->green = *entry_start++; - pp->blue = *entry_start++; - pp->alpha = *entry_start++; - } - else - { - pp->red = png_get_uint_16(entry_start); entry_start += 2; - pp->green = png_get_uint_16(entry_start); entry_start += 2; - pp->blue = png_get_uint_16(entry_start); entry_start += 2; - pp->alpha = png_get_uint_16(entry_start); entry_start += 2; - } - pp->frequency = png_get_uint_16(entry_start); entry_start += 2; - } -#else - pp = new_palette.entries; - for (i = 0; i < new_palette.nentries; i++) - { - - if (new_palette.depth == 8) - { - pp[i].red = *entry_start++; - pp[i].green = *entry_start++; - pp[i].blue = *entry_start++; - pp[i].alpha = *entry_start++; - } - else - { - pp[i].red = png_get_uint_16(entry_start); entry_start += 2; - pp[i].green = png_get_uint_16(entry_start); entry_start += 2; - pp[i].blue = png_get_uint_16(entry_start); entry_start += 2; - pp[i].alpha = png_get_uint_16(entry_start); entry_start += 2; - } - pp->frequency = png_get_uint_16(entry_start); entry_start += 2; - } -#endif - - /* discard all chunk data except the name and stash that */ - new_palette.name = (png_charp)chunkdata; - - png_set_sPLT(png_ptr, info_ptr, &new_palette, 1); - - png_free(png_ptr, chunkdata); - png_free(png_ptr, new_palette.entries); -} -#endif /* PNG_READ_sPLT_SUPPORTED */ - -#if defined(PNG_READ_tRNS_SUPPORTED) -void /* PRIVATE */ -png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_byte readbuf[PNG_MAX_PALETTE_LENGTH]; - - png_debug(1, "in png_handle_tRNS\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before tRNS"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid tRNS after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) - { - png_warning(png_ptr, "Duplicate tRNS chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) - { - png_byte buf[2]; - - if (length != 2) - { - png_warning(png_ptr, "Incorrect tRNS chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, 2); - png_ptr->num_trans = 1; - png_ptr->trans_values.gray = png_get_uint_16(buf); - } - else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) - { - png_byte buf[6]; - - if (length != 6) - { - png_warning(png_ptr, "Incorrect tRNS chunk length"); - png_crc_finish(png_ptr, length); - return; - } - png_crc_read(png_ptr, buf, (png_size_t)length); - png_ptr->num_trans = 1; - png_ptr->trans_values.red = png_get_uint_16(buf); - png_ptr->trans_values.green = png_get_uint_16(buf + 2); - png_ptr->trans_values.blue = png_get_uint_16(buf + 4); - } - else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - if (!(png_ptr->mode & PNG_HAVE_PLTE)) - { - /* Should be an error, but we can cope with it. */ - png_warning(png_ptr, "Missing PLTE before tRNS"); - } - if (length > (png_uint_32)png_ptr->num_palette || - length > PNG_MAX_PALETTE_LENGTH) - { - png_warning(png_ptr, "Incorrect tRNS chunk length"); - png_crc_finish(png_ptr, length); - return; - } - if (length == 0) - { - png_warning(png_ptr, "Zero length tRNS chunk"); - png_crc_finish(png_ptr, length); - return; - } - png_crc_read(png_ptr, readbuf, (png_size_t)length); - png_ptr->num_trans = (png_uint_16)length; - } - else - { - png_warning(png_ptr, "tRNS chunk not allowed with alpha channel"); - png_crc_finish(png_ptr, length); - return; - } - - if (png_crc_finish(png_ptr, 0)) - { - png_ptr->num_trans = 0; - return; - } - - png_set_tRNS(png_ptr, info_ptr, readbuf, png_ptr->num_trans, - &(png_ptr->trans_values)); -} -#endif - -#if defined(PNG_READ_bKGD_SUPPORTED) -void /* PRIVATE */ -png_handle_bKGD(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_size_t truelen; - png_byte buf[6]; - - png_debug(1, "in png_handle_bKGD\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before bKGD"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid bKGD after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - !(png_ptr->mode & PNG_HAVE_PLTE)) - { - png_warning(png_ptr, "Missing PLTE before bKGD"); - png_crc_finish(png_ptr, length); - return; - } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)) - { - png_warning(png_ptr, "Duplicate bKGD chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - truelen = 1; - else if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) - truelen = 6; - else - truelen = 2; - - if (length != truelen) - { - png_warning(png_ptr, "Incorrect bKGD chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, truelen); - if (png_crc_finish(png_ptr, 0)) - return; - - /* We convert the index value into RGB components so that we can allow - * arbitrary RGB values for background when we have transparency, and - * so it is easy to determine the RGB values of the background color - * from the info_ptr struct. */ - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - png_ptr->background.index = buf[0]; - if(info_ptr->num_palette) - { - if(buf[0] > info_ptr->num_palette) - { - png_warning(png_ptr, "Incorrect bKGD chunk index value"); - return; - } - png_ptr->background.red = - (png_uint_16)png_ptr->palette[buf[0]].red; - png_ptr->background.green = - (png_uint_16)png_ptr->palette[buf[0]].green; - png_ptr->background.blue = - (png_uint_16)png_ptr->palette[buf[0]].blue; - } - } - else if (!(png_ptr->color_type & PNG_COLOR_MASK_COLOR)) /* GRAY */ - { - png_ptr->background.red = - png_ptr->background.green = - png_ptr->background.blue = - png_ptr->background.gray = png_get_uint_16(buf); - } - else - { - png_ptr->background.red = png_get_uint_16(buf); - png_ptr->background.green = png_get_uint_16(buf + 2); - png_ptr->background.blue = png_get_uint_16(buf + 4); - } - - png_set_bKGD(png_ptr, info_ptr, &(png_ptr->background)); -} -#endif - -#if defined(PNG_READ_hIST_SUPPORTED) -void /* PRIVATE */ -png_handle_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - unsigned int num, i; - png_uint_16 readbuf[PNG_MAX_PALETTE_LENGTH]; - - png_debug(1, "in png_handle_hIST\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before hIST"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid hIST after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (!(png_ptr->mode & PNG_HAVE_PLTE)) - { - png_warning(png_ptr, "Missing PLTE before hIST"); - png_crc_finish(png_ptr, length); - return; - } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)) - { - png_warning(png_ptr, "Duplicate hIST chunk"); - png_crc_finish(png_ptr, length); - return; - } - - num = length / 2 ; - if (num != (unsigned int) png_ptr->num_palette || num > - (unsigned int) PNG_MAX_PALETTE_LENGTH) - { - png_warning(png_ptr, "Incorrect hIST chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - for (i = 0; i < num; i++) - { - png_byte buf[2]; - - png_crc_read(png_ptr, buf, 2); - readbuf[i] = png_get_uint_16(buf); - } - - if (png_crc_finish(png_ptr, 0)) - return; - - png_set_hIST(png_ptr, info_ptr, readbuf); -} -#endif - -#if defined(PNG_READ_pHYs_SUPPORTED) -void /* PRIVATE */ -png_handle_pHYs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_byte buf[9]; - png_uint_32 res_x, res_y; - int unit_type; - - png_debug(1, "in png_handle_pHYs\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before pHYs"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid pHYs after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) - { - png_warning(png_ptr, "Duplicate pHYs chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (length != 9) - { - png_warning(png_ptr, "Incorrect pHYs chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, 9); - if (png_crc_finish(png_ptr, 0)) - return; - - res_x = png_get_uint_32(buf); - res_y = png_get_uint_32(buf + 4); - unit_type = buf[8]; - png_set_pHYs(png_ptr, info_ptr, res_x, res_y, unit_type); -} -#endif - -#if defined(PNG_READ_oFFs_SUPPORTED) -void /* PRIVATE */ -png_handle_oFFs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_byte buf[9]; - png_int_32 offset_x, offset_y; - int unit_type; - - png_debug(1, "in png_handle_oFFs\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before oFFs"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid oFFs after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) - { - png_warning(png_ptr, "Duplicate oFFs chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (length != 9) - { - png_warning(png_ptr, "Incorrect oFFs chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, 9); - if (png_crc_finish(png_ptr, 0)) - return; - - offset_x = png_get_int_32(buf); - offset_y = png_get_int_32(buf + 4); - unit_type = buf[8]; - png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y, unit_type); -} -#endif - -#if defined(PNG_READ_pCAL_SUPPORTED) -/* read the pCAL chunk (described in the PNG Extensions document) */ -void /* PRIVATE */ -png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_charp purpose; - png_int_32 X0, X1; - png_byte type, nparams; - png_charp buf, units, endptr; - png_charpp params; - png_size_t slength; - int i; - - png_debug(1, "in png_handle_pCAL\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before pCAL"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid pCAL after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)) - { - png_warning(png_ptr, "Duplicate pCAL chunk"); - png_crc_finish(png_ptr, length); - return; - } - - png_debug1(2, "Allocating and reading pCAL chunk data (%lu bytes)\n", - length + 1); - purpose = (png_charp)png_malloc_warn(png_ptr, length + 1); - if (purpose == NULL) - { - png_warning(png_ptr, "No memory for pCAL purpose."); - return; - } - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)purpose, slength); - - if (png_crc_finish(png_ptr, 0)) - { - png_free(png_ptr, purpose); - return; - } - - purpose[slength] = 0x00; /* null terminate the last string */ - - png_debug(3, "Finding end of pCAL purpose string\n"); - for (buf = purpose; *buf; buf++) - /* empty loop */ ; - - endptr = purpose + slength; - - /* We need to have at least 12 bytes after the purpose string - in order to get the parameter information. */ - if (endptr <= buf + 12) - { - png_warning(png_ptr, "Invalid pCAL data"); - png_free(png_ptr, purpose); - return; - } - - png_debug(3, "Reading pCAL X0, X1, type, nparams, and units\n"); - X0 = png_get_int_32((png_bytep)buf+1); - X1 = png_get_int_32((png_bytep)buf+5); - type = buf[9]; - nparams = buf[10]; - units = buf + 11; - - png_debug(3, "Checking pCAL equation type and number of parameters\n"); - /* Check that we have the right number of parameters for known - equation types. */ - if ((type == PNG_EQUATION_LINEAR && nparams != 2) || - (type == PNG_EQUATION_BASE_E && nparams != 3) || - (type == PNG_EQUATION_ARBITRARY && nparams != 3) || - (type == PNG_EQUATION_HYPERBOLIC && nparams != 4)) - { - png_warning(png_ptr, "Invalid pCAL parameters for equation type"); - png_free(png_ptr, purpose); - return; - } - else if (type >= PNG_EQUATION_LAST) - { - png_warning(png_ptr, "Unrecognized equation type for pCAL chunk"); - } - - for (buf = units; *buf; buf++) - /* Empty loop to move past the units string. */ ; - - png_debug(3, "Allocating pCAL parameters array\n"); - params = (png_charpp)png_malloc_warn(png_ptr, (png_uint_32)(nparams - *png_sizeof(png_charp))) ; - if (params == NULL) - { - png_free(png_ptr, purpose); - png_warning(png_ptr, "No memory for pCAL params."); - return; - } - - /* Get pointers to the start of each parameter string. */ - for (i = 0; i < (int)nparams; i++) - { - buf++; /* Skip the null string terminator from previous parameter. */ - - png_debug1(3, "Reading pCAL parameter %d\n", i); - for (params[i] = buf; *buf != 0x00 && buf <= endptr; buf++) - /* Empty loop to move past each parameter string */ ; - - /* Make sure we haven't run out of data yet */ - if (buf > endptr) - { - png_warning(png_ptr, "Invalid pCAL data"); - png_free(png_ptr, purpose); - png_free(png_ptr, params); - return; - } - } - - png_set_pCAL(png_ptr, info_ptr, purpose, X0, X1, type, nparams, - units, params); - - png_free(png_ptr, purpose); - png_free(png_ptr, params); -} -#endif - -#if defined(PNG_READ_sCAL_SUPPORTED) -/* read the sCAL chunk */ -void /* PRIVATE */ -png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_charp buffer, ep; -#ifdef PNG_FLOATING_POINT_SUPPORTED - double width, height; - png_charp vp; -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - png_charp swidth, sheight; -#endif -#endif - png_size_t slength; - - png_debug(1, "in png_handle_sCAL\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before sCAL"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid sCAL after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sCAL)) - { - png_warning(png_ptr, "Duplicate sCAL chunk"); - png_crc_finish(png_ptr, length); - return; - } - - png_debug1(2, "Allocating and reading sCAL chunk data (%lu bytes)\n", - length + 1); - buffer = (png_charp)png_malloc_warn(png_ptr, length + 1); - if (buffer == NULL) - { - png_warning(png_ptr, "Out of memory while processing sCAL chunk"); - return; - } - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)buffer, slength); - - if (png_crc_finish(png_ptr, 0)) - { - png_free(png_ptr, buffer); - return; - } - - buffer[slength] = 0x00; /* null terminate the last string */ - - ep = buffer + 1; /* skip unit byte */ - -#ifdef PNG_FLOATING_POINT_SUPPORTED - width = png_strtod(png_ptr, ep, &vp); - if (*vp) - { - png_warning(png_ptr, "malformed width string in sCAL chunk"); - return; - } -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - swidth = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1); - if (swidth == NULL) - { - png_warning(png_ptr, "Out of memory while processing sCAL chunk width"); - return; - } - png_memcpy(swidth, ep, (png_size_t)png_strlen(ep)); -#endif -#endif - - for (ep = buffer; *ep; ep++) - /* empty loop */ ; - ep++; - -#ifdef PNG_FLOATING_POINT_SUPPORTED - height = png_strtod(png_ptr, ep, &vp); - if (*vp) - { - png_warning(png_ptr, "malformed height string in sCAL chunk"); - return; - } -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - sheight = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1); - if (swidth == NULL) - { - png_warning(png_ptr, "Out of memory while processing sCAL chunk height"); - return; - } - png_memcpy(sheight, ep, (png_size_t)png_strlen(ep)); -#endif -#endif - - if (buffer + slength < ep -#ifdef PNG_FLOATING_POINT_SUPPORTED - || width <= 0. || height <= 0. -#endif - ) - { - png_warning(png_ptr, "Invalid sCAL data"); - png_free(png_ptr, buffer); -#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) - png_free(png_ptr, swidth); - png_free(png_ptr, sheight); -#endif - return; - } - - -#ifdef PNG_FLOATING_POINT_SUPPORTED - png_set_sCAL(png_ptr, info_ptr, buffer[0], width, height); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - png_set_sCAL_s(png_ptr, info_ptr, buffer[0], swidth, sheight); -#endif -#endif - - png_free(png_ptr, buffer); -#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) - png_free(png_ptr, swidth); - png_free(png_ptr, sheight); -#endif -} -#endif - -#if defined(PNG_READ_tIME_SUPPORTED) -void /* PRIVATE */ -png_handle_tIME(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_byte buf[7]; - png_time mod_time; - - png_debug(1, "in png_handle_tIME\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Out of place tIME chunk"); - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)) - { - png_warning(png_ptr, "Duplicate tIME chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (png_ptr->mode & PNG_HAVE_IDAT) - png_ptr->mode |= PNG_AFTER_IDAT; - - if (length != 7) - { - png_warning(png_ptr, "Incorrect tIME chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, 7); - if (png_crc_finish(png_ptr, 0)) - return; - - mod_time.second = buf[6]; - mod_time.minute = buf[5]; - mod_time.hour = buf[4]; - mod_time.day = buf[3]; - mod_time.month = buf[2]; - mod_time.year = png_get_uint_16(buf); - - png_set_tIME(png_ptr, info_ptr, &mod_time); -} -#endif - -#if defined(PNG_READ_tEXt_SUPPORTED) -/* Note: this does not properly handle chunks that are > 64K under DOS */ -void /* PRIVATE */ -png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_textp text_ptr; - png_charp key; - png_charp text; - png_uint_32 skip = 0; - png_size_t slength; - int ret; - - png_debug(1, "in png_handle_tEXt\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before tEXt"); - - if (png_ptr->mode & PNG_HAVE_IDAT) - png_ptr->mode |= PNG_AFTER_IDAT; - -#ifdef PNG_MAX_MALLOC_64K - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr, "tEXt chunk too large to fit in memory"); - skip = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - - key = (png_charp)png_malloc_warn(png_ptr, length + 1); - if (key == NULL) - { - png_warning(png_ptr, "No memory to process text chunk."); - return; - } - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)key, slength); - - if (png_crc_finish(png_ptr, skip)) - { - png_free(png_ptr, key); - return; - } - - key[slength] = 0x00; - - for (text = key; *text; text++) - /* empty loop to find end of key */ ; - - if (text != key + slength) - text++; - - text_ptr = (png_textp)png_malloc_warn(png_ptr, - (png_uint_32)png_sizeof(png_text)); - if (text_ptr == NULL) - { - png_warning(png_ptr, "Not enough memory to process text chunk."); - png_free(png_ptr, key); - return; - } - text_ptr->compression = PNG_TEXT_COMPRESSION_NONE; - text_ptr->key = key; -#ifdef PNG_iTXt_SUPPORTED - text_ptr->lang = NULL; - text_ptr->lang_key = NULL; - text_ptr->itxt_length = 0; -#endif - text_ptr->text = text; - text_ptr->text_length = png_strlen(text); - - ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1); - - png_free(png_ptr, key); - png_free(png_ptr, text_ptr); - if (ret) - png_warning(png_ptr, "Insufficient memory to process text chunk."); -} -#endif - -#if defined(PNG_READ_zTXt_SUPPORTED) -/* note: this does not correctly handle chunks that are > 64K under DOS */ -void /* PRIVATE */ -png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_textp text_ptr; - png_charp chunkdata; - png_charp text; - int comp_type; - int ret; - png_size_t slength, prefix_len, data_len; - - png_debug(1, "in png_handle_zTXt\n"); - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before zTXt"); - - if (png_ptr->mode & PNG_HAVE_IDAT) - png_ptr->mode |= PNG_AFTER_IDAT; - -#ifdef PNG_MAX_MALLOC_64K - /* We will no doubt have problems with chunks even half this size, but - there is no hard and fast rule to tell us where to stop. */ - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr,"zTXt chunk too large to fit in memory"); - png_crc_finish(png_ptr, length); - return; - } -#endif - - chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); - if (chunkdata == NULL) - { - png_warning(png_ptr,"Out of memory processing zTXt chunk."); - return; - } - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunkdata, slength); - if (png_crc_finish(png_ptr, 0)) - { - png_free(png_ptr, chunkdata); - return; - } - - chunkdata[slength] = 0x00; - - for (text = chunkdata; *text; text++) - /* empty loop */ ; - - /* zTXt must have some text after the chunkdataword */ - if (text == chunkdata + slength) - { - comp_type = PNG_TEXT_COMPRESSION_NONE; - png_warning(png_ptr, "Zero length zTXt chunk"); - } - else - { - comp_type = *(++text); - if (comp_type != PNG_TEXT_COMPRESSION_zTXt) - { - png_warning(png_ptr, "Unknown compression type in zTXt chunk"); - comp_type = PNG_TEXT_COMPRESSION_zTXt; - } - text++; /* skip the compression_method byte */ - } - prefix_len = text - chunkdata; - - chunkdata = (png_charp)png_decompress_chunk(png_ptr, comp_type, chunkdata, - (png_size_t)length, prefix_len, &data_len); - - text_ptr = (png_textp)png_malloc_warn(png_ptr, - (png_uint_32)png_sizeof(png_text)); - if (text_ptr == NULL) - { - png_warning(png_ptr,"Not enough memory to process zTXt chunk."); - png_free(png_ptr, chunkdata); - return; - } - text_ptr->compression = comp_type; - text_ptr->key = chunkdata; -#ifdef PNG_iTXt_SUPPORTED - text_ptr->lang = NULL; - text_ptr->lang_key = NULL; - text_ptr->itxt_length = 0; -#endif - text_ptr->text = chunkdata + prefix_len; - text_ptr->text_length = data_len; - - ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1); - - png_free(png_ptr, text_ptr); - png_free(png_ptr, chunkdata); - if (ret) - png_error(png_ptr, "Insufficient memory to store zTXt chunk."); -} -#endif - -#if defined(PNG_READ_iTXt_SUPPORTED) -/* note: this does not correctly handle chunks that are > 64K under DOS */ -void /* PRIVATE */ -png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_textp text_ptr; - png_charp chunkdata; - png_charp key, lang, text, lang_key; - int comp_flag; - int comp_type = 0; - int ret; - png_size_t slength, prefix_len, data_len; - - png_debug(1, "in png_handle_iTXt\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before iTXt"); - - if (png_ptr->mode & PNG_HAVE_IDAT) - png_ptr->mode |= PNG_AFTER_IDAT; - -#ifdef PNG_MAX_MALLOC_64K - /* We will no doubt have problems with chunks even half this size, but - there is no hard and fast rule to tell us where to stop. */ - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr,"iTXt chunk too large to fit in memory"); - png_crc_finish(png_ptr, length); - return; - } -#endif - - chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); - if (chunkdata == NULL) - { - png_warning(png_ptr, "No memory to process iTXt chunk."); - return; - } - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunkdata, slength); - if (png_crc_finish(png_ptr, 0)) - { - png_free(png_ptr, chunkdata); - return; - } - - chunkdata[slength] = 0x00; - - for (lang = chunkdata; *lang; lang++) - /* empty loop */ ; - lang++; /* skip NUL separator */ - - /* iTXt must have a language tag (possibly empty), two compression bytes, - translated keyword (possibly empty), and possibly some text after the - keyword */ - - if (lang >= chunkdata + slength) - { - comp_flag = PNG_TEXT_COMPRESSION_NONE; - png_warning(png_ptr, "Zero length iTXt chunk"); - } - else - { - comp_flag = *lang++; - comp_type = *lang++; - } - - for (lang_key = lang; *lang_key; lang_key++) - /* empty loop */ ; - lang_key++; /* skip NUL separator */ - - for (text = lang_key; *text; text++) - /* empty loop */ ; - text++; /* skip NUL separator */ - - prefix_len = text - chunkdata; - - key=chunkdata; - if (comp_flag) - chunkdata = png_decompress_chunk(png_ptr, comp_type, chunkdata, - (size_t)length, prefix_len, &data_len); - else - data_len=png_strlen(chunkdata + prefix_len); - text_ptr = (png_textp)png_malloc_warn(png_ptr, - (png_uint_32)png_sizeof(png_text)); - if (text_ptr == NULL) - { - png_warning(png_ptr,"Not enough memory to process iTXt chunk."); - png_free(png_ptr, chunkdata); - return; - } - text_ptr->compression = (int)comp_flag + 1; - text_ptr->lang_key = chunkdata+(lang_key-key); - text_ptr->lang = chunkdata+(lang-key); - text_ptr->itxt_length = data_len; - text_ptr->text_length = 0; - text_ptr->key = chunkdata; - text_ptr->text = chunkdata + prefix_len; - - ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1); - - png_free(png_ptr, text_ptr); - png_free(png_ptr, chunkdata); - if (ret) - png_error(png_ptr, "Insufficient memory to store iTXt chunk."); -} -#endif - -/* This function is called when we haven't found a handler for a - chunk. If there isn't a problem with the chunk itself (ie bad - chunk name, CRC, or a critical chunk), the chunk is silently ignored - -- unless the PNG_FLAG_UNKNOWN_CHUNKS_SUPPORTED flag is on in which - case it will be saved away to be written out later. */ -void /* PRIVATE */ -png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_uint_32 skip = 0; - - png_debug(1, "in png_handle_unknown\n"); - - if (png_ptr->mode & PNG_HAVE_IDAT) - { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IDAT; -#endif - if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) /* not an IDAT */ - png_ptr->mode |= PNG_AFTER_IDAT; - } - - png_check_chunk_name(png_ptr, png_ptr->chunk_name); - - if (!(png_ptr->chunk_name[0] & 0x20)) - { -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != - PNG_HANDLE_CHUNK_ALWAYS -#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) - && png_ptr->read_user_chunk_fn == NULL -#endif - ) -#endif - png_chunk_error(png_ptr, "unknown critical chunk"); - } - -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - if ((png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS) || - (png_ptr->read_user_chunk_fn != NULL)) - { -#ifdef PNG_MAX_MALLOC_64K - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr, "unknown chunk too large to fit in memory"); - skip = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - png_strcpy((png_charp)png_ptr->unknown_chunk.name, - (png_charp)png_ptr->chunk_name); - png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr, length); - png_ptr->unknown_chunk.size = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data, length); -#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) - if(png_ptr->read_user_chunk_fn != NULL) - { - /* callback to user unknown chunk handler */ - int ret; - ret = (*(png_ptr->read_user_chunk_fn)) - (png_ptr, &png_ptr->unknown_chunk); - if (ret < 0) - png_chunk_error(png_ptr, "error in user chunk"); - if (ret == 0) - { - if (!(png_ptr->chunk_name[0] & 0x20)) - if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != - PNG_HANDLE_CHUNK_ALWAYS) - png_chunk_error(png_ptr, "unknown critical chunk"); - png_set_unknown_chunks(png_ptr, info_ptr, - &png_ptr->unknown_chunk, 1); - } - } -#else - png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1); -#endif - png_free(png_ptr, png_ptr->unknown_chunk.data); - png_ptr->unknown_chunk.data = NULL; - } - else -#endif - skip = length; - - png_crc_finish(png_ptr, skip); - -#if !defined(PNG_READ_USER_CHUNKS_SUPPORTED) - if (&info_ptr == NULL) /* quiet compiler warnings about unused info_ptr */ - return; -#endif -} - -/* This function is called to verify that a chunk name is valid. - This function can't have the "critical chunk check" incorporated - into it, since in the future we will need to be able to call user - functions to handle unknown critical chunks after we check that - the chunk name itself is valid. */ - -#define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97)) - -void /* PRIVATE */ -png_check_chunk_name(png_structp png_ptr, png_bytep chunk_name) -{ - png_debug(1, "in png_check_chunk_name\n"); - if (isnonalpha(chunk_name[0]) || isnonalpha(chunk_name[1]) || - isnonalpha(chunk_name[2]) || isnonalpha(chunk_name[3])) - { - png_chunk_error(png_ptr, "invalid chunk type"); - } -} - -/* Combines the row recently read in with the existing pixels in the - row. This routine takes care of alpha and transparency if requested. - This routine also handles the two methods of progressive display - of interlaced images, depending on the mask value. - The mask value describes which pixels are to be combined with - the row. The pattern always repeats every 8 pixels, so just 8 - bits are needed. A one indicates the pixel is to be combined, - a zero indicates the pixel is to be skipped. This is in addition - to any alpha or transparency value associated with the pixel. If - you want all pixels to be combined, pass 0xff (255) in mask. */ -#ifndef PNG_HAVE_MMX_COMBINE_ROW -void /* PRIVATE */ -png_combine_row(png_structp png_ptr, png_bytep row, int mask) -{ - png_debug(1,"in png_combine_row\n"); - if (mask == 0xff) - { - png_memcpy(row, png_ptr->row_buf + 1, - PNG_ROWBYTES(png_ptr->row_info.pixel_depth, png_ptr->width)); - } - else - { - switch (png_ptr->row_info.pixel_depth) - { - case 1: - { - png_bytep sp = png_ptr->row_buf + 1; - png_bytep dp = row; - int s_inc, s_start, s_end; - int m = 0x80; - int shift; - png_uint_32 i; - png_uint_32 row_width = png_ptr->width; - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 7; - s_inc = 1; - } - else -#endif - { - s_start = 7; - s_end = 0; - s_inc = -1; - } - - shift = s_start; - - for (i = 0; i < row_width; i++) - { - if (m & mask) - { - int value; - - value = (*sp >> shift) & 0x01; - *dp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - case 2: - { - png_bytep sp = png_ptr->row_buf + 1; - png_bytep dp = row; - int s_start, s_end, s_inc; - int m = 0x80; - int shift; - png_uint_32 i; - png_uint_32 row_width = png_ptr->width; - int value; - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 6; - s_inc = 2; - } - else -#endif - { - s_start = 6; - s_end = 0; - s_inc = -2; - } - - shift = s_start; - - for (i = 0; i < row_width; i++) - { - if (m & mask) - { - value = (*sp >> shift) & 0x03; - *dp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - case 4: - { - png_bytep sp = png_ptr->row_buf + 1; - png_bytep dp = row; - int s_start, s_end, s_inc; - int m = 0x80; - int shift; - png_uint_32 i; - png_uint_32 row_width = png_ptr->width; - int value; - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 4; - s_inc = 4; - } - else -#endif - { - s_start = 4; - s_end = 0; - s_inc = -4; - } - shift = s_start; - - for (i = 0; i < row_width; i++) - { - if (m & mask) - { - value = (*sp >> shift) & 0xf; - *dp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - default: - { - png_bytep sp = png_ptr->row_buf + 1; - png_bytep dp = row; - png_size_t pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); - png_uint_32 i; - png_uint_32 row_width = png_ptr->width; - png_byte m = 0x80; - - - for (i = 0; i < row_width; i++) - { - if (m & mask) - { - png_memcpy(dp, sp, pixel_bytes); - } - - sp += pixel_bytes; - dp += pixel_bytes; - - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - } - } -} -#endif /* !PNG_HAVE_MMX_COMBINE_ROW */ - -#ifdef PNG_READ_INTERLACING_SUPPORTED -#ifndef PNG_HAVE_MMX_READ_INTERLACE /* else in pngvcrd.c, pnggccrd.c */ -/* OLD pre-1.0.9 interface: -void png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, - png_uint_32 transformations) - */ -void /* PRIVATE */ -png_do_read_interlace(png_structp png_ptr) -{ - png_row_infop row_info = &(png_ptr->row_info); - png_bytep row = png_ptr->row_buf + 1; - int pass = png_ptr->pass; - png_uint_32 transformations = png_ptr->transformations; -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - /* offset to next interlace block */ - const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; -#endif - - png_debug(1,"in png_do_read_interlace (stock C version)\n"); - if (row != NULL && row_info != NULL) - { - png_uint_32 final_width; - - final_width = row_info->width * png_pass_inc[pass]; - - switch (row_info->pixel_depth) - { - case 1: - { - png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 3); - png_bytep dp = row + (png_size_t)((final_width - 1) >> 3); - int sshift, dshift; - int s_start, s_end, s_inc; - int jstop = png_pass_inc[pass]; - png_byte v; - png_uint_32 i; - int j; - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (int)((row_info->width + 7) & 0x07); - dshift = (int)((final_width + 7) & 0x07); - s_start = 7; - s_end = 0; - s_inc = -1; - } - else -#endif - { - sshift = 7 - (int)((row_info->width + 7) & 0x07); - dshift = 7 - (int)((final_width + 7) & 0x07); - s_start = 0; - s_end = 7; - s_inc = 1; - } - - for (i = 0; i < row_info->width; i++) - { - v = (png_byte)((*sp >> sshift) & 0x01); - for (j = 0; j < jstop; j++) - { - *dp &= (png_byte)((0x7f7f >> (7 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - case 2: - { - png_bytep sp = row + (png_uint_32)((row_info->width - 1) >> 2); - png_bytep dp = row + (png_uint_32)((final_width - 1) >> 2); - int sshift, dshift; - int s_start, s_end, s_inc; - int jstop = png_pass_inc[pass]; - png_uint_32 i; - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (int)(((row_info->width + 3) & 0x03) << 1); - dshift = (int)(((final_width + 3) & 0x03) << 1); - s_start = 6; - s_end = 0; - s_inc = -2; - } - else -#endif - { - sshift = (int)((3 - ((row_info->width + 3) & 0x03)) << 1); - dshift = (int)((3 - ((final_width + 3) & 0x03)) << 1); - s_start = 0; - s_end = 6; - s_inc = 2; - } - - for (i = 0; i < row_info->width; i++) - { - png_byte v; - int j; - - v = (png_byte)((*sp >> sshift) & 0x03); - for (j = 0; j < jstop; j++) - { - *dp &= (png_byte)((0x3f3f >> (6 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - case 4: - { - png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 1); - png_bytep dp = row + (png_size_t)((final_width - 1) >> 1); - int sshift, dshift; - int s_start, s_end, s_inc; - png_uint_32 i; - int jstop = png_pass_inc[pass]; - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (int)(((row_info->width + 1) & 0x01) << 2); - dshift = (int)(((final_width + 1) & 0x01) << 2); - s_start = 4; - s_end = 0; - s_inc = -4; - } - else -#endif - { - sshift = (int)((1 - ((row_info->width + 1) & 0x01)) << 2); - dshift = (int)((1 - ((final_width + 1) & 0x01)) << 2); - s_start = 0; - s_end = 4; - s_inc = 4; - } - - for (i = 0; i < row_info->width; i++) - { - png_byte v = (png_byte)((*sp >> sshift) & 0xf); - int j; - - for (j = 0; j < jstop; j++) - { - *dp &= (png_byte)((0xf0f >> (4 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - default: - { - png_size_t pixel_bytes = (row_info->pixel_depth >> 3); - png_bytep sp = row + (png_size_t)(row_info->width - 1) * pixel_bytes; - png_bytep dp = row + (png_size_t)(final_width - 1) * pixel_bytes; - - int jstop = png_pass_inc[pass]; - png_uint_32 i; - - for (i = 0; i < row_info->width; i++) - { - png_byte v[8]; - int j; - - png_memcpy(v, sp, pixel_bytes); - for (j = 0; j < jstop; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sp -= pixel_bytes; - } - break; - } - } - row_info->width = final_width; - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,final_width); - } -#if !defined(PNG_READ_PACKSWAP_SUPPORTED) - if (&transformations == NULL) /* silence compiler warning */ - return; -#endif -} -#endif /* !PNG_HAVE_MMX_READ_INTERLACE */ -#endif /* PNG_READ_INTERLACING_SUPPORTED */ - -#ifndef PNG_HAVE_MMX_READ_FILTER_ROW -void /* PRIVATE */ -png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row, - png_bytep prev_row, int filter) -{ - png_debug(1, "in png_read_filter_row\n"); - png_debug2(2,"row = %lu, filter = %d\n", png_ptr->row_number, filter); - switch (filter) - { - case PNG_FILTER_VALUE_NONE: - break; - case PNG_FILTER_VALUE_SUB: - { - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_bytep rp = row + bpp; - png_bytep lp = row; - - for (i = bpp; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*lp++)) & 0xff); - rp++; - } - break; - } - case PNG_FILTER_VALUE_UP: - { - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_bytep rp = row; - png_bytep pp = prev_row; - - for (i = 0; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); - rp++; - } - break; - } - case PNG_FILTER_VALUE_AVG: - { - png_uint_32 i; - png_bytep rp = row; - png_bytep pp = prev_row; - png_bytep lp = row; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_uint_32 istop = row_info->rowbytes - bpp; - - for (i = 0; i < bpp; i++) - { - *rp = (png_byte)(((int)(*rp) + - ((int)(*pp++) / 2 )) & 0xff); - rp++; - } - - for (i = 0; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + - (int)(*pp++ + *lp++) / 2 ) & 0xff); - rp++; - } - break; - } - case PNG_FILTER_VALUE_PAETH: - { - png_uint_32 i; - png_bytep rp = row; - png_bytep pp = prev_row; - png_bytep lp = row; - png_bytep cp = prev_row; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_uint_32 istop=row_info->rowbytes - bpp; - - for (i = 0; i < bpp; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); - rp++; - } - - for (i = 0; i < istop; i++) /* use leftover rp,pp */ - { - int a, b, c, pa, pb, pc, p; - - a = *lp++; - b = *pp++; - c = *cp++; - - p = b - c; - pc = a - c; - -#ifdef PNG_USE_ABS - pa = abs(p); - pb = abs(pc); - pc = abs(p + pc); -#else - pa = p < 0 ? -p : p; - pb = pc < 0 ? -pc : pc; - pc = (p + pc) < 0 ? -(p + pc) : p + pc; -#endif - - /* - if (pa <= pb && pa <= pc) - p = a; - else if (pb <= pc) - p = b; - else - p = c; - */ - - p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; - - *rp = (png_byte)(((int)(*rp) + p) & 0xff); - rp++; - } - break; - } - default: - png_warning(png_ptr, "Ignoring bad adaptive filter type"); - *row=0; - break; - } -} -#endif /* !PNG_HAVE_MMX_READ_FILTER_ROW */ - -void /* PRIVATE */ -png_read_finish_row(png_structp png_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* start of interlace block */ - const int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - - /* offset to next interlace block */ - const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - - /* start of interlace block in the y direction */ - const int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - - /* offset to next interlace block in the y direction */ - const int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; -#endif - - png_debug(1, "in png_read_finish_row\n"); - png_ptr->row_number++; - if (png_ptr->row_number < png_ptr->num_rows) - return; - - if (png_ptr->interlaced) - { - png_ptr->row_number = 0; - png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1); - do - { - png_ptr->pass++; - if (png_ptr->pass >= 7) - break; - png_ptr->iwidth = (png_ptr->width + - png_pass_inc[png_ptr->pass] - 1 - - png_pass_start[png_ptr->pass]) / - png_pass_inc[png_ptr->pass]; - - png_ptr->irowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, - png_ptr->iwidth) + 1; - - if (!(png_ptr->transformations & PNG_INTERLACE)) - { - png_ptr->num_rows = (png_ptr->height + - png_pass_yinc[png_ptr->pass] - 1 - - png_pass_ystart[png_ptr->pass]) / - png_pass_yinc[png_ptr->pass]; - if (!(png_ptr->num_rows)) - continue; - } - else /* if (png_ptr->transformations & PNG_INTERLACE) */ - break; - } while (png_ptr->iwidth == 0); - - if (png_ptr->pass < 7) - return; - } - - if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) - { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IDAT; -#endif - char extra; - int ret; - - png_ptr->zstream.next_out = (Byte *)&extra; - png_ptr->zstream.avail_out = (uInt)1; - for(;;) - { - if (!(png_ptr->zstream.avail_in)) - { - while (!png_ptr->idat_size) - { - png_byte chunk_length[4]; - - png_crc_finish(png_ptr, 0); - - png_read_data(png_ptr, chunk_length, 4); - png_ptr->idat_size = png_get_uint_31(png_ptr, chunk_length); - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); - if (png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) - png_error(png_ptr, "Not enough image data"); - - } - png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size; - png_ptr->zstream.next_in = png_ptr->zbuf; - if (png_ptr->zbuf_size > png_ptr->idat_size) - png_ptr->zstream.avail_in = (uInt)png_ptr->idat_size; - png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zstream.avail_in); - png_ptr->idat_size -= png_ptr->zstream.avail_in; - } - ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); - if (ret == Z_STREAM_END) - { - if (!(png_ptr->zstream.avail_out) || png_ptr->zstream.avail_in || - png_ptr->idat_size) - png_warning(png_ptr, "Extra compressed data"); - png_ptr->mode |= PNG_AFTER_IDAT; - png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; - break; - } - if (ret != Z_OK) - png_error(png_ptr, png_ptr->zstream.msg ? png_ptr->zstream.msg : - "Decompression Error"); - - if (!(png_ptr->zstream.avail_out)) - { - png_warning(png_ptr, "Extra compressed data."); - png_ptr->mode |= PNG_AFTER_IDAT; - png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; - break; - } - - } - png_ptr->zstream.avail_out = 0; - } - - if (png_ptr->idat_size || png_ptr->zstream.avail_in) - png_warning(png_ptr, "Extra compression data"); - - inflateReset(&png_ptr->zstream); - - png_ptr->mode |= PNG_AFTER_IDAT; -} - -void /* PRIVATE */ -png_read_start_row(png_structp png_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* start of interlace block */ - const int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - - /* offset to next interlace block */ - const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - - /* start of interlace block in the y direction */ - const int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - - /* offset to next interlace block in the y direction */ - const int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; -#endif - - int max_pixel_depth; - png_uint_32 row_bytes; - - png_debug(1, "in png_read_start_row\n"); - png_ptr->zstream.avail_in = 0; - png_init_read_transformations(png_ptr); - if (png_ptr->interlaced) - { - if (!(png_ptr->transformations & PNG_INTERLACE)) - png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 - - png_pass_ystart[0]) / png_pass_yinc[0]; - else - png_ptr->num_rows = png_ptr->height; - - png_ptr->iwidth = (png_ptr->width + - png_pass_inc[png_ptr->pass] - 1 - - png_pass_start[png_ptr->pass]) / - png_pass_inc[png_ptr->pass]; - - row_bytes = PNG_ROWBYTES(png_ptr->pixel_depth,png_ptr->iwidth) + 1; - - png_ptr->irowbytes = (png_size_t)row_bytes; - if((png_uint_32)png_ptr->irowbytes != row_bytes) - png_error(png_ptr, "Rowbytes overflow in png_read_start_row"); - } - else - { - png_ptr->num_rows = png_ptr->height; - png_ptr->iwidth = png_ptr->width; - png_ptr->irowbytes = png_ptr->rowbytes + 1; - } - max_pixel_depth = png_ptr->pixel_depth; - -#if defined(PNG_READ_PACK_SUPPORTED) - if ((png_ptr->transformations & PNG_PACK) && png_ptr->bit_depth < 8) - max_pixel_depth = 8; -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) - if (png_ptr->transformations & PNG_EXPAND) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - if (png_ptr->num_trans) - max_pixel_depth = 32; - else - max_pixel_depth = 24; - } - else if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) - { - if (max_pixel_depth < 8) - max_pixel_depth = 8; - if (png_ptr->num_trans) - max_pixel_depth *= 2; - } - else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) - { - if (png_ptr->num_trans) - { - max_pixel_depth *= 4; - max_pixel_depth /= 3; - } - } - } -#endif - -#if defined(PNG_READ_FILLER_SUPPORTED) - if (png_ptr->transformations & (PNG_FILLER)) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - max_pixel_depth = 32; - else if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) - { - if (max_pixel_depth <= 8) - max_pixel_depth = 16; - else - max_pixel_depth = 32; - } - else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) - { - if (max_pixel_depth <= 32) - max_pixel_depth = 32; - else - max_pixel_depth = 64; - } - } -#endif - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) - if (png_ptr->transformations & PNG_GRAY_TO_RGB) - { - if ( -#if defined(PNG_READ_EXPAND_SUPPORTED) - (png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND)) || -#endif -#if defined(PNG_READ_FILLER_SUPPORTED) - (png_ptr->transformations & (PNG_FILLER)) || -#endif - png_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - { - if (max_pixel_depth <= 16) - max_pixel_depth = 32; - else - max_pixel_depth = 64; - } - else - { - if (max_pixel_depth <= 8) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - max_pixel_depth = 32; - else - max_pixel_depth = 24; - } - else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - max_pixel_depth = 64; - else - max_pixel_depth = 48; - } - } -#endif - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) && \ -defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) - if(png_ptr->transformations & PNG_USER_TRANSFORM) - { - int user_pixel_depth=png_ptr->user_transform_depth* - png_ptr->user_transform_channels; - if(user_pixel_depth > max_pixel_depth) - max_pixel_depth=user_pixel_depth; - } -#endif - - /* align the width on the next larger 8 pixels. Mainly used - for interlacing */ - row_bytes = ((png_ptr->width + 7) & ~((png_uint_32)7)); - /* calculate the maximum bytes needed, adding a byte and a pixel - for safety's sake */ - row_bytes = PNG_ROWBYTES(max_pixel_depth,row_bytes) + - 1 + ((max_pixel_depth + 7) >> 3); -#ifdef PNG_MAX_MALLOC_64K - if (row_bytes > (png_uint_32)65536L) - png_error(png_ptr, "This image requires a row greater than 64KB"); -#endif - png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes+64); - png_ptr->row_buf = png_ptr->big_row_buf+32; -#if defined(PNG_DEBUG) && defined(PNG_USE_PNGGCCRD) - png_ptr->row_buf_size = row_bytes; -#endif - -#ifdef PNG_MAX_MALLOC_64K - if ((png_uint_32)png_ptr->rowbytes + 1 > (png_uint_32)65536L) - png_error(png_ptr, "This image requires a row greater than 64KB"); -#endif - if ((png_uint_32)png_ptr->rowbytes > (png_uint_32)(PNG_SIZE_MAX - 1)) - png_error(png_ptr, "Row has too many bytes to allocate in memory."); - png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)( - png_ptr->rowbytes + 1)); - - png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1); - - png_debug1(3, "width = %lu,\n", png_ptr->width); - png_debug1(3, "height = %lu,\n", png_ptr->height); - png_debug1(3, "iwidth = %lu,\n", png_ptr->iwidth); - png_debug1(3, "num_rows = %lu\n", png_ptr->num_rows); - png_debug1(3, "rowbytes = %lu,\n", png_ptr->rowbytes); - png_debug1(3, "irowbytes = %lu,\n", png_ptr->irowbytes); - - png_ptr->flags |= PNG_FLAG_ROW_INIT; -} -#endif /* PNG_READ_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/pngset.c b/irrlicht-1.6/source/Irrlicht/libpng/pngset.c deleted file mode 100644 index 9cf615018..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/pngset.c +++ /dev/null @@ -1,1271 +0,0 @@ - -/* pngset.c - storage of image information into info struct - * - * Last changed in libpng 1.2.17 May 15, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * The functions here are used during reads to store data from the file - * into the info struct, and during writes to store application data - * into the info struct for writing into the file. This abstracts the - * info struct and allows us to change the structure in the future. - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) - -#if defined(PNG_bKGD_SUPPORTED) -void PNGAPI -png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background) -{ - png_debug1(1, "in %s storage function\n", "bKGD"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - png_memcpy(&(info_ptr->background), background, png_sizeof(png_color_16)); - info_ptr->valid |= PNG_INFO_bKGD; -} -#endif - -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -void PNGAPI -png_set_cHRM(png_structp png_ptr, png_infop info_ptr, - double white_x, double white_y, double red_x, double red_y, - double green_x, double green_y, double blue_x, double blue_y) -{ - png_debug1(1, "in %s storage function\n", "cHRM"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - if (white_x < 0.0 || white_y < 0.0 || - red_x < 0.0 || red_y < 0.0 || - green_x < 0.0 || green_y < 0.0 || - blue_x < 0.0 || blue_y < 0.0) - { - png_warning(png_ptr, - "Ignoring attempt to set negative chromaticity value"); - return; - } - if (white_x > 21474.83 || white_y > 21474.83 || - red_x > 21474.83 || red_y > 21474.83 || - green_x > 21474.83 || green_y > 21474.83 || - blue_x > 21474.83 || blue_y > 21474.83) - { - png_warning(png_ptr, - "Ignoring attempt to set chromaticity value exceeding 21474.83"); - return; - } - - info_ptr->x_white = (float)white_x; - info_ptr->y_white = (float)white_y; - info_ptr->x_red = (float)red_x; - info_ptr->y_red = (float)red_y; - info_ptr->x_green = (float)green_x; - info_ptr->y_green = (float)green_y; - info_ptr->x_blue = (float)blue_x; - info_ptr->y_blue = (float)blue_y; -#ifdef PNG_FIXED_POINT_SUPPORTED - info_ptr->int_x_white = (png_fixed_point)(white_x*100000.+0.5); - info_ptr->int_y_white = (png_fixed_point)(white_y*100000.+0.5); - info_ptr->int_x_red = (png_fixed_point)( red_x*100000.+0.5); - info_ptr->int_y_red = (png_fixed_point)( red_y*100000.+0.5); - info_ptr->int_x_green = (png_fixed_point)(green_x*100000.+0.5); - info_ptr->int_y_green = (png_fixed_point)(green_y*100000.+0.5); - info_ptr->int_x_blue = (png_fixed_point)( blue_x*100000.+0.5); - info_ptr->int_y_blue = (png_fixed_point)( blue_y*100000.+0.5); -#endif - info_ptr->valid |= PNG_INFO_cHRM; -} -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -void PNGAPI -png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr, - png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x, - png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y, - png_fixed_point blue_x, png_fixed_point blue_y) -{ - png_debug1(1, "in %s storage function\n", "cHRM"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - if (white_x < 0 || white_y < 0 || - red_x < 0 || red_y < 0 || - green_x < 0 || green_y < 0 || - blue_x < 0 || blue_y < 0) - { - png_warning(png_ptr, - "Ignoring attempt to set negative chromaticity value"); - return; - } -#ifdef PNG_FLOATING_POINT_SUPPORTED - if (white_x > (double) PNG_UINT_31_MAX || - white_y > (double) PNG_UINT_31_MAX || - red_x > (double) PNG_UINT_31_MAX || - red_y > (double) PNG_UINT_31_MAX || - green_x > (double) PNG_UINT_31_MAX || - green_y > (double) PNG_UINT_31_MAX || - blue_x > (double) PNG_UINT_31_MAX || - blue_y > (double) PNG_UINT_31_MAX) -#else - if (white_x > (png_fixed_point) PNG_UINT_31_MAX/100000L || - white_y > (png_fixed_point) PNG_UINT_31_MAX/100000L || - red_x > (png_fixed_point) PNG_UINT_31_MAX/100000L || - red_y > (png_fixed_point) PNG_UINT_31_MAX/100000L || - green_x > (png_fixed_point) PNG_UINT_31_MAX/100000L || - green_y > (png_fixed_point) PNG_UINT_31_MAX/100000L || - blue_x > (png_fixed_point) PNG_UINT_31_MAX/100000L || - blue_y > (png_fixed_point) PNG_UINT_31_MAX/100000L) -#endif - { - png_warning(png_ptr, - "Ignoring attempt to set chromaticity value exceeding 21474.83"); - return; - } - info_ptr->int_x_white = white_x; - info_ptr->int_y_white = white_y; - info_ptr->int_x_red = red_x; - info_ptr->int_y_red = red_y; - info_ptr->int_x_green = green_x; - info_ptr->int_y_green = green_y; - info_ptr->int_x_blue = blue_x; - info_ptr->int_y_blue = blue_y; -#ifdef PNG_FLOATING_POINT_SUPPORTED - info_ptr->x_white = (float)(white_x/100000.); - info_ptr->y_white = (float)(white_y/100000.); - info_ptr->x_red = (float)( red_x/100000.); - info_ptr->y_red = (float)( red_y/100000.); - info_ptr->x_green = (float)(green_x/100000.); - info_ptr->y_green = (float)(green_y/100000.); - info_ptr->x_blue = (float)( blue_x/100000.); - info_ptr->y_blue = (float)( blue_y/100000.); -#endif - info_ptr->valid |= PNG_INFO_cHRM; -} -#endif -#endif - -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -void PNGAPI -png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma) -{ - double gamma; - png_debug1(1, "in %s storage function\n", "gAMA"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - /* Check for overflow */ - if (file_gamma > 21474.83) - { - png_warning(png_ptr, "Limiting gamma to 21474.83"); - gamma=21474.83; - } - else - gamma=file_gamma; - info_ptr->gamma = (float)gamma; -#ifdef PNG_FIXED_POINT_SUPPORTED - info_ptr->int_gamma = (int)(gamma*100000.+.5); -#endif - info_ptr->valid |= PNG_INFO_gAMA; - if(gamma == 0.0) - png_warning(png_ptr, "Setting gamma=0"); -} -#endif -void PNGAPI -png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point - int_gamma) -{ - png_fixed_point gamma; - - png_debug1(1, "in %s storage function\n", "gAMA"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - if (int_gamma > (png_fixed_point) PNG_UINT_31_MAX) - { - png_warning(png_ptr, "Limiting gamma to 21474.83"); - gamma=PNG_UINT_31_MAX; - } - else - { - if (int_gamma < 0) - { - png_warning(png_ptr, "Setting negative gamma to zero"); - gamma=0; - } - else - gamma=int_gamma; - } -#ifdef PNG_FLOATING_POINT_SUPPORTED - info_ptr->gamma = (float)(gamma/100000.); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - info_ptr->int_gamma = gamma; -#endif - info_ptr->valid |= PNG_INFO_gAMA; - if(gamma == 0) - png_warning(png_ptr, "Setting gamma=0"); -} -#endif - -#if defined(PNG_hIST_SUPPORTED) -void PNGAPI -png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist) -{ - int i; - - png_debug1(1, "in %s storage function\n", "hIST"); - if (png_ptr == NULL || info_ptr == NULL) - return; - if (info_ptr->num_palette <= 0 || info_ptr->num_palette - > PNG_MAX_PALETTE_LENGTH) - { - png_warning(png_ptr, - "Invalid palette size, hIST allocation skipped."); - return; - } - -#ifdef PNG_FREE_ME_SUPPORTED - png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0); -#endif - /* Changed from info->num_palette to PNG_MAX_PALETTE_LENGTH in version - 1.2.1 */ - png_ptr->hist = (png_uint_16p)png_malloc_warn(png_ptr, - (png_uint_32)(PNG_MAX_PALETTE_LENGTH * png_sizeof (png_uint_16))); - if (png_ptr->hist == NULL) - { - png_warning(png_ptr, "Insufficient memory for hIST chunk data."); - return; - } - - for (i = 0; i < info_ptr->num_palette; i++) - png_ptr->hist[i] = hist[i]; - info_ptr->hist = png_ptr->hist; - info_ptr->valid |= PNG_INFO_hIST; - -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_HIST; -#else - png_ptr->flags |= PNG_FLAG_FREE_HIST; -#endif -} -#endif - -void PNGAPI -png_set_IHDR(png_structp png_ptr, png_infop info_ptr, - png_uint_32 width, png_uint_32 height, int bit_depth, - int color_type, int interlace_type, int compression_type, - int filter_type) -{ - png_debug1(1, "in %s storage function\n", "IHDR"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - /* check for width and height valid values */ - if (width == 0 || height == 0) - png_error(png_ptr, "Image width or height is zero in IHDR"); -#ifdef PNG_SET_USER_LIMITS_SUPPORTED - if (width > png_ptr->user_width_max || height > png_ptr->user_height_max) - png_error(png_ptr, "image size exceeds user limits in IHDR"); -#else - if (width > PNG_USER_WIDTH_MAX || height > PNG_USER_HEIGHT_MAX) - png_error(png_ptr, "image size exceeds user limits in IHDR"); -#endif - if (width > PNG_UINT_31_MAX || height > PNG_UINT_31_MAX) - png_error(png_ptr, "Invalid image size in IHDR"); - if ( width > (PNG_UINT_32_MAX - >> 3) /* 8-byte RGBA pixels */ - - 64 /* bigrowbuf hack */ - - 1 /* filter byte */ - - 7*8 /* rounding of width to multiple of 8 pixels */ - - 8) /* extra max_pixel_depth pad */ - png_warning(png_ptr, "Width is too large for libpng to process pixels"); - - /* check other values */ - if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 && - bit_depth != 8 && bit_depth != 16) - png_error(png_ptr, "Invalid bit depth in IHDR"); - - if (color_type < 0 || color_type == 1 || - color_type == 5 || color_type > 6) - png_error(png_ptr, "Invalid color type in IHDR"); - - if (((color_type == PNG_COLOR_TYPE_PALETTE) && bit_depth > 8) || - ((color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_GRAY_ALPHA || - color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8)) - png_error(png_ptr, "Invalid color type/bit depth combination in IHDR"); - - if (interlace_type >= PNG_INTERLACE_LAST) - png_error(png_ptr, "Unknown interlace method in IHDR"); - - if (compression_type != PNG_COMPRESSION_TYPE_BASE) - png_error(png_ptr, "Unknown compression method in IHDR"); - -#if defined(PNG_MNG_FEATURES_SUPPORTED) - /* Accept filter_method 64 (intrapixel differencing) only if - * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and - * 2. Libpng did not read a PNG signature (this filter_method is only - * used in PNG datastreams that are embedded in MNG datastreams) and - * 3. The application called png_permit_mng_features with a mask that - * included PNG_FLAG_MNG_FILTER_64 and - * 4. The filter_method is 64 and - * 5. The color_type is RGB or RGBA - */ - if((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&png_ptr->mng_features_permitted) - png_warning(png_ptr,"MNG features are not allowed in a PNG datastream"); - if(filter_type != PNG_FILTER_TYPE_BASE) - { - if(!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - (filter_type == PNG_INTRAPIXEL_DIFFERENCING) && - ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) && - (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_RGB_ALPHA))) - png_error(png_ptr, "Unknown filter method in IHDR"); - if(png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) - png_warning(png_ptr, "Invalid filter method in IHDR"); - } -#else - if(filter_type != PNG_FILTER_TYPE_BASE) - png_error(png_ptr, "Unknown filter method in IHDR"); -#endif - - info_ptr->width = width; - info_ptr->height = height; - info_ptr->bit_depth = (png_byte)bit_depth; - info_ptr->color_type =(png_byte) color_type; - info_ptr->compression_type = (png_byte)compression_type; - info_ptr->filter_type = (png_byte)filter_type; - info_ptr->interlace_type = (png_byte)interlace_type; - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - info_ptr->channels = 1; - else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR) - info_ptr->channels = 3; - else - info_ptr->channels = 1; - if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA) - info_ptr->channels++; - info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth); - - /* check for potential overflow */ - if ( width > (PNG_UINT_32_MAX - >> 3) /* 8-byte RGBA pixels */ - - 64 /* bigrowbuf hack */ - - 1 /* filter byte */ - - 7*8 /* rounding of width to multiple of 8 pixels */ - - 8) /* extra max_pixel_depth pad */ - info_ptr->rowbytes = (png_size_t)0; - else - info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth,width); -} - -#if defined(PNG_oFFs_SUPPORTED) -void PNGAPI -png_set_oFFs(png_structp png_ptr, png_infop info_ptr, - png_int_32 offset_x, png_int_32 offset_y, int unit_type) -{ - png_debug1(1, "in %s storage function\n", "oFFs"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - info_ptr->x_offset = offset_x; - info_ptr->y_offset = offset_y; - info_ptr->offset_unit_type = (png_byte)unit_type; - info_ptr->valid |= PNG_INFO_oFFs; -} -#endif - -#if defined(PNG_pCAL_SUPPORTED) -void PNGAPI -png_set_pCAL(png_structp png_ptr, png_infop info_ptr, - png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams, - png_charp units, png_charpp params) -{ - png_uint_32 length; - int i; - - png_debug1(1, "in %s storage function\n", "pCAL"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - length = png_strlen(purpose) + 1; - png_debug1(3, "allocating purpose for info (%lu bytes)\n", length); - info_ptr->pcal_purpose = (png_charp)png_malloc_warn(png_ptr, length); - if (info_ptr->pcal_purpose == NULL) - { - png_warning(png_ptr, "Insufficient memory for pCAL purpose."); - return; - } - png_memcpy(info_ptr->pcal_purpose, purpose, (png_size_t)length); - - png_debug(3, "storing X0, X1, type, and nparams in info\n"); - info_ptr->pcal_X0 = X0; - info_ptr->pcal_X1 = X1; - info_ptr->pcal_type = (png_byte)type; - info_ptr->pcal_nparams = (png_byte)nparams; - - length = png_strlen(units) + 1; - png_debug1(3, "allocating units for info (%lu bytes)\n", length); - info_ptr->pcal_units = (png_charp)png_malloc_warn(png_ptr, length); - if (info_ptr->pcal_units == NULL) - { - png_warning(png_ptr, "Insufficient memory for pCAL units."); - return; - } - png_memcpy(info_ptr->pcal_units, units, (png_size_t)length); - - info_ptr->pcal_params = (png_charpp)png_malloc_warn(png_ptr, - (png_uint_32)((nparams + 1) * png_sizeof(png_charp))); - if (info_ptr->pcal_params == NULL) - { - png_warning(png_ptr, "Insufficient memory for pCAL params."); - return; - } - - info_ptr->pcal_params[nparams] = NULL; - - for (i = 0; i < nparams; i++) - { - length = png_strlen(params[i]) + 1; - png_debug2(3, "allocating parameter %d for info (%lu bytes)\n", i, length); - info_ptr->pcal_params[i] = (png_charp)png_malloc_warn(png_ptr, length); - if (info_ptr->pcal_params[i] == NULL) - { - png_warning(png_ptr, "Insufficient memory for pCAL parameter."); - return; - } - png_memcpy(info_ptr->pcal_params[i], params[i], (png_size_t)length); - } - - info_ptr->valid |= PNG_INFO_pCAL; -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_PCAL; -#endif -} -#endif - -#if defined(PNG_READ_sCAL_SUPPORTED) || defined(PNG_WRITE_sCAL_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -void PNGAPI -png_set_sCAL(png_structp png_ptr, png_infop info_ptr, - int unit, double width, double height) -{ - png_debug1(1, "in %s storage function\n", "sCAL"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - info_ptr->scal_unit = (png_byte)unit; - info_ptr->scal_pixel_width = width; - info_ptr->scal_pixel_height = height; - - info_ptr->valid |= PNG_INFO_sCAL; -} -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -void PNGAPI -png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr, - int unit, png_charp swidth, png_charp sheight) -{ - png_uint_32 length; - - png_debug1(1, "in %s storage function\n", "sCAL"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - info_ptr->scal_unit = (png_byte)unit; - - length = png_strlen(swidth) + 1; - png_debug1(3, "allocating unit for info (%d bytes)\n", length); - info_ptr->scal_s_width = (png_charp)png_malloc_warn(png_ptr, length); - if (info_ptr->scal_s_width == NULL) - { - png_warning(png_ptr, "Memory allocation failed while processing sCAL."); - } - png_memcpy(info_ptr->scal_s_width, swidth, (png_size_t)length); - - length = png_strlen(sheight) + 1; - png_debug1(3, "allocating unit for info (%d bytes)\n", length); - info_ptr->scal_s_height = (png_charp)png_malloc_warn(png_ptr, length); - if (info_ptr->scal_s_height == NULL) - { - png_free (png_ptr, info_ptr->scal_s_width); - png_warning(png_ptr, "Memory allocation failed while processing sCAL."); - } - png_memcpy(info_ptr->scal_s_height, sheight, (png_size_t)length); - - info_ptr->valid |= PNG_INFO_sCAL; -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_SCAL; -#endif -} -#endif -#endif -#endif - -#if defined(PNG_pHYs_SUPPORTED) -void PNGAPI -png_set_pHYs(png_structp png_ptr, png_infop info_ptr, - png_uint_32 res_x, png_uint_32 res_y, int unit_type) -{ - png_debug1(1, "in %s storage function\n", "pHYs"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - info_ptr->x_pixels_per_unit = res_x; - info_ptr->y_pixels_per_unit = res_y; - info_ptr->phys_unit_type = (png_byte)unit_type; - info_ptr->valid |= PNG_INFO_pHYs; -} -#endif - -void PNGAPI -png_set_PLTE(png_structp png_ptr, png_infop info_ptr, - png_colorp palette, int num_palette) -{ - - png_debug1(1, "in %s storage function\n", "PLTE"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - if (num_palette < 0 || num_palette > PNG_MAX_PALETTE_LENGTH) - { - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - png_error(png_ptr, "Invalid palette length"); - else - { - png_warning(png_ptr, "Invalid palette length"); - return; - } - } - - /* - * It may not actually be necessary to set png_ptr->palette here; - * we do it for backward compatibility with the way the png_handle_tRNS - * function used to do the allocation. - */ -#ifdef PNG_FREE_ME_SUPPORTED - png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0); -#endif - - /* Changed in libpng-1.2.1 to allocate PNG_MAX_PALETTE_LENGTH instead - of num_palette entries, - in case of an invalid PNG file that has too-large sample values. */ - png_ptr->palette = (png_colorp)png_malloc(png_ptr, - PNG_MAX_PALETTE_LENGTH * png_sizeof(png_color)); - png_memset(png_ptr->palette, 0, PNG_MAX_PALETTE_LENGTH * - png_sizeof(png_color)); - png_memcpy(png_ptr->palette, palette, num_palette * png_sizeof (png_color)); - info_ptr->palette = png_ptr->palette; - info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette; - -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_PLTE; -#else - png_ptr->flags |= PNG_FLAG_FREE_PLTE; -#endif - - info_ptr->valid |= PNG_INFO_PLTE; -} - -#if defined(PNG_sBIT_SUPPORTED) -void PNGAPI -png_set_sBIT(png_structp png_ptr, png_infop info_ptr, - png_color_8p sig_bit) -{ - png_debug1(1, "in %s storage function\n", "sBIT"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - png_memcpy(&(info_ptr->sig_bit), sig_bit, png_sizeof (png_color_8)); - info_ptr->valid |= PNG_INFO_sBIT; -} -#endif - -#if defined(PNG_sRGB_SUPPORTED) -void PNGAPI -png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent) -{ - png_debug1(1, "in %s storage function\n", "sRGB"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - info_ptr->srgb_intent = (png_byte)intent; - info_ptr->valid |= PNG_INFO_sRGB; -} - -void PNGAPI -png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr, - int intent) -{ -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED - float file_gamma; -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - png_fixed_point int_file_gamma; -#endif -#endif -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED - float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y; -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - png_fixed_point int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, - int_green_y, int_blue_x, int_blue_y; -#endif -#endif - png_debug1(1, "in %s storage function\n", "sRGB_gAMA_and_cHRM"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - png_set_sRGB(png_ptr, info_ptr, intent); - -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED - file_gamma = (float).45455; - png_set_gAMA(png_ptr, info_ptr, file_gamma); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - int_file_gamma = 45455L; - png_set_gAMA_fixed(png_ptr, info_ptr, int_file_gamma); -#endif -#endif - -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FIXED_POINT_SUPPORTED - int_white_x = 31270L; - int_white_y = 32900L; - int_red_x = 64000L; - int_red_y = 33000L; - int_green_x = 30000L; - int_green_y = 60000L; - int_blue_x = 15000L; - int_blue_y = 6000L; - - png_set_cHRM_fixed(png_ptr, info_ptr, - int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, int_green_y, - int_blue_x, int_blue_y); -#endif -#ifdef PNG_FLOATING_POINT_SUPPORTED - white_x = (float).3127; - white_y = (float).3290; - red_x = (float).64; - red_y = (float).33; - green_x = (float).30; - green_y = (float).60; - blue_x = (float).15; - blue_y = (float).06; - - png_set_cHRM(png_ptr, info_ptr, - white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y); -#endif -#endif -} -#endif - - -#if defined(PNG_iCCP_SUPPORTED) -void PNGAPI -png_set_iCCP(png_structp png_ptr, png_infop info_ptr, - png_charp name, int compression_type, - png_charp profile, png_uint_32 proflen) -{ - png_charp new_iccp_name; - png_charp new_iccp_profile; - - png_debug1(1, "in %s storage function\n", "iCCP"); - if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL) - return; - - new_iccp_name = (png_charp)png_malloc_warn(png_ptr, png_strlen(name)+1); - if (new_iccp_name == NULL) - { - png_warning(png_ptr, "Insufficient memory to process iCCP chunk."); - return; - } - png_strcpy(new_iccp_name, name); - new_iccp_profile = (png_charp)png_malloc_warn(png_ptr, proflen); - if (new_iccp_profile == NULL) - { - png_free (png_ptr, new_iccp_name); - png_warning(png_ptr, "Insufficient memory to process iCCP profile."); - return; - } - png_memcpy(new_iccp_profile, profile, (png_size_t)proflen); - - png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, 0); - - info_ptr->iccp_proflen = proflen; - info_ptr->iccp_name = new_iccp_name; - info_ptr->iccp_profile = new_iccp_profile; - /* Compression is always zero but is here so the API and info structure - * does not have to change if we introduce multiple compression types */ - info_ptr->iccp_compression = (png_byte)compression_type; -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_ICCP; -#endif - info_ptr->valid |= PNG_INFO_iCCP; -} -#endif - -#if defined(PNG_TEXT_SUPPORTED) -void PNGAPI -png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, - int num_text) -{ - int ret; - ret=png_set_text_2(png_ptr, info_ptr, text_ptr, num_text); - if (ret) - png_error(png_ptr, "Insufficient memory to store text"); -} - -int /* PRIVATE */ -png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, - int num_text) -{ - int i; - - png_debug1(1, "in %s storage function\n", (png_ptr->chunk_name[0] == '\0' ? - "text" : (png_const_charp)png_ptr->chunk_name)); - - if (png_ptr == NULL || info_ptr == NULL || num_text == 0) - return(0); - - /* Make sure we have enough space in the "text" array in info_struct - * to hold all of the incoming text_ptr objects. - */ - if (info_ptr->num_text + num_text > info_ptr->max_text) - { - if (info_ptr->text != NULL) - { - png_textp old_text; - int old_max; - - old_max = info_ptr->max_text; - info_ptr->max_text = info_ptr->num_text + num_text + 8; - old_text = info_ptr->text; - info_ptr->text = (png_textp)png_malloc_warn(png_ptr, - (png_uint_32)(info_ptr->max_text * png_sizeof (png_text))); - if (info_ptr->text == NULL) - { - png_free(png_ptr, old_text); - return(1); - } - png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max * - png_sizeof(png_text))); - png_free(png_ptr, old_text); - } - else - { - info_ptr->max_text = num_text + 8; - info_ptr->num_text = 0; - info_ptr->text = (png_textp)png_malloc_warn(png_ptr, - (png_uint_32)(info_ptr->max_text * png_sizeof (png_text))); - if (info_ptr->text == NULL) - return(1); -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_TEXT; -#endif - } - png_debug1(3, "allocated %d entries for info_ptr->text\n", - info_ptr->max_text); - } - for (i = 0; i < num_text; i++) - { - png_size_t text_length,key_len; - png_size_t lang_len,lang_key_len; - png_textp textp = &(info_ptr->text[info_ptr->num_text]); - - if (text_ptr[i].key == NULL) - continue; - - key_len = png_strlen(text_ptr[i].key); - - if(text_ptr[i].compression <= 0) - { - lang_len = 0; - lang_key_len = 0; - } - else -#ifdef PNG_iTXt_SUPPORTED - { - /* set iTXt data */ - if (text_ptr[i].lang != NULL) - lang_len = png_strlen(text_ptr[i].lang); - else - lang_len = 0; - if (text_ptr[i].lang_key != NULL) - lang_key_len = png_strlen(text_ptr[i].lang_key); - else - lang_key_len = 0; - } -#else - { - png_warning(png_ptr, "iTXt chunk not supported."); - continue; - } -#endif - - if (text_ptr[i].text == NULL || text_ptr[i].text[0] == '\0') - { - text_length = 0; -#ifdef PNG_iTXt_SUPPORTED - if(text_ptr[i].compression > 0) - textp->compression = PNG_ITXT_COMPRESSION_NONE; - else -#endif - textp->compression = PNG_TEXT_COMPRESSION_NONE; - } - else - { - text_length = png_strlen(text_ptr[i].text); - textp->compression = text_ptr[i].compression; - } - - textp->key = (png_charp)png_malloc_warn(png_ptr, - (png_uint_32)(key_len + text_length + lang_len + lang_key_len + 4)); - if (textp->key == NULL) - return(1); - png_debug2(2, "Allocated %lu bytes at %x in png_set_text\n", - (png_uint_32)(key_len + lang_len + lang_key_len + text_length + 4), - (int)textp->key); - - png_memcpy(textp->key, text_ptr[i].key, - (png_size_t)(key_len)); - *(textp->key+key_len) = '\0'; -#ifdef PNG_iTXt_SUPPORTED - if (text_ptr[i].compression > 0) - { - textp->lang=textp->key + key_len + 1; - png_memcpy(textp->lang, text_ptr[i].lang, lang_len); - *(textp->lang+lang_len) = '\0'; - textp->lang_key=textp->lang + lang_len + 1; - png_memcpy(textp->lang_key, text_ptr[i].lang_key, lang_key_len); - *(textp->lang_key+lang_key_len) = '\0'; - textp->text=textp->lang_key + lang_key_len + 1; - } - else -#endif - { -#ifdef PNG_iTXt_SUPPORTED - textp->lang=NULL; - textp->lang_key=NULL; -#endif - textp->text=textp->key + key_len + 1; - } - if(text_length) - png_memcpy(textp->text, text_ptr[i].text, - (png_size_t)(text_length)); - *(textp->text+text_length) = '\0'; - -#ifdef PNG_iTXt_SUPPORTED - if(textp->compression > 0) - { - textp->text_length = 0; - textp->itxt_length = text_length; - } - else -#endif - { - textp->text_length = text_length; -#ifdef PNG_iTXt_SUPPORTED - textp->itxt_length = 0; -#endif - } -#if 0 /* appears to be redundant; */ - info_ptr->text[info_ptr->num_text]= *textp; -#endif - info_ptr->num_text++; - png_debug1(3, "transferred text chunk %d\n", info_ptr->num_text); - } - return(0); -} -#endif - -#if defined(PNG_tIME_SUPPORTED) -void PNGAPI -png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time) -{ - png_debug1(1, "in %s storage function\n", "tIME"); - if (png_ptr == NULL || info_ptr == NULL || - (png_ptr->mode & PNG_WROTE_tIME)) - return; - - png_memcpy(&(info_ptr->mod_time), mod_time, png_sizeof (png_time)); - info_ptr->valid |= PNG_INFO_tIME; -} -#endif - -#if defined(PNG_tRNS_SUPPORTED) -void PNGAPI -png_set_tRNS(png_structp png_ptr, png_infop info_ptr, - png_bytep trans, int num_trans, png_color_16p trans_values) -{ - png_debug1(1, "in %s storage function\n", "tRNS"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - if (trans != NULL) - { - /* - * It may not actually be necessary to set png_ptr->trans here; - * we do it for backward compatibility with the way the png_handle_tRNS - * function used to do the allocation. - */ -#ifdef PNG_FREE_ME_SUPPORTED - png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0); -#endif - /* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */ - png_ptr->trans = info_ptr->trans = (png_bytep)png_malloc(png_ptr, - (png_uint_32)PNG_MAX_PALETTE_LENGTH); - if (num_trans <= PNG_MAX_PALETTE_LENGTH) - png_memcpy(info_ptr->trans, trans, (png_size_t)num_trans); -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_TRNS; -#else - png_ptr->flags |= PNG_FLAG_FREE_TRNS; -#endif - } - - if (trans_values != NULL) - { - png_memcpy(&(info_ptr->trans_values), trans_values, - png_sizeof(png_color_16)); - if (num_trans == 0) - num_trans = 1; - } - info_ptr->num_trans = (png_uint_16)num_trans; - info_ptr->valid |= PNG_INFO_tRNS; -} -#endif - -#if defined(PNG_sPLT_SUPPORTED) -void PNGAPI -png_set_sPLT(png_structp png_ptr, - png_infop info_ptr, png_sPLT_tp entries, int nentries) -{ - png_sPLT_tp np; - int i; - - if (png_ptr == NULL || info_ptr == NULL) - return; - - np = (png_sPLT_tp)png_malloc_warn(png_ptr, - (info_ptr->splt_palettes_num + nentries) * png_sizeof(png_sPLT_t)); - if (np == NULL) - { - png_warning(png_ptr, "No memory for sPLT palettes."); - return; - } - - png_memcpy(np, info_ptr->splt_palettes, - info_ptr->splt_palettes_num * png_sizeof(png_sPLT_t)); - png_free(png_ptr, info_ptr->splt_palettes); - info_ptr->splt_palettes=NULL; - - for (i = 0; i < nentries; i++) - { - png_sPLT_tp to = np + info_ptr->splt_palettes_num + i; - png_sPLT_tp from = entries + i; - - to->name = (png_charp)png_malloc(png_ptr, - png_strlen(from->name) + 1); - /* TODO: use png_malloc_warn */ - png_strcpy(to->name, from->name); - to->entries = (png_sPLT_entryp)png_malloc(png_ptr, - from->nentries * png_sizeof(png_sPLT_entry)); - /* TODO: use png_malloc_warn */ - png_memcpy(to->entries, from->entries, - from->nentries * png_sizeof(png_sPLT_entry)); - to->nentries = from->nentries; - to->depth = from->depth; - } - - info_ptr->splt_palettes = np; - info_ptr->splt_palettes_num += nentries; - info_ptr->valid |= PNG_INFO_sPLT; -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_SPLT; -#endif -} -#endif /* PNG_sPLT_SUPPORTED */ - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -void PNGAPI -png_set_unknown_chunks(png_structp png_ptr, - png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns) -{ - png_unknown_chunkp np; - int i; - - if (png_ptr == NULL || info_ptr == NULL || num_unknowns == 0) - return; - - np = (png_unknown_chunkp)png_malloc_warn(png_ptr, - (info_ptr->unknown_chunks_num + num_unknowns) * - png_sizeof(png_unknown_chunk)); - if (np == NULL) - { - png_warning(png_ptr, "Out of memory while processing unknown chunk."); - return; - } - - png_memcpy(np, info_ptr->unknown_chunks, - info_ptr->unknown_chunks_num * png_sizeof(png_unknown_chunk)); - png_free(png_ptr, info_ptr->unknown_chunks); - info_ptr->unknown_chunks=NULL; - - for (i = 0; i < num_unknowns; i++) - { - png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i; - png_unknown_chunkp from = unknowns + i; - - png_strncpy((png_charp)to->name, (png_charp)from->name, 5); - to->data = (png_bytep)png_malloc_warn(png_ptr, from->size); - if (to->data == NULL) - { - png_warning(png_ptr, "Out of memory processing unknown chunk."); - } - else - { - png_memcpy(to->data, from->data, from->size); - to->size = from->size; - - /* note our location in the read or write sequence */ - to->location = (png_byte)(png_ptr->mode & 0xff); - } - } - - info_ptr->unknown_chunks = np; - info_ptr->unknown_chunks_num += num_unknowns; -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_UNKN; -#endif -} -void PNGAPI -png_set_unknown_chunk_location(png_structp png_ptr, png_infop info_ptr, - int chunk, int location) -{ - if(png_ptr != NULL && info_ptr != NULL && chunk >= 0 && chunk < - (int)info_ptr->unknown_chunks_num) - info_ptr->unknown_chunks[chunk].location = (png_byte)location; -} -#endif - -#if defined(PNG_1_0_X) || defined(PNG_1_2_X) -#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ - defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) -void PNGAPI -png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted) -{ - /* This function is deprecated in favor of png_permit_mng_features() - and will be removed from libpng-1.3.0 */ - png_debug(1, "in png_permit_empty_plte, DEPRECATED.\n"); - if (png_ptr == NULL) - return; - png_ptr->mng_features_permitted = (png_byte) - ((png_ptr->mng_features_permitted & (~(PNG_FLAG_MNG_EMPTY_PLTE))) | - ((empty_plte_permitted & PNG_FLAG_MNG_EMPTY_PLTE))); -} -#endif -#endif - -#if defined(PNG_MNG_FEATURES_SUPPORTED) -png_uint_32 PNGAPI -png_permit_mng_features (png_structp png_ptr, png_uint_32 mng_features) -{ - png_debug(1, "in png_permit_mng_features\n"); - if (png_ptr == NULL) - return (png_uint_32)0; - png_ptr->mng_features_permitted = - (png_byte)(mng_features & PNG_ALL_MNG_FEATURES); - return (png_uint_32)png_ptr->mng_features_permitted; -} -#endif - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -void PNGAPI -png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_bytep - chunk_list, int num_chunks) -{ - png_bytep new_list, p; - int i, old_num_chunks; - if (png_ptr == NULL) - return; - if (num_chunks == 0) - { - if(keep == PNG_HANDLE_CHUNK_ALWAYS || keep == PNG_HANDLE_CHUNK_IF_SAFE) - png_ptr->flags |= PNG_FLAG_KEEP_UNKNOWN_CHUNKS; - else - png_ptr->flags &= ~PNG_FLAG_KEEP_UNKNOWN_CHUNKS; - - if(keep == PNG_HANDLE_CHUNK_ALWAYS) - png_ptr->flags |= PNG_FLAG_KEEP_UNSAFE_CHUNKS; - else - png_ptr->flags &= ~PNG_FLAG_KEEP_UNSAFE_CHUNKS; - return; - } - if (chunk_list == NULL) - return; - old_num_chunks=png_ptr->num_chunk_list; - new_list=(png_bytep)png_malloc(png_ptr, - (png_uint_32)(5*(num_chunks+old_num_chunks))); - if(png_ptr->chunk_list != NULL) - { - png_memcpy(new_list, png_ptr->chunk_list, - (png_size_t)(5*old_num_chunks)); - png_free(png_ptr, png_ptr->chunk_list); - png_ptr->chunk_list=NULL; - } - png_memcpy(new_list+5*old_num_chunks, chunk_list, - (png_size_t)(5*num_chunks)); - for (p=new_list+5*old_num_chunks+4, i=0; i<num_chunks; i++, p+=5) - *p=(png_byte)keep; - png_ptr->num_chunk_list=old_num_chunks+num_chunks; - png_ptr->chunk_list=new_list; -#ifdef PNG_FREE_ME_SUPPORTED - png_ptr->free_me |= PNG_FREE_LIST; -#endif -} -#endif - -#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) -void PNGAPI -png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr, - png_user_chunk_ptr read_user_chunk_fn) -{ - png_debug(1, "in png_set_read_user_chunk_fn\n"); - if (png_ptr == NULL) - return; - png_ptr->read_user_chunk_fn = read_user_chunk_fn; - png_ptr->user_chunk_ptr = user_chunk_ptr; -} -#endif - -#if defined(PNG_INFO_IMAGE_SUPPORTED) -void PNGAPI -png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers) -{ - png_debug1(1, "in %s storage function\n", "rows"); - - if (png_ptr == NULL || info_ptr == NULL) - return; - - if(info_ptr->row_pointers && (info_ptr->row_pointers != row_pointers)) - png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); - info_ptr->row_pointers = row_pointers; - if(row_pointers) - info_ptr->valid |= PNG_INFO_IDAT; -} -#endif - -#ifdef PNG_WRITE_SUPPORTED -void PNGAPI -png_set_compression_buffer_size(png_structp png_ptr, png_uint_32 size) -{ - if (png_ptr == NULL) - return; - if(png_ptr->zbuf) - png_free(png_ptr, png_ptr->zbuf); - png_ptr->zbuf_size = (png_size_t)size; - png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, size); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; -} -#endif - -void PNGAPI -png_set_invalid(png_structp png_ptr, png_infop info_ptr, int mask) -{ - if (png_ptr && info_ptr) - info_ptr->valid &= ~(mask); -} - - -#ifndef PNG_1_0_X -#ifdef PNG_ASSEMBLER_CODE_SUPPORTED -/* this function was added to libpng 1.2.0 and should always exist by default */ -void PNGAPI -png_set_asm_flags (png_structp png_ptr, png_uint_32 asm_flags) -{ -#ifdef PNG_MMX_CODE_SUPPORTED - png_uint_32 settable_asm_flags; - png_uint_32 settable_mmx_flags; -#endif - if (png_ptr == NULL) - return; -#ifdef PNG_MMX_CODE_SUPPORTED - - settable_mmx_flags = -#ifdef PNG_HAVE_MMX_COMBINE_ROW - PNG_ASM_FLAG_MMX_READ_COMBINE_ROW | -#endif -#ifdef PNG_HAVE_MMX_READ_INTERLACE - PNG_ASM_FLAG_MMX_READ_INTERLACE | -#endif -#ifdef PNG_HAVE_MMX_READ_FILTER_ROW - PNG_ASM_FLAG_MMX_READ_FILTER_SUB | - PNG_ASM_FLAG_MMX_READ_FILTER_UP | - PNG_ASM_FLAG_MMX_READ_FILTER_AVG | - PNG_ASM_FLAG_MMX_READ_FILTER_PAETH | -#endif - 0; - - /* could be some non-MMX ones in the future, but not currently: */ - settable_asm_flags = settable_mmx_flags; - - if (!(png_ptr->asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_COMPILED) || - !(png_ptr->asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU)) - { - /* clear all MMX flags if MMX isn't supported */ - settable_asm_flags &= ~settable_mmx_flags; - png_ptr->asm_flags &= ~settable_mmx_flags; - } - - /* we're replacing the settable bits with those passed in by the user, - * so first zero them out of the master copy, then bitwise-OR in the - * allowed subset that was requested */ - - png_ptr->asm_flags &= ~settable_asm_flags; /* zero them */ - png_ptr->asm_flags |= (asm_flags & settable_asm_flags); /* set them */ -#endif /* ?PNG_MMX_CODE_SUPPORTED */ -} - -/* this function was added to libpng 1.2.0 */ -void PNGAPI -png_set_mmx_thresholds (png_structp png_ptr, - png_byte mmx_bitdepth_threshold, - png_uint_32 mmx_rowbytes_threshold) -{ - if (png_ptr == NULL) - return; -#ifdef PNG_MMX_CODE_SUPPORTED - png_ptr->mmx_bitdepth_threshold = mmx_bitdepth_threshold; - png_ptr->mmx_rowbytes_threshold = mmx_rowbytes_threshold; -#endif /* ?PNG_MMX_CODE_SUPPORTED */ -} -#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ - -#ifdef PNG_SET_USER_LIMITS_SUPPORTED -/* this function was added to libpng 1.2.6 */ -void PNGAPI -png_set_user_limits (png_structp png_ptr, png_uint_32 user_width_max, - png_uint_32 user_height_max) -{ - /* Images with dimensions larger than these limits will be - * rejected by png_set_IHDR(). To accept any PNG datastream - * regardless of dimensions, set both limits to 0x7ffffffL. - */ - if(png_ptr == NULL) return; - png_ptr->user_width_max = user_width_max; - png_ptr->user_height_max = user_height_max; -} -#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ - -#endif /* ?PNG_1_0_X */ -#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/pngtest.c b/irrlicht-1.6/source/Irrlicht/libpng/pngtest.c deleted file mode 100644 index 4f6d60237..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/pngtest.c +++ /dev/null @@ -1,1554 +0,0 @@ - -/* pngtest.c - a simple test program to test libpng - * - * Last changed in libpng 1.2.6 - August 15, 2004 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2004 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This program reads in a PNG image, writes it out again, and then - * compares the two files. If the files are identical, this shows that - * the basic chunk handling, filtering, and (de)compression code is working - * properly. It does not currently test all of the transforms, although - * it probably should. - * - * The program will report "FAIL" in certain legitimate cases: - * 1) when the compression level or filter selection method is changed. - * 2) when the maximum IDAT size (PNG_ZBUF_SIZE in pngconf.h) is not 8192. - * 3) unknown unsafe-to-copy ancillary chunks or unknown critical chunks - * exist in the input file. - * 4) others not listed here... - * In these cases, it is best to check with another tool such as "pngcheck" - * to see what the differences between the two files are. - * - * If a filename is given on the command-line, then this file is used - * for the input, rather than the default "pngtest.png". This allows - * testing a wide variety of files easily. You can also test a number - * of files at once by typing "pngtest -m file1.png file2.png ..." - */ - -#include "png.h" - -#if defined(_WIN32_WCE) -# if _WIN32_WCE < 211 - __error__ (f|w)printf functions are not supported on old WindowsCE.; -# endif -# include <windows.h> -# include <stdlib.h> -# define READFILE(file, data, length, check) \ - if (ReadFile(file, data, length, &check,NULL)) check = 0 -# define WRITEFILE(file, data, length, check)) \ - if (WriteFile(file, data, length, &check, NULL)) check = 0 -# define FCLOSE(file) CloseHandle(file) -#else -# include <stdio.h> -# include <stdlib.h> -# define READFILE(file, data, length, check) \ - check=(png_size_t)fread(data,(png_size_t)1,length,file) -# define WRITEFILE(file, data, length, check) \ - check=(png_size_t)fwrite(data,(png_size_t)1, length, file) -# define FCLOSE(file) fclose(file) -#endif - -#if defined(PNG_NO_STDIO) -# if defined(_WIN32_WCE) - typedef HANDLE png_FILE_p; -# else - typedef FILE * png_FILE_p; -# endif -#endif - -/* Makes pngtest verbose so we can find problems (needs to be before png.h) */ -#ifndef PNG_DEBUG -# define PNG_DEBUG 0 -#endif - -#if !PNG_DEBUG -# define SINGLE_ROWBUF_ALLOC /* makes buffer overruns easier to nail */ -#endif - -/* Turn on CPU timing -#define PNGTEST_TIMING -*/ - -#ifdef PNG_NO_FLOATING_POINT_SUPPORTED -#undef PNGTEST_TIMING -#endif - -#ifdef PNGTEST_TIMING -static float t_start, t_stop, t_decode, t_encode, t_misc; -#include <time.h> -#endif - -#if defined(PNG_TIME_RFC1123_SUPPORTED) -static int tIME_chunk_present=0; -static char tIME_string[30] = "no tIME chunk present in file"; -#endif - -static int verbose = 0; - -int test_one_file PNGARG((PNG_CONST char *inname, PNG_CONST char *outname)); - -#ifdef __TURBOC__ -#include <mem.h> -#endif - -/* defined so I can write to a file on gui/windowing platforms */ -/* #define STDERR stderr */ -#define STDERR stdout /* for DOS */ - -/* example of using row callbacks to make a simple progress meter */ -static int status_pass=1; -static int status_dots_requested=0; -static int status_dots=1; - -/* In case a system header (e.g., on AIX) defined jmpbuf */ -#ifdef jmpbuf -# undef jmpbuf -#endif - -/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */ -#ifndef png_jmpbuf -# define png_jmpbuf(png_ptr) png_ptr->jmpbuf -#endif - -void -#ifdef PNG_1_0_X -PNGAPI -#endif -read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass); -void -#ifdef PNG_1_0_X -PNGAPI -#endif -read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass) -{ - if(png_ptr == NULL || row_number > PNG_UINT_31_MAX) return; - if(status_pass != pass) - { - fprintf(stdout,"\n Pass %d: ",pass); - status_pass = pass; - status_dots = 31; - } - status_dots--; - if(status_dots == 0) - { - fprintf(stdout, "\n "); - status_dots=30; - } - fprintf(stdout, "r"); -} - -void -#ifdef PNG_1_0_X -PNGAPI -#endif -write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass); -void -#ifdef PNG_1_0_X -PNGAPI -#endif -write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass) -{ - if(png_ptr == NULL || row_number > PNG_UINT_31_MAX || pass > 7) return; - fprintf(stdout, "w"); -} - - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) -/* Example of using user transform callback (we don't transform anything, - but merely examine the row filters. We set this to 256 rather than - 5 in case illegal filter values are present.) */ -static png_uint_32 filters_used[256]; -void -#ifdef PNG_1_0_X -PNGAPI -#endif -count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data); -void -#ifdef PNG_1_0_X -PNGAPI -#endif -count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data) -{ - if(png_ptr != NULL && row_info != NULL) - ++filters_used[*(data-1)]; -} -#endif - -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) -/* example of using user transform callback (we don't transform anything, - but merely count the zero samples) */ - -static png_uint_32 zero_samples; - -void -#ifdef PNG_1_0_X -PNGAPI -#endif -count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data); -void -#ifdef PNG_1_0_X -PNGAPI -#endif -count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data) -{ - png_bytep dp = data; - if(png_ptr == NULL)return; - - /* contents of row_info: - * png_uint_32 width width of row - * png_uint_32 rowbytes number of bytes in row - * png_byte color_type color type of pixels - * png_byte bit_depth bit depth of samples - * png_byte channels number of channels (1-4) - * png_byte pixel_depth bits per pixel (depth*channels) - */ - - - /* counts the number of zero samples (or zero pixels if color_type is 3 */ - - if(row_info->color_type == 0 || row_info->color_type == 3) - { - int pos=0; - png_uint_32 n, nstop; - for (n=0, nstop=row_info->width; n<nstop; n++) - { - if(row_info->bit_depth == 1) - { - if(((*dp << pos++ ) & 0x80) == 0) zero_samples++; - if(pos == 8) - { - pos = 0; - dp++; - } - } - if(row_info->bit_depth == 2) - { - if(((*dp << (pos+=2)) & 0xc0) == 0) zero_samples++; - if(pos == 8) - { - pos = 0; - dp++; - } - } - if(row_info->bit_depth == 4) - { - if(((*dp << (pos+=4)) & 0xf0) == 0) zero_samples++; - if(pos == 8) - { - pos = 0; - dp++; - } - } - if(row_info->bit_depth == 8) - if(*dp++ == 0) zero_samples++; - if(row_info->bit_depth == 16) - { - if((*dp | *(dp+1)) == 0) zero_samples++; - dp+=2; - } - } - } - else /* other color types */ - { - png_uint_32 n, nstop; - int channel; - int color_channels = row_info->channels; - if(row_info->color_type > 3)color_channels--; - - for (n=0, nstop=row_info->width; n<nstop; n++) - { - for (channel = 0; channel < color_channels; channel++) - { - if(row_info->bit_depth == 8) - if(*dp++ == 0) zero_samples++; - if(row_info->bit_depth == 16) - { - if((*dp | *(dp+1)) == 0) zero_samples++; - dp+=2; - } - } - if(row_info->color_type > 3) - { - dp++; - if(row_info->bit_depth == 16)dp++; - } - } - } -} -#endif /* PNG_WRITE_USER_TRANSFORM_SUPPORTED */ - -static int wrote_question = 0; - -#if defined(PNG_NO_STDIO) -/* START of code to validate stdio-free compilation */ -/* These copies of the default read/write functions come from pngrio.c and */ -/* pngwio.c. They allow "don't include stdio" testing of the library. */ -/* This is the function that does the actual reading of data. If you are - not reading from a standard C stream, you should create a replacement - read_data function and use it at run time with png_set_read_fn(), rather - than changing the library. */ - -#ifndef USE_FAR_KEYWORD -static void -pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_size_t check; - - /* fread() returns 0 on error, so it is OK to store this in a png_size_t - * instead of an int, which is what fread() actually returns. - */ - READFILE((png_FILE_p)png_ptr->io_ptr, data, length, check); - - if (check != length) - { - png_error(png_ptr, "Read Error!"); - } -} -#else -/* this is the model-independent version. Since the standard I/O library - can't handle far buffers in the medium and small models, we have to copy - the data. -*/ - -#define NEAR_BUF_SIZE 1024 -#define MIN(a,b) (a <= b ? a : b) - -static void -pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - int check; - png_byte *n_data; - png_FILE_p io_ptr; - - /* Check if data really is near. If so, use usual code. */ - n_data = (png_byte *)CVT_PTR_NOCHECK(data); - io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); - if ((png_bytep)n_data == data) - { - READFILE(io_ptr, n_data, length, check); - } - else - { - png_byte buf[NEAR_BUF_SIZE]; - png_size_t read, remaining, err; - check = 0; - remaining = length; - do - { - read = MIN(NEAR_BUF_SIZE, remaining); - READFILE(io_ptr, buf, 1, err); - png_memcpy(data, buf, read); /* copy far buffer to near buffer */ - if(err != read) - break; - else - check += err; - data += read; - remaining -= read; - } - while (remaining != 0); - } - if (check != length) - { - png_error(png_ptr, "read Error"); - } -} -#endif /* USE_FAR_KEYWORD */ - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -static void -pngtest_flush(png_structp png_ptr) -{ -#if !defined(_WIN32_WCE) - png_FILE_p io_ptr; - io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr)); - if (io_ptr != NULL) - fflush(io_ptr); -#endif -} -#endif - -/* This is the function that does the actual writing of data. If you are - not writing to a standard C stream, you should create a replacement - write_data function and use it at run time with png_set_write_fn(), rather - than changing the library. */ -#ifndef USE_FAR_KEYWORD -static void -pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_uint_32 check; - - WRITEFILE((png_FILE_p)png_ptr->io_ptr, data, length, check); - if (check != length) - { - png_error(png_ptr, "Write Error"); - } -} -#else -/* this is the model-independent version. Since the standard I/O library - can't handle far buffers in the medium and small models, we have to copy - the data. -*/ - -#define NEAR_BUF_SIZE 1024 -#define MIN(a,b) (a <= b ? a : b) - -static void -pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_uint_32 check; - png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */ - png_FILE_p io_ptr; - - /* Check if data really is near. If so, use usual code. */ - near_data = (png_byte *)CVT_PTR_NOCHECK(data); - io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); - if ((png_bytep)near_data == data) - { - WRITEFILE(io_ptr, near_data, length, check); - } - else - { - png_byte buf[NEAR_BUF_SIZE]; - png_size_t written, remaining, err; - check = 0; - remaining = length; - do - { - written = MIN(NEAR_BUF_SIZE, remaining); - png_memcpy(buf, data, written); /* copy far buffer to near buffer */ - WRITEFILE(io_ptr, buf, written, err); - if (err != written) - break; - else - check += err; - data += written; - remaining -= written; - } - while (remaining != 0); - } - if (check != length) - { - png_error(png_ptr, "Write Error"); - } -} - -#endif /* USE_FAR_KEYWORD */ - -/* This function is called when there is a warning, but the library thinks - * it can continue anyway. Replacement functions don't have to do anything - * here if you don't want to. In the default configuration, png_ptr is - * not used, but it is passed in case it may be useful. - */ -static void -pngtest_warning(png_structp png_ptr, png_const_charp message) -{ - PNG_CONST char *name = "UNKNOWN (ERROR!)"; - if (png_ptr != NULL && png_ptr->error_ptr != NULL) - name = png_ptr->error_ptr; - fprintf(STDERR, "%s: libpng warning: %s\n", name, message); -} - -/* This is the default error handling function. Note that replacements for - * this function MUST NOT RETURN, or the program will likely crash. This - * function is used by default, or if the program supplies NULL for the - * error function pointer in png_set_error_fn(). - */ -static void -pngtest_error(png_structp png_ptr, png_const_charp message) -{ - pngtest_warning(png_ptr, message); - /* We can return because png_error calls the default handler, which is - * actually OK in this case. */ -} -#endif /* PNG_NO_STDIO */ -/* END of code to validate stdio-free compilation */ - -/* START of code to validate memory allocation and deallocation */ -#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - -/* Allocate memory. For reasonable files, size should never exceed - 64K. However, zlib may allocate more then 64K if you don't tell - it not to. See zconf.h and png.h for more information. zlib does - need to allocate exactly 64K, so whatever you call here must - have the ability to do that. - - This piece of code can be compiled to validate max 64K allocations - by setting MAXSEG_64K in zlib zconf.h *or* PNG_MAX_MALLOC_64K. */ -typedef struct memory_information -{ - png_uint_32 size; - png_voidp pointer; - struct memory_information FAR *next; -} memory_information; -typedef memory_information FAR *memory_infop; - -static memory_infop pinformation = NULL; -static int current_allocation = 0; -static int maximum_allocation = 0; -static int total_allocation = 0; -static int num_allocations = 0; - -png_voidp png_debug_malloc PNGARG((png_structp png_ptr, png_uint_32 size)); -void png_debug_free PNGARG((png_structp png_ptr, png_voidp ptr)); - -png_voidp -png_debug_malloc(png_structp png_ptr, png_uint_32 size) -{ - - /* png_malloc has already tested for NULL; png_create_struct calls - png_debug_malloc directly, with png_ptr == NULL which is OK */ - - if (size == 0) - return (NULL); - - /* This calls the library allocator twice, once to get the requested - buffer and once to get a new free list entry. */ - { - /* Disable malloc_fn and free_fn */ - memory_infop pinfo; - png_set_mem_fn(png_ptr, NULL, NULL, NULL); - pinfo = (memory_infop)png_malloc(png_ptr, - (png_uint_32)png_sizeof (*pinfo)); - pinfo->size = size; - current_allocation += size; - total_allocation += size; - num_allocations ++; - if (current_allocation > maximum_allocation) - maximum_allocation = current_allocation; - pinfo->pointer = (png_voidp)png_malloc(png_ptr, size); - /* Restore malloc_fn and free_fn */ - png_set_mem_fn(png_ptr, png_voidp_NULL, (png_malloc_ptr)png_debug_malloc, - (png_free_ptr)png_debug_free); - if (size != 0 && pinfo->pointer == NULL) - { - current_allocation -= size; - total_allocation -= size; - png_error(png_ptr, - "out of memory in pngtest->png_debug_malloc."); - } - pinfo->next = pinformation; - pinformation = pinfo; - /* Make sure the caller isn't assuming zeroed memory. */ - png_memset(pinfo->pointer, 0xdd, pinfo->size); - if(verbose) - printf("png_malloc %lu bytes at %x\n",(unsigned long)size, - pinfo->pointer); - return (png_voidp)(pinfo->pointer); - } -} - -/* Free a pointer. It is removed from the list at the same time. */ -void -png_debug_free(png_structp png_ptr, png_voidp ptr) -{ - if (png_ptr == NULL) - fprintf(STDERR, "NULL pointer to png_debug_free.\n"); - if (ptr == 0) - { -#if 0 /* This happens all the time. */ - fprintf(STDERR, "WARNING: freeing NULL pointer\n"); -#endif - return; - } - - /* Unlink the element from the list. */ - { - memory_infop FAR *ppinfo = &pinformation; - for (;;) - { - memory_infop pinfo = *ppinfo; - if (pinfo->pointer == ptr) - { - *ppinfo = pinfo->next; - current_allocation -= pinfo->size; - if (current_allocation < 0) - fprintf(STDERR, "Duplicate free of memory\n"); - /* We must free the list element too, but first kill - the memory that is to be freed. */ - png_memset(ptr, 0x55, pinfo->size); - png_free_default(png_ptr, pinfo); - pinfo=NULL; - break; - } - if (pinfo->next == NULL) - { - fprintf(STDERR, "Pointer %x not found\n", (unsigned int)ptr); - break; - } - ppinfo = &pinfo->next; - } - } - - /* Finally free the data. */ - if(verbose) - printf("Freeing %x\n",ptr); - png_free_default(png_ptr, ptr); - ptr=NULL; -} -#endif /* PNG_USER_MEM_SUPPORTED && PNG_DEBUG */ -/* END of code to test memory allocation/deallocation */ - -/* Test one file */ -int -test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) -{ - static png_FILE_p fpin; - static png_FILE_p fpout; /* "static" prevents setjmp corruption */ - png_structp read_ptr; - png_infop read_info_ptr, end_info_ptr; -#ifdef PNG_WRITE_SUPPORTED - png_structp write_ptr; - png_infop write_info_ptr; - png_infop write_end_info_ptr; -#else - png_structp write_ptr = NULL; - png_infop write_info_ptr = NULL; - png_infop write_end_info_ptr = NULL; -#endif - png_bytep row_buf; - png_uint_32 y; - png_uint_32 width, height; - int num_pass, pass; - int bit_depth, color_type; -#ifdef PNG_SETJMP_SUPPORTED -#ifdef USE_FAR_KEYWORD - jmp_buf jmpbuf; -#endif -#endif - -#if defined(_WIN32_WCE) - TCHAR path[MAX_PATH]; -#endif - char inbuf[256], outbuf[256]; - - row_buf = NULL; - -#if defined(_WIN32_WCE) - MultiByteToWideChar(CP_ACP, 0, inname, -1, path, MAX_PATH); - if ((fpin = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE) -#else - if ((fpin = fopen(inname, "rb")) == NULL) -#endif - { - fprintf(STDERR, "Could not find input file %s\n", inname); - return (1); - } - -#if defined(_WIN32_WCE) - MultiByteToWideChar(CP_ACP, 0, outname, -1, path, MAX_PATH); - if ((fpout = CreateFile(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL)) == INVALID_HANDLE_VALUE) -#else - if ((fpout = fopen(outname, "wb")) == NULL) -#endif - { - fprintf(STDERR, "Could not open output file %s\n", outname); - FCLOSE(fpin); - return (1); - } - - png_debug(0, "Allocating read and write structures\n"); -#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - read_ptr = png_create_read_struct_2(PNG_LIBPNG_VER_STRING, png_voidp_NULL, - png_error_ptr_NULL, png_error_ptr_NULL, png_voidp_NULL, - (png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free); -#else - read_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL, - png_error_ptr_NULL, png_error_ptr_NULL); -#endif -#if defined(PNG_NO_STDIO) - png_set_error_fn(read_ptr, (png_voidp)inname, pngtest_error, - pngtest_warning); -#endif -#ifdef PNG_WRITE_SUPPORTED -#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - write_ptr = png_create_write_struct_2(PNG_LIBPNG_VER_STRING, png_voidp_NULL, - png_error_ptr_NULL, png_error_ptr_NULL, png_voidp_NULL, - (png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free); -#else - write_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL, - png_error_ptr_NULL, png_error_ptr_NULL); -#endif -#if defined(PNG_NO_STDIO) - png_set_error_fn(write_ptr, (png_voidp)inname, pngtest_error, - pngtest_warning); -#endif -#endif - png_debug(0, "Allocating read_info, write_info and end_info structures\n"); - read_info_ptr = png_create_info_struct(read_ptr); - end_info_ptr = png_create_info_struct(read_ptr); -#ifdef PNG_WRITE_SUPPORTED - write_info_ptr = png_create_info_struct(write_ptr); - write_end_info_ptr = png_create_info_struct(write_ptr); -#endif - -#ifdef PNG_SETJMP_SUPPORTED - png_debug(0, "Setting jmpbuf for read struct\n"); -#ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) -#else - if (setjmp(png_jmpbuf(read_ptr))) -#endif - { - fprintf(STDERR, "%s -> %s: libpng read error\n", inname, outname); - if (row_buf) - png_free(read_ptr, row_buf); - png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); -#ifdef PNG_WRITE_SUPPORTED - png_destroy_info_struct(write_ptr, &write_end_info_ptr); - png_destroy_write_struct(&write_ptr, &write_info_ptr); -#endif - FCLOSE(fpin); - FCLOSE(fpout); - return (1); - } -#ifdef USE_FAR_KEYWORD - png_memcpy(png_jmpbuf(read_ptr),jmpbuf,png_sizeof(jmp_buf)); -#endif - -#ifdef PNG_WRITE_SUPPORTED - png_debug(0, "Setting jmpbuf for write struct\n"); -#ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) -#else - if (setjmp(png_jmpbuf(write_ptr))) -#endif - { - fprintf(STDERR, "%s -> %s: libpng write error\n", inname, outname); - png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); - png_destroy_info_struct(write_ptr, &write_end_info_ptr); -#ifdef PNG_WRITE_SUPPORTED - png_destroy_write_struct(&write_ptr, &write_info_ptr); -#endif - FCLOSE(fpin); - FCLOSE(fpout); - return (1); - } -#ifdef USE_FAR_KEYWORD - png_memcpy(png_jmpbuf(write_ptr),jmpbuf,png_sizeof(jmp_buf)); -#endif -#endif -#endif - - png_debug(0, "Initializing input and output streams\n"); -#if !defined(PNG_NO_STDIO) - png_init_io(read_ptr, fpin); -# ifdef PNG_WRITE_SUPPORTED - png_init_io(write_ptr, fpout); -# endif -#else - png_set_read_fn(read_ptr, (png_voidp)fpin, pngtest_read_data); -# ifdef PNG_WRITE_SUPPORTED - png_set_write_fn(write_ptr, (png_voidp)fpout, pngtest_write_data, -# if defined(PNG_WRITE_FLUSH_SUPPORTED) - pngtest_flush); -# else - NULL); -# endif -# endif -#endif - if(status_dots_requested == 1) - { -#ifdef PNG_WRITE_SUPPORTED - png_set_write_status_fn(write_ptr, write_row_callback); -#endif - png_set_read_status_fn(read_ptr, read_row_callback); - } - else - { -#ifdef PNG_WRITE_SUPPORTED - png_set_write_status_fn(write_ptr, png_write_status_ptr_NULL); -#endif - png_set_read_status_fn(read_ptr, png_read_status_ptr_NULL); - } - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - { - int i; - for(i=0; i<256; i++) - filters_used[i]=0; - png_set_read_user_transform_fn(read_ptr, count_filters); - } -#endif -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) - zero_samples=0; - png_set_write_user_transform_fn(write_ptr, count_zero_samples); -#endif - -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) -# ifndef PNG_HANDLE_CHUNK_ALWAYS -# define PNG_HANDLE_CHUNK_ALWAYS 3 -# endif - png_set_keep_unknown_chunks(read_ptr, PNG_HANDLE_CHUNK_ALWAYS, - png_bytep_NULL, 0); -#endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) -# ifndef PNG_HANDLE_CHUNK_IF_SAFE -# define PNG_HANDLE_CHUNK_IF_SAFE 2 -# endif - png_set_keep_unknown_chunks(write_ptr, PNG_HANDLE_CHUNK_IF_SAFE, - png_bytep_NULL, 0); -#endif - - png_debug(0, "Reading info struct\n"); - png_read_info(read_ptr, read_info_ptr); - - png_debug(0, "Transferring info struct\n"); - { - int interlace_type, compression_type, filter_type; - - if (png_get_IHDR(read_ptr, read_info_ptr, &width, &height, &bit_depth, - &color_type, &interlace_type, &compression_type, &filter_type)) - { - png_set_IHDR(write_ptr, write_info_ptr, width, height, bit_depth, -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) - color_type, interlace_type, compression_type, filter_type); -#else - color_type, PNG_INTERLACE_NONE, compression_type, filter_type); -#endif - } - } -#if defined(PNG_FIXED_POINT_SUPPORTED) -#if defined(PNG_cHRM_SUPPORTED) - { - png_fixed_point white_x, white_y, red_x, red_y, green_x, green_y, blue_x, - blue_y; - if (png_get_cHRM_fixed(read_ptr, read_info_ptr, &white_x, &white_y, &red_x, - &red_y, &green_x, &green_y, &blue_x, &blue_y)) - { - png_set_cHRM_fixed(write_ptr, write_info_ptr, white_x, white_y, red_x, - red_y, green_x, green_y, blue_x, blue_y); - } - } -#endif -#if defined(PNG_gAMA_SUPPORTED) - { - png_fixed_point gamma; - - if (png_get_gAMA_fixed(read_ptr, read_info_ptr, &gamma)) - { - png_set_gAMA_fixed(write_ptr, write_info_ptr, gamma); - } - } -#endif -#else /* Use floating point versions */ -#if defined(PNG_FLOATING_POINT_SUPPORTED) -#if defined(PNG_cHRM_SUPPORTED) - { - double white_x, white_y, red_x, red_y, green_x, green_y, blue_x, - blue_y; - if (png_get_cHRM(read_ptr, read_info_ptr, &white_x, &white_y, &red_x, - &red_y, &green_x, &green_y, &blue_x, &blue_y)) - { - png_set_cHRM(write_ptr, write_info_ptr, white_x, white_y, red_x, - red_y, green_x, green_y, blue_x, blue_y); - } - } -#endif -#if defined(PNG_gAMA_SUPPORTED) - { - double gamma; - - if (png_get_gAMA(read_ptr, read_info_ptr, &gamma)) - { - png_set_gAMA(write_ptr, write_info_ptr, gamma); - } - } -#endif -#endif /* floating point */ -#endif /* fixed point */ -#if defined(PNG_iCCP_SUPPORTED) - { - png_charp name; - png_charp profile; - png_uint_32 proflen; - int compression_type; - - if (png_get_iCCP(read_ptr, read_info_ptr, &name, &compression_type, - &profile, &proflen)) - { - png_set_iCCP(write_ptr, write_info_ptr, name, compression_type, - profile, proflen); - } - } -#endif -#if defined(PNG_sRGB_SUPPORTED) - { - int intent; - - if (png_get_sRGB(read_ptr, read_info_ptr, &intent)) - { - png_set_sRGB(write_ptr, write_info_ptr, intent); - } - } -#endif - { - png_colorp palette; - int num_palette; - - if (png_get_PLTE(read_ptr, read_info_ptr, &palette, &num_palette)) - { - png_set_PLTE(write_ptr, write_info_ptr, palette, num_palette); - } - } -#if defined(PNG_bKGD_SUPPORTED) - { - png_color_16p background; - - if (png_get_bKGD(read_ptr, read_info_ptr, &background)) - { - png_set_bKGD(write_ptr, write_info_ptr, background); - } - } -#endif -#if defined(PNG_hIST_SUPPORTED) - { - png_uint_16p hist; - - if (png_get_hIST(read_ptr, read_info_ptr, &hist)) - { - png_set_hIST(write_ptr, write_info_ptr, hist); - } - } -#endif -#if defined(PNG_oFFs_SUPPORTED) - { - png_int_32 offset_x, offset_y; - int unit_type; - - if (png_get_oFFs(read_ptr, read_info_ptr,&offset_x,&offset_y,&unit_type)) - { - png_set_oFFs(write_ptr, write_info_ptr, offset_x, offset_y, unit_type); - } - } -#endif -#if defined(PNG_pCAL_SUPPORTED) - { - png_charp purpose, units; - png_charpp params; - png_int_32 X0, X1; - int type, nparams; - - if (png_get_pCAL(read_ptr, read_info_ptr, &purpose, &X0, &X1, &type, - &nparams, &units, ¶ms)) - { - png_set_pCAL(write_ptr, write_info_ptr, purpose, X0, X1, type, - nparams, units, params); - } - } -#endif -#if defined(PNG_pHYs_SUPPORTED) - { - png_uint_32 res_x, res_y; - int unit_type; - - if (png_get_pHYs(read_ptr, read_info_ptr, &res_x, &res_y, &unit_type)) - { - png_set_pHYs(write_ptr, write_info_ptr, res_x, res_y, unit_type); - } - } -#endif -#if defined(PNG_sBIT_SUPPORTED) - { - png_color_8p sig_bit; - - if (png_get_sBIT(read_ptr, read_info_ptr, &sig_bit)) - { - png_set_sBIT(write_ptr, write_info_ptr, sig_bit); - } - } -#endif -#if defined(PNG_sCAL_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED - { - int unit; - double scal_width, scal_height; - - if (png_get_sCAL(read_ptr, read_info_ptr, &unit, &scal_width, - &scal_height)) - { - png_set_sCAL(write_ptr, write_info_ptr, unit, scal_width, scal_height); - } - } -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - { - int unit; - png_charp scal_width, scal_height; - - if (png_get_sCAL_s(read_ptr, read_info_ptr, &unit, &scal_width, - &scal_height)) - { - png_set_sCAL_s(write_ptr, write_info_ptr, unit, scal_width, scal_height); - } - } -#endif -#endif -#endif -#if defined(PNG_TEXT_SUPPORTED) - { - png_textp text_ptr; - int num_text; - - if (png_get_text(read_ptr, read_info_ptr, &text_ptr, &num_text) > 0) - { - png_debug1(0, "Handling %d iTXt/tEXt/zTXt chunks\n", num_text); - png_set_text(write_ptr, write_info_ptr, text_ptr, num_text); - } - } -#endif -#if defined(PNG_tIME_SUPPORTED) - { - png_timep mod_time; - - if (png_get_tIME(read_ptr, read_info_ptr, &mod_time)) - { - png_set_tIME(write_ptr, write_info_ptr, mod_time); -#if defined(PNG_TIME_RFC1123_SUPPORTED) - /* we have to use png_strcpy instead of "=" because the string - pointed to by png_convert_to_rfc1123() gets free'ed before - we use it */ - png_strcpy(tIME_string,png_convert_to_rfc1123(read_ptr, mod_time)); - tIME_chunk_present++; -#endif /* PNG_TIME_RFC1123_SUPPORTED */ - } - } -#endif -#if defined(PNG_tRNS_SUPPORTED) - { - png_bytep trans; - int num_trans; - png_color_16p trans_values; - - if (png_get_tRNS(read_ptr, read_info_ptr, &trans, &num_trans, - &trans_values)) - { - png_set_tRNS(write_ptr, write_info_ptr, trans, num_trans, - trans_values); - } - } -#endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) - { - png_unknown_chunkp unknowns; - int num_unknowns = (int)png_get_unknown_chunks(read_ptr, read_info_ptr, - &unknowns); - if (num_unknowns) - { - png_size_t i; - png_set_unknown_chunks(write_ptr, write_info_ptr, unknowns, - num_unknowns); - /* copy the locations from the read_info_ptr. The automatically - generated locations in write_info_ptr are wrong because we - haven't written anything yet */ - for (i = 0; i < (png_size_t)num_unknowns; i++) - png_set_unknown_chunk_location(write_ptr, write_info_ptr, i, - unknowns[i].location); - } - } -#endif - -#ifdef PNG_WRITE_SUPPORTED - png_debug(0, "\nWriting info struct\n"); - -/* If we wanted, we could write info in two steps: - png_write_info_before_PLTE(write_ptr, write_info_ptr); - */ - png_write_info(write_ptr, write_info_ptr); -#endif - -#ifdef SINGLE_ROWBUF_ALLOC - png_debug(0, "\nAllocating row buffer..."); - row_buf = (png_bytep)png_malloc(read_ptr, - png_get_rowbytes(read_ptr, read_info_ptr)); - png_debug1(0, "0x%08lx\n\n", (unsigned long)row_buf); -#endif /* SINGLE_ROWBUF_ALLOC */ - png_debug(0, "Writing row data\n"); - -#if defined(PNG_READ_INTERLACING_SUPPORTED) || \ - defined(PNG_WRITE_INTERLACING_SUPPORTED) - num_pass = png_set_interlace_handling(read_ptr); -# ifdef PNG_WRITE_SUPPORTED - png_set_interlace_handling(write_ptr); -# endif -#else - num_pass=1; -#endif - -#ifdef PNGTEST_TIMING - t_stop = (float)clock(); - t_misc += (t_stop - t_start); - t_start = t_stop; -#endif - for (pass = 0; pass < num_pass; pass++) - { - png_debug1(0, "Writing row data for pass %d\n",pass); - for (y = 0; y < height; y++) - { -#ifndef SINGLE_ROWBUF_ALLOC - png_debug2(0, "\nAllocating row buffer (pass %d, y = %ld)...", pass,y); - row_buf = (png_bytep)png_malloc(read_ptr, - png_get_rowbytes(read_ptr, read_info_ptr)); - png_debug2(0, "0x%08lx (%ld bytes)\n", (unsigned long)row_buf, - png_get_rowbytes(read_ptr, read_info_ptr)); -#endif /* !SINGLE_ROWBUF_ALLOC */ - png_read_rows(read_ptr, (png_bytepp)&row_buf, png_bytepp_NULL, 1); - -#ifdef PNG_WRITE_SUPPORTED -#ifdef PNGTEST_TIMING - t_stop = (float)clock(); - t_decode += (t_stop - t_start); - t_start = t_stop; -#endif - png_write_rows(write_ptr, (png_bytepp)&row_buf, 1); -#ifdef PNGTEST_TIMING - t_stop = (float)clock(); - t_encode += (t_stop - t_start); - t_start = t_stop; -#endif -#endif /* PNG_WRITE_SUPPORTED */ - -#ifndef SINGLE_ROWBUF_ALLOC - png_debug2(0, "Freeing row buffer (pass %d, y = %ld)\n\n", pass, y); - png_free(read_ptr, row_buf); -#endif /* !SINGLE_ROWBUF_ALLOC */ - } - } - -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - png_free_data(read_ptr, read_info_ptr, PNG_FREE_UNKN, -1); -#endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) - png_free_data(write_ptr, write_info_ptr, PNG_FREE_UNKN, -1); -#endif - - png_debug(0, "Reading and writing end_info data\n"); - - png_read_end(read_ptr, end_info_ptr); -#if defined(PNG_TEXT_SUPPORTED) - { - png_textp text_ptr; - int num_text; - - if (png_get_text(read_ptr, end_info_ptr, &text_ptr, &num_text) > 0) - { - png_debug1(0, "Handling %d iTXt/tEXt/zTXt chunks\n", num_text); - png_set_text(write_ptr, write_end_info_ptr, text_ptr, num_text); - } - } -#endif -#if defined(PNG_tIME_SUPPORTED) - { - png_timep mod_time; - - if (png_get_tIME(read_ptr, end_info_ptr, &mod_time)) - { - png_set_tIME(write_ptr, write_end_info_ptr, mod_time); -#if defined(PNG_TIME_RFC1123_SUPPORTED) - /* we have to use png_strcpy instead of "=" because the string - pointed to by png_convert_to_rfc1123() gets free'ed before - we use it */ - png_strcpy(tIME_string,png_convert_to_rfc1123(read_ptr, mod_time)); - tIME_chunk_present++; -#endif /* PNG_TIME_RFC1123_SUPPORTED */ - } - } -#endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) - { - png_unknown_chunkp unknowns; - int num_unknowns; - num_unknowns = (int)png_get_unknown_chunks(read_ptr, end_info_ptr, - &unknowns); - if (num_unknowns) - { - png_size_t i; - png_set_unknown_chunks(write_ptr, write_end_info_ptr, unknowns, - num_unknowns); - /* copy the locations from the read_info_ptr. The automatically - generated locations in write_end_info_ptr are wrong because we - haven't written the end_info yet */ - for (i = 0; i < (png_size_t)num_unknowns; i++) - png_set_unknown_chunk_location(write_ptr, write_end_info_ptr, i, - unknowns[i].location); - } - } -#endif -#ifdef PNG_WRITE_SUPPORTED - png_write_end(write_ptr, write_end_info_ptr); -#endif - -#ifdef PNG_EASY_ACCESS_SUPPORTED - if(verbose) - { - png_uint_32 iwidth, iheight; - iwidth = png_get_image_width(write_ptr, write_info_ptr); - iheight = png_get_image_height(write_ptr, write_info_ptr); - fprintf(STDERR, "Image width = %lu, height = %lu\n", - (unsigned long)iwidth, (unsigned long)iheight); - } -#endif - - png_debug(0, "Destroying data structs\n"); -#ifdef SINGLE_ROWBUF_ALLOC - png_debug(1, "destroying row_buf for read_ptr\n"); - png_free(read_ptr, row_buf); - row_buf=NULL; -#endif /* SINGLE_ROWBUF_ALLOC */ - png_debug(1, "destroying read_ptr, read_info_ptr, end_info_ptr\n"); - png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); -#ifdef PNG_WRITE_SUPPORTED - png_debug(1, "destroying write_end_info_ptr\n"); - png_destroy_info_struct(write_ptr, &write_end_info_ptr); - png_debug(1, "destroying write_ptr, write_info_ptr\n"); - png_destroy_write_struct(&write_ptr, &write_info_ptr); -#endif - png_debug(0, "Destruction complete.\n"); - - FCLOSE(fpin); - FCLOSE(fpout); - - png_debug(0, "Opening files for comparison\n"); -#if defined(_WIN32_WCE) - MultiByteToWideChar(CP_ACP, 0, inname, -1, path, MAX_PATH); - if ((fpin = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE) -#else - if ((fpin = fopen(inname, "rb")) == NULL) -#endif - { - fprintf(STDERR, "Could not find file %s\n", inname); - return (1); - } - -#if defined(_WIN32_WCE) - MultiByteToWideChar(CP_ACP, 0, outname, -1, path, MAX_PATH); - if ((fpout = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE) -#else - if ((fpout = fopen(outname, "rb")) == NULL) -#endif - { - fprintf(STDERR, "Could not find file %s\n", outname); - FCLOSE(fpin); - return (1); - } - - for(;;) - { - png_size_t num_in, num_out; - - READFILE(fpin, inbuf, 1, num_in); - READFILE(fpout, outbuf, 1, num_out); - - if (num_in != num_out) - { - fprintf(STDERR, "\nFiles %s and %s are of a different size\n", - inname, outname); - if(wrote_question == 0) - { - fprintf(STDERR, - " Was %s written with the same maximum IDAT chunk size (%d bytes),", - inname,PNG_ZBUF_SIZE); - fprintf(STDERR, - "\n filtering heuristic (libpng default), compression"); - fprintf(STDERR, - " level (zlib default),\n and zlib version (%s)?\n\n", - ZLIB_VERSION); - wrote_question=1; - } - FCLOSE(fpin); - FCLOSE(fpout); - return (0); - } - - if (!num_in) - break; - - if (png_memcmp(inbuf, outbuf, num_in)) - { - fprintf(STDERR, "\nFiles %s and %s are different\n", inname, outname); - if(wrote_question == 0) - { - fprintf(STDERR, - " Was %s written with the same maximum IDAT chunk size (%d bytes),", - inname,PNG_ZBUF_SIZE); - fprintf(STDERR, - "\n filtering heuristic (libpng default), compression"); - fprintf(STDERR, - " level (zlib default),\n and zlib version (%s)?\n\n", - ZLIB_VERSION); - wrote_question=1; - } - FCLOSE(fpin); - FCLOSE(fpout); - return (0); - } - } - - FCLOSE(fpin); - FCLOSE(fpout); - - return (0); -} - -/* input and output filenames */ -#ifdef RISCOS -static PNG_CONST char *inname = "pngtest/png"; -static PNG_CONST char *outname = "pngout/png"; -#else -static PNG_CONST char *inname = "pngtest.png"; -static PNG_CONST char *outname = "pngout.png"; -#endif - -int -main(int argc, char *argv[]) -{ - int multiple = 0; - int ierror = 0; - - fprintf(STDERR, "Testing libpng version %s\n", PNG_LIBPNG_VER_STRING); - fprintf(STDERR, " with zlib version %s\n", ZLIB_VERSION); - fprintf(STDERR,"%s",png_get_copyright(NULL)); - /* Show the version of libpng used in building the library */ - fprintf(STDERR," library (%lu):%s", - (unsigned long)png_access_version_number(), - png_get_header_version(NULL)); - /* Show the version of libpng used in building the application */ - fprintf(STDERR," pngtest (%lu):%s", (unsigned long)PNG_LIBPNG_VER, - PNG_HEADER_VERSION_STRING); - fprintf(STDERR," png_sizeof(png_struct)=%ld, png_sizeof(png_info)=%ld\n", - (long)png_sizeof(png_struct), (long)png_sizeof(png_info)); - - /* Do some consistency checking on the memory allocation settings, I'm - not sure this matters, but it is nice to know, the first of these - tests should be impossible because of the way the macros are set - in pngconf.h */ -#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K) - fprintf(STDERR, " NOTE: Zlib compiled for max 64k, libpng not\n"); -#endif - /* I think the following can happen. */ -#if !defined(MAXSEG_64K) && defined(PNG_MAX_MALLOC_64K) - fprintf(STDERR, " NOTE: libpng compiled for max 64k, zlib not\n"); -#endif - - if (strcmp(png_libpng_ver, PNG_LIBPNG_VER_STRING)) - { - fprintf(STDERR, - "Warning: versions are different between png.h and png.c\n"); - fprintf(STDERR, " png.h version: %s\n", PNG_LIBPNG_VER_STRING); - fprintf(STDERR, " png.c version: %s\n\n", png_libpng_ver); - ++ierror; - } - - if (argc > 1) - { - if (strcmp(argv[1], "-m") == 0) - { - multiple = 1; - status_dots_requested = 0; - } - else if (strcmp(argv[1], "-mv") == 0 || - strcmp(argv[1], "-vm") == 0 ) - { - multiple = 1; - verbose = 1; - status_dots_requested = 1; - } - else if (strcmp(argv[1], "-v") == 0) - { - verbose = 1; - status_dots_requested = 1; - inname = argv[2]; - } - else - { - inname = argv[1]; - status_dots_requested = 0; - } - } - - if (!multiple && argc == 3+verbose) - outname = argv[2+verbose]; - - if ((!multiple && argc > 3+verbose) || (multiple && argc < 2)) - { - fprintf(STDERR, - "usage: %s [infile.png] [outfile.png]\n\t%s -m {infile.png}\n", - argv[0], argv[0]); - fprintf(STDERR, - " reads/writes one PNG file (without -m) or multiple files (-m)\n"); - fprintf(STDERR, - " with -m %s is used as a temporary file\n", outname); - exit(1); - } - - if (multiple) - { - int i; -#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - int allocation_now = current_allocation; -#endif - for (i=2; i<argc; ++i) - { -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - int k; -#endif - int kerror; - fprintf(STDERR, "Testing %s:",argv[i]); - kerror = test_one_file(argv[i], outname); - if (kerror == 0) - { -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) - fprintf(STDERR, "\n PASS (%lu zero samples)\n", - (unsigned long)zero_samples); -#else - fprintf(STDERR, " PASS\n"); -#endif -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - for (k=0; k<256; k++) - if(filters_used[k]) - fprintf(STDERR, " Filter %d was used %lu times\n", - k,(unsigned long)filters_used[k]); -#endif -#if defined(PNG_TIME_RFC1123_SUPPORTED) - if(tIME_chunk_present != 0) - fprintf(STDERR, " tIME = %s\n",tIME_string); - tIME_chunk_present = 0; -#endif /* PNG_TIME_RFC1123_SUPPORTED */ - } - else - { - fprintf(STDERR, " FAIL\n"); - ierror += kerror; - } -#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - if (allocation_now != current_allocation) - fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n", - current_allocation-allocation_now); - if (current_allocation != 0) - { - memory_infop pinfo = pinformation; - - fprintf(STDERR, "MEMORY ERROR: %d bytes still allocated\n", - current_allocation); - while (pinfo != NULL) - { - fprintf(STDERR, " %lu bytes at %x\n", (unsigned long)pinfo->size, - (unsigned int) pinfo->pointer); - pinfo = pinfo->next; - } - } -#endif - } -#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - fprintf(STDERR, " Current memory allocation: %10d bytes\n", - current_allocation); - fprintf(STDERR, " Maximum memory allocation: %10d bytes\n", - maximum_allocation); - fprintf(STDERR, " Total memory allocation: %10d bytes\n", - total_allocation); - fprintf(STDERR, " Number of allocations: %10d\n", - num_allocations); -#endif - } - else - { - int i; - for (i=0; i<3; ++i) - { - int kerror; -#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - int allocation_now = current_allocation; -#endif - if (i == 1) status_dots_requested = 1; - else if(verbose == 0)status_dots_requested = 0; - if (i == 0 || verbose == 1 || ierror != 0) - fprintf(STDERR, "Testing %s:",inname); - kerror = test_one_file(inname, outname); - if(kerror == 0) - { - if(verbose == 1 || i == 2) - { -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - int k; -#endif -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) - fprintf(STDERR, "\n PASS (%lu zero samples)\n", - (unsigned long)zero_samples); -#else - fprintf(STDERR, " PASS\n"); -#endif -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - for (k=0; k<256; k++) - if(filters_used[k]) - fprintf(STDERR, " Filter %d was used %lu times\n", - k,(unsigned long)filters_used[k]); -#endif -#if defined(PNG_TIME_RFC1123_SUPPORTED) - if(tIME_chunk_present != 0) - fprintf(STDERR, " tIME = %s\n",tIME_string); -#endif /* PNG_TIME_RFC1123_SUPPORTED */ - } - } - else - { - if(verbose == 0 && i != 2) - fprintf(STDERR, "Testing %s:",inname); - fprintf(STDERR, " FAIL\n"); - ierror += kerror; - } -#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - if (allocation_now != current_allocation) - fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n", - current_allocation-allocation_now); - if (current_allocation != 0) - { - memory_infop pinfo = pinformation; - - fprintf(STDERR, "MEMORY ERROR: %d bytes still allocated\n", - current_allocation); - while (pinfo != NULL) - { - fprintf(STDERR," %lu bytes at %x\n", - (unsigned long)pinfo->size, (unsigned int)pinfo->pointer); - pinfo = pinfo->next; - } - } -#endif - } -#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - fprintf(STDERR, " Current memory allocation: %10d bytes\n", - current_allocation); - fprintf(STDERR, " Maximum memory allocation: %10d bytes\n", - maximum_allocation); - fprintf(STDERR, " Total memory allocation: %10d bytes\n", - total_allocation); - fprintf(STDERR, " Number of allocations: %10d\n", - num_allocations); -#endif - } - -#ifdef PNGTEST_TIMING - t_stop = (float)clock(); - t_misc += (t_stop - t_start); - t_start = t_stop; - fprintf(STDERR," CPU time used = %.3f seconds", - (t_misc+t_decode+t_encode)/(float)CLOCKS_PER_SEC); - fprintf(STDERR," (decoding %.3f,\n", - t_decode/(float)CLOCKS_PER_SEC); - fprintf(STDERR," encoding %.3f ,", - t_encode/(float)CLOCKS_PER_SEC); - fprintf(STDERR," other %.3f seconds)\n\n", - t_misc/(float)CLOCKS_PER_SEC); -#endif - - if (ierror == 0) - fprintf(STDERR, "libpng passes test\n"); - else - fprintf(STDERR, "libpng FAILS test\n"); - return (int)(ierror != 0); -} - -/* Generate a compiler error if there is an old png.h in the search path. */ -typedef version_1_2_18 your_png_h_is_not_version_1_2_18; diff --git a/irrlicht-1.6/source/Irrlicht/libpng/pngtest.png b/irrlicht-1.6/source/Irrlicht/libpng/pngtest.png deleted file mode 100644 index f3a6df448..000000000 Binary files a/irrlicht-1.6/source/Irrlicht/libpng/pngtest.png and /dev/null differ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/pngtrans.c b/irrlicht-1.6/source/Irrlicht/libpng/pngtrans.c deleted file mode 100644 index 4f09aadc3..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/pngtrans.c +++ /dev/null @@ -1,662 +0,0 @@ - -/* pngtrans.c - transforms the data in a row (used by both readers and writers) - * - * Last changed in libpng 1.2.13 November 13, 2006 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2006 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) -#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -/* turn on BGR-to-RGB mapping */ -void PNGAPI -png_set_bgr(png_structp png_ptr) -{ - png_debug(1, "in png_set_bgr\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= PNG_BGR; -} -#endif - -#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) -/* turn on 16 bit byte swapping */ -void PNGAPI -png_set_swap(png_structp png_ptr) -{ - png_debug(1, "in png_set_swap\n"); - if(png_ptr == NULL) return; - if (png_ptr->bit_depth == 16) - png_ptr->transformations |= PNG_SWAP_BYTES; -} -#endif - -#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) -/* turn on pixel packing */ -void PNGAPI -png_set_packing(png_structp png_ptr) -{ - png_debug(1, "in png_set_packing\n"); - if(png_ptr == NULL) return; - if (png_ptr->bit_depth < 8) - { - png_ptr->transformations |= PNG_PACK; - png_ptr->usr_bit_depth = 8; - } -} -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED) -/* turn on packed pixel swapping */ -void PNGAPI -png_set_packswap(png_structp png_ptr) -{ - png_debug(1, "in png_set_packswap\n"); - if(png_ptr == NULL) return; - if (png_ptr->bit_depth < 8) - png_ptr->transformations |= PNG_PACKSWAP; -} -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) -void PNGAPI -png_set_shift(png_structp png_ptr, png_color_8p true_bits) -{ - png_debug(1, "in png_set_shift\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= PNG_SHIFT; - png_ptr->shift = *true_bits; -} -#endif - -#if defined(PNG_READ_INTERLACING_SUPPORTED) || \ - defined(PNG_WRITE_INTERLACING_SUPPORTED) -int PNGAPI -png_set_interlace_handling(png_structp png_ptr) -{ - png_debug(1, "in png_set_interlace handling\n"); - if (png_ptr && png_ptr->interlaced) - { - png_ptr->transformations |= PNG_INTERLACE; - return (7); - } - - return (1); -} -#endif - -#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) -/* Add a filler byte on read, or remove a filler or alpha byte on write. - * The filler type has changed in v0.95 to allow future 2-byte fillers - * for 48-bit input data, as well as to avoid problems with some compilers - * that don't like bytes as parameters. - */ -void PNGAPI -png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc) -{ - png_debug(1, "in png_set_filler\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= PNG_FILLER; - png_ptr->filler = (png_byte)filler; - if (filler_loc == PNG_FILLER_AFTER) - png_ptr->flags |= PNG_FLAG_FILLER_AFTER; - else - png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER; - - /* This should probably go in the "do_read_filler" routine. - * I attempted to do that in libpng-1.0.1a but that caused problems - * so I restored it in libpng-1.0.2a - */ - - if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) - { - png_ptr->usr_channels = 4; - } - - /* Also I added this in libpng-1.0.2a (what happens when we expand - * a less-than-8-bit grayscale to GA? */ - - if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY && png_ptr->bit_depth >= 8) - { - png_ptr->usr_channels = 2; - } -} - -#if !defined(PNG_1_0_X) -/* Added to libpng-1.2.7 */ -void PNGAPI -png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc) -{ - png_debug(1, "in png_set_add_alpha\n"); - if(png_ptr == NULL) return; - png_set_filler(png_ptr, filler, filler_loc); - png_ptr->transformations |= PNG_ADD_ALPHA; -} -#endif - -#endif - -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ - defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) -void PNGAPI -png_set_swap_alpha(png_structp png_ptr) -{ - png_debug(1, "in png_set_swap_alpha\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= PNG_SWAP_ALPHA; -} -#endif - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ - defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) -void PNGAPI -png_set_invert_alpha(png_structp png_ptr) -{ - png_debug(1, "in png_set_invert_alpha\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= PNG_INVERT_ALPHA; -} -#endif - -#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) -void PNGAPI -png_set_invert_mono(png_structp png_ptr) -{ - png_debug(1, "in png_set_invert_mono\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= PNG_INVERT_MONO; -} - -/* invert monochrome grayscale data */ -void /* PRIVATE */ -png_do_invert(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_invert\n"); - /* This test removed from libpng version 1.0.13 and 1.2.0: - * if (row_info->bit_depth == 1 && - */ -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row == NULL || row_info == NULL) - return; -#endif - if (row_info->color_type == PNG_COLOR_TYPE_GRAY) - { - png_bytep rp = row; - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - - for (i = 0; i < istop; i++) - { - *rp = (png_byte)(~(*rp)); - rp++; - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA && - row_info->bit_depth == 8) - { - png_bytep rp = row; - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - - for (i = 0; i < istop; i+=2) - { - *rp = (png_byte)(~(*rp)); - rp+=2; - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA && - row_info->bit_depth == 16) - { - png_bytep rp = row; - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - - for (i = 0; i < istop; i+=4) - { - *rp = (png_byte)(~(*rp)); - *(rp+1) = (png_byte)(~(*(rp+1))); - rp+=4; - } - } -} -#endif - -#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) -/* swaps byte order on 16 bit depth images */ -void /* PRIVATE */ -png_do_swap(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_swap\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - row_info->bit_depth == 16) - { - png_bytep rp = row; - png_uint_32 i; - png_uint_32 istop= row_info->width * row_info->channels; - - for (i = 0; i < istop; i++, rp += 2) - { - png_byte t = *rp; - *rp = *(rp + 1); - *(rp + 1) = t; - } - } -} -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED) -static PNG_CONST png_byte onebppswaptable[256] = { - 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, - 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0, - 0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, - 0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8, - 0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4, - 0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4, - 0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC, - 0x1C, 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC, - 0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2, - 0x12, 0x92, 0x52, 0xD2, 0x32, 0xB2, 0x72, 0xF2, - 0x0A, 0x8A, 0x4A, 0xCA, 0x2A, 0xAA, 0x6A, 0xEA, - 0x1A, 0x9A, 0x5A, 0xDA, 0x3A, 0xBA, 0x7A, 0xFA, - 0x06, 0x86, 0x46, 0xC6, 0x26, 0xA6, 0x66, 0xE6, - 0x16, 0x96, 0x56, 0xD6, 0x36, 0xB6, 0x76, 0xF6, - 0x0E, 0x8E, 0x4E, 0xCE, 0x2E, 0xAE, 0x6E, 0xEE, - 0x1E, 0x9E, 0x5E, 0xDE, 0x3E, 0xBE, 0x7E, 0xFE, - 0x01, 0x81, 0x41, 0xC1, 0x21, 0xA1, 0x61, 0xE1, - 0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1, - 0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9, - 0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9, - 0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5, - 0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5, - 0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED, - 0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD, - 0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3, - 0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3, - 0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB, - 0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB, - 0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7, - 0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7, - 0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF, - 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF -}; - -static PNG_CONST png_byte twobppswaptable[256] = { - 0x00, 0x40, 0x80, 0xC0, 0x10, 0x50, 0x90, 0xD0, - 0x20, 0x60, 0xA0, 0xE0, 0x30, 0x70, 0xB0, 0xF0, - 0x04, 0x44, 0x84, 0xC4, 0x14, 0x54, 0x94, 0xD4, - 0x24, 0x64, 0xA4, 0xE4, 0x34, 0x74, 0xB4, 0xF4, - 0x08, 0x48, 0x88, 0xC8, 0x18, 0x58, 0x98, 0xD8, - 0x28, 0x68, 0xA8, 0xE8, 0x38, 0x78, 0xB8, 0xF8, - 0x0C, 0x4C, 0x8C, 0xCC, 0x1C, 0x5C, 0x9C, 0xDC, - 0x2C, 0x6C, 0xAC, 0xEC, 0x3C, 0x7C, 0xBC, 0xFC, - 0x01, 0x41, 0x81, 0xC1, 0x11, 0x51, 0x91, 0xD1, - 0x21, 0x61, 0xA1, 0xE1, 0x31, 0x71, 0xB1, 0xF1, - 0x05, 0x45, 0x85, 0xC5, 0x15, 0x55, 0x95, 0xD5, - 0x25, 0x65, 0xA5, 0xE5, 0x35, 0x75, 0xB5, 0xF5, - 0x09, 0x49, 0x89, 0xC9, 0x19, 0x59, 0x99, 0xD9, - 0x29, 0x69, 0xA9, 0xE9, 0x39, 0x79, 0xB9, 0xF9, - 0x0D, 0x4D, 0x8D, 0xCD, 0x1D, 0x5D, 0x9D, 0xDD, - 0x2D, 0x6D, 0xAD, 0xED, 0x3D, 0x7D, 0xBD, 0xFD, - 0x02, 0x42, 0x82, 0xC2, 0x12, 0x52, 0x92, 0xD2, - 0x22, 0x62, 0xA2, 0xE2, 0x32, 0x72, 0xB2, 0xF2, - 0x06, 0x46, 0x86, 0xC6, 0x16, 0x56, 0x96, 0xD6, - 0x26, 0x66, 0xA6, 0xE6, 0x36, 0x76, 0xB6, 0xF6, - 0x0A, 0x4A, 0x8A, 0xCA, 0x1A, 0x5A, 0x9A, 0xDA, - 0x2A, 0x6A, 0xAA, 0xEA, 0x3A, 0x7A, 0xBA, 0xFA, - 0x0E, 0x4E, 0x8E, 0xCE, 0x1E, 0x5E, 0x9E, 0xDE, - 0x2E, 0x6E, 0xAE, 0xEE, 0x3E, 0x7E, 0xBE, 0xFE, - 0x03, 0x43, 0x83, 0xC3, 0x13, 0x53, 0x93, 0xD3, - 0x23, 0x63, 0xA3, 0xE3, 0x33, 0x73, 0xB3, 0xF3, - 0x07, 0x47, 0x87, 0xC7, 0x17, 0x57, 0x97, 0xD7, - 0x27, 0x67, 0xA7, 0xE7, 0x37, 0x77, 0xB7, 0xF7, - 0x0B, 0x4B, 0x8B, 0xCB, 0x1B, 0x5B, 0x9B, 0xDB, - 0x2B, 0x6B, 0xAB, 0xEB, 0x3B, 0x7B, 0xBB, 0xFB, - 0x0F, 0x4F, 0x8F, 0xCF, 0x1F, 0x5F, 0x9F, 0xDF, - 0x2F, 0x6F, 0xAF, 0xEF, 0x3F, 0x7F, 0xBF, 0xFF -}; - -static PNG_CONST png_byte fourbppswaptable[256] = { - 0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, - 0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0, - 0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71, - 0x81, 0x91, 0xA1, 0xB1, 0xC1, 0xD1, 0xE1, 0xF1, - 0x02, 0x12, 0x22, 0x32, 0x42, 0x52, 0x62, 0x72, - 0x82, 0x92, 0xA2, 0xB2, 0xC2, 0xD2, 0xE2, 0xF2, - 0x03, 0x13, 0x23, 0x33, 0x43, 0x53, 0x63, 0x73, - 0x83, 0x93, 0xA3, 0xB3, 0xC3, 0xD3, 0xE3, 0xF3, - 0x04, 0x14, 0x24, 0x34, 0x44, 0x54, 0x64, 0x74, - 0x84, 0x94, 0xA4, 0xB4, 0xC4, 0xD4, 0xE4, 0xF4, - 0x05, 0x15, 0x25, 0x35, 0x45, 0x55, 0x65, 0x75, - 0x85, 0x95, 0xA5, 0xB5, 0xC5, 0xD5, 0xE5, 0xF5, - 0x06, 0x16, 0x26, 0x36, 0x46, 0x56, 0x66, 0x76, - 0x86, 0x96, 0xA6, 0xB6, 0xC6, 0xD6, 0xE6, 0xF6, - 0x07, 0x17, 0x27, 0x37, 0x47, 0x57, 0x67, 0x77, - 0x87, 0x97, 0xA7, 0xB7, 0xC7, 0xD7, 0xE7, 0xF7, - 0x08, 0x18, 0x28, 0x38, 0x48, 0x58, 0x68, 0x78, - 0x88, 0x98, 0xA8, 0xB8, 0xC8, 0xD8, 0xE8, 0xF8, - 0x09, 0x19, 0x29, 0x39, 0x49, 0x59, 0x69, 0x79, - 0x89, 0x99, 0xA9, 0xB9, 0xC9, 0xD9, 0xE9, 0xF9, - 0x0A, 0x1A, 0x2A, 0x3A, 0x4A, 0x5A, 0x6A, 0x7A, - 0x8A, 0x9A, 0xAA, 0xBA, 0xCA, 0xDA, 0xEA, 0xFA, - 0x0B, 0x1B, 0x2B, 0x3B, 0x4B, 0x5B, 0x6B, 0x7B, - 0x8B, 0x9B, 0xAB, 0xBB, 0xCB, 0xDB, 0xEB, 0xFB, - 0x0C, 0x1C, 0x2C, 0x3C, 0x4C, 0x5C, 0x6C, 0x7C, - 0x8C, 0x9C, 0xAC, 0xBC, 0xCC, 0xDC, 0xEC, 0xFC, - 0x0D, 0x1D, 0x2D, 0x3D, 0x4D, 0x5D, 0x6D, 0x7D, - 0x8D, 0x9D, 0xAD, 0xBD, 0xCD, 0xDD, 0xED, 0xFD, - 0x0E, 0x1E, 0x2E, 0x3E, 0x4E, 0x5E, 0x6E, 0x7E, - 0x8E, 0x9E, 0xAE, 0xBE, 0xCE, 0xDE, 0xEE, 0xFE, - 0x0F, 0x1F, 0x2F, 0x3F, 0x4F, 0x5F, 0x6F, 0x7F, - 0x8F, 0x9F, 0xAF, 0xBF, 0xCF, 0xDF, 0xEF, 0xFF -}; - -/* swaps pixel packing order within bytes */ -void /* PRIVATE */ -png_do_packswap(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_packswap\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - row_info->bit_depth < 8) - { - png_bytep rp, end, table; - - end = row + row_info->rowbytes; - - if (row_info->bit_depth == 1) - table = (png_bytep)onebppswaptable; - else if (row_info->bit_depth == 2) - table = (png_bytep)twobppswaptable; - else if (row_info->bit_depth == 4) - table = (png_bytep)fourbppswaptable; - else - return; - - for (rp = row; rp < end; rp++) - *rp = table[*rp]; - } -} -#endif /* PNG_READ_PACKSWAP_SUPPORTED or PNG_WRITE_PACKSWAP_SUPPORTED */ - -#if defined(PNG_WRITE_FILLER_SUPPORTED) || \ - defined(PNG_READ_STRIP_ALPHA_SUPPORTED) -/* remove filler or alpha byte(s) */ -void /* PRIVATE */ -png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags) -{ - png_debug(1, "in png_do_strip_filler\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif - { - png_bytep sp=row; - png_bytep dp=row; - png_uint_32 row_width=row_info->width; - png_uint_32 i; - - if ((row_info->color_type == PNG_COLOR_TYPE_RGB || - (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA && - (flags & PNG_FLAG_STRIP_ALPHA))) && - row_info->channels == 4) - { - if (row_info->bit_depth == 8) - { - /* This converts from RGBX or RGBA to RGB */ - if (flags & PNG_FLAG_FILLER_AFTER) - { - dp+=3; sp+=4; - for (i = 1; i < row_width; i++) - { - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - sp++; - } - } - /* This converts from XRGB or ARGB to RGB */ - else - { - for (i = 0; i < row_width; i++) - { - sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - } - } - row_info->pixel_depth = 24; - row_info->rowbytes = row_width * 3; - } - else /* if (row_info->bit_depth == 16) */ - { - if (flags & PNG_FLAG_FILLER_AFTER) - { - /* This converts from RRGGBBXX or RRGGBBAA to RRGGBB */ - sp += 8; dp += 6; - for (i = 1; i < row_width; i++) - { - /* This could be (although png_memcpy is probably slower): - png_memcpy(dp, sp, 6); - sp += 8; - dp += 6; - */ - - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - sp += 2; - } - } - else - { - /* This converts from XXRRGGBB or AARRGGBB to RRGGBB */ - for (i = 0; i < row_width; i++) - { - /* This could be (although png_memcpy is probably slower): - png_memcpy(dp, sp, 6); - sp += 8; - dp += 6; - */ - - sp+=2; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - } - } - row_info->pixel_depth = 48; - row_info->rowbytes = row_width * 6; - } - row_info->channels = 3; - } - else if ((row_info->color_type == PNG_COLOR_TYPE_GRAY || - (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA && - (flags & PNG_FLAG_STRIP_ALPHA))) && - row_info->channels == 2) - { - if (row_info->bit_depth == 8) - { - /* This converts from GX or GA to G */ - if (flags & PNG_FLAG_FILLER_AFTER) - { - for (i = 0; i < row_width; i++) - { - *dp++ = *sp++; - sp++; - } - } - /* This converts from XG or AG to G */ - else - { - for (i = 0; i < row_width; i++) - { - sp++; - *dp++ = *sp++; - } - } - row_info->pixel_depth = 8; - row_info->rowbytes = row_width; - } - else /* if (row_info->bit_depth == 16) */ - { - if (flags & PNG_FLAG_FILLER_AFTER) - { - /* This converts from GGXX or GGAA to GG */ - sp += 4; dp += 2; - for (i = 1; i < row_width; i++) - { - *dp++ = *sp++; - *dp++ = *sp++; - sp += 2; - } - } - else - { - /* This converts from XXGG or AAGG to GG */ - for (i = 0; i < row_width; i++) - { - sp += 2; - *dp++ = *sp++; - *dp++ = *sp++; - } - } - row_info->pixel_depth = 16; - row_info->rowbytes = row_width * 2; - } - row_info->channels = 1; - } - if (flags & PNG_FLAG_STRIP_ALPHA) - row_info->color_type &= ~PNG_COLOR_MASK_ALPHA; - } -} -#endif - -#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -/* swaps red and blue bytes within a pixel */ -void /* PRIVATE */ -png_do_bgr(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_bgr\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - (row_info->color_type & PNG_COLOR_MASK_COLOR)) - { - png_uint_32 row_width = row_info->width; - if (row_info->bit_depth == 8) - { - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - { - png_bytep rp; - png_uint_32 i; - - for (i = 0, rp = row; i < row_width; i++, rp += 3) - { - png_byte save = *rp; - *rp = *(rp + 2); - *(rp + 2) = save; - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - png_bytep rp; - png_uint_32 i; - - for (i = 0, rp = row; i < row_width; i++, rp += 4) - { - png_byte save = *rp; - *rp = *(rp + 2); - *(rp + 2) = save; - } - } - } - else if (row_info->bit_depth == 16) - { - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - { - png_bytep rp; - png_uint_32 i; - - for (i = 0, rp = row; i < row_width; i++, rp += 6) - { - png_byte save = *rp; - *rp = *(rp + 4); - *(rp + 4) = save; - save = *(rp + 1); - *(rp + 1) = *(rp + 5); - *(rp + 5) = save; - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - png_bytep rp; - png_uint_32 i; - - for (i = 0, rp = row; i < row_width; i++, rp += 8) - { - png_byte save = *rp; - *rp = *(rp + 4); - *(rp + 4) = save; - save = *(rp + 1); - *(rp + 1) = *(rp + 5); - *(rp + 5) = save; - } - } - } - } -} -#endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */ - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -void PNGAPI -png_set_user_transform_info(png_structp png_ptr, png_voidp - user_transform_ptr, int user_transform_depth, int user_transform_channels) -{ - png_debug(1, "in png_set_user_transform_info\n"); - if(png_ptr == NULL) return; -#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) - png_ptr->user_transform_ptr = user_transform_ptr; - png_ptr->user_transform_depth = (png_byte)user_transform_depth; - png_ptr->user_transform_channels = (png_byte)user_transform_channels; -#else - if(user_transform_ptr || user_transform_depth || user_transform_channels) - png_warning(png_ptr, - "This version of libpng does not support user transform info"); -#endif -} -#endif - -/* This function returns a pointer to the user_transform_ptr associated with - * the user transform functions. The application should free any memory - * associated with this pointer before png_write_destroy and png_read_destroy - * are called. - */ -png_voidp PNGAPI -png_get_user_transform_ptr(png_structp png_ptr) -{ -#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) - if (png_ptr == NULL) return (NULL); - return ((png_voidp)png_ptr->user_transform_ptr); -#else - return (NULL); -#endif -} -#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/pngvcrd.c b/irrlicht-1.6/source/Irrlicht/libpng/pngvcrd.c deleted file mode 100644 index 7bb6280d8..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/pngvcrd.c +++ /dev/null @@ -1,3904 +0,0 @@ - -/* pngvcrd.c - mixed C/assembler version of utilities to read a PNG file - * - * For Intel x86 CPU and Microsoft Visual C++ compiler - * - * Last changed in libpng 1.2.6 - August 15, 2004 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2004 Glenn Randers-Pehrson - * Copyright (c) 1998, Intel Corporation - * - * Contributed by Nirav Chhatrapati, Intel Corporation, 1998 - * Interface to libpng contributed by Gilles Vollant, 1999 - * - * - * In png_do_read_interlace() in libpng versions 1.0.3a through 1.0.4d, - * a sign error in the post-MMX cleanup code for each pixel_depth resulted - * in bad pixels at the beginning of some rows of some images, and also - * (due to out-of-range memory reads and writes) caused heap corruption - * when compiled with MSVC 6.0. The error was fixed in version 1.0.4e. - * - * [png_read_filter_row_mmx_avg() bpp == 2 bugfix, GRR 20000916] - * - * [runtime MMX configuration, GRR 20010102] - * - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_USE_PNGVCRD) - -static int mmx_supported=2; - - -int PNGAPI -png_mmx_support(void) -{ - int mmx_supported_local = 0; - _asm { - push ebx //CPUID will trash these - push ecx - push edx - - pushfd //Save Eflag to stack - pop eax //Get Eflag from stack into eax - mov ecx, eax //Make another copy of Eflag in ecx - xor eax, 0x200000 //Toggle ID bit in Eflag [i.e. bit(21)] - push eax //Save modified Eflag back to stack - - popfd //Restored modified value back to Eflag reg - pushfd //Save Eflag to stack - pop eax //Get Eflag from stack - push ecx // save original Eflag to stack - popfd // restore original Eflag - xor eax, ecx //Compare the new Eflag with the original Eflag - jz NOT_SUPPORTED //If the same, CPUID instruction is not supported, - //skip following instructions and jump to - //NOT_SUPPORTED label - - xor eax, eax //Set eax to zero - - _asm _emit 0x0f //CPUID instruction (two bytes opcode) - _asm _emit 0xa2 - - cmp eax, 1 //make sure eax return non-zero value - jl NOT_SUPPORTED //If eax is zero, mmx not supported - - xor eax, eax //set eax to zero - inc eax //Now increment eax to 1. This instruction is - //faster than the instruction "mov eax, 1" - - _asm _emit 0x0f //CPUID instruction - _asm _emit 0xa2 - - and edx, 0x00800000 //mask out all bits but mmx bit(24) - cmp edx, 0 // 0 = mmx not supported - jz NOT_SUPPORTED // non-zero = Yes, mmx IS supported - - mov mmx_supported_local, 1 //set return value to 1 - -NOT_SUPPORTED: - mov eax, mmx_supported_local //move return value to eax - pop edx //CPUID trashed these - pop ecx - pop ebx - } - - //mmx_supported_local=0; // test code for force don't support MMX - //printf("MMX : %u (1=MMX supported)\n",mmx_supported_local); - - mmx_supported = mmx_supported_local; - return mmx_supported_local; -} - -/* Combines the row recently read in with the previous row. - This routine takes care of alpha and transparency if requested. - This routine also handles the two methods of progressive display - of interlaced images, depending on the mask value. - The mask value describes which pixels are to be combined with - the row. The pattern always repeats every 8 pixels, so just 8 - bits are needed. A one indicates the pixel is to be combined; a - zero indicates the pixel is to be skipped. This is in addition - to any alpha or transparency value associated with the pixel. If - you want all pixels to be combined, pass 0xff (255) in mask. */ - -/* Use this routine for x86 platform - uses faster MMX routine if machine - supports MMX */ - -void /* PRIVATE */ -png_combine_row(png_structp png_ptr, png_bytep row, int mask) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; -#endif - - png_debug(1,"in png_combine_row_asm\n"); - - if (mmx_supported == 2) { -#if !defined(PNG_1_0_X) - /* this should have happened in png_init_mmx_flags() already */ - png_warning(png_ptr, "asm_flags may not have been initialized"); -#endif - png_mmx_support(); - } - - if (mask == 0xff) - { - png_memcpy(row, png_ptr->row_buf + 1, - (png_size_t)PNG_ROWBYTES(png_ptr->row_info.pixel_depth, - png_ptr->width)); - } - /* GRR: add "else if (mask == 0)" case? - * or does png_combine_row() not even get called in that case? */ - else - { - switch (png_ptr->row_info.pixel_depth) - { - case 1: - { - png_bytep sp; - png_bytep dp; - int s_inc, s_start, s_end; - int m; - int shift; - png_uint_32 i; - - sp = png_ptr->row_buf + 1; - dp = row; - m = 0x80; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 7; - s_inc = 1; - } - else -#endif - { - s_start = 7; - s_end = 0; - s_inc = -1; - } - - shift = s_start; - - for (i = 0; i < png_ptr->width; i++) - { - if (m & mask) - { - int value; - - value = (*sp >> shift) & 0x1; - *dp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - - case 2: - { - png_bytep sp; - png_bytep dp; - int s_start, s_end, s_inc; - int m; - int shift; - png_uint_32 i; - int value; - - sp = png_ptr->row_buf + 1; - dp = row; - m = 0x80; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 6; - s_inc = 2; - } - else -#endif - { - s_start = 6; - s_end = 0; - s_inc = -2; - } - - shift = s_start; - - for (i = 0; i < png_ptr->width; i++) - { - if (m & mask) - { - value = (*sp >> shift) & 0x3; - *dp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - - case 4: - { - png_bytep sp; - png_bytep dp; - int s_start, s_end, s_inc; - int m; - int shift; - png_uint_32 i; - int value; - - sp = png_ptr->row_buf + 1; - dp = row; - m = 0x80; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 4; - s_inc = 4; - } - else -#endif - { - s_start = 4; - s_end = 0; - s_inc = -4; - } - shift = s_start; - - for (i = 0; i < png_ptr->width; i++) - { - if (m & mask) - { - value = (*sp >> shift) & 0xf; - *dp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - - case 8: - { - png_bytep srcptr; - png_bytep dstptr; - png_uint_32 len; - int m; - int diff, unmask; - - __int64 mask0=0x0102040810204080; - -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && mmx_supported */ ) -#else - if (mmx_supported) -#endif - { - srcptr = png_ptr->row_buf + 1; - dstptr = row; - m = 0x80; - unmask = ~mask; - len = png_ptr->width &~7; //reduce to multiple of 8 - diff = png_ptr->width & 7; //amount lost - - _asm - { - movd mm7, unmask //load bit pattern - psubb mm6,mm6 //zero mm6 - punpcklbw mm7,mm7 - punpcklwd mm7,mm7 - punpckldq mm7,mm7 //fill register with 8 masks - - movq mm0,mask0 - - pand mm0,mm7 //nonzero if keep byte - pcmpeqb mm0,mm6 //zeros->1s, v versa - - mov ecx,len //load length of line (pixels) - mov esi,srcptr //load source - mov ebx,dstptr //load dest - cmp ecx,0 //lcr - je mainloop8end - -mainloop8: - movq mm4,[esi] - pand mm4,mm0 - movq mm6,mm0 - pandn mm6,[ebx] - por mm4,mm6 - movq [ebx],mm4 - - add esi,8 //inc by 8 bytes processed - add ebx,8 - sub ecx,8 //dec by 8 pixels processed - - ja mainloop8 -mainloop8end: - - mov ecx,diff - cmp ecx,0 - jz end8 - - mov edx,mask - sal edx,24 //make low byte the high byte - -secondloop8: - sal edx,1 //move high bit to CF - jnc skip8 //if CF = 0 - mov al,[esi] - mov [ebx],al -skip8: - inc esi - inc ebx - - dec ecx - jnz secondloop8 -end8: - emms - } - } - else /* mmx not supported - use modified C routine */ - { - register unsigned int incr1, initial_val, final_val; - png_size_t pixel_bytes; - png_uint_32 i; - register int disp = png_pass_inc[png_ptr->pass]; - int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; - - pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); - srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* - pixel_bytes; - dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; - initial_val = offset_table[png_ptr->pass]*pixel_bytes; - final_val = png_ptr->width*pixel_bytes; - incr1 = (disp)*pixel_bytes; - for (i = initial_val; i < final_val; i += incr1) - { - png_memcpy(dstptr, srcptr, pixel_bytes); - srcptr += incr1; - dstptr += incr1; - } - } /* end of else */ - - break; - } // end 8 bpp - - case 16: - { - png_bytep srcptr; - png_bytep dstptr; - png_uint_32 len; - int unmask, diff; - __int64 mask1=0x0101020204040808, - mask0=0x1010202040408080; - -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && mmx_supported */ ) -#else - if (mmx_supported) -#endif - { - srcptr = png_ptr->row_buf + 1; - dstptr = row; - - unmask = ~mask; - len = (png_ptr->width)&~7; - diff = (png_ptr->width)&7; - _asm - { - movd mm7, unmask //load bit pattern - psubb mm6,mm6 //zero mm6 - punpcklbw mm7,mm7 - punpcklwd mm7,mm7 - punpckldq mm7,mm7 //fill register with 8 masks - - movq mm0,mask0 - movq mm1,mask1 - - pand mm0,mm7 - pand mm1,mm7 - - pcmpeqb mm0,mm6 - pcmpeqb mm1,mm6 - - mov ecx,len //load length of line - mov esi,srcptr //load source - mov ebx,dstptr //load dest - cmp ecx,0 //lcr - jz mainloop16end - -mainloop16: - movq mm4,[esi] - pand mm4,mm0 - movq mm6,mm0 - movq mm7,[ebx] - pandn mm6,mm7 - por mm4,mm6 - movq [ebx],mm4 - - movq mm5,[esi+8] - pand mm5,mm1 - movq mm7,mm1 - movq mm6,[ebx+8] - pandn mm7,mm6 - por mm5,mm7 - movq [ebx+8],mm5 - - add esi,16 //inc by 16 bytes processed - add ebx,16 - sub ecx,8 //dec by 8 pixels processed - - ja mainloop16 - -mainloop16end: - mov ecx,diff - cmp ecx,0 - jz end16 - - mov edx,mask - sal edx,24 //make low byte the high byte -secondloop16: - sal edx,1 //move high bit to CF - jnc skip16 //if CF = 0 - mov ax,[esi] - mov [ebx],ax -skip16: - add esi,2 - add ebx,2 - - dec ecx - jnz secondloop16 -end16: - emms - } - } - else /* mmx not supported - use modified C routine */ - { - register unsigned int incr1, initial_val, final_val; - png_size_t pixel_bytes; - png_uint_32 i; - register int disp = png_pass_inc[png_ptr->pass]; - int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; - - pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); - srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* - pixel_bytes; - dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; - initial_val = offset_table[png_ptr->pass]*pixel_bytes; - final_val = png_ptr->width*pixel_bytes; - incr1 = (disp)*pixel_bytes; - for (i = initial_val; i < final_val; i += incr1) - { - png_memcpy(dstptr, srcptr, pixel_bytes); - srcptr += incr1; - dstptr += incr1; - } - } /* end of else */ - - break; - } // end 16 bpp - - case 24: - { - png_bytep srcptr; - png_bytep dstptr; - png_uint_32 len; - int unmask, diff; - - __int64 mask2=0x0101010202020404, //24bpp - mask1=0x0408080810101020, - mask0=0x2020404040808080; - - srcptr = png_ptr->row_buf + 1; - dstptr = row; - - unmask = ~mask; - len = (png_ptr->width)&~7; - diff = (png_ptr->width)&7; - -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && mmx_supported */ ) -#else - if (mmx_supported) -#endif - { - _asm - { - movd mm7, unmask //load bit pattern - psubb mm6,mm6 //zero mm6 - punpcklbw mm7,mm7 - punpcklwd mm7,mm7 - punpckldq mm7,mm7 //fill register with 8 masks - - movq mm0,mask0 - movq mm1,mask1 - movq mm2,mask2 - - pand mm0,mm7 - pand mm1,mm7 - pand mm2,mm7 - - pcmpeqb mm0,mm6 - pcmpeqb mm1,mm6 - pcmpeqb mm2,mm6 - - mov ecx,len //load length of line - mov esi,srcptr //load source - mov ebx,dstptr //load dest - cmp ecx,0 - jz mainloop24end - -mainloop24: - movq mm4,[esi] - pand mm4,mm0 - movq mm6,mm0 - movq mm7,[ebx] - pandn mm6,mm7 - por mm4,mm6 - movq [ebx],mm4 - - - movq mm5,[esi+8] - pand mm5,mm1 - movq mm7,mm1 - movq mm6,[ebx+8] - pandn mm7,mm6 - por mm5,mm7 - movq [ebx+8],mm5 - - movq mm6,[esi+16] - pand mm6,mm2 - movq mm4,mm2 - movq mm7,[ebx+16] - pandn mm4,mm7 - por mm6,mm4 - movq [ebx+16],mm6 - - add esi,24 //inc by 24 bytes processed - add ebx,24 - sub ecx,8 //dec by 8 pixels processed - - ja mainloop24 - -mainloop24end: - mov ecx,diff - cmp ecx,0 - jz end24 - - mov edx,mask - sal edx,24 //make low byte the high byte -secondloop24: - sal edx,1 //move high bit to CF - jnc skip24 //if CF = 0 - mov ax,[esi] - mov [ebx],ax - xor eax,eax - mov al,[esi+2] - mov [ebx+2],al -skip24: - add esi,3 - add ebx,3 - - dec ecx - jnz secondloop24 - -end24: - emms - } - } - else /* mmx not supported - use modified C routine */ - { - register unsigned int incr1, initial_val, final_val; - png_size_t pixel_bytes; - png_uint_32 i; - register int disp = png_pass_inc[png_ptr->pass]; - int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; - - pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); - srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* - pixel_bytes; - dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; - initial_val = offset_table[png_ptr->pass]*pixel_bytes; - final_val = png_ptr->width*pixel_bytes; - incr1 = (disp)*pixel_bytes; - for (i = initial_val; i < final_val; i += incr1) - { - png_memcpy(dstptr, srcptr, pixel_bytes); - srcptr += incr1; - dstptr += incr1; - } - } /* end of else */ - - break; - } // end 24 bpp - - case 32: - { - png_bytep srcptr; - png_bytep dstptr; - png_uint_32 len; - int unmask, diff; - - __int64 mask3=0x0101010102020202, //32bpp - mask2=0x0404040408080808, - mask1=0x1010101020202020, - mask0=0x4040404080808080; - - srcptr = png_ptr->row_buf + 1; - dstptr = row; - - unmask = ~mask; - len = (png_ptr->width)&~7; - diff = (png_ptr->width)&7; - -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && mmx_supported */ ) -#else - if (mmx_supported) -#endif - { - _asm - { - movd mm7, unmask //load bit pattern - psubb mm6,mm6 //zero mm6 - punpcklbw mm7,mm7 - punpcklwd mm7,mm7 - punpckldq mm7,mm7 //fill register with 8 masks - - movq mm0,mask0 - movq mm1,mask1 - movq mm2,mask2 - movq mm3,mask3 - - pand mm0,mm7 - pand mm1,mm7 - pand mm2,mm7 - pand mm3,mm7 - - pcmpeqb mm0,mm6 - pcmpeqb mm1,mm6 - pcmpeqb mm2,mm6 - pcmpeqb mm3,mm6 - - mov ecx,len //load length of line - mov esi,srcptr //load source - mov ebx,dstptr //load dest - - cmp ecx,0 //lcr - jz mainloop32end - -mainloop32: - movq mm4,[esi] - pand mm4,mm0 - movq mm6,mm0 - movq mm7,[ebx] - pandn mm6,mm7 - por mm4,mm6 - movq [ebx],mm4 - - movq mm5,[esi+8] - pand mm5,mm1 - movq mm7,mm1 - movq mm6,[ebx+8] - pandn mm7,mm6 - por mm5,mm7 - movq [ebx+8],mm5 - - movq mm6,[esi+16] - pand mm6,mm2 - movq mm4,mm2 - movq mm7,[ebx+16] - pandn mm4,mm7 - por mm6,mm4 - movq [ebx+16],mm6 - - movq mm7,[esi+24] - pand mm7,mm3 - movq mm5,mm3 - movq mm4,[ebx+24] - pandn mm5,mm4 - por mm7,mm5 - movq [ebx+24],mm7 - - add esi,32 //inc by 32 bytes processed - add ebx,32 - sub ecx,8 //dec by 8 pixels processed - - ja mainloop32 - -mainloop32end: - mov ecx,diff - cmp ecx,0 - jz end32 - - mov edx,mask - sal edx,24 //make low byte the high byte -secondloop32: - sal edx,1 //move high bit to CF - jnc skip32 //if CF = 0 - mov eax,[esi] - mov [ebx],eax -skip32: - add esi,4 - add ebx,4 - - dec ecx - jnz secondloop32 - -end32: - emms - } - } - else /* mmx _not supported - Use modified C routine */ - { - register unsigned int incr1, initial_val, final_val; - png_size_t pixel_bytes; - png_uint_32 i; - register int disp = png_pass_inc[png_ptr->pass]; - int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; - - pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); - srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* - pixel_bytes; - dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; - initial_val = offset_table[png_ptr->pass]*pixel_bytes; - final_val = png_ptr->width*pixel_bytes; - incr1 = (disp)*pixel_bytes; - for (i = initial_val; i < final_val; i += incr1) - { - png_memcpy(dstptr, srcptr, pixel_bytes); - srcptr += incr1; - dstptr += incr1; - } - } /* end of else */ - - break; - } // end 32 bpp - - case 48: - { - png_bytep srcptr; - png_bytep dstptr; - png_uint_32 len; - int unmask, diff; - - __int64 mask5=0x0101010101010202, - mask4=0x0202020204040404, - mask3=0x0404080808080808, - mask2=0x1010101010102020, - mask1=0x2020202040404040, - mask0=0x4040808080808080; - -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && mmx_supported */ ) -#else - if (mmx_supported) -#endif - { - srcptr = png_ptr->row_buf + 1; - dstptr = row; - - unmask = ~mask; - len = (png_ptr->width)&~7; - diff = (png_ptr->width)&7; - _asm - { - movd mm7, unmask //load bit pattern - psubb mm6,mm6 //zero mm6 - punpcklbw mm7,mm7 - punpcklwd mm7,mm7 - punpckldq mm7,mm7 //fill register with 8 masks - - movq mm0,mask0 - movq mm1,mask1 - movq mm2,mask2 - movq mm3,mask3 - movq mm4,mask4 - movq mm5,mask5 - - pand mm0,mm7 - pand mm1,mm7 - pand mm2,mm7 - pand mm3,mm7 - pand mm4,mm7 - pand mm5,mm7 - - pcmpeqb mm0,mm6 - pcmpeqb mm1,mm6 - pcmpeqb mm2,mm6 - pcmpeqb mm3,mm6 - pcmpeqb mm4,mm6 - pcmpeqb mm5,mm6 - - mov ecx,len //load length of line - mov esi,srcptr //load source - mov ebx,dstptr //load dest - - cmp ecx,0 - jz mainloop48end - -mainloop48: - movq mm7,[esi] - pand mm7,mm0 - movq mm6,mm0 - pandn mm6,[ebx] - por mm7,mm6 - movq [ebx],mm7 - - movq mm6,[esi+8] - pand mm6,mm1 - movq mm7,mm1 - pandn mm7,[ebx+8] - por mm6,mm7 - movq [ebx+8],mm6 - - movq mm6,[esi+16] - pand mm6,mm2 - movq mm7,mm2 - pandn mm7,[ebx+16] - por mm6,mm7 - movq [ebx+16],mm6 - - movq mm7,[esi+24] - pand mm7,mm3 - movq mm6,mm3 - pandn mm6,[ebx+24] - por mm7,mm6 - movq [ebx+24],mm7 - - movq mm6,[esi+32] - pand mm6,mm4 - movq mm7,mm4 - pandn mm7,[ebx+32] - por mm6,mm7 - movq [ebx+32],mm6 - - movq mm7,[esi+40] - pand mm7,mm5 - movq mm6,mm5 - pandn mm6,[ebx+40] - por mm7,mm6 - movq [ebx+40],mm7 - - add esi,48 //inc by 32 bytes processed - add ebx,48 - sub ecx,8 //dec by 8 pixels processed - - ja mainloop48 -mainloop48end: - - mov ecx,diff - cmp ecx,0 - jz end48 - - mov edx,mask - sal edx,24 //make low byte the high byte - -secondloop48: - sal edx,1 //move high bit to CF - jnc skip48 //if CF = 0 - mov eax,[esi] - mov [ebx],eax -skip48: - add esi,4 - add ebx,4 - - dec ecx - jnz secondloop48 - -end48: - emms - } - } - else /* mmx _not supported - Use modified C routine */ - { - register unsigned int incr1, initial_val, final_val; - png_size_t pixel_bytes; - png_uint_32 i; - register int disp = png_pass_inc[png_ptr->pass]; - int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; - - pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); - srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* - pixel_bytes; - dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; - initial_val = offset_table[png_ptr->pass]*pixel_bytes; - final_val = png_ptr->width*pixel_bytes; - incr1 = (disp)*pixel_bytes; - for (i = initial_val; i < final_val; i += incr1) - { - png_memcpy(dstptr, srcptr, pixel_bytes); - srcptr += incr1; - dstptr += incr1; - } - } /* end of else */ - - break; - } // end 48 bpp - - default: - { - png_bytep sptr; - png_bytep dp; - png_size_t pixel_bytes; - int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; - unsigned int i; - register int disp = png_pass_inc[png_ptr->pass]; // get the offset - register unsigned int incr1, initial_val, final_val; - - pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); - sptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* - pixel_bytes; - dp = row + offset_table[png_ptr->pass]*pixel_bytes; - initial_val = offset_table[png_ptr->pass]*pixel_bytes; - final_val = png_ptr->width*pixel_bytes; - incr1 = (disp)*pixel_bytes; - for (i = initial_val; i < final_val; i += incr1) - { - png_memcpy(dp, sptr, pixel_bytes); - sptr += incr1; - dp += incr1; - } - break; - } - } /* end switch (png_ptr->row_info.pixel_depth) */ - } /* end if (non-trivial mask) */ - -} /* end png_combine_row() */ - - -#if defined(PNG_READ_INTERLACING_SUPPORTED) - -void /* PRIVATE */ -png_do_read_interlace(png_structp png_ptr) -{ - png_row_infop row_info = &(png_ptr->row_info); - png_bytep row = png_ptr->row_buf + 1; - int pass = png_ptr->pass; - png_uint_32 transformations = png_ptr->transformations; -#ifdef PNG_USE_LOCAL_ARRAYS - const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; -#endif - - png_debug(1,"in png_do_read_interlace\n"); - - if (mmx_supported == 2) { -#if !defined(PNG_1_0_X) - /* this should have happened in png_init_mmx_flags() already */ - png_warning(png_ptr, "asm_flags may not have been initialized"); -#endif - png_mmx_support(); - } - - if (row != NULL && row_info != NULL) - { - png_uint_32 final_width; - - final_width = row_info->width * png_pass_inc[pass]; - - switch (row_info->pixel_depth) - { - case 1: - { - png_bytep sp, dp; - int sshift, dshift; - int s_start, s_end, s_inc; - png_byte v; - png_uint_32 i; - int j; - - sp = row + (png_size_t)((row_info->width - 1) >> 3); - dp = row + (png_size_t)((final_width - 1) >> 3); -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (int)((row_info->width + 7) & 7); - dshift = (int)((final_width + 7) & 7); - s_start = 7; - s_end = 0; - s_inc = -1; - } - else -#endif - { - sshift = 7 - (int)((row_info->width + 7) & 7); - dshift = 7 - (int)((final_width + 7) & 7); - s_start = 0; - s_end = 7; - s_inc = 1; - } - - for (i = row_info->width; i; i--) - { - v = (png_byte)((*sp >> sshift) & 0x1); - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp &= (png_byte)((0x7f7f >> (7 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - - case 2: - { - png_bytep sp, dp; - int sshift, dshift; - int s_start, s_end, s_inc; - png_uint_32 i; - - sp = row + (png_size_t)((row_info->width - 1) >> 2); - dp = row + (png_size_t)((final_width - 1) >> 2); -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (png_size_t)(((row_info->width + 3) & 3) << 1); - dshift = (png_size_t)(((final_width + 3) & 3) << 1); - s_start = 6; - s_end = 0; - s_inc = -2; - } - else -#endif - { - sshift = (png_size_t)((3 - ((row_info->width + 3) & 3)) << 1); - dshift = (png_size_t)((3 - ((final_width + 3) & 3)) << 1); - s_start = 0; - s_end = 6; - s_inc = 2; - } - - for (i = row_info->width; i; i--) - { - png_byte v; - int j; - - v = (png_byte)((*sp >> sshift) & 0x3); - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp &= (png_byte)((0x3f3f >> (6 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - - case 4: - { - png_bytep sp, dp; - int sshift, dshift; - int s_start, s_end, s_inc; - png_uint_32 i; - - sp = row + (png_size_t)((row_info->width - 1) >> 1); - dp = row + (png_size_t)((final_width - 1) >> 1); -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (png_size_t)(((row_info->width + 1) & 1) << 2); - dshift = (png_size_t)(((final_width + 1) & 1) << 2); - s_start = 4; - s_end = 0; - s_inc = -4; - } - else -#endif - { - sshift = (png_size_t)((1 - ((row_info->width + 1) & 1)) << 2); - dshift = (png_size_t)((1 - ((final_width + 1) & 1)) << 2); - s_start = 0; - s_end = 4; - s_inc = 4; - } - - for (i = row_info->width; i; i--) - { - png_byte v; - int j; - - v = (png_byte)((*sp >> sshift) & 0xf); - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp &= (png_byte)((0xf0f >> (4 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - - default: // This is the place where the routine is modified - { - __int64 const4 = 0x0000000000FFFFFF; - // __int64 const5 = 0x000000FFFFFF0000; // unused... - __int64 const6 = 0x00000000000000FF; - png_bytep sptr, dp; - png_uint_32 i; - png_size_t pixel_bytes; - int width = row_info->width; - - pixel_bytes = (row_info->pixel_depth >> 3); - - sptr = row + (width - 1) * pixel_bytes; - dp = row + (final_width - 1) * pixel_bytes; - // New code by Nirav Chhatrapati - Intel Corporation - // sign fix by GRR - // NOTE: there is NO MMX code for 48-bit and 64-bit images - - // use MMX routine if machine supports it -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_INTERLACE) - /* && mmx_supported */ ) -#else - if (mmx_supported) -#endif - { - if (pixel_bytes == 3) - { - if (((pass == 0) || (pass == 1)) && width) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width - sub edi, 21 // (png_pass_inc[pass] - 1)*pixel_bytes -loop_pass0: - movd mm0, [esi] ; X X X X X v2 v1 v0 - pand mm0, const4 ; 0 0 0 0 0 v2 v1 v0 - movq mm1, mm0 ; 0 0 0 0 0 v2 v1 v0 - psllq mm0, 16 ; 0 0 0 v2 v1 v0 0 0 - movq mm2, mm0 ; 0 0 0 v2 v1 v0 0 0 - psllq mm0, 24 ; v2 v1 v0 0 0 0 0 0 - psrlq mm1, 8 ; 0 0 0 0 0 0 v2 v1 - por mm0, mm2 ; v2 v1 v0 v2 v1 v0 0 0 - por mm0, mm1 ; v2 v1 v0 v2 v1 v0 v2 v1 - movq mm3, mm0 ; v2 v1 v0 v2 v1 v0 v2 v1 - psllq mm0, 16 ; v0 v2 v1 v0 v2 v1 0 0 - movq mm4, mm3 ; v2 v1 v0 v2 v1 v0 v2 v1 - punpckhdq mm3, mm0 ; v0 v2 v1 v0 v2 v1 v0 v2 - movq [edi+16] , mm4 - psrlq mm0, 32 ; 0 0 0 0 v0 v2 v1 v0 - movq [edi+8] , mm3 - punpckldq mm0, mm4 ; v1 v0 v2 v1 v0 v2 v1 v0 - sub esi, 3 - movq [edi], mm0 - sub edi, 24 - //sub esi, 3 - dec ecx - jnz loop_pass0 - EMMS - } - } - else if (((pass == 2) || (pass == 3)) && width) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width - sub edi, 9 // (png_pass_inc[pass] - 1)*pixel_bytes -loop_pass2: - movd mm0, [esi] ; X X X X X v2 v1 v0 - pand mm0, const4 ; 0 0 0 0 0 v2 v1 v0 - movq mm1, mm0 ; 0 0 0 0 0 v2 v1 v0 - psllq mm0, 16 ; 0 0 0 v2 v1 v0 0 0 - movq mm2, mm0 ; 0 0 0 v2 v1 v0 0 0 - psllq mm0, 24 ; v2 v1 v0 0 0 0 0 0 - psrlq mm1, 8 ; 0 0 0 0 0 0 v2 v1 - por mm0, mm2 ; v2 v1 v0 v2 v1 v0 0 0 - por mm0, mm1 ; v2 v1 v0 v2 v1 v0 v2 v1 - movq [edi+4], mm0 ; move to memory - psrlq mm0, 16 ; 0 0 v2 v1 v0 v2 v1 v0 - movd [edi], mm0 ; move to memory - sub esi, 3 - sub edi, 12 - dec ecx - jnz loop_pass2 - EMMS - } - } - else if (width) /* && ((pass == 4) || (pass == 5)) */ - { - int width_mmx = ((width >> 1) << 1) - 8; - if (width_mmx < 0) - width_mmx = 0; - width -= width_mmx; // 8 or 9 pix, 24 or 27 bytes - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub esi, 3 - sub edi, 9 -loop_pass4: - movq mm0, [esi] ; X X v2 v1 v0 v5 v4 v3 - movq mm7, mm0 ; X X v2 v1 v0 v5 v4 v3 - movq mm6, mm0 ; X X v2 v1 v0 v5 v4 v3 - psllq mm0, 24 ; v1 v0 v5 v4 v3 0 0 0 - pand mm7, const4 ; 0 0 0 0 0 v5 v4 v3 - psrlq mm6, 24 ; 0 0 0 X X v2 v1 v0 - por mm0, mm7 ; v1 v0 v5 v4 v3 v5 v4 v3 - movq mm5, mm6 ; 0 0 0 X X v2 v1 v0 - psllq mm6, 8 ; 0 0 X X v2 v1 v0 0 - movq [edi], mm0 ; move quad to memory - psrlq mm5, 16 ; 0 0 0 0 0 X X v2 - pand mm5, const6 ; 0 0 0 0 0 0 0 v2 - por mm6, mm5 ; 0 0 X X v2 v1 v0 v2 - movd [edi+8], mm6 ; move double to memory - sub esi, 6 - sub edi, 12 - sub ecx, 2 - jnz loop_pass4 - EMMS - } - } - - sptr -= width_mmx*3; - dp -= width_mmx*6; - for (i = width; i; i--) - { - png_byte v[8]; - int j; - - png_memcpy(v, sptr, 3); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 3); - dp -= 3; - } - sptr -= 3; - } - } - } /* end of pixel_bytes == 3 */ - - else if (pixel_bytes == 1) - { - if (((pass == 0) || (pass == 1)) && width) - { - int width_mmx = ((width >> 2) << 2); - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub edi, 31 - sub esi, 3 -loop1_pass0: - movd mm0, [esi] ; X X X X v0 v1 v2 v3 - movq mm1, mm0 ; X X X X v0 v1 v2 v3 - punpcklbw mm0, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 - movq mm2, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 - punpcklwd mm0, mm0 ; v2 v2 v2 v2 v3 v3 v3 v3 - movq mm3, mm0 ; v2 v2 v2 v2 v3 v3 v3 v3 - punpckldq mm0, mm0 ; v3 v3 v3 v3 v3 v3 v3 v3 - punpckhdq mm3, mm3 ; v2 v2 v2 v2 v2 v2 v2 v2 - movq [edi], mm0 ; move to memory v3 - punpckhwd mm2, mm2 ; v0 v0 v0 v0 v1 v1 v1 v1 - movq [edi+8], mm3 ; move to memory v2 - movq mm4, mm2 ; v0 v0 v0 v0 v1 v1 v1 v1 - punpckldq mm2, mm2 ; v1 v1 v1 v1 v1 v1 v1 v1 - punpckhdq mm4, mm4 ; v0 v0 v0 v0 v0 v0 v0 v0 - movq [edi+16], mm2 ; move to memory v1 - movq [edi+24], mm4 ; move to memory v0 - sub esi, 4 - sub edi, 32 - sub ecx, 4 - jnz loop1_pass0 - EMMS - } - } - - sptr -= width_mmx; - dp -= width_mmx*8; - for (i = width; i; i--) - { - int j; - - /* I simplified this part in version 1.0.4e - * here and in several other instances where - * pixel_bytes == 1 -- GR-P - * - * Original code: - * - * png_byte v[8]; - * png_memcpy(v, sptr, pixel_bytes); - * for (j = 0; j < png_pass_inc[pass]; j++) - * { - * png_memcpy(dp, v, pixel_bytes); - * dp -= pixel_bytes; - * } - * sptr -= pixel_bytes; - * - * Replacement code is in the next three lines: - */ - - for (j = 0; j < png_pass_inc[pass]; j++) - *dp-- = *sptr; - sptr--; - } - } - else if (((pass == 2) || (pass == 3)) && width) - { - int width_mmx = ((width >> 2) << 2); - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub edi, 15 - sub esi, 3 -loop1_pass2: - movd mm0, [esi] ; X X X X v0 v1 v2 v3 - punpcklbw mm0, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 - movq mm1, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 - punpcklwd mm0, mm0 ; v2 v2 v2 v2 v3 v3 v3 v3 - punpckhwd mm1, mm1 ; v0 v0 v0 v0 v1 v1 v1 v1 - movq [edi], mm0 ; move to memory v2 and v3 - sub esi, 4 - movq [edi+8], mm1 ; move to memory v1 and v0 - sub edi, 16 - sub ecx, 4 - jnz loop1_pass2 - EMMS - } - } - - sptr -= width_mmx; - dp -= width_mmx*4; - for (i = width; i; i--) - { - int j; - - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp-- = *sptr; - } - sptr --; - } - } - else if (width) /* && ((pass == 4) || (pass == 5))) */ - { - int width_mmx = ((width >> 3) << 3); - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub edi, 15 - sub esi, 7 -loop1_pass4: - movq mm0, [esi] ; v0 v1 v2 v3 v4 v5 v6 v7 - movq mm1, mm0 ; v0 v1 v2 v3 v4 v5 v6 v7 - punpcklbw mm0, mm0 ; v4 v4 v5 v5 v6 v6 v7 v7 - //movq mm1, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 - punpckhbw mm1, mm1 ;v0 v0 v1 v1 v2 v2 v3 v3 - movq [edi+8], mm1 ; move to memory v0 v1 v2 and v3 - sub esi, 8 - movq [edi], mm0 ; move to memory v4 v5 v6 and v7 - //sub esi, 4 - sub edi, 16 - sub ecx, 8 - jnz loop1_pass4 - EMMS - } - } - - sptr -= width_mmx; - dp -= width_mmx*2; - for (i = width; i; i--) - { - int j; - - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp-- = *sptr; - } - sptr --; - } - } - } /* end of pixel_bytes == 1 */ - - else if (pixel_bytes == 2) - { - if (((pass == 0) || (pass == 1)) && width) - { - int width_mmx = ((width >> 1) << 1); - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub esi, 2 - sub edi, 30 -loop2_pass0: - movd mm0, [esi] ; X X X X v1 v0 v3 v2 - punpcklwd mm0, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 - movq mm1, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 - punpckldq mm0, mm0 ; v3 v2 v3 v2 v3 v2 v3 v2 - punpckhdq mm1, mm1 ; v1 v0 v1 v0 v1 v0 v1 v0 - movq [edi], mm0 - movq [edi + 8], mm0 - movq [edi + 16], mm1 - movq [edi + 24], mm1 - sub esi, 4 - sub edi, 32 - sub ecx, 2 - jnz loop2_pass0 - EMMS - } - } - - sptr -= (width_mmx*2 - 2); // sign fixed - dp -= (width_mmx*16 - 2); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 2; - png_memcpy(v, sptr, 2); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 2; - png_memcpy(dp, v, 2); - } - } - } - else if (((pass == 2) || (pass == 3)) && width) - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub esi, 2 - sub edi, 14 -loop2_pass2: - movd mm0, [esi] ; X X X X v1 v0 v3 v2 - punpcklwd mm0, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 - movq mm1, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 - punpckldq mm0, mm0 ; v3 v2 v3 v2 v3 v2 v3 v2 - punpckhdq mm1, mm1 ; v1 v0 v1 v0 v1 v0 v1 v0 - movq [edi], mm0 - sub esi, 4 - movq [edi + 8], mm1 - //sub esi, 4 - sub edi, 16 - sub ecx, 2 - jnz loop2_pass2 - EMMS - } - } - - sptr -= (width_mmx*2 - 2); // sign fixed - dp -= (width_mmx*8 - 2); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 2; - png_memcpy(v, sptr, 2); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 2; - png_memcpy(dp, v, 2); - } - } - } - else if (width) // pass == 4 or 5 - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub esi, 2 - sub edi, 6 -loop2_pass4: - movd mm0, [esi] ; X X X X v1 v0 v3 v2 - punpcklwd mm0, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 - sub esi, 4 - movq [edi], mm0 - sub edi, 8 - sub ecx, 2 - jnz loop2_pass4 - EMMS - } - } - - sptr -= (width_mmx*2 - 2); // sign fixed - dp -= (width_mmx*4 - 2); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 2; - png_memcpy(v, sptr, 2); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 2; - png_memcpy(dp, v, 2); - } - } - } - } /* end of pixel_bytes == 2 */ - - else if (pixel_bytes == 4) - { - if (((pass == 0) || (pass == 1)) && width) - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub esi, 4 - sub edi, 60 -loop4_pass0: - movq mm0, [esi] ; v3 v2 v1 v0 v7 v6 v5 v4 - movq mm1, mm0 ; v3 v2 v1 v0 v7 v6 v5 v4 - punpckldq mm0, mm0 ; v7 v6 v5 v4 v7 v6 v5 v4 - punpckhdq mm1, mm1 ; v3 v2 v1 v0 v3 v2 v1 v0 - movq [edi], mm0 - movq [edi + 8], mm0 - movq [edi + 16], mm0 - movq [edi + 24], mm0 - movq [edi+32], mm1 - movq [edi + 40], mm1 - movq [edi+ 48], mm1 - sub esi, 8 - movq [edi + 56], mm1 - sub edi, 64 - sub ecx, 2 - jnz loop4_pass0 - EMMS - } - } - - sptr -= (width_mmx*4 - 4); // sign fixed - dp -= (width_mmx*32 - 4); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 4; - png_memcpy(v, sptr, 4); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 4; - png_memcpy(dp, v, 4); - } - } - } - else if (((pass == 2) || (pass == 3)) && width) - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub esi, 4 - sub edi, 28 -loop4_pass2: - movq mm0, [esi] ; v3 v2 v1 v0 v7 v6 v5 v4 - movq mm1, mm0 ; v3 v2 v1 v0 v7 v6 v5 v4 - punpckldq mm0, mm0 ; v7 v6 v5 v4 v7 v6 v5 v4 - punpckhdq mm1, mm1 ; v3 v2 v1 v0 v3 v2 v1 v0 - movq [edi], mm0 - movq [edi + 8], mm0 - movq [edi+16], mm1 - movq [edi + 24], mm1 - sub esi, 8 - sub edi, 32 - sub ecx, 2 - jnz loop4_pass2 - EMMS - } - } - - sptr -= (width_mmx*4 - 4); // sign fixed - dp -= (width_mmx*16 - 4); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 4; - png_memcpy(v, sptr, 4); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 4; - png_memcpy(dp, v, 4); - } - } - } - else if (width) // pass == 4 or 5 - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub esi, 4 - sub edi, 12 -loop4_pass4: - movq mm0, [esi] ; v3 v2 v1 v0 v7 v6 v5 v4 - movq mm1, mm0 ; v3 v2 v1 v0 v7 v6 v5 v4 - punpckldq mm0, mm0 ; v7 v6 v5 v4 v7 v6 v5 v4 - punpckhdq mm1, mm1 ; v3 v2 v1 v0 v3 v2 v1 v0 - movq [edi], mm0 - sub esi, 8 - movq [edi + 8], mm1 - sub edi, 16 - sub ecx, 2 - jnz loop4_pass4 - EMMS - } - } - - sptr -= (width_mmx*4 - 4); // sign fixed - dp -= (width_mmx*8 - 4); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 4; - png_memcpy(v, sptr, 4); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 4; - png_memcpy(dp, v, 4); - } - } - } - - } /* end of pixel_bytes == 4 */ - - else if (pixel_bytes == 6) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, 6); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 6); - dp -= 6; - } - sptr -= 6; - } - } /* end of pixel_bytes == 6 */ - - else - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr-= pixel_bytes; - } - } - } /* end of mmx_supported */ - - else /* MMX not supported: use modified C code - takes advantage - * of inlining of memcpy for a constant */ - { - if (pixel_bytes == 1) - { - for (i = width; i; i--) - { - int j; - for (j = 0; j < png_pass_inc[pass]; j++) - *dp-- = *sptr; - sptr--; - } - } - else if (pixel_bytes == 3) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr -= pixel_bytes; - } - } - else if (pixel_bytes == 2) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr -= pixel_bytes; - } - } - else if (pixel_bytes == 4) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr -= pixel_bytes; - } - } - else if (pixel_bytes == 6) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr -= pixel_bytes; - } - } - else - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr -= pixel_bytes; - } - } - - } /* end of MMX not supported */ - break; - } - } /* end switch (row_info->pixel_depth) */ - - row_info->width = final_width; - - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,final_width); - } - -} - -#endif /* PNG_READ_INTERLACING_SUPPORTED */ - - -// These variables are utilized in the functions below. They are declared -// globally here to ensure alignment on 8-byte boundaries. - -union uAll { - __int64 use; - double align; -} LBCarryMask = {0x0101010101010101}, - HBClearMask = {0x7f7f7f7f7f7f7f7f}, - ActiveMask, ActiveMask2, ActiveMaskEnd, ShiftBpp, ShiftRem; - - -// Optimized code for PNG Average filter decoder -void /* PRIVATE */ -png_read_filter_row_mmx_avg(png_row_infop row_info, png_bytep row - , png_bytep prev_row) -{ - int bpp; - png_uint_32 FullLength; - png_uint_32 MMXLength; - //png_uint_32 len; - int diff; - - bpp = (row_info->pixel_depth + 7) >> 3; // Get # bytes per pixel - FullLength = row_info->rowbytes; // # of bytes to filter - _asm { - // Init address pointers and offset - mov edi, row // edi ==> Avg(x) - xor ebx, ebx // ebx ==> x - mov edx, edi - mov esi, prev_row // esi ==> Prior(x) - sub edx, bpp // edx ==> Raw(x-bpp) - - xor eax, eax - // Compute the Raw value for the first bpp bytes - // Raw(x) = Avg(x) + (Prior(x)/2) -davgrlp: - mov al, [esi + ebx] // Load al with Prior(x) - inc ebx - shr al, 1 // divide by 2 - add al, [edi+ebx-1] // Add Avg(x); -1 to offset inc ebx - cmp ebx, bpp - mov [edi+ebx-1], al // Write back Raw(x); - // mov does not affect flags; -1 to offset inc ebx - jb davgrlp - // get # of bytes to alignment - mov diff, edi // take start of row - add diff, ebx // add bpp - add diff, 0xf // add 7 + 8 to incr past alignment boundary - and diff, 0xfffffff8 // mask to alignment boundary - sub diff, edi // subtract from start ==> value ebx at alignment - jz davggo - // fix alignment - // Compute the Raw value for the bytes upto the alignment boundary - // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) - xor ecx, ecx -davglp1: - xor eax, eax - mov cl, [esi + ebx] // load cl with Prior(x) - mov al, [edx + ebx] // load al with Raw(x-bpp) - add ax, cx - inc ebx - shr ax, 1 // divide by 2 - add al, [edi+ebx-1] // Add Avg(x); -1 to offset inc ebx - cmp ebx, diff // Check if at alignment boundary - mov [edi+ebx-1], al // Write back Raw(x); - // mov does not affect flags; -1 to offset inc ebx - jb davglp1 // Repeat until at alignment boundary -davggo: - mov eax, FullLength - mov ecx, eax - sub eax, ebx // subtract alignment fix - and eax, 0x00000007 // calc bytes over mult of 8 - sub ecx, eax // drop over bytes from original length - mov MMXLength, ecx - } // end _asm block - // Now do the math for the rest of the row - switch ( bpp ) - { - case 3: - { - ActiveMask.use = 0x0000000000ffffff; - ShiftBpp.use = 24; // == 3 * 8 - ShiftRem.use = 40; // == 64 - 24 - _asm { - // Re-init address pointers and offset - movq mm7, ActiveMask - mov ebx, diff // ebx ==> x = offset to alignment boundary - movq mm5, LBCarryMask - mov edi, row // edi ==> Avg(x) - movq mm4, HBClearMask - mov esi, prev_row // esi ==> Prior(x) - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm2, [edi + ebx - 8] // Load previous aligned 8 bytes - // (we correct position in loop below) -davg3lp: - movq mm0, [edi + ebx] // Load mm0 with Avg(x) - // Add (Prev_row/2) to Average - movq mm3, mm5 - psrlq mm2, ShiftRem // Correct position Raw(x-bpp) data - movq mm1, [esi + ebx] // Load mm1 with Prior(x) - movq mm6, mm7 - pand mm3, mm1 // get lsb for each prev_row byte - psrlq mm1, 1 // divide prev_row bytes by 2 - pand mm1, mm4 // clear invalid bit 7 of each byte - paddb mm0, mm1 // add (Prev_row/2) to Avg for each byte - // Add 1st active group (Raw(x-bpp)/2) to Average with LBCarry - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 1 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active - // byte - // Add 2nd active group (Raw(x-bpp)/2) to Average with LBCarry - psllq mm6, ShiftBpp // shift the mm6 mask to cover bytes 3-5 - movq mm2, mm0 // mov updated Raws to mm2 - psllq mm2, ShiftBpp // shift data to position correctly - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active - // byte - - // Add 3rd active group (Raw(x-bpp)/2) to Average with LBCarry - psllq mm6, ShiftBpp // shift the mm6 mask to cover the last two - // bytes - movq mm2, mm0 // mov updated Raws to mm2 - psllq mm2, ShiftBpp // shift data to position correctly - // Data only needs to be shifted once here to - // get the correct x-bpp offset. - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg - add ebx, 8 - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active - // byte - - // Now ready to write back to memory - movq [edi + ebx - 8], mm0 - // Move updated Raw(x) to use as Raw(x-bpp) for next loop - cmp ebx, MMXLength - movq mm2, mm0 // mov updated Raw(x) to mm2 - jb davg3lp - } // end _asm block - } - break; - - case 6: - case 4: - case 7: - case 5: - { - ActiveMask.use = 0xffffffffffffffff; // use shift below to clear - // appropriate inactive bytes - ShiftBpp.use = bpp << 3; - ShiftRem.use = 64 - ShiftBpp.use; - _asm { - movq mm4, HBClearMask - // Re-init address pointers and offset - mov ebx, diff // ebx ==> x = offset to alignment boundary - // Load ActiveMask and clear all bytes except for 1st active group - movq mm7, ActiveMask - mov edi, row // edi ==> Avg(x) - psrlq mm7, ShiftRem - mov esi, prev_row // esi ==> Prior(x) - movq mm6, mm7 - movq mm5, LBCarryMask - psllq mm6, ShiftBpp // Create mask for 2nd active group - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm2, [edi + ebx - 8] // Load previous aligned 8 bytes - // (we correct position in loop below) -davg4lp: - movq mm0, [edi + ebx] - psrlq mm2, ShiftRem // shift data to position correctly - movq mm1, [esi + ebx] - // Add (Prev_row/2) to Average - movq mm3, mm5 - pand mm3, mm1 // get lsb for each prev_row byte - psrlq mm1, 1 // divide prev_row bytes by 2 - pand mm1, mm4 // clear invalid bit 7 of each byte - paddb mm0, mm1 // add (Prev_row/2) to Avg for each byte - // Add 1st active group (Raw(x-bpp)/2) to Average with LBCarry - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm7 // Leave only Active Group 1 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active - // byte - // Add 2nd active group (Raw(x-bpp)/2) to Average with LBCarry - movq mm2, mm0 // mov updated Raws to mm2 - psllq mm2, ShiftBpp // shift data to position correctly - add ebx, 8 - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active - // byte - cmp ebx, MMXLength - // Now ready to write back to memory - movq [edi + ebx - 8], mm0 - // Prep Raw(x-bpp) for next loop - movq mm2, mm0 // mov updated Raws to mm2 - jb davg4lp - } // end _asm block - } - break; - case 2: - { - ActiveMask.use = 0x000000000000ffff; - ShiftBpp.use = 16; // == 2 * 8 [BUGFIX] - ShiftRem.use = 48; // == 64 - 16 [BUGFIX] - _asm { - // Load ActiveMask - movq mm7, ActiveMask - // Re-init address pointers and offset - mov ebx, diff // ebx ==> x = offset to alignment boundary - movq mm5, LBCarryMask - mov edi, row // edi ==> Avg(x) - movq mm4, HBClearMask - mov esi, prev_row // esi ==> Prior(x) - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm2, [edi + ebx - 8] // Load previous aligned 8 bytes - // (we correct position in loop below) -davg2lp: - movq mm0, [edi + ebx] - psrlq mm2, ShiftRem // shift data to position correctly [BUGFIX] - movq mm1, [esi + ebx] - // Add (Prev_row/2) to Average - movq mm3, mm5 - pand mm3, mm1 // get lsb for each prev_row byte - psrlq mm1, 1 // divide prev_row bytes by 2 - pand mm1, mm4 // clear invalid bit 7 of each byte - movq mm6, mm7 - paddb mm0, mm1 // add (Prev_row/2) to Avg for each byte - // Add 1st active group (Raw(x-bpp)/2) to Average with LBCarry - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 1 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active byte - // Add 2nd active group (Raw(x-bpp)/2) to Average with LBCarry - psllq mm6, ShiftBpp // shift the mm6 mask to cover bytes 2 & 3 - movq mm2, mm0 // mov updated Raws to mm2 - psllq mm2, ShiftBpp // shift data to position correctly - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active byte - - // Add rdd active group (Raw(x-bpp)/2) to Average with LBCarry - psllq mm6, ShiftBpp // shift the mm6 mask to cover bytes 4 & 5 - movq mm2, mm0 // mov updated Raws to mm2 - psllq mm2, ShiftBpp // shift data to position correctly - // Data only needs to be shifted once here to - // get the correct x-bpp offset. - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active byte - - // Add 4th active group (Raw(x-bpp)/2) to Average with LBCarry - psllq mm6, ShiftBpp // shift the mm6 mask to cover bytes 6 & 7 - movq mm2, mm0 // mov updated Raws to mm2 - psllq mm2, ShiftBpp // shift data to position correctly - // Data only needs to be shifted once here to - // get the correct x-bpp offset. - add ebx, 8 - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active byte - - cmp ebx, MMXLength - // Now ready to write back to memory - movq [edi + ebx - 8], mm0 - // Prep Raw(x-bpp) for next loop - movq mm2, mm0 // mov updated Raws to mm2 - jb davg2lp - } // end _asm block - } - break; - - case 1: // bpp == 1 - { - _asm { - // Re-init address pointers and offset - mov ebx, diff // ebx ==> x = offset to alignment boundary - mov edi, row // edi ==> Avg(x) - cmp ebx, FullLength // Test if offset at end of array - jnb davg1end - // Do Paeth decode for remaining bytes - mov esi, prev_row // esi ==> Prior(x) - mov edx, edi - xor ecx, ecx // zero ecx before using cl & cx in loop below - sub edx, bpp // edx ==> Raw(x-bpp) -davg1lp: - // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) - xor eax, eax - mov cl, [esi + ebx] // load cl with Prior(x) - mov al, [edx + ebx] // load al with Raw(x-bpp) - add ax, cx - inc ebx - shr ax, 1 // divide by 2 - add al, [edi+ebx-1] // Add Avg(x); -1 to offset inc ebx - cmp ebx, FullLength // Check if at end of array - mov [edi+ebx-1], al // Write back Raw(x); - // mov does not affect flags; -1 to offset inc ebx - jb davg1lp -davg1end: - } // end _asm block - } - return; - - case 8: // bpp == 8 - { - _asm { - // Re-init address pointers and offset - mov ebx, diff // ebx ==> x = offset to alignment boundary - movq mm5, LBCarryMask - mov edi, row // edi ==> Avg(x) - movq mm4, HBClearMask - mov esi, prev_row // esi ==> Prior(x) - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm2, [edi + ebx - 8] // Load previous aligned 8 bytes - // (NO NEED to correct position in loop below) -davg8lp: - movq mm0, [edi + ebx] - movq mm3, mm5 - movq mm1, [esi + ebx] - add ebx, 8 - pand mm3, mm1 // get lsb for each prev_row byte - psrlq mm1, 1 // divide prev_row bytes by 2 - pand mm3, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 - psrlq mm2, 1 // divide raw bytes by 2 - pand mm1, mm4 // clear invalid bit 7 of each byte - paddb mm0, mm3 // add LBCarrys to Avg for each byte - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm0, mm1 // add (Prev_row/2) to Avg for each byte - paddb mm0, mm2 // add (Raw/2) to Avg for each byte - cmp ebx, MMXLength - movq [edi + ebx - 8], mm0 - movq mm2, mm0 // reuse as Raw(x-bpp) - jb davg8lp - } // end _asm block - } - break; - default: // bpp greater than 8 - { - _asm { - movq mm5, LBCarryMask - // Re-init address pointers and offset - mov ebx, diff // ebx ==> x = offset to alignment boundary - mov edi, row // edi ==> Avg(x) - movq mm4, HBClearMask - mov edx, edi - mov esi, prev_row // esi ==> Prior(x) - sub edx, bpp // edx ==> Raw(x-bpp) -davgAlp: - movq mm0, [edi + ebx] - movq mm3, mm5 - movq mm1, [esi + ebx] - pand mm3, mm1 // get lsb for each prev_row byte - movq mm2, [edx + ebx] - psrlq mm1, 1 // divide prev_row bytes by 2 - pand mm3, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 - psrlq mm2, 1 // divide raw bytes by 2 - pand mm1, mm4 // clear invalid bit 7 of each byte - paddb mm0, mm3 // add LBCarrys to Avg for each byte - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm0, mm1 // add (Prev_row/2) to Avg for each byte - add ebx, 8 - paddb mm0, mm2 // add (Raw/2) to Avg for each byte - cmp ebx, MMXLength - movq [edi + ebx - 8], mm0 - jb davgAlp - } // end _asm block - } - break; - } // end switch ( bpp ) - - _asm { - // MMX acceleration complete now do clean-up - // Check if any remaining bytes left to decode - mov ebx, MMXLength // ebx ==> x = offset bytes remaining after MMX - mov edi, row // edi ==> Avg(x) - cmp ebx, FullLength // Test if offset at end of array - jnb davgend - // Do Paeth decode for remaining bytes - mov esi, prev_row // esi ==> Prior(x) - mov edx, edi - xor ecx, ecx // zero ecx before using cl & cx in loop below - sub edx, bpp // edx ==> Raw(x-bpp) -davglp2: - // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) - xor eax, eax - mov cl, [esi + ebx] // load cl with Prior(x) - mov al, [edx + ebx] // load al with Raw(x-bpp) - add ax, cx - inc ebx - shr ax, 1 // divide by 2 - add al, [edi+ebx-1] // Add Avg(x); -1 to offset inc ebx - cmp ebx, FullLength // Check if at end of array - mov [edi+ebx-1], al // Write back Raw(x); - // mov does not affect flags; -1 to offset inc ebx - jb davglp2 -davgend: - emms // End MMX instructions; prep for possible FP instrs. - } // end _asm block -} - -// Optimized code for PNG Paeth filter decoder -void /* PRIVATE */ -png_read_filter_row_mmx_paeth(png_row_infop row_info, png_bytep row, - png_bytep prev_row) -{ - png_uint_32 FullLength; - png_uint_32 MMXLength; - //png_uint_32 len; - int bpp; - int diff; - //int ptemp; - int patemp, pbtemp, pctemp; - - bpp = (row_info->pixel_depth + 7) >> 3; // Get # bytes per pixel - FullLength = row_info->rowbytes; // # of bytes to filter - _asm - { - xor ebx, ebx // ebx ==> x offset - mov edi, row - xor edx, edx // edx ==> x-bpp offset - mov esi, prev_row - xor eax, eax - - // Compute the Raw value for the first bpp bytes - // Note: the formula works out to be always - // Paeth(x) = Raw(x) + Prior(x) where x < bpp -dpthrlp: - mov al, [edi + ebx] - add al, [esi + ebx] - inc ebx - cmp ebx, bpp - mov [edi + ebx - 1], al - jb dpthrlp - // get # of bytes to alignment - mov diff, edi // take start of row - add diff, ebx // add bpp - xor ecx, ecx - add diff, 0xf // add 7 + 8 to incr past alignment boundary - and diff, 0xfffffff8 // mask to alignment boundary - sub diff, edi // subtract from start ==> value ebx at alignment - jz dpthgo - // fix alignment -dpthlp1: - xor eax, eax - // pav = p - a = (a + b - c) - a = b - c - mov al, [esi + ebx] // load Prior(x) into al - mov cl, [esi + edx] // load Prior(x-bpp) into cl - sub eax, ecx // subtract Prior(x-bpp) - mov patemp, eax // Save pav for later use - xor eax, eax - // pbv = p - b = (a + b - c) - b = a - c - mov al, [edi + edx] // load Raw(x-bpp) into al - sub eax, ecx // subtract Prior(x-bpp) - mov ecx, eax - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - add eax, patemp // pcv = pav + pbv - // pc = abs(pcv) - test eax, 0x80000000 - jz dpthpca - neg eax // reverse sign of neg values -dpthpca: - mov pctemp, eax // save pc for later use - // pb = abs(pbv) - test ecx, 0x80000000 - jz dpthpba - neg ecx // reverse sign of neg values -dpthpba: - mov pbtemp, ecx // save pb for later use - // pa = abs(pav) - mov eax, patemp - test eax, 0x80000000 - jz dpthpaa - neg eax // reverse sign of neg values -dpthpaa: - mov patemp, eax // save pa for later use - // test if pa <= pb - cmp eax, ecx - jna dpthabb - // pa > pb; now test if pb <= pc - cmp ecx, pctemp - jna dpthbbc - // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - mov cl, [esi + edx] // load Prior(x-bpp) into cl - jmp dpthpaeth -dpthbbc: - // pb <= pc; Raw(x) = Paeth(x) + Prior(x) - mov cl, [esi + ebx] // load Prior(x) into cl - jmp dpthpaeth -dpthabb: - // pa <= pb; now test if pa <= pc - cmp eax, pctemp - jna dpthabc - // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - mov cl, [esi + edx] // load Prior(x-bpp) into cl - jmp dpthpaeth -dpthabc: - // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) - mov cl, [edi + edx] // load Raw(x-bpp) into cl -dpthpaeth: - inc ebx - inc edx - // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 - add [edi + ebx - 1], cl - cmp ebx, diff - jb dpthlp1 -dpthgo: - mov ecx, FullLength - mov eax, ecx - sub eax, ebx // subtract alignment fix - and eax, 0x00000007 // calc bytes over mult of 8 - sub ecx, eax // drop over bytes from original length - mov MMXLength, ecx - } // end _asm block - // Now do the math for the rest of the row - switch ( bpp ) - { - case 3: - { - ActiveMask.use = 0x0000000000ffffff; - ActiveMaskEnd.use = 0xffff000000000000; - ShiftBpp.use = 24; // == bpp(3) * 8 - ShiftRem.use = 40; // == 64 - 24 - _asm - { - mov ebx, diff - mov edi, row - mov esi, prev_row - pxor mm0, mm0 - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm1, [edi+ebx-8] -dpth3lp: - psrlq mm1, ShiftRem // shift last 3 bytes to 1st 3 bytes - movq mm2, [esi + ebx] // load b=Prior(x) - punpcklbw mm1, mm0 // Unpack High bytes of a - movq mm3, [esi+ebx-8] // Prep c=Prior(x-bpp) bytes - punpcklbw mm2, mm0 // Unpack High bytes of b - psrlq mm3, ShiftRem // shift last 3 bytes to 1st 3 bytes - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - punpcklbw mm3, mm0 // Unpack High bytes of c - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - psubw mm4, mm3 - pxor mm7, mm7 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - paddw mm6, mm5 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - psubw mm4, mm0 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm5, mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pxor mm1, mm1 - pand mm3, mm7 - pandn mm7, mm0 - paddw mm7, mm3 - pxor mm0, mm0 - packuswb mm7, mm1 - movq mm3, [esi + ebx] // load c=Prior(x-bpp) - pand mm7, ActiveMask - movq mm2, mm3 // load b=Prior(x) step 1 - paddb mm7, [edi + ebx] // add Paeth predictor with Raw(x) - punpcklbw mm3, mm0 // Unpack High bytes of c - movq [edi + ebx], mm7 // write back updated value - movq mm1, mm7 // Now mm1 will be used as Raw(x-bpp) - // Now do Paeth for 2nd set of bytes (3-5) - psrlq mm2, ShiftBpp // load b=Prior(x) step 2 - punpcklbw mm1, mm0 // Unpack High bytes of a - pxor mm7, mm7 - punpcklbw mm2, mm0 // Unpack High bytes of b - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - psubw mm5, mm3 - psubw mm4, mm3 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = - // pav + pbv = pbv + pav - movq mm6, mm5 - paddw mm6, mm4 - - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm5 // Create mask pbv bytes < 0 - pcmpgtw mm7, mm4 // Create mask pav bytes < 0 - pand mm0, mm5 // Only pbv bytes < 0 in mm0 - pand mm7, mm4 // Only pav bytes < 0 in mm7 - psubw mm5, mm0 - psubw mm4, mm7 - psubw mm5, mm0 - psubw mm4, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - movq mm2, [esi + ebx] // load b=Prior(x) - pand mm3, mm7 - pandn mm7, mm0 - pxor mm1, mm1 - paddw mm7, mm3 - pxor mm0, mm0 - packuswb mm7, mm1 - movq mm3, mm2 // load c=Prior(x-bpp) step 1 - pand mm7, ActiveMask - punpckhbw mm2, mm0 // Unpack High bytes of b - psllq mm7, ShiftBpp // Shift bytes to 2nd group of 3 bytes - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - paddb mm7, [edi + ebx] // add Paeth predictor with Raw(x) - psllq mm3, ShiftBpp // load c=Prior(x-bpp) step 2 - movq [edi + ebx], mm7 // write back updated value - movq mm1, mm7 - punpckhbw mm3, mm0 // Unpack High bytes of c - psllq mm1, ShiftBpp // Shift bytes - // Now mm1 will be used as Raw(x-bpp) - // Now do Paeth for 3rd, and final, set of bytes (6-7) - pxor mm7, mm7 - punpckhbw mm1, mm0 // Unpack High bytes of a - psubw mm4, mm3 - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - pxor mm0, mm0 - paddw mm6, mm5 - - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - pandn mm0, mm1 - pandn mm7, mm4 - paddw mm0, mm2 - paddw mm7, mm5 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pand mm3, mm7 - pandn mm7, mm0 - paddw mm7, mm3 - pxor mm1, mm1 - packuswb mm1, mm7 - // Step ebx to next set of 8 bytes and repeat loop til done - add ebx, 8 - pand mm1, ActiveMaskEnd - paddb mm1, [edi + ebx - 8] // add Paeth predictor with Raw(x) - - cmp ebx, MMXLength - pxor mm0, mm0 // pxor does not affect flags - movq [edi + ebx - 8], mm1 // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - // mm3 ready to be used as Prior(x-bpp) next loop - jb dpth3lp - } // end _asm block - } - break; - - case 6: - case 7: - case 5: - { - ActiveMask.use = 0x00000000ffffffff; - ActiveMask2.use = 0xffffffff00000000; - ShiftBpp.use = bpp << 3; // == bpp * 8 - ShiftRem.use = 64 - ShiftBpp.use; - _asm - { - mov ebx, diff - mov edi, row - mov esi, prev_row - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm1, [edi+ebx-8] - pxor mm0, mm0 -dpth6lp: - // Must shift to position Raw(x-bpp) data - psrlq mm1, ShiftRem - // Do first set of 4 bytes - movq mm3, [esi+ebx-8] // read c=Prior(x-bpp) bytes - punpcklbw mm1, mm0 // Unpack Low bytes of a - movq mm2, [esi + ebx] // load b=Prior(x) - punpcklbw mm2, mm0 // Unpack Low bytes of b - // Must shift to position Prior(x-bpp) data - psrlq mm3, ShiftRem - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - punpcklbw mm3, mm0 // Unpack Low bytes of c - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - psubw mm4, mm3 - pxor mm7, mm7 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - paddw mm6, mm5 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - psubw mm4, mm0 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm5, mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pxor mm1, mm1 - pand mm3, mm7 - pandn mm7, mm0 - paddw mm7, mm3 - pxor mm0, mm0 - packuswb mm7, mm1 - movq mm3, [esi + ebx - 8] // load c=Prior(x-bpp) - pand mm7, ActiveMask - psrlq mm3, ShiftRem - movq mm2, [esi + ebx] // load b=Prior(x) step 1 - paddb mm7, [edi + ebx] // add Paeth predictor with Raw(x) - movq mm6, mm2 - movq [edi + ebx], mm7 // write back updated value - movq mm1, [edi+ebx-8] - psllq mm6, ShiftBpp - movq mm5, mm7 - psrlq mm1, ShiftRem - por mm3, mm6 - psllq mm5, ShiftBpp - punpckhbw mm3, mm0 // Unpack High bytes of c - por mm1, mm5 - // Do second set of 4 bytes - punpckhbw mm2, mm0 // Unpack High bytes of b - punpckhbw mm1, mm0 // Unpack High bytes of a - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - psubw mm4, mm3 - pxor mm7, mm7 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - paddw mm6, mm5 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - psubw mm4, mm0 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm5, mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pxor mm1, mm1 - pand mm3, mm7 - pandn mm7, mm0 - pxor mm1, mm1 - paddw mm7, mm3 - pxor mm0, mm0 - // Step ex to next set of 8 bytes and repeat loop til done - add ebx, 8 - packuswb mm1, mm7 - paddb mm1, [edi + ebx - 8] // add Paeth predictor with Raw(x) - cmp ebx, MMXLength - movq [edi + ebx - 8], mm1 // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - jb dpth6lp - } // end _asm block - } - break; - - case 4: - { - ActiveMask.use = 0x00000000ffffffff; - _asm { - mov ebx, diff - mov edi, row - mov esi, prev_row - pxor mm0, mm0 - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm1, [edi+ebx-8] // Only time should need to read - // a=Raw(x-bpp) bytes -dpth4lp: - // Do first set of 4 bytes - movq mm3, [esi+ebx-8] // read c=Prior(x-bpp) bytes - punpckhbw mm1, mm0 // Unpack Low bytes of a - movq mm2, [esi + ebx] // load b=Prior(x) - punpcklbw mm2, mm0 // Unpack High bytes of b - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - punpckhbw mm3, mm0 // Unpack High bytes of c - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - psubw mm4, mm3 - pxor mm7, mm7 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - paddw mm6, mm5 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - psubw mm4, mm0 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm5, mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pxor mm1, mm1 - pand mm3, mm7 - pandn mm7, mm0 - paddw mm7, mm3 - pxor mm0, mm0 - packuswb mm7, mm1 - movq mm3, [esi + ebx] // load c=Prior(x-bpp) - pand mm7, ActiveMask - movq mm2, mm3 // load b=Prior(x) step 1 - paddb mm7, [edi + ebx] // add Paeth predictor with Raw(x) - punpcklbw mm3, mm0 // Unpack High bytes of c - movq [edi + ebx], mm7 // write back updated value - movq mm1, mm7 // Now mm1 will be used as Raw(x-bpp) - // Do second set of 4 bytes - punpckhbw mm2, mm0 // Unpack Low bytes of b - punpcklbw mm1, mm0 // Unpack Low bytes of a - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - psubw mm4, mm3 - pxor mm7, mm7 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - paddw mm6, mm5 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - psubw mm4, mm0 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm5, mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pxor mm1, mm1 - pand mm3, mm7 - pandn mm7, mm0 - pxor mm1, mm1 - paddw mm7, mm3 - pxor mm0, mm0 - // Step ex to next set of 8 bytes and repeat loop til done - add ebx, 8 - packuswb mm1, mm7 - paddb mm1, [edi + ebx - 8] // add Paeth predictor with Raw(x) - cmp ebx, MMXLength - movq [edi + ebx - 8], mm1 // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - jb dpth4lp - } // end _asm block - } - break; - case 8: // bpp == 8 - { - ActiveMask.use = 0x00000000ffffffff; - _asm { - mov ebx, diff - mov edi, row - mov esi, prev_row - pxor mm0, mm0 - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm1, [edi+ebx-8] // Only time should need to read - // a=Raw(x-bpp) bytes -dpth8lp: - // Do first set of 4 bytes - movq mm3, [esi+ebx-8] // read c=Prior(x-bpp) bytes - punpcklbw mm1, mm0 // Unpack Low bytes of a - movq mm2, [esi + ebx] // load b=Prior(x) - punpcklbw mm2, mm0 // Unpack Low bytes of b - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - punpcklbw mm3, mm0 // Unpack Low bytes of c - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - psubw mm4, mm3 - pxor mm7, mm7 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - paddw mm6, mm5 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - psubw mm4, mm0 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm5, mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pxor mm1, mm1 - pand mm3, mm7 - pandn mm7, mm0 - paddw mm7, mm3 - pxor mm0, mm0 - packuswb mm7, mm1 - movq mm3, [esi+ebx-8] // read c=Prior(x-bpp) bytes - pand mm7, ActiveMask - movq mm2, [esi + ebx] // load b=Prior(x) - paddb mm7, [edi + ebx] // add Paeth predictor with Raw(x) - punpckhbw mm3, mm0 // Unpack High bytes of c - movq [edi + ebx], mm7 // write back updated value - movq mm1, [edi+ebx-8] // read a=Raw(x-bpp) bytes - - // Do second set of 4 bytes - punpckhbw mm2, mm0 // Unpack High bytes of b - punpckhbw mm1, mm0 // Unpack High bytes of a - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - psubw mm4, mm3 - pxor mm7, mm7 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - paddw mm6, mm5 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - psubw mm4, mm0 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm5, mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pxor mm1, mm1 - pand mm3, mm7 - pandn mm7, mm0 - pxor mm1, mm1 - paddw mm7, mm3 - pxor mm0, mm0 - // Step ex to next set of 8 bytes and repeat loop til done - add ebx, 8 - packuswb mm1, mm7 - paddb mm1, [edi + ebx - 8] // add Paeth predictor with Raw(x) - cmp ebx, MMXLength - movq [edi + ebx - 8], mm1 // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - jb dpth8lp - } // end _asm block - } - break; - - case 1: // bpp = 1 - case 2: // bpp = 2 - default: // bpp > 8 - { - _asm { - mov ebx, diff - cmp ebx, FullLength - jnb dpthdend - mov edi, row - mov esi, prev_row - // Do Paeth decode for remaining bytes - mov edx, ebx - xor ecx, ecx // zero ecx before using cl & cx in loop below - sub edx, bpp // Set edx = ebx - bpp -dpthdlp: - xor eax, eax - // pav = p - a = (a + b - c) - a = b - c - mov al, [esi + ebx] // load Prior(x) into al - mov cl, [esi + edx] // load Prior(x-bpp) into cl - sub eax, ecx // subtract Prior(x-bpp) - mov patemp, eax // Save pav for later use - xor eax, eax - // pbv = p - b = (a + b - c) - b = a - c - mov al, [edi + edx] // load Raw(x-bpp) into al - sub eax, ecx // subtract Prior(x-bpp) - mov ecx, eax - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - add eax, patemp // pcv = pav + pbv - // pc = abs(pcv) - test eax, 0x80000000 - jz dpthdpca - neg eax // reverse sign of neg values -dpthdpca: - mov pctemp, eax // save pc for later use - // pb = abs(pbv) - test ecx, 0x80000000 - jz dpthdpba - neg ecx // reverse sign of neg values -dpthdpba: - mov pbtemp, ecx // save pb for later use - // pa = abs(pav) - mov eax, patemp - test eax, 0x80000000 - jz dpthdpaa - neg eax // reverse sign of neg values -dpthdpaa: - mov patemp, eax // save pa for later use - // test if pa <= pb - cmp eax, ecx - jna dpthdabb - // pa > pb; now test if pb <= pc - cmp ecx, pctemp - jna dpthdbbc - // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - mov cl, [esi + edx] // load Prior(x-bpp) into cl - jmp dpthdpaeth -dpthdbbc: - // pb <= pc; Raw(x) = Paeth(x) + Prior(x) - mov cl, [esi + ebx] // load Prior(x) into cl - jmp dpthdpaeth -dpthdabb: - // pa <= pb; now test if pa <= pc - cmp eax, pctemp - jna dpthdabc - // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - mov cl, [esi + edx] // load Prior(x-bpp) into cl - jmp dpthdpaeth -dpthdabc: - // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) - mov cl, [edi + edx] // load Raw(x-bpp) into cl -dpthdpaeth: - inc ebx - inc edx - // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 - add [edi + ebx - 1], cl - cmp ebx, FullLength - jb dpthdlp -dpthdend: - } // end _asm block - } - return; // No need to go further with this one - } // end switch ( bpp ) - _asm - { - // MMX acceleration complete now do clean-up - // Check if any remaining bytes left to decode - mov ebx, MMXLength - cmp ebx, FullLength - jnb dpthend - mov edi, row - mov esi, prev_row - // Do Paeth decode for remaining bytes - mov edx, ebx - xor ecx, ecx // zero ecx before using cl & cx in loop below - sub edx, bpp // Set edx = ebx - bpp -dpthlp2: - xor eax, eax - // pav = p - a = (a + b - c) - a = b - c - mov al, [esi + ebx] // load Prior(x) into al - mov cl, [esi + edx] // load Prior(x-bpp) into cl - sub eax, ecx // subtract Prior(x-bpp) - mov patemp, eax // Save pav for later use - xor eax, eax - // pbv = p - b = (a + b - c) - b = a - c - mov al, [edi + edx] // load Raw(x-bpp) into al - sub eax, ecx // subtract Prior(x-bpp) - mov ecx, eax - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - add eax, patemp // pcv = pav + pbv - // pc = abs(pcv) - test eax, 0x80000000 - jz dpthpca2 - neg eax // reverse sign of neg values -dpthpca2: - mov pctemp, eax // save pc for later use - // pb = abs(pbv) - test ecx, 0x80000000 - jz dpthpba2 - neg ecx // reverse sign of neg values -dpthpba2: - mov pbtemp, ecx // save pb for later use - // pa = abs(pav) - mov eax, patemp - test eax, 0x80000000 - jz dpthpaa2 - neg eax // reverse sign of neg values -dpthpaa2: - mov patemp, eax // save pa for later use - // test if pa <= pb - cmp eax, ecx - jna dpthabb2 - // pa > pb; now test if pb <= pc - cmp ecx, pctemp - jna dpthbbc2 - // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - mov cl, [esi + edx] // load Prior(x-bpp) into cl - jmp dpthpaeth2 -dpthbbc2: - // pb <= pc; Raw(x) = Paeth(x) + Prior(x) - mov cl, [esi + ebx] // load Prior(x) into cl - jmp dpthpaeth2 -dpthabb2: - // pa <= pb; now test if pa <= pc - cmp eax, pctemp - jna dpthabc2 - // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - mov cl, [esi + edx] // load Prior(x-bpp) into cl - jmp dpthpaeth2 -dpthabc2: - // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) - mov cl, [edi + edx] // load Raw(x-bpp) into cl -dpthpaeth2: - inc ebx - inc edx - // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 - add [edi + ebx - 1], cl - cmp ebx, FullLength - jb dpthlp2 -dpthend: - emms // End MMX instructions; prep for possible FP instrs. - } // end _asm block -} - -// Optimized code for PNG Sub filter decoder -void /* PRIVATE */ -png_read_filter_row_mmx_sub(png_row_infop row_info, png_bytep row) -{ - //int test; - int bpp; - png_uint_32 FullLength; - png_uint_32 MMXLength; - int diff; - - bpp = (row_info->pixel_depth + 7) >> 3; // Get # bytes per pixel - FullLength = row_info->rowbytes - bpp; // # of bytes to filter - _asm { - mov edi, row - mov esi, edi // lp = row - add edi, bpp // rp = row + bpp - xor eax, eax - // get # of bytes to alignment - mov diff, edi // take start of row - add diff, 0xf // add 7 + 8 to incr past - // alignment boundary - xor ebx, ebx - and diff, 0xfffffff8 // mask to alignment boundary - sub diff, edi // subtract from start ==> value - // ebx at alignment - jz dsubgo - // fix alignment -dsublp1: - mov al, [esi+ebx] - add [edi+ebx], al - inc ebx - cmp ebx, diff - jb dsublp1 -dsubgo: - mov ecx, FullLength - mov edx, ecx - sub edx, ebx // subtract alignment fix - and edx, 0x00000007 // calc bytes over mult of 8 - sub ecx, edx // drop over bytes from length - mov MMXLength, ecx - } // end _asm block - - // Now do the math for the rest of the row - switch ( bpp ) - { - case 3: - { - ActiveMask.use = 0x0000ffffff000000; - ShiftBpp.use = 24; // == 3 * 8 - ShiftRem.use = 40; // == 64 - 24 - _asm { - mov edi, row - movq mm7, ActiveMask // Load ActiveMask for 2nd active byte group - mov esi, edi // lp = row - add edi, bpp // rp = row + bpp - movq mm6, mm7 - mov ebx, diff - psllq mm6, ShiftBpp // Move mask in mm6 to cover 3rd active - // byte group - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm1, [edi+ebx-8] -dsub3lp: - psrlq mm1, ShiftRem // Shift data for adding 1st bpp bytes - // no need for mask; shift clears inactive bytes - // Add 1st active group - movq mm0, [edi+ebx] - paddb mm0, mm1 - // Add 2nd active group - movq mm1, mm0 // mov updated Raws to mm1 - psllq mm1, ShiftBpp // shift data to position correctly - pand mm1, mm7 // mask to use only 2nd active group - paddb mm0, mm1 - // Add 3rd active group - movq mm1, mm0 // mov updated Raws to mm1 - psllq mm1, ShiftBpp // shift data to position correctly - pand mm1, mm6 // mask to use only 3rd active group - add ebx, 8 - paddb mm0, mm1 - cmp ebx, MMXLength - movq [edi+ebx-8], mm0 // Write updated Raws back to array - // Prep for doing 1st add at top of loop - movq mm1, mm0 - jb dsub3lp - } // end _asm block - } - break; - - case 1: - { - // Placed here just in case this is a duplicate of the - // non-MMX code for the SUB filter in png_read_filter_row below - // - // png_bytep rp; - // png_bytep lp; - // png_uint_32 i; - // bpp = (row_info->pixel_depth + 7) >> 3; - // for (i = (png_uint_32)bpp, rp = row + bpp, lp = row; - // i < row_info->rowbytes; i++, rp++, lp++) - // { - // *rp = (png_byte)(((int)(*rp) + (int)(*lp)) & 0xff); - // } - _asm { - mov ebx, diff - mov edi, row - cmp ebx, FullLength - jnb dsub1end - mov esi, edi // lp = row - xor eax, eax - add edi, bpp // rp = row + bpp -dsub1lp: - mov al, [esi+ebx] - add [edi+ebx], al - inc ebx - cmp ebx, FullLength - jb dsub1lp -dsub1end: - } // end _asm block - } - return; - - case 6: - case 7: - case 4: - case 5: - { - ShiftBpp.use = bpp << 3; - ShiftRem.use = 64 - ShiftBpp.use; - _asm { - mov edi, row - mov ebx, diff - mov esi, edi // lp = row - add edi, bpp // rp = row + bpp - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm1, [edi+ebx-8] -dsub4lp: - psrlq mm1, ShiftRem // Shift data for adding 1st bpp bytes - // no need for mask; shift clears inactive bytes - movq mm0, [edi+ebx] - paddb mm0, mm1 - // Add 2nd active group - movq mm1, mm0 // mov updated Raws to mm1 - psllq mm1, ShiftBpp // shift data to position correctly - // there is no need for any mask - // since shift clears inactive bits/bytes - add ebx, 8 - paddb mm0, mm1 - cmp ebx, MMXLength - movq [edi+ebx-8], mm0 - movq mm1, mm0 // Prep for doing 1st add at top of loop - jb dsub4lp - } // end _asm block - } - break; - - case 2: - { - ActiveMask.use = 0x00000000ffff0000; - ShiftBpp.use = 16; // == 2 * 8 - ShiftRem.use = 48; // == 64 - 16 - _asm { - movq mm7, ActiveMask // Load ActiveMask for 2nd active byte group - mov ebx, diff - movq mm6, mm7 - mov edi, row - psllq mm6, ShiftBpp // Move mask in mm6 to cover 3rd active - // byte group - mov esi, edi // lp = row - movq mm5, mm6 - add edi, bpp // rp = row + bpp - psllq mm5, ShiftBpp // Move mask in mm5 to cover 4th active - // byte group - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm1, [edi+ebx-8] -dsub2lp: - // Add 1st active group - psrlq mm1, ShiftRem // Shift data for adding 1st bpp bytes - // no need for mask; shift clears inactive - // bytes - movq mm0, [edi+ebx] - paddb mm0, mm1 - // Add 2nd active group - movq mm1, mm0 // mov updated Raws to mm1 - psllq mm1, ShiftBpp // shift data to position correctly - pand mm1, mm7 // mask to use only 2nd active group - paddb mm0, mm1 - // Add 3rd active group - movq mm1, mm0 // mov updated Raws to mm1 - psllq mm1, ShiftBpp // shift data to position correctly - pand mm1, mm6 // mask to use only 3rd active group - paddb mm0, mm1 - // Add 4th active group - movq mm1, mm0 // mov updated Raws to mm1 - psllq mm1, ShiftBpp // shift data to position correctly - pand mm1, mm5 // mask to use only 4th active group - add ebx, 8 - paddb mm0, mm1 - cmp ebx, MMXLength - movq [edi+ebx-8], mm0 // Write updated Raws back to array - movq mm1, mm0 // Prep for doing 1st add at top of loop - jb dsub2lp - } // end _asm block - } - break; - case 8: - { - _asm { - mov edi, row - mov ebx, diff - mov esi, edi // lp = row - add edi, bpp // rp = row + bpp - mov ecx, MMXLength - movq mm7, [edi+ebx-8] // PRIME the pump (load the first - // Raw(x-bpp) data set - and ecx, 0x0000003f // calc bytes over mult of 64 -dsub8lp: - movq mm0, [edi+ebx] // Load Sub(x) for 1st 8 bytes - paddb mm0, mm7 - movq mm1, [edi+ebx+8] // Load Sub(x) for 2nd 8 bytes - movq [edi+ebx], mm0 // Write Raw(x) for 1st 8 bytes - // Now mm0 will be used as Raw(x-bpp) for - // the 2nd group of 8 bytes. This will be - // repeated for each group of 8 bytes with - // the 8th group being used as the Raw(x-bpp) - // for the 1st group of the next loop. - paddb mm1, mm0 - movq mm2, [edi+ebx+16] // Load Sub(x) for 3rd 8 bytes - movq [edi+ebx+8], mm1 // Write Raw(x) for 2nd 8 bytes - paddb mm2, mm1 - movq mm3, [edi+ebx+24] // Load Sub(x) for 4th 8 bytes - movq [edi+ebx+16], mm2 // Write Raw(x) for 3rd 8 bytes - paddb mm3, mm2 - movq mm4, [edi+ebx+32] // Load Sub(x) for 5th 8 bytes - movq [edi+ebx+24], mm3 // Write Raw(x) for 4th 8 bytes - paddb mm4, mm3 - movq mm5, [edi+ebx+40] // Load Sub(x) for 6th 8 bytes - movq [edi+ebx+32], mm4 // Write Raw(x) for 5th 8 bytes - paddb mm5, mm4 - movq mm6, [edi+ebx+48] // Load Sub(x) for 7th 8 bytes - movq [edi+ebx+40], mm5 // Write Raw(x) for 6th 8 bytes - paddb mm6, mm5 - movq mm7, [edi+ebx+56] // Load Sub(x) for 8th 8 bytes - movq [edi+ebx+48], mm6 // Write Raw(x) for 7th 8 bytes - add ebx, 64 - paddb mm7, mm6 - cmp ebx, ecx - movq [edi+ebx-8], mm7 // Write Raw(x) for 8th 8 bytes - jb dsub8lp - cmp ebx, MMXLength - jnb dsub8lt8 -dsub8lpA: - movq mm0, [edi+ebx] - add ebx, 8 - paddb mm0, mm7 - cmp ebx, MMXLength - movq [edi+ebx-8], mm0 // use -8 to offset early add to ebx - movq mm7, mm0 // Move calculated Raw(x) data to mm1 to - // be the new Raw(x-bpp) for the next loop - jb dsub8lpA -dsub8lt8: - } // end _asm block - } - break; - - default: // bpp greater than 8 bytes - { - _asm { - mov ebx, diff - mov edi, row - mov esi, edi // lp = row - add edi, bpp // rp = row + bpp -dsubAlp: - movq mm0, [edi+ebx] - movq mm1, [esi+ebx] - add ebx, 8 - paddb mm0, mm1 - cmp ebx, MMXLength - movq [edi+ebx-8], mm0 // mov does not affect flags; -8 to offset - // add ebx - jb dsubAlp - } // end _asm block - } - break; - - } // end switch ( bpp ) - - _asm { - mov ebx, MMXLength - mov edi, row - cmp ebx, FullLength - jnb dsubend - mov esi, edi // lp = row - xor eax, eax - add edi, bpp // rp = row + bpp -dsublp2: - mov al, [esi+ebx] - add [edi+ebx], al - inc ebx - cmp ebx, FullLength - jb dsublp2 -dsubend: - emms // End MMX instructions; prep for possible FP instrs. - } // end _asm block -} - -// Optimized code for PNG Up filter decoder -void /* PRIVATE */ -png_read_filter_row_mmx_up(png_row_infop row_info, png_bytep row, - png_bytep prev_row) -{ - png_uint_32 len; - len = row_info->rowbytes; // # of bytes to filter - _asm { - mov edi, row - // get # of bytes to alignment - mov ecx, edi - xor ebx, ebx - add ecx, 0x7 - xor eax, eax - and ecx, 0xfffffff8 - mov esi, prev_row - sub ecx, edi - jz dupgo - // fix alignment -duplp1: - mov al, [edi+ebx] - add al, [esi+ebx] - inc ebx - cmp ebx, ecx - mov [edi + ebx-1], al // mov does not affect flags; -1 to offset inc ebx - jb duplp1 -dupgo: - mov ecx, len - mov edx, ecx - sub edx, ebx // subtract alignment fix - and edx, 0x0000003f // calc bytes over mult of 64 - sub ecx, edx // drop over bytes from length - // Unrolled loop - use all MMX registers and interleave to reduce - // number of branch instructions (loops) and reduce partial stalls -duploop: - movq mm1, [esi+ebx] - movq mm0, [edi+ebx] - movq mm3, [esi+ebx+8] - paddb mm0, mm1 - movq mm2, [edi+ebx+8] - movq [edi+ebx], mm0 - paddb mm2, mm3 - movq mm5, [esi+ebx+16] - movq [edi+ebx+8], mm2 - movq mm4, [edi+ebx+16] - movq mm7, [esi+ebx+24] - paddb mm4, mm5 - movq mm6, [edi+ebx+24] - movq [edi+ebx+16], mm4 - paddb mm6, mm7 - movq mm1, [esi+ebx+32] - movq [edi+ebx+24], mm6 - movq mm0, [edi+ebx+32] - movq mm3, [esi+ebx+40] - paddb mm0, mm1 - movq mm2, [edi+ebx+40] - movq [edi+ebx+32], mm0 - paddb mm2, mm3 - movq mm5, [esi+ebx+48] - movq [edi+ebx+40], mm2 - movq mm4, [edi+ebx+48] - movq mm7, [esi+ebx+56] - paddb mm4, mm5 - movq mm6, [edi+ebx+56] - movq [edi+ebx+48], mm4 - add ebx, 64 - paddb mm6, mm7 - cmp ebx, ecx - movq [edi+ebx-8], mm6 // (+56)movq does not affect flags; - // -8 to offset add ebx - jb duploop - - cmp edx, 0 // Test for bytes over mult of 64 - jz dupend - - - // 2 lines added by lcreeve at netins.net - // (mail 11 Jul 98 in png-implement list) - cmp edx, 8 //test for less than 8 bytes - jb duplt8 - - - add ecx, edx - and edx, 0x00000007 // calc bytes over mult of 8 - sub ecx, edx // drop over bytes from length - jz duplt8 - // Loop using MMX registers mm0 & mm1 to update 8 bytes simultaneously -duplpA: - movq mm1, [esi+ebx] - movq mm0, [edi+ebx] - add ebx, 8 - paddb mm0, mm1 - cmp ebx, ecx - movq [edi+ebx-8], mm0 // movq does not affect flags; -8 to offset add ebx - jb duplpA - cmp edx, 0 // Test for bytes over mult of 8 - jz dupend -duplt8: - xor eax, eax - add ecx, edx // move over byte count into counter - // Loop using x86 registers to update remaining bytes -duplp2: - mov al, [edi + ebx] - add al, [esi + ebx] - inc ebx - cmp ebx, ecx - mov [edi + ebx-1], al // mov does not affect flags; -1 to offset inc ebx - jb duplp2 -dupend: - // Conversion of filtered row completed - emms // End MMX instructions; prep for possible FP instrs. - } // end _asm block -} - - -// Optimized png_read_filter_row routines -void /* PRIVATE */ -png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep - row, png_bytep prev_row, int filter) -{ -#ifdef PNG_DEBUG - char filnm[10]; -#endif - - if (mmx_supported == 2) { -#if !defined(PNG_1_0_X) - /* this should have happened in png_init_mmx_flags() already */ - png_warning(png_ptr, "asm_flags may not have been initialized"); -#endif - png_mmx_support(); - } - -#ifdef PNG_DEBUG - png_debug(1, "in png_read_filter_row\n"); - switch (filter) - { - case 0: sprintf(filnm, "none"); - break; -#if !defined(PNG_1_0_X) - case 1: sprintf(filnm, "sub-%s", - (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB)? "MMX" : "x86"); - break; - case 2: sprintf(filnm, "up-%s", - (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP)? "MMX" : "x86"); - break; - case 3: sprintf(filnm, "avg-%s", - (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG)? "MMX" : "x86"); - break; - case 4: sprintf(filnm, "Paeth-%s", - (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH)? "MMX":"x86"); - break; -#else - case 1: sprintf(filnm, "sub"); - break; - case 2: sprintf(filnm, "up"); - break; - case 3: sprintf(filnm, "avg"); - break; - case 4: sprintf(filnm, "Paeth"); - break; -#endif - default: sprintf(filnm, "unknw"); - break; - } - png_debug2(0,"row=%5d, %s, ", png_ptr->row_number, filnm); - png_debug2(0, "pd=%2d, b=%d, ", (int)row_info->pixel_depth, - (int)((row_info->pixel_depth + 7) >> 3)); - png_debug1(0,"len=%8d, ", row_info->rowbytes); -#endif /* PNG_DEBUG */ - - switch (filter) - { - case PNG_FILTER_VALUE_NONE: - break; - - case PNG_FILTER_VALUE_SUB: - { -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB) && - (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && - (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) -#else - if (mmx_supported) -#endif - { - png_read_filter_row_mmx_sub(row_info, row); - } - else - { - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_bytep rp = row + bpp; - png_bytep lp = row; - - for (i = bpp; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*lp++)) & 0xff); - rp++; - } - } - break; - } - - case PNG_FILTER_VALUE_UP: - { -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP) && - (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && - (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) -#else - if (mmx_supported) -#endif - { - png_read_filter_row_mmx_up(row_info, row, prev_row); - } - else - { - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_bytep rp = row; - png_bytep pp = prev_row; - - for (i = 0; i < istop; ++i) - { - *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); - rp++; - } - } - break; - } - - case PNG_FILTER_VALUE_AVG: - { -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG) && - (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && - (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) -#else - if (mmx_supported) -#endif - { - png_read_filter_row_mmx_avg(row_info, row, prev_row); - } - else - { - png_uint_32 i; - png_bytep rp = row; - png_bytep pp = prev_row; - png_bytep lp = row; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_uint_32 istop = row_info->rowbytes - bpp; - - for (i = 0; i < bpp; i++) - { - *rp = (png_byte)(((int)(*rp) + - ((int)(*pp++) >> 1)) & 0xff); - rp++; - } - - for (i = 0; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + - ((int)(*pp++ + *lp++) >> 1)) & 0xff); - rp++; - } - } - break; - } - - case PNG_FILTER_VALUE_PAETH: - { -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH) && - (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && - (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) -#else - if (mmx_supported) -#endif - { - png_read_filter_row_mmx_paeth(row_info, row, prev_row); - } - else - { - png_uint_32 i; - png_bytep rp = row; - png_bytep pp = prev_row; - png_bytep lp = row; - png_bytep cp = prev_row; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_uint_32 istop=row_info->rowbytes - bpp; - - for (i = 0; i < bpp; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); - rp++; - } - - for (i = 0; i < istop; i++) // use leftover rp,pp - { - int a, b, c, pa, pb, pc, p; - - a = *lp++; - b = *pp++; - c = *cp++; - - p = b - c; - pc = a - c; - -#ifdef PNG_USE_ABS - pa = abs(p); - pb = abs(pc); - pc = abs(p + pc); -#else - pa = p < 0 ? -p : p; - pb = pc < 0 ? -pc : pc; - pc = (p + pc) < 0 ? -(p + pc) : p + pc; -#endif - - /* - if (pa <= pb && pa <= pc) - p = a; - else if (pb <= pc) - p = b; - else - p = c; - */ - - p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; - - *rp = (png_byte)(((int)(*rp) + p) & 0xff); - rp++; - } - } - break; - } - - default: - png_warning(png_ptr, "Ignoring bad row filter type"); - *row=0; - break; - } -} - -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED && PNG_USE_PNGVCRD */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/pngwio.c b/irrlicht-1.6/source/Irrlicht/libpng/pngwio.c deleted file mode 100644 index f40bccb9c..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/pngwio.c +++ /dev/null @@ -1,234 +0,0 @@ - -/* pngwio.c - functions for data output - * - * Last changed in libpng 1.2.13 November 13, 2006 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2002 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This file provides a location for all output. Users who need - * special handling are expected to write functions that have the same - * arguments as these and perform similar functions, but that possibly - * use different output methods. Note that you shouldn't change these - * functions, but rather write replacement functions and then change - * them at run time with png_set_write_fn(...). - */ - -#define PNG_INTERNAL -#include "png.h" -#ifdef PNG_WRITE_SUPPORTED - -/* Write the data to whatever output you are using. The default routine - writes to a file pointer. Note that this routine sometimes gets called - with very small lengths, so you should implement some kind of simple - buffering if you are using unbuffered writes. This should never be asked - to write more than 64K on a 16 bit machine. */ - -void /* PRIVATE */ -png_write_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - if (png_ptr->write_data_fn != NULL ) - (*(png_ptr->write_data_fn))(png_ptr, data, length); - else - png_error(png_ptr, "Call to NULL write function"); -} - -#if !defined(PNG_NO_STDIO) -/* This is the function that does the actual writing of data. If you are - not writing to a standard C stream, you should create a replacement - write_data function and use it at run time with png_set_write_fn(), rather - than changing the library. */ -#ifndef USE_FAR_KEYWORD -void PNGAPI -png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_uint_32 check; - - if(png_ptr == NULL) return; -#if defined(_WIN32_WCE) - if ( !WriteFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) - check = 0; -#else - check = fwrite(data, 1, length, (png_FILE_p)(png_ptr->io_ptr)); -#endif - if (check != length) - png_error(png_ptr, "Write Error"); -} -#else -/* this is the model-independent version. Since the standard I/O library - can't handle far buffers in the medium and small models, we have to copy - the data. -*/ - -#define NEAR_BUF_SIZE 1024 -#define MIN(a,b) (a <= b ? a : b) - -void PNGAPI -png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_uint_32 check; - png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */ - png_FILE_p io_ptr; - - if(png_ptr == NULL) return; - /* Check if data really is near. If so, use usual code. */ - near_data = (png_byte *)CVT_PTR_NOCHECK(data); - io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); - if ((png_bytep)near_data == data) - { -#if defined(_WIN32_WCE) - if ( !WriteFile(io_ptr, near_data, length, &check, NULL) ) - check = 0; -#else - check = fwrite(near_data, 1, length, io_ptr); -#endif - } - else - { - png_byte buf[NEAR_BUF_SIZE]; - png_size_t written, remaining, err; - check = 0; - remaining = length; - do - { - written = MIN(NEAR_BUF_SIZE, remaining); - png_memcpy(buf, data, written); /* copy far buffer to near buffer */ -#if defined(_WIN32_WCE) - if ( !WriteFile(io_ptr, buf, written, &err, NULL) ) - err = 0; -#else - err = fwrite(buf, 1, written, io_ptr); -#endif - if (err != written) - break; - else - check += err; - data += written; - remaining -= written; - } - while (remaining != 0); - } - if (check != length) - png_error(png_ptr, "Write Error"); -} - -#endif -#endif - -/* This function is called to output any data pending writing (normally - to disk). After png_flush is called, there should be no data pending - writing in any buffers. */ -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -void /* PRIVATE */ -png_flush(png_structp png_ptr) -{ - if (png_ptr->output_flush_fn != NULL) - (*(png_ptr->output_flush_fn))(png_ptr); -} - -#if !defined(PNG_NO_STDIO) -void PNGAPI -png_default_flush(png_structp png_ptr) -{ -#if !defined(_WIN32_WCE) - png_FILE_p io_ptr; -#endif - if(png_ptr == NULL) return; -#if !defined(_WIN32_WCE) - io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr)); - if (io_ptr != NULL) - fflush(io_ptr); -#endif -} -#endif -#endif - -/* This function allows the application to supply new output functions for - libpng if standard C streams aren't being used. - - This function takes as its arguments: - png_ptr - pointer to a png output data structure - io_ptr - pointer to user supplied structure containing info about - the output functions. May be NULL. - write_data_fn - pointer to a new output function that takes as its - arguments a pointer to a png_struct, a pointer to - data to be written, and a 32-bit unsigned int that is - the number of bytes to be written. The new write - function should call png_error(png_ptr, "Error msg") - to exit and output any fatal error messages. - flush_data_fn - pointer to a new flush function that takes as its - arguments a pointer to a png_struct. After a call to - the flush function, there should be no data in any buffers - or pending transmission. If the output method doesn't do - any buffering of ouput, a function prototype must still be - supplied although it doesn't have to do anything. If - PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile - time, output_flush_fn will be ignored, although it must be - supplied for compatibility. */ -void PNGAPI -png_set_write_fn(png_structp png_ptr, png_voidp io_ptr, - png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn) -{ - if(png_ptr == NULL) return; - png_ptr->io_ptr = io_ptr; - -#if !defined(PNG_NO_STDIO) - if (write_data_fn != NULL) - png_ptr->write_data_fn = write_data_fn; - else - png_ptr->write_data_fn = png_default_write_data; -#else - png_ptr->write_data_fn = write_data_fn; -#endif - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -#if !defined(PNG_NO_STDIO) - if (output_flush_fn != NULL) - png_ptr->output_flush_fn = output_flush_fn; - else - png_ptr->output_flush_fn = png_default_flush; -#else - png_ptr->output_flush_fn = output_flush_fn; -#endif -#endif /* PNG_WRITE_FLUSH_SUPPORTED */ - - /* It is an error to read while writing a png file */ - if (png_ptr->read_data_fn != NULL) - { - png_ptr->read_data_fn = NULL; - png_warning(png_ptr, - "Attempted to set both read_data_fn and write_data_fn in"); - png_warning(png_ptr, - "the same structure. Resetting read_data_fn to NULL."); - } -} - -#if defined(USE_FAR_KEYWORD) -#if defined(_MSC_VER) -void *png_far_to_near(png_structp png_ptr,png_voidp ptr, int check) -{ - void *near_ptr; - void FAR *far_ptr; - FP_OFF(near_ptr) = FP_OFF(ptr); - far_ptr = (void FAR *)near_ptr; - if(check != 0) - if(FP_SEG(ptr) != FP_SEG(far_ptr)) - png_error(png_ptr,"segment lost in conversion"); - return(near_ptr); -} -# else -void *png_far_to_near(png_structp png_ptr,png_voidp ptr, int check) -{ - void *near_ptr; - void FAR *far_ptr; - near_ptr = (void FAR *)ptr; - far_ptr = (void FAR *)near_ptr; - if(check != 0) - if(far_ptr != ptr) - png_error(png_ptr,"segment lost in conversion"); - return(near_ptr); -} -# endif -# endif -#endif /* PNG_WRITE_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/pngwrite.c b/irrlicht-1.6/source/Irrlicht/libpng/pngwrite.c deleted file mode 100644 index b4fd7df1e..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/pngwrite.c +++ /dev/null @@ -1,1518 +0,0 @@ - -/* pngwrite.c - general routines to write a PNG file - * - * Last changed in libpng 1.2.15 January 5, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -/* get internal access to png.h */ -#define PNG_INTERNAL -#include "png.h" -#ifdef PNG_WRITE_SUPPORTED - -/* Writes all the PNG information. This is the suggested way to use the - * library. If you have a new chunk to add, make a function to write it, - * and put it in the correct location here. If you want the chunk written - * after the image data, put it in png_write_end(). I strongly encourage - * you to supply a PNG_INFO_ flag, and check info_ptr->valid before writing - * the chunk, as that will keep the code from breaking if you want to just - * write a plain PNG file. If you have long comments, I suggest writing - * them in png_write_end(), and compressing them. - */ -void PNGAPI -png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr) -{ - png_debug(1, "in png_write_info_before_PLTE\n"); - if (png_ptr == NULL || info_ptr == NULL) - return; - if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE)) - { - png_write_sig(png_ptr); /* write PNG signature */ -#if defined(PNG_MNG_FEATURES_SUPPORTED) - if((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&(png_ptr->mng_features_permitted)) - { - png_warning(png_ptr,"MNG features are not allowed in a PNG datastream"); - png_ptr->mng_features_permitted=0; - } -#endif - /* write IHDR information. */ - png_write_IHDR(png_ptr, info_ptr->width, info_ptr->height, - info_ptr->bit_depth, info_ptr->color_type, info_ptr->compression_type, - info_ptr->filter_type, -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) - info_ptr->interlace_type); -#else - 0); -#endif - /* the rest of these check to see if the valid field has the appropriate - flag set, and if it does, writes the chunk. */ -#if defined(PNG_WRITE_gAMA_SUPPORTED) - if (info_ptr->valid & PNG_INFO_gAMA) - { -# ifdef PNG_FLOATING_POINT_SUPPORTED - png_write_gAMA(png_ptr, info_ptr->gamma); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - png_write_gAMA_fixed(png_ptr, info_ptr->int_gamma); -# endif -#endif - } -#endif -#if defined(PNG_WRITE_sRGB_SUPPORTED) - if (info_ptr->valid & PNG_INFO_sRGB) - png_write_sRGB(png_ptr, (int)info_ptr->srgb_intent); -#endif -#if defined(PNG_WRITE_iCCP_SUPPORTED) - if (info_ptr->valid & PNG_INFO_iCCP) - png_write_iCCP(png_ptr, info_ptr->iccp_name, PNG_COMPRESSION_TYPE_BASE, - info_ptr->iccp_profile, (int)info_ptr->iccp_proflen); -#endif -#if defined(PNG_WRITE_sBIT_SUPPORTED) - if (info_ptr->valid & PNG_INFO_sBIT) - png_write_sBIT(png_ptr, &(info_ptr->sig_bit), info_ptr->color_type); -#endif -#if defined(PNG_WRITE_cHRM_SUPPORTED) - if (info_ptr->valid & PNG_INFO_cHRM) - { -#ifdef PNG_FLOATING_POINT_SUPPORTED - png_write_cHRM(png_ptr, - info_ptr->x_white, info_ptr->y_white, - info_ptr->x_red, info_ptr->y_red, - info_ptr->x_green, info_ptr->y_green, - info_ptr->x_blue, info_ptr->y_blue); -#else -# ifdef PNG_FIXED_POINT_SUPPORTED - png_write_cHRM_fixed(png_ptr, - info_ptr->int_x_white, info_ptr->int_y_white, - info_ptr->int_x_red, info_ptr->int_y_red, - info_ptr->int_x_green, info_ptr->int_y_green, - info_ptr->int_x_blue, info_ptr->int_y_blue); -# endif -#endif - } -#endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) - if (info_ptr->unknown_chunks_num) - { - png_unknown_chunk *up; - - png_debug(5, "writing extra chunks\n"); - - for (up = info_ptr->unknown_chunks; - up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num; - up++) - { - int keep=png_handle_as_unknown(png_ptr, up->name); - if (keep != PNG_HANDLE_CHUNK_NEVER && - up->location && !(up->location & PNG_HAVE_PLTE) && - !(up->location & PNG_HAVE_IDAT) && - ((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS || - (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS))) - { - png_write_chunk(png_ptr, up->name, up->data, up->size); - } - } - } -#endif - png_ptr->mode |= PNG_WROTE_INFO_BEFORE_PLTE; - } -} - -void PNGAPI -png_write_info(png_structp png_ptr, png_infop info_ptr) -{ -#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) - int i; -#endif - - png_debug(1, "in png_write_info\n"); - - if (png_ptr == NULL || info_ptr == NULL) - return; - - png_write_info_before_PLTE(png_ptr, info_ptr); - - if (info_ptr->valid & PNG_INFO_PLTE) - png_write_PLTE(png_ptr, info_ptr->palette, - (png_uint_32)info_ptr->num_palette); - else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - png_error(png_ptr, "Valid palette required for paletted images"); - -#if defined(PNG_WRITE_tRNS_SUPPORTED) - if (info_ptr->valid & PNG_INFO_tRNS) - { -#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) - /* invert the alpha channel (in tRNS) */ - if ((png_ptr->transformations & PNG_INVERT_ALPHA) && - info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - int j; - for (j=0; j<(int)info_ptr->num_trans; j++) - info_ptr->trans[j] = (png_byte)(255 - info_ptr->trans[j]); - } -#endif - png_write_tRNS(png_ptr, info_ptr->trans, &(info_ptr->trans_values), - info_ptr->num_trans, info_ptr->color_type); - } -#endif -#if defined(PNG_WRITE_bKGD_SUPPORTED) - if (info_ptr->valid & PNG_INFO_bKGD) - png_write_bKGD(png_ptr, &(info_ptr->background), info_ptr->color_type); -#endif -#if defined(PNG_WRITE_hIST_SUPPORTED) - if (info_ptr->valid & PNG_INFO_hIST) - png_write_hIST(png_ptr, info_ptr->hist, info_ptr->num_palette); -#endif -#if defined(PNG_WRITE_oFFs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_oFFs) - png_write_oFFs(png_ptr, info_ptr->x_offset, info_ptr->y_offset, - info_ptr->offset_unit_type); -#endif -#if defined(PNG_WRITE_pCAL_SUPPORTED) - if (info_ptr->valid & PNG_INFO_pCAL) - png_write_pCAL(png_ptr, info_ptr->pcal_purpose, info_ptr->pcal_X0, - info_ptr->pcal_X1, info_ptr->pcal_type, info_ptr->pcal_nparams, - info_ptr->pcal_units, info_ptr->pcal_params); -#endif -#if defined(PNG_WRITE_sCAL_SUPPORTED) - if (info_ptr->valid & PNG_INFO_sCAL) -#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) - png_write_sCAL(png_ptr, (int)info_ptr->scal_unit, - info_ptr->scal_pixel_width, info_ptr->scal_pixel_height); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - png_write_sCAL_s(png_ptr, (int)info_ptr->scal_unit, - info_ptr->scal_s_width, info_ptr->scal_s_height); -#else - png_warning(png_ptr, - "png_write_sCAL not supported; sCAL chunk not written."); -#endif -#endif -#endif -#if defined(PNG_WRITE_pHYs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_pHYs) - png_write_pHYs(png_ptr, info_ptr->x_pixels_per_unit, - info_ptr->y_pixels_per_unit, info_ptr->phys_unit_type); -#endif -#if defined(PNG_WRITE_tIME_SUPPORTED) - if (info_ptr->valid & PNG_INFO_tIME) - { - png_write_tIME(png_ptr, &(info_ptr->mod_time)); - png_ptr->mode |= PNG_WROTE_tIME; - } -#endif -#if defined(PNG_WRITE_sPLT_SUPPORTED) - if (info_ptr->valid & PNG_INFO_sPLT) - for (i = 0; i < (int)info_ptr->splt_palettes_num; i++) - png_write_sPLT(png_ptr, info_ptr->splt_palettes + i); -#endif -#if defined(PNG_WRITE_TEXT_SUPPORTED) - /* Check to see if we need to write text chunks */ - for (i = 0; i < info_ptr->num_text; i++) - { - png_debug2(2, "Writing header text chunk %d, type %d\n", i, - info_ptr->text[i].compression); - /* an internationalized chunk? */ - if (info_ptr->text[i].compression > 0) - { -#if defined(PNG_WRITE_iTXt_SUPPORTED) - /* write international chunk */ - png_write_iTXt(png_ptr, - info_ptr->text[i].compression, - info_ptr->text[i].key, - info_ptr->text[i].lang, - info_ptr->text[i].lang_key, - info_ptr->text[i].text); -#else - png_warning(png_ptr, "Unable to write international text"); -#endif - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; - } - /* If we want a compressed text chunk */ - else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_zTXt) - { -#if defined(PNG_WRITE_zTXt_SUPPORTED) - /* write compressed chunk */ - png_write_zTXt(png_ptr, info_ptr->text[i].key, - info_ptr->text[i].text, 0, - info_ptr->text[i].compression); -#else - png_warning(png_ptr, "Unable to write compressed text"); -#endif - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR; - } - else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE) - { -#if defined(PNG_WRITE_tEXt_SUPPORTED) - /* write uncompressed chunk */ - png_write_tEXt(png_ptr, info_ptr->text[i].key, - info_ptr->text[i].text, - 0); -#else - png_warning(png_ptr, "Unable to write uncompressed text"); -#endif - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; - } - } -#endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) - if (info_ptr->unknown_chunks_num) - { - png_unknown_chunk *up; - - png_debug(5, "writing extra chunks\n"); - - for (up = info_ptr->unknown_chunks; - up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num; - up++) - { - int keep=png_handle_as_unknown(png_ptr, up->name); - if (keep != PNG_HANDLE_CHUNK_NEVER && - up->location && (up->location & PNG_HAVE_PLTE) && - !(up->location & PNG_HAVE_IDAT) && - ((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS || - (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS))) - { - png_write_chunk(png_ptr, up->name, up->data, up->size); - } - } - } -#endif -} - -/* Writes the end of the PNG file. If you don't want to write comments or - * time information, you can pass NULL for info. If you already wrote these - * in png_write_info(), do not write them again here. If you have long - * comments, I suggest writing them here, and compressing them. - */ -void PNGAPI -png_write_end(png_structp png_ptr, png_infop info_ptr) -{ - png_debug(1, "in png_write_end\n"); - if (png_ptr == NULL) - return; - if (!(png_ptr->mode & PNG_HAVE_IDAT)) - png_error(png_ptr, "No IDATs written into file"); - - /* see if user wants us to write information chunks */ - if (info_ptr != NULL) - { -#if defined(PNG_WRITE_TEXT_SUPPORTED) - int i; /* local index variable */ -#endif -#if defined(PNG_WRITE_tIME_SUPPORTED) - /* check to see if user has supplied a time chunk */ - if ((info_ptr->valid & PNG_INFO_tIME) && - !(png_ptr->mode & PNG_WROTE_tIME)) - png_write_tIME(png_ptr, &(info_ptr->mod_time)); -#endif -#if defined(PNG_WRITE_TEXT_SUPPORTED) - /* loop through comment chunks */ - for (i = 0; i < info_ptr->num_text; i++) - { - png_debug2(2, "Writing trailer text chunk %d, type %d\n", i, - info_ptr->text[i].compression); - /* an internationalized chunk? */ - if (info_ptr->text[i].compression > 0) - { -#if defined(PNG_WRITE_iTXt_SUPPORTED) - /* write international chunk */ - png_write_iTXt(png_ptr, - info_ptr->text[i].compression, - info_ptr->text[i].key, - info_ptr->text[i].lang, - info_ptr->text[i].lang_key, - info_ptr->text[i].text); -#else - png_warning(png_ptr, "Unable to write international text"); -#endif - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; - } - else if (info_ptr->text[i].compression >= PNG_TEXT_COMPRESSION_zTXt) - { -#if defined(PNG_WRITE_zTXt_SUPPORTED) - /* write compressed chunk */ - png_write_zTXt(png_ptr, info_ptr->text[i].key, - info_ptr->text[i].text, 0, - info_ptr->text[i].compression); -#else - png_warning(png_ptr, "Unable to write compressed text"); -#endif - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR; - } - else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE) - { -#if defined(PNG_WRITE_tEXt_SUPPORTED) - /* write uncompressed chunk */ - png_write_tEXt(png_ptr, info_ptr->text[i].key, - info_ptr->text[i].text, 0); -#else - png_warning(png_ptr, "Unable to write uncompressed text"); -#endif - - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; - } - } -#endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) - if (info_ptr->unknown_chunks_num) - { - png_unknown_chunk *up; - - png_debug(5, "writing extra chunks\n"); - - for (up = info_ptr->unknown_chunks; - up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num; - up++) - { - int keep=png_handle_as_unknown(png_ptr, up->name); - if (keep != PNG_HANDLE_CHUNK_NEVER && - up->location && (up->location & PNG_AFTER_IDAT) && - ((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS || - (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS))) - { - png_write_chunk(png_ptr, up->name, up->data, up->size); - } - } - } -#endif - } - - png_ptr->mode |= PNG_AFTER_IDAT; - - /* write end of PNG file */ - png_write_IEND(png_ptr); -#if 0 -/* This flush, added in libpng-1.0.8, causes some applications to crash - because they do not set png_ptr->output_flush_fn */ - png_flush(png_ptr); -#endif -} - -#if defined(PNG_WRITE_tIME_SUPPORTED) -#if !defined(_WIN32_WCE) -/* "time.h" functions are not supported on WindowsCE */ -void PNGAPI -png_convert_from_struct_tm(png_timep ptime, struct tm FAR * ttime) -{ - png_debug(1, "in png_convert_from_struct_tm\n"); - ptime->year = (png_uint_16)(1900 + ttime->tm_year); - ptime->month = (png_byte)(ttime->tm_mon + 1); - ptime->day = (png_byte)ttime->tm_mday; - ptime->hour = (png_byte)ttime->tm_hour; - ptime->minute = (png_byte)ttime->tm_min; - ptime->second = (png_byte)ttime->tm_sec; -} - -void PNGAPI -png_convert_from_time_t(png_timep ptime, time_t ttime) -{ - struct tm *tbuf; - - png_debug(1, "in png_convert_from_time_t\n"); - tbuf = gmtime(&ttime); - png_convert_from_struct_tm(ptime, tbuf); -} -#endif -#endif - -/* Initialize png_ptr structure, and allocate any memory needed */ -png_structp PNGAPI -png_create_write_struct(png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn) -{ -#ifdef PNG_USER_MEM_SUPPORTED - return (png_create_write_struct_2(user_png_ver, error_ptr, error_fn, - warn_fn, png_voidp_NULL, png_malloc_ptr_NULL, png_free_ptr_NULL)); -} - -/* Alternate initialize png_ptr structure, and allocate any memory needed */ -png_structp PNGAPI -png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn) -{ -#endif /* PNG_USER_MEM_SUPPORTED */ - png_structp png_ptr; -#ifdef PNG_SETJMP_SUPPORTED -#ifdef USE_FAR_KEYWORD - jmp_buf jmpbuf; -#endif -#endif - int i; - png_debug(1, "in png_create_write_struct\n"); -#ifdef PNG_USER_MEM_SUPPORTED - png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG, - (png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr); -#else - png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); -#endif /* PNG_USER_MEM_SUPPORTED */ - if (png_ptr == NULL) - return (NULL); - -#if !defined(PNG_1_0_X) -#ifdef PNG_ASSEMBLER_CODE_SUPPORTED -#ifdef PNG_MMX_CODE_SUPPORTED - png_init_mmx_flags(png_ptr); /* 1.2.0 addition */ -#endif -#endif -#endif /* PNG_1_0_X */ - - /* added at libpng-1.2.6 */ -#ifdef PNG_SET_USER_LIMITS_SUPPORTED - png_ptr->user_width_max=PNG_USER_WIDTH_MAX; - png_ptr->user_height_max=PNG_USER_HEIGHT_MAX; -#endif - -#ifdef PNG_SETJMP_SUPPORTED -#ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) -#else - if (setjmp(png_ptr->jmpbuf)) -#endif - { - png_free(png_ptr, png_ptr->zbuf); - png_ptr->zbuf=NULL; - png_destroy_struct(png_ptr); - return (NULL); - } -#ifdef USE_FAR_KEYWORD - png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf)); -#endif -#endif - -#ifdef PNG_USER_MEM_SUPPORTED - png_set_mem_fn(png_ptr, mem_ptr, malloc_fn, free_fn); -#endif /* PNG_USER_MEM_SUPPORTED */ - png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn); - - i=0; - do - { - if(user_png_ver[i] != png_libpng_ver[i]) - png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; - } while (png_libpng_ver[i++]); - - if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) - { - /* Libpng 0.90 and later are binary incompatible with libpng 0.89, so - * we must recompile any applications that use any older library version. - * For versions after libpng 1.0, we will be compatible, so we need - * only check the first digit. - */ - if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] || - (user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) || - (user_png_ver[0] == '0' && user_png_ver[2] < '9')) - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char msg[80]; - if (user_png_ver) - { - sprintf(msg, "Application was compiled with png.h from libpng-%.20s", - user_png_ver); - png_warning(png_ptr, msg); - } - sprintf(msg, "Application is running with png.c from libpng-%.20s", - png_libpng_ver); - png_warning(png_ptr, msg); -#endif -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "Incompatible libpng version in application and library"); - } - } - - /* initialize zbuf - compression buffer */ - png_ptr->zbuf_size = PNG_ZBUF_SIZE; - png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, - (png_uint_32)png_ptr->zbuf_size); - - png_set_write_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL, - png_flush_ptr_NULL); - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - png_set_filter_heuristics(png_ptr, PNG_FILTER_HEURISTIC_DEFAULT, - 1, png_doublep_NULL, png_doublep_NULL); -#endif - -#ifdef PNG_SETJMP_SUPPORTED -/* Applications that neglect to set up their own setjmp() and then encounter - a png_error() will longjmp here. Since the jmpbuf is then meaningless we - abort instead of returning. */ -#ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) - PNG_ABORT(); - png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf)); -#else - if (setjmp(png_ptr->jmpbuf)) - PNG_ABORT(); -#endif -#endif - return (png_ptr); -} - -/* Initialize png_ptr structure, and allocate any memory needed */ -#if defined(PNG_1_0_X) || defined(PNG_1_2_X) -/* Deprecated. */ -#undef png_write_init -void PNGAPI -png_write_init(png_structp png_ptr) -{ - /* We only come here via pre-1.0.7-compiled applications */ - png_write_init_2(png_ptr, "1.0.6 or earlier", 0, 0); -} - -void PNGAPI -png_write_init_2(png_structp png_ptr, png_const_charp user_png_ver, - png_size_t png_struct_size, png_size_t png_info_size) -{ - /* We only come here via pre-1.0.12-compiled applications */ - if(png_ptr == NULL) return; -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - if(png_sizeof(png_struct) > png_struct_size || - png_sizeof(png_info) > png_info_size) - { - char msg[80]; - png_ptr->warning_fn=NULL; - if (user_png_ver) - { - sprintf(msg, "Application was compiled with png.h from libpng-%.20s", - user_png_ver); - png_warning(png_ptr, msg); - } - sprintf(msg, "Application is running with png.c from libpng-%.20s", - png_libpng_ver); - png_warning(png_ptr, msg); - } -#endif - if(png_sizeof(png_struct) > png_struct_size) - { - png_ptr->error_fn=NULL; -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "The png struct allocated by the application for writing is too small."); - } - if(png_sizeof(png_info) > png_info_size) - { - png_ptr->error_fn=NULL; -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "The info struct allocated by the application for writing is too small."); - } - png_write_init_3(&png_ptr, user_png_ver, png_struct_size); -} -#endif /* PNG_1_0_X || PNG_1_2_X */ - - -void PNGAPI -png_write_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, - png_size_t png_struct_size) -{ - png_structp png_ptr=*ptr_ptr; -#ifdef PNG_SETJMP_SUPPORTED - jmp_buf tmp_jmp; /* to save current jump buffer */ -#endif - - int i = 0; - - if (png_ptr == NULL) - return; - - do - { - if (user_png_ver[i] != png_libpng_ver[i]) - { -#ifdef PNG_LEGACY_SUPPORTED - png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; -#else - png_ptr->warning_fn=NULL; - png_warning(png_ptr, - "Application uses deprecated png_write_init() and should be recompiled."); - break; -#endif - } - } while (png_libpng_ver[i++]); - - png_debug(1, "in png_write_init_3\n"); - -#ifdef PNG_SETJMP_SUPPORTED - /* save jump buffer and error functions */ - png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf)); -#endif - - if (png_sizeof(png_struct) > png_struct_size) - { - png_destroy_struct(png_ptr); - png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); - *ptr_ptr = png_ptr; - } - - /* reset all variables to 0 */ - png_memset(png_ptr, 0, png_sizeof (png_struct)); - - /* added at libpng-1.2.6 */ -#ifdef PNG_SET_USER_LIMITS_SUPPORTED - png_ptr->user_width_max=PNG_USER_WIDTH_MAX; - png_ptr->user_height_max=PNG_USER_HEIGHT_MAX; -#endif - -#if !defined(PNG_1_0_X) -#ifdef PNG_ASSEMBLER_CODE_SUPPORTED -#ifdef PNG_MMX_CODE_SUPPORTED - png_init_mmx_flags(png_ptr); /* 1.2.0 addition */ -#endif -#endif -#endif /* PNG_1_0_X */ - -#ifdef PNG_SETJMP_SUPPORTED - /* restore jump buffer */ - png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf)); -#endif - - png_set_write_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL, - png_flush_ptr_NULL); - - /* initialize zbuf - compression buffer */ - png_ptr->zbuf_size = PNG_ZBUF_SIZE; - png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, - (png_uint_32)png_ptr->zbuf_size); - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - png_set_filter_heuristics(png_ptr, PNG_FILTER_HEURISTIC_DEFAULT, - 1, png_doublep_NULL, png_doublep_NULL); -#endif -} - -/* Write a few rows of image data. If the image is interlaced, - * either you will have to write the 7 sub images, or, if you - * have called png_set_interlace_handling(), you will have to - * "write" the image seven times. - */ -void PNGAPI -png_write_rows(png_structp png_ptr, png_bytepp row, - png_uint_32 num_rows) -{ - png_uint_32 i; /* row counter */ - png_bytepp rp; /* row pointer */ - - png_debug(1, "in png_write_rows\n"); - - if (png_ptr == NULL) - return; - - /* loop through the rows */ - for (i = 0, rp = row; i < num_rows; i++, rp++) - { - png_write_row(png_ptr, *rp); - } -} - -/* Write the image. You only need to call this function once, even - * if you are writing an interlaced image. - */ -void PNGAPI -png_write_image(png_structp png_ptr, png_bytepp image) -{ - png_uint_32 i; /* row index */ - int pass, num_pass; /* pass variables */ - png_bytepp rp; /* points to current row */ - - if (png_ptr == NULL) - return; - - png_debug(1, "in png_write_image\n"); -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) - /* intialize interlace handling. If image is not interlaced, - this will set pass to 1 */ - num_pass = png_set_interlace_handling(png_ptr); -#else - num_pass = 1; -#endif - /* loop through passes */ - for (pass = 0; pass < num_pass; pass++) - { - /* loop through image */ - for (i = 0, rp = image; i < png_ptr->height; i++, rp++) - { - png_write_row(png_ptr, *rp); - } - } -} - -/* called by user to write a row of image data */ -void PNGAPI -png_write_row(png_structp png_ptr, png_bytep row) -{ - if (png_ptr == NULL) - return; - png_debug2(1, "in png_write_row (row %ld, pass %d)\n", - png_ptr->row_number, png_ptr->pass); - - /* initialize transformations and other stuff if first time */ - if (png_ptr->row_number == 0 && png_ptr->pass == 0) - { - /* make sure we wrote the header info */ - if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE)) - png_error(png_ptr, - "png_write_info was never called before png_write_row."); - - /* check for transforms that have been set but were defined out */ -#if !defined(PNG_WRITE_INVERT_SUPPORTED) && defined(PNG_READ_INVERT_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_MONO) - png_warning(png_ptr, "PNG_WRITE_INVERT_SUPPORTED is not defined."); -#endif -#if !defined(PNG_WRITE_FILLER_SUPPORTED) && defined(PNG_READ_FILLER_SUPPORTED) - if (png_ptr->transformations & PNG_FILLER) - png_warning(png_ptr, "PNG_WRITE_FILLER_SUPPORTED is not defined."); -#endif -#if !defined(PNG_WRITE_PACKSWAP_SUPPORTED) && defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - png_warning(png_ptr, "PNG_WRITE_PACKSWAP_SUPPORTED is not defined."); -#endif -#if !defined(PNG_WRITE_PACK_SUPPORTED) && defined(PNG_READ_PACK_SUPPORTED) - if (png_ptr->transformations & PNG_PACK) - png_warning(png_ptr, "PNG_WRITE_PACK_SUPPORTED is not defined."); -#endif -#if !defined(PNG_WRITE_SHIFT_SUPPORTED) && defined(PNG_READ_SHIFT_SUPPORTED) - if (png_ptr->transformations & PNG_SHIFT) - png_warning(png_ptr, "PNG_WRITE_SHIFT_SUPPORTED is not defined."); -#endif -#if !defined(PNG_WRITE_BGR_SUPPORTED) && defined(PNG_READ_BGR_SUPPORTED) - if (png_ptr->transformations & PNG_BGR) - png_warning(png_ptr, "PNG_WRITE_BGR_SUPPORTED is not defined."); -#endif -#if !defined(PNG_WRITE_SWAP_SUPPORTED) && defined(PNG_READ_SWAP_SUPPORTED) - if (png_ptr->transformations & PNG_SWAP_BYTES) - png_warning(png_ptr, "PNG_WRITE_SWAP_SUPPORTED is not defined."); -#endif - - png_write_start_row(png_ptr); - } - -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) - /* if interlaced and not interested in row, return */ - if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) - { - switch (png_ptr->pass) - { - case 0: - if (png_ptr->row_number & 0x07) - { - png_write_finish_row(png_ptr); - return; - } - break; - case 1: - if ((png_ptr->row_number & 0x07) || png_ptr->width < 5) - { - png_write_finish_row(png_ptr); - return; - } - break; - case 2: - if ((png_ptr->row_number & 0x07) != 4) - { - png_write_finish_row(png_ptr); - return; - } - break; - case 3: - if ((png_ptr->row_number & 0x03) || png_ptr->width < 3) - { - png_write_finish_row(png_ptr); - return; - } - break; - case 4: - if ((png_ptr->row_number & 0x03) != 2) - { - png_write_finish_row(png_ptr); - return; - } - break; - case 5: - if ((png_ptr->row_number & 0x01) || png_ptr->width < 2) - { - png_write_finish_row(png_ptr); - return; - } - break; - case 6: - if (!(png_ptr->row_number & 0x01)) - { - png_write_finish_row(png_ptr); - return; - } - break; - } - } -#endif - - /* set up row info for transformations */ - png_ptr->row_info.color_type = png_ptr->color_type; - png_ptr->row_info.width = png_ptr->usr_width; - png_ptr->row_info.channels = png_ptr->usr_channels; - png_ptr->row_info.bit_depth = png_ptr->usr_bit_depth; - png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth * - png_ptr->row_info.channels); - - png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth, - png_ptr->row_info.width); - - png_debug1(3, "row_info->color_type = %d\n", png_ptr->row_info.color_type); - png_debug1(3, "row_info->width = %lu\n", png_ptr->row_info.width); - png_debug1(3, "row_info->channels = %d\n", png_ptr->row_info.channels); - png_debug1(3, "row_info->bit_depth = %d\n", png_ptr->row_info.bit_depth); - png_debug1(3, "row_info->pixel_depth = %d\n", png_ptr->row_info.pixel_depth); - png_debug1(3, "row_info->rowbytes = %lu\n", png_ptr->row_info.rowbytes); - - /* Copy user's row into buffer, leaving room for filter byte. */ - png_memcpy_check(png_ptr, png_ptr->row_buf + 1, row, - png_ptr->row_info.rowbytes); - -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) - /* handle interlacing */ - if (png_ptr->interlaced && png_ptr->pass < 6 && - (png_ptr->transformations & PNG_INTERLACE)) - { - png_do_write_interlace(&(png_ptr->row_info), - png_ptr->row_buf + 1, png_ptr->pass); - /* this should always get caught above, but still ... */ - if (!(png_ptr->row_info.width)) - { - png_write_finish_row(png_ptr); - return; - } - } -#endif - - /* handle other transformations */ - if (png_ptr->transformations) - png_do_write_transformations(png_ptr); - -#if defined(PNG_MNG_FEATURES_SUPPORTED) - /* Write filter_method 64 (intrapixel differencing) only if - * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and - * 2. Libpng did not write a PNG signature (this filter_method is only - * used in PNG datastreams that are embedded in MNG datastreams) and - * 3. The application called png_permit_mng_features with a mask that - * included PNG_FLAG_MNG_FILTER_64 and - * 4. The filter_method is 64 and - * 5. The color_type is RGB or RGBA - */ - if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING)) - { - /* Intrapixel differencing */ - png_do_write_intrapixel(&(png_ptr->row_info), png_ptr->row_buf + 1); - } -#endif - - /* Find a filter if necessary, filter the row and write it out. */ - png_write_find_filter(png_ptr, &(png_ptr->row_info)); - - if (png_ptr->write_row_fn != NULL) - (*(png_ptr->write_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass); -} - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -/* Set the automatic flush interval or 0 to turn flushing off */ -void PNGAPI -png_set_flush(png_structp png_ptr, int nrows) -{ - png_debug(1, "in png_set_flush\n"); - if (png_ptr == NULL) - return; - png_ptr->flush_dist = (nrows < 0 ? 0 : nrows); -} - -/* flush the current output buffers now */ -void PNGAPI -png_write_flush(png_structp png_ptr) -{ - int wrote_IDAT; - - png_debug(1, "in png_write_flush\n"); - if (png_ptr == NULL) - return; - /* We have already written out all of the data */ - if (png_ptr->row_number >= png_ptr->num_rows) - return; - - do - { - int ret; - - /* compress the data */ - ret = deflate(&png_ptr->zstream, Z_SYNC_FLUSH); - wrote_IDAT = 0; - - /* check for compression errors */ - if (ret != Z_OK) - { - if (png_ptr->zstream.msg != NULL) - png_error(png_ptr, png_ptr->zstream.msg); - else - png_error(png_ptr, "zlib error"); - } - - if (!(png_ptr->zstream.avail_out)) - { - /* write the IDAT and reset the zlib output buffer */ - png_write_IDAT(png_ptr, png_ptr->zbuf, - png_ptr->zbuf_size); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - wrote_IDAT = 1; - } - } while(wrote_IDAT == 1); - - /* If there is any data left to be output, write it into a new IDAT */ - if (png_ptr->zbuf_size != png_ptr->zstream.avail_out) - { - /* write the IDAT and reset the zlib output buffer */ - png_write_IDAT(png_ptr, png_ptr->zbuf, - png_ptr->zbuf_size - png_ptr->zstream.avail_out); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - } - png_ptr->flush_rows = 0; - png_flush(png_ptr); -} -#endif /* PNG_WRITE_FLUSH_SUPPORTED */ - -/* free all memory used by the write */ -void PNGAPI -png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr) -{ - png_structp png_ptr = NULL; - png_infop info_ptr = NULL; -#ifdef PNG_USER_MEM_SUPPORTED - png_free_ptr free_fn = NULL; - png_voidp mem_ptr = NULL; -#endif - - png_debug(1, "in png_destroy_write_struct\n"); - if (png_ptr_ptr != NULL) - { - png_ptr = *png_ptr_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - free_fn = png_ptr->free_fn; - mem_ptr = png_ptr->mem_ptr; -#endif - } - - if (info_ptr_ptr != NULL) - info_ptr = *info_ptr_ptr; - - if (info_ptr != NULL) - { - png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1); - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - if (png_ptr->num_chunk_list) - { - png_free(png_ptr, png_ptr->chunk_list); - png_ptr->chunk_list=NULL; - png_ptr->num_chunk_list=0; - } -#endif - -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)info_ptr, (png_free_ptr)free_fn, - (png_voidp)mem_ptr); -#else - png_destroy_struct((png_voidp)info_ptr); -#endif - *info_ptr_ptr = NULL; - } - - if (png_ptr != NULL) - { - png_write_destroy(png_ptr); -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn, - (png_voidp)mem_ptr); -#else - png_destroy_struct((png_voidp)png_ptr); -#endif - *png_ptr_ptr = NULL; - } -} - - -/* Free any memory used in png_ptr struct (old method) */ -void /* PRIVATE */ -png_write_destroy(png_structp png_ptr) -{ -#ifdef PNG_SETJMP_SUPPORTED - jmp_buf tmp_jmp; /* save jump buffer */ -#endif - png_error_ptr error_fn; - png_error_ptr warning_fn; - png_voidp error_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - png_free_ptr free_fn; -#endif - - png_debug(1, "in png_write_destroy\n"); - /* free any memory zlib uses */ - deflateEnd(&png_ptr->zstream); - - /* free our memory. png_free checks NULL for us. */ - png_free(png_ptr, png_ptr->zbuf); - png_free(png_ptr, png_ptr->row_buf); - png_free(png_ptr, png_ptr->prev_row); - png_free(png_ptr, png_ptr->sub_row); - png_free(png_ptr, png_ptr->up_row); - png_free(png_ptr, png_ptr->avg_row); - png_free(png_ptr, png_ptr->paeth_row); - -#if defined(PNG_TIME_RFC1123_SUPPORTED) - png_free(png_ptr, png_ptr->time_buffer); -#endif - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - png_free(png_ptr, png_ptr->prev_filters); - png_free(png_ptr, png_ptr->filter_weights); - png_free(png_ptr, png_ptr->inv_filter_weights); - png_free(png_ptr, png_ptr->filter_costs); - png_free(png_ptr, png_ptr->inv_filter_costs); -#endif - -#ifdef PNG_SETJMP_SUPPORTED - /* reset structure */ - png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf)); -#endif - - error_fn = png_ptr->error_fn; - warning_fn = png_ptr->warning_fn; - error_ptr = png_ptr->error_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - free_fn = png_ptr->free_fn; -#endif - - png_memset(png_ptr, 0, png_sizeof (png_struct)); - - png_ptr->error_fn = error_fn; - png_ptr->warning_fn = warning_fn; - png_ptr->error_ptr = error_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - png_ptr->free_fn = free_fn; -#endif - -#ifdef PNG_SETJMP_SUPPORTED - png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf)); -#endif -} - -/* Allow the application to select one or more row filters to use. */ -void PNGAPI -png_set_filter(png_structp png_ptr, int method, int filters) -{ - png_debug(1, "in png_set_filter\n"); - if (png_ptr == NULL) - return; -#if defined(PNG_MNG_FEATURES_SUPPORTED) - if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - (method == PNG_INTRAPIXEL_DIFFERENCING)) - method = PNG_FILTER_TYPE_BASE; -#endif - if (method == PNG_FILTER_TYPE_BASE) - { - switch (filters & (PNG_ALL_FILTERS | 0x07)) - { - case 5: - case 6: - case 7: png_warning(png_ptr, "Unknown row filter for method 0"); - case PNG_FILTER_VALUE_NONE: png_ptr->do_filter=PNG_FILTER_NONE; break; - case PNG_FILTER_VALUE_SUB: png_ptr->do_filter=PNG_FILTER_SUB; break; - case PNG_FILTER_VALUE_UP: png_ptr->do_filter=PNG_FILTER_UP; break; - case PNG_FILTER_VALUE_AVG: png_ptr->do_filter=PNG_FILTER_AVG; break; - case PNG_FILTER_VALUE_PAETH: png_ptr->do_filter=PNG_FILTER_PAETH;break; - default: png_ptr->do_filter = (png_byte)filters; break; - } - - /* If we have allocated the row_buf, this means we have already started - * with the image and we should have allocated all of the filter buffers - * that have been selected. If prev_row isn't already allocated, then - * it is too late to start using the filters that need it, since we - * will be missing the data in the previous row. If an application - * wants to start and stop using particular filters during compression, - * it should start out with all of the filters, and then add and - * remove them after the start of compression. - */ - if (png_ptr->row_buf != NULL) - { - if ((png_ptr->do_filter & PNG_FILTER_SUB) && png_ptr->sub_row == NULL) - { - png_ptr->sub_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB; - } - - if ((png_ptr->do_filter & PNG_FILTER_UP) && png_ptr->up_row == NULL) - { - if (png_ptr->prev_row == NULL) - { - png_warning(png_ptr, "Can't add Up filter after starting"); - png_ptr->do_filter &= ~PNG_FILTER_UP; - } - else - { - png_ptr->up_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->up_row[0] = PNG_FILTER_VALUE_UP; - } - } - - if ((png_ptr->do_filter & PNG_FILTER_AVG) && png_ptr->avg_row == NULL) - { - if (png_ptr->prev_row == NULL) - { - png_warning(png_ptr, "Can't add Average filter after starting"); - png_ptr->do_filter &= ~PNG_FILTER_AVG; - } - else - { - png_ptr->avg_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG; - } - } - - if ((png_ptr->do_filter & PNG_FILTER_PAETH) && - png_ptr->paeth_row == NULL) - { - if (png_ptr->prev_row == NULL) - { - png_warning(png_ptr, "Can't add Paeth filter after starting"); - png_ptr->do_filter &= (png_byte)(~PNG_FILTER_PAETH); - } - else - { - png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH; - } - } - - if (png_ptr->do_filter == PNG_NO_FILTERS) - png_ptr->do_filter = PNG_FILTER_NONE; - } - } - else - png_error(png_ptr, "Unknown custom filter method"); -} - -/* This allows us to influence the way in which libpng chooses the "best" - * filter for the current scanline. While the "minimum-sum-of-absolute- - * differences metric is relatively fast and effective, there is some - * question as to whether it can be improved upon by trying to keep the - * filtered data going to zlib more consistent, hopefully resulting in - * better compression. - */ -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* GRR 970116 */ -void PNGAPI -png_set_filter_heuristics(png_structp png_ptr, int heuristic_method, - int num_weights, png_doublep filter_weights, - png_doublep filter_costs) -{ - int i; - - png_debug(1, "in png_set_filter_heuristics\n"); - if (png_ptr == NULL) - return; - if (heuristic_method >= PNG_FILTER_HEURISTIC_LAST) - { - png_warning(png_ptr, "Unknown filter heuristic method"); - return; - } - - if (heuristic_method == PNG_FILTER_HEURISTIC_DEFAULT) - { - heuristic_method = PNG_FILTER_HEURISTIC_UNWEIGHTED; - } - - if (num_weights < 0 || filter_weights == NULL || - heuristic_method == PNG_FILTER_HEURISTIC_UNWEIGHTED) - { - num_weights = 0; - } - - png_ptr->num_prev_filters = (png_byte)num_weights; - png_ptr->heuristic_method = (png_byte)heuristic_method; - - if (num_weights > 0) - { - if (png_ptr->prev_filters == NULL) - { - png_ptr->prev_filters = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(png_sizeof(png_byte) * num_weights)); - - /* To make sure that the weighting starts out fairly */ - for (i = 0; i < num_weights; i++) - { - png_ptr->prev_filters[i] = 255; - } - } - - if (png_ptr->filter_weights == NULL) - { - png_ptr->filter_weights = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(png_sizeof(png_uint_16) * num_weights)); - - png_ptr->inv_filter_weights = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(png_sizeof(png_uint_16) * num_weights)); - for (i = 0; i < num_weights; i++) - { - png_ptr->inv_filter_weights[i] = - png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR; - } - } - - for (i = 0; i < num_weights; i++) - { - if (filter_weights[i] < 0.0) - { - png_ptr->inv_filter_weights[i] = - png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR; - } - else - { - png_ptr->inv_filter_weights[i] = - (png_uint_16)((double)PNG_WEIGHT_FACTOR*filter_weights[i]+0.5); - png_ptr->filter_weights[i] = - (png_uint_16)((double)PNG_WEIGHT_FACTOR/filter_weights[i]+0.5); - } - } - } - - /* If, in the future, there are other filter methods, this would - * need to be based on png_ptr->filter. - */ - if (png_ptr->filter_costs == NULL) - { - png_ptr->filter_costs = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(png_sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST)); - - png_ptr->inv_filter_costs = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(png_sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST)); - - for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) - { - png_ptr->inv_filter_costs[i] = - png_ptr->filter_costs[i] = PNG_COST_FACTOR; - } - } - - /* Here is where we set the relative costs of the different filters. We - * should take the desired compression level into account when setting - * the costs, so that Paeth, for instance, has a high relative cost at low - * compression levels, while it has a lower relative cost at higher - * compression settings. The filter types are in order of increasing - * relative cost, so it would be possible to do this with an algorithm. - */ - for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) - { - if (filter_costs == NULL || filter_costs[i] < 0.0) - { - png_ptr->inv_filter_costs[i] = - png_ptr->filter_costs[i] = PNG_COST_FACTOR; - } - else if (filter_costs[i] >= 1.0) - { - png_ptr->inv_filter_costs[i] = - (png_uint_16)((double)PNG_COST_FACTOR / filter_costs[i] + 0.5); - png_ptr->filter_costs[i] = - (png_uint_16)((double)PNG_COST_FACTOR * filter_costs[i] + 0.5); - } - } -} -#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */ - -void PNGAPI -png_set_compression_level(png_structp png_ptr, int level) -{ - png_debug(1, "in png_set_compression_level\n"); - if (png_ptr == NULL) - return; - png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_LEVEL; - png_ptr->zlib_level = level; -} - -void PNGAPI -png_set_compression_mem_level(png_structp png_ptr, int mem_level) -{ - png_debug(1, "in png_set_compression_mem_level\n"); - if (png_ptr == NULL) - return; - png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL; - png_ptr->zlib_mem_level = mem_level; -} - -void PNGAPI -png_set_compression_strategy(png_structp png_ptr, int strategy) -{ - png_debug(1, "in png_set_compression_strategy\n"); - if (png_ptr == NULL) - return; - png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_STRATEGY; - png_ptr->zlib_strategy = strategy; -} - -void PNGAPI -png_set_compression_window_bits(png_structp png_ptr, int window_bits) -{ - if (png_ptr == NULL) - return; - if (window_bits > 15) - png_warning(png_ptr, "Only compression windows <= 32k supported by PNG"); - else if (window_bits < 8) - png_warning(png_ptr, "Only compression windows >= 256 supported by PNG"); -#ifndef WBITS_8_OK - /* avoid libpng bug with 256-byte windows */ - if (window_bits == 8) - { - png_warning(png_ptr, "Compression window is being reset to 512"); - window_bits=9; - } -#endif - png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS; - png_ptr->zlib_window_bits = window_bits; -} - -void PNGAPI -png_set_compression_method(png_structp png_ptr, int method) -{ - png_debug(1, "in png_set_compression_method\n"); - if (png_ptr == NULL) - return; - if (method != 8) - png_warning(png_ptr, "Only compression method 8 is supported by PNG"); - png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_METHOD; - png_ptr->zlib_method = method; -} - -void PNGAPI -png_set_write_status_fn(png_structp png_ptr, png_write_status_ptr write_row_fn) -{ - if (png_ptr == NULL) - return; - png_ptr->write_row_fn = write_row_fn; -} - -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) -void PNGAPI -png_set_write_user_transform_fn(png_structp png_ptr, png_user_transform_ptr - write_user_transform_fn) -{ - png_debug(1, "in png_set_write_user_transform_fn\n"); - if (png_ptr == NULL) - return; - png_ptr->transformations |= PNG_USER_TRANSFORM; - png_ptr->write_user_transform_fn = write_user_transform_fn; -} -#endif - - -#if defined(PNG_INFO_IMAGE_SUPPORTED) -void PNGAPI -png_write_png(png_structp png_ptr, png_infop info_ptr, - int transforms, voidp params) -{ - if (png_ptr == NULL || info_ptr == NULL) - return; -#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) - /* invert the alpha channel from opacity to transparency */ - if (transforms & PNG_TRANSFORM_INVERT_ALPHA) - png_set_invert_alpha(png_ptr); -#endif - - /* Write the file header information. */ - png_write_info(png_ptr, info_ptr); - - /* ------ these transformations don't touch the info structure ------- */ - -#if defined(PNG_WRITE_INVERT_SUPPORTED) - /* invert monochrome pixels */ - if (transforms & PNG_TRANSFORM_INVERT_MONO) - png_set_invert_mono(png_ptr); -#endif - -#if defined(PNG_WRITE_SHIFT_SUPPORTED) - /* Shift the pixels up to a legal bit depth and fill in - * as appropriate to correctly scale the image. - */ - if ((transforms & PNG_TRANSFORM_SHIFT) - && (info_ptr->valid & PNG_INFO_sBIT)) - png_set_shift(png_ptr, &info_ptr->sig_bit); -#endif - -#if defined(PNG_WRITE_PACK_SUPPORTED) - /* pack pixels into bytes */ - if (transforms & PNG_TRANSFORM_PACKING) - png_set_packing(png_ptr); -#endif - -#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) - /* swap location of alpha bytes from ARGB to RGBA */ - if (transforms & PNG_TRANSFORM_SWAP_ALPHA) - png_set_swap_alpha(png_ptr); -#endif - -#if defined(PNG_WRITE_FILLER_SUPPORTED) - /* Get rid of filler (OR ALPHA) bytes, pack XRGB/RGBX/ARGB/RGBA into - * RGB (4 channels -> 3 channels). The second parameter is not used. - */ - if (transforms & PNG_TRANSFORM_STRIP_FILLER) - png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); -#endif - -#if defined(PNG_WRITE_BGR_SUPPORTED) - /* flip BGR pixels to RGB */ - if (transforms & PNG_TRANSFORM_BGR) - png_set_bgr(png_ptr); -#endif - -#if defined(PNG_WRITE_SWAP_SUPPORTED) - /* swap bytes of 16-bit files to most significant byte first */ - if (transforms & PNG_TRANSFORM_SWAP_ENDIAN) - png_set_swap(png_ptr); -#endif - -#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) - /* swap bits of 1, 2, 4 bit packed pixel formats */ - if (transforms & PNG_TRANSFORM_PACKSWAP) - png_set_packswap(png_ptr); -#endif - - /* ----------------------- end of transformations ------------------- */ - - /* write the bits */ - if (info_ptr->valid & PNG_INFO_IDAT) - png_write_image(png_ptr, info_ptr->row_pointers); - - /* It is REQUIRED to call this to finish writing the rest of the file */ - png_write_end(png_ptr, info_ptr); - - if(transforms == 0 || params == NULL) - /* quiet compiler warnings */ return; -} -#endif -#endif /* PNG_WRITE_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/pngwtran.c b/irrlicht-1.6/source/Irrlicht/libpng/pngwtran.c deleted file mode 100644 index 19b29682c..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/pngwtran.c +++ /dev/null @@ -1,572 +0,0 @@ - -/* pngwtran.c - transforms the data in a row for PNG writers - * - * Last changed in libpng 1.2.9 April 14, 2006 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2006 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -#define PNG_INTERNAL -#include "png.h" -#ifdef PNG_WRITE_SUPPORTED - -/* Transform the data according to the user's wishes. The order of - * transformations is significant. - */ -void /* PRIVATE */ -png_do_write_transformations(png_structp png_ptr) -{ - png_debug(1, "in png_do_write_transformations\n"); - - if (png_ptr == NULL) - return; - -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) - if (png_ptr->transformations & PNG_USER_TRANSFORM) - if(png_ptr->write_user_transform_fn != NULL) - (*(png_ptr->write_user_transform_fn)) /* user write transform function */ - (png_ptr, /* png_ptr */ - &(png_ptr->row_info), /* row_info: */ - /* png_uint_32 width; width of row */ - /* png_uint_32 rowbytes; number of bytes in row */ - /* png_byte color_type; color type of pixels */ - /* png_byte bit_depth; bit depth of samples */ - /* png_byte channels; number of channels (1-4) */ - /* png_byte pixel_depth; bits per pixel (depth*channels) */ - png_ptr->row_buf + 1); /* start of pixel data for row */ -#endif -#if defined(PNG_WRITE_FILLER_SUPPORTED) - if (png_ptr->transformations & PNG_FILLER) - png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, - png_ptr->flags); -#endif -#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif -#if defined(PNG_WRITE_PACK_SUPPORTED) - if (png_ptr->transformations & PNG_PACK) - png_do_pack(&(png_ptr->row_info), png_ptr->row_buf + 1, - (png_uint_32)png_ptr->bit_depth); -#endif -#if defined(PNG_WRITE_SWAP_SUPPORTED) - if (png_ptr->transformations & PNG_SWAP_BYTES) - png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif -#if defined(PNG_WRITE_SHIFT_SUPPORTED) - if (png_ptr->transformations & PNG_SHIFT) - png_do_shift(&(png_ptr->row_info), png_ptr->row_buf + 1, - &(png_ptr->shift)); -#endif -#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) - if (png_ptr->transformations & PNG_SWAP_ALPHA) - png_do_write_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif -#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_ALPHA) - png_do_write_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif -#if defined(PNG_WRITE_BGR_SUPPORTED) - if (png_ptr->transformations & PNG_BGR) - png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif -#if defined(PNG_WRITE_INVERT_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_MONO) - png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif -} - -#if defined(PNG_WRITE_PACK_SUPPORTED) -/* Pack pixels into bytes. Pass the true bit depth in bit_depth. The - * row_info bit depth should be 8 (one pixel per byte). The channels - * should be 1 (this only happens on grayscale and paletted images). - */ -void /* PRIVATE */ -png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) -{ - png_debug(1, "in png_do_pack\n"); - if (row_info->bit_depth == 8 && -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - row_info->channels == 1) - { - switch ((int)bit_depth) - { - case 1: - { - png_bytep sp, dp; - int mask, v; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - sp = row; - dp = row; - mask = 0x80; - v = 0; - - for (i = 0; i < row_width; i++) - { - if (*sp != 0) - v |= mask; - sp++; - if (mask > 1) - mask >>= 1; - else - { - mask = 0x80; - *dp = (png_byte)v; - dp++; - v = 0; - } - } - if (mask != 0x80) - *dp = (png_byte)v; - break; - } - case 2: - { - png_bytep sp, dp; - int shift, v; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - sp = row; - dp = row; - shift = 6; - v = 0; - for (i = 0; i < row_width; i++) - { - png_byte value; - - value = (png_byte)(*sp & 0x03); - v |= (value << shift); - if (shift == 0) - { - shift = 6; - *dp = (png_byte)v; - dp++; - v = 0; - } - else - shift -= 2; - sp++; - } - if (shift != 6) - *dp = (png_byte)v; - break; - } - case 4: - { - png_bytep sp, dp; - int shift, v; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - sp = row; - dp = row; - shift = 4; - v = 0; - for (i = 0; i < row_width; i++) - { - png_byte value; - - value = (png_byte)(*sp & 0x0f); - v |= (value << shift); - - if (shift == 0) - { - shift = 4; - *dp = (png_byte)v; - dp++; - v = 0; - } - else - shift -= 4; - - sp++; - } - if (shift != 4) - *dp = (png_byte)v; - break; - } - } - row_info->bit_depth = (png_byte)bit_depth; - row_info->pixel_depth = (png_byte)(bit_depth * row_info->channels); - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, - row_info->width); - } -} -#endif - -#if defined(PNG_WRITE_SHIFT_SUPPORTED) -/* Shift pixel values to take advantage of whole range. Pass the - * true number of bits in bit_depth. The row should be packed - * according to row_info->bit_depth. Thus, if you had a row of - * bit depth 4, but the pixels only had values from 0 to 7, you - * would pass 3 as bit_depth, and this routine would translate the - * data to 0 to 15. - */ -void /* PRIVATE */ -png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth) -{ - png_debug(1, "in png_do_shift\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL && -#else - if ( -#endif - row_info->color_type != PNG_COLOR_TYPE_PALETTE) - { - int shift_start[4], shift_dec[4]; - int channels = 0; - - if (row_info->color_type & PNG_COLOR_MASK_COLOR) - { - shift_start[channels] = row_info->bit_depth - bit_depth->red; - shift_dec[channels] = bit_depth->red; - channels++; - shift_start[channels] = row_info->bit_depth - bit_depth->green; - shift_dec[channels] = bit_depth->green; - channels++; - shift_start[channels] = row_info->bit_depth - bit_depth->blue; - shift_dec[channels] = bit_depth->blue; - channels++; - } - else - { - shift_start[channels] = row_info->bit_depth - bit_depth->gray; - shift_dec[channels] = bit_depth->gray; - channels++; - } - if (row_info->color_type & PNG_COLOR_MASK_ALPHA) - { - shift_start[channels] = row_info->bit_depth - bit_depth->alpha; - shift_dec[channels] = bit_depth->alpha; - channels++; - } - - /* with low row depths, could only be grayscale, so one channel */ - if (row_info->bit_depth < 8) - { - png_bytep bp = row; - png_uint_32 i; - png_byte mask; - png_uint_32 row_bytes = row_info->rowbytes; - - if (bit_depth->gray == 1 && row_info->bit_depth == 2) - mask = 0x55; - else if (row_info->bit_depth == 4 && bit_depth->gray == 3) - mask = 0x11; - else - mask = 0xff; - - for (i = 0; i < row_bytes; i++, bp++) - { - png_uint_16 v; - int j; - - v = *bp; - *bp = 0; - for (j = shift_start[0]; j > -shift_dec[0]; j -= shift_dec[0]) - { - if (j > 0) - *bp |= (png_byte)((v << j) & 0xff); - else - *bp |= (png_byte)((v >> (-j)) & mask); - } - } - } - else if (row_info->bit_depth == 8) - { - png_bytep bp = row; - png_uint_32 i; - png_uint_32 istop = channels * row_info->width; - - for (i = 0; i < istop; i++, bp++) - { - - png_uint_16 v; - int j; - int c = (int)(i%channels); - - v = *bp; - *bp = 0; - for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c]) - { - if (j > 0) - *bp |= (png_byte)((v << j) & 0xff); - else - *bp |= (png_byte)((v >> (-j)) & 0xff); - } - } - } - else - { - png_bytep bp; - png_uint_32 i; - png_uint_32 istop = channels * row_info->width; - - for (bp = row, i = 0; i < istop; i++) - { - int c = (int)(i%channels); - png_uint_16 value, v; - int j; - - v = (png_uint_16)(((png_uint_16)(*bp) << 8) + *(bp + 1)); - value = 0; - for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c]) - { - if (j > 0) - value |= (png_uint_16)((v << j) & (png_uint_16)0xffff); - else - value |= (png_uint_16)((v >> (-j)) & (png_uint_16)0xffff); - } - *bp++ = (png_byte)(value >> 8); - *bp++ = (png_byte)(value & 0xff); - } - } - } -} -#endif - -#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) -void /* PRIVATE */ -png_do_write_swap_alpha(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_write_swap_alpha\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif - { - if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - /* This converts from ARGB to RGBA */ - if (row_info->bit_depth == 8) - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - for (i = 0, sp = dp = row; i < row_width; i++) - { - png_byte save = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = save; - } - } - /* This converts from AARRGGBB to RRGGBBAA */ - else - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - png_byte save[2]; - save[0] = *(sp++); - save[1] = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = save[0]; - *(dp++) = save[1]; - } - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - { - /* This converts from AG to GA */ - if (row_info->bit_depth == 8) - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - png_byte save = *(sp++); - *(dp++) = *(sp++); - *(dp++) = save; - } - } - /* This converts from AAGG to GGAA */ - else - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - png_byte save[2]; - save[0] = *(sp++); - save[1] = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = save[0]; - *(dp++) = save[1]; - } - } - } - } -} -#endif - -#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) -void /* PRIVATE */ -png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_write_invert_alpha\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif - { - if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - /* This inverts the alpha channel in RGBA */ - if (row_info->bit_depth == 8) - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - for (i = 0, sp = dp = row; i < row_width; i++) - { - /* does nothing - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - */ - sp+=3; dp = sp; - *(dp++) = (png_byte)(255 - *(sp++)); - } - } - /* This inverts the alpha channel in RRGGBBAA */ - else - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - /* does nothing - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - */ - sp+=6; dp = sp; - *(dp++) = (png_byte)(255 - *(sp++)); - *(dp++) = (png_byte)(255 - *(sp++)); - } - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - { - /* This inverts the alpha channel in GA */ - if (row_info->bit_depth == 8) - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - *(dp++) = *(sp++); - *(dp++) = (png_byte)(255 - *(sp++)); - } - } - /* This inverts the alpha channel in GGAA */ - else - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - /* does nothing - *(dp++) = *(sp++); - *(dp++) = *(sp++); - */ - sp+=2; dp = sp; - *(dp++) = (png_byte)(255 - *(sp++)); - *(dp++) = (png_byte)(255 - *(sp++)); - } - } - } - } -} -#endif - -#if defined(PNG_MNG_FEATURES_SUPPORTED) -/* undoes intrapixel differencing */ -void /* PRIVATE */ -png_do_write_intrapixel(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_write_intrapixel\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - (row_info->color_type & PNG_COLOR_MASK_COLOR)) - { - int bytes_per_pixel; - png_uint_32 row_width = row_info->width; - if (row_info->bit_depth == 8) - { - png_bytep rp; - png_uint_32 i; - - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - bytes_per_pixel = 3; - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - bytes_per_pixel = 4; - else - return; - - for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) - { - *(rp) = (png_byte)((*rp - *(rp+1))&0xff); - *(rp+2) = (png_byte)((*(rp+2) - *(rp+1))&0xff); - } - } - else if (row_info->bit_depth == 16) - { - png_bytep rp; - png_uint_32 i; - - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - bytes_per_pixel = 6; - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - bytes_per_pixel = 8; - else - return; - - for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) - { - png_uint_32 s0 = (*(rp ) << 8) | *(rp+1); - png_uint_32 s1 = (*(rp+2) << 8) | *(rp+3); - png_uint_32 s2 = (*(rp+4) << 8) | *(rp+5); - png_uint_32 red = (png_uint_32)((s0-s1) & 0xffffL); - png_uint_32 blue = (png_uint_32)((s2-s1) & 0xffffL); - *(rp ) = (png_byte)((red >> 8) & 0xff); - *(rp+1) = (png_byte)(red & 0xff); - *(rp+4) = (png_byte)((blue >> 8) & 0xff); - *(rp+5) = (png_byte)(blue & 0xff); - } - } - } -} -#endif /* PNG_MNG_FEATURES_SUPPORTED */ -#endif /* PNG_WRITE_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/pngwutil.c b/irrlicht-1.6/source/Irrlicht/libpng/pngwutil.c deleted file mode 100644 index 4e5b75be5..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/pngwutil.c +++ /dev/null @@ -1,2778 +0,0 @@ - -/* pngwutil.c - utilities to write a PNG file - * - * Last changed in libpng 1.2.15 January 5, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -#define PNG_INTERNAL -#include "png.h" -#ifdef PNG_WRITE_SUPPORTED - -/* Place a 32-bit number into a buffer in PNG byte order. We work - * with unsigned numbers for convenience, although one supported - * ancillary chunk uses signed (two's complement) numbers. - */ -void PNGAPI -png_save_uint_32(png_bytep buf, png_uint_32 i) -{ - buf[0] = (png_byte)((i >> 24) & 0xff); - buf[1] = (png_byte)((i >> 16) & 0xff); - buf[2] = (png_byte)((i >> 8) & 0xff); - buf[3] = (png_byte)(i & 0xff); -} - -/* The png_save_int_32 function assumes integers are stored in two's - * complement format. If this isn't the case, then this routine needs to - * be modified to write data in two's complement format. - */ -void PNGAPI -png_save_int_32(png_bytep buf, png_int_32 i) -{ - buf[0] = (png_byte)((i >> 24) & 0xff); - buf[1] = (png_byte)((i >> 16) & 0xff); - buf[2] = (png_byte)((i >> 8) & 0xff); - buf[3] = (png_byte)(i & 0xff); -} - -/* Place a 16-bit number into a buffer in PNG byte order. - * The parameter is declared unsigned int, not png_uint_16, - * just to avoid potential problems on pre-ANSI C compilers. - */ -void PNGAPI -png_save_uint_16(png_bytep buf, unsigned int i) -{ - buf[0] = (png_byte)((i >> 8) & 0xff); - buf[1] = (png_byte)(i & 0xff); -} - -/* Write a PNG chunk all at once. The type is an array of ASCII characters - * representing the chunk name. The array must be at least 4 bytes in - * length, and does not need to be null terminated. To be safe, pass the - * pre-defined chunk names here, and if you need a new one, define it - * where the others are defined. The length is the length of the data. - * All the data must be present. If that is not possible, use the - * png_write_chunk_start(), png_write_chunk_data(), and png_write_chunk_end() - * functions instead. - */ -void PNGAPI -png_write_chunk(png_structp png_ptr, png_bytep chunk_name, - png_bytep data, png_size_t length) -{ - if(png_ptr == NULL) return; - png_write_chunk_start(png_ptr, chunk_name, (png_uint_32)length); - png_write_chunk_data(png_ptr, data, length); - png_write_chunk_end(png_ptr); -} - -/* Write the start of a PNG chunk. The type is the chunk type. - * The total_length is the sum of the lengths of all the data you will be - * passing in png_write_chunk_data(). - */ -void PNGAPI -png_write_chunk_start(png_structp png_ptr, png_bytep chunk_name, - png_uint_32 length) -{ - png_byte buf[4]; - png_debug2(0, "Writing %s chunk (%lu bytes)\n", chunk_name, length); - if(png_ptr == NULL) return; - - /* write the length */ - png_save_uint_32(buf, length); - png_write_data(png_ptr, buf, (png_size_t)4); - - /* write the chunk name */ - png_write_data(png_ptr, chunk_name, (png_size_t)4); - /* reset the crc and run it over the chunk name */ - png_reset_crc(png_ptr); - png_calculate_crc(png_ptr, chunk_name, (png_size_t)4); -} - -/* Write the data of a PNG chunk started with png_write_chunk_start(). - * Note that multiple calls to this function are allowed, and that the - * sum of the lengths from these calls *must* add up to the total_length - * given to png_write_chunk_start(). - */ -void PNGAPI -png_write_chunk_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - /* write the data, and run the CRC over it */ - if(png_ptr == NULL) return; - if (data != NULL && length > 0) - { - png_calculate_crc(png_ptr, data, length); - png_write_data(png_ptr, data, length); - } -} - -/* Finish a chunk started with png_write_chunk_start(). */ -void PNGAPI -png_write_chunk_end(png_structp png_ptr) -{ - png_byte buf[4]; - - if(png_ptr == NULL) return; - - /* write the crc */ - png_save_uint_32(buf, png_ptr->crc); - - png_write_data(png_ptr, buf, (png_size_t)4); -} - -/* Simple function to write the signature. If we have already written - * the magic bytes of the signature, or more likely, the PNG stream is - * being embedded into another stream and doesn't need its own signature, - * we should call png_set_sig_bytes() to tell libpng how many of the - * bytes have already been written. - */ -void /* PRIVATE */ -png_write_sig(png_structp png_ptr) -{ - png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10}; - /* write the rest of the 8 byte signature */ - png_write_data(png_ptr, &png_signature[png_ptr->sig_bytes], - (png_size_t)8 - png_ptr->sig_bytes); - if(png_ptr->sig_bytes < 3) - png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE; -} - -#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_iCCP_SUPPORTED) -/* - * This pair of functions encapsulates the operation of (a) compressing a - * text string, and (b) issuing it later as a series of chunk data writes. - * The compression_state structure is shared context for these functions - * set up by the caller in order to make the whole mess thread-safe. - */ - -typedef struct -{ - char *input; /* the uncompressed input data */ - int input_len; /* its length */ - int num_output_ptr; /* number of output pointers used */ - int max_output_ptr; /* size of output_ptr */ - png_charpp output_ptr; /* array of pointers to output */ -} compression_state; - -/* compress given text into storage in the png_ptr structure */ -static int /* PRIVATE */ -png_text_compress(png_structp png_ptr, - png_charp text, png_size_t text_len, int compression, - compression_state *comp) -{ - int ret; - - comp->num_output_ptr = 0; - comp->max_output_ptr = 0; - comp->output_ptr = NULL; - comp->input = NULL; - comp->input_len = 0; - - /* we may just want to pass the text right through */ - if (compression == PNG_TEXT_COMPRESSION_NONE) - { - comp->input = text; - comp->input_len = text_len; - return((int)text_len); - } - - if (compression >= PNG_TEXT_COMPRESSION_LAST) - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char msg[50]; - sprintf(msg, "Unknown compression type %d", compression); - png_warning(png_ptr, msg); -#else - png_warning(png_ptr, "Unknown compression type"); -#endif - } - - /* We can't write the chunk until we find out how much data we have, - * which means we need to run the compressor first and save the - * output. This shouldn't be a problem, as the vast majority of - * comments should be reasonable, but we will set up an array of - * malloc'd pointers to be sure. - * - * If we knew the application was well behaved, we could simplify this - * greatly by assuming we can always malloc an output buffer large - * enough to hold the compressed text ((1001 * text_len / 1000) + 12) - * and malloc this directly. The only time this would be a bad idea is - * if we can't malloc more than 64K and we have 64K of random input - * data, or if the input string is incredibly large (although this - * wouldn't cause a failure, just a slowdown due to swapping). - */ - - /* set up the compression buffers */ - png_ptr->zstream.avail_in = (uInt)text_len; - png_ptr->zstream.next_in = (Bytef *)text; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - png_ptr->zstream.next_out = (Bytef *)png_ptr->zbuf; - - /* this is the same compression loop as in png_write_row() */ - do - { - /* compress the data */ - ret = deflate(&png_ptr->zstream, Z_NO_FLUSH); - if (ret != Z_OK) - { - /* error */ - if (png_ptr->zstream.msg != NULL) - png_error(png_ptr, png_ptr->zstream.msg); - else - png_error(png_ptr, "zlib error"); - } - /* check to see if we need more room */ - if (!(png_ptr->zstream.avail_out)) - { - /* make sure the output array has room */ - if (comp->num_output_ptr >= comp->max_output_ptr) - { - int old_max; - - old_max = comp->max_output_ptr; - comp->max_output_ptr = comp->num_output_ptr + 4; - if (comp->output_ptr != NULL) - { - png_charpp old_ptr; - - old_ptr = comp->output_ptr; - comp->output_ptr = (png_charpp)png_malloc(png_ptr, - (png_uint_32)(comp->max_output_ptr * - png_sizeof (png_charpp))); - png_memcpy(comp->output_ptr, old_ptr, old_max - * png_sizeof (png_charp)); - png_free(png_ptr, old_ptr); - } - else - comp->output_ptr = (png_charpp)png_malloc(png_ptr, - (png_uint_32)(comp->max_output_ptr * - png_sizeof (png_charp))); - } - - /* save the data */ - comp->output_ptr[comp->num_output_ptr] = (png_charp)png_malloc(png_ptr, - (png_uint_32)png_ptr->zbuf_size); - png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf, - png_ptr->zbuf_size); - comp->num_output_ptr++; - - /* and reset the buffer */ - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - png_ptr->zstream.next_out = png_ptr->zbuf; - } - /* continue until we don't have any more to compress */ - } while (png_ptr->zstream.avail_in); - - /* finish the compression */ - do - { - /* tell zlib we are finished */ - ret = deflate(&png_ptr->zstream, Z_FINISH); - - if (ret == Z_OK) - { - /* check to see if we need more room */ - if (!(png_ptr->zstream.avail_out)) - { - /* check to make sure our output array has room */ - if (comp->num_output_ptr >= comp->max_output_ptr) - { - int old_max; - - old_max = comp->max_output_ptr; - comp->max_output_ptr = comp->num_output_ptr + 4; - if (comp->output_ptr != NULL) - { - png_charpp old_ptr; - - old_ptr = comp->output_ptr; - /* This could be optimized to realloc() */ - comp->output_ptr = (png_charpp)png_malloc(png_ptr, - (png_uint_32)(comp->max_output_ptr * - png_sizeof (png_charpp))); - png_memcpy(comp->output_ptr, old_ptr, - old_max * png_sizeof (png_charp)); - png_free(png_ptr, old_ptr); - } - else - comp->output_ptr = (png_charpp)png_malloc(png_ptr, - (png_uint_32)(comp->max_output_ptr * - png_sizeof (png_charp))); - } - - /* save off the data */ - comp->output_ptr[comp->num_output_ptr] = - (png_charp)png_malloc(png_ptr, (png_uint_32)png_ptr->zbuf_size); - png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf, - png_ptr->zbuf_size); - comp->num_output_ptr++; - - /* and reset the buffer pointers */ - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - png_ptr->zstream.next_out = png_ptr->zbuf; - } - } - else if (ret != Z_STREAM_END) - { - /* we got an error */ - if (png_ptr->zstream.msg != NULL) - png_error(png_ptr, png_ptr->zstream.msg); - else - png_error(png_ptr, "zlib error"); - } - } while (ret != Z_STREAM_END); - - /* text length is number of buffers plus last buffer */ - text_len = png_ptr->zbuf_size * comp->num_output_ptr; - if (png_ptr->zstream.avail_out < png_ptr->zbuf_size) - text_len += png_ptr->zbuf_size - (png_size_t)png_ptr->zstream.avail_out; - - return((int)text_len); -} - -/* ship the compressed text out via chunk writes */ -static void /* PRIVATE */ -png_write_compressed_data_out(png_structp png_ptr, compression_state *comp) -{ - int i; - - /* handle the no-compression case */ - if (comp->input) - { - png_write_chunk_data(png_ptr, (png_bytep)comp->input, - (png_size_t)comp->input_len); - return; - } - - /* write saved output buffers, if any */ - for (i = 0; i < comp->num_output_ptr; i++) - { - png_write_chunk_data(png_ptr,(png_bytep)comp->output_ptr[i], - png_ptr->zbuf_size); - png_free(png_ptr, comp->output_ptr[i]); - comp->output_ptr[i]=NULL; - } - if (comp->max_output_ptr != 0) - png_free(png_ptr, comp->output_ptr); - comp->output_ptr=NULL; - /* write anything left in zbuf */ - if (png_ptr->zstream.avail_out < (png_uint_32)png_ptr->zbuf_size) - png_write_chunk_data(png_ptr, png_ptr->zbuf, - png_ptr->zbuf_size - png_ptr->zstream.avail_out); - - /* reset zlib for another zTXt/iTXt or image data */ - deflateReset(&png_ptr->zstream); - png_ptr->zstream.data_type = Z_BINARY; -} -#endif - -/* Write the IHDR chunk, and update the png_struct with the necessary - * information. Note that the rest of this code depends upon this - * information being correct. - */ -void /* PRIVATE */ -png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height, - int bit_depth, int color_type, int compression_type, int filter_type, - int interlace_type) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IHDR; -#endif - png_byte buf[13]; /* buffer to store the IHDR info */ - - png_debug(1, "in png_write_IHDR\n"); - /* Check that we have valid input data from the application info */ - switch (color_type) - { - case PNG_COLOR_TYPE_GRAY: - switch (bit_depth) - { - case 1: - case 2: - case 4: - case 8: - case 16: png_ptr->channels = 1; break; - default: png_error(png_ptr,"Invalid bit depth for grayscale image"); - } - break; - case PNG_COLOR_TYPE_RGB: - if (bit_depth != 8 && bit_depth != 16) - png_error(png_ptr, "Invalid bit depth for RGB image"); - png_ptr->channels = 3; - break; - case PNG_COLOR_TYPE_PALETTE: - switch (bit_depth) - { - case 1: - case 2: - case 4: - case 8: png_ptr->channels = 1; break; - default: png_error(png_ptr, "Invalid bit depth for paletted image"); - } - break; - case PNG_COLOR_TYPE_GRAY_ALPHA: - if (bit_depth != 8 && bit_depth != 16) - png_error(png_ptr, "Invalid bit depth for grayscale+alpha image"); - png_ptr->channels = 2; - break; - case PNG_COLOR_TYPE_RGB_ALPHA: - if (bit_depth != 8 && bit_depth != 16) - png_error(png_ptr, "Invalid bit depth for RGBA image"); - png_ptr->channels = 4; - break; - default: - png_error(png_ptr, "Invalid image color type specified"); - } - - if (compression_type != PNG_COMPRESSION_TYPE_BASE) - { - png_warning(png_ptr, "Invalid compression type specified"); - compression_type = PNG_COMPRESSION_TYPE_BASE; - } - - /* Write filter_method 64 (intrapixel differencing) only if - * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and - * 2. Libpng did not write a PNG signature (this filter_method is only - * used in PNG datastreams that are embedded in MNG datastreams) and - * 3. The application called png_permit_mng_features with a mask that - * included PNG_FLAG_MNG_FILTER_64 and - * 4. The filter_method is 64 and - * 5. The color_type is RGB or RGBA - */ - if ( -#if defined(PNG_MNG_FEATURES_SUPPORTED) - !((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) && - (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_RGB_ALPHA) && - (filter_type == PNG_INTRAPIXEL_DIFFERENCING)) && -#endif - filter_type != PNG_FILTER_TYPE_BASE) - { - png_warning(png_ptr, "Invalid filter type specified"); - filter_type = PNG_FILTER_TYPE_BASE; - } - -#ifdef PNG_WRITE_INTERLACING_SUPPORTED - if (interlace_type != PNG_INTERLACE_NONE && - interlace_type != PNG_INTERLACE_ADAM7) - { - png_warning(png_ptr, "Invalid interlace type specified"); - interlace_type = PNG_INTERLACE_ADAM7; - } -#else - interlace_type=PNG_INTERLACE_NONE; -#endif - - /* save off the relevent information */ - png_ptr->bit_depth = (png_byte)bit_depth; - png_ptr->color_type = (png_byte)color_type; - png_ptr->interlaced = (png_byte)interlace_type; -#if defined(PNG_MNG_FEATURES_SUPPORTED) - png_ptr->filter_type = (png_byte)filter_type; -#endif - png_ptr->compression_type = (png_byte)compression_type; - png_ptr->width = width; - png_ptr->height = height; - - png_ptr->pixel_depth = (png_byte)(bit_depth * png_ptr->channels); - png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, width); - /* set the usr info, so any transformations can modify it */ - png_ptr->usr_width = png_ptr->width; - png_ptr->usr_bit_depth = png_ptr->bit_depth; - png_ptr->usr_channels = png_ptr->channels; - - /* pack the header information into the buffer */ - png_save_uint_32(buf, width); - png_save_uint_32(buf + 4, height); - buf[8] = (png_byte)bit_depth; - buf[9] = (png_byte)color_type; - buf[10] = (png_byte)compression_type; - buf[11] = (png_byte)filter_type; - buf[12] = (png_byte)interlace_type; - - /* write the chunk */ - png_write_chunk(png_ptr, (png_bytep)png_IHDR, buf, (png_size_t)13); - - /* initialize zlib with PNG info */ - png_ptr->zstream.zalloc = png_zalloc; - png_ptr->zstream.zfree = png_zfree; - png_ptr->zstream.opaque = (voidpf)png_ptr; - if (!(png_ptr->do_filter)) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE || - png_ptr->bit_depth < 8) - png_ptr->do_filter = PNG_FILTER_NONE; - else - png_ptr->do_filter = PNG_ALL_FILTERS; - } - if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_STRATEGY)) - { - if (png_ptr->do_filter != PNG_FILTER_NONE) - png_ptr->zlib_strategy = Z_FILTERED; - else - png_ptr->zlib_strategy = Z_DEFAULT_STRATEGY; - } - if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_LEVEL)) - png_ptr->zlib_level = Z_DEFAULT_COMPRESSION; - if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL)) - png_ptr->zlib_mem_level = 8; - if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS)) - png_ptr->zlib_window_bits = 15; - if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_METHOD)) - png_ptr->zlib_method = 8; - if (deflateInit2(&png_ptr->zstream, png_ptr->zlib_level, - png_ptr->zlib_method, png_ptr->zlib_window_bits, - png_ptr->zlib_mem_level, png_ptr->zlib_strategy) != Z_OK) - png_error(png_ptr, "zlib failed to initialize compressor"); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - /* libpng is not interested in zstream.data_type */ - /* set it to a predefined value, to avoid its evaluation inside zlib */ - png_ptr->zstream.data_type = Z_BINARY; - - png_ptr->mode = PNG_HAVE_IHDR; -} - -/* write the palette. We are careful not to trust png_color to be in the - * correct order for PNG, so people can redefine it to any convenient - * structure. - */ -void /* PRIVATE */ -png_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_PLTE; -#endif - png_uint_32 i; - png_colorp pal_ptr; - png_byte buf[3]; - - png_debug(1, "in png_write_PLTE\n"); - if (( -#if defined(PNG_MNG_FEATURES_SUPPORTED) - !(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) && -#endif - num_pal == 0) || num_pal > 256) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - png_error(png_ptr, "Invalid number of colors in palette"); - } - else - { - png_warning(png_ptr, "Invalid number of colors in palette"); - return; - } - } - - if (!(png_ptr->color_type&PNG_COLOR_MASK_COLOR)) - { - png_warning(png_ptr, - "Ignoring request to write a PLTE chunk in grayscale PNG"); - return; - } - - png_ptr->num_palette = (png_uint_16)num_pal; - png_debug1(3, "num_palette = %d\n", png_ptr->num_palette); - - png_write_chunk_start(png_ptr, (png_bytep)png_PLTE, num_pal * 3); -#ifndef PNG_NO_POINTER_INDEXING - for (i = 0, pal_ptr = palette; i < num_pal; i++, pal_ptr++) - { - buf[0] = pal_ptr->red; - buf[1] = pal_ptr->green; - buf[2] = pal_ptr->blue; - png_write_chunk_data(png_ptr, buf, (png_size_t)3); - } -#else - /* This is a little slower but some buggy compilers need to do this instead */ - pal_ptr=palette; - for (i = 0; i < num_pal; i++) - { - buf[0] = pal_ptr[i].red; - buf[1] = pal_ptr[i].green; - buf[2] = pal_ptr[i].blue; - png_write_chunk_data(png_ptr, buf, (png_size_t)3); - } -#endif - png_write_chunk_end(png_ptr); - png_ptr->mode |= PNG_HAVE_PLTE; -} - -/* write an IDAT chunk */ -void /* PRIVATE */ -png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IDAT; -#endif - png_debug(1, "in png_write_IDAT\n"); - - /* Optimize the CMF field in the zlib stream. */ - /* This hack of the zlib stream is compliant to the stream specification. */ - if (!(png_ptr->mode & PNG_HAVE_IDAT) && - png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE) - { - unsigned int z_cmf = data[0]; /* zlib compression method and flags */ - if ((z_cmf & 0x0f) == 8 && (z_cmf & 0xf0) <= 0x70) - { - /* Avoid memory underflows and multiplication overflows. */ - /* The conditions below are practically always satisfied; - however, they still must be checked. */ - if (length >= 2 && - png_ptr->height < 16384 && png_ptr->width < 16384) - { - png_uint_32 uncompressed_idat_size = png_ptr->height * - ((png_ptr->width * - png_ptr->channels * png_ptr->bit_depth + 15) >> 3); - unsigned int z_cinfo = z_cmf >> 4; - unsigned int half_z_window_size = 1 << (z_cinfo + 7); - while (uncompressed_idat_size <= half_z_window_size && - half_z_window_size >= 256) - { - z_cinfo--; - half_z_window_size >>= 1; - } - z_cmf = (z_cmf & 0x0f) | (z_cinfo << 4); - if (data[0] != (png_byte)z_cmf) - { - data[0] = (png_byte)z_cmf; - data[1] &= 0xe0; - data[1] += (png_byte)(0x1f - ((z_cmf << 8) + data[1]) % 0x1f); - } - } - } - else - png_error(png_ptr, - "Invalid zlib compression method or flags in IDAT"); - } - - png_write_chunk(png_ptr, (png_bytep)png_IDAT, data, length); - png_ptr->mode |= PNG_HAVE_IDAT; -} - -/* write an IEND chunk */ -void /* PRIVATE */ -png_write_IEND(png_structp png_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IEND; -#endif - png_debug(1, "in png_write_IEND\n"); - png_write_chunk(png_ptr, (png_bytep)png_IEND, png_bytep_NULL, - (png_size_t)0); - png_ptr->mode |= PNG_HAVE_IEND; -} - -#if defined(PNG_WRITE_gAMA_SUPPORTED) -/* write a gAMA chunk */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -void /* PRIVATE */ -png_write_gAMA(png_structp png_ptr, double file_gamma) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_gAMA; -#endif - png_uint_32 igamma; - png_byte buf[4]; - - png_debug(1, "in png_write_gAMA\n"); - /* file_gamma is saved in 1/100,000ths */ - igamma = (png_uint_32)(file_gamma * 100000.0 + 0.5); - png_save_uint_32(buf, igamma); - png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4); -} -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -void /* PRIVATE */ -png_write_gAMA_fixed(png_structp png_ptr, png_fixed_point file_gamma) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_gAMA; -#endif - png_byte buf[4]; - - png_debug(1, "in png_write_gAMA\n"); - /* file_gamma is saved in 1/100,000ths */ - png_save_uint_32(buf, (png_uint_32)file_gamma); - png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4); -} -#endif -#endif - -#if defined(PNG_WRITE_sRGB_SUPPORTED) -/* write a sRGB chunk */ -void /* PRIVATE */ -png_write_sRGB(png_structp png_ptr, int srgb_intent) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_sRGB; -#endif - png_byte buf[1]; - - png_debug(1, "in png_write_sRGB\n"); - if(srgb_intent >= PNG_sRGB_INTENT_LAST) - png_warning(png_ptr, - "Invalid sRGB rendering intent specified"); - buf[0]=(png_byte)srgb_intent; - png_write_chunk(png_ptr, (png_bytep)png_sRGB, buf, (png_size_t)1); -} -#endif - -#if defined(PNG_WRITE_iCCP_SUPPORTED) -/* write an iCCP chunk */ -void /* PRIVATE */ -png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type, - png_charp profile, int profile_len) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_iCCP; -#endif - png_size_t name_len; - png_charp new_name; - compression_state comp; - int embedded_profile_len = 0; - - png_debug(1, "in png_write_iCCP\n"); - - comp.num_output_ptr = 0; - comp.max_output_ptr = 0; - comp.output_ptr = NULL; - comp.input = NULL; - comp.input_len = 0; - - if (name == NULL || (name_len = png_check_keyword(png_ptr, name, - &new_name)) == 0) - { - png_warning(png_ptr, "Empty keyword in iCCP chunk"); - return; - } - - if (compression_type != PNG_COMPRESSION_TYPE_BASE) - png_warning(png_ptr, "Unknown compression type in iCCP chunk"); - - if (profile == NULL) - profile_len = 0; - - if (profile_len > 3) - embedded_profile_len = - ((*( (png_bytep)profile ))<<24) | - ((*( (png_bytep)profile+1))<<16) | - ((*( (png_bytep)profile+2))<< 8) | - ((*( (png_bytep)profile+3)) ); - - if (profile_len < embedded_profile_len) - { - png_warning(png_ptr, - "Embedded profile length too large in iCCP chunk"); - return; - } - - if (profile_len > embedded_profile_len) - { - png_warning(png_ptr, - "Truncating profile to actual length in iCCP chunk"); - profile_len = embedded_profile_len; - } - - if (profile_len) - profile_len = png_text_compress(png_ptr, profile, (png_size_t)profile_len, - PNG_COMPRESSION_TYPE_BASE, &comp); - - /* make sure we include the NULL after the name and the compression type */ - png_write_chunk_start(png_ptr, (png_bytep)png_iCCP, - (png_uint_32)name_len+profile_len+2); - new_name[name_len+1]=0x00; - png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 2); - - if (profile_len) - png_write_compressed_data_out(png_ptr, &comp); - - png_write_chunk_end(png_ptr); - png_free(png_ptr, new_name); -} -#endif - -#if defined(PNG_WRITE_sPLT_SUPPORTED) -/* write a sPLT chunk */ -void /* PRIVATE */ -png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_sPLT; -#endif - png_size_t name_len; - png_charp new_name; - png_byte entrybuf[10]; - int entry_size = (spalette->depth == 8 ? 6 : 10); - int palette_size = entry_size * spalette->nentries; - png_sPLT_entryp ep; -#ifdef PNG_NO_POINTER_INDEXING - int i; -#endif - - png_debug(1, "in png_write_sPLT\n"); - if (spalette->name == NULL || (name_len = png_check_keyword(png_ptr, - spalette->name, &new_name))==0) - { - png_warning(png_ptr, "Empty keyword in sPLT chunk"); - return; - } - - /* make sure we include the NULL after the name */ - png_write_chunk_start(png_ptr, (png_bytep)png_sPLT, - (png_uint_32)(name_len + 2 + palette_size)); - png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 1); - png_write_chunk_data(png_ptr, (png_bytep)&spalette->depth, 1); - - /* loop through each palette entry, writing appropriately */ -#ifndef PNG_NO_POINTER_INDEXING - for (ep = spalette->entries; ep<spalette->entries+spalette->nentries; ep++) - { - if (spalette->depth == 8) - { - entrybuf[0] = (png_byte)ep->red; - entrybuf[1] = (png_byte)ep->green; - entrybuf[2] = (png_byte)ep->blue; - entrybuf[3] = (png_byte)ep->alpha; - png_save_uint_16(entrybuf + 4, ep->frequency); - } - else - { - png_save_uint_16(entrybuf + 0, ep->red); - png_save_uint_16(entrybuf + 2, ep->green); - png_save_uint_16(entrybuf + 4, ep->blue); - png_save_uint_16(entrybuf + 6, ep->alpha); - png_save_uint_16(entrybuf + 8, ep->frequency); - } - png_write_chunk_data(png_ptr, entrybuf, (png_size_t)entry_size); - } -#else - ep=spalette->entries; - for (i=0; i>spalette->nentries; i++) - { - if (spalette->depth == 8) - { - entrybuf[0] = (png_byte)ep[i].red; - entrybuf[1] = (png_byte)ep[i].green; - entrybuf[2] = (png_byte)ep[i].blue; - entrybuf[3] = (png_byte)ep[i].alpha; - png_save_uint_16(entrybuf + 4, ep[i].frequency); - } - else - { - png_save_uint_16(entrybuf + 0, ep[i].red); - png_save_uint_16(entrybuf + 2, ep[i].green); - png_save_uint_16(entrybuf + 4, ep[i].blue); - png_save_uint_16(entrybuf + 6, ep[i].alpha); - png_save_uint_16(entrybuf + 8, ep[i].frequency); - } - png_write_chunk_data(png_ptr, entrybuf, entry_size); - } -#endif - - png_write_chunk_end(png_ptr); - png_free(png_ptr, new_name); -} -#endif - -#if defined(PNG_WRITE_sBIT_SUPPORTED) -/* write the sBIT chunk */ -void /* PRIVATE */ -png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_sBIT; -#endif - png_byte buf[4]; - png_size_t size; - - png_debug(1, "in png_write_sBIT\n"); - /* make sure we don't depend upon the order of PNG_COLOR_8 */ - if (color_type & PNG_COLOR_MASK_COLOR) - { - png_byte maxbits; - - maxbits = (png_byte)(color_type==PNG_COLOR_TYPE_PALETTE ? 8 : - png_ptr->usr_bit_depth); - if (sbit->red == 0 || sbit->red > maxbits || - sbit->green == 0 || sbit->green > maxbits || - sbit->blue == 0 || sbit->blue > maxbits) - { - png_warning(png_ptr, "Invalid sBIT depth specified"); - return; - } - buf[0] = sbit->red; - buf[1] = sbit->green; - buf[2] = sbit->blue; - size = 3; - } - else - { - if (sbit->gray == 0 || sbit->gray > png_ptr->usr_bit_depth) - { - png_warning(png_ptr, "Invalid sBIT depth specified"); - return; - } - buf[0] = sbit->gray; - size = 1; - } - - if (color_type & PNG_COLOR_MASK_ALPHA) - { - if (sbit->alpha == 0 || sbit->alpha > png_ptr->usr_bit_depth) - { - png_warning(png_ptr, "Invalid sBIT depth specified"); - return; - } - buf[size++] = sbit->alpha; - } - - png_write_chunk(png_ptr, (png_bytep)png_sBIT, buf, size); -} -#endif - -#if defined(PNG_WRITE_cHRM_SUPPORTED) -/* write the cHRM chunk */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -void /* PRIVATE */ -png_write_cHRM(png_structp png_ptr, double white_x, double white_y, - double red_x, double red_y, double green_x, double green_y, - double blue_x, double blue_y) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_cHRM; -#endif - png_byte buf[32]; - png_uint_32 itemp; - - png_debug(1, "in png_write_cHRM\n"); - /* each value is saved in 1/100,000ths */ - if (white_x < 0 || white_x > 0.8 || white_y < 0 || white_y > 0.8 || - white_x + white_y > 1.0) - { - png_warning(png_ptr, "Invalid cHRM white point specified"); -#if !defined(PNG_NO_CONSOLE_IO) - fprintf(stderr,"white_x=%f, white_y=%f\n",white_x, white_y); -#endif - return; - } - itemp = (png_uint_32)(white_x * 100000.0 + 0.5); - png_save_uint_32(buf, itemp); - itemp = (png_uint_32)(white_y * 100000.0 + 0.5); - png_save_uint_32(buf + 4, itemp); - - if (red_x < 0 || red_y < 0 || red_x + red_y > 1.0) - { - png_warning(png_ptr, "Invalid cHRM red point specified"); - return; - } - itemp = (png_uint_32)(red_x * 100000.0 + 0.5); - png_save_uint_32(buf + 8, itemp); - itemp = (png_uint_32)(red_y * 100000.0 + 0.5); - png_save_uint_32(buf + 12, itemp); - - if (green_x < 0 || green_y < 0 || green_x + green_y > 1.0) - { - png_warning(png_ptr, "Invalid cHRM green point specified"); - return; - } - itemp = (png_uint_32)(green_x * 100000.0 + 0.5); - png_save_uint_32(buf + 16, itemp); - itemp = (png_uint_32)(green_y * 100000.0 + 0.5); - png_save_uint_32(buf + 20, itemp); - - if (blue_x < 0 || blue_y < 0 || blue_x + blue_y > 1.0) - { - png_warning(png_ptr, "Invalid cHRM blue point specified"); - return; - } - itemp = (png_uint_32)(blue_x * 100000.0 + 0.5); - png_save_uint_32(buf + 24, itemp); - itemp = (png_uint_32)(blue_y * 100000.0 + 0.5); - png_save_uint_32(buf + 28, itemp); - - png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32); -} -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -void /* PRIVATE */ -png_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x, - png_fixed_point white_y, png_fixed_point red_x, png_fixed_point red_y, - png_fixed_point green_x, png_fixed_point green_y, png_fixed_point blue_x, - png_fixed_point blue_y) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_cHRM; -#endif - png_byte buf[32]; - - png_debug(1, "in png_write_cHRM\n"); - /* each value is saved in 1/100,000ths */ - if (white_x > 80000L || white_y > 80000L || white_x + white_y > 100000L) - { - png_warning(png_ptr, "Invalid fixed cHRM white point specified"); -#if !defined(PNG_NO_CONSOLE_IO) - fprintf(stderr,"white_x=%ld, white_y=%ld\n",white_x, white_y); -#endif - return; - } - png_save_uint_32(buf, (png_uint_32)white_x); - png_save_uint_32(buf + 4, (png_uint_32)white_y); - - if (red_x + red_y > 100000L) - { - png_warning(png_ptr, "Invalid cHRM fixed red point specified"); - return; - } - png_save_uint_32(buf + 8, (png_uint_32)red_x); - png_save_uint_32(buf + 12, (png_uint_32)red_y); - - if (green_x + green_y > 100000L) - { - png_warning(png_ptr, "Invalid fixed cHRM green point specified"); - return; - } - png_save_uint_32(buf + 16, (png_uint_32)green_x); - png_save_uint_32(buf + 20, (png_uint_32)green_y); - - if (blue_x + blue_y > 100000L) - { - png_warning(png_ptr, "Invalid fixed cHRM blue point specified"); - return; - } - png_save_uint_32(buf + 24, (png_uint_32)blue_x); - png_save_uint_32(buf + 28, (png_uint_32)blue_y); - - png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32); -} -#endif -#endif - -#if defined(PNG_WRITE_tRNS_SUPPORTED) -/* write the tRNS chunk */ -void /* PRIVATE */ -png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran, - int num_trans, int color_type) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_tRNS; -#endif - png_byte buf[6]; - - png_debug(1, "in png_write_tRNS\n"); - if (color_type == PNG_COLOR_TYPE_PALETTE) - { - if (num_trans <= 0 || num_trans > (int)png_ptr->num_palette) - { - png_warning(png_ptr,"Invalid number of transparent colors specified"); - return; - } - /* write the chunk out as it is */ - png_write_chunk(png_ptr, (png_bytep)png_tRNS, trans, (png_size_t)num_trans); - } - else if (color_type == PNG_COLOR_TYPE_GRAY) - { - /* one 16 bit value */ - if(tran->gray >= (1 << png_ptr->bit_depth)) - { - png_warning(png_ptr, - "Ignoring attempt to write tRNS chunk out-of-range for bit_depth"); - return; - } - png_save_uint_16(buf, tran->gray); - png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)2); - } - else if (color_type == PNG_COLOR_TYPE_RGB) - { - /* three 16 bit values */ - png_save_uint_16(buf, tran->red); - png_save_uint_16(buf + 2, tran->green); - png_save_uint_16(buf + 4, tran->blue); - if(png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4])) - { - png_warning(png_ptr, - "Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8"); - return; - } - png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)6); - } - else - { - png_warning(png_ptr, "Can't write tRNS with an alpha channel"); - } -} -#endif - -#if defined(PNG_WRITE_bKGD_SUPPORTED) -/* write the background chunk */ -void /* PRIVATE */ -png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_bKGD; -#endif - png_byte buf[6]; - - png_debug(1, "in png_write_bKGD\n"); - if (color_type == PNG_COLOR_TYPE_PALETTE) - { - if ( -#if defined(PNG_MNG_FEATURES_SUPPORTED) - (png_ptr->num_palette || - (!(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE))) && -#endif - back->index > png_ptr->num_palette) - { - png_warning(png_ptr, "Invalid background palette index"); - return; - } - buf[0] = back->index; - png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)1); - } - else if (color_type & PNG_COLOR_MASK_COLOR) - { - png_save_uint_16(buf, back->red); - png_save_uint_16(buf + 2, back->green); - png_save_uint_16(buf + 4, back->blue); - if(png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4])) - { - png_warning(png_ptr, - "Ignoring attempt to write 16-bit bKGD chunk when bit_depth is 8"); - return; - } - png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)6); - } - else - { - if(back->gray >= (1 << png_ptr->bit_depth)) - { - png_warning(png_ptr, - "Ignoring attempt to write bKGD chunk out-of-range for bit_depth"); - return; - } - png_save_uint_16(buf, back->gray); - png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)2); - } -} -#endif - -#if defined(PNG_WRITE_hIST_SUPPORTED) -/* write the histogram */ -void /* PRIVATE */ -png_write_hIST(png_structp png_ptr, png_uint_16p hist, int num_hist) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_hIST; -#endif - int i; - png_byte buf[3]; - - png_debug(1, "in png_write_hIST\n"); - if (num_hist > (int)png_ptr->num_palette) - { - png_debug2(3, "num_hist = %d, num_palette = %d\n", num_hist, - png_ptr->num_palette); - png_warning(png_ptr, "Invalid number of histogram entries specified"); - return; - } - - png_write_chunk_start(png_ptr, (png_bytep)png_hIST, (png_uint_32)(num_hist * 2)); - for (i = 0; i < num_hist; i++) - { - png_save_uint_16(buf, hist[i]); - png_write_chunk_data(png_ptr, buf, (png_size_t)2); - } - png_write_chunk_end(png_ptr); -} -#endif - -#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \ - defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) -/* Check that the tEXt or zTXt keyword is valid per PNG 1.0 specification, - * and if invalid, correct the keyword rather than discarding the entire - * chunk. The PNG 1.0 specification requires keywords 1-79 characters in - * length, forbids leading or trailing whitespace, multiple internal spaces, - * and the non-break space (0x80) from ISO 8859-1. Returns keyword length. - * - * The new_key is allocated to hold the corrected keyword and must be freed - * by the calling routine. This avoids problems with trying to write to - * static keywords without having to have duplicate copies of the strings. - */ -png_size_t /* PRIVATE */ -png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key) -{ - png_size_t key_len; - png_charp kp, dp; - int kflag; - int kwarn=0; - - png_debug(1, "in png_check_keyword\n"); - *new_key = NULL; - - if (key == NULL || (key_len = png_strlen(key)) == 0) - { - png_warning(png_ptr, "zero length keyword"); - return ((png_size_t)0); - } - - png_debug1(2, "Keyword to be checked is '%s'\n", key); - - *new_key = (png_charp)png_malloc_warn(png_ptr, (png_uint_32)(key_len + 2)); - if (*new_key == NULL) - { - png_warning(png_ptr, "Out of memory while procesing keyword"); - return ((png_size_t)0); - } - - /* Replace non-printing characters with a blank and print a warning */ - for (kp = key, dp = *new_key; *kp != '\0'; kp++, dp++) - { - if (*kp < 0x20 || (*kp > 0x7E && (png_byte)*kp < 0xA1)) - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char msg[40]; - - sprintf(msg, "invalid keyword character 0x%02X", *kp); - png_warning(png_ptr, msg); -#else - png_warning(png_ptr, "invalid character in keyword"); -#endif - *dp = ' '; - } - else - { - *dp = *kp; - } - } - *dp = '\0'; - - /* Remove any trailing white space. */ - kp = *new_key + key_len - 1; - if (*kp == ' ') - { - png_warning(png_ptr, "trailing spaces removed from keyword"); - - while (*kp == ' ') - { - *(kp--) = '\0'; - key_len--; - } - } - - /* Remove any leading white space. */ - kp = *new_key; - if (*kp == ' ') - { - png_warning(png_ptr, "leading spaces removed from keyword"); - - while (*kp == ' ') - { - kp++; - key_len--; - } - } - - png_debug1(2, "Checking for multiple internal spaces in '%s'\n", kp); - - /* Remove multiple internal spaces. */ - for (kflag = 0, dp = *new_key; *kp != '\0'; kp++) - { - if (*kp == ' ' && kflag == 0) - { - *(dp++) = *kp; - kflag = 1; - } - else if (*kp == ' ') - { - key_len--; - kwarn=1; - } - else - { - *(dp++) = *kp; - kflag = 0; - } - } - *dp = '\0'; - if(kwarn) - png_warning(png_ptr, "extra interior spaces removed from keyword"); - - if (key_len == 0) - { - png_free(png_ptr, *new_key); - *new_key=NULL; - png_warning(png_ptr, "Zero length keyword"); - } - - if (key_len > 79) - { - png_warning(png_ptr, "keyword length must be 1 - 79 characters"); - new_key[79] = '\0'; - key_len = 79; - } - - return (key_len); -} -#endif - -#if defined(PNG_WRITE_tEXt_SUPPORTED) -/* write a tEXt chunk */ -void /* PRIVATE */ -png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text, - png_size_t text_len) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_tEXt; -#endif - png_size_t key_len; - png_charp new_key; - - png_debug(1, "in png_write_tEXt\n"); - if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0) - { - png_warning(png_ptr, "Empty keyword in tEXt chunk"); - return; - } - - if (text == NULL || *text == '\0') - text_len = 0; - else - text_len = png_strlen(text); - - /* make sure we include the 0 after the key */ - png_write_chunk_start(png_ptr, (png_bytep)png_tEXt, (png_uint_32)key_len+text_len+1); - /* - * We leave it to the application to meet PNG-1.0 requirements on the - * contents of the text. PNG-1.0 through PNG-1.2 discourage the use of - * any non-Latin-1 characters except for NEWLINE. ISO PNG will forbid them. - * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG. - */ - png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1); - if (text_len) - png_write_chunk_data(png_ptr, (png_bytep)text, text_len); - - png_write_chunk_end(png_ptr); - png_free(png_ptr, new_key); -} -#endif - -#if defined(PNG_WRITE_zTXt_SUPPORTED) -/* write a compressed text chunk */ -void /* PRIVATE */ -png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text, - png_size_t text_len, int compression) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_zTXt; -#endif - png_size_t key_len; - char buf[1]; - png_charp new_key; - compression_state comp; - - png_debug(1, "in png_write_zTXt\n"); - - comp.num_output_ptr = 0; - comp.max_output_ptr = 0; - comp.output_ptr = NULL; - comp.input = NULL; - comp.input_len = 0; - - if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0) - { - png_warning(png_ptr, "Empty keyword in zTXt chunk"); - return; - } - - if (text == NULL || *text == '\0' || compression==PNG_TEXT_COMPRESSION_NONE) - { - png_write_tEXt(png_ptr, new_key, text, (png_size_t)0); - png_free(png_ptr, new_key); - return; - } - - text_len = png_strlen(text); - - png_free(png_ptr, new_key); - - /* compute the compressed data; do it now for the length */ - text_len = png_text_compress(png_ptr, text, text_len, compression, - &comp); - - /* write start of chunk */ - png_write_chunk_start(png_ptr, (png_bytep)png_zTXt, (png_uint_32) - (key_len+text_len+2)); - /* write key */ - png_write_chunk_data(png_ptr, (png_bytep)key, key_len + 1); - buf[0] = (png_byte)compression; - /* write compression */ - png_write_chunk_data(png_ptr, (png_bytep)buf, (png_size_t)1); - /* write the compressed data */ - png_write_compressed_data_out(png_ptr, &comp); - - /* close the chunk */ - png_write_chunk_end(png_ptr); -} -#endif - -#if defined(PNG_WRITE_iTXt_SUPPORTED) -/* write an iTXt chunk */ -void /* PRIVATE */ -png_write_iTXt(png_structp png_ptr, int compression, png_charp key, - png_charp lang, png_charp lang_key, png_charp text) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_iTXt; -#endif - png_size_t lang_len, key_len, lang_key_len, text_len; - png_charp new_lang, new_key; - png_byte cbuf[2]; - compression_state comp; - - png_debug(1, "in png_write_iTXt\n"); - - comp.num_output_ptr = 0; - comp.max_output_ptr = 0; - comp.output_ptr = NULL; - comp.input = NULL; - - if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0) - { - png_warning(png_ptr, "Empty keyword in iTXt chunk"); - return; - } - if (lang == NULL || (lang_len = png_check_keyword(png_ptr, lang, &new_lang))==0) - { - png_warning(png_ptr, "Empty language field in iTXt chunk"); - new_lang = NULL; - lang_len = 0; - } - - if (lang_key == NULL) - lang_key_len = 0; - else - lang_key_len = png_strlen(lang_key); - - if (text == NULL) - text_len = 0; - else - text_len = png_strlen(text); - - /* compute the compressed data; do it now for the length */ - text_len = png_text_compress(png_ptr, text, text_len, compression-2, - &comp); - - - /* make sure we include the compression flag, the compression byte, - * and the NULs after the key, lang, and lang_key parts */ - - png_write_chunk_start(png_ptr, (png_bytep)png_iTXt, - (png_uint_32)( - 5 /* comp byte, comp flag, terminators for key, lang and lang_key */ - + key_len - + lang_len - + lang_key_len - + text_len)); - - /* - * We leave it to the application to meet PNG-1.0 requirements on the - * contents of the text. PNG-1.0 through PNG-1.2 discourage the use of - * any non-Latin-1 characters except for NEWLINE. ISO PNG will forbid them. - * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG. - */ - png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1); - - /* set the compression flag */ - if (compression == PNG_ITXT_COMPRESSION_NONE || \ - compression == PNG_TEXT_COMPRESSION_NONE) - cbuf[0] = 0; - else /* compression == PNG_ITXT_COMPRESSION_zTXt */ - cbuf[0] = 1; - /* set the compression method */ - cbuf[1] = 0; - png_write_chunk_data(png_ptr, cbuf, 2); - - cbuf[0] = 0; - png_write_chunk_data(png_ptr, (new_lang ? (png_bytep)new_lang : cbuf), lang_len + 1); - png_write_chunk_data(png_ptr, (lang_key ? (png_bytep)lang_key : cbuf), lang_key_len + 1); - png_write_compressed_data_out(png_ptr, &comp); - - png_write_chunk_end(png_ptr); - png_free(png_ptr, new_key); - if (new_lang) - png_free(png_ptr, new_lang); -} -#endif - -#if defined(PNG_WRITE_oFFs_SUPPORTED) -/* write the oFFs chunk */ -void /* PRIVATE */ -png_write_oFFs(png_structp png_ptr, png_int_32 x_offset, png_int_32 y_offset, - int unit_type) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_oFFs; -#endif - png_byte buf[9]; - - png_debug(1, "in png_write_oFFs\n"); - if (unit_type >= PNG_OFFSET_LAST) - png_warning(png_ptr, "Unrecognized unit type for oFFs chunk"); - - png_save_int_32(buf, x_offset); - png_save_int_32(buf + 4, y_offset); - buf[8] = (png_byte)unit_type; - - png_write_chunk(png_ptr, (png_bytep)png_oFFs, buf, (png_size_t)9); -} -#endif - -#if defined(PNG_WRITE_pCAL_SUPPORTED) -/* write the pCAL chunk (described in the PNG extensions document) */ -void /* PRIVATE */ -png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0, - png_int_32 X1, int type, int nparams, png_charp units, png_charpp params) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_pCAL; -#endif - png_size_t purpose_len, units_len, total_len; - png_uint_32p params_len; - png_byte buf[10]; - png_charp new_purpose; - int i; - - png_debug1(1, "in png_write_pCAL (%d parameters)\n", nparams); - if (type >= PNG_EQUATION_LAST) - png_warning(png_ptr, "Unrecognized equation type for pCAL chunk"); - - purpose_len = png_check_keyword(png_ptr, purpose, &new_purpose) + 1; - png_debug1(3, "pCAL purpose length = %d\n", (int)purpose_len); - units_len = png_strlen(units) + (nparams == 0 ? 0 : 1); - png_debug1(3, "pCAL units length = %d\n", (int)units_len); - total_len = purpose_len + units_len + 10; - - params_len = (png_uint_32p)png_malloc(png_ptr, (png_uint_32)(nparams - *png_sizeof(png_uint_32))); - - /* Find the length of each parameter, making sure we don't count the - null terminator for the last parameter. */ - for (i = 0; i < nparams; i++) - { - params_len[i] = png_strlen(params[i]) + (i == nparams - 1 ? 0 : 1); - png_debug2(3, "pCAL parameter %d length = %lu\n", i, params_len[i]); - total_len += (png_size_t)params_len[i]; - } - - png_debug1(3, "pCAL total length = %d\n", (int)total_len); - png_write_chunk_start(png_ptr, (png_bytep)png_pCAL, (png_uint_32)total_len); - png_write_chunk_data(png_ptr, (png_bytep)new_purpose, purpose_len); - png_save_int_32(buf, X0); - png_save_int_32(buf + 4, X1); - buf[8] = (png_byte)type; - buf[9] = (png_byte)nparams; - png_write_chunk_data(png_ptr, buf, (png_size_t)10); - png_write_chunk_data(png_ptr, (png_bytep)units, (png_size_t)units_len); - - png_free(png_ptr, new_purpose); - - for (i = 0; i < nparams; i++) - { - png_write_chunk_data(png_ptr, (png_bytep)params[i], - (png_size_t)params_len[i]); - } - - png_free(png_ptr, params_len); - png_write_chunk_end(png_ptr); -} -#endif - -#if defined(PNG_WRITE_sCAL_SUPPORTED) -/* write the sCAL chunk */ -#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) -void /* PRIVATE */ -png_write_sCAL(png_structp png_ptr, int unit, double width, double height) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_sCAL; -#endif - char buf[64]; - png_size_t total_len; - - png_debug(1, "in png_write_sCAL\n"); - - buf[0] = (char)unit; -#if defined(_WIN32_WCE) -/* sprintf() function is not supported on WindowsCE */ - { - wchar_t wc_buf[32]; - size_t wc_len; - swprintf(wc_buf, TEXT("%12.12e"), width); - wc_len = wcslen(wc_buf); - WideCharToMultiByte(CP_ACP, 0, wc_buf, -1, buf + 1, wc_len, NULL, NULL); - total_len = wc_len + 2; - swprintf(wc_buf, TEXT("%12.12e"), height); - wc_len = wcslen(wc_buf); - WideCharToMultiByte(CP_ACP, 0, wc_buf, -1, buf + total_len, wc_len, - NULL, NULL); - total_len += wc_len; - } -#else - sprintf(buf + 1, "%12.12e", width); - total_len = 1 + png_strlen(buf + 1) + 1; - sprintf(buf + total_len, "%12.12e", height); - total_len += png_strlen(buf + total_len); -#endif - - png_debug1(3, "sCAL total length = %u\n", (unsigned int)total_len); - png_write_chunk(png_ptr, (png_bytep)png_sCAL, (png_bytep)buf, total_len); -} -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -void /* PRIVATE */ -png_write_sCAL_s(png_structp png_ptr, int unit, png_charp width, - png_charp height) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_sCAL; -#endif - png_byte buf[64]; - png_size_t wlen, hlen, total_len; - - png_debug(1, "in png_write_sCAL_s\n"); - - wlen = png_strlen(width); - hlen = png_strlen(height); - total_len = wlen + hlen + 2; - if (total_len > 64) - { - png_warning(png_ptr, "Can't write sCAL (buffer too small)"); - return; - } - - buf[0] = (png_byte)unit; - png_memcpy(buf + 1, width, wlen + 1); /* append the '\0' here */ - png_memcpy(buf + wlen + 2, height, hlen); /* do NOT append the '\0' here */ - - png_debug1(3, "sCAL total length = %u\n", (unsigned int)total_len); - png_write_chunk(png_ptr, (png_bytep)png_sCAL, buf, total_len); -} -#endif -#endif -#endif - -#if defined(PNG_WRITE_pHYs_SUPPORTED) -/* write the pHYs chunk */ -void /* PRIVATE */ -png_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit, - png_uint_32 y_pixels_per_unit, - int unit_type) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_pHYs; -#endif - png_byte buf[9]; - - png_debug(1, "in png_write_pHYs\n"); - if (unit_type >= PNG_RESOLUTION_LAST) - png_warning(png_ptr, "Unrecognized unit type for pHYs chunk"); - - png_save_uint_32(buf, x_pixels_per_unit); - png_save_uint_32(buf + 4, y_pixels_per_unit); - buf[8] = (png_byte)unit_type; - - png_write_chunk(png_ptr, (png_bytep)png_pHYs, buf, (png_size_t)9); -} -#endif - -#if defined(PNG_WRITE_tIME_SUPPORTED) -/* Write the tIME chunk. Use either png_convert_from_struct_tm() - * or png_convert_from_time_t(), or fill in the structure yourself. - */ -void /* PRIVATE */ -png_write_tIME(png_structp png_ptr, png_timep mod_time) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_tIME; -#endif - png_byte buf[7]; - - png_debug(1, "in png_write_tIME\n"); - if (mod_time->month > 12 || mod_time->month < 1 || - mod_time->day > 31 || mod_time->day < 1 || - mod_time->hour > 23 || mod_time->second > 60) - { - png_warning(png_ptr, "Invalid time specified for tIME chunk"); - return; - } - - png_save_uint_16(buf, mod_time->year); - buf[2] = mod_time->month; - buf[3] = mod_time->day; - buf[4] = mod_time->hour; - buf[5] = mod_time->minute; - buf[6] = mod_time->second; - - png_write_chunk(png_ptr, (png_bytep)png_tIME, buf, (png_size_t)7); -} -#endif - -/* initializes the row writing capability of libpng */ -void /* PRIVATE */ -png_write_start_row(png_structp png_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* start of interlace block */ - int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - - /* offset to next interlace block */ - int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - - /* start of interlace block in the y direction */ - int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - - /* offset to next interlace block in the y direction */ - int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; -#endif - - png_size_t buf_size; - - png_debug(1, "in png_write_start_row\n"); - buf_size = (png_size_t)(PNG_ROWBYTES( - png_ptr->usr_channels*png_ptr->usr_bit_depth,png_ptr->width)+1); - - /* set up row buffer */ - png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, (png_uint_32)buf_size); - png_ptr->row_buf[0] = PNG_FILTER_VALUE_NONE; - - /* set up filtering buffer, if using this filter */ - if (png_ptr->do_filter & PNG_FILTER_SUB) - { - png_ptr->sub_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB; - } - - /* We only need to keep the previous row if we are using one of these. */ - if (png_ptr->do_filter & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH)) - { - /* set up previous row buffer */ - png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)buf_size); - png_memset(png_ptr->prev_row, 0, buf_size); - - if (png_ptr->do_filter & PNG_FILTER_UP) - { - png_ptr->up_row = (png_bytep )png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->up_row[0] = PNG_FILTER_VALUE_UP; - } - - if (png_ptr->do_filter & PNG_FILTER_AVG) - { - png_ptr->avg_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG; - } - - if (png_ptr->do_filter & PNG_FILTER_PAETH) - { - png_ptr->paeth_row = (png_bytep )png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH; - } - } - -#ifdef PNG_WRITE_INTERLACING_SUPPORTED - /* if interlaced, we need to set up width and height of pass */ - if (png_ptr->interlaced) - { - if (!(png_ptr->transformations & PNG_INTERLACE)) - { - png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 - - png_pass_ystart[0]) / png_pass_yinc[0]; - png_ptr->usr_width = (png_ptr->width + png_pass_inc[0] - 1 - - png_pass_start[0]) / png_pass_inc[0]; - } - else - { - png_ptr->num_rows = png_ptr->height; - png_ptr->usr_width = png_ptr->width; - } - } - else -#endif - { - png_ptr->num_rows = png_ptr->height; - png_ptr->usr_width = png_ptr->width; - } - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - png_ptr->zstream.next_out = png_ptr->zbuf; -} - -/* Internal use only. Called when finished processing a row of data. */ -void /* PRIVATE */ -png_write_finish_row(png_structp png_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* start of interlace block */ - int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - - /* offset to next interlace block */ - int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - - /* start of interlace block in the y direction */ - int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - - /* offset to next interlace block in the y direction */ - int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; -#endif - - int ret; - - png_debug(1, "in png_write_finish_row\n"); - /* next row */ - png_ptr->row_number++; - - /* see if we are done */ - if (png_ptr->row_number < png_ptr->num_rows) - return; - -#ifdef PNG_WRITE_INTERLACING_SUPPORTED - /* if interlaced, go to next pass */ - if (png_ptr->interlaced) - { - png_ptr->row_number = 0; - if (png_ptr->transformations & PNG_INTERLACE) - { - png_ptr->pass++; - } - else - { - /* loop until we find a non-zero width or height pass */ - do - { - png_ptr->pass++; - if (png_ptr->pass >= 7) - break; - png_ptr->usr_width = (png_ptr->width + - png_pass_inc[png_ptr->pass] - 1 - - png_pass_start[png_ptr->pass]) / - png_pass_inc[png_ptr->pass]; - png_ptr->num_rows = (png_ptr->height + - png_pass_yinc[png_ptr->pass] - 1 - - png_pass_ystart[png_ptr->pass]) / - png_pass_yinc[png_ptr->pass]; - if (png_ptr->transformations & PNG_INTERLACE) - break; - } while (png_ptr->usr_width == 0 || png_ptr->num_rows == 0); - - } - - /* reset the row above the image for the next pass */ - if (png_ptr->pass < 7) - { - if (png_ptr->prev_row != NULL) - png_memset(png_ptr->prev_row, 0, - (png_size_t)(PNG_ROWBYTES(png_ptr->usr_channels* - png_ptr->usr_bit_depth,png_ptr->width))+1); - return; - } - } -#endif - - /* if we get here, we've just written the last row, so we need - to flush the compressor */ - do - { - /* tell the compressor we are done */ - ret = deflate(&png_ptr->zstream, Z_FINISH); - /* check for an error */ - if (ret == Z_OK) - { - /* check to see if we need more room */ - if (!(png_ptr->zstream.avail_out)) - { - png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - } - } - else if (ret != Z_STREAM_END) - { - if (png_ptr->zstream.msg != NULL) - png_error(png_ptr, png_ptr->zstream.msg); - else - png_error(png_ptr, "zlib error"); - } - } while (ret != Z_STREAM_END); - - /* write any extra space */ - if (png_ptr->zstream.avail_out < png_ptr->zbuf_size) - { - png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size - - png_ptr->zstream.avail_out); - } - - deflateReset(&png_ptr->zstream); - png_ptr->zstream.data_type = Z_BINARY; -} - -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) -/* Pick out the correct pixels for the interlace pass. - * The basic idea here is to go through the row with a source - * pointer and a destination pointer (sp and dp), and copy the - * correct pixels for the pass. As the row gets compacted, - * sp will always be >= dp, so we should never overwrite anything. - * See the default: case for the easiest code to understand. - */ -void /* PRIVATE */ -png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* start of interlace block */ - int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - - /* offset to next interlace block */ - int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; -#endif - - png_debug(1, "in png_do_write_interlace\n"); - /* we don't have to do anything on the last pass (6) */ -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL && pass < 6) -#else - if (pass < 6) -#endif - { - /* each pixel depth is handled separately */ - switch (row_info->pixel_depth) - { - case 1: - { - png_bytep sp; - png_bytep dp; - int shift; - int d; - int value; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - dp = row; - d = 0; - shift = 7; - for (i = png_pass_start[pass]; i < row_width; - i += png_pass_inc[pass]) - { - sp = row + (png_size_t)(i >> 3); - value = (int)(*sp >> (7 - (int)(i & 0x07))) & 0x01; - d |= (value << shift); - - if (shift == 0) - { - shift = 7; - *dp++ = (png_byte)d; - d = 0; - } - else - shift--; - - } - if (shift != 7) - *dp = (png_byte)d; - break; - } - case 2: - { - png_bytep sp; - png_bytep dp; - int shift; - int d; - int value; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - dp = row; - shift = 6; - d = 0; - for (i = png_pass_start[pass]; i < row_width; - i += png_pass_inc[pass]) - { - sp = row + (png_size_t)(i >> 2); - value = (*sp >> ((3 - (int)(i & 0x03)) << 1)) & 0x03; - d |= (value << shift); - - if (shift == 0) - { - shift = 6; - *dp++ = (png_byte)d; - d = 0; - } - else - shift -= 2; - } - if (shift != 6) - *dp = (png_byte)d; - break; - } - case 4: - { - png_bytep sp; - png_bytep dp; - int shift; - int d; - int value; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - dp = row; - shift = 4; - d = 0; - for (i = png_pass_start[pass]; i < row_width; - i += png_pass_inc[pass]) - { - sp = row + (png_size_t)(i >> 1); - value = (*sp >> ((1 - (int)(i & 0x01)) << 2)) & 0x0f; - d |= (value << shift); - - if (shift == 0) - { - shift = 4; - *dp++ = (png_byte)d; - d = 0; - } - else - shift -= 4; - } - if (shift != 4) - *dp = (png_byte)d; - break; - } - default: - { - png_bytep sp; - png_bytep dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - png_size_t pixel_bytes; - - /* start at the beginning */ - dp = row; - /* find out how many bytes each pixel takes up */ - pixel_bytes = (row_info->pixel_depth >> 3); - /* loop through the row, only looking at the pixels that - matter */ - for (i = png_pass_start[pass]; i < row_width; - i += png_pass_inc[pass]) - { - /* find out where the original pixel is */ - sp = row + (png_size_t)i * pixel_bytes; - /* move the pixel */ - if (dp != sp) - png_memcpy(dp, sp, pixel_bytes); - /* next pixel */ - dp += pixel_bytes; - } - break; - } - } - /* set new row width */ - row_info->width = (row_info->width + - png_pass_inc[pass] - 1 - - png_pass_start[pass]) / - png_pass_inc[pass]; - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, - row_info->width); - } -} -#endif - -/* This filters the row, chooses which filter to use, if it has not already - * been specified by the application, and then writes the row out with the - * chosen filter. - */ -#define PNG_MAXSUM (((png_uint_32)(-1)) >> 1) -#define PNG_HISHIFT 10 -#define PNG_LOMASK ((png_uint_32)0xffffL) -#define PNG_HIMASK ((png_uint_32)(~PNG_LOMASK >> PNG_HISHIFT)) -void /* PRIVATE */ -png_write_find_filter(png_structp png_ptr, png_row_infop row_info) -{ - png_bytep prev_row, best_row, row_buf; - png_uint_32 mins, bpp; - png_byte filter_to_do = png_ptr->do_filter; - png_uint_32 row_bytes = row_info->rowbytes; -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - int num_p_filters = (int)png_ptr->num_prev_filters; -#endif - - png_debug(1, "in png_write_find_filter\n"); - /* find out how many bytes offset each pixel is */ - bpp = (row_info->pixel_depth + 7) >> 3; - - prev_row = png_ptr->prev_row; - best_row = row_buf = png_ptr->row_buf; - mins = PNG_MAXSUM; - - /* The prediction method we use is to find which method provides the - * smallest value when summing the absolute values of the distances - * from zero, using anything >= 128 as negative numbers. This is known - * as the "minimum sum of absolute differences" heuristic. Other - * heuristics are the "weighted minimum sum of absolute differences" - * (experimental and can in theory improve compression), and the "zlib - * predictive" method (not implemented yet), which does test compressions - * of lines using different filter methods, and then chooses the - * (series of) filter(s) that give minimum compressed data size (VERY - * computationally expensive). - * - * GRR 980525: consider also - * (1) minimum sum of absolute differences from running average (i.e., - * keep running sum of non-absolute differences & count of bytes) - * [track dispersion, too? restart average if dispersion too large?] - * (1b) minimum sum of absolute differences from sliding average, probably - * with window size <= deflate window (usually 32K) - * (2) minimum sum of squared differences from zero or running average - * (i.e., ~ root-mean-square approach) - */ - - - /* We don't need to test the 'no filter' case if this is the only filter - * that has been chosen, as it doesn't actually do anything to the data. - */ - if ((filter_to_do & PNG_FILTER_NONE) && - filter_to_do != PNG_FILTER_NONE) - { - png_bytep rp; - png_uint_32 sum = 0; - png_uint_32 i; - int v; - - for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++) - { - v = *rp; - sum += (v < 128) ? v : 256 - v; - } - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - png_uint_32 sumhi, sumlo; - int j; - sumlo = sum & PNG_LOMASK; - sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; /* Gives us some footroom */ - - /* Reduce the sum if we match any of the previous rows */ - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_NONE) - { - sumlo = (sumlo * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - sumhi = (sumhi * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - /* Factor in the cost of this filter (this is here for completeness, - * but it makes no sense to have a "cost" for the NONE filter, as - * it has the minimum possible computational cost - none). - */ - sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_NONE]) >> - PNG_COST_SHIFT; - sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_NONE]) >> - PNG_COST_SHIFT; - - if (sumhi > PNG_HIMASK) - sum = PNG_MAXSUM; - else - sum = (sumhi << PNG_HISHIFT) + sumlo; - } -#endif - mins = sum; - } - - /* sub filter */ - if (filter_to_do == PNG_FILTER_SUB) - /* it's the only filter so no testing is needed */ - { - png_bytep rp, lp, dp; - png_uint_32 i; - for (i = 0, rp = row_buf + 1, dp = png_ptr->sub_row + 1; i < bpp; - i++, rp++, dp++) - { - *dp = *rp; - } - for (lp = row_buf + 1; i < row_bytes; - i++, rp++, lp++, dp++) - { - *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff); - } - best_row = png_ptr->sub_row; - } - - else if (filter_to_do & PNG_FILTER_SUB) - { - png_bytep rp, dp, lp; - png_uint_32 sum = 0, lmins = mins; - png_uint_32 i; - int v; - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - /* We temporarily increase the "minimum sum" by the factor we - * would reduce the sum of this filter, so that we can do the - * early exit comparison without scaling the sum each time. - */ - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 lmhi, lmlo; - lmlo = lmins & PNG_LOMASK; - lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_SUB) - { - lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >> - PNG_COST_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >> - PNG_COST_SHIFT; - - if (lmhi > PNG_HIMASK) - lmins = PNG_MAXSUM; - else - lmins = (lmhi << PNG_HISHIFT) + lmlo; - } -#endif - - for (i = 0, rp = row_buf + 1, dp = png_ptr->sub_row + 1; i < bpp; - i++, rp++, dp++) - { - v = *dp = *rp; - - sum += (v < 128) ? v : 256 - v; - } - for (lp = row_buf + 1; i < row_bytes; - i++, rp++, lp++, dp++) - { - v = *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff); - - sum += (v < 128) ? v : 256 - v; - - if (sum > lmins) /* We are already worse, don't continue. */ - break; - } - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 sumhi, sumlo; - sumlo = sum & PNG_LOMASK; - sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_SUB) - { - sumlo = (sumlo * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - sumhi = (sumhi * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - sumlo = (sumlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >> - PNG_COST_SHIFT; - sumhi = (sumhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >> - PNG_COST_SHIFT; - - if (sumhi > PNG_HIMASK) - sum = PNG_MAXSUM; - else - sum = (sumhi << PNG_HISHIFT) + sumlo; - } -#endif - - if (sum < mins) - { - mins = sum; - best_row = png_ptr->sub_row; - } - } - - /* up filter */ - if (filter_to_do == PNG_FILTER_UP) - { - png_bytep rp, dp, pp; - png_uint_32 i; - - for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1, - pp = prev_row + 1; i < row_bytes; - i++, rp++, pp++, dp++) - { - *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff); - } - best_row = png_ptr->up_row; - } - - else if (filter_to_do & PNG_FILTER_UP) - { - png_bytep rp, dp, pp; - png_uint_32 sum = 0, lmins = mins; - png_uint_32 i; - int v; - - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 lmhi, lmlo; - lmlo = lmins & PNG_LOMASK; - lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_UP) - { - lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_UP]) >> - PNG_COST_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_UP]) >> - PNG_COST_SHIFT; - - if (lmhi > PNG_HIMASK) - lmins = PNG_MAXSUM; - else - lmins = (lmhi << PNG_HISHIFT) + lmlo; - } -#endif - - for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1, - pp = prev_row + 1; i < row_bytes; i++) - { - v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff); - - sum += (v < 128) ? v : 256 - v; - - if (sum > lmins) /* We are already worse, don't continue. */ - break; - } - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 sumhi, sumlo; - sumlo = sum & PNG_LOMASK; - sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_UP) - { - sumlo = (sumlo * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - sumhi = (sumhi * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_UP]) >> - PNG_COST_SHIFT; - sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_UP]) >> - PNG_COST_SHIFT; - - if (sumhi > PNG_HIMASK) - sum = PNG_MAXSUM; - else - sum = (sumhi << PNG_HISHIFT) + sumlo; - } -#endif - - if (sum < mins) - { - mins = sum; - best_row = png_ptr->up_row; - } - } - - /* avg filter */ - if (filter_to_do == PNG_FILTER_AVG) - { - png_bytep rp, dp, pp, lp; - png_uint_32 i; - for (i = 0, rp = row_buf + 1, dp = png_ptr->avg_row + 1, - pp = prev_row + 1; i < bpp; i++) - { - *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff); - } - for (lp = row_buf + 1; i < row_bytes; i++) - { - *dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2)) - & 0xff); - } - best_row = png_ptr->avg_row; - } - - else if (filter_to_do & PNG_FILTER_AVG) - { - png_bytep rp, dp, pp, lp; - png_uint_32 sum = 0, lmins = mins; - png_uint_32 i; - int v; - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 lmhi, lmlo; - lmlo = lmins & PNG_LOMASK; - lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_AVG) - { - lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_AVG]) >> - PNG_COST_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_AVG]) >> - PNG_COST_SHIFT; - - if (lmhi > PNG_HIMASK) - lmins = PNG_MAXSUM; - else - lmins = (lmhi << PNG_HISHIFT) + lmlo; - } -#endif - - for (i = 0, rp = row_buf + 1, dp = png_ptr->avg_row + 1, - pp = prev_row + 1; i < bpp; i++) - { - v = *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff); - - sum += (v < 128) ? v : 256 - v; - } - for (lp = row_buf + 1; i < row_bytes; i++) - { - v = *dp++ = - (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2)) & 0xff); - - sum += (v < 128) ? v : 256 - v; - - if (sum > lmins) /* We are already worse, don't continue. */ - break; - } - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 sumhi, sumlo; - sumlo = sum & PNG_LOMASK; - sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_NONE) - { - sumlo = (sumlo * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - sumhi = (sumhi * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_AVG]) >> - PNG_COST_SHIFT; - sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_AVG]) >> - PNG_COST_SHIFT; - - if (sumhi > PNG_HIMASK) - sum = PNG_MAXSUM; - else - sum = (sumhi << PNG_HISHIFT) + sumlo; - } -#endif - - if (sum < mins) - { - mins = sum; - best_row = png_ptr->avg_row; - } - } - - /* Paeth filter */ - if (filter_to_do == PNG_FILTER_PAETH) - { - png_bytep rp, dp, pp, cp, lp; - png_uint_32 i; - for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1, - pp = prev_row + 1; i < bpp; i++) - { - *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff); - } - - for (lp = row_buf + 1, cp = prev_row + 1; i < row_bytes; i++) - { - int a, b, c, pa, pb, pc, p; - - b = *pp++; - c = *cp++; - a = *lp++; - - p = b - c; - pc = a - c; - -#ifdef PNG_USE_ABS - pa = abs(p); - pb = abs(pc); - pc = abs(p + pc); -#else - pa = p < 0 ? -p : p; - pb = pc < 0 ? -pc : pc; - pc = (p + pc) < 0 ? -(p + pc) : p + pc; -#endif - - p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; - - *dp++ = (png_byte)(((int)*rp++ - p) & 0xff); - } - best_row = png_ptr->paeth_row; - } - - else if (filter_to_do & PNG_FILTER_PAETH) - { - png_bytep rp, dp, pp, cp, lp; - png_uint_32 sum = 0, lmins = mins; - png_uint_32 i; - int v; - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 lmhi, lmlo; - lmlo = lmins & PNG_LOMASK; - lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_PAETH) - { - lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_PAETH]) >> - PNG_COST_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_PAETH]) >> - PNG_COST_SHIFT; - - if (lmhi > PNG_HIMASK) - lmins = PNG_MAXSUM; - else - lmins = (lmhi << PNG_HISHIFT) + lmlo; - } -#endif - - for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1, - pp = prev_row + 1; i < bpp; i++) - { - v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff); - - sum += (v < 128) ? v : 256 - v; - } - - for (lp = row_buf + 1, cp = prev_row + 1; i < row_bytes; i++) - { - int a, b, c, pa, pb, pc, p; - - b = *pp++; - c = *cp++; - a = *lp++; - -#ifndef PNG_SLOW_PAETH - p = b - c; - pc = a - c; -#ifdef PNG_USE_ABS - pa = abs(p); - pb = abs(pc); - pc = abs(p + pc); -#else - pa = p < 0 ? -p : p; - pb = pc < 0 ? -pc : pc; - pc = (p + pc) < 0 ? -(p + pc) : p + pc; -#endif - p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; -#else /* PNG_SLOW_PAETH */ - p = a + b - c; - pa = abs(p - a); - pb = abs(p - b); - pc = abs(p - c); - if (pa <= pb && pa <= pc) - p = a; - else if (pb <= pc) - p = b; - else - p = c; -#endif /* PNG_SLOW_PAETH */ - - v = *dp++ = (png_byte)(((int)*rp++ - p) & 0xff); - - sum += (v < 128) ? v : 256 - v; - - if (sum > lmins) /* We are already worse, don't continue. */ - break; - } - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 sumhi, sumlo; - sumlo = sum & PNG_LOMASK; - sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_PAETH) - { - sumlo = (sumlo * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - sumhi = (sumhi * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_PAETH]) >> - PNG_COST_SHIFT; - sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_PAETH]) >> - PNG_COST_SHIFT; - - if (sumhi > PNG_HIMASK) - sum = PNG_MAXSUM; - else - sum = (sumhi << PNG_HISHIFT) + sumlo; - } -#endif - - if (sum < mins) - { - best_row = png_ptr->paeth_row; - } - } - - /* Do the actual writing of the filtered row data from the chosen filter. */ - - png_write_filtered_row(png_ptr, best_row); - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - /* Save the type of filter we picked this time for future calculations */ - if (png_ptr->num_prev_filters > 0) - { - int j; - for (j = 1; j < num_p_filters; j++) - { - png_ptr->prev_filters[j] = png_ptr->prev_filters[j - 1]; - } - png_ptr->prev_filters[j] = best_row[0]; - } -#endif -} - - -/* Do the actual writing of a previously filtered row. */ -void /* PRIVATE */ -png_write_filtered_row(png_structp png_ptr, png_bytep filtered_row) -{ - png_debug(1, "in png_write_filtered_row\n"); - png_debug1(2, "filter = %d\n", filtered_row[0]); - /* set up the zlib input buffer */ - - png_ptr->zstream.next_in = filtered_row; - png_ptr->zstream.avail_in = (uInt)png_ptr->row_info.rowbytes + 1; - /* repeat until we have compressed all the data */ - do - { - int ret; /* return of zlib */ - - /* compress the data */ - ret = deflate(&png_ptr->zstream, Z_NO_FLUSH); - /* check for compression errors */ - if (ret != Z_OK) - { - if (png_ptr->zstream.msg != NULL) - png_error(png_ptr, png_ptr->zstream.msg); - else - png_error(png_ptr, "zlib error"); - } - - /* see if it is time to write another IDAT */ - if (!(png_ptr->zstream.avail_out)) - { - /* write the IDAT and reset the zlib output buffer */ - png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - } - /* repeat until all data has been compressed */ - } while (png_ptr->zstream.avail_in); - - /* swap the current and previous rows */ - if (png_ptr->prev_row != NULL) - { - png_bytep tptr; - - tptr = png_ptr->prev_row; - png_ptr->prev_row = png_ptr->row_buf; - png_ptr->row_buf = tptr; - } - - /* finish row - updates counters and flushes zlib if last row */ - png_write_finish_row(png_ptr); - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) - png_ptr->flush_rows++; - - if (png_ptr->flush_dist > 0 && - png_ptr->flush_rows >= png_ptr->flush_dist) - { - png_write_flush(png_ptr); - } -#endif -} -#endif /* PNG_WRITE_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/projects/beos/x86-shared.proj b/irrlicht-1.6/source/Irrlicht/libpng/projects/beos/x86-shared.proj deleted file mode 100644 index 6d2e3c319..000000000 Binary files a/irrlicht-1.6/source/Irrlicht/libpng/projects/beos/x86-shared.proj and /dev/null differ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/projects/beos/x86-shared.txt b/irrlicht-1.6/source/Irrlicht/libpng/projects/beos/x86-shared.txt deleted file mode 100644 index ea62d617e..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/projects/beos/x86-shared.txt +++ /dev/null @@ -1,22 +0,0 @@ -This project builds a shared library version of libpng on x86 BeOS. - -It defines PNG_USE_PNGGCCRD, which activates the assembly code in -pnggccrd.c; this hasn't been extensively tested on BeOS. - -To install: - -1) build - - Note: As of version 1.0.10, you'll get a fair number of warnings when - you compile pnggccrd.c. As far as I know, these are harmless, - but it would be better if someone fixed them. - -2) copy and png.h, pngconf.h somewhere; /boot/home/config/include (which - you'll have to make) is a good choice - -3) copy libpng.so to /boot/home/config/lib - -4) build your libpng.so applications (remember to include libz.a as - well when you link) - -- Chris Herborth, March 27, 2001 diff --git a/irrlicht-1.6/source/Irrlicht/libpng/projects/beos/x86-static.proj b/irrlicht-1.6/source/Irrlicht/libpng/projects/beos/x86-static.proj deleted file mode 100644 index 37c075366..000000000 Binary files a/irrlicht-1.6/source/Irrlicht/libpng/projects/beos/x86-static.proj and /dev/null differ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/projects/beos/x86-static.txt b/irrlicht-1.6/source/Irrlicht/libpng/projects/beos/x86-static.txt deleted file mode 100644 index 6f9ce6871..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/projects/beos/x86-static.txt +++ /dev/null @@ -1,22 +0,0 @@ -This project builds a static library version of libpng on x86 BeOS. - -It defines PNG_USE_PNGGCCRD, which activates the assembly code in -pnggccrd.c; this hasn't been extensively tested on BeOS. - -To install: - -1) build - - Note: As of version 1.0.10, you'll get a fair number of warnings when - you compile pnggccrd.c. As far as I know, these are harmless, - but it would be better if someone fixed them. - -2) copy and png.h, pngconf.h somewhere; /boot/home/config/include (which - you'll have to make) is a good choice - -3) copy libpng.a to /boot/home/config/lib - -4) build your libpng.a applications (remember to include libz.a as - well when you link) - -- Chris Herborth, March 27, 2001 diff --git a/irrlicht-1.6/source/Irrlicht/libpng/projects/cbuilder5/libpng.bpf b/irrlicht-1.6/source/Irrlicht/libpng/projects/cbuilder5/libpng.bpf deleted file mode 100644 index ee6d9293d..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/projects/cbuilder5/libpng.bpf +++ /dev/null @@ -1,22 +0,0 @@ -USEUNIT("libpng.cpp"); -USEUNIT("..\..\png.c"); -USEUNIT("..\..\pngerror.c"); -USEUNIT("..\..\pngget.c"); -USEUNIT("..\..\pngmem.c"); -USEUNIT("..\..\pngpread.c"); -USEUNIT("..\..\pngread.c"); -USEUNIT("..\..\pngrio.c"); -USEUNIT("..\..\pngrtran.c"); -USEUNIT("..\..\pngrutil.c"); -USEUNIT("..\..\pngset.c"); -USEUNIT("..\..\pngtrans.c"); -USEUNIT("..\..\pngwio.c"); -USEUNIT("..\..\pngwrite.c"); -USEUNIT("..\..\pngwtran.c"); -USEUNIT("..\..\pngwutil.c"); -USELIB("..\..\..\zlib\zlib.lib"); -//--------------------------------------------------------------------------- -This file is used by the project manager only and should be treated like the project file - - -DllEntryPoint diff --git a/irrlicht-1.6/source/Irrlicht/libpng/projects/cbuilder5/libpng.bpg b/irrlicht-1.6/source/Irrlicht/libpng/projects/cbuilder5/libpng.bpg deleted file mode 100644 index c6c6a4e65..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/projects/cbuilder5/libpng.bpg +++ /dev/null @@ -1,25 +0,0 @@ -#------------------------------------------------------------------------------ -VERSION = BWS.01 -#------------------------------------------------------------------------------ -!ifndef ROOT -ROOT = $(MAKEDIR)\.. -!endif -#------------------------------------------------------------------------------ -MAKE = $(ROOT)\bin\make.exe -$(MAKEFLAGS) -f$** -DCC = $(ROOT)\bin\dcc32.exe $** -BRCC = $(ROOT)\bin\brcc32.exe $** -#------------------------------------------------------------------------------ -PROJECTS = libpngstat.lib libpng.dll -#------------------------------------------------------------------------------ -default: $(PROJECTS) -#------------------------------------------------------------------------------ - -libpngstat.lib: libpngstat.bpr - $(ROOT)\bin\bpr2mak -t$(ROOT)\bin\deflib.bmk $** - $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak - -libpng.dll: libpng.bpr - $(ROOT)\bin\bpr2mak $** - $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak - - diff --git a/irrlicht-1.6/source/Irrlicht/libpng/projects/cbuilder5/libpng.bpr b/irrlicht-1.6/source/Irrlicht/libpng/projects/cbuilder5/libpng.bpr deleted file mode 100644 index 7e09ddaea..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/projects/cbuilder5/libpng.bpr +++ /dev/null @@ -1,157 +0,0 @@ -<?xml version='1.0' encoding='utf-8' ?> -<!-- C++Builder XML Project --> -<PROJECT> - <MACROS> - <VERSION value="BCB.05.03"/> - <PROJECT value="libpng.dll"/> - <OBJFILES value="libpng.obj ..\..\pngwutil.obj ..\..\pngerror.obj ..\..\pngget.obj - ..\..\pngmem.obj ..\..\pngpread.obj ..\..\pngread.obj ..\..\pngrio.obj - ..\..\pngrtran.obj ..\..\pngrutil.obj ..\..\pngset.obj ..\..\pngtrans.obj - ..\..\pngwio.obj ..\..\pngwrite.obj ..\..\pngwtran.obj ..\..\png.obj"/> - <RESFILES value=""/> - <DEFFILE value=""/> - <RESDEPEN value="$(RESFILES)"/> - <LIBFILES value="..\..\..\zlib\zlib.lib"/> - <LIBRARIES value="bcbsmp50.lib dclocx50.lib NMFast50.lib Tee50.lib Vclx50.lib Vcl50.lib"/> - <SPARELIBS value="Vcl50.lib Vclx50.lib Tee50.lib NMFast50.lib dclocx50.lib bcbsmp50.lib"/> - <PACKAGES value="Vcl50.bpi Vclx50.bpi bcbsmp50.bpi Qrpt50.bpi Vcldb50.bpi Vclbde50.bpi - ibsmp50.bpi vcldbx50.bpi TeeUI50.bpi TeeDB50.bpi Tee50.bpi TeeQR50.bpi - VCLIB50.bpi bcbie50.bpi vclie50.bpi Inetdb50.bpi Inet50.bpi NMFast50.bpi - dclocx50.bpi bcb97axserver50.bpi SIMULUSCOMPONENTS.bpi Simulus2.bpi"/> - <PATHCPP value=".;..\.."/> - <PATHPAS value=".;"/> - <PATHRC value=".;"/> - <PATHASM value=".;"/> - <DEBUGLIBPATH value="$(BCB)\lib\debug"/> - <RELEASELIBPATH value="$(BCB)\lib\release"/> - <LINKER value="tlink32"/> - <USERDEFINES value="PNG_BUILD_DLL;PNG_NO_MODULEDEF"/> - <SYSDEFINES value="NO_STRICT;_NO_VCL;_RTLDLL"/> - <MAINSOURCE value="libpng.bpf"/> - <INCLUDEPATH value="..\..;..\..\..\zlib;$(BCB)\include"/> - <LIBPATH value="..\..;$(BCB)\lib\obj;$(BCB)\lib"/> - <WARNINGS value="-w8092 -w8091 -w8090 -w8089 -w8087 -wprc -wucp -wstv -wstu -wsig -wpin - -wnod -wnak -wdef -wcln -wbbf -wasm -wamp -wamb"/> - </MACROS> - <OPTIONS> - <CFLAG1 value="-WD -O2 -w -Vx -Ve -x- -RT- -X- -a8 -5 -b- -d -k- -vi -tWD -tWM -c"/> - <PFLAGS value="-$Y- -$L- -$D- -$C- -v -JPHNE -M"/> - <RFLAGS value=""/> - <AFLAGS value="/mx /w2 /zn"/> - <LFLAGS value="-D"" -aa -Tpd -x -Gn -Gi -w"/> - </OPTIONS> - <LINKER> - <ALLOBJ value="c0d32.obj $(OBJFILES)"/> - <ALLRES value="$(RESFILES)"/> - <ALLLIB value="$(LIBFILES) $(LIBRARIES) import32.lib cw32mti.lib"/> - </LINKER> - <IDEOPTIONS> -[Version Info] -IncludeVerInfo=0 -AutoIncBuild=0 -MajorVer=1 -MinorVer=0 -Release=0 -Build=0 -Debug=0 -PreRelease=0 -Special=0 -Private=0 -DLL=1 -Locale=2057 -CodePage=1252 - -[Version Info Keys] -CompanyName= -FileDescription= -FileVersion=1.0.0.0 -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename= -ProductName= -ProductVersion= -Comments= - -[HistoryLists\hlIncludePath] -Count=18 -Item0=..\..;..\..\..\zlib;$(BCB)\include -Item1=..\..;P:\My Documents\Source\PNG+ZLib\zlib;$(BCB)\include -Item2=..\..;..\Source\ThirdParty\PortableNetworkGraphics\external;..\Source\ThirdParty\PortableNetworkGraphics;..\Source\ThirdParty\ZLibCompression\external;$(BCB)\include -Item3=..\Source\ThirdParty\PortableNetworkGraphics\external;..\Source\ThirdParty\PortableNetworkGraphics;..\Source\ThirdParty\ZLibCompression\external;$(BCB)\include -Item4=..\Source\ThirdParty\PortableNetworkGraphics\external;..\Source\ThirdParty\PortableNetworkGraphics;..\Source\ThirdParty\ZLibCompression;$(BCB)\include -Item5=..\Source\ThirdParty\PortableNetworkGraphics;..\Source\ThirdParty\ZLibCompression;$(BCB)\include -Item6=..\Source\ThirdParty\PortableNetworkGraphics;P:\Development\Source\ThirdParty\ZLibCompression;$(BCB)\include -Item7=..\Source\ThirdParty\PortableNetworkGraphics;$(BCB)\include -Item8=$(BCB)\include -Item9=..\Source;..\Source\General\Templates;..\Source\SIMUtilities;$(BCB)\include;$(BCB)\include\vcl -Item10=P:\Development\Source\;P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities\;$(BCB)\include;$(BCB)\include\vcl -Item11=P:\Development\Source;P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities\;$(BCB)\include;$(BCB)\include\vcl -Item12=P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities\;$(BCB)\include;$(BCB)\include\vcl -Item13=P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities;$(BCB)\include;$(BCB)\include\vcl -Item14=P:\Development\Source\General\Templates\;$(BCB)\include;$(BCB)\include\vcl -Item15=P:\Development\Source\General\Templates;$(BCB)\include;$(BCB)\include\vcl -Item16=P:\Development\Source;$(BCB)\include;$(BCB)\include\vcl -Item17=$(BCB)\include;$(BCB)\include\vcl - -[HistoryLists\hlLibraryPath] -Count=10 -Item0=..\..;$(BCB)\lib\obj;$(BCB)\lib -Item1=..\..;..\Source\ThirdParty\PortableNetworkGraphics\external;..\Source\ThirdParty\PortableNetworkGraphics;$(BCB)\lib\obj;$(BCB)\lib -Item2=..\Source\ThirdParty\PortableNetworkGraphics\external;..\Source\ThirdParty\PortableNetworkGraphics;$(BCB)\lib\obj;$(BCB)\lib -Item3=..\Source\ThirdParty\PortableNetworkGraphics;$(BCB)\lib\obj;$(BCB)\lib -Item4=$(BCB)\lib\obj;$(BCB)\lib -Item5=..\Source\SIMUtilities;..\Source;$(BCB)\lib\obj;$(BCB)\lib -Item6=P:\Development\Source\SIMUtilities\;P:\Development\Source\;$(BCB)\lib\obj;$(BCB)\lib -Item7=P:\Development\Source\SIMUtilities;P:\Development\Source\;$(BCB)\lib\obj;$(BCB)\lib -Item8=P:\Development\Source\;$(BCB)\lib\obj;$(BCB)\lib -Item9=P:\Development\Source;$(BCB)\lib\obj;$(BCB)\lib - -[HistoryLists\hlDebugSourcePath] -Count=1 -Item0=$(BCB)\source\vcl - -[HistoryLists\hlConditionals] -Count=20 -Item0=ZLIB_DLL;Z_PREFIX;PNG_BUILD_DLL;PNG_NO_MODULEDEF -Item1=_DEBUG;ZLIB_DLL;Z_PREFIX;PNG_BUILD_DLL;PNG_NO_MODULEDEF -Item2=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_NO_MODULEDEF -Item3=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_DEBUG=5;PNG_NO_MODULEDEF;PNG_NO_GLOBAL_ARRAYS -Item4=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_DEBUG=5;PNG_NO_MODULEDEF;PNG_SETJMP_NOT_SUPPORTED;PNG_DEBUG_FILE=stderr -Item5=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_DEBUG;PNG_NO_MODULEDEF;PNG_SETJMP_NOT_SUPPORTED -Item6=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_DEBUG=5;PNG_NO_MODULEDEF;PNG_SETJMP_NOT_SUPPORTED -Item7=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_DEBUG=5;PNG_NO_MODULEDEF -Item8=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_DEBUG=5 -Item9=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG -Item10=PNG_BUILD_DLL;ZLIB_DLL -Item11=PNG_BUILD_DLL -Item12=PNG_DLL;PNG_BUILD_DLL;ZLIB_DLL -Item13=PNG_DLL;PNG_BUILD_DLL;PNG_NO_GLOBAL_ARRAYS;ZLIB_DLL -Item14=PNG_DLL;PNG_BUILD_DLL;PNG_NO_GLOBAL_ARRAYS -Item15=PNG_DLL;PNG_BUILD_DLL -Item16=PNG_DLL;PNG_BUILD_DLL;PNG_MODULEDEF -Item17=_HTML_FORM -Item18=_DEBUG;_HTML_FORM -Item19=_DEBUG - -[HistoryLists\hlIntOutputDir] -Count=2 -Item0=..\Obj -Item1=P:\Development\Obj - -[Debugging] -DebugSourceDirs= - -[Parameters] -RunParams= -HostApplication=P:\Development\Executables\LibPNGTestApp.exe -RemoteHost= -RemotePath= -RemoteDebug=0 - -[Compiler] -ShowInfoMsgs=0 -LinkDebugVcl=0 -LinkCGLIB=0 - </IDEOPTIONS> -</PROJECT> \ No newline at end of file diff --git a/irrlicht-1.6/source/Irrlicht/libpng/projects/cbuilder5/libpng.cpp b/irrlicht-1.6/source/Irrlicht/libpng/projects/cbuilder5/libpng.cpp deleted file mode 100644 index 97865f59e..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/projects/cbuilder5/libpng.cpp +++ /dev/null @@ -1,29 +0,0 @@ -//--------------------------------------------------------------------------- -#include <windows.h> -//--------------------------------------------------------------------------- -// Important note about DLL memory management when your DLL uses the -// static version of the RunTime Library: -// -// If your DLL exports any functions that pass String objects (or structs/ -// classes containing nested Strings) as parameter or function results, -// you will need to add the library MEMMGR.LIB to both the DLL project and -// any other projects that use the DLL. You will also need to use MEMMGR.LIB -// if any other projects which use the DLL will be performing new or delete -// operations on any non-TObject-derived classes which are exported from the -// DLL. Adding MEMMGR.LIB to your project will change the DLL and its calling -// EXE's to use the BORLNDMM.DLL as their memory manager. In these cases, -// the file BORLNDMM.DLL should be deployed along with your DLL. -// -// To avoid using BORLNDMM.DLL, pass string information using "char *" or -// ShortString parameters. -// -// If your DLL uses the dynamic version of the RTL, you do not need to -// explicitly add MEMMGR.LIB as this will be done implicitly for you -//--------------------------------------------------------------------------- - -int WINAPI DllEntryPoint(HINSTANCE, unsigned long, void*) -{ - return 1; -} -//--------------------------------------------------------------------------- - \ No newline at end of file diff --git a/irrlicht-1.6/source/Irrlicht/libpng/projects/cbuilder5/libpng.readme.txt b/irrlicht-1.6/source/Irrlicht/libpng/projects/cbuilder5/libpng.readme.txt deleted file mode 100644 index 704c121ea..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/projects/cbuilder5/libpng.readme.txt +++ /dev/null @@ -1,25 +0,0 @@ -Project files to build libpng using Borland C++ Builder v5.0 - -In order to build and use libpng, please follow these steps: - - 1). Install zlib in a directory at the same level with libpng. - - 2). In a console window, go to the zlib directory and type: - make -f win32\Makefile.bor - After performing this step, you should have a file named - zlib.lib in the zlib directory. - - 3). Add the following conditional define to your project: - PNG_USE_DLL - - 4). Add libpng.lib or libpngstat.lib to the project. - Build the project. - - 5). If the build fails, add the paths to png.h and zlib.h to - your include path, and restart the build. - -By default, the libpng project uses zlib as a static library. If -you wish to use zlib as a DLL, please read the important notes from -the zlib DLL FAQ, found inside the zlib distribution. - -See the libpng documentation for instructions on how to use the code. diff --git a/irrlicht-1.6/source/Irrlicht/libpng/projects/cbuilder5/libpngstat.bpf b/irrlicht-1.6/source/Irrlicht/libpng/projects/cbuilder5/libpngstat.bpf deleted file mode 100644 index f736b62f4..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/projects/cbuilder5/libpngstat.bpf +++ /dev/null @@ -1,22 +0,0 @@ -USEUNIT("..\..\png.c"); -USEUNIT("..\..\pngerror.c"); -USEUNIT("..\..\pngget.c"); -USEUNIT("..\..\pngmem.c"); -USEUNIT("..\..\pngpread.c"); -USEUNIT("..\..\pngread.c"); -USEUNIT("..\..\pngrio.c"); -USEUNIT("..\..\pngrtran.c"); -USEUNIT("..\..\pngrutil.c"); -USEUNIT("..\..\pngset.c"); -USEUNIT("..\..\pngtrans.c"); -USEUNIT("..\..\pngwio.c"); -USEUNIT("..\..\pngwrite.c"); -USEUNIT("..\..\pngwtran.c"); -USEUNIT("..\..\pngwutil.c"); -USELIB("..\..\..\zlib\zlib.lib"); -//--------------------------------------------------------------------------- -#define Library - -// To add a file to the library use the Project menu 'Add to Project'. - - \ No newline at end of file diff --git a/irrlicht-1.6/source/Irrlicht/libpng/projects/cbuilder5/libpngstat.bpr b/irrlicht-1.6/source/Irrlicht/libpng/projects/cbuilder5/libpngstat.bpr deleted file mode 100644 index 68abb8dd5..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/projects/cbuilder5/libpngstat.bpr +++ /dev/null @@ -1,109 +0,0 @@ -<?xml version='1.0' encoding='utf-8' ?> -<!-- C++Builder XML Project --> -<PROJECT> - <MACROS> - <VERSION value="BCB.05.03"/> - <PROJECT value="libpngstat.lib"/> - <OBJFILES value="..\..\pngerror.obj ..\..\png.obj ..\..\pngwutil.obj ..\..\pngmem.obj - ..\..\pngpread.obj ..\..\pngread.obj ..\..\pngrio.obj ..\..\pngrtran.obj - ..\..\pngrutil.obj ..\..\pngset.obj ..\..\pngtrans.obj ..\..\pngwio.obj - ..\..\pngwrite.obj ..\..\pngwtran.obj ..\..\pngget.obj"/> - <RESFILES value=""/> - <DEFFILE value=""/> - <RESDEPEN value="$(RESFILES)"/> - <LIBFILES value="..\..\..\zlib\zlib.lib"/> - <LIBRARIES value=""/> - <PACKAGES value=""/> - <PATHCPP value=".;..\.."/> - <PATHPAS value=".;"/> - <PATHRC value=".;"/> - <PATHASM value=".;"/> - <LINKER value="TLib"/> - <USERDEFINES value=""/> - <SYSDEFINES value="_RTLDLL;NO_STRICT"/> - <MAINSOURCE value="libpngstat.bpf"/> - <INCLUDEPATH value="..\..;..\..\..\zlib;$(BCB)\include"/> - <LIBPATH value="..\..;$(BCB)\lib\obj;$(BCB)\lib"/> - <WARNINGS value="-w-par"/> - <LISTFILE value=""/> - </MACROS> - <OPTIONS> - <CFLAG1 value="-O2 -w -Vx -Ve -X- -a8 -5 -b- -d -k- -vi -c -tW -tWM"/> - <PFLAGS value="-$Y- -$L- -$D- -$C- -v -JPHNE -M"/> - <AFLAGS value="/mx /w2 /zn"/> - <LFLAGS value=""/> - </OPTIONS> - <LINKER> - <ALLOBJ value="$(OBJFILES)"/> - <ALLLIB value=""/> - </LINKER> - <IDEOPTIONS> -[Version Info] -IncludeVerInfo=0 -AutoIncBuild=0 -MajorVer=1 -MinorVer=0 -Release=0 -Build=0 -Debug=0 -PreRelease=0 -Special=0 -Private=0 -DLL=0 -Locale=2057 -CodePage=1252 - -[Version Info Keys] -CompanyName= -FileDescription= -FileVersion=1.0.0.0 -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename= -ProductName= -ProductVersion=1.0.0.0 -Comments= - -[HistoryLists\hlIncludePath] -Count=2 -Item0=..\..;P:\My Documents\Source\PNG+ZLib\zlib;$(BCB)\include -Item1=..\..;$(BCB)\include;$(BCB)\include\vcl - -[HistoryLists\hlLibraryPath] -Count=1 -Item0=..\..;$(BCB)\lib\obj;$(BCB)\lib - -[HistoryLists\hlDebugSourcePath] -Count=1 -Item0=$(BCB)\source\vcl - -[HistoryLists\hlConditionals] -Count=1 -Item0=_DEBUG - -[HistoryLists\hlTlibPageSize] -Count=1 -Item0=0x0010 - -[Debugging] -DebugSourceDirs=$(BCB)\source\vcl - -[Parameters] -RunParams= -HostApplication= -RemoteHost= -RemotePath= -RemoteDebug=0 - -[Compiler] -ShowInfoMsgs=0 -LinkDebugVcl=0 -LinkCGLIB=0 - -[Language] -ActiveLang= -ProjectLang= -RootDir= - </IDEOPTIONS> -</PROJECT> \ No newline at end of file diff --git a/irrlicht-1.6/source/Irrlicht/libpng/projects/cbuilder5/zlib.readme.txt b/irrlicht-1.6/source/Irrlicht/libpng/projects/cbuilder5/zlib.readme.txt deleted file mode 100644 index 9fb45575c..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/projects/cbuilder5/zlib.readme.txt +++ /dev/null @@ -1,14 +0,0 @@ -The project that builds libpng under Borland C++ Builder does not -explicitly build zlib. By taking this decision, there is no need -to update the libpng project each time when there is a change in -the list of zlib source files. After all, this list is private to -zlib, and applications (such as libpng) should not assume anything -about it. - -If you wish to contribute a project that builds zlib under Borland -C++ Builder, please submit it to the zlib developers, not to the -libpng developers. - -By default, the libpng project uses zlib as a static library. If -you wish to use zlib as a DLL, please read the important notes from -the zlib DLL FAQ, found inside the zlib distribution. diff --git a/irrlicht-1.6/source/Irrlicht/libpng/projects/netware.txt b/irrlicht-1.6/source/Irrlicht/libpng/projects/netware.txt deleted file mode 100644 index 4ba5ba3b3..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/projects/netware.txt +++ /dev/null @@ -1,6 +0,0 @@ -A set of project files is available for Netware. Get -libpng-1.2.5-project-netware.zip from a libpng distribution -site such as http://libpng.sourceforge.net - -Put the zip file in this directory (projects) and then run -"unzip -a libpng-1.2.5-project-netware.zip" diff --git a/irrlicht-1.6/source/Irrlicht/libpng/projects/visualc6/README.txt b/irrlicht-1.6/source/Irrlicht/libpng/projects/visualc6/README.txt deleted file mode 100644 index 863d39b95..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/projects/visualc6/README.txt +++ /dev/null @@ -1,57 +0,0 @@ -Microsoft Developer Studio Project File, Format Version 6.00 for libpng. - -Copyright (C) 2000-2004 Simon-Pierre Cadieux. -Copyright (C) 2004 Cosmin Truta. -For conditions of distribution and use, see copyright notice in png.h - - -Assumptions: -* The libpng source files are in ..\.. -* The zlib source files are in ..\..\..\zlib -* The zlib project files are in ..\..\..\zlib\projects\visualc6 - - -To use: - -1) On the main menu, select "File | Open Workspace". - Open "libpng.dsw". - -2) Select "Build | Set Active Configuration". - Choose the configuration you wish to build. - (Choose libpng or pngtest; zlib will be built automatically.) - -3) Select "Build | Clean". - -4) Select "Build | Build ... (F7)". Ignore warning messages about - not being able to find certain include files (e.g. alloc.h). - -5) If you built the sample program (pngtest), - select "Build | Execute ... (Ctrl+F5)". - - -This project builds the libpng binaries as follows: - -* Win32_DLL_Release\libpng13.dll DLL build -* Win32_DLL_Debug\libpng13d.dll DLL build (debug version) -* Win32_DLL_ASM_Release\libpng13.dll DLL build using ASM code -* Win32_DLL_ASM_Debug\libpng13d.dll DLL build using ASM (debug version) -* Win32_DLL_VB\libpng13vb.dll DLL build for Visual Basic, using stdcall -* Win32_LIB_Release\libpng.lib static build -* Win32_LIB_Debug\libpngd.lib static build (debug version) -* Win32_LIB_ASM_Release\libpng.lib static build using ASM code -* Win32_LIB_ASM_Debug\libpngd.lib static build using ASM (debug version) - - -Notes: - -If you change anything in the source files, or select different compiler -settings, please change the DLL name to something different than any of -the above names. Also, make sure that in your "pngusr.h" you define -PNG_USER_PRIVATEBUILD and PNG_USER_DLLFNAME_POSTFIX according to the -instructions provided in "pngconf.h". - -All DLLs built by this project use the Microsoft dynamic C runtime library -MSVCRT.DLL (MSVCRTD.DLL for debug versions). If you distribute any of the -above mentioned libraries you should also include this DLL in your package. -For a list of files that are redistributable in Visual C++ 6.0, see -Common\Redist\Redist.txt on Disc 1 of the Visual C++ 6.0 product CDs. diff --git a/irrlicht-1.6/source/Irrlicht/libpng/projects/visualc6/libpng.dsp b/irrlicht-1.6/source/Irrlicht/libpng/projects/visualc6/libpng.dsp deleted file mode 100644 index 223362a9f..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/projects/visualc6/libpng.dsp +++ /dev/null @@ -1,507 +0,0 @@ -# Microsoft Developer Studio Project File - Name="libpng" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -CFG=libpng - Win32 DLL Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "libpng.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "libpng.mak" CFG="libpng - Win32 DLL Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "libpng - Win32 DLL Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "libpng - Win32 DLL Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "libpng - Win32 DLL ASM Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "libpng - Win32 DLL ASM Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "libpng - Win32 DLL VB" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "libpng - Win32 LIB Release" (based on "Win32 (x86) Static Library") -!MESSAGE "libpng - Win32 LIB Debug" (based on "Win32 (x86) Static Library") -!MESSAGE "libpng - Win32 LIB ASM Release" (based on "Win32 (x86) Static Library") -!MESSAGE "libpng - Win32 LIB ASM Debug" (based on "Win32 (x86) Static Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" - -!IF "$(CFG)" == "libpng - Win32 DLL Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "libpng___Win32_DLL_Release" -# PROP BASE Intermediate_Dir "libpng___Win32_DLL_Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Win32_DLL_Release" -# PROP Intermediate_Dir "Win32_DLL_Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -CPP=cl.exe -# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c -# SUBTRACT BASE CPP /YX /Yc /Yu -# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /FD /c -# SUBTRACT CPP /YX /Yc /Yu -MTL=midl.exe -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -RSC=rc.exe -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /dll /machine:I386 -# ADD LINK32 zlib1.lib /nologo /dll /machine:I386 /out:"Win32_DLL_Release\libpng13.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_Release" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "libpng___Win32_DLL_Release" -# PROP BASE Intermediate_Dir "libpng___Win32_DLL_Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Win32_DLL_Debug" -# PROP Intermediate_Dir "Win32_DLL_Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -CPP=cl.exe -# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c -# SUBTRACT BASE CPP /YX /Yc /Yu -# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "DEBUG" /D PNG_DEBUG=1 /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /FD /GZ /c -# SUBTRACT CPP /YX /Yc /Yu -MTL=midl.exe -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -RSC=rc.exe -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /i "..\.." /d "_DEBUG" /d PNG_DEBUG=1 -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 zlib1d.lib /nologo /dll /debug /machine:I386 /out:"Win32_DLL_Debug\libpng13d.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_Debug" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "libpng___Win32_DLL_ASM_Release" -# PROP BASE Intermediate_Dir "libpng___Win32_DLL_ASM_Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Win32_DLL_ASM_Release" -# PROP Intermediate_Dir "Win32_DLL_ASM_Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -CPP=cl.exe -# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c -# SUBTRACT BASE CPP /YX /Yc /Yu -# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_USE_PNGVCRD" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /D "PNG_LIBPNG_SPECIALBUILD" /FD /c -# SUBTRACT CPP /YX /Yc /Yu -MTL=midl.exe -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -RSC=rc.exe -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG" /d PNG_LIBPNG_SPECIALBUILD=""""Use MMX instructions"""" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /dll /machine:I386 -# ADD LINK32 zlib1.lib /nologo /dll /machine:I386 /out:"Win32_DLL_ASM_Release\libpng13.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_ASM_Release" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "libpng___Win32_DLL_ASM_Debug" -# PROP BASE Intermediate_Dir "libpng___Win32_DLL_ASM_Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Win32_DLL_ASM_Debug" -# PROP Intermediate_Dir "Win32_DLL_ASM_Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -CPP=cl.exe -# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c -# SUBTRACT BASE CPP /YX /Yc /Yu -# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "DEBUG" /D PNG_DEBUG=1 /D "PNG_USE_PNGVCRD" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /D "PNG_LIBPNG_SPECIALBUILD" /FD /GZ /c -# SUBTRACT CPP /YX /Yc /Yu -MTL=midl.exe -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -RSC=rc.exe -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /i "..\.." /d "_DEBUG" /d PNG_DEBUG=1 /d PNG_LIBPNG_SPECIALBUILD=""""Use MMX instructions"""" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 zlib1d.lib /nologo /dll /debug /machine:I386 /out:"Win32_DLL_ASM_Debug\libpng13d.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_ASM_Debug" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL VB" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "libpng___Win32_DLL_VB" -# PROP BASE Intermediate_Dir "libpng___Win32_DLL_VB" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Win32_DLL_VB" -# PROP Intermediate_Dir "Win32_DLL_VB" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -CPP=cl.exe -# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c -# SUBTRACT BASE CPP /YX /Yc /Yu -# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /D PNGAPI=__stdcall /D "PNG_NO_MODULEDEF" /D "PNG_LIBPNG_SPECIALBUILD" /FD /c -# SUBTRACT CPP /YX /Yc /Yu -MTL=midl.exe -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -RSC=rc.exe -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG" /dPNG_LIBPNG_DLLFNAME_POSTFIX=""""VB"""" /dPNG_LIBPNG_SPECIALBUILD=""""__stdcall calling convention used for exported functions"""" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /dll /machine:I386 -# ADD LINK32 zlib1.lib /nologo /dll /machine:I386 /out:"Win32_DLL_VB\libpng13vb.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_Release" -# Begin Special Build Tool -OutDir=.\Win32_DLL_VB -TargetName=libpng13vb -SOURCE="$(InputPath)" -PostBuild_Cmds=echo Deleting $(targetname) import library and export file (Not required for VB projects) del $(outdir)\$(targetname).lib del $(outdir)\$(targetname).exp -# End Special Build Tool - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "libpng___Win32_LIB_Release" -# PROP BASE Intermediate_Dir "libpng___Win32_LIB_Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Win32_LIB_Release" -# PROP Intermediate_Dir "Win32_LIB_Release" -# PROP Target_Dir "" -CPP=cl.exe -# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c -# SUBTRACT BASE CPP /YX /Yc /Yu -# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /FD /c -# SUBTRACT CPP /YX /Yc /Yu -RSC=rc.exe -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "libpng___Win32_LIB_Debug" -# PROP BASE Intermediate_Dir "libpng___Win32_LIB_Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Win32_LIB_Debug" -# PROP Intermediate_Dir "Win32_LIB_Debug" -# PROP Target_Dir "" -CPP=cl.exe -# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c -# SUBTRACT BASE CPP /YX /Yc /Yu -# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "DEBUG" /D PNG_DEBUG=1 /FD /GZ /c -# SUBTRACT CPP /YX /Yc /Yu -RSC=rc.exe -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"Win32_LIB_Debug\libpngd.lib" - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB ASM Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "libpng___Win32_LIB_ASM_Release" -# PROP BASE Intermediate_Dir "libpng___Win32_LIB_ASM_Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Win32_LIB_ASM_Release" -# PROP Intermediate_Dir "Win32_LIB_ASM_Release" -# PROP Target_Dir "" -CPP=cl.exe -# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c -# SUBTRACT BASE CPP /YX /Yc /Yu -# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_USE_PNGVCRD" /D "PNG_LIBPNG_SPECIALBUILD" /FD /c -# SUBTRACT CPP /YX /Yc /Yu -RSC=rc.exe -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB ASM Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "libpng___Win32_LIB_ASM_Debug" -# PROP BASE Intermediate_Dir "libpng___Win32_LIB_ASM_Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Win32_LIB_ASM_Debug" -# PROP Intermediate_Dir "Win32_LIB_ASM_Debug" -# PROP Target_Dir "" -CPP=cl.exe -# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c -# SUBTRACT BASE CPP /YX /Yc /Yu -# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "DEBUG" /D PNG_DEBUG=1 /D "PNG_USE_PNGVCRD" /D "PNG_LIBPNG_SPECIALBUILD" /FD /GZ /c -# SUBTRACT CPP /YX /Yc /Yu -RSC=rc.exe -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"Win32_LIB_ASM_Debug\libpngd.lib" - -!ENDIF - -# Begin Target - -# Name "libpng - Win32 DLL Release" -# Name "libpng - Win32 DLL Debug" -# Name "libpng - Win32 DLL ASM Release" -# Name "libpng - Win32 DLL ASM Debug" -# Name "libpng - Win32 DLL VB" -# Name "libpng - Win32 LIB Release" -# Name "libpng - Win32 LIB Debug" -# Name "libpng - Win32 LIB ASM Release" -# Name "libpng - Win32 LIB ASM Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=..\..\png.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngerror.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngget.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngmem.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngpread.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngread.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngrio.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngrtran.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngrutil.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngset.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngtrans.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngvcrd.c - -!IF "$(CFG)" == "libpng - Win32 DLL Release" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM Release" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM Debug" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL VB" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB Release" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB Debug" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB ASM Release" - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB ASM Debug" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=..\..\scripts\pngw32.def - -!IF "$(CFG)" == "libpng - Win32 DLL Release" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM Release" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM Debug" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL VB" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB Release" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB Debug" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB ASM Release" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB ASM Debug" - -# PROP Exclude_From_Build 1 - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=..\..\pngwio.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngwrite.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngwtran.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngwutil.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=..\..\png.h -# End Source File -# Begin Source File - -SOURCE=..\..\pngconf.h -# End Source File -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" -# Begin Source File - -SOURCE=..\..\scripts\pngw32.rc - -!IF "$(CFG)" == "libpng - Win32 DLL Release" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM Release" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM Debug" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL VB" - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB Release" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB Debug" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB ASM Release" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB ASM Debug" - -# PROP Exclude_From_Build 1 - -!ENDIF - -# End Source File -# End Group -# Begin Source File - -SOURCE=.\README.txt -# End Source File -# End Target -# End Project diff --git a/irrlicht-1.6/source/Irrlicht/libpng/projects/visualc6/libpng.dsw b/irrlicht-1.6/source/Irrlicht/libpng/projects/visualc6/libpng.dsw deleted file mode 100644 index 2a9864674..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/projects/visualc6/libpng.dsw +++ /dev/null @@ -1,59 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "libpng"=".\libpng.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name zlib - End Project Dependency -}}} - -############################################################################### - -Project: "pngtest"=".\pngtest.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name libpng - End Project Dependency -}}} - -############################################################################### - -Project: "zlib"="..\..\..\zlib\projects\visualc6\zlib.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/irrlicht-1.6/source/Irrlicht/libpng/projects/visualc6/pngtest.dsp b/irrlicht-1.6/source/Irrlicht/libpng/projects/visualc6/pngtest.dsp deleted file mode 100644 index 2e5845c95..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/projects/visualc6/pngtest.dsp +++ /dev/null @@ -1,314 +0,0 @@ -# Microsoft Developer Studio Project File - Name="pngtest" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=pngtest - Win32 DLL Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "pngtest.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "pngtest.mak" CFG="pngtest - Win32 DLL Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "pngtest - Win32 DLL Release" (based on "Win32 (x86) Console Application") -!MESSAGE "pngtest - Win32 DLL Debug" (based on "Win32 (x86) Console Application") -!MESSAGE "pngtest - Win32 DLL ASM Release" (based on "Win32 (x86) Console Application") -!MESSAGE "pngtest - Win32 DLL ASM Debug" (based on "Win32 (x86) Console Application") -!MESSAGE "pngtest - Win32 LIB Release" (based on "Win32 (x86) Console Application") -!MESSAGE "pngtest - Win32 LIB Debug" (based on "Win32 (x86) Console Application") -!MESSAGE "pngtest - Win32 LIB ASM Release" (based on "Win32 (x86) Console Application") -!MESSAGE "pngtest - Win32 LIB ASM Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "pngtest - Win32 DLL Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "pngtest___Win32_DLL_Release" -# PROP BASE Intermediate_Dir "pngtest___Win32_DLL_Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Win32_DLL_Release" -# PROP Intermediate_Dir "Win32_DLL_Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c -# SUBTRACT BASE CPP /YX -# ADD CPP /nologo /MD /W3 /O2 /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /subsystem:console /machine:I386 -# ADD LINK32 Win32_DLL_Release\libpng13.lib ..\..\..\zlib\projects\visualc6\Win32_DLL_Release\zlib1.lib /nologo /subsystem:console /machine:I386 -# Begin Special Build Tool -OutDir=.\Win32_DLL_Release -SOURCE="$(InputPath)" -PostBuild_Desc=[Run Test] -PostBuild_Cmds=set path=$(outdir);..\..\..\zlib\projects\visualc6\Win32_DLL_Release; $(outdir)\pngtest.exe ..\..\pngtest.png -# End Special Build Tool - -!ELSEIF "$(CFG)" == "pngtest - Win32 DLL Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "pngtest___Win32_DLL_Debug" -# PROP BASE Intermediate_Dir "pngtest___Win32_DLL_Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Win32_DLL_Debug" -# PROP Intermediate_Dir "Win32_DLL_Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c -# SUBTRACT BASE CPP /YX -# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "PNG_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 Win32_DLL_Debug\libpng13d.lib ..\..\..\zlib\projects\visualc6\Win32_DLL_Debug\zlib1d.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# Begin Special Build Tool -OutDir=.\Win32_DLL_Debug -SOURCE="$(InputPath)" -PostBuild_Desc=[Run Test] -PostBuild_Cmds=set path=$(outdir);..\..\..\zlib\projects\visualc6\Win32_DLL_Debug; $(outdir)\pngtest.exe ..\..\pngtest.png -# End Special Build Tool - -!ELSEIF "$(CFG)" == "pngtest - Win32 DLL ASM Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "pngtest___Win32_DLL_ASM_Release" -# PROP BASE Intermediate_Dir "pngtest___Win32_DLL_ASM_Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Win32_DLL_ASM_Release" -# PROP Intermediate_Dir "Win32_DLL_ASM_Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c -# SUBTRACT BASE CPP /YX -# ADD CPP /nologo /MD /W3 /O2 /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /subsystem:console /machine:I386 -# ADD LINK32 Win32_DLL_ASM_Release\libpng13.lib ..\..\..\zlib\projects\visualc6\Win32_DLL_ASM_Release\zlib1.lib /nologo /subsystem:console /machine:I386 -# Begin Special Build Tool -OutDir=.\Win32_DLL_ASM_Release -SOURCE="$(InputPath)" -PostBuild_Desc=[Run Test] -PostBuild_Cmds=set path=$(outdir);..\..\..\zlib\projects\visualc6\Win32_DLL_ASM_Release; $(outdir)\pngtest.exe ..\..\pngtest.png -# End Special Build Tool - -!ELSEIF "$(CFG)" == "pngtest - Win32 DLL ASM Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "pngtest___Win32_DLL_ASM_Debug" -# PROP BASE Intermediate_Dir "pngtest___Win32_DLL_ASM_Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Win32_DLL_ASM_Debug" -# PROP Intermediate_Dir "Win32_DLL_ASM_Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c -# SUBTRACT BASE CPP /YX -# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "PNG_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 Win32_DLL_ASM_Debug\libpng13d.lib ..\..\..\zlib\projects\visualc6\Win32_DLL_ASM_Debug\zlib1d.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# Begin Special Build Tool -OutDir=.\Win32_DLL_ASM_Debug -SOURCE="$(InputPath)" -PostBuild_Desc=[Run Test] -PostBuild_Cmds=set path=$(outdir);..\..\..\zlib\projects\visualc6\Win32_DLL_ASM_Debug; $(outdir)\pngtest.exe ..\..\pngtest.png -# End Special Build Tool - -!ELSEIF "$(CFG)" == "pngtest - Win32 LIB Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "pngtest___Win32_LIB_Release" -# PROP BASE Intermediate_Dir "pngtest___Win32_LIB_Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Win32_LIB_Release" -# PROP Intermediate_Dir "Win32_LIB_Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c -# SUBTRACT BASE CPP /YX -# ADD CPP /nologo /MD /W3 /O2 /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /FD /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /subsystem:console /machine:I386 -# ADD LINK32 Win32_LIB_Release\libpng.lib ..\..\..\zlib\projects\visualc6\Win32_LIB_Release\zlib.lib /nologo /subsystem:console /machine:I386 -# Begin Special Build Tool -OutDir=.\Win32_LIB_Release -SOURCE="$(InputPath)" -PostBuild_Desc=[Run Test] -PostBuild_Cmds=$(outdir)\pngtest.exe ..\..\pngtest.png -# End Special Build Tool - -!ELSEIF "$(CFG)" == "pngtest - Win32 LIB Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "pngtest___Win32_LIB_Debug" -# PROP BASE Intermediate_Dir "pngtest___Win32_LIB_Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Win32_LIB_Debug" -# PROP Intermediate_Dir "Win32_LIB_Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c -# SUBTRACT BASE CPP /YX -# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 Win32_LIB_Debug\libpngd.lib ..\..\..\zlib\projects\visualc6\Win32_LIB_Debug\zlibd.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# Begin Special Build Tool -OutDir=.\Win32_LIB_Debug -SOURCE="$(InputPath)" -PostBuild_Desc=[Run Test] -PostBuild_Cmds=$(outdir)\pngtest.exe ..\..\pngtest.png -# End Special Build Tool - -!ELSEIF "$(CFG)" == "pngtest - Win32 LIB ASM Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "pngtest___Win32_LIB_ASM_Release" -# PROP BASE Intermediate_Dir "pngtest___Win32_LIB_ASM_Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Win32_LIB_ASM_Release" -# PROP Intermediate_Dir "Win32_LIB_ASM_Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c -# SUBTRACT BASE CPP /YX -# ADD CPP /nologo /MD /W3 /O2 /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /FD /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /subsystem:console /machine:I386 -# ADD LINK32 Win32_LIB_ASM_Release\libpng.lib ..\..\..\zlib\projects\visualc6\Win32_LIB_ASM_Release\zlib.lib /nologo /subsystem:console /machine:I386 -# Begin Special Build Tool -OutDir=.\Win32_LIB_ASM_Release -SOURCE="$(InputPath)" -PostBuild_Desc=[Run Test] -PostBuild_Cmds=$(outdir)\pngtest.exe ..\..\pngtest.png -# End Special Build Tool - -!ELSEIF "$(CFG)" == "pngtest - Win32 LIB ASM Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "pngtest___Win32_LIB_ASM_Debug" -# PROP BASE Intermediate_Dir "pngtest___Win32_LIB_ASM_Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Win32_LIB_ASM_Debug" -# PROP Intermediate_Dir "Win32_LIB_ASM_Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c -# SUBTRACT BASE CPP /YX -# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 Win32_LIB_ASM_Debug\libpngd.lib ..\..\..\zlib\projects\visualc6\Win32_LIB_ASM_Debug\zlibd.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# Begin Special Build Tool -OutDir=.\Win32_LIB_ASM_Debug -SOURCE="$(InputPath)" -PostBuild_Desc=[Run Test] -PostBuild_Cmds=$(outdir)\pngtest.exe ..\..\pngtest.png -# End Special Build Tool - -!ENDIF - -# Begin Target - -# Name "pngtest - Win32 DLL Release" -# Name "pngtest - Win32 DLL Debug" -# Name "pngtest - Win32 DLL ASM Release" -# Name "pngtest - Win32 DLL ASM Debug" -# Name "pngtest - Win32 LIB Release" -# Name "pngtest - Win32 LIB Debug" -# Name "pngtest - Win32 LIB ASM Release" -# Name "pngtest - Win32 LIB ASM Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=..\..\pngtest.c -# End Source File -# End Group -# End Target -# End Project diff --git a/irrlicht-1.6/source/Irrlicht/libpng/projects/visualc71/PRJ0041.mak b/irrlicht-1.6/source/Irrlicht/libpng/projects/visualc71/PRJ0041.mak deleted file mode 100644 index 3a597b023..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/projects/visualc71/PRJ0041.mak +++ /dev/null @@ -1,21 +0,0 @@ -# Prevent "Cannot find missing dependency..." warnings while compiling -# pngw32.rc (PRJ0041). - -all: $(IntDir)\alloc.h \ - $(IntDir)\fp.h \ - $(IntDir)\m68881.h \ - $(IntDir)\mem.h \ - $(IntDir)\pngusr.h \ - $(IntDir)\strings.h \ - $(IntDir)\unistd.h \ - $(IntDir)\unixio.h - -$(IntDir)\alloc.h \ -$(IntDir)\fp.h \ -$(IntDir)\m68881.h \ -$(IntDir)\mem.h \ -$(IntDir)\pngusr.h \ -$(IntDir)\strings.h \ -$(IntDir)\unistd.h \ -$(IntDir)\unixio.h: - @!echo.>$@ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/projects/visualc71/README.txt b/irrlicht-1.6/source/Irrlicht/libpng/projects/visualc71/README.txt deleted file mode 100644 index e49af14e6..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/projects/visualc71/README.txt +++ /dev/null @@ -1,57 +0,0 @@ -Microsoft Developer Studio Project File, Format Version 7.10 for libpng. - -Copyright (C) 2004 Simon-Pierre Cadieux. -For conditions of distribution and use, see copyright notice in png.h - -Assumptions: -* The libpng source files are in ..\.. -* The zlib source files are in ..\..\..\zlib -* The zlib project file is in . /* Warning: This is until the zlib project - files get intergrated into the next zlib release. The final zlib project - directory will then be ..\..\..\zlib\projects\visualc71. */ - -To use: - -1) On the main menu, select "File | Open Solution". - Open "libpng.sln". - -2) Display the Solution Explorer view (Ctrl+Alt+L) - -3) Set one of the project as the StartUp project. If you just want to build the - binaries set "libpng" as the startup project (Select "libpng" tree view - item + Project | Set as StartUp project). If you want to build and test the - binaries set it to "pngtest" (Select "pngtest" tree view item + - Project | Set as StartUp project) - -4) Select "Build | Configuration Manager...". - Choose the configuration you wish to build. - -5) Select "Build | Clean Solution". - -6) Select "Build | Build Solution (Ctrl-Shift-B)" - -This project builds the libpng binaries as follows: - -* Win32_DLL_Release\libpng13.dll DLL build -* Win32_DLL_Debug\libpng13d.dll DLL build (debug version) -* Win32_DLL_ASM_Release\libpng13.dll DLL build using ASM code -* Win32_DLL_ASM_Debug\libpng13d.dll DLL build using ASM (debug version) -* Win32_DLL_VB\libpng13vb.dll DLL build for Visual Basic, using stdcall -* Win32_LIB_Release\libpng.lib static build -* Win32_LIB_Debug\libpngd.lib static build (debug version) -* Win32_LIB_ASM_Release\libpng.lib static build using ASM code -* Win32_LIB_ASM_Debug\libpngd.lib static build using ASM (debug version) - -Notes: - -If you change anything in the source files, or select different compiler -settings, please change the DLL name to something different than any of -the above names. Also, make sure that in your "pngusr.h" you define -PNG_USER_PRIVATEBUILD and PNG_USER_DLLFNAME_POSTFIX according to the -instructions provided in "pngconf.h". - -All DLLs built by this project use the Microsoft dynamic C runtime library -MSVCR71.DLL (MSVCR71D.DLL for debug versions). If you distribute any of the -above mentioned libraries you may have to include this DLL in your package. -For a list of files that are redistributable in Visual Studio see -$(VCINSTALLDIR)\redist.txt. diff --git a/irrlicht-1.6/source/Irrlicht/libpng/projects/visualc71/README_zlib.txt b/irrlicht-1.6/source/Irrlicht/libpng/projects/visualc71/README_zlib.txt deleted file mode 100644 index 589f5f42d..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/projects/visualc71/README_zlib.txt +++ /dev/null @@ -1,44 +0,0 @@ -/* WARNING: This file was put in the LibPNG distribution for convenience only. - It is expected to be part of the next zlib release under - "projects\visualc71\README.txt." */ - -Microsoft Developer Studio Project File, Format Version 7.10 for zlib. - -Copyright (C) 2004 Simon-Pierre Cadieux. -Copyright (C) 2004 Cosmin Truta. -For conditions of distribution and use, see copyright notice in zlib.h. - - -To use: - -1) On the main menu, select "File | Open Solution". - Open "zlib.sln". - -2) Display the Solution Explorer view (Ctrl+Alt+L) - -3) Set one of the project as the StartUp project. If you just want to build the - binaries set "zlib" as the startup project (Select "zlib" tree view item + - Project | Set as StartUp project). If you want to build and test the - binaries set it to "example" (Select "example" tree view item + Project | - Set as StartUp project), If you want to build the minigzip utility set it to - "minigzip" (Select "minigzip" tree view item + Project | Set as StartUp - project - -4) Select "Build | Configuration Manager...". - Choose the configuration you wish to build. - -5) Select "Build | Clean Solution". - -6) Select "Build | Build Solution (Ctrl-Shift-B)" - -This project builds the zlib binaries as follows: - -* Win32_DLL_Release\zlib1.dll DLL build -* Win32_DLL_Debug\zlib1d.dll DLL build (debug version) -* Win32_DLL_ASM_Release\zlib1.dll DLL build using ASM code -* Win32_DLL_ASM_Debug\zlib1d.dll DLL build using ASM code (debug version) -* Win32_LIB_Release\zlib.lib static build -* Win32_LIB_Debug\zlibd.lib static build (debug version) -* Win32_LIB_ASM_Release\zlib.lib static build using ASM code -* Win32_LIB_ASM_Debug\zlibd.lib static build using ASM code (debug version) - diff --git a/irrlicht-1.6/source/Irrlicht/libpng/projects/visualc71/libpng.sln b/irrlicht-1.6/source/Irrlicht/libpng/projects/visualc71/libpng.sln deleted file mode 100644 index 7f75b0c6b..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/projects/visualc71/libpng.sln +++ /dev/null @@ -1,88 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libpng", "libpng.vcproj", "{0008960E-E0DD-41A6-8265-00B31DDB4C21}" - ProjectSection(ProjectDependencies) = postProject - {2D4F8105-7D21-454C-9932-B47CAB71A5C0} = {2D4F8105-7D21-454C-9932-B47CAB71A5C0} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pngtest", "pngtest.vcproj", "{FD1C2F86-9EEF-47BD-95A4-530917E17FDA}" - ProjectSection(ProjectDependencies) = postProject - {0008960E-E0DD-41A6-8265-00B31DDB4C21} = {0008960E-E0DD-41A6-8265-00B31DDB4C21} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "zlib.vcproj", "{2D4F8105-7D21-454C-9932-B47CAB71A5C0}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfiguration) = preSolution - DLL ASM Debug = DLL ASM Debug - DLL ASM Release = DLL ASM Release - DLL Debug = DLL Debug - DLL Release = DLL Release - DLL VB = DLL VB - LIB ASM Debug = LIB ASM Debug - LIB ASM Release = LIB ASM Release - LIB Debug = LIB Debug - LIB Release = LIB Release - EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {0008960E-E0DD-41A6-8265-00B31DDB4C21}.DLL ASM Debug.ActiveCfg = DLL ASM Debug|Win32 - {0008960E-E0DD-41A6-8265-00B31DDB4C21}.DLL ASM Debug.Build.0 = DLL ASM Debug|Win32 - {0008960E-E0DD-41A6-8265-00B31DDB4C21}.DLL ASM Release.ActiveCfg = DLL ASM Release|Win32 - {0008960E-E0DD-41A6-8265-00B31DDB4C21}.DLL ASM Release.Build.0 = DLL ASM Release|Win32 - {0008960E-E0DD-41A6-8265-00B31DDB4C21}.DLL Debug.ActiveCfg = DLL Debug|Win32 - {0008960E-E0DD-41A6-8265-00B31DDB4C21}.DLL Debug.Build.0 = DLL Debug|Win32 - {0008960E-E0DD-41A6-8265-00B31DDB4C21}.DLL Release.ActiveCfg = DLL Release|Win32 - {0008960E-E0DD-41A6-8265-00B31DDB4C21}.DLL Release.Build.0 = DLL Release|Win32 - {0008960E-E0DD-41A6-8265-00B31DDB4C21}.DLL VB.ActiveCfg = DLL VB|Win32 - {0008960E-E0DD-41A6-8265-00B31DDB4C21}.DLL VB.Build.0 = DLL VB|Win32 - {0008960E-E0DD-41A6-8265-00B31DDB4C21}.LIB ASM Debug.ActiveCfg = LIB ASM Debug|Win32 - {0008960E-E0DD-41A6-8265-00B31DDB4C21}.LIB ASM Debug.Build.0 = LIB ASM Debug|Win32 - {0008960E-E0DD-41A6-8265-00B31DDB4C21}.LIB ASM Release.ActiveCfg = LIB ASM Release|Win32 - {0008960E-E0DD-41A6-8265-00B31DDB4C21}.LIB ASM Release.Build.0 = LIB ASM Release|Win32 - {0008960E-E0DD-41A6-8265-00B31DDB4C21}.LIB Debug.ActiveCfg = LIB Debug|Win32 - {0008960E-E0DD-41A6-8265-00B31DDB4C21}.LIB Debug.Build.0 = LIB Debug|Win32 - {0008960E-E0DD-41A6-8265-00B31DDB4C21}.LIB Release.ActiveCfg = LIB Release|Win32 - {0008960E-E0DD-41A6-8265-00B31DDB4C21}.LIB Release.Build.0 = LIB Release|Win32 - {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.DLL ASM Debug.ActiveCfg = DLL ASM Debug|Win32 - {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.DLL ASM Debug.Build.0 = DLL ASM Debug|Win32 - {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.DLL ASM Release.ActiveCfg = DLL ASM Release|Win32 - {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.DLL ASM Release.Build.0 = DLL ASM Release|Win32 - {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.DLL Debug.ActiveCfg = DLL Debug|Win32 - {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.DLL Debug.Build.0 = DLL Debug|Win32 - {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.DLL Release.ActiveCfg = DLL Release|Win32 - {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.DLL Release.Build.0 = DLL Release|Win32 - {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.DLL VB.ActiveCfg = DLL VB|Win32 - {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.DLL VB.Build.0 = DLL VB|Win32 - {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.LIB ASM Debug.ActiveCfg = LIB ASM Debug|Win32 - {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.LIB ASM Debug.Build.0 = LIB ASM Debug|Win32 - {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.LIB ASM Release.ActiveCfg = LIB ASM Release|Win32 - {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.LIB ASM Release.Build.0 = LIB ASM Release|Win32 - {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.LIB Debug.ActiveCfg = LIB Debug|Win32 - {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.LIB Debug.Build.0 = LIB Debug|Win32 - {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.LIB Release.ActiveCfg = LIB Release|Win32 - {FD1C2F86-9EEF-47BD-95A4-530917E17FDA}.LIB Release.Build.0 = LIB Release|Win32 - {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.DLL ASM Debug.ActiveCfg = DLL ASM Debug|Win32 - {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.DLL ASM Debug.Build.0 = DLL ASM Debug|Win32 - {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.DLL ASM Release.ActiveCfg = DLL ASM Release|Win32 - {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.DLL ASM Release.Build.0 = DLL ASM Release|Win32 - {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.DLL Debug.ActiveCfg = DLL Debug|Win32 - {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.DLL Debug.Build.0 = DLL Debug|Win32 - {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.DLL Release.ActiveCfg = DLL Release|Win32 - {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.DLL Release.Build.0 = DLL Release|Win32 - {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.DLL VB.ActiveCfg = DLL Release|Win32 - {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.DLL VB.Build.0 = DLL Release|Win32 - {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.LIB ASM Debug.ActiveCfg = LIB ASM Debug|Win32 - {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.LIB ASM Debug.Build.0 = LIB ASM Debug|Win32 - {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.LIB ASM Release.ActiveCfg = LIB ASM Release|Win32 - {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.LIB ASM Release.Build.0 = LIB ASM Release|Win32 - {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.LIB Debug.ActiveCfg = LIB Debug|Win32 - {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.LIB Debug.Build.0 = LIB Debug|Win32 - {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.LIB Release.ActiveCfg = LIB Release|Win32 - {2D4F8105-7D21-454C-9932-B47CAB71A5C0}.LIB Release.Build.0 = LIB Release|Win32 - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution - EndGlobalSection -EndGlobal diff --git a/irrlicht-1.6/source/Irrlicht/libpng/projects/visualc71/libpng.vcproj b/irrlicht-1.6/source/Irrlicht/libpng/projects/visualc71/libpng.vcproj deleted file mode 100644 index 19c631fdc..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/projects/visualc71/libpng.vcproj +++ /dev/null @@ -1,735 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?> -<VisualStudioProject - ProjectType="Visual C++" - Version="7.10" - Name="libpng" - RootNamespace="libpng"> - <Platforms> - <Platform - Name="Win32"/> - </Platforms> - <Configurations> - <Configuration - Name="DLL Release|Win32" - OutputDirectory=".\Win32_DLL_Release" - IntermediateDirectory=".\Win32_DLL_Release" - ConfigurationType="2"> - <Tool - Name="VCCLCompilerTool" - InlineFunctionExpansion="1" - AdditionalIncludeDirectories="..\..;..\..\..\zlib" - PreprocessorDefinitions="WIN32;NDEBUG;PNG_BUILD_DLL;ZLIB_DLL" - StringPooling="TRUE" - RuntimeLibrary="2" - EnableFunctionLevelLinking="TRUE" - UsePrecompiledHeader="3" - PrecompiledHeaderThrough="png.h" - WarningLevel="3" - CompileAs="0"/> - <Tool - Name="VCCustomBuildTool"/> - <Tool - Name="VCLinkerTool" - OutputFile="$(OutDir)/libpng13.dll" - LinkIncremental="1" - ModuleDefinitionFile="..\..\scripts\pngw32.def"/> - <Tool - Name="VCMIDLTool"/> - <Tool - Name="VCPostBuildEventTool"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="NDEBUG" - Culture="1033" - AdditionalIncludeDirectories="..\..;..\..\..\zlib;$(IntDir)"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCWebDeploymentTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - <Configuration - Name="DLL Debug|Win32" - OutputDirectory=".\Win32_DLL_Debug" - IntermediateDirectory=".\Win32_DLL_Debug" - ConfigurationType="2"> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - AdditionalIncludeDirectories="..\..;..\..\..\zlib" - PreprocessorDefinitions="WIN32;_DEBUG;DEBUG;PNG_DEBUG=1;PNG_BUILD_DLL;ZLIB_DLL" - BasicRuntimeChecks="3" - RuntimeLibrary="3" - UsePrecompiledHeader="3" - PrecompiledHeaderThrough="png.h" - WarningLevel="3" - DebugInformationFormat="4" - CompileAs="0"/> - <Tool - Name="VCCustomBuildTool"/> - <Tool - Name="VCLinkerTool" - OutputFile="$(OutDir)/libpng13d.dll" - ModuleDefinitionFile="..\..\scripts\pngw32.def" - GenerateDebugInformation="TRUE"/> - <Tool - Name="VCMIDLTool"/> - <Tool - Name="VCPostBuildEventTool"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="_DEBUG,PNG_DEBUG=1" - Culture="1033" - AdditionalIncludeDirectories="..\..;..\..\..\zlib;$(IntDir)"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCWebDeploymentTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - <Configuration - Name="DLL ASM Release|Win32" - OutputDirectory=".\Win32_DLL_ASM_Release" - IntermediateDirectory=".\Win32_DLL_ASM_Release" - ConfigurationType="2"> - <Tool - Name="VCCLCompilerTool" - InlineFunctionExpansion="1" - AdditionalIncludeDirectories="..\..;..\..\..\zlib" - PreprocessorDefinitions="WIN32;NDEBUG;PNG_USE_PNGVCRD;PNG_BUILD_DLL;ZLIB_DLL;PNG_LIBPNG_SPECIALBUILD" - StringPooling="TRUE" - RuntimeLibrary="2" - EnableFunctionLevelLinking="TRUE" - UsePrecompiledHeader="3" - PrecompiledHeaderThrough="png.h" - WarningLevel="3" - CompileAs="0"/> - <Tool - Name="VCCustomBuildTool"/> - <Tool - Name="VCLinkerTool" - OutputFile="$(OutDir)/libpng13.dll" - LinkIncremental="1" - ModuleDefinitionFile="..\..\scripts\pngw32.def"/> - <Tool - Name="VCMIDLTool"/> - <Tool - Name="VCPostBuildEventTool"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool" - AdditionalOptions="/d PNG_LIBPNG_SPECIALBUILD=""""Use MMX instructions""""" - PreprocessorDefinitions="NDEBUG" - Culture="1033" - AdditionalIncludeDirectories="..\..;..\..\..\zlib;$(IntDir)"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCWebDeploymentTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - <Configuration - Name="DLL ASM Debug|Win32" - OutputDirectory=".\Win32_DLL_ASM_Debug" - IntermediateDirectory=".\Win32_DLL_ASM_Debug" - ConfigurationType="2"> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - AdditionalIncludeDirectories="..\..;..\..\..\zlib" - PreprocessorDefinitions="WIN32;_DEBUG;DEBUG;PNG_DEBUG=1;PNG_USE_PNGVCRD;PNG_BUILD_DLL;ZLIB_DLL;PNG_LIBPNG_SPECIALBUILD" - BasicRuntimeChecks="3" - RuntimeLibrary="3" - UsePrecompiledHeader="3" - PrecompiledHeaderThrough="png.h" - WarningLevel="3" - DebugInformationFormat="4" - CompileAs="0"/> - <Tool - Name="VCCustomBuildTool"/> - <Tool - Name="VCLinkerTool" - OutputFile="$(OutDir)/libpng13d.dll" - ModuleDefinitionFile="..\..\scripts\pngw32.def" - GenerateDebugInformation="TRUE"/> - <Tool - Name="VCMIDLTool"/> - <Tool - Name="VCPostBuildEventTool"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool" - AdditionalOptions="/d PNG_LIBPNG_SPECIALBUILD=""""Use MMX instructions""""" - PreprocessorDefinitions="_DEBUG,PNG_DEBUG=1" - Culture="1033" - AdditionalIncludeDirectories="..\..;..\..\..\zlib;$(IntDir)"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCWebDeploymentTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - <Configuration - Name="DLL VB|Win32" - OutputDirectory=".\Win32_DLL_VB" - IntermediateDirectory=".\Win32_DLL_VB" - ConfigurationType="2"> - <Tool - Name="VCCLCompilerTool" - InlineFunctionExpansion="1" - AdditionalIncludeDirectories="..\..;..\..\..\zlib" - PreprocessorDefinitions="WIN32;NDEBUG;PNG_BUILD_DLL;ZLIB_DLL;PNGAPI=__stdcall;PNG_NO_MODULEDEF;PNG_LIBPNG_SPECIALBUILD" - StringPooling="TRUE" - RuntimeLibrary="2" - EnableFunctionLevelLinking="TRUE" - UsePrecompiledHeader="3" - PrecompiledHeaderThrough="png.h" - WarningLevel="3" - CompileAs="0"/> - <Tool - Name="VCCustomBuildTool"/> - <Tool - Name="VCLinkerTool" - OutputFile="$(OutDir)/libpng13vb.dll" - LinkIncremental="1"/> - <Tool - Name="VCMIDLTool"/> - <Tool - Name="VCPostBuildEventTool"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool" - AdditionalOptions="/d PNG_LIBPNG_DLLFNAME_POSTFIX=""""VB"""" /d PNG_LIBPNG_SPECIALBUILD=""""__stdcall calling convention used for exported functions""""" - PreprocessorDefinitions="NDEBUG" - Culture="1033" - AdditionalIncludeDirectories="..\..;..\..\..\zlib;$(IntDir)"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCWebDeploymentTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - <Configuration - Name="LIB Release|Win32" - OutputDirectory=".\Win32_LIB_Release" - IntermediateDirectory=".\Win32_LIB_Release" - ConfigurationType="4"> - <Tool - Name="VCCLCompilerTool" - InlineFunctionExpansion="1" - AdditionalIncludeDirectories="..\..;..\..\..\zlib" - PreprocessorDefinitions="WIN32;NDEBUG" - StringPooling="TRUE" - RuntimeLibrary="2" - EnableFunctionLevelLinking="TRUE" - UsePrecompiledHeader="3" - PrecompiledHeaderThrough="png.h" - WarningLevel="3" - CompileAs="0"/> - <Tool - Name="VCCustomBuildTool"/> - <Tool - Name="VCLibrarianTool" - OutputFile="$(OutDir)/libpng.lib"/> - <Tool - Name="VCMIDLTool"/> - <Tool - Name="VCPostBuildEventTool"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - <Configuration - Name="LIB Debug|Win32" - OutputDirectory=".\Win32_LIB_Debug" - IntermediateDirectory=".\Win32_LIB_Debug" - ConfigurationType="4"> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - AdditionalIncludeDirectories="..\..;..\..\..\zlib" - PreprocessorDefinitions="WIN32;_DEBUG;DEBUG;PNG_DEBUG=1" - BasicRuntimeChecks="3" - RuntimeLibrary="3" - UsePrecompiledHeader="3" - PrecompiledHeaderThrough="png.h" - WarningLevel="3" - DebugInformationFormat="4" - CompileAs="0"/> - <Tool - Name="VCCustomBuildTool"/> - <Tool - Name="VCLibrarianTool" - OutputFile="$(OutDir)/libpngd.lib"/> - <Tool - Name="VCMIDLTool"/> - <Tool - Name="VCPostBuildEventTool"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - <Configuration - Name="LIB ASM Release|Win32" - OutputDirectory=".\Win32_LIB_ASM_Release" - IntermediateDirectory=".\Win32_LIB_ASM_Release" - ConfigurationType="4"> - <Tool - Name="VCCLCompilerTool" - InlineFunctionExpansion="1" - AdditionalIncludeDirectories="..\..,..\..\..\zlib" - PreprocessorDefinitions="WIN32;NDEBUG;PNG_USE_PNGVCRD;PNG_LIBPNG_SPECIALBUILD" - StringPooling="TRUE" - RuntimeLibrary="2" - EnableFunctionLevelLinking="TRUE" - UsePrecompiledHeader="3" - PrecompiledHeaderThrough="png.h" - WarningLevel="3" - CompileAs="0"/> - <Tool - Name="VCCustomBuildTool"/> - <Tool - Name="VCLibrarianTool" - OutputFile="$(OutDir)/libpng.lib"/> - <Tool - Name="VCMIDLTool"/> - <Tool - Name="VCPostBuildEventTool"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - <Configuration - Name="LIB ASM Debug|Win32" - OutputDirectory=".\Win32_LIB_ASM_Debug" - IntermediateDirectory=".\Win32_LIB_ASM_Debug" - ConfigurationType="4"> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - AdditionalIncludeDirectories="..\..,..\..\..\zlib" - PreprocessorDefinitions="WIN32;_DEBUG;DEBUG;PNG_DEBUG=1;PNG_USE_PNGVCRD;PNG_LIBPNG_SPECIALBUILD" - BasicRuntimeChecks="3" - RuntimeLibrary="3" - UsePrecompiledHeader="3" - PrecompiledHeaderThrough="png.h" - WarningLevel="3" - DebugInformationFormat="4" - CompileAs="0"/> - <Tool - Name="VCCustomBuildTool"/> - <Tool - Name="VCLibrarianTool" - OutputFile="$(OutDir)/libpngd.lib"/> - <Tool - Name="VCMIDLTool"/> - <Tool - Name="VCPostBuildEventTool"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - </Configurations> - <References> - </References> - <Files> - <Filter - Name="Source Files" - Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"> - <File - RelativePath="..\..\png.c"> - <FileConfiguration - Name="DLL Release|Win32"> - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="0"/> - </FileConfiguration> - <FileConfiguration - Name="DLL Debug|Win32"> - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="0"/> - </FileConfiguration> - <FileConfiguration - Name="DLL ASM Release|Win32"> - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="0"/> - </FileConfiguration> - <FileConfiguration - Name="DLL ASM Debug|Win32"> - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="0"/> - </FileConfiguration> - <FileConfiguration - Name="DLL VB|Win32"> - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="0"/> - </FileConfiguration> - <FileConfiguration - Name="LIB Release|Win32"> - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="0"/> - </FileConfiguration> - <FileConfiguration - Name="LIB Debug|Win32"> - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="0"/> - </FileConfiguration> - <FileConfiguration - Name="LIB ASM Release|Win32"> - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="0"/> - </FileConfiguration> - <FileConfiguration - Name="LIB ASM Debug|Win32"> - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="0"/> - </FileConfiguration> - </File> - <File - RelativePath="..\..\pngerror.c"> - <FileConfiguration - Name="DLL Release|Win32"> - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="1"/> - </FileConfiguration> - <FileConfiguration - Name="DLL Debug|Win32"> - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="1"/> - </FileConfiguration> - <FileConfiguration - Name="DLL ASM Release|Win32"> - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="1"/> - </FileConfiguration> - <FileConfiguration - Name="DLL ASM Debug|Win32"> - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="1"/> - </FileConfiguration> - <FileConfiguration - Name="DLL VB|Win32"> - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="1"/> - </FileConfiguration> - <FileConfiguration - Name="LIB Release|Win32"> - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="1"/> - </FileConfiguration> - <FileConfiguration - Name="LIB Debug|Win32"> - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="1"/> - </FileConfiguration> - <FileConfiguration - Name="LIB ASM Release|Win32"> - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="1"/> - </FileConfiguration> - <FileConfiguration - Name="LIB ASM Debug|Win32"> - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="1"/> - </FileConfiguration> - </File> - <File - RelativePath="..\..\pngget.c"> - </File> - <File - RelativePath="..\..\pngmem.c"> - </File> - <File - RelativePath="..\..\pngpread.c"> - </File> - <File - RelativePath="..\..\pngread.c"> - </File> - <File - RelativePath="..\..\pngrio.c"> - </File> - <File - RelativePath="..\..\pngrtran.c"> - </File> - <File - RelativePath="..\..\pngrutil.c"> - </File> - <File - RelativePath="..\..\pngset.c"> - </File> - <File - RelativePath="..\..\pngtrans.c"> - </File> - <File - RelativePath="..\..\pngvcrd.c"> - <FileConfiguration - Name="DLL Release|Win32" - ExcludedFromBuild="TRUE"> - <Tool - Name="VCCLCompilerTool"/> - </FileConfiguration> - <FileConfiguration - Name="DLL Debug|Win32" - ExcludedFromBuild="TRUE"> - <Tool - Name="VCCLCompilerTool"/> - </FileConfiguration> - <FileConfiguration - Name="DLL VB|Win32" - ExcludedFromBuild="TRUE"> - <Tool - Name="VCCLCompilerTool"/> - </FileConfiguration> - <FileConfiguration - Name="LIB Release|Win32" - ExcludedFromBuild="TRUE"> - <Tool - Name="VCCLCompilerTool"/> - </FileConfiguration> - <FileConfiguration - Name="LIB Debug|Win32" - ExcludedFromBuild="TRUE"> - <Tool - Name="VCCLCompilerTool"/> - </FileConfiguration> - </File> - <File - RelativePath="..\..\scripts\pngw32.def"> - <FileConfiguration - Name="DLL VB|Win32" - ExcludedFromBuild="TRUE"> - <Tool - Name="VCCustomBuildTool"/> - </FileConfiguration> - <FileConfiguration - Name="LIB Release|Win32" - ExcludedFromBuild="TRUE"> - <Tool - Name="VCCustomBuildTool"/> - </FileConfiguration> - <FileConfiguration - Name="LIB Debug|Win32" - ExcludedFromBuild="TRUE"> - <Tool - Name="VCCustomBuildTool"/> - </FileConfiguration> - <FileConfiguration - Name="LIB ASM Release|Win32" - ExcludedFromBuild="TRUE"> - <Tool - Name="VCCustomBuildTool"/> - </FileConfiguration> - <FileConfiguration - Name="LIB ASM Debug|Win32" - ExcludedFromBuild="TRUE"> - <Tool - Name="VCCustomBuildTool"/> - </FileConfiguration> - </File> - <File - RelativePath="..\..\pngwio.c"> - </File> - <File - RelativePath="..\..\pngwrite.c"> - </File> - <File - RelativePath="..\..\pngwtran.c"> - </File> - <File - RelativePath="..\..\pngwutil.c"> - </File> - </Filter> - <Filter - Name="Header Files" - Filter="h;hpp;hxx;hm;inl"> - <File - RelativePath="..\..\png.h"> - </File> - <File - RelativePath="..\..\pngconf.h"> - </File> - </Filter> - <Filter - Name="Resource Files" - Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"> - <File - RelativePath="..\..\scripts\pngw32.rc"> - <FileConfiguration - Name="LIB Release|Win32" - ExcludedFromBuild="TRUE"> - <Tool - Name="VCResourceCompilerTool"/> - </FileConfiguration> - <FileConfiguration - Name="LIB Debug|Win32" - ExcludedFromBuild="TRUE"> - <Tool - Name="VCResourceCompilerTool"/> - </FileConfiguration> - <FileConfiguration - Name="LIB ASM Release|Win32" - ExcludedFromBuild="TRUE"> - <Tool - Name="VCResourceCompilerTool"/> - </FileConfiguration> - <FileConfiguration - Name="LIB ASM Debug|Win32" - ExcludedFromBuild="TRUE"> - <Tool - Name="VCResourceCompilerTool"/> - </FileConfiguration> - </File> - </Filter> - <File - RelativePath=".\PRJ0041.mak"> - <FileConfiguration - Name="DLL Release|Win32"> - <Tool - Name="VCCustomBuildTool" - Description="Create dummy include files to prevent "Cannot find missing dependency..." warnings." - CommandLine="nmake -f PRJ0041.mak IntDir=$(IntDir)" - Outputs="$(IntDir)\alloc.h;$(IntDir)\fp.h;$(IntDir)\m68881.h;$(IntDir)\mem.h;$(IntDir)\pngusr.h;$(IntDir)\strings.h;$(IntDir)\unistd.h;$(IntDir)\unixio.h"/> - </FileConfiguration> - <FileConfiguration - Name="DLL Debug|Win32"> - <Tool - Name="VCCustomBuildTool" - Description="Create dummy include files to prevent "Cannot find missing dependency..." warnings." - CommandLine="nmake -f PRJ0041.mak IntDir=$(IntDir)" - Outputs="$(IntDir)\alloc.h;$(IntDir)\fp.h;$(IntDir)\m68881.h;$(IntDir)\mem.h;$(IntDir)\pngusr.h;$(IntDir)\strings.h;$(IntDir)\unistd.h;$(IntDir)\unixio.h"/> - </FileConfiguration> - <FileConfiguration - Name="DLL ASM Release|Win32"> - <Tool - Name="VCCustomBuildTool" - Description="Create dummy include files to prevent "Cannot find missing dependency..." warnings." - CommandLine="nmake -f PRJ0041.mak IntDir=$(IntDir)" - Outputs="$(IntDir)\alloc.h;$(IntDir)\fp.h;$(IntDir)\m68881.h;$(IntDir)\mem.h;$(IntDir)\pngusr.h;$(IntDir)\strings.h;$(IntDir)\unistd.h;$(IntDir)\unixio.h"/> - </FileConfiguration> - <FileConfiguration - Name="DLL ASM Debug|Win32"> - <Tool - Name="VCCustomBuildTool" - Description="Create dummy include files to prevent "Cannot find missing dependency..." warnings." - CommandLine="nmake -f PRJ0041.mak IntDir=$(IntDir)" - Outputs="$(IntDir)\alloc.h;$(IntDir)\fp.h;$(IntDir)\m68881.h;$(IntDir)\mem.h;$(IntDir)\pngusr.h;$(IntDir)\strings.h;$(IntDir)\unistd.h;$(IntDir)\unixio.h"/> - </FileConfiguration> - <FileConfiguration - Name="DLL VB|Win32"> - <Tool - Name="VCCustomBuildTool" - Description="Create dummy include files to prevent "Cannot find missing dependency..." warnings." - CommandLine="nmake -f PRJ0041.mak IntDir=$(IntDir)" - Outputs="$(IntDir)\alloc.h;$(IntDir)\fp.h;$(IntDir)\m68881.h;$(IntDir)\mem.h;$(IntDir)\pngusr.h;$(IntDir)\strings.h;$(IntDir)\unistd.h;$(IntDir)\unixio.h"/> - </FileConfiguration> - </File> - <File - RelativePath="README.txt"> - </File> - </Files> - <Globals> - </Globals> -</VisualStudioProject> diff --git a/irrlicht-1.6/source/Irrlicht/libpng/projects/visualc71/pngtest.vcproj b/irrlicht-1.6/source/Irrlicht/libpng/projects/visualc71/pngtest.vcproj deleted file mode 100644 index 210566c5a..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/projects/visualc71/pngtest.vcproj +++ /dev/null @@ -1,459 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?> -<VisualStudioProject - ProjectType="Visual C++" - Version="7.10" - Name="pngtest" - RootNamespace="pngtest"> - <Platforms> - <Platform - Name="Win32"/> - </Platforms> - <Configurations> - <Configuration - Name="DLL Release|Win32" - OutputDirectory=".\Win32_DLL_Release\Test" - IntermediateDirectory=".\Win32_DLL_Release\Test" - ConfigurationType="1"> - <Tool - Name="VCCLCompilerTool" - InlineFunctionExpansion="1" - AdditionalIncludeDirectories="..\..\..\zlib" - PreprocessorDefinitions="WIN32;NDEBUG;PNG_DLL;PNG_NO_STDIO;PNG_NO_GLOBAL_ARRAYS" - StringPooling="TRUE" - RuntimeLibrary="2" - EnableFunctionLevelLinking="TRUE" - WarningLevel="3" - CompileAs="0"/> - <Tool - Name="VCCustomBuildTool" - Description="Testing..." - CommandLine="set path=$(OutDir)\..;$(OutDir)\..\ZLib -$(TargetPath) ..\..\pngtest.png $(IntDir)\pngout.png" - Outputs="$(IntDir)\pngout.png"/> - <Tool - Name="VCLinkerTool" - OutputFile="$(OutDir)/pngtest.exe" - LinkIncremental="1" - SubSystem="1"/> - <Tool - Name="VCMIDLTool"/> - <Tool - Name="VCPostBuildEventTool"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCWebDeploymentTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - <Configuration - Name="DLL Debug|Win32" - OutputDirectory=".\Win32_DLL_Debug\Test" - IntermediateDirectory=".\Win32_DLL_Debug\Test" - ConfigurationType="1"> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - AdditionalIncludeDirectories="..\..\..\zlib" - PreprocessorDefinitions="WIN32;_DEBUG;PNG_DLL;PNG_NO_STDIO;PNG_NO_GLOBAL_ARRAYS" - BasicRuntimeChecks="3" - RuntimeLibrary="3" - WarningLevel="3" - DebugInformationFormat="4" - CompileAs="0"/> - <Tool - Name="VCCustomBuildTool" - Description="Testing..." - CommandLine="set path=$(OutDir)\..;$(OutDir)\..\ZLib -$(TargetPath) ..\..\pngtest.png $(IntDir)\pngout.png" - Outputs="$(IntDir)\pngout.png"/> - <Tool - Name="VCLinkerTool" - OutputFile="$(OutDir)/pngtest.exe" - GenerateDebugInformation="TRUE" - SubSystem="1" - TargetMachine="1"/> - <Tool - Name="VCMIDLTool"/> - <Tool - Name="VCPostBuildEventTool"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCWebDeploymentTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - <Configuration - Name="DLL ASM Release|Win32" - OutputDirectory=".\Win32_DLL_ASM_Release\Test" - IntermediateDirectory=".\Win32_DLL_ASM_Release\Test" - ConfigurationType="1"> - <Tool - Name="VCCLCompilerTool" - InlineFunctionExpansion="1" - AdditionalIncludeDirectories="..\..\..\zlib" - PreprocessorDefinitions="WIN32;NDEBUG;PNG_DLL;PNG_NO_STDIO;PNG_NO_GLOBAL_ARRAYS" - StringPooling="TRUE" - RuntimeLibrary="2" - EnableFunctionLevelLinking="TRUE" - WarningLevel="3" - CompileAs="0"/> - <Tool - Name="VCCustomBuildTool" - Description="Testing..." - CommandLine="set path=$(OutDir)\..;$(OutDir)\..\ZLib -$(TargetPath) ..\..\pngtest.png $(IntDir)\pngout.png" - Outputs="$(IntDir)\pngout.png"/> - <Tool - Name="VCLinkerTool" - OutputFile="$(OutDir)/pngtest.exe" - LinkIncremental="1" - SubSystem="1" - TargetMachine="1"/> - <Tool - Name="VCMIDLTool"/> - <Tool - Name="VCPostBuildEventTool"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCWebDeploymentTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - <Configuration - Name="DLL ASM Debug|Win32" - OutputDirectory=".\Win32_DLL_ASM_Debug\Test" - IntermediateDirectory=".\Win32_DLL_ASM_Debug\Test" - ConfigurationType="1"> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - AdditionalIncludeDirectories="..\..\..\zlib" - PreprocessorDefinitions="WIN32;_DEBUG;PNG_DLL;PNG_NO_STDIO;PNG_NO_GLOBAL_ARRAYS" - BasicRuntimeChecks="3" - RuntimeLibrary="3" - WarningLevel="3" - DebugInformationFormat="4" - CompileAs="0"/> - <Tool - Name="VCCustomBuildTool" - Description="Testing..." - CommandLine="set path=$(OutDir)\..;$(OutDir)\..\ZLib -$(TargetPath) ..\..\pngtest.png $(IntDir)\pngout.png" - Outputs="$(IntDir)\pngout.png"/> - <Tool - Name="VCLinkerTool" - OutputFile="$(OutDir)/pngtest.exe" - GenerateDebugInformation="TRUE" - SubSystem="1" - TargetMachine="1"/> - <Tool - Name="VCMIDLTool"/> - <Tool - Name="VCPostBuildEventTool"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCWebDeploymentTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - <Configuration - Name="DLL VB|Win32" - OutputDirectory=".\Win32_DLL_VB\Test" - IntermediateDirectory=".\Win32_DLL_VB\Test" - ConfigurationType="1"> - <Tool - Name="VCCLCompilerTool" - InlineFunctionExpansion="1" - AdditionalIncludeDirectories="..\..\..\zlib" - PreprocessorDefinitions="WIN32;NDEBUG;PNG_DLL;PNG_NO_STDIO;PNG_NO_GLOBAL_ARRAYS;PNGAPI=__stdcall" - StringPooling="TRUE" - RuntimeLibrary="2" - EnableFunctionLevelLinking="TRUE" - WarningLevel="2" - CallingConvention="2" - CompileAs="0"/> - <Tool - Name="VCCustomBuildTool" - Description="Testing..." - CommandLine="set path=$(OutDir)\..;$(OutDir)\..\..\Win32_DLL_Release\ZLib -$(TargetPath) ..\..\pngtest.png $(IntDir)\pngout.png" - Outputs="$(IntDir)\pngout.png"/> - <Tool - Name="VCLinkerTool" - OutputFile="$(OutDir)/pngtest.exe" - LinkIncremental="1" - IgnoreDefaultLibraryNames="$(IntDir)\libpng13vb.lib" - SubSystem="1" - TargetMachine="1"/> - <Tool - Name="VCMIDLTool"/> - <Tool - Name="VCPostBuildEventTool"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCWebDeploymentTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - <Configuration - Name="LIB Release|Win32" - OutputDirectory=".\Win32_LIB_Release\Test" - IntermediateDirectory=".\Win32_LIB_Release\Test" - ConfigurationType="1"> - <Tool - Name="VCCLCompilerTool" - InlineFunctionExpansion="1" - AdditionalIncludeDirectories="..\..\..\zlib" - PreprocessorDefinitions="WIN32;_DEBUG;PNG_NO_GLOBAL_ARRAYS" - StringPooling="TRUE" - RuntimeLibrary="2" - EnableFunctionLevelLinking="TRUE" - WarningLevel="3" - CompileAs="0"/> - <Tool - Name="VCCustomBuildTool" - Description="Testing..." - CommandLine="set path=$(OutDir)\..;$(OutDir)\..\ZLib -$(TargetPath) ..\..\pngtest.png $(IntDir)\pngout.png" - Outputs="$(IntDir)\pngout.png"/> - <Tool - Name="VCLinkerTool" - OutputFile="$(OutDir)/pngtest.exe" - LinkIncremental="1" - SubSystem="1" - TargetMachine="1"/> - <Tool - Name="VCMIDLTool"/> - <Tool - Name="VCPostBuildEventTool"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCWebDeploymentTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - <Configuration - Name="LIB Debug|Win32" - OutputDirectory=".\Win32_LIB_Debug\Test" - IntermediateDirectory=".\Win32_LIB_Debug\Test" - ConfigurationType="1"> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - AdditionalIncludeDirectories="..\..\..\zlib" - PreprocessorDefinitions="WIN32;_DEBUG;PNG_NO_GLOBAL_ARRAYS" - BasicRuntimeChecks="3" - RuntimeLibrary="3" - WarningLevel="3" - DebugInformationFormat="4" - CompileAs="0"/> - <Tool - Name="VCCustomBuildTool" - Description="Testing..." - CommandLine="set path=$(OutDir)\..;$(OutDir)\..\ZLib -$(TargetPath) ..\..\pngtest.png $(IntDir)\pngout.png" - Outputs="$(IntDir)\pngout.png"/> - <Tool - Name="VCLinkerTool" - OutputFile="$(OutDir)/pngtest.exe" - GenerateDebugInformation="TRUE" - SubSystem="1" - TargetMachine="1"/> - <Tool - Name="VCMIDLTool"/> - <Tool - Name="VCPostBuildEventTool"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCWebDeploymentTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - <Configuration - Name="LIB ASM Release|Win32" - OutputDirectory=".\Win32_LIB_ASM_Release\Test" - IntermediateDirectory=".\Win32_LIB_ASM_Release\Test" - ConfigurationType="1"> - <Tool - Name="VCCLCompilerTool" - InlineFunctionExpansion="1" - AdditionalIncludeDirectories="..\..\..\zlib" - PreprocessorDefinitions="WIN32;NDEBUG;PNG_NO_GLOBAL_ARRAYS" - StringPooling="TRUE" - RuntimeLibrary="2" - EnableFunctionLevelLinking="TRUE" - WarningLevel="3" - CompileAs="0"/> - <Tool - Name="VCCustomBuildTool" - Description="Testing..." - CommandLine="set path=$(OutDir)\..;$(OutDir)\..\ZLib -$(TargetPath) ..\..\pngtest.png $(IntDir)\pngout.png" - Outputs="$(IntDir)\pngout.png"/> - <Tool - Name="VCLinkerTool" - OutputFile="$(OutDir)/pngtest.exe" - LinkIncremental="1" - SubSystem="1" - TargetMachine="1"/> - <Tool - Name="VCMIDLTool"/> - <Tool - Name="VCPostBuildEventTool"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCWebDeploymentTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - <Configuration - Name="LIB ASM Debug|Win32" - OutputDirectory=".\Win32_LIB_ASM_Debug\Test" - IntermediateDirectory=".\Win32_LIB_ASM_Debug\Test" - ConfigurationType="1"> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - AdditionalIncludeDirectories="..\..\..\zlib" - PreprocessorDefinitions="WIN32;_DEBUG;PNG_NO_GLOBAL_ARRAYS" - BasicRuntimeChecks="3" - RuntimeLibrary="3" - WarningLevel="3" - DebugInformationFormat="4" - CompileAs="0"/> - <Tool - Name="VCCustomBuildTool" - Description="Testing..." - CommandLine="set path=$(OutDir)\..;$(OutDir)\..\ZLib -$(TargetPath) ..\..\pngtest.png $(IntDir)\pngout.png" - Outputs="$(IntDir)\pngout.png"/> - <Tool - Name="VCLinkerTool" - OutputFile="$(OutDir)/pngtest.exe" - GenerateDebugInformation="TRUE" - SubSystem="1" - TargetMachine="1"/> - <Tool - Name="VCMIDLTool"/> - <Tool - Name="VCPostBuildEventTool"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCWebDeploymentTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - </Configurations> - <References> - </References> - <Files> - <Filter - Name="Source Files" - Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"> - <File - RelativePath="..\..\pngtest.c"> - </File> - </Filter> - </Files> - <Globals> - </Globals> -</VisualStudioProject> diff --git a/irrlicht-1.6/source/Irrlicht/libpng/projects/visualc71/zlib.vcproj b/irrlicht-1.6/source/Irrlicht/libpng/projects/visualc71/zlib.vcproj deleted file mode 100644 index bc0a2bf33..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/projects/visualc71/zlib.vcproj +++ /dev/null @@ -1,670 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?> -<VisualStudioProject - ProjectType="Visual C++" - Version="7.10" - Name="zlib"> - <Platforms> - <Platform - Name="Win32"/> - </Platforms> - <Configurations> - <Configuration - Name="DLL Release|Win32" - OutputDirectory=".\Win32_DLL_Release\ZLib" - IntermediateDirectory=".\Win32_DLL_Release\ZLib" - ConfigurationType="2"> - <Tool - Name="VCCLCompilerTool" - InlineFunctionExpansion="1" - AdditionalIncludeDirectories="..\..\..\zlib" - PreprocessorDefinitions="WIN32;NDEBUG" - StringPooling="TRUE" - RuntimeLibrary="2" - EnableFunctionLevelLinking="TRUE" - WarningLevel="3" - CompileAs="1"/> - <Tool - Name="VCCustomBuildTool"/> - <Tool - Name="VCLinkerTool" - OutputFile="$(OutDir)\zlib1.dll" - LinkIncremental="1" - ModuleDefinitionFile="..\..\..\zlib\win32\zlib.def"/> - <Tool - Name="VCMIDLTool"/> - <Tool - Name="VCPostBuildEventTool"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="NDEBUG" - Culture="1033"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCWebDeploymentTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - <Configuration - Name="DLL Debug|Win32" - OutputDirectory=".\Win32_DLL_Debug\ZLib" - IntermediateDirectory=".\Win32_DLL_Debug\ZLib" - ConfigurationType="2"> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - AdditionalIncludeDirectories="..\..\..\zlib" - PreprocessorDefinitions="WIN32;_DEBUG" - BasicRuntimeChecks="3" - RuntimeLibrary="3" - WarningLevel="3" - DebugInformationFormat="4" - CompileAs="1"/> - <Tool - Name="VCCustomBuildTool"/> - <Tool - Name="VCLinkerTool" - OutputFile="$(OutDir)\zlib1d.dll" - ModuleDefinitionFile="..\..\..\zlib\win32\zlib.def" - GenerateDebugInformation="TRUE"/> - <Tool - Name="VCMIDLTool"/> - <Tool - Name="VCPostBuildEventTool"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="_DEBUG" - Culture="1033"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCWebDeploymentTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - <Configuration - Name="DLL ASM Release|Win32" - OutputDirectory=".\Win32_DLL_ASM_Release\ZLib" - IntermediateDirectory=".\Win32_DLL_ASM_Release\ZLib" - ConfigurationType="2"> - <Tool - Name="VCCLCompilerTool" - InlineFunctionExpansion="1" - AdditionalIncludeDirectories="..\..\..\zlib" - PreprocessorDefinitions="WIN32;NDEBUG;ASMV;ASMINF" - StringPooling="TRUE" - RuntimeLibrary="2" - EnableFunctionLevelLinking="TRUE" - WarningLevel="3" - CompileAs="1"/> - <Tool - Name="VCCustomBuildTool"/> - <Tool - Name="VCLinkerTool" - OutputFile="$(OutDir)\zlib1.dll" - LinkIncremental="1" - ModuleDefinitionFile="..\..\..\zlib\win32\zlib.def"/> - <Tool - Name="VCMIDLTool"/> - <Tool - Name="VCPostBuildEventTool"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="NDEBUG" - Culture="1033"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCWebDeploymentTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - <Configuration - Name="DLL ASM Debug|Win32" - OutputDirectory=".\Win32_DLL_ASM_Debug\ZLib" - IntermediateDirectory=".\Win32_DLL_ASM_Debug\ZLib" - ConfigurationType="2"> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - AdditionalIncludeDirectories="..\..\..\zlib" - PreprocessorDefinitions="WIN32;_DEBUG;ASMV;ASMINF" - BasicRuntimeChecks="3" - RuntimeLibrary="3" - WarningLevel="3" - DebugInformationFormat="4" - CompileAs="1"/> - <Tool - Name="VCCustomBuildTool"/> - <Tool - Name="VCLinkerTool" - OutputFile="$(OutDir)\zlib1d.dll" - ModuleDefinitionFile="..\..\..\zlib\win32\zlib.def" - GenerateDebugInformation="TRUE"/> - <Tool - Name="VCMIDLTool"/> - <Tool - Name="VCPostBuildEventTool"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="_DEBUG" - Culture="1033"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCWebDeploymentTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - <Configuration - Name="LIB Release|Win32" - OutputDirectory=".\Win32_LIB_Release\ZLib" - IntermediateDirectory=".\Win32_LIB_Release\ZLib" - ConfigurationType="4"> - <Tool - Name="VCCLCompilerTool" - InlineFunctionExpansion="1" - AdditionalIncludeDirectories="..\..\..\zlib" - PreprocessorDefinitions="WIN32;NDEBUG" - StringPooling="TRUE" - RuntimeLibrary="2" - EnableFunctionLevelLinking="TRUE" - WarningLevel="3" - CompileAs="1"/> - <Tool - Name="VCCustomBuildTool"/> - <Tool - Name="VCLibrarianTool" - OutputFile="$(OutDir)\zlib.lib"/> - <Tool - Name="VCMIDLTool"/> - <Tool - Name="VCPostBuildEventTool"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - <Configuration - Name="LIB Debug|Win32" - OutputDirectory=".\Win32_LIB_Debug\ZLib" - IntermediateDirectory=".\Win32_LIB_Debug\ZLib" - ConfigurationType="4"> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - AdditionalIncludeDirectories="..\..\..\zlib" - PreprocessorDefinitions="WIN32;_DEBUG" - BasicRuntimeChecks="3" - RuntimeLibrary="3" - WarningLevel="3" - DebugInformationFormat="4" - CompileAs="1"/> - <Tool - Name="VCCustomBuildTool"/> - <Tool - Name="VCLibrarianTool" - OutputFile="$(OutDir)\zlibd.lib"/> - <Tool - Name="VCMIDLTool"/> - <Tool - Name="VCPostBuildEventTool"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - <Configuration - Name="LIB ASM Release|Win32" - OutputDirectory=".\Win32_LIB_ASM_Release\ZLib" - IntermediateDirectory=".\Win32_LIB_ASM_Release\ZLib" - ConfigurationType="4"> - <Tool - Name="VCCLCompilerTool" - InlineFunctionExpansion="1" - AdditionalIncludeDirectories="..\..\..\zlib" - PreprocessorDefinitions="WIN32;NDEBUG;ASMV;ASMINF" - StringPooling="TRUE" - RuntimeLibrary="2" - EnableFunctionLevelLinking="TRUE" - WarningLevel="3" - CompileAs="1"/> - <Tool - Name="VCCustomBuildTool"/> - <Tool - Name="VCLibrarianTool" - OutputFile="$(OutDir)\zlib.lib"/> - <Tool - Name="VCMIDLTool"/> - <Tool - Name="VCPostBuildEventTool"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - <Configuration - Name="LIB ASM Debug|Win32" - OutputDirectory=".\Win32_LIB_ASM_Debug\ZLib" - IntermediateDirectory=".\Win32_LIB_ASM_Debug\ZLib" - ConfigurationType="4"> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - AdditionalIncludeDirectories="..\..\..\zlib" - PreprocessorDefinitions="WIN32;_DEBUG;ASMV;ASMINF" - BasicRuntimeChecks="3" - RuntimeLibrary="3" - WarningLevel="3" - DebugInformationFormat="4" - CompileAs="1"/> - <Tool - Name="VCCustomBuildTool"/> - <Tool - Name="VCLibrarianTool" - OutputFile="$(OutDir)\zlibd.lib"/> - <Tool - Name="VCMIDLTool"/> - <Tool - Name="VCPostBuildEventTool"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - </Configurations> - <References> - </References> - <Files> - <Filter - Name="Source Files" - Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"> - <File - RelativePath="..\..\..\zlib\adler32.c"> - </File> - <File - RelativePath="..\..\..\zlib\compress.c"> - </File> - <File - RelativePath="..\..\..\zlib\crc32.c"> - </File> - <File - RelativePath="..\..\..\zlib\deflate.c"> - </File> - <File - RelativePath="..\..\..\zlib\gzio.c"> - </File> - <File - RelativePath="..\..\..\zlib\infback.c"> - </File> - <File - RelativePath="..\..\..\zlib\inffast.c"> - </File> - <File - RelativePath="..\..\..\zlib\inflate.c"> - </File> - <File - RelativePath="..\..\..\zlib\inftrees.c"> - </File> - <File - RelativePath="..\..\..\zlib\trees.c"> - </File> - <File - RelativePath="..\..\..\zlib\uncompr.c"> - </File> - <File - RelativePath="..\..\..\zlib\win32\zlib.def"> - <FileConfiguration - Name="LIB Release|Win32" - ExcludedFromBuild="TRUE"> - <Tool - Name="VCCustomBuildTool"/> - </FileConfiguration> - <FileConfiguration - Name="LIB Debug|Win32" - ExcludedFromBuild="TRUE"> - <Tool - Name="VCCustomBuildTool"/> - </FileConfiguration> - <FileConfiguration - Name="LIB ASM Release|Win32" - ExcludedFromBuild="TRUE"> - <Tool - Name="VCCustomBuildTool"/> - </FileConfiguration> - <FileConfiguration - Name="LIB ASM Debug|Win32" - ExcludedFromBuild="TRUE"> - <Tool - Name="VCCustomBuildTool"/> - </FileConfiguration> - </File> - <File - RelativePath="..\..\..\zlib\zutil.c"> - </File> - </Filter> - <Filter - Name="Header Files" - Filter="h;hpp;hxx;hm;inl"> - <File - RelativePath="..\..\..\zlib\crc32.h"> - </File> - <File - RelativePath="..\..\..\zlib\deflate.h"> - </File> - <File - RelativePath="..\..\..\zlib\inffast.h"> - </File> - <File - RelativePath="..\..\..\zlib\inffixed.h"> - </File> - <File - RelativePath="..\..\..\zlib\inflate.h"> - </File> - <File - RelativePath="..\..\..\zlib\inftrees.h"> - </File> - <File - RelativePath="..\..\..\zlib\trees.h"> - </File> - <File - RelativePath="..\..\..\zlib\zconf.h"> - </File> - <File - RelativePath="..\..\..\zlib\zlib.h"> - </File> - <File - RelativePath="..\..\..\zlib\zutil.h"> - </File> - </Filter> - <Filter - Name="Resource Files" - Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"> - <File - RelativePath="..\..\..\zlib\win32\zlib1.rc"> - <FileConfiguration - Name="LIB Release|Win32" - ExcludedFromBuild="TRUE"> - <Tool - Name="VCResourceCompilerTool"/> - </FileConfiguration> - <FileConfiguration - Name="LIB Debug|Win32" - ExcludedFromBuild="TRUE"> - <Tool - Name="VCResourceCompilerTool"/> - </FileConfiguration> - <FileConfiguration - Name="LIB ASM Release|Win32" - ExcludedFromBuild="TRUE"> - <Tool - Name="VCResourceCompilerTool"/> - </FileConfiguration> - <FileConfiguration - Name="LIB ASM Debug|Win32" - ExcludedFromBuild="TRUE"> - <Tool - Name="VCResourceCompilerTool"/> - </FileConfiguration> - </File> - </Filter> - <Filter - Name="Assembler Files (Unsupported)" - Filter="asm;obj;c;cpp;cxx;h;hpp;hxx"> - <File - RelativePath="..\..\..\zlib\contrib\masmx86\gvmat32.asm"> - <FileConfiguration - Name="DLL Release|Win32" - ExcludedFromBuild="TRUE"> - <Tool - Name="VCCustomBuildTool"/> - </FileConfiguration> - <FileConfiguration - Name="DLL Debug|Win32" - ExcludedFromBuild="TRUE"> - <Tool - Name="VCCustomBuildTool"/> - </FileConfiguration> - <FileConfiguration - Name="DLL ASM Release|Win32"> - <Tool - Name="VCCustomBuildTool" - Description="Assembling..." - CommandLine="ml /nologo /c /Cx /coff /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)" -" - Outputs="$(IntDir)\$(InputName).obj"/> - </FileConfiguration> - <FileConfiguration - Name="DLL ASM Debug|Win32"> - <Tool - Name="VCCustomBuildTool" - Description="Assembling..." - CommandLine="ml /nologo /c /Cx /coff /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)" -" - Outputs="$(IntDir)\$(InputName).obj"/> - </FileConfiguration> - <FileConfiguration - Name="LIB Release|Win32" - ExcludedFromBuild="TRUE"> - <Tool - Name="VCCustomBuildTool"/> - </FileConfiguration> - <FileConfiguration - Name="LIB Debug|Win32" - ExcludedFromBuild="TRUE"> - <Tool - Name="VCCustomBuildTool"/> - </FileConfiguration> - <FileConfiguration - Name="LIB ASM Release|Win32"> - <Tool - Name="VCCustomBuildTool" - Description="Assembling..." - CommandLine="ml /nologo /c /Cx /coff /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)" -" - Outputs="$(IntDir)\$(InputName).obj"/> - </FileConfiguration> - <FileConfiguration - Name="LIB ASM Debug|Win32"> - <Tool - Name="VCCustomBuildTool" - Description="Assembling..." - CommandLine="ml /nologo /c /Cx /coff /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)" -" - Outputs="$(IntDir)\$(InputName).obj"/> - </FileConfiguration> - </File> - <File - RelativePath="..\..\..\zlib\contrib\masmx86\gvmat32c.c"> - <FileConfiguration - Name="DLL Release|Win32" - ExcludedFromBuild="TRUE"> - <Tool - Name="VCCLCompilerTool"/> - </FileConfiguration> - <FileConfiguration - Name="DLL Debug|Win32" - ExcludedFromBuild="TRUE"> - <Tool - Name="VCCLCompilerTool"/> - </FileConfiguration> - <FileConfiguration - Name="DLL ASM Release|Win32"> - <Tool - Name="VCCLCompilerTool" - AdditionalIncludeDirectories="..\.."/> - </FileConfiguration> - <FileConfiguration - Name="DLL ASM Debug|Win32"> - <Tool - Name="VCCLCompilerTool" - AdditionalIncludeDirectories="..\.."/> - </FileConfiguration> - <FileConfiguration - Name="LIB Release|Win32" - ExcludedFromBuild="TRUE"> - <Tool - Name="VCCLCompilerTool"/> - </FileConfiguration> - <FileConfiguration - Name="LIB Debug|Win32" - ExcludedFromBuild="TRUE"> - <Tool - Name="VCCLCompilerTool"/> - </FileConfiguration> - <FileConfiguration - Name="LIB ASM Release|Win32"> - <Tool - Name="VCCLCompilerTool" - AdditionalIncludeDirectories="..\.."/> - </FileConfiguration> - <FileConfiguration - Name="LIB ASM Debug|Win32"> - <Tool - Name="VCCLCompilerTool" - AdditionalIncludeDirectories="..\.."/> - </FileConfiguration> - </File> - <File - RelativePath="..\..\..\zlib\contrib\masmx86\inffas32.asm"> - <FileConfiguration - Name="DLL Release|Win32" - ExcludedFromBuild="TRUE"> - <Tool - Name="VCCustomBuildTool"/> - </FileConfiguration> - <FileConfiguration - Name="DLL Debug|Win32" - ExcludedFromBuild="TRUE"> - <Tool - Name="VCCustomBuildTool"/> - </FileConfiguration> - <FileConfiguration - Name="DLL ASM Release|Win32"> - <Tool - Name="VCCustomBuildTool" - Description="Assembling..." - CommandLine="ml /nologo /c /Cx /coff /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)" -" - Outputs="$(IntDir)\$(InputName).obj"/> - </FileConfiguration> - <FileConfiguration - Name="DLL ASM Debug|Win32"> - <Tool - Name="VCCustomBuildTool" - Description="Assembling..." - CommandLine="ml /nologo /c /Cx /coff /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)" -" - Outputs="$(IntDir)\$(InputName).obj"/> - </FileConfiguration> - <FileConfiguration - Name="LIB Release|Win32" - ExcludedFromBuild="TRUE"> - <Tool - Name="VCCustomBuildTool"/> - </FileConfiguration> - <FileConfiguration - Name="LIB Debug|Win32" - ExcludedFromBuild="TRUE"> - <Tool - Name="VCCustomBuildTool"/> - </FileConfiguration> - <FileConfiguration - Name="LIB ASM Release|Win32"> - <Tool - Name="VCCustomBuildTool" - Description="Assembling..." - CommandLine="ml /nologo /c /Cx /coff /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)" -" - Outputs="$(IntDir)\$(InputName).obj"/> - </FileConfiguration> - <FileConfiguration - Name="LIB ASM Debug|Win32"> - <Tool - Name="VCCustomBuildTool" - Description="Assembling..." - CommandLine="ml /nologo /c /Cx /coff /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)" -" - Outputs="$(IntDir)\$(InputName).obj"/> - </FileConfiguration> - </File> - </Filter> - <File - RelativePath="README.txt"> - </File> - </Files> - <Globals> - </Globals> -</VisualStudioProject> diff --git a/irrlicht-1.6/source/Irrlicht/libpng/projects/wince.txt b/irrlicht-1.6/source/Irrlicht/libpng/projects/wince.txt deleted file mode 100644 index 4ccff387c..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/projects/wince.txt +++ /dev/null @@ -1,6 +0,0 @@ -A set of project files is available for WinCE. Get -libpng-1.2.5-project-wince.zip from a libpng distribution -site such as http://libpng.sourceforge.net - -Put the zip file in this directory (projects) and then run -"unzip -a libpng-1.2.5-project-wince.zip" diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/CMakeLists.txt b/irrlicht-1.6/source/Irrlicht/libpng/scripts/CMakeLists.txt deleted file mode 100644 index 901eb811c..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/CMakeLists.txt +++ /dev/null @@ -1,213 +0,0 @@ -project(PNG) - -# Copyright (C) 2007 Glenn Randers-Pehrson -# For conditions of distribution and use, see copyright notice in png.h - -set(PNGLIB_MAJOR 1) -set(PNGLIB_MINOR 2) -set(PNGLIB_RELEASE 18) -set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR}) -set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE}) - -# needed packages -find_package(ZLIB REQUIRED) -if(NOT WIN32) - find_library(M_LIBRARY - NAMES m - PATHS /usr/lib /usr/local/lib - ) - if(NOT M_LIBRARY) - message(STATUS - "math library 'libm' not found - floating point support disabled") - endif(NOT M_LIBRARY) -else(NOT WIN32) - # not needed on windows - set(M_LIBRARY "") -endif(NOT WIN32) - - -# COMMAND LINE OPTIONS -option(PNG_SHARED "Build shared lib" YES) -option(PNG_STATIC "Build static lib" YES) -option(PNG_TESTS "Build pngtest" YES) -option(PNG_NO_CONSOLE_IO "FIXME" YES) -option(PNG_NO_STDIO "FIXME" YES) -option(PNG_DEBUG "Build with debug output" YES) -option(PNGARG "FIXME" YES) -#TODO: -# PNG_CONSOLE_IO_SUPPORTED - -# maybe needs improving, but currently I don't know when we can enable what :) -set(png_asm_tmp "OFF") -if(NOT WIN32) - find_program(uname_executable NAMES uname PATHS /bin /usr/bin /usr/local/bin) - if(uname_executable) - EXEC_PROGRAM(${uname_executable} ARGS --machine OUTPUT_VARIABLE uname_output) - if("uname_output" MATCHES "^.*i[1-9]86.*$") - set(png_asm_tmp "ON") - else("uname_output" MATCHES "^.*i[1-9]86.*$") - set(png_asm_tmp "OFF") - endif("uname_output" MATCHES "^.*i[1-9]86.*$") - endif(uname_executable) -endif(NOT WIN32) - -option(PNG_MMX "Use MMX assembler code (x86 only)" ${png_asm_tmp}) - -# SET LIBNAME -# msvc does not append 'lib' - do it here to have consistent name -if(MSVC) - set(PNG_LIB_NAME lib) -endif(MSVC) -set(PNG_LIB_NAME ${PNG_LIB_NAME}png${PNGLIB_MAJOR}${PNGLIB_MINOR}) - -# to distinguish between debug and release lib -set(CMAKE_DEBUG_POSTFIX "d") - - -# OUR SOURCES -set(libpng_sources - png.h - pngconf.h - png.c - pngerror.c - pngget.c - pngmem.c - pngpread.c - pngread.c - pngrio.c - pngrtran.c - pngrutil.c - pngset.c - pngtrans.c - pngwio.c - pngwrite.c - pngwtran.c - pngwutil.c -) -set(pngtest_sources - pngtest.c -) -# SOME NEEDED DEFINITIONS -add_definitions(-DZLIB_DLL) - -if(MSVC) - add_definitions(-DPNG_USE_PNGVCRD -DPNG_NO_MODULEDEF - -D_CRT_SECURE_NO_DEPRECATE) - set(libpng_sources ${libpng_sources} - pngvcrd.c - ) -else(MSVC) - add_definitions(-DPNG_USE_PNGGCCRD) - set(libpng_sources ${libpng_sources} - pnggccrd.c - ) -endif(MSVC) - -if(NOT MSVC) - if(NOT PNG_MMX) - add_definitions(-DLIBPNG_NO_MMX) - add_definitions(-DPNG_NO_MMX_CODE) - endif(NOT PNG_MMX) -else(NOT MSVC) - if(PNG_MMX) - # maybe add this to pngconf.h ? - add_definitions(-DPNG_MMX_CODE_SUPPORTED) - endif(PNG_MMX) -endif(NOT MSVC) - - -if(PNG_CONSOLE_IO_SUPPORTED) - add_definitions(-DPNG_CONSOLE_IO_SUPPORTED) -endif(PNG_CONSOLE_IO_SUPPORTED) - -if(PNG_NO_CONSOLE_IO) - add_definitions(-DPNG_NO_CONSOLE_IO) -endif(PNG_NO_CONSOLE_IO) - -if(PNG_NO_STDIO) - add_definitions(-DPNG_NO_STDIO) -endif(PNG_NO_STDIO) - -if(PNG_DEBUG) - add_definitions(-DPNG_DEBUG) -endif(PNG_DEBUG) - -if(NOT M_LIBRARY) - add_definitions(-DPNG_NO_FLOATING_POINT_SUPPORTED) -endif(NOT M_LIBRARY) - -# NOW BUILD OUR TARGET -include_directories(${PNG_SOURCE_DIR} ${ZLIB_INCLUDE_DIR}) - -if(PNG_SHARED) - add_library(${PNG_LIB_NAME} SHARED ${libpng_sources}) - target_link_libraries(${PNG_LIB_NAME} ${ZLIB_LIBRARY} ${M_LIBRARY}) -endif(PNG_SHARED) -if(PNG_STATIC) -# does not work without changing name - set(PNG_LIB_NAME_STATIC ${PNG_LIB_NAME}_static) - add_library(${PNG_LIB_NAME_STATIC} STATIC ${libpng_sources}) -endif(PNG_STATIC) - -if(PNG_SHARED AND WIN32) - set_target_properties(${PNG_LIB_NAME} PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL) -endif(PNG_SHARED AND WIN32) - -if(PNG_TESTS) -# does not work with msvc due to png_lib_ver issue - add_executable(pngtest ${pngtest_sources}) - target_link_libraries(pngtest ${PNG_LIB_NAME}) -# add_test(pngtest ${PNG_SOURCE_DIR}/pngtest.png) -endif(PNG_TESTS) - - -# CREATE PKGCONFIG FILES -# we use the same files like ./configure, so we have to set its vars -set(prefix ${CMAKE_INSTALL_PREFIX}) -set(exec_prefix ${CMAKE_INSTALL_PREFIX}) -set(libdir ${CMAKE_INSTALL_PREFIX}/lib) -set(includedir ${CMAKE_INSTALL_PREFIX}/include) - -configure_file(${PNG_SOURCE_DIR}/scripts/libpng.pc.in - ${PNG_BINARY_DIR}/libpng.pc) -configure_file(${PNG_SOURCE_DIR}/scripts/libpng-config.in - ${PNG_BINARY_DIR}/libpng-config) -configure_file(${PNG_SOURCE_DIR}/scripts/libpng.pc.in - ${PNG_BINARY_DIR}/${PNGLIB_NAME}.pc) -configure_file(${PNG_SOURCE_DIR}/scripts/libpng-config.in - ${PNG_BINARY_DIR}/${PNGLIB_NAME}-config) - -# SET UP LINKS -set_target_properties(${PNG_LIB_NAME} PROPERTIES -# VERSION 0.${PNGLIB_RELEASE}.1.2.18 - VERSION 0.${PNGLIB_RELEASE}.0 - SOVERSION 0 - CLEAN_DIRECT_OUTPUT 1) -set_target_properties(${PNG_LIB_NAME_STATIC} PROPERTIES - OUTPUT_NAME ${PNG_LIB_NAME} - CLEAN_DIRECT_OUTPUT 1) - -# INSTALL -install_targets(/lib ${PNG_LIB_NAME} ${PNG_LIB_NAME_STATIC}) -install(FILES png.h pngconf.h DESTINATION include) -install(FILES png.h pngconf.h DESTINATION include/${PNGLIB_NAME}) -install(FILES libpng.3 libpngpf.3 DESTINATION man/man3) -install(FILES png.5 DESTINATION man/man5) -install(FILES ${PNG_BINARY_DIR}/libpng.pc DESTINATION lib/pkgconfig) -install(FILES ${PNG_BINARY_DIR}/libpng-config DESTINATION bin) -install(FILES ${PNG_BINARY_DIR}/${PNGLIB_NAME}.pc DESTINATION lib/pkgconfig) -install(FILES ${PNG_BINARY_DIR}/${PNGLIB_NAME}-config DESTINATION bin) - -# what's with libpng.txt and all the extra files? - - -# UNINSTALL -# do we need this? - - -# DIST -# do we need this? - -# to create msvc import lib for mingw compiled shared lib -# pexports libpng.dll > libpng.def -# lib /def:libpng.def /machine:x86 diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/SCOPTIONS.ppc b/irrlicht-1.6/source/Irrlicht/libpng/scripts/SCOPTIONS.ppc deleted file mode 100644 index 7090fd43d..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/SCOPTIONS.ppc +++ /dev/null @@ -1,7 +0,0 @@ -OPTIMIZE -OPTPEEP -OPTTIME -OPTSCHED -AUTOREGISTER -PARMS=REGISTERS -INCLUDEDIR=hlp:ppc/include diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/descrip.mms b/irrlicht-1.6/source/Irrlicht/libpng/scripts/descrip.mms deleted file mode 100644 index 3879ee627..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/descrip.mms +++ /dev/null @@ -1,52 +0,0 @@ - -cc_defs = /inc=$(ZLIBSRC) -c_deb = - -.ifdef __DECC__ -pref = /prefix=all -.endif - - - -OBJS = png.obj, pngset.obj, pngget.obj, pngrutil.obj, pngtrans.obj,\ - pngwutil.obj, pngread.obj, pngmem.obj, pngwrite.obj, pngrtran.obj,\ - pngwtran.obj, pngrio.obj, pngwio.obj, pngerror.obj, pngpread.obj - - -CFLAGS= $(C_DEB) $(CC_DEFS) $(PREF) - -all : pngtest.exe libpng.olb - @ write sys$output " pngtest available" - -libpng.olb : libpng.olb($(OBJS)) - @ write sys$output " Libpng available" - - -pngtest.exe : pngtest.obj libpng.olb - link pngtest,libpng.olb/lib,$(ZLIBSRC)libz.olb/lib - -test : pngtest.exe - run pngtest - -clean : - delete *.obj;*,*.exe;* - - -# Other dependencies. -png.obj : png.h, pngconf.h -pngpread.obj : png.h, pngconf.h -pngset.obj : png.h, pngconf.h -pngget.obj : png.h, pngconf.h -pngread.obj : png.h, pngconf.h -pngrtran.obj : png.h, pngconf.h -pngrutil.obj : png.h, pngconf.h -pngerror.obj : png.h, pngconf.h -pngmem.obj : png.h, pngconf.h -pngrio.obj : png.h, pngconf.h -pngwio.obj : png.h, pngconf.h -pngtest.obj : png.h, pngconf.h -pngtrans.obj : png.h, pngconf.h -pngwrite.obj : png.h, pngconf.h -pngwtran.obj : png.h, pngconf.h -pngwutil.obj : png.h, pngconf.h - diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/libpng-config-body.in b/irrlicht-1.6/source/Irrlicht/libpng/scripts/libpng-config-body.in deleted file mode 100644 index 0db8898e5..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/libpng-config-body.in +++ /dev/null @@ -1,96 +0,0 @@ - -usage() -{ - cat <<EOF -Usage: libpng-config [OPTION] ... - -Known values for OPTION are: - - --prefix print libpng prefix - --libdir print path to directory containing library - --libs print library linking information - --ccopts print compiler options - --cppflags print pre-processor flags - --cflags print preprocessor flags, I_opts, and compiler options - --I_opts print "-I" include options - --L_opts print linker "-L" flags for dynamic linking - --R_opts print dynamic linker "-R" or "-rpath" flags - --ldopts print linker options - --ldflags print linker flags (ldopts, L_opts, R_opts, and libs) - --static revise subsequent outputs for static linking - --help print this help and exit - --version print version information -EOF - - exit $1 -} - -if test $# -eq 0; then - usage 1 -fi - -while test $# -gt 0; do - case "$1" in - - --prefix) - echo ${prefix} - ;; - - --version) - echo ${version} - exit 0 - ;; - - --help) - usage 0 - ;; - - --ccopts) - echo ${ccopts} - ;; - - --cppflags) - echo ${cppflags} - ;; - - --cflags) - echo ${I_opts} ${cppflags} ${ccopts} - ;; - - --libdir) - echo ${libdir} - ;; - - --libs) - echo ${libs} - ;; - - --I_opts) - echo ${I_opts} - ;; - - --L_opts) - echo ${L_opts} - ;; - - --R_opts) - echo ${R_opts} - ;; - - --ldflags) - echo ${ldflags} ${L_opts} ${R_opts} ${libs} - ;; - - --static) - R_opts="" - ;; - - *) - usage - exit 1 - ;; - esac - shift -done - -exit 0 diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/libpng-config-head.in b/irrlicht-1.6/source/Irrlicht/libpng/scripts/libpng-config-head.in deleted file mode 100644 index 03a92e983..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/libpng-config-head.in +++ /dev/null @@ -1,21 +0,0 @@ -#! /bin/sh - -# libpng-config -# provides configuration info for libpng. - -# Copyright (C) 2002 Glenn Randers-Pehrson -# For conditions of distribution and use, see copyright notice in png.h - -# Modeled after libxml-config. - -version=1.2.18 -prefix="" -libdir="" -libs="" -I_opts="" -L_opts="" -R_opts="" -cppflags="" -ccopts="" -ldopts="" - diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/libpng-config.in b/irrlicht-1.6/source/Irrlicht/libpng/scripts/libpng-config.in deleted file mode 100644 index 6ef907b1e..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/libpng-config.in +++ /dev/null @@ -1,124 +0,0 @@ -#! /bin/sh - -# libpng-config -# provides configuration info for libpng. - -# Copyright (C) 2002, 2004, 2006, 2007 Glenn Randers-Pehrson -# For conditions of distribution and use, see copyright notice in png.h - -# Modeled after libxml-config. - -version="@PNGLIB_VERSION@" -prefix="@prefix@" -exec_prefix="@exec_prefix@" -libdir="@libdir@" -includedir="@includedir@/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@" -libs="-lpng@PNGLIB_MAJOR@@PNGLIB_MINOR@" -all_libs="-lpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ -lz -lm" -I_opts="-I${includedir}" -L_opts="-L${libdir}" -R_opts="" -cppflags="" -ccopts="@LIBPNG_NO_MMX@" -ldopts="" - -usage() -{ - cat <<EOF -Usage: $0 [OPTION] ... - -Known values for OPTION are: - - --prefix print libpng prefix - --libdir print path to directory containing library - --libs print library linking information - --ccopts print compiler options - --cppflags print pre-processor flags - --cflags print preprocessor flags, I_opts, and compiler options - --I_opts print "-I" include options - --L_opts print linker "-L" flags for dynamic linking - --R_opts print dynamic linker "-R" or "-rpath" flags - --ldopts print linker options - --ldflags print linker flags (ldopts, L_opts, R_opts, and libs) - --static revise subsequent outputs for static linking - --help print this help and exit - --version print version information -EOF - - exit $1 -} - -if test $# -eq 0; then - usage 1 -fi - -while test $# -gt 0; do - case "$1" in - - --prefix) - echo ${prefix} - ;; - - --version) - echo ${version} - exit 0 - ;; - - --help) - usage 0 - ;; - - --ccopts) - echo ${ccopts} - ;; - - --cppflags) - echo ${cppflags} - ;; - - --cflags) - echo ${I_opts} ${cppflags} ${ccopts} - ;; - - --libdir) - echo ${libdir} - ;; - - --libs) - echo ${libs} - ;; - - --I_opts) - echo ${I_opts} - ;; - - --L_opts) - echo ${L_opts} - ;; - - --R_opts) - echo ${R_opts} - ;; - - --ldopts) - echo ${ldopts} - ;; - - --ldflags) - echo ${ldopts} ${L_opts} ${R_opts} ${libs} - ;; - - --static) - R_opts="" - libs=${all_libs} - ;; - - *) - usage - exit 1 - ;; - esac - shift -done - -exit 0 diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/libpng.icc b/irrlicht-1.6/source/Irrlicht/libpng/scripts/libpng.icc deleted file mode 100644 index 26bd5ea82..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/libpng.icc +++ /dev/null @@ -1,44 +0,0 @@ -// Project file for libpng (static) -// IBM VisualAge/C++ version 4.0 or later -// Copyright (C) 2000 Cosmin Truta -// For conditions of distribution and use, see copyright notice in png.h -// Notes: -// All modules are compiled in C mode -// Tested with IBM VAC++ 4.0 under Win32 -// Expected to work with IBM VAC++ 4.0 or later under OS/2 and Win32 -// Can be easily adapted for IBM VAC++ 4.0 or later under AIX -// For conditions of distribution and use, see copyright notice in png.h - -option incl(searchpath, "../zlib"), opt(level, "2"), - link(libsearchpath, "../zlib") -{ - target type(lib) "libpng.lib" - { - source type(c) "png.c" - source type(c) "pngerror.c" - source type(c) "pngget.c" - source type(c) "pngmem.c" - source type(c) "pngpread.c" - source type(c) "pngread.c" - source type(c) "pngrio.c" - source type(c) "pngrtran.c" - source type(c) "pngrutil.c" - source type(c) "pngset.c" - source type(c) "pngtrans.c" - source type(c) "pngwio.c" - source type(c) "pngwrite.c" - source type(c) "pngwtran.c" - source type(c) "pngwutil.c" - } -} - -option incl(searchpath, "../zlib"), opt(level, "2"), - link(libsearchpath, "../zlib") -{ - target type(exe) "pngtest.exe" - { - source type(c) "pngtest.c" - source type(lib) "libpng.lib" - source type(lib) "zlib.lib" - } -} diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/libpng.pc-configure.in b/irrlicht-1.6/source/Irrlicht/libpng/scripts/libpng.pc-configure.in deleted file mode 100644 index 9b5c54634..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/libpng.pc-configure.in +++ /dev/null @@ -1,10 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@/libpng12 - -Name: libpng -Description: Loads and saves PNG files -Version: 1.2.18 -Libs: -L${libdir} -lpng12 -Cflags: -I${includedir} @LIBPNG_NO_MMX@ diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/libpng.pc.in b/irrlicht-1.6/source/Irrlicht/libpng/scripts/libpng.pc.in deleted file mode 100644 index 494b0fd77..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/libpng.pc.in +++ /dev/null @@ -1,10 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@/libpng12 - -Name: libpng -Description: Loads and saves PNG files -Version: 1.2.18 -Libs: -L${libdir} -lpng12 -Cflags: -I${includedir} diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.32sunu b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.32sunu deleted file mode 100644 index 27a2b9af1..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.32sunu +++ /dev/null @@ -1,250 +0,0 @@ -# makefile for libpng on Solaris 2.x with cc -# Contributed by William L. Sebok, based on makefile.linux -# Copyright (C) 2002, 2006 Glenn Randers-Pehrson -# Copyright (C) 1998 Greg Roelofs -# Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h - -# Library name: -LIBNAME=libpng12 -PNGMAJ = 0 -PNGMIN = 1.2.18 -PNGVER = $(PNGMAJ).$(PNGMIN) - -# Shared library names: -LIBSO=$(LIBNAME).so -LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) -LIBSOVER=$(LIBNAME).so.$(PNGVER) -OLDSO=libpng.so -OLDSOMAJ=libpng.so.3 -OLDSOVER=libpng.so.3.$(PNGMIN) - -# Utilities: -CC=cc -AR_RC=ar rc -MKDIR_P=mkdir -p -LN_SF=ln -f -s -RANLIB=echo -RM_F=/bin/rm -f - -SUN_CC_FLAGS=-fast -xtarget=ultra -SUN_LD_FLAGS=-fast -xtarget=ultra - -# where make install puts libpng.a, libpng12.so and libpng12/png.h -prefix=/a -exec_prefix=$(prefix) - -# Where the zlib library and include files are located -# Changing these to ../zlib poses a security risk. If you want -# to have zlib in an adjacent directory, specify the full path instead of "..". -#ZLIBLIB=../zlib -#ZLIBINC=../zlib - -ZLIBLIB=/usr/lib -ZLIBINC=/usr/include - -WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes #-Wconversion -CFLAGS=-I$(ZLIBINC) $(SUN_CC_FLAGS) \ - # $(WARNMORE) -g -DPNG_DEBUG=5 -LDFLAGS=$(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) libpng.a -lz -lm - -INCPATH=$(prefix)/include -LIBPATH=$(exec_prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(exec_prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) -KPIC -o $@ $*.c - -all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo libdir=\"$(LIBPATH)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo R_opts=\"-R$(LIBPATH)\"; \ - echo ccopts=\"-xtarget=ultra\"; \ - echo ldopts=\"-xtarget=ultra\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBSO): $(LIBSOMAJ) - $(LN_SF) $(LIBSOMAJ) $(LIBSO) - -$(LIBSOMAJ): $(LIBSOVER) - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) - -$(LIBSOVER): $(OBJSDLL) - @case "`type ld`" in *ucb*) \ - echo; \ - echo '## WARNING:'; \ - echo '## The commands "CC" and "LD" must NOT refer to /usr/ucb/cc'; \ - echo '## and /usr/ucb/ld. If they do, you need to adjust your PATH'; \ - echo '## environment variable to put /usr/ccs/bin ahead of /usr/ucb.'; \ - echo '## The environment variable LD_LIBRARY_PATH should not be set'; \ - echo '## at all. If it is, things are likely to break because of'; \ - echo '## the libucb dependency that is created.'; \ - echo; \ - ;; \ - esac - $(LD) -G -L$(ZLIBLIB) -R$(ZLIBLIB) -h $(LIBSOMAJ) \ - -o $(LIBSOVER) $(OBJSDLL) - -$(OLDSOVER): $(OBJSDLL) - $(LD) -G -L$(ZLIBLIB) -R$(ZLIBLIB) -h $(OLDSOMAJ) \ - -o $(OLDSOVER) $(OBJSDLL) - -pngtest: pngtest.o $(LIBSO) - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h - -@$(RM_F) $(DI)/libpng - (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@$(RM_F) $(DL)/libpng.a - (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBSOVER) libpng.pc \ - $(OLDSOVER) - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(LIBSOMAJ) - -@$(RM_F) $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(OLDSO) - -@$(RM_F) $(DL)/$(OLDSOMAJ) - -@$(RM_F) $(DL)/$(OLDSOMAJ).$(PNGVER)* - cp $(LIBSOVER) $(DL) - cp $(OLDSOVER) $(DL) - chmod 755 $(DL)/$(LIBSOVER) - chmod 755 $(DL)/$(OLDSOVER) - (cd $(DL); \ - $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ - $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ - $(LN_SF) $(LIBSOMAJ) $(LIBSO)) - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc - -@$(RM_F) $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi - -@$(RM_F) $(DM)/man3/libpng.3 - -@$(RM_F) $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi - -@$(RM_F) $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@$(RM_F) $(DB)/libpng-config - -@$(RM_F) $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) $(SUN_CC_FLAGS) -I$(DI) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -o pngtestd -L$(DL) -R$(DL) `$(BINPATH)/$(LIBNAME)-config --ldflags` \ - $(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) - ./pngtestd pngtest.png - -test-installed: - echo - echo Testing installed dynamic shared library. - $(CC) $(SUN_CC_FLAGS) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` \ - $(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) - ./pngtesti pngtest.png - -clean: - $(RM_F) *.o libpng.a pngtest pngtesti pngout.png \ - libpng-config $(LIBSO) $(LIBSOMAJ)* \ - $(OLDSOVER) \ - libpng.pc - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h - -pngtest.o: png.h pngconf.h diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.64sunu b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.64sunu deleted file mode 100644 index 1bd0c501f..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.64sunu +++ /dev/null @@ -1,250 +0,0 @@ -# makefile for libpng on Solaris 2.x with cc -# Contributed by William L. Sebok, based on makefile.linux -# Copyright (C) 2002, 2006 Glenn Randers-Pehrson -# Copyright (C) 1998 Greg Roelofs -# Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h - -# Library name: -LIBNAME=libpng12 -PNGMAJ = 0 -PNGMIN = 1.2.18 -PNGVER = $(PNGMAJ).$(PNGMIN) - -# Shared library names: -LIBSO=$(LIBNAME).so -LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) -LIBSOVER=$(LIBNAME).so.$(PNGVER) -OLDSO=libpng.so -OLDSOMAJ=libpng.so.3 -OLDSOVER=libpng.so.3.$(PNGMIN) - -# Utilities: -CC=cc -AR_RC=ar rc -MKDIR_P=mkdir -p -LN_SF=ln -f -s -RANLIB=echo -RM_F=/bin/rm -f - -SUN_CC_FLAGS=-fast -xtarget=ultra -xarch=v9 -SUN_LD_FLAGS=-fast -xtarget=ultra -xarch=v9 - -# where make install puts libpng.a, libpng12.so and libpng12/png.h -prefix=/a -exec_prefix=$(prefix) - -# Where the zlib library and include files are located -# Changing these to ../zlib poses a security risk. If you want -# to have zlib in an adjacent directory, specify the full path instead of "..". -#ZLIBLIB=../zlib -#ZLIBINC=../zlib - -ZLIBLIB=/usr/lib -ZLIBINC=/usr/include - -WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes #-Wconversion -CFLAGS=-I$(ZLIBINC) $(SUN_CC_FLAGS) \ - # $(WARNMORE) -g -DPNG_DEBUG=5 -LDFLAGS=-L. -R. $(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng12 -lz -lm - -INCPATH=$(prefix)/include -LIBPATH=$(exec_prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(exec_prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) -KPIC -o $@ $*.c - -all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo libdir=\"$(LIBPATH)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo R_opts=\"-R$(LIBPATH)\"; \ - echo ccopts=\"-xtarget=ultra -xarch=v9\"; \ - echo ldopts=\"-xtarget=ultra -xarch=v9\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBSO): $(LIBSOMAJ) - $(LN_SF) $(LIBSOMAJ) $(LIBSO) - -$(LIBSOMAJ): $(LIBSOVER) - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) - -$(LIBSOVER): $(OBJSDLL) - @case "`type ld`" in *ucb*) \ - echo; \ - echo '## WARNING:'; \ - echo '## The commands "CC" and "LD" must NOT refer to /usr/ucb/cc'; \ - echo '## and /usr/ucb/ld. If they do, you need to adjust your PATH'; \ - echo '## environment variable to put /usr/ccs/bin ahead of /usr/ucb.'; \ - echo '## The environment variable LD_LIBRARY_PATH should not be set'; \ - echo '## at all. If it is, things are likely to break because of'; \ - echo '## the libucb dependency that is created.'; \ - echo; \ - ;; \ - esac - $(LD) -G -L$(ZLIBLIB) -R$(ZLIBLIB) -h $(LIBSOMAJ) \ - -o $(LIBSOVER) $(OBJSDLL) - -$(OLDSOVER): $(OBJSDLL) - $(LD) -G -L$(ZLIBLIB) -R$(ZLIBLIB) -h $(OLDSOMAJ) \ - -o $(OLDSOVER) $(OBJSDLL) - -pngtest: pngtest.o $(LIBSO) - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h - -@$(RM_F) $(DI)/libpng - (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@$(RM_F) $(DL)/libpng.a - (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBSOVER) libpng.pc \ - $(OLDSOVER) - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(LIBSOMAJ) - -@$(RM_F) $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(OLDSO) - -@$(RM_F) $(DL)/$(OLDSOMAJ) - -@$(RM_F) $(DL)/$(OLDSOMAJ).$(PNGVER)* - cp $(LIBSOVER) $(DL) - cp $(OLDSOVER) $(DL) - chmod 755 $(DL)/$(LIBSOVER) - chmod 755 $(DL)/$(OLDSOVER) - (cd $(DL); \ - $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ - $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ - $(LN_SF) $(LIBSOMAJ) $(LIBSO)) - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc - -@$(RM_F) $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi - -@$(RM_F) $(DM)/man3/libpng.3 - -@$(RM_F) $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi - -@$(RM_F) $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@$(RM_F) $(DB)/libpng-config - -@$(RM_F) $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) $(SUN_CC_FLAGS) -I$(DI) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -o pngtestd -L$(DL) -R$(DL) `$(BINPATH)/$(LIBNAME)-config --ldflags` \ - $(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) - ./pngtestd pngtest.png - -test-installed: - echo - echo Testing installed dynamic shared library. - $(CC) $(SUN_CC_FLAGS) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` \ - $(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) - ./pngtesti pngtest.png - -clean: - $(RM_F) *.o libpng.a pngtest pngtesti pngout.png \ - libpng-config $(LIBSO) $(LIBSOMAJ)* \ - $(OLDSOVER) \ - libpng.pc - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h - -pngtest.o: png.h pngconf.h diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.acorn b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.acorn deleted file mode 100644 index 2cc0f322b..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.acorn +++ /dev/null @@ -1,51 +0,0 @@ -# Project: libpng - - -# Toolflags: -CCflags = -c -depend !Depend -IC:,Zlib: -g -throwback -DRISCOS -fnah -C++flags = -c -depend !Depend -IC: -throwback -Linkflags = -aif -c++ -o $@ -ObjAsmflags = -throwback -NoCache -depend !Depend -CMHGflags = -LibFileflags = -c -l -o $@ -Squeezeflags = -o $@ - - -# Final targets: -@.libpng-lib: @.o.png @.o.pngerror @.o.pngrio @.o.pngwio @.o.pngmem \ - @.o.pngpread @.o.pngset @.o.pngget @.o.pngread @.o.pngrtran \ - @.o.pngrutil @.o.pngtrans @.o.pngwrite @.o.pngwtran @.o.pngwutil - LibFile $(LibFileflags) @.o.png @.o.pngerror @.o.pngrio @.o.pngrtran \ - @.o.pngmem @.o.pngpread @.o.pngset @.o.pngget @.o.pngread @.o.pngwio \ - @.o.pngrutil @.o.pngtrans @.o.pngwrite @.o.pngwtran @.o.pngwutil -@.mm-libpng-lib: @.mm.png @.mm.pngerror @.mm.pngrio @.mm.pngwio @.mm.pngmem \ - @.mm.pngpread @.mm.pngset @.mm.pngget @.mm.pngread @.mm.pngrtran \ - @.mm.pngrutil @.mm.pngtrans @.mm.pngwrite @.mm.pngwtran @.mm.pngwutil - LibFile $(LibFileflags) @.mm.png @.mm.pngerror @.mm.pngrio \ - @.mm.pngwio @.mm.pngmem @.mm.pngpread @.mm.pngset @.mm.pngget \ - @.mm.pngread @.mm.pngrtran @.mm.pngrutil @.mm.pngtrans @.mm.pngwrite \ - @.mm.pngwtran @.mm.pngwutil - - -# User-editable dependencies: -# (C) Copyright 1997 Tom Tanner -Test: @.pngtest - <Prefix$Dir>.pngtest - @remove <Prefix$Dir>.pngtest - -#It would be nice if you could stop "make" listing from here on! -@.pngtest: @.o.pngtest @.libpng-lib C:o.Stubs Zlib:zlib_lib - Link $(Linkflags) @.o.pngtest @.libpng-lib C:o.Stubs Zlib:zlib_lib - -.SUFFIXES: .o .mm .c - -.c.mm: - MemCheck.CC cc $(ccflags) -o $@ LibPng:$< -.c.o: - cc $(ccflags) -o $@ $< - - -# Static dependencies: - - -# Dynamic dependencies: diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.aix b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.aix deleted file mode 100644 index a172f5907..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.aix +++ /dev/null @@ -1,113 +0,0 @@ -# makefile for libpng using gcc (generic, static library) -# Copyright (C) 2002, 2006 Glenn Randers-Pehrson -# Copyright (C) 2000 Cosmin Truta -# Copyright (C) 2000 Marc O. Gloor (AIX support added, from makefile.gcc) -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h - -# Location of the zlib library and include files -ZLIBINC = ../zlib -ZLIBLIB = ../zlib - -# Compiler, linker, lib and other tools -CC = gcc -LD = $(CC) -AR_RC = ar rcs -MKDIR_P = mkdir -p -RANLIB = ranlib -RM_F = rm -f -LN_SF = ln -f -s - -LIBNAME=libpng12 -PNGMAJ = 0 -PNGMIN = 1.2.18 -PNGVER = $(PNGMAJ).$(PNGMIN) - -prefix=/usr/local -INCPATH=$(prefix)/include -LIBPATH=$(prefix)/lib - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) - -CDEBUG = -g -DPNG_DEBUG=5 -LDDEBUG = -CRELEASE = -O2 -LDRELEASE = -s -WARNMORE=-Wall -CFLAGS = -I$(ZLIBINC) $(WARNMORE) $(CRELEASE) -LDFLAGS = -L. -L$(ZLIBLIB) -lpng12 -lz -lm $(LDRELEASE) - -# File extensions -O=.o -A=.a -E= - -# Variables -OBJS = png$(O) pngerror$(O) pngget$(O) pngmem$(O) pngpread$(O) \ - pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) pngset$(O) \ - pngtrans$(O) pngwio$(O) pngwrite$(O) pngwtran$(O) pngwutil$(O) - -# Targets -all: $(LIBNAME)$(A) pngtest$(E) - -$(LIBNAME)$(A): $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -test: pngtest$(E) - ./pngtest$(E) - -pngtest$(E): pngtest$(O) $(LIBNAME)$(A) - $(LD) -o $@ pngtest$(O) $(LDFLAGS) - -install: $(LIBNAME)$(A) - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@$(RM_F) $(DI)/$(LIBNAME)/png.h - -@$(RM_F) $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) $(DI)/png.h - -@$(RM_F) $(DI)/pngconf.h - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h \ - $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) -r $(DI)/libpng - (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) - -@$(RM_F) $(DL)/$(LIBNAME)$(A) - -@$(RM_F) $(DL)/libpng$(A) - cp $(LIBNAME)$(A) $(DL)/$(LIBNAME)$(A) - chmod 644 $(DL)/$(LIBNAME)$(A) - (cd $(DL); $(LN_SF) $(LIBNAME)$(A) libpng$(A)) - (cd $(DI); $(LN_SF) libpng/* .;) - -clean: - $(RM_F) *.o $(LIBNAME)$(A) pngtest pngout.png - -png$(O): png.h pngconf.h -pngerror$(O): png.h pngconf.h -pngget$(O): png.h pngconf.h -pngmem$(O): png.h pngconf.h -pngpread$(O): png.h pngconf.h -pngread$(O): png.h pngconf.h -pngrio$(O): png.h pngconf.h -pngrtran$(O): png.h pngconf.h -pngrutil$(O): png.h pngconf.h -pngset$(O): png.h pngconf.h -pngtest$(O): png.h pngconf.h -pngtrans$(O): png.h pngconf.h -pngwio$(O): png.h pngconf.h -pngwrite$(O): png.h pngconf.h -pngwtran$(O): png.h pngconf.h -pngwutil$(O): png.h pngconf.h - diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.amiga b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.amiga deleted file mode 100644 index e05b395c2..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.amiga +++ /dev/null @@ -1,48 +0,0 @@ -# Commodore Amiga Makefile -# makefile for libpng and SAS C V6.5x compiler -# Copyright (C) 1995-2000 Wolf Faust -# For conditions of distribution and use, see copyright notice in png.h -# -# Note: Use #define PNG_READ_BIG_ENDIAN_SUPPORTED in pngconf.h -# -# Location/path of zlib include files -ZLIB=/zlib -#compiler -CC=sc -#compiler flags -# WARNING: a bug in V6.51 causes bad code with OPTGO -# So use V6.55 or set NOOPTGO!!!!!!!!! -CFLAGS= NOSTKCHK PARMS=REG OPTIMIZE OPTGO OPTPEEP OPTINLOCAL OPTINL\ - OPTLOOP OPTRDEP=4 OPTDEP=4 OPTCOMP=4 INCLUDEDIR=$(ZLIB) \ - DEFINE=PNG_INTERNAL -#linker flags -LDFLAGS= SD ND BATCH -#link libs -LDLIBS= libpng.lib libgz.lib LIB:scm.lib LIB:sc.lib Lib:amiga.lib -# linker -LN= slink -# file deletion command -RM= delete quiet -# library (.lib) file creation command -AR= oml -# make directory command -MKDIR= makedir - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -all: libpng.lib pngtest - -libpng.lib: $(OBJS) --$(RM) libpng.lib -$(AR) libpng.lib r $(OBJS) - -pngtest: pngtest.o libpng.lib -$(LN) <WITH < -$(LDFLAGS) -TO pngtest -FROM LIB:c.o pngtest.o -LIB $(LDLIBS) -< - diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.atari b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.atari deleted file mode 100644 index c806a0413..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.atari +++ /dev/null @@ -1,51 +0,0 @@ -# makefile for libpng -# Copyright (C) 2002 Glenn Randers-Pehrson -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h -# modified for LC56/ATARI assumes libz.lib is in same dir and uses default -# rules for library management -# -CFLAGS=-I..\zlib -O -LBR = png.lib -LDFLAGS=-lpng -lz -lm - -# where make install puts libpng.a and png.h -prefix=/usr/local -INCPATH=$(prefix)/include -LIBPATH=$(prefix)/lib - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -OBJS = $(LBR)(png.o) $(LBR)(pngset.o) $(LBR)(pngget.o) $(LBR)(pngrutil.o)\ - $(LBR)(pngtrans.o) $(LBR)(pngwutil.o)\ - $(LBR)(pngread.o) $(LBR)(pngerror.o) $(LBR)(pngwrite.o)\ - $(LBR)(pngrtran.o) $(LBR)(pngwtran.o)\ - $(LBR)(pngmem.o) $(LBR)(pngrio.o) $(LBR)(pngwio.o) $(LBR)(pngpread.o) - -all: $(LBR) pngtest.ttp - -$(LBR): $(OBJS) - -pngtest.ttp: pngtest.o $(LBR) - $(CC) $(CFLAGS) $(LDFLAGS) -o$@ pngtest.o - -install: libpng.a - -@mkdir $(DESTDIR)$(INCPATH) - -@mkdir $(DESTDIR)$(INCPATH)/libpng - -@mkdir $(DESTDIR)$(LIBPATH) - -@rm -f $(DESTDIR)$(INCPATH)/png.h - -@rm -f $(DESTDIR)$(INCPATH)/pngconf.h - cp png.h $(DESTDIR)$(INCPATH)/libpng - cp pngconf.h $(DESTDIR)$(INCPATH)/libpng - chmod 644 $(DESTDIR)$(INCPATH)/libpng/png.h - chmod 644 $(DESTDIR)$(INCPATH)/libpng/pngconf.h - (cd $(DESTDIR)$(INCPATH); ln -f -s $(LIBNAME) libpng; \ - ln -f -s $(LIBNAME)/* .) diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.bc32 b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.bc32 deleted file mode 100644 index 2bdecd73a..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.bc32 +++ /dev/null @@ -1,152 +0,0 @@ -# Makefile for libpng -# 32-bit Borland C++ (Note: All modules are compiled in C mode) -# To build the library, do: -# "make -fmakefile.bc32" -# -# -------------------- 32-bit Borland C++ -------------------- - -### Absolutely necessary for this makefile to work -.AUTODEPEND - -## Where zlib.h, zconf.h and zlib.lib are -ZLIB_DIR=..\zlib - - -## Compiler, linker and lib stuff -CC=bcc32 -LD=bcc32 -LIB=tlib - -# -3 = 386, -4 = 486, -5 = Pentium etc. -!ifndef TARGET_CPU -#TARGET_CPU=-6 -!endif - -# Use this if you don't want Borland's fancy exception handling -# (Caution: doesn't work with CBuilderX) -#NOEHLIB=noeh32.lib - -!ifdef DEBUG -CDEBUG=-v -LDEBUG=-v -!else -CDEBUG= -LDEBUG= -!endif - -# STACKOFLOW=1 -!ifdef STACKOFLOW -CDEBUG=$(CDEBUG) -N -LDEBUG=$(LDEBUG) -N -!endif - -# -O2 optimize for speed -# -d merge duplicate strings -# -k- turn off standard stack frame -# -w display all warnings -CFLAGS=-I$(ZLIB_DIR) -O2 -d -k- -w $(TARGET_CPU) $(CDEBUG) - -# -M generate map file -LDFLAGS=-L$(ZLIB_DIR) -M $(LDEBUG) - - -## Variables -OBJS = \ - png.obj \ - pngerror.obj \ - pngget.obj \ - pngmem.obj \ - pngpread.obj \ - pngread.obj \ - pngrio.obj \ - pngrtran.obj \ - pngrutil.obj \ - pngset.obj \ - pngtrans.obj \ - pngwio.obj \ - pngwrite.obj \ - pngwtran.obj \ - pngwutil.obj - -LIBOBJS = \ - +png.obj \ - +pngerror.obj \ - +pngget.obj \ - +pngmem.obj \ - +pngpread.obj \ - +pngread.obj \ - +pngrio.obj \ - +pngrtran.obj \ - +pngrutil.obj \ - +pngset.obj \ - +pngtrans.obj \ - +pngwio.obj \ - +pngwrite.obj \ - +pngwtran.obj \ - +pngwutil.obj - -LIBNAME=libpng.lib - - -## Implicit rules -# Braces let make "batch" calls to the compiler, -# 2 calls instead of 12; space is important. -.c.obj: - $(CC) $(CFLAGS) -c {$*.c } - -.c.exe: - $(CC) $(CFLAGS) $(LDFLAGS) $*.c $(LIBNAME) zlib.lib $(NOEHLIB) - -.obj.exe: - $(LD) $(LDFLAGS) $*.obj $(LIBNAME) zlib.lib $(NOEHLIB) - - -## Major targets -all: libpng pngtest - -libpng: $(LIBNAME) - -pngtest: pngtest.exe - -test: pngtest.exe - pngtest - - -## Minor Targets - -png.obj: png.c -pngerror.obj: pngerror.c -pngget.obj: pngget.c -pngmem.obj: pngmem.c -pngpread.obj: pngpread.c -pngread.obj: pngread.c -pngrio.obj: pngrio.c -pngrtran.obj: pngrtran.c -pngrutil.obj: pngrutil.c -pngset.obj: pngset.c -pngtrans.obj: pngtrans.c -pngwio.obj: pngwio.c -pngwrite.obj: pngwrite.c -pngwtran.obj: pngwtran.c -pngwutil.obj: pngwutil.c - - -$(LIBNAME): $(OBJS) - -del $(LIBNAME) - $(LIB) $(LIBNAME) @&&| -$(LIBOBJS), libpng -| - - -# Cleanup -clean: - -del *.obj - -del $(LIBNAME) - -del pngtest.exe - -del *.lst - -del *.map - -del *.tds - -del pngout.png - - -# End of makefile for libpng diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.beos b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.beos deleted file mode 100644 index 4300681df..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.beos +++ /dev/null @@ -1,222 +0,0 @@ -# makefile for libpng on BeOS x86 ELF with gcc -# modified from makefile.linux by Sander Stoks -# Copyright (C) 2002, 2006 Glenn Randers-Pehrson -# Copyright (C) 1999 Greg Roelofs -# Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h - -# Library name: -LIBNAME=libpng12 -PNGMAJ = 0 -PNGMIN = 1.2.18 -PNGVER = $(PNGMAJ).$(PNGMIN) - -# Shared library names: -LIBSO=$(LIBNAME).so -LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) -LIBSOVER=$(LIBNAME).so.$(PNGVER) -OLDSO=libpng.so -OLDSOMAJ=libpng.so.3 -OLDSOVER=libpng.so.3.$(PNGMIN) - -# Utilities: -CC=gcc -AR_RC=ar rc -MKDIR_P=mkdir -p -LN_SF=ln -sf -RANLIB=ranlib -RM_F=/bin/rm -f - -# Where the zlib library and include files are located -ZLIBLIB=/usr/local/lib -ZLIBINC=/usr/local/include - -ALIGN= -# For i386: -# ALIGN=-malign-loops=2 -malign-functions=2 - -WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes #-Wconversion - -# On BeOS, -O1 is actually better than -O3. This is a known bug but it's -# still here in R4.5 -CFLAGS=-I$(ZLIBINC) -Wall -O1 -funroll-loops \ - $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 -# LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng -lz -LDFLAGS=-L. -Wl,-soname=$(LIBSOMAJ) -L$(ZLIBLIB) -lz - -# where make install puts libpng.a, libpng12.so*, and png.h -prefix=/usr/local -exec_prefix=$(prefix) -INCPATH=$(prefix)/include -LIBPATH=$(exec_prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(exec_prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -OBJSDLL = $(OBJS) - -.SUFFIXES: .c .o - -all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo libs=\"-lpng12 -lz \"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBSO): $(LIBSOMAJ) - $(LN_SF) $(LIBSOMAJ) $(LIBSO) - cp $(LIBSO)* /boot/home/config/lib - -$(LIBSOMAJ): $(LIBSOVER) - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) - -$(LIBSOVER): $(OBJSDLL) - $(CC) -nostart -Wl,-soname,$(LIBSOMAJ) -o \ - $(LIBSOVER) $(OBJSDLL) $(LDFLAGS) - -$(OLDSOVER): $(OBJSDLL) - $(CC) -nostart -Wl,-soname,$(OLDSOMAJ) -o \ - $(OLDSOVER) $(OBJSDLL) $(LDFLAGS) - -pngtest: pngtest.o $(LIBSO) - $(CC) -L$(ZLIBLIB) -L. -lz -lpng12 -o pngtest pngtest.o - -test: pngtest - ./pngtest - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h - -@$(RM_F) $(DI)/libpng - (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@$(RM_F) $(DL)/libpng.a - (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBSOVER) libpng.pc \ - $(OLDSOVER) - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(LIBSOMAJ) - -@$(RM_F) $(DL)/$(OLDSO) - -@$(RM_F) $(DL)/$(OLDSOMAJ) - -@$(RM_F) $(DL)/$(OLDSOVER)* - cp $(LIBSOVER) $(DL) - cp $(OLDSOVER) $(DL) - chmod 755 $(DL)/$(LIBSOVER) - chmod 755 $(DL)/$(OLDSOVER) - (cd $(DL); \ - $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ - $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ - $(LN_SF) $(LIBSOMAJ) $(LIBSO)) - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc - -@$(RM_F) $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi - -@$(RM_F) $(DM)/man3/libpng.3 - -@$(RM_F) $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi - -@$(RM_F) $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@$(RM_F) $(DB)/libpng-config - -@$(RM_F) $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) -I$(DI) $(CFLAGS) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(DL) -L$(ZLIBLIB) -Wl,-rpath $(ZLIBLIB):$(DL) \ - -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtestd pngtest.png - -test-installed: - $(CC) $(CFLAGS) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \ - -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtesti pngtest.png - -clean: - $(RM_F) *.o libpng.a pngtest pngout.png libpng-config \ - $(LIBSO) $(LIBSOMAJ)* pngtesti \ - $(OLDSOVER) \ - libpng.pc - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h -pngtest.o: png.h pngconf.h diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.bor b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.bor deleted file mode 100644 index 49d684421..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.bor +++ /dev/null @@ -1,162 +0,0 @@ -# Makefile for libpng -# 16-bit Borland C++ (Note: All modules are compiled in C mode) -# To build the library, do: -# "make -fmakefile.bor -DMODEL=c" -# or: "make -fmakefile.bor -DMODEL=l" -# -# ------------ Borland C++ ------------ - -### Absolutely necessary for this makefile to work -.AUTODEPEND - -## Where zlib.h, zconf.h and zlib_MODEL.lib are -ZLIB_DIR=..\zlib - - -## Compiler, linker and lib stuff -CC=bcc -LD=bcc -LIB=tlib - -!ifndef MODEL -MODEL=l -!endif - -MODEL_ARG=-m$(MODEL) - -#TARGET_CPU=3 -# 2 = 286, 3 = 386, etc. -!ifndef TARGET_CPU -TARGET_CPU=2 -!endif - -# Use this if you don't want Borland's fancy exception handling -# (for Borland C++ 4.0 or later) -#NOEHLIB=noeh$(MODEL).lib - -!ifdef DEBUG -CDEBUG=-v -LDEBUG=-v -!else -CDEBUG= -LDEBUG= -!endif - -# STACKOFLOW=1 -!ifdef STACKOFLOW -CDEBUG=$(CDEBUG) -N -LDEBUG=$(LDEBUG) -N -!endif - -# -X- turn on dependency generation in the object file -# -w set all warnings on -# -O2 optimize for speed -# -Z global optimization -CFLAGS=-O2 -Z -X- -w -I$(ZLIB_DIR) -$(TARGET_CPU) $(MODEL_ARG) $(CDEBUG) - -# -M generate map file -LDFLAGS=-M -L$(ZLIB_DIR) $(MODEL_ARG) $(LDEBUG) - - -## Variables -OBJS = \ - png.obj \ - pngerror.obj \ - pngget.obj \ - pngmem.obj \ - pngpread.obj \ - pngread.obj \ - pngrio.obj \ - pngrtran.obj \ - pngrutil.obj \ - pngset.obj \ - pngtrans.obj \ - pngwio.obj \ - pngwrite.obj \ - pngwtran.obj \ - pngwutil.obj - -LIBOBJS = \ - +png.obj \ - +pngerror.obj \ - +pngget.obj \ - +pngmem.obj \ - +pngpread.obj \ - +pngread.obj \ - +pngrio.obj \ - +pngrtran.obj \ - +pngrutil.obj \ - +pngset.obj \ - +pngtrans.obj \ - +pngwio.obj \ - +pngwrite.obj \ - +pngwtran.obj \ - +pngwutil.obj - -LIBNAME=libpng$(MODEL).lib - - -## Implicit rules -# Braces let make "batch" calls to the compiler, -# 2 calls instead of 12; space is important. -.c.obj: - $(CC) $(CFLAGS) -c {$*.c } - -.c.exe: - $(CC) $(CFLAGS) $(LDFLAGS) $*.c $(LIBNAME) zlib_$(MODEL).lib $(NOEHLIB) - - -## Major targets -all: libpng pngtest - -libpng: $(LIBNAME) - -pngtest: pngtest$(MODEL).exe - -test: pngtest$(MODEL).exe - pngtest$(MODEL) - - -## Minor Targets - -png.obj: png.c -pngerror.obj: pngerror.c -pngget.obj: pngget.c -pngmem.obj: pngmem.c -pngpread.obj: pngpread.c -pngread.obj: pngread.c -pngrio.obj: pngrio.c -pngrtran.obj: pngrtran.c -pngrutil.obj: pngrutil.c -pngset.obj: pngset.c -pngtrans.obj: pngtrans.c -pngwio.obj: pngwio.c -pngwrite.obj: pngwrite.c -pngwtran.obj: pngwtran.c -pngwutil.obj: pngwutil.c - - -$(LIBNAME): $(OBJS) - -del $(LIBNAME) - $(LIB) $(LIBNAME) @&&| -$(LIBOBJS), libpng$(MODEL) -| - - -pngtest$(MODEL).obj: pngtest.c - $(CC) $(CFLAGS) -opngtest$(MODEL) -c pngtest.c - -pngtest$(MODEL).exe: pngtest$(MODEL).obj - $(LD) $(LDFLAGS) pngtest$(MODEL).obj $(LIBNAME) zlib_$(MODEL).lib $(NOEHLIB) - - -# Clean up anything else you want -clean: - -del *.obj - -del *.exe - -del *.lib - -del *.lst - -del *.map - - -# End of makefile for libpng diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.cygwin b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.cygwin deleted file mode 100644 index ce2c7c2ed..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.cygwin +++ /dev/null @@ -1,316 +0,0 @@ -# makefile for cygwin on x86 -# Builds both dll (with import lib) and static lib versions -# of the library, and builds two copies of pngtest: one -# statically linked and one dynamically linked. -# -# Copyright (C) 2002, 2006 Soren Anderson, Charles Wilson, -# and Glenn Randers-Pehrson, based on makefile for linux-elf w/mmx by: -# Copyright (C) 1998-2000 Greg Roelofs -# Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h - -# This makefile intends to support building outside the src directory -# if desired. When invoking it, specify an argument to SRCDIR on the -# command line that points to the top of the directory where your source -# is located. - -ifdef SRCDIR -VPATH = $(SRCDIR) -else -SRCDIR = . -endif - -# Override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. - -DESTDIR= - -# To enable assembler optimizations, add '-DPNG_USE_PNGGCCRD' to -# $CFLAGS, and include pnggccrd.o in $OBJS, below, and in the dependency -# list at the bottom of this makefile. - -CC=gcc -ifdef MINGW -MINGW_CCFLAGS=-mno-cygwin -I/usr/include/mingw -MINGW_LDFLAGS=-mno-cygwin -L/usr/lib/mingw -endif - -# Where "make install" puts libpng*.a, *png*.dll, png.h, and pngconf.h -ifndef prefix -prefix=/usr -$(warning You haven't specified a 'prefix=' location. Defaulting to "/usr") -endif -exec_prefix=$(prefix) - -# Where the zlib library and include files are located -ZLIBLIB= /usr/lib -ZLIBINC= -#ZLIBLIB=../zlib -#ZLIBINC=../zlib - -ALIGN= -# for i386: -#ALIGN=-malign-loops=2 -malign-functions=2 - -WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes #-Wconversion - -### if you use the asm, add pnggccrd.o to the OBJS list -### -### if you don't need thread safety, but want the asm accel -#CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD \ -# $(addprefix -I,$(ZLIBINC)) -Wall -O3 $(ALIGN) -funroll-loops \ -# -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 -### if you need thread safety and want (minimal) asm accel -#CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_USE_PNGGCCRD $(addprefix -I,$(ZLIBINC)) \ -# -Wall -O3 $(ALIGN) -funroll-loops \ -# -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 -### Normal (non-asm) compilation -CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \ - -Wall -O3 $(ALIGN) -funroll-loops \ - -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 - -LIBNAME = libpng12 -PNGMAJ = 0 -CYGDLL = 12 -PNGMIN = 1.2.18 -PNGVER = $(PNGMAJ).$(PNGMIN) - -SHAREDLIB=cygpng$(CYGDLL).dll -STATLIB=libpng.a -IMPLIB=libpng.dll.a -SHAREDDEF=libpng.def -LIBS=$(SHAREDLIB) $(STATLIB) -EXE=.exe - -LDFLAGS=$(strip -L. $(MINGW_LDFLAGS) -lpng $(addprefix -L,$(ZLIBLIB)) -lz) -LDSFLAGS=$(strip -shared -L. $(MINGW_LDFLAGS) -Wl,--export-all) -LDEXTRA=-Wl,--out-implib=$(IMPLIB) $(addprefix -L,$(ZLIBLIB)) -lz - -MKDIR_P=/bin/mkdir -pv -RANLIB=ranlib -#RANLIB=echo - -INCPATH=$(prefix)/include -LIBPATH=$(exec_prefix)/lib - -BINPATH=$(exec_prefix)/bin -MANPATH=$(prefix)/man -MAN3PATH=$(MANPATH)/man3 -MAN5PATH=$(MANPATH)/man5 - -# cosmetic: shortened strings: -S =$(SRCDIR) -D =$(DESTDIR) -DB =$(D)$(BINPATH) -DI =$(D)$(INCPATH) -DL =$(D)$(LIBPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o # pnggccrd.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -%.o : %.c - $(CC) -c $(CFLAGS) -o $@ $< -%.pic.o : CFLAGS += -DPNG_BUILD_DLL -%.pic.o : %.c - $(CC) -c $(CFLAGS) -o $@ $< - -all: all-static all-shared libpng.pc libpng-config libpng.pc libpng-config - -# Make this to verify that "make [...] install" will do what you want. -buildsetup-tell: - @echo VPATH is set to: \"$(VPATH)\" - @echo prefix is set to: \"$(prefix)\" - @echo -e INCPATH,LIBPATH, etc. are set to:'\n' \ - $(addprefix $(D),$(INCPATH)'\n' $(LIBPATH)'\n' $(BINPATH)'\n' \ - $(MANPATH)'\n' $(MAN3PATH)'\n' $(MAN5PATH)'\n')'\n' - -libpng.pc: scripts/libpng.pc.in - @echo -e Making pkg-config file for this libpng installation..'\n' \ - using PREFIX=\"$(prefix)\"'\n' - cat $(S)/scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! | \ - sed -e s/-lm// > libpng.pc - -libpng-config: scripts/libpng-config-head.in scripts/libpng-config-body.in - @echo -e Making $(LIBNAME) libpng-config file for this libpng \ - installation..'\n' using PREFIX=\"$(prefix)\"'\n' - ( cat $(S)/scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo libs=\"-lpng$(CYGDLL) -lz\"; \ - cat $(S)/scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -static: all-static -shared: all-shared -all-static: $(STATLIB) pngtest-stat$(EXE) -all-shared: $(SHAREDLIB) pngtest$(EXE) - -pnggccrd.o: pnggccrd.c png.h pngconf.h - @echo "" - @echo ' You can ignore the "control reaches end of non-void function"' - @echo ' warning and "<variable> defined but not used" warnings:' - @echo "" - $(CC) -c $(CFLAGS) -o $@ $< - -pnggccrd.pic.o: pnggccrd.c png.h pngconf.h - @echo "" - @echo ' You can ignore the "control reaches end of non-void function"' - @echo ' warning and "<variable> defined but not used" warnings:' - @echo "" - $(CC) -c $(CFLAGS) -DPNG_BUILD_DLL -o $@ $< - -$(STATLIB): $(OBJS) - ar rc $@ $(OBJS) - $(RANLIB) $@ - -$(SHAREDDEF): scripts/pngw32.def - cat $< | sed -e '1{G;s/^\(.*\)\(\n\)/EXPORTS/;};2,/^EXPORTS/d' | \ - sed -e 's/\([^;]*\);/;/' > $@ - -$(SHAREDLIB): $(OBJSDLL) $(SHAREDDEF) - $(CC) $(LDSFLAGS) -o $@ $(OBJSDLL) -L. $(LDEXTRA) - -pngtest$(EXE): pngtest.pic.o $(SHAREDLIB) - $(CC) $(CFLAGS) $< $(LDFLAGS) -o $@ - -pngtest-stat$(EXE): pngtest.o $(STATLIB) - $(CC) -static $(CFLAGS) $< $(LDFLAGS) -o $@ - -pngtest.pic.o: pngtest.c - $(CC) $(CFLAGS) -c $< -o $@ - -pngtest.o: pngtest.c - $(CC) $(CFLAGS) -c $< -o $@ - -test: test-static test-shared - -test-static: pngtest-stat$(EXE) - ./pngtest-stat $(S)/pngtest.png - -test-shared: pngtest$(EXE) - ./pngtest $(S)/pngtest.png - -install-static: $(STATLIB) install-headers install-man - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - install -m 644 $(STATLIB) $(DL)/$(LIBNAME).a - -@rm -f $(DL)/$(STATLIB) - (cd $(DL); ln -sf $(LIBNAME).a $(STATLIB)) - -install-shared: $(SHAREDLIB) libpng.pc libpng-config install-headers install-man - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc - -@/bin/rm -f $(DL)/pkgconfig/libpng.pc - install -m 644 $(IMPLIB) $(DL)/$(LIBNAME).dll.a - -@rm -f $(DL)/$(IMPLIB) - (cd $(DL); ln -sf $(LIBNAME).dll.a $(IMPLIB)) - install -s -m 755 $(SHAREDLIB) $(DB) - install -m 644 libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc) - -install-headers: - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - -@rm -f $(DI)/png.h - -@rm -f $(DI)/pngconf.h - install -m 644 $(S)/png.h $(S)/pngconf.h $(DI)/$(LIBNAME) - -@rm -f $(DI)/libpng - (cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .) - -install-man: - -@if [ ! -d $(D)$(MAN3PATH) ]; then $(MKDIR_P) $(D)$(MAN3PATH); fi - -@if [ ! -d $(D)$(MAN5PATH) ]; then $(MKDIR_P) $(D)$(MAN5PATH); fi - install -m 644 $(S)/libpngpf.3 $(S)/libpng.3 $(D)$(MAN3PATH) - install -m 644 $(S)/png.5 $(D)$(MAN5PATH) - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@/bin/rm -f $(DB)/libpng-config - -@/bin/rm -f $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); ln -sf $(LIBNAME)-config libpng-config) - -# Run this to verify that a future `configure' run will pick up the settings -# you want. -test-config-install: SHELL=/bin/bash -test-config-install: $(DB)/libpng-config - @echo -e Testing libpng-config functions...'\n' - @ for TYRA in LDFLAGS CPPFLAGS CFLAGS LIBS VERSION; \ - do \ - printf "(%d)\t %10s =%s\n" $$(($$gytiu + 1)) $$TYRA \ - "$$($(DB)/libpng-config `echo --$$TYRA |tr '[:upper:]' '[:lower:]'`)"; \ - gytiu=$$(( $$gytiu + 1 )); \ - done - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) -I$(DI) $(CFLAGS) \ - `$(BINPATH)/libpng12-config --cflags` pngtest.c \ - -L$(DL) -L$(ZLIBLIB) \ - -o pngtestd `$(BINPATH)/libpng12-config --ldflags` - ./pngtestd pngtest.png - -test-installed: - $(CC) $(CFLAGS) \ - `$(BINPATH)/libpng12-config --cflags` pngtest.c \ - -L$(ZLIBLIB) \ - -o pngtesti$(EXE) `$(BINPATH)/libpng12-config --ldflags` - ./pngtesti$(EXE) pngtest.png - -clean: - /bin/rm -f *.pic.o *.o $(STATLIB) $(IMPLIB) $(SHAREDLIB) \ - pngtest-stat$(EXE) pngtest$(EXE) pngout.png $(SHAREDDEF) \ - libpng-config libpng.pc pngtesti$(EXE) - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -.PHONY: buildsetup-tell libpng.pc libpng-config test-config-install clean - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h png.c -pngerror.o pngerror.pic.o: png.h pngconf.h pngerror.c -pngrio.o pngrio.pic.o: png.h pngconf.h pngrio.c -pngwio.o pngwio.pic.o: png.h pngconf.h pngwio.c -pngmem.o pngmem.pic.o: png.h pngconf.h pngmem.c -pngset.o pngset.pic.o: png.h pngconf.h pngset.c -pngget.o pngget.pic.o: png.h pngconf.h pngget.c -pngread.o pngread.pic.o: png.h pngconf.h pngread.c -pngrtran.o pngrtran.pic.o: png.h pngconf.h pngrtran.c -pngrutil.o pngrutil.pic.o: png.h pngconf.h pngrutil.c -pngtrans.o pngtrans.pic.o: png.h pngconf.h pngtrans.c -pngwrite.o pngwrite.pic.o: png.h pngconf.h pngwrite.c -pngwtran.o pngwtran.pic.o: png.h pngconf.h pngwtran.c -pngwutil.o pngwutil.pic.o: png.h pngconf.h pngwutil.c -pngpread.o pngpread.pic.o: png.h pngconf.h pngpread.c - -pngtest.o: png.h pngconf.h pngtest.c -pngtest-stat.o: png.h pngconf.h pngtest.c - - - diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.darwin b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.darwin deleted file mode 100644 index a5df6c46d..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.darwin +++ /dev/null @@ -1,230 +0,0 @@ -# makefile for libpng on Darwin / Mac OS X -# Copyright (C) 2002, 2004, 2006 Glenn Randers-Pehrson -# Copyright (C) 2001 Christoph Pfisterer -# derived from makefile.linux: -# Copyright (C) 1998, 1999 Greg Roelofs -# Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h - -# where "make install" puts libpng.a, libpng12.dylib, png.h and pngconf.h -prefix=/usr/local -exec_prefix=$(prefix) - -# Where the zlib library and include files are located -#ZLIBLIB=/usr/local/lib -#ZLIBINC=/usr/local/include -ZLIBLIB=../zlib -ZLIBINC=../zlib - -# Library name: -LIBNAME = libpng12 -PNGMAJ = 0 -PNGMIN = 1.2.18 -PNGVER = $(PNGMAJ).$(PNGMIN) - -# Shared library names: -LIBSO=$(LIBNAME).dylib -LIBSOMAJ=$(LIBNAME).$(PNGMAJ).dylib -LIBSOVER=$(LIBNAME).$(PNGVER).dylib -OLDSO=libpng.dylib -OLDSOMAJ=libpng.3.dylib -OLDSOVER=libpng.3.$(PNGMIN).dylib - -# Utilities: -CC=cc -AR_RC=ar rc -MKDIR_P=mkdir -p -LN_SF=ln -sf -RANLIB=ranlib -RM_F=/bin/rm -f - -CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops -LDFLAGS=-L. -L$(ZLIBLIB) -lpng12 -lz - -INCPATH=$(prefix)/include -LIBPATH=$(exec_prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(exec_prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) -fno-common -o $@ $*.c - -all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! | \ - sed -e s/-lm// > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo libs=\"-lpng12 -lz\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBSO): $(LIBSOMAJ) - $(LN_SF) $(LIBSOMAJ) $(LIBSO) - -$(LIBSOMAJ): $(LIBSOVER) - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) - -$(LIBSOVER): $(OBJSDLL) - $(CC) -dynamiclib \ - -install_name $(LIBPATH)/$(LIBSOMAJ) \ - -current_version $(PNGVER) -compatibility_version $(PNGVER) \ - -o $(LIBSOVER) \ - $(OBJSDLL) -L$(ZLIBLIB) -lz - -$(OLDSOVER): $(OBJSDLL) - $(CC) -dynamiclib \ - -install_name $(LIBPATH)/$(OLDSOMAJ) \ - -current_version 3 -compatibility_version 3 \ - -o $(OLDSOVER) \ - $(OBJSDLL) -L$(ZLIBLIB) -lz - -pngtest: pngtest.o $(LIBSO) - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h - -@$(RM_F) $(DI)/libpng - (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - $(RANLIB) $(DL)/$(LIBNAME).a - -@$(RM_F) $(DL)/libpng.a - (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBSO) libpng.pc \ - $(OLDSOVER) - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@$(RM_F) $(DL)/$(LIBNAME).$(PNGVER)*.dylib - -@$(RM_F) $(DL)/$(LIBNAME).$(PNGMAJ)*.dylib - -@$(RM_F) $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(OLDSO) - -@$(RM_F) $(DL)/$(OLDSOMAJ) - -@$(RM_F) $(DL)/libpng.3.$(PNGMIN)*.dylib - cp $(LIBSOVER) $(DL) - cp $(OLDSOVER) $(DL) - chmod 755 $(DL)/$(LIBSOVER) - chmod 755 $(DL)/$(OLDSOVER) - (cd $(DL); \ - $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ - $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ - $(LN_SF) $(LIBSOMAJ) $(LIBSO)) - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc - -@$(RM_F) $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi - -@$(RM_F) $(DM)/man3/libpng.3 - -@$(RM_F) $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi - -@$(RM_F) $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@$(RM_F) $(DB)/libpng-config - -@$(RM_F) $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) -I$(DI) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(DL) -L$(ZLIBLIB) \ - -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtestd pngtest.png - -test-installed: - $(CC) $(CFLAGS) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(ZLIBLIB) \ - -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtesti pngtest.png - -clean: - $(RM_F) *.o libpng.a pngtest pngout.png libpng-config \ - $(OLDSOVER) \ - libpng.pc $(LIBNAME).*dylib pngtesti - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h - -pngtest.o: png.h pngconf.h diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.dec b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.dec deleted file mode 100644 index 26e41571d..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.dec +++ /dev/null @@ -1,210 +0,0 @@ -# makefile for libpng on DEC Alpha Unix -# Copyright (C) 2000-2002, 2006 Glenn Randers-Pehrson -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h - -# Library name: -PNGMAJ = 0 -PNGMIN = 1.2.18 -PNGVER = $(PNGMAJ).$(PNGMIN) -LIBNAME = libpng12 - -# Shared library names: -LIBSO=$(LIBNAME).so -LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) -LIBSOVER=$(LIBNAME).so.$(PNGVER) -OLDSO=libpng.so -OLDSOMAJ=libpng.so.3 -OLDSOVER=libpng.so.3.$(PNGMIN) - -# Utilities: -AR_RC=ar rc -CC=cc -MKDIR_P=mkdir -LN_SF=ln -f -s -RANLIB=ranlib -RM_F=/bin/rm -f - -# where make install puts libpng.a and png.h -prefix=/usr/local -exec_prefix=$(prefix) -INCPATH=$(prefix)/include -LIBPATH=$(exec_prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(exec_prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -# Where the zlib library and include files are located -#ZLIBLIB=/usr/local/lib -#ZLIBINC=/usr/local/include -ZLIBLIB=../zlib -ZLIBINC=../zlib - -CFLAGS=-std -w1 -I$(ZLIBINC) -O # -g -DPNG_DEBUG=1 -LDFLAGS=-L$(ZLIBLIB) -rpath $(ZLIBLIB) libpng.a -lz -lm - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -all: $(LIBSO) libpng.a pngtest libpng.pc libpng-config - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo ccopts=\"-std\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBSO): $(LIBSOMAJ) - $(LN_SF) $(LIBSOMAJ) $(LIBSO) - -$(LIBSOMAJ): $(LIBSOVER) - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) - -$(LIBSOVER): $(OBJS) - $(CC) -shared -o $@ $(OBJS) -L$(ZLIBLIB) \ - -soname $(LIBSOMAJ) - -$(OLDSOVER): $(OBJS) - $(CC) -shared -o $@ $(OBJS) -L$(ZLIBLIB) \ - -soname $(OLDSOMAJ) - -pngtest: pngtest.o libpng.a - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h - -@/bin/rm -f $(DI)/libpng - (cd $(DI); $(LN_SF)(LIBNAME) libpng; $(LN_SF)(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@/bin/rm -f $(DL)/libpng.a - (cd $(DL); $(LN_SF)(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBSOVER) libpng.pc \ - $(OLDSOVER) - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@/bin/rm -f $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) - -@/bin/rm -f $(DL)/$(LIBSOMAJ) - -@/bin/rm -f $(DL)/$(OLDSO) - -@/bin/rm -f $(DL)/$(OLDSOMAJ) - -@/bin/rm -f $(DL)/$(OLDSOVER)* - cp $(LIBSOVER) $(DL) - cp $(OLDSOVER) $(DL) - chmod 755 $(DL)/$(LIBSOVER) - chmod 755 $(DL)/$(OLDSOVER) - (cd $(DL); \ - $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ - $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ - $(LN_SF)(LIBSOVER) $(LIBSOMAJ); \ - $(LN_SF)(LIBSOMAJ) $(LIBSO)) - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc - -@/bin/rm -f $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; $(LN_SF)(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi - -@/bin/rm -f $(DM)/man3/libpng.3 - -@/bin/rm -f $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi - -@/bin/rm -f $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@/bin/rm -f $(DB)/libpng-config - -@/bin/rm -f $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); $(LN_SF)(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) -w1 -I$(DI) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(DL) -L$(ZLIBLIB) -R$(ZLIBLIB) -R$(DL) \ - -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtestd pngtest.png - -test-installed: - echo - echo Testing installed dynamic shared library. - $(CC) -w1 -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(ZLIBLIB) -R$(ZLIBLIB) \ - -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtesti pngtest.png - -clean: - /bin/rm -f *.o libpng.a pngtest pngtesti pngout.png \ - libpng-config $(LIBSO) $(LIBSOMAJ)* \ - $(OLDSOVER) \ - libpng.pc - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h -pngpread.o: png.h pngconf.h - diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.dj2 b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.dj2 deleted file mode 100644 index 146d4092b..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.dj2 +++ /dev/null @@ -1,55 +0,0 @@ -# DJGPP (DOS gcc) makefile for libpng -# Copyright (C) 2002 Glenn Randers-Pehrson -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h - -# where make install will put libpng.a and png.h -#prefix=/usr/local -prefix=. -INCPATH=$(prefix)/include -LIBPATH=$(prefix)/lib - -CC=gcc -CFLAGS=-I../zlib -O -LDFLAGS=-L. -L../zlib/ -lpng -lz -lm - -RANLIB=ranlib - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o pngwtran.o \ - pngmem.o pngerror.o pngpread.o - -all: libpng.a pngtest - -libpng.a: $(OBJS) - ar rc $@ $(OBJS) - $(RANLIB) $@ - -pngtest: pngtest.o libpng.a - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - coff2exe pngtest - -test: pngtest - ./pngtest -clean: - rm -f *.o libpng.a pngtest pngout.png - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngpread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h - diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.elf b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.elf deleted file mode 100644 index b728a4e41..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.elf +++ /dev/null @@ -1,271 +0,0 @@ -# makefile for libpng.a and libpng12.so on Linux ELF with gcc -# Copyright (C) 1998, 1999, 2002, 2006 Greg Roelofs and Glenn Randers-Pehrson -# Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h - -# Modified for Debian by Junichi Uekawa and Josselin Mouette -# Major modifications are: -# * link libpng explicitly with libz and libm -# * $(OLDSO).3 is a symlink rather than a different library -# * versioned symbols - -# Library name: -LIBNAME = libpng12 -PNGMAJ = 0 -PNGMIN = 1.2.18 -PNGVER = $(PNGMAJ).$(PNGMIN) - -# Shared library names: -LIBSO=$(LIBNAME).so -LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) -LIBSOVER=$(LIBNAME).so.$(PNGVER) -OLDSO=libpng.so -OLDSOMAJ=libpng.so.3 -OLDSOVER=libpng.so.3.$(PNGMIN) - -# Utilities: -AR_RC=ar rc -CC=gcc -MKDIR_P=mkdir -p -LN_SF=ln -sf -RANLIB=ranlib -RM_F=/bin/rm -f - -# where "make install" puts libpng12.a, libpng12.so*, -# libpng12/png.h and libpng12/pngconf.h -# Prefix must be a full pathname. -prefix=/usr/local -exec_prefix=$(prefix) - -# Where the zlib library and include files are located. -ZLIBLIB=/usr/local/lib -ZLIBINC=/usr/local/include -# ZLIBLIB=../zlib -# ZLIBINC=../zlib - -ALIGN= -# for i386: -#ALIGN=-malign-loops=2 -malign-functions=2 - -WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes #-Wconversion - -# for pgcc version 2.95.1, -O3 is buggy; don't use it. - -CFLAGS=-Wall -D_REENTRANT -O2 \ - $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 - -LDFLAGS=-L. -lpng12 -LDFLAGS_A=libpng.a -lz -lm -LIBADDFLAGS=-lz -lm - - -INCPATH=$(prefix)/include -LIBPATH=$(exec_prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(exec_prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c - -all: libpng.a $(LIBSO) pngtest pngtest-static libpng.pc libpng-config - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng.syms: png.h pngconf.h - $(CC) $(CFLAGS) -E -DPNG_BUILDSYMS -DPNG_INTERNAL png.h |\ - awk -F '[\t [\\]();]' -v PNGMAJ=$(PNGMAJ) 'BEGIN{printf("PNG12_%s {global:\n",PNGMAJ)}\ - { for (i=1;i+2<=NF;++i)\ - if ($$(i)=="PNG_FUNCTION_EXPORT" && $$(i+2)=="END")\ - print $$(i+1) ";";\ - for (i=1;i+1<=NF;++i)\ - if ($$(i)=="PNG_DATA_EXPORT")\ - print $$(i+1) ";";}\ - END{print "local: *; };"}' >$@.new - $(RM_F) $@ - mv $@.new $@ - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo L_opts=\"\"; \ - echo R_opts=\"\"; \ - echo libs=\"-lpng12\"; \ - echo all_libs=\"-lpng12 $(LIBADDFLAGS)\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBSO): $(LIBSOMAJ) - $(LN_SF) $(LIBSOMAJ) $(LIBSO) - -$(LIBSOMAJ): $(LIBSOVER) - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) - -$(LIBSOVER): $(OBJSDLL) libpng.syms - $(CC) -shared -Wl,-soname,$(LIBSOMAJ) \ - -Wl,-version-script,libpng.syms \ - -o $(LIBSOVER) \ - $(OBJSDLL) - -$(OLDSOVER): $(OBJSDLL) libpng.syms - $(CC) -shared -Wl,-soname,$(OLDSOMAJ) \ - -Wl,-version-script,libpng.syms \ - -o $(OLDSOVER) \ - $(OBJSDLL) - -pngtest: pngtest.o $(LIBSO) - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -pngtest-static: pngtest.o libpng.a - $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A) - -test: pngtest pngtest-static - @echo "" - @echo " Running pngtest dynamically linked with $(LIBSO):" - @echo "" - LD_LIBRARY_PATH=".:${LD_LIBRARY_PATH}" ./pngtest - @echo "" - @echo " Running pngtest statically linked with libpng.a:" - @echo "" - ./pngtest-static - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h - -@$(RM_F) $(DI)/libpng - (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@$(RM_F) $(DL)/libpng.a - (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBSOVER) libpng.pc \ - $(OLDSOVER) - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(LIBSOMAJ) - -@$(RM_F) $(DL)/$(OLDSO) - -@$(RM_F) $(DL)/$(OLDSOMAJ) - -@$(RM_F) $(DL)/$(OLDSOVER)* - cp $(LIBSOVER) $(DL) - cp $(OLDSOVER) $(DL) - chmod 755 $(DL)/$(LIBSOVER) - chmod 755 $(DL)/$(OLDSOVER) - (cd $(DL); \ - $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ - $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ - $(LN_SF) $(LIBSOMAJ) $(LIBSO)) - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc - -@$(RM_F) $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi - -@$(RM_F) $(DM)/man3/libpng.3 - -@$(RM_F) $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi - -@$(RM_F) $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@$(RM_F) $(DB)/libpng-config - -@$(RM_F) $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) -I$(DI) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(DL) -L$(ZLIBLIB) -Wl, -rpath,$(DL) -Wl,-rpath,$(ZLIBLIB) \ - -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtestd pngtest.png - -test-installed: - $(CC) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \ - -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtesti pngtest.png - -clean: - $(RM_F) *.o libpng.a libpng.syms pngtest pngout.png libpng-config \ - $(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \ - $(OLDSOVER) \ - libpng.pc - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h - -pngtest.o: png.h pngconf.h diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.freebsd b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.freebsd deleted file mode 100644 index 8767ce3db..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.freebsd +++ /dev/null @@ -1,48 +0,0 @@ -# makefile for libpng under FreeBSD -# Copyright (C) 2002, 2007 Glenn Randers-Pehrson and Andrey A. Chernov -# For conditions of distribution and use, see copyright notice in png.h - -PREFIX?= /usr/local -SHLIB_VER?= 5 - -LIB= png -SHLIB_MAJOR= ${SHLIB_VER} -SHLIB_MINOR= 0 -NOPROFILE= YES -NOOBJ= YES - -# where make install puts libpng.a and png.h -DESTDIR= ${PREFIX} -LIBDIR= /lib -INCS= png.h pngconf.h -INCSDIR= /include/libpng -INCDIR= ${INCSDIR} # for 4.x bsd.lib.mk -MAN= libpng.3 libpngpf.3 png.5 -MANDIR= /man/man -SYMLINKS= libpng/png.h ${INCSDIR}/../png.h \ - libpng/pngconf.h ${INCSDIR}/../pngconf.h -LDADD+= -lm -lz -DPADD+= ${LIBM} ${LIBZ} - -CFLAGS+= -I. -DPNG_USE_PNGGCCRD -.if (${MACHINE_ARCH} != "i386") -CFLAGS+= -DPNG_NO_MMX_CODE -.endif - -SRCS= png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \ - pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \ - pngwtran.c pngmem.c pngerror.c pngpread.c pnggccrd.c - -pngtest: pngtest.o libpng.a - ${CC} ${CFLAGS} -L. -static -o pngtest pngtest.o -lpng -lz -lm - -CLEANFILES= pngtest pngtest.o pngout.png - -test: pngtest - ./pngtest - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -.include <bsd.lib.mk> diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.gcc b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.gcc deleted file mode 100644 index 0ca7a86b6..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.gcc +++ /dev/null @@ -1,79 +0,0 @@ -# makefile for libpng using gcc (generic, static library) -# Copyright (C) 2000 Cosmin Truta -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h - -# Location of the zlib library and include files -ZLIBINC = ../zlib -ZLIBLIB = ../zlib - -# Compiler, linker, lib and other tools -CC = gcc -LD = $(CC) -AR_RC = ar rcs -RANLIB = ranlib -RM_F = rm -f - -CDEBUG = -g -DPNG_DEBUG=5 -LDDEBUG = -CRELEASE = -O2 -LDRELEASE = -s -#CFLAGS = -Wall $(CDEBUG) -CFLAGS = -Wall $(CRELEASE) -#LDFLAGS = $(LDDEBUG) -LDFLAGS = $(LDRELEASE) -LIBS = -lz -lm - -# File extensions -O=.o -A=.a -EXE= - -# Variables -OBJS = png$(O) pngerror$(O) pngget$(O) pngmem$(O) pngpread$(O) \ - pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) pngset$(O) \ - pngtrans$(O) pngwio$(O) pngwrite$(O) pngwtran$(O) pngwutil$(O) - -# Targets -all: static - -.c$(O): - $(CC) -c $(CFLAGS) -I$(ZLIBINC) $< - -static: libpng$(A) pngtest$(EXE) - -shared: - @echo This is a generic makefile that cannot create shared libraries. - @echo Please use a configuration that is specific to your platform. - @false - -libpng$(A): $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -test: pngtest$(EXE) - ./pngtest$(EXE) - -pngtest$(EXE): pngtest$(O) libpng$(A) - $(LD) $(LDFLAGS) -L$(ZLIBLIB) -o $@ pngtest$(O) libpng$(A) $(LIBS) - -clean: - $(RM_F) *$(O) libpng$(A) pngtest$(EXE) pngout.png - -png$(O): png.h pngconf.h -pngerror$(O): png.h pngconf.h -pngget$(O): png.h pngconf.h -pngmem$(O): png.h pngconf.h -pngpread$(O): png.h pngconf.h -pngread$(O): png.h pngconf.h -pngrio$(O): png.h pngconf.h -pngrtran$(O): png.h pngconf.h -pngrutil$(O): png.h pngconf.h -pngset$(O): png.h pngconf.h -pngtest$(O): png.h pngconf.h -pngtrans$(O): png.h pngconf.h -pngwio$(O): png.h pngconf.h -pngwrite$(O): png.h pngconf.h -pngwtran$(O): png.h pngconf.h -pngwutil$(O): png.h pngconf.h - diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.gcmmx b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.gcmmx deleted file mode 100644 index 1afed82b3..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.gcmmx +++ /dev/null @@ -1,275 +0,0 @@ -# makefile for libpng.a and libpng12.so on Linux ELF with gcc using MMX -# assembler code -# Copyright 2002, 2006 Greg Roelofs and Glenn Randers-Pehrson -# Copyright 1998-2001 Greg Roelofs -# Copyright 1996-1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h - -# CAUTION: Do not use this makefile with gcc versions 2.7.2.2 and earlier. - -# WARNING: The assembler code in pnggccrd.c may not be thread safe. - -# NOTE: When testing MMX performance on a multitasking system, make sure -# there are no floating-point programs (e.g., SETI@Home) running in -# the background! Context switches between MMX and FPU are expensive. - -# Library name: -LIBNAME = libpng12 -PNGMAJ = 0 -PNGMIN = 1.2.18 -PNGVER = $(PNGMAJ).$(PNGMIN) - -# Shared library names: -LIBSO=$(LIBNAME).so -LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) -LIBSOVER=$(LIBNAME).so.$(PNGVER) -OLDSO=libpng.so -OLDSOMAJ=libpng.so.3 -OLDSOVER=libpng.so.3.$(PNGMIN) - -# Utilities: -CC = gcc -LD = $(CC) -AR_RC = ar rc -LN_SF = ln -sf -MKDIR_P = mkdir -p -RANLIB = ranlib -RM_F = /bin/rm -f - -# where "make install" puts libpng12.a, libpng12.so*, -# libpng12/png.h and libpng12/pngconf.h -# Prefix must be a full pathname. -prefix=/usr/local -exec_prefix=$(prefix) - -# Where the zlib library and include files are located. -#ZLIBLIB=/usr/local/lib -#ZLIBINC=/usr/local/include -ZLIBLIB=../zlib -ZLIBINC=../zlib - -ALIGN= -# for i386: -#ALIGN=-malign-loops=2 -malign-functions=2 - -WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes #-Wconversion - -# for pgcc version 2.95.1, -O3 is buggy; don't use it. - -# Remove -DPNG_THREAD_UNSAFE_OK if you need thread safety -### for generic gcc: -CFLAGS=-DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD -I$(ZLIBINC) -Wall \ - -O3 $(ALIGN) -funroll-loops \ - -fomit-frame-pointer # $(WARNMORE) -g -DPNG_DEBUG=5 -### for gcc 2.95.2 on 686: -#CFLAGS=-DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD -I$(ZLIBINC) -Wall -O3 \ -# -mcpu=i686 -malign-double -ffast-math -fstrict-aliasing \ -# $(ALIGN) -funroll-loops -funroll-all-loops -fomit-frame-pointer -### for gcc 2.7.2.3 on 486 and up: -#CFLAGS=-DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD -I$(ZLIBINC) -Wall -O3 \ -# -m486 -malign-double -ffast-math \ -# $(ALIGN) -funroll-loops -funroll-all-loops -fomit-frame-pointer - -LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng12 -lz -lm -LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm - - -INCPATH=$(prefix)/include -LIBPATH=$(exec_prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(exec_prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o pnggccrd.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c - -all: libpng.a $(LIBSO) pngtest pngtest-static libpng.pc libpng-config - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo cppflags=\"-DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo R_opts=\"-Wl,-rpath,$(LIBPATH)\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -pnggccrd.o: pnggccrd.c png.h pngconf.h - $(CC) -c $(CFLAGS) -o $@ $*.c - -pnggccrd.pic.o: pnggccrd.c png.h pngconf.h - $(CC) -c $(CFLAGS) -fPIC -o $@ pnggccrd.c - -$(LIBSO): $(LIBSOMAJ) - $(LN_SF) $(LIBSOMAJ) $(LIBSO) - -$(LIBSOMAJ): $(LIBSOVER) - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) - -$(LIBSOVER): $(OBJSDLL) - $(CC) -shared -Wl,-soname,$(LIBSOMAJ) \ - -o $(LIBSOVER) \ - $(OBJSDLL) - -$(OLDSOVER): $(OBJSDLL) - $(CC) -shared -Wl,-soname,$(OLDSOMAJ) \ - -o $(OLDSOVER) \ - $(OBJSDLL) - -pngtest: pngtest.o $(LIBSO) - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -pngtest-static: pngtest.o libpng.a - $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A) - -test: pngtest pngtest-static - @echo "" - @echo " Running pngtest dynamically linked with $(LIBSO):" - @echo "" - ./pngtest - @echo "" - @echo " Running pngtest statically linked with libpng.a:" - @echo "" - ./pngtest-static - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h - -@$(RM_F) $(DI)/libpng - (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@$(RM_F) $(DL)/libpng.a - (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBSOVER) libpng.pc \ - $(OLDSOVER) - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(LIBSOMAJ) - -@$(RM_F) $(DL)/$(OLDSO) - -@$(RM_F) $(DL)/$(OLDSOMAJ) - -@$(RM_F) $(DL)/$(OLDSOVER)* - cp $(LIBSOVER) $(DL) - cp $(OLDSOVER) $(DL) - chmod 755 $(DL)/$(LIBSOVER) - chmod 755 $(DL)/$(OLDSOVER) - (cd $(DL); \ - $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ - $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ - $(LN_SF) $(LIBSOMAJ) $(LIBSO)) - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc - -@$(RM_F) $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi - -@$(RM_F) $(DM)/man3/libpng.3 - -@$(RM_F) $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi - -@$(RM_F) $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@$(RM_F) $(DB)/libpng-config - -@$(RM_F) $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) -I$(DI) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(DL) -L$(ZLIBLIB) -Wl, -rpath,$(DL) -Wl,-rpath,$(ZLIBLIB) \ - -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtestd pngtest.png - -test-installed: - $(CC) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \ - -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtesti pngtest.png - -clean: - $(RM_F) *.o libpng.a pngtest pngout.png libpng-config \ - $(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \ - $(OLDSOVER) \ - libpng.pc - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -png.o png.pic.o: png.h pngconf.h png.c -pngerror.o pngerror.pic.o: png.h pngconf.h pngerror.c -pngrio.o pngrio.pic.o: png.h pngconf.h pngrio.c -pngwio.o pngwio.pic.o: png.h pngconf.h pngwio.c -pngmem.o pngmem.pic.o: png.h pngconf.h pngmem.c -pngset.o pngset.pic.o: png.h pngconf.h pngset.c -pngget.o pngget.pic.o: png.h pngconf.h pngget.c -pngread.o pngread.pic.o: png.h pngconf.h pngread.c -pngrtran.o pngrtran.pic.o: png.h pngconf.h pngrtran.c -pngrutil.o pngrutil.pic.o: png.h pngconf.h pngrutil.c -pngtrans.o pngtrans.pic.o: png.h pngconf.h pngtrans.c -pngwrite.o pngwrite.pic.o: png.h pngconf.h pngwrite.c -pngwtran.o pngwtran.pic.o: png.h pngconf.h pngwtran.c -pngwutil.o pngwutil.pic.o: png.h pngconf.h pngwutil.c -pngpread.o pngpread.pic.o: png.h pngconf.h pngpread.c - -pngtest.o: png.h pngconf.h pngtest.c diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.hp64 b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.hp64 deleted file mode 100644 index 091367f50..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.hp64 +++ /dev/null @@ -1,231 +0,0 @@ -# makefile for libpng, HPUX (10.20 and 11.00) using the ANSI/C product. -# Copyright (C) 1999-2002 Glenn Randers-Pehrson -# Copyright (C) 1995 Guy Eric Schalnat, Group 42 -# contributed by Jim Rice and updated by Chris Schleicher, Hewlett Packard -# For conditions of distribution and use, see copyright notice in png.h - -# Where the zlib library and include files are located -ZLIBLIB=/opt/zlib/lib -ZLIBINC=/opt/zlib/include - -# Note that if you plan to build a libpng shared library, zlib must also -# be a shared library, which zlib's configure does not do. After running -# zlib's configure, edit the appropriate lines of makefile to read: -# CFLAGS=-O1 -DHAVE_UNISTD -DUSE_MAP -fPIC \ -# LDSHARED=ld -b -# SHAREDLIB=libz.sl - -# Library name: -LIBNAME = libpng12 -PNGMAJ = 0 -PNGMIN = 1.2.18 -PNGVER = $(PNGMAJ).$(PNGMIN) - -# Shared library names: -LIBSO=$(LIBNAME).sl -LIBSOMAJ=$(LIBNAME).sl.$(PNGMAJ) -LIBSOVER=$(LIBNAME).sl.$(PNGVER) -OLDSO=libpng.sl -OLDSOMAJ=libpng.sl.3 -OLDSOVER=libpng.sl.3.$(PNGMIN) - -# Utilities: -AR_RC=ar rc -CC=cc -MKDIR_P=mkdir -p -LN_SF=ln -sf -RANLIB=ranlib -RM_F=/bin/rm -f - -CFLAGS=-I$(ZLIBINC) -O -Ae -Wl,+vnocompatwarnings +DD64 \ --D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 +Z -DHAVE_UNISTD_H -DUSE_MMAP -# Caution: be sure you have built zlib with the same CFLAGS. -CCFLAGS=-I$(ZLIBINC) -O -Ae -Wl,+vnocompatwarnings +DD64 \ --D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 +Z -DHAVE_UNISTD_H -DUSE_MMAP - -LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm - -# where make install puts libpng.a, libpng12.sl, and png.h -prefix=/opt/libpng -exec_prefix=$(prefix) -INCPATH=$(prefix)/include -LIBPATH=$(exec_prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(exec_prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) +z -o $@ $*.c - -all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo ccopts=\"-Ae +DA1.1 +DS2.0\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBSO): $(LIBSOMAJ) - $(LN_SF) $(LIBSOMAJ) $(LIBSO) - -$(LIBSOMAJ): $(LIBSOVER) - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) - -$(LIBSOVER): $(OBJSDLL) - $(LD) -b +s \ - +h $(LIBSOMAJ) -o $(LIBSOVER) $(OBJSDLL) - -$(OLDSOVER): $(OBJSDLL) - $(LD) -b +s \ - +h $(OLDSOMAJ) -o $(OLDSOVER) $(OBJSDLL) - -pngtest: pngtest.o libpng.a - $(CC) -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h - -@$(RM_F) $(DI)/libpng - (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@$(RM_F) $(DL)/libpng.a - (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBSOVER) libpng.pc \ - $(OLDSOVER) - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(LIBSOMAJ) - -@$(RM_F) $(DL)/$(OLDSO) - -@$(RM_F) $(DL)/$(OLDSOMAJ) - -@$(RM_F) $(DL)/$(OLDSOVER)* - cp $(LIBSOVER) $(DL) - cp $(OLDSOVER) $(DL) - chmod 755 $(DL)/$(LIBSOVER) - chmod 755 $(DL)/$(OLDSOVER) - (cd $(DL); \ - $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ - $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ - $(LN_SF) $(LIBSOMAJ) $(LIBSO)) - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc - -@$(RM_F) $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi - -@$(RM_F) $(DM)/man3/libpng.3 - -@$(RM_F) $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi - -@$(RM_F) $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@$(RM_F) $(DB)/libpng-config - -@$(RM_F) $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) -I$(DI) -I$(ZLIBINC) $(CCFLAGS) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(DL) -L$(ZLIBLIB) \ - -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtestd pngtest.png - -test-installed: - echo - echo Testing installed dynamic shared library. - $(CC) $(CCFLAGS) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(ZLIBLIB) \ - -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtesti pngtest.png - -clean: - $(RM_F) *.o libpng.a pngtest pngtesti pngout.png \ - libpng-config $(LIBSO) $(LIBSOMAJ)* \ - $(OLDSOVER) \ - libpng.pc - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h -pngpread.o: png.h pngconf.h diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.hpgcc b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.hpgcc deleted file mode 100644 index 041f5a878..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.hpgcc +++ /dev/null @@ -1,241 +0,0 @@ -# makefile for libpng on HP-UX using GCC with the HP ANSI/C linker. -# Copyright (C) 2002, 2006 Glenn Randers-Pehrson -# Copyright (C) 2001, Laurent faillie -# Copyright (C) 1998, 1999 Greg Roelofs -# Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h - -# Library name: -LIBNAME = libpng12 -PNGMAJ = 0 -PNGMIN = 1.2.18 -PNGVER = $(PNGMAJ).$(PNGMIN) - -# Shared library names: -LIBSO=$(LIBNAME).sl -LIBSOMAJ=$(LIBNAME).sl.$(PNGMAJ) -LIBSOVER=$(LIBNAME).sl.$(PNGVER) -OLDSO=libpng.sl -OLDSOMAJ=libpng.sl.3 -OLDSOVER=libpng.sl.3.$(PNGMIN) - -# Utilities: -CC=gcc -LD=ld -AR_RC=ar rc -MKDIR_P=mkdir -p -LN_SF=ln -sf -RANLIB=ranlib -RM_F=/bin/rm -f - -# where "make install" puts libpng.a, $(OLDSO)*, png.h and pngconf.h -prefix=/usr/local -exec_prefix=$(prefix) - -# Where the zlib library and include files are located -ZLIBLIB=/opt/zlib/lib -ZLIBINC=/opt/zlib/include - -# Note that if you plan to build a libpng shared library, zlib must also -# be a shared library, which zlib's configure does not do. After running -# zlib's configure, edit the appropriate lines of makefile to read: -# CFLAGS=-O1 -DHAVE_UNISTD -DUSE_MAP -fPIC \ -# LDSHARED=ld -b -# SHAREDLIB=libz.sl - -ALIGN= -# for i386: -#ALIGN=-malign-loops=2 -malign-functions=2 - -WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes #-Wconversion - -# for pgcc version 2.95.1, -O3 is buggy; don't use it. - -CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops \ - $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 -#LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng12 -lz -lm -LDFLAGS=-L. -L$(ZLIBLIB) -lpng12 -lz -lm - -INCPATH=$(prefix)/include -LIBPATH=$(exec_prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(exec_prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c - -all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBSO): $(LIBSOMAJ) - $(LN_SF) $(LIBSOMAJ) $(LIBSO) - -$(LIBSOMAJ): $(LIBSOVER) - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) - -$(LIBSOVER): $(OBJSDLL) - $(LD) -b +s \ - +h $(LIBSOMAJ) -o $(LIBSOVER) $(OBJSDLL) - -$(OLDSOVER): $(OBJSDLL) - $(LD) -b +s \ - +h $(OLDSOMAJ) -o $(OLDSOVER) $(OBJSDLL) - -pngtest: pngtest.o $(LIBSO) - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h - -@$(RM_F) $(DI)/libpng - (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@$(RM_F) $(DL)/libpng.a - (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBSOVER) libpng.pc \ - $(OLDSOVER) - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(LIBSOMAJ) - -@$(RM_F) $(DL)/$(OLDSO) - -@$(RM_F) $(DL)/$(OLDSOMAJ) - -@$(RM_F) $(DL)/$(OLDSOVER)* - cp $(LIBSOVER) $(DL) - cp $(OLDSOVER) $(DL) - chmod 755 $(DL)/$(LIBSOVER) - chmod 755 $(DL)/$(OLDSOVER) - (cd $(DL); \ - $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ - $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ - $(LN_SF) $(LIBSOMAJ) $(LIBSO)) - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc - -@$(RM_F) $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi - -@$(RM_F) $(DM)/man3/libpng.3 - -@$(RM_F) $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi - -@$(RM_F) $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@$(RM_F) $(DB)/libpng-config - -@$(RM_F) $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) -I$(DI) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(DL) -L$(ZLIBLIB) -Wl,-rpath,$(DL) -Wl,-rpath,$(ZLIBLIB) \ - -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtestd pngtest.png - -test-installed: - echo - echo Testing installed dynamic shared library. - $(CC) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \ - -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtesti pngtest.png - -clean: - $(RM_F) *.o libpng.a pngtest pngtesti pngout.png \ - libpng-config $(LIBSO) $(LIBSOMAJ)* \ - $(OLDSOVER) \ - libpng.pc - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h - -pngtest.o: png.h pngconf.h diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.hpux b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.hpux deleted file mode 100644 index 975e80b27..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.hpux +++ /dev/null @@ -1,228 +0,0 @@ -# makefile for libpng, HPUX (10.20 and 11.00) using the ANSI/C product. -# Copyright (C) 1999-2002, 2006 Glenn Randers-Pehrson -# Copyright (C) 1995 Guy Eric Schalnat, Group 42 -# contributed by Jim Rice and updated by Chris Schleicher, Hewlett Packard -# For conditions of distribution and use, see copyright notice in png.h - -# Where the zlib library and include files are located -ZLIBLIB=/opt/zlib/lib -ZLIBINC=/opt/zlib/include - -# Note that if you plan to build a libpng shared library, zlib must also -# be a shared library, which zlib's configure does not do. After running -# zlib's configure, edit the appropriate lines of makefile to read: -# CFLAGS=-O1 -DHAVE_UNISTD -DUSE_MAP -fPIC \ -# LDSHARED=ld -b -# SHAREDLIB=libz.sl - -# Library name: -LIBNAME = libpng12 -PNGMAJ = 0 -PNGMIN = 1.2.18 -PNGVER = $(PNGMAJ).$(PNGMIN) - -# Shared library names: -LIBSO=$(LIBNAME).sl -LIBSOMAJ=$(LIBNAME).sl.$(PNGMAJ) -LIBSOVER=$(LIBNAME).sl.$(PNGVER) -OLDSO=libpng.sl -OLDSOMAJ=libpng.sl.3 -OLDSOVER=libpng.sl.3.$(PNGMIN) - -# Utilities: -AR_RC=ar rc -CC=cc -MKDIR_P=mkdir -p -LN_SF=ln -sf -RANLIB=ranlib -RM_F=/bin/rm -f - -# where make install puts libpng.a, libpng12.sl, and png.h -prefix=/opt/libpng -exec_prefix=$(prefix) -INCPATH=$(prefix)/include -LIBPATH=$(exec_prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(exec_prefix)/bin - -CFLAGS=-I$(ZLIBINC) -O -Ae +DA1.1 +DS2.0 -# Caution: be sure you have built zlib with the same CFLAGS. -CCFLAGS=-I$(ZLIBINC) -O -Ae +DA1.1 +DS2.0 -LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) +z -o $@ $*.c - -all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo ccopts=\"-Ae +DA1.1 +DS2.0\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBSO): $(LIBSOMAJ) - $(LN_SF) $(LIBSOMAJ) $(LIBSO) - -$(LIBSOMAJ): $(LIBSOVER) - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) - -$(LIBSOVER): $(OBJSDLL) - $(LD) -b +s \ - +h $(LIBSOMAJ) -o $(LIBSOVER) $(OBJSDLL) - -$(OLDSOVER): $(OBJSDLL) - $(LD) -b +s \ - +h $(OLDSOMAJ) -o $(OLDSOVER) $(OBJSDLL) - -pngtest: pngtest.o libpng.a - $(CC) -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h - -@$(RM_F) $(DI)/libpng - (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@$(RM_F) $(DL)/libpng.a - (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBSOVER) libpng.pc \ - $(OLDSOVER) - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(LIBSOMAJ) - -@$(RM_F) $(DL)/$(OLDSO) - -@$(RM_F) $(DL)/$(OLDSOMAJ) - -@$(RM_F) $(DL)/$(OLDSOVER)* - cp $(LIBSOVER) $(DL) - cp $(OLDSOVER) $(DL) - chmod 755 $(DL)/$(LIBSOVER) - chmod 755 $(DL)/$(OLDSOVER) - (cd $(DL); \ - $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ - $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ - $(LN_SF) $(LIBSOMAJ) $(LIBSO)) - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc - -@$(RM_F) $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi - -@$(RM_F) $(DM)/man3/libpng.3 - -@$(RM_F) $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi - -@$(RM_F) $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@$(RM_F) $(DB)/libpng-config - -@$(RM_F) $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) -I$(DI) -I$(ZLIBINC) $(CCFLAGS) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(DL) -L$(ZLIBLIB) \ - -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtestd pngtest.png - -test-installed: - echo - echo Testing installed dynamic shared library. - $(CC) $(CCFLAGS) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(ZLIBLIB) \ - -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtesti pngtest.png - -clean: - $(RM_F) *.o libpng.a pngtest pngtesti pngout.png \ - libpng-config $(LIBSO) $(LIBSOMAJ)* \ - $(OLDSOVER) \ - libpng.pc - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h -pngpread.o: png.h pngconf.h diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.ibmc b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.ibmc deleted file mode 100644 index 80929d287..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.ibmc +++ /dev/null @@ -1,71 +0,0 @@ -# Makefile for libpng (static) -# IBM C version 3.x for Win32 and OS/2 -# Copyright (C) 2000 Cosmin Truta -# For conditions of distribution and use, see copyright notice in png.h -# Notes: -# Derived from makefile.std -# All modules are compiled in C mode -# Tested under Win32, expected to work under OS/2 -# Can be easily adapted for IBM VisualAge/C++ for AIX - -# Location of the zlib library and include files -ZLIBINC = ../zlib -ZLIBLIB = ../zlib - -# Compiler, linker, lib and other tools -CC = icc -LD = ilink -AR = ilib -RM = del - -CFLAGS = -I$(ZLIBINC) -Mc -O2 -W3 -LDFLAGS = - -# File extensions -O=.obj -A=.lib -E=.exe - -# Variables -OBJS = png$(O) pngerror$(O) pngget$(O) pngmem$(O) pngpread$(O) \ - pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) pngset$(O) \ - pngtrans$(O) pngwio$(O) pngwrite$(O) pngwtran$(O) pngwutil$(O) - -LIBS = libpng$(A) $(ZLIBLIB)/zlib$(A) - -# Targets -all: libpng$(A) pngtest$(E) - -libpng$(A): $(OBJS) - $(AR) -out:$@ $(OBJS) - -test: pngtest$(E) - pngtest$(E) - -pngtest: pngtest$(E) - -pngtest$(E): pngtest$(O) libpng$(A) - $(LD) $(LDFLAGS) pngtest$(O) $(LIBS) - -clean: - $(RM) *$(O) - $(RM) libpng$(A) - $(RM) pngtest$(E) - $(RM) pngout.png - -png$(O): png.h pngconf.h -pngerror$(O): png.h pngconf.h -pngget$(O): png.h pngconf.h -pngmem$(O): png.h pngconf.h -pngpread$(O): png.h pngconf.h -pngread$(O): png.h pngconf.h -pngrio$(O): png.h pngconf.h -pngrtran$(O): png.h pngconf.h -pngrutil$(O): png.h pngconf.h -pngset$(O): png.h pngconf.h -pngtest$(O): png.h pngconf.h -pngtrans$(O): png.h pngconf.h -pngwio$(O): png.h pngconf.h -pngwrite$(O): png.h pngconf.h -pngwtran$(O): png.h pngconf.h -pngwutil$(O): png.h pngconf.h diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.intel b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.intel deleted file mode 100644 index 400ca072c..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.intel +++ /dev/null @@ -1,114 +0,0 @@ -# Makefile for libpng -# Microsoft Visual C++ with Intel C/C++ Compiler 4.0 and later - -# Copyright (C) 2000, Pawel Mrochen, based on makefile.msc which is -# copyright 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h - -# To use, do "nmake /f scripts\makefile.intel" - - -# ------------------- Intel C/C++ Compiler 4.0 and later ------------------- - -# Caution: the assembler code was introduced at libpng version 1.0.4 and has -# not yet been thoroughly tested. - -# Use assembler code -ASMCODE=-DPNG_USE_PNGVCRD - -# Where the zlib library and include files are located -ZLIBLIB=..\zlib -ZLIBINC=..\zlib - -# Target CPU -CPU=6 # Pentium II -#CPU=5 # Pentium - -# Calling convention -CALLING=r # __fastcall -#CALLING=z # __stdcall -#CALLING=d # __cdecl - -# Uncomment next to put error messages in a file -#ERRFILE=>>pngerrs - -# -------------------------------------------------------------------------- - - -CC=icl -c -CFLAGS=-O2 -G$(CPU)$(CALLING) -Qip -Qunroll4 -I$(ZLIBINC) $(ASMCODE) -nologo -LD=link -LDFLAGS=/SUBSYSTEM:CONSOLE /NOLOGO - -O=.obj - -OBJS=png$(O) pngset$(O) pngget$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O) \ -pngmem$(O) pngpread$(O) pngread$(O) pngerror$(O) pngwrite$(O) \ -pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O) pngvcrd$(O) - - -all: test - -png$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngset$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngget$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngread$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngpread$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngrtran$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngrutil$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngvcrd$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngerror$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngmem$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngrio$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngwio$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngtest$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngtrans$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngwrite$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngwtran$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngwutil$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -libpng.lib: $(OBJS) - if exist libpng.lib del libpng.lib - lib /NOLOGO /OUT:libpng.lib $(OBJS) - -pngtest.exe: pngtest.obj libpng.lib - $(LD) $(LDFLAGS) /OUT:pngtest.exe pngtest.obj libpng.lib $(ZLIBLIB)\zlib.lib - -test: pngtest.exe - pngtest.exe - - -# End of makefile for libpng diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.knr b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.knr deleted file mode 100644 index 4a8d7d11c..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.knr +++ /dev/null @@ -1,99 +0,0 @@ -# makefile for libpng -# Copyright (C) 2002 Glenn Randers-Pehrson -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h - -# This makefile requires the file ansi2knr.c, which you can get -# from the Ghostscript ftp site at ftp://ftp.cs.wisc.edu/ghost/ -# If you have libjpeg, you probably already have ansi2knr.c in the jpeg -# source distribution. - -# where make install puts libpng.a and png.h -prefix=/usr/local -INCPATH=$(prefix)/include -LIBPATH=$(prefix)/lib - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -CC=cc -CFLAGS=-I../zlib -O -LDFLAGS=-L. -L../zlib/ -lpng -lz -lm -# flags for ansi2knr -ANSI2KNRFLAGS= - -RANLIB=ranlib -#RANLIB=echo - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -all: ansi2knr libpng.a pngtest - -# general rule to allow ansi2knr to work -.c.o: - ./ansi2knr $*.c T$*.c - $(CC) $(CFLAGS) -c T$*.c - rm -f T$*.c $*.o - mv T$*.o $*.o - -ansi2knr: ansi2knr.c - $(CC) $(CFLAGS) $(ANSI2KNRFLAGS) -o ansi2knr ansi2knr.c - -libpng.a: ansi2knr $(OBJS) - ar rc $@ $(OBJS) - $(RANLIB) $@ - -pngtest: pngtest.o libpng.a - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install: libpng.a - -@mkdir $(DESTDIR)$(INCPATH) - -@mkdir $(DESTDIR)$(INCPATH)/libpng - -@mkdir $(DESTDIR)$(LIBPATH) - -@rm -f $(DESTDIR)$(INCPATH)/png.h - -@rm -f $(DESTDIR)$(INCPATH)/pngconf.h - cp png.h $(DESTDIR)$(INCPATH)/libpng - cp pngconf.h $(DESTDIR)$(INCPATH)/libpng - chmod 644 $(DESTDIR)$(INCPATH)/libpng/png.h - chmod 644 $(DESTDIR)$(INCPATH)/libpng/pngconf.h - (cd $(DESTDIR)$(INCPATH); ln -f -s libpng/* .) - cp libpng.a $(DESTDIR)$(LIBPATH) - chmod 644 $(DESTDIR)$(LIBPATH)/libpng.a - -clean: - rm -f *.o libpng.a pngtest pngout.png ansi2knr - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngpread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.linux b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.linux deleted file mode 100644 index e79f32d28..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.linux +++ /dev/null @@ -1,245 +0,0 @@ -# makefile for libpng.a and libpng12.so on Linux ELF with gcc -# Copyright (C) 1998, 1999, 2002, 2006 Greg Roelofs and Glenn Randers-Pehrson -# Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h - -# Library name: -LIBNAME = libpng12 -PNGMAJ = 0 -PNGMIN = 1.2.18 -PNGVER = $(PNGMAJ).$(PNGMIN) - -# Shared library names: -LIBSO=$(LIBNAME).so -LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) -LIBSOVER=$(LIBNAME).so.$(PNGVER) -OLDSO=libpng.so -OLDSOMAJ=libpng.so.3 -OLDSOVER=libpng.so.3.$(PNGMIN) - -# Utilities: -AR_RC=ar rc -CC=gcc -MKDIR_P=mkdir -p -LN_SF=ln -sf -RANLIB=ranlib -RM_F=/bin/rm -f - -# where "make install" puts libpng12.a, libpng12.so*, -# libpng12/png.h and libpng12/pngconf.h -# Prefix must be a full pathname. -prefix=/usr/local -exec_prefix=$(prefix) - -# Where the zlib library and include files are located. -#ZLIBLIB=/usr/local/lib -#ZLIBINC=/usr/local/include -ZLIBLIB=../zlib -ZLIBINC=../zlib - -ALIGN= -# for i386: -#ALIGN=-malign-loops=2 -malign-functions=2 - -WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes #-Wconversion - -# for pgcc version 2.95.1, -O3 is buggy; don't use it. - -CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops \ - $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 - -LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng12 -lz -lm -LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm - -INCPATH=$(prefix)/include -LIBPATH=$(exec_prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(exec_prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c - -all: libpng.a $(LIBSO) pngtest pngtest-static libpng.pc libpng-config - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo R_opts=\"-Wl,-rpath,$(LIBPATH)\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBSO): $(LIBSOMAJ) - $(LN_SF) $(LIBSOMAJ) $(LIBSO) - -$(LIBSOMAJ): $(LIBSOVER) - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) - -$(LIBSOVER): $(OBJSDLL) - $(CC) -shared -Wl,-soname,$(LIBSOMAJ) -o $(LIBSOVER) $(OBJSDLL) - -$(OLDSOVER): $(OBJSDLL) - $(CC) -shared -Wl,-soname,$(OLDSOMAJ) \ - -o $(OLDSOVER) \ - $(OBJSDLL) - -pngtest: pngtest.o $(LIBSO) - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -pngtest-static: pngtest.o libpng.a - $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A) - -test: pngtest pngtest-static - @echo "" - @echo " Running pngtest dynamically linked with $(LIBSO):" - @echo "" - ./pngtest - @echo "" - @echo " Running pngtest statically linked with libpng.a:" - @echo "" - ./pngtest-static - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h - -@$(RM_F) $(DI)/libpng - (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@$(RM_F) $(DL)/libpng.a - (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBSOVER) libpng.pc \ - $(OLDSOVER) - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(LIBSOMAJ) - -@$(RM_F) $(DL)/$(OLDSO) - -@$(RM_F) $(DL)/$(OLDSOMAJ) - -@$(RM_F) $(DL)/$(OLDSOVER)* - cp $(LIBSOVER) $(DL) - cp $(OLDSOVER) $(DL) - chmod 755 $(DL)/$(LIBSOVER) - chmod 755 $(DL)/$(OLDSOVER) - (cd $(DL); \ - $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ - $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ - $(LN_SF) $(LIBSOMAJ) $(LIBSO)) - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc - -@$(RM_F) $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi - -@$(RM_F) $(DM)/man3/libpng.3 - -@$(RM_F) $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi - -@$(RM_F) $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@$(RM_F) $(DB)/libpng-config - -@$(RM_F) $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) -I$(DI) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(DL) -L$(ZLIBLIB) -Wl, -rpath,$(DL) -Wl,-rpath,$(ZLIBLIB) \ - -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtestd pngtest.png - -test-installed: - $(CC) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \ - -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtesti pngtest.png - -clean: - $(RM_F) *.o libpng.a pngtest pngout.png libpng-config \ - $(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \ - $(OLDSOVER) \ - libpng.pc - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h - -pngtest.o: png.h pngconf.h diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.mingw b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.mingw deleted file mode 100644 index 6b074acd1..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.mingw +++ /dev/null @@ -1,312 +0,0 @@ -# makefile for mingw on x86 -# Builds both dll (with import lib) and static lib versions -# of the library, and builds two copies of pngtest: one -# statically linked and one dynamically linked. -# -# Built from makefile.cygwin -# Copyright (C) 2002, 2006 Soren Anderson, Charles Wilson, -# and Glenn Randers-Pehrson, based on makefile for linux-elf w/mmx by: -# Copyright (C) 1998-2000 Greg Roelofs -# Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h - -# This makefile intends to support building outside the src directory -# if desired. When invoking it, specify an argument to SRCDIR on the -# command line that points to the top of the directory where your source -# is located. - -ifdef SRCDIR -VPATH = $(SRCDIR) -else -SRCDIR = . -endif - -# Override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. - -DESTDIR= - -# To enable assembler optimizations, add '-DPNG_USE_PNGGCCRD' to -# $CFLAGS, and include pnggccrd.o in $OBJS, below, and in the dependency -# list at the bottom of this makefile. - -CC=gcc - - -# Where "make install" puts libpng*.a, *png*.dll, png.h, and pngconf.h -ifndef prefix -prefix=/usr -$(warning You haven't specified a 'prefix=' location. Defaulting to "/usr") -endif -exec_prefix=$(prefix) - -# Where the zlib library and include files are located -ZLIBLIB= /usr/lib -ZLIBINC= - -ALIGN= -# for i386: -#ALIGN=-malign-loops=2 -malign-functions=2 - -WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes #-Wconversion - -### if you use the asm, add pnggccrd.o to the OBJS list -### -### if you don't need thread safety, but want the asm accel -#CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD \ -# $(addprefix -I,$(ZLIBINC)) -Wall -O3 $(ALIGN) -funroll-loops \ -# -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 -### if you need thread safety and want (minimal) asm accel -#CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_USE_PNGGCCRD $(addprefix -I,$(ZLIBINC)) \ -# -Wall -O3 $(ALIGN) -funroll-loops \ -# -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 -### Normal (non-asm) compilation -CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \ - -Wall -O3 $(ALIGN) -funroll-loops \ - -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 - -LIBNAME = libpng12 -PNGMAJ = 0 -MINGDLL = 12 -PNGMIN = 1.2.18 -PNGVER = $(PNGMAJ).$(PNGMIN) - -SHAREDLIB=libpng$(MINGDLL).dll -STATLIB=libpng.a -IMPLIB=libpng.dll.a -SHAREDDEF=libpng.def -LIBS=$(SHAREDLIB) $(STATLIB) -EXE=.exe - -LDFLAGS=$(strip -L. $(MINGW_LDFLAGS) -lpng $(addprefix -L,$(ZLIBLIB)) -lz) -LDSFLAGS=$(strip -shared -L. $(MINGW_LDFLAGS)) -LDEXTRA=-Wl,--out-implib=$(IMPLIB) $(addprefix -L,$(ZLIBLIB)) -lz - -MKDIR_P=/bin/mkdir -pv -RANLIB=ranlib -#RANLIB=echo - -INCPATH=$(prefix)/include -LIBPATH=$(exec_prefix)/lib - -BINPATH=$(exec_prefix)/bin -MANPATH=$(prefix)/man -MAN3PATH=$(MANPATH)/man3 -MAN5PATH=$(MANPATH)/man5 - -# cosmetic: shortened strings: -S =$(SRCDIR) -D =$(DESTDIR) -DB =$(D)$(BINPATH) -DI =$(D)$(INCPATH) -DL =$(D)$(LIBPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o # pnggccrd.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -%.o : %.c - $(CC) -c $(CFLAGS) -o $@ $< -%.pic.o : CFLAGS += -DPNG_BUILD_DLL -%.pic.o : %.c - $(CC) -c $(CFLAGS) -o $@ $< - -all: all-static all-shared libpng.pc libpng-config libpng.pc libpng-config - -# Make this to verify that "make [...] install" will do what you want. -buildsetup-tell: - @echo VPATH is set to: \"$(VPATH)\" - @echo prefix is set to: \"$(prefix)\" - @echo -e INCPATH,LIBPATH, etc. are set to:'\n' \ - $(addprefix $(D),$(INCPATH)'\n' $(LIBPATH)'\n' $(BINPATH)'\n' \ - $(MANPATH)'\n' $(MAN3PATH)'\n' $(MAN5PATH)'\n')'\n' - -libpng.pc: scripts/libpng.pc.in - @echo -e Making pkg-config file for this libpng installation..'\n' \ - using PREFIX=\"$(prefix)\"'\n' - cat $(S)/scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! | \ - sed -e s/-lm// > libpng.pc - -libpng-config: scripts/libpng-config-head.in scripts/libpng-config-body.in - @echo -e Making $(LIBNAME) libpng-config file for this libpng \ - installation..'\n' using PREFIX=\"$(prefix)\"'\n' - ( cat $(S)/scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo libs=\"-lpng$(MINGDLL) -lz\"; \ - cat $(S)/scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -static: all-static -shared: all-shared -all-static: $(STATLIB) pngtest-stat$(EXE) -all-shared: $(SHAREDLIB) pngtest$(EXE) - -pnggccrd.o: pnggccrd.c png.h pngconf.h - @echo "" - @echo ' You can ignore the "control reaches end of non-void function"' - @echo ' warning and "<variable> defined but not used" warnings:' - @echo "" - $(CC) -c $(CFLAGS) -o $@ $< - -pnggccrd.pic.o: pnggccrd.c png.h pngconf.h - @echo "" - @echo ' You can ignore the "control reaches end of non-void function"' - @echo ' warning and "<variable> defined but not used" warnings:' - @echo "" - $(CC) -c $(CFLAGS) -DPNG_BUILD_DLL -o $@ $< - -$(STATLIB): $(OBJS) - ar rc $@ $(OBJS) - $(RANLIB) $@ - -$(SHAREDDEF): scripts/pngw32.def - cat $< | sed -e '1{G;s/^\(.*\)\(\n\)/EXPORTS/;};2,/^EXPORTS/d' | \ - sed -e 's/\([^;]*\);/;/' > $@ - -$(SHAREDLIB): $(OBJSDLL) $(SHAREDDEF) - $(CC) $(LDSFLAGS) -o $@ $(OBJSDLL) -L. $(LDEXTRA) - -pngtest$(EXE): pngtest.pic.o $(SHAREDLIB) - $(CC) $(CFLAGS) $< $(LDFLAGS) -o $@ - -pngtest-stat$(EXE): pngtest.o $(STATLIB) - $(CC) -static $(CFLAGS) $< $(LDFLAGS) -o $@ - -pngtest.pic.o: pngtest.c - $(CC) $(CFLAGS) -c $< -o $@ - -pngtest.o: pngtest.c - $(CC) $(CFLAGS) -c $< -o $@ - -test: test-static test-shared - -test-static: pngtest-stat$(EXE) - ./pngtest-stat $(S)/pngtest.png - -test-shared: pngtest$(EXE) - ./pngtest $(S)/pngtest.png - -install-static: $(STATLIB) install-headers install-man - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - install -m 644 $(STATLIB) $(DL)/$(LIBNAME).a - -@rm -f $(DL)/$(STATLIB) - (cd $(DL); ln -sf $(LIBNAME).a $(STATLIB)) - -install-shared: $(SHAREDLIB) libpng.pc libpng-config install-headers install-man - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc - -@/bin/rm -f $(DL)/pkgconfig/libpng.pc - install -m 644 $(IMPLIB) $(DL)/$(LIBNAME).dll.a - -@rm -f $(DL)/$(IMPLIB) - (cd $(DL); ln -sf $(LIBNAME).dll.a $(IMPLIB)) - install -s -m 755 $(SHAREDLIB) $(DB) - install -m 644 libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc) - -install-headers: - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - -@rm -f $(DI)/png.h - -@rm -f $(DI)/pngconf.h - install -m 644 $(S)/png.h $(S)/pngconf.h $(DI)/$(LIBNAME) - -@rm -f $(DI)/libpng - (cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .) - -install-man: - -@if [ ! -d $(D)$(MAN3PATH) ]; then $(MKDIR_P) $(D)$(MAN3PATH); fi - -@if [ ! -d $(D)$(MAN5PATH) ]; then $(MKDIR_P) $(D)$(MAN5PATH); fi - install -m 644 $(S)/libpngpf.3 $(S)/libpng.3 $(D)$(MAN3PATH) - install -m 644 $(S)/png.5 $(D)$(MAN5PATH) - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@/bin/rm -f $(DB)/libpng-config - -@/bin/rm -f $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); ln -sf $(LIBNAME)-config libpng-config) - -# Run this to verify that a future `configure' run will pick up the settings -# you want. -test-config-install: SHELL=/bin/bash -test-config-install: $(DB)/libpng-config - @echo -e Testing libpng-config functions...'\n' - @ for TYRA in LDFLAGS CPPFLAGS CFLAGS LIBS VERSION; \ - do \ - printf "(%d)\t %10s =%s\n" $$(($$gytiu + 1)) $$TYRA \ - "$$($(DB)/libpng-config `echo --$$TYRA |tr '[:upper:]' '[:lower:]'`)"; \ - gytiu=$$(( $$gytiu + 1 )); \ - done - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) -I$(DI) $(CFLAGS) \ - `$(BINPATH)/libpng12-config --cflags` pngtest.c \ - -L$(DL) -L$(ZLIBLIB) \ - -o pngtestd `$(BINPATH)/libpng12-config --ldflags` - ./pngtestd pngtest.png - -test-installed: - $(CC) $(CFLAGS) \ - `$(BINPATH)/libpng12-config --cflags` pngtest.c \ - -L$(ZLIBLIB) \ - -o pngtesti$(EXE) `$(BINPATH)/libpng12-config --ldflags` - ./pngtesti$(EXE) pngtest.png - -clean: - /bin/rm -f *.pic.o *.o $(STATLIB) $(IMPLIB) $(SHAREDLIB) \ - pngtest-stat$(EXE) pngtest$(EXE) pngout.png $(SHAREDDEF) \ - libpng-config libpng.pc pngtesti$(EXE) - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -.PHONY: buildsetup-tell libpng.pc libpng-config test-config-install clean - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h png.c -pngerror.o pngerror.pic.o: png.h pngconf.h pngerror.c -pngrio.o pngrio.pic.o: png.h pngconf.h pngrio.c -pngwio.o pngwio.pic.o: png.h pngconf.h pngwio.c -pngmem.o pngmem.pic.o: png.h pngconf.h pngmem.c -pngset.o pngset.pic.o: png.h pngconf.h pngset.c -pngget.o pngget.pic.o: png.h pngconf.h pngget.c -pngread.o pngread.pic.o: png.h pngconf.h pngread.c -pngrtran.o pngrtran.pic.o: png.h pngconf.h pngrtran.c -pngrutil.o pngrutil.pic.o: png.h pngconf.h pngrutil.c -pngtrans.o pngtrans.pic.o: png.h pngconf.h pngtrans.c -pngwrite.o pngwrite.pic.o: png.h pngconf.h pngwrite.c -pngwtran.o pngwtran.pic.o: png.h pngconf.h pngwtran.c -pngwutil.o pngwutil.pic.o: png.h pngconf.h pngwutil.c -pngpread.o pngpread.pic.o: png.h pngconf.h pngpread.c - -pngtest.o: png.h pngconf.h pngtest.c -pngtest-stat.o: png.h pngconf.h pngtest.c - - - diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.mips b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.mips deleted file mode 100644 index b77e006d1..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.mips +++ /dev/null @@ -1,83 +0,0 @@ -# makefile for libpng -# Copyright (C) Glenn Randers-Pehrson -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h - -# where make install puts libpng.a and png.h -prefix=/usr/local -INCPATH=$(prefix)/include -LIBPATH=$(prefix)/lib - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -CC=cc -CFLAGS=-I../zlib -O -systype sysv -DSYSV -w -Dmips -#CFLAGS=-O -LDFLAGS=-L. -L../zlib/ -lpng -lz -lm - -#RANLIB=ranlib -RANLIB=echo - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -all: libpng.a pngtest - -libpng.a: $(OBJS) - ar rc $@ $(OBJS) - $(RANLIB) $@ - -pngtest: pngtest.o libpng.a - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install: libpng.a - -@mkdir $(DESTDIR)$(INCPATH) - -@mkdir $(DESTDIR)$(INCPATH)/libpng - -@mkdir $(DESTDIR)$(LIBPATH) - -@rm -f $(DESTDIR)$(INCPATH)/png.h - -@rm -f $(DESTDIR)$(INCPATH)/pngconf.h - cp png.h $(DESTDIR)$(INCPATH)/libpng - cp pngconf.h $(DESTDIR)$(INCPATH)/libpng - chmod 644 $(DESTDIR)$(INCPATH)/libpng/png.h - chmod 644 $(DESTDIR)$(INCPATH)/libpng/pngconf.h - (cd $(DESTDIR)$(INCPATH); ln -f -s libpng/* .) - cp libpng.a $(DESTDIR)$(LIBPATH) - chmod 644 $(DESTDIR)$(LIBPATH)/libpng.a - -clean: - rm -f *.o libpng.a pngtest pngout.png - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngpread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.msc b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.msc deleted file mode 100644 index 1741ed012..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.msc +++ /dev/null @@ -1,86 +0,0 @@ -# makefile for libpng -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h -# Assumes that zlib.lib, zconf.h, and zlib.h have been copied to ..\zlib - -# -------- Microsoft C 5.1 and later, does not use assembler code -------- -MODEL=L -CFLAGS=-Oait -Gs -nologo -W3 -A$(MODEL) -I..\zlib -#-Ox generates bad code with MSC 5.1 -CC=cl -LD=link -LDFLAGS=/e/st:0x1500/noe -O=.obj - -#uncomment next to put error messages in a file -ERRFILE= >> pngerrs - -# variables -OBJS1 = png$(O) pngset$(O) pngget$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O) -OBJS2 = pngmem$(O) pngpread$(O) pngread$(O) pngerror$(O) pngwrite$(O) -OBJS3 = pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O) - -all: libpng.lib - -png$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngset$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngget$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngread$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngpread$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngrtran$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngrutil$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngerror$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngmem$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngrio$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwio$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngtest$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngtrans$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwrite$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwtran$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwutil$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -libpng.lib: $(OBJS1) $(OBJS2) $(OBJS3) - del libpng.lib - lib libpng $(OBJS1); - lib libpng $(OBJS2); - lib libpng $(OBJS3); - -pngtest.exe: pngtest.obj libpng.lib - $(LD) $(LDFLAGS) pngtest.obj,,,libpng.lib ..\zlib\zlib.lib ; - -test: pngtest.exe - pngtest - -# End of makefile for libpng - diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.ne12bsd b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.ne12bsd deleted file mode 100644 index 42adaca7d..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.ne12bsd +++ /dev/null @@ -1,45 +0,0 @@ -# makefile for libpng for NetBSD for the standard -# make obj && make depend && make && make test -# make includes && make install -# Copyright (C) 2002 Patrick R.L. Welche -# Copyright (C) 2007 Glenn Randers-Pehrson -# For conditions of distribution and use, see copyright notice in png.h - -# You should also run makefile.netbsd - -LOCALBASE?=/usr/local -LIBDIR= ${LOCALBASE}/lib -MANDIR= ${LOCALBASE}/man -INCSDIR=${LOCALBASE}/include/libpng12 - -LIB= png12 -SHLIB_MAJOR= 0 -SHLIB_MINOR= 1.2.18 -SRCS= pnggccrd.c png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \ - pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \ - pngwtran.c pngmem.c pngerror.c pngpread.c -INCS= png.h pngconf.h -MAN= libpng.3 libpngpf.3 png.5 - -CPPFLAGS+=-I${.CURDIR} -DPNG_USE_PNGGCCRD - -# something like this for mmx assembler, but it core dumps for me at the moment -# .if ${MACHINE_ARCH} == "i386" -# CPPFLAGS+=-DPNG_THREAD_UNSAFE_OK -# MKLINT= no -# .else - CPPFLAGS+=-DPNG_NO_MMX_CODE -# .endif - -CLEANFILES+=pngtest.o pngtest - -pngtest.o: pngtest.c - ${CC} -c ${CPPFLAGS} ${CFLAGS} ${.ALLSRC} -o ${.TARGET} - -pngtest: pngtest.o libpng.a - ${CC} ${LDFLAGS} ${.ALLSRC} -o${.TARGET} -lz -lm - -test: pngtest - cd ${.CURDIR} && ${.OBJDIR}/pngtest - -.include <bsd.lib.mk> diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.netbsd b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.netbsd deleted file mode 100644 index 89d6b351f..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.netbsd +++ /dev/null @@ -1,45 +0,0 @@ -# makefile for libpng for NetBSD for the standard -# make obj && make depend && make && make test -# make includes && make install -# Copyright (C) 2002 Patrick R.L. Welche -# Copyright (C) 2007 Glenn Randers-Pehrson -# For conditions of distribution and use, see copyright notice in png.h - -# You should also run makefile.ne0bsd - -LOCALBASE?=/usr/local -LIBDIR= ${LOCALBASE}/lib -MANDIR= ${LOCALBASE}/man -INCSDIR=${LOCALBASE}/include/libpng - -LIB= png -SHLIB_MAJOR= 3 -SHLIB_MINOR= 1.2.18 -SRCS= pnggccrd.c png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \ - pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \ - pngwtran.c pngmem.c pngerror.c pngpread.c -INCS= png.h pngconf.h -MAN= libpng.3 libpngpf.3 png.5 - -CPPFLAGS+=-I${.CURDIR} -DPNG_USE_PNGGCCRD - -# something like this for mmx assembler, but it core dumps for me at the moment -# .if ${MACHINE_ARCH} == "i386" -# CPPFLAGS+=-DPNG_THREAD_UNSAFE_OK -# MKLINT= no -# .else - CPPFLAGS+=-DPNG_NO_MMX_CODE -# .endif - -CLEANFILES+=pngtest.o pngtest - -pngtest.o: pngtest.c - ${CC} -c ${CPPFLAGS} ${CFLAGS} ${.ALLSRC} -o ${.TARGET} - -pngtest: pngtest.o libpng.a - ${CC} ${LDFLAGS} ${.ALLSRC} -o${.TARGET} -lz -lm - -test: pngtest - cd ${.CURDIR} && ${.OBJDIR}/pngtest - -.include <bsd.lib.mk> diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.nommx b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.nommx deleted file mode 100644 index 30208d4ee..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.nommx +++ /dev/null @@ -1,248 +0,0 @@ -# makefile for libpng.a and libpng12.so on Linux ELF with gcc -# Copyright (C) 1998, 1999, 2002, 2006, 2007 Greg Roelofs and -# Glenn Randers-Pehrson -# Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h - -# Library name: -LIBNAME = libpng12 -PNGMAJ = 0 -PNGMIN = 1.2.18 -PNGVER = $(PNGMAJ).$(PNGMIN) - -# Shared library names: -LIBSO=$(LIBNAME).so -LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) -LIBSOVER=$(LIBNAME).so.$(PNGVER) -OLDSO=libpng.so -OLDSOMAJ=libpng.so.3 -OLDSOVER=libpng.so.3.$(PNGMIN) - -# Utilities: -AR_RC=ar rc -CC=gcc -MKDIR_P=mkdir -p -LN_SF=ln -sf -RANLIB=ranlib -RM_F=/bin/rm -f - -# where "make install" puts libpng12.a, libpng12.so*, -# libpng12/png.h and libpng12/pngconf.h -# Prefix must be a full pathname. -prefix=/usr/local -exec_prefix=$(prefix) - -# Where the zlib library and include files are located. -#ZLIBLIB=/usr/local/lib -#ZLIBINC=/usr/local/include -ZLIBLIB=../zlib -ZLIBINC=../zlib - -ALIGN= -# for i386: -#ALIGN=-malign-loops=2 -malign-functions=2 - -WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes #-Wconversion - -# for pgcc version 2.95.1, -O3 is buggy; don't use it. - -CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops \ - -DPNG_NO_MMX_CODE \ - $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 - -LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng12 -lz -lm -LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm - -INCPATH=$(prefix)/include -LIBPATH=$(exec_prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(exec_prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c - -all: libpng.a $(LIBSO) pngtest pngtest-static libpng.pc libpng-config - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s!@PREFIX@!$(prefix)! \ - | sed -e "s!Cflags: !Cflags: -DPNG_NO_MMX_CODE !"> libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME) -DPNG_NO_MMX_CODE\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo R_opts=\"-Wl,-rpath,$(LIBPATH)\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBSO): $(LIBSOMAJ) - $(LN_SF) $(LIBSOMAJ) $(LIBSO) - -$(LIBSOMAJ): $(LIBSOVER) - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) - -$(LIBSOVER): $(OBJSDLL) - $(CC) -shared -Wl,-soname,$(LIBSOMAJ) -o $(LIBSOVER) $(OBJSDLL) - -$(OLDSOVER): $(OBJSDLL) - $(CC) -shared -Wl,-soname,$(OLDSOMAJ) \ - -o $(OLDSOVER) \ - $(OBJSDLL) - -pngtest: pngtest.o $(LIBSO) - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -pngtest-static: pngtest.o libpng.a - $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A) - -test: pngtest pngtest-static - @echo "" - @echo " Running pngtest dynamically linked with $(LIBSO):" - @echo "" - ./pngtest - @echo "" - @echo " Running pngtest statically linked with libpng.a:" - @echo "" - ./pngtest-static - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h - -@$(RM_F) $(DI)/libpng - (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@$(RM_F) $(DL)/libpng.a - (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBSOVER) libpng.pc \ - $(OLDSOVER) - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(LIBSOMAJ) - -@$(RM_F) $(DL)/$(OLDSO) - -@$(RM_F) $(DL)/$(OLDSOMAJ) - -@$(RM_F) $(DL)/$(OLDSOVER)* - cp $(LIBSOVER) $(DL) - cp $(OLDSOVER) $(DL) - chmod 755 $(DL)/$(LIBSOVER) - chmod 755 $(DL)/$(OLDSOVER) - (cd $(DL); \ - $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ - $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ - $(LN_SF) $(LIBSOMAJ) $(LIBSO)) - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc - -@$(RM_F) $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi - -@$(RM_F) $(DM)/man3/libpng.3 - -@$(RM_F) $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi - -@$(RM_F) $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@$(RM_F) $(DB)/libpng-config - -@$(RM_F) $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) -I$(DI) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(DL) -L$(ZLIBLIB) -Wl, -rpath,$(DL) -Wl,-rpath,$(ZLIBLIB) \ - -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtestd pngtest.png - -test-installed: - $(CC) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \ - -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtesti pngtest.png - -clean: - $(RM_F) *.o libpng.a pngtest pngout.png libpng-config \ - $(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \ - $(OLDSOVER) \ - libpng.pc - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h - -pngtest.o: png.h pngconf.h diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.openbsd b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.openbsd deleted file mode 100644 index 3ff3b0ef1..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.openbsd +++ /dev/null @@ -1,73 +0,0 @@ -# makefile for libpng -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# Copyright (C) 2007 Glenn Randers-Pehrson -# For conditions of distribution and use, see copyright notice in png.h - -PREFIX?= /usr/local -LIBDIR= ${PREFIX}/lib -MANDIR= ${PREFIX}/man/cat - -SHLIB_MAJOR= 0 -SHLIB_MINOR= 1.2.18 - -LIB= png -SRCS= png.c pngerror.c pnggccrd.c pngget.c pngmem.c pngpread.c \ - pngread.c pngrio.c pngrtran.c pngrutil.c pngset.c pngtrans.c \ - pngwio.c pngwrite.c pngwtran.c pngwutil.c - -HDRS= png.h pngconf.h - -CFLAGS+= -Wall -CPPFLAGS+= -I${.CURDIR} -DPNG_NO_MMX_CODE -DPNG_USE_PNGGCCRD - -NOPROFILE= Yes - -CLEANFILES+= pngtest.o pngtest - -MAN= libpng.3 libpngpf.3 png.5 -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO libpng.txt - -pngtest.o: pngtest.c - ${CC} ${CPPFLAGS} ${CFLAGS} -c ${.ALLSRC} -o ${.TARGET} - -pngtest: pngtest.o - ${CC} ${LDFLAGS} ${.ALLSRC} -o ${.TARGET} -L${.OBJDIR} -lpng -lz -lm - -test: pngtest - cd ${.OBJDIR} && env \ - LD_LIBRARY_PATH="${.OBJDIR}" ${.OBJDIR}/pngtest - -beforeinstall: - if [ ! -d ${DESTDIR}${PREFIX}/include/libpng ]; then \ - ${INSTALL} -d -o root -g wheel ${DESTDIR}${PREFIX}/include/libpng; \ - fi - if [ ! -d ${DESTDIR}${LIBDIR} ]; then \ - ${INSTALL} -d -o root -g wheel ${DESTDIR}${LIBDIR}; \ - fi - if [ ! -d ${DESTDIR}${LIBDIR}/debug ]; then \ - ${INSTALL} -d -o root -g wheel ${DESTDIR}${LIBDIR}/debug; \ - fi - if [ ! -d ${DESTDIR}${MANDIR}3 ]; then \ - ${INSTALL} -d -o root -g wheel ${DESTDIR}${MANDIR}3; \ - fi - if [ ! -d ${DESTDIR}${MANDIR}5 ]; then \ - ${INSTALL} -d -o root -g wheel ${DESTDIR}${MANDIR}5; \ - fi - if [ ! -d ${DESTDIR}${PREFIX}/share/doc/png ]; then \ - ${INSTALL} -d -o root -g wheel ${DESTDIR}${PREFIX}/share/doc/png; \ - fi - -afterinstall: - @rm -f ${DESTDIR}${LIBDIR}/libpng_pic.a - @rm -f ${DESTDIR}${LIBDIR}/debug/libpng.a - @rm -f ${DESTDIR}${PREFIX}/include/png.h - @rm -f ${DESTDIR}${PREFIX}/include/pngconf.h - @rmdir ${DESTDIR}${LIBDIR}/debug 2>/dev/null || true - ${INSTALL} ${INSTALL_COPY} -o ${SHAREOWN} -g ${SHAREGRP} \ - -m ${NONBINMODE} ${HDRS} ${DESTDIR}${PREFIX}/include/libpng - ${INSTALL} ${INSTALL_COPY} -o ${SHAREOWN} -g ${SHAREGRP} \ - -m ${NONBINMODE} ${HDRS} ${DESTDIR}${PREFIX}/include - ${INSTALL} ${INSTALL_COPY} -o ${SHAREOWN} -g ${SHAREGRP} \ - -m ${NONBINMODE} ${DOCS} ${DESTDIR}${PREFIX}/share/doc/png - -.include <bsd.lib.mk> diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.os2 b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.os2 deleted file mode 100644 index e2eed697c..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.os2 +++ /dev/null @@ -1,69 +0,0 @@ -# makefile for libpng on OS/2 with gcc -# For conditions of distribution and use, see copyright notice in png.h - -# Related files: pngos2.def - -CC=gcc -Zomf -s - -# Where the zlib library and include files are located -ZLIBLIB=../zlib -ZLIBINC=../zlib - -WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes #-Wconversion -CFLAGS=-I$(ZLIBINC) -Wall -O6 -funroll-loops -malign-loops=2 \ - -malign-functions=2 #$(WARNMORE) -g -DPNG_DEBUG=5 -LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lzdll -Zcrtdll -AR=emxomfar - -PNGLIB=png.lib -IMPLIB=emximp -SHAREDLIB=png.dll -SHAREDLIBIMP=pngdll.lib - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -.SUFFIXES: .c .o - -all: $(PNGLIB) $(SHAREDLIB) $(SHAREDLIBIMP) - -$(PNGLIB): $(OBJS) - $(AR) rc $@ $(OBJS) - -$(SHAREDLIB): $(OBJS) pngos2.def - $(CC) $(LDFLAGS) -Zdll -o $@ $^ - -$(SHAREDLIBIMP): pngos2.def - $(IMPLIB) -o $@ $^ - -pngtest.exe: pngtest.o png.dll pngdll.lib - $(CC) -o $@ $(CFLAGS) $< $(LDFLAGS) - -test: pngtest.exe - ./pngtest.exe - -clean: - rm -f *.o $(PNGLIB) png.dll pngdll.lib pngtest.exe pngout.png - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h - -pngtest.o: png.h pngconf.h diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.sco b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.sco deleted file mode 100644 index d2cb1d1e5..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.sco +++ /dev/null @@ -1,225 +0,0 @@ -# makefile for SCO OSr5 ELF and Unixware 7 with Native cc -# Contributed by Mike Hopkirk (hops@sco.com) modified from Makefile.lnx -# force ELF build dynamic linking, SONAME setting in lib and RPATH in app -# Copyright (C) 2002, 2006 Glenn Randers-Pehrson -# Copyright (C) 1998 Greg Roelofs -# Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h - -# Library name: -LIBNAME = libpng12 -PNGMAJ = 0 -PNGMIN = 1.2.18 -PNGVER = $(PNGMAJ).$(PNGMIN) - -# Shared library names: -LIBSO=$(LIBNAME).so -LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) -LIBSOVER=$(LIBNAME).so.$(PNGVER) -OLDSO=libpng.so -OLDSOMAJ=libpng.so.3 -OLDSOVER=libpng.so.3.$(PNGMIN) - -# Utilities: -CC=cc -AR_RC=ar rc -MKDIR_P=mkdir -LN_SF=ln -f -s -RANLIB=echo -RM_F=/bin/rm -f - -# where make install puts libpng.a, $(OLDSO)*, and png.h -prefix=/usr/local -exec_prefix=$(prefix) - -# Where the zlib library and include files are located -#ZLIBLIB=/usr/local/lib -#ZLIBINC=/usr/local/include -ZLIBLIB=../zlib -ZLIBINC=../zlib - -CFLAGS= -dy -belf -I$(ZLIBINC) -O3 -LDFLAGS=-L. -L$(ZLIBLIB) -lpng12 -lz -lm - -INCPATH=$(prefix)/include/libpng -LIBPATH=$(exec_prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(exec_prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) -KPIC -o $@ $*.c - -all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo ccopts=\"-belf\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBSO): $(LIBSOMAJ) - $(LN_SF) $(LIBSOMAJ) $(LIBSO) - -$(LIBSOMAJ): $(LIBSOVER) - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) - -$(LIBSOVER): $(OBJSDLL) - $(CC) -G -Wl,-h,$(LIBSOMAJ) -o $(LIBSOVER) \ - $(OBJSDLL) - -$(OLDSOVER): $(OBJSDLL) - $(CC) -G -Wl,-h,$(OLDSOMAJ) -o $(OLDSOVER) \ - $(OBJSDLL) - -pngtest: pngtest.o $(LIBSO) - LD_RUN_PATH=.:$(ZLIBLIB) $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - -@$(RM_F) $(DI)/png.h - -@$(RM_F) $(DI)/pngconf.h - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h - -@$(RM_F) $(DI)/libpng - (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@$(RM_F) $(DL)/libpng.a - (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBSOVER) libpng.pc \ - $(OLDSOVER) - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(LIBSOMAJ) - -@$(RM_F) $(DL)/$(OLDSO) - -@$(RM_F) $(DL)/$(OLDSOMAJ) - -@$(RM_F) $(DL)/$(OLDSOVER)* - cp $(LIBSOVER) $(DL) - cp $(OLDSOVER) $(DL) - chmod 755 $(DL)/$(LIBSOVER) - chmod 755 $(DL)/$(OLDSOVER) - (cd $(DL); \ - $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ - $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ - $(LN_SF) $(LIBSOMAJ) $(LIBSO)) - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc - -@$(RM_F) $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi - -@$(RM_F) $(DM)/man3/libpng.3 - -@$(RM_F) $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi - -@$(RM_F) $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@$(RM_F) $(DB)/libpng-config - -@$(RM_F) $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) -I$(DI) $(CFLAGS) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(DL) -L$(ZLIBLIB) \ - -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtestd pngtest.png - -test-installed: - $(CC) $(CFLAGS) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(ZLIBLIB) \ - -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtesti pngtest.png - -clean: - $(RM_F) *.o libpng.a pngtest pngout.png libpng-config \ - $(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \ - $(OLDSOVER) \ - libpng.pc - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h - -pngtest.o: png.h pngconf.h diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.sggcc b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.sggcc deleted file mode 100644 index b4c1a4b2d..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.sggcc +++ /dev/null @@ -1,238 +0,0 @@ -# makefile for libpng.a and libpng12.so, SGI IRIX with 'cc' -# Copyright (C) 2001-2002, 2006 Glenn Randers-Pehrson -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h - -# Library name: -LIBNAME=libpng12 -PNGMAJ = 0 -PNGMIN = 1.2.18 -PNGVER = $(PNGMAJ).$(PNGMIN) - -# Shared library names: -LIBSO=$(LIBNAME).so -LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) -LIBSOVER=$(LIBNAME).so.$(PNGVER) -OLDSO=libpng.so -OLDSOMAJ=libpng.so.3 -OLDSOVER=libpng.so.3.$(PNGMIN) - -# Utilities: -AR_RC=ar rc -CC=gcc -MKDIR_P=mkdir -p -LN_SF=ln -sf -RANLIB=echo -RM_F=/bin/rm -f - -# Where make install puts libpng.a, libpng12.so, and libpng12/png.h -# Prefix must be a full pathname. - -prefix=/usr/local -exec_prefix=$(prefix) - -# Where the zlib library and include files are located -#ZLIBLIB=/usr/local/lib32 -#ZLIBINC=/usr/local/include -#ZLIBLIB=/usr/local/lib -#ZLIBINC=/usr/local/include -ZLIBLIB=../zlib -ZLIBINC=../zlib - -# ABI can be blank to use default for your system, -32, -o32, -n32, or -64 -# See "man abi". zlib must be built with the same ABI. -ABI= - -WARNMORE= # -g -DPNG_DEBUG=5 -CFLAGS=$(ABI) -I$(ZLIBINC) -O2 $(WARNMORE) -fPIC -mabi=n32 -LDFLAGS=$(ABI) -L. -L$(ZLIBLIB) -lpng -lz -lm -LDSHARED=cc $(ABI) -shared -soname $(LIBSOMAJ) \ - -set_version sgi$(PNGMAJ).0 -LDLEGACY=cc $(ABI) -shared -soname $(OLDSOMAJ) \ - -set_version sgi$3.0 -# See "man dso" for info about shared objects - -INCPATH=$(prefix)/include -LIBPATH=$(exec_prefix)/lib -#LIBPATH=$(exec_prefix)/lib32 -MANPATH=$(prefix)/man -BINPATH=$(exec_prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = pnggccrd.o png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -all: libpng.a pngtest shared libpng.pc libpng-config - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -shared: $(LIBSOVER) - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo ccopts=\"$(ABI)\"; \ - echo ldopts=\"$(ABI)\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo libdir=\"$(LIBPATH)\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBSO): $(LIBSOMAJ) - $(LN_SF) $(LIBSOMAJ) $(LIBSO) - -$(LIBSOMAJ): $(LIBSOVER) - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) - -$(LIBSOVER): $(OBJS) - $(LDSHARED) -o $@ $(OBJS) - $(RM_F) $(LIBSO) $(LIBSOMAJ) - -$(OLDSOVER): $(OBJS) - $(LDLEGACY) -o $@ $(OBJS) - -pngtest: pngtest.o libpng.a - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - echo - echo Testing local static library. - ./pngtest - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h - -@$(RM_F) $(DI)/libpng - (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@$(RM_F) $(DL)/libpng.a - (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBSOVER) libpng.pc \ - $(OLDSOVER) - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(LIBSOMAJ) - -@$(RM_F) $(DL)/$(OLDSO) - -@$(RM_F) $(DL)/$(OLDSOMAJ) - -@$(RM_F) $(DL)/$(OLDSOVER)* - cp $(LIBSOVER) $(DL) - cp $(OLDSOVER) $(DL) - chmod 755 $(DL)/$(LIBSOVER) - chmod 755 $(DL)/$(OLDSOVER) - (cd $(DL); \ - $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ - $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ - $(LN_SF) $(LIBSOMAJ) $(LIBSO)) - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc - -@$(RM_F) $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi - -@$(RM_F) $(DM)/man3/libpng.3 - -@$(RM_F) $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi - -@$(RM_F) $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@$(RM_F) $(DB)/libpng-config - -@$(RM_F) $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) -I$(DI) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(DL) -L$(ZLIBLIB) \ - -rpath $(ZLIBLIB):$(DL) \ - -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtestd pngtest.png - -test-installed: - echo - echo Testing installed dynamic shared library. - $(CC) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(ZLIBLIB) \ - -rpath $(ZLIBLIB):`$(BINPATH)/$(LIBNAME)-config --libdir` \ - -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtesti pngtest.png - -clean: - $(RM_F) libpng.a pngtest pngtesti pngout.png libpng.pc libpng-config \ - $(LIBSO) $(LIBSOMAJ)* \ - $(OLDSOVER) \ - so_locations - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h -pngpread.o: png.h pngconf.h -pnggccrd.o: png.h pngconf.h - diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.sgi b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.sgi deleted file mode 100644 index 1811914dc..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.sgi +++ /dev/null @@ -1,243 +0,0 @@ -# makefile for libpng.a and libpng12.so, SGI IRIX with 'cc' -# Copyright (C) 2001-2002, 2006, 2007 Glenn Randers-Pehrson -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h - -# Library name: -LIBNAME=libpng12 -PNGMAJ = 0 -PNGMIN = 1.2.18 -PNGVER = $(PNGMAJ).$(PNGMIN) - -# Shared library names: -LIBSO=$(LIBNAME).so -LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) -LIBSOVER=$(LIBNAME).so.$(PNGVER) -OLDSO=libpng.so -OLDSOMAJ=libpng.so.3 -OLDSOVER=libpng.so.3.$(PNGMIN) - -# Utilities: -AR_RC=ar rc -CC=cc -MKDIR_P=mkdir -p -LN_SF=ln -sf -RANLIB=echo -RM_F=/bin/rm -f - -# Where make install puts libpng.a, libpng12.so, and libpng12/png.h -# Prefix must be a full pathname. - -prefix=/usr/local -exec_prefix=$(prefix) - -# Where the zlib library and include files are located -#ZLIBLIB=/usr/local/lib32 -#ZLIBINC=/usr/local/include -#ZLIBLIB=/usr/local/lib -#ZLIBINC=/usr/local/include -ZLIBLIB=../zlib -ZLIBINC=../zlib - -# ABI can be blank to use default for your system, -32, -o32, -n32, or -64 -# See "man abi". zlib must be built with the same ABI. -ABI= - -WARNMORE=-fullwarn -# Note: -KPIC is the default anyhow -#CFLAGS= $(ABI) -I$(ZLIBINC) -O $(WARNMORE) -KPIC -DPNG_USE_PNGGCCRD # -g -DPNG_DEBUG=5 -CFLAGS=$(ABI) -I$(ZLIBINC) -O $(WARNMORE) -DPNG_USE_PNGGCCRD \ - -DPNG_NO_MMX_CODE -LDFLAGS_A=$(ABI) -L. -L$(ZLIBLIB) -lpng12 -lz -lm -LDFLAGS=$(ABI) -L. -L$(ZLIBLIB) -lpng -lz -lm -LDSHARED=cc $(ABI) -shared -soname $(LIBSOMAJ) \ - -set_version sgi$(PNGMAJ).0 -LDLEGACY=cc $(ABI) -shared -soname $(OLDSOMAJ) \ - -set_version sgi$3.0 -# See "man dso" for info about shared objects - -INCPATH=$(prefix)/include -LIBPATH=$(exec_prefix)/lib -#LIBPATH=$(exec_prefix)/lib32 -MANPATH=$(prefix)/man -BINPATH=$(exec_prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = pnggccrd.o png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -all: libpng.a pngtest shared libpng.pc libpng-config - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -shared: $(LIBSOVER) - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo cppflags=\"-DPNG_USE_PNGGCCRD -DPNG_NO_MMX_CODE\"; \ - echo ccopts=\"$(ABI)\"; \ - echo ldopts=\"$(ABI)\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo libdir=\"$(LIBPATH)\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBSO): $(LIBSOMAJ) - $(LN_SF) $(LIBSOMAJ) $(LIBSO) - -$(LIBSOMAJ): $(LIBSOVER) - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) - -$(LIBSOVER): $(OBJS) - $(LDSHARED) -o $@ $(OBJS) - $(RM_F) $(LIBSO) $(LIBSOMAJ) - -$(OLDSOVER): $(OBJS) - $(LDLEGACY) -o $@ $(OBJS) - -pngtest: pngtest.o libpng.a - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - echo - echo Testing local static library. - ./pngtest - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h - -@$(RM_F) $(DI)/libpng - (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@$(RM_F) $(DL)/libpng.a - (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBSOVER) libpng.pc \ - $(OLDSOVER) - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(LIBSOMAJ) - -@$(RM_F) $(DL)/$(OLDSO) - -@$(RM_F) $(DL)/$(OLDSOMAJ) - -@$(RM_F) $(DL)/$(OLDSOVER)* - cp $(LIBSOVER) $(DL) - cp $(OLDSOVER) $(DL) - chmod 755 $(DL)/$(LIBSOVER) - chmod 755 $(DL)/$(OLDSOVER) - (cd $(DL); \ - $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ - $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ - $(LN_SF) $(LIBSOMAJ) $(LIBSO)) - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc - -@$(RM_F) $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi - -@$(RM_F) $(DM)/man3/libpng.3 - -@$(RM_F) $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi - -@$(RM_F) $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@$(RM_F) $(DB)/libpng-config - -@$(RM_F) $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) -I$(DI) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(DL) -L$(ZLIBLIB) \ - -rpath $(ZLIBLIB):$(DL) \ - -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtestd pngtest.png - -test-installed: - echo - echo Testing installed dynamic shared library. - $(CC) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(ZLIBLIB) \ - -rpath $(ZLIBLIB):`$(BINPATH)/$(LIBNAME)-config --libdir` \ - -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtesti pngtest.png - -clean: - $(RM_F) *.o libpng.a pngtest pngtesti pngout.png libpng.pc libpng-config \ - $(LIBSO) $(LIBSOMAJ)* \ - $(OLDSOVER) \ - so_locations - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h -pngpread.o: png.h pngconf.h -pnggccrd.o: png.h pngconf.h - diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.so9 b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.so9 deleted file mode 100644 index 5128fbd17..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.so9 +++ /dev/null @@ -1,247 +0,0 @@ -# makefile for libpng on Solaris 9 (beta) with Forte cc -# Updated by Chad Schrock for Solaris 9 -# Contributed by William L. Sebok, based on makefile.linux -# Copyright (C) 2002, 2006 Glenn Randers-Pehrson -# Copyright (C) 1998-2001 Greg Roelofs -# Copyright (C) 1996-1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h - -# Library name: -PNGMAJ = 0 -PNGMIN = 1.2.18 -PNGVER = $(PNGMAJ).$(PNGMIN) -LIBNAME = libpng12 - -# Shared library names: -LIBSO=$(LIBNAME).so -LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) -LIBSOVER=$(LIBNAME).so.$(PNGVER) -OLDSO=libpng.so -OLDSOMAJ=libpng.so.3 -OLDSOVER=libpng.so.3.$(PNGMIN) - -# Utilities: -# gcc 2.95 doesn't work. -CC=cc -AR_RC=ar rc -MKDIR_P=mkdir -p -LN_SF=ln -f -s -RANLIB=echo -RM_F=/bin/rm -f - -# Where make install puts libpng.a, $(OLDSO)*, and png.h -prefix=/usr/local -exec_prefix=$(prefix) - -# Where the zlib library and include files are located -# Changing these to ../zlib poses a security risk. If you want -# to have zlib in an adjacent directory, specify the full path instead of "..". -#ZLIBLIB=../zlib -#ZLIBINC=../zlib -#ZLIBLIB=/usr/local/lib -#ZLIBINC=/usr/local/include -#Use the preinstalled zlib that comes with Solaris 9: -ZLIBLIB=/usr/lib -ZLIBINC=/usr/include - -#WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes #-Wconversion -#CFLAGS=-I$(ZLIBINC) -Wall -O3 $(WARNMORE) -g -DPNG_DEBUG=5 -CFLAGS=-I$(ZLIBINC) -O3 -LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng12 -lz -lm - -INCPATH=$(prefix)/include -LIBPATH=$(exec_prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(exec_prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) -KPIC -o $@ $*.c - -all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo R_opts=\"-R$(LIBPATH)\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBSO): $(LIBSOMAJ) - $(LN_SF) $(LIBSOMAJ) $(LIBSO) - -$(LIBSOMAJ): $(LIBSOVER) - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) - -$(LIBSOVER): $(OBJSDLL) - @case "`type ld`" in *ucb*) \ - echo; \ - echo '## WARNING:'; \ - echo '## The commands "CC" and "LD" must NOT refer to /usr/ucb/cc'; \ - echo '## and /usr/ucb/ld. If they do, you need to adjust your PATH'; \ - echo '## environment variable to put /usr/ccs/bin ahead of /usr/ucb.'; \ - echo '## The environment variable LD_LIBRARY_PATH should not be set'; \ - echo '## at all. If it is, things are likely to break because of'; \ - echo '## the libucb dependency that is created.'; \ - echo; \ - ;; \ - esac - $(LD) -G -h $(LIBSOMAJ) \ - -o $(LIBSOVER) $(OBJSDLL) - -$(OLDSOVER): $(OBJS) - $(LD) -G -h $(OLDSOMAJ) \ - -o $(OLDSOVER) $(OBJSDLL) - -pngtest: pngtest.o $(LIBSO) - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h - -@$(RM_F) $(DI)/libpng - (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@$(RM_F) $(DL)/libpng.a - (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBSOVER) libpng.pc \ - $(OLDSOVER) - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(LIBSOMAJ) - -@$(RM_F) $(DL)/$(OLDSO) - -@$(RM_F) $(DL)/$(OLDSOMAJ) - -@$(RM_F) $(DL)/$(OLDSOVER)* - cp $(LIBSOVER) $(DL) - cp $(OLDSOVER) $(DL) - chmod 755 $(DL)/$(LIBSOVER) - chmod 755 $(DL)/$(OLDSOVER) - (cd $(DL); \ - $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ - $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ - $(LN_SF) $(LIBSOMAJ) $(LIBSO)) - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc - -@$(RM_F) $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi - -@$(RM_F) $(DM)/man3/libpng.3 - -@$(RM_F) $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi - -@$(RM_F) $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@$(RM_F) $(DB)/libpng-config - -@$(RM_F) $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) -I$(DI) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` \ - -L$(DL) -L$(ZLIBLIB) -R$(ZLIBLIB) -R$(DL) - ./pngtestd pngtest.png - -test-installed: - echo - echo Testing installed dynamic shared library. - $(CC) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` \ - -L$(ZLIBLIB) -R$(ZLIBLIB) - ./pngtesti pngtest.png - -clean: - $(RM_F) *.o libpng.a pngtest pngtesti pngout.png \ - libpng-config $(LIBSO) $(LIBSOMAJ)* \ - $(OLDSOVER) \ - libpng.pc - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h - -pngtest.o: png.h pngconf.h diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.solaris b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.solaris deleted file mode 100644 index 0c6857b19..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.solaris +++ /dev/null @@ -1,244 +0,0 @@ -# makefile for libpng on Solaris 2.x with gcc -# Copyright (C) 2004, 2006, 2007 Glenn Randers-Pehrson -# Contributed by William L. Sebok, based on makefile.linux -# Copyright (C) 1998 Greg Roelofs -# Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h - -# Library name: -LIBNAME = libpng12 -PNGMAJ = 0 -PNGMIN = 1.2.18 -PNGVER = $(PNGMAJ).$(PNGMIN) - -# Shared library names: -LIBSO=$(LIBNAME).so -LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) -LIBSOVER=$(LIBNAME).so.$(PNGVER) -OLDSO=libpng.so -OLDSOMAJ=libpng.so.3 -OLDSOVER=libpng.so.3.$(PNGMIN) - -# Utilities: -AR_RC=ar rc -CC=gcc -MKDIR_P=mkdir -p -LN_SF=ln -f -s -RANLIB=echo -RM_F=/bin/rm -f - -# Where make install puts libpng.a, libpng12.so*, and png.h -prefix=/usr/local -exec_prefix=$(prefix) - -# Where the zlib library and include files are located -# Changing these to ../zlib poses a security risk. If you want -# to have zlib in an adjacent directory, specify the full path instead of "..". -#ZLIBLIB=../zlib -#ZLIBINC=../zlib - -ZLIBLIB=/usr/local/lib -ZLIBINC=/usr/local/include - -WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes #-Wconversion -CFLAGS=-I$(ZLIBINC) -Wall -O \ - # $(WARNMORE) -g -DPNG_DEBUG=5 -LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng12 -lz -lm - -INCPATH=$(prefix)/include -LIBPATH=$(exec_prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(exec_prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c - -all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo cppflags=\"-DPNG_USE_PNGGCCRD -DPNG_NO_MMX_CODE\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo R_opts=\"-R$(LIBPATH)\"; \ - echo libs=\"-lpng12 -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBSO): $(LIBSOMAJ) - $(LN_SF) $(LIBSOMAJ) $(LIBSO) - -$(LIBSOMAJ): $(LIBSOVER) - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) - -$(LIBSOVER): $(OBJSDLL) - @case "`type ld`" in *ucb*) \ - echo; \ - echo '## WARNING:'; \ - echo '## The commands "CC" and "LD" must NOT refer to /usr/ucb/cc'; \ - echo '## and /usr/ucb/ld. If they do, you need to adjust your PATH'; \ - echo '## environment variable to put /usr/ccs/bin ahead of /usr/ucb.'; \ - echo '## The environment variable LD_LIBRARY_PATH should not be set'; \ - echo '## at all. If it is, things are likely to break because of'; \ - echo '## the libucb dependency that is created.'; \ - echo; \ - ;; \ - esac - $(LD) -G -h $(LIBSOMAJ) \ - -o $(LIBSOVER) $(OBJSDLL) - -$(OLDSOVER): $(OBJS) - $(LD) -G -h $(OLDSOMAJ) \ - -o $(OLDSOVER) $(OBJSDLL) - -pngtest: pngtest.o $(LIBSO) - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h - -@$(RM_F) $(DI)/libpng - (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@$(RM_F) $(DL)/libpng.a - (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBSOVER) libpng.pc \ - $(OLDSOVER) - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(LIBSOMAJ) - -@$(RM_F) $(DL)/$(OLDSO) - -@$(RM_F) $(DL)/$(OLDSOMAJ) - -@$(RM_F) $(DL)/$(OLDSOVER)* - cp $(LIBSOVER) $(DL) - cp $(OLDSOVER) $(DL) - chmod 755 $(DL)/$(LIBSOVER) - chmod 755 $(DL)/$(OLDSOVER) - (cd $(DL); \ - $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ - $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ - $(LN_SF) $(LIBSOVER) $(LIBSO); \ - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ)) - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc - -@$(RM_F) $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi - -@$(RM_F) $(DM)/man3/libpng.3 - -@$(RM_F) $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi - -@$(RM_F) $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@$(RM_F) $(DB)/libpng-config - -@$(RM_F) $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) -I$(DI) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` \ - -L$(DL) -L$(ZLIBLIB) -R$(ZLIBLIB) -R$(DL) - ./pngtestd pngtest.png - -test-installed: - echo - echo Testing installed dynamic shared library. - $(CC) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` \ - -L$(ZLIBLIB) -R$(ZLIBLIB) - ./pngtesti pngtest.png - -clean: - $(RM_F) *.o libpng.a pngtest pngtesti pngout.png \ - libpng-config $(LIBSO) $(LIBSOMAJ)* \ - $(OLDSOVER) \ - libpng.pc - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h - -pngtest.o: png.h pngconf.h diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.std b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.std deleted file mode 100644 index eb0aea367..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.std +++ /dev/null @@ -1,92 +0,0 @@ -# makefile for libpng -# Copyright (C) 2002, 2006 Glenn Randers-Pehrson -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h - -# where make install puts libpng.a and png.h -prefix=/usr/local -INCPATH=$(prefix)/include -LIBPATH=$(prefix)/lib - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -# Where the zlib library and include files are located -#ZLIBLIB=/usr/local/lib -#ZLIBINC=/usr/local/include -ZLIBLIB=../zlib -ZLIBINC=../zlib - -CC=cc -AR_RC=ar rc -MKDIR_P=mkdir -LN_SF=ln -sf -RANLIB=ranlib -RM_F=rm -f - -CFLAGS=-I$(ZLIBINC) -O # -g -DPNG_DEBUG=5 -LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -all: libpng.a pngtest - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -pngtest: pngtest.o libpng.a - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install: libpng.a - -@$(MKDIR_P) $(DESTDIR)$(INCPATH) - -@$(MKDIR_P) $(DESTDIR)$(INCPATH)/libpng - -@$(MKDIR_P) $(DESTDIR)$(LIBPATH) - -@$(RM_F) $(DESTDIR)$(INCPATH)/png.h - -@$(RM_F) $(DESTDIR)$(INCPATH)/pngconf.h - cp png.h $(DESTDIR)$(INCPATH)/libpng - cp pngconf.h $(DESTDIR)$(INCPATH)/libpng - chmod 644 $(DESTDIR)$(INCPATH)/libpng/png.h - chmod 644 $(DESTDIR)$(INCPATH)/libpng/pngconf.h - (cd $(DESTDIR)$(INCPATH); ln -f -s libpng/* .) - cp libpng.a $(DESTDIR)$(LIBPATH) - chmod 644 $(DESTDIR)$(LIBPATH)/libpng.a - -clean: - $(RM_F) *.o libpng.a pngtest pngout.png - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h -pngpread.o: png.h pngconf.h - diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.sunos b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.sunos deleted file mode 100644 index fad81fcf8..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.sunos +++ /dev/null @@ -1,97 +0,0 @@ -# makefile for libpng -# Copyright (C) 2002, 2006 Glenn Randers-Pehrson -# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h - -# where make install puts libpng.a and png.h -prefix=/usr/local -INCPATH=$(prefix)/include -LIBPATH=$(prefix)/lib - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -# Where the zlib library and include files are located -#ZLIBLIB=/usr/local/lib -#ZLIBINC=/usr/local/include -ZLIBLIB=../zlib -ZLIBINC=../zlib - - -WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow -Wconversion \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes - -CC=gcc -AR_RC=ar rc -MKDIR_P=mkdir -p -LN_SF=ln -f -s -RANLIB=ranlib -RM_F=/bin/rm -f - -CFLAGS=-I$(ZLIBINC) -O # $(WARNMORE) -DPNG_DEBUG=5 -LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -all: libpng.a pngtest - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -pngtest: pngtest.o libpng.a - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install: libpng.a - -@$(MKDIR_P) $(DESTDIR)$(INCPATH) - -@$(MKDIR_P) $(DESTDIR)$(INCPATH)/libpng - -@$(MKDIR_P) $(DESTDIR)$(LIBPATH) - -@$(RM_F) $(DESTDIR)$(INCPATH)/png.h - -@$(RM_F) $(DESTDIR)$(INCPATH)/pngconf.h - cp png.h $(DESTDIR)$(INCPATH)/libpng - cp pngconf.h $(DESTDIR)$(INCPATH)/libpng - chmod 644 $(DESTDIR)$(INCPATH)/libpng/png.h - chmod 644 $(DESTDIR)$(INCPATH)/libpng/pngconf.h - (cd $(DESTDIR)$(INCPATH); $(LN_SF) libpng/* .) - cp libpng.a $(DESTDIR)$(LIBPATH) - chmod 644 $(DESTDIR)$(LIBPATH)/libpng.a - -clean: - $(RM_F) *.o libpng.a pngtest pngout.png - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h -pngpread.o: png.h pngconf.h - diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.tc3 b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.tc3 deleted file mode 100644 index cedefc415..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.tc3 +++ /dev/null @@ -1,89 +0,0 @@ -# Makefile for libpng -# TurboC/C++ (Note: All modules are compiled in C mode) - -# To use, do "make -fmakefile.tc3" - -# ----- Turbo C 3.00 (can be modified to work with earlier versions) ----- - -MODEL=l -CFLAGS=-O2 -Z -m$(MODEL) -I..\zlib -#CFLAGS=-D_NO_PROTO -O2 -Z -m$(MODEL) -I..\zlib # Turbo C older than 3.00 -CC=tcc -LD=tcc -LIB=tlib -LDFLAGS=-m$(MODEL) -L..\zlib -O=.obj -E=.exe - -# variables -OBJS1 = png$(O) pngset$(O) pngget$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O) -OBJS2 = pngmem$(O) pngpread$(O) pngread$(O) pngerror$(O) pngwrite$(O) -OBJS3 = pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O) -OBJSL1 = +png$(O) +pngset$(O) +pngget$(O) +pngrutil$(O) +pngtrans$(O) -OBJSL2 = +pngwutil$(O) +pngmem$(O) +pngpread$(O) +pngread$(O) +pngerror$(O) -OBJSL3 = +pngwrite$(O) +pngrtran$(O) +pngwtran$(O) +pngrio$(O) +pngwio$(O) - -all: libpng$(MODEL).lib pngtest$(E) - -pngtest: pngtest$(E) - -test: pngtest$(E) - pngtest$(E) - -png$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngset$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngget$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngread$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngpread$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngrtran$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngrutil$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngerror$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngmem$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngrio$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngwio$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngtest$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngtrans$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngwrite$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngwtran$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -pngwutil$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c - -libpng$(MODEL).lib: $(OBJS1) $(OBJS2) $(OBJS3) - $(LIB) libpng$(MODEL) +$(OBJSL1) - $(LIB) libpng$(MODEL) +$(OBJSL2) - $(LIB) libpng$(MODEL) +$(OBJSL3) - -pngtest$(E): pngtest$(O) libpng$(MODEL).lib - $(LD) $(LDFLAGS) pngtest.obj libpng$(MODEL).lib zlib_$(MODEL).lib - -# End of makefile for libpng diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.vcawin32 b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.vcawin32 deleted file mode 100644 index 89effe51f..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.vcawin32 +++ /dev/null @@ -1,103 +0,0 @@ -# makefile for libpng -# Copyright (C) 1998 Tim Wegner -# For conditions of distribution and use, see copyright notice in png.h -# Assumes that zlib.lib, zconf.h, and zlib.h have been copied to ..\zlib -# To use, do "nmake /f scripts\makefile.vcawin32" - -# -------- Microsoft Visual C++ 5.0 and later, uses assembler code -------- -# If you don't want to use assembler (MMX) code, use makefile.vcwin32 instead. - -# Compiler, linker, librarian, and other tools -CC = cl -LD = link -AR = lib -CFLAGS = -DPNG_USE_PNGVCRD -nologo -MD -O2 -W3 -I..\zlib -LDFLAGS = -nologo -ARFLAGS = -nologo -RM = del - -# File extensions -O=.obj - -#uncomment next to put error messages in a file -#ERRFILE= >> pngerrs.log - -# Variables -OBJS1 = png$(O) pngerror$(O) pngget$(O) pngmem$(O) pngpread$(O) -OBJS2 = pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) pngset$(O) -OBJS3 = pngtrans$(O) pngwio$(O) pngwrite$(O) pngwtran$(O) pngwutil$(O) -OBJS4 = pngvcrd$(O) -OBJS = $(OBJS1) $(OBJS2) $(OBJS3) $(OBJS4) - -# Targets -all: libpng.lib - -png$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngset$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngget$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngread$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngpread$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngrtran$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngrutil$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngerror$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngmem$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngrio$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwio$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngtest$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngtrans$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwrite$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwtran$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwutil$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngvcrd$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -libpng.lib: $(OBJS) - -$(RM) $@ - $(AR) $(ARFLAGS) -out:$@ $(OBJS) $(ERRFILE) - -pngtest.exe: pngtest$(O) libpng.lib - $(LD) $(LDFLAGS) -out:$@ pngtest$(O) libpng.lib ..\zlib\zlib.lib $(ERRFILE) - -test: pngtest.exe - pngtest - -clean: - -$(RM) *$(O) - -$(RM) libpng.lib - -$(RM) pngtest.exe - -$(RM) pngout.png - -# End of makefile for libpng - diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.vcwin32 b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.vcwin32 deleted file mode 100644 index 6148c836a..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.vcwin32 +++ /dev/null @@ -1,99 +0,0 @@ -# makefile for libpng -# Copyright (C) 1998 Tim Wegner -# For conditions of distribution and use, see copyright notice in png.h -# Assumes that zlib.lib, zconf.h, and zlib.h have been copied to ..\zlib -# To use, do "nmake /f scripts\makefile.vcwin32" - -# -------- Microsoft Visual C++ 2.0 and later, no assembler code -------- -# If you want to use assembler (MMX) code, use makefile.vcawin32 instead. - -# Compiler, linker, librarian, and other tools -CC = cl -LD = link -AR = lib -CFLAGS = -nologo -MD -O2 -W3 -I..\zlib -LDFLAGS = -nologo -ARFLAGS = -nologo -RM = del - -# File extensions -O=.obj - -#uncomment next to put error messages in a file -#ERRFILE= >> pngerrs.log - -# Variables -OBJS1 = png$(O) pngerror$(O) pngget$(O) pngmem$(O) pngpread$(O) -OBJS2 = pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) pngset$(O) -OBJS3 = pngtrans$(O) pngwio$(O) pngwrite$(O) pngwtran$(O) pngwutil$(O) -OBJS = $(OBJS1) $(OBJS2) $(OBJS3) - -# Targets -all: libpng.lib - -png$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngset$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngget$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngread$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngpread$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngrtran$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngrutil$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngerror$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngmem$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngrio$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwio$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngtest$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngtrans$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwrite$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwtran$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwutil$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -libpng.lib: $(OBJS) - -$(RM) $@ - $(AR) $(ARFLAGS) -out:$@ $(OBJS) $(ERRFILE) - -pngtest.exe: pngtest$(O) libpng.lib - $(LD) $(LDFLAGS) -out:$@ pngtest$(O) libpng.lib ..\zlib\zlib.lib $(ERRFILE) - -test: pngtest.exe - pngtest - -clean: - -$(RM) *$(O) - -$(RM) libpng.lib - -$(RM) pngtest.exe - -$(RM) pngout.png - -# End of makefile for libpng - diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.watcom b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.watcom deleted file mode 100644 index 32cd333f9..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makefile.watcom +++ /dev/null @@ -1,109 +0,0 @@ -# Makefile for libpng -# Watcom C/C++ 10.0 and later, 32-bit protected mode, flat memory model - -# Copyright (C) 2000, Pawel Mrochen, based on makefile.msc which is -# copyright 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h - -# To use, do "wmake /f scripts\makefile.watcom" - - -# ---------------------- Watcom C/C++ 10.0 and later ----------------------- - -# Where the zlib library and include files are located -ZLIBLIB=..\zlib -ZLIBINC=..\zlib - -# Target OS -OS=DOS -#OS=NT - -# Target CPU -CPU=6 # Pentium Pro -#CPU=5 # Pentium - -# Calling convention -CALLING=r # registers -#CALLING=s # stack - -# Uncomment next to put error messages in a file -#ERRFILE=>>pngerrs - -# -------------------------------------------------------------------------- - - -CC=wcc386 -CFLAGS=-$(CPU)$(CALLING) -fp$(CPU) -fpi87 -oneatx -mf -bt=$(OS) -i=$(ZLIBINC) -zq -LD=wcl386 -LDFLAGS=-zq - -O=.obj - -OBJS1=png$(O) pngset$(O) pngget$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O) -OBJS2=pngmem$(O) pngpread$(O) pngread$(O) pngerror$(O) pngwrite$(O) -OBJS3=pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O) - - -all: test - -png$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngset$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngget$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngread$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngpread$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngrtran$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngrutil$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngerror$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngmem$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngrio$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngwio$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngtest$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngtrans$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngwrite$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngwtran$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngwutil$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -libpng.lib: $(OBJS1) $(OBJS2) $(OBJS3) - wlib -b -c -n -q libpng.lib $(OBJS1) - wlib -b -c -q libpng.lib $(OBJS2) - wlib -b -c -q libpng.lib $(OBJS3) - -pngtest.exe: pngtest.obj libpng.lib - $(LD) $(LDFLAGS) pngtest.obj libpng.lib $(ZLIBLIB)\zlib.lib - -test: pngtest.exe .symbolic - pngtest.exe - - -# End of makefile for libpng diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makevms.com b/irrlicht-1.6/source/Irrlicht/libpng/scripts/makevms.com deleted file mode 100644 index 8061ba873..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/makevms.com +++ /dev/null @@ -1,144 +0,0 @@ -$! make libpng under VMS -$! -$! -$! Check for MMK/MMS -$! -$! This procedure accepts one parameter (contrib), which causes it to build -$! the programs from the contrib directory instead of libpng. -$! -$ p1 = f$edit(p1,"UPCASE") -$ if p1 .eqs. "CONTRIB" -$ then -$ set def [.contrib.gregbook] -$ @makevms -$ set def [-.pngminus] -$ @makevms -$ set def [--] -$ exit -$ endif -$ Make = "" -$ If F$Search ("Sys$System:MMS.EXE") .nes. "" Then Make = "MMS" -$ If F$Type (MMK) .eqs. "STRING" Then Make = "MMK" -$! -$! Look for the compiler used -$! -$ zlibsrc = "[-.zlib]" -$ ccopt="/include=''zlibsrc'" -$ if f$getsyi("HW_MODEL").ge.1024 -$ then -$ ccopt = "/prefix=all"+ccopt -$ comp = "__decc__=1" -$ if f$trnlnm("SYS").eqs."" then define sys sys$library: -$ else -$ if f$search("SYS$SYSTEM:DECC$COMPILER.EXE").eqs."" -$ then -$ if f$trnlnm("SYS").eqs."" then define sys sys$library: -$ if f$search("SYS$SYSTEM:VAXC.EXE").eqs."" -$ then -$ comp = "__gcc__=1" -$ CC :== GCC -$ else -$ comp = "__vaxc__=1" -$ endif -$ else -$ if f$trnlnm("SYS").eqs."" then define sys decc$library_include: -$ ccopt = "/decc/prefix=all"+ccopt -$ comp = "__decc__=1" -$ endif -$ endif -$! -$! Build the thing plain or with mms/mmk -$! -$ write sys$output "Compiling Libpng sources ..." -$ if make.eqs."" -$ then -$ dele pngtest.obj;* -$ CALL MAKE png.OBJ "cc ''CCOPT' png" - - png.c png.h pngconf.h -$ CALL MAKE pngpread.OBJ "cc ''CCOPT' pngpread" - - pngpread.c png.h pngconf.h -$ CALL MAKE pngset.OBJ "cc ''CCOPT' pngset" - - pngset.c png.h pngconf.h -$ CALL MAKE pngget.OBJ "cc ''CCOPT' pngget" - - pngget.c png.h pngconf.h -$ CALL MAKE pngread.OBJ "cc ''CCOPT' pngread" - - pngread.c png.h pngconf.h -$ CALL MAKE pngpread.OBJ "cc ''CCOPT' pngpread" - - pngpread.c png.h pngconf.h -$ CALL MAKE pngrtran.OBJ "cc ''CCOPT' pngrtran" - - pngrtran.c png.h pngconf.h -$ CALL MAKE pngrutil.OBJ "cc ''CCOPT' pngrutil" - - pngrutil.c png.h pngconf.h -$ CALL MAKE pngerror.OBJ "cc ''CCOPT' pngerror" - - pngerror.c png.h pngconf.h -$ CALL MAKE pngmem.OBJ "cc ''CCOPT' pngmem" - - pngmem.c png.h pngconf.h -$ CALL MAKE pngrio.OBJ "cc ''CCOPT' pngrio" - - pngrio.c png.h pngconf.h -$ CALL MAKE pngwio.OBJ "cc ''CCOPT' pngwio" - - pngwio.c png.h pngconf.h -$ CALL MAKE pngtrans.OBJ "cc ''CCOPT' pngtrans" - - pngtrans.c png.h pngconf.h -$ CALL MAKE pngwrite.OBJ "cc ''CCOPT' pngwrite" - - pngwrite.c png.h pngconf.h -$ CALL MAKE pngwtran.OBJ "cc ''CCOPT' pngwtran" - - pngwtran.c png.h pngconf.h -$ CALL MAKE pngwutil.OBJ "cc ''CCOPT' pngwutil" - - pngwutil.c png.h pngconf.h -$ write sys$output "Building Libpng ..." -$ CALL MAKE libpng.OLB "lib/crea libpng.olb *.obj" *.OBJ -$ write sys$output "Building pngtest..." -$ CALL MAKE pngtest.OBJ "cc ''CCOPT' pngtest" - - pngtest.c png.h pngconf.h -$ call make pngtest.exe - - "LINK pngtest,libpng.olb/lib,''zlibsrc'libz.olb/lib" - - pngtest.obj libpng.olb -$ write sys$output "Testing Libpng..." -$ run pngtest -$ else -$ if f$search("DESCRIP.MMS") .eqs. "" then copy/nolog [.SCRIPTS]DESCRIP.MMS [] -$ 'make'/macro=('comp',zlibsrc='zlibsrc') -$ endif -$ write sys$output "Libpng build completed" -$ exit -$! -$! -$MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES -$ V = 'F$Verify(0) -$! P1 = What we are trying to make -$! P2 = Command to make it -$! P3 - P8 What it depends on -$ -$ If F$Search(P1) .Eqs. "" Then Goto Makeit -$ Time = F$CvTime(F$File(P1,"RDT")) -$arg=3 -$Loop: -$ Argument = P'arg -$ If Argument .Eqs. "" Then Goto Exit -$ El=0 -$Loop2: -$ File = F$Element(El," ",Argument) -$ If File .Eqs. " " Then Goto Endl -$ AFile = "" -$Loop3: -$ OFile = AFile -$ AFile = F$Search(File) -$ If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl -$ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit -$ Goto Loop3 -$NextEL: -$ El = El + 1 -$ Goto Loop2 -$EndL: -$ arg=arg+1 -$ If arg .Le. 8 Then Goto Loop -$ Goto Exit -$ -$Makeit: -$ VV=F$VERIFY(0) -$ write sys$output P2 -$ 'P2 -$ VV='F$Verify(VV) -$Exit: -$ If V Then Set Verify -$ENDSUBROUTINE diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/pngos2.def b/irrlicht-1.6/source/Irrlicht/libpng/scripts/pngos2.def deleted file mode 100644 index 4e7f073c1..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/pngos2.def +++ /dev/null @@ -1,258 +0,0 @@ -;---------------------------------------- -; PNG.LIB module definition file for OS/2 -;---------------------------------------- - -; Version 1.2.18 - -LIBRARY PNG -DESCRIPTION "PNG image compression library for OS/2" -CODE PRELOAD MOVEABLE DISCARDABLE -DATA PRELOAD MOVEABLE MULTIPLE - -EXPORTS - - - png_build_grayscale_palette - png_check_sig - png_chunk_error - png_chunk_warning - png_convert_from_struct_tm - png_convert_from_time_t - png_create_info_struct - png_create_read_struct - png_create_write_struct - png_data_freer - png_destroy_info_struct - png_destroy_read_struct - png_destroy_write_struct - png_error - png_free - png_free_data - png_get_IHDR - png_get_PLTE - png_get_bKGD - png_get_bit_depth - png_get_cHRM - png_get_cHRM_fixed - png_get_channels - png_get_color_type - png_get_compression_buffer_size - png_get_compression_type - png_get_copyright - png_get_error_ptr - png_get_filter_type - png_get_gAMA - png_get_gAMA_fixed - png_get_hIST - png_get_header_ver - png_get_header_version - png_get_iCCP - png_get_image_height - png_get_image_width - png_get_interlace_type - png_get_io_ptr - png_get_libpng_ver - png_get_oFFs - png_get_pCAL - png_get_pHYs - png_get_pixel_aspect_ratio - png_get_pixels_per_meter - png_get_progressive_ptr - png_get_rgb_to_gray_status - png_get_rowbytes - png_get_rows - png_get_sBIT - png_get_sCAL - png_get_sPLT - png_get_sRGB - png_get_signature - png_get_tIME - png_get_tRNS - png_get_text - png_get_unknown_chunks - png_get_user_chunk_ptr - png_get_user_transform_ptr - png_get_valid - png_get_x_offset_microns - png_get_x_offset_pixels - png_get_x_pixels_per_meter - png_get_y_offset_microns - png_get_y_offset_pixels - png_get_y_pixels_per_meter - png_malloc - png_memcpy_check - png_memset_check - png_permit_empty_plte - png_process_data - png_progressive_combine_row - png_read_end - png_read_image - png_read_info -; png_read_init ; deprecated - png_read_png - png_read_row - png_read_rows - png_read_update_info - png_reset_zstream - png_set_IHDR - png_set_PLTE - png_set_bKGD - png_set_background - png_set_bgr - png_set_cHRM - png_set_cHRM_fixed - png_set_compression_buffer_size - png_set_compression_level - png_set_compression_mem_level - png_set_compression_method - png_set_compression_strategy - png_set_compression_window_bits - png_set_crc_action - png_set_dither - png_set_error_fn - png_set_expand - png_set_filler - png_set_filter - png_set_filter_heuristics - png_set_flush - png_set_gAMA - png_set_gAMA_fixed - png_set_gamma -; png_set_gray_1_2_4_to_8 ; deprecated as of libpng-1.2.9 - png_set_gray_to_rgb - png_set_hIST - png_set_iCCP - png_set_interlace_handling - png_set_invert_alpha - png_set_invert_mono - png_set_keep_unknown_chunks - png_set_oFFs - png_set_pCAL - png_set_pHYs - png_set_packing - png_set_packswap - png_set_palette_to_rgb - png_set_progressive_read_fn - png_set_read_fn - png_set_read_status_fn - png_set_read_user_chunk_fn - png_set_read_user_transform_fn - png_set_rgb_to_gray - png_set_rgb_to_gray_fixed - png_set_rows - png_set_sBIT - png_set_sCAL - png_set_sPLT - png_set_sRGB - png_set_sRGB_gAMA_and_cHRM - png_set_shift - png_set_sig_bytes - png_set_strip_16 - png_set_strip_alpha - png_set_swap - png_set_swap_alpha - png_set_tIME - png_set_tRNS - png_set_tRNS_to_alpha - png_set_text - png_set_unknown_chunk_location - png_set_unknown_chunks - png_set_user_transform_info - png_set_write_fn - png_set_write_status_fn - png_set_write_user_transform_fn - png_sig_cmp - png_start_read_image - png_warning - png_write_chunk - png_write_chunk_data - png_write_chunk_end - png_write_chunk_start - png_write_end - png_write_flush - png_write_image - png_write_info - png_write_info_before_PLTE -; png_write_init ; deprecated - png_write_png - png_write_row - png_write_rows - png_read_init_2 - png_write_init_2 - png_access_version_number - png_init_io - png_convert_to_rfc1123 - png_set_invalid - -; Added at version 1.2.0: - png_mmx_support - png_permit_empty_plte - png_permit_mng_features - png_get_mmx_flagmask - png_get_asm_flagmask - png_get_asm_flags - png_get_mmx_bitdepth_threshold - png_get_mmx_rowbytes_threshold - png_set_asm_flags - png_init_mmx_flags - -; Added at version 1.2.2: - png_handle_as_unknown - -; Added at version 1.2.2 and deleted from 1.2.3: -; png_zalloc -; png_zfree - -; Added at version 1.2.4 - png_malloc_warn - -; Added at version 1.2.6 - png_set_user_limits - png_get_user_height_max - png_get_user_width_max -; Added at version 1.2.7 - png_set_add_alpha - -; Added at version 1.2.9 - png_get_uint_32 - png_save_uint_32 - png_get_uint_16 - png_save_uint_16 - png_get_int_32 - png_save_int_32 - png_get_uint_31 - png_set_expand_gray_1_2_4_to_8 - -; These are not present when libpng is compiled with PNG_NO_GLOBAL_ARRAYS - png_libpng_ver - png_pass_start - png_pass_inc - png_pass_ystart - png_pass_yinc - png_pass_mask - png_pass_dsp_mask -; png_pass_width -; png_pass_height - -; These are not present when libpng is compiled with PNG_NO_GLOBAL_ARRAYS - png_IHDR - png_IDAT - png_IEND - png_PLTE - png_bKGD - png_cHRM - png_gAMA - png_hIST - png_iCCP - png_iTXt - png_oFFs - png_pCAL - png_pHYs - png_sBIT - png_sCAL - png_sPLT - png_sRGB - png_tEXt - png_tIME - png_tRNS - png_zTXt diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/pngw32.def b/irrlicht-1.6/source/Irrlicht/libpng/scripts/pngw32.def deleted file mode 100644 index f66d9c2ec..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/pngw32.def +++ /dev/null @@ -1,236 +0,0 @@ -;------------------------------------------ -; LIBPNG module definition file for Windows -;------------------------------------------ - -LIBRARY - -EXPORTS -;Version 1.2.18 - png_build_grayscale_palette @1 - png_check_sig @2 - png_chunk_error @3 - png_chunk_warning @4 - png_convert_from_struct_tm @5 - png_convert_from_time_t @6 - png_create_info_struct @7 - png_create_read_struct @8 - png_create_write_struct @9 - png_data_freer @10 - png_destroy_info_struct @11 - png_destroy_read_struct @12 - png_destroy_write_struct @13 - png_error @14 - png_free @15 - png_free_data @16 - png_get_IHDR @17 - png_get_PLTE @18 - png_get_bKGD @19 - png_get_bit_depth @20 - png_get_cHRM @21 - png_get_cHRM_fixed @22 - png_get_channels @23 - png_get_color_type @24 - png_get_compression_buffer_size @25 - png_get_compression_type @26 - png_get_copyright @27 - png_get_error_ptr @28 - png_get_filter_type @29 - png_get_gAMA @30 - png_get_gAMA_fixed @31 - png_get_hIST @32 - png_get_header_ver @33 - png_get_header_version @34 - png_get_iCCP @35 - png_get_image_height @36 - png_get_image_width @37 - png_get_interlace_type @38 - png_get_io_ptr @39 - png_get_libpng_ver @40 - png_get_oFFs @41 - png_get_pCAL @42 - png_get_pHYs @43 - png_get_pixel_aspect_ratio @44 - png_get_pixels_per_meter @45 - png_get_progressive_ptr @46 - png_get_rgb_to_gray_status @47 - png_get_rowbytes @48 - png_get_rows @49 - png_get_sBIT @50 - png_get_sCAL @51 - png_get_sPLT @52 - png_get_sRGB @53 - png_get_signature @54 - png_get_tIME @55 - png_get_tRNS @56 - png_get_text @57 - png_get_unknown_chunks @58 - png_get_user_chunk_ptr @59 - png_get_user_transform_ptr @60 - png_get_valid @61 - png_get_x_offset_microns @62 - png_get_x_offset_pixels @63 - png_get_x_pixels_per_meter @64 - png_get_y_offset_microns @65 - png_get_y_offset_pixels @66 - png_get_y_pixels_per_meter @67 - png_malloc @68 - png_memcpy_check @69 - png_memset_check @70 -; png_permit_empty_plte is deprecated - png_permit_empty_plte @71 - png_process_data @72 - png_progressive_combine_row @73 - png_read_end @74 - png_read_image @75 - png_read_info @76 -; png_read_init is deprecated - png_read_init @77 - png_read_png @78 - png_read_row @79 - png_read_rows @80 - png_read_update_info @81 - png_reset_zstream @82 - png_set_IHDR @83 - png_set_PLTE @84 - png_set_bKGD @85 - png_set_background @86 - png_set_bgr @87 - png_set_cHRM @88 - png_set_cHRM_fixed @89 - png_set_compression_buffer_size @90 - png_set_compression_level @91 - png_set_compression_mem_level @92 - png_set_compression_method @93 - png_set_compression_strategy @94 - png_set_compression_window_bits @95 - png_set_crc_action @96 - png_set_dither @97 - png_set_error_fn @98 - png_set_expand @99 - png_set_filler @100 - png_set_filter @101 - png_set_filter_heuristics @102 - png_set_flush @103 - png_set_gAMA @104 - png_set_gAMA_fixed @105 - png_set_gamma @106 -; png_set_gray_1_2_4_to_8 is deprecated - png_set_gray_1_2_4_to_8 @107 - png_set_gray_to_rgb @108 - png_set_hIST @109 - png_set_iCCP @110 - png_set_interlace_handling @111 - png_set_invert_alpha @112 - png_set_invert_mono @113 - png_set_keep_unknown_chunks @114 - png_set_oFFs @115 - png_set_pCAL @116 - png_set_pHYs @117 - png_set_packing @118 - png_set_packswap @119 - png_set_palette_to_rgb @120 - png_set_progressive_read_fn @121 - png_set_read_fn @122 - png_set_read_status_fn @123 - png_set_read_user_chunk_fn @124 - png_set_read_user_transform_fn @125 - png_set_rgb_to_gray @126 - png_set_rgb_to_gray_fixed @127 - png_set_rows @128 - png_set_sBIT @129 - png_set_sCAL @130 - png_set_sPLT @131 - png_set_sRGB @132 - png_set_sRGB_gAMA_and_cHRM @133 - png_set_shift @134 - png_set_sig_bytes @135 - png_set_strip_16 @136 - png_set_strip_alpha @137 - png_set_swap @138 - png_set_swap_alpha @139 - png_set_tIME @140 - png_set_tRNS @141 - png_set_tRNS_to_alpha @142 - png_set_text @143 - png_set_unknown_chunk_location @144 - png_set_unknown_chunks @145 - png_set_user_transform_info @146 - png_set_write_fn @147 - png_set_write_status_fn @148 - png_set_write_user_transform_fn @149 - png_sig_cmp @150 - png_start_read_image @151 - png_warning @152 - png_write_chunk @153 - png_write_chunk_data @154 - png_write_chunk_end @155 - png_write_chunk_start @156 - png_write_end @157 - png_write_flush @158 - png_write_image @159 - png_write_info @160 - png_write_info_before_PLTE @161 -; png_write_init is deprecated - png_write_init @162 - png_write_png @163 - png_write_row @164 - png_write_rows @165 -; png_read_init_2 and png_write_init_2 are deprecated. - png_read_init_2 @166 - png_write_init_2 @167 - png_access_version_number @168 -; png_sig_bytes @169 - png_libpng_ver @170 - png_init_io @171 - png_convert_to_rfc1123 @172 - png_set_invalid @173 -; Added at version 1.0.12 -; For compatibility with 1.0.7-1.0.11 -; png_info_init @174 - png_read_init_3 @175 - png_write_init_3 @176 - png_info_init_3 @177 - png_destroy_struct @178 -; Added at version 1.2.0 -; For use with PNG_USER_MEM_SUPPORTED - png_destroy_struct_2 @179 - png_create_read_struct_2 @180 - png_create_write_struct_2 @181 - png_malloc_default @182 - png_free_default @183 -; MNG features - png_permit_mng_features @184 -; MMX support - png_mmx_support @185 -; png_get_mmx_flagmask @186 - png_get_asm_flagmask @187 - png_get_asm_flags @188 -; png_get_mmx_bitdepth_threshold @189 -; png_get_mmx_rowbytes_threshold @190 - png_set_asm_flags @191 -; png_init_mmx_flags @192 -; Strip error numbers - png_set_strip_error_numbers @193 -; Added at version 1.2.2 - png_handle_as_unknown @194 -; Added at version 1.2.2 and deleted from 1.2.3 -; png_zalloc @195 -; png_zfree @196 -; Added at version 1.2.4 - png_malloc_warn @195 -; Added at version 1.2.6 - png_malloc_warn @195 - png_get_user_height_max @196 - png_get_user_width_max @197 - png_set_user_limits @198 -; Added at version 1.2.7 - png_set_add_alpha @199 -; Added at version 1.2.9 - png_get_uint_32 @200 - png_save_uint_32 @201 - png_get_uint_16 @202 - png_save_uint_16 @203 - png_get_int_32 @204 - png_save_int_32 @205 - png_get_uint_31 @206 - png_set_expand_gray_1_2_4_to_8 @207 diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/pngw32.rc b/irrlicht-1.6/source/Irrlicht/libpng/scripts/pngw32.rc deleted file mode 100644 index f6cb0f0ee..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/pngw32.rc +++ /dev/null @@ -1,112 +0,0 @@ -#define PNG_VERSION_INFO_ONLY - -#include <windows.h> -#include "../png.h" - -#define _QUOTE(x) # x -#define QUOTE(x) _QUOTE(x) - -#define PNG_LIBPNG_DLLFNAME "LIBPNG" - -/* Support deprecated PRIVATEBUILD macro */ -#if defined(PRIVATEBUILD) && !defined(PNG_USER_PRIVATEBUILD) -# define PNG_USER_PRIVATEBUILD PRIVATEBUILD -#endif - -#if defined(PNG_USER_DLLFNAME_POSTFIX) && !defined(PNG_USER_PRIVATEBUILD) -# error "PNG_USER_PRIVATEBUILD must be defined as a string describing the\ - custom changes made to the library." -#endif - -/* Prioritize PNG_USER_x over PNG_LIBPNG_x */ -#ifdef PNG_USER_DLLFNAME_POSTFIX -# undef PNG_LIBPNG_DLLFNAME_POSTFIX -# define PNG_LIBPNG_DLLFNAME_POSTFIX PNG_USER_DLLFNAME_POSTFIX -#endif - -#ifdef PNG_USER_VERSIONINFO_COMMENTS -# undef PNG_LIBPNG_VERSIONINFO_COMMENTS -# define PNG_LIBPNG_VERSIONINFO_COMMENTS PNG_USER_VERSIONINFO_COMMENTS -#endif - -#if defined(PNG_DEBUG) && (PNG_DEBUG > 0) -# define VS_DEBUG VS_FF_DEBUG -# ifndef PNG_LIBPNG_DLLFNAME_POSTFIX -# define PNG_LIBPNG_DLLFNAME_POSTFIX "D" -# endif /* PNG_LIBPNG_DLLFNAME_POSTFIX */ -# ifndef PNG_LIBPNG_VERSIONINFO_COMMENTS -# define PNG_LIBPNG_VERSIONINFO_COMMENTS "PNG_DEBUG=" QUOTE(PNG_DEBUG) -# endif /* PNG_LIBPNG_VERSIONINFO_COMMENTS */ -#else -# define VS_DEBUG 0 -# ifndef PNG_LIBPNG_DLLFNAME_POSTFIX -# define PNG_LIBPNG_DLLFNAME_POSTFIX -# endif /* PNG_LIBPNG_DLLFNAME_POSTFIX */ -#endif /* defined(DEBUG)... */ - -#ifdef PNG_USER_PRIVATEBUILD -# define VS_PRIVATEBUILD VS_FF_PRIVATEBUILD -#else -# define VS_PRIVATEBUILD 0 -#endif /* PNG_USER_PRIVATEBUILD */ - -#ifdef PNG_LIBPNG_SPECIALBUILD -# define VS_SPECIALBUILD VS_FF_SPECIALBUILD -#else -# define VS_SPECIALBUILD 0 -#endif /* PNG_LIBPNG_BUILD_SPECIAL */ - -#if ((PNG_LIBPNG_BUILD_BASE_TYPE & PNG_LIBPNG_RELEASE_STATUS_MASK) !=\ - PNG_LIBPNG_BUILD_STABLE) -# define VS_PRERELEASE VS_FF_PRERELEASE -# define VS_PATCHED 0 -#else -# define VS_PRERELEASE 0 -# if (PNG_LIBPNG_BUILD_BASE_TYPE & PNG_LIBPNG_BUILD_PATCHED) -# define VS_PATCHED VS_FF_PATCHED -# else -# define VS_PATCHED 0 -# endif -#endif - -VS_VERSION_INFO VERSIONINFO -FILEVERSION PNG_LIBPNG_VER_MAJOR, PNG_LIBPNG_VER_MINOR, PNG_LIBPNG_VER_RELEASE, PNG_LIBPNG_VER_BUILD -PRODUCTVERSION PNG_LIBPNG_VER_MAJOR, PNG_LIBPNG_VER_MINOR, PNG_LIBPNG_VER_RELEASE, PNG_LIBPNG_VER_BUILD -FILEFLAGSMASK VS_FFI_FILEFLAGSMASK -FILEFLAGS VS_DEBUG | VS_PRIVATEBUILD | VS_SPECIALBUILD | VS_PRERELEASE | VS_PATCHED -FILEOS VOS__WINDOWS32 -FILETYPE VFT_DLL -FILESUBTYPE VFT2_UNKNOWN -BEGIN - BLOCK "StringFileInfo" - BEGIN BLOCK "040904E4" /* Language type = U.S English(0x0409) and Character Set = Windows, Multilingual(0x04E4) */ - BEGIN -#ifdef PNG_LIBPNG_VERSIONINFO_COMMENTS - VALUE "Comments", PNG_LIBPNG_VERSIONINFO_COMMENTS "\000" -#endif /* PNG_LIBPNG_VERSIONINFO_COMMENTS */ -#ifdef PNG_USER_VERSIONINFO_COMPANYNAME - VALUE "CompanyName", PNG_USER_VERSIONINFO_COMPANYNAME "\000" -#endif /* PNG_USER_VERSIONINFO_COMPANYNAME */ - VALUE "FileDescription", "PNG image compression library\000" - VALUE "FileVersion", PNG_LIBPNG_VER_STRING "\000" - VALUE "InternalName", PNG_LIBPNG_DLLFNAME QUOTE(PNG_LIBPNG_VER_DLLNUM) PNG_LIBPNG_DLLFNAME_POSTFIX " (Windows 32 bit)\000" - VALUE "LegalCopyright", "\251 1998-2004 Glenn Randers-Pehrson et al.\000" -#ifdef PNG_USER_VERSIONINFO_LEGALTRADEMARKS - VALUE "LegalTrademarks", PNG_USER_VERSIONINFO_LEGALTRADEMARKS "\000" -#endif /* PNG_USER_VERSIONINFO_LEGALTRADEMARKS */ - VALUE "OriginalFilename", PNG_LIBPNG_DLLFNAME QUOTE(PNG_LIBPNG_VER_DLLNUM) PNG_LIBPNG_DLLFNAME_POSTFIX ".DLL\000" -#ifdef PNG_USER_PRIVATEBUILD - VALUE "PrivateBuild", PNG_USER_PRIVATEBUILD "\000" -#endif /* PNG_USER_PRIVATEBUILD */ - VALUE "ProductName", "LibPNG\000" - VALUE "ProductVersion", "1\000" -#ifdef PNG_LIBPNG_SPECIALBUILD - VALUE "SpecialBuild", PNG_LIBPNG_SPECIALBUILD "\000" -#endif /* PNG_LIBPNG_SPECIALBUILD */ - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0409, 0x04E4 - END -END diff --git a/irrlicht-1.6/source/Irrlicht/libpng/scripts/smakefile.ppc b/irrlicht-1.6/source/Irrlicht/libpng/scripts/smakefile.ppc deleted file mode 100644 index 2bc21787f..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng/scripts/smakefile.ppc +++ /dev/null @@ -1,30 +0,0 @@ -# Amiga powerUP (TM) Makefile -# makefile for libpng and SAS C V6.58/7.00 PPC compiler -# Copyright (C) 1998 by Andreas R. Kleinert -# For conditions of distribution and use, see copyright notice in png.h - -CC = scppc -CFLAGS = NOSTKCHK NOSINT OPTIMIZE OPTGO OPTPEEP OPTINLOCAL OPTINL IDIR /zlib \ - OPTLOOP OPTRDEP=8 OPTDEP=8 OPTCOMP=8 -LIBNAME = libpng.a -AR = ppc-amigaos-ar -AR_FLAGS = cr -RANLIB = ppc-amigaos-ranlib -LDFLAGS = -r -o -LDLIBS = ../zlib/libzip.a LIB:scppc.a -LN = ppc-amigaos-ld -RM = delete quiet -MKDIR = makedir - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o pngread.o \ -pngerror.o pngpread.o pngwrite.o pngrtran.o pngwtran.o pngrio.o pngwio.o pngmem.o - -all: $(LIBNAME) pngtest - -$(LIBNAME): $(OBJS) - $(AR) $(AR_FLAGS) $@ $(OBJS) - $(RANLIB) $@ - -pngtest: pngtest.o $(LIBNAME) - $(LN) $(LDFLAGS) pngtest LIB:c_ppc.o pngtest.o $(LIBNAME) $(LDLIBS) \ -LIB:end.o diff --git a/irrlicht-1.6/source/Irrlicht/libpng_osx/example.c b/irrlicht-1.6/source/Irrlicht/libpng_osx/example.c deleted file mode 100644 index 08158731a..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng_osx/example.c +++ /dev/null @@ -1,814 +0,0 @@ - -#if 0 /* in case someone actually tries to compile this */ - -/* example.c - an example of using libpng - * Last changed in libpng 1.2.1 December 7, 2001. - * This file has been placed in the public domain by the authors. - * Maintained 1998-2007 Glenn Randers-Pehrson - * Maintained 1996, 1997 Andreas Dilger) - * Written 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -/* This is an example of how to use libpng to read and write PNG files. - * The file libpng.txt is much more verbose then this. If you have not - * read it, do so first. This was designed to be a starting point of an - * implementation. This is not officially part of libpng, is hereby placed - * in the public domain, and therefore does not require a copyright notice. - * - * This file does not currently compile, because it is missing certain - * parts, like allocating memory to hold an image. You will have to - * supply these parts to get it to compile. For an example of a minimal - * working PNG reader/writer, see pngtest.c, included in this distribution; - * see also the programs in the contrib directory. - */ - -#include "png.h" - - /* The png_jmpbuf() macro, used in error handling, became available in - * libpng version 1.0.6. If you want to be able to run your code with older - * versions of libpng, you must define the macro yourself (but only if it - * is not already defined by libpng!). - */ - -#ifndef png_jmpbuf -# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) -#endif - -/* Check to see if a file is a PNG file using png_sig_cmp(). png_sig_cmp() - * returns zero if the image is a PNG and nonzero if it isn't a PNG. - * - * The function check_if_png() shown here, but not used, returns nonzero (true) - * if the file can be opened and is a PNG, 0 (false) otherwise. - * - * If this call is successful, and you are going to keep the file open, - * you should call png_set_sig_bytes(png_ptr, PNG_BYTES_TO_CHECK); once - * you have created the png_ptr, so that libpng knows your application - * has read that many bytes from the start of the file. Make sure you - * don't call png_set_sig_bytes() with more than 8 bytes read or give it - * an incorrect number of bytes read, or you will either have read too - * many bytes (your fault), or you are telling libpng to read the wrong - * number of magic bytes (also your fault). - * - * Many applications already read the first 2 or 4 bytes from the start - * of the image to determine the file type, so it would be easiest just - * to pass the bytes to png_sig_cmp() or even skip that if you know - * you have a PNG file, and call png_set_sig_bytes(). - */ -#define PNG_BYTES_TO_CHECK 4 -int check_if_png(char *file_name, FILE **fp) -{ - char buf[PNG_BYTES_TO_CHECK]; - - /* Open the prospective PNG file. */ - if ((*fp = fopen(file_name, "rb")) == NULL) - return 0; - - /* Read in some of the signature bytes */ - if (fread(buf, 1, PNG_BYTES_TO_CHECK, *fp) != PNG_BYTES_TO_CHECK) - return 0; - - /* Compare the first PNG_BYTES_TO_CHECK bytes of the signature. - Return nonzero (true) if they match */ - - return(!png_sig_cmp(buf, (png_size_t)0, PNG_BYTES_TO_CHECK)); -} - -/* Read a PNG file. You may want to return an error code if the read - * fails (depending upon the failure). There are two "prototypes" given - * here - one where we are given the filename, and we need to open the - * file, and the other where we are given an open file (possibly with - * some or all of the magic bytes read - see comments above). - */ -#ifdef open_file /* prototype 1 */ -void read_png(char *file_name) /* We need to open the file */ -{ - png_structp png_ptr; - png_infop info_ptr; - unsigned int sig_read = 0; - png_uint_32 width, height; - int bit_depth, color_type, interlace_type; - FILE *fp; - - if ((fp = fopen(file_name, "rb")) == NULL) - return (ERROR); -#else no_open_file /* prototype 2 */ -void read_png(FILE *fp, unsigned int sig_read) /* file is already open */ -{ - png_structp png_ptr; - png_infop info_ptr; - png_uint_32 width, height; - int bit_depth, color_type, interlace_type; -#endif no_open_file /* only use one prototype! */ - - /* Create and initialize the png_struct with the desired error handler - * functions. If you want to use the default stderr and longjump method, - * you can supply NULL for the last three parameters. We also supply the - * the compiler header file version, so that we know if the application - * was compiled with a compatible version of the library. REQUIRED - */ - png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, - png_voidp user_error_ptr, user_error_fn, user_warning_fn); - - if (png_ptr == NULL) - { - fclose(fp); - return (ERROR); - } - - /* Allocate/initialize the memory for image information. REQUIRED. */ - info_ptr = png_create_info_struct(png_ptr); - if (info_ptr == NULL) - { - fclose(fp); - png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL); - return (ERROR); - } - - /* Set error handling if you are using the setjmp/longjmp method (this is - * the normal method of doing things with libpng). REQUIRED unless you - * set up your own error handlers in the png_create_read_struct() earlier. - */ - - if (setjmp(png_jmpbuf(png_ptr))) - { - /* Free all of the memory associated with the png_ptr and info_ptr */ - png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL); - fclose(fp); - /* If we get here, we had a problem reading the file */ - return (ERROR); - } - - /* One of the following I/O initialization methods is REQUIRED */ -#ifdef streams /* PNG file I/O method 1 */ - /* Set up the input control if you are using standard C streams */ - png_init_io(png_ptr, fp); - -#else no_streams /* PNG file I/O method 2 */ - /* If you are using replacement read functions, instead of calling - * png_init_io() here you would call: - */ - png_set_read_fn(png_ptr, (void *)user_io_ptr, user_read_fn); - /* where user_io_ptr is a structure you want available to the callbacks */ -#endif no_streams /* Use only one I/O method! */ - - /* If we have already read some of the signature */ - png_set_sig_bytes(png_ptr, sig_read); - -#ifdef hilevel - /* - * If you have enough memory to read in the entire image at once, - * and you need to specify only transforms that can be controlled - * with one of the PNG_TRANSFORM_* bits (this presently excludes - * dithering, filling, setting background, and doing gamma - * adjustment), then you can read the entire image (including - * pixels) into the info structure with this call: - */ - png_read_png(png_ptr, info_ptr, png_transforms, png_voidp_NULL); -#else - /* OK, you're doing it the hard way, with the lower-level functions */ - - /* The call to png_read_info() gives us all of the information from the - * PNG file before the first IDAT (image data chunk). REQUIRED - */ - png_read_info(png_ptr, info_ptr); - - png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, - &interlace_type, int_p_NULL, int_p_NULL); - -/* Set up the data transformations you want. Note that these are all - * optional. Only call them if you want/need them. Many of the - * transformations only work on specific types of images, and many - * are mutually exclusive. - */ - - /* tell libpng to strip 16 bit/color files down to 8 bits/color */ - png_set_strip_16(png_ptr); - - /* Strip alpha bytes from the input data without combining with the - * background (not recommended). - */ - png_set_strip_alpha(png_ptr); - - /* Extract multiple pixels with bit depths of 1, 2, and 4 from a single - * byte into separate bytes (useful for paletted and grayscale images). - */ - png_set_packing(png_ptr); - - /* Change the order of packed pixels to least significant bit first - * (not useful if you are using png_set_packing). */ - png_set_packswap(png_ptr); - - /* Expand paletted colors into true RGB triplets */ - if (color_type == PNG_COLOR_TYPE_PALETTE) - png_set_palette_to_rgb(png_ptr); - - /* Expand grayscale images to the full 8 bits from 1, 2, or 4 bits/pixel */ - if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) - png_set_gray_1_2_4_to_8(png_ptr); - - /* Expand paletted or RGB images with transparency to full alpha channels - * so the data will be available as RGBA quartets. - */ - if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) - png_set_tRNS_to_alpha(png_ptr); - - /* Set the background color to draw transparent and alpha images over. - * It is possible to set the red, green, and blue components directly - * for paletted images instead of supplying a palette index. Note that - * even if the PNG file supplies a background, you are not required to - * use it - you should use the (solid) application background if it has one. - */ - - png_color_16 my_background, *image_background; - - if (png_get_bKGD(png_ptr, info_ptr, &image_background)) - png_set_background(png_ptr, image_background, - PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); - else - png_set_background(png_ptr, &my_background, - PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); - - /* Some suggestions as to how to get a screen gamma value */ - - /* Note that screen gamma is the display_exponent, which includes - * the CRT_exponent and any correction for viewing conditions */ - if (/* We have a user-defined screen gamma value */) - { - screen_gamma = user-defined screen_gamma; - } - /* This is one way that applications share the same screen gamma value */ - else if ((gamma_str = getenv("SCREEN_GAMMA")) != NULL) - { - screen_gamma = atof(gamma_str); - } - /* If we don't have another value */ - else - { - screen_gamma = 2.2; /* A good guess for a PC monitors in a dimly - lit room */ - screen_gamma = 1.7 or 1.0; /* A good guess for Mac systems */ - } - - /* Tell libpng to handle the gamma conversion for you. The final call - * is a good guess for PC generated images, but it should be configurable - * by the user at run time by the user. It is strongly suggested that - * your application support gamma correction. - */ - - int intent; - - if (png_get_sRGB(png_ptr, info_ptr, &intent)) - png_set_gamma(png_ptr, screen_gamma, 0.45455); - else - { - double image_gamma; - if (png_get_gAMA(png_ptr, info_ptr, &image_gamma)) - png_set_gamma(png_ptr, screen_gamma, image_gamma); - else - png_set_gamma(png_ptr, screen_gamma, 0.45455); - } - - /* Dither RGB files down to 8 bit palette or reduce palettes - * to the number of colors available on your screen. - */ - if (color_type & PNG_COLOR_MASK_COLOR) - { - int num_palette; - png_colorp palette; - - /* This reduces the image to the application supplied palette */ - if (/* we have our own palette */) - { - /* An array of colors to which the image should be dithered */ - png_color std_color_cube[MAX_SCREEN_COLORS]; - - png_set_dither(png_ptr, std_color_cube, MAX_SCREEN_COLORS, - MAX_SCREEN_COLORS, png_uint_16p_NULL, 0); - } - /* This reduces the image to the palette supplied in the file */ - else if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette)) - { - png_uint_16p histogram = NULL; - - png_get_hIST(png_ptr, info_ptr, &histogram); - - png_set_dither(png_ptr, palette, num_palette, - max_screen_colors, histogram, 0); - } - } - - /* invert monochrome files to have 0 as white and 1 as black */ - png_set_invert_mono(png_ptr); - - /* If you want to shift the pixel values from the range [0,255] or - * [0,65535] to the original [0,7] or [0,31], or whatever range the - * colors were originally in: - */ - if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT)) - { - png_color_8p sig_bit; - - png_get_sBIT(png_ptr, info_ptr, &sig_bit); - png_set_shift(png_ptr, sig_bit); - } - - /* flip the RGB pixels to BGR (or RGBA to BGRA) */ - if (color_type & PNG_COLOR_MASK_COLOR) - png_set_bgr(png_ptr); - - /* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */ - png_set_swap_alpha(png_ptr); - - /* swap bytes of 16 bit files to least significant byte first */ - png_set_swap(png_ptr); - - /* Add filler (or alpha) byte (before/after each RGB triplet) */ - png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER); - - /* Turn on interlace handling. REQUIRED if you are not using - * png_read_image(). To see how to handle interlacing passes, - * see the png_read_row() method below: - */ - number_passes = png_set_interlace_handling(png_ptr); - - /* Optional call to gamma correct and add the background to the palette - * and update info structure. REQUIRED if you are expecting libpng to - * update the palette for you (ie you selected such a transform above). - */ - png_read_update_info(png_ptr, info_ptr); - - /* Allocate the memory to hold the image using the fields of info_ptr. */ - - /* The easiest way to read the image: */ - png_bytep row_pointers[height]; - - for (row = 0; row < height; row++) - { - row_pointers[row] = png_malloc(png_ptr, png_get_rowbytes(png_ptr, - info_ptr)); - } - - /* Now it's time to read the image. One of these methods is REQUIRED */ -#ifdef entire /* Read the entire image in one go */ - png_read_image(png_ptr, row_pointers); - -#else no_entire /* Read the image one or more scanlines at a time */ - /* The other way to read images - deal with interlacing: */ - - for (pass = 0; pass < number_passes; pass++) - { -#ifdef single /* Read the image a single row at a time */ - for (y = 0; y < height; y++) - { - png_read_rows(png_ptr, &row_pointers[y], png_bytepp_NULL, 1); - } - -#else no_single /* Read the image several rows at a time */ - for (y = 0; y < height; y += number_of_rows) - { -#ifdef sparkle /* Read the image using the "sparkle" effect. */ - png_read_rows(png_ptr, &row_pointers[y], png_bytepp_NULL, - number_of_rows); -#else no_sparkle /* Read the image using the "rectangle" effect */ - png_read_rows(png_ptr, png_bytepp_NULL, &row_pointers[y], - number_of_rows); -#endif no_sparkle /* use only one of these two methods */ - } - - /* if you want to display the image after every pass, do - so here */ -#endif no_single /* use only one of these two methods */ - } -#endif no_entire /* use only one of these two methods */ - - /* read rest of file, and get additional chunks in info_ptr - REQUIRED */ - png_read_end(png_ptr, info_ptr); -#endif hilevel - - /* At this point you have read the entire image */ - - /* clean up after the read, and free any memory allocated - REQUIRED */ - png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL); - - /* close the file */ - fclose(fp); - - /* that's it */ - return (OK); -} - -/* progressively read a file */ - -int -initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr) -{ - /* Create and initialize the png_struct with the desired error handler - * functions. If you want to use the default stderr and longjump method, - * you can supply NULL for the last three parameters. We also check that - * the library version is compatible in case we are using dynamically - * linked libraries. - */ - *png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, - png_voidp user_error_ptr, user_error_fn, user_warning_fn); - - if (*png_ptr == NULL) - { - *info_ptr = NULL; - return (ERROR); - } - - *info_ptr = png_create_info_struct(png_ptr); - - if (*info_ptr == NULL) - { - png_destroy_read_struct(png_ptr, info_ptr, png_infopp_NULL); - return (ERROR); - } - - if (setjmp(png_jmpbuf((*png_ptr)))) - { - png_destroy_read_struct(png_ptr, info_ptr, png_infopp_NULL); - return (ERROR); - } - - /* This one's new. You will need to provide all three - * function callbacks, even if you aren't using them all. - * If you aren't using all functions, you can specify NULL - * parameters. Even when all three functions are NULL, - * you need to call png_set_progressive_read_fn(). - * These functions shouldn't be dependent on global or - * static variables if you are decoding several images - * simultaneously. You should store stream specific data - * in a separate struct, given as the second parameter, - * and retrieve the pointer from inside the callbacks using - * the function png_get_progressive_ptr(png_ptr). - */ - png_set_progressive_read_fn(*png_ptr, (void *)stream_data, - info_callback, row_callback, end_callback); - - return (OK); -} - -int -process_data(png_structp *png_ptr, png_infop *info_ptr, - png_bytep buffer, png_uint_32 length) -{ - if (setjmp(png_jmpbuf((*png_ptr)))) - { - /* Free the png_ptr and info_ptr memory on error */ - png_destroy_read_struct(png_ptr, info_ptr, png_infopp_NULL); - return (ERROR); - } - - /* This one's new also. Simply give it chunks of data as - * they arrive from the data stream (in order, of course). - * On Segmented machines, don't give it any more than 64K. - * The library seems to run fine with sizes of 4K, although - * you can give it much less if necessary (I assume you can - * give it chunks of 1 byte, but I haven't tried with less - * than 256 bytes yet). When this function returns, you may - * want to display any rows that were generated in the row - * callback, if you aren't already displaying them there. - */ - png_process_data(*png_ptr, *info_ptr, buffer, length); - return (OK); -} - -info_callback(png_structp png_ptr, png_infop info) -{ -/* do any setup here, including setting any of the transformations - * mentioned in the Reading PNG files section. For now, you _must_ - * call either png_start_read_image() or png_read_update_info() - * after all the transformations are set (even if you don't set - * any). You may start getting rows before png_process_data() - * returns, so this is your last chance to prepare for that. - */ -} - -row_callback(png_structp png_ptr, png_bytep new_row, - png_uint_32 row_num, int pass) -{ -/* - * This function is called for every row in the image. If the - * image is interlaced, and you turned on the interlace handler, - * this function will be called for every row in every pass. - * - * In this function you will receive a pointer to new row data from - * libpng called new_row that is to replace a corresponding row (of - * the same data format) in a buffer allocated by your application. - * - * The new row data pointer new_row may be NULL, indicating there is - * no new data to be replaced (in cases of interlace loading). - * - * If new_row is not NULL then you need to call - * png_progressive_combine_row() to replace the corresponding row as - * shown below: - */ - /* Check if row_num is in bounds. */ - if((row_num >= 0) && (row_num < height)) - { - /* Get pointer to corresponding row in our - * PNG read buffer. - */ - png_bytep old_row = ((png_bytep *)our_data)[row_num]; - - /* If both rows are allocated then copy the new row - * data to the corresponding row data. - */ - if((old_row != NULL) && (new_row != NULL)) - png_progressive_combine_row(png_ptr, old_row, new_row); - } -/* - * The rows and passes are called in order, so you don't really - * need the row_num and pass, but I'm supplying them because it - * may make your life easier. - * - * For the non-NULL rows of interlaced images, you must call - * png_progressive_combine_row() passing in the new row and the - * old row, as demonstrated above. You can call this function for - * NULL rows (it will just return) and for non-interlaced images - * (it just does the png_memcpy for you) if it will make the code - * easier. Thus, you can just do this for all cases: - */ - - png_progressive_combine_row(png_ptr, old_row, new_row); - -/* where old_row is what was displayed for previous rows. Note - * that the first pass (pass == 0 really) will completely cover - * the old row, so the rows do not have to be initialized. After - * the first pass (and only for interlaced images), you will have - * to pass the current row as new_row, and the function will combine - * the old row and the new row. - */ -} - -end_callback(png_structp png_ptr, png_infop info) -{ -/* this function is called when the whole image has been read, - * including any chunks after the image (up to and including - * the IEND). You will usually have the same info chunk as you - * had in the header, although some data may have been added - * to the comments and time fields. - * - * Most people won't do much here, perhaps setting a flag that - * marks the image as finished. - */ -} - -/* write a png file */ -void write_png(char *file_name /* , ... other image information ... */) -{ - FILE *fp; - png_structp png_ptr; - png_infop info_ptr; - png_colorp palette; - - /* open the file */ - fp = fopen(file_name, "wb"); - if (fp == NULL) - return (ERROR); - - /* Create and initialize the png_struct with the desired error handler - * functions. If you want to use the default stderr and longjump method, - * you can supply NULL for the last three parameters. We also check that - * the library version is compatible with the one used at compile time, - * in case we are using dynamically linked libraries. REQUIRED. - */ - png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, - png_voidp user_error_ptr, user_error_fn, user_warning_fn); - - if (png_ptr == NULL) - { - fclose(fp); - return (ERROR); - } - - /* Allocate/initialize the image information data. REQUIRED */ - info_ptr = png_create_info_struct(png_ptr); - if (info_ptr == NULL) - { - fclose(fp); - png_destroy_write_struct(&png_ptr, png_infopp_NULL); - return (ERROR); - } - - /* Set error handling. REQUIRED if you aren't supplying your own - * error handling functions in the png_create_write_struct() call. - */ - if (setjmp(png_jmpbuf(png_ptr))) - { - /* If we get here, we had a problem reading the file */ - fclose(fp); - png_destroy_write_struct(&png_ptr, &info_ptr); - return (ERROR); - } - - /* One of the following I/O initialization functions is REQUIRED */ -#ifdef streams /* I/O initialization method 1 */ - /* set up the output control if you are using standard C streams */ - png_init_io(png_ptr, fp); -#else no_streams /* I/O initialization method 2 */ - /* If you are using replacement read functions, instead of calling - * png_init_io() here you would call */ - png_set_write_fn(png_ptr, (void *)user_io_ptr, user_write_fn, - user_IO_flush_function); - /* where user_io_ptr is a structure you want available to the callbacks */ -#endif no_streams /* only use one initialization method */ - -#ifdef hilevel - /* This is the easy way. Use it if you already have all the - * image info living info in the structure. You could "|" many - * PNG_TRANSFORM flags into the png_transforms integer here. - */ - png_write_png(png_ptr, info_ptr, png_transforms, png_voidp_NULL); -#else - /* This is the hard way */ - - /* Set the image information here. Width and height are up to 2^31, - * bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on - * the color_type selected. color_type is one of PNG_COLOR_TYPE_GRAY, - * PNG_COLOR_TYPE_GRAY_ALPHA, PNG_COLOR_TYPE_PALETTE, PNG_COLOR_TYPE_RGB, - * or PNG_COLOR_TYPE_RGB_ALPHA. interlace is either PNG_INTERLACE_NONE or - * PNG_INTERLACE_ADAM7, and the compression_type and filter_type MUST - * currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE. REQUIRED - */ - png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, PNG_COLOR_TYPE_???, - PNG_INTERLACE_????, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); - - /* set the palette if there is one. REQUIRED for indexed-color images */ - palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH - * png_sizeof (png_color)); - /* ... set palette colors ... */ - png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH); - /* You must not free palette here, because png_set_PLTE only makes a link to - the palette that you malloced. Wait until you are about to destroy - the png structure. */ - - /* optional significant bit chunk */ - /* if we are dealing with a grayscale image then */ - sig_bit.gray = true_bit_depth; - /* otherwise, if we are dealing with a color image then */ - sig_bit.red = true_red_bit_depth; - sig_bit.green = true_green_bit_depth; - sig_bit.blue = true_blue_bit_depth; - /* if the image has an alpha channel then */ - sig_bit.alpha = true_alpha_bit_depth; - png_set_sBIT(png_ptr, info_ptr, sig_bit); - - - /* Optional gamma chunk is strongly suggested if you have any guess - * as to the correct gamma of the image. - */ - png_set_gAMA(png_ptr, info_ptr, gamma); - - /* Optionally write comments into the image */ - text_ptr[0].key = "Title"; - text_ptr[0].text = "Mona Lisa"; - text_ptr[0].compression = PNG_TEXT_COMPRESSION_NONE; - text_ptr[1].key = "Author"; - text_ptr[1].text = "Leonardo DaVinci"; - text_ptr[1].compression = PNG_TEXT_COMPRESSION_NONE; - text_ptr[2].key = "Description"; - text_ptr[2].text = "<long text>"; - text_ptr[2].compression = PNG_TEXT_COMPRESSION_zTXt; -#ifdef PNG_iTXt_SUPPORTED - text_ptr[0].lang = NULL; - text_ptr[1].lang = NULL; - text_ptr[2].lang = NULL; -#endif - png_set_text(png_ptr, info_ptr, text_ptr, 3); - - /* other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs, */ - /* note that if sRGB is present the gAMA and cHRM chunks must be ignored - * on read and must be written in accordance with the sRGB profile */ - - /* Write the file header information. REQUIRED */ - png_write_info(png_ptr, info_ptr); - - /* If you want, you can write the info in two steps, in case you need to - * write your private chunk ahead of PLTE: - * - * png_write_info_before_PLTE(write_ptr, write_info_ptr); - * write_my_chunk(); - * png_write_info(png_ptr, info_ptr); - * - * However, given the level of known- and unknown-chunk support in 1.1.0 - * and up, this should no longer be necessary. - */ - - /* Once we write out the header, the compression type on the text - * chunks gets changed to PNG_TEXT_COMPRESSION_NONE_WR or - * PNG_TEXT_COMPRESSION_zTXt_WR, so it doesn't get written out again - * at the end. - */ - - /* set up the transformations you want. Note that these are - * all optional. Only call them if you want them. - */ - - /* invert monochrome pixels */ - png_set_invert_mono(png_ptr); - - /* Shift the pixels up to a legal bit depth and fill in - * as appropriate to correctly scale the image. - */ - png_set_shift(png_ptr, &sig_bit); - - /* pack pixels into bytes */ - png_set_packing(png_ptr); - - /* swap location of alpha bytes from ARGB to RGBA */ - png_set_swap_alpha(png_ptr); - - /* Get rid of filler (OR ALPHA) bytes, pack XRGB/RGBX/ARGB/RGBA into - * RGB (4 channels -> 3 channels). The second parameter is not used. - */ - png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); - - /* flip BGR pixels to RGB */ - png_set_bgr(png_ptr); - - /* swap bytes of 16-bit files to most significant byte first */ - png_set_swap(png_ptr); - - /* swap bits of 1, 2, 4 bit packed pixel formats */ - png_set_packswap(png_ptr); - - /* turn on interlace handling if you are not using png_write_image() */ - if (interlacing) - number_passes = png_set_interlace_handling(png_ptr); - else - number_passes = 1; - - /* The easiest way to write the image (you may have a different memory - * layout, however, so choose what fits your needs best). You need to - * use the first method if you aren't handling interlacing yourself. - */ - png_uint_32 k, height, width; - png_byte image[height][width*bytes_per_pixel]; - png_bytep row_pointers[height]; - - if (height > PNG_UINT_32_MAX/png_sizeof(png_bytep)) - png_error (png_ptr, "Image is too tall to process in memory"); - - for (k = 0; k < height; k++) - row_pointers[k] = image + k*width*bytes_per_pixel; - - /* One of the following output methods is REQUIRED */ -#ifdef entire /* write out the entire image data in one call */ - png_write_image(png_ptr, row_pointers); - - /* the other way to write the image - deal with interlacing */ - -#else no_entire /* write out the image data by one or more scanlines */ - /* The number of passes is either 1 for non-interlaced images, - * or 7 for interlaced images. - */ - for (pass = 0; pass < number_passes; pass++) - { - /* Write a few rows at a time. */ - png_write_rows(png_ptr, &row_pointers[first_row], number_of_rows); - - /* If you are only writing one row at a time, this works */ - for (y = 0; y < height; y++) - { - png_write_rows(png_ptr, &row_pointers[y], 1); - } - } -#endif no_entire /* use only one output method */ - - /* You can write optional chunks like tEXt, zTXt, and tIME at the end - * as well. Shouldn't be necessary in 1.1.0 and up as all the public - * chunks are supported and you can use png_set_unknown_chunks() to - * register unknown chunks into the info structure to be written out. - */ - - /* It is REQUIRED to call this to finish writing the rest of the file */ - png_write_end(png_ptr, info_ptr); -#endif hilevel - - /* If you png_malloced a palette, free it here (don't free info_ptr->palette, - as recommended in versions 1.0.5m and earlier of this example; if - libpng mallocs info_ptr->palette, libpng will free it). If you - allocated it with malloc() instead of png_malloc(), use free() instead - of png_free(). */ - png_free(png_ptr, palette); - palette=NULL; - - /* Similarly, if you png_malloced any data that you passed in with - png_set_something(), such as a hist or trans array, free it here, - when you can be sure that libpng is through with it. */ - png_free(png_ptr, trans); - trans=NULL; - - /* clean up after the write, and free any memory allocated */ - png_destroy_write_struct(&png_ptr, &info_ptr); - - /* close the file */ - fclose(fp); - - /* that's it */ - return (OK); -} - -#endif /* if 0 */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng_osx/png.c b/irrlicht-1.6/source/Irrlicht/libpng_osx/png.c deleted file mode 100644 index 76be016d9..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng_osx/png.c +++ /dev/null @@ -1,809 +0,0 @@ - -/* png.c - location for general purpose libpng functions - * - * Last changed in libpng 1.2.15 January 5, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -#define PNG_INTERNAL -#define PNG_NO_EXTERN -#include "png.h" - -/* Generate a compiler error if there is an old png.h in the search path. */ -typedef version_1_2_16 Your_png_h_is_not_version_1_2_16; - -/* Version information for C files. This had better match the version - * string defined in png.h. */ - -#ifdef PNG_USE_GLOBAL_ARRAYS -/* png_libpng_ver was changed to a function in version 1.0.5c */ -const char png_libpng_ver[18] = PNG_LIBPNG_VER_STRING; - -#ifdef PNG_READ_SUPPORTED - -/* png_sig was changed to a function in version 1.0.5c */ -/* Place to hold the signature string for a PNG file. */ -const png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10}; -#endif /* PNG_READ_SUPPORTED */ - -/* Invoke global declarations for constant strings for known chunk types */ -PNG_IHDR; -PNG_IDAT; -PNG_IEND; -PNG_PLTE; -PNG_bKGD; -PNG_cHRM; -PNG_gAMA; -PNG_hIST; -PNG_iCCP; -PNG_iTXt; -PNG_oFFs; -PNG_pCAL; -PNG_sCAL; -PNG_pHYs; -PNG_sBIT; -PNG_sPLT; -PNG_sRGB; -PNG_tEXt; -PNG_tIME; -PNG_tRNS; -PNG_zTXt; - -#ifdef PNG_READ_SUPPORTED -/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - -/* start of interlace block */ -const int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; - -/* offset to next interlace block */ -const int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; - -/* start of interlace block in the y direction */ -const int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; - -/* offset to next interlace block in the y direction */ -const int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; - -/* width of interlace block (used in assembler routines only) */ -#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW -const int FARDATA png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; -#endif - -/* Height of interlace block. This is not currently used - if you need - * it, uncomment it here and in png.h -const int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1}; -*/ - -/* Mask to determine which pixels are valid in a pass */ -const int FARDATA png_pass_mask[] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff}; - -/* Mask to determine which pixels to overwrite while displaying */ -const int FARDATA png_pass_dsp_mask[] - = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; - -#endif /* PNG_READ_SUPPORTED */ -#endif /* PNG_USE_GLOBAL_ARRAYS */ - -/* Tells libpng that we have already handled the first "num_bytes" bytes - * of the PNG file signature. If the PNG data is embedded into another - * stream we can set num_bytes = 8 so that libpng will not attempt to read - * or write any of the magic bytes before it starts on the IHDR. - */ - -#ifdef PNG_READ_SUPPORTED -void PNGAPI -png_set_sig_bytes(png_structp png_ptr, int num_bytes) -{ - if(png_ptr == NULL) return; - png_debug(1, "in png_set_sig_bytes\n"); - if (num_bytes > 8) - png_error(png_ptr, "Too many bytes for PNG signature."); - - png_ptr->sig_bytes = (png_byte)(num_bytes < 0 ? 0 : num_bytes); -} - -/* Checks whether the supplied bytes match the PNG signature. We allow - * checking less than the full 8-byte signature so that those apps that - * already read the first few bytes of a file to determine the file type - * can simply check the remaining bytes for extra assurance. Returns - * an integer less than, equal to, or greater than zero if sig is found, - * respectively, to be less than, to match, or be greater than the correct - * PNG signature (this is the same behaviour as strcmp, memcmp, etc). - */ -int PNGAPI -png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check) -{ - png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10}; - if (num_to_check > 8) - num_to_check = 8; - else if (num_to_check < 1) - return (-1); - - if (start > 7) - return (-1); - - if (start + num_to_check > 8) - num_to_check = 8 - start; - - return ((int)(png_memcmp(&sig[start], &png_signature[start], num_to_check))); -} - -#if defined(PNG_1_0_X) || defined(PNG_1_2_X) -/* (Obsolete) function to check signature bytes. It does not allow one - * to check a partial signature. This function might be removed in the - * future - use png_sig_cmp(). Returns true (nonzero) if the file is a PNG. - */ -int PNGAPI -png_check_sig(png_bytep sig, int num) -{ - return ((int)!png_sig_cmp(sig, (png_size_t)0, (png_size_t)num)); -} -#endif -#endif /* PNG_READ_SUPPORTED */ - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) -/* Function to allocate memory for zlib and clear it to 0. */ -#ifdef PNG_1_0_X -voidpf PNGAPI -#else -voidpf /* private */ -#endif -png_zalloc(voidpf png_ptr, uInt items, uInt size) -{ - png_voidp ptr; - png_structp p=(png_structp)png_ptr; - png_uint_32 save_flags=p->flags; - png_uint_32 num_bytes; - - if(png_ptr == NULL) return (NULL); - if (items > PNG_UINT_32_MAX/size) - { - png_warning (p, "Potential overflow in png_zalloc()"); - return (NULL); - } - num_bytes = (png_uint_32)items * size; - - p->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK; - ptr = (png_voidp)png_malloc((png_structp)png_ptr, num_bytes); - p->flags=save_flags; - -#if defined(PNG_1_0_X) && !defined(PNG_NO_ZALLOC_ZERO) - if (ptr == NULL) - return ((voidpf)ptr); - - if (num_bytes > (png_uint_32)0x8000L) - { - png_memset(ptr, 0, (png_size_t)0x8000L); - png_memset((png_bytep)ptr + (png_size_t)0x8000L, 0, - (png_size_t)(num_bytes - (png_uint_32)0x8000L)); - } - else - { - png_memset(ptr, 0, (png_size_t)num_bytes); - } -#endif - return ((voidpf)ptr); -} - -/* function to free memory for zlib */ -#ifdef PNG_1_0_X -void PNGAPI -#else -void /* private */ -#endif -png_zfree(voidpf png_ptr, voidpf ptr) -{ - png_free((png_structp)png_ptr, (png_voidp)ptr); -} - -/* Reset the CRC variable to 32 bits of 1's. Care must be taken - * in case CRC is > 32 bits to leave the top bits 0. - */ -void /* PRIVATE */ -png_reset_crc(png_structp png_ptr) -{ - png_ptr->crc = crc32(0, Z_NULL, 0); -} - -/* Calculate the CRC over a section of data. We can only pass as - * much data to this routine as the largest single buffer size. We - * also check that this data will actually be used before going to the - * trouble of calculating it. - */ -void /* PRIVATE */ -png_calculate_crc(png_structp png_ptr, png_bytep ptr, png_size_t length) -{ - int need_crc = 1; - - if (png_ptr->chunk_name[0] & 0x20) /* ancillary */ - { - if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) == - (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN)) - need_crc = 0; - } - else /* critical */ - { - if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE) - need_crc = 0; - } - - if (need_crc) - png_ptr->crc = crc32(png_ptr->crc, ptr, (uInt)length); -} - -/* Allocate the memory for an info_struct for the application. We don't - * really need the png_ptr, but it could potentially be useful in the - * future. This should be used in favour of malloc(png_sizeof(png_info)) - * and png_info_init() so that applications that want to use a shared - * libpng don't have to be recompiled if png_info changes size. - */ -png_infop PNGAPI -png_create_info_struct(png_structp png_ptr) -{ - png_infop info_ptr; - - png_debug(1, "in png_create_info_struct\n"); - if(png_ptr == NULL) return (NULL); -#ifdef PNG_USER_MEM_SUPPORTED - info_ptr = (png_infop)png_create_struct_2(PNG_STRUCT_INFO, - png_ptr->malloc_fn, png_ptr->mem_ptr); -#else - info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO); -#endif - if (info_ptr != NULL) - png_info_init_3(&info_ptr, png_sizeof(png_info)); - - return (info_ptr); -} - -/* This function frees the memory associated with a single info struct. - * Normally, one would use either png_destroy_read_struct() or - * png_destroy_write_struct() to free an info struct, but this may be - * useful for some applications. - */ -void PNGAPI -png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr) -{ - png_infop info_ptr = NULL; - if(png_ptr == NULL) return; - - png_debug(1, "in png_destroy_info_struct\n"); - if (info_ptr_ptr != NULL) - info_ptr = *info_ptr_ptr; - - if (info_ptr != NULL) - { - png_info_destroy(png_ptr, info_ptr); - -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)info_ptr, png_ptr->free_fn, - png_ptr->mem_ptr); -#else - png_destroy_struct((png_voidp)info_ptr); -#endif - *info_ptr_ptr = NULL; - } -} - -/* Initialize the info structure. This is now an internal function (0.89) - * and applications using it are urged to use png_create_info_struct() - * instead. - */ -#if defined(PNG_1_0_X) || defined(PNG_1_2_X) -#undef png_info_init -void PNGAPI -png_info_init(png_infop info_ptr) -{ - /* We only come here via pre-1.0.12-compiled applications */ - png_info_init_3(&info_ptr, 0); -} -#endif - -void PNGAPI -png_info_init_3(png_infopp ptr_ptr, png_size_t png_info_struct_size) -{ - png_infop info_ptr = *ptr_ptr; - - if(info_ptr == NULL) return; - - png_debug(1, "in png_info_init_3\n"); - - if(png_sizeof(png_info) > png_info_struct_size) - { - png_destroy_struct(info_ptr); - info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO); - *ptr_ptr = info_ptr; - } - - /* set everything to 0 */ - png_memset(info_ptr, 0, png_sizeof (png_info)); -} - -#ifdef PNG_FREE_ME_SUPPORTED -void PNGAPI -png_data_freer(png_structp png_ptr, png_infop info_ptr, - int freer, png_uint_32 mask) -{ - png_debug(1, "in png_data_freer\n"); - if (png_ptr == NULL || info_ptr == NULL) - return; - if(freer == PNG_DESTROY_WILL_FREE_DATA) - info_ptr->free_me |= mask; - else if(freer == PNG_USER_WILL_FREE_DATA) - info_ptr->free_me &= ~mask; - else - png_warning(png_ptr, - "Unknown freer parameter in png_data_freer."); -} -#endif - -void PNGAPI -png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask, - int num) -{ - png_debug(1, "in png_free_data\n"); - if (png_ptr == NULL || info_ptr == NULL) - return; - -#if defined(PNG_TEXT_SUPPORTED) -/* free text item num or (if num == -1) all text items */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_TEXT) & info_ptr->free_me) -#else -if (mask & PNG_FREE_TEXT) -#endif -{ - if (num != -1) - { - if (info_ptr->text && info_ptr->text[num].key) - { - png_free(png_ptr, info_ptr->text[num].key); - info_ptr->text[num].key = NULL; - } - } - else - { - int i; - for (i = 0; i < info_ptr->num_text; i++) - png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, i); - png_free(png_ptr, info_ptr->text); - info_ptr->text = NULL; - info_ptr->num_text=0; - } -} -#endif - -#if defined(PNG_tRNS_SUPPORTED) -/* free any tRNS entry */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_TRNS) & info_ptr->free_me) -#else -if ((mask & PNG_FREE_TRNS) && (png_ptr->flags & PNG_FLAG_FREE_TRNS)) -#endif -{ - png_free(png_ptr, info_ptr->trans); - info_ptr->valid &= ~PNG_INFO_tRNS; -#ifndef PNG_FREE_ME_SUPPORTED - png_ptr->flags &= ~PNG_FLAG_FREE_TRNS; -#endif - info_ptr->trans = NULL; -} -#endif - -#if defined(PNG_sCAL_SUPPORTED) -/* free any sCAL entry */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_SCAL) & info_ptr->free_me) -#else -if (mask & PNG_FREE_SCAL) -#endif -{ -#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) - png_free(png_ptr, info_ptr->scal_s_width); - png_free(png_ptr, info_ptr->scal_s_height); - info_ptr->scal_s_width = NULL; - info_ptr->scal_s_height = NULL; -#endif - info_ptr->valid &= ~PNG_INFO_sCAL; -} -#endif - -#if defined(PNG_pCAL_SUPPORTED) -/* free any pCAL entry */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_PCAL) & info_ptr->free_me) -#else -if (mask & PNG_FREE_PCAL) -#endif -{ - png_free(png_ptr, info_ptr->pcal_purpose); - png_free(png_ptr, info_ptr->pcal_units); - info_ptr->pcal_purpose = NULL; - info_ptr->pcal_units = NULL; - if (info_ptr->pcal_params != NULL) - { - int i; - for (i = 0; i < (int)info_ptr->pcal_nparams; i++) - { - png_free(png_ptr, info_ptr->pcal_params[i]); - info_ptr->pcal_params[i]=NULL; - } - png_free(png_ptr, info_ptr->pcal_params); - info_ptr->pcal_params = NULL; - } - info_ptr->valid &= ~PNG_INFO_pCAL; -} -#endif - -#if defined(PNG_iCCP_SUPPORTED) -/* free any iCCP entry */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_ICCP) & info_ptr->free_me) -#else -if (mask & PNG_FREE_ICCP) -#endif -{ - png_free(png_ptr, info_ptr->iccp_name); - png_free(png_ptr, info_ptr->iccp_profile); - info_ptr->iccp_name = NULL; - info_ptr->iccp_profile = NULL; - info_ptr->valid &= ~PNG_INFO_iCCP; -} -#endif - -#if defined(PNG_sPLT_SUPPORTED) -/* free a given sPLT entry, or (if num == -1) all sPLT entries */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_SPLT) & info_ptr->free_me) -#else -if (mask & PNG_FREE_SPLT) -#endif -{ - if (num != -1) - { - if(info_ptr->splt_palettes) - { - png_free(png_ptr, info_ptr->splt_palettes[num].name); - png_free(png_ptr, info_ptr->splt_palettes[num].entries); - info_ptr->splt_palettes[num].name = NULL; - info_ptr->splt_palettes[num].entries = NULL; - } - } - else - { - if(info_ptr->splt_palettes_num) - { - int i; - for (i = 0; i < (int)info_ptr->splt_palettes_num; i++) - png_free_data(png_ptr, info_ptr, PNG_FREE_SPLT, i); - - png_free(png_ptr, info_ptr->splt_palettes); - info_ptr->splt_palettes = NULL; - info_ptr->splt_palettes_num = 0; - } - info_ptr->valid &= ~PNG_INFO_sPLT; - } -} -#endif - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_UNKN) & info_ptr->free_me) -#else -if (mask & PNG_FREE_UNKN) -#endif -{ - if (num != -1) - { - if(info_ptr->unknown_chunks) - { - png_free(png_ptr, info_ptr->unknown_chunks[num].data); - info_ptr->unknown_chunks[num].data = NULL; - } - } - else - { - int i; - - if(info_ptr->unknown_chunks_num) - { - for (i = 0; i < (int)info_ptr->unknown_chunks_num; i++) - png_free_data(png_ptr, info_ptr, PNG_FREE_UNKN, i); - - png_free(png_ptr, info_ptr->unknown_chunks); - info_ptr->unknown_chunks = NULL; - info_ptr->unknown_chunks_num = 0; - } - } -} -#endif - -#if defined(PNG_hIST_SUPPORTED) -/* free any hIST entry */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_HIST) & info_ptr->free_me) -#else -if ((mask & PNG_FREE_HIST) && (png_ptr->flags & PNG_FLAG_FREE_HIST)) -#endif -{ - png_free(png_ptr, info_ptr->hist); - info_ptr->hist = NULL; - info_ptr->valid &= ~PNG_INFO_hIST; -#ifndef PNG_FREE_ME_SUPPORTED - png_ptr->flags &= ~PNG_FLAG_FREE_HIST; -#endif -} -#endif - -/* free any PLTE entry that was internally allocated */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_PLTE) & info_ptr->free_me) -#else -if ((mask & PNG_FREE_PLTE) && (png_ptr->flags & PNG_FLAG_FREE_PLTE)) -#endif -{ - png_zfree(png_ptr, info_ptr->palette); - info_ptr->palette = NULL; - info_ptr->valid &= ~PNG_INFO_PLTE; -#ifndef PNG_FREE_ME_SUPPORTED - png_ptr->flags &= ~PNG_FLAG_FREE_PLTE; -#endif - info_ptr->num_palette = 0; -} - -#if defined(PNG_INFO_IMAGE_SUPPORTED) -/* free any image bits attached to the info structure */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_ROWS) & info_ptr->free_me) -#else -if (mask & PNG_FREE_ROWS) -#endif -{ - if(info_ptr->row_pointers) - { - int row; - for (row = 0; row < (int)info_ptr->height; row++) - { - png_free(png_ptr, info_ptr->row_pointers[row]); - info_ptr->row_pointers[row]=NULL; - } - png_free(png_ptr, info_ptr->row_pointers); - info_ptr->row_pointers=NULL; - } - info_ptr->valid &= ~PNG_INFO_IDAT; -} -#endif - -#ifdef PNG_FREE_ME_SUPPORTED - if(num == -1) - info_ptr->free_me &= ~mask; - else - info_ptr->free_me &= ~(mask & ~PNG_FREE_MUL); -#endif -} - -/* This is an internal routine to free any memory that the info struct is - * pointing to before re-using it or freeing the struct itself. Recall - * that png_free() checks for NULL pointers for us. - */ -void /* PRIVATE */ -png_info_destroy(png_structp png_ptr, png_infop info_ptr) -{ - png_debug(1, "in png_info_destroy\n"); - - png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1); - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - if (png_ptr->num_chunk_list) - { - png_free(png_ptr, png_ptr->chunk_list); - png_ptr->chunk_list=NULL; - png_ptr->num_chunk_list=0; - } -#endif - - png_info_init_3(&info_ptr, png_sizeof(png_info)); -} -#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ - -/* This function returns a pointer to the io_ptr associated with the user - * functions. The application should free any memory associated with this - * pointer before png_write_destroy() or png_read_destroy() are called. - */ -png_voidp PNGAPI -png_get_io_ptr(png_structp png_ptr) -{ - if(png_ptr == NULL) return (NULL); - return (png_ptr->io_ptr); -} - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) -#if !defined(PNG_NO_STDIO) -/* Initialize the default input/output functions for the PNG file. If you - * use your own read or write routines, you can call either png_set_read_fn() - * or png_set_write_fn() instead of png_init_io(). If you have defined - * PNG_NO_STDIO, you must use a function of your own because "FILE *" isn't - * necessarily available. - */ -void PNGAPI -png_init_io(png_structp png_ptr, png_FILE_p fp) -{ - png_debug(1, "in png_init_io\n"); - if(png_ptr == NULL) return; - png_ptr->io_ptr = (png_voidp)fp; -} -#endif - -#if defined(PNG_TIME_RFC1123_SUPPORTED) -/* Convert the supplied time into an RFC 1123 string suitable for use in - * a "Creation Time" or other text-based time string. - */ -png_charp PNGAPI -png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime) -{ - static PNG_CONST char short_months[12][4] = - {"Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; - - if(png_ptr == NULL) return (NULL); - if (png_ptr->time_buffer == NULL) - { - png_ptr->time_buffer = (png_charp)png_malloc(png_ptr, (png_uint_32)(29* - png_sizeof(char))); - } - -#if defined(_WIN32_WCE) - { - wchar_t time_buf[29]; - wsprintf(time_buf, TEXT("%d %S %d %02d:%02d:%02d +0000"), - ptime->day % 32, short_months[(ptime->month - 1) % 12], - ptime->year, ptime->hour % 24, ptime->minute % 60, - ptime->second % 61); - WideCharToMultiByte(CP_ACP, 0, time_buf, -1, png_ptr->time_buffer, 29, - NULL, NULL); - } -#else -#ifdef USE_FAR_KEYWORD - { - char near_time_buf[29]; - sprintf(near_time_buf, "%d %s %d %02d:%02d:%02d +0000", - ptime->day % 32, short_months[(ptime->month - 1) % 12], - ptime->year, ptime->hour % 24, ptime->minute % 60, - ptime->second % 61); - png_memcpy(png_ptr->time_buffer, near_time_buf, - 29*png_sizeof(char)); - } -#else - sprintf(png_ptr->time_buffer, "%d %s %d %02d:%02d:%02d +0000", - ptime->day % 32, short_months[(ptime->month - 1) % 12], - ptime->year, ptime->hour % 24, ptime->minute % 60, - ptime->second % 61); -#endif -#endif /* _WIN32_WCE */ - return ((png_charp)png_ptr->time_buffer); -} -#endif /* PNG_TIME_RFC1123_SUPPORTED */ - -#if 0 -/* Signature string for a PNG file. */ -png_bytep PNGAPI -png_sig_bytes(void) -{ - return ((png_bytep)"\211\120\116\107\015\012\032\012"); -} -#endif -#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ - -png_charp PNGAPI -png_get_copyright(png_structp png_ptr) -{ - if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */ - return ((png_charp) "\n libpng version 1.2.16 - January 31, 2007\n\ - Copyright (c) 1998-2007 Glenn Randers-Pehrson\n\ - Copyright (c) 1996-1997 Andreas Dilger\n\ - Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n"); - return ((png_charp) ""); -} - -/* The following return the library version as a short string in the - * format 1.0.0 through 99.99.99zz. To get the version of *.h files - * used with your application, print out PNG_LIBPNG_VER_STRING, which - * is defined in png.h. - * Note: now there is no difference between png_get_libpng_ver() and - * png_get_header_ver(). Due to the version_nn_nn_nn typedef guard, - * it is guaranteed that png.c uses the correct version of png.h. - */ -png_charp PNGAPI -png_get_libpng_ver(png_structp png_ptr) -{ - /* Version of *.c files used when building libpng */ - if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */ - return ((png_charp) PNG_LIBPNG_VER_STRING); - return ((png_charp) ""); -} - -png_charp PNGAPI -png_get_header_ver(png_structp png_ptr) -{ - /* Version of *.h files used when building libpng */ - if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */ - return ((png_charp) PNG_LIBPNG_VER_STRING); - return ((png_charp) ""); -} - -png_charp PNGAPI -png_get_header_version(png_structp png_ptr) -{ - /* Returns longer string containing both version and date */ - if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */ - return ((png_charp) PNG_HEADER_VERSION_STRING); - return ((png_charp) ""); -} - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED -int PNGAPI -png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name) -{ - /* check chunk_name and return "keep" value if it's on the list, else 0 */ - int i; - png_bytep p; - if((png_ptr == NULL && chunk_name == NULL) || png_ptr->num_chunk_list<=0) - return 0; - p=png_ptr->chunk_list+png_ptr->num_chunk_list*5-5; - for (i = png_ptr->num_chunk_list; i; i--, p-=5) - if (!png_memcmp(chunk_name, p, 4)) - return ((int)*(p+4)); - return 0; -} -#endif - -/* This function, added to libpng-1.0.6g, is untested. */ -int PNGAPI -png_reset_zstream(png_structp png_ptr) -{ - if (png_ptr == NULL) return Z_STREAM_ERROR; - return (inflateReset(&png_ptr->zstream)); -} -#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ - -/* This function was added to libpng-1.0.7 */ -png_uint_32 PNGAPI -png_access_version_number(void) -{ - /* Version of *.c files used when building libpng */ - return((png_uint_32) PNG_LIBPNG_VER); -} - - -/* this INTERNAL function was added to libpng 1.2.0 */ -void /* PRIVATE */ -png_init_mmx_flags (png_structp png_ptr) -{ - if(png_ptr == NULL) return; - png_ptr->mmx_rowbytes_threshold = 0; - png_ptr->mmx_bitdepth_threshold = 0; - - /* clear all MMX flags; no support is compiled in */ - png_ptr->asm_flags &= ~( PNG_MMX_FLAGS ); - -} - - - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) -#ifdef PNG_SIZE_T -/* Added at libpng version 1.2.6 */ - PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size)); -png_size_t PNGAPI -png_convert_size(size_t size) -{ - if (size > (png_size_t)-1) - PNG_ABORT(); /* We haven't got access to png_ptr, so no png_error() */ - return ((png_size_t)size); -} -#endif /* PNG_SIZE_T */ -#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng_osx/png.h b/irrlicht-1.6/source/Irrlicht/libpng_osx/png.h deleted file mode 100644 index 1567f9cec..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng_osx/png.h +++ /dev/null @@ -1,3506 +0,0 @@ - -/* png.h - header file for PNG reference library - * - * libpng version 1.2.16 - January 31, 2007 - * Copyright (c) 1998-2007 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * Authors and maintainers: - * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat - * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger - * libpng versions 0.97, January 1998, through 1.2.16 - January 31, 2007: Glenn - * See also "Contributing Authors", below. - * - * Note about libpng version numbers: - * - * Due to various miscommunications, unforeseen code incompatibilities - * and occasional factors outside the authors' control, version numbering - * on the library has not always been consistent and straightforward. - * The following table summarizes matters since version 0.89c, which was - * the first widely used release: - * - * source png.h png.h shared-lib - * version string int version - * ------- ------ ----- ---------- - * 0.89c "1.0 beta 3" 0.89 89 1.0.89 - * 0.90 "1.0 beta 4" 0.90 90 0.90 [should have been 2.0.90] - * 0.95 "1.0 beta 5" 0.95 95 0.95 [should have been 2.0.95] - * 0.96 "1.0 beta 6" 0.96 96 0.96 [should have been 2.0.96] - * 0.97b "1.00.97 beta 7" 1.00.97 97 1.0.1 [should have been 2.0.97] - * 0.97c 0.97 97 2.0.97 - * 0.98 0.98 98 2.0.98 - * 0.99 0.99 98 2.0.99 - * 0.99a-m 0.99 99 2.0.99 - * 1.00 1.00 100 2.1.0 [100 should be 10000] - * 1.0.0 (from here on, the 100 2.1.0 [100 should be 10000] - * 1.0.1 png.h string is 10001 2.1.0 - * 1.0.1a-e identical to the 10002 from here on, the shared library - * 1.0.2 source version) 10002 is 2.V where V is the source code - * 1.0.2a-b 10003 version, except as noted. - * 1.0.3 10003 - * 1.0.3a-d 10004 - * 1.0.4 10004 - * 1.0.4a-f 10005 - * 1.0.5 (+ 2 patches) 10005 - * 1.0.5a-d 10006 - * 1.0.5e-r 10100 (not source compatible) - * 1.0.5s-v 10006 (not binary compatible) - * 1.0.6 (+ 3 patches) 10006 (still binary incompatible) - * 1.0.6d-f 10007 (still binary incompatible) - * 1.0.6g 10007 - * 1.0.6h 10007 10.6h (testing xy.z so-numbering) - * 1.0.6i 10007 10.6i - * 1.0.6j 10007 2.1.0.6j (incompatible with 1.0.0) - * 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 (binary compatible) - * 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 (binary compatible) - * 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 (binary compatible) - * 1.0.7 1 10007 (still compatible) - * 1.0.8beta1-4 1 10008 2.1.0.8beta1-4 - * 1.0.8rc1 1 10008 2.1.0.8rc1 - * 1.0.8 1 10008 2.1.0.8 - * 1.0.9beta1-6 1 10009 2.1.0.9beta1-6 - * 1.0.9rc1 1 10009 2.1.0.9rc1 - * 1.0.9beta7-10 1 10009 2.1.0.9beta7-10 - * 1.0.9rc2 1 10009 2.1.0.9rc2 - * 1.0.9 1 10009 2.1.0.9 - * 1.0.10beta1 1 10010 2.1.0.10beta1 - * 1.0.10rc1 1 10010 2.1.0.10rc1 - * 1.0.10 1 10010 2.1.0.10 - * 1.0.11beta1-3 1 10011 2.1.0.11beta1-3 - * 1.0.11rc1 1 10011 2.1.0.11rc1 - * 1.0.11 1 10011 2.1.0.11 - * 1.0.12beta1-2 2 10012 2.1.0.12beta1-2 - * 1.0.12rc1 2 10012 2.1.0.12rc1 - * 1.0.12 2 10012 2.1.0.12 - * 1.1.0a-f - 10100 2.1.1.0a-f (branch abandoned) - * 1.2.0beta1-2 2 10200 2.1.2.0beta1-2 - * 1.2.0beta3-5 3 10200 3.1.2.0beta3-5 - * 1.2.0rc1 3 10200 3.1.2.0rc1 - * 1.2.0 3 10200 3.1.2.0 - * 1.2.1beta1-4 3 10201 3.1.2.1beta1-4 - * 1.2.1rc1-2 3 10201 3.1.2.1rc1-2 - * 1.2.1 3 10201 3.1.2.1 - * 1.2.2beta1-6 12 10202 12.so.0.1.2.2beta1-6 - * 1.0.13beta1 10 10013 10.so.0.1.0.13beta1 - * 1.0.13rc1 10 10013 10.so.0.1.0.13rc1 - * 1.2.2rc1 12 10202 12.so.0.1.2.2rc1 - * 1.0.13 10 10013 10.so.0.1.0.13 - * 1.2.2 12 10202 12.so.0.1.2.2 - * 1.2.3rc1-6 12 10203 12.so.0.1.2.3rc1-6 - * 1.2.3 12 10203 12.so.0.1.2.3 - * 1.2.4beta1-3 13 10204 12.so.0.1.2.4beta1-3 - * 1.0.14rc1 13 10014 10.so.0.1.0.14rc1 - * 1.2.4rc1 13 10204 12.so.0.1.2.4rc1 - * 1.0.14 10 10014 10.so.0.1.0.14 - * 1.2.4 13 10204 12.so.0.1.2.4 - * 1.2.5beta1-2 13 10205 12.so.0.1.2.5beta1-2 - * 1.0.15rc1-3 10 10015 10.so.0.1.0.15rc1-3 - * 1.2.5rc1-3 13 10205 12.so.0.1.2.5rc1-3 - * 1.0.15 10 10015 10.so.0.1.0.15 - * 1.2.5 13 10205 12.so.0.1.2.5 - * 1.2.6beta1-4 13 10206 12.so.0.1.2.6beta1-4 - * 1.0.16 10 10016 10.so.0.1.0.16 - * 1.2.6 13 10206 12.so.0.1.2.6 - * 1.2.7beta1-2 13 10207 12.so.0.1.2.7beta1-2 - * 1.0.17rc1 10 10017 10.so.0.1.0.17rc1 - * 1.2.7rc1 13 10207 12.so.0.1.2.7rc1 - * 1.0.17 10 10017 10.so.0.1.0.17 - * 1.2.7 13 10207 12.so.0.1.2.7 - * 1.2.8beta1-5 13 10208 12.so.0.1.2.8beta1-5 - * 1.0.18rc1-5 10 10018 10.so.0.1.0.18rc1-5 - * 1.2.8rc1-5 13 10208 12.so.0.1.2.8rc1-5 - * 1.0.18 10 10018 10.so.0.1.0.18 - * 1.2.8 13 10208 12.so.0.1.2.8 - * 1.2.9beta1-3 13 10209 12.so.0.1.2.9beta1-3 - * 1.2.9beta4-11 13 10209 12.so.0.9[.0] - * 1.2.9rc1 13 10209 12.so.0.9[.0] - * 1.2.9 13 10209 12.so.0.9[.0] - * 1.2.10beta1-8 13 10210 12.so.0.10[.0] - * 1.2.10rc1-3 13 10210 12.so.0.10[.0] - * 1.2.10 13 10210 12.so.0.10[.0] - * 1.2.11beta1-4 13 10211 12.so.0.11[.0] - * 1.0.19rc1-5 10 10019 10.so.0.19[.0] - * 1.2.11rc1-5 13 10211 12.so.0.11[.0] - * 1.0.19 10 10019 10.so.0.19[.0] - * 1.2.11 13 10211 12.so.0.11[.0] - * 1.0.20 10 10020 10.so.0.20[.0] - * 1.2.12 13 10212 12.so.0.12[.0] - * 1.2.13beta1 13 10213 12.so.0.13[.0] - * 1.0.21 10 10021 10.so.0.21[.0] - * 1.2.13 13 10213 12.so.0.13[.0] - * 1.2.14beta1-2 13 10214 12.so.0.14[.0] - * 1.0.22rc1 10 10022 10.so.0.22[.0] - * 1.2.14rc1 13 10214 12.so.0.14[.0] - * 1.0.22 10 10022 10.so.0.22[.0] - * 1.2.14 13 10214 12.so.0.14[.0] - * 1.2.15beta1-6 13 10215 12.so.0.15[.0] - * 1.0.23rc1-5 10 10023 10.so.0.23[.0] - * 1.2.15rc1-5 13 10215 12.so.0.15[.0] - * 1.0.23 10 10023 10.so.0.23[.0] - * 1.2.15 13 10215 12.so.0.15[.0] - * 1.2.16beta1-2 13 10216 12.so.0.16[.0] - * 1.2.16rc1 13 10216 12.so.0.16[.0] - * 1.0.24 10 10024 10.so.0.24[.0] - * 1.2.16 13 10216 12.so.0.16[.0] - * - * Henceforth the source version will match the shared-library major - * and minor numbers; the shared-library major version number will be - * used for changes in backward compatibility, as it is intended. The - * PNG_LIBPNG_VER macro, which is not used within libpng but is available - * for applications, is an unsigned integer of the form xyyzz corresponding - * to the source version x.y.z (leading zeros in y and z). Beta versions - * were given the previous public release number plus a letter, until - * version 1.0.6j; from then on they were given the upcoming public - * release number plus "betaNN" or "rcN". - * - * Binary incompatibility exists only when applications make direct access - * to the info_ptr or png_ptr members through png.h, and the compiled - * application is loaded with a different version of the library. - * - * DLLNUM will change each time there are forward or backward changes - * in binary compatibility (e.g., when a new feature is added). - * - * See libpng.txt or libpng.3 for more information. The PNG specification - * is available as a W3C Recommendation and as an ISO Specification, - * <http://www.w3.org/TR/2003/REC-PNG-20031110/ - */ - -/* - * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE: - * - * If you modify libpng you may insert additional notices immediately following - * this sentence. - * - * libpng versions 1.2.6, August 15, 2004, through 1.2.16, January 31, 2007, are - * Copyright (c) 2004, 2007 Glenn Randers-Pehrson, and are - * distributed according to the same disclaimer and license as libpng-1.2.5 - * with the following individual added to the list of Contributing Authors: - * - * Cosmin Truta - * - * libpng versions 1.0.7, July 1, 2000, through 1.2.5, October 3, 2002, are - * Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are - * distributed according to the same disclaimer and license as libpng-1.0.6 - * with the following individuals added to the list of Contributing Authors: - * - * Simon-Pierre Cadieux - * Eric S. Raymond - * Gilles Vollant - * - * and with the following additions to the disclaimer: - * - * There is no warranty against interference with your enjoyment of the - * library or against infringement. There is no warranty that our - * efforts or the library will fulfill any of your particular purposes - * or needs. This library is provided with all faults, and the entire - * risk of satisfactory quality, performance, accuracy, and effort is with - * the user. - * - * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are - * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson, and are - * distributed according to the same disclaimer and license as libpng-0.96, - * with the following individuals added to the list of Contributing Authors: - * - * Tom Lane - * Glenn Randers-Pehrson - * Willem van Schaik - * - * libpng versions 0.89, June 1996, through 0.96, May 1997, are - * Copyright (c) 1996, 1997 Andreas Dilger - * Distributed according to the same disclaimer and license as libpng-0.88, - * with the following individuals added to the list of Contributing Authors: - * - * John Bowler - * Kevin Bracey - * Sam Bushell - * Magnus Holmgren - * Greg Roelofs - * Tom Tanner - * - * libpng versions 0.5, May 1995, through 0.88, January 1996, are - * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. - * - * For the purposes of this copyright and license, "Contributing Authors" - * is defined as the following set of individuals: - * - * Andreas Dilger - * Dave Martindale - * Guy Eric Schalnat - * Paul Schmidt - * Tim Wegner - * - * The PNG Reference Library is supplied "AS IS". The Contributing Authors - * and Group 42, Inc. disclaim all warranties, expressed or implied, - * including, without limitation, the warranties of merchantability and of - * fitness for any purpose. The Contributing Authors and Group 42, Inc. - * assume no liability for direct, indirect, incidental, special, exemplary, - * or consequential damages, which may result from the use of the PNG - * Reference Library, even if advised of the possibility of such damage. - * - * Permission is hereby granted to use, copy, modify, and distribute this - * source code, or portions hereof, for any purpose, without fee, subject - * to the following restrictions: - * - * 1. The origin of this source code must not be misrepresented. - * - * 2. Altered versions must be plainly marked as such and - * must not be misrepresented as being the original source. - * - * 3. This Copyright notice may not be removed or altered from - * any source or altered source distribution. - * - * The Contributing Authors and Group 42, Inc. specifically permit, without - * fee, and encourage the use of this source code as a component to - * supporting the PNG file format in commercial products. If you use this - * source code in a product, acknowledgment is not required but would be - * appreciated. - */ - -/* - * A "png_get_copyright" function is available, for convenient use in "about" - * boxes and the like: - * - * printf("%s",png_get_copyright(NULL)); - * - * Also, the PNG logo (in PNG format, of course) is supplied in the - * files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31). - */ - -/* - * Libpng is OSI Certified Open Source Software. OSI Certified is a - * certification mark of the Open Source Initiative. - */ - -/* - * The contributing authors would like to thank all those who helped - * with testing, bug fixes, and patience. This wouldn't have been - * possible without all of you. - * - * Thanks to Frank J. T. Wojcik for helping with the documentation. - */ - -/* - * Y2K compliance in libpng: - * ========================= - * - * January 31, 2007 - * - * Since the PNG Development group is an ad-hoc body, we can't make - * an official declaration. - * - * This is your unofficial assurance that libpng from version 0.71 and - * upward through 1.2.16 are Y2K compliant. It is my belief that earlier - * versions were also Y2K compliant. - * - * Libpng only has three year fields. One is a 2-byte unsigned integer - * that will hold years up to 65535. The other two hold the date in text - * format, and will hold years up to 9999. - * - * The integer is - * "png_uint_16 year" in png_time_struct. - * - * The strings are - * "png_charp time_buffer" in png_struct and - * "near_time_buffer", which is a local character string in png.c. - * - * There are seven time-related functions: - * png.c: png_convert_to_rfc_1123() in png.c - * (formerly png_convert_to_rfc_1152() in error) - * png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c - * png_convert_from_time_t() in pngwrite.c - * png_get_tIME() in pngget.c - * png_handle_tIME() in pngrutil.c, called in pngread.c - * png_set_tIME() in pngset.c - * png_write_tIME() in pngwutil.c, called in pngwrite.c - * - * All handle dates properly in a Y2K environment. The - * png_convert_from_time_t() function calls gmtime() to convert from system - * clock time, which returns (year - 1900), which we properly convert to - * the full 4-digit year. There is a possibility that applications using - * libpng are not passing 4-digit years into the png_convert_to_rfc_1123() - * function, or that they are incorrectly passing only a 2-digit year - * instead of "year - 1900" into the png_convert_from_struct_tm() function, - * but this is not under our control. The libpng documentation has always - * stated that it works with 4-digit years, and the APIs have been - * documented as such. - * - * The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned - * integer to hold the year, and can hold years as large as 65535. - * - * zlib, upon which libpng depends, is also Y2K compliant. It contains - * no date-related code. - * - * Glenn Randers-Pehrson - * libpng maintainer - * PNG Development Group - */ - -#ifndef PNG_H -#define PNG_H - -/* This is not the place to learn how to use libpng. The file libpng.txt - * describes how to use libpng, and the file example.c summarizes it - * with some code on which to build. This file is useful for looking - * at the actual function definitions and structure components. - */ - -/* Version information for png.h - this should match the version in png.c */ -#define PNG_LIBPNG_VER_STRING "1.2.16" -#define PNG_HEADER_VERSION_STRING \ - " libpng version 1.2.16 - January 31, 2007 (header)\n" - -#define PNG_LIBPNG_VER_SONUM 0 -#define PNG_LIBPNG_VER_DLLNUM 13 - -/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ -#define PNG_LIBPNG_VER_MAJOR 1 -#define PNG_LIBPNG_VER_MINOR 2 -#define PNG_LIBPNG_VER_RELEASE 16 -/* This should match the numeric part of the final component of - * PNG_LIBPNG_VER_STRING, omitting any leading zero: */ - -#define PNG_LIBPNG_VER_BUILD 0 - -/* Release Status */ -#define PNG_LIBPNG_BUILD_ALPHA 1 -#define PNG_LIBPNG_BUILD_BETA 2 -#define PNG_LIBPNG_BUILD_RC 3 -#define PNG_LIBPNG_BUILD_STABLE 4 -#define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7 - -/* Release-Specific Flags */ -#define PNG_LIBPNG_BUILD_PATCH 8 /* Can be OR'ed with - PNG_LIBPNG_BUILD_STABLE only */ -#define PNG_LIBPNG_BUILD_PRIVATE 16 /* Cannot be OR'ed with - PNG_LIBPNG_BUILD_SPECIAL */ -#define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with - PNG_LIBPNG_BUILD_PRIVATE */ - -#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE - -/* Careful here. At one time, Guy wanted to use 082, but that would be octal. - * We must not include leading zeros. - * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only - * version 1.0.0 was mis-numbered 100 instead of 10000). From - * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release */ -#define PNG_LIBPNG_VER 10216 /* 1.2.16 */ - -#ifndef PNG_VERSION_INFO_ONLY -/* include the compression library's header */ -#include "zlib.h" -#endif - -/* include all user configurable info, including optional assembler routines */ -#include "pngconf.h" - -/* - * Added at libpng-1.2.8 */ -/* Ref MSDN: Private as priority over Special - * VS_FF_PRIVATEBUILD File *was not* built using standard release - * procedures. If this value is given, the StringFileInfo block must - * contain a PrivateBuild string. - * - * VS_FF_SPECIALBUILD File *was* built by the original company using - * standard release procedures but is a variation of the standard - * file of the same version number. If this value is given, the - * StringFileInfo block must contain a SpecialBuild string. - */ - -#if defined(PNG_USER_PRIVATEBUILD) -# define PNG_LIBPNG_BUILD_TYPE \ - (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_PRIVATE) -#else -# if defined(PNG_LIBPNG_SPECIALBUILD) -# define PNG_LIBPNG_BUILD_TYPE \ - (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_SPECIAL) -# else -# define PNG_LIBPNG_BUILD_TYPE (PNG_LIBPNG_BUILD_BASE_TYPE) -# endif -#endif - -#ifndef PNG_VERSION_INFO_ONLY - -/* Inhibit C++ name-mangling for libpng functions but not for system calls. */ -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* This file is arranged in several sections. The first section contains - * structure and type definitions. The second section contains the external - * library functions, while the third has the internal library functions, - * which applications aren't expected to use directly. - */ - -#ifndef PNG_NO_TYPECAST_NULL -#define int_p_NULL (int *)NULL -#define png_bytep_NULL (png_bytep)NULL -#define png_bytepp_NULL (png_bytepp)NULL -#define png_doublep_NULL (png_doublep)NULL -#define png_error_ptr_NULL (png_error_ptr)NULL -#define png_flush_ptr_NULL (png_flush_ptr)NULL -#define png_free_ptr_NULL (png_free_ptr)NULL -#define png_infopp_NULL (png_infopp)NULL -#define png_malloc_ptr_NULL (png_malloc_ptr)NULL -#define png_read_status_ptr_NULL (png_read_status_ptr)NULL -#define png_rw_ptr_NULL (png_rw_ptr)NULL -#define png_structp_NULL (png_structp)NULL -#define png_uint_16p_NULL (png_uint_16p)NULL -#define png_voidp_NULL (png_voidp)NULL -#define png_write_status_ptr_NULL (png_write_status_ptr)NULL -#else -#define int_p_NULL NULL -#define png_bytep_NULL NULL -#define png_bytepp_NULL NULL -#define png_doublep_NULL NULL -#define png_error_ptr_NULL NULL -#define png_flush_ptr_NULL NULL -#define png_free_ptr_NULL NULL -#define png_infopp_NULL NULL -#define png_malloc_ptr_NULL NULL -#define png_read_status_ptr_NULL NULL -#define png_rw_ptr_NULL NULL -#define png_structp_NULL NULL -#define png_uint_16p_NULL NULL -#define png_voidp_NULL NULL -#define png_write_status_ptr_NULL NULL -#endif - -/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */ -#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN) -/* Version information for C files, stored in png.c. This had better match - * the version above. - */ -#ifdef PNG_USE_GLOBAL_ARRAYS -PNG_EXPORT_VAR (const char) png_libpng_ver[18]; - /* need room for 99.99.99beta99z */ -#else -#define png_libpng_ver png_get_header_ver(NULL) -#endif - -#ifdef PNG_USE_GLOBAL_ARRAYS -/* This was removed in version 1.0.5c */ -/* Structures to facilitate easy interlacing. See png.c for more details */ -PNG_EXPORT_VAR (const int FARDATA) png_pass_start[7]; -PNG_EXPORT_VAR (const int FARDATA) png_pass_inc[7]; -PNG_EXPORT_VAR (const int FARDATA) png_pass_ystart[7]; -PNG_EXPORT_VAR (const int FARDATA) png_pass_yinc[7]; -PNG_EXPORT_VAR (const int FARDATA) png_pass_mask[7]; -PNG_EXPORT_VAR (const int FARDATA) png_pass_dsp_mask[7]; -#ifdef PNG_USE_PNGGCCRD -PNG_EXPORT_VAR (const int FARDATA) png_pass_width[7]; -#endif -/* This isn't currently used. If you need it, see png.c for more details. -PNG_EXPORT_VAR (const int FARDATA) png_pass_height[7]; -*/ -#endif - -#endif /* PNG_NO_EXTERN */ - -/* Three color definitions. The order of the red, green, and blue, (and the - * exact size) is not important, although the size of the fields need to - * be png_byte or png_uint_16 (as defined below). - */ -typedef struct png_color_struct -{ - png_byte red; - png_byte green; - png_byte blue; -} png_color; -typedef png_color FAR * png_colorp; -typedef png_color FAR * FAR * png_colorpp; - -typedef struct png_color_16_struct -{ - png_byte index; /* used for palette files */ - png_uint_16 red; /* for use in red green blue files */ - png_uint_16 green; - png_uint_16 blue; - png_uint_16 gray; /* for use in grayscale files */ -} png_color_16; -typedef png_color_16 FAR * png_color_16p; -typedef png_color_16 FAR * FAR * png_color_16pp; - -typedef struct png_color_8_struct -{ - png_byte red; /* for use in red green blue files */ - png_byte green; - png_byte blue; - png_byte gray; /* for use in grayscale files */ - png_byte alpha; /* for alpha channel files */ -} png_color_8; -typedef png_color_8 FAR * png_color_8p; -typedef png_color_8 FAR * FAR * png_color_8pp; - -/* - * The following two structures are used for the in-core representation - * of sPLT chunks. - */ -typedef struct png_sPLT_entry_struct -{ - png_uint_16 red; - png_uint_16 green; - png_uint_16 blue; - png_uint_16 alpha; - png_uint_16 frequency; -} png_sPLT_entry; -typedef png_sPLT_entry FAR * png_sPLT_entryp; -typedef png_sPLT_entry FAR * FAR * png_sPLT_entrypp; - -/* When the depth of the sPLT palette is 8 bits, the color and alpha samples - * occupy the LSB of their respective members, and the MSB of each member - * is zero-filled. The frequency member always occupies the full 16 bits. - */ - -typedef struct png_sPLT_struct -{ - png_charp name; /* palette name */ - png_byte depth; /* depth of palette samples */ - png_sPLT_entryp entries; /* palette entries */ - png_int_32 nentries; /* number of palette entries */ -} png_sPLT_t; -typedef png_sPLT_t FAR * png_sPLT_tp; -typedef png_sPLT_t FAR * FAR * png_sPLT_tpp; - -#ifdef PNG_TEXT_SUPPORTED -/* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file, - * and whether that contents is compressed or not. The "key" field - * points to a regular zero-terminated C string. The "text", "lang", and - * "lang_key" fields can be regular C strings, empty strings, or NULL pointers. - * However, the * structure returned by png_get_text() will always contain - * regular zero-terminated C strings (possibly empty), never NULL pointers, - * so they can be safely used in printf() and other string-handling functions. - */ -typedef struct png_text_struct -{ - int compression; /* compression value: - -1: tEXt, none - 0: zTXt, deflate - 1: iTXt, none - 2: iTXt, deflate */ - png_charp key; /* keyword, 1-79 character description of "text" */ - png_charp text; /* comment, may be an empty string (ie "") - or a NULL pointer */ - png_size_t text_length; /* length of the text string */ -#ifdef PNG_iTXt_SUPPORTED - png_size_t itxt_length; /* length of the itxt string */ - png_charp lang; /* language code, 0-79 characters - or a NULL pointer */ - png_charp lang_key; /* keyword translated UTF-8 string, 0 or more - chars or a NULL pointer */ -#endif -} png_text; -typedef png_text FAR * png_textp; -typedef png_text FAR * FAR * png_textpp; -#endif - -/* Supported compression types for text in PNG files (tEXt, and zTXt). - * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */ -#define PNG_TEXT_COMPRESSION_NONE_WR -3 -#define PNG_TEXT_COMPRESSION_zTXt_WR -2 -#define PNG_TEXT_COMPRESSION_NONE -1 -#define PNG_TEXT_COMPRESSION_zTXt 0 -#define PNG_ITXT_COMPRESSION_NONE 1 -#define PNG_ITXT_COMPRESSION_zTXt 2 -#define PNG_TEXT_COMPRESSION_LAST 3 /* Not a valid value */ - -/* png_time is a way to hold the time in an machine independent way. - * Two conversions are provided, both from time_t and struct tm. There - * is no portable way to convert to either of these structures, as far - * as I know. If you know of a portable way, send it to me. As a side - * note - PNG has always been Year 2000 compliant! - */ -typedef struct png_time_struct -{ - png_uint_16 year; /* full year, as in, 1995 */ - png_byte month; /* month of year, 1 - 12 */ - png_byte day; /* day of month, 1 - 31 */ - png_byte hour; /* hour of day, 0 - 23 */ - png_byte minute; /* minute of hour, 0 - 59 */ - png_byte second; /* second of minute, 0 - 60 (for leap seconds) */ -} png_time; -typedef png_time FAR * png_timep; -typedef png_time FAR * FAR * png_timepp; - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -/* png_unknown_chunk is a structure to hold queued chunks for which there is - * no specific support. The idea is that we can use this to queue - * up private chunks for output even though the library doesn't actually - * know about their semantics. - */ -typedef struct png_unknown_chunk_t -{ - png_byte name[5]; - png_byte *data; - png_size_t size; - - /* libpng-using applications should NOT directly modify this byte. */ - png_byte location; /* mode of operation at read time */ -} -png_unknown_chunk; -typedef png_unknown_chunk FAR * png_unknown_chunkp; -typedef png_unknown_chunk FAR * FAR * png_unknown_chunkpp; -#endif - -/* png_info is a structure that holds the information in a PNG file so - * that the application can find out the characteristics of the image. - * If you are reading the file, this structure will tell you what is - * in the PNG file. If you are writing the file, fill in the information - * you want to put into the PNG file, then call png_write_info(). - * The names chosen should be very close to the PNG specification, so - * consult that document for information about the meaning of each field. - * - * With libpng < 0.95, it was only possible to directly set and read the - * the values in the png_info_struct, which meant that the contents and - * order of the values had to remain fixed. With libpng 0.95 and later, - * however, there are now functions that abstract the contents of - * png_info_struct from the application, so this makes it easier to use - * libpng with dynamic libraries, and even makes it possible to use - * libraries that don't have all of the libpng ancillary chunk-handing - * functionality. - * - * In any case, the order of the parameters in png_info_struct should NOT - * be changed for as long as possible to keep compatibility with applications - * that use the old direct-access method with png_info_struct. - * - * The following members may have allocated storage attached that should be - * cleaned up before the structure is discarded: palette, trans, text, - * pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile, - * splt_palettes, scal_unit, row_pointers, and unknowns. By default, these - * are automatically freed when the info structure is deallocated, if they were - * allocated internally by libpng. This behavior can be changed by means - * of the png_data_freer() function. - * - * More allocation details: all the chunk-reading functions that - * change these members go through the corresponding png_set_* - * functions. A function to clear these members is available: see - * png_free_data(). The png_set_* functions do not depend on being - * able to point info structure members to any of the storage they are - * passed (they make their own copies), EXCEPT that the png_set_text - * functions use the same storage passed to them in the text_ptr or - * itxt_ptr structure argument, and the png_set_rows and png_set_unknowns - * functions do not make their own copies. - */ -typedef struct png_info_struct -{ - /* the following are necessary for every PNG file */ - png_uint_32 width; /* width of image in pixels (from IHDR) */ - png_uint_32 height; /* height of image in pixels (from IHDR) */ - png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */ - png_uint_32 rowbytes; /* bytes needed to hold an untransformed row */ - png_colorp palette; /* array of color values (valid & PNG_INFO_PLTE) */ - png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */ - png_uint_16 num_trans; /* number of transparent palette color (tRNS) */ - png_byte bit_depth; /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */ - png_byte color_type; /* see PNG_COLOR_TYPE_ below (from IHDR) */ - /* The following three should have been named *_method not *_type */ - png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */ - png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */ - png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ - - /* The following is informational only on read, and not used on writes. */ - png_byte channels; /* number of data channels per pixel (1, 2, 3, 4) */ - png_byte pixel_depth; /* number of bits per pixel */ - png_byte spare_byte; /* to align the data, and for future use */ - png_byte signature[8]; /* magic bytes read by libpng from start of file */ - - /* The rest of the data is optional. If you are reading, check the - * valid field to see if the information in these are valid. If you - * are writing, set the valid field to those chunks you want written, - * and initialize the appropriate fields below. - */ - -#if defined(PNG_gAMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) - /* The gAMA chunk describes the gamma characteristics of the system - * on which the image was created, normally in the range [1.0, 2.5]. - * Data is valid if (valid & PNG_INFO_gAMA) is non-zero. - */ - float gamma; /* gamma value of image, if (valid & PNG_INFO_gAMA) */ -#endif - -#if defined(PNG_sRGB_SUPPORTED) - /* GR-P, 0.96a */ - /* Data valid if (valid & PNG_INFO_sRGB) non-zero. */ - png_byte srgb_intent; /* sRGB rendering intent [0, 1, 2, or 3] */ -#endif - -#if defined(PNG_TEXT_SUPPORTED) - /* The tEXt, and zTXt chunks contain human-readable textual data in - * uncompressed, compressed, and optionally compressed forms, respectively. - * The data in "text" is an array of pointers to uncompressed, - * null-terminated C strings. Each chunk has a keyword that describes the - * textual data contained in that chunk. Keywords are not required to be - * unique, and the text string may be empty. Any number of text chunks may - * be in an image. - */ - int num_text; /* number of comments read/to write */ - int max_text; /* current size of text array */ - png_textp text; /* array of comments read/to write */ -#endif /* PNG_TEXT_SUPPORTED */ - -#if defined(PNG_tIME_SUPPORTED) - /* The tIME chunk holds the last time the displayed image data was - * modified. See the png_time struct for the contents of this struct. - */ - png_time mod_time; -#endif - -#if defined(PNG_sBIT_SUPPORTED) - /* The sBIT chunk specifies the number of significant high-order bits - * in the pixel data. Values are in the range [1, bit_depth], and are - * only specified for the channels in the pixel data. The contents of - * the low-order bits is not specified. Data is valid if - * (valid & PNG_INFO_sBIT) is non-zero. - */ - png_color_8 sig_bit; /* significant bits in color channels */ -#endif - -#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \ -defined(PNG_READ_BACKGROUND_SUPPORTED) - /* The tRNS chunk supplies transparency data for paletted images and - * other image types that don't need a full alpha channel. There are - * "num_trans" transparency values for a paletted image, stored in the - * same order as the palette colors, starting from index 0. Values - * for the data are in the range [0, 255], ranging from fully transparent - * to fully opaque, respectively. For non-paletted images, there is a - * single color specified that should be treated as fully transparent. - * Data is valid if (valid & PNG_INFO_tRNS) is non-zero. - */ - png_bytep trans; /* transparent values for paletted image */ - png_color_16 trans_values; /* transparent color for non-palette image */ -#endif - -#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - /* The bKGD chunk gives the suggested image background color if the - * display program does not have its own background color and the image - * is needs to composited onto a background before display. The colors - * in "background" are normally in the same color space/depth as the - * pixel data. Data is valid if (valid & PNG_INFO_bKGD) is non-zero. - */ - png_color_16 background; -#endif - -#if defined(PNG_oFFs_SUPPORTED) - /* The oFFs chunk gives the offset in "offset_unit_type" units rightwards - * and downwards from the top-left corner of the display, page, or other - * application-specific co-ordinate space. See the PNG_OFFSET_ defines - * below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero. - */ - png_int_32 x_offset; /* x offset on page */ - png_int_32 y_offset; /* y offset on page */ - png_byte offset_unit_type; /* offset units type */ -#endif - -#if defined(PNG_pHYs_SUPPORTED) - /* The pHYs chunk gives the physical pixel density of the image for - * display or printing in "phys_unit_type" units (see PNG_RESOLUTION_ - * defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero. - */ - png_uint_32 x_pixels_per_unit; /* horizontal pixel density */ - png_uint_32 y_pixels_per_unit; /* vertical pixel density */ - png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */ -#endif - -#if defined(PNG_hIST_SUPPORTED) - /* The hIST chunk contains the relative frequency or importance of the - * various palette entries, so that a viewer can intelligently select a - * reduced-color palette, if required. Data is an array of "num_palette" - * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST) - * is non-zero. - */ - png_uint_16p hist; -#endif - -#ifdef PNG_cHRM_SUPPORTED - /* The cHRM chunk describes the CIE color characteristics of the monitor - * on which the PNG was created. This data allows the viewer to do gamut - * mapping of the input image to ensure that the viewer sees the same - * colors in the image as the creator. Values are in the range - * [0.0, 0.8]. Data valid if (valid & PNG_INFO_cHRM) non-zero. - */ -#ifdef PNG_FLOATING_POINT_SUPPORTED - float x_white; - float y_white; - float x_red; - float y_red; - float x_green; - float y_green; - float x_blue; - float y_blue; -#endif -#endif - -#if defined(PNG_pCAL_SUPPORTED) - /* The pCAL chunk describes a transformation between the stored pixel - * values and original physical data values used to create the image. - * The integer range [0, 2^bit_depth - 1] maps to the floating-point - * range given by [pcal_X0, pcal_X1], and are further transformed by a - * (possibly non-linear) transformation function given by "pcal_type" - * and "pcal_params" into "pcal_units". Please see the PNG_EQUATION_ - * defines below, and the PNG-Group's PNG extensions document for a - * complete description of the transformations and how they should be - * implemented, and for a description of the ASCII parameter strings. - * Data values are valid if (valid & PNG_INFO_pCAL) non-zero. - */ - png_charp pcal_purpose; /* pCAL chunk description string */ - png_int_32 pcal_X0; /* minimum value */ - png_int_32 pcal_X1; /* maximum value */ - png_charp pcal_units; /* Latin-1 string giving physical units */ - png_charpp pcal_params; /* ASCII strings containing parameter values */ - png_byte pcal_type; /* equation type (see PNG_EQUATION_ below) */ - png_byte pcal_nparams; /* number of parameters given in pcal_params */ -#endif - -/* New members added in libpng-1.0.6 */ -#ifdef PNG_FREE_ME_SUPPORTED - png_uint_32 free_me; /* flags items libpng is responsible for freeing */ -#endif - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - /* storage for unknown chunks that the library doesn't recognize. */ - png_unknown_chunkp unknown_chunks; - png_size_t unknown_chunks_num; -#endif - -#if defined(PNG_iCCP_SUPPORTED) - /* iCCP chunk data. */ - png_charp iccp_name; /* profile name */ - png_charp iccp_profile; /* International Color Consortium profile data */ - /* Note to maintainer: should be png_bytep */ - png_uint_32 iccp_proflen; /* ICC profile data length */ - png_byte iccp_compression; /* Always zero */ -#endif - -#if defined(PNG_sPLT_SUPPORTED) - /* data on sPLT chunks (there may be more than one). */ - png_sPLT_tp splt_palettes; - png_uint_32 splt_palettes_num; -#endif - -#if defined(PNG_sCAL_SUPPORTED) - /* The sCAL chunk describes the actual physical dimensions of the - * subject matter of the graphic. The chunk contains a unit specification - * a byte value, and two ASCII strings representing floating-point - * values. The values are width and height corresponsing to one pixel - * in the image. This external representation is converted to double - * here. Data values are valid if (valid & PNG_INFO_sCAL) is non-zero. - */ - png_byte scal_unit; /* unit of physical scale */ -#ifdef PNG_FLOATING_POINT_SUPPORTED - double scal_pixel_width; /* width of one pixel */ - double scal_pixel_height; /* height of one pixel */ -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - png_charp scal_s_width; /* string containing height */ - png_charp scal_s_height; /* string containing width */ -#endif -#endif - -#if defined(PNG_INFO_IMAGE_SUPPORTED) - /* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS) non-zero */ - /* Data valid if (valid & PNG_INFO_IDAT) non-zero */ - png_bytepp row_pointers; /* the image bits */ -#endif - -#if defined(PNG_FIXED_POINT_SUPPORTED) && defined(PNG_gAMA_SUPPORTED) - png_fixed_point int_gamma; /* gamma of image, if (valid & PNG_INFO_gAMA) */ -#endif - -#if defined(PNG_cHRM_SUPPORTED) && defined(PNG_FIXED_POINT_SUPPORTED) - png_fixed_point int_x_white; - png_fixed_point int_y_white; - png_fixed_point int_x_red; - png_fixed_point int_y_red; - png_fixed_point int_x_green; - png_fixed_point int_y_green; - png_fixed_point int_x_blue; - png_fixed_point int_y_blue; -#endif - -} png_info; - -typedef png_info FAR * png_infop; -typedef png_info FAR * FAR * png_infopp; - -/* Maximum positive integer used in PNG is (2^31)-1 */ -#define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL) -#define PNG_UINT_32_MAX ((png_uint_32)(-1)) -#define PNG_SIZE_MAX ((png_size_t)(-1)) -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* PNG_MAX_UINT is deprecated; use PNG_UINT_31_MAX instead. */ -#define PNG_MAX_UINT PNG_UINT_31_MAX -#endif - -/* These describe the color_type field in png_info. */ -/* color type masks */ -#define PNG_COLOR_MASK_PALETTE 1 -#define PNG_COLOR_MASK_COLOR 2 -#define PNG_COLOR_MASK_ALPHA 4 - -/* color types. Note that not all combinations are legal */ -#define PNG_COLOR_TYPE_GRAY 0 -#define PNG_COLOR_TYPE_PALETTE (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE) -#define PNG_COLOR_TYPE_RGB (PNG_COLOR_MASK_COLOR) -#define PNG_COLOR_TYPE_RGB_ALPHA (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA) -#define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA) -/* aliases */ -#define PNG_COLOR_TYPE_RGBA PNG_COLOR_TYPE_RGB_ALPHA -#define PNG_COLOR_TYPE_GA PNG_COLOR_TYPE_GRAY_ALPHA - -/* This is for compression type. PNG 1.0-1.2 only define the single type. */ -#define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */ -#define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE - -/* This is for filter type. PNG 1.0-1.2 only define the single type. */ -#define PNG_FILTER_TYPE_BASE 0 /* Single row per-byte filtering */ -#define PNG_INTRAPIXEL_DIFFERENCING 64 /* Used only in MNG datastreams */ -#define PNG_FILTER_TYPE_DEFAULT PNG_FILTER_TYPE_BASE - -/* These are for the interlacing type. These values should NOT be changed. */ -#define PNG_INTERLACE_NONE 0 /* Non-interlaced image */ -#define PNG_INTERLACE_ADAM7 1 /* Adam7 interlacing */ -#define PNG_INTERLACE_LAST 2 /* Not a valid value */ - -/* These are for the oFFs chunk. These values should NOT be changed. */ -#define PNG_OFFSET_PIXEL 0 /* Offset in pixels */ -#define PNG_OFFSET_MICROMETER 1 /* Offset in micrometers (1/10^6 meter) */ -#define PNG_OFFSET_LAST 2 /* Not a valid value */ - -/* These are for the pCAL chunk. These values should NOT be changed. */ -#define PNG_EQUATION_LINEAR 0 /* Linear transformation */ -#define PNG_EQUATION_BASE_E 1 /* Exponential base e transform */ -#define PNG_EQUATION_ARBITRARY 2 /* Arbitrary base exponential transform */ -#define PNG_EQUATION_HYPERBOLIC 3 /* Hyperbolic sine transformation */ -#define PNG_EQUATION_LAST 4 /* Not a valid value */ - -/* These are for the sCAL chunk. These values should NOT be changed. */ -#define PNG_SCALE_UNKNOWN 0 /* unknown unit (image scale) */ -#define PNG_SCALE_METER 1 /* meters per pixel */ -#define PNG_SCALE_RADIAN 2 /* radians per pixel */ -#define PNG_SCALE_LAST 3 /* Not a valid value */ - -/* These are for the pHYs chunk. These values should NOT be changed. */ -#define PNG_RESOLUTION_UNKNOWN 0 /* pixels/unknown unit (aspect ratio) */ -#define PNG_RESOLUTION_METER 1 /* pixels/meter */ -#define PNG_RESOLUTION_LAST 2 /* Not a valid value */ - -/* These are for the sRGB chunk. These values should NOT be changed. */ -#define PNG_sRGB_INTENT_PERCEPTUAL 0 -#define PNG_sRGB_INTENT_RELATIVE 1 -#define PNG_sRGB_INTENT_SATURATION 2 -#define PNG_sRGB_INTENT_ABSOLUTE 3 -#define PNG_sRGB_INTENT_LAST 4 /* Not a valid value */ - -/* This is for text chunks */ -#define PNG_KEYWORD_MAX_LENGTH 79 - -/* Maximum number of entries in PLTE/sPLT/tRNS arrays */ -#define PNG_MAX_PALETTE_LENGTH 256 - -/* These determine if an ancillary chunk's data has been successfully read - * from the PNG header, or if the application has filled in the corresponding - * data in the info_struct to be written into the output file. The values - * of the PNG_INFO_<chunk> defines should NOT be changed. - */ -#define PNG_INFO_gAMA 0x0001 -#define PNG_INFO_sBIT 0x0002 -#define PNG_INFO_cHRM 0x0004 -#define PNG_INFO_PLTE 0x0008 -#define PNG_INFO_tRNS 0x0010 -#define PNG_INFO_bKGD 0x0020 -#define PNG_INFO_hIST 0x0040 -#define PNG_INFO_pHYs 0x0080 -#define PNG_INFO_oFFs 0x0100 -#define PNG_INFO_tIME 0x0200 -#define PNG_INFO_pCAL 0x0400 -#define PNG_INFO_sRGB 0x0800 /* GR-P, 0.96a */ -#define PNG_INFO_iCCP 0x1000 /* ESR, 1.0.6 */ -#define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */ -#define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */ -#define PNG_INFO_IDAT 0x8000L /* ESR, 1.0.6 */ - -/* This is used for the transformation routines, as some of them - * change these values for the row. It also should enable using - * the routines for other purposes. - */ -typedef struct png_row_info_struct -{ - png_uint_32 width; /* width of row */ - png_uint_32 rowbytes; /* number of bytes in row */ - png_byte color_type; /* color type of row */ - png_byte bit_depth; /* bit depth of row */ - png_byte channels; /* number of channels (1, 2, 3, or 4) */ - png_byte pixel_depth; /* bits per pixel (depth * channels) */ -} png_row_info; - -typedef png_row_info FAR * png_row_infop; -typedef png_row_info FAR * FAR * png_row_infopp; - -/* These are the function types for the I/O functions and for the functions - * that allow the user to override the default I/O functions with his or her - * own. The png_error_ptr type should match that of user-supplied warning - * and error functions, while the png_rw_ptr type should match that of the - * user read/write data functions. - */ -typedef struct png_struct_def png_struct; -typedef png_struct FAR * png_structp; - -typedef void (PNGAPI *png_error_ptr) PNGARG((png_structp, png_const_charp)); -typedef void (PNGAPI *png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t)); -typedef void (PNGAPI *png_flush_ptr) PNGARG((png_structp)); -typedef void (PNGAPI *png_read_status_ptr) PNGARG((png_structp, png_uint_32, - int)); -typedef void (PNGAPI *png_write_status_ptr) PNGARG((png_structp, png_uint_32, - int)); - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -typedef void (PNGAPI *png_progressive_info_ptr) PNGARG((png_structp, png_infop)); -typedef void (PNGAPI *png_progressive_end_ptr) PNGARG((png_structp, png_infop)); -typedef void (PNGAPI *png_progressive_row_ptr) PNGARG((png_structp, png_bytep, - png_uint_32, int)); -#endif - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -typedef void (PNGAPI *png_user_transform_ptr) PNGARG((png_structp, - png_row_infop, png_bytep)); -#endif - -#if defined(PNG_USER_CHUNKS_SUPPORTED) -typedef int (PNGAPI *png_user_chunk_ptr) PNGARG((png_structp, png_unknown_chunkp)); -#endif -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -typedef void (PNGAPI *png_unknown_chunk_ptr) PNGARG((png_structp)); -#endif - -/* Transform masks for the high-level interface */ -#define PNG_TRANSFORM_IDENTITY 0x0000 /* read and write */ -#define PNG_TRANSFORM_STRIP_16 0x0001 /* read only */ -#define PNG_TRANSFORM_STRIP_ALPHA 0x0002 /* read only */ -#define PNG_TRANSFORM_PACKING 0x0004 /* read and write */ -#define PNG_TRANSFORM_PACKSWAP 0x0008 /* read and write */ -#define PNG_TRANSFORM_EXPAND 0x0010 /* read only */ -#define PNG_TRANSFORM_INVERT_MONO 0x0020 /* read and write */ -#define PNG_TRANSFORM_SHIFT 0x0040 /* read and write */ -#define PNG_TRANSFORM_BGR 0x0080 /* read and write */ -#define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */ -#define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */ -#define PNG_TRANSFORM_INVERT_ALPHA 0x0400 /* read and write */ -#define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* WRITE only */ - -/* Flags for MNG supported features */ -#define PNG_FLAG_MNG_EMPTY_PLTE 0x01 -#define PNG_FLAG_MNG_FILTER_64 0x04 -#define PNG_ALL_MNG_FEATURES 0x05 - -typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_size_t)); -typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp)); - -/* The structure that holds the information to read and write PNG files. - * The only people who need to care about what is inside of this are the - * people who will be modifying the library for their own special needs. - * It should NOT be accessed directly by an application, except to store - * the jmp_buf. - */ - -struct png_struct_def -{ -#ifdef PNG_SETJMP_SUPPORTED - jmp_buf jmpbuf; /* used in png_error */ -#endif - png_error_ptr error_fn; /* function for printing errors and aborting */ - png_error_ptr warning_fn; /* function for printing warnings */ - png_voidp error_ptr; /* user supplied struct for error functions */ - png_rw_ptr write_data_fn; /* function for writing output data */ - png_rw_ptr read_data_fn; /* function for reading input data */ - png_voidp io_ptr; /* ptr to application struct for I/O functions */ - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - png_user_transform_ptr read_user_transform_fn; /* user read transform */ -#endif - -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) - png_user_transform_ptr write_user_transform_fn; /* user write transform */ -#endif - -/* These were added in libpng-1.0.2 */ -#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) - png_voidp user_transform_ptr; /* user supplied struct for user transform */ - png_byte user_transform_depth; /* bit depth of user transformed pixels */ - png_byte user_transform_channels; /* channels in user transformed pixels */ -#endif -#endif - - png_uint_32 mode; /* tells us where we are in the PNG file */ - png_uint_32 flags; /* flags indicating various things to libpng */ - png_uint_32 transformations; /* which transformations to perform */ - - z_stream zstream; /* pointer to decompression structure (below) */ - png_bytep zbuf; /* buffer for zlib */ - png_size_t zbuf_size; /* size of zbuf */ - int zlib_level; /* holds zlib compression level */ - int zlib_method; /* holds zlib compression method */ - int zlib_window_bits; /* holds zlib compression window bits */ - int zlib_mem_level; /* holds zlib compression memory level */ - int zlib_strategy; /* holds zlib compression strategy */ - - png_uint_32 width; /* width of image in pixels */ - png_uint_32 height; /* height of image in pixels */ - png_uint_32 num_rows; /* number of rows in current pass */ - png_uint_32 usr_width; /* width of row at start of write */ - png_uint_32 rowbytes; /* size of row in bytes */ - png_uint_32 irowbytes; /* size of current interlaced row in bytes */ - png_uint_32 iwidth; /* width of current interlaced row in pixels */ - png_uint_32 row_number; /* current row in interlace pass */ - png_bytep prev_row; /* buffer to save previous (unfiltered) row */ - png_bytep row_buf; /* buffer to save current (unfiltered) row */ - png_bytep sub_row; /* buffer to save "sub" row when filtering */ - png_bytep up_row; /* buffer to save "up" row when filtering */ - png_bytep avg_row; /* buffer to save "avg" row when filtering */ - png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */ - png_row_info row_info; /* used for transformation routines */ - - png_uint_32 idat_size; /* current IDAT size for read */ - png_uint_32 crc; /* current chunk CRC value */ - png_colorp palette; /* palette from the input file */ - png_uint_16 num_palette; /* number of color entries in palette */ - png_uint_16 num_trans; /* number of transparency values */ - png_byte chunk_name[5]; /* null-terminated name of current chunk */ - png_byte compression; /* file compression type (always 0) */ - png_byte filter; /* file filter type (always 0) */ - png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ - png_byte pass; /* current interlace pass (0 - 6) */ - png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */ - png_byte color_type; /* color type of file */ - png_byte bit_depth; /* bit depth of file */ - png_byte usr_bit_depth; /* bit depth of users row */ - png_byte pixel_depth; /* number of bits per pixel */ - png_byte channels; /* number of channels in file */ - png_byte usr_channels; /* channels at start of write */ - png_byte sig_bytes; /* magic bytes read/written from start of file */ - -#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) -#ifdef PNG_LEGACY_SUPPORTED - png_byte filler; /* filler byte for pixel expansion */ -#else - png_uint_16 filler; /* filler bytes for pixel expansion */ -#endif -#endif - -#if defined(PNG_bKGD_SUPPORTED) - png_byte background_gamma_type; -# ifdef PNG_FLOATING_POINT_SUPPORTED - float background_gamma; -# endif - png_color_16 background; /* background color in screen gamma space */ -#if defined(PNG_READ_GAMMA_SUPPORTED) - png_color_16 background_1; /* background normalized to gamma 1.0 */ -#endif -#endif /* PNG_bKGD_SUPPORTED */ - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) - png_flush_ptr output_flush_fn;/* Function for flushing output */ - png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */ - png_uint_32 flush_rows; /* number of rows written since last flush */ -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - int gamma_shift; /* number of "insignificant" bits 16-bit gamma */ -#ifdef PNG_FLOATING_POINT_SUPPORTED - float gamma; /* file gamma value */ - float screen_gamma; /* screen gamma value (display_exponent) */ -#endif -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - png_bytep gamma_table; /* gamma table for 8-bit depth files */ - png_bytep gamma_from_1; /* converts from 1.0 to screen */ - png_bytep gamma_to_1; /* converts from file to 1.0 */ - png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */ - png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */ - png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */ -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED) - png_color_8 sig_bit; /* significant bits in each available channel */ -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) - png_color_8 shift; /* shift for significant bit tranformation */ -#endif - -#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \ - || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - png_bytep trans; /* transparency values for paletted files */ - png_color_16 trans_values; /* transparency values for non-paletted files */ -#endif - - png_read_status_ptr read_row_fn; /* called after each row is decoded */ - png_write_status_ptr write_row_fn; /* called after each row is encoded */ -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED - png_progressive_info_ptr info_fn; /* called after header data fully read */ - png_progressive_row_ptr row_fn; /* called after each prog. row is decoded */ - png_progressive_end_ptr end_fn; /* called after image is complete */ - png_bytep save_buffer_ptr; /* current location in save_buffer */ - png_bytep save_buffer; /* buffer for previously read data */ - png_bytep current_buffer_ptr; /* current location in current_buffer */ - png_bytep current_buffer; /* buffer for recently used data */ - png_uint_32 push_length; /* size of current input chunk */ - png_uint_32 skip_length; /* bytes to skip in input data */ - png_size_t save_buffer_size; /* amount of data now in save_buffer */ - png_size_t save_buffer_max; /* total size of save_buffer */ - png_size_t buffer_size; /* total amount of available input data */ - png_size_t current_buffer_size; /* amount of data now in current_buffer */ - int process_mode; /* what push library is currently doing */ - int cur_palette; /* current push library palette index */ - -# if defined(PNG_TEXT_SUPPORTED) - png_size_t current_text_size; /* current size of text input data */ - png_size_t current_text_left; /* how much text left to read in input */ - png_charp current_text; /* current text chunk buffer */ - png_charp current_text_ptr; /* current location in current_text */ -# endif /* PNG_PROGRESSIVE_READ_SUPPORTED && PNG_TEXT_SUPPORTED */ - -#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ - -#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) -/* for the Borland special 64K segment handler */ - png_bytepp offset_table_ptr; - png_bytep offset_table; - png_uint_16 offset_table_number; - png_uint_16 offset_table_count; - png_uint_16 offset_table_count_free; -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) - png_bytep palette_lookup; /* lookup table for dithering */ - png_bytep dither_index; /* index translation for palette files */ -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) || defined(PNG_hIST_SUPPORTED) - png_uint_16p hist; /* histogram */ -#endif - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - png_byte heuristic_method; /* heuristic for row filter selection */ - png_byte num_prev_filters; /* number of weights for previous rows */ - png_bytep prev_filters; /* filter type(s) of previous row(s) */ - png_uint_16p filter_weights; /* weight(s) for previous line(s) */ - png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */ - png_uint_16p filter_costs; /* relative filter calculation cost */ - png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */ -#endif - -#if defined(PNG_TIME_RFC1123_SUPPORTED) - png_charp time_buffer; /* String to hold RFC 1123 time text */ -#endif - -/* New members added in libpng-1.0.6 */ - -#ifdef PNG_FREE_ME_SUPPORTED - png_uint_32 free_me; /* flags items libpng is responsible for freeing */ -#endif - -#if defined(PNG_USER_CHUNKS_SUPPORTED) - png_voidp user_chunk_ptr; - png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */ -#endif - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - int num_chunk_list; - png_bytep chunk_list; -#endif - -/* New members added in libpng-1.0.3 */ -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - png_byte rgb_to_gray_status; - /* These were changed from png_byte in libpng-1.0.6 */ - png_uint_16 rgb_to_gray_red_coeff; - png_uint_16 rgb_to_gray_green_coeff; - png_uint_16 rgb_to_gray_blue_coeff; -#endif - -/* New member added in libpng-1.0.4 (renamed in 1.0.9) */ -#if defined(PNG_MNG_FEATURES_SUPPORTED) || \ - defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ - defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) -/* changed from png_byte to png_uint_32 at version 1.2.0 */ -#ifdef PNG_1_0_X - png_byte mng_features_permitted; -#else - png_uint_32 mng_features_permitted; -#endif /* PNG_1_0_X */ -#endif - -/* New member added in libpng-1.0.7 */ -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - png_fixed_point int_gamma; -#endif - -/* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */ -#if defined(PNG_MNG_FEATURES_SUPPORTED) - png_byte filter_type; -#endif - -#if defined(PNG_1_0_X) || (defined(PNG_DEBUG) && defined(PNG_USE_PNGGCCRD)) -/* New member added in libpng-1.0.10, ifdef'ed out in 1.2.0 */ - png_uint_32 row_buf_size; -#endif - -/* New members added in libpng-1.2.0 */ -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) -# if !defined(PNG_1_0_X) -# if defined(PNG_MMX_CODE_SUPPORTED) - png_byte mmx_bitdepth_threshold; - png_uint_32 mmx_rowbytes_threshold; -# endif - png_uint_32 asm_flags; -# endif -#endif - -/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */ -#ifdef PNG_USER_MEM_SUPPORTED - png_voidp mem_ptr; /* user supplied struct for mem functions */ - png_malloc_ptr malloc_fn; /* function for allocating memory */ - png_free_ptr free_fn; /* function for freeing memory */ -#endif - -/* New member added in libpng-1.0.13 and 1.2.0 */ - png_bytep big_row_buf; /* buffer to save current (unfiltered) row */ - -#if defined(PNG_READ_DITHER_SUPPORTED) -/* The following three members were added at version 1.0.14 and 1.2.4 */ - png_bytep dither_sort; /* working sort array */ - png_bytep index_to_palette; /* where the original index currently is */ - /* in the palette */ - png_bytep palette_to_index; /* which original index points to this */ - /* palette color */ -#endif - -/* New members added in libpng-1.0.16 and 1.2.6 */ - png_byte compression_type; - -#ifdef PNG_SET_USER_LIMITS_SUPPORTED - png_uint_32 user_width_max; - png_uint_32 user_height_max; -#endif - -}; - - -/* This triggers a compiler error in png.c, if png.c and png.h - * do not agree upon the version number. - */ -typedef png_structp version_1_2_16; - -typedef png_struct FAR * FAR * png_structpp; - -/* Here are the function definitions most commonly used. This is not - * the place to find out how to use libpng. See libpng.txt for the - * full explanation, see example.c for the summary. This just provides - * a simple one line description of the use of each function. - */ - -/* Returns the version number of the library */ -extern PNG_EXPORT(png_uint_32,png_access_version_number) PNGARG((void)); - -/* Tell lib we have already handled the first <num_bytes> magic bytes. - * Handling more than 8 bytes from the beginning of the file is an error. - */ -extern PNG_EXPORT(void,png_set_sig_bytes) PNGARG((png_structp png_ptr, - int num_bytes)); - -/* Check sig[start] through sig[start + num_to_check - 1] to see if it's a - * PNG file. Returns zero if the supplied bytes match the 8-byte PNG - * signature, and non-zero otherwise. Having num_to_check == 0 or - * start > 7 will always fail (ie return non-zero). - */ -extern PNG_EXPORT(int,png_sig_cmp) PNGARG((png_bytep sig, png_size_t start, - png_size_t num_to_check)); - -/* Simple signature checking function. This is the same as calling - * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n). - */ -extern PNG_EXPORT(int,png_check_sig) PNGARG((png_bytep sig, int num)); - -/* Allocate and initialize png_ptr struct for reading, and any other memory. */ -extern PNG_EXPORT(png_structp,png_create_read_struct) - PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn)); - -/* Allocate and initialize png_ptr struct for writing, and any other memory */ -extern PNG_EXPORT(png_structp,png_create_write_struct) - PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn)); - -#ifdef PNG_WRITE_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_compression_buffer_size) - PNGARG((png_structp png_ptr)); -#endif - -#ifdef PNG_WRITE_SUPPORTED -extern PNG_EXPORT(void,png_set_compression_buffer_size) - PNGARG((png_structp png_ptr, png_uint_32 size)); -#endif - -/* Reset the compression stream */ -extern PNG_EXPORT(int,png_reset_zstream) PNGARG((png_structp png_ptr)); - -/* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */ -#ifdef PNG_USER_MEM_SUPPORTED -extern PNG_EXPORT(png_structp,png_create_read_struct_2) - PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn)); -extern PNG_EXPORT(png_structp,png_create_write_struct_2) - PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn)); -#endif - -/* Write a PNG chunk - size, type, (optional) data, CRC. */ -extern PNG_EXPORT(void,png_write_chunk) PNGARG((png_structp png_ptr, - png_bytep chunk_name, png_bytep data, png_size_t length)); - -/* Write the start of a PNG chunk - length and chunk name. */ -extern PNG_EXPORT(void,png_write_chunk_start) PNGARG((png_structp png_ptr, - png_bytep chunk_name, png_uint_32 length)); - -/* Write the data of a PNG chunk started with png_write_chunk_start(). */ -extern PNG_EXPORT(void,png_write_chunk_data) PNGARG((png_structp png_ptr, - png_bytep data, png_size_t length)); - -/* Finish a chunk started with png_write_chunk_start() (includes CRC). */ -extern PNG_EXPORT(void,png_write_chunk_end) PNGARG((png_structp png_ptr)); - -/* Allocate and initialize the info structure */ -extern PNG_EXPORT(png_infop,png_create_info_struct) - PNGARG((png_structp png_ptr)); - -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* Initialize the info structure (old interface - DEPRECATED) */ -extern PNG_EXPORT(void,png_info_init) PNGARG((png_infop info_ptr)); -#undef png_info_init -#define png_info_init(info_ptr) png_info_init_3(&info_ptr,\ - png_sizeof(png_info)); -#endif - -extern PNG_EXPORT(void,png_info_init_3) PNGARG((png_infopp info_ptr, - png_size_t png_info_struct_size)); - -/* Writes all the PNG information before the image. */ -extern PNG_EXPORT(void,png_write_info_before_PLTE) PNGARG((png_structp png_ptr, - png_infop info_ptr)); -extern PNG_EXPORT(void,png_write_info) PNGARG((png_structp png_ptr, - png_infop info_ptr)); - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* read the information before the actual image data. */ -extern PNG_EXPORT(void,png_read_info) PNGARG((png_structp png_ptr, - png_infop info_ptr)); -#endif - -#if defined(PNG_TIME_RFC1123_SUPPORTED) -extern PNG_EXPORT(png_charp,png_convert_to_rfc1123) - PNGARG((png_structp png_ptr, png_timep ptime)); -#endif - -#if !defined(_WIN32_WCE) -/* "time.h" functions are not supported on WindowsCE */ -#if defined(PNG_WRITE_tIME_SUPPORTED) -/* convert from a struct tm to png_time */ -extern PNG_EXPORT(void,png_convert_from_struct_tm) PNGARG((png_timep ptime, - struct tm FAR * ttime)); - -/* convert from time_t to png_time. Uses gmtime() */ -extern PNG_EXPORT(void,png_convert_from_time_t) PNGARG((png_timep ptime, - time_t ttime)); -#endif /* PNG_WRITE_tIME_SUPPORTED */ -#endif /* _WIN32_WCE */ - -#if defined(PNG_READ_EXPAND_SUPPORTED) -/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */ -extern PNG_EXPORT(void,png_set_expand) PNGARG((png_structp png_ptr)); -#if !defined(PNG_1_0_X) -extern PNG_EXPORT(void,png_set_expand_gray_1_2_4_to_8) PNGARG((png_structp - png_ptr)); -#endif -extern PNG_EXPORT(void,png_set_palette_to_rgb) PNGARG((png_structp png_ptr)); -extern PNG_EXPORT(void,png_set_tRNS_to_alpha) PNGARG((png_structp png_ptr)); -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* Deprecated */ -extern PNG_EXPORT(void,png_set_gray_1_2_4_to_8) PNGARG((png_structp png_ptr)); -#endif -#endif - -#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -/* Use blue, green, red order for pixels. */ -extern PNG_EXPORT(void,png_set_bgr) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) -/* Expand the grayscale to 24-bit RGB if necessary. */ -extern PNG_EXPORT(void,png_set_gray_to_rgb) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) -/* Reduce RGB to grayscale. */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_rgb_to_gray) PNGARG((png_structp png_ptr, - int error_action, double red, double green )); -#endif -extern PNG_EXPORT(void,png_set_rgb_to_gray_fixed) PNGARG((png_structp png_ptr, - int error_action, png_fixed_point red, png_fixed_point green )); -extern PNG_EXPORT(png_byte,png_get_rgb_to_gray_status) PNGARG((png_structp - png_ptr)); -#endif - -extern PNG_EXPORT(void,png_build_grayscale_palette) PNGARG((int bit_depth, - png_colorp palette)); - -#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) -extern PNG_EXPORT(void,png_set_strip_alpha) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ - defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) -extern PNG_EXPORT(void,png_set_swap_alpha) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ - defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) -extern PNG_EXPORT(void,png_set_invert_alpha) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) -/* Add a filler byte to 8-bit Gray or 24-bit RGB images. */ -extern PNG_EXPORT(void,png_set_filler) PNGARG((png_structp png_ptr, - png_uint_32 filler, int flags)); -/* The values of the PNG_FILLER_ defines should NOT be changed */ -#define PNG_FILLER_BEFORE 0 -#define PNG_FILLER_AFTER 1 -/* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */ -#if !defined(PNG_1_0_X) -extern PNG_EXPORT(void,png_set_add_alpha) PNGARG((png_structp png_ptr, - png_uint_32 filler, int flags)); -#endif -#endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */ - -#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) -/* Swap bytes in 16-bit depth files. */ -extern PNG_EXPORT(void,png_set_swap) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) -/* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */ -extern PNG_EXPORT(void,png_set_packing) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED) -/* Swap packing order of pixels in bytes. */ -extern PNG_EXPORT(void,png_set_packswap) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) -/* Converts files to legal bit depths. */ -extern PNG_EXPORT(void,png_set_shift) PNGARG((png_structp png_ptr, - png_color_8p true_bits)); -#endif - -#if defined(PNG_READ_INTERLACING_SUPPORTED) || \ - defined(PNG_WRITE_INTERLACING_SUPPORTED) -/* Have the code handle the interlacing. Returns the number of passes. */ -extern PNG_EXPORT(int,png_set_interlace_handling) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) -/* Invert monochrome files */ -extern PNG_EXPORT(void,png_set_invert_mono) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) -/* Handle alpha and tRNS by replacing with a background color. */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_background) PNGARG((png_structp png_ptr, - png_color_16p background_color, int background_gamma_code, - int need_expand, double background_gamma)); -#endif -#define PNG_BACKGROUND_GAMMA_UNKNOWN 0 -#define PNG_BACKGROUND_GAMMA_SCREEN 1 -#define PNG_BACKGROUND_GAMMA_FILE 2 -#define PNG_BACKGROUND_GAMMA_UNIQUE 3 -#endif - -#if defined(PNG_READ_16_TO_8_SUPPORTED) -/* strip the second byte of information from a 16-bit depth file. */ -extern PNG_EXPORT(void,png_set_strip_16) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) -/* Turn on dithering, and reduce the palette to the number of colors available. */ -extern PNG_EXPORT(void,png_set_dither) PNGARG((png_structp png_ptr, - png_colorp palette, int num_palette, int maximum_colors, - png_uint_16p histogram, int full_dither)); -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) -/* Handle gamma correction. Screen_gamma=(display_exponent) */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_gamma) PNGARG((png_structp png_ptr, - double screen_gamma, double default_file_gamma)); -#endif -#endif - -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ - defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) -/* Permit or disallow empty PLTE (0: not permitted, 1: permitted) */ -/* Deprecated and will be removed. Use png_permit_mng_features() instead. */ -extern PNG_EXPORT(void,png_permit_empty_plte) PNGARG((png_structp png_ptr, - int empty_plte_permitted)); -#endif -#endif - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -/* Set how many lines between output flushes - 0 for no flushing */ -extern PNG_EXPORT(void,png_set_flush) PNGARG((png_structp png_ptr, int nrows)); -/* Flush the current PNG output buffer */ -extern PNG_EXPORT(void,png_write_flush) PNGARG((png_structp png_ptr)); -#endif - -/* optional update palette with requested transformations */ -extern PNG_EXPORT(void,png_start_read_image) PNGARG((png_structp png_ptr)); - -/* optional call to update the users info structure */ -extern PNG_EXPORT(void,png_read_update_info) PNGARG((png_structp png_ptr, - png_infop info_ptr)); - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* read one or more rows of image data. */ -extern PNG_EXPORT(void,png_read_rows) PNGARG((png_structp png_ptr, - png_bytepp row, png_bytepp display_row, png_uint_32 num_rows)); -#endif - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* read a row of data. */ -extern PNG_EXPORT(void,png_read_row) PNGARG((png_structp png_ptr, - png_bytep row, - png_bytep display_row)); -#endif - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* read the whole image into memory at once. */ -extern PNG_EXPORT(void,png_read_image) PNGARG((png_structp png_ptr, - png_bytepp image)); -#endif - -/* write a row of image data */ -extern PNG_EXPORT(void,png_write_row) PNGARG((png_structp png_ptr, - png_bytep row)); - -/* write a few rows of image data */ -extern PNG_EXPORT(void,png_write_rows) PNGARG((png_structp png_ptr, - png_bytepp row, png_uint_32 num_rows)); - -/* write the image data */ -extern PNG_EXPORT(void,png_write_image) PNGARG((png_structp png_ptr, - png_bytepp image)); - -/* writes the end of the PNG file. */ -extern PNG_EXPORT(void,png_write_end) PNGARG((png_structp png_ptr, - png_infop info_ptr)); - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* read the end of the PNG file. */ -extern PNG_EXPORT(void,png_read_end) PNGARG((png_structp png_ptr, - png_infop info_ptr)); -#endif - -/* free any memory associated with the png_info_struct */ -extern PNG_EXPORT(void,png_destroy_info_struct) PNGARG((png_structp png_ptr, - png_infopp info_ptr_ptr)); - -/* free any memory associated with the png_struct and the png_info_structs */ -extern PNG_EXPORT(void,png_destroy_read_struct) PNGARG((png_structpp - png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)); - -/* free all memory used by the read (old method - NOT DLL EXPORTED) */ -extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr, - png_infop end_info_ptr)); - -/* free any memory associated with the png_struct and the png_info_structs */ -extern PNG_EXPORT(void,png_destroy_write_struct) - PNGARG((png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)); - -/* free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */ -extern void png_write_destroy PNGARG((png_structp png_ptr)); - -/* set the libpng method of handling chunk CRC errors */ -extern PNG_EXPORT(void,png_set_crc_action) PNGARG((png_structp png_ptr, - int crit_action, int ancil_action)); - -/* Values for png_set_crc_action() to say how to handle CRC errors in - * ancillary and critical chunks, and whether to use the data contained - * therein. Note that it is impossible to "discard" data in a critical - * chunk. For versions prior to 0.90, the action was always error/quit, - * whereas in version 0.90 and later, the action for CRC errors in ancillary - * chunks is warn/discard. These values should NOT be changed. - * - * value action:critical action:ancillary - */ -#define PNG_CRC_DEFAULT 0 /* error/quit warn/discard data */ -#define PNG_CRC_ERROR_QUIT 1 /* error/quit error/quit */ -#define PNG_CRC_WARN_DISCARD 2 /* (INVALID) warn/discard data */ -#define PNG_CRC_WARN_USE 3 /* warn/use data warn/use data */ -#define PNG_CRC_QUIET_USE 4 /* quiet/use data quiet/use data */ -#define PNG_CRC_NO_CHANGE 5 /* use current value use current value */ - -/* These functions give the user control over the scan-line filtering in - * libpng and the compression methods used by zlib. These functions are - * mainly useful for testing, as the defaults should work with most users. - * Those users who are tight on memory or want faster performance at the - * expense of compression can modify them. See the compression library - * header file (zlib.h) for an explination of the compression functions. - */ - -/* set the filtering method(s) used by libpng. Currently, the only valid - * value for "method" is 0. - */ -extern PNG_EXPORT(void,png_set_filter) PNGARG((png_structp png_ptr, int method, - int filters)); - -/* Flags for png_set_filter() to say which filters to use. The flags - * are chosen so that they don't conflict with real filter types - * below, in case they are supplied instead of the #defined constants. - * These values should NOT be changed. - */ -#define PNG_NO_FILTERS 0x00 -#define PNG_FILTER_NONE 0x08 -#define PNG_FILTER_SUB 0x10 -#define PNG_FILTER_UP 0x20 -#define PNG_FILTER_AVG 0x40 -#define PNG_FILTER_PAETH 0x80 -#define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \ - PNG_FILTER_AVG | PNG_FILTER_PAETH) - -/* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now. - * These defines should NOT be changed. - */ -#define PNG_FILTER_VALUE_NONE 0 -#define PNG_FILTER_VALUE_SUB 1 -#define PNG_FILTER_VALUE_UP 2 -#define PNG_FILTER_VALUE_AVG 3 -#define PNG_FILTER_VALUE_PAETH 4 -#define PNG_FILTER_VALUE_LAST 5 - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* EXPERIMENTAL */ -/* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_ - * defines, either the default (minimum-sum-of-absolute-differences), or - * the experimental method (weighted-minimum-sum-of-absolute-differences). - * - * Weights are factors >= 1.0, indicating how important it is to keep the - * filter type consistent between rows. Larger numbers mean the current - * filter is that many times as likely to be the same as the "num_weights" - * previous filters. This is cumulative for each previous row with a weight. - * There needs to be "num_weights" values in "filter_weights", or it can be - * NULL if the weights aren't being specified. Weights have no influence on - * the selection of the first row filter. Well chosen weights can (in theory) - * improve the compression for a given image. - * - * Costs are factors >= 1.0 indicating the relative decoding costs of a - * filter type. Higher costs indicate more decoding expense, and are - * therefore less likely to be selected over a filter with lower computational - * costs. There needs to be a value in "filter_costs" for each valid filter - * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't - * setting the costs. Costs try to improve the speed of decompression without - * unduly increasing the compressed image size. - * - * A negative weight or cost indicates the default value is to be used, and - * values in the range [0.0, 1.0) indicate the value is to remain unchanged. - * The default values for both weights and costs are currently 1.0, but may - * change if good general weighting/cost heuristics can be found. If both - * the weights and costs are set to 1.0, this degenerates the WEIGHTED method - * to the UNWEIGHTED method, but with added encoding time/computation. - */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_filter_heuristics) PNGARG((png_structp png_ptr, - int heuristic_method, int num_weights, png_doublep filter_weights, - png_doublep filter_costs)); -#endif -#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */ - -/* Heuristic used for row filter selection. These defines should NOT be - * changed. - */ -#define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */ -#define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */ -#define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */ -#define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */ - -/* Set the library compression level. Currently, valid values range from - * 0 - 9, corresponding directly to the zlib compression levels 0 - 9 - * (0 - no compression, 9 - "maximal" compression). Note that tests have - * shown that zlib compression levels 3-6 usually perform as well as level 9 - * for PNG images, and do considerably fewer caclulations. In the future, - * these values may not correspond directly to the zlib compression levels. - */ -extern PNG_EXPORT(void,png_set_compression_level) PNGARG((png_structp png_ptr, - int level)); - -extern PNG_EXPORT(void,png_set_compression_mem_level) - PNGARG((png_structp png_ptr, int mem_level)); - -extern PNG_EXPORT(void,png_set_compression_strategy) - PNGARG((png_structp png_ptr, int strategy)); - -extern PNG_EXPORT(void,png_set_compression_window_bits) - PNGARG((png_structp png_ptr, int window_bits)); - -extern PNG_EXPORT(void,png_set_compression_method) PNGARG((png_structp png_ptr, - int method)); - -/* These next functions are called for input/output, memory, and error - * handling. They are in the file pngrio.c, pngwio.c, and pngerror.c, - * and call standard C I/O routines such as fread(), fwrite(), and - * fprintf(). These functions can be made to use other I/O routines - * at run time for those applications that need to handle I/O in a - * different manner by calling png_set_???_fn(). See libpng.txt for - * more information. - */ - -#if !defined(PNG_NO_STDIO) -/* Initialize the input/output for the PNG file to the default functions. */ -extern PNG_EXPORT(void,png_init_io) PNGARG((png_structp png_ptr, png_FILE_p fp)); -#endif - -/* Replace the (error and abort), and warning functions with user - * supplied functions. If no messages are to be printed you must still - * write and use replacement functions. The replacement error_fn should - * still do a longjmp to the last setjmp location if you are using this - * method of error handling. If error_fn or warning_fn is NULL, the - * default function will be used. - */ - -extern PNG_EXPORT(void,png_set_error_fn) PNGARG((png_structp png_ptr, - png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn)); - -/* Return the user pointer associated with the error functions */ -extern PNG_EXPORT(png_voidp,png_get_error_ptr) PNGARG((png_structp png_ptr)); - -/* Replace the default data output functions with a user supplied one(s). - * If buffered output is not used, then output_flush_fn can be set to NULL. - * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time - * output_flush_fn will be ignored (and thus can be NULL). - */ -extern PNG_EXPORT(void,png_set_write_fn) PNGARG((png_structp png_ptr, - png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)); - -/* Replace the default data input function with a user supplied one. */ -extern PNG_EXPORT(void,png_set_read_fn) PNGARG((png_structp png_ptr, - png_voidp io_ptr, png_rw_ptr read_data_fn)); - -/* Return the user pointer associated with the I/O functions */ -extern PNG_EXPORT(png_voidp,png_get_io_ptr) PNGARG((png_structp png_ptr)); - -extern PNG_EXPORT(void,png_set_read_status_fn) PNGARG((png_structp png_ptr, - png_read_status_ptr read_row_fn)); - -extern PNG_EXPORT(void,png_set_write_status_fn) PNGARG((png_structp png_ptr, - png_write_status_ptr write_row_fn)); - -#ifdef PNG_USER_MEM_SUPPORTED -/* Replace the default memory allocation functions with user supplied one(s). */ -extern PNG_EXPORT(void,png_set_mem_fn) PNGARG((png_structp png_ptr, - png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)); -/* Return the user pointer associated with the memory functions */ -extern PNG_EXPORT(png_voidp,png_get_mem_ptr) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -extern PNG_EXPORT(void,png_set_read_user_transform_fn) PNGARG((png_structp - png_ptr, png_user_transform_ptr read_user_transform_fn)); -#endif - -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -extern PNG_EXPORT(void,png_set_write_user_transform_fn) PNGARG((png_structp - png_ptr, png_user_transform_ptr write_user_transform_fn)); -#endif - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -extern PNG_EXPORT(void,png_set_user_transform_info) PNGARG((png_structp - png_ptr, png_voidp user_transform_ptr, int user_transform_depth, - int user_transform_channels)); -/* Return the user pointer associated with the user transform functions */ -extern PNG_EXPORT(png_voidp,png_get_user_transform_ptr) - PNGARG((png_structp png_ptr)); -#endif - -#ifdef PNG_USER_CHUNKS_SUPPORTED -extern PNG_EXPORT(void,png_set_read_user_chunk_fn) PNGARG((png_structp png_ptr, - png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn)); -extern PNG_EXPORT(png_voidp,png_get_user_chunk_ptr) PNGARG((png_structp - png_ptr)); -#endif - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -/* Sets the function callbacks for the push reader, and a pointer to a - * user-defined structure available to the callback functions. - */ -extern PNG_EXPORT(void,png_set_progressive_read_fn) PNGARG((png_structp png_ptr, - png_voidp progressive_ptr, - png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, - png_progressive_end_ptr end_fn)); - -/* returns the user pointer associated with the push read functions */ -extern PNG_EXPORT(png_voidp,png_get_progressive_ptr) - PNGARG((png_structp png_ptr)); - -/* function to be called when data becomes available */ -extern PNG_EXPORT(void,png_process_data) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_bytep buffer, png_size_t buffer_size)); - -/* function that combines rows. Not very much different than the - * png_combine_row() call. Is this even used????? - */ -extern PNG_EXPORT(void,png_progressive_combine_row) PNGARG((png_structp png_ptr, - png_bytep old_row, png_bytep new_row)); -#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ - -extern PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr, - png_uint_32 size)); - -#if defined(PNG_1_0_X) -# define png_malloc_warn png_malloc -#else -/* Added at libpng version 1.2.4 */ -extern PNG_EXPORT(png_voidp,png_malloc_warn) PNGARG((png_structp png_ptr, - png_uint_32 size)); -#endif - -/* frees a pointer allocated by png_malloc() */ -extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr)); - -#if defined(PNG_1_0_X) -/* Function to allocate memory for zlib. */ -extern PNG_EXPORT(voidpf,png_zalloc) PNGARG((voidpf png_ptr, uInt items, - uInt size)); - -/* Function to free memory for zlib */ -extern PNG_EXPORT(void,png_zfree) PNGARG((voidpf png_ptr, voidpf ptr)); -#endif - -/* Free data that was allocated internally */ -extern PNG_EXPORT(void,png_free_data) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 free_me, int num)); -#ifdef PNG_FREE_ME_SUPPORTED -/* Reassign responsibility for freeing existing data, whether allocated - * by libpng or by the application */ -extern PNG_EXPORT(void,png_data_freer) PNGARG((png_structp png_ptr, - png_infop info_ptr, int freer, png_uint_32 mask)); -#endif -/* assignments for png_data_freer */ -#define PNG_DESTROY_WILL_FREE_DATA 1 -#define PNG_SET_WILL_FREE_DATA 1 -#define PNG_USER_WILL_FREE_DATA 2 -/* Flags for png_ptr->free_me and info_ptr->free_me */ -#define PNG_FREE_HIST 0x0008 -#define PNG_FREE_ICCP 0x0010 -#define PNG_FREE_SPLT 0x0020 -#define PNG_FREE_ROWS 0x0040 -#define PNG_FREE_PCAL 0x0080 -#define PNG_FREE_SCAL 0x0100 -#define PNG_FREE_UNKN 0x0200 -#define PNG_FREE_LIST 0x0400 -#define PNG_FREE_PLTE 0x1000 -#define PNG_FREE_TRNS 0x2000 -#define PNG_FREE_TEXT 0x4000 -#define PNG_FREE_ALL 0x7fff -#define PNG_FREE_MUL 0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */ - -#ifdef PNG_USER_MEM_SUPPORTED -extern PNG_EXPORT(png_voidp,png_malloc_default) PNGARG((png_structp png_ptr, - png_uint_32 size)); -extern PNG_EXPORT(void,png_free_default) PNGARG((png_structp png_ptr, - png_voidp ptr)); -#endif - -extern PNG_EXPORT(png_voidp,png_memcpy_check) PNGARG((png_structp png_ptr, - png_voidp s1, png_voidp s2, png_uint_32 size)); - -extern PNG_EXPORT(png_voidp,png_memset_check) PNGARG((png_structp png_ptr, - png_voidp s1, int value, png_uint_32 size)); - -#if defined(USE_FAR_KEYWORD) /* memory model conversion function */ -extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr, - int check)); -#endif /* USE_FAR_KEYWORD */ - -/* Fatal error in PNG image of libpng - can't continue */ -extern PNG_EXPORT(void,png_error) PNGARG((png_structp png_ptr, - png_const_charp error_message)); - -/* The same, but the chunk name is prepended to the error string. */ -extern PNG_EXPORT(void,png_chunk_error) PNGARG((png_structp png_ptr, - png_const_charp error_message)); - -/* Non-fatal error in libpng. Can continue, but may have a problem. */ -extern PNG_EXPORT(void,png_warning) PNGARG((png_structp png_ptr, - png_const_charp warning_message)); - -/* Non-fatal error in libpng, chunk name is prepended to message. */ -extern PNG_EXPORT(void,png_chunk_warning) PNGARG((png_structp png_ptr, - png_const_charp warning_message)); - -/* The png_set_<chunk> functions are for storing values in the png_info_struct. - * Similarly, the png_get_<chunk> calls are used to read values from the - * png_info_struct, either storing the parameters in the passed variables, or - * setting pointers into the png_info_struct where the data is stored. The - * png_get_<chunk> functions return a non-zero value if the data was available - * in info_ptr, or return zero and do not change any of the parameters if the - * data was not available. - * - * These functions should be used instead of directly accessing png_info - * to avoid problems with future changes in the size and internal layout of - * png_info_struct. - */ -/* Returns "flag" if chunk data is valid in info_ptr. */ -extern PNG_EXPORT(png_uint_32,png_get_valid) PNGARG((png_structp png_ptr, -png_infop info_ptr, png_uint_32 flag)); - -/* Returns number of bytes needed to hold a transformed row. */ -extern PNG_EXPORT(png_uint_32,png_get_rowbytes) PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -#if defined(PNG_INFO_IMAGE_SUPPORTED) -/* Returns row_pointers, which is an array of pointers to scanlines that was -returned from png_read_png(). */ -extern PNG_EXPORT(png_bytepp,png_get_rows) PNGARG((png_structp png_ptr, -png_infop info_ptr)); -/* Set row_pointers, which is an array of pointers to scanlines for use -by png_write_png(). */ -extern PNG_EXPORT(void,png_set_rows) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_bytepp row_pointers)); -#endif - -/* Returns number of color channels in image. */ -extern PNG_EXPORT(png_byte,png_get_channels) PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -#ifdef PNG_EASY_ACCESS_SUPPORTED -/* Returns image width in pixels. */ -extern PNG_EXPORT(png_uint_32, png_get_image_width) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image height in pixels. */ -extern PNG_EXPORT(png_uint_32, png_get_image_height) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image bit_depth. */ -extern PNG_EXPORT(png_byte, png_get_bit_depth) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image color_type. */ -extern PNG_EXPORT(png_byte, png_get_color_type) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image filter_type. */ -extern PNG_EXPORT(png_byte, png_get_filter_type) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image interlace_type. */ -extern PNG_EXPORT(png_byte, png_get_interlace_type) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image compression_type. */ -extern PNG_EXPORT(png_byte, png_get_compression_type) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image resolution in pixels per meter, from pHYs chunk data. */ -extern PNG_EXPORT(png_uint_32, png_get_pixels_per_meter) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_uint_32, png_get_x_pixels_per_meter) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_uint_32, png_get_y_pixels_per_meter) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns pixel aspect ratio, computed from pHYs chunk data. */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(float, png_get_pixel_aspect_ratio) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -#endif - -/* Returns image x, y offset in pixels or microns, from oFFs chunk data. */ -extern PNG_EXPORT(png_int_32, png_get_x_offset_pixels) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_int_32, png_get_y_offset_pixels) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_int_32, png_get_x_offset_microns) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_int_32, png_get_y_offset_microns) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -#endif /* PNG_EASY_ACCESS_SUPPORTED */ - -/* Returns pointer to signature string read from PNG header */ -extern PNG_EXPORT(png_bytep,png_get_signature) PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -#if defined(PNG_bKGD_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_bKGD) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_color_16p *background)); -#endif - -#if defined(PNG_bKGD_SUPPORTED) -extern PNG_EXPORT(void,png_set_bKGD) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_color_16p background)); -#endif - -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_cHRM) PNGARG((png_structp png_ptr, - png_infop info_ptr, double *white_x, double *white_y, double *red_x, - double *red_y, double *green_x, double *green_y, double *blue_x, - double *blue_y)); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_cHRM_fixed) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_fixed_point *int_white_x, png_fixed_point - *int_white_y, png_fixed_point *int_red_x, png_fixed_point *int_red_y, - png_fixed_point *int_green_x, png_fixed_point *int_green_y, png_fixed_point - *int_blue_x, png_fixed_point *int_blue_y)); -#endif -#endif - -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_cHRM) PNGARG((png_structp png_ptr, - png_infop info_ptr, double white_x, double white_y, double red_x, - double red_y, double green_x, double green_y, double blue_x, double blue_y)); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_cHRM_fixed) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_fixed_point int_white_x, png_fixed_point int_white_y, - png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point - int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, - png_fixed_point int_blue_y)); -#endif -#endif - -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_gAMA) PNGARG((png_structp png_ptr, - png_infop info_ptr, double *file_gamma)); -#endif -extern PNG_EXPORT(png_uint_32,png_get_gAMA_fixed) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_fixed_point *int_file_gamma)); -#endif - -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_gAMA) PNGARG((png_structp png_ptr, - png_infop info_ptr, double file_gamma)); -#endif -extern PNG_EXPORT(void,png_set_gAMA_fixed) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_fixed_point int_file_gamma)); -#endif - -#if defined(PNG_hIST_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_hIST) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_16p *hist)); -#endif - -#if defined(PNG_hIST_SUPPORTED) -extern PNG_EXPORT(void,png_set_hIST) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_16p hist)); -#endif - -extern PNG_EXPORT(png_uint_32,png_get_IHDR) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 *width, png_uint_32 *height, - int *bit_depth, int *color_type, int *interlace_method, - int *compression_method, int *filter_method)); - -extern PNG_EXPORT(void,png_set_IHDR) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, - int color_type, int interlace_method, int compression_method, - int filter_method)); - -#if defined(PNG_oFFs_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_oFFs) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_int_32 *offset_x, png_int_32 *offset_y, - int *unit_type)); -#endif - -#if defined(PNG_oFFs_SUPPORTED) -extern PNG_EXPORT(void,png_set_oFFs) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_int_32 offset_x, png_int_32 offset_y, - int unit_type)); -#endif - -#if defined(PNG_pCAL_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_pCAL) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1, - int *type, int *nparams, png_charp *units, png_charpp *params)); -#endif - -#if defined(PNG_pCAL_SUPPORTED) -extern PNG_EXPORT(void,png_set_pCAL) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1, - int type, int nparams, png_charp units, png_charpp params)); -#endif - -#if defined(PNG_pHYs_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_pHYs) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); -#endif - -#if defined(PNG_pHYs_SUPPORTED) -extern PNG_EXPORT(void,png_set_pHYs) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type)); -#endif - -extern PNG_EXPORT(png_uint_32,png_get_PLTE) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_colorp *palette, int *num_palette)); - -extern PNG_EXPORT(void,png_set_PLTE) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_colorp palette, int num_palette)); - -#if defined(PNG_sBIT_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_sBIT) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_color_8p *sig_bit)); -#endif - -#if defined(PNG_sBIT_SUPPORTED) -extern PNG_EXPORT(void,png_set_sBIT) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_color_8p sig_bit)); -#endif - -#if defined(PNG_sRGB_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_sRGB) PNGARG((png_structp png_ptr, - png_infop info_ptr, int *intent)); -#endif - -#if defined(PNG_sRGB_SUPPORTED) -extern PNG_EXPORT(void,png_set_sRGB) PNGARG((png_structp png_ptr, - png_infop info_ptr, int intent)); -extern PNG_EXPORT(void,png_set_sRGB_gAMA_and_cHRM) PNGARG((png_structp png_ptr, - png_infop info_ptr, int intent)); -#endif - -#if defined(PNG_iCCP_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_iCCP) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_charpp name, int *compression_type, - png_charpp profile, png_uint_32 *proflen)); - /* Note to maintainer: profile should be png_bytepp */ -#endif - -#if defined(PNG_iCCP_SUPPORTED) -extern PNG_EXPORT(void,png_set_iCCP) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_charp name, int compression_type, - png_charp profile, png_uint_32 proflen)); - /* Note to maintainer: profile should be png_bytep */ -#endif - -#if defined(PNG_sPLT_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_sPLT) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_sPLT_tpp entries)); -#endif - -#if defined(PNG_sPLT_SUPPORTED) -extern PNG_EXPORT(void,png_set_sPLT) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_sPLT_tp entries, int nentries)); -#endif - -#if defined(PNG_TEXT_SUPPORTED) -/* png_get_text also returns the number of text chunks in *num_text */ -extern PNG_EXPORT(png_uint_32,png_get_text) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_textp *text_ptr, int *num_text)); -#endif - -/* - * Note while png_set_text() will accept a structure whose text, - * language, and translated keywords are NULL pointers, the structure - * returned by png_get_text will always contain regular - * zero-terminated C strings. They might be empty strings but - * they will never be NULL pointers. - */ - -#if defined(PNG_TEXT_SUPPORTED) -extern PNG_EXPORT(void,png_set_text) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_textp text_ptr, int num_text)); -#endif - -#if defined(PNG_tIME_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_tIME) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_timep *mod_time)); -#endif - -#if defined(PNG_tIME_SUPPORTED) -extern PNG_EXPORT(void,png_set_tIME) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_timep mod_time)); -#endif - -#if defined(PNG_tRNS_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_tRNS) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_bytep *trans, int *num_trans, - png_color_16p *trans_values)); -#endif - -#if defined(PNG_tRNS_SUPPORTED) -extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_bytep trans, int num_trans, - png_color_16p trans_values)); -#endif - -#if defined(PNG_tRNS_SUPPORTED) -#endif - -#if defined(PNG_sCAL_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_sCAL) PNGARG((png_structp png_ptr, - png_infop info_ptr, int *unit, double *width, double *height)); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_sCAL_s) PNGARG((png_structp png_ptr, - png_infop info_ptr, int *unit, png_charpp swidth, png_charpp sheight)); -#endif -#endif -#endif /* PNG_sCAL_SUPPORTED */ - -#if defined(PNG_sCAL_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_sCAL) PNGARG((png_structp png_ptr, - png_infop info_ptr, int unit, double width, double height)); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_sCAL_s) PNGARG((png_structp png_ptr, - png_infop info_ptr, int unit, png_charp swidth, png_charp sheight)); -#endif -#endif -#endif /* PNG_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */ - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -/* provide a list of chunks and how they are to be handled, if the built-in - handling or default unknown chunk handling is not desired. Any chunks not - listed will be handled in the default manner. The IHDR and IEND chunks - must not be listed. - keep = 0: follow default behavour - = 1: do not keep - = 2: keep only if safe-to-copy - = 3: keep even if unsafe-to-copy -*/ -extern PNG_EXPORT(void, png_set_keep_unknown_chunks) PNGARG((png_structp - png_ptr, int keep, png_bytep chunk_list, int num_chunks)); -extern PNG_EXPORT(void, png_set_unknown_chunks) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns)); -extern PNG_EXPORT(void, png_set_unknown_chunk_location) - PNGARG((png_structp png_ptr, png_infop info_ptr, int chunk, int location)); -extern PNG_EXPORT(png_uint_32,png_get_unknown_chunks) PNGARG((png_structp - png_ptr, png_infop info_ptr, png_unknown_chunkpp entries)); -#endif -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED -PNG_EXPORT(int,png_handle_as_unknown) PNGARG((png_structp png_ptr, png_bytep - chunk_name)); -#endif - -/* Png_free_data() will turn off the "valid" flag for anything it frees. - If you need to turn it off for a chunk that your application has freed, - you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK); */ -extern PNG_EXPORT(void, png_set_invalid) PNGARG((png_structp png_ptr, - png_infop info_ptr, int mask)); - -#if defined(PNG_INFO_IMAGE_SUPPORTED) -/* The "params" pointer is currently not used and is for future expansion. */ -extern PNG_EXPORT(void, png_read_png) PNGARG((png_structp png_ptr, - png_infop info_ptr, - int transforms, - png_voidp params)); -extern PNG_EXPORT(void, png_write_png) PNGARG((png_structp png_ptr, - png_infop info_ptr, - int transforms, - png_voidp params)); -#endif - -/* Define PNG_DEBUG at compile time for debugging information. Higher - * numbers for PNG_DEBUG mean more debugging information. This has - * only been added since version 0.95 so it is not implemented throughout - * libpng yet, but more support will be added as needed. - */ -#ifdef PNG_DEBUG -#if (PNG_DEBUG > 0) -#if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER) -#include <crtdbg.h> -#if (PNG_DEBUG > 1) -#define png_debug(l,m) _RPT0(_CRT_WARN,m) -#define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m,p1) -#define png_debug2(l,m,p1,p2) _RPT2(_CRT_WARN,m,p1,p2) -#endif -#else /* PNG_DEBUG_FILE || !_MSC_VER */ -#ifndef PNG_DEBUG_FILE -#define PNG_DEBUG_FILE stderr -#endif /* PNG_DEBUG_FILE */ -#if (PNG_DEBUG > 1) -#define png_debug(l,m) \ -{ \ - int num_tabs=l; \ - fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ - (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \ -} -#define png_debug1(l,m,p1) \ -{ \ - int num_tabs=l; \ - fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ - (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \ -} -#define png_debug2(l,m,p1,p2) \ -{ \ - int num_tabs=l; \ - fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ - (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \ -} -#endif /* (PNG_DEBUG > 1) */ -#endif /* _MSC_VER */ -#endif /* (PNG_DEBUG > 0) */ -#endif /* PNG_DEBUG */ -#ifndef png_debug -#define png_debug(l, m) -#endif -#ifndef png_debug1 -#define png_debug1(l, m, p1) -#endif -#ifndef png_debug2 -#define png_debug2(l, m, p1, p2) -#endif - -#if 0 -extern PNG_EXPORT(png_bytep,png_sig_bytes) PNGARG((void)); -#endif - -extern PNG_EXPORT(png_charp,png_get_copyright) PNGARG((png_structp png_ptr)); -extern PNG_EXPORT(png_charp,png_get_header_ver) PNGARG((png_structp png_ptr)); -extern PNG_EXPORT(png_charp,png_get_header_version) PNGARG((png_structp png_ptr)); -extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr)); - -#ifdef PNG_MNG_FEATURES_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_permit_mng_features) PNGARG((png_structp - png_ptr, png_uint_32 mng_features_permitted)); -#endif - -/* For use in png_set_keep_unknown, added to version 1.2.6 */ -#define PNG_HANDLE_CHUNK_AS_DEFAULT 0 -#define PNG_HANDLE_CHUNK_NEVER 1 -#define PNG_HANDLE_CHUNK_IF_SAFE 2 -#define PNG_HANDLE_CHUNK_ALWAYS 3 - -/* Added to version 1.2.0 */ -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) -#if defined(PNG_MMX_CODE_SUPPORTED) -#define PNG_ASM_FLAG_MMX_SUPPORT_COMPILED 0x01 /* not user-settable */ -#define PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU 0x02 /* not user-settable */ -#define PNG_ASM_FLAG_MMX_READ_COMBINE_ROW 0x04 -#define PNG_ASM_FLAG_MMX_READ_INTERLACE 0x08 -#define PNG_ASM_FLAG_MMX_READ_FILTER_SUB 0x10 -#define PNG_ASM_FLAG_MMX_READ_FILTER_UP 0x20 -#define PNG_ASM_FLAG_MMX_READ_FILTER_AVG 0x40 -#define PNG_ASM_FLAG_MMX_READ_FILTER_PAETH 0x80 -#define PNG_ASM_FLAGS_INITIALIZED 0x80000000 /* not user-settable */ - -#define PNG_MMX_READ_FLAGS ( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ - | PNG_ASM_FLAG_MMX_READ_INTERLACE \ - | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ - | PNG_ASM_FLAG_MMX_READ_FILTER_UP \ - | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ - | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ) -#define PNG_MMX_WRITE_FLAGS ( 0 ) - -#define PNG_MMX_FLAGS ( PNG_ASM_FLAG_MMX_SUPPORT_COMPILED \ - | PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU \ - | PNG_MMX_READ_FLAGS \ - | PNG_MMX_WRITE_FLAGS ) - -#define PNG_SELECT_READ 1 -#define PNG_SELECT_WRITE 2 -#endif /* PNG_MMX_CODE_SUPPORTED */ - -#if !defined(PNG_1_0_X) -/* pngget.c */ -extern PNG_EXPORT(png_uint_32,png_get_mmx_flagmask) - PNGARG((int flag_select, int *compilerID)); - -/* pngget.c */ -extern PNG_EXPORT(png_uint_32,png_get_asm_flagmask) - PNGARG((int flag_select)); - -/* pngget.c */ -extern PNG_EXPORT(png_uint_32,png_get_asm_flags) - PNGARG((png_structp png_ptr)); - -/* pngget.c */ -extern PNG_EXPORT(png_byte,png_get_mmx_bitdepth_threshold) - PNGARG((png_structp png_ptr)); - -/* pngget.c */ -extern PNG_EXPORT(png_uint_32,png_get_mmx_rowbytes_threshold) - PNGARG((png_structp png_ptr)); - -/* pngset.c */ -extern PNG_EXPORT(void,png_set_asm_flags) - PNGARG((png_structp png_ptr, png_uint_32 asm_flags)); - -/* pngset.c */ -extern PNG_EXPORT(void,png_set_mmx_thresholds) - PNGARG((png_structp png_ptr, png_byte mmx_bitdepth_threshold, - png_uint_32 mmx_rowbytes_threshold)); - -#endif /* PNG_1_0_X */ - -#if !defined(PNG_1_0_X) -/* png.c, pnggccrd.c, or pngvcrd.c */ -extern PNG_EXPORT(int,png_mmx_support) PNGARG((void)); -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ - -/* Strip the prepended error numbers ("#nnn ") from error and warning - * messages before passing them to the error or warning handler. */ -#ifdef PNG_ERROR_NUMBERS_SUPPORTED -extern PNG_EXPORT(void,png_set_strip_error_numbers) PNGARG((png_structp - png_ptr, png_uint_32 strip_mode)); -#endif - -#endif /* PNG_1_0_X */ - -/* Added at libpng-1.2.6 */ -#ifdef PNG_SET_USER_LIMITS_SUPPORTED -extern PNG_EXPORT(void,png_set_user_limits) PNGARG((png_structp - png_ptr, png_uint_32 user_width_max, png_uint_32 user_height_max)); -extern PNG_EXPORT(png_uint_32,png_get_user_width_max) PNGARG((png_structp - png_ptr)); -extern PNG_EXPORT(png_uint_32,png_get_user_height_max) PNGARG((png_structp - png_ptr)); -#endif - -/* Maintainer: Put new public prototypes here ^, in libpng.3, and project defs */ - -#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED -/* With these routines we avoid an integer divide, which will be slower on - * most machines. However, it does take more operations than the corresponding - * divide method, so it may be slower on a few RISC systems. There are two - * shifts (by 8 or 16 bits) and an addition, versus a single integer divide. - * - * Note that the rounding factors are NOT supposed to be the same! 128 and - * 32768 are correct for the NODIV code; 127 and 32767 are correct for the - * standard method. - * - * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ] - */ - - /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */ - -# define png_composite(composite, fg, alpha, bg) \ - { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) * (png_uint_16)(alpha) \ - + (png_uint_16)(bg)*(png_uint_16)(255 - \ - (png_uint_16)(alpha)) + (png_uint_16)128); \ - (composite) = (png_byte)((temp + (temp >> 8)) >> 8); } - -# define png_composite_16(composite, fg, alpha, bg) \ - { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) * (png_uint_32)(alpha) \ - + (png_uint_32)(bg)*(png_uint_32)(65535L - \ - (png_uint_32)(alpha)) + (png_uint_32)32768L); \ - (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); } - -#else /* standard method using integer division */ - -# define png_composite(composite, fg, alpha, bg) \ - (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \ - (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \ - (png_uint_16)127) / 255) - -# define png_composite_16(composite, fg, alpha, bg) \ - (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \ - (png_uint_32)(bg)*(png_uint_32)(65535L - (png_uint_32)(alpha)) + \ - (png_uint_32)32767) / (png_uint_32)65535L) - -#endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */ - -/* Inline macros to do direct reads of bytes from the input buffer. These - * require that you are using an architecture that uses PNG byte ordering - * (MSB first) and supports unaligned data storage. I think that PowerPC - * in big-endian mode and 680x0 are the only ones that will support this. - * The x86 line of processors definitely do not. The png_get_int_32() - * routine also assumes we are using two's complement format for negative - * values, which is almost certainly true. - */ -#if defined(PNG_READ_BIG_ENDIAN_SUPPORTED) -# define png_get_uint_32(buf) ( *((png_uint_32p) (buf))) -# define png_get_uint_16(buf) ( *((png_uint_16p) (buf))) -# define png_get_int_32(buf) ( *((png_int_32p) (buf))) -#else -extern PNG_EXPORT(png_uint_32,png_get_uint_32) PNGARG((png_bytep buf)); -extern PNG_EXPORT(png_uint_16,png_get_uint_16) PNGARG((png_bytep buf)); -extern PNG_EXPORT(png_int_32,png_get_int_32) PNGARG((png_bytep buf)); -#endif /* !PNG_READ_BIG_ENDIAN_SUPPORTED */ -extern PNG_EXPORT(png_uint_32,png_get_uint_31) - PNGARG((png_structp png_ptr, png_bytep buf)); -/* No png_get_int_16 -- may be added if there's a real need for it. */ - -/* Place a 32-bit number into a buffer in PNG byte order (big-endian). - */ -extern PNG_EXPORT(void,png_save_uint_32) - PNGARG((png_bytep buf, png_uint_32 i)); -extern PNG_EXPORT(void,png_save_int_32) - PNGARG((png_bytep buf, png_int_32 i)); - -/* Place a 16-bit number into a buffer in PNG byte order. - * The parameter is declared unsigned int, not png_uint_16, - * just to avoid potential problems on pre-ANSI C compilers. - */ -extern PNG_EXPORT(void,png_save_uint_16) - PNGARG((png_bytep buf, unsigned int i)); -/* No png_save_int_16 -- may be added if there's a real need for it. */ - -/* ************************************************************************* */ - -/* These next functions are used internally in the code. They generally - * shouldn't be used unless you are writing code to add or replace some - * functionality in libpng. More information about most functions can - * be found in the files where the functions are located. - */ - -#if defined(PNG_INTERNAL) - -/* Various modes of operation. Note that after an init, mode is set to - * zero automatically when the structure is created. - */ -#define PNG_HAVE_IHDR 0x01 -#define PNG_HAVE_PLTE 0x02 -#define PNG_HAVE_IDAT 0x04 -#define PNG_AFTER_IDAT 0x08 /* Have complete zlib datastream */ -#define PNG_HAVE_IEND 0x10 -#define PNG_HAVE_gAMA 0x20 -#define PNG_HAVE_cHRM 0x40 -#define PNG_HAVE_sRGB 0x80 -#define PNG_HAVE_CHUNK_HEADER 0x100 -#define PNG_WROTE_tIME 0x200 -#define PNG_WROTE_INFO_BEFORE_PLTE 0x400 -#define PNG_BACKGROUND_IS_GRAY 0x800 -#define PNG_HAVE_PNG_SIGNATURE 0x1000 -#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */ - -/* flags for the transformations the PNG library does on the image data */ -#define PNG_BGR 0x0001 -#define PNG_INTERLACE 0x0002 -#define PNG_PACK 0x0004 -#define PNG_SHIFT 0x0008 -#define PNG_SWAP_BYTES 0x0010 -#define PNG_INVERT_MONO 0x0020 -#define PNG_DITHER 0x0040 -#define PNG_BACKGROUND 0x0080 -#define PNG_BACKGROUND_EXPAND 0x0100 - /* 0x0200 unused */ -#define PNG_16_TO_8 0x0400 -#define PNG_RGBA 0x0800 -#define PNG_EXPAND 0x1000 -#define PNG_GAMMA 0x2000 -#define PNG_GRAY_TO_RGB 0x4000 -#define PNG_FILLER 0x8000L -#define PNG_PACKSWAP 0x10000L -#define PNG_SWAP_ALPHA 0x20000L -#define PNG_STRIP_ALPHA 0x40000L -#define PNG_INVERT_ALPHA 0x80000L -#define PNG_USER_TRANSFORM 0x100000L -#define PNG_RGB_TO_GRAY_ERR 0x200000L -#define PNG_RGB_TO_GRAY_WARN 0x400000L -#define PNG_RGB_TO_GRAY 0x600000L /* two bits, RGB_TO_GRAY_ERR|WARN */ - /* 0x800000L Unused */ -#define PNG_ADD_ALPHA 0x1000000L /* Added to libpng-1.2.7 */ -#define PNG_EXPAND_tRNS 0x2000000L /* Added to libpng-1.2.9 */ - /* 0x4000000L unused */ - /* 0x8000000L unused */ - /* 0x10000000L unused */ - /* 0x20000000L unused */ - /* 0x40000000L unused */ - -/* flags for png_create_struct */ -#define PNG_STRUCT_PNG 0x0001 -#define PNG_STRUCT_INFO 0x0002 - -/* Scaling factor for filter heuristic weighting calculations */ -#define PNG_WEIGHT_SHIFT 8 -#define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT)) -#define PNG_COST_SHIFT 3 -#define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT)) - -/* flags for the png_ptr->flags rather than declaring a byte for each one */ -#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001 -#define PNG_FLAG_ZLIB_CUSTOM_LEVEL 0x0002 -#define PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL 0x0004 -#define PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS 0x0008 -#define PNG_FLAG_ZLIB_CUSTOM_METHOD 0x0010 -#define PNG_FLAG_ZLIB_FINISHED 0x0020 -#define PNG_FLAG_ROW_INIT 0x0040 -#define PNG_FLAG_FILLER_AFTER 0x0080 -#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100 -#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200 -#define PNG_FLAG_CRC_CRITICAL_USE 0x0400 -#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800 -#define PNG_FLAG_FREE_PLTE 0x1000 -#define PNG_FLAG_FREE_TRNS 0x2000 -#define PNG_FLAG_FREE_HIST 0x4000 -#define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000L -#define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000L -#define PNG_FLAG_LIBRARY_MISMATCH 0x20000L -#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000L -#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000L -#define PNG_FLAG_MALLOC_NULL_MEM_OK 0x100000L -#define PNG_FLAG_ADD_ALPHA 0x200000L /* Added to libpng-1.2.8 */ -#define PNG_FLAG_STRIP_ALPHA 0x400000L /* Added to libpng-1.2.8 */ - /* 0x800000L unused */ - /* 0x1000000L unused */ - /* 0x2000000L unused */ - /* 0x4000000L unused */ - /* 0x8000000L unused */ - /* 0x10000000L unused */ - /* 0x20000000L unused */ - /* 0x40000000L unused */ - -#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \ - PNG_FLAG_CRC_ANCILLARY_NOWARN) - -#define PNG_FLAG_CRC_CRITICAL_MASK (PNG_FLAG_CRC_CRITICAL_USE | \ - PNG_FLAG_CRC_CRITICAL_IGNORE) - -#define PNG_FLAG_CRC_MASK (PNG_FLAG_CRC_ANCILLARY_MASK | \ - PNG_FLAG_CRC_CRITICAL_MASK) - -/* save typing and make code easier to understand */ - -#define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \ - abs((int)((c1).green) - (int)((c2).green)) + \ - abs((int)((c1).blue) - (int)((c2).blue))) - -/* Added to libpng-1.2.6 JB */ -#define PNG_ROWBYTES(pixel_bits, width) \ - ((pixel_bits) >= 8 ? \ - ((width) * (((png_uint_32)(pixel_bits)) >> 3)) : \ - (( ((width) * ((png_uint_32)(pixel_bits))) + 7) >> 3) ) - -/* PNG_OUT_OF_RANGE returns true if value is outside the range - ideal-delta..ideal+delta. Each argument is evaluated twice. - "ideal" and "delta" should be constants, normally simple - integers, "value" a variable. Added to libpng-1.2.6 JB */ -#define PNG_OUT_OF_RANGE(value, ideal, delta) \ - ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) ) - -/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */ -#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN) -/* place to hold the signature string for a PNG file. */ -#ifdef PNG_USE_GLOBAL_ARRAYS - PNG_EXPORT_VAR (const png_byte FARDATA) png_sig[8]; -#else -#if 0 -#define png_sig png_sig_bytes(NULL) -#endif -#endif -#endif /* PNG_NO_EXTERN */ - -/* Constant strings for known chunk types. If you need to add a chunk, - * define the name here, and add an invocation of the macro in png.c and - * wherever it's needed. - */ -#define PNG_IHDR const png_byte png_IHDR[5] = { 73, 72, 68, 82, '\0'} -#define PNG_IDAT const png_byte png_IDAT[5] = { 73, 68, 65, 84, '\0'} -#define PNG_IEND const png_byte png_IEND[5] = { 73, 69, 78, 68, '\0'} -#define PNG_PLTE const png_byte png_PLTE[5] = { 80, 76, 84, 69, '\0'} -#define PNG_bKGD const png_byte png_bKGD[5] = { 98, 75, 71, 68, '\0'} -#define PNG_cHRM const png_byte png_cHRM[5] = { 99, 72, 82, 77, '\0'} -#define PNG_gAMA const png_byte png_gAMA[5] = {103, 65, 77, 65, '\0'} -#define PNG_hIST const png_byte png_hIST[5] = {104, 73, 83, 84, '\0'} -#define PNG_iCCP const png_byte png_iCCP[5] = {105, 67, 67, 80, '\0'} -#define PNG_iTXt const png_byte png_iTXt[5] = {105, 84, 88, 116, '\0'} -#define PNG_oFFs const png_byte png_oFFs[5] = {111, 70, 70, 115, '\0'} -#define PNG_pCAL const png_byte png_pCAL[5] = {112, 67, 65, 76, '\0'} -#define PNG_sCAL const png_byte png_sCAL[5] = {115, 67, 65, 76, '\0'} -#define PNG_pHYs const png_byte png_pHYs[5] = {112, 72, 89, 115, '\0'} -#define PNG_sBIT const png_byte png_sBIT[5] = {115, 66, 73, 84, '\0'} -#define PNG_sPLT const png_byte png_sPLT[5] = {115, 80, 76, 84, '\0'} -#define PNG_sRGB const png_byte png_sRGB[5] = {115, 82, 71, 66, '\0'} -#define PNG_tEXt const png_byte png_tEXt[5] = {116, 69, 88, 116, '\0'} -#define PNG_tIME const png_byte png_tIME[5] = {116, 73, 77, 69, '\0'} -#define PNG_tRNS const png_byte png_tRNS[5] = {116, 82, 78, 83, '\0'} -#define PNG_zTXt const png_byte png_zTXt[5] = {122, 84, 88, 116, '\0'} - -#ifdef PNG_USE_GLOBAL_ARRAYS -PNG_EXPORT_VAR (const png_byte FARDATA) png_IHDR[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_IDAT[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_IEND[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_PLTE[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_bKGD[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_cHRM[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_gAMA[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_hIST[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_iCCP[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_iTXt[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_oFFs[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_pCAL[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_sCAL[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_pHYs[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_sBIT[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_sPLT[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_sRGB[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_tEXt[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_tIME[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_tRNS[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_zTXt[5]; -#endif /* PNG_USE_GLOBAL_ARRAYS */ - -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* Initialize png_ptr struct for reading, and allocate any other memory. - * (old interface - DEPRECATED - use png_create_read_struct instead). - */ -extern PNG_EXPORT(void,png_read_init) PNGARG((png_structp png_ptr)); -#undef png_read_init -#define png_read_init(png_ptr) png_read_init_3(&png_ptr, \ - PNG_LIBPNG_VER_STRING, png_sizeof(png_struct)); -#endif - -extern PNG_EXPORT(void,png_read_init_3) PNGARG((png_structpp ptr_ptr, - png_const_charp user_png_ver, png_size_t png_struct_size)); -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -extern PNG_EXPORT(void,png_read_init_2) PNGARG((png_structp png_ptr, - png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t - png_info_size)); -#endif - -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* Initialize png_ptr struct for writing, and allocate any other memory. - * (old interface - DEPRECATED - use png_create_write_struct instead). - */ -extern PNG_EXPORT(void,png_write_init) PNGARG((png_structp png_ptr)); -#undef png_write_init -#define png_write_init(png_ptr) png_write_init_3(&png_ptr, \ - PNG_LIBPNG_VER_STRING, png_sizeof(png_struct)); -#endif - -extern PNG_EXPORT(void,png_write_init_3) PNGARG((png_structpp ptr_ptr, - png_const_charp user_png_ver, png_size_t png_struct_size)); -extern PNG_EXPORT(void,png_write_init_2) PNGARG((png_structp png_ptr, - png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t - png_info_size)); - -/* Allocate memory for an internal libpng struct */ -PNG_EXTERN png_voidp png_create_struct PNGARG((int type)); - -/* Free memory from internal libpng struct */ -PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr)); - -PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr - malloc_fn, png_voidp mem_ptr)); -PNG_EXTERN void png_destroy_struct_2 PNGARG((png_voidp struct_ptr, - png_free_ptr free_fn, png_voidp mem_ptr)); - -/* Free any memory that info_ptr points to and reset struct. */ -PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr, - png_infop info_ptr)); - -#ifndef PNG_1_0_X -/* Function to allocate memory for zlib. */ -PNG_EXTERN voidpf png_zalloc PNGARG((voidpf png_ptr, uInt items, uInt size)); - -/* Function to free memory for zlib */ -PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr)); - -#ifdef PNG_SIZE_T -/* Function to convert a sizeof an item to png_sizeof item */ - PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size)); -#endif - -/* Next four functions are used internally as callbacks. PNGAPI is required - * but not PNG_EXPORT. PNGAPI added at libpng version 1.2.3. */ - -PNG_EXTERN void PNGAPI png_default_read_data PNGARG((png_structp png_ptr, - png_bytep data, png_size_t length)); - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -PNG_EXTERN void PNGAPI png_push_fill_buffer PNGARG((png_structp png_ptr, - png_bytep buffer, png_size_t length)); -#endif - -PNG_EXTERN void PNGAPI png_default_write_data PNGARG((png_structp png_ptr, - png_bytep data, png_size_t length)); - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -#if !defined(PNG_NO_STDIO) -PNG_EXTERN void PNGAPI png_default_flush PNGARG((png_structp png_ptr)); -#endif -#endif -#else /* PNG_1_0_X */ -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -PNG_EXTERN void png_push_fill_buffer PNGARG((png_structp png_ptr, - png_bytep buffer, png_size_t length)); -#endif -#endif /* PNG_1_0_X */ - -/* Reset the CRC variable */ -PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr)); - -/* Write the "data" buffer to whatever output you are using. */ -PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data, - png_size_t length)); - -/* Read data from whatever input you are using into the "data" buffer */ -PNG_EXTERN void png_read_data PNGARG((png_structp png_ptr, png_bytep data, - png_size_t length)); - -/* Read bytes into buf, and update png_ptr->crc */ -PNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf, - png_size_t length)); - -/* Decompress data in a chunk that uses compression */ -#if defined(PNG_zTXt_SUPPORTED) || defined(PNG_iTXt_SUPPORTED) || \ - defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) -PNG_EXTERN png_charp png_decompress_chunk PNGARG((png_structp png_ptr, - int comp_type, png_charp chunkdata, png_size_t chunklength, - png_size_t prefix_length, png_size_t *data_length)); -#endif - -/* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */ -PNG_EXTERN int png_crc_finish PNGARG((png_structp png_ptr, png_uint_32 skip)); - -/* Read the CRC from the file and compare it to the libpng calculated CRC */ -PNG_EXTERN int png_crc_error PNGARG((png_structp png_ptr)); - -/* Calculate the CRC over a section of data. Note that we are only - * passing a maximum of 64K on systems that have this as a memory limit, - * since this is the maximum buffer size we can specify. - */ -PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr, png_bytep ptr, - png_size_t length)); - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -PNG_EXTERN void png_flush PNGARG((png_structp png_ptr)); -#endif - -/* simple function to write the signature */ -PNG_EXTERN void png_write_sig PNGARG((png_structp png_ptr)); - -/* write various chunks */ - -/* Write the IHDR chunk, and update the png_struct with the necessary - * information. - */ -PNG_EXTERN void png_write_IHDR PNGARG((png_structp png_ptr, png_uint_32 width, - png_uint_32 height, - int bit_depth, int color_type, int compression_method, int filter_method, - int interlace_method)); - -PNG_EXTERN void png_write_PLTE PNGARG((png_structp png_ptr, png_colorp palette, - png_uint_32 num_pal)); - -PNG_EXTERN void png_write_IDAT PNGARG((png_structp png_ptr, png_bytep data, - png_size_t length)); - -PNG_EXTERN void png_write_IEND PNGARG((png_structp png_ptr)); - -#if defined(PNG_WRITE_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -PNG_EXTERN void png_write_gAMA PNGARG((png_structp png_ptr, double file_gamma)); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -PNG_EXTERN void png_write_gAMA_fixed PNGARG((png_structp png_ptr, png_fixed_point - file_gamma)); -#endif -#endif - -#if defined(PNG_WRITE_sBIT_SUPPORTED) -PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr, png_color_8p sbit, - int color_type)); -#endif - -#if defined(PNG_WRITE_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -PNG_EXTERN void png_write_cHRM PNGARG((png_structp png_ptr, - double white_x, double white_y, - double red_x, double red_y, double green_x, double green_y, - double blue_x, double blue_y)); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -PNG_EXTERN void png_write_cHRM_fixed PNGARG((png_structp png_ptr, - png_fixed_point int_white_x, png_fixed_point int_white_y, - png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point - int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, - png_fixed_point int_blue_y)); -#endif -#endif - -#if defined(PNG_WRITE_sRGB_SUPPORTED) -PNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr, - int intent)); -#endif - -#if defined(PNG_WRITE_iCCP_SUPPORTED) -PNG_EXTERN void png_write_iCCP PNGARG((png_structp png_ptr, - png_charp name, int compression_type, - png_charp profile, int proflen)); - /* Note to maintainer: profile should be png_bytep */ -#endif - -#if defined(PNG_WRITE_sPLT_SUPPORTED) -PNG_EXTERN void png_write_sPLT PNGARG((png_structp png_ptr, - png_sPLT_tp palette)); -#endif - -#if defined(PNG_WRITE_tRNS_SUPPORTED) -PNG_EXTERN void png_write_tRNS PNGARG((png_structp png_ptr, png_bytep trans, - png_color_16p values, int number, int color_type)); -#endif - -#if defined(PNG_WRITE_bKGD_SUPPORTED) -PNG_EXTERN void png_write_bKGD PNGARG((png_structp png_ptr, - png_color_16p values, int color_type)); -#endif - -#if defined(PNG_WRITE_hIST_SUPPORTED) -PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, png_uint_16p hist, - int num_hist)); -#endif - -#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \ - defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) -PNG_EXTERN png_size_t png_check_keyword PNGARG((png_structp png_ptr, - png_charp key, png_charpp new_key)); -#endif - -#if defined(PNG_WRITE_tEXt_SUPPORTED) -PNG_EXTERN void png_write_tEXt PNGARG((png_structp png_ptr, png_charp key, - png_charp text, png_size_t text_len)); -#endif - -#if defined(PNG_WRITE_zTXt_SUPPORTED) -PNG_EXTERN void png_write_zTXt PNGARG((png_structp png_ptr, png_charp key, - png_charp text, png_size_t text_len, int compression)); -#endif - -#if defined(PNG_WRITE_iTXt_SUPPORTED) -PNG_EXTERN void png_write_iTXt PNGARG((png_structp png_ptr, - int compression, png_charp key, png_charp lang, png_charp lang_key, - png_charp text)); -#endif - -#if defined(PNG_TEXT_SUPPORTED) /* Added at version 1.0.14 and 1.2.4 */ -PNG_EXTERN int png_set_text_2 PNGARG((png_structp png_ptr, - png_infop info_ptr, png_textp text_ptr, int num_text)); -#endif - -#if defined(PNG_WRITE_oFFs_SUPPORTED) -PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr, - png_int_32 x_offset, png_int_32 y_offset, int unit_type)); -#endif - -#if defined(PNG_WRITE_pCAL_SUPPORTED) -PNG_EXTERN void png_write_pCAL PNGARG((png_structp png_ptr, png_charp purpose, - png_int_32 X0, png_int_32 X1, int type, int nparams, - png_charp units, png_charpp params)); -#endif - -#if defined(PNG_WRITE_pHYs_SUPPORTED) -PNG_EXTERN void png_write_pHYs PNGARG((png_structp png_ptr, - png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit, - int unit_type)); -#endif - -#if defined(PNG_WRITE_tIME_SUPPORTED) -PNG_EXTERN void png_write_tIME PNGARG((png_structp png_ptr, - png_timep mod_time)); -#endif - -#if defined(PNG_WRITE_sCAL_SUPPORTED) -#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) -PNG_EXTERN void png_write_sCAL PNGARG((png_structp png_ptr, - int unit, double width, double height)); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -PNG_EXTERN void png_write_sCAL_s PNGARG((png_structp png_ptr, - int unit, png_charp width, png_charp height)); -#endif -#endif -#endif - -/* Called when finished processing a row of data */ -PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr)); - -/* Internal use only. Called before first row of data */ -PNG_EXTERN void png_write_start_row PNGARG((png_structp png_ptr)); - -#if defined(PNG_READ_GAMMA_SUPPORTED) -PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr)); -#endif - -/* combine a row of data, dealing with alpha, etc. if requested */ -PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row, - int mask)); - -#if defined(PNG_READ_INTERLACING_SUPPORTED) -/* expand an interlaced row */ -/* OLD pre-1.0.9 interface: -PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info, - png_bytep row, int pass, png_uint_32 transformations)); - */ -PNG_EXTERN void png_do_read_interlace PNGARG((png_structp png_ptr)); -#endif - -/* GRR TO DO (2.0 or whenever): simplify other internal calling interfaces */ - -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) -/* grab pixels out of a row for an interlaced pass */ -PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info, - png_bytep row, int pass)); -#endif - -/* unfilter a row */ -PNG_EXTERN void png_read_filter_row PNGARG((png_structp png_ptr, - png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter)); - -/* Choose the best filter to use and filter the row data */ -PNG_EXTERN void png_write_find_filter PNGARG((png_structp png_ptr, - png_row_infop row_info)); - -/* Write out the filtered row. */ -PNG_EXTERN void png_write_filtered_row PNGARG((png_structp png_ptr, - png_bytep filtered_row)); -/* finish a row while reading, dealing with interlacing passes, etc. */ -PNG_EXTERN void png_read_finish_row PNGARG((png_structp png_ptr)); - -/* initialize the row buffers, etc. */ -PNG_EXTERN void png_read_start_row PNGARG((png_structp png_ptr)); -/* optional call to update the users info structure */ -PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr, - png_infop info_ptr)); - -/* these are the functions that do the transformations */ -#if defined(PNG_READ_FILLER_SUPPORTED) -PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info, - png_bytep row, png_uint_32 filler, png_uint_32 flags)); -#endif - -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_read_swap_alpha PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_write_swap_alpha PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_read_invert_alpha PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_write_invert_alpha PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_WRITE_FILLER_SUPPORTED) || \ - defined(PNG_READ_STRIP_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info, - png_bytep row, png_uint_32 flags)); -#endif - -#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) -PNG_EXTERN void png_do_swap PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED) -PNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) -PNG_EXTERN int png_do_rgb_to_gray PNGARG((png_structp png_ptr, png_row_infop - row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) -PNG_EXTERN void png_do_gray_to_rgb PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_READ_PACK_SUPPORTED) -PNG_EXTERN void png_do_unpack PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) -PNG_EXTERN void png_do_unshift PNGARG((png_row_infop row_info, png_bytep row, - png_color_8p sig_bits)); -#endif - -#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) -PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_16_TO_8_SUPPORTED) -PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) -PNG_EXTERN void png_do_dither PNGARG((png_row_infop row_info, - png_bytep row, png_bytep palette_lookup, png_bytep dither_lookup)); - -# if defined(PNG_CORRECT_PALETTE_SUPPORTED) -PNG_EXTERN void png_correct_palette PNGARG((png_structp png_ptr, - png_colorp palette, int num_palette)); -# endif -#endif - -#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -PNG_EXTERN void png_do_bgr PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_WRITE_PACK_SUPPORTED) -PNG_EXTERN void png_do_pack PNGARG((png_row_infop row_info, - png_bytep row, png_uint_32 bit_depth)); -#endif - -#if defined(PNG_WRITE_SHIFT_SUPPORTED) -PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, png_bytep row, - png_color_8p bit_depth)); -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) -#if defined(PNG_READ_GAMMA_SUPPORTED) -PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, - png_color_16p trans_values, png_color_16p background, - png_color_16p background_1, - png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1, - png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1, - png_uint_16pp gamma_16_to_1, int gamma_shift)); -#else -PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, - png_color_16p trans_values, png_color_16p background)); -#endif -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) -PNG_EXTERN void png_do_gamma PNGARG((png_row_infop row_info, png_bytep row, - png_bytep gamma_table, png_uint_16pp gamma_16_table, - int gamma_shift)); -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) -PNG_EXTERN void png_do_expand_palette PNGARG((png_row_infop row_info, - png_bytep row, png_colorp palette, png_bytep trans, int num_trans)); -PNG_EXTERN void png_do_expand PNGARG((png_row_infop row_info, - png_bytep row, png_color_16p trans_value)); -#endif - -/* The following decodes the appropriate chunks, and does error correction, - * then calls the appropriate callback for the chunk if it is valid. - */ - -/* decode the IHDR chunk */ -PNG_EXTERN void png_handle_IHDR PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -PNG_EXTERN void png_handle_PLTE PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -PNG_EXTERN void png_handle_IEND PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); - -#if defined(PNG_READ_bKGD_SUPPORTED) -PNG_EXTERN void png_handle_bKGD PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_cHRM_SUPPORTED) -PNG_EXTERN void png_handle_cHRM PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_gAMA_SUPPORTED) -PNG_EXTERN void png_handle_gAMA PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_hIST_SUPPORTED) -PNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_iCCP_SUPPORTED) -extern void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif /* PNG_READ_iCCP_SUPPORTED */ - -#if defined(PNG_READ_iTXt_SUPPORTED) -PNG_EXTERN void png_handle_iTXt PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_oFFs_SUPPORTED) -PNG_EXTERN void png_handle_oFFs PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_pCAL_SUPPORTED) -PNG_EXTERN void png_handle_pCAL PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_pHYs_SUPPORTED) -PNG_EXTERN void png_handle_pHYs PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_sBIT_SUPPORTED) -PNG_EXTERN void png_handle_sBIT PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_sCAL_SUPPORTED) -PNG_EXTERN void png_handle_sCAL PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_sPLT_SUPPORTED) -extern void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif /* PNG_READ_sPLT_SUPPORTED */ - -#if defined(PNG_READ_sRGB_SUPPORTED) -PNG_EXTERN void png_handle_sRGB PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_tEXt_SUPPORTED) -PNG_EXTERN void png_handle_tEXt PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_tIME_SUPPORTED) -PNG_EXTERN void png_handle_tIME PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_tRNS_SUPPORTED) -PNG_EXTERN void png_handle_tRNS PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_zTXt_SUPPORTED) -PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); - -PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr, - png_bytep chunk_name)); - -/* handle the transformations for reading and writing */ -PNG_EXTERN void png_do_read_transformations PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_do_write_transformations PNGARG((png_structp png_ptr)); - -PNG_EXTERN void png_init_read_transformations PNGARG((png_structp png_ptr)); - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -PNG_EXTERN void png_push_read_chunk PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_push_read_sig PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_push_check_crc PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_push_crc_skip PNGARG((png_structp png_ptr, - png_uint_32 length)); -PNG_EXTERN void png_push_crc_finish PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_push_save_buffer PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_push_restore_buffer PNGARG((png_structp png_ptr, - png_bytep buffer, png_size_t buffer_length)); -PNG_EXTERN void png_push_read_IDAT PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_process_IDAT_data PNGARG((png_structp png_ptr, - png_bytep buffer, png_size_t buffer_length)); -PNG_EXTERN void png_push_process_row PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_push_handle_unknown PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); -PNG_EXTERN void png_push_have_info PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_push_have_end PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_push_have_row PNGARG((png_structp png_ptr, png_bytep row)); -PNG_EXTERN void png_push_read_end PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_process_some_data PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_read_push_finish_row PNGARG((png_structp png_ptr)); -#if defined(PNG_READ_tEXt_SUPPORTED) -PNG_EXTERN void png_push_handle_tEXt PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); -PNG_EXTERN void png_push_read_tEXt PNGARG((png_structp png_ptr, - png_infop info_ptr)); -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) -PNG_EXTERN void png_push_handle_zTXt PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); -PNG_EXTERN void png_push_read_zTXt PNGARG((png_structp png_ptr, - png_infop info_ptr)); -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) -PNG_EXTERN void png_push_handle_iTXt PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); -PNG_EXTERN void png_push_read_iTXt PNGARG((png_structp png_ptr, - png_infop info_ptr)); -#endif - -#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ - -#ifdef PNG_MNG_FEATURES_SUPPORTED -PNG_EXTERN void png_do_read_intrapixel PNGARG((png_row_infop row_info, - png_bytep row)); -PNG_EXTERN void png_do_write_intrapixel PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) -#if defined(PNG_MMX_CODE_SUPPORTED) -/* png.c */ /* PRIVATE */ -PNG_EXTERN void png_init_mmx_flags PNGARG((png_structp png_ptr)); -#endif -#endif - -#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED) -PNG_EXTERN png_uint_32 png_get_pixels_per_inch PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -PNG_EXTERN png_uint_32 png_get_x_pixels_per_inch PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -PNG_EXTERN png_uint_32 png_get_y_pixels_per_inch PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -PNG_EXTERN float png_get_x_offset_inches PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -PNG_EXTERN float png_get_y_offset_inches PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -#if defined(PNG_pHYs_SUPPORTED) -PNG_EXTERN png_uint_32 png_get_pHYs_dpi PNGARG((png_structp png_ptr, -png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); -#endif /* PNG_pHYs_SUPPORTED */ -#endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */ - -/* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */ - -#endif /* PNG_INTERNAL */ - -#ifdef __cplusplus -} -#endif - -#endif /* PNG_VERSION_INFO_ONLY */ -/* do not put anything past this line */ -#endif /* PNG_H */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng_osx/pngconf.h b/irrlicht-1.6/source/Irrlicht/libpng_osx/pngconf.h deleted file mode 100644 index d71a15329..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng_osx/pngconf.h +++ /dev/null @@ -1,1483 +0,0 @@ - -/* pngconf.h - machine configurable file for libpng - * - * libpng version 1.2.16 - January 31, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -/* Any machine specific code is near the front of this file, so if you - * are configuring libpng for a machine, you may want to read the section - * starting here down to where it starts to typedef png_color, png_text, - * and png_info. - */ - -#ifndef PNGCONF_H -#define PNGCONF_H - -#define PNG_1_2_X - -/* - * PNG_USER_CONFIG has to be defined on the compiler command line. This - * includes the resource compiler for Windows DLL configurations. - */ -#ifdef PNG_USER_CONFIG -# ifndef PNG_USER_PRIVATEBUILD -# define PNG_USER_PRIVATEBUILD -# endif -#include "pngusr.h" -#endif - -/* PNG_CONFIGURE_LIBPNG is set by the "configure" script. */ -#ifdef PNG_CONFIGURE_LIBPNG -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#endif - -/* - * Added at libpng-1.2.8 - * - * If you create a private DLL you need to define in "pngusr.h" the followings: - * #define PNG_USER_PRIVATEBUILD <Describes by whom and why this version of - * the DLL was built> - * e.g. #define PNG_USER_PRIVATEBUILD "Build by MyCompany for xyz reasons." - * #define PNG_USER_DLLFNAME_POSTFIX <two-letter postfix that serve to - * distinguish your DLL from those of the official release. These - * correspond to the trailing letters that come after the version - * number and must match your private DLL name> - * e.g. // private DLL "libpng13gx.dll" - * #define PNG_USER_DLLFNAME_POSTFIX "gx" - * - * The following macros are also at your disposal if you want to complete the - * DLL VERSIONINFO structure. - * - PNG_USER_VERSIONINFO_COMMENTS - * - PNG_USER_VERSIONINFO_COMPANYNAME - * - PNG_USER_VERSIONINFO_LEGALTRADEMARKS - */ - -#ifdef __STDC__ -#ifdef SPECIALBUILD -# pragma message("PNG_LIBPNG_SPECIALBUILD (and deprecated SPECIALBUILD)\ - are now LIBPNG reserved macros. Use PNG_USER_PRIVATEBUILD instead.") -#endif - -#ifdef PRIVATEBUILD -# pragma message("PRIVATEBUILD is deprecated.\ - Use PNG_USER_PRIVATEBUILD instead.") -# define PNG_USER_PRIVATEBUILD PRIVATEBUILD -#endif -#endif /* __STDC__ */ - -#ifndef PNG_VERSION_INFO_ONLY - -/* End of material added to libpng-1.2.8 */ - -/* This is the size of the compression buffer, and thus the size of - * an IDAT chunk. Make this whatever size you feel is best for your - * machine. One of these will be allocated per png_struct. When this - * is full, it writes the data to the disk, and does some other - * calculations. Making this an extremely small size will slow - * the library down, but you may want to experiment to determine - * where it becomes significant, if you are concerned with memory - * usage. Note that zlib allocates at least 32Kb also. For readers, - * this describes the size of the buffer available to read the data in. - * Unless this gets smaller than the size of a row (compressed), - * it should not make much difference how big this is. - */ - -#ifndef PNG_ZBUF_SIZE -# define PNG_ZBUF_SIZE 8192 -#endif - -/* Enable if you want a write-only libpng */ - -#ifndef PNG_NO_READ_SUPPORTED -# define PNG_READ_SUPPORTED -#endif - -/* Enable if you want a read-only libpng */ - -#ifndef PNG_NO_WRITE_SUPPORTED -# define PNG_WRITE_SUPPORTED -#endif - -/* Enabled by default in 1.2.0. You can disable this if you don't need to - support PNGs that are embedded in MNG datastreams */ -#if !defined(PNG_1_0_X) && !defined(PNG_NO_MNG_FEATURES) -# ifndef PNG_MNG_FEATURES_SUPPORTED -# define PNG_MNG_FEATURES_SUPPORTED -# endif -#endif - -#ifndef PNG_NO_FLOATING_POINT_SUPPORTED -# ifndef PNG_FLOATING_POINT_SUPPORTED -# define PNG_FLOATING_POINT_SUPPORTED -# endif -#endif - -/* If you are running on a machine where you cannot allocate more - * than 64K of memory at once, uncomment this. While libpng will not - * normally need that much memory in a chunk (unless you load up a very - * large file), zlib needs to know how big of a chunk it can use, and - * libpng thus makes sure to check any memory allocation to verify it - * will fit into memory. -#define PNG_MAX_MALLOC_64K - */ -#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K) -# define PNG_MAX_MALLOC_64K -#endif - -/* Special munging to support doing things the 'cygwin' way: - * 'Normal' png-on-win32 defines/defaults: - * PNG_BUILD_DLL -- building dll - * PNG_USE_DLL -- building an application, linking to dll - * (no define) -- building static library, or building an - * application and linking to the static lib - * 'Cygwin' defines/defaults: - * PNG_BUILD_DLL -- (ignored) building the dll - * (no define) -- (ignored) building an application, linking to the dll - * PNG_STATIC -- (ignored) building the static lib, or building an - * application that links to the static lib. - * ALL_STATIC -- (ignored) building various static libs, or building an - * application that links to the static libs. - * Thus, - * a cygwin user should define either PNG_BUILD_DLL or PNG_STATIC, and - * this bit of #ifdefs will define the 'correct' config variables based on - * that. If a cygwin user *wants* to define 'PNG_USE_DLL' that's okay, but - * unnecessary. - * - * Also, the precedence order is: - * ALL_STATIC (since we can't #undef something outside our namespace) - * PNG_BUILD_DLL - * PNG_STATIC - * (nothing) == PNG_USE_DLL - * - * CYGWIN (2002-01-20): The preceding is now obsolete. With the advent - * of auto-import in binutils, we no longer need to worry about - * __declspec(dllexport) / __declspec(dllimport) and friends. Therefore, - * we don't need to worry about PNG_STATIC or ALL_STATIC when it comes - * to __declspec() stuff. However, we DO need to worry about - * PNG_BUILD_DLL and PNG_STATIC because those change some defaults - * such as CONSOLE_IO and whether GLOBAL_ARRAYS are allowed. - */ -#if defined(__CYGWIN__) -# if defined(ALL_STATIC) -# if defined(PNG_BUILD_DLL) -# undef PNG_BUILD_DLL -# endif -# if defined(PNG_USE_DLL) -# undef PNG_USE_DLL -# endif -# if defined(PNG_DLL) -# undef PNG_DLL -# endif -# if !defined(PNG_STATIC) -# define PNG_STATIC -# endif -# else -# if defined (PNG_BUILD_DLL) -# if defined(PNG_STATIC) -# undef PNG_STATIC -# endif -# if defined(PNG_USE_DLL) -# undef PNG_USE_DLL -# endif -# if !defined(PNG_DLL) -# define PNG_DLL -# endif -# else -# if defined(PNG_STATIC) -# if defined(PNG_USE_DLL) -# undef PNG_USE_DLL -# endif -# if defined(PNG_DLL) -# undef PNG_DLL -# endif -# else -# if !defined(PNG_USE_DLL) -# define PNG_USE_DLL -# endif -# if !defined(PNG_DLL) -# define PNG_DLL -# endif -# endif -# endif -# endif -#endif - -/* This protects us against compilers that run on a windowing system - * and thus don't have or would rather us not use the stdio types: - * stdin, stdout, and stderr. The only one currently used is stderr - * in png_error() and png_warning(). #defining PNG_NO_CONSOLE_IO will - * prevent these from being compiled and used. #defining PNG_NO_STDIO - * will also prevent these, plus will prevent the entire set of stdio - * macros and functions (FILE *, printf, etc.) from being compiled and used, - * unless (PNG_DEBUG > 0) has been #defined. - * - * #define PNG_NO_CONSOLE_IO - * #define PNG_NO_STDIO - */ - -#if defined(_WIN32_WCE) -# include <windows.h> - /* Console I/O functions are not supported on WindowsCE */ -# define PNG_NO_CONSOLE_IO -# ifdef PNG_DEBUG -# undef PNG_DEBUG -# endif -#endif - -#ifdef PNG_BUILD_DLL -# ifndef PNG_CONSOLE_IO_SUPPORTED -# ifndef PNG_NO_CONSOLE_IO -# define PNG_NO_CONSOLE_IO -# endif -# endif -#endif - -# ifdef PNG_NO_STDIO -# ifndef PNG_NO_CONSOLE_IO -# define PNG_NO_CONSOLE_IO -# endif -# ifdef PNG_DEBUG -# if (PNG_DEBUG > 0) -# include <stdio.h> -# endif -# endif -# else -# if !defined(_WIN32_WCE) -/* "stdio.h" functions are not supported on WindowsCE */ -# include <stdio.h> -# endif -# endif - -/* This macro protects us against machines that don't have function - * prototypes (ie K&R style headers). If your compiler does not handle - * function prototypes, define this macro and use the included ansi2knr. - * I've always been able to use _NO_PROTO as the indicator, but you may - * need to drag the empty declaration out in front of here, or change the - * ifdef to suit your own needs. - */ -#ifndef PNGARG - -#ifdef OF /* zlib prototype munger */ -# define PNGARG(arglist) OF(arglist) -#else - -#ifdef _NO_PROTO -# define PNGARG(arglist) () -# ifndef PNG_TYPECAST_NULL -# define PNG_TYPECAST_NULL -# endif -#else -# define PNGARG(arglist) arglist -#endif /* _NO_PROTO */ - -#endif /* OF */ - -#endif /* PNGARG */ - -/* Try to determine if we are compiling on a Mac. Note that testing for - * just __MWERKS__ is not good enough, because the Codewarrior is now used - * on non-Mac platforms. - */ -#ifndef MACOS -# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \ - defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC) -# define MACOS -# endif -#endif - -/* enough people need this for various reasons to include it here */ -#if !defined(MACOS) && !defined(RISCOS) && !defined(_WIN32_WCE) -# include <sys/types.h> -#endif - -#if !defined(PNG_SETJMP_NOT_SUPPORTED) && !defined(PNG_NO_SETJMP_SUPPORTED) -# define PNG_SETJMP_SUPPORTED -#endif - -#ifdef PNG_SETJMP_SUPPORTED -/* This is an attempt to force a single setjmp behaviour on Linux. If - * the X config stuff didn't define _BSD_SOURCE we wouldn't need this. - */ - -# ifdef __linux__ -# ifdef _BSD_SOURCE -# define PNG_SAVE_BSD_SOURCE -# undef _BSD_SOURCE -# endif -# ifdef _SETJMP_H - /* If you encounter a compiler error here, see the explanation - * near the end of INSTALL. - */ - __png.h__ already includes setjmp.h; - __dont__ include it again.; -# endif -# endif /* __linux__ */ - - /* include setjmp.h for error handling */ -# include <setjmp.h> - -# ifdef __linux__ -# ifdef PNG_SAVE_BSD_SOURCE -# define _BSD_SOURCE -# undef PNG_SAVE_BSD_SOURCE -# endif -# endif /* __linux__ */ -#endif /* PNG_SETJMP_SUPPORTED */ - -#ifdef BSD -# include <strings.h> -#else -# include <string.h> -#endif - -/* Other defines for things like memory and the like can go here. */ -#ifdef PNG_INTERNAL - -#include <stdlib.h> - -/* The functions exported by PNG_EXTERN are PNG_INTERNAL functions, which - * aren't usually used outside the library (as far as I know), so it is - * debatable if they should be exported at all. In the future, when it is - * possible to have run-time registry of chunk-handling functions, some of - * these will be made available again. -#define PNG_EXTERN extern - */ -#define PNG_EXTERN - -/* Other defines specific to compilers can go here. Try to keep - * them inside an appropriate ifdef/endif pair for portability. - */ - -#if defined(PNG_FLOATING_POINT_SUPPORTED) -# if defined(MACOS) - /* We need to check that <math.h> hasn't already been included earlier - * as it seems it doesn't agree with <fp.h>, yet we should really use - * <fp.h> if possible. - */ -# if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__) -# include <fp.h> -# endif -# else -# include <math.h> -# endif -# if defined(_AMIGA) && defined(__SASC) && defined(_M68881) - /* Amiga SAS/C: We must include builtin FPU functions when compiling using - * MATH=68881 - */ -# include <m68881.h> -# endif -#endif - -/* Codewarrior on NT has linking problems without this. */ -#if (defined(__MWERKS__) && defined(WIN32)) || defined(__STDC__) -# define PNG_ALWAYS_EXTERN -#endif - -/* This provides the non-ANSI (far) memory allocation routines. */ -#if defined(__TURBOC__) && defined(__MSDOS__) -# include <mem.h> -# include <alloc.h> -#endif - -/* I have no idea why is this necessary... */ -#if defined(_MSC_VER) && (defined(WIN32) || defined(_Windows) || \ - defined(_WINDOWS) || defined(_WIN32) || defined(__WIN32__)) -# include <malloc.h> -#endif - -/* This controls how fine the dithering gets. As this allocates - * a largish chunk of memory (32K), those who are not as concerned - * with dithering quality can decrease some or all of these. - */ -#ifndef PNG_DITHER_RED_BITS -# define PNG_DITHER_RED_BITS 5 -#endif -#ifndef PNG_DITHER_GREEN_BITS -# define PNG_DITHER_GREEN_BITS 5 -#endif -#ifndef PNG_DITHER_BLUE_BITS -# define PNG_DITHER_BLUE_BITS 5 -#endif - -/* This controls how fine the gamma correction becomes when you - * are only interested in 8 bits anyway. Increasing this value - * results in more memory being used, and more pow() functions - * being called to fill in the gamma tables. Don't set this value - * less then 8, and even that may not work (I haven't tested it). - */ - -#ifndef PNG_MAX_GAMMA_8 -# define PNG_MAX_GAMMA_8 11 -#endif - -/* This controls how much a difference in gamma we can tolerate before - * we actually start doing gamma conversion. - */ -#ifndef PNG_GAMMA_THRESHOLD -# define PNG_GAMMA_THRESHOLD 0.05 -#endif - -#endif /* PNG_INTERNAL */ - -/* The following uses const char * instead of char * for error - * and warning message functions, so some compilers won't complain. - * If you do not want to use const, define PNG_NO_CONST here. - */ - -#ifndef PNG_NO_CONST -# define PNG_CONST const -#else -# define PNG_CONST -#endif - -/* The following defines give you the ability to remove code from the - * library that you will not be using. I wish I could figure out how to - * automate this, but I can't do that without making it seriously hard - * on the users. So if you are not using an ability, change the #define - * to and #undef, and that part of the library will not be compiled. If - * your linker can't find a function, you may want to make sure the - * ability is defined here. Some of these depend upon some others being - * defined. I haven't figured out all the interactions here, so you may - * have to experiment awhile to get everything to compile. If you are - * creating or using a shared library, you probably shouldn't touch this, - * as it will affect the size of the structures, and this will cause bad - * things to happen if the library and/or application ever change. - */ - -/* Any features you will not be using can be undef'ed here */ - -/* GR-P, 0.96a: Set "*TRANSFORMS_SUPPORTED as default but allow user - * to turn it off with "*TRANSFORMS_NOT_SUPPORTED" or *PNG_NO_*_TRANSFORMS - * on the compile line, then pick and choose which ones to define without - * having to edit this file. It is safe to use the *TRANSFORMS_NOT_SUPPORTED - * if you only want to have a png-compliant reader/writer but don't need - * any of the extra transformations. This saves about 80 kbytes in a - * typical installation of the library. (PNG_NO_* form added in version - * 1.0.1c, for consistency) - */ - -/* The size of the png_text structure changed in libpng-1.0.6 when - * iTXt support was added. iTXt support was turned off by default through - * libpng-1.2.x, to support old apps that malloc the png_text structure - * instead of calling png_set_text() and letting libpng malloc it. It - * was turned on by default in libpng-1.3.0. - */ - -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -# ifndef PNG_NO_iTXt_SUPPORTED -# define PNG_NO_iTXt_SUPPORTED -# endif -# ifndef PNG_NO_READ_iTXt -# define PNG_NO_READ_iTXt -# endif -# ifndef PNG_NO_WRITE_iTXt -# define PNG_NO_WRITE_iTXt -# endif -#endif - -#if !defined(PNG_NO_iTXt_SUPPORTED) -# if !defined(PNG_READ_iTXt_SUPPORTED) && !defined(PNG_NO_READ_iTXt) -# define PNG_READ_iTXt -# endif -# if !defined(PNG_WRITE_iTXt_SUPPORTED) && !defined(PNG_NO_WRITE_iTXt) -# define PNG_WRITE_iTXt -# endif -#endif - -/* The following support, added after version 1.0.0, can be turned off here en - * masse by defining PNG_LEGACY_SUPPORTED in case you need binary compatibility - * with old applications that require the length of png_struct and png_info - * to remain unchanged. - */ - -#ifdef PNG_LEGACY_SUPPORTED -# define PNG_NO_FREE_ME -# define PNG_NO_READ_UNKNOWN_CHUNKS -# define PNG_NO_WRITE_UNKNOWN_CHUNKS -# define PNG_NO_READ_USER_CHUNKS -# define PNG_NO_READ_iCCP -# define PNG_NO_WRITE_iCCP -# define PNG_NO_READ_iTXt -# define PNG_NO_WRITE_iTXt -# define PNG_NO_READ_sCAL -# define PNG_NO_WRITE_sCAL -# define PNG_NO_READ_sPLT -# define PNG_NO_WRITE_sPLT -# define PNG_NO_INFO_IMAGE -# define PNG_NO_READ_RGB_TO_GRAY -# define PNG_NO_READ_USER_TRANSFORM -# define PNG_NO_WRITE_USER_TRANSFORM -# define PNG_NO_USER_MEM -# define PNG_NO_READ_EMPTY_PLTE -# define PNG_NO_MNG_FEATURES -# define PNG_NO_FIXED_POINT_SUPPORTED -#endif - -/* Ignore attempt to turn off both floating and fixed point support */ -#if !defined(PNG_FLOATING_POINT_SUPPORTED) || \ - !defined(PNG_NO_FIXED_POINT_SUPPORTED) -# define PNG_FIXED_POINT_SUPPORTED -#endif - -#ifndef PNG_NO_FREE_ME -# define PNG_FREE_ME_SUPPORTED -#endif - -#if defined(PNG_READ_SUPPORTED) - -#if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \ - !defined(PNG_NO_READ_TRANSFORMS) -# define PNG_READ_TRANSFORMS_SUPPORTED -#endif - -#ifdef PNG_READ_TRANSFORMS_SUPPORTED -# ifndef PNG_NO_READ_EXPAND -# define PNG_READ_EXPAND_SUPPORTED -# endif -# ifndef PNG_NO_READ_SHIFT -# define PNG_READ_SHIFT_SUPPORTED -# endif -# ifndef PNG_NO_READ_PACK -# define PNG_READ_PACK_SUPPORTED -# endif -# ifndef PNG_NO_READ_BGR -# define PNG_READ_BGR_SUPPORTED -# endif -# ifndef PNG_NO_READ_SWAP -# define PNG_READ_SWAP_SUPPORTED -# endif -# ifndef PNG_NO_READ_PACKSWAP -# define PNG_READ_PACKSWAP_SUPPORTED -# endif -# ifndef PNG_NO_READ_INVERT -# define PNG_READ_INVERT_SUPPORTED -# endif -# ifndef PNG_NO_READ_DITHER -# define PNG_READ_DITHER_SUPPORTED -# endif -# ifndef PNG_NO_READ_BACKGROUND -# define PNG_READ_BACKGROUND_SUPPORTED -# endif -# ifndef PNG_NO_READ_16_TO_8 -# define PNG_READ_16_TO_8_SUPPORTED -# endif -# ifndef PNG_NO_READ_FILLER -# define PNG_READ_FILLER_SUPPORTED -# endif -# ifndef PNG_NO_READ_GAMMA -# define PNG_READ_GAMMA_SUPPORTED -# endif -# ifndef PNG_NO_READ_GRAY_TO_RGB -# define PNG_READ_GRAY_TO_RGB_SUPPORTED -# endif -# ifndef PNG_NO_READ_SWAP_ALPHA -# define PNG_READ_SWAP_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_READ_INVERT_ALPHA -# define PNG_READ_INVERT_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_READ_STRIP_ALPHA -# define PNG_READ_STRIP_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_READ_USER_TRANSFORM -# define PNG_READ_USER_TRANSFORM_SUPPORTED -# endif -# ifndef PNG_NO_READ_RGB_TO_GRAY -# define PNG_READ_RGB_TO_GRAY_SUPPORTED -# endif -#endif /* PNG_READ_TRANSFORMS_SUPPORTED */ - -#if !defined(PNG_NO_PROGRESSIVE_READ) && \ - !defined(PNG_PROGRESSIVE_READ_NOT_SUPPORTED) /* if you don't do progressive */ -# define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */ -#endif /* about interlacing capability! You'll */ - /* still have interlacing unless you change the following line: */ - -#define PNG_READ_INTERLACING_SUPPORTED /* required for PNG-compliant decoders */ - -#ifndef PNG_NO_READ_COMPOSITE_NODIV -# ifndef PNG_NO_READ_COMPOSITED_NODIV /* libpng-1.0.x misspelling */ -# define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel, SGI */ -# endif -#endif - -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* Deprecated, will be removed from version 2.0.0. - Use PNG_MNG_FEATURES_SUPPORTED instead. */ -#ifndef PNG_NO_READ_EMPTY_PLTE -# define PNG_READ_EMPTY_PLTE_SUPPORTED -#endif -#endif - -#endif /* PNG_READ_SUPPORTED */ - -#if defined(PNG_WRITE_SUPPORTED) - -# if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \ - !defined(PNG_NO_WRITE_TRANSFORMS) -# define PNG_WRITE_TRANSFORMS_SUPPORTED -#endif - -#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED -# ifndef PNG_NO_WRITE_SHIFT -# define PNG_WRITE_SHIFT_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_PACK -# define PNG_WRITE_PACK_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_BGR -# define PNG_WRITE_BGR_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_SWAP -# define PNG_WRITE_SWAP_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_PACKSWAP -# define PNG_WRITE_PACKSWAP_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_INVERT -# define PNG_WRITE_INVERT_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_FILLER -# define PNG_WRITE_FILLER_SUPPORTED /* same as WRITE_STRIP_ALPHA */ -# endif -# ifndef PNG_NO_WRITE_SWAP_ALPHA -# define PNG_WRITE_SWAP_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_INVERT_ALPHA -# define PNG_WRITE_INVERT_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_USER_TRANSFORM -# define PNG_WRITE_USER_TRANSFORM_SUPPORTED -# endif -#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */ - -#if !defined(PNG_NO_WRITE_INTERLACING_SUPPORTED) && \ - !defined(PNG_WRITE_INTERLACING_SUPPORTED) -#define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant - encoders, but can cause trouble - if left undefined */ -#endif - -#if !defined(PNG_NO_WRITE_WEIGHTED_FILTER) && \ - !defined(PNG_WRITE_WEIGHTED_FILTER) && \ - defined(PNG_FLOATING_POINT_SUPPORTED) -# define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED -#endif - -#ifndef PNG_NO_WRITE_FLUSH -# define PNG_WRITE_FLUSH_SUPPORTED -#endif - -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* Deprecated, see PNG_MNG_FEATURES_SUPPORTED, above */ -#ifndef PNG_NO_WRITE_EMPTY_PLTE -# define PNG_WRITE_EMPTY_PLTE_SUPPORTED -#endif -#endif - -#endif /* PNG_WRITE_SUPPORTED */ - -#ifndef PNG_1_0_X -# ifndef PNG_NO_ERROR_NUMBERS -# define PNG_ERROR_NUMBERS_SUPPORTED -# endif -#endif /* PNG_1_0_X */ - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) -# ifndef PNG_NO_USER_TRANSFORM_PTR -# define PNG_USER_TRANSFORM_PTR_SUPPORTED -# endif -#endif - -#ifndef PNG_NO_STDIO -# define PNG_TIME_RFC1123_SUPPORTED -#endif - -/* This adds extra functions in pngget.c for accessing data from the - * info pointer (added in version 0.99) - * png_get_image_width() - * png_get_image_height() - * png_get_bit_depth() - * png_get_color_type() - * png_get_compression_type() - * png_get_filter_type() - * png_get_interlace_type() - * png_get_pixel_aspect_ratio() - * png_get_pixels_per_meter() - * png_get_x_offset_pixels() - * png_get_y_offset_pixels() - * png_get_x_offset_microns() - * png_get_y_offset_microns() - */ -#if !defined(PNG_NO_EASY_ACCESS) && !defined(PNG_EASY_ACCESS_SUPPORTED) -# define PNG_EASY_ACCESS_SUPPORTED -#endif - -/* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0 - * even when PNG_USE_PNGVCRD or PNG_USE_PNGGCCRD is not defined. - * - * PNG_NO_ASSEMBLER_CODE disables use of all assembler code and optimized C, - * and removes or includes several functions in the API. - * - * PNG_NO_MMX_CODE disables the use of MMX code without changing the API. - * When MMX code is off, then optimized C replacement functions are used. -*/ -#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_ASSEMBLER_CODE) -# ifndef PNG_ASSEMBLER_CODE_SUPPORTED -# define PNG_ASSEMBLER_CODE_SUPPORTED -# endif -# if defined(XP_MACOSX) && !defined(PNG_NO_MMX_CODE) - /* work around Intel-Mac compiler bug */ -# define PNG_NO_MMX_CODE -# endif -# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) && \ - defined(__MMX__) -# define PNG_MMX_CODE_SUPPORTED -# endif -# if !defined(PNG_USE_PNGGCCRD) && !defined(PNG_NO_MMX_CODE) && \ - !defined(PNG_USE_PNGVCRD) && defined(__MMX__) -# define PNG_USE_PNGGCCRD -# endif -#endif - -/* If you are sure that you don't need thread safety and you are compiling - with PNG_USE_PNGCCRD for an MMX application, you can define this for - faster execution. See pnggccrd.c. -#define PNG_THREAD_UNSAFE_OK -*/ - -#if !defined(PNG_1_0_X) -#if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED) -# define PNG_USER_MEM_SUPPORTED -#endif -#endif /* PNG_1_0_X */ - -/* Added at libpng-1.2.6 */ -#if !defined(PNG_1_0_X) -#ifndef PNG_SET_USER_LIMITS_SUPPORTED -#if !defined(PNG_NO_SET_USER_LIMITS) && !defined(PNG_SET_USER_LIMITS_SUPPORTED) -# define PNG_SET_USER_LIMITS_SUPPORTED -#endif -#endif -#endif /* PNG_1_0_X */ - -/* Added at libpng-1.0.16 and 1.2.6. To accept all valid PNGS no matter - * how large, set these limits to 0x7fffffffL - */ -#ifndef PNG_USER_WIDTH_MAX -# define PNG_USER_WIDTH_MAX 1000000L -#endif -#ifndef PNG_USER_HEIGHT_MAX -# define PNG_USER_HEIGHT_MAX 1000000L -#endif - -/* These are currently experimental features, define them if you want */ - -/* very little testing */ -/* -#ifdef PNG_READ_SUPPORTED -# ifndef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED -# define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED -# endif -#endif -*/ - -/* This is only for PowerPC big-endian and 680x0 systems */ -/* some testing */ -/* -#ifndef PNG_READ_BIG_ENDIAN_SUPPORTED -# define PNG_READ_BIG_ENDIAN_SUPPORTED -#endif -*/ - -/* Buggy compilers (e.g., gcc 2.7.2.2) need this */ -/* -#define PNG_NO_POINTER_INDEXING -*/ - -/* These functions are turned off by default, as they will be phased out. */ -/* -#define PNG_USELESS_TESTS_SUPPORTED -#define PNG_CORRECT_PALETTE_SUPPORTED -*/ - -/* Any chunks you are not interested in, you can undef here. The - * ones that allocate memory may be expecially important (hIST, - * tEXt, zTXt, tRNS, pCAL). Others will just save time and make png_info - * a bit smaller. - */ - -#if defined(PNG_READ_SUPPORTED) && \ - !defined(PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \ - !defined(PNG_NO_READ_ANCILLARY_CHUNKS) -# define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED -#endif - -#if defined(PNG_WRITE_SUPPORTED) && \ - !defined(PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \ - !defined(PNG_NO_WRITE_ANCILLARY_CHUNKS) -# define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED -#endif - -#ifdef PNG_READ_ANCILLARY_CHUNKS_SUPPORTED - -#ifdef PNG_NO_READ_TEXT -# define PNG_NO_READ_iTXt -# define PNG_NO_READ_tEXt -# define PNG_NO_READ_zTXt -#endif -#ifndef PNG_NO_READ_bKGD -# define PNG_READ_bKGD_SUPPORTED -# define PNG_bKGD_SUPPORTED -#endif -#ifndef PNG_NO_READ_cHRM -# define PNG_READ_cHRM_SUPPORTED -# define PNG_cHRM_SUPPORTED -#endif -#ifndef PNG_NO_READ_gAMA -# define PNG_READ_gAMA_SUPPORTED -# define PNG_gAMA_SUPPORTED -#endif -#ifndef PNG_NO_READ_hIST -# define PNG_READ_hIST_SUPPORTED -# define PNG_hIST_SUPPORTED -#endif -#ifndef PNG_NO_READ_iCCP -# define PNG_READ_iCCP_SUPPORTED -# define PNG_iCCP_SUPPORTED -#endif -#ifndef PNG_NO_READ_iTXt -# ifndef PNG_READ_iTXt_SUPPORTED -# define PNG_READ_iTXt_SUPPORTED -# endif -# ifndef PNG_iTXt_SUPPORTED -# define PNG_iTXt_SUPPORTED -# endif -#endif -#ifndef PNG_NO_READ_oFFs -# define PNG_READ_oFFs_SUPPORTED -# define PNG_oFFs_SUPPORTED -#endif -#ifndef PNG_NO_READ_pCAL -# define PNG_READ_pCAL_SUPPORTED -# define PNG_pCAL_SUPPORTED -#endif -#ifndef PNG_NO_READ_sCAL -# define PNG_READ_sCAL_SUPPORTED -# define PNG_sCAL_SUPPORTED -#endif -#ifndef PNG_NO_READ_pHYs -# define PNG_READ_pHYs_SUPPORTED -# define PNG_pHYs_SUPPORTED -#endif -#ifndef PNG_NO_READ_sBIT -# define PNG_READ_sBIT_SUPPORTED -# define PNG_sBIT_SUPPORTED -#endif -#ifndef PNG_NO_READ_sPLT -# define PNG_READ_sPLT_SUPPORTED -# define PNG_sPLT_SUPPORTED -#endif -#ifndef PNG_NO_READ_sRGB -# define PNG_READ_sRGB_SUPPORTED -# define PNG_sRGB_SUPPORTED -#endif -#ifndef PNG_NO_READ_tEXt -# define PNG_READ_tEXt_SUPPORTED -# define PNG_tEXt_SUPPORTED -#endif -#ifndef PNG_NO_READ_tIME -# define PNG_READ_tIME_SUPPORTED -# define PNG_tIME_SUPPORTED -#endif -#ifndef PNG_NO_READ_tRNS -# define PNG_READ_tRNS_SUPPORTED -# define PNG_tRNS_SUPPORTED -#endif -#ifndef PNG_NO_READ_zTXt -# define PNG_READ_zTXt_SUPPORTED -# define PNG_zTXt_SUPPORTED -#endif -#ifndef PNG_NO_READ_UNKNOWN_CHUNKS -# define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED -# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED -# define PNG_UNKNOWN_CHUNKS_SUPPORTED -# endif -# ifndef PNG_NO_HANDLE_AS_UNKNOWN -# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED -# endif -#endif -#if !defined(PNG_NO_READ_USER_CHUNKS) && \ - defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) -# define PNG_READ_USER_CHUNKS_SUPPORTED -# define PNG_USER_CHUNKS_SUPPORTED -# ifdef PNG_NO_READ_UNKNOWN_CHUNKS -# undef PNG_NO_READ_UNKNOWN_CHUNKS -# endif -# ifdef PNG_NO_HANDLE_AS_UNKNOWN -# undef PNG_NO_HANDLE_AS_UNKNOWN -# endif -#endif -#ifndef PNG_NO_READ_OPT_PLTE -# define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */ -#endif /* optional PLTE chunk in RGB and RGBA images */ -#if defined(PNG_READ_iTXt_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) || \ - defined(PNG_READ_zTXt_SUPPORTED) -# define PNG_READ_TEXT_SUPPORTED -# define PNG_TEXT_SUPPORTED -#endif - -#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */ - -#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED - -#ifdef PNG_NO_WRITE_TEXT -# define PNG_NO_WRITE_iTXt -# define PNG_NO_WRITE_tEXt -# define PNG_NO_WRITE_zTXt -#endif -#ifndef PNG_NO_WRITE_bKGD -# define PNG_WRITE_bKGD_SUPPORTED -# ifndef PNG_bKGD_SUPPORTED -# define PNG_bKGD_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_cHRM -# define PNG_WRITE_cHRM_SUPPORTED -# ifndef PNG_cHRM_SUPPORTED -# define PNG_cHRM_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_gAMA -# define PNG_WRITE_gAMA_SUPPORTED -# ifndef PNG_gAMA_SUPPORTED -# define PNG_gAMA_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_hIST -# define PNG_WRITE_hIST_SUPPORTED -# ifndef PNG_hIST_SUPPORTED -# define PNG_hIST_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_iCCP -# define PNG_WRITE_iCCP_SUPPORTED -# ifndef PNG_iCCP_SUPPORTED -# define PNG_iCCP_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_iTXt -# ifndef PNG_WRITE_iTXt_SUPPORTED -# define PNG_WRITE_iTXt_SUPPORTED -# endif -# ifndef PNG_iTXt_SUPPORTED -# define PNG_iTXt_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_oFFs -# define PNG_WRITE_oFFs_SUPPORTED -# ifndef PNG_oFFs_SUPPORTED -# define PNG_oFFs_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_pCAL -# define PNG_WRITE_pCAL_SUPPORTED -# ifndef PNG_pCAL_SUPPORTED -# define PNG_pCAL_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_sCAL -# define PNG_WRITE_sCAL_SUPPORTED -# ifndef PNG_sCAL_SUPPORTED -# define PNG_sCAL_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_pHYs -# define PNG_WRITE_pHYs_SUPPORTED -# ifndef PNG_pHYs_SUPPORTED -# define PNG_pHYs_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_sBIT -# define PNG_WRITE_sBIT_SUPPORTED -# ifndef PNG_sBIT_SUPPORTED -# define PNG_sBIT_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_sPLT -# define PNG_WRITE_sPLT_SUPPORTED -# ifndef PNG_sPLT_SUPPORTED -# define PNG_sPLT_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_sRGB -# define PNG_WRITE_sRGB_SUPPORTED -# ifndef PNG_sRGB_SUPPORTED -# define PNG_sRGB_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_tEXt -# define PNG_WRITE_tEXt_SUPPORTED -# ifndef PNG_tEXt_SUPPORTED -# define PNG_tEXt_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_tIME -# define PNG_WRITE_tIME_SUPPORTED -# ifndef PNG_tIME_SUPPORTED -# define PNG_tIME_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_tRNS -# define PNG_WRITE_tRNS_SUPPORTED -# ifndef PNG_tRNS_SUPPORTED -# define PNG_tRNS_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_zTXt -# define PNG_WRITE_zTXt_SUPPORTED -# ifndef PNG_zTXt_SUPPORTED -# define PNG_zTXt_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS -# define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED -# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED -# define PNG_UNKNOWN_CHUNKS_SUPPORTED -# endif -# ifndef PNG_NO_HANDLE_AS_UNKNOWN -# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED -# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED -# endif -# endif -#endif -#if defined(PNG_WRITE_iTXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \ - defined(PNG_WRITE_zTXt_SUPPORTED) -# define PNG_WRITE_TEXT_SUPPORTED -# ifndef PNG_TEXT_SUPPORTED -# define PNG_TEXT_SUPPORTED -# endif -#endif - -#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */ - -/* Turn this off to disable png_read_png() and - * png_write_png() and leave the row_pointers member - * out of the info structure. - */ -#ifndef PNG_NO_INFO_IMAGE -# define PNG_INFO_IMAGE_SUPPORTED -#endif - -/* need the time information for reading tIME chunks */ -#if defined(PNG_tIME_SUPPORTED) -# if !defined(_WIN32_WCE) - /* "time.h" functions are not supported on WindowsCE */ -# include <time.h> -# endif -#endif - -/* Some typedefs to get us started. These should be safe on most of the - * common platforms. The typedefs should be at least as large as the - * numbers suggest (a png_uint_32 must be at least 32 bits long), but they - * don't have to be exactly that size. Some compilers dislike passing - * unsigned shorts as function parameters, so you may be better off using - * unsigned int for png_uint_16. Likewise, for 64-bit systems, you may - * want to have unsigned int for png_uint_32 instead of unsigned long. - */ - -typedef unsigned long png_uint_32; -typedef long png_int_32; -typedef unsigned short png_uint_16; -typedef short png_int_16; -typedef unsigned char png_byte; - -/* This is usually size_t. It is typedef'ed just in case you need it to - change (I'm not sure if you will or not, so I thought I'd be safe) */ -#ifdef PNG_SIZE_T - typedef PNG_SIZE_T png_size_t; -# define png_sizeof(x) png_convert_size(sizeof (x)) -#else - typedef size_t png_size_t; -# define png_sizeof(x) sizeof (x) -#endif - -/* The following is needed for medium model support. It cannot be in the - * PNG_INTERNAL section. Needs modification for other compilers besides - * MSC. Model independent support declares all arrays and pointers to be - * large using the far keyword. The zlib version used must also support - * model independent data. As of version zlib 1.0.4, the necessary changes - * have been made in zlib. The USE_FAR_KEYWORD define triggers other - * changes that are needed. (Tim Wegner) - */ - -/* Separate compiler dependencies (problem here is that zlib.h always - defines FAR. (SJT) */ -#ifdef __BORLANDC__ -# if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__) -# define LDATA 1 -# else -# define LDATA 0 -# endif - /* GRR: why is Cygwin in here? Cygwin is not Borland C... */ -# if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__) -# define PNG_MAX_MALLOC_64K -# if (LDATA != 1) -# ifndef FAR -# define FAR __far -# endif -# define USE_FAR_KEYWORD -# endif /* LDATA != 1 */ - /* Possibly useful for moving data out of default segment. - * Uncomment it if you want. Could also define FARDATA as - * const if your compiler supports it. (SJT) -# define FARDATA FAR - */ -# endif /* __WIN32__, __FLAT__, __CYGWIN__ */ -#endif /* __BORLANDC__ */ - - -/* Suggest testing for specific compiler first before testing for - * FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM, - * making reliance oncertain keywords suspect. (SJT) - */ - -/* MSC Medium model */ -#if defined(FAR) -# if defined(M_I86MM) -# define USE_FAR_KEYWORD -# define FARDATA FAR -# include <dos.h> -# endif -#endif - -/* SJT: default case */ -#ifndef FAR -# define FAR -#endif - -/* At this point FAR is always defined */ -#ifndef FARDATA -# define FARDATA -#endif - -/* Typedef for floating-point numbers that are converted - to fixed-point with a multiple of 100,000, e.g., int_gamma */ -typedef png_int_32 png_fixed_point; - -/* Add typedefs for pointers */ -typedef void FAR * png_voidp; -typedef png_byte FAR * png_bytep; -typedef png_uint_32 FAR * png_uint_32p; -typedef png_int_32 FAR * png_int_32p; -typedef png_uint_16 FAR * png_uint_16p; -typedef png_int_16 FAR * png_int_16p; -typedef PNG_CONST char FAR * png_const_charp; -typedef char FAR * png_charp; -typedef png_fixed_point FAR * png_fixed_point_p; - -#ifndef PNG_NO_STDIO -#if defined(_WIN32_WCE) -typedef HANDLE png_FILE_p; -#else -typedef FILE * png_FILE_p; -#endif -#endif - -#ifdef PNG_FLOATING_POINT_SUPPORTED -typedef double FAR * png_doublep; -#endif - -/* Pointers to pointers; i.e. arrays */ -typedef png_byte FAR * FAR * png_bytepp; -typedef png_uint_32 FAR * FAR * png_uint_32pp; -typedef png_int_32 FAR * FAR * png_int_32pp; -typedef png_uint_16 FAR * FAR * png_uint_16pp; -typedef png_int_16 FAR * FAR * png_int_16pp; -typedef PNG_CONST char FAR * FAR * png_const_charpp; -typedef char FAR * FAR * png_charpp; -typedef png_fixed_point FAR * FAR * png_fixed_point_pp; -#ifdef PNG_FLOATING_POINT_SUPPORTED -typedef double FAR * FAR * png_doublepp; -#endif - -/* Pointers to pointers to pointers; i.e., pointer to array */ -typedef char FAR * FAR * FAR * png_charppp; - -#if defined(PNG_1_0_X) || defined(PNG_1_2_X) -/* SPC - Is this stuff deprecated? */ -/* It'll be removed as of libpng-1.3.0 - GR-P */ -/* libpng typedefs for types in zlib. If zlib changes - * or another compression library is used, then change these. - * Eliminates need to change all the source files. - */ -typedef charf * png_zcharp; -typedef charf * FAR * png_zcharpp; -typedef z_stream FAR * png_zstreamp; -#endif /* (PNG_1_0_X) || defined(PNG_1_2_X) */ - -/* - * Define PNG_BUILD_DLL if the module being built is a Windows - * LIBPNG DLL. - * - * Define PNG_USE_DLL if you want to *link* to the Windows LIBPNG DLL. - * It is equivalent to Microsoft predefined macro _DLL that is - * automatically defined when you compile using the share - * version of the CRT (C Run-Time library) - * - * The cygwin mods make this behavior a little different: - * Define PNG_BUILD_DLL if you are building a dll for use with cygwin - * Define PNG_STATIC if you are building a static library for use with cygwin, - * -or- if you are building an application that you want to link to the - * static library. - * PNG_USE_DLL is defined by default (no user action needed) unless one of - * the other flags is defined. - */ - -#if !defined(PNG_DLL) && (defined(PNG_BUILD_DLL) || defined(PNG_USE_DLL)) -# define PNG_DLL -#endif -/* If CYGWIN, then disallow GLOBAL ARRAYS unless building a static lib. - * When building a static lib, default to no GLOBAL ARRAYS, but allow - * command-line override - */ -#if defined(__CYGWIN__) -# if !defined(PNG_STATIC) -# if defined(PNG_USE_GLOBAL_ARRAYS) -# undef PNG_USE_GLOBAL_ARRAYS -# endif -# if !defined(PNG_USE_LOCAL_ARRAYS) -# define PNG_USE_LOCAL_ARRAYS -# endif -# else -# if defined(PNG_USE_LOCAL_ARRAYS) || defined(PNG_NO_GLOBAL_ARRAYS) -# if defined(PNG_USE_GLOBAL_ARRAYS) -# undef PNG_USE_GLOBAL_ARRAYS -# endif -# endif -# endif -# if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS) -# define PNG_USE_LOCAL_ARRAYS -# endif -#endif - -/* Do not use global arrays (helps with building DLL's) - * They are no longer used in libpng itself, since version 1.0.5c, - * but might be required for some pre-1.0.5c applications. - */ -#if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS) -# if defined(PNG_NO_GLOBAL_ARRAYS) || (defined(__GNUC__) && defined(PNG_DLL)) -# define PNG_USE_LOCAL_ARRAYS -# else -# define PNG_USE_GLOBAL_ARRAYS -# endif -#endif - -#if defined(__CYGWIN__) -# undef PNGAPI -# define PNGAPI __cdecl -# undef PNG_IMPEXP -# define PNG_IMPEXP -#endif - -/* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall", - * you may get warnings regarding the linkage of png_zalloc and png_zfree. - * Don't ignore those warnings; you must also reset the default calling - * convention in your compiler to match your PNGAPI, and you must build - * zlib and your applications the same way you build libpng. - */ - -#if defined(__MINGW32__) && !defined(PNG_MODULEDEF) -# ifndef PNG_NO_MODULEDEF -# define PNG_NO_MODULEDEF -# endif -#endif - -#if !defined(PNG_IMPEXP) && defined(PNG_BUILD_DLL) && !defined(PNG_NO_MODULEDEF) -# define PNG_IMPEXP -#endif - -#if defined(PNG_DLL) || defined(_DLL) || defined(__DLL__ ) || \ - (( defined(_Windows) || defined(_WINDOWS) || \ - defined(WIN32) || defined(_WIN32) || defined(__WIN32__) )) - -# ifndef PNGAPI -# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800)) -# define PNGAPI __cdecl -# else -# define PNGAPI _cdecl -# endif -# endif - -# if !defined(PNG_IMPEXP) && (!defined(PNG_DLL) || \ - 0 /* WINCOMPILER_WITH_NO_SUPPORT_FOR_DECLIMPEXP */) -# define PNG_IMPEXP -# endif - -# if !defined(PNG_IMPEXP) - -# define PNG_EXPORT_TYPE1(type,symbol) PNG_IMPEXP type PNGAPI symbol -# define PNG_EXPORT_TYPE2(type,symbol) type PNG_IMPEXP PNGAPI symbol - - /* Borland/Microsoft */ -# if defined(_MSC_VER) || defined(__BORLANDC__) -# if (_MSC_VER >= 800) || (__BORLANDC__ >= 0x500) -# define PNG_EXPORT PNG_EXPORT_TYPE1 -# else -# define PNG_EXPORT PNG_EXPORT_TYPE2 -# if defined(PNG_BUILD_DLL) -# define PNG_IMPEXP __export -# else -# define PNG_IMPEXP /*__import */ /* doesn't exist AFAIK in - VC++ */ -# endif /* Exists in Borland C++ for - C++ classes (== huge) */ -# endif -# endif - -# if !defined(PNG_IMPEXP) -# if defined(PNG_BUILD_DLL) -# define PNG_IMPEXP __declspec(dllexport) -# else -# define PNG_IMPEXP __declspec(dllimport) -# endif -# endif -# endif /* PNG_IMPEXP */ -#else /* !(DLL || non-cygwin WINDOWS) */ -# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__) -# ifndef PNGAPI -# define PNGAPI _System -# endif -# else -# if 0 /* ... other platforms, with other meanings */ -# endif -# endif -#endif - -#ifndef PNGAPI -# define PNGAPI -#endif -#ifndef PNG_IMPEXP -# define PNG_IMPEXP -#endif - -#ifdef PNG_BUILDSYMS -# ifndef PNG_EXPORT -# define PNG_EXPORT(type,symbol) PNG_FUNCTION_EXPORT symbol END -# endif -# ifdef PNG_USE_GLOBAL_ARRAYS -# ifndef PNG_EXPORT_VAR -# define PNG_EXPORT_VAR(type) PNG_DATA_EXPORT -# endif -# endif -#endif - -#ifndef PNG_EXPORT -# define PNG_EXPORT(type,symbol) PNG_IMPEXP type PNGAPI symbol -#endif - -#ifdef PNG_USE_GLOBAL_ARRAYS -# ifndef PNG_EXPORT_VAR -# define PNG_EXPORT_VAR(type) extern PNG_IMPEXP type -# endif -#endif - -/* User may want to use these so they are not in PNG_INTERNAL. Any library - * functions that are passed far data must be model independent. - */ - -#ifndef PNG_ABORT -# define PNG_ABORT() abort() -#endif - -#ifdef PNG_SETJMP_SUPPORTED -# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) -#else -# define png_jmpbuf(png_ptr) \ - (LIBPNG_WAS_COMPILED_WITH__PNG_SETJMP_NOT_SUPPORTED) -#endif - -#if defined(USE_FAR_KEYWORD) /* memory model independent fns */ -/* use this to make far-to-near assignments */ -# define CHECK 1 -# define NOCHECK 0 -# define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK)) -# define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK)) -# define png_strcpy _fstrcpy -# define png_strncpy _fstrncpy /* Added to v 1.2.6 */ -# define png_strlen _fstrlen -# define png_memcmp _fmemcmp /* SJT: added */ -# define png_memcpy _fmemcpy -# define png_memset _fmemset -#else /* use the usual functions */ -# define CVT_PTR(ptr) (ptr) -# define CVT_PTR_NOCHECK(ptr) (ptr) -# define png_strcpy strcpy -# define png_strncpy strncpy /* Added to v 1.2.6 */ -# define png_strlen strlen -# define png_memcmp memcmp /* SJT: added */ -# define png_memcpy memcpy -# define png_memset memset -#endif -/* End of memory model independent support */ - -/* Just a little check that someone hasn't tried to define something - * contradictory. - */ -#if (PNG_ZBUF_SIZE > 65536L) && defined(PNG_MAX_MALLOC_64K) -# undef PNG_ZBUF_SIZE -# define PNG_ZBUF_SIZE 65536L -#endif - -#ifdef PNG_READ_SUPPORTED -/* Prior to libpng-1.0.9, this block was in pngasmrd.h */ -#if defined(PNG_INTERNAL) - -/* These are the default thresholds before the MMX code kicks in; if either - * rowbytes or bitdepth is below the threshold, plain C code is used. These - * can be overridden at runtime via the png_set_mmx_thresholds() call in - * libpng 1.2.0 and later. The values below were chosen by Intel. - */ - -#ifndef PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT -# define PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT 128 /* >= */ -#endif -#ifndef PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT -# define PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT 9 /* >= */ -#endif - -/* Set this in the makefile for VC++ on Pentium, not here. */ -/* Platform must be Pentium. Makefile must assemble and load pngvcrd.c . - * MMX will be detected at run time and used if present. - */ -#ifdef PNG_USE_PNGVCRD -# define PNG_HAVE_ASSEMBLER_COMBINE_ROW -# define PNG_HAVE_ASSEMBLER_READ_INTERLACE -# define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW -#endif - -/* Set this in the makefile for gcc/as on Pentium, not here. */ -/* Platform must be Pentium. Makefile must assemble and load pnggccrd.c . - * MMX will be detected at run time and used if present. - */ -#ifdef PNG_USE_PNGGCCRD -# define PNG_HAVE_ASSEMBLER_COMBINE_ROW -# define PNG_HAVE_ASSEMBLER_READ_INTERLACE -# define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW -#endif -/* - see pnggccrd.c for info about what is currently enabled */ - -#endif /* PNG_INTERNAL */ -#endif /* PNG_READ_SUPPORTED */ - -/* Added at libpng-1.2.8 */ -#endif /* PNG_VERSION_INFO_ONLY */ - -#endif /* PNGCONF_H */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng_osx/pngerror.c b/irrlicht-1.6/source/Irrlicht/libpng_osx/pngerror.c deleted file mode 100644 index c8c58b91d..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng_osx/pngerror.c +++ /dev/null @@ -1,320 +0,0 @@ - -/* pngerror.c - stub functions for i/o and memory allocation - * - * Last changed in libpng 1.2.13 November 13, 2006 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2006 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This file provides a location for all error handling. Users who - * need special error handling are expected to write replacement functions - * and use png_set_error_fn() to use those functions. See the instructions - * at each function. - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) -static void /* PRIVATE */ -png_default_error PNGARG((png_structp png_ptr, - png_const_charp error_message)); -static void /* PRIVATE */ -png_default_warning PNGARG((png_structp png_ptr, - png_const_charp warning_message)); - -/* This function is called whenever there is a fatal error. This function - * should not be changed. If there is a need to handle errors differently, - * you should supply a replacement error function and use png_set_error_fn() - * to replace the error function at run-time. - */ -void PNGAPI -png_error(png_structp png_ptr, png_const_charp error_message) -{ -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - char msg[16]; - if (png_ptr != NULL) - { - if (png_ptr->flags& - (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) - { - if (*error_message == '#') - { - int offset; - for (offset=1; offset<15; offset++) - if (*(error_message+offset) == ' ') - break; - if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT) - { - int i; - for (i=0; i<offset-1; i++) - msg[i]=error_message[i+1]; - msg[i]='\0'; - error_message=msg; - } - else - error_message+=offset; - } - else - { - if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT) - { - msg[0]='0'; - msg[1]='\0'; - error_message=msg; - } - } - } - } -#endif - if (png_ptr != NULL && png_ptr->error_fn != NULL) - (*(png_ptr->error_fn))(png_ptr, error_message); - - /* If the custom handler doesn't exist, or if it returns, - use the default handler, which will not return. */ - png_default_error(png_ptr, error_message); -} - -/* This function is called whenever there is a non-fatal error. This function - * should not be changed. If there is a need to handle warnings differently, - * you should supply a replacement warning function and use - * png_set_error_fn() to replace the warning function at run-time. - */ -void PNGAPI -png_warning(png_structp png_ptr, png_const_charp warning_message) -{ - int offset = 0; - if (png_ptr != NULL) - { -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - if (png_ptr->flags& - (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) -#endif - { - if (*warning_message == '#') - { - for (offset=1; offset<15; offset++) - if (*(warning_message+offset) == ' ') - break; - } - } - if (png_ptr != NULL && png_ptr->warning_fn != NULL) - (*(png_ptr->warning_fn))(png_ptr, warning_message+offset); - } - else - png_default_warning(png_ptr, warning_message+offset); -} - -/* These utilities are used internally to build an error message that relates - * to the current chunk. The chunk name comes from png_ptr->chunk_name, - * this is used to prefix the message. The message is limited in length - * to 63 bytes, the name characters are output as hex digits wrapped in [] - * if the character is invalid. - */ -#define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97)) -static PNG_CONST char png_digit[16] = { - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - 'A', 'B', 'C', 'D', 'E', 'F' -}; - -static void /* PRIVATE */ -png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp - error_message) -{ - int iout = 0, iin = 0; - - while (iin < 4) - { - int c = png_ptr->chunk_name[iin++]; - if (isnonalpha(c)) - { - buffer[iout++] = '['; - buffer[iout++] = png_digit[(c & 0xf0) >> 4]; - buffer[iout++] = png_digit[c & 0x0f]; - buffer[iout++] = ']'; - } - else - { - buffer[iout++] = (png_byte)c; - } - } - - if (error_message == NULL) - buffer[iout] = 0; - else - { - buffer[iout++] = ':'; - buffer[iout++] = ' '; - png_strncpy(buffer+iout, error_message, 63); - buffer[iout+63] = 0; - } -} - -void PNGAPI -png_chunk_error(png_structp png_ptr, png_const_charp error_message) -{ - char msg[18+64]; - if (png_ptr == NULL) - png_error(png_ptr, error_message); - else - { - png_format_buffer(png_ptr, msg, error_message); - png_error(png_ptr, msg); - } -} - -void PNGAPI -png_chunk_warning(png_structp png_ptr, png_const_charp warning_message) -{ - char msg[18+64]; - if (png_ptr == NULL) - png_warning(png_ptr, warning_message); - else - { - png_format_buffer(png_ptr, msg, warning_message); - png_warning(png_ptr, msg); - } -} - -/* This is the default error handling function. Note that replacements for - * this function MUST NOT RETURN, or the program will likely crash. This - * function is used by default, or if the program supplies NULL for the - * error function pointer in png_set_error_fn(). - */ -static void /* PRIVATE */ -png_default_error(png_structp png_ptr, png_const_charp error_message) -{ -#ifndef PNG_NO_CONSOLE_IO -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - if (*error_message == '#') - { - int offset; - char error_number[16]; - for (offset=0; offset<15; offset++) - { - error_number[offset] = *(error_message+offset+1); - if (*(error_message+offset) == ' ') - break; - } - if((offset > 1) && (offset < 15)) - { - error_number[offset-1]='\0'; - fprintf(stderr, "libpng error no. %s: %s\n", error_number, - error_message+offset); - } - else - fprintf(stderr, "libpng error: %s, offset=%d\n", error_message,offset); - } - else -#endif - fprintf(stderr, "libpng error: %s\n", error_message); -#endif - -#ifdef PNG_SETJMP_SUPPORTED - if (png_ptr) - { -# ifdef USE_FAR_KEYWORD - { - jmp_buf jmpbuf; - png_memcpy(jmpbuf,png_ptr->jmpbuf,png_sizeof(jmp_buf)); - longjmp(jmpbuf, 1); - } -# else - longjmp(png_ptr->jmpbuf, 1); -# endif - } -#else - PNG_ABORT(); -#endif -#ifdef PNG_NO_CONSOLE_IO - /* make compiler happy */ ; - if (&error_message != NULL) - return; -#endif -} - -/* This function is called when there is a warning, but the library thinks - * it can continue anyway. Replacement functions don't have to do anything - * here if you don't want them to. In the default configuration, png_ptr is - * not used, but it is passed in case it may be useful. - */ -static void /* PRIVATE */ -png_default_warning(png_structp png_ptr, png_const_charp warning_message) -{ -#ifndef PNG_NO_CONSOLE_IO -# ifdef PNG_ERROR_NUMBERS_SUPPORTED - if (*warning_message == '#') - { - int offset; - char warning_number[16]; - for (offset=0; offset<15; offset++) - { - warning_number[offset]=*(warning_message+offset+1); - if (*(warning_message+offset) == ' ') - break; - } - if((offset > 1) && (offset < 15)) - { - warning_number[offset-1]='\0'; - fprintf(stderr, "libpng warning no. %s: %s\n", warning_number, - warning_message+offset); - } - else - fprintf(stderr, "libpng warning: %s\n", warning_message); - } - else -# endif - fprintf(stderr, "libpng warning: %s\n", warning_message); -#else - /* make compiler happy */ ; - if (warning_message) - return; -#endif - /* make compiler happy */ ; - if (png_ptr) - return; -} - -/* This function is called when the application wants to use another method - * of handling errors and warnings. Note that the error function MUST NOT - * return to the calling routine or serious problems will occur. The return - * method used in the default routine calls longjmp(png_ptr->jmpbuf, 1) - */ -void PNGAPI -png_set_error_fn(png_structp png_ptr, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warning_fn) -{ - if (png_ptr == NULL) - return; - png_ptr->error_ptr = error_ptr; - png_ptr->error_fn = error_fn; - png_ptr->warning_fn = warning_fn; -} - - -/* This function returns a pointer to the error_ptr associated with the user - * functions. The application should free any memory associated with this - * pointer before png_write_destroy and png_read_destroy are called. - */ -png_voidp PNGAPI -png_get_error_ptr(png_structp png_ptr) -{ - if (png_ptr == NULL) - return NULL; - return ((png_voidp)png_ptr->error_ptr); -} - - -#ifdef PNG_ERROR_NUMBERS_SUPPORTED -void PNGAPI -png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode) -{ - if(png_ptr != NULL) - { - png_ptr->flags &= - ((~(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode); - } -} -#endif -#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng_osx/pnggccrd.c b/irrlicht-1.6/source/Irrlicht/libpng_osx/pnggccrd.c deleted file mode 100644 index 7983f8ea1..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng_osx/pnggccrd.c +++ /dev/null @@ -1,5420 +0,0 @@ - -/* pnggccrd.c - mixed C/assembler version of utilities to read a PNG file - * - * For Intel x86 CPU (Pentium-MMX or later) and GNU C compiler. - * - * See http://www.intel.com/drg/pentiumII/appnotes/916/916.htm - * and http://www.intel.com/drg/pentiumII/appnotes/923/923.htm - * for Intel's performance analysis of the MMX vs. non-MMX code. - * - * Last changed in libpng 1.2.15 January 5, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson - * Copyright (c) 1998, Intel Corporation - * - * Based on MSVC code contributed by Nirav Chhatrapati, Intel Corp., 1998. - * Interface to libpng contributed by Gilles Vollant, 1999. - * GNU C port by Greg Roelofs, 1999-2001. - * - * Lines 2350-4300 converted in place with intel2gas 1.3.1: - * - * intel2gas -mdI pnggccrd.c.partially-msvc -o pnggccrd.c - * - * and then cleaned up by hand. See http://hermes.terminal.at/intel2gas/ . - * - * NOTE: A sufficiently recent version of GNU as (or as.exe under DOS/Windows) - * is required to assemble the newer MMX instructions such as movq. - * For djgpp, see - * - * ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bnu281b.zip - * - * (or a later version in the same directory). For Linux, check your - * distribution's web site(s) or try these links: - * - * http://rufus.w3.org/linux/RPM/binutils.html - * http://www.debian.org/Packages/stable/devel/binutils.html - * ftp://ftp.slackware.com/pub/linux/slackware/slackware/slakware/d1/ - * binutils.tgz - * - * For other platforms, see the main GNU site: - * - * ftp://ftp.gnu.org/pub/gnu/binutils/ - * - * Version 2.5.2l.15 is definitely too old... - */ - -/* - * TEMPORARY PORTING NOTES AND CHANGELOG (mostly by Greg Roelofs) - * ===================================== - * - * 19991006: - * - fixed sign error in post-MMX cleanup code (16- & 32-bit cases) - * - * 19991007: - * - additional optimizations (possible or definite): - * x [DONE] write MMX code for 64-bit case (pixel_bytes == 8) [not tested] - * - write MMX code for 48-bit case (pixel_bytes == 6) - * - figure out what's up with 24-bit case (pixel_bytes == 3): - * why subtract 8 from width_mmx in the pass 4/5 case? - * (only width_mmx case) (near line 1606) - * x [DONE] replace pixel_bytes within each block with the true - * constant value (or are compilers smart enough to do that?) - * - rewrite all MMX interlacing code so it's aligned with - * the *beginning* of the row buffer, not the end. This - * would not only allow one to eliminate half of the memory - * writes for odd passes (that is, pass == odd), it may also - * eliminate some unaligned-data-access exceptions (assuming - * there's a penalty for not aligning 64-bit accesses on - * 64-bit boundaries). The only catch is that the "leftover" - * pixel(s) at the end of the row would have to be saved, - * but there are enough unused MMX registers in every case, - * so this is not a problem. A further benefit is that the - * post-MMX cleanup code (C code) in at least some of the - * cases could be done within the assembler block. - * x [DONE] the "v3 v2 v1 v0 v7 v6 v5 v4" comments are confusing, - * inconsistent, and don't match the MMX Programmer's Reference - * Manual conventions anyway. They should be changed to - * "b7 b6 b5 b4 b3 b2 b1 b0," where b0 indicates the byte that - * was lowest in memory (e.g., corresponding to a left pixel) - * and b7 is the byte that was highest (e.g., a right pixel). - * - * 19991016: - * - Brennan's Guide notwithstanding, gcc under Linux does *not* - * want globals prefixed by underscores when referencing them-- - * i.e., if the variable is const4, then refer to it as const4, - * not _const4. This seems to be a djgpp-specific requirement. - * Also, such variables apparently *must* be declared outside - * of functions; neither static nor automatic variables work if - * defined within the scope of a single function, but both - * static and truly global (multi-module) variables work fine. - * - * 19991023: - * - fixed png_combine_row() non-MMX replication bug (odd passes only?) - * - switched from string-concatenation-with-macros to cleaner method of - * renaming global variables for djgpp--i.e., always use prefixes in - * inlined assembler code (== strings) and conditionally rename the - * variables, not the other way around. Hence _const4, _mask8_0, etc. - * - * 19991024: - * - fixed mmxsupport()/png_do_read_interlace() first-row bug - * This one was severely weird: even though mmxsupport() doesn't touch - * ebx (where "row" pointer was stored), it nevertheless managed to zero - * the register (even in static/non-fPIC code--see below), which in turn - * caused png_do_read_interlace() to return prematurely on the first row of - * interlaced images (i.e., without expanding the interlaced pixels). - * Inspection of the generated assembly code didn't turn up any clues, - * although it did point at a minor optimization (i.e., get rid of - * mmx_supported_local variable and just use eax). Possibly the CPUID - * instruction is more destructive than it looks? (Not yet checked.) - * - "info gcc" was next to useless, so compared fPIC and non-fPIC assembly - * listings... Apparently register spillage has to do with ebx, since - * it's used to index the global offset table. Commenting it out of the - * input-reg lists in png_combine_row() eliminated compiler barfage, so - * ifdef'd with __PIC__ macro: if defined, use a global for unmask - * - * 19991107: - * - verified CPUID clobberage: 12-char string constant ("GenuineIntel", - * "AuthenticAMD", etc.) placed in ebx:ecx:edx. Still need to polish. - * - * 19991120: - * - made "diff" variable (now "_dif") global to simplify conversion of - * filtering routines (running out of regs, sigh). "diff" is still used - * in interlacing routines, however. - * - fixed up both versions of mmxsupport() (ORIG_THAT_USED_TO_CLOBBER_EBX - * macro determines which is used); original not yet tested. - * - * 20000213: - * - when compiling with gcc, be sure to use -fomit-frame-pointer - * - * 20000319: - * - fixed a register-name typo in png_do_read_interlace(), default (MMX) case, - * pass == 4 or 5, that caused visible corruption of interlaced images - * - * 20000623: - * - Various problems were reported with gcc 2.95.2 in the Cygwin environment, - * many of the form "forbidden register 0 (ax) was spilled for class AREG." - * This is explained at http://gcc.gnu.org/fom_serv/cache/23.html, and - * Chuck Wilson supplied a patch involving dummy output registers. See - * http://sourceforge.net/bugs/?func=detailbug&bug_id=108741&group_id=5624 - * for the original (anonymous) SourceForge bug report. - * - * 20000706: - * - Chuck Wilson passed along these remaining gcc 2.95.2 errors: - * pnggccrd.c: In function `png_combine_row': - * pnggccrd.c:525: more than 10 operands in `asm' - * pnggccrd.c:669: more than 10 operands in `asm' - * pnggccrd.c:828: more than 10 operands in `asm' - * pnggccrd.c:994: more than 10 operands in `asm' - * pnggccrd.c:1177: more than 10 operands in `asm' - * They are all the same problem and can be worked around by using the - * global _unmask variable unconditionally, not just in the -fPIC case. - * Reportedly earlier versions of gcc also have the problem with more than - * 10 operands; they just don't report it. Much strangeness ensues, etc. - * - * 20000729: - * - enabled png_read_filter_row_mmx_up() (shortest remaining unconverted - * MMX routine); began converting png_read_filter_row_mmx_sub() - * - to finish remaining sections: - * - clean up indentation and comments - * - preload local variables - * - add output and input regs (order of former determines numerical - * mapping of latter) - * - avoid all usage of ebx (including bx, bh, bl) register [20000823] - * - remove "$" from addressing of Shift and Mask variables [20000823] - * - * 20000731: - * - global union vars causing segfaults in png_read_filter_row_mmx_sub()? - * - * 20000822: - * - ARGH, stupid png_read_filter_row_mmx_sub() segfault only happens with - * shared-library (-fPIC) version! Code works just fine as part of static - * library. Damn damn damn damn damn, should have tested that sooner. - * ebx is getting clobbered again (explicitly this time); need to save it - * on stack or rewrite asm code to avoid using it altogether. Blargh! - * - * 20000823: - * - first section was trickiest; all remaining sections have ebx -> edx now. - * (-fPIC works again.) Also added missing underscores to various Shift* - * and *Mask* globals and got rid of leading "$" signs. - * - * 20000826: - * - added visual separators to help navigate microscopic printed copies - * (http://pobox.com/~newt/code/gpr-latest.zip, mode 10); started working - * on png_read_filter_row_mmx_avg() - * - * 20000828: - * - finished png_read_filter_row_mmx_avg(): only Paeth left! (930 lines...) - * What the hell, did png_read_filter_row_mmx_paeth(), too. Comments not - * cleaned up/shortened in either routine, but functionality is complete - * and seems to be working fine. - * - * 20000829: - * - ahhh, figured out last(?) bit of gcc/gas asm-fu: if register is listed - * as an input reg (with dummy output variables, etc.), then it *cannot* - * also appear in the clobber list or gcc 2.95.2 will barf. The solution - * is simple enough... - * - * 20000914: - * - bug in png_read_filter_row_mmx_avg(): 16-bit grayscale not handled - * correctly (but 48-bit RGB just fine) - * - * 20000916: - * - fixed bug in png_read_filter_row_mmx_avg(), bpp == 2 case; three errors: - * - "_ShiftBpp.use = 24;" should have been "_ShiftBpp.use = 16;" - * - "_ShiftRem.use = 40;" should have been "_ShiftRem.use = 48;" - * - "psllq _ShiftRem, %%mm2" should have been "psrlq _ShiftRem, %%mm2" - * - * 20010101: - * - added new png_init_mmx_flags() function (here only because it needs to - * call mmxsupport(), which should probably become global png_mmxsupport()); - * modified other MMX routines to run conditionally (png_ptr->asm_flags) - * - * 20010103: - * - renamed mmxsupport() to png_mmx_support(), with auto-set of mmx_supported, - * and made it public; moved png_init_mmx_flags() to png.c as internal func - * - * 20010104: - * - removed dependency on png_read_filter_row_c() (C code already duplicated - * within MMX version of png_read_filter_row()) so no longer necessary to - * compile it into pngrutil.o - * - * 20010310: - * - fixed buffer-overrun bug in png_combine_row() C code (non-MMX) - * - * 20020304: - * - eliminated incorrect use of width_mmx in pixel_bytes == 8 case - * - * 20040724: - * - more tinkering with clobber list at lines 4529 and 5033, to get - * it to compile on gcc-3.4. - * - * STILL TO DO: - * - test png_do_read_interlace() 64-bit case (pixel_bytes == 8) - * - write MMX code for 48-bit case (pixel_bytes == 6) - * - figure out what's up with 24-bit case (pixel_bytes == 3): - * why subtract 8 from width_mmx in the pass 4/5 case? - * (only width_mmx case) (near line 1606) - * - rewrite all MMX interlacing code so it's aligned with beginning - * of the row buffer, not the end (see 19991007 for details) - * x pick one version of mmxsupport() and get rid of the other - * - add error messages to any remaining bogus default cases - * - enable pixel_depth == 8 cases in png_read_filter_row()? (test speed) - * x add support for runtime enable/disable/query of various MMX routines - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_USE_PNGGCCRD) - -int PNGAPI png_mmx_support(void); - -#ifdef PNG_USE_LOCAL_ARRAYS -static const int FARDATA png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; -static const int FARDATA png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; -static const int FARDATA png_pass_width[7] = {8, 4, 4, 2, 2, 1, 1}; -#endif - -#if defined(PNG_MMX_CODE_SUPPORTED) -/* djgpp, Win32, Cygwin, and OS2 add their own underscores to global variables, - * so define them without: */ -#if defined(__DJGPP__) || defined(WIN32) || defined(__CYGWIN__) || \ - defined(__OS2__) -# define _mmx_supported mmx_supported -# define _const4 const4 -# define _const6 const6 -# define _mask8_0 mask8_0 -# define _mask16_1 mask16_1 -# define _mask16_0 mask16_0 -# define _mask24_2 mask24_2 -# define _mask24_1 mask24_1 -# define _mask24_0 mask24_0 -# define _mask32_3 mask32_3 -# define _mask32_2 mask32_2 -# define _mask32_1 mask32_1 -# define _mask32_0 mask32_0 -# define _mask48_5 mask48_5 -# define _mask48_4 mask48_4 -# define _mask48_3 mask48_3 -# define _mask48_2 mask48_2 -# define _mask48_1 mask48_1 -# define _mask48_0 mask48_0 -# define _LBCarryMask LBCarryMask -# define _HBClearMask HBClearMask -# define _ActiveMask ActiveMask -# define _ActiveMask2 ActiveMask2 -# define _ActiveMaskEnd ActiveMaskEnd -# define _ShiftBpp ShiftBpp -# define _ShiftRem ShiftRem -#ifdef PNG_THREAD_UNSAFE_OK -# define _unmask unmask -# define _FullLength FullLength -# define _MMXLength MMXLength -# define _dif dif -# define _patemp patemp -# define _pbtemp pbtemp -# define _pctemp pctemp -#endif -#endif - - -/* These constants are used in the inlined MMX assembly code. - Ignore gcc's "At top level: defined but not used" warnings. */ - -/* GRR 20000706: originally _unmask was needed only when compiling with -fPIC, - * since that case uses the %ebx register for indexing the Global Offset Table - * and there were no other registers available. But gcc 2.95 and later emit - * "more than 10 operands in `asm'" errors when %ebx is used to preload unmask - * in the non-PIC case, so we'll just use the global unconditionally now. - */ -#ifdef PNG_THREAD_UNSAFE_OK -static int _unmask; -#endif - -static unsigned long long _mask8_0 = 0x0102040810204080LL; - -static unsigned long long _mask16_1 = 0x0101020204040808LL; -static unsigned long long _mask16_0 = 0x1010202040408080LL; - -static unsigned long long _mask24_2 = 0x0101010202020404LL; -static unsigned long long _mask24_1 = 0x0408080810101020LL; -static unsigned long long _mask24_0 = 0x2020404040808080LL; - -static unsigned long long _mask32_3 = 0x0101010102020202LL; -static unsigned long long _mask32_2 = 0x0404040408080808LL; -static unsigned long long _mask32_1 = 0x1010101020202020LL; -static unsigned long long _mask32_0 = 0x4040404080808080LL; - -static unsigned long long _mask48_5 = 0x0101010101010202LL; -static unsigned long long _mask48_4 = 0x0202020204040404LL; -static unsigned long long _mask48_3 = 0x0404080808080808LL; -static unsigned long long _mask48_2 = 0x1010101010102020LL; -static unsigned long long _mask48_1 = 0x2020202040404040LL; -static unsigned long long _mask48_0 = 0x4040808080808080LL; - -static unsigned long long _const4 = 0x0000000000FFFFFFLL; -//static unsigned long long _const5 = 0x000000FFFFFF0000LL; // NOT USED -static unsigned long long _const6 = 0x00000000000000FFLL; - -// These are used in the row-filter routines and should/would be local -// variables if not for gcc addressing limitations. -// WARNING: Their presence probably defeats the thread safety of libpng. - -#ifdef PNG_THREAD_UNSAFE_OK -static png_uint_32 _FullLength; -static png_uint_32 _MMXLength; -static int _dif; -static int _patemp; // temp variables for Paeth routine -static int _pbtemp; -static int _pctemp; -#endif - -void /* PRIVATE */ -png_squelch_warnings(void) -{ -#ifdef PNG_THREAD_UNSAFE_OK - _dif = _dif; - _patemp = _patemp; - _pbtemp = _pbtemp; - _pctemp = _pctemp; - _MMXLength = _MMXLength; -#endif - _const4 = _const4; - _const6 = _const6; - _mask8_0 = _mask8_0; - _mask16_1 = _mask16_1; - _mask16_0 = _mask16_0; - _mask24_2 = _mask24_2; - _mask24_1 = _mask24_1; - _mask24_0 = _mask24_0; - _mask32_3 = _mask32_3; - _mask32_2 = _mask32_2; - _mask32_1 = _mask32_1; - _mask32_0 = _mask32_0; - _mask48_5 = _mask48_5; - _mask48_4 = _mask48_4; - _mask48_3 = _mask48_3; - _mask48_2 = _mask48_2; - _mask48_1 = _mask48_1; - _mask48_0 = _mask48_0; -} -#endif /* PNG_MMX_CODE_SUPPORTED */ - - -static int _mmx_supported = 2; - -/*===========================================================================*/ -/* */ -/* P N G _ C O M B I N E _ R O W */ -/* */ -/*===========================================================================*/ - -#if defined(PNG_HAVE_MMX_COMBINE_ROW) - -#define BPP2 2 -#define BPP3 3 /* bytes per pixel (a.k.a. pixel_bytes) */ -#define BPP4 4 -#define BPP6 6 /* (defined only to help avoid cut-and-paste errors) */ -#define BPP8 8 - -/* Combines the row recently read in with the previous row. - This routine takes care of alpha and transparency if requested. - This routine also handles the two methods of progressive display - of interlaced images, depending on the mask value. - The mask value describes which pixels are to be combined with - the row. The pattern always repeats every 8 pixels, so just 8 - bits are needed. A one indicates the pixel is to be combined; a - zero indicates the pixel is to be skipped. This is in addition - to any alpha or transparency value associated with the pixel. - If you want all pixels to be combined, pass 0xff (255) in mask. */ - -/* Use this routine for the x86 platform - it uses a faster MMX routine - if the machine supports MMX. */ - -void /* PRIVATE */ -png_combine_row(png_structp png_ptr, png_bytep row, int mask) -{ - png_debug(1, "in png_combine_row (pnggccrd.c)\n"); - -#if defined(PNG_MMX_CODE_SUPPORTED) - if (_mmx_supported == 2) { -#if !defined(PNG_1_0_X) - /* this should have happened in png_init_mmx_flags() already */ - png_warning(png_ptr, "asm_flags may not have been initialized"); -#endif - png_mmx_support(); - } -#endif - - if (mask == 0xff) - { - png_debug(2,"mask == 0xff: doing single png_memcpy()\n"); - png_memcpy(row, png_ptr->row_buf + 1, - (png_size_t)PNG_ROWBYTES(png_ptr->row_info.pixel_depth,png_ptr->width)); - } - else /* (png_combine_row() is never called with mask == 0) */ - { - switch (png_ptr->row_info.pixel_depth) - { - case 1: /* png_ptr->row_info.pixel_depth */ - { - png_bytep sp; - png_bytep dp; - int s_inc, s_start, s_end; - int m; - int shift; - png_uint_32 i; - - sp = png_ptr->row_buf + 1; - dp = row; - m = 0x80; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 7; - s_inc = 1; - } - else -#endif - { - s_start = 7; - s_end = 0; - s_inc = -1; - } - - shift = s_start; - - for (i = 0; i < png_ptr->width; i++) - { - if (m & mask) - { - int value; - - value = (*sp >> shift) & 0x1; - *dp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - - case 2: /* png_ptr->row_info.pixel_depth */ - { - png_bytep sp; - png_bytep dp; - int s_start, s_end, s_inc; - int m; - int shift; - png_uint_32 i; - int value; - - sp = png_ptr->row_buf + 1; - dp = row; - m = 0x80; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 6; - s_inc = 2; - } - else -#endif - { - s_start = 6; - s_end = 0; - s_inc = -2; - } - - shift = s_start; - - for (i = 0; i < png_ptr->width; i++) - { - if (m & mask) - { - value = (*sp >> shift) & 0x3; - *dp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - - case 4: /* png_ptr->row_info.pixel_depth */ - { - png_bytep sp; - png_bytep dp; - int s_start, s_end, s_inc; - int m; - int shift; - png_uint_32 i; - int value; - - sp = png_ptr->row_buf + 1; - dp = row; - m = 0x80; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 4; - s_inc = 4; - } - else -#endif - { - s_start = 4; - s_end = 0; - s_inc = -4; - } - shift = s_start; - - for (i = 0; i < png_ptr->width; i++) - { - if (m & mask) - { - value = (*sp >> shift) & 0xf; - *dp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - - case 8: /* png_ptr->row_info.pixel_depth */ - { - png_bytep srcptr; - png_bytep dstptr; - -#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && _mmx_supported */ ) -#else - if (_mmx_supported) -#endif - { - png_uint_32 len; - int diff; - int dummy_value_a; // fix 'forbidden register spilled' error - int dummy_value_d; - int dummy_value_c; - int dummy_value_S; - int dummy_value_D; - _unmask = ~mask; // global variable for -fPIC version - srcptr = png_ptr->row_buf + 1; - dstptr = row; - len = png_ptr->width &~7; // reduce to multiple of 8 - diff = (int) (png_ptr->width & 7); // amount lost - - __asm__ __volatile__ ( - "movd _unmask, %%mm7 \n\t" // load bit pattern - "psubb %%mm6, %%mm6 \n\t" // zero mm6 - "punpcklbw %%mm7, %%mm7 \n\t" - "punpcklwd %%mm7, %%mm7 \n\t" - "punpckldq %%mm7, %%mm7 \n\t" // fill reg with 8 masks - - "movq _mask8_0, %%mm0 \n\t" - "pand %%mm7, %%mm0 \n\t" // nonzero if keep byte - "pcmpeqb %%mm6, %%mm0 \n\t" // zeros->1s, v versa - -// preload "movl len, %%ecx \n\t" // load length of line -// preload "movl srcptr, %%esi \n\t" // load source -// preload "movl dstptr, %%edi \n\t" // load dest - - "cmpl $0, %%ecx \n\t" // len == 0 ? - "je mainloop8end \n\t" - - "mainloop8: \n\t" - "movq (%%esi), %%mm4 \n\t" // *srcptr - "pand %%mm0, %%mm4 \n\t" - "movq %%mm0, %%mm6 \n\t" - "pandn (%%edi), %%mm6 \n\t" // *dstptr - "por %%mm6, %%mm4 \n\t" - "movq %%mm4, (%%edi) \n\t" - "addl $8, %%esi \n\t" // inc by 8 bytes processed - "addl $8, %%edi \n\t" - "subl $8, %%ecx \n\t" // dec by 8 pixels processed - "ja mainloop8 \n\t" - - "mainloop8end: \n\t" -// preload "movl diff, %%ecx \n\t" // (diff is in eax) - "movl %%eax, %%ecx \n\t" - "cmpl $0, %%ecx \n\t" - "jz end8 \n\t" -// preload "movl mask, %%edx \n\t" - "sall $24, %%edx \n\t" // make low byte, high byte - - "secondloop8: \n\t" - "sall %%edx \n\t" // move high bit to CF - "jnc skip8 \n\t" // if CF = 0 - "movb (%%esi), %%al \n\t" - "movb %%al, (%%edi) \n\t" - - "skip8: \n\t" - "incl %%esi \n\t" - "incl %%edi \n\t" - "decl %%ecx \n\t" - "jnz secondloop8 \n\t" - - "end8: \n\t" - "EMMS \n\t" // DONE - - : "=a" (dummy_value_a), // output regs (dummy) - "=d" (dummy_value_d), - "=c" (dummy_value_c), - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "3" (srcptr), // esi // input regs - "4" (dstptr), // edi - "0" (diff), // eax -// was (unmask) "b" RESERVED // ebx // Global Offset Table idx - "2" (len), // ecx - "1" (mask) // edx - -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm4", "%mm6", "%mm7" // clobber list -#endif - ); - } - else /* mmx _not supported - Use modified C routine */ -#endif /* PNG_MMX_CODE_SUPPORTED */ - { - register png_uint_32 i; - png_uint_32 initial_val = png_pass_start[png_ptr->pass]; - /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ - register int stride = png_pass_inc[png_ptr->pass]; - /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ - register int rep_bytes = png_pass_width[png_ptr->pass]; - /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ - png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ - int diff = (int) (png_ptr->width & 7); /* amount lost */ - register png_uint_32 final_val = len; /* GRR bugfix */ - - srcptr = png_ptr->row_buf + 1 + initial_val; - dstptr = row + initial_val; - - for (i = initial_val; i < final_val; i += stride) - { - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - if (diff) /* number of leftover pixels: 3 for pngtest */ - { - final_val+=diff /* *BPP1 */ ; - for (; i < final_val; i += stride) - { - if (rep_bytes > (int)(final_val-i)) - rep_bytes = (int)(final_val-i); - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - } - - } /* end of else (_mmx_supported) */ - - break; - } /* end 8 bpp */ - - case 16: /* png_ptr->row_info.pixel_depth */ - { - png_bytep srcptr; - png_bytep dstptr; - -#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && _mmx_supported */ ) -#else - if (_mmx_supported) -#endif - { - png_uint_32 len; - int diff; - int dummy_value_a; // fix 'forbidden register spilled' error - int dummy_value_d; - int dummy_value_c; - int dummy_value_S; - int dummy_value_D; - _unmask = ~mask; // global variable for -fPIC version - srcptr = png_ptr->row_buf + 1; - dstptr = row; - len = png_ptr->width &~7; // reduce to multiple of 8 - diff = (int) (png_ptr->width & 7); // amount lost // - - __asm__ __volatile__ ( - "movd _unmask, %%mm7 \n\t" // load bit pattern - "psubb %%mm6, %%mm6 \n\t" // zero mm6 - "punpcklbw %%mm7, %%mm7 \n\t" - "punpcklwd %%mm7, %%mm7 \n\t" - "punpckldq %%mm7, %%mm7 \n\t" // fill reg with 8 masks - - "movq _mask16_0, %%mm0 \n\t" - "movq _mask16_1, %%mm1 \n\t" - - "pand %%mm7, %%mm0 \n\t" - "pand %%mm7, %%mm1 \n\t" - - "pcmpeqb %%mm6, %%mm0 \n\t" - "pcmpeqb %%mm6, %%mm1 \n\t" - -// preload "movl len, %%ecx \n\t" // load length of line -// preload "movl srcptr, %%esi \n\t" // load source -// preload "movl dstptr, %%edi \n\t" // load dest - - "cmpl $0, %%ecx \n\t" - "jz mainloop16end \n\t" - - "mainloop16: \n\t" - "movq (%%esi), %%mm4 \n\t" - "pand %%mm0, %%mm4 \n\t" - "movq %%mm0, %%mm6 \n\t" - "movq (%%edi), %%mm7 \n\t" - "pandn %%mm7, %%mm6 \n\t" - "por %%mm6, %%mm4 \n\t" - "movq %%mm4, (%%edi) \n\t" - - "movq 8(%%esi), %%mm5 \n\t" - "pand %%mm1, %%mm5 \n\t" - "movq %%mm1, %%mm7 \n\t" - "movq 8(%%edi), %%mm6 \n\t" - "pandn %%mm6, %%mm7 \n\t" - "por %%mm7, %%mm5 \n\t" - "movq %%mm5, 8(%%edi) \n\t" - - "addl $16, %%esi \n\t" // inc by 16 bytes processed - "addl $16, %%edi \n\t" - "subl $8, %%ecx \n\t" // dec by 8 pixels processed - "ja mainloop16 \n\t" - - "mainloop16end: \n\t" -// preload "movl diff, %%ecx \n\t" // (diff is in eax) - "movl %%eax, %%ecx \n\t" - "cmpl $0, %%ecx \n\t" - "jz end16 \n\t" -// preload "movl mask, %%edx \n\t" - "sall $24, %%edx \n\t" // make low byte, high byte - - "secondloop16: \n\t" - "sall %%edx \n\t" // move high bit to CF - "jnc skip16 \n\t" // if CF = 0 - "movw (%%esi), %%ax \n\t" - "movw %%ax, (%%edi) \n\t" - - "skip16: \n\t" - "addl $2, %%esi \n\t" - "addl $2, %%edi \n\t" - "decl %%ecx \n\t" - "jnz secondloop16 \n\t" - - "end16: \n\t" - "EMMS \n\t" // DONE - - : "=a" (dummy_value_a), // output regs (dummy) - "=c" (dummy_value_c), - "=d" (dummy_value_d), - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "0" (diff), // eax // input regs -// was (unmask) " " RESERVED // ebx // Global Offset Table idx - "1" (len), // ecx - "2" (mask), // edx - "3" (srcptr), // esi - "4" (dstptr) // edi - -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1", "%mm4" // clobber list - , "%mm5", "%mm6", "%mm7" -#endif - ); - } - else /* mmx _not supported - Use modified C routine */ -#endif /* PNG_MMX_CODE_SUPPORTED */ - { - register png_uint_32 i; - png_uint_32 initial_val = BPP2 * png_pass_start[png_ptr->pass]; - /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ - register int stride = BPP2 * png_pass_inc[png_ptr->pass]; - /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ - register int rep_bytes = BPP2 * png_pass_width[png_ptr->pass]; - /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ - png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ - int diff = (int) (png_ptr->width & 7); /* amount lost */ - register png_uint_32 final_val = BPP2 * len; /* GRR bugfix */ - - srcptr = png_ptr->row_buf + 1 + initial_val; - dstptr = row + initial_val; - - for (i = initial_val; i < final_val; i += stride) - { - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - if (diff) /* number of leftover pixels: 3 for pngtest */ - { - final_val+=diff*BPP2; - for (; i < final_val; i += stride) - { - if (rep_bytes > (int)(final_val-i)) - rep_bytes = (int)(final_val-i); - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - } - } /* end of else (_mmx_supported) */ - - break; - } /* end 16 bpp */ - - case 24: /* png_ptr->row_info.pixel_depth */ - { - png_bytep srcptr; - png_bytep dstptr; - -#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && _mmx_supported */ ) -#else - if (_mmx_supported) -#endif - { - png_uint_32 len; - int diff; - int dummy_value_a; // fix 'forbidden register spilled' error - int dummy_value_d; - int dummy_value_c; - int dummy_value_S; - int dummy_value_D; - _unmask = ~mask; // global variable for -fPIC version - srcptr = png_ptr->row_buf + 1; - dstptr = row; - len = png_ptr->width &~7; // reduce to multiple of 8 - diff = (int) (png_ptr->width & 7); // amount lost // - - __asm__ __volatile__ ( - "movd _unmask, %%mm7 \n\t" // load bit pattern - "psubb %%mm6, %%mm6 \n\t" // zero mm6 - "punpcklbw %%mm7, %%mm7 \n\t" - "punpcklwd %%mm7, %%mm7 \n\t" - "punpckldq %%mm7, %%mm7 \n\t" // fill reg with 8 masks - - "movq _mask24_0, %%mm0 \n\t" - "movq _mask24_1, %%mm1 \n\t" - "movq _mask24_2, %%mm2 \n\t" - - "pand %%mm7, %%mm0 \n\t" - "pand %%mm7, %%mm1 \n\t" - "pand %%mm7, %%mm2 \n\t" - - "pcmpeqb %%mm6, %%mm0 \n\t" - "pcmpeqb %%mm6, %%mm1 \n\t" - "pcmpeqb %%mm6, %%mm2 \n\t" - -// preload "movl len, %%ecx \n\t" // load length of line -// preload "movl srcptr, %%esi \n\t" // load source -// preload "movl dstptr, %%edi \n\t" // load dest - - "cmpl $0, %%ecx \n\t" - "jz mainloop24end \n\t" - - "mainloop24: \n\t" - "movq (%%esi), %%mm4 \n\t" - "pand %%mm0, %%mm4 \n\t" - "movq %%mm0, %%mm6 \n\t" - "movq (%%edi), %%mm7 \n\t" - "pandn %%mm7, %%mm6 \n\t" - "por %%mm6, %%mm4 \n\t" - "movq %%mm4, (%%edi) \n\t" - - "movq 8(%%esi), %%mm5 \n\t" - "pand %%mm1, %%mm5 \n\t" - "movq %%mm1, %%mm7 \n\t" - "movq 8(%%edi), %%mm6 \n\t" - "pandn %%mm6, %%mm7 \n\t" - "por %%mm7, %%mm5 \n\t" - "movq %%mm5, 8(%%edi) \n\t" - - "movq 16(%%esi), %%mm6 \n\t" - "pand %%mm2, %%mm6 \n\t" - "movq %%mm2, %%mm4 \n\t" - "movq 16(%%edi), %%mm7 \n\t" - "pandn %%mm7, %%mm4 \n\t" - "por %%mm4, %%mm6 \n\t" - "movq %%mm6, 16(%%edi) \n\t" - - "addl $24, %%esi \n\t" // inc by 24 bytes processed - "addl $24, %%edi \n\t" - "subl $8, %%ecx \n\t" // dec by 8 pixels processed - - "ja mainloop24 \n\t" - - "mainloop24end: \n\t" -// preload "movl diff, %%ecx \n\t" // (diff is in eax) - "movl %%eax, %%ecx \n\t" - "cmpl $0, %%ecx \n\t" - "jz end24 \n\t" -// preload "movl mask, %%edx \n\t" - "sall $24, %%edx \n\t" // make low byte, high byte - - "secondloop24: \n\t" - "sall %%edx \n\t" // move high bit to CF - "jnc skip24 \n\t" // if CF = 0 - "movw (%%esi), %%ax \n\t" - "movw %%ax, (%%edi) \n\t" - "xorl %%eax, %%eax \n\t" - "movb 2(%%esi), %%al \n\t" - "movb %%al, 2(%%edi) \n\t" - - "skip24: \n\t" - "addl $3, %%esi \n\t" - "addl $3, %%edi \n\t" - "decl %%ecx \n\t" - "jnz secondloop24 \n\t" - - "end24: \n\t" - "EMMS \n\t" // DONE - - : "=a" (dummy_value_a), // output regs (dummy) - "=d" (dummy_value_d), - "=c" (dummy_value_c), - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "3" (srcptr), // esi // input regs - "4" (dstptr), // edi - "0" (diff), // eax -// was (unmask) "b" RESERVED // ebx // Global Offset Table idx - "2" (len), // ecx - "1" (mask) // edx - -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1", "%mm2" // clobber list - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - else /* mmx _not supported - Use modified C routine */ -#endif /* PNG_MMX_CODE_SUPPORTED */ - { - register png_uint_32 i; - png_uint_32 initial_val = BPP3 * png_pass_start[png_ptr->pass]; - /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ - register int stride = BPP3 * png_pass_inc[png_ptr->pass]; - /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ - register int rep_bytes = BPP3 * png_pass_width[png_ptr->pass]; - /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ - png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ - int diff = (int) (png_ptr->width & 7); /* amount lost */ - register png_uint_32 final_val = BPP3 * len; /* GRR bugfix */ - - srcptr = png_ptr->row_buf + 1 + initial_val; - dstptr = row + initial_val; - - for (i = initial_val; i < final_val; i += stride) - { - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - if (diff) /* number of leftover pixels: 3 for pngtest */ - { - final_val+=diff*BPP3; - for (; i < final_val; i += stride) - { - if (rep_bytes > (int)(final_val-i)) - rep_bytes = (int)(final_val-i); - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - } - } /* end of else (_mmx_supported) */ - - break; - } /* end 24 bpp */ - - case 32: /* png_ptr->row_info.pixel_depth */ - { - png_bytep srcptr; - png_bytep dstptr; - -#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && _mmx_supported */ ) -#else - if (_mmx_supported) -#endif - { - png_uint_32 len; - int diff; - int dummy_value_a; // fix 'forbidden register spilled' error - int dummy_value_d; - int dummy_value_c; - int dummy_value_S; - int dummy_value_D; - _unmask = ~mask; // global variable for -fPIC version - srcptr = png_ptr->row_buf + 1; - dstptr = row; - len = png_ptr->width &~7; // reduce to multiple of 8 - diff = (int) (png_ptr->width & 7); // amount lost // - - __asm__ __volatile__ ( - "movd _unmask, %%mm7 \n\t" // load bit pattern - "psubb %%mm6, %%mm6 \n\t" // zero mm6 - "punpcklbw %%mm7, %%mm7 \n\t" - "punpcklwd %%mm7, %%mm7 \n\t" - "punpckldq %%mm7, %%mm7 \n\t" // fill reg with 8 masks - - "movq _mask32_0, %%mm0 \n\t" - "movq _mask32_1, %%mm1 \n\t" - "movq _mask32_2, %%mm2 \n\t" - "movq _mask32_3, %%mm3 \n\t" - - "pand %%mm7, %%mm0 \n\t" - "pand %%mm7, %%mm1 \n\t" - "pand %%mm7, %%mm2 \n\t" - "pand %%mm7, %%mm3 \n\t" - - "pcmpeqb %%mm6, %%mm0 \n\t" - "pcmpeqb %%mm6, %%mm1 \n\t" - "pcmpeqb %%mm6, %%mm2 \n\t" - "pcmpeqb %%mm6, %%mm3 \n\t" - -// preload "movl len, %%ecx \n\t" // load length of line -// preload "movl srcptr, %%esi \n\t" // load source -// preload "movl dstptr, %%edi \n\t" // load dest - - "cmpl $0, %%ecx \n\t" // lcr - "jz mainloop32end \n\t" - - "mainloop32: \n\t" - "movq (%%esi), %%mm4 \n\t" - "pand %%mm0, %%mm4 \n\t" - "movq %%mm0, %%mm6 \n\t" - "movq (%%edi), %%mm7 \n\t" - "pandn %%mm7, %%mm6 \n\t" - "por %%mm6, %%mm4 \n\t" - "movq %%mm4, (%%edi) \n\t" - - "movq 8(%%esi), %%mm5 \n\t" - "pand %%mm1, %%mm5 \n\t" - "movq %%mm1, %%mm7 \n\t" - "movq 8(%%edi), %%mm6 \n\t" - "pandn %%mm6, %%mm7 \n\t" - "por %%mm7, %%mm5 \n\t" - "movq %%mm5, 8(%%edi) \n\t" - - "movq 16(%%esi), %%mm6 \n\t" - "pand %%mm2, %%mm6 \n\t" - "movq %%mm2, %%mm4 \n\t" - "movq 16(%%edi), %%mm7 \n\t" - "pandn %%mm7, %%mm4 \n\t" - "por %%mm4, %%mm6 \n\t" - "movq %%mm6, 16(%%edi) \n\t" - - "movq 24(%%esi), %%mm7 \n\t" - "pand %%mm3, %%mm7 \n\t" - "movq %%mm3, %%mm5 \n\t" - "movq 24(%%edi), %%mm4 \n\t" - "pandn %%mm4, %%mm5 \n\t" - "por %%mm5, %%mm7 \n\t" - "movq %%mm7, 24(%%edi) \n\t" - - "addl $32, %%esi \n\t" // inc by 32 bytes processed - "addl $32, %%edi \n\t" - "subl $8, %%ecx \n\t" // dec by 8 pixels processed - "ja mainloop32 \n\t" - - "mainloop32end: \n\t" -// preload "movl diff, %%ecx \n\t" // (diff is in eax) - "movl %%eax, %%ecx \n\t" - "cmpl $0, %%ecx \n\t" - "jz end32 \n\t" -// preload "movl mask, %%edx \n\t" - "sall $24, %%edx \n\t" // low byte => high byte - - "secondloop32: \n\t" - "sall %%edx \n\t" // move high bit to CF - "jnc skip32 \n\t" // if CF = 0 - "movl (%%esi), %%eax \n\t" - "movl %%eax, (%%edi) \n\t" - - "skip32: \n\t" - "addl $4, %%esi \n\t" - "addl $4, %%edi \n\t" - "decl %%ecx \n\t" - "jnz secondloop32 \n\t" - - "end32: \n\t" - "EMMS \n\t" // DONE - - : "=a" (dummy_value_a), // output regs (dummy) - "=d" (dummy_value_d), - "=c" (dummy_value_c), - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "3" (srcptr), // esi // input regs - "4" (dstptr), // edi - "0" (diff), // eax -// was (unmask) "b" RESERVED // ebx // Global Offset Table idx - "2" (len), // ecx - "1" (mask) // edx - -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1", "%mm2", "%mm3" // clobber list - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - else /* mmx _not supported - Use modified C routine */ -#endif /* PNG_MMX_CODE_SUPPORTED */ - { - register png_uint_32 i; - png_uint_32 initial_val = BPP4 * png_pass_start[png_ptr->pass]; - /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ - register int stride = BPP4 * png_pass_inc[png_ptr->pass]; - /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ - register int rep_bytes = BPP4 * png_pass_width[png_ptr->pass]; - /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ - png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ - int diff = (int) (png_ptr->width & 7); /* amount lost */ - register png_uint_32 final_val = BPP4 * len; /* GRR bugfix */ - - srcptr = png_ptr->row_buf + 1 + initial_val; - dstptr = row + initial_val; - - for (i = initial_val; i < final_val; i += stride) - { - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - if (diff) /* number of leftover pixels: 3 for pngtest */ - { - final_val+=diff*BPP4; - for (; i < final_val; i += stride) - { - if (rep_bytes > (int)(final_val-i)) - rep_bytes = (int)(final_val-i); - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - } - } /* end of else (_mmx_supported) */ - - break; - } /* end 32 bpp */ - - case 48: /* png_ptr->row_info.pixel_depth */ - { - png_bytep srcptr; - png_bytep dstptr; - -#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && _mmx_supported */ ) -#else - if (_mmx_supported) -#endif - { - png_uint_32 len; - int diff; - int dummy_value_a; // fix 'forbidden register spilled' error - int dummy_value_d; - int dummy_value_c; - int dummy_value_S; - int dummy_value_D; - _unmask = ~mask; // global variable for -fPIC version - srcptr = png_ptr->row_buf + 1; - dstptr = row; - len = png_ptr->width &~7; // reduce to multiple of 8 - diff = (int) (png_ptr->width & 7); // amount lost // - - __asm__ __volatile__ ( - "movd _unmask, %%mm7 \n\t" // load bit pattern - "psubb %%mm6, %%mm6 \n\t" // zero mm6 - "punpcklbw %%mm7, %%mm7 \n\t" - "punpcklwd %%mm7, %%mm7 \n\t" - "punpckldq %%mm7, %%mm7 \n\t" // fill reg with 8 masks - - "movq _mask48_0, %%mm0 \n\t" - "movq _mask48_1, %%mm1 \n\t" - "movq _mask48_2, %%mm2 \n\t" - "movq _mask48_3, %%mm3 \n\t" - "movq _mask48_4, %%mm4 \n\t" - "movq _mask48_5, %%mm5 \n\t" - - "pand %%mm7, %%mm0 \n\t" - "pand %%mm7, %%mm1 \n\t" - "pand %%mm7, %%mm2 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pand %%mm7, %%mm4 \n\t" - "pand %%mm7, %%mm5 \n\t" - - "pcmpeqb %%mm6, %%mm0 \n\t" - "pcmpeqb %%mm6, %%mm1 \n\t" - "pcmpeqb %%mm6, %%mm2 \n\t" - "pcmpeqb %%mm6, %%mm3 \n\t" - "pcmpeqb %%mm6, %%mm4 \n\t" - "pcmpeqb %%mm6, %%mm5 \n\t" - -// preload "movl len, %%ecx \n\t" // load length of line -// preload "movl srcptr, %%esi \n\t" // load source -// preload "movl dstptr, %%edi \n\t" // load dest - - "cmpl $0, %%ecx \n\t" - "jz mainloop48end \n\t" - - "mainloop48: \n\t" - "movq (%%esi), %%mm7 \n\t" - "pand %%mm0, %%mm7 \n\t" - "movq %%mm0, %%mm6 \n\t" - "pandn (%%edi), %%mm6 \n\t" - "por %%mm6, %%mm7 \n\t" - "movq %%mm7, (%%edi) \n\t" - - "movq 8(%%esi), %%mm6 \n\t" - "pand %%mm1, %%mm6 \n\t" - "movq %%mm1, %%mm7 \n\t" - "pandn 8(%%edi), %%mm7 \n\t" - "por %%mm7, %%mm6 \n\t" - "movq %%mm6, 8(%%edi) \n\t" - - "movq 16(%%esi), %%mm6 \n\t" - "pand %%mm2, %%mm6 \n\t" - "movq %%mm2, %%mm7 \n\t" - "pandn 16(%%edi), %%mm7 \n\t" - "por %%mm7, %%mm6 \n\t" - "movq %%mm6, 16(%%edi) \n\t" - - "movq 24(%%esi), %%mm7 \n\t" - "pand %%mm3, %%mm7 \n\t" - "movq %%mm3, %%mm6 \n\t" - "pandn 24(%%edi), %%mm6 \n\t" - "por %%mm6, %%mm7 \n\t" - "movq %%mm7, 24(%%edi) \n\t" - - "movq 32(%%esi), %%mm6 \n\t" - "pand %%mm4, %%mm6 \n\t" - "movq %%mm4, %%mm7 \n\t" - "pandn 32(%%edi), %%mm7 \n\t" - "por %%mm7, %%mm6 \n\t" - "movq %%mm6, 32(%%edi) \n\t" - - "movq 40(%%esi), %%mm7 \n\t" - "pand %%mm5, %%mm7 \n\t" - "movq %%mm5, %%mm6 \n\t" - "pandn 40(%%edi), %%mm6 \n\t" - "por %%mm6, %%mm7 \n\t" - "movq %%mm7, 40(%%edi) \n\t" - - "addl $48, %%esi \n\t" // inc by 48 bytes processed - "addl $48, %%edi \n\t" - "subl $8, %%ecx \n\t" // dec by 8 pixels processed - - "ja mainloop48 \n\t" - - "mainloop48end: \n\t" -// preload "movl diff, %%ecx \n\t" // (diff is in eax) - "movl %%eax, %%ecx \n\t" - "cmpl $0, %%ecx \n\t" - "jz end48 \n\t" -// preload "movl mask, %%edx \n\t" - "sall $24, %%edx \n\t" // make low byte, high byte - - "secondloop48: \n\t" - "sall %%edx \n\t" // move high bit to CF - "jnc skip48 \n\t" // if CF = 0 - "movl (%%esi), %%eax \n\t" - "movl %%eax, (%%edi) \n\t" - - "skip48: \n\t" - "addl $4, %%esi \n\t" - "addl $4, %%edi \n\t" - "decl %%ecx \n\t" - "jnz secondloop48 \n\t" - - "end48: \n\t" - "EMMS \n\t" // DONE - - : "=a" (dummy_value_a), // output regs (dummy) - "=d" (dummy_value_d), - "=c" (dummy_value_c), - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "3" (srcptr), // esi // input regs - "4" (dstptr), // edi - "0" (diff), // eax -// was (unmask) "b" RESERVED // ebx // Global Offset Table idx - "2" (len), // ecx - "1" (mask) // edx - -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1", "%mm2", "%mm3" // clobber list - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - else /* mmx _not supported - Use modified C routine */ -#endif /* PNG_MMX_CODE_SUPPORTED */ - { - register png_uint_32 i; - png_uint_32 initial_val = BPP6 * png_pass_start[png_ptr->pass]; - /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ - register int stride = BPP6 * png_pass_inc[png_ptr->pass]; - /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ - register int rep_bytes = BPP6 * png_pass_width[png_ptr->pass]; - /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ - png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ - int diff = (int) (png_ptr->width & 7); /* amount lost */ - register png_uint_32 final_val = BPP6 * len; /* GRR bugfix */ - - srcptr = png_ptr->row_buf + 1 + initial_val; - dstptr = row + initial_val; - - for (i = initial_val; i < final_val; i += stride) - { - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - if (diff) /* number of leftover pixels: 3 for pngtest */ - { - final_val+=diff*BPP6; - for (; i < final_val; i += stride) - { - if (rep_bytes > (int)(final_val-i)) - rep_bytes = (int)(final_val-i); - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - } - } /* end of else (_mmx_supported) */ - - break; - } /* end 48 bpp */ - - case 64: /* png_ptr->row_info.pixel_depth */ - { - png_bytep srcptr; - png_bytep dstptr; - register png_uint_32 i; - png_uint_32 initial_val = BPP8 * png_pass_start[png_ptr->pass]; - /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ - register int stride = BPP8 * png_pass_inc[png_ptr->pass]; - /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ - register int rep_bytes = BPP8 * png_pass_width[png_ptr->pass]; - /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ - png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ - int diff = (int) (png_ptr->width & 7); /* amount lost */ - register png_uint_32 final_val = BPP8 * len; /* GRR bugfix */ - - srcptr = png_ptr->row_buf + 1 + initial_val; - dstptr = row + initial_val; - - for (i = initial_val; i < final_val; i += stride) - { - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - if (diff) /* number of leftover pixels: 3 for pngtest */ - { - final_val+=diff*BPP8; - for (; i < final_val; i += stride) - { - if (rep_bytes > (int)(final_val-i)) - rep_bytes = (int)(final_val-i); - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - } - - break; - } /* end 64 bpp */ - - default: /* png_ptr->row_info.pixel_depth != 1,2,4,8,16,24,32,48,64 */ - { - /* this should never happen */ - png_warning(png_ptr, "Invalid row_info.pixel_depth in pnggccrd"); - break; - } - } /* end switch (png_ptr->row_info.pixel_depth) */ - - } /* end if (non-trivial mask) */ - -} /* end png_combine_row() */ - -#endif /* PNG_HAVE_MMX_COMBINE_ROW */ - - - - -/*===========================================================================*/ -/* */ -/* P N G _ D O _ R E A D _ I N T E R L A C E */ -/* */ -/*===========================================================================*/ - -#if defined(PNG_READ_INTERLACING_SUPPORTED) -#if defined(PNG_HAVE_MMX_READ_INTERLACE) - -/* png_do_read_interlace() is called after any 16-bit to 8-bit conversion - * has taken place. [GRR: what other steps come before and/or after?] - */ - -void /* PRIVATE */ -png_do_read_interlace(png_structp png_ptr) -{ - png_row_infop row_info = &(png_ptr->row_info); - png_bytep row = png_ptr->row_buf + 1; - int pass = png_ptr->pass; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - png_uint_32 transformations = png_ptr->transformations; -#endif - - png_debug(1, "in png_do_read_interlace (pnggccrd.c)\n"); - -#if defined(PNG_MMX_CODE_SUPPORTED) - if (_mmx_supported == 2) { -#if !defined(PNG_1_0_X) - /* this should have happened in png_init_mmx_flags() already */ - png_warning(png_ptr, "asm_flags may not have been initialized"); -#endif - png_mmx_support(); - } -#endif - - if (row != NULL && row_info != NULL) - { - png_uint_32 final_width; - - final_width = row_info->width * png_pass_inc[pass]; - - switch (row_info->pixel_depth) - { - case 1: - { - png_bytep sp, dp; - int sshift, dshift; - int s_start, s_end, s_inc; - png_byte v; - png_uint_32 i; - int j; - - sp = row + (png_size_t)((row_info->width - 1) >> 3); - dp = row + (png_size_t)((final_width - 1) >> 3); -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (int)((row_info->width + 7) & 7); - dshift = (int)((final_width + 7) & 7); - s_start = 7; - s_end = 0; - s_inc = -1; - } - else -#endif - { - sshift = 7 - (int)((row_info->width + 7) & 7); - dshift = 7 - (int)((final_width + 7) & 7); - s_start = 0; - s_end = 7; - s_inc = 1; - } - - for (i = row_info->width; i; i--) - { - v = (png_byte)((*sp >> sshift) & 0x1); - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp &= (png_byte)((0x7f7f >> (7 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - - case 2: - { - png_bytep sp, dp; - int sshift, dshift; - int s_start, s_end, s_inc; - png_uint_32 i; - - sp = row + (png_size_t)((row_info->width - 1) >> 2); - dp = row + (png_size_t)((final_width - 1) >> 2); -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (png_size_t)(((row_info->width + 3) & 3) << 1); - dshift = (png_size_t)(((final_width + 3) & 3) << 1); - s_start = 6; - s_end = 0; - s_inc = -2; - } - else -#endif - { - sshift = (png_size_t)((3 - ((row_info->width + 3) & 3)) << 1); - dshift = (png_size_t)((3 - ((final_width + 3) & 3)) << 1); - s_start = 0; - s_end = 6; - s_inc = 2; - } - - for (i = row_info->width; i; i--) - { - png_byte v; - int j; - - v = (png_byte)((*sp >> sshift) & 0x3); - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp &= (png_byte)((0x3f3f >> (6 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - - case 4: - { - png_bytep sp, dp; - int sshift, dshift; - int s_start, s_end, s_inc; - png_uint_32 i; - - sp = row + (png_size_t)((row_info->width - 1) >> 1); - dp = row + (png_size_t)((final_width - 1) >> 1); -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (png_size_t)(((row_info->width + 1) & 1) << 2); - dshift = (png_size_t)(((final_width + 1) & 1) << 2); - s_start = 4; - s_end = 0; - s_inc = -4; - } - else -#endif - { - sshift = (png_size_t)((1 - ((row_info->width + 1) & 1)) << 2); - dshift = (png_size_t)((1 - ((final_width + 1) & 1)) << 2); - s_start = 0; - s_end = 4; - s_inc = 4; - } - - for (i = row_info->width; i; i--) - { - png_byte v; - int j; - - v = (png_byte)((*sp >> sshift) & 0xf); - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp &= (png_byte)((0xf0f >> (4 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - - /*====================================================================*/ - - default: /* 8-bit or larger (this is where the routine is modified) */ - { -#if 0 -// static unsigned long long _const4 = 0x0000000000FFFFFFLL; no good -// static unsigned long long const4 = 0x0000000000FFFFFFLL; no good -// unsigned long long _const4 = 0x0000000000FFFFFFLL; no good -// unsigned long long const4 = 0x0000000000FFFFFFLL; no good -#endif - png_bytep sptr, dp; - png_uint_32 i; - png_size_t pixel_bytes; - int width = (int)row_info->width; - - pixel_bytes = (row_info->pixel_depth >> 3); - - /* point sptr at the last pixel in the pre-expanded row: */ - sptr = row + (width - 1) * pixel_bytes; - - /* point dp at the last pixel position in the expanded row: */ - dp = row + (final_width - 1) * pixel_bytes; - - /* New code by Nirav Chhatrapati - Intel Corporation */ - -#if defined(PNG_MMX_CODE_SUPPORTED) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_INTERLACE) - /* && _mmx_supported */ ) -#else - if (_mmx_supported) -#endif - { - //-------------------------------------------------------------- - if (pixel_bytes == 3) - { - if (((pass == 0) || (pass == 1)) && width) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - int dummy_value_a; - - __asm__ __volatile__ ( - "subl $21, %%edi \n\t" - // (png_pass_inc[pass] - 1)*pixel_bytes - - ".loop3_pass0: \n\t" - "movd (%%esi), %%mm0 \n\t" // x x x x x 2 1 0 - "pand (%3), %%mm0 \n\t" // z z z z z 2 1 0 - "movq %%mm0, %%mm1 \n\t" // z z z z z 2 1 0 - "psllq $16, %%mm0 \n\t" // z z z 2 1 0 z z - "movq %%mm0, %%mm2 \n\t" // z z z 2 1 0 z z - "psllq $24, %%mm0 \n\t" // 2 1 0 z z z z z - "psrlq $8, %%mm1 \n\t" // z z z z z z 2 1 - "por %%mm2, %%mm0 \n\t" // 2 1 0 2 1 0 z z - "por %%mm1, %%mm0 \n\t" // 2 1 0 2 1 0 2 1 - "movq %%mm0, %%mm3 \n\t" // 2 1 0 2 1 0 2 1 - "psllq $16, %%mm0 \n\t" // 0 2 1 0 2 1 z z - "movq %%mm3, %%mm4 \n\t" // 2 1 0 2 1 0 2 1 - "punpckhdq %%mm0, %%mm3 \n\t" // 0 2 1 0 2 1 0 2 - "movq %%mm4, 16(%%edi) \n\t" - "psrlq $32, %%mm0 \n\t" // z z z z 0 2 1 0 - "movq %%mm3, 8(%%edi) \n\t" - "punpckldq %%mm4, %%mm0 \n\t" // 1 0 2 1 0 2 1 0 - "subl $3, %%esi \n\t" - "movq %%mm0, (%%edi) \n\t" - "subl $24, %%edi \n\t" - "decl %%ecx \n\t" - "jnz .loop3_pass0 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D), - "=a" (dummy_value_a) - - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width), // ecx - "3" (&_const4) // %1(?) (0x0000000000FFFFFFLL) - -#if 0 /* %mm0, ..., %mm4 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1", "%mm2" // clobber list - , "%mm3", "%mm4" -#endif - ); - } - else if (((pass == 2) || (pass == 3)) && width) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - int dummy_value_a; - - __asm__ __volatile__ ( - "subl $9, %%edi \n\t" - // (png_pass_inc[pass] - 1)*pixel_bytes - - ".loop3_pass2: \n\t" - "movd (%%esi), %%mm0 \n\t" // x x x x x 2 1 0 - "pand (%3), %%mm0 \n\t" // z z z z z 2 1 0 - "movq %%mm0, %%mm1 \n\t" // z z z z z 2 1 0 - "psllq $16, %%mm0 \n\t" // z z z 2 1 0 z z - "movq %%mm0, %%mm2 \n\t" // z z z 2 1 0 z z - "psllq $24, %%mm0 \n\t" // 2 1 0 z z z z z - "psrlq $8, %%mm1 \n\t" // z z z z z z 2 1 - "por %%mm2, %%mm0 \n\t" // 2 1 0 2 1 0 z z - "por %%mm1, %%mm0 \n\t" // 2 1 0 2 1 0 2 1 - "movq %%mm0, 4(%%edi) \n\t" - "psrlq $16, %%mm0 \n\t" // z z 2 1 0 2 1 0 - "subl $3, %%esi \n\t" - "movd %%mm0, (%%edi) \n\t" - "subl $12, %%edi \n\t" - "decl %%ecx \n\t" - "jnz .loop3_pass2 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D), - "=a" (dummy_value_a) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width), // ecx - "3" (&_const4) // (0x0000000000FFFFFFLL) - -#if 0 /* %mm0, ..., %mm2 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1", "%mm2" // clobber list -#endif - ); - } - else if (width) /* && ((pass == 4) || (pass == 5)) */ - { - int width_mmx = ((width >> 1) << 1) - 8; // GRR: huh? - if (width_mmx < 0) - width_mmx = 0; - width -= width_mmx; // 8 or 9 pix, 24 or 27 bytes - if (width_mmx) - { - // png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; - // sptr points at last pixel in pre-expanded row - // dp points at last pixel position in expanded row - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - int dummy_value_a; - int dummy_value_d; - - __asm__ __volatile__ ( - "subl $3, %%esi \n\t" - "subl $9, %%edi \n\t" - // (png_pass_inc[pass] + 1)*pixel_bytes - - ".loop3_pass4: \n\t" - "movq (%%esi), %%mm0 \n\t" // x x 5 4 3 2 1 0 - "movq %%mm0, %%mm1 \n\t" // x x 5 4 3 2 1 0 - "movq %%mm0, %%mm2 \n\t" // x x 5 4 3 2 1 0 - "psllq $24, %%mm0 \n\t" // 4 3 2 1 0 z z z - "pand (%3), %%mm1 \n\t" // z z z z z 2 1 0 - "psrlq $24, %%mm2 \n\t" // z z z x x 5 4 3 - "por %%mm1, %%mm0 \n\t" // 4 3 2 1 0 2 1 0 - "movq %%mm2, %%mm3 \n\t" // z z z x x 5 4 3 - "psllq $8, %%mm2 \n\t" // z z x x 5 4 3 z - "movq %%mm0, (%%edi) \n\t" - "psrlq $16, %%mm3 \n\t" // z z z z z x x 5 - "pand (%4), %%mm3 \n\t" // z z z z z z z 5 - "por %%mm3, %%mm2 \n\t" // z z x x 5 4 3 5 - "subl $6, %%esi \n\t" - "movd %%mm2, 8(%%edi) \n\t" - "subl $12, %%edi \n\t" - "subl $2, %%ecx \n\t" - "jnz .loop3_pass4 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D), - "=a" (dummy_value_a), - "=d" (dummy_value_d) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx), // ecx - "3" (&_const4), // 0x0000000000FFFFFFLL - "4" (&_const6) // 0x00000000000000FFLL - -#if 0 /* %mm0, ..., %mm3 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list - , "%mm2", "%mm3" -#endif - ); - } - - sptr -= width_mmx*3; - dp -= width_mmx*6; - for (i = width; i; i--) - { - png_byte v[8]; - int j; - - png_memcpy(v, sptr, 3); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 3); - dp -= 3; - } - sptr -= 3; - } - } - } /* end of pixel_bytes == 3 */ - - //-------------------------------------------------------------- - else if (pixel_bytes == 1) - { - if (((pass == 0) || (pass == 1)) && width) - { - int width_mmx = ((width >> 2) << 2); - width -= width_mmx; // 0-3 pixels => 0-3 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $3, %%esi \n\t" - "subl $31, %%edi \n\t" - - ".loop1_pass0: \n\t" - "movd (%%esi), %%mm0 \n\t" // x x x x 3 2 1 0 - "movq %%mm0, %%mm1 \n\t" // x x x x 3 2 1 0 - "punpcklbw %%mm0, %%mm0 \n\t" // 3 3 2 2 1 1 0 0 - "movq %%mm0, %%mm2 \n\t" // 3 3 2 2 1 1 0 0 - "punpcklwd %%mm0, %%mm0 \n\t" // 1 1 1 1 0 0 0 0 - "movq %%mm0, %%mm3 \n\t" // 1 1 1 1 0 0 0 0 - "punpckldq %%mm0, %%mm0 \n\t" // 0 0 0 0 0 0 0 0 - "punpckhdq %%mm3, %%mm3 \n\t" // 1 1 1 1 1 1 1 1 - "movq %%mm0, (%%edi) \n\t" - "punpckhwd %%mm2, %%mm2 \n\t" // 3 3 3 3 2 2 2 2 - "movq %%mm3, 8(%%edi) \n\t" - "movq %%mm2, %%mm4 \n\t" // 3 3 3 3 2 2 2 2 - "punpckldq %%mm2, %%mm2 \n\t" // 2 2 2 2 2 2 2 2 - "punpckhdq %%mm4, %%mm4 \n\t" // 3 3 3 3 3 3 3 3 - "movq %%mm2, 16(%%edi) \n\t" - "subl $4, %%esi \n\t" - "movq %%mm4, 24(%%edi) \n\t" - "subl $32, %%edi \n\t" - "subl $4, %%ecx \n\t" - "jnz .loop1_pass0 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, ..., %mm4 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1", "%mm2" // clobber list - , "%mm3", "%mm4" -#endif - ); - } - - sptr -= width_mmx; - dp -= width_mmx*8; - for (i = width; i; i--) - { - int j; - - /* I simplified this part in version 1.0.4e - * here and in several other instances where - * pixel_bytes == 1 -- GR-P - * - * Original code: - * - * png_byte v[8]; - * png_memcpy(v, sptr, pixel_bytes); - * for (j = 0; j < png_pass_inc[pass]; j++) - * { - * png_memcpy(dp, v, pixel_bytes); - * dp -= pixel_bytes; - * } - * sptr -= pixel_bytes; - * - * Replacement code is in the next three lines: - */ - - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp-- = *sptr; - } - --sptr; - } - } - else if (((pass == 2) || (pass == 3)) && width) - { - int width_mmx = ((width >> 2) << 2); - width -= width_mmx; // 0-3 pixels => 0-3 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $3, %%esi \n\t" - "subl $15, %%edi \n\t" - - ".loop1_pass2: \n\t" - "movd (%%esi), %%mm0 \n\t" // x x x x 3 2 1 0 - "punpcklbw %%mm0, %%mm0 \n\t" // 3 3 2 2 1 1 0 0 - "movq %%mm0, %%mm1 \n\t" // 3 3 2 2 1 1 0 0 - "punpcklwd %%mm0, %%mm0 \n\t" // 1 1 1 1 0 0 0 0 - "punpckhwd %%mm1, %%mm1 \n\t" // 3 3 3 3 2 2 2 2 - "movq %%mm0, (%%edi) \n\t" - "subl $4, %%esi \n\t" - "movq %%mm1, 8(%%edi) \n\t" - "subl $16, %%edi \n\t" - "subl $4, %%ecx \n\t" - "jnz .loop1_pass2 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list -#endif - ); - } - - sptr -= width_mmx; - dp -= width_mmx*4; - for (i = width; i; i--) - { - int j; - - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp-- = *sptr; - } - --sptr; - } - } - else if (width) /* && ((pass == 4) || (pass == 5)) */ - { - int width_mmx = ((width >> 3) << 3); - width -= width_mmx; // 0-3 pixels => 0-3 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $7, %%esi \n\t" - "subl $15, %%edi \n\t" - - ".loop1_pass4: \n\t" - "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 - "movq %%mm0, %%mm1 \n\t" // 7 6 5 4 3 2 1 0 - "punpcklbw %%mm0, %%mm0 \n\t" // 3 3 2 2 1 1 0 0 - "punpckhbw %%mm1, %%mm1 \n\t" // 7 7 6 6 5 5 4 4 - "movq %%mm1, 8(%%edi) \n\t" - "subl $8, %%esi \n\t" - "movq %%mm0, (%%edi) \n\t" - "subl $16, %%edi \n\t" - "subl $8, %%ecx \n\t" - "jnz .loop1_pass4 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (none) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list -#endif - ); - } - - sptr -= width_mmx; - dp -= width_mmx*2; - for (i = width; i; i--) - { - int j; - - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp-- = *sptr; - } - --sptr; - } - } - } /* end of pixel_bytes == 1 */ - - //-------------------------------------------------------------- - else if (pixel_bytes == 2) - { - if (((pass == 0) || (pass == 1)) && width) - { - int width_mmx = ((width >> 1) << 1); - width -= width_mmx; // 0,1 pixels => 0,2 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $2, %%esi \n\t" - "subl $30, %%edi \n\t" - - ".loop2_pass0: \n\t" - "movd (%%esi), %%mm0 \n\t" // x x x x 3 2 1 0 - "punpcklwd %%mm0, %%mm0 \n\t" // 3 2 3 2 1 0 1 0 - "movq %%mm0, %%mm1 \n\t" // 3 2 3 2 1 0 1 0 - "punpckldq %%mm0, %%mm0 \n\t" // 1 0 1 0 1 0 1 0 - "punpckhdq %%mm1, %%mm1 \n\t" // 3 2 3 2 3 2 3 2 - "movq %%mm0, (%%edi) \n\t" - "movq %%mm0, 8(%%edi) \n\t" - "movq %%mm1, 16(%%edi) \n\t" - "subl $4, %%esi \n\t" - "movq %%mm1, 24(%%edi) \n\t" - "subl $32, %%edi \n\t" - "subl $2, %%ecx \n\t" - "jnz .loop2_pass0 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list -#endif - ); - } - - sptr -= (width_mmx*2 - 2); // sign fixed - dp -= (width_mmx*16 - 2); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 2; - png_memcpy(v, sptr, 2); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 2; - png_memcpy(dp, v, 2); - } - } - } - else if (((pass == 2) || (pass == 3)) && width) - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; // 0,1 pixels => 0,2 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $2, %%esi \n\t" - "subl $14, %%edi \n\t" - - ".loop2_pass2: \n\t" - "movd (%%esi), %%mm0 \n\t" // x x x x 3 2 1 0 - "punpcklwd %%mm0, %%mm0 \n\t" // 3 2 3 2 1 0 1 0 - "movq %%mm0, %%mm1 \n\t" // 3 2 3 2 1 0 1 0 - "punpckldq %%mm0, %%mm0 \n\t" // 1 0 1 0 1 0 1 0 - "punpckhdq %%mm1, %%mm1 \n\t" // 3 2 3 2 3 2 3 2 - "movq %%mm0, (%%edi) \n\t" - "subl $4, %%esi \n\t" - "movq %%mm1, 8(%%edi) \n\t" - "subl $16, %%edi \n\t" - "subl $2, %%ecx \n\t" - "jnz .loop2_pass2 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list -#endif - ); - } - - sptr -= (width_mmx*2 - 2); // sign fixed - dp -= (width_mmx*8 - 2); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 2; - png_memcpy(v, sptr, 2); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 2; - png_memcpy(dp, v, 2); - } - } - } - else if (width) // pass == 4 or 5 - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; // 0,1 pixels => 0,2 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $2, %%esi \n\t" - "subl $6, %%edi \n\t" - - ".loop2_pass4: \n\t" - "movd (%%esi), %%mm0 \n\t" // x x x x 3 2 1 0 - "punpcklwd %%mm0, %%mm0 \n\t" // 3 2 3 2 1 0 1 0 - "subl $4, %%esi \n\t" - "movq %%mm0, (%%edi) \n\t" - "subl $8, %%edi \n\t" - "subl $2, %%ecx \n\t" - "jnz .loop2_pass4 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0" // clobber list -#endif - ); - } - - sptr -= (width_mmx*2 - 2); // sign fixed - dp -= (width_mmx*4 - 2); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 2; - png_memcpy(v, sptr, 2); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 2; - png_memcpy(dp, v, 2); - } - } - } - } /* end of pixel_bytes == 2 */ - - //-------------------------------------------------------------- - else if (pixel_bytes == 4) - { - if (((pass == 0) || (pass == 1)) && width) - { - int width_mmx = ((width >> 1) << 1); - width -= width_mmx; // 0,1 pixels => 0,4 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $4, %%esi \n\t" - "subl $60, %%edi \n\t" - - ".loop4_pass0: \n\t" - "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 - "movq %%mm0, %%mm1 \n\t" // 7 6 5 4 3 2 1 0 - "punpckldq %%mm0, %%mm0 \n\t" // 3 2 1 0 3 2 1 0 - "punpckhdq %%mm1, %%mm1 \n\t" // 7 6 5 4 7 6 5 4 - "movq %%mm0, (%%edi) \n\t" - "movq %%mm0, 8(%%edi) \n\t" - "movq %%mm0, 16(%%edi) \n\t" - "movq %%mm0, 24(%%edi) \n\t" - "movq %%mm1, 32(%%edi) \n\t" - "movq %%mm1, 40(%%edi) \n\t" - "movq %%mm1, 48(%%edi) \n\t" - "subl $8, %%esi \n\t" - "movq %%mm1, 56(%%edi) \n\t" - "subl $64, %%edi \n\t" - "subl $2, %%ecx \n\t" - "jnz .loop4_pass0 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list -#endif - ); - } - - sptr -= (width_mmx*4 - 4); // sign fixed - dp -= (width_mmx*32 - 4); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 4; - png_memcpy(v, sptr, 4); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 4; - png_memcpy(dp, v, 4); - } - } - } - else if (((pass == 2) || (pass == 3)) && width) - { - int width_mmx = ((width >> 1) << 1); - width -= width_mmx; // 0,1 pixels => 0,4 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $4, %%esi \n\t" - "subl $28, %%edi \n\t" - - ".loop4_pass2: \n\t" - "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 - "movq %%mm0, %%mm1 \n\t" // 7 6 5 4 3 2 1 0 - "punpckldq %%mm0, %%mm0 \n\t" // 3 2 1 0 3 2 1 0 - "punpckhdq %%mm1, %%mm1 \n\t" // 7 6 5 4 7 6 5 4 - "movq %%mm0, (%%edi) \n\t" - "movq %%mm0, 8(%%edi) \n\t" - "movq %%mm1, 16(%%edi) \n\t" - "movq %%mm1, 24(%%edi) \n\t" - "subl $8, %%esi \n\t" - "subl $32, %%edi \n\t" - "subl $2, %%ecx \n\t" - "jnz .loop4_pass2 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list -#endif - ); - } - - sptr -= (width_mmx*4 - 4); // sign fixed - dp -= (width_mmx*16 - 4); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 4; - png_memcpy(v, sptr, 4); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 4; - png_memcpy(dp, v, 4); - } - } - } - else if (width) // pass == 4 or 5 - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; // 0,1 pixels => 0,4 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $4, %%esi \n\t" - "subl $12, %%edi \n\t" - - ".loop4_pass4: \n\t" - "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 - "movq %%mm0, %%mm1 \n\t" // 7 6 5 4 3 2 1 0 - "punpckldq %%mm0, %%mm0 \n\t" // 3 2 1 0 3 2 1 0 - "punpckhdq %%mm1, %%mm1 \n\t" // 7 6 5 4 7 6 5 4 - "movq %%mm0, (%%edi) \n\t" - "subl $8, %%esi \n\t" - "movq %%mm1, 8(%%edi) \n\t" - "subl $16, %%edi \n\t" - "subl $2, %%ecx \n\t" - "jnz .loop4_pass4 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list -#endif - ); - } - - sptr -= (width_mmx*4 - 4); // sign fixed - dp -= (width_mmx*8 - 4); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 4; - png_memcpy(v, sptr, 4); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 4; - png_memcpy(dp, v, 4); - } - } - } - } /* end of pixel_bytes == 4 */ - - //-------------------------------------------------------------- - else if (pixel_bytes == 8) - { -// GRR TEST: should work, but needs testing (special 64-bit version of rpng2?) - // GRR NOTE: no need to combine passes here! - if (((pass == 0) || (pass == 1)) && width) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - // source is 8-byte RRGGBBAA - // dest is 64-byte RRGGBBAA RRGGBBAA RRGGBBAA RRGGBBAA ... - __asm__ __volatile__ ( - "subl $56, %%edi \n\t" // start of last block - - ".loop8_pass0: \n\t" - "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 - "movq %%mm0, (%%edi) \n\t" - "movq %%mm0, 8(%%edi) \n\t" - "movq %%mm0, 16(%%edi) \n\t" - "movq %%mm0, 24(%%edi) \n\t" - "movq %%mm0, 32(%%edi) \n\t" - "movq %%mm0, 40(%%edi) \n\t" - "movq %%mm0, 48(%%edi) \n\t" - "subl $8, %%esi \n\t" - "movq %%mm0, 56(%%edi) \n\t" - "subl $64, %%edi \n\t" - "decl %%ecx \n\t" - "jnz .loop8_pass0 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width) // ecx - -#if 0 /* %mm0 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0" // clobber list -#endif - ); - } - else if (((pass == 2) || (pass == 3)) && width) - { - // source is 8-byte RRGGBBAA - // dest is 32-byte RRGGBBAA RRGGBBAA RRGGBBAA RRGGBBAA - // (recall that expansion is _in place_: sptr and dp - // both point at locations within same row buffer) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $24, %%edi \n\t" // start of last block - - ".loop8_pass2: \n\t" - "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 - "movq %%mm0, (%%edi) \n\t" - "movq %%mm0, 8(%%edi) \n\t" - "movq %%mm0, 16(%%edi) \n\t" - "subl $8, %%esi \n\t" - "movq %%mm0, 24(%%edi) \n\t" - "subl $32, %%edi \n\t" - "decl %%ecx \n\t" - "jnz .loop8_pass2 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width) // ecx - -#if 0 /* %mm0 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0" // clobber list -#endif - ); - } - } - else if (width) // pass == 4 or 5 - { - // source is 8-byte RRGGBBAA - // dest is 16-byte RRGGBBAA RRGGBBAA - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $8, %%edi \n\t" // start of last block - - ".loop8_pass4: \n\t" - "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 - "movq %%mm0, (%%edi) \n\t" - "subl $8, %%esi \n\t" - "movq %%mm0, 8(%%edi) \n\t" - "subl $16, %%edi \n\t" - "decl %%ecx \n\t" - "jnz .loop8_pass4 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width) // ecx - -#if 0 /* %mm0 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0" // clobber list -#endif - ); - } - } - - } /* end of pixel_bytes == 8 */ - - //-------------------------------------------------------------- - else if (pixel_bytes == 6) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, 6); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 6); - dp -= 6; - } - sptr -= 6; - } - } /* end of pixel_bytes == 6 */ - - //-------------------------------------------------------------- - else - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr-= pixel_bytes; - } - } - } // end of _mmx_supported ======================================== - - else /* MMX not supported: use modified C code - takes advantage - * of inlining of png_memcpy for a constant */ - /* GRR 19991007: does it? or should pixel_bytes in each - * block be replaced with immediate value (e.g., 1)? */ - /* GRR 19991017: replaced with constants in each case */ -#endif /* PNG_MMX_CODE_SUPPORTED */ - { - if (pixel_bytes == 1) - { - for (i = width; i; i--) - { - int j; - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp-- = *sptr; - } - --sptr; - } - } - else if (pixel_bytes == 3) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, 3); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 3); - dp -= 3; - } - sptr -= 3; - } - } - else if (pixel_bytes == 2) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, 2); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 2); - dp -= 2; - } - sptr -= 2; - } - } - else if (pixel_bytes == 4) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, 4); - for (j = 0; j < png_pass_inc[pass]; j++) - { -#ifdef PNG_DEBUG - if (dp < row || dp+3 > row+png_ptr->row_buf_size) - { - printf("dp out of bounds: row=%d, dp=%d, rp=%d\n", - row, dp, row+png_ptr->row_buf_size); - printf("row_buf=%d\n",png_ptr->row_buf_size); - } -#endif - png_memcpy(dp, v, 4); - dp -= 4; - } - sptr -= 4; - } - } - else if (pixel_bytes == 6) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, 6); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 6); - dp -= 6; - } - sptr -= 6; - } - } - else if (pixel_bytes == 8) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, 8); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 8); - dp -= 8; - } - sptr -= 8; - } - } - else /* GRR: should never be reached */ - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr -= pixel_bytes; - } - } - - } /* end if (MMX not supported) */ - break; - } - } /* end switch (row_info->pixel_depth) */ - - row_info->width = final_width; - - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,final_width); - } - -} /* end png_do_read_interlace() */ - -#endif /* PNG_HAVE_MMX_READ_INTERLACE */ -#endif /* PNG_READ_INTERLACING_SUPPORTED */ - - - -#if defined(PNG_HAVE_MMX_READ_FILTER_ROW) -#if defined(PNG_MMX_CODE_SUPPORTED) - -// These variables are utilized in the functions below. They are declared -// globally here to ensure alignment on 8-byte boundaries. - -union uAll { - long long use; - double align; -} _LBCarryMask = {0x0101010101010101LL}, - _HBClearMask = {0x7f7f7f7f7f7f7f7fLL}, - _ActiveMask, _ActiveMask2, _ActiveMaskEnd, _ShiftBpp, _ShiftRem; - -#ifdef PNG_THREAD_UNSAFE_OK -//===========================================================================// -// // -// P N G _ R E A D _ F I L T E R _ R O W _ M M X _ A V G // -// // -//===========================================================================// - -// Optimized code for PNG Average filter decoder - -static void /* PRIVATE */ -png_read_filter_row_mmx_avg(png_row_infop row_info, png_bytep row, - png_bytep prev_row) -{ - int bpp; - int dummy_value_c; // fix 'forbidden register 2 (cx) was spilled' error - int dummy_value_S; - int dummy_value_D; - - bpp = (row_info->pixel_depth + 7) >> 3; // get # bytes per pixel - _FullLength = row_info->rowbytes; // # of bytes to filter - - __asm__ __volatile__ ( - // initialize address pointers and offset -#ifdef __PIC__ - "pushl %%ebx \n\t" // save index to Global Offset Table -#endif -//pre "movl row, %%edi \n\t" // edi: Avg(x) - "xorl %%ebx, %%ebx \n\t" // ebx: x - "movl %%edi, %%edx \n\t" -//pre "movl prev_row, %%esi \n\t" // esi: Prior(x) -//pre "subl bpp, %%edx \n\t" // (bpp is preloaded into ecx) - "subl %%ecx, %%edx \n\t" // edx: Raw(x-bpp) - - "xorl %%eax,%%eax \n\t" - - // Compute the Raw value for the first bpp bytes - // Raw(x) = Avg(x) + (Prior(x)/2) - "avg_rlp: \n\t" - "movb (%%esi,%%ebx,),%%al \n\t" // load al with Prior(x) - "incl %%ebx \n\t" - "shrb %%al \n\t" // divide by 2 - "addb -1(%%edi,%%ebx,),%%al \n\t" // add Avg(x); -1 to offset inc ebx -//pre "cmpl bpp, %%ebx \n\t" // (bpp is preloaded into ecx) - "cmpl %%ecx, %%ebx \n\t" - "movb %%al,-1(%%edi,%%ebx,) \n\t" // write Raw(x); -1 to offset inc ebx - "jb avg_rlp \n\t" // mov does not affect flags - - // get # of bytes to alignment - "movl %%edi, _dif \n\t" // take start of row - "addl %%ebx, _dif \n\t" // add bpp - "addl $0xf, _dif \n\t" // add 7+8 to incr past alignment bdry - "andl $0xfffffff8, _dif \n\t" // mask to alignment boundary - "subl %%edi, _dif \n\t" // subtract from start => value ebx at - "jz avg_go \n\t" // alignment - - // fix alignment - // Compute the Raw value for the bytes up to the alignment boundary - // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) - "xorl %%ecx, %%ecx \n\t" - - "avg_lp1: \n\t" - "xorl %%eax, %%eax \n\t" - "movb (%%esi,%%ebx,), %%cl \n\t" // load cl with Prior(x) - "movb (%%edx,%%ebx,), %%al \n\t" // load al with Raw(x-bpp) - "addw %%cx, %%ax \n\t" - "incl %%ebx \n\t" - "shrw %%ax \n\t" // divide by 2 - "addb -1(%%edi,%%ebx,), %%al \n\t" // add Avg(x); -1 to offset inc ebx - "cmpl _dif, %%ebx \n\t" // check if at alignment boundary - "movb %%al, -1(%%edi,%%ebx,) \n\t" // write Raw(x); -1 to offset inc ebx - "jb avg_lp1 \n\t" // repeat until at alignment boundary - - "avg_go: \n\t" - "movl _FullLength, %%eax \n\t" - "movl %%eax, %%ecx \n\t" - "subl %%ebx, %%eax \n\t" // subtract alignment fix - "andl $0x00000007, %%eax \n\t" // calc bytes over mult of 8 - "subl %%eax, %%ecx \n\t" // drop over bytes from original length - "movl %%ecx, _MMXLength \n\t" -#ifdef __PIC__ - "popl %%ebx \n\t" // restore index to Global Offset Table -#endif - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "0" (bpp), // ecx // input regs - "1" (prev_row), // esi - "2" (row) // edi - - : "%eax", "%edx" // clobber list -#ifndef __PIC__ - , "%ebx" -#endif - // GRR: INCLUDE "memory" as clobbered? (_dif, _MMXLength) - // (seems to work fine without...) - ); - - // now do the math for the rest of the row - switch (bpp) - { - case 3: - { - _ActiveMask.use = 0x0000000000ffffffLL; - _ShiftBpp.use = 24; // == 3 * 8 - _ShiftRem.use = 40; // == 64 - 24 - - __asm__ __volatile__ ( - // re-init address pointers and offset - "movq _ActiveMask, %%mm7 \n\t" - "movl _dif, %%ecx \n\t" // ecx: x = offset to - "movq _LBCarryMask, %%mm5 \n\t" // alignment boundary -// preload "movl row, %%edi \n\t" // edi: Avg(x) - "movq _HBClearMask, %%mm4 \n\t" -// preload "movl prev_row, %%esi \n\t" // esi: Prior(x) - - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm2 \n\t" // load previous aligned 8 bytes - // (correct pos. in loop below) - "avg_3lp: \n\t" - "movq (%%edi,%%ecx,), %%mm0 \n\t" // load mm0 with Avg(x) - "movq %%mm5, %%mm3 \n\t" - "psrlq _ShiftRem, %%mm2 \n\t" // correct position Raw(x-bpp) - // data - "movq (%%esi,%%ecx,), %%mm1 \n\t" // load mm1 with Prior(x) - "movq %%mm7, %%mm6 \n\t" - "pand %%mm1, %%mm3 \n\t" // get lsb for each prev_row byte - "psrlq $1, %%mm1 \n\t" // divide prev_row bytes by 2 - "pand %%mm4, %%mm1 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm0 \n\t" // add (Prev_row/2) to Avg for - // each byte - // add 1st active group (Raw(x-bpp)/2) to average with LBCarry - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting - // LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte - // where both - // lsb's were == 1 (only valid for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) - // for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 1 - // bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to - // Avg for each Active - // byte - // add 2nd active group (Raw(x-bpp)/2) to average with _LBCarry - "psllq _ShiftBpp, %%mm6 \n\t" // shift the mm6 mask to cover - // bytes 3-5 - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "psllq _ShiftBpp, %%mm2 \n\t" // shift data to pos. correctly - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting - // LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte - // where both - // lsb's were == 1 (only valid for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) - // for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 2 - // bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to - // Avg for each Active - // byte - - // add 3rd active group (Raw(x-bpp)/2) to average with _LBCarry - "psllq _ShiftBpp, %%mm6 \n\t" // shift mm6 mask to cover last - // two - // bytes - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "psllq _ShiftBpp, %%mm2 \n\t" // shift data to pos. correctly - // Data only needs to be shifted once here to - // get the correct x-bpp offset. - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting - // LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte - // where both - // lsb's were == 1 (only valid for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) - // for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 2 - // bytes to add to Avg - "addl $8, %%ecx \n\t" - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to - // Avg for each Active - // byte - // now ready to write back to memory - "movq %%mm0, -8(%%edi,%%ecx,) \n\t" - // move updated Raw(x) to use as Raw(x-bpp) for next loop - "cmpl _MMXLength, %%ecx \n\t" - "movq %%mm0, %%mm2 \n\t" // mov updated Raw(x) to mm2 - "jb avg_3lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; // end 3 bpp - - case 6: - case 4: - //case 7: // who wrote this? PNG doesn't support 5 or 7 bytes/pixel - //case 5: // GRR BOGUS - { - _ActiveMask.use = 0xffffffffffffffffLL; // use shift below to clear - // appropriate inactive bytes - _ShiftBpp.use = bpp << 3; - _ShiftRem.use = 64 - _ShiftBpp.use; - - __asm__ __volatile__ ( - "movq _HBClearMask, %%mm4 \n\t" - - // re-init address pointers and offset - "movl _dif, %%ecx \n\t" // ecx: x = offset to - // alignment boundary - - // load _ActiveMask and clear all bytes except for 1st active group - "movq _ActiveMask, %%mm7 \n\t" -// preload "movl row, %%edi \n\t" // edi: Avg(x) - "psrlq _ShiftRem, %%mm7 \n\t" -// preload "movl prev_row, %%esi \n\t" // esi: Prior(x) - "movq %%mm7, %%mm6 \n\t" - "movq _LBCarryMask, %%mm5 \n\t" - "psllq _ShiftBpp, %%mm6 \n\t" // create mask for 2nd active - // group - - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm2 \n\t" // load previous aligned 8 bytes - // (we correct pos. in loop below) - "avg_4lp: \n\t" - "movq (%%edi,%%ecx,), %%mm0 \n\t" - "psrlq _ShiftRem, %%mm2 \n\t" // shift data to pos. correctly - "movq (%%esi,%%ecx,), %%mm1 \n\t" - // add (Prev_row/2) to average - "movq %%mm5, %%mm3 \n\t" - "pand %%mm1, %%mm3 \n\t" // get lsb for each prev_row byte - "psrlq $1, %%mm1 \n\t" // divide prev_row bytes by 2 - "pand %%mm4, %%mm1 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm0 \n\t" // add (Prev_row/2) to Avg for - // each byte - // add 1st active group (Raw(x-bpp)/2) to average with _LBCarry - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting - // LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte - // where both - // lsb's were == 1 (only valid for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) - // for each byte - "pand %%mm7, %%mm2 \n\t" // leave only Active Group 1 - // bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to Avg - // for each Active - // byte - // add 2nd active group (Raw(x-bpp)/2) to average with _LBCarry - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "psllq _ShiftBpp, %%mm2 \n\t" // shift data to pos. correctly - "addl $8, %%ecx \n\t" - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting - // LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte - // where both - // lsb's were == 1 (only valid for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) - // for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 2 - // bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to - // Avg for each Active - // byte - "cmpl _MMXLength, %%ecx \n\t" - // now ready to write back to memory - "movq %%mm0, -8(%%edi,%%ecx,) \n\t" - // prep Raw(x-bpp) for next loop - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "jb avg_4lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; // end 4,6 bpp - - case 2: - { - _ActiveMask.use = 0x000000000000ffffLL; - _ShiftBpp.use = 16; // == 2 * 8 - _ShiftRem.use = 48; // == 64 - 16 - - __asm__ __volatile__ ( - // load _ActiveMask - "movq _ActiveMask, %%mm7 \n\t" - // re-init address pointers and offset - "movl _dif, %%ecx \n\t" // ecx: x = offset to alignment - // boundary - "movq _LBCarryMask, %%mm5 \n\t" -// preload "movl row, %%edi \n\t" // edi: Avg(x) - "movq _HBClearMask, %%mm4 \n\t" -// preload "movl prev_row, %%esi \n\t" // esi: Prior(x) - - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm2 \n\t" // load previous aligned 8 bytes - // (we correct pos. in loop below) - "avg_2lp: \n\t" - "movq (%%edi,%%ecx,), %%mm0 \n\t" - "psrlq _ShiftRem, %%mm2 \n\t" // shift data to pos. correctly - "movq (%%esi,%%ecx,), %%mm1 \n\t" // (GRR BUGFIX: was psllq) - // add (Prev_row/2) to average - "movq %%mm5, %%mm3 \n\t" - "pand %%mm1, %%mm3 \n\t" // get lsb for each prev_row byte - "psrlq $1, %%mm1 \n\t" // divide prev_row bytes by 2 - "pand %%mm4, %%mm1 \n\t" // clear invalid bit 7 of each - // byte - "movq %%mm7, %%mm6 \n\t" - "paddb %%mm1, %%mm0 \n\t" // add (Prev_row/2) to Avg for - // each byte - - // add 1st active group (Raw(x-bpp)/2) to average with _LBCarry - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting - // LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte - // where both - // lsb's were == 1 (only valid - // for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) - // for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 1 - // bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to Avg - // for each Active byte - - // add 2nd active group (Raw(x-bpp)/2) to average with _LBCarry - "psllq _ShiftBpp, %%mm6 \n\t" // shift the mm6 mask to cover - // bytes 2 & 3 - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "psllq _ShiftBpp, %%mm2 \n\t" // shift data to pos. correctly - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting - // LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte - // where both - // lsb's were == 1 (only valid - // for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) - // for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 2 - // bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to - // Avg for each Active byte - - // add 3rd active group (Raw(x-bpp)/2) to average with _LBCarry - "psllq _ShiftBpp, %%mm6 \n\t" // shift the mm6 mask to cover - // bytes 4 & 5 - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "psllq _ShiftBpp, %%mm2 \n\t" // shift data to pos. correctly - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting - // LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte - // where both lsb's were == 1 - // (only valid for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) - // for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 2 - // bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to - // Avg for each Active byte - - // add 4th active group (Raw(x-bpp)/2) to average with _LBCarry - "psllq _ShiftBpp, %%mm6 \n\t" // shift the mm6 mask to cover - // bytes 6 & 7 - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "psllq _ShiftBpp, %%mm2 \n\t" // shift data to pos. correctly - "addl $8, %%ecx \n\t" - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting - // LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte - // where both - // lsb's were == 1 (only valid - // for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) - // for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 2 - // bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to - // Avg for each Active byte - - "cmpl _MMXLength, %%ecx \n\t" - // now ready to write back to memory - "movq %%mm0, -8(%%edi,%%ecx,) \n\t" - // prep Raw(x-bpp) for next loop - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "jb avg_2lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; // end 2 bpp - - case 1: - { - __asm__ __volatile__ ( - // re-init address pointers and offset -#ifdef __PIC__ - "pushl %%ebx \n\t" // save Global Offset Table index -#endif - "movl _dif, %%ebx \n\t" // ebx: x = offset to alignment - // boundary -// preload "movl row, %%edi \n\t" // edi: Avg(x) - "cmpl _FullLength, %%ebx \n\t" // test if offset at end of array - "jnb avg_1end \n\t" - // do Paeth decode for remaining bytes -// preload "movl prev_row, %%esi \n\t" // esi: Prior(x) - "movl %%edi, %%edx \n\t" -// preload "subl bpp, %%edx \n\t" // (bpp is preloaded into ecx) - "subl %%ecx, %%edx \n\t" // edx: Raw(x-bpp) - "xorl %%ecx, %%ecx \n\t" // zero ecx before using cl & cx - // in loop below - "avg_1lp: \n\t" - // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) - "xorl %%eax, %%eax \n\t" - "movb (%%esi,%%ebx,), %%cl \n\t" // load cl with Prior(x) - "movb (%%edx,%%ebx,), %%al \n\t" // load al with Raw(x-bpp) - "addw %%cx, %%ax \n\t" - "incl %%ebx \n\t" - "shrw %%ax \n\t" // divide by 2 - "addb -1(%%edi,%%ebx,), %%al \n\t" // add Avg(x); -1 to offset - // inc ebx - "cmpl _FullLength, %%ebx \n\t" // check if at end of array - "movb %%al, -1(%%edi,%%ebx,) \n\t" // write back Raw(x); - // mov does not affect flags; -1 to offset inc ebx - "jb avg_1lp \n\t" - - "avg_1end: \n\t" -#ifdef __PIC__ - "popl %%ebx \n\t" // Global Offset Table index -#endif - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "0" (bpp), // ecx // input regs - "1" (prev_row), // esi - "2" (row) // edi - - : "%eax", "%edx" // clobber list -#ifndef __PIC__ - , "%ebx" -#endif - ); - } - return; // end 1 bpp - - case 8: - { - __asm__ __volatile__ ( - // re-init address pointers and offset - "movl _dif, %%ecx \n\t" // ecx: x == offset to alignment - "movq _LBCarryMask, %%mm5 \n\t" // boundary -// preload "movl row, %%edi \n\t" // edi: Avg(x) - "movq _HBClearMask, %%mm4 \n\t" -// preload "movl prev_row, %%esi \n\t" // esi: Prior(x) - - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm2 \n\t" // load previous aligned 8 bytes - // (NO NEED to correct pos. in loop below) - - "avg_8lp: \n\t" - "movq (%%edi,%%ecx,), %%mm0 \n\t" - "movq %%mm5, %%mm3 \n\t" - "movq (%%esi,%%ecx,), %%mm1 \n\t" - "addl $8, %%ecx \n\t" - "pand %%mm1, %%mm3 \n\t" // get lsb for each prev_row byte - "psrlq $1, %%mm1 \n\t" // divide prev_row bytes by 2 - "pand %%mm2, %%mm3 \n\t" // get LBCarrys for each byte - // where both lsb's were == 1 - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm1 \n\t" // clear invalid bit 7, each byte - "paddb %%mm3, %%mm0 \n\t" // add LBCarrys to Avg, each byte - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7, each byte - "paddb %%mm1, %%mm0 \n\t" // add (Prev_row/2) to Avg, each - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) to Avg for each - "cmpl _MMXLength, %%ecx \n\t" - "movq %%mm0, -8(%%edi,%%ecx,) \n\t" - "movq %%mm0, %%mm2 \n\t" // reuse as Raw(x-bpp) - "jb avg_8lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm5 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2" - , "%mm3", "%mm4", "%mm5" -#endif - ); - } - break; // end 8 bpp - - default: // bpp greater than 8 (!= 1,2,3,4,[5],6,[7],8) - { - -#ifdef PNG_DEBUG - // GRR: PRINT ERROR HERE: SHOULD NEVER BE REACHED - png_debug(1, - "Internal logic error in pnggccrd (png_read_filter_row_mmx_avg())\n"); -#endif - -#if 0 - __asm__ __volatile__ ( - "movq _LBCarryMask, %%mm5 \n\t" - // re-init address pointers and offset - "movl _dif, %%ebx \n\t" // ebx: x = offset to - // alignment boundary - "movl row, %%edi \n\t" // edi: Avg(x) - "movq _HBClearMask, %%mm4 \n\t" - "movl %%edi, %%edx \n\t" - "movl prev_row, %%esi \n\t" // esi: Prior(x) - "subl bpp, %%edx \n\t" // edx: Raw(x-bpp) - "avg_Alp: \n\t" - "movq (%%edi,%%ebx,), %%mm0 \n\t" - "movq %%mm5, %%mm3 \n\t" - "movq (%%esi,%%ebx,), %%mm1 \n\t" - "pand %%mm1, %%mm3 \n\t" // get lsb for each prev_row byte - "movq (%%edx,%%ebx,), %%mm2 \n\t" - "psrlq $1, %%mm1 \n\t" // divide prev_row bytes by 2 - "pand %%mm2, %%mm3 \n\t" // get LBCarrys for each byte - // where both lsb's were == 1 - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm1 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm3, %%mm0 \n\t" // add LBCarrys to Avg for each - // byte - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each - // byte - "paddb %%mm1, %%mm0 \n\t" // add (Prev_row/2) to Avg for - // each byte - "addl $8, %%ebx \n\t" - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) to Avg for each - // byte - "cmpl _MMXLength, %%ebx \n\t" - "movq %%mm0, -8(%%edi,%%ebx,) \n\t" - "jb avg_Alp \n\t" - - : // FIXASM: output regs/vars go here, e.g.: "=m" (memory_var) - - : // FIXASM: input regs, e.g.: "c" (count), "S" (src), "D" (dest) - - : "%ebx", "%edx", "%edi", "%esi" // CHECKASM: clobber list - ); -#endif /* 0 - NEVER REACHED */ - } - break; - - } // end switch (bpp) - - __asm__ __volatile__ ( - // MMX acceleration complete; now do clean-up - // check if any remaining bytes left to decode -#ifdef __PIC__ - "pushl %%ebx \n\t" // save index to Global Offset Table -#endif - "movl _MMXLength, %%ebx \n\t" // ebx: x == offset bytes after MMX -//pre "movl row, %%edi \n\t" // edi: Avg(x) - "cmpl _FullLength, %%ebx \n\t" // test if offset at end of array - "jnb avg_end \n\t" - - // do Avg decode for remaining bytes -//pre "movl prev_row, %%esi \n\t" // esi: Prior(x) - "movl %%edi, %%edx \n\t" -//pre "subl bpp, %%edx \n\t" // (bpp is preloaded into ecx) - "subl %%ecx, %%edx \n\t" // edx: Raw(x-bpp) - "xorl %%ecx, %%ecx \n\t" // zero ecx before using cl & cx below - - "avg_lp2: \n\t" - // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) - "xorl %%eax, %%eax \n\t" - "movb (%%esi,%%ebx,), %%cl \n\t" // load cl with Prior(x) - "movb (%%edx,%%ebx,), %%al \n\t" // load al with Raw(x-bpp) - "addw %%cx, %%ax \n\t" - "incl %%ebx \n\t" - "shrw %%ax \n\t" // divide by 2 - "addb -1(%%edi,%%ebx,), %%al \n\t" // add Avg(x); -1 to offset inc ebx - "cmpl _FullLength, %%ebx \n\t" // check if at end of array - "movb %%al, -1(%%edi,%%ebx,) \n\t" // write back Raw(x) [mov does not - "jb avg_lp2 \n\t" // affect flags; -1 to offset inc ebx] - - "avg_end: \n\t" - "EMMS \n\t" // end MMX; prep for poss. FP instrs. -#ifdef __PIC__ - "popl %%ebx \n\t" // restore index to Global Offset Table -#endif - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "0" (bpp), // ecx // input regs - "1" (prev_row), // esi - "2" (row) // edi - - : "%eax", "%edx" // clobber list -#ifndef __PIC__ - , "%ebx" -#endif - ); - -} /* end png_read_filter_row_mmx_avg() */ -#endif - - - -#ifdef PNG_THREAD_UNSAFE_OK -//===========================================================================// -// // -// P N G _ R E A D _ F I L T E R _ R O W _ M M X _ P A E T H // -// // -//===========================================================================// - -// Optimized code for PNG Paeth filter decoder - -static void /* PRIVATE */ -png_read_filter_row_mmx_paeth(png_row_infop row_info, png_bytep row, - png_bytep prev_row) -{ - int bpp; - int dummy_value_c; // fix 'forbidden register 2 (cx) was spilled' error - int dummy_value_S; - int dummy_value_D; - - bpp = (row_info->pixel_depth + 7) >> 3; // Get # bytes per pixel - _FullLength = row_info->rowbytes; // # of bytes to filter - - __asm__ __volatile__ ( -#ifdef __PIC__ - "pushl %%ebx \n\t" // save index to Global Offset Table -#endif - "xorl %%ebx, %%ebx \n\t" // ebx: x offset -//pre "movl row, %%edi \n\t" - "xorl %%edx, %%edx \n\t" // edx: x-bpp offset -//pre "movl prev_row, %%esi \n\t" - "xorl %%eax, %%eax \n\t" - - // Compute the Raw value for the first bpp bytes - // Note: the formula works out to be always - // Paeth(x) = Raw(x) + Prior(x) where x < bpp - "paeth_rlp: \n\t" - "movb (%%edi,%%ebx,), %%al \n\t" - "addb (%%esi,%%ebx,), %%al \n\t" - "incl %%ebx \n\t" -//pre "cmpl bpp, %%ebx \n\t" (bpp is preloaded into ecx) - "cmpl %%ecx, %%ebx \n\t" - "movb %%al, -1(%%edi,%%ebx,) \n\t" - "jb paeth_rlp \n\t" - // get # of bytes to alignment - "movl %%edi, _dif \n\t" // take start of row - "addl %%ebx, _dif \n\t" // add bpp - "xorl %%ecx, %%ecx \n\t" - "addl $0xf, _dif \n\t" // add 7 + 8 to incr past alignment - // boundary - "andl $0xfffffff8, _dif \n\t" // mask to alignment boundary - "subl %%edi, _dif \n\t" // subtract from start ==> value ebx - // at alignment - "jz paeth_go \n\t" - // fix alignment - - "paeth_lp1: \n\t" - "xorl %%eax, %%eax \n\t" - // pav = p - a = (a + b - c) - a = b - c - "movb (%%esi,%%ebx,), %%al \n\t" // load Prior(x) into al - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "subl %%ecx, %%eax \n\t" // subtract Prior(x-bpp) - "movl %%eax, _patemp \n\t" // Save pav for later use - "xorl %%eax, %%eax \n\t" - // pbv = p - b = (a + b - c) - b = a - c - "movb (%%edi,%%edx,), %%al \n\t" // load Raw(x-bpp) into al - "subl %%ecx, %%eax \n\t" // subtract Prior(x-bpp) - "movl %%eax, %%ecx \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "addl _patemp, %%eax \n\t" // pcv = pav + pbv - // pc = abs(pcv) - "testl $0x80000000, %%eax \n\t" - "jz paeth_pca \n\t" - "negl %%eax \n\t" // reverse sign of neg values - - "paeth_pca: \n\t" - "movl %%eax, _pctemp \n\t" // save pc for later use - // pb = abs(pbv) - "testl $0x80000000, %%ecx \n\t" - "jz paeth_pba \n\t" - "negl %%ecx \n\t" // reverse sign of neg values - - "paeth_pba: \n\t" - "movl %%ecx, _pbtemp \n\t" // save pb for later use - // pa = abs(pav) - "movl _patemp, %%eax \n\t" - "testl $0x80000000, %%eax \n\t" - "jz paeth_paa \n\t" - "negl %%eax \n\t" // reverse sign of neg values - - "paeth_paa: \n\t" - "movl %%eax, _patemp \n\t" // save pa for later use - // test if pa <= pb - "cmpl %%ecx, %%eax \n\t" - "jna paeth_abb \n\t" - // pa > pb; now test if pb <= pc - "cmpl _pctemp, %%ecx \n\t" - "jna paeth_bbc \n\t" - // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "jmp paeth_paeth \n\t" - - "paeth_bbc: \n\t" - // pb <= pc; Raw(x) = Paeth(x) + Prior(x) - "movb (%%esi,%%ebx,), %%cl \n\t" // load Prior(x) into cl - "jmp paeth_paeth \n\t" - - "paeth_abb: \n\t" - // pa <= pb; now test if pa <= pc - "cmpl _pctemp, %%eax \n\t" - "jna paeth_abc \n\t" - // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "jmp paeth_paeth \n\t" - - "paeth_abc: \n\t" - // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) - "movb (%%edi,%%edx,), %%cl \n\t" // load Raw(x-bpp) into cl - - "paeth_paeth: \n\t" - "incl %%ebx \n\t" - "incl %%edx \n\t" - // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 - "addb %%cl, -1(%%edi,%%ebx,) \n\t" - "cmpl _dif, %%ebx \n\t" - "jb paeth_lp1 \n\t" - - "paeth_go: \n\t" - "movl _FullLength, %%ecx \n\t" - "movl %%ecx, %%eax \n\t" - "subl %%ebx, %%eax \n\t" // subtract alignment fix - "andl $0x00000007, %%eax \n\t" // calc bytes over mult of 8 - "subl %%eax, %%ecx \n\t" // drop over bytes from original length - "movl %%ecx, _MMXLength \n\t" -#ifdef __PIC__ - "popl %%ebx \n\t" // restore index to Global Offset Table -#endif - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "0" (bpp), // ecx // input regs - "1" (prev_row), // esi - "2" (row) // edi - - : "%eax", "%edx" // clobber list -#ifndef __PIC__ - , "%ebx" -#endif - ); - - // now do the math for the rest of the row - switch (bpp) - { - case 3: - { - _ActiveMask.use = 0x0000000000ffffffLL; - _ActiveMaskEnd.use = 0xffff000000000000LL; - _ShiftBpp.use = 24; // == bpp(3) * 8 - _ShiftRem.use = 40; // == 64 - 24 - - __asm__ __volatile__ ( - "movl _dif, %%ecx \n\t" -// preload "movl row, %%edi \n\t" -// preload "movl prev_row, %%esi \n\t" - "pxor %%mm0, %%mm0 \n\t" - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm1 \n\t" - "paeth_3lp: \n\t" - "psrlq _ShiftRem, %%mm1 \n\t" // shift last 3 bytes to 1st - // 3 bytes - "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) - "punpcklbw %%mm0, %%mm1 \n\t" // unpack High bytes of a - "movq -8(%%esi,%%ecx,), %%mm3 \n\t" // prep c=Prior(x-bpp) bytes - "punpcklbw %%mm0, %%mm2 \n\t" // unpack High bytes of b - "psrlq _ShiftRem, %%mm3 \n\t" // shift last 3 bytes to 1st - // 3 bytes - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - "punpcklbw %%mm0, %%mm3 \n\t" // unpack High bytes of c - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - "pxor %%mm7, %%mm7 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "paddw %%mm5, %%mm6 \n\t" - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "psubw %%mm0, %%mm4 \n\t" - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pxor %%mm1, %%mm1 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "packuswb %%mm1, %%mm7 \n\t" - "movq (%%esi,%%ecx,), %%mm3 \n\t" // load c=Prior(x-bpp) - "pand _ActiveMask, %%mm7 \n\t" - "movq %%mm3, %%mm2 \n\t" // load b=Prior(x) step 1 - "paddb (%%edi,%%ecx,), %%mm7 \n\t" // add Paeth predictor with Raw(x) - "punpcklbw %%mm0, %%mm3 \n\t" // unpack High bytes of c - "movq %%mm7, (%%edi,%%ecx,) \n\t" // write back updated value - "movq %%mm7, %%mm1 \n\t" // now mm1 will be used as - // Raw(x-bpp) - // now do Paeth for 2nd set of bytes (3-5) - "psrlq _ShiftBpp, %%mm2 \n\t" // load b=Prior(x) step 2 - "punpcklbw %%mm0, %%mm1 \n\t" // unpack High bytes of a - "pxor %%mm7, %%mm7 \n\t" - "punpcklbw %%mm0, %%mm2 \n\t" // unpack High bytes of b - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - "psubw %%mm3, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = - // pav + pbv = pbv + pav - "movq %%mm5, %%mm6 \n\t" - "paddw %%mm4, %%mm6 \n\t" - - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm5, %%mm0 \n\t" // create mask pbv bytes < 0 - "pcmpgtw %%mm4, %%mm7 \n\t" // create mask pav bytes < 0 - "pand %%mm5, %%mm0 \n\t" // only pbv bytes < 0 in mm0 - "pand %%mm4, %%mm7 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm0, %%mm5 \n\t" - "psubw %%mm7, %%mm4 \n\t" - "psubw %%mm0, %%mm5 \n\t" - "psubw %%mm7, %%mm4 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "pxor %%mm1, %%mm1 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "packuswb %%mm1, %%mm7 \n\t" - "movq %%mm2, %%mm3 \n\t" // load c=Prior(x-bpp) step 1 - "pand _ActiveMask, %%mm7 \n\t" - "punpckhbw %%mm0, %%mm2 \n\t" // unpack High bytes of b - "psllq _ShiftBpp, %%mm7 \n\t" // shift bytes to 2nd group of - // 3 bytes - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - "paddb (%%edi,%%ecx,), %%mm7 \n\t" // add Paeth predictor with Raw(x) - "psllq _ShiftBpp, %%mm3 \n\t" // load c=Prior(x-bpp) step 2 - "movq %%mm7, (%%edi,%%ecx,) \n\t" // write back updated value - "movq %%mm7, %%mm1 \n\t" - "punpckhbw %%mm0, %%mm3 \n\t" // unpack High bytes of c - "psllq _ShiftBpp, %%mm1 \n\t" // shift bytes - // now mm1 will be used as Raw(x-bpp) - // now do Paeth for 3rd, and final, set of bytes (6-7) - "pxor %%mm7, %%mm7 \n\t" - "punpckhbw %%mm0, %%mm1 \n\t" // unpack High bytes of a - "psubw %%mm3, %%mm4 \n\t" - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "paddw %%mm5, %%mm6 \n\t" - - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm1, %%mm1 \n\t" - "packuswb %%mm7, %%mm1 \n\t" - // step ecx to next set of 8 bytes and repeat loop til done - "addl $8, %%ecx \n\t" - "pand _ActiveMaskEnd, %%mm1 \n\t" - "paddb -8(%%edi,%%ecx,), %%mm1 \n\t" // add Paeth predictor with - // Raw(x) - - "cmpl _MMXLength, %%ecx \n\t" - "pxor %%mm0, %%mm0 \n\t" // pxor does not affect flags - "movq %%mm1, -8(%%edi,%%ecx,) \n\t" // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - // mm3 ready to be used as Prior(x-bpp) next loop - "jb paeth_3lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; // end 3 bpp - - case 6: - //case 7: // GRR BOGUS - //case 5: // GRR BOGUS - { - _ActiveMask.use = 0x00000000ffffffffLL; - _ActiveMask2.use = 0xffffffff00000000LL; - _ShiftBpp.use = bpp << 3; // == bpp * 8 - _ShiftRem.use = 64 - _ShiftBpp.use; - - __asm__ __volatile__ ( - "movl _dif, %%ecx \n\t" -// preload "movl row, %%edi \n\t" -// preload "movl prev_row, %%esi \n\t" - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm1 \n\t" - "pxor %%mm0, %%mm0 \n\t" - - "paeth_6lp: \n\t" - // must shift to position Raw(x-bpp) data - "psrlq _ShiftRem, %%mm1 \n\t" - // do first set of 4 bytes - "movq -8(%%esi,%%ecx,), %%mm3 \n\t" // read c=Prior(x-bpp) bytes - "punpcklbw %%mm0, %%mm1 \n\t" // unpack Low bytes of a - "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) - "punpcklbw %%mm0, %%mm2 \n\t" // unpack Low bytes of b - // must shift to position Prior(x-bpp) data - "psrlq _ShiftRem, %%mm3 \n\t" - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - "punpcklbw %%mm0, %%mm3 \n\t" // unpack Low bytes of c - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - "pxor %%mm7, %%mm7 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "paddw %%mm5, %%mm6 \n\t" - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "psubw %%mm0, %%mm4 \n\t" - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pxor %%mm1, %%mm1 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "packuswb %%mm1, %%mm7 \n\t" - "movq -8(%%esi,%%ecx,), %%mm3 \n\t" // load c=Prior(x-bpp) - "pand _ActiveMask, %%mm7 \n\t" - "psrlq _ShiftRem, %%mm3 \n\t" - "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) step 1 - "paddb (%%edi,%%ecx,), %%mm7 \n\t" // add Paeth predictor and Raw(x) - "movq %%mm2, %%mm6 \n\t" - "movq %%mm7, (%%edi,%%ecx,) \n\t" // write back updated value - "movq -8(%%edi,%%ecx,), %%mm1 \n\t" - "psllq _ShiftBpp, %%mm6 \n\t" - "movq %%mm7, %%mm5 \n\t" - "psrlq _ShiftRem, %%mm1 \n\t" - "por %%mm6, %%mm3 \n\t" - "psllq _ShiftBpp, %%mm5 \n\t" - "punpckhbw %%mm0, %%mm3 \n\t" // unpack High bytes of c - "por %%mm5, %%mm1 \n\t" - // do second set of 4 bytes - "punpckhbw %%mm0, %%mm2 \n\t" // unpack High bytes of b - "punpckhbw %%mm0, %%mm1 \n\t" // unpack High bytes of a - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - "pxor %%mm7, %%mm7 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "paddw %%mm5, %%mm6 \n\t" - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "psubw %%mm0, %%mm4 \n\t" - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pxor %%mm1, %%mm1 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "pxor %%mm1, %%mm1 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - // step ecx to next set of 8 bytes and repeat loop til done - "addl $8, %%ecx \n\t" - "packuswb %%mm7, %%mm1 \n\t" - "paddb -8(%%edi,%%ecx,), %%mm1 \n\t" // add Paeth predictor with Raw(x) - "cmpl _MMXLength, %%ecx \n\t" - "movq %%mm1, -8(%%edi,%%ecx,) \n\t" // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - "jb paeth_6lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; // end 6 bpp - - case 4: - { - _ActiveMask.use = 0x00000000ffffffffLL; - - __asm__ __volatile__ ( - "movl _dif, %%ecx \n\t" -// preload "movl row, %%edi \n\t" -// preload "movl prev_row, %%esi \n\t" - "pxor %%mm0, %%mm0 \n\t" - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm1 \n\t" // only time should need to read - // a=Raw(x-bpp) bytes - "paeth_4lp: \n\t" - // do first set of 4 bytes - "movq -8(%%esi,%%ecx,), %%mm3 \n\t" // read c=Prior(x-bpp) bytes - "punpckhbw %%mm0, %%mm1 \n\t" // unpack Low bytes of a - "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) - "punpcklbw %%mm0, %%mm2 \n\t" // unpack High bytes of b - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - "punpckhbw %%mm0, %%mm3 \n\t" // unpack High bytes of c - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - "pxor %%mm7, %%mm7 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "paddw %%mm5, %%mm6 \n\t" - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "psubw %%mm0, %%mm4 \n\t" - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pxor %%mm1, %%mm1 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "packuswb %%mm1, %%mm7 \n\t" - "movq (%%esi,%%ecx,), %%mm3 \n\t" // load c=Prior(x-bpp) - "pand _ActiveMask, %%mm7 \n\t" - "movq %%mm3, %%mm2 \n\t" // load b=Prior(x) step 1 - "paddb (%%edi,%%ecx,), %%mm7 \n\t" // add Paeth predictor with Raw(x) - "punpcklbw %%mm0, %%mm3 \n\t" // unpack High bytes of c - "movq %%mm7, (%%edi,%%ecx,) \n\t" // write back updated value - "movq %%mm7, %%mm1 \n\t" // now mm1 will be used as Raw(x-bpp) - // do second set of 4 bytes - "punpckhbw %%mm0, %%mm2 \n\t" // unpack Low bytes of b - "punpcklbw %%mm0, %%mm1 \n\t" // unpack Low bytes of a - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - "pxor %%mm7, %%mm7 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "paddw %%mm5, %%mm6 \n\t" - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "psubw %%mm0, %%mm4 \n\t" - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pxor %%mm1, %%mm1 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "pxor %%mm1, %%mm1 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - // step ecx to next set of 8 bytes and repeat loop til done - "addl $8, %%ecx \n\t" - "packuswb %%mm7, %%mm1 \n\t" - "paddb -8(%%edi,%%ecx,), %%mm1 \n\t" // add predictor with Raw(x) - "cmpl _MMXLength, %%ecx \n\t" - "movq %%mm1, -8(%%edi,%%ecx,) \n\t" // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - "jb paeth_4lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; // end 4 bpp - - case 8: // bpp == 8 - { - _ActiveMask.use = 0x00000000ffffffffLL; - - __asm__ __volatile__ ( - "movl _dif, %%ecx \n\t" -// preload "movl row, %%edi \n\t" -// preload "movl prev_row, %%esi \n\t" - "pxor %%mm0, %%mm0 \n\t" - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm1 \n\t" // only time should need to read - // a=Raw(x-bpp) bytes - "paeth_8lp: \n\t" - // do first set of 4 bytes - "movq -8(%%esi,%%ecx,), %%mm3 \n\t" // read c=Prior(x-bpp) bytes - "punpcklbw %%mm0, %%mm1 \n\t" // unpack Low bytes of a - "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) - "punpcklbw %%mm0, %%mm2 \n\t" // unpack Low bytes of b - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - "punpcklbw %%mm0, %%mm3 \n\t" // unpack Low bytes of c - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - "pxor %%mm7, %%mm7 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "paddw %%mm5, %%mm6 \n\t" - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "psubw %%mm0, %%mm4 \n\t" - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pxor %%mm1, %%mm1 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "packuswb %%mm1, %%mm7 \n\t" - "movq -8(%%esi,%%ecx,), %%mm3 \n\t" // read c=Prior(x-bpp) bytes - "pand _ActiveMask, %%mm7 \n\t" - "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) - "paddb (%%edi,%%ecx,), %%mm7 \n\t" // add Paeth predictor with Raw(x) - "punpckhbw %%mm0, %%mm3 \n\t" // unpack High bytes of c - "movq %%mm7, (%%edi,%%ecx,) \n\t" // write back updated value - "movq -8(%%edi,%%ecx,), %%mm1 \n\t" // read a=Raw(x-bpp) bytes - - // do second set of 4 bytes - "punpckhbw %%mm0, %%mm2 \n\t" // unpack High bytes of b - "punpckhbw %%mm0, %%mm1 \n\t" // unpack High bytes of a - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - "pxor %%mm7, %%mm7 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "paddw %%mm5, %%mm6 \n\t" - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "psubw %%mm0, %%mm4 \n\t" - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pxor %%mm1, %%mm1 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "pxor %%mm1, %%mm1 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - // step ecx to next set of 8 bytes and repeat loop til done - "addl $8, %%ecx \n\t" - "packuswb %%mm7, %%mm1 \n\t" - "paddb -8(%%edi,%%ecx,), %%mm1 \n\t" // add Paeth predictor with Raw(x) - "cmpl _MMXLength, %%ecx \n\t" - "movq %%mm1, -8(%%edi,%%ecx,) \n\t" // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - "jb paeth_8lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; // end 8 bpp - - case 1: // bpp = 1 - case 2: // bpp = 2 - default: // bpp > 8 - { - __asm__ __volatile__ ( -#ifdef __PIC__ - "pushl %%ebx \n\t" // save Global Offset Table index -#endif - "movl _dif, %%ebx \n\t" - "cmpl _FullLength, %%ebx \n\t" - "jnb paeth_dend \n\t" - -// preload "movl row, %%edi \n\t" -// preload "movl prev_row, %%esi \n\t" - // do Paeth decode for remaining bytes - "movl %%ebx, %%edx \n\t" -// preload "subl bpp, %%edx \n\t" // (bpp is preloaded into ecx) - "subl %%ecx, %%edx \n\t" // edx = ebx - bpp - "xorl %%ecx, %%ecx \n\t" // zero ecx before using cl & cx - - "paeth_dlp: \n\t" - "xorl %%eax, %%eax \n\t" - // pav = p - a = (a + b - c) - a = b - c - "movb (%%esi,%%ebx,), %%al \n\t" // load Prior(x) into al - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "subl %%ecx, %%eax \n\t" // subtract Prior(x-bpp) - "movl %%eax, _patemp \n\t" // Save pav for later use - "xorl %%eax, %%eax \n\t" - // pbv = p - b = (a + b - c) - b = a - c - "movb (%%edi,%%edx,), %%al \n\t" // load Raw(x-bpp) into al - "subl %%ecx, %%eax \n\t" // subtract Prior(x-bpp) - "movl %%eax, %%ecx \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "addl _patemp, %%eax \n\t" // pcv = pav + pbv - // pc = abs(pcv) - "testl $0x80000000, %%eax \n\t" - "jz paeth_dpca \n\t" - "negl %%eax \n\t" // reverse sign of neg values - - "paeth_dpca: \n\t" - "movl %%eax, _pctemp \n\t" // save pc for later use - // pb = abs(pbv) - "testl $0x80000000, %%ecx \n\t" - "jz paeth_dpba \n\t" - "negl %%ecx \n\t" // reverse sign of neg values - - "paeth_dpba: \n\t" - "movl %%ecx, _pbtemp \n\t" // save pb for later use - // pa = abs(pav) - "movl _patemp, %%eax \n\t" - "testl $0x80000000, %%eax \n\t" - "jz paeth_dpaa \n\t" - "negl %%eax \n\t" // reverse sign of neg values - - "paeth_dpaa: \n\t" - "movl %%eax, _patemp \n\t" // save pa for later use - // test if pa <= pb - "cmpl %%ecx, %%eax \n\t" - "jna paeth_dabb \n\t" - // pa > pb; now test if pb <= pc - "cmpl _pctemp, %%ecx \n\t" - "jna paeth_dbbc \n\t" - // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "jmp paeth_dpaeth \n\t" - - "paeth_dbbc: \n\t" - // pb <= pc; Raw(x) = Paeth(x) + Prior(x) - "movb (%%esi,%%ebx,), %%cl \n\t" // load Prior(x) into cl - "jmp paeth_dpaeth \n\t" - - "paeth_dabb: \n\t" - // pa <= pb; now test if pa <= pc - "cmpl _pctemp, %%eax \n\t" - "jna paeth_dabc \n\t" - // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "jmp paeth_dpaeth \n\t" - - "paeth_dabc: \n\t" - // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) - "movb (%%edi,%%edx,), %%cl \n\t" // load Raw(x-bpp) into cl - - "paeth_dpaeth: \n\t" - "incl %%ebx \n\t" - "incl %%edx \n\t" - // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 - "addb %%cl, -1(%%edi,%%ebx,) \n\t" - "cmpl _FullLength, %%ebx \n\t" - "jb paeth_dlp \n\t" - - "paeth_dend: \n\t" -#ifdef __PIC__ - "popl %%ebx \n\t" // index to Global Offset Table -#endif - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "0" (bpp), // ecx // input regs - "1" (prev_row), // esi - "2" (row) // edi - - : "%eax", "%edx" // clobber list -#ifndef __PIC__ - , "%ebx" -#endif - ); - } - return; // No need to go further with this one - - } // end switch (bpp) - - __asm__ __volatile__ ( - // MMX acceleration complete; now do clean-up - // check if any remaining bytes left to decode -#ifdef __PIC__ - "pushl %%ebx \n\t" // save index to Global Offset Table -#endif - "movl _MMXLength, %%ebx \n\t" - "cmpl _FullLength, %%ebx \n\t" - "jnb paeth_end \n\t" -//pre "movl row, %%edi \n\t" -//pre "movl prev_row, %%esi \n\t" - // do Paeth decode for remaining bytes - "movl %%ebx, %%edx \n\t" -//pre "subl bpp, %%edx \n\t" // (bpp is preloaded into ecx) - "subl %%ecx, %%edx \n\t" // edx = ebx - bpp - "xorl %%ecx, %%ecx \n\t" // zero ecx before using cl & cx below - - "paeth_lp2: \n\t" - "xorl %%eax, %%eax \n\t" - // pav = p - a = (a + b - c) - a = b - c - "movb (%%esi,%%ebx,), %%al \n\t" // load Prior(x) into al - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "subl %%ecx, %%eax \n\t" // subtract Prior(x-bpp) - "movl %%eax, _patemp \n\t" // Save pav for later use - "xorl %%eax, %%eax \n\t" - // pbv = p - b = (a + b - c) - b = a - c - "movb (%%edi,%%edx,), %%al \n\t" // load Raw(x-bpp) into al - "subl %%ecx, %%eax \n\t" // subtract Prior(x-bpp) - "movl %%eax, %%ecx \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "addl _patemp, %%eax \n\t" // pcv = pav + pbv - // pc = abs(pcv) - "testl $0x80000000, %%eax \n\t" - "jz paeth_pca2 \n\t" - "negl %%eax \n\t" // reverse sign of neg values - - "paeth_pca2: \n\t" - "movl %%eax, _pctemp \n\t" // save pc for later use - // pb = abs(pbv) - "testl $0x80000000, %%ecx \n\t" - "jz paeth_pba2 \n\t" - "negl %%ecx \n\t" // reverse sign of neg values - - "paeth_pba2: \n\t" - "movl %%ecx, _pbtemp \n\t" // save pb for later use - // pa = abs(pav) - "movl _patemp, %%eax \n\t" - "testl $0x80000000, %%eax \n\t" - "jz paeth_paa2 \n\t" - "negl %%eax \n\t" // reverse sign of neg values - - "paeth_paa2: \n\t" - "movl %%eax, _patemp \n\t" // save pa for later use - // test if pa <= pb - "cmpl %%ecx, %%eax \n\t" - "jna paeth_abb2 \n\t" - // pa > pb; now test if pb <= pc - "cmpl _pctemp, %%ecx \n\t" - "jna paeth_bbc2 \n\t" - // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "jmp paeth_paeth2 \n\t" - - "paeth_bbc2: \n\t" - // pb <= pc; Raw(x) = Paeth(x) + Prior(x) - "movb (%%esi,%%ebx,), %%cl \n\t" // load Prior(x) into cl - "jmp paeth_paeth2 \n\t" - - "paeth_abb2: \n\t" - // pa <= pb; now test if pa <= pc - "cmpl _pctemp, %%eax \n\t" - "jna paeth_abc2 \n\t" - // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "jmp paeth_paeth2 \n\t" - - "paeth_abc2: \n\t" - // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) - "movb (%%edi,%%edx,), %%cl \n\t" // load Raw(x-bpp) into cl - - "paeth_paeth2: \n\t" - "incl %%ebx \n\t" - "incl %%edx \n\t" - // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 - "addb %%cl, -1(%%edi,%%ebx,) \n\t" - "cmpl _FullLength, %%ebx \n\t" - "jb paeth_lp2 \n\t" - - "paeth_end: \n\t" - "EMMS \n\t" // end MMX; prep for poss. FP instrs. -#ifdef __PIC__ - "popl %%ebx \n\t" // restore index to Global Offset Table -#endif - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "0" (bpp), // ecx // input regs - "1" (prev_row), // esi - "2" (row) // edi - - : "%eax", "%edx" // clobber list (no input regs!) -#ifndef __PIC__ - , "%ebx" -#endif - ); - -} /* end png_read_filter_row_mmx_paeth() */ -#endif - - - - -#ifdef PNG_THREAD_UNSAFE_OK -//===========================================================================// -// // -// P N G _ R E A D _ F I L T E R _ R O W _ M M X _ S U B // -// // -//===========================================================================// - -// Optimized code for PNG Sub filter decoder - -static void /* PRIVATE */ -png_read_filter_row_mmx_sub(png_row_infop row_info, png_bytep row) -{ - int bpp; - int dummy_value_a; - int dummy_value_D; - - bpp = (row_info->pixel_depth + 7) >> 3; // calc number of bytes per pixel - _FullLength = row_info->rowbytes - bpp; // number of bytes to filter - - __asm__ __volatile__ ( -//pre "movl row, %%edi \n\t" - "movl %%edi, %%esi \n\t" // lp = row -//pre "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp -//irr "xorl %%eax, %%eax \n\t" - // get # of bytes to alignment - "movl %%edi, _dif \n\t" // take start of row - "addl $0xf, _dif \n\t" // add 7 + 8 to incr past - // alignment boundary - "xorl %%ecx, %%ecx \n\t" - "andl $0xfffffff8, _dif \n\t" // mask to alignment boundary - "subl %%edi, _dif \n\t" // subtract from start ==> value - "jz sub_go \n\t" // ecx at alignment - - "sub_lp1: \n\t" // fix alignment - "movb (%%esi,%%ecx,), %%al \n\t" - "addb %%al, (%%edi,%%ecx,) \n\t" - "incl %%ecx \n\t" - "cmpl _dif, %%ecx \n\t" - "jb sub_lp1 \n\t" - - "sub_go: \n\t" - "movl _FullLength, %%eax \n\t" - "movl %%eax, %%edx \n\t" - "subl %%ecx, %%edx \n\t" // subtract alignment fix - "andl $0x00000007, %%edx \n\t" // calc bytes over mult of 8 - "subl %%edx, %%eax \n\t" // drop over bytes from length - "movl %%eax, _MMXLength \n\t" - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%esi", "%ecx", "%edx" // clobber list - -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - - // now do the math for the rest of the row - switch (bpp) - { - case 3: - { - _ActiveMask.use = 0x0000ffffff000000LL; - _ShiftBpp.use = 24; // == 3 * 8 - _ShiftRem.use = 40; // == 64 - 24 - - __asm__ __volatile__ ( -// preload "movl row, %%edi \n\t" - "movq _ActiveMask, %%mm7 \n\t" // load _ActiveMask for 2nd - // active byte group - "movl %%edi, %%esi \n\t" // lp = row -// preload "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp - "movq %%mm7, %%mm6 \n\t" - "movl _dif, %%edx \n\t" - "psllq _ShiftBpp, %%mm6 \n\t" // move mask in mm6 to cover - // 3rd active byte group - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%edx,), %%mm1 \n\t" - - "sub_3lp: \n\t" // shift data for adding first - "psrlq _ShiftRem, %%mm1 \n\t" // bpp bytes (no need for mask; - // shift clears inactive bytes) - // add 1st active group - "movq (%%edi,%%edx,), %%mm0 \n\t" - "paddb %%mm1, %%mm0 \n\t" - - // add 2nd active group - "movq %%mm0, %%mm1 \n\t" // mov updated Raws to mm1 - "psllq _ShiftBpp, %%mm1 \n\t" // shift data to pos. correctly - "pand %%mm7, %%mm1 \n\t" // mask to use 2nd active group - "paddb %%mm1, %%mm0 \n\t" - - // add 3rd active group - "movq %%mm0, %%mm1 \n\t" // mov updated Raws to mm1 - "psllq _ShiftBpp, %%mm1 \n\t" // shift data to pos. correctly - "pand %%mm6, %%mm1 \n\t" // mask to use 3rd active group - "addl $8, %%edx \n\t" - "paddb %%mm1, %%mm0 \n\t" - - "cmpl _MMXLength, %%edx \n\t" - "movq %%mm0, -8(%%edi,%%edx,) \n\t" // write updated Raws to array - "movq %%mm0, %%mm1 \n\t" // prep 1st add at top of loop - "jb sub_3lp \n\t" - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%edx", "%esi" // clobber list -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm6", "%mm7" -#endif - ); - } - break; - - case 1: - { - __asm__ __volatile__ ( - "movl _dif, %%edx \n\t" -// preload "movl row, %%edi \n\t" - "cmpl _FullLength, %%edx \n\t" - "jnb sub_1end \n\t" - "movl %%edi, %%esi \n\t" // lp = row - "xorl %%eax, %%eax \n\t" -// preload "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp - - "sub_1lp: \n\t" - "movb (%%esi,%%edx,), %%al \n\t" - "addb %%al, (%%edi,%%edx,) \n\t" - "incl %%edx \n\t" - "cmpl _FullLength, %%edx \n\t" - "jb sub_1lp \n\t" - - "sub_1end: \n\t" - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%edx", "%esi" // clobber list - ); - } - return; - - case 6: - case 4: - //case 7: // GRR BOGUS - //case 5: // GRR BOGUS - { - _ShiftBpp.use = bpp << 3; - _ShiftRem.use = 64 - _ShiftBpp.use; - - __asm__ __volatile__ ( -// preload "movl row, %%edi \n\t" - "movl _dif, %%edx \n\t" - "movl %%edi, %%esi \n\t" // lp = row -// preload "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp - - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%edx,), %%mm1 \n\t" - - "sub_4lp: \n\t" // shift data for adding first - "psrlq _ShiftRem, %%mm1 \n\t" // bpp bytes (no need for mask; - // shift clears inactive bytes) - "movq (%%edi,%%edx,), %%mm0 \n\t" - "paddb %%mm1, %%mm0 \n\t" - - // add 2nd active group - "movq %%mm0, %%mm1 \n\t" // mov updated Raws to mm1 - "psllq _ShiftBpp, %%mm1 \n\t" // shift data to pos. correctly - "addl $8, %%edx \n\t" - "paddb %%mm1, %%mm0 \n\t" - - "cmpl _MMXLength, %%edx \n\t" - "movq %%mm0, -8(%%edi,%%edx,) \n\t" - "movq %%mm0, %%mm1 \n\t" // prep 1st add at top of loop - "jb sub_4lp \n\t" - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%edx", "%esi" // clobber list -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1" -#endif - ); - } - break; - - case 2: - { - _ActiveMask.use = 0x00000000ffff0000LL; - _ShiftBpp.use = 16; // == 2 * 8 - _ShiftRem.use = 48; // == 64 - 16 - - __asm__ __volatile__ ( - "movq _ActiveMask, %%mm7 \n\t" // load _ActiveMask for 2nd - // active byte group - "movl _dif, %%edx \n\t" - "movq %%mm7, %%mm6 \n\t" -// preload "movl row, %%edi \n\t" - "psllq _ShiftBpp, %%mm6 \n\t" // move mask in mm6 to cover - // 3rd active byte group - "movl %%edi, %%esi \n\t" // lp = row - "movq %%mm6, %%mm5 \n\t" -// preload "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp - "psllq _ShiftBpp, %%mm5 \n\t" // move mask in mm5 to cover - // 4th active byte group - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%edx,), %%mm1 \n\t" - - "sub_2lp: \n\t" // shift data for adding first - "psrlq _ShiftRem, %%mm1 \n\t" // bpp bytes (no need for mask; - // shift clears inactive bytes) - // add 1st active group - "movq (%%edi,%%edx,), %%mm0 \n\t" - "paddb %%mm1, %%mm0 \n\t" - - // add 2nd active group - "movq %%mm0, %%mm1 \n\t" // mov updated Raws to mm1 - "psllq _ShiftBpp, %%mm1 \n\t" // shift data to pos. correctly - "pand %%mm7, %%mm1 \n\t" // mask to use 2nd active group - "paddb %%mm1, %%mm0 \n\t" - - // add 3rd active group - "movq %%mm0, %%mm1 \n\t" // mov updated Raws to mm1 - "psllq _ShiftBpp, %%mm1 \n\t" // shift data to pos. correctly - "pand %%mm6, %%mm1 \n\t" // mask to use 3rd active group - "paddb %%mm1, %%mm0 \n\t" - - // add 4th active group - "movq %%mm0, %%mm1 \n\t" // mov updated Raws to mm1 - "psllq _ShiftBpp, %%mm1 \n\t" // shift data to pos. correctly - "pand %%mm5, %%mm1 \n\t" // mask to use 4th active group - "addl $8, %%edx \n\t" - "paddb %%mm1, %%mm0 \n\t" - "cmpl _MMXLength, %%edx \n\t" - "movq %%mm0, -8(%%edi,%%edx,) \n\t" // write updated Raws to array - "movq %%mm0, %%mm1 \n\t" // prep 1st add at top of loop - "jb sub_2lp \n\t" - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%edx", "%esi" // clobber list -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; - - case 8: - { - __asm__ __volatile__ ( -// preload "movl row, %%edi \n\t" - "movl _dif, %%edx \n\t" - "movl %%edi, %%esi \n\t" // lp = row -// preload "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp - "movl _MMXLength, %%ecx \n\t" - - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%edx,), %%mm7 \n\t" - "andl $0x0000003f, %%ecx \n\t" // calc bytes over mult of 64 - - "sub_8lp: \n\t" - "movq (%%edi,%%edx,), %%mm0 \n\t" // load Sub(x) for 1st 8 bytes - "paddb %%mm7, %%mm0 \n\t" - "movq 8(%%edi,%%edx,), %%mm1 \n\t" // load Sub(x) for 2nd 8 bytes - "movq %%mm0, (%%edi,%%edx,) \n\t" // write Raw(x) for 1st 8 bytes - - // Now mm0 will be used as Raw(x-bpp) for the 2nd group of 8 bytes. - // This will be repeated for each group of 8 bytes with the 8th - // group being used as the Raw(x-bpp) for the 1st group of the - // next loop. - - "paddb %%mm0, %%mm1 \n\t" - "movq 16(%%edi,%%edx,), %%mm2 \n\t" // load Sub(x) for 3rd 8 bytes - "movq %%mm1, 8(%%edi,%%edx,) \n\t" // write Raw(x) for 2nd 8 bytes - "paddb %%mm1, %%mm2 \n\t" - "movq 24(%%edi,%%edx,), %%mm3 \n\t" // load Sub(x) for 4th 8 bytes - "movq %%mm2, 16(%%edi,%%edx,) \n\t" // write Raw(x) for 3rd 8 bytes - "paddb %%mm2, %%mm3 \n\t" - "movq 32(%%edi,%%edx,), %%mm4 \n\t" // load Sub(x) for 5th 8 bytes - "movq %%mm3, 24(%%edi,%%edx,) \n\t" // write Raw(x) for 4th 8 bytes - "paddb %%mm3, %%mm4 \n\t" - "movq 40(%%edi,%%edx,), %%mm5 \n\t" // load Sub(x) for 6th 8 bytes - "movq %%mm4, 32(%%edi,%%edx,) \n\t" // write Raw(x) for 5th 8 bytes - "paddb %%mm4, %%mm5 \n\t" - "movq 48(%%edi,%%edx,), %%mm6 \n\t" // load Sub(x) for 7th 8 bytes - "movq %%mm5, 40(%%edi,%%edx,) \n\t" // write Raw(x) for 6th 8 bytes - "paddb %%mm5, %%mm6 \n\t" - "movq 56(%%edi,%%edx,), %%mm7 \n\t" // load Sub(x) for 8th 8 bytes - "movq %%mm6, 48(%%edi,%%edx,) \n\t" // write Raw(x) for 7th 8 bytes - "addl $64, %%edx \n\t" - "paddb %%mm6, %%mm7 \n\t" - "cmpl %%ecx, %%edx \n\t" - "movq %%mm7, -8(%%edi,%%edx,) \n\t" // write Raw(x) for 8th 8 bytes - "jb sub_8lp \n\t" - - "cmpl _MMXLength, %%edx \n\t" - "jnb sub_8lt8 \n\t" - - "sub_8lpA: \n\t" - "movq (%%edi,%%edx,), %%mm0 \n\t" - "addl $8, %%edx \n\t" - "paddb %%mm7, %%mm0 \n\t" - "cmpl _MMXLength, %%edx \n\t" - "movq %%mm0, -8(%%edi,%%edx,) \n\t" // -8 to offset early addl edx - "movq %%mm0, %%mm7 \n\t" // move calculated Raw(x) data - // to mm1 to be new Raw(x-bpp) - // for next loop - "jb sub_8lpA \n\t" - - "sub_8lt8: \n\t" - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%ecx", "%edx", "%esi" // clobber list -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3", "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; - - default: // bpp greater than 8 bytes GRR BOGUS - { - __asm__ __volatile__ ( - "movl _dif, %%edx \n\t" -// preload "movl row, %%edi \n\t" - "movl %%edi, %%esi \n\t" // lp = row -// preload "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp - - "sub_Alp: \n\t" - "movq (%%edi,%%edx,), %%mm0 \n\t" - "movq (%%esi,%%edx,), %%mm1 \n\t" - "addl $8, %%edx \n\t" - "paddb %%mm1, %%mm0 \n\t" - "cmpl _MMXLength, %%edx \n\t" - "movq %%mm0, -8(%%edi,%%edx,) \n\t" // mov does not affect flags; - // -8 to offset addl edx - "jb sub_Alp \n\t" - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%edx", "%esi" // clobber list -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1" -#endif - ); - } - break; - - } // end switch (bpp) - - __asm__ __volatile__ ( - "movl _MMXLength, %%edx \n\t" -//pre "movl row, %%edi \n\t" - "cmpl _FullLength, %%edx \n\t" - "jnb sub_end \n\t" - - "movl %%edi, %%esi \n\t" // lp = row -//pre "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp - "xorl %%eax, %%eax \n\t" - - "sub_lp2: \n\t" - "movb (%%esi,%%edx,), %%al \n\t" - "addb %%al, (%%edi,%%edx,) \n\t" - "incl %%edx \n\t" - "cmpl _FullLength, %%edx \n\t" - "jb sub_lp2 \n\t" - - "sub_end: \n\t" - "EMMS \n\t" // end MMX instructions - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%edx", "%esi" // clobber list - ); - -} // end of png_read_filter_row_mmx_sub() -#endif - - - - -//===========================================================================// -// // -// P N G _ R E A D _ F I L T E R _ R O W _ M M X _ U P // -// // -//===========================================================================// - -// Optimized code for PNG Up filter decoder - -static void /* PRIVATE */ -png_read_filter_row_mmx_up(png_row_infop row_info, png_bytep row, - png_bytep prev_row) -{ - png_uint_32 len; - int dummy_value_d; // fix 'forbidden register 3 (dx) was spilled' error - int dummy_value_S; - int dummy_value_D; - - len = row_info->rowbytes; // number of bytes to filter - - __asm__ __volatile__ ( -//pre "movl row, %%edi \n\t" - // get # of bytes to alignment -#ifdef __PIC__ - "pushl %%ebx \n\t" -#endif - "movl %%edi, %%ecx \n\t" - "xorl %%ebx, %%ebx \n\t" - "addl $0x7, %%ecx \n\t" - "xorl %%eax, %%eax \n\t" - "andl $0xfffffff8, %%ecx \n\t" -//pre "movl prev_row, %%esi \n\t" - "subl %%edi, %%ecx \n\t" - "jz up_go \n\t" - - "up_lp1: \n\t" // fix alignment - "movb (%%edi,%%ebx,), %%al \n\t" - "addb (%%esi,%%ebx,), %%al \n\t" - "incl %%ebx \n\t" - "cmpl %%ecx, %%ebx \n\t" - "movb %%al, -1(%%edi,%%ebx,) \n\t" // mov does not affect flags; -1 to - "jb up_lp1 \n\t" // offset incl ebx - - "up_go: \n\t" -//pre "movl len, %%edx \n\t" - "movl %%edx, %%ecx \n\t" - "subl %%ebx, %%edx \n\t" // subtract alignment fix - "andl $0x0000003f, %%edx \n\t" // calc bytes over mult of 64 - "subl %%edx, %%ecx \n\t" // drop over bytes from length - - // unrolled loop - use all MMX registers and interleave to reduce - // number of branch instructions (loops) and reduce partial stalls - "up_loop: \n\t" - "movq (%%esi,%%ebx,), %%mm1 \n\t" - "movq (%%edi,%%ebx,), %%mm0 \n\t" - "movq 8(%%esi,%%ebx,), %%mm3 \n\t" - "paddb %%mm1, %%mm0 \n\t" - "movq 8(%%edi,%%ebx,), %%mm2 \n\t" - "movq %%mm0, (%%edi,%%ebx,) \n\t" - "paddb %%mm3, %%mm2 \n\t" - "movq 16(%%esi,%%ebx,), %%mm5 \n\t" - "movq %%mm2, 8(%%edi,%%ebx,) \n\t" - "movq 16(%%edi,%%ebx,), %%mm4 \n\t" - "movq 24(%%esi,%%ebx,), %%mm7 \n\t" - "paddb %%mm5, %%mm4 \n\t" - "movq 24(%%edi,%%ebx,), %%mm6 \n\t" - "movq %%mm4, 16(%%edi,%%ebx,) \n\t" - "paddb %%mm7, %%mm6 \n\t" - "movq 32(%%esi,%%ebx,), %%mm1 \n\t" - "movq %%mm6, 24(%%edi,%%ebx,) \n\t" - "movq 32(%%edi,%%ebx,), %%mm0 \n\t" - "movq 40(%%esi,%%ebx,), %%mm3 \n\t" - "paddb %%mm1, %%mm0 \n\t" - "movq 40(%%edi,%%ebx,), %%mm2 \n\t" - "movq %%mm0, 32(%%edi,%%ebx,) \n\t" - "paddb %%mm3, %%mm2 \n\t" - "movq 48(%%esi,%%ebx,), %%mm5 \n\t" - "movq %%mm2, 40(%%edi,%%ebx,) \n\t" - "movq 48(%%edi,%%ebx,), %%mm4 \n\t" - "movq 56(%%esi,%%ebx,), %%mm7 \n\t" - "paddb %%mm5, %%mm4 \n\t" - "movq 56(%%edi,%%ebx,), %%mm6 \n\t" - "movq %%mm4, 48(%%edi,%%ebx,) \n\t" - "addl $64, %%ebx \n\t" - "paddb %%mm7, %%mm6 \n\t" - "cmpl %%ecx, %%ebx \n\t" - "movq %%mm6, -8(%%edi,%%ebx,) \n\t" // (+56)movq does not affect flags; - "jb up_loop \n\t" // -8 to offset addl ebx - - "cmpl $0, %%edx \n\t" // test for bytes over mult of 64 - "jz up_end \n\t" - - "cmpl $8, %%edx \n\t" // test for less than 8 bytes - "jb up_lt8 \n\t" // [added by lcreeve at netins.net] - - "addl %%edx, %%ecx \n\t" - "andl $0x00000007, %%edx \n\t" // calc bytes over mult of 8 - "subl %%edx, %%ecx \n\t" // drop over bytes from length - "jz up_lt8 \n\t" - - "up_lpA: \n\t" // use MMX regs to update 8 bytes sim. - "movq (%%esi,%%ebx,), %%mm1 \n\t" - "movq (%%edi,%%ebx,), %%mm0 \n\t" - "addl $8, %%ebx \n\t" - "paddb %%mm1, %%mm0 \n\t" - "cmpl %%ecx, %%ebx \n\t" - "movq %%mm0, -8(%%edi,%%ebx,) \n\t" // movq does not affect flags; -8 to - "jb up_lpA \n\t" // offset add ebx - "cmpl $0, %%edx \n\t" // test for bytes over mult of 8 - "jz up_end \n\t" - - "up_lt8: \n\t" - "xorl %%eax, %%eax \n\t" - "addl %%edx, %%ecx \n\t" // move over byte count into counter - - "up_lp2: \n\t" // use x86 regs for remaining bytes - "movb (%%edi,%%ebx,), %%al \n\t" - "addb (%%esi,%%ebx,), %%al \n\t" - "incl %%ebx \n\t" - "cmpl %%ecx, %%ebx \n\t" - "movb %%al, -1(%%edi,%%ebx,) \n\t" // mov does not affect flags; -1 to - "jb up_lp2 \n\t" // offset inc ebx - - "up_end: \n\t" - "EMMS \n\t" // conversion of filtered row complete -#ifdef __PIC__ - "popl %%ebx \n\t" -#endif - - : "=d" (dummy_value_d), // 0 // output regs (dummy) - "=S" (dummy_value_S), // 1 - "=D" (dummy_value_D) // 2 - - : "0" (len), // edx // input regs - "1" (prev_row), // esi - "2" (row) // edi - - : "%eax", "%ecx" // clobber list (no input regs!) -#ifndef __PIC__ - , "%ebx" -#endif - -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - -} // end of png_read_filter_row_mmx_up() - -#endif /* PNG_MMX_CODE_SUPPORTED */ - - - - -/*===========================================================================*/ -/* */ -/* P N G _ R E A D _ F I L T E R _ R O W */ -/* */ -/*===========================================================================*/ - - -/* Optimized png_read_filter_row routines */ - -void /* PRIVATE */ -png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep - row, png_bytep prev_row, int filter) -{ -#ifdef PNG_DEBUG - char filnm[10]; -#endif - -#if defined(PNG_MMX_CODE_SUPPORTED) -/* GRR: these are superseded by png_ptr->asm_flags: */ -#define UseMMX_sub 1 // GRR: converted 20000730 -#define UseMMX_up 1 // GRR: converted 20000729 -#define UseMMX_avg 1 // GRR: converted 20000828 (+ 16-bit bugfix 20000916) -#define UseMMX_paeth 1 // GRR: converted 20000828 - - if (_mmx_supported == 2) { - /* this should have happened in png_init_mmx_flags() already */ -#if !defined(PNG_1_0_X) - png_warning(png_ptr, "asm_flags may not have been initialized"); -#endif - png_mmx_support(); - } -#endif /* PNG_MMX_CODE_SUPPORTED */ - -#ifdef PNG_DEBUG - png_debug(1, "in png_read_filter_row (pnggccrd.c)\n"); - switch (filter) - { - case 0: sprintf(filnm, "none"); - break; - case 1: sprintf(filnm, "sub-%s", -#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB)? "MMX" : -#endif -#endif -"x86"); - break; - case 2: sprintf(filnm, "up-%s", -#ifdef PNG_MMX_CODE_SUPPORTED -#if !defined(PNG_1_0_X) - (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP)? "MMX" : -#endif -#endif - "x86"); - break; - case 3: sprintf(filnm, "avg-%s", -#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG)? "MMX" : -#endif -#endif - "x86"); - break; - case 4: sprintf(filnm, "Paeth-%s", -#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH)? "MMX": -#endif -#endif -"x86"); - break; - default: sprintf(filnm, "unknw"); - break; - } - png_debug2(0, "row_number=%5ld, %5s, ", png_ptr->row_number, filnm); - png_debug1(0, "row=0x%08lx, ", (unsigned long)row); - png_debug2(0, "pixdepth=%2d, bytes=%d, ", (int)row_info->pixel_depth, - (int)((row_info->pixel_depth + 7) >> 3)); - png_debug1(0,"rowbytes=%8ld\n", row_info->rowbytes); -#endif /* PNG_DEBUG */ - - switch (filter) - { - case PNG_FILTER_VALUE_NONE: - break; - - case PNG_FILTER_VALUE_SUB: -#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB) && - (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && - (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) -#else - if (_mmx_supported) -#endif - { - png_read_filter_row_mmx_sub(row_info, row); - } - else -#endif /* PNG_MMX_CODE_SUPPORTED */ - { - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_bytep rp = row + bpp; - png_bytep lp = row; - - for (i = bpp; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*lp++)) & 0xff); - rp++; - } - } /* end !UseMMX_sub */ - break; - - case PNG_FILTER_VALUE_UP: -#if defined(PNG_MMX_CODE_SUPPORTED) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP) && - (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && - (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) -#else - if (_mmx_supported) -#endif - { - png_read_filter_row_mmx_up(row_info, row, prev_row); - } - else -#endif /* PNG_MMX_CODE_SUPPORTED */ - { - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_bytep rp = row; - png_bytep pp = prev_row; - - for (i = 0; i < istop; ++i) - { - *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); - rp++; - } - } /* end !UseMMX_up */ - break; - - case PNG_FILTER_VALUE_AVG: -#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG) && - (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && - (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) -#else - if (_mmx_supported) -#endif - { - png_read_filter_row_mmx_avg(row_info, row, prev_row); - } - else -#endif /* PNG_MMX_CODE_SUPPORTED */ - { - png_uint_32 i; - png_bytep rp = row; - png_bytep pp = prev_row; - png_bytep lp = row; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_uint_32 istop = row_info->rowbytes - bpp; - - for (i = 0; i < bpp; i++) - { - *rp = (png_byte)(((int)(*rp) + - ((int)(*pp++) >> 1)) & 0xff); - rp++; - } - - for (i = 0; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + - ((int)(*pp++ + *lp++) >> 1)) & 0xff); - rp++; - } - } /* end !UseMMX_avg */ - break; - - case PNG_FILTER_VALUE_PAETH: -#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK) -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH) && - (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && - (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) -#else - if (_mmx_supported) -#endif - { - png_read_filter_row_mmx_paeth(row_info, row, prev_row); - } - else -#endif /* PNG_MMX_CODE_SUPPORTED */ - { - png_uint_32 i; - png_bytep rp = row; - png_bytep pp = prev_row; - png_bytep lp = row; - png_bytep cp = prev_row; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_uint_32 istop = row_info->rowbytes - bpp; - - for (i = 0; i < bpp; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); - rp++; - } - - for (i = 0; i < istop; i++) /* use leftover rp,pp */ - { - int a, b, c, pa, pb, pc, p; - - a = *lp++; - b = *pp++; - c = *cp++; - - p = b - c; - pc = a - c; - -#ifdef PNG_USE_ABS - pa = abs(p); - pb = abs(pc); - pc = abs(p + pc); -#else - pa = p < 0 ? -p : p; - pb = pc < 0 ? -pc : pc; - pc = (p + pc) < 0 ? -(p + pc) : p + pc; -#endif - - /* - if (pa <= pb && pa <= pc) - p = a; - else if (pb <= pc) - p = b; - else - p = c; - */ - - p = (pa <= pb && pa <= pc) ? a : (pb <= pc) ? b : c; - - *rp = (png_byte)(((int)(*rp) + p) & 0xff); - rp++; - } - } /* end !UseMMX_paeth */ - break; - - default: - png_warning(png_ptr, "Ignoring bad row-filter type"); - *row=0; - break; - } -} - -#endif /* PNG_HAVE_MMX_READ_FILTER_ROW */ - - -/*===========================================================================*/ -/* */ -/* P N G _ M M X _ S U P P O R T */ -/* */ -/*===========================================================================*/ - -/* GRR NOTES: (1) the following code assumes 386 or better (pushfl/popfl) - * (2) all instructions compile with gcc 2.7.2.3 and later - * (3) the function is moved down here to prevent gcc from - * inlining it in multiple places and then barfing be- - * cause the ".NOT_SUPPORTED" label is multiply defined - * [is there a way to signal that a *single* function should - * not be inlined? is there a way to modify the label for - * each inlined instance, e.g., by appending _1, _2, etc.? - * maybe if don't use leading "." in label name? (nope...sigh)] - */ - -int PNGAPI -png_mmx_support(void) -{ -#if defined(PNG_MMX_CODE_SUPPORTED) - int result; - __asm__ __volatile__ ( - "pushl %%ebx \n\t" // ebx gets clobbered by CPUID instruction - "pushl %%ecx \n\t" // so does ecx... - "pushl %%edx \n\t" // ...and edx (but ecx & edx safe on Linux) -// ".byte 0x66 \n\t" // convert 16-bit pushf to 32-bit pushfd -// "pushf \n\t" // 16-bit pushf - "pushfl \n\t" // save Eflag to stack - "popl %%eax \n\t" // get Eflag from stack into eax - "movl %%eax, %%ecx \n\t" // make another copy of Eflag in ecx - "xorl $0x200000, %%eax \n\t" // toggle ID bit in Eflag (i.e., bit 21) - "pushl %%eax \n\t" // save modified Eflag back to stack -// ".byte 0x66 \n\t" // convert 16-bit popf to 32-bit popfd -// "popf \n\t" // 16-bit popf - "popfl \n\t" // restore modified value to Eflag reg - "pushfl \n\t" // save Eflag to stack - "popl %%eax \n\t" // get Eflag from stack - "pushl %%ecx \n\t" // save original Eflag to stack - "popfl \n\t" // restore original Eflag - "xorl %%ecx, %%eax \n\t" // compare new Eflag with original Eflag - "jz 0f \n\t" // if same, CPUID instr. is not supported - - "xorl %%eax, %%eax \n\t" // set eax to zero -// ".byte 0x0f, 0xa2 \n\t" // CPUID instruction (two-byte opcode) - "cpuid \n\t" // get the CPU identification info - "cmpl $1, %%eax \n\t" // make sure eax return non-zero value - "jl 0f \n\t" // if eax is zero, MMX is not supported - - "xorl %%eax, %%eax \n\t" // set eax to zero and... - "incl %%eax \n\t" // ...increment eax to 1. This pair is - // faster than the instruction "mov eax, 1" - "cpuid \n\t" // get the CPU identification info again - "andl $0x800000, %%edx \n\t" // mask out all bits but MMX bit (23) - "cmpl $0, %%edx \n\t" // 0 = MMX not supported - "jz 0f \n\t" // non-zero = yes, MMX IS supported - - "movl $1, %%eax \n\t" // set return value to 1 - "jmp 1f \n\t" // DONE: have MMX support - - "0: \n\t" // .NOT_SUPPORTED: target label for jump instructions - "movl $0, %%eax \n\t" // set return value to 0 - "1: \n\t" // .RETURN: target label for jump instructions - "popl %%edx \n\t" // restore edx - "popl %%ecx \n\t" // restore ecx - "popl %%ebx \n\t" // restore ebx - -// "ret \n\t" // DONE: no MMX support - // (fall through to standard C "ret") - - : "=a" (result) // output list - - : // any variables used on input (none) - - // no clobber list -// , "%ebx", "%ecx", "%edx" // GRR: we handle these manually -// , "memory" // if write to a variable gcc thought was in a reg -// , "cc" // "condition codes" (flag bits) - ); - _mmx_supported = result; -#else - _mmx_supported = 0; -#endif /* PNG_MMX_CODE_SUPPORTED */ - - return _mmx_supported; -} - - -#endif /* PNG_USE_PNGGCCRD */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng_osx/pngget.c b/irrlicht-1.6/source/Irrlicht/libpng_osx/pngget.c deleted file mode 100644 index 036e9af6e..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng_osx/pngget.c +++ /dev/null @@ -1,955 +0,0 @@ - -/* pngget.c - retrieval of values from info struct - * - * Last changed in libpng 1.2.15 January 5, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) - -png_uint_32 PNGAPI -png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag) -{ - if (png_ptr != NULL && info_ptr != NULL) - return(info_ptr->valid & flag); - else - return(0); -} - -png_uint_32 PNGAPI -png_get_rowbytes(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - return(info_ptr->rowbytes); - else - return(0); -} - -#if defined(PNG_INFO_IMAGE_SUPPORTED) -png_bytepp PNGAPI -png_get_rows(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - return(info_ptr->row_pointers); - else - return(0); -} -#endif - -#ifdef PNG_EASY_ACCESS_SUPPORTED -/* easy access to info, added in libpng-0.99 */ -png_uint_32 PNGAPI -png_get_image_width(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - { - return info_ptr->width; - } - return (0); -} - -png_uint_32 PNGAPI -png_get_image_height(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - { - return info_ptr->height; - } - return (0); -} - -png_byte PNGAPI -png_get_bit_depth(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - { - return info_ptr->bit_depth; - } - return (0); -} - -png_byte PNGAPI -png_get_color_type(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - { - return info_ptr->color_type; - } - return (0); -} - -png_byte PNGAPI -png_get_filter_type(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - { - return info_ptr->filter_type; - } - return (0); -} - -png_byte PNGAPI -png_get_interlace_type(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - { - return info_ptr->interlace_type; - } - return (0); -} - -png_byte PNGAPI -png_get_compression_type(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - { - return info_ptr->compression_type; - } - return (0); -} - -png_uint_32 PNGAPI -png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_pHYs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_pHYs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_x_pixels_per_meter"); - if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER) - return (0); - else return (info_ptr->x_pixels_per_unit); - } -#else - return (0); -#endif - return (0); -} - -png_uint_32 PNGAPI -png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_pHYs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_pHYs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_y_pixels_per_meter"); - if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER) - return (0); - else return (info_ptr->y_pixels_per_unit); - } -#else - return (0); -#endif - return (0); -} - -png_uint_32 PNGAPI -png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_pHYs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_pHYs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_pixels_per_meter"); - if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER || - info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit) - return (0); - else return (info_ptr->x_pixels_per_unit); - } -#else - return (0); -#endif - return (0); -} - -#ifdef PNG_FLOATING_POINT_SUPPORTED -float PNGAPI -png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr) - { - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_pHYs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_pHYs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_aspect_ratio"); - if (info_ptr->x_pixels_per_unit == 0) - return ((float)0.0); - else - return ((float)((float)info_ptr->y_pixels_per_unit - /(float)info_ptr->x_pixels_per_unit)); - } -#else - return (0.0); -#endif - return ((float)0.0); -} -#endif - -png_int_32 PNGAPI -png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_oFFs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_oFFs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns"); - if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) - return (0); - else return (info_ptr->x_offset); - } -#else - return (0); -#endif - return (0); -} - -png_int_32 PNGAPI -png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_oFFs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_oFFs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns"); - if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) - return (0); - else return (info_ptr->y_offset); - } -#else - return (0); -#endif - return (0); -} - -png_int_32 PNGAPI -png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_oFFs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_oFFs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns"); - if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) - return (0); - else return (info_ptr->x_offset); - } -#else - return (0); -#endif - return (0); -} - -png_int_32 PNGAPI -png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_oFFs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_oFFs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns"); - if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) - return (0); - else return (info_ptr->y_offset); - } -#else - return (0); -#endif - return (0); -} - -#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED) -png_uint_32 PNGAPI -png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) -{ - return ((png_uint_32)((float)png_get_pixels_per_meter(png_ptr, info_ptr) - *.0254 +.5)); -} - -png_uint_32 PNGAPI -png_get_x_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) -{ - return ((png_uint_32)((float)png_get_x_pixels_per_meter(png_ptr, info_ptr) - *.0254 +.5)); -} - -png_uint_32 PNGAPI -png_get_y_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) -{ - return ((png_uint_32)((float)png_get_y_pixels_per_meter(png_ptr, info_ptr) - *.0254 +.5)); -} - -float PNGAPI -png_get_x_offset_inches(png_structp png_ptr, png_infop info_ptr) -{ - return ((float)png_get_x_offset_microns(png_ptr, info_ptr) - *.00003937); -} - -float PNGAPI -png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr) -{ - return ((float)png_get_y_offset_microns(png_ptr, info_ptr) - *.00003937); -} - -#if defined(PNG_pHYs_SUPPORTED) -png_uint_32 PNGAPI -png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr, - png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) -{ - png_uint_32 retval = 0; - - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) - { - png_debug1(1, "in %s retrieval function\n", "pHYs"); - if (res_x != NULL) - { - *res_x = info_ptr->x_pixels_per_unit; - retval |= PNG_INFO_pHYs; - } - if (res_y != NULL) - { - *res_y = info_ptr->y_pixels_per_unit; - retval |= PNG_INFO_pHYs; - } - if (unit_type != NULL) - { - *unit_type = (int)info_ptr->phys_unit_type; - retval |= PNG_INFO_pHYs; - if(*unit_type == 1) - { - if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50); - if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50); - } - } - } - return (retval); -} -#endif /* PNG_pHYs_SUPPORTED */ -#endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */ - -/* png_get_channels really belongs in here, too, but it's been around longer */ - -#endif /* PNG_EASY_ACCESS_SUPPORTED */ - -png_byte PNGAPI -png_get_channels(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - return(info_ptr->channels); - else - return (0); -} - -png_bytep PNGAPI -png_get_signature(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - return(info_ptr->signature); - else - return (NULL); -} - -#if defined(PNG_bKGD_SUPPORTED) -png_uint_32 PNGAPI -png_get_bKGD(png_structp png_ptr, png_infop info_ptr, - png_color_16p *background) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD) - && background != NULL) - { - png_debug1(1, "in %s retrieval function\n", "bKGD"); - *background = &(info_ptr->background); - return (PNG_INFO_bKGD); - } - return (0); -} -#endif - -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -png_uint_32 PNGAPI -png_get_cHRM(png_structp png_ptr, png_infop info_ptr, - double *white_x, double *white_y, double *red_x, double *red_y, - double *green_x, double *green_y, double *blue_x, double *blue_y) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) - { - png_debug1(1, "in %s retrieval function\n", "cHRM"); - if (white_x != NULL) - *white_x = (double)info_ptr->x_white; - if (white_y != NULL) - *white_y = (double)info_ptr->y_white; - if (red_x != NULL) - *red_x = (double)info_ptr->x_red; - if (red_y != NULL) - *red_y = (double)info_ptr->y_red; - if (green_x != NULL) - *green_x = (double)info_ptr->x_green; - if (green_y != NULL) - *green_y = (double)info_ptr->y_green; - if (blue_x != NULL) - *blue_x = (double)info_ptr->x_blue; - if (blue_y != NULL) - *blue_y = (double)info_ptr->y_blue; - return (PNG_INFO_cHRM); - } - return (0); -} -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -png_uint_32 PNGAPI -png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr, - png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x, - png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y, - png_fixed_point *blue_x, png_fixed_point *blue_y) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) - { - png_debug1(1, "in %s retrieval function\n", "cHRM"); - if (white_x != NULL) - *white_x = info_ptr->int_x_white; - if (white_y != NULL) - *white_y = info_ptr->int_y_white; - if (red_x != NULL) - *red_x = info_ptr->int_x_red; - if (red_y != NULL) - *red_y = info_ptr->int_y_red; - if (green_x != NULL) - *green_x = info_ptr->int_x_green; - if (green_y != NULL) - *green_y = info_ptr->int_y_green; - if (blue_x != NULL) - *blue_x = info_ptr->int_x_blue; - if (blue_y != NULL) - *blue_y = info_ptr->int_y_blue; - return (PNG_INFO_cHRM); - } - return (0); -} -#endif -#endif - -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -png_uint_32 PNGAPI -png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) - && file_gamma != NULL) - { - png_debug1(1, "in %s retrieval function\n", "gAMA"); - *file_gamma = (double)info_ptr->gamma; - return (PNG_INFO_gAMA); - } - return (0); -} -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -png_uint_32 PNGAPI -png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, - png_fixed_point *int_file_gamma) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) - && int_file_gamma != NULL) - { - png_debug1(1, "in %s retrieval function\n", "gAMA"); - *int_file_gamma = info_ptr->int_gamma; - return (PNG_INFO_gAMA); - } - return (0); -} -#endif -#endif - -#if defined(PNG_sRGB_SUPPORTED) -png_uint_32 PNGAPI -png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB) - && file_srgb_intent != NULL) - { - png_debug1(1, "in %s retrieval function\n", "sRGB"); - *file_srgb_intent = (int)info_ptr->srgb_intent; - return (PNG_INFO_sRGB); - } - return (0); -} -#endif - -#if defined(PNG_iCCP_SUPPORTED) -png_uint_32 PNGAPI -png_get_iCCP(png_structp png_ptr, png_infop info_ptr, - png_charpp name, int *compression_type, - png_charpp profile, png_uint_32 *proflen) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP) - && name != NULL && profile != NULL && proflen != NULL) - { - png_debug1(1, "in %s retrieval function\n", "iCCP"); - *name = info_ptr->iccp_name; - *profile = info_ptr->iccp_profile; - /* compression_type is a dummy so the API won't have to change - if we introduce multiple compression types later. */ - *proflen = (int)info_ptr->iccp_proflen; - *compression_type = (int)info_ptr->iccp_compression; - return (PNG_INFO_iCCP); - } - return (0); -} -#endif - -#if defined(PNG_sPLT_SUPPORTED) -png_uint_32 PNGAPI -png_get_sPLT(png_structp png_ptr, png_infop info_ptr, - png_sPLT_tpp spalettes) -{ - if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL) - *spalettes = info_ptr->splt_palettes; - return ((png_uint_32)info_ptr->splt_palettes_num); -} -#endif - -#if defined(PNG_hIST_SUPPORTED) -png_uint_32 PNGAPI -png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST) - && hist != NULL) - { - png_debug1(1, "in %s retrieval function\n", "hIST"); - *hist = info_ptr->hist; - return (PNG_INFO_hIST); - } - return (0); -} -#endif - -png_uint_32 PNGAPI -png_get_IHDR(png_structp png_ptr, png_infop info_ptr, - png_uint_32 *width, png_uint_32 *height, int *bit_depth, - int *color_type, int *interlace_type, int *compression_type, - int *filter_type) - -{ - if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL && - bit_depth != NULL && color_type != NULL) - { - png_debug1(1, "in %s retrieval function\n", "IHDR"); - *width = info_ptr->width; - *height = info_ptr->height; - *bit_depth = info_ptr->bit_depth; - if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16) - png_error(png_ptr, "Invalid bit depth"); - *color_type = info_ptr->color_type; - if (info_ptr->color_type > 6) - png_error(png_ptr, "Invalid color type"); - if (compression_type != NULL) - *compression_type = info_ptr->compression_type; - if (filter_type != NULL) - *filter_type = info_ptr->filter_type; - if (interlace_type != NULL) - *interlace_type = info_ptr->interlace_type; - - /* check for potential overflow of rowbytes */ - if (*width == 0 || *width > PNG_UINT_31_MAX) - png_error(png_ptr, "Invalid image width"); - if (*height == 0 || *height > PNG_UINT_31_MAX) - png_error(png_ptr, "Invalid image height"); - if (info_ptr->width > (PNG_UINT_32_MAX - >> 3) /* 8-byte RGBA pixels */ - - 64 /* bigrowbuf hack */ - - 1 /* filter byte */ - - 7*8 /* rounding of width to multiple of 8 pixels */ - - 8) /* extra max_pixel_depth pad */ - { - png_warning(png_ptr, - "Width too large for libpng to process image data."); - } - return (1); - } - return (0); -} - -#if defined(PNG_oFFs_SUPPORTED) -png_uint_32 PNGAPI -png_get_oFFs(png_structp png_ptr, png_infop info_ptr, - png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs) - && offset_x != NULL && offset_y != NULL && unit_type != NULL) - { - png_debug1(1, "in %s retrieval function\n", "oFFs"); - *offset_x = info_ptr->x_offset; - *offset_y = info_ptr->y_offset; - *unit_type = (int)info_ptr->offset_unit_type; - return (PNG_INFO_oFFs); - } - return (0); -} -#endif - -#if defined(PNG_pCAL_SUPPORTED) -png_uint_32 PNGAPI -png_get_pCAL(png_structp png_ptr, png_infop info_ptr, - png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, - png_charp *units, png_charpp *params) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL) - && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL && - nparams != NULL && units != NULL && params != NULL) - { - png_debug1(1, "in %s retrieval function\n", "pCAL"); - *purpose = info_ptr->pcal_purpose; - *X0 = info_ptr->pcal_X0; - *X1 = info_ptr->pcal_X1; - *type = (int)info_ptr->pcal_type; - *nparams = (int)info_ptr->pcal_nparams; - *units = info_ptr->pcal_units; - *params = info_ptr->pcal_params; - return (PNG_INFO_pCAL); - } - return (0); -} -#endif - -#if defined(PNG_sCAL_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -png_uint_32 PNGAPI -png_get_sCAL(png_structp png_ptr, png_infop info_ptr, - int *unit, double *width, double *height) -{ - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_sCAL)) - { - *unit = info_ptr->scal_unit; - *width = info_ptr->scal_pixel_width; - *height = info_ptr->scal_pixel_height; - return (PNG_INFO_sCAL); - } - return(0); -} -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -png_uint_32 PNGAPI -png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr, - int *unit, png_charpp width, png_charpp height) -{ - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_sCAL)) - { - *unit = info_ptr->scal_unit; - *width = info_ptr->scal_s_width; - *height = info_ptr->scal_s_height; - return (PNG_INFO_sCAL); - } - return(0); -} -#endif -#endif -#endif - -#if defined(PNG_pHYs_SUPPORTED) -png_uint_32 PNGAPI -png_get_pHYs(png_structp png_ptr, png_infop info_ptr, - png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) -{ - png_uint_32 retval = 0; - - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_pHYs)) - { - png_debug1(1, "in %s retrieval function\n", "pHYs"); - if (res_x != NULL) - { - *res_x = info_ptr->x_pixels_per_unit; - retval |= PNG_INFO_pHYs; - } - if (res_y != NULL) - { - *res_y = info_ptr->y_pixels_per_unit; - retval |= PNG_INFO_pHYs; - } - if (unit_type != NULL) - { - *unit_type = (int)info_ptr->phys_unit_type; - retval |= PNG_INFO_pHYs; - } - } - return (retval); -} -#endif - -png_uint_32 PNGAPI -png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette, - int *num_palette) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE) - && palette != NULL) - { - png_debug1(1, "in %s retrieval function\n", "PLTE"); - *palette = info_ptr->palette; - *num_palette = info_ptr->num_palette; - png_debug1(3, "num_palette = %d\n", *num_palette); - return (PNG_INFO_PLTE); - } - return (0); -} - -#if defined(PNG_sBIT_SUPPORTED) -png_uint_32 PNGAPI -png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT) - && sig_bit != NULL) - { - png_debug1(1, "in %s retrieval function\n", "sBIT"); - *sig_bit = &(info_ptr->sig_bit); - return (PNG_INFO_sBIT); - } - return (0); -} -#endif - -#if defined(PNG_TEXT_SUPPORTED) -png_uint_32 PNGAPI -png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr, - int *num_text) -{ - if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0) - { - png_debug1(1, "in %s retrieval function\n", - (png_ptr->chunk_name[0] == '\0' ? "text" - : (png_const_charp)png_ptr->chunk_name)); - if (text_ptr != NULL) - *text_ptr = info_ptr->text; - if (num_text != NULL) - *num_text = info_ptr->num_text; - return ((png_uint_32)info_ptr->num_text); - } - if (num_text != NULL) - *num_text = 0; - return(0); -} -#endif - -#if defined(PNG_tIME_SUPPORTED) -png_uint_32 PNGAPI -png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME) - && mod_time != NULL) - { - png_debug1(1, "in %s retrieval function\n", "tIME"); - *mod_time = &(info_ptr->mod_time); - return (PNG_INFO_tIME); - } - return (0); -} -#endif - -#if defined(PNG_tRNS_SUPPORTED) -png_uint_32 PNGAPI -png_get_tRNS(png_structp png_ptr, png_infop info_ptr, - png_bytep *trans, int *num_trans, png_color_16p *trans_values) -{ - png_uint_32 retval = 0; - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) - { - png_debug1(1, "in %s retrieval function\n", "tRNS"); - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - if (trans != NULL) - { - *trans = info_ptr->trans; - retval |= PNG_INFO_tRNS; - } - if (trans_values != NULL) - *trans_values = &(info_ptr->trans_values); - } - else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */ - { - if (trans_values != NULL) - { - *trans_values = &(info_ptr->trans_values); - retval |= PNG_INFO_tRNS; - } - if(trans != NULL) - *trans = NULL; - } - if(num_trans != NULL) - { - *num_trans = info_ptr->num_trans; - retval |= PNG_INFO_tRNS; - } - } - return (retval); -} -#endif - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -png_uint_32 PNGAPI -png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr, - png_unknown_chunkpp unknowns) -{ - if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL) - *unknowns = info_ptr->unknown_chunks; - return ((png_uint_32)info_ptr->unknown_chunks_num); -} -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) -png_byte PNGAPI -png_get_rgb_to_gray_status (png_structp png_ptr) -{ - return (png_byte)(png_ptr? png_ptr->rgb_to_gray_status : 0); -} -#endif - -#if defined(PNG_USER_CHUNKS_SUPPORTED) -png_voidp PNGAPI -png_get_user_chunk_ptr(png_structp png_ptr) -{ - return (png_ptr? png_ptr->user_chunk_ptr : NULL); -} -#endif - -#ifdef PNG_WRITE_SUPPORTED -png_uint_32 PNGAPI -png_get_compression_buffer_size(png_structp png_ptr) -{ - return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L); -} -#endif - -#ifdef PNG_ASSEMBLER_CODE_SUPPORTED -#ifndef PNG_1_0_X -/* this function was added to libpng 1.2.0 and should exist by default */ -png_uint_32 PNGAPI -png_get_asm_flags (png_structp png_ptr) -{ -#ifdef PNG_MMX_CODE_SUPPORTED - return (png_uint_32)(png_ptr? png_ptr->asm_flags : 0L); -#else - return (png_ptr? 0L: 0L); -#endif -} - -/* this function was added to libpng 1.2.0 and should exist by default */ -png_uint_32 PNGAPI -png_get_asm_flagmask (int flag_select) -{ -#ifdef PNG_MMX_CODE_SUPPORTED - png_uint_32 settable_asm_flags = 0; - - if (flag_select & PNG_SELECT_READ) - settable_asm_flags |= - PNG_ASM_FLAG_MMX_READ_COMBINE_ROW | - PNG_ASM_FLAG_MMX_READ_INTERLACE | - PNG_ASM_FLAG_MMX_READ_FILTER_SUB | - PNG_ASM_FLAG_MMX_READ_FILTER_UP | - PNG_ASM_FLAG_MMX_READ_FILTER_AVG | - PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ; - /* no non-MMX flags yet */ - -#if 0 - /* GRR: no write-flags yet, either, but someday... */ - if (flag_select & PNG_SELECT_WRITE) - settable_asm_flags |= - PNG_ASM_FLAG_MMX_WRITE_ [whatever] ; -#endif /* 0 */ - - return settable_asm_flags; /* _theoretically_ settable capabilities only */ -#else - return (0L); -#endif /* PNG_MMX_CODE_SUPPORTED */ -} - - - /* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */ -/* this function was added to libpng 1.2.0 */ -png_uint_32 PNGAPI -png_get_mmx_flagmask (int flag_select, int *compilerID) -{ -#if defined(PNG_MMX_CODE_SUPPORTED) - png_uint_32 settable_mmx_flags = 0; - - if (flag_select & PNG_SELECT_READ) - settable_mmx_flags |= - PNG_ASM_FLAG_MMX_READ_COMBINE_ROW | - PNG_ASM_FLAG_MMX_READ_INTERLACE | - PNG_ASM_FLAG_MMX_READ_FILTER_SUB | - PNG_ASM_FLAG_MMX_READ_FILTER_UP | - PNG_ASM_FLAG_MMX_READ_FILTER_AVG | - PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ; -#if 0 - /* GRR: no MMX write support yet, but someday... */ - if (flag_select & PNG_SELECT_WRITE) - settable_mmx_flags |= - PNG_ASM_FLAG_MMX_WRITE_ [whatever] ; -#endif /* 0 */ - - if (compilerID != NULL) { -#ifdef PNG_USE_PNGVCRD - *compilerID = 1; /* MSVC */ -#else -#ifdef PNG_USE_PNGGCCRD - *compilerID = 2; /* gcc/gas */ -#else - *compilerID = -1; /* unknown (i.e., no asm/MMX code compiled) */ -#endif -#endif - } - - return settable_mmx_flags; /* _theoretically_ settable capabilities only */ -#else - return (0L); -#endif /* ?PNG_MMX_CODE_SUPPORTED */ -} - -/* this function was added to libpng 1.2.0 */ -png_byte PNGAPI -png_get_mmx_bitdepth_threshold (png_structp png_ptr) -{ -#if defined(PNG_MMX_CODE_SUPPORTED) - return (png_byte)(png_ptr? png_ptr->mmx_bitdepth_threshold : 0); -#else - return (png_ptr? 0: 0); -#endif /* ?PNG_MMX_CODE_SUPPORTED */ -} - -/* this function was added to libpng 1.2.0 */ -png_uint_32 PNGAPI -png_get_mmx_rowbytes_threshold (png_structp png_ptr) -{ -#if defined(PNG_MMX_CODE_SUPPORTED) - return (png_uint_32)(png_ptr? png_ptr->mmx_rowbytes_threshold : 0L); -#else - return (png_ptr? 0L: 0L); -#endif /* ?PNG_MMX_CODE_SUPPORTED */ -} -#endif /* ?PNG_1_0_X */ -#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ - -#ifdef PNG_SET_USER_LIMITS_SUPPORTED -/* these functions were added to libpng 1.2.6 */ -png_uint_32 PNGAPI -png_get_user_width_max (png_structp png_ptr) -{ - return (png_ptr? png_ptr->user_width_max : 0); -} -png_uint_32 PNGAPI -png_get_user_height_max (png_structp png_ptr) -{ - return (png_ptr? png_ptr->user_height_max : 0); -} -#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ - -#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng_osx/pngmem.c b/irrlicht-1.6/source/Irrlicht/libpng_osx/pngmem.c deleted file mode 100644 index 248060f38..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng_osx/pngmem.c +++ /dev/null @@ -1,608 +0,0 @@ - -/* pngmem.c - stub functions for memory allocation - * - * Last changed in libpng 1.2.13 November 13, 2006 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2006 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This file provides a location for all memory allocation. Users who - * need special memory handling are expected to supply replacement - * functions for png_malloc() and png_free(), and to use - * png_create_read_struct_2() and png_create_write_struct_2() to - * identify the replacement functions. - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) - -/* Borland DOS special memory handler */ -#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) -/* if you change this, be sure to change the one in png.h also */ - -/* Allocate memory for a png_struct. The malloc and memset can be replaced - by a single call to calloc() if this is thought to improve performance. */ -png_voidp /* PRIVATE */ -png_create_struct(int type) -{ -#ifdef PNG_USER_MEM_SUPPORTED - return (png_create_struct_2(type, png_malloc_ptr_NULL, png_voidp_NULL)); -} - -/* Alternate version of png_create_struct, for use with user-defined malloc. */ -png_voidp /* PRIVATE */ -png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr) -{ -#endif /* PNG_USER_MEM_SUPPORTED */ - png_size_t size; - png_voidp struct_ptr; - - if (type == PNG_STRUCT_INFO) - size = png_sizeof(png_info); - else if (type == PNG_STRUCT_PNG) - size = png_sizeof(png_struct); - else - return (png_get_copyright(NULL)); - -#ifdef PNG_USER_MEM_SUPPORTED - if(malloc_fn != NULL) - { - png_struct dummy_struct; - png_structp png_ptr = &dummy_struct; - png_ptr->mem_ptr=mem_ptr; - struct_ptr = (*(malloc_fn))(png_ptr, (png_uint_32)size); - } - else -#endif /* PNG_USER_MEM_SUPPORTED */ - struct_ptr = (png_voidp)farmalloc(size); - if (struct_ptr != NULL) - png_memset(struct_ptr, 0, size); - return (struct_ptr); -} - -/* Free memory allocated by a png_create_struct() call */ -void /* PRIVATE */ -png_destroy_struct(png_voidp struct_ptr) -{ -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2(struct_ptr, png_free_ptr_NULL, png_voidp_NULL); -} - -/* Free memory allocated by a png_create_struct() call */ -void /* PRIVATE */ -png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, - png_voidp mem_ptr) -{ -#endif - if (struct_ptr != NULL) - { -#ifdef PNG_USER_MEM_SUPPORTED - if(free_fn != NULL) - { - png_struct dummy_struct; - png_structp png_ptr = &dummy_struct; - png_ptr->mem_ptr=mem_ptr; - (*(free_fn))(png_ptr, struct_ptr); - return; - } -#endif /* PNG_USER_MEM_SUPPORTED */ - farfree (struct_ptr); - } -} - -/* Allocate memory. For reasonable files, size should never exceed - * 64K. However, zlib may allocate more then 64K if you don't tell - * it not to. See zconf.h and png.h for more information. zlib does - * need to allocate exactly 64K, so whatever you call here must - * have the ability to do that. - * - * Borland seems to have a problem in DOS mode for exactly 64K. - * It gives you a segment with an offset of 8 (perhaps to store its - * memory stuff). zlib doesn't like this at all, so we have to - * detect and deal with it. This code should not be needed in - * Windows or OS/2 modes, and only in 16 bit mode. This code has - * been updated by Alexander Lehmann for version 0.89 to waste less - * memory. - * - * Note that we can't use png_size_t for the "size" declaration, - * since on some systems a png_size_t is a 16-bit quantity, and as a - * result, we would be truncating potentially larger memory requests - * (which should cause a fatal error) and introducing major problems. - */ - -png_voidp PNGAPI -png_malloc(png_structp png_ptr, png_uint_32 size) -{ - png_voidp ret; - - if (png_ptr == NULL || size == 0) - return (NULL); - -#ifdef PNG_USER_MEM_SUPPORTED - if(png_ptr->malloc_fn != NULL) - ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size)); - else - ret = (png_malloc_default(png_ptr, size)); - if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out of memory!"); - return (ret); -} - -png_voidp PNGAPI -png_malloc_default(png_structp png_ptr, png_uint_32 size) -{ - png_voidp ret; -#endif /* PNG_USER_MEM_SUPPORTED */ - - if (png_ptr == NULL || size == 0) - return (NULL); - -#ifdef PNG_MAX_MALLOC_64K - if (size > (png_uint_32)65536L) - { - png_warning(png_ptr, "Cannot Allocate > 64K"); - ret = NULL; - } - else -#endif - - if (size != (size_t)size) - ret = NULL; - else if (size == (png_uint_32)65536L) - { - if (png_ptr->offset_table == NULL) - { - /* try to see if we need to do any of this fancy stuff */ - ret = farmalloc(size); - if (ret == NULL || ((png_size_t)ret & 0xffff)) - { - int num_blocks; - png_uint_32 total_size; - png_bytep table; - int i; - png_byte huge * hptr; - - if (ret != NULL) - { - farfree(ret); - ret = NULL; - } - - if(png_ptr->zlib_window_bits > 14) - num_blocks = (int)(1 << (png_ptr->zlib_window_bits - 14)); - else - num_blocks = 1; - if (png_ptr->zlib_mem_level >= 7) - num_blocks += (int)(1 << (png_ptr->zlib_mem_level - 7)); - else - num_blocks++; - - total_size = ((png_uint_32)65536L) * (png_uint_32)num_blocks+16; - - table = farmalloc(total_size); - - if (table == NULL) - { -#ifndef PNG_USER_MEM_SUPPORTED - if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out Of Memory."); /* Note "O" and "M" */ - else - png_warning(png_ptr, "Out Of Memory."); -#endif - return (NULL); - } - - if ((png_size_t)table & 0xfff0) - { -#ifndef PNG_USER_MEM_SUPPORTED - if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, - "Farmalloc didn't return normalized pointer"); - else - png_warning(png_ptr, - "Farmalloc didn't return normalized pointer"); -#endif - return (NULL); - } - - png_ptr->offset_table = table; - png_ptr->offset_table_ptr = farmalloc(num_blocks * - png_sizeof (png_bytep)); - - if (png_ptr->offset_table_ptr == NULL) - { -#ifndef PNG_USER_MEM_SUPPORTED - if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out Of memory."); /* Note "O" and "M" */ - else - png_warning(png_ptr, "Out Of memory."); -#endif - return (NULL); - } - - hptr = (png_byte huge *)table; - if ((png_size_t)hptr & 0xf) - { - hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L); - hptr = hptr + 16L; /* "hptr += 16L" fails on Turbo C++ 3.0 */ - } - for (i = 0; i < num_blocks; i++) - { - png_ptr->offset_table_ptr[i] = (png_bytep)hptr; - hptr = hptr + (png_uint_32)65536L; /* "+=" fails on TC++3.0 */ - } - - png_ptr->offset_table_number = num_blocks; - png_ptr->offset_table_count = 0; - png_ptr->offset_table_count_free = 0; - } - } - - if (png_ptr->offset_table_count >= png_ptr->offset_table_number) - { -#ifndef PNG_USER_MEM_SUPPORTED - if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out of Memory."); /* Note "o" and "M" */ - else - png_warning(png_ptr, "Out of Memory."); -#endif - return (NULL); - } - - ret = png_ptr->offset_table_ptr[png_ptr->offset_table_count++]; - } - else - ret = farmalloc(size); - -#ifndef PNG_USER_MEM_SUPPORTED - if (ret == NULL) - { - if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out of memory."); /* Note "o" and "m" */ - else - png_warning(png_ptr, "Out of memory."); /* Note "o" and "m" */ - } -#endif - - return (ret); -} - -/* free a pointer allocated by png_malloc(). In the default - configuration, png_ptr is not used, but is passed in case it - is needed. If ptr is NULL, return without taking any action. */ -void PNGAPI -png_free(png_structp png_ptr, png_voidp ptr) -{ - if (png_ptr == NULL || ptr == NULL) - return; - -#ifdef PNG_USER_MEM_SUPPORTED - if (png_ptr->free_fn != NULL) - { - (*(png_ptr->free_fn))(png_ptr, ptr); - return; - } - else png_free_default(png_ptr, ptr); -} - -void PNGAPI -png_free_default(png_structp png_ptr, png_voidp ptr) -{ -#endif /* PNG_USER_MEM_SUPPORTED */ - - if(png_ptr == NULL) return; - - if (png_ptr->offset_table != NULL) - { - int i; - - for (i = 0; i < png_ptr->offset_table_count; i++) - { - if (ptr == png_ptr->offset_table_ptr[i]) - { - ptr = NULL; - png_ptr->offset_table_count_free++; - break; - } - } - if (png_ptr->offset_table_count_free == png_ptr->offset_table_count) - { - farfree(png_ptr->offset_table); - farfree(png_ptr->offset_table_ptr); - png_ptr->offset_table = NULL; - png_ptr->offset_table_ptr = NULL; - } - } - - if (ptr != NULL) - { - farfree(ptr); - } -} - -#else /* Not the Borland DOS special memory handler */ - -/* Allocate memory for a png_struct or a png_info. The malloc and - memset can be replaced by a single call to calloc() if this is thought - to improve performance noticably. */ -png_voidp /* PRIVATE */ -png_create_struct(int type) -{ -#ifdef PNG_USER_MEM_SUPPORTED - return (png_create_struct_2(type, png_malloc_ptr_NULL, png_voidp_NULL)); -} - -/* Allocate memory for a png_struct or a png_info. The malloc and - memset can be replaced by a single call to calloc() if this is thought - to improve performance noticably. */ -png_voidp /* PRIVATE */ -png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr) -{ -#endif /* PNG_USER_MEM_SUPPORTED */ - png_size_t size; - png_voidp struct_ptr; - - if (type == PNG_STRUCT_INFO) - size = png_sizeof(png_info); - else if (type == PNG_STRUCT_PNG) - size = png_sizeof(png_struct); - else - return (NULL); - -#ifdef PNG_USER_MEM_SUPPORTED - if(malloc_fn != NULL) - { - png_struct dummy_struct; - png_structp png_ptr = &dummy_struct; - png_ptr->mem_ptr=mem_ptr; - struct_ptr = (*(malloc_fn))(png_ptr, size); - if (struct_ptr != NULL) - png_memset(struct_ptr, 0, size); - return (struct_ptr); - } -#endif /* PNG_USER_MEM_SUPPORTED */ - -#if defined(__TURBOC__) && !defined(__FLAT__) - struct_ptr = (png_voidp)farmalloc(size); -#else -# if defined(_MSC_VER) && defined(MAXSEG_64K) - struct_ptr = (png_voidp)halloc(size,1); -# else - struct_ptr = (png_voidp)malloc(size); -# endif -#endif - if (struct_ptr != NULL) - png_memset(struct_ptr, 0, size); - - return (struct_ptr); -} - - -/* Free memory allocated by a png_create_struct() call */ -void /* PRIVATE */ -png_destroy_struct(png_voidp struct_ptr) -{ -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2(struct_ptr, png_free_ptr_NULL, png_voidp_NULL); -} - -/* Free memory allocated by a png_create_struct() call */ -void /* PRIVATE */ -png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, - png_voidp mem_ptr) -{ -#endif /* PNG_USER_MEM_SUPPORTED */ - if (struct_ptr != NULL) - { -#ifdef PNG_USER_MEM_SUPPORTED - if(free_fn != NULL) - { - png_struct dummy_struct; - png_structp png_ptr = &dummy_struct; - png_ptr->mem_ptr=mem_ptr; - (*(free_fn))(png_ptr, struct_ptr); - return; - } -#endif /* PNG_USER_MEM_SUPPORTED */ -#if defined(__TURBOC__) && !defined(__FLAT__) - farfree(struct_ptr); -#else -# if defined(_MSC_VER) && defined(MAXSEG_64K) - hfree(struct_ptr); -# else - free(struct_ptr); -# endif -#endif - } -} - -/* Allocate memory. For reasonable files, size should never exceed - 64K. However, zlib may allocate more then 64K if you don't tell - it not to. See zconf.h and png.h for more information. zlib does - need to allocate exactly 64K, so whatever you call here must - have the ability to do that. */ - -png_voidp PNGAPI -png_malloc(png_structp png_ptr, png_uint_32 size) -{ - png_voidp ret; - -#ifdef PNG_USER_MEM_SUPPORTED - if (png_ptr == NULL || size == 0) - return (NULL); - - if(png_ptr->malloc_fn != NULL) - ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size)); - else - ret = (png_malloc_default(png_ptr, size)); - if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out of Memory!"); - return (ret); -} - -png_voidp PNGAPI -png_malloc_default(png_structp png_ptr, png_uint_32 size) -{ - png_voidp ret; -#endif /* PNG_USER_MEM_SUPPORTED */ - - if (png_ptr == NULL || size == 0) - return (NULL); - -#ifdef PNG_MAX_MALLOC_64K - if (size > (png_uint_32)65536L) - { -#ifndef PNG_USER_MEM_SUPPORTED - if(png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Cannot Allocate > 64K"); - else -#endif - return NULL; - } -#endif - - /* Check for overflow */ -#if defined(__TURBOC__) && !defined(__FLAT__) - if (size != (unsigned long)size) - ret = NULL; - else - ret = farmalloc(size); -#else -# if defined(_MSC_VER) && defined(MAXSEG_64K) - if (size != (unsigned long)size) - ret = NULL; - else - ret = halloc(size, 1); -# else - if (size != (size_t)size) - ret = NULL; - else - ret = malloc((size_t)size); -# endif -#endif - -#ifndef PNG_USER_MEM_SUPPORTED - if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out of Memory"); -#endif - - return (ret); -} - -/* Free a pointer allocated by png_malloc(). If ptr is NULL, return - without taking any action. */ -void PNGAPI -png_free(png_structp png_ptr, png_voidp ptr) -{ - if (png_ptr == NULL || ptr == NULL) - return; - -#ifdef PNG_USER_MEM_SUPPORTED - if (png_ptr->free_fn != NULL) - { - (*(png_ptr->free_fn))(png_ptr, ptr); - return; - } - else png_free_default(png_ptr, ptr); -} -void PNGAPI -png_free_default(png_structp png_ptr, png_voidp ptr) -{ - if (png_ptr == NULL || ptr == NULL) - return; - -#endif /* PNG_USER_MEM_SUPPORTED */ - -#if defined(__TURBOC__) && !defined(__FLAT__) - farfree(ptr); -#else -# if defined(_MSC_VER) && defined(MAXSEG_64K) - hfree(ptr); -# else - free(ptr); -# endif -#endif -} - -#endif /* Not Borland DOS special memory handler */ - -#if defined(PNG_1_0_X) -# define png_malloc_warn png_malloc -#else -/* This function was added at libpng version 1.2.3. The png_malloc_warn() - * function will set up png_malloc() to issue a png_warning and return NULL - * instead of issuing a png_error, if it fails to allocate the requested - * memory. - */ -png_voidp PNGAPI -png_malloc_warn(png_structp png_ptr, png_uint_32 size) -{ - png_voidp ptr; - png_uint_32 save_flags; - if(png_ptr == NULL) return (NULL); - - save_flags=png_ptr->flags; - png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK; - ptr = (png_voidp)png_malloc((png_structp)png_ptr, size); - png_ptr->flags=save_flags; - return(ptr); -} -#endif - -png_voidp PNGAPI -png_memcpy_check (png_structp png_ptr, png_voidp s1, png_voidp s2, - png_uint_32 length) -{ - png_size_t size; - - size = (png_size_t)length; - if ((png_uint_32)size != length) - png_error(png_ptr,"Overflow in png_memcpy_check."); - - return(png_memcpy (s1, s2, size)); -} - -png_voidp PNGAPI -png_memset_check (png_structp png_ptr, png_voidp s1, int value, - png_uint_32 length) -{ - png_size_t size; - - size = (png_size_t)length; - if ((png_uint_32)size != length) - png_error(png_ptr,"Overflow in png_memset_check."); - - return (png_memset (s1, value, size)); - -} - -#ifdef PNG_USER_MEM_SUPPORTED -/* This function is called when the application wants to use another method - * of allocating and freeing memory. - */ -void PNGAPI -png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr - malloc_fn, png_free_ptr free_fn) -{ - if(png_ptr != NULL) { - png_ptr->mem_ptr = mem_ptr; - png_ptr->malloc_fn = malloc_fn; - png_ptr->free_fn = free_fn; - } -} - -/* This function returns a pointer to the mem_ptr associated with the user - * functions. The application should free any memory associated with this - * pointer before png_write_destroy and png_read_destroy are called. - */ -png_voidp PNGAPI -png_get_mem_ptr(png_structp png_ptr) -{ - if(png_ptr == NULL) return (NULL); - return ((png_voidp)png_ptr->mem_ptr); -} -#endif /* PNG_USER_MEM_SUPPORTED */ -#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng_osx/pngpread.c b/irrlicht-1.6/source/Irrlicht/libpng_osx/pngpread.c deleted file mode 100644 index d226c75d3..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng_osx/pngpread.c +++ /dev/null @@ -1,1584 +0,0 @@ - -/* pngpread.c - read a png file in push mode - * - * Last changed in libpng 1.2.13 November 13, 2006 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2006 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -#define PNG_INTERNAL -#include "png.h" - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED - -/* push model modes */ -#define PNG_READ_SIG_MODE 0 -#define PNG_READ_CHUNK_MODE 1 -#define PNG_READ_IDAT_MODE 2 -#define PNG_SKIP_MODE 3 -#define PNG_READ_tEXt_MODE 4 -#define PNG_READ_zTXt_MODE 5 -#define PNG_READ_DONE_MODE 6 -#define PNG_READ_iTXt_MODE 7 -#define PNG_ERROR_MODE 8 - -void PNGAPI -png_process_data(png_structp png_ptr, png_infop info_ptr, - png_bytep buffer, png_size_t buffer_size) -{ - if(png_ptr == NULL) return; - png_push_restore_buffer(png_ptr, buffer, buffer_size); - - while (png_ptr->buffer_size) - { - png_process_some_data(png_ptr, info_ptr); - } -} - -/* What we do with the incoming data depends on what we were previously - * doing before we ran out of data... - */ -void /* PRIVATE */ -png_process_some_data(png_structp png_ptr, png_infop info_ptr) -{ - if(png_ptr == NULL) return; - switch (png_ptr->process_mode) - { - case PNG_READ_SIG_MODE: - { - png_push_read_sig(png_ptr, info_ptr); - break; - } - case PNG_READ_CHUNK_MODE: - { - png_push_read_chunk(png_ptr, info_ptr); - break; - } - case PNG_READ_IDAT_MODE: - { - png_push_read_IDAT(png_ptr); - break; - } -#if defined(PNG_READ_tEXt_SUPPORTED) - case PNG_READ_tEXt_MODE: - { - png_push_read_tEXt(png_ptr, info_ptr); - break; - } -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - case PNG_READ_zTXt_MODE: - { - png_push_read_zTXt(png_ptr, info_ptr); - break; - } -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - case PNG_READ_iTXt_MODE: - { - png_push_read_iTXt(png_ptr, info_ptr); - break; - } -#endif - case PNG_SKIP_MODE: - { - png_push_crc_finish(png_ptr); - break; - } - default: - { - png_ptr->buffer_size = 0; - break; - } - } -} - -/* Read any remaining signature bytes from the stream and compare them with - * the correct PNG signature. It is possible that this routine is called - * with bytes already read from the signature, either because they have been - * checked by the calling application, or because of multiple calls to this - * routine. - */ -void /* PRIVATE */ -png_push_read_sig(png_structp png_ptr, png_infop info_ptr) -{ - png_size_t num_checked = png_ptr->sig_bytes, - num_to_check = 8 - num_checked; - - if (png_ptr->buffer_size < num_to_check) - { - num_to_check = png_ptr->buffer_size; - } - - png_push_fill_buffer(png_ptr, &(info_ptr->signature[num_checked]), - num_to_check); - png_ptr->sig_bytes = (png_byte)(png_ptr->sig_bytes+num_to_check); - - if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check)) - { - if (num_checked < 4 && - png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4)) - png_error(png_ptr, "Not a PNG file"); - else - png_error(png_ptr, "PNG file corrupted by ASCII conversion"); - } - else - { - if (png_ptr->sig_bytes >= 8) - { - png_ptr->process_mode = PNG_READ_CHUNK_MODE; - } - } -} - -void /* PRIVATE */ -png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IHDR; - PNG_IDAT; - PNG_IEND; - PNG_PLTE; -#if defined(PNG_READ_bKGD_SUPPORTED) - PNG_bKGD; -#endif -#if defined(PNG_READ_cHRM_SUPPORTED) - PNG_cHRM; -#endif -#if defined(PNG_READ_gAMA_SUPPORTED) - PNG_gAMA; -#endif -#if defined(PNG_READ_hIST_SUPPORTED) - PNG_hIST; -#endif -#if defined(PNG_READ_iCCP_SUPPORTED) - PNG_iCCP; -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - PNG_iTXt; -#endif -#if defined(PNG_READ_oFFs_SUPPORTED) - PNG_oFFs; -#endif -#if defined(PNG_READ_pCAL_SUPPORTED) - PNG_pCAL; -#endif -#if defined(PNG_READ_pHYs_SUPPORTED) - PNG_pHYs; -#endif -#if defined(PNG_READ_sBIT_SUPPORTED) - PNG_sBIT; -#endif -#if defined(PNG_READ_sCAL_SUPPORTED) - PNG_sCAL; -#endif -#if defined(PNG_READ_sRGB_SUPPORTED) - PNG_sRGB; -#endif -#if defined(PNG_READ_sPLT_SUPPORTED) - PNG_sPLT; -#endif -#if defined(PNG_READ_tEXt_SUPPORTED) - PNG_tEXt; -#endif -#if defined(PNG_READ_tIME_SUPPORTED) - PNG_tIME; -#endif -#if defined(PNG_READ_tRNS_SUPPORTED) - PNG_tRNS; -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - PNG_zTXt; -#endif -#endif /* PNG_USE_LOCAL_ARRAYS */ - /* First we make sure we have enough data for the 4 byte chunk name - * and the 4 byte chunk length before proceeding with decoding the - * chunk data. To fully decode each of these chunks, we also make - * sure we have enough data in the buffer for the 4 byte CRC at the - * end of every chunk (except IDAT, which is handled separately). - */ - if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER)) - { - png_byte chunk_length[4]; - - if (png_ptr->buffer_size < 8) - { - png_push_save_buffer(png_ptr); - return; - } - - png_push_fill_buffer(png_ptr, chunk_length, 4); - png_ptr->push_length = png_get_uint_31(png_ptr,chunk_length); - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); - png_ptr->mode |= PNG_HAVE_CHUNK_HEADER; - } - - if (!png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) - if(png_ptr->mode & PNG_AFTER_IDAT) - png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT; - - if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_IHDR(png_ptr, info_ptr, png_ptr->push_length); - } - else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_IEND(png_ptr, info_ptr, png_ptr->push_length); - - png_ptr->process_mode = PNG_READ_DONE_MODE; - png_push_have_end(png_ptr, info_ptr); - } -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED - else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - png_ptr->mode |= PNG_HAVE_IDAT; - png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length); - if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) - png_ptr->mode |= PNG_HAVE_PLTE; - else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - { - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before IDAT"); - else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - !(png_ptr->mode & PNG_HAVE_PLTE)) - png_error(png_ptr, "Missing PLTE before IDAT"); - } - } -#endif - else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_PLTE(png_ptr, info_ptr, png_ptr->push_length); - } - else if (!png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) - { - /* If we reach an IDAT chunk, this means we have read all of the - * header chunks, and we can start reading the image (or if this - * is called after the image has been read - we have an error). - */ - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before IDAT"); - else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - !(png_ptr->mode & PNG_HAVE_PLTE)) - png_error(png_ptr, "Missing PLTE before IDAT"); - - if (png_ptr->mode & PNG_HAVE_IDAT) - { - if (!(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT)) - if (png_ptr->push_length == 0) - return; - - if (png_ptr->mode & PNG_AFTER_IDAT) - png_error(png_ptr, "Too many IDAT's found"); - } - - png_ptr->idat_size = png_ptr->push_length; - png_ptr->mode |= PNG_HAVE_IDAT; - png_ptr->process_mode = PNG_READ_IDAT_MODE; - png_push_have_info(png_ptr, info_ptr); - png_ptr->zstream.avail_out = (uInt)png_ptr->irowbytes; - png_ptr->zstream.next_out = png_ptr->row_buf; - return; - } -#if defined(PNG_READ_gAMA_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_gAMA(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_sBIT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_sBIT(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_cHRM_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_cHRM(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_sRGB_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_sRGB(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_iCCP_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_iCCP(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_sPLT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_sPLT(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_tRNS_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_tRNS(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_bKGD_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_bKGD(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_hIST_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_hIST(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_pHYs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_pHYs(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_oFFs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_oFFs(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_pCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_pCAL(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_sCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_sCAL(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_tIME_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_handle_tIME(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_tEXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_push_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_push_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_push_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length); - } -#endif - else - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - png_push_handle_unknown(png_ptr, info_ptr, png_ptr->push_length); - } - - png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER; -} - -void /* PRIVATE */ -png_push_crc_skip(png_structp png_ptr, png_uint_32 skip) -{ - png_ptr->process_mode = PNG_SKIP_MODE; - png_ptr->skip_length = skip; -} - -void /* PRIVATE */ -png_push_crc_finish(png_structp png_ptr) -{ - if (png_ptr->skip_length && png_ptr->save_buffer_size) - { - png_size_t save_size; - - if (png_ptr->skip_length < (png_uint_32)png_ptr->save_buffer_size) - save_size = (png_size_t)png_ptr->skip_length; - else - save_size = png_ptr->save_buffer_size; - - png_calculate_crc(png_ptr, png_ptr->save_buffer_ptr, save_size); - - png_ptr->skip_length -= save_size; - png_ptr->buffer_size -= save_size; - png_ptr->save_buffer_size -= save_size; - png_ptr->save_buffer_ptr += save_size; - } - if (png_ptr->skip_length && png_ptr->current_buffer_size) - { - png_size_t save_size; - - if (png_ptr->skip_length < (png_uint_32)png_ptr->current_buffer_size) - save_size = (png_size_t)png_ptr->skip_length; - else - save_size = png_ptr->current_buffer_size; - - png_calculate_crc(png_ptr, png_ptr->current_buffer_ptr, save_size); - - png_ptr->skip_length -= save_size; - png_ptr->buffer_size -= save_size; - png_ptr->current_buffer_size -= save_size; - png_ptr->current_buffer_ptr += save_size; - } - if (!png_ptr->skip_length) - { - if (png_ptr->buffer_size < 4) - { - png_push_save_buffer(png_ptr); - return; - } - - png_crc_finish(png_ptr, 0); - png_ptr->process_mode = PNG_READ_CHUNK_MODE; - } -} - -void PNGAPI -png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length) -{ - png_bytep ptr; - - if(png_ptr == NULL) return; - ptr = buffer; - if (png_ptr->save_buffer_size) - { - png_size_t save_size; - - if (length < png_ptr->save_buffer_size) - save_size = length; - else - save_size = png_ptr->save_buffer_size; - - png_memcpy(ptr, png_ptr->save_buffer_ptr, save_size); - length -= save_size; - ptr += save_size; - png_ptr->buffer_size -= save_size; - png_ptr->save_buffer_size -= save_size; - png_ptr->save_buffer_ptr += save_size; - } - if (length && png_ptr->current_buffer_size) - { - png_size_t save_size; - - if (length < png_ptr->current_buffer_size) - save_size = length; - else - save_size = png_ptr->current_buffer_size; - - png_memcpy(ptr, png_ptr->current_buffer_ptr, save_size); - png_ptr->buffer_size -= save_size; - png_ptr->current_buffer_size -= save_size; - png_ptr->current_buffer_ptr += save_size; - } -} - -void /* PRIVATE */ -png_push_save_buffer(png_structp png_ptr) -{ - if (png_ptr->save_buffer_size) - { - if (png_ptr->save_buffer_ptr != png_ptr->save_buffer) - { - png_size_t i,istop; - png_bytep sp; - png_bytep dp; - - istop = png_ptr->save_buffer_size; - for (i = 0, sp = png_ptr->save_buffer_ptr, dp = png_ptr->save_buffer; - i < istop; i++, sp++, dp++) - { - *dp = *sp; - } - } - } - if (png_ptr->save_buffer_size + png_ptr->current_buffer_size > - png_ptr->save_buffer_max) - { - png_size_t new_max; - png_bytep old_buffer; - - if (png_ptr->save_buffer_size > PNG_SIZE_MAX - - (png_ptr->current_buffer_size + 256)) - { - png_error(png_ptr, "Potential overflow of save_buffer"); - } - new_max = png_ptr->save_buffer_size + png_ptr->current_buffer_size + 256; - old_buffer = png_ptr->save_buffer; - png_ptr->save_buffer = (png_bytep)png_malloc(png_ptr, - (png_uint_32)new_max); - png_memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size); - png_free(png_ptr, old_buffer); - png_ptr->save_buffer_max = new_max; - } - if (png_ptr->current_buffer_size) - { - png_memcpy(png_ptr->save_buffer + png_ptr->save_buffer_size, - png_ptr->current_buffer_ptr, png_ptr->current_buffer_size); - png_ptr->save_buffer_size += png_ptr->current_buffer_size; - png_ptr->current_buffer_size = 0; - } - png_ptr->save_buffer_ptr = png_ptr->save_buffer; - png_ptr->buffer_size = 0; -} - -void /* PRIVATE */ -png_push_restore_buffer(png_structp png_ptr, png_bytep buffer, - png_size_t buffer_length) -{ - png_ptr->current_buffer = buffer; - png_ptr->current_buffer_size = buffer_length; - png_ptr->buffer_size = buffer_length + png_ptr->save_buffer_size; - png_ptr->current_buffer_ptr = png_ptr->current_buffer; -} - -void /* PRIVATE */ -png_push_read_IDAT(png_structp png_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IDAT; -#endif - if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER)) - { - png_byte chunk_length[4]; - - if (png_ptr->buffer_size < 8) - { - png_push_save_buffer(png_ptr); - return; - } - - png_push_fill_buffer(png_ptr, chunk_length, 4); - png_ptr->push_length = png_get_uint_31(png_ptr,chunk_length); - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); - png_ptr->mode |= PNG_HAVE_CHUNK_HEADER; - - if (png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) - { - png_ptr->process_mode = PNG_READ_CHUNK_MODE; - if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) - png_error(png_ptr, "Not enough compressed data"); - return; - } - - png_ptr->idat_size = png_ptr->push_length; - } - if (png_ptr->idat_size && png_ptr->save_buffer_size) - { - png_size_t save_size; - - if (png_ptr->idat_size < (png_uint_32)png_ptr->save_buffer_size) - { - save_size = (png_size_t)png_ptr->idat_size; - /* check for overflow */ - if((png_uint_32)save_size != png_ptr->idat_size) - png_error(png_ptr, "save_size overflowed in pngpread"); - } - else - save_size = png_ptr->save_buffer_size; - - png_calculate_crc(png_ptr, png_ptr->save_buffer_ptr, save_size); - if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) - png_process_IDAT_data(png_ptr, png_ptr->save_buffer_ptr, save_size); - png_ptr->idat_size -= save_size; - png_ptr->buffer_size -= save_size; - png_ptr->save_buffer_size -= save_size; - png_ptr->save_buffer_ptr += save_size; - } - if (png_ptr->idat_size && png_ptr->current_buffer_size) - { - png_size_t save_size; - - if (png_ptr->idat_size < (png_uint_32)png_ptr->current_buffer_size) - { - save_size = (png_size_t)png_ptr->idat_size; - /* check for overflow */ - if((png_uint_32)save_size != png_ptr->idat_size) - png_error(png_ptr, "save_size overflowed in pngpread"); - } - else - save_size = png_ptr->current_buffer_size; - - png_calculate_crc(png_ptr, png_ptr->current_buffer_ptr, save_size); - if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) - png_process_IDAT_data(png_ptr, png_ptr->current_buffer_ptr, save_size); - - png_ptr->idat_size -= save_size; - png_ptr->buffer_size -= save_size; - png_ptr->current_buffer_size -= save_size; - png_ptr->current_buffer_ptr += save_size; - } - if (!png_ptr->idat_size) - { - if (png_ptr->buffer_size < 4) - { - png_push_save_buffer(png_ptr); - return; - } - - png_crc_finish(png_ptr, 0); - png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER; - png_ptr->mode |= PNG_AFTER_IDAT; - } -} - -void /* PRIVATE */ -png_process_IDAT_data(png_structp png_ptr, png_bytep buffer, - png_size_t buffer_length) -{ - int ret; - - if ((png_ptr->flags & PNG_FLAG_ZLIB_FINISHED) && buffer_length) - png_error(png_ptr, "Extra compression data"); - - png_ptr->zstream.next_in = buffer; - png_ptr->zstream.avail_in = (uInt)buffer_length; - for(;;) - { - ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); - if (ret != Z_OK) - { - if (ret == Z_STREAM_END) - { - if (png_ptr->zstream.avail_in) - png_error(png_ptr, "Extra compressed data"); - if (!(png_ptr->zstream.avail_out)) - { - png_push_process_row(png_ptr); - } - - png_ptr->mode |= PNG_AFTER_IDAT; - png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; - break; - } - else if (ret == Z_BUF_ERROR) - break; - else - png_error(png_ptr, "Decompression Error"); - } - if (!(png_ptr->zstream.avail_out)) - { - if (( -#if defined(PNG_READ_INTERLACING_SUPPORTED) - png_ptr->interlaced && png_ptr->pass > 6) || - (!png_ptr->interlaced && -#endif - png_ptr->row_number == png_ptr->num_rows)) - { - if (png_ptr->zstream.avail_in) - png_warning(png_ptr, "Too much data in IDAT chunks"); - png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; - break; - } - png_push_process_row(png_ptr); - png_ptr->zstream.avail_out = (uInt)png_ptr->irowbytes; - png_ptr->zstream.next_out = png_ptr->row_buf; - } - else - break; - } -} - -void /* PRIVATE */ -png_push_process_row(png_structp png_ptr) -{ - png_ptr->row_info.color_type = png_ptr->color_type; - png_ptr->row_info.width = png_ptr->iwidth; - png_ptr->row_info.channels = png_ptr->channels; - png_ptr->row_info.bit_depth = png_ptr->bit_depth; - png_ptr->row_info.pixel_depth = png_ptr->pixel_depth; - - png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth, - png_ptr->row_info.width); - - png_read_filter_row(png_ptr, &(png_ptr->row_info), - png_ptr->row_buf + 1, png_ptr->prev_row + 1, - (int)(png_ptr->row_buf[0])); - - png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf, - png_ptr->rowbytes + 1); - - if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA)) - png_do_read_transformations(png_ptr); - -#if defined(PNG_READ_INTERLACING_SUPPORTED) - /* blow up interlaced rows to full size */ - if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) - { - if (png_ptr->pass < 6) -/* old interface (pre-1.0.9): - png_do_read_interlace(&(png_ptr->row_info), - png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations); - */ - png_do_read_interlace(png_ptr); - - switch (png_ptr->pass) - { - case 0: - { - int i; - for (i = 0; i < 8 && png_ptr->pass == 0; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); /* updates png_ptr->pass */ - } - if (png_ptr->pass == 2) /* pass 1 might be empty */ - { - for (i = 0; i < 4 && png_ptr->pass == 2; i++) - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - } - if (png_ptr->pass == 4 && png_ptr->height <= 4) - { - for (i = 0; i < 2 && png_ptr->pass == 4; i++) - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - } - if (png_ptr->pass == 6 && png_ptr->height <= 4) - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - break; - } - case 1: - { - int i; - for (i = 0; i < 8 && png_ptr->pass == 1; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } - if (png_ptr->pass == 2) /* skip top 4 generated rows */ - { - for (i = 0; i < 4 && png_ptr->pass == 2; i++) - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - } - break; - } - case 2: - { - int i; - for (i = 0; i < 4 && png_ptr->pass == 2; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } - for (i = 0; i < 4 && png_ptr->pass == 2; i++) - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - if (png_ptr->pass == 4) /* pass 3 might be empty */ - { - for (i = 0; i < 2 && png_ptr->pass == 4; i++) - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - } - break; - } - case 3: - { - int i; - for (i = 0; i < 4 && png_ptr->pass == 3; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } - if (png_ptr->pass == 4) /* skip top two generated rows */ - { - for (i = 0; i < 2 && png_ptr->pass == 4; i++) - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - } - break; - } - case 4: - { - int i; - for (i = 0; i < 2 && png_ptr->pass == 4; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } - for (i = 0; i < 2 && png_ptr->pass == 4; i++) - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - if (png_ptr->pass == 6) /* pass 5 might be empty */ - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - break; - } - case 5: - { - int i; - for (i = 0; i < 2 && png_ptr->pass == 5; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } - if (png_ptr->pass == 6) /* skip top generated row */ - { - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - break; - } - case 6: - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - if (png_ptr->pass != 6) - break; - png_push_have_row(png_ptr, png_bytep_NULL); - png_read_push_finish_row(png_ptr); - } - } - } - else -#endif - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } -} - -void /* PRIVATE */ -png_read_push_finish_row(png_structp png_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* start of interlace block */ - const int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; - - /* offset to next interlace block */ - const int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; - - /* start of interlace block in the y direction */ - const int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; - - /* offset to next interlace block in the y direction */ - const int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; - - /* Width of interlace block. This is not currently used - if you need - * it, uncomment it here and in png.h - const int FARDATA png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; - */ - - /* Height of interlace block. This is not currently used - if you need - * it, uncomment it here and in png.h - const int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1}; - */ -#endif - - png_ptr->row_number++; - if (png_ptr->row_number < png_ptr->num_rows) - return; - - if (png_ptr->interlaced) - { - png_ptr->row_number = 0; - png_memset_check(png_ptr, png_ptr->prev_row, 0, - png_ptr->rowbytes + 1); - do - { - png_ptr->pass++; - if ((png_ptr->pass == 1 && png_ptr->width < 5) || - (png_ptr->pass == 3 && png_ptr->width < 3) || - (png_ptr->pass == 5 && png_ptr->width < 2)) - png_ptr->pass++; - - if (png_ptr->pass > 7) - png_ptr->pass--; - if (png_ptr->pass >= 7) - break; - - png_ptr->iwidth = (png_ptr->width + - png_pass_inc[png_ptr->pass] - 1 - - png_pass_start[png_ptr->pass]) / - png_pass_inc[png_ptr->pass]; - - png_ptr->irowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, - png_ptr->iwidth) + 1; - - if (png_ptr->transformations & PNG_INTERLACE) - break; - - png_ptr->num_rows = (png_ptr->height + - png_pass_yinc[png_ptr->pass] - 1 - - png_pass_ystart[png_ptr->pass]) / - png_pass_yinc[png_ptr->pass]; - - } while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0); - } -} - -#if defined(PNG_READ_tEXt_SUPPORTED) -void /* PRIVATE */ -png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 - length) -{ - if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) - { - png_error(png_ptr, "Out of place tEXt"); - /* to quiet some compiler warnings */ - if(info_ptr == NULL) return; - } - -#ifdef PNG_MAX_MALLOC_64K - png_ptr->skip_length = 0; /* This may not be necessary */ - - if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */ - { - png_warning(png_ptr, "tEXt chunk too large to fit in memory"); - png_ptr->skip_length = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - - png_ptr->current_text = (png_charp)png_malloc(png_ptr, - (png_uint_32)(length+1)); - png_ptr->current_text[length] = '\0'; - png_ptr->current_text_ptr = png_ptr->current_text; - png_ptr->current_text_size = (png_size_t)length; - png_ptr->current_text_left = (png_size_t)length; - png_ptr->process_mode = PNG_READ_tEXt_MODE; -} - -void /* PRIVATE */ -png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr->buffer_size && png_ptr->current_text_left) - { - png_size_t text_size; - - if (png_ptr->buffer_size < png_ptr->current_text_left) - text_size = png_ptr->buffer_size; - else - text_size = png_ptr->current_text_left; - png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size); - png_ptr->current_text_left -= text_size; - png_ptr->current_text_ptr += text_size; - } - if (!(png_ptr->current_text_left)) - { - png_textp text_ptr; - png_charp text; - png_charp key; - int ret; - - if (png_ptr->buffer_size < 4) - { - png_push_save_buffer(png_ptr); - return; - } - - png_push_crc_finish(png_ptr); - -#if defined(PNG_MAX_MALLOC_64K) - if (png_ptr->skip_length) - return; -#endif - - key = png_ptr->current_text; - - for (text = key; *text; text++) - /* empty loop */ ; - - if (text != key + png_ptr->current_text_size) - text++; - - text_ptr = (png_textp)png_malloc(png_ptr, - (png_uint_32)png_sizeof(png_text)); - text_ptr->compression = PNG_TEXT_COMPRESSION_NONE; - text_ptr->key = key; -#ifdef PNG_iTXt_SUPPORTED - text_ptr->lang = NULL; - text_ptr->lang_key = NULL; -#endif - text_ptr->text = text; - - ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1); - - png_free(png_ptr, key); - png_free(png_ptr, text_ptr); - png_ptr->current_text = NULL; - - if (ret) - png_warning(png_ptr, "Insufficient memory to store text chunk."); - } -} -#endif - -#if defined(PNG_READ_zTXt_SUPPORTED) -void /* PRIVATE */ -png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 - length) -{ - if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) - { - png_error(png_ptr, "Out of place zTXt"); - /* to quiet some compiler warnings */ - if(info_ptr == NULL) return; - } - -#ifdef PNG_MAX_MALLOC_64K - /* We can't handle zTXt chunks > 64K, since we don't have enough space - * to be able to store the uncompressed data. Actually, the threshold - * is probably around 32K, but it isn't as definite as 64K is. - */ - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr, "zTXt chunk too large to fit in memory"); - png_push_crc_skip(png_ptr, length); - return; - } -#endif - - png_ptr->current_text = (png_charp)png_malloc(png_ptr, - (png_uint_32)(length+1)); - png_ptr->current_text[length] = '\0'; - png_ptr->current_text_ptr = png_ptr->current_text; - png_ptr->current_text_size = (png_size_t)length; - png_ptr->current_text_left = (png_size_t)length; - png_ptr->process_mode = PNG_READ_zTXt_MODE; -} - -void /* PRIVATE */ -png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr->buffer_size && png_ptr->current_text_left) - { - png_size_t text_size; - - if (png_ptr->buffer_size < (png_uint_32)png_ptr->current_text_left) - text_size = png_ptr->buffer_size; - else - text_size = png_ptr->current_text_left; - png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size); - png_ptr->current_text_left -= text_size; - png_ptr->current_text_ptr += text_size; - } - if (!(png_ptr->current_text_left)) - { - png_textp text_ptr; - png_charp text; - png_charp key; - int ret; - png_size_t text_size, key_size; - - if (png_ptr->buffer_size < 4) - { - png_push_save_buffer(png_ptr); - return; - } - - png_push_crc_finish(png_ptr); - - key = png_ptr->current_text; - - for (text = key; *text; text++) - /* empty loop */ ; - - /* zTXt can't have zero text */ - if (text == key + png_ptr->current_text_size) - { - png_ptr->current_text = NULL; - png_free(png_ptr, key); - return; - } - - text++; - - if (*text != PNG_TEXT_COMPRESSION_zTXt) /* check compression byte */ - { - png_ptr->current_text = NULL; - png_free(png_ptr, key); - return; - } - - text++; - - png_ptr->zstream.next_in = (png_bytep )text; - png_ptr->zstream.avail_in = (uInt)(png_ptr->current_text_size - - (text - key)); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - - key_size = text - key; - text_size = 0; - text = NULL; - ret = Z_STREAM_END; - - while (png_ptr->zstream.avail_in) - { - ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); - if (ret != Z_OK && ret != Z_STREAM_END) - { - inflateReset(&png_ptr->zstream); - png_ptr->zstream.avail_in = 0; - png_ptr->current_text = NULL; - png_free(png_ptr, key); - png_free(png_ptr, text); - return; - } - if (!(png_ptr->zstream.avail_out) || ret == Z_STREAM_END) - { - if (text == NULL) - { - text = (png_charp)png_malloc(png_ptr, - (png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out - + key_size + 1)); - png_memcpy(text + key_size, png_ptr->zbuf, - png_ptr->zbuf_size - png_ptr->zstream.avail_out); - png_memcpy(text, key, key_size); - text_size = key_size + png_ptr->zbuf_size - - png_ptr->zstream.avail_out; - *(text + text_size) = '\0'; - } - else - { - png_charp tmp; - - tmp = text; - text = (png_charp)png_malloc(png_ptr, text_size + - (png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out - + 1)); - png_memcpy(text, tmp, text_size); - png_free(png_ptr, tmp); - png_memcpy(text + text_size, png_ptr->zbuf, - png_ptr->zbuf_size - png_ptr->zstream.avail_out); - text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out; - *(text + text_size) = '\0'; - } - if (ret != Z_STREAM_END) - { - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - } - } - else - { - break; - } - - if (ret == Z_STREAM_END) - break; - } - - inflateReset(&png_ptr->zstream); - png_ptr->zstream.avail_in = 0; - - if (ret != Z_STREAM_END) - { - png_ptr->current_text = NULL; - png_free(png_ptr, key); - png_free(png_ptr, text); - return; - } - - png_ptr->current_text = NULL; - png_free(png_ptr, key); - key = text; - text += key_size; - - text_ptr = (png_textp)png_malloc(png_ptr, - (png_uint_32)png_sizeof(png_text)); - text_ptr->compression = PNG_TEXT_COMPRESSION_zTXt; - text_ptr->key = key; -#ifdef PNG_iTXt_SUPPORTED - text_ptr->lang = NULL; - text_ptr->lang_key = NULL; -#endif - text_ptr->text = text; - - ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1); - - png_free(png_ptr, key); - png_free(png_ptr, text_ptr); - - if (ret) - png_warning(png_ptr, "Insufficient memory to store text chunk."); - } -} -#endif - -#if defined(PNG_READ_iTXt_SUPPORTED) -void /* PRIVATE */ -png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 - length) -{ - if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) - { - png_error(png_ptr, "Out of place iTXt"); - /* to quiet some compiler warnings */ - if(info_ptr == NULL) return; - } - -#ifdef PNG_MAX_MALLOC_64K - png_ptr->skip_length = 0; /* This may not be necessary */ - - if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */ - { - png_warning(png_ptr, "iTXt chunk too large to fit in memory"); - png_ptr->skip_length = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - - png_ptr->current_text = (png_charp)png_malloc(png_ptr, - (png_uint_32)(length+1)); - png_ptr->current_text[length] = '\0'; - png_ptr->current_text_ptr = png_ptr->current_text; - png_ptr->current_text_size = (png_size_t)length; - png_ptr->current_text_left = (png_size_t)length; - png_ptr->process_mode = PNG_READ_iTXt_MODE; -} - -void /* PRIVATE */ -png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr) -{ - - if (png_ptr->buffer_size && png_ptr->current_text_left) - { - png_size_t text_size; - - if (png_ptr->buffer_size < png_ptr->current_text_left) - text_size = png_ptr->buffer_size; - else - text_size = png_ptr->current_text_left; - png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size); - png_ptr->current_text_left -= text_size; - png_ptr->current_text_ptr += text_size; - } - if (!(png_ptr->current_text_left)) - { - png_textp text_ptr; - png_charp key; - int comp_flag; - png_charp lang; - png_charp lang_key; - png_charp text; - int ret; - - if (png_ptr->buffer_size < 4) - { - png_push_save_buffer(png_ptr); - return; - } - - png_push_crc_finish(png_ptr); - -#if defined(PNG_MAX_MALLOC_64K) - if (png_ptr->skip_length) - return; -#endif - - key = png_ptr->current_text; - - for (lang = key; *lang; lang++) - /* empty loop */ ; - - if (lang != key + png_ptr->current_text_size) - lang++; - - comp_flag = *lang++; - lang++; /* skip comp_type, always zero */ - - for (lang_key = lang; *lang_key; lang_key++) - /* empty loop */ ; - lang_key++; /* skip NUL separator */ - - for (text = lang_key; *text; text++) - /* empty loop */ ; - - if (text != key + png_ptr->current_text_size) - text++; - - text_ptr = (png_textp)png_malloc(png_ptr, - (png_uint_32)png_sizeof(png_text)); - text_ptr->compression = comp_flag + 2; - text_ptr->key = key; - text_ptr->lang = lang; - text_ptr->lang_key = lang_key; - text_ptr->text = text; - text_ptr->text_length = 0; - text_ptr->itxt_length = png_strlen(text); - - ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1); - - png_ptr->current_text = NULL; - - png_free(png_ptr, text_ptr); - if (ret) - png_warning(png_ptr, "Insufficient memory to store iTXt chunk."); - } -} -#endif - -/* This function is called when we haven't found a handler for this - * chunk. If there isn't a problem with the chunk itself (ie a bad chunk - * name or a critical chunk), the chunk is (currently) silently ignored. - */ -void /* PRIVATE */ -png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 - length) -{ - png_uint_32 skip=0; - png_check_chunk_name(png_ptr, png_ptr->chunk_name); - - if (!(png_ptr->chunk_name[0] & 0x20)) - { -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != - PNG_HANDLE_CHUNK_ALWAYS -#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) - && png_ptr->read_user_chunk_fn == NULL -#endif - ) -#endif - png_chunk_error(png_ptr, "unknown critical chunk"); - - /* to quiet compiler warnings about unused info_ptr */ - if (info_ptr == NULL) - return; - } - -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - if (png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS) - { - png_unknown_chunk chunk; - -#ifdef PNG_MAX_MALLOC_64K - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr, "unknown chunk too large to fit in memory"); - skip = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - - png_strcpy((png_charp)chunk.name, (png_charp)png_ptr->chunk_name); - chunk.data = (png_bytep)png_malloc(png_ptr, length); - png_crc_read(png_ptr, chunk.data, length); - chunk.size = length; -#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) - if(png_ptr->read_user_chunk_fn != NULL) - { - /* callback to user unknown chunk handler */ - if ((*(png_ptr->read_user_chunk_fn)) (png_ptr, &chunk) <= 0) - { - if (!(png_ptr->chunk_name[0] & 0x20)) - if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != - PNG_HANDLE_CHUNK_ALWAYS) - png_chunk_error(png_ptr, "unknown critical chunk"); - } - png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1); - } - else -#endif - png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1); - png_free(png_ptr, chunk.data); - } - else -#endif - skip=length; - png_push_crc_skip(png_ptr, skip); -} - -void /* PRIVATE */ -png_push_have_info(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr->info_fn != NULL) - (*(png_ptr->info_fn))(png_ptr, info_ptr); -} - -void /* PRIVATE */ -png_push_have_end(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr->end_fn != NULL) - (*(png_ptr->end_fn))(png_ptr, info_ptr); -} - -void /* PRIVATE */ -png_push_have_row(png_structp png_ptr, png_bytep row) -{ - if (png_ptr->row_fn != NULL) - (*(png_ptr->row_fn))(png_ptr, row, png_ptr->row_number, - (int)png_ptr->pass); -} - -void PNGAPI -png_progressive_combine_row (png_structp png_ptr, - png_bytep old_row, png_bytep new_row) -{ - if(png_ptr == NULL) return; -#ifdef PNG_USE_LOCAL_ARRAYS - const int FARDATA png_pass_dsp_mask[7] = - {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; -#endif - if (new_row != NULL) /* new_row must == png_ptr->row_buf here. */ - png_combine_row(png_ptr, old_row, png_pass_dsp_mask[png_ptr->pass]); -} - -void PNGAPI -png_set_progressive_read_fn(png_structp png_ptr, png_voidp progressive_ptr, - png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, - png_progressive_end_ptr end_fn) -{ - if(png_ptr == NULL) return; - png_ptr->info_fn = info_fn; - png_ptr->row_fn = row_fn; - png_ptr->end_fn = end_fn; - - png_set_read_fn(png_ptr, progressive_ptr, png_push_fill_buffer); -} - -png_voidp PNGAPI -png_get_progressive_ptr(png_structp png_ptr) -{ - if(png_ptr == NULL) return (NULL); - return png_ptr->io_ptr; -} -#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng_osx/pngread.c b/irrlicht-1.6/source/Irrlicht/libpng_osx/pngread.c deleted file mode 100644 index 56dac8a80..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng_osx/pngread.c +++ /dev/null @@ -1,1473 +0,0 @@ - -/* pngread.c - read a PNG file - * - * Last changed in libpng 1.2.15 January 5, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This file contains routines that an application calls directly to - * read a PNG file or stream. - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_READ_SUPPORTED) - -/* Create a PNG structure for reading, and allocate any memory needed. */ -png_structp PNGAPI -png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn) -{ - -#ifdef PNG_USER_MEM_SUPPORTED - return (png_create_read_struct_2(user_png_ver, error_ptr, error_fn, - warn_fn, png_voidp_NULL, png_malloc_ptr_NULL, png_free_ptr_NULL)); -} - -/* Alternate create PNG structure for reading, and allocate any memory needed. */ -png_structp PNGAPI -png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn) -{ -#endif /* PNG_USER_MEM_SUPPORTED */ - - png_structp png_ptr; - -#ifdef PNG_SETJMP_SUPPORTED -#ifdef USE_FAR_KEYWORD - jmp_buf jmpbuf; -#endif -#endif - - int i; - - png_debug(1, "in png_create_read_struct\n"); -#ifdef PNG_USER_MEM_SUPPORTED - png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG, - (png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr); -#else - png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); -#endif - if (png_ptr == NULL) - return (NULL); - -#if !defined(PNG_1_0_X) -#ifdef PNG_MMX_CODE_SUPPORTED - png_init_mmx_flags(png_ptr); /* 1.2.0 addition */ -#endif -#endif /* PNG_1_0_X */ - - /* added at libpng-1.2.6 */ -#ifdef PNG_SET_USER_LIMITS_SUPPORTED - png_ptr->user_width_max=PNG_USER_WIDTH_MAX; - png_ptr->user_height_max=PNG_USER_HEIGHT_MAX; -#endif - -#ifdef PNG_SETJMP_SUPPORTED -#ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) -#else - if (setjmp(png_ptr->jmpbuf)) -#endif - { - png_free(png_ptr, png_ptr->zbuf); - png_ptr->zbuf=NULL; -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)png_ptr, - (png_free_ptr)free_fn, (png_voidp)mem_ptr); -#else - png_destroy_struct((png_voidp)png_ptr); -#endif - return (NULL); - } -#ifdef USE_FAR_KEYWORD - png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf)); -#endif -#endif - -#ifdef PNG_USER_MEM_SUPPORTED - png_set_mem_fn(png_ptr, mem_ptr, malloc_fn, free_fn); -#endif - - png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn); - - i=0; - do - { - if(user_png_ver[i] != png_libpng_ver[i]) - png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; - } while (png_libpng_ver[i++]); - - if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) - { - /* Libpng 0.90 and later are binary incompatible with libpng 0.89, so - * we must recompile any applications that use any older library version. - * For versions after libpng 1.0, we will be compatible, so we need - * only check the first digit. - */ - if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] || - (user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) || - (user_png_ver[0] == '0' && user_png_ver[2] < '9')) - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char msg[80]; - if (user_png_ver) - { - sprintf(msg, "Application was compiled with png.h from libpng-%.20s", - user_png_ver); - png_warning(png_ptr, msg); - } - sprintf(msg, "Application is running with png.c from libpng-%.20s", - png_libpng_ver); - png_warning(png_ptr, msg); -#endif -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "Incompatible libpng version in application and library"); - } - } - - /* initialize zbuf - compression buffer */ - png_ptr->zbuf_size = PNG_ZBUF_SIZE; - png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, - (png_uint_32)png_ptr->zbuf_size); - png_ptr->zstream.zalloc = png_zalloc; - png_ptr->zstream.zfree = png_zfree; - png_ptr->zstream.opaque = (voidpf)png_ptr; - - switch (inflateInit(&png_ptr->zstream)) - { - case Z_OK: /* Do nothing */ break; - case Z_MEM_ERROR: - case Z_STREAM_ERROR: png_error(png_ptr, "zlib memory error"); break; - case Z_VERSION_ERROR: png_error(png_ptr, "zlib version error"); break; - default: png_error(png_ptr, "Unknown zlib error"); - } - - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - - png_set_read_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL); - -#ifdef PNG_SETJMP_SUPPORTED -/* Applications that neglect to set up their own setjmp() and then encounter - a png_error() will longjmp here. Since the jmpbuf is then meaningless we - abort instead of returning. */ -#ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) - PNG_ABORT(); - png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf)); -#else - if (setjmp(png_ptr->jmpbuf)) - PNG_ABORT(); -#endif -#endif - return (png_ptr); -} - -#if defined(PNG_1_0_X) || defined(PNG_1_2_X) -/* Initialize PNG structure for reading, and allocate any memory needed. - This interface is deprecated in favour of the png_create_read_struct(), - and it will disappear as of libpng-1.3.0. */ -#undef png_read_init -void PNGAPI -png_read_init(png_structp png_ptr) -{ - /* We only come here via pre-1.0.7-compiled applications */ - png_read_init_2(png_ptr, "1.0.6 or earlier", 0, 0); -} - -void PNGAPI -png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver, - png_size_t png_struct_size, png_size_t png_info_size) -{ - /* We only come here via pre-1.0.12-compiled applications */ - if(png_ptr == NULL) return; -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - if(png_sizeof(png_struct) > png_struct_size || - png_sizeof(png_info) > png_info_size) - { - char msg[80]; - png_ptr->warning_fn=NULL; - if (user_png_ver) - { - sprintf(msg, "Application was compiled with png.h from libpng-%.20s", - user_png_ver); - png_warning(png_ptr, msg); - } - sprintf(msg, "Application is running with png.c from libpng-%.20s", - png_libpng_ver); - png_warning(png_ptr, msg); - } -#endif - if(png_sizeof(png_struct) > png_struct_size) - { - png_ptr->error_fn=NULL; -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "The png struct allocated by the application for reading is too small."); - } - if(png_sizeof(png_info) > png_info_size) - { - png_ptr->error_fn=NULL; -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "The info struct allocated by application for reading is too small."); - } - png_read_init_3(&png_ptr, user_png_ver, png_struct_size); -} -#endif /* PNG_1_0_X || PNG_1_2_X */ - -void PNGAPI -png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, - png_size_t png_struct_size) -{ -#ifdef PNG_SETJMP_SUPPORTED - jmp_buf tmp_jmp; /* to save current jump buffer */ -#endif - - int i=0; - - png_structp png_ptr=*ptr_ptr; - - if(png_ptr == NULL) return; - - do - { - if(user_png_ver[i] != png_libpng_ver[i]) - { -#ifdef PNG_LEGACY_SUPPORTED - png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; -#else - png_ptr->warning_fn=NULL; - png_warning(png_ptr, - "Application uses deprecated png_read_init() and should be recompiled."); - break; -#endif - } - } while (png_libpng_ver[i++]); - - png_debug(1, "in png_read_init_3\n"); - -#ifdef PNG_SETJMP_SUPPORTED - /* save jump buffer and error functions */ - png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf)); -#endif - - if(png_sizeof(png_struct) > png_struct_size) - { - png_destroy_struct(png_ptr); - *ptr_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); - png_ptr = *ptr_ptr; - } - - /* reset all variables to 0 */ - png_memset(png_ptr, 0, png_sizeof (png_struct)); - -#ifdef PNG_SETJMP_SUPPORTED - /* restore jump buffer */ - png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf)); -#endif - - /* added at libpng-1.2.6 */ -#ifdef PNG_SET_USER_LIMITS_SUPPORTED - png_ptr->user_width_max=PNG_USER_WIDTH_MAX; - png_ptr->user_height_max=PNG_USER_HEIGHT_MAX; -#endif - - /* initialize zbuf - compression buffer */ - png_ptr->zbuf_size = PNG_ZBUF_SIZE; - png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, - (png_uint_32)png_ptr->zbuf_size); - png_ptr->zstream.zalloc = png_zalloc; - png_ptr->zstream.zfree = png_zfree; - png_ptr->zstream.opaque = (voidpf)png_ptr; - - switch (inflateInit(&png_ptr->zstream)) - { - case Z_OK: /* Do nothing */ break; - case Z_MEM_ERROR: - case Z_STREAM_ERROR: png_error(png_ptr, "zlib memory"); break; - case Z_VERSION_ERROR: png_error(png_ptr, "zlib version"); break; - default: png_error(png_ptr, "Unknown zlib error"); - } - - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - - png_set_read_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL); -} - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* Read the information before the actual image data. This has been - * changed in v0.90 to allow reading a file that already has the magic - * bytes read from the stream. You can tell libpng how many bytes have - * been read from the beginning of the stream (up to the maximum of 8) - * via png_set_sig_bytes(), and we will only check the remaining bytes - * here. The application can then have access to the signature bytes we - * read if it is determined that this isn't a valid PNG file. - */ -void PNGAPI -png_read_info(png_structp png_ptr, png_infop info_ptr) -{ - if(png_ptr == NULL) return; - png_debug(1, "in png_read_info\n"); - /* If we haven't checked all of the PNG signature bytes, do so now. */ - if (png_ptr->sig_bytes < 8) - { - png_size_t num_checked = png_ptr->sig_bytes, - num_to_check = 8 - num_checked; - - png_read_data(png_ptr, &(info_ptr->signature[num_checked]), num_to_check); - png_ptr->sig_bytes = 8; - - if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check)) - { - if (num_checked < 4 && - png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4)) - png_error(png_ptr, "Not a PNG file"); - else - png_error(png_ptr, "PNG file corrupted by ASCII conversion"); - } - if (num_checked < 3) - png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE; - } - - for(;;) - { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IHDR; - PNG_IDAT; - PNG_IEND; - PNG_PLTE; -#if defined(PNG_READ_bKGD_SUPPORTED) - PNG_bKGD; -#endif -#if defined(PNG_READ_cHRM_SUPPORTED) - PNG_cHRM; -#endif -#if defined(PNG_READ_gAMA_SUPPORTED) - PNG_gAMA; -#endif -#if defined(PNG_READ_hIST_SUPPORTED) - PNG_hIST; -#endif -#if defined(PNG_READ_iCCP_SUPPORTED) - PNG_iCCP; -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - PNG_iTXt; -#endif -#if defined(PNG_READ_oFFs_SUPPORTED) - PNG_oFFs; -#endif -#if defined(PNG_READ_pCAL_SUPPORTED) - PNG_pCAL; -#endif -#if defined(PNG_READ_pHYs_SUPPORTED) - PNG_pHYs; -#endif -#if defined(PNG_READ_sBIT_SUPPORTED) - PNG_sBIT; -#endif -#if defined(PNG_READ_sCAL_SUPPORTED) - PNG_sCAL; -#endif -#if defined(PNG_READ_sPLT_SUPPORTED) - PNG_sPLT; -#endif -#if defined(PNG_READ_sRGB_SUPPORTED) - PNG_sRGB; -#endif -#if defined(PNG_READ_tEXt_SUPPORTED) - PNG_tEXt; -#endif -#if defined(PNG_READ_tIME_SUPPORTED) - PNG_tIME; -#endif -#if defined(PNG_READ_tRNS_SUPPORTED) - PNG_tRNS; -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - PNG_zTXt; -#endif -#endif /* PNG_USE_LOCAL_ARRAYS */ - png_byte chunk_length[4]; - png_uint_32 length; - - png_read_data(png_ptr, chunk_length, 4); - length = png_get_uint_31(png_ptr,chunk_length); - - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); - - png_debug2(0, "Reading %s chunk, length=%lu.\n", png_ptr->chunk_name, - length); - - /* This should be a binary subdivision search or a hash for - * matching the chunk name rather than a linear search. - */ - if (!png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) - if(png_ptr->mode & PNG_AFTER_IDAT) - png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT; - - if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) - png_handle_IHDR(png_ptr, info_ptr, length); - else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4)) - png_handle_IEND(png_ptr, info_ptr, length); -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED - else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name)) - { - if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - png_ptr->mode |= PNG_HAVE_IDAT; - png_handle_unknown(png_ptr, info_ptr, length); - if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) - png_ptr->mode |= PNG_HAVE_PLTE; - else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - { - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before IDAT"); - else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - !(png_ptr->mode & PNG_HAVE_PLTE)) - png_error(png_ptr, "Missing PLTE before IDAT"); - break; - } - } -#endif - else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) - png_handle_PLTE(png_ptr, info_ptr, length); - else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - { - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before IDAT"); - else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - !(png_ptr->mode & PNG_HAVE_PLTE)) - png_error(png_ptr, "Missing PLTE before IDAT"); - - png_ptr->idat_size = length; - png_ptr->mode |= PNG_HAVE_IDAT; - break; - } -#if defined(PNG_READ_bKGD_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4)) - png_handle_bKGD(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_cHRM_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4)) - png_handle_cHRM(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_gAMA_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4)) - png_handle_gAMA(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_hIST_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4)) - png_handle_hIST(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_oFFs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4)) - png_handle_oFFs(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_pCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4)) - png_handle_pCAL(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4)) - png_handle_sCAL(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_pHYs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4)) - png_handle_pHYs(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sBIT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4)) - png_handle_sBIT(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sRGB_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4)) - png_handle_sRGB(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_iCCP_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4)) - png_handle_iCCP(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sPLT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4)) - png_handle_sPLT(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_tEXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4)) - png_handle_tEXt(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_tIME_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4)) - png_handle_tIME(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_tRNS_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4)) - png_handle_tRNS(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4)) - png_handle_zTXt(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4)) - png_handle_iTXt(png_ptr, info_ptr, length); -#endif - else - png_handle_unknown(png_ptr, info_ptr, length); - } -} -#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ - -/* optional call to update the users info_ptr structure */ -void PNGAPI -png_read_update_info(png_structp png_ptr, png_infop info_ptr) -{ - png_debug(1, "in png_read_update_info\n"); - if(png_ptr == NULL) return; - if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) - png_read_start_row(png_ptr); - else - png_warning(png_ptr, - "Ignoring extra png_read_update_info() call; row buffer not reallocated"); - png_read_transform_info(png_ptr, info_ptr); -} - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* Initialize palette, background, etc, after transformations - * are set, but before any reading takes place. This allows - * the user to obtain a gamma-corrected palette, for example. - * If the user doesn't call this, we will do it ourselves. - */ -void PNGAPI -png_start_read_image(png_structp png_ptr) -{ - png_debug(1, "in png_start_read_image\n"); - if(png_ptr == NULL) return; - if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) - png_read_start_row(png_ptr); -} -#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -void PNGAPI -png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IDAT; - const int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; - const int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff}; -#endif - int ret; - if(png_ptr == NULL) return; - png_debug2(1, "in png_read_row (row %lu, pass %d)\n", - png_ptr->row_number, png_ptr->pass); - if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) - png_read_start_row(png_ptr); - if (png_ptr->row_number == 0 && png_ptr->pass == 0) - { - /* check for transforms that have been set but were defined out */ -#if defined(PNG_WRITE_INVERT_SUPPORTED) && !defined(PNG_READ_INVERT_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_MONO) - png_warning(png_ptr, "PNG_READ_INVERT_SUPPORTED is not defined."); -#endif -#if defined(PNG_WRITE_FILLER_SUPPORTED) && !defined(PNG_READ_FILLER_SUPPORTED) - if (png_ptr->transformations & PNG_FILLER) - png_warning(png_ptr, "PNG_READ_FILLER_SUPPORTED is not defined."); -#endif -#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) && !defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - png_warning(png_ptr, "PNG_READ_PACKSWAP_SUPPORTED is not defined."); -#endif -#if defined(PNG_WRITE_PACK_SUPPORTED) && !defined(PNG_READ_PACK_SUPPORTED) - if (png_ptr->transformations & PNG_PACK) - png_warning(png_ptr, "PNG_READ_PACK_SUPPORTED is not defined."); -#endif -#if defined(PNG_WRITE_SHIFT_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) - if (png_ptr->transformations & PNG_SHIFT) - png_warning(png_ptr, "PNG_READ_SHIFT_SUPPORTED is not defined."); -#endif -#if defined(PNG_WRITE_BGR_SUPPORTED) && !defined(PNG_READ_BGR_SUPPORTED) - if (png_ptr->transformations & PNG_BGR) - png_warning(png_ptr, "PNG_READ_BGR_SUPPORTED is not defined."); -#endif -#if defined(PNG_WRITE_SWAP_SUPPORTED) && !defined(PNG_READ_SWAP_SUPPORTED) - if (png_ptr->transformations & PNG_SWAP_BYTES) - png_warning(png_ptr, "PNG_READ_SWAP_SUPPORTED is not defined."); -#endif - } - -#if defined(PNG_READ_INTERLACING_SUPPORTED) - /* if interlaced and we do not need a new row, combine row and return */ - if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) - { - switch (png_ptr->pass) - { - case 0: - if (png_ptr->row_number & 0x07) - { - if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); - png_read_finish_row(png_ptr); - return; - } - break; - case 1: - if ((png_ptr->row_number & 0x07) || png_ptr->width < 5) - { - if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); - png_read_finish_row(png_ptr); - return; - } - break; - case 2: - if ((png_ptr->row_number & 0x07) != 4) - { - if (dsp_row != NULL && (png_ptr->row_number & 4)) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); - png_read_finish_row(png_ptr); - return; - } - break; - case 3: - if ((png_ptr->row_number & 3) || png_ptr->width < 3) - { - if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); - png_read_finish_row(png_ptr); - return; - } - break; - case 4: - if ((png_ptr->row_number & 3) != 2) - { - if (dsp_row != NULL && (png_ptr->row_number & 2)) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); - png_read_finish_row(png_ptr); - return; - } - break; - case 5: - if ((png_ptr->row_number & 1) || png_ptr->width < 2) - { - if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); - png_read_finish_row(png_ptr); - return; - } - break; - case 6: - if (!(png_ptr->row_number & 1)) - { - png_read_finish_row(png_ptr); - return; - } - break; - } - } -#endif - - if (!(png_ptr->mode & PNG_HAVE_IDAT)) - png_error(png_ptr, "Invalid attempt to read row data"); - - png_ptr->zstream.next_out = png_ptr->row_buf; - png_ptr->zstream.avail_out = (uInt)png_ptr->irowbytes; - do - { - if (!(png_ptr->zstream.avail_in)) - { - while (!png_ptr->idat_size) - { - png_byte chunk_length[4]; - - png_crc_finish(png_ptr, 0); - - png_read_data(png_ptr, chunk_length, 4); - png_ptr->idat_size = png_get_uint_31(png_ptr,chunk_length); - - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); - if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - png_error(png_ptr, "Not enough image data"); - } - png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size; - png_ptr->zstream.next_in = png_ptr->zbuf; - if (png_ptr->zbuf_size > png_ptr->idat_size) - png_ptr->zstream.avail_in = (uInt)png_ptr->idat_size; - png_crc_read(png_ptr, png_ptr->zbuf, - (png_size_t)png_ptr->zstream.avail_in); - png_ptr->idat_size -= png_ptr->zstream.avail_in; - } - ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); - if (ret == Z_STREAM_END) - { - if (png_ptr->zstream.avail_out || png_ptr->zstream.avail_in || - png_ptr->idat_size) - png_error(png_ptr, "Extra compressed data"); - png_ptr->mode |= PNG_AFTER_IDAT; - png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; - break; - } - if (ret != Z_OK) - png_error(png_ptr, png_ptr->zstream.msg ? png_ptr->zstream.msg : - "Decompression error"); - - } while (png_ptr->zstream.avail_out); - - png_ptr->row_info.color_type = png_ptr->color_type; - png_ptr->row_info.width = png_ptr->iwidth; - png_ptr->row_info.channels = png_ptr->channels; - png_ptr->row_info.bit_depth = png_ptr->bit_depth; - png_ptr->row_info.pixel_depth = png_ptr->pixel_depth; - png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth, - png_ptr->row_info.width); - - if(png_ptr->row_buf[0]) - png_read_filter_row(png_ptr, &(png_ptr->row_info), - png_ptr->row_buf + 1, png_ptr->prev_row + 1, - (int)(png_ptr->row_buf[0])); - - png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf, - png_ptr->rowbytes + 1); - -#if defined(PNG_MNG_FEATURES_SUPPORTED) - if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING)) - { - /* Intrapixel differencing */ - png_do_read_intrapixel(&(png_ptr->row_info), png_ptr->row_buf + 1); - } -#endif - - - if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA)) - png_do_read_transformations(png_ptr); - -#if defined(PNG_READ_INTERLACING_SUPPORTED) - /* blow up interlaced rows to full size */ - if (png_ptr->interlaced && - (png_ptr->transformations & PNG_INTERLACE)) - { - if (png_ptr->pass < 6) -/* old interface (pre-1.0.9): - png_do_read_interlace(&(png_ptr->row_info), - png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations); - */ - png_do_read_interlace(png_ptr); - - if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); - if (row != NULL) - png_combine_row(png_ptr, row, - png_pass_mask[png_ptr->pass]); - } - else -#endif - { - if (row != NULL) - png_combine_row(png_ptr, row, 0xff); - if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, 0xff); - } - png_read_finish_row(png_ptr); - - if (png_ptr->read_row_fn != NULL) - (*(png_ptr->read_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass); -} -#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* Read one or more rows of image data. If the image is interlaced, - * and png_set_interlace_handling() has been called, the rows need to - * contain the contents of the rows from the previous pass. If the - * image has alpha or transparency, and png_handle_alpha()[*] has been - * called, the rows contents must be initialized to the contents of the - * screen. - * - * "row" holds the actual image, and pixels are placed in it - * as they arrive. If the image is displayed after each pass, it will - * appear to "sparkle" in. "display_row" can be used to display a - * "chunky" progressive image, with finer detail added as it becomes - * available. If you do not want this "chunky" display, you may pass - * NULL for display_row. If you do not want the sparkle display, and - * you have not called png_handle_alpha(), you may pass NULL for rows. - * If you have called png_handle_alpha(), and the image has either an - * alpha channel or a transparency chunk, you must provide a buffer for - * rows. In this case, you do not have to provide a display_row buffer - * also, but you may. If the image is not interlaced, or if you have - * not called png_set_interlace_handling(), the display_row buffer will - * be ignored, so pass NULL to it. - * - * [*] png_handle_alpha() does not exist yet, as of this version of libpng - */ - -void PNGAPI -png_read_rows(png_structp png_ptr, png_bytepp row, - png_bytepp display_row, png_uint_32 num_rows) -{ - png_uint_32 i; - png_bytepp rp; - png_bytepp dp; - - png_debug(1, "in png_read_rows\n"); - if(png_ptr == NULL) return; - rp = row; - dp = display_row; - if (rp != NULL && dp != NULL) - for (i = 0; i < num_rows; i++) - { - png_bytep rptr = *rp++; - png_bytep dptr = *dp++; - - png_read_row(png_ptr, rptr, dptr); - } - else if(rp != NULL) - for (i = 0; i < num_rows; i++) - { - png_bytep rptr = *rp; - png_read_row(png_ptr, rptr, png_bytep_NULL); - rp++; - } - else if(dp != NULL) - for (i = 0; i < num_rows; i++) - { - png_bytep dptr = *dp; - png_read_row(png_ptr, png_bytep_NULL, dptr); - dp++; - } -} -#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* Read the entire image. If the image has an alpha channel or a tRNS - * chunk, and you have called png_handle_alpha()[*], you will need to - * initialize the image to the current image that PNG will be overlaying. - * We set the num_rows again here, in case it was incorrectly set in - * png_read_start_row() by a call to png_read_update_info() or - * png_start_read_image() if png_set_interlace_handling() wasn't called - * prior to either of these functions like it should have been. You can - * only call this function once. If you desire to have an image for - * each pass of a interlaced image, use png_read_rows() instead. - * - * [*] png_handle_alpha() does not exist yet, as of this version of libpng - */ -void PNGAPI -png_read_image(png_structp png_ptr, png_bytepp image) -{ - png_uint_32 i,image_height; - int pass, j; - png_bytepp rp; - - png_debug(1, "in png_read_image\n"); - if(png_ptr == NULL) return; - -#ifdef PNG_READ_INTERLACING_SUPPORTED - pass = png_set_interlace_handling(png_ptr); -#else - if (png_ptr->interlaced) - png_error(png_ptr, - "Cannot read interlaced image -- interlace handler disabled."); - pass = 1; -#endif - - - image_height=png_ptr->height; - png_ptr->num_rows = image_height; /* Make sure this is set correctly */ - - for (j = 0; j < pass; j++) - { - rp = image; - for (i = 0; i < image_height; i++) - { - png_read_row(png_ptr, *rp, png_bytep_NULL); - rp++; - } - } -} -#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* Read the end of the PNG file. Will not read past the end of the - * file, will verify the end is accurate, and will read any comments - * or time information at the end of the file, if info is not NULL. - */ -void PNGAPI -png_read_end(png_structp png_ptr, png_infop info_ptr) -{ - png_byte chunk_length[4]; - png_uint_32 length; - - png_debug(1, "in png_read_end\n"); - if(png_ptr == NULL) return; - png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */ - - do - { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IHDR; - PNG_IDAT; - PNG_IEND; - PNG_PLTE; -#if defined(PNG_READ_bKGD_SUPPORTED) - PNG_bKGD; -#endif -#if defined(PNG_READ_cHRM_SUPPORTED) - PNG_cHRM; -#endif -#if defined(PNG_READ_gAMA_SUPPORTED) - PNG_gAMA; -#endif -#if defined(PNG_READ_hIST_SUPPORTED) - PNG_hIST; -#endif -#if defined(PNG_READ_iCCP_SUPPORTED) - PNG_iCCP; -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - PNG_iTXt; -#endif -#if defined(PNG_READ_oFFs_SUPPORTED) - PNG_oFFs; -#endif -#if defined(PNG_READ_pCAL_SUPPORTED) - PNG_pCAL; -#endif -#if defined(PNG_READ_pHYs_SUPPORTED) - PNG_pHYs; -#endif -#if defined(PNG_READ_sBIT_SUPPORTED) - PNG_sBIT; -#endif -#if defined(PNG_READ_sCAL_SUPPORTED) - PNG_sCAL; -#endif -#if defined(PNG_READ_sPLT_SUPPORTED) - PNG_sPLT; -#endif -#if defined(PNG_READ_sRGB_SUPPORTED) - PNG_sRGB; -#endif -#if defined(PNG_READ_tEXt_SUPPORTED) - PNG_tEXt; -#endif -#if defined(PNG_READ_tIME_SUPPORTED) - PNG_tIME; -#endif -#if defined(PNG_READ_tRNS_SUPPORTED) - PNG_tRNS; -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - PNG_zTXt; -#endif -#endif /* PNG_USE_LOCAL_ARRAYS */ - - png_read_data(png_ptr, chunk_length, 4); - length = png_get_uint_31(png_ptr,chunk_length); - - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); - - png_debug1(0, "Reading %s chunk.\n", png_ptr->chunk_name); - - if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) - png_handle_IHDR(png_ptr, info_ptr, length); - else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4)) - png_handle_IEND(png_ptr, info_ptr, length); -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED - else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name)) - { - if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - { - if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT)) - png_error(png_ptr, "Too many IDAT's found"); - } - png_handle_unknown(png_ptr, info_ptr, length); - if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) - png_ptr->mode |= PNG_HAVE_PLTE; - } -#endif - else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - { - /* Zero length IDATs are legal after the last IDAT has been - * read, but not after other chunks have been read. - */ - if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT)) - png_error(png_ptr, "Too many IDAT's found"); - png_crc_finish(png_ptr, length); - } - else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) - png_handle_PLTE(png_ptr, info_ptr, length); -#if defined(PNG_READ_bKGD_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4)) - png_handle_bKGD(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_cHRM_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4)) - png_handle_cHRM(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_gAMA_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4)) - png_handle_gAMA(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_hIST_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4)) - png_handle_hIST(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_oFFs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4)) - png_handle_oFFs(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_pCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4)) - png_handle_pCAL(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4)) - png_handle_sCAL(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_pHYs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4)) - png_handle_pHYs(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sBIT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4)) - png_handle_sBIT(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sRGB_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4)) - png_handle_sRGB(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_iCCP_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4)) - png_handle_iCCP(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sPLT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4)) - png_handle_sPLT(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_tEXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4)) - png_handle_tEXt(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_tIME_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4)) - png_handle_tIME(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_tRNS_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4)) - png_handle_tRNS(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4)) - png_handle_zTXt(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4)) - png_handle_iTXt(png_ptr, info_ptr, length); -#endif - else - png_handle_unknown(png_ptr, info_ptr, length); - } while (!(png_ptr->mode & PNG_HAVE_IEND)); -} -#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ - -/* free all memory used by the read */ -void PNGAPI -png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, - png_infopp end_info_ptr_ptr) -{ - png_structp png_ptr = NULL; - png_infop info_ptr = NULL, end_info_ptr = NULL; -#ifdef PNG_USER_MEM_SUPPORTED - png_free_ptr free_fn; - png_voidp mem_ptr; -#endif - - png_debug(1, "in png_destroy_read_struct\n"); - if (png_ptr_ptr != NULL) - png_ptr = *png_ptr_ptr; - - if (info_ptr_ptr != NULL) - info_ptr = *info_ptr_ptr; - - if (end_info_ptr_ptr != NULL) - end_info_ptr = *end_info_ptr_ptr; - -#ifdef PNG_USER_MEM_SUPPORTED - free_fn = png_ptr->free_fn; - mem_ptr = png_ptr->mem_ptr; -#endif - - png_read_destroy(png_ptr, info_ptr, end_info_ptr); - - if (info_ptr != NULL) - { -#if defined(PNG_TEXT_SUPPORTED) - png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, -1); -#endif - -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)info_ptr, (png_free_ptr)free_fn, - (png_voidp)mem_ptr); -#else - png_destroy_struct((png_voidp)info_ptr); -#endif - *info_ptr_ptr = NULL; - } - - if (end_info_ptr != NULL) - { -#if defined(PNG_READ_TEXT_SUPPORTED) - png_free_data(png_ptr, end_info_ptr, PNG_FREE_TEXT, -1); -#endif -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)end_info_ptr, (png_free_ptr)free_fn, - (png_voidp)mem_ptr); -#else - png_destroy_struct((png_voidp)end_info_ptr); -#endif - *end_info_ptr_ptr = NULL; - } - - if (png_ptr != NULL) - { -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn, - (png_voidp)mem_ptr); -#else - png_destroy_struct((png_voidp)png_ptr); -#endif - *png_ptr_ptr = NULL; - } -} - -/* free all memory used by the read (old method) */ -void /* PRIVATE */ -png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr) -{ -#ifdef PNG_SETJMP_SUPPORTED - jmp_buf tmp_jmp; -#endif - png_error_ptr error_fn; - png_error_ptr warning_fn; - png_voidp error_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - png_free_ptr free_fn; -#endif - - png_debug(1, "in png_read_destroy\n"); - if (info_ptr != NULL) - png_info_destroy(png_ptr, info_ptr); - - if (end_info_ptr != NULL) - png_info_destroy(png_ptr, end_info_ptr); - - png_free(png_ptr, png_ptr->zbuf); - png_free(png_ptr, png_ptr->big_row_buf); - png_free(png_ptr, png_ptr->prev_row); -#if defined(PNG_READ_DITHER_SUPPORTED) - png_free(png_ptr, png_ptr->palette_lookup); - png_free(png_ptr, png_ptr->dither_index); -#endif -#if defined(PNG_READ_GAMMA_SUPPORTED) - png_free(png_ptr, png_ptr->gamma_table); -#endif -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - png_free(png_ptr, png_ptr->gamma_from_1); - png_free(png_ptr, png_ptr->gamma_to_1); -#endif -#ifdef PNG_FREE_ME_SUPPORTED - if (png_ptr->free_me & PNG_FREE_PLTE) - png_zfree(png_ptr, png_ptr->palette); - png_ptr->free_me &= ~PNG_FREE_PLTE; -#else - if (png_ptr->flags & PNG_FLAG_FREE_PLTE) - png_zfree(png_ptr, png_ptr->palette); - png_ptr->flags &= ~PNG_FLAG_FREE_PLTE; -#endif -#if defined(PNG_tRNS_SUPPORTED) || \ - defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) -#ifdef PNG_FREE_ME_SUPPORTED - if (png_ptr->free_me & PNG_FREE_TRNS) - png_free(png_ptr, png_ptr->trans); - png_ptr->free_me &= ~PNG_FREE_TRNS; -#else - if (png_ptr->flags & PNG_FLAG_FREE_TRNS) - png_free(png_ptr, png_ptr->trans); - png_ptr->flags &= ~PNG_FLAG_FREE_TRNS; -#endif -#endif -#if defined(PNG_READ_hIST_SUPPORTED) -#ifdef PNG_FREE_ME_SUPPORTED - if (png_ptr->free_me & PNG_FREE_HIST) - png_free(png_ptr, png_ptr->hist); - png_ptr->free_me &= ~PNG_FREE_HIST; -#else - if (png_ptr->flags & PNG_FLAG_FREE_HIST) - png_free(png_ptr, png_ptr->hist); - png_ptr->flags &= ~PNG_FLAG_FREE_HIST; -#endif -#endif -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (png_ptr->gamma_16_table != NULL) - { - int i; - int istop = (1 << (8 - png_ptr->gamma_shift)); - for (i = 0; i < istop; i++) - { - png_free(png_ptr, png_ptr->gamma_16_table[i]); - } - png_free(png_ptr, png_ptr->gamma_16_table); - } -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->gamma_16_from_1 != NULL) - { - int i; - int istop = (1 << (8 - png_ptr->gamma_shift)); - for (i = 0; i < istop; i++) - { - png_free(png_ptr, png_ptr->gamma_16_from_1[i]); - } - png_free(png_ptr, png_ptr->gamma_16_from_1); - } - if (png_ptr->gamma_16_to_1 != NULL) - { - int i; - int istop = (1 << (8 - png_ptr->gamma_shift)); - for (i = 0; i < istop; i++) - { - png_free(png_ptr, png_ptr->gamma_16_to_1[i]); - } - png_free(png_ptr, png_ptr->gamma_16_to_1); - } -#endif -#endif -#if defined(PNG_TIME_RFC1123_SUPPORTED) - png_free(png_ptr, png_ptr->time_buffer); -#endif - - inflateEnd(&png_ptr->zstream); -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED - png_free(png_ptr, png_ptr->save_buffer); -#endif - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -#ifdef PNG_TEXT_SUPPORTED - png_free(png_ptr, png_ptr->current_text); -#endif /* PNG_TEXT_SUPPORTED */ -#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ - - /* Save the important info out of the png_struct, in case it is - * being used again. - */ -#ifdef PNG_SETJMP_SUPPORTED - png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf)); -#endif - - error_fn = png_ptr->error_fn; - warning_fn = png_ptr->warning_fn; - error_ptr = png_ptr->error_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - free_fn = png_ptr->free_fn; -#endif - - png_memset(png_ptr, 0, png_sizeof (png_struct)); - - png_ptr->error_fn = error_fn; - png_ptr->warning_fn = warning_fn; - png_ptr->error_ptr = error_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - png_ptr->free_fn = free_fn; -#endif - -#ifdef PNG_SETJMP_SUPPORTED - png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf)); -#endif - -} - -void PNGAPI -png_set_read_status_fn(png_structp png_ptr, png_read_status_ptr read_row_fn) -{ - if(png_ptr == NULL) return; - png_ptr->read_row_fn = read_row_fn; -} - - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -#if defined(PNG_INFO_IMAGE_SUPPORTED) -void PNGAPI -png_read_png(png_structp png_ptr, png_infop info_ptr, - int transforms, - voidp params) -{ - int row; - - if(png_ptr == NULL) return; -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) - /* invert the alpha channel from opacity to transparency - */ - if (transforms & PNG_TRANSFORM_INVERT_ALPHA) - png_set_invert_alpha(png_ptr); -#endif - - /* png_read_info() gives us all of the information from the - * PNG file before the first IDAT (image data chunk). - */ - png_read_info(png_ptr, info_ptr); - if (info_ptr->height > PNG_UINT_32_MAX/png_sizeof(png_bytep)) - png_error(png_ptr,"Image is too high to process with png_read_png()"); - - /* -------------- image transformations start here ------------------- */ - -#if defined(PNG_READ_16_TO_8_SUPPORTED) - /* tell libpng to strip 16 bit/color files down to 8 bits per color - */ - if (transforms & PNG_TRANSFORM_STRIP_16) - png_set_strip_16(png_ptr); -#endif - -#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) - /* Strip alpha bytes from the input data without combining with - * the background (not recommended). - */ - if (transforms & PNG_TRANSFORM_STRIP_ALPHA) - png_set_strip_alpha(png_ptr); -#endif - -#if defined(PNG_READ_PACK_SUPPORTED) && !defined(PNG_READ_EXPAND_SUPPORTED) - /* Extract multiple pixels with bit depths of 1, 2, or 4 from a single - * byte into separate bytes (useful for paletted and grayscale images). - */ - if (transforms & PNG_TRANSFORM_PACKING) - png_set_packing(png_ptr); -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - /* Change the order of packed pixels to least significant bit first - * (not useful if you are using png_set_packing). - */ - if (transforms & PNG_TRANSFORM_PACKSWAP) - png_set_packswap(png_ptr); -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) - /* Expand paletted colors into true RGB triplets - * Expand grayscale images to full 8 bits from 1, 2, or 4 bits/pixel - * Expand paletted or RGB images with transparency to full alpha - * channels so the data will be available as RGBA quartets. - */ - if (transforms & PNG_TRANSFORM_EXPAND) - if ((png_ptr->bit_depth < 8) || - (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) || - (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))) - png_set_expand(png_ptr); -#endif - - /* We don't handle background color or gamma transformation or dithering. - */ - -#if defined(PNG_READ_INVERT_SUPPORTED) - /* invert monochrome files to have 0 as white and 1 as black - */ - if (transforms & PNG_TRANSFORM_INVERT_MONO) - png_set_invert_mono(png_ptr); -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) - /* If you want to shift the pixel values from the range [0,255] or - * [0,65535] to the original [0,7] or [0,31], or whatever range the - * colors were originally in: - */ - if ((transforms & PNG_TRANSFORM_SHIFT) - && png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT)) - { - png_color_8p sig_bit; - - png_get_sBIT(png_ptr, info_ptr, &sig_bit); - png_set_shift(png_ptr, sig_bit); - } -#endif - -#if defined(PNG_READ_BGR_SUPPORTED) - /* flip the RGB pixels to BGR (or RGBA to BGRA) - */ - if (transforms & PNG_TRANSFORM_BGR) - png_set_bgr(png_ptr); -#endif - -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) - /* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) - */ - if (transforms & PNG_TRANSFORM_SWAP_ALPHA) - png_set_swap_alpha(png_ptr); -#endif - -#if defined(PNG_READ_SWAP_SUPPORTED) - /* swap bytes of 16 bit files to least significant byte first - */ - if (transforms & PNG_TRANSFORM_SWAP_ENDIAN) - png_set_swap(png_ptr); -#endif - - /* We don't handle adding filler bytes */ - - /* Optional call to gamma correct and add the background to the palette - * and update info structure. REQUIRED if you are expecting libpng to - * update the palette for you (i.e., you selected such a transform above). - */ - png_read_update_info(png_ptr, info_ptr); - - /* -------------- image transformations end here ------------------- */ - -#ifdef PNG_FREE_ME_SUPPORTED - png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); -#endif - if(info_ptr->row_pointers == NULL) - { - info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr, - info_ptr->height * png_sizeof(png_bytep)); -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_ROWS; -#endif - for (row = 0; row < (int)info_ptr->height; row++) - { - info_ptr->row_pointers[row] = (png_bytep)png_malloc(png_ptr, - png_get_rowbytes(png_ptr, info_ptr)); - } - } - - png_read_image(png_ptr, info_ptr->row_pointers); - info_ptr->valid |= PNG_INFO_IDAT; - - /* read rest of file, and get additional chunks in info_ptr - REQUIRED */ - png_read_end(png_ptr, info_ptr); - - if(transforms == 0 || params == NULL) - /* quiet compiler warnings */ return; - -} -#endif /* PNG_INFO_IMAGE_SUPPORTED */ -#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ -#endif /* PNG_READ_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng_osx/pngrio.c b/irrlicht-1.6/source/Irrlicht/libpng_osx/pngrio.c deleted file mode 100644 index 7d2522f1f..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng_osx/pngrio.c +++ /dev/null @@ -1,167 +0,0 @@ - -/* pngrio.c - functions for data input - * - * Last changed in libpng 1.2.13 November 13, 2006 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2006 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This file provides a location for all input. Users who need - * special handling are expected to write a function that has the same - * arguments as this and performs a similar function, but that possibly - * has a different input method. Note that you shouldn't change this - * function, but rather write a replacement function and then make - * libpng use it at run time with png_set_read_fn(...). - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_READ_SUPPORTED) - -/* Read the data from whatever input you are using. The default routine - reads from a file pointer. Note that this routine sometimes gets called - with very small lengths, so you should implement some kind of simple - buffering if you are using unbuffered reads. This should never be asked - to read more then 64K on a 16 bit machine. */ -void /* PRIVATE */ -png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_debug1(4,"reading %d bytes\n", (int)length); - if (png_ptr->read_data_fn != NULL) - (*(png_ptr->read_data_fn))(png_ptr, data, length); - else - png_error(png_ptr, "Call to NULL read function"); -} - -#if !defined(PNG_NO_STDIO) -/* This is the function that does the actual reading of data. If you are - not reading from a standard C stream, you should create a replacement - read_data function and use it at run time with png_set_read_fn(), rather - than changing the library. */ -#ifndef USE_FAR_KEYWORD -void PNGAPI -png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_size_t check; - - if(png_ptr == NULL) return; - /* fread() returns 0 on error, so it is OK to store this in a png_size_t - * instead of an int, which is what fread() actually returns. - */ -#if defined(_WIN32_WCE) - if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) - check = 0; -#else - check = (png_size_t)fread(data, (png_size_t)1, length, - (png_FILE_p)png_ptr->io_ptr); -#endif - - if (check != length) - png_error(png_ptr, "Read Error"); -} -#else -/* this is the model-independent version. Since the standard I/O library - can't handle far buffers in the medium and small models, we have to copy - the data. -*/ - -#define NEAR_BUF_SIZE 1024 -#define MIN(a,b) (a <= b ? a : b) - -static void PNGAPI -png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - int check; - png_byte *n_data; - png_FILE_p io_ptr; - - if(png_ptr == NULL) return; - /* Check if data really is near. If so, use usual code. */ - n_data = (png_byte *)CVT_PTR_NOCHECK(data); - io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); - if ((png_bytep)n_data == data) - { -#if defined(_WIN32_WCE) - if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) - check = 0; -#else - check = fread(n_data, 1, length, io_ptr); -#endif - } - else - { - png_byte buf[NEAR_BUF_SIZE]; - png_size_t read, remaining, err; - check = 0; - remaining = length; - do - { - read = MIN(NEAR_BUF_SIZE, remaining); -#if defined(_WIN32_WCE) - if ( !ReadFile((HANDLE)(io_ptr), buf, read, &err, NULL) ) - err = 0; -#else - err = fread(buf, (png_size_t)1, read, io_ptr); -#endif - png_memcpy(data, buf, read); /* copy far buffer to near buffer */ - if(err != read) - break; - else - check += err; - data += read; - remaining -= read; - } - while (remaining != 0); - } - if ((png_uint_32)check != (png_uint_32)length) - png_error(png_ptr, "read Error"); -} -#endif -#endif - -/* This function allows the application to supply a new input function - for libpng if standard C streams aren't being used. - - This function takes as its arguments: - png_ptr - pointer to a png input data structure - io_ptr - pointer to user supplied structure containing info about - the input functions. May be NULL. - read_data_fn - pointer to a new input function that takes as its - arguments a pointer to a png_struct, a pointer to - a location where input data can be stored, and a 32-bit - unsigned int that is the number of bytes to be read. - To exit and output any fatal error messages the new write - function should call png_error(png_ptr, "Error msg"). */ -void PNGAPI -png_set_read_fn(png_structp png_ptr, png_voidp io_ptr, - png_rw_ptr read_data_fn) -{ - if(png_ptr == NULL) return; - png_ptr->io_ptr = io_ptr; - -#if !defined(PNG_NO_STDIO) - if (read_data_fn != NULL) - png_ptr->read_data_fn = read_data_fn; - else - png_ptr->read_data_fn = png_default_read_data; -#else - png_ptr->read_data_fn = read_data_fn; -#endif - - /* It is an error to write to a read device */ - if (png_ptr->write_data_fn != NULL) - { - png_ptr->write_data_fn = NULL; - png_warning(png_ptr, - "It's an error to set both read_data_fn and write_data_fn in the "); - png_warning(png_ptr, - "same structure. Resetting write_data_fn to NULL."); - } - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) - png_ptr->output_flush_fn = NULL; -#endif -} -#endif /* PNG_READ_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng_osx/pngrtran.c b/irrlicht-1.6/source/Irrlicht/libpng_osx/pngrtran.c deleted file mode 100644 index 2fa96f312..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng_osx/pngrtran.c +++ /dev/null @@ -1,4247 +0,0 @@ - -/* pngrtran.c - transforms the data in a row for PNG readers - * - * Last changed in libpng 1.2.15 January 5, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This file contains functions optionally called by an application - * in order to tell libpng how to handle data when reading a PNG. - * Transformations that are used in both reading and writing are - * in pngtrans.c. - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_READ_SUPPORTED) - -/* Set the action on getting a CRC error for an ancillary or critical chunk. */ -void PNGAPI -png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action) -{ - png_debug(1, "in png_set_crc_action\n"); - /* Tell libpng how we react to CRC errors in critical chunks */ - if(png_ptr == NULL) return; - switch (crit_action) - { - case PNG_CRC_NO_CHANGE: /* leave setting as is */ - break; - case PNG_CRC_WARN_USE: /* warn/use data */ - png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; - png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE; - break; - case PNG_CRC_QUIET_USE: /* quiet/use data */ - png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; - png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE | - PNG_FLAG_CRC_CRITICAL_IGNORE; - break; - case PNG_CRC_WARN_DISCARD: /* not a valid action for critical data */ - png_warning(png_ptr, "Can't discard critical data on CRC error."); - case PNG_CRC_ERROR_QUIT: /* error/quit */ - case PNG_CRC_DEFAULT: - default: - png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; - break; - } - - switch (ancil_action) - { - case PNG_CRC_NO_CHANGE: /* leave setting as is */ - break; - case PNG_CRC_WARN_USE: /* warn/use data */ - png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; - png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE; - break; - case PNG_CRC_QUIET_USE: /* quiet/use data */ - png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; - png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE | - PNG_FLAG_CRC_ANCILLARY_NOWARN; - break; - case PNG_CRC_ERROR_QUIT: /* error/quit */ - png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; - png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_NOWARN; - break; - case PNG_CRC_WARN_DISCARD: /* warn/discard data */ - case PNG_CRC_DEFAULT: - default: - png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; - break; - } -} - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ - defined(PNG_FLOATING_POINT_SUPPORTED) -/* handle alpha and tRNS via a background color */ -void PNGAPI -png_set_background(png_structp png_ptr, - png_color_16p background_color, int background_gamma_code, - int need_expand, double background_gamma) -{ - png_debug(1, "in png_set_background\n"); - if(png_ptr == NULL) return; - if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN) - { - png_warning(png_ptr, "Application must supply a known background gamma"); - return; - } - - png_ptr->transformations |= PNG_BACKGROUND; - png_memcpy(&(png_ptr->background), background_color, - png_sizeof(png_color_16)); - png_ptr->background_gamma = (float)background_gamma; - png_ptr->background_gamma_type = (png_byte)(background_gamma_code); - png_ptr->transformations |= (need_expand ? PNG_BACKGROUND_EXPAND : 0); -} -#endif - -#if defined(PNG_READ_16_TO_8_SUPPORTED) -/* strip 16 bit depth files to 8 bit depth */ -void PNGAPI -png_set_strip_16(png_structp png_ptr) -{ - png_debug(1, "in png_set_strip_16\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= PNG_16_TO_8; -} -#endif - -#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) -void PNGAPI -png_set_strip_alpha(png_structp png_ptr) -{ - png_debug(1, "in png_set_strip_alpha\n"); - if(png_ptr == NULL) return; - png_ptr->flags |= PNG_FLAG_STRIP_ALPHA; -} -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) -/* Dither file to 8 bit. Supply a palette, the current number - * of elements in the palette, the maximum number of elements - * allowed, and a histogram if possible. If the current number - * of colors is greater then the maximum number, the palette will be - * modified to fit in the maximum number. "full_dither" indicates - * whether we need a dithering cube set up for RGB images, or if we - * simply are reducing the number of colors in a paletted image. - */ - -typedef struct png_dsort_struct -{ - struct png_dsort_struct FAR * next; - png_byte left; - png_byte right; -} png_dsort; -typedef png_dsort FAR * png_dsortp; -typedef png_dsort FAR * FAR * png_dsortpp; - -void PNGAPI -png_set_dither(png_structp png_ptr, png_colorp palette, - int num_palette, int maximum_colors, png_uint_16p histogram, - int full_dither) -{ - png_debug(1, "in png_set_dither\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= PNG_DITHER; - - if (!full_dither) - { - int i; - - png_ptr->dither_index = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * png_sizeof (png_byte))); - for (i = 0; i < num_palette; i++) - png_ptr->dither_index[i] = (png_byte)i; - } - - if (num_palette > maximum_colors) - { - if (histogram != NULL) - { - /* This is easy enough, just throw out the least used colors. - Perhaps not the best solution, but good enough. */ - - int i; - - /* initialize an array to sort colors */ - png_ptr->dither_sort = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * png_sizeof (png_byte))); - - /* initialize the dither_sort array */ - for (i = 0; i < num_palette; i++) - png_ptr->dither_sort[i] = (png_byte)i; - - /* Find the least used palette entries by starting a - bubble sort, and running it until we have sorted - out enough colors. Note that we don't care about - sorting all the colors, just finding which are - least used. */ - - for (i = num_palette - 1; i >= maximum_colors; i--) - { - int done; /* to stop early if the list is pre-sorted */ - int j; - - done = 1; - for (j = 0; j < i; j++) - { - if (histogram[png_ptr->dither_sort[j]] - < histogram[png_ptr->dither_sort[j + 1]]) - { - png_byte t; - - t = png_ptr->dither_sort[j]; - png_ptr->dither_sort[j] = png_ptr->dither_sort[j + 1]; - png_ptr->dither_sort[j + 1] = t; - done = 0; - } - } - if (done) - break; - } - - /* swap the palette around, and set up a table, if necessary */ - if (full_dither) - { - int j = num_palette; - - /* put all the useful colors within the max, but don't - move the others */ - for (i = 0; i < maximum_colors; i++) - { - if ((int)png_ptr->dither_sort[i] >= maximum_colors) - { - do - j--; - while ((int)png_ptr->dither_sort[j] >= maximum_colors); - palette[i] = palette[j]; - } - } - } - else - { - int j = num_palette; - - /* move all the used colors inside the max limit, and - develop a translation table */ - for (i = 0; i < maximum_colors; i++) - { - /* only move the colors we need to */ - if ((int)png_ptr->dither_sort[i] >= maximum_colors) - { - png_color tmp_color; - - do - j--; - while ((int)png_ptr->dither_sort[j] >= maximum_colors); - - tmp_color = palette[j]; - palette[j] = palette[i]; - palette[i] = tmp_color; - /* indicate where the color went */ - png_ptr->dither_index[j] = (png_byte)i; - png_ptr->dither_index[i] = (png_byte)j; - } - } - - /* find closest color for those colors we are not using */ - for (i = 0; i < num_palette; i++) - { - if ((int)png_ptr->dither_index[i] >= maximum_colors) - { - int min_d, k, min_k, d_index; - - /* find the closest color to one we threw out */ - d_index = png_ptr->dither_index[i]; - min_d = PNG_COLOR_DIST(palette[d_index], palette[0]); - for (k = 1, min_k = 0; k < maximum_colors; k++) - { - int d; - - d = PNG_COLOR_DIST(palette[d_index], palette[k]); - - if (d < min_d) - { - min_d = d; - min_k = k; - } - } - /* point to closest color */ - png_ptr->dither_index[i] = (png_byte)min_k; - } - } - } - png_free(png_ptr, png_ptr->dither_sort); - png_ptr->dither_sort=NULL; - } - else - { - /* This is much harder to do simply (and quickly). Perhaps - we need to go through a median cut routine, but those - don't always behave themselves with only a few colors - as input. So we will just find the closest two colors, - and throw out one of them (chosen somewhat randomly). - [We don't understand this at all, so if someone wants to - work on improving it, be our guest - AED, GRP] - */ - int i; - int max_d; - int num_new_palette; - png_dsortp t; - png_dsortpp hash; - - t=NULL; - - /* initialize palette index arrays */ - png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * png_sizeof (png_byte))); - png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * png_sizeof (png_byte))); - - /* initialize the sort array */ - for (i = 0; i < num_palette; i++) - { - png_ptr->index_to_palette[i] = (png_byte)i; - png_ptr->palette_to_index[i] = (png_byte)i; - } - - hash = (png_dsortpp)png_malloc(png_ptr, (png_uint_32)(769 * - png_sizeof (png_dsortp))); - for (i = 0; i < 769; i++) - hash[i] = NULL; -/* png_memset(hash, 0, 769 * png_sizeof (png_dsortp)); */ - - num_new_palette = num_palette; - - /* initial wild guess at how far apart the farthest pixel - pair we will be eliminating will be. Larger - numbers mean more areas will be allocated, Smaller - numbers run the risk of not saving enough data, and - having to do this all over again. - - I have not done extensive checking on this number. - */ - max_d = 96; - - while (num_new_palette > maximum_colors) - { - for (i = 0; i < num_new_palette - 1; i++) - { - int j; - - for (j = i + 1; j < num_new_palette; j++) - { - int d; - - d = PNG_COLOR_DIST(palette[i], palette[j]); - - if (d <= max_d) - { - - t = (png_dsortp)png_malloc_warn(png_ptr, - (png_uint_32)(png_sizeof(png_dsort))); - if (t == NULL) - break; - t->next = hash[d]; - t->left = (png_byte)i; - t->right = (png_byte)j; - hash[d] = t; - } - } - if (t == NULL) - break; - } - - if (t != NULL) - for (i = 0; i <= max_d; i++) - { - if (hash[i] != NULL) - { - png_dsortp p; - - for (p = hash[i]; p; p = p->next) - { - if ((int)png_ptr->index_to_palette[p->left] - < num_new_palette && - (int)png_ptr->index_to_palette[p->right] - < num_new_palette) - { - int j, next_j; - - if (num_new_palette & 0x01) - { - j = p->left; - next_j = p->right; - } - else - { - j = p->right; - next_j = p->left; - } - - num_new_palette--; - palette[png_ptr->index_to_palette[j]] - = palette[num_new_palette]; - if (!full_dither) - { - int k; - - for (k = 0; k < num_palette; k++) - { - if (png_ptr->dither_index[k] == - png_ptr->index_to_palette[j]) - png_ptr->dither_index[k] = - png_ptr->index_to_palette[next_j]; - if ((int)png_ptr->dither_index[k] == - num_new_palette) - png_ptr->dither_index[k] = - png_ptr->index_to_palette[j]; - } - } - - png_ptr->index_to_palette[png_ptr->palette_to_index - [num_new_palette]] = png_ptr->index_to_palette[j]; - png_ptr->palette_to_index[png_ptr->index_to_palette[j]] - = png_ptr->palette_to_index[num_new_palette]; - - png_ptr->index_to_palette[j] = (png_byte)num_new_palette; - png_ptr->palette_to_index[num_new_palette] = (png_byte)j; - } - if (num_new_palette <= maximum_colors) - break; - } - if (num_new_palette <= maximum_colors) - break; - } - } - - for (i = 0; i < 769; i++) - { - if (hash[i] != NULL) - { - png_dsortp p = hash[i]; - while (p) - { - t = p->next; - png_free(png_ptr, p); - p = t; - } - } - hash[i] = 0; - } - max_d += 96; - } - png_free(png_ptr, hash); - png_free(png_ptr, png_ptr->palette_to_index); - png_free(png_ptr, png_ptr->index_to_palette); - png_ptr->palette_to_index=NULL; - png_ptr->index_to_palette=NULL; - } - num_palette = maximum_colors; - } - if (png_ptr->palette == NULL) - { - png_ptr->palette = palette; - } - png_ptr->num_palette = (png_uint_16)num_palette; - - if (full_dither) - { - int i; - png_bytep distance; - int total_bits = PNG_DITHER_RED_BITS + PNG_DITHER_GREEN_BITS + - PNG_DITHER_BLUE_BITS; - int num_red = (1 << PNG_DITHER_RED_BITS); - int num_green = (1 << PNG_DITHER_GREEN_BITS); - int num_blue = (1 << PNG_DITHER_BLUE_BITS); - png_size_t num_entries = ((png_size_t)1 << total_bits); - - png_ptr->palette_lookup = (png_bytep )png_malloc(png_ptr, - (png_uint_32)(num_entries * png_sizeof (png_byte))); - - png_memset(png_ptr->palette_lookup, 0, num_entries * - png_sizeof (png_byte)); - - distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries * - png_sizeof(png_byte))); - - png_memset(distance, 0xff, num_entries * png_sizeof(png_byte)); - - for (i = 0; i < num_palette; i++) - { - int ir, ig, ib; - int r = (palette[i].red >> (8 - PNG_DITHER_RED_BITS)); - int g = (palette[i].green >> (8 - PNG_DITHER_GREEN_BITS)); - int b = (palette[i].blue >> (8 - PNG_DITHER_BLUE_BITS)); - - for (ir = 0; ir < num_red; ir++) - { - /* int dr = abs(ir - r); */ - int dr = ((ir > r) ? ir - r : r - ir); - int index_r = (ir << (PNG_DITHER_BLUE_BITS + PNG_DITHER_GREEN_BITS)); - - for (ig = 0; ig < num_green; ig++) - { - /* int dg = abs(ig - g); */ - int dg = ((ig > g) ? ig - g : g - ig); - int dt = dr + dg; - int dm = ((dr > dg) ? dr : dg); - int index_g = index_r | (ig << PNG_DITHER_BLUE_BITS); - - for (ib = 0; ib < num_blue; ib++) - { - int d_index = index_g | ib; - /* int db = abs(ib - b); */ - int db = ((ib > b) ? ib - b : b - ib); - int dmax = ((dm > db) ? dm : db); - int d = dmax + dt + db; - - if (d < (int)distance[d_index]) - { - distance[d_index] = (png_byte)d; - png_ptr->palette_lookup[d_index] = (png_byte)i; - } - } - } - } - } - - png_free(png_ptr, distance); - } -} -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) -/* Transform the image from the file_gamma to the screen_gamma. We - * only do transformations on images where the file_gamma and screen_gamma - * are not close reciprocals, otherwise it slows things down slightly, and - * also needlessly introduces small errors. - * - * We will turn off gamma transformation later if no semitransparent entries - * are present in the tRNS array for palette images. We can't do it here - * because we don't necessarily have the tRNS chunk yet. - */ -void PNGAPI -png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma) -{ - png_debug(1, "in png_set_gamma\n"); - if(png_ptr == NULL) return; - if ((fabs(scrn_gamma * file_gamma - 1.0) > PNG_GAMMA_THRESHOLD) || - (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) || - (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)) - png_ptr->transformations |= PNG_GAMMA; - png_ptr->gamma = (float)file_gamma; - png_ptr->screen_gamma = (float)scrn_gamma; -} -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) -/* Expand paletted images to RGB, expand grayscale images of - * less than 8-bit depth to 8-bit depth, and expand tRNS chunks - * to alpha channels. - */ -void PNGAPI -png_set_expand(png_structp png_ptr) -{ - png_debug(1, "in png_set_expand\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); -} - -/* GRR 19990627: the following three functions currently are identical - * to png_set_expand(). However, it is entirely reasonable that someone - * might wish to expand an indexed image to RGB but *not* expand a single, - * fully transparent palette entry to a full alpha channel--perhaps instead - * convert tRNS to the grayscale/RGB format (16-bit RGB value), or replace - * the transparent color with a particular RGB value, or drop tRNS entirely. - * IOW, a future version of the library may make the transformations flag - * a bit more fine-grained, with separate bits for each of these three - * functions. - * - * More to the point, these functions make it obvious what libpng will be - * doing, whereas "expand" can (and does) mean any number of things. - * - * GRP 20060307: In libpng-1.4.0, png_set_gray_1_2_4_to_8() was modified - * to expand only the sample depth but not to expand the tRNS to alpha. - */ - -/* Expand paletted images to RGB. */ -void PNGAPI -png_set_palette_to_rgb(png_structp png_ptr) -{ - png_debug(1, "in png_set_palette_to_rgb\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); -} - -#if !defined(PNG_1_0_X) -/* Expand grayscale images of less than 8-bit depth to 8 bits. */ -void PNGAPI -png_set_expand_gray_1_2_4_to_8(png_structp png_ptr) -{ - png_debug(1, "in png_set_expand_gray_1_2_4_to_8\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= PNG_EXPAND_tRNS; -} -#endif - -#if defined(PNG_1_0_X) || defined(PNG_1_2_X) -/* Expand grayscale images of less than 8-bit depth to 8 bits. */ -/* Deprecated as of libpng-1.2.9 */ -void PNGAPI -png_set_gray_1_2_4_to_8(png_structp png_ptr) -{ - png_debug(1, "in png_set_gray_1_2_4_to_8\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); -} -#endif - - -/* Expand tRNS chunks to alpha channels. */ -void PNGAPI -png_set_tRNS_to_alpha(png_structp png_ptr) -{ - png_debug(1, "in png_set_expand\n"); - png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); -} -#endif /* defined(PNG_READ_EXPAND_SUPPORTED) */ - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) -void PNGAPI -png_set_gray_to_rgb(png_structp png_ptr) -{ - png_debug(1, "in png_set_gray_to_rgb\n"); - png_ptr->transformations |= PNG_GRAY_TO_RGB; -} -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) -#if defined(PNG_FLOATING_POINT_SUPPORTED) -/* Convert a RGB image to a grayscale of the same width. This allows us, - * for example, to convert a 24 bpp RGB image into an 8 bpp grayscale image. - */ - -void PNGAPI -png_set_rgb_to_gray(png_structp png_ptr, int error_action, double red, - double green) -{ - int red_fixed = (int)((float)red*100000.0 + 0.5); - int green_fixed = (int)((float)green*100000.0 + 0.5); - if(png_ptr == NULL) return; - png_set_rgb_to_gray_fixed(png_ptr, error_action, red_fixed, green_fixed); -} -#endif - -void PNGAPI -png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action, - png_fixed_point red, png_fixed_point green) -{ - png_debug(1, "in png_set_rgb_to_gray\n"); - if(png_ptr == NULL) return; - switch(error_action) - { - case 1: png_ptr->transformations |= PNG_RGB_TO_GRAY; - break; - case 2: png_ptr->transformations |= PNG_RGB_TO_GRAY_WARN; - break; - case 3: png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR; - } - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) -#if defined(PNG_READ_EXPAND_SUPPORTED) - png_ptr->transformations |= PNG_EXPAND; -#else - { - png_warning(png_ptr, "Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED."); - png_ptr->transformations &= ~PNG_RGB_TO_GRAY; - } -#endif - { - png_uint_16 red_int, green_int; - if(red < 0 || green < 0) - { - red_int = 6968; /* .212671 * 32768 + .5 */ - green_int = 23434; /* .715160 * 32768 + .5 */ - } - else if(red + green < 100000L) - { - red_int = (png_uint_16)(((png_uint_32)red*32768L)/100000L); - green_int = (png_uint_16)(((png_uint_32)green*32768L)/100000L); - } - else - { - png_warning(png_ptr, "ignoring out of range rgb_to_gray coefficients"); - red_int = 6968; - green_int = 23434; - } - png_ptr->rgb_to_gray_red_coeff = red_int; - png_ptr->rgb_to_gray_green_coeff = green_int; - png_ptr->rgb_to_gray_blue_coeff = (png_uint_16)(32768-red_int-green_int); - } -} -#endif - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -void PNGAPI -png_set_read_user_transform_fn(png_structp png_ptr, png_user_transform_ptr - read_user_transform_fn) -{ - png_debug(1, "in png_set_read_user_transform_fn\n"); - if(png_ptr == NULL) return; -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - png_ptr->transformations |= PNG_USER_TRANSFORM; - png_ptr->read_user_transform_fn = read_user_transform_fn; -#endif -#ifdef PNG_LEGACY_SUPPORTED - if(read_user_transform_fn) - png_warning(png_ptr, - "This version of libpng does not support user transforms"); -#endif -} -#endif - -/* Initialize everything needed for the read. This includes modifying - * the palette. - */ -void /* PRIVATE */ -png_init_read_transformations(png_structp png_ptr) -{ - png_debug(1, "in png_init_read_transformations\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if(png_ptr != NULL) -#endif - { -#if defined(PNG_READ_BACKGROUND_SUPPORTED) || defined(PNG_READ_SHIFT_SUPPORTED) \ - || defined(PNG_READ_GAMMA_SUPPORTED) - int color_type = png_ptr->color_type; -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED) - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) - /* Detect gray background and attempt to enable optimization - * for gray --> RGB case */ - /* Note: if PNG_BACKGROUND_EXPAND is set and color_type is either RGB or - * RGB_ALPHA (in which case need_expand is superfluous anyway), the - * background color might actually be gray yet not be flagged as such. - * This is not a problem for the current code, which uses - * PNG_BACKGROUND_IS_GRAY only to decide when to do the - * png_do_gray_to_rgb() transformation. - */ - if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) && - !(color_type & PNG_COLOR_MASK_COLOR)) - { - png_ptr->mode |= PNG_BACKGROUND_IS_GRAY; - } else if ((png_ptr->transformations & PNG_BACKGROUND) && - !(png_ptr->transformations & PNG_BACKGROUND_EXPAND) && - (png_ptr->transformations & PNG_GRAY_TO_RGB) && - png_ptr->background.red == png_ptr->background.green && - png_ptr->background.red == png_ptr->background.blue) - { - png_ptr->mode |= PNG_BACKGROUND_IS_GRAY; - png_ptr->background.gray = png_ptr->background.red; - } -#endif - - if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) && - (png_ptr->transformations & PNG_EXPAND)) - { - if (!(color_type & PNG_COLOR_MASK_COLOR)) /* i.e., GRAY or GRAY_ALPHA */ - { - /* expand background and tRNS chunks */ - switch (png_ptr->bit_depth) - { - case 1: - png_ptr->background.gray *= (png_uint_16)0xff; - png_ptr->background.red = png_ptr->background.green - = png_ptr->background.blue = png_ptr->background.gray; - if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) - { - png_ptr->trans_values.gray *= (png_uint_16)0xff; - png_ptr->trans_values.red = png_ptr->trans_values.green - = png_ptr->trans_values.blue = png_ptr->trans_values.gray; - } - break; - case 2: - png_ptr->background.gray *= (png_uint_16)0x55; - png_ptr->background.red = png_ptr->background.green - = png_ptr->background.blue = png_ptr->background.gray; - if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) - { - png_ptr->trans_values.gray *= (png_uint_16)0x55; - png_ptr->trans_values.red = png_ptr->trans_values.green - = png_ptr->trans_values.blue = png_ptr->trans_values.gray; - } - break; - case 4: - png_ptr->background.gray *= (png_uint_16)0x11; - png_ptr->background.red = png_ptr->background.green - = png_ptr->background.blue = png_ptr->background.gray; - if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) - { - png_ptr->trans_values.gray *= (png_uint_16)0x11; - png_ptr->trans_values.red = png_ptr->trans_values.green - = png_ptr->trans_values.blue = png_ptr->trans_values.gray; - } - break; - case 8: - case 16: - png_ptr->background.red = png_ptr->background.green - = png_ptr->background.blue = png_ptr->background.gray; - break; - } - } - else if (color_type == PNG_COLOR_TYPE_PALETTE) - { - png_ptr->background.red = - png_ptr->palette[png_ptr->background.index].red; - png_ptr->background.green = - png_ptr->palette[png_ptr->background.index].green; - png_ptr->background.blue = - png_ptr->palette[png_ptr->background.index].blue; - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_ALPHA) - { -#if defined(PNG_READ_EXPAND_SUPPORTED) - if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) -#endif - { - /* invert the alpha channel (in tRNS) unless the pixels are - going to be expanded, in which case leave it for later */ - int i,istop; - istop=(int)png_ptr->num_trans; - for (i=0; i<istop; i++) - png_ptr->trans[i] = (png_byte)(255 - png_ptr->trans[i]); - } - } -#endif - - } - } -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED) - png_ptr->background_1 = png_ptr->background; -#endif -#if defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) - - if ((color_type == PNG_COLOR_TYPE_PALETTE && png_ptr->num_trans != 0) - && (fabs(png_ptr->screen_gamma * png_ptr->gamma - 1.0) - < PNG_GAMMA_THRESHOLD)) - { - int i,k; - k=0; - for (i=0; i<png_ptr->num_trans; i++) - { - if (png_ptr->trans[i] != 0 && png_ptr->trans[i] != 0xff) - k=1; /* partial transparency is present */ - } - if (k == 0) - png_ptr->transformations &= (~PNG_GAMMA); - } - - if ((png_ptr->transformations & (PNG_GAMMA | PNG_RGB_TO_GRAY)) && - png_ptr->gamma != 0.0) - { - png_build_gamma_table(png_ptr); -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->transformations & PNG_BACKGROUND) - { - if (color_type == PNG_COLOR_TYPE_PALETTE) - { - /* could skip if no transparency and - */ - png_color back, back_1; - png_colorp palette = png_ptr->palette; - int num_palette = png_ptr->num_palette; - int i; - if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_FILE) - { - back.red = png_ptr->gamma_table[png_ptr->background.red]; - back.green = png_ptr->gamma_table[png_ptr->background.green]; - back.blue = png_ptr->gamma_table[png_ptr->background.blue]; - - back_1.red = png_ptr->gamma_to_1[png_ptr->background.red]; - back_1.green = png_ptr->gamma_to_1[png_ptr->background.green]; - back_1.blue = png_ptr->gamma_to_1[png_ptr->background.blue]; - } - else - { - double g, gs; - - switch (png_ptr->background_gamma_type) - { - case PNG_BACKGROUND_GAMMA_SCREEN: - g = (png_ptr->screen_gamma); - gs = 1.0; - break; - case PNG_BACKGROUND_GAMMA_FILE: - g = 1.0 / (png_ptr->gamma); - gs = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); - break; - case PNG_BACKGROUND_GAMMA_UNIQUE: - g = 1.0 / (png_ptr->background_gamma); - gs = 1.0 / (png_ptr->background_gamma * - png_ptr->screen_gamma); - break; - default: - g = 1.0; /* back_1 */ - gs = 1.0; /* back */ - } - - if ( fabs(gs - 1.0) < PNG_GAMMA_THRESHOLD) - { - back.red = (png_byte)png_ptr->background.red; - back.green = (png_byte)png_ptr->background.green; - back.blue = (png_byte)png_ptr->background.blue; - } - else - { - back.red = (png_byte)(pow( - (double)png_ptr->background.red/255, gs) * 255.0 + .5); - back.green = (png_byte)(pow( - (double)png_ptr->background.green/255, gs) * 255.0 + .5); - back.blue = (png_byte)(pow( - (double)png_ptr->background.blue/255, gs) * 255.0 + .5); - } - - back_1.red = (png_byte)(pow( - (double)png_ptr->background.red/255, g) * 255.0 + .5); - back_1.green = (png_byte)(pow( - (double)png_ptr->background.green/255, g) * 255.0 + .5); - back_1.blue = (png_byte)(pow( - (double)png_ptr->background.blue/255, g) * 255.0 + .5); - } - for (i = 0; i < num_palette; i++) - { - if (i < (int)png_ptr->num_trans && png_ptr->trans[i] != 0xff) - { - if (png_ptr->trans[i] == 0) - { - palette[i] = back; - } - else /* if (png_ptr->trans[i] != 0xff) */ - { - png_byte v, w; - - v = png_ptr->gamma_to_1[palette[i].red]; - png_composite(w, v, png_ptr->trans[i], back_1.red); - palette[i].red = png_ptr->gamma_from_1[w]; - - v = png_ptr->gamma_to_1[palette[i].green]; - png_composite(w, v, png_ptr->trans[i], back_1.green); - palette[i].green = png_ptr->gamma_from_1[w]; - - v = png_ptr->gamma_to_1[palette[i].blue]; - png_composite(w, v, png_ptr->trans[i], back_1.blue); - palette[i].blue = png_ptr->gamma_from_1[w]; - } - } - else - { - palette[i].red = png_ptr->gamma_table[palette[i].red]; - palette[i].green = png_ptr->gamma_table[palette[i].green]; - palette[i].blue = png_ptr->gamma_table[palette[i].blue]; - } - } - } - /* if (png_ptr->background_gamma_type!=PNG_BACKGROUND_GAMMA_UNKNOWN) */ - else - /* color_type != PNG_COLOR_TYPE_PALETTE */ - { - double m = (double)(((png_uint_32)1 << png_ptr->bit_depth) - 1); - double g = 1.0; - double gs = 1.0; - - switch (png_ptr->background_gamma_type) - { - case PNG_BACKGROUND_GAMMA_SCREEN: - g = (png_ptr->screen_gamma); - gs = 1.0; - break; - case PNG_BACKGROUND_GAMMA_FILE: - g = 1.0 / (png_ptr->gamma); - gs = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); - break; - case PNG_BACKGROUND_GAMMA_UNIQUE: - g = 1.0 / (png_ptr->background_gamma); - gs = 1.0 / (png_ptr->background_gamma * - png_ptr->screen_gamma); - break; - } - - png_ptr->background_1.gray = (png_uint_16)(pow( - (double)png_ptr->background.gray / m, g) * m + .5); - png_ptr->background.gray = (png_uint_16)(pow( - (double)png_ptr->background.gray / m, gs) * m + .5); - - if ((png_ptr->background.red != png_ptr->background.green) || - (png_ptr->background.red != png_ptr->background.blue) || - (png_ptr->background.red != png_ptr->background.gray)) - { - /* RGB or RGBA with color background */ - png_ptr->background_1.red = (png_uint_16)(pow( - (double)png_ptr->background.red / m, g) * m + .5); - png_ptr->background_1.green = (png_uint_16)(pow( - (double)png_ptr->background.green / m, g) * m + .5); - png_ptr->background_1.blue = (png_uint_16)(pow( - (double)png_ptr->background.blue / m, g) * m + .5); - png_ptr->background.red = (png_uint_16)(pow( - (double)png_ptr->background.red / m, gs) * m + .5); - png_ptr->background.green = (png_uint_16)(pow( - (double)png_ptr->background.green / m, gs) * m + .5); - png_ptr->background.blue = (png_uint_16)(pow( - (double)png_ptr->background.blue / m, gs) * m + .5); - } - else - { - /* GRAY, GRAY ALPHA, RGB, or RGBA with gray background */ - png_ptr->background_1.red = png_ptr->background_1.green - = png_ptr->background_1.blue = png_ptr->background_1.gray; - png_ptr->background.red = png_ptr->background.green - = png_ptr->background.blue = png_ptr->background.gray; - } - } - } - else - /* transformation does not include PNG_BACKGROUND */ -#endif /* PNG_READ_BACKGROUND_SUPPORTED */ - if (color_type == PNG_COLOR_TYPE_PALETTE) - { - png_colorp palette = png_ptr->palette; - int num_palette = png_ptr->num_palette; - int i; - - for (i = 0; i < num_palette; i++) - { - palette[i].red = png_ptr->gamma_table[palette[i].red]; - palette[i].green = png_ptr->gamma_table[palette[i].green]; - palette[i].blue = png_ptr->gamma_table[palette[i].blue]; - } - } - } -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - else -#endif -#endif /* PNG_READ_GAMMA_SUPPORTED && PNG_FLOATING_POINT_SUPPORTED */ -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - /* No GAMMA transformation */ - if ((png_ptr->transformations & PNG_BACKGROUND) && - (color_type == PNG_COLOR_TYPE_PALETTE)) - { - int i; - int istop = (int)png_ptr->num_trans; - png_color back; - png_colorp palette = png_ptr->palette; - - back.red = (png_byte)png_ptr->background.red; - back.green = (png_byte)png_ptr->background.green; - back.blue = (png_byte)png_ptr->background.blue; - - for (i = 0; i < istop; i++) - { - if (png_ptr->trans[i] == 0) - { - palette[i] = back; - } - else if (png_ptr->trans[i] != 0xff) - { - /* The png_composite() macro is defined in png.h */ - png_composite(palette[i].red, palette[i].red, - png_ptr->trans[i], back.red); - png_composite(palette[i].green, palette[i].green, - png_ptr->trans[i], back.green); - png_composite(palette[i].blue, palette[i].blue, - png_ptr->trans[i], back.blue); - } - } - } -#endif /* PNG_READ_BACKGROUND_SUPPORTED */ - -#if defined(PNG_READ_SHIFT_SUPPORTED) - if ((png_ptr->transformations & PNG_SHIFT) && - (color_type == PNG_COLOR_TYPE_PALETTE)) - { - png_uint_16 i; - png_uint_16 istop = png_ptr->num_palette; - int sr = 8 - png_ptr->sig_bit.red; - int sg = 8 - png_ptr->sig_bit.green; - int sb = 8 - png_ptr->sig_bit.blue; - - if (sr < 0 || sr > 8) - sr = 0; - if (sg < 0 || sg > 8) - sg = 0; - if (sb < 0 || sb > 8) - sb = 0; - for (i = 0; i < istop; i++) - { - png_ptr->palette[i].red >>= sr; - png_ptr->palette[i].green >>= sg; - png_ptr->palette[i].blue >>= sb; - } - } -#endif /* PNG_READ_SHIFT_SUPPORTED */ - } -#if !defined(PNG_READ_GAMMA_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) \ - && !defined(PNG_READ_BACKGROUND_SUPPORTED) - if(png_ptr) - return; -#endif -} - -/* Modify the info structure to reflect the transformations. The - * info should be updated so a PNG file could be written with it, - * assuming the transformations result in valid PNG data. - */ -void /* PRIVATE */ -png_read_transform_info(png_structp png_ptr, png_infop info_ptr) -{ - png_debug(1, "in png_read_transform_info\n"); -#if defined(PNG_READ_EXPAND_SUPPORTED) - if (png_ptr->transformations & PNG_EXPAND) - { - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - if (png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND_tRNS)) - info_ptr->color_type = PNG_COLOR_TYPE_RGB_ALPHA; - else - info_ptr->color_type = PNG_COLOR_TYPE_RGB; - info_ptr->bit_depth = 8; - info_ptr->num_trans = 0; - } - else - { - if (png_ptr->num_trans) - { - if (png_ptr->transformations & PNG_EXPAND_tRNS) - info_ptr->color_type |= PNG_COLOR_MASK_ALPHA; - else - info_ptr->color_type |= PNG_COLOR_MASK_COLOR; - } - if (info_ptr->bit_depth < 8) - info_ptr->bit_depth = 8; - info_ptr->num_trans = 0; - } - } -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->transformations & PNG_BACKGROUND) - { - info_ptr->color_type &= ~PNG_COLOR_MASK_ALPHA; - info_ptr->num_trans = 0; - info_ptr->background = png_ptr->background; - } -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (png_ptr->transformations & PNG_GAMMA) - { -#ifdef PNG_FLOATING_POINT_SUPPORTED - info_ptr->gamma = png_ptr->gamma; -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - info_ptr->int_gamma = png_ptr->int_gamma; -#endif - } -#endif - -#if defined(PNG_READ_16_TO_8_SUPPORTED) - if ((png_ptr->transformations & PNG_16_TO_8) && (info_ptr->bit_depth == 16)) - info_ptr->bit_depth = 8; -#endif - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) - if (png_ptr->transformations & PNG_GRAY_TO_RGB) - info_ptr->color_type |= PNG_COLOR_MASK_COLOR; -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - if (png_ptr->transformations & PNG_RGB_TO_GRAY) - info_ptr->color_type &= ~PNG_COLOR_MASK_COLOR; -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) - if (png_ptr->transformations & PNG_DITHER) - { - if (((info_ptr->color_type == PNG_COLOR_TYPE_RGB) || - (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)) && - png_ptr->palette_lookup && info_ptr->bit_depth == 8) - { - info_ptr->color_type = PNG_COLOR_TYPE_PALETTE; - } - } -#endif - -#if defined(PNG_READ_PACK_SUPPORTED) - if ((png_ptr->transformations & PNG_PACK) && (info_ptr->bit_depth < 8)) - info_ptr->bit_depth = 8; -#endif - - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - info_ptr->channels = 1; - else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR) - info_ptr->channels = 3; - else - info_ptr->channels = 1; - -#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) - if (png_ptr->flags & PNG_FLAG_STRIP_ALPHA) - info_ptr->color_type &= ~PNG_COLOR_MASK_ALPHA; -#endif - - if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA) - info_ptr->channels++; - -#if defined(PNG_READ_FILLER_SUPPORTED) - /* STRIP_ALPHA and FILLER allowed: MASK_ALPHA bit stripped above */ - if ((png_ptr->transformations & PNG_FILLER) && - ((info_ptr->color_type == PNG_COLOR_TYPE_RGB) || - (info_ptr->color_type == PNG_COLOR_TYPE_GRAY))) - { - info_ptr->channels++; - /* if adding a true alpha channel not just filler */ -#if !defined(PNG_1_0_X) - if (png_ptr->transformations & PNG_ADD_ALPHA) - info_ptr->color_type |= PNG_COLOR_MASK_ALPHA; -#endif - } -#endif - -#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) && \ -defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - if(png_ptr->transformations & PNG_USER_TRANSFORM) - { - if(info_ptr->bit_depth < png_ptr->user_transform_depth) - info_ptr->bit_depth = png_ptr->user_transform_depth; - if(info_ptr->channels < png_ptr->user_transform_channels) - info_ptr->channels = png_ptr->user_transform_channels; - } -#endif - - info_ptr->pixel_depth = (png_byte)(info_ptr->channels * - info_ptr->bit_depth); - - info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth,info_ptr->width); - -#if !defined(PNG_READ_EXPAND_SUPPORTED) - if(png_ptr) - return; -#endif -} - -/* Transform the row. The order of transformations is significant, - * and is very touchy. If you add a transformation, take care to - * decide how it fits in with the other transformations here. - */ -void /* PRIVATE */ -png_do_read_transformations(png_structp png_ptr) -{ - png_debug(1, "in png_do_read_transformations\n"); -#if !defined(PNG_USELESS_TESTS_SUPPORTED) - if (png_ptr->row_buf == NULL) - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char msg[50]; - - sprintf(msg, "NULL row buffer for row %ld, pass %d", png_ptr->row_number, - png_ptr->pass); - png_error(png_ptr, msg); -#else - png_error(png_ptr, "NULL row buffer"); -#endif - } -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) - if (png_ptr->transformations & PNG_EXPAND) - { - if (png_ptr->row_info.color_type == PNG_COLOR_TYPE_PALETTE) - { - png_do_expand_palette(&(png_ptr->row_info), png_ptr->row_buf + 1, - png_ptr->palette, png_ptr->trans, png_ptr->num_trans); - } - else - { - if (png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND_tRNS)) - png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1, - &(png_ptr->trans_values)); - else - png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1, - NULL); - } - } -#endif - -#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) - if (png_ptr->flags & PNG_FLAG_STRIP_ALPHA) - png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, - PNG_FLAG_FILLER_AFTER | (png_ptr->flags & PNG_FLAG_STRIP_ALPHA)); -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - if (png_ptr->transformations & PNG_RGB_TO_GRAY) - { - int rgb_error = - png_do_rgb_to_gray(png_ptr, &(png_ptr->row_info), png_ptr->row_buf + 1); - if(rgb_error) - { - png_ptr->rgb_to_gray_status=1; - if(png_ptr->transformations == PNG_RGB_TO_GRAY_WARN) - png_warning(png_ptr, "png_do_rgb_to_gray found nongray pixel"); - if(png_ptr->transformations == PNG_RGB_TO_GRAY_ERR) - png_error(png_ptr, "png_do_rgb_to_gray found nongray pixel"); - } - } -#endif - -/* -From Andreas Dilger e-mail to png-implement, 26 March 1998: - - In most cases, the "simple transparency" should be done prior to doing - gray-to-RGB, or you will have to test 3x as many bytes to check if a - pixel is transparent. You would also need to make sure that the - transparency information is upgraded to RGB. - - To summarize, the current flow is: - - Gray + simple transparency -> compare 1 or 2 gray bytes and composite - with background "in place" if transparent, - convert to RGB if necessary - - Gray + alpha -> composite with gray background and remove alpha bytes, - convert to RGB if necessary - - To support RGB backgrounds for gray images we need: - - Gray + simple transparency -> convert to RGB + simple transparency, compare - 3 or 6 bytes and composite with background - "in place" if transparent (3x compare/pixel - compared to doing composite with gray bkgrnd) - - Gray + alpha -> convert to RGB + alpha, composite with background and - remove alpha bytes (3x float operations/pixel - compared with composite on gray background) - - Greg's change will do this. The reason it wasn't done before is for - performance, as this increases the per-pixel operations. If we would check - in advance if the background was gray or RGB, and position the gray-to-RGB - transform appropriately, then it would save a lot of work/time. - */ - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) - /* if gray -> RGB, do so now only if background is non-gray; else do later - * for performance reasons */ - if ((png_ptr->transformations & PNG_GRAY_TO_RGB) && - !(png_ptr->mode & PNG_BACKGROUND_IS_GRAY)) - png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - if ((png_ptr->transformations & PNG_BACKGROUND) && - ((png_ptr->num_trans != 0 ) || - (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) - png_do_background(&(png_ptr->row_info), png_ptr->row_buf + 1, - &(png_ptr->trans_values), &(png_ptr->background) -#if defined(PNG_READ_GAMMA_SUPPORTED) - , &(png_ptr->background_1), - png_ptr->gamma_table, png_ptr->gamma_from_1, - png_ptr->gamma_to_1, png_ptr->gamma_16_table, - png_ptr->gamma_16_from_1, png_ptr->gamma_16_to_1, - png_ptr->gamma_shift -#endif -); -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) - if ((png_ptr->transformations & PNG_GAMMA) && -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - !((png_ptr->transformations & PNG_BACKGROUND) && - ((png_ptr->num_trans != 0) || - (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) && -#endif - (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)) - png_do_gamma(&(png_ptr->row_info), png_ptr->row_buf + 1, - png_ptr->gamma_table, png_ptr->gamma_16_table, - png_ptr->gamma_shift); -#endif - -#if defined(PNG_READ_16_TO_8_SUPPORTED) - if (png_ptr->transformations & PNG_16_TO_8) - png_do_chop(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) - if (png_ptr->transformations & PNG_DITHER) - { - png_do_dither((png_row_infop)&(png_ptr->row_info), png_ptr->row_buf + 1, - png_ptr->palette_lookup, png_ptr->dither_index); - if(png_ptr->row_info.rowbytes == (png_uint_32)0) - png_error(png_ptr, "png_do_dither returned rowbytes=0"); - } -#endif - -#if defined(PNG_READ_INVERT_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_MONO) - png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) - if (png_ptr->transformations & PNG_SHIFT) - png_do_unshift(&(png_ptr->row_info), png_ptr->row_buf + 1, - &(png_ptr->shift)); -#endif - -#if defined(PNG_READ_PACK_SUPPORTED) - if (png_ptr->transformations & PNG_PACK) - png_do_unpack(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_BGR_SUPPORTED) - if (png_ptr->transformations & PNG_BGR) - png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) - /* if gray -> RGB, do so now only if we did not do so above */ - if ((png_ptr->transformations & PNG_GRAY_TO_RGB) && - (png_ptr->mode & PNG_BACKGROUND_IS_GRAY)) - png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_FILLER_SUPPORTED) - if (png_ptr->transformations & PNG_FILLER) - png_do_read_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, - (png_uint_32)png_ptr->filler, png_ptr->flags); -#endif - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_ALPHA) - png_do_read_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) - if (png_ptr->transformations & PNG_SWAP_ALPHA) - png_do_read_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_SWAP_SUPPORTED) - if (png_ptr->transformations & PNG_SWAP_BYTES) - png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - if (png_ptr->transformations & PNG_USER_TRANSFORM) - { - if(png_ptr->read_user_transform_fn != NULL) - (*(png_ptr->read_user_transform_fn)) /* user read transform function */ - (png_ptr, /* png_ptr */ - &(png_ptr->row_info), /* row_info: */ - /* png_uint_32 width; width of row */ - /* png_uint_32 rowbytes; number of bytes in row */ - /* png_byte color_type; color type of pixels */ - /* png_byte bit_depth; bit depth of samples */ - /* png_byte channels; number of channels (1-4) */ - /* png_byte pixel_depth; bits per pixel (depth*channels) */ - png_ptr->row_buf + 1); /* start of pixel data for row */ -#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) - if(png_ptr->user_transform_depth) - png_ptr->row_info.bit_depth = png_ptr->user_transform_depth; - if(png_ptr->user_transform_channels) - png_ptr->row_info.channels = png_ptr->user_transform_channels; -#endif - png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth * - png_ptr->row_info.channels); - png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth, - png_ptr->row_info.width); - } -#endif - -} - -#if defined(PNG_READ_PACK_SUPPORTED) -/* Unpack pixels of 1, 2, or 4 bits per pixel into 1 byte per pixel, - * without changing the actual values. Thus, if you had a row with - * a bit depth of 1, you would end up with bytes that only contained - * the numbers 0 or 1. If you would rather they contain 0 and 255, use - * png_do_shift() after this. - */ -void /* PRIVATE */ -png_do_unpack(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_unpack\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL && row_info->bit_depth < 8) -#else - if (row_info->bit_depth < 8) -#endif - { - png_uint_32 i; - png_uint_32 row_width=row_info->width; - - switch (row_info->bit_depth) - { - case 1: - { - png_bytep sp = row + (png_size_t)((row_width - 1) >> 3); - png_bytep dp = row + (png_size_t)row_width - 1; - png_uint_32 shift = 7 - (int)((row_width + 7) & 0x07); - for (i = 0; i < row_width; i++) - { - *dp = (png_byte)((*sp >> shift) & 0x01); - if (shift == 7) - { - shift = 0; - sp--; - } - else - shift++; - - dp--; - } - break; - } - case 2: - { - - png_bytep sp = row + (png_size_t)((row_width - 1) >> 2); - png_bytep dp = row + (png_size_t)row_width - 1; - png_uint_32 shift = (int)((3 - ((row_width + 3) & 0x03)) << 1); - for (i = 0; i < row_width; i++) - { - *dp = (png_byte)((*sp >> shift) & 0x03); - if (shift == 6) - { - shift = 0; - sp--; - } - else - shift += 2; - - dp--; - } - break; - } - case 4: - { - png_bytep sp = row + (png_size_t)((row_width - 1) >> 1); - png_bytep dp = row + (png_size_t)row_width - 1; - png_uint_32 shift = (int)((1 - ((row_width + 1) & 0x01)) << 2); - for (i = 0; i < row_width; i++) - { - *dp = (png_byte)((*sp >> shift) & 0x0f); - if (shift == 4) - { - shift = 0; - sp--; - } - else - shift = 4; - - dp--; - } - break; - } - } - row_info->bit_depth = 8; - row_info->pixel_depth = (png_byte)(8 * row_info->channels); - row_info->rowbytes = row_width * row_info->channels; - } -} -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) -/* Reverse the effects of png_do_shift. This routine merely shifts the - * pixels back to their significant bits values. Thus, if you have - * a row of bit depth 8, but only 5 are significant, this will shift - * the values back to 0 through 31. - */ -void /* PRIVATE */ -png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits) -{ - png_debug(1, "in png_do_unshift\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && sig_bits != NULL && -#endif - row_info->color_type != PNG_COLOR_TYPE_PALETTE) - { - int shift[4]; - int channels = 0; - int c; - png_uint_16 value = 0; - png_uint_32 row_width = row_info->width; - - if (row_info->color_type & PNG_COLOR_MASK_COLOR) - { - shift[channels++] = row_info->bit_depth - sig_bits->red; - shift[channels++] = row_info->bit_depth - sig_bits->green; - shift[channels++] = row_info->bit_depth - sig_bits->blue; - } - else - { - shift[channels++] = row_info->bit_depth - sig_bits->gray; - } - if (row_info->color_type & PNG_COLOR_MASK_ALPHA) - { - shift[channels++] = row_info->bit_depth - sig_bits->alpha; - } - - for (c = 0; c < channels; c++) - { - if (shift[c] <= 0) - shift[c] = 0; - else - value = 1; - } - - if (!value) - return; - - switch (row_info->bit_depth) - { - case 2: - { - png_bytep bp; - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - - for (bp = row, i = 0; i < istop; i++) - { - *bp >>= 1; - *bp++ &= 0x55; - } - break; - } - case 4: - { - png_bytep bp = row; - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_byte mask = (png_byte)((((int)0xf0 >> shift[0]) & (int)0xf0) | - (png_byte)((int)0xf >> shift[0])); - - for (i = 0; i < istop; i++) - { - *bp >>= shift[0]; - *bp++ &= mask; - } - break; - } - case 8: - { - png_bytep bp = row; - png_uint_32 i; - png_uint_32 istop = row_width * channels; - - for (i = 0; i < istop; i++) - { - *bp++ >>= shift[i%channels]; - } - break; - } - case 16: - { - png_bytep bp = row; - png_uint_32 i; - png_uint_32 istop = channels * row_width; - - for (i = 0; i < istop; i++) - { - value = (png_uint_16)((*bp << 8) + *(bp + 1)); - value >>= shift[i%channels]; - *bp++ = (png_byte)(value >> 8); - *bp++ = (png_byte)(value & 0xff); - } - break; - } - } - } -} -#endif - -#if defined(PNG_READ_16_TO_8_SUPPORTED) -/* chop rows of bit depth 16 down to 8 */ -void /* PRIVATE */ -png_do_chop(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_chop\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL && row_info->bit_depth == 16) -#else - if (row_info->bit_depth == 16) -#endif - { - png_bytep sp = row; - png_bytep dp = row; - png_uint_32 i; - png_uint_32 istop = row_info->width * row_info->channels; - - for (i = 0; i<istop; i++, sp += 2, dp++) - { -#if defined(PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED) - /* This does a more accurate scaling of the 16-bit color - * value, rather than a simple low-byte truncation. - * - * What the ideal calculation should be: - * *dp = (((((png_uint_32)(*sp) << 8) | - * (png_uint_32)(*(sp + 1))) * 255 + 127) / (png_uint_32)65535L; - * - * GRR: no, I think this is what it really should be: - * *dp = (((((png_uint_32)(*sp) << 8) | - * (png_uint_32)(*(sp + 1))) + 128L) / (png_uint_32)257L; - * - * GRR: here's the exact calculation with shifts: - * temp = (((png_uint_32)(*sp) << 8) | (png_uint_32)(*(sp + 1))) + 128L; - * *dp = (temp - (temp >> 8)) >> 8; - * - * Approximate calculation with shift/add instead of multiply/divide: - * *dp = ((((png_uint_32)(*sp) << 8) | - * (png_uint_32)((int)(*(sp + 1)) - *sp)) + 128) >> 8; - * - * What we actually do to avoid extra shifting and conversion: - */ - - *dp = *sp + ((((int)(*(sp + 1)) - *sp) > 128) ? 1 : 0); -#else - /* Simply discard the low order byte */ - *dp = *sp; -#endif - } - row_info->bit_depth = 8; - row_info->pixel_depth = (png_byte)(8 * row_info->channels); - row_info->rowbytes = row_info->width * row_info->channels; - } -} -#endif - -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) -void /* PRIVATE */ -png_do_read_swap_alpha(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_read_swap_alpha\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif - { - png_uint_32 row_width = row_info->width; - if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - /* This converts from RGBA to ARGB */ - if (row_info->bit_depth == 8) - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_byte save; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - save = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = save; - } - } - /* This converts from RRGGBBAA to AARRGGBB */ - else - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_byte save[2]; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - save[0] = *(--sp); - save[1] = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = save[0]; - *(--dp) = save[1]; - } - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - { - /* This converts from GA to AG */ - if (row_info->bit_depth == 8) - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_byte save; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - save = *(--sp); - *(--dp) = *(--sp); - *(--dp) = save; - } - } - /* This converts from GGAA to AAGG */ - else - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_byte save[2]; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - save[0] = *(--sp); - save[1] = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = save[0]; - *(--dp) = save[1]; - } - } - } - } -} -#endif - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) -void /* PRIVATE */ -png_do_read_invert_alpha(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_read_invert_alpha\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif - { - png_uint_32 row_width = row_info->width; - if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - /* This inverts the alpha channel in RGBA */ - if (row_info->bit_depth == 8) - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - *(--dp) = (png_byte)(255 - *(--sp)); - -/* This does nothing: - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - We can replace it with: -*/ - sp-=3; - dp=sp; - } - } - /* This inverts the alpha channel in RRGGBBAA */ - else - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - *(--dp) = (png_byte)(255 - *(--sp)); - *(--dp) = (png_byte)(255 - *(--sp)); - -/* This does nothing: - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - We can replace it with: -*/ - sp-=6; - dp=sp; - } - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - { - /* This inverts the alpha channel in GA */ - if (row_info->bit_depth == 8) - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - *(--dp) = (png_byte)(255 - *(--sp)); - *(--dp) = *(--sp); - } - } - /* This inverts the alpha channel in GGAA */ - else - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - *(--dp) = (png_byte)(255 - *(--sp)); - *(--dp) = (png_byte)(255 - *(--sp)); -/* - *(--dp) = *(--sp); - *(--dp) = *(--sp); -*/ - sp-=2; - dp=sp; - } - } - } - } -} -#endif - -#if defined(PNG_READ_FILLER_SUPPORTED) -/* Add filler channel if we have RGB color */ -void /* PRIVATE */ -png_do_read_filler(png_row_infop row_info, png_bytep row, - png_uint_32 filler, png_uint_32 flags) -{ - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - png_byte hi_filler = (png_byte)((filler>>8) & 0xff); - png_byte lo_filler = (png_byte)(filler & 0xff); - - png_debug(1, "in png_do_read_filler\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - row_info->color_type == PNG_COLOR_TYPE_GRAY) - { - if(row_info->bit_depth == 8) - { - /* This changes the data from G to GX */ - if (flags & PNG_FLAG_FILLER_AFTER) - { - png_bytep sp = row + (png_size_t)row_width; - png_bytep dp = sp + (png_size_t)row_width; - for (i = 1; i < row_width; i++) - { - *(--dp) = lo_filler; - *(--dp) = *(--sp); - } - *(--dp) = lo_filler; - row_info->channels = 2; - row_info->pixel_depth = 16; - row_info->rowbytes = row_width * 2; - } - /* This changes the data from G to XG */ - else - { - png_bytep sp = row + (png_size_t)row_width; - png_bytep dp = sp + (png_size_t)row_width; - for (i = 0; i < row_width; i++) - { - *(--dp) = *(--sp); - *(--dp) = lo_filler; - } - row_info->channels = 2; - row_info->pixel_depth = 16; - row_info->rowbytes = row_width * 2; - } - } - else if(row_info->bit_depth == 16) - { - /* This changes the data from GG to GGXX */ - if (flags & PNG_FLAG_FILLER_AFTER) - { - png_bytep sp = row + (png_size_t)row_width * 2; - png_bytep dp = sp + (png_size_t)row_width * 2; - for (i = 1; i < row_width; i++) - { - *(--dp) = hi_filler; - *(--dp) = lo_filler; - *(--dp) = *(--sp); - *(--dp) = *(--sp); - } - *(--dp) = hi_filler; - *(--dp) = lo_filler; - row_info->channels = 2; - row_info->pixel_depth = 32; - row_info->rowbytes = row_width * 4; - } - /* This changes the data from GG to XXGG */ - else - { - png_bytep sp = row + (png_size_t)row_width * 2; - png_bytep dp = sp + (png_size_t)row_width * 2; - for (i = 0; i < row_width; i++) - { - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = hi_filler; - *(--dp) = lo_filler; - } - row_info->channels = 2; - row_info->pixel_depth = 32; - row_info->rowbytes = row_width * 4; - } - } - } /* COLOR_TYPE == GRAY */ - else if (row_info->color_type == PNG_COLOR_TYPE_RGB) - { - if(row_info->bit_depth == 8) - { - /* This changes the data from RGB to RGBX */ - if (flags & PNG_FLAG_FILLER_AFTER) - { - png_bytep sp = row + (png_size_t)row_width * 3; - png_bytep dp = sp + (png_size_t)row_width; - for (i = 1; i < row_width; i++) - { - *(--dp) = lo_filler; - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - } - *(--dp) = lo_filler; - row_info->channels = 4; - row_info->pixel_depth = 32; - row_info->rowbytes = row_width * 4; - } - /* This changes the data from RGB to XRGB */ - else - { - png_bytep sp = row + (png_size_t)row_width * 3; - png_bytep dp = sp + (png_size_t)row_width; - for (i = 0; i < row_width; i++) - { - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = lo_filler; - } - row_info->channels = 4; - row_info->pixel_depth = 32; - row_info->rowbytes = row_width * 4; - } - } - else if(row_info->bit_depth == 16) - { - /* This changes the data from RRGGBB to RRGGBBXX */ - if (flags & PNG_FLAG_FILLER_AFTER) - { - png_bytep sp = row + (png_size_t)row_width * 6; - png_bytep dp = sp + (png_size_t)row_width * 2; - for (i = 1; i < row_width; i++) - { - *(--dp) = hi_filler; - *(--dp) = lo_filler; - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - } - *(--dp) = hi_filler; - *(--dp) = lo_filler; - row_info->channels = 4; - row_info->pixel_depth = 64; - row_info->rowbytes = row_width * 8; - } - /* This changes the data from RRGGBB to XXRRGGBB */ - else - { - png_bytep sp = row + (png_size_t)row_width * 6; - png_bytep dp = sp + (png_size_t)row_width * 2; - for (i = 0; i < row_width; i++) - { - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = hi_filler; - *(--dp) = lo_filler; - } - row_info->channels = 4; - row_info->pixel_depth = 64; - row_info->rowbytes = row_width * 8; - } - } - } /* COLOR_TYPE == RGB */ -} -#endif - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) -/* expand grayscale files to RGB, with or without alpha */ -void /* PRIVATE */ -png_do_gray_to_rgb(png_row_infop row_info, png_bytep row) -{ - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - png_debug(1, "in png_do_gray_to_rgb\n"); - if (row_info->bit_depth >= 8 && -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - !(row_info->color_type & PNG_COLOR_MASK_COLOR)) - { - if (row_info->color_type == PNG_COLOR_TYPE_GRAY) - { - if (row_info->bit_depth == 8) - { - png_bytep sp = row + (png_size_t)row_width - 1; - png_bytep dp = sp + (png_size_t)row_width * 2; - for (i = 0; i < row_width; i++) - { - *(dp--) = *sp; - *(dp--) = *sp; - *(dp--) = *(sp--); - } - } - else - { - png_bytep sp = row + (png_size_t)row_width * 2 - 1; - png_bytep dp = sp + (png_size_t)row_width * 4; - for (i = 0; i < row_width; i++) - { - *(dp--) = *sp; - *(dp--) = *(sp - 1); - *(dp--) = *sp; - *(dp--) = *(sp - 1); - *(dp--) = *(sp--); - *(dp--) = *(sp--); - } - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - { - if (row_info->bit_depth == 8) - { - png_bytep sp = row + (png_size_t)row_width * 2 - 1; - png_bytep dp = sp + (png_size_t)row_width * 2; - for (i = 0; i < row_width; i++) - { - *(dp--) = *(sp--); - *(dp--) = *sp; - *(dp--) = *sp; - *(dp--) = *(sp--); - } - } - else - { - png_bytep sp = row + (png_size_t)row_width * 4 - 1; - png_bytep dp = sp + (png_size_t)row_width * 4; - for (i = 0; i < row_width; i++) - { - *(dp--) = *(sp--); - *(dp--) = *(sp--); - *(dp--) = *sp; - *(dp--) = *(sp - 1); - *(dp--) = *sp; - *(dp--) = *(sp - 1); - *(dp--) = *(sp--); - *(dp--) = *(sp--); - } - } - } - row_info->channels += (png_byte)2; - row_info->color_type |= PNG_COLOR_MASK_COLOR; - row_info->pixel_depth = (png_byte)(row_info->channels * - row_info->bit_depth); - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); - } -} -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) -/* reduce RGB files to grayscale, with or without alpha - * using the equation given in Poynton's ColorFAQ at - * <http://www.inforamp.net/~poynton/> - * Copyright (c) 1998-01-04 Charles Poynton poynton at inforamp.net - * - * Y = 0.212671 * R + 0.715160 * G + 0.072169 * B - * - * We approximate this with - * - * Y = 0.21268 * R + 0.7151 * G + 0.07217 * B - * - * which can be expressed with integers as - * - * Y = (6969 * R + 23434 * G + 2365 * B)/32768 - * - * The calculation is to be done in a linear colorspace. - * - * Other integer coefficents can be used via png_set_rgb_to_gray(). - */ -int /* PRIVATE */ -png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row) - -{ - png_uint_32 i; - - png_uint_32 row_width = row_info->width; - int rgb_error = 0; - - png_debug(1, "in png_do_rgb_to_gray\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - (row_info->color_type & PNG_COLOR_MASK_COLOR)) - { - png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff; - png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff; - png_uint_32 bc = png_ptr->rgb_to_gray_blue_coeff; - - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - { - if (row_info->bit_depth == 8) - { -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL) - { - png_bytep sp = row; - png_bytep dp = row; - - for (i = 0; i < row_width; i++) - { - png_byte red = png_ptr->gamma_to_1[*(sp++)]; - png_byte green = png_ptr->gamma_to_1[*(sp++)]; - png_byte blue = png_ptr->gamma_to_1[*(sp++)]; - if(red != green || red != blue) - { - rgb_error |= 1; - *(dp++) = png_ptr->gamma_from_1[ - (rc*red+gc*green+bc*blue)>>15]; - } - else - *(dp++) = *(sp-1); - } - } - else -#endif - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_byte red = *(sp++); - png_byte green = *(sp++); - png_byte blue = *(sp++); - if(red != green || red != blue) - { - rgb_error |= 1; - *(dp++) = (png_byte)((rc*red+gc*green+bc*blue)>>15); - } - else - *(dp++) = *(sp-1); - } - } - } - - else /* RGB bit_depth == 16 */ - { -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->gamma_16_to_1 != NULL && - png_ptr->gamma_16_from_1 != NULL) - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 red, green, blue, w; - - red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - - if(red == green && red == blue) - w = red; - else - { - png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff) >> - png_ptr->gamma_shift][red>>8]; - png_uint_16 green_1 = png_ptr->gamma_16_to_1[(green&0xff) >> - png_ptr->gamma_shift][green>>8]; - png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >> - png_ptr->gamma_shift][blue>>8]; - png_uint_16 gray16 = (png_uint_16)((rc*red_1 + gc*green_1 - + bc*blue_1)>>15); - w = png_ptr->gamma_16_from_1[(gray16&0xff) >> - png_ptr->gamma_shift][gray16 >> 8]; - rgb_error |= 1; - } - - *(dp++) = (png_byte)((w>>8) & 0xff); - *(dp++) = (png_byte)(w & 0xff); - } - } - else -#endif - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 red, green, blue, gray16; - - red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - - if(red != green || red != blue) - rgb_error |= 1; - gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15); - *(dp++) = (png_byte)((gray16>>8) & 0xff); - *(dp++) = (png_byte)(gray16 & 0xff); - } - } - } - } - if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - if (row_info->bit_depth == 8) - { -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL) - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_byte red = png_ptr->gamma_to_1[*(sp++)]; - png_byte green = png_ptr->gamma_to_1[*(sp++)]; - png_byte blue = png_ptr->gamma_to_1[*(sp++)]; - if(red != green || red != blue) - rgb_error |= 1; - *(dp++) = png_ptr->gamma_from_1 - [(rc*red + gc*green + bc*blue)>>15]; - *(dp++) = *(sp++); /* alpha */ - } - } - else -#endif - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_byte red = *(sp++); - png_byte green = *(sp++); - png_byte blue = *(sp++); - if(red != green || red != blue) - rgb_error |= 1; - *(dp++) = (png_byte)((rc*red + gc*green + bc*blue)>>15); - *(dp++) = *(sp++); /* alpha */ - } - } - } - else /* RGBA bit_depth == 16 */ - { -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->gamma_16_to_1 != NULL && - png_ptr->gamma_16_from_1 != NULL) - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 red, green, blue, w; - - red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - - if(red == green && red == blue) - w = red; - else - { - png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff) >> - png_ptr->gamma_shift][red>>8]; - png_uint_16 green_1 = png_ptr->gamma_16_to_1[(green&0xff) >> - png_ptr->gamma_shift][green>>8]; - png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >> - png_ptr->gamma_shift][blue>>8]; - png_uint_16 gray16 = (png_uint_16)((rc * red_1 - + gc * green_1 + bc * blue_1)>>15); - w = png_ptr->gamma_16_from_1[(gray16&0xff) >> - png_ptr->gamma_shift][gray16 >> 8]; - rgb_error |= 1; - } - - *(dp++) = (png_byte)((w>>8) & 0xff); - *(dp++) = (png_byte)(w & 0xff); - *(dp++) = *(sp++); /* alpha */ - *(dp++) = *(sp++); - } - } - else -#endif - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 red, green, blue, gray16; - red = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; - green = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; - blue = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; - if(red != green || red != blue) - rgb_error |= 1; - gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15); - *(dp++) = (png_byte)((gray16>>8) & 0xff); - *(dp++) = (png_byte)(gray16 & 0xff); - *(dp++) = *(sp++); /* alpha */ - *(dp++) = *(sp++); - } - } - } - } - row_info->channels -= (png_byte)2; - row_info->color_type &= ~PNG_COLOR_MASK_COLOR; - row_info->pixel_depth = (png_byte)(row_info->channels * - row_info->bit_depth); - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); - } - return rgb_error; -} -#endif - -/* Build a grayscale palette. Palette is assumed to be 1 << bit_depth - * large of png_color. This lets grayscale images be treated as - * paletted. Most useful for gamma correction and simplification - * of code. - */ -void PNGAPI -png_build_grayscale_palette(int bit_depth, png_colorp palette) -{ - int num_palette; - int color_inc; - int i; - int v; - - png_debug(1, "in png_do_build_grayscale_palette\n"); - if (palette == NULL) - return; - - switch (bit_depth) - { - case 1: - num_palette = 2; - color_inc = 0xff; - break; - case 2: - num_palette = 4; - color_inc = 0x55; - break; - case 4: - num_palette = 16; - color_inc = 0x11; - break; - case 8: - num_palette = 256; - color_inc = 1; - break; - default: - num_palette = 0; - color_inc = 0; - break; - } - - for (i = 0, v = 0; i < num_palette; i++, v += color_inc) - { - palette[i].red = (png_byte)v; - palette[i].green = (png_byte)v; - palette[i].blue = (png_byte)v; - } -} - -/* This function is currently unused. Do we really need it? */ -#if defined(PNG_READ_DITHER_SUPPORTED) && defined(PNG_CORRECT_PALETTE_SUPPORTED) -void /* PRIVATE */ -png_correct_palette(png_structp png_ptr, png_colorp palette, - int num_palette) -{ - png_debug(1, "in png_correct_palette\n"); -#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ - defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) - if (png_ptr->transformations & (PNG_GAMMA | PNG_BACKGROUND)) - { - png_color back, back_1; - - if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_FILE) - { - back.red = png_ptr->gamma_table[png_ptr->background.red]; - back.green = png_ptr->gamma_table[png_ptr->background.green]; - back.blue = png_ptr->gamma_table[png_ptr->background.blue]; - - back_1.red = png_ptr->gamma_to_1[png_ptr->background.red]; - back_1.green = png_ptr->gamma_to_1[png_ptr->background.green]; - back_1.blue = png_ptr->gamma_to_1[png_ptr->background.blue]; - } - else - { - double g; - - g = 1.0 / (png_ptr->background_gamma * png_ptr->screen_gamma); - - if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_SCREEN || - fabs(g - 1.0) < PNG_GAMMA_THRESHOLD) - { - back.red = png_ptr->background.red; - back.green = png_ptr->background.green; - back.blue = png_ptr->background.blue; - } - else - { - back.red = - (png_byte)(pow((double)png_ptr->background.red/255, g) * - 255.0 + 0.5); - back.green = - (png_byte)(pow((double)png_ptr->background.green/255, g) * - 255.0 + 0.5); - back.blue = - (png_byte)(pow((double)png_ptr->background.blue/255, g) * - 255.0 + 0.5); - } - - g = 1.0 / png_ptr->background_gamma; - - back_1.red = - (png_byte)(pow((double)png_ptr->background.red/255, g) * - 255.0 + 0.5); - back_1.green = - (png_byte)(pow((double)png_ptr->background.green/255, g) * - 255.0 + 0.5); - back_1.blue = - (png_byte)(pow((double)png_ptr->background.blue/255, g) * - 255.0 + 0.5); - } - - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - png_uint_32 i; - - for (i = 0; i < (png_uint_32)num_palette; i++) - { - if (i < png_ptr->num_trans && png_ptr->trans[i] == 0) - { - palette[i] = back; - } - else if (i < png_ptr->num_trans && png_ptr->trans[i] != 0xff) - { - png_byte v, w; - - v = png_ptr->gamma_to_1[png_ptr->palette[i].red]; - png_composite(w, v, png_ptr->trans[i], back_1.red); - palette[i].red = png_ptr->gamma_from_1[w]; - - v = png_ptr->gamma_to_1[png_ptr->palette[i].green]; - png_composite(w, v, png_ptr->trans[i], back_1.green); - palette[i].green = png_ptr->gamma_from_1[w]; - - v = png_ptr->gamma_to_1[png_ptr->palette[i].blue]; - png_composite(w, v, png_ptr->trans[i], back_1.blue); - palette[i].blue = png_ptr->gamma_from_1[w]; - } - else - { - palette[i].red = png_ptr->gamma_table[palette[i].red]; - palette[i].green = png_ptr->gamma_table[palette[i].green]; - palette[i].blue = png_ptr->gamma_table[palette[i].blue]; - } - } - } - else - { - int i; - - for (i = 0; i < num_palette; i++) - { - if (palette[i].red == (png_byte)png_ptr->trans_values.gray) - { - palette[i] = back; - } - else - { - palette[i].red = png_ptr->gamma_table[palette[i].red]; - palette[i].green = png_ptr->gamma_table[palette[i].green]; - palette[i].blue = png_ptr->gamma_table[palette[i].blue]; - } - } - } - } - else -#endif -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (png_ptr->transformations & PNG_GAMMA) - { - int i; - - for (i = 0; i < num_palette; i++) - { - palette[i].red = png_ptr->gamma_table[palette[i].red]; - palette[i].green = png_ptr->gamma_table[palette[i].green]; - palette[i].blue = png_ptr->gamma_table[palette[i].blue]; - } - } -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - else -#endif -#endif -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->transformations & PNG_BACKGROUND) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - png_color back; - - back.red = (png_byte)png_ptr->background.red; - back.green = (png_byte)png_ptr->background.green; - back.blue = (png_byte)png_ptr->background.blue; - - for (i = 0; i < (int)png_ptr->num_trans; i++) - { - if (png_ptr->trans[i] == 0) - { - palette[i].red = back.red; - palette[i].green = back.green; - palette[i].blue = back.blue; - } - else if (png_ptr->trans[i] != 0xff) - { - png_composite(palette[i].red, png_ptr->palette[i].red, - png_ptr->trans[i], back.red); - png_composite(palette[i].green, png_ptr->palette[i].green, - png_ptr->trans[i], back.green); - png_composite(palette[i].blue, png_ptr->palette[i].blue, - png_ptr->trans[i], back.blue); - } - } - } - else /* assume grayscale palette (what else could it be?) */ - { - int i; - - for (i = 0; i < num_palette; i++) - { - if (i == (png_byte)png_ptr->trans_values.gray) - { - palette[i].red = (png_byte)png_ptr->background.red; - palette[i].green = (png_byte)png_ptr->background.green; - palette[i].blue = (png_byte)png_ptr->background.blue; - } - } - } - } -#endif -} -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) -/* Replace any alpha or transparency with the supplied background color. - * "background" is already in the screen gamma, while "background_1" is - * at a gamma of 1.0. Paletted files have already been taken care of. - */ -void /* PRIVATE */ -png_do_background(png_row_infop row_info, png_bytep row, - png_color_16p trans_values, png_color_16p background -#if defined(PNG_READ_GAMMA_SUPPORTED) - , png_color_16p background_1, - png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1, - png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1, - png_uint_16pp gamma_16_to_1, int gamma_shift -#endif - ) -{ - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width=row_info->width; - int shift; - - png_debug(1, "in png_do_background\n"); - if (background != NULL && -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - (!(row_info->color_type & PNG_COLOR_MASK_ALPHA) || - (row_info->color_type != PNG_COLOR_TYPE_PALETTE && trans_values))) - { - switch (row_info->color_type) - { - case PNG_COLOR_TYPE_GRAY: - { - switch (row_info->bit_depth) - { - case 1: - { - sp = row; - shift = 7; - for (i = 0; i < row_width; i++) - { - if ((png_uint_16)((*sp >> shift) & 0x01) - == trans_values->gray) - { - *sp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff); - *sp |= (png_byte)(background->gray << shift); - } - if (!shift) - { - shift = 7; - sp++; - } - else - shift--; - } - break; - } - case 2: - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_table != NULL) - { - sp = row; - shift = 6; - for (i = 0; i < row_width; i++) - { - if ((png_uint_16)((*sp >> shift) & 0x03) - == trans_values->gray) - { - *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); - *sp |= (png_byte)(background->gray << shift); - } - else - { - png_byte p = (png_byte)((*sp >> shift) & 0x03); - png_byte g = (png_byte)((gamma_table [p | (p << 2) | - (p << 4) | (p << 6)] >> 6) & 0x03); - *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); - *sp |= (png_byte)(g << shift); - } - if (!shift) - { - shift = 6; - sp++; - } - else - shift -= 2; - } - } - else -#endif - { - sp = row; - shift = 6; - for (i = 0; i < row_width; i++) - { - if ((png_uint_16)((*sp >> shift) & 0x03) - == trans_values->gray) - { - *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); - *sp |= (png_byte)(background->gray << shift); - } - if (!shift) - { - shift = 6; - sp++; - } - else - shift -= 2; - } - } - break; - } - case 4: - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_table != NULL) - { - sp = row; - shift = 4; - for (i = 0; i < row_width; i++) - { - if ((png_uint_16)((*sp >> shift) & 0x0f) - == trans_values->gray) - { - *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); - *sp |= (png_byte)(background->gray << shift); - } - else - { - png_byte p = (png_byte)((*sp >> shift) & 0x0f); - png_byte g = (png_byte)((gamma_table[p | - (p << 4)] >> 4) & 0x0f); - *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); - *sp |= (png_byte)(g << shift); - } - if (!shift) - { - shift = 4; - sp++; - } - else - shift -= 4; - } - } - else -#endif - { - sp = row; - shift = 4; - for (i = 0; i < row_width; i++) - { - if ((png_uint_16)((*sp >> shift) & 0x0f) - == trans_values->gray) - { - *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); - *sp |= (png_byte)(background->gray << shift); - } - if (!shift) - { - shift = 4; - sp++; - } - else - shift -= 4; - } - } - break; - } - case 8: - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_table != NULL) - { - sp = row; - for (i = 0; i < row_width; i++, sp++) - { - if (*sp == trans_values->gray) - { - *sp = (png_byte)background->gray; - } - else - { - *sp = gamma_table[*sp]; - } - } - } - else -#endif - { - sp = row; - for (i = 0; i < row_width; i++, sp++) - { - if (*sp == trans_values->gray) - { - *sp = (png_byte)background->gray; - } - } - } - break; - } - case 16: - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_16 != NULL) - { - sp = row; - for (i = 0; i < row_width; i++, sp += 2) - { - png_uint_16 v; - - v = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - if (v == trans_values->gray) - { - /* background is already in screen gamma */ - *sp = (png_byte)((background->gray >> 8) & 0xff); - *(sp + 1) = (png_byte)(background->gray & 0xff); - } - else - { - v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - } - } - } - else -#endif - { - sp = row; - for (i = 0; i < row_width; i++, sp += 2) - { - png_uint_16 v; - - v = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - if (v == trans_values->gray) - { - *sp = (png_byte)((background->gray >> 8) & 0xff); - *(sp + 1) = (png_byte)(background->gray & 0xff); - } - } - } - break; - } - } - break; - } - case PNG_COLOR_TYPE_RGB: - { - if (row_info->bit_depth == 8) - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_table != NULL) - { - sp = row; - for (i = 0; i < row_width; i++, sp += 3) - { - if (*sp == trans_values->red && - *(sp + 1) == trans_values->green && - *(sp + 2) == trans_values->blue) - { - *sp = (png_byte)background->red; - *(sp + 1) = (png_byte)background->green; - *(sp + 2) = (png_byte)background->blue; - } - else - { - *sp = gamma_table[*sp]; - *(sp + 1) = gamma_table[*(sp + 1)]; - *(sp + 2) = gamma_table[*(sp + 2)]; - } - } - } - else -#endif - { - sp = row; - for (i = 0; i < row_width; i++, sp += 3) - { - if (*sp == trans_values->red && - *(sp + 1) == trans_values->green && - *(sp + 2) == trans_values->blue) - { - *sp = (png_byte)background->red; - *(sp + 1) = (png_byte)background->green; - *(sp + 2) = (png_byte)background->blue; - } - } - } - } - else /* if (row_info->bit_depth == 16) */ - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_16 != NULL) - { - sp = row; - for (i = 0; i < row_width; i++, sp += 6) - { - png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - png_uint_16 g = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); - png_uint_16 b = (png_uint_16)(((*(sp+4)) << 8) + *(sp+5)); - if (r == trans_values->red && g == trans_values->green && - b == trans_values->blue) - { - /* background is already in screen gamma */ - *sp = (png_byte)((background->red >> 8) & 0xff); - *(sp + 1) = (png_byte)(background->red & 0xff); - *(sp + 2) = (png_byte)((background->green >> 8) & 0xff); - *(sp + 3) = (png_byte)(background->green & 0xff); - *(sp + 4) = (png_byte)((background->blue >> 8) & 0xff); - *(sp + 5) = (png_byte)(background->blue & 0xff); - } - else - { - png_uint_16 v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)]; - *(sp + 2) = (png_byte)((v >> 8) & 0xff); - *(sp + 3) = (png_byte)(v & 0xff); - v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)]; - *(sp + 4) = (png_byte)((v >> 8) & 0xff); - *(sp + 5) = (png_byte)(v & 0xff); - } - } - } - else -#endif - { - sp = row; - for (i = 0; i < row_width; i++, sp += 6) - { - png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp+1)); - png_uint_16 g = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); - png_uint_16 b = (png_uint_16)(((*(sp+4)) << 8) + *(sp+5)); - - if (r == trans_values->red && g == trans_values->green && - b == trans_values->blue) - { - *sp = (png_byte)((background->red >> 8) & 0xff); - *(sp + 1) = (png_byte)(background->red & 0xff); - *(sp + 2) = (png_byte)((background->green >> 8) & 0xff); - *(sp + 3) = (png_byte)(background->green & 0xff); - *(sp + 4) = (png_byte)((background->blue >> 8) & 0xff); - *(sp + 5) = (png_byte)(background->blue & 0xff); - } - } - } - } - break; - } - case PNG_COLOR_TYPE_GRAY_ALPHA: - { - if (row_info->bit_depth == 8) - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_to_1 != NULL && gamma_from_1 != NULL && - gamma_table != NULL) - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 2, dp++) - { - png_uint_16 a = *(sp + 1); - - if (a == 0xff) - { - *dp = gamma_table[*sp]; - } - else if (a == 0) - { - /* background is already in screen gamma */ - *dp = (png_byte)background->gray; - } - else - { - png_byte v, w; - - v = gamma_to_1[*sp]; - png_composite(w, v, a, background_1->gray); - *dp = gamma_from_1[w]; - } - } - } - else -#endif - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 2, dp++) - { - png_byte a = *(sp + 1); - - if (a == 0xff) - { - *dp = *sp; - } -#if defined(PNG_READ_GAMMA_SUPPORTED) - else if (a == 0) - { - *dp = (png_byte)background->gray; - } - else - { - png_composite(*dp, *sp, a, background_1->gray); - } -#else - *dp = (png_byte)background->gray; -#endif - } - } - } - else /* if (png_ptr->bit_depth == 16) */ - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_16 != NULL && gamma_16_from_1 != NULL && - gamma_16_to_1 != NULL) - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 4, dp += 2) - { - png_uint_16 a = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); - - if (a == (png_uint_16)0xffff) - { - png_uint_16 v; - - v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; - *dp = (png_byte)((v >> 8) & 0xff); - *(dp + 1) = (png_byte)(v & 0xff); - } -#if defined(PNG_READ_GAMMA_SUPPORTED) - else if (a == 0) -#else - else -#endif - { - /* background is already in screen gamma */ - *dp = (png_byte)((background->gray >> 8) & 0xff); - *(dp + 1) = (png_byte)(background->gray & 0xff); - } -#if defined(PNG_READ_GAMMA_SUPPORTED) - else - { - png_uint_16 g, v, w; - - g = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp]; - png_composite_16(v, g, a, background_1->gray); - w = gamma_16_from_1[(v&0xff) >> gamma_shift][v >> 8]; - *dp = (png_byte)((w >> 8) & 0xff); - *(dp + 1) = (png_byte)(w & 0xff); - } -#endif - } - } - else -#endif - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 4, dp += 2) - { - png_uint_16 a = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); - if (a == (png_uint_16)0xffff) - { - png_memcpy(dp, sp, 2); - } -#if defined(PNG_READ_GAMMA_SUPPORTED) - else if (a == 0) -#else - else -#endif - { - *dp = (png_byte)((background->gray >> 8) & 0xff); - *(dp + 1) = (png_byte)(background->gray & 0xff); - } -#if defined(PNG_READ_GAMMA_SUPPORTED) - else - { - png_uint_16 g, v; - - g = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - png_composite_16(v, g, a, background_1->gray); - *dp = (png_byte)((v >> 8) & 0xff); - *(dp + 1) = (png_byte)(v & 0xff); - } -#endif - } - } - } - break; - } - case PNG_COLOR_TYPE_RGB_ALPHA: - { - if (row_info->bit_depth == 8) - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_to_1 != NULL && gamma_from_1 != NULL && - gamma_table != NULL) - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 4, dp += 3) - { - png_byte a = *(sp + 3); - - if (a == 0xff) - { - *dp = gamma_table[*sp]; - *(dp + 1) = gamma_table[*(sp + 1)]; - *(dp + 2) = gamma_table[*(sp + 2)]; - } - else if (a == 0) - { - /* background is already in screen gamma */ - *dp = (png_byte)background->red; - *(dp + 1) = (png_byte)background->green; - *(dp + 2) = (png_byte)background->blue; - } - else - { - png_byte v, w; - - v = gamma_to_1[*sp]; - png_composite(w, v, a, background_1->red); - *dp = gamma_from_1[w]; - v = gamma_to_1[*(sp + 1)]; - png_composite(w, v, a, background_1->green); - *(dp + 1) = gamma_from_1[w]; - v = gamma_to_1[*(sp + 2)]; - png_composite(w, v, a, background_1->blue); - *(dp + 2) = gamma_from_1[w]; - } - } - } - else -#endif - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 4, dp += 3) - { - png_byte a = *(sp + 3); - - if (a == 0xff) - { - *dp = *sp; - *(dp + 1) = *(sp + 1); - *(dp + 2) = *(sp + 2); - } - else if (a == 0) - { - *dp = (png_byte)background->red; - *(dp + 1) = (png_byte)background->green; - *(dp + 2) = (png_byte)background->blue; - } - else - { - png_composite(*dp, *sp, a, background->red); - png_composite(*(dp + 1), *(sp + 1), a, - background->green); - png_composite(*(dp + 2), *(sp + 2), a, - background->blue); - } - } - } - } - else /* if (row_info->bit_depth == 16) */ - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_16 != NULL && gamma_16_from_1 != NULL && - gamma_16_to_1 != NULL) - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 8, dp += 6) - { - png_uint_16 a = (png_uint_16)(((png_uint_16)(*(sp + 6)) - << 8) + (png_uint_16)(*(sp + 7))); - if (a == (png_uint_16)0xffff) - { - png_uint_16 v; - - v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; - *dp = (png_byte)((v >> 8) & 0xff); - *(dp + 1) = (png_byte)(v & 0xff); - v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)]; - *(dp + 2) = (png_byte)((v >> 8) & 0xff); - *(dp + 3) = (png_byte)(v & 0xff); - v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)]; - *(dp + 4) = (png_byte)((v >> 8) & 0xff); - *(dp + 5) = (png_byte)(v & 0xff); - } - else if (a == 0) - { - /* background is already in screen gamma */ - *dp = (png_byte)((background->red >> 8) & 0xff); - *(dp + 1) = (png_byte)(background->red & 0xff); - *(dp + 2) = (png_byte)((background->green >> 8) & 0xff); - *(dp + 3) = (png_byte)(background->green & 0xff); - *(dp + 4) = (png_byte)((background->blue >> 8) & 0xff); - *(dp + 5) = (png_byte)(background->blue & 0xff); - } - else - { - png_uint_16 v, w, x; - - v = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp]; - png_composite_16(w, v, a, background_1->red); - x = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8]; - *dp = (png_byte)((x >> 8) & 0xff); - *(dp + 1) = (png_byte)(x & 0xff); - v = gamma_16_to_1[*(sp + 3) >> gamma_shift][*(sp + 2)]; - png_composite_16(w, v, a, background_1->green); - x = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8]; - *(dp + 2) = (png_byte)((x >> 8) & 0xff); - *(dp + 3) = (png_byte)(x & 0xff); - v = gamma_16_to_1[*(sp + 5) >> gamma_shift][*(sp + 4)]; - png_composite_16(w, v, a, background_1->blue); - x = gamma_16_from_1[(w & 0xff) >> gamma_shift][w >> 8]; - *(dp + 4) = (png_byte)((x >> 8) & 0xff); - *(dp + 5) = (png_byte)(x & 0xff); - } - } - } - else -#endif - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 8, dp += 6) - { - png_uint_16 a = (png_uint_16)(((png_uint_16)(*(sp + 6)) - << 8) + (png_uint_16)(*(sp + 7))); - if (a == (png_uint_16)0xffff) - { - png_memcpy(dp, sp, 6); - } - else if (a == 0) - { - *dp = (png_byte)((background->red >> 8) & 0xff); - *(dp + 1) = (png_byte)(background->red & 0xff); - *(dp + 2) = (png_byte)((background->green >> 8) & 0xff); - *(dp + 3) = (png_byte)(background->green & 0xff); - *(dp + 4) = (png_byte)((background->blue >> 8) & 0xff); - *(dp + 5) = (png_byte)(background->blue & 0xff); - } - else - { - png_uint_16 v; - - png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - png_uint_16 g = (png_uint_16)(((*(sp + 2)) << 8) - + *(sp + 3)); - png_uint_16 b = (png_uint_16)(((*(sp + 4)) << 8) - + *(sp + 5)); - - png_composite_16(v, r, a, background->red); - *dp = (png_byte)((v >> 8) & 0xff); - *(dp + 1) = (png_byte)(v & 0xff); - png_composite_16(v, g, a, background->green); - *(dp + 2) = (png_byte)((v >> 8) & 0xff); - *(dp + 3) = (png_byte)(v & 0xff); - png_composite_16(v, b, a, background->blue); - *(dp + 4) = (png_byte)((v >> 8) & 0xff); - *(dp + 5) = (png_byte)(v & 0xff); - } - } - } - } - break; - } - } - - if (row_info->color_type & PNG_COLOR_MASK_ALPHA) - { - row_info->color_type &= ~PNG_COLOR_MASK_ALPHA; - row_info->channels--; - row_info->pixel_depth = (png_byte)(row_info->channels * - row_info->bit_depth); - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); - } - } -} -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) -/* Gamma correct the image, avoiding the alpha channel. Make sure - * you do this after you deal with the transparency issue on grayscale - * or RGB images. If your bit depth is 8, use gamma_table, if it - * is 16, use gamma_16_table and gamma_shift. Build these with - * build_gamma_table(). - */ -void /* PRIVATE */ -png_do_gamma(png_row_infop row_info, png_bytep row, - png_bytep gamma_table, png_uint_16pp gamma_16_table, - int gamma_shift) -{ - png_bytep sp; - png_uint_32 i; - png_uint_32 row_width=row_info->width; - - png_debug(1, "in png_do_gamma\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - ((row_info->bit_depth <= 8 && gamma_table != NULL) || - (row_info->bit_depth == 16 && gamma_16_table != NULL))) - { - switch (row_info->color_type) - { - case PNG_COLOR_TYPE_RGB: - { - if (row_info->bit_depth == 8) - { - sp = row; - for (i = 0; i < row_width; i++) - { - *sp = gamma_table[*sp]; - sp++; - *sp = gamma_table[*sp]; - sp++; - *sp = gamma_table[*sp]; - sp++; - } - } - else /* if (row_info->bit_depth == 16) */ - { - sp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 v; - - v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - } - } - break; - } - case PNG_COLOR_TYPE_RGB_ALPHA: - { - if (row_info->bit_depth == 8) - { - sp = row; - for (i = 0; i < row_width; i++) - { - *sp = gamma_table[*sp]; - sp++; - *sp = gamma_table[*sp]; - sp++; - *sp = gamma_table[*sp]; - sp++; - sp++; - } - } - else /* if (row_info->bit_depth == 16) */ - { - sp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 4; - } - } - break; - } - case PNG_COLOR_TYPE_GRAY_ALPHA: - { - if (row_info->bit_depth == 8) - { - sp = row; - for (i = 0; i < row_width; i++) - { - *sp = gamma_table[*sp]; - sp += 2; - } - } - else /* if (row_info->bit_depth == 16) */ - { - sp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 4; - } - } - break; - } - case PNG_COLOR_TYPE_GRAY: - { - if (row_info->bit_depth == 2) - { - sp = row; - for (i = 0; i < row_width; i += 4) - { - int a = *sp & 0xc0; - int b = *sp & 0x30; - int c = *sp & 0x0c; - int d = *sp & 0x03; - - *sp = (png_byte)( - ((((int)gamma_table[a|(a>>2)|(a>>4)|(a>>6)]) ) & 0xc0)| - ((((int)gamma_table[(b<<2)|b|(b>>2)|(b>>4)])>>2) & 0x30)| - ((((int)gamma_table[(c<<4)|(c<<2)|c|(c>>2)])>>4) & 0x0c)| - ((((int)gamma_table[(d<<6)|(d<<4)|(d<<2)|d])>>6) )); - sp++; - } - } - if (row_info->bit_depth == 4) - { - sp = row; - for (i = 0; i < row_width; i += 2) - { - int msb = *sp & 0xf0; - int lsb = *sp & 0x0f; - - *sp = (png_byte)((((int)gamma_table[msb | (msb >> 4)]) & 0xf0) - | (((int)gamma_table[(lsb << 4) | lsb]) >> 4)); - sp++; - } - } - else if (row_info->bit_depth == 8) - { - sp = row; - for (i = 0; i < row_width; i++) - { - *sp = gamma_table[*sp]; - sp++; - } - } - else if (row_info->bit_depth == 16) - { - sp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - } - } - break; - } - } - } -} -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) -/* Expands a palette row to an RGB or RGBA row depending - * upon whether you supply trans and num_trans. - */ -void /* PRIVATE */ -png_do_expand_palette(png_row_infop row_info, png_bytep row, - png_colorp palette, png_bytep trans, int num_trans) -{ - int shift, value; - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width=row_info->width; - - png_debug(1, "in png_do_expand_palette\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - row_info->color_type == PNG_COLOR_TYPE_PALETTE) - { - if (row_info->bit_depth < 8) - { - switch (row_info->bit_depth) - { - case 1: - { - sp = row + (png_size_t)((row_width - 1) >> 3); - dp = row + (png_size_t)row_width - 1; - shift = 7 - (int)((row_width + 7) & 0x07); - for (i = 0; i < row_width; i++) - { - if ((*sp >> shift) & 0x01) - *dp = 1; - else - *dp = 0; - if (shift == 7) - { - shift = 0; - sp--; - } - else - shift++; - - dp--; - } - break; - } - case 2: - { - sp = row + (png_size_t)((row_width - 1) >> 2); - dp = row + (png_size_t)row_width - 1; - shift = (int)((3 - ((row_width + 3) & 0x03)) << 1); - for (i = 0; i < row_width; i++) - { - value = (*sp >> shift) & 0x03; - *dp = (png_byte)value; - if (shift == 6) - { - shift = 0; - sp--; - } - else - shift += 2; - - dp--; - } - break; - } - case 4: - { - sp = row + (png_size_t)((row_width - 1) >> 1); - dp = row + (png_size_t)row_width - 1; - shift = (int)((row_width & 0x01) << 2); - for (i = 0; i < row_width; i++) - { - value = (*sp >> shift) & 0x0f; - *dp = (png_byte)value; - if (shift == 4) - { - shift = 0; - sp--; - } - else - shift += 4; - - dp--; - } - break; - } - } - row_info->bit_depth = 8; - row_info->pixel_depth = 8; - row_info->rowbytes = row_width; - } - switch (row_info->bit_depth) - { - case 8: - { - if (trans != NULL) - { - sp = row + (png_size_t)row_width - 1; - dp = row + (png_size_t)(row_width << 2) - 1; - - for (i = 0; i < row_width; i++) - { - if ((int)(*sp) >= num_trans) - *dp-- = 0xff; - else - *dp-- = trans[*sp]; - *dp-- = palette[*sp].blue; - *dp-- = palette[*sp].green; - *dp-- = palette[*sp].red; - sp--; - } - row_info->bit_depth = 8; - row_info->pixel_depth = 32; - row_info->rowbytes = row_width * 4; - row_info->color_type = 6; - row_info->channels = 4; - } - else - { - sp = row + (png_size_t)row_width - 1; - dp = row + (png_size_t)(row_width * 3) - 1; - - for (i = 0; i < row_width; i++) - { - *dp-- = palette[*sp].blue; - *dp-- = palette[*sp].green; - *dp-- = palette[*sp].red; - sp--; - } - row_info->bit_depth = 8; - row_info->pixel_depth = 24; - row_info->rowbytes = row_width * 3; - row_info->color_type = 2; - row_info->channels = 3; - } - break; - } - } - } -} - -/* If the bit depth < 8, it is expanded to 8. Also, if the already - * expanded transparency value is supplied, an alpha channel is built. - */ -void /* PRIVATE */ -png_do_expand(png_row_infop row_info, png_bytep row, - png_color_16p trans_value) -{ - int shift, value; - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width=row_info->width; - - png_debug(1, "in png_do_expand\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif - { - if (row_info->color_type == PNG_COLOR_TYPE_GRAY) - { - png_uint_16 gray = (png_uint_16)(trans_value ? trans_value->gray : 0); - - if (row_info->bit_depth < 8) - { - switch (row_info->bit_depth) - { - case 1: - { - gray = (png_uint_16)(gray*0xff); - sp = row + (png_size_t)((row_width - 1) >> 3); - dp = row + (png_size_t)row_width - 1; - shift = 7 - (int)((row_width + 7) & 0x07); - for (i = 0; i < row_width; i++) - { - if ((*sp >> shift) & 0x01) - *dp = 0xff; - else - *dp = 0; - if (shift == 7) - { - shift = 0; - sp--; - } - else - shift++; - - dp--; - } - break; - } - case 2: - { - gray = (png_uint_16)(gray*0x55); - sp = row + (png_size_t)((row_width - 1) >> 2); - dp = row + (png_size_t)row_width - 1; - shift = (int)((3 - ((row_width + 3) & 0x03)) << 1); - for (i = 0; i < row_width; i++) - { - value = (*sp >> shift) & 0x03; - *dp = (png_byte)(value | (value << 2) | (value << 4) | - (value << 6)); - if (shift == 6) - { - shift = 0; - sp--; - } - else - shift += 2; - - dp--; - } - break; - } - case 4: - { - gray = (png_uint_16)(gray*0x11); - sp = row + (png_size_t)((row_width - 1) >> 1); - dp = row + (png_size_t)row_width - 1; - shift = (int)((1 - ((row_width + 1) & 0x01)) << 2); - for (i = 0; i < row_width; i++) - { - value = (*sp >> shift) & 0x0f; - *dp = (png_byte)(value | (value << 4)); - if (shift == 4) - { - shift = 0; - sp--; - } - else - shift = 4; - - dp--; - } - break; - } - } - row_info->bit_depth = 8; - row_info->pixel_depth = 8; - row_info->rowbytes = row_width; - } - - if (trans_value != NULL) - { - if (row_info->bit_depth == 8) - { - sp = row + (png_size_t)row_width - 1; - dp = row + (png_size_t)(row_width << 1) - 1; - for (i = 0; i < row_width; i++) - { - if (*sp == gray) - *dp-- = 0; - else - *dp-- = 0xff; - *dp-- = *sp--; - } - } - else if (row_info->bit_depth == 16) - { - sp = row + row_info->rowbytes - 1; - dp = row + (row_info->rowbytes << 1) - 1; - for (i = 0; i < row_width; i++) - { - if (((png_uint_16)*(sp) | - ((png_uint_16)*(sp - 1) << 8)) == gray) - { - *dp-- = 0; - *dp-- = 0; - } - else - { - *dp-- = 0xff; - *dp-- = 0xff; - } - *dp-- = *sp--; - *dp-- = *sp--; - } - } - row_info->color_type = PNG_COLOR_TYPE_GRAY_ALPHA; - row_info->channels = 2; - row_info->pixel_depth = (png_byte)(row_info->bit_depth << 1); - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, - row_width); - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_RGB && trans_value) - { - if (row_info->bit_depth == 8) - { - sp = row + (png_size_t)row_info->rowbytes - 1; - dp = row + (png_size_t)(row_width << 2) - 1; - for (i = 0; i < row_width; i++) - { - if (*(sp - 2) == trans_value->red && - *(sp - 1) == trans_value->green && - *(sp - 0) == trans_value->blue) - *dp-- = 0; - else - *dp-- = 0xff; - *dp-- = *sp--; - *dp-- = *sp--; - *dp-- = *sp--; - } - } - else if (row_info->bit_depth == 16) - { - sp = row + row_info->rowbytes - 1; - dp = row + (png_size_t)(row_width << 3) - 1; - for (i = 0; i < row_width; i++) - { - if ((((png_uint_16)*(sp - 4) | - ((png_uint_16)*(sp - 5) << 8)) == trans_value->red) && - (((png_uint_16)*(sp - 2) | - ((png_uint_16)*(sp - 3) << 8)) == trans_value->green) && - (((png_uint_16)*(sp - 0) | - ((png_uint_16)*(sp - 1) << 8)) == trans_value->blue)) - { - *dp-- = 0; - *dp-- = 0; - } - else - { - *dp-- = 0xff; - *dp-- = 0xff; - } - *dp-- = *sp--; - *dp-- = *sp--; - *dp-- = *sp--; - *dp-- = *sp--; - *dp-- = *sp--; - *dp-- = *sp--; - } - } - row_info->color_type = PNG_COLOR_TYPE_RGB_ALPHA; - row_info->channels = 4; - row_info->pixel_depth = (png_byte)(row_info->bit_depth << 2); - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); - } - } -} -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) -void /* PRIVATE */ -png_do_dither(png_row_infop row_info, png_bytep row, - png_bytep palette_lookup, png_bytep dither_lookup) -{ - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width=row_info->width; - - png_debug(1, "in png_do_dither\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif - { - if (row_info->color_type == PNG_COLOR_TYPE_RGB && - palette_lookup && row_info->bit_depth == 8) - { - int r, g, b, p; - sp = row; - dp = row; - for (i = 0; i < row_width; i++) - { - r = *sp++; - g = *sp++; - b = *sp++; - - /* this looks real messy, but the compiler will reduce - it down to a reasonable formula. For example, with - 5 bits per color, we get: - p = (((r >> 3) & 0x1f) << 10) | - (((g >> 3) & 0x1f) << 5) | - ((b >> 3) & 0x1f); - */ - p = (((r >> (8 - PNG_DITHER_RED_BITS)) & - ((1 << PNG_DITHER_RED_BITS) - 1)) << - (PNG_DITHER_GREEN_BITS + PNG_DITHER_BLUE_BITS)) | - (((g >> (8 - PNG_DITHER_GREEN_BITS)) & - ((1 << PNG_DITHER_GREEN_BITS) - 1)) << - (PNG_DITHER_BLUE_BITS)) | - ((b >> (8 - PNG_DITHER_BLUE_BITS)) & - ((1 << PNG_DITHER_BLUE_BITS) - 1)); - - *dp++ = palette_lookup[p]; - } - row_info->color_type = PNG_COLOR_TYPE_PALETTE; - row_info->channels = 1; - row_info->pixel_depth = row_info->bit_depth; - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); - } - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA && - palette_lookup != NULL && row_info->bit_depth == 8) - { - int r, g, b, p; - sp = row; - dp = row; - for (i = 0; i < row_width; i++) - { - r = *sp++; - g = *sp++; - b = *sp++; - sp++; - - p = (((r >> (8 - PNG_DITHER_RED_BITS)) & - ((1 << PNG_DITHER_RED_BITS) - 1)) << - (PNG_DITHER_GREEN_BITS + PNG_DITHER_BLUE_BITS)) | - (((g >> (8 - PNG_DITHER_GREEN_BITS)) & - ((1 << PNG_DITHER_GREEN_BITS) - 1)) << - (PNG_DITHER_BLUE_BITS)) | - ((b >> (8 - PNG_DITHER_BLUE_BITS)) & - ((1 << PNG_DITHER_BLUE_BITS) - 1)); - - *dp++ = palette_lookup[p]; - } - row_info->color_type = PNG_COLOR_TYPE_PALETTE; - row_info->channels = 1; - row_info->pixel_depth = row_info->bit_depth; - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); - } - else if (row_info->color_type == PNG_COLOR_TYPE_PALETTE && - dither_lookup && row_info->bit_depth == 8) - { - sp = row; - for (i = 0; i < row_width; i++, sp++) - { - *sp = dither_lookup[*sp]; - } - } - } -} -#endif - -#ifdef PNG_FLOATING_POINT_SUPPORTED -#if defined(PNG_READ_GAMMA_SUPPORTED) -static int png_gamma_shift[] = - {0x10, 0x21, 0x42, 0x84, 0x110, 0x248, 0x550, 0xff0, 0x00}; - -/* We build the 8- or 16-bit gamma tables here. Note that for 16-bit - * tables, we don't make a full table if we are reducing to 8-bit in - * the future. Note also how the gamma_16 tables are segmented so that - * we don't need to allocate > 64K chunks for a full 16-bit table. - */ -void /* PRIVATE */ -png_build_gamma_table(png_structp png_ptr) -{ - png_debug(1, "in png_build_gamma_table\n"); - - if (png_ptr->bit_depth <= 8) - { - int i; - double g; - - if (png_ptr->screen_gamma > .000001) - g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); - else - g = 1.0; - - png_ptr->gamma_table = (png_bytep)png_malloc(png_ptr, - (png_uint_32)256); - - for (i = 0; i < 256; i++) - { - png_ptr->gamma_table[i] = (png_byte)(pow((double)i / 255.0, - g) * 255.0 + .5); - } - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ - defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - if (png_ptr->transformations & ((PNG_BACKGROUND) | PNG_RGB_TO_GRAY)) - { - - g = 1.0 / (png_ptr->gamma); - - png_ptr->gamma_to_1 = (png_bytep)png_malloc(png_ptr, - (png_uint_32)256); - - for (i = 0; i < 256; i++) - { - png_ptr->gamma_to_1[i] = (png_byte)(pow((double)i / 255.0, - g) * 255.0 + .5); - } - - - png_ptr->gamma_from_1 = (png_bytep)png_malloc(png_ptr, - (png_uint_32)256); - - if(png_ptr->screen_gamma > 0.000001) - g = 1.0 / png_ptr->screen_gamma; - else - g = png_ptr->gamma; /* probably doing rgb_to_gray */ - - for (i = 0; i < 256; i++) - { - png_ptr->gamma_from_1[i] = (png_byte)(pow((double)i / 255.0, - g) * 255.0 + .5); - - } - } -#endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_RGB_TO_GRAY_SUPPORTED */ - } - else - { - double g; - int i, j, shift, num; - int sig_bit; - png_uint_32 ig; - - if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) - { - sig_bit = (int)png_ptr->sig_bit.red; - if ((int)png_ptr->sig_bit.green > sig_bit) - sig_bit = png_ptr->sig_bit.green; - if ((int)png_ptr->sig_bit.blue > sig_bit) - sig_bit = png_ptr->sig_bit.blue; - } - else - { - sig_bit = (int)png_ptr->sig_bit.gray; - } - - if (sig_bit > 0) - shift = 16 - sig_bit; - else - shift = 0; - - if (png_ptr->transformations & PNG_16_TO_8) - { - if (shift < (16 - PNG_MAX_GAMMA_8)) - shift = (16 - PNG_MAX_GAMMA_8); - } - - if (shift > 8) - shift = 8; - if (shift < 0) - shift = 0; - - png_ptr->gamma_shift = (png_byte)shift; - - num = (1 << (8 - shift)); - - if (png_ptr->screen_gamma > .000001) - g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); - else - g = 1.0; - - png_ptr->gamma_16_table = (png_uint_16pp)png_malloc(png_ptr, - (png_uint_32)(num * png_sizeof (png_uint_16p))); - - if (png_ptr->transformations & (PNG_16_TO_8 | PNG_BACKGROUND)) - { - double fin, fout; - png_uint_32 last, max; - - for (i = 0; i < num; i++) - { - png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(256 * png_sizeof (png_uint_16))); - } - - g = 1.0 / g; - last = 0; - for (i = 0; i < 256; i++) - { - fout = ((double)i + 0.5) / 256.0; - fin = pow(fout, g); - max = (png_uint_32)(fin * (double)((png_uint_32)num << 8)); - while (last <= max) - { - png_ptr->gamma_16_table[(int)(last & (0xff >> shift))] - [(int)(last >> (8 - shift))] = (png_uint_16)( - (png_uint_16)i | ((png_uint_16)i << 8)); - last++; - } - } - while (last < ((png_uint_32)num << 8)) - { - png_ptr->gamma_16_table[(int)(last & (0xff >> shift))] - [(int)(last >> (8 - shift))] = (png_uint_16)65535L; - last++; - } - } - else - { - for (i = 0; i < num; i++) - { - png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(256 * png_sizeof (png_uint_16))); - - ig = (((png_uint_32)i * (png_uint_32)png_gamma_shift[shift]) >> 4); - for (j = 0; j < 256; j++) - { - png_ptr->gamma_16_table[i][j] = - (png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) / - 65535.0, g) * 65535.0 + .5); - } - } - } - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ - defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - if (png_ptr->transformations & (PNG_BACKGROUND | PNG_RGB_TO_GRAY)) - { - - g = 1.0 / (png_ptr->gamma); - - png_ptr->gamma_16_to_1 = (png_uint_16pp)png_malloc(png_ptr, - (png_uint_32)(num * png_sizeof (png_uint_16p ))); - - for (i = 0; i < num; i++) - { - png_ptr->gamma_16_to_1[i] = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(256 * png_sizeof (png_uint_16))); - - ig = (((png_uint_32)i * - (png_uint_32)png_gamma_shift[shift]) >> 4); - for (j = 0; j < 256; j++) - { - png_ptr->gamma_16_to_1[i][j] = - (png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) / - 65535.0, g) * 65535.0 + .5); - } - } - - if(png_ptr->screen_gamma > 0.000001) - g = 1.0 / png_ptr->screen_gamma; - else - g = png_ptr->gamma; /* probably doing rgb_to_gray */ - - png_ptr->gamma_16_from_1 = (png_uint_16pp)png_malloc(png_ptr, - (png_uint_32)(num * png_sizeof (png_uint_16p))); - - for (i = 0; i < num; i++) - { - png_ptr->gamma_16_from_1[i] = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(256 * png_sizeof (png_uint_16))); - - ig = (((png_uint_32)i * - (png_uint_32)png_gamma_shift[shift]) >> 4); - for (j = 0; j < 256; j++) - { - png_ptr->gamma_16_from_1[i][j] = - (png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) / - 65535.0, g) * 65535.0 + .5); - } - } - } -#endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_RGB_TO_GRAY_SUPPORTED */ - } -} -#endif -/* To do: install integer version of png_build_gamma_table here */ -#endif - -#if defined(PNG_MNG_FEATURES_SUPPORTED) -/* undoes intrapixel differencing */ -void /* PRIVATE */ -png_do_read_intrapixel(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_read_intrapixel\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - (row_info->color_type & PNG_COLOR_MASK_COLOR)) - { - int bytes_per_pixel; - png_uint_32 row_width = row_info->width; - if (row_info->bit_depth == 8) - { - png_bytep rp; - png_uint_32 i; - - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - bytes_per_pixel = 3; - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - bytes_per_pixel = 4; - else - return; - - for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) - { - *(rp) = (png_byte)((256 + *rp + *(rp+1))&0xff); - *(rp+2) = (png_byte)((256 + *(rp+2) + *(rp+1))&0xff); - } - } - else if (row_info->bit_depth == 16) - { - png_bytep rp; - png_uint_32 i; - - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - bytes_per_pixel = 6; - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - bytes_per_pixel = 8; - else - return; - - for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) - { - png_uint_32 s0 = (*(rp ) << 8) | *(rp+1); - png_uint_32 s1 = (*(rp+2) << 8) | *(rp+3); - png_uint_32 s2 = (*(rp+4) << 8) | *(rp+5); - png_uint_32 red = (png_uint_32)((s0+s1+65536L) & 0xffffL); - png_uint_32 blue = (png_uint_32)((s2+s1+65536L) & 0xffffL); - *(rp ) = (png_byte)((red >> 8) & 0xff); - *(rp+1) = (png_byte)(red & 0xff); - *(rp+4) = (png_byte)((blue >> 8) & 0xff); - *(rp+5) = (png_byte)(blue & 0xff); - } - } - } -} -#endif /* PNG_MNG_FEATURES_SUPPORTED */ -#endif /* PNG_READ_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng_osx/pngrutil.c b/irrlicht-1.6/source/Irrlicht/libpng_osx/pngrutil.c deleted file mode 100644 index 6157b3de4..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng_osx/pngrutil.c +++ /dev/null @@ -1,3126 +0,0 @@ - -/* pngrutil.c - utilities to read a PNG file - * - * Last changed in libpng 1.2.15 January 5, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This file contains routines that are only called from within - * libpng itself during the course of reading an image. - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_READ_SUPPORTED) - -#ifdef PNG_FLOATING_POINT_SUPPORTED -# if defined(_WIN32_WCE) -/* strtod() function is not supported on WindowsCE */ -__inline double png_strtod(png_structp png_ptr, const char *nptr, char **endptr) -{ - double result = 0; - int len; - wchar_t *str, *end; - - len = MultiByteToWideChar(CP_ACP, 0, nptr, -1, NULL, 0); - str = (wchar_t *)png_malloc(png_ptr, len * sizeof(wchar_t)); - if ( NULL != str ) - { - MultiByteToWideChar(CP_ACP, 0, nptr, -1, str, len); - result = wcstod(str, &end); - len = WideCharToMultiByte(CP_ACP, 0, end, -1, NULL, 0, NULL, NULL); - *endptr = (char *)nptr + (png_strlen(nptr) - len + 1); - png_free(str); - } - return result; -} -# else -# define png_strtod(p,a,b) strtod(a,b) -# endif -#endif - -png_uint_32 PNGAPI -png_get_uint_31(png_structp png_ptr, png_bytep buf) -{ - png_uint_32 i = png_get_uint_32(buf); - if (i > PNG_UINT_31_MAX) - png_error(png_ptr, "PNG unsigned integer out of range."); - return (i); -} -#ifndef PNG_READ_BIG_ENDIAN_SUPPORTED -/* Grab an unsigned 32-bit integer from a buffer in big-endian format. */ -png_uint_32 PNGAPI -png_get_uint_32(png_bytep buf) -{ - png_uint_32 i = ((png_uint_32)(*buf) << 24) + - ((png_uint_32)(*(buf + 1)) << 16) + - ((png_uint_32)(*(buf + 2)) << 8) + - (png_uint_32)(*(buf + 3)); - - return (i); -} - -/* Grab a signed 32-bit integer from a buffer in big-endian format. The - * data is stored in the PNG file in two's complement format, and it is - * assumed that the machine format for signed integers is the same. */ -png_int_32 PNGAPI -png_get_int_32(png_bytep buf) -{ - png_int_32 i = ((png_int_32)(*buf) << 24) + - ((png_int_32)(*(buf + 1)) << 16) + - ((png_int_32)(*(buf + 2)) << 8) + - (png_int_32)(*(buf + 3)); - - return (i); -} - -/* Grab an unsigned 16-bit integer from a buffer in big-endian format. */ -png_uint_16 PNGAPI -png_get_uint_16(png_bytep buf) -{ - png_uint_16 i = (png_uint_16)(((png_uint_16)(*buf) << 8) + - (png_uint_16)(*(buf + 1))); - - return (i); -} -#endif /* PNG_READ_BIG_ENDIAN_SUPPORTED */ - -/* Read data, and (optionally) run it through the CRC. */ -void /* PRIVATE */ -png_crc_read(png_structp png_ptr, png_bytep buf, png_size_t length) -{ - if(png_ptr == NULL) return; - png_read_data(png_ptr, buf, length); - png_calculate_crc(png_ptr, buf, length); -} - -/* Optionally skip data and then check the CRC. Depending on whether we - are reading a ancillary or critical chunk, and how the program has set - things up, we may calculate the CRC on the data and print a message. - Returns '1' if there was a CRC error, '0' otherwise. */ -int /* PRIVATE */ -png_crc_finish(png_structp png_ptr, png_uint_32 skip) -{ - png_size_t i; - png_size_t istop = png_ptr->zbuf_size; - - for (i = (png_size_t)skip; i > istop; i -= istop) - { - png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size); - } - if (i) - { - png_crc_read(png_ptr, png_ptr->zbuf, i); - } - - if (png_crc_error(png_ptr)) - { - if (((png_ptr->chunk_name[0] & 0x20) && /* Ancillary */ - !(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)) || - (!(png_ptr->chunk_name[0] & 0x20) && /* Critical */ - (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_USE))) - { - png_chunk_warning(png_ptr, "CRC error"); - } - else - { - png_chunk_error(png_ptr, "CRC error"); - } - return (1); - } - - return (0); -} - -/* Compare the CRC stored in the PNG file with that calculated by libpng from - the data it has read thus far. */ -int /* PRIVATE */ -png_crc_error(png_structp png_ptr) -{ - png_byte crc_bytes[4]; - png_uint_32 crc; - int need_crc = 1; - - if (png_ptr->chunk_name[0] & 0x20) /* ancillary */ - { - if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) == - (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN)) - need_crc = 0; - } - else /* critical */ - { - if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE) - need_crc = 0; - } - - png_read_data(png_ptr, crc_bytes, 4); - - if (need_crc) - { - crc = png_get_uint_32(crc_bytes); - return ((int)(crc != png_ptr->crc)); - } - else - return (0); -} - -#if defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_READ_iTXt_SUPPORTED) || \ - defined(PNG_READ_iCCP_SUPPORTED) -/* - * Decompress trailing data in a chunk. The assumption is that chunkdata - * points at an allocated area holding the contents of a chunk with a - * trailing compressed part. What we get back is an allocated area - * holding the original prefix part and an uncompressed version of the - * trailing part (the malloc area passed in is freed). - */ -png_charp /* PRIVATE */ -png_decompress_chunk(png_structp png_ptr, int comp_type, - png_charp chunkdata, png_size_t chunklength, - png_size_t prefix_size, png_size_t *newlength) -{ - static char msg[] = "Error decoding compressed text"; - png_charp text; - png_size_t text_size; - - if (comp_type == PNG_COMPRESSION_TYPE_BASE) - { - int ret = Z_OK; - png_ptr->zstream.next_in = (png_bytep)(chunkdata + prefix_size); - png_ptr->zstream.avail_in = (uInt)(chunklength - prefix_size); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - - text_size = 0; - text = NULL; - - while (png_ptr->zstream.avail_in) - { - ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); - if (ret != Z_OK && ret != Z_STREAM_END) - { - if (png_ptr->zstream.msg != NULL) - png_warning(png_ptr, png_ptr->zstream.msg); - else - png_warning(png_ptr, msg); - inflateReset(&png_ptr->zstream); - png_ptr->zstream.avail_in = 0; - - if (text == NULL) - { - text_size = prefix_size + png_sizeof(msg) + 1; - text = (png_charp)png_malloc_warn(png_ptr, text_size); - if (text == NULL) - { - png_free(png_ptr,chunkdata); - png_error(png_ptr,"Not enough memory to decompress chunk"); - } - png_memcpy(text, chunkdata, prefix_size); - } - - text[text_size - 1] = 0x00; - - /* Copy what we can of the error message into the text chunk */ - text_size = (png_size_t)(chunklength - (text - chunkdata) - 1); - text_size = png_sizeof(msg) > text_size ? text_size : - png_sizeof(msg); - png_memcpy(text + prefix_size, msg, text_size + 1); - break; - } - if (!png_ptr->zstream.avail_out || ret == Z_STREAM_END) - { - if (text == NULL) - { - text_size = prefix_size + - png_ptr->zbuf_size - png_ptr->zstream.avail_out; - text = (png_charp)png_malloc_warn(png_ptr, text_size + 1); - if (text == NULL) - { - png_free(png_ptr,chunkdata); - png_error(png_ptr,"Not enough memory to decompress chunk."); - } - png_memcpy(text + prefix_size, png_ptr->zbuf, - text_size - prefix_size); - png_memcpy(text, chunkdata, prefix_size); - *(text + text_size) = 0x00; - } - else - { - png_charp tmp; - - tmp = text; - text = (png_charp)png_malloc_warn(png_ptr, - (png_uint_32)(text_size + - png_ptr->zbuf_size - png_ptr->zstream.avail_out + 1)); - if (text == NULL) - { - png_free(png_ptr, tmp); - png_free(png_ptr, chunkdata); - png_error(png_ptr,"Not enough memory to decompress chunk.."); - } - png_memcpy(text, tmp, text_size); - png_free(png_ptr, tmp); - png_memcpy(text + text_size, png_ptr->zbuf, - (png_ptr->zbuf_size - png_ptr->zstream.avail_out)); - text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out; - *(text + text_size) = 0x00; - } - if (ret == Z_STREAM_END) - break; - else - { - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - } - } - } - if (ret != Z_STREAM_END) - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char umsg[52]; - - if (ret == Z_BUF_ERROR) - sprintf(umsg,"Buffer error in compressed datastream in %s chunk", - png_ptr->chunk_name); - else if (ret == Z_DATA_ERROR) - sprintf(umsg,"Data error in compressed datastream in %s chunk", - png_ptr->chunk_name); - else - sprintf(umsg,"Incomplete compressed datastream in %s chunk", - png_ptr->chunk_name); - png_warning(png_ptr, umsg); -#else - png_warning(png_ptr, - "Incomplete compressed datastream in chunk other than IDAT"); -#endif - text_size=prefix_size; - if (text == NULL) - { - text = (png_charp)png_malloc_warn(png_ptr, text_size+1); - if (text == NULL) - { - png_free(png_ptr, chunkdata); - png_error(png_ptr,"Not enough memory for text."); - } - png_memcpy(text, chunkdata, prefix_size); - } - *(text + text_size) = 0x00; - } - - inflateReset(&png_ptr->zstream); - png_ptr->zstream.avail_in = 0; - - png_free(png_ptr, chunkdata); - chunkdata = text; - *newlength=text_size; - } - else /* if (comp_type != PNG_COMPRESSION_TYPE_BASE) */ - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char umsg[50]; - - sprintf(umsg, "Unknown zTXt compression type %d", comp_type); - png_warning(png_ptr, umsg); -#else - png_warning(png_ptr, "Unknown zTXt compression type"); -#endif - - *(chunkdata + prefix_size) = 0x00; - *newlength=prefix_size; - } - - return chunkdata; -} -#endif - -/* read and check the IDHR chunk */ -void /* PRIVATE */ -png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_byte buf[13]; - png_uint_32 width, height; - int bit_depth, color_type, compression_type, filter_type; - int interlace_type; - - png_debug(1, "in png_handle_IHDR\n"); - - if (png_ptr->mode & PNG_HAVE_IHDR) - png_error(png_ptr, "Out of place IHDR"); - - /* check the length */ - if (length != 13) - png_error(png_ptr, "Invalid IHDR chunk"); - - png_ptr->mode |= PNG_HAVE_IHDR; - - png_crc_read(png_ptr, buf, 13); - png_crc_finish(png_ptr, 0); - - width = png_get_uint_31(png_ptr, buf); - height = png_get_uint_31(png_ptr, buf + 4); - bit_depth = buf[8]; - color_type = buf[9]; - compression_type = buf[10]; - filter_type = buf[11]; - interlace_type = buf[12]; - - /* set internal variables */ - png_ptr->width = width; - png_ptr->height = height; - png_ptr->bit_depth = (png_byte)bit_depth; - png_ptr->interlaced = (png_byte)interlace_type; - png_ptr->color_type = (png_byte)color_type; -#if defined(PNG_MNG_FEATURES_SUPPORTED) - png_ptr->filter_type = (png_byte)filter_type; -#endif - png_ptr->compression_type = (png_byte)compression_type; - - /* find number of channels */ - switch (png_ptr->color_type) - { - case PNG_COLOR_TYPE_GRAY: - case PNG_COLOR_TYPE_PALETTE: - png_ptr->channels = 1; - break; - case PNG_COLOR_TYPE_RGB: - png_ptr->channels = 3; - break; - case PNG_COLOR_TYPE_GRAY_ALPHA: - png_ptr->channels = 2; - break; - case PNG_COLOR_TYPE_RGB_ALPHA: - png_ptr->channels = 4; - break; - } - - /* set up other useful info */ - png_ptr->pixel_depth = (png_byte)(png_ptr->bit_depth * - png_ptr->channels); - png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth,png_ptr->width); - png_debug1(3,"bit_depth = %d\n", png_ptr->bit_depth); - png_debug1(3,"channels = %d\n", png_ptr->channels); - png_debug1(3,"rowbytes = %lu\n", png_ptr->rowbytes); - png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, - color_type, interlace_type, compression_type, filter_type); -} - -/* read and check the palette */ -void /* PRIVATE */ -png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_color palette[PNG_MAX_PALETTE_LENGTH]; - int num, i; -#ifndef PNG_NO_POINTER_INDEXING - png_colorp pal_ptr; -#endif - - png_debug(1, "in png_handle_PLTE\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before PLTE"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid PLTE after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->mode & PNG_HAVE_PLTE) - png_error(png_ptr, "Duplicate PLTE chunk"); - - png_ptr->mode |= PNG_HAVE_PLTE; - - if (!(png_ptr->color_type&PNG_COLOR_MASK_COLOR)) - { - png_warning(png_ptr, - "Ignoring PLTE chunk in grayscale PNG"); - png_crc_finish(png_ptr, length); - return; - } -#if !defined(PNG_READ_OPT_PLTE_SUPPORTED) - if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE) - { - png_crc_finish(png_ptr, length); - return; - } -#endif - - if (length > 3*PNG_MAX_PALETTE_LENGTH || length % 3) - { - if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE) - { - png_warning(png_ptr, "Invalid palette chunk"); - png_crc_finish(png_ptr, length); - return; - } - else - { - png_error(png_ptr, "Invalid palette chunk"); - } - } - - num = (int)length / 3; - -#ifndef PNG_NO_POINTER_INDEXING - for (i = 0, pal_ptr = palette; i < num; i++, pal_ptr++) - { - png_byte buf[3]; - - png_crc_read(png_ptr, buf, 3); - pal_ptr->red = buf[0]; - pal_ptr->green = buf[1]; - pal_ptr->blue = buf[2]; - } -#else - for (i = 0; i < num; i++) - { - png_byte buf[3]; - - png_crc_read(png_ptr, buf, 3); - /* don't depend upon png_color being any order */ - palette[i].red = buf[0]; - palette[i].green = buf[1]; - palette[i].blue = buf[2]; - } -#endif - - /* If we actually NEED the PLTE chunk (ie for a paletted image), we do - whatever the normal CRC configuration tells us. However, if we - have an RGB image, the PLTE can be considered ancillary, so - we will act as though it is. */ -#if !defined(PNG_READ_OPT_PLTE_SUPPORTED) - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) -#endif - { - png_crc_finish(png_ptr, 0); - } -#if !defined(PNG_READ_OPT_PLTE_SUPPORTED) - else if (png_crc_error(png_ptr)) /* Only if we have a CRC error */ - { - /* If we don't want to use the data from an ancillary chunk, - we have two options: an error abort, or a warning and we - ignore the data in this chunk (which should be OK, since - it's considered ancillary for a RGB or RGBA image). */ - if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_USE)) - { - if (png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) - { - png_chunk_error(png_ptr, "CRC error"); - } - else - { - png_chunk_warning(png_ptr, "CRC error"); - return; - } - } - /* Otherwise, we (optionally) emit a warning and use the chunk. */ - else if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)) - { - png_chunk_warning(png_ptr, "CRC error"); - } - } -#endif - - png_set_PLTE(png_ptr, info_ptr, palette, num); - -#if defined(PNG_READ_tRNS_SUPPORTED) - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) - { - if (png_ptr->num_trans > (png_uint_16)num) - { - png_warning(png_ptr, "Truncating incorrect tRNS chunk length"); - png_ptr->num_trans = (png_uint_16)num; - } - if (info_ptr->num_trans > (png_uint_16)num) - { - png_warning(png_ptr, "Truncating incorrect info tRNS chunk length"); - info_ptr->num_trans = (png_uint_16)num; - } - } - } -#endif - -} - -void /* PRIVATE */ -png_handle_IEND(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_debug(1, "in png_handle_IEND\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR) || !(png_ptr->mode & PNG_HAVE_IDAT)) - { - png_error(png_ptr, "No image in file"); - } - - png_ptr->mode |= (PNG_AFTER_IDAT | PNG_HAVE_IEND); - - if (length != 0) - { - png_warning(png_ptr, "Incorrect IEND chunk length"); - } - png_crc_finish(png_ptr, length); - - if (&info_ptr == NULL) /* quiet compiler warnings about unused info_ptr */ - return; -} - -#if defined(PNG_READ_gAMA_SUPPORTED) -void /* PRIVATE */ -png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_fixed_point igamma; -#ifdef PNG_FLOATING_POINT_SUPPORTED - float file_gamma; -#endif - png_byte buf[4]; - - png_debug(1, "in png_handle_gAMA\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before gAMA"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid gAMA after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->mode & PNG_HAVE_PLTE) - /* Should be an error, but we can cope with it */ - png_warning(png_ptr, "Out of place gAMA chunk"); - - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) -#if defined(PNG_READ_sRGB_SUPPORTED) - && !(info_ptr->valid & PNG_INFO_sRGB) -#endif - ) - { - png_warning(png_ptr, "Duplicate gAMA chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (length != 4) - { - png_warning(png_ptr, "Incorrect gAMA chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, 4); - if (png_crc_finish(png_ptr, 0)) - return; - - igamma = (png_fixed_point)png_get_uint_32(buf); - /* check for zero gamma */ - if (igamma == 0) - { - png_warning(png_ptr, - "Ignoring gAMA chunk with gamma=0"); - return; - } - -#if defined(PNG_READ_sRGB_SUPPORTED) - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)) - if (PNG_OUT_OF_RANGE(igamma, 45500L, 500)) - { - png_warning(png_ptr, - "Ignoring incorrect gAMA value when sRGB is also present"); -#ifndef PNG_NO_CONSOLE_IO - fprintf(stderr, "gamma = (%d/100000)\n", (int)igamma); -#endif - return; - } -#endif /* PNG_READ_sRGB_SUPPORTED */ - -#ifdef PNG_FLOATING_POINT_SUPPORTED - file_gamma = (float)igamma / (float)100000.0; -# ifdef PNG_READ_GAMMA_SUPPORTED - png_ptr->gamma = file_gamma; -# endif - png_set_gAMA(png_ptr, info_ptr, file_gamma); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - png_set_gAMA_fixed(png_ptr, info_ptr, igamma); -#endif -} -#endif - -#if defined(PNG_READ_sBIT_SUPPORTED) -void /* PRIVATE */ -png_handle_sBIT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_size_t truelen; - png_byte buf[4]; - - png_debug(1, "in png_handle_sBIT\n"); - - buf[0] = buf[1] = buf[2] = buf[3] = 0; - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before sBIT"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid sBIT after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->mode & PNG_HAVE_PLTE) - { - /* Should be an error, but we can cope with it */ - png_warning(png_ptr, "Out of place sBIT chunk"); - } - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)) - { - png_warning(png_ptr, "Duplicate sBIT chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - truelen = 3; - else - truelen = (png_size_t)png_ptr->channels; - - if (length != truelen || length > 4) - { - png_warning(png_ptr, "Incorrect sBIT chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, truelen); - if (png_crc_finish(png_ptr, 0)) - return; - - if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) - { - png_ptr->sig_bit.red = buf[0]; - png_ptr->sig_bit.green = buf[1]; - png_ptr->sig_bit.blue = buf[2]; - png_ptr->sig_bit.alpha = buf[3]; - } - else - { - png_ptr->sig_bit.gray = buf[0]; - png_ptr->sig_bit.red = buf[0]; - png_ptr->sig_bit.green = buf[0]; - png_ptr->sig_bit.blue = buf[0]; - png_ptr->sig_bit.alpha = buf[1]; - } - png_set_sBIT(png_ptr, info_ptr, &(png_ptr->sig_bit)); -} -#endif - -#if defined(PNG_READ_cHRM_SUPPORTED) -void /* PRIVATE */ -png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_byte buf[4]; -#ifdef PNG_FLOATING_POINT_SUPPORTED - float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y; -#endif - png_fixed_point int_x_white, int_y_white, int_x_red, int_y_red, int_x_green, - int_y_green, int_x_blue, int_y_blue; - - png_uint_32 uint_x, uint_y; - - png_debug(1, "in png_handle_cHRM\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before cHRM"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid cHRM after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->mode & PNG_HAVE_PLTE) - /* Should be an error, but we can cope with it */ - png_warning(png_ptr, "Missing PLTE before cHRM"); - - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM) -#if defined(PNG_READ_sRGB_SUPPORTED) - && !(info_ptr->valid & PNG_INFO_sRGB) -#endif - ) - { - png_warning(png_ptr, "Duplicate cHRM chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (length != 32) - { - png_warning(png_ptr, "Incorrect cHRM chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, 4); - uint_x = png_get_uint_32(buf); - - png_crc_read(png_ptr, buf, 4); - uint_y = png_get_uint_32(buf); - - if (uint_x > 80000L || uint_y > 80000L || - uint_x + uint_y > 100000L) - { - png_warning(png_ptr, "Invalid cHRM white point"); - png_crc_finish(png_ptr, 24); - return; - } - int_x_white = (png_fixed_point)uint_x; - int_y_white = (png_fixed_point)uint_y; - - png_crc_read(png_ptr, buf, 4); - uint_x = png_get_uint_32(buf); - - png_crc_read(png_ptr, buf, 4); - uint_y = png_get_uint_32(buf); - - if (uint_x + uint_y > 100000L) - { - png_warning(png_ptr, "Invalid cHRM red point"); - png_crc_finish(png_ptr, 16); - return; - } - int_x_red = (png_fixed_point)uint_x; - int_y_red = (png_fixed_point)uint_y; - - png_crc_read(png_ptr, buf, 4); - uint_x = png_get_uint_32(buf); - - png_crc_read(png_ptr, buf, 4); - uint_y = png_get_uint_32(buf); - - if (uint_x + uint_y > 100000L) - { - png_warning(png_ptr, "Invalid cHRM green point"); - png_crc_finish(png_ptr, 8); - return; - } - int_x_green = (png_fixed_point)uint_x; - int_y_green = (png_fixed_point)uint_y; - - png_crc_read(png_ptr, buf, 4); - uint_x = png_get_uint_32(buf); - - png_crc_read(png_ptr, buf, 4); - uint_y = png_get_uint_32(buf); - - if (uint_x + uint_y > 100000L) - { - png_warning(png_ptr, "Invalid cHRM blue point"); - png_crc_finish(png_ptr, 0); - return; - } - int_x_blue = (png_fixed_point)uint_x; - int_y_blue = (png_fixed_point)uint_y; - -#ifdef PNG_FLOATING_POINT_SUPPORTED - white_x = (float)int_x_white / (float)100000.0; - white_y = (float)int_y_white / (float)100000.0; - red_x = (float)int_x_red / (float)100000.0; - red_y = (float)int_y_red / (float)100000.0; - green_x = (float)int_x_green / (float)100000.0; - green_y = (float)int_y_green / (float)100000.0; - blue_x = (float)int_x_blue / (float)100000.0; - blue_y = (float)int_y_blue / (float)100000.0; -#endif - -#if defined(PNG_READ_sRGB_SUPPORTED) - if ((info_ptr != NULL) && (info_ptr->valid & PNG_INFO_sRGB)) - { - if (PNG_OUT_OF_RANGE(int_x_white, 31270, 1000) || - PNG_OUT_OF_RANGE(int_y_white, 32900, 1000) || - PNG_OUT_OF_RANGE(int_x_red, 64000L, 1000) || - PNG_OUT_OF_RANGE(int_y_red, 33000, 1000) || - PNG_OUT_OF_RANGE(int_x_green, 30000, 1000) || - PNG_OUT_OF_RANGE(int_y_green, 60000L, 1000) || - PNG_OUT_OF_RANGE(int_x_blue, 15000, 1000) || - PNG_OUT_OF_RANGE(int_y_blue, 6000, 1000)) - { - png_warning(png_ptr, - "Ignoring incorrect cHRM value when sRGB is also present"); -#ifndef PNG_NO_CONSOLE_IO -#ifdef PNG_FLOATING_POINT_SUPPORTED - fprintf(stderr,"wx=%f, wy=%f, rx=%f, ry=%f\n", - white_x, white_y, red_x, red_y); - fprintf(stderr,"gx=%f, gy=%f, bx=%f, by=%f\n", - green_x, green_y, blue_x, blue_y); -#else - fprintf(stderr,"wx=%ld, wy=%ld, rx=%ld, ry=%ld\n", - int_x_white, int_y_white, int_x_red, int_y_red); - fprintf(stderr,"gx=%ld, gy=%ld, bx=%ld, by=%ld\n", - int_x_green, int_y_green, int_x_blue, int_y_blue); -#endif -#endif /* PNG_NO_CONSOLE_IO */ - } - png_crc_finish(png_ptr, 0); - return; - } -#endif /* PNG_READ_sRGB_SUPPORTED */ - -#ifdef PNG_FLOATING_POINT_SUPPORTED - png_set_cHRM(png_ptr, info_ptr, - white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - png_set_cHRM_fixed(png_ptr, info_ptr, - int_x_white, int_y_white, int_x_red, int_y_red, int_x_green, - int_y_green, int_x_blue, int_y_blue); -#endif - if (png_crc_finish(png_ptr, 0)) - return; -} -#endif - -#if defined(PNG_READ_sRGB_SUPPORTED) -void /* PRIVATE */ -png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - int intent; - png_byte buf[1]; - - png_debug(1, "in png_handle_sRGB\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before sRGB"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid sRGB after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->mode & PNG_HAVE_PLTE) - /* Should be an error, but we can cope with it */ - png_warning(png_ptr, "Out of place sRGB chunk"); - - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)) - { - png_warning(png_ptr, "Duplicate sRGB chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (length != 1) - { - png_warning(png_ptr, "Incorrect sRGB chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, 1); - if (png_crc_finish(png_ptr, 0)) - return; - - intent = buf[0]; - /* check for bad intent */ - if (intent >= PNG_sRGB_INTENT_LAST) - { - png_warning(png_ptr, "Unknown sRGB intent"); - return; - } - -#if defined(PNG_READ_gAMA_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED) - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)) - { - png_fixed_point igamma; -#ifdef PNG_FIXED_POINT_SUPPORTED - igamma=info_ptr->int_gamma; -#else -# ifdef PNG_FLOATING_POINT_SUPPORTED - igamma=(png_fixed_point)(info_ptr->gamma * 100000.); -# endif -#endif - if (PNG_OUT_OF_RANGE(igamma, 45500L, 500)) - { - png_warning(png_ptr, - "Ignoring incorrect gAMA value when sRGB is also present"); -#ifndef PNG_NO_CONSOLE_IO -# ifdef PNG_FIXED_POINT_SUPPORTED - fprintf(stderr,"incorrect gamma=(%d/100000)\n",(int)png_ptr->int_gamma); -# else -# ifdef PNG_FLOATING_POINT_SUPPORTED - fprintf(stderr,"incorrect gamma=%f\n",png_ptr->gamma); -# endif -# endif -#endif - } - } -#endif /* PNG_READ_gAMA_SUPPORTED */ - -#ifdef PNG_READ_cHRM_SUPPORTED -#ifdef PNG_FIXED_POINT_SUPPORTED - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) - if (PNG_OUT_OF_RANGE(info_ptr->int_x_white, 31270, 1000) || - PNG_OUT_OF_RANGE(info_ptr->int_y_white, 32900, 1000) || - PNG_OUT_OF_RANGE(info_ptr->int_x_red, 64000L, 1000) || - PNG_OUT_OF_RANGE(info_ptr->int_y_red, 33000, 1000) || - PNG_OUT_OF_RANGE(info_ptr->int_x_green, 30000, 1000) || - PNG_OUT_OF_RANGE(info_ptr->int_y_green, 60000L, 1000) || - PNG_OUT_OF_RANGE(info_ptr->int_x_blue, 15000, 1000) || - PNG_OUT_OF_RANGE(info_ptr->int_y_blue, 6000, 1000)) - { - png_warning(png_ptr, - "Ignoring incorrect cHRM value when sRGB is also present"); - } -#endif /* PNG_FIXED_POINT_SUPPORTED */ -#endif /* PNG_READ_cHRM_SUPPORTED */ - - png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, intent); -} -#endif /* PNG_READ_sRGB_SUPPORTED */ - -#if defined(PNG_READ_iCCP_SUPPORTED) -void /* PRIVATE */ -png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -/* Note: this does not properly handle chunks that are > 64K under DOS */ -{ - png_charp chunkdata; - png_byte compression_type; - png_bytep pC; - png_charp profile; - png_uint_32 skip = 0; - png_uint_32 profile_size, profile_length; - png_size_t slength, prefix_length, data_length; - - png_debug(1, "in png_handle_iCCP\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before iCCP"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid iCCP after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->mode & PNG_HAVE_PLTE) - /* Should be an error, but we can cope with it */ - png_warning(png_ptr, "Out of place iCCP chunk"); - - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)) - { - png_warning(png_ptr, "Duplicate iCCP chunk"); - png_crc_finish(png_ptr, length); - return; - } - -#ifdef PNG_MAX_MALLOC_64K - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr, "iCCP chunk too large to fit in memory"); - skip = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - - chunkdata = (png_charp)png_malloc(png_ptr, length + 1); - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunkdata, slength); - - if (png_crc_finish(png_ptr, skip)) - { - png_free(png_ptr, chunkdata); - return; - } - - chunkdata[slength] = 0x00; - - for (profile = chunkdata; *profile; profile++) - /* empty loop to find end of name */ ; - - ++profile; - - /* there should be at least one zero (the compression type byte) - following the separator, and we should be on it */ - if ( profile >= chunkdata + slength) - { - png_free(png_ptr, chunkdata); - png_warning(png_ptr, "Malformed iCCP chunk"); - return; - } - - /* compression_type should always be zero */ - compression_type = *profile++; - if (compression_type) - { - png_warning(png_ptr, "Ignoring nonzero compression type in iCCP chunk"); - compression_type=0x00; /* Reset it to zero (libpng-1.0.6 through 1.0.8 - wrote nonzero) */ - } - - prefix_length = profile - chunkdata; - chunkdata = png_decompress_chunk(png_ptr, compression_type, chunkdata, - slength, prefix_length, &data_length); - - profile_length = data_length - prefix_length; - - if ( prefix_length > data_length || profile_length < 4) - { - png_free(png_ptr, chunkdata); - png_warning(png_ptr, "Profile size field missing from iCCP chunk"); - return; - } - - /* Check the profile_size recorded in the first 32 bits of the ICC profile */ - pC = (png_bytep)(chunkdata+prefix_length); - profile_size = ((*(pC ))<<24) | - ((*(pC+1))<<16) | - ((*(pC+2))<< 8) | - ((*(pC+3)) ); - - if(profile_size < profile_length) - profile_length = profile_size; - - if(profile_size > profile_length) - { - png_free(png_ptr, chunkdata); - png_warning(png_ptr, "Ignoring truncated iCCP profile."); - return; - } - - png_set_iCCP(png_ptr, info_ptr, chunkdata, compression_type, - chunkdata + prefix_length, profile_length); - png_free(png_ptr, chunkdata); -} -#endif /* PNG_READ_iCCP_SUPPORTED */ - -#if defined(PNG_READ_sPLT_SUPPORTED) -void /* PRIVATE */ -png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -/* Note: this does not properly handle chunks that are > 64K under DOS */ -{ - png_bytep chunkdata; - png_bytep entry_start; - png_sPLT_t new_palette; -#ifdef PNG_NO_POINTER_INDEXING - png_sPLT_entryp pp; -#endif - int data_length, entry_size, i; - png_uint_32 skip = 0; - png_size_t slength; - - png_debug(1, "in png_handle_sPLT\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before sPLT"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid sPLT after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - -#ifdef PNG_MAX_MALLOC_64K - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr, "sPLT chunk too large to fit in memory"); - skip = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - - chunkdata = (png_bytep)png_malloc(png_ptr, length + 1); - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunkdata, slength); - - if (png_crc_finish(png_ptr, skip)) - { - png_free(png_ptr, chunkdata); - return; - } - - chunkdata[slength] = 0x00; - - for (entry_start = chunkdata; *entry_start; entry_start++) - /* empty loop to find end of name */ ; - ++entry_start; - - /* a sample depth should follow the separator, and we should be on it */ - if (entry_start > chunkdata + slength) - { - png_free(png_ptr, chunkdata); - png_warning(png_ptr, "malformed sPLT chunk"); - return; - } - - new_palette.depth = *entry_start++; - entry_size = (new_palette.depth == 8 ? 6 : 10); - data_length = (slength - (entry_start - chunkdata)); - - /* integrity-check the data length */ - if (data_length % entry_size) - { - png_free(png_ptr, chunkdata); - png_warning(png_ptr, "sPLT chunk has bad length"); - return; - } - - new_palette.nentries = (png_int_32) ( data_length / entry_size); - if ((png_uint_32) new_palette.nentries > (png_uint_32) (PNG_SIZE_MAX / - png_sizeof(png_sPLT_entry))) - { - png_warning(png_ptr, "sPLT chunk too long"); - return; - } - new_palette.entries = (png_sPLT_entryp)png_malloc_warn( - png_ptr, new_palette.nentries * png_sizeof(png_sPLT_entry)); - if (new_palette.entries == NULL) - { - png_warning(png_ptr, "sPLT chunk requires too much memory"); - return; - } - -#ifndef PNG_NO_POINTER_INDEXING - for (i = 0; i < new_palette.nentries; i++) - { - png_sPLT_entryp pp = new_palette.entries + i; - - if (new_palette.depth == 8) - { - pp->red = *entry_start++; - pp->green = *entry_start++; - pp->blue = *entry_start++; - pp->alpha = *entry_start++; - } - else - { - pp->red = png_get_uint_16(entry_start); entry_start += 2; - pp->green = png_get_uint_16(entry_start); entry_start += 2; - pp->blue = png_get_uint_16(entry_start); entry_start += 2; - pp->alpha = png_get_uint_16(entry_start); entry_start += 2; - } - pp->frequency = png_get_uint_16(entry_start); entry_start += 2; - } -#else - pp = new_palette.entries; - for (i = 0; i < new_palette.nentries; i++) - { - - if (new_palette.depth == 8) - { - pp[i].red = *entry_start++; - pp[i].green = *entry_start++; - pp[i].blue = *entry_start++; - pp[i].alpha = *entry_start++; - } - else - { - pp[i].red = png_get_uint_16(entry_start); entry_start += 2; - pp[i].green = png_get_uint_16(entry_start); entry_start += 2; - pp[i].blue = png_get_uint_16(entry_start); entry_start += 2; - pp[i].alpha = png_get_uint_16(entry_start); entry_start += 2; - } - pp->frequency = png_get_uint_16(entry_start); entry_start += 2; - } -#endif - - /* discard all chunk data except the name and stash that */ - new_palette.name = (png_charp)chunkdata; - - png_set_sPLT(png_ptr, info_ptr, &new_palette, 1); - - png_free(png_ptr, chunkdata); - png_free(png_ptr, new_palette.entries); -} -#endif /* PNG_READ_sPLT_SUPPORTED */ - -#if defined(PNG_READ_tRNS_SUPPORTED) -void /* PRIVATE */ -png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_byte readbuf[PNG_MAX_PALETTE_LENGTH]; - - png_debug(1, "in png_handle_tRNS\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before tRNS"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid tRNS after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) - { - png_warning(png_ptr, "Duplicate tRNS chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) - { - png_byte buf[2]; - - if (length != 2) - { - png_warning(png_ptr, "Incorrect tRNS chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, 2); - png_ptr->num_trans = 1; - png_ptr->trans_values.gray = png_get_uint_16(buf); - } - else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) - { - png_byte buf[6]; - - if (length != 6) - { - png_warning(png_ptr, "Incorrect tRNS chunk length"); - png_crc_finish(png_ptr, length); - return; - } - png_crc_read(png_ptr, buf, (png_size_t)length); - png_ptr->num_trans = 1; - png_ptr->trans_values.red = png_get_uint_16(buf); - png_ptr->trans_values.green = png_get_uint_16(buf + 2); - png_ptr->trans_values.blue = png_get_uint_16(buf + 4); - } - else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - if (!(png_ptr->mode & PNG_HAVE_PLTE)) - { - /* Should be an error, but we can cope with it. */ - png_warning(png_ptr, "Missing PLTE before tRNS"); - } - if (length > (png_uint_32)png_ptr->num_palette || - length > PNG_MAX_PALETTE_LENGTH) - { - png_warning(png_ptr, "Incorrect tRNS chunk length"); - png_crc_finish(png_ptr, length); - return; - } - if (length == 0) - { - png_warning(png_ptr, "Zero length tRNS chunk"); - png_crc_finish(png_ptr, length); - return; - } - png_crc_read(png_ptr, readbuf, (png_size_t)length); - png_ptr->num_trans = (png_uint_16)length; - } - else - { - png_warning(png_ptr, "tRNS chunk not allowed with alpha channel"); - png_crc_finish(png_ptr, length); - return; - } - - if (png_crc_finish(png_ptr, 0)) - return; - - png_set_tRNS(png_ptr, info_ptr, readbuf, png_ptr->num_trans, - &(png_ptr->trans_values)); -} -#endif - -#if defined(PNG_READ_bKGD_SUPPORTED) -void /* PRIVATE */ -png_handle_bKGD(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_size_t truelen; - png_byte buf[6]; - - png_debug(1, "in png_handle_bKGD\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before bKGD"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid bKGD after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - !(png_ptr->mode & PNG_HAVE_PLTE)) - { - png_warning(png_ptr, "Missing PLTE before bKGD"); - png_crc_finish(png_ptr, length); - return; - } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)) - { - png_warning(png_ptr, "Duplicate bKGD chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - truelen = 1; - else if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) - truelen = 6; - else - truelen = 2; - - if (length != truelen) - { - png_warning(png_ptr, "Incorrect bKGD chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, truelen); - if (png_crc_finish(png_ptr, 0)) - return; - - /* We convert the index value into RGB components so that we can allow - * arbitrary RGB values for background when we have transparency, and - * so it is easy to determine the RGB values of the background color - * from the info_ptr struct. */ - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - png_ptr->background.index = buf[0]; - if(info_ptr->num_palette) - { - if(buf[0] > info_ptr->num_palette) - { - png_warning(png_ptr, "Incorrect bKGD chunk index value"); - return; - } - png_ptr->background.red = - (png_uint_16)png_ptr->palette[buf[0]].red; - png_ptr->background.green = - (png_uint_16)png_ptr->palette[buf[0]].green; - png_ptr->background.blue = - (png_uint_16)png_ptr->palette[buf[0]].blue; - } - } - else if (!(png_ptr->color_type & PNG_COLOR_MASK_COLOR)) /* GRAY */ - { - png_ptr->background.red = - png_ptr->background.green = - png_ptr->background.blue = - png_ptr->background.gray = png_get_uint_16(buf); - } - else - { - png_ptr->background.red = png_get_uint_16(buf); - png_ptr->background.green = png_get_uint_16(buf + 2); - png_ptr->background.blue = png_get_uint_16(buf + 4); - } - - png_set_bKGD(png_ptr, info_ptr, &(png_ptr->background)); -} -#endif - -#if defined(PNG_READ_hIST_SUPPORTED) -void /* PRIVATE */ -png_handle_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - unsigned int num, i; - png_uint_16 readbuf[PNG_MAX_PALETTE_LENGTH]; - - png_debug(1, "in png_handle_hIST\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before hIST"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid hIST after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (!(png_ptr->mode & PNG_HAVE_PLTE)) - { - png_warning(png_ptr, "Missing PLTE before hIST"); - png_crc_finish(png_ptr, length); - return; - } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)) - { - png_warning(png_ptr, "Duplicate hIST chunk"); - png_crc_finish(png_ptr, length); - return; - } - - num = length / 2 ; - if (num != (unsigned int) png_ptr->num_palette || num > - (unsigned int) PNG_MAX_PALETTE_LENGTH) - { - png_warning(png_ptr, "Incorrect hIST chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - for (i = 0; i < num; i++) - { - png_byte buf[2]; - - png_crc_read(png_ptr, buf, 2); - readbuf[i] = png_get_uint_16(buf); - } - - if (png_crc_finish(png_ptr, 0)) - return; - - png_set_hIST(png_ptr, info_ptr, readbuf); -} -#endif - -#if defined(PNG_READ_pHYs_SUPPORTED) -void /* PRIVATE */ -png_handle_pHYs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_byte buf[9]; - png_uint_32 res_x, res_y; - int unit_type; - - png_debug(1, "in png_handle_pHYs\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before pHYs"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid pHYs after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) - { - png_warning(png_ptr, "Duplicate pHYs chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (length != 9) - { - png_warning(png_ptr, "Incorrect pHYs chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, 9); - if (png_crc_finish(png_ptr, 0)) - return; - - res_x = png_get_uint_32(buf); - res_y = png_get_uint_32(buf + 4); - unit_type = buf[8]; - png_set_pHYs(png_ptr, info_ptr, res_x, res_y, unit_type); -} -#endif - -#if defined(PNG_READ_oFFs_SUPPORTED) -void /* PRIVATE */ -png_handle_oFFs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_byte buf[9]; - png_int_32 offset_x, offset_y; - int unit_type; - - png_debug(1, "in png_handle_oFFs\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before oFFs"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid oFFs after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) - { - png_warning(png_ptr, "Duplicate oFFs chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (length != 9) - { - png_warning(png_ptr, "Incorrect oFFs chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, 9); - if (png_crc_finish(png_ptr, 0)) - return; - - offset_x = png_get_int_32(buf); - offset_y = png_get_int_32(buf + 4); - unit_type = buf[8]; - png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y, unit_type); -} -#endif - -#if defined(PNG_READ_pCAL_SUPPORTED) -/* read the pCAL chunk (described in the PNG Extensions document) */ -void /* PRIVATE */ -png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_charp purpose; - png_int_32 X0, X1; - png_byte type, nparams; - png_charp buf, units, endptr; - png_charpp params; - png_size_t slength; - int i; - - png_debug(1, "in png_handle_pCAL\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before pCAL"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid pCAL after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)) - { - png_warning(png_ptr, "Duplicate pCAL chunk"); - png_crc_finish(png_ptr, length); - return; - } - - png_debug1(2, "Allocating and reading pCAL chunk data (%lu bytes)\n", - length + 1); - purpose = (png_charp)png_malloc_warn(png_ptr, length + 1); - if (purpose == NULL) - { - png_warning(png_ptr, "No memory for pCAL purpose."); - return; - } - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)purpose, slength); - - if (png_crc_finish(png_ptr, 0)) - { - png_free(png_ptr, purpose); - return; - } - - purpose[slength] = 0x00; /* null terminate the last string */ - - png_debug(3, "Finding end of pCAL purpose string\n"); - for (buf = purpose; *buf; buf++) - /* empty loop */ ; - - endptr = purpose + slength; - - /* We need to have at least 12 bytes after the purpose string - in order to get the parameter information. */ - if (endptr <= buf + 12) - { - png_warning(png_ptr, "Invalid pCAL data"); - png_free(png_ptr, purpose); - return; - } - - png_debug(3, "Reading pCAL X0, X1, type, nparams, and units\n"); - X0 = png_get_int_32((png_bytep)buf+1); - X1 = png_get_int_32((png_bytep)buf+5); - type = buf[9]; - nparams = buf[10]; - units = buf + 11; - - png_debug(3, "Checking pCAL equation type and number of parameters\n"); - /* Check that we have the right number of parameters for known - equation types. */ - if ((type == PNG_EQUATION_LINEAR && nparams != 2) || - (type == PNG_EQUATION_BASE_E && nparams != 3) || - (type == PNG_EQUATION_ARBITRARY && nparams != 3) || - (type == PNG_EQUATION_HYPERBOLIC && nparams != 4)) - { - png_warning(png_ptr, "Invalid pCAL parameters for equation type"); - png_free(png_ptr, purpose); - return; - } - else if (type >= PNG_EQUATION_LAST) - { - png_warning(png_ptr, "Unrecognized equation type for pCAL chunk"); - } - - for (buf = units; *buf; buf++) - /* Empty loop to move past the units string. */ ; - - png_debug(3, "Allocating pCAL parameters array\n"); - params = (png_charpp)png_malloc_warn(png_ptr, (png_uint_32)(nparams - *png_sizeof(png_charp))) ; - if (params == NULL) - { - png_free(png_ptr, purpose); - png_warning(png_ptr, "No memory for pCAL params."); - return; - } - - /* Get pointers to the start of each parameter string. */ - for (i = 0; i < (int)nparams; i++) - { - buf++; /* Skip the null string terminator from previous parameter. */ - - png_debug1(3, "Reading pCAL parameter %d\n", i); - for (params[i] = buf; *buf != 0x00 && buf <= endptr; buf++) - /* Empty loop to move past each parameter string */ ; - - /* Make sure we haven't run out of data yet */ - if (buf > endptr) - { - png_warning(png_ptr, "Invalid pCAL data"); - png_free(png_ptr, purpose); - png_free(png_ptr, params); - return; - } - } - - png_set_pCAL(png_ptr, info_ptr, purpose, X0, X1, type, nparams, - units, params); - - png_free(png_ptr, purpose); - png_free(png_ptr, params); -} -#endif - -#if defined(PNG_READ_sCAL_SUPPORTED) -/* read the sCAL chunk */ -void /* PRIVATE */ -png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_charp buffer, ep; -#ifdef PNG_FLOATING_POINT_SUPPORTED - double width, height; - png_charp vp; -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - png_charp swidth, sheight; -#endif -#endif - png_size_t slength; - - png_debug(1, "in png_handle_sCAL\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before sCAL"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid sCAL after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sCAL)) - { - png_warning(png_ptr, "Duplicate sCAL chunk"); - png_crc_finish(png_ptr, length); - return; - } - - png_debug1(2, "Allocating and reading sCAL chunk data (%lu bytes)\n", - length + 1); - buffer = (png_charp)png_malloc_warn(png_ptr, length + 1); - if (buffer == NULL) - { - png_warning(png_ptr, "Out of memory while processing sCAL chunk"); - return; - } - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)buffer, slength); - - if (png_crc_finish(png_ptr, 0)) - { - png_free(png_ptr, buffer); - return; - } - - buffer[slength] = 0x00; /* null terminate the last string */ - - ep = buffer + 1; /* skip unit byte */ - -#ifdef PNG_FLOATING_POINT_SUPPORTED - width = png_strtod(png_ptr, ep, &vp); - if (*vp) - { - png_warning(png_ptr, "malformed width string in sCAL chunk"); - return; - } -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - swidth = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1); - if (swidth == NULL) - { - png_warning(png_ptr, "Out of memory while processing sCAL chunk width"); - return; - } - png_memcpy(swidth, ep, (png_size_t)png_strlen(ep)); -#endif -#endif - - for (ep = buffer; *ep; ep++) - /* empty loop */ ; - ep++; - -#ifdef PNG_FLOATING_POINT_SUPPORTED - height = png_strtod(png_ptr, ep, &vp); - if (*vp) - { - png_warning(png_ptr, "malformed height string in sCAL chunk"); - return; - } -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - sheight = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1); - if (swidth == NULL) - { - png_warning(png_ptr, "Out of memory while processing sCAL chunk height"); - return; - } - png_memcpy(sheight, ep, (png_size_t)png_strlen(ep)); -#endif -#endif - - if (buffer + slength < ep -#ifdef PNG_FLOATING_POINT_SUPPORTED - || width <= 0. || height <= 0. -#endif - ) - { - png_warning(png_ptr, "Invalid sCAL data"); - png_free(png_ptr, buffer); -#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) - png_free(png_ptr, swidth); - png_free(png_ptr, sheight); -#endif - return; - } - - -#ifdef PNG_FLOATING_POINT_SUPPORTED - png_set_sCAL(png_ptr, info_ptr, buffer[0], width, height); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - png_set_sCAL_s(png_ptr, info_ptr, buffer[0], swidth, sheight); -#endif -#endif - - png_free(png_ptr, buffer); -#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) - png_free(png_ptr, swidth); - png_free(png_ptr, sheight); -#endif -} -#endif - -#if defined(PNG_READ_tIME_SUPPORTED) -void /* PRIVATE */ -png_handle_tIME(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_byte buf[7]; - png_time mod_time; - - png_debug(1, "in png_handle_tIME\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Out of place tIME chunk"); - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)) - { - png_warning(png_ptr, "Duplicate tIME chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (png_ptr->mode & PNG_HAVE_IDAT) - png_ptr->mode |= PNG_AFTER_IDAT; - - if (length != 7) - { - png_warning(png_ptr, "Incorrect tIME chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, 7); - if (png_crc_finish(png_ptr, 0)) - return; - - mod_time.second = buf[6]; - mod_time.minute = buf[5]; - mod_time.hour = buf[4]; - mod_time.day = buf[3]; - mod_time.month = buf[2]; - mod_time.year = png_get_uint_16(buf); - - png_set_tIME(png_ptr, info_ptr, &mod_time); -} -#endif - -#if defined(PNG_READ_tEXt_SUPPORTED) -/* Note: this does not properly handle chunks that are > 64K under DOS */ -void /* PRIVATE */ -png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_textp text_ptr; - png_charp key; - png_charp text; - png_uint_32 skip = 0; - png_size_t slength; - int ret; - - png_debug(1, "in png_handle_tEXt\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before tEXt"); - - if (png_ptr->mode & PNG_HAVE_IDAT) - png_ptr->mode |= PNG_AFTER_IDAT; - -#ifdef PNG_MAX_MALLOC_64K - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr, "tEXt chunk too large to fit in memory"); - skip = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - - key = (png_charp)png_malloc_warn(png_ptr, length + 1); - if (key == NULL) - { - png_warning(png_ptr, "No memory to process text chunk."); - return; - } - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)key, slength); - - if (png_crc_finish(png_ptr, skip)) - { - png_free(png_ptr, key); - return; - } - - key[slength] = 0x00; - - for (text = key; *text; text++) - /* empty loop to find end of key */ ; - - if (text != key + slength) - text++; - - text_ptr = (png_textp)png_malloc_warn(png_ptr, - (png_uint_32)png_sizeof(png_text)); - if (text_ptr == NULL) - { - png_warning(png_ptr, "Not enough memory to process text chunk."); - png_free(png_ptr, key); - return; - } - text_ptr->compression = PNG_TEXT_COMPRESSION_NONE; - text_ptr->key = key; -#ifdef PNG_iTXt_SUPPORTED - text_ptr->lang = NULL; - text_ptr->lang_key = NULL; - text_ptr->itxt_length = 0; -#endif - text_ptr->text = text; - text_ptr->text_length = png_strlen(text); - - ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1); - - png_free(png_ptr, key); - png_free(png_ptr, text_ptr); - if (ret) - png_warning(png_ptr, "Insufficient memory to process text chunk."); -} -#endif - -#if defined(PNG_READ_zTXt_SUPPORTED) -/* note: this does not correctly handle chunks that are > 64K under DOS */ -void /* PRIVATE */ -png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_textp text_ptr; - png_charp chunkdata; - png_charp text; - int comp_type; - int ret; - png_size_t slength, prefix_len, data_len; - - png_debug(1, "in png_handle_zTXt\n"); - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before zTXt"); - - if (png_ptr->mode & PNG_HAVE_IDAT) - png_ptr->mode |= PNG_AFTER_IDAT; - -#ifdef PNG_MAX_MALLOC_64K - /* We will no doubt have problems with chunks even half this size, but - there is no hard and fast rule to tell us where to stop. */ - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr,"zTXt chunk too large to fit in memory"); - png_crc_finish(png_ptr, length); - return; - } -#endif - - chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); - if (chunkdata == NULL) - { - png_warning(png_ptr,"Out of memory processing zTXt chunk."); - return; - } - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunkdata, slength); - if (png_crc_finish(png_ptr, 0)) - { - png_free(png_ptr, chunkdata); - return; - } - - chunkdata[slength] = 0x00; - - for (text = chunkdata; *text; text++) - /* empty loop */ ; - - /* zTXt must have some text after the chunkdataword */ - if (text == chunkdata + slength) - { - comp_type = PNG_TEXT_COMPRESSION_NONE; - png_warning(png_ptr, "Zero length zTXt chunk"); - } - else - { - comp_type = *(++text); - if (comp_type != PNG_TEXT_COMPRESSION_zTXt) - { - png_warning(png_ptr, "Unknown compression type in zTXt chunk"); - comp_type = PNG_TEXT_COMPRESSION_zTXt; - } - text++; /* skip the compression_method byte */ - } - prefix_len = text - chunkdata; - - chunkdata = (png_charp)png_decompress_chunk(png_ptr, comp_type, chunkdata, - (png_size_t)length, prefix_len, &data_len); - - text_ptr = (png_textp)png_malloc_warn(png_ptr, - (png_uint_32)png_sizeof(png_text)); - if (text_ptr == NULL) - { - png_warning(png_ptr,"Not enough memory to process zTXt chunk."); - png_free(png_ptr, chunkdata); - return; - } - text_ptr->compression = comp_type; - text_ptr->key = chunkdata; -#ifdef PNG_iTXt_SUPPORTED - text_ptr->lang = NULL; - text_ptr->lang_key = NULL; - text_ptr->itxt_length = 0; -#endif - text_ptr->text = chunkdata + prefix_len; - text_ptr->text_length = data_len; - - ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1); - - png_free(png_ptr, text_ptr); - png_free(png_ptr, chunkdata); - if (ret) - png_error(png_ptr, "Insufficient memory to store zTXt chunk."); -} -#endif - -#if defined(PNG_READ_iTXt_SUPPORTED) -/* note: this does not correctly handle chunks that are > 64K under DOS */ -void /* PRIVATE */ -png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_textp text_ptr; - png_charp chunkdata; - png_charp key, lang, text, lang_key; - int comp_flag; - int comp_type = 0; - int ret; - png_size_t slength, prefix_len, data_len; - - png_debug(1, "in png_handle_iTXt\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before iTXt"); - - if (png_ptr->mode & PNG_HAVE_IDAT) - png_ptr->mode |= PNG_AFTER_IDAT; - -#ifdef PNG_MAX_MALLOC_64K - /* We will no doubt have problems with chunks even half this size, but - there is no hard and fast rule to tell us where to stop. */ - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr,"iTXt chunk too large to fit in memory"); - png_crc_finish(png_ptr, length); - return; - } -#endif - - chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); - if (chunkdata == NULL) - { - png_warning(png_ptr, "No memory to process iTXt chunk."); - return; - } - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunkdata, slength); - if (png_crc_finish(png_ptr, 0)) - { - png_free(png_ptr, chunkdata); - return; - } - - chunkdata[slength] = 0x00; - - for (lang = chunkdata; *lang; lang++) - /* empty loop */ ; - lang++; /* skip NUL separator */ - - /* iTXt must have a language tag (possibly empty), two compression bytes, - translated keyword (possibly empty), and possibly some text after the - keyword */ - - if (lang >= chunkdata + slength) - { - comp_flag = PNG_TEXT_COMPRESSION_NONE; - png_warning(png_ptr, "Zero length iTXt chunk"); - } - else - { - comp_flag = *lang++; - comp_type = *lang++; - } - - for (lang_key = lang; *lang_key; lang_key++) - /* empty loop */ ; - lang_key++; /* skip NUL separator */ - - for (text = lang_key; *text; text++) - /* empty loop */ ; - text++; /* skip NUL separator */ - - prefix_len = text - chunkdata; - - key=chunkdata; - if (comp_flag) - chunkdata = png_decompress_chunk(png_ptr, comp_type, chunkdata, - (size_t)length, prefix_len, &data_len); - else - data_len=png_strlen(chunkdata + prefix_len); - text_ptr = (png_textp)png_malloc_warn(png_ptr, - (png_uint_32)png_sizeof(png_text)); - if (text_ptr == NULL) - { - png_warning(png_ptr,"Not enough memory to process iTXt chunk."); - png_free(png_ptr, chunkdata); - return; - } - text_ptr->compression = (int)comp_flag + 1; - text_ptr->lang_key = chunkdata+(lang_key-key); - text_ptr->lang = chunkdata+(lang-key); - text_ptr->itxt_length = data_len; - text_ptr->text_length = 0; - text_ptr->key = chunkdata; - text_ptr->text = chunkdata + prefix_len; - - ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1); - - png_free(png_ptr, text_ptr); - png_free(png_ptr, chunkdata); - if (ret) - png_error(png_ptr, "Insufficient memory to store iTXt chunk."); -} -#endif - -/* This function is called when we haven't found a handler for a - chunk. If there isn't a problem with the chunk itself (ie bad - chunk name, CRC, or a critical chunk), the chunk is silently ignored - -- unless the PNG_FLAG_UNKNOWN_CHUNKS_SUPPORTED flag is on in which - case it will be saved away to be written out later. */ -void /* PRIVATE */ -png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_uint_32 skip = 0; - - png_debug(1, "in png_handle_unknown\n"); - - if (png_ptr->mode & PNG_HAVE_IDAT) - { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IDAT; -#endif - if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) /* not an IDAT */ - png_ptr->mode |= PNG_AFTER_IDAT; - } - - png_check_chunk_name(png_ptr, png_ptr->chunk_name); - - if (!(png_ptr->chunk_name[0] & 0x20)) - { -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != - PNG_HANDLE_CHUNK_ALWAYS -#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) - && png_ptr->read_user_chunk_fn == NULL -#endif - ) -#endif - png_chunk_error(png_ptr, "unknown critical chunk"); - } - -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - if ((png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS) || - (png_ptr->read_user_chunk_fn != NULL)) - { - png_unknown_chunk chunk; - -#ifdef PNG_MAX_MALLOC_64K - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr, "unknown chunk too large to fit in memory"); - skip = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - png_strcpy((png_charp)chunk.name, (png_charp)png_ptr->chunk_name); - chunk.data = (png_bytep)png_malloc(png_ptr, length); - chunk.size = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunk.data, length); -#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) - if(png_ptr->read_user_chunk_fn != NULL) - { - /* callback to user unknown chunk handler */ - if ((*(png_ptr->read_user_chunk_fn)) (png_ptr, &chunk) <= 0) - { - if (!(png_ptr->chunk_name[0] & 0x20)) - if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != - PNG_HANDLE_CHUNK_ALWAYS) - { - png_free(png_ptr, chunk.data); - png_chunk_error(png_ptr, "unknown critical chunk"); - } - png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1); - } - } - else -#endif - png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1); - png_free(png_ptr, chunk.data); - } - else -#endif - skip = length; - - png_crc_finish(png_ptr, skip); - -#if !defined(PNG_READ_USER_CHUNKS_SUPPORTED) - if (&info_ptr == NULL) /* quiet compiler warnings about unused info_ptr */ - return; -#endif -} - -/* This function is called to verify that a chunk name is valid. - This function can't have the "critical chunk check" incorporated - into it, since in the future we will need to be able to call user - functions to handle unknown critical chunks after we check that - the chunk name itself is valid. */ - -#define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97)) - -void /* PRIVATE */ -png_check_chunk_name(png_structp png_ptr, png_bytep chunk_name) -{ - png_debug(1, "in png_check_chunk_name\n"); - if (isnonalpha(chunk_name[0]) || isnonalpha(chunk_name[1]) || - isnonalpha(chunk_name[2]) || isnonalpha(chunk_name[3])) - { - png_chunk_error(png_ptr, "invalid chunk type"); - } -} - -/* Combines the row recently read in with the existing pixels in the - row. This routine takes care of alpha and transparency if requested. - This routine also handles the two methods of progressive display - of interlaced images, depending on the mask value. - The mask value describes which pixels are to be combined with - the row. The pattern always repeats every 8 pixels, so just 8 - bits are needed. A one indicates the pixel is to be combined, - a zero indicates the pixel is to be skipped. This is in addition - to any alpha or transparency value associated with the pixel. If - you want all pixels to be combined, pass 0xff (255) in mask. */ -#ifndef PNG_HAVE_MMX_COMBINE_ROW -void /* PRIVATE */ -png_combine_row(png_structp png_ptr, png_bytep row, int mask) -{ - png_debug(1,"in png_combine_row\n"); - if (mask == 0xff) - { - png_memcpy(row, png_ptr->row_buf + 1, - PNG_ROWBYTES(png_ptr->row_info.pixel_depth, png_ptr->width)); - } - else - { - switch (png_ptr->row_info.pixel_depth) - { - case 1: - { - png_bytep sp = png_ptr->row_buf + 1; - png_bytep dp = row; - int s_inc, s_start, s_end; - int m = 0x80; - int shift; - png_uint_32 i; - png_uint_32 row_width = png_ptr->width; - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 7; - s_inc = 1; - } - else -#endif - { - s_start = 7; - s_end = 0; - s_inc = -1; - } - - shift = s_start; - - for (i = 0; i < row_width; i++) - { - if (m & mask) - { - int value; - - value = (*sp >> shift) & 0x01; - *dp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - case 2: - { - png_bytep sp = png_ptr->row_buf + 1; - png_bytep dp = row; - int s_start, s_end, s_inc; - int m = 0x80; - int shift; - png_uint_32 i; - png_uint_32 row_width = png_ptr->width; - int value; - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 6; - s_inc = 2; - } - else -#endif - { - s_start = 6; - s_end = 0; - s_inc = -2; - } - - shift = s_start; - - for (i = 0; i < row_width; i++) - { - if (m & mask) - { - value = (*sp >> shift) & 0x03; - *dp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - case 4: - { - png_bytep sp = png_ptr->row_buf + 1; - png_bytep dp = row; - int s_start, s_end, s_inc; - int m = 0x80; - int shift; - png_uint_32 i; - png_uint_32 row_width = png_ptr->width; - int value; - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 4; - s_inc = 4; - } - else -#endif - { - s_start = 4; - s_end = 0; - s_inc = -4; - } - shift = s_start; - - for (i = 0; i < row_width; i++) - { - if (m & mask) - { - value = (*sp >> shift) & 0xf; - *dp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - default: - { - png_bytep sp = png_ptr->row_buf + 1; - png_bytep dp = row; - png_size_t pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); - png_uint_32 i; - png_uint_32 row_width = png_ptr->width; - png_byte m = 0x80; - - - for (i = 0; i < row_width; i++) - { - if (m & mask) - { - png_memcpy(dp, sp, pixel_bytes); - } - - sp += pixel_bytes; - dp += pixel_bytes; - - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - } - } -} -#endif /* !PNG_HAVE_MMX_COMBINE_ROW */ - -#ifdef PNG_READ_INTERLACING_SUPPORTED -#ifndef PNG_HAVE_MMX_READ_INTERLACE /* else in pngvcrd.c, pnggccrd.c */ -/* OLD pre-1.0.9 interface: -void png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, - png_uint_32 transformations) - */ -void /* PRIVATE */ -png_do_read_interlace(png_structp png_ptr) -{ - png_row_infop row_info = &(png_ptr->row_info); - png_bytep row = png_ptr->row_buf + 1; - int pass = png_ptr->pass; - png_uint_32 transformations = png_ptr->transformations; -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - /* offset to next interlace block */ - const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; -#endif - - png_debug(1,"in png_do_read_interlace (stock C version)\n"); - if (row != NULL && row_info != NULL) - { - png_uint_32 final_width; - - final_width = row_info->width * png_pass_inc[pass]; - - switch (row_info->pixel_depth) - { - case 1: - { - png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 3); - png_bytep dp = row + (png_size_t)((final_width - 1) >> 3); - int sshift, dshift; - int s_start, s_end, s_inc; - int jstop = png_pass_inc[pass]; - png_byte v; - png_uint_32 i; - int j; - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (int)((row_info->width + 7) & 0x07); - dshift = (int)((final_width + 7) & 0x07); - s_start = 7; - s_end = 0; - s_inc = -1; - } - else -#endif - { - sshift = 7 - (int)((row_info->width + 7) & 0x07); - dshift = 7 - (int)((final_width + 7) & 0x07); - s_start = 0; - s_end = 7; - s_inc = 1; - } - - for (i = 0; i < row_info->width; i++) - { - v = (png_byte)((*sp >> sshift) & 0x01); - for (j = 0; j < jstop; j++) - { - *dp &= (png_byte)((0x7f7f >> (7 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - case 2: - { - png_bytep sp = row + (png_uint_32)((row_info->width - 1) >> 2); - png_bytep dp = row + (png_uint_32)((final_width - 1) >> 2); - int sshift, dshift; - int s_start, s_end, s_inc; - int jstop = png_pass_inc[pass]; - png_uint_32 i; - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (int)(((row_info->width + 3) & 0x03) << 1); - dshift = (int)(((final_width + 3) & 0x03) << 1); - s_start = 6; - s_end = 0; - s_inc = -2; - } - else -#endif - { - sshift = (int)((3 - ((row_info->width + 3) & 0x03)) << 1); - dshift = (int)((3 - ((final_width + 3) & 0x03)) << 1); - s_start = 0; - s_end = 6; - s_inc = 2; - } - - for (i = 0; i < row_info->width; i++) - { - png_byte v; - int j; - - v = (png_byte)((*sp >> sshift) & 0x03); - for (j = 0; j < jstop; j++) - { - *dp &= (png_byte)((0x3f3f >> (6 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - case 4: - { - png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 1); - png_bytep dp = row + (png_size_t)((final_width - 1) >> 1); - int sshift, dshift; - int s_start, s_end, s_inc; - png_uint_32 i; - int jstop = png_pass_inc[pass]; - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (int)(((row_info->width + 1) & 0x01) << 2); - dshift = (int)(((final_width + 1) & 0x01) << 2); - s_start = 4; - s_end = 0; - s_inc = -4; - } - else -#endif - { - sshift = (int)((1 - ((row_info->width + 1) & 0x01)) << 2); - dshift = (int)((1 - ((final_width + 1) & 0x01)) << 2); - s_start = 0; - s_end = 4; - s_inc = 4; - } - - for (i = 0; i < row_info->width; i++) - { - png_byte v = (png_byte)((*sp >> sshift) & 0xf); - int j; - - for (j = 0; j < jstop; j++) - { - *dp &= (png_byte)((0xf0f >> (4 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - default: - { - png_size_t pixel_bytes = (row_info->pixel_depth >> 3); - png_bytep sp = row + (png_size_t)(row_info->width - 1) * pixel_bytes; - png_bytep dp = row + (png_size_t)(final_width - 1) * pixel_bytes; - - int jstop = png_pass_inc[pass]; - png_uint_32 i; - - for (i = 0; i < row_info->width; i++) - { - png_byte v[8]; - int j; - - png_memcpy(v, sp, pixel_bytes); - for (j = 0; j < jstop; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sp -= pixel_bytes; - } - break; - } - } - row_info->width = final_width; - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,final_width); - } -#if !defined(PNG_READ_PACKSWAP_SUPPORTED) - if (&transformations == NULL) /* silence compiler warning */ - return; -#endif -} -#endif /* !PNG_HAVE_MMX_READ_INTERLACE */ -#endif /* PNG_READ_INTERLACING_SUPPORTED */ - -#ifndef PNG_HAVE_MMX_READ_FILTER_ROW -void /* PRIVATE */ -png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row, - png_bytep prev_row, int filter) -{ - png_debug(1, "in png_read_filter_row\n"); - png_debug2(2,"row = %lu, filter = %d\n", png_ptr->row_number, filter); - switch (filter) - { - case PNG_FILTER_VALUE_NONE: - break; - case PNG_FILTER_VALUE_SUB: - { - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_bytep rp = row + bpp; - png_bytep lp = row; - - for (i = bpp; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*lp++)) & 0xff); - rp++; - } - break; - } - case PNG_FILTER_VALUE_UP: - { - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_bytep rp = row; - png_bytep pp = prev_row; - - for (i = 0; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); - rp++; - } - break; - } - case PNG_FILTER_VALUE_AVG: - { - png_uint_32 i; - png_bytep rp = row; - png_bytep pp = prev_row; - png_bytep lp = row; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_uint_32 istop = row_info->rowbytes - bpp; - - for (i = 0; i < bpp; i++) - { - *rp = (png_byte)(((int)(*rp) + - ((int)(*pp++) / 2 )) & 0xff); - rp++; - } - - for (i = 0; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + - (int)(*pp++ + *lp++) / 2 ) & 0xff); - rp++; - } - break; - } - case PNG_FILTER_VALUE_PAETH: - { - png_uint_32 i; - png_bytep rp = row; - png_bytep pp = prev_row; - png_bytep lp = row; - png_bytep cp = prev_row; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_uint_32 istop=row_info->rowbytes - bpp; - - for (i = 0; i < bpp; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); - rp++; - } - - for (i = 0; i < istop; i++) /* use leftover rp,pp */ - { - int a, b, c, pa, pb, pc, p; - - a = *lp++; - b = *pp++; - c = *cp++; - - p = b - c; - pc = a - c; - -#ifdef PNG_USE_ABS - pa = abs(p); - pb = abs(pc); - pc = abs(p + pc); -#else - pa = p < 0 ? -p : p; - pb = pc < 0 ? -pc : pc; - pc = (p + pc) < 0 ? -(p + pc) : p + pc; -#endif - - /* - if (pa <= pb && pa <= pc) - p = a; - else if (pb <= pc) - p = b; - else - p = c; - */ - - p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; - - *rp = (png_byte)(((int)(*rp) + p) & 0xff); - rp++; - } - break; - } - default: - png_warning(png_ptr, "Ignoring bad adaptive filter type"); - *row=0; - break; - } -} -#endif /* !PNG_HAVE_MMX_READ_FILTER_ROW */ - -void /* PRIVATE */ -png_read_finish_row(png_structp png_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* start of interlace block */ - const int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - - /* offset to next interlace block */ - const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - - /* start of interlace block in the y direction */ - const int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - - /* offset to next interlace block in the y direction */ - const int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; -#endif - - png_debug(1, "in png_read_finish_row\n"); - png_ptr->row_number++; - if (png_ptr->row_number < png_ptr->num_rows) - return; - - if (png_ptr->interlaced) - { - png_ptr->row_number = 0; - png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1); - do - { - png_ptr->pass++; - if (png_ptr->pass >= 7) - break; - png_ptr->iwidth = (png_ptr->width + - png_pass_inc[png_ptr->pass] - 1 - - png_pass_start[png_ptr->pass]) / - png_pass_inc[png_ptr->pass]; - - png_ptr->irowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, - png_ptr->iwidth) + 1; - - if (!(png_ptr->transformations & PNG_INTERLACE)) - { - png_ptr->num_rows = (png_ptr->height + - png_pass_yinc[png_ptr->pass] - 1 - - png_pass_ystart[png_ptr->pass]) / - png_pass_yinc[png_ptr->pass]; - if (!(png_ptr->num_rows)) - continue; - } - else /* if (png_ptr->transformations & PNG_INTERLACE) */ - break; - } while (png_ptr->iwidth == 0); - - if (png_ptr->pass < 7) - return; - } - - if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) - { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IDAT; -#endif - char extra; - int ret; - - png_ptr->zstream.next_out = (Byte *)&extra; - png_ptr->zstream.avail_out = (uInt)1; - for(;;) - { - if (!(png_ptr->zstream.avail_in)) - { - while (!png_ptr->idat_size) - { - png_byte chunk_length[4]; - - png_crc_finish(png_ptr, 0); - - png_read_data(png_ptr, chunk_length, 4); - png_ptr->idat_size = png_get_uint_31(png_ptr, chunk_length); - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); - if (png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) - png_error(png_ptr, "Not enough image data"); - - } - png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size; - png_ptr->zstream.next_in = png_ptr->zbuf; - if (png_ptr->zbuf_size > png_ptr->idat_size) - png_ptr->zstream.avail_in = (uInt)png_ptr->idat_size; - png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zstream.avail_in); - png_ptr->idat_size -= png_ptr->zstream.avail_in; - } - ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); - if (ret == Z_STREAM_END) - { - if (!(png_ptr->zstream.avail_out) || png_ptr->zstream.avail_in || - png_ptr->idat_size) - png_warning(png_ptr, "Extra compressed data"); - png_ptr->mode |= PNG_AFTER_IDAT; - png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; - break; - } - if (ret != Z_OK) - png_error(png_ptr, png_ptr->zstream.msg ? png_ptr->zstream.msg : - "Decompression Error"); - - if (!(png_ptr->zstream.avail_out)) - { - png_warning(png_ptr, "Extra compressed data."); - png_ptr->mode |= PNG_AFTER_IDAT; - png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; - break; - } - - } - png_ptr->zstream.avail_out = 0; - } - - if (png_ptr->idat_size || png_ptr->zstream.avail_in) - png_warning(png_ptr, "Extra compression data"); - - inflateReset(&png_ptr->zstream); - - png_ptr->mode |= PNG_AFTER_IDAT; -} - -void /* PRIVATE */ -png_read_start_row(png_structp png_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* start of interlace block */ - const int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - - /* offset to next interlace block */ - const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - - /* start of interlace block in the y direction */ - const int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - - /* offset to next interlace block in the y direction */ - const int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; -#endif - - int max_pixel_depth; - png_uint_32 row_bytes; - - png_debug(1, "in png_read_start_row\n"); - png_ptr->zstream.avail_in = 0; - png_init_read_transformations(png_ptr); - if (png_ptr->interlaced) - { - if (!(png_ptr->transformations & PNG_INTERLACE)) - png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 - - png_pass_ystart[0]) / png_pass_yinc[0]; - else - png_ptr->num_rows = png_ptr->height; - - png_ptr->iwidth = (png_ptr->width + - png_pass_inc[png_ptr->pass] - 1 - - png_pass_start[png_ptr->pass]) / - png_pass_inc[png_ptr->pass]; - - row_bytes = PNG_ROWBYTES(png_ptr->pixel_depth,png_ptr->iwidth) + 1; - - png_ptr->irowbytes = (png_size_t)row_bytes; - if((png_uint_32)png_ptr->irowbytes != row_bytes) - png_error(png_ptr, "Rowbytes overflow in png_read_start_row"); - } - else - { - png_ptr->num_rows = png_ptr->height; - png_ptr->iwidth = png_ptr->width; - png_ptr->irowbytes = png_ptr->rowbytes + 1; - } - max_pixel_depth = png_ptr->pixel_depth; - -#if defined(PNG_READ_PACK_SUPPORTED) - if ((png_ptr->transformations & PNG_PACK) && png_ptr->bit_depth < 8) - max_pixel_depth = 8; -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) - if (png_ptr->transformations & PNG_EXPAND) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - if (png_ptr->num_trans) - max_pixel_depth = 32; - else - max_pixel_depth = 24; - } - else if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) - { - if (max_pixel_depth < 8) - max_pixel_depth = 8; - if (png_ptr->num_trans) - max_pixel_depth *= 2; - } - else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) - { - if (png_ptr->num_trans) - { - max_pixel_depth *= 4; - max_pixel_depth /= 3; - } - } - } -#endif - -#if defined(PNG_READ_FILLER_SUPPORTED) - if (png_ptr->transformations & (PNG_FILLER)) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - max_pixel_depth = 32; - else if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) - { - if (max_pixel_depth <= 8) - max_pixel_depth = 16; - else - max_pixel_depth = 32; - } - else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) - { - if (max_pixel_depth <= 32) - max_pixel_depth = 32; - else - max_pixel_depth = 64; - } - } -#endif - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) - if (png_ptr->transformations & PNG_GRAY_TO_RGB) - { - if ( -#if defined(PNG_READ_EXPAND_SUPPORTED) - (png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND)) || -#endif -#if defined(PNG_READ_FILLER_SUPPORTED) - (png_ptr->transformations & (PNG_FILLER)) || -#endif - png_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - { - if (max_pixel_depth <= 16) - max_pixel_depth = 32; - else - max_pixel_depth = 64; - } - else - { - if (max_pixel_depth <= 8) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - max_pixel_depth = 32; - else - max_pixel_depth = 24; - } - else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - max_pixel_depth = 64; - else - max_pixel_depth = 48; - } - } -#endif - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) && \ -defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) - if(png_ptr->transformations & PNG_USER_TRANSFORM) - { - int user_pixel_depth=png_ptr->user_transform_depth* - png_ptr->user_transform_channels; - if(user_pixel_depth > max_pixel_depth) - max_pixel_depth=user_pixel_depth; - } -#endif - - /* align the width on the next larger 8 pixels. Mainly used - for interlacing */ - row_bytes = ((png_ptr->width + 7) & ~((png_uint_32)7)); - /* calculate the maximum bytes needed, adding a byte and a pixel - for safety's sake */ - row_bytes = PNG_ROWBYTES(max_pixel_depth,row_bytes) + - 1 + ((max_pixel_depth + 7) >> 3); -#ifdef PNG_MAX_MALLOC_64K - if (row_bytes > (png_uint_32)65536L) - png_error(png_ptr, "This image requires a row greater than 64KB"); -#endif - png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes+64); - png_ptr->row_buf = png_ptr->big_row_buf+32; -#if defined(PNG_DEBUG) && defined(PNG_USE_PNGGCCRD) - png_ptr->row_buf_size = row_bytes; -#endif - -#ifdef PNG_MAX_MALLOC_64K - if ((png_uint_32)png_ptr->rowbytes + 1 > (png_uint_32)65536L) - png_error(png_ptr, "This image requires a row greater than 64KB"); -#endif - if ((png_uint_32)png_ptr->rowbytes > (png_uint_32)(PNG_SIZE_MAX - 1)) - png_error(png_ptr, "Row has too many bytes to allocate in memory."); - png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)( - png_ptr->rowbytes + 1)); - - png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1); - - png_debug1(3, "width = %lu,\n", png_ptr->width); - png_debug1(3, "height = %lu,\n", png_ptr->height); - png_debug1(3, "iwidth = %lu,\n", png_ptr->iwidth); - png_debug1(3, "num_rows = %lu\n", png_ptr->num_rows); - png_debug1(3, "rowbytes = %lu,\n", png_ptr->rowbytes); - png_debug1(3, "irowbytes = %lu,\n", png_ptr->irowbytes); - - png_ptr->flags |= PNG_FLAG_ROW_INIT; -} -#endif /* PNG_READ_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng_osx/pngset.c b/irrlicht-1.6/source/Irrlicht/libpng_osx/pngset.c deleted file mode 100644 index 24fa24dea..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng_osx/pngset.c +++ /dev/null @@ -1,1269 +0,0 @@ - -/* pngset.c - storage of image information into info struct - * - * Last changed in libpng 1.2.15 January 5, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * The functions here are used during reads to store data from the file - * into the info struct, and during writes to store application data - * into the info struct for writing into the file. This abstracts the - * info struct and allows us to change the structure in the future. - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) - -#if defined(PNG_bKGD_SUPPORTED) -void PNGAPI -png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background) -{ - png_debug1(1, "in %s storage function\n", "bKGD"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - png_memcpy(&(info_ptr->background), background, png_sizeof(png_color_16)); - info_ptr->valid |= PNG_INFO_bKGD; -} -#endif - -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -void PNGAPI -png_set_cHRM(png_structp png_ptr, png_infop info_ptr, - double white_x, double white_y, double red_x, double red_y, - double green_x, double green_y, double blue_x, double blue_y) -{ - png_debug1(1, "in %s storage function\n", "cHRM"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - if (white_x < 0.0 || white_y < 0.0 || - red_x < 0.0 || red_y < 0.0 || - green_x < 0.0 || green_y < 0.0 || - blue_x < 0.0 || blue_y < 0.0) - { - png_warning(png_ptr, - "Ignoring attempt to set negative chromaticity value"); - return; - } - if (white_x > 21474.83 || white_y > 21474.83 || - red_x > 21474.83 || red_y > 21474.83 || - green_x > 21474.83 || green_y > 21474.83 || - blue_x > 21474.83 || blue_y > 21474.83) - { - png_warning(png_ptr, - "Ignoring attempt to set chromaticity value exceeding 21474.83"); - return; - } - - info_ptr->x_white = (float)white_x; - info_ptr->y_white = (float)white_y; - info_ptr->x_red = (float)red_x; - info_ptr->y_red = (float)red_y; - info_ptr->x_green = (float)green_x; - info_ptr->y_green = (float)green_y; - info_ptr->x_blue = (float)blue_x; - info_ptr->y_blue = (float)blue_y; -#ifdef PNG_FIXED_POINT_SUPPORTED - info_ptr->int_x_white = (png_fixed_point)(white_x*100000.+0.5); - info_ptr->int_y_white = (png_fixed_point)(white_y*100000.+0.5); - info_ptr->int_x_red = (png_fixed_point)( red_x*100000.+0.5); - info_ptr->int_y_red = (png_fixed_point)( red_y*100000.+0.5); - info_ptr->int_x_green = (png_fixed_point)(green_x*100000.+0.5); - info_ptr->int_y_green = (png_fixed_point)(green_y*100000.+0.5); - info_ptr->int_x_blue = (png_fixed_point)( blue_x*100000.+0.5); - info_ptr->int_y_blue = (png_fixed_point)( blue_y*100000.+0.5); -#endif - info_ptr->valid |= PNG_INFO_cHRM; -} -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -void PNGAPI -png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr, - png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x, - png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y, - png_fixed_point blue_x, png_fixed_point blue_y) -{ - png_debug1(1, "in %s storage function\n", "cHRM"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - if (white_x < 0 || white_y < 0 || - red_x < 0 || red_y < 0 || - green_x < 0 || green_y < 0 || - blue_x < 0 || blue_y < 0) - { - png_warning(png_ptr, - "Ignoring attempt to set negative chromaticity value"); - return; - } -#ifdef PNG_FLOATING_POINT_SUPPORTED - if (white_x > (double) PNG_UINT_31_MAX || - white_y > (double) PNG_UINT_31_MAX || - red_x > (double) PNG_UINT_31_MAX || - red_y > (double) PNG_UINT_31_MAX || - green_x > (double) PNG_UINT_31_MAX || - green_y > (double) PNG_UINT_31_MAX || - blue_x > (double) PNG_UINT_31_MAX || - blue_y > (double) PNG_UINT_31_MAX) -#else - if (white_x > (png_fixed_point) PNG_UINT_31_MAX/100000L || - white_y > (png_fixed_point) PNG_UINT_31_MAX/100000L || - red_x > (png_fixed_point) PNG_UINT_31_MAX/100000L || - red_y > (png_fixed_point) PNG_UINT_31_MAX/100000L || - green_x > (png_fixed_point) PNG_UINT_31_MAX/100000L || - green_y > (png_fixed_point) PNG_UINT_31_MAX/100000L || - blue_x > (png_fixed_point) PNG_UINT_31_MAX/100000L || - blue_y > (png_fixed_point) PNG_UINT_31_MAX/100000L) -#endif - { - png_warning(png_ptr, - "Ignoring attempt to set chromaticity value exceeding 21474.83"); - return; - } - info_ptr->int_x_white = white_x; - info_ptr->int_y_white = white_y; - info_ptr->int_x_red = red_x; - info_ptr->int_y_red = red_y; - info_ptr->int_x_green = green_x; - info_ptr->int_y_green = green_y; - info_ptr->int_x_blue = blue_x; - info_ptr->int_y_blue = blue_y; -#ifdef PNG_FLOATING_POINT_SUPPORTED - info_ptr->x_white = (float)(white_x/100000.); - info_ptr->y_white = (float)(white_y/100000.); - info_ptr->x_red = (float)( red_x/100000.); - info_ptr->y_red = (float)( red_y/100000.); - info_ptr->x_green = (float)(green_x/100000.); - info_ptr->y_green = (float)(green_y/100000.); - info_ptr->x_blue = (float)( blue_x/100000.); - info_ptr->y_blue = (float)( blue_y/100000.); -#endif - info_ptr->valid |= PNG_INFO_cHRM; -} -#endif -#endif - -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -void PNGAPI -png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma) -{ - double gamma; - png_debug1(1, "in %s storage function\n", "gAMA"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - /* Check for overflow */ - if (file_gamma > 21474.83) - { - png_warning(png_ptr, "Limiting gamma to 21474.83"); - gamma=21474.83; - } - else - gamma=file_gamma; - info_ptr->gamma = (float)gamma; -#ifdef PNG_FIXED_POINT_SUPPORTED - info_ptr->int_gamma = (int)(gamma*100000.+.5); -#endif - info_ptr->valid |= PNG_INFO_gAMA; - if(gamma == 0.0) - png_warning(png_ptr, "Setting gamma=0"); -} -#endif -void PNGAPI -png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point - int_gamma) -{ - png_fixed_point gamma; - - png_debug1(1, "in %s storage function\n", "gAMA"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - if (int_gamma > (png_fixed_point) PNG_UINT_31_MAX) - { - png_warning(png_ptr, "Limiting gamma to 21474.83"); - gamma=PNG_UINT_31_MAX; - } - else - { - if (int_gamma < 0) - { - png_warning(png_ptr, "Setting negative gamma to zero"); - gamma=0; - } - else - gamma=int_gamma; - } -#ifdef PNG_FLOATING_POINT_SUPPORTED - info_ptr->gamma = (float)(gamma/100000.); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - info_ptr->int_gamma = gamma; -#endif - info_ptr->valid |= PNG_INFO_gAMA; - if(gamma == 0) - png_warning(png_ptr, "Setting gamma=0"); -} -#endif - -#if defined(PNG_hIST_SUPPORTED) -void PNGAPI -png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist) -{ - int i; - - png_debug1(1, "in %s storage function\n", "hIST"); - if (png_ptr == NULL || info_ptr == NULL) - return; - if (info_ptr->num_palette <= 0 || info_ptr->num_palette - > PNG_MAX_PALETTE_LENGTH) - { - png_warning(png_ptr, - "Invalid palette size, hIST allocation skipped."); - return; - } - -#ifdef PNG_FREE_ME_SUPPORTED - png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0); -#endif - /* Changed from info->num_palette to PNG_MAX_PALETTE_LENGTH in version - 1.2.1 */ - png_ptr->hist = (png_uint_16p)png_malloc_warn(png_ptr, - (png_uint_32)(PNG_MAX_PALETTE_LENGTH * png_sizeof (png_uint_16))); - if (png_ptr->hist == NULL) - { - png_warning(png_ptr, "Insufficient memory for hIST chunk data."); - return; - } - - for (i = 0; i < info_ptr->num_palette; i++) - png_ptr->hist[i] = hist[i]; - info_ptr->hist = png_ptr->hist; - info_ptr->valid |= PNG_INFO_hIST; - -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_HIST; -#else - png_ptr->flags |= PNG_FLAG_FREE_HIST; -#endif -} -#endif - -void PNGAPI -png_set_IHDR(png_structp png_ptr, png_infop info_ptr, - png_uint_32 width, png_uint_32 height, int bit_depth, - int color_type, int interlace_type, int compression_type, - int filter_type) -{ - png_debug1(1, "in %s storage function\n", "IHDR"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - /* check for width and height valid values */ - if (width == 0 || height == 0) - png_error(png_ptr, "Image width or height is zero in IHDR"); -#ifdef PNG_SET_USER_LIMITS_SUPPORTED - if (width > png_ptr->user_width_max || height > png_ptr->user_height_max) - png_error(png_ptr, "image size exceeds user limits in IHDR"); -#else - if (width > PNG_USER_WIDTH_MAX || height > PNG_USER_HEIGHT_MAX) - png_error(png_ptr, "image size exceeds user limits in IHDR"); -#endif - if (width > PNG_UINT_31_MAX || height > PNG_UINT_31_MAX) - png_error(png_ptr, "Invalid image size in IHDR"); - if ( width > (PNG_UINT_32_MAX - >> 3) /* 8-byte RGBA pixels */ - - 64 /* bigrowbuf hack */ - - 1 /* filter byte */ - - 7*8 /* rounding of width to multiple of 8 pixels */ - - 8) /* extra max_pixel_depth pad */ - png_warning(png_ptr, "Width is too large for libpng to process pixels"); - - /* check other values */ - if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 && - bit_depth != 8 && bit_depth != 16) - png_error(png_ptr, "Invalid bit depth in IHDR"); - - if (color_type < 0 || color_type == 1 || - color_type == 5 || color_type > 6) - png_error(png_ptr, "Invalid color type in IHDR"); - - if (((color_type == PNG_COLOR_TYPE_PALETTE) && bit_depth > 8) || - ((color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_GRAY_ALPHA || - color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8)) - png_error(png_ptr, "Invalid color type/bit depth combination in IHDR"); - - if (interlace_type >= PNG_INTERLACE_LAST) - png_error(png_ptr, "Unknown interlace method in IHDR"); - - if (compression_type != PNG_COMPRESSION_TYPE_BASE) - png_error(png_ptr, "Unknown compression method in IHDR"); - -#if defined(PNG_MNG_FEATURES_SUPPORTED) - /* Accept filter_method 64 (intrapixel differencing) only if - * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and - * 2. Libpng did not read a PNG signature (this filter_method is only - * used in PNG datastreams that are embedded in MNG datastreams) and - * 3. The application called png_permit_mng_features with a mask that - * included PNG_FLAG_MNG_FILTER_64 and - * 4. The filter_method is 64 and - * 5. The color_type is RGB or RGBA - */ - if((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&png_ptr->mng_features_permitted) - png_warning(png_ptr,"MNG features are not allowed in a PNG datastream"); - if(filter_type != PNG_FILTER_TYPE_BASE) - { - if(!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - (filter_type == PNG_INTRAPIXEL_DIFFERENCING) && - ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) && - (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_RGB_ALPHA))) - png_error(png_ptr, "Unknown filter method in IHDR"); - if(png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) - png_warning(png_ptr, "Invalid filter method in IHDR"); - } -#else - if(filter_type != PNG_FILTER_TYPE_BASE) - png_error(png_ptr, "Unknown filter method in IHDR"); -#endif - - info_ptr->width = width; - info_ptr->height = height; - info_ptr->bit_depth = (png_byte)bit_depth; - info_ptr->color_type =(png_byte) color_type; - info_ptr->compression_type = (png_byte)compression_type; - info_ptr->filter_type = (png_byte)filter_type; - info_ptr->interlace_type = (png_byte)interlace_type; - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - info_ptr->channels = 1; - else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR) - info_ptr->channels = 3; - else - info_ptr->channels = 1; - if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA) - info_ptr->channels++; - info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth); - - /* check for potential overflow */ - if ( width > (PNG_UINT_32_MAX - >> 3) /* 8-byte RGBA pixels */ - - 64 /* bigrowbuf hack */ - - 1 /* filter byte */ - - 7*8 /* rounding of width to multiple of 8 pixels */ - - 8) /* extra max_pixel_depth pad */ - info_ptr->rowbytes = (png_size_t)0; - else - info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth,width); -} - -#if defined(PNG_oFFs_SUPPORTED) -void PNGAPI -png_set_oFFs(png_structp png_ptr, png_infop info_ptr, - png_int_32 offset_x, png_int_32 offset_y, int unit_type) -{ - png_debug1(1, "in %s storage function\n", "oFFs"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - info_ptr->x_offset = offset_x; - info_ptr->y_offset = offset_y; - info_ptr->offset_unit_type = (png_byte)unit_type; - info_ptr->valid |= PNG_INFO_oFFs; -} -#endif - -#if defined(PNG_pCAL_SUPPORTED) -void PNGAPI -png_set_pCAL(png_structp png_ptr, png_infop info_ptr, - png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams, - png_charp units, png_charpp params) -{ - png_uint_32 length; - int i; - - png_debug1(1, "in %s storage function\n", "pCAL"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - length = png_strlen(purpose) + 1; - png_debug1(3, "allocating purpose for info (%lu bytes)\n", length); - info_ptr->pcal_purpose = (png_charp)png_malloc_warn(png_ptr, length); - if (info_ptr->pcal_purpose == NULL) - { - png_warning(png_ptr, "Insufficient memory for pCAL purpose."); - return; - } - png_memcpy(info_ptr->pcal_purpose, purpose, (png_size_t)length); - - png_debug(3, "storing X0, X1, type, and nparams in info\n"); - info_ptr->pcal_X0 = X0; - info_ptr->pcal_X1 = X1; - info_ptr->pcal_type = (png_byte)type; - info_ptr->pcal_nparams = (png_byte)nparams; - - length = png_strlen(units) + 1; - png_debug1(3, "allocating units for info (%lu bytes)\n", length); - info_ptr->pcal_units = (png_charp)png_malloc_warn(png_ptr, length); - if (info_ptr->pcal_units == NULL) - { - png_warning(png_ptr, "Insufficient memory for pCAL units."); - return; - } - png_memcpy(info_ptr->pcal_units, units, (png_size_t)length); - - info_ptr->pcal_params = (png_charpp)png_malloc_warn(png_ptr, - (png_uint_32)((nparams + 1) * png_sizeof(png_charp))); - if (info_ptr->pcal_params == NULL) - { - png_warning(png_ptr, "Insufficient memory for pCAL params."); - return; - } - - info_ptr->pcal_params[nparams] = NULL; - - for (i = 0; i < nparams; i++) - { - length = png_strlen(params[i]) + 1; - png_debug2(3, "allocating parameter %d for info (%lu bytes)\n", i, length); - info_ptr->pcal_params[i] = (png_charp)png_malloc_warn(png_ptr, length); - if (info_ptr->pcal_params[i] == NULL) - { - png_warning(png_ptr, "Insufficient memory for pCAL parameter."); - return; - } - png_memcpy(info_ptr->pcal_params[i], params[i], (png_size_t)length); - } - - info_ptr->valid |= PNG_INFO_pCAL; -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_PCAL; -#endif -} -#endif - -#if defined(PNG_READ_sCAL_SUPPORTED) || defined(PNG_WRITE_sCAL_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -void PNGAPI -png_set_sCAL(png_structp png_ptr, png_infop info_ptr, - int unit, double width, double height) -{ - png_debug1(1, "in %s storage function\n", "sCAL"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - info_ptr->scal_unit = (png_byte)unit; - info_ptr->scal_pixel_width = width; - info_ptr->scal_pixel_height = height; - - info_ptr->valid |= PNG_INFO_sCAL; -} -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -void PNGAPI -png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr, - int unit, png_charp swidth, png_charp sheight) -{ - png_uint_32 length; - - png_debug1(1, "in %s storage function\n", "sCAL"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - info_ptr->scal_unit = (png_byte)unit; - - length = png_strlen(swidth) + 1; - png_debug1(3, "allocating unit for info (%d bytes)\n", length); - info_ptr->scal_s_width = (png_charp)png_malloc_warn(png_ptr, length); - if (info_ptr->scal_s_width == NULL) - { - png_warning(png_ptr, "Memory allocation failed while processing sCAL."); - } - png_memcpy(info_ptr->scal_s_width, swidth, (png_size_t)length); - - length = png_strlen(sheight) + 1; - png_debug1(3, "allocating unit for info (%d bytes)\n", length); - info_ptr->scal_s_height = (png_charp)png_malloc_warn(png_ptr, length); - if (info_ptr->scal_s_height == NULL) - { - png_free (png_ptr, info_ptr->scal_s_width); - png_warning(png_ptr, "Memory allocation failed while processing sCAL."); - } - png_memcpy(info_ptr->scal_s_height, sheight, (png_size_t)length); - - info_ptr->valid |= PNG_INFO_sCAL; -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_SCAL; -#endif -} -#endif -#endif -#endif - -#if defined(PNG_pHYs_SUPPORTED) -void PNGAPI -png_set_pHYs(png_structp png_ptr, png_infop info_ptr, - png_uint_32 res_x, png_uint_32 res_y, int unit_type) -{ - png_debug1(1, "in %s storage function\n", "pHYs"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - info_ptr->x_pixels_per_unit = res_x; - info_ptr->y_pixels_per_unit = res_y; - info_ptr->phys_unit_type = (png_byte)unit_type; - info_ptr->valid |= PNG_INFO_pHYs; -} -#endif - -void PNGAPI -png_set_PLTE(png_structp png_ptr, png_infop info_ptr, - png_colorp palette, int num_palette) -{ - - png_debug1(1, "in %s storage function\n", "PLTE"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - if (num_palette < 0 || num_palette > PNG_MAX_PALETTE_LENGTH) - { - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - png_error(png_ptr, "Invalid palette length"); - else - { - png_warning(png_ptr, "Invalid palette length"); - return; - } - } - - /* - * It may not actually be necessary to set png_ptr->palette here; - * we do it for backward compatibility with the way the png_handle_tRNS - * function used to do the allocation. - */ -#ifdef PNG_FREE_ME_SUPPORTED - png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0); -#endif - - /* Changed in libpng-1.2.1 to allocate PNG_MAX_PALETTE_LENGTH instead - of num_palette entries, - in case of an invalid PNG file that has too-large sample values. */ - png_ptr->palette = (png_colorp)png_malloc(png_ptr, - PNG_MAX_PALETTE_LENGTH * png_sizeof(png_color)); - png_memset(png_ptr->palette, 0, PNG_MAX_PALETTE_LENGTH * - png_sizeof(png_color)); - png_memcpy(png_ptr->palette, palette, num_palette * png_sizeof (png_color)); - info_ptr->palette = png_ptr->palette; - info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette; - -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_PLTE; -#else - png_ptr->flags |= PNG_FLAG_FREE_PLTE; -#endif - - info_ptr->valid |= PNG_INFO_PLTE; -} - -#if defined(PNG_sBIT_SUPPORTED) -void PNGAPI -png_set_sBIT(png_structp png_ptr, png_infop info_ptr, - png_color_8p sig_bit) -{ - png_debug1(1, "in %s storage function\n", "sBIT"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - png_memcpy(&(info_ptr->sig_bit), sig_bit, png_sizeof (png_color_8)); - info_ptr->valid |= PNG_INFO_sBIT; -} -#endif - -#if defined(PNG_sRGB_SUPPORTED) -void PNGAPI -png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent) -{ - png_debug1(1, "in %s storage function\n", "sRGB"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - info_ptr->srgb_intent = (png_byte)intent; - info_ptr->valid |= PNG_INFO_sRGB; -} - -void PNGAPI -png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr, - int intent) -{ -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED - float file_gamma; -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - png_fixed_point int_file_gamma; -#endif -#endif -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED - float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y; -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - png_fixed_point int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, - int_green_y, int_blue_x, int_blue_y; -#endif -#endif - png_debug1(1, "in %s storage function\n", "sRGB_gAMA_and_cHRM"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - png_set_sRGB(png_ptr, info_ptr, intent); - -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED - file_gamma = (float).45455; - png_set_gAMA(png_ptr, info_ptr, file_gamma); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - int_file_gamma = 45455L; - png_set_gAMA_fixed(png_ptr, info_ptr, int_file_gamma); -#endif -#endif - -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FIXED_POINT_SUPPORTED - int_white_x = 31270L; - int_white_y = 32900L; - int_red_x = 64000L; - int_red_y = 33000L; - int_green_x = 30000L; - int_green_y = 60000L; - int_blue_x = 15000L; - int_blue_y = 6000L; - - png_set_cHRM_fixed(png_ptr, info_ptr, - int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, int_green_y, - int_blue_x, int_blue_y); -#endif -#ifdef PNG_FLOATING_POINT_SUPPORTED - white_x = (float).3127; - white_y = (float).3290; - red_x = (float).64; - red_y = (float).33; - green_x = (float).30; - green_y = (float).60; - blue_x = (float).15; - blue_y = (float).06; - - png_set_cHRM(png_ptr, info_ptr, - white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y); -#endif -#endif -} -#endif - - -#if defined(PNG_iCCP_SUPPORTED) -void PNGAPI -png_set_iCCP(png_structp png_ptr, png_infop info_ptr, - png_charp name, int compression_type, - png_charp profile, png_uint_32 proflen) -{ - png_charp new_iccp_name; - png_charp new_iccp_profile; - - png_debug1(1, "in %s storage function\n", "iCCP"); - if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL) - return; - - new_iccp_name = (png_charp)png_malloc_warn(png_ptr, png_strlen(name)+1); - if (new_iccp_name == NULL) - { - png_warning(png_ptr, "Insufficient memory to process iCCP chunk."); - return; - } - png_strcpy(new_iccp_name, name); - new_iccp_profile = (png_charp)png_malloc_warn(png_ptr, proflen); - if (new_iccp_profile == NULL) - { - png_free (png_ptr, new_iccp_name); - png_warning(png_ptr, "Insufficient memory to process iCCP profile."); - return; - } - png_memcpy(new_iccp_profile, profile, (png_size_t)proflen); - - png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, 0); - - info_ptr->iccp_proflen = proflen; - info_ptr->iccp_name = new_iccp_name; - info_ptr->iccp_profile = new_iccp_profile; - /* Compression is always zero but is here so the API and info structure - * does not have to change if we introduce multiple compression types */ - info_ptr->iccp_compression = (png_byte)compression_type; -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_ICCP; -#endif - info_ptr->valid |= PNG_INFO_iCCP; -} -#endif - -#if defined(PNG_TEXT_SUPPORTED) -void PNGAPI -png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, - int num_text) -{ - int ret; - ret=png_set_text_2(png_ptr, info_ptr, text_ptr, num_text); - if (ret) - png_error(png_ptr, "Insufficient memory to store text"); -} - -int /* PRIVATE */ -png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, - int num_text) -{ - int i; - - png_debug1(1, "in %s storage function\n", (png_ptr->chunk_name[0] == '\0' ? - "text" : (png_const_charp)png_ptr->chunk_name)); - - if (png_ptr == NULL || info_ptr == NULL || num_text == 0) - return(0); - - /* Make sure we have enough space in the "text" array in info_struct - * to hold all of the incoming text_ptr objects. - */ - if (info_ptr->num_text + num_text > info_ptr->max_text) - { - if (info_ptr->text != NULL) - { - png_textp old_text; - int old_max; - - old_max = info_ptr->max_text; - info_ptr->max_text = info_ptr->num_text + num_text + 8; - old_text = info_ptr->text; - info_ptr->text = (png_textp)png_malloc_warn(png_ptr, - (png_uint_32)(info_ptr->max_text * png_sizeof (png_text))); - if (info_ptr->text == NULL) - { - png_free(png_ptr, old_text); - return(1); - } - png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max * - png_sizeof(png_text))); - png_free(png_ptr, old_text); - } - else - { - info_ptr->max_text = num_text + 8; - info_ptr->num_text = 0; - info_ptr->text = (png_textp)png_malloc_warn(png_ptr, - (png_uint_32)(info_ptr->max_text * png_sizeof (png_text))); - if (info_ptr->text == NULL) - return(1); -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_TEXT; -#endif - } - png_debug1(3, "allocated %d entries for info_ptr->text\n", - info_ptr->max_text); - } - for (i = 0; i < num_text; i++) - { - png_size_t text_length,key_len; - png_size_t lang_len,lang_key_len; - png_textp textp = &(info_ptr->text[info_ptr->num_text]); - - if (text_ptr[i].key == NULL) - continue; - - key_len = png_strlen(text_ptr[i].key); - - if(text_ptr[i].compression <= 0) - { - lang_len = 0; - lang_key_len = 0; - } - else -#ifdef PNG_iTXt_SUPPORTED - { - /* set iTXt data */ - if (text_ptr[i].lang != NULL) - lang_len = png_strlen(text_ptr[i].lang); - else - lang_len = 0; - if (text_ptr[i].lang_key != NULL) - lang_key_len = png_strlen(text_ptr[i].lang_key); - else - lang_key_len = 0; - } -#else - { - png_warning(png_ptr, "iTXt chunk not supported."); - continue; - } -#endif - - if (text_ptr[i].text == NULL || text_ptr[i].text[0] == '\0') - { - text_length = 0; -#ifdef PNG_iTXt_SUPPORTED - if(text_ptr[i].compression > 0) - textp->compression = PNG_ITXT_COMPRESSION_NONE; - else -#endif - textp->compression = PNG_TEXT_COMPRESSION_NONE; - } - else - { - text_length = png_strlen(text_ptr[i].text); - textp->compression = text_ptr[i].compression; - } - - textp->key = (png_charp)png_malloc_warn(png_ptr, - (png_uint_32)(key_len + text_length + lang_len + lang_key_len + 4)); - if (textp->key == NULL) - return(1); - png_debug2(2, "Allocated %lu bytes at %x in png_set_text\n", - (png_uint_32)(key_len + lang_len + lang_key_len + text_length + 4), - (int)textp->key); - - png_memcpy(textp->key, text_ptr[i].key, - (png_size_t)(key_len)); - *(textp->key+key_len) = '\0'; -#ifdef PNG_iTXt_SUPPORTED - if (text_ptr[i].compression > 0) - { - textp->lang=textp->key + key_len + 1; - png_memcpy(textp->lang, text_ptr[i].lang, lang_len); - *(textp->lang+lang_len) = '\0'; - textp->lang_key=textp->lang + lang_len + 1; - png_memcpy(textp->lang_key, text_ptr[i].lang_key, lang_key_len); - *(textp->lang_key+lang_key_len) = '\0'; - textp->text=textp->lang_key + lang_key_len + 1; - } - else -#endif - { -#ifdef PNG_iTXt_SUPPORTED - textp->lang=NULL; - textp->lang_key=NULL; -#endif - textp->text=textp->key + key_len + 1; - } - if(text_length) - png_memcpy(textp->text, text_ptr[i].text, - (png_size_t)(text_length)); - *(textp->text+text_length) = '\0'; - -#ifdef PNG_iTXt_SUPPORTED - if(textp->compression > 0) - { - textp->text_length = 0; - textp->itxt_length = text_length; - } - else -#endif - { - textp->text_length = text_length; -#ifdef PNG_iTXt_SUPPORTED - textp->itxt_length = 0; -#endif - } - info_ptr->text[info_ptr->num_text]= *textp; - info_ptr->num_text++; - png_debug1(3, "transferred text chunk %d\n", info_ptr->num_text); - } - return(0); -} -#endif - -#if defined(PNG_tIME_SUPPORTED) -void PNGAPI -png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time) -{ - png_debug1(1, "in %s storage function\n", "tIME"); - if (png_ptr == NULL || info_ptr == NULL || - (png_ptr->mode & PNG_WROTE_tIME)) - return; - - png_memcpy(&(info_ptr->mod_time), mod_time, png_sizeof (png_time)); - info_ptr->valid |= PNG_INFO_tIME; -} -#endif - -#if defined(PNG_tRNS_SUPPORTED) -void PNGAPI -png_set_tRNS(png_structp png_ptr, png_infop info_ptr, - png_bytep trans, int num_trans, png_color_16p trans_values) -{ - png_debug1(1, "in %s storage function\n", "tRNS"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - if (trans != NULL) - { - /* - * It may not actually be necessary to set png_ptr->trans here; - * we do it for backward compatibility with the way the png_handle_tRNS - * function used to do the allocation. - */ -#ifdef PNG_FREE_ME_SUPPORTED - png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0); -#endif - /* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */ - png_ptr->trans = info_ptr->trans = (png_bytep)png_malloc(png_ptr, - (png_uint_32)PNG_MAX_PALETTE_LENGTH); - if (num_trans <= PNG_MAX_PALETTE_LENGTH) - png_memcpy(info_ptr->trans, trans, (png_size_t)num_trans); -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_TRNS; -#else - png_ptr->flags |= PNG_FLAG_FREE_TRNS; -#endif - } - - if (trans_values != NULL) - { - png_memcpy(&(info_ptr->trans_values), trans_values, - png_sizeof(png_color_16)); - if (num_trans == 0) - num_trans = 1; - } - info_ptr->num_trans = (png_uint_16)num_trans; - info_ptr->valid |= PNG_INFO_tRNS; -} -#endif - -#if defined(PNG_sPLT_SUPPORTED) -void PNGAPI -png_set_sPLT(png_structp png_ptr, - png_infop info_ptr, png_sPLT_tp entries, int nentries) -{ - png_sPLT_tp np; - int i; - - if (png_ptr == NULL || info_ptr == NULL) - return; - - np = (png_sPLT_tp)png_malloc_warn(png_ptr, - (info_ptr->splt_palettes_num + nentries) * png_sizeof(png_sPLT_t)); - if (np == NULL) - { - png_warning(png_ptr, "No memory for sPLT palettes."); - return; - } - - png_memcpy(np, info_ptr->splt_palettes, - info_ptr->splt_palettes_num * png_sizeof(png_sPLT_t)); - png_free(png_ptr, info_ptr->splt_palettes); - info_ptr->splt_palettes=NULL; - - for (i = 0; i < nentries; i++) - { - png_sPLT_tp to = np + info_ptr->splt_palettes_num + i; - png_sPLT_tp from = entries + i; - - to->name = (png_charp)png_malloc(png_ptr, - png_strlen(from->name) + 1); - /* TODO: use png_malloc_warn */ - png_strcpy(to->name, from->name); - to->entries = (png_sPLT_entryp)png_malloc(png_ptr, - from->nentries * png_sizeof(png_sPLT_entry)); - /* TODO: use png_malloc_warn */ - png_memcpy(to->entries, from->entries, - from->nentries * png_sizeof(png_sPLT_entry)); - to->nentries = from->nentries; - to->depth = from->depth; - } - - info_ptr->splt_palettes = np; - info_ptr->splt_palettes_num += nentries; - info_ptr->valid |= PNG_INFO_sPLT; -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_SPLT; -#endif -} -#endif /* PNG_sPLT_SUPPORTED */ - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -void PNGAPI -png_set_unknown_chunks(png_structp png_ptr, - png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns) -{ - png_unknown_chunkp np; - int i; - - if (png_ptr == NULL || info_ptr == NULL || num_unknowns == 0) - return; - - np = (png_unknown_chunkp)png_malloc_warn(png_ptr, - (info_ptr->unknown_chunks_num + num_unknowns) * - png_sizeof(png_unknown_chunk)); - if (np == NULL) - { - png_warning(png_ptr, "Out of memory while processing unknown chunk."); - return; - } - - png_memcpy(np, info_ptr->unknown_chunks, - info_ptr->unknown_chunks_num * png_sizeof(png_unknown_chunk)); - png_free(png_ptr, info_ptr->unknown_chunks); - info_ptr->unknown_chunks=NULL; - - for (i = 0; i < num_unknowns; i++) - { - png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i; - png_unknown_chunkp from = unknowns + i; - - png_strncpy((png_charp)to->name, (png_charp)from->name, 5); - to->data = (png_bytep)png_malloc_warn(png_ptr, from->size); - if (to->data == NULL) - { - png_warning(png_ptr, "Out of memory processing unknown chunk."); - } - else - { - png_memcpy(to->data, from->data, from->size); - to->size = from->size; - - /* note our location in the read or write sequence */ - to->location = (png_byte)(png_ptr->mode & 0xff); - } - } - - info_ptr->unknown_chunks = np; - info_ptr->unknown_chunks_num += num_unknowns; -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_UNKN; -#endif -} -void PNGAPI -png_set_unknown_chunk_location(png_structp png_ptr, png_infop info_ptr, - int chunk, int location) -{ - if(png_ptr != NULL && info_ptr != NULL && chunk >= 0 && chunk < - (int)info_ptr->unknown_chunks_num) - info_ptr->unknown_chunks[chunk].location = (png_byte)location; -} -#endif - -#if defined(PNG_1_0_X) || defined(PNG_1_2_X) -#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ - defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) -void PNGAPI -png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted) -{ - /* This function is deprecated in favor of png_permit_mng_features() - and will be removed from libpng-1.3.0 */ - png_debug(1, "in png_permit_empty_plte, DEPRECATED.\n"); - if (png_ptr == NULL) - return; - png_ptr->mng_features_permitted = (png_byte) - ((png_ptr->mng_features_permitted & (~(PNG_FLAG_MNG_EMPTY_PLTE))) | - ((empty_plte_permitted & PNG_FLAG_MNG_EMPTY_PLTE))); -} -#endif -#endif - -#if defined(PNG_MNG_FEATURES_SUPPORTED) -png_uint_32 PNGAPI -png_permit_mng_features (png_structp png_ptr, png_uint_32 mng_features) -{ - png_debug(1, "in png_permit_mng_features\n"); - if (png_ptr == NULL) - return (png_uint_32)0; - png_ptr->mng_features_permitted = - (png_byte)(mng_features & PNG_ALL_MNG_FEATURES); - return (png_uint_32)png_ptr->mng_features_permitted; -} -#endif - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -void PNGAPI -png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_bytep - chunk_list, int num_chunks) -{ - png_bytep new_list, p; - int i, old_num_chunks; - if (png_ptr == NULL) - return; - if (num_chunks == 0) - { - if(keep == PNG_HANDLE_CHUNK_ALWAYS || keep == PNG_HANDLE_CHUNK_IF_SAFE) - png_ptr->flags |= PNG_FLAG_KEEP_UNKNOWN_CHUNKS; - else - png_ptr->flags &= ~PNG_FLAG_KEEP_UNKNOWN_CHUNKS; - - if(keep == PNG_HANDLE_CHUNK_ALWAYS) - png_ptr->flags |= PNG_FLAG_KEEP_UNSAFE_CHUNKS; - else - png_ptr->flags &= ~PNG_FLAG_KEEP_UNSAFE_CHUNKS; - return; - } - if (chunk_list == NULL) - return; - old_num_chunks=png_ptr->num_chunk_list; - new_list=(png_bytep)png_malloc(png_ptr, - (png_uint_32)(5*(num_chunks+old_num_chunks))); - if(png_ptr->chunk_list != NULL) - { - png_memcpy(new_list, png_ptr->chunk_list, - (png_size_t)(5*old_num_chunks)); - png_free(png_ptr, png_ptr->chunk_list); - png_ptr->chunk_list=NULL; - } - png_memcpy(new_list+5*old_num_chunks, chunk_list, - (png_size_t)(5*num_chunks)); - for (p=new_list+5*old_num_chunks+4, i=0; i<num_chunks; i++, p+=5) - *p=(png_byte)keep; - png_ptr->num_chunk_list=old_num_chunks+num_chunks; - png_ptr->chunk_list=new_list; -#ifdef PNG_FREE_ME_SUPPORTED - png_ptr->free_me |= PNG_FREE_LIST; -#endif -} -#endif - -#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) -void PNGAPI -png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr, - png_user_chunk_ptr read_user_chunk_fn) -{ - png_debug(1, "in png_set_read_user_chunk_fn\n"); - if (png_ptr == NULL) - return; - png_ptr->read_user_chunk_fn = read_user_chunk_fn; - png_ptr->user_chunk_ptr = user_chunk_ptr; -} -#endif - -#if defined(PNG_INFO_IMAGE_SUPPORTED) -void PNGAPI -png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers) -{ - png_debug1(1, "in %s storage function\n", "rows"); - - if (png_ptr == NULL || info_ptr == NULL) - return; - - if(info_ptr->row_pointers && (info_ptr->row_pointers != row_pointers)) - png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); - info_ptr->row_pointers = row_pointers; - if(row_pointers) - info_ptr->valid |= PNG_INFO_IDAT; -} -#endif - -#ifdef PNG_WRITE_SUPPORTED -void PNGAPI -png_set_compression_buffer_size(png_structp png_ptr, png_uint_32 size) -{ - if (png_ptr == NULL) - return; - if(png_ptr->zbuf) - png_free(png_ptr, png_ptr->zbuf); - png_ptr->zbuf_size = (png_size_t)size; - png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, size); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; -} -#endif - -void PNGAPI -png_set_invalid(png_structp png_ptr, png_infop info_ptr, int mask) -{ - if (png_ptr && info_ptr) - info_ptr->valid &= ~(mask); -} - - -#ifndef PNG_1_0_X -#ifdef PNG_ASSEMBLER_CODE_SUPPORTED -/* this function was added to libpng 1.2.0 and should always exist by default */ -void PNGAPI -png_set_asm_flags (png_structp png_ptr, png_uint_32 asm_flags) -{ -#ifdef PNG_MMX_CODE_SUPPORTED - png_uint_32 settable_asm_flags; - png_uint_32 settable_mmx_flags; -#endif - if (png_ptr == NULL) - return; -#ifdef PNG_MMX_CODE_SUPPORTED - - settable_mmx_flags = -#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW - PNG_ASM_FLAG_MMX_READ_COMBINE_ROW | -#endif -#ifdef PNG_HAVE_ASSEMBLER_READ_INTERLACE - PNG_ASM_FLAG_MMX_READ_INTERLACE | -#endif -#ifdef PNG_HAVE_ASSEMBLER_READ_FILTER_ROW - PNG_ASM_FLAG_MMX_READ_FILTER_SUB | - PNG_ASM_FLAG_MMX_READ_FILTER_UP | - PNG_ASM_FLAG_MMX_READ_FILTER_AVG | - PNG_ASM_FLAG_MMX_READ_FILTER_PAETH | -#endif - 0; - - /* could be some non-MMX ones in the future, but not currently: */ - settable_asm_flags = settable_mmx_flags; - - if (!(png_ptr->asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_COMPILED) || - !(png_ptr->asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU)) - { - /* clear all MMX flags if MMX isn't supported */ - settable_asm_flags &= ~settable_mmx_flags; - png_ptr->asm_flags &= ~settable_mmx_flags; - } - - /* we're replacing the settable bits with those passed in by the user, - * so first zero them out of the master copy, then bitwise-OR in the - * allowed subset that was requested */ - - png_ptr->asm_flags &= ~settable_asm_flags; /* zero them */ - png_ptr->asm_flags |= (asm_flags & settable_asm_flags); /* set them */ -#endif /* ?PNG_MMX_CODE_SUPPORTED */ -} - -/* this function was added to libpng 1.2.0 */ -void PNGAPI -png_set_mmx_thresholds (png_structp png_ptr, - png_byte mmx_bitdepth_threshold, - png_uint_32 mmx_rowbytes_threshold) -{ - if (png_ptr == NULL) - return; -#ifdef PNG_MMX_CODE_SUPPORTED - png_ptr->mmx_bitdepth_threshold = mmx_bitdepth_threshold; - png_ptr->mmx_rowbytes_threshold = mmx_rowbytes_threshold; -#endif /* ?PNG_MMX_CODE_SUPPORTED */ -} -#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ - -#ifdef PNG_SET_USER_LIMITS_SUPPORTED -/* this function was added to libpng 1.2.6 */ -void PNGAPI -png_set_user_limits (png_structp png_ptr, png_uint_32 user_width_max, - png_uint_32 user_height_max) -{ - /* Images with dimensions larger than these limits will be - * rejected by png_set_IHDR(). To accept any PNG datastream - * regardless of dimensions, set both limits to 0x7ffffffL. - */ - if(png_ptr == NULL) return; - png_ptr->user_width_max = user_width_max; - png_ptr->user_height_max = user_height_max; -} -#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ - -#endif /* ?PNG_1_0_X */ -#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng_osx/pngtest.c b/irrlicht-1.6/source/Irrlicht/libpng_osx/pngtest.c deleted file mode 100644 index 3d09dee3f..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng_osx/pngtest.c +++ /dev/null @@ -1,1554 +0,0 @@ - -/* pngtest.c - a simple test program to test libpng - * - * Last changed in libpng 1.2.6 - August 15, 2004 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2004 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This program reads in a PNG image, writes it out again, and then - * compares the two files. If the files are identical, this shows that - * the basic chunk handling, filtering, and (de)compression code is working - * properly. It does not currently test all of the transforms, although - * it probably should. - * - * The program will report "FAIL" in certain legitimate cases: - * 1) when the compression level or filter selection method is changed. - * 2) when the maximum IDAT size (PNG_ZBUF_SIZE in pngconf.h) is not 8192. - * 3) unknown unsafe-to-copy ancillary chunks or unknown critical chunks - * exist in the input file. - * 4) others not listed here... - * In these cases, it is best to check with another tool such as "pngcheck" - * to see what the differences between the two files are. - * - * If a filename is given on the command-line, then this file is used - * for the input, rather than the default "pngtest.png". This allows - * testing a wide variety of files easily. You can also test a number - * of files at once by typing "pngtest -m file1.png file2.png ..." - */ - -#include "png.h" - -#if defined(_WIN32_WCE) -# if _WIN32_WCE < 211 - __error__ (f|w)printf functions are not supported on old WindowsCE.; -# endif -# include <windows.h> -# include <stdlib.h> -# define READFILE(file, data, length, check) \ - if (ReadFile(file, data, length, &check,NULL)) check = 0 -# define WRITEFILE(file, data, length, check)) \ - if (WriteFile(file, data, length, &check, NULL)) check = 0 -# define FCLOSE(file) CloseHandle(file) -#else -# include <stdio.h> -# include <stdlib.h> -# define READFILE(file, data, length, check) \ - check=(png_size_t)fread(data,(png_size_t)1,length,file) -# define WRITEFILE(file, data, length, check) \ - check=(png_size_t)fwrite(data,(png_size_t)1, length, file) -# define FCLOSE(file) fclose(file) -#endif - -#if defined(PNG_NO_STDIO) -# if defined(_WIN32_WCE) - typedef HANDLE png_FILE_p; -# else - typedef FILE * png_FILE_p; -# endif -#endif - -/* Makes pngtest verbose so we can find problems (needs to be before png.h) */ -#ifndef PNG_DEBUG -# define PNG_DEBUG 0 -#endif - -#if !PNG_DEBUG -# define SINGLE_ROWBUF_ALLOC /* makes buffer overruns easier to nail */ -#endif - -/* Turn on CPU timing -#define PNGTEST_TIMING -*/ - -#ifdef PNG_NO_FLOATING_POINT_SUPPORTED -#undef PNGTEST_TIMING -#endif - -#ifdef PNGTEST_TIMING -static float t_start, t_stop, t_decode, t_encode, t_misc; -#include <time.h> -#endif - -#if defined(PNG_TIME_RFC1123_SUPPORTED) -static int tIME_chunk_present=0; -static char tIME_string[30] = "no tIME chunk present in file"; -#endif - -static int verbose = 0; - -int test_one_file PNGARG((PNG_CONST char *inname, PNG_CONST char *outname)); - -#ifdef __TURBOC__ -#include <mem.h> -#endif - -/* defined so I can write to a file on gui/windowing platforms */ -/* #define STDERR stderr */ -#define STDERR stdout /* for DOS */ - -/* example of using row callbacks to make a simple progress meter */ -static int status_pass=1; -static int status_dots_requested=0; -static int status_dots=1; - -/* In case a system header (e.g., on AIX) defined jmpbuf */ -#ifdef jmpbuf -# undef jmpbuf -#endif - -/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */ -#ifndef png_jmpbuf -# define png_jmpbuf(png_ptr) png_ptr->jmpbuf -#endif - -void -#ifdef PNG_1_0_X -PNGAPI -#endif -read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass); -void -#ifdef PNG_1_0_X -PNGAPI -#endif -read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass) -{ - if(png_ptr == NULL || row_number > PNG_UINT_31_MAX) return; - if(status_pass != pass) - { - fprintf(stdout,"\n Pass %d: ",pass); - status_pass = pass; - status_dots = 31; - } - status_dots--; - if(status_dots == 0) - { - fprintf(stdout, "\n "); - status_dots=30; - } - fprintf(stdout, "r"); -} - -void -#ifdef PNG_1_0_X -PNGAPI -#endif -write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass); -void -#ifdef PNG_1_0_X -PNGAPI -#endif -write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass) -{ - if(png_ptr == NULL || row_number > PNG_UINT_31_MAX || pass > 7) return; - fprintf(stdout, "w"); -} - - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) -/* Example of using user transform callback (we don't transform anything, - but merely examine the row filters. We set this to 256 rather than - 5 in case illegal filter values are present.) */ -static png_uint_32 filters_used[256]; -void -#ifdef PNG_1_0_X -PNGAPI -#endif -count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data); -void -#ifdef PNG_1_0_X -PNGAPI -#endif -count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data) -{ - if(png_ptr != NULL && row_info != NULL) - ++filters_used[*(data-1)]; -} -#endif - -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) -/* example of using user transform callback (we don't transform anything, - but merely count the zero samples) */ - -static png_uint_32 zero_samples; - -void -#ifdef PNG_1_0_X -PNGAPI -#endif -count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data); -void -#ifdef PNG_1_0_X -PNGAPI -#endif -count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data) -{ - png_bytep dp = data; - if(png_ptr == NULL)return; - - /* contents of row_info: - * png_uint_32 width width of row - * png_uint_32 rowbytes number of bytes in row - * png_byte color_type color type of pixels - * png_byte bit_depth bit depth of samples - * png_byte channels number of channels (1-4) - * png_byte pixel_depth bits per pixel (depth*channels) - */ - - - /* counts the number of zero samples (or zero pixels if color_type is 3 */ - - if(row_info->color_type == 0 || row_info->color_type == 3) - { - int pos=0; - png_uint_32 n, nstop; - for (n=0, nstop=row_info->width; n<nstop; n++) - { - if(row_info->bit_depth == 1) - { - if(((*dp << pos++ ) & 0x80) == 0) zero_samples++; - if(pos == 8) - { - pos = 0; - dp++; - } - } - if(row_info->bit_depth == 2) - { - if(((*dp << (pos+=2)) & 0xc0) == 0) zero_samples++; - if(pos == 8) - { - pos = 0; - dp++; - } - } - if(row_info->bit_depth == 4) - { - if(((*dp << (pos+=4)) & 0xf0) == 0) zero_samples++; - if(pos == 8) - { - pos = 0; - dp++; - } - } - if(row_info->bit_depth == 8) - if(*dp++ == 0) zero_samples++; - if(row_info->bit_depth == 16) - { - if((*dp | *(dp+1)) == 0) zero_samples++; - dp+=2; - } - } - } - else /* other color types */ - { - png_uint_32 n, nstop; - int channel; - int color_channels = row_info->channels; - if(row_info->color_type > 3)color_channels--; - - for (n=0, nstop=row_info->width; n<nstop; n++) - { - for (channel = 0; channel < color_channels; channel++) - { - if(row_info->bit_depth == 8) - if(*dp++ == 0) zero_samples++; - if(row_info->bit_depth == 16) - { - if((*dp | *(dp+1)) == 0) zero_samples++; - dp+=2; - } - } - if(row_info->color_type > 3) - { - dp++; - if(row_info->bit_depth == 16)dp++; - } - } - } -} -#endif /* PNG_WRITE_USER_TRANSFORM_SUPPORTED */ - -static int wrote_question = 0; - -#if defined(PNG_NO_STDIO) -/* START of code to validate stdio-free compilation */ -/* These copies of the default read/write functions come from pngrio.c and */ -/* pngwio.c. They allow "don't include stdio" testing of the library. */ -/* This is the function that does the actual reading of data. If you are - not reading from a standard C stream, you should create a replacement - read_data function and use it at run time with png_set_read_fn(), rather - than changing the library. */ - -#ifndef USE_FAR_KEYWORD -static void -pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_size_t check; - - /* fread() returns 0 on error, so it is OK to store this in a png_size_t - * instead of an int, which is what fread() actually returns. - */ - READFILE((png_FILE_p)png_ptr->io_ptr, data, length, check); - - if (check != length) - { - png_error(png_ptr, "Read Error!"); - } -} -#else -/* this is the model-independent version. Since the standard I/O library - can't handle far buffers in the medium and small models, we have to copy - the data. -*/ - -#define NEAR_BUF_SIZE 1024 -#define MIN(a,b) (a <= b ? a : b) - -static void -pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - int check; - png_byte *n_data; - png_FILE_p io_ptr; - - /* Check if data really is near. If so, use usual code. */ - n_data = (png_byte *)CVT_PTR_NOCHECK(data); - io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); - if ((png_bytep)n_data == data) - { - READFILE(io_ptr, n_data, length, check); - } - else - { - png_byte buf[NEAR_BUF_SIZE]; - png_size_t read, remaining, err; - check = 0; - remaining = length; - do - { - read = MIN(NEAR_BUF_SIZE, remaining); - READFILE(io_ptr, buf, 1, err); - png_memcpy(data, buf, read); /* copy far buffer to near buffer */ - if(err != read) - break; - else - check += err; - data += read; - remaining -= read; - } - while (remaining != 0); - } - if (check != length) - { - png_error(png_ptr, "read Error"); - } -} -#endif /* USE_FAR_KEYWORD */ - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -static void -pngtest_flush(png_structp png_ptr) -{ -#if !defined(_WIN32_WCE) - png_FILE_p io_ptr; - io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr)); - if (io_ptr != NULL) - fflush(io_ptr); -#endif -} -#endif - -/* This is the function that does the actual writing of data. If you are - not writing to a standard C stream, you should create a replacement - write_data function and use it at run time with png_set_write_fn(), rather - than changing the library. */ -#ifndef USE_FAR_KEYWORD -static void -pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_uint_32 check; - - WRITEFILE((png_FILE_p)png_ptr->io_ptr, data, length, check); - if (check != length) - { - png_error(png_ptr, "Write Error"); - } -} -#else -/* this is the model-independent version. Since the standard I/O library - can't handle far buffers in the medium and small models, we have to copy - the data. -*/ - -#define NEAR_BUF_SIZE 1024 -#define MIN(a,b) (a <= b ? a : b) - -static void -pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_uint_32 check; - png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */ - png_FILE_p io_ptr; - - /* Check if data really is near. If so, use usual code. */ - near_data = (png_byte *)CVT_PTR_NOCHECK(data); - io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); - if ((png_bytep)near_data == data) - { - WRITEFILE(io_ptr, near_data, length, check); - } - else - { - png_byte buf[NEAR_BUF_SIZE]; - png_size_t written, remaining, err; - check = 0; - remaining = length; - do - { - written = MIN(NEAR_BUF_SIZE, remaining); - png_memcpy(buf, data, written); /* copy far buffer to near buffer */ - WRITEFILE(io_ptr, buf, written, err); - if (err != written) - break; - else - check += err; - data += written; - remaining -= written; - } - while (remaining != 0); - } - if (check != length) - { - png_error(png_ptr, "Write Error"); - } -} - -#endif /* USE_FAR_KEYWORD */ - -/* This function is called when there is a warning, but the library thinks - * it can continue anyway. Replacement functions don't have to do anything - * here if you don't want to. In the default configuration, png_ptr is - * not used, but it is passed in case it may be useful. - */ -static void -pngtest_warning(png_structp png_ptr, png_const_charp message) -{ - PNG_CONST char *name = "UNKNOWN (ERROR!)"; - if (png_ptr != NULL && png_ptr->error_ptr != NULL) - name = png_ptr->error_ptr; - fprintf(STDERR, "%s: libpng warning: %s\n", name, message); -} - -/* This is the default error handling function. Note that replacements for - * this function MUST NOT RETURN, or the program will likely crash. This - * function is used by default, or if the program supplies NULL for the - * error function pointer in png_set_error_fn(). - */ -static void -pngtest_error(png_structp png_ptr, png_const_charp message) -{ - pngtest_warning(png_ptr, message); - /* We can return because png_error calls the default handler, which is - * actually OK in this case. */ -} -#endif /* PNG_NO_STDIO */ -/* END of code to validate stdio-free compilation */ - -/* START of code to validate memory allocation and deallocation */ -#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - -/* Allocate memory. For reasonable files, size should never exceed - 64K. However, zlib may allocate more then 64K if you don't tell - it not to. See zconf.h and png.h for more information. zlib does - need to allocate exactly 64K, so whatever you call here must - have the ability to do that. - - This piece of code can be compiled to validate max 64K allocations - by setting MAXSEG_64K in zlib zconf.h *or* PNG_MAX_MALLOC_64K. */ -typedef struct memory_information -{ - png_uint_32 size; - png_voidp pointer; - struct memory_information FAR *next; -} memory_information; -typedef memory_information FAR *memory_infop; - -static memory_infop pinformation = NULL; -static int current_allocation = 0; -static int maximum_allocation = 0; -static int total_allocation = 0; -static int num_allocations = 0; - -png_voidp png_debug_malloc PNGARG((png_structp png_ptr, png_uint_32 size)); -void png_debug_free PNGARG((png_structp png_ptr, png_voidp ptr)); - -png_voidp -png_debug_malloc(png_structp png_ptr, png_uint_32 size) -{ - - /* png_malloc has already tested for NULL; png_create_struct calls - png_debug_malloc directly, with png_ptr == NULL which is OK */ - - if (size == 0) - return (NULL); - - /* This calls the library allocator twice, once to get the requested - buffer and once to get a new free list entry. */ - { - /* Disable malloc_fn and free_fn */ - memory_infop pinfo; - png_set_mem_fn(png_ptr, NULL, NULL, NULL); - pinfo = (memory_infop)png_malloc(png_ptr, - (png_uint_32)png_sizeof (*pinfo)); - pinfo->size = size; - current_allocation += size; - total_allocation += size; - num_allocations ++; - if (current_allocation > maximum_allocation) - maximum_allocation = current_allocation; - pinfo->pointer = (png_voidp)png_malloc(png_ptr, size); - /* Restore malloc_fn and free_fn */ - png_set_mem_fn(png_ptr, png_voidp_NULL, (png_malloc_ptr)png_debug_malloc, - (png_free_ptr)png_debug_free); - if (size != 0 && pinfo->pointer == NULL) - { - current_allocation -= size; - total_allocation -= size; - png_error(png_ptr, - "out of memory in pngtest->png_debug_malloc."); - } - pinfo->next = pinformation; - pinformation = pinfo; - /* Make sure the caller isn't assuming zeroed memory. */ - png_memset(pinfo->pointer, 0xdd, pinfo->size); - if(verbose) - printf("png_malloc %lu bytes at %x\n",(unsigned long)size, - pinfo->pointer); - return (png_voidp)(pinfo->pointer); - } -} - -/* Free a pointer. It is removed from the list at the same time. */ -void -png_debug_free(png_structp png_ptr, png_voidp ptr) -{ - if (png_ptr == NULL) - fprintf(STDERR, "NULL pointer to png_debug_free.\n"); - if (ptr == 0) - { -#if 0 /* This happens all the time. */ - fprintf(STDERR, "WARNING: freeing NULL pointer\n"); -#endif - return; - } - - /* Unlink the element from the list. */ - { - memory_infop FAR *ppinfo = &pinformation; - for (;;) - { - memory_infop pinfo = *ppinfo; - if (pinfo->pointer == ptr) - { - *ppinfo = pinfo->next; - current_allocation -= pinfo->size; - if (current_allocation < 0) - fprintf(STDERR, "Duplicate free of memory\n"); - /* We must free the list element too, but first kill - the memory that is to be freed. */ - png_memset(ptr, 0x55, pinfo->size); - png_free_default(png_ptr, pinfo); - pinfo=NULL; - break; - } - if (pinfo->next == NULL) - { - fprintf(STDERR, "Pointer %x not found\n", (unsigned int)ptr); - break; - } - ppinfo = &pinfo->next; - } - } - - /* Finally free the data. */ - if(verbose) - printf("Freeing %x\n",ptr); - png_free_default(png_ptr, ptr); - ptr=NULL; -} -#endif /* PNG_USER_MEM_SUPPORTED && PNG_DEBUG */ -/* END of code to test memory allocation/deallocation */ - -/* Test one file */ -int -test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) -{ - static png_FILE_p fpin; - static png_FILE_p fpout; /* "static" prevents setjmp corruption */ - png_structp read_ptr; - png_infop read_info_ptr, end_info_ptr; -#ifdef PNG_WRITE_SUPPORTED - png_structp write_ptr; - png_infop write_info_ptr; - png_infop write_end_info_ptr; -#else - png_structp write_ptr = NULL; - png_infop write_info_ptr = NULL; - png_infop write_end_info_ptr = NULL; -#endif - png_bytep row_buf; - png_uint_32 y; - png_uint_32 width, height; - int num_pass, pass; - int bit_depth, color_type; -#ifdef PNG_SETJMP_SUPPORTED -#ifdef USE_FAR_KEYWORD - jmp_buf jmpbuf; -#endif -#endif - -#if defined(_WIN32_WCE) - TCHAR path[MAX_PATH]; -#endif - char inbuf[256], outbuf[256]; - - row_buf = NULL; - -#if defined(_WIN32_WCE) - MultiByteToWideChar(CP_ACP, 0, inname, -1, path, MAX_PATH); - if ((fpin = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE) -#else - if ((fpin = fopen(inname, "rb")) == NULL) -#endif - { - fprintf(STDERR, "Could not find input file %s\n", inname); - return (1); - } - -#if defined(_WIN32_WCE) - MultiByteToWideChar(CP_ACP, 0, outname, -1, path, MAX_PATH); - if ((fpout = CreateFile(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL)) == INVALID_HANDLE_VALUE) -#else - if ((fpout = fopen(outname, "wb")) == NULL) -#endif - { - fprintf(STDERR, "Could not open output file %s\n", outname); - FCLOSE(fpin); - return (1); - } - - png_debug(0, "Allocating read and write structures\n"); -#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - read_ptr = png_create_read_struct_2(PNG_LIBPNG_VER_STRING, png_voidp_NULL, - png_error_ptr_NULL, png_error_ptr_NULL, png_voidp_NULL, - (png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free); -#else - read_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL, - png_error_ptr_NULL, png_error_ptr_NULL); -#endif -#if defined(PNG_NO_STDIO) - png_set_error_fn(read_ptr, (png_voidp)inname, pngtest_error, - pngtest_warning); -#endif -#ifdef PNG_WRITE_SUPPORTED -#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - write_ptr = png_create_write_struct_2(PNG_LIBPNG_VER_STRING, png_voidp_NULL, - png_error_ptr_NULL, png_error_ptr_NULL, png_voidp_NULL, - (png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free); -#else - write_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL, - png_error_ptr_NULL, png_error_ptr_NULL); -#endif -#if defined(PNG_NO_STDIO) - png_set_error_fn(write_ptr, (png_voidp)inname, pngtest_error, - pngtest_warning); -#endif -#endif - png_debug(0, "Allocating read_info, write_info and end_info structures\n"); - read_info_ptr = png_create_info_struct(read_ptr); - end_info_ptr = png_create_info_struct(read_ptr); -#ifdef PNG_WRITE_SUPPORTED - write_info_ptr = png_create_info_struct(write_ptr); - write_end_info_ptr = png_create_info_struct(write_ptr); -#endif - -#ifdef PNG_SETJMP_SUPPORTED - png_debug(0, "Setting jmpbuf for read struct\n"); -#ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) -#else - if (setjmp(png_jmpbuf(read_ptr))) -#endif - { - fprintf(STDERR, "%s -> %s: libpng read error\n", inname, outname); - if (row_buf) - png_free(read_ptr, row_buf); - png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); -#ifdef PNG_WRITE_SUPPORTED - png_destroy_info_struct(write_ptr, &write_end_info_ptr); - png_destroy_write_struct(&write_ptr, &write_info_ptr); -#endif - FCLOSE(fpin); - FCLOSE(fpout); - return (1); - } -#ifdef USE_FAR_KEYWORD - png_memcpy(png_jmpbuf(read_ptr),jmpbuf,png_sizeof(jmp_buf)); -#endif - -#ifdef PNG_WRITE_SUPPORTED - png_debug(0, "Setting jmpbuf for write struct\n"); -#ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) -#else - if (setjmp(png_jmpbuf(write_ptr))) -#endif - { - fprintf(STDERR, "%s -> %s: libpng write error\n", inname, outname); - png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); - png_destroy_info_struct(write_ptr, &write_end_info_ptr); -#ifdef PNG_WRITE_SUPPORTED - png_destroy_write_struct(&write_ptr, &write_info_ptr); -#endif - FCLOSE(fpin); - FCLOSE(fpout); - return (1); - } -#ifdef USE_FAR_KEYWORD - png_memcpy(png_jmpbuf(write_ptr),jmpbuf,png_sizeof(jmp_buf)); -#endif -#endif -#endif - - png_debug(0, "Initializing input and output streams\n"); -#if !defined(PNG_NO_STDIO) - png_init_io(read_ptr, fpin); -# ifdef PNG_WRITE_SUPPORTED - png_init_io(write_ptr, fpout); -# endif -#else - png_set_read_fn(read_ptr, (png_voidp)fpin, pngtest_read_data); -# ifdef PNG_WRITE_SUPPORTED - png_set_write_fn(write_ptr, (png_voidp)fpout, pngtest_write_data, -# if defined(PNG_WRITE_FLUSH_SUPPORTED) - pngtest_flush); -# else - NULL); -# endif -# endif -#endif - if(status_dots_requested == 1) - { -#ifdef PNG_WRITE_SUPPORTED - png_set_write_status_fn(write_ptr, write_row_callback); -#endif - png_set_read_status_fn(read_ptr, read_row_callback); - } - else - { -#ifdef PNG_WRITE_SUPPORTED - png_set_write_status_fn(write_ptr, png_write_status_ptr_NULL); -#endif - png_set_read_status_fn(read_ptr, png_read_status_ptr_NULL); - } - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - { - int i; - for(i=0; i<256; i++) - filters_used[i]=0; - png_set_read_user_transform_fn(read_ptr, count_filters); - } -#endif -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) - zero_samples=0; - png_set_write_user_transform_fn(write_ptr, count_zero_samples); -#endif - -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) -# ifndef PNG_HANDLE_CHUNK_ALWAYS -# define PNG_HANDLE_CHUNK_ALWAYS 3 -# endif - png_set_keep_unknown_chunks(read_ptr, PNG_HANDLE_CHUNK_ALWAYS, - png_bytep_NULL, 0); -#endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) -# ifndef PNG_HANDLE_CHUNK_IF_SAFE -# define PNG_HANDLE_CHUNK_IF_SAFE 2 -# endif - png_set_keep_unknown_chunks(write_ptr, PNG_HANDLE_CHUNK_IF_SAFE, - png_bytep_NULL, 0); -#endif - - png_debug(0, "Reading info struct\n"); - png_read_info(read_ptr, read_info_ptr); - - png_debug(0, "Transferring info struct\n"); - { - int interlace_type, compression_type, filter_type; - - if (png_get_IHDR(read_ptr, read_info_ptr, &width, &height, &bit_depth, - &color_type, &interlace_type, &compression_type, &filter_type)) - { - png_set_IHDR(write_ptr, write_info_ptr, width, height, bit_depth, -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) - color_type, interlace_type, compression_type, filter_type); -#else - color_type, PNG_INTERLACE_NONE, compression_type, filter_type); -#endif - } - } -#if defined(PNG_FIXED_POINT_SUPPORTED) -#if defined(PNG_cHRM_SUPPORTED) - { - png_fixed_point white_x, white_y, red_x, red_y, green_x, green_y, blue_x, - blue_y; - if (png_get_cHRM_fixed(read_ptr, read_info_ptr, &white_x, &white_y, &red_x, - &red_y, &green_x, &green_y, &blue_x, &blue_y)) - { - png_set_cHRM_fixed(write_ptr, write_info_ptr, white_x, white_y, red_x, - red_y, green_x, green_y, blue_x, blue_y); - } - } -#endif -#if defined(PNG_gAMA_SUPPORTED) - { - png_fixed_point gamma; - - if (png_get_gAMA_fixed(read_ptr, read_info_ptr, &gamma)) - { - png_set_gAMA_fixed(write_ptr, write_info_ptr, gamma); - } - } -#endif -#else /* Use floating point versions */ -#if defined(PNG_FLOATING_POINT_SUPPORTED) -#if defined(PNG_cHRM_SUPPORTED) - { - double white_x, white_y, red_x, red_y, green_x, green_y, blue_x, - blue_y; - if (png_get_cHRM(read_ptr, read_info_ptr, &white_x, &white_y, &red_x, - &red_y, &green_x, &green_y, &blue_x, &blue_y)) - { - png_set_cHRM(write_ptr, write_info_ptr, white_x, white_y, red_x, - red_y, green_x, green_y, blue_x, blue_y); - } - } -#endif -#if defined(PNG_gAMA_SUPPORTED) - { - double gamma; - - if (png_get_gAMA(read_ptr, read_info_ptr, &gamma)) - { - png_set_gAMA(write_ptr, write_info_ptr, gamma); - } - } -#endif -#endif /* floating point */ -#endif /* fixed point */ -#if defined(PNG_iCCP_SUPPORTED) - { - png_charp name; - png_charp profile; - png_uint_32 proflen; - int compression_type; - - if (png_get_iCCP(read_ptr, read_info_ptr, &name, &compression_type, - &profile, &proflen)) - { - png_set_iCCP(write_ptr, write_info_ptr, name, compression_type, - profile, proflen); - } - } -#endif -#if defined(PNG_sRGB_SUPPORTED) - { - int intent; - - if (png_get_sRGB(read_ptr, read_info_ptr, &intent)) - { - png_set_sRGB(write_ptr, write_info_ptr, intent); - } - } -#endif - { - png_colorp palette; - int num_palette; - - if (png_get_PLTE(read_ptr, read_info_ptr, &palette, &num_palette)) - { - png_set_PLTE(write_ptr, write_info_ptr, palette, num_palette); - } - } -#if defined(PNG_bKGD_SUPPORTED) - { - png_color_16p background; - - if (png_get_bKGD(read_ptr, read_info_ptr, &background)) - { - png_set_bKGD(write_ptr, write_info_ptr, background); - } - } -#endif -#if defined(PNG_hIST_SUPPORTED) - { - png_uint_16p hist; - - if (png_get_hIST(read_ptr, read_info_ptr, &hist)) - { - png_set_hIST(write_ptr, write_info_ptr, hist); - } - } -#endif -#if defined(PNG_oFFs_SUPPORTED) - { - png_int_32 offset_x, offset_y; - int unit_type; - - if (png_get_oFFs(read_ptr, read_info_ptr,&offset_x,&offset_y,&unit_type)) - { - png_set_oFFs(write_ptr, write_info_ptr, offset_x, offset_y, unit_type); - } - } -#endif -#if defined(PNG_pCAL_SUPPORTED) - { - png_charp purpose, units; - png_charpp params; - png_int_32 X0, X1; - int type, nparams; - - if (png_get_pCAL(read_ptr, read_info_ptr, &purpose, &X0, &X1, &type, - &nparams, &units, ¶ms)) - { - png_set_pCAL(write_ptr, write_info_ptr, purpose, X0, X1, type, - nparams, units, params); - } - } -#endif -#if defined(PNG_pHYs_SUPPORTED) - { - png_uint_32 res_x, res_y; - int unit_type; - - if (png_get_pHYs(read_ptr, read_info_ptr, &res_x, &res_y, &unit_type)) - { - png_set_pHYs(write_ptr, write_info_ptr, res_x, res_y, unit_type); - } - } -#endif -#if defined(PNG_sBIT_SUPPORTED) - { - png_color_8p sig_bit; - - if (png_get_sBIT(read_ptr, read_info_ptr, &sig_bit)) - { - png_set_sBIT(write_ptr, write_info_ptr, sig_bit); - } - } -#endif -#if defined(PNG_sCAL_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED - { - int unit; - double scal_width, scal_height; - - if (png_get_sCAL(read_ptr, read_info_ptr, &unit, &scal_width, - &scal_height)) - { - png_set_sCAL(write_ptr, write_info_ptr, unit, scal_width, scal_height); - } - } -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - { - int unit; - png_charp scal_width, scal_height; - - if (png_get_sCAL_s(read_ptr, read_info_ptr, &unit, &scal_width, - &scal_height)) - { - png_set_sCAL_s(write_ptr, write_info_ptr, unit, scal_width, scal_height); - } - } -#endif -#endif -#endif -#if defined(PNG_TEXT_SUPPORTED) - { - png_textp text_ptr; - int num_text; - - if (png_get_text(read_ptr, read_info_ptr, &text_ptr, &num_text) > 0) - { - png_debug1(0, "Handling %d iTXt/tEXt/zTXt chunks\n", num_text); - png_set_text(write_ptr, write_info_ptr, text_ptr, num_text); - } - } -#endif -#if defined(PNG_tIME_SUPPORTED) - { - png_timep mod_time; - - if (png_get_tIME(read_ptr, read_info_ptr, &mod_time)) - { - png_set_tIME(write_ptr, write_info_ptr, mod_time); -#if defined(PNG_TIME_RFC1123_SUPPORTED) - /* we have to use png_strcpy instead of "=" because the string - pointed to by png_convert_to_rfc1123() gets free'ed before - we use it */ - png_strcpy(tIME_string,png_convert_to_rfc1123(read_ptr, mod_time)); - tIME_chunk_present++; -#endif /* PNG_TIME_RFC1123_SUPPORTED */ - } - } -#endif -#if defined(PNG_tRNS_SUPPORTED) - { - png_bytep trans; - int num_trans; - png_color_16p trans_values; - - if (png_get_tRNS(read_ptr, read_info_ptr, &trans, &num_trans, - &trans_values)) - { - png_set_tRNS(write_ptr, write_info_ptr, trans, num_trans, - trans_values); - } - } -#endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) - { - png_unknown_chunkp unknowns; - int num_unknowns = (int)png_get_unknown_chunks(read_ptr, read_info_ptr, - &unknowns); - if (num_unknowns) - { - png_size_t i; - png_set_unknown_chunks(write_ptr, write_info_ptr, unknowns, - num_unknowns); - /* copy the locations from the read_info_ptr. The automatically - generated locations in write_info_ptr are wrong because we - haven't written anything yet */ - for (i = 0; i < (png_size_t)num_unknowns; i++) - png_set_unknown_chunk_location(write_ptr, write_info_ptr, i, - unknowns[i].location); - } - } -#endif - -#ifdef PNG_WRITE_SUPPORTED - png_debug(0, "\nWriting info struct\n"); - -/* If we wanted, we could write info in two steps: - png_write_info_before_PLTE(write_ptr, write_info_ptr); - */ - png_write_info(write_ptr, write_info_ptr); -#endif - -#ifdef SINGLE_ROWBUF_ALLOC - png_debug(0, "\nAllocating row buffer..."); - row_buf = (png_bytep)png_malloc(read_ptr, - png_get_rowbytes(read_ptr, read_info_ptr)); - png_debug1(0, "0x%08lx\n\n", (unsigned long)row_buf); -#endif /* SINGLE_ROWBUF_ALLOC */ - png_debug(0, "Writing row data\n"); - -#if defined(PNG_READ_INTERLACING_SUPPORTED) || \ - defined(PNG_WRITE_INTERLACING_SUPPORTED) - num_pass = png_set_interlace_handling(read_ptr); -# ifdef PNG_WRITE_SUPPORTED - png_set_interlace_handling(write_ptr); -# endif -#else - num_pass=1; -#endif - -#ifdef PNGTEST_TIMING - t_stop = (float)clock(); - t_misc += (t_stop - t_start); - t_start = t_stop; -#endif - for (pass = 0; pass < num_pass; pass++) - { - png_debug1(0, "Writing row data for pass %d\n",pass); - for (y = 0; y < height; y++) - { -#ifndef SINGLE_ROWBUF_ALLOC - png_debug2(0, "\nAllocating row buffer (pass %d, y = %ld)...", pass,y); - row_buf = (png_bytep)png_malloc(read_ptr, - png_get_rowbytes(read_ptr, read_info_ptr)); - png_debug2(0, "0x%08lx (%ld bytes)\n", (unsigned long)row_buf, - png_get_rowbytes(read_ptr, read_info_ptr)); -#endif /* !SINGLE_ROWBUF_ALLOC */ - png_read_rows(read_ptr, (png_bytepp)&row_buf, png_bytepp_NULL, 1); - -#ifdef PNG_WRITE_SUPPORTED -#ifdef PNGTEST_TIMING - t_stop = (float)clock(); - t_decode += (t_stop - t_start); - t_start = t_stop; -#endif - png_write_rows(write_ptr, (png_bytepp)&row_buf, 1); -#ifdef PNGTEST_TIMING - t_stop = (float)clock(); - t_encode += (t_stop - t_start); - t_start = t_stop; -#endif -#endif /* PNG_WRITE_SUPPORTED */ - -#ifndef SINGLE_ROWBUF_ALLOC - png_debug2(0, "Freeing row buffer (pass %d, y = %ld)\n\n", pass, y); - png_free(read_ptr, row_buf); -#endif /* !SINGLE_ROWBUF_ALLOC */ - } - } - -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - png_free_data(read_ptr, read_info_ptr, PNG_FREE_UNKN, -1); -#endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) - png_free_data(write_ptr, write_info_ptr, PNG_FREE_UNKN, -1); -#endif - - png_debug(0, "Reading and writing end_info data\n"); - - png_read_end(read_ptr, end_info_ptr); -#if defined(PNG_TEXT_SUPPORTED) - { - png_textp text_ptr; - int num_text; - - if (png_get_text(read_ptr, end_info_ptr, &text_ptr, &num_text) > 0) - { - png_debug1(0, "Handling %d iTXt/tEXt/zTXt chunks\n", num_text); - png_set_text(write_ptr, write_end_info_ptr, text_ptr, num_text); - } - } -#endif -#if defined(PNG_tIME_SUPPORTED) - { - png_timep mod_time; - - if (png_get_tIME(read_ptr, end_info_ptr, &mod_time)) - { - png_set_tIME(write_ptr, write_end_info_ptr, mod_time); -#if defined(PNG_TIME_RFC1123_SUPPORTED) - /* we have to use png_strcpy instead of "=" because the string - pointed to by png_convert_to_rfc1123() gets free'ed before - we use it */ - png_strcpy(tIME_string,png_convert_to_rfc1123(read_ptr, mod_time)); - tIME_chunk_present++; -#endif /* PNG_TIME_RFC1123_SUPPORTED */ - } - } -#endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) - { - png_unknown_chunkp unknowns; - int num_unknowns; - num_unknowns = (int)png_get_unknown_chunks(read_ptr, end_info_ptr, - &unknowns); - if (num_unknowns) - { - png_size_t i; - png_set_unknown_chunks(write_ptr, write_end_info_ptr, unknowns, - num_unknowns); - /* copy the locations from the read_info_ptr. The automatically - generated locations in write_end_info_ptr are wrong because we - haven't written the end_info yet */ - for (i = 0; i < (png_size_t)num_unknowns; i++) - png_set_unknown_chunk_location(write_ptr, write_end_info_ptr, i, - unknowns[i].location); - } - } -#endif -#ifdef PNG_WRITE_SUPPORTED - png_write_end(write_ptr, write_end_info_ptr); -#endif - -#ifdef PNG_EASY_ACCESS_SUPPORTED - if(verbose) - { - png_uint_32 iwidth, iheight; - iwidth = png_get_image_width(write_ptr, write_info_ptr); - iheight = png_get_image_height(write_ptr, write_info_ptr); - fprintf(STDERR, "Image width = %lu, height = %lu\n", - (unsigned long)iwidth, (unsigned long)iheight); - } -#endif - - png_debug(0, "Destroying data structs\n"); -#ifdef SINGLE_ROWBUF_ALLOC - png_debug(1, "destroying row_buf for read_ptr\n"); - png_free(read_ptr, row_buf); - row_buf=NULL; -#endif /* SINGLE_ROWBUF_ALLOC */ - png_debug(1, "destroying read_ptr, read_info_ptr, end_info_ptr\n"); - png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); -#ifdef PNG_WRITE_SUPPORTED - png_debug(1, "destroying write_end_info_ptr\n"); - png_destroy_info_struct(write_ptr, &write_end_info_ptr); - png_debug(1, "destroying write_ptr, write_info_ptr\n"); - png_destroy_write_struct(&write_ptr, &write_info_ptr); -#endif - png_debug(0, "Destruction complete.\n"); - - FCLOSE(fpin); - FCLOSE(fpout); - - png_debug(0, "Opening files for comparison\n"); -#if defined(_WIN32_WCE) - MultiByteToWideChar(CP_ACP, 0, inname, -1, path, MAX_PATH); - if ((fpin = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE) -#else - if ((fpin = fopen(inname, "rb")) == NULL) -#endif - { - fprintf(STDERR, "Could not find file %s\n", inname); - return (1); - } - -#if defined(_WIN32_WCE) - MultiByteToWideChar(CP_ACP, 0, outname, -1, path, MAX_PATH); - if ((fpout = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE) -#else - if ((fpout = fopen(outname, "rb")) == NULL) -#endif - { - fprintf(STDERR, "Could not find file %s\n", outname); - FCLOSE(fpin); - return (1); - } - - for(;;) - { - png_size_t num_in, num_out; - - READFILE(fpin, inbuf, 1, num_in); - READFILE(fpout, outbuf, 1, num_out); - - if (num_in != num_out) - { - fprintf(STDERR, "\nFiles %s and %s are of a different size\n", - inname, outname); - if(wrote_question == 0) - { - fprintf(STDERR, - " Was %s written with the same maximum IDAT chunk size (%d bytes),", - inname,PNG_ZBUF_SIZE); - fprintf(STDERR, - "\n filtering heuristic (libpng default), compression"); - fprintf(STDERR, - " level (zlib default),\n and zlib version (%s)?\n\n", - ZLIB_VERSION); - wrote_question=1; - } - FCLOSE(fpin); - FCLOSE(fpout); - return (0); - } - - if (!num_in) - break; - - if (png_memcmp(inbuf, outbuf, num_in)) - { - fprintf(STDERR, "\nFiles %s and %s are different\n", inname, outname); - if(wrote_question == 0) - { - fprintf(STDERR, - " Was %s written with the same maximum IDAT chunk size (%d bytes),", - inname,PNG_ZBUF_SIZE); - fprintf(STDERR, - "\n filtering heuristic (libpng default), compression"); - fprintf(STDERR, - " level (zlib default),\n and zlib version (%s)?\n\n", - ZLIB_VERSION); - wrote_question=1; - } - FCLOSE(fpin); - FCLOSE(fpout); - return (0); - } - } - - FCLOSE(fpin); - FCLOSE(fpout); - - return (0); -} - -/* input and output filenames */ -#ifdef RISCOS -static PNG_CONST char *inname = "pngtest/png"; -static PNG_CONST char *outname = "pngout/png"; -#else -static PNG_CONST char *inname = "pngtest.png"; -static PNG_CONST char *outname = "pngout.png"; -#endif - -int -main(int argc, char *argv[]) -{ - int multiple = 0; - int ierror = 0; - - fprintf(STDERR, "Testing libpng version %s\n", PNG_LIBPNG_VER_STRING); - fprintf(STDERR, " with zlib version %s\n", ZLIB_VERSION); - fprintf(STDERR,"%s",png_get_copyright(NULL)); - /* Show the version of libpng used in building the library */ - fprintf(STDERR," library (%lu):%s", - (unsigned long)png_access_version_number(), - png_get_header_version(NULL)); - /* Show the version of libpng used in building the application */ - fprintf(STDERR," pngtest (%lu):%s", (unsigned long)PNG_LIBPNG_VER, - PNG_HEADER_VERSION_STRING); - fprintf(STDERR," png_sizeof(png_struct)=%ld, png_sizeof(png_info)=%ld\n", - (long)png_sizeof(png_struct), (long)png_sizeof(png_info)); - - /* Do some consistency checking on the memory allocation settings, I'm - not sure this matters, but it is nice to know, the first of these - tests should be impossible because of the way the macros are set - in pngconf.h */ -#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K) - fprintf(STDERR, " NOTE: Zlib compiled for max 64k, libpng not\n"); -#endif - /* I think the following can happen. */ -#if !defined(MAXSEG_64K) && defined(PNG_MAX_MALLOC_64K) - fprintf(STDERR, " NOTE: libpng compiled for max 64k, zlib not\n"); -#endif - - if (strcmp(png_libpng_ver, PNG_LIBPNG_VER_STRING)) - { - fprintf(STDERR, - "Warning: versions are different between png.h and png.c\n"); - fprintf(STDERR, " png.h version: %s\n", PNG_LIBPNG_VER_STRING); - fprintf(STDERR, " png.c version: %s\n\n", png_libpng_ver); - ++ierror; - } - - if (argc > 1) - { - if (strcmp(argv[1], "-m") == 0) - { - multiple = 1; - status_dots_requested = 0; - } - else if (strcmp(argv[1], "-mv") == 0 || - strcmp(argv[1], "-vm") == 0 ) - { - multiple = 1; - verbose = 1; - status_dots_requested = 1; - } - else if (strcmp(argv[1], "-v") == 0) - { - verbose = 1; - status_dots_requested = 1; - inname = argv[2]; - } - else - { - inname = argv[1]; - status_dots_requested = 0; - } - } - - if (!multiple && argc == 3+verbose) - outname = argv[2+verbose]; - - if ((!multiple && argc > 3+verbose) || (multiple && argc < 2)) - { - fprintf(STDERR, - "usage: %s [infile.png] [outfile.png]\n\t%s -m {infile.png}\n", - argv[0], argv[0]); - fprintf(STDERR, - " reads/writes one PNG file (without -m) or multiple files (-m)\n"); - fprintf(STDERR, - " with -m %s is used as a temporary file\n", outname); - exit(1); - } - - if (multiple) - { - int i; -#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - int allocation_now = current_allocation; -#endif - for (i=2; i<argc; ++i) - { -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - int k; -#endif - int kerror; - fprintf(STDERR, "Testing %s:",argv[i]); - kerror = test_one_file(argv[i], outname); - if (kerror == 0) - { -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) - fprintf(STDERR, "\n PASS (%lu zero samples)\n", - (unsigned long)zero_samples); -#else - fprintf(STDERR, " PASS\n"); -#endif -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - for (k=0; k<256; k++) - if(filters_used[k]) - fprintf(STDERR, " Filter %d was used %lu times\n", - k,(unsigned long)filters_used[k]); -#endif -#if defined(PNG_TIME_RFC1123_SUPPORTED) - if(tIME_chunk_present != 0) - fprintf(STDERR, " tIME = %s\n",tIME_string); - tIME_chunk_present = 0; -#endif /* PNG_TIME_RFC1123_SUPPORTED */ - } - else - { - fprintf(STDERR, " FAIL\n"); - ierror += kerror; - } -#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - if (allocation_now != current_allocation) - fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n", - current_allocation-allocation_now); - if (current_allocation != 0) - { - memory_infop pinfo = pinformation; - - fprintf(STDERR, "MEMORY ERROR: %d bytes still allocated\n", - current_allocation); - while (pinfo != NULL) - { - fprintf(STDERR, " %lu bytes at %x\n", (unsigned long)pinfo->size, - (unsigned int) pinfo->pointer); - pinfo = pinfo->next; - } - } -#endif - } -#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - fprintf(STDERR, " Current memory allocation: %10d bytes\n", - current_allocation); - fprintf(STDERR, " Maximum memory allocation: %10d bytes\n", - maximum_allocation); - fprintf(STDERR, " Total memory allocation: %10d bytes\n", - total_allocation); - fprintf(STDERR, " Number of allocations: %10d\n", - num_allocations); -#endif - } - else - { - int i; - for (i=0; i<3; ++i) - { - int kerror; -#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - int allocation_now = current_allocation; -#endif - if (i == 1) status_dots_requested = 1; - else if(verbose == 0)status_dots_requested = 0; - if (i == 0 || verbose == 1 || ierror != 0) - fprintf(STDERR, "Testing %s:",inname); - kerror = test_one_file(inname, outname); - if(kerror == 0) - { - if(verbose == 1 || i == 2) - { -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - int k; -#endif -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) - fprintf(STDERR, "\n PASS (%lu zero samples)\n", - (unsigned long)zero_samples); -#else - fprintf(STDERR, " PASS\n"); -#endif -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - for (k=0; k<256; k++) - if(filters_used[k]) - fprintf(STDERR, " Filter %d was used %lu times\n", - k,(unsigned long)filters_used[k]); -#endif -#if defined(PNG_TIME_RFC1123_SUPPORTED) - if(tIME_chunk_present != 0) - fprintf(STDERR, " tIME = %s\n",tIME_string); -#endif /* PNG_TIME_RFC1123_SUPPORTED */ - } - } - else - { - if(verbose == 0 && i != 2) - fprintf(STDERR, "Testing %s:",inname); - fprintf(STDERR, " FAIL\n"); - ierror += kerror; - } -#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - if (allocation_now != current_allocation) - fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n", - current_allocation-allocation_now); - if (current_allocation != 0) - { - memory_infop pinfo = pinformation; - - fprintf(STDERR, "MEMORY ERROR: %d bytes still allocated\n", - current_allocation); - while (pinfo != NULL) - { - fprintf(STDERR," %lu bytes at %x\n", - (unsigned long)pinfo->size, (unsigned int)pinfo->pointer); - pinfo = pinfo->next; - } - } -#endif - } -#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - fprintf(STDERR, " Current memory allocation: %10d bytes\n", - current_allocation); - fprintf(STDERR, " Maximum memory allocation: %10d bytes\n", - maximum_allocation); - fprintf(STDERR, " Total memory allocation: %10d bytes\n", - total_allocation); - fprintf(STDERR, " Number of allocations: %10d\n", - num_allocations); -#endif - } - -#ifdef PNGTEST_TIMING - t_stop = (float)clock(); - t_misc += (t_stop - t_start); - t_start = t_stop; - fprintf(STDERR," CPU time used = %.3f seconds", - (t_misc+t_decode+t_encode)/(float)CLOCKS_PER_SEC); - fprintf(STDERR," (decoding %.3f,\n", - t_decode/(float)CLOCKS_PER_SEC); - fprintf(STDERR," encoding %.3f ,", - t_encode/(float)CLOCKS_PER_SEC); - fprintf(STDERR," other %.3f seconds)\n\n", - t_misc/(float)CLOCKS_PER_SEC); -#endif - - if (ierror == 0) - fprintf(STDERR, "libpng passes test\n"); - else - fprintf(STDERR, "libpng FAILS test\n"); - return (int)(ierror != 0); -} - -/* Generate a compiler error if there is an old png.h in the search path. */ -typedef version_1_2_16 your_png_h_is_not_version_1_2_16; diff --git a/irrlicht-1.6/source/Irrlicht/libpng_osx/pngtrans.c b/irrlicht-1.6/source/Irrlicht/libpng_osx/pngtrans.c deleted file mode 100644 index 25f42c871..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng_osx/pngtrans.c +++ /dev/null @@ -1,661 +0,0 @@ - -/* pngtrans.c - transforms the data in a row (used by both readers and writers) - * - * Last changed in libpng 1.2.13 November 13, 2006 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2006 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) -#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -/* turn on BGR-to-RGB mapping */ -void PNGAPI -png_set_bgr(png_structp png_ptr) -{ - png_debug(1, "in png_set_bgr\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= PNG_BGR; -} -#endif - -#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) -/* turn on 16 bit byte swapping */ -void PNGAPI -png_set_swap(png_structp png_ptr) -{ - png_debug(1, "in png_set_swap\n"); - if(png_ptr == NULL) return; - if (png_ptr->bit_depth == 16) - png_ptr->transformations |= PNG_SWAP_BYTES; -} -#endif - -#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) -/* turn on pixel packing */ -void PNGAPI -png_set_packing(png_structp png_ptr) -{ - png_debug(1, "in png_set_packing\n"); - if(png_ptr == NULL) return; - if (png_ptr->bit_depth < 8) - { - png_ptr->transformations |= PNG_PACK; - png_ptr->usr_bit_depth = 8; - } -} -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED) -/* turn on packed pixel swapping */ -void PNGAPI -png_set_packswap(png_structp png_ptr) -{ - png_debug(1, "in png_set_packswap\n"); - if(png_ptr == NULL) return; - if (png_ptr->bit_depth < 8) - png_ptr->transformations |= PNG_PACKSWAP; -} -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) -void PNGAPI -png_set_shift(png_structp png_ptr, png_color_8p true_bits) -{ - png_debug(1, "in png_set_shift\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= PNG_SHIFT; - png_ptr->shift = *true_bits; -} -#endif - -#if defined(PNG_READ_INTERLACING_SUPPORTED) || \ - defined(PNG_WRITE_INTERLACING_SUPPORTED) -int PNGAPI -png_set_interlace_handling(png_structp png_ptr) -{ - png_debug(1, "in png_set_interlace handling\n"); - if (png_ptr && png_ptr->interlaced) - { - png_ptr->transformations |= PNG_INTERLACE; - return (7); - } - - return (1); -} -#endif - -#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) -/* Add a filler byte on read, or remove a filler or alpha byte on write. - * The filler type has changed in v0.95 to allow future 2-byte fillers - * for 48-bit input data, as well as to avoid problems with some compilers - * that don't like bytes as parameters. - */ -void PNGAPI -png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc) -{ - png_debug(1, "in png_set_filler\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= PNG_FILLER; - png_ptr->filler = (png_byte)filler; - if (filler_loc == PNG_FILLER_AFTER) - png_ptr->flags |= PNG_FLAG_FILLER_AFTER; - else - png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER; - - /* This should probably go in the "do_read_filler" routine. - * I attempted to do that in libpng-1.0.1a but that caused problems - * so I restored it in libpng-1.0.2a - */ - - if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) - { - png_ptr->usr_channels = 4; - } - - /* Also I added this in libpng-1.0.2a (what happens when we expand - * a less-than-8-bit grayscale to GA? */ - - if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY && png_ptr->bit_depth >= 8) - { - png_ptr->usr_channels = 2; - } -} - -#if !defined(PNG_1_0_X) -/* Added to libpng-1.2.7 */ -void PNGAPI -png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc) -{ - png_debug(1, "in png_set_add_alpha\n"); - if(png_ptr == NULL) return; - png_set_filler(png_ptr, filler, filler_loc); - png_ptr->transformations |= PNG_ADD_ALPHA; -} -#endif - -#endif - -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ - defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) -void PNGAPI -png_set_swap_alpha(png_structp png_ptr) -{ - png_debug(1, "in png_set_swap_alpha\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= PNG_SWAP_ALPHA; -} -#endif - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ - defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) -void PNGAPI -png_set_invert_alpha(png_structp png_ptr) -{ - png_debug(1, "in png_set_invert_alpha\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= PNG_INVERT_ALPHA; -} -#endif - -#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) -void PNGAPI -png_set_invert_mono(png_structp png_ptr) -{ - png_debug(1, "in png_set_invert_mono\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= PNG_INVERT_MONO; -} - -/* invert monochrome grayscale data */ -void /* PRIVATE */ -png_do_invert(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_invert\n"); - /* This test removed from libpng version 1.0.13 and 1.2.0: - * if (row_info->bit_depth == 1 && - */ -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row == NULL || row_info == NULL) - return; -#endif - if (row_info->color_type == PNG_COLOR_TYPE_GRAY) - { - png_bytep rp = row; - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - - for (i = 0; i < istop; i++) - { - *rp = (png_byte)(~(*rp)); - rp++; - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA && - row_info->bit_depth == 8) - { - png_bytep rp = row; - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - - for (i = 0; i < istop; i+=2) - { - *rp = (png_byte)(~(*rp)); - rp+=2; - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA && - row_info->bit_depth == 16) - { - png_bytep rp = row; - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - - for (i = 0; i < istop; i+=4) - { - *rp = (png_byte)(~(*rp)); - *(rp+1) = (png_byte)(~(*(rp+1))); - rp+=4; - } - } -} -#endif - -#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) -/* swaps byte order on 16 bit depth images */ -void /* PRIVATE */ -png_do_swap(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_swap\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - row_info->bit_depth == 16) - { - png_bytep rp = row; - png_uint_32 i; - png_uint_32 istop= row_info->width * row_info->channels; - - for (i = 0; i < istop; i++, rp += 2) - { - png_byte t = *rp; - *rp = *(rp + 1); - *(rp + 1) = t; - } - } -} -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED) -static PNG_CONST png_byte onebppswaptable[256] = { - 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, - 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0, - 0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, - 0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8, - 0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4, - 0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4, - 0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC, - 0x1C, 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC, - 0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2, - 0x12, 0x92, 0x52, 0xD2, 0x32, 0xB2, 0x72, 0xF2, - 0x0A, 0x8A, 0x4A, 0xCA, 0x2A, 0xAA, 0x6A, 0xEA, - 0x1A, 0x9A, 0x5A, 0xDA, 0x3A, 0xBA, 0x7A, 0xFA, - 0x06, 0x86, 0x46, 0xC6, 0x26, 0xA6, 0x66, 0xE6, - 0x16, 0x96, 0x56, 0xD6, 0x36, 0xB6, 0x76, 0xF6, - 0x0E, 0x8E, 0x4E, 0xCE, 0x2E, 0xAE, 0x6E, 0xEE, - 0x1E, 0x9E, 0x5E, 0xDE, 0x3E, 0xBE, 0x7E, 0xFE, - 0x01, 0x81, 0x41, 0xC1, 0x21, 0xA1, 0x61, 0xE1, - 0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1, - 0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9, - 0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9, - 0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5, - 0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5, - 0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED, - 0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD, - 0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3, - 0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3, - 0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB, - 0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB, - 0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7, - 0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7, - 0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF, - 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF -}; - -static PNG_CONST png_byte twobppswaptable[256] = { - 0x00, 0x40, 0x80, 0xC0, 0x10, 0x50, 0x90, 0xD0, - 0x20, 0x60, 0xA0, 0xE0, 0x30, 0x70, 0xB0, 0xF0, - 0x04, 0x44, 0x84, 0xC4, 0x14, 0x54, 0x94, 0xD4, - 0x24, 0x64, 0xA4, 0xE4, 0x34, 0x74, 0xB4, 0xF4, - 0x08, 0x48, 0x88, 0xC8, 0x18, 0x58, 0x98, 0xD8, - 0x28, 0x68, 0xA8, 0xE8, 0x38, 0x78, 0xB8, 0xF8, - 0x0C, 0x4C, 0x8C, 0xCC, 0x1C, 0x5C, 0x9C, 0xDC, - 0x2C, 0x6C, 0xAC, 0xEC, 0x3C, 0x7C, 0xBC, 0xFC, - 0x01, 0x41, 0x81, 0xC1, 0x11, 0x51, 0x91, 0xD1, - 0x21, 0x61, 0xA1, 0xE1, 0x31, 0x71, 0xB1, 0xF1, - 0x05, 0x45, 0x85, 0xC5, 0x15, 0x55, 0x95, 0xD5, - 0x25, 0x65, 0xA5, 0xE5, 0x35, 0x75, 0xB5, 0xF5, - 0x09, 0x49, 0x89, 0xC9, 0x19, 0x59, 0x99, 0xD9, - 0x29, 0x69, 0xA9, 0xE9, 0x39, 0x79, 0xB9, 0xF9, - 0x0D, 0x4D, 0x8D, 0xCD, 0x1D, 0x5D, 0x9D, 0xDD, - 0x2D, 0x6D, 0xAD, 0xED, 0x3D, 0x7D, 0xBD, 0xFD, - 0x02, 0x42, 0x82, 0xC2, 0x12, 0x52, 0x92, 0xD2, - 0x22, 0x62, 0xA2, 0xE2, 0x32, 0x72, 0xB2, 0xF2, - 0x06, 0x46, 0x86, 0xC6, 0x16, 0x56, 0x96, 0xD6, - 0x26, 0x66, 0xA6, 0xE6, 0x36, 0x76, 0xB6, 0xF6, - 0x0A, 0x4A, 0x8A, 0xCA, 0x1A, 0x5A, 0x9A, 0xDA, - 0x2A, 0x6A, 0xAA, 0xEA, 0x3A, 0x7A, 0xBA, 0xFA, - 0x0E, 0x4E, 0x8E, 0xCE, 0x1E, 0x5E, 0x9E, 0xDE, - 0x2E, 0x6E, 0xAE, 0xEE, 0x3E, 0x7E, 0xBE, 0xFE, - 0x03, 0x43, 0x83, 0xC3, 0x13, 0x53, 0x93, 0xD3, - 0x23, 0x63, 0xA3, 0xE3, 0x33, 0x73, 0xB3, 0xF3, - 0x07, 0x47, 0x87, 0xC7, 0x17, 0x57, 0x97, 0xD7, - 0x27, 0x67, 0xA7, 0xE7, 0x37, 0x77, 0xB7, 0xF7, - 0x0B, 0x4B, 0x8B, 0xCB, 0x1B, 0x5B, 0x9B, 0xDB, - 0x2B, 0x6B, 0xAB, 0xEB, 0x3B, 0x7B, 0xBB, 0xFB, - 0x0F, 0x4F, 0x8F, 0xCF, 0x1F, 0x5F, 0x9F, 0xDF, - 0x2F, 0x6F, 0xAF, 0xEF, 0x3F, 0x7F, 0xBF, 0xFF -}; - -static PNG_CONST png_byte fourbppswaptable[256] = { - 0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, - 0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0, - 0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71, - 0x81, 0x91, 0xA1, 0xB1, 0xC1, 0xD1, 0xE1, 0xF1, - 0x02, 0x12, 0x22, 0x32, 0x42, 0x52, 0x62, 0x72, - 0x82, 0x92, 0xA2, 0xB2, 0xC2, 0xD2, 0xE2, 0xF2, - 0x03, 0x13, 0x23, 0x33, 0x43, 0x53, 0x63, 0x73, - 0x83, 0x93, 0xA3, 0xB3, 0xC3, 0xD3, 0xE3, 0xF3, - 0x04, 0x14, 0x24, 0x34, 0x44, 0x54, 0x64, 0x74, - 0x84, 0x94, 0xA4, 0xB4, 0xC4, 0xD4, 0xE4, 0xF4, - 0x05, 0x15, 0x25, 0x35, 0x45, 0x55, 0x65, 0x75, - 0x85, 0x95, 0xA5, 0xB5, 0xC5, 0xD5, 0xE5, 0xF5, - 0x06, 0x16, 0x26, 0x36, 0x46, 0x56, 0x66, 0x76, - 0x86, 0x96, 0xA6, 0xB6, 0xC6, 0xD6, 0xE6, 0xF6, - 0x07, 0x17, 0x27, 0x37, 0x47, 0x57, 0x67, 0x77, - 0x87, 0x97, 0xA7, 0xB7, 0xC7, 0xD7, 0xE7, 0xF7, - 0x08, 0x18, 0x28, 0x38, 0x48, 0x58, 0x68, 0x78, - 0x88, 0x98, 0xA8, 0xB8, 0xC8, 0xD8, 0xE8, 0xF8, - 0x09, 0x19, 0x29, 0x39, 0x49, 0x59, 0x69, 0x79, - 0x89, 0x99, 0xA9, 0xB9, 0xC9, 0xD9, 0xE9, 0xF9, - 0x0A, 0x1A, 0x2A, 0x3A, 0x4A, 0x5A, 0x6A, 0x7A, - 0x8A, 0x9A, 0xAA, 0xBA, 0xCA, 0xDA, 0xEA, 0xFA, - 0x0B, 0x1B, 0x2B, 0x3B, 0x4B, 0x5B, 0x6B, 0x7B, - 0x8B, 0x9B, 0xAB, 0xBB, 0xCB, 0xDB, 0xEB, 0xFB, - 0x0C, 0x1C, 0x2C, 0x3C, 0x4C, 0x5C, 0x6C, 0x7C, - 0x8C, 0x9C, 0xAC, 0xBC, 0xCC, 0xDC, 0xEC, 0xFC, - 0x0D, 0x1D, 0x2D, 0x3D, 0x4D, 0x5D, 0x6D, 0x7D, - 0x8D, 0x9D, 0xAD, 0xBD, 0xCD, 0xDD, 0xED, 0xFD, - 0x0E, 0x1E, 0x2E, 0x3E, 0x4E, 0x5E, 0x6E, 0x7E, - 0x8E, 0x9E, 0xAE, 0xBE, 0xCE, 0xDE, 0xEE, 0xFE, - 0x0F, 0x1F, 0x2F, 0x3F, 0x4F, 0x5F, 0x6F, 0x7F, - 0x8F, 0x9F, 0xAF, 0xBF, 0xCF, 0xDF, 0xEF, 0xFF -}; - -/* swaps pixel packing order within bytes */ -void /* PRIVATE */ -png_do_packswap(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_packswap\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - row_info->bit_depth < 8) - { - png_bytep rp, end, table; - - end = row + row_info->rowbytes; - - if (row_info->bit_depth == 1) - table = (png_bytep)onebppswaptable; - else if (row_info->bit_depth == 2) - table = (png_bytep)twobppswaptable; - else if (row_info->bit_depth == 4) - table = (png_bytep)fourbppswaptable; - else - return; - - for (rp = row; rp < end; rp++) - *rp = table[*rp]; - } -} -#endif /* PNG_READ_PACKSWAP_SUPPORTED or PNG_WRITE_PACKSWAP_SUPPORTED */ - -#if defined(PNG_WRITE_FILLER_SUPPORTED) || \ - defined(PNG_READ_STRIP_ALPHA_SUPPORTED) -/* remove filler or alpha byte(s) */ -void /* PRIVATE */ -png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags) -{ - png_debug(1, "in png_do_strip_filler\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif - { - png_bytep sp=row; - png_bytep dp=row; - png_uint_32 row_width=row_info->width; - png_uint_32 i; - - if ((row_info->color_type == PNG_COLOR_TYPE_RGB || - (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA && - (flags & PNG_FLAG_STRIP_ALPHA))) && - row_info->channels == 4) - { - if (row_info->bit_depth == 8) - { - /* This converts from RGBX or RGBA to RGB */ - if (flags & PNG_FLAG_FILLER_AFTER) - { - dp+=3; sp+=4; - for (i = 1; i < row_width; i++) - { - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - sp++; - } - } - /* This converts from XRGB or ARGB to RGB */ - else - { - for (i = 0; i < row_width; i++) - { - sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - } - } - row_info->pixel_depth = 24; - row_info->rowbytes = row_width * 3; - } - else /* if (row_info->bit_depth == 16) */ - { - if (flags & PNG_FLAG_FILLER_AFTER) - { - /* This converts from RRGGBBXX or RRGGBBAA to RRGGBB */ - sp += 8; dp += 6; - for (i = 1; i < row_width; i++) - { - /* This could be (although png_memcpy is probably slower): - png_memcpy(dp, sp, 6); - sp += 8; - dp += 6; - */ - - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - sp += 2; - } - } - else - { - /* This converts from XXRRGGBB or AARRGGBB to RRGGBB */ - for (i = 0; i < row_width; i++) - { - /* This could be (although png_memcpy is probably slower): - png_memcpy(dp, sp, 6); - sp += 8; - dp += 6; - */ - - sp+=2; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - } - } - row_info->pixel_depth = 48; - row_info->rowbytes = row_width * 6; - } - row_info->channels = 3; - } - else if ((row_info->color_type == PNG_COLOR_TYPE_GRAY || - (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA && - (flags & PNG_FLAG_STRIP_ALPHA))) && - row_info->channels == 2) - { - if (row_info->bit_depth == 8) - { - /* This converts from GX or GA to G */ - if (flags & PNG_FLAG_FILLER_AFTER) - { - for (i = 0; i < row_width; i++) - { - *dp++ = *sp++; - sp++; - } - } - /* This converts from XG or AG to G */ - else - { - for (i = 0; i < row_width; i++) - { - sp++; - *dp++ = *sp++; - } - } - row_info->pixel_depth = 8; - row_info->rowbytes = row_width; - } - else /* if (row_info->bit_depth == 16) */ - { - if (flags & PNG_FLAG_FILLER_AFTER) - { - /* This converts from GGXX or GGAA to GG */ - sp += 4; dp += 2; - for (i = 1; i < row_width; i++) - { - *dp++ = *sp++; - *dp++ = *sp++; - sp += 2; - } - } - else - { - /* This converts from XXGG or AAGG to GG */ - for (i = 0; i < row_width; i++) - { - sp += 2; - *dp++ = *sp++; - *dp++ = *sp++; - } - } - row_info->pixel_depth = 16; - row_info->rowbytes = row_width * 2; - } - row_info->channels = 1; - } - if (flags & PNG_FLAG_STRIP_ALPHA) - row_info->color_type &= ~PNG_COLOR_MASK_ALPHA; - } -} -#endif - -#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -/* swaps red and blue bytes within a pixel */ -void /* PRIVATE */ -png_do_bgr(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_bgr\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - (row_info->color_type & PNG_COLOR_MASK_COLOR)) - { - png_uint_32 row_width = row_info->width; - if (row_info->bit_depth == 8) - { - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - { - png_bytep rp; - png_uint_32 i; - - for (i = 0, rp = row; i < row_width; i++, rp += 3) - { - png_byte save = *rp; - *rp = *(rp + 2); - *(rp + 2) = save; - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - png_bytep rp; - png_uint_32 i; - - for (i = 0, rp = row; i < row_width; i++, rp += 4) - { - png_byte save = *rp; - *rp = *(rp + 2); - *(rp + 2) = save; - } - } - } - else if (row_info->bit_depth == 16) - { - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - { - png_bytep rp; - png_uint_32 i; - - for (i = 0, rp = row; i < row_width; i++, rp += 6) - { - png_byte save = *rp; - *rp = *(rp + 4); - *(rp + 4) = save; - save = *(rp + 1); - *(rp + 1) = *(rp + 5); - *(rp + 5) = save; - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - png_bytep rp; - png_uint_32 i; - - for (i = 0, rp = row; i < row_width; i++, rp += 8) - { - png_byte save = *rp; - *rp = *(rp + 4); - *(rp + 4) = save; - save = *(rp + 1); - *(rp + 1) = *(rp + 5); - *(rp + 5) = save; - } - } - } - } -} -#endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */ - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -void PNGAPI -png_set_user_transform_info(png_structp png_ptr, png_voidp - user_transform_ptr, int user_transform_depth, int user_transform_channels) -{ - png_debug(1, "in png_set_user_transform_info\n"); - if(png_ptr == NULL) return; -#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) - png_ptr->user_transform_ptr = user_transform_ptr; - png_ptr->user_transform_depth = (png_byte)user_transform_depth; - png_ptr->user_transform_channels = (png_byte)user_transform_channels; -#else - if(user_transform_ptr || user_transform_depth || user_transform_channels) - png_warning(png_ptr, - "This version of libpng does not support user transform info"); -#endif -} -#endif - -/* This function returns a pointer to the user_transform_ptr associated with - * the user transform functions. The application should free any memory - * associated with this pointer before png_write_destroy and png_read_destroy - * are called. - */ -png_voidp PNGAPI -png_get_user_transform_ptr(png_structp png_ptr) -{ - if (png_ptr == NULL) return (NULL); -#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) - return ((png_voidp)png_ptr->user_transform_ptr); -#endif - return (NULL); -} -#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng_osx/pngvcrd.c b/irrlicht-1.6/source/Irrlicht/libpng_osx/pngvcrd.c deleted file mode 100644 index d1c6405e5..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng_osx/pngvcrd.c +++ /dev/null @@ -1,3904 +0,0 @@ - -/* pngvcrd.c - mixed C/assembler version of utilities to read a PNG file - * - * For Intel x86 CPU and Microsoft Visual C++ compiler - * - * Last changed in libpng 1.2.6 - August 15, 2004 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2004 Glenn Randers-Pehrson - * Copyright (c) 1998, Intel Corporation - * - * Contributed by Nirav Chhatrapati, Intel Corporation, 1998 - * Interface to libpng contributed by Gilles Vollant, 1999 - * - * - * In png_do_read_interlace() in libpng versions 1.0.3a through 1.0.4d, - * a sign error in the post-MMX cleanup code for each pixel_depth resulted - * in bad pixels at the beginning of some rows of some images, and also - * (due to out-of-range memory reads and writes) caused heap corruption - * when compiled with MSVC 6.0. The error was fixed in version 1.0.4e. - * - * [png_read_filter_row_mmx_avg() bpp == 2 bugfix, GRR 20000916] - * - * [runtime MMX configuration, GRR 20010102] - * - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_USE_PNGVCRD) - -static int mmx_supported=2; - - -int PNGAPI -png_mmx_support(void) -{ - int mmx_supported_local = 0; - _asm { - push ebx //CPUID will trash these - push ecx - push edx - - pushfd //Save Eflag to stack - pop eax //Get Eflag from stack into eax - mov ecx, eax //Make another copy of Eflag in ecx - xor eax, 0x200000 //Toggle ID bit in Eflag [i.e. bit(21)] - push eax //Save modified Eflag back to stack - - popfd //Restored modified value back to Eflag reg - pushfd //Save Eflag to stack - pop eax //Get Eflag from stack - push ecx // save original Eflag to stack - popfd // restore original Eflag - xor eax, ecx //Compare the new Eflag with the original Eflag - jz NOT_SUPPORTED //If the same, CPUID instruction is not supported, - //skip following instructions and jump to - //NOT_SUPPORTED label - - xor eax, eax //Set eax to zero - - _asm _emit 0x0f //CPUID instruction (two bytes opcode) - _asm _emit 0xa2 - - cmp eax, 1 //make sure eax return non-zero value - jl NOT_SUPPORTED //If eax is zero, mmx not supported - - xor eax, eax //set eax to zero - inc eax //Now increment eax to 1. This instruction is - //faster than the instruction "mov eax, 1" - - _asm _emit 0x0f //CPUID instruction - _asm _emit 0xa2 - - and edx, 0x00800000 //mask out all bits but mmx bit(24) - cmp edx, 0 // 0 = mmx not supported - jz NOT_SUPPORTED // non-zero = Yes, mmx IS supported - - mov mmx_supported_local, 1 //set return value to 1 - -NOT_SUPPORTED: - mov eax, mmx_supported_local //move return value to eax - pop edx //CPUID trashed these - pop ecx - pop ebx - } - - //mmx_supported_local=0; // test code for force don't support MMX - //printf("MMX : %u (1=MMX supported)\n",mmx_supported_local); - - mmx_supported = mmx_supported_local; - return mmx_supported_local; -} - -/* Combines the row recently read in with the previous row. - This routine takes care of alpha and transparency if requested. - This routine also handles the two methods of progressive display - of interlaced images, depending on the mask value. - The mask value describes which pixels are to be combined with - the row. The pattern always repeats every 8 pixels, so just 8 - bits are needed. A one indicates the pixel is to be combined; a - zero indicates the pixel is to be skipped. This is in addition - to any alpha or transparency value associated with the pixel. If - you want all pixels to be combined, pass 0xff (255) in mask. */ - -/* Use this routine for x86 platform - uses faster MMX routine if machine - supports MMX */ - -void /* PRIVATE */ -png_combine_row(png_structp png_ptr, png_bytep row, int mask) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; -#endif - - png_debug(1,"in png_combine_row_asm\n"); - - if (mmx_supported == 2) { -#if !defined(PNG_1_0_X) - /* this should have happened in png_init_mmx_flags() already */ - png_warning(png_ptr, "asm_flags may not have been initialized"); -#endif - png_mmx_support(); - } - - if (mask == 0xff) - { - png_memcpy(row, png_ptr->row_buf + 1, - (png_size_t)PNG_ROWBYTES(png_ptr->row_info.pixel_depth, - png_ptr->width)); - } - /* GRR: add "else if (mask == 0)" case? - * or does png_combine_row() not even get called in that case? */ - else - { - switch (png_ptr->row_info.pixel_depth) - { - case 1: - { - png_bytep sp; - png_bytep dp; - int s_inc, s_start, s_end; - int m; - int shift; - png_uint_32 i; - - sp = png_ptr->row_buf + 1; - dp = row; - m = 0x80; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 7; - s_inc = 1; - } - else -#endif - { - s_start = 7; - s_end = 0; - s_inc = -1; - } - - shift = s_start; - - for (i = 0; i < png_ptr->width; i++) - { - if (m & mask) - { - int value; - - value = (*sp >> shift) & 0x1; - *dp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - - case 2: - { - png_bytep sp; - png_bytep dp; - int s_start, s_end, s_inc; - int m; - int shift; - png_uint_32 i; - int value; - - sp = png_ptr->row_buf + 1; - dp = row; - m = 0x80; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 6; - s_inc = 2; - } - else -#endif - { - s_start = 6; - s_end = 0; - s_inc = -2; - } - - shift = s_start; - - for (i = 0; i < png_ptr->width; i++) - { - if (m & mask) - { - value = (*sp >> shift) & 0x3; - *dp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - - case 4: - { - png_bytep sp; - png_bytep dp; - int s_start, s_end, s_inc; - int m; - int shift; - png_uint_32 i; - int value; - - sp = png_ptr->row_buf + 1; - dp = row; - m = 0x80; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 4; - s_inc = 4; - } - else -#endif - { - s_start = 4; - s_end = 0; - s_inc = -4; - } - shift = s_start; - - for (i = 0; i < png_ptr->width; i++) - { - if (m & mask) - { - value = (*sp >> shift) & 0xf; - *dp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - - case 8: - { - png_bytep srcptr; - png_bytep dstptr; - png_uint_32 len; - int m; - int diff, unmask; - - __int64 mask0=0x0102040810204080; - -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && mmx_supported */ ) -#else - if (mmx_supported) -#endif - { - srcptr = png_ptr->row_buf + 1; - dstptr = row; - m = 0x80; - unmask = ~mask; - len = png_ptr->width &~7; //reduce to multiple of 8 - diff = png_ptr->width & 7; //amount lost - - _asm - { - movd mm7, unmask //load bit pattern - psubb mm6,mm6 //zero mm6 - punpcklbw mm7,mm7 - punpcklwd mm7,mm7 - punpckldq mm7,mm7 //fill register with 8 masks - - movq mm0,mask0 - - pand mm0,mm7 //nonzero if keep byte - pcmpeqb mm0,mm6 //zeros->1s, v versa - - mov ecx,len //load length of line (pixels) - mov esi,srcptr //load source - mov ebx,dstptr //load dest - cmp ecx,0 //lcr - je mainloop8end - -mainloop8: - movq mm4,[esi] - pand mm4,mm0 - movq mm6,mm0 - pandn mm6,[ebx] - por mm4,mm6 - movq [ebx],mm4 - - add esi,8 //inc by 8 bytes processed - add ebx,8 - sub ecx,8 //dec by 8 pixels processed - - ja mainloop8 -mainloop8end: - - mov ecx,diff - cmp ecx,0 - jz end8 - - mov edx,mask - sal edx,24 //make low byte the high byte - -secondloop8: - sal edx,1 //move high bit to CF - jnc skip8 //if CF = 0 - mov al,[esi] - mov [ebx],al -skip8: - inc esi - inc ebx - - dec ecx - jnz secondloop8 -end8: - emms - } - } - else /* mmx not supported - use modified C routine */ - { - register unsigned int incr1, initial_val, final_val; - png_size_t pixel_bytes; - png_uint_32 i; - register int disp = png_pass_inc[png_ptr->pass]; - int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; - - pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); - srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* - pixel_bytes; - dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; - initial_val = offset_table[png_ptr->pass]*pixel_bytes; - final_val = png_ptr->width*pixel_bytes; - incr1 = (disp)*pixel_bytes; - for (i = initial_val; i < final_val; i += incr1) - { - png_memcpy(dstptr, srcptr, pixel_bytes); - srcptr += incr1; - dstptr += incr1; - } - } /* end of else */ - - break; - } // end 8 bpp - - case 16: - { - png_bytep srcptr; - png_bytep dstptr; - png_uint_32 len; - int unmask, diff; - __int64 mask1=0x0101020204040808, - mask0=0x1010202040408080; - -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && mmx_supported */ ) -#else - if (mmx_supported) -#endif - { - srcptr = png_ptr->row_buf + 1; - dstptr = row; - - unmask = ~mask; - len = (png_ptr->width)&~7; - diff = (png_ptr->width)&7; - _asm - { - movd mm7, unmask //load bit pattern - psubb mm6,mm6 //zero mm6 - punpcklbw mm7,mm7 - punpcklwd mm7,mm7 - punpckldq mm7,mm7 //fill register with 8 masks - - movq mm0,mask0 - movq mm1,mask1 - - pand mm0,mm7 - pand mm1,mm7 - - pcmpeqb mm0,mm6 - pcmpeqb mm1,mm6 - - mov ecx,len //load length of line - mov esi,srcptr //load source - mov ebx,dstptr //load dest - cmp ecx,0 //lcr - jz mainloop16end - -mainloop16: - movq mm4,[esi] - pand mm4,mm0 - movq mm6,mm0 - movq mm7,[ebx] - pandn mm6,mm7 - por mm4,mm6 - movq [ebx],mm4 - - movq mm5,[esi+8] - pand mm5,mm1 - movq mm7,mm1 - movq mm6,[ebx+8] - pandn mm7,mm6 - por mm5,mm7 - movq [ebx+8],mm5 - - add esi,16 //inc by 16 bytes processed - add ebx,16 - sub ecx,8 //dec by 8 pixels processed - - ja mainloop16 - -mainloop16end: - mov ecx,diff - cmp ecx,0 - jz end16 - - mov edx,mask - sal edx,24 //make low byte the high byte -secondloop16: - sal edx,1 //move high bit to CF - jnc skip16 //if CF = 0 - mov ax,[esi] - mov [ebx],ax -skip16: - add esi,2 - add ebx,2 - - dec ecx - jnz secondloop16 -end16: - emms - } - } - else /* mmx not supported - use modified C routine */ - { - register unsigned int incr1, initial_val, final_val; - png_size_t pixel_bytes; - png_uint_32 i; - register int disp = png_pass_inc[png_ptr->pass]; - int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; - - pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); - srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* - pixel_bytes; - dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; - initial_val = offset_table[png_ptr->pass]*pixel_bytes; - final_val = png_ptr->width*pixel_bytes; - incr1 = (disp)*pixel_bytes; - for (i = initial_val; i < final_val; i += incr1) - { - png_memcpy(dstptr, srcptr, pixel_bytes); - srcptr += incr1; - dstptr += incr1; - } - } /* end of else */ - - break; - } // end 16 bpp - - case 24: - { - png_bytep srcptr; - png_bytep dstptr; - png_uint_32 len; - int unmask, diff; - - __int64 mask2=0x0101010202020404, //24bpp - mask1=0x0408080810101020, - mask0=0x2020404040808080; - - srcptr = png_ptr->row_buf + 1; - dstptr = row; - - unmask = ~mask; - len = (png_ptr->width)&~7; - diff = (png_ptr->width)&7; - -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && mmx_supported */ ) -#else - if (mmx_supported) -#endif - { - _asm - { - movd mm7, unmask //load bit pattern - psubb mm6,mm6 //zero mm6 - punpcklbw mm7,mm7 - punpcklwd mm7,mm7 - punpckldq mm7,mm7 //fill register with 8 masks - - movq mm0,mask0 - movq mm1,mask1 - movq mm2,mask2 - - pand mm0,mm7 - pand mm1,mm7 - pand mm2,mm7 - - pcmpeqb mm0,mm6 - pcmpeqb mm1,mm6 - pcmpeqb mm2,mm6 - - mov ecx,len //load length of line - mov esi,srcptr //load source - mov ebx,dstptr //load dest - cmp ecx,0 - jz mainloop24end - -mainloop24: - movq mm4,[esi] - pand mm4,mm0 - movq mm6,mm0 - movq mm7,[ebx] - pandn mm6,mm7 - por mm4,mm6 - movq [ebx],mm4 - - - movq mm5,[esi+8] - pand mm5,mm1 - movq mm7,mm1 - movq mm6,[ebx+8] - pandn mm7,mm6 - por mm5,mm7 - movq [ebx+8],mm5 - - movq mm6,[esi+16] - pand mm6,mm2 - movq mm4,mm2 - movq mm7,[ebx+16] - pandn mm4,mm7 - por mm6,mm4 - movq [ebx+16],mm6 - - add esi,24 //inc by 24 bytes processed - add ebx,24 - sub ecx,8 //dec by 8 pixels processed - - ja mainloop24 - -mainloop24end: - mov ecx,diff - cmp ecx,0 - jz end24 - - mov edx,mask - sal edx,24 //make low byte the high byte -secondloop24: - sal edx,1 //move high bit to CF - jnc skip24 //if CF = 0 - mov ax,[esi] - mov [ebx],ax - xor eax,eax - mov al,[esi+2] - mov [ebx+2],al -skip24: - add esi,3 - add ebx,3 - - dec ecx - jnz secondloop24 - -end24: - emms - } - } - else /* mmx not supported - use modified C routine */ - { - register unsigned int incr1, initial_val, final_val; - png_size_t pixel_bytes; - png_uint_32 i; - register int disp = png_pass_inc[png_ptr->pass]; - int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; - - pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); - srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* - pixel_bytes; - dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; - initial_val = offset_table[png_ptr->pass]*pixel_bytes; - final_val = png_ptr->width*pixel_bytes; - incr1 = (disp)*pixel_bytes; - for (i = initial_val; i < final_val; i += incr1) - { - png_memcpy(dstptr, srcptr, pixel_bytes); - srcptr += incr1; - dstptr += incr1; - } - } /* end of else */ - - break; - } // end 24 bpp - - case 32: - { - png_bytep srcptr; - png_bytep dstptr; - png_uint_32 len; - int unmask, diff; - - __int64 mask3=0x0101010102020202, //32bpp - mask2=0x0404040408080808, - mask1=0x1010101020202020, - mask0=0x4040404080808080; - - srcptr = png_ptr->row_buf + 1; - dstptr = row; - - unmask = ~mask; - len = (png_ptr->width)&~7; - diff = (png_ptr->width)&7; - -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && mmx_supported */ ) -#else - if (mmx_supported) -#endif - { - _asm - { - movd mm7, unmask //load bit pattern - psubb mm6,mm6 //zero mm6 - punpcklbw mm7,mm7 - punpcklwd mm7,mm7 - punpckldq mm7,mm7 //fill register with 8 masks - - movq mm0,mask0 - movq mm1,mask1 - movq mm2,mask2 - movq mm3,mask3 - - pand mm0,mm7 - pand mm1,mm7 - pand mm2,mm7 - pand mm3,mm7 - - pcmpeqb mm0,mm6 - pcmpeqb mm1,mm6 - pcmpeqb mm2,mm6 - pcmpeqb mm3,mm6 - - mov ecx,len //load length of line - mov esi,srcptr //load source - mov ebx,dstptr //load dest - - cmp ecx,0 //lcr - jz mainloop32end - -mainloop32: - movq mm4,[esi] - pand mm4,mm0 - movq mm6,mm0 - movq mm7,[ebx] - pandn mm6,mm7 - por mm4,mm6 - movq [ebx],mm4 - - movq mm5,[esi+8] - pand mm5,mm1 - movq mm7,mm1 - movq mm6,[ebx+8] - pandn mm7,mm6 - por mm5,mm7 - movq [ebx+8],mm5 - - movq mm6,[esi+16] - pand mm6,mm2 - movq mm4,mm2 - movq mm7,[ebx+16] - pandn mm4,mm7 - por mm6,mm4 - movq [ebx+16],mm6 - - movq mm7,[esi+24] - pand mm7,mm3 - movq mm5,mm3 - movq mm4,[ebx+24] - pandn mm5,mm4 - por mm7,mm5 - movq [ebx+24],mm7 - - add esi,32 //inc by 32 bytes processed - add ebx,32 - sub ecx,8 //dec by 8 pixels processed - - ja mainloop32 - -mainloop32end: - mov ecx,diff - cmp ecx,0 - jz end32 - - mov edx,mask - sal edx,24 //make low byte the high byte -secondloop32: - sal edx,1 //move high bit to CF - jnc skip32 //if CF = 0 - mov eax,[esi] - mov [ebx],eax -skip32: - add esi,4 - add ebx,4 - - dec ecx - jnz secondloop32 - -end32: - emms - } - } - else /* mmx _not supported - Use modified C routine */ - { - register unsigned int incr1, initial_val, final_val; - png_size_t pixel_bytes; - png_uint_32 i; - register int disp = png_pass_inc[png_ptr->pass]; - int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; - - pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); - srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* - pixel_bytes; - dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; - initial_val = offset_table[png_ptr->pass]*pixel_bytes; - final_val = png_ptr->width*pixel_bytes; - incr1 = (disp)*pixel_bytes; - for (i = initial_val; i < final_val; i += incr1) - { - png_memcpy(dstptr, srcptr, pixel_bytes); - srcptr += incr1; - dstptr += incr1; - } - } /* end of else */ - - break; - } // end 32 bpp - - case 48: - { - png_bytep srcptr; - png_bytep dstptr; - png_uint_32 len; - int unmask, diff; - - __int64 mask5=0x0101010101010202, - mask4=0x0202020204040404, - mask3=0x0404080808080808, - mask2=0x1010101010102020, - mask1=0x2020202040404040, - mask0=0x4040808080808080; - -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) - /* && mmx_supported */ ) -#else - if (mmx_supported) -#endif - { - srcptr = png_ptr->row_buf + 1; - dstptr = row; - - unmask = ~mask; - len = (png_ptr->width)&~7; - diff = (png_ptr->width)&7; - _asm - { - movd mm7, unmask //load bit pattern - psubb mm6,mm6 //zero mm6 - punpcklbw mm7,mm7 - punpcklwd mm7,mm7 - punpckldq mm7,mm7 //fill register with 8 masks - - movq mm0,mask0 - movq mm1,mask1 - movq mm2,mask2 - movq mm3,mask3 - movq mm4,mask4 - movq mm5,mask5 - - pand mm0,mm7 - pand mm1,mm7 - pand mm2,mm7 - pand mm3,mm7 - pand mm4,mm7 - pand mm5,mm7 - - pcmpeqb mm0,mm6 - pcmpeqb mm1,mm6 - pcmpeqb mm2,mm6 - pcmpeqb mm3,mm6 - pcmpeqb mm4,mm6 - pcmpeqb mm5,mm6 - - mov ecx,len //load length of line - mov esi,srcptr //load source - mov ebx,dstptr //load dest - - cmp ecx,0 - jz mainloop48end - -mainloop48: - movq mm7,[esi] - pand mm7,mm0 - movq mm6,mm0 - pandn mm6,[ebx] - por mm7,mm6 - movq [ebx],mm7 - - movq mm6,[esi+8] - pand mm6,mm1 - movq mm7,mm1 - pandn mm7,[ebx+8] - por mm6,mm7 - movq [ebx+8],mm6 - - movq mm6,[esi+16] - pand mm6,mm2 - movq mm7,mm2 - pandn mm7,[ebx+16] - por mm6,mm7 - movq [ebx+16],mm6 - - movq mm7,[esi+24] - pand mm7,mm3 - movq mm6,mm3 - pandn mm6,[ebx+24] - por mm7,mm6 - movq [ebx+24],mm7 - - movq mm6,[esi+32] - pand mm6,mm4 - movq mm7,mm4 - pandn mm7,[ebx+32] - por mm6,mm7 - movq [ebx+32],mm6 - - movq mm7,[esi+40] - pand mm7,mm5 - movq mm6,mm5 - pandn mm6,[ebx+40] - por mm7,mm6 - movq [ebx+40],mm7 - - add esi,48 //inc by 32 bytes processed - add ebx,48 - sub ecx,8 //dec by 8 pixels processed - - ja mainloop48 -mainloop48end: - - mov ecx,diff - cmp ecx,0 - jz end48 - - mov edx,mask - sal edx,24 //make low byte the high byte - -secondloop48: - sal edx,1 //move high bit to CF - jnc skip48 //if CF = 0 - mov eax,[esi] - mov [ebx],eax -skip48: - add esi,4 - add ebx,4 - - dec ecx - jnz secondloop48 - -end48: - emms - } - } - else /* mmx _not supported - Use modified C routine */ - { - register unsigned int incr1, initial_val, final_val; - png_size_t pixel_bytes; - png_uint_32 i; - register int disp = png_pass_inc[png_ptr->pass]; - int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; - - pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); - srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* - pixel_bytes; - dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; - initial_val = offset_table[png_ptr->pass]*pixel_bytes; - final_val = png_ptr->width*pixel_bytes; - incr1 = (disp)*pixel_bytes; - for (i = initial_val; i < final_val; i += incr1) - { - png_memcpy(dstptr, srcptr, pixel_bytes); - srcptr += incr1; - dstptr += incr1; - } - } /* end of else */ - - break; - } // end 48 bpp - - default: - { - png_bytep sptr; - png_bytep dp; - png_size_t pixel_bytes; - int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; - unsigned int i; - register int disp = png_pass_inc[png_ptr->pass]; // get the offset - register unsigned int incr1, initial_val, final_val; - - pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); - sptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* - pixel_bytes; - dp = row + offset_table[png_ptr->pass]*pixel_bytes; - initial_val = offset_table[png_ptr->pass]*pixel_bytes; - final_val = png_ptr->width*pixel_bytes; - incr1 = (disp)*pixel_bytes; - for (i = initial_val; i < final_val; i += incr1) - { - png_memcpy(dp, sptr, pixel_bytes); - sptr += incr1; - dp += incr1; - } - break; - } - } /* end switch (png_ptr->row_info.pixel_depth) */ - } /* end if (non-trivial mask) */ - -} /* end png_combine_row() */ - - -#if defined(PNG_READ_INTERLACING_SUPPORTED) - -void /* PRIVATE */ -png_do_read_interlace(png_structp png_ptr) -{ - png_row_infop row_info = &(png_ptr->row_info); - png_bytep row = png_ptr->row_buf + 1; - int pass = png_ptr->pass; - png_uint_32 transformations = png_ptr->transformations; -#ifdef PNG_USE_LOCAL_ARRAYS - const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; -#endif - - png_debug(1,"in png_do_read_interlace\n"); - - if (mmx_supported == 2) { -#if !defined(PNG_1_0_X) - /* this should have happened in png_init_mmx_flags() already */ - png_warning(png_ptr, "asm_flags may not have been initialized"); -#endif - png_mmx_support(); - } - - if (row != NULL && row_info != NULL) - { - png_uint_32 final_width; - - final_width = row_info->width * png_pass_inc[pass]; - - switch (row_info->pixel_depth) - { - case 1: - { - png_bytep sp, dp; - int sshift, dshift; - int s_start, s_end, s_inc; - png_byte v; - png_uint_32 i; - int j; - - sp = row + (png_size_t)((row_info->width - 1) >> 3); - dp = row + (png_size_t)((final_width - 1) >> 3); -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (int)((row_info->width + 7) & 7); - dshift = (int)((final_width + 7) & 7); - s_start = 7; - s_end = 0; - s_inc = -1; - } - else -#endif - { - sshift = 7 - (int)((row_info->width + 7) & 7); - dshift = 7 - (int)((final_width + 7) & 7); - s_start = 0; - s_end = 7; - s_inc = 1; - } - - for (i = row_info->width; i; i--) - { - v = (png_byte)((*sp >> sshift) & 0x1); - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp &= (png_byte)((0x7f7f >> (7 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - - case 2: - { - png_bytep sp, dp; - int sshift, dshift; - int s_start, s_end, s_inc; - png_uint_32 i; - - sp = row + (png_size_t)((row_info->width - 1) >> 2); - dp = row + (png_size_t)((final_width - 1) >> 2); -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (png_size_t)(((row_info->width + 3) & 3) << 1); - dshift = (png_size_t)(((final_width + 3) & 3) << 1); - s_start = 6; - s_end = 0; - s_inc = -2; - } - else -#endif - { - sshift = (png_size_t)((3 - ((row_info->width + 3) & 3)) << 1); - dshift = (png_size_t)((3 - ((final_width + 3) & 3)) << 1); - s_start = 0; - s_end = 6; - s_inc = 2; - } - - for (i = row_info->width; i; i--) - { - png_byte v; - int j; - - v = (png_byte)((*sp >> sshift) & 0x3); - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp &= (png_byte)((0x3f3f >> (6 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - - case 4: - { - png_bytep sp, dp; - int sshift, dshift; - int s_start, s_end, s_inc; - png_uint_32 i; - - sp = row + (png_size_t)((row_info->width - 1) >> 1); - dp = row + (png_size_t)((final_width - 1) >> 1); -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (png_size_t)(((row_info->width + 1) & 1) << 2); - dshift = (png_size_t)(((final_width + 1) & 1) << 2); - s_start = 4; - s_end = 0; - s_inc = -4; - } - else -#endif - { - sshift = (png_size_t)((1 - ((row_info->width + 1) & 1)) << 2); - dshift = (png_size_t)((1 - ((final_width + 1) & 1)) << 2); - s_start = 0; - s_end = 4; - s_inc = 4; - } - - for (i = row_info->width; i; i--) - { - png_byte v; - int j; - - v = (png_byte)((*sp >> sshift) & 0xf); - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp &= (png_byte)((0xf0f >> (4 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - - default: // This is the place where the routine is modified - { - __int64 const4 = 0x0000000000FFFFFF; - // __int64 const5 = 0x000000FFFFFF0000; // unused... - __int64 const6 = 0x00000000000000FF; - png_bytep sptr, dp; - png_uint_32 i; - png_size_t pixel_bytes; - int width = row_info->width; - - pixel_bytes = (row_info->pixel_depth >> 3); - - sptr = row + (width - 1) * pixel_bytes; - dp = row + (final_width - 1) * pixel_bytes; - // New code by Nirav Chhatrapati - Intel Corporation - // sign fix by GRR - // NOTE: there is NO MMX code for 48-bit and 64-bit images - - // use MMX routine if machine supports it -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_INTERLACE) - /* && mmx_supported */ ) -#else - if (mmx_supported) -#endif - { - if (pixel_bytes == 3) - { - if (((pass == 0) || (pass == 1)) && width) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width - sub edi, 21 // (png_pass_inc[pass] - 1)*pixel_bytes -loop_pass0: - movd mm0, [esi] ; X X X X X v2 v1 v0 - pand mm0, const4 ; 0 0 0 0 0 v2 v1 v0 - movq mm1, mm0 ; 0 0 0 0 0 v2 v1 v0 - psllq mm0, 16 ; 0 0 0 v2 v1 v0 0 0 - movq mm2, mm0 ; 0 0 0 v2 v1 v0 0 0 - psllq mm0, 24 ; v2 v1 v0 0 0 0 0 0 - psrlq mm1, 8 ; 0 0 0 0 0 0 v2 v1 - por mm0, mm2 ; v2 v1 v0 v2 v1 v0 0 0 - por mm0, mm1 ; v2 v1 v0 v2 v1 v0 v2 v1 - movq mm3, mm0 ; v2 v1 v0 v2 v1 v0 v2 v1 - psllq mm0, 16 ; v0 v2 v1 v0 v2 v1 0 0 - movq mm4, mm3 ; v2 v1 v0 v2 v1 v0 v2 v1 - punpckhdq mm3, mm0 ; v0 v2 v1 v0 v2 v1 v0 v2 - movq [edi+16] , mm4 - psrlq mm0, 32 ; 0 0 0 0 v0 v2 v1 v0 - movq [edi+8] , mm3 - punpckldq mm0, mm4 ; v1 v0 v2 v1 v0 v2 v1 v0 - sub esi, 3 - movq [edi], mm0 - sub edi, 24 - //sub esi, 3 - dec ecx - jnz loop_pass0 - EMMS - } - } - else if (((pass == 2) || (pass == 3)) && width) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width - sub edi, 9 // (png_pass_inc[pass] - 1)*pixel_bytes -loop_pass2: - movd mm0, [esi] ; X X X X X v2 v1 v0 - pand mm0, const4 ; 0 0 0 0 0 v2 v1 v0 - movq mm1, mm0 ; 0 0 0 0 0 v2 v1 v0 - psllq mm0, 16 ; 0 0 0 v2 v1 v0 0 0 - movq mm2, mm0 ; 0 0 0 v2 v1 v0 0 0 - psllq mm0, 24 ; v2 v1 v0 0 0 0 0 0 - psrlq mm1, 8 ; 0 0 0 0 0 0 v2 v1 - por mm0, mm2 ; v2 v1 v0 v2 v1 v0 0 0 - por mm0, mm1 ; v2 v1 v0 v2 v1 v0 v2 v1 - movq [edi+4], mm0 ; move to memory - psrlq mm0, 16 ; 0 0 v2 v1 v0 v2 v1 v0 - movd [edi], mm0 ; move to memory - sub esi, 3 - sub edi, 12 - dec ecx - jnz loop_pass2 - EMMS - } - } - else if (width) /* && ((pass == 4) || (pass == 5)) */ - { - int width_mmx = ((width >> 1) << 1) - 8; - if (width_mmx < 0) - width_mmx = 0; - width -= width_mmx; // 8 or 9 pix, 24 or 27 bytes - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub esi, 3 - sub edi, 9 -loop_pass4: - movq mm0, [esi] ; X X v2 v1 v0 v5 v4 v3 - movq mm7, mm0 ; X X v2 v1 v0 v5 v4 v3 - movq mm6, mm0 ; X X v2 v1 v0 v5 v4 v3 - psllq mm0, 24 ; v1 v0 v5 v4 v3 0 0 0 - pand mm7, const4 ; 0 0 0 0 0 v5 v4 v3 - psrlq mm6, 24 ; 0 0 0 X X v2 v1 v0 - por mm0, mm7 ; v1 v0 v5 v4 v3 v5 v4 v3 - movq mm5, mm6 ; 0 0 0 X X v2 v1 v0 - psllq mm6, 8 ; 0 0 X X v2 v1 v0 0 - movq [edi], mm0 ; move quad to memory - psrlq mm5, 16 ; 0 0 0 0 0 X X v2 - pand mm5, const6 ; 0 0 0 0 0 0 0 v2 - por mm6, mm5 ; 0 0 X X v2 v1 v0 v2 - movd [edi+8], mm6 ; move double to memory - sub esi, 6 - sub edi, 12 - sub ecx, 2 - jnz loop_pass4 - EMMS - } - } - - sptr -= width_mmx*3; - dp -= width_mmx*6; - for (i = width; i; i--) - { - png_byte v[8]; - int j; - - png_memcpy(v, sptr, 3); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 3); - dp -= 3; - } - sptr -= 3; - } - } - } /* end of pixel_bytes == 3 */ - - else if (pixel_bytes == 1) - { - if (((pass == 0) || (pass == 1)) && width) - { - int width_mmx = ((width >> 2) << 2); - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub edi, 31 - sub esi, 3 -loop1_pass0: - movd mm0, [esi] ; X X X X v0 v1 v2 v3 - movq mm1, mm0 ; X X X X v0 v1 v2 v3 - punpcklbw mm0, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 - movq mm2, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 - punpcklwd mm0, mm0 ; v2 v2 v2 v2 v3 v3 v3 v3 - movq mm3, mm0 ; v2 v2 v2 v2 v3 v3 v3 v3 - punpckldq mm0, mm0 ; v3 v3 v3 v3 v3 v3 v3 v3 - punpckhdq mm3, mm3 ; v2 v2 v2 v2 v2 v2 v2 v2 - movq [edi], mm0 ; move to memory v3 - punpckhwd mm2, mm2 ; v0 v0 v0 v0 v1 v1 v1 v1 - movq [edi+8], mm3 ; move to memory v2 - movq mm4, mm2 ; v0 v0 v0 v0 v1 v1 v1 v1 - punpckldq mm2, mm2 ; v1 v1 v1 v1 v1 v1 v1 v1 - punpckhdq mm4, mm4 ; v0 v0 v0 v0 v0 v0 v0 v0 - movq [edi+16], mm2 ; move to memory v1 - movq [edi+24], mm4 ; move to memory v0 - sub esi, 4 - sub edi, 32 - sub ecx, 4 - jnz loop1_pass0 - EMMS - } - } - - sptr -= width_mmx; - dp -= width_mmx*8; - for (i = width; i; i--) - { - int j; - - /* I simplified this part in version 1.0.4e - * here and in several other instances where - * pixel_bytes == 1 -- GR-P - * - * Original code: - * - * png_byte v[8]; - * png_memcpy(v, sptr, pixel_bytes); - * for (j = 0; j < png_pass_inc[pass]; j++) - * { - * png_memcpy(dp, v, pixel_bytes); - * dp -= pixel_bytes; - * } - * sptr -= pixel_bytes; - * - * Replacement code is in the next three lines: - */ - - for (j = 0; j < png_pass_inc[pass]; j++) - *dp-- = *sptr; - sptr--; - } - } - else if (((pass == 2) || (pass == 3)) && width) - { - int width_mmx = ((width >> 2) << 2); - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub edi, 15 - sub esi, 3 -loop1_pass2: - movd mm0, [esi] ; X X X X v0 v1 v2 v3 - punpcklbw mm0, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 - movq mm1, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 - punpcklwd mm0, mm0 ; v2 v2 v2 v2 v3 v3 v3 v3 - punpckhwd mm1, mm1 ; v0 v0 v0 v0 v1 v1 v1 v1 - movq [edi], mm0 ; move to memory v2 and v3 - sub esi, 4 - movq [edi+8], mm1 ; move to memory v1 and v0 - sub edi, 16 - sub ecx, 4 - jnz loop1_pass2 - EMMS - } - } - - sptr -= width_mmx; - dp -= width_mmx*4; - for (i = width; i; i--) - { - int j; - - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp-- = *sptr; - } - sptr --; - } - } - else if (width) /* && ((pass == 4) || (pass == 5))) */ - { - int width_mmx = ((width >> 3) << 3); - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub edi, 15 - sub esi, 7 -loop1_pass4: - movq mm0, [esi] ; v0 v1 v2 v3 v4 v5 v6 v7 - movq mm1, mm0 ; v0 v1 v2 v3 v4 v5 v6 v7 - punpcklbw mm0, mm0 ; v4 v4 v5 v5 v6 v6 v7 v7 - //movq mm1, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 - punpckhbw mm1, mm1 ;v0 v0 v1 v1 v2 v2 v3 v3 - movq [edi+8], mm1 ; move to memory v0 v1 v2 and v3 - sub esi, 8 - movq [edi], mm0 ; move to memory v4 v5 v6 and v7 - //sub esi, 4 - sub edi, 16 - sub ecx, 8 - jnz loop1_pass4 - EMMS - } - } - - sptr -= width_mmx; - dp -= width_mmx*2; - for (i = width; i; i--) - { - int j; - - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp-- = *sptr; - } - sptr --; - } - } - } /* end of pixel_bytes == 1 */ - - else if (pixel_bytes == 2) - { - if (((pass == 0) || (pass == 1)) && width) - { - int width_mmx = ((width >> 1) << 1); - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub esi, 2 - sub edi, 30 -loop2_pass0: - movd mm0, [esi] ; X X X X v1 v0 v3 v2 - punpcklwd mm0, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 - movq mm1, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 - punpckldq mm0, mm0 ; v3 v2 v3 v2 v3 v2 v3 v2 - punpckhdq mm1, mm1 ; v1 v0 v1 v0 v1 v0 v1 v0 - movq [edi], mm0 - movq [edi + 8], mm0 - movq [edi + 16], mm1 - movq [edi + 24], mm1 - sub esi, 4 - sub edi, 32 - sub ecx, 2 - jnz loop2_pass0 - EMMS - } - } - - sptr -= (width_mmx*2 - 2); // sign fixed - dp -= (width_mmx*16 - 2); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 2; - png_memcpy(v, sptr, 2); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 2; - png_memcpy(dp, v, 2); - } - } - } - else if (((pass == 2) || (pass == 3)) && width) - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub esi, 2 - sub edi, 14 -loop2_pass2: - movd mm0, [esi] ; X X X X v1 v0 v3 v2 - punpcklwd mm0, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 - movq mm1, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 - punpckldq mm0, mm0 ; v3 v2 v3 v2 v3 v2 v3 v2 - punpckhdq mm1, mm1 ; v1 v0 v1 v0 v1 v0 v1 v0 - movq [edi], mm0 - sub esi, 4 - movq [edi + 8], mm1 - //sub esi, 4 - sub edi, 16 - sub ecx, 2 - jnz loop2_pass2 - EMMS - } - } - - sptr -= (width_mmx*2 - 2); // sign fixed - dp -= (width_mmx*8 - 2); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 2; - png_memcpy(v, sptr, 2); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 2; - png_memcpy(dp, v, 2); - } - } - } - else if (width) // pass == 4 or 5 - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub esi, 2 - sub edi, 6 -loop2_pass4: - movd mm0, [esi] ; X X X X v1 v0 v3 v2 - punpcklwd mm0, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 - sub esi, 4 - movq [edi], mm0 - sub edi, 8 - sub ecx, 2 - jnz loop2_pass4 - EMMS - } - } - - sptr -= (width_mmx*2 - 2); // sign fixed - dp -= (width_mmx*4 - 2); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 2; - png_memcpy(v, sptr, 2); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 2; - png_memcpy(dp, v, 2); - } - } - } - } /* end of pixel_bytes == 2 */ - - else if (pixel_bytes == 4) - { - if (((pass == 0) || (pass == 1)) && width) - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub esi, 4 - sub edi, 60 -loop4_pass0: - movq mm0, [esi] ; v3 v2 v1 v0 v7 v6 v5 v4 - movq mm1, mm0 ; v3 v2 v1 v0 v7 v6 v5 v4 - punpckldq mm0, mm0 ; v7 v6 v5 v4 v7 v6 v5 v4 - punpckhdq mm1, mm1 ; v3 v2 v1 v0 v3 v2 v1 v0 - movq [edi], mm0 - movq [edi + 8], mm0 - movq [edi + 16], mm0 - movq [edi + 24], mm0 - movq [edi+32], mm1 - movq [edi + 40], mm1 - movq [edi+ 48], mm1 - sub esi, 8 - movq [edi + 56], mm1 - sub edi, 64 - sub ecx, 2 - jnz loop4_pass0 - EMMS - } - } - - sptr -= (width_mmx*4 - 4); // sign fixed - dp -= (width_mmx*32 - 4); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 4; - png_memcpy(v, sptr, 4); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 4; - png_memcpy(dp, v, 4); - } - } - } - else if (((pass == 2) || (pass == 3)) && width) - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub esi, 4 - sub edi, 28 -loop4_pass2: - movq mm0, [esi] ; v3 v2 v1 v0 v7 v6 v5 v4 - movq mm1, mm0 ; v3 v2 v1 v0 v7 v6 v5 v4 - punpckldq mm0, mm0 ; v7 v6 v5 v4 v7 v6 v5 v4 - punpckhdq mm1, mm1 ; v3 v2 v1 v0 v3 v2 v1 v0 - movq [edi], mm0 - movq [edi + 8], mm0 - movq [edi+16], mm1 - movq [edi + 24], mm1 - sub esi, 8 - sub edi, 32 - sub ecx, 2 - jnz loop4_pass2 - EMMS - } - } - - sptr -= (width_mmx*4 - 4); // sign fixed - dp -= (width_mmx*16 - 4); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 4; - png_memcpy(v, sptr, 4); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 4; - png_memcpy(dp, v, 4); - } - } - } - else if (width) // pass == 4 or 5 - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub esi, 4 - sub edi, 12 -loop4_pass4: - movq mm0, [esi] ; v3 v2 v1 v0 v7 v6 v5 v4 - movq mm1, mm0 ; v3 v2 v1 v0 v7 v6 v5 v4 - punpckldq mm0, mm0 ; v7 v6 v5 v4 v7 v6 v5 v4 - punpckhdq mm1, mm1 ; v3 v2 v1 v0 v3 v2 v1 v0 - movq [edi], mm0 - sub esi, 8 - movq [edi + 8], mm1 - sub edi, 16 - sub ecx, 2 - jnz loop4_pass4 - EMMS - } - } - - sptr -= (width_mmx*4 - 4); // sign fixed - dp -= (width_mmx*8 - 4); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 4; - png_memcpy(v, sptr, 4); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 4; - png_memcpy(dp, v, 4); - } - } - } - - } /* end of pixel_bytes == 4 */ - - else if (pixel_bytes == 6) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, 6); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 6); - dp -= 6; - } - sptr -= 6; - } - } /* end of pixel_bytes == 6 */ - - else - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr-= pixel_bytes; - } - } - } /* end of mmx_supported */ - - else /* MMX not supported: use modified C code - takes advantage - * of inlining of memcpy for a constant */ - { - if (pixel_bytes == 1) - { - for (i = width; i; i--) - { - int j; - for (j = 0; j < png_pass_inc[pass]; j++) - *dp-- = *sptr; - sptr--; - } - } - else if (pixel_bytes == 3) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr -= pixel_bytes; - } - } - else if (pixel_bytes == 2) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr -= pixel_bytes; - } - } - else if (pixel_bytes == 4) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr -= pixel_bytes; - } - } - else if (pixel_bytes == 6) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr -= pixel_bytes; - } - } - else - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr -= pixel_bytes; - } - } - - } /* end of MMX not supported */ - break; - } - } /* end switch (row_info->pixel_depth) */ - - row_info->width = final_width; - - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,final_width); - } - -} - -#endif /* PNG_READ_INTERLACING_SUPPORTED */ - - -// These variables are utilized in the functions below. They are declared -// globally here to ensure alignment on 8-byte boundaries. - -union uAll { - __int64 use; - double align; -} LBCarryMask = {0x0101010101010101}, - HBClearMask = {0x7f7f7f7f7f7f7f7f}, - ActiveMask, ActiveMask2, ActiveMaskEnd, ShiftBpp, ShiftRem; - - -// Optimized code for PNG Average filter decoder -void /* PRIVATE */ -png_read_filter_row_mmx_avg(png_row_infop row_info, png_bytep row - , png_bytep prev_row) -{ - int bpp; - png_uint_32 FullLength; - png_uint_32 MMXLength; - //png_uint_32 len; - int diff; - - bpp = (row_info->pixel_depth + 7) >> 3; // Get # bytes per pixel - FullLength = row_info->rowbytes; // # of bytes to filter - _asm { - // Init address pointers and offset - mov edi, row // edi ==> Avg(x) - xor ebx, ebx // ebx ==> x - mov edx, edi - mov esi, prev_row // esi ==> Prior(x) - sub edx, bpp // edx ==> Raw(x-bpp) - - xor eax, eax - // Compute the Raw value for the first bpp bytes - // Raw(x) = Avg(x) + (Prior(x)/2) -davgrlp: - mov al, [esi + ebx] // Load al with Prior(x) - inc ebx - shr al, 1 // divide by 2 - add al, [edi+ebx-1] // Add Avg(x); -1 to offset inc ebx - cmp ebx, bpp - mov [edi+ebx-1], al // Write back Raw(x); - // mov does not affect flags; -1 to offset inc ebx - jb davgrlp - // get # of bytes to alignment - mov diff, edi // take start of row - add diff, ebx // add bpp - add diff, 0xf // add 7 + 8 to incr past alignment boundary - and diff, 0xfffffff8 // mask to alignment boundary - sub diff, edi // subtract from start ==> value ebx at alignment - jz davggo - // fix alignment - // Compute the Raw value for the bytes upto the alignment boundary - // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) - xor ecx, ecx -davglp1: - xor eax, eax - mov cl, [esi + ebx] // load cl with Prior(x) - mov al, [edx + ebx] // load al with Raw(x-bpp) - add ax, cx - inc ebx - shr ax, 1 // divide by 2 - add al, [edi+ebx-1] // Add Avg(x); -1 to offset inc ebx - cmp ebx, diff // Check if at alignment boundary - mov [edi+ebx-1], al // Write back Raw(x); - // mov does not affect flags; -1 to offset inc ebx - jb davglp1 // Repeat until at alignment boundary -davggo: - mov eax, FullLength - mov ecx, eax - sub eax, ebx // subtract alignment fix - and eax, 0x00000007 // calc bytes over mult of 8 - sub ecx, eax // drop over bytes from original length - mov MMXLength, ecx - } // end _asm block - // Now do the math for the rest of the row - switch ( bpp ) - { - case 3: - { - ActiveMask.use = 0x0000000000ffffff; - ShiftBpp.use = 24; // == 3 * 8 - ShiftRem.use = 40; // == 64 - 24 - _asm { - // Re-init address pointers and offset - movq mm7, ActiveMask - mov ebx, diff // ebx ==> x = offset to alignment boundary - movq mm5, LBCarryMask - mov edi, row // edi ==> Avg(x) - movq mm4, HBClearMask - mov esi, prev_row // esi ==> Prior(x) - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm2, [edi + ebx - 8] // Load previous aligned 8 bytes - // (we correct position in loop below) -davg3lp: - movq mm0, [edi + ebx] // Load mm0 with Avg(x) - // Add (Prev_row/2) to Average - movq mm3, mm5 - psrlq mm2, ShiftRem // Correct position Raw(x-bpp) data - movq mm1, [esi + ebx] // Load mm1 with Prior(x) - movq mm6, mm7 - pand mm3, mm1 // get lsb for each prev_row byte - psrlq mm1, 1 // divide prev_row bytes by 2 - pand mm1, mm4 // clear invalid bit 7 of each byte - paddb mm0, mm1 // add (Prev_row/2) to Avg for each byte - // Add 1st active group (Raw(x-bpp)/2) to Average with LBCarry - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 1 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active - // byte - // Add 2nd active group (Raw(x-bpp)/2) to Average with LBCarry - psllq mm6, ShiftBpp // shift the mm6 mask to cover bytes 3-5 - movq mm2, mm0 // mov updated Raws to mm2 - psllq mm2, ShiftBpp // shift data to position correctly - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active - // byte - - // Add 3rd active group (Raw(x-bpp)/2) to Average with LBCarry - psllq mm6, ShiftBpp // shift the mm6 mask to cover the last two - // bytes - movq mm2, mm0 // mov updated Raws to mm2 - psllq mm2, ShiftBpp // shift data to position correctly - // Data only needs to be shifted once here to - // get the correct x-bpp offset. - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg - add ebx, 8 - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active - // byte - - // Now ready to write back to memory - movq [edi + ebx - 8], mm0 - // Move updated Raw(x) to use as Raw(x-bpp) for next loop - cmp ebx, MMXLength - movq mm2, mm0 // mov updated Raw(x) to mm2 - jb davg3lp - } // end _asm block - } - break; - - case 6: - case 4: - case 7: - case 5: - { - ActiveMask.use = 0xffffffffffffffff; // use shift below to clear - // appropriate inactive bytes - ShiftBpp.use = bpp << 3; - ShiftRem.use = 64 - ShiftBpp.use; - _asm { - movq mm4, HBClearMask - // Re-init address pointers and offset - mov ebx, diff // ebx ==> x = offset to alignment boundary - // Load ActiveMask and clear all bytes except for 1st active group - movq mm7, ActiveMask - mov edi, row // edi ==> Avg(x) - psrlq mm7, ShiftRem - mov esi, prev_row // esi ==> Prior(x) - movq mm6, mm7 - movq mm5, LBCarryMask - psllq mm6, ShiftBpp // Create mask for 2nd active group - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm2, [edi + ebx - 8] // Load previous aligned 8 bytes - // (we correct position in loop below) -davg4lp: - movq mm0, [edi + ebx] - psrlq mm2, ShiftRem // shift data to position correctly - movq mm1, [esi + ebx] - // Add (Prev_row/2) to Average - movq mm3, mm5 - pand mm3, mm1 // get lsb for each prev_row byte - psrlq mm1, 1 // divide prev_row bytes by 2 - pand mm1, mm4 // clear invalid bit 7 of each byte - paddb mm0, mm1 // add (Prev_row/2) to Avg for each byte - // Add 1st active group (Raw(x-bpp)/2) to Average with LBCarry - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm7 // Leave only Active Group 1 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active - // byte - // Add 2nd active group (Raw(x-bpp)/2) to Average with LBCarry - movq mm2, mm0 // mov updated Raws to mm2 - psllq mm2, ShiftBpp // shift data to position correctly - add ebx, 8 - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active - // byte - cmp ebx, MMXLength - // Now ready to write back to memory - movq [edi + ebx - 8], mm0 - // Prep Raw(x-bpp) for next loop - movq mm2, mm0 // mov updated Raws to mm2 - jb davg4lp - } // end _asm block - } - break; - case 2: - { - ActiveMask.use = 0x000000000000ffff; - ShiftBpp.use = 16; // == 2 * 8 [BUGFIX] - ShiftRem.use = 48; // == 64 - 16 [BUGFIX] - _asm { - // Load ActiveMask - movq mm7, ActiveMask - // Re-init address pointers and offset - mov ebx, diff // ebx ==> x = offset to alignment boundary - movq mm5, LBCarryMask - mov edi, row // edi ==> Avg(x) - movq mm4, HBClearMask - mov esi, prev_row // esi ==> Prior(x) - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm2, [edi + ebx - 8] // Load previous aligned 8 bytes - // (we correct position in loop below) -davg2lp: - movq mm0, [edi + ebx] - psrlq mm2, ShiftRem // shift data to position correctly [BUGFIX] - movq mm1, [esi + ebx] - // Add (Prev_row/2) to Average - movq mm3, mm5 - pand mm3, mm1 // get lsb for each prev_row byte - psrlq mm1, 1 // divide prev_row bytes by 2 - pand mm1, mm4 // clear invalid bit 7 of each byte - movq mm6, mm7 - paddb mm0, mm1 // add (Prev_row/2) to Avg for each byte - // Add 1st active group (Raw(x-bpp)/2) to Average with LBCarry - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 1 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active byte - // Add 2nd active group (Raw(x-bpp)/2) to Average with LBCarry - psllq mm6, ShiftBpp // shift the mm6 mask to cover bytes 2 & 3 - movq mm2, mm0 // mov updated Raws to mm2 - psllq mm2, ShiftBpp // shift data to position correctly - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active byte - - // Add rdd active group (Raw(x-bpp)/2) to Average with LBCarry - psllq mm6, ShiftBpp // shift the mm6 mask to cover bytes 4 & 5 - movq mm2, mm0 // mov updated Raws to mm2 - psllq mm2, ShiftBpp // shift data to position correctly - // Data only needs to be shifted once here to - // get the correct x-bpp offset. - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active byte - - // Add 4th active group (Raw(x-bpp)/2) to Average with LBCarry - psllq mm6, ShiftBpp // shift the mm6 mask to cover bytes 6 & 7 - movq mm2, mm0 // mov updated Raws to mm2 - psllq mm2, ShiftBpp // shift data to position correctly - // Data only needs to be shifted once here to - // get the correct x-bpp offset. - add ebx, 8 - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active byte - - cmp ebx, MMXLength - // Now ready to write back to memory - movq [edi + ebx - 8], mm0 - // Prep Raw(x-bpp) for next loop - movq mm2, mm0 // mov updated Raws to mm2 - jb davg2lp - } // end _asm block - } - break; - - case 1: // bpp == 1 - { - _asm { - // Re-init address pointers and offset - mov ebx, diff // ebx ==> x = offset to alignment boundary - mov edi, row // edi ==> Avg(x) - cmp ebx, FullLength // Test if offset at end of array - jnb davg1end - // Do Paeth decode for remaining bytes - mov esi, prev_row // esi ==> Prior(x) - mov edx, edi - xor ecx, ecx // zero ecx before using cl & cx in loop below - sub edx, bpp // edx ==> Raw(x-bpp) -davg1lp: - // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) - xor eax, eax - mov cl, [esi + ebx] // load cl with Prior(x) - mov al, [edx + ebx] // load al with Raw(x-bpp) - add ax, cx - inc ebx - shr ax, 1 // divide by 2 - add al, [edi+ebx-1] // Add Avg(x); -1 to offset inc ebx - cmp ebx, FullLength // Check if at end of array - mov [edi+ebx-1], al // Write back Raw(x); - // mov does not affect flags; -1 to offset inc ebx - jb davg1lp -davg1end: - } // end _asm block - } - return; - - case 8: // bpp == 8 - { - _asm { - // Re-init address pointers and offset - mov ebx, diff // ebx ==> x = offset to alignment boundary - movq mm5, LBCarryMask - mov edi, row // edi ==> Avg(x) - movq mm4, HBClearMask - mov esi, prev_row // esi ==> Prior(x) - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm2, [edi + ebx - 8] // Load previous aligned 8 bytes - // (NO NEED to correct position in loop below) -davg8lp: - movq mm0, [edi + ebx] - movq mm3, mm5 - movq mm1, [esi + ebx] - add ebx, 8 - pand mm3, mm1 // get lsb for each prev_row byte - psrlq mm1, 1 // divide prev_row bytes by 2 - pand mm3, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 - psrlq mm2, 1 // divide raw bytes by 2 - pand mm1, mm4 // clear invalid bit 7 of each byte - paddb mm0, mm3 // add LBCarrys to Avg for each byte - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm0, mm1 // add (Prev_row/2) to Avg for each byte - paddb mm0, mm2 // add (Raw/2) to Avg for each byte - cmp ebx, MMXLength - movq [edi + ebx - 8], mm0 - movq mm2, mm0 // reuse as Raw(x-bpp) - jb davg8lp - } // end _asm block - } - break; - default: // bpp greater than 8 - { - _asm { - movq mm5, LBCarryMask - // Re-init address pointers and offset - mov ebx, diff // ebx ==> x = offset to alignment boundary - mov edi, row // edi ==> Avg(x) - movq mm4, HBClearMask - mov edx, edi - mov esi, prev_row // esi ==> Prior(x) - sub edx, bpp // edx ==> Raw(x-bpp) -davgAlp: - movq mm0, [edi + ebx] - movq mm3, mm5 - movq mm1, [esi + ebx] - pand mm3, mm1 // get lsb for each prev_row byte - movq mm2, [edx + ebx] - psrlq mm1, 1 // divide prev_row bytes by 2 - pand mm3, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 - psrlq mm2, 1 // divide raw bytes by 2 - pand mm1, mm4 // clear invalid bit 7 of each byte - paddb mm0, mm3 // add LBCarrys to Avg for each byte - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm0, mm1 // add (Prev_row/2) to Avg for each byte - add ebx, 8 - paddb mm0, mm2 // add (Raw/2) to Avg for each byte - cmp ebx, MMXLength - movq [edi + ebx - 8], mm0 - jb davgAlp - } // end _asm block - } - break; - } // end switch ( bpp ) - - _asm { - // MMX acceleration complete now do clean-up - // Check if any remaining bytes left to decode - mov ebx, MMXLength // ebx ==> x = offset bytes remaining after MMX - mov edi, row // edi ==> Avg(x) - cmp ebx, FullLength // Test if offset at end of array - jnb davgend - // Do Paeth decode for remaining bytes - mov esi, prev_row // esi ==> Prior(x) - mov edx, edi - xor ecx, ecx // zero ecx before using cl & cx in loop below - sub edx, bpp // edx ==> Raw(x-bpp) -davglp2: - // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) - xor eax, eax - mov cl, [esi + ebx] // load cl with Prior(x) - mov al, [edx + ebx] // load al with Raw(x-bpp) - add ax, cx - inc ebx - shr ax, 1 // divide by 2 - add al, [edi+ebx-1] // Add Avg(x); -1 to offset inc ebx - cmp ebx, FullLength // Check if at end of array - mov [edi+ebx-1], al // Write back Raw(x); - // mov does not affect flags; -1 to offset inc ebx - jb davglp2 -davgend: - emms // End MMX instructions; prep for possible FP instrs. - } // end _asm block -} - -// Optimized code for PNG Paeth filter decoder -void /* PRIVATE */ -png_read_filter_row_mmx_paeth(png_row_infop row_info, png_bytep row, - png_bytep prev_row) -{ - png_uint_32 FullLength; - png_uint_32 MMXLength; - //png_uint_32 len; - int bpp; - int diff; - //int ptemp; - int patemp, pbtemp, pctemp; - - bpp = (row_info->pixel_depth + 7) >> 3; // Get # bytes per pixel - FullLength = row_info->rowbytes; // # of bytes to filter - _asm - { - xor ebx, ebx // ebx ==> x offset - mov edi, row - xor edx, edx // edx ==> x-bpp offset - mov esi, prev_row - xor eax, eax - - // Compute the Raw value for the first bpp bytes - // Note: the formula works out to be always - // Paeth(x) = Raw(x) + Prior(x) where x < bpp -dpthrlp: - mov al, [edi + ebx] - add al, [esi + ebx] - inc ebx - cmp ebx, bpp - mov [edi + ebx - 1], al - jb dpthrlp - // get # of bytes to alignment - mov diff, edi // take start of row - add diff, ebx // add bpp - xor ecx, ecx - add diff, 0xf // add 7 + 8 to incr past alignment boundary - and diff, 0xfffffff8 // mask to alignment boundary - sub diff, edi // subtract from start ==> value ebx at alignment - jz dpthgo - // fix alignment -dpthlp1: - xor eax, eax - // pav = p - a = (a + b - c) - a = b - c - mov al, [esi + ebx] // load Prior(x) into al - mov cl, [esi + edx] // load Prior(x-bpp) into cl - sub eax, ecx // subtract Prior(x-bpp) - mov patemp, eax // Save pav for later use - xor eax, eax - // pbv = p - b = (a + b - c) - b = a - c - mov al, [edi + edx] // load Raw(x-bpp) into al - sub eax, ecx // subtract Prior(x-bpp) - mov ecx, eax - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - add eax, patemp // pcv = pav + pbv - // pc = abs(pcv) - test eax, 0x80000000 - jz dpthpca - neg eax // reverse sign of neg values -dpthpca: - mov pctemp, eax // save pc for later use - // pb = abs(pbv) - test ecx, 0x80000000 - jz dpthpba - neg ecx // reverse sign of neg values -dpthpba: - mov pbtemp, ecx // save pb for later use - // pa = abs(pav) - mov eax, patemp - test eax, 0x80000000 - jz dpthpaa - neg eax // reverse sign of neg values -dpthpaa: - mov patemp, eax // save pa for later use - // test if pa <= pb - cmp eax, ecx - jna dpthabb - // pa > pb; now test if pb <= pc - cmp ecx, pctemp - jna dpthbbc - // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - mov cl, [esi + edx] // load Prior(x-bpp) into cl - jmp dpthpaeth -dpthbbc: - // pb <= pc; Raw(x) = Paeth(x) + Prior(x) - mov cl, [esi + ebx] // load Prior(x) into cl - jmp dpthpaeth -dpthabb: - // pa <= pb; now test if pa <= pc - cmp eax, pctemp - jna dpthabc - // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - mov cl, [esi + edx] // load Prior(x-bpp) into cl - jmp dpthpaeth -dpthabc: - // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) - mov cl, [edi + edx] // load Raw(x-bpp) into cl -dpthpaeth: - inc ebx - inc edx - // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 - add [edi + ebx - 1], cl - cmp ebx, diff - jb dpthlp1 -dpthgo: - mov ecx, FullLength - mov eax, ecx - sub eax, ebx // subtract alignment fix - and eax, 0x00000007 // calc bytes over mult of 8 - sub ecx, eax // drop over bytes from original length - mov MMXLength, ecx - } // end _asm block - // Now do the math for the rest of the row - switch ( bpp ) - { - case 3: - { - ActiveMask.use = 0x0000000000ffffff; - ActiveMaskEnd.use = 0xffff000000000000; - ShiftBpp.use = 24; // == bpp(3) * 8 - ShiftRem.use = 40; // == 64 - 24 - _asm - { - mov ebx, diff - mov edi, row - mov esi, prev_row - pxor mm0, mm0 - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm1, [edi+ebx-8] -dpth3lp: - psrlq mm1, ShiftRem // shift last 3 bytes to 1st 3 bytes - movq mm2, [esi + ebx] // load b=Prior(x) - punpcklbw mm1, mm0 // Unpack High bytes of a - movq mm3, [esi+ebx-8] // Prep c=Prior(x-bpp) bytes - punpcklbw mm2, mm0 // Unpack High bytes of b - psrlq mm3, ShiftRem // shift last 3 bytes to 1st 3 bytes - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - punpcklbw mm3, mm0 // Unpack High bytes of c - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - psubw mm4, mm3 - pxor mm7, mm7 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - paddw mm6, mm5 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - psubw mm4, mm0 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm5, mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pxor mm1, mm1 - pand mm3, mm7 - pandn mm7, mm0 - paddw mm7, mm3 - pxor mm0, mm0 - packuswb mm7, mm1 - movq mm3, [esi + ebx] // load c=Prior(x-bpp) - pand mm7, ActiveMask - movq mm2, mm3 // load b=Prior(x) step 1 - paddb mm7, [edi + ebx] // add Paeth predictor with Raw(x) - punpcklbw mm3, mm0 // Unpack High bytes of c - movq [edi + ebx], mm7 // write back updated value - movq mm1, mm7 // Now mm1 will be used as Raw(x-bpp) - // Now do Paeth for 2nd set of bytes (3-5) - psrlq mm2, ShiftBpp // load b=Prior(x) step 2 - punpcklbw mm1, mm0 // Unpack High bytes of a - pxor mm7, mm7 - punpcklbw mm2, mm0 // Unpack High bytes of b - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - psubw mm5, mm3 - psubw mm4, mm3 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = - // pav + pbv = pbv + pav - movq mm6, mm5 - paddw mm6, mm4 - - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm5 // Create mask pbv bytes < 0 - pcmpgtw mm7, mm4 // Create mask pav bytes < 0 - pand mm0, mm5 // Only pbv bytes < 0 in mm0 - pand mm7, mm4 // Only pav bytes < 0 in mm7 - psubw mm5, mm0 - psubw mm4, mm7 - psubw mm5, mm0 - psubw mm4, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - movq mm2, [esi + ebx] // load b=Prior(x) - pand mm3, mm7 - pandn mm7, mm0 - pxor mm1, mm1 - paddw mm7, mm3 - pxor mm0, mm0 - packuswb mm7, mm1 - movq mm3, mm2 // load c=Prior(x-bpp) step 1 - pand mm7, ActiveMask - punpckhbw mm2, mm0 // Unpack High bytes of b - psllq mm7, ShiftBpp // Shift bytes to 2nd group of 3 bytes - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - paddb mm7, [edi + ebx] // add Paeth predictor with Raw(x) - psllq mm3, ShiftBpp // load c=Prior(x-bpp) step 2 - movq [edi + ebx], mm7 // write back updated value - movq mm1, mm7 - punpckhbw mm3, mm0 // Unpack High bytes of c - psllq mm1, ShiftBpp // Shift bytes - // Now mm1 will be used as Raw(x-bpp) - // Now do Paeth for 3rd, and final, set of bytes (6-7) - pxor mm7, mm7 - punpckhbw mm1, mm0 // Unpack High bytes of a - psubw mm4, mm3 - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - pxor mm0, mm0 - paddw mm6, mm5 - - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - pandn mm0, mm1 - pandn mm7, mm4 - paddw mm0, mm2 - paddw mm7, mm5 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pand mm3, mm7 - pandn mm7, mm0 - paddw mm7, mm3 - pxor mm1, mm1 - packuswb mm1, mm7 - // Step ebx to next set of 8 bytes and repeat loop til done - add ebx, 8 - pand mm1, ActiveMaskEnd - paddb mm1, [edi + ebx - 8] // add Paeth predictor with Raw(x) - - cmp ebx, MMXLength - pxor mm0, mm0 // pxor does not affect flags - movq [edi + ebx - 8], mm1 // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - // mm3 ready to be used as Prior(x-bpp) next loop - jb dpth3lp - } // end _asm block - } - break; - - case 6: - case 7: - case 5: - { - ActiveMask.use = 0x00000000ffffffff; - ActiveMask2.use = 0xffffffff00000000; - ShiftBpp.use = bpp << 3; // == bpp * 8 - ShiftRem.use = 64 - ShiftBpp.use; - _asm - { - mov ebx, diff - mov edi, row - mov esi, prev_row - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm1, [edi+ebx-8] - pxor mm0, mm0 -dpth6lp: - // Must shift to position Raw(x-bpp) data - psrlq mm1, ShiftRem - // Do first set of 4 bytes - movq mm3, [esi+ebx-8] // read c=Prior(x-bpp) bytes - punpcklbw mm1, mm0 // Unpack Low bytes of a - movq mm2, [esi + ebx] // load b=Prior(x) - punpcklbw mm2, mm0 // Unpack Low bytes of b - // Must shift to position Prior(x-bpp) data - psrlq mm3, ShiftRem - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - punpcklbw mm3, mm0 // Unpack Low bytes of c - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - psubw mm4, mm3 - pxor mm7, mm7 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - paddw mm6, mm5 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - psubw mm4, mm0 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm5, mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pxor mm1, mm1 - pand mm3, mm7 - pandn mm7, mm0 - paddw mm7, mm3 - pxor mm0, mm0 - packuswb mm7, mm1 - movq mm3, [esi + ebx - 8] // load c=Prior(x-bpp) - pand mm7, ActiveMask - psrlq mm3, ShiftRem - movq mm2, [esi + ebx] // load b=Prior(x) step 1 - paddb mm7, [edi + ebx] // add Paeth predictor with Raw(x) - movq mm6, mm2 - movq [edi + ebx], mm7 // write back updated value - movq mm1, [edi+ebx-8] - psllq mm6, ShiftBpp - movq mm5, mm7 - psrlq mm1, ShiftRem - por mm3, mm6 - psllq mm5, ShiftBpp - punpckhbw mm3, mm0 // Unpack High bytes of c - por mm1, mm5 - // Do second set of 4 bytes - punpckhbw mm2, mm0 // Unpack High bytes of b - punpckhbw mm1, mm0 // Unpack High bytes of a - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - psubw mm4, mm3 - pxor mm7, mm7 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - paddw mm6, mm5 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - psubw mm4, mm0 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm5, mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pxor mm1, mm1 - pand mm3, mm7 - pandn mm7, mm0 - pxor mm1, mm1 - paddw mm7, mm3 - pxor mm0, mm0 - // Step ex to next set of 8 bytes and repeat loop til done - add ebx, 8 - packuswb mm1, mm7 - paddb mm1, [edi + ebx - 8] // add Paeth predictor with Raw(x) - cmp ebx, MMXLength - movq [edi + ebx - 8], mm1 // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - jb dpth6lp - } // end _asm block - } - break; - - case 4: - { - ActiveMask.use = 0x00000000ffffffff; - _asm { - mov ebx, diff - mov edi, row - mov esi, prev_row - pxor mm0, mm0 - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm1, [edi+ebx-8] // Only time should need to read - // a=Raw(x-bpp) bytes -dpth4lp: - // Do first set of 4 bytes - movq mm3, [esi+ebx-8] // read c=Prior(x-bpp) bytes - punpckhbw mm1, mm0 // Unpack Low bytes of a - movq mm2, [esi + ebx] // load b=Prior(x) - punpcklbw mm2, mm0 // Unpack High bytes of b - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - punpckhbw mm3, mm0 // Unpack High bytes of c - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - psubw mm4, mm3 - pxor mm7, mm7 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - paddw mm6, mm5 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - psubw mm4, mm0 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm5, mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pxor mm1, mm1 - pand mm3, mm7 - pandn mm7, mm0 - paddw mm7, mm3 - pxor mm0, mm0 - packuswb mm7, mm1 - movq mm3, [esi + ebx] // load c=Prior(x-bpp) - pand mm7, ActiveMask - movq mm2, mm3 // load b=Prior(x) step 1 - paddb mm7, [edi + ebx] // add Paeth predictor with Raw(x) - punpcklbw mm3, mm0 // Unpack High bytes of c - movq [edi + ebx], mm7 // write back updated value - movq mm1, mm7 // Now mm1 will be used as Raw(x-bpp) - // Do second set of 4 bytes - punpckhbw mm2, mm0 // Unpack Low bytes of b - punpcklbw mm1, mm0 // Unpack Low bytes of a - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - psubw mm4, mm3 - pxor mm7, mm7 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - paddw mm6, mm5 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - psubw mm4, mm0 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm5, mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pxor mm1, mm1 - pand mm3, mm7 - pandn mm7, mm0 - pxor mm1, mm1 - paddw mm7, mm3 - pxor mm0, mm0 - // Step ex to next set of 8 bytes and repeat loop til done - add ebx, 8 - packuswb mm1, mm7 - paddb mm1, [edi + ebx - 8] // add Paeth predictor with Raw(x) - cmp ebx, MMXLength - movq [edi + ebx - 8], mm1 // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - jb dpth4lp - } // end _asm block - } - break; - case 8: // bpp == 8 - { - ActiveMask.use = 0x00000000ffffffff; - _asm { - mov ebx, diff - mov edi, row - mov esi, prev_row - pxor mm0, mm0 - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm1, [edi+ebx-8] // Only time should need to read - // a=Raw(x-bpp) bytes -dpth8lp: - // Do first set of 4 bytes - movq mm3, [esi+ebx-8] // read c=Prior(x-bpp) bytes - punpcklbw mm1, mm0 // Unpack Low bytes of a - movq mm2, [esi + ebx] // load b=Prior(x) - punpcklbw mm2, mm0 // Unpack Low bytes of b - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - punpcklbw mm3, mm0 // Unpack Low bytes of c - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - psubw mm4, mm3 - pxor mm7, mm7 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - paddw mm6, mm5 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - psubw mm4, mm0 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm5, mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pxor mm1, mm1 - pand mm3, mm7 - pandn mm7, mm0 - paddw mm7, mm3 - pxor mm0, mm0 - packuswb mm7, mm1 - movq mm3, [esi+ebx-8] // read c=Prior(x-bpp) bytes - pand mm7, ActiveMask - movq mm2, [esi + ebx] // load b=Prior(x) - paddb mm7, [edi + ebx] // add Paeth predictor with Raw(x) - punpckhbw mm3, mm0 // Unpack High bytes of c - movq [edi + ebx], mm7 // write back updated value - movq mm1, [edi+ebx-8] // read a=Raw(x-bpp) bytes - - // Do second set of 4 bytes - punpckhbw mm2, mm0 // Unpack High bytes of b - punpckhbw mm1, mm0 // Unpack High bytes of a - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - psubw mm4, mm3 - pxor mm7, mm7 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - paddw mm6, mm5 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - psubw mm4, mm0 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm5, mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pxor mm1, mm1 - pand mm3, mm7 - pandn mm7, mm0 - pxor mm1, mm1 - paddw mm7, mm3 - pxor mm0, mm0 - // Step ex to next set of 8 bytes and repeat loop til done - add ebx, 8 - packuswb mm1, mm7 - paddb mm1, [edi + ebx - 8] // add Paeth predictor with Raw(x) - cmp ebx, MMXLength - movq [edi + ebx - 8], mm1 // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - jb dpth8lp - } // end _asm block - } - break; - - case 1: // bpp = 1 - case 2: // bpp = 2 - default: // bpp > 8 - { - _asm { - mov ebx, diff - cmp ebx, FullLength - jnb dpthdend - mov edi, row - mov esi, prev_row - // Do Paeth decode for remaining bytes - mov edx, ebx - xor ecx, ecx // zero ecx before using cl & cx in loop below - sub edx, bpp // Set edx = ebx - bpp -dpthdlp: - xor eax, eax - // pav = p - a = (a + b - c) - a = b - c - mov al, [esi + ebx] // load Prior(x) into al - mov cl, [esi + edx] // load Prior(x-bpp) into cl - sub eax, ecx // subtract Prior(x-bpp) - mov patemp, eax // Save pav for later use - xor eax, eax - // pbv = p - b = (a + b - c) - b = a - c - mov al, [edi + edx] // load Raw(x-bpp) into al - sub eax, ecx // subtract Prior(x-bpp) - mov ecx, eax - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - add eax, patemp // pcv = pav + pbv - // pc = abs(pcv) - test eax, 0x80000000 - jz dpthdpca - neg eax // reverse sign of neg values -dpthdpca: - mov pctemp, eax // save pc for later use - // pb = abs(pbv) - test ecx, 0x80000000 - jz dpthdpba - neg ecx // reverse sign of neg values -dpthdpba: - mov pbtemp, ecx // save pb for later use - // pa = abs(pav) - mov eax, patemp - test eax, 0x80000000 - jz dpthdpaa - neg eax // reverse sign of neg values -dpthdpaa: - mov patemp, eax // save pa for later use - // test if pa <= pb - cmp eax, ecx - jna dpthdabb - // pa > pb; now test if pb <= pc - cmp ecx, pctemp - jna dpthdbbc - // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - mov cl, [esi + edx] // load Prior(x-bpp) into cl - jmp dpthdpaeth -dpthdbbc: - // pb <= pc; Raw(x) = Paeth(x) + Prior(x) - mov cl, [esi + ebx] // load Prior(x) into cl - jmp dpthdpaeth -dpthdabb: - // pa <= pb; now test if pa <= pc - cmp eax, pctemp - jna dpthdabc - // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - mov cl, [esi + edx] // load Prior(x-bpp) into cl - jmp dpthdpaeth -dpthdabc: - // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) - mov cl, [edi + edx] // load Raw(x-bpp) into cl -dpthdpaeth: - inc ebx - inc edx - // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 - add [edi + ebx - 1], cl - cmp ebx, FullLength - jb dpthdlp -dpthdend: - } // end _asm block - } - return; // No need to go further with this one - } // end switch ( bpp ) - _asm - { - // MMX acceleration complete now do clean-up - // Check if any remaining bytes left to decode - mov ebx, MMXLength - cmp ebx, FullLength - jnb dpthend - mov edi, row - mov esi, prev_row - // Do Paeth decode for remaining bytes - mov edx, ebx - xor ecx, ecx // zero ecx before using cl & cx in loop below - sub edx, bpp // Set edx = ebx - bpp -dpthlp2: - xor eax, eax - // pav = p - a = (a + b - c) - a = b - c - mov al, [esi + ebx] // load Prior(x) into al - mov cl, [esi + edx] // load Prior(x-bpp) into cl - sub eax, ecx // subtract Prior(x-bpp) - mov patemp, eax // Save pav for later use - xor eax, eax - // pbv = p - b = (a + b - c) - b = a - c - mov al, [edi + edx] // load Raw(x-bpp) into al - sub eax, ecx // subtract Prior(x-bpp) - mov ecx, eax - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - add eax, patemp // pcv = pav + pbv - // pc = abs(pcv) - test eax, 0x80000000 - jz dpthpca2 - neg eax // reverse sign of neg values -dpthpca2: - mov pctemp, eax // save pc for later use - // pb = abs(pbv) - test ecx, 0x80000000 - jz dpthpba2 - neg ecx // reverse sign of neg values -dpthpba2: - mov pbtemp, ecx // save pb for later use - // pa = abs(pav) - mov eax, patemp - test eax, 0x80000000 - jz dpthpaa2 - neg eax // reverse sign of neg values -dpthpaa2: - mov patemp, eax // save pa for later use - // test if pa <= pb - cmp eax, ecx - jna dpthabb2 - // pa > pb; now test if pb <= pc - cmp ecx, pctemp - jna dpthbbc2 - // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - mov cl, [esi + edx] // load Prior(x-bpp) into cl - jmp dpthpaeth2 -dpthbbc2: - // pb <= pc; Raw(x) = Paeth(x) + Prior(x) - mov cl, [esi + ebx] // load Prior(x) into cl - jmp dpthpaeth2 -dpthabb2: - // pa <= pb; now test if pa <= pc - cmp eax, pctemp - jna dpthabc2 - // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - mov cl, [esi + edx] // load Prior(x-bpp) into cl - jmp dpthpaeth2 -dpthabc2: - // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) - mov cl, [edi + edx] // load Raw(x-bpp) into cl -dpthpaeth2: - inc ebx - inc edx - // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 - add [edi + ebx - 1], cl - cmp ebx, FullLength - jb dpthlp2 -dpthend: - emms // End MMX instructions; prep for possible FP instrs. - } // end _asm block -} - -// Optimized code for PNG Sub filter decoder -void /* PRIVATE */ -png_read_filter_row_mmx_sub(png_row_infop row_info, png_bytep row) -{ - //int test; - int bpp; - png_uint_32 FullLength; - png_uint_32 MMXLength; - int diff; - - bpp = (row_info->pixel_depth + 7) >> 3; // Get # bytes per pixel - FullLength = row_info->rowbytes - bpp; // # of bytes to filter - _asm { - mov edi, row - mov esi, edi // lp = row - add edi, bpp // rp = row + bpp - xor eax, eax - // get # of bytes to alignment - mov diff, edi // take start of row - add diff, 0xf // add 7 + 8 to incr past - // alignment boundary - xor ebx, ebx - and diff, 0xfffffff8 // mask to alignment boundary - sub diff, edi // subtract from start ==> value - // ebx at alignment - jz dsubgo - // fix alignment -dsublp1: - mov al, [esi+ebx] - add [edi+ebx], al - inc ebx - cmp ebx, diff - jb dsublp1 -dsubgo: - mov ecx, FullLength - mov edx, ecx - sub edx, ebx // subtract alignment fix - and edx, 0x00000007 // calc bytes over mult of 8 - sub ecx, edx // drop over bytes from length - mov MMXLength, ecx - } // end _asm block - - // Now do the math for the rest of the row - switch ( bpp ) - { - case 3: - { - ActiveMask.use = 0x0000ffffff000000; - ShiftBpp.use = 24; // == 3 * 8 - ShiftRem.use = 40; // == 64 - 24 - _asm { - mov edi, row - movq mm7, ActiveMask // Load ActiveMask for 2nd active byte group - mov esi, edi // lp = row - add edi, bpp // rp = row + bpp - movq mm6, mm7 - mov ebx, diff - psllq mm6, ShiftBpp // Move mask in mm6 to cover 3rd active - // byte group - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm1, [edi+ebx-8] -dsub3lp: - psrlq mm1, ShiftRem // Shift data for adding 1st bpp bytes - // no need for mask; shift clears inactive bytes - // Add 1st active group - movq mm0, [edi+ebx] - paddb mm0, mm1 - // Add 2nd active group - movq mm1, mm0 // mov updated Raws to mm1 - psllq mm1, ShiftBpp // shift data to position correctly - pand mm1, mm7 // mask to use only 2nd active group - paddb mm0, mm1 - // Add 3rd active group - movq mm1, mm0 // mov updated Raws to mm1 - psllq mm1, ShiftBpp // shift data to position correctly - pand mm1, mm6 // mask to use only 3rd active group - add ebx, 8 - paddb mm0, mm1 - cmp ebx, MMXLength - movq [edi+ebx-8], mm0 // Write updated Raws back to array - // Prep for doing 1st add at top of loop - movq mm1, mm0 - jb dsub3lp - } // end _asm block - } - break; - - case 1: - { - // Placed here just in case this is a duplicate of the - // non-MMX code for the SUB filter in png_read_filter_row below - // - // png_bytep rp; - // png_bytep lp; - // png_uint_32 i; - // bpp = (row_info->pixel_depth + 7) >> 3; - // for (i = (png_uint_32)bpp, rp = row + bpp, lp = row; - // i < row_info->rowbytes; i++, rp++, lp++) - // { - // *rp = (png_byte)(((int)(*rp) + (int)(*lp)) & 0xff); - // } - _asm { - mov ebx, diff - mov edi, row - cmp ebx, FullLength - jnb dsub1end - mov esi, edi // lp = row - xor eax, eax - add edi, bpp // rp = row + bpp -dsub1lp: - mov al, [esi+ebx] - add [edi+ebx], al - inc ebx - cmp ebx, FullLength - jb dsub1lp -dsub1end: - } // end _asm block - } - return; - - case 6: - case 7: - case 4: - case 5: - { - ShiftBpp.use = bpp << 3; - ShiftRem.use = 64 - ShiftBpp.use; - _asm { - mov edi, row - mov ebx, diff - mov esi, edi // lp = row - add edi, bpp // rp = row + bpp - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm1, [edi+ebx-8] -dsub4lp: - psrlq mm1, ShiftRem // Shift data for adding 1st bpp bytes - // no need for mask; shift clears inactive bytes - movq mm0, [edi+ebx] - paddb mm0, mm1 - // Add 2nd active group - movq mm1, mm0 // mov updated Raws to mm1 - psllq mm1, ShiftBpp // shift data to position correctly - // there is no need for any mask - // since shift clears inactive bits/bytes - add ebx, 8 - paddb mm0, mm1 - cmp ebx, MMXLength - movq [edi+ebx-8], mm0 - movq mm1, mm0 // Prep for doing 1st add at top of loop - jb dsub4lp - } // end _asm block - } - break; - - case 2: - { - ActiveMask.use = 0x00000000ffff0000; - ShiftBpp.use = 16; // == 2 * 8 - ShiftRem.use = 48; // == 64 - 16 - _asm { - movq mm7, ActiveMask // Load ActiveMask for 2nd active byte group - mov ebx, diff - movq mm6, mm7 - mov edi, row - psllq mm6, ShiftBpp // Move mask in mm6 to cover 3rd active - // byte group - mov esi, edi // lp = row - movq mm5, mm6 - add edi, bpp // rp = row + bpp - psllq mm5, ShiftBpp // Move mask in mm5 to cover 4th active - // byte group - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm1, [edi+ebx-8] -dsub2lp: - // Add 1st active group - psrlq mm1, ShiftRem // Shift data for adding 1st bpp bytes - // no need for mask; shift clears inactive - // bytes - movq mm0, [edi+ebx] - paddb mm0, mm1 - // Add 2nd active group - movq mm1, mm0 // mov updated Raws to mm1 - psllq mm1, ShiftBpp // shift data to position correctly - pand mm1, mm7 // mask to use only 2nd active group - paddb mm0, mm1 - // Add 3rd active group - movq mm1, mm0 // mov updated Raws to mm1 - psllq mm1, ShiftBpp // shift data to position correctly - pand mm1, mm6 // mask to use only 3rd active group - paddb mm0, mm1 - // Add 4th active group - movq mm1, mm0 // mov updated Raws to mm1 - psllq mm1, ShiftBpp // shift data to position correctly - pand mm1, mm5 // mask to use only 4th active group - add ebx, 8 - paddb mm0, mm1 - cmp ebx, MMXLength - movq [edi+ebx-8], mm0 // Write updated Raws back to array - movq mm1, mm0 // Prep for doing 1st add at top of loop - jb dsub2lp - } // end _asm block - } - break; - case 8: - { - _asm { - mov edi, row - mov ebx, diff - mov esi, edi // lp = row - add edi, bpp // rp = row + bpp - mov ecx, MMXLength - movq mm7, [edi+ebx-8] // PRIME the pump (load the first - // Raw(x-bpp) data set - and ecx, 0x0000003f // calc bytes over mult of 64 -dsub8lp: - movq mm0, [edi+ebx] // Load Sub(x) for 1st 8 bytes - paddb mm0, mm7 - movq mm1, [edi+ebx+8] // Load Sub(x) for 2nd 8 bytes - movq [edi+ebx], mm0 // Write Raw(x) for 1st 8 bytes - // Now mm0 will be used as Raw(x-bpp) for - // the 2nd group of 8 bytes. This will be - // repeated for each group of 8 bytes with - // the 8th group being used as the Raw(x-bpp) - // for the 1st group of the next loop. - paddb mm1, mm0 - movq mm2, [edi+ebx+16] // Load Sub(x) for 3rd 8 bytes - movq [edi+ebx+8], mm1 // Write Raw(x) for 2nd 8 bytes - paddb mm2, mm1 - movq mm3, [edi+ebx+24] // Load Sub(x) for 4th 8 bytes - movq [edi+ebx+16], mm2 // Write Raw(x) for 3rd 8 bytes - paddb mm3, mm2 - movq mm4, [edi+ebx+32] // Load Sub(x) for 5th 8 bytes - movq [edi+ebx+24], mm3 // Write Raw(x) for 4th 8 bytes - paddb mm4, mm3 - movq mm5, [edi+ebx+40] // Load Sub(x) for 6th 8 bytes - movq [edi+ebx+32], mm4 // Write Raw(x) for 5th 8 bytes - paddb mm5, mm4 - movq mm6, [edi+ebx+48] // Load Sub(x) for 7th 8 bytes - movq [edi+ebx+40], mm5 // Write Raw(x) for 6th 8 bytes - paddb mm6, mm5 - movq mm7, [edi+ebx+56] // Load Sub(x) for 8th 8 bytes - movq [edi+ebx+48], mm6 // Write Raw(x) for 7th 8 bytes - add ebx, 64 - paddb mm7, mm6 - cmp ebx, ecx - movq [edi+ebx-8], mm7 // Write Raw(x) for 8th 8 bytes - jb dsub8lp - cmp ebx, MMXLength - jnb dsub8lt8 -dsub8lpA: - movq mm0, [edi+ebx] - add ebx, 8 - paddb mm0, mm7 - cmp ebx, MMXLength - movq [edi+ebx-8], mm0 // use -8 to offset early add to ebx - movq mm7, mm0 // Move calculated Raw(x) data to mm1 to - // be the new Raw(x-bpp) for the next loop - jb dsub8lpA -dsub8lt8: - } // end _asm block - } - break; - - default: // bpp greater than 8 bytes - { - _asm { - mov ebx, diff - mov edi, row - mov esi, edi // lp = row - add edi, bpp // rp = row + bpp -dsubAlp: - movq mm0, [edi+ebx] - movq mm1, [esi+ebx] - add ebx, 8 - paddb mm0, mm1 - cmp ebx, MMXLength - movq [edi+ebx-8], mm0 // mov does not affect flags; -8 to offset - // add ebx - jb dsubAlp - } // end _asm block - } - break; - - } // end switch ( bpp ) - - _asm { - mov ebx, MMXLength - mov edi, row - cmp ebx, FullLength - jnb dsubend - mov esi, edi // lp = row - xor eax, eax - add edi, bpp // rp = row + bpp -dsublp2: - mov al, [esi+ebx] - add [edi+ebx], al - inc ebx - cmp ebx, FullLength - jb dsublp2 -dsubend: - emms // End MMX instructions; prep for possible FP instrs. - } // end _asm block -} - -// Optimized code for PNG Up filter decoder -void /* PRIVATE */ -png_read_filter_row_mmx_up(png_row_infop row_info, png_bytep row, - png_bytep prev_row) -{ - png_uint_32 len; - len = row_info->rowbytes; // # of bytes to filter - _asm { - mov edi, row - // get # of bytes to alignment - mov ecx, edi - xor ebx, ebx - add ecx, 0x7 - xor eax, eax - and ecx, 0xfffffff8 - mov esi, prev_row - sub ecx, edi - jz dupgo - // fix alignment -duplp1: - mov al, [edi+ebx] - add al, [esi+ebx] - inc ebx - cmp ebx, ecx - mov [edi + ebx-1], al // mov does not affect flags; -1 to offset inc ebx - jb duplp1 -dupgo: - mov ecx, len - mov edx, ecx - sub edx, ebx // subtract alignment fix - and edx, 0x0000003f // calc bytes over mult of 64 - sub ecx, edx // drop over bytes from length - // Unrolled loop - use all MMX registers and interleave to reduce - // number of branch instructions (loops) and reduce partial stalls -duploop: - movq mm1, [esi+ebx] - movq mm0, [edi+ebx] - movq mm3, [esi+ebx+8] - paddb mm0, mm1 - movq mm2, [edi+ebx+8] - movq [edi+ebx], mm0 - paddb mm2, mm3 - movq mm5, [esi+ebx+16] - movq [edi+ebx+8], mm2 - movq mm4, [edi+ebx+16] - movq mm7, [esi+ebx+24] - paddb mm4, mm5 - movq mm6, [edi+ebx+24] - movq [edi+ebx+16], mm4 - paddb mm6, mm7 - movq mm1, [esi+ebx+32] - movq [edi+ebx+24], mm6 - movq mm0, [edi+ebx+32] - movq mm3, [esi+ebx+40] - paddb mm0, mm1 - movq mm2, [edi+ebx+40] - movq [edi+ebx+32], mm0 - paddb mm2, mm3 - movq mm5, [esi+ebx+48] - movq [edi+ebx+40], mm2 - movq mm4, [edi+ebx+48] - movq mm7, [esi+ebx+56] - paddb mm4, mm5 - movq mm6, [edi+ebx+56] - movq [edi+ebx+48], mm4 - add ebx, 64 - paddb mm6, mm7 - cmp ebx, ecx - movq [edi+ebx-8], mm6 // (+56)movq does not affect flags; - // -8 to offset add ebx - jb duploop - - cmp edx, 0 // Test for bytes over mult of 64 - jz dupend - - - // 2 lines added by lcreeve at netins.net - // (mail 11 Jul 98 in png-implement list) - cmp edx, 8 //test for less than 8 bytes - jb duplt8 - - - add ecx, edx - and edx, 0x00000007 // calc bytes over mult of 8 - sub ecx, edx // drop over bytes from length - jz duplt8 - // Loop using MMX registers mm0 & mm1 to update 8 bytes simultaneously -duplpA: - movq mm1, [esi+ebx] - movq mm0, [edi+ebx] - add ebx, 8 - paddb mm0, mm1 - cmp ebx, ecx - movq [edi+ebx-8], mm0 // movq does not affect flags; -8 to offset add ebx - jb duplpA - cmp edx, 0 // Test for bytes over mult of 8 - jz dupend -duplt8: - xor eax, eax - add ecx, edx // move over byte count into counter - // Loop using x86 registers to update remaining bytes -duplp2: - mov al, [edi + ebx] - add al, [esi + ebx] - inc ebx - cmp ebx, ecx - mov [edi + ebx-1], al // mov does not affect flags; -1 to offset inc ebx - jb duplp2 -dupend: - // Conversion of filtered row completed - emms // End MMX instructions; prep for possible FP instrs. - } // end _asm block -} - - -// Optimized png_read_filter_row routines -void /* PRIVATE */ -png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep - row, png_bytep prev_row, int filter) -{ -#ifdef PNG_DEBUG - char filnm[10]; -#endif - - if (mmx_supported == 2) { -#if !defined(PNG_1_0_X) - /* this should have happened in png_init_mmx_flags() already */ - png_warning(png_ptr, "asm_flags may not have been initialized"); -#endif - png_mmx_support(); - } - -#ifdef PNG_DEBUG - png_debug(1, "in png_read_filter_row\n"); - switch (filter) - { - case 0: sprintf(filnm, "none"); - break; -#if !defined(PNG_1_0_X) - case 1: sprintf(filnm, "sub-%s", - (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB)? "MMX" : "x86"); - break; - case 2: sprintf(filnm, "up-%s", - (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP)? "MMX" : "x86"); - break; - case 3: sprintf(filnm, "avg-%s", - (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG)? "MMX" : "x86"); - break; - case 4: sprintf(filnm, "Paeth-%s", - (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH)? "MMX":"x86"); - break; -#else - case 1: sprintf(filnm, "sub"); - break; - case 2: sprintf(filnm, "up"); - break; - case 3: sprintf(filnm, "avg"); - break; - case 4: sprintf(filnm, "Paeth"); - break; -#endif - default: sprintf(filnm, "unknw"); - break; - } - png_debug2(0,"row=%5d, %s, ", png_ptr->row_number, filnm); - png_debug2(0, "pd=%2d, b=%d, ", (int)row_info->pixel_depth, - (int)((row_info->pixel_depth + 7) >> 3)); - png_debug1(0,"len=%8d, ", row_info->rowbytes); -#endif /* PNG_DEBUG */ - - switch (filter) - { - case PNG_FILTER_VALUE_NONE: - break; - - case PNG_FILTER_VALUE_SUB: - { -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB) && - (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && - (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) -#else - if (mmx_supported) -#endif - { - png_read_filter_row_mmx_sub(row_info, row); - } - else - { - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_bytep rp = row + bpp; - png_bytep lp = row; - - for (i = bpp; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*lp++)) & 0xff); - rp++; - } - } - break; - } - - case PNG_FILTER_VALUE_UP: - { -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP) && - (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && - (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) -#else - if (mmx_supported) -#endif - { - png_read_filter_row_mmx_up(row_info, row, prev_row); - } - else - { - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_bytep rp = row; - png_bytep pp = prev_row; - - for (i = 0; i < istop; ++i) - { - *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); - rp++; - } - } - break; - } - - case PNG_FILTER_VALUE_AVG: - { -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG) && - (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && - (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) -#else - if (mmx_supported) -#endif - { - png_read_filter_row_mmx_avg(row_info, row, prev_row); - } - else - { - png_uint_32 i; - png_bytep rp = row; - png_bytep pp = prev_row; - png_bytep lp = row; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_uint_32 istop = row_info->rowbytes - bpp; - - for (i = 0; i < bpp; i++) - { - *rp = (png_byte)(((int)(*rp) + - ((int)(*pp++) >> 1)) & 0xff); - rp++; - } - - for (i = 0; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + - ((int)(*pp++ + *lp++) >> 1)) & 0xff); - rp++; - } - } - break; - } - - case PNG_FILTER_VALUE_PAETH: - { -#if !defined(PNG_1_0_X) - if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH) && - (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && - (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) -#else - if (mmx_supported) -#endif - { - png_read_filter_row_mmx_paeth(row_info, row, prev_row); - } - else - { - png_uint_32 i; - png_bytep rp = row; - png_bytep pp = prev_row; - png_bytep lp = row; - png_bytep cp = prev_row; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_uint_32 istop=row_info->rowbytes - bpp; - - for (i = 0; i < bpp; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); - rp++; - } - - for (i = 0; i < istop; i++) // use leftover rp,pp - { - int a, b, c, pa, pb, pc, p; - - a = *lp++; - b = *pp++; - c = *cp++; - - p = b - c; - pc = a - c; - -#ifdef PNG_USE_ABS - pa = abs(p); - pb = abs(pc); - pc = abs(p + pc); -#else - pa = p < 0 ? -p : p; - pb = pc < 0 ? -pc : pc; - pc = (p + pc) < 0 ? -(p + pc) : p + pc; -#endif - - /* - if (pa <= pb && pa <= pc) - p = a; - else if (pb <= pc) - p = b; - else - p = c; - */ - - p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; - - *rp = (png_byte)(((int)(*rp) + p) & 0xff); - rp++; - } - } - break; - } - - default: - png_warning(png_ptr, "Ignoring bad row filter type"); - *row=0; - break; - } -} - -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED && PNG_USE_PNGVCRD */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng_osx/pngwio.c b/irrlicht-1.6/source/Irrlicht/libpng_osx/pngwio.c deleted file mode 100644 index 4d9d57e36..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng_osx/pngwio.c +++ /dev/null @@ -1,234 +0,0 @@ - -/* pngwio.c - functions for data output - * - * Last changed in libpng 1.2.13 November 13, 2006 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2002 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This file provides a location for all output. Users who need - * special handling are expected to write functions that have the same - * arguments as these and perform similar functions, but that possibly - * use different output methods. Note that you shouldn't change these - * functions, but rather write replacement functions and then change - * them at run time with png_set_write_fn(...). - */ - -#define PNG_INTERNAL -#include "png.h" -#ifdef PNG_WRITE_SUPPORTED - -/* Write the data to whatever output you are using. The default routine - writes to a file pointer. Note that this routine sometimes gets called - with very small lengths, so you should implement some kind of simple - buffering if you are using unbuffered writes. This should never be asked - to write more than 64K on a 16 bit machine. */ - -void /* PRIVATE */ -png_write_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - if (png_ptr->write_data_fn != NULL ) - (*(png_ptr->write_data_fn))(png_ptr, data, length); - else - png_error(png_ptr, "Call to NULL write function"); -} - -#if !defined(PNG_NO_STDIO) -/* This is the function that does the actual writing of data. If you are - not writing to a standard C stream, you should create a replacement - write_data function and use it at run time with png_set_write_fn(), rather - than changing the library. */ -#ifndef USE_FAR_KEYWORD -void PNGAPI -png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_uint_32 check; - - if(png_ptr == NULL) return; -#if defined(_WIN32_WCE) - if ( !WriteFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) - check = 0; -#else - check = fwrite(data, 1, length, (png_FILE_p)(png_ptr->io_ptr)); -#endif - if (check != length) - png_error(png_ptr, "Write Error"); -} -#else -/* this is the model-independent version. Since the standard I/O library - can't handle far buffers in the medium and small models, we have to copy - the data. -*/ - -#define NEAR_BUF_SIZE 1024 -#define MIN(a,b) (a <= b ? a : b) - -void PNGAPI -png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_uint_32 check; - png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */ - png_FILE_p io_ptr; - - if(png_ptr == NULL) return; - /* Check if data really is near. If so, use usual code. */ - near_data = (png_byte *)CVT_PTR_NOCHECK(data); - io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); - if ((png_bytep)near_data == data) - { -#if defined(_WIN32_WCE) - if ( !WriteFile(io_ptr, near_data, length, &check, NULL) ) - check = 0; -#else - check = fwrite(near_data, 1, length, io_ptr); -#endif - } - else - { - png_byte buf[NEAR_BUF_SIZE]; - png_size_t written, remaining, err; - check = 0; - remaining = length; - do - { - written = MIN(NEAR_BUF_SIZE, remaining); - png_memcpy(buf, data, written); /* copy far buffer to near buffer */ -#if defined(_WIN32_WCE) - if ( !WriteFile(io_ptr, buf, written, &err, NULL) ) - err = 0; -#else - err = fwrite(buf, 1, written, io_ptr); -#endif - if (err != written) - break; - else - check += err; - data += written; - remaining -= written; - } - while (remaining != 0); - } - if (check != length) - png_error(png_ptr, "Write Error"); -} - -#endif -#endif - -/* This function is called to output any data pending writing (normally - to disk). After png_flush is called, there should be no data pending - writing in any buffers. */ -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -void /* PRIVATE */ -png_flush(png_structp png_ptr) -{ - if (png_ptr->output_flush_fn != NULL) - (*(png_ptr->output_flush_fn))(png_ptr); -} - -#if !defined(PNG_NO_STDIO) -void PNGAPI -png_default_flush(png_structp png_ptr) -{ -#if !defined(_WIN32_WCE) - png_FILE_p io_ptr; -#endif - if(png_ptr == NULL) return; -#if !defined(_WIN32_WCE) - io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr)); - if (io_ptr != NULL) - fflush(io_ptr); -#endif -} -#endif -#endif - -/* This function allows the application to supply new output functions for - libpng if standard C streams aren't being used. - - This function takes as its arguments: - png_ptr - pointer to a png output data structure - io_ptr - pointer to user supplied structure containing info about - the output functions. May be NULL. - write_data_fn - pointer to a new output function that takes as its - arguments a pointer to a png_struct, a pointer to - data to be written, and a 32-bit unsigned int that is - the number of bytes to be written. The new write - function should call png_error(png_ptr, "Error msg") - to exit and output any fatal error messages. - flush_data_fn - pointer to a new flush function that takes as its - arguments a pointer to a png_struct. After a call to - the flush function, there should be no data in any buffers - or pending transmission. If the output method doesn't do - any buffering of ouput, a function prototype must still be - supplied although it doesn't have to do anything. If - PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile - time, output_flush_fn will be ignored, although it must be - supplied for compatibility. */ -void PNGAPI -png_set_write_fn(png_structp png_ptr, png_voidp io_ptr, - png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn) -{ - if(png_ptr == NULL) return; - png_ptr->io_ptr = io_ptr; - -#if !defined(PNG_NO_STDIO) - if (write_data_fn != NULL) - png_ptr->write_data_fn = write_data_fn; - else - png_ptr->write_data_fn = png_default_write_data; -#else - png_ptr->write_data_fn = write_data_fn; -#endif - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -#if !defined(PNG_NO_STDIO) - if (output_flush_fn != NULL) - png_ptr->output_flush_fn = output_flush_fn; - else - png_ptr->output_flush_fn = png_default_flush; -#else - png_ptr->output_flush_fn = output_flush_fn; -#endif -#endif /* PNG_WRITE_FLUSH_SUPPORTED */ - - /* It is an error to read while writing a png file */ - if (png_ptr->read_data_fn != NULL) - { - png_ptr->read_data_fn = NULL; - png_warning(png_ptr, - "Attempted to set both read_data_fn and write_data_fn in"); - png_warning(png_ptr, - "the same structure. Resetting read_data_fn to NULL."); - } -} - -#if defined(USE_FAR_KEYWORD) -#if defined(_MSC_VER) -void *png_far_to_near(png_structp png_ptr,png_voidp ptr, int check) -{ - void *near_ptr; - void FAR *far_ptr; - FP_OFF(near_ptr) = FP_OFF(ptr); - far_ptr = (void FAR *)near_ptr; - if(check != 0) - if(FP_SEG(ptr) != FP_SEG(far_ptr)) - png_error(png_ptr,"segment lost in conversion"); - return(near_ptr); -} -# else -void *png_far_to_near(png_structp png_ptr,png_voidp ptr, int check) -{ - void *near_ptr; - void FAR *far_ptr; - near_ptr = (void FAR *)ptr; - far_ptr = (void FAR *)near_ptr; - if(check != 0) - if(far_ptr != ptr) - png_error(png_ptr,"segment lost in conversion"); - return(near_ptr); -} -# endif -# endif -#endif /* PNG_WRITE_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng_osx/pngwrite.c b/irrlicht-1.6/source/Irrlicht/libpng_osx/pngwrite.c deleted file mode 100644 index df7ade334..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng_osx/pngwrite.c +++ /dev/null @@ -1,1518 +0,0 @@ - -/* pngwrite.c - general routines to write a PNG file - * - * Last changed in libpng 1.2.15 January 5, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -/* get internal access to png.h */ -#define PNG_INTERNAL -#include "png.h" -#ifdef PNG_WRITE_SUPPORTED - -/* Writes all the PNG information. This is the suggested way to use the - * library. If you have a new chunk to add, make a function to write it, - * and put it in the correct location here. If you want the chunk written - * after the image data, put it in png_write_end(). I strongly encourage - * you to supply a PNG_INFO_ flag, and check info_ptr->valid before writing - * the chunk, as that will keep the code from breaking if you want to just - * write a plain PNG file. If you have long comments, I suggest writing - * them in png_write_end(), and compressing them. - */ -void PNGAPI -png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr) -{ - png_debug(1, "in png_write_info_before_PLTE\n"); - if (png_ptr == NULL || info_ptr == NULL) - return; - if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE)) - { - png_write_sig(png_ptr); /* write PNG signature */ -#if defined(PNG_MNG_FEATURES_SUPPORTED) - if((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&(png_ptr->mng_features_permitted)) - { - png_warning(png_ptr,"MNG features are not allowed in a PNG datastream"); - png_ptr->mng_features_permitted=0; - } -#endif - /* write IHDR information. */ - png_write_IHDR(png_ptr, info_ptr->width, info_ptr->height, - info_ptr->bit_depth, info_ptr->color_type, info_ptr->compression_type, - info_ptr->filter_type, -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) - info_ptr->interlace_type); -#else - 0); -#endif - /* the rest of these check to see if the valid field has the appropriate - flag set, and if it does, writes the chunk. */ -#if defined(PNG_WRITE_gAMA_SUPPORTED) - if (info_ptr->valid & PNG_INFO_gAMA) - { -# ifdef PNG_FLOATING_POINT_SUPPORTED - png_write_gAMA(png_ptr, info_ptr->gamma); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - png_write_gAMA_fixed(png_ptr, info_ptr->int_gamma); -# endif -#endif - } -#endif -#if defined(PNG_WRITE_sRGB_SUPPORTED) - if (info_ptr->valid & PNG_INFO_sRGB) - png_write_sRGB(png_ptr, (int)info_ptr->srgb_intent); -#endif -#if defined(PNG_WRITE_iCCP_SUPPORTED) - if (info_ptr->valid & PNG_INFO_iCCP) - png_write_iCCP(png_ptr, info_ptr->iccp_name, PNG_COMPRESSION_TYPE_BASE, - info_ptr->iccp_profile, (int)info_ptr->iccp_proflen); -#endif -#if defined(PNG_WRITE_sBIT_SUPPORTED) - if (info_ptr->valid & PNG_INFO_sBIT) - png_write_sBIT(png_ptr, &(info_ptr->sig_bit), info_ptr->color_type); -#endif -#if defined(PNG_WRITE_cHRM_SUPPORTED) - if (info_ptr->valid & PNG_INFO_cHRM) - { -#ifdef PNG_FLOATING_POINT_SUPPORTED - png_write_cHRM(png_ptr, - info_ptr->x_white, info_ptr->y_white, - info_ptr->x_red, info_ptr->y_red, - info_ptr->x_green, info_ptr->y_green, - info_ptr->x_blue, info_ptr->y_blue); -#else -# ifdef PNG_FIXED_POINT_SUPPORTED - png_write_cHRM_fixed(png_ptr, - info_ptr->int_x_white, info_ptr->int_y_white, - info_ptr->int_x_red, info_ptr->int_y_red, - info_ptr->int_x_green, info_ptr->int_y_green, - info_ptr->int_x_blue, info_ptr->int_y_blue); -# endif -#endif - } -#endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) - if (info_ptr->unknown_chunks_num) - { - png_unknown_chunk *up; - - png_debug(5, "writing extra chunks\n"); - - for (up = info_ptr->unknown_chunks; - up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num; - up++) - { - int keep=png_handle_as_unknown(png_ptr, up->name); - if (keep != PNG_HANDLE_CHUNK_NEVER && - up->location && !(up->location & PNG_HAVE_PLTE) && - !(up->location & PNG_HAVE_IDAT) && - ((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS || - (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS))) - { - png_write_chunk(png_ptr, up->name, up->data, up->size); - } - } - } -#endif - png_ptr->mode |= PNG_WROTE_INFO_BEFORE_PLTE; - } -} - -void PNGAPI -png_write_info(png_structp png_ptr, png_infop info_ptr) -{ -#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) - int i; -#endif - - png_debug(1, "in png_write_info\n"); - - if (png_ptr == NULL || info_ptr == NULL) - return; - - png_write_info_before_PLTE(png_ptr, info_ptr); - - if (info_ptr->valid & PNG_INFO_PLTE) - png_write_PLTE(png_ptr, info_ptr->palette, - (png_uint_32)info_ptr->num_palette); - else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - png_error(png_ptr, "Valid palette required for paletted images"); - -#if defined(PNG_WRITE_tRNS_SUPPORTED) - if (info_ptr->valid & PNG_INFO_tRNS) - { -#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) - /* invert the alpha channel (in tRNS) */ - if ((png_ptr->transformations & PNG_INVERT_ALPHA) && - info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - int j; - for (j=0; j<(int)info_ptr->num_trans; j++) - info_ptr->trans[j] = (png_byte)(255 - info_ptr->trans[j]); - } -#endif - png_write_tRNS(png_ptr, info_ptr->trans, &(info_ptr->trans_values), - info_ptr->num_trans, info_ptr->color_type); - } -#endif -#if defined(PNG_WRITE_bKGD_SUPPORTED) - if (info_ptr->valid & PNG_INFO_bKGD) - png_write_bKGD(png_ptr, &(info_ptr->background), info_ptr->color_type); -#endif -#if defined(PNG_WRITE_hIST_SUPPORTED) - if (info_ptr->valid & PNG_INFO_hIST) - png_write_hIST(png_ptr, info_ptr->hist, info_ptr->num_palette); -#endif -#if defined(PNG_WRITE_oFFs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_oFFs) - png_write_oFFs(png_ptr, info_ptr->x_offset, info_ptr->y_offset, - info_ptr->offset_unit_type); -#endif -#if defined(PNG_WRITE_pCAL_SUPPORTED) - if (info_ptr->valid & PNG_INFO_pCAL) - png_write_pCAL(png_ptr, info_ptr->pcal_purpose, info_ptr->pcal_X0, - info_ptr->pcal_X1, info_ptr->pcal_type, info_ptr->pcal_nparams, - info_ptr->pcal_units, info_ptr->pcal_params); -#endif -#if defined(PNG_WRITE_sCAL_SUPPORTED) - if (info_ptr->valid & PNG_INFO_sCAL) -#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) - png_write_sCAL(png_ptr, (int)info_ptr->scal_unit, - info_ptr->scal_pixel_width, info_ptr->scal_pixel_height); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - png_write_sCAL_s(png_ptr, (int)info_ptr->scal_unit, - info_ptr->scal_s_width, info_ptr->scal_s_height); -#else - png_warning(png_ptr, - "png_write_sCAL not supported; sCAL chunk not written."); -#endif -#endif -#endif -#if defined(PNG_WRITE_pHYs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_pHYs) - png_write_pHYs(png_ptr, info_ptr->x_pixels_per_unit, - info_ptr->y_pixels_per_unit, info_ptr->phys_unit_type); -#endif -#if defined(PNG_WRITE_tIME_SUPPORTED) - if (info_ptr->valid & PNG_INFO_tIME) - { - png_write_tIME(png_ptr, &(info_ptr->mod_time)); - png_ptr->mode |= PNG_WROTE_tIME; - } -#endif -#if defined(PNG_WRITE_sPLT_SUPPORTED) - if (info_ptr->valid & PNG_INFO_sPLT) - for (i = 0; i < (int)info_ptr->splt_palettes_num; i++) - png_write_sPLT(png_ptr, info_ptr->splt_palettes + i); -#endif -#if defined(PNG_WRITE_TEXT_SUPPORTED) - /* Check to see if we need to write text chunks */ - for (i = 0; i < info_ptr->num_text; i++) - { - png_debug2(2, "Writing header text chunk %d, type %d\n", i, - info_ptr->text[i].compression); - /* an internationalized chunk? */ - if (info_ptr->text[i].compression > 0) - { -#if defined(PNG_WRITE_iTXt_SUPPORTED) - /* write international chunk */ - png_write_iTXt(png_ptr, - info_ptr->text[i].compression, - info_ptr->text[i].key, - info_ptr->text[i].lang, - info_ptr->text[i].lang_key, - info_ptr->text[i].text); -#else - png_warning(png_ptr, "Unable to write international text"); -#endif - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; - } - /* If we want a compressed text chunk */ - else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_zTXt) - { -#if defined(PNG_WRITE_zTXt_SUPPORTED) - /* write compressed chunk */ - png_write_zTXt(png_ptr, info_ptr->text[i].key, - info_ptr->text[i].text, 0, - info_ptr->text[i].compression); -#else - png_warning(png_ptr, "Unable to write compressed text"); -#endif - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR; - } - else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE) - { -#if defined(PNG_WRITE_tEXt_SUPPORTED) - /* write uncompressed chunk */ - png_write_tEXt(png_ptr, info_ptr->text[i].key, - info_ptr->text[i].text, - 0); -#else - png_warning(png_ptr, "Unable to write uncompressed text"); -#endif - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; - } - } -#endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) - if (info_ptr->unknown_chunks_num) - { - png_unknown_chunk *up; - - png_debug(5, "writing extra chunks\n"); - - for (up = info_ptr->unknown_chunks; - up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num; - up++) - { - int keep=png_handle_as_unknown(png_ptr, up->name); - if (keep != PNG_HANDLE_CHUNK_NEVER && - up->location && (up->location & PNG_HAVE_PLTE) && - !(up->location & PNG_HAVE_IDAT) && - ((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS || - (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS))) - { - png_write_chunk(png_ptr, up->name, up->data, up->size); - } - } - } -#endif -} - -/* Writes the end of the PNG file. If you don't want to write comments or - * time information, you can pass NULL for info. If you already wrote these - * in png_write_info(), do not write them again here. If you have long - * comments, I suggest writing them here, and compressing them. - */ -void PNGAPI -png_write_end(png_structp png_ptr, png_infop info_ptr) -{ - png_debug(1, "in png_write_end\n"); - if (png_ptr == NULL) - return; - if (!(png_ptr->mode & PNG_HAVE_IDAT)) - png_error(png_ptr, "No IDATs written into file"); - - /* see if user wants us to write information chunks */ - if (info_ptr != NULL) - { -#if defined(PNG_WRITE_TEXT_SUPPORTED) - int i; /* local index variable */ -#endif -#if defined(PNG_WRITE_tIME_SUPPORTED) - /* check to see if user has supplied a time chunk */ - if ((info_ptr->valid & PNG_INFO_tIME) && - !(png_ptr->mode & PNG_WROTE_tIME)) - png_write_tIME(png_ptr, &(info_ptr->mod_time)); -#endif -#if defined(PNG_WRITE_TEXT_SUPPORTED) - /* loop through comment chunks */ - for (i = 0; i < info_ptr->num_text; i++) - { - png_debug2(2, "Writing trailer text chunk %d, type %d\n", i, - info_ptr->text[i].compression); - /* an internationalized chunk? */ - if (info_ptr->text[i].compression > 0) - { -#if defined(PNG_WRITE_iTXt_SUPPORTED) - /* write international chunk */ - png_write_iTXt(png_ptr, - info_ptr->text[i].compression, - info_ptr->text[i].key, - info_ptr->text[i].lang, - info_ptr->text[i].lang_key, - info_ptr->text[i].text); -#else - png_warning(png_ptr, "Unable to write international text"); -#endif - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; - } - else if (info_ptr->text[i].compression >= PNG_TEXT_COMPRESSION_zTXt) - { -#if defined(PNG_WRITE_zTXt_SUPPORTED) - /* write compressed chunk */ - png_write_zTXt(png_ptr, info_ptr->text[i].key, - info_ptr->text[i].text, 0, - info_ptr->text[i].compression); -#else - png_warning(png_ptr, "Unable to write compressed text"); -#endif - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR; - } - else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE) - { -#if defined(PNG_WRITE_tEXt_SUPPORTED) - /* write uncompressed chunk */ - png_write_tEXt(png_ptr, info_ptr->text[i].key, - info_ptr->text[i].text, 0); -#else - png_warning(png_ptr, "Unable to write uncompressed text"); -#endif - - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; - } - } -#endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) - if (info_ptr->unknown_chunks_num) - { - png_unknown_chunk *up; - - png_debug(5, "writing extra chunks\n"); - - for (up = info_ptr->unknown_chunks; - up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num; - up++) - { - int keep=png_handle_as_unknown(png_ptr, up->name); - if (keep != PNG_HANDLE_CHUNK_NEVER && - up->location && (up->location & PNG_AFTER_IDAT) && - ((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS || - (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS))) - { - png_write_chunk(png_ptr, up->name, up->data, up->size); - } - } - } -#endif - } - - png_ptr->mode |= PNG_AFTER_IDAT; - - /* write end of PNG file */ - png_write_IEND(png_ptr); -#if 0 -/* This flush, added in libpng-1.0.8, causes some applications to crash - because they do not set png_ptr->output_flush_fn */ - png_flush(png_ptr); -#endif -} - -#if defined(PNG_WRITE_tIME_SUPPORTED) -#if !defined(_WIN32_WCE) -/* "time.h" functions are not supported on WindowsCE */ -void PNGAPI -png_convert_from_struct_tm(png_timep ptime, struct tm FAR * ttime) -{ - png_debug(1, "in png_convert_from_struct_tm\n"); - ptime->year = (png_uint_16)(1900 + ttime->tm_year); - ptime->month = (png_byte)(ttime->tm_mon + 1); - ptime->day = (png_byte)ttime->tm_mday; - ptime->hour = (png_byte)ttime->tm_hour; - ptime->minute = (png_byte)ttime->tm_min; - ptime->second = (png_byte)ttime->tm_sec; -} - -void PNGAPI -png_convert_from_time_t(png_timep ptime, time_t ttime) -{ - struct tm *tbuf; - - png_debug(1, "in png_convert_from_time_t\n"); - tbuf = gmtime(&ttime); - png_convert_from_struct_tm(ptime, tbuf); -} -#endif -#endif - -/* Initialize png_ptr structure, and allocate any memory needed */ -png_structp PNGAPI -png_create_write_struct(png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn) -{ -#ifdef PNG_USER_MEM_SUPPORTED - return (png_create_write_struct_2(user_png_ver, error_ptr, error_fn, - warn_fn, png_voidp_NULL, png_malloc_ptr_NULL, png_free_ptr_NULL)); -} - -/* Alternate initialize png_ptr structure, and allocate any memory needed */ -png_structp PNGAPI -png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn) -{ -#endif /* PNG_USER_MEM_SUPPORTED */ - png_structp png_ptr; -#ifdef PNG_SETJMP_SUPPORTED -#ifdef USE_FAR_KEYWORD - jmp_buf jmpbuf; -#endif -#endif - int i; - png_debug(1, "in png_create_write_struct\n"); -#ifdef PNG_USER_MEM_SUPPORTED - png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG, - (png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr); -#else - png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); -#endif /* PNG_USER_MEM_SUPPORTED */ - if (png_ptr == NULL) - return (NULL); - -#if !defined(PNG_1_0_X) -#ifdef PNG_ASSEMBLER_CODE_SUPPORTED -#ifdef PNG_MMX_CODE_SUPPORTED - png_init_mmx_flags(png_ptr); /* 1.2.0 addition */ -#endif -#endif -#endif /* PNG_1_0_X */ - - /* added at libpng-1.2.6 */ -#ifdef PNG_SET_USER_LIMITS_SUPPORTED - png_ptr->user_width_max=PNG_USER_WIDTH_MAX; - png_ptr->user_height_max=PNG_USER_HEIGHT_MAX; -#endif - -#ifdef PNG_SETJMP_SUPPORTED -#ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) -#else - if (setjmp(png_ptr->jmpbuf)) -#endif - { - png_free(png_ptr, png_ptr->zbuf); - png_ptr->zbuf=NULL; - png_destroy_struct(png_ptr); - return (NULL); - } -#ifdef USE_FAR_KEYWORD - png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf)); -#endif -#endif - -#ifdef PNG_USER_MEM_SUPPORTED - png_set_mem_fn(png_ptr, mem_ptr, malloc_fn, free_fn); -#endif /* PNG_USER_MEM_SUPPORTED */ - png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn); - - i=0; - do - { - if(user_png_ver[i] != png_libpng_ver[i]) - png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; - } while (png_libpng_ver[i++]); - - if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) - { - /* Libpng 0.90 and later are binary incompatible with libpng 0.89, so - * we must recompile any applications that use any older library version. - * For versions after libpng 1.0, we will be compatible, so we need - * only check the first digit. - */ - if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] || - (user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) || - (user_png_ver[0] == '0' && user_png_ver[2] < '9')) - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char msg[80]; - if (user_png_ver) - { - sprintf(msg, "Application was compiled with png.h from libpng-%.20s", - user_png_ver); - png_warning(png_ptr, msg); - } - sprintf(msg, "Application is running with png.c from libpng-%.20s", - png_libpng_ver); - png_warning(png_ptr, msg); -#endif -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "Incompatible libpng version in application and library"); - } - } - - /* initialize zbuf - compression buffer */ - png_ptr->zbuf_size = PNG_ZBUF_SIZE; - png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, - (png_uint_32)png_ptr->zbuf_size); - - png_set_write_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL, - png_flush_ptr_NULL); - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - png_set_filter_heuristics(png_ptr, PNG_FILTER_HEURISTIC_DEFAULT, - 1, png_doublep_NULL, png_doublep_NULL); -#endif - -#ifdef PNG_SETJMP_SUPPORTED -/* Applications that neglect to set up their own setjmp() and then encounter - a png_error() will longjmp here. Since the jmpbuf is then meaningless we - abort instead of returning. */ -#ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) - PNG_ABORT(); - png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf)); -#else - if (setjmp(png_ptr->jmpbuf)) - PNG_ABORT(); -#endif -#endif - return (png_ptr); -} - -/* Initialize png_ptr structure, and allocate any memory needed */ -#if defined(PNG_1_0_X) || defined(PNG_1_2_X) -/* Deprecated. */ -#undef png_write_init -void PNGAPI -png_write_init(png_structp png_ptr) -{ - /* We only come here via pre-1.0.7-compiled applications */ - png_write_init_2(png_ptr, "1.0.6 or earlier", 0, 0); -} - -void PNGAPI -png_write_init_2(png_structp png_ptr, png_const_charp user_png_ver, - png_size_t png_struct_size, png_size_t png_info_size) -{ - /* We only come here via pre-1.0.12-compiled applications */ - if(png_ptr == NULL) return; -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - if(png_sizeof(png_struct) > png_struct_size || - png_sizeof(png_info) > png_info_size) - { - char msg[80]; - png_ptr->warning_fn=NULL; - if (user_png_ver) - { - sprintf(msg, "Application was compiled with png.h from libpng-%.20s", - user_png_ver); - png_warning(png_ptr, msg); - } - sprintf(msg, "Application is running with png.c from libpng-%.20s", - png_libpng_ver); - png_warning(png_ptr, msg); - } -#endif - if(png_sizeof(png_struct) > png_struct_size) - { - png_ptr->error_fn=NULL; -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "The png struct allocated by the application for writing is too small."); - } - if(png_sizeof(png_info) > png_info_size) - { - png_ptr->error_fn=NULL; -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "The info struct allocated by the application for writing is too small."); - } - png_write_init_3(&png_ptr, user_png_ver, png_struct_size); -} -#endif /* PNG_1_0_X || PNG_1_2_X */ - - -void PNGAPI -png_write_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, - png_size_t png_struct_size) -{ - png_structp png_ptr=*ptr_ptr; -#ifdef PNG_SETJMP_SUPPORTED - jmp_buf tmp_jmp; /* to save current jump buffer */ -#endif - - int i = 0; - - if (png_ptr == NULL) - return; - - do - { - if (user_png_ver[i] != png_libpng_ver[i]) - { -#ifdef PNG_LEGACY_SUPPORTED - png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; -#else - png_ptr->warning_fn=NULL; - png_warning(png_ptr, - "Application uses deprecated png_write_init() and should be recompiled."); - break; -#endif - } - } while (png_libpng_ver[i++]); - - png_debug(1, "in png_write_init_3\n"); - -#ifdef PNG_SETJMP_SUPPORTED - /* save jump buffer and error functions */ - png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf)); -#endif - - if (png_sizeof(png_struct) > png_struct_size) - { - png_destroy_struct(png_ptr); - png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); - *ptr_ptr = png_ptr; - } - - /* reset all variables to 0 */ - png_memset(png_ptr, 0, png_sizeof (png_struct)); - - /* added at libpng-1.2.6 */ -#ifdef PNG_SET_USER_LIMITS_SUPPORTED - png_ptr->user_width_max=PNG_USER_WIDTH_MAX; - png_ptr->user_height_max=PNG_USER_HEIGHT_MAX; -#endif - -#if !defined(PNG_1_0_X) -#ifdef PNG_ASSEMBLER_CODE_SUPPORTED -#ifdef PNG_MMX_CODE_SUPPORTED - png_init_mmx_flags(png_ptr); /* 1.2.0 addition */ -#endif -#endif -#endif /* PNG_1_0_X */ - -#ifdef PNG_SETJMP_SUPPORTED - /* restore jump buffer */ - png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf)); -#endif - - png_set_write_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL, - png_flush_ptr_NULL); - - /* initialize zbuf - compression buffer */ - png_ptr->zbuf_size = PNG_ZBUF_SIZE; - png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, - (png_uint_32)png_ptr->zbuf_size); - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - png_set_filter_heuristics(png_ptr, PNG_FILTER_HEURISTIC_DEFAULT, - 1, png_doublep_NULL, png_doublep_NULL); -#endif -} - -/* Write a few rows of image data. If the image is interlaced, - * either you will have to write the 7 sub images, or, if you - * have called png_set_interlace_handling(), you will have to - * "write" the image seven times. - */ -void PNGAPI -png_write_rows(png_structp png_ptr, png_bytepp row, - png_uint_32 num_rows) -{ - png_uint_32 i; /* row counter */ - png_bytepp rp; /* row pointer */ - - png_debug(1, "in png_write_rows\n"); - - if (png_ptr == NULL) - return; - - /* loop through the rows */ - for (i = 0, rp = row; i < num_rows; i++, rp++) - { - png_write_row(png_ptr, *rp); - } -} - -/* Write the image. You only need to call this function once, even - * if you are writing an interlaced image. - */ -void PNGAPI -png_write_image(png_structp png_ptr, png_bytepp image) -{ - png_uint_32 i; /* row index */ - int pass, num_pass; /* pass variables */ - png_bytepp rp; /* points to current row */ - - if (png_ptr == NULL) - return; - - png_debug(1, "in png_write_image\n"); -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) - /* intialize interlace handling. If image is not interlaced, - this will set pass to 1 */ - num_pass = png_set_interlace_handling(png_ptr); -#else - num_pass = 1; -#endif - /* loop through passes */ - for (pass = 0; pass < num_pass; pass++) - { - /* loop through image */ - for (i = 0, rp = image; i < png_ptr->height; i++, rp++) - { - png_write_row(png_ptr, *rp); - } - } -} - -/* called by user to write a row of image data */ -void PNGAPI -png_write_row(png_structp png_ptr, png_bytep row) -{ - if (png_ptr == NULL) - return; - png_debug2(1, "in png_write_row (row %ld, pass %d)\n", - png_ptr->row_number, png_ptr->pass); - - /* initialize transformations and other stuff if first time */ - if (png_ptr->row_number == 0 && png_ptr->pass == 0) - { - /* make sure we wrote the header info */ - if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE)) - png_error(png_ptr, - "png_write_info was never called before png_write_row."); - - /* check for transforms that have been set but were defined out */ -#if !defined(PNG_WRITE_INVERT_SUPPORTED) && defined(PNG_READ_INVERT_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_MONO) - png_warning(png_ptr, "PNG_WRITE_INVERT_SUPPORTED is not defined."); -#endif -#if !defined(PNG_WRITE_FILLER_SUPPORTED) && defined(PNG_READ_FILLER_SUPPORTED) - if (png_ptr->transformations & PNG_FILLER) - png_warning(png_ptr, "PNG_WRITE_FILLER_SUPPORTED is not defined."); -#endif -#if !defined(PNG_WRITE_PACKSWAP_SUPPORTED) && defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - png_warning(png_ptr, "PNG_WRITE_PACKSWAP_SUPPORTED is not defined."); -#endif -#if !defined(PNG_WRITE_PACK_SUPPORTED) && defined(PNG_READ_PACK_SUPPORTED) - if (png_ptr->transformations & PNG_PACK) - png_warning(png_ptr, "PNG_WRITE_PACK_SUPPORTED is not defined."); -#endif -#if !defined(PNG_WRITE_SHIFT_SUPPORTED) && defined(PNG_READ_SHIFT_SUPPORTED) - if (png_ptr->transformations & PNG_SHIFT) - png_warning(png_ptr, "PNG_WRITE_SHIFT_SUPPORTED is not defined."); -#endif -#if !defined(PNG_WRITE_BGR_SUPPORTED) && defined(PNG_READ_BGR_SUPPORTED) - if (png_ptr->transformations & PNG_BGR) - png_warning(png_ptr, "PNG_WRITE_BGR_SUPPORTED is not defined."); -#endif -#if !defined(PNG_WRITE_SWAP_SUPPORTED) && defined(PNG_READ_SWAP_SUPPORTED) - if (png_ptr->transformations & PNG_SWAP_BYTES) - png_warning(png_ptr, "PNG_WRITE_SWAP_SUPPORTED is not defined."); -#endif - - png_write_start_row(png_ptr); - } - -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) - /* if interlaced and not interested in row, return */ - if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) - { - switch (png_ptr->pass) - { - case 0: - if (png_ptr->row_number & 0x07) - { - png_write_finish_row(png_ptr); - return; - } - break; - case 1: - if ((png_ptr->row_number & 0x07) || png_ptr->width < 5) - { - png_write_finish_row(png_ptr); - return; - } - break; - case 2: - if ((png_ptr->row_number & 0x07) != 4) - { - png_write_finish_row(png_ptr); - return; - } - break; - case 3: - if ((png_ptr->row_number & 0x03) || png_ptr->width < 3) - { - png_write_finish_row(png_ptr); - return; - } - break; - case 4: - if ((png_ptr->row_number & 0x03) != 2) - { - png_write_finish_row(png_ptr); - return; - } - break; - case 5: - if ((png_ptr->row_number & 0x01) || png_ptr->width < 2) - { - png_write_finish_row(png_ptr); - return; - } - break; - case 6: - if (!(png_ptr->row_number & 0x01)) - { - png_write_finish_row(png_ptr); - return; - } - break; - } - } -#endif - - /* set up row info for transformations */ - png_ptr->row_info.color_type = png_ptr->color_type; - png_ptr->row_info.width = png_ptr->usr_width; - png_ptr->row_info.channels = png_ptr->usr_channels; - png_ptr->row_info.bit_depth = png_ptr->usr_bit_depth; - png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth * - png_ptr->row_info.channels); - - png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth, - png_ptr->row_info.width); - - png_debug1(3, "row_info->color_type = %d\n", png_ptr->row_info.color_type); - png_debug1(3, "row_info->width = %lu\n", png_ptr->row_info.width); - png_debug1(3, "row_info->channels = %d\n", png_ptr->row_info.channels); - png_debug1(3, "row_info->bit_depth = %d\n", png_ptr->row_info.bit_depth); - png_debug1(3, "row_info->pixel_depth = %d\n", png_ptr->row_info.pixel_depth); - png_debug1(3, "row_info->rowbytes = %lu\n", png_ptr->row_info.rowbytes); - - /* Copy user's row into buffer, leaving room for filter byte. */ - png_memcpy_check(png_ptr, png_ptr->row_buf + 1, row, - png_ptr->row_info.rowbytes); - -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) - /* handle interlacing */ - if (png_ptr->interlaced && png_ptr->pass < 6 && - (png_ptr->transformations & PNG_INTERLACE)) - { - png_do_write_interlace(&(png_ptr->row_info), - png_ptr->row_buf + 1, png_ptr->pass); - /* this should always get caught above, but still ... */ - if (!(png_ptr->row_info.width)) - { - png_write_finish_row(png_ptr); - return; - } - } -#endif - - /* handle other transformations */ - if (png_ptr->transformations) - png_do_write_transformations(png_ptr); - -#if defined(PNG_MNG_FEATURES_SUPPORTED) - /* Write filter_method 64 (intrapixel differencing) only if - * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and - * 2. Libpng did not write a PNG signature (this filter_method is only - * used in PNG datastreams that are embedded in MNG datastreams) and - * 3. The application called png_permit_mng_features with a mask that - * included PNG_FLAG_MNG_FILTER_64 and - * 4. The filter_method is 64 and - * 5. The color_type is RGB or RGBA - */ - if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING)) - { - /* Intrapixel differencing */ - png_do_write_intrapixel(&(png_ptr->row_info), png_ptr->row_buf + 1); - } -#endif - - /* Find a filter if necessary, filter the row and write it out. */ - png_write_find_filter(png_ptr, &(png_ptr->row_info)); - - if (png_ptr->write_row_fn != NULL) - (*(png_ptr->write_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass); -} - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -/* Set the automatic flush interval or 0 to turn flushing off */ -void PNGAPI -png_set_flush(png_structp png_ptr, int nrows) -{ - png_debug(1, "in png_set_flush\n"); - if (png_ptr == NULL) - return; - png_ptr->flush_dist = (nrows < 0 ? 0 : nrows); -} - -/* flush the current output buffers now */ -void PNGAPI -png_write_flush(png_structp png_ptr) -{ - int wrote_IDAT; - - png_debug(1, "in png_write_flush\n"); - if (png_ptr == NULL) - return; - /* We have already written out all of the data */ - if (png_ptr->row_number >= png_ptr->num_rows) - return; - - do - { - int ret; - - /* compress the data */ - ret = deflate(&png_ptr->zstream, Z_SYNC_FLUSH); - wrote_IDAT = 0; - - /* check for compression errors */ - if (ret != Z_OK) - { - if (png_ptr->zstream.msg != NULL) - png_error(png_ptr, png_ptr->zstream.msg); - else - png_error(png_ptr, "zlib error"); - } - - if (!(png_ptr->zstream.avail_out)) - { - /* write the IDAT and reset the zlib output buffer */ - png_write_IDAT(png_ptr, png_ptr->zbuf, - png_ptr->zbuf_size); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - wrote_IDAT = 1; - } - } while(wrote_IDAT == 1); - - /* If there is any data left to be output, write it into a new IDAT */ - if (png_ptr->zbuf_size != png_ptr->zstream.avail_out) - { - /* write the IDAT and reset the zlib output buffer */ - png_write_IDAT(png_ptr, png_ptr->zbuf, - png_ptr->zbuf_size - png_ptr->zstream.avail_out); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - } - png_ptr->flush_rows = 0; - png_flush(png_ptr); -} -#endif /* PNG_WRITE_FLUSH_SUPPORTED */ - -/* free all memory used by the write */ -void PNGAPI -png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr) -{ - png_structp png_ptr = NULL; - png_infop info_ptr = NULL; -#ifdef PNG_USER_MEM_SUPPORTED - png_free_ptr free_fn = NULL; - png_voidp mem_ptr = NULL; -#endif - - png_debug(1, "in png_destroy_write_struct\n"); - if (png_ptr_ptr != NULL) - { - png_ptr = *png_ptr_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - free_fn = png_ptr->free_fn; - mem_ptr = png_ptr->mem_ptr; -#endif - } - - if (info_ptr_ptr != NULL) - info_ptr = *info_ptr_ptr; - - if (info_ptr != NULL) - { - png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1); - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - if (png_ptr->num_chunk_list) - { - png_free(png_ptr, png_ptr->chunk_list); - png_ptr->chunk_list=NULL; - png_ptr->num_chunk_list=0; - } -#endif - -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)info_ptr, (png_free_ptr)free_fn, - (png_voidp)mem_ptr); -#else - png_destroy_struct((png_voidp)info_ptr); -#endif - *info_ptr_ptr = NULL; - } - - if (png_ptr != NULL) - { - png_write_destroy(png_ptr); -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn, - (png_voidp)mem_ptr); -#else - png_destroy_struct((png_voidp)png_ptr); -#endif - *png_ptr_ptr = NULL; - } -} - - -/* Free any memory used in png_ptr struct (old method) */ -void /* PRIVATE */ -png_write_destroy(png_structp png_ptr) -{ -#ifdef PNG_SETJMP_SUPPORTED - jmp_buf tmp_jmp; /* save jump buffer */ -#endif - png_error_ptr error_fn; - png_error_ptr warning_fn; - png_voidp error_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - png_free_ptr free_fn; -#endif - - png_debug(1, "in png_write_destroy\n"); - /* free any memory zlib uses */ - deflateEnd(&png_ptr->zstream); - - /* free our memory. png_free checks NULL for us. */ - png_free(png_ptr, png_ptr->zbuf); - png_free(png_ptr, png_ptr->row_buf); - png_free(png_ptr, png_ptr->prev_row); - png_free(png_ptr, png_ptr->sub_row); - png_free(png_ptr, png_ptr->up_row); - png_free(png_ptr, png_ptr->avg_row); - png_free(png_ptr, png_ptr->paeth_row); - -#if defined(PNG_TIME_RFC1123_SUPPORTED) - png_free(png_ptr, png_ptr->time_buffer); -#endif - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - png_free(png_ptr, png_ptr->prev_filters); - png_free(png_ptr, png_ptr->filter_weights); - png_free(png_ptr, png_ptr->inv_filter_weights); - png_free(png_ptr, png_ptr->filter_costs); - png_free(png_ptr, png_ptr->inv_filter_costs); -#endif - -#ifdef PNG_SETJMP_SUPPORTED - /* reset structure */ - png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf)); -#endif - - error_fn = png_ptr->error_fn; - warning_fn = png_ptr->warning_fn; - error_ptr = png_ptr->error_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - free_fn = png_ptr->free_fn; -#endif - - png_memset(png_ptr, 0, png_sizeof (png_struct)); - - png_ptr->error_fn = error_fn; - png_ptr->warning_fn = warning_fn; - png_ptr->error_ptr = error_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - png_ptr->free_fn = free_fn; -#endif - -#ifdef PNG_SETJMP_SUPPORTED - png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf)); -#endif -} - -/* Allow the application to select one or more row filters to use. */ -void PNGAPI -png_set_filter(png_structp png_ptr, int method, int filters) -{ - png_debug(1, "in png_set_filter\n"); - if (png_ptr == NULL) - return; -#if defined(PNG_MNG_FEATURES_SUPPORTED) - if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - (method == PNG_INTRAPIXEL_DIFFERENCING)) - method = PNG_FILTER_TYPE_BASE; -#endif - if (method == PNG_FILTER_TYPE_BASE) - { - switch (filters & (PNG_ALL_FILTERS | 0x07)) - { - case 5: - case 6: - case 7: png_warning(png_ptr, "Unknown row filter for method 0"); - case PNG_FILTER_VALUE_NONE: png_ptr->do_filter=PNG_FILTER_NONE; break; - case PNG_FILTER_VALUE_SUB: png_ptr->do_filter=PNG_FILTER_SUB; break; - case PNG_FILTER_VALUE_UP: png_ptr->do_filter=PNG_FILTER_UP; break; - case PNG_FILTER_VALUE_AVG: png_ptr->do_filter=PNG_FILTER_AVG; break; - case PNG_FILTER_VALUE_PAETH: png_ptr->do_filter=PNG_FILTER_PAETH;break; - default: png_ptr->do_filter = (png_byte)filters; break; - } - - /* If we have allocated the row_buf, this means we have already started - * with the image and we should have allocated all of the filter buffers - * that have been selected. If prev_row isn't already allocated, then - * it is too late to start using the filters that need it, since we - * will be missing the data in the previous row. If an application - * wants to start and stop using particular filters during compression, - * it should start out with all of the filters, and then add and - * remove them after the start of compression. - */ - if (png_ptr->row_buf != NULL) - { - if ((png_ptr->do_filter & PNG_FILTER_SUB) && png_ptr->sub_row == NULL) - { - png_ptr->sub_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB; - } - - if ((png_ptr->do_filter & PNG_FILTER_UP) && png_ptr->up_row == NULL) - { - if (png_ptr->prev_row == NULL) - { - png_warning(png_ptr, "Can't add Up filter after starting"); - png_ptr->do_filter &= ~PNG_FILTER_UP; - } - else - { - png_ptr->up_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->up_row[0] = PNG_FILTER_VALUE_UP; - } - } - - if ((png_ptr->do_filter & PNG_FILTER_AVG) && png_ptr->avg_row == NULL) - { - if (png_ptr->prev_row == NULL) - { - png_warning(png_ptr, "Can't add Average filter after starting"); - png_ptr->do_filter &= ~PNG_FILTER_AVG; - } - else - { - png_ptr->avg_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG; - } - } - - if ((png_ptr->do_filter & PNG_FILTER_PAETH) && - png_ptr->paeth_row == NULL) - { - if (png_ptr->prev_row == NULL) - { - png_warning(png_ptr, "Can't add Paeth filter after starting"); - png_ptr->do_filter &= (png_byte)(~PNG_FILTER_PAETH); - } - else - { - png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH; - } - } - - if (png_ptr->do_filter == PNG_NO_FILTERS) - png_ptr->do_filter = PNG_FILTER_NONE; - } - } - else - png_error(png_ptr, "Unknown custom filter method"); -} - -/* This allows us to influence the way in which libpng chooses the "best" - * filter for the current scanline. While the "minimum-sum-of-absolute- - * differences metric is relatively fast and effective, there is some - * question as to whether it can be improved upon by trying to keep the - * filtered data going to zlib more consistent, hopefully resulting in - * better compression. - */ -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* GRR 970116 */ -void PNGAPI -png_set_filter_heuristics(png_structp png_ptr, int heuristic_method, - int num_weights, png_doublep filter_weights, - png_doublep filter_costs) -{ - int i; - - png_debug(1, "in png_set_filter_heuristics\n"); - if (png_ptr == NULL) - return; - if (heuristic_method >= PNG_FILTER_HEURISTIC_LAST) - { - png_warning(png_ptr, "Unknown filter heuristic method"); - return; - } - - if (heuristic_method == PNG_FILTER_HEURISTIC_DEFAULT) - { - heuristic_method = PNG_FILTER_HEURISTIC_UNWEIGHTED; - } - - if (num_weights < 0 || filter_weights == NULL || - heuristic_method == PNG_FILTER_HEURISTIC_UNWEIGHTED) - { - num_weights = 0; - } - - png_ptr->num_prev_filters = (png_byte)num_weights; - png_ptr->heuristic_method = (png_byte)heuristic_method; - - if (num_weights > 0) - { - if (png_ptr->prev_filters == NULL) - { - png_ptr->prev_filters = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(png_sizeof(png_byte) * num_weights)); - - /* To make sure that the weighting starts out fairly */ - for (i = 0; i < num_weights; i++) - { - png_ptr->prev_filters[i] = 255; - } - } - - if (png_ptr->filter_weights == NULL) - { - png_ptr->filter_weights = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(png_sizeof(png_uint_16) * num_weights)); - - png_ptr->inv_filter_weights = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(png_sizeof(png_uint_16) * num_weights)); - for (i = 0; i < num_weights; i++) - { - png_ptr->inv_filter_weights[i] = - png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR; - } - } - - for (i = 0; i < num_weights; i++) - { - if (filter_weights[i] < 0.0) - { - png_ptr->inv_filter_weights[i] = - png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR; - } - else - { - png_ptr->inv_filter_weights[i] = - (png_uint_16)((double)PNG_WEIGHT_FACTOR*filter_weights[i]+0.5); - png_ptr->filter_weights[i] = - (png_uint_16)((double)PNG_WEIGHT_FACTOR/filter_weights[i]+0.5); - } - } - } - - /* If, in the future, there are other filter methods, this would - * need to be based on png_ptr->filter. - */ - if (png_ptr->filter_costs == NULL) - { - png_ptr->filter_costs = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(png_sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST)); - - png_ptr->inv_filter_costs = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(png_sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST)); - - for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) - { - png_ptr->inv_filter_costs[i] = - png_ptr->filter_costs[i] = PNG_COST_FACTOR; - } - } - - /* Here is where we set the relative costs of the different filters. We - * should take the desired compression level into account when setting - * the costs, so that Paeth, for instance, has a high relative cost at low - * compression levels, while it has a lower relative cost at higher - * compression settings. The filter types are in order of increasing - * relative cost, so it would be possible to do this with an algorithm. - */ - for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) - { - if (filter_costs == NULL || filter_costs[i] < 0.0) - { - png_ptr->inv_filter_costs[i] = - png_ptr->filter_costs[i] = PNG_COST_FACTOR; - } - else if (filter_costs[i] >= 1.0) - { - png_ptr->inv_filter_costs[i] = - (png_uint_16)((double)PNG_COST_FACTOR / filter_costs[i] + 0.5); - png_ptr->filter_costs[i] = - (png_uint_16)((double)PNG_COST_FACTOR * filter_costs[i] + 0.5); - } - } -} -#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */ - -void PNGAPI -png_set_compression_level(png_structp png_ptr, int level) -{ - png_debug(1, "in png_set_compression_level\n"); - if (png_ptr == NULL) - return; - png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_LEVEL; - png_ptr->zlib_level = level; -} - -void PNGAPI -png_set_compression_mem_level(png_structp png_ptr, int mem_level) -{ - png_debug(1, "in png_set_compression_mem_level\n"); - if (png_ptr == NULL) - return; - png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL; - png_ptr->zlib_mem_level = mem_level; -} - -void PNGAPI -png_set_compression_strategy(png_structp png_ptr, int strategy) -{ - png_debug(1, "in png_set_compression_strategy\n"); - if (png_ptr == NULL) - return; - png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_STRATEGY; - png_ptr->zlib_strategy = strategy; -} - -void PNGAPI -png_set_compression_window_bits(png_structp png_ptr, int window_bits) -{ - if (png_ptr == NULL) - return; - if (window_bits > 15) - png_warning(png_ptr, "Only compression windows <= 32k supported by PNG"); - else if (window_bits < 8) - png_warning(png_ptr, "Only compression windows >= 256 supported by PNG"); -#ifndef WBITS_8_OK - /* avoid libpng bug with 256-byte windows */ - if (window_bits == 8) - { - png_warning(png_ptr, "Compression window is being reset to 512"); - window_bits=9; - } -#endif - png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS; - png_ptr->zlib_window_bits = window_bits; -} - -void PNGAPI -png_set_compression_method(png_structp png_ptr, int method) -{ - png_debug(1, "in png_set_compression_method\n"); - if (png_ptr == NULL) - return; - if (method != 8) - png_warning(png_ptr, "Only compression method 8 is supported by PNG"); - png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_METHOD; - png_ptr->zlib_method = method; -} - -void PNGAPI -png_set_write_status_fn(png_structp png_ptr, png_write_status_ptr write_row_fn) -{ - if (png_ptr == NULL) - return; - png_ptr->write_row_fn = write_row_fn; -} - -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) -void PNGAPI -png_set_write_user_transform_fn(png_structp png_ptr, png_user_transform_ptr - write_user_transform_fn) -{ - png_debug(1, "in png_set_write_user_transform_fn\n"); - if (png_ptr == NULL) - return; - png_ptr->transformations |= PNG_USER_TRANSFORM; - png_ptr->write_user_transform_fn = write_user_transform_fn; -} -#endif - - -#if defined(PNG_INFO_IMAGE_SUPPORTED) -void PNGAPI -png_write_png(png_structp png_ptr, png_infop info_ptr, - int transforms, voidp params) -{ - if (png_ptr == NULL || info_ptr == NULL) - return; -#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) - /* invert the alpha channel from opacity to transparency */ - if (transforms & PNG_TRANSFORM_INVERT_ALPHA) - png_set_invert_alpha(png_ptr); -#endif - - /* Write the file header information. */ - png_write_info(png_ptr, info_ptr); - - /* ------ these transformations don't touch the info structure ------- */ - -#if defined(PNG_WRITE_INVERT_SUPPORTED) - /* invert monochrome pixels */ - if (transforms & PNG_TRANSFORM_INVERT_MONO) - png_set_invert_mono(png_ptr); -#endif - -#if defined(PNG_WRITE_SHIFT_SUPPORTED) - /* Shift the pixels up to a legal bit depth and fill in - * as appropriate to correctly scale the image. - */ - if ((transforms & PNG_TRANSFORM_SHIFT) - && (info_ptr->valid & PNG_INFO_sBIT)) - png_set_shift(png_ptr, &info_ptr->sig_bit); -#endif - -#if defined(PNG_WRITE_PACK_SUPPORTED) - /* pack pixels into bytes */ - if (transforms & PNG_TRANSFORM_PACKING) - png_set_packing(png_ptr); -#endif - -#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) - /* swap location of alpha bytes from ARGB to RGBA */ - if (transforms & PNG_TRANSFORM_SWAP_ALPHA) - png_set_swap_alpha(png_ptr); -#endif - -#if defined(PNG_WRITE_FILLER_SUPPORTED) - /* Get rid of filler (OR ALPHA) bytes, pack XRGB/RGBX/ARGB/RGBA into - * RGB (4 channels -> 3 channels). The second parameter is not used. - */ - if (transforms & PNG_TRANSFORM_STRIP_FILLER) - png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); -#endif - -#if defined(PNG_WRITE_BGR_SUPPORTED) - /* flip BGR pixels to RGB */ - if (transforms & PNG_TRANSFORM_BGR) - png_set_bgr(png_ptr); -#endif - -#if defined(PNG_WRITE_SWAP_SUPPORTED) - /* swap bytes of 16-bit files to most significant byte first */ - if (transforms & PNG_TRANSFORM_SWAP_ENDIAN) - png_set_swap(png_ptr); -#endif - -#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) - /* swap bits of 1, 2, 4 bit packed pixel formats */ - if (transforms & PNG_TRANSFORM_PACKSWAP) - png_set_packswap(png_ptr); -#endif - - /* ----------------------- end of transformations ------------------- */ - - /* write the bits */ - if (info_ptr->valid & PNG_INFO_IDAT) - png_write_image(png_ptr, info_ptr->row_pointers); - - /* It is REQUIRED to call this to finish writing the rest of the file */ - png_write_end(png_ptr, info_ptr); - - if(transforms == 0 || params == NULL) - /* quiet compiler warnings */ return; -} -#endif -#endif /* PNG_WRITE_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng_osx/pngwtran.c b/irrlicht-1.6/source/Irrlicht/libpng_osx/pngwtran.c deleted file mode 100644 index 0372fe656..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng_osx/pngwtran.c +++ /dev/null @@ -1,572 +0,0 @@ - -/* pngwtran.c - transforms the data in a row for PNG writers - * - * Last changed in libpng 1.2.9 April 14, 2006 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2006 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -#define PNG_INTERNAL -#include "png.h" -#ifdef PNG_WRITE_SUPPORTED - -/* Transform the data according to the user's wishes. The order of - * transformations is significant. - */ -void /* PRIVATE */ -png_do_write_transformations(png_structp png_ptr) -{ - png_debug(1, "in png_do_write_transformations\n"); - - if (png_ptr == NULL) - return; - -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) - if (png_ptr->transformations & PNG_USER_TRANSFORM) - if(png_ptr->write_user_transform_fn != NULL) - (*(png_ptr->write_user_transform_fn)) /* user write transform function */ - (png_ptr, /* png_ptr */ - &(png_ptr->row_info), /* row_info: */ - /* png_uint_32 width; width of row */ - /* png_uint_32 rowbytes; number of bytes in row */ - /* png_byte color_type; color type of pixels */ - /* png_byte bit_depth; bit depth of samples */ - /* png_byte channels; number of channels (1-4) */ - /* png_byte pixel_depth; bits per pixel (depth*channels) */ - png_ptr->row_buf + 1); /* start of pixel data for row */ -#endif -#if defined(PNG_WRITE_FILLER_SUPPORTED) - if (png_ptr->transformations & PNG_FILLER) - png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, - png_ptr->flags); -#endif -#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif -#if defined(PNG_WRITE_PACK_SUPPORTED) - if (png_ptr->transformations & PNG_PACK) - png_do_pack(&(png_ptr->row_info), png_ptr->row_buf + 1, - (png_uint_32)png_ptr->bit_depth); -#endif -#if defined(PNG_WRITE_SWAP_SUPPORTED) - if (png_ptr->transformations & PNG_SWAP_BYTES) - png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif -#if defined(PNG_WRITE_SHIFT_SUPPORTED) - if (png_ptr->transformations & PNG_SHIFT) - png_do_shift(&(png_ptr->row_info), png_ptr->row_buf + 1, - &(png_ptr->shift)); -#endif -#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) - if (png_ptr->transformations & PNG_SWAP_ALPHA) - png_do_write_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif -#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_ALPHA) - png_do_write_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif -#if defined(PNG_WRITE_BGR_SUPPORTED) - if (png_ptr->transformations & PNG_BGR) - png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif -#if defined(PNG_WRITE_INVERT_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_MONO) - png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif -} - -#if defined(PNG_WRITE_PACK_SUPPORTED) -/* Pack pixels into bytes. Pass the true bit depth in bit_depth. The - * row_info bit depth should be 8 (one pixel per byte). The channels - * should be 1 (this only happens on grayscale and paletted images). - */ -void /* PRIVATE */ -png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) -{ - png_debug(1, "in png_do_pack\n"); - if (row_info->bit_depth == 8 && -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - row_info->channels == 1) - { - switch ((int)bit_depth) - { - case 1: - { - png_bytep sp, dp; - int mask, v; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - sp = row; - dp = row; - mask = 0x80; - v = 0; - - for (i = 0; i < row_width; i++) - { - if (*sp != 0) - v |= mask; - sp++; - if (mask > 1) - mask >>= 1; - else - { - mask = 0x80; - *dp = (png_byte)v; - dp++; - v = 0; - } - } - if (mask != 0x80) - *dp = (png_byte)v; - break; - } - case 2: - { - png_bytep sp, dp; - int shift, v; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - sp = row; - dp = row; - shift = 6; - v = 0; - for (i = 0; i < row_width; i++) - { - png_byte value; - - value = (png_byte)(*sp & 0x03); - v |= (value << shift); - if (shift == 0) - { - shift = 6; - *dp = (png_byte)v; - dp++; - v = 0; - } - else - shift -= 2; - sp++; - } - if (shift != 6) - *dp = (png_byte)v; - break; - } - case 4: - { - png_bytep sp, dp; - int shift, v; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - sp = row; - dp = row; - shift = 4; - v = 0; - for (i = 0; i < row_width; i++) - { - png_byte value; - - value = (png_byte)(*sp & 0x0f); - v |= (value << shift); - - if (shift == 0) - { - shift = 4; - *dp = (png_byte)v; - dp++; - v = 0; - } - else - shift -= 4; - - sp++; - } - if (shift != 4) - *dp = (png_byte)v; - break; - } - } - row_info->bit_depth = (png_byte)bit_depth; - row_info->pixel_depth = (png_byte)(bit_depth * row_info->channels); - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, - row_info->width); - } -} -#endif - -#if defined(PNG_WRITE_SHIFT_SUPPORTED) -/* Shift pixel values to take advantage of whole range. Pass the - * true number of bits in bit_depth. The row should be packed - * according to row_info->bit_depth. Thus, if you had a row of - * bit depth 4, but the pixels only had values from 0 to 7, you - * would pass 3 as bit_depth, and this routine would translate the - * data to 0 to 15. - */ -void /* PRIVATE */ -png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth) -{ - png_debug(1, "in png_do_shift\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL && -#else - if ( -#endif - row_info->color_type != PNG_COLOR_TYPE_PALETTE) - { - int shift_start[4], shift_dec[4]; - int channels = 0; - - if (row_info->color_type & PNG_COLOR_MASK_COLOR) - { - shift_start[channels] = row_info->bit_depth - bit_depth->red; - shift_dec[channels] = bit_depth->red; - channels++; - shift_start[channels] = row_info->bit_depth - bit_depth->green; - shift_dec[channels] = bit_depth->green; - channels++; - shift_start[channels] = row_info->bit_depth - bit_depth->blue; - shift_dec[channels] = bit_depth->blue; - channels++; - } - else - { - shift_start[channels] = row_info->bit_depth - bit_depth->gray; - shift_dec[channels] = bit_depth->gray; - channels++; - } - if (row_info->color_type & PNG_COLOR_MASK_ALPHA) - { - shift_start[channels] = row_info->bit_depth - bit_depth->alpha; - shift_dec[channels] = bit_depth->alpha; - channels++; - } - - /* with low row depths, could only be grayscale, so one channel */ - if (row_info->bit_depth < 8) - { - png_bytep bp = row; - png_uint_32 i; - png_byte mask; - png_uint_32 row_bytes = row_info->rowbytes; - - if (bit_depth->gray == 1 && row_info->bit_depth == 2) - mask = 0x55; - else if (row_info->bit_depth == 4 && bit_depth->gray == 3) - mask = 0x11; - else - mask = 0xff; - - for (i = 0; i < row_bytes; i++, bp++) - { - png_uint_16 v; - int j; - - v = *bp; - *bp = 0; - for (j = shift_start[0]; j > -shift_dec[0]; j -= shift_dec[0]) - { - if (j > 0) - *bp |= (png_byte)((v << j) & 0xff); - else - *bp |= (png_byte)((v >> (-j)) & mask); - } - } - } - else if (row_info->bit_depth == 8) - { - png_bytep bp = row; - png_uint_32 i; - png_uint_32 istop = channels * row_info->width; - - for (i = 0; i < istop; i++, bp++) - { - - png_uint_16 v; - int j; - int c = (int)(i%channels); - - v = *bp; - *bp = 0; - for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c]) - { - if (j > 0) - *bp |= (png_byte)((v << j) & 0xff); - else - *bp |= (png_byte)((v >> (-j)) & 0xff); - } - } - } - else - { - png_bytep bp; - png_uint_32 i; - png_uint_32 istop = channels * row_info->width; - - for (bp = row, i = 0; i < istop; i++) - { - int c = (int)(i%channels); - png_uint_16 value, v; - int j; - - v = (png_uint_16)(((png_uint_16)(*bp) << 8) + *(bp + 1)); - value = 0; - for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c]) - { - if (j > 0) - value |= (png_uint_16)((v << j) & (png_uint_16)0xffff); - else - value |= (png_uint_16)((v >> (-j)) & (png_uint_16)0xffff); - } - *bp++ = (png_byte)(value >> 8); - *bp++ = (png_byte)(value & 0xff); - } - } - } -} -#endif - -#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) -void /* PRIVATE */ -png_do_write_swap_alpha(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_write_swap_alpha\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif - { - if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - /* This converts from ARGB to RGBA */ - if (row_info->bit_depth == 8) - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - for (i = 0, sp = dp = row; i < row_width; i++) - { - png_byte save = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = save; - } - } - /* This converts from AARRGGBB to RRGGBBAA */ - else - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - png_byte save[2]; - save[0] = *(sp++); - save[1] = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = save[0]; - *(dp++) = save[1]; - } - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - { - /* This converts from AG to GA */ - if (row_info->bit_depth == 8) - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - png_byte save = *(sp++); - *(dp++) = *(sp++); - *(dp++) = save; - } - } - /* This converts from AAGG to GGAA */ - else - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - png_byte save[2]; - save[0] = *(sp++); - save[1] = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = save[0]; - *(dp++) = save[1]; - } - } - } - } -} -#endif - -#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) -void /* PRIVATE */ -png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_write_invert_alpha\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif - { - if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - /* This inverts the alpha channel in RGBA */ - if (row_info->bit_depth == 8) - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - for (i = 0, sp = dp = row; i < row_width; i++) - { - /* does nothing - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - */ - sp+=3; dp = sp; - *(dp++) = (png_byte)(255 - *(sp++)); - } - } - /* This inverts the alpha channel in RRGGBBAA */ - else - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - /* does nothing - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - */ - sp+=6; dp = sp; - *(dp++) = (png_byte)(255 - *(sp++)); - *(dp++) = (png_byte)(255 - *(sp++)); - } - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - { - /* This inverts the alpha channel in GA */ - if (row_info->bit_depth == 8) - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - *(dp++) = *(sp++); - *(dp++) = (png_byte)(255 - *(sp++)); - } - } - /* This inverts the alpha channel in GGAA */ - else - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - /* does nothing - *(dp++) = *(sp++); - *(dp++) = *(sp++); - */ - sp+=2; dp = sp; - *(dp++) = (png_byte)(255 - *(sp++)); - *(dp++) = (png_byte)(255 - *(sp++)); - } - } - } - } -} -#endif - -#if defined(PNG_MNG_FEATURES_SUPPORTED) -/* undoes intrapixel differencing */ -void /* PRIVATE */ -png_do_write_intrapixel(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_write_intrapixel\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - (row_info->color_type & PNG_COLOR_MASK_COLOR)) - { - int bytes_per_pixel; - png_uint_32 row_width = row_info->width; - if (row_info->bit_depth == 8) - { - png_bytep rp; - png_uint_32 i; - - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - bytes_per_pixel = 3; - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - bytes_per_pixel = 4; - else - return; - - for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) - { - *(rp) = (png_byte)((*rp - *(rp+1))&0xff); - *(rp+2) = (png_byte)((*(rp+2) - *(rp+1))&0xff); - } - } - else if (row_info->bit_depth == 16) - { - png_bytep rp; - png_uint_32 i; - - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - bytes_per_pixel = 6; - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - bytes_per_pixel = 8; - else - return; - - for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) - { - png_uint_32 s0 = (*(rp ) << 8) | *(rp+1); - png_uint_32 s1 = (*(rp+2) << 8) | *(rp+3); - png_uint_32 s2 = (*(rp+4) << 8) | *(rp+5); - png_uint_32 red = (png_uint_32)((s0-s1) & 0xffffL); - png_uint_32 blue = (png_uint_32)((s2-s1) & 0xffffL); - *(rp ) = (png_byte)((red >> 8) & 0xff); - *(rp+1) = (png_byte)(red & 0xff); - *(rp+4) = (png_byte)((blue >> 8) & 0xff); - *(rp+5) = (png_byte)(blue & 0xff); - } - } - } -} -#endif /* PNG_MNG_FEATURES_SUPPORTED */ -#endif /* PNG_WRITE_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/libpng_osx/pngwutil.c b/irrlicht-1.6/source/Irrlicht/libpng_osx/pngwutil.c deleted file mode 100644 index e108c6106..000000000 --- a/irrlicht-1.6/source/Irrlicht/libpng_osx/pngwutil.c +++ /dev/null @@ -1,2777 +0,0 @@ - -/* pngwutil.c - utilities to write a PNG file - * - * Last changed in libpng 1.2.15 January 5, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -#define PNG_INTERNAL -#include "png.h" -#ifdef PNG_WRITE_SUPPORTED - -/* Place a 32-bit number into a buffer in PNG byte order. We work - * with unsigned numbers for convenience, although one supported - * ancillary chunk uses signed (two's complement) numbers. - */ -void PNGAPI -png_save_uint_32(png_bytep buf, png_uint_32 i) -{ - buf[0] = (png_byte)((i >> 24) & 0xff); - buf[1] = (png_byte)((i >> 16) & 0xff); - buf[2] = (png_byte)((i >> 8) & 0xff); - buf[3] = (png_byte)(i & 0xff); -} - -/* The png_save_int_32 function assumes integers are stored in two's - * complement format. If this isn't the case, then this routine needs to - * be modified to write data in two's complement format. - */ -void PNGAPI -png_save_int_32(png_bytep buf, png_int_32 i) -{ - buf[0] = (png_byte)((i >> 24) & 0xff); - buf[1] = (png_byte)((i >> 16) & 0xff); - buf[2] = (png_byte)((i >> 8) & 0xff); - buf[3] = (png_byte)(i & 0xff); -} - -/* Place a 16-bit number into a buffer in PNG byte order. - * The parameter is declared unsigned int, not png_uint_16, - * just to avoid potential problems on pre-ANSI C compilers. - */ -void PNGAPI -png_save_uint_16(png_bytep buf, unsigned int i) -{ - buf[0] = (png_byte)((i >> 8) & 0xff); - buf[1] = (png_byte)(i & 0xff); -} - -/* Write a PNG chunk all at once. The type is an array of ASCII characters - * representing the chunk name. The array must be at least 4 bytes in - * length, and does not need to be null terminated. To be safe, pass the - * pre-defined chunk names here, and if you need a new one, define it - * where the others are defined. The length is the length of the data. - * All the data must be present. If that is not possible, use the - * png_write_chunk_start(), png_write_chunk_data(), and png_write_chunk_end() - * functions instead. - */ -void PNGAPI -png_write_chunk(png_structp png_ptr, png_bytep chunk_name, - png_bytep data, png_size_t length) -{ - if(png_ptr == NULL) return; - png_write_chunk_start(png_ptr, chunk_name, (png_uint_32)length); - png_write_chunk_data(png_ptr, data, length); - png_write_chunk_end(png_ptr); -} - -/* Write the start of a PNG chunk. The type is the chunk type. - * The total_length is the sum of the lengths of all the data you will be - * passing in png_write_chunk_data(). - */ -void PNGAPI -png_write_chunk_start(png_structp png_ptr, png_bytep chunk_name, - png_uint_32 length) -{ - png_byte buf[4]; - png_debug2(0, "Writing %s chunk (%lu bytes)\n", chunk_name, length); - if(png_ptr == NULL) return; - - /* write the length */ - png_save_uint_32(buf, length); - png_write_data(png_ptr, buf, (png_size_t)4); - - /* write the chunk name */ - png_write_data(png_ptr, chunk_name, (png_size_t)4); - /* reset the crc and run it over the chunk name */ - png_reset_crc(png_ptr); - png_calculate_crc(png_ptr, chunk_name, (png_size_t)4); -} - -/* Write the data of a PNG chunk started with png_write_chunk_start(). - * Note that multiple calls to this function are allowed, and that the - * sum of the lengths from these calls *must* add up to the total_length - * given to png_write_chunk_start(). - */ -void PNGAPI -png_write_chunk_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - /* write the data, and run the CRC over it */ - if(png_ptr == NULL) return; - if (data != NULL && length > 0) - { - png_calculate_crc(png_ptr, data, length); - png_write_data(png_ptr, data, length); - } -} - -/* Finish a chunk started with png_write_chunk_start(). */ -void PNGAPI -png_write_chunk_end(png_structp png_ptr) -{ - png_byte buf[4]; - - if(png_ptr == NULL) return; - - /* write the crc */ - png_save_uint_32(buf, png_ptr->crc); - - png_write_data(png_ptr, buf, (png_size_t)4); -} - -/* Simple function to write the signature. If we have already written - * the magic bytes of the signature, or more likely, the PNG stream is - * being embedded into another stream and doesn't need its own signature, - * we should call png_set_sig_bytes() to tell libpng how many of the - * bytes have already been written. - */ -void /* PRIVATE */ -png_write_sig(png_structp png_ptr) -{ - png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10}; - /* write the rest of the 8 byte signature */ - png_write_data(png_ptr, &png_signature[png_ptr->sig_bytes], - (png_size_t)8 - png_ptr->sig_bytes); - if(png_ptr->sig_bytes < 3) - png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE; -} - -#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_iCCP_SUPPORTED) -/* - * This pair of functions encapsulates the operation of (a) compressing a - * text string, and (b) issuing it later as a series of chunk data writes. - * The compression_state structure is shared context for these functions - * set up by the caller in order to make the whole mess thread-safe. - */ - -typedef struct -{ - char *input; /* the uncompressed input data */ - int input_len; /* its length */ - int num_output_ptr; /* number of output pointers used */ - int max_output_ptr; /* size of output_ptr */ - png_charpp output_ptr; /* array of pointers to output */ -} compression_state; - -/* compress given text into storage in the png_ptr structure */ -static int /* PRIVATE */ -png_text_compress(png_structp png_ptr, - png_charp text, png_size_t text_len, int compression, - compression_state *comp) -{ - int ret; - - comp->num_output_ptr = 0; - comp->max_output_ptr = 0; - comp->output_ptr = NULL; - comp->input = NULL; - comp->input_len = 0; - - /* we may just want to pass the text right through */ - if (compression == PNG_TEXT_COMPRESSION_NONE) - { - comp->input = text; - comp->input_len = text_len; - return((int)text_len); - } - - if (compression >= PNG_TEXT_COMPRESSION_LAST) - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char msg[50]; - sprintf(msg, "Unknown compression type %d", compression); - png_warning(png_ptr, msg); -#else - png_warning(png_ptr, "Unknown compression type"); -#endif - } - - /* We can't write the chunk until we find out how much data we have, - * which means we need to run the compressor first and save the - * output. This shouldn't be a problem, as the vast majority of - * comments should be reasonable, but we will set up an array of - * malloc'd pointers to be sure. - * - * If we knew the application was well behaved, we could simplify this - * greatly by assuming we can always malloc an output buffer large - * enough to hold the compressed text ((1001 * text_len / 1000) + 12) - * and malloc this directly. The only time this would be a bad idea is - * if we can't malloc more than 64K and we have 64K of random input - * data, or if the input string is incredibly large (although this - * wouldn't cause a failure, just a slowdown due to swapping). - */ - - /* set up the compression buffers */ - png_ptr->zstream.avail_in = (uInt)text_len; - png_ptr->zstream.next_in = (Bytef *)text; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - png_ptr->zstream.next_out = (Bytef *)png_ptr->zbuf; - - /* this is the same compression loop as in png_write_row() */ - do - { - /* compress the data */ - ret = deflate(&png_ptr->zstream, Z_NO_FLUSH); - if (ret != Z_OK) - { - /* error */ - if (png_ptr->zstream.msg != NULL) - png_error(png_ptr, png_ptr->zstream.msg); - else - png_error(png_ptr, "zlib error"); - } - /* check to see if we need more room */ - if (!(png_ptr->zstream.avail_out)) - { - /* make sure the output array has room */ - if (comp->num_output_ptr >= comp->max_output_ptr) - { - int old_max; - - old_max = comp->max_output_ptr; - comp->max_output_ptr = comp->num_output_ptr + 4; - if (comp->output_ptr != NULL) - { - png_charpp old_ptr; - - old_ptr = comp->output_ptr; - comp->output_ptr = (png_charpp)png_malloc(png_ptr, - (png_uint_32)(comp->max_output_ptr * - png_sizeof (png_charpp))); - png_memcpy(comp->output_ptr, old_ptr, old_max - * png_sizeof (png_charp)); - png_free(png_ptr, old_ptr); - } - else - comp->output_ptr = (png_charpp)png_malloc(png_ptr, - (png_uint_32)(comp->max_output_ptr * - png_sizeof (png_charp))); - } - - /* save the data */ - comp->output_ptr[comp->num_output_ptr] = (png_charp)png_malloc(png_ptr, - (png_uint_32)png_ptr->zbuf_size); - png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf, - png_ptr->zbuf_size); - comp->num_output_ptr++; - - /* and reset the buffer */ - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - png_ptr->zstream.next_out = png_ptr->zbuf; - } - /* continue until we don't have any more to compress */ - } while (png_ptr->zstream.avail_in); - - /* finish the compression */ - do - { - /* tell zlib we are finished */ - ret = deflate(&png_ptr->zstream, Z_FINISH); - - if (ret == Z_OK) - { - /* check to see if we need more room */ - if (!(png_ptr->zstream.avail_out)) - { - /* check to make sure our output array has room */ - if (comp->num_output_ptr >= comp->max_output_ptr) - { - int old_max; - - old_max = comp->max_output_ptr; - comp->max_output_ptr = comp->num_output_ptr + 4; - if (comp->output_ptr != NULL) - { - png_charpp old_ptr; - - old_ptr = comp->output_ptr; - /* This could be optimized to realloc() */ - comp->output_ptr = (png_charpp)png_malloc(png_ptr, - (png_uint_32)(comp->max_output_ptr * - png_sizeof (png_charpp))); - png_memcpy(comp->output_ptr, old_ptr, - old_max * png_sizeof (png_charp)); - png_free(png_ptr, old_ptr); - } - else - comp->output_ptr = (png_charpp)png_malloc(png_ptr, - (png_uint_32)(comp->max_output_ptr * - png_sizeof (png_charp))); - } - - /* save off the data */ - comp->output_ptr[comp->num_output_ptr] = - (png_charp)png_malloc(png_ptr, (png_uint_32)png_ptr->zbuf_size); - png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf, - png_ptr->zbuf_size); - comp->num_output_ptr++; - - /* and reset the buffer pointers */ - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - png_ptr->zstream.next_out = png_ptr->zbuf; - } - } - else if (ret != Z_STREAM_END) - { - /* we got an error */ - if (png_ptr->zstream.msg != NULL) - png_error(png_ptr, png_ptr->zstream.msg); - else - png_error(png_ptr, "zlib error"); - } - } while (ret != Z_STREAM_END); - - /* text length is number of buffers plus last buffer */ - text_len = png_ptr->zbuf_size * comp->num_output_ptr; - if (png_ptr->zstream.avail_out < png_ptr->zbuf_size) - text_len += png_ptr->zbuf_size - (png_size_t)png_ptr->zstream.avail_out; - - return((int)text_len); -} - -/* ship the compressed text out via chunk writes */ -static void /* PRIVATE */ -png_write_compressed_data_out(png_structp png_ptr, compression_state *comp) -{ - int i; - - /* handle the no-compression case */ - if (comp->input) - { - png_write_chunk_data(png_ptr, (png_bytep)comp->input, - (png_size_t)comp->input_len); - return; - } - - /* write saved output buffers, if any */ - for (i = 0; i < comp->num_output_ptr; i++) - { - png_write_chunk_data(png_ptr,(png_bytep)comp->output_ptr[i], - png_ptr->zbuf_size); - png_free(png_ptr, comp->output_ptr[i]); - comp->output_ptr[i]=NULL; - } - if (comp->max_output_ptr != 0) - png_free(png_ptr, comp->output_ptr); - comp->output_ptr=NULL; - /* write anything left in zbuf */ - if (png_ptr->zstream.avail_out < (png_uint_32)png_ptr->zbuf_size) - png_write_chunk_data(png_ptr, png_ptr->zbuf, - png_ptr->zbuf_size - png_ptr->zstream.avail_out); - - /* reset zlib for another zTXt/iTXt or image data */ - deflateReset(&png_ptr->zstream); - png_ptr->zstream.data_type = Z_BINARY; -} -#endif - -/* Write the IHDR chunk, and update the png_struct with the necessary - * information. Note that the rest of this code depends upon this - * information being correct. - */ -void /* PRIVATE */ -png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height, - int bit_depth, int color_type, int compression_type, int filter_type, - int interlace_type) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IHDR; -#endif - png_byte buf[13]; /* buffer to store the IHDR info */ - - png_debug(1, "in png_write_IHDR\n"); - /* Check that we have valid input data from the application info */ - switch (color_type) - { - case PNG_COLOR_TYPE_GRAY: - switch (bit_depth) - { - case 1: - case 2: - case 4: - case 8: - case 16: png_ptr->channels = 1; break; - default: png_error(png_ptr,"Invalid bit depth for grayscale image"); - } - break; - case PNG_COLOR_TYPE_RGB: - if (bit_depth != 8 && bit_depth != 16) - png_error(png_ptr, "Invalid bit depth for RGB image"); - png_ptr->channels = 3; - break; - case PNG_COLOR_TYPE_PALETTE: - switch (bit_depth) - { - case 1: - case 2: - case 4: - case 8: png_ptr->channels = 1; break; - default: png_error(png_ptr, "Invalid bit depth for paletted image"); - } - break; - case PNG_COLOR_TYPE_GRAY_ALPHA: - if (bit_depth != 8 && bit_depth != 16) - png_error(png_ptr, "Invalid bit depth for grayscale+alpha image"); - png_ptr->channels = 2; - break; - case PNG_COLOR_TYPE_RGB_ALPHA: - if (bit_depth != 8 && bit_depth != 16) - png_error(png_ptr, "Invalid bit depth for RGBA image"); - png_ptr->channels = 4; - break; - default: - png_error(png_ptr, "Invalid image color type specified"); - } - - if (compression_type != PNG_COMPRESSION_TYPE_BASE) - { - png_warning(png_ptr, "Invalid compression type specified"); - compression_type = PNG_COMPRESSION_TYPE_BASE; - } - - /* Write filter_method 64 (intrapixel differencing) only if - * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and - * 2. Libpng did not write a PNG signature (this filter_method is only - * used in PNG datastreams that are embedded in MNG datastreams) and - * 3. The application called png_permit_mng_features with a mask that - * included PNG_FLAG_MNG_FILTER_64 and - * 4. The filter_method is 64 and - * 5. The color_type is RGB or RGBA - */ - if ( -#if defined(PNG_MNG_FEATURES_SUPPORTED) - !((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) && - (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_RGB_ALPHA) && - (filter_type == PNG_INTRAPIXEL_DIFFERENCING)) && -#endif - filter_type != PNG_FILTER_TYPE_BASE) - { - png_warning(png_ptr, "Invalid filter type specified"); - filter_type = PNG_FILTER_TYPE_BASE; - } - -#ifdef PNG_WRITE_INTERLACING_SUPPORTED - if (interlace_type != PNG_INTERLACE_NONE && - interlace_type != PNG_INTERLACE_ADAM7) - { - png_warning(png_ptr, "Invalid interlace type specified"); - interlace_type = PNG_INTERLACE_ADAM7; - } -#else - interlace_type=PNG_INTERLACE_NONE; -#endif - - /* save off the relevent information */ - png_ptr->bit_depth = (png_byte)bit_depth; - png_ptr->color_type = (png_byte)color_type; - png_ptr->interlaced = (png_byte)interlace_type; -#if defined(PNG_MNG_FEATURES_SUPPORTED) - png_ptr->filter_type = (png_byte)filter_type; -#endif - png_ptr->compression_type = (png_byte)compression_type; - png_ptr->width = width; - png_ptr->height = height; - - png_ptr->pixel_depth = (png_byte)(bit_depth * png_ptr->channels); - png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, width); - /* set the usr info, so any transformations can modify it */ - png_ptr->usr_width = png_ptr->width; - png_ptr->usr_bit_depth = png_ptr->bit_depth; - png_ptr->usr_channels = png_ptr->channels; - - /* pack the header information into the buffer */ - png_save_uint_32(buf, width); - png_save_uint_32(buf + 4, height); - buf[8] = (png_byte)bit_depth; - buf[9] = (png_byte)color_type; - buf[10] = (png_byte)compression_type; - buf[11] = (png_byte)filter_type; - buf[12] = (png_byte)interlace_type; - - /* write the chunk */ - png_write_chunk(png_ptr, (png_bytep)png_IHDR, buf, (png_size_t)13); - - /* initialize zlib with PNG info */ - png_ptr->zstream.zalloc = png_zalloc; - png_ptr->zstream.zfree = png_zfree; - png_ptr->zstream.opaque = (voidpf)png_ptr; - if (!(png_ptr->do_filter)) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE || - png_ptr->bit_depth < 8) - png_ptr->do_filter = PNG_FILTER_NONE; - else - png_ptr->do_filter = PNG_ALL_FILTERS; - } - if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_STRATEGY)) - { - if (png_ptr->do_filter != PNG_FILTER_NONE) - png_ptr->zlib_strategy = Z_FILTERED; - else - png_ptr->zlib_strategy = Z_DEFAULT_STRATEGY; - } - if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_LEVEL)) - png_ptr->zlib_level = Z_DEFAULT_COMPRESSION; - if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL)) - png_ptr->zlib_mem_level = 8; - if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS)) - png_ptr->zlib_window_bits = 15; - if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_METHOD)) - png_ptr->zlib_method = 8; - deflateInit2(&png_ptr->zstream, png_ptr->zlib_level, - png_ptr->zlib_method, png_ptr->zlib_window_bits, - png_ptr->zlib_mem_level, png_ptr->zlib_strategy); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - /* libpng is not interested in zstream.data_type */ - /* set it to a predefined value, to avoid its evaluation inside zlib */ - png_ptr->zstream.data_type = Z_BINARY; - - png_ptr->mode = PNG_HAVE_IHDR; -} - -/* write the palette. We are careful not to trust png_color to be in the - * correct order for PNG, so people can redefine it to any convenient - * structure. - */ -void /* PRIVATE */ -png_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_PLTE; -#endif - png_uint_32 i; - png_colorp pal_ptr; - png_byte buf[3]; - - png_debug(1, "in png_write_PLTE\n"); - if (( -#if defined(PNG_MNG_FEATURES_SUPPORTED) - !(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) && -#endif - num_pal == 0) || num_pal > 256) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - png_error(png_ptr, "Invalid number of colors in palette"); - } - else - { - png_warning(png_ptr, "Invalid number of colors in palette"); - return; - } - } - - if (!(png_ptr->color_type&PNG_COLOR_MASK_COLOR)) - { - png_warning(png_ptr, - "Ignoring request to write a PLTE chunk in grayscale PNG"); - return; - } - - png_ptr->num_palette = (png_uint_16)num_pal; - png_debug1(3, "num_palette = %d\n", png_ptr->num_palette); - - png_write_chunk_start(png_ptr, (png_bytep)png_PLTE, num_pal * 3); -#ifndef PNG_NO_POINTER_INDEXING - for (i = 0, pal_ptr = palette; i < num_pal; i++, pal_ptr++) - { - buf[0] = pal_ptr->red; - buf[1] = pal_ptr->green; - buf[2] = pal_ptr->blue; - png_write_chunk_data(png_ptr, buf, (png_size_t)3); - } -#else - /* This is a little slower but some buggy compilers need to do this instead */ - pal_ptr=palette; - for (i = 0; i < num_pal; i++) - { - buf[0] = pal_ptr[i].red; - buf[1] = pal_ptr[i].green; - buf[2] = pal_ptr[i].blue; - png_write_chunk_data(png_ptr, buf, (png_size_t)3); - } -#endif - png_write_chunk_end(png_ptr); - png_ptr->mode |= PNG_HAVE_PLTE; -} - -/* write an IDAT chunk */ -void /* PRIVATE */ -png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IDAT; -#endif - png_debug(1, "in png_write_IDAT\n"); - - /* Optimize the CMF field in the zlib stream. */ - /* This hack of the zlib stream is compliant to the stream specification. */ - if (!(png_ptr->mode & PNG_HAVE_IDAT) && - png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE) - { - unsigned int z_cmf = data[0]; /* zlib compression method and flags */ - if ((z_cmf & 0x0f) == 8 && (z_cmf & 0xf0) <= 0x70) - { - /* Avoid memory underflows and multiplication overflows. */ - /* The conditions below are practically always satisfied; - however, they still must be checked. */ - if (length >= 2 && - png_ptr->height < 16384 && png_ptr->width < 16384) - { - png_uint_32 uncompressed_idat_size = png_ptr->height * - ((png_ptr->width * - png_ptr->channels * png_ptr->bit_depth + 15) >> 3); - unsigned int z_cinfo = z_cmf >> 4; - unsigned int half_z_window_size = 1 << (z_cinfo + 7); - while (uncompressed_idat_size <= half_z_window_size && - half_z_window_size >= 256) - { - z_cinfo--; - half_z_window_size >>= 1; - } - z_cmf = (z_cmf & 0x0f) | (z_cinfo << 4); - if (data[0] != (png_byte)z_cmf) - { - data[0] = (png_byte)z_cmf; - data[1] &= 0xe0; - data[1] += (png_byte)(0x1f - ((z_cmf << 8) + data[1]) % 0x1f); - } - } - } - else - png_error(png_ptr, - "Invalid zlib compression method or flags in IDAT"); - } - - png_write_chunk(png_ptr, (png_bytep)png_IDAT, data, length); - png_ptr->mode |= PNG_HAVE_IDAT; -} - -/* write an IEND chunk */ -void /* PRIVATE */ -png_write_IEND(png_structp png_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IEND; -#endif - png_debug(1, "in png_write_IEND\n"); - png_write_chunk(png_ptr, (png_bytep)png_IEND, png_bytep_NULL, - (png_size_t)0); - png_ptr->mode |= PNG_HAVE_IEND; -} - -#if defined(PNG_WRITE_gAMA_SUPPORTED) -/* write a gAMA chunk */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -void /* PRIVATE */ -png_write_gAMA(png_structp png_ptr, double file_gamma) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_gAMA; -#endif - png_uint_32 igamma; - png_byte buf[4]; - - png_debug(1, "in png_write_gAMA\n"); - /* file_gamma is saved in 1/100,000ths */ - igamma = (png_uint_32)(file_gamma * 100000.0 + 0.5); - png_save_uint_32(buf, igamma); - png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4); -} -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -void /* PRIVATE */ -png_write_gAMA_fixed(png_structp png_ptr, png_fixed_point file_gamma) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_gAMA; -#endif - png_byte buf[4]; - - png_debug(1, "in png_write_gAMA\n"); - /* file_gamma is saved in 1/100,000ths */ - png_save_uint_32(buf, (png_uint_32)file_gamma); - png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4); -} -#endif -#endif - -#if defined(PNG_WRITE_sRGB_SUPPORTED) -/* write a sRGB chunk */ -void /* PRIVATE */ -png_write_sRGB(png_structp png_ptr, int srgb_intent) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_sRGB; -#endif - png_byte buf[1]; - - png_debug(1, "in png_write_sRGB\n"); - if(srgb_intent >= PNG_sRGB_INTENT_LAST) - png_warning(png_ptr, - "Invalid sRGB rendering intent specified"); - buf[0]=(png_byte)srgb_intent; - png_write_chunk(png_ptr, (png_bytep)png_sRGB, buf, (png_size_t)1); -} -#endif - -#if defined(PNG_WRITE_iCCP_SUPPORTED) -/* write an iCCP chunk */ -void /* PRIVATE */ -png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type, - png_charp profile, int profile_len) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_iCCP; -#endif - png_size_t name_len; - png_charp new_name; - compression_state comp; - int embedded_profile_len = 0; - - png_debug(1, "in png_write_iCCP\n"); - - comp.num_output_ptr = 0; - comp.max_output_ptr = 0; - comp.output_ptr = NULL; - comp.input = NULL; - comp.input_len = 0; - - if (name == NULL || (name_len = png_check_keyword(png_ptr, name, - &new_name)) == 0) - { - png_warning(png_ptr, "Empty keyword in iCCP chunk"); - return; - } - - if (compression_type != PNG_COMPRESSION_TYPE_BASE) - png_warning(png_ptr, "Unknown compression type in iCCP chunk"); - - if (profile == NULL) - profile_len = 0; - - if (profile_len > 3) - embedded_profile_len = - ((*( (png_bytep)profile ))<<24) | - ((*( (png_bytep)profile+1))<<16) | - ((*( (png_bytep)profile+2))<< 8) | - ((*( (png_bytep)profile+3)) ); - - if (profile_len < embedded_profile_len) - { - png_warning(png_ptr, - "Embedded profile length too large in iCCP chunk"); - return; - } - - if (profile_len > embedded_profile_len) - { - png_warning(png_ptr, - "Truncating profile to actual length in iCCP chunk"); - profile_len = embedded_profile_len; - } - - if (profile_len) - profile_len = png_text_compress(png_ptr, profile, (png_size_t)profile_len, - PNG_COMPRESSION_TYPE_BASE, &comp); - - /* make sure we include the NULL after the name and the compression type */ - png_write_chunk_start(png_ptr, (png_bytep)png_iCCP, - (png_uint_32)name_len+profile_len+2); - new_name[name_len+1]=0x00; - png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 2); - - if (profile_len) - png_write_compressed_data_out(png_ptr, &comp); - - png_write_chunk_end(png_ptr); - png_free(png_ptr, new_name); -} -#endif - -#if defined(PNG_WRITE_sPLT_SUPPORTED) -/* write a sPLT chunk */ -void /* PRIVATE */ -png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_sPLT; -#endif - png_size_t name_len; - png_charp new_name; - png_byte entrybuf[10]; - int entry_size = (spalette->depth == 8 ? 6 : 10); - int palette_size = entry_size * spalette->nentries; - png_sPLT_entryp ep; -#ifdef PNG_NO_POINTER_INDEXING - int i; -#endif - - png_debug(1, "in png_write_sPLT\n"); - if (spalette->name == NULL || (name_len = png_check_keyword(png_ptr, - spalette->name, &new_name))==0) - { - png_warning(png_ptr, "Empty keyword in sPLT chunk"); - return; - } - - /* make sure we include the NULL after the name */ - png_write_chunk_start(png_ptr, (png_bytep)png_sPLT, - (png_uint_32)(name_len + 2 + palette_size)); - png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 1); - png_write_chunk_data(png_ptr, (png_bytep)&spalette->depth, 1); - - /* loop through each palette entry, writing appropriately */ -#ifndef PNG_NO_POINTER_INDEXING - for (ep = spalette->entries; ep<spalette->entries+spalette->nentries; ep++) - { - if (spalette->depth == 8) - { - entrybuf[0] = (png_byte)ep->red; - entrybuf[1] = (png_byte)ep->green; - entrybuf[2] = (png_byte)ep->blue; - entrybuf[3] = (png_byte)ep->alpha; - png_save_uint_16(entrybuf + 4, ep->frequency); - } - else - { - png_save_uint_16(entrybuf + 0, ep->red); - png_save_uint_16(entrybuf + 2, ep->green); - png_save_uint_16(entrybuf + 4, ep->blue); - png_save_uint_16(entrybuf + 6, ep->alpha); - png_save_uint_16(entrybuf + 8, ep->frequency); - } - png_write_chunk_data(png_ptr, entrybuf, (png_size_t)entry_size); - } -#else - ep=spalette->entries; - for (i=0; i>spalette->nentries; i++) - { - if (spalette->depth == 8) - { - entrybuf[0] = (png_byte)ep[i].red; - entrybuf[1] = (png_byte)ep[i].green; - entrybuf[2] = (png_byte)ep[i].blue; - entrybuf[3] = (png_byte)ep[i].alpha; - png_save_uint_16(entrybuf + 4, ep[i].frequency); - } - else - { - png_save_uint_16(entrybuf + 0, ep[i].red); - png_save_uint_16(entrybuf + 2, ep[i].green); - png_save_uint_16(entrybuf + 4, ep[i].blue); - png_save_uint_16(entrybuf + 6, ep[i].alpha); - png_save_uint_16(entrybuf + 8, ep[i].frequency); - } - png_write_chunk_data(png_ptr, entrybuf, entry_size); - } -#endif - - png_write_chunk_end(png_ptr); - png_free(png_ptr, new_name); -} -#endif - -#if defined(PNG_WRITE_sBIT_SUPPORTED) -/* write the sBIT chunk */ -void /* PRIVATE */ -png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_sBIT; -#endif - png_byte buf[4]; - png_size_t size; - - png_debug(1, "in png_write_sBIT\n"); - /* make sure we don't depend upon the order of PNG_COLOR_8 */ - if (color_type & PNG_COLOR_MASK_COLOR) - { - png_byte maxbits; - - maxbits = (png_byte)(color_type==PNG_COLOR_TYPE_PALETTE ? 8 : - png_ptr->usr_bit_depth); - if (sbit->red == 0 || sbit->red > maxbits || - sbit->green == 0 || sbit->green > maxbits || - sbit->blue == 0 || sbit->blue > maxbits) - { - png_warning(png_ptr, "Invalid sBIT depth specified"); - return; - } - buf[0] = sbit->red; - buf[1] = sbit->green; - buf[2] = sbit->blue; - size = 3; - } - else - { - if (sbit->gray == 0 || sbit->gray > png_ptr->usr_bit_depth) - { - png_warning(png_ptr, "Invalid sBIT depth specified"); - return; - } - buf[0] = sbit->gray; - size = 1; - } - - if (color_type & PNG_COLOR_MASK_ALPHA) - { - if (sbit->alpha == 0 || sbit->alpha > png_ptr->usr_bit_depth) - { - png_warning(png_ptr, "Invalid sBIT depth specified"); - return; - } - buf[size++] = sbit->alpha; - } - - png_write_chunk(png_ptr, (png_bytep)png_sBIT, buf, size); -} -#endif - -#if defined(PNG_WRITE_cHRM_SUPPORTED) -/* write the cHRM chunk */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -void /* PRIVATE */ -png_write_cHRM(png_structp png_ptr, double white_x, double white_y, - double red_x, double red_y, double green_x, double green_y, - double blue_x, double blue_y) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_cHRM; -#endif - png_byte buf[32]; - png_uint_32 itemp; - - png_debug(1, "in png_write_cHRM\n"); - /* each value is saved in 1/100,000ths */ - if (white_x < 0 || white_x > 0.8 || white_y < 0 || white_y > 0.8 || - white_x + white_y > 1.0) - { - png_warning(png_ptr, "Invalid cHRM white point specified"); -#if !defined(PNG_NO_CONSOLE_IO) - fprintf(stderr,"white_x=%f, white_y=%f\n",white_x, white_y); -#endif - return; - } - itemp = (png_uint_32)(white_x * 100000.0 + 0.5); - png_save_uint_32(buf, itemp); - itemp = (png_uint_32)(white_y * 100000.0 + 0.5); - png_save_uint_32(buf + 4, itemp); - - if (red_x < 0 || red_y < 0 || red_x + red_y > 1.0) - { - png_warning(png_ptr, "Invalid cHRM red point specified"); - return; - } - itemp = (png_uint_32)(red_x * 100000.0 + 0.5); - png_save_uint_32(buf + 8, itemp); - itemp = (png_uint_32)(red_y * 100000.0 + 0.5); - png_save_uint_32(buf + 12, itemp); - - if (green_x < 0 || green_y < 0 || green_x + green_y > 1.0) - { - png_warning(png_ptr, "Invalid cHRM green point specified"); - return; - } - itemp = (png_uint_32)(green_x * 100000.0 + 0.5); - png_save_uint_32(buf + 16, itemp); - itemp = (png_uint_32)(green_y * 100000.0 + 0.5); - png_save_uint_32(buf + 20, itemp); - - if (blue_x < 0 || blue_y < 0 || blue_x + blue_y > 1.0) - { - png_warning(png_ptr, "Invalid cHRM blue point specified"); - return; - } - itemp = (png_uint_32)(blue_x * 100000.0 + 0.5); - png_save_uint_32(buf + 24, itemp); - itemp = (png_uint_32)(blue_y * 100000.0 + 0.5); - png_save_uint_32(buf + 28, itemp); - - png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32); -} -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -void /* PRIVATE */ -png_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x, - png_fixed_point white_y, png_fixed_point red_x, png_fixed_point red_y, - png_fixed_point green_x, png_fixed_point green_y, png_fixed_point blue_x, - png_fixed_point blue_y) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_cHRM; -#endif - png_byte buf[32]; - - png_debug(1, "in png_write_cHRM\n"); - /* each value is saved in 1/100,000ths */ - if (white_x > 80000L || white_y > 80000L || white_x + white_y > 100000L) - { - png_warning(png_ptr, "Invalid fixed cHRM white point specified"); -#if !defined(PNG_NO_CONSOLE_IO) - fprintf(stderr,"white_x=%ld, white_y=%ld\n",white_x, white_y); -#endif - return; - } - png_save_uint_32(buf, (png_uint_32)white_x); - png_save_uint_32(buf + 4, (png_uint_32)white_y); - - if (red_x + red_y > 100000L) - { - png_warning(png_ptr, "Invalid cHRM fixed red point specified"); - return; - } - png_save_uint_32(buf + 8, (png_uint_32)red_x); - png_save_uint_32(buf + 12, (png_uint_32)red_y); - - if (green_x + green_y > 100000L) - { - png_warning(png_ptr, "Invalid fixed cHRM green point specified"); - return; - } - png_save_uint_32(buf + 16, (png_uint_32)green_x); - png_save_uint_32(buf + 20, (png_uint_32)green_y); - - if (blue_x + blue_y > 100000L) - { - png_warning(png_ptr, "Invalid fixed cHRM blue point specified"); - return; - } - png_save_uint_32(buf + 24, (png_uint_32)blue_x); - png_save_uint_32(buf + 28, (png_uint_32)blue_y); - - png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32); -} -#endif -#endif - -#if defined(PNG_WRITE_tRNS_SUPPORTED) -/* write the tRNS chunk */ -void /* PRIVATE */ -png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran, - int num_trans, int color_type) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_tRNS; -#endif - png_byte buf[6]; - - png_debug(1, "in png_write_tRNS\n"); - if (color_type == PNG_COLOR_TYPE_PALETTE) - { - if (num_trans <= 0 || num_trans > (int)png_ptr->num_palette) - { - png_warning(png_ptr,"Invalid number of transparent colors specified"); - return; - } - /* write the chunk out as it is */ - png_write_chunk(png_ptr, (png_bytep)png_tRNS, trans, (png_size_t)num_trans); - } - else if (color_type == PNG_COLOR_TYPE_GRAY) - { - /* one 16 bit value */ - if(tran->gray >= (1 << png_ptr->bit_depth)) - { - png_warning(png_ptr, - "Ignoring attempt to write tRNS chunk out-of-range for bit_depth"); - return; - } - png_save_uint_16(buf, tran->gray); - png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)2); - } - else if (color_type == PNG_COLOR_TYPE_RGB) - { - /* three 16 bit values */ - png_save_uint_16(buf, tran->red); - png_save_uint_16(buf + 2, tran->green); - png_save_uint_16(buf + 4, tran->blue); - if(png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4])) - { - png_warning(png_ptr, - "Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8"); - return; - } - png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)6); - } - else - { - png_warning(png_ptr, "Can't write tRNS with an alpha channel"); - } -} -#endif - -#if defined(PNG_WRITE_bKGD_SUPPORTED) -/* write the background chunk */ -void /* PRIVATE */ -png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_bKGD; -#endif - png_byte buf[6]; - - png_debug(1, "in png_write_bKGD\n"); - if (color_type == PNG_COLOR_TYPE_PALETTE) - { - if ( -#if defined(PNG_MNG_FEATURES_SUPPORTED) - (png_ptr->num_palette || - (!(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE))) && -#endif - back->index > png_ptr->num_palette) - { - png_warning(png_ptr, "Invalid background palette index"); - return; - } - buf[0] = back->index; - png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)1); - } - else if (color_type & PNG_COLOR_MASK_COLOR) - { - png_save_uint_16(buf, back->red); - png_save_uint_16(buf + 2, back->green); - png_save_uint_16(buf + 4, back->blue); - if(png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4])) - { - png_warning(png_ptr, - "Ignoring attempt to write 16-bit bKGD chunk when bit_depth is 8"); - return; - } - png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)6); - } - else - { - if(back->gray >= (1 << png_ptr->bit_depth)) - { - png_warning(png_ptr, - "Ignoring attempt to write bKGD chunk out-of-range for bit_depth"); - return; - } - png_save_uint_16(buf, back->gray); - png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)2); - } -} -#endif - -#if defined(PNG_WRITE_hIST_SUPPORTED) -/* write the histogram */ -void /* PRIVATE */ -png_write_hIST(png_structp png_ptr, png_uint_16p hist, int num_hist) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_hIST; -#endif - int i; - png_byte buf[3]; - - png_debug(1, "in png_write_hIST\n"); - if (num_hist > (int)png_ptr->num_palette) - { - png_debug2(3, "num_hist = %d, num_palette = %d\n", num_hist, - png_ptr->num_palette); - png_warning(png_ptr, "Invalid number of histogram entries specified"); - return; - } - - png_write_chunk_start(png_ptr, (png_bytep)png_hIST, (png_uint_32)(num_hist * 2)); - for (i = 0; i < num_hist; i++) - { - png_save_uint_16(buf, hist[i]); - png_write_chunk_data(png_ptr, buf, (png_size_t)2); - } - png_write_chunk_end(png_ptr); -} -#endif - -#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \ - defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) -/* Check that the tEXt or zTXt keyword is valid per PNG 1.0 specification, - * and if invalid, correct the keyword rather than discarding the entire - * chunk. The PNG 1.0 specification requires keywords 1-79 characters in - * length, forbids leading or trailing whitespace, multiple internal spaces, - * and the non-break space (0x80) from ISO 8859-1. Returns keyword length. - * - * The new_key is allocated to hold the corrected keyword and must be freed - * by the calling routine. This avoids problems with trying to write to - * static keywords without having to have duplicate copies of the strings. - */ -png_size_t /* PRIVATE */ -png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key) -{ - png_size_t key_len; - png_charp kp, dp; - int kflag; - int kwarn=0; - - png_debug(1, "in png_check_keyword\n"); - *new_key = NULL; - - if (key == NULL || (key_len = png_strlen(key)) == 0) - { - png_warning(png_ptr, "zero length keyword"); - return ((png_size_t)0); - } - - png_debug1(2, "Keyword to be checked is '%s'\n", key); - - *new_key = (png_charp)png_malloc_warn(png_ptr, (png_uint_32)(key_len + 2)); - if (*new_key == NULL) - { - png_warning(png_ptr, "Out of memory while procesing keyword"); - return ((png_size_t)0); - } - - /* Replace non-printing characters with a blank and print a warning */ - for (kp = key, dp = *new_key; *kp != '\0'; kp++, dp++) - { - if (*kp < 0x20 || (*kp > 0x7E && (png_byte)*kp < 0xA1)) - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char msg[40]; - - sprintf(msg, "invalid keyword character 0x%02X", *kp); - png_warning(png_ptr, msg); -#else - png_warning(png_ptr, "invalid character in keyword"); -#endif - *dp = ' '; - } - else - { - *dp = *kp; - } - } - *dp = '\0'; - - /* Remove any trailing white space. */ - kp = *new_key + key_len - 1; - if (*kp == ' ') - { - png_warning(png_ptr, "trailing spaces removed from keyword"); - - while (*kp == ' ') - { - *(kp--) = '\0'; - key_len--; - } - } - - /* Remove any leading white space. */ - kp = *new_key; - if (*kp == ' ') - { - png_warning(png_ptr, "leading spaces removed from keyword"); - - while (*kp == ' ') - { - kp++; - key_len--; - } - } - - png_debug1(2, "Checking for multiple internal spaces in '%s'\n", kp); - - /* Remove multiple internal spaces. */ - for (kflag = 0, dp = *new_key; *kp != '\0'; kp++) - { - if (*kp == ' ' && kflag == 0) - { - *(dp++) = *kp; - kflag = 1; - } - else if (*kp == ' ') - { - key_len--; - kwarn=1; - } - else - { - *(dp++) = *kp; - kflag = 0; - } - } - *dp = '\0'; - if(kwarn) - png_warning(png_ptr, "extra interior spaces removed from keyword"); - - if (key_len == 0) - { - png_free(png_ptr, *new_key); - *new_key=NULL; - png_warning(png_ptr, "Zero length keyword"); - } - - if (key_len > 79) - { - png_warning(png_ptr, "keyword length must be 1 - 79 characters"); - new_key[79] = '\0'; - key_len = 79; - } - - return (key_len); -} -#endif - -#if defined(PNG_WRITE_tEXt_SUPPORTED) -/* write a tEXt chunk */ -void /* PRIVATE */ -png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text, - png_size_t text_len) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_tEXt; -#endif - png_size_t key_len; - png_charp new_key; - - png_debug(1, "in png_write_tEXt\n"); - if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0) - { - png_warning(png_ptr, "Empty keyword in tEXt chunk"); - return; - } - - if (text == NULL || *text == '\0') - text_len = 0; - else - text_len = png_strlen(text); - - /* make sure we include the 0 after the key */ - png_write_chunk_start(png_ptr, (png_bytep)png_tEXt, (png_uint_32)key_len+text_len+1); - /* - * We leave it to the application to meet PNG-1.0 requirements on the - * contents of the text. PNG-1.0 through PNG-1.2 discourage the use of - * any non-Latin-1 characters except for NEWLINE. ISO PNG will forbid them. - * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG. - */ - png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1); - if (text_len) - png_write_chunk_data(png_ptr, (png_bytep)text, text_len); - - png_write_chunk_end(png_ptr); - png_free(png_ptr, new_key); -} -#endif - -#if defined(PNG_WRITE_zTXt_SUPPORTED) -/* write a compressed text chunk */ -void /* PRIVATE */ -png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text, - png_size_t text_len, int compression) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_zTXt; -#endif - png_size_t key_len; - char buf[1]; - png_charp new_key; - compression_state comp; - - png_debug(1, "in png_write_zTXt\n"); - - comp.num_output_ptr = 0; - comp.max_output_ptr = 0; - comp.output_ptr = NULL; - comp.input = NULL; - comp.input_len = 0; - - if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0) - { - png_warning(png_ptr, "Empty keyword in zTXt chunk"); - return; - } - - if (text == NULL || *text == '\0' || compression==PNG_TEXT_COMPRESSION_NONE) - { - png_write_tEXt(png_ptr, new_key, text, (png_size_t)0); - png_free(png_ptr, new_key); - return; - } - - text_len = png_strlen(text); - - png_free(png_ptr, new_key); - - /* compute the compressed data; do it now for the length */ - text_len = png_text_compress(png_ptr, text, text_len, compression, - &comp); - - /* write start of chunk */ - png_write_chunk_start(png_ptr, (png_bytep)png_zTXt, (png_uint_32) - (key_len+text_len+2)); - /* write key */ - png_write_chunk_data(png_ptr, (png_bytep)key, key_len + 1); - buf[0] = (png_byte)compression; - /* write compression */ - png_write_chunk_data(png_ptr, (png_bytep)buf, (png_size_t)1); - /* write the compressed data */ - png_write_compressed_data_out(png_ptr, &comp); - - /* close the chunk */ - png_write_chunk_end(png_ptr); -} -#endif - -#if defined(PNG_WRITE_iTXt_SUPPORTED) -/* write an iTXt chunk */ -void /* PRIVATE */ -png_write_iTXt(png_structp png_ptr, int compression, png_charp key, - png_charp lang, png_charp lang_key, png_charp text) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_iTXt; -#endif - png_size_t lang_len, key_len, lang_key_len, text_len; - png_charp new_lang, new_key; - png_byte cbuf[2]; - compression_state comp; - - png_debug(1, "in png_write_iTXt\n"); - - comp.num_output_ptr = 0; - comp.max_output_ptr = 0; - comp.output_ptr = NULL; - comp.input = NULL; - - if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0) - { - png_warning(png_ptr, "Empty keyword in iTXt chunk"); - return; - } - if (lang == NULL || (lang_len = png_check_keyword(png_ptr, lang, &new_lang))==0) - { - png_warning(png_ptr, "Empty language field in iTXt chunk"); - new_lang = NULL; - lang_len = 0; - } - - if (lang_key == NULL) - lang_key_len = 0; - else - lang_key_len = png_strlen(lang_key); - - if (text == NULL) - text_len = 0; - else - text_len = png_strlen(text); - - /* compute the compressed data; do it now for the length */ - text_len = png_text_compress(png_ptr, text, text_len, compression-2, - &comp); - - - /* make sure we include the compression flag, the compression byte, - * and the NULs after the key, lang, and lang_key parts */ - - png_write_chunk_start(png_ptr, (png_bytep)png_iTXt, - (png_uint_32)( - 5 /* comp byte, comp flag, terminators for key, lang and lang_key */ - + key_len - + lang_len - + lang_key_len - + text_len)); - - /* - * We leave it to the application to meet PNG-1.0 requirements on the - * contents of the text. PNG-1.0 through PNG-1.2 discourage the use of - * any non-Latin-1 characters except for NEWLINE. ISO PNG will forbid them. - * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG. - */ - png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1); - - /* set the compression flag */ - if (compression == PNG_ITXT_COMPRESSION_NONE || \ - compression == PNG_TEXT_COMPRESSION_NONE) - cbuf[0] = 0; - else /* compression == PNG_ITXT_COMPRESSION_zTXt */ - cbuf[0] = 1; - /* set the compression method */ - cbuf[1] = 0; - png_write_chunk_data(png_ptr, cbuf, 2); - - cbuf[0] = 0; - png_write_chunk_data(png_ptr, (new_lang ? (png_bytep)new_lang : cbuf), lang_len + 1); - png_write_chunk_data(png_ptr, (lang_key ? (png_bytep)lang_key : cbuf), lang_key_len + 1); - png_write_compressed_data_out(png_ptr, &comp); - - png_write_chunk_end(png_ptr); - png_free(png_ptr, new_key); - if (new_lang) - png_free(png_ptr, new_lang); -} -#endif - -#if defined(PNG_WRITE_oFFs_SUPPORTED) -/* write the oFFs chunk */ -void /* PRIVATE */ -png_write_oFFs(png_structp png_ptr, png_int_32 x_offset, png_int_32 y_offset, - int unit_type) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_oFFs; -#endif - png_byte buf[9]; - - png_debug(1, "in png_write_oFFs\n"); - if (unit_type >= PNG_OFFSET_LAST) - png_warning(png_ptr, "Unrecognized unit type for oFFs chunk"); - - png_save_int_32(buf, x_offset); - png_save_int_32(buf + 4, y_offset); - buf[8] = (png_byte)unit_type; - - png_write_chunk(png_ptr, (png_bytep)png_oFFs, buf, (png_size_t)9); -} -#endif - -#if defined(PNG_WRITE_pCAL_SUPPORTED) -/* write the pCAL chunk (described in the PNG extensions document) */ -void /* PRIVATE */ -png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0, - png_int_32 X1, int type, int nparams, png_charp units, png_charpp params) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_pCAL; -#endif - png_size_t purpose_len, units_len, total_len; - png_uint_32p params_len; - png_byte buf[10]; - png_charp new_purpose; - int i; - - png_debug1(1, "in png_write_pCAL (%d parameters)\n", nparams); - if (type >= PNG_EQUATION_LAST) - png_warning(png_ptr, "Unrecognized equation type for pCAL chunk"); - - purpose_len = png_check_keyword(png_ptr, purpose, &new_purpose) + 1; - png_debug1(3, "pCAL purpose length = %d\n", (int)purpose_len); - units_len = png_strlen(units) + (nparams == 0 ? 0 : 1); - png_debug1(3, "pCAL units length = %d\n", (int)units_len); - total_len = purpose_len + units_len + 10; - - params_len = (png_uint_32p)png_malloc(png_ptr, (png_uint_32)(nparams - *png_sizeof(png_uint_32))); - - /* Find the length of each parameter, making sure we don't count the - null terminator for the last parameter. */ - for (i = 0; i < nparams; i++) - { - params_len[i] = png_strlen(params[i]) + (i == nparams - 1 ? 0 : 1); - png_debug2(3, "pCAL parameter %d length = %lu\n", i, params_len[i]); - total_len += (png_size_t)params_len[i]; - } - - png_debug1(3, "pCAL total length = %d\n", (int)total_len); - png_write_chunk_start(png_ptr, (png_bytep)png_pCAL, (png_uint_32)total_len); - png_write_chunk_data(png_ptr, (png_bytep)new_purpose, purpose_len); - png_save_int_32(buf, X0); - png_save_int_32(buf + 4, X1); - buf[8] = (png_byte)type; - buf[9] = (png_byte)nparams; - png_write_chunk_data(png_ptr, buf, (png_size_t)10); - png_write_chunk_data(png_ptr, (png_bytep)units, (png_size_t)units_len); - - png_free(png_ptr, new_purpose); - - for (i = 0; i < nparams; i++) - { - png_write_chunk_data(png_ptr, (png_bytep)params[i], - (png_size_t)params_len[i]); - } - - png_free(png_ptr, params_len); - png_write_chunk_end(png_ptr); -} -#endif - -#if defined(PNG_WRITE_sCAL_SUPPORTED) -/* write the sCAL chunk */ -#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) -void /* PRIVATE */ -png_write_sCAL(png_structp png_ptr, int unit, double width, double height) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_sCAL; -#endif - char buf[64]; - png_size_t total_len; - - png_debug(1, "in png_write_sCAL\n"); - - buf[0] = (char)unit; -#if defined(_WIN32_WCE) -/* sprintf() function is not supported on WindowsCE */ - { - wchar_t wc_buf[32]; - size_t wc_len; - swprintf(wc_buf, TEXT("%12.12e"), width); - wc_len = wcslen(wc_buf); - WideCharToMultiByte(CP_ACP, 0, wc_buf, -1, buf + 1, wc_len, NULL, NULL); - total_len = wc_len + 2; - swprintf(wc_buf, TEXT("%12.12e"), height); - wc_len = wcslen(wc_buf); - WideCharToMultiByte(CP_ACP, 0, wc_buf, -1, buf + total_len, wc_len, - NULL, NULL); - total_len += wc_len; - } -#else - sprintf(buf + 1, "%12.12e", width); - total_len = 1 + png_strlen(buf + 1) + 1; - sprintf(buf + total_len, "%12.12e", height); - total_len += png_strlen(buf + total_len); -#endif - - png_debug1(3, "sCAL total length = %u\n", (unsigned int)total_len); - png_write_chunk(png_ptr, (png_bytep)png_sCAL, (png_bytep)buf, total_len); -} -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -void /* PRIVATE */ -png_write_sCAL_s(png_structp png_ptr, int unit, png_charp width, - png_charp height) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_sCAL; -#endif - png_byte buf[64]; - png_size_t wlen, hlen, total_len; - - png_debug(1, "in png_write_sCAL_s\n"); - - wlen = png_strlen(width); - hlen = png_strlen(height); - total_len = wlen + hlen + 2; - if (total_len > 64) - { - png_warning(png_ptr, "Can't write sCAL (buffer too small)"); - return; - } - - buf[0] = (png_byte)unit; - png_memcpy(buf + 1, width, wlen + 1); /* append the '\0' here */ - png_memcpy(buf + wlen + 2, height, hlen); /* do NOT append the '\0' here */ - - png_debug1(3, "sCAL total length = %u\n", (unsigned int)total_len); - png_write_chunk(png_ptr, (png_bytep)png_sCAL, buf, total_len); -} -#endif -#endif -#endif - -#if defined(PNG_WRITE_pHYs_SUPPORTED) -/* write the pHYs chunk */ -void /* PRIVATE */ -png_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit, - png_uint_32 y_pixels_per_unit, - int unit_type) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_pHYs; -#endif - png_byte buf[9]; - - png_debug(1, "in png_write_pHYs\n"); - if (unit_type >= PNG_RESOLUTION_LAST) - png_warning(png_ptr, "Unrecognized unit type for pHYs chunk"); - - png_save_uint_32(buf, x_pixels_per_unit); - png_save_uint_32(buf + 4, y_pixels_per_unit); - buf[8] = (png_byte)unit_type; - - png_write_chunk(png_ptr, (png_bytep)png_pHYs, buf, (png_size_t)9); -} -#endif - -#if defined(PNG_WRITE_tIME_SUPPORTED) -/* Write the tIME chunk. Use either png_convert_from_struct_tm() - * or png_convert_from_time_t(), or fill in the structure yourself. - */ -void /* PRIVATE */ -png_write_tIME(png_structp png_ptr, png_timep mod_time) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_tIME; -#endif - png_byte buf[7]; - - png_debug(1, "in png_write_tIME\n"); - if (mod_time->month > 12 || mod_time->month < 1 || - mod_time->day > 31 || mod_time->day < 1 || - mod_time->hour > 23 || mod_time->second > 60) - { - png_warning(png_ptr, "Invalid time specified for tIME chunk"); - return; - } - - png_save_uint_16(buf, mod_time->year); - buf[2] = mod_time->month; - buf[3] = mod_time->day; - buf[4] = mod_time->hour; - buf[5] = mod_time->minute; - buf[6] = mod_time->second; - - png_write_chunk(png_ptr, (png_bytep)png_tIME, buf, (png_size_t)7); -} -#endif - -/* initializes the row writing capability of libpng */ -void /* PRIVATE */ -png_write_start_row(png_structp png_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* start of interlace block */ - int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - - /* offset to next interlace block */ - int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - - /* start of interlace block in the y direction */ - int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - - /* offset to next interlace block in the y direction */ - int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; -#endif - - png_size_t buf_size; - - png_debug(1, "in png_write_start_row\n"); - buf_size = (png_size_t)(PNG_ROWBYTES( - png_ptr->usr_channels*png_ptr->usr_bit_depth,png_ptr->width)+1); - - /* set up row buffer */ - png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, (png_uint_32)buf_size); - png_ptr->row_buf[0] = PNG_FILTER_VALUE_NONE; - - /* set up filtering buffer, if using this filter */ - if (png_ptr->do_filter & PNG_FILTER_SUB) - { - png_ptr->sub_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB; - } - - /* We only need to keep the previous row if we are using one of these. */ - if (png_ptr->do_filter & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH)) - { - /* set up previous row buffer */ - png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)buf_size); - png_memset(png_ptr->prev_row, 0, buf_size); - - if (png_ptr->do_filter & PNG_FILTER_UP) - { - png_ptr->up_row = (png_bytep )png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->up_row[0] = PNG_FILTER_VALUE_UP; - } - - if (png_ptr->do_filter & PNG_FILTER_AVG) - { - png_ptr->avg_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG; - } - - if (png_ptr->do_filter & PNG_FILTER_PAETH) - { - png_ptr->paeth_row = (png_bytep )png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH; - } - } - -#ifdef PNG_WRITE_INTERLACING_SUPPORTED - /* if interlaced, we need to set up width and height of pass */ - if (png_ptr->interlaced) - { - if (!(png_ptr->transformations & PNG_INTERLACE)) - { - png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 - - png_pass_ystart[0]) / png_pass_yinc[0]; - png_ptr->usr_width = (png_ptr->width + png_pass_inc[0] - 1 - - png_pass_start[0]) / png_pass_inc[0]; - } - else - { - png_ptr->num_rows = png_ptr->height; - png_ptr->usr_width = png_ptr->width; - } - } - else -#endif - { - png_ptr->num_rows = png_ptr->height; - png_ptr->usr_width = png_ptr->width; - } - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - png_ptr->zstream.next_out = png_ptr->zbuf; -} - -/* Internal use only. Called when finished processing a row of data. */ -void /* PRIVATE */ -png_write_finish_row(png_structp png_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* start of interlace block */ - int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - - /* offset to next interlace block */ - int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - - /* start of interlace block in the y direction */ - int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - - /* offset to next interlace block in the y direction */ - int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; -#endif - - int ret; - - png_debug(1, "in png_write_finish_row\n"); - /* next row */ - png_ptr->row_number++; - - /* see if we are done */ - if (png_ptr->row_number < png_ptr->num_rows) - return; - -#ifdef PNG_WRITE_INTERLACING_SUPPORTED - /* if interlaced, go to next pass */ - if (png_ptr->interlaced) - { - png_ptr->row_number = 0; - if (png_ptr->transformations & PNG_INTERLACE) - { - png_ptr->pass++; - } - else - { - /* loop until we find a non-zero width or height pass */ - do - { - png_ptr->pass++; - if (png_ptr->pass >= 7) - break; - png_ptr->usr_width = (png_ptr->width + - png_pass_inc[png_ptr->pass] - 1 - - png_pass_start[png_ptr->pass]) / - png_pass_inc[png_ptr->pass]; - png_ptr->num_rows = (png_ptr->height + - png_pass_yinc[png_ptr->pass] - 1 - - png_pass_ystart[png_ptr->pass]) / - png_pass_yinc[png_ptr->pass]; - if (png_ptr->transformations & PNG_INTERLACE) - break; - } while (png_ptr->usr_width == 0 || png_ptr->num_rows == 0); - - } - - /* reset the row above the image for the next pass */ - if (png_ptr->pass < 7) - { - if (png_ptr->prev_row != NULL) - png_memset(png_ptr->prev_row, 0, - (png_size_t)(PNG_ROWBYTES(png_ptr->usr_channels* - png_ptr->usr_bit_depth,png_ptr->width))+1); - return; - } - } -#endif - - /* if we get here, we've just written the last row, so we need - to flush the compressor */ - do - { - /* tell the compressor we are done */ - ret = deflate(&png_ptr->zstream, Z_FINISH); - /* check for an error */ - if (ret == Z_OK) - { - /* check to see if we need more room */ - if (!(png_ptr->zstream.avail_out)) - { - png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - } - } - else if (ret != Z_STREAM_END) - { - if (png_ptr->zstream.msg != NULL) - png_error(png_ptr, png_ptr->zstream.msg); - else - png_error(png_ptr, "zlib error"); - } - } while (ret != Z_STREAM_END); - - /* write any extra space */ - if (png_ptr->zstream.avail_out < png_ptr->zbuf_size) - { - png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size - - png_ptr->zstream.avail_out); - } - - deflateReset(&png_ptr->zstream); - png_ptr->zstream.data_type = Z_BINARY; -} - -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) -/* Pick out the correct pixels for the interlace pass. - * The basic idea here is to go through the row with a source - * pointer and a destination pointer (sp and dp), and copy the - * correct pixels for the pass. As the row gets compacted, - * sp will always be >= dp, so we should never overwrite anything. - * See the default: case for the easiest code to understand. - */ -void /* PRIVATE */ -png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* start of interlace block */ - int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - - /* offset to next interlace block */ - int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; -#endif - - png_debug(1, "in png_do_write_interlace\n"); - /* we don't have to do anything on the last pass (6) */ -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL && pass < 6) -#else - if (pass < 6) -#endif - { - /* each pixel depth is handled separately */ - switch (row_info->pixel_depth) - { - case 1: - { - png_bytep sp; - png_bytep dp; - int shift; - int d; - int value; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - dp = row; - d = 0; - shift = 7; - for (i = png_pass_start[pass]; i < row_width; - i += png_pass_inc[pass]) - { - sp = row + (png_size_t)(i >> 3); - value = (int)(*sp >> (7 - (int)(i & 0x07))) & 0x01; - d |= (value << shift); - - if (shift == 0) - { - shift = 7; - *dp++ = (png_byte)d; - d = 0; - } - else - shift--; - - } - if (shift != 7) - *dp = (png_byte)d; - break; - } - case 2: - { - png_bytep sp; - png_bytep dp; - int shift; - int d; - int value; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - dp = row; - shift = 6; - d = 0; - for (i = png_pass_start[pass]; i < row_width; - i += png_pass_inc[pass]) - { - sp = row + (png_size_t)(i >> 2); - value = (*sp >> ((3 - (int)(i & 0x03)) << 1)) & 0x03; - d |= (value << shift); - - if (shift == 0) - { - shift = 6; - *dp++ = (png_byte)d; - d = 0; - } - else - shift -= 2; - } - if (shift != 6) - *dp = (png_byte)d; - break; - } - case 4: - { - png_bytep sp; - png_bytep dp; - int shift; - int d; - int value; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - dp = row; - shift = 4; - d = 0; - for (i = png_pass_start[pass]; i < row_width; - i += png_pass_inc[pass]) - { - sp = row + (png_size_t)(i >> 1); - value = (*sp >> ((1 - (int)(i & 0x01)) << 2)) & 0x0f; - d |= (value << shift); - - if (shift == 0) - { - shift = 4; - *dp++ = (png_byte)d; - d = 0; - } - else - shift -= 4; - } - if (shift != 4) - *dp = (png_byte)d; - break; - } - default: - { - png_bytep sp; - png_bytep dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - png_size_t pixel_bytes; - - /* start at the beginning */ - dp = row; - /* find out how many bytes each pixel takes up */ - pixel_bytes = (row_info->pixel_depth >> 3); - /* loop through the row, only looking at the pixels that - matter */ - for (i = png_pass_start[pass]; i < row_width; - i += png_pass_inc[pass]) - { - /* find out where the original pixel is */ - sp = row + (png_size_t)i * pixel_bytes; - /* move the pixel */ - if (dp != sp) - png_memcpy(dp, sp, pixel_bytes); - /* next pixel */ - dp += pixel_bytes; - } - break; - } - } - /* set new row width */ - row_info->width = (row_info->width + - png_pass_inc[pass] - 1 - - png_pass_start[pass]) / - png_pass_inc[pass]; - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, - row_info->width); - } -} -#endif - -/* This filters the row, chooses which filter to use, if it has not already - * been specified by the application, and then writes the row out with the - * chosen filter. - */ -#define PNG_MAXSUM (((png_uint_32)(-1)) >> 1) -#define PNG_HISHIFT 10 -#define PNG_LOMASK ((png_uint_32)0xffffL) -#define PNG_HIMASK ((png_uint_32)(~PNG_LOMASK >> PNG_HISHIFT)) -void /* PRIVATE */ -png_write_find_filter(png_structp png_ptr, png_row_infop row_info) -{ - png_bytep prev_row, best_row, row_buf; - png_uint_32 mins, bpp; - png_byte filter_to_do = png_ptr->do_filter; - png_uint_32 row_bytes = row_info->rowbytes; -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - int num_p_filters = (int)png_ptr->num_prev_filters; -#endif - - png_debug(1, "in png_write_find_filter\n"); - /* find out how many bytes offset each pixel is */ - bpp = (row_info->pixel_depth + 7) >> 3; - - prev_row = png_ptr->prev_row; - best_row = row_buf = png_ptr->row_buf; - mins = PNG_MAXSUM; - - /* The prediction method we use is to find which method provides the - * smallest value when summing the absolute values of the distances - * from zero, using anything >= 128 as negative numbers. This is known - * as the "minimum sum of absolute differences" heuristic. Other - * heuristics are the "weighted minimum sum of absolute differences" - * (experimental and can in theory improve compression), and the "zlib - * predictive" method (not implemented yet), which does test compressions - * of lines using different filter methods, and then chooses the - * (series of) filter(s) that give minimum compressed data size (VERY - * computationally expensive). - * - * GRR 980525: consider also - * (1) minimum sum of absolute differences from running average (i.e., - * keep running sum of non-absolute differences & count of bytes) - * [track dispersion, too? restart average if dispersion too large?] - * (1b) minimum sum of absolute differences from sliding average, probably - * with window size <= deflate window (usually 32K) - * (2) minimum sum of squared differences from zero or running average - * (i.e., ~ root-mean-square approach) - */ - - - /* We don't need to test the 'no filter' case if this is the only filter - * that has been chosen, as it doesn't actually do anything to the data. - */ - if ((filter_to_do & PNG_FILTER_NONE) && - filter_to_do != PNG_FILTER_NONE) - { - png_bytep rp; - png_uint_32 sum = 0; - png_uint_32 i; - int v; - - for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++) - { - v = *rp; - sum += (v < 128) ? v : 256 - v; - } - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - png_uint_32 sumhi, sumlo; - int j; - sumlo = sum & PNG_LOMASK; - sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; /* Gives us some footroom */ - - /* Reduce the sum if we match any of the previous rows */ - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_NONE) - { - sumlo = (sumlo * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - sumhi = (sumhi * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - /* Factor in the cost of this filter (this is here for completeness, - * but it makes no sense to have a "cost" for the NONE filter, as - * it has the minimum possible computational cost - none). - */ - sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_NONE]) >> - PNG_COST_SHIFT; - sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_NONE]) >> - PNG_COST_SHIFT; - - if (sumhi > PNG_HIMASK) - sum = PNG_MAXSUM; - else - sum = (sumhi << PNG_HISHIFT) + sumlo; - } -#endif - mins = sum; - } - - /* sub filter */ - if (filter_to_do == PNG_FILTER_SUB) - /* it's the only filter so no testing is needed */ - { - png_bytep rp, lp, dp; - png_uint_32 i; - for (i = 0, rp = row_buf + 1, dp = png_ptr->sub_row + 1; i < bpp; - i++, rp++, dp++) - { - *dp = *rp; - } - for (lp = row_buf + 1; i < row_bytes; - i++, rp++, lp++, dp++) - { - *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff); - } - best_row = png_ptr->sub_row; - } - - else if (filter_to_do & PNG_FILTER_SUB) - { - png_bytep rp, dp, lp; - png_uint_32 sum = 0, lmins = mins; - png_uint_32 i; - int v; - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - /* We temporarily increase the "minimum sum" by the factor we - * would reduce the sum of this filter, so that we can do the - * early exit comparison without scaling the sum each time. - */ - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 lmhi, lmlo; - lmlo = lmins & PNG_LOMASK; - lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_SUB) - { - lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >> - PNG_COST_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >> - PNG_COST_SHIFT; - - if (lmhi > PNG_HIMASK) - lmins = PNG_MAXSUM; - else - lmins = (lmhi << PNG_HISHIFT) + lmlo; - } -#endif - - for (i = 0, rp = row_buf + 1, dp = png_ptr->sub_row + 1; i < bpp; - i++, rp++, dp++) - { - v = *dp = *rp; - - sum += (v < 128) ? v : 256 - v; - } - for (lp = row_buf + 1; i < row_bytes; - i++, rp++, lp++, dp++) - { - v = *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff); - - sum += (v < 128) ? v : 256 - v; - - if (sum > lmins) /* We are already worse, don't continue. */ - break; - } - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 sumhi, sumlo; - sumlo = sum & PNG_LOMASK; - sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_SUB) - { - sumlo = (sumlo * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - sumhi = (sumhi * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - sumlo = (sumlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >> - PNG_COST_SHIFT; - sumhi = (sumhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >> - PNG_COST_SHIFT; - - if (sumhi > PNG_HIMASK) - sum = PNG_MAXSUM; - else - sum = (sumhi << PNG_HISHIFT) + sumlo; - } -#endif - - if (sum < mins) - { - mins = sum; - best_row = png_ptr->sub_row; - } - } - - /* up filter */ - if (filter_to_do == PNG_FILTER_UP) - { - png_bytep rp, dp, pp; - png_uint_32 i; - - for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1, - pp = prev_row + 1; i < row_bytes; - i++, rp++, pp++, dp++) - { - *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff); - } - best_row = png_ptr->up_row; - } - - else if (filter_to_do & PNG_FILTER_UP) - { - png_bytep rp, dp, pp; - png_uint_32 sum = 0, lmins = mins; - png_uint_32 i; - int v; - - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 lmhi, lmlo; - lmlo = lmins & PNG_LOMASK; - lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_UP) - { - lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_UP]) >> - PNG_COST_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_UP]) >> - PNG_COST_SHIFT; - - if (lmhi > PNG_HIMASK) - lmins = PNG_MAXSUM; - else - lmins = (lmhi << PNG_HISHIFT) + lmlo; - } -#endif - - for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1, - pp = prev_row + 1; i < row_bytes; i++) - { - v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff); - - sum += (v < 128) ? v : 256 - v; - - if (sum > lmins) /* We are already worse, don't continue. */ - break; - } - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 sumhi, sumlo; - sumlo = sum & PNG_LOMASK; - sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_UP) - { - sumlo = (sumlo * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - sumhi = (sumhi * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_UP]) >> - PNG_COST_SHIFT; - sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_UP]) >> - PNG_COST_SHIFT; - - if (sumhi > PNG_HIMASK) - sum = PNG_MAXSUM; - else - sum = (sumhi << PNG_HISHIFT) + sumlo; - } -#endif - - if (sum < mins) - { - mins = sum; - best_row = png_ptr->up_row; - } - } - - /* avg filter */ - if (filter_to_do == PNG_FILTER_AVG) - { - png_bytep rp, dp, pp, lp; - png_uint_32 i; - for (i = 0, rp = row_buf + 1, dp = png_ptr->avg_row + 1, - pp = prev_row + 1; i < bpp; i++) - { - *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff); - } - for (lp = row_buf + 1; i < row_bytes; i++) - { - *dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2)) - & 0xff); - } - best_row = png_ptr->avg_row; - } - - else if (filter_to_do & PNG_FILTER_AVG) - { - png_bytep rp, dp, pp, lp; - png_uint_32 sum = 0, lmins = mins; - png_uint_32 i; - int v; - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 lmhi, lmlo; - lmlo = lmins & PNG_LOMASK; - lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_AVG) - { - lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_AVG]) >> - PNG_COST_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_AVG]) >> - PNG_COST_SHIFT; - - if (lmhi > PNG_HIMASK) - lmins = PNG_MAXSUM; - else - lmins = (lmhi << PNG_HISHIFT) + lmlo; - } -#endif - - for (i = 0, rp = row_buf + 1, dp = png_ptr->avg_row + 1, - pp = prev_row + 1; i < bpp; i++) - { - v = *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff); - - sum += (v < 128) ? v : 256 - v; - } - for (lp = row_buf + 1; i < row_bytes; i++) - { - v = *dp++ = - (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2)) & 0xff); - - sum += (v < 128) ? v : 256 - v; - - if (sum > lmins) /* We are already worse, don't continue. */ - break; - } - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 sumhi, sumlo; - sumlo = sum & PNG_LOMASK; - sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_NONE) - { - sumlo = (sumlo * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - sumhi = (sumhi * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_AVG]) >> - PNG_COST_SHIFT; - sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_AVG]) >> - PNG_COST_SHIFT; - - if (sumhi > PNG_HIMASK) - sum = PNG_MAXSUM; - else - sum = (sumhi << PNG_HISHIFT) + sumlo; - } -#endif - - if (sum < mins) - { - mins = sum; - best_row = png_ptr->avg_row; - } - } - - /* Paeth filter */ - if (filter_to_do == PNG_FILTER_PAETH) - { - png_bytep rp, dp, pp, cp, lp; - png_uint_32 i; - for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1, - pp = prev_row + 1; i < bpp; i++) - { - *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff); - } - - for (lp = row_buf + 1, cp = prev_row + 1; i < row_bytes; i++) - { - int a, b, c, pa, pb, pc, p; - - b = *pp++; - c = *cp++; - a = *lp++; - - p = b - c; - pc = a - c; - -#ifdef PNG_USE_ABS - pa = abs(p); - pb = abs(pc); - pc = abs(p + pc); -#else - pa = p < 0 ? -p : p; - pb = pc < 0 ? -pc : pc; - pc = (p + pc) < 0 ? -(p + pc) : p + pc; -#endif - - p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; - - *dp++ = (png_byte)(((int)*rp++ - p) & 0xff); - } - best_row = png_ptr->paeth_row; - } - - else if (filter_to_do & PNG_FILTER_PAETH) - { - png_bytep rp, dp, pp, cp, lp; - png_uint_32 sum = 0, lmins = mins; - png_uint_32 i; - int v; - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 lmhi, lmlo; - lmlo = lmins & PNG_LOMASK; - lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_PAETH) - { - lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_PAETH]) >> - PNG_COST_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_PAETH]) >> - PNG_COST_SHIFT; - - if (lmhi > PNG_HIMASK) - lmins = PNG_MAXSUM; - else - lmins = (lmhi << PNG_HISHIFT) + lmlo; - } -#endif - - for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1, - pp = prev_row + 1; i < bpp; i++) - { - v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff); - - sum += (v < 128) ? v : 256 - v; - } - - for (lp = row_buf + 1, cp = prev_row + 1; i < row_bytes; i++) - { - int a, b, c, pa, pb, pc, p; - - b = *pp++; - c = *cp++; - a = *lp++; - -#ifndef PNG_SLOW_PAETH - p = b - c; - pc = a - c; -#ifdef PNG_USE_ABS - pa = abs(p); - pb = abs(pc); - pc = abs(p + pc); -#else - pa = p < 0 ? -p : p; - pb = pc < 0 ? -pc : pc; - pc = (p + pc) < 0 ? -(p + pc) : p + pc; -#endif - p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; -#else /* PNG_SLOW_PAETH */ - p = a + b - c; - pa = abs(p - a); - pb = abs(p - b); - pc = abs(p - c); - if (pa <= pb && pa <= pc) - p = a; - else if (pb <= pc) - p = b; - else - p = c; -#endif /* PNG_SLOW_PAETH */ - - v = *dp++ = (png_byte)(((int)*rp++ - p) & 0xff); - - sum += (v < 128) ? v : 256 - v; - - if (sum > lmins) /* We are already worse, don't continue. */ - break; - } - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 sumhi, sumlo; - sumlo = sum & PNG_LOMASK; - sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_PAETH) - { - sumlo = (sumlo * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - sumhi = (sumhi * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_PAETH]) >> - PNG_COST_SHIFT; - sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_PAETH]) >> - PNG_COST_SHIFT; - - if (sumhi > PNG_HIMASK) - sum = PNG_MAXSUM; - else - sum = (sumhi << PNG_HISHIFT) + sumlo; - } -#endif - - if (sum < mins) - { - best_row = png_ptr->paeth_row; - } - } - - /* Do the actual writing of the filtered row data from the chosen filter. */ - - png_write_filtered_row(png_ptr, best_row); - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - /* Save the type of filter we picked this time for future calculations */ - if (png_ptr->num_prev_filters > 0) - { - int j; - for (j = 1; j < num_p_filters; j++) - { - png_ptr->prev_filters[j] = png_ptr->prev_filters[j - 1]; - } - png_ptr->prev_filters[j] = best_row[0]; - } -#endif -} - - -/* Do the actual writing of a previously filtered row. */ -void /* PRIVATE */ -png_write_filtered_row(png_structp png_ptr, png_bytep filtered_row) -{ - png_debug(1, "in png_write_filtered_row\n"); - png_debug1(2, "filter = %d\n", filtered_row[0]); - /* set up the zlib input buffer */ - - png_ptr->zstream.next_in = filtered_row; - png_ptr->zstream.avail_in = (uInt)png_ptr->row_info.rowbytes + 1; - /* repeat until we have compressed all the data */ - do - { - int ret; /* return of zlib */ - - /* compress the data */ - ret = deflate(&png_ptr->zstream, Z_NO_FLUSH); - /* check for compression errors */ - if (ret != Z_OK) - { - if (png_ptr->zstream.msg != NULL) - png_error(png_ptr, png_ptr->zstream.msg); - else - png_error(png_ptr, "zlib error"); - } - - /* see if it is time to write another IDAT */ - if (!(png_ptr->zstream.avail_out)) - { - /* write the IDAT and reset the zlib output buffer */ - png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - } - /* repeat until all data has been compressed */ - } while (png_ptr->zstream.avail_in); - - /* swap the current and previous rows */ - if (png_ptr->prev_row != NULL) - { - png_bytep tptr; - - tptr = png_ptr->prev_row; - png_ptr->prev_row = png_ptr->row_buf; - png_ptr->row_buf = tptr; - } - - /* finish row - updates counters and flushes zlib if last row */ - png_write_finish_row(png_ptr); - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) - png_ptr->flush_rows++; - - if (png_ptr->flush_dist > 0 && - png_ptr->flush_rows >= png_ptr->flush_dist) - { - png_write_flush(png_ptr); - } -#endif -} -#endif /* PNG_WRITE_SUPPORTED */ diff --git a/irrlicht-1.6/source/Irrlicht/os.cpp b/irrlicht-1.6/source/Irrlicht/os.cpp deleted file mode 100644 index 7fdf6fd58..000000000 --- a/irrlicht-1.6/source/Irrlicht/os.cpp +++ /dev/null @@ -1,304 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "os.h" -#include "irrString.h" -#include "IrrCompileConfig.h" -#include "irrMath.h" - -#if defined(_IRR_COMPILE_WITH_SDL_DEVICE_) - #include <SDL/SDL_endian.h> - #define bswap_16(X) SDL_Swap16(X) - #define bswap_32(X) SDL_Swap32(X) -#elif defined(_IRR_WINDOWS_API_) && defined(_MSC_VER) && (_MSC_VER > 1298) - #include <stdlib.h> - #define bswap_16(X) _byteswap_ushort(X) - #define bswap_32(X) _byteswap_ulong(X) -#elif defined(_IRR_OSX_PLATFORM_) - #include <libkern/OSByteOrder.h> - #define bswap_16(X) OSReadSwapInt16(&X,0) - #define bswap_32(X) OSReadSwapInt32(&X,0) -#elif defined(__FreeBSD__) - #include <sys/endian.h> - #define bswap_16(X) bswap16(X) - #define bswap_32(X) bswap32(X) -#elif !defined(_IRR_SOLARIS_PLATFORM_) && !defined(__PPC__) && !defined(_IRR_WINDOWS_API_) - #include <byteswap.h> -#else - #define bswap_16(X) ((((X)&0xFF) << 8) | (((X)&0xFF00) >> 8)) - #define bswap_32(X) ( (((X)&0x000000FF)<<24) | (((X)&0xFF000000) >> 24) | (((X)&0x0000FF00) << 8) | (((X) &0x00FF0000) >> 8)) -#endif - -namespace irr -{ -namespace os -{ - u16 Byteswap::byteswap(u16 num) {return bswap_16(num);} - s16 Byteswap::byteswap(s16 num) {return bswap_16(num);} - u32 Byteswap::byteswap(u32 num) {return bswap_32(num);} - s32 Byteswap::byteswap(s32 num) {return bswap_32(num);} - f32 Byteswap::byteswap(f32 num) {u32 tmp=bswap_32(*((u32*)&num)); return *((f32*)&tmp);} - // prevent accidental byte swapping of chars - u8 Byteswap::byteswap(u8 num) {return num;} - c8 Byteswap::byteswap(c8 num) {return num;} -} -} - -#if defined(_IRR_WINDOWS_API_) -// ---------------------------------------------------------------- -// Windows specific functions -// ---------------------------------------------------------------- - -#ifdef _IRR_XBOX_PLATFORM_ -#include <xtl.h> -#else -#define WIN32_LEAN_AND_MEAN -#include <windows.h> -#endif - -namespace irr -{ -namespace os -{ - //! prints a debuginfo string - void Printer::print(const c8* message) - { -#if defined (_WIN32_WCE ) - core::stringw tmp(message); - tmp += L"\n"; - OutputDebugStringW(tmp.c_str()); -#else - OutputDebugString(message); - OutputDebugString("\n"); - printf("%s\n", message); -#endif - } - - static LARGE_INTEGER HighPerformanceFreq; - static BOOL HighPerformanceTimerSupport = FALSE; - static BOOL MultiCore = FALSE; - - void Timer::initTimer() - { -#if !defined(_WIN32_WCE) && !defined (_IRR_XBOX_PLATFORM_) - // disable hires timer on multiple core systems, bios bugs result in bad hires timers. - SYSTEM_INFO sysinfo; - GetSystemInfo(&sysinfo); - MultiCore = (sysinfo.dwNumberOfProcessors > 1); -#endif - HighPerformanceTimerSupport = QueryPerformanceFrequency(&HighPerformanceFreq); - initVirtualTimer(); - } - - u32 Timer::getRealTime() - { - if (HighPerformanceTimerSupport) - { -#if !defined(_WIN32_WCE) && !defined (_IRR_XBOX_PLATFORM_) - // Avoid potential timing inaccuracies across multiple cores by - // temporarily setting the affinity of this process to one core. - DWORD_PTR affinityMask; - if(MultiCore) - affinityMask = SetThreadAffinityMask(GetCurrentThread(), 1); -#endif - LARGE_INTEGER nTime; - BOOL queriedOK = QueryPerformanceCounter(&nTime); - -#if !defined(_WIN32_WCE) && !defined (_IRR_XBOX_PLATFORM_) - // Restore the true affinity. - if(MultiCore) - (void)SetThreadAffinityMask(GetCurrentThread(), affinityMask); -#endif - if(queriedOK) - return u32((nTime.QuadPart) * 1000 / HighPerformanceFreq.QuadPart); - - } - - return GetTickCount(); - } - -} // end namespace os - - -#else - -// ---------------------------------------------------------------- -// linux/ansi version -// ---------------------------------------------------------------- - -#include <stdio.h> -#include <time.h> -#include <sys/time.h> - -namespace irr -{ -namespace os -{ - - //! prints a debuginfo string - void Printer::print(const c8* message) - { - printf("%s\n", message); - } - - void Timer::initTimer() - { - initVirtualTimer(); - } - - u32 Timer::getRealTime() - { - timeval tv; - gettimeofday(&tv, 0); - return (u32)(tv.tv_sec * 1000) + (tv.tv_usec / 1000); - } - -} // end namespace os - -#endif // end linux / windows - -namespace os -{ - // The platform independent implementation of the printer - ILogger* Printer::Logger = 0; - - void Printer::log(const c8* message, ELOG_LEVEL ll) - { - if (Logger) - Logger->log(message, ll); - } - - void Printer::log(const wchar_t* message, ELOG_LEVEL ll) - { - if (Logger) - Logger->log(message, ll); - } - - void Printer::log(const c8* message, const c8* hint, ELOG_LEVEL ll) - { - if (Logger) - Logger->log(message, hint, ll); - } - - void Printer::log(const c8* message, const io::path& hint, ELOG_LEVEL ll) - { - if (Logger) - Logger->log(message, hint.c_str(), ll); - } - - // our Randomizer is not really os specific, so we - // code one for all, which should work on every platform the same, - // which is desireable. - - s32 Randomizer::seed = 0x0f0f0f0f; - - //! generates a pseudo random number - s32 Randomizer::rand() - { - const s32 m = 2147483399; // a non-Mersenne prime - const s32 a = 40692; // another spectral success story - const s32 q = m/a; - const s32 r = m%a; // again less than q - - seed = a * (seed%q) - r* (seed/q); - if (seed<0) seed += m; - - return seed; - } - - //! resets the randomizer - void Randomizer::reset() - { - seed = 0x0f0f0f0f; - } - - - // ------------------------------------------------------ - // virtual timer implementation - - f32 Timer::VirtualTimerSpeed = 1.0f; - s32 Timer::VirtualTimerStopCounter = 0; - u32 Timer::LastVirtualTime = 0; - u32 Timer::StartRealTime = 0; - u32 Timer::StaticTime = 0; - - //! returns current virtual time - u32 Timer::getTime() - { - if (isStopped()) - return LastVirtualTime; - - return LastVirtualTime + (u32)((StaticTime - StartRealTime) * VirtualTimerSpeed); - } - - //! ticks, advances the virtual timer - void Timer::tick() - { - StaticTime = getRealTime(); - } - - //! sets the current virtual time - void Timer::setTime(u32 time) - { - StaticTime = getRealTime(); - LastVirtualTime = time; - StartRealTime = StaticTime; - } - - //! stops the virtual timer - void Timer::stopTimer() - { - if (!isStopped()) - { - // stop the virtual timer - LastVirtualTime = getTime(); - } - - --VirtualTimerStopCounter; - } - - //! starts the virtual timer - void Timer::startTimer() - { - ++VirtualTimerStopCounter; - - if (!isStopped()) - { - // restart virtual timer - setTime(LastVirtualTime); - } - } - - //! sets the speed of the virtual timer - void Timer::setSpeed(f32 speed) - { - setTime(getTime()); - - VirtualTimerSpeed = speed; - if (VirtualTimerSpeed < 0.0f) - VirtualTimerSpeed = 0.0f; - } - - //! gets the speed of the virtual timer - f32 Timer::getSpeed() - { - return VirtualTimerSpeed; - } - - //! returns if the timer currently is stopped - bool Timer::isStopped() - { - return VirtualTimerStopCounter != 0; - } - - void Timer::initVirtualTimer() - { - StaticTime = getRealTime(); - StartRealTime = StaticTime; - } - -} // end namespace os -} // end namespace irr - - diff --git a/irrlicht-1.6/source/Irrlicht/os.h b/irrlicht-1.6/source/Irrlicht/os.h deleted file mode 100644 index 0bd058807..000000000 --- a/irrlicht-1.6/source/Irrlicht/os.h +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_OS_H_INCLUDED__ -#define __IRR_OS_H_INCLUDED__ - -#include "IrrCompileConfig.h" // for endian check -#include "irrTypes.h" -#include "irrString.h" -#include "path.h" -#include "ILogger.h" - -namespace irr -{ - -namespace os -{ - class Byteswap - { - public: - static u16 byteswap(u16 num); - static s16 byteswap(s16 num); - static u32 byteswap(u32 num); - static s32 byteswap(s32 num); - static f32 byteswap(f32 num); - // prevent accidental swapping of chars - static u8 byteswap(u8 num); - static c8 byteswap(c8 num); - }; - - class Printer - { - public: - // prints out a string to the console out stdout or debug log or whatever - static void print(const c8* message); - static void log(const c8* message, ELOG_LEVEL ll = ELL_INFORMATION); - static void log(const wchar_t* message, ELOG_LEVEL ll = ELL_INFORMATION); - static void log(const c8* message, const c8* hint, ELOG_LEVEL ll = ELL_INFORMATION); - static void log(const c8* message, const io::path& hint, ELOG_LEVEL ll = ELL_INFORMATION); - static ILogger* Logger; - }; - - - class Randomizer - { - public: - - //! resets the randomizer - static void reset(); - - //! generates a pseudo random number - static s32 rand(); - - private: - - static s32 seed; - }; - - - - - class Timer - { - public: - - //! returns the current time in milliseconds - static u32 getTime(); - - //! initializes the real timer - static void initTimer(); - - //! sets the current virtual (game) time - static void setTime(u32 time); - - //! stops the virtual (game) timer - static void stopTimer(); - - //! starts the game timer - static void startTimer(); - - //! sets the speed of the virtual timer - static void setSpeed(f32 speed); - - //! gets the speed of the virtual timer - static f32 getSpeed(); - - //! returns if the timer currently is stopped - static bool isStopped(); - - //! makes the virtual timer update the time value based on the real time - static void tick(); - - //! returns the current real time in milliseconds - static u32 getRealTime(); - - private: - - static void initVirtualTimer(); - - static f32 VirtualTimerSpeed; - static s32 VirtualTimerStopCounter; - static u32 StartRealTime; - static u32 LastVirtualTime; - static u32 StaticTime; - }; - -} // end namespace os -} // end namespace irr - - -#endif - diff --git a/irrlicht-1.6/source/Irrlicht/source.txt b/irrlicht-1.6/source/Irrlicht/source.txt deleted file mode 100644 index f90ea0637..000000000 --- a/irrlicht-1.6/source/Irrlicht/source.txt +++ /dev/null @@ -1,40 +0,0 @@ -Source code of the Irrlicht Engine - -The complete source of the Irrlicht Engine can be found when decompressing -the .zip file included in this directory. -Please note that YOU DO NOT NEED THIS SOURCE to develop 3d applications with -the Irrlicht Engine. Instead, please use the .dll in the \bin directory, the -.lib in the \lib directory and the header files in the \include directory. - -You will find a good tutorial how to set up your development environment and to -use the engine in the \examples directory. (Try 1.helloworld) - -The source of the engine is only included because of the following reasons: - - - To let developers be able to debug the engine. - - To let developers be able to make changes to the engine. - - To let developers be able to compile their own versions of the engine. - - - -HOW TO COMPILE THE ENGINE WITH LINUX - -If you wish to compile the engine in linux yourself, unzip the source source.zip -file in the \source directory. Run a 'make' in the now existing new subfolder 'Irrlicht'. -After this, you should be able to make all example applications in \examples. -Then just start an X Server and run them, from the directory where they are. - -If you get a compiling/linking problem like - - undefined reference to `glXGetProcAddress' - -Then there are several solutions: -A) This disables the use of OpenGL extensions: - Open the file IrrCompileConfig.h, comment out _IRR_OPENGL_USE_EXTPOINTER_, - and recompile Irrlicht using - make clean - make -B) Replace all occurrences of 'glXGetProcAddress' with 'glXGetProcAddressARB' and run a - make - This will solve the issue but keep the OpenGL extension enabled. - diff --git a/irrlicht-1.6/source/Irrlicht/zlib/ChangeLog b/irrlicht-1.6/source/Irrlicht/zlib/ChangeLog deleted file mode 100644 index 1ac946309..000000000 --- a/irrlicht-1.6/source/Irrlicht/zlib/ChangeLog +++ /dev/null @@ -1,855 +0,0 @@ - - ChangeLog file for zlib - -Changes in 1.2.3 (18 July 2005) -- Apply security vulnerability fixes to contrib/infback9 as well -- Clean up some text files (carriage returns, trailing space) -- Update testzlib, vstudio, masmx64, and masmx86 in contrib [Vollant] - -Changes in 1.2.2.4 (11 July 2005) -- Add inflatePrime() function for starting inflation at bit boundary -- Avoid some Visual C warnings in deflate.c -- Avoid more silly Visual C warnings in inflate.c and inftrees.c for 64-bit - compile -- Fix some spelling errors in comments [Betts] -- Correct inflateInit2() error return documentation in zlib.h -- Added zran.c example of compressed data random access to examples - directory, shows use of inflatePrime() -- Fix cast for assignments to strm->state in inflate.c and infback.c -- Fix zlibCompileFlags() in zutil.c to use 1L for long shifts [Oberhumer] -- Move declarations of gf2 functions to right place in crc32.c [Oberhumer] -- Add cast in trees.c t avoid a warning [Oberhumer] -- Avoid some warnings in fitblk.c, gun.c, gzjoin.c in examples [Oberhumer] -- Update make_vms.com [Zinser] -- Initialize state->write in inflateReset() since copied in inflate_fast() -- Be more strict on incomplete code sets in inflate_table() and increase - ENOUGH and MAXD -- this repairs a possible security vulnerability for - invalid inflate input. Thanks to Tavis Ormandy and Markus Oberhumer for - discovering the vulnerability and providing test cases. -- Add ia64 support to configure for HP-UX [Smith] -- Add error return to gzread() for format or i/o error [Levin] -- Use malloc.h for OS/2 [Necasek] - -Changes in 1.2.2.3 (27 May 2005) -- Replace 1U constants in inflate.c and inftrees.c for 64-bit compile -- Typecast fread() return values in gzio.c [Vollant] -- Remove trailing space in minigzip.c outmode (VC++ can't deal with it) -- Fix crc check bug in gzread() after gzungetc() [Heiner] -- Add the deflateTune() function to adjust internal compression parameters -- Add a fast gzip decompressor, gun.c, to examples (use of inflateBack) -- Remove an incorrect assertion in examples/zpipe.c -- Add C++ wrapper in infback9.h [Donais] -- Fix bug in inflateCopy() when decoding fixed codes -- Note in zlib.h how much deflateSetDictionary() actually uses -- Remove USE_DICT_HEAD in deflate.c (would mess up inflate if used) -- Add _WIN32_WCE to define WIN32 in zconf.in.h [Spencer] -- Don't include stderr.h or errno.h for _WIN32_WCE in zutil.h [Spencer] -- Add gzdirect() function to indicate transparent reads -- Update contrib/minizip [Vollant] -- Fix compilation of deflate.c when both ASMV and FASTEST [Oberhumer] -- Add casts in crc32.c to avoid warnings [Oberhumer] -- Add contrib/masmx64 [Vollant] -- Update contrib/asm586, asm686, masmx86, testzlib, vstudio [Vollant] - -Changes in 1.2.2.2 (30 December 2004) -- Replace structure assignments in deflate.c and inflate.c with zmemcpy to - avoid implicit memcpy calls (portability for no-library compilation) -- Increase sprintf() buffer size in gzdopen() to allow for large numbers -- Add INFLATE_STRICT to check distances against zlib header -- Improve WinCE errno handling and comments [Chang] -- Remove comment about no gzip header processing in FAQ -- Add Z_FIXED strategy option to deflateInit2() to force fixed trees -- Add updated make_vms.com [Coghlan], update README -- Create a new "examples" directory, move gzappend.c there, add zpipe.c, - fitblk.c, gzlog.[ch], gzjoin.c, and zlib_how.html. -- Add FAQ entry and comments in deflate.c on uninitialized memory access -- Add Solaris 9 make options in configure [Gilbert] -- Allow strerror() usage in gzio.c for STDC -- Fix DecompressBuf in contrib/delphi/ZLib.pas [ManChesTer] -- Update contrib/masmx86/inffas32.asm and gvmat32.asm [Vollant] -- Use z_off_t for adler32_combine() and crc32_combine() lengths -- Make adler32() much faster for small len -- Use OS_CODE in deflate() default gzip header - -Changes in 1.2.2.1 (31 October 2004) -- Allow inflateSetDictionary() call for raw inflate -- Fix inflate header crc check bug for file names and comments -- Add deflateSetHeader() and gz_header structure for custom gzip headers -- Add inflateGetheader() to retrieve gzip headers -- Add crc32_combine() and adler32_combine() functions -- Add alloc_func, free_func, in_func, out_func to Z_PREFIX list -- Use zstreamp consistently in zlib.h (inflate_back functions) -- Remove GUNZIP condition from definition of inflate_mode in inflate.h - and in contrib/inflate86/inffast.S [Truta, Anderson] -- Add support for AMD64 in contrib/inflate86/inffas86.c [Anderson] -- Update projects/README.projects and projects/visualc6 [Truta] -- Update win32/DLL_FAQ.txt [Truta] -- Avoid warning under NO_GZCOMPRESS in gzio.c; fix typo [Truta] -- Deprecate Z_ASCII; use Z_TEXT instead [Truta] -- Use a new algorithm for setting strm->data_type in trees.c [Truta] -- Do not define an exit() prototype in zutil.c unless DEBUG defined -- Remove prototype of exit() from zutil.c, example.c, minigzip.c [Truta] -- Add comment in zlib.h for Z_NO_FLUSH parameter to deflate() -- Fix Darwin build version identification [Peterson] - -Changes in 1.2.2 (3 October 2004) -- Update zlib.h comments on gzip in-memory processing -- Set adler to 1 in inflateReset() to support Java test suite [Walles] -- Add contrib/dotzlib [Ravn] -- Update win32/DLL_FAQ.txt [Truta] -- Update contrib/minizip [Vollant] -- Move contrib/visual-basic.txt to old/ [Truta] -- Fix assembler builds in projects/visualc6/ [Truta] - -Changes in 1.2.1.2 (9 September 2004) -- Update INDEX file -- Fix trees.c to update strm->data_type (no one ever noticed!) -- Fix bug in error case in inflate.c, infback.c, and infback9.c [Brown] -- Add "volatile" to crc table flag declaration (for DYNAMIC_CRC_TABLE) -- Add limited multitasking protection to DYNAMIC_CRC_TABLE -- Add NO_vsnprintf for VMS in zutil.h [Mozilla] -- Don't declare strerror() under VMS [Mozilla] -- Add comment to DYNAMIC_CRC_TABLE to use get_crc_table() to initialize -- Update contrib/ada [Anisimkov] -- Update contrib/minizip [Vollant] -- Fix configure to not hardcode directories for Darwin [Peterson] -- Fix gzio.c to not return error on empty files [Brown] -- Fix indentation; update version in contrib/delphi/ZLib.pas and - contrib/pascal/zlibpas.pas [Truta] -- Update mkasm.bat in contrib/masmx86 [Truta] -- Update contrib/untgz [Truta] -- Add projects/README.projects [Truta] -- Add project for MS Visual C++ 6.0 in projects/visualc6 [Cadieux, Truta] -- Update win32/DLL_FAQ.txt [Truta] -- Update list of Z_PREFIX symbols in zconf.h [Randers-Pehrson, Truta] -- Remove an unnecessary assignment to curr in inftrees.c [Truta] -- Add OS/2 to exe builds in configure [Poltorak] -- Remove err dummy parameter in zlib.h [Kientzle] - -Changes in 1.2.1.1 (9 January 2004) -- Update email address in README -- Several FAQ updates -- Fix a big fat bug in inftrees.c that prevented decoding valid - dynamic blocks with only literals and no distance codes -- - Thanks to "Hot Emu" for the bug report and sample file -- Add a note to puff.c on no distance codes case. - -Changes in 1.2.1 (17 November 2003) -- Remove a tab in contrib/gzappend/gzappend.c -- Update some interfaces in contrib for new zlib functions -- Update zlib version number in some contrib entries -- Add Windows CE definition for ptrdiff_t in zutil.h [Mai, Truta] -- Support shared libraries on Hurd and KFreeBSD [Brown] -- Fix error in NO_DIVIDE option of adler32.c - -Changes in 1.2.0.8 (4 November 2003) -- Update version in contrib/delphi/ZLib.pas and contrib/pascal/zlibpas.pas -- Add experimental NO_DIVIDE #define in adler32.c - - Possibly faster on some processors (let me know if it is) -- Correct Z_BLOCK to not return on first inflate call if no wrap -- Fix strm->data_type on inflate() return to correctly indicate EOB -- Add deflatePrime() function for appending in the middle of a byte -- Add contrib/gzappend for an example of appending to a stream -- Update win32/DLL_FAQ.txt [Truta] -- Delete Turbo C comment in README [Truta] -- Improve some indentation in zconf.h [Truta] -- Fix infinite loop on bad input in configure script [Church] -- Fix gzeof() for concatenated gzip files [Johnson] -- Add example to contrib/visual-basic.txt [Michael B.] -- Add -p to mkdir's in Makefile.in [vda] -- Fix configure to properly detect presence or lack of printf functions -- Add AS400 support [Monnerat] -- Add a little Cygwin support [Wilson] - -Changes in 1.2.0.7 (21 September 2003) -- Correct some debug formats in contrib/infback9 -- Cast a type in a debug statement in trees.c -- Change search and replace delimiter in configure from % to # [Beebe] -- Update contrib/untgz to 0.2 with various fixes [Truta] -- Add build support for Amiga [Nikl] -- Remove some directories in old that have been updated to 1.2 -- Add dylib building for Mac OS X in configure and Makefile.in -- Remove old distribution stuff from Makefile -- Update README to point to DLL_FAQ.txt, and add comment on Mac OS X -- Update links in README - -Changes in 1.2.0.6 (13 September 2003) -- Minor FAQ updates -- Update contrib/minizip to 1.00 [Vollant] -- Remove test of gz functions in example.c when GZ_COMPRESS defined [Truta] -- Update POSTINC comment for 68060 [Nikl] -- Add contrib/infback9 with deflate64 decoding (unsupported) -- For MVS define NO_vsnprintf and undefine FAR [van Burik] -- Add pragma for fdopen on MVS [van Burik] - -Changes in 1.2.0.5 (8 September 2003) -- Add OF to inflateBackEnd() declaration in zlib.h -- Remember start when using gzdopen in the middle of a file -- Use internal off_t counters in gz* functions to properly handle seeks -- Perform more rigorous check for distance-too-far in inffast.c -- Add Z_BLOCK flush option to return from inflate at block boundary -- Set strm->data_type on return from inflate - - Indicate bits unused, if at block boundary, and if in last block -- Replace size_t with ptrdiff_t in crc32.c, and check for correct size -- Add condition so old NO_DEFLATE define still works for compatibility -- FAQ update regarding the Windows DLL [Truta] -- INDEX update: add qnx entry, remove aix entry [Truta] -- Install zlib.3 into mandir [Wilson] -- Move contrib/zlib_dll_FAQ.txt to win32/DLL_FAQ.txt; update [Truta] -- Adapt the zlib interface to the new DLL convention guidelines [Truta] -- Introduce ZLIB_WINAPI macro to allow the export of functions using - the WINAPI calling convention, for Visual Basic [Vollant, Truta] -- Update msdos and win32 scripts and makefiles [Truta] -- Export symbols by name, not by ordinal, in win32/zlib.def [Truta] -- Add contrib/ada [Anisimkov] -- Move asm files from contrib/vstudio/vc70_32 to contrib/asm386 [Truta] -- Rename contrib/asm386 to contrib/masmx86 [Truta, Vollant] -- Add contrib/masm686 [Truta] -- Fix offsets in contrib/inflate86 and contrib/masmx86/inffas32.asm - [Truta, Vollant] -- Update contrib/delphi; rename to contrib/pascal; add example [Truta] -- Remove contrib/delphi2; add a new contrib/delphi [Truta] -- Avoid inclusion of the nonstandard <memory.h> in contrib/iostream, - and fix some method prototypes [Truta] -- Fix the ZCR_SEED2 constant to avoid warnings in contrib/minizip - [Truta] -- Avoid the use of backslash (\) in contrib/minizip [Vollant] -- Fix file time handling in contrib/untgz; update makefiles [Truta] -- Update contrib/vstudio/vc70_32 to comply with the new DLL guidelines - [Vollant] -- Remove contrib/vstudio/vc15_16 [Vollant] -- Rename contrib/vstudio/vc70_32 to contrib/vstudio/vc7 [Truta] -- Update README.contrib [Truta] -- Invert the assignment order of match_head and s->prev[...] in - INSERT_STRING [Truta] -- Compare TOO_FAR with 32767 instead of 32768, to avoid 16-bit warnings - [Truta] -- Compare function pointers with 0, not with NULL or Z_NULL [Truta] -- Fix prototype of syncsearch in inflate.c [Truta] -- Introduce ASMINF macro to be enabled when using an ASM implementation - of inflate_fast [Truta] -- Change NO_DEFLATE to NO_GZCOMPRESS [Truta] -- Modify test_gzio in example.c to take a single file name as a - parameter [Truta] -- Exit the example.c program if gzopen fails [Truta] -- Add type casts around strlen in example.c [Truta] -- Remove casting to sizeof in minigzip.c; give a proper type - to the variable compared with SUFFIX_LEN [Truta] -- Update definitions of STDC and STDC99 in zconf.h [Truta] -- Synchronize zconf.h with the new Windows DLL interface [Truta] -- Use SYS16BIT instead of __32BIT__ to distinguish between - 16- and 32-bit platforms [Truta] -- Use far memory allocators in small 16-bit memory models for - Turbo C [Truta] -- Add info about the use of ASMV, ASMINF and ZLIB_WINAPI in - zlibCompileFlags [Truta] -- Cygwin has vsnprintf [Wilson] -- In Windows16, OS_CODE is 0, as in MSDOS [Truta] -- In Cygwin, OS_CODE is 3 (Unix), not 11 (Windows32) [Wilson] - -Changes in 1.2.0.4 (10 August 2003) -- Minor FAQ updates -- Be more strict when checking inflateInit2's windowBits parameter -- Change NO_GUNZIP compile option to NO_GZIP to cover deflate as well -- Add gzip wrapper option to deflateInit2 using windowBits -- Add updated QNX rule in configure and qnx directory [Bonnefoy] -- Make inflate distance-too-far checks more rigorous -- Clean up FAR usage in inflate -- Add casting to sizeof() in gzio.c and minigzip.c - -Changes in 1.2.0.3 (19 July 2003) -- Fix silly error in gzungetc() implementation [Vollant] -- Update contrib/minizip and contrib/vstudio [Vollant] -- Fix printf format in example.c -- Correct cdecl support in zconf.in.h [Anisimkov] -- Minor FAQ updates - -Changes in 1.2.0.2 (13 July 2003) -- Add ZLIB_VERNUM in zlib.h for numerical preprocessor comparisons -- Attempt to avoid warnings in crc32.c for pointer-int conversion -- Add AIX to configure, remove aix directory [Bakker] -- Add some casts to minigzip.c -- Improve checking after insecure sprintf() or vsprintf() calls -- Remove #elif's from crc32.c -- Change leave label to inf_leave in inflate.c and infback.c to avoid - library conflicts -- Remove inflate gzip decoding by default--only enable gzip decoding by - special request for stricter backward compatibility -- Add zlibCompileFlags() function to return compilation information -- More typecasting in deflate.c to avoid warnings -- Remove leading underscore from _Capital #defines [Truta] -- Fix configure to link shared library when testing -- Add some Windows CE target adjustments [Mai] -- Remove #define ZLIB_DLL in zconf.h [Vollant] -- Add zlib.3 [Rodgers] -- Update RFC URL in deflate.c and algorithm.txt [Mai] -- Add zlib_dll_FAQ.txt to contrib [Truta] -- Add UL to some constants [Truta] -- Update minizip and vstudio [Vollant] -- Remove vestigial NEED_DUMMY_RETURN from zconf.in.h -- Expand use of NO_DUMMY_DECL to avoid all dummy structures -- Added iostream3 to contrib [Schwardt] -- Replace rewind() with fseek() for WinCE [Truta] -- Improve setting of zlib format compression level flags - - Report 0 for huffman and rle strategies and for level == 0 or 1 - - Report 2 only for level == 6 -- Only deal with 64K limit when necessary at compile time [Truta] -- Allow TOO_FAR check to be turned off at compile time [Truta] -- Add gzclearerr() function [Souza] -- Add gzungetc() function - -Changes in 1.2.0.1 (17 March 2003) -- Add Z_RLE strategy for run-length encoding [Truta] - - When Z_RLE requested, restrict matches to distance one - - Update zlib.h, minigzip.c, gzopen(), gzdopen() for Z_RLE -- Correct FASTEST compilation to allow level == 0 -- Clean up what gets compiled for FASTEST -- Incorporate changes to zconf.in.h [Vollant] - - Refine detection of Turbo C need for dummy returns - - Refine ZLIB_DLL compilation - - Include additional header file on VMS for off_t typedef -- Try to use _vsnprintf where it supplants vsprintf [Vollant] -- Add some casts in inffast.c -- Enchance comments in zlib.h on what happens if gzprintf() tries to - write more than 4095 bytes before compression -- Remove unused state from inflateBackEnd() -- Remove exit(0) from minigzip.c, example.c -- Get rid of all those darn tabs -- Add "check" target to Makefile.in that does the same thing as "test" -- Add "mostlyclean" and "maintainer-clean" targets to Makefile.in -- Update contrib/inflate86 [Anderson] -- Update contrib/testzlib, contrib/vstudio, contrib/minizip [Vollant] -- Add msdos and win32 directories with makefiles [Truta] -- More additions and improvements to the FAQ - -Changes in 1.2.0 (9 March 2003) -- New and improved inflate code - - About 20% faster - - Does not allocate 32K window unless and until needed - - Automatically detects and decompresses gzip streams - - Raw inflate no longer needs an extra dummy byte at end - - Added inflateBack functions using a callback interface--even faster - than inflate, useful for file utilities (gzip, zip) - - Added inflateCopy() function to record state for random access on - externally generated deflate streams (e.g. in gzip files) - - More readable code (I hope) -- New and improved crc32() - - About 50% faster, thanks to suggestions from Rodney Brown -- Add deflateBound() and compressBound() functions -- Fix memory leak in deflateInit2() -- Permit setting dictionary for raw deflate (for parallel deflate) -- Fix const declaration for gzwrite() -- Check for some malloc() failures in gzio.c -- Fix bug in gzopen() on single-byte file 0x1f -- Fix bug in gzread() on concatenated file with 0x1f at end of buffer - and next buffer doesn't start with 0x8b -- Fix uncompress() to return Z_DATA_ERROR on truncated input -- Free memory at end of example.c -- Remove MAX #define in trees.c (conflicted with some libraries) -- Fix static const's in deflate.c, gzio.c, and zutil.[ch] -- Declare malloc() and free() in gzio.c if STDC not defined -- Use malloc() instead of calloc() in zutil.c if int big enough -- Define STDC for AIX -- Add aix/ with approach for compiling shared library on AIX -- Add HP-UX support for shared libraries in configure -- Add OpenUNIX support for shared libraries in configure -- Use $cc instead of gcc to build shared library -- Make prefix directory if needed when installing -- Correct Macintosh avoidance of typedef Byte in zconf.h -- Correct Turbo C memory allocation when under Linux -- Use libz.a instead of -lz in Makefile (assure use of compiled library) -- Update configure to check for snprintf or vsnprintf functions and their - return value, warn during make if using an insecure function -- Fix configure problem with compile-time knowledge of HAVE_UNISTD_H that - is lost when library is used--resolution is to build new zconf.h -- Documentation improvements (in zlib.h): - - Document raw deflate and inflate - - Update RFCs URL - - Point out that zlib and gzip formats are different - - Note that Z_BUF_ERROR is not fatal - - Document string limit for gzprintf() and possible buffer overflow - - Note requirement on avail_out when flushing - - Note permitted values of flush parameter of inflate() -- Add some FAQs (and even answers) to the FAQ -- Add contrib/inflate86/ for x86 faster inflate -- Add contrib/blast/ for PKWare Data Compression Library decompression -- Add contrib/puff/ simple inflate for deflate format description - -Changes in 1.1.4 (11 March 2002) -- ZFREE was repeated on same allocation on some error conditions. - This creates a security problem described in - http://www.zlib.org/advisory-2002-03-11.txt -- Returned incorrect error (Z_MEM_ERROR) on some invalid data -- Avoid accesses before window for invalid distances with inflate window - less than 32K. -- force windowBits > 8 to avoid a bug in the encoder for a window size - of 256 bytes. (A complete fix will be available in 1.1.5). - -Changes in 1.1.3 (9 July 1998) -- fix "an inflate input buffer bug that shows up on rare but persistent - occasions" (Mark) -- fix gzread and gztell for concatenated .gz files (Didier Le Botlan) -- fix gzseek(..., SEEK_SET) in write mode -- fix crc check after a gzeek (Frank Faubert) -- fix miniunzip when the last entry in a zip file is itself a zip file - (J Lillge) -- add contrib/asm586 and contrib/asm686 (Brian Raiter) - See http://www.muppetlabs.com/~breadbox/software/assembly.html -- add support for Delphi 3 in contrib/delphi (Bob Dellaca) -- add support for C++Builder 3 and Delphi 3 in contrib/delphi2 (Davide Moretti) -- do not exit prematurely in untgz if 0 at start of block (Magnus Holmgren) -- use macro EXTERN instead of extern to support DLL for BeOS (Sander Stoks) -- added a FAQ file - -- Support gzdopen on Mac with Metrowerks (Jason Linhart) -- Do not redefine Byte on Mac (Brad Pettit & Jason Linhart) -- define SEEK_END too if SEEK_SET is not defined (Albert Chin-A-Young) -- avoid some warnings with Borland C (Tom Tanner) -- fix a problem in contrib/minizip/zip.c for 16-bit MSDOS (Gilles Vollant) -- emulate utime() for WIN32 in contrib/untgz (Gilles Vollant) -- allow several arguments to configure (Tim Mooney, Frodo Looijaard) -- use libdir and includedir in Makefile.in (Tim Mooney) -- support shared libraries on OSF1 V4 (Tim Mooney) -- remove so_locations in "make clean" (Tim Mooney) -- fix maketree.c compilation error (Glenn, Mark) -- Python interface to zlib now in Python 1.5 (Jeremy Hylton) -- new Makefile.riscos (Rich Walker) -- initialize static descriptors in trees.c for embedded targets (Nick Smith) -- use "foo-gz" in example.c for RISCOS and VMS (Nick Smith) -- add the OS/2 files in Makefile.in too (Andrew Zabolotny) -- fix fdopen and halloc macros for Microsoft C 6.0 (Tom Lane) -- fix maketree.c to allow clean compilation of inffixed.h (Mark) -- fix parameter check in deflateCopy (Gunther Nikl) -- cleanup trees.c, use compressed_len only in debug mode (Christian Spieler) -- Many portability patches by Christian Spieler: - . zutil.c, zutil.h: added "const" for zmem* - . Make_vms.com: fixed some typos - . Make_vms.com: msdos/Makefile.*: removed zutil.h from some dependency lists - . msdos/Makefile.msc: remove "default rtl link library" info from obj files - . msdos/Makefile.*: use model-dependent name for the built zlib library - . msdos/Makefile.emx, nt/Makefile.emx, nt/Makefile.gcc: - new makefiles, for emx (DOS/OS2), emx&rsxnt and mingw32 (Windows 9x / NT) -- use define instead of typedef for Bytef also for MSC small/medium (Tom Lane) -- replace __far with _far for better portability (Christian Spieler, Tom Lane) -- fix test for errno.h in configure (Tim Newsham) - -Changes in 1.1.2 (19 March 98) -- added contrib/minzip, mini zip and unzip based on zlib (Gilles Vollant) - See http://www.winimage.com/zLibDll/unzip.html -- preinitialize the inflate tables for fixed codes, to make the code - completely thread safe (Mark) -- some simplifications and slight speed-up to the inflate code (Mark) -- fix gzeof on non-compressed files (Allan Schrum) -- add -std1 option in configure for OSF1 to fix gzprintf (Martin Mokrejs) -- use default value of 4K for Z_BUFSIZE for 16-bit MSDOS (Tim Wegner + Glenn) -- added os2/Makefile.def and os2/zlib.def (Andrew Zabolotny) -- add shared lib support for UNIX_SV4.2MP (MATSUURA Takanori) -- do not wrap extern "C" around system includes (Tom Lane) -- mention zlib binding for TCL in README (Andreas Kupries) -- added amiga/Makefile.pup for Amiga powerUP SAS/C PPC (Andreas Kleinert) -- allow "make install prefix=..." even after configure (Glenn Randers-Pehrson) -- allow "configure --prefix $HOME" (Tim Mooney) -- remove warnings in example.c and gzio.c (Glenn Randers-Pehrson) -- move Makefile.sas to amiga/Makefile.sas - -Changes in 1.1.1 (27 Feb 98) -- fix macros _tr_tally_* in deflate.h for debug mode (Glenn Randers-Pehrson) -- remove block truncation heuristic which had very marginal effect for zlib - (smaller lit_bufsize than in gzip 1.2.4) and degraded a little the - compression ratio on some files. This also allows inlining _tr_tally for - matches in deflate_slow. -- added msdos/Makefile.w32 for WIN32 Microsoft Visual C++ (Bob Frazier) - -Changes in 1.1.0 (24 Feb 98) -- do not return STREAM_END prematurely in inflate (John Bowler) -- revert to the zlib 1.0.8 inflate to avoid the gcc 2.8.0 bug (Jeremy Buhler) -- compile with -DFASTEST to get compression code optimized for speed only -- in minigzip, try mmap'ing the input file first (Miguel Albrecht) -- increase size of I/O buffers in minigzip.c and gzio.c (not a big gain - on Sun but significant on HP) - -- add a pointer to experimental unzip library in README (Gilles Vollant) -- initialize variable gcc in configure (Chris Herborth) - -Changes in 1.0.9 (17 Feb 1998) -- added gzputs and gzgets functions -- do not clear eof flag in gzseek (Mark Diekhans) -- fix gzseek for files in transparent mode (Mark Diekhans) -- do not assume that vsprintf returns the number of bytes written (Jens Krinke) -- replace EXPORT with ZEXPORT to avoid conflict with other programs -- added compress2 in zconf.h, zlib.def, zlib.dnt -- new asm code from Gilles Vollant in contrib/asm386 -- simplify the inflate code (Mark): - . Replace ZALLOC's in huft_build() with single ZALLOC in inflate_blocks_new() - . ZALLOC the length list in inflate_trees_fixed() instead of using stack - . ZALLOC the value area for huft_build() instead of using stack - . Simplify Z_FINISH check in inflate() - -- Avoid gcc 2.8.0 comparison bug a little differently than zlib 1.0.8 -- in inftrees.c, avoid cc -O bug on HP (Farshid Elahi) -- in zconf.h move the ZLIB_DLL stuff earlier to avoid problems with - the declaration of FAR (Gilles VOllant) -- install libz.so* with mode 755 (executable) instead of 644 (Marc Lehmann) -- read_buf buf parameter of type Bytef* instead of charf* -- zmemcpy parameters are of type Bytef*, not charf* (Joseph Strout) -- do not redeclare unlink in minigzip.c for WIN32 (John Bowler) -- fix check for presence of directories in "make install" (Ian Willis) - -Changes in 1.0.8 (27 Jan 1998) -- fixed offsets in contrib/asm386/gvmat32.asm (Gilles Vollant) -- fix gzgetc and gzputc for big endian systems (Markus Oberhumer) -- added compress2() to allow setting the compression level -- include sys/types.h to get off_t on some systems (Marc Lehmann & QingLong) -- use constant arrays for the static trees in trees.c instead of computing - them at run time (thanks to Ken Raeburn for this suggestion). To create - trees.h, compile with GEN_TREES_H and run "make test". -- check return code of example in "make test" and display result -- pass minigzip command line options to file_compress -- simplifying code of inflateSync to avoid gcc 2.8 bug - -- support CC="gcc -Wall" in configure -s (QingLong) -- avoid a flush caused by ftell in gzopen for write mode (Ken Raeburn) -- fix test for shared library support to avoid compiler warnings -- zlib.lib -> zlib.dll in msdos/zlib.rc (Gilles Vollant) -- check for TARGET_OS_MAC in addition to MACOS (Brad Pettit) -- do not use fdopen for Metrowerks on Mac (Brad Pettit)) -- add checks for gzputc and gzputc in example.c -- avoid warnings in gzio.c and deflate.c (Andreas Kleinert) -- use const for the CRC table (Ken Raeburn) -- fixed "make uninstall" for shared libraries -- use Tracev instead of Trace in infblock.c -- in example.c use correct compressed length for test_sync -- suppress +vnocompatwarnings in configure for HPUX (not always supported) - -Changes in 1.0.7 (20 Jan 1998) -- fix gzseek which was broken in write mode -- return error for gzseek to negative absolute position -- fix configure for Linux (Chun-Chung Chen) -- increase stack space for MSC (Tim Wegner) -- get_crc_table and inflateSyncPoint are EXPORTed (Gilles Vollant) -- define EXPORTVA for gzprintf (Gilles Vollant) -- added man page zlib.3 (Rick Rodgers) -- for contrib/untgz, fix makedir() and improve Makefile - -- check gzseek in write mode in example.c -- allocate extra buffer for seeks only if gzseek is actually called -- avoid signed/unsigned comparisons (Tim Wegner, Gilles Vollant) -- add inflateSyncPoint in zconf.h -- fix list of exported functions in nt/zlib.dnt and mdsos/zlib.def - -Changes in 1.0.6 (19 Jan 1998) -- add functions gzprintf, gzputc, gzgetc, gztell, gzeof, gzseek, gzrewind and - gzsetparams (thanks to Roland Giersig and Kevin Ruland for some of this code) -- Fix a deflate bug occurring only with compression level 0 (thanks to - Andy Buckler for finding this one). -- In minigzip, pass transparently also the first byte for .Z files. -- return Z_BUF_ERROR instead of Z_OK if output buffer full in uncompress() -- check Z_FINISH in inflate (thanks to Marc Schluper) -- Implement deflateCopy (thanks to Adam Costello) -- make static libraries by default in configure, add --shared option. -- move MSDOS or Windows specific files to directory msdos -- suppress the notion of partial flush to simplify the interface - (but the symbol Z_PARTIAL_FLUSH is kept for compatibility with 1.0.4) -- suppress history buffer provided by application to simplify the interface - (this feature was not implemented anyway in 1.0.4) -- next_in and avail_in must be initialized before calling inflateInit or - inflateInit2 -- add EXPORT in all exported functions (for Windows DLL) -- added Makefile.nt (thanks to Stephen Williams) -- added the unsupported "contrib" directory: - contrib/asm386/ by Gilles Vollant <info@winimage.com> - 386 asm code replacing longest_match(). - contrib/iostream/ by Kevin Ruland <kevin@rodin.wustl.edu> - A C++ I/O streams interface to the zlib gz* functions - contrib/iostream2/ by Tyge Lvset <Tyge.Lovset@cmr.no> - Another C++ I/O streams interface - contrib/untgz/ by "Pedro A. Aranda Guti\irrez" <paag@tid.es> - A very simple tar.gz file extractor using zlib - contrib/visual-basic.txt by Carlos Rios <c_rios@sonda.cl> - How to use compress(), uncompress() and the gz* functions from VB. -- pass params -f (filtered data), -h (huffman only), -1 to -9 (compression - level) in minigzip (thanks to Tom Lane) - -- use const for rommable constants in deflate -- added test for gzseek and gztell in example.c -- add undocumented function inflateSyncPoint() (hack for Paul Mackerras) -- add undocumented function zError to convert error code to string - (for Tim Smithers) -- Allow compilation of gzio with -DNO_DEFLATE to avoid the compression code. -- Use default memcpy for Symantec MSDOS compiler. -- Add EXPORT keyword for check_func (needed for Windows DLL) -- add current directory to LD_LIBRARY_PATH for "make test" -- create also a link for libz.so.1 -- added support for FUJITSU UXP/DS (thanks to Toshiaki Nomura) -- use $(SHAREDLIB) instead of libz.so in Makefile.in (for HPUX) -- added -soname for Linux in configure (Chun-Chung Chen, -- assign numbers to the exported functions in zlib.def (for Windows DLL) -- add advice in zlib.h for best usage of deflateSetDictionary -- work around compiler bug on Atari (cast Z_NULL in call of s->checkfn) -- allow compilation with ANSI keywords only enabled for TurboC in large model -- avoid "versionString"[0] (Borland bug) -- add NEED_DUMMY_RETURN for Borland -- use variable z_verbose for tracing in debug mode (L. Peter Deutsch). -- allow compilation with CC -- defined STDC for OS/2 (David Charlap) -- limit external names to 8 chars for MVS (Thomas Lund) -- in minigzip.c, use static buffers only for 16-bit systems -- fix suffix check for "minigzip -d foo.gz" -- do not return an error for the 2nd of two consecutive gzflush() (Felix Lee) -- use _fdopen instead of fdopen for MSC >= 6.0 (Thomas Fanslau) -- added makelcc.bat for lcc-win32 (Tom St Denis) -- in Makefile.dj2, use copy and del instead of install and rm (Frank Donahoe) -- Avoid expanded $Id$. Use "rcs -kb" or "cvs admin -kb" to avoid Id expansion. -- check for unistd.h in configure (for off_t) -- remove useless check parameter in inflate_blocks_free -- avoid useless assignment of s->check to itself in inflate_blocks_new -- do not flush twice in gzclose (thanks to Ken Raeburn) -- rename FOPEN as F_OPEN to avoid clash with /usr/include/sys/file.h -- use NO_ERRNO_H instead of enumeration of operating systems with errno.h -- work around buggy fclose on pipes for HP/UX -- support zlib DLL with BORLAND C++ 5.0 (thanks to Glenn Randers-Pehrson) -- fix configure if CC is already equal to gcc - -Changes in 1.0.5 (3 Jan 98) -- Fix inflate to terminate gracefully when fed corrupted or invalid data -- Use const for rommable constants in inflate -- Eliminate memory leaks on error conditions in inflate -- Removed some vestigial code in inflate -- Update web address in README - -Changes in 1.0.4 (24 Jul 96) -- In very rare conditions, deflate(s, Z_FINISH) could fail to produce an EOF - bit, so the decompressor could decompress all the correct data but went - on to attempt decompressing extra garbage data. This affected minigzip too. -- zlibVersion and gzerror return const char* (needed for DLL) -- port to RISCOS (no fdopen, no multiple dots, no unlink, no fileno) -- use z_error only for DEBUG (avoid problem with DLLs) - -Changes in 1.0.3 (2 Jul 96) -- use z_streamp instead of z_stream *, which is now a far pointer in MSDOS - small and medium models; this makes the library incompatible with previous - versions for these models. (No effect in large model or on other systems.) -- return OK instead of BUF_ERROR if previous deflate call returned with - avail_out as zero but there is nothing to do -- added memcmp for non STDC compilers -- define NO_DUMMY_DECL for more Mac compilers (.h files merged incorrectly) -- define __32BIT__ if __386__ or i386 is defined (pb. with Watcom and SCO) -- better check for 16-bit mode MSC (avoids problem with Symantec) - -Changes in 1.0.2 (23 May 96) -- added Windows DLL support -- added a function zlibVersion (for the DLL support) -- fixed declarations using Bytef in infutil.c (pb with MSDOS medium model) -- Bytef is define's instead of typedef'd only for Borland C -- avoid reading uninitialized memory in example.c -- mention in README that the zlib format is now RFC1950 -- updated Makefile.dj2 -- added algorithm.doc - -Changes in 1.0.1 (20 May 96) [1.0 skipped to avoid confusion] -- fix array overlay in deflate.c which sometimes caused bad compressed data -- fix inflate bug with empty stored block -- fix MSDOS medium model which was broken in 0.99 -- fix deflateParams() which could generated bad compressed data. -- Bytef is define'd instead of typedef'ed (work around Borland bug) -- added an INDEX file -- new makefiles for DJGPP (Makefile.dj2), 32-bit Borland (Makefile.b32), - Watcom (Makefile.wat), Amiga SAS/C (Makefile.sas) -- speed up adler32 for modern machines without auto-increment -- added -ansi for IRIX in configure -- static_init_done in trees.c is an int -- define unlink as delete for VMS -- fix configure for QNX -- add configure branch for SCO and HPUX -- avoid many warnings (unused variables, dead assignments, etc...) -- no fdopen for BeOS -- fix the Watcom fix for 32 bit mode (define FAR as empty) -- removed redefinition of Byte for MKWERKS -- work around an MWKERKS bug (incorrect merge of all .h files) - -Changes in 0.99 (27 Jan 96) -- allow preset dictionary shared between compressor and decompressor -- allow compression level 0 (no compression) -- add deflateParams in zlib.h: allow dynamic change of compression level - and compression strategy. -- test large buffers and deflateParams in example.c -- add optional "configure" to build zlib as a shared library -- suppress Makefile.qnx, use configure instead -- fixed deflate for 64-bit systems (detected on Cray) -- fixed inflate_blocks for 64-bit systems (detected on Alpha) -- declare Z_DEFLATED in zlib.h (possible parameter for deflateInit2) -- always return Z_BUF_ERROR when deflate() has nothing to do -- deflateInit and inflateInit are now macros to allow version checking -- prefix all global functions and types with z_ with -DZ_PREFIX -- make falloc completely reentrant (inftrees.c) -- fixed very unlikely race condition in ct_static_init -- free in reverse order of allocation to help memory manager -- use zlib-1.0/* instead of zlib/* inside the tar.gz -- make zlib warning-free with "gcc -O3 -Wall -Wwrite-strings -Wpointer-arith - -Wconversion -Wstrict-prototypes -Wmissing-prototypes" -- allow gzread on concatenated .gz files -- deflateEnd now returns Z_DATA_ERROR if it was premature -- deflate is finally (?) fully deterministic (no matches beyond end of input) -- Document Z_SYNC_FLUSH -- add uninstall in Makefile -- Check for __cpluplus in zlib.h -- Better test in ct_align for partial flush -- avoid harmless warnings for Borland C++ -- initialize hash_head in deflate.c -- avoid warning on fdopen (gzio.c) for HP cc -Aa -- include stdlib.h for STDC compilers -- include errno.h for Cray -- ignore error if ranlib doesn't exist -- call ranlib twice for NeXTSTEP -- use exec_prefix instead of prefix for libz.a -- renamed ct_* as _tr_* to avoid conflict with applications -- clear z->msg in inflateInit2 before any error return -- initialize opaque in example.c, gzio.c, deflate.c and inflate.c -- fixed typo in zconf.h (_GNUC__ => __GNUC__) -- check for WIN32 in zconf.h and zutil.c (avoid farmalloc in 32-bit mode) -- fix typo in Make_vms.com (f$trnlnm -> f$getsyi) -- in fcalloc, normalize pointer if size > 65520 bytes -- don't use special fcalloc for 32 bit Borland C++ -- use STDC instead of __GO32__ to avoid redeclaring exit, calloc, etc... -- use Z_BINARY instead of BINARY -- document that gzclose after gzdopen will close the file -- allow "a" as mode in gzopen. -- fix error checking in gzread -- allow skipping .gz extra-field on pipes -- added reference to Perl interface in README -- put the crc table in FAR data (I dislike more and more the medium model :) -- added get_crc_table -- added a dimension to all arrays (Borland C can't count). -- workaround Borland C bug in declaration of inflate_codes_new & inflate_fast -- guard against multiple inclusion of *.h (for precompiled header on Mac) -- Watcom C pretends to be Microsoft C small model even in 32 bit mode. -- don't use unsized arrays to avoid silly warnings by Visual C++: - warning C4746: 'inflate_mask' : unsized array treated as '__far' - (what's wrong with far data in far model?). -- define enum out of inflate_blocks_state to allow compilation with C++ - -Changes in 0.95 (16 Aug 95) -- fix MSDOS small and medium model (now easier to adapt to any compiler) -- inlined send_bits -- fix the final (:-) bug for deflate with flush (output was correct but - not completely flushed in rare occasions). -- default window size is same for compression and decompression - (it's now sufficient to set MAX_WBITS in zconf.h). -- voidp -> voidpf and voidnp -> voidp (for consistency with other - typedefs and because voidnp was not near in large model). - -Changes in 0.94 (13 Aug 95) -- support MSDOS medium model -- fix deflate with flush (could sometimes generate bad output) -- fix deflateReset (zlib header was incorrectly suppressed) -- added support for VMS -- allow a compression level in gzopen() -- gzflush now calls fflush -- For deflate with flush, flush even if no more input is provided. -- rename libgz.a as libz.a -- avoid complex expression in infcodes.c triggering Turbo C bug -- work around a problem with gcc on Alpha (in INSERT_STRING) -- don't use inline functions (problem with some gcc versions) -- allow renaming of Byte, uInt, etc... with #define. -- avoid warning about (unused) pointer before start of array in deflate.c -- avoid various warnings in gzio.c, example.c, infblock.c, adler32.c, zutil.c -- avoid reserved word 'new' in trees.c - -Changes in 0.93 (25 June 95) -- temporarily disable inline functions -- make deflate deterministic -- give enough lookahead for PARTIAL_FLUSH -- Set binary mode for stdin/stdout in minigzip.c for OS/2 -- don't even use signed char in inflate (not portable enough) -- fix inflate memory leak for segmented architectures - -Changes in 0.92 (3 May 95) -- don't assume that char is signed (problem on SGI) -- Clear bit buffer when starting a stored block -- no memcpy on Pyramid -- suppressed inftest.c -- optimized fill_window, put longest_match inline for gcc -- optimized inflate on stored blocks. -- untabify all sources to simplify patches - -Changes in 0.91 (2 May 95) -- Default MEM_LEVEL is 8 (not 9 for Unix) as documented in zlib.h -- Document the memory requirements in zconf.h -- added "make install" -- fix sync search logic in inflateSync -- deflate(Z_FULL_FLUSH) now works even if output buffer too short -- after inflateSync, don't scare people with just "lo world" -- added support for DJGPP - -Changes in 0.9 (1 May 95) -- don't assume that zalloc clears the allocated memory (the TurboC bug - was Mark's bug after all :) -- let again gzread copy uncompressed data unchanged (was working in 0.71) -- deflate(Z_FULL_FLUSH), inflateReset and inflateSync are now fully implemented -- added a test of inflateSync in example.c -- moved MAX_WBITS to zconf.h because users might want to change that. -- document explicitly that zalloc(64K) on MSDOS must return a normalized - pointer (zero offset) -- added Makefiles for Microsoft C, Turbo C, Borland C++ -- faster crc32() - -Changes in 0.8 (29 April 95) -- added fast inflate (inffast.c) -- deflate(Z_FINISH) now returns Z_STREAM_END when done. Warning: this - is incompatible with previous versions of zlib which returned Z_OK. -- work around a TurboC compiler bug (bad code for b << 0, see infutil.h) - (actually that was not a compiler bug, see 0.81 above) -- gzread no longer reads one extra byte in certain cases -- In gzio destroy(), don't reference a freed structure -- avoid many warnings for MSDOS -- avoid the ERROR symbol which is used by MS Windows - -Changes in 0.71 (14 April 95) -- Fixed more MSDOS compilation problems :( There is still a bug with - TurboC large model. - -Changes in 0.7 (14 April 95) -- Added full inflate support. -- Simplified the crc32() interface. The pre- and post-conditioning - (one's complement) is now done inside crc32(). WARNING: this is - incompatible with previous versions; see zlib.h for the new usage. - -Changes in 0.61 (12 April 95) -- workaround for a bug in TurboC. example and minigzip now work on MSDOS. - -Changes in 0.6 (11 April 95) -- added minigzip.c -- added gzdopen to reopen a file descriptor as gzFile -- added transparent reading of non-gziped files in gzread. -- fixed bug in gzread (don't read crc as data) -- fixed bug in destroy (gzio.c) (don't return Z_STREAM_END for gzclose). -- don't allocate big arrays in the stack (for MSDOS) -- fix some MSDOS compilation problems - -Changes in 0.5: -- do real compression in deflate.c. Z_PARTIAL_FLUSH is supported but - not yet Z_FULL_FLUSH. -- support decompression but only in a single step (forced Z_FINISH) -- added opaque object for zalloc and zfree. -- added deflateReset and inflateReset -- added a variable zlib_version for consistency checking. -- renamed the 'filter' parameter of deflateInit2 as 'strategy'. - Added Z_FILTERED and Z_HUFFMAN_ONLY constants. - -Changes in 0.4: -- avoid "zip" everywhere, use zlib instead of ziplib. -- suppress Z_BLOCK_FLUSH, interpret Z_PARTIAL_FLUSH as block flush - if compression method == 8. -- added adler32 and crc32 -- renamed deflateOptions as deflateInit2, call one or the other but not both -- added the method parameter for deflateInit2. -- added inflateInit2 -- simplied considerably deflateInit and inflateInit by not supporting - user-provided history buffer. This is supported only in deflateInit2 - and inflateInit2. - -Changes in 0.3: -- prefix all macro names with Z_ -- use Z_FINISH instead of deflateEnd to finish compression. -- added Z_HUFFMAN_ONLY -- added gzerror() diff --git a/irrlicht-1.6/source/Irrlicht/zlib/FAQ b/irrlicht-1.6/source/Irrlicht/zlib/FAQ deleted file mode 100644 index 15d043615..000000000 --- a/irrlicht-1.6/source/Irrlicht/zlib/FAQ +++ /dev/null @@ -1,339 +0,0 @@ - - Frequently Asked Questions about zlib - - -If your question is not there, please check the zlib home page -http://www.zlib.org which may have more recent information. -The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html - - - 1. Is zlib Y2K-compliant? - - Yes. zlib doesn't handle dates. - - 2. Where can I get a Windows DLL version? - - The zlib sources can be compiled without change to produce a DLL. - See the file win32/DLL_FAQ.txt in the zlib distribution. - Pointers to the precompiled DLL are found in the zlib web site at - http://www.zlib.org. - - 3. Where can I get a Visual Basic interface to zlib? - - See - * http://www.dogma.net/markn/articles/zlibtool/zlibtool.htm - * contrib/visual-basic.txt in the zlib distribution - * win32/DLL_FAQ.txt in the zlib distribution - - 4. compress() returns Z_BUF_ERROR. - - Make sure that before the call of compress, the length of the compressed - buffer is equal to the total size of the compressed buffer and not - zero. For Visual Basic, check that this parameter is passed by reference - ("as any"), not by value ("as long"). - - 5. deflate() or inflate() returns Z_BUF_ERROR. - - Before making the call, make sure that avail_in and avail_out are not - zero. When setting the parameter flush equal to Z_FINISH, also make sure - that avail_out is big enough to allow processing all pending input. - Note that a Z_BUF_ERROR is not fatal--another call to deflate() or - inflate() can be made with more input or output space. A Z_BUF_ERROR - may in fact be unavoidable depending on how the functions are used, since - it is not possible to tell whether or not there is more output pending - when strm.avail_out returns with zero. - - 6. Where's the zlib documentation (man pages, etc.)? - - It's in zlib.h for the moment, and Francis S. Lin has converted it to a - web page zlib.html. Volunteers to transform this to Unix-style man pages, - please contact us (zlib@gzip.org). Examples of zlib usage are in the files - example.c and minigzip.c. - - 7. Why don't you use GNU autoconf or libtool or ...? - - Because we would like to keep zlib as a very small and simple - package. zlib is rather portable and doesn't need much configuration. - - 8. I found a bug in zlib. - - Most of the time, such problems are due to an incorrect usage of - zlib. Please try to reproduce the problem with a small program and send - the corresponding source to us at zlib@gzip.org . Do not send - multi-megabyte data files without prior agreement. - - 9. Why do I get "undefined reference to gzputc"? - - If "make test" produces something like - - example.o(.text+0x154): undefined reference to `gzputc' - - check that you don't have old files libz.* in /usr/lib, /usr/local/lib or - /usr/X11R6/lib. Remove any old versions, then do "make install". - -10. I need a Delphi interface to zlib. - - See the contrib/delphi directory in the zlib distribution. - -11. Can zlib handle .zip archives? - - Not by itself, no. See the directory contrib/minizip in the zlib - distribution. - -12. Can zlib handle .Z files? - - No, sorry. You have to spawn an uncompress or gunzip subprocess, or adapt - the code of uncompress on your own. - -13. How can I make a Unix shared library? - - make clean - ./configure -s - make - -14. How do I install a shared zlib library on Unix? - - After the above, then: - - make install - - However, many flavors of Unix come with a shared zlib already installed. - Before going to the trouble of compiling a shared version of zlib and - trying to install it, you may want to check if it's already there! If you - can #include <zlib.h>, it's there. The -lz option will probably link to it. - -15. I have a question about OttoPDF. - - We are not the authors of OttoPDF. The real author is on the OttoPDF web - site: Joel Hainley, jhainley@myndkryme.com. - -16. Can zlib decode Flate data in an Adobe PDF file? - - Yes. See http://www.fastio.com/ (ClibPDF), or http://www.pdflib.com/ . - To modify PDF forms, see http://sourceforge.net/projects/acroformtool/ . - -17. Why am I getting this "register_frame_info not found" error on Solaris? - - After installing zlib 1.1.4 on Solaris 2.6, running applications using zlib - generates an error such as: - - ld.so.1: rpm: fatal: relocation error: file /usr/local/lib/libz.so: - symbol __register_frame_info: referenced symbol not found - - The symbol __register_frame_info is not part of zlib, it is generated by - the C compiler (cc or gcc). You must recompile applications using zlib - which have this problem. This problem is specific to Solaris. See - http://www.sunfreeware.com for Solaris versions of zlib and applications - using zlib. - -18. Why does gzip give an error on a file I make with compress/deflate? - - The compress and deflate functions produce data in the zlib format, which - is different and incompatible with the gzip format. The gz* functions in - zlib on the other hand use the gzip format. Both the zlib and gzip - formats use the same compressed data format internally, but have different - headers and trailers around the compressed data. - -19. Ok, so why are there two different formats? - - The gzip format was designed to retain the directory information about - a single file, such as the name and last modification date. The zlib - format on the other hand was designed for in-memory and communication - channel applications, and has a much more compact header and trailer and - uses a faster integrity check than gzip. - -20. Well that's nice, but how do I make a gzip file in memory? - - You can request that deflate write the gzip format instead of the zlib - format using deflateInit2(). You can also request that inflate decode - the gzip format using inflateInit2(). Read zlib.h for more details. - -21. Is zlib thread-safe? - - Yes. However any library routines that zlib uses and any application- - provided memory allocation routines must also be thread-safe. zlib's gz* - functions use stdio library routines, and most of zlib's functions use the - library memory allocation routines by default. zlib's Init functions allow - for the application to provide custom memory allocation routines. - - Of course, you should only operate on any given zlib or gzip stream from a - single thread at a time. - -22. Can I use zlib in my commercial application? - - Yes. Please read the license in zlib.h. - -23. Is zlib under the GNU license? - - No. Please read the license in zlib.h. - -24. The license says that altered source versions must be "plainly marked". So - what exactly do I need to do to meet that requirement? - - You need to change the ZLIB_VERSION and ZLIB_VERNUM #defines in zlib.h. In - particular, the final version number needs to be changed to "f", and an - identification string should be appended to ZLIB_VERSION. Version numbers - x.x.x.f are reserved for modifications to zlib by others than the zlib - maintainers. For example, if the version of the base zlib you are altering - is "1.2.3.4", then in zlib.h you should change ZLIB_VERNUM to 0x123f, and - ZLIB_VERSION to something like "1.2.3.f-zachary-mods-v3". You can also - update the version strings in deflate.c and inftrees.c. - - For altered source distributions, you should also note the origin and - nature of the changes in zlib.h, as well as in ChangeLog and README, along - with the dates of the alterations. The origin should include at least your - name (or your company's name), and an email address to contact for help or - issues with the library. - - Note that distributing a compiled zlib library along with zlib.h and - zconf.h is also a source distribution, and so you should change - ZLIB_VERSION and ZLIB_VERNUM and note the origin and nature of the changes - in zlib.h as you would for a full source distribution. - -25. Will zlib work on a big-endian or little-endian architecture, and can I - exchange compressed data between them? - - Yes and yes. - -26. Will zlib work on a 64-bit machine? - - It should. It has been tested on 64-bit machines, and has no dependence - on any data types being limited to 32-bits in length. If you have any - difficulties, please provide a complete problem report to zlib@gzip.org - -27. Will zlib decompress data from the PKWare Data Compression Library? - - No. The PKWare DCL uses a completely different compressed data format - than does PKZIP and zlib. However, you can look in zlib's contrib/blast - directory for a possible solution to your problem. - -28. Can I access data randomly in a compressed stream? - - No, not without some preparation. If when compressing you periodically - use Z_FULL_FLUSH, carefully write all the pending data at those points, - and keep an index of those locations, then you can start decompression - at those points. You have to be careful to not use Z_FULL_FLUSH too - often, since it can significantly degrade compression. - -29. Does zlib work on MVS, OS/390, CICS, etc.? - - We don't know for sure. We have heard occasional reports of success on - these systems. If you do use it on one of these, please provide us with - a report, instructions, and patches that we can reference when we get - these questions. Thanks. - -30. Is there some simpler, easier to read version of inflate I can look at - to understand the deflate format? - - First off, you should read RFC 1951. Second, yes. Look in zlib's - contrib/puff directory. - -31. Does zlib infringe on any patents? - - As far as we know, no. In fact, that was originally the whole point behind - zlib. Look here for some more information: - - http://www.gzip.org/#faq11 - -32. Can zlib work with greater than 4 GB of data? - - Yes. inflate() and deflate() will process any amount of data correctly. - Each call of inflate() or deflate() is limited to input and output chunks - of the maximum value that can be stored in the compiler's "unsigned int" - type, but there is no limit to the number of chunks. Note however that the - strm.total_in and strm_total_out counters may be limited to 4 GB. These - counters are provided as a convenience and are not used internally by - inflate() or deflate(). The application can easily set up its own counters - updated after each call of inflate() or deflate() to count beyond 4 GB. - compress() and uncompress() may be limited to 4 GB, since they operate in a - single call. gzseek() and gztell() may be limited to 4 GB depending on how - zlib is compiled. See the zlibCompileFlags() function in zlib.h. - - The word "may" appears several times above since there is a 4 GB limit - only if the compiler's "long" type is 32 bits. If the compiler's "long" - type is 64 bits, then the limit is 16 exabytes. - -33. Does zlib have any security vulnerabilities? - - The only one that we are aware of is potentially in gzprintf(). If zlib - is compiled to use sprintf() or vsprintf(), then there is no protection - against a buffer overflow of a 4K string space, other than the caller of - gzprintf() assuring that the output will not exceed 4K. On the other - hand, if zlib is compiled to use snprintf() or vsnprintf(), which should - normally be the case, then there is no vulnerability. The ./configure - script will display warnings if an insecure variation of sprintf() will - be used by gzprintf(). Also the zlibCompileFlags() function will return - information on what variant of sprintf() is used by gzprintf(). - - If you don't have snprintf() or vsnprintf() and would like one, you can - find a portable implementation here: - - http://www.ijs.si/software/snprintf/ - - Note that you should be using the most recent version of zlib. Versions - 1.1.3 and before were subject to a double-free vulnerability. - -34. Is there a Java version of zlib? - - Probably what you want is to use zlib in Java. zlib is already included - as part of the Java SDK in the java.util.zip package. If you really want - a version of zlib written in the Java language, look on the zlib home - page for links: http://www.zlib.org/ - -35. I get this or that compiler or source-code scanner warning when I crank it - up to maximally-pedantic. Can't you guys write proper code? - - Many years ago, we gave up attempting to avoid warnings on every compiler - in the universe. It just got to be a waste of time, and some compilers - were downright silly. So now, we simply make sure that the code always - works. - -36. Valgrind (or some similar memory access checker) says that deflate is - performing a conditional jump that depends on an uninitialized value. - Isn't that a bug? - - No. That is intentional for performance reasons, and the output of - deflate is not affected. This only started showing up recently since - zlib 1.2.x uses malloc() by default for allocations, whereas earlier - versions used calloc(), which zeros out the allocated memory. - -37. Will zlib read the (insert any ancient or arcane format here) compressed - data format? - - Probably not. Look in the comp.compression FAQ for pointers to various - formats and associated software. - -38. How can I encrypt/decrypt zip files with zlib? - - zlib doesn't support encryption. The original PKZIP encryption is very weak - and can be broken with freely available programs. To get strong encryption, - use GnuPG, http://www.gnupg.org/ , which already includes zlib compression. - For PKZIP compatible "encryption", look at http://www.info-zip.org/ - -39. What's the difference between the "gzip" and "deflate" HTTP 1.1 encodings? - - "gzip" is the gzip format, and "deflate" is the zlib format. They should - probably have called the second one "zlib" instead to avoid confusion - with the raw deflate compressed data format. While the HTTP 1.1 RFC 2616 - correctly points to the zlib specification in RFC 1950 for the "deflate" - transfer encoding, there have been reports of servers and browsers that - incorrectly produce or expect raw deflate data per the deflate - specficiation in RFC 1951, most notably Microsoft. So even though the - "deflate" transfer encoding using the zlib format would be the more - efficient approach (and in fact exactly what the zlib format was designed - for), using the "gzip" transfer encoding is probably more reliable due to - an unfortunate choice of name on the part of the HTTP 1.1 authors. - - Bottom line: use the gzip format for HTTP 1.1 encoding. - -40. Does zlib support the new "Deflate64" format introduced by PKWare? - - No. PKWare has apparently decided to keep that format proprietary, since - they have not documented it as they have previous compression formats. - In any case, the compression improvements are so modest compared to other - more modern approaches, that it's not worth the effort to implement. - -41. Can you please sign these lengthy legal documents and fax them back to us - so that we can use your software in our product? - - No. Go away. Shoo. diff --git a/irrlicht-1.6/source/Irrlicht/zlib/INDEX b/irrlicht-1.6/source/Irrlicht/zlib/INDEX deleted file mode 100644 index 4d7eac44b..000000000 --- a/irrlicht-1.6/source/Irrlicht/zlib/INDEX +++ /dev/null @@ -1,51 +0,0 @@ -ChangeLog history of changes -FAQ Frequently Asked Questions about zlib -INDEX this file -Makefile makefile for Unix (generated by configure) -Makefile.in makefile for Unix (template for configure) -README guess what -algorithm.txt description of the (de)compression algorithm -configure configure script for Unix -zconf.in.h template for zconf.h (used by configure) - -amiga/ makefiles for Amiga SAS C -as400/ makefiles for IBM AS/400 -msdos/ makefiles for MSDOS -old/ makefiles for various architectures and zlib documentation - files that have not yet been updated for zlib 1.2.x -projects/ projects for various Integrated Development Environments -qnx/ makefiles for QNX -win32/ makefiles for Windows - - zlib public header files (must be kept): -zconf.h -zlib.h - - private source files used to build the zlib library: -adler32.c -compress.c -crc32.c -crc32.h -deflate.c -deflate.h -gzio.c -infback.c -inffast.c -inffast.h -inffixed.h -inflate.c -inflate.h -inftrees.c -inftrees.h -trees.c -trees.h -uncompr.c -zutil.c -zutil.h - - source files for sample programs: -example.c -minigzip.c - - unsupported contribution by third parties -See contrib/README.contrib diff --git a/irrlicht-1.6/source/Irrlicht/zlib/README b/irrlicht-1.6/source/Irrlicht/zlib/README deleted file mode 100644 index 80f71ae85..000000000 --- a/irrlicht-1.6/source/Irrlicht/zlib/README +++ /dev/null @@ -1,125 +0,0 @@ -ZLIB DATA COMPRESSION LIBRARY - -zlib 1.2.3 is a general purpose data compression library. All the code is -thread safe. The data format used by the zlib library is described by RFCs -(Request for Comments) 1950 to 1952 in the files -http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format) -and rfc1952.txt (gzip format). These documents are also available in other -formats from ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html - -All functions of the compression library are documented in the file zlib.h -(volunteer to write man pages welcome, contact zlib@gzip.org). A usage example -of the library is given in the file example.c which also tests that the library -is working correctly. Another example is given in the file minigzip.c. The -compression library itself is composed of all source files except example.c and -minigzip.c. - -To compile all files and run the test program, follow the instructions given at -the top of Makefile. In short "make test; make install" should work for most -machines. For Unix: "./configure; make test; make install". For MSDOS, use one -of the special makefiles such as Makefile.msc. For VMS, use make_vms.com. - -Questions about zlib should be sent to <zlib@gzip.org>, or to Gilles Vollant -<info@winimage.com> for the Windows DLL version. The zlib home page is -http://www.zlib.org or http://www.gzip.org/zlib/ Before reporting a problem, -please check this site to verify that you have the latest version of zlib; -otherwise get the latest version and check whether the problem still exists or -not. - -PLEASE read the zlib FAQ http://www.gzip.org/zlib/zlib_faq.html before asking -for help. - -Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997 -issue of Dr. Dobb's Journal; a copy of the article is available in -http://dogma.net/markn/articles/zlibtool/zlibtool.htm - -The changes made in version 1.2.3 are documented in the file ChangeLog. - -Unsupported third party contributions are provided in directory "contrib". - -A Java implementation of zlib is available in the Java Development Kit -http://java.sun.com/j2se/1.4.2/docs/api/java/util/zip/package-summary.html -See the zlib home page http://www.zlib.org for details. - -A Perl interface to zlib written by Paul Marquess <pmqs@cpan.org> is in the -CPAN (Comprehensive Perl Archive Network) sites -http://www.cpan.org/modules/by-module/Compress/ - -A Python interface to zlib written by A.M. Kuchling <amk@amk.ca> is -available in Python 1.5 and later versions, see -http://www.python.org/doc/lib/module-zlib.html - -A zlib binding for TCL written by Andreas Kupries <a.kupries@westend.com> is -availlable at http://www.oche.de/~akupries/soft/trf/trf_zip.html - -An experimental package to read and write files in .zip format, written on top -of zlib by Gilles Vollant <info@winimage.com>, is available in the -contrib/minizip directory of zlib. - - -Notes for some targets: - -- For Windows DLL versions, please see win32/DLL_FAQ.txt - -- For 64-bit Irix, deflate.c must be compiled without any optimization. With - -O, one libpng test fails. The test works in 32 bit mode (with the -n32 - compiler flag). The compiler bug has been reported to SGI. - -- zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works - when compiled with cc. - -- On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is - necessary to get gzprintf working correctly. This is done by configure. - -- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with - other compilers. Use "make test" to check your compiler. - -- gzdopen is not supported on RISCOS, BEOS and by some Mac compilers. - -- For PalmOs, see http://palmzlib.sourceforge.net/ - -- When building a shared, i.e. dynamic library on Mac OS X, the library must be - installed before testing (do "make install" before "make test"), since the - library location is specified in the library. - - -Acknowledgments: - - The deflate format used by zlib was defined by Phil Katz. The deflate - and zlib specifications were written by L. Peter Deutsch. Thanks to all the - people who reported problems and suggested various improvements in zlib; - they are too numerous to cite here. - -Copyright notice: - - (C) 1995-2004 Jean-loup Gailly and Mark Adler - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jean-loup Gailly Mark Adler - jloup@gzip.org madler@alumni.caltech.edu - -If you use the zlib library in a product, we would appreciate *not* -receiving lengthy legal documents to sign. The sources are provided -for free but without warranty of any kind. The library has been -entirely written by Jean-loup Gailly and Mark Adler; it does not -include third-party code. - -If you redistribute modified sources, we would appreciate that you include -in the file ChangeLog history information documenting your changes. Please -read the FAQ for more information on the distribution of modified source -versions. diff --git a/irrlicht-1.6/source/Irrlicht/zlib/adler32.c b/irrlicht-1.6/source/Irrlicht/zlib/adler32.c deleted file mode 100644 index f201d6701..000000000 --- a/irrlicht-1.6/source/Irrlicht/zlib/adler32.c +++ /dev/null @@ -1,149 +0,0 @@ -/* adler32.c -- compute the Adler-32 checksum of a data stream - * Copyright (C) 1995-2004 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#define ZLIB_INTERNAL -#include "zlib.h" - -#define BASE 65521UL /* largest prime smaller than 65536 */ -#define NMAX 5552 -/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ - -#define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;} -#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1); -#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2); -#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); -#define DO16(buf) DO8(buf,0); DO8(buf,8); - -/* use NO_DIVIDE if your processor does not do division in hardware */ -#ifdef NO_DIVIDE -# define MOD(a) \ - do { \ - if (a >= (BASE << 16)) a -= (BASE << 16); \ - if (a >= (BASE << 15)) a -= (BASE << 15); \ - if (a >= (BASE << 14)) a -= (BASE << 14); \ - if (a >= (BASE << 13)) a -= (BASE << 13); \ - if (a >= (BASE << 12)) a -= (BASE << 12); \ - if (a >= (BASE << 11)) a -= (BASE << 11); \ - if (a >= (BASE << 10)) a -= (BASE << 10); \ - if (a >= (BASE << 9)) a -= (BASE << 9); \ - if (a >= (BASE << 8)) a -= (BASE << 8); \ - if (a >= (BASE << 7)) a -= (BASE << 7); \ - if (a >= (BASE << 6)) a -= (BASE << 6); \ - if (a >= (BASE << 5)) a -= (BASE << 5); \ - if (a >= (BASE << 4)) a -= (BASE << 4); \ - if (a >= (BASE << 3)) a -= (BASE << 3); \ - if (a >= (BASE << 2)) a -= (BASE << 2); \ - if (a >= (BASE << 1)) a -= (BASE << 1); \ - if (a >= BASE) a -= BASE; \ - } while (0) -# define MOD4(a) \ - do { \ - if (a >= (BASE << 4)) a -= (BASE << 4); \ - if (a >= (BASE << 3)) a -= (BASE << 3); \ - if (a >= (BASE << 2)) a -= (BASE << 2); \ - if (a >= (BASE << 1)) a -= (BASE << 1); \ - if (a >= BASE) a -= BASE; \ - } while (0) -#else -# define MOD(a) a %= BASE -# define MOD4(a) a %= BASE -#endif - -/* ========================================================================= */ -uLong ZEXPORT adler32(adler, buf, len) - uLong adler; - const Bytef *buf; - uInt len; -{ - unsigned long sum2; - unsigned n; - - /* split Adler-32 into component sums */ - sum2 = (adler >> 16) & 0xffff; - adler &= 0xffff; - - /* in case user likes doing a byte at a time, keep it fast */ - if (len == 1) { - adler += buf[0]; - if (adler >= BASE) - adler -= BASE; - sum2 += adler; - if (sum2 >= BASE) - sum2 -= BASE; - return adler | (sum2 << 16); - } - - /* initial Adler-32 value (deferred check for len == 1 speed) */ - if (buf == Z_NULL) - return 1L; - - /* in case short lengths are provided, keep it somewhat fast */ - if (len < 16) { - while (len--) { - adler += *buf++; - sum2 += adler; - } - if (adler >= BASE) - adler -= BASE; - MOD4(sum2); /* only added so many BASE's */ - return adler | (sum2 << 16); - } - - /* do length NMAX blocks -- requires just one modulo operation */ - while (len >= NMAX) { - len -= NMAX; - n = NMAX / 16; /* NMAX is divisible by 16 */ - do { - DO16(buf); /* 16 sums unrolled */ - buf += 16; - } while (--n); - MOD(adler); - MOD(sum2); - } - - /* do remaining bytes (less than NMAX, still just one modulo) */ - if (len) { /* avoid modulos if none remaining */ - while (len >= 16) { - len -= 16; - DO16(buf); - buf += 16; - } - while (len--) { - adler += *buf++; - sum2 += adler; - } - MOD(adler); - MOD(sum2); - } - - /* return recombined sums */ - return adler | (sum2 << 16); -} - -/* ========================================================================= */ -uLong ZEXPORT adler32_combine(adler1, adler2, len2) - uLong adler1; - uLong adler2; - z_off_t len2; -{ - unsigned long sum1; - unsigned long sum2; - unsigned rem; - - /* the derivation of this formula is left as an exercise for the reader */ - rem = (unsigned)(len2 % BASE); - sum1 = adler1 & 0xffff; - sum2 = rem * sum1; - MOD(sum2); - sum1 += (adler2 & 0xffff) + BASE - 1; - sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem; - if (sum1 > BASE) sum1 -= BASE; - if (sum1 > BASE) sum1 -= BASE; - if (sum2 > (BASE << 1)) sum2 -= (BASE << 1); - if (sum2 > BASE) sum2 -= BASE; - return sum1 | (sum2 << 16); -} diff --git a/irrlicht-1.6/source/Irrlicht/zlib/algorithm.txt b/irrlicht-1.6/source/Irrlicht/zlib/algorithm.txt deleted file mode 100644 index 9f6b06808..000000000 --- a/irrlicht-1.6/source/Irrlicht/zlib/algorithm.txt +++ /dev/null @@ -1,209 +0,0 @@ -1. Compression algorithm (deflate) - -The deflation algorithm used by gzip (also zip and zlib) is a variation of -LZ77 (Lempel-Ziv 1977, see reference below). It finds duplicated strings in -the input data. The second occurrence of a string is replaced by a -pointer to the previous string, in the form of a pair (distance, -length). Distances are limited to 32K bytes, and lengths are limited -to 258 bytes. When a string does not occur anywhere in the previous -32K bytes, it is emitted as a sequence of literal bytes. (In this -description, `string' must be taken as an arbitrary sequence of bytes, -and is not restricted to printable characters.) - -Literals or match lengths are compressed with one Huffman tree, and -match distances are compressed with another tree. The trees are stored -in a compact form at the start of each block. The blocks can have any -size (except that the compressed data for one block must fit in -available memory). A block is terminated when deflate() determines that -it would be useful to start another block with fresh trees. (This is -somewhat similar to the behavior of LZW-based _compress_.) - -Duplicated strings are found using a hash table. All input strings of -length 3 are inserted in the hash table. A hash index is computed for -the next 3 bytes. If the hash chain for this index is not empty, all -strings in the chain are compared with the current input string, and -the longest match is selected. - -The hash chains are searched starting with the most recent strings, to -favor small distances and thus take advantage of the Huffman encoding. -The hash chains are singly linked. There are no deletions from the -hash chains, the algorithm simply discards matches that are too old. - -To avoid a worst-case situation, very long hash chains are arbitrarily -truncated at a certain length, determined by a runtime option (level -parameter of deflateInit). So deflate() does not always find the longest -possible match but generally finds a match which is long enough. - -deflate() also defers the selection of matches with a lazy evaluation -mechanism. After a match of length N has been found, deflate() searches for -a longer match at the next input byte. If a longer match is found, the -previous match is truncated to a length of one (thus producing a single -literal byte) and the process of lazy evaluation begins again. Otherwise, -the original match is kept, and the next match search is attempted only N -steps later. - -The lazy match evaluation is also subject to a runtime parameter. If -the current match is long enough, deflate() reduces the search for a longer -match, thus speeding up the whole process. If compression ratio is more -important than speed, deflate() attempts a complete second search even if -the first match is already long enough. - -The lazy match evaluation is not performed for the fastest compression -modes (level parameter 1 to 3). For these fast modes, new strings -are inserted in the hash table only when no match was found, or -when the match is not too long. This degrades the compression ratio -but saves time since there are both fewer insertions and fewer searches. - - -2. Decompression algorithm (inflate) - -2.1 Introduction - -The key question is how to represent a Huffman code (or any prefix code) so -that you can decode fast. The most important characteristic is that shorter -codes are much more common than longer codes, so pay attention to decoding the -short codes fast, and let the long codes take longer to decode. - -inflate() sets up a first level table that covers some number of bits of -input less than the length of longest code. It gets that many bits from the -stream, and looks it up in the table. The table will tell if the next -code is that many bits or less and how many, and if it is, it will tell -the value, else it will point to the next level table for which inflate() -grabs more bits and tries to decode a longer code. - -How many bits to make the first lookup is a tradeoff between the time it -takes to decode and the time it takes to build the table. If building the -table took no time (and if you had infinite memory), then there would only -be a first level table to cover all the way to the longest code. However, -building the table ends up taking a lot longer for more bits since short -codes are replicated many times in such a table. What inflate() does is -simply to make the number of bits in the first table a variable, and then -to set that variable for the maximum speed. - -For inflate, which has 286 possible codes for the literal/length tree, the size -of the first table is nine bits. Also the distance trees have 30 possible -values, and the size of the first table is six bits. Note that for each of -those cases, the table ended up one bit longer than the ``average'' code -length, i.e. the code length of an approximately flat code which would be a -little more than eight bits for 286 symbols and a little less than five bits -for 30 symbols. - - -2.2 More details on the inflate table lookup - -Ok, you want to know what this cleverly obfuscated inflate tree actually -looks like. You are correct that it's not a Huffman tree. It is simply a -lookup table for the first, let's say, nine bits of a Huffman symbol. The -symbol could be as short as one bit or as long as 15 bits. If a particular -symbol is shorter than nine bits, then that symbol's translation is duplicated -in all those entries that start with that symbol's bits. For example, if the -symbol is four bits, then it's duplicated 32 times in a nine-bit table. If a -symbol is nine bits long, it appears in the table once. - -If the symbol is longer than nine bits, then that entry in the table points -to another similar table for the remaining bits. Again, there are duplicated -entries as needed. The idea is that most of the time the symbol will be short -and there will only be one table look up. (That's whole idea behind data -compression in the first place.) For the less frequent long symbols, there -will be two lookups. If you had a compression method with really long -symbols, you could have as many levels of lookups as is efficient. For -inflate, two is enough. - -So a table entry either points to another table (in which case nine bits in -the above example are gobbled), or it contains the translation for the symbol -and the number of bits to gobble. Then you start again with the next -ungobbled bit. - -You may wonder: why not just have one lookup table for how ever many bits the -longest symbol is? The reason is that if you do that, you end up spending -more time filling in duplicate symbol entries than you do actually decoding. -At least for deflate's output that generates new trees every several 10's of -kbytes. You can imagine that filling in a 2^15 entry table for a 15-bit code -would take too long if you're only decoding several thousand symbols. At the -other extreme, you could make a new table for every bit in the code. In fact, -that's essentially a Huffman tree. But then you spend two much time -traversing the tree while decoding, even for short symbols. - -So the number of bits for the first lookup table is a trade of the time to -fill out the table vs. the time spent looking at the second level and above of -the table. - -Here is an example, scaled down: - -The code being decoded, with 10 symbols, from 1 to 6 bits long: - -A: 0 -B: 10 -C: 1100 -D: 11010 -E: 11011 -F: 11100 -G: 11101 -H: 11110 -I: 111110 -J: 111111 - -Let's make the first table three bits long (eight entries): - -000: A,1 -001: A,1 -010: A,1 -011: A,1 -100: B,2 -101: B,2 -110: -> table X (gobble 3 bits) -111: -> table Y (gobble 3 bits) - -Each entry is what the bits decode as and how many bits that is, i.e. how -many bits to gobble. Or the entry points to another table, with the number of -bits to gobble implicit in the size of the table. - -Table X is two bits long since the longest code starting with 110 is five bits -long: - -00: C,1 -01: C,1 -10: D,2 -11: E,2 - -Table Y is three bits long since the longest code starting with 111 is six -bits long: - -000: F,2 -001: F,2 -010: G,2 -011: G,2 -100: H,2 -101: H,2 -110: I,3 -111: J,3 - -So what we have here are three tables with a total of 20 entries that had to -be constructed. That's compared to 64 entries for a single table. Or -compared to 16 entries for a Huffman tree (six two entry tables and one four -entry table). Assuming that the code ideally represents the probability of -the symbols, it takes on the average 1.25 lookups per symbol. That's compared -to one lookup for the single table, or 1.66 lookups per symbol for the -Huffman tree. - -There, I think that gives you a picture of what's going on. For inflate, the -meaning of a particular symbol is often more than just a letter. It can be a -byte (a "literal"), or it can be either a length or a distance which -indicates a base value and a number of bits to fetch after the code that is -added to the base value. Or it might be the special end-of-block code. The -data structures created in inftrees.c try to encode all that information -compactly in the tables. - - -Jean-loup Gailly Mark Adler -jloup@gzip.org madler@alumni.caltech.edu - - -References: - -[LZ77] Ziv J., Lempel A., ``A Universal Algorithm for Sequential Data -Compression,'' IEEE Transactions on Information Theory, Vol. 23, No. 3, -pp. 337-343. - -``DEFLATE Compressed Data Format Specification'' available in -http://www.ietf.org/rfc/rfc1951.txt diff --git a/irrlicht-1.6/source/Irrlicht/zlib/compress.c b/irrlicht-1.6/source/Irrlicht/zlib/compress.c deleted file mode 100644 index d37e84f5e..000000000 --- a/irrlicht-1.6/source/Irrlicht/zlib/compress.c +++ /dev/null @@ -1,79 +0,0 @@ -/* compress.c -- compress a memory buffer - * Copyright (C) 1995-2003 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#define ZLIB_INTERNAL -#include "zlib.h" - -/* =========================================================================== - Compresses the source buffer into the destination buffer. The level - parameter has the same meaning as in deflateInit. sourceLen is the byte - length of the source buffer. Upon entry, destLen is the total size of the - destination buffer, which must be at least 0.1% larger than sourceLen plus - 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. - - compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_BUF_ERROR if there was not enough room in the output buffer, - Z_STREAM_ERROR if the level parameter is invalid. -*/ -int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; - int level; -{ - z_stream stream; - int err; - - stream.next_in = (Bytef*)source; - stream.avail_in = (uInt)sourceLen; -#ifdef MAXSEG_64K - /* Check for source > 64K on 16-bit machine: */ - if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; -#endif - stream.next_out = dest; - stream.avail_out = (uInt)*destLen; - if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; - - stream.zalloc = (alloc_func)0; - stream.zfree = (free_func)0; - stream.opaque = (voidpf)0; - - err = deflateInit(&stream, level); - if (err != Z_OK) return err; - - err = deflate(&stream, Z_FINISH); - if (err != Z_STREAM_END) { - deflateEnd(&stream); - return err == Z_OK ? Z_BUF_ERROR : err; - } - *destLen = stream.total_out; - - err = deflateEnd(&stream); - return err; -} - -/* =========================================================================== - */ -int ZEXPORT compress (dest, destLen, source, sourceLen) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; -{ - return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); -} - -/* =========================================================================== - If the default memLevel or windowBits for deflateInit() is changed, then - this function needs to be updated. - */ -uLong ZEXPORT compressBound (sourceLen) - uLong sourceLen; -{ - return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 11; -} diff --git a/irrlicht-1.6/source/Irrlicht/zlib/crc32.c b/irrlicht-1.6/source/Irrlicht/zlib/crc32.c deleted file mode 100644 index 32814c20c..000000000 --- a/irrlicht-1.6/source/Irrlicht/zlib/crc32.c +++ /dev/null @@ -1,423 +0,0 @@ -/* crc32.c -- compute the CRC-32 of a data stream - * Copyright (C) 1995-2005 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - * - * Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster - * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing - * tables for updating the shift register in one step with three exclusive-ors - * instead of four steps with four exclusive-ors. This results in about a - * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3. - */ - -/* @(#) $Id$ */ - -/* - Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore - protection on the static variables used to control the first-use generation - of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should - first call get_crc_table() to initialize the tables before allowing more than - one thread to use crc32(). - */ - -#ifdef MAKECRCH -# include <stdio.h> -# ifndef DYNAMIC_CRC_TABLE -# define DYNAMIC_CRC_TABLE -# endif /* !DYNAMIC_CRC_TABLE */ -#endif /* MAKECRCH */ - -#include "zutil.h" /* for STDC and FAR definitions */ - -#define local static - -/* Find a four-byte integer type for crc32_little() and crc32_big(). */ -#ifndef NOBYFOUR -# ifdef STDC /* need ANSI C limits.h to determine sizes */ -# include <limits.h> -# define BYFOUR -# if (UINT_MAX == 0xffffffffUL) - typedef unsigned int u4; -# else -# if (ULONG_MAX == 0xffffffffUL) - typedef unsigned long u4; -# else -# if (USHRT_MAX == 0xffffffffUL) - typedef unsigned short u4; -# else -# undef BYFOUR /* can't find a four-byte integer type! */ -# endif -# endif -# endif -# endif /* STDC */ -#endif /* !NOBYFOUR */ - -/* Definitions for doing the crc four data bytes at a time. */ -#ifdef BYFOUR -# define REV(w) (((w)>>24)+(((w)>>8)&0xff00)+ \ - (((w)&0xff00)<<8)+(((w)&0xff)<<24)) - local unsigned long crc32_little OF((unsigned long, - const unsigned char FAR *, unsigned)); - local unsigned long crc32_big OF((unsigned long, - const unsigned char FAR *, unsigned)); -# define TBLS 8 -#else -# define TBLS 1 -#endif /* BYFOUR */ - -/* Local functions for crc concatenation */ -local unsigned long gf2_matrix_times OF((unsigned long *mat, - unsigned long vec)); -local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat)); - -#ifdef DYNAMIC_CRC_TABLE - -local volatile int crc_table_empty = 1; -local unsigned long FAR crc_table[TBLS][256]; -local void make_crc_table OF((void)); -#ifdef MAKECRCH - local void write_table OF((FILE *, const unsigned long FAR *)); -#endif /* MAKECRCH */ -/* - Generate tables for a byte-wise 32-bit CRC calculation on the polynomial: - x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. - - Polynomials over GF(2) are represented in binary, one bit per coefficient, - with the lowest powers in the most significant bit. Then adding polynomials - is just exclusive-or, and multiplying a polynomial by x is a right shift by - one. If we call the above polynomial p, and represent a byte as the - polynomial q, also with the lowest power in the most significant bit (so the - byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, - where a mod b means the remainder after dividing a by b. - - This calculation is done using the shift-register method of multiplying and - taking the remainder. The register is initialized to zero, and for each - incoming bit, x^32 is added mod p to the register if the bit is a one (where - x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by - x (which is shifting right by one and adding x^32 mod p if the bit shifted - out is a one). We start with the highest power (least significant bit) of - q and repeat for all eight bits of q. - - The first table is simply the CRC of all possible eight bit values. This is - all the information needed to generate CRCs on data a byte at a time for all - combinations of CRC register values and incoming bytes. The remaining tables - allow for word-at-a-time CRC calculation for both big-endian and little- - endian machines, where a word is four bytes. -*/ -local void make_crc_table() -{ - unsigned long c; - int n, k; - unsigned long poly; /* polynomial exclusive-or pattern */ - /* terms of polynomial defining this crc (except x^32): */ - static volatile int first = 1; /* flag to limit concurrent making */ - static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; - - /* See if another task is already doing this (not thread-safe, but better - than nothing -- significantly reduces duration of vulnerability in - case the advice about DYNAMIC_CRC_TABLE is ignored) */ - if (first) { - first = 0; - - /* make exclusive-or pattern from polynomial (0xedb88320UL) */ - poly = 0UL; - for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++) - poly |= 1UL << (31 - p[n]); - - /* generate a crc for every 8-bit value */ - for (n = 0; n < 256; n++) { - c = (unsigned long)n; - for (k = 0; k < 8; k++) - c = c & 1 ? poly ^ (c >> 1) : c >> 1; - crc_table[0][n] = c; - } - -#ifdef BYFOUR - /* generate crc for each value followed by one, two, and three zeros, - and then the byte reversal of those as well as the first table */ - for (n = 0; n < 256; n++) { - c = crc_table[0][n]; - crc_table[4][n] = REV(c); - for (k = 1; k < 4; k++) { - c = crc_table[0][c & 0xff] ^ (c >> 8); - crc_table[k][n] = c; - crc_table[k + 4][n] = REV(c); - } - } -#endif /* BYFOUR */ - - crc_table_empty = 0; - } - else { /* not first */ - /* wait for the other guy to finish (not efficient, but rare) */ - while (crc_table_empty) - ; - } - -#ifdef MAKECRCH - /* write out CRC tables to crc32.h */ - { - FILE *out; - - out = fopen("crc32.h", "w"); - if (out == NULL) return; - fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n"); - fprintf(out, " * Generated automatically by crc32.c\n */\n\n"); - fprintf(out, "local const unsigned long FAR "); - fprintf(out, "crc_table[TBLS][256] =\n{\n {\n"); - write_table(out, crc_table[0]); -# ifdef BYFOUR - fprintf(out, "#ifdef BYFOUR\n"); - for (k = 1; k < 8; k++) { - fprintf(out, " },\n {\n"); - write_table(out, crc_table[k]); - } - fprintf(out, "#endif\n"); -# endif /* BYFOUR */ - fprintf(out, " }\n};\n"); - fclose(out); - } -#endif /* MAKECRCH */ -} - -#ifdef MAKECRCH -local void write_table(out, table) - FILE *out; - const unsigned long FAR *table; -{ - int n; - - for (n = 0; n < 256; n++) - fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", table[n], - n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", ")); -} -#endif /* MAKECRCH */ - -#else /* !DYNAMIC_CRC_TABLE */ -/* ======================================================================== - * Tables of CRC-32s of all single-byte values, made by make_crc_table(). - */ -#include "crc32.h" -#endif /* DYNAMIC_CRC_TABLE */ - -/* ========================================================================= - * This function can be used by asm versions of crc32() - */ -const unsigned long FAR * ZEXPORT get_crc_table() -{ -#ifdef DYNAMIC_CRC_TABLE - if (crc_table_empty) - make_crc_table(); -#endif /* DYNAMIC_CRC_TABLE */ - return (const unsigned long FAR *)crc_table; -} - -/* ========================================================================= */ -#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8) -#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1 - -/* ========================================================================= */ -unsigned long ZEXPORT crc32(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - unsigned len; -{ - if (buf == Z_NULL) return 0UL; - -#ifdef DYNAMIC_CRC_TABLE - if (crc_table_empty) - make_crc_table(); -#endif /* DYNAMIC_CRC_TABLE */ - -#ifdef BYFOUR - if (sizeof(void *) == sizeof(ptrdiff_t)) { - u4 endian; - - endian = 1; - if (*((unsigned char *)(&endian))) - return crc32_little(crc, buf, len); - else - return crc32_big(crc, buf, len); - } -#endif /* BYFOUR */ - crc = crc ^ 0xffffffffUL; - while (len >= 8) { - DO8; - len -= 8; - } - if (len) do { - DO1; - } while (--len); - return crc ^ 0xffffffffUL; -} - -#ifdef BYFOUR - -/* ========================================================================= */ -#define DOLIT4 c ^= *buf4++; \ - c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \ - crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24] -#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4 - -/* ========================================================================= */ -local unsigned long crc32_little(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - unsigned len; -{ - register u4 c; - register const u4 FAR *buf4; - - c = (u4)crc; - c = ~c; - while (len && ((ptrdiff_t)buf & 3)) { - c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); - len--; - } - - buf4 = (const u4 FAR *)(const void FAR *)buf; - while (len >= 32) { - DOLIT32; - len -= 32; - } - while (len >= 4) { - DOLIT4; - len -= 4; - } - buf = (const unsigned char FAR *)buf4; - - if (len) do { - c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); - } while (--len); - c = ~c; - return (unsigned long)c; -} - -/* ========================================================================= */ -#define DOBIG4 c ^= *++buf4; \ - c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \ - crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24] -#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4 - -/* ========================================================================= */ -local unsigned long crc32_big(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - unsigned len; -{ - register u4 c; - register const u4 FAR *buf4; - - c = REV((u4)crc); - c = ~c; - while (len && ((ptrdiff_t)buf & 3)) { - c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); - len--; - } - - buf4 = (const u4 FAR *)(const void FAR *)buf; - buf4--; - while (len >= 32) { - DOBIG32; - len -= 32; - } - while (len >= 4) { - DOBIG4; - len -= 4; - } - buf4++; - buf = (const unsigned char FAR *)buf4; - - if (len) do { - c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); - } while (--len); - c = ~c; - return (unsigned long)(REV(c)); -} - -#endif /* BYFOUR */ - -#define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */ - -/* ========================================================================= */ -local unsigned long gf2_matrix_times(mat, vec) - unsigned long *mat; - unsigned long vec; -{ - unsigned long sum; - - sum = 0; - while (vec) { - if (vec & 1) - sum ^= *mat; - vec >>= 1; - mat++; - } - return sum; -} - -/* ========================================================================= */ -local void gf2_matrix_square(square, mat) - unsigned long *square; - unsigned long *mat; -{ - int n; - - for (n = 0; n < GF2_DIM; n++) - square[n] = gf2_matrix_times(mat, mat[n]); -} - -/* ========================================================================= */ -uLong ZEXPORT crc32_combine(crc1, crc2, len2) - uLong crc1; - uLong crc2; - z_off_t len2; -{ - int n; - unsigned long row; - unsigned long even[GF2_DIM]; /* even-power-of-two zeros operator */ - unsigned long odd[GF2_DIM]; /* odd-power-of-two zeros operator */ - - /* degenerate case */ - if (len2 == 0) - return crc1; - - /* put operator for one zero bit in odd */ - odd[0] = 0xedb88320L; /* CRC-32 polynomial */ - row = 1; - for (n = 1; n < GF2_DIM; n++) { - odd[n] = row; - row <<= 1; - } - - /* put operator for two zero bits in even */ - gf2_matrix_square(even, odd); - - /* put operator for four zero bits in odd */ - gf2_matrix_square(odd, even); - - /* apply len2 zeros to crc1 (first square will put the operator for one - zero byte, eight zero bits, in even) */ - do { - /* apply zeros operator for this bit of len2 */ - gf2_matrix_square(even, odd); - if (len2 & 1) - crc1 = gf2_matrix_times(even, crc1); - len2 >>= 1; - - /* if no more bits set, then done */ - if (len2 == 0) - break; - - /* another iteration of the loop with odd and even swapped */ - gf2_matrix_square(odd, even); - if (len2 & 1) - crc1 = gf2_matrix_times(odd, crc1); - len2 >>= 1; - - /* if no more bits set, then done */ - } while (len2 != 0); - - /* return combined crc */ - crc1 ^= crc2; - return crc1; -} diff --git a/irrlicht-1.6/source/Irrlicht/zlib/crc32.h b/irrlicht-1.6/source/Irrlicht/zlib/crc32.h deleted file mode 100644 index 5de49bc97..000000000 --- a/irrlicht-1.6/source/Irrlicht/zlib/crc32.h +++ /dev/null @@ -1,441 +0,0 @@ -/* crc32.h -- tables for rapid CRC calculation - * Generated automatically by crc32.c - */ - -local const unsigned long FAR crc_table[TBLS][256] = -{ - { - 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL, - 0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL, - 0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL, - 0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL, - 0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL, - 0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL, - 0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL, - 0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL, - 0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL, - 0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL, - 0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL, - 0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL, - 0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL, - 0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL, - 0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL, - 0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL, - 0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL, - 0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL, - 0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL, - 0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL, - 0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL, - 0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL, - 0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL, - 0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL, - 0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL, - 0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL, - 0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL, - 0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL, - 0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL, - 0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL, - 0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL, - 0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL, - 0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL, - 0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL, - 0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL, - 0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL, - 0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL, - 0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL, - 0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL, - 0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL, - 0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL, - 0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL, - 0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL, - 0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL, - 0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL, - 0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL, - 0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL, - 0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL, - 0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL, - 0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL, - 0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL, - 0x2d02ef8dUL -#ifdef BYFOUR - }, - { - 0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL, - 0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL, - 0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL, - 0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL, - 0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL, - 0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL, - 0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL, - 0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL, - 0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL, - 0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL, - 0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL, - 0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL, - 0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL, - 0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL, - 0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL, - 0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL, - 0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL, - 0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL, - 0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL, - 0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL, - 0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL, - 0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL, - 0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL, - 0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL, - 0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL, - 0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL, - 0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL, - 0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL, - 0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL, - 0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL, - 0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL, - 0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL, - 0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL, - 0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL, - 0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL, - 0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL, - 0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL, - 0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL, - 0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL, - 0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL, - 0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL, - 0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL, - 0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL, - 0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL, - 0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL, - 0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL, - 0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL, - 0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL, - 0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL, - 0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL, - 0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL, - 0x9324fd72UL - }, - { - 0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL, - 0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL, - 0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL, - 0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL, - 0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL, - 0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL, - 0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL, - 0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL, - 0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL, - 0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL, - 0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL, - 0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL, - 0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL, - 0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL, - 0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL, - 0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL, - 0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL, - 0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL, - 0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL, - 0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL, - 0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL, - 0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL, - 0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL, - 0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL, - 0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL, - 0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL, - 0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL, - 0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL, - 0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL, - 0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL, - 0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL, - 0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL, - 0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL, - 0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL, - 0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL, - 0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL, - 0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL, - 0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL, - 0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL, - 0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL, - 0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL, - 0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL, - 0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL, - 0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL, - 0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL, - 0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL, - 0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL, - 0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL, - 0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL, - 0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL, - 0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL, - 0xbe9834edUL - }, - { - 0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL, - 0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL, - 0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL, - 0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL, - 0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL, - 0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL, - 0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL, - 0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL, - 0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL, - 0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL, - 0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL, - 0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL, - 0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL, - 0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL, - 0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL, - 0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL, - 0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL, - 0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL, - 0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL, - 0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL, - 0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL, - 0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL, - 0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL, - 0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL, - 0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL, - 0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL, - 0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL, - 0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL, - 0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL, - 0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL, - 0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL, - 0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL, - 0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL, - 0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL, - 0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL, - 0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL, - 0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL, - 0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL, - 0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL, - 0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL, - 0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL, - 0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL, - 0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL, - 0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL, - 0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL, - 0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL, - 0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL, - 0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL, - 0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL, - 0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL, - 0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL, - 0xde0506f1UL - }, - { - 0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL, - 0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL, - 0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL, - 0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL, - 0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL, - 0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL, - 0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL, - 0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL, - 0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL, - 0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL, - 0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL, - 0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL, - 0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL, - 0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL, - 0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL, - 0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL, - 0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL, - 0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL, - 0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL, - 0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL, - 0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL, - 0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL, - 0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL, - 0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL, - 0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL, - 0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL, - 0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL, - 0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL, - 0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL, - 0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL, - 0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL, - 0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL, - 0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL, - 0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL, - 0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL, - 0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL, - 0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL, - 0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL, - 0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL, - 0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL, - 0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL, - 0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL, - 0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL, - 0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL, - 0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL, - 0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL, - 0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL, - 0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL, - 0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL, - 0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL, - 0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL, - 0x8def022dUL - }, - { - 0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL, - 0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL, - 0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL, - 0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL, - 0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL, - 0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL, - 0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL, - 0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL, - 0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL, - 0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL, - 0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL, - 0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL, - 0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL, - 0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL, - 0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL, - 0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL, - 0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL, - 0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL, - 0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL, - 0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL, - 0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL, - 0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL, - 0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL, - 0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL, - 0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL, - 0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL, - 0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL, - 0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL, - 0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL, - 0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL, - 0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL, - 0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL, - 0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL, - 0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL, - 0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL, - 0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL, - 0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL, - 0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL, - 0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL, - 0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL, - 0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL, - 0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL, - 0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL, - 0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL, - 0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL, - 0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL, - 0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL, - 0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL, - 0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL, - 0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL, - 0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL, - 0x72fd2493UL - }, - { - 0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL, - 0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL, - 0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL, - 0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL, - 0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL, - 0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL, - 0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL, - 0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL, - 0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL, - 0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL, - 0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL, - 0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL, - 0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL, - 0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL, - 0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL, - 0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL, - 0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL, - 0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL, - 0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL, - 0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL, - 0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL, - 0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL, - 0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL, - 0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL, - 0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL, - 0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL, - 0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL, - 0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL, - 0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL, - 0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL, - 0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL, - 0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL, - 0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL, - 0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL, - 0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL, - 0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL, - 0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL, - 0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL, - 0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL, - 0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL, - 0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL, - 0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL, - 0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL, - 0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL, - 0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL, - 0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL, - 0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL, - 0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL, - 0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL, - 0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL, - 0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL, - 0xed3498beUL - }, - { - 0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL, - 0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL, - 0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL, - 0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL, - 0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL, - 0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL, - 0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL, - 0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL, - 0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL, - 0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL, - 0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL, - 0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL, - 0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL, - 0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL, - 0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL, - 0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL, - 0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL, - 0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL, - 0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL, - 0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL, - 0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL, - 0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL, - 0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL, - 0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL, - 0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL, - 0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL, - 0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL, - 0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL, - 0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL, - 0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL, - 0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL, - 0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL, - 0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL, - 0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL, - 0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL, - 0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL, - 0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL, - 0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL, - 0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL, - 0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL, - 0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL, - 0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL, - 0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL, - 0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL, - 0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL, - 0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL, - 0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL, - 0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL, - 0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL, - 0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL, - 0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL, - 0xf10605deUL -#endif - } -}; diff --git a/irrlicht-1.6/source/Irrlicht/zlib/deflate.c b/irrlicht-1.6/source/Irrlicht/zlib/deflate.c deleted file mode 100644 index 529f716b7..000000000 --- a/irrlicht-1.6/source/Irrlicht/zlib/deflate.c +++ /dev/null @@ -1,1736 +0,0 @@ -/* deflate.c -- compress data using the deflation algorithm - * Copyright (C) 1995-2005 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* - * ALGORITHM - * - * The "deflation" process depends on being able to identify portions - * of the input text which are identical to earlier input (within a - * sliding window trailing behind the input currently being processed). - * - * The most straightforward technique turns out to be the fastest for - * most input files: try all possible matches and select the longest. - * The key feature of this algorithm is that insertions into the string - * dictionary are very simple and thus fast, and deletions are avoided - * completely. Insertions are performed at each input character, whereas - * string matches are performed only when the previous match ends. So it - * is preferable to spend more time in matches to allow very fast string - * insertions and avoid deletions. The matching algorithm for small - * strings is inspired from that of Rabin & Karp. A brute force approach - * is used to find longer strings when a small match has been found. - * A similar algorithm is used in comic (by Jan-Mark Wams) and freeze - * (by Leonid Broukhis). - * A previous version of this file used a more sophisticated algorithm - * (by Fiala and Greene) which is guaranteed to run in linear amortized - * time, but has a larger average cost, uses more memory and is patented. - * However the F&G algorithm may be faster for some highly redundant - * files if the parameter max_chain_length (described below) is too large. - * - * ACKNOWLEDGEMENTS - * - * The idea of lazy evaluation of matches is due to Jan-Mark Wams, and - * I found it in 'freeze' written by Leonid Broukhis. - * Thanks to many people for bug reports and testing. - * - * REFERENCES - * - * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification". - * Available in http://www.ietf.org/rfc/rfc1951.txt - * - * A description of the Rabin and Karp algorithm is given in the book - * "Algorithms" by R. Sedgewick, Addison-Wesley, p252. - * - * Fiala,E.R., and Greene,D.H. - * Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595 - * - */ - -/* @(#) $Id$ */ - -#include "deflate.h" - -const char deflate_copyright[] = - " deflate 1.2.3 Copyright 1995-2005 Jean-loup Gailly "; -/* - If you use the zlib library in a product, an acknowledgment is welcome - in the documentation of your product. If for some reason you cannot - include such an acknowledgment, I would appreciate that you keep this - copyright string in the executable of your product. - */ - -/* =========================================================================== - * Function prototypes. - */ -typedef enum { - need_more, /* block not completed, need more input or more output */ - block_done, /* block flush performed */ - finish_started, /* finish started, need only more output at next deflate */ - finish_done /* finish done, accept no more input or output */ -} block_state; - -typedef block_state (*compress_func) OF((deflate_state *s, int flush)); -/* Compression function. Returns the block state after the call. */ - -local void fill_window OF((deflate_state *s)); -local block_state deflate_stored OF((deflate_state *s, int flush)); -local block_state deflate_fast OF((deflate_state *s, int flush)); -#ifndef FASTEST -local block_state deflate_slow OF((deflate_state *s, int flush)); -#endif -local void lm_init OF((deflate_state *s)); -local void putShortMSB OF((deflate_state *s, uInt b)); -local void flush_pending OF((z_streamp strm)); -local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size)); -#ifndef FASTEST -#ifdef ASMV - void match_init OF((void)); /* asm code initialization */ - uInt longest_match OF((deflate_state *s, IPos cur_match)); -#else -local uInt longest_match OF((deflate_state *s, IPos cur_match)); -#endif -#endif -local uInt longest_match_fast OF((deflate_state *s, IPos cur_match)); - -#ifdef DEBUG -local void check_match OF((deflate_state *s, IPos start, IPos match, - int length)); -#endif - -/* =========================================================================== - * Local data - */ - -#define NIL 0 -/* Tail of hash chains */ - -#ifndef TOO_FAR -# define TOO_FAR 4096 -#endif -/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */ - -#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) -/* Minimum amount of lookahead, except at the end of the input file. - * See deflate.c for comments about the MIN_MATCH+1. - */ - -/* Values for max_lazy_match, good_match and max_chain_length, depending on - * the desired pack level (0..9). The values given below have been tuned to - * exclude worst case performance for pathological files. Better values may be - * found for specific files. - */ -typedef struct config_s { - ush good_length; /* reduce lazy search above this match length */ - ush max_lazy; /* do not perform lazy search above this match length */ - ush nice_length; /* quit search above this match length */ - ush max_chain; - compress_func func; -} config; - -#ifdef FASTEST -local const config configuration_table[2] = { -/* good lazy nice chain */ -/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */ -/* 1 */ {4, 4, 8, 4, deflate_fast}}; /* max speed, no lazy matches */ -#else -local const config configuration_table[10] = { -/* good lazy nice chain */ -/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */ -/* 1 */ {4, 4, 8, 4, deflate_fast}, /* max speed, no lazy matches */ -/* 2 */ {4, 5, 16, 8, deflate_fast}, -/* 3 */ {4, 6, 32, 32, deflate_fast}, - -/* 4 */ {4, 4, 16, 16, deflate_slow}, /* lazy matches */ -/* 5 */ {8, 16, 32, 32, deflate_slow}, -/* 6 */ {8, 16, 128, 128, deflate_slow}, -/* 7 */ {8, 32, 128, 256, deflate_slow}, -/* 8 */ {32, 128, 258, 1024, deflate_slow}, -/* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* max compression */ -#endif - -/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4 - * For deflate_fast() (levels <= 3) good is ignored and lazy has a different - * meaning. - */ - -#define EQUAL 0 -/* result of memcmp for equal strings */ - -#ifndef NO_DUMMY_DECL -struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ -#endif - -/* =========================================================================== - * Update a hash value with the given input byte - * IN assertion: all calls to to UPDATE_HASH are made with consecutive - * input characters, so that a running hash key can be computed from the - * previous key instead of complete recalculation each time. - */ -#define UPDATE_HASH(s,h,c) (h = (((h)<<s->hash_shift) ^ (c)) & s->hash_mask) - - -/* =========================================================================== - * Insert string str in the dictionary and set match_head to the previous head - * of the hash chain (the most recent string with same hash key). Return - * the previous length of the hash chain. - * If this file is compiled with -DFASTEST, the compression level is forced - * to 1, and no hash chains are maintained. - * IN assertion: all calls to to INSERT_STRING are made with consecutive - * input characters and the first MIN_MATCH bytes of str are valid - * (except for the last MIN_MATCH-1 bytes of the input file). - */ -#ifdef FASTEST -#define INSERT_STRING(s, str, match_head) \ - (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ - match_head = s->head[s->ins_h], \ - s->head[s->ins_h] = (Pos)(str)) -#else -#define INSERT_STRING(s, str, match_head) \ - (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ - match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \ - s->head[s->ins_h] = (Pos)(str)) -#endif - -/* =========================================================================== - * Initialize the hash table (avoiding 64K overflow for 16 bit systems). - * prev[] will be initialized on the fly. - */ -#define CLEAR_HASH(s) \ - s->head[s->hash_size-1] = NIL; \ - zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head)); - -/* ========================================================================= */ -int ZEXPORT deflateInit_(strm, level, version, stream_size) - z_streamp strm; - int level; - const char *version; - int stream_size; -{ - return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, - Z_DEFAULT_STRATEGY, version, stream_size); - /* To do: ignore strm->next_in if we use it as window */ -} - -/* ========================================================================= */ -int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, - version, stream_size) - z_streamp strm; - int level; - int method; - int windowBits; - int memLevel; - int strategy; - const char *version; - int stream_size; -{ - deflate_state *s; - int wrap = 1; - static const char my_version[] = ZLIB_VERSION; - - ushf *overlay; - /* We overlay pending_buf and d_buf+l_buf. This works since the average - * output size for (length,distance) codes is <= 24 bits. - */ - - if (version == Z_NULL || version[0] != my_version[0] || - stream_size != sizeof(z_stream)) { - return Z_VERSION_ERROR; - } - if (strm == Z_NULL) return Z_STREAM_ERROR; - - strm->msg = Z_NULL; - if (strm->zalloc == (alloc_func)0) { - strm->zalloc = zcalloc; - strm->opaque = (voidpf)0; - } - if (strm->zfree == (free_func)0) strm->zfree = zcfree; - -#ifdef FASTEST - if (level != 0) level = 1; -#else - if (level == Z_DEFAULT_COMPRESSION) level = 6; -#endif - - if (windowBits < 0) { /* suppress zlib wrapper */ - wrap = 0; - windowBits = -windowBits; - } -#ifdef GZIP - else if (windowBits > 15) { - wrap = 2; /* write gzip wrapper instead */ - windowBits -= 16; - } -#endif - if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED || - windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || - strategy < 0 || strategy > Z_FIXED) { - return Z_STREAM_ERROR; - } - if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */ - s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state)); - if (s == Z_NULL) return Z_MEM_ERROR; - strm->state = (struct internal_state FAR *)s; - s->strm = strm; - - s->wrap = wrap; - s->gzhead = Z_NULL; - s->w_bits = windowBits; - s->w_size = 1 << s->w_bits; - s->w_mask = s->w_size - 1; - - s->hash_bits = memLevel + 7; - s->hash_size = 1 << s->hash_bits; - s->hash_mask = s->hash_size - 1; - s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH); - - s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte)); - s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos)); - s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos)); - - s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */ - - overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2); - s->pending_buf = (uchf *) overlay; - s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L); - - if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || - s->pending_buf == Z_NULL) { - s->status = FINISH_STATE; - strm->msg = (char*)ERR_MSG(Z_MEM_ERROR); - deflateEnd (strm); - return Z_MEM_ERROR; - } - s->d_buf = overlay + s->lit_bufsize/sizeof(ush); - s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize; - - s->level = level; - s->strategy = strategy; - s->method = (Byte)method; - - return deflateReset(strm); -} - -/* ========================================================================= */ -int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) - z_streamp strm; - const Bytef *dictionary; - uInt dictLength; -{ - deflate_state *s; - uInt length = dictLength; - uInt n; - IPos hash_head = 0; - - if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL || - strm->state->wrap == 2 || - (strm->state->wrap == 1 && strm->state->status != INIT_STATE)) - return Z_STREAM_ERROR; - - s = strm->state; - if (s->wrap) - strm->adler = adler32(strm->adler, dictionary, dictLength); - - if (length < MIN_MATCH) return Z_OK; - if (length > MAX_DIST(s)) { - length = MAX_DIST(s); - dictionary += dictLength - length; /* use the tail of the dictionary */ - } - zmemcpy(s->window, dictionary, length); - s->strstart = length; - s->block_start = (long)length; - - /* Insert all strings in the hash table (except for the last two bytes). - * s->lookahead stays null, so s->ins_h will be recomputed at the next - * call of fill_window. - */ - s->ins_h = s->window[0]; - UPDATE_HASH(s, s->ins_h, s->window[1]); - for (n = 0; n <= length - MIN_MATCH; n++) { - INSERT_STRING(s, n, hash_head); - } - if (hash_head) hash_head = 0; /* to make compiler happy */ - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflateReset (strm) - z_streamp strm; -{ - deflate_state *s; - - if (strm == Z_NULL || strm->state == Z_NULL || - strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) { - return Z_STREAM_ERROR; - } - - strm->total_in = strm->total_out = 0; - strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */ - strm->data_type = Z_UNKNOWN; - - s = (deflate_state *)strm->state; - s->pending = 0; - s->pending_out = s->pending_buf; - - if (s->wrap < 0) { - s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */ - } - s->status = s->wrap ? INIT_STATE : BUSY_STATE; - strm->adler = -#ifdef GZIP - s->wrap == 2 ? crc32(0L, Z_NULL, 0) : -#endif - adler32(0L, Z_NULL, 0); - s->last_flush = Z_NO_FLUSH; - - _tr_init(s); - lm_init(s); - - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflateSetHeader (strm, head) - z_streamp strm; - gz_headerp head; -{ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - if (strm->state->wrap != 2) return Z_STREAM_ERROR; - strm->state->gzhead = head; - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflatePrime (strm, bits, value) - z_streamp strm; - int bits; - int value; -{ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - strm->state->bi_valid = bits; - strm->state->bi_buf = (ush)(value & ((1 << bits) - 1)); - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflateParams(strm, level, strategy) - z_streamp strm; - int level; - int strategy; -{ - deflate_state *s; - compress_func func; - int err = Z_OK; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - s = strm->state; - -#ifdef FASTEST - if (level != 0) level = 1; -#else - if (level == Z_DEFAULT_COMPRESSION) level = 6; -#endif - if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) { - return Z_STREAM_ERROR; - } - func = configuration_table[s->level].func; - - if (func != configuration_table[level].func && strm->total_in != 0) { - /* Flush the last buffer: */ - err = deflate(strm, Z_PARTIAL_FLUSH); - } - if (s->level != level) { - s->level = level; - s->max_lazy_match = configuration_table[level].max_lazy; - s->good_match = configuration_table[level].good_length; - s->nice_match = configuration_table[level].nice_length; - s->max_chain_length = configuration_table[level].max_chain; - } - s->strategy = strategy; - return err; -} - -/* ========================================================================= */ -int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain) - z_streamp strm; - int good_length; - int max_lazy; - int nice_length; - int max_chain; -{ - deflate_state *s; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - s = strm->state; - s->good_match = good_length; - s->max_lazy_match = max_lazy; - s->nice_match = nice_length; - s->max_chain_length = max_chain; - return Z_OK; -} - -/* ========================================================================= - * For the default windowBits of 15 and memLevel of 8, this function returns - * a close to exact, as well as small, upper bound on the compressed size. - * They are coded as constants here for a reason--if the #define's are - * changed, then this function needs to be changed as well. The return - * value for 15 and 8 only works for those exact settings. - * - * For any setting other than those defaults for windowBits and memLevel, - * the value returned is a conservative worst case for the maximum expansion - * resulting from using fixed blocks instead of stored blocks, which deflate - * can emit on compressed data for some combinations of the parameters. - * - * This function could be more sophisticated to provide closer upper bounds - * for every combination of windowBits and memLevel, as well as wrap. - * But even the conservative upper bound of about 14% expansion does not - * seem onerous for output buffer allocation. - */ -uLong ZEXPORT deflateBound(strm, sourceLen) - z_streamp strm; - uLong sourceLen; -{ - deflate_state *s; - uLong destLen; - - /* conservative upper bound */ - destLen = sourceLen + - ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 11; - - /* if can't get parameters, return conservative bound */ - if (strm == Z_NULL || strm->state == Z_NULL) - return destLen; - - /* if not default parameters, return conservative bound */ - s = strm->state; - if (s->w_bits != 15 || s->hash_bits != 8 + 7) - return destLen; - - /* default settings: return tight bound for that case */ - return compressBound(sourceLen); -} - -/* ========================================================================= - * Put a short in the pending buffer. The 16-bit value is put in MSB order. - * IN assertion: the stream state is correct and there is enough room in - * pending_buf. - */ -local void putShortMSB (s, b) - deflate_state *s; - uInt b; -{ - put_byte(s, (Byte)(b >> 8)); - put_byte(s, (Byte)(b & 0xff)); -} - -/* ========================================================================= - * Flush as much pending output as possible. All deflate() output goes - * through this function so some applications may wish to modify it - * to avoid allocating a large strm->next_out buffer and copying into it. - * (See also read_buf()). - */ -local void flush_pending(strm) - z_streamp strm; -{ - unsigned len = strm->state->pending; - - if (len > strm->avail_out) len = strm->avail_out; - if (len == 0) return; - - zmemcpy(strm->next_out, strm->state->pending_out, len); - strm->next_out += len; - strm->state->pending_out += len; - strm->total_out += len; - strm->avail_out -= len; - strm->state->pending -= len; - if (strm->state->pending == 0) { - strm->state->pending_out = strm->state->pending_buf; - } -} - -/* ========================================================================= */ -int ZEXPORT deflate (strm, flush) - z_streamp strm; - int flush; -{ - int old_flush; /* value of flush param for previous deflate call */ - deflate_state *s; - - if (strm == Z_NULL || strm->state == Z_NULL || - flush > Z_FINISH || flush < 0) { - return Z_STREAM_ERROR; - } - s = strm->state; - - if (strm->next_out == Z_NULL || - (strm->next_in == Z_NULL && strm->avail_in != 0) || - (s->status == FINISH_STATE && flush != Z_FINISH)) { - ERR_RETURN(strm, Z_STREAM_ERROR); - } - if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR); - - s->strm = strm; /* just in case */ - old_flush = s->last_flush; - s->last_flush = flush; - - /* Write the header */ - if (s->status == INIT_STATE) { -#ifdef GZIP - if (s->wrap == 2) { - strm->adler = crc32(0L, Z_NULL, 0); - put_byte(s, 31); - put_byte(s, 139); - put_byte(s, 8); - if (s->gzhead == NULL) { - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, s->level == 9 ? 2 : - (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? - 4 : 0)); - put_byte(s, OS_CODE); - s->status = BUSY_STATE; - } - else { - put_byte(s, (s->gzhead->text ? 1 : 0) + - (s->gzhead->hcrc ? 2 : 0) + - (s->gzhead->extra == Z_NULL ? 0 : 4) + - (s->gzhead->name == Z_NULL ? 0 : 8) + - (s->gzhead->comment == Z_NULL ? 0 : 16) - ); - put_byte(s, (Byte)(s->gzhead->time & 0xff)); - put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff)); - put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff)); - put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff)); - put_byte(s, s->level == 9 ? 2 : - (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? - 4 : 0)); - put_byte(s, s->gzhead->os & 0xff); - if (s->gzhead->extra != NULL) { - put_byte(s, s->gzhead->extra_len & 0xff); - put_byte(s, (s->gzhead->extra_len >> 8) & 0xff); - } - if (s->gzhead->hcrc) - strm->adler = crc32(strm->adler, s->pending_buf, - s->pending); - s->gzindex = 0; - s->status = EXTRA_STATE; - } - } - else -#endif - { - uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8; - uInt level_flags; - - if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2) - level_flags = 0; - else if (s->level < 6) - level_flags = 1; - else if (s->level == 6) - level_flags = 2; - else - level_flags = 3; - header |= (level_flags << 6); - if (s->strstart != 0) header |= PRESET_DICT; - header += 31 - (header % 31); - - s->status = BUSY_STATE; - putShortMSB(s, header); - - /* Save the adler32 of the preset dictionary: */ - if (s->strstart != 0) { - putShortMSB(s, (uInt)(strm->adler >> 16)); - putShortMSB(s, (uInt)(strm->adler & 0xffff)); - } - strm->adler = adler32(0L, Z_NULL, 0); - } - } -#ifdef GZIP - if (s->status == EXTRA_STATE) { - if (s->gzhead->extra != NULL) { - uInt beg = s->pending; /* start of bytes to update crc */ - - while (s->gzindex < (s->gzhead->extra_len & 0xffff)) { - if (s->pending == s->pending_buf_size) { - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - flush_pending(strm); - beg = s->pending; - if (s->pending == s->pending_buf_size) - break; - } - put_byte(s, s->gzhead->extra[s->gzindex]); - s->gzindex++; - } - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - if (s->gzindex == s->gzhead->extra_len) { - s->gzindex = 0; - s->status = NAME_STATE; - } - } - else - s->status = NAME_STATE; - } - if (s->status == NAME_STATE) { - if (s->gzhead->name != NULL) { - uInt beg = s->pending; /* start of bytes to update crc */ - int val; - - do { - if (s->pending == s->pending_buf_size) { - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - flush_pending(strm); - beg = s->pending; - if (s->pending == s->pending_buf_size) { - val = 1; - break; - } - } - val = s->gzhead->name[s->gzindex++]; - put_byte(s, val); - } while (val != 0); - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - if (val == 0) { - s->gzindex = 0; - s->status = COMMENT_STATE; - } - } - else - s->status = COMMENT_STATE; - } - if (s->status == COMMENT_STATE) { - if (s->gzhead->comment != NULL) { - uInt beg = s->pending; /* start of bytes to update crc */ - int val; - - do { - if (s->pending == s->pending_buf_size) { - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - flush_pending(strm); - beg = s->pending; - if (s->pending == s->pending_buf_size) { - val = 1; - break; - } - } - val = s->gzhead->comment[s->gzindex++]; - put_byte(s, val); - } while (val != 0); - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - if (val == 0) - s->status = HCRC_STATE; - } - else - s->status = HCRC_STATE; - } - if (s->status == HCRC_STATE) { - if (s->gzhead->hcrc) { - if (s->pending + 2 > s->pending_buf_size) - flush_pending(strm); - if (s->pending + 2 <= s->pending_buf_size) { - put_byte(s, (Byte)(strm->adler & 0xff)); - put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); - strm->adler = crc32(0L, Z_NULL, 0); - s->status = BUSY_STATE; - } - } - else - s->status = BUSY_STATE; - } -#endif - - /* Flush as much pending output as possible */ - if (s->pending != 0) { - flush_pending(strm); - if (strm->avail_out == 0) { - /* Since avail_out is 0, deflate will be called again with - * more output space, but possibly with both pending and - * avail_in equal to zero. There won't be anything to do, - * but this is not an error situation so make sure we - * return OK instead of BUF_ERROR at next call of deflate: - */ - s->last_flush = -1; - return Z_OK; - } - - /* Make sure there is something to do and avoid duplicate consecutive - * flushes. For repeated and useless calls with Z_FINISH, we keep - * returning Z_STREAM_END instead of Z_BUF_ERROR. - */ - } else if (strm->avail_in == 0 && flush <= old_flush && - flush != Z_FINISH) { - ERR_RETURN(strm, Z_BUF_ERROR); - } - - /* User must not provide more input after the first FINISH: */ - if (s->status == FINISH_STATE && strm->avail_in != 0) { - ERR_RETURN(strm, Z_BUF_ERROR); - } - - /* Start a new block or continue the current one. - */ - if (strm->avail_in != 0 || s->lookahead != 0 || - (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) { - block_state bstate; - - bstate = (*(configuration_table[s->level].func))(s, flush); - - if (bstate == finish_started || bstate == finish_done) { - s->status = FINISH_STATE; - } - if (bstate == need_more || bstate == finish_started) { - if (strm->avail_out == 0) { - s->last_flush = -1; /* avoid BUF_ERROR next call, see above */ - } - return Z_OK; - /* If flush != Z_NO_FLUSH && avail_out == 0, the next call - * of deflate should use the same flush parameter to make sure - * that the flush is complete. So we don't have to output an - * empty block here, this will be done at next call. This also - * ensures that for a very small output buffer, we emit at most - * one empty block. - */ - } - if (bstate == block_done) { - if (flush == Z_PARTIAL_FLUSH) { - _tr_align(s); - } else { /* FULL_FLUSH or SYNC_FLUSH */ - _tr_stored_block(s, (char*)0, 0L, 0); - /* For a full flush, this empty block will be recognized - * as a special marker by inflate_sync(). - */ - if (flush == Z_FULL_FLUSH) { - CLEAR_HASH(s); /* forget history */ - } - } - flush_pending(strm); - if (strm->avail_out == 0) { - s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */ - return Z_OK; - } - } - } - Assert(strm->avail_out > 0, "bug2"); - - if (flush != Z_FINISH) return Z_OK; - if (s->wrap <= 0) return Z_STREAM_END; - - /* Write the trailer */ -#ifdef GZIP - if (s->wrap == 2) { - put_byte(s, (Byte)(strm->adler & 0xff)); - put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); - put_byte(s, (Byte)((strm->adler >> 16) & 0xff)); - put_byte(s, (Byte)((strm->adler >> 24) & 0xff)); - put_byte(s, (Byte)(strm->total_in & 0xff)); - put_byte(s, (Byte)((strm->total_in >> 8) & 0xff)); - put_byte(s, (Byte)((strm->total_in >> 16) & 0xff)); - put_byte(s, (Byte)((strm->total_in >> 24) & 0xff)); - } - else -#endif - { - putShortMSB(s, (uInt)(strm->adler >> 16)); - putShortMSB(s, (uInt)(strm->adler & 0xffff)); - } - flush_pending(strm); - /* If avail_out is zero, the application will call deflate again - * to flush the rest. - */ - if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */ - return s->pending != 0 ? Z_OK : Z_STREAM_END; -} - -/* ========================================================================= */ -int ZEXPORT deflateEnd (strm) - z_streamp strm; -{ - int status; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - - status = strm->state->status; - if (status != INIT_STATE && - status != EXTRA_STATE && - status != NAME_STATE && - status != COMMENT_STATE && - status != HCRC_STATE && - status != BUSY_STATE && - status != FINISH_STATE) { - return Z_STREAM_ERROR; - } - - /* Deallocate in reverse order of allocations: */ - TRY_FREE(strm, strm->state->pending_buf); - TRY_FREE(strm, strm->state->head); - TRY_FREE(strm, strm->state->prev); - TRY_FREE(strm, strm->state->window); - - ZFREE(strm, strm->state); - strm->state = Z_NULL; - - return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK; -} - -/* ========================================================================= - * Copy the source state to the destination state. - * To simplify the source, this is not supported for 16-bit MSDOS (which - * doesn't have enough memory anyway to duplicate compression states). - */ -int ZEXPORT deflateCopy (dest, source) - z_streamp dest; - z_streamp source; -{ -#ifdef MAXSEG_64K - return Z_STREAM_ERROR; -#else - deflate_state *ds; - deflate_state *ss; - ushf *overlay; - - - if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) { - return Z_STREAM_ERROR; - } - - ss = source->state; - - zmemcpy(dest, source, sizeof(z_stream)); - - ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state)); - if (ds == Z_NULL) return Z_MEM_ERROR; - dest->state = (struct internal_state FAR *) ds; - zmemcpy(ds, ss, sizeof(deflate_state)); - ds->strm = dest; - - ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); - ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos)); - ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos)); - overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2); - ds->pending_buf = (uchf *) overlay; - - if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL || - ds->pending_buf == Z_NULL) { - deflateEnd (dest); - return Z_MEM_ERROR; - } - /* following zmemcpy do not work for 16-bit MSDOS */ - zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte)); - zmemcpy(ds->prev, ss->prev, ds->w_size * sizeof(Pos)); - zmemcpy(ds->head, ss->head, ds->hash_size * sizeof(Pos)); - zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size); - - ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); - ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush); - ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize; - - ds->l_desc.dyn_tree = ds->dyn_ltree; - ds->d_desc.dyn_tree = ds->dyn_dtree; - ds->bl_desc.dyn_tree = ds->bl_tree; - - return Z_OK; -#endif /* MAXSEG_64K */ -} - -/* =========================================================================== - * Read a new buffer from the current input stream, update the adler32 - * and total number of bytes read. All deflate() input goes through - * this function so some applications may wish to modify it to avoid - * allocating a large strm->next_in buffer and copying from it. - * (See also flush_pending()). - */ -local int read_buf(strm, buf, size) - z_streamp strm; - Bytef *buf; - unsigned size; -{ - unsigned len = strm->avail_in; - - if (len > size) len = size; - if (len == 0) return 0; - - strm->avail_in -= len; - - if (strm->state->wrap == 1) { - strm->adler = adler32(strm->adler, strm->next_in, len); - } -#ifdef GZIP - else if (strm->state->wrap == 2) { - strm->adler = crc32(strm->adler, strm->next_in, len); - } -#endif - zmemcpy(buf, strm->next_in, len); - strm->next_in += len; - strm->total_in += len; - - return (int)len; -} - -/* =========================================================================== - * Initialize the "longest match" routines for a new zlib stream - */ -local void lm_init (s) - deflate_state *s; -{ - s->window_size = (ulg)2L*s->w_size; - - CLEAR_HASH(s); - - /* Set the default configuration parameters: - */ - s->max_lazy_match = configuration_table[s->level].max_lazy; - s->good_match = configuration_table[s->level].good_length; - s->nice_match = configuration_table[s->level].nice_length; - s->max_chain_length = configuration_table[s->level].max_chain; - - s->strstart = 0; - s->block_start = 0L; - s->lookahead = 0; - s->match_length = s->prev_length = MIN_MATCH-1; - s->match_available = 0; - s->ins_h = 0; -#ifndef FASTEST -#ifdef ASMV - match_init(); /* initialize the asm code */ -#endif -#endif -} - -#ifndef FASTEST -/* =========================================================================== - * Set match_start to the longest match starting at the given string and - * return its length. Matches shorter or equal to prev_length are discarded, - * in which case the result is equal to prev_length and match_start is - * garbage. - * IN assertions: cur_match is the head of the hash chain for the current - * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 - * OUT assertion: the match length is not greater than s->lookahead. - */ -#ifndef ASMV -/* For 80x86 and 680x0, an optimized version will be provided in match.asm or - * match.S. The code will be functionally equivalent. - */ -local uInt longest_match(s, cur_match) - deflate_state *s; - IPos cur_match; /* current match */ -{ - unsigned chain_length = s->max_chain_length;/* max hash chain length */ - register Bytef *scan = s->window + s->strstart; /* current string */ - register Bytef *match; /* matched string */ - register int len; /* length of current match */ - int best_len = s->prev_length; /* best match length so far */ - int nice_match = s->nice_match; /* stop if match long enough */ - IPos limit = s->strstart > (IPos)MAX_DIST(s) ? - s->strstart - (IPos)MAX_DIST(s) : NIL; - /* Stop when cur_match becomes <= limit. To simplify the code, - * we prevent matches with the string of window index 0. - */ - Posf *prev = s->prev; - uInt wmask = s->w_mask; - -#ifdef UNALIGNED_OK - /* Compare two bytes at a time. Note: this is not always beneficial. - * Try with and without -DUNALIGNED_OK to check. - */ - register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1; - register ush scan_start = *(ushf*)scan; - register ush scan_end = *(ushf*)(scan+best_len-1); -#else - register Bytef *strend = s->window + s->strstart + MAX_MATCH; - register Byte scan_end1 = scan[best_len-1]; - register Byte scan_end = scan[best_len]; -#endif - - /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. - * It is easy to get rid of this optimization if necessary. - */ - Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); - - /* Do not waste too much time if we already have a good match: */ - if (s->prev_length >= s->good_match) { - chain_length >>= 2; - } - /* Do not look for matches beyond the end of the input. This is necessary - * to make deflate deterministic. - */ - if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; - - Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); - - do { - Assert(cur_match < s->strstart, "no future"); - match = s->window + cur_match; - - /* Skip to next match if the match length cannot increase - * or if the match length is less than 2. Note that the checks below - * for insufficient lookahead only occur occasionally for performance - * reasons. Therefore uninitialized memory will be accessed, and - * conditional jumps will be made that depend on those values. - * However the length of the match is limited to the lookahead, so - * the output of deflate is not affected by the uninitialized values. - */ -#if (defined(UNALIGNED_OK) && MAX_MATCH == 258) - /* This code assumes sizeof(unsigned short) == 2. Do not use - * UNALIGNED_OK if your compiler uses a different size. - */ - if (*(ushf*)(match+best_len-1) != scan_end || - *(ushf*)match != scan_start) continue; - - /* It is not necessary to compare scan[2] and match[2] since they are - * always equal when the other bytes match, given that the hash keys - * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at - * strstart+3, +5, ... up to strstart+257. We check for insufficient - * lookahead only every 4th comparison; the 128th check will be made - * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is - * necessary to put more guard bytes at the end of the window, or - * to check more often for insufficient lookahead. - */ - Assert(scan[2] == match[2], "scan[2]?"); - scan++, match++; - do { - } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) && - *(ushf*)(scan+=2) == *(ushf*)(match+=2) && - *(ushf*)(scan+=2) == *(ushf*)(match+=2) && - *(ushf*)(scan+=2) == *(ushf*)(match+=2) && - scan < strend); - /* The funny "do {}" generates better code on most compilers */ - - /* Here, scan <= window+strstart+257 */ - Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); - if (*scan == *match) scan++; - - len = (MAX_MATCH - 1) - (int)(strend-scan); - scan = strend - (MAX_MATCH-1); - -#else /* UNALIGNED_OK */ - - if (match[best_len] != scan_end || - match[best_len-1] != scan_end1 || - *match != *scan || - *++match != scan[1]) continue; - - /* The check at best_len-1 can be removed because it will be made - * again later. (This heuristic is not always a win.) - * It is not necessary to compare scan[2] and match[2] since they - * are always equal when the other bytes match, given that - * the hash keys are equal and that HASH_BITS >= 8. - */ - scan += 2, match++; - Assert(*scan == *match, "match[2]?"); - - /* We check for insufficient lookahead only every 8th comparison; - * the 256th check will be made at strstart+258. - */ - do { - } while (*++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - scan < strend); - - Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); - - len = MAX_MATCH - (int)(strend - scan); - scan = strend - MAX_MATCH; - -#endif /* UNALIGNED_OK */ - - if (len > best_len) { - s->match_start = cur_match; - best_len = len; - if (len >= nice_match) break; -#ifdef UNALIGNED_OK - scan_end = *(ushf*)(scan+best_len-1); -#else - scan_end1 = scan[best_len-1]; - scan_end = scan[best_len]; -#endif - } - } while ((cur_match = prev[cur_match & wmask]) > limit - && --chain_length != 0); - - if ((uInt)best_len <= s->lookahead) return (uInt)best_len; - return s->lookahead; -} -#endif /* ASMV */ -#endif /* FASTEST */ - -/* --------------------------------------------------------------------------- - * Optimized version for level == 1 or strategy == Z_RLE only - */ -local uInt longest_match_fast(s, cur_match) - deflate_state *s; - IPos cur_match; /* current match */ -{ - register Bytef *scan = s->window + s->strstart; /* current string */ - register Bytef *match; /* matched string */ - register int len; /* length of current match */ - register Bytef *strend = s->window + s->strstart + MAX_MATCH; - - /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. - * It is easy to get rid of this optimization if necessary. - */ - Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); - - Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); - - Assert(cur_match < s->strstart, "no future"); - - match = s->window + cur_match; - - /* Return failure if the match length is less than 2: - */ - if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1; - - /* The check at best_len-1 can be removed because it will be made - * again later. (This heuristic is not always a win.) - * It is not necessary to compare scan[2] and match[2] since they - * are always equal when the other bytes match, given that - * the hash keys are equal and that HASH_BITS >= 8. - */ - scan += 2, match += 2; - Assert(*scan == *match, "match[2]?"); - - /* We check for insufficient lookahead only every 8th comparison; - * the 256th check will be made at strstart+258. - */ - do { - } while (*++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - scan < strend); - - Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); - - len = MAX_MATCH - (int)(strend - scan); - - if (len < MIN_MATCH) return MIN_MATCH - 1; - - s->match_start = cur_match; - return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead; -} - -#ifdef DEBUG -/* =========================================================================== - * Check that the match at match_start is indeed a match. - */ -local void check_match(s, start, match, length) - deflate_state *s; - IPos start, match; - int length; -{ - /* check that the match is indeed a match */ - if (zmemcmp(s->window + match, - s->window + start, length) != EQUAL) { - fprintf(stderr, " start %u, match %u, length %d\n", - start, match, length); - do { - fprintf(stderr, "%c%c", s->window[match++], s->window[start++]); - } while (--length != 0); - z_error("invalid match"); - } - if (z_verbose > 1) { - fprintf(stderr,"\\[%d,%d]", start-match, length); - do { putc(s->window[start++], stderr); } while (--length != 0); - } -} -#else -# define check_match(s, start, match, length) -#endif /* DEBUG */ - -/* =========================================================================== - * Fill the window when the lookahead becomes insufficient. - * Updates strstart and lookahead. - * - * IN assertion: lookahead < MIN_LOOKAHEAD - * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD - * At least one byte has been read, or avail_in == 0; reads are - * performed for at least two bytes (required for the zip translate_eol - * option -- not supported here). - */ -local void fill_window(s) - deflate_state *s; -{ - register unsigned n, m; - register Posf *p; - unsigned more; /* Amount of free space at the end of the window. */ - uInt wsize = s->w_size; - - do { - more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); - - /* Deal with !@#$% 64K limit: */ - if (sizeof(int) <= 2) { - if (more == 0 && s->strstart == 0 && s->lookahead == 0) { - more = wsize; - - } else if (more == (unsigned)(-1)) { - /* Very unlikely, but possible on 16 bit machine if - * strstart == 0 && lookahead == 1 (input done a byte at time) - */ - more--; - } - } - - /* If the window is almost full and there is insufficient lookahead, - * move the upper half to the lower one to make room in the upper half. - */ - if (s->strstart >= wsize+MAX_DIST(s)) { - - zmemcpy(s->window, s->window+wsize, (unsigned)wsize); - s->match_start -= wsize; - s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ - s->block_start -= (long) wsize; - - /* Slide the hash table (could be avoided with 32 bit values - at the expense of memory usage). We slide even when level == 0 - to keep the hash table consistent if we switch back to level > 0 - later. (Using level 0 permanently is not an optimal usage of - zlib, so we don't care about this pathological case.) - */ - /* %%% avoid this when Z_RLE */ - n = s->hash_size; - p = &s->head[n]; - do { - m = *--p; - *p = (Pos)(m >= wsize ? m-wsize : NIL); - } while (--n); - - n = wsize; -#ifndef FASTEST - p = &s->prev[n]; - do { - m = *--p; - *p = (Pos)(m >= wsize ? m-wsize : NIL); - /* If n is not on any hash chain, prev[n] is garbage but - * its value will never be used. - */ - } while (--n); -#endif - more += wsize; - } - if (s->strm->avail_in == 0) return; - - /* If there was no sliding: - * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && - * more == window_size - lookahead - strstart - * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) - * => more >= window_size - 2*WSIZE + 2 - * In the BIG_MEM or MMAP case (not yet supported), - * window_size == input_size + MIN_LOOKAHEAD && - * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. - * Otherwise, window_size == 2*WSIZE so more >= 2. - * If there was sliding, more >= WSIZE. So in all cases, more >= 2. - */ - Assert(more >= 2, "more < 2"); - - n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more); - s->lookahead += n; - - /* Initialize the hash value now that we have some input: */ - if (s->lookahead >= MIN_MATCH) { - s->ins_h = s->window[s->strstart]; - UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]); -#if MIN_MATCH != 3 - Call UPDATE_HASH() MIN_MATCH-3 more times -#endif - } - /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, - * but this is not important since only literal bytes will be emitted. - */ - - } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0); -} - -/* =========================================================================== - * Flush the current block, with given end-of-file flag. - * IN assertion: strstart is set to the end of the current match. - */ -#define FLUSH_BLOCK_ONLY(s, eof) { \ - _tr_flush_block(s, (s->block_start >= 0L ? \ - (charf *)&s->window[(unsigned)s->block_start] : \ - (charf *)Z_NULL), \ - (ulg)((long)s->strstart - s->block_start), \ - (eof)); \ - s->block_start = s->strstart; \ - flush_pending(s->strm); \ - Tracev((stderr,"[FLUSH]")); \ -} - -/* Same but force premature exit if necessary. */ -#define FLUSH_BLOCK(s, eof) { \ - FLUSH_BLOCK_ONLY(s, eof); \ - if (s->strm->avail_out == 0) return (eof) ? finish_started : need_more; \ -} - -/* =========================================================================== - * Copy without compression as much as possible from the input stream, return - * the current block state. - * This function does not insert new strings in the dictionary since - * uncompressible data is probably not useful. This function is used - * only for the level=0 compression option. - * NOTE: this function should be optimized to avoid extra copying from - * window to pending_buf. - */ -local block_state deflate_stored(s, flush) - deflate_state *s; - int flush; -{ - /* Stored blocks are limited to 0xffff bytes, pending_buf is limited - * to pending_buf_size, and each stored block has a 5 byte header: - */ - ulg max_block_size = 0xffff; - ulg max_start; - - if (max_block_size > s->pending_buf_size - 5) { - max_block_size = s->pending_buf_size - 5; - } - - /* Copy as much as possible from input to output: */ - for (;;) { - /* Fill the window as much as possible: */ - if (s->lookahead <= 1) { - - Assert(s->strstart < s->w_size+MAX_DIST(s) || - s->block_start >= (long)s->w_size, "slide too late"); - - fill_window(s); - if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more; - - if (s->lookahead == 0) break; /* flush the current block */ - } - Assert(s->block_start >= 0L, "block gone"); - - s->strstart += s->lookahead; - s->lookahead = 0; - - /* Emit a stored block if pending_buf will be full: */ - max_start = s->block_start + max_block_size; - if (s->strstart == 0 || (ulg)s->strstart >= max_start) { - /* strstart == 0 is possible when wraparound on 16-bit machine */ - s->lookahead = (uInt)(s->strstart - max_start); - s->strstart = (uInt)max_start; - FLUSH_BLOCK(s, 0); - } - /* Flush if we may have to slide, otherwise block_start may become - * negative and the data will be gone: - */ - if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) { - FLUSH_BLOCK(s, 0); - } - } - FLUSH_BLOCK(s, flush == Z_FINISH); - return flush == Z_FINISH ? finish_done : block_done; -} - -/* =========================================================================== - * Compress as much as possible from the input stream, return the current - * block state. - * This function does not perform lazy evaluation of matches and inserts - * new strings in the dictionary only for unmatched strings or for short - * matches. It is used only for the fast compression options. - */ -local block_state deflate_fast(s, flush) - deflate_state *s; - int flush; -{ - IPos hash_head = NIL; /* head of the hash chain */ - int bflush; /* set if current block must be flushed */ - - for (;;) { - /* Make sure that we always have enough lookahead, except - * at the end of the input file. We need MAX_MATCH bytes - * for the next match, plus MIN_MATCH bytes to insert the - * string following the next match. - */ - if (s->lookahead < MIN_LOOKAHEAD) { - fill_window(s); - if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { - return need_more; - } - if (s->lookahead == 0) break; /* flush the current block */ - } - - /* Insert the string window[strstart .. strstart+2] in the - * dictionary, and set hash_head to the head of the hash chain: - */ - if (s->lookahead >= MIN_MATCH) { - INSERT_STRING(s, s->strstart, hash_head); - } - - /* Find the longest match, discarding those <= prev_length. - * At this point we have always match_length < MIN_MATCH - */ - if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) { - /* To simplify the code, we prevent matches with the string - * of window index 0 (in particular we have to avoid a match - * of the string with itself at the start of the input file). - */ -#ifdef FASTEST - if ((s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) || - (s->strategy == Z_RLE && s->strstart - hash_head == 1)) { - s->match_length = longest_match_fast (s, hash_head); - } -#else - if (s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) { - s->match_length = longest_match (s, hash_head); - } else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) { - s->match_length = longest_match_fast (s, hash_head); - } -#endif - /* longest_match() or longest_match_fast() sets match_start */ - } - if (s->match_length >= MIN_MATCH) { - check_match(s, s->strstart, s->match_start, s->match_length); - - _tr_tally_dist(s, s->strstart - s->match_start, - s->match_length - MIN_MATCH, bflush); - - s->lookahead -= s->match_length; - - /* Insert new strings in the hash table only if the match length - * is not too large. This saves time but degrades compression. - */ -#ifndef FASTEST - if (s->match_length <= s->max_insert_length && - s->lookahead >= MIN_MATCH) { - s->match_length--; /* string at strstart already in table */ - do { - s->strstart++; - INSERT_STRING(s, s->strstart, hash_head); - /* strstart never exceeds WSIZE-MAX_MATCH, so there are - * always MIN_MATCH bytes ahead. - */ - } while (--s->match_length != 0); - s->strstart++; - } else -#endif - { - s->strstart += s->match_length; - s->match_length = 0; - s->ins_h = s->window[s->strstart]; - UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]); -#if MIN_MATCH != 3 - Call UPDATE_HASH() MIN_MATCH-3 more times -#endif - /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not - * matter since it will be recomputed at next deflate call. - */ - } - } else { - /* No match, output a literal byte */ - Tracevv((stderr,"%c", s->window[s->strstart])); - _tr_tally_lit (s, s->window[s->strstart], bflush); - s->lookahead--; - s->strstart++; - } - if (bflush) FLUSH_BLOCK(s, 0); - } - FLUSH_BLOCK(s, flush == Z_FINISH); - return flush == Z_FINISH ? finish_done : block_done; -} - -#ifndef FASTEST -/* =========================================================================== - * Same as above, but achieves better compression. We use a lazy - * evaluation for matches: a match is finally adopted only if there is - * no better match at the next window position. - */ -local block_state deflate_slow(s, flush) - deflate_state *s; - int flush; -{ - IPos hash_head = NIL; /* head of hash chain */ - int bflush; /* set if current block must be flushed */ - - /* Process the input block. */ - for (;;) { - /* Make sure that we always have enough lookahead, except - * at the end of the input file. We need MAX_MATCH bytes - * for the next match, plus MIN_MATCH bytes to insert the - * string following the next match. - */ - if (s->lookahead < MIN_LOOKAHEAD) { - fill_window(s); - if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { - return need_more; - } - if (s->lookahead == 0) break; /* flush the current block */ - } - - /* Insert the string window[strstart .. strstart+2] in the - * dictionary, and set hash_head to the head of the hash chain: - */ - if (s->lookahead >= MIN_MATCH) { - INSERT_STRING(s, s->strstart, hash_head); - } - - /* Find the longest match, discarding those <= prev_length. - */ - s->prev_length = s->match_length, s->prev_match = s->match_start; - s->match_length = MIN_MATCH-1; - - if (hash_head != NIL && s->prev_length < s->max_lazy_match && - s->strstart - hash_head <= MAX_DIST(s)) { - /* To simplify the code, we prevent matches with the string - * of window index 0 (in particular we have to avoid a match - * of the string with itself at the start of the input file). - */ - if (s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) { - s->match_length = longest_match (s, hash_head); - } else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) { - s->match_length = longest_match_fast (s, hash_head); - } - /* longest_match() or longest_match_fast() sets match_start */ - - if (s->match_length <= 5 && (s->strategy == Z_FILTERED -#if TOO_FAR <= 32767 - || (s->match_length == MIN_MATCH && - s->strstart - s->match_start > TOO_FAR) -#endif - )) { - - /* If prev_match is also MIN_MATCH, match_start is garbage - * but we will ignore the current match anyway. - */ - s->match_length = MIN_MATCH-1; - } - } - /* If there was a match at the previous step and the current - * match is not better, output the previous match: - */ - if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) { - uInt max_insert = s->strstart + s->lookahead - MIN_MATCH; - /* Do not insert strings in hash table beyond this. */ - - check_match(s, s->strstart-1, s->prev_match, s->prev_length); - - _tr_tally_dist(s, s->strstart -1 - s->prev_match, - s->prev_length - MIN_MATCH, bflush); - - /* Insert in hash table all strings up to the end of the match. - * strstart-1 and strstart are already inserted. If there is not - * enough lookahead, the last two strings are not inserted in - * the hash table. - */ - s->lookahead -= s->prev_length-1; - s->prev_length -= 2; - do { - if (++s->strstart <= max_insert) { - INSERT_STRING(s, s->strstart, hash_head); - } - } while (--s->prev_length != 0); - s->match_available = 0; - s->match_length = MIN_MATCH-1; - s->strstart++; - - if (bflush) FLUSH_BLOCK(s, 0); - - } else if (s->match_available) { - /* If there was no match at the previous position, output a - * single literal. If there was a match but the current match - * is longer, truncate the previous match to a single literal. - */ - Tracevv((stderr,"%c", s->window[s->strstart-1])); - _tr_tally_lit(s, s->window[s->strstart-1], bflush); - if (bflush) { - FLUSH_BLOCK_ONLY(s, 0); - } - s->strstart++; - s->lookahead--; - if (s->strm->avail_out == 0) return need_more; - } else { - /* There is no previous match to compare with, wait for - * the next step to decide. - */ - s->match_available = 1; - s->strstart++; - s->lookahead--; - } - } - Assert (flush != Z_NO_FLUSH, "no flush?"); - if (s->match_available) { - Tracevv((stderr,"%c", s->window[s->strstart-1])); - _tr_tally_lit(s, s->window[s->strstart-1], bflush); - s->match_available = 0; - } - FLUSH_BLOCK(s, flush == Z_FINISH); - return flush == Z_FINISH ? finish_done : block_done; -} -#endif /* FASTEST */ - -#if 0 -/* =========================================================================== - * For Z_RLE, simply look for runs of bytes, generate matches only of distance - * one. Do not maintain a hash table. (It will be regenerated if this run of - * deflate switches away from Z_RLE.) - */ -local block_state deflate_rle(s, flush) - deflate_state *s; - int flush; -{ - int bflush; /* set if current block must be flushed */ - uInt run; /* length of run */ - uInt max; /* maximum length of run */ - uInt prev; /* byte at distance one to match */ - Bytef *scan; /* scan for end of run */ - - for (;;) { - /* Make sure that we always have enough lookahead, except - * at the end of the input file. We need MAX_MATCH bytes - * for the longest encodable run. - */ - if (s->lookahead < MAX_MATCH) { - fill_window(s); - if (s->lookahead < MAX_MATCH && flush == Z_NO_FLUSH) { - return need_more; - } - if (s->lookahead == 0) break; /* flush the current block */ - } - - /* See how many times the previous byte repeats */ - run = 0; - if (s->strstart > 0) { /* if there is a previous byte, that is */ - max = s->lookahead < MAX_MATCH ? s->lookahead : MAX_MATCH; - scan = s->window + s->strstart - 1; - prev = *scan++; - do { - if (*scan++ != prev) - break; - } while (++run < max); - } - - /* Emit match if have run of MIN_MATCH or longer, else emit literal */ - if (run >= MIN_MATCH) { - check_match(s, s->strstart, s->strstart - 1, run); - _tr_tally_dist(s, 1, run - MIN_MATCH, bflush); - s->lookahead -= run; - s->strstart += run; - } else { - /* No match, output a literal byte */ - Tracevv((stderr,"%c", s->window[s->strstart])); - _tr_tally_lit (s, s->window[s->strstart], bflush); - s->lookahead--; - s->strstart++; - } - if (bflush) FLUSH_BLOCK(s, 0); - } - FLUSH_BLOCK(s, flush == Z_FINISH); - return flush == Z_FINISH ? finish_done : block_done; -} -#endif diff --git a/irrlicht-1.6/source/Irrlicht/zlib/deflate.h b/irrlicht-1.6/source/Irrlicht/zlib/deflate.h deleted file mode 100644 index 222c53e04..000000000 --- a/irrlicht-1.6/source/Irrlicht/zlib/deflate.h +++ /dev/null @@ -1,331 +0,0 @@ -/* deflate.h -- internal compression state - * Copyright (C) 1995-2004 Jean-loup Gailly - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* @(#) $Id$ */ - -#ifndef DEFLATE_H -#define DEFLATE_H - -#include "zutil.h" - -/* define NO_GZIP when compiling if you want to disable gzip header and - trailer creation by deflate(). NO_GZIP would be used to avoid linking in - the crc code when it is not needed. For shared libraries, gzip encoding - should be left enabled. */ -#ifndef NO_GZIP -# define GZIP -#endif - -/* =========================================================================== - * Internal compression state. - */ - -#define LENGTH_CODES 29 -/* number of length codes, not counting the special END_BLOCK code */ - -#define LITERALS 256 -/* number of literal bytes 0..255 */ - -#define L_CODES (LITERALS+1+LENGTH_CODES) -/* number of Literal or Length codes, including the END_BLOCK code */ - -#define D_CODES 30 -/* number of distance codes */ - -#define BL_CODES 19 -/* number of codes used to transfer the bit lengths */ - -#define HEAP_SIZE (2*L_CODES+1) -/* maximum heap size */ - -#define MAX_BITS 15 -/* All codes must not exceed MAX_BITS bits */ - -#define INIT_STATE 42 -#define EXTRA_STATE 69 -#define NAME_STATE 73 -#define COMMENT_STATE 91 -#define HCRC_STATE 103 -#define BUSY_STATE 113 -#define FINISH_STATE 666 -/* Stream status */ - - -/* Data structure describing a single value and its code string. */ -typedef struct ct_data_s { - union { - ush freq; /* frequency count */ - ush code; /* bit string */ - } fc; - union { - ush dad; /* father node in Huffman tree */ - ush len; /* length of bit string */ - } dl; -} FAR ct_data; - -#define Freq fc.freq -#define Code fc.code -#define Dad dl.dad -#define Len dl.len - -typedef struct static_tree_desc_s static_tree_desc; - -typedef struct tree_desc_s { - ct_data *dyn_tree; /* the dynamic tree */ - int max_code; /* largest code with non zero frequency */ - static_tree_desc *stat_desc; /* the corresponding static tree */ -} FAR tree_desc; - -typedef ush Pos; -typedef Pos FAR Posf; -typedef unsigned IPos; - -/* A Pos is an index in the character window. We use short instead of int to - * save space in the various tables. IPos is used only for parameter passing. - */ - -typedef struct internal_state { - z_streamp strm; /* pointer back to this zlib stream */ - int status; /* as the name implies */ - Bytef *pending_buf; /* output still pending */ - ulg pending_buf_size; /* size of pending_buf */ - Bytef *pending_out; /* next pending byte to output to the stream */ - uInt pending; /* nb of bytes in the pending buffer */ - int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ - gz_headerp gzhead; /* gzip header information to write */ - uInt gzindex; /* where in extra, name, or comment */ - Byte method; /* STORED (for zip only) or DEFLATED */ - int last_flush; /* value of flush param for previous deflate call */ - - /* used by deflate.c: */ - - uInt w_size; /* LZ77 window size (32K by default) */ - uInt w_bits; /* log2(w_size) (8..16) */ - uInt w_mask; /* w_size - 1 */ - - Bytef *window; - /* Sliding window. Input bytes are read into the second half of the window, - * and move to the first half later to keep a dictionary of at least wSize - * bytes. With this organization, matches are limited to a distance of - * wSize-MAX_MATCH bytes, but this ensures that IO is always - * performed with a length multiple of the block size. Also, it limits - * the window size to 64K, which is quite useful on MSDOS. - * To do: use the user input buffer as sliding window. - */ - - ulg window_size; - /* Actual size of window: 2*wSize, except when the user input buffer - * is directly used as sliding window. - */ - - Posf *prev; - /* Link to older string with same hash index. To limit the size of this - * array to 64K, this link is maintained only for the last 32K strings. - * An index in this array is thus a window index modulo 32K. - */ - - Posf *head; /* Heads of the hash chains or NIL. */ - - uInt ins_h; /* hash index of string to be inserted */ - uInt hash_size; /* number of elements in hash table */ - uInt hash_bits; /* log2(hash_size) */ - uInt hash_mask; /* hash_size-1 */ - - uInt hash_shift; - /* Number of bits by which ins_h must be shifted at each input - * step. It must be such that after MIN_MATCH steps, the oldest - * byte no longer takes part in the hash key, that is: - * hash_shift * MIN_MATCH >= hash_bits - */ - - long block_start; - /* Window position at the beginning of the current output block. Gets - * negative when the window is moved backwards. - */ - - uInt match_length; /* length of best match */ - IPos prev_match; /* previous match */ - int match_available; /* set if previous match exists */ - uInt strstart; /* start of string to insert */ - uInt match_start; /* start of matching string */ - uInt lookahead; /* number of valid bytes ahead in window */ - - uInt prev_length; - /* Length of the best match at previous step. Matches not greater than this - * are discarded. This is used in the lazy match evaluation. - */ - - uInt max_chain_length; - /* To speed up deflation, hash chains are never searched beyond this - * length. A higher limit improves compression ratio but degrades the - * speed. - */ - - uInt max_lazy_match; - /* Attempt to find a better match only when the current match is strictly - * smaller than this value. This mechanism is used only for compression - * levels >= 4. - */ -# define max_insert_length max_lazy_match - /* Insert new strings in the hash table only if the match length is not - * greater than this length. This saves time but degrades compression. - * max_insert_length is used only for compression levels <= 3. - */ - - int level; /* compression level (1..9) */ - int strategy; /* favor or force Huffman coding*/ - - uInt good_match; - /* Use a faster search when the previous match is longer than this */ - - int nice_match; /* Stop searching when current match exceeds this */ - - /* used by trees.c: */ - /* Didn't use ct_data typedef below to supress compiler warning */ - struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */ - struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */ - struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */ - - struct tree_desc_s l_desc; /* desc. for literal tree */ - struct tree_desc_s d_desc; /* desc. for distance tree */ - struct tree_desc_s bl_desc; /* desc. for bit length tree */ - - ush bl_count[MAX_BITS+1]; - /* number of codes at each bit length for an optimal tree */ - - int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */ - int heap_len; /* number of elements in the heap */ - int heap_max; /* element of largest frequency */ - /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. - * The same heap array is used to build all trees. - */ - - uch depth[2*L_CODES+1]; - /* Depth of each subtree used as tie breaker for trees of equal frequency - */ - - uchf *l_buf; /* buffer for literals or lengths */ - - uInt lit_bufsize; - /* Size of match buffer for literals/lengths. There are 4 reasons for - * limiting lit_bufsize to 64K: - * - frequencies can be kept in 16 bit counters - * - if compression is not successful for the first block, all input - * data is still in the window so we can still emit a stored block even - * when input comes from standard input. (This can also be done for - * all blocks if lit_bufsize is not greater than 32K.) - * - if compression is not successful for a file smaller than 64K, we can - * even emit a stored file instead of a stored block (saving 5 bytes). - * This is applicable only for zip (not gzip or zlib). - * - creating new Huffman trees less frequently may not provide fast - * adaptation to changes in the input data statistics. (Take for - * example a binary file with poorly compressible code followed by - * a highly compressible string table.) Smaller buffer sizes give - * fast adaptation but have of course the overhead of transmitting - * trees more frequently. - * - I can't count above 4 - */ - - uInt last_lit; /* running index in l_buf */ - - ushf *d_buf; - /* Buffer for distances. To simplify the code, d_buf and l_buf have - * the same number of elements. To use different lengths, an extra flag - * array would be necessary. - */ - - ulg opt_len; /* bit length of current block with optimal trees */ - ulg static_len; /* bit length of current block with static trees */ - uInt matches; /* number of string matches in current block */ - int last_eob_len; /* bit length of EOB code for last block */ - -#ifdef DEBUG - ulg compressed_len; /* total bit length of compressed file mod 2^32 */ - ulg bits_sent; /* bit length of compressed data sent mod 2^32 */ -#endif - - ush bi_buf; - /* Output buffer. bits are inserted starting at the bottom (least - * significant bits). - */ - int bi_valid; - /* Number of valid bits in bi_buf. All bits above the last valid bit - * are always zero. - */ - -} FAR deflate_state; - -/* Output a byte on the stream. - * IN assertion: there is enough room in pending_buf. - */ -#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);} - - -#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) -/* Minimum amount of lookahead, except at the end of the input file. - * See deflate.c for comments about the MIN_MATCH+1. - */ - -#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD) -/* In order to simplify the code, particularly on 16 bit machines, match - * distances are limited to MAX_DIST instead of WSIZE. - */ - - /* in trees.c */ -void _tr_init OF((deflate_state *s)); -int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); -void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len, - int eof)); -void _tr_align OF((deflate_state *s)); -void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len, - int eof)); - -#define d_code(dist) \ - ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) -/* Mapping from a distance to a distance code. dist is the distance - 1 and - * must not have side effects. _dist_code[256] and _dist_code[257] are never - * used. - */ - -#ifndef DEBUG -/* Inline versions of _tr_tally for speed: */ - -#if defined(GEN_TREES_H) || !defined(STDC) - extern uch _length_code[]; - extern uch _dist_code[]; -#else - extern const uch _length_code[]; - extern const uch _dist_code[]; -#endif - -# define _tr_tally_lit(s, c, flush) \ - { uch cc = (c); \ - s->d_buf[s->last_lit] = 0; \ - s->l_buf[s->last_lit++] = cc; \ - s->dyn_ltree[cc].Freq++; \ - flush = (s->last_lit == s->lit_bufsize-1); \ - } -# define _tr_tally_dist(s, distance, length, flush) \ - { uch len = (length); \ - ush dist = (distance); \ - s->d_buf[s->last_lit] = dist; \ - s->l_buf[s->last_lit++] = len; \ - dist--; \ - s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ - s->dyn_dtree[d_code(dist)].Freq++; \ - flush = (s->last_lit == s->lit_bufsize-1); \ - } -#else -# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c) -# define _tr_tally_dist(s, distance, length, flush) \ - flush = _tr_tally(s, distance, length) -#endif - -#endif /* DEFLATE_H */ diff --git a/irrlicht-1.6/source/Irrlicht/zlib/gzio.c b/irrlicht-1.6/source/Irrlicht/zlib/gzio.c deleted file mode 100644 index 5e20a4aa0..000000000 --- a/irrlicht-1.6/source/Irrlicht/zlib/gzio.c +++ /dev/null @@ -1,1026 +0,0 @@ -/* gzio.c -- IO on .gz files - * Copyright (C) 1995-2005 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - * - * Compile this file with -DNO_GZCOMPRESS to avoid the compression code. - */ - -/* @(#) $Id$ */ - -#include <stdio.h> - -#include "zutil.h" - -#ifdef NO_DEFLATE /* for compatibility with old definition */ -# define NO_GZCOMPRESS -#endif - -#ifndef NO_DUMMY_DECL -struct internal_state {int dummy;}; /* for buggy compilers */ -#endif - -#ifndef Z_BUFSIZE -# ifdef MAXSEG_64K -# define Z_BUFSIZE 4096 /* minimize memory usage for 16-bit DOS */ -# else -# define Z_BUFSIZE 16384 -# endif -#endif -#ifndef Z_PRINTF_BUFSIZE -# define Z_PRINTF_BUFSIZE 4096 -#endif - -#ifdef __MVS__ -# pragma map (fdopen , "\174\174FDOPEN") - FILE *fdopen(int, const char *); -#endif - -#ifndef STDC -extern voidp malloc OF((uInt size)); -extern void free OF((voidpf ptr)); -#endif - -#define ALLOC(size) malloc(size) -#define TRYFREE(p) {if (p) free(p);} - -static int const gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */ - -/* gzip flag byte */ -#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */ -#define HEAD_CRC 0x02 /* bit 1 set: header CRC present */ -#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ -#define ORIG_NAME 0x08 /* bit 3 set: original file name present */ -#define COMMENT 0x10 /* bit 4 set: file comment present */ -#define RESERVED 0xE0 /* bits 5..7: reserved */ - -typedef struct gz_stream { - z_stream stream; - int z_err; /* error code for last stream operation */ - int z_eof; /* set if end of input file */ - FILE *file; /* .gz file */ - Byte *inbuf; /* input buffer */ - Byte *outbuf; /* output buffer */ - uLong crc; /* crc32 of uncompressed data */ - char *msg; /* error message */ - char *path; /* path name for debugging only */ - int transparent; /* 1 if input file is not a .gz file */ - char mode; /* 'w' or 'r' */ - z_off_t start; /* start of compressed data in file (header skipped) */ - z_off_t in; /* bytes into deflate or inflate */ - z_off_t out; /* bytes out of deflate or inflate */ - int back; /* one character push-back */ - int last; /* true if push-back is last character */ -} gz_stream; - - -local gzFile gz_open OF((const char *path, const char *mode, int fd)); -local int do_flush OF((gzFile file, int flush)); -local int get_byte OF((gz_stream *s)); -local void check_header OF((gz_stream *s)); -local int destroy OF((gz_stream *s)); -local void putLong OF((FILE *file, uLong x)); -local uLong getLong OF((gz_stream *s)); - -/* =========================================================================== - Opens a gzip (.gz) file for reading or writing. The mode parameter - is as in fopen ("rb" or "wb"). The file is given either by file descriptor - or path name (if fd == -1). - gz_open returns NULL if the file could not be opened or if there was - insufficient memory to allocate the (de)compression state; errno - can be checked to distinguish the two cases (if errno is zero, the - zlib error is Z_MEM_ERROR). -*/ -local gzFile gz_open (path, mode, fd) - const char *path; - const char *mode; - int fd; -{ - int err; - int level = Z_DEFAULT_COMPRESSION; /* compression level */ - int strategy = Z_DEFAULT_STRATEGY; /* compression strategy */ - char *p = (char*)mode; - gz_stream *s; - char fmode[80]; /* copy of mode, without the compression level */ - char *m = fmode; - - if (!path || !mode) return Z_NULL; - - s = (gz_stream *)ALLOC(sizeof(gz_stream)); - if (!s) return Z_NULL; - - s->stream.zalloc = (alloc_func)0; - s->stream.zfree = (free_func)0; - s->stream.opaque = (voidpf)0; - s->stream.next_in = s->inbuf = Z_NULL; - s->stream.next_out = s->outbuf = Z_NULL; - s->stream.avail_in = s->stream.avail_out = 0; - s->file = NULL; - s->z_err = Z_OK; - s->z_eof = 0; - s->in = 0; - s->out = 0; - s->back = EOF; - s->crc = crc32(0L, Z_NULL, 0); - s->msg = NULL; - s->transparent = 0; - - s->path = (char*)ALLOC(strlen(path)+1); - if (s->path == NULL) { - return destroy(s), (gzFile)Z_NULL; - } - strcpy(s->path, path); /* do this early for debugging */ - - s->mode = '\0'; - do { - if (*p == 'r') s->mode = 'r'; - if (*p == 'w' || *p == 'a') s->mode = 'w'; - if (*p >= '0' && *p <= '9') { - level = *p - '0'; - } else if (*p == 'f') { - strategy = Z_FILTERED; - } else if (*p == 'h') { - strategy = Z_HUFFMAN_ONLY; - } else if (*p == 'R') { - strategy = Z_RLE; - } else { - *m++ = *p; /* copy the mode */ - } - } while (*p++ && m != fmode + sizeof(fmode)); - if (s->mode == '\0') return destroy(s), (gzFile)Z_NULL; - - if (s->mode == 'w') { -#ifdef NO_GZCOMPRESS - err = Z_STREAM_ERROR; -#else - err = deflateInit2(&(s->stream), level, - Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, strategy); - /* windowBits is passed < 0 to suppress zlib header */ - - s->stream.next_out = s->outbuf = (Byte*)ALLOC(Z_BUFSIZE); -#endif - if (err != Z_OK || s->outbuf == Z_NULL) { - return destroy(s), (gzFile)Z_NULL; - } - } else { - s->stream.next_in = s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); - - err = inflateInit2(&(s->stream), -MAX_WBITS); - /* windowBits is passed < 0 to tell that there is no zlib header. - * Note that in this case inflate *requires* an extra "dummy" byte - * after the compressed stream in order to complete decompression and - * return Z_STREAM_END. Here the gzip CRC32 ensures that 4 bytes are - * present after the compressed stream. - */ - if (err != Z_OK || s->inbuf == Z_NULL) { - return destroy(s), (gzFile)Z_NULL; - } - } - s->stream.avail_out = Z_BUFSIZE; - - errno = 0; - s->file = fd < 0 ? F_OPEN(path, fmode) : (FILE*)fdopen(fd, fmode); - - if (s->file == NULL) { - return destroy(s), (gzFile)Z_NULL; - } - if (s->mode == 'w') { - /* Write a very simple .gz header: - */ - fprintf(s->file, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1], - Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, OS_CODE); - s->start = 10L; - /* We use 10L instead of ftell(s->file) to because ftell causes an - * fflush on some systems. This version of the library doesn't use - * start anyway in write mode, so this initialization is not - * necessary. - */ - } else { - check_header(s); /* skip the .gz header */ - s->start = ftell(s->file) - s->stream.avail_in; - } - - return (gzFile)s; -} - -/* =========================================================================== - Opens a gzip (.gz) file for reading or writing. -*/ -gzFile ZEXPORT gzopen (path, mode) - const char *path; - const char *mode; -{ - return gz_open (path, mode, -1); -} - -/* =========================================================================== - Associate a gzFile with the file descriptor fd. fd is not dup'ed here - to mimic the behavio(u)r of fdopen. -*/ -gzFile ZEXPORT gzdopen (fd, mode) - int fd; - const char *mode; -{ - char name[46]; /* allow for up to 128-bit integers */ - - if (fd < 0) return (gzFile)Z_NULL; - sprintf(name, "<fd:%d>", fd); /* for debugging */ - - return gz_open (name, mode, fd); -} - -/* =========================================================================== - * Update the compression level and strategy - */ -int ZEXPORT gzsetparams (file, level, strategy) - gzFile file; - int level; - int strategy; -{ - gz_stream *s = (gz_stream*)file; - - if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR; - - /* Make room to allow flushing */ - if (s->stream.avail_out == 0) { - - s->stream.next_out = s->outbuf; - if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) { - s->z_err = Z_ERRNO; - } - s->stream.avail_out = Z_BUFSIZE; - } - - return deflateParams (&(s->stream), level, strategy); -} - -/* =========================================================================== - Read a byte from a gz_stream; update next_in and avail_in. Return EOF - for end of file. - IN assertion: the stream s has been sucessfully opened for reading. -*/ -local int get_byte(s) - gz_stream *s; -{ - if (s->z_eof) return EOF; - if (s->stream.avail_in == 0) { - errno = 0; - s->stream.avail_in = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file); - if (s->stream.avail_in == 0) { - s->z_eof = 1; - if (ferror(s->file)) s->z_err = Z_ERRNO; - return EOF; - } - s->stream.next_in = s->inbuf; - } - s->stream.avail_in--; - return *(s->stream.next_in)++; -} - -/* =========================================================================== - Check the gzip header of a gz_stream opened for reading. Set the stream - mode to transparent if the gzip magic header is not present; set s->err - to Z_DATA_ERROR if the magic header is present but the rest of the header - is incorrect. - IN assertion: the stream s has already been created sucessfully; - s->stream.avail_in is zero for the first time, but may be non-zero - for concatenated .gz files. -*/ -local void check_header(s) - gz_stream *s; -{ - int method; /* method byte */ - int flags; /* flags byte */ - uInt len; - int c; - - /* Assure two bytes in the buffer so we can peek ahead -- handle case - where first byte of header is at the end of the buffer after the last - gzip segment */ - len = s->stream.avail_in; - if (len < 2) { - if (len) s->inbuf[0] = s->stream.next_in[0]; - errno = 0; - len = (uInt)fread(s->inbuf + len, 1, Z_BUFSIZE >> len, s->file); - if (len == 0 && ferror(s->file)) s->z_err = Z_ERRNO; - s->stream.avail_in += len; - s->stream.next_in = s->inbuf; - if (s->stream.avail_in < 2) { - s->transparent = s->stream.avail_in; - return; - } - } - - /* Peek ahead to check the gzip magic header */ - if (s->stream.next_in[0] != gz_magic[0] || - s->stream.next_in[1] != gz_magic[1]) { - s->transparent = 1; - return; - } - s->stream.avail_in -= 2; - s->stream.next_in += 2; - - /* Check the rest of the gzip header */ - method = get_byte(s); - flags = get_byte(s); - if (method != Z_DEFLATED || (flags & RESERVED) != 0) { - s->z_err = Z_DATA_ERROR; - return; - } - - /* Discard time, xflags and OS code: */ - for (len = 0; len < 6; len++) (void)get_byte(s); - - if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */ - len = (uInt)get_byte(s); - len += ((uInt)get_byte(s))<<8; - /* len is garbage if EOF but the loop below will quit anyway */ - while (len-- != 0 && get_byte(s) != EOF) ; - } - if ((flags & ORIG_NAME) != 0) { /* skip the original file name */ - while ((c = get_byte(s)) != 0 && c != EOF) ; - } - if ((flags & COMMENT) != 0) { /* skip the .gz file comment */ - while ((c = get_byte(s)) != 0 && c != EOF) ; - } - if ((flags & HEAD_CRC) != 0) { /* skip the header crc */ - for (len = 0; len < 2; len++) (void)get_byte(s); - } - s->z_err = s->z_eof ? Z_DATA_ERROR : Z_OK; -} - - /* =========================================================================== - * Cleanup then free the given gz_stream. Return a zlib error code. - Try freeing in the reverse order of allocations. - */ -local int destroy (s) - gz_stream *s; -{ - int err = Z_OK; - - if (!s) return Z_STREAM_ERROR; - - TRYFREE(s->msg); - - if (s->stream.state != NULL) { - if (s->mode == 'w') { -#ifdef NO_GZCOMPRESS - err = Z_STREAM_ERROR; -#else - err = deflateEnd(&(s->stream)); -#endif - } else if (s->mode == 'r') { - err = inflateEnd(&(s->stream)); - } - } - if (s->file != NULL && fclose(s->file)) { -#ifdef ESPIPE - if (errno != ESPIPE) /* fclose is broken for pipes in HP/UX */ -#endif - err = Z_ERRNO; - } - if (s->z_err < 0) err = s->z_err; - - TRYFREE(s->inbuf); - TRYFREE(s->outbuf); - TRYFREE(s->path); - TRYFREE(s); - return err; -} - -/* =========================================================================== - Reads the given number of uncompressed bytes from the compressed file. - gzread returns the number of bytes actually read (0 for end of file). -*/ -int ZEXPORT gzread (file, buf, len) - gzFile file; - voidp buf; - unsigned len; -{ - gz_stream *s = (gz_stream*)file; - Bytef *start = (Bytef*)buf; /* starting point for crc computation */ - Byte *next_out; /* == stream.next_out but not forced far (for MSDOS) */ - - if (s == NULL || s->mode != 'r') return Z_STREAM_ERROR; - - if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO) return -1; - if (s->z_err == Z_STREAM_END) return 0; /* EOF */ - - next_out = (Byte*)buf; - s->stream.next_out = (Bytef*)buf; - s->stream.avail_out = len; - - if (s->stream.avail_out && s->back != EOF) { - *next_out++ = s->back; - s->stream.next_out++; - s->stream.avail_out--; - s->back = EOF; - s->out++; - start++; - if (s->last) { - s->z_err = Z_STREAM_END; - return 1; - } - } - - while (s->stream.avail_out != 0) { - - if (s->transparent) { - /* Copy first the lookahead bytes: */ - uInt n = s->stream.avail_in; - if (n > s->stream.avail_out) n = s->stream.avail_out; - if (n > 0) { - zmemcpy(s->stream.next_out, s->stream.next_in, n); - next_out += n; - s->stream.next_out = next_out; - s->stream.next_in += n; - s->stream.avail_out -= n; - s->stream.avail_in -= n; - } - if (s->stream.avail_out > 0) { - s->stream.avail_out -= - (uInt)fread(next_out, 1, s->stream.avail_out, s->file); - } - len -= s->stream.avail_out; - s->in += len; - s->out += len; - if (len == 0) s->z_eof = 1; - return (int)len; - } - if (s->stream.avail_in == 0 && !s->z_eof) { - - errno = 0; - s->stream.avail_in = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file); - if (s->stream.avail_in == 0) { - s->z_eof = 1; - if (ferror(s->file)) { - s->z_err = Z_ERRNO; - break; - } - } - s->stream.next_in = s->inbuf; - } - s->in += s->stream.avail_in; - s->out += s->stream.avail_out; - s->z_err = inflate(&(s->stream), Z_NO_FLUSH); - s->in -= s->stream.avail_in; - s->out -= s->stream.avail_out; - - if (s->z_err == Z_STREAM_END) { - /* Check CRC and original size */ - s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); - start = s->stream.next_out; - - if (getLong(s) != s->crc) { - s->z_err = Z_DATA_ERROR; - } else { - (void)getLong(s); - /* The uncompressed length returned by above getlong() may be - * different from s->out in case of concatenated .gz files. - * Check for such files: - */ - check_header(s); - if (s->z_err == Z_OK) { - inflateReset(&(s->stream)); - s->crc = crc32(0L, Z_NULL, 0); - } - } - } - if (s->z_err != Z_OK || s->z_eof) break; - } - s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); - - if (len == s->stream.avail_out && - (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO)) - return -1; - return (int)(len - s->stream.avail_out); -} - - -/* =========================================================================== - Reads one byte from the compressed file. gzgetc returns this byte - or -1 in case of end of file or error. -*/ -int ZEXPORT gzgetc(file) - gzFile file; -{ - unsigned char c; - - return gzread(file, &c, 1) == 1 ? c : -1; -} - - -/* =========================================================================== - Push one byte back onto the stream. -*/ -int ZEXPORT gzungetc(c, file) - int c; - gzFile file; -{ - gz_stream *s = (gz_stream*)file; - - if (s == NULL || s->mode != 'r' || c == EOF || s->back != EOF) return EOF; - s->back = c; - s->out--; - s->last = (s->z_err == Z_STREAM_END); - if (s->last) s->z_err = Z_OK; - s->z_eof = 0; - return c; -} - - -/* =========================================================================== - Reads bytes from the compressed file until len-1 characters are - read, or a newline character is read and transferred to buf, or an - end-of-file condition is encountered. The string is then terminated - with a null character. - gzgets returns buf, or Z_NULL in case of error. - - The current implementation is not optimized at all. -*/ -char * ZEXPORT gzgets(file, buf, len) - gzFile file; - char *buf; - int len; -{ - char *b = buf; - if (buf == Z_NULL || len <= 0) return Z_NULL; - - while (--len > 0 && gzread(file, buf, 1) == 1 && *buf++ != '\n') ; - *buf = '\0'; - return b == buf && len > 0 ? Z_NULL : b; -} - - -#ifndef NO_GZCOMPRESS -/* =========================================================================== - Writes the given number of uncompressed bytes into the compressed file. - gzwrite returns the number of bytes actually written (0 in case of error). -*/ -int ZEXPORT gzwrite (file, buf, len) - gzFile file; - voidpc buf; - unsigned len; -{ - gz_stream *s = (gz_stream*)file; - - if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR; - - s->stream.next_in = (Bytef*)buf; - s->stream.avail_in = len; - - while (s->stream.avail_in != 0) { - - if (s->stream.avail_out == 0) { - - s->stream.next_out = s->outbuf; - if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) { - s->z_err = Z_ERRNO; - break; - } - s->stream.avail_out = Z_BUFSIZE; - } - s->in += s->stream.avail_in; - s->out += s->stream.avail_out; - s->z_err = deflate(&(s->stream), Z_NO_FLUSH); - s->in -= s->stream.avail_in; - s->out -= s->stream.avail_out; - if (s->z_err != Z_OK) break; - } - s->crc = crc32(s->crc, (const Bytef *)buf, len); - - return (int)(len - s->stream.avail_in); -} - - -/* =========================================================================== - Converts, formats, and writes the args to the compressed file under - control of the format string, as in fprintf. gzprintf returns the number of - uncompressed bytes actually written (0 in case of error). -*/ -#ifdef STDC -#include <stdarg.h> - -int ZEXPORTVA gzprintf (gzFile file, const char *format, /* args */ ...) -{ - char buf[Z_PRINTF_BUFSIZE]; - va_list va; - int len; - - buf[sizeof(buf) - 1] = 0; - va_start(va, format); -#ifdef NO_vsnprintf -# ifdef HAS_vsprintf_void - (void)vsprintf(buf, format, va); - va_end(va); - for (len = 0; len < sizeof(buf); len++) - if (buf[len] == 0) break; -# else - len = vsprintf(buf, format, va); - va_end(va); -# endif -#else -# ifdef HAS_vsnprintf_void - (void)vsnprintf(buf, sizeof(buf), format, va); - va_end(va); - len = strlen(buf); -# else - len = vsnprintf(buf, sizeof(buf), format, va); - va_end(va); -# endif -#endif - if (len <= 0 || len >= (int)sizeof(buf) || buf[sizeof(buf) - 1] != 0) - return 0; - return gzwrite(file, buf, (unsigned)len); -} -#else /* not ANSI C */ - -int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, - a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) - gzFile file; - const char *format; - int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, - a11, a12, a13, a14, a15, a16, a17, a18, a19, a20; -{ - char buf[Z_PRINTF_BUFSIZE]; - int len; - - buf[sizeof(buf) - 1] = 0; -#ifdef NO_snprintf -# ifdef HAS_sprintf_void - sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8, - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); - for (len = 0; len < sizeof(buf); len++) - if (buf[len] == 0) break; -# else - len = sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8, - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); -# endif -#else -# ifdef HAS_snprintf_void - snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8, - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); - len = strlen(buf); -# else - len = snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8, - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); -# endif -#endif - if (len <= 0 || len >= sizeof(buf) || buf[sizeof(buf) - 1] != 0) - return 0; - return gzwrite(file, buf, len); -} -#endif - -/* =========================================================================== - Writes c, converted to an unsigned char, into the compressed file. - gzputc returns the value that was written, or -1 in case of error. -*/ -int ZEXPORT gzputc(file, c) - gzFile file; - int c; -{ - unsigned char cc = (unsigned char) c; /* required for big endian systems */ - - return gzwrite(file, &cc, 1) == 1 ? (int)cc : -1; -} - - -/* =========================================================================== - Writes the given null-terminated string to the compressed file, excluding - the terminating null character. - gzputs returns the number of characters written, or -1 in case of error. -*/ -int ZEXPORT gzputs(file, s) - gzFile file; - const char *s; -{ - return gzwrite(file, (char*)s, (unsigned)strlen(s)); -} - - -/* =========================================================================== - Flushes all pending output into the compressed file. The parameter - flush is as in the deflate() function. -*/ -local int do_flush (file, flush) - gzFile file; - int flush; -{ - uInt len; - int done = 0; - gz_stream *s = (gz_stream*)file; - - if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR; - - s->stream.avail_in = 0; /* should be zero already anyway */ - - for (;;) { - len = Z_BUFSIZE - s->stream.avail_out; - - if (len != 0) { - if ((uInt)fwrite(s->outbuf, 1, len, s->file) != len) { - s->z_err = Z_ERRNO; - return Z_ERRNO; - } - s->stream.next_out = s->outbuf; - s->stream.avail_out = Z_BUFSIZE; - } - if (done) break; - s->out += s->stream.avail_out; - s->z_err = deflate(&(s->stream), flush); - s->out -= s->stream.avail_out; - - /* Ignore the second of two consecutive flushes: */ - if (len == 0 && s->z_err == Z_BUF_ERROR) s->z_err = Z_OK; - - /* deflate has finished flushing only when it hasn't used up - * all the available space in the output buffer: - */ - done = (s->stream.avail_out != 0 || s->z_err == Z_STREAM_END); - - if (s->z_err != Z_OK && s->z_err != Z_STREAM_END) break; - } - return s->z_err == Z_STREAM_END ? Z_OK : s->z_err; -} - -int ZEXPORT gzflush (file, flush) - gzFile file; - int flush; -{ - gz_stream *s = (gz_stream*)file; - int err = do_flush (file, flush); - - if (err) return err; - fflush(s->file); - return s->z_err == Z_STREAM_END ? Z_OK : s->z_err; -} -#endif /* NO_GZCOMPRESS */ - -/* =========================================================================== - Sets the starting position for the next gzread or gzwrite on the given - compressed file. The offset represents a number of bytes in the - gzseek returns the resulting offset location as measured in bytes from - the beginning of the uncompressed stream, or -1 in case of error. - SEEK_END is not implemented, returns error. - In this version of the library, gzseek can be extremely slow. -*/ -z_off_t ZEXPORT gzseek (file, offset, whence) - gzFile file; - z_off_t offset; - int whence; -{ - gz_stream *s = (gz_stream*)file; - - if (s == NULL || whence == SEEK_END || - s->z_err == Z_ERRNO || s->z_err == Z_DATA_ERROR) { - return -1L; - } - - if (s->mode == 'w') { -#ifdef NO_GZCOMPRESS - return -1L; -#else - if (whence == SEEK_SET) { - offset -= s->in; - } - if (offset < 0) return -1L; - - /* At this point, offset is the number of zero bytes to write. */ - if (s->inbuf == Z_NULL) { - s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); /* for seeking */ - if (s->inbuf == Z_NULL) return -1L; - zmemzero(s->inbuf, Z_BUFSIZE); - } - while (offset > 0) { - uInt size = Z_BUFSIZE; - if (offset < Z_BUFSIZE) size = (uInt)offset; - - size = gzwrite(file, s->inbuf, size); - if (size == 0) return -1L; - - offset -= size; - } - return s->in; -#endif - } - /* Rest of function is for reading only */ - - /* compute absolute position */ - if (whence == SEEK_CUR) { - offset += s->out; - } - if (offset < 0) return -1L; - - if (s->transparent) { - /* map to fseek */ - s->back = EOF; - s->stream.avail_in = 0; - s->stream.next_in = s->inbuf; - if (fseek(s->file, offset, SEEK_SET) < 0) return -1L; - - s->in = s->out = offset; - return offset; - } - - /* For a negative seek, rewind and use positive seek */ - if (offset >= s->out) { - offset -= s->out; - } else if (gzrewind(file) < 0) { - return -1L; - } - /* offset is now the number of bytes to skip. */ - - if (offset != 0 && s->outbuf == Z_NULL) { - s->outbuf = (Byte*)ALLOC(Z_BUFSIZE); - if (s->outbuf == Z_NULL) return -1L; - } - if (offset && s->back != EOF) { - s->back = EOF; - s->out++; - offset--; - if (s->last) s->z_err = Z_STREAM_END; - } - while (offset > 0) { - int size = Z_BUFSIZE; - if (offset < Z_BUFSIZE) size = (int)offset; - - size = gzread(file, s->outbuf, (uInt)size); - if (size <= 0) return -1L; - offset -= size; - } - return s->out; -} - -/* =========================================================================== - Rewinds input file. -*/ -int ZEXPORT gzrewind (file) - gzFile file; -{ - gz_stream *s = (gz_stream*)file; - - if (s == NULL || s->mode != 'r') return -1; - - s->z_err = Z_OK; - s->z_eof = 0; - s->back = EOF; - s->stream.avail_in = 0; - s->stream.next_in = s->inbuf; - s->crc = crc32(0L, Z_NULL, 0); - if (!s->transparent) (void)inflateReset(&s->stream); - s->in = 0; - s->out = 0; - return fseek(s->file, s->start, SEEK_SET); -} - -/* =========================================================================== - Returns the starting position for the next gzread or gzwrite on the - given compressed file. This position represents a number of bytes in the - uncompressed data stream. -*/ -z_off_t ZEXPORT gztell (file) - gzFile file; -{ - return gzseek(file, 0L, SEEK_CUR); -} - -/* =========================================================================== - Returns 1 when EOF has previously been detected reading the given - input stream, otherwise zero. -*/ -int ZEXPORT gzeof (file) - gzFile file; -{ - gz_stream *s = (gz_stream*)file; - - /* With concatenated compressed files that can have embedded - * crc trailers, z_eof is no longer the only/best indicator of EOF - * on a gz_stream. Handle end-of-stream error explicitly here. - */ - if (s == NULL || s->mode != 'r') return 0; - if (s->z_eof) return 1; - return s->z_err == Z_STREAM_END; -} - -/* =========================================================================== - Returns 1 if reading and doing so transparently, otherwise zero. -*/ -int ZEXPORT gzdirect (file) - gzFile file; -{ - gz_stream *s = (gz_stream*)file; - - if (s == NULL || s->mode != 'r') return 0; - return s->transparent; -} - -/* =========================================================================== - Outputs a long in LSB order to the given file -*/ -local void putLong (file, x) - FILE *file; - uLong x; -{ - int n; - for (n = 0; n < 4; n++) { - fputc((int)(x & 0xff), file); - x >>= 8; - } -} - -/* =========================================================================== - Reads a long in LSB order from the given gz_stream. Sets z_err in case - of error. -*/ -local uLong getLong (s) - gz_stream *s; -{ - uLong x = (uLong)get_byte(s); - int c; - - x += ((uLong)get_byte(s))<<8; - x += ((uLong)get_byte(s))<<16; - c = get_byte(s); - if (c == EOF) s->z_err = Z_DATA_ERROR; - x += ((uLong)c)<<24; - return x; -} - -/* =========================================================================== - Flushes all pending output if necessary, closes the compressed file - and deallocates all the (de)compression state. -*/ -int ZEXPORT gzclose (file) - gzFile file; -{ - gz_stream *s = (gz_stream*)file; - - if (s == NULL) return Z_STREAM_ERROR; - - if (s->mode == 'w') { -#ifdef NO_GZCOMPRESS - return Z_STREAM_ERROR; -#else - if (do_flush (file, Z_FINISH) != Z_OK) - return destroy((gz_stream*)file); - - putLong (s->file, s->crc); - putLong (s->file, (uLong)(s->in & 0xffffffff)); -#endif - } - return destroy((gz_stream*)file); -} - -#ifdef STDC -# define zstrerror(errnum) strerror(errnum) -#else -# define zstrerror(errnum) "" -#endif - -/* =========================================================================== - Returns the error message for the last error which occurred on the - given compressed file. errnum is set to zlib error number. If an - error occurred in the file system and not in the compression library, - errnum is set to Z_ERRNO and the application may consult errno - to get the exact error code. -*/ -const char * ZEXPORT gzerror (file, errnum) - gzFile file; - int *errnum; -{ - char *m; - gz_stream *s = (gz_stream*)file; - - if (s == NULL) { - *errnum = Z_STREAM_ERROR; - return (const char*)ERR_MSG(Z_STREAM_ERROR); - } - *errnum = s->z_err; - if (*errnum == Z_OK) return (const char*)""; - - m = (char*)(*errnum == Z_ERRNO ? zstrerror(errno) : s->stream.msg); - - if (m == NULL || *m == '\0') m = (char*)ERR_MSG(s->z_err); - - TRYFREE(s->msg); - s->msg = (char*)ALLOC(strlen(s->path) + strlen(m) + 3); - if (s->msg == Z_NULL) return (const char*)ERR_MSG(Z_MEM_ERROR); - strcpy(s->msg, s->path); - strcat(s->msg, ": "); - strcat(s->msg, m); - return (const char*)s->msg; -} - -/* =========================================================================== - Clear the error and end-of-file flags, and do the same for the real file. -*/ -void ZEXPORT gzclearerr (file) - gzFile file; -{ - gz_stream *s = (gz_stream*)file; - - if (s == NULL) return; - if (s->z_err != Z_STREAM_END) s->z_err = Z_OK; - s->z_eof = 0; - clearerr(s->file); -} diff --git a/irrlicht-1.6/source/Irrlicht/zlib/infback.c b/irrlicht-1.6/source/Irrlicht/zlib/infback.c deleted file mode 100644 index 1e03e1bab..000000000 --- a/irrlicht-1.6/source/Irrlicht/zlib/infback.c +++ /dev/null @@ -1,623 +0,0 @@ -/* infback.c -- inflate using a call-back interface - * Copyright (C) 1995-2005 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* - This code is largely copied from inflate.c. Normally either infback.o or - inflate.o would be linked into an application--not both. The interface - with inffast.c is retained so that optimized assembler-coded versions of - inflate_fast() can be used with either inflate.c or infback.c. - */ - -#include "zutil.h" -#include "inftrees.h" -#include "inflate.h" -#include "inffast.h" - -/* function prototypes */ -local void fixedtables OF((struct inflate_state FAR *state)); - -/* - strm provides memory allocation functions in zalloc and zfree, or - Z_NULL to use the library memory allocation functions. - - windowBits is in the range 8..15, and window is a user-supplied - window and output buffer that is 2**windowBits bytes. - */ -int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size) -z_streamp strm; -int windowBits; -unsigned char FAR *window; -const char *version; -int stream_size; -{ - struct inflate_state FAR *state; - - if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || - stream_size != (int)(sizeof(z_stream))) - return Z_VERSION_ERROR; - if (strm == Z_NULL || window == Z_NULL || - windowBits < 8 || windowBits > 15) - return Z_STREAM_ERROR; - strm->msg = Z_NULL; /* in case we return an error */ - if (strm->zalloc == (alloc_func)0) { - strm->zalloc = zcalloc; - strm->opaque = (voidpf)0; - } - if (strm->zfree == (free_func)0) strm->zfree = zcfree; - state = (struct inflate_state FAR *)ZALLOC(strm, 1, - sizeof(struct inflate_state)); - if (state == Z_NULL) return Z_MEM_ERROR; - Tracev((stderr, "inflate: allocated\n")); - strm->state = (struct internal_state FAR *)state; - state->dmax = 32768U; - state->wbits = windowBits; - state->wsize = 1U << windowBits; - state->window = window; - state->write = 0; - state->whave = 0; - return Z_OK; -} - -/* - Return state with length and distance decoding tables and index sizes set to - fixed code decoding. Normally this returns fixed tables from inffixed.h. - If BUILDFIXED is defined, then instead this routine builds the tables the - first time it's called, and returns those tables the first time and - thereafter. This reduces the size of the code by about 2K bytes, in - exchange for a little execution time. However, BUILDFIXED should not be - used for threaded applications, since the rewriting of the tables and virgin - may not be thread-safe. - */ -local void fixedtables(state) -struct inflate_state FAR *state; -{ -#ifdef BUILDFIXED - static int virgin = 1; - static code *lenfix, *distfix; - static code fixed[544]; - - /* build fixed huffman tables if first call (may not be thread safe) */ - if (virgin) { - unsigned sym, bits; - static code *next; - - /* literal/length table */ - sym = 0; - while (sym < 144) state->lens[sym++] = 8; - while (sym < 256) state->lens[sym++] = 9; - while (sym < 280) state->lens[sym++] = 7; - while (sym < 288) state->lens[sym++] = 8; - next = fixed; - lenfix = next; - bits = 9; - inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); - - /* distance table */ - sym = 0; - while (sym < 32) state->lens[sym++] = 5; - distfix = next; - bits = 5; - inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); - - /* do this just once */ - virgin = 0; - } -#else /* !BUILDFIXED */ -# include "inffixed.h" -#endif /* BUILDFIXED */ - state->lencode = lenfix; - state->lenbits = 9; - state->distcode = distfix; - state->distbits = 5; -} - -/* Macros for inflateBack(): */ - -/* Load returned state from inflate_fast() */ -#define LOAD() \ - do { \ - put = strm->next_out; \ - left = strm->avail_out; \ - next = strm->next_in; \ - have = strm->avail_in; \ - hold = state->hold; \ - bits = state->bits; \ - } while (0) - -/* Set state from registers for inflate_fast() */ -#define RESTORE() \ - do { \ - strm->next_out = put; \ - strm->avail_out = left; \ - strm->next_in = next; \ - strm->avail_in = have; \ - state->hold = hold; \ - state->bits = bits; \ - } while (0) - -/* Clear the input bit accumulator */ -#define INITBITS() \ - do { \ - hold = 0; \ - bits = 0; \ - } while (0) - -/* Assure that some input is available. If input is requested, but denied, - then return a Z_BUF_ERROR from inflateBack(). */ -#define PULL() \ - do { \ - if (have == 0) { \ - have = in(in_desc, &next); \ - if (have == 0) { \ - next = Z_NULL; \ - ret = Z_BUF_ERROR; \ - goto inf_leave; \ - } \ - } \ - } while (0) - -/* Get a byte of input into the bit accumulator, or return from inflateBack() - with an error if there is no input available. */ -#define PULLBYTE() \ - do { \ - PULL(); \ - have--; \ - hold += (unsigned long)(*next++) << bits; \ - bits += 8; \ - } while (0) - -/* Assure that there are at least n bits in the bit accumulator. If there is - not enough available input to do that, then return from inflateBack() with - an error. */ -#define NEEDBITS(n) \ - do { \ - while (bits < (unsigned)(n)) \ - PULLBYTE(); \ - } while (0) - -/* Return the low n bits of the bit accumulator (n < 16) */ -#define BITS(n) \ - ((unsigned)hold & ((1U << (n)) - 1)) - -/* Remove n bits from the bit accumulator */ -#define DROPBITS(n) \ - do { \ - hold >>= (n); \ - bits -= (unsigned)(n); \ - } while (0) - -/* Remove zero to seven bits as needed to go to a byte boundary */ -#define BYTEBITS() \ - do { \ - hold >>= bits & 7; \ - bits -= bits & 7; \ - } while (0) - -/* Assure that some output space is available, by writing out the window - if it's full. If the write fails, return from inflateBack() with a - Z_BUF_ERROR. */ -#define ROOM() \ - do { \ - if (left == 0) { \ - put = state->window; \ - left = state->wsize; \ - state->whave = left; \ - if (out(out_desc, put, left)) { \ - ret = Z_BUF_ERROR; \ - goto inf_leave; \ - } \ - } \ - } while (0) - -/* - strm provides the memory allocation functions and window buffer on input, - and provides information on the unused input on return. For Z_DATA_ERROR - returns, strm will also provide an error message. - - in() and out() are the call-back input and output functions. When - inflateBack() needs more input, it calls in(). When inflateBack() has - filled the window with output, or when it completes with data in the - window, it calls out() to write out the data. The application must not - change the provided input until in() is called again or inflateBack() - returns. The application must not change the window/output buffer until - inflateBack() returns. - - in() and out() are called with a descriptor parameter provided in the - inflateBack() call. This parameter can be a structure that provides the - information required to do the read or write, as well as accumulated - information on the input and output such as totals and check values. - - in() should return zero on failure. out() should return non-zero on - failure. If either in() or out() fails, than inflateBack() returns a - Z_BUF_ERROR. strm->next_in can be checked for Z_NULL to see whether it - was in() or out() that caused in the error. Otherwise, inflateBack() - returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format - error, or Z_MEM_ERROR if it could not allocate memory for the state. - inflateBack() can also return Z_STREAM_ERROR if the input parameters - are not correct, i.e. strm is Z_NULL or the state was not initialized. - */ -int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc) -z_streamp strm; -in_func in; -void FAR *in_desc; -out_func out; -void FAR *out_desc; -{ - struct inflate_state FAR *state; - unsigned char FAR *next; /* next input */ - unsigned char FAR *put; /* next output */ - unsigned have, left; /* available input and output */ - unsigned long hold; /* bit buffer */ - unsigned bits; /* bits in bit buffer */ - unsigned copy; /* number of stored or match bytes to copy */ - unsigned char FAR *from; /* where to copy match bytes from */ - code this; /* current decoding table entry */ - code last; /* parent table entry */ - unsigned len; /* length to copy for repeats, bits to drop */ - int ret; /* return code */ - static const unsigned short order[19] = /* permutation of code lengths */ - {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; - - /* Check that the strm exists and that the state was initialized */ - if (strm == Z_NULL || strm->state == Z_NULL) - return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - - /* Reset the state */ - strm->msg = Z_NULL; - state->mode = TYPE; - state->last = 0; - state->whave = 0; - next = strm->next_in; - have = next != Z_NULL ? strm->avail_in : 0; - hold = 0; - bits = 0; - put = state->window; - left = state->wsize; - - /* Inflate until end of block marked as last */ - for (;;) - switch (state->mode) { - case TYPE: - /* determine and dispatch block type */ - if (state->last) { - BYTEBITS(); - state->mode = DONE; - break; - } - NEEDBITS(3); - state->last = BITS(1); - DROPBITS(1); - switch (BITS(2)) { - case 0: /* stored block */ - Tracev((stderr, "inflate: stored block%s\n", - state->last ? " (last)" : "")); - state->mode = STORED; - break; - case 1: /* fixed block */ - fixedtables(state); - Tracev((stderr, "inflate: fixed codes block%s\n", - state->last ? " (last)" : "")); - state->mode = LEN; /* decode codes */ - break; - case 2: /* dynamic block */ - Tracev((stderr, "inflate: dynamic codes block%s\n", - state->last ? " (last)" : "")); - state->mode = TABLE; - break; - case 3: - strm->msg = (char *)"invalid block type"; - state->mode = BAD; - } - DROPBITS(2); - break; - - case STORED: - /* get and verify stored block length */ - BYTEBITS(); /* go to byte boundary */ - NEEDBITS(32); - if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { - strm->msg = (char *)"invalid stored block lengths"; - state->mode = BAD; - break; - } - state->length = (unsigned)hold & 0xffff; - Tracev((stderr, "inflate: stored length %u\n", - state->length)); - INITBITS(); - - /* copy stored block from input to output */ - while (state->length != 0) { - copy = state->length; - PULL(); - ROOM(); - if (copy > have) copy = have; - if (copy > left) copy = left; - zmemcpy(put, next, copy); - have -= copy; - next += copy; - left -= copy; - put += copy; - state->length -= copy; - } - Tracev((stderr, "inflate: stored end\n")); - state->mode = TYPE; - break; - - case TABLE: - /* get dynamic table entries descriptor */ - NEEDBITS(14); - state->nlen = BITS(5) + 257; - DROPBITS(5); - state->ndist = BITS(5) + 1; - DROPBITS(5); - state->ncode = BITS(4) + 4; - DROPBITS(4); -#ifndef PKZIP_BUG_WORKAROUND - if (state->nlen > 286 || state->ndist > 30) { - strm->msg = (char *)"too many length or distance symbols"; - state->mode = BAD; - break; - } -#endif - Tracev((stderr, "inflate: table sizes ok\n")); - - /* get code length code lengths (not a typo) */ - state->have = 0; - while (state->have < state->ncode) { - NEEDBITS(3); - state->lens[order[state->have++]] = (unsigned short)BITS(3); - DROPBITS(3); - } - while (state->have < 19) - state->lens[order[state->have++]] = 0; - state->next = state->codes; - state->lencode = (code const FAR *)(state->next); - state->lenbits = 7; - ret = inflate_table(CODES, state->lens, 19, &(state->next), - &(state->lenbits), state->work); - if (ret) { - strm->msg = (char *)"invalid code lengths set"; - state->mode = BAD; - break; - } - Tracev((stderr, "inflate: code lengths ok\n")); - - /* get length and distance code code lengths */ - state->have = 0; - while (state->have < state->nlen + state->ndist) { - for (;;) { - this = state->lencode[BITS(state->lenbits)]; - if ((unsigned)(this.bits) <= bits) break; - PULLBYTE(); - } - if (this.val < 16) { - NEEDBITS(this.bits); - DROPBITS(this.bits); - state->lens[state->have++] = this.val; - } - else { - if (this.val == 16) { - NEEDBITS(this.bits + 2); - DROPBITS(this.bits); - if (state->have == 0) { - strm->msg = (char *)"invalid bit length repeat"; - state->mode = BAD; - break; - } - len = (unsigned)(state->lens[state->have - 1]); - copy = 3 + BITS(2); - DROPBITS(2); - } - else if (this.val == 17) { - NEEDBITS(this.bits + 3); - DROPBITS(this.bits); - len = 0; - copy = 3 + BITS(3); - DROPBITS(3); - } - else { - NEEDBITS(this.bits + 7); - DROPBITS(this.bits); - len = 0; - copy = 11 + BITS(7); - DROPBITS(7); - } - if (state->have + copy > state->nlen + state->ndist) { - strm->msg = (char *)"invalid bit length repeat"; - state->mode = BAD; - break; - } - while (copy--) - state->lens[state->have++] = (unsigned short)len; - } - } - - /* handle error breaks in while */ - if (state->mode == BAD) break; - - /* build code tables */ - state->next = state->codes; - state->lencode = (code const FAR *)(state->next); - state->lenbits = 9; - ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), - &(state->lenbits), state->work); - if (ret) { - strm->msg = (char *)"invalid literal/lengths set"; - state->mode = BAD; - break; - } - state->distcode = (code const FAR *)(state->next); - state->distbits = 6; - ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, - &(state->next), &(state->distbits), state->work); - if (ret) { - strm->msg = (char *)"invalid distances set"; - state->mode = BAD; - break; - } - Tracev((stderr, "inflate: codes ok\n")); - state->mode = LEN; - - case LEN: - /* use inflate_fast() if we have enough input and output */ - if (have >= 6 && left >= 258) { - RESTORE(); - if (state->whave < state->wsize) - state->whave = state->wsize - left; - inflate_fast(strm, state->wsize); - LOAD(); - break; - } - - /* get a literal, length, or end-of-block code */ - for (;;) { - this = state->lencode[BITS(state->lenbits)]; - if ((unsigned)(this.bits) <= bits) break; - PULLBYTE(); - } - if (this.op && (this.op & 0xf0) == 0) { - last = this; - for (;;) { - this = state->lencode[last.val + - (BITS(last.bits + last.op) >> last.bits)]; - if ((unsigned)(last.bits + this.bits) <= bits) break; - PULLBYTE(); - } - DROPBITS(last.bits); - } - DROPBITS(this.bits); - state->length = (unsigned)this.val; - - /* process literal */ - if (this.op == 0) { - Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ? - "inflate: literal '%c'\n" : - "inflate: literal 0x%02x\n", this.val)); - ROOM(); - *put++ = (unsigned char)(state->length); - left--; - state->mode = LEN; - break; - } - - /* process end of block */ - if (this.op & 32) { - Tracevv((stderr, "inflate: end of block\n")); - state->mode = TYPE; - break; - } - - /* invalid code */ - if (this.op & 64) { - strm->msg = (char *)"invalid literal/length code"; - state->mode = BAD; - break; - } - - /* length code -- get extra bits, if any */ - state->extra = (unsigned)(this.op) & 15; - if (state->extra != 0) { - NEEDBITS(state->extra); - state->length += BITS(state->extra); - DROPBITS(state->extra); - } - Tracevv((stderr, "inflate: length %u\n", state->length)); - - /* get distance code */ - for (;;) { - this = state->distcode[BITS(state->distbits)]; - if ((unsigned)(this.bits) <= bits) break; - PULLBYTE(); - } - if ((this.op & 0xf0) == 0) { - last = this; - for (;;) { - this = state->distcode[last.val + - (BITS(last.bits + last.op) >> last.bits)]; - if ((unsigned)(last.bits + this.bits) <= bits) break; - PULLBYTE(); - } - DROPBITS(last.bits); - } - DROPBITS(this.bits); - if (this.op & 64) { - strm->msg = (char *)"invalid distance code"; - state->mode = BAD; - break; - } - state->offset = (unsigned)this.val; - - /* get distance extra bits, if any */ - state->extra = (unsigned)(this.op) & 15; - if (state->extra != 0) { - NEEDBITS(state->extra); - state->offset += BITS(state->extra); - DROPBITS(state->extra); - } - if (state->offset > state->wsize - (state->whave < state->wsize ? - left : 0)) { - strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } - Tracevv((stderr, "inflate: distance %u\n", state->offset)); - - /* copy match from window to output */ - do { - ROOM(); - copy = state->wsize - state->offset; - if (copy < left) { - from = put + copy; - copy = left - copy; - } - else { - from = put - state->offset; - copy = left; - } - if (copy > state->length) copy = state->length; - state->length -= copy; - left -= copy; - do { - *put++ = *from++; - } while (--copy); - } while (state->length != 0); - break; - - case DONE: - /* inflate stream terminated properly -- write leftover output */ - ret = Z_STREAM_END; - if (left < state->wsize) { - if (out(out_desc, state->window, state->wsize - left)) - ret = Z_BUF_ERROR; - } - goto inf_leave; - - case BAD: - ret = Z_DATA_ERROR; - goto inf_leave; - - default: /* can't happen, but makes compilers happy */ - ret = Z_STREAM_ERROR; - goto inf_leave; - } - - /* Return unused input */ - inf_leave: - strm->next_in = next; - strm->avail_in = have; - return ret; -} - -int ZEXPORT inflateBackEnd(strm) -z_streamp strm; -{ - if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) - return Z_STREAM_ERROR; - ZFREE(strm, strm->state); - strm->state = Z_NULL; - Tracev((stderr, "inflate: end\n")); - return Z_OK; -} diff --git a/irrlicht-1.6/source/Irrlicht/zlib/inffast.c b/irrlicht-1.6/source/Irrlicht/zlib/inffast.c deleted file mode 100644 index fa31cad90..000000000 --- a/irrlicht-1.6/source/Irrlicht/zlib/inffast.c +++ /dev/null @@ -1,318 +0,0 @@ -/* inffast.c -- fast decoding - * Copyright (C) 1995-2004 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "zutil.h" -#include "inftrees.h" -#include "inflate.h" -#include "inffast.h" - -#ifndef ASMINF - -/* Allow machine dependent optimization for post-increment or pre-increment. - Based on testing to date, - Pre-increment preferred for: - - PowerPC G3 (Adler) - - MIPS R5000 (Randers-Pehrson) - Post-increment preferred for: - - none - No measurable difference: - - Pentium III (Anderson) - - M68060 (Nikl) - */ -#ifdef POSTINC -# define OFF 0 -# define PUP(a) *(a)++ -#else -# define OFF 1 -# define PUP(a) *++(a) -#endif - -/* - Decode literal, length, and distance codes and write out the resulting - literal and match bytes until either not enough input or output is - available, an end-of-block is encountered, or a data error is encountered. - When large enough input and output buffers are supplied to inflate(), for - example, a 16K input buffer and a 64K output buffer, more than 95% of the - inflate execution time is spent in this routine. - - Entry assumptions: - - state->mode == LEN - strm->avail_in >= 6 - strm->avail_out >= 258 - start >= strm->avail_out - state->bits < 8 - - On return, state->mode is one of: - - LEN -- ran out of enough output space or enough available input - TYPE -- reached end of block code, inflate() to interpret next block - BAD -- error in block data - - Notes: - - - The maximum input bits used by a length/distance pair is 15 bits for the - length code, 5 bits for the length extra, 15 bits for the distance code, - and 13 bits for the distance extra. This totals 48 bits, or six bytes. - Therefore if strm->avail_in >= 6, then there is enough input to avoid - checking for available input while decoding. - - - The maximum bytes that a single length/distance pair can output is 258 - bytes, which is the maximum length that can be coded. inflate_fast() - requires strm->avail_out >= 258 for each loop to avoid checking for - output space. - */ -void inflate_fast(strm, start) -z_streamp strm; -unsigned start; /* inflate()'s starting value for strm->avail_out */ -{ - struct inflate_state FAR *state; - unsigned char FAR *in; /* local strm->next_in */ - unsigned char FAR *last; /* while in < last, enough input available */ - unsigned char FAR *out; /* local strm->next_out */ - unsigned char FAR *beg; /* inflate()'s initial strm->next_out */ - unsigned char FAR *end; /* while out < end, enough space available */ -#ifdef INFLATE_STRICT - unsigned dmax; /* maximum distance from zlib header */ -#endif - unsigned wsize; /* window size or zero if not using window */ - unsigned whave; /* valid bytes in the window */ - unsigned write; /* window write index */ - unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */ - unsigned long hold; /* local strm->hold */ - unsigned bits; /* local strm->bits */ - code const FAR *lcode; /* local strm->lencode */ - code const FAR *dcode; /* local strm->distcode */ - unsigned lmask; /* mask for first level of length codes */ - unsigned dmask; /* mask for first level of distance codes */ - code this; /* retrieved table entry */ - unsigned op; /* code bits, operation, extra bits, or */ - /* window position, window bytes to copy */ - unsigned len; /* match length, unused bytes */ - unsigned dist; /* match distance */ - unsigned char FAR *from; /* where to copy match from */ - - /* copy state to local variables */ - state = (struct inflate_state FAR *)strm->state; - in = strm->next_in - OFF; - last = in + (strm->avail_in - 5); - out = strm->next_out - OFF; - beg = out - (start - strm->avail_out); - end = out + (strm->avail_out - 257); -#ifdef INFLATE_STRICT - dmax = state->dmax; -#endif - wsize = state->wsize; - whave = state->whave; - write = state->write; - window = state->window; - hold = state->hold; - bits = state->bits; - lcode = state->lencode; - dcode = state->distcode; - lmask = (1U << state->lenbits) - 1; - dmask = (1U << state->distbits) - 1; - - /* decode literals and length/distances until end-of-block or not enough - input data or output space */ - do { - if (bits < 15) { - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - } - this = lcode[hold & lmask]; - dolen: - op = (unsigned)(this.bits); - hold >>= op; - bits -= op; - op = (unsigned)(this.op); - if (op == 0) { /* literal */ - Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ? - "inflate: literal '%c'\n" : - "inflate: literal 0x%02x\n", this.val)); - PUP(out) = (unsigned char)(this.val); - } - else if (op & 16) { /* length base */ - len = (unsigned)(this.val); - op &= 15; /* number of extra bits */ - if (op) { - if (bits < op) { - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - } - len += (unsigned)hold & ((1U << op) - 1); - hold >>= op; - bits -= op; - } - Tracevv((stderr, "inflate: length %u\n", len)); - if (bits < 15) { - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - } - this = dcode[hold & dmask]; - dodist: - op = (unsigned)(this.bits); - hold >>= op; - bits -= op; - op = (unsigned)(this.op); - if (op & 16) { /* distance base */ - dist = (unsigned)(this.val); - op &= 15; /* number of extra bits */ - if (bits < op) { - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - if (bits < op) { - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - } - } - dist += (unsigned)hold & ((1U << op) - 1); -#ifdef INFLATE_STRICT - if (dist > dmax) { - strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } -#endif - hold >>= op; - bits -= op; - Tracevv((stderr, "inflate: distance %u\n", dist)); - op = (unsigned)(out - beg); /* max distance in output */ - if (dist > op) { /* see if copy from window */ - op = dist - op; /* distance back in window */ - if (op > whave) { - strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } - from = window - OFF; - if (write == 0) { /* very common case */ - from += wsize - op; - if (op < len) { /* some from window */ - len -= op; - do { - PUP(out) = PUP(from); - } while (--op); - from = out - dist; /* rest from output */ - } - } - else if (write < op) { /* wrap around window */ - from += wsize + write - op; - op -= write; - if (op < len) { /* some from end of window */ - len -= op; - do { - PUP(out) = PUP(from); - } while (--op); - from = window - OFF; - if (write < len) { /* some from start of window */ - op = write; - len -= op; - do { - PUP(out) = PUP(from); - } while (--op); - from = out - dist; /* rest from output */ - } - } - } - else { /* contiguous in window */ - from += write - op; - if (op < len) { /* some from window */ - len -= op; - do { - PUP(out) = PUP(from); - } while (--op); - from = out - dist; /* rest from output */ - } - } - while (len > 2) { - PUP(out) = PUP(from); - PUP(out) = PUP(from); - PUP(out) = PUP(from); - len -= 3; - } - if (len) { - PUP(out) = PUP(from); - if (len > 1) - PUP(out) = PUP(from); - } - } - else { - from = out - dist; /* copy direct from output */ - do { /* minimum length is three */ - PUP(out) = PUP(from); - PUP(out) = PUP(from); - PUP(out) = PUP(from); - len -= 3; - } while (len > 2); - if (len) { - PUP(out) = PUP(from); - if (len > 1) - PUP(out) = PUP(from); - } - } - } - else if ((op & 64) == 0) { /* 2nd level distance code */ - this = dcode[this.val + (hold & ((1U << op) - 1))]; - goto dodist; - } - else { - strm->msg = (char *)"invalid distance code"; - state->mode = BAD; - break; - } - } - else if ((op & 64) == 0) { /* 2nd level length code */ - this = lcode[this.val + (hold & ((1U << op) - 1))]; - goto dolen; - } - else if (op & 32) { /* end-of-block */ - Tracevv((stderr, "inflate: end of block\n")); - state->mode = TYPE; - break; - } - else { - strm->msg = (char *)"invalid literal/length code"; - state->mode = BAD; - break; - } - } while (in < last && out < end); - - /* return unused bytes (on entry, bits < 8, so in won't go too far back) */ - len = bits >> 3; - in -= len; - bits -= len << 3; - hold &= (1U << bits) - 1; - - /* update state and return */ - strm->next_in = in + OFF; - strm->next_out = out + OFF; - strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last)); - strm->avail_out = (unsigned)(out < end ? - 257 + (end - out) : 257 - (out - end)); - state->hold = hold; - state->bits = bits; - return; -} - -/* - inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe): - - Using bit fields for code structure - - Different op definition to avoid & for extra bits (do & for table bits) - - Three separate decoding do-loops for direct, window, and write == 0 - - Special case for distance > 1 copies to do overlapped load and store copy - - Explicit branch predictions (based on measured branch probabilities) - - Deferring match copy and interspersed it with decoding subsequent codes - - Swapping literal/length else - - Swapping window/direct else - - Larger unrolled copy loops (three is about right) - - Moving len -= 3 statement into middle of loop - */ - -#endif /* !ASMINF */ diff --git a/irrlicht-1.6/source/Irrlicht/zlib/inffast.h b/irrlicht-1.6/source/Irrlicht/zlib/inffast.h deleted file mode 100644 index 614fa7877..000000000 --- a/irrlicht-1.6/source/Irrlicht/zlib/inffast.h +++ /dev/null @@ -1,11 +0,0 @@ -/* inffast.h -- header to use inffast.c - * Copyright (C) 1995-2003 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -void inflate_fast OF((z_streamp strm, unsigned start)); diff --git a/irrlicht-1.6/source/Irrlicht/zlib/inffixed.h b/irrlicht-1.6/source/Irrlicht/zlib/inffixed.h deleted file mode 100644 index 423d5c5b5..000000000 --- a/irrlicht-1.6/source/Irrlicht/zlib/inffixed.h +++ /dev/null @@ -1,94 +0,0 @@ - /* inffixed.h -- table for decoding fixed codes - * Generated automatically by makefixed(). - */ - - /* WARNING: this file should *not* be used by applications. It - is part of the implementation of the compression library and - is subject to change. Applications should only use zlib.h. - */ - - static const code lenfix[512] = { - {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48}, - {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128}, - {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59}, - {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176}, - {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20}, - {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100}, - {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8}, - {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216}, - {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76}, - {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114}, - {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2}, - {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148}, - {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42}, - {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86}, - {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15}, - {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236}, - {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62}, - {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142}, - {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31}, - {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162}, - {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25}, - {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105}, - {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4}, - {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202}, - {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69}, - {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125}, - {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13}, - {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195}, - {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35}, - {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91}, - {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19}, - {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246}, - {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55}, - {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135}, - {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99}, - {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190}, - {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16}, - {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96}, - {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6}, - {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209}, - {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72}, - {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116}, - {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4}, - {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153}, - {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44}, - {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82}, - {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11}, - {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229}, - {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58}, - {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138}, - {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51}, - {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173}, - {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30}, - {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110}, - {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0}, - {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195}, - {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65}, - {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121}, - {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9}, - {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258}, - {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37}, - {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93}, - {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23}, - {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251}, - {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51}, - {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131}, - {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67}, - {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183}, - {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23}, - {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103}, - {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9}, - {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223}, - {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79}, - {0,9,255} - }; - - static const code distfix[32] = { - {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025}, - {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193}, - {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385}, - {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577}, - {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073}, - {22,5,193},{64,5,0} - }; diff --git a/irrlicht-1.6/source/Irrlicht/zlib/inflate.c b/irrlicht-1.6/source/Irrlicht/zlib/inflate.c deleted file mode 100644 index 33ea90292..000000000 --- a/irrlicht-1.6/source/Irrlicht/zlib/inflate.c +++ /dev/null @@ -1,1368 +0,0 @@ -/* inflate.c -- zlib decompression - * Copyright (C) 1995-2005 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* - * Change history: - * - * 1.2.beta0 24 Nov 2002 - * - First version -- complete rewrite of inflate to simplify code, avoid - * creation of window when not needed, minimize use of window when it is - * needed, make inffast.c even faster, implement gzip decoding, and to - * improve code readability and style over the previous zlib inflate code - * - * 1.2.beta1 25 Nov 2002 - * - Use pointers for available input and output checking in inffast.c - * - Remove input and output counters in inffast.c - * - Change inffast.c entry and loop from avail_in >= 7 to >= 6 - * - Remove unnecessary second byte pull from length extra in inffast.c - * - Unroll direct copy to three copies per loop in inffast.c - * - * 1.2.beta2 4 Dec 2002 - * - Change external routine names to reduce potential conflicts - * - Correct filename to inffixed.h for fixed tables in inflate.c - * - Make hbuf[] unsigned char to match parameter type in inflate.c - * - Change strm->next_out[-state->offset] to *(strm->next_out - state->offset) - * to avoid negation problem on Alphas (64 bit) in inflate.c - * - * 1.2.beta3 22 Dec 2002 - * - Add comments on state->bits assertion in inffast.c - * - Add comments on op field in inftrees.h - * - Fix bug in reuse of allocated window after inflateReset() - * - Remove bit fields--back to byte structure for speed - * - Remove distance extra == 0 check in inflate_fast()--only helps for lengths - * - Change post-increments to pre-increments in inflate_fast(), PPC biased? - * - Add compile time option, POSTINC, to use post-increments instead (Intel?) - * - Make MATCH copy in inflate() much faster for when inflate_fast() not used - * - Use local copies of stream next and avail values, as well as local bit - * buffer and bit count in inflate()--for speed when inflate_fast() not used - * - * 1.2.beta4 1 Jan 2003 - * - Split ptr - 257 statements in inflate_table() to avoid compiler warnings - * - Move a comment on output buffer sizes from inffast.c to inflate.c - * - Add comments in inffast.c to introduce the inflate_fast() routine - * - Rearrange window copies in inflate_fast() for speed and simplification - * - Unroll last copy for window match in inflate_fast() - * - Use local copies of window variables in inflate_fast() for speed - * - Pull out common write == 0 case for speed in inflate_fast() - * - Make op and len in inflate_fast() unsigned for consistency - * - Add FAR to lcode and dcode declarations in inflate_fast() - * - Simplified bad distance check in inflate_fast() - * - Added inflateBackInit(), inflateBack(), and inflateBackEnd() in new - * source file infback.c to provide a call-back interface to inflate for - * programs like gzip and unzip -- uses window as output buffer to avoid - * window copying - * - * 1.2.beta5 1 Jan 2003 - * - Improved inflateBack() interface to allow the caller to provide initial - * input in strm. - * - Fixed stored blocks bug in inflateBack() - * - * 1.2.beta6 4 Jan 2003 - * - Added comments in inffast.c on effectiveness of POSTINC - * - Typecasting all around to reduce compiler warnings - * - Changed loops from while (1) or do {} while (1) to for (;;), again to - * make compilers happy - * - Changed type of window in inflateBackInit() to unsigned char * - * - * 1.2.beta7 27 Jan 2003 - * - Changed many types to unsigned or unsigned short to avoid warnings - * - Added inflateCopy() function - * - * 1.2.0 9 Mar 2003 - * - Changed inflateBack() interface to provide separate opaque descriptors - * for the in() and out() functions - * - Changed inflateBack() argument and in_func typedef to swap the length - * and buffer address return values for the input function - * - Check next_in and next_out for Z_NULL on entry to inflate() - * - * The history for versions after 1.2.0 are in ChangeLog in zlib distribution. - */ - -#include "zutil.h" -#include "inftrees.h" -#include "inflate.h" -#include "inffast.h" - -#ifdef MAKEFIXED -# ifndef BUILDFIXED -# define BUILDFIXED -# endif -#endif - -/* function prototypes */ -local void fixedtables OF((struct inflate_state FAR *state)); -local int updatewindow OF((z_streamp strm, unsigned out)); -#ifdef BUILDFIXED - void makefixed OF((void)); -#endif -local unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf, - unsigned len)); - -int ZEXPORT inflateReset(strm) -z_streamp strm; -{ - struct inflate_state FAR *state; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - strm->total_in = strm->total_out = state->total = 0; - strm->msg = Z_NULL; - strm->adler = 1; /* to support ill-conceived Java test suite */ - state->mode = HEAD; - state->last = 0; - state->havedict = 0; - state->dmax = 32768U; - state->head = Z_NULL; - state->wsize = 0; - state->whave = 0; - state->write = 0; - state->hold = 0; - state->bits = 0; - state->lencode = state->distcode = state->next = state->codes; - Tracev((stderr, "inflate: reset\n")); - return Z_OK; -} - -int ZEXPORT inflatePrime(strm, bits, value) -z_streamp strm; -int bits; -int value; -{ - struct inflate_state FAR *state; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR; - value &= (1L << bits) - 1; - state->hold += value << state->bits; - state->bits += bits; - return Z_OK; -} - -int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size) -z_streamp strm; -int windowBits; -const char *version; -int stream_size; -{ - struct inflate_state FAR *state; - - if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || - stream_size != (int)(sizeof(z_stream))) - return Z_VERSION_ERROR; - if (strm == Z_NULL) return Z_STREAM_ERROR; - strm->msg = Z_NULL; /* in case we return an error */ - if (strm->zalloc == (alloc_func)0) { - strm->zalloc = zcalloc; - strm->opaque = (voidpf)0; - } - if (strm->zfree == (free_func)0) strm->zfree = zcfree; - state = (struct inflate_state FAR *) - ZALLOC(strm, 1, sizeof(struct inflate_state)); - if (state == Z_NULL) return Z_MEM_ERROR; - Tracev((stderr, "inflate: allocated\n")); - strm->state = (struct internal_state FAR *)state; - if (windowBits < 0) { - state->wrap = 0; - windowBits = -windowBits; - } - else { - state->wrap = (windowBits >> 4) + 1; -#ifdef GUNZIP - if (windowBits < 48) windowBits &= 15; -#endif - } - if (windowBits < 8 || windowBits > 15) { - ZFREE(strm, state); - strm->state = Z_NULL; - return Z_STREAM_ERROR; - } - state->wbits = (unsigned)windowBits; - state->window = Z_NULL; - return inflateReset(strm); -} - -int ZEXPORT inflateInit_(strm, version, stream_size) -z_streamp strm; -const char *version; -int stream_size; -{ - return inflateInit2_(strm, DEF_WBITS, version, stream_size); -} - -/* - Return state with length and distance decoding tables and index sizes set to - fixed code decoding. Normally this returns fixed tables from inffixed.h. - If BUILDFIXED is defined, then instead this routine builds the tables the - first time it's called, and returns those tables the first time and - thereafter. This reduces the size of the code by about 2K bytes, in - exchange for a little execution time. However, BUILDFIXED should not be - used for threaded applications, since the rewriting of the tables and virgin - may not be thread-safe. - */ -local void fixedtables(state) -struct inflate_state FAR *state; -{ -#ifdef BUILDFIXED - static int virgin = 1; - static code *lenfix, *distfix; - static code fixed[544]; - - /* build fixed huffman tables if first call (may not be thread safe) */ - if (virgin) { - unsigned sym, bits; - static code *next; - - /* literal/length table */ - sym = 0; - while (sym < 144) state->lens[sym++] = 8; - while (sym < 256) state->lens[sym++] = 9; - while (sym < 280) state->lens[sym++] = 7; - while (sym < 288) state->lens[sym++] = 8; - next = fixed; - lenfix = next; - bits = 9; - inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); - - /* distance table */ - sym = 0; - while (sym < 32) state->lens[sym++] = 5; - distfix = next; - bits = 5; - inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); - - /* do this just once */ - virgin = 0; - } -#else /* !BUILDFIXED */ -# include "inffixed.h" -#endif /* BUILDFIXED */ - state->lencode = lenfix; - state->lenbits = 9; - state->distcode = distfix; - state->distbits = 5; -} - -#ifdef MAKEFIXED -#include <stdio.h> - -/* - Write out the inffixed.h that is #include'd above. Defining MAKEFIXED also - defines BUILDFIXED, so the tables are built on the fly. makefixed() writes - those tables to stdout, which would be piped to inffixed.h. A small program - can simply call makefixed to do this: - - void makefixed(void); - - int main(void) - { - makefixed(); - return 0; - } - - Then that can be linked with zlib built with MAKEFIXED defined and run: - - a.out > inffixed.h - */ -void makefixed() -{ - unsigned low, size; - struct inflate_state state; - - fixedtables(&state); - puts(" /* inffixed.h -- table for decoding fixed codes"); - puts(" * Generated automatically by makefixed()."); - puts(" */"); - puts(""); - puts(" /* WARNING: this file should *not* be used by applications."); - puts(" It is part of the implementation of this library and is"); - puts(" subject to change. Applications should only use zlib.h."); - puts(" */"); - puts(""); - size = 1U << 9; - printf(" static const code lenfix[%u] = {", size); - low = 0; - for (;;) { - if ((low % 7) == 0) printf("\n "); - printf("{%u,%u,%d}", state.lencode[low].op, state.lencode[low].bits, - state.lencode[low].val); - if (++low == size) break; - putchar(','); - } - puts("\n };"); - size = 1U << 5; - printf("\n static const code distfix[%u] = {", size); - low = 0; - for (;;) { - if ((low % 6) == 0) printf("\n "); - printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits, - state.distcode[low].val); - if (++low == size) break; - putchar(','); - } - puts("\n };"); -} -#endif /* MAKEFIXED */ - -/* - Update the window with the last wsize (normally 32K) bytes written before - returning. If window does not exist yet, create it. This is only called - when a window is already in use, or when output has been written during this - inflate call, but the end of the deflate stream has not been reached yet. - It is also called to create a window for dictionary data when a dictionary - is loaded. - - Providing output buffers larger than 32K to inflate() should provide a speed - advantage, since only the last 32K of output is copied to the sliding window - upon return from inflate(), and since all distances after the first 32K of - output will fall in the output data, making match copies simpler and faster. - The advantage may be dependent on the size of the processor's data caches. - */ -local int updatewindow(strm, out) -z_streamp strm; -unsigned out; -{ - struct inflate_state FAR *state; - unsigned copy, dist; - - state = (struct inflate_state FAR *)strm->state; - - /* if it hasn't been done already, allocate space for the window */ - if (state->window == Z_NULL) { - state->window = (unsigned char FAR *) - ZALLOC(strm, 1U << state->wbits, - sizeof(unsigned char)); - if (state->window == Z_NULL) return 1; - } - - /* if window not in use yet, initialize */ - if (state->wsize == 0) { - state->wsize = 1U << state->wbits; - state->write = 0; - state->whave = 0; - } - - /* copy state->wsize or less output bytes into the circular window */ - copy = out - strm->avail_out; - if (copy >= state->wsize) { - zmemcpy(state->window, strm->next_out - state->wsize, state->wsize); - state->write = 0; - state->whave = state->wsize; - } - else { - dist = state->wsize - state->write; - if (dist > copy) dist = copy; - zmemcpy(state->window + state->write, strm->next_out - copy, dist); - copy -= dist; - if (copy) { - zmemcpy(state->window, strm->next_out - copy, copy); - state->write = copy; - state->whave = state->wsize; - } - else { - state->write += dist; - if (state->write == state->wsize) state->write = 0; - if (state->whave < state->wsize) state->whave += dist; - } - } - return 0; -} - -/* Macros for inflate(): */ - -/* check function to use adler32() for zlib or crc32() for gzip */ -#ifdef GUNZIP -# define UPDATE(check, buf, len) \ - (state->flags ? crc32(check, buf, len) : adler32(check, buf, len)) -#else -# define UPDATE(check, buf, len) adler32(check, buf, len) -#endif - -/* check macros for header crc */ -#ifdef GUNZIP -# define CRC2(check, word) \ - do { \ - hbuf[0] = (unsigned char)(word); \ - hbuf[1] = (unsigned char)((word) >> 8); \ - check = crc32(check, hbuf, 2); \ - } while (0) - -# define CRC4(check, word) \ - do { \ - hbuf[0] = (unsigned char)(word); \ - hbuf[1] = (unsigned char)((word) >> 8); \ - hbuf[2] = (unsigned char)((word) >> 16); \ - hbuf[3] = (unsigned char)((word) >> 24); \ - check = crc32(check, hbuf, 4); \ - } while (0) -#endif - -/* Load registers with state in inflate() for speed */ -#define LOAD() \ - do { \ - put = strm->next_out; \ - left = strm->avail_out; \ - next = strm->next_in; \ - have = strm->avail_in; \ - hold = state->hold; \ - bits = state->bits; \ - } while (0) - -/* Restore state from registers in inflate() */ -#define RESTORE() \ - do { \ - strm->next_out = put; \ - strm->avail_out = left; \ - strm->next_in = next; \ - strm->avail_in = have; \ - state->hold = hold; \ - state->bits = bits; \ - } while (0) - -/* Clear the input bit accumulator */ -#define INITBITS() \ - do { \ - hold = 0; \ - bits = 0; \ - } while (0) - -/* Get a byte of input into the bit accumulator, or return from inflate() - if there is no input available. */ -#define PULLBYTE() \ - do { \ - if (have == 0) goto inf_leave; \ - have--; \ - hold += (unsigned long)(*next++) << bits; \ - bits += 8; \ - } while (0) - -/* Assure that there are at least n bits in the bit accumulator. If there is - not enough available input to do that, then return from inflate(). */ -#define NEEDBITS(n) \ - do { \ - while (bits < (unsigned)(n)) \ - PULLBYTE(); \ - } while (0) - -/* Return the low n bits of the bit accumulator (n < 16) */ -#define BITS(n) \ - ((unsigned)hold & ((1U << (n)) - 1)) - -/* Remove n bits from the bit accumulator */ -#define DROPBITS(n) \ - do { \ - hold >>= (n); \ - bits -= (unsigned)(n); \ - } while (0) - -/* Remove zero to seven bits as needed to go to a byte boundary */ -#define BYTEBITS() \ - do { \ - hold >>= bits & 7; \ - bits -= bits & 7; \ - } while (0) - -/* Reverse the bytes in a 32-bit value */ -#define REVERSE(q) \ - ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \ - (((q) & 0xff00) << 8) + (((q) & 0xff) << 24)) - -/* - inflate() uses a state machine to process as much input data and generate as - much output data as possible before returning. The state machine is - structured roughly as follows: - - for (;;) switch (state) { - ... - case STATEn: - if (not enough input data or output space to make progress) - return; - ... make progress ... - state = STATEm; - break; - ... - } - - so when inflate() is called again, the same case is attempted again, and - if the appropriate resources are provided, the machine proceeds to the - next state. The NEEDBITS() macro is usually the way the state evaluates - whether it can proceed or should return. NEEDBITS() does the return if - the requested bits are not available. The typical use of the BITS macros - is: - - NEEDBITS(n); - ... do something with BITS(n) ... - DROPBITS(n); - - where NEEDBITS(n) either returns from inflate() if there isn't enough - input left to load n bits into the accumulator, or it continues. BITS(n) - gives the low n bits in the accumulator. When done, DROPBITS(n) drops - the low n bits off the accumulator. INITBITS() clears the accumulator - and sets the number of available bits to zero. BYTEBITS() discards just - enough bits to put the accumulator on a byte boundary. After BYTEBITS() - and a NEEDBITS(8), then BITS(8) would return the next byte in the stream. - - NEEDBITS(n) uses PULLBYTE() to get an available byte of input, or to return - if there is no input available. The decoding of variable length codes uses - PULLBYTE() directly in order to pull just enough bytes to decode the next - code, and no more. - - Some states loop until they get enough input, making sure that enough - state information is maintained to continue the loop where it left off - if NEEDBITS() returns in the loop. For example, want, need, and keep - would all have to actually be part of the saved state in case NEEDBITS() - returns: - - case STATEw: - while (want < need) { - NEEDBITS(n); - keep[want++] = BITS(n); - DROPBITS(n); - } - state = STATEx; - case STATEx: - - As shown above, if the next state is also the next case, then the break - is omitted. - - A state may also return if there is not enough output space available to - complete that state. Those states are copying stored data, writing a - literal byte, and copying a matching string. - - When returning, a "goto inf_leave" is used to update the total counters, - update the check value, and determine whether any progress has been made - during that inflate() call in order to return the proper return code. - Progress is defined as a change in either strm->avail_in or strm->avail_out. - When there is a window, goto inf_leave will update the window with the last - output written. If a goto inf_leave occurs in the middle of decompression - and there is no window currently, goto inf_leave will create one and copy - output to the window for the next call of inflate(). - - In this implementation, the flush parameter of inflate() only affects the - return code (per zlib.h). inflate() always writes as much as possible to - strm->next_out, given the space available and the provided input--the effect - documented in zlib.h of Z_SYNC_FLUSH. Furthermore, inflate() always defers - the allocation of and copying into a sliding window until necessary, which - provides the effect documented in zlib.h for Z_FINISH when the entire input - stream available. So the only thing the flush parameter actually does is: - when flush is set to Z_FINISH, inflate() cannot return Z_OK. Instead it - will return Z_BUF_ERROR if it has not reached the end of the stream. - */ - -int ZEXPORT inflate(strm, flush) -z_streamp strm; -int flush; -{ - struct inflate_state FAR *state; - unsigned char FAR *next; /* next input */ - unsigned char FAR *put; /* next output */ - unsigned have, left; /* available input and output */ - unsigned long hold; /* bit buffer */ - unsigned bits; /* bits in bit buffer */ - unsigned in, out; /* save starting available input and output */ - unsigned copy; /* number of stored or match bytes to copy */ - unsigned char FAR *from; /* where to copy match bytes from */ - code this; /* current decoding table entry */ - code last; /* parent table entry */ - unsigned len; /* length to copy for repeats, bits to drop */ - int ret; /* return code */ -#ifdef GUNZIP - unsigned char hbuf[4]; /* buffer for gzip header crc calculation */ -#endif - static const unsigned short order[19] = /* permutation of code lengths */ - {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; - - if (strm == Z_NULL || strm->state == Z_NULL || strm->next_out == Z_NULL || - (strm->next_in == Z_NULL && strm->avail_in != 0)) - return Z_STREAM_ERROR; - - state = (struct inflate_state FAR *)strm->state; - if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */ - LOAD(); - in = have; - out = left; - ret = Z_OK; - for (;;) - switch (state->mode) { - case HEAD: - if (state->wrap == 0) { - state->mode = TYPEDO; - break; - } - NEEDBITS(16); -#ifdef GUNZIP - if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */ - state->check = crc32(0L, Z_NULL, 0); - CRC2(state->check, hold); - INITBITS(); - state->mode = FLAGS; - break; - } - state->flags = 0; /* expect zlib header */ - if (state->head != Z_NULL) - state->head->done = -1; - if (!(state->wrap & 1) || /* check if zlib header allowed */ -#else - if ( -#endif - ((BITS(8) << 8) + (hold >> 8)) % 31) { - strm->msg = (char *)"incorrect header check"; - state->mode = BAD; - break; - } - if (BITS(4) != Z_DEFLATED) { - strm->msg = (char *)"unknown compression method"; - state->mode = BAD; - break; - } - DROPBITS(4); - len = BITS(4) + 8; - if (len > state->wbits) { - strm->msg = (char *)"invalid window size"; - state->mode = BAD; - break; - } - state->dmax = 1U << len; - Tracev((stderr, "inflate: zlib header ok\n")); - strm->adler = state->check = adler32(0L, Z_NULL, 0); - state->mode = hold & 0x200 ? DICTID : TYPE; - INITBITS(); - break; -#ifdef GUNZIP - case FLAGS: - NEEDBITS(16); - state->flags = (int)(hold); - if ((state->flags & 0xff) != Z_DEFLATED) { - strm->msg = (char *)"unknown compression method"; - state->mode = BAD; - break; - } - if (state->flags & 0xe000) { - strm->msg = (char *)"unknown header flags set"; - state->mode = BAD; - break; - } - if (state->head != Z_NULL) - state->head->text = (int)((hold >> 8) & 1); - if (state->flags & 0x0200) CRC2(state->check, hold); - INITBITS(); - state->mode = TIME; - case TIME: - NEEDBITS(32); - if (state->head != Z_NULL) - state->head->time = hold; - if (state->flags & 0x0200) CRC4(state->check, hold); - INITBITS(); - state->mode = OS; - case OS: - NEEDBITS(16); - if (state->head != Z_NULL) { - state->head->xflags = (int)(hold & 0xff); - state->head->os = (int)(hold >> 8); - } - if (state->flags & 0x0200) CRC2(state->check, hold); - INITBITS(); - state->mode = EXLEN; - case EXLEN: - if (state->flags & 0x0400) { - NEEDBITS(16); - state->length = (unsigned)(hold); - if (state->head != Z_NULL) - state->head->extra_len = (unsigned)hold; - if (state->flags & 0x0200) CRC2(state->check, hold); - INITBITS(); - } - else if (state->head != Z_NULL) - state->head->extra = Z_NULL; - state->mode = EXTRA; - case EXTRA: - if (state->flags & 0x0400) { - copy = state->length; - if (copy > have) copy = have; - if (copy) { - if (state->head != Z_NULL && - state->head->extra != Z_NULL) { - len = state->head->extra_len - state->length; - zmemcpy(state->head->extra + len, next, - len + copy > state->head->extra_max ? - state->head->extra_max - len : copy); - } - if (state->flags & 0x0200) - state->check = crc32(state->check, next, copy); - have -= copy; - next += copy; - state->length -= copy; - } - if (state->length) goto inf_leave; - } - state->length = 0; - state->mode = NAME; - case NAME: - if (state->flags & 0x0800) { - if (have == 0) goto inf_leave; - copy = 0; - do { - len = (unsigned)(next[copy++]); - if (state->head != Z_NULL && - state->head->name != Z_NULL && - state->length < state->head->name_max) - state->head->name[state->length++] = len; - } while (len && copy < have); - if (state->flags & 0x0200) - state->check = crc32(state->check, next, copy); - have -= copy; - next += copy; - if (len) goto inf_leave; - } - else if (state->head != Z_NULL) - state->head->name = Z_NULL; - state->length = 0; - state->mode = COMMENT; - case COMMENT: - if (state->flags & 0x1000) { - if (have == 0) goto inf_leave; - copy = 0; - do { - len = (unsigned)(next[copy++]); - if (state->head != Z_NULL && - state->head->comment != Z_NULL && - state->length < state->head->comm_max) - state->head->comment[state->length++] = len; - } while (len && copy < have); - if (state->flags & 0x0200) - state->check = crc32(state->check, next, copy); - have -= copy; - next += copy; - if (len) goto inf_leave; - } - else if (state->head != Z_NULL) - state->head->comment = Z_NULL; - state->mode = HCRC; - case HCRC: - if (state->flags & 0x0200) { - NEEDBITS(16); - if (hold != (state->check & 0xffff)) { - strm->msg = (char *)"header crc mismatch"; - state->mode = BAD; - break; - } - INITBITS(); - } - if (state->head != Z_NULL) { - state->head->hcrc = (int)((state->flags >> 9) & 1); - state->head->done = 1; - } - strm->adler = state->check = crc32(0L, Z_NULL, 0); - state->mode = TYPE; - break; -#endif - case DICTID: - NEEDBITS(32); - strm->adler = state->check = REVERSE(hold); - INITBITS(); - state->mode = DICT; - case DICT: - if (state->havedict == 0) { - RESTORE(); - return Z_NEED_DICT; - } - strm->adler = state->check = adler32(0L, Z_NULL, 0); - state->mode = TYPE; - case TYPE: - if (flush == Z_BLOCK) goto inf_leave; - case TYPEDO: - if (state->last) { - BYTEBITS(); - state->mode = CHECK; - break; - } - NEEDBITS(3); - state->last = BITS(1); - DROPBITS(1); - switch (BITS(2)) { - case 0: /* stored block */ - Tracev((stderr, "inflate: stored block%s\n", - state->last ? " (last)" : "")); - state->mode = STORED; - break; - case 1: /* fixed block */ - fixedtables(state); - Tracev((stderr, "inflate: fixed codes block%s\n", - state->last ? " (last)" : "")); - state->mode = LEN; /* decode codes */ - break; - case 2: /* dynamic block */ - Tracev((stderr, "inflate: dynamic codes block%s\n", - state->last ? " (last)" : "")); - state->mode = TABLE; - break; - case 3: - strm->msg = (char *)"invalid block type"; - state->mode = BAD; - } - DROPBITS(2); - break; - case STORED: - BYTEBITS(); /* go to byte boundary */ - NEEDBITS(32); - if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { - strm->msg = (char *)"invalid stored block lengths"; - state->mode = BAD; - break; - } - state->length = (unsigned)hold & 0xffff; - Tracev((stderr, "inflate: stored length %u\n", - state->length)); - INITBITS(); - state->mode = COPY; - case COPY: - copy = state->length; - if (copy) { - if (copy > have) copy = have; - if (copy > left) copy = left; - if (copy == 0) goto inf_leave; - zmemcpy(put, next, copy); - have -= copy; - next += copy; - left -= copy; - put += copy; - state->length -= copy; - break; - } - Tracev((stderr, "inflate: stored end\n")); - state->mode = TYPE; - break; - case TABLE: - NEEDBITS(14); - state->nlen = BITS(5) + 257; - DROPBITS(5); - state->ndist = BITS(5) + 1; - DROPBITS(5); - state->ncode = BITS(4) + 4; - DROPBITS(4); -#ifndef PKZIP_BUG_WORKAROUND - if (state->nlen > 286 || state->ndist > 30) { - strm->msg = (char *)"too many length or distance symbols"; - state->mode = BAD; - break; - } -#endif - Tracev((stderr, "inflate: table sizes ok\n")); - state->have = 0; - state->mode = LENLENS; - case LENLENS: - while (state->have < state->ncode) { - NEEDBITS(3); - state->lens[order[state->have++]] = (unsigned short)BITS(3); - DROPBITS(3); - } - while (state->have < 19) - state->lens[order[state->have++]] = 0; - state->next = state->codes; - state->lencode = (code const FAR *)(state->next); - state->lenbits = 7; - ret = inflate_table(CODES, state->lens, 19, &(state->next), - &(state->lenbits), state->work); - if (ret) { - strm->msg = (char *)"invalid code lengths set"; - state->mode = BAD; - break; - } - Tracev((stderr, "inflate: code lengths ok\n")); - state->have = 0; - state->mode = CODELENS; - case CODELENS: - while (state->have < state->nlen + state->ndist) { - for (;;) { - this = state->lencode[BITS(state->lenbits)]; - if ((unsigned)(this.bits) <= bits) break; - PULLBYTE(); - } - if (this.val < 16) { - NEEDBITS(this.bits); - DROPBITS(this.bits); - state->lens[state->have++] = this.val; - } - else { - if (this.val == 16) { - NEEDBITS(this.bits + 2); - DROPBITS(this.bits); - if (state->have == 0) { - strm->msg = (char *)"invalid bit length repeat"; - state->mode = BAD; - break; - } - len = state->lens[state->have - 1]; - copy = 3 + BITS(2); - DROPBITS(2); - } - else if (this.val == 17) { - NEEDBITS(this.bits + 3); - DROPBITS(this.bits); - len = 0; - copy = 3 + BITS(3); - DROPBITS(3); - } - else { - NEEDBITS(this.bits + 7); - DROPBITS(this.bits); - len = 0; - copy = 11 + BITS(7); - DROPBITS(7); - } - if (state->have + copy > state->nlen + state->ndist) { - strm->msg = (char *)"invalid bit length repeat"; - state->mode = BAD; - break; - } - while (copy--) - state->lens[state->have++] = (unsigned short)len; - } - } - - /* handle error breaks in while */ - if (state->mode == BAD) break; - - /* build code tables */ - state->next = state->codes; - state->lencode = (code const FAR *)(state->next); - state->lenbits = 9; - ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), - &(state->lenbits), state->work); - if (ret) { - strm->msg = (char *)"invalid literal/lengths set"; - state->mode = BAD; - break; - } - state->distcode = (code const FAR *)(state->next); - state->distbits = 6; - ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, - &(state->next), &(state->distbits), state->work); - if (ret) { - strm->msg = (char *)"invalid distances set"; - state->mode = BAD; - break; - } - Tracev((stderr, "inflate: codes ok\n")); - state->mode = LEN; - case LEN: - if (have >= 6 && left >= 258) { - RESTORE(); - inflate_fast(strm, out); - LOAD(); - break; - } - for (;;) { - this = state->lencode[BITS(state->lenbits)]; - if ((unsigned)(this.bits) <= bits) break; - PULLBYTE(); - } - if (this.op && (this.op & 0xf0) == 0) { - last = this; - for (;;) { - this = state->lencode[last.val + - (BITS(last.bits + last.op) >> last.bits)]; - if ((unsigned)(last.bits + this.bits) <= bits) break; - PULLBYTE(); - } - DROPBITS(last.bits); - } - DROPBITS(this.bits); - state->length = (unsigned)this.val; - if ((int)(this.op) == 0) { - Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ? - "inflate: literal '%c'\n" : - "inflate: literal 0x%02x\n", this.val)); - state->mode = LIT; - break; - } - if (this.op & 32) { - Tracevv((stderr, "inflate: end of block\n")); - state->mode = TYPE; - break; - } - if (this.op & 64) { - strm->msg = (char *)"invalid literal/length code"; - state->mode = BAD; - break; - } - state->extra = (unsigned)(this.op) & 15; - state->mode = LENEXT; - case LENEXT: - if (state->extra) { - NEEDBITS(state->extra); - state->length += BITS(state->extra); - DROPBITS(state->extra); - } - Tracevv((stderr, "inflate: length %u\n", state->length)); - state->mode = DIST; - case DIST: - for (;;) { - this = state->distcode[BITS(state->distbits)]; - if ((unsigned)(this.bits) <= bits) break; - PULLBYTE(); - } - if ((this.op & 0xf0) == 0) { - last = this; - for (;;) { - this = state->distcode[last.val + - (BITS(last.bits + last.op) >> last.bits)]; - if ((unsigned)(last.bits + this.bits) <= bits) break; - PULLBYTE(); - } - DROPBITS(last.bits); - } - DROPBITS(this.bits); - if (this.op & 64) { - strm->msg = (char *)"invalid distance code"; - state->mode = BAD; - break; - } - state->offset = (unsigned)this.val; - state->extra = (unsigned)(this.op) & 15; - state->mode = DISTEXT; - case DISTEXT: - if (state->extra) { - NEEDBITS(state->extra); - state->offset += BITS(state->extra); - DROPBITS(state->extra); - } -#ifdef INFLATE_STRICT - if (state->offset > state->dmax) { - strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } -#endif - if (state->offset > state->whave + out - left) { - strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } - Tracevv((stderr, "inflate: distance %u\n", state->offset)); - state->mode = MATCH; - case MATCH: - if (left == 0) goto inf_leave; - copy = out - left; - if (state->offset > copy) { /* copy from window */ - copy = state->offset - copy; - if (copy > state->write) { - copy -= state->write; - from = state->window + (state->wsize - copy); - } - else - from = state->window + (state->write - copy); - if (copy > state->length) copy = state->length; - } - else { /* copy from output */ - from = put - state->offset; - copy = state->length; - } - if (copy > left) copy = left; - left -= copy; - state->length -= copy; - do { - *put++ = *from++; - } while (--copy); - if (state->length == 0) state->mode = LEN; - break; - case LIT: - if (left == 0) goto inf_leave; - *put++ = (unsigned char)(state->length); - left--; - state->mode = LEN; - break; - case CHECK: - if (state->wrap) { - NEEDBITS(32); - out -= left; - strm->total_out += out; - state->total += out; - if (out) - strm->adler = state->check = - UPDATE(state->check, put - out, out); - out = left; - if (( -#ifdef GUNZIP - state->flags ? hold : -#endif - REVERSE(hold)) != state->check) { - strm->msg = (char *)"incorrect data check"; - state->mode = BAD; - break; - } - INITBITS(); - Tracev((stderr, "inflate: check matches trailer\n")); - } -#ifdef GUNZIP - state->mode = LENGTH; - case LENGTH: - if (state->wrap && state->flags) { - NEEDBITS(32); - if (hold != (state->total & 0xffffffffUL)) { - strm->msg = (char *)"incorrect length check"; - state->mode = BAD; - break; - } - INITBITS(); - Tracev((stderr, "inflate: length matches trailer\n")); - } -#endif - state->mode = DONE; - case DONE: - ret = Z_STREAM_END; - goto inf_leave; - case BAD: - ret = Z_DATA_ERROR; - goto inf_leave; - case MEM: - return Z_MEM_ERROR; - case SYNC: - default: - return Z_STREAM_ERROR; - } - - /* - Return from inflate(), updating the total counts and the check value. - If there was no progress during the inflate() call, return a buffer - error. Call updatewindow() to create and/or update the window state. - Note: a memory error from inflate() is non-recoverable. - */ - inf_leave: - RESTORE(); - if (state->wsize || (state->mode < CHECK && out != strm->avail_out)) - if (updatewindow(strm, out)) { - state->mode = MEM; - return Z_MEM_ERROR; - } - in -= strm->avail_in; - out -= strm->avail_out; - strm->total_in += in; - strm->total_out += out; - state->total += out; - if (state->wrap && out) - strm->adler = state->check = - UPDATE(state->check, strm->next_out - out, out); - strm->data_type = state->bits + (state->last ? 64 : 0) + - (state->mode == TYPE ? 128 : 0); - if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK) - ret = Z_BUF_ERROR; - return ret; -} - -int ZEXPORT inflateEnd(strm) -z_streamp strm; -{ - struct inflate_state FAR *state; - if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) - return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if (state->window != Z_NULL) ZFREE(strm, state->window); - ZFREE(strm, strm->state); - strm->state = Z_NULL; - Tracev((stderr, "inflate: end\n")); - return Z_OK; -} - -int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength) -z_streamp strm; -const Bytef *dictionary; -uInt dictLength; -{ - struct inflate_state FAR *state; - unsigned long id; - - /* check state */ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if (state->wrap != 0 && state->mode != DICT) - return Z_STREAM_ERROR; - - /* check for correct dictionary id */ - if (state->mode == DICT) { - id = adler32(0L, Z_NULL, 0); - id = adler32(id, dictionary, dictLength); - if (id != state->check) - return Z_DATA_ERROR; - } - - /* copy dictionary to window */ - if (updatewindow(strm, strm->avail_out)) { - state->mode = MEM; - return Z_MEM_ERROR; - } - if (dictLength > state->wsize) { - zmemcpy(state->window, dictionary + dictLength - state->wsize, - state->wsize); - state->whave = state->wsize; - } - else { - zmemcpy(state->window + state->wsize - dictLength, dictionary, - dictLength); - state->whave = dictLength; - } - state->havedict = 1; - Tracev((stderr, "inflate: dictionary set\n")); - return Z_OK; -} - -int ZEXPORT inflateGetHeader(strm, head) -z_streamp strm; -gz_headerp head; -{ - struct inflate_state FAR *state; - - /* check state */ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if ((state->wrap & 2) == 0) return Z_STREAM_ERROR; - - /* save header structure */ - state->head = head; - head->done = 0; - return Z_OK; -} - -/* - Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff. Return when found - or when out of input. When called, *have is the number of pattern bytes - found in order so far, in 0..3. On return *have is updated to the new - state. If on return *have equals four, then the pattern was found and the - return value is how many bytes were read including the last byte of the - pattern. If *have is less than four, then the pattern has not been found - yet and the return value is len. In the latter case, syncsearch() can be - called again with more data and the *have state. *have is initialized to - zero for the first call. - */ -local unsigned syncsearch(have, buf, len) -unsigned FAR *have; -unsigned char FAR *buf; -unsigned len; -{ - unsigned got; - unsigned next; - - got = *have; - next = 0; - while (next < len && got < 4) { - if ((int)(buf[next]) == (got < 2 ? 0 : 0xff)) - got++; - else if (buf[next]) - got = 0; - else - got = 4 - got; - next++; - } - *have = got; - return next; -} - -int ZEXPORT inflateSync(strm) -z_streamp strm; -{ - unsigned len; /* number of bytes to look at or looked at */ - unsigned long in, out; /* temporary to save total_in and total_out */ - unsigned char buf[4]; /* to restore bit buffer to byte string */ - struct inflate_state FAR *state; - - /* check parameters */ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR; - - /* if first time, start search in bit buffer */ - if (state->mode != SYNC) { - state->mode = SYNC; - state->hold <<= state->bits & 7; - state->bits -= state->bits & 7; - len = 0; - while (state->bits >= 8) { - buf[len++] = (unsigned char)(state->hold); - state->hold >>= 8; - state->bits -= 8; - } - state->have = 0; - syncsearch(&(state->have), buf, len); - } - - /* search available input */ - len = syncsearch(&(state->have), strm->next_in, strm->avail_in); - strm->avail_in -= len; - strm->next_in += len; - strm->total_in += len; - - /* return no joy or set up to restart inflate() on a new block */ - if (state->have != 4) return Z_DATA_ERROR; - in = strm->total_in; out = strm->total_out; - inflateReset(strm); - strm->total_in = in; strm->total_out = out; - state->mode = TYPE; - return Z_OK; -} - -/* - Returns true if inflate is currently at the end of a block generated by - Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP - implementation to provide an additional safety check. PPP uses - Z_SYNC_FLUSH but removes the length bytes of the resulting empty stored - block. When decompressing, PPP checks that at the end of input packet, - inflate is waiting for these length bytes. - */ -int ZEXPORT inflateSyncPoint(strm) -z_streamp strm; -{ - struct inflate_state FAR *state; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - return state->mode == STORED && state->bits == 0; -} - -int ZEXPORT inflateCopy(dest, source) -z_streamp dest; -z_streamp source; -{ - struct inflate_state FAR *state; - struct inflate_state FAR *copy; - unsigned char FAR *window; - unsigned wsize; - - /* check input */ - if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL || - source->zalloc == (alloc_func)0 || source->zfree == (free_func)0) - return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)source->state; - - /* allocate space */ - copy = (struct inflate_state FAR *) - ZALLOC(source, 1, sizeof(struct inflate_state)); - if (copy == Z_NULL) return Z_MEM_ERROR; - window = Z_NULL; - if (state->window != Z_NULL) { - window = (unsigned char FAR *) - ZALLOC(source, 1U << state->wbits, sizeof(unsigned char)); - if (window == Z_NULL) { - ZFREE(source, copy); - return Z_MEM_ERROR; - } - } - - /* copy state */ - zmemcpy(dest, source, sizeof(z_stream)); - zmemcpy(copy, state, sizeof(struct inflate_state)); - if (state->lencode >= state->codes && - state->lencode <= state->codes + ENOUGH - 1) { - copy->lencode = copy->codes + (state->lencode - state->codes); - copy->distcode = copy->codes + (state->distcode - state->codes); - } - copy->next = copy->codes + (state->next - state->codes); - if (window != Z_NULL) { - wsize = 1U << state->wbits; - zmemcpy(window, state->window, wsize); - } - copy->window = window; - dest->state = (struct internal_state FAR *)copy; - return Z_OK; -} diff --git a/irrlicht-1.6/source/Irrlicht/zlib/inflate.h b/irrlicht-1.6/source/Irrlicht/zlib/inflate.h deleted file mode 100644 index fbbc87143..000000000 --- a/irrlicht-1.6/source/Irrlicht/zlib/inflate.h +++ /dev/null @@ -1,115 +0,0 @@ -/* inflate.h -- internal inflate state definition - * Copyright (C) 1995-2004 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* define NO_GZIP when compiling if you want to disable gzip header and - trailer decoding by inflate(). NO_GZIP would be used to avoid linking in - the crc code when it is not needed. For shared libraries, gzip decoding - should be left enabled. */ -#ifndef NO_GZIP -# define GUNZIP -#endif - -/* Possible inflate modes between inflate() calls */ -typedef enum { - HEAD, /* i: waiting for magic header */ - FLAGS, /* i: waiting for method and flags (gzip) */ - TIME, /* i: waiting for modification time (gzip) */ - OS, /* i: waiting for extra flags and operating system (gzip) */ - EXLEN, /* i: waiting for extra length (gzip) */ - EXTRA, /* i: waiting for extra bytes (gzip) */ - NAME, /* i: waiting for end of file name (gzip) */ - COMMENT, /* i: waiting for end of comment (gzip) */ - HCRC, /* i: waiting for header crc (gzip) */ - DICTID, /* i: waiting for dictionary check value */ - DICT, /* waiting for inflateSetDictionary() call */ - TYPE, /* i: waiting for type bits, including last-flag bit */ - TYPEDO, /* i: same, but skip check to exit inflate on new block */ - STORED, /* i: waiting for stored size (length and complement) */ - COPY, /* i/o: waiting for input or output to copy stored block */ - TABLE, /* i: waiting for dynamic block table lengths */ - LENLENS, /* i: waiting for code length code lengths */ - CODELENS, /* i: waiting for length/lit and distance code lengths */ - LEN, /* i: waiting for length/lit code */ - LENEXT, /* i: waiting for length extra bits */ - DIST, /* i: waiting for distance code */ - DISTEXT, /* i: waiting for distance extra bits */ - MATCH, /* o: waiting for output space to copy string */ - LIT, /* o: waiting for output space to write literal */ - CHECK, /* i: waiting for 32-bit check value */ - LENGTH, /* i: waiting for 32-bit length (gzip) */ - DONE, /* finished check, done -- remain here until reset */ - BAD, /* got a data error -- remain here until reset */ - MEM, /* got an inflate() memory error -- remain here until reset */ - SYNC /* looking for synchronization bytes to restart inflate() */ -} inflate_mode; - -/* - State transitions between above modes - - - (most modes can go to the BAD or MEM mode -- not shown for clarity) - - Process header: - HEAD -> (gzip) or (zlib) - (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME - NAME -> COMMENT -> HCRC -> TYPE - (zlib) -> DICTID or TYPE - DICTID -> DICT -> TYPE - Read deflate blocks: - TYPE -> STORED or TABLE or LEN or CHECK - STORED -> COPY -> TYPE - TABLE -> LENLENS -> CODELENS -> LEN - Read deflate codes: - LEN -> LENEXT or LIT or TYPE - LENEXT -> DIST -> DISTEXT -> MATCH -> LEN - LIT -> LEN - Process trailer: - CHECK -> LENGTH -> DONE - */ - -/* state maintained between inflate() calls. Approximately 7K bytes. */ -struct inflate_state { - inflate_mode mode; /* current inflate mode */ - int last; /* true if processing last block */ - int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ - int havedict; /* true if dictionary provided */ - int flags; /* gzip header method and flags (0 if zlib) */ - unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ - unsigned long check; /* protected copy of check value */ - unsigned long total; /* protected copy of output count */ - gz_headerp head; /* where to save gzip header information */ - /* sliding window */ - unsigned wbits; /* log base 2 of requested window size */ - unsigned wsize; /* window size or zero if not using window */ - unsigned whave; /* valid bytes in the window */ - unsigned write; /* window write index */ - unsigned char FAR *window; /* allocated sliding window, if needed */ - /* bit accumulator */ - unsigned long hold; /* input bit accumulator */ - unsigned bits; /* number of bits in "in" */ - /* for string and stored block copying */ - unsigned length; /* literal or length of data to copy */ - unsigned offset; /* distance back to copy string from */ - /* for table and code decoding */ - unsigned extra; /* extra bits needed */ - /* fixed and dynamic code tables */ - code const FAR *lencode; /* starting table for length/literal codes */ - code const FAR *distcode; /* starting table for distance codes */ - unsigned lenbits; /* index bits for lencode */ - unsigned distbits; /* index bits for distcode */ - /* dynamic table building */ - unsigned ncode; /* number of code length code lengths */ - unsigned nlen; /* number of length code lengths */ - unsigned ndist; /* number of distance code lengths */ - unsigned have; /* number of code lengths in lens[] */ - code FAR *next; /* next available space in codes[] */ - unsigned short lens[320]; /* temporary storage for code lengths */ - unsigned short work[288]; /* work area for code table building */ - code codes[ENOUGH]; /* space for code tables */ -}; diff --git a/irrlicht-1.6/source/Irrlicht/zlib/inftrees.c b/irrlicht-1.6/source/Irrlicht/zlib/inftrees.c deleted file mode 100644 index 38ded81c3..000000000 --- a/irrlicht-1.6/source/Irrlicht/zlib/inftrees.c +++ /dev/null @@ -1,329 +0,0 @@ -/* inftrees.c -- generate Huffman trees for efficient decoding - * Copyright (C) 1995-2005 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "zutil.h" -#include "inftrees.h" - -#define MAXBITS 15 - -const char inflate_copyright[] = - " inflate 1.2.3 Copyright 1995-2005 Mark Adler "; -/* - If you use the zlib library in a product, an acknowledgment is welcome - in the documentation of your product. If for some reason you cannot - include such an acknowledgment, I would appreciate that you keep this - copyright string in the executable of your product. - */ - -/* - Build a set of tables to decode the provided canonical Huffman code. - The code lengths are lens[0..codes-1]. The result starts at *table, - whose indices are 0..2^bits-1. work is a writable array of at least - lens shorts, which is used as a work area. type is the type of code - to be generated, CODES, LENS, or DISTS. On return, zero is success, - -1 is an invalid code, and +1 means that ENOUGH isn't enough. table - on return points to the next available entry's address. bits is the - requested root table index bits, and on return it is the actual root - table index bits. It will differ if the request is greater than the - longest code or if it is less than the shortest code. - */ -int inflate_table(type, lens, codes, table, bits, work) -codetype type; -unsigned short FAR *lens; -unsigned codes; -code FAR * FAR *table; -unsigned FAR *bits; -unsigned short FAR *work; -{ - unsigned len; /* a code's length in bits */ - unsigned sym; /* index of code symbols */ - unsigned min, max; /* minimum and maximum code lengths */ - unsigned root; /* number of index bits for root table */ - unsigned curr; /* number of index bits for current table */ - unsigned drop; /* code bits to drop for sub-table */ - int left; /* number of prefix codes available */ - unsigned used; /* code entries in table used */ - unsigned huff; /* Huffman code */ - unsigned incr; /* for incrementing code, index */ - unsigned fill; /* index for replicating entries */ - unsigned low; /* low bits for current root entry */ - unsigned mask; /* mask for low root bits */ - code this; /* table entry for duplication */ - code FAR *next; /* next available space in table */ - const unsigned short FAR *base; /* base value table to use */ - const unsigned short FAR *extra; /* extra bits table to use */ - int end; /* use base and extra for symbol > end */ - unsigned short count[MAXBITS+1]; /* number of codes of each length */ - unsigned short offs[MAXBITS+1]; /* offsets in table for each length */ - static const unsigned short lbase[31] = { /* Length codes 257..285 base */ - 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, - 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; - static const unsigned short lext[31] = { /* Length codes 257..285 extra */ - 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, - 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 201, 196}; - static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ - 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, - 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, - 8193, 12289, 16385, 24577, 0, 0}; - static const unsigned short dext[32] = { /* Distance codes 0..29 extra */ - 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, - 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, - 28, 28, 29, 29, 64, 64}; - - /* - Process a set of code lengths to create a canonical Huffman code. The - code lengths are lens[0..codes-1]. Each length corresponds to the - symbols 0..codes-1. The Huffman code is generated by first sorting the - symbols by length from short to long, and retaining the symbol order - for codes with equal lengths. Then the code starts with all zero bits - for the first code of the shortest length, and the codes are integer - increments for the same length, and zeros are appended as the length - increases. For the deflate format, these bits are stored backwards - from their more natural integer increment ordering, and so when the - decoding tables are built in the large loop below, the integer codes - are incremented backwards. - - This routine assumes, but does not check, that all of the entries in - lens[] are in the range 0..MAXBITS. The caller must assure this. - 1..MAXBITS is interpreted as that code length. zero means that that - symbol does not occur in this code. - - The codes are sorted by computing a count of codes for each length, - creating from that a table of starting indices for each length in the - sorted table, and then entering the symbols in order in the sorted - table. The sorted table is work[], with that space being provided by - the caller. - - The length counts are used for other purposes as well, i.e. finding - the minimum and maximum length codes, determining if there are any - codes at all, checking for a valid set of lengths, and looking ahead - at length counts to determine sub-table sizes when building the - decoding tables. - */ - - /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */ - for (len = 0; len <= MAXBITS; len++) - count[len] = 0; - for (sym = 0; sym < codes; sym++) - count[lens[sym]]++; - - /* bound code lengths, force root to be within code lengths */ - root = *bits; - for (max = MAXBITS; max >= 1; max--) - if (count[max] != 0) break; - if (root > max) root = max; - if (max == 0) { /* no symbols to code at all */ - this.op = (unsigned char)64; /* invalid code marker */ - this.bits = (unsigned char)1; - this.val = (unsigned short)0; - *(*table)++ = this; /* make a table to force an error */ - *(*table)++ = this; - *bits = 1; - return 0; /* no symbols, but wait for decoding to report error */ - } - for (min = 1; min <= MAXBITS; min++) - if (count[min] != 0) break; - if (root < min) root = min; - - /* check for an over-subscribed or incomplete set of lengths */ - left = 1; - for (len = 1; len <= MAXBITS; len++) { - left <<= 1; - left -= count[len]; - if (left < 0) return -1; /* over-subscribed */ - } - if (left > 0 && (type == CODES || max != 1)) - return -1; /* incomplete set */ - - /* generate offsets into symbol table for each length for sorting */ - offs[1] = 0; - for (len = 1; len < MAXBITS; len++) - offs[len + 1] = offs[len] + count[len]; - - /* sort symbols by length, by symbol order within each length */ - for (sym = 0; sym < codes; sym++) - if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym; - - /* - Create and fill in decoding tables. In this loop, the table being - filled is at next and has curr index bits. The code being used is huff - with length len. That code is converted to an index by dropping drop - bits off of the bottom. For codes where len is less than drop + curr, - those top drop + curr - len bits are incremented through all values to - fill the table with replicated entries. - - root is the number of index bits for the root table. When len exceeds - root, sub-tables are created pointed to by the root entry with an index - of the low root bits of huff. This is saved in low to check for when a - new sub-table should be started. drop is zero when the root table is - being filled, and drop is root when sub-tables are being filled. - - When a new sub-table is needed, it is necessary to look ahead in the - code lengths to determine what size sub-table is needed. The length - counts are used for this, and so count[] is decremented as codes are - entered in the tables. - - used keeps track of how many table entries have been allocated from the - provided *table space. It is checked when a LENS table is being made - against the space in *table, ENOUGH, minus the maximum space needed by - the worst case distance code, MAXD. This should never happen, but the - sufficiency of ENOUGH has not been proven exhaustively, hence the check. - This assumes that when type == LENS, bits == 9. - - sym increments through all symbols, and the loop terminates when - all codes of length max, i.e. all codes, have been processed. This - routine permits incomplete codes, so another loop after this one fills - in the rest of the decoding tables with invalid code markers. - */ - - /* set up for code type */ - switch (type) { - case CODES: - base = extra = work; /* dummy value--not used */ - end = 19; - break; - case LENS: - base = lbase; - base -= 257; - extra = lext; - extra -= 257; - end = 256; - break; - default: /* DISTS */ - base = dbase; - extra = dext; - end = -1; - } - - /* initialize state for loop */ - huff = 0; /* starting code */ - sym = 0; /* starting code symbol */ - len = min; /* starting code length */ - next = *table; /* current table to fill in */ - curr = root; /* current table index bits */ - drop = 0; /* current bits to drop from code for index */ - low = (unsigned)(-1); /* trigger new sub-table when len > root */ - used = 1U << root; /* use root table entries */ - mask = used - 1; /* mask for comparing low */ - - /* check available table space */ - if (type == LENS && used >= ENOUGH - MAXD) - return 1; - - /* process all codes and make table entries */ - for (;;) { - /* create table entry */ - this.bits = (unsigned char)(len - drop); - if ((int)(work[sym]) < end) { - this.op = (unsigned char)0; - this.val = work[sym]; - } - else if ((int)(work[sym]) > end) { - this.op = (unsigned char)(extra[work[sym]]); - this.val = base[work[sym]]; - } - else { - this.op = (unsigned char)(32 + 64); /* end of block */ - this.val = 0; - } - - /* replicate for those indices with low len bits equal to huff */ - incr = 1U << (len - drop); - fill = 1U << curr; - min = fill; /* save offset to next table */ - do { - fill -= incr; - next[(huff >> drop) + fill] = this; - } while (fill != 0); - - /* backwards increment the len-bit code huff */ - incr = 1U << (len - 1); - while (huff & incr) - incr >>= 1; - if (incr != 0) { - huff &= incr - 1; - huff += incr; - } - else - huff = 0; - - /* go to next symbol, update count, len */ - sym++; - if (--(count[len]) == 0) { - if (len == max) break; - len = lens[work[sym]]; - } - - /* create new sub-table if needed */ - if (len > root && (huff & mask) != low) { - /* if first time, transition to sub-tables */ - if (drop == 0) - drop = root; - - /* increment past last table */ - next += min; /* here min is 1 << curr */ - - /* determine length of next table */ - curr = len - drop; - left = (int)(1 << curr); - while (curr + drop < max) { - left -= count[curr + drop]; - if (left <= 0) break; - curr++; - left <<= 1; - } - - /* check for enough space */ - used += 1U << curr; - if (type == LENS && used >= ENOUGH - MAXD) - return 1; - - /* point entry in root table to sub-table */ - low = huff & mask; - (*table)[low].op = (unsigned char)curr; - (*table)[low].bits = (unsigned char)root; - (*table)[low].val = (unsigned short)(next - *table); - } - } - - /* - Fill in rest of table for incomplete codes. This loop is similar to the - loop above in incrementing huff for table indices. It is assumed that - len is equal to curr + drop, so there is no loop needed to increment - through high index bits. When the current sub-table is filled, the loop - drops back to the root table to fill in any remaining entries there. - */ - this.op = (unsigned char)64; /* invalid code marker */ - this.bits = (unsigned char)(len - drop); - this.val = (unsigned short)0; - while (huff != 0) { - /* when done with sub-table, drop back to root table */ - if (drop != 0 && (huff & mask) != low) { - drop = 0; - len = root; - next = *table; - this.bits = (unsigned char)len; - } - - /* put invalid code marker in table */ - next[huff >> drop] = this; - - /* backwards increment the len-bit code huff */ - incr = 1U << (len - 1); - while (huff & incr) - incr >>= 1; - if (incr != 0) { - huff &= incr - 1; - huff += incr; - } - else - huff = 0; - } - - /* set return parameters */ - *table += used; - *bits = root; - return 0; -} diff --git a/irrlicht-1.6/source/Irrlicht/zlib/inftrees.h b/irrlicht-1.6/source/Irrlicht/zlib/inftrees.h deleted file mode 100644 index dc0fd567e..000000000 --- a/irrlicht-1.6/source/Irrlicht/zlib/inftrees.h +++ /dev/null @@ -1,55 +0,0 @@ -/* inftrees.h -- header to use inftrees.c - * Copyright (C) 1995-2005 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* Structure for decoding tables. Each entry provides either the - information needed to do the operation requested by the code that - indexed that table entry, or it provides a pointer to another - table that indexes more bits of the code. op indicates whether - the entry is a pointer to another table, a literal, a length or - distance, an end-of-block, or an invalid code. For a table - pointer, the low four bits of op is the number of index bits of - that table. For a length or distance, the low four bits of op - is the number of extra bits to get after the code. bits is - the number of bits in this code or part of the code to drop off - of the bit buffer. val is the actual byte to output in the case - of a literal, the base length or distance, or the offset from - the current table to the next table. Each entry is four bytes. */ -typedef struct { - unsigned char op; /* operation, extra bits, table bits */ - unsigned char bits; /* bits in this part of the code */ - unsigned short val; /* offset in table or code value */ -} code; - -/* op values as set by inflate_table(): - 00000000 - literal - 0000tttt - table link, tttt != 0 is the number of table index bits - 0001eeee - length or distance, eeee is the number of extra bits - 01100000 - end of block - 01000000 - invalid code - */ - -/* Maximum size of dynamic tree. The maximum found in a long but non- - exhaustive search was 1444 code structures (852 for length/literals - and 592 for distances, the latter actually the result of an - exhaustive search). The true maximum is not known, but the value - below is more than safe. */ -#define ENOUGH 2048 -#define MAXD 592 - -/* Type of code to build for inftable() */ -typedef enum { - CODES, - LENS, - DISTS -} codetype; - -extern int inflate_table OF((codetype type, unsigned short FAR *lens, - unsigned codes, code FAR * FAR *table, - unsigned FAR *bits, unsigned short FAR *work)); diff --git a/irrlicht-1.6/source/Irrlicht/zlib/trees.c b/irrlicht-1.6/source/Irrlicht/zlib/trees.c deleted file mode 100644 index 7a0480286..000000000 --- a/irrlicht-1.6/source/Irrlicht/zlib/trees.c +++ /dev/null @@ -1,1219 +0,0 @@ -/* trees.c -- output deflated data using Huffman coding - * Copyright (C) 1995-2005 Jean-loup Gailly - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* - * ALGORITHM - * - * The "deflation" process uses several Huffman trees. The more - * common source values are represented by shorter bit sequences. - * - * Each code tree is stored in a compressed form which is itself - * a Huffman encoding of the lengths of all the code strings (in - * ascending order by source values). The actual code strings are - * reconstructed from the lengths in the inflate process, as described - * in the deflate specification. - * - * REFERENCES - * - * Deutsch, L.P.,"'Deflate' Compressed Data Format Specification". - * Available in ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc - * - * Storer, James A. - * Data Compression: Methods and Theory, pp. 49-50. - * Computer Science Press, 1988. ISBN 0-7167-8156-5. - * - * Sedgewick, R. - * Algorithms, p290. - * Addison-Wesley, 1983. ISBN 0-201-06672-6. - */ - -/* @(#) $Id$ */ - -/* #define GEN_TREES_H */ - -#include "deflate.h" - -#ifdef DEBUG -# include <ctype.h> -#endif - -/* =========================================================================== - * Constants - */ - -#define MAX_BL_BITS 7 -/* Bit length codes must not exceed MAX_BL_BITS bits */ - -#define END_BLOCK 256 -/* end of block literal code */ - -#define REP_3_6 16 -/* repeat previous bit length 3-6 times (2 bits of repeat count) */ - -#define REPZ_3_10 17 -/* repeat a zero length 3-10 times (3 bits of repeat count) */ - -#define REPZ_11_138 18 -/* repeat a zero length 11-138 times (7 bits of repeat count) */ - -local const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */ - = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0}; - -local const int extra_dbits[D_CODES] /* extra bits for each distance code */ - = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; - -local const int extra_blbits[BL_CODES]/* extra bits for each bit length code */ - = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7}; - -local const uch bl_order[BL_CODES] - = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15}; -/* The lengths of the bit length codes are sent in order of decreasing - * probability, to avoid transmitting the lengths for unused bit length codes. - */ - -#define Buf_size (8 * 2*sizeof(char)) -/* Number of bits used within bi_buf. (bi_buf might be implemented on - * more than 16 bits on some systems.) - */ - -/* =========================================================================== - * Local data. These are initialized only once. - */ - -#define DIST_CODE_LEN 512 /* see definition of array dist_code below */ - -#if defined(GEN_TREES_H) || !defined(STDC) -/* non ANSI compilers may not accept trees.h */ - -local ct_data static_ltree[L_CODES+2]; -/* The static literal tree. Since the bit lengths are imposed, there is no - * need for the L_CODES extra codes used during heap construction. However - * The codes 286 and 287 are needed to build a canonical tree (see _tr_init - * below). - */ - -local ct_data static_dtree[D_CODES]; -/* The static distance tree. (Actually a trivial tree since all codes use - * 5 bits.) - */ - -uch _dist_code[DIST_CODE_LEN]; -/* Distance codes. The first 256 values correspond to the distances - * 3 .. 258, the last 256 values correspond to the top 8 bits of - * the 15 bit distances. - */ - -uch _length_code[MAX_MATCH-MIN_MATCH+1]; -/* length code for each normalized match length (0 == MIN_MATCH) */ - -local int base_length[LENGTH_CODES]; -/* First normalized length for each code (0 = MIN_MATCH) */ - -local int base_dist[D_CODES]; -/* First normalized distance for each code (0 = distance of 1) */ - -#else -# include "trees.h" -#endif /* GEN_TREES_H */ - -struct static_tree_desc_s { - const ct_data *static_tree; /* static tree or NULL */ - const intf *extra_bits; /* extra bits for each code or NULL */ - int extra_base; /* base index for extra_bits */ - int elems; /* max number of elements in the tree */ - int max_length; /* max bit length for the codes */ -}; - -local static_tree_desc static_l_desc = -{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS}; - -local static_tree_desc static_d_desc = -{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS}; - -local static_tree_desc static_bl_desc = -{(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS}; - -/* =========================================================================== - * Local (static) routines in this file. - */ - -local void tr_static_init OF((void)); -local void init_block OF((deflate_state *s)); -local void pqdownheap OF((deflate_state *s, ct_data *tree, int k)); -local void gen_bitlen OF((deflate_state *s, tree_desc *desc)); -local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count)); -local void build_tree OF((deflate_state *s, tree_desc *desc)); -local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code)); -local void send_tree OF((deflate_state *s, ct_data *tree, int max_code)); -local int build_bl_tree OF((deflate_state *s)); -local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes, - int blcodes)); -local void compress_block OF((deflate_state *s, ct_data *ltree, - ct_data *dtree)); -local void set_data_type OF((deflate_state *s)); -local unsigned bi_reverse OF((unsigned value, int length)); -local void bi_windup OF((deflate_state *s)); -local void bi_flush OF((deflate_state *s)); -local void copy_block OF((deflate_state *s, charf *buf, unsigned len, - int header)); - -#ifdef GEN_TREES_H -local void gen_trees_header OF((void)); -#endif - -#ifndef DEBUG -# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len) - /* Send a code of the given tree. c and tree must not have side effects */ - -#else /* DEBUG */ -# define send_code(s, c, tree) \ - { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \ - send_bits(s, tree[c].Code, tree[c].Len); } -#endif - -/* =========================================================================== - * Output a short LSB first on the stream. - * IN assertion: there is enough room in pendingBuf. - */ -#define put_short(s, w) { \ - put_byte(s, (uch)((w) & 0xff)); \ - put_byte(s, (uch)((ush)(w) >> 8)); \ -} - -/* =========================================================================== - * Send a value on a given number of bits. - * IN assertion: length <= 16 and value fits in length bits. - */ -#ifdef DEBUG -local void send_bits OF((deflate_state *s, int value, int length)); - -local void send_bits(s, value, length) - deflate_state *s; - int value; /* value to send */ - int length; /* number of bits */ -{ - Tracevv((stderr," l %2d v %4x ", length, value)); - Assert(length > 0 && length <= 15, "invalid length"); - s->bits_sent += (ulg)length; - - /* If not enough room in bi_buf, use (valid) bits from bi_buf and - * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid)) - * unused bits in value. - */ - if (s->bi_valid > (int)Buf_size - length) { - s->bi_buf |= (value << s->bi_valid); - put_short(s, s->bi_buf); - s->bi_buf = (ush)value >> (Buf_size - s->bi_valid); - s->bi_valid += length - Buf_size; - } else { - s->bi_buf |= value << s->bi_valid; - s->bi_valid += length; - } -} -#else /* !DEBUG */ - -#define send_bits(s, value, length) \ -{ int len = length;\ - if (s->bi_valid > (int)Buf_size - len) {\ - int val = value;\ - s->bi_buf |= (val << s->bi_valid);\ - put_short(s, s->bi_buf);\ - s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\ - s->bi_valid += len - Buf_size;\ - } else {\ - s->bi_buf |= (value) << s->bi_valid;\ - s->bi_valid += len;\ - }\ -} -#endif /* DEBUG */ - - -/* the arguments must not have side effects */ - -/* =========================================================================== - * Initialize the various 'constant' tables. - */ -local void tr_static_init() -{ -#if defined(GEN_TREES_H) || !defined(STDC) - static int static_init_done = 0; - int n; /* iterates over tree elements */ - int bits; /* bit counter */ - int length; /* length value */ - int code; /* code value */ - int dist; /* distance index */ - ush bl_count[MAX_BITS+1]; - /* number of codes at each bit length for an optimal tree */ - - if (static_init_done) return; - - /* For some embedded targets, global variables are not initialized: */ - static_l_desc.static_tree = static_ltree; - static_l_desc.extra_bits = extra_lbits; - static_d_desc.static_tree = static_dtree; - static_d_desc.extra_bits = extra_dbits; - static_bl_desc.extra_bits = extra_blbits; - - /* Initialize the mapping length (0..255) -> length code (0..28) */ - length = 0; - for (code = 0; code < LENGTH_CODES-1; code++) { - base_length[code] = length; - for (n = 0; n < (1<<extra_lbits[code]); n++) { - _length_code[length++] = (uch)code; - } - } - Assert (length == 256, "tr_static_init: length != 256"); - /* Note that the length 255 (match length 258) can be represented - * in two different ways: code 284 + 5 bits or code 285, so we - * overwrite length_code[255] to use the best encoding: - */ - _length_code[length-1] = (uch)code; - - /* Initialize the mapping dist (0..32K) -> dist code (0..29) */ - dist = 0; - for (code = 0 ; code < 16; code++) { - base_dist[code] = dist; - for (n = 0; n < (1<<extra_dbits[code]); n++) { - _dist_code[dist++] = (uch)code; - } - } - Assert (dist == 256, "tr_static_init: dist != 256"); - dist >>= 7; /* from now on, all distances are divided by 128 */ - for ( ; code < D_CODES; code++) { - base_dist[code] = dist << 7; - for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) { - _dist_code[256 + dist++] = (uch)code; - } - } - Assert (dist == 256, "tr_static_init: 256+dist != 512"); - - /* Construct the codes of the static literal tree */ - for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0; - n = 0; - while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++; - while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++; - while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++; - while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++; - /* Codes 286 and 287 do not exist, but we must include them in the - * tree construction to get a canonical Huffman tree (longest code - * all ones) - */ - gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count); - - /* The static distance tree is trivial: */ - for (n = 0; n < D_CODES; n++) { - static_dtree[n].Len = 5; - static_dtree[n].Code = bi_reverse((unsigned)n, 5); - } - static_init_done = 1; - -# ifdef GEN_TREES_H - gen_trees_header(); -# endif -#endif /* defined(GEN_TREES_H) || !defined(STDC) */ -} - -/* =========================================================================== - * Genererate the file trees.h describing the static trees. - */ -#ifdef GEN_TREES_H -# ifndef DEBUG -# include <stdio.h> -# endif - -# define SEPARATOR(i, last, width) \ - ((i) == (last)? "\n};\n\n" : \ - ((i) % (width) == (width)-1 ? ",\n" : ", ")) - -void gen_trees_header() -{ - FILE *header = fopen("trees.h", "w"); - int i; - - Assert (header != NULL, "Can't open trees.h"); - fprintf(header, - "/* header created automatically with -DGEN_TREES_H */\n\n"); - - fprintf(header, "local const ct_data static_ltree[L_CODES+2] = {\n"); - for (i = 0; i < L_CODES+2; i++) { - fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code, - static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5)); - } - - fprintf(header, "local const ct_data static_dtree[D_CODES] = {\n"); - for (i = 0; i < D_CODES; i++) { - fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code, - static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5)); - } - - fprintf(header, "const uch _dist_code[DIST_CODE_LEN] = {\n"); - for (i = 0; i < DIST_CODE_LEN; i++) { - fprintf(header, "%2u%s", _dist_code[i], - SEPARATOR(i, DIST_CODE_LEN-1, 20)); - } - - fprintf(header, "const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {\n"); - for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) { - fprintf(header, "%2u%s", _length_code[i], - SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20)); - } - - fprintf(header, "local const int base_length[LENGTH_CODES] = {\n"); - for (i = 0; i < LENGTH_CODES; i++) { - fprintf(header, "%1u%s", base_length[i], - SEPARATOR(i, LENGTH_CODES-1, 20)); - } - - fprintf(header, "local const int base_dist[D_CODES] = {\n"); - for (i = 0; i < D_CODES; i++) { - fprintf(header, "%5u%s", base_dist[i], - SEPARATOR(i, D_CODES-1, 10)); - } - - fclose(header); -} -#endif /* GEN_TREES_H */ - -/* =========================================================================== - * Initialize the tree data structures for a new zlib stream. - */ -void _tr_init(s) - deflate_state *s; -{ - tr_static_init(); - - s->l_desc.dyn_tree = s->dyn_ltree; - s->l_desc.stat_desc = &static_l_desc; - - s->d_desc.dyn_tree = s->dyn_dtree; - s->d_desc.stat_desc = &static_d_desc; - - s->bl_desc.dyn_tree = s->bl_tree; - s->bl_desc.stat_desc = &static_bl_desc; - - s->bi_buf = 0; - s->bi_valid = 0; - s->last_eob_len = 8; /* enough lookahead for inflate */ -#ifdef DEBUG - s->compressed_len = 0L; - s->bits_sent = 0L; -#endif - - /* Initialize the first block of the first file: */ - init_block(s); -} - -/* =========================================================================== - * Initialize a new block. - */ -local void init_block(s) - deflate_state *s; -{ - int n; /* iterates over tree elements */ - - /* Initialize the trees. */ - for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0; - for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0; - for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0; - - s->dyn_ltree[END_BLOCK].Freq = 1; - s->opt_len = s->static_len = 0L; - s->last_lit = s->matches = 0; -} - -#define SMALLEST 1 -/* Index within the heap array of least frequent node in the Huffman tree */ - - -/* =========================================================================== - * Remove the smallest element from the heap and recreate the heap with - * one less element. Updates heap and heap_len. - */ -#define pqremove(s, tree, top) \ -{\ - top = s->heap[SMALLEST]; \ - s->heap[SMALLEST] = s->heap[s->heap_len--]; \ - pqdownheap(s, tree, SMALLEST); \ -} - -/* =========================================================================== - * Compares to subtrees, using the tree depth as tie breaker when - * the subtrees have equal frequency. This minimizes the worst case length. - */ -#define smaller(tree, n, m, depth) \ - (tree[n].Freq < tree[m].Freq || \ - (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m])) - -/* =========================================================================== - * Restore the heap property by moving down the tree starting at node k, - * exchanging a node with the smallest of its two sons if necessary, stopping - * when the heap property is re-established (each father smaller than its - * two sons). - */ -local void pqdownheap(s, tree, k) - deflate_state *s; - ct_data *tree; /* the tree to restore */ - int k; /* node to move down */ -{ - int v = s->heap[k]; - int j = k << 1; /* left son of k */ - while (j <= s->heap_len) { - /* Set j to the smallest of the two sons: */ - if (j < s->heap_len && - smaller(tree, s->heap[j+1], s->heap[j], s->depth)) { - j++; - } - /* Exit if v is smaller than both sons */ - if (smaller(tree, v, s->heap[j], s->depth)) break; - - /* Exchange v with the smallest son */ - s->heap[k] = s->heap[j]; k = j; - - /* And continue down the tree, setting j to the left son of k */ - j <<= 1; - } - s->heap[k] = v; -} - -/* =========================================================================== - * Compute the optimal bit lengths for a tree and update the total bit length - * for the current block. - * IN assertion: the fields freq and dad are set, heap[heap_max] and - * above are the tree nodes sorted by increasing frequency. - * OUT assertions: the field len is set to the optimal bit length, the - * array bl_count contains the frequencies for each bit length. - * The length opt_len is updated; static_len is also updated if stree is - * not null. - */ -local void gen_bitlen(s, desc) - deflate_state *s; - tree_desc *desc; /* the tree descriptor */ -{ - ct_data *tree = desc->dyn_tree; - int max_code = desc->max_code; - const ct_data *stree = desc->stat_desc->static_tree; - const intf *extra = desc->stat_desc->extra_bits; - int base = desc->stat_desc->extra_base; - int max_length = desc->stat_desc->max_length; - int h; /* heap index */ - int n, m; /* iterate over the tree elements */ - int bits; /* bit length */ - int xbits; /* extra bits */ - ush f; /* frequency */ - int overflow = 0; /* number of elements with bit length too large */ - - for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0; - - /* In a first pass, compute the optimal bit lengths (which may - * overflow in the case of the bit length tree). - */ - tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */ - - for (h = s->heap_max+1; h < HEAP_SIZE; h++) { - n = s->heap[h]; - bits = tree[tree[n].Dad].Len + 1; - if (bits > max_length) bits = max_length, overflow++; - tree[n].Len = (ush)bits; - /* We overwrite tree[n].Dad which is no longer needed */ - - if (n > max_code) continue; /* not a leaf node */ - - s->bl_count[bits]++; - xbits = 0; - if (n >= base) xbits = extra[n-base]; - f = tree[n].Freq; - s->opt_len += (ulg)f * (bits + xbits); - if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits); - } - if (overflow == 0) return; - - Trace((stderr,"\nbit length overflow\n")); - /* This happens for example on obj2 and pic of the Calgary corpus */ - - /* Find the first bit length which could increase: */ - do { - bits = max_length-1; - while (s->bl_count[bits] == 0) bits--; - s->bl_count[bits]--; /* move one leaf down the tree */ - s->bl_count[bits+1] += 2; /* move one overflow item as its brother */ - s->bl_count[max_length]--; - /* The brother of the overflow item also moves one step up, - * but this does not affect bl_count[max_length] - */ - overflow -= 2; - } while (overflow > 0); - - /* Now recompute all bit lengths, scanning in increasing frequency. - * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all - * lengths instead of fixing only the wrong ones. This idea is taken - * from 'ar' written by Haruhiko Okumura.) - */ - for (bits = max_length; bits != 0; bits--) { - n = s->bl_count[bits]; - while (n != 0) { - m = s->heap[--h]; - if (m > max_code) continue; - if ((unsigned) tree[m].Len != (unsigned) bits) { - Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits)); - s->opt_len += ((long)bits - (long)tree[m].Len) - *(long)tree[m].Freq; - tree[m].Len = (ush)bits; - } - n--; - } - } -} - -/* =========================================================================== - * Generate the codes for a given tree and bit counts (which need not be - * optimal). - * IN assertion: the array bl_count contains the bit length statistics for - * the given tree and the field len is set for all tree elements. - * OUT assertion: the field code is set for all tree elements of non - * zero code length. - */ -local void gen_codes (tree, max_code, bl_count) - ct_data *tree; /* the tree to decorate */ - int max_code; /* largest code with non zero frequency */ - ushf *bl_count; /* number of codes at each bit length */ -{ - ush next_code[MAX_BITS+1]; /* next code value for each bit length */ - ush code = 0; /* running code value */ - int bits; /* bit index */ - int n; /* code index */ - - /* The distribution counts are first used to generate the code values - * without bit reversal. - */ - for (bits = 1; bits <= MAX_BITS; bits++) { - next_code[bits] = code = (code + bl_count[bits-1]) << 1; - } - /* Check that the bit counts in bl_count are consistent. The last code - * must be all ones. - */ - Assert (code + bl_count[MAX_BITS]-1 == (1<<MAX_BITS)-1, - "inconsistent bit counts"); - Tracev((stderr,"\ngen_codes: max_code %d ", max_code)); - - for (n = 0; n <= max_code; n++) { - int len = tree[n].Len; - if (len == 0) continue; - /* Now reverse the bits */ - tree[n].Code = bi_reverse(next_code[len]++, len); - - Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ", - n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1)); - } -} - -/* =========================================================================== - * Construct one Huffman tree and assigns the code bit strings and lengths. - * Update the total bit length for the current block. - * IN assertion: the field freq is set for all tree elements. - * OUT assertions: the fields len and code are set to the optimal bit length - * and corresponding code. The length opt_len is updated; static_len is - * also updated if stree is not null. The field max_code is set. - */ -local void build_tree(s, desc) - deflate_state *s; - tree_desc *desc; /* the tree descriptor */ -{ - ct_data *tree = desc->dyn_tree; - const ct_data *stree = desc->stat_desc->static_tree; - int elems = desc->stat_desc->elems; - int n, m; /* iterate over heap elements */ - int max_code = -1; /* largest code with non zero frequency */ - int node; /* new node being created */ - - /* Construct the initial heap, with least frequent element in - * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1]. - * heap[0] is not used. - */ - s->heap_len = 0, s->heap_max = HEAP_SIZE; - - for (n = 0; n < elems; n++) { - if (tree[n].Freq != 0) { - s->heap[++(s->heap_len)] = max_code = n; - s->depth[n] = 0; - } else { - tree[n].Len = 0; - } - } - - /* The pkzip format requires that at least one distance code exists, - * and that at least one bit should be sent even if there is only one - * possible code. So to avoid special checks later on we force at least - * two codes of non zero frequency. - */ - while (s->heap_len < 2) { - node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0); - tree[node].Freq = 1; - s->depth[node] = 0; - s->opt_len--; if (stree) s->static_len -= stree[node].Len; - /* node is 0 or 1 so it does not have extra bits */ - } - desc->max_code = max_code; - - /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree, - * establish sub-heaps of increasing lengths: - */ - for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n); - - /* Construct the Huffman tree by repeatedly combining the least two - * frequent nodes. - */ - node = elems; /* next internal node of the tree */ - do { - pqremove(s, tree, n); /* n = node of least frequency */ - m = s->heap[SMALLEST]; /* m = node of next least frequency */ - - s->heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */ - s->heap[--(s->heap_max)] = m; - - /* Create a new node father of n and m */ - tree[node].Freq = tree[n].Freq + tree[m].Freq; - s->depth[node] = (uch)((s->depth[n] >= s->depth[m] ? - s->depth[n] : s->depth[m]) + 1); - tree[n].Dad = tree[m].Dad = (ush)node; -#ifdef DUMP_BL_TREE - if (tree == s->bl_tree) { - fprintf(stderr,"\nnode %d(%d), sons %d(%d) %d(%d)", - node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq); - } -#endif - /* and insert the new node in the heap */ - s->heap[SMALLEST] = node++; - pqdownheap(s, tree, SMALLEST); - - } while (s->heap_len >= 2); - - s->heap[--(s->heap_max)] = s->heap[SMALLEST]; - - /* At this point, the fields freq and dad are set. We can now - * generate the bit lengths. - */ - gen_bitlen(s, (tree_desc *)desc); - - /* The field len is now set, we can generate the bit codes */ - gen_codes ((ct_data *)tree, max_code, s->bl_count); -} - -/* =========================================================================== - * Scan a literal or distance tree to determine the frequencies of the codes - * in the bit length tree. - */ -local void scan_tree (s, tree, max_code) - deflate_state *s; - ct_data *tree; /* the tree to be scanned */ - int max_code; /* and its largest code of non zero frequency */ -{ - int n; /* iterates over all tree elements */ - int prevlen = -1; /* last emitted length */ - int curlen; /* length of current code */ - int nextlen = tree[0].Len; /* length of next code */ - int count = 0; /* repeat count of the current code */ - int max_count = 7; /* max repeat count */ - int min_count = 4; /* min repeat count */ - - if (nextlen == 0) max_count = 138, min_count = 3; - tree[max_code+1].Len = (ush)0xffff; /* guard */ - - for (n = 0; n <= max_code; n++) { - curlen = nextlen; nextlen = tree[n+1].Len; - if (++count < max_count && curlen == nextlen) { - continue; - } else if (count < min_count) { - s->bl_tree[curlen].Freq += count; - } else if (curlen != 0) { - if (curlen != prevlen) s->bl_tree[curlen].Freq++; - s->bl_tree[REP_3_6].Freq++; - } else if (count <= 10) { - s->bl_tree[REPZ_3_10].Freq++; - } else { - s->bl_tree[REPZ_11_138].Freq++; - } - count = 0; prevlen = curlen; - if (nextlen == 0) { - max_count = 138, min_count = 3; - } else if (curlen == nextlen) { - max_count = 6, min_count = 3; - } else { - max_count = 7, min_count = 4; - } - } -} - -/* =========================================================================== - * Send a literal or distance tree in compressed form, using the codes in - * bl_tree. - */ -local void send_tree (s, tree, max_code) - deflate_state *s; - ct_data *tree; /* the tree to be scanned */ - int max_code; /* and its largest code of non zero frequency */ -{ - int n; /* iterates over all tree elements */ - int prevlen = -1; /* last emitted length */ - int curlen; /* length of current code */ - int nextlen = tree[0].Len; /* length of next code */ - int count = 0; /* repeat count of the current code */ - int max_count = 7; /* max repeat count */ - int min_count = 4; /* min repeat count */ - - /* tree[max_code+1].Len = -1; */ /* guard already set */ - if (nextlen == 0) max_count = 138, min_count = 3; - - for (n = 0; n <= max_code; n++) { - curlen = nextlen; nextlen = tree[n+1].Len; - if (++count < max_count && curlen == nextlen) { - continue; - } else if (count < min_count) { - do { send_code(s, curlen, s->bl_tree); } while (--count != 0); - - } else if (curlen != 0) { - if (curlen != prevlen) { - send_code(s, curlen, s->bl_tree); count--; - } - Assert(count >= 3 && count <= 6, " 3_6?"); - send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2); - - } else if (count <= 10) { - send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3); - - } else { - send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7); - } - count = 0; prevlen = curlen; - if (nextlen == 0) { - max_count = 138, min_count = 3; - } else if (curlen == nextlen) { - max_count = 6, min_count = 3; - } else { - max_count = 7, min_count = 4; - } - } -} - -/* =========================================================================== - * Construct the Huffman tree for the bit lengths and return the index in - * bl_order of the last bit length code to send. - */ -local int build_bl_tree(s) - deflate_state *s; -{ - int max_blindex; /* index of last bit length code of non zero freq */ - - /* Determine the bit length frequencies for literal and distance trees */ - scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code); - scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code); - - /* Build the bit length tree: */ - build_tree(s, (tree_desc *)(&(s->bl_desc))); - /* opt_len now includes the length of the tree representations, except - * the lengths of the bit lengths codes and the 5+5+4 bits for the counts. - */ - - /* Determine the number of bit length codes to send. The pkzip format - * requires that at least 4 bit length codes be sent. (appnote.txt says - * 3 but the actual value used is 4.) - */ - for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) { - if (s->bl_tree[bl_order[max_blindex]].Len != 0) break; - } - /* Update opt_len to include the bit length tree and counts */ - s->opt_len += 3*(max_blindex+1) + 5+5+4; - Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", - s->opt_len, s->static_len)); - - return max_blindex; -} - -/* =========================================================================== - * Send the header for a block using dynamic Huffman trees: the counts, the - * lengths of the bit length codes, the literal tree and the distance tree. - * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. - */ -local void send_all_trees(s, lcodes, dcodes, blcodes) - deflate_state *s; - int lcodes, dcodes, blcodes; /* number of codes for each tree */ -{ - int rank; /* index in bl_order */ - - Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); - Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, - "too many codes"); - Tracev((stderr, "\nbl counts: ")); - send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */ - send_bits(s, dcodes-1, 5); - send_bits(s, blcodes-4, 4); /* not -3 as stated in appnote.txt */ - for (rank = 0; rank < blcodes; rank++) { - Tracev((stderr, "\nbl code %2d ", bl_order[rank])); - send_bits(s, s->bl_tree[bl_order[rank]].Len, 3); - } - Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent)); - - send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */ - Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent)); - - send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */ - Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent)); -} - -/* =========================================================================== - * Send a stored block - */ -void _tr_stored_block(s, buf, stored_len, eof) - deflate_state *s; - charf *buf; /* input block */ - ulg stored_len; /* length of input block */ - int eof; /* true if this is the last block for a file */ -{ - send_bits(s, (STORED_BLOCK<<1)+eof, 3); /* send block type */ -#ifdef DEBUG - s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L; - s->compressed_len += (stored_len + 4) << 3; -#endif - copy_block(s, buf, (unsigned)stored_len, 1); /* with header */ -} - -/* =========================================================================== - * Send one empty static block to give enough lookahead for inflate. - * This takes 10 bits, of which 7 may remain in the bit buffer. - * The current inflate code requires 9 bits of lookahead. If the - * last two codes for the previous block (real code plus EOB) were coded - * on 5 bits or less, inflate may have only 5+3 bits of lookahead to decode - * the last real code. In this case we send two empty static blocks instead - * of one. (There are no problems if the previous block is stored or fixed.) - * To simplify the code, we assume the worst case of last real code encoded - * on one bit only. - */ -void _tr_align(s) - deflate_state *s; -{ - send_bits(s, STATIC_TREES<<1, 3); - send_code(s, END_BLOCK, static_ltree); -#ifdef DEBUG - s->compressed_len += 10L; /* 3 for block type, 7 for EOB */ -#endif - bi_flush(s); - /* Of the 10 bits for the empty block, we have already sent - * (10 - bi_valid) bits. The lookahead for the last real code (before - * the EOB of the previous block) was thus at least one plus the length - * of the EOB plus what we have just sent of the empty static block. - */ - if (1 + s->last_eob_len + 10 - s->bi_valid < 9) { - send_bits(s, STATIC_TREES<<1, 3); - send_code(s, END_BLOCK, static_ltree); -#ifdef DEBUG - s->compressed_len += 10L; -#endif - bi_flush(s); - } - s->last_eob_len = 7; -} - -/* =========================================================================== - * Determine the best encoding for the current block: dynamic trees, static - * trees or store, and output the encoded block to the zip file. - */ -void _tr_flush_block(s, buf, stored_len, eof) - deflate_state *s; - charf *buf; /* input block, or NULL if too old */ - ulg stored_len; /* length of input block */ - int eof; /* true if this is the last block for a file */ -{ - ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ - int max_blindex = 0; /* index of last bit length code of non zero freq */ - - /* Build the Huffman trees unless a stored block is forced */ - if (s->level > 0) { - - /* Check if the file is binary or text */ - if (stored_len > 0 && s->strm->data_type == Z_UNKNOWN) - set_data_type(s); - - /* Construct the literal and distance trees */ - build_tree(s, (tree_desc *)(&(s->l_desc))); - Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len, - s->static_len)); - - build_tree(s, (tree_desc *)(&(s->d_desc))); - Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len, - s->static_len)); - /* At this point, opt_len and static_len are the total bit lengths of - * the compressed block data, excluding the tree representations. - */ - - /* Build the bit length tree for the above two trees, and get the index - * in bl_order of the last bit length code to send. - */ - max_blindex = build_bl_tree(s); - - /* Determine the best encoding. Compute the block lengths in bytes. */ - opt_lenb = (s->opt_len+3+7)>>3; - static_lenb = (s->static_len+3+7)>>3; - - Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ", - opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len, - s->last_lit)); - - if (static_lenb <= opt_lenb) opt_lenb = static_lenb; - - } else { - Assert(buf != (char*)0, "lost buf"); - opt_lenb = static_lenb = stored_len + 5; /* force a stored block */ - } - -#ifdef FORCE_STORED - if (buf != (char*)0) { /* force stored block */ -#else - if (stored_len+4 <= opt_lenb && buf != (char*)0) { - /* 4: two words for the lengths */ -#endif - /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. - * Otherwise we can't have processed more than WSIZE input bytes since - * the last block flush, because compression would have been - * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to - * transform a block into a stored block. - */ - _tr_stored_block(s, buf, stored_len, eof); - -#ifdef FORCE_STATIC - } else if (static_lenb >= 0) { /* force static trees */ -#else - } else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) { -#endif - send_bits(s, (STATIC_TREES<<1)+eof, 3); - compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree); -#ifdef DEBUG - s->compressed_len += 3 + s->static_len; -#endif - } else { - send_bits(s, (DYN_TREES<<1)+eof, 3); - send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1, - max_blindex+1); - compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree); -#ifdef DEBUG - s->compressed_len += 3 + s->opt_len; -#endif - } - Assert (s->compressed_len == s->bits_sent, "bad compressed size"); - /* The above check is made mod 2^32, for files larger than 512 MB - * and uLong implemented on 32 bits. - */ - init_block(s); - - if (eof) { - bi_windup(s); -#ifdef DEBUG - s->compressed_len += 7; /* align on byte boundary */ -#endif - } - Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3, - s->compressed_len-7*eof)); -} - -/* =========================================================================== - * Save the match info and tally the frequency counts. Return true if - * the current block must be flushed. - */ -int _tr_tally (s, dist, lc) - deflate_state *s; - unsigned dist; /* distance of matched string */ - unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */ -{ - s->d_buf[s->last_lit] = (ush)dist; - s->l_buf[s->last_lit++] = (uch)lc; - if (dist == 0) { - /* lc is the unmatched char */ - s->dyn_ltree[lc].Freq++; - } else { - s->matches++; - /* Here, lc is the match length - MIN_MATCH */ - dist--; /* dist = match distance - 1 */ - Assert((ush)dist < (ush)MAX_DIST(s) && - (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) && - (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match"); - - s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++; - s->dyn_dtree[d_code(dist)].Freq++; - } - -#ifdef TRUNCATE_BLOCK - /* Try to guess if it is profitable to stop the current block here */ - if ((s->last_lit & 0x1fff) == 0 && s->level > 2) { - /* Compute an upper bound for the compressed length */ - ulg out_length = (ulg)s->last_lit*8L; - ulg in_length = (ulg)((long)s->strstart - s->block_start); - int dcode; - for (dcode = 0; dcode < D_CODES; dcode++) { - out_length += (ulg)s->dyn_dtree[dcode].Freq * - (5L+extra_dbits[dcode]); - } - out_length >>= 3; - Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ", - s->last_lit, in_length, out_length, - 100L - out_length*100L/in_length)); - if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1; - } -#endif - return (s->last_lit == s->lit_bufsize-1); - /* We avoid equality with lit_bufsize because of wraparound at 64K - * on 16 bit machines and because stored blocks are restricted to - * 64K-1 bytes. - */ -} - -/* =========================================================================== - * Send the block data compressed using the given Huffman trees - */ -local void compress_block(s, ltree, dtree) - deflate_state *s; - ct_data *ltree; /* literal tree */ - ct_data *dtree; /* distance tree */ -{ - unsigned dist; /* distance of matched string */ - int lc; /* match length or unmatched char (if dist == 0) */ - unsigned lx = 0; /* running index in l_buf */ - unsigned code; /* the code to send */ - int extra; /* number of extra bits to send */ - - if (s->last_lit != 0) do { - dist = s->d_buf[lx]; - lc = s->l_buf[lx++]; - if (dist == 0) { - send_code(s, lc, ltree); /* send a literal byte */ - Tracecv(isgraph(lc), (stderr," '%c' ", lc)); - } else { - /* Here, lc is the match length - MIN_MATCH */ - code = _length_code[lc]; - send_code(s, code+LITERALS+1, ltree); /* send the length code */ - extra = extra_lbits[code]; - if (extra != 0) { - lc -= base_length[code]; - send_bits(s, lc, extra); /* send the extra length bits */ - } - dist--; /* dist is now the match distance - 1 */ - code = d_code(dist); - Assert (code < D_CODES, "bad d_code"); - - send_code(s, code, dtree); /* send the distance code */ - extra = extra_dbits[code]; - if (extra != 0) { - dist -= base_dist[code]; - send_bits(s, dist, extra); /* send the extra distance bits */ - } - } /* literal or match pair ? */ - - /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */ - Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx, - "pendingBuf overflow"); - - } while (lx < s->last_lit); - - send_code(s, END_BLOCK, ltree); - s->last_eob_len = ltree[END_BLOCK].Len; -} - -/* =========================================================================== - * Set the data type to BINARY or TEXT, using a crude approximation: - * set it to Z_TEXT if all symbols are either printable characters (33 to 255) - * or white spaces (9 to 13, or 32); or set it to Z_BINARY otherwise. - * IN assertion: the fields Freq of dyn_ltree are set. - */ -local void set_data_type(s) - deflate_state *s; -{ - int n; - - for (n = 0; n < 9; n++) - if (s->dyn_ltree[n].Freq != 0) - break; - if (n == 9) - for (n = 14; n < 32; n++) - if (s->dyn_ltree[n].Freq != 0) - break; - s->strm->data_type = (n == 32) ? Z_TEXT : Z_BINARY; -} - -/* =========================================================================== - * Reverse the first len bits of a code, using straightforward code (a faster - * method would use a table) - * IN assertion: 1 <= len <= 15 - */ -local unsigned bi_reverse(code, len) - unsigned code; /* the value to invert */ - int len; /* its bit length */ -{ - register unsigned res = 0; - do { - res |= code & 1; - code >>= 1, res <<= 1; - } while (--len > 0); - return res >> 1; -} - -/* =========================================================================== - * Flush the bit buffer, keeping at most 7 bits in it. - */ -local void bi_flush(s) - deflate_state *s; -{ - if (s->bi_valid == 16) { - put_short(s, s->bi_buf); - s->bi_buf = 0; - s->bi_valid = 0; - } else if (s->bi_valid >= 8) { - put_byte(s, (Byte)s->bi_buf); - s->bi_buf >>= 8; - s->bi_valid -= 8; - } -} - -/* =========================================================================== - * Flush the bit buffer and align the output on a byte boundary - */ -local void bi_windup(s) - deflate_state *s; -{ - if (s->bi_valid > 8) { - put_short(s, s->bi_buf); - } else if (s->bi_valid > 0) { - put_byte(s, (Byte)s->bi_buf); - } - s->bi_buf = 0; - s->bi_valid = 0; -#ifdef DEBUG - s->bits_sent = (s->bits_sent+7) & ~7; -#endif -} - -/* =========================================================================== - * Copy a stored block, storing first the length and its - * one's complement if requested. - */ -local void copy_block(s, buf, len, header) - deflate_state *s; - charf *buf; /* the input data */ - unsigned len; /* its length */ - int header; /* true if block header must be written */ -{ - bi_windup(s); /* align on byte boundary */ - s->last_eob_len = 8; /* enough lookahead for inflate */ - - if (header) { - put_short(s, (ush)len); - put_short(s, (ush)~len); -#ifdef DEBUG - s->bits_sent += 2*16; -#endif - } -#ifdef DEBUG - s->bits_sent += (ulg)len<<3; -#endif - while (len--) { - put_byte(s, *buf++); - } -} diff --git a/irrlicht-1.6/source/Irrlicht/zlib/trees.h b/irrlicht-1.6/source/Irrlicht/zlib/trees.h deleted file mode 100644 index 1ca868b84..000000000 --- a/irrlicht-1.6/source/Irrlicht/zlib/trees.h +++ /dev/null @@ -1,128 +0,0 @@ -/* header created automatically with -DGEN_TREES_H */ - -local const ct_data static_ltree[L_CODES+2] = { -{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}}, -{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}}, -{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}}, -{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}}, -{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}}, -{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}}, -{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}}, -{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}}, -{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}}, -{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}}, -{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}}, -{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}}, -{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}}, -{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}}, -{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}}, -{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}}, -{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}}, -{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}}, -{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}}, -{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}}, -{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}}, -{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}}, -{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}}, -{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}}, -{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}}, -{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}}, -{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}}, -{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}}, -{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}}, -{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}}, -{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}}, -{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}}, -{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}}, -{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}}, -{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}}, -{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}}, -{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}}, -{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}}, -{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}}, -{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}}, -{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}}, -{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}}, -{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}}, -{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}}, -{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}}, -{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}}, -{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}}, -{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}}, -{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}}, -{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}}, -{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}}, -{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}}, -{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}}, -{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}}, -{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}}, -{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}}, -{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}}, -{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}} -}; - -local const ct_data static_dtree[D_CODES] = { -{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}}, -{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}}, -{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}}, -{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}}, -{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}}, -{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}} -}; - -const uch _dist_code[DIST_CODE_LEN] = { - 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, - 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, -10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, -11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, -12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, -13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, -13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, -18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, -23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, -27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, -27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, -28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, -28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, -28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 -}; - -const uch _length_code[MAX_MATCH-MIN_MATCH+1]= { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, -13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, -17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, -19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, -21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, -22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, -23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, -25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, -26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, -27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28 -}; - -local const int base_length[LENGTH_CODES] = { -0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, -64, 80, 96, 112, 128, 160, 192, 224, 0 -}; - -local const int base_dist[D_CODES] = { - 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, - 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, - 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576 -}; - diff --git a/irrlicht-1.6/source/Irrlicht/zlib/uncompr.c b/irrlicht-1.6/source/Irrlicht/zlib/uncompr.c deleted file mode 100644 index ad6db0a67..000000000 --- a/irrlicht-1.6/source/Irrlicht/zlib/uncompr.c +++ /dev/null @@ -1,61 +0,0 @@ -/* uncompr.c -- decompress a memory buffer - * Copyright (C) 1995-2003 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#define ZLIB_INTERNAL -#include "zlib.h" - -/* =========================================================================== - Decompresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total - size of the destination buffer, which must be large enough to hold the - entire uncompressed data. (The size of the uncompressed data must have - been saved previously by the compressor and transmitted to the decompressor - by some mechanism outside the scope of this compression library.) - Upon exit, destLen is the actual size of the compressed buffer. - This function can be used to decompress a whole file at once if the - input file is mmap'ed. - - uncompress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer, or Z_DATA_ERROR if the input data was corrupted. -*/ -int ZEXPORT uncompress (dest, destLen, source, sourceLen) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; -{ - z_stream stream; - int err; - - stream.next_in = (Bytef*)source; - stream.avail_in = (uInt)sourceLen; - /* Check for source > 64K on 16-bit machine: */ - if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; - - stream.next_out = dest; - stream.avail_out = (uInt)*destLen; - if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; - - stream.zalloc = (alloc_func)0; - stream.zfree = (free_func)0; - - err = inflateInit(&stream); - if (err != Z_OK) return err; - - err = inflate(&stream, Z_FINISH); - if (err != Z_STREAM_END) { - inflateEnd(&stream); - if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) - return Z_DATA_ERROR; - return err; - } - *destLen = stream.total_out; - - err = inflateEnd(&stream); - return err; -} diff --git a/irrlicht-1.6/source/Irrlicht/zlib/zconf.h b/irrlicht-1.6/source/Irrlicht/zlib/zconf.h deleted file mode 100644 index e3b0c962e..000000000 --- a/irrlicht-1.6/source/Irrlicht/zlib/zconf.h +++ /dev/null @@ -1,332 +0,0 @@ -/* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2005 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#ifndef ZCONF_H -#define ZCONF_H - -/* - * If you *really* need a unique prefix for all types and library functions, - * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. - */ -#ifdef Z_PREFIX -# define deflateInit_ z_deflateInit_ -# define deflate z_deflate -# define deflateEnd z_deflateEnd -# define inflateInit_ z_inflateInit_ -# define inflate z_inflate -# define inflateEnd z_inflateEnd -# define deflateInit2_ z_deflateInit2_ -# define deflateSetDictionary z_deflateSetDictionary -# define deflateCopy z_deflateCopy -# define deflateReset z_deflateReset -# define deflateParams z_deflateParams -# define deflateBound z_deflateBound -# define deflatePrime z_deflatePrime -# define inflateInit2_ z_inflateInit2_ -# define inflateSetDictionary z_inflateSetDictionary -# define inflateSync z_inflateSync -# define inflateSyncPoint z_inflateSyncPoint -# define inflateCopy z_inflateCopy -# define inflateReset z_inflateReset -# define inflateBack z_inflateBack -# define inflateBackEnd z_inflateBackEnd -# define compress z_compress -# define compress2 z_compress2 -# define compressBound z_compressBound -# define uncompress z_uncompress -# define adler32 z_adler32 -# define crc32 z_crc32 -# define get_crc_table z_get_crc_table -# define zError z_zError - -# define alloc_func z_alloc_func -# define free_func z_free_func -# define in_func z_in_func -# define out_func z_out_func -# define Byte z_Byte -# define uInt z_uInt -# define uLong z_uLong -# define Bytef z_Bytef -# define charf z_charf -# define intf z_intf -# define uIntf z_uIntf -# define uLongf z_uLongf -# define voidpf z_voidpf -# define voidp z_voidp -#endif - -#if defined(__MSDOS__) && !defined(MSDOS) -# define MSDOS -#endif -#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) -# define OS2 -#endif -#if defined(_WINDOWS) && !defined(WINDOWS) -# define WINDOWS -#endif -#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) -# ifndef WIN32 -# define WIN32 -# endif -#endif -#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) -# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) -# ifndef SYS16BIT -# define SYS16BIT -# endif -# endif -#endif - -/* - * Compile with -DMAXSEG_64K if the alloc function cannot allocate more - * than 64k bytes at a time (needed on systems with 16-bit int). - */ -#ifdef SYS16BIT -# define MAXSEG_64K -#endif -#ifdef MSDOS -# define UNALIGNED_OK -#endif - -#ifdef __STDC_VERSION__ -# ifndef STDC -# define STDC -# endif -# if __STDC_VERSION__ >= 199901L -# ifndef STDC99 -# define STDC99 -# endif -# endif -#endif -#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) -# define STDC -#endif -#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) -# define STDC -#endif -#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) -# define STDC -#endif -#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) -# define STDC -#endif - -#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ -# define STDC -#endif - -#ifndef STDC -# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ -# define const /* note: need a more gentle solution here */ -# endif -#endif - -/* Some Mac compilers merge all .h files incorrectly: */ -#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) -# define NO_DUMMY_DECL -#endif - -/* Maximum value for memLevel in deflateInit2 */ -#ifndef MAX_MEM_LEVEL -# ifdef MAXSEG_64K -# define MAX_MEM_LEVEL 8 -# else -# define MAX_MEM_LEVEL 9 -# endif -#endif - -/* Maximum value for windowBits in deflateInit2 and inflateInit2. - * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files - * created by gzip. (Files created by minigzip can still be extracted by - * gzip.) - */ -#ifndef MAX_WBITS -# define MAX_WBITS 15 /* 32K LZ77 window */ -#endif - -/* The memory requirements for deflate are (in bytes): - (1 << (windowBits+2)) + (1 << (memLevel+9)) - that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) - plus a few kilobytes for small objects. For example, if you want to reduce - the default memory requirements from 256K to 128K, compile with - make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" - Of course this will generally degrade compression (there's no free lunch). - - The memory requirements for inflate are (in bytes) 1 << windowBits - that is, 32K for windowBits=15 (default value) plus a few kilobytes - for small objects. -*/ - - /* Type declarations */ - -#ifndef OF /* function prototypes */ -# ifdef STDC -# define OF(args) args -# else -# define OF(args) () -# endif -#endif - -/* The following definitions for FAR are needed only for MSDOS mixed - * model programming (small or medium model with some far allocations). - * This was tested only with MSC; for other MSDOS compilers you may have - * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, - * just define FAR to be empty. - */ -#ifdef SYS16BIT -# if defined(M_I86SM) || defined(M_I86MM) - /* MSC small or medium model */ -# define SMALL_MEDIUM -# ifdef _MSC_VER -# define FAR _far -# else -# define FAR far -# endif -# endif -# if (defined(__SMALL__) || defined(__MEDIUM__)) - /* Turbo C small or medium model */ -# define SMALL_MEDIUM -# ifdef __BORLANDC__ -# define FAR _far -# else -# define FAR far -# endif -# endif -#endif - -#if defined(WINDOWS) || defined(WIN32) - /* If building or using zlib as a DLL, define ZLIB_DLL. - * This is not mandatory, but it offers a little performance increase. - */ -# ifdef ZLIB_DLL -# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) -# ifdef ZLIB_INTERNAL -# define ZEXTERN extern __declspec(dllexport) -# else -# define ZEXTERN extern __declspec(dllimport) -# endif -# endif -# endif /* ZLIB_DLL */ - /* If building or using zlib with the WINAPI/WINAPIV calling convention, - * define ZLIB_WINAPI. - * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. - */ -# ifdef ZLIB_WINAPI -# ifdef FAR -# undef FAR -# endif -# include <windows.h> - /* No need for _export, use ZLIB.DEF instead. */ - /* For complete Windows compatibility, use WINAPI, not __stdcall. */ -# define ZEXPORT WINAPI -# ifdef WIN32 -# define ZEXPORTVA WINAPIV -# else -# define ZEXPORTVA FAR CDECL -# endif -# endif -#endif - -#if defined (__BEOS__) -# ifdef ZLIB_DLL -# ifdef ZLIB_INTERNAL -# define ZEXPORT __declspec(dllexport) -# define ZEXPORTVA __declspec(dllexport) -# else -# define ZEXPORT __declspec(dllimport) -# define ZEXPORTVA __declspec(dllimport) -# endif -# endif -#endif - -#ifndef ZEXTERN -# define ZEXTERN extern -#endif -#ifndef ZEXPORT -# define ZEXPORT -#endif -#ifndef ZEXPORTVA -# define ZEXPORTVA -#endif - -#ifndef FAR -# define FAR -#endif - -#if !defined(__MACTYPES__) -typedef unsigned char Byte; /* 8 bits */ -#endif -typedef unsigned int uInt; /* 16 bits or more */ -typedef unsigned long uLong; /* 32 bits or more */ - -#ifdef SMALL_MEDIUM - /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ -# define Bytef Byte FAR -#else - typedef Byte FAR Bytef; -#endif -typedef char FAR charf; -typedef int FAR intf; -typedef uInt FAR uIntf; -typedef uLong FAR uLongf; - -#ifdef STDC - typedef void const *voidpc; - typedef void FAR *voidpf; - typedef void *voidp; -#else - typedef Byte const *voidpc; - typedef Byte FAR *voidpf; - typedef Byte *voidp; -#endif - -#if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */ -# include <sys/types.h> /* for off_t */ -# include <unistd.h> /* for SEEK_* and off_t */ -# ifdef VMS -# include <unixio.h> /* for off_t */ -# endif -# define z_off_t off_t -#endif -#ifndef SEEK_SET -# define SEEK_SET 0 /* Seek from beginning of file. */ -# define SEEK_CUR 1 /* Seek from current position. */ -# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ -#endif -#ifndef z_off_t -# define z_off_t long -#endif - -#if defined(__OS400__) -# define NO_vsnprintf -#endif - -#if defined(__MVS__) -# define NO_vsnprintf -# ifdef FAR -# undef FAR -# endif -#endif - -/* MVS linker does not support external names larger than 8 bytes */ -#if defined(__MVS__) -# pragma map(deflateInit_,"DEIN") -# pragma map(deflateInit2_,"DEIN2") -# pragma map(deflateEnd,"DEEND") -# pragma map(deflateBound,"DEBND") -# pragma map(inflateInit_,"ININ") -# pragma map(inflateInit2_,"ININ2") -# pragma map(inflateEnd,"INEND") -# pragma map(inflateSync,"INSY") -# pragma map(inflateSetDictionary,"INSEDI") -# pragma map(compressBound,"CMBND") -# pragma map(inflate_table,"INTABL") -# pragma map(inflate_fast,"INFA") -# pragma map(inflate_copyright,"INCOPY") -#endif - -#endif /* ZCONF_H */ diff --git a/irrlicht-1.6/source/Irrlicht/zlib/zlib.3 b/irrlicht-1.6/source/Irrlicht/zlib/zlib.3 deleted file mode 100644 index f6b0da117..000000000 --- a/irrlicht-1.6/source/Irrlicht/zlib/zlib.3 +++ /dev/null @@ -1,159 +0,0 @@ -.TH ZLIB 3 "18 July 2005" -.SH NAME -zlib \- compression/decompression library -.SH SYNOPSIS -[see -.I zlib.h -for full description] -.SH DESCRIPTION -The -.I zlib -library is a general purpose data compression library. -The code is thread safe. -It provides in-memory compression and decompression functions, -including integrity checks of the uncompressed data. -This version of the library supports only one compression method (deflation) -but other algorithms will be added later -and will have the same stream interface. -.LP -Compression can be done in a single step if the buffers are large enough -(for example if an input file is mmap'ed), -or can be done by repeated calls of the compression function. -In the latter case, -the application must provide more input and/or consume the output -(providing more output space) before each call. -.LP -The library also supports reading and writing files in -.IR gzip (1) -(.gz) format -with an interface similar to that of stdio. -.LP -The library does not install any signal handler. -The decoder checks the consistency of the compressed data, -so the library should never crash even in case of corrupted input. -.LP -All functions of the compression library are documented in the file -.IR zlib.h . -The distribution source includes examples of use of the library -in the files -.I example.c -and -.IR minigzip.c . -.LP -Changes to this version are documented in the file -.I ChangeLog -that accompanies the source, -and are concerned primarily with bug fixes and portability enhancements. -.LP -A Java implementation of -.I zlib -is available in the Java Development Kit 1.1: -.IP -http://www.javasoft.com/products/JDK/1.1/docs/api/Package-java.util.zip.html -.LP -A Perl interface to -.IR zlib , -written by Paul Marquess (pmqs@cpan.org), -is available at CPAN (Comprehensive Perl Archive Network) sites, -including: -.IP -http://www.cpan.org/modules/by-module/Compress/ -.LP -A Python interface to -.IR zlib , -written by A.M. Kuchling (amk@magnet.com), -is available in Python 1.5 and later versions: -.IP -http://www.python.org/doc/lib/module-zlib.html -.LP -A -.I zlib -binding for -.IR tcl (1), -written by Andreas Kupries (a.kupries@westend.com), -is availlable at: -.IP -http://www.westend.com/~kupries/doc/trf/man/man.html -.LP -An experimental package to read and write files in .zip format, -written on top of -.I zlib -by Gilles Vollant (info@winimage.com), -is available at: -.IP -http://www.winimage.com/zLibDll/unzip.html -and also in the -.I contrib/minizip -directory of the main -.I zlib -web site. -.SH "SEE ALSO" -The -.I zlib -web site can be found at either of these locations: -.IP -http://www.zlib.org -.br -http://www.gzip.org/zlib/ -.LP -The data format used by the zlib library is described by RFC -(Request for Comments) 1950 to 1952 in the files: -.IP -http://www.ietf.org/rfc/rfc1950.txt (concerning zlib format) -.br -http://www.ietf.org/rfc/rfc1951.txt (concerning deflate format) -.br -http://www.ietf.org/rfc/rfc1952.txt (concerning gzip format) -.LP -These documents are also available in other formats from: -.IP -ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html -.LP -Mark Nelson (markn@ieee.org) wrote an article about -.I zlib -for the Jan. 1997 issue of Dr. Dobb's Journal; -a copy of the article is available at: -.IP -http://dogma.net/markn/articles/zlibtool/zlibtool.htm -.SH "REPORTING PROBLEMS" -Before reporting a problem, -please check the -.I zlib -web site to verify that you have the latest version of -.IR zlib ; -otherwise, -obtain the latest version and see if the problem still exists. -Please read the -.I zlib -FAQ at: -.IP -http://www.gzip.org/zlib/zlib_faq.html -.LP -before asking for help. -Send questions and/or comments to zlib@gzip.org, -or (for the Windows DLL version) to Gilles Vollant (info@winimage.com). -.SH AUTHORS -Version 1.2.3 -Copyright (C) 1995-2005 Jean-loup Gailly (jloup@gzip.org) -and Mark Adler (madler@alumni.caltech.edu). -.LP -This software is provided "as-is," -without any express or implied warranty. -In no event will the authors be held liable for any damages -arising from the use of this software. -See the distribution directory with respect to requirements -governing redistribution. -The deflate format used by -.I zlib -was defined by Phil Katz. -The deflate and -.I zlib -specifications were written by L. Peter Deutsch. -Thanks to all the people who reported problems and suggested various -improvements in -.IR zlib ; -who are too numerous to cite here. -.LP -UNIX manual page by R. P. C. Rodgers, -U.S. National Library of Medicine (rodgers@nlm.nih.gov). -.\" end of man page diff --git a/irrlicht-1.6/source/Irrlicht/zlib/zlib.h b/irrlicht-1.6/source/Irrlicht/zlib/zlib.h deleted file mode 100644 index 62d0e4675..000000000 --- a/irrlicht-1.6/source/Irrlicht/zlib/zlib.h +++ /dev/null @@ -1,1357 +0,0 @@ -/* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.2.3, July 18th, 2005 - - Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jean-loup Gailly Mark Adler - jloup@gzip.org madler@alumni.caltech.edu - - - The data format used by the zlib library is described by RFCs (Request for - Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt - (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). -*/ - -#ifndef ZLIB_H -#define ZLIB_H - -#include "zconf.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define ZLIB_VERSION "1.2.3" -#define ZLIB_VERNUM 0x1230 - -/* - The 'zlib' compression library provides in-memory compression and - decompression functions, including integrity checks of the uncompressed - data. This version of the library supports only one compression method - (deflation) but other algorithms will be added later and will have the same - stream interface. - - Compression can be done in a single step if the buffers are large - enough (for example if an input file is mmap'ed), or can be done by - repeated calls of the compression function. In the latter case, the - application must provide more input and/or consume the output - (providing more output space) before each call. - - The compressed data format used by default by the in-memory functions is - the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped - around a deflate stream, which is itself documented in RFC 1951. - - The library also supports reading and writing files in gzip (.gz) format - with an interface similar to that of stdio using the functions that start - with "gz". The gzip format is different from the zlib format. gzip is a - gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. - - This library can optionally read and write gzip streams in memory as well. - - The zlib format was designed to be compact and fast for use in memory - and on communications channels. The gzip format was designed for single- - file compression on file systems, has a larger header than zlib to maintain - directory information, and uses a different, slower check method than zlib. - - The library does not install any signal handler. The decoder checks - the consistency of the compressed data, so the library should never - crash even in case of corrupted input. -*/ - -typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); -typedef void (*free_func) OF((voidpf opaque, voidpf address)); - -struct internal_state; - -typedef struct z_stream_s { - Bytef *next_in; /* next input byte */ - uInt avail_in; /* number of bytes available at next_in */ - uLong total_in; /* total nb of input bytes read so far */ - - Bytef *next_out; /* next output byte should be put there */ - uInt avail_out; /* remaining free space at next_out */ - uLong total_out; /* total nb of bytes output so far */ - - char *msg; /* last error message, NULL if no error */ - struct internal_state FAR *state; /* not visible by applications */ - - alloc_func zalloc; /* used to allocate the internal state */ - free_func zfree; /* used to free the internal state */ - voidpf opaque; /* private data object passed to zalloc and zfree */ - - int data_type; /* best guess about the data type: binary or text */ - uLong adler; /* adler32 value of the uncompressed data */ - uLong reserved; /* reserved for future use */ -} z_stream; - -typedef z_stream FAR *z_streamp; - -/* - gzip header information passed to and from zlib routines. See RFC 1952 - for more details on the meanings of these fields. -*/ -typedef struct gz_header_s { - int text; /* true if compressed data believed to be text */ - uLong time; /* modification time */ - int xflags; /* extra flags (not used when writing a gzip file) */ - int os; /* operating system */ - Bytef *extra; /* pointer to extra field or Z_NULL if none */ - uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ - uInt extra_max; /* space at extra (only when reading header) */ - Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ - uInt name_max; /* space at name (only when reading header) */ - Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ - uInt comm_max; /* space at comment (only when reading header) */ - int hcrc; /* true if there was or will be a header crc */ - int done; /* true when done reading gzip header (not used - when writing a gzip file) */ -} gz_header; - -typedef gz_header FAR *gz_headerp; - -/* - The application must update next_in and avail_in when avail_in has - dropped to zero. It must update next_out and avail_out when avail_out - has dropped to zero. The application must initialize zalloc, zfree and - opaque before calling the init function. All other fields are set by the - compression library and must not be updated by the application. - - The opaque value provided by the application will be passed as the first - parameter for calls of zalloc and zfree. This can be useful for custom - memory management. The compression library attaches no meaning to the - opaque value. - - zalloc must return Z_NULL if there is not enough memory for the object. - If zlib is used in a multi-threaded application, zalloc and zfree must be - thread safe. - - On 16-bit systems, the functions zalloc and zfree must be able to allocate - exactly 65536 bytes, but will not be required to allocate more than this - if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, - pointers returned by zalloc for objects of exactly 65536 bytes *must* - have their offset normalized to zero. The default allocation function - provided by this library ensures this (see zutil.c). To reduce memory - requirements and avoid any allocation of 64K objects, at the expense of - compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). - - The fields total_in and total_out can be used for statistics or - progress reports. After compression, total_in holds the total size of - the uncompressed data and may be saved for use in the decompressor - (particularly if the decompressor wants to decompress everything in - a single step). -*/ - - /* constants */ - -#define Z_NO_FLUSH 0 -#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ -#define Z_SYNC_FLUSH 2 -#define Z_FULL_FLUSH 3 -#define Z_FINISH 4 -#define Z_BLOCK 5 -/* Allowed flush values; see deflate() and inflate() below for details */ - -#define Z_OK 0 -#define Z_STREAM_END 1 -#define Z_NEED_DICT 2 -#define Z_ERRNO (-1) -#define Z_STREAM_ERROR (-2) -#define Z_DATA_ERROR (-3) -#define Z_MEM_ERROR (-4) -#define Z_BUF_ERROR (-5) -#define Z_VERSION_ERROR (-6) -/* Return codes for the compression/decompression functions. Negative - * values are errors, positive values are used for special but normal events. - */ - -#define Z_NO_COMPRESSION 0 -#define Z_BEST_SPEED 1 -#define Z_BEST_COMPRESSION 9 -#define Z_DEFAULT_COMPRESSION (-1) -/* compression levels */ - -#define Z_FILTERED 1 -#define Z_HUFFMAN_ONLY 2 -#define Z_RLE 3 -#define Z_FIXED 4 -#define Z_DEFAULT_STRATEGY 0 -/* compression strategy; see deflateInit2() below for details */ - -#define Z_BINARY 0 -#define Z_TEXT 1 -#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ -#define Z_UNKNOWN 2 -/* Possible values of the data_type field (though see inflate()) */ - -#define Z_DEFLATED 8 -/* The deflate compression method (the only one supported in this version) */ - -#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ - -#define zlib_version zlibVersion() -/* for compatibility with versions < 1.0.2 */ - - /* basic functions */ - -ZEXTERN const char * ZEXPORT zlibVersion OF((void)); -/* The application can compare zlibVersion and ZLIB_VERSION for consistency. - If the first character differs, the library code actually used is - not compatible with the zlib.h header file used by the application. - This check is automatically made by deflateInit and inflateInit. - */ - -/* -ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); - - Initializes the internal stream state for compression. The fields - zalloc, zfree and opaque must be initialized before by the caller. - If zalloc and zfree are set to Z_NULL, deflateInit updates them to - use default allocation functions. - - The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: - 1 gives best speed, 9 gives best compression, 0 gives no compression at - all (the input data is simply copied a block at a time). - Z_DEFAULT_COMPRESSION requests a default compromise between speed and - compression (currently equivalent to level 6). - - deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if level is not a valid compression level, - Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible - with the version assumed by the caller (ZLIB_VERSION). - msg is set to null if there is no error message. deflateInit does not - perform any compression: this will be done by deflate(). -*/ - - -ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); -/* - deflate compresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce some - output latency (reading input without producing any output) except when - forced to flush. - - The detailed semantics are as follows. deflate performs one or both of the - following actions: - - - Compress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in and avail_in are updated and - processing will resume at this point for the next call of deflate(). - - - Provide more output starting at next_out and update next_out and avail_out - accordingly. This action is forced if the parameter flush is non zero. - Forcing flush frequently degrades the compression ratio, so this parameter - should be set only when necessary (in interactive applications). - Some output may be provided even if flush is not set. - - Before the call of deflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming - more output, and updating avail_in or avail_out accordingly; avail_out - should never be zero before the call. The application can consume the - compressed output when it wants, for example when the output buffer is full - (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK - and with zero avail_out, it must be called again after making room in the - output buffer because there might be more output pending. - - Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to - decide how much data to accumualte before producing output, in order to - maximize compression. - - If the parameter flush is set to Z_SYNC_FLUSH, all pending output is - flushed to the output buffer and the output is aligned on a byte boundary, so - that the decompressor can get all input data available so far. (In particular - avail_in is zero after the call if enough output space has been provided - before the call.) Flushing may degrade compression for some compression - algorithms and so it should be used only when necessary. - - If flush is set to Z_FULL_FLUSH, all output is flushed as with - Z_SYNC_FLUSH, and the compression state is reset so that decompression can - restart from this point if previous compressed data has been damaged or if - random access is desired. Using Z_FULL_FLUSH too often can seriously degrade - compression. - - If deflate returns with avail_out == 0, this function must be called again - with the same value of the flush parameter and more output space (updated - avail_out), until the flush is complete (deflate returns with non-zero - avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that - avail_out is greater than six to avoid repeated flush markers due to - avail_out == 0 on return. - - If the parameter flush is set to Z_FINISH, pending input is processed, - pending output is flushed and deflate returns with Z_STREAM_END if there - was enough output space; if deflate returns with Z_OK, this function must be - called again with Z_FINISH and more output space (updated avail_out) but no - more input data, until it returns with Z_STREAM_END or an error. After - deflate has returned Z_STREAM_END, the only possible operations on the - stream are deflateReset or deflateEnd. - - Z_FINISH can be used immediately after deflateInit if all the compression - is to be done in a single step. In this case, avail_out must be at least - the value returned by deflateBound (see below). If deflate does not return - Z_STREAM_END, then it must be called again as described above. - - deflate() sets strm->adler to the adler32 checksum of all input read - so far (that is, total_in bytes). - - deflate() may update strm->data_type if it can make a good guess about - the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered - binary. This field is only for information purposes and does not affect - the compression algorithm in any manner. - - deflate() returns Z_OK if some progress has been made (more input - processed or more output produced), Z_STREAM_END if all input has been - consumed and all output has been produced (only when flush is set to - Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example - if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible - (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not - fatal, and deflate() can be called again with more input and more output - space to continue compressing. -*/ - - -ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any - pending output. - - deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the - stream state was inconsistent, Z_DATA_ERROR if the stream was freed - prematurely (some input or output was discarded). In the error case, - msg may be set but then points to a static string (which must not be - deallocated). -*/ - - -/* -ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); - - Initializes the internal stream state for decompression. The fields - next_in, avail_in, zalloc, zfree and opaque must be initialized before by - the caller. If next_in is not Z_NULL and avail_in is large enough (the exact - value depends on the compression method), inflateInit determines the - compression method from the zlib header and allocates all data structures - accordingly; otherwise the allocation will be deferred to the first call of - inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to - use default allocation functions. - - inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_VERSION_ERROR if the zlib library version is incompatible with the - version assumed by the caller. msg is set to null if there is no error - message. inflateInit does not perform any decompression apart from reading - the zlib header if present: this will be done by inflate(). (So next_in and - avail_in may be modified, but next_out and avail_out are unchanged.) -*/ - - -ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); -/* - inflate decompresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce - some output latency (reading input without producing any output) except when - forced to flush. - - The detailed semantics are as follows. inflate performs one or both of the - following actions: - - - Decompress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in is updated and processing - will resume at this point for the next call of inflate(). - - - Provide more output starting at next_out and update next_out and avail_out - accordingly. inflate() provides as much output as possible, until there - is no more input data or no more space in the output buffer (see below - about the flush parameter). - - Before the call of inflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming - more output, and updating the next_* and avail_* values accordingly. - The application can consume the uncompressed output when it wants, for - example when the output buffer is full (avail_out == 0), or after each - call of inflate(). If inflate returns Z_OK and with zero avail_out, it - must be called again after making room in the output buffer because there - might be more output pending. - - The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, - Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much - output as possible to the output buffer. Z_BLOCK requests that inflate() stop - if and when it gets to the next deflate block boundary. When decoding the - zlib or gzip format, this will cause inflate() to return immediately after - the header and before the first block. When doing a raw inflate, inflate() - will go ahead and process the first block, and will return when it gets to - the end of that block, or when it runs out of data. - - The Z_BLOCK option assists in appending to or combining deflate streams. - Also to assist in this, on return inflate() will set strm->data_type to the - number of unused bits in the last byte taken from strm->next_in, plus 64 - if inflate() is currently decoding the last block in the deflate stream, - plus 128 if inflate() returned immediately after decoding an end-of-block - code or decoding the complete header up to just before the first byte of the - deflate stream. The end-of-block will not be indicated until all of the - uncompressed data from that block has been written to strm->next_out. The - number of unused bits may in general be greater than seven, except when - bit 7 of data_type is set, in which case the number of unused bits will be - less than eight. - - inflate() should normally be called until it returns Z_STREAM_END or an - error. However if all decompression is to be performed in a single step - (a single call of inflate), the parameter flush should be set to - Z_FINISH. In this case all pending input is processed and all pending - output is flushed; avail_out must be large enough to hold all the - uncompressed data. (The size of the uncompressed data may have been saved - by the compressor for this purpose.) The next operation on this stream must - be inflateEnd to deallocate the decompression state. The use of Z_FINISH - is never required, but can be used to inform inflate that a faster approach - may be used for the single inflate() call. - - In this implementation, inflate() always flushes as much output as - possible to the output buffer, and always uses the faster approach on the - first call. So the only effect of the flush parameter in this implementation - is on the return value of inflate(), as noted below, or when it returns early - because Z_BLOCK is used. - - If a preset dictionary is needed after this call (see inflateSetDictionary - below), inflate sets strm->adler to the adler32 checksum of the dictionary - chosen by the compressor and returns Z_NEED_DICT; otherwise it sets - strm->adler to the adler32 checksum of all output produced so far (that is, - total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described - below. At the end of the stream, inflate() checks that its computed adler32 - checksum is equal to that saved by the compressor and returns Z_STREAM_END - only if the checksum is correct. - - inflate() will decompress and check either zlib-wrapped or gzip-wrapped - deflate data. The header type is detected automatically. Any information - contained in the gzip header is not retained, so applications that need that - information should instead use raw inflate, see inflateInit2() below, or - inflateBack() and perform their own processing of the gzip header and - trailer. - - inflate() returns Z_OK if some progress has been made (more input processed - or more output produced), Z_STREAM_END if the end of the compressed data has - been reached and all uncompressed output has been produced, Z_NEED_DICT if a - preset dictionary is needed at this point, Z_DATA_ERROR if the input data was - corrupted (input stream not conforming to the zlib format or incorrect check - value), Z_STREAM_ERROR if the stream structure was inconsistent (for example - if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory, - Z_BUF_ERROR if no progress is possible or if there was not enough room in the - output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and - inflate() can be called again with more input and more output space to - continue decompressing. If Z_DATA_ERROR is returned, the application may then - call inflateSync() to look for a good compression block if a partial recovery - of the data is desired. -*/ - - -ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any - pending output. - - inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state - was inconsistent. In the error case, msg may be set but then points to a - static string (which must not be deallocated). -*/ - - /* Advanced functions */ - -/* - The following functions are needed only in some special applications. -*/ - -/* -ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, - int level, - int method, - int windowBits, - int memLevel, - int strategy)); - - This is another version of deflateInit with more compression options. The - fields next_in, zalloc, zfree and opaque must be initialized before by - the caller. - - The method parameter is the compression method. It must be Z_DEFLATED in - this version of the library. - - The windowBits parameter is the base two logarithm of the window size - (the size of the history buffer). It should be in the range 8..15 for this - version of the library. Larger values of this parameter result in better - compression at the expense of memory usage. The default value is 15 if - deflateInit is used instead. - - windowBits can also be -8..-15 for raw deflate. In this case, -windowBits - determines the window size. deflate() will then generate raw deflate data - with no zlib header or trailer, and will not compute an adler32 check value. - - windowBits can also be greater than 15 for optional gzip encoding. Add - 16 to windowBits to write a simple gzip header and trailer around the - compressed data instead of a zlib wrapper. The gzip header will have no - file name, no extra data, no comment, no modification time (set to zero), - no header crc, and the operating system will be set to 255 (unknown). If a - gzip stream is being written, strm->adler is a crc32 instead of an adler32. - - The memLevel parameter specifies how much memory should be allocated - for the internal compression state. memLevel=1 uses minimum memory but - is slow and reduces compression ratio; memLevel=9 uses maximum memory - for optimal speed. The default value is 8. See zconf.h for total memory - usage as a function of windowBits and memLevel. - - The strategy parameter is used to tune the compression algorithm. Use the - value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a - filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no - string match), or Z_RLE to limit match distances to one (run-length - encoding). Filtered data consists mostly of small values with a somewhat - random distribution. In this case, the compression algorithm is tuned to - compress them better. The effect of Z_FILTERED is to force more Huffman - coding and less string matching; it is somewhat intermediate between - Z_DEFAULT and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as - Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy - parameter only affects the compression ratio but not the correctness of the - compressed output even if it is not set appropriately. Z_FIXED prevents the - use of dynamic Huffman codes, allowing for a simpler decoder for special - applications. - - deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid - method). msg is set to null if there is no error message. deflateInit2 does - not perform any compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); -/* - Initializes the compression dictionary from the given byte sequence - without producing any compressed output. This function must be called - immediately after deflateInit, deflateInit2 or deflateReset, before any - call of deflate. The compressor and decompressor must use exactly the same - dictionary (see inflateSetDictionary). - - The dictionary should consist of strings (byte sequences) that are likely - to be encountered later in the data to be compressed, with the most commonly - used strings preferably put towards the end of the dictionary. Using a - dictionary is most useful when the data to be compressed is short and can be - predicted with good accuracy; the data can then be compressed better than - with the default empty dictionary. - - Depending on the size of the compression data structures selected by - deflateInit or deflateInit2, a part of the dictionary may in effect be - discarded, for example if the dictionary is larger than the window size in - deflate or deflate2. Thus the strings most likely to be useful should be - put at the end of the dictionary, not at the front. In addition, the - current implementation of deflate will use at most the window size minus - 262 bytes of the provided dictionary. - - Upon return of this function, strm->adler is set to the adler32 value - of the dictionary; the decompressor may later use this value to determine - which dictionary has been used by the compressor. (The adler32 value - applies to the whole dictionary even if only a subset of the dictionary is - actually used by the compressor.) If a raw deflate was requested, then the - adler32 value is not computed and strm->adler is not set. - - deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a - parameter is invalid (such as NULL dictionary) or the stream state is - inconsistent (for example if deflate has already been called for this stream - or if the compression method is bsort). deflateSetDictionary does not - perform any compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, - z_streamp source)); -/* - Sets the destination stream as a complete copy of the source stream. - - This function can be useful when several compression strategies will be - tried, for example when there are several ways of pre-processing the input - data with a filter. The streams that will be discarded should then be freed - by calling deflateEnd. Note that deflateCopy duplicates the internal - compression state which can be quite large, so this strategy is slow and - can consume lots of memory. - - deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being NULL). msg is left unchanged in both source and - destination. -*/ - -ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); -/* - This function is equivalent to deflateEnd followed by deflateInit, - but does not free and reallocate all the internal compression state. - The stream will keep the same compression level and any other attributes - that may have been set by deflateInit2. - - deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being NULL). -*/ - -ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, - int level, - int strategy)); -/* - Dynamically update the compression level and compression strategy. The - interpretation of level and strategy is as in deflateInit2. This can be - used to switch between compression and straight copy of the input data, or - to switch to a different kind of input data requiring a different - strategy. If the compression level is changed, the input available so far - is compressed with the old level (and may be flushed); the new level will - take effect only at the next call of deflate(). - - Before the call of deflateParams, the stream state must be set as for - a call of deflate(), since the currently available input may have to - be compressed and flushed. In particular, strm->avail_out must be non-zero. - - deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source - stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR - if strm->avail_out was zero. -*/ - -ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, - int good_length, - int max_lazy, - int nice_length, - int max_chain)); -/* - Fine tune deflate's internal compression parameters. This should only be - used by someone who understands the algorithm used by zlib's deflate for - searching for the best matching string, and even then only by the most - fanatic optimizer trying to squeeze out the last compressed bit for their - specific input data. Read the deflate.c source code for the meaning of the - max_lazy, good_length, nice_length, and max_chain parameters. - - deflateTune() can be called after deflateInit() or deflateInit2(), and - returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. - */ - -ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, - uLong sourceLen)); -/* - deflateBound() returns an upper bound on the compressed size after - deflation of sourceLen bytes. It must be called after deflateInit() - or deflateInit2(). This would be used to allocate an output buffer - for deflation in a single pass, and so would be called before deflate(). -*/ - -ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, - int bits, - int value)); -/* - deflatePrime() inserts bits in the deflate output stream. The intent - is that this function is used to start off the deflate output with the - bits leftover from a previous deflate stream when appending to it. As such, - this function can only be used for raw deflate, and must be used before the - first deflate() call after a deflateInit2() or deflateReset(). bits must be - less than or equal to 16, and that many of the least significant bits of - value will be inserted in the output. - - deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, - gz_headerp head)); -/* - deflateSetHeader() provides gzip header information for when a gzip - stream is requested by deflateInit2(). deflateSetHeader() may be called - after deflateInit2() or deflateReset() and before the first call of - deflate(). The text, time, os, extra field, name, and comment information - in the provided gz_header structure are written to the gzip header (xflag is - ignored -- the extra flags are set according to the compression level). The - caller must assure that, if not Z_NULL, name and comment are terminated with - a zero byte, and that if extra is not Z_NULL, that extra_len bytes are - available there. If hcrc is true, a gzip header crc is included. Note that - the current versions of the command-line version of gzip (up through version - 1.3.x) do not support header crc's, and will report that it is a "multi-part - gzip file" and give up. - - If deflateSetHeader is not used, the default gzip header has text false, - the time set to zero, and os set to 255, with no extra, name, or comment - fields. The gzip header is returned to the default state by deflateReset(). - - deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -/* -ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, - int windowBits)); - - This is another version of inflateInit with an extra parameter. The - fields next_in, avail_in, zalloc, zfree and opaque must be initialized - before by the caller. - - The windowBits parameter is the base two logarithm of the maximum window - size (the size of the history buffer). It should be in the range 8..15 for - this version of the library. The default value is 15 if inflateInit is used - instead. windowBits must be greater than or equal to the windowBits value - provided to deflateInit2() while compressing, or it must be equal to 15 if - deflateInit2() was not used. If a compressed stream with a larger window - size is given as input, inflate() will return with the error code - Z_DATA_ERROR instead of trying to allocate a larger window. - - windowBits can also be -8..-15 for raw inflate. In this case, -windowBits - determines the window size. inflate() will then process raw deflate data, - not looking for a zlib or gzip header, not generating a check value, and not - looking for any check values for comparison at the end of the stream. This - is for use with other formats that use the deflate compressed data format - such as zip. Those formats provide their own check values. If a custom - format is developed using the raw deflate format for compressed data, it is - recommended that a check value such as an adler32 or a crc32 be applied to - the uncompressed data as is done in the zlib, gzip, and zip formats. For - most applications, the zlib format should be used as is. Note that comments - above on the use in deflateInit2() applies to the magnitude of windowBits. - - windowBits can also be greater than 15 for optional gzip decoding. Add - 32 to windowBits to enable zlib and gzip decoding with automatic header - detection, or add 16 to decode only the gzip format (the zlib format will - return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is - a crc32 instead of an adler32. - - inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). msg - is set to null if there is no error message. inflateInit2 does not perform - any decompression apart from reading the zlib header if present: this will - be done by inflate(). (So next_in and avail_in may be modified, but next_out - and avail_out are unchanged.) -*/ - -ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); -/* - Initializes the decompression dictionary from the given uncompressed byte - sequence. This function must be called immediately after a call of inflate, - if that call returned Z_NEED_DICT. The dictionary chosen by the compressor - can be determined from the adler32 value returned by that call of inflate. - The compressor and decompressor must use exactly the same dictionary (see - deflateSetDictionary). For raw inflate, this function can be called - immediately after inflateInit2() or inflateReset() and before any call of - inflate() to set the dictionary. The application must insure that the - dictionary that was used for compression is provided. - - inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a - parameter is invalid (such as NULL dictionary) or the stream state is - inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the - expected one (incorrect adler32 value). inflateSetDictionary does not - perform any decompression: this will be done by subsequent calls of - inflate(). -*/ - -ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); -/* - Skips invalid compressed data until a full flush point (see above the - description of deflate with Z_FULL_FLUSH) can be found, or until all - available input is skipped. No output is provided. - - inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR - if no more input was provided, Z_DATA_ERROR if no flush point has been found, - or Z_STREAM_ERROR if the stream structure was inconsistent. In the success - case, the application may save the current current value of total_in which - indicates where valid compressed data was found. In the error case, the - application may repeatedly call inflateSync, providing more input each time, - until success or end of the input data. -*/ - -ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, - z_streamp source)); -/* - Sets the destination stream as a complete copy of the source stream. - - This function can be useful when randomly accessing a large stream. The - first pass through the stream can periodically record the inflate state, - allowing restarting inflate at those points when randomly accessing the - stream. - - inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being NULL). msg is left unchanged in both source and - destination. -*/ - -ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); -/* - This function is equivalent to inflateEnd followed by inflateInit, - but does not free and reallocate all the internal decompression state. - The stream will keep attributes that may have been set by inflateInit2. - - inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being NULL). -*/ - -ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, - int bits, - int value)); -/* - This function inserts bits in the inflate input stream. The intent is - that this function is used to start inflating at a bit position in the - middle of a byte. The provided bits will be used before any bytes are used - from next_in. This function should only be used with raw inflate, and - should be used before the first inflate() call after inflateInit2() or - inflateReset(). bits must be less than or equal to 16, and that many of the - least significant bits of value will be inserted in the input. - - inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, - gz_headerp head)); -/* - inflateGetHeader() requests that gzip header information be stored in the - provided gz_header structure. inflateGetHeader() may be called after - inflateInit2() or inflateReset(), and before the first call of inflate(). - As inflate() processes the gzip stream, head->done is zero until the header - is completed, at which time head->done is set to one. If a zlib stream is - being decoded, then head->done is set to -1 to indicate that there will be - no gzip header information forthcoming. Note that Z_BLOCK can be used to - force inflate() to return immediately after header processing is complete - and before any actual data is decompressed. - - The text, time, xflags, and os fields are filled in with the gzip header - contents. hcrc is set to true if there is a header CRC. (The header CRC - was valid if done is set to one.) If extra is not Z_NULL, then extra_max - contains the maximum number of bytes to write to extra. Once done is true, - extra_len contains the actual extra field length, and extra contains the - extra field, or that field truncated if extra_max is less than extra_len. - If name is not Z_NULL, then up to name_max characters are written there, - terminated with a zero unless the length is greater than name_max. If - comment is not Z_NULL, then up to comm_max characters are written there, - terminated with a zero unless the length is greater than comm_max. When - any of extra, name, or comment are not Z_NULL and the respective field is - not present in the header, then that field is set to Z_NULL to signal its - absence. This allows the use of deflateSetHeader() with the returned - structure to duplicate the header. However if those fields are set to - allocated memory, then the application will need to save those pointers - elsewhere so that they can be eventually freed. - - If inflateGetHeader is not used, then the header information is simply - discarded. The header is always checked for validity, including the header - CRC if present. inflateReset() will reset the process to discard the header - information. The application would need to call inflateGetHeader() again to - retrieve the header from the next gzip stream. - - inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -/* -ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, - unsigned char FAR *window)); - - Initialize the internal stream state for decompression using inflateBack() - calls. The fields zalloc, zfree and opaque in strm must be initialized - before the call. If zalloc and zfree are Z_NULL, then the default library- - derived memory allocation routines are used. windowBits is the base two - logarithm of the window size, in the range 8..15. window is a caller - supplied buffer of that size. Except for special applications where it is - assured that deflate was used with small window sizes, windowBits must be 15 - and a 32K byte window must be supplied to be able to decompress general - deflate streams. - - See inflateBack() for the usage of these routines. - - inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of - the paramaters are invalid, Z_MEM_ERROR if the internal state could not - be allocated, or Z_VERSION_ERROR if the version of the library does not - match the version of the header file. -*/ - -typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *)); -typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); - -ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, - in_func in, void FAR *in_desc, - out_func out, void FAR *out_desc)); -/* - inflateBack() does a raw inflate with a single call using a call-back - interface for input and output. This is more efficient than inflate() for - file i/o applications in that it avoids copying between the output and the - sliding window by simply making the window itself the output buffer. This - function trusts the application to not change the output buffer passed by - the output function, at least until inflateBack() returns. - - inflateBackInit() must be called first to allocate the internal state - and to initialize the state with the user-provided window buffer. - inflateBack() may then be used multiple times to inflate a complete, raw - deflate stream with each call. inflateBackEnd() is then called to free - the allocated state. - - A raw deflate stream is one with no zlib or gzip header or trailer. - This routine would normally be used in a utility that reads zip or gzip - files and writes out uncompressed files. The utility would decode the - header and process the trailer on its own, hence this routine expects - only the raw deflate stream to decompress. This is different from the - normal behavior of inflate(), which expects either a zlib or gzip header and - trailer around the deflate stream. - - inflateBack() uses two subroutines supplied by the caller that are then - called by inflateBack() for input and output. inflateBack() calls those - routines until it reads a complete deflate stream and writes out all of the - uncompressed data, or until it encounters an error. The function's - parameters and return types are defined above in the in_func and out_func - typedefs. inflateBack() will call in(in_desc, &buf) which should return the - number of bytes of provided input, and a pointer to that input in buf. If - there is no input available, in() must return zero--buf is ignored in that - case--and inflateBack() will return a buffer error. inflateBack() will call - out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out() - should return zero on success, or non-zero on failure. If out() returns - non-zero, inflateBack() will return with an error. Neither in() nor out() - are permitted to change the contents of the window provided to - inflateBackInit(), which is also the buffer that out() uses to write from. - The length written by out() will be at most the window size. Any non-zero - amount of input may be provided by in(). - - For convenience, inflateBack() can be provided input on the first call by - setting strm->next_in and strm->avail_in. If that input is exhausted, then - in() will be called. Therefore strm->next_in must be initialized before - calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called - immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in - must also be initialized, and then if strm->avail_in is not zero, input will - initially be taken from strm->next_in[0 .. strm->avail_in - 1]. - - The in_desc and out_desc parameters of inflateBack() is passed as the - first parameter of in() and out() respectively when they are called. These - descriptors can be optionally used to pass any information that the caller- - supplied in() and out() functions need to do their job. - - On return, inflateBack() will set strm->next_in and strm->avail_in to - pass back any unused input that was provided by the last in() call. The - return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR - if in() or out() returned an error, Z_DATA_ERROR if there was a format - error in the deflate stream (in which case strm->msg is set to indicate the - nature of the error), or Z_STREAM_ERROR if the stream was not properly - initialized. In the case of Z_BUF_ERROR, an input or output error can be - distinguished using strm->next_in which will be Z_NULL only if in() returned - an error. If strm->next is not Z_NULL, then the Z_BUF_ERROR was due to - out() returning non-zero. (in() will always be called before out(), so - strm->next_in is assured to be defined if out() returns non-zero.) Note - that inflateBack() cannot return Z_OK. -*/ - -ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); -/* - All memory allocated by inflateBackInit() is freed. - - inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream - state was inconsistent. -*/ - -ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); -/* Return flags indicating compile-time options. - - Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: - 1.0: size of uInt - 3.2: size of uLong - 5.4: size of voidpf (pointer) - 7.6: size of z_off_t - - Compiler, assembler, and debug options: - 8: DEBUG - 9: ASMV or ASMINF -- use ASM code - 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention - 11: 0 (reserved) - - One-time table building (smaller code, but not thread-safe if true): - 12: BUILDFIXED -- build static block decoding tables when needed - 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed - 14,15: 0 (reserved) - - Library content (indicates missing functionality): - 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking - deflate code when not needed) - 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect - and decode gzip streams (to avoid linking crc code) - 18-19: 0 (reserved) - - Operation variations (changes in library functionality): - 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate - 21: FASTEST -- deflate algorithm with only one, lowest compression level - 22,23: 0 (reserved) - - The sprintf variant used by gzprintf (zero is best): - 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format - 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! - 26: 0 = returns value, 1 = void -- 1 means inferred string length returned - - Remainder: - 27-31: 0 (reserved) - */ - - - /* utility functions */ - -/* - The following utility functions are implemented on top of the - basic stream-oriented functions. To simplify the interface, some - default options are assumed (compression level and memory usage, - standard memory allocation functions). The source code of these - utility functions can easily be modified if you need special options. -*/ - -ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); -/* - Compresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total - size of the destination buffer, which must be at least the value returned - by compressBound(sourceLen). Upon exit, destLen is the actual size of the - compressed buffer. - This function can be used to compress a whole file at once if the - input file is mmap'ed. - compress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer. -*/ - -ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen, - int level)); -/* - Compresses the source buffer into the destination buffer. The level - parameter has the same meaning as in deflateInit. sourceLen is the byte - length of the source buffer. Upon entry, destLen is the total size of the - destination buffer, which must be at least the value returned by - compressBound(sourceLen). Upon exit, destLen is the actual size of the - compressed buffer. - - compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_BUF_ERROR if there was not enough room in the output buffer, - Z_STREAM_ERROR if the level parameter is invalid. -*/ - -ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); -/* - compressBound() returns an upper bound on the compressed size after - compress() or compress2() on sourceLen bytes. It would be used before - a compress() or compress2() call to allocate the destination buffer. -*/ - -ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); -/* - Decompresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total - size of the destination buffer, which must be large enough to hold the - entire uncompressed data. (The size of the uncompressed data must have - been saved previously by the compressor and transmitted to the decompressor - by some mechanism outside the scope of this compression library.) - Upon exit, destLen is the actual size of the compressed buffer. - This function can be used to decompress a whole file at once if the - input file is mmap'ed. - - uncompress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. -*/ - - -typedef voidp gzFile; - -ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); -/* - Opens a gzip (.gz) file for reading or writing. The mode parameter - is as in fopen ("rb" or "wb") but can also include a compression level - ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for - Huffman only compression as in "wb1h", or 'R' for run-length encoding - as in "wb1R". (See the description of deflateInit2 for more information - about the strategy parameter.) - - gzopen can be used to read a file which is not in gzip format; in this - case gzread will directly read from the file without decompression. - - gzopen returns NULL if the file could not be opened or if there was - insufficient memory to allocate the (de)compression state; errno - can be checked to distinguish the two cases (if errno is zero, the - zlib error is Z_MEM_ERROR). */ - -ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); -/* - gzdopen() associates a gzFile with the file descriptor fd. File - descriptors are obtained from calls like open, dup, creat, pipe or - fileno (in the file has been previously opened with fopen). - The mode parameter is as in gzopen. - The next call of gzclose on the returned gzFile will also close the - file descriptor fd, just like fclose(fdopen(fd), mode) closes the file - descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). - gzdopen returns NULL if there was insufficient memory to allocate - the (de)compression state. -*/ - -ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); -/* - Dynamically update the compression level or strategy. See the description - of deflateInit2 for the meaning of these parameters. - gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not - opened for writing. -*/ - -ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); -/* - Reads the given number of uncompressed bytes from the compressed file. - If the input file was not in gzip format, gzread copies the given number - of bytes into the buffer. - gzread returns the number of uncompressed bytes actually read (0 for - end of file, -1 for error). */ - -ZEXTERN int ZEXPORT gzwrite OF((gzFile file, - voidpc buf, unsigned len)); -/* - Writes the given number of uncompressed bytes into the compressed file. - gzwrite returns the number of uncompressed bytes actually written - (0 in case of error). -*/ - -ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); -/* - Converts, formats, and writes the args to the compressed file under - control of the format string, as in fprintf. gzprintf returns the number of - uncompressed bytes actually written (0 in case of error). The number of - uncompressed bytes written is limited to 4095. The caller should assure that - this limit is not exceeded. If it is exceeded, then gzprintf() will return - return an error (0) with nothing written. In this case, there may also be a - buffer overflow with unpredictable consequences, which is possible only if - zlib was compiled with the insecure functions sprintf() or vsprintf() - because the secure snprintf() or vsnprintf() functions were not available. -*/ - -ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); -/* - Writes the given null-terminated string to the compressed file, excluding - the terminating null character. - gzputs returns the number of characters written, or -1 in case of error. -*/ - -ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); -/* - Reads bytes from the compressed file until len-1 characters are read, or - a newline character is read and transferred to buf, or an end-of-file - condition is encountered. The string is then terminated with a null - character. - gzgets returns buf, or Z_NULL in case of error. -*/ - -ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); -/* - Writes c, converted to an unsigned char, into the compressed file. - gzputc returns the value that was written, or -1 in case of error. -*/ - -ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); -/* - Reads one byte from the compressed file. gzgetc returns this byte - or -1 in case of end of file or error. -*/ - -ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); -/* - Push one character back onto the stream to be read again later. - Only one character of push-back is allowed. gzungetc() returns the - character pushed, or -1 on failure. gzungetc() will fail if a - character has been pushed but not read yet, or if c is -1. The pushed - character will be discarded if the stream is repositioned with gzseek() - or gzrewind(). -*/ - -ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); -/* - Flushes all pending output into the compressed file. The parameter - flush is as in the deflate() function. The return value is the zlib - error number (see function gzerror below). gzflush returns Z_OK if - the flush parameter is Z_FINISH and all output could be flushed. - gzflush should be called only when strictly necessary because it can - degrade compression. -*/ - -ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, - z_off_t offset, int whence)); -/* - Sets the starting position for the next gzread or gzwrite on the - given compressed file. The offset represents a number of bytes in the - uncompressed data stream. The whence parameter is defined as in lseek(2); - the value SEEK_END is not supported. - If the file is opened for reading, this function is emulated but can be - extremely slow. If the file is opened for writing, only forward seeks are - supported; gzseek then compresses a sequence of zeroes up to the new - starting position. - - gzseek returns the resulting offset location as measured in bytes from - the beginning of the uncompressed stream, or -1 in case of error, in - particular if the file is opened for writing and the new starting position - would be before the current position. -*/ - -ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); -/* - Rewinds the given file. This function is supported only for reading. - - gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) -*/ - -ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); -/* - Returns the starting position for the next gzread or gzwrite on the - given compressed file. This position represents a number of bytes in the - uncompressed data stream. - - gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) -*/ - -ZEXTERN int ZEXPORT gzeof OF((gzFile file)); -/* - Returns 1 when EOF has previously been detected reading the given - input stream, otherwise zero. -*/ - -ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); -/* - Returns 1 if file is being read directly without decompression, otherwise - zero. -*/ - -ZEXTERN int ZEXPORT gzclose OF((gzFile file)); -/* - Flushes all pending output if necessary, closes the compressed file - and deallocates all the (de)compression state. The return value is the zlib - error number (see function gzerror below). -*/ - -ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); -/* - Returns the error message for the last error which occurred on the - given compressed file. errnum is set to zlib error number. If an - error occurred in the file system and not in the compression library, - errnum is set to Z_ERRNO and the application may consult errno - to get the exact error code. -*/ - -ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); -/* - Clears the error and end-of-file flags for file. This is analogous to the - clearerr() function in stdio. This is useful for continuing to read a gzip - file that is being written concurrently. -*/ - - /* checksum functions */ - -/* - These functions are not related to compression but are exported - anyway because they might be useful in applications using the - compression library. -*/ - -ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); -/* - Update a running Adler-32 checksum with the bytes buf[0..len-1] and - return the updated checksum. If buf is NULL, this function returns - the required initial value for the checksum. - An Adler-32 checksum is almost as reliable as a CRC32 but can be computed - much faster. Usage example: - - uLong adler = adler32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - adler = adler32(adler, buffer, length); - } - if (adler != original_adler) error(); -*/ - -ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, - z_off_t len2)); -/* - Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 - and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for - each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of - seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. -*/ - -ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); -/* - Update a running CRC-32 with the bytes buf[0..len-1] and return the - updated CRC-32. If buf is NULL, this function returns the required initial - value for the for the crc. Pre- and post-conditioning (one's complement) is - performed within this function so it shouldn't be done by the application. - Usage example: - - uLong crc = crc32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - crc = crc32(crc, buffer, length); - } - if (crc != original_crc) error(); -*/ - -ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); - -/* - Combine two CRC-32 check values into one. For two sequences of bytes, - seq1 and seq2 with lengths len1 and len2, CRC-32 check values were - calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 - check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and - len2. -*/ - - - /* various hacks, don't look :) */ - -/* deflateInit and inflateInit are macros to allow checking the zlib version - * and the compiler's view of z_stream: - */ -ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, - int windowBits, int memLevel, - int strategy, const char *version, - int stream_size)); -ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, - unsigned char FAR *window, - const char *version, - int stream_size)); -#define deflateInit(strm, level) \ - deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) -#define inflateInit(strm) \ - inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) -#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ - deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ - (strategy), ZLIB_VERSION, sizeof(z_stream)) -#define inflateInit2(strm, windowBits) \ - inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) -#define inflateBackInit(strm, windowBits, window) \ - inflateBackInit_((strm), (windowBits), (window), \ - ZLIB_VERSION, sizeof(z_stream)) - - -#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) - struct internal_state {int dummy;}; /* hack for buggy compilers */ -#endif - -ZEXTERN const char * ZEXPORT zError OF((int)); -ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); -ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); - -#ifdef __cplusplus -} -#endif - -#endif /* ZLIB_H */ diff --git a/irrlicht-1.6/source/Irrlicht/zlib/zutil.c b/irrlicht-1.6/source/Irrlicht/zlib/zutil.c deleted file mode 100644 index 0f4bd7871..000000000 --- a/irrlicht-1.6/source/Irrlicht/zlib/zutil.c +++ /dev/null @@ -1,318 +0,0 @@ -/* zutil.c -- target dependent utility functions for the compression library - * Copyright (C) 1995-2005 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#include "zutil.h" - -#ifndef NO_DUMMY_DECL -struct internal_state {int dummy;}; /* for buggy compilers */ -#endif - -const char * const z_errmsg[10] = { -"need dictionary", /* Z_NEED_DICT 2 */ -"stream end", /* Z_STREAM_END 1 */ -"", /* Z_OK 0 */ -"file error", /* Z_ERRNO (-1) */ -"stream error", /* Z_STREAM_ERROR (-2) */ -"data error", /* Z_DATA_ERROR (-3) */ -"insufficient memory", /* Z_MEM_ERROR (-4) */ -"buffer error", /* Z_BUF_ERROR (-5) */ -"incompatible version",/* Z_VERSION_ERROR (-6) */ -""}; - - -const char * ZEXPORT zlibVersion() -{ - return ZLIB_VERSION; -} - -uLong ZEXPORT zlibCompileFlags() -{ - uLong flags; - - flags = 0; - switch (sizeof(uInt)) { - case 2: break; - case 4: flags += 1; break; - case 8: flags += 2; break; - default: flags += 3; - } - switch (sizeof(uLong)) { - case 2: break; - case 4: flags += 1 << 2; break; - case 8: flags += 2 << 2; break; - default: flags += 3 << 2; - } - switch (sizeof(voidpf)) { - case 2: break; - case 4: flags += 1 << 4; break; - case 8: flags += 2 << 4; break; - default: flags += 3 << 4; - } - switch (sizeof(z_off_t)) { - case 2: break; - case 4: flags += 1 << 6; break; - case 8: flags += 2 << 6; break; - default: flags += 3 << 6; - } -#ifdef DEBUG - flags += 1 << 8; -#endif -#if defined(ASMV) || defined(ASMINF) - flags += 1 << 9; -#endif -#ifdef ZLIB_WINAPI - flags += 1 << 10; -#endif -#ifdef BUILDFIXED - flags += 1 << 12; -#endif -#ifdef DYNAMIC_CRC_TABLE - flags += 1 << 13; -#endif -#ifdef NO_GZCOMPRESS - flags += 1L << 16; -#endif -#ifdef NO_GZIP - flags += 1L << 17; -#endif -#ifdef PKZIP_BUG_WORKAROUND - flags += 1L << 20; -#endif -#ifdef FASTEST - flags += 1L << 21; -#endif -#ifdef STDC -# ifdef NO_vsnprintf - flags += 1L << 25; -# ifdef HAS_vsprintf_void - flags += 1L << 26; -# endif -# else -# ifdef HAS_vsnprintf_void - flags += 1L << 26; -# endif -# endif -#else - flags += 1L << 24; -# ifdef NO_snprintf - flags += 1L << 25; -# ifdef HAS_sprintf_void - flags += 1L << 26; -# endif -# else -# ifdef HAS_snprintf_void - flags += 1L << 26; -# endif -# endif -#endif - return flags; -} - -#ifdef DEBUG - -# ifndef verbose -# define verbose 0 -# endif -int z_verbose = verbose; - -void z_error (m) - char *m; -{ - fprintf(stderr, "%s\n", m); - exit(1); -} -#endif - -/* exported to allow conversion of error code to string for compress() and - * uncompress() - */ -const char * ZEXPORT zError(err) - int err; -{ - return ERR_MSG(err); -} - -#if defined(_WIN32_WCE) - /* The Microsoft C Run-Time Library for Windows CE doesn't have - * errno. We define it as a global variable to simplify porting. - * Its value is always 0 and should not be used. - */ - int errno = 0; -#endif - -#ifndef HAVE_MEMCPY - -void zmemcpy(dest, source, len) - Bytef* dest; - const Bytef* source; - uInt len; -{ - if (len == 0) return; - do { - *dest++ = *source++; /* ??? to be unrolled */ - } while (--len != 0); -} - -int zmemcmp(s1, s2, len) - const Bytef* s1; - const Bytef* s2; - uInt len; -{ - uInt j; - - for (j = 0; j < len; j++) { - if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; - } - return 0; -} - -void zmemzero(dest, len) - Bytef* dest; - uInt len; -{ - if (len == 0) return; - do { - *dest++ = 0; /* ??? to be unrolled */ - } while (--len != 0); -} -#endif - - -#ifdef SYS16BIT - -#ifdef __TURBOC__ -/* Turbo C in 16-bit mode */ - -# define MY_ZCALLOC - -/* Turbo C malloc() does not allow dynamic allocation of 64K bytes - * and farmalloc(64K) returns a pointer with an offset of 8, so we - * must fix the pointer. Warning: the pointer must be put back to its - * original form in order to free it, use zcfree(). - */ - -#define MAX_PTR 10 -/* 10*64K = 640K */ - -local int next_ptr = 0; - -typedef struct ptr_table_s { - voidpf org_ptr; - voidpf new_ptr; -} ptr_table; - -local ptr_table table[MAX_PTR]; -/* This table is used to remember the original form of pointers - * to large buffers (64K). Such pointers are normalized with a zero offset. - * Since MSDOS is not a preemptive multitasking OS, this table is not - * protected from concurrent access. This hack doesn't work anyway on - * a protected system like OS/2. Use Microsoft C instead. - */ - -voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) -{ - voidpf buf = opaque; /* just to make some compilers happy */ - ulg bsize = (ulg)items*size; - - /* If we allocate less than 65520 bytes, we assume that farmalloc - * will return a usable pointer which doesn't have to be normalized. - */ - if (bsize < 65520L) { - buf = farmalloc(bsize); - if (*(ush*)&buf != 0) return buf; - } else { - buf = farmalloc(bsize + 16L); - } - if (buf == NULL || next_ptr >= MAX_PTR) return NULL; - table[next_ptr].org_ptr = buf; - - /* Normalize the pointer to seg:0 */ - *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; - *(ush*)&buf = 0; - table[next_ptr++].new_ptr = buf; - return buf; -} - -void zcfree (voidpf opaque, voidpf ptr) -{ - int n; - if (*(ush*)&ptr != 0) { /* object < 64K */ - farfree(ptr); - return; - } - /* Find the original pointer */ - for (n = 0; n < next_ptr; n++) { - if (ptr != table[n].new_ptr) continue; - - farfree(table[n].org_ptr); - while (++n < next_ptr) { - table[n-1] = table[n]; - } - next_ptr--; - return; - } - ptr = opaque; /* just to make some compilers happy */ - Assert(0, "zcfree: ptr not found"); -} - -#endif /* __TURBOC__ */ - - -#ifdef M_I86 -/* Microsoft C in 16-bit mode */ - -# define MY_ZCALLOC - -#if (!defined(_MSC_VER) || (_MSC_VER <= 600)) -# define _halloc halloc -# define _hfree hfree -#endif - -voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) -{ - if (opaque) opaque = 0; /* to make compiler happy */ - return _halloc((long)items, size); -} - -void zcfree (voidpf opaque, voidpf ptr) -{ - if (opaque) opaque = 0; /* to make compiler happy */ - _hfree(ptr); -} - -#endif /* M_I86 */ - -#endif /* SYS16BIT */ - - -#ifndef MY_ZCALLOC /* Any system without a special alloc function */ - -#ifndef STDC -extern voidp malloc OF((uInt size)); -extern voidp calloc OF((uInt items, uInt size)); -extern void free OF((voidpf ptr)); -#endif - -voidpf zcalloc (opaque, items, size) - voidpf opaque; - unsigned items; - unsigned size; -{ - if (opaque) items += size - size; /* make compiler happy */ - return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : - (voidpf)calloc(items, size); -} - -void zcfree (opaque, ptr) - voidpf opaque; - voidpf ptr; -{ - free(ptr); - if (opaque) return; /* make compiler happy */ -} - -#endif /* MY_ZCALLOC */ diff --git a/irrlicht-1.6/source/Irrlicht/zlib/zutil.h b/irrlicht-1.6/source/Irrlicht/zlib/zutil.h deleted file mode 100644 index 0ba6e0208..000000000 --- a/irrlicht-1.6/source/Irrlicht/zlib/zutil.h +++ /dev/null @@ -1,269 +0,0 @@ -/* zutil.h -- internal interface and configuration of the compression library - * Copyright (C) 1995-2005 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* @(#) $Id$ */ - -#ifndef ZUTIL_H -#define ZUTIL_H - -#define ZLIB_INTERNAL -#include "zlib.h" - -#ifdef STDC -# ifndef _WIN32_WCE -# include <stddef.h> -# endif -# include <string.h> -# include <stdlib.h> -#endif -#ifdef NO_ERRNO_H -# ifdef _WIN32_WCE - /* The Microsoft C Run-Time Library for Windows CE doesn't have - * errno. We define it as a global variable to simplify porting. - * Its value is always 0 and should not be used. We rename it to - * avoid conflict with other libraries that use the same workaround. - */ -# define errno z_errno -# endif - extern int errno; -#else -# ifndef _WIN32_WCE -# include <errno.h> -# endif -#endif - -#ifndef local -# define local static -#endif -/* compile with -Dlocal if your debugger can't find static symbols */ - -typedef unsigned char uch; -typedef uch FAR uchf; -typedef unsigned short ush; -typedef ush FAR ushf; -typedef unsigned long ulg; - -extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ -/* (size given to avoid silly warnings with Visual C++) */ - -#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] - -#define ERR_RETURN(strm,err) \ - return (strm->msg = (char*)ERR_MSG(err), (err)) -/* To be used only when the state is known to be valid */ - - /* common constants */ - -#ifndef DEF_WBITS -# define DEF_WBITS MAX_WBITS -#endif -/* default windowBits for decompression. MAX_WBITS is for compression only */ - -#if MAX_MEM_LEVEL >= 8 -# define DEF_MEM_LEVEL 8 -#else -# define DEF_MEM_LEVEL MAX_MEM_LEVEL -#endif -/* default memLevel */ - -#define STORED_BLOCK 0 -#define STATIC_TREES 1 -#define DYN_TREES 2 -/* The three kinds of block type */ - -#define MIN_MATCH 3 -#define MAX_MATCH 258 -/* The minimum and maximum match lengths */ - -#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ - - /* target dependencies */ - -#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) -# define OS_CODE 0x00 -# if defined(__TURBOC__) || defined(__BORLANDC__) -# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) - /* Allow compilation with ANSI keywords only enabled */ - void _Cdecl farfree( void *block ); - void *_Cdecl farmalloc( unsigned long nbytes ); -# else -# include <alloc.h> -# endif -# else /* MSC or DJGPP */ -# include <malloc.h> -# endif -#endif - -#ifdef AMIGA -# define OS_CODE 0x01 -#endif - -#if defined(VAXC) || defined(VMS) -# define OS_CODE 0x02 -# define F_OPEN(name, mode) \ - fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") -#endif - -#if defined(ATARI) || defined(atarist) -# define OS_CODE 0x05 -#endif - -#ifdef OS2 -# define OS_CODE 0x06 -# ifdef M_I86 - #include <malloc.h> -# endif -#endif - -#if defined(MACOS) || defined(TARGET_OS_MAC) -# define OS_CODE 0x07 -# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os -# include <unix.h> /* for fdopen */ -# else -# ifndef fdopen -# define fdopen(fd,mode) NULL /* No fdopen() */ -# endif -# endif -#endif - -#ifdef TOPS20 -# define OS_CODE 0x0a -#endif - -#ifdef WIN32 -# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */ -# define OS_CODE 0x0b -# endif -#endif - -#ifdef __50SERIES /* Prime/PRIMOS */ -# define OS_CODE 0x0f -#endif - -#if defined(_BEOS_) || defined(RISCOS) -# define fdopen(fd,mode) NULL /* No fdopen() */ -#endif - -#if (defined(_MSC_VER) && (_MSC_VER > 600)) -# if defined(_WIN32_WCE) -# define fdopen(fd,mode) NULL /* No fdopen() */ -# ifndef _PTRDIFF_T_DEFINED - typedef int ptrdiff_t; -# define _PTRDIFF_T_DEFINED -# endif -# else -# define fdopen(fd,type) _fdopen(fd,type) -# endif -#endif - - /* common defaults */ - -#ifndef OS_CODE -# define OS_CODE 0x03 /* assume Unix */ -#endif - -#ifndef F_OPEN -# define F_OPEN(name, mode) fopen((name), (mode)) -#endif - - /* functions */ - -#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) -# ifndef HAVE_VSNPRINTF -# define HAVE_VSNPRINTF -# endif -#endif -#if defined(__CYGWIN__) -# ifndef HAVE_VSNPRINTF -# define HAVE_VSNPRINTF -# endif -#endif -#ifndef HAVE_VSNPRINTF -# ifdef MSDOS - /* vsnprintf may exist on some MS-DOS compilers (DJGPP?), - but for now we just assume it doesn't. */ -# define NO_vsnprintf -# endif -# ifdef __TURBOC__ -# define NO_vsnprintf -# endif -# ifdef WIN32 - /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ -# if !defined(vsnprintf) && !defined(NO_vsnprintf) -# define vsnprintf _vsnprintf -# endif -# endif -# ifdef __SASC -# define NO_vsnprintf -# endif -#endif -#ifdef VMS -# define NO_vsnprintf -#endif - -#if defined(pyr) -# define NO_MEMCPY -#endif -#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) - /* Use our own functions for small and medium model with MSC <= 5.0. - * You may have to use the same strategy for Borland C (untested). - * The __SC__ check is for Symantec. - */ -# define NO_MEMCPY -#endif -#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) -# define HAVE_MEMCPY -#endif -#ifdef HAVE_MEMCPY -# ifdef SMALL_MEDIUM /* MSDOS small or medium model */ -# define zmemcpy _fmemcpy -# define zmemcmp _fmemcmp -# define zmemzero(dest, len) _fmemset(dest, 0, len) -# else -# define zmemcpy memcpy -# define zmemcmp memcmp -# define zmemzero(dest, len) memset(dest, 0, len) -# endif -#else - extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); - extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); - extern void zmemzero OF((Bytef* dest, uInt len)); -#endif - -/* Diagnostic functions */ -#ifdef DEBUG -# include <stdio.h> - extern int z_verbose; - extern void z_error OF((char *m)); -# define Assert(cond,msg) {if(!(cond)) z_error(msg);} -# define Trace(x) {if (z_verbose>=0) fprintf x ;} -# define Tracev(x) {if (z_verbose>0) fprintf x ;} -# define Tracevv(x) {if (z_verbose>1) fprintf x ;} -# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} -# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} -#else -# define Assert(cond,msg) -# define Trace(x) -# define Tracev(x) -# define Tracevv(x) -# define Tracec(c,x) -# define Tracecv(c,x) -#endif - - -voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); -void zcfree OF((voidpf opaque, voidpf ptr)); - -#define ZALLOC(strm, items, size) \ - (*((strm)->zalloc))((strm)->opaque, (items), (size)) -#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) -#define TRY_FREE(s, p) {if (p) ZFREE(s, p);} - -#endif /* ZUTIL_H */ diff --git a/irrlicht-1.6/source/source.txt b/irrlicht-1.6/source/source.txt deleted file mode 100644 index 2943cc93b..000000000 --- a/irrlicht-1.6/source/source.txt +++ /dev/null @@ -1,53 +0,0 @@ -Source code of the Irrlicht Engine - -The complete source of the Irrlicht Engine can be found in this directory. -Please note that YOU DO NOT NEED THIS SOURCE to develop 3d applications with -the Irrlicht Engine. Instead, please use the .dll in the \bin directory, the -.lib in the \lib directory and the header files in the \include directory. - -You will find a good tutorial how to set up your development environment and to -use the engine in the \examples directory. (Try 1.helloworld) - -The source of the engine is only included because of the following reasons: - - - To let developers be able to debug the engine. - - To let developers be able to make changes to the engine. - - To let developers be able to compile their own versions of the engine. - - - -HOW TO COMPILE THE ENGINE WITH LINUX - -If you wish to compile the engine for Linux yourself, run a 'make' in the -folder 'source/Irrlicht'. After this, you should be able to make all example -applications in examples. Then just run them from the directory where they are -built. -For the necessary compiler and linker flags please check the provided Makefiles -in the examples directories. - -Only the Software Drivers and the Null Driver will work on all Linux machines, -while OpenGL support requires either GLX support of the X11 server (try glxinfo) -or a software OpenGL solution such as Mesa. - -If you get a compiling/linking problem like - - undefined reference to `glXGetProcAddress' - -This is a problem introduced by the NVidia drivers. There are several solutions: -A) Update your drivers. All versions with GLX 1.4 support (i.e. beginning with - 12/2005) will work. -B) Define the symbol _IRR_GETPROCADDRESS_WORKAROUND_ during compilation of - COpenGLDriver.cpp, either by adding it to the compiler command line or by - uncommenting the line defining this symbol inside the OpenGL driver source. - This will force the use of glXGetProcAddressARB which has better chances to - work on older systems. - -If you get compiling or runtime problems regarding XF86VidMode, Xxf86vm.so, or -the XFree86 VidMode extension you have also several solutions: -A) Install the extension for your X server or the developer package in case of - compiler/linker problems. -B) Disable the VidMode usage by disabling the define _IRR_LINUX_X11_VIDMODE_ in - include/IrrCompileConfig.h - In this case you might give the RandR extension a try (by enabling the - next define in that file) which also provides fullscreen support under Linux. - If both extensions fail you won't have fullscreen support for Irrlicht. diff --git a/readme.txt b/readme.txt deleted file mode 100644 index ac5c5d7a0..000000000 --- a/readme.txt +++ /dev/null @@ -1,36 +0,0 @@ - -GameKit is a prototyping environment that includes -http://gamekit.googlecode.com - -+ Bullet Physics Library for physics -+ Irrlicht 1.6 for Graphics -+ readblend to read 32bit little-endian .blend files -+ some example .blend files included in the GameKit folder - -On Apple, you can copy a user file called game.blend next to the GameKit.app bundle, to override the default .blend file. - -It has been tested on Windows, Mac OS X and Linux. - -Some notes: - -Use Cmake (http://cmake.org) to create a build system, for example: - -cmake . -G "Visual Studio 9 2008" -cmake . -G Xcode -cmake . -G "Unix Makefiles" - - -By default, OpenGL is enabled. - -To switch to Direct3D8 or Direct3D9 edit the following files: - -gamekit\irrlicht-1.5\include\IrrCompileConfig.h around line 89 - -//#define _IRR_COMPILE_WITH_DIRECT3D_8_ -#define _IRR_COMPILE_WITH_DIRECT3D_9_ - - -gamekit\GameKit\main.cpp around line 644: -//driverType = video::EDT_OPENGL; -//driverType = video::EDT_DIRECT3D8; - driverType = video::EDT_DIRECT3D9; diff --git a/vectormathlibrary/include/vectormath/SSE/cpp/boolInVec.h b/vectormathlibrary/include/vectormath/SSE/cpp/boolInVec.h new file mode 100644 index 000000000..d21d25cbb --- /dev/null +++ b/vectormathlibrary/include/vectormath/SSE/cpp/boolInVec.h @@ -0,0 +1,247 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _BOOLINVEC_H +#define _BOOLINVEC_H + +#include <math.h> + +namespace Vectormath { + +class floatInVec; + +//-------------------------------------------------------------------------------------------------- +// boolInVec class +// + +class boolInVec +{ + private: + __m128 mData; + + inline boolInVec(__m128 vec); + public: + inline boolInVec() {} + + // matches standard type conversions + // + inline boolInVec(const floatInVec &vec); + + // explicit cast from bool + // + explicit inline boolInVec(bool scalar); + +#ifdef _VECTORMATH_NO_SCALAR_CAST + // explicit cast to bool + // + inline bool getAsBool() const; +#else + // implicit cast to bool + // + inline operator bool() const; +#endif + + // get vector data + // bool value is splatted across all word slots of vector as 0 (false) or -1 (true) + // + inline __m128 get128() const; + + // operators + // + inline const boolInVec operator ! () const; + inline boolInVec& operator = (const boolInVec &vec); + inline boolInVec& operator &= (const boolInVec &vec); + inline boolInVec& operator ^= (const boolInVec &vec); + inline boolInVec& operator |= (const boolInVec &vec); + + // friend functions + // + friend inline const boolInVec operator == (const boolInVec &vec0, const boolInVec &vec1); + friend inline const boolInVec operator != (const boolInVec &vec0, const boolInVec &vec1); + friend inline const boolInVec operator < (const floatInVec &vec0, const floatInVec &vec1); + friend inline const boolInVec operator <= (const floatInVec &vec0, const floatInVec &vec1); + friend inline const boolInVec operator > (const floatInVec &vec0, const floatInVec &vec1); + friend inline const boolInVec operator >= (const floatInVec &vec0, const floatInVec &vec1); + friend inline const boolInVec operator == (const floatInVec &vec0, const floatInVec &vec1); + friend inline const boolInVec operator != (const floatInVec &vec0, const floatInVec &vec1); + friend inline const boolInVec operator & (const boolInVec &vec0, const boolInVec &vec1); + friend inline const boolInVec operator ^ (const boolInVec &vec0, const boolInVec &vec1); + friend inline const boolInVec operator | (const boolInVec &vec0, const boolInVec &vec1); + friend inline const boolInVec select(const boolInVec &vec0, const boolInVec &vec1, const boolInVec &select_vec1); +}; + +//-------------------------------------------------------------------------------------------------- +// boolInVec functions +// + +// operators +// +inline const boolInVec operator == (const boolInVec &vec0, const boolInVec &vec1); +inline const boolInVec operator != (const boolInVec &vec0, const boolInVec &vec1); +inline const boolInVec operator & (const boolInVec &vec0, const boolInVec &vec1); +inline const boolInVec operator ^ (const boolInVec &vec0, const boolInVec &vec1); +inline const boolInVec operator | (const boolInVec &vec0, const boolInVec &vec1); + +// select between vec0 and vec1 using boolInVec. +// false selects vec0, true selects vec1 +// +inline const boolInVec select(const boolInVec &vec0, const boolInVec &vec1, const boolInVec &select_vec1); + +} // namespace Vectormath + +//-------------------------------------------------------------------------------------------------- +// boolInVec implementation +// + +#include "floatInVec.h" + +namespace Vectormath { + +inline +boolInVec::boolInVec(__m128 vec) +{ + mData = vec; +} + +inline +boolInVec::boolInVec(const floatInVec &vec) +{ + *this = (vec != floatInVec(0.0f)); +} + +inline +boolInVec::boolInVec(bool scalar) +{ + unsigned int mask = -(int)scalar; + mData = _mm_set1_ps(*(float *)&mask); // TODO: Union +} + +#ifdef _VECTORMATH_NO_SCALAR_CAST +inline +bool +boolInVec::getAsBool() const +#else +inline +boolInVec::operator bool() const +#endif +{ + return *(bool *)&mData; +} + +inline +__m128 +boolInVec::get128() const +{ + return mData; +} + +inline +const boolInVec +boolInVec::operator ! () const +{ + return boolInVec(_mm_andnot_ps(mData, _mm_cmpneq_ps(_mm_setzero_ps(),_mm_setzero_ps()))); +} + +inline +boolInVec& +boolInVec::operator = (const boolInVec &vec) +{ + mData = vec.mData; + return *this; +} + +inline +boolInVec& +boolInVec::operator &= (const boolInVec &vec) +{ + *this = *this & vec; + return *this; +} + +inline +boolInVec& +boolInVec::operator ^= (const boolInVec &vec) +{ + *this = *this ^ vec; + return *this; +} + +inline +boolInVec& +boolInVec::operator |= (const boolInVec &vec) +{ + *this = *this | vec; + return *this; +} + +inline +const boolInVec +operator == (const boolInVec &vec0, const boolInVec &vec1) +{ + return boolInVec(_mm_cmpeq_ps(vec0.get128(), vec1.get128())); +} + +inline +const boolInVec +operator != (const boolInVec &vec0, const boolInVec &vec1) +{ + return boolInVec(_mm_cmpneq_ps(vec0.get128(), vec1.get128())); +} + +inline +const boolInVec +operator & (const boolInVec &vec0, const boolInVec &vec1) +{ + return boolInVec(_mm_and_ps(vec0.get128(), vec1.get128())); +} + +inline +const boolInVec +operator | (const boolInVec &vec0, const boolInVec &vec1) +{ + return boolInVec(_mm_or_ps(vec0.get128(), vec1.get128())); +} + +inline +const boolInVec +operator ^ (const boolInVec &vec0, const boolInVec &vec1) +{ + return boolInVec(_mm_xor_ps(vec0.get128(), vec1.get128())); +} + +inline +const boolInVec +select(const boolInVec &vec0, const boolInVec &vec1, const boolInVec &select_vec1) +{ + return boolInVec(vec_sel(vec0.get128(), vec1.get128(), select_vec1.get128())); +} + +} // namespace Vectormath + +#endif // boolInVec_h diff --git a/vectormathlibrary/include/vectormath/SSE/cpp/floatInVec.h b/vectormathlibrary/include/vectormath/SSE/cpp/floatInVec.h new file mode 100644 index 000000000..e8ac5959e --- /dev/null +++ b/vectormathlibrary/include/vectormath/SSE/cpp/floatInVec.h @@ -0,0 +1,340 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _FLOATINVEC_H +#define _FLOATINVEC_H + +#include <math.h> +#include <xmmintrin.h> + +namespace Vectormath { + +class boolInVec; + +//-------------------------------------------------------------------------------------------------- +// floatInVec class +// + +class floatInVec +{ + private: + __m128 mData; + + public: + inline floatInVec(__m128 vec); + + inline floatInVec() {} + + // matches standard type conversions + // + inline floatInVec(const boolInVec &vec); + + // construct from a slot of __m128 + // + inline floatInVec(__m128 vec, int slot); + + // explicit cast from float + // + explicit inline floatInVec(float scalar); + +#ifdef _VECTORMATH_NO_SCALAR_CAST + // explicit cast to float + // + inline float getAsFloat() const; +#else + // implicit cast to float + // + inline operator float() const; +#endif + + // get vector data + // float value is splatted across all word slots of vector + // + inline __m128 get128() const; + + // operators + // + inline const floatInVec operator ++ (int); + inline const floatInVec operator -- (int); + inline floatInVec& operator ++ (); + inline floatInVec& operator -- (); + inline const floatInVec operator - () const; + inline floatInVec& operator = (const floatInVec &vec); + inline floatInVec& operator *= (const floatInVec &vec); + inline floatInVec& operator /= (const floatInVec &vec); + inline floatInVec& operator += (const floatInVec &vec); + inline floatInVec& operator -= (const floatInVec &vec); + + // friend functions + // + friend inline const floatInVec operator * (const floatInVec &vec0, const floatInVec &vec1); + friend inline const floatInVec operator / (const floatInVec &vec0, const floatInVec &vec1); + friend inline const floatInVec operator + (const floatInVec &vec0, const floatInVec &vec1); + friend inline const floatInVec operator - (const floatInVec &vec0, const floatInVec &vec1); + friend inline const floatInVec select(const floatInVec &vec0, const floatInVec &vec1, boolInVec select_vec1); +}; + +//-------------------------------------------------------------------------------------------------- +// floatInVec functions +// + +// operators +// +inline const floatInVec operator * (const floatInVec &vec0, const floatInVec &vec1); +inline const floatInVec operator / (const floatInVec &vec0, const floatInVec &vec1); +inline const floatInVec operator + (const floatInVec &vec0, const floatInVec &vec1); +inline const floatInVec operator - (const floatInVec &vec0, const floatInVec &vec1); +inline const boolInVec operator < (const floatInVec &vec0, const floatInVec &vec1); +inline const boolInVec operator <= (const floatInVec &vec0, const floatInVec &vec1); +inline const boolInVec operator > (const floatInVec &vec0, const floatInVec &vec1); +inline const boolInVec operator >= (const floatInVec &vec0, const floatInVec &vec1); +inline const boolInVec operator == (const floatInVec &vec0, const floatInVec &vec1); +inline const boolInVec operator != (const floatInVec &vec0, const floatInVec &vec1); + +// select between vec0 and vec1 using boolInVec. +// false selects vec0, true selects vec1 +// +inline const floatInVec select(const floatInVec &vec0, const floatInVec &vec1, const boolInVec &select_vec1); + +} // namespace Vectormath + +//-------------------------------------------------------------------------------------------------- +// floatInVec implementation +// + +#include "boolInVec.h" + +namespace Vectormath { + +inline +floatInVec::floatInVec(__m128 vec) +{ + mData = vec; +} + +inline +floatInVec::floatInVec(const boolInVec &vec) +{ + mData = vec_sel(_mm_setzero_ps(), _mm_set1_ps(1.0f), vec.get128()); +} + +inline +floatInVec::floatInVec(__m128 vec, int slot) +{ + SSEFloat v; + v.m128 = vec; + mData = _mm_set1_ps(v.f[slot]); +} + +inline +floatInVec::floatInVec(float scalar) +{ + mData = _mm_set1_ps(scalar); +} + +#ifdef _VECTORMATH_NO_SCALAR_CAST +inline +float +floatInVec::getAsFloat() const +#else +inline +floatInVec::operator float() const +#endif +{ + return *((float *)&mData); +} + +inline +__m128 +floatInVec::get128() const +{ + return mData; +} + +inline +const floatInVec +floatInVec::operator ++ (int) +{ + __m128 olddata = mData; + operator ++(); + return floatInVec(olddata); +} + +inline +const floatInVec +floatInVec::operator -- (int) +{ + __m128 olddata = mData; + operator --(); + return floatInVec(olddata); +} + +inline +floatInVec& +floatInVec::operator ++ () +{ + *this += floatInVec(_mm_set1_ps(1.0f)); + return *this; +} + +inline +floatInVec& +floatInVec::operator -- () +{ + *this -= floatInVec(_mm_set1_ps(1.0f)); + return *this; +} + +inline +const floatInVec +floatInVec::operator - () const +{ + return floatInVec(_mm_sub_ps(_mm_setzero_ps(), mData)); +} + +inline +floatInVec& +floatInVec::operator = (const floatInVec &vec) +{ + mData = vec.mData; + return *this; +} + +inline +floatInVec& +floatInVec::operator *= (const floatInVec &vec) +{ + *this = *this * vec; + return *this; +} + +inline +floatInVec& +floatInVec::operator /= (const floatInVec &vec) +{ + *this = *this / vec; + return *this; +} + +inline +floatInVec& +floatInVec::operator += (const floatInVec &vec) +{ + *this = *this + vec; + return *this; +} + +inline +floatInVec& +floatInVec::operator -= (const floatInVec &vec) +{ + *this = *this - vec; + return *this; +} + +inline +const floatInVec +operator * (const floatInVec &vec0, const floatInVec &vec1) +{ + return floatInVec(_mm_mul_ps(vec0.get128(), vec1.get128())); +} + +inline +const floatInVec +operator / (const floatInVec &num, const floatInVec &den) +{ + return floatInVec(_mm_div_ps(num.get128(), den.get128())); +} + +inline +const floatInVec +operator + (const floatInVec &vec0, const floatInVec &vec1) +{ + return floatInVec(_mm_add_ps(vec0.get128(), vec1.get128())); +} + +inline +const floatInVec +operator - (const floatInVec &vec0, const floatInVec &vec1) +{ + return floatInVec(_mm_sub_ps(vec0.get128(), vec1.get128())); +} + +inline +const boolInVec +operator < (const floatInVec &vec0, const floatInVec &vec1) +{ + return boolInVec(_mm_cmpgt_ps(vec1.get128(), vec0.get128())); +} + +inline +const boolInVec +operator <= (const floatInVec &vec0, const floatInVec &vec1) +{ + return boolInVec(_mm_cmpge_ps(vec1.get128(), vec0.get128())); +} + +inline +const boolInVec +operator > (const floatInVec &vec0, const floatInVec &vec1) +{ + return boolInVec(_mm_cmpgt_ps(vec0.get128(), vec1.get128())); +} + +inline +const boolInVec +operator >= (const floatInVec &vec0, const floatInVec &vec1) +{ + return boolInVec(_mm_cmpge_ps(vec0.get128(), vec1.get128())); +} + +inline +const boolInVec +operator == (const floatInVec &vec0, const floatInVec &vec1) +{ + return boolInVec(_mm_cmpeq_ps(vec0.get128(), vec1.get128())); +} + +inline +const boolInVec +operator != (const floatInVec &vec0, const floatInVec &vec1) +{ + return boolInVec(_mm_cmpneq_ps(vec0.get128(), vec1.get128())); +} + +inline +const floatInVec +select(const floatInVec &vec0, const floatInVec &vec1, const boolInVec &select_vec1) +{ + return floatInVec(vec_sel(vec0.get128(), vec1.get128(), select_vec1.get128())); +} + +} // namespace Vectormath + +#endif // floatInVec_h diff --git a/vectormathlibrary/include/vectormath/SSE/cpp/mat_aos.h b/vectormathlibrary/include/vectormath/SSE/cpp/mat_aos.h new file mode 100644 index 000000000..120eac502 --- /dev/null +++ b/vectormathlibrary/include/vectormath/SSE/cpp/mat_aos.h @@ -0,0 +1,2190 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + + +#ifndef _VECTORMATH_MAT_AOS_CPP_H +#define _VECTORMATH_MAT_AOS_CPP_H + +namespace Vectormath { +namespace Aos { + +//----------------------------------------------------------------------------- +// Constants +// for shuffles, words are labeled [x,y,z,w] [a,b,c,d] + +#define _VECTORMATH_PERM_ZBWX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B, _VECTORMATH_PERM_W, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_XCYX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_C, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_XYAB ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A, _VECTORMATH_PERM_B }) +#define _VECTORMATH_PERM_ZWCD ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_W, _VECTORMATH_PERM_C, _VECTORMATH_PERM_D }) +#define _VECTORMATH_PERM_XZBX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_CXXX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_C, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_YAXX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_XAZC ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_A, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_C }) +#define _VECTORMATH_PERM_YXWZ ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X, _VECTORMATH_PERM_W, _VECTORMATH_PERM_Z }) +#define _VECTORMATH_PERM_YBWD ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_B, _VECTORMATH_PERM_W, _VECTORMATH_PERM_D }) +#define _VECTORMATH_PERM_XYCX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_C, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_YCXY ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_C, _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y }) +#define _VECTORMATH_PERM_CXYC ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_C, _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_C }) +#define _VECTORMATH_PERM_ZAYX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_BZXX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_B, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_XZYA ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A }) +#define _VECTORMATH_PERM_ZXXB ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X, _VECTORMATH_PERM_B }) +#define _VECTORMATH_PERM_YXXC ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X, _VECTORMATH_PERM_C }) +#define _VECTORMATH_PERM_BBYX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_B, _VECTORMATH_PERM_B, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PI_OVER_2 1.570796327f + +//----------------------------------------------------------------------------- +// Definitions + +inline Matrix3::Matrix3( const Matrix3 & mat ) +{ + mCol0 = mat.mCol0; + mCol1 = mat.mCol1; + mCol2 = mat.mCol2; +} + +inline Matrix3::Matrix3( float scalar ) +{ + mCol0 = Vector3( scalar ); + mCol1 = Vector3( scalar ); + mCol2 = Vector3( scalar ); +} + +inline Matrix3::Matrix3( const floatInVec &scalar ) +{ + mCol0 = Vector3( scalar ); + mCol1 = Vector3( scalar ); + mCol2 = Vector3( scalar ); +} + +inline Matrix3::Matrix3( const Quat &unitQuat ) +{ + __m128 xyzw_2, wwww, yzxw, zxyw, yzxw_2, zxyw_2; + __m128 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; + __declspec(align(16)) unsigned int sx[4] = {0xffffffff, 0, 0, 0}; + __declspec(align(16)) unsigned int sz[4] = {0, 0, 0xffffffff, 0}; + __m128 select_x = _mm_load_ps((float *)sx); + __m128 select_z = _mm_load_ps((float *)sz); + + xyzw_2 = _mm_add_ps( unitQuat.get128(), unitQuat.get128() ); + wwww = _mm_shuffle_ps( unitQuat.get128(), unitQuat.get128(), _MM_SHUFFLE(3,3,3,3) ); + yzxw = _mm_shuffle_ps( unitQuat.get128(), unitQuat.get128(), _MM_SHUFFLE(3,0,2,1) ); + zxyw = _mm_shuffle_ps( unitQuat.get128(), unitQuat.get128(), _MM_SHUFFLE(3,1,0,2) ); + yzxw_2 = _mm_shuffle_ps( xyzw_2, xyzw_2, _MM_SHUFFLE(3,0,2,1) ); + zxyw_2 = _mm_shuffle_ps( xyzw_2, xyzw_2, _MM_SHUFFLE(3,1,0,2) ); + + tmp0 = _mm_mul_ps( yzxw_2, wwww ); // tmp0 = 2yw, 2zw, 2xw, 2w2 + tmp1 = _mm_sub_ps( _mm_set1_ps(1.0f), _mm_mul_ps(yzxw, yzxw_2) ); // tmp1 = 1 - 2y2, 1 - 2z2, 1 - 2x2, 1 - 2w2 + tmp2 = _mm_mul_ps( yzxw, xyzw_2 ); // tmp2 = 2xy, 2yz, 2xz, 2w2 + tmp0 = _mm_add_ps( _mm_mul_ps(zxyw, xyzw_2), tmp0 ); // tmp0 = 2yw + 2zx, 2zw + 2xy, 2xw + 2yz, 2w2 + 2w2 + tmp1 = _mm_sub_ps( tmp1, _mm_mul_ps(zxyw, zxyw_2) ); // tmp1 = 1 - 2y2 - 2z2, 1 - 2z2 - 2x2, 1 - 2x2 - 2y2, 1 - 2w2 - 2w2 + tmp2 = _mm_sub_ps( tmp2, _mm_mul_ps(zxyw_2, wwww) ); // tmp2 = 2xy - 2zw, 2yz - 2xw, 2xz - 2yw, 2w2 -2w2 + + tmp3 = vec_sel( tmp0, tmp1, select_x ); + tmp4 = vec_sel( tmp1, tmp2, select_x ); + tmp5 = vec_sel( tmp2, tmp0, select_x ); + mCol0 = Vector3( vec_sel( tmp3, tmp2, select_z ) ); + mCol1 = Vector3( vec_sel( tmp4, tmp0, select_z ) ); + mCol2 = Vector3( vec_sel( tmp5, tmp1, select_z ) ); +} + +inline Matrix3::Matrix3( const Vector3 &_col0, const Vector3 &_col1, const Vector3 &_col2 ) +{ + mCol0 = _col0; + mCol1 = _col1; + mCol2 = _col2; +} + +inline Matrix3 & Matrix3::setCol0( const Vector3 &_col0 ) +{ + mCol0 = _col0; + return *this; +} + +inline Matrix3 & Matrix3::setCol1( const Vector3 &_col1 ) +{ + mCol1 = _col1; + return *this; +} + +inline Matrix3 & Matrix3::setCol2( const Vector3 &_col2 ) +{ + mCol2 = _col2; + return *this; +} + +inline Matrix3 & Matrix3::setCol( int col, const Vector3 &vec ) +{ + *(&mCol0 + col) = vec; + return *this; +} + +inline Matrix3 & Matrix3::setRow( int row, const Vector3 &vec ) +{ + mCol0.setElem( row, vec.getElem( 0 ) ); + mCol1.setElem( row, vec.getElem( 1 ) ); + mCol2.setElem( row, vec.getElem( 2 ) ); + return *this; +} + +inline Matrix3 & Matrix3::setElem( int col, int row, float val ) +{ + (*this)[col].setElem(row, val); + return *this; +} + +inline Matrix3 & Matrix3::setElem( int col, int row, const floatInVec &val ) +{ + Vector3 tmpV3_0; + tmpV3_0 = this->getCol( col ); + tmpV3_0.setElem( row, val ); + this->setCol( col, tmpV3_0 ); + return *this; +} + +inline const floatInVec Matrix3::getElem( int col, int row ) const +{ + return this->getCol( col ).getElem( row ); +} + +inline const Vector3 Matrix3::getCol0( ) const +{ + return mCol0; +} + +inline const Vector3 Matrix3::getCol1( ) const +{ + return mCol1; +} + +inline const Vector3 Matrix3::getCol2( ) const +{ + return mCol2; +} + +inline const Vector3 Matrix3::getCol( int col ) const +{ + return *(&mCol0 + col); +} + +inline const Vector3 Matrix3::getRow( int row ) const +{ + return Vector3( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ) ); +} + +inline Vector3 & Matrix3::operator []( int col ) +{ + return *(&mCol0 + col); +} + +inline const Vector3 Matrix3::operator []( int col ) const +{ + return *(&mCol0 + col); +} + +inline Matrix3 & Matrix3::operator =( const Matrix3 & mat ) +{ + mCol0 = mat.mCol0; + mCol1 = mat.mCol1; + mCol2 = mat.mCol2; + return *this; +} + +inline const Matrix3 transpose( const Matrix3 & mat ) +{ + __m128 tmp0, tmp1, res0, res1, res2; + tmp0 = vec_mergeh( mat.getCol0().get128(), mat.getCol2().get128() ); + tmp1 = vec_mergel( mat.getCol0().get128(), mat.getCol2().get128() ); + res0 = vec_mergeh( tmp0, mat.getCol1().get128() ); + //res1 = vec_perm( tmp0, mat.getCol1().get128(), _VECTORMATH_PERM_ZBWX ); + __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; + res1 = _mm_shuffle_ps( tmp0, tmp0, _MM_SHUFFLE(0,3,2,2)); + res1 = vec_sel(res1, mat.getCol1().get128(), select_y); + //res2 = vec_perm( tmp1, mat.getCol1().get128(), _VECTORMATH_PERM_XCYX ); + res2 = _mm_shuffle_ps( tmp1, tmp1, _MM_SHUFFLE(0,1,1,0)); + res2 = vec_sel(res2, vec_splat(mat.getCol1().get128(), 2), select_y); + return Matrix3( + Vector3( res0 ), + Vector3( res1 ), + Vector3( res2 ) + ); +} + +inline const Matrix3 inverse( const Matrix3 & mat ) +{ + __m128 tmp0, tmp1, tmp2, tmp3, tmp4, dot, invdet, inv0, inv1, inv2; + tmp2 = _vmathVfCross( mat.getCol0().get128(), mat.getCol1().get128() ); + tmp0 = _vmathVfCross( mat.getCol1().get128(), mat.getCol2().get128() ); + tmp1 = _vmathVfCross( mat.getCol2().get128(), mat.getCol0().get128() ); + dot = _vmathVfDot3( tmp2, mat.getCol2().get128() ); + dot = vec_splat( dot, 0 ); + invdet = recipf4( dot ); + tmp3 = vec_mergeh( tmp0, tmp2 ); + tmp4 = vec_mergel( tmp0, tmp2 ); + inv0 = vec_mergeh( tmp3, tmp1 ); + //inv1 = vec_perm( tmp3, tmp1, _VECTORMATH_PERM_ZBWX ); + __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; + inv1 = _mm_shuffle_ps( tmp3, tmp3, _MM_SHUFFLE(0,3,2,2)); + inv1 = vec_sel(inv1, tmp1, select_y); + //inv2 = vec_perm( tmp4, tmp1, _VECTORMATH_PERM_XCYX ); + inv2 = _mm_shuffle_ps( tmp4, tmp4, _MM_SHUFFLE(0,1,1,0)); + inv2 = vec_sel(inv2, vec_splat(tmp1, 2), select_y); + inv0 = vec_mul( inv0, invdet ); + inv1 = vec_mul( inv1, invdet ); + inv2 = vec_mul( inv2, invdet ); + return Matrix3( + Vector3( inv0 ), + Vector3( inv1 ), + Vector3( inv2 ) + ); +} + +inline const floatInVec determinant( const Matrix3 & mat ) +{ + return dot( mat.getCol2(), cross( mat.getCol0(), mat.getCol1() ) ); +} + +inline const Matrix3 Matrix3::operator +( const Matrix3 & mat ) const +{ + return Matrix3( + ( mCol0 + mat.mCol0 ), + ( mCol1 + mat.mCol1 ), + ( mCol2 + mat.mCol2 ) + ); +} + +inline const Matrix3 Matrix3::operator -( const Matrix3 & mat ) const +{ + return Matrix3( + ( mCol0 - mat.mCol0 ), + ( mCol1 - mat.mCol1 ), + ( mCol2 - mat.mCol2 ) + ); +} + +inline Matrix3 & Matrix3::operator +=( const Matrix3 & mat ) +{ + *this = *this + mat; + return *this; +} + +inline Matrix3 & Matrix3::operator -=( const Matrix3 & mat ) +{ + *this = *this - mat; + return *this; +} + +inline const Matrix3 Matrix3::operator -( ) const +{ + return Matrix3( + ( -mCol0 ), + ( -mCol1 ), + ( -mCol2 ) + ); +} + +inline const Matrix3 absPerElem( const Matrix3 & mat ) +{ + return Matrix3( + absPerElem( mat.getCol0() ), + absPerElem( mat.getCol1() ), + absPerElem( mat.getCol2() ) + ); +} + +inline const Matrix3 Matrix3::operator *( float scalar ) const +{ + return *this * floatInVec(scalar); +} + +inline const Matrix3 Matrix3::operator *( const floatInVec &scalar ) const +{ + return Matrix3( + ( mCol0 * scalar ), + ( mCol1 * scalar ), + ( mCol2 * scalar ) + ); +} + +inline Matrix3 & Matrix3::operator *=( float scalar ) +{ + return *this *= floatInVec(scalar); +} + +inline Matrix3 & Matrix3::operator *=( const floatInVec &scalar ) +{ + *this = *this * scalar; + return *this; +} + +inline const Matrix3 operator *( float scalar, const Matrix3 & mat ) +{ + return floatInVec(scalar) * mat; +} + +inline const Matrix3 operator *( const floatInVec &scalar, const Matrix3 & mat ) +{ + return mat * scalar; +} + +inline const Vector3 Matrix3::operator *( const Vector3 &vec ) const +{ + __m128 res; + __m128 xxxx, yyyy, zzzz; + xxxx = vec_splat( vec.get128(), 0 ); + yyyy = vec_splat( vec.get128(), 1 ); + zzzz = vec_splat( vec.get128(), 2 ); + res = vec_mul( mCol0.get128(), xxxx ); + res = vec_madd( mCol1.get128(), yyyy, res ); + res = vec_madd( mCol2.get128(), zzzz, res ); + return Vector3( res ); +} + +inline const Matrix3 Matrix3::operator *( const Matrix3 & mat ) const +{ + return Matrix3( + ( *this * mat.mCol0 ), + ( *this * mat.mCol1 ), + ( *this * mat.mCol2 ) + ); +} + +inline Matrix3 & Matrix3::operator *=( const Matrix3 & mat ) +{ + *this = *this * mat; + return *this; +} + +inline const Matrix3 mulPerElem( const Matrix3 & mat0, const Matrix3 & mat1 ) +{ + return Matrix3( + mulPerElem( mat0.getCol0(), mat1.getCol0() ), + mulPerElem( mat0.getCol1(), mat1.getCol1() ), + mulPerElem( mat0.getCol2(), mat1.getCol2() ) + ); +} + +inline const Matrix3 Matrix3::identity( ) +{ + return Matrix3( + Vector3::xAxis( ), + Vector3::yAxis( ), + Vector3::zAxis( ) + ); +} + +inline const Matrix3 Matrix3::rotationX( float radians ) +{ + return rotationX( floatInVec(radians) ); +} + +inline const Matrix3 Matrix3::rotationX( const floatInVec &radians ) +{ + __m128 s, c, res1, res2; + __m128 zero; + __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; + __declspec(align(16)) unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; + zero = _mm_setzero_ps(); + sincosf4( radians.get128(), &s, &c ); + res1 = vec_sel( zero, c, select_y ); + res1 = vec_sel( res1, s, select_z ); + res2 = vec_sel( zero, negatef4(s), select_y ); + res2 = vec_sel( res2, c, select_z ); + return Matrix3( + Vector3::xAxis( ), + Vector3( res1 ), + Vector3( res2 ) + ); +} + +inline const Matrix3 Matrix3::rotationY( float radians ) +{ + return rotationY( floatInVec(radians) ); +} + +inline const Matrix3 Matrix3::rotationY( const floatInVec &radians ) +{ + __m128 s, c, res0, res2; + __m128 zero; + __declspec(align(16)) unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; + __declspec(align(16)) unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; + zero = _mm_setzero_ps(); + sincosf4( radians.get128(), &s, &c ); + res0 = vec_sel( zero, c, select_x ); + res0 = vec_sel( res0, negatef4(s), select_z ); + res2 = vec_sel( zero, s, select_x ); + res2 = vec_sel( res2, c, select_z ); + return Matrix3( + Vector3( res0 ), + Vector3::yAxis( ), + Vector3( res2 ) + ); +} + +inline const Matrix3 Matrix3::rotationZ( float radians ) +{ + return rotationZ( floatInVec(radians) ); +} + +inline const Matrix3 Matrix3::rotationZ( const floatInVec &radians ) +{ + __m128 s, c, res0, res1; + __m128 zero; + __declspec(align(16)) unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; + __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; + zero = _mm_setzero_ps(); + sincosf4( radians.get128(), &s, &c ); + res0 = vec_sel( zero, c, select_x ); + res0 = vec_sel( res0, s, select_y ); + res1 = vec_sel( zero, negatef4(s), select_x ); + res1 = vec_sel( res1, c, select_y ); + return Matrix3( + Vector3( res0 ), + Vector3( res1 ), + Vector3::zAxis( ) + ); +} + +inline const Matrix3 Matrix3::rotationZYX( const Vector3 &radiansXYZ ) +{ + __m128 angles, s, negS, c, X0, X1, Y0, Y1, Z0, Z1, tmp; + angles = Vector4( radiansXYZ, 0.0f ).get128(); + sincosf4( angles, &s, &c ); + negS = negatef4( s ); + Z0 = vec_mergel( c, s ); + Z1 = vec_mergel( negS, c ); + __declspec(align(16)) unsigned int select_xyz[4] = {0xffffffff, 0xffffffff, 0xffffffff, 0}; + Z1 = vec_and( Z1, _mm_load_ps( (float *)select_xyz ) ); + Y0 = _mm_shuffle_ps( c, negS, _MM_SHUFFLE(0,1,1,1) ); + Y1 = _mm_shuffle_ps( s, c, _MM_SHUFFLE(0,1,1,1) ); + X0 = vec_splat( s, 0 ); + X1 = vec_splat( c, 0 ); + tmp = vec_mul( Z0, Y1 ); + return Matrix3( + Vector3( vec_mul( Z0, Y0 ) ), + Vector3( vec_madd( Z1, X1, vec_mul( tmp, X0 ) ) ), + Vector3( vec_nmsub( Z1, X0, vec_mul( tmp, X1 ) ) ) + ); +} + +inline const Matrix3 Matrix3::rotation( float radians, const Vector3 &unitVec ) +{ + return rotation( floatInVec(radians), unitVec ); +} + +inline const Matrix3 Matrix3::rotation( const floatInVec &radians, const Vector3 &unitVec ) +{ + __m128 axis, s, c, oneMinusC, axisS, negAxisS, xxxx, yyyy, zzzz, tmp0, tmp1, tmp2; + axis = unitVec.get128(); + sincosf4( radians.get128(), &s, &c ); + xxxx = vec_splat( axis, 0 ); + yyyy = vec_splat( axis, 1 ); + zzzz = vec_splat( axis, 2 ); + oneMinusC = vec_sub( _mm_set1_ps(1.0f), c ); + axisS = vec_mul( axis, s ); + negAxisS = negatef4( axisS ); + __declspec(align(16)) unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; + __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; + __declspec(align(16)) unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; + //tmp0 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_XZBX ); + tmp0 = _mm_shuffle_ps( axisS, axisS, _MM_SHUFFLE(0,0,2,0) ); + tmp0 = vec_sel(tmp0, vec_splat(negAxisS, 1), select_z); + //tmp1 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_CXXX ); + tmp1 = vec_sel( vec_splat(axisS, 0), vec_splat(negAxisS, 2), select_x ); + //tmp2 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_YAXX ); + tmp2 = _mm_shuffle_ps( axisS, axisS, _MM_SHUFFLE(0,0,0,1) ); + tmp2 = vec_sel(tmp2, vec_splat(negAxisS, 0), select_y); + tmp0 = vec_sel( tmp0, c, select_x ); + tmp1 = vec_sel( tmp1, c, select_y ); + tmp2 = vec_sel( tmp2, c, select_z ); + return Matrix3( + Vector3( vec_madd( vec_mul( axis, xxxx ), oneMinusC, tmp0 ) ), + Vector3( vec_madd( vec_mul( axis, yyyy ), oneMinusC, tmp1 ) ), + Vector3( vec_madd( vec_mul( axis, zzzz ), oneMinusC, tmp2 ) ) + ); +} + +inline const Matrix3 Matrix3::rotation( const Quat &unitQuat ) +{ + return Matrix3( unitQuat ); +} + +inline const Matrix3 Matrix3::scale( const Vector3 &scaleVec ) +{ + __m128 zero = _mm_setzero_ps(); + __declspec(align(16)) unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; + __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; + __declspec(align(16)) unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; + return Matrix3( + Vector3( vec_sel( zero, scaleVec.get128(), select_x ) ), + Vector3( vec_sel( zero, scaleVec.get128(), select_y ) ), + Vector3( vec_sel( zero, scaleVec.get128(), select_z ) ) + ); +} + +inline const Matrix3 appendScale( const Matrix3 & mat, const Vector3 &scaleVec ) +{ + return Matrix3( + ( mat.getCol0() * scaleVec.getX( ) ), + ( mat.getCol1() * scaleVec.getY( ) ), + ( mat.getCol2() * scaleVec.getZ( ) ) + ); +} + +inline const Matrix3 prependScale( const Vector3 &scaleVec, const Matrix3 & mat ) +{ + return Matrix3( + mulPerElem( mat.getCol0(), scaleVec ), + mulPerElem( mat.getCol1(), scaleVec ), + mulPerElem( mat.getCol2(), scaleVec ) + ); +} + +inline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, bool select1 ) +{ + return Matrix3( + select( mat0.getCol0(), mat1.getCol0(), select1 ), + select( mat0.getCol1(), mat1.getCol1(), select1 ), + select( mat0.getCol2(), mat1.getCol2(), select1 ) + ); +} + +inline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, const boolInVec &select1 ) +{ + return Matrix3( + select( mat0.getCol0(), mat1.getCol0(), select1 ), + select( mat0.getCol1(), mat1.getCol1(), select1 ), + select( mat0.getCol2(), mat1.getCol2(), select1 ) + ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( const Matrix3 & mat ) +{ + print( mat.getRow( 0 ) ); + print( mat.getRow( 1 ) ); + print( mat.getRow( 2 ) ); +} + +inline void print( const Matrix3 & mat, const char * name ) +{ + printf("%s:\n", name); + print( mat ); +} + +#endif + +inline Matrix4::Matrix4( const Matrix4 & mat ) +{ + mCol0 = mat.mCol0; + mCol1 = mat.mCol1; + mCol2 = mat.mCol2; + mCol3 = mat.mCol3; +} + +inline Matrix4::Matrix4( float scalar ) +{ + mCol0 = Vector4( scalar ); + mCol1 = Vector4( scalar ); + mCol2 = Vector4( scalar ); + mCol3 = Vector4( scalar ); +} + +inline Matrix4::Matrix4( const floatInVec &scalar ) +{ + mCol0 = Vector4( scalar ); + mCol1 = Vector4( scalar ); + mCol2 = Vector4( scalar ); + mCol3 = Vector4( scalar ); +} + +inline Matrix4::Matrix4( const Transform3 & mat ) +{ + mCol0 = Vector4( mat.getCol0(), 0.0f ); + mCol1 = Vector4( mat.getCol1(), 0.0f ); + mCol2 = Vector4( mat.getCol2(), 0.0f ); + mCol3 = Vector4( mat.getCol3(), 1.0f ); +} + +inline Matrix4::Matrix4( const Vector4 &_col0, const Vector4 &_col1, const Vector4 &_col2, const Vector4 &_col3 ) +{ + mCol0 = _col0; + mCol1 = _col1; + mCol2 = _col2; + mCol3 = _col3; +} + +inline Matrix4::Matrix4( const Matrix3 & mat, const Vector3 &translateVec ) +{ + mCol0 = Vector4( mat.getCol0(), 0.0f ); + mCol1 = Vector4( mat.getCol1(), 0.0f ); + mCol2 = Vector4( mat.getCol2(), 0.0f ); + mCol3 = Vector4( translateVec, 1.0f ); +} + +inline Matrix4::Matrix4( const Quat &unitQuat, const Vector3 &translateVec ) +{ + Matrix3 mat; + mat = Matrix3( unitQuat ); + mCol0 = Vector4( mat.getCol0(), 0.0f ); + mCol1 = Vector4( mat.getCol1(), 0.0f ); + mCol2 = Vector4( mat.getCol2(), 0.0f ); + mCol3 = Vector4( translateVec, 1.0f ); +} + +inline Matrix4 & Matrix4::setCol0( const Vector4 &_col0 ) +{ + mCol0 = _col0; + return *this; +} + +inline Matrix4 & Matrix4::setCol1( const Vector4 &_col1 ) +{ + mCol1 = _col1; + return *this; +} + +inline Matrix4 & Matrix4::setCol2( const Vector4 &_col2 ) +{ + mCol2 = _col2; + return *this; +} + +inline Matrix4 & Matrix4::setCol3( const Vector4 &_col3 ) +{ + mCol3 = _col3; + return *this; +} + +inline Matrix4 & Matrix4::setCol( int col, const Vector4 &vec ) +{ + *(&mCol0 + col) = vec; + return *this; +} + +inline Matrix4 & Matrix4::setRow( int row, const Vector4 &vec ) +{ + mCol0.setElem( row, vec.getElem( 0 ) ); + mCol1.setElem( row, vec.getElem( 1 ) ); + mCol2.setElem( row, vec.getElem( 2 ) ); + mCol3.setElem( row, vec.getElem( 3 ) ); + return *this; +} + +inline Matrix4 & Matrix4::setElem( int col, int row, float val ) +{ + (*this)[col].setElem(row, val); + return *this; +} + +inline Matrix4 & Matrix4::setElem( int col, int row, const floatInVec &val ) +{ + Vector4 tmpV3_0; + tmpV3_0 = this->getCol( col ); + tmpV3_0.setElem( row, val ); + this->setCol( col, tmpV3_0 ); + return *this; +} + +inline const floatInVec Matrix4::getElem( int col, int row ) const +{ + return this->getCol( col ).getElem( row ); +} + +inline const Vector4 Matrix4::getCol0( ) const +{ + return mCol0; +} + +inline const Vector4 Matrix4::getCol1( ) const +{ + return mCol1; +} + +inline const Vector4 Matrix4::getCol2( ) const +{ + return mCol2; +} + +inline const Vector4 Matrix4::getCol3( ) const +{ + return mCol3; +} + +inline const Vector4 Matrix4::getCol( int col ) const +{ + return *(&mCol0 + col); +} + +inline const Vector4 Matrix4::getRow( int row ) const +{ + return Vector4( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ), mCol3.getElem( row ) ); +} + +inline Vector4 & Matrix4::operator []( int col ) +{ + return *(&mCol0 + col); +} + +inline const Vector4 Matrix4::operator []( int col ) const +{ + return *(&mCol0 + col); +} + +inline Matrix4 & Matrix4::operator =( const Matrix4 & mat ) +{ + mCol0 = mat.mCol0; + mCol1 = mat.mCol1; + mCol2 = mat.mCol2; + mCol3 = mat.mCol3; + return *this; +} + +inline const Matrix4 transpose( const Matrix4 & mat ) +{ + __m128 tmp0, tmp1, tmp2, tmp3, res0, res1, res2, res3; + tmp0 = vec_mergeh( mat.getCol0().get128(), mat.getCol2().get128() ); + tmp1 = vec_mergeh( mat.getCol1().get128(), mat.getCol3().get128() ); + tmp2 = vec_mergel( mat.getCol0().get128(), mat.getCol2().get128() ); + tmp3 = vec_mergel( mat.getCol1().get128(), mat.getCol3().get128() ); + res0 = vec_mergeh( tmp0, tmp1 ); + res1 = vec_mergel( tmp0, tmp1 ); + res2 = vec_mergeh( tmp2, tmp3 ); + res3 = vec_mergel( tmp2, tmp3 ); + return Matrix4( + Vector4( res0 ), + Vector4( res1 ), + Vector4( res2 ), + Vector4( res3 ) + ); +} + +// TODO: Tidy +static __declspec(align(16)) const unsigned int _vmathPNPN[4] = {0x00000000, 0x80000000, 0x00000000, 0x80000000}; +static __declspec(align(16)) const unsigned int _vmathNPNP[4] = {0x80000000, 0x00000000, 0x80000000, 0x00000000}; +static __declspec(align(16)) const float _vmathZERONE[4] = {1.0f, 0.0f, 0.0f, 1.0f}; + +inline const Matrix4 inverse( const Matrix4 & mat ) +{ + __m128 Va,Vb,Vc; + __m128 r1,r2,r3,tt,tt2; + __m128 sum,Det,RDet; + __m128 trns0,trns1,trns2,trns3; + + __m128 _L1 = mat.getCol0().get128(); + __m128 _L2 = mat.getCol1().get128(); + __m128 _L3 = mat.getCol2().get128(); + __m128 _L4 = mat.getCol3().get128(); + // Calculating the minterms for the first line. + + // _mm_ror_ps is just a macro using _mm_shuffle_ps(). + tt = _L4; tt2 = _mm_ror_ps(_L3,1); + Vc = _mm_mul_ps(tt2,_mm_ror_ps(tt,0)); // V3'V4 + Va = _mm_mul_ps(tt2,_mm_ror_ps(tt,2)); // V3'V4" + Vb = _mm_mul_ps(tt2,_mm_ror_ps(tt,3)); // V3'V4^ + + r1 = _mm_sub_ps(_mm_ror_ps(Va,1),_mm_ror_ps(Vc,2)); // V3"V4^ - V3^V4" + r2 = _mm_sub_ps(_mm_ror_ps(Vb,2),_mm_ror_ps(Vb,0)); // V3^V4' - V3'V4^ + r3 = _mm_sub_ps(_mm_ror_ps(Va,0),_mm_ror_ps(Vc,1)); // V3'V4" - V3"V4' + + tt = _L2; + Va = _mm_ror_ps(tt,1); sum = _mm_mul_ps(Va,r1); + Vb = _mm_ror_ps(tt,2); sum = _mm_add_ps(sum,_mm_mul_ps(Vb,r2)); + Vc = _mm_ror_ps(tt,3); sum = _mm_add_ps(sum,_mm_mul_ps(Vc,r3)); + + // Calculating the determinant. + Det = _mm_mul_ps(sum,_L1); + Det = _mm_add_ps(Det,_mm_movehl_ps(Det,Det)); + + const __m128 Sign_PNPN = _mm_load_ps((float *)_vmathPNPN); + const __m128 Sign_NPNP = _mm_load_ps((float *)_vmathNPNP); + + __m128 mtL1 = _mm_xor_ps(sum,Sign_PNPN); + + // Calculating the minterms of the second line (using previous results). + tt = _mm_ror_ps(_L1,1); sum = _mm_mul_ps(tt,r1); + tt = _mm_ror_ps(tt,1); sum = _mm_add_ps(sum,_mm_mul_ps(tt,r2)); + tt = _mm_ror_ps(tt,1); sum = _mm_add_ps(sum,_mm_mul_ps(tt,r3)); + __m128 mtL2 = _mm_xor_ps(sum,Sign_NPNP); + + // Testing the determinant. + Det = _mm_sub_ss(Det,_mm_shuffle_ps(Det,Det,1)); + + // Calculating the minterms of the third line. + tt = _mm_ror_ps(_L1,1); + Va = _mm_mul_ps(tt,Vb); // V1'V2" + Vb = _mm_mul_ps(tt,Vc); // V1'V2^ + Vc = _mm_mul_ps(tt,_L2); // V1'V2 + + r1 = _mm_sub_ps(_mm_ror_ps(Va,1),_mm_ror_ps(Vc,2)); // V1"V2^ - V1^V2" + r2 = _mm_sub_ps(_mm_ror_ps(Vb,2),_mm_ror_ps(Vb,0)); // V1^V2' - V1'V2^ + r3 = _mm_sub_ps(_mm_ror_ps(Va,0),_mm_ror_ps(Vc,1)); // V1'V2" - V1"V2' + + tt = _mm_ror_ps(_L4,1); sum = _mm_mul_ps(tt,r1); + tt = _mm_ror_ps(tt,1); sum = _mm_add_ps(sum,_mm_mul_ps(tt,r2)); + tt = _mm_ror_ps(tt,1); sum = _mm_add_ps(sum,_mm_mul_ps(tt,r3)); + __m128 mtL3 = _mm_xor_ps(sum,Sign_PNPN); + + // Dividing is FASTER than rcp_nr! (Because rcp_nr causes many register-memory RWs). + RDet = _mm_div_ss(_mm_load_ss((float *)&_vmathZERONE), Det); // TODO: just 1.0f? + RDet = _mm_shuffle_ps(RDet,RDet,0x00); + + // Devide the first 12 minterms with the determinant. + mtL1 = _mm_mul_ps(mtL1, RDet); + mtL2 = _mm_mul_ps(mtL2, RDet); + mtL3 = _mm_mul_ps(mtL3, RDet); + + // Calculate the minterms of the forth line and devide by the determinant. + tt = _mm_ror_ps(_L3,1); sum = _mm_mul_ps(tt,r1); + tt = _mm_ror_ps(tt,1); sum = _mm_add_ps(sum,_mm_mul_ps(tt,r2)); + tt = _mm_ror_ps(tt,1); sum = _mm_add_ps(sum,_mm_mul_ps(tt,r3)); + __m128 mtL4 = _mm_xor_ps(sum,Sign_NPNP); + mtL4 = _mm_mul_ps(mtL4, RDet); + + // Now we just have to transpose the minterms matrix. + trns0 = _mm_unpacklo_ps(mtL1,mtL2); + trns1 = _mm_unpacklo_ps(mtL3,mtL4); + trns2 = _mm_unpackhi_ps(mtL1,mtL2); + trns3 = _mm_unpackhi_ps(mtL3,mtL4); + _L1 = _mm_movelh_ps(trns0,trns1); + _L2 = _mm_movehl_ps(trns1,trns0); + _L3 = _mm_movelh_ps(trns2,trns3); + _L4 = _mm_movehl_ps(trns3,trns2); + + return Matrix4( + Vector4( _L1 ), + Vector4( _L2 ), + Vector4( _L3 ), + Vector4( _L4 ) + ); +} + +inline const Matrix4 affineInverse( const Matrix4 & mat ) +{ + Transform3 affineMat; + affineMat.setCol0( mat.getCol0().getXYZ( ) ); + affineMat.setCol1( mat.getCol1().getXYZ( ) ); + affineMat.setCol2( mat.getCol2().getXYZ( ) ); + affineMat.setCol3( mat.getCol3().getXYZ( ) ); + return Matrix4( inverse( affineMat ) ); +} + +inline const Matrix4 orthoInverse( const Matrix4 & mat ) +{ + Transform3 affineMat; + affineMat.setCol0( mat.getCol0().getXYZ( ) ); + affineMat.setCol1( mat.getCol1().getXYZ( ) ); + affineMat.setCol2( mat.getCol2().getXYZ( ) ); + affineMat.setCol3( mat.getCol3().getXYZ( ) ); + return Matrix4( orthoInverse( affineMat ) ); +} + +inline const floatInVec determinant( const Matrix4 & mat ) +{ + __m128 Va,Vb,Vc; + __m128 r1,r2,r3,tt,tt2; + __m128 sum,Det; + + __m128 _L1 = mat.getCol0().get128(); + __m128 _L2 = mat.getCol1().get128(); + __m128 _L3 = mat.getCol2().get128(); + __m128 _L4 = mat.getCol3().get128(); + // Calculating the minterms for the first line. + + // _mm_ror_ps is just a macro using _mm_shuffle_ps(). + tt = _L4; tt2 = _mm_ror_ps(_L3,1); + Vc = _mm_mul_ps(tt2,_mm_ror_ps(tt,0)); // V3'V4 + Va = _mm_mul_ps(tt2,_mm_ror_ps(tt,2)); // V3'V4" + Vb = _mm_mul_ps(tt2,_mm_ror_ps(tt,3)); // V3'V4^ + + r1 = _mm_sub_ps(_mm_ror_ps(Va,1),_mm_ror_ps(Vc,2)); // V3"V4^ - V3^V4" + r2 = _mm_sub_ps(_mm_ror_ps(Vb,2),_mm_ror_ps(Vb,0)); // V3^V4' - V3'V4^ + r3 = _mm_sub_ps(_mm_ror_ps(Va,0),_mm_ror_ps(Vc,1)); // V3'V4" - V3"V4' + + tt = _L2; + Va = _mm_ror_ps(tt,1); sum = _mm_mul_ps(Va,r1); + Vb = _mm_ror_ps(tt,2); sum = _mm_add_ps(sum,_mm_mul_ps(Vb,r2)); + Vc = _mm_ror_ps(tt,3); sum = _mm_add_ps(sum,_mm_mul_ps(Vc,r3)); + + // Calculating the determinant. + Det = _mm_mul_ps(sum,_L1); + Det = _mm_add_ps(Det,_mm_movehl_ps(Det,Det)); + + // Calculating the minterms of the second line (using previous results). + tt = _mm_ror_ps(_L1,1); sum = _mm_mul_ps(tt,r1); + tt = _mm_ror_ps(tt,1); sum = _mm_add_ps(sum,_mm_mul_ps(tt,r2)); + tt = _mm_ror_ps(tt,1); sum = _mm_add_ps(sum,_mm_mul_ps(tt,r3)); + + // Testing the determinant. + Det = _mm_sub_ss(Det,_mm_shuffle_ps(Det,Det,1)); + return floatInVec(Det, 0); +} + +inline const Matrix4 Matrix4::operator +( const Matrix4 & mat ) const +{ + return Matrix4( + ( mCol0 + mat.mCol0 ), + ( mCol1 + mat.mCol1 ), + ( mCol2 + mat.mCol2 ), + ( mCol3 + mat.mCol3 ) + ); +} + +inline const Matrix4 Matrix4::operator -( const Matrix4 & mat ) const +{ + return Matrix4( + ( mCol0 - mat.mCol0 ), + ( mCol1 - mat.mCol1 ), + ( mCol2 - mat.mCol2 ), + ( mCol3 - mat.mCol3 ) + ); +} + +inline Matrix4 & Matrix4::operator +=( const Matrix4 & mat ) +{ + *this = *this + mat; + return *this; +} + +inline Matrix4 & Matrix4::operator -=( const Matrix4 & mat ) +{ + *this = *this - mat; + return *this; +} + +inline const Matrix4 Matrix4::operator -( ) const +{ + return Matrix4( + ( -mCol0 ), + ( -mCol1 ), + ( -mCol2 ), + ( -mCol3 ) + ); +} + +inline const Matrix4 absPerElem( const Matrix4 & mat ) +{ + return Matrix4( + absPerElem( mat.getCol0() ), + absPerElem( mat.getCol1() ), + absPerElem( mat.getCol2() ), + absPerElem( mat.getCol3() ) + ); +} + +inline const Matrix4 Matrix4::operator *( float scalar ) const +{ + return *this * floatInVec(scalar); +} + +inline const Matrix4 Matrix4::operator *( const floatInVec &scalar ) const +{ + return Matrix4( + ( mCol0 * scalar ), + ( mCol1 * scalar ), + ( mCol2 * scalar ), + ( mCol3 * scalar ) + ); +} + +inline Matrix4 & Matrix4::operator *=( float scalar ) +{ + return *this *= floatInVec(scalar); +} + +inline Matrix4 & Matrix4::operator *=( const floatInVec &scalar ) +{ + *this = *this * scalar; + return *this; +} + +inline const Matrix4 operator *( float scalar, const Matrix4 & mat ) +{ + return floatInVec(scalar) * mat; +} + +inline const Matrix4 operator *( const floatInVec &scalar, const Matrix4 & mat ) +{ + return mat * scalar; +} + +inline const Vector4 Matrix4::operator *( const Vector4 &vec ) const +{ + return Vector4( + _mm_add_ps( + _mm_add_ps(_mm_mul_ps(mCol0.get128(), _mm_shuffle_ps(vec.get128(), vec.get128(), _MM_SHUFFLE(0,0,0,0))), _mm_mul_ps(mCol1.get128(), _mm_shuffle_ps(vec.get128(), vec.get128(), _MM_SHUFFLE(1,1,1,1)))), + _mm_add_ps(_mm_mul_ps(mCol2.get128(), _mm_shuffle_ps(vec.get128(), vec.get128(), _MM_SHUFFLE(2,2,2,2))), _mm_mul_ps(mCol3.get128(), _mm_shuffle_ps(vec.get128(), vec.get128(), _MM_SHUFFLE(3,3,3,3))))) + ); +} + +inline const Vector4 Matrix4::operator *( const Vector3 &vec ) const +{ + return Vector4( + _mm_add_ps( + _mm_add_ps(_mm_mul_ps(mCol0.get128(), _mm_shuffle_ps(vec.get128(), vec.get128(), _MM_SHUFFLE(0,0,0,0))), _mm_mul_ps(mCol1.get128(), _mm_shuffle_ps(vec.get128(), vec.get128(), _MM_SHUFFLE(1,1,1,1)))), + _mm_mul_ps(mCol2.get128(), _mm_shuffle_ps(vec.get128(), vec.get128(), _MM_SHUFFLE(2,2,2,2)))) + ); +} + +inline const Vector4 Matrix4::operator *( const Point3 &pnt ) const +{ + return Vector4( + _mm_add_ps( + _mm_add_ps(_mm_mul_ps(mCol0.get128(), _mm_shuffle_ps(pnt.get128(), pnt.get128(), _MM_SHUFFLE(0,0,0,0))), _mm_mul_ps(mCol1.get128(), _mm_shuffle_ps(pnt.get128(), pnt.get128(), _MM_SHUFFLE(1,1,1,1)))), + _mm_add_ps(_mm_mul_ps(mCol2.get128(), _mm_shuffle_ps(pnt.get128(), pnt.get128(), _MM_SHUFFLE(2,2,2,2))), mCol3.get128())) + ); +} + +inline const Matrix4 Matrix4::operator *( const Matrix4 & mat ) const +{ + return Matrix4( + ( *this * mat.mCol0 ), + ( *this * mat.mCol1 ), + ( *this * mat.mCol2 ), + ( *this * mat.mCol3 ) + ); +} + +inline Matrix4 & Matrix4::operator *=( const Matrix4 & mat ) +{ + *this = *this * mat; + return *this; +} + +inline const Matrix4 Matrix4::operator *( const Transform3 & tfrm ) const +{ + return Matrix4( + ( *this * tfrm.getCol0() ), + ( *this * tfrm.getCol1() ), + ( *this * tfrm.getCol2() ), + ( *this * Point3( tfrm.getCol3() ) ) + ); +} + +inline Matrix4 & Matrix4::operator *=( const Transform3 & tfrm ) +{ + *this = *this * tfrm; + return *this; +} + +inline const Matrix4 mulPerElem( const Matrix4 & mat0, const Matrix4 & mat1 ) +{ + return Matrix4( + mulPerElem( mat0.getCol0(), mat1.getCol0() ), + mulPerElem( mat0.getCol1(), mat1.getCol1() ), + mulPerElem( mat0.getCol2(), mat1.getCol2() ), + mulPerElem( mat0.getCol3(), mat1.getCol3() ) + ); +} + +inline const Matrix4 Matrix4::identity( ) +{ + return Matrix4( + Vector4::xAxis( ), + Vector4::yAxis( ), + Vector4::zAxis( ), + Vector4::wAxis( ) + ); +} + +inline Matrix4 & Matrix4::setUpper3x3( const Matrix3 & mat3 ) +{ + mCol0.setXYZ( mat3.getCol0() ); + mCol1.setXYZ( mat3.getCol1() ); + mCol2.setXYZ( mat3.getCol2() ); + return *this; +} + +inline const Matrix3 Matrix4::getUpper3x3( ) const +{ + return Matrix3( + mCol0.getXYZ( ), + mCol1.getXYZ( ), + mCol2.getXYZ( ) + ); +} + +inline Matrix4 & Matrix4::setTranslation( const Vector3 &translateVec ) +{ + mCol3.setXYZ( translateVec ); + return *this; +} + +inline const Vector3 Matrix4::getTranslation( ) const +{ + return mCol3.getXYZ( ); +} + +inline const Matrix4 Matrix4::rotationX( float radians ) +{ + return rotationX( floatInVec(radians) ); +} + +inline const Matrix4 Matrix4::rotationX( const floatInVec &radians ) +{ + __m128 s, c, res1, res2; + __m128 zero; + __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; + __declspec(align(16)) unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; + zero = _mm_setzero_ps(); + sincosf4( radians.get128(), &s, &c ); + res1 = vec_sel( zero, c, select_y ); + res1 = vec_sel( res1, s, select_z ); + res2 = vec_sel( zero, negatef4(s), select_y ); + res2 = vec_sel( res2, c, select_z ); + return Matrix4( + Vector4::xAxis( ), + Vector4( res1 ), + Vector4( res2 ), + Vector4::wAxis( ) + ); +} + +inline const Matrix4 Matrix4::rotationY( float radians ) +{ + return rotationY( floatInVec(radians) ); +} + +inline const Matrix4 Matrix4::rotationY( const floatInVec &radians ) +{ + __m128 s, c, res0, res2; + __m128 zero; + __declspec(align(16)) unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; + __declspec(align(16)) unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; + zero = _mm_setzero_ps(); + sincosf4( radians.get128(), &s, &c ); + res0 = vec_sel( zero, c, select_x ); + res0 = vec_sel( res0, negatef4(s), select_z ); + res2 = vec_sel( zero, s, select_x ); + res2 = vec_sel( res2, c, select_z ); + return Matrix4( + Vector4( res0 ), + Vector4::yAxis( ), + Vector4( res2 ), + Vector4::wAxis( ) + ); +} + +inline const Matrix4 Matrix4::rotationZ( float radians ) +{ + return rotationZ( floatInVec(radians) ); +} + +inline const Matrix4 Matrix4::rotationZ( const floatInVec &radians ) +{ + __m128 s, c, res0, res1; + __m128 zero; + __declspec(align(16)) unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; + __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; + zero = _mm_setzero_ps(); + sincosf4( radians.get128(), &s, &c ); + res0 = vec_sel( zero, c, select_x ); + res0 = vec_sel( res0, s, select_y ); + res1 = vec_sel( zero, negatef4(s), select_x ); + res1 = vec_sel( res1, c, select_y ); + return Matrix4( + Vector4( res0 ), + Vector4( res1 ), + Vector4::zAxis( ), + Vector4::wAxis( ) + ); +} + +inline const Matrix4 Matrix4::rotationZYX( const Vector3 &radiansXYZ ) +{ + __m128 angles, s, negS, c, X0, X1, Y0, Y1, Z0, Z1, tmp; + angles = Vector4( radiansXYZ, 0.0f ).get128(); + sincosf4( angles, &s, &c ); + negS = negatef4( s ); + Z0 = vec_mergel( c, s ); + Z1 = vec_mergel( negS, c ); + __declspec(align(16)) unsigned int select_xyz[4] = {0xffffffff, 0xffffffff, 0xffffffff, 0}; + Z1 = vec_and( Z1, _mm_load_ps( (float *)select_xyz ) ); + Y0 = _mm_shuffle_ps( c, negS, _MM_SHUFFLE(0,1,1,1) ); + Y1 = _mm_shuffle_ps( s, c, _MM_SHUFFLE(0,1,1,1) ); + X0 = vec_splat( s, 0 ); + X1 = vec_splat( c, 0 ); + tmp = vec_mul( Z0, Y1 ); + return Matrix4( + Vector4( vec_mul( Z0, Y0 ) ), + Vector4( vec_madd( Z1, X1, vec_mul( tmp, X0 ) ) ), + Vector4( vec_nmsub( Z1, X0, vec_mul( tmp, X1 ) ) ), + Vector4::wAxis( ) + ); +} + +inline const Matrix4 Matrix4::rotation( float radians, const Vector3 &unitVec ) +{ + return rotation( floatInVec(radians), unitVec ); +} + +inline const Matrix4 Matrix4::rotation( const floatInVec &radians, const Vector3 &unitVec ) +{ + __m128 axis, s, c, oneMinusC, axisS, negAxisS, xxxx, yyyy, zzzz, tmp0, tmp1, tmp2; + axis = unitVec.get128(); + sincosf4( radians.get128(), &s, &c ); + xxxx = vec_splat( axis, 0 ); + yyyy = vec_splat( axis, 1 ); + zzzz = vec_splat( axis, 2 ); + oneMinusC = vec_sub( _mm_set1_ps(1.0f), c ); + axisS = vec_mul( axis, s ); + negAxisS = negatef4( axisS ); + __declspec(align(16)) unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; + __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; + __declspec(align(16)) unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; + //tmp0 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_XZBX ); + tmp0 = _mm_shuffle_ps( axisS, axisS, _MM_SHUFFLE(0,0,2,0) ); + tmp0 = vec_sel(tmp0, vec_splat(negAxisS, 1), select_z); + //tmp1 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_CXXX ); + tmp1 = vec_sel( vec_splat(axisS, 0), vec_splat(negAxisS, 2), select_x ); + //tmp2 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_YAXX ); + tmp2 = _mm_shuffle_ps( axisS, axisS, _MM_SHUFFLE(0,0,0,1) ); + tmp2 = vec_sel(tmp2, vec_splat(negAxisS, 0), select_y); + tmp0 = vec_sel( tmp0, c, select_x ); + tmp1 = vec_sel( tmp1, c, select_y ); + tmp2 = vec_sel( tmp2, c, select_z ); + __declspec(align(16)) unsigned int select_xyz[4] = {0xffffffff, 0xffffffff, 0xffffffff, 0}; + axis = vec_and( axis, _mm_load_ps( (float *)select_xyz ) ); + tmp0 = vec_and( tmp0, _mm_load_ps( (float *)select_xyz ) ); + tmp1 = vec_and( tmp1, _mm_load_ps( (float *)select_xyz ) ); + tmp2 = vec_and( tmp2, _mm_load_ps( (float *)select_xyz ) ); + return Matrix4( + Vector4( vec_madd( vec_mul( axis, xxxx ), oneMinusC, tmp0 ) ), + Vector4( vec_madd( vec_mul( axis, yyyy ), oneMinusC, tmp1 ) ), + Vector4( vec_madd( vec_mul( axis, zzzz ), oneMinusC, tmp2 ) ), + Vector4::wAxis( ) + ); +} + +inline const Matrix4 Matrix4::rotation( const Quat &unitQuat ) +{ + return Matrix4( Transform3::rotation( unitQuat ) ); +} + +inline const Matrix4 Matrix4::scale( const Vector3 &scaleVec ) +{ + __m128 zero = _mm_setzero_ps(); + __declspec(align(16)) unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; + __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; + __declspec(align(16)) unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; + return Matrix4( + Vector4( vec_sel( zero, scaleVec.get128(), select_x ) ), + Vector4( vec_sel( zero, scaleVec.get128(), select_y ) ), + Vector4( vec_sel( zero, scaleVec.get128(), select_z ) ), + Vector4::wAxis( ) + ); +} + +inline const Matrix4 appendScale( const Matrix4 & mat, const Vector3 &scaleVec ) +{ + return Matrix4( + ( mat.getCol0() * scaleVec.getX( ) ), + ( mat.getCol1() * scaleVec.getY( ) ), + ( mat.getCol2() * scaleVec.getZ( ) ), + mat.getCol3() + ); +} + +inline const Matrix4 prependScale( const Vector3 &scaleVec, const Matrix4 & mat ) +{ + Vector4 scale4; + scale4 = Vector4( scaleVec, 1.0f ); + return Matrix4( + mulPerElem( mat.getCol0(), scale4 ), + mulPerElem( mat.getCol1(), scale4 ), + mulPerElem( mat.getCol2(), scale4 ), + mulPerElem( mat.getCol3(), scale4 ) + ); +} + +inline const Matrix4 Matrix4::translation( const Vector3 &translateVec ) +{ + return Matrix4( + Vector4::xAxis( ), + Vector4::yAxis( ), + Vector4::zAxis( ), + Vector4( translateVec, 1.0f ) + ); +} + +inline const Matrix4 Matrix4::lookAt( const Point3 &eyePos, const Point3 &lookAtPos, const Vector3 &upVec ) +{ + Matrix4 m4EyeFrame; + Vector3 v3X, v3Y, v3Z; + v3Y = normalize( upVec ); + v3Z = normalize( ( eyePos - lookAtPos ) ); + v3X = normalize( cross( v3Y, v3Z ) ); + v3Y = cross( v3Z, v3X ); + m4EyeFrame = Matrix4( Vector4( v3X ), Vector4( v3Y ), Vector4( v3Z ), Vector4( eyePos ) ); + return orthoInverse( m4EyeFrame ); +} + +inline const Matrix4 Matrix4::perspective( float fovyRadians, float aspect, float zNear, float zFar ) +{ + float f, rangeInv; + __m128 zero, col0, col1, col2, col3; + union { __m128 v; float s[4]; } tmp; + f = tanf( _VECTORMATH_PI_OVER_2 - fovyRadians * 0.5f ); + rangeInv = 1.0f / ( zNear - zFar ); + zero = _mm_setzero_ps(); + tmp.v = zero; + tmp.s[0] = f / aspect; + col0 = tmp.v; + tmp.v = zero; + tmp.s[1] = f; + col1 = tmp.v; + tmp.v = zero; + tmp.s[2] = ( zNear + zFar ) * rangeInv; + tmp.s[3] = -1.0f; + col2 = tmp.v; + tmp.v = zero; + tmp.s[2] = zNear * zFar * rangeInv * 2.0f; + col3 = tmp.v; + return Matrix4( + Vector4( col0 ), + Vector4( col1 ), + Vector4( col2 ), + Vector4( col3 ) + ); +} + +inline const Matrix4 Matrix4::frustum( float left, float right, float bottom, float top, float zNear, float zFar ) +{ + /* function implementation based on code from STIDC SDK: */ + /* -------------------------------------------------------------- */ + /* PLEASE DO NOT MODIFY THIS SECTION */ + /* This prolog section is automatically generated. */ + /* */ + /* (C)Copyright */ + /* Sony Computer Entertainment, Inc., */ + /* Toshiba Corporation, */ + /* International Business Machines Corporation, */ + /* 2001,2002. */ + /* S/T/I Confidential Information */ + /* -------------------------------------------------------------- */ + __m128 lbf, rtn; + __m128 diff, sum, inv_diff; + __m128 diagonal, column, near2; + __m128 zero = _mm_setzero_ps(); + union { __m128 v; float s[4]; } l, f, r, n, b, t; // TODO: Union? + l.s[0] = left; + f.s[0] = zFar; + r.s[0] = right; + n.s[0] = zNear; + b.s[0] = bottom; + t.s[0] = top; + lbf = vec_mergeh( l.v, f.v ); + rtn = vec_mergeh( r.v, n.v ); + lbf = vec_mergeh( lbf, b.v ); + rtn = vec_mergeh( rtn, t.v ); + diff = vec_sub( rtn, lbf ); + sum = vec_add( rtn, lbf ); + inv_diff = recipf4( diff ); + near2 = vec_splat( n.v, 0 ); + near2 = vec_add( near2, near2 ); + diagonal = vec_mul( near2, inv_diff ); + column = vec_mul( sum, inv_diff ); + __declspec(align(16)) unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; + __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; + __declspec(align(16)) unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; + __declspec(align(16)) unsigned int select_w[4] = {0, 0, 0, 0xffffffff}; + return Matrix4( + Vector4( vec_sel( zero, diagonal, select_x ) ), + Vector4( vec_sel( zero, diagonal, select_y ) ), + Vector4( vec_sel( column, _mm_set1_ps(-1.0f), select_w ) ), + Vector4( vec_sel( zero, vec_mul( diagonal, vec_splat( f.v, 0 ) ), select_z ) ) + ); +} + +inline const Matrix4 Matrix4::orthographic( float left, float right, float bottom, float top, float zNear, float zFar ) +{ + /* function implementation based on code from STIDC SDK: */ + /* -------------------------------------------------------------- */ + /* PLEASE DO NOT MODIFY THIS SECTION */ + /* This prolog section is automatically generated. */ + /* */ + /* (C)Copyright */ + /* Sony Computer Entertainment, Inc., */ + /* Toshiba Corporation, */ + /* International Business Machines Corporation, */ + /* 2001,2002. */ + /* S/T/I Confidential Information */ + /* -------------------------------------------------------------- */ + __m128 lbf, rtn; + __m128 diff, sum, inv_diff, neg_inv_diff; + __m128 diagonal, column; + __m128 zero = _mm_setzero_ps(); + union { __m128 v; float s[4]; } l, f, r, n, b, t; + l.s[0] = left; + f.s[0] = zFar; + r.s[0] = right; + n.s[0] = zNear; + b.s[0] = bottom; + t.s[0] = top; + lbf = vec_mergeh( l.v, f.v ); + rtn = vec_mergeh( r.v, n.v ); + lbf = vec_mergeh( lbf, b.v ); + rtn = vec_mergeh( rtn, t.v ); + diff = vec_sub( rtn, lbf ); + sum = vec_add( rtn, lbf ); + inv_diff = recipf4( diff ); + neg_inv_diff = negatef4( inv_diff ); + diagonal = vec_add( inv_diff, inv_diff ); + __declspec(align(16)) unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; + __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; + __declspec(align(16)) unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; + __declspec(align(16)) unsigned int select_w[4] = {0, 0, 0, 0xffffffff}; + column = vec_mul( sum, vec_sel( neg_inv_diff, inv_diff, select_z ) ); // TODO: no madds with zero + return Matrix4( + Vector4( vec_sel( zero, diagonal, select_x ) ), + Vector4( vec_sel( zero, diagonal, select_y ) ), + Vector4( vec_sel( zero, diagonal, select_z ) ), + Vector4( vec_sel( column, _mm_set1_ps(1.0f), select_w ) ) + ); +} + +inline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, bool select1 ) +{ + return Matrix4( + select( mat0.getCol0(), mat1.getCol0(), select1 ), + select( mat0.getCol1(), mat1.getCol1(), select1 ), + select( mat0.getCol2(), mat1.getCol2(), select1 ), + select( mat0.getCol3(), mat1.getCol3(), select1 ) + ); +} + +inline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, const boolInVec &select1 ) +{ + return Matrix4( + select( mat0.getCol0(), mat1.getCol0(), select1 ), + select( mat0.getCol1(), mat1.getCol1(), select1 ), + select( mat0.getCol2(), mat1.getCol2(), select1 ), + select( mat0.getCol3(), mat1.getCol3(), select1 ) + ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( const Matrix4 & mat ) +{ + print( mat.getRow( 0 ) ); + print( mat.getRow( 1 ) ); + print( mat.getRow( 2 ) ); + print( mat.getRow( 3 ) ); +} + +inline void print( const Matrix4 & mat, const char * name ) +{ + printf("%s:\n", name); + print( mat ); +} + +#endif + +inline Transform3::Transform3( const Transform3 & tfrm ) +{ + mCol0 = tfrm.mCol0; + mCol1 = tfrm.mCol1; + mCol2 = tfrm.mCol2; + mCol3 = tfrm.mCol3; +} + +inline Transform3::Transform3( float scalar ) +{ + mCol0 = Vector3( scalar ); + mCol1 = Vector3( scalar ); + mCol2 = Vector3( scalar ); + mCol3 = Vector3( scalar ); +} + +inline Transform3::Transform3( const floatInVec &scalar ) +{ + mCol0 = Vector3( scalar ); + mCol1 = Vector3( scalar ); + mCol2 = Vector3( scalar ); + mCol3 = Vector3( scalar ); +} + +inline Transform3::Transform3( const Vector3 &_col0, const Vector3 &_col1, const Vector3 &_col2, const Vector3 &_col3 ) +{ + mCol0 = _col0; + mCol1 = _col1; + mCol2 = _col2; + mCol3 = _col3; +} + +inline Transform3::Transform3( const Matrix3 & tfrm, const Vector3 &translateVec ) +{ + this->setUpper3x3( tfrm ); + this->setTranslation( translateVec ); +} + +inline Transform3::Transform3( const Quat &unitQuat, const Vector3 &translateVec ) +{ + this->setUpper3x3( Matrix3( unitQuat ) ); + this->setTranslation( translateVec ); +} + +inline Transform3 & Transform3::setCol0( const Vector3 &_col0 ) +{ + mCol0 = _col0; + return *this; +} + +inline Transform3 & Transform3::setCol1( const Vector3 &_col1 ) +{ + mCol1 = _col1; + return *this; +} + +inline Transform3 & Transform3::setCol2( const Vector3 &_col2 ) +{ + mCol2 = _col2; + return *this; +} + +inline Transform3 & Transform3::setCol3( const Vector3 &_col3 ) +{ + mCol3 = _col3; + return *this; +} + +inline Transform3 & Transform3::setCol( int col, const Vector3 &vec ) +{ + *(&mCol0 + col) = vec; + return *this; +} + +inline Transform3 & Transform3::setRow( int row, const Vector4 &vec ) +{ + mCol0.setElem( row, vec.getElem( 0 ) ); + mCol1.setElem( row, vec.getElem( 1 ) ); + mCol2.setElem( row, vec.getElem( 2 ) ); + mCol3.setElem( row, vec.getElem( 3 ) ); + return *this; +} + +inline Transform3 & Transform3::setElem( int col, int row, float val ) +{ + (*this)[col].setElem(row, val); + return *this; +} + +inline Transform3 & Transform3::setElem( int col, int row, const floatInVec &val ) +{ + Vector3 tmpV3_0; + tmpV3_0 = this->getCol( col ); + tmpV3_0.setElem( row, val ); + this->setCol( col, tmpV3_0 ); + return *this; +} + +inline const floatInVec Transform3::getElem( int col, int row ) const +{ + return this->getCol( col ).getElem( row ); +} + +inline const Vector3 Transform3::getCol0( ) const +{ + return mCol0; +} + +inline const Vector3 Transform3::getCol1( ) const +{ + return mCol1; +} + +inline const Vector3 Transform3::getCol2( ) const +{ + return mCol2; +} + +inline const Vector3 Transform3::getCol3( ) const +{ + return mCol3; +} + +inline const Vector3 Transform3::getCol( int col ) const +{ + return *(&mCol0 + col); +} + +inline const Vector4 Transform3::getRow( int row ) const +{ + return Vector4( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ), mCol3.getElem( row ) ); +} + +inline Vector3 & Transform3::operator []( int col ) +{ + return *(&mCol0 + col); +} + +inline const Vector3 Transform3::operator []( int col ) const +{ + return *(&mCol0 + col); +} + +inline Transform3 & Transform3::operator =( const Transform3 & tfrm ) +{ + mCol0 = tfrm.mCol0; + mCol1 = tfrm.mCol1; + mCol2 = tfrm.mCol2; + mCol3 = tfrm.mCol3; + return *this; +} + +inline const Transform3 inverse( const Transform3 & tfrm ) +{ + __m128 inv0, inv1, inv2, inv3; + __m128 tmp0, tmp1, tmp2, tmp3, tmp4, dot, invdet; + __m128 xxxx, yyyy, zzzz; + tmp2 = _vmathVfCross( tfrm.getCol0().get128(), tfrm.getCol1().get128() ); + tmp0 = _vmathVfCross( tfrm.getCol1().get128(), tfrm.getCol2().get128() ); + tmp1 = _vmathVfCross( tfrm.getCol2().get128(), tfrm.getCol0().get128() ); + inv3 = negatef4( tfrm.getCol3().get128() ); + dot = _vmathVfDot3( tmp2, tfrm.getCol2().get128() ); + dot = vec_splat( dot, 0 ); + invdet = recipf4( dot ); + tmp3 = vec_mergeh( tmp0, tmp2 ); + tmp4 = vec_mergel( tmp0, tmp2 ); + inv0 = vec_mergeh( tmp3, tmp1 ); + xxxx = vec_splat( inv3, 0 ); + //inv1 = vec_perm( tmp3, tmp1, _VECTORMATH_PERM_ZBWX ); + __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; + inv1 = _mm_shuffle_ps( tmp3, tmp3, _MM_SHUFFLE(0,3,2,2)); + inv1 = vec_sel(inv1, tmp1, select_y); + //inv2 = vec_perm( tmp4, tmp1, _VECTORMATH_PERM_XCYX ); + inv2 = _mm_shuffle_ps( tmp4, tmp4, _MM_SHUFFLE(0,1,1,0)); + inv2 = vec_sel(inv2, vec_splat(tmp1, 2), select_y); + yyyy = vec_splat( inv3, 1 ); + zzzz = vec_splat( inv3, 2 ); + inv3 = vec_mul( inv0, xxxx ); + inv3 = vec_madd( inv1, yyyy, inv3 ); + inv3 = vec_madd( inv2, zzzz, inv3 ); + inv0 = vec_mul( inv0, invdet ); + inv1 = vec_mul( inv1, invdet ); + inv2 = vec_mul( inv2, invdet ); + inv3 = vec_mul( inv3, invdet ); + return Transform3( + Vector3( inv0 ), + Vector3( inv1 ), + Vector3( inv2 ), + Vector3( inv3 ) + ); +} + +inline const Transform3 orthoInverse( const Transform3 & tfrm ) +{ + __m128 inv0, inv1, inv2, inv3; + __m128 tmp0, tmp1; + __m128 xxxx, yyyy, zzzz; + tmp0 = vec_mergeh( tfrm.getCol0().get128(), tfrm.getCol2().get128() ); + tmp1 = vec_mergel( tfrm.getCol0().get128(), tfrm.getCol2().get128() ); + inv3 = negatef4( tfrm.getCol3().get128() ); + inv0 = vec_mergeh( tmp0, tfrm.getCol1().get128() ); + xxxx = vec_splat( inv3, 0 ); + //inv1 = vec_perm( tmp0, tfrm.getCol1().get128(), _VECTORMATH_PERM_ZBWX ); + __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; + inv1 = _mm_shuffle_ps( tmp0, tmp0, _MM_SHUFFLE(0,3,2,2)); + inv1 = vec_sel(inv1, tfrm.getCol1().get128(), select_y); + //inv2 = vec_perm( tmp1, tfrm.getCol1().get128(), _VECTORMATH_PERM_XCYX ); + inv2 = _mm_shuffle_ps( tmp1, tmp1, _MM_SHUFFLE(0,1,1,0)); + inv2 = vec_sel(inv2, vec_splat(tfrm.getCol1().get128(), 2), select_y); + yyyy = vec_splat( inv3, 1 ); + zzzz = vec_splat( inv3, 2 ); + inv3 = vec_mul( inv0, xxxx ); + inv3 = vec_madd( inv1, yyyy, inv3 ); + inv3 = vec_madd( inv2, zzzz, inv3 ); + return Transform3( + Vector3( inv0 ), + Vector3( inv1 ), + Vector3( inv2 ), + Vector3( inv3 ) + ); +} + +inline const Transform3 absPerElem( const Transform3 & tfrm ) +{ + return Transform3( + absPerElem( tfrm.getCol0() ), + absPerElem( tfrm.getCol1() ), + absPerElem( tfrm.getCol2() ), + absPerElem( tfrm.getCol3() ) + ); +} + +inline const Vector3 Transform3::operator *( const Vector3 &vec ) const +{ + __m128 res; + __m128 xxxx, yyyy, zzzz; + xxxx = vec_splat( vec.get128(), 0 ); + yyyy = vec_splat( vec.get128(), 1 ); + zzzz = vec_splat( vec.get128(), 2 ); + res = vec_mul( mCol0.get128(), xxxx ); + res = vec_madd( mCol1.get128(), yyyy, res ); + res = vec_madd( mCol2.get128(), zzzz, res ); + return Vector3( res ); +} + +inline const Point3 Transform3::operator *( const Point3 &pnt ) const +{ + __m128 tmp0, tmp1, res; + __m128 xxxx, yyyy, zzzz; + xxxx = vec_splat( pnt.get128(), 0 ); + yyyy = vec_splat( pnt.get128(), 1 ); + zzzz = vec_splat( pnt.get128(), 2 ); + tmp0 = vec_mul( mCol0.get128(), xxxx ); + tmp1 = vec_mul( mCol1.get128(), yyyy ); + tmp0 = vec_madd( mCol2.get128(), zzzz, tmp0 ); + tmp1 = vec_add( mCol3.get128(), tmp1 ); + res = vec_add( tmp0, tmp1 ); + return Point3( res ); +} + +inline const Transform3 Transform3::operator *( const Transform3 & tfrm ) const +{ + return Transform3( + ( *this * tfrm.mCol0 ), + ( *this * tfrm.mCol1 ), + ( *this * tfrm.mCol2 ), + Vector3( ( *this * Point3( tfrm.mCol3 ) ) ) + ); +} + +inline Transform3 & Transform3::operator *=( const Transform3 & tfrm ) +{ + *this = *this * tfrm; + return *this; +} + +inline const Transform3 mulPerElem( const Transform3 & tfrm0, const Transform3 & tfrm1 ) +{ + return Transform3( + mulPerElem( tfrm0.getCol0(), tfrm1.getCol0() ), + mulPerElem( tfrm0.getCol1(), tfrm1.getCol1() ), + mulPerElem( tfrm0.getCol2(), tfrm1.getCol2() ), + mulPerElem( tfrm0.getCol3(), tfrm1.getCol3() ) + ); +} + +inline const Transform3 Transform3::identity( ) +{ + return Transform3( + Vector3::xAxis( ), + Vector3::yAxis( ), + Vector3::zAxis( ), + Vector3( 0.0f ) + ); +} + +inline Transform3 & Transform3::setUpper3x3( const Matrix3 & tfrm ) +{ + mCol0 = tfrm.getCol0(); + mCol1 = tfrm.getCol1(); + mCol2 = tfrm.getCol2(); + return *this; +} + +inline const Matrix3 Transform3::getUpper3x3( ) const +{ + return Matrix3( mCol0, mCol1, mCol2 ); +} + +inline Transform3 & Transform3::setTranslation( const Vector3 &translateVec ) +{ + mCol3 = translateVec; + return *this; +} + +inline const Vector3 Transform3::getTranslation( ) const +{ + return mCol3; +} + +inline const Transform3 Transform3::rotationX( float radians ) +{ + return rotationX( floatInVec(radians) ); +} + +inline const Transform3 Transform3::rotationX( const floatInVec &radians ) +{ + __m128 s, c, res1, res2; + __m128 zero; + __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; + __declspec(align(16)) unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; + zero = _mm_setzero_ps(); + sincosf4( radians.get128(), &s, &c ); + res1 = vec_sel( zero, c, select_y ); + res1 = vec_sel( res1, s, select_z ); + res2 = vec_sel( zero, negatef4(s), select_y ); + res2 = vec_sel( res2, c, select_z ); + return Transform3( + Vector3::xAxis( ), + Vector3( res1 ), + Vector3( res2 ), + Vector3( _mm_setzero_ps() ) + ); +} + +inline const Transform3 Transform3::rotationY( float radians ) +{ + return rotationY( floatInVec(radians) ); +} + +inline const Transform3 Transform3::rotationY( const floatInVec &radians ) +{ + __m128 s, c, res0, res2; + __m128 zero; + __declspec(align(16)) unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; + __declspec(align(16)) unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; + zero = _mm_setzero_ps(); + sincosf4( radians.get128(), &s, &c ); + res0 = vec_sel( zero, c, select_x ); + res0 = vec_sel( res0, negatef4(s), select_z ); + res2 = vec_sel( zero, s, select_x ); + res2 = vec_sel( res2, c, select_z ); + return Transform3( + Vector3( res0 ), + Vector3::yAxis( ), + Vector3( res2 ), + Vector3( 0.0f ) + ); +} + +inline const Transform3 Transform3::rotationZ( float radians ) +{ + return rotationZ( floatInVec(radians) ); +} + +inline const Transform3 Transform3::rotationZ( const floatInVec &radians ) +{ + __m128 s, c, res0, res1; + __declspec(align(16)) unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; + __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; + __m128 zero = _mm_setzero_ps(); + sincosf4( radians.get128(), &s, &c ); + res0 = vec_sel( zero, c, select_x ); + res0 = vec_sel( res0, s, select_y ); + res1 = vec_sel( zero, negatef4(s), select_x ); + res1 = vec_sel( res1, c, select_y ); + return Transform3( + Vector3( res0 ), + Vector3( res1 ), + Vector3::zAxis( ), + Vector3( 0.0f ) + ); +} + +inline const Transform3 Transform3::rotationZYX( const Vector3 &radiansXYZ ) +{ + __m128 angles, s, negS, c, X0, X1, Y0, Y1, Z0, Z1, tmp; + angles = Vector4( radiansXYZ, 0.0f ).get128(); + sincosf4( angles, &s, &c ); + negS = negatef4( s ); + Z0 = vec_mergel( c, s ); + Z1 = vec_mergel( negS, c ); + __declspec(align(16)) unsigned int select_xyz[4] = {0xffffffff, 0xffffffff, 0xffffffff, 0}; + Z1 = vec_and( Z1, _mm_load_ps( (float *)select_xyz ) ); + Y0 = _mm_shuffle_ps( c, negS, _MM_SHUFFLE(0,1,1,1) ); + Y1 = _mm_shuffle_ps( s, c, _MM_SHUFFLE(0,1,1,1) ); + X0 = vec_splat( s, 0 ); + X1 = vec_splat( c, 0 ); + tmp = vec_mul( Z0, Y1 ); + return Transform3( + Vector3( vec_mul( Z0, Y0 ) ), + Vector3( vec_madd( Z1, X1, vec_mul( tmp, X0 ) ) ), + Vector3( vec_nmsub( Z1, X0, vec_mul( tmp, X1 ) ) ), + Vector3( 0.0f ) + ); +} + +inline const Transform3 Transform3::rotation( float radians, const Vector3 &unitVec ) +{ + return rotation( floatInVec(radians), unitVec ); +} + +inline const Transform3 Transform3::rotation( const floatInVec &radians, const Vector3 &unitVec ) +{ + return Transform3( Matrix3::rotation( radians, unitVec ), Vector3( 0.0f ) ); +} + +inline const Transform3 Transform3::rotation( const Quat &unitQuat ) +{ + return Transform3( Matrix3( unitQuat ), Vector3( 0.0f ) ); +} + +inline const Transform3 Transform3::scale( const Vector3 &scaleVec ) +{ + __m128 zero = _mm_setzero_ps(); + __declspec(align(16)) unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; + __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; + __declspec(align(16)) unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; + return Transform3( + Vector3( vec_sel( zero, scaleVec.get128(), select_x ) ), + Vector3( vec_sel( zero, scaleVec.get128(), select_y ) ), + Vector3( vec_sel( zero, scaleVec.get128(), select_z ) ), + Vector3( 0.0f ) + ); +} + +inline const Transform3 appendScale( const Transform3 & tfrm, const Vector3 &scaleVec ) +{ + return Transform3( + ( tfrm.getCol0() * scaleVec.getX( ) ), + ( tfrm.getCol1() * scaleVec.getY( ) ), + ( tfrm.getCol2() * scaleVec.getZ( ) ), + tfrm.getCol3() + ); +} + +inline const Transform3 prependScale( const Vector3 &scaleVec, const Transform3 & tfrm ) +{ + return Transform3( + mulPerElem( tfrm.getCol0(), scaleVec ), + mulPerElem( tfrm.getCol1(), scaleVec ), + mulPerElem( tfrm.getCol2(), scaleVec ), + mulPerElem( tfrm.getCol3(), scaleVec ) + ); +} + +inline const Transform3 Transform3::translation( const Vector3 &translateVec ) +{ + return Transform3( + Vector3::xAxis( ), + Vector3::yAxis( ), + Vector3::zAxis( ), + translateVec + ); +} + +inline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, bool select1 ) +{ + return Transform3( + select( tfrm0.getCol0(), tfrm1.getCol0(), select1 ), + select( tfrm0.getCol1(), tfrm1.getCol1(), select1 ), + select( tfrm0.getCol2(), tfrm1.getCol2(), select1 ), + select( tfrm0.getCol3(), tfrm1.getCol3(), select1 ) + ); +} + +inline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, const boolInVec &select1 ) +{ + return Transform3( + select( tfrm0.getCol0(), tfrm1.getCol0(), select1 ), + select( tfrm0.getCol1(), tfrm1.getCol1(), select1 ), + select( tfrm0.getCol2(), tfrm1.getCol2(), select1 ), + select( tfrm0.getCol3(), tfrm1.getCol3(), select1 ) + ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( const Transform3 & tfrm ) +{ + print( tfrm.getRow( 0 ) ); + print( tfrm.getRow( 1 ) ); + print( tfrm.getRow( 2 ) ); +} + +inline void print( const Transform3 & tfrm, const char * name ) +{ + printf("%s:\n", name); + print( tfrm ); +} + +#endif + +inline Quat::Quat( const Matrix3 & tfrm ) +{ + __m128 res; + __m128 col0, col1, col2; + __m128 xx_yy, xx_yy_zz_xx, yy_zz_xx_yy, zz_xx_yy_zz, diagSum, diagDiff; + __m128 zy_xz_yx, yz_zx_xy, sum, diff; + __m128 radicand, invSqrt, scale; + __m128 res0, res1, res2, res3; + __m128 xx, yy, zz; + __declspec(align(16)) unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; + __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; + __declspec(align(16)) unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; + __declspec(align(16)) unsigned int select_w[4] = {0, 0, 0, 0xffffffff}; + + col0 = tfrm.getCol0().get128(); + col1 = tfrm.getCol1().get128(); + col2 = tfrm.getCol2().get128(); + + /* four cases: */ + /* trace > 0 */ + /* else */ + /* xx largest diagonal element */ + /* yy largest diagonal element */ + /* zz largest diagonal element */ + + /* compute quaternion for each case */ + + xx_yy = vec_sel( col0, col1, select_y ); + //xx_yy_zz_xx = vec_perm( xx_yy, col2, _VECTORMATH_PERM_XYCX ); + //yy_zz_xx_yy = vec_perm( xx_yy, col2, _VECTORMATH_PERM_YCXY ); + //zz_xx_yy_zz = vec_perm( xx_yy, col2, _VECTORMATH_PERM_CXYC ); + xx_yy_zz_xx = _mm_shuffle_ps( xx_yy, xx_yy, _MM_SHUFFLE(0,0,1,0) ); + xx_yy_zz_xx = vec_sel( xx_yy_zz_xx, col2, select_z ); // TODO: Ck + yy_zz_xx_yy = _mm_shuffle_ps( xx_yy_zz_xx, xx_yy_zz_xx, _MM_SHUFFLE(1,0,2,1) ); + zz_xx_yy_zz = _mm_shuffle_ps( xx_yy_zz_xx, xx_yy_zz_xx, _MM_SHUFFLE(2,1,0,2) ); + + diagSum = vec_add( vec_add( xx_yy_zz_xx, yy_zz_xx_yy ), zz_xx_yy_zz ); + diagDiff = vec_sub( vec_sub( xx_yy_zz_xx, yy_zz_xx_yy ), zz_xx_yy_zz ); + radicand = vec_add( vec_sel( diagDiff, diagSum, select_w ), _mm_set1_ps(1.0f) ); + // invSqrt = rsqrtf4( radicand ); + invSqrt = newtonrapson_rsqrt4( radicand ); + + + + zy_xz_yx = vec_sel( col0, col1, select_z ); // zy_xz_yx = 00 01 12 03 + //zy_xz_yx = vec_perm( zy_xz_yx, col2, _VECTORMATH_PERM_ZAYX ); + zy_xz_yx = _mm_shuffle_ps( zy_xz_yx, zy_xz_yx, _MM_SHUFFLE(0,1,2,2) ); // zy_xz_yx = 12 12 01 00 + zy_xz_yx = vec_sel( zy_xz_yx, vec_splat(col2, 0), select_y ); // zy_xz_yx = 12 20 01 00 + yz_zx_xy = vec_sel( col0, col1, select_x ); // yz_zx_xy = 10 01 02 03 + //yz_zx_xy = vec_perm( yz_zx_xy, col2, _VECTORMATH_PERM_BZXX ); + yz_zx_xy = _mm_shuffle_ps( yz_zx_xy, yz_zx_xy, _MM_SHUFFLE(0,0,2,0) ); // yz_zx_xy = 10 02 10 10 + yz_zx_xy = vec_sel( yz_zx_xy, vec_splat(col2, 1), select_x ); // yz_zx_xy = 21 02 10 10 + + sum = vec_add( zy_xz_yx, yz_zx_xy ); + diff = vec_sub( zy_xz_yx, yz_zx_xy ); + + scale = vec_mul( invSqrt, _mm_set1_ps(0.5f) ); + + //res0 = vec_perm( sum, diff, _VECTORMATH_PERM_XZYA ); + res0 = _mm_shuffle_ps( sum, sum, _MM_SHUFFLE(0,1,2,0) ); + res0 = vec_sel( res0, vec_splat(diff, 0), select_w ); // TODO: Ck + //res1 = vec_perm( sum, diff, _VECTORMATH_PERM_ZXXB ); + res1 = _mm_shuffle_ps( sum, sum, _MM_SHUFFLE(0,0,0,2) ); + res1 = vec_sel( res1, vec_splat(diff, 1), select_w ); // TODO: Ck + //res2 = vec_perm( sum, diff, _VECTORMATH_PERM_YXXC ); + res2 = _mm_shuffle_ps( sum, sum, _MM_SHUFFLE(0,0,0,1) ); + res2 = vec_sel( res2, vec_splat(diff, 2), select_w ); // TODO: Ck + res3 = diff; + res0 = vec_sel( res0, radicand, select_x ); + res1 = vec_sel( res1, radicand, select_y ); + res2 = vec_sel( res2, radicand, select_z ); + res3 = vec_sel( res3, radicand, select_w ); + res0 = vec_mul( res0, vec_splat( scale, 0 ) ); + res1 = vec_mul( res1, vec_splat( scale, 1 ) ); + res2 = vec_mul( res2, vec_splat( scale, 2 ) ); + res3 = vec_mul( res3, vec_splat( scale, 3 ) ); + + /* determine case and select answer */ + + xx = vec_splat( col0, 0 ); + yy = vec_splat( col1, 1 ); + zz = vec_splat( col2, 2 ); + res = vec_sel( res0, res1, vec_cmpgt( yy, xx ) ); + res = vec_sel( res, res2, vec_and( vec_cmpgt( zz, xx ), vec_cmpgt( zz, yy ) ) ); + res = vec_sel( res, res3, vec_cmpgt( vec_splat( diagSum, 0 ), _mm_setzero_ps() ) ); + mVec128 = res; +} + +inline const Matrix3 outer( const Vector3 &tfrm0, const Vector3 &tfrm1 ) +{ + return Matrix3( + ( tfrm0 * tfrm1.getX( ) ), + ( tfrm0 * tfrm1.getY( ) ), + ( tfrm0 * tfrm1.getZ( ) ) + ); +} + +inline const Matrix4 outer( const Vector4 &tfrm0, const Vector4 &tfrm1 ) +{ + return Matrix4( + ( tfrm0 * tfrm1.getX( ) ), + ( tfrm0 * tfrm1.getY( ) ), + ( tfrm0 * tfrm1.getZ( ) ), + ( tfrm0 * tfrm1.getW( ) ) + ); +} + +inline const Vector3 rowMul( const Vector3 &vec, const Matrix3 & mat ) +{ + __m128 tmp0, tmp1, mcol0, mcol1, mcol2, res; + __m128 xxxx, yyyy, zzzz; + tmp0 = vec_mergeh( mat.getCol0().get128(), mat.getCol2().get128() ); + tmp1 = vec_mergel( mat.getCol0().get128(), mat.getCol2().get128() ); + xxxx = vec_splat( vec.get128(), 0 ); + mcol0 = vec_mergeh( tmp0, mat.getCol1().get128() ); + //mcol1 = vec_perm( tmp0, mat.getCol1().get128(), _VECTORMATH_PERM_ZBWX ); + __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; + mcol1 = _mm_shuffle_ps( tmp0, tmp0, _MM_SHUFFLE(0,3,2,2)); + mcol1 = vec_sel(mcol1, mat.getCol1().get128(), select_y); + //mcol2 = vec_perm( tmp1, mat.getCol1().get128(), _VECTORMATH_PERM_XCYX ); + mcol2 = _mm_shuffle_ps( tmp1, tmp1, _MM_SHUFFLE(0,1,1,0)); + mcol2 = vec_sel(mcol2, vec_splat(mat.getCol1().get128(), 2), select_y); + yyyy = vec_splat( vec.get128(), 1 ); + res = vec_mul( mcol0, xxxx ); + zzzz = vec_splat( vec.get128(), 2 ); + res = vec_madd( mcol1, yyyy, res ); + res = vec_madd( mcol2, zzzz, res ); + return Vector3( res ); +} + +inline const Matrix3 crossMatrix( const Vector3 &vec ) +{ + __m128 neg, res0, res1, res2; + neg = negatef4( vec.get128() ); + __declspec(align(16)) unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; + __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; + __declspec(align(16)) unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; + //res0 = vec_perm( vec.get128(), neg, _VECTORMATH_PERM_XZBX ); + res0 = _mm_shuffle_ps( vec.get128(), vec.get128(), _MM_SHUFFLE(0,2,2,0) ); + res0 = vec_sel(res0, vec_splat(neg, 1), select_z); + //res1 = vec_perm( vec.get128(), neg, _VECTORMATH_PERM_CXXX ); + res1 = vec_sel(vec_splat(vec.get128(), 0), vec_splat(neg, 2), select_x); + //res2 = vec_perm( vec.get128(), neg, _VECTORMATH_PERM_YAXX ); + res2 = _mm_shuffle_ps( vec.get128(), vec.get128(), _MM_SHUFFLE(0,0,1,1) ); + res2 = vec_sel(res2, vec_splat(neg, 0), select_y); + __declspec(align(16)) unsigned int filter_x[4] = {0, 0xffffffff, 0xffffffff, 0xffffffff}; + __declspec(align(16)) unsigned int filter_y[4] = {0xffffffff, 0, 0xffffffff, 0xffffffff}; + __declspec(align(16)) unsigned int filter_z[4] = {0xffffffff, 0xffffffff, 0, 0xffffffff}; + res0 = vec_and( res0, _mm_load_ps((float *)filter_x ) ); + res1 = vec_and( res1, _mm_load_ps((float *)filter_y ) ); + res2 = vec_and( res2, _mm_load_ps((float *)filter_z ) ); // TODO: Use selects? + return Matrix3( + Vector3( res0 ), + Vector3( res1 ), + Vector3( res2 ) + ); +} + +inline const Matrix3 crossMatrixMul( const Vector3 &vec, const Matrix3 & mat ) +{ + return Matrix3( cross( vec, mat.getCol0() ), cross( vec, mat.getCol1() ), cross( vec, mat.getCol2() ) ); +} + +} // namespace Aos +} // namespace Vectormath + +#endif diff --git a/vectormathlibrary/include/vectormath/SSE/cpp/quat_aos.h b/vectormathlibrary/include/vectormath/SSE/cpp/quat_aos.h new file mode 100644 index 000000000..a7cd4e145 --- /dev/null +++ b/vectormathlibrary/include/vectormath/SSE/cpp/quat_aos.h @@ -0,0 +1,533 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + + +#ifndef _VECTORMATH_QUAT_AOS_CPP_H +#define _VECTORMATH_QUAT_AOS_CPP_H + +//----------------------------------------------------------------------------- +// Definitions + +#ifndef _VECTORMATH_INTERNAL_FUNCTIONS +#define _VECTORMATH_INTERNAL_FUNCTIONS + +#endif + +namespace Vectormath { +namespace Aos { + +inline Quat::Quat( float _x, float _y, float _z, float _w ) +{ + mVec128 = _mm_setr_ps(_x, _y, _z, _w); +} + +inline Quat::Quat( const floatInVec &_x, const floatInVec &_y, const floatInVec &_z, const floatInVec &_w ) +{ + mVec128 = _mm_unpacklo_ps( + _mm_unpacklo_ps( _x.get128(), _z.get128() ), + _mm_unpacklo_ps( _y.get128(), _w.get128() ) ); +} + +inline Quat::Quat( const Vector3 &xyz, float _w ) +{ + mVec128 = xyz.get128(); + _vmathVfSetElement(mVec128, _w, 3); +} + +inline Quat::Quat( const Vector3 &xyz, const floatInVec &_w ) +{ + mVec128 = xyz.get128(); + mVec128 = _vmathVfInsert(mVec128, _w.get128(), 3); +} + +inline Quat::Quat( const Vector4 &vec ) +{ + mVec128 = vec.get128(); +} + +inline Quat::Quat( float scalar ) +{ + mVec128 = floatInVec(scalar).get128(); +} + +inline Quat::Quat( const floatInVec &scalar ) +{ + mVec128 = scalar.get128(); +} + +inline Quat::Quat( __m128 vf4 ) +{ + mVec128 = vf4; +} + +inline const Quat Quat::identity( ) +{ + return Quat( _VECTORMATH_UNIT_0001 ); +} + +inline const Quat lerp( float t, const Quat &quat0, const Quat &quat1 ) +{ + return lerp( floatInVec(t), quat0, quat1 ); +} + +inline const Quat lerp( const floatInVec &t, const Quat &quat0, const Quat &quat1 ) +{ + return ( quat0 + ( ( quat1 - quat0 ) * t ) ); +} + +inline const Quat slerp( float t, const Quat &unitQuat0, const Quat &unitQuat1 ) +{ + return slerp( floatInVec(t), unitQuat0, unitQuat1 ); +} + +inline const Quat slerp( const floatInVec &t, const Quat &unitQuat0, const Quat &unitQuat1 ) +{ + Quat start; + vec_float4 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines; + vec_uint4 selectMask; + cosAngle = _vmathVfDot4( unitQuat0.get128(), unitQuat1.get128() ); + selectMask = (vec_uint4)vec_cmpgt( _mm_setzero_ps(), cosAngle ); + cosAngle = vec_sel( cosAngle, negatef4( cosAngle ), selectMask ); + start = Quat( vec_sel( unitQuat0.get128(), negatef4( unitQuat0.get128() ), selectMask ) ); + selectMask = (vec_uint4)vec_cmpgt( _mm_set1_ps(_VECTORMATH_SLERP_TOL), cosAngle ); + angle = acosf4( cosAngle ); + tttt = t.get128(); + oneMinusT = vec_sub( _mm_set1_ps(1.0f), tttt ); + angles = vec_mergeh( _mm_set1_ps(1.0f), tttt ); + angles = vec_mergeh( angles, oneMinusT ); + angles = vec_madd( angles, angle, _mm_setzero_ps() ); + sines = sinf4( angles ); + scales = _mm_div_ps( sines, vec_splat( sines, 0 ) ); + scale0 = vec_sel( oneMinusT, vec_splat( scales, 1 ), selectMask ); + scale1 = vec_sel( tttt, vec_splat( scales, 2 ), selectMask ); + return Quat( vec_madd( start.get128(), scale0, vec_mul( unitQuat1.get128(), scale1 ) ) ); +} + +inline const Quat squad( float t, const Quat &unitQuat0, const Quat &unitQuat1, const Quat &unitQuat2, const Quat &unitQuat3 ) +{ + return squad( floatInVec(t), unitQuat0, unitQuat1, unitQuat2, unitQuat3 ); +} + +inline const Quat squad( const floatInVec &t, const Quat &unitQuat0, const Quat &unitQuat1, const Quat &unitQuat2, const Quat &unitQuat3 ) +{ + return slerp( ( ( floatInVec(2.0f) * t ) * ( floatInVec(1.0f) - t ) ), slerp( t, unitQuat0, unitQuat3 ), slerp( t, unitQuat1, unitQuat2 ) ); +} + +inline __m128 Quat::get128( ) const +{ + return mVec128; +} + +inline Quat & Quat::operator =( const Quat &quat ) +{ + mVec128 = quat.mVec128; + return *this; +} + +inline Quat & Quat::setXYZ( const Vector3 &vec ) +{ + __declspec(align(16)) unsigned int sw[4] = {0, 0, 0, 0xffffffff}; + mVec128 = vec_sel( vec.get128(), mVec128, sw ); + return *this; +} + +inline const Vector3 Quat::getXYZ( ) const +{ + return Vector3( mVec128 ); +} + +inline Quat & Quat::setX( float _x ) +{ + _vmathVfSetElement(mVec128, _x, 0); + return *this; +} + +inline Quat & Quat::setX( const floatInVec &_x ) +{ + mVec128 = _vmathVfInsert(mVec128, _x.get128(), 0); + return *this; +} + +inline const floatInVec Quat::getX( ) const +{ + return floatInVec( mVec128, 0 ); +} + +inline Quat & Quat::setY( float _y ) +{ + _vmathVfSetElement(mVec128, _y, 1); + return *this; +} + +inline Quat & Quat::setY( const floatInVec &_y ) +{ + mVec128 = _vmathVfInsert(mVec128, _y.get128(), 1); + return *this; +} + +inline const floatInVec Quat::getY( ) const +{ + return floatInVec( mVec128, 1 ); +} + +inline Quat & Quat::setZ( float _z ) +{ + _vmathVfSetElement(mVec128, _z, 2); + return *this; +} + +inline Quat & Quat::setZ( const floatInVec &_z ) +{ + mVec128 = _vmathVfInsert(mVec128, _z.get128(), 2); + return *this; +} + +inline const floatInVec Quat::getZ( ) const +{ + return floatInVec( mVec128, 2 ); +} + +inline Quat & Quat::setW( float _w ) +{ + _vmathVfSetElement(mVec128, _w, 3); + return *this; +} + +inline Quat & Quat::setW( const floatInVec &_w ) +{ + mVec128 = _vmathVfInsert(mVec128, _w.get128(), 3); + return *this; +} + +inline const floatInVec Quat::getW( ) const +{ + return floatInVec( mVec128, 3 ); +} + +inline Quat & Quat::setElem( int idx, float value ) +{ + _vmathVfSetElement(mVec128, value, idx); + return *this; +} + +inline Quat & Quat::setElem( int idx, const floatInVec &value ) +{ + mVec128 = _vmathVfInsert(mVec128, value.get128(), idx); + return *this; +} + +inline const floatInVec Quat::getElem( int idx ) const +{ + return floatInVec( mVec128, idx ); +} + +inline VecIdx Quat::operator []( int idx ) +{ + return VecIdx( mVec128, idx ); +} + +inline const floatInVec Quat::operator []( int idx ) const +{ + return floatInVec( mVec128, idx ); +} + +inline const Quat Quat::operator +( const Quat &quat ) const +{ + return Quat( _mm_add_ps( mVec128, quat.mVec128 ) ); +} + +inline const Quat Quat::operator -( const Quat &quat ) const +{ + return Quat( _mm_sub_ps( mVec128, quat.mVec128 ) ); +} + +inline const Quat Quat::operator *( float scalar ) const +{ + return *this * floatInVec(scalar); +} + +inline const Quat Quat::operator *( const floatInVec &scalar ) const +{ + return Quat( _mm_mul_ps( mVec128, scalar.get128() ) ); +} + +inline Quat & Quat::operator +=( const Quat &quat ) +{ + *this = *this + quat; + return *this; +} + +inline Quat & Quat::operator -=( const Quat &quat ) +{ + *this = *this - quat; + return *this; +} + +inline Quat & Quat::operator *=( float scalar ) +{ + *this = *this * scalar; + return *this; +} + +inline Quat & Quat::operator *=( const floatInVec &scalar ) +{ + *this = *this * scalar; + return *this; +} + +inline const Quat Quat::operator /( float scalar ) const +{ + return *this / floatInVec(scalar); +} + +inline const Quat Quat::operator /( const floatInVec &scalar ) const +{ + return Quat( _mm_div_ps( mVec128, scalar.get128() ) ); +} + +inline Quat & Quat::operator /=( float scalar ) +{ + *this = *this / scalar; + return *this; +} + +inline Quat & Quat::operator /=( const floatInVec &scalar ) +{ + *this = *this / scalar; + return *this; +} + +inline const Quat Quat::operator -( ) const +{ + return Quat(_mm_sub_ps( _mm_setzero_ps(), mVec128 ) ); +} + +inline const Quat operator *( float scalar, const Quat &quat ) +{ + return floatInVec(scalar) * quat; +} + +inline const Quat operator *( const floatInVec &scalar, const Quat &quat ) +{ + return quat * scalar; +} + +inline const floatInVec dot( const Quat &quat0, const Quat &quat1 ) +{ + return floatInVec( _vmathVfDot4( quat0.get128(), quat1.get128() ), 0 ); +} + +inline const floatInVec norm( const Quat &quat ) +{ + return floatInVec( _vmathVfDot4( quat.get128(), quat.get128() ), 0 ); +} + +inline const floatInVec length( const Quat &quat ) +{ + return floatInVec( _mm_sqrt_ps(_vmathVfDot4( quat.get128(), quat.get128() )), 0 ); +} + +inline const Quat normalize( const Quat &quat ) +{ + return Quat( _mm_mul_ps( quat.get128(), _mm_rsqrt_ps( _vmathVfDot4( quat.get128(), quat.get128() ) ) ) ); +} + +inline const Quat Quat::rotation( const Vector3 &unitVec0, const Vector3 &unitVec1 ) +{ + Vector3 crossVec; + __m128 cosAngle, cosAngleX2Plus2, recipCosHalfAngleX2, cosHalfAngleX2, res; + cosAngle = _vmathVfDot3( unitVec0.get128(), unitVec1.get128() ); + cosAngleX2Plus2 = vec_madd( cosAngle, _mm_set1_ps(2.0f), _mm_set1_ps(2.0f) ); + recipCosHalfAngleX2 = _mm_rsqrt_ps( cosAngleX2Plus2 ); + cosHalfAngleX2 = vec_mul( recipCosHalfAngleX2, cosAngleX2Plus2 ); + crossVec = cross( unitVec0, unitVec1 ); + res = vec_mul( crossVec.get128(), recipCosHalfAngleX2 ); + __declspec(align(16)) unsigned int sw[4] = {0, 0, 0, 0xffffffff}; + res = vec_sel( res, vec_mul( cosHalfAngleX2, _mm_set1_ps(0.5f) ), sw ); + return Quat( res ); +} + +inline const Quat Quat::rotation( float radians, const Vector3 &unitVec ) +{ + return rotation( floatInVec(radians), unitVec ); +} + +inline const Quat Quat::rotation( const floatInVec &radians, const Vector3 &unitVec ) +{ + __m128 s, c, angle, res; + angle = vec_mul( radians.get128(), _mm_set1_ps(0.5f) ); + sincosf4( angle, &s, &c ); + __declspec(align(16)) unsigned int sw[4] = {0, 0, 0, 0xffffffff}; + res = vec_sel( vec_mul( unitVec.get128(), s ), c, sw ); + return Quat( res ); +} + +inline const Quat Quat::rotationX( float radians ) +{ + return rotationX( floatInVec(radians) ); +} + +inline const Quat Quat::rotationX( const floatInVec &radians ) +{ + __m128 s, c, angle, res; + angle = vec_mul( radians.get128(), _mm_set1_ps(0.5f) ); + sincosf4( angle, &s, &c ); + __declspec(align(16)) unsigned int xsw[4] = {0xffffffff, 0, 0, 0}; + __declspec(align(16)) unsigned int wsw[4] = {0, 0, 0, 0xffffffff}; + res = vec_sel( _mm_setzero_ps(), s, xsw ); + res = vec_sel( res, c, wsw ); + return Quat( res ); +} + +inline const Quat Quat::rotationY( float radians ) +{ + return rotationY( floatInVec(radians) ); +} + +inline const Quat Quat::rotationY( const floatInVec &radians ) +{ + __m128 s, c, angle, res; + angle = vec_mul( radians.get128(), _mm_set1_ps(0.5f) ); + sincosf4( angle, &s, &c ); + __declspec(align(16)) unsigned int ysw[4] = {0, 0xffffffff, 0, 0}; + __declspec(align(16)) unsigned int wsw[4] = {0, 0, 0, 0xffffffff}; + res = vec_sel( _mm_setzero_ps(), s, ysw ); + res = vec_sel( res, c, wsw ); + return Quat( res ); +} + +inline const Quat Quat::rotationZ( float radians ) +{ + return rotationZ( floatInVec(radians) ); +} + +inline const Quat Quat::rotationZ( const floatInVec &radians ) +{ + __m128 s, c, angle, res; + angle = vec_mul( radians.get128(), _mm_set1_ps(0.5f) ); + sincosf4( angle, &s, &c ); + __declspec(align(16)) unsigned int zsw[4] = {0, 0, 0xffffffff, 0}; + __declspec(align(16)) unsigned int wsw[4] = {0, 0, 0, 0xffffffff}; + res = vec_sel( _mm_setzero_ps(), s, zsw ); + res = vec_sel( res, c, wsw ); + return Quat( res ); +} + +inline const Quat Quat::operator *( const Quat &quat ) const +{ + __m128 ldata, rdata, qv, tmp0, tmp1, tmp2, tmp3; + __m128 product, l_wxyz, r_wxyz, xy, qw; + ldata = mVec128; + rdata = quat.mVec128; + tmp0 = _mm_shuffle_ps( ldata, ldata, _MM_SHUFFLE(3,0,2,1) ); + tmp1 = _mm_shuffle_ps( rdata, rdata, _MM_SHUFFLE(3,1,0,2) ); + tmp2 = _mm_shuffle_ps( ldata, ldata, _MM_SHUFFLE(3,1,0,2) ); + tmp3 = _mm_shuffle_ps( rdata, rdata, _MM_SHUFFLE(3,0,2,1) ); + qv = vec_mul( vec_splat( ldata, 3 ), rdata ); + qv = vec_madd( vec_splat( rdata, 3 ), ldata, qv ); + qv = vec_madd( tmp0, tmp1, qv ); + qv = vec_nmsub( tmp2, tmp3, qv ); + product = vec_mul( ldata, rdata ); + l_wxyz = vec_sld( ldata, ldata, 12 ); + r_wxyz = vec_sld( rdata, rdata, 12 ); + qw = vec_nmsub( l_wxyz, r_wxyz, product ); + xy = vec_madd( l_wxyz, r_wxyz, product ); + qw = vec_sub( qw, vec_sld( xy, xy, 8 ) ); + __declspec(align(16)) unsigned int sw[4] = {0, 0, 0, 0xffffffff}; + return Quat( vec_sel( qv, qw, sw ) ); +} + +inline Quat & Quat::operator *=( const Quat &quat ) +{ + *this = *this * quat; + return *this; +} + +inline const Vector3 rotate( const Quat &quat, const Vector3 &vec ) +{ __m128 qdata, vdata, product, tmp0, tmp1, tmp2, tmp3, wwww, qv, qw, res; + qdata = quat.get128(); + vdata = vec.get128(); + tmp0 = _mm_shuffle_ps( qdata, qdata, _MM_SHUFFLE(3,0,2,1) ); + tmp1 = _mm_shuffle_ps( vdata, vdata, _MM_SHUFFLE(3,1,0,2) ); + tmp2 = _mm_shuffle_ps( qdata, qdata, _MM_SHUFFLE(3,1,0,2) ); + tmp3 = _mm_shuffle_ps( vdata, vdata, _MM_SHUFFLE(3,0,2,1) ); + wwww = vec_splat( qdata, 3 ); + qv = vec_mul( wwww, vdata ); + qv = vec_madd( tmp0, tmp1, qv ); + qv = vec_nmsub( tmp2, tmp3, qv ); + product = vec_mul( qdata, vdata ); + qw = vec_madd( vec_sld( qdata, qdata, 4 ), vec_sld( vdata, vdata, 4 ), product ); + qw = vec_add( vec_sld( product, product, 8 ), qw ); + tmp1 = _mm_shuffle_ps( qv, qv, _MM_SHUFFLE(3,1,0,2) ); + tmp3 = _mm_shuffle_ps( qv, qv, _MM_SHUFFLE(3,0,2,1) ); + res = vec_mul( vec_splat( qw, 0 ), qdata ); + res = vec_madd( wwww, qv, res ); + res = vec_madd( tmp0, tmp1, res ); + res = vec_nmsub( tmp2, tmp3, res ); + return Vector3( res ); +} + +inline const Quat conj( const Quat &quat ) +{ + __declspec(align(16)) unsigned int sw[4] = {0x80000000,0x80000000,0x80000000,0}; + return Quat( vec_xor( quat.get128(), _mm_load_ps((float *)sw) ) ); +} + +inline const Quat select( const Quat &quat0, const Quat &quat1, bool select1 ) +{ + return select( quat0, quat1, boolInVec(select1) ); +} + +inline const Quat select( const Quat &quat0, const Quat &quat1, const boolInVec &select1 ) +{ + return Quat( vec_sel( quat0.get128(), quat1.get128(), select1.get128() ) ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( const Quat &quat ) +{ + union { __m128 v; float s[4]; } tmp; + tmp.v = quat.get128(); + printf( "( %f %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] ); +} + +inline void print( const Quat &quat, const char * name ) +{ + union { __m128 v; float s[4]; } tmp; + tmp.v = quat.get128(); + printf( "%s: ( %f %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] ); +} + +#endif + +} // namespace Aos +} // namespace Vectormath + +#endif diff --git a/vectormathlibrary/include/vectormath/SSE/cpp/vec_aos.h b/vectormathlibrary/include/vectormath/SSE/cpp/vec_aos.h new file mode 100644 index 000000000..4fe957928 --- /dev/null +++ b/vectormathlibrary/include/vectormath/SSE/cpp/vec_aos.h @@ -0,0 +1,1391 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_VEC_AOS_CPP_H +#define _VECTORMATH_VEC_AOS_CPP_H + +//----------------------------------------------------------------------------- +// Constants +// for permutes words are labeled [x,y,z,w] [a,b,c,d] + +#define _VECTORMATH_PERM_X 0x00010203 +#define _VECTORMATH_PERM_Y 0x04050607 +#define _VECTORMATH_PERM_Z 0x08090a0b +#define _VECTORMATH_PERM_W 0x0c0d0e0f +#define _VECTORMATH_PERM_A 0x10111213 +#define _VECTORMATH_PERM_B 0x14151617 +#define _VECTORMATH_PERM_C 0x18191a1b +#define _VECTORMATH_PERM_D 0x1c1d1e1f +#define _VECTORMATH_PERM_XYZA (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A } +#define _VECTORMATH_PERM_ZXYW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_W } +#define _VECTORMATH_PERM_YZXW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_W } +#define _VECTORMATH_PERM_YZAB (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A, _VECTORMATH_PERM_B } +#define _VECTORMATH_PERM_ZABC (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A, _VECTORMATH_PERM_B, _VECTORMATH_PERM_C } +#define _VECTORMATH_PERM_XYAW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A, _VECTORMATH_PERM_W } +#define _VECTORMATH_PERM_XAZW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_A, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_W } +#define _VECTORMATH_MASK_0xF000 (vec_uint4){ 0xffffffff, 0, 0, 0 } +#define _VECTORMATH_MASK_0x0F00 (vec_uint4){ 0, 0xffffffff, 0, 0 } +#define _VECTORMATH_MASK_0x00F0 (vec_uint4){ 0, 0, 0xffffffff, 0 } +#define _VECTORMATH_MASK_0x000F (vec_uint4){ 0, 0, 0, 0xffffffff } +#define _VECTORMATH_UNIT_1000 _mm_setr_ps(1.0f,0.0f,0.0f,0.0f) // (__m128){ 1.0f, 0.0f, 0.0f, 0.0f } +#define _VECTORMATH_UNIT_0100 _mm_setr_ps(0.0f,1.0f,0.0f,0.0f) // (__m128){ 0.0f, 1.0f, 0.0f, 0.0f } +#define _VECTORMATH_UNIT_0010 _mm_setr_ps(0.0f,0.0f,1.0f,0.0f) // (__m128){ 0.0f, 0.0f, 1.0f, 0.0f } +#define _VECTORMATH_UNIT_0001 _mm_setr_ps(0.0f,0.0f,0.0f,1.0f) // (__m128){ 0.0f, 0.0f, 0.0f, 1.0f } +#define _VECTORMATH_SLERP_TOL 0.999f + +//----------------------------------------------------------------------------- +// Definitions + +#ifndef _VECTORMATH_INTERNAL_FUNCTIONS +#define _VECTORMATH_INTERNAL_FUNCTIONS + +static inline __m128 _vmathVfDot3( __m128 vec0, __m128 vec1 ) +{ + __m128 result = _mm_mul_ps( vec0, vec1); + return _mm_add_ps( vec_splat( result, 0 ), _mm_add_ps( vec_splat( result, 1 ), vec_splat( result, 2 ) ) ); +} + +static inline __m128 _vmathVfDot4( __m128 vec0, __m128 vec1 ) +{ + __m128 result = _mm_mul_ps(vec0, vec1); + return _mm_add_ps(_mm_shuffle_ps(result, result, _MM_SHUFFLE(0,0,0,0)), + _mm_add_ps(_mm_shuffle_ps(result, result, _MM_SHUFFLE(1,1,1,1)), + _mm_add_ps(_mm_shuffle_ps(result, result, _MM_SHUFFLE(2,2,2,2)), _mm_shuffle_ps(result, result, _MM_SHUFFLE(3,3,3,3))))); +} + +static inline __m128 _vmathVfCross( __m128 vec0, __m128 vec1 ) +{ + __m128 tmp0, tmp1, tmp2, tmp3, result; + tmp0 = _mm_shuffle_ps( vec0, vec0, _MM_SHUFFLE(3,0,2,1) ); + tmp1 = _mm_shuffle_ps( vec1, vec1, _MM_SHUFFLE(3,1,0,2) ); + tmp2 = _mm_shuffle_ps( vec0, vec0, _MM_SHUFFLE(3,1,0,2) ); + tmp3 = _mm_shuffle_ps( vec1, vec1, _MM_SHUFFLE(3,0,2,1) ); + result = vec_mul( tmp0, tmp1 ); + result = vec_nmsub( tmp2, tmp3, result ); + return result; +} +/* +static inline vec_uint4 _vmathVfToHalfFloatsUnpacked(__m128 v) +{ +#if 0 + vec_int4 bexp; + vec_uint4 mant, sign, hfloat; + vec_uint4 notZero, isInf; + const vec_uint4 hfloatInf = (vec_uint4)(0x00007c00u); + const vec_uint4 mergeMant = (vec_uint4)(0x000003ffu); + const vec_uint4 mergeSign = (vec_uint4)(0x00008000u); + + sign = vec_sr((vec_uint4)v, (vec_uint4)16); + mant = vec_sr((vec_uint4)v, (vec_uint4)13); + bexp = vec_and(vec_sr((vec_int4)v, (vec_uint4)23), (vec_int4)0xff); + + notZero = (vec_uint4)vec_cmpgt(bexp, (vec_int4)112); + isInf = (vec_uint4)vec_cmpgt(bexp, (vec_int4)142); + + bexp = _mm_add_ps(bexp, (vec_int4)-112); + bexp = vec_sl(bexp, (vec_uint4)10); + + hfloat = vec_sel((vec_uint4)bexp, mant, mergeMant); + hfloat = vec_sel((vec_uint4)(0), hfloat, notZero); + hfloat = vec_sel(hfloat, hfloatInf, isInf); + hfloat = vec_sel(hfloat, sign, mergeSign); + + return hfloat; +#else + assert(0); + return _mm_setzero_ps(); +#endif +} + +static inline vec_ushort8 _vmath2VfToHalfFloats(__m128 u, __m128 v) +{ +#if 0 + vec_uint4 hfloat_u, hfloat_v; + const vec_uchar16 pack = (vec_uchar16){2,3,6,7,10,11,14,15,18,19,22,23,26,27,30,31}; + hfloat_u = _vmathVfToHalfFloatsUnpacked(u); + hfloat_v = _vmathVfToHalfFloatsUnpacked(v); + return (vec_ushort8)vec_perm(hfloat_u, hfloat_v, pack); +#else + assert(0); + return _mm_setzero_si128(); +#endif +} +*/ + +static inline __m128 _vmathVfInsert(__m128 dst, __m128 src, int slot) +{ + SSEFloat s; + s.m128 = src; + SSEFloat d; + d.m128 = dst; + d.f[slot] = s.f[slot]; + return d.m128; +} + +#define _vmathVfSetElement(vec, scalar, slot) ((float *)&(vec))[slot] = scalar + +static inline __m128 _vmathVfSplatScalar(float scalar) +{ + return _mm_set1_ps(scalar); +} + +#endif + +namespace Vectormath { +namespace Aos { + +#ifdef _VECTORMATH_NO_SCALAR_CAST +inline VecIdx::operator floatInVec() const +{ + return floatInVec(ref, i); +} + +inline float VecIdx::getAsFloat() const +#else +inline VecIdx::operator float() const +#endif +{ + return ((float *)&ref)[i]; +} + +inline float VecIdx::operator =( float scalar ) +{ + _vmathVfSetElement(ref, scalar, i); + return scalar; +} + +inline floatInVec VecIdx::operator =( const floatInVec &scalar ) +{ + ref = _vmathVfInsert(ref, scalar.get128(), i); + return scalar; +} + +inline floatInVec VecIdx::operator =( const VecIdx& scalar ) +{ + return *this = floatInVec(scalar.ref, scalar.i); +} + +inline floatInVec VecIdx::operator *=( float scalar ) +{ + return *this *= floatInVec(scalar); +} + +inline floatInVec VecIdx::operator *=( const floatInVec &scalar ) +{ + return *this = floatInVec(ref, i) * scalar; +} + +inline floatInVec VecIdx::operator /=( float scalar ) +{ + return *this /= floatInVec(scalar); +} + +inline floatInVec VecIdx::operator /=( const floatInVec &scalar ) +{ + return *this = floatInVec(ref, i) / scalar; +} + +inline floatInVec VecIdx::operator +=( float scalar ) +{ + return *this += floatInVec(scalar); +} + +inline floatInVec VecIdx::operator +=( const floatInVec &scalar ) +{ + return *this = floatInVec(ref, i) + scalar; +} + +inline floatInVec VecIdx::operator -=( float scalar ) +{ + return *this -= floatInVec(scalar); +} + +inline floatInVec VecIdx::operator -=( const floatInVec &scalar ) +{ + return *this = floatInVec(ref, i) - scalar; +} + +inline Vector3::Vector3( float _x, float _y, float _z ) +{ + mVec128 = _mm_setr_ps(_x, _y, _z, 0.0f); +} + +inline Vector3::Vector3( const floatInVec &_x, const floatInVec &_y, const floatInVec &_z ) +{ + __m128 xz = _mm_unpacklo_ps( _x.get128(), _z.get128() ); + mVec128 = _mm_unpacklo_ps( xz, _y.get128() ); +} + +inline Vector3::Vector3( const Point3 &pnt ) +{ + mVec128 = pnt.get128(); +} + +inline Vector3::Vector3( float scalar ) +{ + mVec128 = floatInVec(scalar).get128(); +} + +inline Vector3::Vector3( const floatInVec &scalar ) +{ + mVec128 = scalar.get128(); +} + +inline Vector3::Vector3( __m128 vf4 ) +{ + mVec128 = vf4; +} + +inline const Vector3 Vector3::xAxis( ) +{ + return Vector3( _VECTORMATH_UNIT_1000 ); +} + +inline const Vector3 Vector3::yAxis( ) +{ + return Vector3( _VECTORMATH_UNIT_0100 ); +} + +inline const Vector3 Vector3::zAxis( ) +{ + return Vector3( _VECTORMATH_UNIT_0010 ); +} + +inline const Vector3 lerp( float t, const Vector3 &vec0, const Vector3 &vec1 ) +{ + return lerp( floatInVec(t), vec0, vec1 ); +} + +inline const Vector3 lerp( const floatInVec &t, const Vector3 &vec0, const Vector3 &vec1 ) +{ + return ( vec0 + ( ( vec1 - vec0 ) * t ) ); +} + +inline const Vector3 slerp( float t, const Vector3 &unitVec0, const Vector3 &unitVec1 ) +{ + return slerp( floatInVec(t), unitVec0, unitVec1 ); +} + +inline const Vector3 slerp( const floatInVec &t, const Vector3 &unitVec0, const Vector3 &unitVec1 ) +{ + __m128 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines; + cosAngle = _vmathVfDot3( unitVec0.get128(), unitVec1.get128() ); + __m128 selectMask = _mm_cmpgt_ps( _mm_set1_ps(_VECTORMATH_SLERP_TOL), cosAngle ); + angle = acosf4( cosAngle ); + tttt = t.get128(); + oneMinusT = _mm_sub_ps( _mm_set1_ps(1.0f), tttt ); + angles = _mm_unpacklo_ps( _mm_set1_ps(1.0f), tttt ); // angles = 1, t, 1, t + angles = _mm_unpacklo_ps( angles, oneMinusT ); // angles = 1, 1-t, t, 1-t + angles = _mm_mul_ps( angles, angle ); + sines = sinf4( angles ); + scales = _mm_div_ps( sines, vec_splat( sines, 0 ) ); + scale0 = vec_sel( oneMinusT, vec_splat( scales, 1 ), selectMask ); + scale1 = vec_sel( tttt, vec_splat( scales, 2 ), selectMask ); + return Vector3( vec_madd( unitVec0.get128(), scale0, _mm_mul_ps( unitVec1.get128(), scale1 ) ) ); +} + +inline __m128 Vector3::get128( ) const +{ + return mVec128; +} + +inline void storeXYZ( const Vector3 &vec, __m128 * quad ) +{ + __m128 dstVec = *quad; + __declspec(align(16)) unsigned int sw[4] = {0, 0, 0, 0xffffffff}; // TODO: Centralize + dstVec = vec_sel(vec.get128(), dstVec, sw); + *quad = dstVec; +} + +inline void loadXYZArray( Vector3 & vec0, Vector3 & vec1, Vector3 & vec2, Vector3 & vec3, const __m128 * threeQuads ) +{ + const float *quads = (float *)threeQuads; + vec0 = Vector3( _mm_load_ps(quads) ); + vec1 = Vector3( _mm_loadu_ps(quads + 3) ); + vec2 = Vector3( _mm_loadu_ps(quads + 6) ); + vec3 = Vector3( _mm_loadu_ps(quads + 9) ); +} + +inline void storeXYZArray( const Vector3 &vec0, const Vector3 &vec1, const Vector3 &vec2, const Vector3 &vec3, __m128 * threeQuads ) +{ + __m128 xxxx = _mm_shuffle_ps( vec1.get128(), vec1.get128(), _MM_SHUFFLE(0, 0, 0, 0) ); + __m128 zzzz = _mm_shuffle_ps( vec2.get128(), vec2.get128(), _MM_SHUFFLE(2, 2, 2, 2) ); + __declspec(align(16)) unsigned int xsw[4] = {0, 0, 0, 0xffffffff}; + __declspec(align(16)) unsigned int zsw[4] = {0xffffffff, 0, 0, 0}; + threeQuads[0] = vec_sel( vec0.get128(), xxxx, xsw ); + threeQuads[1] = _mm_shuffle_ps( vec1.get128(), vec2.get128(), _MM_SHUFFLE(1, 0, 2, 1) ); + threeQuads[2] = vec_sel( _mm_shuffle_ps( vec3.get128(), vec3.get128(), _MM_SHUFFLE(2, 1, 0, 3) ), zzzz, zsw ); +} +/* +inline void storeHalfFloats( const Vector3 &vec0, const Vector3 &vec1, const Vector3 &vec2, const Vector3 &vec3, const Vector3 &vec4, const Vector3 &vec5, const Vector3 &vec6, const Vector3 &vec7, vec_ushort8 * threeQuads ) +{ + assert(0); +#if 0 + __m128 xyz0[3]; + __m128 xyz1[3]; + storeXYZArray( vec0, vec1, vec2, vec3, xyz0 ); + storeXYZArray( vec4, vec5, vec6, vec7, xyz1 ); + threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); + threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); + threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); +#endif +} +*/ +inline Vector3 & Vector3::operator =( const Vector3 &vec ) +{ + mVec128 = vec.mVec128; + return *this; +} + +inline Vector3 & Vector3::setX( float _x ) +{ + _vmathVfSetElement(mVec128, _x, 0); + return *this; +} + +inline Vector3 & Vector3::setX( const floatInVec &_x ) +{ + mVec128 = _vmathVfInsert(mVec128, _x.get128(), 0); + return *this; +} + +inline const floatInVec Vector3::getX( ) const +{ + return floatInVec( mVec128, 0 ); +} + +inline Vector3 & Vector3::setY( float _y ) +{ + _vmathVfSetElement(mVec128, _y, 1); + return *this; +} + +inline Vector3 & Vector3::setY( const floatInVec &_y ) +{ + mVec128 = _vmathVfInsert(mVec128, _y.get128(), 1); + return *this; +} + +inline const floatInVec Vector3::getY( ) const +{ + return floatInVec( mVec128, 1 ); +} + +inline Vector3 & Vector3::setZ( float _z ) +{ + _vmathVfSetElement(mVec128, _z, 2); + return *this; +} + +inline Vector3 & Vector3::setZ( const floatInVec &_z ) +{ + mVec128 = _vmathVfInsert(mVec128, _z.get128(), 2); + return *this; +} + +inline const floatInVec Vector3::getZ( ) const +{ + return floatInVec( mVec128, 2 ); +} + +inline Vector3 & Vector3::setElem( int idx, float value ) +{ + _vmathVfSetElement(mVec128, value, idx); + return *this; +} + +inline Vector3 & Vector3::setElem( int idx, const floatInVec &value ) +{ + mVec128 = _vmathVfInsert(mVec128, value.get128(), idx); + return *this; +} + +inline const floatInVec Vector3::getElem( int idx ) const +{ + return floatInVec( mVec128, idx ); +} + +inline VecIdx Vector3::operator []( int idx ) +{ + return VecIdx( mVec128, idx ); +} + +inline const floatInVec Vector3::operator []( int idx ) const +{ + return floatInVec( mVec128, idx ); +} + +inline const Vector3 Vector3::operator +( const Vector3 &vec ) const +{ + return Vector3( _mm_add_ps( mVec128, vec.mVec128 ) ); +} + +inline const Vector3 Vector3::operator -( const Vector3 &vec ) const +{ + return Vector3( _mm_sub_ps( mVec128, vec.mVec128 ) ); +} + +inline const Point3 Vector3::operator +( const Point3 &pnt ) const +{ + return Point3( _mm_add_ps( mVec128, pnt.get128() ) ); +} + +inline const Vector3 Vector3::operator *( float scalar ) const +{ + return *this * floatInVec(scalar); +} + +inline const Vector3 Vector3::operator *( const floatInVec &scalar ) const +{ + return Vector3( _mm_mul_ps( mVec128, scalar.get128() ) ); +} + +inline Vector3 & Vector3::operator +=( const Vector3 &vec ) +{ + *this = *this + vec; + return *this; +} + +inline Vector3 & Vector3::operator -=( const Vector3 &vec ) +{ + *this = *this - vec; + return *this; +} + +inline Vector3 & Vector3::operator *=( float scalar ) +{ + *this = *this * scalar; + return *this; +} + +inline Vector3 & Vector3::operator *=( const floatInVec &scalar ) +{ + *this = *this * scalar; + return *this; +} + +inline const Vector3 Vector3::operator /( float scalar ) const +{ + return *this / floatInVec(scalar); +} + +inline const Vector3 Vector3::operator /( const floatInVec &scalar ) const +{ + return Vector3( _mm_div_ps( mVec128, scalar.get128() ) ); +} + +inline Vector3 & Vector3::operator /=( float scalar ) +{ + *this = *this / scalar; + return *this; +} + +inline Vector3 & Vector3::operator /=( const floatInVec &scalar ) +{ + *this = *this / scalar; + return *this; +} + +inline const Vector3 Vector3::operator -( ) const +{ + return Vector3(_mm_sub_ps( _mm_setzero_ps(), mVec128 ) ); +} + +inline const Vector3 operator *( float scalar, const Vector3 &vec ) +{ + return floatInVec(scalar) * vec; +} + +inline const Vector3 operator *( const floatInVec &scalar, const Vector3 &vec ) +{ + return vec * scalar; +} + +inline const Vector3 mulPerElem( const Vector3 &vec0, const Vector3 &vec1 ) +{ + return Vector3( _mm_mul_ps( vec0.get128(), vec1.get128() ) ); +} + +inline const Vector3 divPerElem( const Vector3 &vec0, const Vector3 &vec1 ) +{ + return Vector3( _mm_div_ps( vec0.get128(), vec1.get128() ) ); +} + +inline const Vector3 recipPerElem( const Vector3 &vec ) +{ + return Vector3( _mm_rcp_ps( vec.get128() ) ); +} + +inline const Vector3 absPerElem( const Vector3 &vec ) +{ + return Vector3( fabsf4( vec.get128() ) ); +} + +inline const Vector3 copySignPerElem( const Vector3 &vec0, const Vector3 &vec1 ) +{ + __m128 vmask = toM128(0x7fffffff); + return Vector3( _mm_or_ps( + _mm_and_ps ( vmask, vec0.get128() ), // Value + _mm_andnot_ps( vmask, vec1.get128() ) ) ); // Signs +} + +inline const Vector3 maxPerElem( const Vector3 &vec0, const Vector3 &vec1 ) +{ + return Vector3( _mm_max_ps( vec0.get128(), vec1.get128() ) ); +} + +inline const floatInVec maxElem( const Vector3 &vec ) +{ + return floatInVec( _mm_max_ps( _mm_max_ps( vec_splat( vec.get128(), 0 ), vec_splat( vec.get128(), 1 ) ), vec_splat( vec.get128(), 2 ) ) ); +} + +inline const Vector3 minPerElem( const Vector3 &vec0, const Vector3 &vec1 ) +{ + return Vector3( _mm_min_ps( vec0.get128(), vec1.get128() ) ); +} + +inline const floatInVec minElem( const Vector3 &vec ) +{ + return floatInVec( _mm_min_ps( _mm_min_ps( vec_splat( vec.get128(), 0 ), vec_splat( vec.get128(), 1 ) ), vec_splat( vec.get128(), 2 ) ) ); +} + +inline const floatInVec sum( const Vector3 &vec ) +{ + return floatInVec( _mm_add_ps( _mm_add_ps( vec_splat( vec.get128(), 0 ), vec_splat( vec.get128(), 1 ) ), vec_splat( vec.get128(), 2 ) ) ); +} + +inline const floatInVec dot( const Vector3 &vec0, const Vector3 &vec1 ) +{ + return floatInVec( _vmathVfDot3( vec0.get128(), vec1.get128() ), 0 ); +} + +inline const floatInVec lengthSqr( const Vector3 &vec ) +{ + return floatInVec( _vmathVfDot3( vec.get128(), vec.get128() ), 0 ); +} + +inline const floatInVec length( const Vector3 &vec ) +{ + return floatInVec( _mm_sqrt_ps(_vmathVfDot3( vec.get128(), vec.get128() )), 0 ); +} + + +inline const Vector3 normalizeApprox( const Vector3 &vec ) +{ + return Vector3( _mm_mul_ps( vec.get128(), _mm_rsqrt_ps( _vmathVfDot3( vec.get128(), vec.get128() ) ) ) ); +} + +inline const Vector3 normalize( const Vector3 &vec ) +{ + return Vector3( _mm_mul_ps( vec.get128(), newtonrapson_rsqrt4( _vmathVfDot3( vec.get128(), vec.get128() ) ) ) ); +} + +inline const Vector3 cross( const Vector3 &vec0, const Vector3 &vec1 ) +{ + return Vector3( _vmathVfCross( vec0.get128(), vec1.get128() ) ); +} + +inline const Vector3 select( const Vector3 &vec0, const Vector3 &vec1, bool select1 ) +{ + return select( vec0, vec1, boolInVec(select1) ); +} + +inline const Vector3 select( const Vector3 &vec0, const Vector3 &vec1, const boolInVec &select1 ) +{ + return Vector3(vec_sel( vec0.get128(), vec1.get128(), select1.get128() )); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( const Vector3 &vec ) +{ + union { __m128 v; float s[4]; } tmp; + tmp.v = vec.get128(); + printf( "( %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2] ); +} + +inline void print( const Vector3 &vec, const char * name ) +{ + union { __m128 v; float s[4]; } tmp; + tmp.v = vec.get128(); + printf( "%s: ( %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2] ); +} + +#endif + +inline Vector4::Vector4( float _x, float _y, float _z, float _w ) +{ + mVec128 = _mm_setr_ps(_x, _y, _z, _w); + } + +inline Vector4::Vector4( const floatInVec &_x, const floatInVec &_y, const floatInVec &_z, const floatInVec &_w ) +{ + mVec128 = _mm_unpacklo_ps( + _mm_unpacklo_ps( _x.get128(), _z.get128() ), + _mm_unpacklo_ps( _y.get128(), _w.get128() ) ); +} + +inline Vector4::Vector4( const Vector3 &xyz, float _w ) +{ + mVec128 = xyz.get128(); + _vmathVfSetElement(mVec128, _w, 3); +} + +inline Vector4::Vector4( const Vector3 &xyz, const floatInVec &_w ) +{ + mVec128 = xyz.get128(); + mVec128 = _vmathVfInsert(mVec128, _w.get128(), 3); +} + +inline Vector4::Vector4( const Vector3 &vec ) +{ + mVec128 = vec.get128(); + mVec128 = _vmathVfInsert(mVec128, _mm_setzero_ps(), 3); +} + +inline Vector4::Vector4( const Point3 &pnt ) +{ + mVec128 = pnt.get128(); + mVec128 = _vmathVfInsert(mVec128, _mm_set1_ps(1.0f), 3); +} + +inline Vector4::Vector4( const Quat &quat ) +{ + mVec128 = quat.get128(); +} + +inline Vector4::Vector4( float scalar ) +{ + mVec128 = floatInVec(scalar).get128(); +} + +inline Vector4::Vector4( const floatInVec &scalar ) +{ + mVec128 = scalar.get128(); +} + +inline Vector4::Vector4( __m128 vf4 ) +{ + mVec128 = vf4; +} + +inline const Vector4 Vector4::xAxis( ) +{ + return Vector4( _VECTORMATH_UNIT_1000 ); +} + +inline const Vector4 Vector4::yAxis( ) +{ + return Vector4( _VECTORMATH_UNIT_0100 ); +} + +inline const Vector4 Vector4::zAxis( ) +{ + return Vector4( _VECTORMATH_UNIT_0010 ); +} + +inline const Vector4 Vector4::wAxis( ) +{ + return Vector4( _VECTORMATH_UNIT_0001 ); +} + +inline const Vector4 lerp( float t, const Vector4 &vec0, const Vector4 &vec1 ) +{ + return lerp( floatInVec(t), vec0, vec1 ); +} + +inline const Vector4 lerp( const floatInVec &t, const Vector4 &vec0, const Vector4 &vec1 ) +{ + return ( vec0 + ( ( vec1 - vec0 ) * t ) ); +} + +inline const Vector4 slerp( float t, const Vector4 &unitVec0, const Vector4 &unitVec1 ) +{ + return slerp( floatInVec(t), unitVec0, unitVec1 ); +} + +inline const Vector4 slerp( const floatInVec &t, const Vector4 &unitVec0, const Vector4 &unitVec1 ) +{ + __m128 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines; + cosAngle = _vmathVfDot4( unitVec0.get128(), unitVec1.get128() ); + __m128 selectMask = _mm_cmpgt_ps( _mm_set1_ps(_VECTORMATH_SLERP_TOL), cosAngle ); + angle = acosf4( cosAngle ); + tttt = t.get128(); + oneMinusT = _mm_sub_ps( _mm_set1_ps(1.0f), tttt ); + angles = _mm_unpacklo_ps( _mm_set1_ps(1.0f), tttt ); // angles = 1, t, 1, t + angles = _mm_unpacklo_ps( angles, oneMinusT ); // angles = 1, 1-t, t, 1-t + angles = _mm_mul_ps( angles, angle ); + sines = sinf4( angles ); + scales = _mm_div_ps( sines, vec_splat( sines, 0 ) ); + scale0 = vec_sel( oneMinusT, vec_splat( scales, 1 ), selectMask ); + scale1 = vec_sel( tttt, vec_splat( scales, 2 ), selectMask ); + return Vector4( vec_madd( unitVec0.get128(), scale0, _mm_mul_ps( unitVec1.get128(), scale1 ) ) ); +} + +inline __m128 Vector4::get128( ) const +{ + return mVec128; +} +/* +inline void storeHalfFloats( const Vector4 &vec0, const Vector4 &vec1, const Vector4 &vec2, const Vector4 &vec3, vec_ushort8 * twoQuads ) +{ + twoQuads[0] = _vmath2VfToHalfFloats(vec0.get128(), vec1.get128()); + twoQuads[1] = _vmath2VfToHalfFloats(vec2.get128(), vec3.get128()); +} +*/ +inline Vector4 & Vector4::operator =( const Vector4 &vec ) +{ + mVec128 = vec.mVec128; + return *this; +} + +inline Vector4 & Vector4::setXYZ( const Vector3 &vec ) +{ + __declspec(align(16)) unsigned int sw[4] = {0, 0, 0, 0xffffffff}; + mVec128 = vec_sel( vec.get128(), mVec128, sw ); + return *this; +} + +inline const Vector3 Vector4::getXYZ( ) const +{ + return Vector3( mVec128 ); +} + +inline Vector4 & Vector4::setX( float _x ) +{ + _vmathVfSetElement(mVec128, _x, 0); + return *this; +} + +inline Vector4 & Vector4::setX( const floatInVec &_x ) +{ + mVec128 = _vmathVfInsert(mVec128, _x.get128(), 0); + return *this; +} + +inline const floatInVec Vector4::getX( ) const +{ + return floatInVec( mVec128, 0 ); +} + +inline Vector4 & Vector4::setY( float _y ) +{ + _vmathVfSetElement(mVec128, _y, 1); + return *this; +} + +inline Vector4 & Vector4::setY( const floatInVec &_y ) +{ + mVec128 = _vmathVfInsert(mVec128, _y.get128(), 1); + return *this; +} + +inline const floatInVec Vector4::getY( ) const +{ + return floatInVec( mVec128, 1 ); +} + +inline Vector4 & Vector4::setZ( float _z ) +{ + _vmathVfSetElement(mVec128, _z, 2); + return *this; +} + +inline Vector4 & Vector4::setZ( const floatInVec &_z ) +{ + mVec128 = _vmathVfInsert(mVec128, _z.get128(), 2); + return *this; +} + +inline const floatInVec Vector4::getZ( ) const +{ + return floatInVec( mVec128, 2 ); +} + +inline Vector4 & Vector4::setW( float _w ) +{ + _vmathVfSetElement(mVec128, _w, 3); + return *this; +} + +inline Vector4 & Vector4::setW( const floatInVec &_w ) +{ + mVec128 = _vmathVfInsert(mVec128, _w.get128(), 3); + return *this; +} + +inline const floatInVec Vector4::getW( ) const +{ + return floatInVec( mVec128, 3 ); +} + +inline Vector4 & Vector4::setElem( int idx, float value ) +{ + _vmathVfSetElement(mVec128, value, idx); + return *this; +} + +inline Vector4 & Vector4::setElem( int idx, const floatInVec &value ) +{ + mVec128 = _vmathVfInsert(mVec128, value.get128(), idx); + return *this; +} + +inline const floatInVec Vector4::getElem( int idx ) const +{ + return floatInVec( mVec128, idx ); +} + +inline VecIdx Vector4::operator []( int idx ) +{ + return VecIdx( mVec128, idx ); +} + +inline const floatInVec Vector4::operator []( int idx ) const +{ + return floatInVec( mVec128, idx ); +} + +inline const Vector4 Vector4::operator +( const Vector4 &vec ) const +{ + return Vector4( _mm_add_ps( mVec128, vec.mVec128 ) ); +} + +inline const Vector4 Vector4::operator -( const Vector4 &vec ) const +{ + return Vector4( _mm_sub_ps( mVec128, vec.mVec128 ) ); +} + +inline const Vector4 Vector4::operator *( float scalar ) const +{ + return *this * floatInVec(scalar); +} + +inline const Vector4 Vector4::operator *( const floatInVec &scalar ) const +{ + return Vector4( _mm_mul_ps( mVec128, scalar.get128() ) ); +} + +inline Vector4 & Vector4::operator +=( const Vector4 &vec ) +{ + *this = *this + vec; + return *this; +} + +inline Vector4 & Vector4::operator -=( const Vector4 &vec ) +{ + *this = *this - vec; + return *this; +} + +inline Vector4 & Vector4::operator *=( float scalar ) +{ + *this = *this * scalar; + return *this; +} + +inline Vector4 & Vector4::operator *=( const floatInVec &scalar ) +{ + *this = *this * scalar; + return *this; +} + +inline const Vector4 Vector4::operator /( float scalar ) const +{ + return *this / floatInVec(scalar); +} + +inline const Vector4 Vector4::operator /( const floatInVec &scalar ) const +{ + return Vector4( _mm_div_ps( mVec128, scalar.get128() ) ); +} + +inline Vector4 & Vector4::operator /=( float scalar ) +{ + *this = *this / scalar; + return *this; +} + +inline Vector4 & Vector4::operator /=( const floatInVec &scalar ) +{ + *this = *this / scalar; + return *this; +} + +inline const Vector4 Vector4::operator -( ) const +{ + return Vector4(_mm_sub_ps( _mm_setzero_ps(), mVec128 ) ); +} + +inline const Vector4 operator *( float scalar, const Vector4 &vec ) +{ + return floatInVec(scalar) * vec; +} + +inline const Vector4 operator *( const floatInVec &scalar, const Vector4 &vec ) +{ + return vec * scalar; +} + +inline const Vector4 mulPerElem( const Vector4 &vec0, const Vector4 &vec1 ) +{ + return Vector4( _mm_mul_ps( vec0.get128(), vec1.get128() ) ); +} + +inline const Vector4 divPerElem( const Vector4 &vec0, const Vector4 &vec1 ) +{ + return Vector4( _mm_div_ps( vec0.get128(), vec1.get128() ) ); +} + +inline const Vector4 recipPerElem( const Vector4 &vec ) +{ + return Vector4( _mm_rcp_ps( vec.get128() ) ); +} + +inline const Vector4 absPerElem( const Vector4 &vec ) +{ + return Vector4( fabsf4( vec.get128() ) ); +} + +inline const Vector4 copySignPerElem( const Vector4 &vec0, const Vector4 &vec1 ) +{ + __m128 vmask = toM128(0x7fffffff); + return Vector4( _mm_or_ps( + _mm_and_ps ( vmask, vec0.get128() ), // Value + _mm_andnot_ps( vmask, vec1.get128() ) ) ); // Signs +} + +inline const Vector4 maxPerElem( const Vector4 &vec0, const Vector4 &vec1 ) +{ + return Vector4( _mm_max_ps( vec0.get128(), vec1.get128() ) ); +} + +inline const floatInVec maxElem( const Vector4 &vec ) +{ + return floatInVec( _mm_max_ps( + _mm_max_ps( vec_splat( vec.get128(), 0 ), vec_splat( vec.get128(), 1 ) ), + _mm_max_ps( vec_splat( vec.get128(), 2 ), vec_splat( vec.get128(), 3 ) ) ) ); +} + +inline const Vector4 minPerElem( const Vector4 &vec0, const Vector4 &vec1 ) +{ + return Vector4( _mm_min_ps( vec0.get128(), vec1.get128() ) ); +} + +inline const floatInVec minElem( const Vector4 &vec ) +{ + return floatInVec( _mm_min_ps( + _mm_min_ps( vec_splat( vec.get128(), 0 ), vec_splat( vec.get128(), 1 ) ), + _mm_min_ps( vec_splat( vec.get128(), 2 ), vec_splat( vec.get128(), 3 ) ) ) ); +} + +inline const floatInVec sum( const Vector4 &vec ) +{ + return floatInVec( _mm_add_ps( + _mm_add_ps( vec_splat( vec.get128(), 0 ), vec_splat( vec.get128(), 1 ) ), + _mm_add_ps( vec_splat( vec.get128(), 2 ), vec_splat( vec.get128(), 3 ) ) ) ); +} + +inline const floatInVec dot( const Vector4 &vec0, const Vector4 &vec1 ) +{ + return floatInVec( _vmathVfDot4( vec0.get128(), vec1.get128() ), 0 ); +} + +inline const floatInVec lengthSqr( const Vector4 &vec ) +{ + return floatInVec( _vmathVfDot4( vec.get128(), vec.get128() ), 0 ); +} + +inline const floatInVec length( const Vector4 &vec ) +{ + return floatInVec( _mm_sqrt_ps(_vmathVfDot4( vec.get128(), vec.get128() )), 0 ); +} + +inline const Vector4 normalizeApprox( const Vector4 &vec ) +{ + return Vector4( _mm_mul_ps( vec.get128(), _mm_rsqrt_ps( _vmathVfDot4( vec.get128(), vec.get128() ) ) ) ); +} + +inline const Vector4 normalize( const Vector4 &vec ) +{ + return Vector4( _mm_mul_ps( vec.get128(), newtonrapson_rsqrt4( _vmathVfDot4( vec.get128(), vec.get128() ) ) ) ); +} + +inline const Vector4 select( const Vector4 &vec0, const Vector4 &vec1, bool select1 ) +{ + return select( vec0, vec1, boolInVec(select1) ); +} + +inline const Vector4 select( const Vector4 &vec0, const Vector4 &vec1, const boolInVec &select1 ) +{ + return Vector4( vec_sel( vec0.get128(), vec1.get128(), select1.get128() ) ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( const Vector4 &vec ) +{ + union { __m128 v; float s[4]; } tmp; + tmp.v = vec.get128(); + printf( "( %f %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] ); +} + +inline void print( const Vector4 &vec, const char * name ) +{ + union { __m128 v; float s[4]; } tmp; + tmp.v = vec.get128(); + printf( "%s: ( %f %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] ); +} + +#endif + +inline Point3::Point3( float _x, float _y, float _z ) +{ + mVec128 = _mm_setr_ps(_x, _y, _z, 0.0f); +} + +inline Point3::Point3( const floatInVec &_x, const floatInVec &_y, const floatInVec &_z ) +{ + mVec128 = _mm_unpacklo_ps( _mm_unpacklo_ps( _x.get128(), _z.get128() ), _y.get128() ); +} + +inline Point3::Point3( const Vector3 &vec ) +{ + mVec128 = vec.get128(); +} + +inline Point3::Point3( float scalar ) +{ + mVec128 = floatInVec(scalar).get128(); +} + +inline Point3::Point3( const floatInVec &scalar ) +{ + mVec128 = scalar.get128(); +} + +inline Point3::Point3( __m128 vf4 ) +{ + mVec128 = vf4; +} + +inline const Point3 lerp( float t, const Point3 &pnt0, const Point3 &pnt1 ) +{ + return lerp( floatInVec(t), pnt0, pnt1 ); +} + +inline const Point3 lerp( const floatInVec &t, const Point3 &pnt0, const Point3 &pnt1 ) +{ + return ( pnt0 + ( ( pnt1 - pnt0 ) * t ) ); +} + +inline __m128 Point3::get128( ) const +{ + return mVec128; +} + +inline void storeXYZ( const Point3 &pnt, __m128 * quad ) +{ + __m128 dstVec = *quad; + __declspec(align(16)) unsigned int sw[4] = {0, 0, 0, 0xffffffff}; // TODO: Centralize + dstVec = vec_sel(pnt.get128(), dstVec, sw); + *quad = dstVec; +} + +inline void loadXYZArray( Point3 & pnt0, Point3 & pnt1, Point3 & pnt2, Point3 & pnt3, const __m128 * threeQuads ) +{ + const float *quads = (float *)threeQuads; + pnt0 = Point3( _mm_load_ps(quads) ); + pnt1 = Point3( _mm_loadu_ps(quads + 3) ); + pnt2 = Point3( _mm_loadu_ps(quads + 6) ); + pnt3 = Point3( _mm_loadu_ps(quads + 9) ); +} + +inline void storeXYZArray( const Point3 &pnt0, const Point3 &pnt1, const Point3 &pnt2, const Point3 &pnt3, __m128 * threeQuads ) +{ + __m128 xxxx = _mm_shuffle_ps( pnt1.get128(), pnt1.get128(), _MM_SHUFFLE(0, 0, 0, 0) ); + __m128 zzzz = _mm_shuffle_ps( pnt2.get128(), pnt2.get128(), _MM_SHUFFLE(2, 2, 2, 2) ); + __declspec(align(16)) unsigned int xsw[4] = {0, 0, 0, 0xffffffff}; + __declspec(align(16)) unsigned int zsw[4] = {0xffffffff, 0, 0, 0}; + threeQuads[0] = vec_sel( pnt0.get128(), xxxx, xsw ); + threeQuads[1] = _mm_shuffle_ps( pnt1.get128(), pnt2.get128(), _MM_SHUFFLE(1, 0, 2, 1) ); + threeQuads[2] = vec_sel( _mm_shuffle_ps( pnt3.get128(), pnt3.get128(), _MM_SHUFFLE(2, 1, 0, 3) ), zzzz, zsw ); +} +/* +inline void storeHalfFloats( const Point3 &pnt0, const Point3 &pnt1, const Point3 &pnt2, const Point3 &pnt3, const Point3 &pnt4, const Point3 &pnt5, const Point3 &pnt6, const Point3 &pnt7, vec_ushort8 * threeQuads ) +{ +#if 0 + __m128 xyz0[3]; + __m128 xyz1[3]; + storeXYZArray( pnt0, pnt1, pnt2, pnt3, xyz0 ); + storeXYZArray( pnt4, pnt5, pnt6, pnt7, xyz1 ); + threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); + threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); + threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); +#else + assert(0); +#endif +} +*/ +inline Point3 & Point3::operator =( const Point3 &pnt ) +{ + mVec128 = pnt.mVec128; + return *this; +} + +inline Point3 & Point3::setX( float _x ) +{ + _vmathVfSetElement(mVec128, _x, 0); + return *this; +} + +inline Point3 & Point3::setX( const floatInVec &_x ) +{ + mVec128 = _vmathVfInsert(mVec128, _x.get128(), 0); + return *this; +} + +inline const floatInVec Point3::getX( ) const +{ + return floatInVec( mVec128, 0 ); +} + +inline Point3 & Point3::setY( float _y ) +{ + _vmathVfSetElement(mVec128, _y, 1); + return *this; +} + +inline Point3 & Point3::setY( const floatInVec &_y ) +{ + mVec128 = _vmathVfInsert(mVec128, _y.get128(), 1); + return *this; +} + +inline const floatInVec Point3::getY( ) const +{ + return floatInVec( mVec128, 1 ); +} + +inline Point3 & Point3::setZ( float _z ) +{ + _vmathVfSetElement(mVec128, _z, 2); + return *this; +} + +inline Point3 & Point3::setZ( const floatInVec &_z ) +{ + mVec128 = _vmathVfInsert(mVec128, _z.get128(), 2); + return *this; +} + +inline const floatInVec Point3::getZ( ) const +{ + return floatInVec( mVec128, 2 ); +} + +inline Point3 & Point3::setElem( int idx, float value ) +{ + _vmathVfSetElement(mVec128, value, idx); + return *this; +} + +inline Point3 & Point3::setElem( int idx, const floatInVec &value ) +{ + mVec128 = _vmathVfInsert(mVec128, value.get128(), idx); + return *this; +} + +inline const floatInVec Point3::getElem( int idx ) const +{ + return floatInVec( mVec128, idx ); +} + +inline VecIdx Point3::operator []( int idx ) +{ + return VecIdx( mVec128, idx ); +} + +inline const floatInVec Point3::operator []( int idx ) const +{ + return floatInVec( mVec128, idx ); +} + +inline const Vector3 Point3::operator -( const Point3 &pnt ) const +{ + return Vector3( _mm_sub_ps( mVec128, pnt.mVec128 ) ); +} + +inline const Point3 Point3::operator +( const Vector3 &vec ) const +{ + return Point3( _mm_add_ps( mVec128, vec.get128() ) ); +} + +inline const Point3 Point3::operator -( const Vector3 &vec ) const +{ + return Point3( _mm_sub_ps( mVec128, vec.get128() ) ); +} + +inline Point3 & Point3::operator +=( const Vector3 &vec ) +{ + *this = *this + vec; + return *this; +} + +inline Point3 & Point3::operator -=( const Vector3 &vec ) +{ + *this = *this - vec; + return *this; +} + +inline const Point3 mulPerElem( const Point3 &pnt0, const Point3 &pnt1 ) +{ + return Point3( _mm_mul_ps( pnt0.get128(), pnt1.get128() ) ); +} + +inline const Point3 divPerElem( const Point3 &pnt0, const Point3 &pnt1 ) +{ + return Point3( _mm_div_ps( pnt0.get128(), pnt1.get128() ) ); +} + +inline const Point3 recipPerElem( const Point3 &pnt ) +{ + return Point3( _mm_rcp_ps( pnt.get128() ) ); +} + +inline const Point3 absPerElem( const Point3 &pnt ) +{ + return Point3( fabsf4( pnt.get128() ) ); +} + +inline const Point3 copySignPerElem( const Point3 &pnt0, const Point3 &pnt1 ) +{ + __m128 vmask = toM128(0x7fffffff); + return Point3( _mm_or_ps( + _mm_and_ps ( vmask, pnt0.get128() ), // Value + _mm_andnot_ps( vmask, pnt1.get128() ) ) ); // Signs +} + +inline const Point3 maxPerElem( const Point3 &pnt0, const Point3 &pnt1 ) +{ + return Point3( _mm_max_ps( pnt0.get128(), pnt1.get128() ) ); +} + +inline const floatInVec maxElem( const Point3 &pnt ) +{ + return floatInVec( _mm_max_ps( _mm_max_ps( vec_splat( pnt.get128(), 0 ), vec_splat( pnt.get128(), 1 ) ), vec_splat( pnt.get128(), 2 ) ) ); +} + +inline const Point3 minPerElem( const Point3 &pnt0, const Point3 &pnt1 ) +{ + return Point3( _mm_min_ps( pnt0.get128(), pnt1.get128() ) ); +} + +inline const floatInVec minElem( const Point3 &pnt ) +{ + return floatInVec( _mm_min_ps( _mm_min_ps( vec_splat( pnt.get128(), 0 ), vec_splat( pnt.get128(), 1 ) ), vec_splat( pnt.get128(), 2 ) ) ); +} + +inline const floatInVec sum( const Point3 &pnt ) +{ + return floatInVec( _mm_add_ps( _mm_add_ps( vec_splat( pnt.get128(), 0 ), vec_splat( pnt.get128(), 1 ) ), vec_splat( pnt.get128(), 2 ) ) ); +} + +inline const Point3 scale( const Point3 &pnt, float scaleVal ) +{ + return scale( pnt, floatInVec( scaleVal ) ); +} + +inline const Point3 scale( const Point3 &pnt, const floatInVec &scaleVal ) +{ + return mulPerElem( pnt, Point3( scaleVal ) ); +} + +inline const Point3 scale( const Point3 &pnt, const Vector3 &scaleVec ) +{ + return mulPerElem( pnt, Point3( scaleVec ) ); +} + +inline const floatInVec projection( const Point3 &pnt, const Vector3 &unitVec ) +{ + return floatInVec( _vmathVfDot3( pnt.get128(), unitVec.get128() ), 0 ); +} + +inline const floatInVec distSqrFromOrigin( const Point3 &pnt ) +{ + return lengthSqr( Vector3( pnt ) ); +} + +inline const floatInVec distFromOrigin( const Point3 &pnt ) +{ + return length( Vector3( pnt ) ); +} + +inline const floatInVec distSqr( const Point3 &pnt0, const Point3 &pnt1 ) +{ + return lengthSqr( ( pnt1 - pnt0 ) ); +} + +inline const floatInVec dist( const Point3 &pnt0, const Point3 &pnt1 ) +{ + return length( ( pnt1 - pnt0 ) ); +} + +inline const Point3 select( const Point3 &pnt0, const Point3 &pnt1, bool select1 ) +{ + return select( pnt0, pnt1, boolInVec(select1) ); +} + +inline const Point3 select( const Point3 &pnt0, const Point3 &pnt1, const boolInVec &select1 ) +{ + return Point3( vec_sel( pnt0.get128(), pnt1.get128(), select1.get128() ) ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( const Point3 &pnt ) +{ + union { __m128 v; float s[4]; } tmp; + tmp.v = pnt.get128(); + printf( "( %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2] ); +} + +inline void print( const Point3 &pnt, const char * name ) +{ + union { __m128 v; float s[4]; } tmp; + tmp.v = pnt.get128(); + printf( "%s: ( %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2] ); +} + +#endif + +} // namespace Aos +} // namespace Vectormath + +#endif diff --git a/vectormathlibrary/include/vectormath/SSE/cpp/vecidx_aos.h b/vectormathlibrary/include/vectormath/SSE/cpp/vecidx_aos.h new file mode 100644 index 000000000..14dc408d0 --- /dev/null +++ b/vectormathlibrary/include/vectormath/SSE/cpp/vecidx_aos.h @@ -0,0 +1,80 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_VECIDX_AOS_H +#define _VECTORMATH_VECIDX_AOS_H + + +#include "floatInVec.h" + +namespace Vectormath { +namespace Aos { + +//----------------------------------------------------------------------------- +// VecIdx +// Used in setting elements of Vector3, Vector4, Point3, or Quat with the +// subscripting operator. +// + +__declspec(align(16)) class VecIdx +{ +private: + __m128 &ref; + int i; +public: + inline VecIdx( __m128& vec, int idx ): ref(vec) { i = idx; } + + // implicitly casts to float unless _VECTORMATH_NO_SCALAR_CAST defined + // in which case, implicitly casts to floatInVec, and one must call + // getAsFloat to convert to float. + // +#ifdef _VECTORMATH_NO_SCALAR_CAST + inline operator floatInVec() const; + inline float getAsFloat() const; +#else + inline operator float() const; +#endif + + inline float operator =( float scalar ); + inline floatInVec operator =( const floatInVec &scalar ); + inline floatInVec operator =( const VecIdx& scalar ); + inline floatInVec operator *=( float scalar ); + inline floatInVec operator *=( const floatInVec &scalar ); + inline floatInVec operator /=( float scalar ); + inline floatInVec operator /=( const floatInVec &scalar ); + inline floatInVec operator +=( float scalar ); + inline floatInVec operator +=( const floatInVec &scalar ); + inline floatInVec operator -=( float scalar ); + inline floatInVec operator -=( const floatInVec &scalar ); +}; + +} // namespace Aos +} // namespace Vectormath + +#endif diff --git a/vectormathlibrary/include/vectormath/SSE/cpp/vectormath_aos.h b/vectormathlibrary/include/vectormath/SSE/cpp/vectormath_aos.h new file mode 100644 index 000000000..d68e312ac --- /dev/null +++ b/vectormathlibrary/include/vectormath/SSE/cpp/vectormath_aos.h @@ -0,0 +1,2499 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_AOS_CPP_SSE_H +#define _VECTORMATH_AOS_CPP_SSE_H + +#include <math.h> +#include <xmmintrin.h> +#include <emmintrin.h> +#include <assert.h> + +#define _VECTORMATH_DEBUG + +// TODO: Tidy +typedef __m128 vec_float4; +typedef __m128 vec_uint4; +typedef __m128 vec_int4; +typedef __m128i vec_uchar16; +typedef __m128i vec_ushort8; + +#define vec_splat(x, e) _mm_shuffle_ps(x, x, _MM_SHUFFLE(e,e,e,e)) + +#define _mm_ror_ps(vec,i) \ + (((i)%4) ? (_mm_shuffle_ps(vec,vec, _MM_SHUFFLE((unsigned char)(i+3)%4,(unsigned char)(i+2)%4,(unsigned char)(i+1)%4,(unsigned char)(i+0)%4))) : (vec)) +#define _mm_rol_ps(vec,i) \ + (((i)%4) ? (_mm_shuffle_ps(vec,vec, _MM_SHUFFLE((unsigned char)(7-i)%4,(unsigned char)(6-i)%4,(unsigned char)(5-i)%4,(unsigned char)(4-i)%4))) : (vec)) + +#define vec_sld(vec,vec2,x) _mm_ror_ps(vec, ((x)/4)) + +#define _mm_abs_ps(vec) _mm_andnot_ps(_MASKSIGN_,vec) +#define _mm_neg_ps(vec) _mm_xor_ps(_MASKSIGN_,vec) + +#define vec_madd(a, b, c) _mm_add_ps(c, _mm_mul_ps(a, b) ) + +union SSEFloat +{ + __m128 m128; + float f[4]; +}; + +static inline __m128 vec_sel(__m128 a, __m128 b, __m128 mask) +{ + return _mm_or_ps(_mm_and_ps(mask, b), _mm_andnot_ps(mask, a)); +} +static inline __m128 vec_sel(__m128 a, __m128 b, const unsigned int *_mask) +{ + return vec_sel(a, b, _mm_load_ps((float *)_mask)); +} +static inline __m128 vec_sel(__m128 a, __m128 b, unsigned int _mask) +{ + return vec_sel(a, b, _mm_set1_ps(*(float *)&_mask)); +} + +static inline __m128 toM128(unsigned int x) +{ + return _mm_set1_ps( *(float *)&x ); +} + +static inline __m128 fabsf4(__m128 x) +{ + return _mm_and_ps( x, toM128( 0x7fffffff ) ); +} +/* +union SSE64 +{ + __m128 m128; + struct + { + __m64 m01; + __m64 m23; + } m64; +}; + +static inline __m128 vec_cts(__m128 x, int a) +{ + assert(a == 0); // Only 2^0 supported + (void)a; + SSE64 sse64; + sse64.m64.m01 = _mm_cvttps_pi32(x); + sse64.m64.m23 = _mm_cvttps_pi32(_mm_ror_ps(x,2)); + _mm_empty(); + return sse64.m128; +} + +static inline __m128 vec_ctf(__m128 x, int a) +{ + assert(a == 0); // Only 2^0 supported + (void)a; + SSE64 sse64; + sse64.m128 = x; + __m128 result =_mm_movelh_ps( + _mm_cvt_pi2ps(_mm_setzero_ps(), sse64.m64.m01), + _mm_cvt_pi2ps(_mm_setzero_ps(), sse64.m64.m23)); + _mm_empty(); + return result; +} +*/ +static inline __m128 vec_cts(__m128 x, int a) +{ + assert(a == 0); // Only 2^0 supported + (void)a; + __m128i result = _mm_cvtps_epi32(x); + return (__m128 &)result; +} + +static inline __m128 vec_ctf(__m128 x, int a) +{ + assert(a == 0); // Only 2^0 supported + (void)a; + return _mm_cvtepi32_ps((__m128i &)x); +} + +#define vec_nmsub(a,b,c) _mm_sub_ps( c, _mm_mul_ps( a, b ) ) +#define vec_sub(a,b) _mm_sub_ps( a, b ) +#define vec_add(a,b) _mm_add_ps( a, b ) +#define vec_mul(a,b) _mm_mul_ps( a, b ) +#define vec_xor(a,b) _mm_xor_ps( a, b ) +#define vec_and(a,b) _mm_and_ps( a, b ) +#define vec_cmpeq(a,b) _mm_cmpeq_ps( a, b ) +#define vec_cmpgt(a,b) _mm_cmpgt_ps( a, b ) + +#define vec_mergeh(a,b) _mm_unpacklo_ps( a, b ) +#define vec_mergel(a,b) _mm_unpackhi_ps( a, b ) + +#define vec_andc(a,b) _mm_andnot_ps( b, a ) + +#define sqrtf4(x) _mm_sqrt_ps( x ) +#define rsqrtf4(x) _mm_rsqrt_ps( x ) +#define recipf4(x) _mm_rcp_ps( x ) +#define negatef4(x) _mm_sub_ps( _mm_setzero_ps(), x ) + +static __forceinline __m128 newtonrapson_rsqrt4( const __m128 v ) +{ +#define _half4 _mm_setr_ps(.5f,.5f,.5f,.5f) +#define _three _mm_setr_ps(3.f,3.f,3.f,3.f) +const __m128 approx = _mm_rsqrt_ps( v ); +const __m128 muls = _mm_mul_ps(_mm_mul_ps(v, approx), approx); +return _mm_mul_ps(_mm_mul_ps(_half4, approx), _mm_sub_ps(_three, muls) ); +} + +static inline __m128 acosf4(__m128 x) +{ + __m128 xabs = fabsf4(x); + __m128 select = _mm_cmplt_ps( x, _mm_setzero_ps() ); + __m128 t1 = sqrtf4(vec_sub(_mm_set1_ps(1.0f), xabs)); + + /* Instruction counts can be reduced if the polynomial was + * computed entirely from nested (dependent) fma's. However, + * to reduce the number of pipeline stalls, the polygon is evaluated + * in two halves (hi amd lo). + */ + __m128 xabs2 = _mm_mul_ps(xabs, xabs); + __m128 xabs4 = _mm_mul_ps(xabs2, xabs2); + __m128 hi = vec_madd(vec_madd(vec_madd(_mm_set1_ps(-0.0012624911f), + xabs, _mm_set1_ps(0.0066700901f)), + xabs, _mm_set1_ps(-0.0170881256f)), + xabs, _mm_set1_ps( 0.0308918810f)); + __m128 lo = vec_madd(vec_madd(vec_madd(_mm_set1_ps(-0.0501743046f), + xabs, _mm_set1_ps(0.0889789874f)), + xabs, _mm_set1_ps(-0.2145988016f)), + xabs, _mm_set1_ps( 1.5707963050f)); + + __m128 result = vec_madd(hi, xabs4, lo); + + // Adjust the result if x is negactive. + return vec_sel( + vec_mul(t1, result), // Positive + vec_nmsub(t1, result, _mm_set1_ps(3.1415926535898f)), // Negative + select); +} + +static inline __m128 sinf4(vec_float4 x) +{ + +// +// Common constants used to evaluate sinf4/cosf4/tanf4 +// +#define _SINCOS_CC0 -0.0013602249f +#define _SINCOS_CC1 0.0416566950f +#define _SINCOS_CC2 -0.4999990225f +#define _SINCOS_SC0 -0.0001950727f +#define _SINCOS_SC1 0.0083320758f +#define _SINCOS_SC2 -0.1666665247f + +#define _SINCOS_KC1 1.57079625129f +#define _SINCOS_KC2 7.54978995489e-8f + + vec_float4 xl,xl2,xl3,res; + + // Range reduction using : xl = angle * TwoOverPi; + // + xl = vec_mul(x, _mm_set1_ps(0.63661977236f)); + + // Find the quadrant the angle falls in + // using: q = (int) (ceil(abs(xl))*sign(xl)) + // + vec_int4 q = vec_cts(xl,0); + + // Compute an offset based on the quadrant that the angle falls in + // + vec_int4 offset = _mm_and_ps(q,toM128(0x3)); + + // Remainder in range [-pi/4..pi/4] + // + vec_float4 qf = vec_ctf(q,0); + xl = vec_nmsub(qf,_mm_set1_ps(_SINCOS_KC2),vec_nmsub(qf,_mm_set1_ps(_SINCOS_KC1),x)); + + // Compute x^2 and x^3 + // + xl2 = vec_mul(xl,xl); + xl3 = vec_mul(xl2,xl); + + // Compute both the sin and cos of the angles + // using a polynomial expression: + // cx = 1.0f + xl2 * ((C0 * xl2 + C1) * xl2 + C2), and + // sx = xl + xl3 * ((S0 * xl2 + S1) * xl2 + S2) + // + + vec_float4 cx = + vec_madd( + vec_madd( + vec_madd(_mm_set1_ps(_SINCOS_CC0),xl2,_mm_set1_ps(_SINCOS_CC1)),xl2,_mm_set1_ps(_SINCOS_CC2)),xl2,_mm_set1_ps(1.0f)); + vec_float4 sx = + vec_madd( + vec_madd( + vec_madd(_mm_set1_ps(_SINCOS_SC0),xl2,_mm_set1_ps(_SINCOS_SC1)),xl2,_mm_set1_ps(_SINCOS_SC2)),xl3,xl); + + // Use the cosine when the offset is odd and the sin + // when the offset is even + // + res = vec_sel(cx,sx,vec_cmpeq(vec_and(offset, + toM128(0x1)), + _mm_setzero_ps())); + + // Flip the sign of the result when (offset mod 4) = 1 or 2 + // + return vec_sel( + vec_xor(toM128(0x80000000U), res), // Negative + res, // Positive + vec_cmpeq(vec_and(offset,toM128(0x2)),_mm_setzero_ps())); +} + +static inline void sincosf4(vec_float4 x, vec_float4* s, vec_float4* c) +{ + vec_float4 xl,xl2,xl3; + vec_int4 offsetSin, offsetCos; + + // Range reduction using : xl = angle * TwoOverPi; + // + xl = vec_mul(x, _mm_set1_ps(0.63661977236f)); + + // Find the quadrant the angle falls in + // using: q = (int) (ceil(abs(xl))*sign(xl)) + // + //vec_int4 q = vec_cts(vec_add(xl,vec_sel(_mm_set1_ps(0.5f),xl,(0x80000000))),0); + vec_int4 q = vec_cts(xl,0); + + // Compute the offset based on the quadrant that the angle falls in. + // Add 1 to the offset for the cosine. + // + offsetSin = vec_and(q,toM128((int)0x3)); + __m128i temp = _mm_add_epi32(_mm_set1_epi32(1),(__m128i &)offsetSin); + offsetCos = (__m128 &)temp; + + // Remainder in range [-pi/4..pi/4] + // + vec_float4 qf = vec_ctf(q,0); + xl = vec_nmsub(qf,_mm_set1_ps(_SINCOS_KC2),vec_nmsub(qf,_mm_set1_ps(_SINCOS_KC1),x)); + + // Compute x^2 and x^3 + // + xl2 = vec_mul(xl,xl); + xl3 = vec_mul(xl2,xl); + + // Compute both the sin and cos of the angles + // using a polynomial expression: + // cx = 1.0f + xl2 * ((C0 * xl2 + C1) * xl2 + C2), and + // sx = xl + xl3 * ((S0 * xl2 + S1) * xl2 + S2) + // + vec_float4 cx = + vec_madd( + vec_madd( + vec_madd(_mm_set1_ps(_SINCOS_CC0),xl2,_mm_set1_ps(_SINCOS_CC1)),xl2,_mm_set1_ps(_SINCOS_CC2)),xl2,_mm_set1_ps(1.0f)); + vec_float4 sx = + vec_madd( + vec_madd( + vec_madd(_mm_set1_ps(_SINCOS_SC0),xl2,_mm_set1_ps(_SINCOS_SC1)),xl2,_mm_set1_ps(_SINCOS_SC2)),xl3,xl); + + // Use the cosine when the offset is odd and the sin + // when the offset is even + // + vec_uint4 sinMask = (vec_uint4)vec_cmpeq(vec_and(offsetSin,toM128(0x1)),_mm_setzero_ps()); + vec_uint4 cosMask = (vec_uint4)vec_cmpeq(vec_and(offsetCos,toM128(0x1)),_mm_setzero_ps()); + *s = vec_sel(cx,sx,sinMask); + *c = vec_sel(cx,sx,cosMask); + + // Flip the sign of the result when (offset mod 4) = 1 or 2 + // + sinMask = vec_cmpeq(vec_and(offsetSin,toM128(0x2)),_mm_setzero_ps()); + cosMask = vec_cmpeq(vec_and(offsetCos,toM128(0x2)),_mm_setzero_ps()); + + *s = vec_sel((vec_float4)vec_xor(toM128(0x80000000),(vec_uint4)*s),*s,sinMask); + *c = vec_sel((vec_float4)vec_xor(toM128(0x80000000),(vec_uint4)*c),*c,cosMask); +} + +#include "vecidx_aos.h" +#include "floatInVec.h" +#include "boolInVec.h" + +#ifdef _VECTORMATH_DEBUG +#include <stdio.h> +#endif +namespace Vectormath { + +namespace Aos { + +//----------------------------------------------------------------------------- +// Forward Declarations +// + +class Vector3; +class Vector4; +class Point3; +class Quat; +class Matrix3; +class Matrix4; +class Transform3; + +// A 3-D vector in array-of-structures format +// +class Vector3 +{ + __m128 mVec128; + +public: + // Default constructor; does no initialization + // + inline Vector3( ) { }; + + // Construct a 3-D vector from x, y, and z elements + // + inline Vector3( float x, float y, float z ); + + // Construct a 3-D vector from x, y, and z elements (scalar data contained in vector data type) + // + inline Vector3( const floatInVec &x, const floatInVec &y, const floatInVec &z ); + + // Copy elements from a 3-D point into a 3-D vector + // + explicit inline Vector3( const Point3 &pnt ); + + // Set all elements of a 3-D vector to the same scalar value + // + explicit inline Vector3( float scalar ); + + // Set all elements of a 3-D vector to the same scalar value (scalar data contained in vector data type) + // + explicit inline Vector3( const floatInVec &scalar ); + + // Set vector float data in a 3-D vector + // + explicit inline Vector3( __m128 vf4 ); + + // Get vector float data from a 3-D vector + // + inline __m128 get128( ) const; + + // Assign one 3-D vector to another + // + inline Vector3 & operator =( const Vector3 &vec ); + + // Set the x element of a 3-D vector + // + inline Vector3 & setX( float x ); + + // Set the y element of a 3-D vector + // + inline Vector3 & setY( float y ); + + // Set the z element of a 3-D vector + // + inline Vector3 & setZ( float z ); + + // Set the x element of a 3-D vector (scalar data contained in vector data type) + // + inline Vector3 & setX( const floatInVec &x ); + + // Set the y element of a 3-D vector (scalar data contained in vector data type) + // + inline Vector3 & setY( const floatInVec &y ); + + // Set the z element of a 3-D vector (scalar data contained in vector data type) + // + inline Vector3 & setZ( const floatInVec &z ); + + // Get the x element of a 3-D vector + // + inline const floatInVec getX( ) const; + + // Get the y element of a 3-D vector + // + inline const floatInVec getY( ) const; + + // Get the z element of a 3-D vector + // + inline const floatInVec getZ( ) const; + + // Set an x, y, or z element of a 3-D vector by index + // + inline Vector3 & setElem( int idx, float value ); + + // Set an x, y, or z element of a 3-D vector by index (scalar data contained in vector data type) + // + inline Vector3 & setElem( int idx, const floatInVec &value ); + + // Get an x, y, or z element of a 3-D vector by index + // + inline const floatInVec getElem( int idx ) const; + + // Subscripting operator to set or get an element + // + inline VecIdx operator []( int idx ); + + // Subscripting operator to get an element + // + inline const floatInVec operator []( int idx ) const; + + // Add two 3-D vectors + // + inline const Vector3 operator +( const Vector3 &vec ) const; + + // Subtract a 3-D vector from another 3-D vector + // + inline const Vector3 operator -( const Vector3 &vec ) const; + + // Add a 3-D vector to a 3-D point + // + inline const Point3 operator +( const Point3 &pnt ) const; + + // Multiply a 3-D vector by a scalar + // + inline const Vector3 operator *( float scalar ) const; + + // Divide a 3-D vector by a scalar + // + inline const Vector3 operator /( float scalar ) const; + + // Multiply a 3-D vector by a scalar (scalar data contained in vector data type) + // + inline const Vector3 operator *( const floatInVec &scalar ) const; + + // Divide a 3-D vector by a scalar (scalar data contained in vector data type) + // + inline const Vector3 operator /( const floatInVec &scalar ) const; + + // Perform compound assignment and addition with a 3-D vector + // + inline Vector3 & operator +=( const Vector3 &vec ); + + // Perform compound assignment and subtraction by a 3-D vector + // + inline Vector3 & operator -=( const Vector3 &vec ); + + // Perform compound assignment and multiplication by a scalar + // + inline Vector3 & operator *=( float scalar ); + + // Perform compound assignment and division by a scalar + // + inline Vector3 & operator /=( float scalar ); + + // Perform compound assignment and multiplication by a scalar (scalar data contained in vector data type) + // + inline Vector3 & operator *=( const floatInVec &scalar ); + + // Perform compound assignment and division by a scalar (scalar data contained in vector data type) + // + inline Vector3 & operator /=( const floatInVec &scalar ); + + // Negate all elements of a 3-D vector + // + inline const Vector3 operator -( ) const; + + // Construct x axis + // + static inline const Vector3 xAxis( ); + + // Construct y axis + // + static inline const Vector3 yAxis( ); + + // Construct z axis + // + static inline const Vector3 zAxis( ); +}; + +// Multiply a 3-D vector by a scalar +// +inline const Vector3 operator *( float scalar, const Vector3 &vec ); + +// Multiply a 3-D vector by a scalar (scalar data contained in vector data type) +// +inline const Vector3 operator *( const floatInVec &scalar, const Vector3 &vec ); + +// Multiply two 3-D vectors per element +// +inline const Vector3 mulPerElem( const Vector3 &vec0, const Vector3 &vec1 ); + +// Divide two 3-D vectors per element +// NOTE: +// Floating-point behavior matches standard library function divf4. +// +inline const Vector3 divPerElem( const Vector3 &vec0, const Vector3 &vec1 ); + +// Compute the reciprocal of a 3-D vector per element +// NOTE: +// Floating-point behavior matches standard library function recipf4. +// +inline const Vector3 recipPerElem( const Vector3 &vec ); + +// Compute the absolute value of a 3-D vector per element +// +inline const Vector3 absPerElem( const Vector3 &vec ); + +// Copy sign from one 3-D vector to another, per element +// +inline const Vector3 copySignPerElem( const Vector3 &vec0, const Vector3 &vec1 ); + +// Maximum of two 3-D vectors per element +// +inline const Vector3 maxPerElem( const Vector3 &vec0, const Vector3 &vec1 ); + +// Minimum of two 3-D vectors per element +// +inline const Vector3 minPerElem( const Vector3 &vec0, const Vector3 &vec1 ); + +// Maximum element of a 3-D vector +// +inline const floatInVec maxElem( const Vector3 &vec ); + +// Minimum element of a 3-D vector +// +inline const floatInVec minElem( const Vector3 &vec ); + +// Compute the sum of all elements of a 3-D vector +// +inline const floatInVec sum( const Vector3 &vec ); + +// Compute the dot product of two 3-D vectors +// +inline const floatInVec dot( const Vector3 &vec0, const Vector3 &vec1 ); + +// Compute the square of the length of a 3-D vector +// +inline const floatInVec lengthSqr( const Vector3 &vec ); + +// Compute the length of a 3-D vector +// +inline const floatInVec length( const Vector3 &vec ); + +// Normalize a 3-D vector +// NOTE: +// The result is unpredictable when all elements of vec are at or near zero. +// +inline const Vector3 normalize( const Vector3 &vec ); + +// Compute cross product of two 3-D vectors +// +inline const Vector3 cross( const Vector3 &vec0, const Vector3 &vec1 ); + +// Outer product of two 3-D vectors +// +inline const Matrix3 outer( const Vector3 &vec0, const Vector3 &vec1 ); + +// Pre-multiply a row vector by a 3x3 matrix +// NOTE: +// Slower than column post-multiply. +// +inline const Vector3 rowMul( const Vector3 &vec, const Matrix3 & mat ); + +// Cross-product matrix of a 3-D vector +// +inline const Matrix3 crossMatrix( const Vector3 &vec ); + +// Create cross-product matrix and multiply +// NOTE: +// Faster than separately creating a cross-product matrix and multiplying. +// +inline const Matrix3 crossMatrixMul( const Vector3 &vec, const Matrix3 & mat ); + +// Linear interpolation between two 3-D vectors +// NOTE: +// Does not clamp t between 0 and 1. +// +inline const Vector3 lerp( float t, const Vector3 &vec0, const Vector3 &vec1 ); + +// Linear interpolation between two 3-D vectors (scalar data contained in vector data type) +// NOTE: +// Does not clamp t between 0 and 1. +// +inline const Vector3 lerp( const floatInVec &t, const Vector3 &vec0, const Vector3 &vec1 ); + +// Spherical linear interpolation between two 3-D vectors +// NOTE: +// The result is unpredictable if the vectors point in opposite directions. +// Does not clamp t between 0 and 1. +// +inline const Vector3 slerp( float t, const Vector3 &unitVec0, const Vector3 &unitVec1 ); + +// Spherical linear interpolation between two 3-D vectors (scalar data contained in vector data type) +// NOTE: +// The result is unpredictable if the vectors point in opposite directions. +// Does not clamp t between 0 and 1. +// +inline const Vector3 slerp( const floatInVec &t, const Vector3 &unitVec0, const Vector3 &unitVec1 ); + +// Conditionally select between two 3-D vectors +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// However, the transfer of select1 to a VMX register may use more processing time than a branch. +// Use the boolInVec version for better performance. +// +inline const Vector3 select( const Vector3 &vec0, const Vector3 &vec1, bool select1 ); + +// Conditionally select between two 3-D vectors (scalar data contained in vector data type) +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// +inline const Vector3 select( const Vector3 &vec0, const Vector3 &vec1, const boolInVec &select1 ); + +// Store x, y, and z elements of 3-D vector in first three words of a quadword, preserving fourth word +// +inline void storeXYZ( const Vector3 &vec, __m128 * quad ); + +// Load four three-float 3-D vectors, stored in three quadwords +// +inline void loadXYZArray( Vector3 & vec0, Vector3 & vec1, Vector3 & vec2, Vector3 & vec3, const __m128 * threeQuads ); + +// Store four 3-D vectors in three quadwords +// +inline void storeXYZArray( const Vector3 &vec0, const Vector3 &vec1, const Vector3 &vec2, const Vector3 &vec3, __m128 * threeQuads ); + +// Store eight 3-D vectors as half-floats +// +inline void storeHalfFloats( const Vector3 &vec0, const Vector3 &vec1, const Vector3 &vec2, const Vector3 &vec3, const Vector3 &vec4, const Vector3 &vec5, const Vector3 &vec6, const Vector3 &vec7, vec_ushort8 * threeQuads ); + +#ifdef _VECTORMATH_DEBUG + +// Print a 3-D vector +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Vector3 &vec ); + +// Print a 3-D vector and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Vector3 &vec, const char * name ); + +#endif + +// A 4-D vector in array-of-structures format +// +class Vector4 +{ + __m128 mVec128; + +public: + // Default constructor; does no initialization + // + inline Vector4( ) { }; + + // Construct a 4-D vector from x, y, z, and w elements + // + inline Vector4( float x, float y, float z, float w ); + + // Construct a 4-D vector from x, y, z, and w elements (scalar data contained in vector data type) + // + inline Vector4( const floatInVec &x, const floatInVec &y, const floatInVec &z, const floatInVec &w ); + + // Construct a 4-D vector from a 3-D vector and a scalar + // + inline Vector4( const Vector3 &xyz, float w ); + + // Construct a 4-D vector from a 3-D vector and a scalar (scalar data contained in vector data type) + // + inline Vector4( const Vector3 &xyz, const floatInVec &w ); + + // Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0 + // + explicit inline Vector4( const Vector3 &vec ); + + // Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1 + // + explicit inline Vector4( const Point3 &pnt ); + + // Copy elements from a quaternion into a 4-D vector + // + explicit inline Vector4( const Quat &quat ); + + // Set all elements of a 4-D vector to the same scalar value + // + explicit inline Vector4( float scalar ); + + // Set all elements of a 4-D vector to the same scalar value (scalar data contained in vector data type) + // + explicit inline Vector4( const floatInVec &scalar ); + + // Set vector float data in a 4-D vector + // + explicit inline Vector4( __m128 vf4 ); + + // Get vector float data from a 4-D vector + // + inline __m128 get128( ) const; + + // Assign one 4-D vector to another + // + inline Vector4 & operator =( const Vector4 &vec ); + + // Set the x, y, and z elements of a 4-D vector + // NOTE: + // This function does not change the w element. + // + inline Vector4 & setXYZ( const Vector3 &vec ); + + // Get the x, y, and z elements of a 4-D vector + // + inline const Vector3 getXYZ( ) const; + + // Set the x element of a 4-D vector + // + inline Vector4 & setX( float x ); + + // Set the y element of a 4-D vector + // + inline Vector4 & setY( float y ); + + // Set the z element of a 4-D vector + // + inline Vector4 & setZ( float z ); + + // Set the w element of a 4-D vector + // + inline Vector4 & setW( float w ); + + // Set the x element of a 4-D vector (scalar data contained in vector data type) + // + inline Vector4 & setX( const floatInVec &x ); + + // Set the y element of a 4-D vector (scalar data contained in vector data type) + // + inline Vector4 & setY( const floatInVec &y ); + + // Set the z element of a 4-D vector (scalar data contained in vector data type) + // + inline Vector4 & setZ( const floatInVec &z ); + + // Set the w element of a 4-D vector (scalar data contained in vector data type) + // + inline Vector4 & setW( const floatInVec &w ); + + // Get the x element of a 4-D vector + // + inline const floatInVec getX( ) const; + + // Get the y element of a 4-D vector + // + inline const floatInVec getY( ) const; + + // Get the z element of a 4-D vector + // + inline const floatInVec getZ( ) const; + + // Get the w element of a 4-D vector + // + inline const floatInVec getW( ) const; + + // Set an x, y, z, or w element of a 4-D vector by index + // + inline Vector4 & setElem( int idx, float value ); + + // Set an x, y, z, or w element of a 4-D vector by index (scalar data contained in vector data type) + // + inline Vector4 & setElem( int idx, const floatInVec &value ); + + // Get an x, y, z, or w element of a 4-D vector by index + // + inline const floatInVec getElem( int idx ) const; + + // Subscripting operator to set or get an element + // + inline VecIdx operator []( int idx ); + + // Subscripting operator to get an element + // + inline const floatInVec operator []( int idx ) const; + + // Add two 4-D vectors + // + inline const Vector4 operator +( const Vector4 &vec ) const; + + // Subtract a 4-D vector from another 4-D vector + // + inline const Vector4 operator -( const Vector4 &vec ) const; + + // Multiply a 4-D vector by a scalar + // + inline const Vector4 operator *( float scalar ) const; + + // Divide a 4-D vector by a scalar + // + inline const Vector4 operator /( float scalar ) const; + + // Multiply a 4-D vector by a scalar (scalar data contained in vector data type) + // + inline const Vector4 operator *( const floatInVec &scalar ) const; + + // Divide a 4-D vector by a scalar (scalar data contained in vector data type) + // + inline const Vector4 operator /( const floatInVec &scalar ) const; + + // Perform compound assignment and addition with a 4-D vector + // + inline Vector4 & operator +=( const Vector4 &vec ); + + // Perform compound assignment and subtraction by a 4-D vector + // + inline Vector4 & operator -=( const Vector4 &vec ); + + // Perform compound assignment and multiplication by a scalar + // + inline Vector4 & operator *=( float scalar ); + + // Perform compound assignment and division by a scalar + // + inline Vector4 & operator /=( float scalar ); + + // Perform compound assignment and multiplication by a scalar (scalar data contained in vector data type) + // + inline Vector4 & operator *=( const floatInVec &scalar ); + + // Perform compound assignment and division by a scalar (scalar data contained in vector data type) + // + inline Vector4 & operator /=( const floatInVec &scalar ); + + // Negate all elements of a 4-D vector + // + inline const Vector4 operator -( ) const; + + // Construct x axis + // + static inline const Vector4 xAxis( ); + + // Construct y axis + // + static inline const Vector4 yAxis( ); + + // Construct z axis + // + static inline const Vector4 zAxis( ); + + // Construct w axis + // + static inline const Vector4 wAxis( ); + +}; + +// Multiply a 4-D vector by a scalar +// +inline const Vector4 operator *( float scalar, const Vector4 &vec ); + +// Multiply a 4-D vector by a scalar (scalar data contained in vector data type) +// +inline const Vector4 operator *( const floatInVec &scalar, const Vector4 &vec ); + +// Multiply two 4-D vectors per element +// +inline const Vector4 mulPerElem( const Vector4 &vec0, const Vector4 &vec1 ); + +// Divide two 4-D vectors per element +// NOTE: +// Floating-point behavior matches standard library function divf4. +// +inline const Vector4 divPerElem( const Vector4 &vec0, const Vector4 &vec1 ); + +// Compute the reciprocal of a 4-D vector per element +// NOTE: +// Floating-point behavior matches standard library function recipf4. +// +inline const Vector4 recipPerElem( const Vector4 &vec ); + +// Compute the absolute value of a 4-D vector per element +// +inline const Vector4 absPerElem( const Vector4 &vec ); + +// Copy sign from one 4-D vector to another, per element +// +inline const Vector4 copySignPerElem( const Vector4 &vec0, const Vector4 &vec1 ); + +// Maximum of two 4-D vectors per element +// +inline const Vector4 maxPerElem( const Vector4 &vec0, const Vector4 &vec1 ); + +// Minimum of two 4-D vectors per element +// +inline const Vector4 minPerElem( const Vector4 &vec0, const Vector4 &vec1 ); + +// Maximum element of a 4-D vector +// +inline const floatInVec maxElem( const Vector4 &vec ); + +// Minimum element of a 4-D vector +// +inline const floatInVec minElem( const Vector4 &vec ); + +// Compute the sum of all elements of a 4-D vector +// +inline const floatInVec sum( const Vector4 &vec ); + +// Compute the dot product of two 4-D vectors +// +inline const floatInVec dot( const Vector4 &vec0, const Vector4 &vec1 ); + +// Compute the square of the length of a 4-D vector +// +inline const floatInVec lengthSqr( const Vector4 &vec ); + +// Compute the length of a 4-D vector +// +inline const floatInVec length( const Vector4 &vec ); + +// Normalize a 4-D vector +// NOTE: +// The result is unpredictable when all elements of vec are at or near zero. +// +inline const Vector4 normalize( const Vector4 &vec ); + +// Outer product of two 4-D vectors +// +inline const Matrix4 outer( const Vector4 &vec0, const Vector4 &vec1 ); + +// Linear interpolation between two 4-D vectors +// NOTE: +// Does not clamp t between 0 and 1. +// +inline const Vector4 lerp( float t, const Vector4 &vec0, const Vector4 &vec1 ); + +// Linear interpolation between two 4-D vectors (scalar data contained in vector data type) +// NOTE: +// Does not clamp t between 0 and 1. +// +inline const Vector4 lerp( const floatInVec &t, const Vector4 &vec0, const Vector4 &vec1 ); + +// Spherical linear interpolation between two 4-D vectors +// NOTE: +// The result is unpredictable if the vectors point in opposite directions. +// Does not clamp t between 0 and 1. +// +inline const Vector4 slerp( float t, const Vector4 &unitVec0, const Vector4 &unitVec1 ); + +// Spherical linear interpolation between two 4-D vectors (scalar data contained in vector data type) +// NOTE: +// The result is unpredictable if the vectors point in opposite directions. +// Does not clamp t between 0 and 1. +// +inline const Vector4 slerp( const floatInVec &t, const Vector4 &unitVec0, const Vector4 &unitVec1 ); + +// Conditionally select between two 4-D vectors +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// However, the transfer of select1 to a VMX register may use more processing time than a branch. +// Use the boolInVec version for better performance. +// +inline const Vector4 select( const Vector4 &vec0, const Vector4 &vec1, bool select1 ); + +// Conditionally select between two 4-D vectors (scalar data contained in vector data type) +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// +inline const Vector4 select( const Vector4 &vec0, const Vector4 &vec1, const boolInVec &select1 ); + +// Store four 4-D vectors as half-floats +// +inline void storeHalfFloats( const Vector4 &vec0, const Vector4 &vec1, const Vector4 &vec2, const Vector4 &vec3, vec_ushort8 * twoQuads ); + +#ifdef _VECTORMATH_DEBUG + +// Print a 4-D vector +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Vector4 &vec ); + +// Print a 4-D vector and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Vector4 &vec, const char * name ); + +#endif + +// A 3-D point in array-of-structures format +// +class Point3 +{ + __m128 mVec128; + +public: + // Default constructor; does no initialization + // + inline Point3( ) { }; + + // Construct a 3-D point from x, y, and z elements + // + inline Point3( float x, float y, float z ); + + // Construct a 3-D point from x, y, and z elements (scalar data contained in vector data type) + // + inline Point3( const floatInVec &x, const floatInVec &y, const floatInVec &z ); + + // Copy elements from a 3-D vector into a 3-D point + // + explicit inline Point3( const Vector3 &vec ); + + // Set all elements of a 3-D point to the same scalar value + // + explicit inline Point3( float scalar ); + + // Set all elements of a 3-D point to the same scalar value (scalar data contained in vector data type) + // + explicit inline Point3( const floatInVec &scalar ); + + // Set vector float data in a 3-D point + // + explicit inline Point3( __m128 vf4 ); + + // Get vector float data from a 3-D point + // + inline __m128 get128( ) const; + + // Assign one 3-D point to another + // + inline Point3 & operator =( const Point3 &pnt ); + + // Set the x element of a 3-D point + // + inline Point3 & setX( float x ); + + // Set the y element of a 3-D point + // + inline Point3 & setY( float y ); + + // Set the z element of a 3-D point + // + inline Point3 & setZ( float z ); + + // Set the x element of a 3-D point (scalar data contained in vector data type) + // + inline Point3 & setX( const floatInVec &x ); + + // Set the y element of a 3-D point (scalar data contained in vector data type) + // + inline Point3 & setY( const floatInVec &y ); + + // Set the z element of a 3-D point (scalar data contained in vector data type) + // + inline Point3 & setZ( const floatInVec &z ); + + // Get the x element of a 3-D point + // + inline const floatInVec getX( ) const; + + // Get the y element of a 3-D point + // + inline const floatInVec getY( ) const; + + // Get the z element of a 3-D point + // + inline const floatInVec getZ( ) const; + + // Set an x, y, or z element of a 3-D point by index + // + inline Point3 & setElem( int idx, float value ); + + // Set an x, y, or z element of a 3-D point by index (scalar data contained in vector data type) + // + inline Point3 & setElem( int idx, const floatInVec &value ); + + // Get an x, y, or z element of a 3-D point by index + // + inline const floatInVec getElem( int idx ) const; + + // Subscripting operator to set or get an element + // + inline VecIdx operator []( int idx ); + + // Subscripting operator to get an element + // + inline const floatInVec operator []( int idx ) const; + + // Subtract a 3-D point from another 3-D point + // + inline const Vector3 operator -( const Point3 &pnt ) const; + + // Add a 3-D point to a 3-D vector + // + inline const Point3 operator +( const Vector3 &vec ) const; + + // Subtract a 3-D vector from a 3-D point + // + inline const Point3 operator -( const Vector3 &vec ) const; + + // Perform compound assignment and addition with a 3-D vector + // + inline Point3 & operator +=( const Vector3 &vec ); + + // Perform compound assignment and subtraction by a 3-D vector + // + inline Point3 & operator -=( const Vector3 &vec ); + +}; + +// Multiply two 3-D points per element +// +inline const Point3 mulPerElem( const Point3 &pnt0, const Point3 &pnt1 ); + +// Divide two 3-D points per element +// NOTE: +// Floating-point behavior matches standard library function divf4. +// +inline const Point3 divPerElem( const Point3 &pnt0, const Point3 &pnt1 ); + +// Compute the reciprocal of a 3-D point per element +// NOTE: +// Floating-point behavior matches standard library function recipf4. +// +inline const Point3 recipPerElem( const Point3 &pnt ); + +// Compute the absolute value of a 3-D point per element +// +inline const Point3 absPerElem( const Point3 &pnt ); + +// Copy sign from one 3-D point to another, per element +// +inline const Point3 copySignPerElem( const Point3 &pnt0, const Point3 &pnt1 ); + +// Maximum of two 3-D points per element +// +inline const Point3 maxPerElem( const Point3 &pnt0, const Point3 &pnt1 ); + +// Minimum of two 3-D points per element +// +inline const Point3 minPerElem( const Point3 &pnt0, const Point3 &pnt1 ); + +// Maximum element of a 3-D point +// +inline const floatInVec maxElem( const Point3 &pnt ); + +// Minimum element of a 3-D point +// +inline const floatInVec minElem( const Point3 &pnt ); + +// Compute the sum of all elements of a 3-D point +// +inline const floatInVec sum( const Point3 &pnt ); + +// Apply uniform scale to a 3-D point +// +inline const Point3 scale( const Point3 &pnt, float scaleVal ); + +// Apply uniform scale to a 3-D point (scalar data contained in vector data type) +// +inline const Point3 scale( const Point3 &pnt, const floatInVec &scaleVal ); + +// Apply non-uniform scale to a 3-D point +// +inline const Point3 scale( const Point3 &pnt, const Vector3 &scaleVec ); + +// Scalar projection of a 3-D point on a unit-length 3-D vector +// +inline const floatInVec projection( const Point3 &pnt, const Vector3 &unitVec ); + +// Compute the square of the distance of a 3-D point from the coordinate-system origin +// +inline const floatInVec distSqrFromOrigin( const Point3 &pnt ); + +// Compute the distance of a 3-D point from the coordinate-system origin +// +inline const floatInVec distFromOrigin( const Point3 &pnt ); + +// Compute the square of the distance between two 3-D points +// +inline const floatInVec distSqr( const Point3 &pnt0, const Point3 &pnt1 ); + +// Compute the distance between two 3-D points +// +inline const floatInVec dist( const Point3 &pnt0, const Point3 &pnt1 ); + +// Linear interpolation between two 3-D points +// NOTE: +// Does not clamp t between 0 and 1. +// +inline const Point3 lerp( float t, const Point3 &pnt0, const Point3 &pnt1 ); + +// Linear interpolation between two 3-D points (scalar data contained in vector data type) +// NOTE: +// Does not clamp t between 0 and 1. +// +inline const Point3 lerp( const floatInVec &t, const Point3 &pnt0, const Point3 &pnt1 ); + +// Conditionally select between two 3-D points +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// However, the transfer of select1 to a VMX register may use more processing time than a branch. +// Use the boolInVec version for better performance. +// +inline const Point3 select( const Point3 &pnt0, const Point3 &pnt1, bool select1 ); + +// Conditionally select between two 3-D points (scalar data contained in vector data type) +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// +inline const Point3 select( const Point3 &pnt0, const Point3 &pnt1, const boolInVec &select1 ); + +// Store x, y, and z elements of 3-D point in first three words of a quadword, preserving fourth word +// +inline void storeXYZ( const Point3 &pnt, __m128 * quad ); + +// Load four three-float 3-D points, stored in three quadwords +// +inline void loadXYZArray( Point3 & pnt0, Point3 & pnt1, Point3 & pnt2, Point3 & pnt3, const __m128 * threeQuads ); + +// Store four 3-D points in three quadwords +// +inline void storeXYZArray( const Point3 &pnt0, const Point3 &pnt1, const Point3 &pnt2, const Point3 &pnt3, __m128 * threeQuads ); + +// Store eight 3-D points as half-floats +// +inline void storeHalfFloats( const Point3 &pnt0, const Point3 &pnt1, const Point3 &pnt2, const Point3 &pnt3, const Point3 &pnt4, const Point3 &pnt5, const Point3 &pnt6, const Point3 &pnt7, vec_ushort8 * threeQuads ); + +#ifdef _VECTORMATH_DEBUG + +// Print a 3-D point +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Point3 &pnt ); + +// Print a 3-D point and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Point3 &pnt, const char * name ); + +#endif + +// A quaternion in array-of-structures format +// +class Quat +{ + __m128 mVec128; + +public: + // Default constructor; does no initialization + // + inline Quat( ) { }; + + // Construct a quaternion from x, y, z, and w elements + // + inline Quat( float x, float y, float z, float w ); + + // Construct a quaternion from x, y, z, and w elements (scalar data contained in vector data type) + // + inline Quat( const floatInVec &x, const floatInVec &y, const floatInVec &z, const floatInVec &w ); + + // Construct a quaternion from a 3-D vector and a scalar + // + inline Quat( const Vector3 &xyz, float w ); + + // Construct a quaternion from a 3-D vector and a scalar (scalar data contained in vector data type) + // + inline Quat( const Vector3 &xyz, const floatInVec &w ); + + // Copy elements from a 4-D vector into a quaternion + // + explicit inline Quat( const Vector4 &vec ); + + // Convert a rotation matrix to a unit-length quaternion + // + explicit inline Quat( const Matrix3 & rotMat ); + + // Set all elements of a quaternion to the same scalar value + // + explicit inline Quat( float scalar ); + + // Set all elements of a quaternion to the same scalar value (scalar data contained in vector data type) + // + explicit inline Quat( const floatInVec &scalar ); + + // Set vector float data in a quaternion + // + explicit inline Quat( __m128 vf4 ); + + // Get vector float data from a quaternion + // + inline __m128 get128( ) const; + + // Assign one quaternion to another + // + inline Quat & operator =( const Quat &quat ); + + // Set the x, y, and z elements of a quaternion + // NOTE: + // This function does not change the w element. + // + inline Quat & setXYZ( const Vector3 &vec ); + + // Get the x, y, and z elements of a quaternion + // + inline const Vector3 getXYZ( ) const; + + // Set the x element of a quaternion + // + inline Quat & setX( float x ); + + // Set the y element of a quaternion + // + inline Quat & setY( float y ); + + // Set the z element of a quaternion + // + inline Quat & setZ( float z ); + + // Set the w element of a quaternion + // + inline Quat & setW( float w ); + + // Set the x element of a quaternion (scalar data contained in vector data type) + // + inline Quat & setX( const floatInVec &x ); + + // Set the y element of a quaternion (scalar data contained in vector data type) + // + inline Quat & setY( const floatInVec &y ); + + // Set the z element of a quaternion (scalar data contained in vector data type) + // + inline Quat & setZ( const floatInVec &z ); + + // Set the w element of a quaternion (scalar data contained in vector data type) + // + inline Quat & setW( const floatInVec &w ); + + // Get the x element of a quaternion + // + inline const floatInVec getX( ) const; + + // Get the y element of a quaternion + // + inline const floatInVec getY( ) const; + + // Get the z element of a quaternion + // + inline const floatInVec getZ( ) const; + + // Get the w element of a quaternion + // + inline const floatInVec getW( ) const; + + // Set an x, y, z, or w element of a quaternion by index + // + inline Quat & setElem( int idx, float value ); + + // Set an x, y, z, or w element of a quaternion by index (scalar data contained in vector data type) + // + inline Quat & setElem( int idx, const floatInVec &value ); + + // Get an x, y, z, or w element of a quaternion by index + // + inline const floatInVec getElem( int idx ) const; + + // Subscripting operator to set or get an element + // + inline VecIdx operator []( int idx ); + + // Subscripting operator to get an element + // + inline const floatInVec operator []( int idx ) const; + + // Add two quaternions + // + inline const Quat operator +( const Quat &quat ) const; + + // Subtract a quaternion from another quaternion + // + inline const Quat operator -( const Quat &quat ) const; + + // Multiply two quaternions + // + inline const Quat operator *( const Quat &quat ) const; + + // Multiply a quaternion by a scalar + // + inline const Quat operator *( float scalar ) const; + + // Divide a quaternion by a scalar + // + inline const Quat operator /( float scalar ) const; + + // Multiply a quaternion by a scalar (scalar data contained in vector data type) + // + inline const Quat operator *( const floatInVec &scalar ) const; + + // Divide a quaternion by a scalar (scalar data contained in vector data type) + // + inline const Quat operator /( const floatInVec &scalar ) const; + + // Perform compound assignment and addition with a quaternion + // + inline Quat & operator +=( const Quat &quat ); + + // Perform compound assignment and subtraction by a quaternion + // + inline Quat & operator -=( const Quat &quat ); + + // Perform compound assignment and multiplication by a quaternion + // + inline Quat & operator *=( const Quat &quat ); + + // Perform compound assignment and multiplication by a scalar + // + inline Quat & operator *=( float scalar ); + + // Perform compound assignment and division by a scalar + // + inline Quat & operator /=( float scalar ); + + // Perform compound assignment and multiplication by a scalar (scalar data contained in vector data type) + // + inline Quat & operator *=( const floatInVec &scalar ); + + // Perform compound assignment and division by a scalar (scalar data contained in vector data type) + // + inline Quat & operator /=( const floatInVec &scalar ); + + // Negate all elements of a quaternion + // + inline const Quat operator -( ) const; + + // Construct an identity quaternion + // + static inline const Quat identity( ); + + // Construct a quaternion to rotate between two unit-length 3-D vectors + // NOTE: + // The result is unpredictable if unitVec0 and unitVec1 point in opposite directions. + // + static inline const Quat rotation( const Vector3 &unitVec0, const Vector3 &unitVec1 ); + + // Construct a quaternion to rotate around a unit-length 3-D vector + // + static inline const Quat rotation( float radians, const Vector3 &unitVec ); + + // Construct a quaternion to rotate around a unit-length 3-D vector (scalar data contained in vector data type) + // + static inline const Quat rotation( const floatInVec &radians, const Vector3 &unitVec ); + + // Construct a quaternion to rotate around the x axis + // + static inline const Quat rotationX( float radians ); + + // Construct a quaternion to rotate around the y axis + // + static inline const Quat rotationY( float radians ); + + // Construct a quaternion to rotate around the z axis + // + static inline const Quat rotationZ( float radians ); + + // Construct a quaternion to rotate around the x axis (scalar data contained in vector data type) + // + static inline const Quat rotationX( const floatInVec &radians ); + + // Construct a quaternion to rotate around the y axis (scalar data contained in vector data type) + // + static inline const Quat rotationY( const floatInVec &radians ); + + // Construct a quaternion to rotate around the z axis (scalar data contained in vector data type) + // + static inline const Quat rotationZ( const floatInVec &radians ); +}; + +// Multiply a quaternion by a scalar +// +inline const Quat operator *( float scalar, const Quat &quat ); + +// Multiply a quaternion by a scalar (scalar data contained in vector data type) +// +inline const Quat operator *( const floatInVec &scalar, const Quat &quat ); + +// Compute the conjugate of a quaternion +// +inline const Quat conj( const Quat &quat ); + +// Use a unit-length quaternion to rotate a 3-D vector +// +inline const Vector3 rotate( const Quat &unitQuat, const Vector3 &vec ); + +// Compute the dot product of two quaternions +// +inline const floatInVec dot( const Quat &quat0, const Quat &quat1 ); + +// Compute the norm of a quaternion +// +inline const floatInVec norm( const Quat &quat ); + +// Compute the length of a quaternion +// +inline const floatInVec length( const Quat &quat ); + +// Normalize a quaternion +// NOTE: +// The result is unpredictable when all elements of quat are at or near zero. +// +inline const Quat normalize( const Quat &quat ); + +// Linear interpolation between two quaternions +// NOTE: +// Does not clamp t between 0 and 1. +// +inline const Quat lerp( float t, const Quat &quat0, const Quat &quat1 ); + +// Linear interpolation between two quaternions (scalar data contained in vector data type) +// NOTE: +// Does not clamp t between 0 and 1. +// +inline const Quat lerp( const floatInVec &t, const Quat &quat0, const Quat &quat1 ); + +// Spherical linear interpolation between two quaternions +// NOTE: +// Interpolates along the shortest path between orientations. +// Does not clamp t between 0 and 1. +// +inline const Quat slerp( float t, const Quat &unitQuat0, const Quat &unitQuat1 ); + +// Spherical linear interpolation between two quaternions (scalar data contained in vector data type) +// NOTE: +// Interpolates along the shortest path between orientations. +// Does not clamp t between 0 and 1. +// +inline const Quat slerp( const floatInVec &t, const Quat &unitQuat0, const Quat &unitQuat1 ); + +// Spherical quadrangle interpolation +// +inline const Quat squad( float t, const Quat &unitQuat0, const Quat &unitQuat1, const Quat &unitQuat2, const Quat &unitQuat3 ); + +// Spherical quadrangle interpolation (scalar data contained in vector data type) +// +inline const Quat squad( const floatInVec &t, const Quat &unitQuat0, const Quat &unitQuat1, const Quat &unitQuat2, const Quat &unitQuat3 ); + +// Conditionally select between two quaternions +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// However, the transfer of select1 to a VMX register may use more processing time than a branch. +// Use the boolInVec version for better performance. +// +inline const Quat select( const Quat &quat0, const Quat &quat1, bool select1 ); + +// Conditionally select between two quaternions (scalar data contained in vector data type) +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// +inline const Quat select( const Quat &quat0, const Quat &quat1, const boolInVec &select1 ); + +#ifdef _VECTORMATH_DEBUG + +// Print a quaternion +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Quat &quat ); + +// Print a quaternion and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Quat &quat, const char * name ); + +#endif + +// A 3x3 matrix in array-of-structures format +// +class Matrix3 +{ + Vector3 mCol0; + Vector3 mCol1; + Vector3 mCol2; + +public: + // Default constructor; does no initialization + // + inline Matrix3( ) { }; + + // Copy a 3x3 matrix + // + inline Matrix3( const Matrix3 & mat ); + + // Construct a 3x3 matrix containing the specified columns + // + inline Matrix3( const Vector3 &col0, const Vector3 &col1, const Vector3 &col2 ); + + // Construct a 3x3 rotation matrix from a unit-length quaternion + // + explicit inline Matrix3( const Quat &unitQuat ); + + // Set all elements of a 3x3 matrix to the same scalar value + // + explicit inline Matrix3( float scalar ); + + // Set all elements of a 3x3 matrix to the same scalar value (scalar data contained in vector data type) + // + explicit inline Matrix3( const floatInVec &scalar ); + + // Assign one 3x3 matrix to another + // + inline Matrix3 & operator =( const Matrix3 & mat ); + + // Set column 0 of a 3x3 matrix + // + inline Matrix3 & setCol0( const Vector3 &col0 ); + + // Set column 1 of a 3x3 matrix + // + inline Matrix3 & setCol1( const Vector3 &col1 ); + + // Set column 2 of a 3x3 matrix + // + inline Matrix3 & setCol2( const Vector3 &col2 ); + + // Get column 0 of a 3x3 matrix + // + inline const Vector3 getCol0( ) const; + + // Get column 1 of a 3x3 matrix + // + inline const Vector3 getCol1( ) const; + + // Get column 2 of a 3x3 matrix + // + inline const Vector3 getCol2( ) const; + + // Set the column of a 3x3 matrix referred to by the specified index + // + inline Matrix3 & setCol( int col, const Vector3 &vec ); + + // Set the row of a 3x3 matrix referred to by the specified index + // + inline Matrix3 & setRow( int row, const Vector3 &vec ); + + // Get the column of a 3x3 matrix referred to by the specified index + // + inline const Vector3 getCol( int col ) const; + + // Get the row of a 3x3 matrix referred to by the specified index + // + inline const Vector3 getRow( int row ) const; + + // Subscripting operator to set or get a column + // + inline Vector3 & operator []( int col ); + + // Subscripting operator to get a column + // + inline const Vector3 operator []( int col ) const; + + // Set the element of a 3x3 matrix referred to by column and row indices + // + inline Matrix3 & setElem( int col, int row, float val ); + + // Set the element of a 3x3 matrix referred to by column and row indices (scalar data contained in vector data type) + // + inline Matrix3 & setElem( int col, int row, const floatInVec &val ); + + // Get the element of a 3x3 matrix referred to by column and row indices + // + inline const floatInVec getElem( int col, int row ) const; + + // Add two 3x3 matrices + // + inline const Matrix3 operator +( const Matrix3 & mat ) const; + + // Subtract a 3x3 matrix from another 3x3 matrix + // + inline const Matrix3 operator -( const Matrix3 & mat ) const; + + // Negate all elements of a 3x3 matrix + // + inline const Matrix3 operator -( ) const; + + // Multiply a 3x3 matrix by a scalar + // + inline const Matrix3 operator *( float scalar ) const; + + // Multiply a 3x3 matrix by a scalar (scalar data contained in vector data type) + // + inline const Matrix3 operator *( const floatInVec &scalar ) const; + + // Multiply a 3x3 matrix by a 3-D vector + // + inline const Vector3 operator *( const Vector3 &vec ) const; + + // Multiply two 3x3 matrices + // + inline const Matrix3 operator *( const Matrix3 & mat ) const; + + // Perform compound assignment and addition with a 3x3 matrix + // + inline Matrix3 & operator +=( const Matrix3 & mat ); + + // Perform compound assignment and subtraction by a 3x3 matrix + // + inline Matrix3 & operator -=( const Matrix3 & mat ); + + // Perform compound assignment and multiplication by a scalar + // + inline Matrix3 & operator *=( float scalar ); + + // Perform compound assignment and multiplication by a scalar (scalar data contained in vector data type) + // + inline Matrix3 & operator *=( const floatInVec &scalar ); + + // Perform compound assignment and multiplication by a 3x3 matrix + // + inline Matrix3 & operator *=( const Matrix3 & mat ); + + // Construct an identity 3x3 matrix + // + static inline const Matrix3 identity( ); + + // Construct a 3x3 matrix to rotate around the x axis + // + static inline const Matrix3 rotationX( float radians ); + + // Construct a 3x3 matrix to rotate around the y axis + // + static inline const Matrix3 rotationY( float radians ); + + // Construct a 3x3 matrix to rotate around the z axis + // + static inline const Matrix3 rotationZ( float radians ); + + // Construct a 3x3 matrix to rotate around the x axis (scalar data contained in vector data type) + // + static inline const Matrix3 rotationX( const floatInVec &radians ); + + // Construct a 3x3 matrix to rotate around the y axis (scalar data contained in vector data type) + // + static inline const Matrix3 rotationY( const floatInVec &radians ); + + // Construct a 3x3 matrix to rotate around the z axis (scalar data contained in vector data type) + // + static inline const Matrix3 rotationZ( const floatInVec &radians ); + + // Construct a 3x3 matrix to rotate around the x, y, and z axes + // + static inline const Matrix3 rotationZYX( const Vector3 &radiansXYZ ); + + // Construct a 3x3 matrix to rotate around a unit-length 3-D vector + // + static inline const Matrix3 rotation( float radians, const Vector3 &unitVec ); + + // Construct a 3x3 matrix to rotate around a unit-length 3-D vector (scalar data contained in vector data type) + // + static inline const Matrix3 rotation( const floatInVec &radians, const Vector3 &unitVec ); + + // Construct a rotation matrix from a unit-length quaternion + // + static inline const Matrix3 rotation( const Quat &unitQuat ); + + // Construct a 3x3 matrix to perform scaling + // + static inline const Matrix3 scale( const Vector3 &scaleVec ); + +}; +// Multiply a 3x3 matrix by a scalar +// +inline const Matrix3 operator *( float scalar, const Matrix3 & mat ); + +// Multiply a 3x3 matrix by a scalar (scalar data contained in vector data type) +// +inline const Matrix3 operator *( const floatInVec &scalar, const Matrix3 & mat ); + +// Append (post-multiply) a scale transformation to a 3x3 matrix +// NOTE: +// Faster than creating and multiplying a scale transformation matrix. +// +inline const Matrix3 appendScale( const Matrix3 & mat, const Vector3 &scaleVec ); + +// Prepend (pre-multiply) a scale transformation to a 3x3 matrix +// NOTE: +// Faster than creating and multiplying a scale transformation matrix. +// +inline const Matrix3 prependScale( const Vector3 &scaleVec, const Matrix3 & mat ); + +// Multiply two 3x3 matrices per element +// +inline const Matrix3 mulPerElem( const Matrix3 & mat0, const Matrix3 & mat1 ); + +// Compute the absolute value of a 3x3 matrix per element +// +inline const Matrix3 absPerElem( const Matrix3 & mat ); + +// Transpose of a 3x3 matrix +// +inline const Matrix3 transpose( const Matrix3 & mat ); + +// Compute the inverse of a 3x3 matrix +// NOTE: +// Result is unpredictable when the determinant of mat is equal to or near 0. +// +inline const Matrix3 inverse( const Matrix3 & mat ); + +// Determinant of a 3x3 matrix +// +inline const floatInVec determinant( const Matrix3 & mat ); + +// Conditionally select between two 3x3 matrices +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// However, the transfer of select1 to a VMX register may use more processing time than a branch. +// Use the boolInVec version for better performance. +// +inline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, bool select1 ); + +// Conditionally select between two 3x3 matrices (scalar data contained in vector data type) +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// +inline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, const boolInVec &select1 ); + +#ifdef _VECTORMATH_DEBUG + +// Print a 3x3 matrix +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Matrix3 & mat ); + +// Print a 3x3 matrix and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Matrix3 & mat, const char * name ); + +#endif + +// A 4x4 matrix in array-of-structures format +// +class Matrix4 +{ + Vector4 mCol0; + Vector4 mCol1; + Vector4 mCol2; + Vector4 mCol3; + +public: + // Default constructor; does no initialization + // + inline Matrix4( ) { }; + + // Copy a 4x4 matrix + // + inline Matrix4( const Matrix4 & mat ); + + // Construct a 4x4 matrix containing the specified columns + // + inline Matrix4( const Vector4 &col0, const Vector4 &col1, const Vector4 &col2, const Vector4 &col3 ); + + // Construct a 4x4 matrix from a 3x4 transformation matrix + // + explicit inline Matrix4( const Transform3 & mat ); + + // Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector + // + inline Matrix4( const Matrix3 & mat, const Vector3 &translateVec ); + + // Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector + // + inline Matrix4( const Quat &unitQuat, const Vector3 &translateVec ); + + // Set all elements of a 4x4 matrix to the same scalar value + // + explicit inline Matrix4( float scalar ); + + // Set all elements of a 4x4 matrix to the same scalar value (scalar data contained in vector data type) + // + explicit inline Matrix4( const floatInVec &scalar ); + + // Assign one 4x4 matrix to another + // + inline Matrix4 & operator =( const Matrix4 & mat ); + + // Set the upper-left 3x3 submatrix + // NOTE: + // This function does not change the bottom row elements. + // + inline Matrix4 & setUpper3x3( const Matrix3 & mat3 ); + + // Get the upper-left 3x3 submatrix of a 4x4 matrix + // + inline const Matrix3 getUpper3x3( ) const; + + // Set translation component + // NOTE: + // This function does not change the bottom row elements. + // + inline Matrix4 & setTranslation( const Vector3 &translateVec ); + + // Get the translation component of a 4x4 matrix + // + inline const Vector3 getTranslation( ) const; + + // Set column 0 of a 4x4 matrix + // + inline Matrix4 & setCol0( const Vector4 &col0 ); + + // Set column 1 of a 4x4 matrix + // + inline Matrix4 & setCol1( const Vector4 &col1 ); + + // Set column 2 of a 4x4 matrix + // + inline Matrix4 & setCol2( const Vector4 &col2 ); + + // Set column 3 of a 4x4 matrix + // + inline Matrix4 & setCol3( const Vector4 &col3 ); + + // Get column 0 of a 4x4 matrix + // + inline const Vector4 getCol0( ) const; + + // Get column 1 of a 4x4 matrix + // + inline const Vector4 getCol1( ) const; + + // Get column 2 of a 4x4 matrix + // + inline const Vector4 getCol2( ) const; + + // Get column 3 of a 4x4 matrix + // + inline const Vector4 getCol3( ) const; + + // Set the column of a 4x4 matrix referred to by the specified index + // + inline Matrix4 & setCol( int col, const Vector4 &vec ); + + // Set the row of a 4x4 matrix referred to by the specified index + // + inline Matrix4 & setRow( int row, const Vector4 &vec ); + + // Get the column of a 4x4 matrix referred to by the specified index + // + inline const Vector4 getCol( int col ) const; + + // Get the row of a 4x4 matrix referred to by the specified index + // + inline const Vector4 getRow( int row ) const; + + // Subscripting operator to set or get a column + // + inline Vector4 & operator []( int col ); + + // Subscripting operator to get a column + // + inline const Vector4 operator []( int col ) const; + + // Set the element of a 4x4 matrix referred to by column and row indices + // + inline Matrix4 & setElem( int col, int row, float val ); + + // Set the element of a 4x4 matrix referred to by column and row indices (scalar data contained in vector data type) + // + inline Matrix4 & setElem( int col, int row, const floatInVec &val ); + + // Get the element of a 4x4 matrix referred to by column and row indices + // + inline const floatInVec getElem( int col, int row ) const; + + // Add two 4x4 matrices + // + inline const Matrix4 operator +( const Matrix4 & mat ) const; + + // Subtract a 4x4 matrix from another 4x4 matrix + // + inline const Matrix4 operator -( const Matrix4 & mat ) const; + + // Negate all elements of a 4x4 matrix + // + inline const Matrix4 operator -( ) const; + + // Multiply a 4x4 matrix by a scalar + // + inline const Matrix4 operator *( float scalar ) const; + + // Multiply a 4x4 matrix by a scalar (scalar data contained in vector data type) + // + inline const Matrix4 operator *( const floatInVec &scalar ) const; + + // Multiply a 4x4 matrix by a 4-D vector + // + inline const Vector4 operator *( const Vector4 &vec ) const; + + // Multiply a 4x4 matrix by a 3-D vector + // + inline const Vector4 operator *( const Vector3 &vec ) const; + + // Multiply a 4x4 matrix by a 3-D point + // + inline const Vector4 operator *( const Point3 &pnt ) const; + + // Multiply two 4x4 matrices + // + inline const Matrix4 operator *( const Matrix4 & mat ) const; + + // Multiply a 4x4 matrix by a 3x4 transformation matrix + // + inline const Matrix4 operator *( const Transform3 & tfrm ) const; + + // Perform compound assignment and addition with a 4x4 matrix + // + inline Matrix4 & operator +=( const Matrix4 & mat ); + + // Perform compound assignment and subtraction by a 4x4 matrix + // + inline Matrix4 & operator -=( const Matrix4 & mat ); + + // Perform compound assignment and multiplication by a scalar + // + inline Matrix4 & operator *=( float scalar ); + + // Perform compound assignment and multiplication by a scalar (scalar data contained in vector data type) + // + inline Matrix4 & operator *=( const floatInVec &scalar ); + + // Perform compound assignment and multiplication by a 4x4 matrix + // + inline Matrix4 & operator *=( const Matrix4 & mat ); + + // Perform compound assignment and multiplication by a 3x4 transformation matrix + // + inline Matrix4 & operator *=( const Transform3 & tfrm ); + + // Construct an identity 4x4 matrix + // + static inline const Matrix4 identity( ); + + // Construct a 4x4 matrix to rotate around the x axis + // + static inline const Matrix4 rotationX( float radians ); + + // Construct a 4x4 matrix to rotate around the y axis + // + static inline const Matrix4 rotationY( float radians ); + + // Construct a 4x4 matrix to rotate around the z axis + // + static inline const Matrix4 rotationZ( float radians ); + + // Construct a 4x4 matrix to rotate around the x axis (scalar data contained in vector data type) + // + static inline const Matrix4 rotationX( const floatInVec &radians ); + + // Construct a 4x4 matrix to rotate around the y axis (scalar data contained in vector data type) + // + static inline const Matrix4 rotationY( const floatInVec &radians ); + + // Construct a 4x4 matrix to rotate around the z axis (scalar data contained in vector data type) + // + static inline const Matrix4 rotationZ( const floatInVec &radians ); + + // Construct a 4x4 matrix to rotate around the x, y, and z axes + // + static inline const Matrix4 rotationZYX( const Vector3 &radiansXYZ ); + + // Construct a 4x4 matrix to rotate around a unit-length 3-D vector + // + static inline const Matrix4 rotation( float radians, const Vector3 &unitVec ); + + // Construct a 4x4 matrix to rotate around a unit-length 3-D vector (scalar data contained in vector data type) + // + static inline const Matrix4 rotation( const floatInVec &radians, const Vector3 &unitVec ); + + // Construct a rotation matrix from a unit-length quaternion + // + static inline const Matrix4 rotation( const Quat &unitQuat ); + + // Construct a 4x4 matrix to perform scaling + // + static inline const Matrix4 scale( const Vector3 &scaleVec ); + + // Construct a 4x4 matrix to perform translation + // + static inline const Matrix4 translation( const Vector3 &translateVec ); + + // Construct viewing matrix based on eye, position looked at, and up direction + // + static inline const Matrix4 lookAt( const Point3 &eyePos, const Point3 &lookAtPos, const Vector3 &upVec ); + + // Construct a perspective projection matrix + // + static inline const Matrix4 perspective( float fovyRadians, float aspect, float zNear, float zFar ); + + // Construct a perspective projection matrix based on frustum + // + static inline const Matrix4 frustum( float left, float right, float bottom, float top, float zNear, float zFar ); + + // Construct an orthographic projection matrix + // + static inline const Matrix4 orthographic( float left, float right, float bottom, float top, float zNear, float zFar ); +}; +// Multiply a 4x4 matrix by a scalar +// +inline const Matrix4 operator *( float scalar, const Matrix4 & mat ); + +// Multiply a 4x4 matrix by a scalar (scalar data contained in vector data type) +// +inline const Matrix4 operator *( const floatInVec &scalar, const Matrix4 & mat ); + +// Append (post-multiply) a scale transformation to a 4x4 matrix +// NOTE: +// Faster than creating and multiplying a scale transformation matrix. +// +inline const Matrix4 appendScale( const Matrix4 & mat, const Vector3 &scaleVec ); + +// Prepend (pre-multiply) a scale transformation to a 4x4 matrix +// NOTE: +// Faster than creating and multiplying a scale transformation matrix. +// +inline const Matrix4 prependScale( const Vector3 &scaleVec, const Matrix4 & mat ); + +// Multiply two 4x4 matrices per element +// +inline const Matrix4 mulPerElem( const Matrix4 & mat0, const Matrix4 & mat1 ); + +// Compute the absolute value of a 4x4 matrix per element +// +inline const Matrix4 absPerElem( const Matrix4 & mat ); + +// Transpose of a 4x4 matrix +// +inline const Matrix4 transpose( const Matrix4 & mat ); + +// Compute the inverse of a 4x4 matrix +// NOTE: +// Result is unpredictable when the determinant of mat is equal to or near 0. +// +inline const Matrix4 inverse( const Matrix4 & mat ); + +// Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix +// NOTE: +// This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. The result is unpredictable when the determinant of mat is equal to or near 0. +// +inline const Matrix4 affineInverse( const Matrix4 & mat ); + +// Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix +// NOTE: +// This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. +// +inline const Matrix4 orthoInverse( const Matrix4 & mat ); + +// Determinant of a 4x4 matrix +// +inline const floatInVec determinant( const Matrix4 & mat ); + +// Conditionally select between two 4x4 matrices +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// However, the transfer of select1 to a VMX register may use more processing time than a branch. +// Use the boolInVec version for better performance. +// +inline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, bool select1 ); + +// Conditionally select between two 4x4 matrices (scalar data contained in vector data type) +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// +inline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, const boolInVec &select1 ); + +#ifdef _VECTORMATH_DEBUG + +// Print a 4x4 matrix +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Matrix4 & mat ); + +// Print a 4x4 matrix and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Matrix4 & mat, const char * name ); + +#endif + +// A 3x4 transformation matrix in array-of-structures format +// +class Transform3 +{ + Vector3 mCol0; + Vector3 mCol1; + Vector3 mCol2; + Vector3 mCol3; + +public: + // Default constructor; does no initialization + // + inline Transform3( ) { }; + + // Copy a 3x4 transformation matrix + // + inline Transform3( const Transform3 & tfrm ); + + // Construct a 3x4 transformation matrix containing the specified columns + // + inline Transform3( const Vector3 &col0, const Vector3 &col1, const Vector3 &col2, const Vector3 &col3 ); + + // Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector + // + inline Transform3( const Matrix3 & tfrm, const Vector3 &translateVec ); + + // Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector + // + inline Transform3( const Quat &unitQuat, const Vector3 &translateVec ); + + // Set all elements of a 3x4 transformation matrix to the same scalar value + // + explicit inline Transform3( float scalar ); + + // Set all elements of a 3x4 transformation matrix to the same scalar value (scalar data contained in vector data type) + // + explicit inline Transform3( const floatInVec &scalar ); + + // Assign one 3x4 transformation matrix to another + // + inline Transform3 & operator =( const Transform3 & tfrm ); + + // Set the upper-left 3x3 submatrix + // + inline Transform3 & setUpper3x3( const Matrix3 & mat3 ); + + // Get the upper-left 3x3 submatrix of a 3x4 transformation matrix + // + inline const Matrix3 getUpper3x3( ) const; + + // Set translation component + // + inline Transform3 & setTranslation( const Vector3 &translateVec ); + + // Get the translation component of a 3x4 transformation matrix + // + inline const Vector3 getTranslation( ) const; + + // Set column 0 of a 3x4 transformation matrix + // + inline Transform3 & setCol0( const Vector3 &col0 ); + + // Set column 1 of a 3x4 transformation matrix + // + inline Transform3 & setCol1( const Vector3 &col1 ); + + // Set column 2 of a 3x4 transformation matrix + // + inline Transform3 & setCol2( const Vector3 &col2 ); + + // Set column 3 of a 3x4 transformation matrix + // + inline Transform3 & setCol3( const Vector3 &col3 ); + + // Get column 0 of a 3x4 transformation matrix + // + inline const Vector3 getCol0( ) const; + + // Get column 1 of a 3x4 transformation matrix + // + inline const Vector3 getCol1( ) const; + + // Get column 2 of a 3x4 transformation matrix + // + inline const Vector3 getCol2( ) const; + + // Get column 3 of a 3x4 transformation matrix + // + inline const Vector3 getCol3( ) const; + + // Set the column of a 3x4 transformation matrix referred to by the specified index + // + inline Transform3 & setCol( int col, const Vector3 &vec ); + + // Set the row of a 3x4 transformation matrix referred to by the specified index + // + inline Transform3 & setRow( int row, const Vector4 &vec ); + + // Get the column of a 3x4 transformation matrix referred to by the specified index + // + inline const Vector3 getCol( int col ) const; + + // Get the row of a 3x4 transformation matrix referred to by the specified index + // + inline const Vector4 getRow( int row ) const; + + // Subscripting operator to set or get a column + // + inline Vector3 & operator []( int col ); + + // Subscripting operator to get a column + // + inline const Vector3 operator []( int col ) const; + + // Set the element of a 3x4 transformation matrix referred to by column and row indices + // + inline Transform3 & setElem( int col, int row, float val ); + + // Set the element of a 3x4 transformation matrix referred to by column and row indices (scalar data contained in vector data type) + // + inline Transform3 & setElem( int col, int row, const floatInVec &val ); + + // Get the element of a 3x4 transformation matrix referred to by column and row indices + // + inline const floatInVec getElem( int col, int row ) const; + + // Multiply a 3x4 transformation matrix by a 3-D vector + // + inline const Vector3 operator *( const Vector3 &vec ) const; + + // Multiply a 3x4 transformation matrix by a 3-D point + // + inline const Point3 operator *( const Point3 &pnt ) const; + + // Multiply two 3x4 transformation matrices + // + inline const Transform3 operator *( const Transform3 & tfrm ) const; + + // Perform compound assignment and multiplication by a 3x4 transformation matrix + // + inline Transform3 & operator *=( const Transform3 & tfrm ); + + // Construct an identity 3x4 transformation matrix + // + static inline const Transform3 identity( ); + + // Construct a 3x4 transformation matrix to rotate around the x axis + // + static inline const Transform3 rotationX( float radians ); + + // Construct a 3x4 transformation matrix to rotate around the y axis + // + static inline const Transform3 rotationY( float radians ); + + // Construct a 3x4 transformation matrix to rotate around the z axis + // + static inline const Transform3 rotationZ( float radians ); + + // Construct a 3x4 transformation matrix to rotate around the x axis (scalar data contained in vector data type) + // + static inline const Transform3 rotationX( const floatInVec &radians ); + + // Construct a 3x4 transformation matrix to rotate around the y axis (scalar data contained in vector data type) + // + static inline const Transform3 rotationY( const floatInVec &radians ); + + // Construct a 3x4 transformation matrix to rotate around the z axis (scalar data contained in vector data type) + // + static inline const Transform3 rotationZ( const floatInVec &radians ); + + // Construct a 3x4 transformation matrix to rotate around the x, y, and z axes + // + static inline const Transform3 rotationZYX( const Vector3 &radiansXYZ ); + + // Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector + // + static inline const Transform3 rotation( float radians, const Vector3 &unitVec ); + + // Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector (scalar data contained in vector data type) + // + static inline const Transform3 rotation( const floatInVec &radians, const Vector3 &unitVec ); + + // Construct a rotation matrix from a unit-length quaternion + // + static inline const Transform3 rotation( const Quat &unitQuat ); + + // Construct a 3x4 transformation matrix to perform scaling + // + static inline const Transform3 scale( const Vector3 &scaleVec ); + + // Construct a 3x4 transformation matrix to perform translation + // + static inline const Transform3 translation( const Vector3 &translateVec ); + +}; +// Append (post-multiply) a scale transformation to a 3x4 transformation matrix +// NOTE: +// Faster than creating and multiplying a scale transformation matrix. +// +inline const Transform3 appendScale( const Transform3 & tfrm, const Vector3 &scaleVec ); + +// Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix +// NOTE: +// Faster than creating and multiplying a scale transformation matrix. +// +inline const Transform3 prependScale( const Vector3 &scaleVec, const Transform3 & tfrm ); + +// Multiply two 3x4 transformation matrices per element +// +inline const Transform3 mulPerElem( const Transform3 & tfrm0, const Transform3 & tfrm1 ); + +// Compute the absolute value of a 3x4 transformation matrix per element +// +inline const Transform3 absPerElem( const Transform3 & tfrm ); + +// Inverse of a 3x4 transformation matrix +// NOTE: +// Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0. +// +inline const Transform3 inverse( const Transform3 & tfrm ); + +// Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix +// NOTE: +// This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions. +// +inline const Transform3 orthoInverse( const Transform3 & tfrm ); + +// Conditionally select between two 3x4 transformation matrices +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// However, the transfer of select1 to a VMX register may use more processing time than a branch. +// Use the boolInVec version for better performance. +// +inline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, bool select1 ); + +// Conditionally select between two 3x4 transformation matrices (scalar data contained in vector data type) +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// +inline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, const boolInVec &select1 ); + +#ifdef _VECTORMATH_DEBUG + +// Print a 3x4 transformation matrix +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Transform3 & tfrm ); + +// Print a 3x4 transformation matrix and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Transform3 & tfrm, const char * name ); + +#endif + +} // namespace Aos +} // namespace Vectormath + +#include "vec_aos.h" +#include "quat_aos.h" +#include "mat_aos.h" + +#endif diff --git a/vectormathlibrary/include/vectormath/c/vectormath_aos.h b/vectormathlibrary/include/vectormath/c/vectormath_aos.h new file mode 100644 index 000000000..73147a3b5 --- /dev/null +++ b/vectormathlibrary/include/vectormath/c/vectormath_aos.h @@ -0,0 +1,41 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_AOS_C_H +#define _VECTORMATH_AOS_C_H + +#if defined(__SPU__) +# include "../spu/c/vectormath_aos.h" +#elif defined(__ALTIVEC__) +# include "../ppu/c/vectormath_aos.h" +#else +# include "../scalar/c/vectormath_aos.h" +#endif + +#endif diff --git a/vectormathlibrary/include/vectormath/c/vectormath_aos_v.h b/vectormathlibrary/include/vectormath/c/vectormath_aos_v.h new file mode 100644 index 000000000..24f085774 --- /dev/null +++ b/vectormathlibrary/include/vectormath/c/vectormath_aos_v.h @@ -0,0 +1,41 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_AOS_C_V_H +#define _VECTORMATH_AOS_C_V_H + +#if defined(__SPU__) +# include "../spu/c/vectormath_aos_v.h" +#elif defined(__ALTIVEC__) +# include "../ppu/c/vectormath_aos_v.h" +#else +# include "../scalar/c/vectormath_aos_v.h" +#endif + +#endif diff --git a/vectormathlibrary/include/vectormath/c/vectormath_soa.h b/vectormathlibrary/include/vectormath/c/vectormath_soa.h new file mode 100644 index 000000000..4e722960a --- /dev/null +++ b/vectormathlibrary/include/vectormath/c/vectormath_soa.h @@ -0,0 +1,41 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_SOA_C_H +#define _VECTORMATH_SOA_C_H + +#if defined(__SPU__) +# include "../spu/c/vectormath_soa.h" +#elif defined(__ALTIVEC__) +# include "../ppu/c/vectormath_soa.h" +#else +# error "Not implemented." +#endif + +#endif diff --git a/vectormathlibrary/include/vectormath/c/vectormath_soa_v.h b/vectormathlibrary/include/vectormath/c/vectormath_soa_v.h new file mode 100644 index 000000000..eaf706b1e --- /dev/null +++ b/vectormathlibrary/include/vectormath/c/vectormath_soa_v.h @@ -0,0 +1,41 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_SOA_C_V_H +#define _VECTORMATH_SOA_C_V_H + +#if defined(__SPU__) +# include "../spu/c/vectormath_soa_v.h" +#elif defined(__ALTIVEC__) +# include "../ppu/c/vectormath_soa_v.h" +#else +# error "Not implemented." +#endif + +#endif diff --git a/vectormathlibrary/include/vectormath/cpp/vectormath_aos.h b/vectormathlibrary/include/vectormath/cpp/vectormath_aos.h new file mode 100644 index 000000000..1be566c1c --- /dev/null +++ b/vectormathlibrary/include/vectormath/cpp/vectormath_aos.h @@ -0,0 +1,43 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_AOS_CPP_H +#define _VECTORMATH_AOS_CPP_H + +#if defined(__SPU__) +# include "../spu/cpp/vectormath_aos.h" +#elif defined(__ALTIVEC__) +# include "../ppu/cpp/vectormath_aos.h" +#elif defined(__SSE__) +# include "../SSE/cpp/vectormath_aos.h" +#else +# include "../scalar/cpp/vectormath_aos.h" +#endif + +#endif diff --git a/vectormathlibrary/include/vectormath/cpp/vectormath_soa.h b/vectormathlibrary/include/vectormath/cpp/vectormath_soa.h new file mode 100644 index 000000000..854ece117 --- /dev/null +++ b/vectormathlibrary/include/vectormath/cpp/vectormath_soa.h @@ -0,0 +1,41 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_SOA_CPP_H +#define _VECTORMATH_SOA_CPP_H + +#if defined(__SPU__) +# include "../spu/cpp/vectormath_soa.h" +#elif defined(__ALTIVEC__) +# include "../ppu/cpp/vectormath_soa.h" +#else +# error "Not implemented." +#endif + +#endif diff --git a/vectormathlibrary/include/vectormath/ppu/c/mat_aos.h b/vectormathlibrary/include/vectormath/ppu/c/mat_aos.h new file mode 100644 index 000000000..13f482150 --- /dev/null +++ b/vectormathlibrary/include/vectormath/ppu/c/mat_aos.h @@ -0,0 +1,1833 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_MAT_AOS_C_H +#define _VECTORMATH_MAT_AOS_C_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/*----------------------------------------------------------------------------- + * Constants + * for shuffles, words are labeled [x,y,z,w] [a,b,c,d] + */ +#define _VECTORMATH_PERM_ZBWX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B, _VECTORMATH_PERM_W, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_XCYX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_C, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_XYAB ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A, _VECTORMATH_PERM_B }) +#define _VECTORMATH_PERM_ZWCD ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_W, _VECTORMATH_PERM_C, _VECTORMATH_PERM_D }) +#define _VECTORMATH_PERM_XZBX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_CXXX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_C, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_YAXX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_XAZC ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_A, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_C }) +#define _VECTORMATH_PERM_YXWZ ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X, _VECTORMATH_PERM_W, _VECTORMATH_PERM_Z }) +#define _VECTORMATH_PERM_YBWD ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_B, _VECTORMATH_PERM_W, _VECTORMATH_PERM_D }) +#define _VECTORMATH_PERM_XYCX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_C, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_YCXY ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_C, _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y }) +#define _VECTORMATH_PERM_CXYC ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_C, _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_C }) +#define _VECTORMATH_PERM_ZAYX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_BZXX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_B, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_XZYA ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A }) +#define _VECTORMATH_PERM_ZXXB ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X, _VECTORMATH_PERM_B }) +#define _VECTORMATH_PERM_YXXC ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X, _VECTORMATH_PERM_C }) +#define _VECTORMATH_PERM_BBYX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_B, _VECTORMATH_PERM_B, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PI_OVER_2 1.570796327f + +/*----------------------------------------------------------------------------- + * Definitions + */ +static inline void vmathM3Copy( VmathMatrix3 *result, const VmathMatrix3 *mat ) +{ + vmathV3Copy( &result->col0, &mat->col0 ); + vmathV3Copy( &result->col1, &mat->col1 ); + vmathV3Copy( &result->col2, &mat->col2 ); +} + +static inline void vmathM3MakeFromScalar( VmathMatrix3 *result, float scalar ) +{ + vmathV3MakeFromScalar( &result->col0, scalar ); + vmathV3MakeFromScalar( &result->col1, scalar ); + vmathV3MakeFromScalar( &result->col2, scalar ); +} + +static inline void vmathM3MakeFromQ( VmathMatrix3 *result, const VmathQuat *unitQuat ) +{ + vec_float4 xyzw_2, wwww, yzxw, zxyw, yzxw_2, zxyw_2; + vec_float4 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; + vec_uint4 select_x = _VECTORMATH_MASK_0xF000; + vec_uint4 select_z = _VECTORMATH_MASK_0x00F0; + xyzw_2 = vec_add( unitQuat->vec128, unitQuat->vec128 ); + wwww = vec_splat( unitQuat->vec128, 3 ); + yzxw = vec_perm( unitQuat->vec128, unitQuat->vec128, _VECTORMATH_PERM_YZXW ); + zxyw = vec_perm( unitQuat->vec128, unitQuat->vec128, _VECTORMATH_PERM_ZXYW ); + yzxw_2 = vec_perm( xyzw_2, xyzw_2, _VECTORMATH_PERM_YZXW ); + zxyw_2 = vec_perm( xyzw_2, xyzw_2, _VECTORMATH_PERM_ZXYW ); + tmp0 = vec_madd( yzxw_2, wwww, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + tmp1 = vec_nmsub( yzxw, yzxw_2, ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); + tmp2 = vec_madd( yzxw, xyzw_2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + tmp0 = vec_madd( zxyw, xyzw_2, tmp0 ); + tmp1 = vec_nmsub( zxyw, zxyw_2, tmp1 ); + tmp2 = vec_nmsub( zxyw_2, wwww, tmp2 ); + tmp3 = vec_sel( tmp0, tmp1, select_x ); + tmp4 = vec_sel( tmp1, tmp2, select_x ); + tmp5 = vec_sel( tmp2, tmp0, select_x ); + result->col0.vec128 = vec_sel( tmp3, tmp2, select_z ); + result->col1.vec128 = vec_sel( tmp4, tmp0, select_z ); + result->col2.vec128 = vec_sel( tmp5, tmp1, select_z ); +} + +static inline void vmathM3MakeFromCols( VmathMatrix3 *result, const VmathVector3 *_col0, const VmathVector3 *_col1, const VmathVector3 *_col2 ) +{ + vmathV3Copy( &result->col0, _col0 ); + vmathV3Copy( &result->col1, _col1 ); + vmathV3Copy( &result->col2, _col2 ); +} + +static inline void vmathM3SetCol0( VmathMatrix3 *result, const VmathVector3 *_col0 ) +{ + vmathV3Copy( &result->col0, _col0 ); +} + +static inline void vmathM3SetCol1( VmathMatrix3 *result, const VmathVector3 *_col1 ) +{ + vmathV3Copy( &result->col1, _col1 ); +} + +static inline void vmathM3SetCol2( VmathMatrix3 *result, const VmathVector3 *_col2 ) +{ + vmathV3Copy( &result->col2, _col2 ); +} + +static inline void vmathM3SetCol( VmathMatrix3 *result, int col, const VmathVector3 *vec ) +{ + vmathV3Copy( (&result->col0 + col), vec ); +} + +static inline void vmathM3SetRow( VmathMatrix3 *result, int row, const VmathVector3 *vec ) +{ + vmathV3SetElem( &result->col0, row, vmathV3GetElem( vec, 0 ) ); + vmathV3SetElem( &result->col1, row, vmathV3GetElem( vec, 1 ) ); + vmathV3SetElem( &result->col2, row, vmathV3GetElem( vec, 2 ) ); +} + +static inline void vmathM3SetElem( VmathMatrix3 *result, int col, int row, float val ) +{ + VmathVector3 tmpV3_0; + vmathM3GetCol( &tmpV3_0, result, col ); + vmathV3SetElem( &tmpV3_0, row, val ); + vmathM3SetCol( result, col, &tmpV3_0 ); +} + +static inline float vmathM3GetElem( const VmathMatrix3 *mat, int col, int row ) +{ + VmathVector3 tmpV3_0; + vmathM3GetCol( &tmpV3_0, mat, col ); + return vmathV3GetElem( &tmpV3_0, row ); +} + +static inline void vmathM3GetCol0( VmathVector3 *result, const VmathMatrix3 *mat ) +{ + vmathV3Copy( result, &mat->col0 ); +} + +static inline void vmathM3GetCol1( VmathVector3 *result, const VmathMatrix3 *mat ) +{ + vmathV3Copy( result, &mat->col1 ); +} + +static inline void vmathM3GetCol2( VmathVector3 *result, const VmathMatrix3 *mat ) +{ + vmathV3Copy( result, &mat->col2 ); +} + +static inline void vmathM3GetCol( VmathVector3 *result, const VmathMatrix3 *mat, int col ) +{ + vmathV3Copy( result, (&mat->col0 + col) ); +} + +static inline void vmathM3GetRow( VmathVector3 *result, const VmathMatrix3 *mat, int row ) +{ + vmathV3MakeFromElems( result, vmathV3GetElem( &mat->col0, row ), vmathV3GetElem( &mat->col1, row ), vmathV3GetElem( &mat->col2, row ) ); +} + +static inline void vmathM3Transpose( VmathMatrix3 *result, const VmathMatrix3 *mat ) +{ + vec_float4 tmp0, tmp1, res0, res1, res2; + tmp0 = vec_mergeh( mat->col0.vec128, mat->col2.vec128 ); + tmp1 = vec_mergel( mat->col0.vec128, mat->col2.vec128 ); + res0 = vec_mergeh( tmp0, mat->col1.vec128 ); + res1 = vec_perm( tmp0, mat->col1.vec128, _VECTORMATH_PERM_ZBWX ); + res2 = vec_perm( tmp1, mat->col1.vec128, _VECTORMATH_PERM_XCYX ); + result->col0.vec128 = res0; + result->col1.vec128 = res1; + result->col2.vec128 = res2; +} + +static inline void vmathM3Inverse( VmathMatrix3 *result, const VmathMatrix3 *mat ) +{ + vec_float4 tmp0, tmp1, tmp2, tmp3, tmp4, dot, invdet, inv0, inv1, inv2; + vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + tmp2 = _vmathVfCross( mat->col0.vec128, mat->col1.vec128 ); + tmp0 = _vmathVfCross( mat->col1.vec128, mat->col2.vec128 ); + tmp1 = _vmathVfCross( mat->col2.vec128, mat->col0.vec128 ); + dot = _vmathVfDot3( tmp2, mat->col2.vec128 ); + dot = vec_splat( dot, 0 ); + invdet = recipf4( dot ); + tmp3 = vec_mergeh( tmp0, tmp2 ); + tmp4 = vec_mergel( tmp0, tmp2 ); + inv0 = vec_mergeh( tmp3, tmp1 ); + inv1 = vec_perm( tmp3, tmp1, _VECTORMATH_PERM_ZBWX ); + inv2 = vec_perm( tmp4, tmp1, _VECTORMATH_PERM_XCYX ); + inv0 = vec_madd( inv0, invdet, zero ); + inv1 = vec_madd( inv1, invdet, zero ); + inv2 = vec_madd( inv2, invdet, zero ); + result->col0.vec128 = inv0; + result->col1.vec128 = inv1; + result->col2.vec128 = inv2; +} + +static inline float vmathM3Determinant( const VmathMatrix3 *mat ) +{ + VmathVector3 tmpV3_0; + vmathV3Cross( &tmpV3_0, &mat->col0, &mat->col1 ); + return vmathV3Dot( &mat->col2, &tmpV3_0 ); +} + +static inline void vmathM3Add( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ) +{ + vmathV3Add( &result->col0, &mat0->col0, &mat1->col0 ); + vmathV3Add( &result->col1, &mat0->col1, &mat1->col1 ); + vmathV3Add( &result->col2, &mat0->col2, &mat1->col2 ); +} + +static inline void vmathM3Sub( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ) +{ + vmathV3Sub( &result->col0, &mat0->col0, &mat1->col0 ); + vmathV3Sub( &result->col1, &mat0->col1, &mat1->col1 ); + vmathV3Sub( &result->col2, &mat0->col2, &mat1->col2 ); +} + +static inline void vmathM3Neg( VmathMatrix3 *result, const VmathMatrix3 *mat ) +{ + vmathV3Neg( &result->col0, &mat->col0 ); + vmathV3Neg( &result->col1, &mat->col1 ); + vmathV3Neg( &result->col2, &mat->col2 ); +} + +static inline void vmathM3AbsPerElem( VmathMatrix3 *result, const VmathMatrix3 *mat ) +{ + vmathV3AbsPerElem( &result->col0, &mat->col0 ); + vmathV3AbsPerElem( &result->col1, &mat->col1 ); + vmathV3AbsPerElem( &result->col2, &mat->col2 ); +} + +static inline void vmathM3ScalarMul( VmathMatrix3 *result, const VmathMatrix3 *mat, float scalar ) +{ + vmathV3ScalarMul( &result->col0, &mat->col0, scalar ); + vmathV3ScalarMul( &result->col1, &mat->col1, scalar ); + vmathV3ScalarMul( &result->col2, &mat->col2, scalar ); +} + +static inline void vmathM3MulV3( VmathVector3 *result, const VmathMatrix3 *mat, const VmathVector3 *vec ) +{ + vec_float4 res; + vec_float4 xxxx, yyyy, zzzz; + xxxx = vec_splat( vec->vec128, 0 ); + yyyy = vec_splat( vec->vec128, 1 ); + zzzz = vec_splat( vec->vec128, 2 ); + res = vec_madd( mat->col0.vec128, xxxx, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + res = vec_madd( mat->col1.vec128, yyyy, res ); + res = vec_madd( mat->col2.vec128, zzzz, res ); + result->vec128 = res; +} + +static inline void vmathM3Mul( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ) +{ + VmathMatrix3 tmpResult; + vmathM3MulV3( &tmpResult.col0, mat0, &mat1->col0 ); + vmathM3MulV3( &tmpResult.col1, mat0, &mat1->col1 ); + vmathM3MulV3( &tmpResult.col2, mat0, &mat1->col2 ); + vmathM3Copy( result, &tmpResult ); +} + +static inline void vmathM3MulPerElem( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ) +{ + vmathV3MulPerElem( &result->col0, &mat0->col0, &mat1->col0 ); + vmathV3MulPerElem( &result->col1, &mat0->col1, &mat1->col1 ); + vmathV3MulPerElem( &result->col2, &mat0->col2, &mat1->col2 ); +} + +static inline void vmathM3MakeIdentity( VmathMatrix3 *result ) +{ + vmathV3MakeXAxis( &result->col0 ); + vmathV3MakeYAxis( &result->col1 ); + vmathV3MakeZAxis( &result->col2 ); +} + +static inline void vmathM3MakeRotationX( VmathMatrix3 *result, float radians ) +{ + vec_float4 s, c, res1, res2; + vec_uint4 select_y, select_z; + vec_float4 zero; + select_y = _VECTORMATH_MASK_0x0F00; + select_z = _VECTORMATH_MASK_0x00F0; + zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + sincosf4( _vmathVfSplatScalar(radians), &s, &c ); + res1 = vec_sel( zero, c, select_y ); + res1 = vec_sel( res1, s, select_z ); + res2 = vec_sel( zero, negatef4(s), select_y ); + res2 = vec_sel( res2, c, select_z ); + vmathV3MakeXAxis( &result->col0 ); + result->col1.vec128 = res1; + result->col2.vec128 = res2; +} + +static inline void vmathM3MakeRotationY( VmathMatrix3 *result, float radians ) +{ + vec_float4 s, c, res0, res2; + vec_uint4 select_x, select_z; + vec_float4 zero; + select_x = _VECTORMATH_MASK_0xF000; + select_z = _VECTORMATH_MASK_0x00F0; + zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + sincosf4( _vmathVfSplatScalar(radians), &s, &c ); + res0 = vec_sel( zero, c, select_x ); + res0 = vec_sel( res0, negatef4(s), select_z ); + res2 = vec_sel( zero, s, select_x ); + res2 = vec_sel( res2, c, select_z ); + result->col0.vec128 = res0; + vmathV3MakeYAxis( &result->col1 ); + result->col2.vec128 = res2; +} + +static inline void vmathM3MakeRotationZ( VmathMatrix3 *result, float radians ) +{ + vec_float4 s, c, res0, res1; + vec_uint4 select_x, select_y; + vec_float4 zero; + select_x = _VECTORMATH_MASK_0xF000; + select_y = _VECTORMATH_MASK_0x0F00; + zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + sincosf4( _vmathVfSplatScalar(radians), &s, &c ); + res0 = vec_sel( zero, c, select_x ); + res0 = vec_sel( res0, s, select_y ); + res1 = vec_sel( zero, negatef4(s), select_x ); + res1 = vec_sel( res1, c, select_y ); + result->col0.vec128 = res0; + result->col1.vec128 = res1; + vmathV3MakeZAxis( &result->col2 ); +} + +static inline void vmathM3MakeRotationZYX( VmathMatrix3 *result, const VmathVector3 *radiansXYZ ) +{ + VmathVector4 tmpV4_0; + vec_float4 angles, s, negS, c, X0, X1, Y0, Y1, Z0, Z1, tmp; + vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + vmathV4MakeFromV3Scalar( &tmpV4_0, radiansXYZ, 0.0f ); + angles = tmpV4_0.vec128; + sincosf4( angles, &s, &c ); + negS = negatef4( s ); + Z0 = vec_mergel( c, s ); + Z1 = vec_mergel( negS, c ); + Z1 = vec_andc( Z1, (vec_float4)_VECTORMATH_MASK_0x000F ); + Y0 = vec_perm( negS, c, _VECTORMATH_PERM_BBYX ); + Y1 = vec_perm( c, s, _VECTORMATH_PERM_BBYX ); + X0 = vec_splat( s, 0 ); + X1 = vec_splat( c, 0 ); + tmp = vec_madd( Z0, Y1, zero ); + result->col0.vec128 = vec_madd( Z0, Y0, zero ); + result->col1.vec128 = vec_madd( Z1, X1, vec_madd( tmp, X0, zero ) ); + result->col2.vec128 = vec_nmsub( Z1, X0, vec_madd( tmp, X1, zero ) ); +} + +static inline void vmathM3MakeRotationAxis( VmathMatrix3 *result, float radians, const VmathVector3 *unitVec ) +{ + vec_float4 axis, s, c, oneMinusC, axisS, negAxisS, xxxx, yyyy, zzzz, tmp0, tmp1, tmp2; + vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + axis = unitVec->vec128; + sincosf4( (vec_float4){radians,radians,radians,radians}, &s, &c ); + xxxx = vec_splat( axis, 0 ); + yyyy = vec_splat( axis, 1 ); + zzzz = vec_splat( axis, 2 ); + oneMinusC = vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), c ); + axisS = vec_madd( axis, s, zero ); + negAxisS = negatef4( axisS ); + tmp0 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_XZBX ); + tmp1 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_CXXX ); + tmp2 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_YAXX ); + tmp0 = vec_sel( tmp0, c, _VECTORMATH_MASK_0xF000 ); + tmp1 = vec_sel( tmp1, c, _VECTORMATH_MASK_0x0F00 ); + tmp2 = vec_sel( tmp2, c, _VECTORMATH_MASK_0x00F0 ); + result->col0.vec128 = vec_madd( vec_madd( axis, xxxx, zero ), oneMinusC, tmp0 ); + result->col1.vec128 = vec_madd( vec_madd( axis, yyyy, zero ), oneMinusC, tmp1 ); + result->col2.vec128 = vec_madd( vec_madd( axis, zzzz, zero ), oneMinusC, tmp2 ); +} + +static inline void vmathM3MakeRotationQ( VmathMatrix3 *result, const VmathQuat *unitQuat ) +{ + vmathM3MakeFromQ( result, unitQuat ); +} + +static inline void vmathM3MakeScale( VmathMatrix3 *result, const VmathVector3 *scaleVec ) +{ + vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + result->col0.vec128 = vec_sel( zero, scaleVec->vec128, _VECTORMATH_MASK_0xF000 ); + result->col1.vec128 = vec_sel( zero, scaleVec->vec128, _VECTORMATH_MASK_0x0F00 ); + result->col2.vec128 = vec_sel( zero, scaleVec->vec128, _VECTORMATH_MASK_0x00F0 ); +} + +static inline void vmathM3AppendScale( VmathMatrix3 *result, const VmathMatrix3 *mat, const VmathVector3 *scaleVec ) +{ + vmathV3ScalarMul( &result->col0, &mat->col0, vmathV3GetX( scaleVec ) ); + vmathV3ScalarMul( &result->col1, &mat->col1, vmathV3GetY( scaleVec ) ); + vmathV3ScalarMul( &result->col2, &mat->col2, vmathV3GetZ( scaleVec ) ); +} + +static inline void vmathM3PrependScale( VmathMatrix3 *result, const VmathVector3 *scaleVec, const VmathMatrix3 *mat ) +{ + vmathV3MulPerElem( &result->col0, &mat->col0, scaleVec ); + vmathV3MulPerElem( &result->col1, &mat->col1, scaleVec ); + vmathV3MulPerElem( &result->col2, &mat->col2, scaleVec ); +} + +static inline void vmathM3Select( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1, unsigned int select1 ) +{ + vmathV3Select( &result->col0, &mat0->col0, &mat1->col0, select1 ); + vmathV3Select( &result->col1, &mat0->col1, &mat1->col1, select1 ); + vmathV3Select( &result->col2, &mat0->col2, &mat1->col2, select1 ); +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathM3Print( const VmathMatrix3 *mat ) +{ + VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2; + vmathM3GetRow( &tmpV3_0, mat, 0 ); + vmathV3Print( &tmpV3_0 ); + vmathM3GetRow( &tmpV3_1, mat, 1 ); + vmathV3Print( &tmpV3_1 ); + vmathM3GetRow( &tmpV3_2, mat, 2 ); + vmathV3Print( &tmpV3_2 ); +} + +static inline void vmathM3Prints( const VmathMatrix3 *mat, const char *name ) +{ + printf("%s:\n", name); + vmathM3Print( mat ); +} + +#endif + +static inline void vmathM4Copy( VmathMatrix4 *result, const VmathMatrix4 *mat ) +{ + vmathV4Copy( &result->col0, &mat->col0 ); + vmathV4Copy( &result->col1, &mat->col1 ); + vmathV4Copy( &result->col2, &mat->col2 ); + vmathV4Copy( &result->col3, &mat->col3 ); +} + +static inline void vmathM4MakeFromScalar( VmathMatrix4 *result, float scalar ) +{ + vmathV4MakeFromScalar( &result->col0, scalar ); + vmathV4MakeFromScalar( &result->col1, scalar ); + vmathV4MakeFromScalar( &result->col2, scalar ); + vmathV4MakeFromScalar( &result->col3, scalar ); +} + +static inline void vmathM4MakeFromT3( VmathMatrix4 *result, const VmathTransform3 *mat ) +{ + vmathV4MakeFromV3Scalar( &result->col0, &mat->col0, 0.0f ); + vmathV4MakeFromV3Scalar( &result->col1, &mat->col1, 0.0f ); + vmathV4MakeFromV3Scalar( &result->col2, &mat->col2, 0.0f ); + vmathV4MakeFromV3Scalar( &result->col3, &mat->col3, 1.0f ); +} + +static inline void vmathM4MakeFromCols( VmathMatrix4 *result, const VmathVector4 *_col0, const VmathVector4 *_col1, const VmathVector4 *_col2, const VmathVector4 *_col3 ) +{ + vmathV4Copy( &result->col0, _col0 ); + vmathV4Copy( &result->col1, _col1 ); + vmathV4Copy( &result->col2, _col2 ); + vmathV4Copy( &result->col3, _col3 ); +} + +static inline void vmathM4MakeFromM3V3( VmathMatrix4 *result, const VmathMatrix3 *mat, const VmathVector3 *translateVec ) +{ + vmathV4MakeFromV3Scalar( &result->col0, &mat->col0, 0.0f ); + vmathV4MakeFromV3Scalar( &result->col1, &mat->col1, 0.0f ); + vmathV4MakeFromV3Scalar( &result->col2, &mat->col2, 0.0f ); + vmathV4MakeFromV3Scalar( &result->col3, translateVec, 1.0f ); +} + +static inline void vmathM4MakeFromQV3( VmathMatrix4 *result, const VmathQuat *unitQuat, const VmathVector3 *translateVec ) +{ + VmathMatrix3 mat; + vmathM3MakeFromQ( &mat, unitQuat ); + vmathV4MakeFromV3Scalar( &result->col0, &mat.col0, 0.0f ); + vmathV4MakeFromV3Scalar( &result->col1, &mat.col1, 0.0f ); + vmathV4MakeFromV3Scalar( &result->col2, &mat.col2, 0.0f ); + vmathV4MakeFromV3Scalar( &result->col3, translateVec, 1.0f ); +} + +static inline void vmathM4SetCol0( VmathMatrix4 *result, const VmathVector4 *_col0 ) +{ + vmathV4Copy( &result->col0, _col0 ); +} + +static inline void vmathM4SetCol1( VmathMatrix4 *result, const VmathVector4 *_col1 ) +{ + vmathV4Copy( &result->col1, _col1 ); +} + +static inline void vmathM4SetCol2( VmathMatrix4 *result, const VmathVector4 *_col2 ) +{ + vmathV4Copy( &result->col2, _col2 ); +} + +static inline void vmathM4SetCol3( VmathMatrix4 *result, const VmathVector4 *_col3 ) +{ + vmathV4Copy( &result->col3, _col3 ); +} + +static inline void vmathM4SetCol( VmathMatrix4 *result, int col, const VmathVector4 *vec ) +{ + vmathV4Copy( (&result->col0 + col), vec ); +} + +static inline void vmathM4SetRow( VmathMatrix4 *result, int row, const VmathVector4 *vec ) +{ + vmathV4SetElem( &result->col0, row, vmathV4GetElem( vec, 0 ) ); + vmathV4SetElem( &result->col1, row, vmathV4GetElem( vec, 1 ) ); + vmathV4SetElem( &result->col2, row, vmathV4GetElem( vec, 2 ) ); + vmathV4SetElem( &result->col3, row, vmathV4GetElem( vec, 3 ) ); +} + +static inline void vmathM4SetElem( VmathMatrix4 *result, int col, int row, float val ) +{ + VmathVector4 tmpV3_0; + vmathM4GetCol( &tmpV3_0, result, col ); + vmathV4SetElem( &tmpV3_0, row, val ); + vmathM4SetCol( result, col, &tmpV3_0 ); +} + +static inline float vmathM4GetElem( const VmathMatrix4 *mat, int col, int row ) +{ + VmathVector4 tmpV4_0; + vmathM4GetCol( &tmpV4_0, mat, col ); + return vmathV4GetElem( &tmpV4_0, row ); +} + +static inline void vmathM4GetCol0( VmathVector4 *result, const VmathMatrix4 *mat ) +{ + vmathV4Copy( result, &mat->col0 ); +} + +static inline void vmathM4GetCol1( VmathVector4 *result, const VmathMatrix4 *mat ) +{ + vmathV4Copy( result, &mat->col1 ); +} + +static inline void vmathM4GetCol2( VmathVector4 *result, const VmathMatrix4 *mat ) +{ + vmathV4Copy( result, &mat->col2 ); +} + +static inline void vmathM4GetCol3( VmathVector4 *result, const VmathMatrix4 *mat ) +{ + vmathV4Copy( result, &mat->col3 ); +} + +static inline void vmathM4GetCol( VmathVector4 *result, const VmathMatrix4 *mat, int col ) +{ + vmathV4Copy( result, (&mat->col0 + col) ); +} + +static inline void vmathM4GetRow( VmathVector4 *result, const VmathMatrix4 *mat, int row ) +{ + vmathV4MakeFromElems( result, vmathV4GetElem( &mat->col0, row ), vmathV4GetElem( &mat->col1, row ), vmathV4GetElem( &mat->col2, row ), vmathV4GetElem( &mat->col3, row ) ); +} + +static inline void vmathM4Transpose( VmathMatrix4 *result, const VmathMatrix4 *mat ) +{ + vec_float4 tmp0, tmp1, tmp2, tmp3, res0, res1, res2, res3; + tmp0 = vec_mergeh( mat->col0.vec128, mat->col2.vec128 ); + tmp1 = vec_mergeh( mat->col1.vec128, mat->col3.vec128 ); + tmp2 = vec_mergel( mat->col0.vec128, mat->col2.vec128 ); + tmp3 = vec_mergel( mat->col1.vec128, mat->col3.vec128 ); + res0 = vec_mergeh( tmp0, tmp1 ); + res1 = vec_mergel( tmp0, tmp1 ); + res2 = vec_mergeh( tmp2, tmp3 ); + res3 = vec_mergel( tmp2, tmp3 ); + result->col0.vec128 = res0; + result->col1.vec128 = res1; + result->col2.vec128 = res2; + result->col3.vec128 = res3; +} + +static inline void vmathM4Inverse( VmathMatrix4 *result, const VmathMatrix4 *mat ) +{ + /* function implementation based on code from STIDC SDK: */ + /* -------------------------------------------------------------- */ + /* PLEASE DO NOT MODIFY THIS SECTION */ + /* This prolog section is automatically generated. */ + /* */ + /* (C)Copyright */ + /* Sony Computer Entertainment, Inc., */ + /* Toshiba Corporation, */ + /* International Business Machines Corporation, */ + /* 2001,2002. */ + /* S/T/I Confidential Information */ + /* -------------------------------------------------------------- */ + vector float in0, in1, in2, in3; + vector float tmp0, tmp1, tmp2, tmp3; + vector float cof0, cof1, cof2, cof3; + vector float t0, t1, t2, t3; + vector float t01, t02, t03, t12, t23; + vector float t1r, t2r; + vector float t01r, t02r, t03r, t12r, t23r; + vector float t1r3, t1r3r; + vector float det, det0, det1, det2, det3, invdet; + vector float vzero = (vector float){0.0}; + in0 = mat->col0.vec128; + in1 = mat->col1.vec128; + in2 = mat->col2.vec128; + in3 = mat->col3.vec128; + /* Perform transform of the input matrix of the form: + * A B C D + * E F G H + * I J K L + * M N O P + * + * The pseudo transpose of the input matrix is trans: + * A E I M + * J N B F + * C G K O + * L P D H + */ + tmp0 = vec_perm(in0, in1, _VECTORMATH_PERM_XAZC); /* A E C G */ + tmp1 = vec_perm(in2, in3, _VECTORMATH_PERM_XAZC); /* I M K O */ + tmp2 = vec_perm(in0, in1, _VECTORMATH_PERM_YBWD); /* B F D H */ + tmp3 = vec_perm(in2, in3, _VECTORMATH_PERM_YBWD); /* J N L P */ + t0 = vec_perm(tmp0, tmp1, _VECTORMATH_PERM_XYAB); /* A E I M */ + t1 = vec_perm(tmp3, tmp2, _VECTORMATH_PERM_XYAB); /* J N B F */ + t2 = vec_perm(tmp0, tmp1, _VECTORMATH_PERM_ZWCD); /* C G K O */ + t3 = vec_perm(tmp3, tmp2, _VECTORMATH_PERM_ZWCD); /* L P D H */ + /* Generate a cofactor matrix. The computed cofactors reside in + * cof0, cof1, cof2, cof3. + */ + t23 = vec_madd(t2, t3, vzero); /* CL GP KD OH */ + t23 = vec_perm(t23, t23, _VECTORMATH_PERM_YXWZ); /* GP CL OH KD */ + cof0 = vec_nmsub(t1, t23, vzero); /* -(JGP NCL FOH BKD) */ + cof1 = vec_nmsub(t0, t23, vzero); /* -(AGP ECL IOH MKD) */ + t23r = vec_sld(t23, t23, 8); /* OH KD GP CL */ + cof0 = vec_madd(t1, t23r, cof0); /* JOH NKD BGP FCL + cof0 */ + cof1 = vec_madd(t0, t23r, cof1); /* AOH EKD IGP MCL + cof1 */ + cof1 = vec_sld(cof1, cof1, 8); /* IGP MCL AOH EKD - IOH MKD AGP ECL */ + t12 = vec_madd(t1, t2, vzero); /* JC NG BK FO */ + t12 = vec_perm(t12, t12, _VECTORMATH_PERM_YXWZ); /* NG JC FO BK */ + cof0 = vec_madd(t3, t12, cof0); /* LNG PJC DFO HBK + cof0 */ + cof3 = vec_madd(t0, t12, vzero); /* ANG EJC IFO MBK */ + t12r = vec_sld(t12, t12, 8); /* FO BK NG JC */ + cof0 = vec_nmsub(t3, t12r, cof0); /* cof0 - LFO PBK DNG HJC */ + cof3 = vec_nmsub(t0, t12r, cof3); /* cof3 - AFO EBK ING MJC */ + cof3 = vec_sld(cof3, cof3, 8); /* ING MJC AFO EBK - IFO MBK ANG EJC */ + t1r = vec_sld(t1, t1, 8); /* B F J N */ + t2r = vec_sld(t2, t2, 8); /* K O C G */ + t1r3 = vec_madd(t1r, t3, vzero); /* BL FP JD NH */ + t1r3 = vec_perm(t1r3, t1r3, _VECTORMATH_PERM_YXWZ); /* FP BL NH JD */ + cof0 = vec_madd(t2r, t1r3, cof0); /* KFP OBL CNH GJD + cof0 */ + cof2 = vec_madd(t0, t1r3, vzero); /* AFP EBL INH MJD */ + t1r3r = vec_sld(t1r3, t1r3, 8); /* NH JD FP BL */ + cof0 = vec_nmsub(t2r, t1r3r, cof0); /* cof0 - KNH OJD CFP GBL */ + cof2 = vec_nmsub(t0, t1r3r, cof2); /* cof2 - ANH EJD IFP MBL */ + cof2 = vec_sld(cof2, cof2, 8); /* IFP MBL ANH EJD - INH MJD AFP EBL */ + t01 = vec_madd(t0, t1, vzero); /* AJ EN IB MF */ + t01 = vec_perm(t01, t01, _VECTORMATH_PERM_YXWZ); /* EN AJ MF IB */ + cof2 = vec_nmsub(t3, t01, cof2); /* cof2 - LEN PAJ DMF HIB */ + cof3 = vec_madd(t2r, t01, cof3); /* KEN OAJ CMF GIB + cof3 */ + t01r = vec_sld(t01, t01, 8); /* MF IB EN AJ */ + cof2 = vec_madd(t3, t01r, cof2); /* LMF PIB DEN HAJ + cof2 */ + cof3 = vec_nmsub(t2r, t01r, cof3); /* cof3 - KMF OIB CEN GAJ */ + t03 = vec_madd(t0, t3, vzero); /* AL EP ID MH */ + t03 = vec_perm(t03, t03, _VECTORMATH_PERM_YXWZ); /* EP AL MH ID */ + cof1 = vec_nmsub(t2r, t03, cof1); /* cof1 - KEP OAL CMH GID */ + cof2 = vec_madd(t1, t03, cof2); /* JEP NAL BMH FID + cof2 */ + t03r = vec_sld(t03, t03, 8); /* MH ID EP AL */ + cof1 = vec_madd(t2r, t03r, cof1); /* KMH OID CEP GAL + cof1 */ + cof2 = vec_nmsub(t1, t03r, cof2); /* cof2 - JMH NID BEP FAL */ + t02 = vec_madd(t0, t2r, vzero); /* AK EO IC MG */ + t02 = vec_perm(t02, t02, _VECTORMATH_PERM_YXWZ); /* E0 AK MG IC */ + cof1 = vec_madd(t3, t02, cof1); /* LEO PAK DMG HIC + cof1 */ + cof3 = vec_nmsub(t1, t02, cof3); /* cof3 - JEO NAK BMG FIC */ + t02r = vec_sld(t02, t02, 8); /* MG IC EO AK */ + cof1 = vec_nmsub(t3, t02r, cof1); /* cof1 - LMG PIC DEO HAK */ + cof3 = vec_madd(t1, t02r, cof3); /* JMG NIC BEO FAK + cof3 */ + /* Compute the determinant of the matrix + * + * det = sum_across(t0 * cof0); + * + * We perform a sum across the entire vector so that + * we don't have to splat the result when multiplying the + * cofactors by the inverse of the determinant. + */ + det = vec_madd(t0, cof0, vzero); + det0 = vec_splat(det, 0); + det1 = vec_splat(det, 1); + det2 = vec_splat(det, 2); + det3 = vec_splat(det, 3); + det = vec_add(det0, det1); + det2 = vec_add(det2, det3); + det = vec_add(det, det2); + /* Compute the reciprocal of the determinant. + */ + invdet = recipf4(det); + /* Multiply the cofactors by the reciprocal of the determinant. + */ + result->col0.vec128 = vec_madd(cof0, invdet, vzero); + result->col1.vec128 = vec_madd(cof1, invdet, vzero); + result->col2.vec128 = vec_madd(cof2, invdet, vzero); + result->col3.vec128 = vec_madd(cof3, invdet, vzero); +} + +static inline void vmathM4AffineInverse( VmathMatrix4 *result, const VmathMatrix4 *mat ) +{ + VmathTransform3 affineMat, tmpT3_0; + VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3; + vmathV4GetXYZ( &tmpV3_0, &mat->col0 ); + vmathT3SetCol0( &affineMat, &tmpV3_0 ); + vmathV4GetXYZ( &tmpV3_1, &mat->col1 ); + vmathT3SetCol1( &affineMat, &tmpV3_1 ); + vmathV4GetXYZ( &tmpV3_2, &mat->col2 ); + vmathT3SetCol2( &affineMat, &tmpV3_2 ); + vmathV4GetXYZ( &tmpV3_3, &mat->col3 ); + vmathT3SetCol3( &affineMat, &tmpV3_3 ); + vmathT3Inverse( &tmpT3_0, &affineMat ); + vmathM4MakeFromT3( result, &tmpT3_0 ); +} + +static inline void vmathM4OrthoInverse( VmathMatrix4 *result, const VmathMatrix4 *mat ) +{ + VmathTransform3 affineMat, tmpT3_0; + VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3; + vmathV4GetXYZ( &tmpV3_0, &mat->col0 ); + vmathT3SetCol0( &affineMat, &tmpV3_0 ); + vmathV4GetXYZ( &tmpV3_1, &mat->col1 ); + vmathT3SetCol1( &affineMat, &tmpV3_1 ); + vmathV4GetXYZ( &tmpV3_2, &mat->col2 ); + vmathT3SetCol2( &affineMat, &tmpV3_2 ); + vmathV4GetXYZ( &tmpV3_3, &mat->col3 ); + vmathT3SetCol3( &affineMat, &tmpV3_3 ); + vmathT3OrthoInverse( &tmpT3_0, &affineMat ); + vmathM4MakeFromT3( result, &tmpT3_0 ); +} + +static inline float vmathM4Determinant( const VmathMatrix4 *mat ) +{ + /* function implementation based on code from STIDC SDK: */ + /* -------------------------------------------------------------- */ + /* PLEASE DO NOT MODIFY THIS SECTION */ + /* This prolog section is automatically generated. */ + /* */ + /* (C)Copyright */ + /* Sony Computer Entertainment, Inc., */ + /* Toshiba Corporation, */ + /* International Business Machines Corporation, */ + /* 2001,2002. */ + /* S/T/I Confidential Information */ + /* -------------------------------------------------------------- */ + vector float in0, in1, in2, in3; + vector float tmp0, tmp1, tmp2, tmp3; + vector float cof0; + vector float t0, t1, t2, t3; + vector float t12, t23; + vector float t1r, t2r; + vector float t12r, t23r; + vector float t1r3, t1r3r; + vector float vzero = (vector float){0.0}; + union { vec_float4 v; float s[4]; } tmp; + in0 = mat->col0.vec128; + in1 = mat->col1.vec128; + in2 = mat->col2.vec128; + in3 = mat->col3.vec128; + /* Perform transform of the input matrix of the form: + * A B C D + * E F G H + * I J K L + * M N O P + * + * The pseudo transpose of the input matrix is trans: + * A E I M + * J N B F + * C G K O + * L P D H + */ + tmp0 = vec_perm(in0, in1, _VECTORMATH_PERM_XAZC); /* A E C G */ + tmp1 = vec_perm(in2, in3, _VECTORMATH_PERM_XAZC); /* I M K O */ + tmp2 = vec_perm(in0, in1, _VECTORMATH_PERM_YBWD); /* B F D H */ + tmp3 = vec_perm(in2, in3, _VECTORMATH_PERM_YBWD); /* J N L P */ + t0 = vec_perm(tmp0, tmp1, _VECTORMATH_PERM_XYAB); /* A E I M */ + t1 = vec_perm(tmp3, tmp2, _VECTORMATH_PERM_XYAB); /* J N B F */ + t2 = vec_perm(tmp0, tmp1, _VECTORMATH_PERM_ZWCD); /* C G K O */ + t3 = vec_perm(tmp3, tmp2, _VECTORMATH_PERM_ZWCD); /* L P D H */ + /* Generate a cofactor matrix. The computed cofactors reside in + * cof0, cof1, cof2, cof3. + */ + t23 = vec_madd(t2, t3, vzero); /* CL GP KD OH */ + t23 = vec_perm(t23, t23, _VECTORMATH_PERM_YXWZ); /* GP CL OH KD */ + cof0 = vec_nmsub(t1, t23, vzero); /* -(JGP NCL FOH BKD) */ + t23r = vec_sld(t23, t23, 8); /* OH KD GP CL */ + cof0 = vec_madd(t1, t23r, cof0); /* JOH NKD BGP FCL + cof0 */ + t12 = vec_madd(t1, t2, vzero); /* JC NG BK FO */ + t12 = vec_perm(t12, t12, _VECTORMATH_PERM_YXWZ); /* NG JC FO BK */ + cof0 = vec_madd(t3, t12, cof0); /* LNG PJC DFO HBK + cof0 */ + t12r = vec_sld(t12, t12, 8); /* FO BK NG JC */ + cof0 = vec_nmsub(t3, t12r, cof0); /* cof0 - LFO PBK DNG HJC */ + t1r = vec_sld(t1, t1, 8); /* B F J N */ + t2r = vec_sld(t2, t2, 8); /* K O C G */ + t1r3 = vec_madd(t1r, t3, vzero); /* BL FP JD NH */ + t1r3 = vec_perm(t1r3, t1r3, _VECTORMATH_PERM_YXWZ); /* FP BL NH JD */ + cof0 = vec_madd(t2r, t1r3, cof0); /* KFP OBL CNH GJD + cof0 */ + t1r3r = vec_sld(t1r3, t1r3, 8); /* NH JD FP BL */ + cof0 = vec_nmsub(t2r, t1r3r, cof0); /* cof0 - KNH OJD CFP GBL */ + tmp.v = _vmathVfDot4(t0,cof0); + return tmp.s[0]; +} + +static inline void vmathM4Add( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ) +{ + vmathV4Add( &result->col0, &mat0->col0, &mat1->col0 ); + vmathV4Add( &result->col1, &mat0->col1, &mat1->col1 ); + vmathV4Add( &result->col2, &mat0->col2, &mat1->col2 ); + vmathV4Add( &result->col3, &mat0->col3, &mat1->col3 ); +} + +static inline void vmathM4Sub( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ) +{ + vmathV4Sub( &result->col0, &mat0->col0, &mat1->col0 ); + vmathV4Sub( &result->col1, &mat0->col1, &mat1->col1 ); + vmathV4Sub( &result->col2, &mat0->col2, &mat1->col2 ); + vmathV4Sub( &result->col3, &mat0->col3, &mat1->col3 ); +} + +static inline void vmathM4Neg( VmathMatrix4 *result, const VmathMatrix4 *mat ) +{ + vmathV4Neg( &result->col0, &mat->col0 ); + vmathV4Neg( &result->col1, &mat->col1 ); + vmathV4Neg( &result->col2, &mat->col2 ); + vmathV4Neg( &result->col3, &mat->col3 ); +} + +static inline void vmathM4AbsPerElem( VmathMatrix4 *result, const VmathMatrix4 *mat ) +{ + vmathV4AbsPerElem( &result->col0, &mat->col0 ); + vmathV4AbsPerElem( &result->col1, &mat->col1 ); + vmathV4AbsPerElem( &result->col2, &mat->col2 ); + vmathV4AbsPerElem( &result->col3, &mat->col3 ); +} + +static inline void vmathM4ScalarMul( VmathMatrix4 *result, const VmathMatrix4 *mat, float scalar ) +{ + vmathV4ScalarMul( &result->col0, &mat->col0, scalar ); + vmathV4ScalarMul( &result->col1, &mat->col1, scalar ); + vmathV4ScalarMul( &result->col2, &mat->col2, scalar ); + vmathV4ScalarMul( &result->col3, &mat->col3, scalar ); +} + +static inline void vmathM4MulV4( VmathVector4 *result, const VmathMatrix4 *mat, const VmathVector4 *vec ) +{ + vec_float4 tmp0, tmp1, res; + vec_float4 xxxx, yyyy, zzzz, wwww; + vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + xxxx = vec_splat( vec->vec128, 0 ); + yyyy = vec_splat( vec->vec128, 1 ); + zzzz = vec_splat( vec->vec128, 2 ); + wwww = vec_splat( vec->vec128, 3 ); + tmp0 = vec_madd( mat->col0.vec128, xxxx, zero ); + tmp1 = vec_madd( mat->col1.vec128, yyyy, zero ); + tmp0 = vec_madd( mat->col2.vec128, zzzz, tmp0 ); + tmp1 = vec_madd( mat->col3.vec128, wwww, tmp1 ); + res = vec_add( tmp0, tmp1 ); + result->vec128 = res; +} + +static inline void vmathM4MulV3( VmathVector4 *result, const VmathMatrix4 *mat, const VmathVector3 *vec ) +{ + vec_float4 res; + vec_float4 xxxx, yyyy, zzzz; + xxxx = vec_splat( vec->vec128, 0 ); + yyyy = vec_splat( vec->vec128, 1 ); + zzzz = vec_splat( vec->vec128, 2 ); + res = vec_madd( mat->col0.vec128, xxxx, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + res = vec_madd( mat->col1.vec128, yyyy, res ); + res = vec_madd( mat->col2.vec128, zzzz, res ); + result->vec128 = res; +} + +static inline void vmathM4MulP3( VmathVector4 *result, const VmathMatrix4 *mat, const VmathPoint3 *pnt ) +{ + vec_float4 tmp0, tmp1, res; + vec_float4 xxxx, yyyy, zzzz; + vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + xxxx = vec_splat( pnt->vec128, 0 ); + yyyy = vec_splat( pnt->vec128, 1 ); + zzzz = vec_splat( pnt->vec128, 2 ); + tmp0 = vec_madd( mat->col0.vec128, xxxx, zero ); + tmp1 = vec_madd( mat->col1.vec128, yyyy, zero ); + tmp0 = vec_madd( mat->col2.vec128, zzzz, tmp0 ); + tmp1 = vec_add( mat->col3.vec128, tmp1 ); + res = vec_add( tmp0, tmp1 ); + result->vec128 = res; +} + +static inline void vmathM4Mul( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ) +{ + VmathMatrix4 tmpResult; + vmathM4MulV4( &tmpResult.col0, mat0, &mat1->col0 ); + vmathM4MulV4( &tmpResult.col1, mat0, &mat1->col1 ); + vmathM4MulV4( &tmpResult.col2, mat0, &mat1->col2 ); + vmathM4MulV4( &tmpResult.col3, mat0, &mat1->col3 ); + vmathM4Copy( result, &tmpResult ); +} + +static inline void vmathM4MulT3( VmathMatrix4 *result, const VmathMatrix4 *mat, const VmathTransform3 *tfrm1 ) +{ + VmathMatrix4 tmpResult; + VmathPoint3 tmpP3_0; + vmathM4MulV3( &tmpResult.col0, mat, &tfrm1->col0 ); + vmathM4MulV3( &tmpResult.col1, mat, &tfrm1->col1 ); + vmathM4MulV3( &tmpResult.col2, mat, &tfrm1->col2 ); + vmathP3MakeFromV3( &tmpP3_0, &tfrm1->col3 ); + vmathM4MulP3( &tmpResult.col3, mat, &tmpP3_0 ); + vmathM4Copy( result, &tmpResult ); +} + +static inline void vmathM4MulPerElem( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ) +{ + vmathV4MulPerElem( &result->col0, &mat0->col0, &mat1->col0 ); + vmathV4MulPerElem( &result->col1, &mat0->col1, &mat1->col1 ); + vmathV4MulPerElem( &result->col2, &mat0->col2, &mat1->col2 ); + vmathV4MulPerElem( &result->col3, &mat0->col3, &mat1->col3 ); +} + +static inline void vmathM4MakeIdentity( VmathMatrix4 *result ) +{ + vmathV4MakeXAxis( &result->col0 ); + vmathV4MakeYAxis( &result->col1 ); + vmathV4MakeZAxis( &result->col2 ); + vmathV4MakeWAxis( &result->col3 ); +} + +static inline void vmathM4SetUpper3x3( VmathMatrix4 *result, const VmathMatrix3 *mat3 ) +{ + vmathV4SetXYZ( &result->col0, &mat3->col0 ); + vmathV4SetXYZ( &result->col1, &mat3->col1 ); + vmathV4SetXYZ( &result->col2, &mat3->col2 ); +} + +static inline void vmathM4GetUpper3x3( VmathMatrix3 *result, const VmathMatrix4 *mat ) +{ + vmathV4GetXYZ( &result->col0, &mat->col0 ); + vmathV4GetXYZ( &result->col1, &mat->col1 ); + vmathV4GetXYZ( &result->col2, &mat->col2 ); +} + +static inline void vmathM4SetTranslation( VmathMatrix4 *result, const VmathVector3 *translateVec ) +{ + vmathV4SetXYZ( &result->col3, translateVec ); +} + +static inline void vmathM4GetTranslation( VmathVector3 *result, const VmathMatrix4 *mat ) +{ + vmathV4GetXYZ( result, &mat->col3 ); +} + +static inline void vmathM4MakeRotationX( VmathMatrix4 *result, float radians ) +{ + vec_float4 s, c, res1, res2; + vec_uint4 select_y, select_z; + vec_float4 zero; + select_y = _VECTORMATH_MASK_0x0F00; + select_z = _VECTORMATH_MASK_0x00F0; + zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + sincosf4( _vmathVfSplatScalar(radians), &s, &c ); + res1 = vec_sel( zero, c, select_y ); + res1 = vec_sel( res1, s, select_z ); + res2 = vec_sel( zero, negatef4(s), select_y ); + res2 = vec_sel( res2, c, select_z ); + vmathV4MakeXAxis( &result->col0 ); + result->col1.vec128 = res1; + result->col2.vec128 = res2; + vmathV4MakeWAxis( &result->col3 ); +} + +static inline void vmathM4MakeRotationY( VmathMatrix4 *result, float radians ) +{ + vec_float4 s, c, res0, res2; + vec_uint4 select_x, select_z; + vec_float4 zero; + select_x = _VECTORMATH_MASK_0xF000; + select_z = _VECTORMATH_MASK_0x00F0; + zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + sincosf4( _vmathVfSplatScalar(radians), &s, &c ); + res0 = vec_sel( zero, c, select_x ); + res0 = vec_sel( res0, negatef4(s), select_z ); + res2 = vec_sel( zero, s, select_x ); + res2 = vec_sel( res2, c, select_z ); + result->col0.vec128 = res0; + vmathV4MakeYAxis( &result->col1 ); + result->col2.vec128 = res2; + vmathV4MakeWAxis( &result->col3 ); +} + +static inline void vmathM4MakeRotationZ( VmathMatrix4 *result, float radians ) +{ + vec_float4 s, c, res0, res1; + vec_uint4 select_x, select_y; + vec_float4 zero; + select_x = _VECTORMATH_MASK_0xF000; + select_y = _VECTORMATH_MASK_0x0F00; + zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + sincosf4( _vmathVfSplatScalar(radians), &s, &c ); + res0 = vec_sel( zero, c, select_x ); + res0 = vec_sel( res0, s, select_y ); + res1 = vec_sel( zero, negatef4(s), select_x ); + res1 = vec_sel( res1, c, select_y ); + result->col0.vec128 = res0; + result->col1.vec128 = res1; + vmathV4MakeZAxis( &result->col2 ); + vmathV4MakeWAxis( &result->col3 ); +} + +static inline void vmathM4MakeRotationZYX( VmathMatrix4 *result, const VmathVector3 *radiansXYZ ) +{ + VmathVector4 tmpV4_0; + vec_float4 angles, s, negS, c, X0, X1, Y0, Y1, Z0, Z1, tmp; + vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + vmathV4MakeFromV3Scalar( &tmpV4_0, radiansXYZ, 0.0f ); + angles = tmpV4_0.vec128; + sincosf4( angles, &s, &c ); + negS = negatef4( s ); + Z0 = vec_mergel( c, s ); + Z1 = vec_mergel( negS, c ); + Z1 = vec_andc( Z1, (vec_float4)_VECTORMATH_MASK_0x000F ); + Y0 = vec_perm( negS, c, _VECTORMATH_PERM_BBYX ); + Y1 = vec_perm( c, s, _VECTORMATH_PERM_BBYX ); + X0 = vec_splat( s, 0 ); + X1 = vec_splat( c, 0 ); + tmp = vec_madd( Z0, Y1, zero ); + result->col0.vec128 = vec_madd( Z0, Y0, zero ); + result->col1.vec128 = vec_madd( Z1, X1, vec_madd( tmp, X0, zero ) ); + result->col2.vec128 = vec_nmsub( Z1, X0, vec_madd( tmp, X1, zero ) ); + vmathV4MakeWAxis( &result->col3 ); +} + +static inline void vmathM4MakeRotationAxis( VmathMatrix4 *result, float radians, const VmathVector3 *unitVec ) +{ + vec_float4 axis, s, c, oneMinusC, axisS, negAxisS, xxxx, yyyy, zzzz, tmp0, tmp1, tmp2, zeroW; + vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + axis = unitVec->vec128; + sincosf4( (vec_float4){radians,radians,radians,radians}, &s, &c ); + xxxx = vec_splat( axis, 0 ); + yyyy = vec_splat( axis, 1 ); + zzzz = vec_splat( axis, 2 ); + oneMinusC = vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), c ); + axisS = vec_madd( axis, s, zero ); + negAxisS = negatef4( axisS ); + tmp0 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_XZBX ); + tmp1 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_CXXX ); + tmp2 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_YAXX ); + tmp0 = vec_sel( tmp0, c, _VECTORMATH_MASK_0xF000 ); + tmp1 = vec_sel( tmp1, c, _VECTORMATH_MASK_0x0F00 ); + tmp2 = vec_sel( tmp2, c, _VECTORMATH_MASK_0x00F0 ); + zeroW = (vec_float4)_VECTORMATH_MASK_0x000F; + axis = vec_andc( axis, zeroW ); + tmp0 = vec_andc( tmp0, zeroW ); + tmp1 = vec_andc( tmp1, zeroW ); + tmp2 = vec_andc( tmp2, zeroW ); + result->col0.vec128 = vec_madd( vec_madd( axis, xxxx, zero ), oneMinusC, tmp0 ); + result->col1.vec128 = vec_madd( vec_madd( axis, yyyy, zero ), oneMinusC, tmp1 ); + result->col2.vec128 = vec_madd( vec_madd( axis, zzzz, zero ), oneMinusC, tmp2 ); + vmathV4MakeWAxis( &result->col3 ); +} + +static inline void vmathM4MakeRotationQ( VmathMatrix4 *result, const VmathQuat *unitQuat ) +{ + VmathTransform3 tmpT3_0; + vmathT3MakeRotationQ( &tmpT3_0, unitQuat ); + vmathM4MakeFromT3( result, &tmpT3_0 ); +} + +static inline void vmathM4MakeScale( VmathMatrix4 *result, const VmathVector3 *scaleVec ) +{ + vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + result->col0.vec128 = vec_sel( zero, scaleVec->vec128, _VECTORMATH_MASK_0xF000 ); + result->col1.vec128 = vec_sel( zero, scaleVec->vec128, _VECTORMATH_MASK_0x0F00 ); + result->col2.vec128 = vec_sel( zero, scaleVec->vec128, _VECTORMATH_MASK_0x00F0 ); + vmathV4MakeWAxis( &result->col3 ); +} + +static inline void vmathM4AppendScale( VmathMatrix4 *result, const VmathMatrix4 *mat, const VmathVector3 *scaleVec ) +{ + vmathV4ScalarMul( &result->col0, &mat->col0, vmathV3GetX( scaleVec ) ); + vmathV4ScalarMul( &result->col1, &mat->col1, vmathV3GetY( scaleVec ) ); + vmathV4ScalarMul( &result->col2, &mat->col2, vmathV3GetZ( scaleVec ) ); + vmathV4Copy( &result->col3, &mat->col3 ); +} + +static inline void vmathM4PrependScale( VmathMatrix4 *result, const VmathVector3 *scaleVec, const VmathMatrix4 *mat ) +{ + VmathVector4 scale4; + vmathV4MakeFromV3Scalar( &scale4, scaleVec, 1.0f ); + vmathV4MulPerElem( &result->col0, &mat->col0, &scale4 ); + vmathV4MulPerElem( &result->col1, &mat->col1, &scale4 ); + vmathV4MulPerElem( &result->col2, &mat->col2, &scale4 ); + vmathV4MulPerElem( &result->col3, &mat->col3, &scale4 ); +} + +static inline void vmathM4MakeTranslation( VmathMatrix4 *result, const VmathVector3 *translateVec ) +{ + vmathV4MakeXAxis( &result->col0 ); + vmathV4MakeYAxis( &result->col1 ); + vmathV4MakeZAxis( &result->col2 ); + vmathV4MakeFromV3Scalar( &result->col3, translateVec, 1.0f ); +} + +static inline void vmathM4MakeLookAt( VmathMatrix4 *result, const VmathPoint3 *eyePos, const VmathPoint3 *lookAtPos, const VmathVector3 *upVec ) +{ + VmathMatrix4 m4EyeFrame; + VmathVector3 v3X, v3Y, v3Z, tmpV3_0, tmpV3_1; + VmathVector4 tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3; + vmathV3Normalize( &v3Y, upVec ); + vmathP3Sub( &tmpV3_0, eyePos, lookAtPos ); + vmathV3Normalize( &v3Z, &tmpV3_0 ); + vmathV3Cross( &tmpV3_1, &v3Y, &v3Z ); + vmathV3Normalize( &v3X, &tmpV3_1 ); + vmathV3Cross( &v3Y, &v3Z, &v3X ); + vmathV4MakeFromV3( &tmpV4_0, &v3X ); + vmathV4MakeFromV3( &tmpV4_1, &v3Y ); + vmathV4MakeFromV3( &tmpV4_2, &v3Z ); + vmathV4MakeFromP3( &tmpV4_3, eyePos ); + vmathM4MakeFromCols( &m4EyeFrame, &tmpV4_0, &tmpV4_1, &tmpV4_2, &tmpV4_3 ); + vmathM4OrthoInverse( result, &m4EyeFrame ); +} + +static inline void vmathM4MakePerspective( VmathMatrix4 *result, float fovyRadians, float aspect, float zNear, float zFar ) +{ + float f, rangeInv; + vec_float4 zero, col0, col1, col2, col3; + union { vec_float4 v; float s[4]; } tmp; + f = tanf( _VECTORMATH_PI_OVER_2 - fovyRadians * 0.5f ); + rangeInv = 1.0f / ( zNear - zFar ); + zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + tmp.v = zero; + tmp.s[0] = f / aspect; + col0 = tmp.v; + tmp.v = zero; + tmp.s[1] = f; + col1 = tmp.v; + tmp.v = zero; + tmp.s[2] = ( zNear + zFar ) * rangeInv; + tmp.s[3] = -1.0f; + col2 = tmp.v; + tmp.v = zero; + tmp.s[2] = zNear * zFar * rangeInv * 2.0f; + col3 = tmp.v; + result->col0.vec128 = col0; + result->col1.vec128 = col1; + result->col2.vec128 = col2; + result->col3.vec128 = col3; +} + +static inline void vmathM4MakeFrustum( VmathMatrix4 *result, float left, float right, float bottom, float top, float zNear, float zFar ) +{ + /* function implementation based on code from STIDC SDK: */ + /* -------------------------------------------------------------- */ + /* PLEASE DO NOT MODIFY THIS SECTION */ + /* This prolog section is automatically generated. */ + /* */ + /* (C)Copyright */ + /* Sony Computer Entertainment, Inc., */ + /* Toshiba Corporation, */ + /* International Business Machines Corporation, */ + /* 2001,2002. */ + /* S/T/I Confidential Information */ + /* -------------------------------------------------------------- */ + vec_float4 lbf, rtn; + vec_float4 diff, sum, inv_diff; + vec_float4 diagonal, column, near2; + vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + union { vec_float4 v; float s[4]; } l, f, r, n, b, t; + l.s[0] = left; + f.s[0] = zFar; + r.s[0] = right; + n.s[0] = zNear; + b.s[0] = bottom; + t.s[0] = top; + lbf = vec_mergeh( l.v, f.v ); + rtn = vec_mergeh( r.v, n.v ); + lbf = vec_mergeh( lbf, b.v ); + rtn = vec_mergeh( rtn, t.v ); + diff = vec_sub( rtn, lbf ); + sum = vec_add( rtn, lbf ); + inv_diff = recipf4( diff ); + near2 = vec_splat( n.v, 0 ); + near2 = vec_add( near2, near2 ); + diagonal = vec_madd( near2, inv_diff, zero ); + column = vec_madd( sum, inv_diff, zero ); + result->col0.vec128 = vec_sel( zero, diagonal, _VECTORMATH_MASK_0xF000 ); + result->col1.vec128 = vec_sel( zero, diagonal, _VECTORMATH_MASK_0x0F00 ); + result->col2.vec128 = vec_sel( column, ((vec_float4){-1.0f,-1.0f,-1.0f,-1.0f}), _VECTORMATH_MASK_0x000F ); + result->col3.vec128 = vec_sel( zero, vec_madd( diagonal, vec_splat( f.v, 0 ), zero ), _VECTORMATH_MASK_0x00F0 ); +} + +static inline void vmathM4MakeOrthographic( VmathMatrix4 *result, float left, float right, float bottom, float top, float zNear, float zFar ) +{ + /* function implementation based on code from STIDC SDK: */ + /* -------------------------------------------------------------- */ + /* PLEASE DO NOT MODIFY THIS SECTION */ + /* This prolog section is automatically generated. */ + /* */ + /* (C)Copyright */ + /* Sony Computer Entertainment, Inc., */ + /* Toshiba Corporation, */ + /* International Business Machines Corporation, */ + /* 2001,2002. */ + /* S/T/I Confidential Information */ + /* -------------------------------------------------------------- */ + vec_float4 lbf, rtn; + vec_float4 diff, sum, inv_diff, neg_inv_diff; + vec_float4 diagonal, column; + vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + union { vec_float4 v; float s[4]; } l, f, r, n, b, t; + l.s[0] = left; + f.s[0] = zFar; + r.s[0] = right; + n.s[0] = zNear; + b.s[0] = bottom; + t.s[0] = top; + lbf = vec_mergeh( l.v, f.v ); + rtn = vec_mergeh( r.v, n.v ); + lbf = vec_mergeh( lbf, b.v ); + rtn = vec_mergeh( rtn, t.v ); + diff = vec_sub( rtn, lbf ); + sum = vec_add( rtn, lbf ); + inv_diff = recipf4( diff ); + neg_inv_diff = negatef4( inv_diff ); + diagonal = vec_add( inv_diff, inv_diff ); + column = vec_madd( sum, vec_sel( neg_inv_diff, inv_diff, _VECTORMATH_MASK_0x00F0 ), zero ); + result->col0.vec128 = vec_sel( zero, diagonal, _VECTORMATH_MASK_0xF000 ); + result->col1.vec128 = vec_sel( zero, diagonal, _VECTORMATH_MASK_0x0F00 ); + result->col2.vec128 = vec_sel( zero, diagonal, _VECTORMATH_MASK_0x00F0 ); + result->col3.vec128 = vec_sel( column, ((vec_float4){1.0f,1.0f,1.0f,1.0f}), _VECTORMATH_MASK_0x000F ); +} + +static inline void vmathM4Select( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1, unsigned int select1 ) +{ + vmathV4Select( &result->col0, &mat0->col0, &mat1->col0, select1 ); + vmathV4Select( &result->col1, &mat0->col1, &mat1->col1, select1 ); + vmathV4Select( &result->col2, &mat0->col2, &mat1->col2, select1 ); + vmathV4Select( &result->col3, &mat0->col3, &mat1->col3, select1 ); +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathM4Print( const VmathMatrix4 *mat ) +{ + VmathVector4 tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3; + vmathM4GetRow( &tmpV4_0, mat, 0 ); + vmathV4Print( &tmpV4_0 ); + vmathM4GetRow( &tmpV4_1, mat, 1 ); + vmathV4Print( &tmpV4_1 ); + vmathM4GetRow( &tmpV4_2, mat, 2 ); + vmathV4Print( &tmpV4_2 ); + vmathM4GetRow( &tmpV4_3, mat, 3 ); + vmathV4Print( &tmpV4_3 ); +} + +static inline void vmathM4Prints( const VmathMatrix4 *mat, const char *name ) +{ + printf("%s:\n", name); + vmathM4Print( mat ); +} + +#endif + +static inline void vmathT3Copy( VmathTransform3 *result, const VmathTransform3 *tfrm ) +{ + vmathV3Copy( &result->col0, &tfrm->col0 ); + vmathV3Copy( &result->col1, &tfrm->col1 ); + vmathV3Copy( &result->col2, &tfrm->col2 ); + vmathV3Copy( &result->col3, &tfrm->col3 ); +} + +static inline void vmathT3MakeFromScalar( VmathTransform3 *result, float scalar ) +{ + vmathV3MakeFromScalar( &result->col0, scalar ); + vmathV3MakeFromScalar( &result->col1, scalar ); + vmathV3MakeFromScalar( &result->col2, scalar ); + vmathV3MakeFromScalar( &result->col3, scalar ); +} + +static inline void vmathT3MakeFromCols( VmathTransform3 *result, const VmathVector3 *_col0, const VmathVector3 *_col1, const VmathVector3 *_col2, const VmathVector3 *_col3 ) +{ + vmathV3Copy( &result->col0, _col0 ); + vmathV3Copy( &result->col1, _col1 ); + vmathV3Copy( &result->col2, _col2 ); + vmathV3Copy( &result->col3, _col3 ); +} + +static inline void vmathT3MakeFromM3V3( VmathTransform3 *result, const VmathMatrix3 *tfrm, const VmathVector3 *translateVec ) +{ + vmathT3SetUpper3x3( result, tfrm ); + vmathT3SetTranslation( result, translateVec ); +} + +static inline void vmathT3MakeFromQV3( VmathTransform3 *result, const VmathQuat *unitQuat, const VmathVector3 *translateVec ) +{ + VmathMatrix3 tmpM3_0; + vmathM3MakeFromQ( &tmpM3_0, unitQuat ); + vmathT3SetUpper3x3( result, &tmpM3_0 ); + vmathT3SetTranslation( result, translateVec ); +} + +static inline void vmathT3SetCol0( VmathTransform3 *result, const VmathVector3 *_col0 ) +{ + vmathV3Copy( &result->col0, _col0 ); +} + +static inline void vmathT3SetCol1( VmathTransform3 *result, const VmathVector3 *_col1 ) +{ + vmathV3Copy( &result->col1, _col1 ); +} + +static inline void vmathT3SetCol2( VmathTransform3 *result, const VmathVector3 *_col2 ) +{ + vmathV3Copy( &result->col2, _col2 ); +} + +static inline void vmathT3SetCol3( VmathTransform3 *result, const VmathVector3 *_col3 ) +{ + vmathV3Copy( &result->col3, _col3 ); +} + +static inline void vmathT3SetCol( VmathTransform3 *result, int col, const VmathVector3 *vec ) +{ + vmathV3Copy( (&result->col0 + col), vec ); +} + +static inline void vmathT3SetRow( VmathTransform3 *result, int row, const VmathVector4 *vec ) +{ + vmathV3SetElem( &result->col0, row, vmathV4GetElem( vec, 0 ) ); + vmathV3SetElem( &result->col1, row, vmathV4GetElem( vec, 1 ) ); + vmathV3SetElem( &result->col2, row, vmathV4GetElem( vec, 2 ) ); + vmathV3SetElem( &result->col3, row, vmathV4GetElem( vec, 3 ) ); +} + +static inline void vmathT3SetElem( VmathTransform3 *result, int col, int row, float val ) +{ + VmathVector3 tmpV3_0; + vmathT3GetCol( &tmpV3_0, result, col ); + vmathV3SetElem( &tmpV3_0, row, val ); + vmathT3SetCol( result, col, &tmpV3_0 ); +} + +static inline float vmathT3GetElem( const VmathTransform3 *tfrm, int col, int row ) +{ + VmathVector3 tmpV3_0; + vmathT3GetCol( &tmpV3_0, tfrm, col ); + return vmathV3GetElem( &tmpV3_0, row ); +} + +static inline void vmathT3GetCol0( VmathVector3 *result, const VmathTransform3 *tfrm ) +{ + vmathV3Copy( result, &tfrm->col0 ); +} + +static inline void vmathT3GetCol1( VmathVector3 *result, const VmathTransform3 *tfrm ) +{ + vmathV3Copy( result, &tfrm->col1 ); +} + +static inline void vmathT3GetCol2( VmathVector3 *result, const VmathTransform3 *tfrm ) +{ + vmathV3Copy( result, &tfrm->col2 ); +} + +static inline void vmathT3GetCol3( VmathVector3 *result, const VmathTransform3 *tfrm ) +{ + vmathV3Copy( result, &tfrm->col3 ); +} + +static inline void vmathT3GetCol( VmathVector3 *result, const VmathTransform3 *tfrm, int col ) +{ + vmathV3Copy( result, (&tfrm->col0 + col) ); +} + +static inline void vmathT3GetRow( VmathVector4 *result, const VmathTransform3 *tfrm, int row ) +{ + vmathV4MakeFromElems( result, vmathV3GetElem( &tfrm->col0, row ), vmathV3GetElem( &tfrm->col1, row ), vmathV3GetElem( &tfrm->col2, row ), vmathV3GetElem( &tfrm->col3, row ) ); +} + +static inline void vmathT3Inverse( VmathTransform3 *result, const VmathTransform3 *tfrm ) +{ + vec_float4 inv0, inv1, inv2, inv3; + vec_float4 tmp0, tmp1, tmp2, tmp3, tmp4, dot, invdet; + vec_float4 xxxx, yyyy, zzzz; + vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + tmp2 = _vmathVfCross( tfrm->col0.vec128, tfrm->col1.vec128 ); + tmp0 = _vmathVfCross( tfrm->col1.vec128, tfrm->col2.vec128 ); + tmp1 = _vmathVfCross( tfrm->col2.vec128, tfrm->col0.vec128 ); + inv3 = negatef4( tfrm->col3.vec128 ); + dot = _vmathVfDot3( tmp2, tfrm->col2.vec128 ); + dot = vec_splat( dot, 0 ); + invdet = recipf4( dot ); + tmp3 = vec_mergeh( tmp0, tmp2 ); + tmp4 = vec_mergel( tmp0, tmp2 ); + inv0 = vec_mergeh( tmp3, tmp1 ); + xxxx = vec_splat( inv3, 0 ); + inv1 = vec_perm( tmp3, tmp1, _VECTORMATH_PERM_ZBWX ); + inv2 = vec_perm( tmp4, tmp1, _VECTORMATH_PERM_XCYX ); + yyyy = vec_splat( inv3, 1 ); + zzzz = vec_splat( inv3, 2 ); + inv3 = vec_madd( inv0, xxxx, zero ); + inv3 = vec_madd( inv1, yyyy, inv3 ); + inv3 = vec_madd( inv2, zzzz, inv3 ); + inv0 = vec_madd( inv0, invdet, zero ); + inv1 = vec_madd( inv1, invdet, zero ); + inv2 = vec_madd( inv2, invdet, zero ); + inv3 = vec_madd( inv3, invdet, zero ); + result->col0.vec128 = inv0; + result->col1.vec128 = inv1; + result->col2.vec128 = inv2; + result->col3.vec128 = inv3; +} + +static inline void vmathT3OrthoInverse( VmathTransform3 *result, const VmathTransform3 *tfrm ) +{ + vec_float4 inv0, inv1, inv2, inv3; + vec_float4 tmp0, tmp1; + vec_float4 xxxx, yyyy, zzzz; + tmp0 = vec_mergeh( tfrm->col0.vec128, tfrm->col2.vec128 ); + tmp1 = vec_mergel( tfrm->col0.vec128, tfrm->col2.vec128 ); + inv3 = negatef4( tfrm->col3.vec128 ); + inv0 = vec_mergeh( tmp0, tfrm->col1.vec128 ); + xxxx = vec_splat( inv3, 0 ); + inv1 = vec_perm( tmp0, tfrm->col1.vec128, _VECTORMATH_PERM_ZBWX ); + inv2 = vec_perm( tmp1, tfrm->col1.vec128, _VECTORMATH_PERM_XCYX ); + yyyy = vec_splat( inv3, 1 ); + zzzz = vec_splat( inv3, 2 ); + inv3 = vec_madd( inv0, xxxx, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + inv3 = vec_madd( inv1, yyyy, inv3 ); + inv3 = vec_madd( inv2, zzzz, inv3 ); + result->col0.vec128 = inv0; + result->col1.vec128 = inv1; + result->col2.vec128 = inv2; + result->col3.vec128 = inv3; +} + +static inline void vmathT3AbsPerElem( VmathTransform3 *result, const VmathTransform3 *tfrm ) +{ + vmathV3AbsPerElem( &result->col0, &tfrm->col0 ); + vmathV3AbsPerElem( &result->col1, &tfrm->col1 ); + vmathV3AbsPerElem( &result->col2, &tfrm->col2 ); + vmathV3AbsPerElem( &result->col3, &tfrm->col3 ); +} + +static inline void vmathT3MulV3( VmathVector3 *result, const VmathTransform3 *tfrm, const VmathVector3 *vec ) +{ + vec_float4 res; + vec_float4 xxxx, yyyy, zzzz; + xxxx = vec_splat( vec->vec128, 0 ); + yyyy = vec_splat( vec->vec128, 1 ); + zzzz = vec_splat( vec->vec128, 2 ); + res = vec_madd( tfrm->col0.vec128, xxxx, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + res = vec_madd( tfrm->col1.vec128, yyyy, res ); + res = vec_madd( tfrm->col2.vec128, zzzz, res ); + result->vec128 = res; +} + +static inline void vmathT3MulP3( VmathPoint3 *result, const VmathTransform3 *tfrm, const VmathPoint3 *pnt ) +{ + vec_float4 tmp0, tmp1, res; + vec_float4 xxxx, yyyy, zzzz; + vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + xxxx = vec_splat( pnt->vec128, 0 ); + yyyy = vec_splat( pnt->vec128, 1 ); + zzzz = vec_splat( pnt->vec128, 2 ); + tmp0 = vec_madd( tfrm->col0.vec128, xxxx, zero ); + tmp1 = vec_madd( tfrm->col1.vec128, yyyy, zero ); + tmp0 = vec_madd( tfrm->col2.vec128, zzzz, tmp0 ); + tmp1 = vec_add( tfrm->col3.vec128, tmp1 ); + res = vec_add( tmp0, tmp1 ); + result->vec128 = res; +} + +static inline void vmathT3Mul( VmathTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1 ) +{ + VmathTransform3 tmpResult; + VmathPoint3 tmpP3_0, tmpP3_1; + vmathT3MulV3( &tmpResult.col0, tfrm0, &tfrm1->col0 ); + vmathT3MulV3( &tmpResult.col1, tfrm0, &tfrm1->col1 ); + vmathT3MulV3( &tmpResult.col2, tfrm0, &tfrm1->col2 ); + vmathP3MakeFromV3( &tmpP3_0, &tfrm1->col3 ); + vmathT3MulP3( &tmpP3_1, tfrm0, &tmpP3_0 ); + vmathV3MakeFromP3( &tmpResult.col3, &tmpP3_1 ); + vmathT3Copy( result, &tmpResult ); +} + +static inline void vmathT3MulPerElem( VmathTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1 ) +{ + vmathV3MulPerElem( &result->col0, &tfrm0->col0, &tfrm1->col0 ); + vmathV3MulPerElem( &result->col1, &tfrm0->col1, &tfrm1->col1 ); + vmathV3MulPerElem( &result->col2, &tfrm0->col2, &tfrm1->col2 ); + vmathV3MulPerElem( &result->col3, &tfrm0->col3, &tfrm1->col3 ); +} + +static inline void vmathT3MakeIdentity( VmathTransform3 *result ) +{ + vmathV3MakeXAxis( &result->col0 ); + vmathV3MakeYAxis( &result->col1 ); + vmathV3MakeZAxis( &result->col2 ); + vmathV3MakeFromScalar( &result->col3, 0.0f ); +} + +static inline void vmathT3SetUpper3x3( VmathTransform3 *result, const VmathMatrix3 *tfrm ) +{ + vmathV3Copy( &result->col0, &tfrm->col0 ); + vmathV3Copy( &result->col1, &tfrm->col1 ); + vmathV3Copy( &result->col2, &tfrm->col2 ); +} + +static inline void vmathT3GetUpper3x3( VmathMatrix3 *result, const VmathTransform3 *tfrm ) +{ + vmathM3MakeFromCols( result, &tfrm->col0, &tfrm->col1, &tfrm->col2 ); +} + +static inline void vmathT3SetTranslation( VmathTransform3 *result, const VmathVector3 *translateVec ) +{ + vmathV3Copy( &result->col3, translateVec ); +} + +static inline void vmathT3GetTranslation( VmathVector3 *result, const VmathTransform3 *tfrm ) +{ + vmathV3Copy( result, &tfrm->col3 ); +} + +static inline void vmathT3MakeRotationX( VmathTransform3 *result, float radians ) +{ + vec_float4 s, c, res1, res2; + vec_uint4 select_y, select_z; + vec_float4 zero; + select_y = _VECTORMATH_MASK_0x0F00; + select_z = _VECTORMATH_MASK_0x00F0; + zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + sincosf4( _vmathVfSplatScalar(radians), &s, &c ); + res1 = vec_sel( zero, c, select_y ); + res1 = vec_sel( res1, s, select_z ); + res2 = vec_sel( zero, negatef4(s), select_y ); + res2 = vec_sel( res2, c, select_z ); + vmathV3MakeXAxis( &result->col0 ); + result->col1.vec128 = res1; + result->col2.vec128 = res2; + vmathV3MakeFromScalar( &result->col3, 0.0f ); +} + +static inline void vmathT3MakeRotationY( VmathTransform3 *result, float radians ) +{ + vec_float4 s, c, res0, res2; + vec_uint4 select_x, select_z; + vec_float4 zero; + select_x = _VECTORMATH_MASK_0xF000; + select_z = _VECTORMATH_MASK_0x00F0; + zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + sincosf4( _vmathVfSplatScalar(radians), &s, &c ); + res0 = vec_sel( zero, c, select_x ); + res0 = vec_sel( res0, negatef4(s), select_z ); + res2 = vec_sel( zero, s, select_x ); + res2 = vec_sel( res2, c, select_z ); + result->col0.vec128 = res0; + vmathV3MakeYAxis( &result->col1 ); + result->col2.vec128 = res2; + vmathV3MakeFromScalar( &result->col3, 0.0f ); +} + +static inline void vmathT3MakeRotationZ( VmathTransform3 *result, float radians ) +{ + vec_float4 s, c, res0, res1; + vec_uint4 select_x, select_y; + vec_float4 zero; + select_x = _VECTORMATH_MASK_0xF000; + select_y = _VECTORMATH_MASK_0x0F00; + zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + sincosf4( _vmathVfSplatScalar(radians), &s, &c ); + res0 = vec_sel( zero, c, select_x ); + res0 = vec_sel( res0, s, select_y ); + res1 = vec_sel( zero, negatef4(s), select_x ); + res1 = vec_sel( res1, c, select_y ); + result->col0.vec128 = res0; + result->col1.vec128 = res1; + vmathV3MakeZAxis( &result->col2 ); + vmathV3MakeFromScalar( &result->col3, 0.0f ); +} + +static inline void vmathT3MakeRotationZYX( VmathTransform3 *result, const VmathVector3 *radiansXYZ ) +{ + VmathVector4 tmpV4_0; + vec_float4 angles, s, negS, c, X0, X1, Y0, Y1, Z0, Z1, tmp; + vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + vmathV4MakeFromV3Scalar( &tmpV4_0, radiansXYZ, 0.0f ); + angles = tmpV4_0.vec128; + sincosf4( angles, &s, &c ); + negS = negatef4( s ); + Z0 = vec_mergel( c, s ); + Z1 = vec_mergel( negS, c ); + Z1 = vec_andc( Z1, (vec_float4)_VECTORMATH_MASK_0x000F ); + Y0 = vec_perm( negS, c, _VECTORMATH_PERM_BBYX ); + Y1 = vec_perm( c, s, _VECTORMATH_PERM_BBYX ); + X0 = vec_splat( s, 0 ); + X1 = vec_splat( c, 0 ); + tmp = vec_madd( Z0, Y1, zero ); + result->col0.vec128 = vec_madd( Z0, Y0, zero ); + result->col1.vec128 = vec_madd( Z1, X1, vec_madd( tmp, X0, zero ) ); + result->col2.vec128 = vec_nmsub( Z1, X0, vec_madd( tmp, X1, zero ) ); + vmathV3MakeFromScalar( &result->col3, 0.0f ); +} + +static inline void vmathT3MakeRotationAxis( VmathTransform3 *result, float radians, const VmathVector3 *unitVec ) +{ + VmathMatrix3 tmpM3_0; + VmathVector3 tmpV3_0; + vmathM3MakeRotationAxis( &tmpM3_0, radians, unitVec ); + vmathV3MakeFromScalar( &tmpV3_0, 0.0f ); + vmathT3MakeFromM3V3( result, &tmpM3_0, &tmpV3_0 ); +} + +static inline void vmathT3MakeRotationQ( VmathTransform3 *result, const VmathQuat *unitQuat ) +{ + VmathMatrix3 tmpM3_0; + VmathVector3 tmpV3_0; + vmathM3MakeFromQ( &tmpM3_0, unitQuat ); + vmathV3MakeFromScalar( &tmpV3_0, 0.0f ); + vmathT3MakeFromM3V3( result, &tmpM3_0, &tmpV3_0 ); +} + +static inline void vmathT3MakeScale( VmathTransform3 *result, const VmathVector3 *scaleVec ) +{ + vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + result->col0.vec128 = vec_sel( zero, scaleVec->vec128, _VECTORMATH_MASK_0xF000 ); + result->col1.vec128 = vec_sel( zero, scaleVec->vec128, _VECTORMATH_MASK_0x0F00 ); + result->col2.vec128 = vec_sel( zero, scaleVec->vec128, _VECTORMATH_MASK_0x00F0 ); + vmathV3MakeFromScalar( &result->col3, 0.0f ); +} + +static inline void vmathT3AppendScale( VmathTransform3 *result, const VmathTransform3 *tfrm, const VmathVector3 *scaleVec ) +{ + vmathV3ScalarMul( &result->col0, &tfrm->col0, vmathV3GetX( scaleVec ) ); + vmathV3ScalarMul( &result->col1, &tfrm->col1, vmathV3GetY( scaleVec ) ); + vmathV3ScalarMul( &result->col2, &tfrm->col2, vmathV3GetZ( scaleVec ) ); + vmathV3Copy( &result->col3, &tfrm->col3 ); +} + +static inline void vmathT3PrependScale( VmathTransform3 *result, const VmathVector3 *scaleVec, const VmathTransform3 *tfrm ) +{ + vmathV3MulPerElem( &result->col0, &tfrm->col0, scaleVec ); + vmathV3MulPerElem( &result->col1, &tfrm->col1, scaleVec ); + vmathV3MulPerElem( &result->col2, &tfrm->col2, scaleVec ); + vmathV3MulPerElem( &result->col3, &tfrm->col3, scaleVec ); +} + +static inline void vmathT3MakeTranslation( VmathTransform3 *result, const VmathVector3 *translateVec ) +{ + vmathV3MakeXAxis( &result->col0 ); + vmathV3MakeYAxis( &result->col1 ); + vmathV3MakeZAxis( &result->col2 ); + vmathV3Copy( &result->col3, translateVec ); +} + +static inline void vmathT3Select( VmathTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1, unsigned int select1 ) +{ + vmathV3Select( &result->col0, &tfrm0->col0, &tfrm1->col0, select1 ); + vmathV3Select( &result->col1, &tfrm0->col1, &tfrm1->col1, select1 ); + vmathV3Select( &result->col2, &tfrm0->col2, &tfrm1->col2, select1 ); + vmathV3Select( &result->col3, &tfrm0->col3, &tfrm1->col3, select1 ); +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathT3Print( const VmathTransform3 *tfrm ) +{ + VmathVector4 tmpV4_0, tmpV4_1, tmpV4_2; + vmathT3GetRow( &tmpV4_0, tfrm, 0 ); + vmathV4Print( &tmpV4_0 ); + vmathT3GetRow( &tmpV4_1, tfrm, 1 ); + vmathV4Print( &tmpV4_1 ); + vmathT3GetRow( &tmpV4_2, tfrm, 2 ); + vmathV4Print( &tmpV4_2 ); +} + +static inline void vmathT3Prints( const VmathTransform3 *tfrm, const char *name ) +{ + printf("%s:\n", name); + vmathT3Print( tfrm ); +} + +#endif + +static inline void vmathQMakeFromM3( VmathQuat *result, const VmathMatrix3 *tfrm ) +{ + vec_float4 res; + vec_float4 col0, col1, col2; + vec_float4 xx_yy, xx_yy_zz_xx, yy_zz_xx_yy, zz_xx_yy_zz, diagSum, diagDiff; + vec_float4 zy_xz_yx, yz_zx_xy, sum, diff; + vec_float4 radicand, invSqrt, scale; + vec_float4 res0, res1, res2, res3; + vec_float4 xx, yy, zz; + vec_uint4 select_x = _VECTORMATH_MASK_0xF000; + vec_uint4 select_y = _VECTORMATH_MASK_0x0F00; + vec_uint4 select_z = _VECTORMATH_MASK_0x00F0; + vec_uint4 select_w = _VECTORMATH_MASK_0x000F; + vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + + col0 = tfrm->col0.vec128; + col1 = tfrm->col1.vec128; + col2 = tfrm->col2.vec128; + + /* four cases: */ + /* trace > 0 */ + /* else */ + /* xx largest diagonal element */ + /* yy largest diagonal element */ + /* zz largest diagonal element */ + + /* compute quaternion for each case */ + + xx_yy = vec_sel( col0, col1, select_y ); + xx_yy_zz_xx = vec_perm( xx_yy, col2, _VECTORMATH_PERM_XYCX ); + yy_zz_xx_yy = vec_perm( xx_yy, col2, _VECTORMATH_PERM_YCXY ); + zz_xx_yy_zz = vec_perm( xx_yy, col2, _VECTORMATH_PERM_CXYC ); + + diagSum = vec_add( vec_add( xx_yy_zz_xx, yy_zz_xx_yy ), zz_xx_yy_zz ); + diagDiff = vec_sub( vec_sub( xx_yy_zz_xx, yy_zz_xx_yy ), zz_xx_yy_zz ); + radicand = vec_add( vec_sel( diagDiff, diagSum, select_w ), ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); + invSqrt = rsqrtf4( radicand ); + + zy_xz_yx = vec_sel( col0, col1, select_z ); + zy_xz_yx = vec_perm( zy_xz_yx, col2, _VECTORMATH_PERM_ZAYX ); + yz_zx_xy = vec_sel( col0, col1, select_x ); + yz_zx_xy = vec_perm( yz_zx_xy, col2, _VECTORMATH_PERM_BZXX ); + + sum = vec_add( zy_xz_yx, yz_zx_xy ); + diff = vec_sub( zy_xz_yx, yz_zx_xy ); + + scale = vec_madd( invSqrt, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), zero ); + res0 = vec_perm( sum, diff, _VECTORMATH_PERM_XZYA ); + res1 = vec_perm( sum, diff, _VECTORMATH_PERM_ZXXB ); + res2 = vec_perm( sum, diff, _VECTORMATH_PERM_YXXC ); + res3 = diff; + res0 = vec_sel( res0, radicand, select_x ); + res1 = vec_sel( res1, radicand, select_y ); + res2 = vec_sel( res2, radicand, select_z ); + res3 = vec_sel( res3, radicand, select_w ); + res0 = vec_madd( res0, vec_splat( scale, 0 ), zero ); + res1 = vec_madd( res1, vec_splat( scale, 1 ), zero ); + res2 = vec_madd( res2, vec_splat( scale, 2 ), zero ); + res3 = vec_madd( res3, vec_splat( scale, 3 ), zero ); + + /* determine case and select answer */ + + xx = vec_splat( col0, 0 ); + yy = vec_splat( col1, 1 ); + zz = vec_splat( col2, 2 ); + res = vec_sel( res0, res1, vec_cmpgt( yy, xx ) ); + res = vec_sel( res, res2, vec_and( vec_cmpgt( zz, xx ), vec_cmpgt( zz, yy ) ) ); + res = vec_sel( res, res3, vec_cmpgt( vec_splat( diagSum, 0 ), zero ) ); + result->vec128 = res; +} + +static inline void vmathV3Outer( VmathMatrix3 *result, const VmathVector3 *tfrm0, const VmathVector3 *tfrm1 ) +{ + vmathV3ScalarMul( &result->col0, tfrm0, vmathV3GetX( tfrm1 ) ); + vmathV3ScalarMul( &result->col1, tfrm0, vmathV3GetY( tfrm1 ) ); + vmathV3ScalarMul( &result->col2, tfrm0, vmathV3GetZ( tfrm1 ) ); +} + +static inline void vmathV4Outer( VmathMatrix4 *result, const VmathVector4 *tfrm0, const VmathVector4 *tfrm1 ) +{ + vmathV4ScalarMul( &result->col0, tfrm0, vmathV4GetX( tfrm1 ) ); + vmathV4ScalarMul( &result->col1, tfrm0, vmathV4GetY( tfrm1 ) ); + vmathV4ScalarMul( &result->col2, tfrm0, vmathV4GetZ( tfrm1 ) ); + vmathV4ScalarMul( &result->col3, tfrm0, vmathV4GetW( tfrm1 ) ); +} + +static inline void vmathV3RowMul( VmathVector3 *result, const VmathVector3 *vec, const VmathMatrix3 *mat ) +{ + vec_float4 tmp0, tmp1, mcol0, mcol1, mcol2, res; + vec_float4 xxxx, yyyy, zzzz; + tmp0 = vec_mergeh( mat->col0.vec128, mat->col2.vec128 ); + tmp1 = vec_mergel( mat->col0.vec128, mat->col2.vec128 ); + xxxx = vec_splat( vec->vec128, 0 ); + mcol0 = vec_mergeh( tmp0, mat->col1.vec128 ); + mcol1 = vec_perm( tmp0, mat->col1.vec128, _VECTORMATH_PERM_ZBWX ); + mcol2 = vec_perm( tmp1, mat->col1.vec128, _VECTORMATH_PERM_XCYX ); + yyyy = vec_splat( vec->vec128, 1 ); + res = vec_madd( mcol0, xxxx, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + zzzz = vec_splat( vec->vec128, 2 ); + res = vec_madd( mcol1, yyyy, res ); + res = vec_madd( mcol2, zzzz, res ); + result->vec128 = res; +} + +static inline void vmathV3CrossMatrix( VmathMatrix3 *result, const VmathVector3 *vec ) +{ + vec_float4 neg, res0, res1, res2; + neg = negatef4( vec->vec128 ); + res0 = vec_perm( vec->vec128, neg, _VECTORMATH_PERM_XZBX ); + res1 = vec_perm( vec->vec128, neg, _VECTORMATH_PERM_CXXX ); + res2 = vec_perm( vec->vec128, neg, _VECTORMATH_PERM_YAXX ); + res0 = vec_andc( res0, (vec_float4)_VECTORMATH_MASK_0xF000 ); + res1 = vec_andc( res1, (vec_float4)_VECTORMATH_MASK_0x0F00 ); + res2 = vec_andc( res2, (vec_float4)_VECTORMATH_MASK_0x00F0 ); + result->col0.vec128 = res0; + result->col1.vec128 = res1; + result->col2.vec128 = res2; +} + +static inline void vmathV3CrossMatrixMul( VmathMatrix3 *result, const VmathVector3 *vec, const VmathMatrix3 *mat ) +{ + VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2; + vmathV3Cross( &tmpV3_0, vec, &mat->col0 ); + vmathV3Cross( &tmpV3_1, vec, &mat->col1 ); + vmathV3Cross( &tmpV3_2, vec, &mat->col2 ); + vmathM3MakeFromCols( result, &tmpV3_0, &tmpV3_1, &tmpV3_2 ); +} + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/vectormathlibrary/include/vectormath/ppu/c/mat_aos_v.h b/vectormathlibrary/include/vectormath/ppu/c/mat_aos_v.h new file mode 100644 index 000000000..47c683abe --- /dev/null +++ b/vectormathlibrary/include/vectormath/ppu/c/mat_aos_v.h @@ -0,0 +1,1026 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_MAT_AOS_V_C_H +#define _VECTORMATH_MAT_AOS_V_C_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/*----------------------------------------------------------------------------- + * Constants + * for shuffles, words are labeled [x,y,z,w] [a,b,c,d] + */ +#define _VECTORMATH_PERM_ZBWX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B, _VECTORMATH_PERM_W, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_XCYX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_C, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_XYAB ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A, _VECTORMATH_PERM_B }) +#define _VECTORMATH_PERM_ZWCD ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_W, _VECTORMATH_PERM_C, _VECTORMATH_PERM_D }) +#define _VECTORMATH_PERM_XZBX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_CXXX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_C, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_YAXX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_XAZC ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_A, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_C }) +#define _VECTORMATH_PERM_YXWZ ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X, _VECTORMATH_PERM_W, _VECTORMATH_PERM_Z }) +#define _VECTORMATH_PERM_YBWD ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_B, _VECTORMATH_PERM_W, _VECTORMATH_PERM_D }) +#define _VECTORMATH_PERM_XYCX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_C, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_YCXY ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_C, _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y }) +#define _VECTORMATH_PERM_CXYC ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_C, _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_C }) +#define _VECTORMATH_PERM_ZAYX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_BZXX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_B, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_XZYA ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A }) +#define _VECTORMATH_PERM_ZXXB ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X, _VECTORMATH_PERM_B }) +#define _VECTORMATH_PERM_YXXC ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X, _VECTORMATH_PERM_C }) +#define _VECTORMATH_PERM_BBYX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_B, _VECTORMATH_PERM_B, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PI_OVER_2 1.570796327f + +/*----------------------------------------------------------------------------- + * Definitions + */ +static inline VmathMatrix3 vmathM3MakeFromScalar_V( float scalar ) +{ + VmathMatrix3 result; + vmathM3MakeFromScalar(&result, scalar); + return result; +} + +static inline VmathMatrix3 vmathM3MakeFromQ_V( VmathQuat unitQuat ) +{ + VmathMatrix3 result; + vmathM3MakeFromQ(&result, &unitQuat); + return result; +} + +static inline VmathMatrix3 vmathM3MakeFromCols_V( VmathVector3 _col0, VmathVector3 _col1, VmathVector3 _col2 ) +{ + VmathMatrix3 result; + vmathM3MakeFromCols(&result, &_col0, &_col1, &_col2); + return result; +} + +static inline void vmathM3SetCol0_V( VmathMatrix3 *result, VmathVector3 _col0 ) +{ + vmathM3SetCol0(result, &_col0); +} + +static inline void vmathM3SetCol1_V( VmathMatrix3 *result, VmathVector3 _col1 ) +{ + vmathM3SetCol1(result, &_col1); +} + +static inline void vmathM3SetCol2_V( VmathMatrix3 *result, VmathVector3 _col2 ) +{ + vmathM3SetCol2(result, &_col2); +} + +static inline void vmathM3SetCol_V( VmathMatrix3 *result, int col, VmathVector3 vec ) +{ + vmathM3SetCol(result, col, &vec); +} + +static inline void vmathM3SetRow_V( VmathMatrix3 *result, int row, VmathVector3 vec ) +{ + vmathM3SetRow(result, row, &vec); +} + +static inline void vmathM3SetElem_V( VmathMatrix3 *result, int col, int row, float val ) +{ + vmathM3SetElem(result, col, row, val); +} + +static inline float vmathM3GetElem_V( VmathMatrix3 mat, int col, int row ) +{ + return vmathM3GetElem(&mat, col, row); +} + +static inline VmathVector3 vmathM3GetCol0_V( VmathMatrix3 mat ) +{ + VmathVector3 result; + vmathM3GetCol0(&result, &mat); + return result; +} + +static inline VmathVector3 vmathM3GetCol1_V( VmathMatrix3 mat ) +{ + VmathVector3 result; + vmathM3GetCol1(&result, &mat); + return result; +} + +static inline VmathVector3 vmathM3GetCol2_V( VmathMatrix3 mat ) +{ + VmathVector3 result; + vmathM3GetCol2(&result, &mat); + return result; +} + +static inline VmathVector3 vmathM3GetCol_V( VmathMatrix3 mat, int col ) +{ + VmathVector3 result; + vmathM3GetCol(&result, &mat, col); + return result; +} + +static inline VmathVector3 vmathM3GetRow_V( VmathMatrix3 mat, int row ) +{ + VmathVector3 result; + vmathM3GetRow(&result, &mat, row); + return result; +} + +static inline VmathMatrix3 vmathM3Transpose_V( VmathMatrix3 mat ) +{ + VmathMatrix3 result; + vmathM3Transpose(&result, &mat); + return result; +} + +static inline VmathMatrix3 vmathM3Inverse_V( VmathMatrix3 mat ) +{ + VmathMatrix3 result; + vmathM3Inverse(&result, &mat); + return result; +} + +static inline float vmathM3Determinant_V( VmathMatrix3 mat ) +{ + return vmathM3Determinant(&mat); +} + +static inline VmathMatrix3 vmathM3Add_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ) +{ + VmathMatrix3 result; + vmathM3Add(&result, &mat0, &mat1); + return result; +} + +static inline VmathMatrix3 vmathM3Sub_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ) +{ + VmathMatrix3 result; + vmathM3Sub(&result, &mat0, &mat1); + return result; +} + +static inline VmathMatrix3 vmathM3Neg_V( VmathMatrix3 mat ) +{ + VmathMatrix3 result; + vmathM3Neg(&result, &mat); + return result; +} + +static inline VmathMatrix3 vmathM3AbsPerElem_V( VmathMatrix3 mat ) +{ + VmathMatrix3 result; + vmathM3AbsPerElem(&result, &mat); + return result; +} + +static inline VmathMatrix3 vmathM3ScalarMul_V( VmathMatrix3 mat, float scalar ) +{ + VmathMatrix3 result; + vmathM3ScalarMul(&result, &mat, scalar); + return result; +} + +static inline VmathVector3 vmathM3MulV3_V( VmathMatrix3 mat, VmathVector3 vec ) +{ + VmathVector3 result; + vmathM3MulV3(&result, &mat, &vec); + return result; +} + +static inline VmathMatrix3 vmathM3Mul_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ) +{ + VmathMatrix3 result; + vmathM3Mul(&result, &mat0, &mat1); + return result; +} + +static inline VmathMatrix3 vmathM3MulPerElem_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ) +{ + VmathMatrix3 result; + vmathM3MulPerElem(&result, &mat0, &mat1); + return result; +} + +static inline VmathMatrix3 vmathM3MakeIdentity_V( ) +{ + VmathMatrix3 result; + vmathM3MakeIdentity(&result); + return result; +} + +static inline VmathMatrix3 vmathM3MakeRotationX_V( float radians ) +{ + VmathMatrix3 result; + vmathM3MakeRotationX(&result, radians); + return result; +} + +static inline VmathMatrix3 vmathM3MakeRotationY_V( float radians ) +{ + VmathMatrix3 result; + vmathM3MakeRotationY(&result, radians); + return result; +} + +static inline VmathMatrix3 vmathM3MakeRotationZ_V( float radians ) +{ + VmathMatrix3 result; + vmathM3MakeRotationZ(&result, radians); + return result; +} + +static inline VmathMatrix3 vmathM3MakeRotationZYX_V( VmathVector3 radiansXYZ ) +{ + VmathMatrix3 result; + vmathM3MakeRotationZYX(&result, &radiansXYZ); + return result; +} + +static inline VmathMatrix3 vmathM3MakeRotationAxis_V( float radians, VmathVector3 unitVec ) +{ + VmathMatrix3 result; + vmathM3MakeRotationAxis(&result, radians, &unitVec); + return result; +} + +static inline VmathMatrix3 vmathM3MakeRotationQ_V( VmathQuat unitQuat ) +{ + VmathMatrix3 result; + vmathM3MakeRotationQ(&result, &unitQuat); + return result; +} + +static inline VmathMatrix3 vmathM3MakeScale_V( VmathVector3 scaleVec ) +{ + VmathMatrix3 result; + vmathM3MakeScale(&result, &scaleVec); + return result; +} + +static inline VmathMatrix3 vmathM3AppendScale_V( VmathMatrix3 mat, VmathVector3 scaleVec ) +{ + VmathMatrix3 result; + vmathM3AppendScale(&result, &mat, &scaleVec); + return result; +} + +static inline VmathMatrix3 vmathM3PrependScale_V( VmathVector3 scaleVec, VmathMatrix3 mat ) +{ + VmathMatrix3 result; + vmathM3PrependScale(&result, &scaleVec, &mat); + return result; +} + +static inline VmathMatrix3 vmathM3Select_V( VmathMatrix3 mat0, VmathMatrix3 mat1, unsigned int select1 ) +{ + VmathMatrix3 result; + vmathM3Select(&result, &mat0, &mat1, select1); + return result; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathM3Print_V( VmathMatrix3 mat ) +{ + vmathM3Print(&mat); +} + +static inline void vmathM3Prints_V( VmathMatrix3 mat, const char *name ) +{ + vmathM3Prints(&mat, name); +} + +#endif + +static inline VmathMatrix4 vmathM4MakeFromScalar_V( float scalar ) +{ + VmathMatrix4 result; + vmathM4MakeFromScalar(&result, scalar); + return result; +} + +static inline VmathMatrix4 vmathM4MakeFromT3_V( VmathTransform3 mat ) +{ + VmathMatrix4 result; + vmathM4MakeFromT3(&result, &mat); + return result; +} + +static inline VmathMatrix4 vmathM4MakeFromCols_V( VmathVector4 _col0, VmathVector4 _col1, VmathVector4 _col2, VmathVector4 _col3 ) +{ + VmathMatrix4 result; + vmathM4MakeFromCols(&result, &_col0, &_col1, &_col2, &_col3); + return result; +} + +static inline VmathMatrix4 vmathM4MakeFromM3V3_V( VmathMatrix3 mat, VmathVector3 translateVec ) +{ + VmathMatrix4 result; + vmathM4MakeFromM3V3(&result, &mat, &translateVec); + return result; +} + +static inline VmathMatrix4 vmathM4MakeFromQV3_V( VmathQuat unitQuat, VmathVector3 translateVec ) +{ + VmathMatrix4 result; + vmathM4MakeFromQV3(&result, &unitQuat, &translateVec); + return result; +} + +static inline void vmathM4SetCol0_V( VmathMatrix4 *result, VmathVector4 _col0 ) +{ + vmathM4SetCol0(result, &_col0); +} + +static inline void vmathM4SetCol1_V( VmathMatrix4 *result, VmathVector4 _col1 ) +{ + vmathM4SetCol1(result, &_col1); +} + +static inline void vmathM4SetCol2_V( VmathMatrix4 *result, VmathVector4 _col2 ) +{ + vmathM4SetCol2(result, &_col2); +} + +static inline void vmathM4SetCol3_V( VmathMatrix4 *result, VmathVector4 _col3 ) +{ + vmathM4SetCol3(result, &_col3); +} + +static inline void vmathM4SetCol_V( VmathMatrix4 *result, int col, VmathVector4 vec ) +{ + vmathM4SetCol(result, col, &vec); +} + +static inline void vmathM4SetRow_V( VmathMatrix4 *result, int row, VmathVector4 vec ) +{ + vmathM4SetRow(result, row, &vec); +} + +static inline void vmathM4SetElem_V( VmathMatrix4 *result, int col, int row, float val ) +{ + vmathM4SetElem(result, col, row, val); +} + +static inline float vmathM4GetElem_V( VmathMatrix4 mat, int col, int row ) +{ + return vmathM4GetElem(&mat, col, row); +} + +static inline VmathVector4 vmathM4GetCol0_V( VmathMatrix4 mat ) +{ + VmathVector4 result; + vmathM4GetCol0(&result, &mat); + return result; +} + +static inline VmathVector4 vmathM4GetCol1_V( VmathMatrix4 mat ) +{ + VmathVector4 result; + vmathM4GetCol1(&result, &mat); + return result; +} + +static inline VmathVector4 vmathM4GetCol2_V( VmathMatrix4 mat ) +{ + VmathVector4 result; + vmathM4GetCol2(&result, &mat); + return result; +} + +static inline VmathVector4 vmathM4GetCol3_V( VmathMatrix4 mat ) +{ + VmathVector4 result; + vmathM4GetCol3(&result, &mat); + return result; +} + +static inline VmathVector4 vmathM4GetCol_V( VmathMatrix4 mat, int col ) +{ + VmathVector4 result; + vmathM4GetCol(&result, &mat, col); + return result; +} + +static inline VmathVector4 vmathM4GetRow_V( VmathMatrix4 mat, int row ) +{ + VmathVector4 result; + vmathM4GetRow(&result, &mat, row); + return result; +} + +static inline VmathMatrix4 vmathM4Transpose_V( VmathMatrix4 mat ) +{ + VmathMatrix4 result; + vmathM4Transpose(&result, &mat); + return result; +} + +static inline VmathMatrix4 vmathM4Inverse_V( VmathMatrix4 mat ) +{ + VmathMatrix4 result; + vmathM4Inverse(&result, &mat); + return result; +} + +static inline VmathMatrix4 vmathM4AffineInverse_V( VmathMatrix4 mat ) +{ + VmathMatrix4 result; + vmathM4AffineInverse(&result, &mat); + return result; +} + +static inline VmathMatrix4 vmathM4OrthoInverse_V( VmathMatrix4 mat ) +{ + VmathMatrix4 result; + vmathM4OrthoInverse(&result, &mat); + return result; +} + +static inline float vmathM4Determinant_V( VmathMatrix4 mat ) +{ + return vmathM4Determinant(&mat); +} + +static inline VmathMatrix4 vmathM4Add_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ) +{ + VmathMatrix4 result; + vmathM4Add(&result, &mat0, &mat1); + return result; +} + +static inline VmathMatrix4 vmathM4Sub_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ) +{ + VmathMatrix4 result; + vmathM4Sub(&result, &mat0, &mat1); + return result; +} + +static inline VmathMatrix4 vmathM4Neg_V( VmathMatrix4 mat ) +{ + VmathMatrix4 result; + vmathM4Neg(&result, &mat); + return result; +} + +static inline VmathMatrix4 vmathM4AbsPerElem_V( VmathMatrix4 mat ) +{ + VmathMatrix4 result; + vmathM4AbsPerElem(&result, &mat); + return result; +} + +static inline VmathMatrix4 vmathM4ScalarMul_V( VmathMatrix4 mat, float scalar ) +{ + VmathMatrix4 result; + vmathM4ScalarMul(&result, &mat, scalar); + return result; +} + +static inline VmathVector4 vmathM4MulV4_V( VmathMatrix4 mat, VmathVector4 vec ) +{ + VmathVector4 result; + vmathM4MulV4(&result, &mat, &vec); + return result; +} + +static inline VmathVector4 vmathM4MulV3_V( VmathMatrix4 mat, VmathVector3 vec ) +{ + VmathVector4 result; + vmathM4MulV3(&result, &mat, &vec); + return result; +} + +static inline VmathVector4 vmathM4MulP3_V( VmathMatrix4 mat, VmathPoint3 pnt ) +{ + VmathVector4 result; + vmathM4MulP3(&result, &mat, &pnt); + return result; +} + +static inline VmathMatrix4 vmathM4Mul_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ) +{ + VmathMatrix4 result; + vmathM4Mul(&result, &mat0, &mat1); + return result; +} + +static inline VmathMatrix4 vmathM4MulT3_V( VmathMatrix4 mat, VmathTransform3 tfrm1 ) +{ + VmathMatrix4 result; + vmathM4MulT3(&result, &mat, &tfrm1); + return result; +} + +static inline VmathMatrix4 vmathM4MulPerElem_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ) +{ + VmathMatrix4 result; + vmathM4MulPerElem(&result, &mat0, &mat1); + return result; +} + +static inline VmathMatrix4 vmathM4MakeIdentity_V( ) +{ + VmathMatrix4 result; + vmathM4MakeIdentity(&result); + return result; +} + +static inline void vmathM4SetUpper3x3_V( VmathMatrix4 *result, VmathMatrix3 mat3 ) +{ + vmathM4SetUpper3x3(result, &mat3); +} + +static inline VmathMatrix3 vmathM4GetUpper3x3_V( VmathMatrix4 mat ) +{ + VmathMatrix3 result; + vmathM4GetUpper3x3(&result, &mat); + return result; +} + +static inline void vmathM4SetTranslation_V( VmathMatrix4 *result, VmathVector3 translateVec ) +{ + vmathM4SetTranslation(result, &translateVec); +} + +static inline VmathVector3 vmathM4GetTranslation_V( VmathMatrix4 mat ) +{ + VmathVector3 result; + vmathM4GetTranslation(&result, &mat); + return result; +} + +static inline VmathMatrix4 vmathM4MakeRotationX_V( float radians ) +{ + VmathMatrix4 result; + vmathM4MakeRotationX(&result, radians); + return result; +} + +static inline VmathMatrix4 vmathM4MakeRotationY_V( float radians ) +{ + VmathMatrix4 result; + vmathM4MakeRotationY(&result, radians); + return result; +} + +static inline VmathMatrix4 vmathM4MakeRotationZ_V( float radians ) +{ + VmathMatrix4 result; + vmathM4MakeRotationZ(&result, radians); + return result; +} + +static inline VmathMatrix4 vmathM4MakeRotationZYX_V( VmathVector3 radiansXYZ ) +{ + VmathMatrix4 result; + vmathM4MakeRotationZYX(&result, &radiansXYZ); + return result; +} + +static inline VmathMatrix4 vmathM4MakeRotationAxis_V( float radians, VmathVector3 unitVec ) +{ + VmathMatrix4 result; + vmathM4MakeRotationAxis(&result, radians, &unitVec); + return result; +} + +static inline VmathMatrix4 vmathM4MakeRotationQ_V( VmathQuat unitQuat ) +{ + VmathMatrix4 result; + vmathM4MakeRotationQ(&result, &unitQuat); + return result; +} + +static inline VmathMatrix4 vmathM4MakeScale_V( VmathVector3 scaleVec ) +{ + VmathMatrix4 result; + vmathM4MakeScale(&result, &scaleVec); + return result; +} + +static inline VmathMatrix4 vmathM4AppendScale_V( VmathMatrix4 mat, VmathVector3 scaleVec ) +{ + VmathMatrix4 result; + vmathM4AppendScale(&result, &mat, &scaleVec); + return result; +} + +static inline VmathMatrix4 vmathM4PrependScale_V( VmathVector3 scaleVec, VmathMatrix4 mat ) +{ + VmathMatrix4 result; + vmathM4PrependScale(&result, &scaleVec, &mat); + return result; +} + +static inline VmathMatrix4 vmathM4MakeTranslation_V( VmathVector3 translateVec ) +{ + VmathMatrix4 result; + vmathM4MakeTranslation(&result, &translateVec); + return result; +} + +static inline VmathMatrix4 vmathM4MakeLookAt_V( VmathPoint3 eyePos, VmathPoint3 lookAtPos, VmathVector3 upVec ) +{ + VmathMatrix4 result; + vmathM4MakeLookAt(&result, &eyePos, &lookAtPos, &upVec); + return result; +} + +static inline VmathMatrix4 vmathM4MakePerspective_V( float fovyRadians, float aspect, float zNear, float zFar ) +{ + VmathMatrix4 result; + vmathM4MakePerspective(&result, fovyRadians, aspect, zNear, zFar); + return result; +} + +static inline VmathMatrix4 vmathM4MakeFrustum_V( float left, float right, float bottom, float top, float zNear, float zFar ) +{ + VmathMatrix4 result; + vmathM4MakeFrustum(&result, left, right, bottom, top, zNear, zFar); + return result; +} + +static inline VmathMatrix4 vmathM4MakeOrthographic_V( float left, float right, float bottom, float top, float zNear, float zFar ) +{ + VmathMatrix4 result; + vmathM4MakeOrthographic(&result, left, right, bottom, top, zNear, zFar); + return result; +} + +static inline VmathMatrix4 vmathM4Select_V( VmathMatrix4 mat0, VmathMatrix4 mat1, unsigned int select1 ) +{ + VmathMatrix4 result; + vmathM4Select(&result, &mat0, &mat1, select1); + return result; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathM4Print_V( VmathMatrix4 mat ) +{ + vmathM4Print(&mat); +} + +static inline void vmathM4Prints_V( VmathMatrix4 mat, const char *name ) +{ + vmathM4Prints(&mat, name); +} + +#endif + +static inline VmathTransform3 vmathT3MakeFromScalar_V( float scalar ) +{ + VmathTransform3 result; + vmathT3MakeFromScalar(&result, scalar); + return result; +} + +static inline VmathTransform3 vmathT3MakeFromCols_V( VmathVector3 _col0, VmathVector3 _col1, VmathVector3 _col2, VmathVector3 _col3 ) +{ + VmathTransform3 result; + vmathT3MakeFromCols(&result, &_col0, &_col1, &_col2, &_col3); + return result; +} + +static inline VmathTransform3 vmathT3MakeFromM3V3_V( VmathMatrix3 tfrm, VmathVector3 translateVec ) +{ + VmathTransform3 result; + vmathT3MakeFromM3V3(&result, &tfrm, &translateVec); + return result; +} + +static inline VmathTransform3 vmathT3MakeFromQV3_V( VmathQuat unitQuat, VmathVector3 translateVec ) +{ + VmathTransform3 result; + vmathT3MakeFromQV3(&result, &unitQuat, &translateVec); + return result; +} + +static inline void vmathT3SetCol0_V( VmathTransform3 *result, VmathVector3 _col0 ) +{ + vmathT3SetCol0(result, &_col0); +} + +static inline void vmathT3SetCol1_V( VmathTransform3 *result, VmathVector3 _col1 ) +{ + vmathT3SetCol1(result, &_col1); +} + +static inline void vmathT3SetCol2_V( VmathTransform3 *result, VmathVector3 _col2 ) +{ + vmathT3SetCol2(result, &_col2); +} + +static inline void vmathT3SetCol3_V( VmathTransform3 *result, VmathVector3 _col3 ) +{ + vmathT3SetCol3(result, &_col3); +} + +static inline void vmathT3SetCol_V( VmathTransform3 *result, int col, VmathVector3 vec ) +{ + vmathT3SetCol(result, col, &vec); +} + +static inline void vmathT3SetRow_V( VmathTransform3 *result, int row, VmathVector4 vec ) +{ + vmathT3SetRow(result, row, &vec); +} + +static inline void vmathT3SetElem_V( VmathTransform3 *result, int col, int row, float val ) +{ + vmathT3SetElem(result, col, row, val); +} + +static inline float vmathT3GetElem_V( VmathTransform3 tfrm, int col, int row ) +{ + return vmathT3GetElem(&tfrm, col, row); +} + +static inline VmathVector3 vmathT3GetCol0_V( VmathTransform3 tfrm ) +{ + VmathVector3 result; + vmathT3GetCol0(&result, &tfrm); + return result; +} + +static inline VmathVector3 vmathT3GetCol1_V( VmathTransform3 tfrm ) +{ + VmathVector3 result; + vmathT3GetCol1(&result, &tfrm); + return result; +} + +static inline VmathVector3 vmathT3GetCol2_V( VmathTransform3 tfrm ) +{ + VmathVector3 result; + vmathT3GetCol2(&result, &tfrm); + return result; +} + +static inline VmathVector3 vmathT3GetCol3_V( VmathTransform3 tfrm ) +{ + VmathVector3 result; + vmathT3GetCol3(&result, &tfrm); + return result; +} + +static inline VmathVector3 vmathT3GetCol_V( VmathTransform3 tfrm, int col ) +{ + VmathVector3 result; + vmathT3GetCol(&result, &tfrm, col); + return result; +} + +static inline VmathVector4 vmathT3GetRow_V( VmathTransform3 tfrm, int row ) +{ + VmathVector4 result; + vmathT3GetRow(&result, &tfrm, row); + return result; +} + +static inline VmathTransform3 vmathT3Inverse_V( VmathTransform3 tfrm ) +{ + VmathTransform3 result; + vmathT3Inverse(&result, &tfrm); + return result; +} + +static inline VmathTransform3 vmathT3OrthoInverse_V( VmathTransform3 tfrm ) +{ + VmathTransform3 result; + vmathT3OrthoInverse(&result, &tfrm); + return result; +} + +static inline VmathTransform3 vmathT3AbsPerElem_V( VmathTransform3 tfrm ) +{ + VmathTransform3 result; + vmathT3AbsPerElem(&result, &tfrm); + return result; +} + +static inline VmathVector3 vmathT3MulV3_V( VmathTransform3 tfrm, VmathVector3 vec ) +{ + VmathVector3 result; + vmathT3MulV3(&result, &tfrm, &vec); + return result; +} + +static inline VmathPoint3 vmathT3MulP3_V( VmathTransform3 tfrm, VmathPoint3 pnt ) +{ + VmathPoint3 result; + vmathT3MulP3(&result, &tfrm, &pnt); + return result; +} + +static inline VmathTransform3 vmathT3Mul_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1 ) +{ + VmathTransform3 result; + vmathT3Mul(&result, &tfrm0, &tfrm1); + return result; +} + +static inline VmathTransform3 vmathT3MulPerElem_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1 ) +{ + VmathTransform3 result; + vmathT3MulPerElem(&result, &tfrm0, &tfrm1); + return result; +} + +static inline VmathTransform3 vmathT3MakeIdentity_V( ) +{ + VmathTransform3 result; + vmathT3MakeIdentity(&result); + return result; +} + +static inline void vmathT3SetUpper3x3_V( VmathTransform3 *result, VmathMatrix3 tfrm ) +{ + vmathT3SetUpper3x3(result, &tfrm); +} + +static inline VmathMatrix3 vmathT3GetUpper3x3_V( VmathTransform3 tfrm ) +{ + VmathMatrix3 result; + vmathT3GetUpper3x3(&result, &tfrm); + return result; +} + +static inline void vmathT3SetTranslation_V( VmathTransform3 *result, VmathVector3 translateVec ) +{ + vmathT3SetTranslation(result, &translateVec); +} + +static inline VmathVector3 vmathT3GetTranslation_V( VmathTransform3 tfrm ) +{ + VmathVector3 result; + vmathT3GetTranslation(&result, &tfrm); + return result; +} + +static inline VmathTransform3 vmathT3MakeRotationX_V( float radians ) +{ + VmathTransform3 result; + vmathT3MakeRotationX(&result, radians); + return result; +} + +static inline VmathTransform3 vmathT3MakeRotationY_V( float radians ) +{ + VmathTransform3 result; + vmathT3MakeRotationY(&result, radians); + return result; +} + +static inline VmathTransform3 vmathT3MakeRotationZ_V( float radians ) +{ + VmathTransform3 result; + vmathT3MakeRotationZ(&result, radians); + return result; +} + +static inline VmathTransform3 vmathT3MakeRotationZYX_V( VmathVector3 radiansXYZ ) +{ + VmathTransform3 result; + vmathT3MakeRotationZYX(&result, &radiansXYZ); + return result; +} + +static inline VmathTransform3 vmathT3MakeRotationAxis_V( float radians, VmathVector3 unitVec ) +{ + VmathTransform3 result; + vmathT3MakeRotationAxis(&result, radians, &unitVec); + return result; +} + +static inline VmathTransform3 vmathT3MakeRotationQ_V( VmathQuat unitQuat ) +{ + VmathTransform3 result; + vmathT3MakeRotationQ(&result, &unitQuat); + return result; +} + +static inline VmathTransform3 vmathT3MakeScale_V( VmathVector3 scaleVec ) +{ + VmathTransform3 result; + vmathT3MakeScale(&result, &scaleVec); + return result; +} + +static inline VmathTransform3 vmathT3AppendScale_V( VmathTransform3 tfrm, VmathVector3 scaleVec ) +{ + VmathTransform3 result; + vmathT3AppendScale(&result, &tfrm, &scaleVec); + return result; +} + +static inline VmathTransform3 vmathT3PrependScale_V( VmathVector3 scaleVec, VmathTransform3 tfrm ) +{ + VmathTransform3 result; + vmathT3PrependScale(&result, &scaleVec, &tfrm); + return result; +} + +static inline VmathTransform3 vmathT3MakeTranslation_V( VmathVector3 translateVec ) +{ + VmathTransform3 result; + vmathT3MakeTranslation(&result, &translateVec); + return result; +} + +static inline VmathTransform3 vmathT3Select_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1, unsigned int select1 ) +{ + VmathTransform3 result; + vmathT3Select(&result, &tfrm0, &tfrm1, select1); + return result; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathT3Print_V( VmathTransform3 tfrm ) +{ + vmathT3Print(&tfrm); +} + +static inline void vmathT3Prints_V( VmathTransform3 tfrm, const char *name ) +{ + vmathT3Prints(&tfrm, name); +} + +#endif + +static inline VmathQuat vmathQMakeFromM3_V( VmathMatrix3 tfrm ) +{ + VmathQuat result; + vmathQMakeFromM3(&result, &tfrm); + return result; +} + +static inline VmathMatrix3 vmathV3Outer_V( VmathVector3 tfrm0, VmathVector3 tfrm1 ) +{ + VmathMatrix3 result; + vmathV3Outer(&result, &tfrm0, &tfrm1); + return result; +} + +static inline VmathMatrix4 vmathV4Outer_V( VmathVector4 tfrm0, VmathVector4 tfrm1 ) +{ + VmathMatrix4 result; + vmathV4Outer(&result, &tfrm0, &tfrm1); + return result; +} + +static inline VmathVector3 vmathV3RowMul_V( VmathVector3 vec, VmathMatrix3 mat ) +{ + VmathVector3 result; + vmathV3RowMul(&result, &vec, &mat); + return result; +} + +static inline VmathMatrix3 vmathV3CrossMatrix_V( VmathVector3 vec ) +{ + VmathMatrix3 result; + vmathV3CrossMatrix(&result, &vec); + return result; +} + +static inline VmathMatrix3 vmathV3CrossMatrixMul_V( VmathVector3 vec, VmathMatrix3 mat ) +{ + VmathMatrix3 result; + vmathV3CrossMatrixMul(&result, &vec, &mat); + return result; +} + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/vectormathlibrary/include/vectormath/ppu/c/mat_soa.h b/vectormathlibrary/include/vectormath/ppu/c/mat_soa.h new file mode 100644 index 000000000..3b673c4eb --- /dev/null +++ b/vectormathlibrary/include/vectormath/ppu/c/mat_soa.h @@ -0,0 +1,1493 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_MAT_SOA_C_H +#define _VECTORMATH_MAT_SOA_C_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/*----------------------------------------------------------------------------- + * Constants + */ +#define _VECTORMATH_PI_OVER_2 1.570796327f + +/*----------------------------------------------------------------------------- + * Definitions + */ +static inline void vmathSoaM3Copy( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ) +{ + vmathSoaV3Copy( &result->col0, &mat->col0 ); + vmathSoaV3Copy( &result->col1, &mat->col1 ); + vmathSoaV3Copy( &result->col2, &mat->col2 ); +} + +static inline void vmathSoaM3MakeFromScalar( VmathSoaMatrix3 *result, vec_float4 scalar ) +{ + vmathSoaV3MakeFromScalar( &result->col0, scalar ); + vmathSoaV3MakeFromScalar( &result->col1, scalar ); + vmathSoaV3MakeFromScalar( &result->col2, scalar ); +} + +static inline void vmathSoaM3MakeFromQ( VmathSoaMatrix3 *result, const VmathSoaQuat *unitQuat ) +{ + vec_float4 qx, qy, qz, qw, qx2, qy2, qz2, qxqx2, qyqy2, qzqz2, qxqy2, qyqz2, qzqw2, qxqz2, qyqw2, qxqw2; + qx = unitQuat->x; + qy = unitQuat->y; + qz = unitQuat->z; + qw = unitQuat->w; + qx2 = vec_add( qx, qx ); + qy2 = vec_add( qy, qy ); + qz2 = vec_add( qz, qz ); + qxqx2 = vec_madd( qx, qx2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + qxqy2 = vec_madd( qx, qy2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + qxqz2 = vec_madd( qx, qz2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + qxqw2 = vec_madd( qw, qx2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + qyqy2 = vec_madd( qy, qy2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + qyqz2 = vec_madd( qy, qz2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + qyqw2 = vec_madd( qw, qy2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + qzqz2 = vec_madd( qz, qz2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + qzqw2 = vec_madd( qw, qz2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV3MakeFromElems( &result->col0, vec_sub( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), qyqy2 ), qzqz2 ), vec_add( qxqy2, qzqw2 ), vec_sub( qxqz2, qyqw2 ) ); + vmathSoaV3MakeFromElems( &result->col1, vec_sub( qxqy2, qzqw2 ), vec_sub( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), qxqx2 ), qzqz2 ), vec_add( qyqz2, qxqw2 ) ); + vmathSoaV3MakeFromElems( &result->col2, vec_add( qxqz2, qyqw2 ), vec_sub( qyqz2, qxqw2 ), vec_sub( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), qxqx2 ), qyqy2 ) ); +} + +static inline void vmathSoaM3MakeFromCols( VmathSoaMatrix3 *result, const VmathSoaVector3 *_col0, const VmathSoaVector3 *_col1, const VmathSoaVector3 *_col2 ) +{ + vmathSoaV3Copy( &result->col0, _col0 ); + vmathSoaV3Copy( &result->col1, _col1 ); + vmathSoaV3Copy( &result->col2, _col2 ); +} + +static inline void vmathSoaM3MakeFromAos( VmathSoaMatrix3 *result, const VmathMatrix3 *mat ) +{ + vmathSoaV3MakeFromAos( &result->col0, &mat->col0 ); + vmathSoaV3MakeFromAos( &result->col1, &mat->col1 ); + vmathSoaV3MakeFromAos( &result->col2, &mat->col2 ); +} + +static inline void vmathSoaM3MakeFrom4Aos( VmathSoaMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1, const VmathMatrix3 *mat2, const VmathMatrix3 *mat3 ) +{ + vmathSoaV3MakeFrom4Aos( &result->col0, &mat0->col0, &mat1->col0, &mat2->col0, &mat3->col0 ); + vmathSoaV3MakeFrom4Aos( &result->col1, &mat0->col1, &mat1->col1, &mat2->col1, &mat3->col1 ); + vmathSoaV3MakeFrom4Aos( &result->col2, &mat0->col2, &mat1->col2, &mat2->col2, &mat3->col2 ); +} + +static inline void vmathSoaM3Get4Aos( const VmathSoaMatrix3 *mat, VmathMatrix3 *result0, VmathMatrix3 *result1, VmathMatrix3 *result2, VmathMatrix3 *result3 ) +{ + vmathSoaV3Get4Aos( &mat->col0, &result0->col0, &result1->col0, &result2->col0, &result3->col0 ); + vmathSoaV3Get4Aos( &mat->col1, &result0->col1, &result1->col1, &result2->col1, &result3->col1 ); + vmathSoaV3Get4Aos( &mat->col2, &result0->col2, &result1->col2, &result2->col2, &result3->col2 ); +} + +static inline void vmathSoaM3SetCol0( VmathSoaMatrix3 *result, const VmathSoaVector3 *_col0 ) +{ + vmathSoaV3Copy( &result->col0, _col0 ); +} + +static inline void vmathSoaM3SetCol1( VmathSoaMatrix3 *result, const VmathSoaVector3 *_col1 ) +{ + vmathSoaV3Copy( &result->col1, _col1 ); +} + +static inline void vmathSoaM3SetCol2( VmathSoaMatrix3 *result, const VmathSoaVector3 *_col2 ) +{ + vmathSoaV3Copy( &result->col2, _col2 ); +} + +static inline void vmathSoaM3SetCol( VmathSoaMatrix3 *result, int col, const VmathSoaVector3 *vec ) +{ + vmathSoaV3Copy( (&result->col0 + col), vec ); +} + +static inline void vmathSoaM3SetRow( VmathSoaMatrix3 *result, int row, const VmathSoaVector3 *vec ) +{ + vmathSoaV3SetElem( &result->col0, row, vmathSoaV3GetElem( vec, 0 ) ); + vmathSoaV3SetElem( &result->col1, row, vmathSoaV3GetElem( vec, 1 ) ); + vmathSoaV3SetElem( &result->col2, row, vmathSoaV3GetElem( vec, 2 ) ); +} + +static inline void vmathSoaM3SetElem( VmathSoaMatrix3 *result, int col, int row, vec_float4 val ) +{ + VmathSoaVector3 tmpV3_0; + vmathSoaM3GetCol( &tmpV3_0, result, col ); + vmathSoaV3SetElem( &tmpV3_0, row, val ); + vmathSoaM3SetCol( result, col, &tmpV3_0 ); +} + +static inline vec_float4 vmathSoaM3GetElem( const VmathSoaMatrix3 *mat, int col, int row ) +{ + VmathSoaVector3 tmpV3_0; + vmathSoaM3GetCol( &tmpV3_0, mat, col ); + return vmathSoaV3GetElem( &tmpV3_0, row ); +} + +static inline void vmathSoaM3GetCol0( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat ) +{ + vmathSoaV3Copy( result, &mat->col0 ); +} + +static inline void vmathSoaM3GetCol1( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat ) +{ + vmathSoaV3Copy( result, &mat->col1 ); +} + +static inline void vmathSoaM3GetCol2( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat ) +{ + vmathSoaV3Copy( result, &mat->col2 ); +} + +static inline void vmathSoaM3GetCol( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat, int col ) +{ + vmathSoaV3Copy( result, (&mat->col0 + col) ); +} + +static inline void vmathSoaM3GetRow( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat, int row ) +{ + vmathSoaV3MakeFromElems( result, vmathSoaV3GetElem( &mat->col0, row ), vmathSoaV3GetElem( &mat->col1, row ), vmathSoaV3GetElem( &mat->col2, row ) ); +} + +static inline void vmathSoaM3Transpose( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ) +{ + VmathSoaMatrix3 tmpResult; + vmathSoaV3MakeFromElems( &tmpResult.col0, mat->col0.x, mat->col1.x, mat->col2.x ); + vmathSoaV3MakeFromElems( &tmpResult.col1, mat->col0.y, mat->col1.y, mat->col2.y ); + vmathSoaV3MakeFromElems( &tmpResult.col2, mat->col0.z, mat->col1.z, mat->col2.z ); + vmathSoaM3Copy( result, &tmpResult ); +} + +static inline void vmathSoaM3Inverse( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ) +{ + VmathSoaVector3 tmp0, tmp1, tmp2; + vec_float4 detinv; + vmathSoaV3Cross( &tmp0, &mat->col1, &mat->col2 ); + vmathSoaV3Cross( &tmp1, &mat->col2, &mat->col0 ); + vmathSoaV3Cross( &tmp2, &mat->col0, &mat->col1 ); + detinv = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vmathSoaV3Dot( &mat->col2, &tmp2 ) ); + vmathSoaV3MakeFromElems( &result->col0, vec_madd( tmp0.x, detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp1.x, detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp2.x, detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + vmathSoaV3MakeFromElems( &result->col1, vec_madd( tmp0.y, detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp1.y, detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp2.y, detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + vmathSoaV3MakeFromElems( &result->col2, vec_madd( tmp0.z, detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp1.z, detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp2.z, detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); +} + +static inline vec_float4 vmathSoaM3Determinant( const VmathSoaMatrix3 *mat ) +{ + VmathSoaVector3 tmpV3_0; + vmathSoaV3Cross( &tmpV3_0, &mat->col0, &mat->col1 ); + return vmathSoaV3Dot( &mat->col2, &tmpV3_0 ); +} + +static inline void vmathSoaM3Add( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1 ) +{ + vmathSoaV3Add( &result->col0, &mat0->col0, &mat1->col0 ); + vmathSoaV3Add( &result->col1, &mat0->col1, &mat1->col1 ); + vmathSoaV3Add( &result->col2, &mat0->col2, &mat1->col2 ); +} + +static inline void vmathSoaM3Sub( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1 ) +{ + vmathSoaV3Sub( &result->col0, &mat0->col0, &mat1->col0 ); + vmathSoaV3Sub( &result->col1, &mat0->col1, &mat1->col1 ); + vmathSoaV3Sub( &result->col2, &mat0->col2, &mat1->col2 ); +} + +static inline void vmathSoaM3Neg( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ) +{ + vmathSoaV3Neg( &result->col0, &mat->col0 ); + vmathSoaV3Neg( &result->col1, &mat->col1 ); + vmathSoaV3Neg( &result->col2, &mat->col2 ); +} + +static inline void vmathSoaM3AbsPerElem( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ) +{ + vmathSoaV3AbsPerElem( &result->col0, &mat->col0 ); + vmathSoaV3AbsPerElem( &result->col1, &mat->col1 ); + vmathSoaV3AbsPerElem( &result->col2, &mat->col2 ); +} + +static inline void vmathSoaM3ScalarMul( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat, vec_float4 scalar ) +{ + vmathSoaV3ScalarMul( &result->col0, &mat->col0, scalar ); + vmathSoaV3ScalarMul( &result->col1, &mat->col1, scalar ); + vmathSoaV3ScalarMul( &result->col2, &mat->col2, scalar ); +} + +static inline void vmathSoaM3MulV3( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat, const VmathSoaVector3 *vec ) +{ + vec_float4 tmpX, tmpY, tmpZ; + tmpX = vec_add( vec_add( vec_madd( mat->col0.x, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mat->col1.x, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col2.x, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmpY = vec_add( vec_add( vec_madd( mat->col0.y, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mat->col1.y, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col2.y, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmpZ = vec_add( vec_add( vec_madd( mat->col0.z, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mat->col1.z, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col2.z, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + vmathSoaV3MakeFromElems( result, tmpX, tmpY, tmpZ ); +} + +static inline void vmathSoaM3Mul( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1 ) +{ + VmathSoaMatrix3 tmpResult; + vmathSoaM3MulV3( &tmpResult.col0, mat0, &mat1->col0 ); + vmathSoaM3MulV3( &tmpResult.col1, mat0, &mat1->col1 ); + vmathSoaM3MulV3( &tmpResult.col2, mat0, &mat1->col2 ); + vmathSoaM3Copy( result, &tmpResult ); +} + +static inline void vmathSoaM3MulPerElem( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1 ) +{ + vmathSoaV3MulPerElem( &result->col0, &mat0->col0, &mat1->col0 ); + vmathSoaV3MulPerElem( &result->col1, &mat0->col1, &mat1->col1 ); + vmathSoaV3MulPerElem( &result->col2, &mat0->col2, &mat1->col2 ); +} + +static inline void vmathSoaM3MakeIdentity( VmathSoaMatrix3 *result ) +{ + vmathSoaV3MakeXAxis( &result->col0 ); + vmathSoaV3MakeYAxis( &result->col1 ); + vmathSoaV3MakeZAxis( &result->col2 ); +} + +static inline void vmathSoaM3MakeRotationX( VmathSoaMatrix3 *result, vec_float4 radians ) +{ + vec_float4 s, c; + sincosf4( radians, &s, &c ); + vmathSoaV3MakeXAxis( &result->col0 ); + vmathSoaV3MakeFromElems( &result->col1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c, s ); + vmathSoaV3MakeFromElems( &result->col2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), negatef4( s ), c ); +} + +static inline void vmathSoaM3MakeRotationY( VmathSoaMatrix3 *result, vec_float4 radians ) +{ + vec_float4 s, c; + sincosf4( radians, &s, &c ); + vmathSoaV3MakeFromElems( &result->col0, c, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), negatef4( s ) ); + vmathSoaV3MakeYAxis( &result->col1 ); + vmathSoaV3MakeFromElems( &result->col2, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c ); +} + +static inline void vmathSoaM3MakeRotationZ( VmathSoaMatrix3 *result, vec_float4 radians ) +{ + vec_float4 s, c; + sincosf4( radians, &s, &c ); + vmathSoaV3MakeFromElems( &result->col0, c, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV3MakeFromElems( &result->col1, negatef4( s ), c, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV3MakeZAxis( &result->col2 ); +} + +static inline void vmathSoaM3MakeRotationZYX( VmathSoaMatrix3 *result, const VmathSoaVector3 *radiansXYZ ) +{ + vec_float4 sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; + sincosf4( radiansXYZ->x, &sX, &cX ); + sincosf4( radiansXYZ->y, &sY, &cY ); + sincosf4( radiansXYZ->z, &sZ, &cZ ); + tmp0 = vec_madd( cZ, sY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + tmp1 = vec_madd( sZ, sY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV3MakeFromElems( &result->col0, vec_madd( cZ, cY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sZ, cY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), negatef4( sY ) ); + vmathSoaV3MakeFromElems( &result->col1, vec_sub( vec_madd( tmp0, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sZ, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_add( vec_madd( tmp1, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( cZ, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( cY, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + vmathSoaV3MakeFromElems( &result->col2, vec_add( vec_madd( tmp0, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sZ, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_sub( vec_madd( tmp1, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( cZ, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( cY, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); +} + +static inline void vmathSoaM3MakeRotationAxis( VmathSoaMatrix3 *result, vec_float4 radians, const VmathSoaVector3 *unitVec ) +{ + vec_float4 x, y, z, s, c, oneMinusC, xy, yz, zx; + sincosf4( radians, &s, &c ); + x = unitVec->x; + y = unitVec->y; + z = unitVec->z; + xy = vec_madd( x, y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + yz = vec_madd( y, z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + zx = vec_madd( z, x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + oneMinusC = vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), c ); + vmathSoaV3MakeFromElems( &result->col0, vec_add( vec_madd( vec_madd( x, x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), c ), vec_add( vec_madd( xy, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( z, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_sub( vec_madd( zx, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( y, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ); + vmathSoaV3MakeFromElems( &result->col1, vec_sub( vec_madd( xy, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( z, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_add( vec_madd( vec_madd( y, y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), c ), vec_add( vec_madd( yz, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( x, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ); + vmathSoaV3MakeFromElems( &result->col2, vec_add( vec_madd( zx, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( y, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_sub( vec_madd( yz, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( x, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_add( vec_madd( vec_madd( z, z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), c ) ); +} + +static inline void vmathSoaM3MakeRotationQ( VmathSoaMatrix3 *result, const VmathSoaQuat *unitQuat ) +{ + vmathSoaM3MakeFromQ( result, unitQuat ); +} + +static inline void vmathSoaM3MakeScale( VmathSoaMatrix3 *result, const VmathSoaVector3 *scaleVec ) +{ + vmathSoaV3MakeFromElems( &result->col0, scaleVec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV3MakeFromElems( &result->col1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), scaleVec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV3MakeFromElems( &result->col2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), scaleVec->z ); +} + +static inline void vmathSoaM3AppendScale( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat, const VmathSoaVector3 *scaleVec ) +{ + vmathSoaV3ScalarMul( &result->col0, &mat->col0, vmathSoaV3GetX( scaleVec ) ); + vmathSoaV3ScalarMul( &result->col1, &mat->col1, vmathSoaV3GetY( scaleVec ) ); + vmathSoaV3ScalarMul( &result->col2, &mat->col2, vmathSoaV3GetZ( scaleVec ) ); +} + +static inline void vmathSoaM3PrependScale( VmathSoaMatrix3 *result, const VmathSoaVector3 *scaleVec, const VmathSoaMatrix3 *mat ) +{ + vmathSoaV3MulPerElem( &result->col0, &mat->col0, scaleVec ); + vmathSoaV3MulPerElem( &result->col1, &mat->col1, scaleVec ); + vmathSoaV3MulPerElem( &result->col2, &mat->col2, scaleVec ); +} + +static inline void vmathSoaM3Select( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1, vec_uint4 select1 ) +{ + vmathSoaV3Select( &result->col0, &mat0->col0, &mat1->col0, select1 ); + vmathSoaV3Select( &result->col1, &mat0->col1, &mat1->col1, select1 ); + vmathSoaV3Select( &result->col2, &mat0->col2, &mat1->col2, select1 ); +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathSoaM3Print( const VmathSoaMatrix3 *mat ) +{ + VmathMatrix3 mat0, mat1, mat2, mat3; + vmathSoaM3Get4Aos( mat, &mat0, &mat1, &mat2, &mat3 ); + printf("slot 0:\n"); + vmathM3Print( &mat0 ); + printf("slot 1:\n"); + vmathM3Print( &mat1 ); + printf("slot 2:\n"); + vmathM3Print( &mat2 ); + printf("slot 3:\n"); + vmathM3Print( &mat3 ); +} + +static inline void vmathSoaM3Prints( const VmathSoaMatrix3 *mat, const char *name ) +{ + printf("%s:\n", name); + vmathSoaM3Print( mat ); +} + +#endif + +static inline void vmathSoaM4Copy( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ) +{ + vmathSoaV4Copy( &result->col0, &mat->col0 ); + vmathSoaV4Copy( &result->col1, &mat->col1 ); + vmathSoaV4Copy( &result->col2, &mat->col2 ); + vmathSoaV4Copy( &result->col3, &mat->col3 ); +} + +static inline void vmathSoaM4MakeFromScalar( VmathSoaMatrix4 *result, vec_float4 scalar ) +{ + vmathSoaV4MakeFromScalar( &result->col0, scalar ); + vmathSoaV4MakeFromScalar( &result->col1, scalar ); + vmathSoaV4MakeFromScalar( &result->col2, scalar ); + vmathSoaV4MakeFromScalar( &result->col3, scalar ); +} + +static inline void vmathSoaM4MakeFromT3( VmathSoaMatrix4 *result, const VmathSoaTransform3 *mat ) +{ + vmathSoaV4MakeFromV3Scalar( &result->col0, &mat->col0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV4MakeFromV3Scalar( &result->col1, &mat->col1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV4MakeFromV3Scalar( &result->col2, &mat->col2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV4MakeFromV3Scalar( &result->col3, &mat->col3, ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); +} + +static inline void vmathSoaM4MakeFromCols( VmathSoaMatrix4 *result, const VmathSoaVector4 *_col0, const VmathSoaVector4 *_col1, const VmathSoaVector4 *_col2, const VmathSoaVector4 *_col3 ) +{ + vmathSoaV4Copy( &result->col0, _col0 ); + vmathSoaV4Copy( &result->col1, _col1 ); + vmathSoaV4Copy( &result->col2, _col2 ); + vmathSoaV4Copy( &result->col3, _col3 ); +} + +static inline void vmathSoaM4MakeFromM3V3( VmathSoaMatrix4 *result, const VmathSoaMatrix3 *mat, const VmathSoaVector3 *translateVec ) +{ + vmathSoaV4MakeFromV3Scalar( &result->col0, &mat->col0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV4MakeFromV3Scalar( &result->col1, &mat->col1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV4MakeFromV3Scalar( &result->col2, &mat->col2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV4MakeFromV3Scalar( &result->col3, translateVec, ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); +} + +static inline void vmathSoaM4MakeFromQV3( VmathSoaMatrix4 *result, const VmathSoaQuat *unitQuat, const VmathSoaVector3 *translateVec ) +{ + VmathSoaMatrix3 mat; + vmathSoaM3MakeFromQ( &mat, unitQuat ); + vmathSoaV4MakeFromV3Scalar( &result->col0, &mat.col0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV4MakeFromV3Scalar( &result->col1, &mat.col1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV4MakeFromV3Scalar( &result->col2, &mat.col2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV4MakeFromV3Scalar( &result->col3, translateVec, ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); +} + +static inline void vmathSoaM4MakeFromAos( VmathSoaMatrix4 *result, const VmathMatrix4 *mat ) +{ + vmathSoaV4MakeFromAos( &result->col0, &mat->col0 ); + vmathSoaV4MakeFromAos( &result->col1, &mat->col1 ); + vmathSoaV4MakeFromAos( &result->col2, &mat->col2 ); + vmathSoaV4MakeFromAos( &result->col3, &mat->col3 ); +} + +static inline void vmathSoaM4MakeFrom4Aos( VmathSoaMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1, const VmathMatrix4 *mat2, const VmathMatrix4 *mat3 ) +{ + vmathSoaV4MakeFrom4Aos( &result->col0, &mat0->col0, &mat1->col0, &mat2->col0, &mat3->col0 ); + vmathSoaV4MakeFrom4Aos( &result->col1, &mat0->col1, &mat1->col1, &mat2->col1, &mat3->col1 ); + vmathSoaV4MakeFrom4Aos( &result->col2, &mat0->col2, &mat1->col2, &mat2->col2, &mat3->col2 ); + vmathSoaV4MakeFrom4Aos( &result->col3, &mat0->col3, &mat1->col3, &mat2->col3, &mat3->col3 ); +} + +static inline void vmathSoaM4Get4Aos( const VmathSoaMatrix4 *mat, VmathMatrix4 *result0, VmathMatrix4 *result1, VmathMatrix4 *result2, VmathMatrix4 *result3 ) +{ + vmathSoaV4Get4Aos( &mat->col0, &result0->col0, &result1->col0, &result2->col0, &result3->col0 ); + vmathSoaV4Get4Aos( &mat->col1, &result0->col1, &result1->col1, &result2->col1, &result3->col1 ); + vmathSoaV4Get4Aos( &mat->col2, &result0->col2, &result1->col2, &result2->col2, &result3->col2 ); + vmathSoaV4Get4Aos( &mat->col3, &result0->col3, &result1->col3, &result2->col3, &result3->col3 ); +} + +static inline void vmathSoaM4SetCol0( VmathSoaMatrix4 *result, const VmathSoaVector4 *_col0 ) +{ + vmathSoaV4Copy( &result->col0, _col0 ); +} + +static inline void vmathSoaM4SetCol1( VmathSoaMatrix4 *result, const VmathSoaVector4 *_col1 ) +{ + vmathSoaV4Copy( &result->col1, _col1 ); +} + +static inline void vmathSoaM4SetCol2( VmathSoaMatrix4 *result, const VmathSoaVector4 *_col2 ) +{ + vmathSoaV4Copy( &result->col2, _col2 ); +} + +static inline void vmathSoaM4SetCol3( VmathSoaMatrix4 *result, const VmathSoaVector4 *_col3 ) +{ + vmathSoaV4Copy( &result->col3, _col3 ); +} + +static inline void vmathSoaM4SetCol( VmathSoaMatrix4 *result, int col, const VmathSoaVector4 *vec ) +{ + vmathSoaV4Copy( (&result->col0 + col), vec ); +} + +static inline void vmathSoaM4SetRow( VmathSoaMatrix4 *result, int row, const VmathSoaVector4 *vec ) +{ + vmathSoaV4SetElem( &result->col0, row, vmathSoaV4GetElem( vec, 0 ) ); + vmathSoaV4SetElem( &result->col1, row, vmathSoaV4GetElem( vec, 1 ) ); + vmathSoaV4SetElem( &result->col2, row, vmathSoaV4GetElem( vec, 2 ) ); + vmathSoaV4SetElem( &result->col3, row, vmathSoaV4GetElem( vec, 3 ) ); +} + +static inline void vmathSoaM4SetElem( VmathSoaMatrix4 *result, int col, int row, vec_float4 val ) +{ + VmathSoaVector4 tmpV3_0; + vmathSoaM4GetCol( &tmpV3_0, result, col ); + vmathSoaV4SetElem( &tmpV3_0, row, val ); + vmathSoaM4SetCol( result, col, &tmpV3_0 ); +} + +static inline vec_float4 vmathSoaM4GetElem( const VmathSoaMatrix4 *mat, int col, int row ) +{ + VmathSoaVector4 tmpV4_0; + vmathSoaM4GetCol( &tmpV4_0, mat, col ); + return vmathSoaV4GetElem( &tmpV4_0, row ); +} + +static inline void vmathSoaM4GetCol0( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat ) +{ + vmathSoaV4Copy( result, &mat->col0 ); +} + +static inline void vmathSoaM4GetCol1( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat ) +{ + vmathSoaV4Copy( result, &mat->col1 ); +} + +static inline void vmathSoaM4GetCol2( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat ) +{ + vmathSoaV4Copy( result, &mat->col2 ); +} + +static inline void vmathSoaM4GetCol3( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat ) +{ + vmathSoaV4Copy( result, &mat->col3 ); +} + +static inline void vmathSoaM4GetCol( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, int col ) +{ + vmathSoaV4Copy( result, (&mat->col0 + col) ); +} + +static inline void vmathSoaM4GetRow( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, int row ) +{ + vmathSoaV4MakeFromElems( result, vmathSoaV4GetElem( &mat->col0, row ), vmathSoaV4GetElem( &mat->col1, row ), vmathSoaV4GetElem( &mat->col2, row ), vmathSoaV4GetElem( &mat->col3, row ) ); +} + +static inline void vmathSoaM4Transpose( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ) +{ + VmathSoaMatrix4 tmpResult; + vmathSoaV4MakeFromElems( &tmpResult.col0, mat->col0.x, mat->col1.x, mat->col2.x, mat->col3.x ); + vmathSoaV4MakeFromElems( &tmpResult.col1, mat->col0.y, mat->col1.y, mat->col2.y, mat->col3.y ); + vmathSoaV4MakeFromElems( &tmpResult.col2, mat->col0.z, mat->col1.z, mat->col2.z, mat->col3.z ); + vmathSoaV4MakeFromElems( &tmpResult.col3, mat->col0.w, mat->col1.w, mat->col2.w, mat->col3.w ); + vmathSoaM4Copy( result, &tmpResult ); +} + +static inline void vmathSoaM4Inverse( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ) +{ + VmathSoaVector4 res0, res1, res2, res3; + vec_float4 mA, mB, mC, mD, mE, mF, mG, mH, mI, mJ, mK, mL, mM, mN, mO, mP, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, detInv; + mA = mat->col0.x; + mB = mat->col0.y; + mC = mat->col0.z; + mD = mat->col0.w; + mE = mat->col1.x; + mF = mat->col1.y; + mG = mat->col1.z; + mH = mat->col1.w; + mI = mat->col2.x; + mJ = mat->col2.y; + mK = mat->col2.z; + mL = mat->col2.w; + mM = mat->col3.x; + mN = mat->col3.y; + mO = mat->col3.z; + mP = mat->col3.w; + tmp0 = vec_sub( vec_madd( mK, mD, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mC, mL, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmp1 = vec_sub( vec_madd( mO, mH, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mG, mP, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmp2 = vec_sub( vec_madd( mB, mK, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mJ, mC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmp3 = vec_sub( vec_madd( mF, mO, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mN, mG, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmp4 = vec_sub( vec_madd( mJ, mD, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mB, mL, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmp5 = vec_sub( vec_madd( mN, mH, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mF, mP, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + vmathSoaV4SetX( &res0, vec_sub( vec_sub( vec_madd( mJ, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mL, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mK, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ); + vmathSoaV4SetY( &res0, vec_sub( vec_sub( vec_madd( mN, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mP, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mO, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ); + vmathSoaV4SetZ( &res0, vec_sub( vec_add( vec_madd( mD, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mC, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mB, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ); + vmathSoaV4SetW( &res0, vec_sub( vec_add( vec_madd( mH, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mG, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mF, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ); + detInv = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec_add( vec_add( vec_add( vec_madd( mA, res0.x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mE, res0.y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mI, res0.z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mM, res0.w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ); + vmathSoaV4SetX( &res1, vec_madd( mI, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + vmathSoaV4SetY( &res1, vec_madd( mM, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + vmathSoaV4SetZ( &res1, vec_madd( mA, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + vmathSoaV4SetW( &res1, vec_madd( mE, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + vmathSoaV4SetX( &res3, vec_madd( mI, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + vmathSoaV4SetY( &res3, vec_madd( mM, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + vmathSoaV4SetZ( &res3, vec_madd( mA, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + vmathSoaV4SetW( &res3, vec_madd( mE, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + vmathSoaV4SetX( &res2, vec_madd( mI, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + vmathSoaV4SetY( &res2, vec_madd( mM, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + vmathSoaV4SetZ( &res2, vec_madd( mA, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + vmathSoaV4SetW( &res2, vec_madd( mE, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmp0 = vec_sub( vec_madd( mI, mB, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mA, mJ, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmp1 = vec_sub( vec_madd( mM, mF, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mE, mN, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmp2 = vec_sub( vec_madd( mI, mD, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mA, mL, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmp3 = vec_sub( vec_madd( mM, mH, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mE, mP, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmp4 = vec_sub( vec_madd( mI, mC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mA, mK, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmp5 = vec_sub( vec_madd( mM, mG, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mE, mO, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + vmathSoaV4SetX( &res2, vec_add( vec_sub( vec_madd( mL, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mJ, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res2.x ) ); + vmathSoaV4SetY( &res2, vec_add( vec_sub( vec_madd( mP, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mN, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res2.y ) ); + vmathSoaV4SetZ( &res2, vec_sub( vec_sub( vec_madd( mB, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mD, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res2.z ) ); + vmathSoaV4SetW( &res2, vec_sub( vec_sub( vec_madd( mF, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mH, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res2.w ) ); + vmathSoaV4SetX( &res3, vec_add( vec_sub( vec_madd( mJ, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mK, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res3.x ) ); + vmathSoaV4SetY( &res3, vec_add( vec_sub( vec_madd( mN, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mO, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res3.y ) ); + vmathSoaV4SetZ( &res3, vec_sub( vec_sub( vec_madd( mC, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mB, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res3.z ) ); + vmathSoaV4SetW( &res3, vec_sub( vec_sub( vec_madd( mG, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mF, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res3.w ) ); + vmathSoaV4SetX( &res1, vec_sub( vec_sub( vec_madd( mK, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mL, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res1.x ) ); + vmathSoaV4SetY( &res1, vec_sub( vec_sub( vec_madd( mO, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mP, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res1.y ) ); + vmathSoaV4SetZ( &res1, vec_add( vec_sub( vec_madd( mD, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mC, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res1.z ) ); + vmathSoaV4SetW( &res1, vec_add( vec_sub( vec_madd( mH, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mG, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res1.w ) ); + vmathSoaV4ScalarMul( &result->col0, &res0, detInv ); + vmathSoaV4ScalarMul( &result->col1, &res1, detInv ); + vmathSoaV4ScalarMul( &result->col2, &res2, detInv ); + vmathSoaV4ScalarMul( &result->col3, &res3, detInv ); +} + +static inline void vmathSoaM4AffineInverse( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ) +{ + VmathSoaTransform3 affineMat, tmpT3_0; + VmathSoaVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3; + vmathSoaV4GetXYZ( &tmpV3_0, &mat->col0 ); + vmathSoaT3SetCol0( &affineMat, &tmpV3_0 ); + vmathSoaV4GetXYZ( &tmpV3_1, &mat->col1 ); + vmathSoaT3SetCol1( &affineMat, &tmpV3_1 ); + vmathSoaV4GetXYZ( &tmpV3_2, &mat->col2 ); + vmathSoaT3SetCol2( &affineMat, &tmpV3_2 ); + vmathSoaV4GetXYZ( &tmpV3_3, &mat->col3 ); + vmathSoaT3SetCol3( &affineMat, &tmpV3_3 ); + vmathSoaT3Inverse( &tmpT3_0, &affineMat ); + vmathSoaM4MakeFromT3( result, &tmpT3_0 ); +} + +static inline void vmathSoaM4OrthoInverse( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ) +{ + VmathSoaTransform3 affineMat, tmpT3_0; + VmathSoaVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3; + vmathSoaV4GetXYZ( &tmpV3_0, &mat->col0 ); + vmathSoaT3SetCol0( &affineMat, &tmpV3_0 ); + vmathSoaV4GetXYZ( &tmpV3_1, &mat->col1 ); + vmathSoaT3SetCol1( &affineMat, &tmpV3_1 ); + vmathSoaV4GetXYZ( &tmpV3_2, &mat->col2 ); + vmathSoaT3SetCol2( &affineMat, &tmpV3_2 ); + vmathSoaV4GetXYZ( &tmpV3_3, &mat->col3 ); + vmathSoaT3SetCol3( &affineMat, &tmpV3_3 ); + vmathSoaT3OrthoInverse( &tmpT3_0, &affineMat ); + vmathSoaM4MakeFromT3( result, &tmpT3_0 ); +} + +static inline vec_float4 vmathSoaM4Determinant( const VmathSoaMatrix4 *mat ) +{ + vec_float4 dx, dy, dz, dw, mA, mB, mC, mD, mE, mF, mG, mH, mI, mJ, mK, mL, mM, mN, mO, mP, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; + mA = mat->col0.x; + mB = mat->col0.y; + mC = mat->col0.z; + mD = mat->col0.w; + mE = mat->col1.x; + mF = mat->col1.y; + mG = mat->col1.z; + mH = mat->col1.w; + mI = mat->col2.x; + mJ = mat->col2.y; + mK = mat->col2.z; + mL = mat->col2.w; + mM = mat->col3.x; + mN = mat->col3.y; + mO = mat->col3.z; + mP = mat->col3.w; + tmp0 = vec_sub( vec_madd( mK, mD, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mC, mL, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmp1 = vec_sub( vec_madd( mO, mH, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mG, mP, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmp2 = vec_sub( vec_madd( mB, mK, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mJ, mC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmp3 = vec_sub( vec_madd( mF, mO, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mN, mG, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmp4 = vec_sub( vec_madd( mJ, mD, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mB, mL, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmp5 = vec_sub( vec_madd( mN, mH, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mF, mP, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + dx = vec_sub( vec_sub( vec_madd( mJ, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mL, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mK, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + dy = vec_sub( vec_sub( vec_madd( mN, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mP, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mO, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + dz = vec_sub( vec_add( vec_madd( mD, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mC, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mB, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + dw = vec_sub( vec_add( vec_madd( mH, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mG, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mF, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + return vec_add( vec_add( vec_add( vec_madd( mA, dx, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mE, dy, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mI, dz, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mM, dw, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); +} + +static inline void vmathSoaM4Add( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1 ) +{ + vmathSoaV4Add( &result->col0, &mat0->col0, &mat1->col0 ); + vmathSoaV4Add( &result->col1, &mat0->col1, &mat1->col1 ); + vmathSoaV4Add( &result->col2, &mat0->col2, &mat1->col2 ); + vmathSoaV4Add( &result->col3, &mat0->col3, &mat1->col3 ); +} + +static inline void vmathSoaM4Sub( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1 ) +{ + vmathSoaV4Sub( &result->col0, &mat0->col0, &mat1->col0 ); + vmathSoaV4Sub( &result->col1, &mat0->col1, &mat1->col1 ); + vmathSoaV4Sub( &result->col2, &mat0->col2, &mat1->col2 ); + vmathSoaV4Sub( &result->col3, &mat0->col3, &mat1->col3 ); +} + +static inline void vmathSoaM4Neg( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ) +{ + vmathSoaV4Neg( &result->col0, &mat->col0 ); + vmathSoaV4Neg( &result->col1, &mat->col1 ); + vmathSoaV4Neg( &result->col2, &mat->col2 ); + vmathSoaV4Neg( &result->col3, &mat->col3 ); +} + +static inline void vmathSoaM4AbsPerElem( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ) +{ + vmathSoaV4AbsPerElem( &result->col0, &mat->col0 ); + vmathSoaV4AbsPerElem( &result->col1, &mat->col1 ); + vmathSoaV4AbsPerElem( &result->col2, &mat->col2 ); + vmathSoaV4AbsPerElem( &result->col3, &mat->col3 ); +} + +static inline void vmathSoaM4ScalarMul( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat, vec_float4 scalar ) +{ + vmathSoaV4ScalarMul( &result->col0, &mat->col0, scalar ); + vmathSoaV4ScalarMul( &result->col1, &mat->col1, scalar ); + vmathSoaV4ScalarMul( &result->col2, &mat->col2, scalar ); + vmathSoaV4ScalarMul( &result->col3, &mat->col3, scalar ); +} + +static inline void vmathSoaM4MulV4( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, const VmathSoaVector4 *vec ) +{ + vec_float4 tmpX, tmpY, tmpZ, tmpW; + tmpX = vec_add( vec_add( vec_add( vec_madd( mat->col0.x, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mat->col1.x, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col2.x, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col3.x, vec->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmpY = vec_add( vec_add( vec_add( vec_madd( mat->col0.y, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mat->col1.y, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col2.y, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col3.y, vec->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmpZ = vec_add( vec_add( vec_add( vec_madd( mat->col0.z, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mat->col1.z, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col2.z, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col3.z, vec->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmpW = vec_add( vec_add( vec_add( vec_madd( mat->col0.w, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mat->col1.w, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col2.w, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col3.w, vec->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + vmathSoaV4MakeFromElems( result, tmpX, tmpY, tmpZ, tmpW ); +} + +static inline void vmathSoaM4MulV3( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, const VmathSoaVector3 *vec ) +{ + result->x = vec_add( vec_add( vec_madd( mat->col0.x, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mat->col1.x, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col2.x, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + result->y = vec_add( vec_add( vec_madd( mat->col0.y, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mat->col1.y, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col2.y, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + result->z = vec_add( vec_add( vec_madd( mat->col0.z, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mat->col1.z, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col2.z, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + result->w = vec_add( vec_add( vec_madd( mat->col0.w, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mat->col1.w, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col2.w, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); +} + +static inline void vmathSoaM4MulP3( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, const VmathSoaPoint3 *pnt ) +{ + result->x = vec_add( vec_add( vec_add( vec_madd( mat->col0.x, pnt->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mat->col1.x, pnt->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col2.x, pnt->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), mat->col3.x ); + result->y = vec_add( vec_add( vec_add( vec_madd( mat->col0.y, pnt->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mat->col1.y, pnt->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col2.y, pnt->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), mat->col3.y ); + result->z = vec_add( vec_add( vec_add( vec_madd( mat->col0.z, pnt->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mat->col1.z, pnt->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col2.z, pnt->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), mat->col3.z ); + result->w = vec_add( vec_add( vec_add( vec_madd( mat->col0.w, pnt->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mat->col1.w, pnt->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col2.w, pnt->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), mat->col3.w ); +} + +static inline void vmathSoaM4Mul( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1 ) +{ + VmathSoaMatrix4 tmpResult; + vmathSoaM4MulV4( &tmpResult.col0, mat0, &mat1->col0 ); + vmathSoaM4MulV4( &tmpResult.col1, mat0, &mat1->col1 ); + vmathSoaM4MulV4( &tmpResult.col2, mat0, &mat1->col2 ); + vmathSoaM4MulV4( &tmpResult.col3, mat0, &mat1->col3 ); + vmathSoaM4Copy( result, &tmpResult ); +} + +static inline void vmathSoaM4MulT3( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat, const VmathSoaTransform3 *tfrm1 ) +{ + VmathSoaMatrix4 tmpResult; + VmathSoaPoint3 tmpP3_0; + vmathSoaM4MulV3( &tmpResult.col0, mat, &tfrm1->col0 ); + vmathSoaM4MulV3( &tmpResult.col1, mat, &tfrm1->col1 ); + vmathSoaM4MulV3( &tmpResult.col2, mat, &tfrm1->col2 ); + vmathSoaP3MakeFromV3( &tmpP3_0, &tfrm1->col3 ); + vmathSoaM4MulP3( &tmpResult.col3, mat, &tmpP3_0 ); + vmathSoaM4Copy( result, &tmpResult ); +} + +static inline void vmathSoaM4MulPerElem( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1 ) +{ + vmathSoaV4MulPerElem( &result->col0, &mat0->col0, &mat1->col0 ); + vmathSoaV4MulPerElem( &result->col1, &mat0->col1, &mat1->col1 ); + vmathSoaV4MulPerElem( &result->col2, &mat0->col2, &mat1->col2 ); + vmathSoaV4MulPerElem( &result->col3, &mat0->col3, &mat1->col3 ); +} + +static inline void vmathSoaM4MakeIdentity( VmathSoaMatrix4 *result ) +{ + vmathSoaV4MakeXAxis( &result->col0 ); + vmathSoaV4MakeYAxis( &result->col1 ); + vmathSoaV4MakeZAxis( &result->col2 ); + vmathSoaV4MakeWAxis( &result->col3 ); +} + +static inline void vmathSoaM4SetUpper3x3( VmathSoaMatrix4 *result, const VmathSoaMatrix3 *mat3 ) +{ + vmathSoaV4SetXYZ( &result->col0, &mat3->col0 ); + vmathSoaV4SetXYZ( &result->col1, &mat3->col1 ); + vmathSoaV4SetXYZ( &result->col2, &mat3->col2 ); +} + +static inline void vmathSoaM4GetUpper3x3( VmathSoaMatrix3 *result, const VmathSoaMatrix4 *mat ) +{ + vmathSoaV4GetXYZ( &result->col0, &mat->col0 ); + vmathSoaV4GetXYZ( &result->col1, &mat->col1 ); + vmathSoaV4GetXYZ( &result->col2, &mat->col2 ); +} + +static inline void vmathSoaM4SetTranslation( VmathSoaMatrix4 *result, const VmathSoaVector3 *translateVec ) +{ + vmathSoaV4SetXYZ( &result->col3, translateVec ); +} + +static inline void vmathSoaM4GetTranslation( VmathSoaVector3 *result, const VmathSoaMatrix4 *mat ) +{ + vmathSoaV4GetXYZ( result, &mat->col3 ); +} + +static inline void vmathSoaM4MakeRotationX( VmathSoaMatrix4 *result, vec_float4 radians ) +{ + vec_float4 s, c; + sincosf4( radians, &s, &c ); + vmathSoaV4MakeXAxis( &result->col0 ); + vmathSoaV4MakeFromElems( &result->col1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV4MakeFromElems( &result->col2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), negatef4( s ), c, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV4MakeWAxis( &result->col3 ); +} + +static inline void vmathSoaM4MakeRotationY( VmathSoaMatrix4 *result, vec_float4 radians ) +{ + vec_float4 s, c; + sincosf4( radians, &s, &c ); + vmathSoaV4MakeFromElems( &result->col0, c, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), negatef4( s ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV4MakeYAxis( &result->col1 ); + vmathSoaV4MakeFromElems( &result->col2, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV4MakeWAxis( &result->col3 ); +} + +static inline void vmathSoaM4MakeRotationZ( VmathSoaMatrix4 *result, vec_float4 radians ) +{ + vec_float4 s, c; + sincosf4( radians, &s, &c ); + vmathSoaV4MakeFromElems( &result->col0, c, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV4MakeFromElems( &result->col1, negatef4( s ), c, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV4MakeZAxis( &result->col2 ); + vmathSoaV4MakeWAxis( &result->col3 ); +} + +static inline void vmathSoaM4MakeRotationZYX( VmathSoaMatrix4 *result, const VmathSoaVector3 *radiansXYZ ) +{ + vec_float4 sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; + sincosf4( radiansXYZ->x, &sX, &cX ); + sincosf4( radiansXYZ->y, &sY, &cY ); + sincosf4( radiansXYZ->z, &sZ, &cZ ); + tmp0 = vec_madd( cZ, sY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + tmp1 = vec_madd( sZ, sY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV4MakeFromElems( &result->col0, vec_madd( cZ, cY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sZ, cY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), negatef4( sY ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV4MakeFromElems( &result->col1, vec_sub( vec_madd( tmp0, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sZ, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_add( vec_madd( tmp1, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( cZ, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( cY, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV4MakeFromElems( &result->col2, vec_add( vec_madd( tmp0, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sZ, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_sub( vec_madd( tmp1, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( cZ, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( cY, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV4MakeWAxis( &result->col3 ); +} + +static inline void vmathSoaM4MakeRotationAxis( VmathSoaMatrix4 *result, vec_float4 radians, const VmathSoaVector3 *unitVec ) +{ + vec_float4 x, y, z, s, c, oneMinusC, xy, yz, zx; + sincosf4( radians, &s, &c ); + x = unitVec->x; + y = unitVec->y; + z = unitVec->z; + xy = vec_madd( x, y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + yz = vec_madd( y, z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + zx = vec_madd( z, x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + oneMinusC = vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), c ); + vmathSoaV4MakeFromElems( &result->col0, vec_add( vec_madd( vec_madd( x, x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), c ), vec_add( vec_madd( xy, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( z, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_sub( vec_madd( zx, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( y, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV4MakeFromElems( &result->col1, vec_sub( vec_madd( xy, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( z, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_add( vec_madd( vec_madd( y, y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), c ), vec_add( vec_madd( yz, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( x, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV4MakeFromElems( &result->col2, vec_add( vec_madd( zx, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( y, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_sub( vec_madd( yz, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( x, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_add( vec_madd( vec_madd( z, z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), c ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV4MakeWAxis( &result->col3 ); +} + +static inline void vmathSoaM4MakeRotationQ( VmathSoaMatrix4 *result, const VmathSoaQuat *unitQuat ) +{ + VmathSoaTransform3 tmpT3_0; + vmathSoaT3MakeRotationQ( &tmpT3_0, unitQuat ); + vmathSoaM4MakeFromT3( result, &tmpT3_0 ); +} + +static inline void vmathSoaM4MakeScale( VmathSoaMatrix4 *result, const VmathSoaVector3 *scaleVec ) +{ + vmathSoaV4MakeFromElems( &result->col0, scaleVec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV4MakeFromElems( &result->col1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), scaleVec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV4MakeFromElems( &result->col2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), scaleVec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV4MakeWAxis( &result->col3 ); +} + +static inline void vmathSoaM4AppendScale( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat, const VmathSoaVector3 *scaleVec ) +{ + vmathSoaV4ScalarMul( &result->col0, &mat->col0, vmathSoaV3GetX( scaleVec ) ); + vmathSoaV4ScalarMul( &result->col1, &mat->col1, vmathSoaV3GetY( scaleVec ) ); + vmathSoaV4ScalarMul( &result->col2, &mat->col2, vmathSoaV3GetZ( scaleVec ) ); + vmathSoaV4Copy( &result->col3, &mat->col3 ); +} + +static inline void vmathSoaM4PrependScale( VmathSoaMatrix4 *result, const VmathSoaVector3 *scaleVec, const VmathSoaMatrix4 *mat ) +{ + VmathSoaVector4 scale4; + vmathSoaV4MakeFromV3Scalar( &scale4, scaleVec, ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); + vmathSoaV4MulPerElem( &result->col0, &mat->col0, &scale4 ); + vmathSoaV4MulPerElem( &result->col1, &mat->col1, &scale4 ); + vmathSoaV4MulPerElem( &result->col2, &mat->col2, &scale4 ); + vmathSoaV4MulPerElem( &result->col3, &mat->col3, &scale4 ); +} + +static inline void vmathSoaM4MakeTranslation( VmathSoaMatrix4 *result, const VmathSoaVector3 *translateVec ) +{ + vmathSoaV4MakeXAxis( &result->col0 ); + vmathSoaV4MakeYAxis( &result->col1 ); + vmathSoaV4MakeZAxis( &result->col2 ); + vmathSoaV4MakeFromV3Scalar( &result->col3, translateVec, ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); +} + +static inline void vmathSoaM4MakeLookAt( VmathSoaMatrix4 *result, const VmathSoaPoint3 *eyePos, const VmathSoaPoint3 *lookAtPos, const VmathSoaVector3 *upVec ) +{ + VmathSoaMatrix4 m4EyeFrame; + VmathSoaVector3 v3X, v3Y, v3Z, tmpV3_0, tmpV3_1; + VmathSoaVector4 tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3; + vmathSoaV3Normalize( &v3Y, upVec ); + vmathSoaP3Sub( &tmpV3_0, eyePos, lookAtPos ); + vmathSoaV3Normalize( &v3Z, &tmpV3_0 ); + vmathSoaV3Cross( &tmpV3_1, &v3Y, &v3Z ); + vmathSoaV3Normalize( &v3X, &tmpV3_1 ); + vmathSoaV3Cross( &v3Y, &v3Z, &v3X ); + vmathSoaV4MakeFromV3( &tmpV4_0, &v3X ); + vmathSoaV4MakeFromV3( &tmpV4_1, &v3Y ); + vmathSoaV4MakeFromV3( &tmpV4_2, &v3Z ); + vmathSoaV4MakeFromP3( &tmpV4_3, eyePos ); + vmathSoaM4MakeFromCols( &m4EyeFrame, &tmpV4_0, &tmpV4_1, &tmpV4_2, &tmpV4_3 ); + vmathSoaM4OrthoInverse( result, &m4EyeFrame ); +} + +static inline void vmathSoaM4MakePerspective( VmathSoaMatrix4 *result, vec_float4 fovyRadians, vec_float4 aspect, vec_float4 zNear, vec_float4 zFar ) +{ + vec_float4 f, rangeInv; + f = tanf4( vec_sub( ((vec_float4){_VECTORMATH_PI_OVER_2,_VECTORMATH_PI_OVER_2,_VECTORMATH_PI_OVER_2,_VECTORMATH_PI_OVER_2}), vec_madd( ((vec_float4){0.5f,0.5f,0.5f,0.5f}), fovyRadians, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ); + rangeInv = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec_sub( zNear, zFar ) ); + vmathSoaV4MakeFromElems( &result->col0, divf4( f, aspect ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV4MakeFromElems( &result->col1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), f, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV4MakeFromElems( &result->col2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), vec_madd( vec_add( zNear, zFar ), rangeInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){-1.0f,-1.0f,-1.0f,-1.0f}) ); + vmathSoaV4MakeFromElems( &result->col3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), vec_madd( vec_madd( vec_madd( zNear, zFar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), rangeInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){2.0f,2.0f,2.0f,2.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); +} + +static inline void vmathSoaM4MakeFrustum( VmathSoaMatrix4 *result, vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ) +{ + vec_float4 sum_rl, sum_tb, sum_nf, inv_rl, inv_tb, inv_nf, n2; + sum_rl = vec_add( right, left ); + sum_tb = vec_add( top, bottom ); + sum_nf = vec_add( zNear, zFar ); + inv_rl = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec_sub( right, left ) ); + inv_tb = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec_sub( top, bottom ) ); + inv_nf = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec_sub( zNear, zFar ) ); + n2 = vec_add( zNear, zNear ); + vmathSoaV4MakeFromElems( &result->col0, vec_madd( n2, inv_rl, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV4MakeFromElems( &result->col1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), vec_madd( n2, inv_tb, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV4MakeFromElems( &result->col2, vec_madd( sum_rl, inv_rl, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sum_tb, inv_tb, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sum_nf, inv_nf, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){-1.0f,-1.0f,-1.0f,-1.0f}) ); + vmathSoaV4MakeFromElems( &result->col3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), vec_madd( vec_madd( n2, inv_nf, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), zFar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); +} + +static inline void vmathSoaM4MakeOrthographic( VmathSoaMatrix4 *result, vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ) +{ + vec_float4 sum_rl, sum_tb, sum_nf, inv_rl, inv_tb, inv_nf; + sum_rl = vec_add( right, left ); + sum_tb = vec_add( top, bottom ); + sum_nf = vec_add( zNear, zFar ); + inv_rl = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec_sub( right, left ) ); + inv_tb = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec_sub( top, bottom ) ); + inv_nf = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec_sub( zNear, zFar ) ); + vmathSoaV4MakeFromElems( &result->col0, vec_add( inv_rl, inv_rl ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV4MakeFromElems( &result->col1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), vec_add( inv_tb, inv_tb ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV4MakeFromElems( &result->col2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), vec_add( inv_nf, inv_nf ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV4MakeFromElems( &result->col3, vec_madd( negatef4( sum_rl ), inv_rl, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( negatef4( sum_tb ), inv_tb, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sum_nf, inv_nf, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); +} + +static inline void vmathSoaM4Select( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1, vec_uint4 select1 ) +{ + vmathSoaV4Select( &result->col0, &mat0->col0, &mat1->col0, select1 ); + vmathSoaV4Select( &result->col1, &mat0->col1, &mat1->col1, select1 ); + vmathSoaV4Select( &result->col2, &mat0->col2, &mat1->col2, select1 ); + vmathSoaV4Select( &result->col3, &mat0->col3, &mat1->col3, select1 ); +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathSoaM4Print( const VmathSoaMatrix4 *mat ) +{ + VmathMatrix4 mat0, mat1, mat2, mat3; + vmathSoaM4Get4Aos( mat, &mat0, &mat1, &mat2, &mat3 ); + printf("slot 0:\n"); + vmathM4Print( &mat0 ); + printf("slot 1:\n"); + vmathM4Print( &mat1 ); + printf("slot 2:\n"); + vmathM4Print( &mat2 ); + printf("slot 3:\n"); + vmathM4Print( &mat3 ); +} + +static inline void vmathSoaM4Prints( const VmathSoaMatrix4 *mat, const char *name ) +{ + printf("%s:\n", name); + vmathSoaM4Print( mat ); +} + +#endif + +static inline void vmathSoaT3Copy( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm ) +{ + vmathSoaV3Copy( &result->col0, &tfrm->col0 ); + vmathSoaV3Copy( &result->col1, &tfrm->col1 ); + vmathSoaV3Copy( &result->col2, &tfrm->col2 ); + vmathSoaV3Copy( &result->col3, &tfrm->col3 ); +} + +static inline void vmathSoaT3MakeFromScalar( VmathSoaTransform3 *result, vec_float4 scalar ) +{ + vmathSoaV3MakeFromScalar( &result->col0, scalar ); + vmathSoaV3MakeFromScalar( &result->col1, scalar ); + vmathSoaV3MakeFromScalar( &result->col2, scalar ); + vmathSoaV3MakeFromScalar( &result->col3, scalar ); +} + +static inline void vmathSoaT3MakeFromCols( VmathSoaTransform3 *result, const VmathSoaVector3 *_col0, const VmathSoaVector3 *_col1, const VmathSoaVector3 *_col2, const VmathSoaVector3 *_col3 ) +{ + vmathSoaV3Copy( &result->col0, _col0 ); + vmathSoaV3Copy( &result->col1, _col1 ); + vmathSoaV3Copy( &result->col2, _col2 ); + vmathSoaV3Copy( &result->col3, _col3 ); +} + +static inline void vmathSoaT3MakeFromM3V3( VmathSoaTransform3 *result, const VmathSoaMatrix3 *tfrm, const VmathSoaVector3 *translateVec ) +{ + vmathSoaT3SetUpper3x3( result, tfrm ); + vmathSoaT3SetTranslation( result, translateVec ); +} + +static inline void vmathSoaT3MakeFromQV3( VmathSoaTransform3 *result, const VmathSoaQuat *unitQuat, const VmathSoaVector3 *translateVec ) +{ + VmathSoaMatrix3 tmpM3_0; + vmathSoaM3MakeFromQ( &tmpM3_0, unitQuat ); + vmathSoaT3SetUpper3x3( result, &tmpM3_0 ); + vmathSoaT3SetTranslation( result, translateVec ); +} + +static inline void vmathSoaT3MakeFromAos( VmathSoaTransform3 *result, const VmathTransform3 *tfrm ) +{ + vmathSoaV3MakeFromAos( &result->col0, &tfrm->col0 ); + vmathSoaV3MakeFromAos( &result->col1, &tfrm->col1 ); + vmathSoaV3MakeFromAos( &result->col2, &tfrm->col2 ); + vmathSoaV3MakeFromAos( &result->col3, &tfrm->col3 ); +} + +static inline void vmathSoaT3MakeFrom4Aos( VmathSoaTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1, const VmathTransform3 *tfrm2, const VmathTransform3 *tfrm3 ) +{ + vmathSoaV3MakeFrom4Aos( &result->col0, &tfrm0->col0, &tfrm1->col0, &tfrm2->col0, &tfrm3->col0 ); + vmathSoaV3MakeFrom4Aos( &result->col1, &tfrm0->col1, &tfrm1->col1, &tfrm2->col1, &tfrm3->col1 ); + vmathSoaV3MakeFrom4Aos( &result->col2, &tfrm0->col2, &tfrm1->col2, &tfrm2->col2, &tfrm3->col2 ); + vmathSoaV3MakeFrom4Aos( &result->col3, &tfrm0->col3, &tfrm1->col3, &tfrm2->col3, &tfrm3->col3 ); +} + +static inline void vmathSoaT3Get4Aos( const VmathSoaTransform3 *tfrm, VmathTransform3 *result0, VmathTransform3 *result1, VmathTransform3 *result2, VmathTransform3 *result3 ) +{ + vmathSoaV3Get4Aos( &tfrm->col0, &result0->col0, &result1->col0, &result2->col0, &result3->col0 ); + vmathSoaV3Get4Aos( &tfrm->col1, &result0->col1, &result1->col1, &result2->col1, &result3->col1 ); + vmathSoaV3Get4Aos( &tfrm->col2, &result0->col2, &result1->col2, &result2->col2, &result3->col2 ); + vmathSoaV3Get4Aos( &tfrm->col3, &result0->col3, &result1->col3, &result2->col3, &result3->col3 ); +} + +static inline void vmathSoaT3SetCol0( VmathSoaTransform3 *result, const VmathSoaVector3 *_col0 ) +{ + vmathSoaV3Copy( &result->col0, _col0 ); +} + +static inline void vmathSoaT3SetCol1( VmathSoaTransform3 *result, const VmathSoaVector3 *_col1 ) +{ + vmathSoaV3Copy( &result->col1, _col1 ); +} + +static inline void vmathSoaT3SetCol2( VmathSoaTransform3 *result, const VmathSoaVector3 *_col2 ) +{ + vmathSoaV3Copy( &result->col2, _col2 ); +} + +static inline void vmathSoaT3SetCol3( VmathSoaTransform3 *result, const VmathSoaVector3 *_col3 ) +{ + vmathSoaV3Copy( &result->col3, _col3 ); +} + +static inline void vmathSoaT3SetCol( VmathSoaTransform3 *result, int col, const VmathSoaVector3 *vec ) +{ + vmathSoaV3Copy( (&result->col0 + col), vec ); +} + +static inline void vmathSoaT3SetRow( VmathSoaTransform3 *result, int row, const VmathSoaVector4 *vec ) +{ + vmathSoaV3SetElem( &result->col0, row, vmathSoaV4GetElem( vec, 0 ) ); + vmathSoaV3SetElem( &result->col1, row, vmathSoaV4GetElem( vec, 1 ) ); + vmathSoaV3SetElem( &result->col2, row, vmathSoaV4GetElem( vec, 2 ) ); + vmathSoaV3SetElem( &result->col3, row, vmathSoaV4GetElem( vec, 3 ) ); +} + +static inline void vmathSoaT3SetElem( VmathSoaTransform3 *result, int col, int row, vec_float4 val ) +{ + VmathSoaVector3 tmpV3_0; + vmathSoaT3GetCol( &tmpV3_0, result, col ); + vmathSoaV3SetElem( &tmpV3_0, row, val ); + vmathSoaT3SetCol( result, col, &tmpV3_0 ); +} + +static inline vec_float4 vmathSoaT3GetElem( const VmathSoaTransform3 *tfrm, int col, int row ) +{ + VmathSoaVector3 tmpV3_0; + vmathSoaT3GetCol( &tmpV3_0, tfrm, col ); + return vmathSoaV3GetElem( &tmpV3_0, row ); +} + +static inline void vmathSoaT3GetCol0( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ) +{ + vmathSoaV3Copy( result, &tfrm->col0 ); +} + +static inline void vmathSoaT3GetCol1( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ) +{ + vmathSoaV3Copy( result, &tfrm->col1 ); +} + +static inline void vmathSoaT3GetCol2( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ) +{ + vmathSoaV3Copy( result, &tfrm->col2 ); +} + +static inline void vmathSoaT3GetCol3( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ) +{ + vmathSoaV3Copy( result, &tfrm->col3 ); +} + +static inline void vmathSoaT3GetCol( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm, int col ) +{ + vmathSoaV3Copy( result, (&tfrm->col0 + col) ); +} + +static inline void vmathSoaT3GetRow( VmathSoaVector4 *result, const VmathSoaTransform3 *tfrm, int row ) +{ + vmathSoaV4MakeFromElems( result, vmathSoaV3GetElem( &tfrm->col0, row ), vmathSoaV3GetElem( &tfrm->col1, row ), vmathSoaV3GetElem( &tfrm->col2, row ), vmathSoaV3GetElem( &tfrm->col3, row ) ); +} + +static inline void vmathSoaT3Inverse( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm ) +{ + VmathSoaVector3 tmp0, tmp1, tmp2, inv0, inv1, inv2, tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5; + vec_float4 detinv; + vmathSoaV3Cross( &tmp0, &tfrm->col1, &tfrm->col2 ); + vmathSoaV3Cross( &tmp1, &tfrm->col2, &tfrm->col0 ); + vmathSoaV3Cross( &tmp2, &tfrm->col0, &tfrm->col1 ); + detinv = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vmathSoaV3Dot( &tfrm->col2, &tmp2 ) ); + vmathSoaV3MakeFromElems( &inv0, vec_madd( tmp0.x, detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp1.x, detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp2.x, detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + vmathSoaV3MakeFromElems( &inv1, vec_madd( tmp0.y, detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp1.y, detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp2.y, detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + vmathSoaV3MakeFromElems( &inv2, vec_madd( tmp0.z, detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp1.z, detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp2.z, detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + vmathSoaV3Copy( &result->col0, &inv0 ); + vmathSoaV3Copy( &result->col1, &inv1 ); + vmathSoaV3Copy( &result->col2, &inv2 ); + vmathSoaV3ScalarMul( &tmpV3_0, &inv0, tfrm->col3.x ); + vmathSoaV3ScalarMul( &tmpV3_1, &inv1, tfrm->col3.y ); + vmathSoaV3ScalarMul( &tmpV3_2, &inv2, tfrm->col3.z ); + vmathSoaV3Add( &tmpV3_3, &tmpV3_1, &tmpV3_2 ); + vmathSoaV3Add( &tmpV3_4, &tmpV3_0, &tmpV3_3 ); + vmathSoaV3Neg( &tmpV3_5, &tmpV3_4 ); + vmathSoaV3Copy( &result->col3, &tmpV3_5 ); +} + +static inline void vmathSoaT3OrthoInverse( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm ) +{ + VmathSoaVector3 inv0, inv1, inv2, tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5; + vmathSoaV3MakeFromElems( &inv0, tfrm->col0.x, tfrm->col1.x, tfrm->col2.x ); + vmathSoaV3MakeFromElems( &inv1, tfrm->col0.y, tfrm->col1.y, tfrm->col2.y ); + vmathSoaV3MakeFromElems( &inv2, tfrm->col0.z, tfrm->col1.z, tfrm->col2.z ); + vmathSoaV3Copy( &result->col0, &inv0 ); + vmathSoaV3Copy( &result->col1, &inv1 ); + vmathSoaV3Copy( &result->col2, &inv2 ); + vmathSoaV3ScalarMul( &tmpV3_0, &inv0, tfrm->col3.x ); + vmathSoaV3ScalarMul( &tmpV3_1, &inv1, tfrm->col3.y ); + vmathSoaV3ScalarMul( &tmpV3_2, &inv2, tfrm->col3.z ); + vmathSoaV3Add( &tmpV3_3, &tmpV3_1, &tmpV3_2 ); + vmathSoaV3Add( &tmpV3_4, &tmpV3_0, &tmpV3_3 ); + vmathSoaV3Neg( &tmpV3_5, &tmpV3_4 ); + vmathSoaV3Copy( &result->col3, &tmpV3_5 ); +} + +static inline void vmathSoaT3AbsPerElem( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm ) +{ + vmathSoaV3AbsPerElem( &result->col0, &tfrm->col0 ); + vmathSoaV3AbsPerElem( &result->col1, &tfrm->col1 ); + vmathSoaV3AbsPerElem( &result->col2, &tfrm->col2 ); + vmathSoaV3AbsPerElem( &result->col3, &tfrm->col3 ); +} + +static inline void vmathSoaT3MulV3( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm, const VmathSoaVector3 *vec ) +{ + vec_float4 tmpX, tmpY, tmpZ; + tmpX = vec_add( vec_add( vec_madd( tfrm->col0.x, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tfrm->col1.x, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tfrm->col2.x, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmpY = vec_add( vec_add( vec_madd( tfrm->col0.y, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tfrm->col1.y, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tfrm->col2.y, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmpZ = vec_add( vec_add( vec_madd( tfrm->col0.z, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tfrm->col1.z, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tfrm->col2.z, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + vmathSoaV3MakeFromElems( result, tmpX, tmpY, tmpZ ); +} + +static inline void vmathSoaT3MulP3( VmathSoaPoint3 *result, const VmathSoaTransform3 *tfrm, const VmathSoaPoint3 *pnt ) +{ + vec_float4 tmpX, tmpY, tmpZ; + tmpX = vec_add( vec_add( vec_add( vec_madd( tfrm->col0.x, pnt->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tfrm->col1.x, pnt->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tfrm->col2.x, pnt->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), tfrm->col3.x ); + tmpY = vec_add( vec_add( vec_add( vec_madd( tfrm->col0.y, pnt->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tfrm->col1.y, pnt->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tfrm->col2.y, pnt->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), tfrm->col3.y ); + tmpZ = vec_add( vec_add( vec_add( vec_madd( tfrm->col0.z, pnt->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tfrm->col1.z, pnt->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tfrm->col2.z, pnt->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), tfrm->col3.z ); + vmathSoaP3MakeFromElems( result, tmpX, tmpY, tmpZ ); +} + +static inline void vmathSoaT3Mul( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm0, const VmathSoaTransform3 *tfrm1 ) +{ + VmathSoaTransform3 tmpResult; + VmathSoaPoint3 tmpP3_0, tmpP3_1; + vmathSoaT3MulV3( &tmpResult.col0, tfrm0, &tfrm1->col0 ); + vmathSoaT3MulV3( &tmpResult.col1, tfrm0, &tfrm1->col1 ); + vmathSoaT3MulV3( &tmpResult.col2, tfrm0, &tfrm1->col2 ); + vmathSoaP3MakeFromV3( &tmpP3_0, &tfrm1->col3 ); + vmathSoaT3MulP3( &tmpP3_1, tfrm0, &tmpP3_0 ); + vmathSoaV3MakeFromP3( &tmpResult.col3, &tmpP3_1 ); + vmathSoaT3Copy( result, &tmpResult ); +} + +static inline void vmathSoaT3MulPerElem( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm0, const VmathSoaTransform3 *tfrm1 ) +{ + vmathSoaV3MulPerElem( &result->col0, &tfrm0->col0, &tfrm1->col0 ); + vmathSoaV3MulPerElem( &result->col1, &tfrm0->col1, &tfrm1->col1 ); + vmathSoaV3MulPerElem( &result->col2, &tfrm0->col2, &tfrm1->col2 ); + vmathSoaV3MulPerElem( &result->col3, &tfrm0->col3, &tfrm1->col3 ); +} + +static inline void vmathSoaT3MakeIdentity( VmathSoaTransform3 *result ) +{ + vmathSoaV3MakeXAxis( &result->col0 ); + vmathSoaV3MakeYAxis( &result->col1 ); + vmathSoaV3MakeZAxis( &result->col2 ); + vmathSoaV3MakeFromScalar( &result->col3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); +} + +static inline void vmathSoaT3SetUpper3x3( VmathSoaTransform3 *result, const VmathSoaMatrix3 *tfrm ) +{ + vmathSoaV3Copy( &result->col0, &tfrm->col0 ); + vmathSoaV3Copy( &result->col1, &tfrm->col1 ); + vmathSoaV3Copy( &result->col2, &tfrm->col2 ); +} + +static inline void vmathSoaT3GetUpper3x3( VmathSoaMatrix3 *result, const VmathSoaTransform3 *tfrm ) +{ + vmathSoaM3MakeFromCols( result, &tfrm->col0, &tfrm->col1, &tfrm->col2 ); +} + +static inline void vmathSoaT3SetTranslation( VmathSoaTransform3 *result, const VmathSoaVector3 *translateVec ) +{ + vmathSoaV3Copy( &result->col3, translateVec ); +} + +static inline void vmathSoaT3GetTranslation( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ) +{ + vmathSoaV3Copy( result, &tfrm->col3 ); +} + +static inline void vmathSoaT3MakeRotationX( VmathSoaTransform3 *result, vec_float4 radians ) +{ + vec_float4 s, c; + sincosf4( radians, &s, &c ); + vmathSoaV3MakeXAxis( &result->col0 ); + vmathSoaV3MakeFromElems( &result->col1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c, s ); + vmathSoaV3MakeFromElems( &result->col2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), negatef4( s ), c ); + vmathSoaV3MakeFromScalar( &result->col3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); +} + +static inline void vmathSoaT3MakeRotationY( VmathSoaTransform3 *result, vec_float4 radians ) +{ + vec_float4 s, c; + sincosf4( radians, &s, &c ); + vmathSoaV3MakeFromElems( &result->col0, c, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), negatef4( s ) ); + vmathSoaV3MakeYAxis( &result->col1 ); + vmathSoaV3MakeFromElems( &result->col2, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c ); + vmathSoaV3MakeFromScalar( &result->col3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); +} + +static inline void vmathSoaT3MakeRotationZ( VmathSoaTransform3 *result, vec_float4 radians ) +{ + vec_float4 s, c; + sincosf4( radians, &s, &c ); + vmathSoaV3MakeFromElems( &result->col0, c, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV3MakeFromElems( &result->col1, negatef4( s ), c, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV3MakeZAxis( &result->col2 ); + vmathSoaV3MakeFromScalar( &result->col3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); +} + +static inline void vmathSoaT3MakeRotationZYX( VmathSoaTransform3 *result, const VmathSoaVector3 *radiansXYZ ) +{ + vec_float4 sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; + sincosf4( radiansXYZ->x, &sX, &cX ); + sincosf4( radiansXYZ->y, &sY, &cY ); + sincosf4( radiansXYZ->z, &sZ, &cZ ); + tmp0 = vec_madd( cZ, sY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + tmp1 = vec_madd( sZ, sY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV3MakeFromElems( &result->col0, vec_madd( cZ, cY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sZ, cY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), negatef4( sY ) ); + vmathSoaV3MakeFromElems( &result->col1, vec_sub( vec_madd( tmp0, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sZ, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_add( vec_madd( tmp1, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( cZ, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( cY, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + vmathSoaV3MakeFromElems( &result->col2, vec_add( vec_madd( tmp0, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sZ, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_sub( vec_madd( tmp1, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( cZ, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( cY, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + vmathSoaV3MakeFromScalar( &result->col3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); +} + +static inline void vmathSoaT3MakeRotationAxis( VmathSoaTransform3 *result, vec_float4 radians, const VmathSoaVector3 *unitVec ) +{ + VmathSoaMatrix3 tmpM3_0; + VmathSoaVector3 tmpV3_0; + vmathSoaM3MakeRotationAxis( &tmpM3_0, radians, unitVec ); + vmathSoaV3MakeFromScalar( &tmpV3_0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaT3MakeFromM3V3( result, &tmpM3_0, &tmpV3_0 ); +} + +static inline void vmathSoaT3MakeRotationQ( VmathSoaTransform3 *result, const VmathSoaQuat *unitQuat ) +{ + VmathSoaMatrix3 tmpM3_0; + VmathSoaVector3 tmpV3_0; + vmathSoaM3MakeFromQ( &tmpM3_0, unitQuat ); + vmathSoaV3MakeFromScalar( &tmpV3_0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaT3MakeFromM3V3( result, &tmpM3_0, &tmpV3_0 ); +} + +static inline void vmathSoaT3MakeScale( VmathSoaTransform3 *result, const VmathSoaVector3 *scaleVec ) +{ + vmathSoaV3MakeFromElems( &result->col0, scaleVec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV3MakeFromElems( &result->col1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), scaleVec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathSoaV3MakeFromElems( &result->col2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), scaleVec->z ); + vmathSoaV3MakeFromScalar( &result->col3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); +} + +static inline void vmathSoaT3AppendScale( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm, const VmathSoaVector3 *scaleVec ) +{ + vmathSoaV3ScalarMul( &result->col0, &tfrm->col0, vmathSoaV3GetX( scaleVec ) ); + vmathSoaV3ScalarMul( &result->col1, &tfrm->col1, vmathSoaV3GetY( scaleVec ) ); + vmathSoaV3ScalarMul( &result->col2, &tfrm->col2, vmathSoaV3GetZ( scaleVec ) ); + vmathSoaV3Copy( &result->col3, &tfrm->col3 ); +} + +static inline void vmathSoaT3PrependScale( VmathSoaTransform3 *result, const VmathSoaVector3 *scaleVec, const VmathSoaTransform3 *tfrm ) +{ + vmathSoaV3MulPerElem( &result->col0, &tfrm->col0, scaleVec ); + vmathSoaV3MulPerElem( &result->col1, &tfrm->col1, scaleVec ); + vmathSoaV3MulPerElem( &result->col2, &tfrm->col2, scaleVec ); + vmathSoaV3MulPerElem( &result->col3, &tfrm->col3, scaleVec ); +} + +static inline void vmathSoaT3MakeTranslation( VmathSoaTransform3 *result, const VmathSoaVector3 *translateVec ) +{ + vmathSoaV3MakeXAxis( &result->col0 ); + vmathSoaV3MakeYAxis( &result->col1 ); + vmathSoaV3MakeZAxis( &result->col2 ); + vmathSoaV3Copy( &result->col3, translateVec ); +} + +static inline void vmathSoaT3Select( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm0, const VmathSoaTransform3 *tfrm1, vec_uint4 select1 ) +{ + vmathSoaV3Select( &result->col0, &tfrm0->col0, &tfrm1->col0, select1 ); + vmathSoaV3Select( &result->col1, &tfrm0->col1, &tfrm1->col1, select1 ); + vmathSoaV3Select( &result->col2, &tfrm0->col2, &tfrm1->col2, select1 ); + vmathSoaV3Select( &result->col3, &tfrm0->col3, &tfrm1->col3, select1 ); +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathSoaT3Print( const VmathSoaTransform3 *tfrm ) +{ + VmathTransform3 mat0, mat1, mat2, mat3; + vmathSoaT3Get4Aos( tfrm, &mat0, &mat1, &mat2, &mat3 ); + printf("slot 0:\n"); + vmathT3Print( &mat0 ); + printf("slot 1:\n"); + vmathT3Print( &mat1 ); + printf("slot 2:\n"); + vmathT3Print( &mat2 ); + printf("slot 3:\n"); + vmathT3Print( &mat3 ); +} + +static inline void vmathSoaT3Prints( const VmathSoaTransform3 *tfrm, const char *name ) +{ + printf("%s:\n", name); + vmathSoaT3Print( tfrm ); +} + +#endif + +static inline void vmathSoaQMakeFromM3( VmathSoaQuat *result, const VmathSoaMatrix3 *tfrm ) +{ + vec_float4 trace, radicand, scale, xx, yx, zx, xy, yy, zy, xz, yz, zz, tmpx, tmpy, tmpz, tmpw, qx, qy, qz, qw; + vec_uint4 negTrace, ZgtX, ZgtY, YgtX; + vec_uint4 largestXorY, largestYorZ, largestZorX; + + xx = tfrm->col0.x; + yx = tfrm->col0.y; + zx = tfrm->col0.z; + xy = tfrm->col1.x; + yy = tfrm->col1.y; + zy = tfrm->col1.z; + xz = tfrm->col2.x; + yz = tfrm->col2.y; + zz = tfrm->col2.z; + + trace = vec_add( vec_add( xx, yy ), zz ); + + negTrace = (vec_uint4)vec_cmpgt( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), trace ); + ZgtX = (vec_uint4)vec_cmpgt( zz, xx ); + ZgtY = (vec_uint4)vec_cmpgt( zz, yy ); + YgtX = (vec_uint4)vec_cmpgt( yy, xx ); + largestXorY = vec_andc( negTrace, vec_and( ZgtX, ZgtY ) ); + largestYorZ = vec_and( negTrace, vec_or( YgtX, ZgtX ) ); + largestZorX = vec_andc( negTrace, vec_andc( YgtX, ZgtY ) ); + + zz = vec_sel( zz, negatef4(zz), largestXorY ); + xy = vec_sel( xy, negatef4(xy), largestXorY ); + xx = vec_sel( xx, negatef4(xx), largestYorZ ); + yz = vec_sel( yz, negatef4(yz), largestYorZ ); + yy = vec_sel( yy, negatef4(yy), largestZorX ); + zx = vec_sel( zx, negatef4(zx), largestZorX ); + + radicand = vec_add( vec_add( vec_add( xx, yy ), zz ), ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); + scale = vec_madd( ((vec_float4){0.5f,0.5f,0.5f,0.5f}), divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( radicand ) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + + tmpx = vec_madd( vec_sub( zy, yz ), scale, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + tmpy = vec_madd( vec_sub( xz, zx ), scale, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + tmpz = vec_madd( vec_sub( yx, xy ), scale, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + tmpw = vec_madd( radicand, scale, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + qx = tmpx; + qy = tmpy; + qz = tmpz; + qw = tmpw; + + qx = vec_sel( qx, tmpw, largestXorY ); + qy = vec_sel( qy, tmpz, largestXorY ); + qz = vec_sel( qz, tmpy, largestXorY ); + qw = vec_sel( qw, tmpx, largestXorY ); + tmpx = qx; + tmpz = qz; + qx = vec_sel( qx, qy, largestYorZ ); + qy = vec_sel( qy, tmpx, largestYorZ ); + qz = vec_sel( qz, qw, largestYorZ ); + qw = vec_sel( qw, tmpz, largestYorZ ); + + result->x = qx; + result->y = qy; + result->z = qz; + result->w = qw; +} + +static inline void vmathSoaV3Outer( VmathSoaMatrix3 *result, const VmathSoaVector3 *tfrm0, const VmathSoaVector3 *tfrm1 ) +{ + vmathSoaV3ScalarMul( &result->col0, tfrm0, vmathSoaV3GetX( tfrm1 ) ); + vmathSoaV3ScalarMul( &result->col1, tfrm0, vmathSoaV3GetY( tfrm1 ) ); + vmathSoaV3ScalarMul( &result->col2, tfrm0, vmathSoaV3GetZ( tfrm1 ) ); +} + +static inline void vmathSoaV4Outer( VmathSoaMatrix4 *result, const VmathSoaVector4 *tfrm0, const VmathSoaVector4 *tfrm1 ) +{ + vmathSoaV4ScalarMul( &result->col0, tfrm0, vmathSoaV4GetX( tfrm1 ) ); + vmathSoaV4ScalarMul( &result->col1, tfrm0, vmathSoaV4GetY( tfrm1 ) ); + vmathSoaV4ScalarMul( &result->col2, tfrm0, vmathSoaV4GetZ( tfrm1 ) ); + vmathSoaV4ScalarMul( &result->col3, tfrm0, vmathSoaV4GetW( tfrm1 ) ); +} + +static inline void vmathSoaV3RowMul( VmathSoaVector3 *result, const VmathSoaVector3 *vec, const VmathSoaMatrix3 *mat ) +{ + vec_float4 tmpX, tmpY, tmpZ; + tmpX = vec_add( vec_add( vec_madd( vec->x, mat->col0.x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( vec->y, mat->col0.y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( vec->z, mat->col0.z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmpY = vec_add( vec_add( vec_madd( vec->x, mat->col1.x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( vec->y, mat->col1.y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( vec->z, mat->col1.z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmpZ = vec_add( vec_add( vec_madd( vec->x, mat->col2.x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( vec->y, mat->col2.y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( vec->z, mat->col2.z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + vmathSoaV3MakeFromElems( result, tmpX, tmpY, tmpZ ); +} + +static inline void vmathSoaV3CrossMatrix( VmathSoaMatrix3 *result, const VmathSoaVector3 *vec ) +{ + vmathSoaV3MakeFromElems( &result->col0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), vec->z, negatef4( vec->y ) ); + vmathSoaV3MakeFromElems( &result->col1, negatef4( vec->z ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), vec->x ); + vmathSoaV3MakeFromElems( &result->col2, vec->y, negatef4( vec->x ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); +} + +static inline void vmathSoaV3CrossMatrixMul( VmathSoaMatrix3 *result, const VmathSoaVector3 *vec, const VmathSoaMatrix3 *mat ) +{ + VmathSoaVector3 tmpV3_0, tmpV3_1, tmpV3_2; + vmathSoaV3Cross( &tmpV3_0, vec, &mat->col0 ); + vmathSoaV3Cross( &tmpV3_1, vec, &mat->col1 ); + vmathSoaV3Cross( &tmpV3_2, vec, &mat->col2 ); + vmathSoaM3MakeFromCols( result, &tmpV3_0, &tmpV3_1, &tmpV3_2 ); +} + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/vectormathlibrary/include/vectormath/ppu/c/mat_soa_v.h b/vectormathlibrary/include/vectormath/ppu/c/mat_soa_v.h new file mode 100644 index 000000000..c8401e3d0 --- /dev/null +++ b/vectormathlibrary/include/vectormath/ppu/c/mat_soa_v.h @@ -0,0 +1,1063 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_MAT_SOA_V_C_H +#define _VECTORMATH_MAT_SOA_V_C_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/*----------------------------------------------------------------------------- + * Constants + */ +#define _VECTORMATH_PI_OVER_2 1.570796327f + +/*----------------------------------------------------------------------------- + * Definitions + */ +static inline VmathSoaMatrix3 vmathSoaM3MakeFromScalar_V( vec_float4 scalar ) +{ + VmathSoaMatrix3 result; + vmathSoaM3MakeFromScalar(&result, scalar); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3MakeFromQ_V( VmathSoaQuat unitQuat ) +{ + VmathSoaMatrix3 result; + vmathSoaM3MakeFromQ(&result, &unitQuat); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3MakeFromCols_V( VmathSoaVector3 _col0, VmathSoaVector3 _col1, VmathSoaVector3 _col2 ) +{ + VmathSoaMatrix3 result; + vmathSoaM3MakeFromCols(&result, &_col0, &_col1, &_col2); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3MakeFromAos_V( VmathMatrix3 mat ) +{ + VmathSoaMatrix3 result; + vmathSoaM3MakeFromAos(&result, &mat); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3MakeFrom4Aos_V( VmathMatrix3 mat0, VmathMatrix3 mat1, VmathMatrix3 mat2, VmathMatrix3 mat3 ) +{ + VmathSoaMatrix3 result; + vmathSoaM3MakeFrom4Aos(&result, &mat0, &mat1, &mat2, &mat3); + return result; +} + +static inline void vmathSoaM3Get4Aos_V( VmathSoaMatrix3 mat, VmathMatrix3 *result0, VmathMatrix3 *result1, VmathMatrix3 *result2, VmathMatrix3 *result3 ) +{ + vmathSoaM3Get4Aos(&mat, result0, result1, result2, result3); +} + +static inline void vmathSoaM3SetCol0_V( VmathSoaMatrix3 *result, VmathSoaVector3 _col0 ) +{ + vmathSoaM3SetCol0(result, &_col0); +} + +static inline void vmathSoaM3SetCol1_V( VmathSoaMatrix3 *result, VmathSoaVector3 _col1 ) +{ + vmathSoaM3SetCol1(result, &_col1); +} + +static inline void vmathSoaM3SetCol2_V( VmathSoaMatrix3 *result, VmathSoaVector3 _col2 ) +{ + vmathSoaM3SetCol2(result, &_col2); +} + +static inline void vmathSoaM3SetCol_V( VmathSoaMatrix3 *result, int col, VmathSoaVector3 vec ) +{ + vmathSoaM3SetCol(result, col, &vec); +} + +static inline void vmathSoaM3SetRow_V( VmathSoaMatrix3 *result, int row, VmathSoaVector3 vec ) +{ + vmathSoaM3SetRow(result, row, &vec); +} + +static inline void vmathSoaM3SetElem_V( VmathSoaMatrix3 *result, int col, int row, vec_float4 val ) +{ + vmathSoaM3SetElem(result, col, row, val); +} + +static inline vec_float4 vmathSoaM3GetElem_V( VmathSoaMatrix3 mat, int col, int row ) +{ + return vmathSoaM3GetElem(&mat, col, row); +} + +static inline VmathSoaVector3 vmathSoaM3GetCol0_V( VmathSoaMatrix3 mat ) +{ + VmathSoaVector3 result; + vmathSoaM3GetCol0(&result, &mat); + return result; +} + +static inline VmathSoaVector3 vmathSoaM3GetCol1_V( VmathSoaMatrix3 mat ) +{ + VmathSoaVector3 result; + vmathSoaM3GetCol1(&result, &mat); + return result; +} + +static inline VmathSoaVector3 vmathSoaM3GetCol2_V( VmathSoaMatrix3 mat ) +{ + VmathSoaVector3 result; + vmathSoaM3GetCol2(&result, &mat); + return result; +} + +static inline VmathSoaVector3 vmathSoaM3GetCol_V( VmathSoaMatrix3 mat, int col ) +{ + VmathSoaVector3 result; + vmathSoaM3GetCol(&result, &mat, col); + return result; +} + +static inline VmathSoaVector3 vmathSoaM3GetRow_V( VmathSoaMatrix3 mat, int row ) +{ + VmathSoaVector3 result; + vmathSoaM3GetRow(&result, &mat, row); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3Transpose_V( VmathSoaMatrix3 mat ) +{ + VmathSoaMatrix3 result; + vmathSoaM3Transpose(&result, &mat); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3Inverse_V( VmathSoaMatrix3 mat ) +{ + VmathSoaMatrix3 result; + vmathSoaM3Inverse(&result, &mat); + return result; +} + +static inline vec_float4 vmathSoaM3Determinant_V( VmathSoaMatrix3 mat ) +{ + return vmathSoaM3Determinant(&mat); +} + +static inline VmathSoaMatrix3 vmathSoaM3Add_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1 ) +{ + VmathSoaMatrix3 result; + vmathSoaM3Add(&result, &mat0, &mat1); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3Sub_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1 ) +{ + VmathSoaMatrix3 result; + vmathSoaM3Sub(&result, &mat0, &mat1); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3Neg_V( VmathSoaMatrix3 mat ) +{ + VmathSoaMatrix3 result; + vmathSoaM3Neg(&result, &mat); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3AbsPerElem_V( VmathSoaMatrix3 mat ) +{ + VmathSoaMatrix3 result; + vmathSoaM3AbsPerElem(&result, &mat); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3ScalarMul_V( VmathSoaMatrix3 mat, vec_float4 scalar ) +{ + VmathSoaMatrix3 result; + vmathSoaM3ScalarMul(&result, &mat, scalar); + return result; +} + +static inline VmathSoaVector3 vmathSoaM3MulV3_V( VmathSoaMatrix3 mat, VmathSoaVector3 vec ) +{ + VmathSoaVector3 result; + vmathSoaM3MulV3(&result, &mat, &vec); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3Mul_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1 ) +{ + VmathSoaMatrix3 result; + vmathSoaM3Mul(&result, &mat0, &mat1); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3MulPerElem_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1 ) +{ + VmathSoaMatrix3 result; + vmathSoaM3MulPerElem(&result, &mat0, &mat1); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3MakeIdentity_V( ) +{ + VmathSoaMatrix3 result; + vmathSoaM3MakeIdentity(&result); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3MakeRotationX_V( vec_float4 radians ) +{ + VmathSoaMatrix3 result; + vmathSoaM3MakeRotationX(&result, radians); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3MakeRotationY_V( vec_float4 radians ) +{ + VmathSoaMatrix3 result; + vmathSoaM3MakeRotationY(&result, radians); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3MakeRotationZ_V( vec_float4 radians ) +{ + VmathSoaMatrix3 result; + vmathSoaM3MakeRotationZ(&result, radians); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3MakeRotationZYX_V( VmathSoaVector3 radiansXYZ ) +{ + VmathSoaMatrix3 result; + vmathSoaM3MakeRotationZYX(&result, &radiansXYZ); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3MakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec ) +{ + VmathSoaMatrix3 result; + vmathSoaM3MakeRotationAxis(&result, radians, &unitVec); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3MakeRotationQ_V( VmathSoaQuat unitQuat ) +{ + VmathSoaMatrix3 result; + vmathSoaM3MakeRotationQ(&result, &unitQuat); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3MakeScale_V( VmathSoaVector3 scaleVec ) +{ + VmathSoaMatrix3 result; + vmathSoaM3MakeScale(&result, &scaleVec); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3AppendScale_V( VmathSoaMatrix3 mat, VmathSoaVector3 scaleVec ) +{ + VmathSoaMatrix3 result; + vmathSoaM3AppendScale(&result, &mat, &scaleVec); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3PrependScale_V( VmathSoaVector3 scaleVec, VmathSoaMatrix3 mat ) +{ + VmathSoaMatrix3 result; + vmathSoaM3PrependScale(&result, &scaleVec, &mat); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3Select_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1, vec_uint4 select1 ) +{ + VmathSoaMatrix3 result; + vmathSoaM3Select(&result, &mat0, &mat1, select1); + return result; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathSoaM3Print_V( VmathSoaMatrix3 mat ) +{ + vmathSoaM3Print(&mat); +} + +static inline void vmathSoaM3Prints_V( VmathSoaMatrix3 mat, const char *name ) +{ + vmathSoaM3Prints(&mat, name); +} + +#endif + +static inline VmathSoaMatrix4 vmathSoaM4MakeFromScalar_V( vec_float4 scalar ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeFromScalar(&result, scalar); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakeFromT3_V( VmathSoaTransform3 mat ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeFromT3(&result, &mat); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakeFromCols_V( VmathSoaVector4 _col0, VmathSoaVector4 _col1, VmathSoaVector4 _col2, VmathSoaVector4 _col3 ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeFromCols(&result, &_col0, &_col1, &_col2, &_col3); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakeFromM3V3_V( VmathSoaMatrix3 mat, VmathSoaVector3 translateVec ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeFromM3V3(&result, &mat, &translateVec); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakeFromQV3_V( VmathSoaQuat unitQuat, VmathSoaVector3 translateVec ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeFromQV3(&result, &unitQuat, &translateVec); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakeFromAos_V( VmathMatrix4 mat ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeFromAos(&result, &mat); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakeFrom4Aos_V( VmathMatrix4 mat0, VmathMatrix4 mat1, VmathMatrix4 mat2, VmathMatrix4 mat3 ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeFrom4Aos(&result, &mat0, &mat1, &mat2, &mat3); + return result; +} + +static inline void vmathSoaM4Get4Aos_V( VmathSoaMatrix4 mat, VmathMatrix4 *result0, VmathMatrix4 *result1, VmathMatrix4 *result2, VmathMatrix4 *result3 ) +{ + vmathSoaM4Get4Aos(&mat, result0, result1, result2, result3); +} + +static inline void vmathSoaM4SetCol0_V( VmathSoaMatrix4 *result, VmathSoaVector4 _col0 ) +{ + vmathSoaM4SetCol0(result, &_col0); +} + +static inline void vmathSoaM4SetCol1_V( VmathSoaMatrix4 *result, VmathSoaVector4 _col1 ) +{ + vmathSoaM4SetCol1(result, &_col1); +} + +static inline void vmathSoaM4SetCol2_V( VmathSoaMatrix4 *result, VmathSoaVector4 _col2 ) +{ + vmathSoaM4SetCol2(result, &_col2); +} + +static inline void vmathSoaM4SetCol3_V( VmathSoaMatrix4 *result, VmathSoaVector4 _col3 ) +{ + vmathSoaM4SetCol3(result, &_col3); +} + +static inline void vmathSoaM4SetCol_V( VmathSoaMatrix4 *result, int col, VmathSoaVector4 vec ) +{ + vmathSoaM4SetCol(result, col, &vec); +} + +static inline void vmathSoaM4SetRow_V( VmathSoaMatrix4 *result, int row, VmathSoaVector4 vec ) +{ + vmathSoaM4SetRow(result, row, &vec); +} + +static inline void vmathSoaM4SetElem_V( VmathSoaMatrix4 *result, int col, int row, vec_float4 val ) +{ + vmathSoaM4SetElem(result, col, row, val); +} + +static inline vec_float4 vmathSoaM4GetElem_V( VmathSoaMatrix4 mat, int col, int row ) +{ + return vmathSoaM4GetElem(&mat, col, row); +} + +static inline VmathSoaVector4 vmathSoaM4GetCol0_V( VmathSoaMatrix4 mat ) +{ + VmathSoaVector4 result; + vmathSoaM4GetCol0(&result, &mat); + return result; +} + +static inline VmathSoaVector4 vmathSoaM4GetCol1_V( VmathSoaMatrix4 mat ) +{ + VmathSoaVector4 result; + vmathSoaM4GetCol1(&result, &mat); + return result; +} + +static inline VmathSoaVector4 vmathSoaM4GetCol2_V( VmathSoaMatrix4 mat ) +{ + VmathSoaVector4 result; + vmathSoaM4GetCol2(&result, &mat); + return result; +} + +static inline VmathSoaVector4 vmathSoaM4GetCol3_V( VmathSoaMatrix4 mat ) +{ + VmathSoaVector4 result; + vmathSoaM4GetCol3(&result, &mat); + return result; +} + +static inline VmathSoaVector4 vmathSoaM4GetCol_V( VmathSoaMatrix4 mat, int col ) +{ + VmathSoaVector4 result; + vmathSoaM4GetCol(&result, &mat, col); + return result; +} + +static inline VmathSoaVector4 vmathSoaM4GetRow_V( VmathSoaMatrix4 mat, int row ) +{ + VmathSoaVector4 result; + vmathSoaM4GetRow(&result, &mat, row); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4Transpose_V( VmathSoaMatrix4 mat ) +{ + VmathSoaMatrix4 result; + vmathSoaM4Transpose(&result, &mat); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4Inverse_V( VmathSoaMatrix4 mat ) +{ + VmathSoaMatrix4 result; + vmathSoaM4Inverse(&result, &mat); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4AffineInverse_V( VmathSoaMatrix4 mat ) +{ + VmathSoaMatrix4 result; + vmathSoaM4AffineInverse(&result, &mat); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4OrthoInverse_V( VmathSoaMatrix4 mat ) +{ + VmathSoaMatrix4 result; + vmathSoaM4OrthoInverse(&result, &mat); + return result; +} + +static inline vec_float4 vmathSoaM4Determinant_V( VmathSoaMatrix4 mat ) +{ + return vmathSoaM4Determinant(&mat); +} + +static inline VmathSoaMatrix4 vmathSoaM4Add_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1 ) +{ + VmathSoaMatrix4 result; + vmathSoaM4Add(&result, &mat0, &mat1); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4Sub_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1 ) +{ + VmathSoaMatrix4 result; + vmathSoaM4Sub(&result, &mat0, &mat1); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4Neg_V( VmathSoaMatrix4 mat ) +{ + VmathSoaMatrix4 result; + vmathSoaM4Neg(&result, &mat); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4AbsPerElem_V( VmathSoaMatrix4 mat ) +{ + VmathSoaMatrix4 result; + vmathSoaM4AbsPerElem(&result, &mat); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4ScalarMul_V( VmathSoaMatrix4 mat, vec_float4 scalar ) +{ + VmathSoaMatrix4 result; + vmathSoaM4ScalarMul(&result, &mat, scalar); + return result; +} + +static inline VmathSoaVector4 vmathSoaM4MulV4_V( VmathSoaMatrix4 mat, VmathSoaVector4 vec ) +{ + VmathSoaVector4 result; + vmathSoaM4MulV4(&result, &mat, &vec); + return result; +} + +static inline VmathSoaVector4 vmathSoaM4MulV3_V( VmathSoaMatrix4 mat, VmathSoaVector3 vec ) +{ + VmathSoaVector4 result; + vmathSoaM4MulV3(&result, &mat, &vec); + return result; +} + +static inline VmathSoaVector4 vmathSoaM4MulP3_V( VmathSoaMatrix4 mat, VmathSoaPoint3 pnt ) +{ + VmathSoaVector4 result; + vmathSoaM4MulP3(&result, &mat, &pnt); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4Mul_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1 ) +{ + VmathSoaMatrix4 result; + vmathSoaM4Mul(&result, &mat0, &mat1); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MulT3_V( VmathSoaMatrix4 mat, VmathSoaTransform3 tfrm1 ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MulT3(&result, &mat, &tfrm1); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MulPerElem_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1 ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MulPerElem(&result, &mat0, &mat1); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakeIdentity_V( ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeIdentity(&result); + return result; +} + +static inline void vmathSoaM4SetUpper3x3_V( VmathSoaMatrix4 *result, VmathSoaMatrix3 mat3 ) +{ + vmathSoaM4SetUpper3x3(result, &mat3); +} + +static inline VmathSoaMatrix3 vmathSoaM4GetUpper3x3_V( VmathSoaMatrix4 mat ) +{ + VmathSoaMatrix3 result; + vmathSoaM4GetUpper3x3(&result, &mat); + return result; +} + +static inline void vmathSoaM4SetTranslation_V( VmathSoaMatrix4 *result, VmathSoaVector3 translateVec ) +{ + vmathSoaM4SetTranslation(result, &translateVec); +} + +static inline VmathSoaVector3 vmathSoaM4GetTranslation_V( VmathSoaMatrix4 mat ) +{ + VmathSoaVector3 result; + vmathSoaM4GetTranslation(&result, &mat); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakeRotationX_V( vec_float4 radians ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeRotationX(&result, radians); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakeRotationY_V( vec_float4 radians ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeRotationY(&result, radians); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakeRotationZ_V( vec_float4 radians ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeRotationZ(&result, radians); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakeRotationZYX_V( VmathSoaVector3 radiansXYZ ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeRotationZYX(&result, &radiansXYZ); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeRotationAxis(&result, radians, &unitVec); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakeRotationQ_V( VmathSoaQuat unitQuat ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeRotationQ(&result, &unitQuat); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakeScale_V( VmathSoaVector3 scaleVec ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeScale(&result, &scaleVec); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4AppendScale_V( VmathSoaMatrix4 mat, VmathSoaVector3 scaleVec ) +{ + VmathSoaMatrix4 result; + vmathSoaM4AppendScale(&result, &mat, &scaleVec); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4PrependScale_V( VmathSoaVector3 scaleVec, VmathSoaMatrix4 mat ) +{ + VmathSoaMatrix4 result; + vmathSoaM4PrependScale(&result, &scaleVec, &mat); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakeTranslation_V( VmathSoaVector3 translateVec ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeTranslation(&result, &translateVec); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakeLookAt_V( VmathSoaPoint3 eyePos, VmathSoaPoint3 lookAtPos, VmathSoaVector3 upVec ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeLookAt(&result, &eyePos, &lookAtPos, &upVec); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakePerspective_V( vec_float4 fovyRadians, vec_float4 aspect, vec_float4 zNear, vec_float4 zFar ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakePerspective(&result, fovyRadians, aspect, zNear, zFar); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakeFrustum_V( vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeFrustum(&result, left, right, bottom, top, zNear, zFar); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakeOrthographic_V( vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeOrthographic(&result, left, right, bottom, top, zNear, zFar); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4Select_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1, vec_uint4 select1 ) +{ + VmathSoaMatrix4 result; + vmathSoaM4Select(&result, &mat0, &mat1, select1); + return result; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathSoaM4Print_V( VmathSoaMatrix4 mat ) +{ + vmathSoaM4Print(&mat); +} + +static inline void vmathSoaM4Prints_V( VmathSoaMatrix4 mat, const char *name ) +{ + vmathSoaM4Prints(&mat, name); +} + +#endif + +static inline VmathSoaTransform3 vmathSoaT3MakeFromScalar_V( vec_float4 scalar ) +{ + VmathSoaTransform3 result; + vmathSoaT3MakeFromScalar(&result, scalar); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3MakeFromCols_V( VmathSoaVector3 _col0, VmathSoaVector3 _col1, VmathSoaVector3 _col2, VmathSoaVector3 _col3 ) +{ + VmathSoaTransform3 result; + vmathSoaT3MakeFromCols(&result, &_col0, &_col1, &_col2, &_col3); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3MakeFromM3V3_V( VmathSoaMatrix3 tfrm, VmathSoaVector3 translateVec ) +{ + VmathSoaTransform3 result; + vmathSoaT3MakeFromM3V3(&result, &tfrm, &translateVec); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3MakeFromQV3_V( VmathSoaQuat unitQuat, VmathSoaVector3 translateVec ) +{ + VmathSoaTransform3 result; + vmathSoaT3MakeFromQV3(&result, &unitQuat, &translateVec); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3MakeFromAos_V( VmathTransform3 tfrm ) +{ + VmathSoaTransform3 result; + vmathSoaT3MakeFromAos(&result, &tfrm); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3MakeFrom4Aos_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1, VmathTransform3 tfrm2, VmathTransform3 tfrm3 ) +{ + VmathSoaTransform3 result; + vmathSoaT3MakeFrom4Aos(&result, &tfrm0, &tfrm1, &tfrm2, &tfrm3); + return result; +} + +static inline void vmathSoaT3Get4Aos_V( VmathSoaTransform3 tfrm, VmathTransform3 *result0, VmathTransform3 *result1, VmathTransform3 *result2, VmathTransform3 *result3 ) +{ + vmathSoaT3Get4Aos(&tfrm, result0, result1, result2, result3); +} + +static inline void vmathSoaT3SetCol0_V( VmathSoaTransform3 *result, VmathSoaVector3 _col0 ) +{ + vmathSoaT3SetCol0(result, &_col0); +} + +static inline void vmathSoaT3SetCol1_V( VmathSoaTransform3 *result, VmathSoaVector3 _col1 ) +{ + vmathSoaT3SetCol1(result, &_col1); +} + +static inline void vmathSoaT3SetCol2_V( VmathSoaTransform3 *result, VmathSoaVector3 _col2 ) +{ + vmathSoaT3SetCol2(result, &_col2); +} + +static inline void vmathSoaT3SetCol3_V( VmathSoaTransform3 *result, VmathSoaVector3 _col3 ) +{ + vmathSoaT3SetCol3(result, &_col3); +} + +static inline void vmathSoaT3SetCol_V( VmathSoaTransform3 *result, int col, VmathSoaVector3 vec ) +{ + vmathSoaT3SetCol(result, col, &vec); +} + +static inline void vmathSoaT3SetRow_V( VmathSoaTransform3 *result, int row, VmathSoaVector4 vec ) +{ + vmathSoaT3SetRow(result, row, &vec); +} + +static inline void vmathSoaT3SetElem_V( VmathSoaTransform3 *result, int col, int row, vec_float4 val ) +{ + vmathSoaT3SetElem(result, col, row, val); +} + +static inline vec_float4 vmathSoaT3GetElem_V( VmathSoaTransform3 tfrm, int col, int row ) +{ + return vmathSoaT3GetElem(&tfrm, col, row); +} + +static inline VmathSoaVector3 vmathSoaT3GetCol0_V( VmathSoaTransform3 tfrm ) +{ + VmathSoaVector3 result; + vmathSoaT3GetCol0(&result, &tfrm); + return result; +} + +static inline VmathSoaVector3 vmathSoaT3GetCol1_V( VmathSoaTransform3 tfrm ) +{ + VmathSoaVector3 result; + vmathSoaT3GetCol1(&result, &tfrm); + return result; +} + +static inline VmathSoaVector3 vmathSoaT3GetCol2_V( VmathSoaTransform3 tfrm ) +{ + VmathSoaVector3 result; + vmathSoaT3GetCol2(&result, &tfrm); + return result; +} + +static inline VmathSoaVector3 vmathSoaT3GetCol3_V( VmathSoaTransform3 tfrm ) +{ + VmathSoaVector3 result; + vmathSoaT3GetCol3(&result, &tfrm); + return result; +} + +static inline VmathSoaVector3 vmathSoaT3GetCol_V( VmathSoaTransform3 tfrm, int col ) +{ + VmathSoaVector3 result; + vmathSoaT3GetCol(&result, &tfrm, col); + return result; +} + +static inline VmathSoaVector4 vmathSoaT3GetRow_V( VmathSoaTransform3 tfrm, int row ) +{ + VmathSoaVector4 result; + vmathSoaT3GetRow(&result, &tfrm, row); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3Inverse_V( VmathSoaTransform3 tfrm ) +{ + VmathSoaTransform3 result; + vmathSoaT3Inverse(&result, &tfrm); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3OrthoInverse_V( VmathSoaTransform3 tfrm ) +{ + VmathSoaTransform3 result; + vmathSoaT3OrthoInverse(&result, &tfrm); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3AbsPerElem_V( VmathSoaTransform3 tfrm ) +{ + VmathSoaTransform3 result; + vmathSoaT3AbsPerElem(&result, &tfrm); + return result; +} + +static inline VmathSoaVector3 vmathSoaT3MulV3_V( VmathSoaTransform3 tfrm, VmathSoaVector3 vec ) +{ + VmathSoaVector3 result; + vmathSoaT3MulV3(&result, &tfrm, &vec); + return result; +} + +static inline VmathSoaPoint3 vmathSoaT3MulP3_V( VmathSoaTransform3 tfrm, VmathSoaPoint3 pnt ) +{ + VmathSoaPoint3 result; + vmathSoaT3MulP3(&result, &tfrm, &pnt); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3Mul_V( VmathSoaTransform3 tfrm0, VmathSoaTransform3 tfrm1 ) +{ + VmathSoaTransform3 result; + vmathSoaT3Mul(&result, &tfrm0, &tfrm1); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3MulPerElem_V( VmathSoaTransform3 tfrm0, VmathSoaTransform3 tfrm1 ) +{ + VmathSoaTransform3 result; + vmathSoaT3MulPerElem(&result, &tfrm0, &tfrm1); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3MakeIdentity_V( ) +{ + VmathSoaTransform3 result; + vmathSoaT3MakeIdentity(&result); + return result; +} + +static inline void vmathSoaT3SetUpper3x3_V( VmathSoaTransform3 *result, VmathSoaMatrix3 tfrm ) +{ + vmathSoaT3SetUpper3x3(result, &tfrm); +} + +static inline VmathSoaMatrix3 vmathSoaT3GetUpper3x3_V( VmathSoaTransform3 tfrm ) +{ + VmathSoaMatrix3 result; + vmathSoaT3GetUpper3x3(&result, &tfrm); + return result; +} + +static inline void vmathSoaT3SetTranslation_V( VmathSoaTransform3 *result, VmathSoaVector3 translateVec ) +{ + vmathSoaT3SetTranslation(result, &translateVec); +} + +static inline VmathSoaVector3 vmathSoaT3GetTranslation_V( VmathSoaTransform3 tfrm ) +{ + VmathSoaVector3 result; + vmathSoaT3GetTranslation(&result, &tfrm); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3MakeRotationX_V( vec_float4 radians ) +{ + VmathSoaTransform3 result; + vmathSoaT3MakeRotationX(&result, radians); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3MakeRotationY_V( vec_float4 radians ) +{ + VmathSoaTransform3 result; + vmathSoaT3MakeRotationY(&result, radians); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3MakeRotationZ_V( vec_float4 radians ) +{ + VmathSoaTransform3 result; + vmathSoaT3MakeRotationZ(&result, radians); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3MakeRotationZYX_V( VmathSoaVector3 radiansXYZ ) +{ + VmathSoaTransform3 result; + vmathSoaT3MakeRotationZYX(&result, &radiansXYZ); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3MakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec ) +{ + VmathSoaTransform3 result; + vmathSoaT3MakeRotationAxis(&result, radians, &unitVec); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3MakeRotationQ_V( VmathSoaQuat unitQuat ) +{ + VmathSoaTransform3 result; + vmathSoaT3MakeRotationQ(&result, &unitQuat); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3MakeScale_V( VmathSoaVector3 scaleVec ) +{ + VmathSoaTransform3 result; + vmathSoaT3MakeScale(&result, &scaleVec); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3AppendScale_V( VmathSoaTransform3 tfrm, VmathSoaVector3 scaleVec ) +{ + VmathSoaTransform3 result; + vmathSoaT3AppendScale(&result, &tfrm, &scaleVec); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3PrependScale_V( VmathSoaVector3 scaleVec, VmathSoaTransform3 tfrm ) +{ + VmathSoaTransform3 result; + vmathSoaT3PrependScale(&result, &scaleVec, &tfrm); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3MakeTranslation_V( VmathSoaVector3 translateVec ) +{ + VmathSoaTransform3 result; + vmathSoaT3MakeTranslation(&result, &translateVec); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3Select_V( VmathSoaTransform3 tfrm0, VmathSoaTransform3 tfrm1, vec_uint4 select1 ) +{ + VmathSoaTransform3 result; + vmathSoaT3Select(&result, &tfrm0, &tfrm1, select1); + return result; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathSoaT3Print_V( VmathSoaTransform3 tfrm ) +{ + vmathSoaT3Print(&tfrm); +} + +static inline void vmathSoaT3Prints_V( VmathSoaTransform3 tfrm, const char *name ) +{ + vmathSoaT3Prints(&tfrm, name); +} + +#endif + +static inline VmathSoaQuat vmathSoaQMakeFromM3_V( VmathSoaMatrix3 tfrm ) +{ + VmathSoaQuat result; + vmathSoaQMakeFromM3(&result, &tfrm); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaV3Outer_V( VmathSoaVector3 tfrm0, VmathSoaVector3 tfrm1 ) +{ + VmathSoaMatrix3 result; + vmathSoaV3Outer(&result, &tfrm0, &tfrm1); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaV4Outer_V( VmathSoaVector4 tfrm0, VmathSoaVector4 tfrm1 ) +{ + VmathSoaMatrix4 result; + vmathSoaV4Outer(&result, &tfrm0, &tfrm1); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3RowMul_V( VmathSoaVector3 vec, VmathSoaMatrix3 mat ) +{ + VmathSoaVector3 result; + vmathSoaV3RowMul(&result, &vec, &mat); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaV3CrossMatrix_V( VmathSoaVector3 vec ) +{ + VmathSoaMatrix3 result; + vmathSoaV3CrossMatrix(&result, &vec); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaV3CrossMatrixMul_V( VmathSoaVector3 vec, VmathSoaMatrix3 mat ) +{ + VmathSoaMatrix3 result; + vmathSoaV3CrossMatrixMul(&result, &vec, &mat); + return result; +} + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/vectormathlibrary/include/vectormath/ppu/c/quat_aos.h b/vectormathlibrary/include/vectormath/ppu/c/quat_aos.h new file mode 100644 index 000000000..2915f4f07 --- /dev/null +++ b/vectormathlibrary/include/vectormath/ppu/c/quat_aos.h @@ -0,0 +1,379 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_QUAT_AOS_C_H +#define _VECTORMATH_QUAT_AOS_C_H +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/*----------------------------------------------------------------------------- + * Definitions + */ +#ifndef _VECTORMATH_INTERNAL_FUNCTIONS +#define _VECTORMATH_INTERNAL_FUNCTIONS + +#endif + +static inline void vmathQCopy( VmathQuat *result, const VmathQuat *quat ) +{ + result->vec128 = quat->vec128; +} + +static inline void vmathQMakeFromElems( VmathQuat *result, float _x, float _y, float _z, float _w ) +{ + if (__builtin_constant_p(_x) & __builtin_constant_p(_y) & + __builtin_constant_p(_z) & __builtin_constant_p(_w)) { + result->vec128 = (vec_float4){_x, _y, _z, _w}; + } else { + float *pf = (float *)&result->vec128; + pf[0] = _x; + pf[1] = _y; + pf[2] = _z; + pf[3] = _w; + } +} + +static inline void vmathQMakeFromV3Scalar( VmathQuat *result, const VmathVector3 *xyz, float _w ) +{ + result->vec128 = xyz->vec128; + _vmathVfSetElement(result->vec128, _w, 3); +} + +static inline void vmathQMakeFromV4( VmathQuat *result, const VmathVector4 *vec ) +{ + result->vec128 = vec->vec128; +} + +static inline void vmathQMakeFromScalar( VmathQuat *result, float scalar ) +{ + result->vec128 = _vmathVfSplatScalar(scalar); +} + +static inline void vmathQMakeFrom128( VmathQuat *result, vec_float4 vf4 ) +{ + result->vec128 = vf4; +} + +static inline void vmathQMakeIdentity( VmathQuat *result ) +{ + result->vec128 = _VECTORMATH_UNIT_0001; +} + +static inline void vmathQLerp( VmathQuat *result, float t, const VmathQuat *quat0, const VmathQuat *quat1 ) +{ + VmathQuat tmpQ_0, tmpQ_1; + vmathQSub( &tmpQ_0, quat1, quat0 ); + vmathQScalarMul( &tmpQ_1, &tmpQ_0, t ); + vmathQAdd( result, quat0, &tmpQ_1 ); +} + +static inline void vmathQSlerp( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1 ) +{ + VmathQuat start; + vec_float4 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines; + vec_uint4 selectMask; + cosAngle = _vmathVfDot4( unitQuat0->vec128, unitQuat1->vec128 ); + cosAngle = vec_splat( cosAngle, 0 ); + selectMask = (vec_uint4)vec_cmpgt( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), cosAngle ); + cosAngle = vec_sel( cosAngle, negatef4( cosAngle ), selectMask ); + start.vec128 = vec_sel( unitQuat0->vec128, negatef4( unitQuat0->vec128 ), selectMask ); + selectMask = (vec_uint4)vec_cmpgt( ((vec_float4){_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL}), cosAngle ); + angle = acosf4( cosAngle ); + tttt = _vmathVfSplatScalar(t); + oneMinusT = vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), tttt ); + angles = vec_mergeh( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), tttt ); + angles = vec_mergeh( angles, oneMinusT ); + angles = vec_madd( angles, angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + sines = sinf4( angles ); + scales = divf4( sines, vec_splat( sines, 0 ) ); + scale0 = vec_sel( oneMinusT, vec_splat( scales, 1 ), selectMask ); + scale1 = vec_sel( tttt, vec_splat( scales, 2 ), selectMask ); + result->vec128 = vec_madd( start.vec128, scale0, vec_madd( unitQuat1->vec128, scale1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); +} + +static inline void vmathQSquad( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1, const VmathQuat *unitQuat2, const VmathQuat *unitQuat3 ) +{ + VmathQuat tmp0, tmp1; + vmathQSlerp( &tmp0, t, unitQuat0, unitQuat3 ); + vmathQSlerp( &tmp1, t, unitQuat1, unitQuat2 ); + vmathQSlerp( result, ( ( 2.0f * t ) * ( 1.0f - t ) ), &tmp0, &tmp1 ); +} + +static inline vec_float4 vmathQGet128( const VmathQuat *quat ) +{ + return quat->vec128; +} + +static inline void vmathQSetXYZ( VmathQuat *result, const VmathVector3 *vec ) +{ + result->vec128 = vec_sel( vec->vec128, result->vec128, _VECTORMATH_MASK_0x000F ); +} + +static inline void vmathQGetXYZ( VmathVector3 *result, const VmathQuat *quat ) +{ + result->vec128 = quat->vec128; +} + +static inline void vmathQSetX( VmathQuat *result, float _x ) +{ + _vmathVfSetElement(result->vec128, _x, 0); +} + +static inline float vmathQGetX( const VmathQuat *quat ) +{ + return _vmathVfGetElement(quat->vec128, 0); +} + +static inline void vmathQSetY( VmathQuat *result, float _y ) +{ + _vmathVfSetElement(result->vec128, _y, 1); +} + +static inline float vmathQGetY( const VmathQuat *quat ) +{ + return _vmathVfGetElement(quat->vec128, 1); +} + +static inline void vmathQSetZ( VmathQuat *result, float _z ) +{ + _vmathVfSetElement(result->vec128, _z, 2); +} + +static inline float vmathQGetZ( const VmathQuat *quat ) +{ + return _vmathVfGetElement(quat->vec128, 2); +} + +static inline void vmathQSetW( VmathQuat *result, float _w ) +{ + _vmathVfSetElement(result->vec128, _w, 3); +} + +static inline float vmathQGetW( const VmathQuat *quat ) +{ + return _vmathVfGetElement(quat->vec128, 3); +} + +static inline void vmathQSetElem( VmathQuat *result, int idx, float value ) +{ + _vmathVfSetElement(result->vec128, value, idx); +} + +static inline float vmathQGetElem( const VmathQuat *quat, int idx ) +{ + return _vmathVfGetElement(quat->vec128, idx); +} + +static inline void vmathQAdd( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ) +{ + result->vec128 = vec_add( quat0->vec128, quat1->vec128 ); +} + +static inline void vmathQSub( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ) +{ + result->vec128 = vec_sub( quat0->vec128, quat1->vec128 ); +} + +static inline void vmathQScalarMul( VmathQuat *result, const VmathQuat *quat, float scalar ) +{ + result->vec128 = vec_madd( quat->vec128, _vmathVfSplatScalar(scalar), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); +} + +static inline void vmathQScalarDiv( VmathQuat *result, const VmathQuat *quat, float scalar ) +{ + result->vec128 = divf4( quat->vec128, _vmathVfSplatScalar(scalar) ); +} + +static inline void vmathQNeg( VmathQuat *result, const VmathQuat *quat ) +{ + result->vec128 = negatef4( quat->vec128 ); +} + +static inline float vmathQDot( const VmathQuat *quat0, const VmathQuat *quat1 ) +{ + vec_float4 result = _vmathVfDot4( quat0->vec128, quat1->vec128 ); + return _vmathVfGetElement(result, 0); +} + +static inline float vmathQNorm( const VmathQuat *quat ) +{ + vec_float4 result = _vmathVfDot4( quat->vec128, quat->vec128 ); + return _vmathVfGetElement(result, 0); +} + +static inline float vmathQLength( const VmathQuat *quat ) +{ + return sqrtf( vmathQNorm( quat ) ); +} + +static inline void vmathQNormalize( VmathQuat *result, const VmathQuat *quat ) +{ + vec_float4 dot = _vmathVfDot4( quat->vec128, quat->vec128 ); + result->vec128 = vec_madd( quat->vec128, rsqrtf4( dot ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); +} + +static inline void vmathQMakeRotationArc( VmathQuat *result, const VmathVector3 *unitVec0, const VmathVector3 *unitVec1 ) +{ + VmathVector3 crossVec, tmpV3_0; + vec_float4 cosAngle, cosAngleX2Plus2, recipCosHalfAngleX2, cosHalfAngleX2, res; + cosAngle = _vmathVfDot3( unitVec0->vec128, unitVec1->vec128 ); + cosAngle = vec_splat( cosAngle, 0 ); + cosAngleX2Plus2 = vec_madd( cosAngle, ((vec_float4){2.0f,2.0f,2.0f,2.0f}), ((vec_float4){2.0f,2.0f,2.0f,2.0f}) ); + recipCosHalfAngleX2 = rsqrtf4( cosAngleX2Plus2 ); + cosHalfAngleX2 = vec_madd( recipCosHalfAngleX2, cosAngleX2Plus2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + vmathV3Cross( &tmpV3_0, unitVec0, unitVec1 ); + crossVec = tmpV3_0; + res = vec_madd( crossVec.vec128, recipCosHalfAngleX2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + res = vec_sel( res, vec_madd( cosHalfAngleX2, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), _VECTORMATH_MASK_0x000F ); + result->vec128 = res; +} + +static inline void vmathQMakeRotationAxis( VmathQuat *result, float radians, const VmathVector3 *unitVec ) +{ + vec_float4 s, c, angle, res; + angle = vec_madd( _vmathVfSplatScalar(radians), ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + sincosf4( angle, &s, &c ); + res = vec_sel( vec_madd( unitVec->vec128, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), c, _VECTORMATH_MASK_0x000F ); + result->vec128 = res; +} + +static inline void vmathQMakeRotationX( VmathQuat *result, float radians ) +{ + vec_float4 s, c, angle, res; + angle = vec_madd( _vmathVfSplatScalar(radians), ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + sincosf4( angle, &s, &c ); + res = vec_sel( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, _VECTORMATH_MASK_0xF000 ); + res = vec_sel( res, c, _VECTORMATH_MASK_0x000F ); + result->vec128 = res; +} + +static inline void vmathQMakeRotationY( VmathQuat *result, float radians ) +{ + vec_float4 s, c, angle, res; + angle = vec_madd( _vmathVfSplatScalar(radians), ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + sincosf4( angle, &s, &c ); + res = vec_sel( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, _VECTORMATH_MASK_0x0F00 ); + res = vec_sel( res, c, _VECTORMATH_MASK_0x000F ); + result->vec128 = res; +} + +static inline void vmathQMakeRotationZ( VmathQuat *result, float radians ) +{ + vec_float4 s, c, angle, res; + angle = vec_madd( _vmathVfSplatScalar(radians), ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + sincosf4( angle, &s, &c ); + res = vec_sel( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, _VECTORMATH_MASK_0x00F0 ); + res = vec_sel( res, c, _VECTORMATH_MASK_0x000F ); + result->vec128 = res; +} + +static inline void vmathQMul( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ) +{ + vec_float4 ldata, rdata, qv, tmp0, tmp1, tmp2, tmp3; + vec_float4 product, l_wxyz, r_wxyz, xy, qw; + ldata = quat0->vec128; + rdata = quat1->vec128; + tmp0 = vec_perm( ldata, ldata, _VECTORMATH_PERM_YZXW ); + tmp1 = vec_perm( rdata, rdata, _VECTORMATH_PERM_ZXYW ); + tmp2 = vec_perm( ldata, ldata, _VECTORMATH_PERM_ZXYW ); + tmp3 = vec_perm( rdata, rdata, _VECTORMATH_PERM_YZXW ); + qv = vec_madd( vec_splat( ldata, 3 ), rdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + qv = vec_madd( vec_splat( rdata, 3 ), ldata, qv ); + qv = vec_madd( tmp0, tmp1, qv ); + qv = vec_nmsub( tmp2, tmp3, qv ); + product = vec_madd( ldata, rdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + l_wxyz = vec_sld( ldata, ldata, 12 ); + r_wxyz = vec_sld( rdata, rdata, 12 ); + qw = vec_nmsub( l_wxyz, r_wxyz, product ); + xy = vec_madd( l_wxyz, r_wxyz, product ); + qw = vec_sub( qw, vec_sld( xy, xy, 8 ) ); + result->vec128 = vec_sel( qv, qw, _VECTORMATH_MASK_0x000F ); +} + +static inline void vmathQRotate( VmathVector3 *result, const VmathQuat *quat, const VmathVector3 *vec ) +{ + vec_float4 qdata, vdata, product, tmp0, tmp1, tmp2, tmp3, wwww, qv, qw, res; + qdata = quat->vec128; + vdata = vec->vec128; + tmp0 = vec_perm( qdata, qdata, _VECTORMATH_PERM_YZXW ); + tmp1 = vec_perm( vdata, vdata, _VECTORMATH_PERM_ZXYW ); + tmp2 = vec_perm( qdata, qdata, _VECTORMATH_PERM_ZXYW ); + tmp3 = vec_perm( vdata, vdata, _VECTORMATH_PERM_YZXW ); + wwww = vec_splat( qdata, 3 ); + qv = vec_madd( wwww, vdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + qv = vec_madd( tmp0, tmp1, qv ); + qv = vec_nmsub( tmp2, tmp3, qv ); + product = vec_madd( qdata, vdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + qw = vec_madd( vec_sld( qdata, qdata, 4 ), vec_sld( vdata, vdata, 4 ), product ); + qw = vec_add( vec_sld( product, product, 8 ), qw ); + tmp1 = vec_perm( qv, qv, _VECTORMATH_PERM_ZXYW ); + tmp3 = vec_perm( qv, qv, _VECTORMATH_PERM_YZXW ); + res = vec_madd( vec_splat( qw, 0 ), qdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + res = vec_madd( wwww, qv, res ); + res = vec_madd( tmp0, tmp1, res ); + res = vec_nmsub( tmp2, tmp3, res ); + result->vec128 = res; +} + +static inline void vmathQConj( VmathQuat *result, const VmathQuat *quat ) +{ + result->vec128 = vec_xor( quat->vec128, ((vec_float4)(vec_int4){0x80000000,0x80000000,0x80000000,0}) ); +} + +static inline void vmathQSelect( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1, unsigned int select1 ) +{ + unsigned int tmp; + tmp = (unsigned int)-(select1 > 0); + result->vec128 = vec_sel( quat0->vec128, quat1->vec128, _vmathVuiSplatScalar(tmp) ); +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathQPrint( const VmathQuat *quat ) +{ + union { vec_float4 v; float s[4]; } tmp; + tmp.v = quat->vec128; + printf( "( %f %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] ); +} + +static inline void vmathQPrints( const VmathQuat *quat, const char *name ) +{ + union { vec_float4 v; float s[4]; } tmp; + tmp.v = quat->vec128; + printf( "%s: ( %f %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] ); +} + +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/vectormathlibrary/include/vectormath/ppu/c/quat_aos_v.h b/vectormathlibrary/include/vectormath/ppu/c/quat_aos_v.h new file mode 100644 index 000000000..04cf6ccf9 --- /dev/null +++ b/vectormathlibrary/include/vectormath/ppu/c/quat_aos_v.h @@ -0,0 +1,312 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_QUAT_AOS_V_C_H +#define _VECTORMATH_QUAT_AOS_V_C_H +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/*----------------------------------------------------------------------------- + * Definitions + */ +#ifndef _VECTORMATH_INTERNAL_FUNCTIONS +#define _VECTORMATH_INTERNAL_FUNCTIONS + +#endif + +static inline VmathQuat vmathQMakeFromElems_V( float _x, float _y, float _z, float _w ) +{ + VmathQuat result; + vmathQMakeFromElems(&result, _x, _y, _z, _w); + return result; +} + +static inline VmathQuat vmathQMakeFromV3Scalar_V( VmathVector3 xyz, float _w ) +{ + VmathQuat result; + vmathQMakeFromV3Scalar(&result, &xyz, _w); + return result; +} + +static inline VmathQuat vmathQMakeFromV4_V( VmathVector4 vec ) +{ + VmathQuat result; + vmathQMakeFromV4(&result, &vec); + return result; +} + +static inline VmathQuat vmathQMakeFromScalar_V( float scalar ) +{ + VmathQuat result; + vmathQMakeFromScalar(&result, scalar); + return result; +} + +static inline VmathQuat vmathQMakeFrom128_V( vec_float4 vf4 ) +{ + VmathQuat result; + vmathQMakeFrom128(&result, vf4); + return result; +} + +static inline VmathQuat vmathQMakeIdentity_V( ) +{ + VmathQuat result; + vmathQMakeIdentity(&result); + return result; +} + +static inline VmathQuat vmathQLerp_V( float t, VmathQuat quat0, VmathQuat quat1 ) +{ + VmathQuat result; + vmathQLerp(&result, t, &quat0, &quat1); + return result; +} + +static inline VmathQuat vmathQSlerp_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1 ) +{ + VmathQuat result; + vmathQSlerp(&result, t, &unitQuat0, &unitQuat1); + return result; +} + +static inline VmathQuat vmathQSquad_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1, VmathQuat unitQuat2, VmathQuat unitQuat3 ) +{ + VmathQuat result; + vmathQSquad(&result, t, &unitQuat0, &unitQuat1, &unitQuat2, &unitQuat3); + return result; +} + +static inline vec_float4 vmathQGet128_V( VmathQuat quat ) +{ + return vmathQGet128(&quat); +} + +static inline void vmathQSetXYZ_V( VmathQuat *result, VmathVector3 vec ) +{ + vmathQSetXYZ(result, &vec); +} + +static inline VmathVector3 vmathQGetXYZ_V( VmathQuat quat ) +{ + VmathVector3 result; + vmathQGetXYZ(&result, &quat); + return result; +} + +static inline void vmathQSetX_V( VmathQuat *result, float _x ) +{ + vmathQSetX(result, _x); +} + +static inline float vmathQGetX_V( VmathQuat quat ) +{ + return vmathQGetX(&quat); +} + +static inline void vmathQSetY_V( VmathQuat *result, float _y ) +{ + vmathQSetY(result, _y); +} + +static inline float vmathQGetY_V( VmathQuat quat ) +{ + return vmathQGetY(&quat); +} + +static inline void vmathQSetZ_V( VmathQuat *result, float _z ) +{ + vmathQSetZ(result, _z); +} + +static inline float vmathQGetZ_V( VmathQuat quat ) +{ + return vmathQGetZ(&quat); +} + +static inline void vmathQSetW_V( VmathQuat *result, float _w ) +{ + vmathQSetW(result, _w); +} + +static inline float vmathQGetW_V( VmathQuat quat ) +{ + return vmathQGetW(&quat); +} + +static inline void vmathQSetElem_V( VmathQuat *result, int idx, float value ) +{ + vmathQSetElem(result, idx, value); +} + +static inline float vmathQGetElem_V( VmathQuat quat, int idx ) +{ + return vmathQGetElem(&quat, idx); +} + +static inline VmathQuat vmathQAdd_V( VmathQuat quat0, VmathQuat quat1 ) +{ + VmathQuat result; + vmathQAdd(&result, &quat0, &quat1); + return result; +} + +static inline VmathQuat vmathQSub_V( VmathQuat quat0, VmathQuat quat1 ) +{ + VmathQuat result; + vmathQSub(&result, &quat0, &quat1); + return result; +} + +static inline VmathQuat vmathQScalarMul_V( VmathQuat quat, float scalar ) +{ + VmathQuat result; + vmathQScalarMul(&result, &quat, scalar); + return result; +} + +static inline VmathQuat vmathQScalarDiv_V( VmathQuat quat, float scalar ) +{ + VmathQuat result; + vmathQScalarDiv(&result, &quat, scalar); + return result; +} + +static inline VmathQuat vmathQNeg_V( VmathQuat quat ) +{ + VmathQuat result; + vmathQNeg(&result, &quat); + return result; +} + +static inline float vmathQDot_V( VmathQuat quat0, VmathQuat quat1 ) +{ + return vmathQDot(&quat0, &quat1); +} + +static inline float vmathQNorm_V( VmathQuat quat ) +{ + return vmathQNorm(&quat); +} + +static inline float vmathQLength_V( VmathQuat quat ) +{ + return vmathQLength(&quat); +} + +static inline VmathQuat vmathQNormalize_V( VmathQuat quat ) +{ + VmathQuat result; + vmathQNormalize(&result, &quat); + return result; +} + +static inline VmathQuat vmathQMakeRotationArc_V( VmathVector3 unitVec0, VmathVector3 unitVec1 ) +{ + VmathQuat result; + vmathQMakeRotationArc(&result, &unitVec0, &unitVec1); + return result; +} + +static inline VmathQuat vmathQMakeRotationAxis_V( float radians, VmathVector3 unitVec ) +{ + VmathQuat result; + vmathQMakeRotationAxis(&result, radians, &unitVec); + return result; +} + +static inline VmathQuat vmathQMakeRotationX_V( float radians ) +{ + VmathQuat result; + vmathQMakeRotationX(&result, radians); + return result; +} + +static inline VmathQuat vmathQMakeRotationY_V( float radians ) +{ + VmathQuat result; + vmathQMakeRotationY(&result, radians); + return result; +} + +static inline VmathQuat vmathQMakeRotationZ_V( float radians ) +{ + VmathQuat result; + vmathQMakeRotationZ(&result, radians); + return result; +} + +static inline VmathQuat vmathQMul_V( VmathQuat quat0, VmathQuat quat1 ) +{ + VmathQuat result; + vmathQMul(&result, &quat0, &quat1); + return result; +} + +static inline VmathVector3 vmathQRotate_V( VmathQuat quat, VmathVector3 vec ) +{ + VmathVector3 result; + vmathQRotate(&result, &quat, &vec); + return result; +} + +static inline VmathQuat vmathQConj_V( VmathQuat quat ) +{ + VmathQuat result; + vmathQConj(&result, &quat); + return result; +} + +static inline VmathQuat vmathQSelect_V( VmathQuat quat0, VmathQuat quat1, unsigned int select1 ) +{ + VmathQuat result; + vmathQSelect(&result, &quat0, &quat1, select1); + return result; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathQPrint_V( VmathQuat quat ) +{ + vmathQPrint(&quat); +} + +static inline void vmathQPrints_V( VmathQuat quat, const char *name ) +{ + vmathQPrints(&quat, name); +} + +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/vectormathlibrary/include/vectormath/ppu/c/quat_soa.h b/vectormathlibrary/include/vectormath/ppu/c/quat_soa.h new file mode 100644 index 000000000..334c17b01 --- /dev/null +++ b/vectormathlibrary/include/vectormath/ppu/c/quat_soa.h @@ -0,0 +1,415 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_QUAT_SOA_C_H +#define _VECTORMATH_QUAT_SOA_C_H +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/*----------------------------------------------------------------------------- + * Definitions + */ +#ifndef _VECTORMATH_INTERNAL_FUNCTIONS +#define _VECTORMATH_INTERNAL_FUNCTIONS + +#endif + +static inline void vmathSoaQCopy( VmathSoaQuat *result, const VmathSoaQuat *quat ) +{ + result->x = quat->x; + result->y = quat->y; + result->z = quat->z; + result->w = quat->w; +} + +static inline void vmathSoaQMakeFromElems( VmathSoaQuat *result, vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w ) +{ + result->x = _x; + result->y = _y; + result->z = _z; + result->w = _w; +} + +static inline void vmathSoaQMakeFromV3Scalar( VmathSoaQuat *result, const VmathSoaVector3 *xyz, vec_float4 _w ) +{ + vmathSoaQSetXYZ( result, xyz ); + vmathSoaQSetW( result, _w ); +} + +static inline void vmathSoaQMakeFromV4( VmathSoaQuat *result, const VmathSoaVector4 *vec ) +{ + result->x = vec->x; + result->y = vec->y; + result->z = vec->z; + result->w = vec->w; +} + +static inline void vmathSoaQMakeFromScalar( VmathSoaQuat *result, vec_float4 scalar ) +{ + result->x = scalar; + result->y = scalar; + result->z = scalar; + result->w = scalar; +} + +static inline void vmathSoaQMakeFromAos( VmathSoaQuat *result, const VmathQuat *quat ) +{ + vec_float4 vec128 = quat->vec128; + result->x = vec_splat( vec128, 0 ); + result->y = vec_splat( vec128, 1 ); + result->z = vec_splat( vec128, 2 ); + result->w = vec_splat( vec128, 3 ); +} + +static inline void vmathSoaQMakeFrom4Aos( VmathSoaQuat *result, const VmathQuat *quat0, const VmathQuat *quat1, const VmathQuat *quat2, const VmathQuat *quat3 ) +{ + vec_float4 tmp0, tmp1, tmp2, tmp3; + tmp0 = vec_mergeh( quat0->vec128, quat2->vec128 ); + tmp1 = vec_mergeh( quat1->vec128, quat3->vec128 ); + tmp2 = vec_mergel( quat0->vec128, quat2->vec128 ); + tmp3 = vec_mergel( quat1->vec128, quat3->vec128 ); + result->x = vec_mergeh( tmp0, tmp1 ); + result->y = vec_mergel( tmp0, tmp1 ); + result->z = vec_mergeh( tmp2, tmp3 ); + result->w = vec_mergel( tmp2, tmp3 ); +} + +static inline void vmathSoaQMakeIdentity( VmathSoaQuat *result ) +{ + vmathSoaQMakeFromElems( result, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); +} + +static inline void vmathSoaQLerp( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ) +{ + VmathSoaQuat tmpQ_0, tmpQ_1; + vmathSoaQSub( &tmpQ_0, quat1, quat0 ); + vmathSoaQScalarMul( &tmpQ_1, &tmpQ_0, t ); + vmathSoaQAdd( result, quat0, &tmpQ_1 ); +} + +static inline void vmathSoaQSlerp( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *unitQuat0, const VmathSoaQuat *unitQuat1 ) +{ + VmathSoaQuat start, tmpQ_0, tmpQ_1; + vec_float4 recipSinAngle, scale0, scale1, cosAngle, angle; + vec_uint4 selectMask; + cosAngle = vmathSoaQDot( unitQuat0, unitQuat1 ); + selectMask = (vec_uint4)vec_cmpgt( (vec_float4){0.0f,0.0f,0.0f,0.0f}, cosAngle ); + cosAngle = vec_sel( cosAngle, negatef4( cosAngle ), selectMask ); + vmathSoaQSetX( &start, vec_sel( unitQuat0->x, negatef4( unitQuat0->x ), selectMask ) ); + vmathSoaQSetY( &start, vec_sel( unitQuat0->y, negatef4( unitQuat0->y ), selectMask ) ); + vmathSoaQSetZ( &start, vec_sel( unitQuat0->z, negatef4( unitQuat0->z ), selectMask ) ); + vmathSoaQSetW( &start, vec_sel( unitQuat0->w, negatef4( unitQuat0->w ), selectMask ) ); + selectMask = (vec_uint4)vec_cmpgt( (vec_float4){_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL}, cosAngle ); + angle = acosf4( cosAngle ); + recipSinAngle = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sinf4( angle ) ); + scale0 = vec_sel( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), vec_madd( sinf4( vec_madd( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), recipSinAngle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), selectMask ); + scale1 = vec_sel( t, vec_madd( sinf4( vec_madd( t, angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), recipSinAngle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), selectMask ); + vmathSoaQScalarMul( &tmpQ_0, &start, scale0 ); + vmathSoaQScalarMul( &tmpQ_1, unitQuat1, scale1 ); + vmathSoaQAdd( result, &tmpQ_0, &tmpQ_1 ); +} + +static inline void vmathSoaQSquad( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *unitQuat0, const VmathSoaQuat *unitQuat1, const VmathSoaQuat *unitQuat2, const VmathSoaQuat *unitQuat3 ) +{ + VmathSoaQuat tmp0, tmp1; + vmathSoaQSlerp( &tmp0, t, unitQuat0, unitQuat3 ); + vmathSoaQSlerp( &tmp1, t, unitQuat1, unitQuat2 ); + vmathSoaQSlerp( result, vec_madd( vec_madd( ((vec_float4){2.0f,2.0f,2.0f,2.0f}), t, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), &tmp0, &tmp1 ); +} + +static inline void vmathSoaQGet4Aos( const VmathSoaQuat *quat, VmathQuat *result0, VmathQuat *result1, VmathQuat *result2, VmathQuat *result3 ) +{ + vec_float4 tmp0, tmp1, tmp2, tmp3; + tmp0 = vec_mergeh( quat->x, quat->z ); + tmp1 = vec_mergeh( quat->y, quat->w ); + tmp2 = vec_mergel( quat->x, quat->z ); + tmp3 = vec_mergel( quat->y, quat->w ); + vmathQMakeFrom128( result0, vec_mergeh( tmp0, tmp1 ) ); + vmathQMakeFrom128( result1, vec_mergel( tmp0, tmp1 ) ); + vmathQMakeFrom128( result2, vec_mergeh( tmp2, tmp3 ) ); + vmathQMakeFrom128( result3, vec_mergel( tmp2, tmp3 ) ); +} + +static inline void vmathSoaQSetXYZ( VmathSoaQuat *result, const VmathSoaVector3 *vec ) +{ + result->x = vec->x; + result->y = vec->y; + result->z = vec->z; +} + +static inline void vmathSoaQGetXYZ( VmathSoaVector3 *result, const VmathSoaQuat *quat ) +{ + vmathSoaV3MakeFromElems( result, quat->x, quat->y, quat->z ); +} + +static inline void vmathSoaQSetX( VmathSoaQuat *result, vec_float4 _x ) +{ + result->x = _x; +} + +static inline vec_float4 vmathSoaQGetX( const VmathSoaQuat *quat ) +{ + return quat->x; +} + +static inline void vmathSoaQSetY( VmathSoaQuat *result, vec_float4 _y ) +{ + result->y = _y; +} + +static inline vec_float4 vmathSoaQGetY( const VmathSoaQuat *quat ) +{ + return quat->y; +} + +static inline void vmathSoaQSetZ( VmathSoaQuat *result, vec_float4 _z ) +{ + result->z = _z; +} + +static inline vec_float4 vmathSoaQGetZ( const VmathSoaQuat *quat ) +{ + return quat->z; +} + +static inline void vmathSoaQSetW( VmathSoaQuat *result, vec_float4 _w ) +{ + result->w = _w; +} + +static inline vec_float4 vmathSoaQGetW( const VmathSoaQuat *quat ) +{ + return quat->w; +} + +static inline void vmathSoaQSetElem( VmathSoaQuat *result, int idx, vec_float4 value ) +{ + *(&result->x + idx) = value; +} + +static inline vec_float4 vmathSoaQGetElem( const VmathSoaQuat *quat, int idx ) +{ + return *(&quat->x + idx); +} + +static inline void vmathSoaQAdd( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ) +{ + result->x = vec_add( quat0->x, quat1->x ); + result->y = vec_add( quat0->y, quat1->y ); + result->z = vec_add( quat0->z, quat1->z ); + result->w = vec_add( quat0->w, quat1->w ); +} + +static inline void vmathSoaQSub( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ) +{ + result->x = vec_sub( quat0->x, quat1->x ); + result->y = vec_sub( quat0->y, quat1->y ); + result->z = vec_sub( quat0->z, quat1->z ); + result->w = vec_sub( quat0->w, quat1->w ); +} + +static inline void vmathSoaQScalarMul( VmathSoaQuat *result, const VmathSoaQuat *quat, vec_float4 scalar ) +{ + result->x = vec_madd( quat->x, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + result->y = vec_madd( quat->y, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + result->z = vec_madd( quat->z, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + result->w = vec_madd( quat->w, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); +} + +static inline void vmathSoaQScalarDiv( VmathSoaQuat *result, const VmathSoaQuat *quat, vec_float4 scalar ) +{ + result->x = divf4( quat->x, scalar ); + result->y = divf4( quat->y, scalar ); + result->z = divf4( quat->z, scalar ); + result->w = divf4( quat->w, scalar ); +} + +static inline void vmathSoaQNeg( VmathSoaQuat *result, const VmathSoaQuat *quat ) +{ + result->x = negatef4( quat->x ); + result->y = negatef4( quat->y ); + result->z = negatef4( quat->z ); + result->w = negatef4( quat->w ); +} + +static inline vec_float4 vmathSoaQDot( const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ) +{ + vec_float4 result; + result = vec_madd( quat0->x, quat1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + result = vec_add( result, vec_madd( quat0->y, quat1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + result = vec_add( result, vec_madd( quat0->z, quat1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + result = vec_add( result, vec_madd( quat0->w, quat1->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + return result; +} + +static inline vec_float4 vmathSoaQNorm( const VmathSoaQuat *quat ) +{ + vec_float4 result; + result = vec_madd( quat->x, quat->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + result = vec_add( result, vec_madd( quat->y, quat->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + result = vec_add( result, vec_madd( quat->z, quat->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + result = vec_add( result, vec_madd( quat->w, quat->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + return result; +} + +static inline vec_float4 vmathSoaQLength( const VmathSoaQuat *quat ) +{ + return sqrtf4( vmathSoaQNorm( quat ) ); +} + +static inline void vmathSoaQNormalize( VmathSoaQuat *result, const VmathSoaQuat *quat ) +{ + vec_float4 lenSqr, lenInv; + lenSqr = vmathSoaQNorm( quat ); + lenInv = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( lenSqr ) ); + result->x = vec_madd( quat->x, lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + result->y = vec_madd( quat->y, lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + result->z = vec_madd( quat->z, lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + result->w = vec_madd( quat->w, lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); +} + +static inline void vmathSoaQMakeRotationArc( VmathSoaQuat *result, const VmathSoaVector3 *unitVec0, const VmathSoaVector3 *unitVec1 ) +{ + VmathSoaVector3 tmpV3_0, tmpV3_1; + vec_float4 cosHalfAngleX2, recipCosHalfAngleX2; + cosHalfAngleX2 = sqrtf4( vec_madd( ((vec_float4){2.0f,2.0f,2.0f,2.0f}), vec_add( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vmathSoaV3Dot( unitVec0, unitVec1 ) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + recipCosHalfAngleX2 = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), cosHalfAngleX2 ); + vmathSoaV3Cross( &tmpV3_0, unitVec0, unitVec1 ); + vmathSoaV3ScalarMul( &tmpV3_1, &tmpV3_0, recipCosHalfAngleX2 ); + vmathSoaQMakeFromV3Scalar( result, &tmpV3_1, vec_madd( cosHalfAngleX2, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); +} + +static inline void vmathSoaQMakeRotationAxis( VmathSoaQuat *result, vec_float4 radians, const VmathSoaVector3 *unitVec ) +{ + VmathSoaVector3 tmpV3_0; + vec_float4 s, c, angle; + angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + sincosf4( angle, &s, &c ); + vmathSoaV3ScalarMul( &tmpV3_0, unitVec, s ); + vmathSoaQMakeFromV3Scalar( result, &tmpV3_0, c ); +} + +static inline void vmathSoaQMakeRotationX( VmathSoaQuat *result, vec_float4 radians ) +{ + vec_float4 s, c, angle; + angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + sincosf4( angle, &s, &c ); + vmathSoaQMakeFromElems( result, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c ); +} + +static inline void vmathSoaQMakeRotationY( VmathSoaQuat *result, vec_float4 radians ) +{ + vec_float4 s, c, angle; + angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + sincosf4( angle, &s, &c ); + vmathSoaQMakeFromElems( result, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c ); +} + +static inline void vmathSoaQMakeRotationZ( VmathSoaQuat *result, vec_float4 radians ) +{ + vec_float4 s, c, angle; + angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + sincosf4( angle, &s, &c ); + vmathSoaQMakeFromElems( result, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, c ); +} + +static inline void vmathSoaQMul( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ) +{ + vec_float4 tmpX, tmpY, tmpZ, tmpW; + tmpX = vec_sub( vec_add( vec_add( vec_madd( quat0->w, quat1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat0->x, quat1->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->y, quat1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->z, quat1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmpY = vec_sub( vec_add( vec_add( vec_madd( quat0->w, quat1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat0->y, quat1->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->z, quat1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->x, quat1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmpZ = vec_sub( vec_add( vec_add( vec_madd( quat0->w, quat1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat0->z, quat1->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->x, quat1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->y, quat1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmpW = vec_sub( vec_sub( vec_sub( vec_madd( quat0->w, quat1->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat0->x, quat1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->y, quat1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->z, quat1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + vmathSoaQMakeFromElems( result, tmpX, tmpY, tmpZ, tmpW ); +} + +static inline void vmathSoaQRotate( VmathSoaVector3 *result, const VmathSoaQuat *quat, const VmathSoaVector3 *vec ) +{ + vec_float4 tmpX, tmpY, tmpZ, tmpW; + tmpX = vec_sub( vec_add( vec_madd( quat->w, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat->y, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat->z, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmpY = vec_sub( vec_add( vec_madd( quat->w, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat->z, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat->x, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmpZ = vec_sub( vec_add( vec_madd( quat->w, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat->x, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat->y, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmpW = vec_add( vec_add( vec_madd( quat->x, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat->y, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat->z, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + result->x = vec_add( vec_sub( vec_add( vec_madd( tmpW, quat->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmpX, quat->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpY, quat->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpZ, quat->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + result->y = vec_add( vec_sub( vec_add( vec_madd( tmpW, quat->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmpY, quat->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpZ, quat->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpX, quat->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + result->z = vec_add( vec_sub( vec_add( vec_madd( tmpW, quat->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmpZ, quat->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpX, quat->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpY, quat->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); +} + +static inline void vmathSoaQConj( VmathSoaQuat *result, const VmathSoaQuat *quat ) +{ + vmathSoaQMakeFromElems( result, negatef4( quat->x ), negatef4( quat->y ), negatef4( quat->z ), quat->w ); +} + +static inline void vmathSoaQSelect( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1, vec_uint4 select1 ) +{ + result->x = vec_sel( quat0->x, quat1->x, select1 ); + result->y = vec_sel( quat0->y, quat1->y, select1 ); + result->z = vec_sel( quat0->z, quat1->z, select1 ); + result->w = vec_sel( quat0->w, quat1->w, select1 ); +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathSoaQPrint( const VmathSoaQuat *quat ) +{ + VmathQuat vec0, vec1, vec2, vec3; + vmathSoaQGet4Aos( quat, &vec0, &vec1, &vec2, &vec3 ); + printf("slot 0:\n"); + vmathQPrint( &vec0 ); + printf("slot 1:\n"); + vmathQPrint( &vec1 ); + printf("slot 2:\n"); + vmathQPrint( &vec2 ); + printf("slot 3:\n"); + vmathQPrint( &vec3 ); +} + +static inline void vmathSoaQPrints( const VmathSoaQuat *quat, const char *name ) +{ + VmathQuat vec0, vec1, vec2, vec3; + printf( "%s:\n", name ); + vmathSoaQGet4Aos( quat, &vec0, &vec1, &vec2, &vec3 ); + printf("slot 0:\n"); + vmathQPrint( &vec0 ); + printf("slot 1:\n"); + vmathQPrint( &vec1 ); + printf("slot 2:\n"); + vmathQPrint( &vec2 ); + printf("slot 3:\n"); + vmathQPrint( &vec3 ); +} + +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/vectormathlibrary/include/vectormath/ppu/c/quat_soa_v.h b/vectormathlibrary/include/vectormath/ppu/c/quat_soa_v.h new file mode 100644 index 000000000..601d9da92 --- /dev/null +++ b/vectormathlibrary/include/vectormath/ppu/c/quat_soa_v.h @@ -0,0 +1,319 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_QUAT_SOA_V_C_H +#define _VECTORMATH_QUAT_SOA_V_C_H +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/*----------------------------------------------------------------------------- + * Definitions + */ +#ifndef _VECTORMATH_INTERNAL_FUNCTIONS +#define _VECTORMATH_INTERNAL_FUNCTIONS + +#endif + +static inline VmathSoaQuat vmathSoaQMakeFromElems_V( vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w ) +{ + VmathSoaQuat result; + vmathSoaQMakeFromElems(&result, _x, _y, _z, _w); + return result; +} + +static inline VmathSoaQuat vmathSoaQMakeFromV3Scalar_V( VmathSoaVector3 xyz, vec_float4 _w ) +{ + VmathSoaQuat result; + vmathSoaQMakeFromV3Scalar(&result, &xyz, _w); + return result; +} + +static inline VmathSoaQuat vmathSoaQMakeFromV4_V( VmathSoaVector4 vec ) +{ + VmathSoaQuat result; + vmathSoaQMakeFromV4(&result, &vec); + return result; +} + +static inline VmathSoaQuat vmathSoaQMakeFromScalar_V( vec_float4 scalar ) +{ + VmathSoaQuat result; + vmathSoaQMakeFromScalar(&result, scalar); + return result; +} + +static inline VmathSoaQuat vmathSoaQMakeFromAos_V( VmathQuat quat ) +{ + VmathSoaQuat result; + vmathSoaQMakeFromAos(&result, &quat); + return result; +} + +static inline VmathSoaQuat vmathSoaQMakeFrom4Aos_V( VmathQuat quat0, VmathQuat quat1, VmathQuat quat2, VmathQuat quat3 ) +{ + VmathSoaQuat result; + vmathSoaQMakeFrom4Aos(&result, &quat0, &quat1, &quat2, &quat3); + return result; +} + +static inline VmathSoaQuat vmathSoaQMakeIdentity_V( ) +{ + VmathSoaQuat result; + vmathSoaQMakeIdentity(&result); + return result; +} + +static inline VmathSoaQuat vmathSoaQLerp_V( vec_float4 t, VmathSoaQuat quat0, VmathSoaQuat quat1 ) +{ + VmathSoaQuat result; + vmathSoaQLerp(&result, t, &quat0, &quat1); + return result; +} + +static inline VmathSoaQuat vmathSoaQSlerp_V( vec_float4 t, VmathSoaQuat unitQuat0, VmathSoaQuat unitQuat1 ) +{ + VmathSoaQuat result; + vmathSoaQSlerp(&result, t, &unitQuat0, &unitQuat1); + return result; +} + +static inline VmathSoaQuat vmathSoaQSquad_V( vec_float4 t, VmathSoaQuat unitQuat0, VmathSoaQuat unitQuat1, VmathSoaQuat unitQuat2, VmathSoaQuat unitQuat3 ) +{ + VmathSoaQuat result; + vmathSoaQSquad(&result, t, &unitQuat0, &unitQuat1, &unitQuat2, &unitQuat3); + return result; +} + +static inline void vmathSoaQGet4Aos_V( VmathSoaQuat quat, VmathQuat *result0, VmathQuat *result1, VmathQuat *result2, VmathQuat *result3 ) +{ + vmathSoaQGet4Aos(&quat, result0, result1, result2, result3); +} + +static inline void vmathSoaQSetXYZ_V( VmathSoaQuat *result, VmathSoaVector3 vec ) +{ + vmathSoaQSetXYZ(result, &vec); +} + +static inline VmathSoaVector3 vmathSoaQGetXYZ_V( VmathSoaQuat quat ) +{ + VmathSoaVector3 result; + vmathSoaQGetXYZ(&result, &quat); + return result; +} + +static inline void vmathSoaQSetX_V( VmathSoaQuat *result, vec_float4 _x ) +{ + vmathSoaQSetX(result, _x); +} + +static inline vec_float4 vmathSoaQGetX_V( VmathSoaQuat quat ) +{ + return vmathSoaQGetX(&quat); +} + +static inline void vmathSoaQSetY_V( VmathSoaQuat *result, vec_float4 _y ) +{ + vmathSoaQSetY(result, _y); +} + +static inline vec_float4 vmathSoaQGetY_V( VmathSoaQuat quat ) +{ + return vmathSoaQGetY(&quat); +} + +static inline void vmathSoaQSetZ_V( VmathSoaQuat *result, vec_float4 _z ) +{ + vmathSoaQSetZ(result, _z); +} + +static inline vec_float4 vmathSoaQGetZ_V( VmathSoaQuat quat ) +{ + return vmathSoaQGetZ(&quat); +} + +static inline void vmathSoaQSetW_V( VmathSoaQuat *result, vec_float4 _w ) +{ + vmathSoaQSetW(result, _w); +} + +static inline vec_float4 vmathSoaQGetW_V( VmathSoaQuat quat ) +{ + return vmathSoaQGetW(&quat); +} + +static inline void vmathSoaQSetElem_V( VmathSoaQuat *result, int idx, vec_float4 value ) +{ + vmathSoaQSetElem(result, idx, value); +} + +static inline vec_float4 vmathSoaQGetElem_V( VmathSoaQuat quat, int idx ) +{ + return vmathSoaQGetElem(&quat, idx); +} + +static inline VmathSoaQuat vmathSoaQAdd_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ) +{ + VmathSoaQuat result; + vmathSoaQAdd(&result, &quat0, &quat1); + return result; +} + +static inline VmathSoaQuat vmathSoaQSub_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ) +{ + VmathSoaQuat result; + vmathSoaQSub(&result, &quat0, &quat1); + return result; +} + +static inline VmathSoaQuat vmathSoaQScalarMul_V( VmathSoaQuat quat, vec_float4 scalar ) +{ + VmathSoaQuat result; + vmathSoaQScalarMul(&result, &quat, scalar); + return result; +} + +static inline VmathSoaQuat vmathSoaQScalarDiv_V( VmathSoaQuat quat, vec_float4 scalar ) +{ + VmathSoaQuat result; + vmathSoaQScalarDiv(&result, &quat, scalar); + return result; +} + +static inline VmathSoaQuat vmathSoaQNeg_V( VmathSoaQuat quat ) +{ + VmathSoaQuat result; + vmathSoaQNeg(&result, &quat); + return result; +} + +static inline vec_float4 vmathSoaQDot_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ) +{ + return vmathSoaQDot(&quat0, &quat1); +} + +static inline vec_float4 vmathSoaQNorm_V( VmathSoaQuat quat ) +{ + return vmathSoaQNorm(&quat); +} + +static inline vec_float4 vmathSoaQLength_V( VmathSoaQuat quat ) +{ + return vmathSoaQLength(&quat); +} + +static inline VmathSoaQuat vmathSoaQNormalize_V( VmathSoaQuat quat ) +{ + VmathSoaQuat result; + vmathSoaQNormalize(&result, &quat); + return result; +} + +static inline VmathSoaQuat vmathSoaQMakeRotationArc_V( VmathSoaVector3 unitVec0, VmathSoaVector3 unitVec1 ) +{ + VmathSoaQuat result; + vmathSoaQMakeRotationArc(&result, &unitVec0, &unitVec1); + return result; +} + +static inline VmathSoaQuat vmathSoaQMakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec ) +{ + VmathSoaQuat result; + vmathSoaQMakeRotationAxis(&result, radians, &unitVec); + return result; +} + +static inline VmathSoaQuat vmathSoaQMakeRotationX_V( vec_float4 radians ) +{ + VmathSoaQuat result; + vmathSoaQMakeRotationX(&result, radians); + return result; +} + +static inline VmathSoaQuat vmathSoaQMakeRotationY_V( vec_float4 radians ) +{ + VmathSoaQuat result; + vmathSoaQMakeRotationY(&result, radians); + return result; +} + +static inline VmathSoaQuat vmathSoaQMakeRotationZ_V( vec_float4 radians ) +{ + VmathSoaQuat result; + vmathSoaQMakeRotationZ(&result, radians); + return result; +} + +static inline VmathSoaQuat vmathSoaQMul_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ) +{ + VmathSoaQuat result; + vmathSoaQMul(&result, &quat0, &quat1); + return result; +} + +static inline VmathSoaVector3 vmathSoaQRotate_V( VmathSoaQuat quat, VmathSoaVector3 vec ) +{ + VmathSoaVector3 result; + vmathSoaQRotate(&result, &quat, &vec); + return result; +} + +static inline VmathSoaQuat vmathSoaQConj_V( VmathSoaQuat quat ) +{ + VmathSoaQuat result; + vmathSoaQConj(&result, &quat); + return result; +} + +static inline VmathSoaQuat vmathSoaQSelect_V( VmathSoaQuat quat0, VmathSoaQuat quat1, vec_uint4 select1 ) +{ + VmathSoaQuat result; + vmathSoaQSelect(&result, &quat0, &quat1, select1); + return result; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathSoaQPrint_V( VmathSoaQuat quat ) +{ + vmathSoaQPrint(&quat); +} + +static inline void vmathSoaQPrints_V( VmathSoaQuat quat, const char *name ) +{ + vmathSoaQPrints(&quat, name); +} + +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/vectormathlibrary/include/vectormath/ppu/c/vec_aos.h b/vectormathlibrary/include/vectormath/ppu/c/vec_aos.h new file mode 100644 index 000000000..58427a224 --- /dev/null +++ b/vectormathlibrary/include/vectormath/ppu/c/vec_aos.h @@ -0,0 +1,1125 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_VEC_AOS_C_H +#define _VECTORMATH_VEC_AOS_C_H +#include <altivec.h> +#include <simdmath.h> +#include <stddef.h> +#include "vec_types.h" +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/*----------------------------------------------------------------------------- + * Constants + * for permutes words are labeled [x,y,z,w] [a,b,c,d] + */ +#define _VECTORMATH_PERM_X 0x00010203 +#define _VECTORMATH_PERM_Y 0x04050607 +#define _VECTORMATH_PERM_Z 0x08090a0b +#define _VECTORMATH_PERM_W 0x0c0d0e0f +#define _VECTORMATH_PERM_A 0x10111213 +#define _VECTORMATH_PERM_B 0x14151617 +#define _VECTORMATH_PERM_C 0x18191a1b +#define _VECTORMATH_PERM_D 0x1c1d1e1f +#define _VECTORMATH_PERM_XYZA (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A } +#define _VECTORMATH_PERM_ZXYW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_W } +#define _VECTORMATH_PERM_YZXW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_W } +#define _VECTORMATH_PERM_YZAB (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A, _VECTORMATH_PERM_B } +#define _VECTORMATH_PERM_ZABC (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A, _VECTORMATH_PERM_B, _VECTORMATH_PERM_C } +#define _VECTORMATH_PERM_XYAW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A, _VECTORMATH_PERM_W } +#define _VECTORMATH_PERM_XAZW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_A, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_W } +#define _VECTORMATH_MASK_0xF000 (vec_uint4){ 0xffffffff, 0, 0, 0 } +#define _VECTORMATH_MASK_0x0F00 (vec_uint4){ 0, 0xffffffff, 0, 0 } +#define _VECTORMATH_MASK_0x00F0 (vec_uint4){ 0, 0, 0xffffffff, 0 } +#define _VECTORMATH_MASK_0x000F (vec_uint4){ 0, 0, 0, 0xffffffff } +#define _VECTORMATH_UNIT_1000 (vec_float4){ 1.0f, 0.0f, 0.0f, 0.0f } +#define _VECTORMATH_UNIT_0100 (vec_float4){ 0.0f, 1.0f, 0.0f, 0.0f } +#define _VECTORMATH_UNIT_0010 (vec_float4){ 0.0f, 0.0f, 1.0f, 0.0f } +#define _VECTORMATH_UNIT_0001 (vec_float4){ 0.0f, 0.0f, 0.0f, 1.0f } +#define _VECTORMATH_SLERP_TOL 0.999f + +/*----------------------------------------------------------------------------- + * Definitions + */ +#ifndef _VECTORMATH_INTERNAL_FUNCTIONS +#define _VECTORMATH_INTERNAL_FUNCTIONS + +static inline vec_float4 _vmathVfDot3( vec_float4 vec0, vec_float4 vec1 ) +{ + vec_float4 result; + result = vec_madd( vec0, vec1, (vec_float4){0.0f,0.0f,0.0f,0.0f} ); + result = vec_madd( vec_sld( vec0, vec0, 4 ), vec_sld( vec1, vec1, 4 ), result ); + return vec_madd( vec_sld( vec0, vec0, 8 ), vec_sld( vec1, vec1, 8 ), result ); +} + +static inline vec_float4 _vmathVfDot4( vec_float4 vec0, vec_float4 vec1 ) +{ + vec_float4 result; + result = vec_madd( vec0, vec1, (vec_float4){0.0f,0.0f,0.0f,0.0f} ); + result = vec_madd( vec_sld( vec0, vec0, 4 ), vec_sld( vec1, vec1, 4 ), result ); + return vec_add( vec_sld( result, result, 8 ), result ); +} + +static inline vec_float4 _vmathVfCross( vec_float4 vec0, vec_float4 vec1 ) +{ + vec_float4 tmp0, tmp1, tmp2, tmp3, result; + tmp0 = vec_perm( vec0, vec0, _VECTORMATH_PERM_YZXW ); + tmp1 = vec_perm( vec1, vec1, _VECTORMATH_PERM_ZXYW ); + tmp2 = vec_perm( vec0, vec0, _VECTORMATH_PERM_ZXYW ); + tmp3 = vec_perm( vec1, vec1, _VECTORMATH_PERM_YZXW ); + result = vec_madd( tmp0, tmp1, (vec_float4){0.0f,0.0f,0.0f,0.0f} ); + result = vec_nmsub( tmp2, tmp3, result ); + return result; +} + +static inline vec_uint4 _vmathVfToHalfFloatsUnpacked(vec_float4 v) +{ + vec_int4 bexp; + vec_uint4 mant, sign, hfloat; + vec_uint4 notZero, isInf; + const vec_uint4 hfloatInf = (vec_uint4){0x00007c00u,0x00007c00u,0x00007c00u,0x00007c00u}; + const vec_uint4 mergeMant = (vec_uint4){0x000003ffu,0x000003ffu,0x000003ffu,0x000003ffu}; + const vec_uint4 mergeSign = (vec_uint4){0x00008000u,0x00008000u,0x00008000u,0x00008000u}; + + sign = vec_sr((vec_uint4)v, (vec_uint4){16,16,16,16}); + mant = vec_sr((vec_uint4)v, (vec_uint4){13,13,13,13}); + bexp = vec_and(vec_sr((vec_int4)v, (vec_uint4){23,23,23,23}), (vec_int4){0xff,0xff,0xff,0xff}); + + notZero = (vec_uint4)vec_cmpgt(bexp, (vec_int4){112,112,112,112}); + isInf = (vec_uint4)vec_cmpgt(bexp, (vec_int4){142,142,142,142}); + + bexp = vec_add(bexp, (vec_int4){-112,-112,-112,-112}); + bexp = vec_sl(bexp, (vec_uint4){10,10,10,10}); + + hfloat = vec_sel((vec_uint4)bexp, mant, mergeMant); + hfloat = vec_sel((vec_uint4){0,0,0,0}, hfloat, notZero); + hfloat = vec_sel(hfloat, hfloatInf, isInf); + hfloat = vec_sel(hfloat, sign, mergeSign); + + return hfloat; +} + +static inline vec_ushort8 _vmath2VfToHalfFloats(vec_float4 u, vec_float4 v) +{ + vec_uint4 hfloat_u, hfloat_v; + const vec_uchar16 pack = (vec_uchar16){2,3,6,7,10,11,14,15,18,19,22,23,26,27,30,31}; + hfloat_u = _vmathVfToHalfFloatsUnpacked(u); + hfloat_v = _vmathVfToHalfFloatsUnpacked(v); + return (vec_ushort8)vec_perm(hfloat_u, hfloat_v, pack); +} + +#ifndef __GNUC__ +#define __builtin_constant_p(x) 0 +#endif + +static inline vec_float4 _vmathVfInsert(vec_float4 dst, vec_float4 src, int slot) +{ +#ifdef __GNUC__ + if (__builtin_constant_p(slot)) { + dst = vec_sld(dst, dst, slot<<2); + dst = vec_sld(dst, src, 4); + if (slot != 3) dst = vec_sld(dst, dst, (3-slot)<<2); + return dst; + } else +#endif + { + vec_uchar16 shiftpattern = vec_lvsr( 0, (float *)(size_t)(slot<<2) ); + vec_uint4 selectmask = (vec_uint4)vec_perm( (vec_uint4){0,0,0,0}, _VECTORMATH_MASK_0xF000, shiftpattern ); + return vec_sel( dst, src, selectmask ); + } +} + +#define _vmathVfGetElement(vec, slot) ((float *)&(vec))[slot] +#ifdef _VECTORMATH_SET_CONSTS_IN_MEM +#define _vmathVfSetElement(vec, scalar, slot) ((float *)&(vec))[slot] = scalar +#else +#define _vmathVfSetElement(vec, scalar, slot) \ +{ \ + if (__builtin_constant_p(scalar)) { \ + (vec) = _vmathVfInsert(vec, (vec_float4){scalar, scalar, scalar, scalar}, slot); \ + } else { \ + ((float *)&(vec))[slot] = scalar; \ + } \ +} +#endif + +static inline vec_float4 _vmathVfSplatScalar(float scalar) +{ + vec_float4 result; + if (__builtin_constant_p(scalar)) { + result = (vec_float4){scalar, scalar, scalar, scalar}; + } else { + result = vec_ld(0, &scalar); + result = vec_splat(vec_perm(result, result, vec_lvsl(0, &scalar)), 0); + } + return result; +} + +static inline vec_uint4 _vmathVuiSplatScalar(unsigned int scalar) +{ + vec_uint4 result; + if (__builtin_constant_p(scalar)) { + result = (vec_uint4){scalar, scalar, scalar, scalar}; + } else { + result = vec_ld(0, &scalar); + result = vec_splat(vec_perm(result, result, vec_lvsl(0, &scalar)), 0); + } + return result; +} + +#endif + +static inline void vmathV3Copy( VmathVector3 *result, const VmathVector3 *vec ) +{ + result->vec128 = vec->vec128; +} + +static inline void vmathV3MakeFromElems( VmathVector3 *result, float _x, float _y, float _z ) +{ + if (__builtin_constant_p(_x) & __builtin_constant_p(_y) & __builtin_constant_p(_z)) { + result->vec128 = (vec_float4){_x, _y, _z, 0.0f}; + } else { + float *pf = (float *)&result->vec128; + pf[0] = _x; + pf[1] = _y; + pf[2] = _z; + } +} + +static inline void vmathV3MakeFromP3( VmathVector3 *result, const VmathPoint3 *pnt ) +{ + result->vec128 = pnt->vec128; +} + +static inline void vmathV3MakeFromScalar( VmathVector3 *result, float scalar ) +{ + result->vec128 = _vmathVfSplatScalar(scalar); +} + +static inline void vmathV3MakeFrom128( VmathVector3 *result, vec_float4 vf4 ) +{ + result->vec128 = vf4; +} + +static inline void vmathV3MakeXAxis( VmathVector3 *result ) +{ + result->vec128 = _VECTORMATH_UNIT_1000; +} + +static inline void vmathV3MakeYAxis( VmathVector3 *result ) +{ + result->vec128 = _VECTORMATH_UNIT_0100; +} + +static inline void vmathV3MakeZAxis( VmathVector3 *result ) +{ + result->vec128 = _VECTORMATH_UNIT_0010; +} + +static inline void vmathV3Lerp( VmathVector3 *result, float t, const VmathVector3 *vec0, const VmathVector3 *vec1 ) +{ + VmathVector3 tmpV3_0, tmpV3_1; + vmathV3Sub( &tmpV3_0, vec1, vec0 ); + vmathV3ScalarMul( &tmpV3_1, &tmpV3_0, t ); + vmathV3Add( result, vec0, &tmpV3_1 ); +} + +static inline void vmathV3Slerp( VmathVector3 *result, float t, const VmathVector3 *unitVec0, const VmathVector3 *unitVec1 ) +{ + vec_float4 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines; + vec_uint4 selectMask; + cosAngle = _vmathVfDot3( unitVec0->vec128, unitVec1->vec128 ); + cosAngle = vec_splat( cosAngle, 0 ); + selectMask = (vec_uint4)vec_cmpgt( ((vec_float4){_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL}), cosAngle ); + angle = acosf4( cosAngle ); + tttt = _vmathVfSplatScalar(t); + oneMinusT = vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), tttt ); + angles = vec_mergeh( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), tttt ); + angles = vec_mergeh( angles, oneMinusT ); + angles = vec_madd( angles, angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + sines = sinf4( angles ); + scales = divf4( sines, vec_splat( sines, 0 ) ); + scale0 = vec_sel( oneMinusT, vec_splat( scales, 1 ), selectMask ); + scale1 = vec_sel( tttt, vec_splat( scales, 2 ), selectMask ); + result->vec128 = vec_madd( unitVec0->vec128, scale0, vec_madd( unitVec1->vec128, scale1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); +} + +static inline vec_float4 vmathV3Get128( const VmathVector3 *vec ) +{ + return vec->vec128; +} + +static inline void vmathV3StoreXYZ( const VmathVector3 *vec, vec_float4 *quad ) +{ + vec_float4 dstVec = *quad; + vec_uint4 mask = _VECTORMATH_MASK_0x000F; + dstVec = vec_sel(vec->vec128, dstVec, mask); + *quad = dstVec; +} + +static inline void vmathV3LoadXYZArray( VmathVector3 *vec0, VmathVector3 *vec1, VmathVector3 *vec2, VmathVector3 *vec3, const vec_float4 *threeQuads ) +{ + vec_float4 xyzx, yzxy, zxyz, xyz1, xyz2, xyz3; + xyzx = threeQuads[0]; + yzxy = threeQuads[1]; + zxyz = threeQuads[2]; + xyz1 = vec_sld( xyzx, yzxy, 12 ); + xyz2 = vec_sld( yzxy, zxyz, 8 ); + xyz3 = vec_sld( zxyz, zxyz, 4 ); + vec0->vec128 = xyzx; + vec1->vec128 = xyz1; + vec2->vec128 = xyz2; + vec3->vec128 = xyz3; +} + +static inline void vmathV3StoreXYZArray( const VmathVector3 *vec0, const VmathVector3 *vec1, const VmathVector3 *vec2, const VmathVector3 *vec3, vec_float4 *threeQuads ) +{ + vec_float4 xyzx, yzxy, zxyz; + xyzx = vec_perm( vec0->vec128, vec1->vec128, _VECTORMATH_PERM_XYZA ); + yzxy = vec_perm( vec1->vec128, vec2->vec128, _VECTORMATH_PERM_YZAB ); + zxyz = vec_perm( vec2->vec128, vec3->vec128, _VECTORMATH_PERM_ZABC ); + threeQuads[0] = xyzx; + threeQuads[1] = yzxy; + threeQuads[2] = zxyz; +} + +static inline void vmathV3StoreHalfFloats( const VmathVector3 *vec0, const VmathVector3 *vec1, const VmathVector3 *vec2, const VmathVector3 *vec3, const VmathVector3 *vec4, const VmathVector3 *vec5, const VmathVector3 *vec6, const VmathVector3 *vec7, vec_ushort8 *threeQuads ) +{ + vec_float4 xyz0[3]; + vec_float4 xyz1[3]; + vmathV3StoreXYZArray( vec0, vec1, vec2, vec3, xyz0 ); + vmathV3StoreXYZArray( vec4, vec5, vec6, vec7, xyz1 ); + threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); + threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); + threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); +} + +static inline void vmathV3SetX( VmathVector3 *result, float _x ) +{ + _vmathVfSetElement(result->vec128, _x, 0); +} + +static inline float vmathV3GetX( const VmathVector3 *vec ) +{ + return _vmathVfGetElement(vec->vec128, 0); +} + +static inline void vmathV3SetY( VmathVector3 *result, float _y ) +{ + _vmathVfSetElement(result->vec128, _y, 1); +} + +static inline float vmathV3GetY( const VmathVector3 *vec ) +{ + return _vmathVfGetElement(vec->vec128, 1); +} + +static inline void vmathV3SetZ( VmathVector3 *result, float _z ) +{ + _vmathVfSetElement(result->vec128, _z, 2); +} + +static inline float vmathV3GetZ( const VmathVector3 *vec ) +{ + return _vmathVfGetElement(vec->vec128, 2); +} + +static inline void vmathV3SetElem( VmathVector3 *result, int idx, float value ) +{ + _vmathVfSetElement(result->vec128, value, idx); +} + +static inline float vmathV3GetElem( const VmathVector3 *vec, int idx ) +{ + return _vmathVfGetElement(vec->vec128, idx); +} + +static inline void vmathV3Add( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) +{ + result->vec128 = vec_add( vec0->vec128, vec1->vec128 ); +} + +static inline void vmathV3Sub( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) +{ + result->vec128 = vec_sub( vec0->vec128, vec1->vec128 ); +} + +static inline void vmathV3AddP3( VmathPoint3 *result, const VmathVector3 *vec, const VmathPoint3 *pnt1 ) +{ + result->vec128 = vec_add( vec->vec128, pnt1->vec128 ); +} + +static inline void vmathV3ScalarMul( VmathVector3 *result, const VmathVector3 *vec, float scalar ) +{ + result->vec128 = vec_madd( vec->vec128, _vmathVfSplatScalar(scalar), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); +} + +static inline void vmathV3ScalarDiv( VmathVector3 *result, const VmathVector3 *vec, float scalar ) +{ + result->vec128 = divf4( vec->vec128, _vmathVfSplatScalar(scalar) ); +} + +static inline void vmathV3Neg( VmathVector3 *result, const VmathVector3 *vec ) +{ + result->vec128 = negatef4( vec->vec128 ); +} + +static inline void vmathV3MulPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) +{ + result->vec128 = vec_madd( vec0->vec128, vec1->vec128, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); +} + +static inline void vmathV3DivPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) +{ + result->vec128 = divf4( vec0->vec128, vec1->vec128 ); +} + +static inline void vmathV3RecipPerElem( VmathVector3 *result, const VmathVector3 *vec ) +{ + result->vec128 = recipf4( vec->vec128 ); +} + +static inline void vmathV3SqrtPerElem( VmathVector3 *result, const VmathVector3 *vec ) +{ + result->vec128 = sqrtf4( vec->vec128 ); +} + +static inline void vmathV3RsqrtPerElem( VmathVector3 *result, const VmathVector3 *vec ) +{ + result->vec128 = rsqrtf4( vec->vec128 ); +} + +static inline void vmathV3AbsPerElem( VmathVector3 *result, const VmathVector3 *vec ) +{ + result->vec128 = fabsf4( vec->vec128 ); +} + +static inline void vmathV3CopySignPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) +{ + result->vec128 = copysignf4( vec0->vec128, vec1->vec128 ); +} + +static inline void vmathV3MaxPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) +{ + result->vec128 = fmaxf4( vec0->vec128, vec1->vec128 ); +} + +static inline float vmathV3MaxElem( const VmathVector3 *vec ) +{ + vec_float4 result; + result = fmaxf4( vec_splat( vec->vec128, 1 ), vec->vec128 ); + result = fmaxf4( vec_splat( vec->vec128, 2 ), result ); + return _vmathVfGetElement(result, 0); +} + +static inline void vmathV3MinPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) +{ + result->vec128 = fminf4( vec0->vec128, vec1->vec128 ); +} + +static inline float vmathV3MinElem( const VmathVector3 *vec ) +{ + vec_float4 result; + result = fminf4( vec_splat( vec->vec128, 1 ), vec->vec128 ); + result = fminf4( vec_splat( vec->vec128, 2 ), result ); + return _vmathVfGetElement(result, 0); +} + +static inline float vmathV3Sum( const VmathVector3 *vec ) +{ + vec_float4 result; + result = vec_add( vec_splat( vec->vec128, 1 ), vec->vec128 ); + result = vec_add( vec_splat( vec->vec128, 2 ), result ); + return _vmathVfGetElement(result, 0); +} + +static inline float vmathV3Dot( const VmathVector3 *vec0, const VmathVector3 *vec1 ) +{ + vec_float4 result = _vmathVfDot3( vec0->vec128, vec1->vec128 ); + return _vmathVfGetElement(result, 0); +} + +static inline float vmathV3LengthSqr( const VmathVector3 *vec ) +{ + vec_float4 result = _vmathVfDot3( vec->vec128, vec->vec128 ); + return _vmathVfGetElement(result, 0); +} + +static inline float vmathV3Length( const VmathVector3 *vec ) +{ + return sqrtf( vmathV3LengthSqr( vec ) ); +} + +static inline void vmathV3Normalize( VmathVector3 *result, const VmathVector3 *vec ) +{ + vec_float4 dot = _vmathVfDot3( vec->vec128, vec->vec128 ); + dot = vec_splat( dot, 0 ); + result->vec128 = vec_madd( vec->vec128, rsqrtf4( dot ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); +} + +static inline void vmathV3Cross( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) +{ + result->vec128 = _vmathVfCross( vec0->vec128, vec1->vec128 ); +} + +static inline void vmathV3Select( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1, unsigned int select1 ) +{ + unsigned int tmp; + tmp = (unsigned int)-(select1 > 0); + result->vec128 = vec_sel( vec0->vec128, vec1->vec128, _vmathVuiSplatScalar(tmp) ); +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathV3Print( const VmathVector3 *vec ) +{ + union { vec_float4 v; float s[4]; } tmp; + tmp.v = vec->vec128; + printf( "( %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2] ); +} + +static inline void vmathV3Prints( const VmathVector3 *vec, const char *name ) +{ + union { vec_float4 v; float s[4]; } tmp; + tmp.v = vec->vec128; + printf( "%s: ( %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2] ); +} + +#endif + +static inline void vmathV4Copy( VmathVector4 *result, const VmathVector4 *vec ) +{ + result->vec128 = vec->vec128; +} + +static inline void vmathV4MakeFromElems( VmathVector4 *result, float _x, float _y, float _z, float _w ) +{ + if (__builtin_constant_p(_x) & __builtin_constant_p(_y) & + __builtin_constant_p(_z) & __builtin_constant_p(_w)) { + result->vec128 = (vec_float4){_x, _y, _z, _w}; + } else { + float *pf = (float *)&result->vec128; + pf[0] = _x; + pf[1] = _y; + pf[2] = _z; + pf[3] = _w; + } +} + +static inline void vmathV4MakeFromV3Scalar( VmathVector4 *result, const VmathVector3 *xyz, float _w ) +{ + result->vec128 = xyz->vec128; + _vmathVfSetElement(result->vec128, _w, 3); +} + +static inline void vmathV4MakeFromV3( VmathVector4 *result, const VmathVector3 *vec ) +{ + result->vec128 = vec->vec128; + result->vec128 = _vmathVfInsert(result->vec128, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), 3); +} + +static inline void vmathV4MakeFromP3( VmathVector4 *result, const VmathPoint3 *pnt ) +{ + result->vec128 = pnt->vec128; + result->vec128 = _vmathVfInsert(result->vec128, ((vec_float4){1.0f,1.0f,1.0f,1.0f}), 3); +} + +static inline void vmathV4MakeFromQ( VmathVector4 *result, const VmathQuat *quat ) +{ + result->vec128 = quat->vec128; +} + +static inline void vmathV4MakeFromScalar( VmathVector4 *result, float scalar ) +{ + result->vec128 = _vmathVfSplatScalar(scalar); +} + +static inline void vmathV4MakeFrom128( VmathVector4 *result, vec_float4 vf4 ) +{ + result->vec128 = vf4; +} + +static inline void vmathV4MakeXAxis( VmathVector4 *result ) +{ + result->vec128 = _VECTORMATH_UNIT_1000; +} + +static inline void vmathV4MakeYAxis( VmathVector4 *result ) +{ + result->vec128 = _VECTORMATH_UNIT_0100; +} + +static inline void vmathV4MakeZAxis( VmathVector4 *result ) +{ + result->vec128 = _VECTORMATH_UNIT_0010; +} + +static inline void vmathV4MakeWAxis( VmathVector4 *result ) +{ + result->vec128 = _VECTORMATH_UNIT_0001; +} + +static inline void vmathV4Lerp( VmathVector4 *result, float t, const VmathVector4 *vec0, const VmathVector4 *vec1 ) +{ + VmathVector4 tmpV4_0, tmpV4_1; + vmathV4Sub( &tmpV4_0, vec1, vec0 ); + vmathV4ScalarMul( &tmpV4_1, &tmpV4_0, t ); + vmathV4Add( result, vec0, &tmpV4_1 ); +} + +static inline void vmathV4Slerp( VmathVector4 *result, float t, const VmathVector4 *unitVec0, const VmathVector4 *unitVec1 ) +{ + vec_float4 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines; + vec_uint4 selectMask; + cosAngle = _vmathVfDot4( unitVec0->vec128, unitVec1->vec128 ); + cosAngle = vec_splat( cosAngle, 0 ); + selectMask = (vec_uint4)vec_cmpgt( ((vec_float4){_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL}), cosAngle ); + angle = acosf4( cosAngle ); + tttt = _vmathVfSplatScalar(t); + oneMinusT = vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), tttt ); + angles = vec_mergeh( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), tttt ); + angles = vec_mergeh( angles, oneMinusT ); + angles = vec_madd( angles, angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + sines = sinf4( angles ); + scales = divf4( sines, vec_splat( sines, 0 ) ); + scale0 = vec_sel( oneMinusT, vec_splat( scales, 1 ), selectMask ); + scale1 = vec_sel( tttt, vec_splat( scales, 2 ), selectMask ); + result->vec128 = vec_madd( unitVec0->vec128, scale0, vec_madd( unitVec1->vec128, scale1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); +} + +static inline vec_float4 vmathV4Get128( const VmathVector4 *vec ) +{ + return vec->vec128; +} + +static inline void vmathV4StoreHalfFloats( const VmathVector4 *vec0, const VmathVector4 *vec1, const VmathVector4 *vec2, const VmathVector4 *vec3, vec_ushort8 *twoQuads ) +{ + twoQuads[0] = _vmath2VfToHalfFloats(vec0->vec128, vec1->vec128); + twoQuads[1] = _vmath2VfToHalfFloats(vec2->vec128, vec3->vec128); +} + +static inline void vmathV4SetXYZ( VmathVector4 *result, const VmathVector3 *vec ) +{ + result->vec128 = vec_sel( vec->vec128, result->vec128, _VECTORMATH_MASK_0x000F ); +} + +static inline void vmathV4GetXYZ( VmathVector3 *result, const VmathVector4 *vec ) +{ + result->vec128 = vec->vec128; +} + +static inline void vmathV4SetX( VmathVector4 *result, float _x ) +{ + _vmathVfSetElement(result->vec128, _x, 0); +} + +static inline float vmathV4GetX( const VmathVector4 *vec ) +{ + return _vmathVfGetElement(vec->vec128, 0); +} + +static inline void vmathV4SetY( VmathVector4 *result, float _y ) +{ + _vmathVfSetElement(result->vec128, _y, 1); +} + +static inline float vmathV4GetY( const VmathVector4 *vec ) +{ + return _vmathVfGetElement(vec->vec128, 1); +} + +static inline void vmathV4SetZ( VmathVector4 *result, float _z ) +{ + _vmathVfSetElement(result->vec128, _z, 2); +} + +static inline float vmathV4GetZ( const VmathVector4 *vec ) +{ + return _vmathVfGetElement(vec->vec128, 2); +} + +static inline void vmathV4SetW( VmathVector4 *result, float _w ) +{ + _vmathVfSetElement(result->vec128, _w, 3); +} + +static inline float vmathV4GetW( const VmathVector4 *vec ) +{ + return _vmathVfGetElement(vec->vec128, 3); +} + +static inline void vmathV4SetElem( VmathVector4 *result, int idx, float value ) +{ + _vmathVfSetElement(result->vec128, value, idx); +} + +static inline float vmathV4GetElem( const VmathVector4 *vec, int idx ) +{ + return _vmathVfGetElement(vec->vec128, idx); +} + +static inline void vmathV4Add( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) +{ + result->vec128 = vec_add( vec0->vec128, vec1->vec128 ); +} + +static inline void vmathV4Sub( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) +{ + result->vec128 = vec_sub( vec0->vec128, vec1->vec128 ); +} + +static inline void vmathV4ScalarMul( VmathVector4 *result, const VmathVector4 *vec, float scalar ) +{ + result->vec128 = vec_madd( vec->vec128, _vmathVfSplatScalar(scalar), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); +} + +static inline void vmathV4ScalarDiv( VmathVector4 *result, const VmathVector4 *vec, float scalar ) +{ + result->vec128 = divf4( vec->vec128, _vmathVfSplatScalar(scalar) ); +} + +static inline void vmathV4Neg( VmathVector4 *result, const VmathVector4 *vec ) +{ + result->vec128 = negatef4( vec->vec128 ); +} + +static inline void vmathV4MulPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) +{ + result->vec128 = vec_madd( vec0->vec128, vec1->vec128, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); +} + +static inline void vmathV4DivPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) +{ + result->vec128 = divf4( vec0->vec128, vec1->vec128 ); +} + +static inline void vmathV4RecipPerElem( VmathVector4 *result, const VmathVector4 *vec ) +{ + result->vec128 = recipf4( vec->vec128 ); +} + +static inline void vmathV4SqrtPerElem( VmathVector4 *result, const VmathVector4 *vec ) +{ + result->vec128 = sqrtf4( vec->vec128 ); +} + +static inline void vmathV4RsqrtPerElem( VmathVector4 *result, const VmathVector4 *vec ) +{ + result->vec128 = rsqrtf4( vec->vec128 ); +} + +static inline void vmathV4AbsPerElem( VmathVector4 *result, const VmathVector4 *vec ) +{ + result->vec128 = fabsf4( vec->vec128 ); +} + +static inline void vmathV4CopySignPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) +{ + result->vec128 = copysignf4( vec0->vec128, vec1->vec128 ); +} + +static inline void vmathV4MaxPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) +{ + result->vec128 = fmaxf4( vec0->vec128, vec1->vec128 ); +} + +static inline float vmathV4MaxElem( const VmathVector4 *vec ) +{ + vec_float4 result; + result = fmaxf4( vec_splat( vec->vec128, 1 ), vec->vec128 ); + result = fmaxf4( vec_splat( vec->vec128, 2 ), result ); + result = fmaxf4( vec_splat( vec->vec128, 3 ), result ); + return _vmathVfGetElement(result, 0); +} + +static inline void vmathV4MinPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) +{ + result->vec128 = fminf4( vec0->vec128, vec1->vec128 ); +} + +static inline float vmathV4MinElem( const VmathVector4 *vec ) +{ + vec_float4 result; + result = fminf4( vec_splat( vec->vec128, 1 ), vec->vec128 ); + result = fminf4( vec_splat( vec->vec128, 2 ), result ); + result = fminf4( vec_splat( vec->vec128, 3 ), result ); + return _vmathVfGetElement(result, 0); +} + +static inline float vmathV4Sum( const VmathVector4 *vec ) +{ + vec_float4 result; + result = vec_add( vec_splat( vec->vec128, 1 ), vec->vec128 ); + result = vec_add( vec_splat( vec->vec128, 2 ), result ); + result = vec_add( vec_splat( vec->vec128, 3 ), result ); + return _vmathVfGetElement(result, 0); +} + +static inline float vmathV4Dot( const VmathVector4 *vec0, const VmathVector4 *vec1 ) +{ + vec_float4 result = _vmathVfDot4( vec0->vec128, vec1->vec128 ); + return _vmathVfGetElement(result, 0); +} + +static inline float vmathV4LengthSqr( const VmathVector4 *vec ) +{ + vec_float4 result = _vmathVfDot4( vec->vec128, vec->vec128 ); + return _vmathVfGetElement(result, 0); +} + +static inline float vmathV4Length( const VmathVector4 *vec ) +{ + return sqrtf( vmathV4LengthSqr( vec ) ); +} + +static inline void vmathV4Normalize( VmathVector4 *result, const VmathVector4 *vec ) +{ + vec_float4 dot = _vmathVfDot4( vec->vec128, vec->vec128 ); + result->vec128 = vec_madd( vec->vec128, rsqrtf4( dot ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); +} + +static inline void vmathV4Select( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1, unsigned int select1 ) +{ + unsigned int tmp; + tmp = (unsigned int)-(select1 > 0); + result->vec128 = vec_sel( vec0->vec128, vec1->vec128, _vmathVuiSplatScalar(tmp) ); +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathV4Print( const VmathVector4 *vec ) +{ + union { vec_float4 v; float s[4]; } tmp; + tmp.v = vec->vec128; + printf( "( %f %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] ); +} + +static inline void vmathV4Prints( const VmathVector4 *vec, const char *name ) +{ + union { vec_float4 v; float s[4]; } tmp; + tmp.v = vec->vec128; + printf( "%s: ( %f %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] ); +} + +#endif + +static inline void vmathP3Copy( VmathPoint3 *result, const VmathPoint3 *pnt ) +{ + result->vec128 = pnt->vec128; +} + +static inline void vmathP3MakeFromElems( VmathPoint3 *result, float _x, float _y, float _z ) +{ + if (__builtin_constant_p(_x) & __builtin_constant_p(_y) & __builtin_constant_p(_z)) { + result->vec128 = (vec_float4){_x, _y, _z, 0.0f}; + } else { + float *pf = (float *)&result->vec128; + pf[0] = _x; + pf[1] = _y; + pf[2] = _z; + } +} + +static inline void vmathP3MakeFromV3( VmathPoint3 *result, const VmathVector3 *vec ) +{ + result->vec128 = vec->vec128; +} + +static inline void vmathP3MakeFromScalar( VmathPoint3 *result, float scalar ) +{ + result->vec128 = _vmathVfSplatScalar(scalar); +} + +static inline void vmathP3MakeFrom128( VmathPoint3 *result, vec_float4 vf4 ) +{ + result->vec128 = vf4; +} + +static inline void vmathP3Lerp( VmathPoint3 *result, float t, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) +{ + VmathVector3 tmpV3_0, tmpV3_1; + vmathP3Sub( &tmpV3_0, pnt1, pnt0 ); + vmathV3ScalarMul( &tmpV3_1, &tmpV3_0, t ); + vmathP3AddV3( result, pnt0, &tmpV3_1 ); +} + +static inline vec_float4 vmathP3Get128( const VmathPoint3 *pnt ) +{ + return pnt->vec128; +} + +static inline void vmathP3StoreXYZ( const VmathPoint3 *pnt, vec_float4 *quad ) +{ + vec_float4 dstVec = *quad; + vec_uint4 mask = _VECTORMATH_MASK_0x000F; + dstVec = vec_sel(pnt->vec128, dstVec, mask); + *quad = dstVec; +} + +static inline void vmathP3LoadXYZArray( VmathPoint3 *pnt0, VmathPoint3 *pnt1, VmathPoint3 *pnt2, VmathPoint3 *pnt3, const vec_float4 *threeQuads ) +{ + vec_float4 xyzx, yzxy, zxyz, xyz1, xyz2, xyz3; + xyzx = threeQuads[0]; + yzxy = threeQuads[1]; + zxyz = threeQuads[2]; + xyz1 = vec_sld( xyzx, yzxy, 12 ); + xyz2 = vec_sld( yzxy, zxyz, 8 ); + xyz3 = vec_sld( zxyz, zxyz, 4 ); + pnt0->vec128 = xyzx; + pnt1->vec128 = xyz1; + pnt2->vec128 = xyz2; + pnt3->vec128 = xyz3; +} + +static inline void vmathP3StoreXYZArray( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, const VmathPoint3 *pnt2, const VmathPoint3 *pnt3, vec_float4 *threeQuads ) +{ + vec_float4 xyzx, yzxy, zxyz; + xyzx = vec_perm( pnt0->vec128, pnt1->vec128, _VECTORMATH_PERM_XYZA ); + yzxy = vec_perm( pnt1->vec128, pnt2->vec128, _VECTORMATH_PERM_YZAB ); + zxyz = vec_perm( pnt2->vec128, pnt3->vec128, _VECTORMATH_PERM_ZABC ); + threeQuads[0] = xyzx; + threeQuads[1] = yzxy; + threeQuads[2] = zxyz; +} + +static inline void vmathP3StoreHalfFloats( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, const VmathPoint3 *pnt2, const VmathPoint3 *pnt3, const VmathPoint3 *pnt4, const VmathPoint3 *pnt5, const VmathPoint3 *pnt6, const VmathPoint3 *pnt7, vec_ushort8 *threeQuads ) +{ + vec_float4 xyz0[3]; + vec_float4 xyz1[3]; + vmathP3StoreXYZArray( pnt0, pnt1, pnt2, pnt3, xyz0 ); + vmathP3StoreXYZArray( pnt4, pnt5, pnt6, pnt7, xyz1 ); + threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); + threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); + threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); +} + +static inline void vmathP3SetX( VmathPoint3 *result, float _x ) +{ + _vmathVfSetElement(result->vec128, _x, 0); +} + +static inline float vmathP3GetX( const VmathPoint3 *pnt ) +{ + return _vmathVfGetElement(pnt->vec128, 0); +} + +static inline void vmathP3SetY( VmathPoint3 *result, float _y ) +{ + _vmathVfSetElement(result->vec128, _y, 1); +} + +static inline float vmathP3GetY( const VmathPoint3 *pnt ) +{ + return _vmathVfGetElement(pnt->vec128, 1); +} + +static inline void vmathP3SetZ( VmathPoint3 *result, float _z ) +{ + _vmathVfSetElement(result->vec128, _z, 2); +} + +static inline float vmathP3GetZ( const VmathPoint3 *pnt ) +{ + return _vmathVfGetElement(pnt->vec128, 2); +} + +static inline void vmathP3SetElem( VmathPoint3 *result, int idx, float value ) +{ + _vmathVfSetElement(result->vec128, value, idx); +} + +static inline float vmathP3GetElem( const VmathPoint3 *pnt, int idx ) +{ + return _vmathVfGetElement(pnt->vec128, idx); +} + +static inline void vmathP3Sub( VmathVector3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) +{ + result->vec128 = vec_sub( pnt0->vec128, pnt1->vec128 ); +} + +static inline void vmathP3AddV3( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *vec1 ) +{ + result->vec128 = vec_add( pnt->vec128, vec1->vec128 ); +} + +static inline void vmathP3SubV3( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *vec1 ) +{ + result->vec128 = vec_sub( pnt->vec128, vec1->vec128 ); +} + +static inline void vmathP3MulPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) +{ + result->vec128 = vec_madd( pnt0->vec128, pnt1->vec128, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); +} + +static inline void vmathP3DivPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) +{ + result->vec128 = divf4( pnt0->vec128, pnt1->vec128 ); +} + +static inline void vmathP3RecipPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ) +{ + result->vec128 = recipf4( pnt->vec128 ); +} + +static inline void vmathP3SqrtPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ) +{ + result->vec128 = sqrtf4( pnt->vec128 ); +} + +static inline void vmathP3RsqrtPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ) +{ + result->vec128 = rsqrtf4( pnt->vec128 ); +} + +static inline void vmathP3AbsPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ) +{ + result->vec128 = fabsf4( pnt->vec128 ); +} + +static inline void vmathP3CopySignPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) +{ + result->vec128 = copysignf4( pnt0->vec128, pnt1->vec128 ); +} + +static inline void vmathP3MaxPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) +{ + result->vec128 = fmaxf4( pnt0->vec128, pnt1->vec128 ); +} + +static inline float vmathP3MaxElem( const VmathPoint3 *pnt ) +{ + vec_float4 result; + result = fmaxf4( vec_splat( pnt->vec128, 1 ), pnt->vec128 ); + result = fmaxf4( vec_splat( pnt->vec128, 2 ), result ); + return _vmathVfGetElement(result, 0); +} + +static inline void vmathP3MinPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) +{ + result->vec128 = fminf4( pnt0->vec128, pnt1->vec128 ); +} + +static inline float vmathP3MinElem( const VmathPoint3 *pnt ) +{ + vec_float4 result; + result = fminf4( vec_splat( pnt->vec128, 1 ), pnt->vec128 ); + result = fminf4( vec_splat( pnt->vec128, 2 ), result ); + return _vmathVfGetElement(result, 0); +} + +static inline float vmathP3Sum( const VmathPoint3 *pnt ) +{ + vec_float4 result; + result = vec_add( vec_splat( pnt->vec128, 1 ), pnt->vec128 ); + result = vec_add( vec_splat( pnt->vec128, 2 ), result ); + return _vmathVfGetElement(result, 0); +} + +static inline void vmathP3Scale( VmathPoint3 *result, const VmathPoint3 *pnt, float scaleVal ) +{ + VmathPoint3 tmpP3_0; + vmathP3MakeFromScalar( &tmpP3_0, scaleVal ); + vmathP3MulPerElem( result, pnt, &tmpP3_0 ); +} + +static inline void vmathP3NonUniformScale( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *scaleVec ) +{ + VmathPoint3 tmpP3_0; + vmathP3MakeFromV3( &tmpP3_0, scaleVec ); + vmathP3MulPerElem( result, pnt, &tmpP3_0 ); +} + +static inline float vmathP3Projection( const VmathPoint3 *pnt, const VmathVector3 *unitVec ) +{ + vec_float4 result = _vmathVfDot3( pnt->vec128, unitVec->vec128 ); + return _vmathVfGetElement(result, 0); +} + +static inline float vmathP3DistSqrFromOrigin( const VmathPoint3 *pnt ) +{ + VmathVector3 tmpV3_0; + vmathV3MakeFromP3( &tmpV3_0, pnt ); + return vmathV3LengthSqr( &tmpV3_0 ); +} + +static inline float vmathP3DistFromOrigin( const VmathPoint3 *pnt ) +{ + VmathVector3 tmpV3_0; + vmathV3MakeFromP3( &tmpV3_0, pnt ); + return vmathV3Length( &tmpV3_0 ); +} + +static inline float vmathP3DistSqr( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) +{ + VmathVector3 tmpV3_0; + vmathP3Sub( &tmpV3_0, pnt1, pnt0 ); + return vmathV3LengthSqr( &tmpV3_0 ); +} + +static inline float vmathP3Dist( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) +{ + VmathVector3 tmpV3_0; + vmathP3Sub( &tmpV3_0, pnt1, pnt0 ); + return vmathV3Length( &tmpV3_0 ); +} + +static inline void vmathP3Select( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, unsigned int select1 ) +{ + unsigned int tmp; + tmp = (unsigned int)-(select1 > 0); + result->vec128 = vec_sel( pnt0->vec128, pnt1->vec128, _vmathVuiSplatScalar(tmp) ); +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathP3Print( const VmathPoint3 *pnt ) +{ + union { vec_float4 v; float s[4]; } tmp; + tmp.v = pnt->vec128; + printf( "( %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2] ); +} + +static inline void vmathP3Prints( const VmathPoint3 *pnt, const char *name ) +{ + union { vec_float4 v; float s[4]; } tmp; + tmp.v = pnt->vec128; + printf( "%s: ( %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2] ); +} + +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/vectormathlibrary/include/vectormath/ppu/c/vec_aos_v.h b/vectormathlibrary/include/vectormath/ppu/c/vec_aos_v.h new file mode 100644 index 000000000..6dcc79c72 --- /dev/null +++ b/vectormathlibrary/include/vectormath/ppu/c/vec_aos_v.h @@ -0,0 +1,953 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_VEC_AOS_V_C_H +#define _VECTORMATH_VEC_AOS_V_C_H +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/*----------------------------------------------------------------------------- + * Constants + * for permutes words are labeled [x,y,z,w] [a,b,c,d] + */ +#define _VECTORMATH_PERM_X 0x00010203 +#define _VECTORMATH_PERM_Y 0x04050607 +#define _VECTORMATH_PERM_Z 0x08090a0b +#define _VECTORMATH_PERM_W 0x0c0d0e0f +#define _VECTORMATH_PERM_A 0x10111213 +#define _VECTORMATH_PERM_B 0x14151617 +#define _VECTORMATH_PERM_C 0x18191a1b +#define _VECTORMATH_PERM_D 0x1c1d1e1f +#define _VECTORMATH_PERM_XYZA (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A } +#define _VECTORMATH_PERM_ZXYW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_W } +#define _VECTORMATH_PERM_YZXW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_W } +#define _VECTORMATH_PERM_YZAB (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A, _VECTORMATH_PERM_B } +#define _VECTORMATH_PERM_ZABC (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A, _VECTORMATH_PERM_B, _VECTORMATH_PERM_C } +#define _VECTORMATH_PERM_XYAW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A, _VECTORMATH_PERM_W } +#define _VECTORMATH_PERM_XAZW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_A, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_W } +#define _VECTORMATH_MASK_0xF000 (vec_uint4){ 0xffffffff, 0, 0, 0 } +#define _VECTORMATH_MASK_0x0F00 (vec_uint4){ 0, 0xffffffff, 0, 0 } +#define _VECTORMATH_MASK_0x00F0 (vec_uint4){ 0, 0, 0xffffffff, 0 } +#define _VECTORMATH_MASK_0x000F (vec_uint4){ 0, 0, 0, 0xffffffff } +#define _VECTORMATH_UNIT_1000 (vec_float4){ 1.0f, 0.0f, 0.0f, 0.0f } +#define _VECTORMATH_UNIT_0100 (vec_float4){ 0.0f, 1.0f, 0.0f, 0.0f } +#define _VECTORMATH_UNIT_0010 (vec_float4){ 0.0f, 0.0f, 1.0f, 0.0f } +#define _VECTORMATH_UNIT_0001 (vec_float4){ 0.0f, 0.0f, 0.0f, 1.0f } +#define _VECTORMATH_SLERP_TOL 0.999f + +/*----------------------------------------------------------------------------- + * Definitions + */ +#ifndef _VECTORMATH_INTERNAL_FUNCTIONS +#define _VECTORMATH_INTERNAL_FUNCTIONS + +#endif + +static inline VmathVector3 vmathV3MakeFromElems_V( float _x, float _y, float _z ) +{ + VmathVector3 result; + vmathV3MakeFromElems(&result, _x, _y, _z); + return result; +} + +static inline VmathVector3 vmathV3MakeFromP3_V( VmathPoint3 pnt ) +{ + VmathVector3 result; + vmathV3MakeFromP3(&result, &pnt); + return result; +} + +static inline VmathVector3 vmathV3MakeFromScalar_V( float scalar ) +{ + VmathVector3 result; + vmathV3MakeFromScalar(&result, scalar); + return result; +} + +static inline VmathVector3 vmathV3MakeFrom128_V( vec_float4 vf4 ) +{ + VmathVector3 result; + vmathV3MakeFrom128(&result, vf4); + return result; +} + +static inline VmathVector3 vmathV3MakeXAxis_V( ) +{ + VmathVector3 result; + vmathV3MakeXAxis(&result); + return result; +} + +static inline VmathVector3 vmathV3MakeYAxis_V( ) +{ + VmathVector3 result; + vmathV3MakeYAxis(&result); + return result; +} + +static inline VmathVector3 vmathV3MakeZAxis_V( ) +{ + VmathVector3 result; + vmathV3MakeZAxis(&result); + return result; +} + +static inline VmathVector3 vmathV3Lerp_V( float t, VmathVector3 vec0, VmathVector3 vec1 ) +{ + VmathVector3 result; + vmathV3Lerp(&result, t, &vec0, &vec1); + return result; +} + +static inline VmathVector3 vmathV3Slerp_V( float t, VmathVector3 unitVec0, VmathVector3 unitVec1 ) +{ + VmathVector3 result; + vmathV3Slerp(&result, t, &unitVec0, &unitVec1); + return result; +} + +static inline vec_float4 vmathV3Get128_V( VmathVector3 vec ) +{ + return vmathV3Get128(&vec); +} + +static inline void vmathV3StoreXYZ_V( VmathVector3 vec, vec_float4 *quad ) +{ + vmathV3StoreXYZ(&vec, quad); +} + +static inline void vmathV3LoadXYZArray_V( VmathVector3 *vec0, VmathVector3 *vec1, VmathVector3 *vec2, VmathVector3 *vec3, const vec_float4 *threeQuads ) +{ + vmathV3LoadXYZArray(vec0, vec1, vec2, vec3, threeQuads); +} + +static inline void vmathV3StoreXYZArray_V( VmathVector3 vec0, VmathVector3 vec1, VmathVector3 vec2, VmathVector3 vec3, vec_float4 *threeQuads ) +{ + vmathV3StoreXYZArray(&vec0, &vec1, &vec2, &vec3, threeQuads); +} + +static inline void vmathV3StoreHalfFloats_V( VmathVector3 vec0, VmathVector3 vec1, VmathVector3 vec2, VmathVector3 vec3, VmathVector3 vec4, VmathVector3 vec5, VmathVector3 vec6, VmathVector3 vec7, vec_ushort8 *threeQuads ) +{ + vmathV3StoreHalfFloats(&vec0, &vec1, &vec2, &vec3, &vec4, &vec5, &vec6, &vec7, threeQuads); +} + +static inline void vmathV3SetX_V( VmathVector3 *result, float _x ) +{ + vmathV3SetX(result, _x); +} + +static inline float vmathV3GetX_V( VmathVector3 vec ) +{ + return vmathV3GetX(&vec); +} + +static inline void vmathV3SetY_V( VmathVector3 *result, float _y ) +{ + vmathV3SetY(result, _y); +} + +static inline float vmathV3GetY_V( VmathVector3 vec ) +{ + return vmathV3GetY(&vec); +} + +static inline void vmathV3SetZ_V( VmathVector3 *result, float _z ) +{ + vmathV3SetZ(result, _z); +} + +static inline float vmathV3GetZ_V( VmathVector3 vec ) +{ + return vmathV3GetZ(&vec); +} + +static inline void vmathV3SetElem_V( VmathVector3 *result, int idx, float value ) +{ + vmathV3SetElem(result, idx, value); +} + +static inline float vmathV3GetElem_V( VmathVector3 vec, int idx ) +{ + return vmathV3GetElem(&vec, idx); +} + +static inline VmathVector3 vmathV3Add_V( VmathVector3 vec0, VmathVector3 vec1 ) +{ + VmathVector3 result; + vmathV3Add(&result, &vec0, &vec1); + return result; +} + +static inline VmathVector3 vmathV3Sub_V( VmathVector3 vec0, VmathVector3 vec1 ) +{ + VmathVector3 result; + vmathV3Sub(&result, &vec0, &vec1); + return result; +} + +static inline VmathPoint3 vmathV3AddP3_V( VmathVector3 vec, VmathPoint3 pnt1 ) +{ + VmathPoint3 result; + vmathV3AddP3(&result, &vec, &pnt1); + return result; +} + +static inline VmathVector3 vmathV3ScalarMul_V( VmathVector3 vec, float scalar ) +{ + VmathVector3 result; + vmathV3ScalarMul(&result, &vec, scalar); + return result; +} + +static inline VmathVector3 vmathV3ScalarDiv_V( VmathVector3 vec, float scalar ) +{ + VmathVector3 result; + vmathV3ScalarDiv(&result, &vec, scalar); + return result; +} + +static inline VmathVector3 vmathV3Neg_V( VmathVector3 vec ) +{ + VmathVector3 result; + vmathV3Neg(&result, &vec); + return result; +} + +static inline VmathVector3 vmathV3MulPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ) +{ + VmathVector3 result; + vmathV3MulPerElem(&result, &vec0, &vec1); + return result; +} + +static inline VmathVector3 vmathV3DivPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ) +{ + VmathVector3 result; + vmathV3DivPerElem(&result, &vec0, &vec1); + return result; +} + +static inline VmathVector3 vmathV3RecipPerElem_V( VmathVector3 vec ) +{ + VmathVector3 result; + vmathV3RecipPerElem(&result, &vec); + return result; +} + +static inline VmathVector3 vmathV3SqrtPerElem_V( VmathVector3 vec ) +{ + VmathVector3 result; + vmathV3SqrtPerElem(&result, &vec); + return result; +} + +static inline VmathVector3 vmathV3RsqrtPerElem_V( VmathVector3 vec ) +{ + VmathVector3 result; + vmathV3RsqrtPerElem(&result, &vec); + return result; +} + +static inline VmathVector3 vmathV3AbsPerElem_V( VmathVector3 vec ) +{ + VmathVector3 result; + vmathV3AbsPerElem(&result, &vec); + return result; +} + +static inline VmathVector3 vmathV3CopySignPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ) +{ + VmathVector3 result; + vmathV3CopySignPerElem(&result, &vec0, &vec1); + return result; +} + +static inline VmathVector3 vmathV3MaxPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ) +{ + VmathVector3 result; + vmathV3MaxPerElem(&result, &vec0, &vec1); + return result; +} + +static inline float vmathV3MaxElem_V( VmathVector3 vec ) +{ + return vmathV3MaxElem(&vec); +} + +static inline VmathVector3 vmathV3MinPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ) +{ + VmathVector3 result; + vmathV3MinPerElem(&result, &vec0, &vec1); + return result; +} + +static inline float vmathV3MinElem_V( VmathVector3 vec ) +{ + return vmathV3MinElem(&vec); +} + +static inline float vmathV3Sum_V( VmathVector3 vec ) +{ + return vmathV3Sum(&vec); +} + +static inline float vmathV3Dot_V( VmathVector3 vec0, VmathVector3 vec1 ) +{ + return vmathV3Dot(&vec0, &vec1); +} + +static inline float vmathV3LengthSqr_V( VmathVector3 vec ) +{ + return vmathV3LengthSqr(&vec); +} + +static inline float vmathV3Length_V( VmathVector3 vec ) +{ + return vmathV3Length(&vec); +} + +static inline VmathVector3 vmathV3Normalize_V( VmathVector3 vec ) +{ + VmathVector3 result; + vmathV3Normalize(&result, &vec); + return result; +} + +static inline VmathVector3 vmathV3Cross_V( VmathVector3 vec0, VmathVector3 vec1 ) +{ + VmathVector3 result; + vmathV3Cross(&result, &vec0, &vec1); + return result; +} + +static inline VmathVector3 vmathV3Select_V( VmathVector3 vec0, VmathVector3 vec1, unsigned int select1 ) +{ + VmathVector3 result; + vmathV3Select(&result, &vec0, &vec1, select1); + return result; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathV3Print_V( VmathVector3 vec ) +{ + vmathV3Print(&vec); +} + +static inline void vmathV3Prints_V( VmathVector3 vec, const char *name ) +{ + vmathV3Prints(&vec, name); +} + +#endif + +static inline VmathVector4 vmathV4MakeFromElems_V( float _x, float _y, float _z, float _w ) +{ + VmathVector4 result; + vmathV4MakeFromElems(&result, _x, _y, _z, _w); + return result; +} + +static inline VmathVector4 vmathV4MakeFromV3Scalar_V( VmathVector3 xyz, float _w ) +{ + VmathVector4 result; + vmathV4MakeFromV3Scalar(&result, &xyz, _w); + return result; +} + +static inline VmathVector4 vmathV4MakeFromV3_V( VmathVector3 vec ) +{ + VmathVector4 result; + vmathV4MakeFromV3(&result, &vec); + return result; +} + +static inline VmathVector4 vmathV4MakeFromP3_V( VmathPoint3 pnt ) +{ + VmathVector4 result; + vmathV4MakeFromP3(&result, &pnt); + return result; +} + +static inline VmathVector4 vmathV4MakeFromQ_V( VmathQuat quat ) +{ + VmathVector4 result; + vmathV4MakeFromQ(&result, &quat); + return result; +} + +static inline VmathVector4 vmathV4MakeFromScalar_V( float scalar ) +{ + VmathVector4 result; + vmathV4MakeFromScalar(&result, scalar); + return result; +} + +static inline VmathVector4 vmathV4MakeFrom128_V( vec_float4 vf4 ) +{ + VmathVector4 result; + vmathV4MakeFrom128(&result, vf4); + return result; +} + +static inline VmathVector4 vmathV4MakeXAxis_V( ) +{ + VmathVector4 result; + vmathV4MakeXAxis(&result); + return result; +} + +static inline VmathVector4 vmathV4MakeYAxis_V( ) +{ + VmathVector4 result; + vmathV4MakeYAxis(&result); + return result; +} + +static inline VmathVector4 vmathV4MakeZAxis_V( ) +{ + VmathVector4 result; + vmathV4MakeZAxis(&result); + return result; +} + +static inline VmathVector4 vmathV4MakeWAxis_V( ) +{ + VmathVector4 result; + vmathV4MakeWAxis(&result); + return result; +} + +static inline VmathVector4 vmathV4Lerp_V( float t, VmathVector4 vec0, VmathVector4 vec1 ) +{ + VmathVector4 result; + vmathV4Lerp(&result, t, &vec0, &vec1); + return result; +} + +static inline VmathVector4 vmathV4Slerp_V( float t, VmathVector4 unitVec0, VmathVector4 unitVec1 ) +{ + VmathVector4 result; + vmathV4Slerp(&result, t, &unitVec0, &unitVec1); + return result; +} + +static inline vec_float4 vmathV4Get128_V( VmathVector4 vec ) +{ + return vmathV4Get128(&vec); +} + +static inline void vmathV4StoreHalfFloats_V( VmathVector4 vec0, VmathVector4 vec1, VmathVector4 vec2, VmathVector4 vec3, vec_ushort8 *twoQuads ) +{ + vmathV4StoreHalfFloats(&vec0, &vec1, &vec2, &vec3, twoQuads); +} + +static inline void vmathV4SetXYZ_V( VmathVector4 *result, VmathVector3 vec ) +{ + vmathV4SetXYZ(result, &vec); +} + +static inline VmathVector3 vmathV4GetXYZ_V( VmathVector4 vec ) +{ + VmathVector3 result; + vmathV4GetXYZ(&result, &vec); + return result; +} + +static inline void vmathV4SetX_V( VmathVector4 *result, float _x ) +{ + vmathV4SetX(result, _x); +} + +static inline float vmathV4GetX_V( VmathVector4 vec ) +{ + return vmathV4GetX(&vec); +} + +static inline void vmathV4SetY_V( VmathVector4 *result, float _y ) +{ + vmathV4SetY(result, _y); +} + +static inline float vmathV4GetY_V( VmathVector4 vec ) +{ + return vmathV4GetY(&vec); +} + +static inline void vmathV4SetZ_V( VmathVector4 *result, float _z ) +{ + vmathV4SetZ(result, _z); +} + +static inline float vmathV4GetZ_V( VmathVector4 vec ) +{ + return vmathV4GetZ(&vec); +} + +static inline void vmathV4SetW_V( VmathVector4 *result, float _w ) +{ + vmathV4SetW(result, _w); +} + +static inline float vmathV4GetW_V( VmathVector4 vec ) +{ + return vmathV4GetW(&vec); +} + +static inline void vmathV4SetElem_V( VmathVector4 *result, int idx, float value ) +{ + vmathV4SetElem(result, idx, value); +} + +static inline float vmathV4GetElem_V( VmathVector4 vec, int idx ) +{ + return vmathV4GetElem(&vec, idx); +} + +static inline VmathVector4 vmathV4Add_V( VmathVector4 vec0, VmathVector4 vec1 ) +{ + VmathVector4 result; + vmathV4Add(&result, &vec0, &vec1); + return result; +} + +static inline VmathVector4 vmathV4Sub_V( VmathVector4 vec0, VmathVector4 vec1 ) +{ + VmathVector4 result; + vmathV4Sub(&result, &vec0, &vec1); + return result; +} + +static inline VmathVector4 vmathV4ScalarMul_V( VmathVector4 vec, float scalar ) +{ + VmathVector4 result; + vmathV4ScalarMul(&result, &vec, scalar); + return result; +} + +static inline VmathVector4 vmathV4ScalarDiv_V( VmathVector4 vec, float scalar ) +{ + VmathVector4 result; + vmathV4ScalarDiv(&result, &vec, scalar); + return result; +} + +static inline VmathVector4 vmathV4Neg_V( VmathVector4 vec ) +{ + VmathVector4 result; + vmathV4Neg(&result, &vec); + return result; +} + +static inline VmathVector4 vmathV4MulPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ) +{ + VmathVector4 result; + vmathV4MulPerElem(&result, &vec0, &vec1); + return result; +} + +static inline VmathVector4 vmathV4DivPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ) +{ + VmathVector4 result; + vmathV4DivPerElem(&result, &vec0, &vec1); + return result; +} + +static inline VmathVector4 vmathV4RecipPerElem_V( VmathVector4 vec ) +{ + VmathVector4 result; + vmathV4RecipPerElem(&result, &vec); + return result; +} + +static inline VmathVector4 vmathV4SqrtPerElem_V( VmathVector4 vec ) +{ + VmathVector4 result; + vmathV4SqrtPerElem(&result, &vec); + return result; +} + +static inline VmathVector4 vmathV4RsqrtPerElem_V( VmathVector4 vec ) +{ + VmathVector4 result; + vmathV4RsqrtPerElem(&result, &vec); + return result; +} + +static inline VmathVector4 vmathV4AbsPerElem_V( VmathVector4 vec ) +{ + VmathVector4 result; + vmathV4AbsPerElem(&result, &vec); + return result; +} + +static inline VmathVector4 vmathV4CopySignPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ) +{ + VmathVector4 result; + vmathV4CopySignPerElem(&result, &vec0, &vec1); + return result; +} + +static inline VmathVector4 vmathV4MaxPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ) +{ + VmathVector4 result; + vmathV4MaxPerElem(&result, &vec0, &vec1); + return result; +} + +static inline float vmathV4MaxElem_V( VmathVector4 vec ) +{ + return vmathV4MaxElem(&vec); +} + +static inline VmathVector4 vmathV4MinPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ) +{ + VmathVector4 result; + vmathV4MinPerElem(&result, &vec0, &vec1); + return result; +} + +static inline float vmathV4MinElem_V( VmathVector4 vec ) +{ + return vmathV4MinElem(&vec); +} + +static inline float vmathV4Sum_V( VmathVector4 vec ) +{ + return vmathV4Sum(&vec); +} + +static inline float vmathV4Dot_V( VmathVector4 vec0, VmathVector4 vec1 ) +{ + return vmathV4Dot(&vec0, &vec1); +} + +static inline float vmathV4LengthSqr_V( VmathVector4 vec ) +{ + return vmathV4LengthSqr(&vec); +} + +static inline float vmathV4Length_V( VmathVector4 vec ) +{ + return vmathV4Length(&vec); +} + +static inline VmathVector4 vmathV4Normalize_V( VmathVector4 vec ) +{ + VmathVector4 result; + vmathV4Normalize(&result, &vec); + return result; +} + +static inline VmathVector4 vmathV4Select_V( VmathVector4 vec0, VmathVector4 vec1, unsigned int select1 ) +{ + VmathVector4 result; + vmathV4Select(&result, &vec0, &vec1, select1); + return result; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathV4Print_V( VmathVector4 vec ) +{ + vmathV4Print(&vec); +} + +static inline void vmathV4Prints_V( VmathVector4 vec, const char *name ) +{ + vmathV4Prints(&vec, name); +} + +#endif + +static inline VmathPoint3 vmathP3MakeFromElems_V( float _x, float _y, float _z ) +{ + VmathPoint3 result; + vmathP3MakeFromElems(&result, _x, _y, _z); + return result; +} + +static inline VmathPoint3 vmathP3MakeFromV3_V( VmathVector3 vec ) +{ + VmathPoint3 result; + vmathP3MakeFromV3(&result, &vec); + return result; +} + +static inline VmathPoint3 vmathP3MakeFromScalar_V( float scalar ) +{ + VmathPoint3 result; + vmathP3MakeFromScalar(&result, scalar); + return result; +} + +static inline VmathPoint3 vmathP3MakeFrom128_V( vec_float4 vf4 ) +{ + VmathPoint3 result; + vmathP3MakeFrom128(&result, vf4); + return result; +} + +static inline VmathPoint3 vmathP3Lerp_V( float t, VmathPoint3 pnt0, VmathPoint3 pnt1 ) +{ + VmathPoint3 result; + vmathP3Lerp(&result, t, &pnt0, &pnt1); + return result; +} + +static inline vec_float4 vmathP3Get128_V( VmathPoint3 pnt ) +{ + return vmathP3Get128(&pnt); +} + +static inline void vmathP3StoreXYZ_V( VmathPoint3 pnt, vec_float4 *quad ) +{ + vmathP3StoreXYZ(&pnt, quad); +} + +static inline void vmathP3LoadXYZArray_V( VmathPoint3 *pnt0, VmathPoint3 *pnt1, VmathPoint3 *pnt2, VmathPoint3 *pnt3, const vec_float4 *threeQuads ) +{ + vmathP3LoadXYZArray(pnt0, pnt1, pnt2, pnt3, threeQuads); +} + +static inline void vmathP3StoreXYZArray_V( VmathPoint3 pnt0, VmathPoint3 pnt1, VmathPoint3 pnt2, VmathPoint3 pnt3, vec_float4 *threeQuads ) +{ + vmathP3StoreXYZArray(&pnt0, &pnt1, &pnt2, &pnt3, threeQuads); +} + +static inline void vmathP3StoreHalfFloats_V( VmathPoint3 pnt0, VmathPoint3 pnt1, VmathPoint3 pnt2, VmathPoint3 pnt3, VmathPoint3 pnt4, VmathPoint3 pnt5, VmathPoint3 pnt6, VmathPoint3 pnt7, vec_ushort8 *threeQuads ) +{ + vmathP3StoreHalfFloats(&pnt0, &pnt1, &pnt2, &pnt3, &pnt4, &pnt5, &pnt6, &pnt7, threeQuads); +} + +static inline void vmathP3SetX_V( VmathPoint3 *result, float _x ) +{ + vmathP3SetX(result, _x); +} + +static inline float vmathP3GetX_V( VmathPoint3 pnt ) +{ + return vmathP3GetX(&pnt); +} + +static inline void vmathP3SetY_V( VmathPoint3 *result, float _y ) +{ + vmathP3SetY(result, _y); +} + +static inline float vmathP3GetY_V( VmathPoint3 pnt ) +{ + return vmathP3GetY(&pnt); +} + +static inline void vmathP3SetZ_V( VmathPoint3 *result, float _z ) +{ + vmathP3SetZ(result, _z); +} + +static inline float vmathP3GetZ_V( VmathPoint3 pnt ) +{ + return vmathP3GetZ(&pnt); +} + +static inline void vmathP3SetElem_V( VmathPoint3 *result, int idx, float value ) +{ + vmathP3SetElem(result, idx, value); +} + +static inline float vmathP3GetElem_V( VmathPoint3 pnt, int idx ) +{ + return vmathP3GetElem(&pnt, idx); +} + +static inline VmathVector3 vmathP3Sub_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) +{ + VmathVector3 result; + vmathP3Sub(&result, &pnt0, &pnt1); + return result; +} + +static inline VmathPoint3 vmathP3AddV3_V( VmathPoint3 pnt, VmathVector3 vec1 ) +{ + VmathPoint3 result; + vmathP3AddV3(&result, &pnt, &vec1); + return result; +} + +static inline VmathPoint3 vmathP3SubV3_V( VmathPoint3 pnt, VmathVector3 vec1 ) +{ + VmathPoint3 result; + vmathP3SubV3(&result, &pnt, &vec1); + return result; +} + +static inline VmathPoint3 vmathP3MulPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) +{ + VmathPoint3 result; + vmathP3MulPerElem(&result, &pnt0, &pnt1); + return result; +} + +static inline VmathPoint3 vmathP3DivPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) +{ + VmathPoint3 result; + vmathP3DivPerElem(&result, &pnt0, &pnt1); + return result; +} + +static inline VmathPoint3 vmathP3RecipPerElem_V( VmathPoint3 pnt ) +{ + VmathPoint3 result; + vmathP3RecipPerElem(&result, &pnt); + return result; +} + +static inline VmathPoint3 vmathP3SqrtPerElem_V( VmathPoint3 pnt ) +{ + VmathPoint3 result; + vmathP3SqrtPerElem(&result, &pnt); + return result; +} + +static inline VmathPoint3 vmathP3RsqrtPerElem_V( VmathPoint3 pnt ) +{ + VmathPoint3 result; + vmathP3RsqrtPerElem(&result, &pnt); + return result; +} + +static inline VmathPoint3 vmathP3AbsPerElem_V( VmathPoint3 pnt ) +{ + VmathPoint3 result; + vmathP3AbsPerElem(&result, &pnt); + return result; +} + +static inline VmathPoint3 vmathP3CopySignPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) +{ + VmathPoint3 result; + vmathP3CopySignPerElem(&result, &pnt0, &pnt1); + return result; +} + +static inline VmathPoint3 vmathP3MaxPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) +{ + VmathPoint3 result; + vmathP3MaxPerElem(&result, &pnt0, &pnt1); + return result; +} + +static inline float vmathP3MaxElem_V( VmathPoint3 pnt ) +{ + return vmathP3MaxElem(&pnt); +} + +static inline VmathPoint3 vmathP3MinPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) +{ + VmathPoint3 result; + vmathP3MinPerElem(&result, &pnt0, &pnt1); + return result; +} + +static inline float vmathP3MinElem_V( VmathPoint3 pnt ) +{ + return vmathP3MinElem(&pnt); +} + +static inline float vmathP3Sum_V( VmathPoint3 pnt ) +{ + return vmathP3Sum(&pnt); +} + +static inline VmathPoint3 vmathP3Scale_V( VmathPoint3 pnt, float scaleVal ) +{ + VmathPoint3 result; + vmathP3Scale(&result, &pnt, scaleVal); + return result; +} + +static inline VmathPoint3 vmathP3NonUniformScale_V( VmathPoint3 pnt, VmathVector3 scaleVec ) +{ + VmathPoint3 result; + vmathP3NonUniformScale(&result, &pnt, &scaleVec); + return result; +} + +static inline float vmathP3Projection_V( VmathPoint3 pnt, VmathVector3 unitVec ) +{ + return vmathP3Projection(&pnt, &unitVec); +} + +static inline float vmathP3DistSqrFromOrigin_V( VmathPoint3 pnt ) +{ + return vmathP3DistSqrFromOrigin(&pnt); +} + +static inline float vmathP3DistFromOrigin_V( VmathPoint3 pnt ) +{ + return vmathP3DistFromOrigin(&pnt); +} + +static inline float vmathP3DistSqr_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) +{ + return vmathP3DistSqr(&pnt0, &pnt1); +} + +static inline float vmathP3Dist_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) +{ + return vmathP3Dist(&pnt0, &pnt1); +} + +static inline VmathPoint3 vmathP3Select_V( VmathPoint3 pnt0, VmathPoint3 pnt1, unsigned int select1 ) +{ + VmathPoint3 result; + vmathP3Select(&result, &pnt0, &pnt1, select1); + return result; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathP3Print_V( VmathPoint3 pnt ) +{ + vmathP3Print(&pnt); +} + +static inline void vmathP3Prints_V( VmathPoint3 pnt, const char *name ) +{ + vmathP3Prints(&pnt, name); +} + +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/vectormathlibrary/include/vectormath/ppu/c/vec_soa.h b/vectormathlibrary/include/vectormath/ppu/c/vec_soa.h new file mode 100644 index 000000000..1cda25747 --- /dev/null +++ b/vectormathlibrary/include/vectormath/ppu/c/vec_soa.h @@ -0,0 +1,1223 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_VEC_SOA_C_H +#define _VECTORMATH_VEC_SOA_C_H +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/*----------------------------------------------------------------------------- + * Constants + * for permutes, words are labeled [x,y,z,w] [a,b,c,d] + */ +#define _VECTORMATH_PERM_X 0x00010203 +#define _VECTORMATH_PERM_Y 0x04050607 +#define _VECTORMATH_PERM_Z 0x08090a0b +#define _VECTORMATH_PERM_W 0x0c0d0e0f +#define _VECTORMATH_PERM_A 0x10111213 +#define _VECTORMATH_PERM_B 0x14151617 +#define _VECTORMATH_PERM_C 0x18191a1b +#define _VECTORMATH_PERM_D 0x1c1d1e1f +#define _VECTORMATH_PERM_ZBWX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B, _VECTORMATH_PERM_W, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_XCYX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_C, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_ZDWX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_D, _VECTORMATH_PERM_W, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_ZCXA ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_C, _VECTORMATH_PERM_X, _VECTORMATH_PERM_A }) +#define _VECTORMATH_PERM_XBZD ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_B, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_D }) +#define _VECTORMATH_PERM_WDYB ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_W, _VECTORMATH_PERM_D, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_B }) +#define _VECTORMATH_PERM_ZBXD ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B, _VECTORMATH_PERM_X, _VECTORMATH_PERM_D }) +#define _VECTORMATH_PERM_WCYA ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_W, _VECTORMATH_PERM_C, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A }) +#define _VECTORMATH_PERM_XDZB ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_D, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B }) +#define _VECTORMATH_SLERP_TOL 0.999f + +/*----------------------------------------------------------------------------- + * Definitions + */ +#ifndef _VECTORMATH_INTERNAL_FUNCTIONS +#define _VECTORMATH_INTERNAL_FUNCTIONS + +#endif + +static inline void vmathSoaV3Copy( VmathSoaVector3 *result, const VmathSoaVector3 *vec ) +{ + result->x = vec->x; + result->y = vec->y; + result->z = vec->z; +} + +static inline void vmathSoaV3MakeFromElems( VmathSoaVector3 *result, vec_float4 _x, vec_float4 _y, vec_float4 _z ) +{ + result->x = _x; + result->y = _y; + result->z = _z; +} + +static inline void vmathSoaV3MakeFromP3( VmathSoaVector3 *result, const VmathSoaPoint3 *pnt ) +{ + result->x = pnt->x; + result->y = pnt->y; + result->z = pnt->z; +} + +static inline void vmathSoaV3MakeFromScalar( VmathSoaVector3 *result, vec_float4 scalar ) +{ + result->x = scalar; + result->y = scalar; + result->z = scalar; +} + +static inline void vmathSoaV3MakeFromAos( VmathSoaVector3 *result, const VmathVector3 *vec ) +{ + vec_float4 vec128 = vec->vec128; + result->x = vec_splat( vec128, 0 ); + result->y = vec_splat( vec128, 1 ); + result->z = vec_splat( vec128, 2 ); +} + +static inline void vmathSoaV3MakeFrom4Aos( VmathSoaVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1, const VmathVector3 *vec2, const VmathVector3 *vec3 ) +{ + vec_float4 tmp0, tmp1, tmp2, tmp3; + tmp0 = vec_mergeh( vec0->vec128, vec2->vec128 ); + tmp1 = vec_mergeh( vec1->vec128, vec3->vec128 ); + tmp2 = vec_mergel( vec0->vec128, vec2->vec128 ); + tmp3 = vec_mergel( vec1->vec128, vec3->vec128 ); + result->x = vec_mergeh( tmp0, tmp1 ); + result->y = vec_mergel( tmp0, tmp1 ); + result->z = vec_mergeh( tmp2, tmp3 ); +} + +static inline void vmathSoaV3MakeXAxis( VmathSoaVector3 *result ) +{ + vmathSoaV3MakeFromElems( result, ((vec_float4){1.0f,1.0f,1.0f,1.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); +} + +static inline void vmathSoaV3MakeYAxis( VmathSoaVector3 *result ) +{ + vmathSoaV3MakeFromElems( result, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){1.0f,1.0f,1.0f,1.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); +} + +static inline void vmathSoaV3MakeZAxis( VmathSoaVector3 *result ) +{ + vmathSoaV3MakeFromElems( result, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); +} + +static inline void vmathSoaV3Lerp( VmathSoaVector3 *result, vec_float4 t, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) +{ + VmathSoaVector3 tmpV3_0, tmpV3_1; + vmathSoaV3Sub( &tmpV3_0, vec1, vec0 ); + vmathSoaV3ScalarMul( &tmpV3_1, &tmpV3_0, t ); + vmathSoaV3Add( result, vec0, &tmpV3_1 ); +} + +static inline void vmathSoaV3Slerp( VmathSoaVector3 *result, vec_float4 t, const VmathSoaVector3 *unitVec0, const VmathSoaVector3 *unitVec1 ) +{ + VmathSoaVector3 tmpV3_0, tmpV3_1; + vec_float4 recipSinAngle, scale0, scale1, cosAngle, angle; + vec_uint4 selectMask; + cosAngle = vmathSoaV3Dot( unitVec0, unitVec1 ); + selectMask = (vec_uint4)vec_cmpgt( (vec_float4){_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL}, cosAngle ); + angle = acosf4( cosAngle ); + recipSinAngle = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sinf4( angle ) ); + scale0 = vec_sel( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), vec_madd( sinf4( vec_madd( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), recipSinAngle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), selectMask ); + scale1 = vec_sel( t, vec_madd( sinf4( vec_madd( t, angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), recipSinAngle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), selectMask ); + vmathSoaV3ScalarMul( &tmpV3_0, unitVec0, scale0 ); + vmathSoaV3ScalarMul( &tmpV3_1, unitVec1, scale1 ); + vmathSoaV3Add( result, &tmpV3_0, &tmpV3_1 ); +} + +static inline void vmathSoaV3Get4Aos( const VmathSoaVector3 *vec, VmathVector3 *result0, VmathVector3 *result1, VmathVector3 *result2, VmathVector3 *result3 ) +{ + vec_float4 tmp0, tmp1; + tmp0 = vec_mergeh( vec->x, vec->z ); + tmp1 = vec_mergel( vec->x, vec->z ); + vmathV3MakeFrom128( result0, vec_mergeh( tmp0, vec->y ) ); + vmathV3MakeFrom128( result1, vec_perm( tmp0, vec->y, _VECTORMATH_PERM_ZBWX ) ); + vmathV3MakeFrom128( result2, vec_perm( tmp1, vec->y, _VECTORMATH_PERM_XCYX ) ); + vmathV3MakeFrom128( result3, vec_perm( tmp1, vec->y, _VECTORMATH_PERM_ZDWX ) ); +} + +static inline void vmathSoaV3LoadXYZArray( VmathSoaVector3 *vec, const vec_float4 *threeQuads ) +{ + vec_float4 xyxy, yzyz, zxzx, xyzx, yzxy, zxyz; + xyzx = threeQuads[0]; + yzxy = threeQuads[1]; + zxyz = threeQuads[2]; + xyxy = vec_sld( yzxy, xyzx, 8 ); + zxzx = vec_sld( xyzx, zxyz, 8 ); + yzyz = vec_sld( zxyz, yzxy, 8 ); + vmathSoaV3SetX( vec, vec_perm( xyxy, zxzx, _VECTORMATH_PERM_ZBXD ) ); + vmathSoaV3SetY( vec, vec_perm( xyxy, yzyz, _VECTORMATH_PERM_WCYA ) ); + vmathSoaV3SetZ( vec, vec_perm( zxzx, yzyz, _VECTORMATH_PERM_XDZB ) ); +} + +static inline void vmathSoaV3StoreXYZArray( const VmathSoaVector3 *vec, vec_float4 *threeQuads ) +{ + vec_float4 xyzx, yzxy, zxyz, xyxy, zxzx, yzyz; + xyxy = vec_perm( vec->x, vec->y, _VECTORMATH_PERM_ZCXA ); + zxzx = vec_perm( vec->z, vec->x, _VECTORMATH_PERM_XBZD ); + yzyz = vec_perm( vec->y, vec->z, _VECTORMATH_PERM_WDYB ); + xyzx = vec_sld( xyxy, zxzx, 8 ); + yzxy = vec_sld( yzyz, xyxy, 8 ); + zxyz = vec_sld( zxzx, yzyz, 8 ); + threeQuads[0] = xyzx; + threeQuads[1] = yzxy; + threeQuads[2] = zxyz; +} + +static inline void vmathSoaV3StoreHalfFloats( const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1, vec_ushort8 *threeQuads ) +{ + vec_float4 xyz0[3]; + vec_float4 xyz1[3]; + vmathSoaV3StoreXYZArray( vec0, xyz0 ); + vmathSoaV3StoreXYZArray( vec1, xyz1 ); + threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); + threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); + threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); +} + +static inline void vmathSoaV3SetX( VmathSoaVector3 *result, vec_float4 _x ) +{ + result->x = _x; +} + +static inline vec_float4 vmathSoaV3GetX( const VmathSoaVector3 *vec ) +{ + return vec->x; +} + +static inline void vmathSoaV3SetY( VmathSoaVector3 *result, vec_float4 _y ) +{ + result->y = _y; +} + +static inline vec_float4 vmathSoaV3GetY( const VmathSoaVector3 *vec ) +{ + return vec->y; +} + +static inline void vmathSoaV3SetZ( VmathSoaVector3 *result, vec_float4 _z ) +{ + result->z = _z; +} + +static inline vec_float4 vmathSoaV3GetZ( const VmathSoaVector3 *vec ) +{ + return vec->z; +} + +static inline void vmathSoaV3SetElem( VmathSoaVector3 *result, int idx, vec_float4 value ) +{ + *(&result->x + idx) = value; +} + +static inline vec_float4 vmathSoaV3GetElem( const VmathSoaVector3 *vec, int idx ) +{ + return *(&vec->x + idx); +} + +static inline void vmathSoaV3Add( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) +{ + result->x = vec_add( vec0->x, vec1->x ); + result->y = vec_add( vec0->y, vec1->y ); + result->z = vec_add( vec0->z, vec1->z ); +} + +static inline void vmathSoaV3Sub( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) +{ + result->x = vec_sub( vec0->x, vec1->x ); + result->y = vec_sub( vec0->y, vec1->y ); + result->z = vec_sub( vec0->z, vec1->z ); +} + +static inline void vmathSoaV3AddP3( VmathSoaPoint3 *result, const VmathSoaVector3 *vec, const VmathSoaPoint3 *pnt1 ) +{ + result->x = vec_add( vec->x, pnt1->x ); + result->y = vec_add( vec->y, pnt1->y ); + result->z = vec_add( vec->z, pnt1->z ); +} + +static inline void vmathSoaV3ScalarMul( VmathSoaVector3 *result, const VmathSoaVector3 *vec, vec_float4 scalar ) +{ + result->x = vec_madd( vec->x, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + result->y = vec_madd( vec->y, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + result->z = vec_madd( vec->z, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); +} + +static inline void vmathSoaV3ScalarDiv( VmathSoaVector3 *result, const VmathSoaVector3 *vec, vec_float4 scalar ) +{ + result->x = divf4( vec->x, scalar ); + result->y = divf4( vec->y, scalar ); + result->z = divf4( vec->z, scalar ); +} + +static inline void vmathSoaV3Neg( VmathSoaVector3 *result, const VmathSoaVector3 *vec ) +{ + result->x = negatef4( vec->x ); + result->y = negatef4( vec->y ); + result->z = negatef4( vec->z ); +} + +static inline void vmathSoaV3MulPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) +{ + result->x = vec_madd( vec0->x, vec1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + result->y = vec_madd( vec0->y, vec1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + result->z = vec_madd( vec0->z, vec1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); +} + +static inline void vmathSoaV3DivPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) +{ + result->x = divf4( vec0->x, vec1->x ); + result->y = divf4( vec0->y, vec1->y ); + result->z = divf4( vec0->z, vec1->z ); +} + +static inline void vmathSoaV3RecipPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec ) +{ + result->x = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec->x ); + result->y = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec->y ); + result->z = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec->z ); +} + +static inline void vmathSoaV3SqrtPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec ) +{ + result->x = sqrtf4( vec->x ); + result->y = sqrtf4( vec->y ); + result->z = sqrtf4( vec->z ); +} + +static inline void vmathSoaV3RsqrtPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec ) +{ + result->x = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( vec->x ) ); + result->y = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( vec->y ) ); + result->z = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( vec->z ) ); +} + +static inline void vmathSoaV3AbsPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec ) +{ + result->x = fabsf4( vec->x ); + result->y = fabsf4( vec->y ); + result->z = fabsf4( vec->z ); +} + +static inline void vmathSoaV3CopySignPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) +{ + result->x = copysignf4( vec0->x, vec1->x ); + result->y = copysignf4( vec0->y, vec1->y ); + result->z = copysignf4( vec0->z, vec1->z ); +} + +static inline void vmathSoaV3MaxPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) +{ + result->x = fmaxf4( vec0->x, vec1->x ); + result->y = fmaxf4( vec0->y, vec1->y ); + result->z = fmaxf4( vec0->z, vec1->z ); +} + +static inline vec_float4 vmathSoaV3MaxElem( const VmathSoaVector3 *vec ) +{ + vec_float4 result; + result = fmaxf4( vec->x, vec->y ); + result = fmaxf4( vec->z, result ); + return result; +} + +static inline void vmathSoaV3MinPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) +{ + result->x = fminf4( vec0->x, vec1->x ); + result->y = fminf4( vec0->y, vec1->y ); + result->z = fminf4( vec0->z, vec1->z ); +} + +static inline vec_float4 vmathSoaV3MinElem( const VmathSoaVector3 *vec ) +{ + vec_float4 result; + result = fminf4( vec->x, vec->y ); + result = fminf4( vec->z, result ); + return result; +} + +static inline vec_float4 vmathSoaV3Sum( const VmathSoaVector3 *vec ) +{ + vec_float4 result; + result = vec_add( vec->x, vec->y ); + result = vec_add( result, vec->z ); + return result; +} + +static inline vec_float4 vmathSoaV3Dot( const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) +{ + vec_float4 result; + result = vec_madd( vec0->x, vec1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + result = vec_add( result, vec_madd( vec0->y, vec1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + result = vec_add( result, vec_madd( vec0->z, vec1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + return result; +} + +static inline vec_float4 vmathSoaV3LengthSqr( const VmathSoaVector3 *vec ) +{ + vec_float4 result; + result = vec_madd( vec->x, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + result = vec_add( result, vec_madd( vec->y, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + result = vec_add( result, vec_madd( vec->z, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + return result; +} + +static inline vec_float4 vmathSoaV3Length( const VmathSoaVector3 *vec ) +{ + return sqrtf4( vmathSoaV3LengthSqr( vec ) ); +} + +static inline void vmathSoaV3Normalize( VmathSoaVector3 *result, const VmathSoaVector3 *vec ) +{ + vec_float4 lenSqr, lenInv; + lenSqr = vmathSoaV3LengthSqr( vec ); + lenInv = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( lenSqr ) ); + result->x = vec_madd( vec->x, lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + result->y = vec_madd( vec->y, lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + result->z = vec_madd( vec->z, lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); +} + +static inline void vmathSoaV3Cross( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) +{ + vec_float4 tmpX, tmpY, tmpZ; + tmpX = vec_sub( vec_madd( vec0->y, vec1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( vec0->z, vec1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmpY = vec_sub( vec_madd( vec0->z, vec1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( vec0->x, vec1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmpZ = vec_sub( vec_madd( vec0->x, vec1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( vec0->y, vec1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + vmathSoaV3MakeFromElems( result, tmpX, tmpY, tmpZ ); +} + +static inline void vmathSoaV3Select( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1, vec_uint4 select1 ) +{ + result->x = vec_sel( vec0->x, vec1->x, select1 ); + result->y = vec_sel( vec0->y, vec1->y, select1 ); + result->z = vec_sel( vec0->z, vec1->z, select1 ); +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathSoaV3Print( const VmathSoaVector3 *vec ) +{ + VmathVector3 vec0, vec1, vec2, vec3; + vmathSoaV3Get4Aos( vec, &vec0, &vec1, &vec2, &vec3 ); + printf("slot 0:\n"); + vmathV3Print( &vec0 ); + printf("slot 1:\n"); + vmathV3Print( &vec1 ); + printf("slot 2:\n"); + vmathV3Print( &vec2 ); + printf("slot 3:\n"); + vmathV3Print( &vec3 ); +} + +static inline void vmathSoaV3Prints( const VmathSoaVector3 *vec, const char *name ) +{ + VmathVector3 vec0, vec1, vec2, vec3; + printf( "%s:\n", name ); + vmathSoaV3Get4Aos( vec, &vec0, &vec1, &vec2, &vec3 ); + printf("slot 0:\n"); + vmathV3Print( &vec0 ); + printf("slot 1:\n"); + vmathV3Print( &vec1 ); + printf("slot 2:\n"); + vmathV3Print( &vec2 ); + printf("slot 3:\n"); + vmathV3Print( &vec3 ); +} + +#endif + +static inline void vmathSoaV4Copy( VmathSoaVector4 *result, const VmathSoaVector4 *vec ) +{ + result->x = vec->x; + result->y = vec->y; + result->z = vec->z; + result->w = vec->w; +} + +static inline void vmathSoaV4MakeFromElems( VmathSoaVector4 *result, vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w ) +{ + result->x = _x; + result->y = _y; + result->z = _z; + result->w = _w; +} + +static inline void vmathSoaV4MakeFromV3Scalar( VmathSoaVector4 *result, const VmathSoaVector3 *xyz, vec_float4 _w ) +{ + vmathSoaV4SetXYZ( result, xyz ); + vmathSoaV4SetW( result, _w ); +} + +static inline void vmathSoaV4MakeFromV3( VmathSoaVector4 *result, const VmathSoaVector3 *vec ) +{ + result->x = vec->x; + result->y = vec->y; + result->z = vec->z; + result->w = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); +} + +static inline void vmathSoaV4MakeFromP3( VmathSoaVector4 *result, const VmathSoaPoint3 *pnt ) +{ + result->x = pnt->x; + result->y = pnt->y; + result->z = pnt->z; + result->w = ((vec_float4){1.0f,1.0f,1.0f,1.0f}); +} + +static inline void vmathSoaV4MakeFromQ( VmathSoaVector4 *result, const VmathSoaQuat *quat ) +{ + result->x = quat->x; + result->y = quat->y; + result->z = quat->z; + result->w = quat->w; +} + +static inline void vmathSoaV4MakeFromScalar( VmathSoaVector4 *result, vec_float4 scalar ) +{ + result->x = scalar; + result->y = scalar; + result->z = scalar; + result->w = scalar; +} + +static inline void vmathSoaV4MakeFromAos( VmathSoaVector4 *result, const VmathVector4 *vec ) +{ + vec_float4 vec128 = vec->vec128; + result->x = vec_splat( vec128, 0 ); + result->y = vec_splat( vec128, 1 ); + result->z = vec_splat( vec128, 2 ); + result->w = vec_splat( vec128, 3 ); +} + +static inline void vmathSoaV4MakeFrom4Aos( VmathSoaVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1, const VmathVector4 *vec2, const VmathVector4 *vec3 ) +{ + vec_float4 tmp0, tmp1, tmp2, tmp3; + tmp0 = vec_mergeh( vec0->vec128, vec2->vec128 ); + tmp1 = vec_mergeh( vec1->vec128, vec3->vec128 ); + tmp2 = vec_mergel( vec0->vec128, vec2->vec128 ); + tmp3 = vec_mergel( vec1->vec128, vec3->vec128 ); + result->x = vec_mergeh( tmp0, tmp1 ); + result->y = vec_mergel( tmp0, tmp1 ); + result->z = vec_mergeh( tmp2, tmp3 ); + result->w = vec_mergel( tmp2, tmp3 ); +} + +static inline void vmathSoaV4MakeXAxis( VmathSoaVector4 *result ) +{ + vmathSoaV4MakeFromElems( result, ((vec_float4){1.0f,1.0f,1.0f,1.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); +} + +static inline void vmathSoaV4MakeYAxis( VmathSoaVector4 *result ) +{ + vmathSoaV4MakeFromElems( result, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){1.0f,1.0f,1.0f,1.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); +} + +static inline void vmathSoaV4MakeZAxis( VmathSoaVector4 *result ) +{ + vmathSoaV4MakeFromElems( result, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){1.0f,1.0f,1.0f,1.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); +} + +static inline void vmathSoaV4MakeWAxis( VmathSoaVector4 *result ) +{ + vmathSoaV4MakeFromElems( result, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); +} + +static inline void vmathSoaV4Lerp( VmathSoaVector4 *result, vec_float4 t, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ) +{ + VmathSoaVector4 tmpV4_0, tmpV4_1; + vmathSoaV4Sub( &tmpV4_0, vec1, vec0 ); + vmathSoaV4ScalarMul( &tmpV4_1, &tmpV4_0, t ); + vmathSoaV4Add( result, vec0, &tmpV4_1 ); +} + +static inline void vmathSoaV4Slerp( VmathSoaVector4 *result, vec_float4 t, const VmathSoaVector4 *unitVec0, const VmathSoaVector4 *unitVec1 ) +{ + VmathSoaVector4 tmpV4_0, tmpV4_1; + vec_float4 recipSinAngle, scale0, scale1, cosAngle, angle; + vec_uint4 selectMask; + cosAngle = vmathSoaV4Dot( unitVec0, unitVec1 ); + selectMask = (vec_uint4)vec_cmpgt( (vec_float4){_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL}, cosAngle ); + angle = acosf4( cosAngle ); + recipSinAngle = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sinf4( angle ) ); + scale0 = vec_sel( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), vec_madd( sinf4( vec_madd( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), recipSinAngle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), selectMask ); + scale1 = vec_sel( t, vec_madd( sinf4( vec_madd( t, angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), recipSinAngle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), selectMask ); + vmathSoaV4ScalarMul( &tmpV4_0, unitVec0, scale0 ); + vmathSoaV4ScalarMul( &tmpV4_1, unitVec1, scale1 ); + vmathSoaV4Add( result, &tmpV4_0, &tmpV4_1 ); +} + +static inline void vmathSoaV4Get4Aos( const VmathSoaVector4 *vec, VmathVector4 *result0, VmathVector4 *result1, VmathVector4 *result2, VmathVector4 *result3 ) +{ + vec_float4 tmp0, tmp1, tmp2, tmp3; + tmp0 = vec_mergeh( vec->x, vec->z ); + tmp1 = vec_mergeh( vec->y, vec->w ); + tmp2 = vec_mergel( vec->x, vec->z ); + tmp3 = vec_mergel( vec->y, vec->w ); + vmathV4MakeFrom128( result0, vec_mergeh( tmp0, tmp1 ) ); + vmathV4MakeFrom128( result1, vec_mergel( tmp0, tmp1 ) ); + vmathV4MakeFrom128( result2, vec_mergeh( tmp2, tmp3 ) ); + vmathV4MakeFrom128( result3, vec_mergel( tmp2, tmp3 ) ); +} + +static inline void vmathSoaV4StoreHalfFloats( const VmathSoaVector4 *vec, vec_ushort8 *twoQuads ) +{ + VmathVector4 v0, v1, v2, v3; + vmathSoaV4Get4Aos( vec, &v0, &v1, &v2, &v3 ); + twoQuads[0] = _vmath2VfToHalfFloats(v0.vec128, v1.vec128); + twoQuads[1] = _vmath2VfToHalfFloats(v2.vec128, v3.vec128); +} + +static inline void vmathSoaV4SetXYZ( VmathSoaVector4 *result, const VmathSoaVector3 *vec ) +{ + result->x = vec->x; + result->y = vec->y; + result->z = vec->z; +} + +static inline void vmathSoaV4GetXYZ( VmathSoaVector3 *result, const VmathSoaVector4 *vec ) +{ + vmathSoaV3MakeFromElems( result, vec->x, vec->y, vec->z ); +} + +static inline void vmathSoaV4SetX( VmathSoaVector4 *result, vec_float4 _x ) +{ + result->x = _x; +} + +static inline vec_float4 vmathSoaV4GetX( const VmathSoaVector4 *vec ) +{ + return vec->x; +} + +static inline void vmathSoaV4SetY( VmathSoaVector4 *result, vec_float4 _y ) +{ + result->y = _y; +} + +static inline vec_float4 vmathSoaV4GetY( const VmathSoaVector4 *vec ) +{ + return vec->y; +} + +static inline void vmathSoaV4SetZ( VmathSoaVector4 *result, vec_float4 _z ) +{ + result->z = _z; +} + +static inline vec_float4 vmathSoaV4GetZ( const VmathSoaVector4 *vec ) +{ + return vec->z; +} + +static inline void vmathSoaV4SetW( VmathSoaVector4 *result, vec_float4 _w ) +{ + result->w = _w; +} + +static inline vec_float4 vmathSoaV4GetW( const VmathSoaVector4 *vec ) +{ + return vec->w; +} + +static inline void vmathSoaV4SetElem( VmathSoaVector4 *result, int idx, vec_float4 value ) +{ + *(&result->x + idx) = value; +} + +static inline vec_float4 vmathSoaV4GetElem( const VmathSoaVector4 *vec, int idx ) +{ + return *(&vec->x + idx); +} + +static inline void vmathSoaV4Add( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ) +{ + result->x = vec_add( vec0->x, vec1->x ); + result->y = vec_add( vec0->y, vec1->y ); + result->z = vec_add( vec0->z, vec1->z ); + result->w = vec_add( vec0->w, vec1->w ); +} + +static inline void vmathSoaV4Sub( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ) +{ + result->x = vec_sub( vec0->x, vec1->x ); + result->y = vec_sub( vec0->y, vec1->y ); + result->z = vec_sub( vec0->z, vec1->z ); + result->w = vec_sub( vec0->w, vec1->w ); +} + +static inline void vmathSoaV4ScalarMul( VmathSoaVector4 *result, const VmathSoaVector4 *vec, vec_float4 scalar ) +{ + result->x = vec_madd( vec->x, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + result->y = vec_madd( vec->y, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + result->z = vec_madd( vec->z, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + result->w = vec_madd( vec->w, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); +} + +static inline void vmathSoaV4ScalarDiv( VmathSoaVector4 *result, const VmathSoaVector4 *vec, vec_float4 scalar ) +{ + result->x = divf4( vec->x, scalar ); + result->y = divf4( vec->y, scalar ); + result->z = divf4( vec->z, scalar ); + result->w = divf4( vec->w, scalar ); +} + +static inline void vmathSoaV4Neg( VmathSoaVector4 *result, const VmathSoaVector4 *vec ) +{ + result->x = negatef4( vec->x ); + result->y = negatef4( vec->y ); + result->z = negatef4( vec->z ); + result->w = negatef4( vec->w ); +} + +static inline void vmathSoaV4MulPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ) +{ + result->x = vec_madd( vec0->x, vec1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + result->y = vec_madd( vec0->y, vec1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + result->z = vec_madd( vec0->z, vec1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + result->w = vec_madd( vec0->w, vec1->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); +} + +static inline void vmathSoaV4DivPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ) +{ + result->x = divf4( vec0->x, vec1->x ); + result->y = divf4( vec0->y, vec1->y ); + result->z = divf4( vec0->z, vec1->z ); + result->w = divf4( vec0->w, vec1->w ); +} + +static inline void vmathSoaV4RecipPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec ) +{ + result->x = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec->x ); + result->y = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec->y ); + result->z = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec->z ); + result->w = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec->w ); +} + +static inline void vmathSoaV4SqrtPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec ) +{ + result->x = sqrtf4( vec->x ); + result->y = sqrtf4( vec->y ); + result->z = sqrtf4( vec->z ); + result->w = sqrtf4( vec->w ); +} + +static inline void vmathSoaV4RsqrtPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec ) +{ + result->x = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( vec->x ) ); + result->y = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( vec->y ) ); + result->z = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( vec->z ) ); + result->w = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( vec->w ) ); +} + +static inline void vmathSoaV4AbsPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec ) +{ + result->x = fabsf4( vec->x ); + result->y = fabsf4( vec->y ); + result->z = fabsf4( vec->z ); + result->w = fabsf4( vec->w ); +} + +static inline void vmathSoaV4CopySignPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ) +{ + result->x = copysignf4( vec0->x, vec1->x ); + result->y = copysignf4( vec0->y, vec1->y ); + result->z = copysignf4( vec0->z, vec1->z ); + result->w = copysignf4( vec0->w, vec1->w ); +} + +static inline void vmathSoaV4MaxPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ) +{ + result->x = fmaxf4( vec0->x, vec1->x ); + result->y = fmaxf4( vec0->y, vec1->y ); + result->z = fmaxf4( vec0->z, vec1->z ); + result->w = fmaxf4( vec0->w, vec1->w ); +} + +static inline vec_float4 vmathSoaV4MaxElem( const VmathSoaVector4 *vec ) +{ + vec_float4 result; + result = fmaxf4( vec->x, vec->y ); + result = fmaxf4( vec->z, result ); + result = fmaxf4( vec->w, result ); + return result; +} + +static inline void vmathSoaV4MinPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ) +{ + result->x = fminf4( vec0->x, vec1->x ); + result->y = fminf4( vec0->y, vec1->y ); + result->z = fminf4( vec0->z, vec1->z ); + result->w = fminf4( vec0->w, vec1->w ); +} + +static inline vec_float4 vmathSoaV4MinElem( const VmathSoaVector4 *vec ) +{ + vec_float4 result; + result = fminf4( vec->x, vec->y ); + result = fminf4( vec->z, result ); + result = fminf4( vec->w, result ); + return result; +} + +static inline vec_float4 vmathSoaV4Sum( const VmathSoaVector4 *vec ) +{ + vec_float4 result; + result = vec_add( vec->x, vec->y ); + result = vec_add( result, vec->z ); + result = vec_add( result, vec->w ); + return result; +} + +static inline vec_float4 vmathSoaV4Dot( const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ) +{ + vec_float4 result; + result = vec_madd( vec0->x, vec1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + result = vec_add( result, vec_madd( vec0->y, vec1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + result = vec_add( result, vec_madd( vec0->z, vec1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + result = vec_add( result, vec_madd( vec0->w, vec1->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + return result; +} + +static inline vec_float4 vmathSoaV4LengthSqr( const VmathSoaVector4 *vec ) +{ + vec_float4 result; + result = vec_madd( vec->x, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + result = vec_add( result, vec_madd( vec->y, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + result = vec_add( result, vec_madd( vec->z, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + result = vec_add( result, vec_madd( vec->w, vec->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + return result; +} + +static inline vec_float4 vmathSoaV4Length( const VmathSoaVector4 *vec ) +{ + return sqrtf4( vmathSoaV4LengthSqr( vec ) ); +} + +static inline void vmathSoaV4Normalize( VmathSoaVector4 *result, const VmathSoaVector4 *vec ) +{ + vec_float4 lenSqr, lenInv; + lenSqr = vmathSoaV4LengthSqr( vec ); + lenInv = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( lenSqr ) ); + result->x = vec_madd( vec->x, lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + result->y = vec_madd( vec->y, lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + result->z = vec_madd( vec->z, lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + result->w = vec_madd( vec->w, lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); +} + +static inline void vmathSoaV4Select( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1, vec_uint4 select1 ) +{ + result->x = vec_sel( vec0->x, vec1->x, select1 ); + result->y = vec_sel( vec0->y, vec1->y, select1 ); + result->z = vec_sel( vec0->z, vec1->z, select1 ); + result->w = vec_sel( vec0->w, vec1->w, select1 ); +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathSoaV4Print( const VmathSoaVector4 *vec ) +{ + VmathVector4 vec0, vec1, vec2, vec3; + vmathSoaV4Get4Aos( vec, &vec0, &vec1, &vec2, &vec3 ); + printf("slot 0:\n"); + vmathV4Print( &vec0 ); + printf("slot 1:\n"); + vmathV4Print( &vec1 ); + printf("slot 2:\n"); + vmathV4Print( &vec2 ); + printf("slot 3:\n"); + vmathV4Print( &vec3 ); +} + +static inline void vmathSoaV4Prints( const VmathSoaVector4 *vec, const char *name ) +{ + VmathVector4 vec0, vec1, vec2, vec3; + printf( "%s:\n", name ); + vmathSoaV4Get4Aos( vec, &vec0, &vec1, &vec2, &vec3 ); + printf("slot 0:\n"); + vmathV4Print( &vec0 ); + printf("slot 1:\n"); + vmathV4Print( &vec1 ); + printf("slot 2:\n"); + vmathV4Print( &vec2 ); + printf("slot 3:\n"); + vmathV4Print( &vec3 ); +} + +#endif + +static inline void vmathSoaP3Copy( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ) +{ + result->x = pnt->x; + result->y = pnt->y; + result->z = pnt->z; +} + +static inline void vmathSoaP3MakeFromElems( VmathSoaPoint3 *result, vec_float4 _x, vec_float4 _y, vec_float4 _z ) +{ + result->x = _x; + result->y = _y; + result->z = _z; +} + +static inline void vmathSoaP3MakeFromV3( VmathSoaPoint3 *result, const VmathSoaVector3 *vec ) +{ + result->x = vec->x; + result->y = vec->y; + result->z = vec->z; +} + +static inline void vmathSoaP3MakeFromScalar( VmathSoaPoint3 *result, vec_float4 scalar ) +{ + result->x = scalar; + result->y = scalar; + result->z = scalar; +} + +static inline void vmathSoaP3MakeFromAos( VmathSoaPoint3 *result, const VmathPoint3 *pnt ) +{ + vec_float4 vec128 = pnt->vec128; + result->x = vec_splat( vec128, 0 ); + result->y = vec_splat( vec128, 1 ); + result->z = vec_splat( vec128, 2 ); +} + +static inline void vmathSoaP3MakeFrom4Aos( VmathSoaPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, const VmathPoint3 *pnt2, const VmathPoint3 *pnt3 ) +{ + vec_float4 tmp0, tmp1, tmp2, tmp3; + tmp0 = vec_mergeh( pnt0->vec128, pnt2->vec128 ); + tmp1 = vec_mergeh( pnt1->vec128, pnt3->vec128 ); + tmp2 = vec_mergel( pnt0->vec128, pnt2->vec128 ); + tmp3 = vec_mergel( pnt1->vec128, pnt3->vec128 ); + result->x = vec_mergeh( tmp0, tmp1 ); + result->y = vec_mergel( tmp0, tmp1 ); + result->z = vec_mergeh( tmp2, tmp3 ); +} + +static inline void vmathSoaP3Lerp( VmathSoaPoint3 *result, vec_float4 t, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ) +{ + VmathSoaVector3 tmpV3_0, tmpV3_1; + vmathSoaP3Sub( &tmpV3_0, pnt1, pnt0 ); + vmathSoaV3ScalarMul( &tmpV3_1, &tmpV3_0, t ); + vmathSoaP3AddV3( result, pnt0, &tmpV3_1 ); +} + +static inline void vmathSoaP3Get4Aos( const VmathSoaPoint3 *pnt, VmathPoint3 *result0, VmathPoint3 *result1, VmathPoint3 *result2, VmathPoint3 *result3 ) +{ + vec_float4 tmp0, tmp1; + tmp0 = vec_mergeh( pnt->x, pnt->z ); + tmp1 = vec_mergel( pnt->x, pnt->z ); + vmathP3MakeFrom128( result0, vec_mergeh( tmp0, pnt->y ) ); + vmathP3MakeFrom128( result1, vec_perm( tmp0, pnt->y, _VECTORMATH_PERM_ZBWX ) ); + vmathP3MakeFrom128( result2, vec_perm( tmp1, pnt->y, _VECTORMATH_PERM_XCYX ) ); + vmathP3MakeFrom128( result3, vec_perm( tmp1, pnt->y, _VECTORMATH_PERM_ZDWX ) ); +} + +static inline void vmathSoaP3LoadXYZArray( VmathSoaPoint3 *vec, const vec_float4 *threeQuads ) +{ + vec_float4 xyxy, yzyz, zxzx, xyzx, yzxy, zxyz; + xyzx = threeQuads[0]; + yzxy = threeQuads[1]; + zxyz = threeQuads[2]; + xyxy = vec_sld( yzxy, xyzx, 8 ); + zxzx = vec_sld( xyzx, zxyz, 8 ); + yzyz = vec_sld( zxyz, yzxy, 8 ); + vmathSoaP3SetX( vec, vec_perm( xyxy, zxzx, _VECTORMATH_PERM_ZBXD ) ); + vmathSoaP3SetY( vec, vec_perm( xyxy, yzyz, _VECTORMATH_PERM_WCYA ) ); + vmathSoaP3SetZ( vec, vec_perm( zxzx, yzyz, _VECTORMATH_PERM_XDZB ) ); +} + +static inline void vmathSoaP3StoreXYZArray( const VmathSoaPoint3 *vec, vec_float4 *threeQuads ) +{ + vec_float4 xyzx, yzxy, zxyz, xyxy, zxzx, yzyz; + xyxy = vec_perm( vec->x, vec->y, _VECTORMATH_PERM_ZCXA ); + zxzx = vec_perm( vec->z, vec->x, _VECTORMATH_PERM_XBZD ); + yzyz = vec_perm( vec->y, vec->z, _VECTORMATH_PERM_WDYB ); + xyzx = vec_sld( xyxy, zxzx, 8 ); + yzxy = vec_sld( yzyz, xyxy, 8 ); + zxyz = vec_sld( zxzx, yzyz, 8 ); + threeQuads[0] = xyzx; + threeQuads[1] = yzxy; + threeQuads[2] = zxyz; +} + +static inline void vmathSoaP3StoreHalfFloats( const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1, vec_ushort8 *threeQuads ) +{ + vec_float4 xyz0[3]; + vec_float4 xyz1[3]; + vmathSoaP3StoreXYZArray( pnt0, xyz0 ); + vmathSoaP3StoreXYZArray( pnt1, xyz1 ); + threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); + threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); + threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); +} + +static inline void vmathSoaP3SetX( VmathSoaPoint3 *result, vec_float4 _x ) +{ + result->x = _x; +} + +static inline vec_float4 vmathSoaP3GetX( const VmathSoaPoint3 *pnt ) +{ + return pnt->x; +} + +static inline void vmathSoaP3SetY( VmathSoaPoint3 *result, vec_float4 _y ) +{ + result->y = _y; +} + +static inline vec_float4 vmathSoaP3GetY( const VmathSoaPoint3 *pnt ) +{ + return pnt->y; +} + +static inline void vmathSoaP3SetZ( VmathSoaPoint3 *result, vec_float4 _z ) +{ + result->z = _z; +} + +static inline vec_float4 vmathSoaP3GetZ( const VmathSoaPoint3 *pnt ) +{ + return pnt->z; +} + +static inline void vmathSoaP3SetElem( VmathSoaPoint3 *result, int idx, vec_float4 value ) +{ + *(&result->x + idx) = value; +} + +static inline vec_float4 vmathSoaP3GetElem( const VmathSoaPoint3 *pnt, int idx ) +{ + return *(&pnt->x + idx); +} + +static inline void vmathSoaP3Sub( VmathSoaVector3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ) +{ + result->x = vec_sub( pnt0->x, pnt1->x ); + result->y = vec_sub( pnt0->y, pnt1->y ); + result->z = vec_sub( pnt0->z, pnt1->z ); +} + +static inline void vmathSoaP3AddV3( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt, const VmathSoaVector3 *vec1 ) +{ + result->x = vec_add( pnt->x, vec1->x ); + result->y = vec_add( pnt->y, vec1->y ); + result->z = vec_add( pnt->z, vec1->z ); +} + +static inline void vmathSoaP3SubV3( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt, const VmathSoaVector3 *vec1 ) +{ + result->x = vec_sub( pnt->x, vec1->x ); + result->y = vec_sub( pnt->y, vec1->y ); + result->z = vec_sub( pnt->z, vec1->z ); +} + +static inline void vmathSoaP3MulPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ) +{ + result->x = vec_madd( pnt0->x, pnt1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + result->y = vec_madd( pnt0->y, pnt1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + result->z = vec_madd( pnt0->z, pnt1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); +} + +static inline void vmathSoaP3DivPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ) +{ + result->x = divf4( pnt0->x, pnt1->x ); + result->y = divf4( pnt0->y, pnt1->y ); + result->z = divf4( pnt0->z, pnt1->z ); +} + +static inline void vmathSoaP3RecipPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ) +{ + result->x = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), pnt->x ); + result->y = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), pnt->y ); + result->z = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), pnt->z ); +} + +static inline void vmathSoaP3SqrtPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ) +{ + result->x = sqrtf4( pnt->x ); + result->y = sqrtf4( pnt->y ); + result->z = sqrtf4( pnt->z ); +} + +static inline void vmathSoaP3RsqrtPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ) +{ + result->x = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( pnt->x ) ); + result->y = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( pnt->y ) ); + result->z = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( pnt->z ) ); +} + +static inline void vmathSoaP3AbsPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ) +{ + result->x = fabsf4( pnt->x ); + result->y = fabsf4( pnt->y ); + result->z = fabsf4( pnt->z ); +} + +static inline void vmathSoaP3CopySignPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ) +{ + result->x = copysignf4( pnt0->x, pnt1->x ); + result->y = copysignf4( pnt0->y, pnt1->y ); + result->z = copysignf4( pnt0->z, pnt1->z ); +} + +static inline void vmathSoaP3MaxPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ) +{ + result->x = fmaxf4( pnt0->x, pnt1->x ); + result->y = fmaxf4( pnt0->y, pnt1->y ); + result->z = fmaxf4( pnt0->z, pnt1->z ); +} + +static inline vec_float4 vmathSoaP3MaxElem( const VmathSoaPoint3 *pnt ) +{ + vec_float4 result; + result = fmaxf4( pnt->x, pnt->y ); + result = fmaxf4( pnt->z, result ); + return result; +} + +static inline void vmathSoaP3MinPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ) +{ + result->x = fminf4( pnt0->x, pnt1->x ); + result->y = fminf4( pnt0->y, pnt1->y ); + result->z = fminf4( pnt0->z, pnt1->z ); +} + +static inline vec_float4 vmathSoaP3MinElem( const VmathSoaPoint3 *pnt ) +{ + vec_float4 result; + result = fminf4( pnt->x, pnt->y ); + result = fminf4( pnt->z, result ); + return result; +} + +static inline vec_float4 vmathSoaP3Sum( const VmathSoaPoint3 *pnt ) +{ + vec_float4 result; + result = vec_add( pnt->x, pnt->y ); + result = vec_add( result, pnt->z ); + return result; +} + +static inline void vmathSoaP3Scale( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt, vec_float4 scaleVal ) +{ + VmathSoaPoint3 tmpP3_0; + vmathSoaP3MakeFromScalar( &tmpP3_0, scaleVal ); + vmathSoaP3MulPerElem( result, pnt, &tmpP3_0 ); +} + +static inline void vmathSoaP3NonUniformScale( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt, const VmathSoaVector3 *scaleVec ) +{ + VmathSoaPoint3 tmpP3_0; + vmathSoaP3MakeFromV3( &tmpP3_0, scaleVec ); + vmathSoaP3MulPerElem( result, pnt, &tmpP3_0 ); +} + +static inline vec_float4 vmathSoaP3Projection( const VmathSoaPoint3 *pnt, const VmathSoaVector3 *unitVec ) +{ + vec_float4 result; + result = vec_madd( pnt->x, unitVec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + result = vec_add( result, vec_madd( pnt->y, unitVec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + result = vec_add( result, vec_madd( pnt->z, unitVec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + return result; +} + +static inline vec_float4 vmathSoaP3DistSqrFromOrigin( const VmathSoaPoint3 *pnt ) +{ + VmathSoaVector3 tmpV3_0; + vmathSoaV3MakeFromP3( &tmpV3_0, pnt ); + return vmathSoaV3LengthSqr( &tmpV3_0 ); +} + +static inline vec_float4 vmathSoaP3DistFromOrigin( const VmathSoaPoint3 *pnt ) +{ + VmathSoaVector3 tmpV3_0; + vmathSoaV3MakeFromP3( &tmpV3_0, pnt ); + return vmathSoaV3Length( &tmpV3_0 ); +} + +static inline vec_float4 vmathSoaP3DistSqr( const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ) +{ + VmathSoaVector3 tmpV3_0; + vmathSoaP3Sub( &tmpV3_0, pnt1, pnt0 ); + return vmathSoaV3LengthSqr( &tmpV3_0 ); +} + +static inline vec_float4 vmathSoaP3Dist( const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ) +{ + VmathSoaVector3 tmpV3_0; + vmathSoaP3Sub( &tmpV3_0, pnt1, pnt0 ); + return vmathSoaV3Length( &tmpV3_0 ); +} + +static inline void vmathSoaP3Select( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1, vec_uint4 select1 ) +{ + result->x = vec_sel( pnt0->x, pnt1->x, select1 ); + result->y = vec_sel( pnt0->y, pnt1->y, select1 ); + result->z = vec_sel( pnt0->z, pnt1->z, select1 ); +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathSoaP3Print( const VmathSoaPoint3 *pnt ) +{ + VmathPoint3 vec0, vec1, vec2, vec3; + vmathSoaP3Get4Aos( pnt, &vec0, &vec1, &vec2, &vec3 ); + printf("slot 0:\n"); + vmathP3Print( &vec0 ); + printf("slot 1:\n"); + vmathP3Print( &vec1 ); + printf("slot 2:\n"); + vmathP3Print( &vec2 ); + printf("slot 3:\n"); + vmathP3Print( &vec3 ); +} + +static inline void vmathSoaP3Prints( const VmathSoaPoint3 *pnt, const char *name ) +{ + VmathPoint3 vec0, vec1, vec2, vec3; + printf( "%s:\n", name ); + vmathSoaP3Get4Aos( pnt, &vec0, &vec1, &vec2, &vec3 ); + printf("slot 0:\n"); + vmathP3Print( &vec0 ); + printf("slot 1:\n"); + vmathP3Print( &vec1 ); + printf("slot 2:\n"); + vmathP3Print( &vec2 ); + printf("slot 3:\n"); + vmathP3Print( &vec3 ); +} + +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/vectormathlibrary/include/vectormath/ppu/c/vec_soa_v.h b/vectormathlibrary/include/vectormath/ppu/c/vec_soa_v.h new file mode 100644 index 000000000..75d7bb6bc --- /dev/null +++ b/vectormathlibrary/include/vectormath/ppu/c/vec_soa_v.h @@ -0,0 +1,958 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_VEC_SOA_V_C_H +#define _VECTORMATH_VEC_SOA_V_C_H +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/*----------------------------------------------------------------------------- + * Constants + * for permutes, words are labeled [x,y,z,w] [a,b,c,d] + */ +#define _VECTORMATH_PERM_X 0x00010203 +#define _VECTORMATH_PERM_Y 0x04050607 +#define _VECTORMATH_PERM_Z 0x08090a0b +#define _VECTORMATH_PERM_W 0x0c0d0e0f +#define _VECTORMATH_PERM_A 0x10111213 +#define _VECTORMATH_PERM_B 0x14151617 +#define _VECTORMATH_PERM_C 0x18191a1b +#define _VECTORMATH_PERM_D 0x1c1d1e1f +#define _VECTORMATH_PERM_ZBWX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B, _VECTORMATH_PERM_W, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_XCYX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_C, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_ZDWX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_D, _VECTORMATH_PERM_W, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_ZCXA ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_C, _VECTORMATH_PERM_X, _VECTORMATH_PERM_A }) +#define _VECTORMATH_PERM_XBZD ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_B, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_D }) +#define _VECTORMATH_PERM_WDYB ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_W, _VECTORMATH_PERM_D, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_B }) +#define _VECTORMATH_PERM_ZBXD ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B, _VECTORMATH_PERM_X, _VECTORMATH_PERM_D }) +#define _VECTORMATH_PERM_WCYA ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_W, _VECTORMATH_PERM_C, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A }) +#define _VECTORMATH_PERM_XDZB ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_D, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B }) +#define _VECTORMATH_SLERP_TOL 0.999f + +/*----------------------------------------------------------------------------- + * Definitions + */ +#ifndef _VECTORMATH_INTERNAL_FUNCTIONS +#define _VECTORMATH_INTERNAL_FUNCTIONS + +#endif + +static inline VmathSoaVector3 vmathSoaV3MakeFromElems_V( vec_float4 _x, vec_float4 _y, vec_float4 _z ) +{ + VmathSoaVector3 result; + vmathSoaV3MakeFromElems(&result, _x, _y, _z); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3MakeFromP3_V( VmathSoaPoint3 pnt ) +{ + VmathSoaVector3 result; + vmathSoaV3MakeFromP3(&result, &pnt); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3MakeFromScalar_V( vec_float4 scalar ) +{ + VmathSoaVector3 result; + vmathSoaV3MakeFromScalar(&result, scalar); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3MakeFromAos_V( VmathVector3 vec ) +{ + VmathSoaVector3 result; + vmathSoaV3MakeFromAos(&result, &vec); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3MakeFrom4Aos_V( VmathVector3 vec0, VmathVector3 vec1, VmathVector3 vec2, VmathVector3 vec3 ) +{ + VmathSoaVector3 result; + vmathSoaV3MakeFrom4Aos(&result, &vec0, &vec1, &vec2, &vec3); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3MakeXAxis_V( ) +{ + VmathSoaVector3 result; + vmathSoaV3MakeXAxis(&result); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3MakeYAxis_V( ) +{ + VmathSoaVector3 result; + vmathSoaV3MakeYAxis(&result); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3MakeZAxis_V( ) +{ + VmathSoaVector3 result; + vmathSoaV3MakeZAxis(&result); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3Lerp_V( vec_float4 t, VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) +{ + VmathSoaVector3 result; + vmathSoaV3Lerp(&result, t, &vec0, &vec1); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3Slerp_V( vec_float4 t, VmathSoaVector3 unitVec0, VmathSoaVector3 unitVec1 ) +{ + VmathSoaVector3 result; + vmathSoaV3Slerp(&result, t, &unitVec0, &unitVec1); + return result; +} + +static inline void vmathSoaV3Get4Aos_V( VmathSoaVector3 vec, VmathVector3 *result0, VmathVector3 *result1, VmathVector3 *result2, VmathVector3 *result3 ) +{ + vmathSoaV3Get4Aos(&vec, result0, result1, result2, result3); +} + +static inline void vmathSoaV3LoadXYZArray_V( VmathSoaVector3 *vec, const vec_float4 *threeQuads ) +{ + vmathSoaV3LoadXYZArray(vec, threeQuads); +} + +static inline void vmathSoaV3StoreXYZArray_V( VmathSoaVector3 vec, vec_float4 *threeQuads ) +{ + vmathSoaV3StoreXYZArray(&vec, threeQuads); +} + +static inline void vmathSoaV3StoreHalfFloats_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1, vec_ushort8 *threeQuads ) +{ + vmathSoaV3StoreHalfFloats(&vec0, &vec1, threeQuads); +} + +static inline void vmathSoaV3SetX_V( VmathSoaVector3 *result, vec_float4 _x ) +{ + vmathSoaV3SetX(result, _x); +} + +static inline vec_float4 vmathSoaV3GetX_V( VmathSoaVector3 vec ) +{ + return vmathSoaV3GetX(&vec); +} + +static inline void vmathSoaV3SetY_V( VmathSoaVector3 *result, vec_float4 _y ) +{ + vmathSoaV3SetY(result, _y); +} + +static inline vec_float4 vmathSoaV3GetY_V( VmathSoaVector3 vec ) +{ + return vmathSoaV3GetY(&vec); +} + +static inline void vmathSoaV3SetZ_V( VmathSoaVector3 *result, vec_float4 _z ) +{ + vmathSoaV3SetZ(result, _z); +} + +static inline vec_float4 vmathSoaV3GetZ_V( VmathSoaVector3 vec ) +{ + return vmathSoaV3GetZ(&vec); +} + +static inline void vmathSoaV3SetElem_V( VmathSoaVector3 *result, int idx, vec_float4 value ) +{ + vmathSoaV3SetElem(result, idx, value); +} + +static inline vec_float4 vmathSoaV3GetElem_V( VmathSoaVector3 vec, int idx ) +{ + return vmathSoaV3GetElem(&vec, idx); +} + +static inline VmathSoaVector3 vmathSoaV3Add_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) +{ + VmathSoaVector3 result; + vmathSoaV3Add(&result, &vec0, &vec1); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3Sub_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) +{ + VmathSoaVector3 result; + vmathSoaV3Sub(&result, &vec0, &vec1); + return result; +} + +static inline VmathSoaPoint3 vmathSoaV3AddP3_V( VmathSoaVector3 vec, VmathSoaPoint3 pnt1 ) +{ + VmathSoaPoint3 result; + vmathSoaV3AddP3(&result, &vec, &pnt1); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3ScalarMul_V( VmathSoaVector3 vec, vec_float4 scalar ) +{ + VmathSoaVector3 result; + vmathSoaV3ScalarMul(&result, &vec, scalar); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3ScalarDiv_V( VmathSoaVector3 vec, vec_float4 scalar ) +{ + VmathSoaVector3 result; + vmathSoaV3ScalarDiv(&result, &vec, scalar); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3Neg_V( VmathSoaVector3 vec ) +{ + VmathSoaVector3 result; + vmathSoaV3Neg(&result, &vec); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3MulPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) +{ + VmathSoaVector3 result; + vmathSoaV3MulPerElem(&result, &vec0, &vec1); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3DivPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) +{ + VmathSoaVector3 result; + vmathSoaV3DivPerElem(&result, &vec0, &vec1); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3RecipPerElem_V( VmathSoaVector3 vec ) +{ + VmathSoaVector3 result; + vmathSoaV3RecipPerElem(&result, &vec); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3SqrtPerElem_V( VmathSoaVector3 vec ) +{ + VmathSoaVector3 result; + vmathSoaV3SqrtPerElem(&result, &vec); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3RsqrtPerElem_V( VmathSoaVector3 vec ) +{ + VmathSoaVector3 result; + vmathSoaV3RsqrtPerElem(&result, &vec); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3AbsPerElem_V( VmathSoaVector3 vec ) +{ + VmathSoaVector3 result; + vmathSoaV3AbsPerElem(&result, &vec); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3CopySignPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) +{ + VmathSoaVector3 result; + vmathSoaV3CopySignPerElem(&result, &vec0, &vec1); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3MaxPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) +{ + VmathSoaVector3 result; + vmathSoaV3MaxPerElem(&result, &vec0, &vec1); + return result; +} + +static inline vec_float4 vmathSoaV3MaxElem_V( VmathSoaVector3 vec ) +{ + return vmathSoaV3MaxElem(&vec); +} + +static inline VmathSoaVector3 vmathSoaV3MinPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) +{ + VmathSoaVector3 result; + vmathSoaV3MinPerElem(&result, &vec0, &vec1); + return result; +} + +static inline vec_float4 vmathSoaV3MinElem_V( VmathSoaVector3 vec ) +{ + return vmathSoaV3MinElem(&vec); +} + +static inline vec_float4 vmathSoaV3Sum_V( VmathSoaVector3 vec ) +{ + return vmathSoaV3Sum(&vec); +} + +static inline vec_float4 vmathSoaV3Dot_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) +{ + return vmathSoaV3Dot(&vec0, &vec1); +} + +static inline vec_float4 vmathSoaV3LengthSqr_V( VmathSoaVector3 vec ) +{ + return vmathSoaV3LengthSqr(&vec); +} + +static inline vec_float4 vmathSoaV3Length_V( VmathSoaVector3 vec ) +{ + return vmathSoaV3Length(&vec); +} + +static inline VmathSoaVector3 vmathSoaV3Normalize_V( VmathSoaVector3 vec ) +{ + VmathSoaVector3 result; + vmathSoaV3Normalize(&result, &vec); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3Cross_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) +{ + VmathSoaVector3 result; + vmathSoaV3Cross(&result, &vec0, &vec1); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3Select_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1, vec_uint4 select1 ) +{ + VmathSoaVector3 result; + vmathSoaV3Select(&result, &vec0, &vec1, select1); + return result; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathSoaV3Print_V( VmathSoaVector3 vec ) +{ + vmathSoaV3Print(&vec); +} + +static inline void vmathSoaV3Prints_V( VmathSoaVector3 vec, const char *name ) +{ + vmathSoaV3Prints(&vec, name); +} + +#endif + +static inline VmathSoaVector4 vmathSoaV4MakeFromElems_V( vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w ) +{ + VmathSoaVector4 result; + vmathSoaV4MakeFromElems(&result, _x, _y, _z, _w); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4MakeFromV3Scalar_V( VmathSoaVector3 xyz, vec_float4 _w ) +{ + VmathSoaVector4 result; + vmathSoaV4MakeFromV3Scalar(&result, &xyz, _w); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4MakeFromV3_V( VmathSoaVector3 vec ) +{ + VmathSoaVector4 result; + vmathSoaV4MakeFromV3(&result, &vec); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4MakeFromP3_V( VmathSoaPoint3 pnt ) +{ + VmathSoaVector4 result; + vmathSoaV4MakeFromP3(&result, &pnt); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4MakeFromQ_V( VmathSoaQuat quat ) +{ + VmathSoaVector4 result; + vmathSoaV4MakeFromQ(&result, &quat); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4MakeFromScalar_V( vec_float4 scalar ) +{ + VmathSoaVector4 result; + vmathSoaV4MakeFromScalar(&result, scalar); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4MakeFromAos_V( VmathVector4 vec ) +{ + VmathSoaVector4 result; + vmathSoaV4MakeFromAos(&result, &vec); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4MakeFrom4Aos_V( VmathVector4 vec0, VmathVector4 vec1, VmathVector4 vec2, VmathVector4 vec3 ) +{ + VmathSoaVector4 result; + vmathSoaV4MakeFrom4Aos(&result, &vec0, &vec1, &vec2, &vec3); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4MakeXAxis_V( ) +{ + VmathSoaVector4 result; + vmathSoaV4MakeXAxis(&result); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4MakeYAxis_V( ) +{ + VmathSoaVector4 result; + vmathSoaV4MakeYAxis(&result); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4MakeZAxis_V( ) +{ + VmathSoaVector4 result; + vmathSoaV4MakeZAxis(&result); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4MakeWAxis_V( ) +{ + VmathSoaVector4 result; + vmathSoaV4MakeWAxis(&result); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4Lerp_V( vec_float4 t, VmathSoaVector4 vec0, VmathSoaVector4 vec1 ) +{ + VmathSoaVector4 result; + vmathSoaV4Lerp(&result, t, &vec0, &vec1); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4Slerp_V( vec_float4 t, VmathSoaVector4 unitVec0, VmathSoaVector4 unitVec1 ) +{ + VmathSoaVector4 result; + vmathSoaV4Slerp(&result, t, &unitVec0, &unitVec1); + return result; +} + +static inline void vmathSoaV4Get4Aos_V( VmathSoaVector4 vec, VmathVector4 *result0, VmathVector4 *result1, VmathVector4 *result2, VmathVector4 *result3 ) +{ + vmathSoaV4Get4Aos(&vec, result0, result1, result2, result3); +} + +static inline void vmathSoaV4StoreHalfFloats_V( VmathSoaVector4 vec, vec_ushort8 *twoQuads ) +{ + vmathSoaV4StoreHalfFloats(&vec, twoQuads); +} + +static inline void vmathSoaV4SetXYZ_V( VmathSoaVector4 *result, VmathSoaVector3 vec ) +{ + vmathSoaV4SetXYZ(result, &vec); +} + +static inline VmathSoaVector3 vmathSoaV4GetXYZ_V( VmathSoaVector4 vec ) +{ + VmathSoaVector3 result; + vmathSoaV4GetXYZ(&result, &vec); + return result; +} + +static inline void vmathSoaV4SetX_V( VmathSoaVector4 *result, vec_float4 _x ) +{ + vmathSoaV4SetX(result, _x); +} + +static inline vec_float4 vmathSoaV4GetX_V( VmathSoaVector4 vec ) +{ + return vmathSoaV4GetX(&vec); +} + +static inline void vmathSoaV4SetY_V( VmathSoaVector4 *result, vec_float4 _y ) +{ + vmathSoaV4SetY(result, _y); +} + +static inline vec_float4 vmathSoaV4GetY_V( VmathSoaVector4 vec ) +{ + return vmathSoaV4GetY(&vec); +} + +static inline void vmathSoaV4SetZ_V( VmathSoaVector4 *result, vec_float4 _z ) +{ + vmathSoaV4SetZ(result, _z); +} + +static inline vec_float4 vmathSoaV4GetZ_V( VmathSoaVector4 vec ) +{ + return vmathSoaV4GetZ(&vec); +} + +static inline void vmathSoaV4SetW_V( VmathSoaVector4 *result, vec_float4 _w ) +{ + vmathSoaV4SetW(result, _w); +} + +static inline vec_float4 vmathSoaV4GetW_V( VmathSoaVector4 vec ) +{ + return vmathSoaV4GetW(&vec); +} + +static inline void vmathSoaV4SetElem_V( VmathSoaVector4 *result, int idx, vec_float4 value ) +{ + vmathSoaV4SetElem(result, idx, value); +} + +static inline vec_float4 vmathSoaV4GetElem_V( VmathSoaVector4 vec, int idx ) +{ + return vmathSoaV4GetElem(&vec, idx); +} + +static inline VmathSoaVector4 vmathSoaV4Add_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ) +{ + VmathSoaVector4 result; + vmathSoaV4Add(&result, &vec0, &vec1); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4Sub_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ) +{ + VmathSoaVector4 result; + vmathSoaV4Sub(&result, &vec0, &vec1); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4ScalarMul_V( VmathSoaVector4 vec, vec_float4 scalar ) +{ + VmathSoaVector4 result; + vmathSoaV4ScalarMul(&result, &vec, scalar); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4ScalarDiv_V( VmathSoaVector4 vec, vec_float4 scalar ) +{ + VmathSoaVector4 result; + vmathSoaV4ScalarDiv(&result, &vec, scalar); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4Neg_V( VmathSoaVector4 vec ) +{ + VmathSoaVector4 result; + vmathSoaV4Neg(&result, &vec); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4MulPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ) +{ + VmathSoaVector4 result; + vmathSoaV4MulPerElem(&result, &vec0, &vec1); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4DivPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ) +{ + VmathSoaVector4 result; + vmathSoaV4DivPerElem(&result, &vec0, &vec1); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4RecipPerElem_V( VmathSoaVector4 vec ) +{ + VmathSoaVector4 result; + vmathSoaV4RecipPerElem(&result, &vec); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4SqrtPerElem_V( VmathSoaVector4 vec ) +{ + VmathSoaVector4 result; + vmathSoaV4SqrtPerElem(&result, &vec); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4RsqrtPerElem_V( VmathSoaVector4 vec ) +{ + VmathSoaVector4 result; + vmathSoaV4RsqrtPerElem(&result, &vec); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4AbsPerElem_V( VmathSoaVector4 vec ) +{ + VmathSoaVector4 result; + vmathSoaV4AbsPerElem(&result, &vec); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4CopySignPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ) +{ + VmathSoaVector4 result; + vmathSoaV4CopySignPerElem(&result, &vec0, &vec1); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4MaxPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ) +{ + VmathSoaVector4 result; + vmathSoaV4MaxPerElem(&result, &vec0, &vec1); + return result; +} + +static inline vec_float4 vmathSoaV4MaxElem_V( VmathSoaVector4 vec ) +{ + return vmathSoaV4MaxElem(&vec); +} + +static inline VmathSoaVector4 vmathSoaV4MinPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ) +{ + VmathSoaVector4 result; + vmathSoaV4MinPerElem(&result, &vec0, &vec1); + return result; +} + +static inline vec_float4 vmathSoaV4MinElem_V( VmathSoaVector4 vec ) +{ + return vmathSoaV4MinElem(&vec); +} + +static inline vec_float4 vmathSoaV4Sum_V( VmathSoaVector4 vec ) +{ + return vmathSoaV4Sum(&vec); +} + +static inline vec_float4 vmathSoaV4Dot_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ) +{ + return vmathSoaV4Dot(&vec0, &vec1); +} + +static inline vec_float4 vmathSoaV4LengthSqr_V( VmathSoaVector4 vec ) +{ + return vmathSoaV4LengthSqr(&vec); +} + +static inline vec_float4 vmathSoaV4Length_V( VmathSoaVector4 vec ) +{ + return vmathSoaV4Length(&vec); +} + +static inline VmathSoaVector4 vmathSoaV4Normalize_V( VmathSoaVector4 vec ) +{ + VmathSoaVector4 result; + vmathSoaV4Normalize(&result, &vec); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4Select_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1, vec_uint4 select1 ) +{ + VmathSoaVector4 result; + vmathSoaV4Select(&result, &vec0, &vec1, select1); + return result; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathSoaV4Print_V( VmathSoaVector4 vec ) +{ + vmathSoaV4Print(&vec); +} + +static inline void vmathSoaV4Prints_V( VmathSoaVector4 vec, const char *name ) +{ + vmathSoaV4Prints(&vec, name); +} + +#endif + +static inline VmathSoaPoint3 vmathSoaP3MakeFromElems_V( vec_float4 _x, vec_float4 _y, vec_float4 _z ) +{ + VmathSoaPoint3 result; + vmathSoaP3MakeFromElems(&result, _x, _y, _z); + return result; +} + +static inline VmathSoaPoint3 vmathSoaP3MakeFromV3_V( VmathSoaVector3 vec ) +{ + VmathSoaPoint3 result; + vmathSoaP3MakeFromV3(&result, &vec); + return result; +} + +static inline VmathSoaPoint3 vmathSoaP3MakeFromScalar_V( vec_float4 scalar ) +{ + VmathSoaPoint3 result; + vmathSoaP3MakeFromScalar(&result, scalar); + return result; +} + +static inline VmathSoaPoint3 vmathSoaP3MakeFromAos_V( VmathPoint3 pnt ) +{ + VmathSoaPoint3 result; + vmathSoaP3MakeFromAos(&result, &pnt); + return result; +} + +static inline VmathSoaPoint3 vmathSoaP3MakeFrom4Aos_V( VmathPoint3 pnt0, VmathPoint3 pnt1, VmathPoint3 pnt2, VmathPoint3 pnt3 ) +{ + VmathSoaPoint3 result; + vmathSoaP3MakeFrom4Aos(&result, &pnt0, &pnt1, &pnt2, &pnt3); + return result; +} + +static inline VmathSoaPoint3 vmathSoaP3Lerp_V( vec_float4 t, VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ) +{ + VmathSoaPoint3 result; + vmathSoaP3Lerp(&result, t, &pnt0, &pnt1); + return result; +} + +static inline void vmathSoaP3Get4Aos_V( VmathSoaPoint3 pnt, VmathPoint3 *result0, VmathPoint3 *result1, VmathPoint3 *result2, VmathPoint3 *result3 ) +{ + vmathSoaP3Get4Aos(&pnt, result0, result1, result2, result3); +} + +static inline void vmathSoaP3LoadXYZArray_V( VmathSoaPoint3 *vec, const vec_float4 *threeQuads ) +{ + vmathSoaP3LoadXYZArray(vec, threeQuads); +} + +static inline void vmathSoaP3StoreXYZArray_V( VmathSoaPoint3 vec, vec_float4 *threeQuads ) +{ + vmathSoaP3StoreXYZArray(&vec, threeQuads); +} + +static inline void vmathSoaP3StoreHalfFloats_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1, vec_ushort8 *threeQuads ) +{ + vmathSoaP3StoreHalfFloats(&pnt0, &pnt1, threeQuads); +} + +static inline void vmathSoaP3SetX_V( VmathSoaPoint3 *result, vec_float4 _x ) +{ + vmathSoaP3SetX(result, _x); +} + +static inline vec_float4 vmathSoaP3GetX_V( VmathSoaPoint3 pnt ) +{ + return vmathSoaP3GetX(&pnt); +} + +static inline void vmathSoaP3SetY_V( VmathSoaPoint3 *result, vec_float4 _y ) +{ + vmathSoaP3SetY(result, _y); +} + +static inline vec_float4 vmathSoaP3GetY_V( VmathSoaPoint3 pnt ) +{ + return vmathSoaP3GetY(&pnt); +} + +static inline void vmathSoaP3SetZ_V( VmathSoaPoint3 *result, vec_float4 _z ) +{ + vmathSoaP3SetZ(result, _z); +} + +static inline vec_float4 vmathSoaP3GetZ_V( VmathSoaPoint3 pnt ) +{ + return vmathSoaP3GetZ(&pnt); +} + +static inline void vmathSoaP3SetElem_V( VmathSoaPoint3 *result, int idx, vec_float4 value ) +{ + vmathSoaP3SetElem(result, idx, value); +} + +static inline vec_float4 vmathSoaP3GetElem_V( VmathSoaPoint3 pnt, int idx ) +{ + return vmathSoaP3GetElem(&pnt, idx); +} + +static inline VmathSoaVector3 vmathSoaP3Sub_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ) +{ + VmathSoaVector3 result; + vmathSoaP3Sub(&result, &pnt0, &pnt1); + return result; +} + +static inline VmathSoaPoint3 vmathSoaP3AddV3_V( VmathSoaPoint3 pnt, VmathSoaVector3 vec1 ) +{ + VmathSoaPoint3 result; + vmathSoaP3AddV3(&result, &pnt, &vec1); + return result; +} + +static inline VmathSoaPoint3 vmathSoaP3SubV3_V( VmathSoaPoint3 pnt, VmathSoaVector3 vec1 ) +{ + VmathSoaPoint3 result; + vmathSoaP3SubV3(&result, &pnt, &vec1); + return result; +} + +static inline VmathSoaPoint3 vmathSoaP3MulPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ) +{ + VmathSoaPoint3 result; + vmathSoaP3MulPerElem(&result, &pnt0, &pnt1); + return result; +} + +static inline VmathSoaPoint3 vmathSoaP3DivPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ) +{ + VmathSoaPoint3 result; + vmathSoaP3DivPerElem(&result, &pnt0, &pnt1); + return result; +} + +static inline VmathSoaPoint3 vmathSoaP3RecipPerElem_V( VmathSoaPoint3 pnt ) +{ + VmathSoaPoint3 result; + vmathSoaP3RecipPerElem(&result, &pnt); + return result; +} + +static inline VmathSoaPoint3 vmathSoaP3SqrtPerElem_V( VmathSoaPoint3 pnt ) +{ + VmathSoaPoint3 result; + vmathSoaP3SqrtPerElem(&result, &pnt); + return result; +} + +static inline VmathSoaPoint3 vmathSoaP3RsqrtPerElem_V( VmathSoaPoint3 pnt ) +{ + VmathSoaPoint3 result; + vmathSoaP3RsqrtPerElem(&result, &pnt); + return result; +} + +static inline VmathSoaPoint3 vmathSoaP3AbsPerElem_V( VmathSoaPoint3 pnt ) +{ + VmathSoaPoint3 result; + vmathSoaP3AbsPerElem(&result, &pnt); + return result; +} + +static inline VmathSoaPoint3 vmathSoaP3CopySignPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ) +{ + VmathSoaPoint3 result; + vmathSoaP3CopySignPerElem(&result, &pnt0, &pnt1); + return result; +} + +static inline VmathSoaPoint3 vmathSoaP3MaxPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ) +{ + VmathSoaPoint3 result; + vmathSoaP3MaxPerElem(&result, &pnt0, &pnt1); + return result; +} + +static inline vec_float4 vmathSoaP3MaxElem_V( VmathSoaPoint3 pnt ) +{ + return vmathSoaP3MaxElem(&pnt); +} + +static inline VmathSoaPoint3 vmathSoaP3MinPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ) +{ + VmathSoaPoint3 result; + vmathSoaP3MinPerElem(&result, &pnt0, &pnt1); + return result; +} + +static inline vec_float4 vmathSoaP3MinElem_V( VmathSoaPoint3 pnt ) +{ + return vmathSoaP3MinElem(&pnt); +} + +static inline vec_float4 vmathSoaP3Sum_V( VmathSoaPoint3 pnt ) +{ + return vmathSoaP3Sum(&pnt); +} + +static inline VmathSoaPoint3 vmathSoaP3Scale_V( VmathSoaPoint3 pnt, vec_float4 scaleVal ) +{ + VmathSoaPoint3 result; + vmathSoaP3Scale(&result, &pnt, scaleVal); + return result; +} + +static inline VmathSoaPoint3 vmathSoaP3NonUniformScale_V( VmathSoaPoint3 pnt, VmathSoaVector3 scaleVec ) +{ + VmathSoaPoint3 result; + vmathSoaP3NonUniformScale(&result, &pnt, &scaleVec); + return result; +} + +static inline vec_float4 vmathSoaP3Projection_V( VmathSoaPoint3 pnt, VmathSoaVector3 unitVec ) +{ + return vmathSoaP3Projection(&pnt, &unitVec); +} + +static inline vec_float4 vmathSoaP3DistSqrFromOrigin_V( VmathSoaPoint3 pnt ) +{ + return vmathSoaP3DistSqrFromOrigin(&pnt); +} + +static inline vec_float4 vmathSoaP3DistFromOrigin_V( VmathSoaPoint3 pnt ) +{ + return vmathSoaP3DistFromOrigin(&pnt); +} + +static inline vec_float4 vmathSoaP3DistSqr_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ) +{ + return vmathSoaP3DistSqr(&pnt0, &pnt1); +} + +static inline vec_float4 vmathSoaP3Dist_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ) +{ + return vmathSoaP3Dist(&pnt0, &pnt1); +} + +static inline VmathSoaPoint3 vmathSoaP3Select_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1, vec_uint4 select1 ) +{ + VmathSoaPoint3 result; + vmathSoaP3Select(&result, &pnt0, &pnt1, select1); + return result; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathSoaP3Print_V( VmathSoaPoint3 pnt ) +{ + vmathSoaP3Print(&pnt); +} + +static inline void vmathSoaP3Prints_V( VmathSoaPoint3 pnt, const char *name ) +{ + vmathSoaP3Prints(&pnt, name); +} + +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/vectormathlibrary/include/vectormath/ppu/c/vec_types.h b/vectormathlibrary/include/vectormath/ppu/c/vec_types.h new file mode 100644 index 000000000..e35c795fa --- /dev/null +++ b/vectormathlibrary/include/vectormath/ppu/c/vec_types.h @@ -0,0 +1,59 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +/* Single token vector data types for the PowerPC SIMD/Vector Multi-media + eXtension */ + +#ifndef _VEC_TYPES_H_ +#define _VEC_TYPES_H_ 1 + +#define qword vector unsigned char + +#define vec_uchar16 vector unsigned char +#define vec_char16 vector signed char +#define vec_bchar16 vector bool char + +#define vec_ushort8 vector unsigned short +#define vec_short8 vector signed short +#define vec_bshort8 vector bool short + +#define vec_pixel8 vector pixel + +#define vec_uint4 vector unsigned int +#define vec_int4 vector signed int +#define vec_bint4 vector bool int + +#define vec_float4 vector float + +#define vec_ullong2 vector bool char +#define vec_llong2 vector bool short + +#define vec_double2 vector bool int + +#endif /* _VEC_TYPES_H_ */ diff --git a/vectormathlibrary/include/vectormath/ppu/c/vectormath_aos.h b/vectormathlibrary/include/vectormath/ppu/c/vectormath_aos.h new file mode 100644 index 000000000..6a6ccd285 --- /dev/null +++ b/vectormathlibrary/include/vectormath/ppu/c/vectormath_aos.h @@ -0,0 +1,1960 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_AOS_C_PPU_H +#define _VECTORMATH_AOS_C_PPU_H + +#include <math.h> +#include <altivec.h> +#include <simdmath.h> +#include "vec_types.h" + +#ifdef _VECTORMATH_DEBUG +#include <stdio.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#ifndef _VECTORMATH_AOS_C_TYPES_H +#define _VECTORMATH_AOS_C_TYPES_H + +/* A 3-D vector in array-of-structures format + */ +typedef struct _VmathVector3 +{ + vec_float4 vec128; +} VmathVector3; + +/* A 4-D vector in array-of-structures format + */ +typedef struct _VmathVector4 +{ + vec_float4 vec128; +} VmathVector4; + +/* A 3-D point in array-of-structures format + */ +typedef struct _VmathPoint3 +{ + vec_float4 vec128; +} VmathPoint3; + +/* A quaternion in array-of-structures format + */ +typedef struct _VmathQuat +{ + vec_float4 vec128; +} VmathQuat; + +/* A 3x3 matrix in array-of-structures format + */ +typedef struct _VmathMatrix3 +{ + VmathVector3 col0; + VmathVector3 col1; + VmathVector3 col2; +} VmathMatrix3; + +/* A 4x4 matrix in array-of-structures format + */ +typedef struct _VmathMatrix4 +{ + VmathVector4 col0; + VmathVector4 col1; + VmathVector4 col2; + VmathVector4 col3; +} VmathMatrix4; + +/* A 3x4 transformation matrix in array-of-structures format + */ +typedef struct _VmathTransform3 +{ + VmathVector3 col0; + VmathVector3 col1; + VmathVector3 col2; + VmathVector3 col3; +} VmathTransform3; + +#endif + +/* + * Copy a 3-D vector + */ +static inline void vmathV3Copy( VmathVector3 *result, const VmathVector3 *vec ); + +/* + * Construct a 3-D vector from x, y, and z elements + */ +static inline void vmathV3MakeFromElems( VmathVector3 *result, float x, float y, float z ); + +/* + * Copy elements from a 3-D point into a 3-D vector + */ +static inline void vmathV3MakeFromP3( VmathVector3 *result, const VmathPoint3 *pnt ); + +/* + * Set all elements of a 3-D vector to the same scalar value + */ +static inline void vmathV3MakeFromScalar( VmathVector3 *result, float scalar ); + +/* + * Set vector float data in a 3-D vector + */ +static inline void vmathV3MakeFrom128( VmathVector3 *result, vec_float4 vf4 ); + +/* + * Get vector float data from a 3-D vector + */ +static inline vec_float4 vmathV3Get128( const VmathVector3 *vec ); + +/* + * Set the x element of a 3-D vector + */ +static inline void vmathV3SetX( VmathVector3 *result, float x ); + +/* + * Set the y element of a 3-D vector + */ +static inline void vmathV3SetY( VmathVector3 *result, float y ); + +/* + * Set the z element of a 3-D vector + */ +static inline void vmathV3SetZ( VmathVector3 *result, float z ); + +/* + * Get the x element of a 3-D vector + */ +static inline float vmathV3GetX( const VmathVector3 *vec ); + +/* + * Get the y element of a 3-D vector + */ +static inline float vmathV3GetY( const VmathVector3 *vec ); + +/* + * Get the z element of a 3-D vector + */ +static inline float vmathV3GetZ( const VmathVector3 *vec ); + +/* + * Set an x, y, or z element of a 3-D vector by index + */ +static inline void vmathV3SetElem( VmathVector3 *result, int idx, float value ); + +/* + * Get an x, y, or z element of a 3-D vector by index + */ +static inline float vmathV3GetElem( const VmathVector3 *vec, int idx ); + +/* + * Add two 3-D vectors + */ +static inline void vmathV3Add( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); + +/* + * Subtract a 3-D vector from another 3-D vector + */ +static inline void vmathV3Sub( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); + +/* + * Add a 3-D vector to a 3-D point + */ +static inline void vmathV3AddP3( VmathPoint3 *result, const VmathVector3 *vec, const VmathPoint3 *pnt ); + +/* + * Multiply a 3-D vector by a scalar + */ +static inline void vmathV3ScalarMul( VmathVector3 *result, const VmathVector3 *vec, float scalar ); + +/* + * Divide a 3-D vector by a scalar + */ +static inline void vmathV3ScalarDiv( VmathVector3 *result, const VmathVector3 *vec, float scalar ); + +/* + * Negate all elements of a 3-D vector + */ +static inline void vmathV3Neg( VmathVector3 *result, const VmathVector3 *vec ); + +/* + * Construct x axis + */ +static inline void vmathV3MakeXAxis( VmathVector3 *result ); + +/* + * Construct y axis + */ +static inline void vmathV3MakeYAxis( VmathVector3 *result ); + +/* + * Construct z axis + */ +static inline void vmathV3MakeZAxis( VmathVector3 *result ); + +/* + * Multiply two 3-D vectors per element + */ +static inline void vmathV3MulPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); + +/* + * Divide two 3-D vectors per element + * NOTE: + * Floating-point behavior matches standard library function divf4. + */ +static inline void vmathV3DivPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); + +/* + * Compute the reciprocal of a 3-D vector per element + * NOTE: + * Floating-point behavior matches standard library function recipf4. + */ +static inline void vmathV3RecipPerElem( VmathVector3 *result, const VmathVector3 *vec ); + +/* + * Compute the square root of a 3-D vector per element + * NOTE: + * Floating-point behavior matches standard library function sqrtf4. + */ +static inline void vmathV3SqrtPerElem( VmathVector3 *result, const VmathVector3 *vec ); + +/* + * Compute the reciprocal square root of a 3-D vector per element + * NOTE: + * Floating-point behavior matches standard library function rsqrtf4. + */ +static inline void vmathV3RsqrtPerElem( VmathVector3 *result, const VmathVector3 *vec ); + +/* + * Compute the absolute value of a 3-D vector per element + */ +static inline void vmathV3AbsPerElem( VmathVector3 *result, const VmathVector3 *vec ); + +/* + * Copy sign from one 3-D vector to another, per element + */ +static inline void vmathV3CopySignPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); + +/* + * Maximum of two 3-D vectors per element + */ +static inline void vmathV3MaxPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); + +/* + * Minimum of two 3-D vectors per element + */ +static inline void vmathV3MinPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); + +/* + * Maximum element of a 3-D vector + */ +static inline float vmathV3MaxElem( const VmathVector3 *vec ); + +/* + * Minimum element of a 3-D vector + */ +static inline float vmathV3MinElem( const VmathVector3 *vec ); + +/* + * Compute the sum of all elements of a 3-D vector + */ +static inline float vmathV3Sum( const VmathVector3 *vec ); + +/* + * Compute the dot product of two 3-D vectors + */ +static inline float vmathV3Dot( const VmathVector3 *vec0, const VmathVector3 *vec1 ); + +/* + * Compute the square of the length of a 3-D vector + */ +static inline float vmathV3LengthSqr( const VmathVector3 *vec ); + +/* + * Compute the length of a 3-D vector + */ +static inline float vmathV3Length( const VmathVector3 *vec ); + +/* + * Normalize a 3-D vector + * NOTE: + * The result is unpredictable when all elements of vec are at or near zero. + */ +static inline void vmathV3Normalize( VmathVector3 *result, const VmathVector3 *vec ); + +/* + * Compute cross product of two 3-D vectors + */ +static inline void vmathV3Cross( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); + +/* + * Outer product of two 3-D vectors + */ +static inline void vmathV3Outer( VmathMatrix3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); + +/* + * Pre-multiply a row vector by a 3x3 matrix + * NOTE: + * Slower than column post-multiply. + */ +static inline void vmathV3RowMul( VmathVector3 *result, const VmathVector3 *vec, const VmathMatrix3 *mat ); + +/* + * Cross-product matrix of a 3-D vector + */ +static inline void vmathV3CrossMatrix( VmathMatrix3 *result, const VmathVector3 *vec ); + +/* + * Create cross-product matrix and multiply + * NOTE: + * Faster than separately creating a cross-product matrix and multiplying. + */ +static inline void vmathV3CrossMatrixMul( VmathMatrix3 *result, const VmathVector3 *vec, const VmathMatrix3 *mat ); + +/* + * Linear interpolation between two 3-D vectors + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline void vmathV3Lerp( VmathVector3 *result, float t, const VmathVector3 *vec0, const VmathVector3 *vec1 ); + +/* + * Spherical linear interpolation between two 3-D vectors + * NOTE: + * The result is unpredictable if the vectors point in opposite directions. + * Does not clamp t between 0 and 1. + */ +static inline void vmathV3Slerp( VmathVector3 *result, float t, const VmathVector3 *unitVec0, const VmathVector3 *unitVec1 ); + +/* + * Conditionally select between two 3-D vectors + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + * However, the transfer of select1 to a VMX register may use more processing time than a branch. + */ +static inline void vmathV3Select( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1, unsigned int select1 ); + +/* + * Store x, y, and z elements of a 3-D vector in the first three words of a quadword. + * The value of the fourth word (the word with the highest address) remains unchanged + */ +static inline void vmathV3StoreXYZ( const VmathVector3 *vec, vec_float4 *quad ); + +/* + * Load four three-float 3-D vectors, stored in three quadwords + */ +static inline void vmathV3LoadXYZArray( VmathVector3 *vec0, VmathVector3 *vec1, VmathVector3 *vec2, VmathVector3 *vec3, const vec_float4 *threeQuads ); + +/* + * Store four 3-D vectors in three quadwords + */ +static inline void vmathV3StoreXYZArray( const VmathVector3 *vec0, const VmathVector3 *vec1, const VmathVector3 *vec2, const VmathVector3 *vec3, vec_float4 *threeQuads ); + +/* + * Store eight 3-D vectors as half-floats + */ +static inline void vmathV3StoreHalfFloats( const VmathVector3 *vec0, const VmathVector3 *vec1, const VmathVector3 *vec2, const VmathVector3 *vec3, const VmathVector3 *vec4, const VmathVector3 *vec5, const VmathVector3 *vec6, const VmathVector3 *vec7, vec_ushort8 *threeQuads ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3-D vector + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathV3Print( const VmathVector3 *vec ); + +/* + * Print a 3-D vector and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathV3Prints( const VmathVector3 *vec, const char *name ); + +#endif + +/* + * Copy a 4-D vector + */ +static inline void vmathV4Copy( VmathVector4 *result, const VmathVector4 *vec ); + +/* + * Construct a 4-D vector from x, y, z, and w elements + */ +static inline void vmathV4MakeFromElems( VmathVector4 *result, float x, float y, float z, float w ); + +/* + * Construct a 4-D vector from a 3-D vector and a scalar + */ +static inline void vmathV4MakeFromV3Scalar( VmathVector4 *result, const VmathVector3 *xyz, float w ); + +/* + * Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0 + */ +static inline void vmathV4MakeFromV3( VmathVector4 *result, const VmathVector3 *vec ); + +/* + * Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1 + */ +static inline void vmathV4MakeFromP3( VmathVector4 *result, const VmathPoint3 *pnt ); + +/* + * Copy elements from a quaternion into a 4-D vector + */ +static inline void vmathV4MakeFromQ( VmathVector4 *result, const VmathQuat *quat ); + +/* + * Set all elements of a 4-D vector to the same scalar value + */ +static inline void vmathV4MakeFromScalar( VmathVector4 *result, float scalar ); + +/* + * Set vector float data in a 4-D vector + */ +static inline void vmathV4MakeFrom128( VmathVector4 *result, vec_float4 vf4 ); + +/* + * Get vector float data from a 4-D vector + */ +static inline vec_float4 vmathV4Get128( const VmathVector4 *vec ); + +/* + * Set the x, y, and z elements of a 4-D vector + * NOTE: + * This function does not change the w element. + */ +static inline void vmathV4SetXYZ( VmathVector4 *result, const VmathVector3 *vec ); + +/* + * Get the x, y, and z elements of a 4-D vector + */ +static inline void vmathV4GetXYZ( VmathVector3 *result, const VmathVector4 *vec ); + +/* + * Set the x element of a 4-D vector + */ +static inline void vmathV4SetX( VmathVector4 *result, float x ); + +/* + * Set the y element of a 4-D vector + */ +static inline void vmathV4SetY( VmathVector4 *result, float y ); + +/* + * Set the z element of a 4-D vector + */ +static inline void vmathV4SetZ( VmathVector4 *result, float z ); + +/* + * Set the w element of a 4-D vector + */ +static inline void vmathV4SetW( VmathVector4 *result, float w ); + +/* + * Get the x element of a 4-D vector + */ +static inline float vmathV4GetX( const VmathVector4 *vec ); + +/* + * Get the y element of a 4-D vector + */ +static inline float vmathV4GetY( const VmathVector4 *vec ); + +/* + * Get the z element of a 4-D vector + */ +static inline float vmathV4GetZ( const VmathVector4 *vec ); + +/* + * Get the w element of a 4-D vector + */ +static inline float vmathV4GetW( const VmathVector4 *vec ); + +/* + * Set an x, y, z, or w element of a 4-D vector by index + */ +static inline void vmathV4SetElem( VmathVector4 *result, int idx, float value ); + +/* + * Get an x, y, z, or w element of a 4-D vector by index + */ +static inline float vmathV4GetElem( const VmathVector4 *vec, int idx ); + +/* + * Add two 4-D vectors + */ +static inline void vmathV4Add( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); + +/* + * Subtract a 4-D vector from another 4-D vector + */ +static inline void vmathV4Sub( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); + +/* + * Multiply a 4-D vector by a scalar + */ +static inline void vmathV4ScalarMul( VmathVector4 *result, const VmathVector4 *vec, float scalar ); + +/* + * Divide a 4-D vector by a scalar + */ +static inline void vmathV4ScalarDiv( VmathVector4 *result, const VmathVector4 *vec, float scalar ); + +/* + * Negate all elements of a 4-D vector + */ +static inline void vmathV4Neg( VmathVector4 *result, const VmathVector4 *vec ); + +/* + * Construct x axis + */ +static inline void vmathV4MakeXAxis( VmathVector4 *result ); + +/* + * Construct y axis + */ +static inline void vmathV4MakeYAxis( VmathVector4 *result ); + +/* + * Construct z axis + */ +static inline void vmathV4MakeZAxis( VmathVector4 *result ); + +/* + * Construct w axis + */ +static inline void vmathV4MakeWAxis( VmathVector4 *result ); + +/* + * Multiply two 4-D vectors per element + */ +static inline void vmathV4MulPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); + +/* + * Divide two 4-D vectors per element + * NOTE: + * Floating-point behavior matches standard library function divf4. + */ +static inline void vmathV4DivPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); + +/* + * Compute the reciprocal of a 4-D vector per element + * NOTE: + * Floating-point behavior matches standard library function recipf4. + */ +static inline void vmathV4RecipPerElem( VmathVector4 *result, const VmathVector4 *vec ); + +/* + * Compute the square root of a 4-D vector per element + * NOTE: + * Floating-point behavior matches standard library function sqrtf4. + */ +static inline void vmathV4SqrtPerElem( VmathVector4 *result, const VmathVector4 *vec ); + +/* + * Compute the reciprocal square root of a 4-D vector per element + * NOTE: + * Floating-point behavior matches standard library function rsqrtf4. + */ +static inline void vmathV4RsqrtPerElem( VmathVector4 *result, const VmathVector4 *vec ); + +/* + * Compute the absolute value of a 4-D vector per element + */ +static inline void vmathV4AbsPerElem( VmathVector4 *result, const VmathVector4 *vec ); + +/* + * Copy sign from one 4-D vector to another, per element + */ +static inline void vmathV4CopySignPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); + +/* + * Maximum of two 4-D vectors per element + */ +static inline void vmathV4MaxPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); + +/* + * Minimum of two 4-D vectors per element + */ +static inline void vmathV4MinPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); + +/* + * Maximum element of a 4-D vector + */ +static inline float vmathV4MaxElem( const VmathVector4 *vec ); + +/* + * Minimum element of a 4-D vector + */ +static inline float vmathV4MinElem( const VmathVector4 *vec ); + +/* + * Compute the sum of all elements of a 4-D vector + */ +static inline float vmathV4Sum( const VmathVector4 *vec ); + +/* + * Compute the dot product of two 4-D vectors + */ +static inline float vmathV4Dot( const VmathVector4 *vec0, const VmathVector4 *vec1 ); + +/* + * Compute the square of the length of a 4-D vector + */ +static inline float vmathV4LengthSqr( const VmathVector4 *vec ); + +/* + * Compute the length of a 4-D vector + */ +static inline float vmathV4Length( const VmathVector4 *vec ); + +/* + * Normalize a 4-D vector + * NOTE: + * The result is unpredictable when all elements of vec are at or near zero. + */ +static inline void vmathV4Normalize( VmathVector4 *result, const VmathVector4 *vec ); + +/* + * Outer product of two 4-D vectors + */ +static inline void vmathV4Outer( VmathMatrix4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); + +/* + * Linear interpolation between two 4-D vectors + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline void vmathV4Lerp( VmathVector4 *result, float t, const VmathVector4 *vec0, const VmathVector4 *vec1 ); + +/* + * Spherical linear interpolation between two 4-D vectors + * NOTE: + * The result is unpredictable if the vectors point in opposite directions. + * Does not clamp t between 0 and 1. + */ +static inline void vmathV4Slerp( VmathVector4 *result, float t, const VmathVector4 *unitVec0, const VmathVector4 *unitVec1 ); + +/* + * Conditionally select between two 4-D vectors + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + * However, the transfer of select1 to a VMX register may use more processing time than a branch. + */ +static inline void vmathV4Select( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1, unsigned int select1 ); + +/* + * Store four 4-D vectors as half-floats + */ +static inline void vmathV4StoreHalfFloats( const VmathVector4 *vec0, const VmathVector4 *vec1, const VmathVector4 *vec2, const VmathVector4 *vec3, vec_ushort8 *twoQuads ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 4-D vector + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathV4Print( const VmathVector4 *vec ); + +/* + * Print a 4-D vector and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathV4Prints( const VmathVector4 *vec, const char *name ); + +#endif + +/* + * Copy a 3-D point + */ +static inline void vmathP3Copy( VmathPoint3 *result, const VmathPoint3 *pnt ); + +/* + * Construct a 3-D point from x, y, and z elements + */ +static inline void vmathP3MakeFromElems( VmathPoint3 *result, float x, float y, float z ); + +/* + * Copy elements from a 3-D vector into a 3-D point + */ +static inline void vmathP3MakeFromV3( VmathPoint3 *result, const VmathVector3 *vec ); + +/* + * Set all elements of a 3-D point to the same scalar value + */ +static inline void vmathP3MakeFromScalar( VmathPoint3 *result, float scalar ); + +/* + * Set vector float data in a 3-D point + */ +static inline void vmathP3MakeFrom128( VmathPoint3 *result, vec_float4 vf4 ); + +/* + * Get vector float data from a 3-D point + */ +static inline vec_float4 vmathP3Get128( const VmathPoint3 *pnt ); + +/* + * Set the x element of a 3-D point + */ +static inline void vmathP3SetX( VmathPoint3 *result, float x ); + +/* + * Set the y element of a 3-D point + */ +static inline void vmathP3SetY( VmathPoint3 *result, float y ); + +/* + * Set the z element of a 3-D point + */ +static inline void vmathP3SetZ( VmathPoint3 *result, float z ); + +/* + * Get the x element of a 3-D point + */ +static inline float vmathP3GetX( const VmathPoint3 *pnt ); + +/* + * Get the y element of a 3-D point + */ +static inline float vmathP3GetY( const VmathPoint3 *pnt ); + +/* + * Get the z element of a 3-D point + */ +static inline float vmathP3GetZ( const VmathPoint3 *pnt ); + +/* + * Set an x, y, or z element of a 3-D point by index + */ +static inline void vmathP3SetElem( VmathPoint3 *result, int idx, float value ); + +/* + * Get an x, y, or z element of a 3-D point by index + */ +static inline float vmathP3GetElem( const VmathPoint3 *pnt, int idx ); + +/* + * Subtract a 3-D point from another 3-D point + */ +static inline void vmathP3Sub( VmathVector3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); + +/* + * Add a 3-D point to a 3-D vector + */ +static inline void vmathP3AddV3( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *vec ); + +/* + * Subtract a 3-D vector from a 3-D point + */ +static inline void vmathP3SubV3( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *vec ); + +/* + * Multiply two 3-D points per element + */ +static inline void vmathP3MulPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); + +/* + * Divide two 3-D points per element + * NOTE: + * Floating-point behavior matches standard library function divf4. + */ +static inline void vmathP3DivPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); + +/* + * Compute the reciprocal of a 3-D point per element + * NOTE: + * Floating-point behavior matches standard library function recipf4. + */ +static inline void vmathP3RecipPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ); + +/* + * Compute the square root of a 3-D point per element + * NOTE: + * Floating-point behavior matches standard library function sqrtf4. + */ +static inline void vmathP3SqrtPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ); + +/* + * Compute the reciprocal square root of a 3-D point per element + * NOTE: + * Floating-point behavior matches standard library function rsqrtf4. + */ +static inline void vmathP3RsqrtPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ); + +/* + * Compute the absolute value of a 3-D point per element + */ +static inline void vmathP3AbsPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ); + +/* + * Copy sign from one 3-D point to another, per element + */ +static inline void vmathP3CopySignPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); + +/* + * Maximum of two 3-D points per element + */ +static inline void vmathP3MaxPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); + +/* + * Minimum of two 3-D points per element + */ +static inline void vmathP3MinPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); + +/* + * Maximum element of a 3-D point + */ +static inline float vmathP3MaxElem( const VmathPoint3 *pnt ); + +/* + * Minimum element of a 3-D point + */ +static inline float vmathP3MinElem( const VmathPoint3 *pnt ); + +/* + * Compute the sum of all elements of a 3-D point + */ +static inline float vmathP3Sum( const VmathPoint3 *pnt ); + +/* + * Apply uniform scale to a 3-D point + */ +static inline void vmathP3Scale( VmathPoint3 *result, const VmathPoint3 *pnt, float scaleVal ); + +/* + * Apply non-uniform scale to a 3-D point + */ +static inline void vmathP3NonUniformScale( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *scaleVec ); + +/* + * Scalar projection of a 3-D point on a unit-length 3-D vector + */ +static inline float vmathP3Projection( const VmathPoint3 *pnt, const VmathVector3 *unitVec ); + +/* + * Compute the square of the distance of a 3-D point from the coordinate-system origin + */ +static inline float vmathP3DistSqrFromOrigin( const VmathPoint3 *pnt ); + +/* + * Compute the distance of a 3-D point from the coordinate-system origin + */ +static inline float vmathP3DistFromOrigin( const VmathPoint3 *pnt ); + +/* + * Compute the square of the distance between two 3-D points + */ +static inline float vmathP3DistSqr( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); + +/* + * Compute the distance between two 3-D points + */ +static inline float vmathP3Dist( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); + +/* + * Linear interpolation between two 3-D points + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline void vmathP3Lerp( VmathPoint3 *result, float t, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); + +/* + * Conditionally select between two 3-D points + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + * However, the transfer of select1 to a VMX register may use more processing time than a branch. + */ +static inline void vmathP3Select( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, unsigned int select1 ); + +/* + * Store x, y, and z elements of a 3-D point in the first three words of a quadword. + * The value of the fourth word (the word with the highest address) remains unchanged + */ +static inline void vmathP3StoreXYZ( const VmathPoint3 *pnt, vec_float4 *quad ); + +/* + * Load four three-float 3-D points, stored in three quadwords + */ +static inline void vmathP3LoadXYZArray( VmathPoint3 *pnt0, VmathPoint3 *pnt1, VmathPoint3 *pnt2, VmathPoint3 *pnt3, const vec_float4 *threeQuads ); + +/* + * Store four 3-D points in three quadwords + */ +static inline void vmathP3StoreXYZArray( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, const VmathPoint3 *pnt2, const VmathPoint3 *pnt3, vec_float4 *threeQuads ); + +/* + * Store eight 3-D points as half-floats + */ +static inline void vmathP3StoreHalfFloats( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, const VmathPoint3 *pnt2, const VmathPoint3 *pnt3, const VmathPoint3 *pnt4, const VmathPoint3 *pnt5, const VmathPoint3 *pnt6, const VmathPoint3 *pnt7, vec_ushort8 *threeQuads ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3-D point + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathP3Print( const VmathPoint3 *pnt ); + +/* + * Print a 3-D point and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathP3Prints( const VmathPoint3 *pnt, const char *name ); + +#endif + +/* + * Copy a quaternion + */ +static inline void vmathQCopy( VmathQuat *result, const VmathQuat *quat ); + +/* + * Construct a quaternion from x, y, z, and w elements + */ +static inline void vmathQMakeFromElems( VmathQuat *result, float x, float y, float z, float w ); + +/* + * Construct a quaternion from a 3-D vector and a scalar + */ +static inline void vmathQMakeFromV3Scalar( VmathQuat *result, const VmathVector3 *xyz, float w ); + +/* + * Copy elements from a 4-D vector into a quaternion + */ +static inline void vmathQMakeFromV4( VmathQuat *result, const VmathVector4 *vec ); + +/* + * Convert a rotation matrix to a unit-length quaternion + */ +static inline void vmathQMakeFromM3( VmathQuat *result, const VmathMatrix3 *rotMat ); + +/* + * Set all elements of a quaternion to the same scalar value + */ +static inline void vmathQMakeFromScalar( VmathQuat *result, float scalar ); + +/* + * Set vector float data in a quaternion + */ +static inline void vmathQMakeFrom128( VmathQuat *result, vec_float4 vf4 ); + +/* + * Get vector float data from a quaternion + */ +static inline vec_float4 vmathQGet128( const VmathQuat *quat ); + +/* + * Set the x, y, and z elements of a quaternion + * NOTE: + * This function does not change the w element. + */ +static inline void vmathQSetXYZ( VmathQuat *result, const VmathVector3 *vec ); + +/* + * Get the x, y, and z elements of a quaternion + */ +static inline void vmathQGetXYZ( VmathVector3 *result, const VmathQuat *quat ); + +/* + * Set the x element of a quaternion + */ +static inline void vmathQSetX( VmathQuat *result, float x ); + +/* + * Set the y element of a quaternion + */ +static inline void vmathQSetY( VmathQuat *result, float y ); + +/* + * Set the z element of a quaternion + */ +static inline void vmathQSetZ( VmathQuat *result, float z ); + +/* + * Set the w element of a quaternion + */ +static inline void vmathQSetW( VmathQuat *result, float w ); + +/* + * Get the x element of a quaternion + */ +static inline float vmathQGetX( const VmathQuat *quat ); + +/* + * Get the y element of a quaternion + */ +static inline float vmathQGetY( const VmathQuat *quat ); + +/* + * Get the z element of a quaternion + */ +static inline float vmathQGetZ( const VmathQuat *quat ); + +/* + * Get the w element of a quaternion + */ +static inline float vmathQGetW( const VmathQuat *quat ); + +/* + * Set an x, y, z, or w element of a quaternion by index + */ +static inline void vmathQSetElem( VmathQuat *result, int idx, float value ); + +/* + * Get an x, y, z, or w element of a quaternion by index + */ +static inline float vmathQGetElem( const VmathQuat *quat, int idx ); + +/* + * Add two quaternions + */ +static inline void vmathQAdd( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ); + +/* + * Subtract a quaternion from another quaternion + */ +static inline void vmathQSub( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ); + +/* + * Multiply two quaternions + */ +static inline void vmathQMul( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ); + +/* + * Multiply a quaternion by a scalar + */ +static inline void vmathQScalarMul( VmathQuat *result, const VmathQuat *quat, float scalar ); + +/* + * Divide a quaternion by a scalar + */ +static inline void vmathQScalarDiv( VmathQuat *result, const VmathQuat *quat, float scalar ); + +/* + * Negate all elements of a quaternion + */ +static inline void vmathQNeg( VmathQuat *result, const VmathQuat *quat ); + +/* + * Construct an identity quaternion + */ +static inline void vmathQMakeIdentity( VmathQuat *result ); + +/* + * Construct a quaternion to rotate between two unit-length 3-D vectors + * NOTE: + * The result is unpredictable if unitVec0 and unitVec1 point in opposite directions. + */ +static inline void vmathQMakeRotationArc( VmathQuat *result, const VmathVector3 *unitVec0, const VmathVector3 *unitVec1 ); + +/* + * Construct a quaternion to rotate around a unit-length 3-D vector + */ +static inline void vmathQMakeRotationAxis( VmathQuat *result, float radians, const VmathVector3 *unitVec ); + +/* + * Construct a quaternion to rotate around the x axis + */ +static inline void vmathQMakeRotationX( VmathQuat *result, float radians ); + +/* + * Construct a quaternion to rotate around the y axis + */ +static inline void vmathQMakeRotationY( VmathQuat *result, float radians ); + +/* + * Construct a quaternion to rotate around the z axis + */ +static inline void vmathQMakeRotationZ( VmathQuat *result, float radians ); + +/* + * Compute the conjugate of a quaternion + */ +static inline void vmathQConj( VmathQuat *result, const VmathQuat *quat ); + +/* + * Use a unit-length quaternion to rotate a 3-D vector + */ +static inline void vmathQRotate( VmathVector3 *result, const VmathQuat *unitQuat, const VmathVector3 *vec ); + +/* + * Compute the dot product of two quaternions + */ +static inline float vmathQDot( const VmathQuat *quat0, const VmathQuat *quat1 ); + +/* + * Compute the norm of a quaternion + */ +static inline float vmathQNorm( const VmathQuat *quat ); + +/* + * Compute the length of a quaternion + */ +static inline float vmathQLength( const VmathQuat *quat ); + +/* + * Normalize a quaternion + * NOTE: + * The result is unpredictable when all elements of quat are at or near zero. + */ +static inline void vmathQNormalize( VmathQuat *result, const VmathQuat *quat ); + +/* + * Linear interpolation between two quaternions + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline void vmathQLerp( VmathQuat *result, float t, const VmathQuat *quat0, const VmathQuat *quat1 ); + +/* + * Spherical linear interpolation between two quaternions + * NOTE: + * Interpolates along the shortest path between orientations. + * Does not clamp t between 0 and 1. + */ +static inline void vmathQSlerp( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1 ); + +/* + * Spherical quadrangle interpolation + */ +static inline void vmathQSquad( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1, const VmathQuat *unitQuat2, const VmathQuat *unitQuat3 ); + +/* + * Conditionally select between two quaternions + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + * However, the transfer of select1 to a VMX register may use more processing time than a branch. + */ +static inline void vmathQSelect( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1, unsigned int select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a quaternion + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathQPrint( const VmathQuat *quat ); + +/* + * Print a quaternion and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathQPrints( const VmathQuat *quat, const char *name ); + +#endif + +/* + * Copy a 3x3 matrix + */ +static inline void vmathM3Copy( VmathMatrix3 *result, const VmathMatrix3 *mat ); + +/* + * Construct a 3x3 matrix containing the specified columns + */ +static inline void vmathM3MakeFromCols( VmathMatrix3 *result, const VmathVector3 *col0, const VmathVector3 *col1, const VmathVector3 *col2 ); + +/* + * Construct a 3x3 rotation matrix from a unit-length quaternion + */ +static inline void vmathM3MakeFromQ( VmathMatrix3 *result, const VmathQuat *unitQuat ); + +/* + * Set all elements of a 3x3 matrix to the same scalar value + */ +static inline void vmathM3MakeFromScalar( VmathMatrix3 *result, float scalar ); + +/* + * Set column 0 of a 3x3 matrix + */ +static inline void vmathM3SetCol0( VmathMatrix3 *result, const VmathVector3 *col0 ); + +/* + * Set column 1 of a 3x3 matrix + */ +static inline void vmathM3SetCol1( VmathMatrix3 *result, const VmathVector3 *col1 ); + +/* + * Set column 2 of a 3x3 matrix + */ +static inline void vmathM3SetCol2( VmathMatrix3 *result, const VmathVector3 *col2 ); + +/* + * Get column 0 of a 3x3 matrix + */ +static inline void vmathM3GetCol0( VmathVector3 *result, const VmathMatrix3 *mat ); + +/* + * Get column 1 of a 3x3 matrix + */ +static inline void vmathM3GetCol1( VmathVector3 *result, const VmathMatrix3 *mat ); + +/* + * Get column 2 of a 3x3 matrix + */ +static inline void vmathM3GetCol2( VmathVector3 *result, const VmathMatrix3 *mat ); + +/* + * Set the column of a 3x3 matrix referred to by the specified index + */ +static inline void vmathM3SetCol( VmathMatrix3 *result, int col, const VmathVector3 *vec ); + +/* + * Set the row of a 3x3 matrix referred to by the specified index + */ +static inline void vmathM3SetRow( VmathMatrix3 *result, int row, const VmathVector3 *vec ); + +/* + * Get the column of a 3x3 matrix referred to by the specified index + */ +static inline void vmathM3GetCol( VmathVector3 *result, const VmathMatrix3 *mat, int col ); + +/* + * Get the row of a 3x3 matrix referred to by the specified index + */ +static inline void vmathM3GetRow( VmathVector3 *result, const VmathMatrix3 *mat, int row ); + +/* + * Set the element of a 3x3 matrix referred to by column and row indices + */ +static inline void vmathM3SetElem( VmathMatrix3 *result, int col, int row, float val ); + +/* + * Get the element of a 3x3 matrix referred to by column and row indices + */ +static inline float vmathM3GetElem( const VmathMatrix3 *mat, int col, int row ); + +/* + * Add two 3x3 matrices + */ +static inline void vmathM3Add( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ); + +/* + * Subtract a 3x3 matrix from another 3x3 matrix + */ +static inline void vmathM3Sub( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ); + +/* + * Negate all elements of a 3x3 matrix + */ +static inline void vmathM3Neg( VmathMatrix3 *result, const VmathMatrix3 *mat ); + +/* + * Multiply a 3x3 matrix by a scalar + */ +static inline void vmathM3ScalarMul( VmathMatrix3 *result, const VmathMatrix3 *mat, float scalar ); + +/* + * Multiply a 3x3 matrix by a 3-D vector + */ +static inline void vmathM3MulV3( VmathVector3 *result, const VmathMatrix3 *mat, const VmathVector3 *vec ); + +/* + * Multiply two 3x3 matrices + */ +static inline void vmathM3Mul( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ); + +/* + * Construct an identity 3x3 matrix + */ +static inline void vmathM3MakeIdentity( VmathMatrix3 *result ); + +/* + * Construct a 3x3 matrix to rotate around the x axis + */ +static inline void vmathM3MakeRotationX( VmathMatrix3 *result, float radians ); + +/* + * Construct a 3x3 matrix to rotate around the y axis + */ +static inline void vmathM3MakeRotationY( VmathMatrix3 *result, float radians ); + +/* + * Construct a 3x3 matrix to rotate around the z axis + */ +static inline void vmathM3MakeRotationZ( VmathMatrix3 *result, float radians ); + +/* + * Construct a 3x3 matrix to rotate around the x, y, and z axes + */ +static inline void vmathM3MakeRotationZYX( VmathMatrix3 *result, const VmathVector3 *radiansXYZ ); + +/* + * Construct a 3x3 matrix to rotate around a unit-length 3-D vector + */ +static inline void vmathM3MakeRotationAxis( VmathMatrix3 *result, float radians, const VmathVector3 *unitVec ); + +/* + * Construct a rotation matrix from a unit-length quaternion + */ +static inline void vmathM3MakeRotationQ( VmathMatrix3 *result, const VmathQuat *unitQuat ); + +/* + * Construct a 3x3 matrix to perform scaling + */ +static inline void vmathM3MakeScale( VmathMatrix3 *result, const VmathVector3 *scaleVec ); + +/* + * Append (post-multiply) a scale transformation to a 3x3 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline void vmathM3AppendScale( VmathMatrix3 *result, const VmathMatrix3 *mat, const VmathVector3 *scaleVec ); + +/* + * Prepend (pre-multiply) a scale transformation to a 3x3 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline void vmathM3PrependScale( VmathMatrix3 *result, const VmathVector3 *scaleVec, const VmathMatrix3 *mat ); + +/* + * Multiply two 3x3 matrices per element + */ +static inline void vmathM3MulPerElem( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ); + +/* + * Compute the absolute value of a 3x3 matrix per element + */ +static inline void vmathM3AbsPerElem( VmathMatrix3 *result, const VmathMatrix3 *mat ); + +/* + * Transpose of a 3x3 matrix + */ +static inline void vmathM3Transpose( VmathMatrix3 *result, const VmathMatrix3 *mat ); + +/* + * Compute the inverse of a 3x3 matrix + * NOTE: + * Result is unpredictable when the determinant of mat is equal to or near 0. + */ +static inline void vmathM3Inverse( VmathMatrix3 *result, const VmathMatrix3 *mat ); + +/* + * Determinant of a 3x3 matrix + */ +static inline float vmathM3Determinant( const VmathMatrix3 *mat ); + +/* + * Conditionally select between two 3x3 matrices + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + * However, the transfer of select1 to a VMX register may use more processing time than a branch. + */ +static inline void vmathM3Select( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1, unsigned int select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3x3 matrix + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathM3Print( const VmathMatrix3 *mat ); + +/* + * Print a 3x3 matrix and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathM3Prints( const VmathMatrix3 *mat, const char *name ); + +#endif + +/* + * Copy a 4x4 matrix + */ +static inline void vmathM4Copy( VmathMatrix4 *result, const VmathMatrix4 *mat ); + +/* + * Construct a 4x4 matrix containing the specified columns + */ +static inline void vmathM4MakeFromCols( VmathMatrix4 *result, const VmathVector4 *col0, const VmathVector4 *col1, const VmathVector4 *col2, const VmathVector4 *col3 ); + +/* + * Construct a 4x4 matrix from a 3x4 transformation matrix + */ +static inline void vmathM4MakeFromT3( VmathMatrix4 *result, const VmathTransform3 *mat ); + +/* + * Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector + */ +static inline void vmathM4MakeFromM3V3( VmathMatrix4 *result, const VmathMatrix3 *mat, const VmathVector3 *translateVec ); + +/* + * Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector + */ +static inline void vmathM4MakeFromQV3( VmathMatrix4 *result, const VmathQuat *unitQuat, const VmathVector3 *translateVec ); + +/* + * Set all elements of a 4x4 matrix to the same scalar value + */ +static inline void vmathM4MakeFromScalar( VmathMatrix4 *result, float scalar ); + +/* + * Set the upper-left 3x3 submatrix + * NOTE: + * This function does not change the bottom row elements. + */ +static inline void vmathM4SetUpper3x3( VmathMatrix4 *result, const VmathMatrix3 *mat3 ); + +/* + * Get the upper-left 3x3 submatrix of a 4x4 matrix + */ +static inline void vmathM4GetUpper3x3( VmathMatrix3 *result, const VmathMatrix4 *mat ); + +/* + * Set translation component + * NOTE: + * This function does not change the bottom row elements. + */ +static inline void vmathM4SetTranslation( VmathMatrix4 *result, const VmathVector3 *translateVec ); + +/* + * Get the translation component of a 4x4 matrix + */ +static inline void vmathM4GetTranslation( VmathVector3 *result, const VmathMatrix4 *mat ); + +/* + * Set column 0 of a 4x4 matrix + */ +static inline void vmathM4SetCol0( VmathMatrix4 *result, const VmathVector4 *col0 ); + +/* + * Set column 1 of a 4x4 matrix + */ +static inline void vmathM4SetCol1( VmathMatrix4 *result, const VmathVector4 *col1 ); + +/* + * Set column 2 of a 4x4 matrix + */ +static inline void vmathM4SetCol2( VmathMatrix4 *result, const VmathVector4 *col2 ); + +/* + * Set column 3 of a 4x4 matrix + */ +static inline void vmathM4SetCol3( VmathMatrix4 *result, const VmathVector4 *col3 ); + +/* + * Get column 0 of a 4x4 matrix + */ +static inline void vmathM4GetCol0( VmathVector4 *result, const VmathMatrix4 *mat ); + +/* + * Get column 1 of a 4x4 matrix + */ +static inline void vmathM4GetCol1( VmathVector4 *result, const VmathMatrix4 *mat ); + +/* + * Get column 2 of a 4x4 matrix + */ +static inline void vmathM4GetCol2( VmathVector4 *result, const VmathMatrix4 *mat ); + +/* + * Get column 3 of a 4x4 matrix + */ +static inline void vmathM4GetCol3( VmathVector4 *result, const VmathMatrix4 *mat ); + +/* + * Set the column of a 4x4 matrix referred to by the specified index + */ +static inline void vmathM4SetCol( VmathMatrix4 *result, int col, const VmathVector4 *vec ); + +/* + * Set the row of a 4x4 matrix referred to by the specified index + */ +static inline void vmathM4SetRow( VmathMatrix4 *result, int row, const VmathVector4 *vec ); + +/* + * Get the column of a 4x4 matrix referred to by the specified index + */ +static inline void vmathM4GetCol( VmathVector4 *result, const VmathMatrix4 *mat, int col ); + +/* + * Get the row of a 4x4 matrix referred to by the specified index + */ +static inline void vmathM4GetRow( VmathVector4 *result, const VmathMatrix4 *mat, int row ); + +/* + * Set the element of a 4x4 matrix referred to by column and row indices + */ +static inline void vmathM4SetElem( VmathMatrix4 *result, int col, int row, float val ); + +/* + * Get the element of a 4x4 matrix referred to by column and row indices + */ +static inline float vmathM4GetElem( const VmathMatrix4 *mat, int col, int row ); + +/* + * Add two 4x4 matrices + */ +static inline void vmathM4Add( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ); + +/* + * Subtract a 4x4 matrix from another 4x4 matrix + */ +static inline void vmathM4Sub( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ); + +/* + * Negate all elements of a 4x4 matrix + */ +static inline void vmathM4Neg( VmathMatrix4 *result, const VmathMatrix4 *mat ); + +/* + * Multiply a 4x4 matrix by a scalar + */ +static inline void vmathM4ScalarMul( VmathMatrix4 *result, const VmathMatrix4 *mat, float scalar ); + +/* + * Multiply a 4x4 matrix by a 4-D vector + */ +static inline void vmathM4MulV4( VmathVector4 *result, const VmathMatrix4 *mat, const VmathVector4 *vec ); + +/* + * Multiply a 4x4 matrix by a 3-D vector + */ +static inline void vmathM4MulV3( VmathVector4 *result, const VmathMatrix4 *mat, const VmathVector3 *vec ); + +/* + * Multiply a 4x4 matrix by a 3-D point + */ +static inline void vmathM4MulP3( VmathVector4 *result, const VmathMatrix4 *mat, const VmathPoint3 *pnt ); + +/* + * Multiply two 4x4 matrices + */ +static inline void vmathM4Mul( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ); + +/* + * Multiply a 4x4 matrix by a 3x4 transformation matrix + */ +static inline void vmathM4MulT3( VmathMatrix4 *result, const VmathMatrix4 *mat, const VmathTransform3 *tfrm ); + +/* + * Construct an identity 4x4 matrix + */ +static inline void vmathM4MakeIdentity( VmathMatrix4 *result ); + +/* + * Construct a 4x4 matrix to rotate around the x axis + */ +static inline void vmathM4MakeRotationX( VmathMatrix4 *result, float radians ); + +/* + * Construct a 4x4 matrix to rotate around the y axis + */ +static inline void vmathM4MakeRotationY( VmathMatrix4 *result, float radians ); + +/* + * Construct a 4x4 matrix to rotate around the z axis + */ +static inline void vmathM4MakeRotationZ( VmathMatrix4 *result, float radians ); + +/* + * Construct a 4x4 matrix to rotate around the x, y, and z axes + */ +static inline void vmathM4MakeRotationZYX( VmathMatrix4 *result, const VmathVector3 *radiansXYZ ); + +/* + * Construct a 4x4 matrix to rotate around a unit-length 3-D vector + */ +static inline void vmathM4MakeRotationAxis( VmathMatrix4 *result, float radians, const VmathVector3 *unitVec ); + +/* + * Construct a rotation matrix from a unit-length quaternion + */ +static inline void vmathM4MakeRotationQ( VmathMatrix4 *result, const VmathQuat *unitQuat ); + +/* + * Construct a 4x4 matrix to perform scaling + */ +static inline void vmathM4MakeScale( VmathMatrix4 *result, const VmathVector3 *scaleVec ); + +/* + * Construct a 4x4 matrix to perform translation + */ +static inline void vmathM4MakeTranslation( VmathMatrix4 *result, const VmathVector3 *translateVec ); + +/* + * Construct viewing matrix based on eye position, position looked at, and up direction + */ +static inline void vmathM4MakeLookAt( VmathMatrix4 *result, const VmathPoint3 *eyePos, const VmathPoint3 *lookAtPos, const VmathVector3 *upVec ); + +/* + * Construct a perspective projection matrix + */ +static inline void vmathM4MakePerspective( VmathMatrix4 *result, float fovyRadians, float aspect, float zNear, float zFar ); + +/* + * Construct a perspective projection matrix based on frustum + */ +static inline void vmathM4MakeFrustum( VmathMatrix4 *result, float left, float right, float bottom, float top, float zNear, float zFar ); + +/* + * Construct an orthographic projection matrix + */ +static inline void vmathM4MakeOrthographic( VmathMatrix4 *result, float left, float right, float bottom, float top, float zNear, float zFar ); + +/* + * Append (post-multiply) a scale transformation to a 4x4 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline void vmathM4AppendScale( VmathMatrix4 *result, const VmathMatrix4 *mat, const VmathVector3 *scaleVec ); + +/* + * Prepend (pre-multiply) a scale transformation to a 4x4 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline void vmathM4PrependScale( VmathMatrix4 *result, const VmathVector3 *scaleVec, const VmathMatrix4 *mat ); + +/* + * Multiply two 4x4 matrices per element + */ +static inline void vmathM4MulPerElem( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ); + +/* + * Compute the absolute value of a 4x4 matrix per element + */ +static inline void vmathM4AbsPerElem( VmathMatrix4 *result, const VmathMatrix4 *mat ); + +/* + * Transpose of a 4x4 matrix + */ +static inline void vmathM4Transpose( VmathMatrix4 *result, const VmathMatrix4 *mat ); + +/* + * Compute the inverse of a 4x4 matrix + * NOTE: + * Result is unpredictable when the determinant of mat is equal to or near 0. + */ +static inline void vmathM4Inverse( VmathMatrix4 *result, const VmathMatrix4 *mat ); + +/* + * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix + * NOTE: + * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. The result is unpredictable when the determinant of mat is equal to or near 0. + */ +static inline void vmathM4AffineInverse( VmathMatrix4 *result, const VmathMatrix4 *mat ); + +/* + * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix + * NOTE: + * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. + */ +static inline void vmathM4OrthoInverse( VmathMatrix4 *result, const VmathMatrix4 *mat ); + +/* + * Determinant of a 4x4 matrix + */ +static inline float vmathM4Determinant( const VmathMatrix4 *mat ); + +/* + * Conditionally select between two 4x4 matrices + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + * However, the transfer of select1 to a VMX register may use more processing time than a branch. + */ +static inline void vmathM4Select( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1, unsigned int select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 4x4 matrix + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathM4Print( const VmathMatrix4 *mat ); + +/* + * Print a 4x4 matrix and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathM4Prints( const VmathMatrix4 *mat, const char *name ); + +#endif + +/* + * Copy a 3x4 transformation matrix + */ +static inline void vmathT3Copy( VmathTransform3 *result, const VmathTransform3 *tfrm ); + +/* + * Construct a 3x4 transformation matrix containing the specified columns + */ +static inline void vmathT3MakeFromCols( VmathTransform3 *result, const VmathVector3 *col0, const VmathVector3 *col1, const VmathVector3 *col2, const VmathVector3 *col3 ); + +/* + * Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector + */ +static inline void vmathT3MakeFromM3V3( VmathTransform3 *result, const VmathMatrix3 *tfrm, const VmathVector3 *translateVec ); + +/* + * Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector + */ +static inline void vmathT3MakeFromQV3( VmathTransform3 *result, const VmathQuat *unitQuat, const VmathVector3 *translateVec ); + +/* + * Set all elements of a 3x4 transformation matrix to the same scalar value + */ +static inline void vmathT3MakeFromScalar( VmathTransform3 *result, float scalar ); + +/* + * Set the upper-left 3x3 submatrix + */ +static inline void vmathT3SetUpper3x3( VmathTransform3 *result, const VmathMatrix3 *mat3 ); + +/* + * Get the upper-left 3x3 submatrix of a 3x4 transformation matrix + */ +static inline void vmathT3GetUpper3x3( VmathMatrix3 *result, const VmathTransform3 *tfrm ); + +/* + * Set translation component + */ +static inline void vmathT3SetTranslation( VmathTransform3 *result, const VmathVector3 *translateVec ); + +/* + * Get the translation component of a 3x4 transformation matrix + */ +static inline void vmathT3GetTranslation( VmathVector3 *result, const VmathTransform3 *tfrm ); + +/* + * Set column 0 of a 3x4 transformation matrix + */ +static inline void vmathT3SetCol0( VmathTransform3 *result, const VmathVector3 *col0 ); + +/* + * Set column 1 of a 3x4 transformation matrix + */ +static inline void vmathT3SetCol1( VmathTransform3 *result, const VmathVector3 *col1 ); + +/* + * Set column 2 of a 3x4 transformation matrix + */ +static inline void vmathT3SetCol2( VmathTransform3 *result, const VmathVector3 *col2 ); + +/* + * Set column 3 of a 3x4 transformation matrix + */ +static inline void vmathT3SetCol3( VmathTransform3 *result, const VmathVector3 *col3 ); + +/* + * Get column 0 of a 3x4 transformation matrix + */ +static inline void vmathT3GetCol0( VmathVector3 *result, const VmathTransform3 *tfrm ); + +/* + * Get column 1 of a 3x4 transformation matrix + */ +static inline void vmathT3GetCol1( VmathVector3 *result, const VmathTransform3 *tfrm ); + +/* + * Get column 2 of a 3x4 transformation matrix + */ +static inline void vmathT3GetCol2( VmathVector3 *result, const VmathTransform3 *tfrm ); + +/* + * Get column 3 of a 3x4 transformation matrix + */ +static inline void vmathT3GetCol3( VmathVector3 *result, const VmathTransform3 *tfrm ); + +/* + * Set the column of a 3x4 transformation matrix referred to by the specified index + */ +static inline void vmathT3SetCol( VmathTransform3 *result, int col, const VmathVector3 *vec ); + +/* + * Set the row of a 3x4 transformation matrix referred to by the specified index + */ +static inline void vmathT3SetRow( VmathTransform3 *result, int row, const VmathVector4 *vec ); + +/* + * Get the column of a 3x4 transformation matrix referred to by the specified index + */ +static inline void vmathT3GetCol( VmathVector3 *result, const VmathTransform3 *tfrm, int col ); + +/* + * Get the row of a 3x4 transformation matrix referred to by the specified index + */ +static inline void vmathT3GetRow( VmathVector4 *result, const VmathTransform3 *tfrm, int row ); + +/* + * Set the element of a 3x4 transformation matrix referred to by column and row indices + */ +static inline void vmathT3SetElem( VmathTransform3 *result, int col, int row, float val ); + +/* + * Get the element of a 3x4 transformation matrix referred to by column and row indices + */ +static inline float vmathT3GetElem( const VmathTransform3 *tfrm, int col, int row ); + +/* + * Multiply a 3x4 transformation matrix by a 3-D vector + */ +static inline void vmathT3MulV3( VmathVector3 *result, const VmathTransform3 *tfrm, const VmathVector3 *vec ); + +/* + * Multiply a 3x4 transformation matrix by a 3-D point + */ +static inline void vmathT3MulP3( VmathPoint3 *result, const VmathTransform3 *tfrm, const VmathPoint3 *pnt ); + +/* + * Multiply two 3x4 transformation matrices + */ +static inline void vmathT3Mul( VmathTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1 ); + +/* + * Construct an identity 3x4 transformation matrix + */ +static inline void vmathT3MakeIdentity( VmathTransform3 *result ); + +/* + * Construct a 3x4 transformation matrix to rotate around the x axis + */ +static inline void vmathT3MakeRotationX( VmathTransform3 *result, float radians ); + +/* + * Construct a 3x4 transformation matrix to rotate around the y axis + */ +static inline void vmathT3MakeRotationY( VmathTransform3 *result, float radians ); + +/* + * Construct a 3x4 transformation matrix to rotate around the z axis + */ +static inline void vmathT3MakeRotationZ( VmathTransform3 *result, float radians ); + +/* + * Construct a 3x4 transformation matrix to rotate around the x, y, and z axes + */ +static inline void vmathT3MakeRotationZYX( VmathTransform3 *result, const VmathVector3 *radiansXYZ ); + +/* + * Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector + */ +static inline void vmathT3MakeRotationAxis( VmathTransform3 *result, float radians, const VmathVector3 *unitVec ); + +/* + * Construct a rotation matrix from a unit-length quaternion + */ +static inline void vmathT3MakeRotationQ( VmathTransform3 *result, const VmathQuat *unitQuat ); + +/* + * Construct a 3x4 transformation matrix to perform scaling + */ +static inline void vmathT3MakeScale( VmathTransform3 *result, const VmathVector3 *scaleVec ); + +/* + * Construct a 3x4 transformation matrix to perform translation + */ +static inline void vmathT3MakeTranslation( VmathTransform3 *result, const VmathVector3 *translateVec ); + +/* + * Append (post-multiply) a scale transformation to a 3x4 transformation matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline void vmathT3AppendScale( VmathTransform3 *result, const VmathTransform3 *tfrm, const VmathVector3 *scaleVec ); + +/* + * Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline void vmathT3PrependScale( VmathTransform3 *result, const VmathVector3 *scaleVec, const VmathTransform3 *tfrm ); + +/* + * Multiply two 3x4 transformation matrices per element + */ +static inline void vmathT3MulPerElem( VmathTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1 ); + +/* + * Compute the absolute value of a 3x4 transformation matrix per element + */ +static inline void vmathT3AbsPerElem( VmathTransform3 *result, const VmathTransform3 *tfrm ); + +/* + * Inverse of a 3x4 transformation matrix + * NOTE: + * Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0. + */ +static inline void vmathT3Inverse( VmathTransform3 *result, const VmathTransform3 *tfrm ); + +/* + * Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix + * NOTE: + * This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions. + */ +static inline void vmathT3OrthoInverse( VmathTransform3 *result, const VmathTransform3 *tfrm ); + +/* + * Conditionally select between two 3x4 transformation matrices + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + * However, the transfer of select1 to a VMX register may use more processing time than a branch. + */ +static inline void vmathT3Select( VmathTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1, unsigned int select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3x4 transformation matrix + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathT3Print( const VmathTransform3 *tfrm ); + +/* + * Print a 3x4 transformation matrix and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathT3Prints( const VmathTransform3 *tfrm, const char *name ); + +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include "vec_aos.h" +#include "quat_aos.h" +#include "mat_aos.h" + +#endif diff --git a/vectormathlibrary/include/vectormath/ppu/c/vectormath_aos_v.h b/vectormathlibrary/include/vectormath/ppu/c/vectormath_aos_v.h new file mode 100644 index 000000000..a8599172b --- /dev/null +++ b/vectormathlibrary/include/vectormath/ppu/c/vectormath_aos_v.h @@ -0,0 +1,1925 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_AOS_C_V_PPU_H +#define _VECTORMATH_AOS_C_V_PPU_H + +#include <math.h> +#include <altivec.h> +#include "vec_types.h" + +#ifdef _VECTORMATH_DEBUG +#include <stdio.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#ifndef _VECTORMATH_AOS_C_TYPES_H +#define _VECTORMATH_AOS_C_TYPES_H + +/* A 3-D vector in array-of-structures format + */ +typedef struct _VmathVector3 +{ + vec_float4 vec128; +} VmathVector3; + +/* A 4-D vector in array-of-structures format + */ +typedef struct _VmathVector4 +{ + vec_float4 vec128; +} VmathVector4; + +/* A 3-D point in array-of-structures format + */ +typedef struct _VmathPoint3 +{ + vec_float4 vec128; +} VmathPoint3; + +/* A quaternion in array-of-structures format + */ +typedef struct _VmathQuat +{ + vec_float4 vec128; +} VmathQuat; + +/* A 3x3 matrix in array-of-structures format + */ +typedef struct _VmathMatrix3 +{ + VmathVector3 col0; + VmathVector3 col1; + VmathVector3 col2; +} VmathMatrix3; + +/* A 4x4 matrix in array-of-structures format + */ +typedef struct _VmathMatrix4 +{ + VmathVector4 col0; + VmathVector4 col1; + VmathVector4 col2; + VmathVector4 col3; +} VmathMatrix4; + +/* A 3x4 transformation matrix in array-of-structures format + */ +typedef struct _VmathTransform3 +{ + VmathVector3 col0; + VmathVector3 col1; + VmathVector3 col2; + VmathVector3 col3; +} VmathTransform3; + +#endif + +/* + * Construct a 3-D vector from x, y, and z elements + */ +static inline VmathVector3 vmathV3MakeFromElems_V( float x, float y, float z ); + +/* + * Copy elements from a 3-D point into a 3-D vector + */ +static inline VmathVector3 vmathV3MakeFromP3_V( VmathPoint3 pnt ); + +/* + * Set all elements of a 3-D vector to the same scalar value + */ +static inline VmathVector3 vmathV3MakeFromScalar_V( float scalar ); + +/* + * Set vector float data in a 3-D vector + */ +static inline VmathVector3 vmathV3MakeFrom128_V( vec_float4 vf4 ); + +/* + * Get vector float data from a 3-D vector + */ +static inline vec_float4 vmathV3Get128_V( VmathVector3 vec ); + +/* + * Set the x element of a 3-D vector + */ +static inline void vmathV3SetX_V( VmathVector3 *result, float x ); + +/* + * Set the y element of a 3-D vector + */ +static inline void vmathV3SetY_V( VmathVector3 *result, float y ); + +/* + * Set the z element of a 3-D vector + */ +static inline void vmathV3SetZ_V( VmathVector3 *result, float z ); + +/* + * Get the x element of a 3-D vector + */ +static inline float vmathV3GetX_V( VmathVector3 vec ); + +/* + * Get the y element of a 3-D vector + */ +static inline float vmathV3GetY_V( VmathVector3 vec ); + +/* + * Get the z element of a 3-D vector + */ +static inline float vmathV3GetZ_V( VmathVector3 vec ); + +/* + * Set an x, y, or z element of a 3-D vector by index + */ +static inline void vmathV3SetElem_V( VmathVector3 *result, int idx, float value ); + +/* + * Get an x, y, or z element of a 3-D vector by index + */ +static inline float vmathV3GetElem_V( VmathVector3 vec, int idx ); + +/* + * Add two 3-D vectors + */ +static inline VmathVector3 vmathV3Add_V( VmathVector3 vec0, VmathVector3 vec1 ); + +/* + * Subtract a 3-D vector from another 3-D vector + */ +static inline VmathVector3 vmathV3Sub_V( VmathVector3 vec0, VmathVector3 vec1 ); + +/* + * Add a 3-D vector to a 3-D point + */ +static inline VmathPoint3 vmathV3AddP3_V( VmathVector3 vec, VmathPoint3 pnt ); + +/* + * Multiply a 3-D vector by a scalar + */ +static inline VmathVector3 vmathV3ScalarMul_V( VmathVector3 vec, float scalar ); + +/* + * Divide a 3-D vector by a scalar + */ +static inline VmathVector3 vmathV3ScalarDiv_V( VmathVector3 vec, float scalar ); + +/* + * Negate all elements of a 3-D vector + */ +static inline VmathVector3 vmathV3Neg_V( VmathVector3 vec ); + +/* + * Construct x axis + */ +static inline VmathVector3 vmathV3MakeXAxis_V( ); + +/* + * Construct y axis + */ +static inline VmathVector3 vmathV3MakeYAxis_V( ); + +/* + * Construct z axis + */ +static inline VmathVector3 vmathV3MakeZAxis_V( ); + +/* + * Multiply two 3-D vectors per element + */ +static inline VmathVector3 vmathV3MulPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ); + +/* + * Divide two 3-D vectors per element + * NOTE: + * Floating-point behavior matches standard library function divf4. + */ +static inline VmathVector3 vmathV3DivPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ); + +/* + * Compute the reciprocal of a 3-D vector per element + * NOTE: + * Floating-point behavior matches standard library function recipf4. + */ +static inline VmathVector3 vmathV3RecipPerElem_V( VmathVector3 vec ); + +/* + * Compute the square root of a 3-D vector per element + * NOTE: + * Floating-point behavior matches standard library function sqrtf4. + */ +static inline VmathVector3 vmathV3SqrtPerElem_V( VmathVector3 vec ); + +/* + * Compute the reciprocal square root of a 3-D vector per element + * NOTE: + * Floating-point behavior matches standard library function rsqrtf4. + */ +static inline VmathVector3 vmathV3RsqrtPerElem_V( VmathVector3 vec ); + +/* + * Compute the absolute value of a 3-D vector per element + */ +static inline VmathVector3 vmathV3AbsPerElem_V( VmathVector3 vec ); + +/* + * Copy sign from one 3-D vector to another, per element + */ +static inline VmathVector3 vmathV3CopySignPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ); + +/* + * Maximum of two 3-D vectors per element + */ +static inline VmathVector3 vmathV3MaxPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ); + +/* + * Minimum of two 3-D vectors per element + */ +static inline VmathVector3 vmathV3MinPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ); + +/* + * Maximum element of a 3-D vector + */ +static inline float vmathV3MaxElem_V( VmathVector3 vec ); + +/* + * Minimum element of a 3-D vector + */ +static inline float vmathV3MinElem_V( VmathVector3 vec ); + +/* + * Compute the sum of all elements of a 3-D vector + */ +static inline float vmathV3Sum_V( VmathVector3 vec ); + +/* + * Compute the dot product of two 3-D vectors + */ +static inline float vmathV3Dot_V( VmathVector3 vec0, VmathVector3 vec1 ); + +/* + * Compute the square of the length of a 3-D vector + */ +static inline float vmathV3LengthSqr_V( VmathVector3 vec ); + +/* + * Compute the length of a 3-D vector + */ +static inline float vmathV3Length_V( VmathVector3 vec ); + +/* + * Normalize a 3-D vector + * NOTE: + * The result is unpredictable when all elements of vec are at or near zero. + */ +static inline VmathVector3 vmathV3Normalize_V( VmathVector3 vec ); + +/* + * Compute cross product of two 3-D vectors + */ +static inline VmathVector3 vmathV3Cross_V( VmathVector3 vec0, VmathVector3 vec1 ); + +/* + * Outer product of two 3-D vectors + */ +static inline VmathMatrix3 vmathV3Outer_V( VmathVector3 vec0, VmathVector3 vec1 ); + +/* + * Pre-multiply a row vector by a 3x3 matrix + * NOTE: + * Slower than column post-multiply. + */ +static inline VmathVector3 vmathV3RowMul_V( VmathVector3 vec, VmathMatrix3 mat ); + +/* + * Cross-product matrix of a 3-D vector + */ +static inline VmathMatrix3 vmathV3CrossMatrix_V( VmathVector3 vec ); + +/* + * Create cross-product matrix and multiply + * NOTE: + * Faster than separately creating a cross-product matrix and multiplying. + */ +static inline VmathMatrix3 vmathV3CrossMatrixMul_V( VmathVector3 vec, VmathMatrix3 mat ); + +/* + * Linear interpolation between two 3-D vectors + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline VmathVector3 vmathV3Lerp_V( float t, VmathVector3 vec0, VmathVector3 vec1 ); + +/* + * Spherical linear interpolation between two 3-D vectors + * NOTE: + * The result is unpredictable if the vectors point in opposite directions. + * Does not clamp t between 0 and 1. + */ +static inline VmathVector3 vmathV3Slerp_V( float t, VmathVector3 unitVec0, VmathVector3 unitVec1 ); + +/* + * Conditionally select between two 3-D vectors + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + * However, the transfer of select1 to a VMX register may use more processing time than a branch. + */ +static inline VmathVector3 vmathV3Select_V( VmathVector3 vec0, VmathVector3 vec1, unsigned int select1 ); + +/* + * Store x, y, and z elements of a 3-D vector in the first three words of a quadword. + * The value of the fourth word (the word with the highest address) remains unchanged + */ +static inline void vmathV3StoreXYZ_V( VmathVector3 vec, vec_float4 *quad ); + +/* + * Load four three-float 3-D vectors, stored in three quadwords + */ +static inline void vmathV3LoadXYZArray_V( VmathVector3 *vec0, VmathVector3 *vec1, VmathVector3 *vec2, VmathVector3 *vec3, const vec_float4 *threeQuads ); + +/* + * Store four 3-D vectors in three quadwords + */ +static inline void vmathV3StoreXYZArray_V( VmathVector3 vec0, VmathVector3 vec1, VmathVector3 vec2, VmathVector3 vec3, vec_float4 *threeQuads ); + +/* + * Store eight 3-D vectors as half-floats + */ +static inline void vmathV3StoreHalfFloats_V( VmathVector3 vec0, VmathVector3 vec1, VmathVector3 vec2, VmathVector3 vec3, VmathVector3 vec4, VmathVector3 vec5, VmathVector3 vec6, VmathVector3 vec7, vec_ushort8 *threeQuads ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3-D vector + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathV3Print_V( VmathVector3 vec ); + +/* + * Print a 3-D vector and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathV3Prints_V( VmathVector3 vec, const char *name ); + +#endif + +/* + * Construct a 4-D vector from x, y, z, and w elements + */ +static inline VmathVector4 vmathV4MakeFromElems_V( float x, float y, float z, float w ); + +/* + * Construct a 4-D vector from a 3-D vector and a scalar + */ +static inline VmathVector4 vmathV4MakeFromV3Scalar_V( VmathVector3 xyz, float w ); + +/* + * Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0 + */ +static inline VmathVector4 vmathV4MakeFromV3_V( VmathVector3 vec ); + +/* + * Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1 + */ +static inline VmathVector4 vmathV4MakeFromP3_V( VmathPoint3 pnt ); + +/* + * Copy elements from a quaternion into a 4-D vector + */ +static inline VmathVector4 vmathV4MakeFromQ_V( VmathQuat quat ); + +/* + * Set all elements of a 4-D vector to the same scalar value + */ +static inline VmathVector4 vmathV4MakeFromScalar_V( float scalar ); + +/* + * Set vector float data in a 4-D vector + */ +static inline VmathVector4 vmathV4MakeFrom128_V( vec_float4 vf4 ); + +/* + * Get vector float data from a 4-D vector + */ +static inline vec_float4 vmathV4Get128_V( VmathVector4 vec ); + +/* + * Set the x, y, and z elements of a 4-D vector + * NOTE: + * This function does not change the w element. + */ +static inline void vmathV4SetXYZ_V( VmathVector4 *result, VmathVector3 vec ); + +/* + * Get the x, y, and z elements of a 4-D vector + */ +static inline VmathVector3 vmathV4GetXYZ_V( VmathVector4 vec ); + +/* + * Set the x element of a 4-D vector + */ +static inline void vmathV4SetX_V( VmathVector4 *result, float x ); + +/* + * Set the y element of a 4-D vector + */ +static inline void vmathV4SetY_V( VmathVector4 *result, float y ); + +/* + * Set the z element of a 4-D vector + */ +static inline void vmathV4SetZ_V( VmathVector4 *result, float z ); + +/* + * Set the w element of a 4-D vector + */ +static inline void vmathV4SetW_V( VmathVector4 *result, float w ); + +/* + * Get the x element of a 4-D vector + */ +static inline float vmathV4GetX_V( VmathVector4 vec ); + +/* + * Get the y element of a 4-D vector + */ +static inline float vmathV4GetY_V( VmathVector4 vec ); + +/* + * Get the z element of a 4-D vector + */ +static inline float vmathV4GetZ_V( VmathVector4 vec ); + +/* + * Get the w element of a 4-D vector + */ +static inline float vmathV4GetW_V( VmathVector4 vec ); + +/* + * Set an x, y, z, or w element of a 4-D vector by index + */ +static inline void vmathV4SetElem_V( VmathVector4 *result, int idx, float value ); + +/* + * Get an x, y, z, or w element of a 4-D vector by index + */ +static inline float vmathV4GetElem_V( VmathVector4 vec, int idx ); + +/* + * Add two 4-D vectors + */ +static inline VmathVector4 vmathV4Add_V( VmathVector4 vec0, VmathVector4 vec1 ); + +/* + * Subtract a 4-D vector from another 4-D vector + */ +static inline VmathVector4 vmathV4Sub_V( VmathVector4 vec0, VmathVector4 vec1 ); + +/* + * Multiply a 4-D vector by a scalar + */ +static inline VmathVector4 vmathV4ScalarMul_V( VmathVector4 vec, float scalar ); + +/* + * Divide a 4-D vector by a scalar + */ +static inline VmathVector4 vmathV4ScalarDiv_V( VmathVector4 vec, float scalar ); + +/* + * Negate all elements of a 4-D vector + */ +static inline VmathVector4 vmathV4Neg_V( VmathVector4 vec ); + +/* + * Construct x axis + */ +static inline VmathVector4 vmathV4MakeXAxis_V( ); + +/* + * Construct y axis + */ +static inline VmathVector4 vmathV4MakeYAxis_V( ); + +/* + * Construct z axis + */ +static inline VmathVector4 vmathV4MakeZAxis_V( ); + +/* + * Construct w axis + */ +static inline VmathVector4 vmathV4MakeWAxis_V( ); + +/* + * Multiply two 4-D vectors per element + */ +static inline VmathVector4 vmathV4MulPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ); + +/* + * Divide two 4-D vectors per element + * NOTE: + * Floating-point behavior matches standard library function divf4. + */ +static inline VmathVector4 vmathV4DivPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ); + +/* + * Compute the reciprocal of a 4-D vector per element + * NOTE: + * Floating-point behavior matches standard library function recipf4. + */ +static inline VmathVector4 vmathV4RecipPerElem_V( VmathVector4 vec ); + +/* + * Compute the square root of a 4-D vector per element + * NOTE: + * Floating-point behavior matches standard library function sqrtf4. + */ +static inline VmathVector4 vmathV4SqrtPerElem_V( VmathVector4 vec ); + +/* + * Compute the reciprocal square root of a 4-D vector per element + * NOTE: + * Floating-point behavior matches standard library function rsqrtf4. + */ +static inline VmathVector4 vmathV4RsqrtPerElem_V( VmathVector4 vec ); + +/* + * Compute the absolute value of a 4-D vector per element + */ +static inline VmathVector4 vmathV4AbsPerElem_V( VmathVector4 vec ); + +/* + * Copy sign from one 4-D vector to another, per element + */ +static inline VmathVector4 vmathV4CopySignPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ); + +/* + * Maximum of two 4-D vectors per element + */ +static inline VmathVector4 vmathV4MaxPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ); + +/* + * Minimum of two 4-D vectors per element + */ +static inline VmathVector4 vmathV4MinPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ); + +/* + * Maximum element of a 4-D vector + */ +static inline float vmathV4MaxElem_V( VmathVector4 vec ); + +/* + * Minimum element of a 4-D vector + */ +static inline float vmathV4MinElem_V( VmathVector4 vec ); + +/* + * Compute the sum of all elements of a 4-D vector + */ +static inline float vmathV4Sum_V( VmathVector4 vec ); + +/* + * Compute the dot product of two 4-D vectors + */ +static inline float vmathV4Dot_V( VmathVector4 vec0, VmathVector4 vec1 ); + +/* + * Compute the square of the length of a 4-D vector + */ +static inline float vmathV4LengthSqr_V( VmathVector4 vec ); + +/* + * Compute the length of a 4-D vector + */ +static inline float vmathV4Length_V( VmathVector4 vec ); + +/* + * Normalize a 4-D vector + * NOTE: + * The result is unpredictable when all elements of vec are at or near zero. + */ +static inline VmathVector4 vmathV4Normalize_V( VmathVector4 vec ); + +/* + * Outer product of two 4-D vectors + */ +static inline VmathMatrix4 vmathV4Outer_V( VmathVector4 vec0, VmathVector4 vec1 ); + +/* + * Linear interpolation between two 4-D vectors + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline VmathVector4 vmathV4Lerp_V( float t, VmathVector4 vec0, VmathVector4 vec1 ); + +/* + * Spherical linear interpolation between two 4-D vectors + * NOTE: + * The result is unpredictable if the vectors point in opposite directions. + * Does not clamp t between 0 and 1. + */ +static inline VmathVector4 vmathV4Slerp_V( float t, VmathVector4 unitVec0, VmathVector4 unitVec1 ); + +/* + * Conditionally select between two 4-D vectors + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + * However, the transfer of select1 to a VMX register may use more processing time than a branch. + */ +static inline VmathVector4 vmathV4Select_V( VmathVector4 vec0, VmathVector4 vec1, unsigned int select1 ); + +/* + * Store four 4-D vectors as half-floats + */ +static inline void vmathV4StoreHalfFloats_V( VmathVector4 vec0, VmathVector4 vec1, VmathVector4 vec2, VmathVector4 vec3, vec_ushort8 *twoQuads ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 4-D vector + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathV4Print_V( VmathVector4 vec ); + +/* + * Print a 4-D vector and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathV4Prints_V( VmathVector4 vec, const char *name ); + +#endif + +/* + * Construct a 3-D point from x, y, and z elements + */ +static inline VmathPoint3 vmathP3MakeFromElems_V( float x, float y, float z ); + +/* + * Copy elements from a 3-D vector into a 3-D point + */ +static inline VmathPoint3 vmathP3MakeFromV3_V( VmathVector3 vec ); + +/* + * Set all elements of a 3-D point to the same scalar value + */ +static inline VmathPoint3 vmathP3MakeFromScalar_V( float scalar ); + +/* + * Set vector float data in a 3-D point + */ +static inline VmathPoint3 vmathP3MakeFrom128_V( vec_float4 vf4 ); + +/* + * Get vector float data from a 3-D point + */ +static inline vec_float4 vmathP3Get128_V( VmathPoint3 pnt ); + +/* + * Set the x element of a 3-D point + */ +static inline void vmathP3SetX_V( VmathPoint3 *result, float x ); + +/* + * Set the y element of a 3-D point + */ +static inline void vmathP3SetY_V( VmathPoint3 *result, float y ); + +/* + * Set the z element of a 3-D point + */ +static inline void vmathP3SetZ_V( VmathPoint3 *result, float z ); + +/* + * Get the x element of a 3-D point + */ +static inline float vmathP3GetX_V( VmathPoint3 pnt ); + +/* + * Get the y element of a 3-D point + */ +static inline float vmathP3GetY_V( VmathPoint3 pnt ); + +/* + * Get the z element of a 3-D point + */ +static inline float vmathP3GetZ_V( VmathPoint3 pnt ); + +/* + * Set an x, y, or z element of a 3-D point by index + */ +static inline void vmathP3SetElem_V( VmathPoint3 *result, int idx, float value ); + +/* + * Get an x, y, or z element of a 3-D point by index + */ +static inline float vmathP3GetElem_V( VmathPoint3 pnt, int idx ); + +/* + * Subtract a 3-D point from another 3-D point + */ +static inline VmathVector3 vmathP3Sub_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); + +/* + * Add a 3-D point to a 3-D vector + */ +static inline VmathPoint3 vmathP3AddV3_V( VmathPoint3 pnt, VmathVector3 vec ); + +/* + * Subtract a 3-D vector from a 3-D point + */ +static inline VmathPoint3 vmathP3SubV3_V( VmathPoint3 pnt, VmathVector3 vec ); + +/* + * Multiply two 3-D points per element + */ +static inline VmathPoint3 vmathP3MulPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); + +/* + * Divide two 3-D points per element + * NOTE: + * Floating-point behavior matches standard library function divf4. + */ +static inline VmathPoint3 vmathP3DivPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); + +/* + * Compute the reciprocal of a 3-D point per element + * NOTE: + * Floating-point behavior matches standard library function recipf4. + */ +static inline VmathPoint3 vmathP3RecipPerElem_V( VmathPoint3 pnt ); + +/* + * Compute the square root of a 3-D point per element + * NOTE: + * Floating-point behavior matches standard library function sqrtf4. + */ +static inline VmathPoint3 vmathP3SqrtPerElem_V( VmathPoint3 pnt ); + +/* + * Compute the reciprocal square root of a 3-D point per element + * NOTE: + * Floating-point behavior matches standard library function rsqrtf4. + */ +static inline VmathPoint3 vmathP3RsqrtPerElem_V( VmathPoint3 pnt ); + +/* + * Compute the absolute value of a 3-D point per element + */ +static inline VmathPoint3 vmathP3AbsPerElem_V( VmathPoint3 pnt ); + +/* + * Copy sign from one 3-D point to another, per element + */ +static inline VmathPoint3 vmathP3CopySignPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); + +/* + * Maximum of two 3-D points per element + */ +static inline VmathPoint3 vmathP3MaxPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); + +/* + * Minimum of two 3-D points per element + */ +static inline VmathPoint3 vmathP3MinPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); + +/* + * Maximum element of a 3-D point + */ +static inline float vmathP3MaxElem_V( VmathPoint3 pnt ); + +/* + * Minimum element of a 3-D point + */ +static inline float vmathP3MinElem_V( VmathPoint3 pnt ); + +/* + * Compute the sum of all elements of a 3-D point + */ +static inline float vmathP3Sum_V( VmathPoint3 pnt ); + +/* + * Apply uniform scale to a 3-D point + */ +static inline VmathPoint3 vmathP3Scale_V( VmathPoint3 pnt, float scaleVal ); + +/* + * Apply non-uniform scale to a 3-D point + */ +static inline VmathPoint3 vmathP3NonUniformScale_V( VmathPoint3 pnt, VmathVector3 scaleVec ); + +/* + * Scalar projection of a 3-D point on a unit-length 3-D vector + */ +static inline float vmathP3Projection_V( VmathPoint3 pnt, VmathVector3 unitVec ); + +/* + * Compute the square of the distance of a 3-D point from the coordinate-system origin + */ +static inline float vmathP3DistSqrFromOrigin_V( VmathPoint3 pnt ); + +/* + * Compute the distance of a 3-D point from the coordinate-system origin + */ +static inline float vmathP3DistFromOrigin_V( VmathPoint3 pnt ); + +/* + * Compute the square of the distance between two 3-D points + */ +static inline float vmathP3DistSqr_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); + +/* + * Compute the distance between two 3-D points + */ +static inline float vmathP3Dist_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); + +/* + * Linear interpolation between two 3-D points + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline VmathPoint3 vmathP3Lerp_V( float t, VmathPoint3 pnt0, VmathPoint3 pnt1 ); + +/* + * Conditionally select between two 3-D points + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + * However, the transfer of select1 to a VMX register may use more processing time than a branch. + */ +static inline VmathPoint3 vmathP3Select_V( VmathPoint3 pnt0, VmathPoint3 pnt1, unsigned int select1 ); + +/* + * Store x, y, and z elements of a 3-D point in the first three words of a quadword. + * The value of the fourth word (the word with the highest address) remains unchanged + */ +static inline void vmathP3StoreXYZ_V( VmathPoint3 pnt, vec_float4 *quad ); + +/* + * Load four three-float 3-D points, stored in three quadwords + */ +static inline void vmathP3LoadXYZArray_V( VmathPoint3 *pnt0, VmathPoint3 *pnt1, VmathPoint3 *pnt2, VmathPoint3 *pnt3, const vec_float4 *threeQuads ); + +/* + * Store four 3-D points in three quadwords + */ +static inline void vmathP3StoreXYZArray_V( VmathPoint3 pnt0, VmathPoint3 pnt1, VmathPoint3 pnt2, VmathPoint3 pnt3, vec_float4 *threeQuads ); + +/* + * Store eight 3-D points as half-floats + */ +static inline void vmathP3StoreHalfFloats_V( VmathPoint3 pnt0, VmathPoint3 pnt1, VmathPoint3 pnt2, VmathPoint3 pnt3, VmathPoint3 pnt4, VmathPoint3 pnt5, VmathPoint3 pnt6, VmathPoint3 pnt7, vec_ushort8 *threeQuads ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3-D point + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathP3Print_V( VmathPoint3 pnt ); + +/* + * Print a 3-D point and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathP3Prints_V( VmathPoint3 pnt, const char *name ); + +#endif + +/* + * Construct a quaternion from x, y, z, and w elements + */ +static inline VmathQuat vmathQMakeFromElems_V( float x, float y, float z, float w ); + +/* + * Construct a quaternion from a 3-D vector and a scalar + */ +static inline VmathQuat vmathQMakeFromV3Scalar_V( VmathVector3 xyz, float w ); + +/* + * Copy elements from a 4-D vector into a quaternion + */ +static inline VmathQuat vmathQMakeFromV4_V( VmathVector4 vec ); + +/* + * Convert a rotation matrix to a unit-length quaternion + */ +static inline VmathQuat vmathQMakeFromM3_V( VmathMatrix3 rotMat ); + +/* + * Set all elements of a quaternion to the same scalar value + */ +static inline VmathQuat vmathQMakeFromScalar_V( float scalar ); + +/* + * Set vector float data in a quaternion + */ +static inline VmathQuat vmathQMakeFrom128_V( vec_float4 vf4 ); + +/* + * Get vector float data from a quaternion + */ +static inline vec_float4 vmathQGet128_V( VmathQuat quat ); + +/* + * Set the x, y, and z elements of a quaternion + * NOTE: + * This function does not change the w element. + */ +static inline void vmathQSetXYZ_V( VmathQuat *result, VmathVector3 vec ); + +/* + * Get the x, y, and z elements of a quaternion + */ +static inline VmathVector3 vmathQGetXYZ_V( VmathQuat quat ); + +/* + * Set the x element of a quaternion + */ +static inline void vmathQSetX_V( VmathQuat *result, float x ); + +/* + * Set the y element of a quaternion + */ +static inline void vmathQSetY_V( VmathQuat *result, float y ); + +/* + * Set the z element of a quaternion + */ +static inline void vmathQSetZ_V( VmathQuat *result, float z ); + +/* + * Set the w element of a quaternion + */ +static inline void vmathQSetW_V( VmathQuat *result, float w ); + +/* + * Get the x element of a quaternion + */ +static inline float vmathQGetX_V( VmathQuat quat ); + +/* + * Get the y element of a quaternion + */ +static inline float vmathQGetY_V( VmathQuat quat ); + +/* + * Get the z element of a quaternion + */ +static inline float vmathQGetZ_V( VmathQuat quat ); + +/* + * Get the w element of a quaternion + */ +static inline float vmathQGetW_V( VmathQuat quat ); + +/* + * Set an x, y, z, or w element of a quaternion by index + */ +static inline void vmathQSetElem_V( VmathQuat *result, int idx, float value ); + +/* + * Get an x, y, z, or w element of a quaternion by index + */ +static inline float vmathQGetElem_V( VmathQuat quat, int idx ); + +/* + * Add two quaternions + */ +static inline VmathQuat vmathQAdd_V( VmathQuat quat0, VmathQuat quat1 ); + +/* + * Subtract a quaternion from another quaternion + */ +static inline VmathQuat vmathQSub_V( VmathQuat quat0, VmathQuat quat1 ); + +/* + * Multiply two quaternions + */ +static inline VmathQuat vmathQMul_V( VmathQuat quat0, VmathQuat quat1 ); + +/* + * Multiply a quaternion by a scalar + */ +static inline VmathQuat vmathQScalarMul_V( VmathQuat quat, float scalar ); + +/* + * Divide a quaternion by a scalar + */ +static inline VmathQuat vmathQScalarDiv_V( VmathQuat quat, float scalar ); + +/* + * Negate all elements of a quaternion + */ +static inline VmathQuat vmathQNeg_V( VmathQuat quat ); + +/* + * Construct an identity quaternion + */ +static inline VmathQuat vmathQMakeIdentity_V( ); + +/* + * Construct a quaternion to rotate between two unit-length 3-D vectors + * NOTE: + * The result is unpredictable if unitVec0 and unitVec1 point in opposite directions. + */ +static inline VmathQuat vmathQMakeRotationArc_V( VmathVector3 unitVec0, VmathVector3 unitVec1 ); + +/* + * Construct a quaternion to rotate around a unit-length 3-D vector + */ +static inline VmathQuat vmathQMakeRotationAxis_V( float radians, VmathVector3 unitVec ); + +/* + * Construct a quaternion to rotate around the x axis + */ +static inline VmathQuat vmathQMakeRotationX_V( float radians ); + +/* + * Construct a quaternion to rotate around the y axis + */ +static inline VmathQuat vmathQMakeRotationY_V( float radians ); + +/* + * Construct a quaternion to rotate around the z axis + */ +static inline VmathQuat vmathQMakeRotationZ_V( float radians ); + +/* + * Compute the conjugate of a quaternion + */ +static inline VmathQuat vmathQConj_V( VmathQuat quat ); + +/* + * Use a unit-length quaternion to rotate a 3-D vector + */ +static inline VmathVector3 vmathQRotate_V( VmathQuat unitQuat, VmathVector3 vec ); + +/* + * Compute the dot product of two quaternions + */ +static inline float vmathQDot_V( VmathQuat quat0, VmathQuat quat1 ); + +/* + * Compute the norm of a quaternion + */ +static inline float vmathQNorm_V( VmathQuat quat ); + +/* + * Compute the length of a quaternion + */ +static inline float vmathQLength_V( VmathQuat quat ); + +/* + * Normalize a quaternion + * NOTE: + * The result is unpredictable when all elements of quat are at or near zero. + */ +static inline VmathQuat vmathQNormalize_V( VmathQuat quat ); + +/* + * Linear interpolation between two quaternions + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline VmathQuat vmathQLerp_V( float t, VmathQuat quat0, VmathQuat quat1 ); + +/* + * Spherical linear interpolation between two quaternions + * NOTE: + * Interpolates along the shortest path between orientations. + * Does not clamp t between 0 and 1. + */ +static inline VmathQuat vmathQSlerp_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1 ); + +/* + * Spherical quadrangle interpolation + */ +static inline VmathQuat vmathQSquad_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1, VmathQuat unitQuat2, VmathQuat unitQuat3 ); + +/* + * Conditionally select between two quaternions + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + * However, the transfer of select1 to a VMX register may use more processing time than a branch. + */ +static inline VmathQuat vmathQSelect_V( VmathQuat quat0, VmathQuat quat1, unsigned int select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a quaternion + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathQPrint_V( VmathQuat quat ); + +/* + * Print a quaternion and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathQPrints_V( VmathQuat quat, const char *name ); + +#endif + +/* + * Construct a 3x3 matrix containing the specified columns + */ +static inline VmathMatrix3 vmathM3MakeFromCols_V( VmathVector3 col0, VmathVector3 col1, VmathVector3 col2 ); + +/* + * Construct a 3x3 rotation matrix from a unit-length quaternion + */ +static inline VmathMatrix3 vmathM3MakeFromQ_V( VmathQuat unitQuat ); + +/* + * Set all elements of a 3x3 matrix to the same scalar value + */ +static inline VmathMatrix3 vmathM3MakeFromScalar_V( float scalar ); + +/* + * Set column 0 of a 3x3 matrix + */ +static inline void vmathM3SetCol0_V( VmathMatrix3 *result, VmathVector3 col0 ); + +/* + * Set column 1 of a 3x3 matrix + */ +static inline void vmathM3SetCol1_V( VmathMatrix3 *result, VmathVector3 col1 ); + +/* + * Set column 2 of a 3x3 matrix + */ +static inline void vmathM3SetCol2_V( VmathMatrix3 *result, VmathVector3 col2 ); + +/* + * Get column 0 of a 3x3 matrix + */ +static inline VmathVector3 vmathM3GetCol0_V( VmathMatrix3 mat ); + +/* + * Get column 1 of a 3x3 matrix + */ +static inline VmathVector3 vmathM3GetCol1_V( VmathMatrix3 mat ); + +/* + * Get column 2 of a 3x3 matrix + */ +static inline VmathVector3 vmathM3GetCol2_V( VmathMatrix3 mat ); + +/* + * Set the column of a 3x3 matrix referred to by the specified index + */ +static inline void vmathM3SetCol_V( VmathMatrix3 *result, int col, VmathVector3 vec ); + +/* + * Set the row of a 3x3 matrix referred to by the specified index + */ +static inline void vmathM3SetRow_V( VmathMatrix3 *result, int row, VmathVector3 vec ); + +/* + * Get the column of a 3x3 matrix referred to by the specified index + */ +static inline VmathVector3 vmathM3GetCol_V( VmathMatrix3 mat, int col ); + +/* + * Get the row of a 3x3 matrix referred to by the specified index + */ +static inline VmathVector3 vmathM3GetRow_V( VmathMatrix3 mat, int row ); + +/* + * Set the element of a 3x3 matrix referred to by column and row indices + */ +static inline void vmathM3SetElem_V( VmathMatrix3 *result, int col, int row, float val ); + +/* + * Get the element of a 3x3 matrix referred to by column and row indices + */ +static inline float vmathM3GetElem_V( VmathMatrix3 mat, int col, int row ); + +/* + * Add two 3x3 matrices + */ +static inline VmathMatrix3 vmathM3Add_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ); + +/* + * Subtract a 3x3 matrix from another 3x3 matrix + */ +static inline VmathMatrix3 vmathM3Sub_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ); + +/* + * Negate all elements of a 3x3 matrix + */ +static inline VmathMatrix3 vmathM3Neg_V( VmathMatrix3 mat ); + +/* + * Multiply a 3x3 matrix by a scalar + */ +static inline VmathMatrix3 vmathM3ScalarMul_V( VmathMatrix3 mat, float scalar ); + +/* + * Multiply a 3x3 matrix by a 3-D vector + */ +static inline VmathVector3 vmathM3MulV3_V( VmathMatrix3 mat, VmathVector3 vec ); + +/* + * Multiply two 3x3 matrices + */ +static inline VmathMatrix3 vmathM3Mul_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ); + +/* + * Construct an identity 3x3 matrix + */ +static inline VmathMatrix3 vmathM3MakeIdentity_V( ); + +/* + * Construct a 3x3 matrix to rotate around the x axis + */ +static inline VmathMatrix3 vmathM3MakeRotationX_V( float radians ); + +/* + * Construct a 3x3 matrix to rotate around the y axis + */ +static inline VmathMatrix3 vmathM3MakeRotationY_V( float radians ); + +/* + * Construct a 3x3 matrix to rotate around the z axis + */ +static inline VmathMatrix3 vmathM3MakeRotationZ_V( float radians ); + +/* + * Construct a 3x3 matrix to rotate around the x, y, and z axes + */ +static inline VmathMatrix3 vmathM3MakeRotationZYX_V( VmathVector3 radiansXYZ ); + +/* + * Construct a 3x3 matrix to rotate around a unit-length 3-D vector + */ +static inline VmathMatrix3 vmathM3MakeRotationAxis_V( float radians, VmathVector3 unitVec ); + +/* + * Construct a rotation matrix from a unit-length quaternion + */ +static inline VmathMatrix3 vmathM3MakeRotationQ_V( VmathQuat unitQuat ); + +/* + * Construct a 3x3 matrix to perform scaling + */ +static inline VmathMatrix3 vmathM3MakeScale_V( VmathVector3 scaleVec ); + +/* + * Append (post-multiply) a scale transformation to a 3x3 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline VmathMatrix3 vmathM3AppendScale_V( VmathMatrix3 mat, VmathVector3 scaleVec ); + +/* + * Prepend (pre-multiply) a scale transformation to a 3x3 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline VmathMatrix3 vmathM3PrependScale_V( VmathVector3 scaleVec, VmathMatrix3 mat ); + +/* + * Multiply two 3x3 matrices per element + */ +static inline VmathMatrix3 vmathM3MulPerElem_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ); + +/* + * Compute the absolute value of a 3x3 matrix per element + */ +static inline VmathMatrix3 vmathM3AbsPerElem_V( VmathMatrix3 mat ); + +/* + * Transpose of a 3x3 matrix + */ +static inline VmathMatrix3 vmathM3Transpose_V( VmathMatrix3 mat ); + +/* + * Compute the inverse of a 3x3 matrix + * NOTE: + * Result is unpredictable when the determinant of mat is equal to or near 0. + */ +static inline VmathMatrix3 vmathM3Inverse_V( VmathMatrix3 mat ); + +/* + * Determinant of a 3x3 matrix + */ +static inline float vmathM3Determinant_V( VmathMatrix3 mat ); + +/* + * Conditionally select between two 3x3 matrices + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + * However, the transfer of select1 to a VMX register may use more processing time than a branch. + */ +static inline VmathMatrix3 vmathM3Select_V( VmathMatrix3 mat0, VmathMatrix3 mat1, unsigned int select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3x3 matrix + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathM3Print_V( VmathMatrix3 mat ); + +/* + * Print a 3x3 matrix and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathM3Prints_V( VmathMatrix3 mat, const char *name ); + +#endif + +/* + * Construct a 4x4 matrix containing the specified columns + */ +static inline VmathMatrix4 vmathM4MakeFromCols_V( VmathVector4 col0, VmathVector4 col1, VmathVector4 col2, VmathVector4 col3 ); + +/* + * Construct a 4x4 matrix from a 3x4 transformation matrix + */ +static inline VmathMatrix4 vmathM4MakeFromT3_V( VmathTransform3 mat ); + +/* + * Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector + */ +static inline VmathMatrix4 vmathM4MakeFromM3V3_V( VmathMatrix3 mat, VmathVector3 translateVec ); + +/* + * Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector + */ +static inline VmathMatrix4 vmathM4MakeFromQV3_V( VmathQuat unitQuat, VmathVector3 translateVec ); + +/* + * Set all elements of a 4x4 matrix to the same scalar value + */ +static inline VmathMatrix4 vmathM4MakeFromScalar_V( float scalar ); + +/* + * Set the upper-left 3x3 submatrix + * NOTE: + * This function does not change the bottom row elements. + */ +static inline void vmathM4SetUpper3x3_V( VmathMatrix4 *result, VmathMatrix3 mat3 ); + +/* + * Get the upper-left 3x3 submatrix of a 4x4 matrix + */ +static inline VmathMatrix3 vmathM4GetUpper3x3_V( VmathMatrix4 mat ); + +/* + * Set translation component + * NOTE: + * This function does not change the bottom row elements. + */ +static inline void vmathM4SetTranslation_V( VmathMatrix4 *result, VmathVector3 translateVec ); + +/* + * Get the translation component of a 4x4 matrix + */ +static inline VmathVector3 vmathM4GetTranslation_V( VmathMatrix4 mat ); + +/* + * Set column 0 of a 4x4 matrix + */ +static inline void vmathM4SetCol0_V( VmathMatrix4 *result, VmathVector4 col0 ); + +/* + * Set column 1 of a 4x4 matrix + */ +static inline void vmathM4SetCol1_V( VmathMatrix4 *result, VmathVector4 col1 ); + +/* + * Set column 2 of a 4x4 matrix + */ +static inline void vmathM4SetCol2_V( VmathMatrix4 *result, VmathVector4 col2 ); + +/* + * Set column 3 of a 4x4 matrix + */ +static inline void vmathM4SetCol3_V( VmathMatrix4 *result, VmathVector4 col3 ); + +/* + * Get column 0 of a 4x4 matrix + */ +static inline VmathVector4 vmathM4GetCol0_V( VmathMatrix4 mat ); + +/* + * Get column 1 of a 4x4 matrix + */ +static inline VmathVector4 vmathM4GetCol1_V( VmathMatrix4 mat ); + +/* + * Get column 2 of a 4x4 matrix + */ +static inline VmathVector4 vmathM4GetCol2_V( VmathMatrix4 mat ); + +/* + * Get column 3 of a 4x4 matrix + */ +static inline VmathVector4 vmathM4GetCol3_V( VmathMatrix4 mat ); + +/* + * Set the column of a 4x4 matrix referred to by the specified index + */ +static inline void vmathM4SetCol_V( VmathMatrix4 *result, int col, VmathVector4 vec ); + +/* + * Set the row of a 4x4 matrix referred to by the specified index + */ +static inline void vmathM4SetRow_V( VmathMatrix4 *result, int row, VmathVector4 vec ); + +/* + * Get the column of a 4x4 matrix referred to by the specified index + */ +static inline VmathVector4 vmathM4GetCol_V( VmathMatrix4 mat, int col ); + +/* + * Get the row of a 4x4 matrix referred to by the specified index + */ +static inline VmathVector4 vmathM4GetRow_V( VmathMatrix4 mat, int row ); + +/* + * Set the element of a 4x4 matrix referred to by column and row indices + */ +static inline void vmathM4SetElem_V( VmathMatrix4 *result, int col, int row, float val ); + +/* + * Get the element of a 4x4 matrix referred to by column and row indices + */ +static inline float vmathM4GetElem_V( VmathMatrix4 mat, int col, int row ); + +/* + * Add two 4x4 matrices + */ +static inline VmathMatrix4 vmathM4Add_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ); + +/* + * Subtract a 4x4 matrix from another 4x4 matrix + */ +static inline VmathMatrix4 vmathM4Sub_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ); + +/* + * Negate all elements of a 4x4 matrix + */ +static inline VmathMatrix4 vmathM4Neg_V( VmathMatrix4 mat ); + +/* + * Multiply a 4x4 matrix by a scalar + */ +static inline VmathMatrix4 vmathM4ScalarMul_V( VmathMatrix4 mat, float scalar ); + +/* + * Multiply a 4x4 matrix by a 4-D vector + */ +static inline VmathVector4 vmathM4MulV4_V( VmathMatrix4 mat, VmathVector4 vec ); + +/* + * Multiply a 4x4 matrix by a 3-D vector + */ +static inline VmathVector4 vmathM4MulV3_V( VmathMatrix4 mat, VmathVector3 vec ); + +/* + * Multiply a 4x4 matrix by a 3-D point + */ +static inline VmathVector4 vmathM4MulP3_V( VmathMatrix4 mat, VmathPoint3 pnt ); + +/* + * Multiply two 4x4 matrices + */ +static inline VmathMatrix4 vmathM4Mul_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ); + +/* + * Multiply a 4x4 matrix by a 3x4 transformation matrix + */ +static inline VmathMatrix4 vmathM4MulT3_V( VmathMatrix4 mat, VmathTransform3 tfrm ); + +/* + * Construct an identity 4x4 matrix + */ +static inline VmathMatrix4 vmathM4MakeIdentity_V( ); + +/* + * Construct a 4x4 matrix to rotate around the x axis + */ +static inline VmathMatrix4 vmathM4MakeRotationX_V( float radians ); + +/* + * Construct a 4x4 matrix to rotate around the y axis + */ +static inline VmathMatrix4 vmathM4MakeRotationY_V( float radians ); + +/* + * Construct a 4x4 matrix to rotate around the z axis + */ +static inline VmathMatrix4 vmathM4MakeRotationZ_V( float radians ); + +/* + * Construct a 4x4 matrix to rotate around the x, y, and z axes + */ +static inline VmathMatrix4 vmathM4MakeRotationZYX_V( VmathVector3 radiansXYZ ); + +/* + * Construct a 4x4 matrix to rotate around a unit-length 3-D vector + */ +static inline VmathMatrix4 vmathM4MakeRotationAxis_V( float radians, VmathVector3 unitVec ); + +/* + * Construct a rotation matrix from a unit-length quaternion + */ +static inline VmathMatrix4 vmathM4MakeRotationQ_V( VmathQuat unitQuat ); + +/* + * Construct a 4x4 matrix to perform scaling + */ +static inline VmathMatrix4 vmathM4MakeScale_V( VmathVector3 scaleVec ); + +/* + * Construct a 4x4 matrix to perform translation + */ +static inline VmathMatrix4 vmathM4MakeTranslation_V( VmathVector3 translateVec ); + +/* + * Construct viewing matrix based on eye position, position looked at, and up direction + */ +static inline VmathMatrix4 vmathM4MakeLookAt_V( VmathPoint3 eyePos, VmathPoint3 lookAtPos, VmathVector3 upVec ); + +/* + * Construct a perspective projection matrix + */ +static inline VmathMatrix4 vmathM4MakePerspective_V( float fovyRadians, float aspect, float zNear, float zFar ); + +/* + * Construct a perspective projection matrix based on frustum + */ +static inline VmathMatrix4 vmathM4MakeFrustum_V( float left, float right, float bottom, float top, float zNear, float zFar ); + +/* + * Construct an orthographic projection matrix + */ +static inline VmathMatrix4 vmathM4MakeOrthographic_V( float left, float right, float bottom, float top, float zNear, float zFar ); + +/* + * Append (post-multiply) a scale transformation to a 4x4 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline VmathMatrix4 vmathM4AppendScale_V( VmathMatrix4 mat, VmathVector3 scaleVec ); + +/* + * Prepend (pre-multiply) a scale transformation to a 4x4 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline VmathMatrix4 vmathM4PrependScale_V( VmathVector3 scaleVec, VmathMatrix4 mat ); + +/* + * Multiply two 4x4 matrices per element + */ +static inline VmathMatrix4 vmathM4MulPerElem_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ); + +/* + * Compute the absolute value of a 4x4 matrix per element + */ +static inline VmathMatrix4 vmathM4AbsPerElem_V( VmathMatrix4 mat ); + +/* + * Transpose of a 4x4 matrix + */ +static inline VmathMatrix4 vmathM4Transpose_V( VmathMatrix4 mat ); + +/* + * Compute the inverse of a 4x4 matrix + * NOTE: + * Result is unpredictable when the determinant of mat is equal to or near 0. + */ +static inline VmathMatrix4 vmathM4Inverse_V( VmathMatrix4 mat ); + +/* + * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix + * NOTE: + * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. The result is unpredictable when the determinant of mat is equal to or near 0. + */ +static inline VmathMatrix4 vmathM4AffineInverse_V( VmathMatrix4 mat ); + +/* + * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix + * NOTE: + * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. + */ +static inline VmathMatrix4 vmathM4OrthoInverse_V( VmathMatrix4 mat ); + +/* + * Determinant of a 4x4 matrix + */ +static inline float vmathM4Determinant_V( VmathMatrix4 mat ); + +/* + * Conditionally select between two 4x4 matrices + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + * However, the transfer of select1 to a VMX register may use more processing time than a branch. + */ +static inline VmathMatrix4 vmathM4Select_V( VmathMatrix4 mat0, VmathMatrix4 mat1, unsigned int select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 4x4 matrix + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathM4Print_V( VmathMatrix4 mat ); + +/* + * Print a 4x4 matrix and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathM4Prints_V( VmathMatrix4 mat, const char *name ); + +#endif + +/* + * Construct a 3x4 transformation matrix containing the specified columns + */ +static inline VmathTransform3 vmathT3MakeFromCols_V( VmathVector3 col0, VmathVector3 col1, VmathVector3 col2, VmathVector3 col3 ); + +/* + * Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector + */ +static inline VmathTransform3 vmathT3MakeFromM3V3_V( VmathMatrix3 tfrm, VmathVector3 translateVec ); + +/* + * Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector + */ +static inline VmathTransform3 vmathT3MakeFromQV3_V( VmathQuat unitQuat, VmathVector3 translateVec ); + +/* + * Set all elements of a 3x4 transformation matrix to the same scalar value + */ +static inline VmathTransform3 vmathT3MakeFromScalar_V( float scalar ); + +/* + * Set the upper-left 3x3 submatrix + */ +static inline void vmathT3SetUpper3x3_V( VmathTransform3 *result, VmathMatrix3 mat3 ); + +/* + * Get the upper-left 3x3 submatrix of a 3x4 transformation matrix + */ +static inline VmathMatrix3 vmathT3GetUpper3x3_V( VmathTransform3 tfrm ); + +/* + * Set translation component + */ +static inline void vmathT3SetTranslation_V( VmathTransform3 *result, VmathVector3 translateVec ); + +/* + * Get the translation component of a 3x4 transformation matrix + */ +static inline VmathVector3 vmathT3GetTranslation_V( VmathTransform3 tfrm ); + +/* + * Set column 0 of a 3x4 transformation matrix + */ +static inline void vmathT3SetCol0_V( VmathTransform3 *result, VmathVector3 col0 ); + +/* + * Set column 1 of a 3x4 transformation matrix + */ +static inline void vmathT3SetCol1_V( VmathTransform3 *result, VmathVector3 col1 ); + +/* + * Set column 2 of a 3x4 transformation matrix + */ +static inline void vmathT3SetCol2_V( VmathTransform3 *result, VmathVector3 col2 ); + +/* + * Set column 3 of a 3x4 transformation matrix + */ +static inline void vmathT3SetCol3_V( VmathTransform3 *result, VmathVector3 col3 ); + +/* + * Get column 0 of a 3x4 transformation matrix + */ +static inline VmathVector3 vmathT3GetCol0_V( VmathTransform3 tfrm ); + +/* + * Get column 1 of a 3x4 transformation matrix + */ +static inline VmathVector3 vmathT3GetCol1_V( VmathTransform3 tfrm ); + +/* + * Get column 2 of a 3x4 transformation matrix + */ +static inline VmathVector3 vmathT3GetCol2_V( VmathTransform3 tfrm ); + +/* + * Get column 3 of a 3x4 transformation matrix + */ +static inline VmathVector3 vmathT3GetCol3_V( VmathTransform3 tfrm ); + +/* + * Set the column of a 3x4 transformation matrix referred to by the specified index + */ +static inline void vmathT3SetCol_V( VmathTransform3 *result, int col, VmathVector3 vec ); + +/* + * Set the row of a 3x4 transformation matrix referred to by the specified index + */ +static inline void vmathT3SetRow_V( VmathTransform3 *result, int row, VmathVector4 vec ); + +/* + * Get the column of a 3x4 transformation matrix referred to by the specified index + */ +static inline VmathVector3 vmathT3GetCol_V( VmathTransform3 tfrm, int col ); + +/* + * Get the row of a 3x4 transformation matrix referred to by the specified index + */ +static inline VmathVector4 vmathT3GetRow_V( VmathTransform3 tfrm, int row ); + +/* + * Set the element of a 3x4 transformation matrix referred to by column and row indices + */ +static inline void vmathT3SetElem_V( VmathTransform3 *result, int col, int row, float val ); + +/* + * Get the element of a 3x4 transformation matrix referred to by column and row indices + */ +static inline float vmathT3GetElem_V( VmathTransform3 tfrm, int col, int row ); + +/* + * Multiply a 3x4 transformation matrix by a 3-D vector + */ +static inline VmathVector3 vmathT3MulV3_V( VmathTransform3 tfrm, VmathVector3 vec ); + +/* + * Multiply a 3x4 transformation matrix by a 3-D point + */ +static inline VmathPoint3 vmathT3MulP3_V( VmathTransform3 tfrm, VmathPoint3 pnt ); + +/* + * Multiply two 3x4 transformation matrices + */ +static inline VmathTransform3 vmathT3Mul_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1 ); + +/* + * Construct an identity 3x4 transformation matrix + */ +static inline VmathTransform3 vmathT3MakeIdentity_V( ); + +/* + * Construct a 3x4 transformation matrix to rotate around the x axis + */ +static inline VmathTransform3 vmathT3MakeRotationX_V( float radians ); + +/* + * Construct a 3x4 transformation matrix to rotate around the y axis + */ +static inline VmathTransform3 vmathT3MakeRotationY_V( float radians ); + +/* + * Construct a 3x4 transformation matrix to rotate around the z axis + */ +static inline VmathTransform3 vmathT3MakeRotationZ_V( float radians ); + +/* + * Construct a 3x4 transformation matrix to rotate around the x, y, and z axes + */ +static inline VmathTransform3 vmathT3MakeRotationZYX_V( VmathVector3 radiansXYZ ); + +/* + * Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector + */ +static inline VmathTransform3 vmathT3MakeRotationAxis_V( float radians, VmathVector3 unitVec ); + +/* + * Construct a rotation matrix from a unit-length quaternion + */ +static inline VmathTransform3 vmathT3MakeRotationQ_V( VmathQuat unitQuat ); + +/* + * Construct a 3x4 transformation matrix to perform scaling + */ +static inline VmathTransform3 vmathT3MakeScale_V( VmathVector3 scaleVec ); + +/* + * Construct a 3x4 transformation matrix to perform translation + */ +static inline VmathTransform3 vmathT3MakeTranslation_V( VmathVector3 translateVec ); + +/* + * Append (post-multiply) a scale transformation to a 3x4 transformation matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline VmathTransform3 vmathT3AppendScale_V( VmathTransform3 tfrm, VmathVector3 scaleVec ); + +/* + * Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline VmathTransform3 vmathT3PrependScale_V( VmathVector3 scaleVec, VmathTransform3 tfrm ); + +/* + * Multiply two 3x4 transformation matrices per element + */ +static inline VmathTransform3 vmathT3MulPerElem_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1 ); + +/* + * Compute the absolute value of a 3x4 transformation matrix per element + */ +static inline VmathTransform3 vmathT3AbsPerElem_V( VmathTransform3 tfrm ); + +/* + * Inverse of a 3x4 transformation matrix + * NOTE: + * Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0. + */ +static inline VmathTransform3 vmathT3Inverse_V( VmathTransform3 tfrm ); + +/* + * Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix + * NOTE: + * This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions. + */ +static inline VmathTransform3 vmathT3OrthoInverse_V( VmathTransform3 tfrm ); + +/* + * Conditionally select between two 3x4 transformation matrices + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + * However, the transfer of select1 to a VMX register may use more processing time than a branch. + */ +static inline VmathTransform3 vmathT3Select_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1, unsigned int select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3x4 transformation matrix + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathT3Print_V( VmathTransform3 tfrm ); + +/* + * Print a 3x4 transformation matrix and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathT3Prints_V( VmathTransform3 tfrm, const char *name ); + +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include "vectormath_aos.h" +#include "vec_aos_v.h" +#include "quat_aos_v.h" +#include "mat_aos_v.h" + +#endif diff --git a/vectormathlibrary/include/vectormath/ppu/c/vectormath_soa.h b/vectormathlibrary/include/vectormath/ppu/c/vectormath_soa.h new file mode 100644 index 000000000..0188dcb3a --- /dev/null +++ b/vectormathlibrary/include/vectormath/ppu/c/vectormath_soa.h @@ -0,0 +1,2013 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_SOA_C_PPU_H +#define _VECTORMATH_SOA_C_PPU_H + +#include <math.h> +#include <altivec.h> +#include "vectormath_aos.h" + +#ifdef _VECTORMATH_DEBUG +#include <stdio.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#ifndef _VECTORMATH_SOA_C_TYPES_H +#define _VECTORMATH_SOA_C_TYPES_H + +/* A set of four 3-D vectors in structure-of-arrays format + */ +typedef struct _VmathSoaVector3 +{ + vec_float4 x; + vec_float4 y; + vec_float4 z; +} VmathSoaVector3; + +/* A set of four 4-D vectors in structure-of-arrays format + */ +typedef struct _VmathSoaVector4 +{ + vec_float4 x; + vec_float4 y; + vec_float4 z; + vec_float4 w; +} VmathSoaVector4; + +/* A set of four 3-D points in structure-of-arrays format + */ +typedef struct _VmathSoaPoint3 +{ + vec_float4 x; + vec_float4 y; + vec_float4 z; +} VmathSoaPoint3; + +/* A set of four quaternions in structure-of-arrays format + */ +typedef struct _VmathSoaQuat +{ + vec_float4 x; + vec_float4 y; + vec_float4 z; + vec_float4 w; +} VmathSoaQuat; + +/* A set of four 3x3 matrices in structure-of-arrays format + */ +typedef struct _VmathSoaMatrix3 +{ + VmathSoaVector3 col0; + VmathSoaVector3 col1; + VmathSoaVector3 col2; +} VmathSoaMatrix3; + +/* A set of four 4x4 matrices in structure-of-arrays format + */ +typedef struct _VmathSoaMatrix4 +{ + VmathSoaVector4 col0; + VmathSoaVector4 col1; + VmathSoaVector4 col2; + VmathSoaVector4 col3; +} VmathSoaMatrix4; + +/* A set of four 3x4 transformation matrices in structure-of-arrays format + */ +typedef struct _VmathSoaTransform3 +{ + VmathSoaVector3 col0; + VmathSoaVector3 col1; + VmathSoaVector3 col2; + VmathSoaVector3 col3; +} VmathSoaTransform3; + +#endif + +/* + * Copy a 3-D vector + */ +static inline void vmathSoaV3Copy( VmathSoaVector3 *result, const VmathSoaVector3 *vec ); + +/* + * Construct a 3-D vector from x, y, and z elements + */ +static inline void vmathSoaV3MakeFromElems( VmathSoaVector3 *result, vec_float4 x, vec_float4 y, vec_float4 z ); + +/* + * Copy elements from a 3-D point into a 3-D vector + */ +static inline void vmathSoaV3MakeFromP3( VmathSoaVector3 *result, const VmathSoaPoint3 *pnt ); + +/* + * Set all elements of a 3-D vector to the same scalar value + */ +static inline void vmathSoaV3MakeFromScalar( VmathSoaVector3 *result, vec_float4 scalar ); + +/* + * Replicate an AoS 3-D vector + */ +static inline void vmathSoaV3MakeFromAos( VmathSoaVector3 *result, const VmathVector3 *vec ); + +/* + * Insert four AoS 3-D vectors + */ +static inline void vmathSoaV3MakeFrom4Aos( VmathSoaVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1, const VmathVector3 *vec2, const VmathVector3 *vec3 ); + +/* + * Extract four AoS 3-D vectors + */ +static inline void vmathSoaV3Get4Aos( const VmathSoaVector3 *vec, VmathVector3 *result0, VmathVector3 *result1, VmathVector3 *result2, VmathVector3 *result3 ); + +/* + * Set the x element of a 3-D vector + */ +static inline void vmathSoaV3SetX( VmathSoaVector3 *result, vec_float4 x ); + +/* + * Set the y element of a 3-D vector + */ +static inline void vmathSoaV3SetY( VmathSoaVector3 *result, vec_float4 y ); + +/* + * Set the z element of a 3-D vector + */ +static inline void vmathSoaV3SetZ( VmathSoaVector3 *result, vec_float4 z ); + +/* + * Get the x element of a 3-D vector + */ +static inline vec_float4 vmathSoaV3GetX( const VmathSoaVector3 *vec ); + +/* + * Get the y element of a 3-D vector + */ +static inline vec_float4 vmathSoaV3GetY( const VmathSoaVector3 *vec ); + +/* + * Get the z element of a 3-D vector + */ +static inline vec_float4 vmathSoaV3GetZ( const VmathSoaVector3 *vec ); + +/* + * Set an x, y, or z element of a 3-D vector by index + */ +static inline void vmathSoaV3SetElem( VmathSoaVector3 *result, int idx, vec_float4 value ); + +/* + * Get an x, y, or z element of a 3-D vector by index + */ +static inline vec_float4 vmathSoaV3GetElem( const VmathSoaVector3 *vec, int idx ); + +/* + * Add two 3-D vectors + */ +static inline void vmathSoaV3Add( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); + +/* + * Subtract a 3-D vector from another 3-D vector + */ +static inline void vmathSoaV3Sub( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); + +/* + * Add a 3-D vector to a 3-D point + */ +static inline void vmathSoaV3AddP3( VmathSoaPoint3 *result, const VmathSoaVector3 *vec, const VmathSoaPoint3 *pnt ); + +/* + * Multiply a 3-D vector by a scalar + */ +static inline void vmathSoaV3ScalarMul( VmathSoaVector3 *result, const VmathSoaVector3 *vec, vec_float4 scalar ); + +/* + * Divide a 3-D vector by a scalar + */ +static inline void vmathSoaV3ScalarDiv( VmathSoaVector3 *result, const VmathSoaVector3 *vec, vec_float4 scalar ); + +/* + * Negate all elements of a 3-D vector + */ +static inline void vmathSoaV3Neg( VmathSoaVector3 *result, const VmathSoaVector3 *vec ); + +/* + * Construct x axis + */ +static inline void vmathSoaV3MakeXAxis( VmathSoaVector3 *result ); + +/* + * Construct y axis + */ +static inline void vmathSoaV3MakeYAxis( VmathSoaVector3 *result ); + +/* + * Construct z axis + */ +static inline void vmathSoaV3MakeZAxis( VmathSoaVector3 *result ); + +/* + * Multiply two 3-D vectors per element + */ +static inline void vmathSoaV3MulPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); + +/* + * Divide two 3-D vectors per element + * NOTE: + * Floating-point behavior matches standard library function divf4. + */ +static inline void vmathSoaV3DivPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); + +/* + * Compute the reciprocal of a 3-D vector per element + * NOTE: + * Floating-point behavior matches standard library function recipf4. + */ +static inline void vmathSoaV3RecipPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec ); + +/* + * Compute the square root of a 3-D vector per element + * NOTE: + * Floating-point behavior matches standard library function sqrtf4. + */ +static inline void vmathSoaV3SqrtPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec ); + +/* + * Compute the reciprocal square root of a 3-D vector per element + * NOTE: + * Floating-point behavior matches standard library function rsqrtf4. + */ +static inline void vmathSoaV3RsqrtPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec ); + +/* + * Compute the absolute value of a 3-D vector per element + */ +static inline void vmathSoaV3AbsPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec ); + +/* + * Copy sign from one 3-D vector to another, per element + */ +static inline void vmathSoaV3CopySignPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); + +/* + * Maximum of two 3-D vectors per element + */ +static inline void vmathSoaV3MaxPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); + +/* + * Minimum of two 3-D vectors per element + */ +static inline void vmathSoaV3MinPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); + +/* + * Maximum element of a 3-D vector + */ +static inline vec_float4 vmathSoaV3MaxElem( const VmathSoaVector3 *vec ); + +/* + * Minimum element of a 3-D vector + */ +static inline vec_float4 vmathSoaV3MinElem( const VmathSoaVector3 *vec ); + +/* + * Compute the sum of all elements of a 3-D vector + */ +static inline vec_float4 vmathSoaV3Sum( const VmathSoaVector3 *vec ); + +/* + * Compute the dot product of two 3-D vectors + */ +static inline vec_float4 vmathSoaV3Dot( const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); + +/* + * Compute the square of the length of a 3-D vector + */ +static inline vec_float4 vmathSoaV3LengthSqr( const VmathSoaVector3 *vec ); + +/* + * Compute the length of a 3-D vector + */ +static inline vec_float4 vmathSoaV3Length( const VmathSoaVector3 *vec ); + +/* + * Normalize a 3-D vector + * NOTE: + * The result is unpredictable when all elements of vec are at or near zero. + */ +static inline void vmathSoaV3Normalize( VmathSoaVector3 *result, const VmathSoaVector3 *vec ); + +/* + * Compute cross product of two 3-D vectors + */ +static inline void vmathSoaV3Cross( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); + +/* + * Outer product of two 3-D vectors + */ +static inline void vmathSoaV3Outer( VmathSoaMatrix3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); + +/* + * Pre-multiply a row vector by a 3x3 matrix + */ +static inline void vmathSoaV3RowMul( VmathSoaVector3 *result, const VmathSoaVector3 *vec, const VmathSoaMatrix3 *mat ); + +/* + * Cross-product matrix of a 3-D vector + */ +static inline void vmathSoaV3CrossMatrix( VmathSoaMatrix3 *result, const VmathSoaVector3 *vec ); + +/* + * Create cross-product matrix and multiply + * NOTE: + * Faster than separately creating a cross-product matrix and multiplying. + */ +static inline void vmathSoaV3CrossMatrixMul( VmathSoaMatrix3 *result, const VmathSoaVector3 *vec, const VmathSoaMatrix3 *mat ); + +/* + * Linear interpolation between two 3-D vectors + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline void vmathSoaV3Lerp( VmathSoaVector3 *result, vec_float4 t, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); + +/* + * Spherical linear interpolation between two 3-D vectors + * NOTE: + * The result is unpredictable if the vectors point in opposite directions. + * Does not clamp t between 0 and 1. + */ +static inline void vmathSoaV3Slerp( VmathSoaVector3 *result, vec_float4 t, const VmathSoaVector3 *unitVec0, const VmathSoaVector3 *unitVec1 ); + +/* + * Conditionally select between two 3-D vectors + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline void vmathSoaV3Select( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1, vec_uint4 select1 ); + +/* + * Load four three-float 3-D vectors, stored in three quadwords + */ +static inline void vmathSoaV3LoadXYZArray( VmathSoaVector3 *vec, const vec_float4 *threeQuads ); + +/* + * Store four slots of an SoA 3-D vector in three quadwords + */ +static inline void vmathSoaV3StoreXYZArray( const VmathSoaVector3 *vec, vec_float4 *threeQuads ); + +/* + * Store eight slots of two SoA 3-D vectors as half-floats + */ +static inline void vmathSoaV3StoreHalfFloats( const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1, vec_ushort8 *threeQuads ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3-D vector + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaV3Print( const VmathSoaVector3 *vec ); + +/* + * Print a 3-D vector and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaV3Prints( const VmathSoaVector3 *vec, const char *name ); + +#endif + +/* + * Copy a 4-D vector + */ +static inline void vmathSoaV4Copy( VmathSoaVector4 *result, const VmathSoaVector4 *vec ); + +/* + * Construct a 4-D vector from x, y, z, and w elements + */ +static inline void vmathSoaV4MakeFromElems( VmathSoaVector4 *result, vec_float4 x, vec_float4 y, vec_float4 z, vec_float4 w ); + +/* + * Construct a 4-D vector from a 3-D vector and a scalar + */ +static inline void vmathSoaV4MakeFromV3Scalar( VmathSoaVector4 *result, const VmathSoaVector3 *xyz, vec_float4 w ); + +/* + * Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0 + */ +static inline void vmathSoaV4MakeFromV3( VmathSoaVector4 *result, const VmathSoaVector3 *vec ); + +/* + * Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1 + */ +static inline void vmathSoaV4MakeFromP3( VmathSoaVector4 *result, const VmathSoaPoint3 *pnt ); + +/* + * Copy elements from a quaternion into a 4-D vector + */ +static inline void vmathSoaV4MakeFromQ( VmathSoaVector4 *result, const VmathSoaQuat *quat ); + +/* + * Set all elements of a 4-D vector to the same scalar value + */ +static inline void vmathSoaV4MakeFromScalar( VmathSoaVector4 *result, vec_float4 scalar ); + +/* + * Replicate an AoS 4-D vector + */ +static inline void vmathSoaV4MakeFromAos( VmathSoaVector4 *result, const VmathVector4 *vec ); + +/* + * Insert four AoS 4-D vectors + */ +static inline void vmathSoaV4MakeFrom4Aos( VmathSoaVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1, const VmathVector4 *vec2, const VmathVector4 *vec3 ); + +/* + * Extract four AoS 4-D vectors + */ +static inline void vmathSoaV4Get4Aos( const VmathSoaVector4 *vec, VmathVector4 *result0, VmathVector4 *result1, VmathVector4 *result2, VmathVector4 *result3 ); + +/* + * Set the x, y, and z elements of a 4-D vector + * NOTE: + * This function does not change the w element. + */ +static inline void vmathSoaV4SetXYZ( VmathSoaVector4 *result, const VmathSoaVector3 *vec ); + +/* + * Get the x, y, and z elements of a 4-D vector + */ +static inline void vmathSoaV4GetXYZ( VmathSoaVector3 *result, const VmathSoaVector4 *vec ); + +/* + * Set the x element of a 4-D vector + */ +static inline void vmathSoaV4SetX( VmathSoaVector4 *result, vec_float4 x ); + +/* + * Set the y element of a 4-D vector + */ +static inline void vmathSoaV4SetY( VmathSoaVector4 *result, vec_float4 y ); + +/* + * Set the z element of a 4-D vector + */ +static inline void vmathSoaV4SetZ( VmathSoaVector4 *result, vec_float4 z ); + +/* + * Set the w element of a 4-D vector + */ +static inline void vmathSoaV4SetW( VmathSoaVector4 *result, vec_float4 w ); + +/* + * Get the x element of a 4-D vector + */ +static inline vec_float4 vmathSoaV4GetX( const VmathSoaVector4 *vec ); + +/* + * Get the y element of a 4-D vector + */ +static inline vec_float4 vmathSoaV4GetY( const VmathSoaVector4 *vec ); + +/* + * Get the z element of a 4-D vector + */ +static inline vec_float4 vmathSoaV4GetZ( const VmathSoaVector4 *vec ); + +/* + * Get the w element of a 4-D vector + */ +static inline vec_float4 vmathSoaV4GetW( const VmathSoaVector4 *vec ); + +/* + * Set an x, y, z, or w element of a 4-D vector by index + */ +static inline void vmathSoaV4SetElem( VmathSoaVector4 *result, int idx, vec_float4 value ); + +/* + * Get an x, y, z, or w element of a 4-D vector by index + */ +static inline vec_float4 vmathSoaV4GetElem( const VmathSoaVector4 *vec, int idx ); + +/* + * Add two 4-D vectors + */ +static inline void vmathSoaV4Add( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); + +/* + * Subtract a 4-D vector from another 4-D vector + */ +static inline void vmathSoaV4Sub( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); + +/* + * Multiply a 4-D vector by a scalar + */ +static inline void vmathSoaV4ScalarMul( VmathSoaVector4 *result, const VmathSoaVector4 *vec, vec_float4 scalar ); + +/* + * Divide a 4-D vector by a scalar + */ +static inline void vmathSoaV4ScalarDiv( VmathSoaVector4 *result, const VmathSoaVector4 *vec, vec_float4 scalar ); + +/* + * Negate all elements of a 4-D vector + */ +static inline void vmathSoaV4Neg( VmathSoaVector4 *result, const VmathSoaVector4 *vec ); + +/* + * Construct x axis + */ +static inline void vmathSoaV4MakeXAxis( VmathSoaVector4 *result ); + +/* + * Construct y axis + */ +static inline void vmathSoaV4MakeYAxis( VmathSoaVector4 *result ); + +/* + * Construct z axis + */ +static inline void vmathSoaV4MakeZAxis( VmathSoaVector4 *result ); + +/* + * Construct w axis + */ +static inline void vmathSoaV4MakeWAxis( VmathSoaVector4 *result ); + +/* + * Multiply two 4-D vectors per element + */ +static inline void vmathSoaV4MulPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); + +/* + * Divide two 4-D vectors per element + * NOTE: + * Floating-point behavior matches standard library function divf4. + */ +static inline void vmathSoaV4DivPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); + +/* + * Compute the reciprocal of a 4-D vector per element + * NOTE: + * Floating-point behavior matches standard library function recipf4. + */ +static inline void vmathSoaV4RecipPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec ); + +/* + * Compute the square root of a 4-D vector per element + * NOTE: + * Floating-point behavior matches standard library function sqrtf4. + */ +static inline void vmathSoaV4SqrtPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec ); + +/* + * Compute the reciprocal square root of a 4-D vector per element + * NOTE: + * Floating-point behavior matches standard library function rsqrtf4. + */ +static inline void vmathSoaV4RsqrtPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec ); + +/* + * Compute the absolute value of a 4-D vector per element + */ +static inline void vmathSoaV4AbsPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec ); + +/* + * Copy sign from one 4-D vector to another, per element + */ +static inline void vmathSoaV4CopySignPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); + +/* + * Maximum of two 4-D vectors per element + */ +static inline void vmathSoaV4MaxPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); + +/* + * Minimum of two 4-D vectors per element + */ +static inline void vmathSoaV4MinPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); + +/* + * Maximum element of a 4-D vector + */ +static inline vec_float4 vmathSoaV4MaxElem( const VmathSoaVector4 *vec ); + +/* + * Minimum element of a 4-D vector + */ +static inline vec_float4 vmathSoaV4MinElem( const VmathSoaVector4 *vec ); + +/* + * Compute the sum of all elements of a 4-D vector + */ +static inline vec_float4 vmathSoaV4Sum( const VmathSoaVector4 *vec ); + +/* + * Compute the dot product of two 4-D vectors + */ +static inline vec_float4 vmathSoaV4Dot( const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); + +/* + * Compute the square of the length of a 4-D vector + */ +static inline vec_float4 vmathSoaV4LengthSqr( const VmathSoaVector4 *vec ); + +/* + * Compute the length of a 4-D vector + */ +static inline vec_float4 vmathSoaV4Length( const VmathSoaVector4 *vec ); + +/* + * Normalize a 4-D vector + * NOTE: + * The result is unpredictable when all elements of vec are at or near zero. + */ +static inline void vmathSoaV4Normalize( VmathSoaVector4 *result, const VmathSoaVector4 *vec ); + +/* + * Outer product of two 4-D vectors + */ +static inline void vmathSoaV4Outer( VmathSoaMatrix4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); + +/* + * Linear interpolation between two 4-D vectors + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline void vmathSoaV4Lerp( VmathSoaVector4 *result, vec_float4 t, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); + +/* + * Spherical linear interpolation between two 4-D vectors + * NOTE: + * The result is unpredictable if the vectors point in opposite directions. + * Does not clamp t between 0 and 1. + */ +static inline void vmathSoaV4Slerp( VmathSoaVector4 *result, vec_float4 t, const VmathSoaVector4 *unitVec0, const VmathSoaVector4 *unitVec1 ); + +/* + * Conditionally select between two 4-D vectors + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline void vmathSoaV4Select( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1, vec_uint4 select1 ); + +/* + * Store four slots of an SoA 4-D vector as half-floats + */ +static inline void vmathSoaV4StoreHalfFloats( const VmathSoaVector4 *vec, vec_ushort8 *twoQuads ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 4-D vector + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaV4Print( const VmathSoaVector4 *vec ); + +/* + * Print a 4-D vector and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaV4Prints( const VmathSoaVector4 *vec, const char *name ); + +#endif + +/* + * Copy a 3-D point + */ +static inline void vmathSoaP3Copy( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ); + +/* + * Construct a 3-D point from x, y, and z elements + */ +static inline void vmathSoaP3MakeFromElems( VmathSoaPoint3 *result, vec_float4 x, vec_float4 y, vec_float4 z ); + +/* + * Copy elements from a 3-D vector into a 3-D point + */ +static inline void vmathSoaP3MakeFromV3( VmathSoaPoint3 *result, const VmathSoaVector3 *vec ); + +/* + * Set all elements of a 3-D point to the same scalar value + */ +static inline void vmathSoaP3MakeFromScalar( VmathSoaPoint3 *result, vec_float4 scalar ); + +/* + * Replicate an AoS 3-D point + */ +static inline void vmathSoaP3MakeFromAos( VmathSoaPoint3 *result, const VmathPoint3 *pnt ); + +/* + * Insert four AoS 3-D points + */ +static inline void vmathSoaP3MakeFrom4Aos( VmathSoaPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, const VmathPoint3 *pnt2, const VmathPoint3 *pnt3 ); + +/* + * Extract four AoS 3-D points + */ +static inline void vmathSoaP3Get4Aos( const VmathSoaPoint3 *pnt, VmathPoint3 *result0, VmathPoint3 *result1, VmathPoint3 *result2, VmathPoint3 *result3 ); + +/* + * Set the x element of a 3-D point + */ +static inline void vmathSoaP3SetX( VmathSoaPoint3 *result, vec_float4 x ); + +/* + * Set the y element of a 3-D point + */ +static inline void vmathSoaP3SetY( VmathSoaPoint3 *result, vec_float4 y ); + +/* + * Set the z element of a 3-D point + */ +static inline void vmathSoaP3SetZ( VmathSoaPoint3 *result, vec_float4 z ); + +/* + * Get the x element of a 3-D point + */ +static inline vec_float4 vmathSoaP3GetX( const VmathSoaPoint3 *pnt ); + +/* + * Get the y element of a 3-D point + */ +static inline vec_float4 vmathSoaP3GetY( const VmathSoaPoint3 *pnt ); + +/* + * Get the z element of a 3-D point + */ +static inline vec_float4 vmathSoaP3GetZ( const VmathSoaPoint3 *pnt ); + +/* + * Set an x, y, or z element of a 3-D point by index + */ +static inline void vmathSoaP3SetElem( VmathSoaPoint3 *result, int idx, vec_float4 value ); + +/* + * Get an x, y, or z element of a 3-D point by index + */ +static inline vec_float4 vmathSoaP3GetElem( const VmathSoaPoint3 *pnt, int idx ); + +/* + * Subtract a 3-D point from another 3-D point + */ +static inline void vmathSoaP3Sub( VmathSoaVector3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ); + +/* + * Add a 3-D point to a 3-D vector + */ +static inline void vmathSoaP3AddV3( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt, const VmathSoaVector3 *vec ); + +/* + * Subtract a 3-D vector from a 3-D point + */ +static inline void vmathSoaP3SubV3( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt, const VmathSoaVector3 *vec ); + +/* + * Multiply two 3-D points per element + */ +static inline void vmathSoaP3MulPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ); + +/* + * Divide two 3-D points per element + * NOTE: + * Floating-point behavior matches standard library function divf4. + */ +static inline void vmathSoaP3DivPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ); + +/* + * Compute the reciprocal of a 3-D point per element + * NOTE: + * Floating-point behavior matches standard library function recipf4. + */ +static inline void vmathSoaP3RecipPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ); + +/* + * Compute the square root of a 3-D point per element + * NOTE: + * Floating-point behavior matches standard library function sqrtf4. + */ +static inline void vmathSoaP3SqrtPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ); + +/* + * Compute the reciprocal square root of a 3-D point per element + * NOTE: + * Floating-point behavior matches standard library function rsqrtf4. + */ +static inline void vmathSoaP3RsqrtPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ); + +/* + * Compute the absolute value of a 3-D point per element + */ +static inline void vmathSoaP3AbsPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ); + +/* + * Copy sign from one 3-D point to another, per element + */ +static inline void vmathSoaP3CopySignPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ); + +/* + * Maximum of two 3-D points per element + */ +static inline void vmathSoaP3MaxPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ); + +/* + * Minimum of two 3-D points per element + */ +static inline void vmathSoaP3MinPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ); + +/* + * Maximum element of a 3-D point + */ +static inline vec_float4 vmathSoaP3MaxElem( const VmathSoaPoint3 *pnt ); + +/* + * Minimum element of a 3-D point + */ +static inline vec_float4 vmathSoaP3MinElem( const VmathSoaPoint3 *pnt ); + +/* + * Compute the sum of all elements of a 3-D point + */ +static inline vec_float4 vmathSoaP3Sum( const VmathSoaPoint3 *pnt ); + +/* + * Apply uniform scale to a 3-D point + */ +static inline void vmathSoaP3Scale( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt, vec_float4 scaleVal ); + +/* + * Apply non-uniform scale to a 3-D point + */ +static inline void vmathSoaP3NonUniformScale( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt, const VmathSoaVector3 *scaleVec ); + +/* + * Scalar projection of a 3-D point on a unit-length 3-D vector + */ +static inline vec_float4 vmathSoaP3Projection( const VmathSoaPoint3 *pnt, const VmathSoaVector3 *unitVec ); + +/* + * Compute the square of the distance of a 3-D point from the coordinate-system origin + */ +static inline vec_float4 vmathSoaP3DistSqrFromOrigin( const VmathSoaPoint3 *pnt ); + +/* + * Compute the distance of a 3-D point from the coordinate-system origin + */ +static inline vec_float4 vmathSoaP3DistFromOrigin( const VmathSoaPoint3 *pnt ); + +/* + * Compute the square of the distance between two 3-D points + */ +static inline vec_float4 vmathSoaP3DistSqr( const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ); + +/* + * Compute the distance between two 3-D points + */ +static inline vec_float4 vmathSoaP3Dist( const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ); + +/* + * Linear interpolation between two 3-D points + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline void vmathSoaP3Lerp( VmathSoaPoint3 *result, vec_float4 t, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ); + +/* + * Conditionally select between two 3-D points + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline void vmathSoaP3Select( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1, vec_uint4 select1 ); + +/* + * Load four three-float 3-D points, stored in three quadwords + */ +static inline void vmathSoaP3LoadXYZArray( VmathSoaPoint3 *pnt, const vec_float4 *threeQuads ); + +/* + * Store four slots of an SoA 3-D point in three quadwords + */ +static inline void vmathSoaP3StoreXYZArray( const VmathSoaPoint3 *pnt, vec_float4 *threeQuads ); + +/* + * Store eight slots of two SoA 3-D points as half-floats + */ +static inline void vmathSoaP3StoreHalfFloats( const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1, vec_ushort8 *threeQuads ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3-D point + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaP3Print( const VmathSoaPoint3 *pnt ); + +/* + * Print a 3-D point and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaP3Prints( const VmathSoaPoint3 *pnt, const char *name ); + +#endif + +/* + * Copy a quaternion + */ +static inline void vmathSoaQCopy( VmathSoaQuat *result, const VmathSoaQuat *quat ); + +/* + * Construct a quaternion from x, y, z, and w elements + */ +static inline void vmathSoaQMakeFromElems( VmathSoaQuat *result, vec_float4 x, vec_float4 y, vec_float4 z, vec_float4 w ); + +/* + * Construct a quaternion from a 3-D vector and a scalar + */ +static inline void vmathSoaQMakeFromV3Scalar( VmathSoaQuat *result, const VmathSoaVector3 *xyz, vec_float4 w ); + +/* + * Copy elements from a 4-D vector into a quaternion + */ +static inline void vmathSoaQMakeFromV4( VmathSoaQuat *result, const VmathSoaVector4 *vec ); + +/* + * Convert a rotation matrix to a unit-length quaternion + */ +static inline void vmathSoaQMakeFromM3( VmathSoaQuat *result, const VmathSoaMatrix3 *rotMat ); + +/* + * Set all elements of a quaternion to the same scalar value + */ +static inline void vmathSoaQMakeFromScalar( VmathSoaQuat *result, vec_float4 scalar ); + +/* + * Replicate an AoS quaternion + */ +static inline void vmathSoaQMakeFromAos( VmathSoaQuat *result, const VmathQuat *quat ); + +/* + * Insert four AoS quaternions + */ +static inline void vmathSoaQMakeFrom4Aos( VmathSoaQuat *result, const VmathQuat *quat0, const VmathQuat *quat1, const VmathQuat *quat2, const VmathQuat *quat3 ); + +/* + * Extract four AoS quaternions + */ +static inline void vmathSoaQGet4Aos( const VmathSoaQuat *quat, VmathQuat *result0, VmathQuat *result1, VmathQuat *result2, VmathQuat *result3 ); + +/* + * Set the x, y, and z elements of a quaternion + * NOTE: + * This function does not change the w element. + */ +static inline void vmathSoaQSetXYZ( VmathSoaQuat *result, const VmathSoaVector3 *vec ); + +/* + * Get the x, y, and z elements of a quaternion + */ +static inline void vmathSoaQGetXYZ( VmathSoaVector3 *result, const VmathSoaQuat *quat ); + +/* + * Set the x element of a quaternion + */ +static inline void vmathSoaQSetX( VmathSoaQuat *result, vec_float4 x ); + +/* + * Set the y element of a quaternion + */ +static inline void vmathSoaQSetY( VmathSoaQuat *result, vec_float4 y ); + +/* + * Set the z element of a quaternion + */ +static inline void vmathSoaQSetZ( VmathSoaQuat *result, vec_float4 z ); + +/* + * Set the w element of a quaternion + */ +static inline void vmathSoaQSetW( VmathSoaQuat *result, vec_float4 w ); + +/* + * Get the x element of a quaternion + */ +static inline vec_float4 vmathSoaQGetX( const VmathSoaQuat *quat ); + +/* + * Get the y element of a quaternion + */ +static inline vec_float4 vmathSoaQGetY( const VmathSoaQuat *quat ); + +/* + * Get the z element of a quaternion + */ +static inline vec_float4 vmathSoaQGetZ( const VmathSoaQuat *quat ); + +/* + * Get the w element of a quaternion + */ +static inline vec_float4 vmathSoaQGetW( const VmathSoaQuat *quat ); + +/* + * Set an x, y, z, or w element of a quaternion by index + */ +static inline void vmathSoaQSetElem( VmathSoaQuat *result, int idx, vec_float4 value ); + +/* + * Get an x, y, z, or w element of a quaternion by index + */ +static inline vec_float4 vmathSoaQGetElem( const VmathSoaQuat *quat, int idx ); + +/* + * Add two quaternions + */ +static inline void vmathSoaQAdd( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ); + +/* + * Subtract a quaternion from another quaternion + */ +static inline void vmathSoaQSub( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ); + +/* + * Multiply two quaternions + */ +static inline void vmathSoaQMul( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ); + +/* + * Multiply a quaternion by a scalar + */ +static inline void vmathSoaQScalarMul( VmathSoaQuat *result, const VmathSoaQuat *quat, vec_float4 scalar ); + +/* + * Divide a quaternion by a scalar + */ +static inline void vmathSoaQScalarDiv( VmathSoaQuat *result, const VmathSoaQuat *quat, vec_float4 scalar ); + +/* + * Negate all elements of a quaternion + */ +static inline void vmathSoaQNeg( VmathSoaQuat *result, const VmathSoaQuat *quat ); + +/* + * Construct an identity quaternion + */ +static inline void vmathSoaQMakeIdentity( VmathSoaQuat *result ); + +/* + * Construct a quaternion to rotate between two unit-length 3-D vectors + * NOTE: + * The result is unpredictable if unitVec0 and unitVec1 point in opposite directions. + */ +static inline void vmathSoaQMakeRotationArc( VmathSoaQuat *result, const VmathSoaVector3 *unitVec0, const VmathSoaVector3 *unitVec1 ); + +/* + * Construct a quaternion to rotate around a unit-length 3-D vector + */ +static inline void vmathSoaQMakeRotationAxis( VmathSoaQuat *result, vec_float4 radians, const VmathSoaVector3 *unitVec ); + +/* + * Construct a quaternion to rotate around the x axis + */ +static inline void vmathSoaQMakeRotationX( VmathSoaQuat *result, vec_float4 radians ); + +/* + * Construct a quaternion to rotate around the y axis + */ +static inline void vmathSoaQMakeRotationY( VmathSoaQuat *result, vec_float4 radians ); + +/* + * Construct a quaternion to rotate around the z axis + */ +static inline void vmathSoaQMakeRotationZ( VmathSoaQuat *result, vec_float4 radians ); + +/* + * Compute the conjugate of a quaternion + */ +static inline void vmathSoaQConj( VmathSoaQuat *result, const VmathSoaQuat *quat ); + +/* + * Use a unit-length quaternion to rotate a 3-D vector + */ +static inline void vmathSoaQRotate( VmathSoaVector3 *result, const VmathSoaQuat *unitQuat, const VmathSoaVector3 *vec ); + +/* + * Compute the dot product of two quaternions + */ +static inline vec_float4 vmathSoaQDot( const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ); + +/* + * Compute the norm of a quaternion + */ +static inline vec_float4 vmathSoaQNorm( const VmathSoaQuat *quat ); + +/* + * Compute the length of a quaternion + */ +static inline vec_float4 vmathSoaQLength( const VmathSoaQuat *quat ); + +/* + * Normalize a quaternion + * NOTE: + * The result is unpredictable when all elements of quat are at or near zero. + */ +static inline void vmathSoaQNormalize( VmathSoaQuat *result, const VmathSoaQuat *quat ); + +/* + * Linear interpolation between two quaternions + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline void vmathSoaQLerp( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ); + +/* + * Spherical linear interpolation between two quaternions + * NOTE: + * Interpolates along the shortest path between orientations. + * Does not clamp t between 0 and 1. + */ +static inline void vmathSoaQSlerp( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *unitQuat0, const VmathSoaQuat *unitQuat1 ); + +/* + * Spherical quadrangle interpolation + */ +static inline void vmathSoaQSquad( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *unitQuat0, const VmathSoaQuat *unitQuat1, const VmathSoaQuat *unitQuat2, const VmathSoaQuat *unitQuat3 ); + +/* + * Conditionally select between two quaternions + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline void vmathSoaQSelect( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1, vec_uint4 select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a quaternion + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaQPrint( const VmathSoaQuat *quat ); + +/* + * Print a quaternion and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaQPrints( const VmathSoaQuat *quat, const char *name ); + +#endif + +/* + * Copy a 3x3 matrix + */ +static inline void vmathSoaM3Copy( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ); + +/* + * Construct a 3x3 matrix containing the specified columns + */ +static inline void vmathSoaM3MakeFromCols( VmathSoaMatrix3 *result, const VmathSoaVector3 *col0, const VmathSoaVector3 *col1, const VmathSoaVector3 *col2 ); + +/* + * Construct a 3x3 rotation matrix from a unit-length quaternion + */ +static inline void vmathSoaM3MakeFromQ( VmathSoaMatrix3 *result, const VmathSoaQuat *unitQuat ); + +/* + * Set all elements of a 3x3 matrix to the same scalar value + */ +static inline void vmathSoaM3MakeFromScalar( VmathSoaMatrix3 *result, vec_float4 scalar ); + +/* + * Replicate an AoS 3x3 matrix + */ +static inline void vmathSoaM3MakeFromAos( VmathSoaMatrix3 *result, const VmathMatrix3 *mat ); + +/* + * Insert four AoS 3x3 matrices + */ +static inline void vmathSoaM3MakeFrom4Aos( VmathSoaMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1, const VmathMatrix3 *mat2, const VmathMatrix3 *mat3 ); + +/* + * Extract four AoS 3x3 matrices + */ +static inline void vmathSoaM3Get4Aos( const VmathSoaMatrix3 *mat, VmathMatrix3 *result0, VmathMatrix3 *result1, VmathMatrix3 *result2, VmathMatrix3 *result3 ); + +/* + * Set column 0 of a 3x3 matrix + */ +static inline void vmathSoaM3SetCol0( VmathSoaMatrix3 *result, const VmathSoaVector3 *col0 ); + +/* + * Set column 1 of a 3x3 matrix + */ +static inline void vmathSoaM3SetCol1( VmathSoaMatrix3 *result, const VmathSoaVector3 *col1 ); + +/* + * Set column 2 of a 3x3 matrix + */ +static inline void vmathSoaM3SetCol2( VmathSoaMatrix3 *result, const VmathSoaVector3 *col2 ); + +/* + * Get column 0 of a 3x3 matrix + */ +static inline void vmathSoaM3GetCol0( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat ); + +/* + * Get column 1 of a 3x3 matrix + */ +static inline void vmathSoaM3GetCol1( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat ); + +/* + * Get column 2 of a 3x3 matrix + */ +static inline void vmathSoaM3GetCol2( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat ); + +/* + * Set the column of a 3x3 matrix referred to by the specified index + */ +static inline void vmathSoaM3SetCol( VmathSoaMatrix3 *result, int col, const VmathSoaVector3 *vec ); + +/* + * Set the row of a 3x3 matrix referred to by the specified index + */ +static inline void vmathSoaM3SetRow( VmathSoaMatrix3 *result, int row, const VmathSoaVector3 *vec ); + +/* + * Get the column of a 3x3 matrix referred to by the specified index + */ +static inline void vmathSoaM3GetCol( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat, int col ); + +/* + * Get the row of a 3x3 matrix referred to by the specified index + */ +static inline void vmathSoaM3GetRow( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat, int row ); + +/* + * Set the element of a 3x3 matrix referred to by column and row indices + */ +static inline void vmathSoaM3SetElem( VmathSoaMatrix3 *result, int col, int row, vec_float4 val ); + +/* + * Get the element of a 3x3 matrix referred to by column and row indices + */ +static inline vec_float4 vmathSoaM3GetElem( const VmathSoaMatrix3 *mat, int col, int row ); + +/* + * Add two 3x3 matrices + */ +static inline void vmathSoaM3Add( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1 ); + +/* + * Subtract a 3x3 matrix from another 3x3 matrix + */ +static inline void vmathSoaM3Sub( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1 ); + +/* + * Negate all elements of a 3x3 matrix + */ +static inline void vmathSoaM3Neg( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ); + +/* + * Multiply a 3x3 matrix by a scalar + */ +static inline void vmathSoaM3ScalarMul( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat, vec_float4 scalar ); + +/* + * Multiply a 3x3 matrix by a 3-D vector + */ +static inline void vmathSoaM3MulV3( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat, const VmathSoaVector3 *vec ); + +/* + * Multiply two 3x3 matrices + */ +static inline void vmathSoaM3Mul( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1 ); + +/* + * Construct an identity 3x3 matrix + */ +static inline void vmathSoaM3MakeIdentity( VmathSoaMatrix3 *result ); + +/* + * Construct a 3x3 matrix to rotate around the x axis + */ +static inline void vmathSoaM3MakeRotationX( VmathSoaMatrix3 *result, vec_float4 radians ); + +/* + * Construct a 3x3 matrix to rotate around the y axis + */ +static inline void vmathSoaM3MakeRotationY( VmathSoaMatrix3 *result, vec_float4 radians ); + +/* + * Construct a 3x3 matrix to rotate around the z axis + */ +static inline void vmathSoaM3MakeRotationZ( VmathSoaMatrix3 *result, vec_float4 radians ); + +/* + * Construct a 3x3 matrix to rotate around the x, y, and z axes + */ +static inline void vmathSoaM3MakeRotationZYX( VmathSoaMatrix3 *result, const VmathSoaVector3 *radiansXYZ ); + +/* + * Construct a 3x3 matrix to rotate around a unit-length 3-D vector + */ +static inline void vmathSoaM3MakeRotationAxis( VmathSoaMatrix3 *result, vec_float4 radians, const VmathSoaVector3 *unitVec ); + +/* + * Construct a rotation matrix from a unit-length quaternion + */ +static inline void vmathSoaM3MakeRotationQ( VmathSoaMatrix3 *result, const VmathSoaQuat *unitQuat ); + +/* + * Construct a 3x3 matrix to perform scaling + */ +static inline void vmathSoaM3MakeScale( VmathSoaMatrix3 *result, const VmathSoaVector3 *scaleVec ); + +/* + * Append (post-multiply) a scale transformation to a 3x3 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline void vmathSoaM3AppendScale( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat, const VmathSoaVector3 *scaleVec ); + +/* + * Prepend (pre-multiply) a scale transformation to a 3x3 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline void vmathSoaM3PrependScale( VmathSoaMatrix3 *result, const VmathSoaVector3 *scaleVec, const VmathSoaMatrix3 *mat ); + +/* + * Multiply two 3x3 matrices per element + */ +static inline void vmathSoaM3MulPerElem( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1 ); + +/* + * Compute the absolute value of a 3x3 matrix per element + */ +static inline void vmathSoaM3AbsPerElem( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ); + +/* + * Transpose of a 3x3 matrix + */ +static inline void vmathSoaM3Transpose( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ); + +/* + * Compute the inverse of a 3x3 matrix + * NOTE: + * Result is unpredictable when the determinant of mat is equal to or near 0. + */ +static inline void vmathSoaM3Inverse( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ); + +/* + * Determinant of a 3x3 matrix + */ +static inline vec_float4 vmathSoaM3Determinant( const VmathSoaMatrix3 *mat ); + +/* + * Conditionally select between two 3x3 matrices + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline void vmathSoaM3Select( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1, vec_uint4 select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3x3 matrix + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaM3Print( const VmathSoaMatrix3 *mat ); + +/* + * Print a 3x3 matrix and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaM3Prints( const VmathSoaMatrix3 *mat, const char *name ); + +#endif + +/* + * Copy a 4x4 matrix + */ +static inline void vmathSoaM4Copy( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ); + +/* + * Construct a 4x4 matrix containing the specified columns + */ +static inline void vmathSoaM4MakeFromCols( VmathSoaMatrix4 *result, const VmathSoaVector4 *col0, const VmathSoaVector4 *col1, const VmathSoaVector4 *col2, const VmathSoaVector4 *col3 ); + +/* + * Construct a 4x4 matrix from a 3x4 transformation matrix + */ +static inline void vmathSoaM4MakeFromT3( VmathSoaMatrix4 *result, const VmathSoaTransform3 *mat ); + +/* + * Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector + */ +static inline void vmathSoaM4MakeFromM3V3( VmathSoaMatrix4 *result, const VmathSoaMatrix3 *mat, const VmathSoaVector3 *translateVec ); + +/* + * Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector + */ +static inline void vmathSoaM4MakeFromQV3( VmathSoaMatrix4 *result, const VmathSoaQuat *unitQuat, const VmathSoaVector3 *translateVec ); + +/* + * Set all elements of a 4x4 matrix to the same scalar value + */ +static inline void vmathSoaM4MakeFromScalar( VmathSoaMatrix4 *result, vec_float4 scalar ); + +/* + * Replicate an AoS 4x4 matrix + */ +static inline void vmathSoaM4MakeFromAos( VmathSoaMatrix4 *result, const VmathMatrix4 *mat ); + +/* + * Insert four AoS 4x4 matrices + */ +static inline void vmathSoaM4MakeFrom4Aos( VmathSoaMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1, const VmathMatrix4 *mat2, const VmathMatrix4 *mat3 ); + +/* + * Extract four AoS 4x4 matrices + */ +static inline void vmathSoaM4Get4Aos( const VmathSoaMatrix4 *mat, VmathMatrix4 *result0, VmathMatrix4 *result1, VmathMatrix4 *result2, VmathMatrix4 *result3 ); + +/* + * Set the upper-left 3x3 submatrix + * NOTE: + * This function does not change the bottom row elements. + */ +static inline void vmathSoaM4SetUpper3x3( VmathSoaMatrix4 *result, const VmathSoaMatrix3 *mat3 ); + +/* + * Get the upper-left 3x3 submatrix of a 4x4 matrix + */ +static inline void vmathSoaM4GetUpper3x3( VmathSoaMatrix3 *result, const VmathSoaMatrix4 *mat ); + +/* + * Set translation component + * NOTE: + * This function does not change the bottom row elements. + */ +static inline void vmathSoaM4SetTranslation( VmathSoaMatrix4 *result, const VmathSoaVector3 *translateVec ); + +/* + * Get the translation component of a 4x4 matrix + */ +static inline void vmathSoaM4GetTranslation( VmathSoaVector3 *result, const VmathSoaMatrix4 *mat ); + +/* + * Set column 0 of a 4x4 matrix + */ +static inline void vmathSoaM4SetCol0( VmathSoaMatrix4 *result, const VmathSoaVector4 *col0 ); + +/* + * Set column 1 of a 4x4 matrix + */ +static inline void vmathSoaM4SetCol1( VmathSoaMatrix4 *result, const VmathSoaVector4 *col1 ); + +/* + * Set column 2 of a 4x4 matrix + */ +static inline void vmathSoaM4SetCol2( VmathSoaMatrix4 *result, const VmathSoaVector4 *col2 ); + +/* + * Set column 3 of a 4x4 matrix + */ +static inline void vmathSoaM4SetCol3( VmathSoaMatrix4 *result, const VmathSoaVector4 *col3 ); + +/* + * Get column 0 of a 4x4 matrix + */ +static inline void vmathSoaM4GetCol0( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat ); + +/* + * Get column 1 of a 4x4 matrix + */ +static inline void vmathSoaM4GetCol1( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat ); + +/* + * Get column 2 of a 4x4 matrix + */ +static inline void vmathSoaM4GetCol2( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat ); + +/* + * Get column 3 of a 4x4 matrix + */ +static inline void vmathSoaM4GetCol3( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat ); + +/* + * Set the column of a 4x4 matrix referred to by the specified index + */ +static inline void vmathSoaM4SetCol( VmathSoaMatrix4 *result, int col, const VmathSoaVector4 *vec ); + +/* + * Set the row of a 4x4 matrix referred to by the specified index + */ +static inline void vmathSoaM4SetRow( VmathSoaMatrix4 *result, int row, const VmathSoaVector4 *vec ); + +/* + * Get the column of a 4x4 matrix referred to by the specified index + */ +static inline void vmathSoaM4GetCol( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, int col ); + +/* + * Get the row of a 4x4 matrix referred to by the specified index + */ +static inline void vmathSoaM4GetRow( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, int row ); + +/* + * Set the element of a 4x4 matrix referred to by column and row indices + */ +static inline void vmathSoaM4SetElem( VmathSoaMatrix4 *result, int col, int row, vec_float4 val ); + +/* + * Get the element of a 4x4 matrix referred to by column and row indices + */ +static inline vec_float4 vmathSoaM4GetElem( const VmathSoaMatrix4 *mat, int col, int row ); + +/* + * Add two 4x4 matrices + */ +static inline void vmathSoaM4Add( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1 ); + +/* + * Subtract a 4x4 matrix from another 4x4 matrix + */ +static inline void vmathSoaM4Sub( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1 ); + +/* + * Negate all elements of a 4x4 matrix + */ +static inline void vmathSoaM4Neg( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ); + +/* + * Multiply a 4x4 matrix by a scalar + */ +static inline void vmathSoaM4ScalarMul( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat, vec_float4 scalar ); + +/* + * Multiply a 4x4 matrix by a 4-D vector + */ +static inline void vmathSoaM4MulV4( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, const VmathSoaVector4 *vec ); + +/* + * Multiply a 4x4 matrix by a 3-D vector + */ +static inline void vmathSoaM4MulV3( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, const VmathSoaVector3 *vec ); + +/* + * Multiply a 4x4 matrix by a 3-D point + */ +static inline void vmathSoaM4MulP3( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, const VmathSoaPoint3 *pnt ); + +/* + * Multiply two 4x4 matrices + */ +static inline void vmathSoaM4Mul( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1 ); + +/* + * Multiply a 4x4 matrix by a 3x4 transformation matrix + */ +static inline void vmathSoaM4MulT3( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat, const VmathSoaTransform3 *tfrm ); + +/* + * Construct an identity 4x4 matrix + */ +static inline void vmathSoaM4MakeIdentity( VmathSoaMatrix4 *result ); + +/* + * Construct a 4x4 matrix to rotate around the x axis + */ +static inline void vmathSoaM4MakeRotationX( VmathSoaMatrix4 *result, vec_float4 radians ); + +/* + * Construct a 4x4 matrix to rotate around the y axis + */ +static inline void vmathSoaM4MakeRotationY( VmathSoaMatrix4 *result, vec_float4 radians ); + +/* + * Construct a 4x4 matrix to rotate around the z axis + */ +static inline void vmathSoaM4MakeRotationZ( VmathSoaMatrix4 *result, vec_float4 radians ); + +/* + * Construct a 4x4 matrix to rotate around the x, y, and z axes + */ +static inline void vmathSoaM4MakeRotationZYX( VmathSoaMatrix4 *result, const VmathSoaVector3 *radiansXYZ ); + +/* + * Construct a 4x4 matrix to rotate around a unit-length 3-D vector + */ +static inline void vmathSoaM4MakeRotationAxis( VmathSoaMatrix4 *result, vec_float4 radians, const VmathSoaVector3 *unitVec ); + +/* + * Construct a rotation matrix from a unit-length quaternion + */ +static inline void vmathSoaM4MakeRotationQ( VmathSoaMatrix4 *result, const VmathSoaQuat *unitQuat ); + +/* + * Construct a 4x4 matrix to perform scaling + */ +static inline void vmathSoaM4MakeScale( VmathSoaMatrix4 *result, const VmathSoaVector3 *scaleVec ); + +/* + * Construct a 4x4 matrix to perform translation + */ +static inline void vmathSoaM4MakeTranslation( VmathSoaMatrix4 *result, const VmathSoaVector3 *translateVec ); + +/* + * Construct viewing matrix based on eye position, position looked at, and up direction + */ +static inline void vmathSoaM4MakeLookAt( VmathSoaMatrix4 *result, const VmathSoaPoint3 *eyePos, const VmathSoaPoint3 *lookAtPos, const VmathSoaVector3 *upVec ); + +/* + * Construct a perspective projection matrix + */ +static inline void vmathSoaM4MakePerspective( VmathSoaMatrix4 *result, vec_float4 fovyRadians, vec_float4 aspect, vec_float4 zNear, vec_float4 zFar ); + +/* + * Construct a perspective projection matrix based on frustum + */ +static inline void vmathSoaM4MakeFrustum( VmathSoaMatrix4 *result, vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ); + +/* + * Construct an orthographic projection matrix + */ +static inline void vmathSoaM4MakeOrthographic( VmathSoaMatrix4 *result, vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ); + +/* + * Append (post-multiply) a scale transformation to a 4x4 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline void vmathSoaM4AppendScale( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat, const VmathSoaVector3 *scaleVec ); + +/* + * Prepend (pre-multiply) a scale transformation to a 4x4 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline void vmathSoaM4PrependScale( VmathSoaMatrix4 *result, const VmathSoaVector3 *scaleVec, const VmathSoaMatrix4 *mat ); + +/* + * Multiply two 4x4 matrices per element + */ +static inline void vmathSoaM4MulPerElem( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1 ); + +/* + * Compute the absolute value of a 4x4 matrix per element + */ +static inline void vmathSoaM4AbsPerElem( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ); + +/* + * Transpose of a 4x4 matrix + */ +static inline void vmathSoaM4Transpose( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ); + +/* + * Compute the inverse of a 4x4 matrix + * NOTE: + * Result is unpredictable when the determinant of mat is equal to or near 0. + */ +static inline void vmathSoaM4Inverse( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ); + +/* + * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix + * NOTE: + * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. The result is unpredictable when the determinant of mat is equal to or near 0. + */ +static inline void vmathSoaM4AffineInverse( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ); + +/* + * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix + * NOTE: + * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. + */ +static inline void vmathSoaM4OrthoInverse( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ); + +/* + * Determinant of a 4x4 matrix + */ +static inline vec_float4 vmathSoaM4Determinant( const VmathSoaMatrix4 *mat ); + +/* + * Conditionally select between two 4x4 matrices + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline void vmathSoaM4Select( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1, vec_uint4 select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 4x4 matrix + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaM4Print( const VmathSoaMatrix4 *mat ); + +/* + * Print a 4x4 matrix and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaM4Prints( const VmathSoaMatrix4 *mat, const char *name ); + +#endif + +/* + * Copy a 3x4 transformation matrix + */ +static inline void vmathSoaT3Copy( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm ); + +/* + * Construct a 3x4 transformation matrix containing the specified columns + */ +static inline void vmathSoaT3MakeFromCols( VmathSoaTransform3 *result, const VmathSoaVector3 *col0, const VmathSoaVector3 *col1, const VmathSoaVector3 *col2, const VmathSoaVector3 *col3 ); + +/* + * Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector + */ +static inline void vmathSoaT3MakeFromM3V3( VmathSoaTransform3 *result, const VmathSoaMatrix3 *tfrm, const VmathSoaVector3 *translateVec ); + +/* + * Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector + */ +static inline void vmathSoaT3MakeFromQV3( VmathSoaTransform3 *result, const VmathSoaQuat *unitQuat, const VmathSoaVector3 *translateVec ); + +/* + * Set all elements of a 3x4 transformation matrix to the same scalar value + */ +static inline void vmathSoaT3MakeFromScalar( VmathSoaTransform3 *result, vec_float4 scalar ); + +/* + * Replicate an AoS 3x4 transformation matrix + */ +static inline void vmathSoaT3MakeFromAos( VmathSoaTransform3 *result, const VmathTransform3 *tfrm ); + +/* + * Insert four AoS 3x4 transformation matrices + */ +static inline void vmathSoaT3MakeFrom4Aos( VmathSoaTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1, const VmathTransform3 *tfrm2, const VmathTransform3 *tfrm3 ); + +/* + * Extract four AoS 3x4 transformation matrices + */ +static inline void vmathSoaT3Get4Aos( const VmathSoaTransform3 *tfrm, VmathTransform3 *result0, VmathTransform3 *result1, VmathTransform3 *result2, VmathTransform3 *result3 ); + +/* + * Set the upper-left 3x3 submatrix + */ +static inline void vmathSoaT3SetUpper3x3( VmathSoaTransform3 *result, const VmathSoaMatrix3 *mat3 ); + +/* + * Get the upper-left 3x3 submatrix of a 3x4 transformation matrix + */ +static inline void vmathSoaT3GetUpper3x3( VmathSoaMatrix3 *result, const VmathSoaTransform3 *tfrm ); + +/* + * Set translation component + */ +static inline void vmathSoaT3SetTranslation( VmathSoaTransform3 *result, const VmathSoaVector3 *translateVec ); + +/* + * Get the translation component of a 3x4 transformation matrix + */ +static inline void vmathSoaT3GetTranslation( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ); + +/* + * Set column 0 of a 3x4 transformation matrix + */ +static inline void vmathSoaT3SetCol0( VmathSoaTransform3 *result, const VmathSoaVector3 *col0 ); + +/* + * Set column 1 of a 3x4 transformation matrix + */ +static inline void vmathSoaT3SetCol1( VmathSoaTransform3 *result, const VmathSoaVector3 *col1 ); + +/* + * Set column 2 of a 3x4 transformation matrix + */ +static inline void vmathSoaT3SetCol2( VmathSoaTransform3 *result, const VmathSoaVector3 *col2 ); + +/* + * Set column 3 of a 3x4 transformation matrix + */ +static inline void vmathSoaT3SetCol3( VmathSoaTransform3 *result, const VmathSoaVector3 *col3 ); + +/* + * Get column 0 of a 3x4 transformation matrix + */ +static inline void vmathSoaT3GetCol0( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ); + +/* + * Get column 1 of a 3x4 transformation matrix + */ +static inline void vmathSoaT3GetCol1( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ); + +/* + * Get column 2 of a 3x4 transformation matrix + */ +static inline void vmathSoaT3GetCol2( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ); + +/* + * Get column 3 of a 3x4 transformation matrix + */ +static inline void vmathSoaT3GetCol3( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ); + +/* + * Set the column of a 3x4 transformation matrix referred to by the specified index + */ +static inline void vmathSoaT3SetCol( VmathSoaTransform3 *result, int col, const VmathSoaVector3 *vec ); + +/* + * Set the row of a 3x4 transformation matrix referred to by the specified index + */ +static inline void vmathSoaT3SetRow( VmathSoaTransform3 *result, int row, const VmathSoaVector4 *vec ); + +/* + * Get the column of a 3x4 transformation matrix referred to by the specified index + */ +static inline void vmathSoaT3GetCol( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm, int col ); + +/* + * Get the row of a 3x4 transformation matrix referred to by the specified index + */ +static inline void vmathSoaT3GetRow( VmathSoaVector4 *result, const VmathSoaTransform3 *tfrm, int row ); + +/* + * Set the element of a 3x4 transformation matrix referred to by column and row indices + */ +static inline void vmathSoaT3SetElem( VmathSoaTransform3 *result, int col, int row, vec_float4 val ); + +/* + * Get the element of a 3x4 transformation matrix referred to by column and row indices + */ +static inline vec_float4 vmathSoaT3GetElem( const VmathSoaTransform3 *tfrm, int col, int row ); + +/* + * Multiply a 3x4 transformation matrix by a 3-D vector + */ +static inline void vmathSoaT3MulV3( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm, const VmathSoaVector3 *vec ); + +/* + * Multiply a 3x4 transformation matrix by a 3-D point + */ +static inline void vmathSoaT3MulP3( VmathSoaPoint3 *result, const VmathSoaTransform3 *tfrm, const VmathSoaPoint3 *pnt ); + +/* + * Multiply two 3x4 transformation matrices + */ +static inline void vmathSoaT3Mul( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm0, const VmathSoaTransform3 *tfrm1 ); + +/* + * Construct an identity 3x4 transformation matrix + */ +static inline void vmathSoaT3MakeIdentity( VmathSoaTransform3 *result ); + +/* + * Construct a 3x4 transformation matrix to rotate around the x axis + */ +static inline void vmathSoaT3MakeRotationX( VmathSoaTransform3 *result, vec_float4 radians ); + +/* + * Construct a 3x4 transformation matrix to rotate around the y axis + */ +static inline void vmathSoaT3MakeRotationY( VmathSoaTransform3 *result, vec_float4 radians ); + +/* + * Construct a 3x4 transformation matrix to rotate around the z axis + */ +static inline void vmathSoaT3MakeRotationZ( VmathSoaTransform3 *result, vec_float4 radians ); + +/* + * Construct a 3x4 transformation matrix to rotate around the x, y, and z axes + */ +static inline void vmathSoaT3MakeRotationZYX( VmathSoaTransform3 *result, const VmathSoaVector3 *radiansXYZ ); + +/* + * Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector + */ +static inline void vmathSoaT3MakeRotationAxis( VmathSoaTransform3 *result, vec_float4 radians, const VmathSoaVector3 *unitVec ); + +/* + * Construct a rotation matrix from a unit-length quaternion + */ +static inline void vmathSoaT3MakeRotationQ( VmathSoaTransform3 *result, const VmathSoaQuat *unitQuat ); + +/* + * Construct a 3x4 transformation matrix to perform scaling + */ +static inline void vmathSoaT3MakeScale( VmathSoaTransform3 *result, const VmathSoaVector3 *scaleVec ); + +/* + * Construct a 3x4 transformation matrix to perform translation + */ +static inline void vmathSoaT3MakeTranslation( VmathSoaTransform3 *result, const VmathSoaVector3 *translateVec ); + +/* + * Append (post-multiply) a scale transformation to a 3x4 transformation matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline void vmathSoaT3AppendScale( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm, const VmathSoaVector3 *scaleVec ); + +/* + * Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline void vmathSoaT3PrependScale( VmathSoaTransform3 *result, const VmathSoaVector3 *scaleVec, const VmathSoaTransform3 *tfrm ); + +/* + * Multiply two 3x4 transformation matrices per element + */ +static inline void vmathSoaT3MulPerElem( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm0, const VmathSoaTransform3 *tfrm1 ); + +/* + * Compute the absolute value of a 3x4 transformation matrix per element + */ +static inline void vmathSoaT3AbsPerElem( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm ); + +/* + * Inverse of a 3x4 transformation matrix + * NOTE: + * Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0. + */ +static inline void vmathSoaT3Inverse( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm ); + +/* + * Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix + * NOTE: + * This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions. + */ +static inline void vmathSoaT3OrthoInverse( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm ); + +/* + * Conditionally select between two 3x4 transformation matrices + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline void vmathSoaT3Select( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm0, const VmathSoaTransform3 *tfrm1, vec_uint4 select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3x4 transformation matrix + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaT3Print( const VmathSoaTransform3 *tfrm ); + +/* + * Print a 3x4 transformation matrix and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaT3Prints( const VmathSoaTransform3 *tfrm, const char *name ); + +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include "vec_soa.h" +#include "quat_soa.h" +#include "mat_soa.h" + +#endif diff --git a/vectormathlibrary/include/vectormath/ppu/c/vectormath_soa_v.h b/vectormathlibrary/include/vectormath/ppu/c/vectormath_soa_v.h new file mode 100644 index 000000000..7a93c1757 --- /dev/null +++ b/vectormathlibrary/include/vectormath/ppu/c/vectormath_soa_v.h @@ -0,0 +1,1979 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_SOA_C_V_PPU_H +#define _VECTORMATH_SOA_C_V_PPU_H + +#include <math.h> +#include <altivec.h> +#include "vectormath_aos_v.h" + +#ifdef _VECTORMATH_DEBUG +#include <stdio.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#ifndef _VECTORMATH_SOA_C_TYPES_H +#define _VECTORMATH_SOA_C_TYPES_H + +/* A set of four 3-D vectors in structure-of-arrays format + */ +typedef struct _VmathSoaVector3 +{ + vec_float4 x; + vec_float4 y; + vec_float4 z; +} VmathSoaVector3; + +/* A set of four 4-D vectors in structure-of-arrays format + */ +typedef struct _VmathSoaVector4 +{ + vec_float4 x; + vec_float4 y; + vec_float4 z; + vec_float4 w; +} VmathSoaVector4; + +/* A set of four 3-D points in structure-of-arrays format + */ +typedef struct _VmathSoaPoint3 +{ + vec_float4 x; + vec_float4 y; + vec_float4 z; +} VmathSoaPoint3; + +/* A set of four quaternions in structure-of-arrays format + */ +typedef struct _VmathSoaQuat +{ + vec_float4 x; + vec_float4 y; + vec_float4 z; + vec_float4 w; +} VmathSoaQuat; + +/* A set of four 3x3 matrices in structure-of-arrays format + */ +typedef struct _VmathSoaMatrix3 +{ + VmathSoaVector3 col0; + VmathSoaVector3 col1; + VmathSoaVector3 col2; +} VmathSoaMatrix3; + +/* A set of four 4x4 matrices in structure-of-arrays format + */ +typedef struct _VmathSoaMatrix4 +{ + VmathSoaVector4 col0; + VmathSoaVector4 col1; + VmathSoaVector4 col2; + VmathSoaVector4 col3; +} VmathSoaMatrix4; + +/* A set of four 3x4 transformation matrices in structure-of-arrays format + */ +typedef struct _VmathSoaTransform3 +{ + VmathSoaVector3 col0; + VmathSoaVector3 col1; + VmathSoaVector3 col2; + VmathSoaVector3 col3; +} VmathSoaTransform3; + +#endif + +/* + * Construct a 3-D vector from x, y, and z elements + */ +static inline VmathSoaVector3 vmathSoaV3MakeFromElems_V( vec_float4 x, vec_float4 y, vec_float4 z ); + +/* + * Copy elements from a 3-D point into a 3-D vector + */ +static inline VmathSoaVector3 vmathSoaV3MakeFromP3_V( VmathSoaPoint3 pnt ); + +/* + * Set all elements of a 3-D vector to the same scalar value + */ +static inline VmathSoaVector3 vmathSoaV3MakeFromScalar_V( vec_float4 scalar ); + +/* + * Replicate an AoS 3-D vector + */ +static inline VmathSoaVector3 vmathSoaV3MakeFromAos_V( VmathVector3 vec ); + +/* + * Insert four AoS 3-D vectors + */ +static inline VmathSoaVector3 vmathSoaV3MakeFrom4Aos_V( VmathVector3 vec0, VmathVector3 vec1, VmathVector3 vec2, VmathVector3 vec3 ); + +/* + * Extract four AoS 3-D vectors + */ +static inline void vmathSoaV3Get4Aos_V( VmathSoaVector3 vec, VmathVector3 *result0, VmathVector3 *result1, VmathVector3 *result2, VmathVector3 *result3 ); + +/* + * Set the x element of a 3-D vector + */ +static inline void vmathSoaV3SetX_V( VmathSoaVector3 *result, vec_float4 x ); + +/* + * Set the y element of a 3-D vector + */ +static inline void vmathSoaV3SetY_V( VmathSoaVector3 *result, vec_float4 y ); + +/* + * Set the z element of a 3-D vector + */ +static inline void vmathSoaV3SetZ_V( VmathSoaVector3 *result, vec_float4 z ); + +/* + * Get the x element of a 3-D vector + */ +static inline vec_float4 vmathSoaV3GetX_V( VmathSoaVector3 vec ); + +/* + * Get the y element of a 3-D vector + */ +static inline vec_float4 vmathSoaV3GetY_V( VmathSoaVector3 vec ); + +/* + * Get the z element of a 3-D vector + */ +static inline vec_float4 vmathSoaV3GetZ_V( VmathSoaVector3 vec ); + +/* + * Set an x, y, or z element of a 3-D vector by index + */ +static inline void vmathSoaV3SetElem_V( VmathSoaVector3 *result, int idx, vec_float4 value ); + +/* + * Get an x, y, or z element of a 3-D vector by index + */ +static inline vec_float4 vmathSoaV3GetElem_V( VmathSoaVector3 vec, int idx ); + +/* + * Add two 3-D vectors + */ +static inline VmathSoaVector3 vmathSoaV3Add_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); + +/* + * Subtract a 3-D vector from another 3-D vector + */ +static inline VmathSoaVector3 vmathSoaV3Sub_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); + +/* + * Add a 3-D vector to a 3-D point + */ +static inline VmathSoaPoint3 vmathSoaV3AddP3_V( VmathSoaVector3 vec, VmathSoaPoint3 pnt ); + +/* + * Multiply a 3-D vector by a scalar + */ +static inline VmathSoaVector3 vmathSoaV3ScalarMul_V( VmathSoaVector3 vec, vec_float4 scalar ); + +/* + * Divide a 3-D vector by a scalar + */ +static inline VmathSoaVector3 vmathSoaV3ScalarDiv_V( VmathSoaVector3 vec, vec_float4 scalar ); + +/* + * Negate all elements of a 3-D vector + */ +static inline VmathSoaVector3 vmathSoaV3Neg_V( VmathSoaVector3 vec ); + +/* + * Construct x axis + */ +static inline VmathSoaVector3 vmathSoaV3MakeXAxis_V( ); + +/* + * Construct y axis + */ +static inline VmathSoaVector3 vmathSoaV3MakeYAxis_V( ); + +/* + * Construct z axis + */ +static inline VmathSoaVector3 vmathSoaV3MakeZAxis_V( ); + +/* + * Multiply two 3-D vectors per element + */ +static inline VmathSoaVector3 vmathSoaV3MulPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); + +/* + * Divide two 3-D vectors per element + * NOTE: + * Floating-point behavior matches standard library function divf4. + */ +static inline VmathSoaVector3 vmathSoaV3DivPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); + +/* + * Compute the reciprocal of a 3-D vector per element + * NOTE: + * Floating-point behavior matches standard library function recipf4. + */ +static inline VmathSoaVector3 vmathSoaV3RecipPerElem_V( VmathSoaVector3 vec ); + +/* + * Compute the square root of a 3-D vector per element + * NOTE: + * Floating-point behavior matches standard library function sqrtf4. + */ +static inline VmathSoaVector3 vmathSoaV3SqrtPerElem_V( VmathSoaVector3 vec ); + +/* + * Compute the reciprocal square root of a 3-D vector per element + * NOTE: + * Floating-point behavior matches standard library function rsqrtf4. + */ +static inline VmathSoaVector3 vmathSoaV3RsqrtPerElem_V( VmathSoaVector3 vec ); + +/* + * Compute the absolute value of a 3-D vector per element + */ +static inline VmathSoaVector3 vmathSoaV3AbsPerElem_V( VmathSoaVector3 vec ); + +/* + * Copy sign from one 3-D vector to another, per element + */ +static inline VmathSoaVector3 vmathSoaV3CopySignPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); + +/* + * Maximum of two 3-D vectors per element + */ +static inline VmathSoaVector3 vmathSoaV3MaxPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); + +/* + * Minimum of two 3-D vectors per element + */ +static inline VmathSoaVector3 vmathSoaV3MinPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); + +/* + * Maximum element of a 3-D vector + */ +static inline vec_float4 vmathSoaV3MaxElem_V( VmathSoaVector3 vec ); + +/* + * Minimum element of a 3-D vector + */ +static inline vec_float4 vmathSoaV3MinElem_V( VmathSoaVector3 vec ); + +/* + * Compute the sum of all elements of a 3-D vector + */ +static inline vec_float4 vmathSoaV3Sum_V( VmathSoaVector3 vec ); + +/* + * Compute the dot product of two 3-D vectors + */ +static inline vec_float4 vmathSoaV3Dot_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); + +/* + * Compute the square of the length of a 3-D vector + */ +static inline vec_float4 vmathSoaV3LengthSqr_V( VmathSoaVector3 vec ); + +/* + * Compute the length of a 3-D vector + */ +static inline vec_float4 vmathSoaV3Length_V( VmathSoaVector3 vec ); + +/* + * Normalize a 3-D vector + * NOTE: + * The result is unpredictable when all elements of vec are at or near zero. + */ +static inline VmathSoaVector3 vmathSoaV3Normalize_V( VmathSoaVector3 vec ); + +/* + * Compute cross product of two 3-D vectors + */ +static inline VmathSoaVector3 vmathSoaV3Cross_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); + +/* + * Outer product of two 3-D vectors + */ +static inline VmathSoaMatrix3 vmathSoaV3Outer_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); + +/* + * Pre-multiply a row vector by a 3x3 matrix + */ +static inline VmathSoaVector3 vmathSoaV3RowMul_V( VmathSoaVector3 vec, VmathSoaMatrix3 mat ); + +/* + * Cross-product matrix of a 3-D vector + */ +static inline VmathSoaMatrix3 vmathSoaV3CrossMatrix_V( VmathSoaVector3 vec ); + +/* + * Create cross-product matrix and multiply + * NOTE: + * Faster than separately creating a cross-product matrix and multiplying. + */ +static inline VmathSoaMatrix3 vmathSoaV3CrossMatrixMul_V( VmathSoaVector3 vec, VmathSoaMatrix3 mat ); + +/* + * Linear interpolation between two 3-D vectors + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline VmathSoaVector3 vmathSoaV3Lerp_V( vec_float4 t, VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); + +/* + * Spherical linear interpolation between two 3-D vectors + * NOTE: + * The result is unpredictable if the vectors point in opposite directions. + * Does not clamp t between 0 and 1. + */ +static inline VmathSoaVector3 vmathSoaV3Slerp_V( vec_float4 t, VmathSoaVector3 unitVec0, VmathSoaVector3 unitVec1 ); + +/* + * Conditionally select between two 3-D vectors + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline VmathSoaVector3 vmathSoaV3Select_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1, vec_uint4 select1 ); + +/* + * Load four three-float 3-D vectors, stored in three quadwords + */ +static inline void vmathSoaV3LoadXYZArray_V( VmathSoaVector3 *vec, const vec_float4 *threeQuads ); + +/* + * Store four slots of an SoA 3-D vector in three quadwords + */ +static inline void vmathSoaV3StoreXYZArray_V( VmathSoaVector3 vec, vec_float4 *threeQuads ); + +/* + * Store eight slots of two SoA 3-D vectors as half-floats + */ +static inline void vmathSoaV3StoreHalfFloats_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1, vec_ushort8 *threeQuads ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3-D vector + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaV3Print_V( VmathSoaVector3 vec ); + +/* + * Print a 3-D vector and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaV3Prints_V( VmathSoaVector3 vec, const char *name ); + +#endif + +/* + * Construct a 4-D vector from x, y, z, and w elements + */ +static inline VmathSoaVector4 vmathSoaV4MakeFromElems_V( vec_float4 x, vec_float4 y, vec_float4 z, vec_float4 w ); + +/* + * Construct a 4-D vector from a 3-D vector and a scalar + */ +static inline VmathSoaVector4 vmathSoaV4MakeFromV3Scalar_V( VmathSoaVector3 xyz, vec_float4 w ); + +/* + * Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0 + */ +static inline VmathSoaVector4 vmathSoaV4MakeFromV3_V( VmathSoaVector3 vec ); + +/* + * Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1 + */ +static inline VmathSoaVector4 vmathSoaV4MakeFromP3_V( VmathSoaPoint3 pnt ); + +/* + * Copy elements from a quaternion into a 4-D vector + */ +static inline VmathSoaVector4 vmathSoaV4MakeFromQ_V( VmathSoaQuat quat ); + +/* + * Set all elements of a 4-D vector to the same scalar value + */ +static inline VmathSoaVector4 vmathSoaV4MakeFromScalar_V( vec_float4 scalar ); + +/* + * Replicate an AoS 4-D vector + */ +static inline VmathSoaVector4 vmathSoaV4MakeFromAos_V( VmathVector4 vec ); + +/* + * Insert four AoS 4-D vectors + */ +static inline VmathSoaVector4 vmathSoaV4MakeFrom4Aos_V( VmathVector4 vec0, VmathVector4 vec1, VmathVector4 vec2, VmathVector4 vec3 ); + +/* + * Extract four AoS 4-D vectors + */ +static inline void vmathSoaV4Get4Aos_V( VmathSoaVector4 vec, VmathVector4 *result0, VmathVector4 *result1, VmathVector4 *result2, VmathVector4 *result3 ); + +/* + * Set the x, y, and z elements of a 4-D vector + * NOTE: + * This function does not change the w element. + */ +static inline void vmathSoaV4SetXYZ_V( VmathSoaVector4 *result, VmathSoaVector3 vec ); + +/* + * Get the x, y, and z elements of a 4-D vector + */ +static inline VmathSoaVector3 vmathSoaV4GetXYZ_V( VmathSoaVector4 vec ); + +/* + * Set the x element of a 4-D vector + */ +static inline void vmathSoaV4SetX_V( VmathSoaVector4 *result, vec_float4 x ); + +/* + * Set the y element of a 4-D vector + */ +static inline void vmathSoaV4SetY_V( VmathSoaVector4 *result, vec_float4 y ); + +/* + * Set the z element of a 4-D vector + */ +static inline void vmathSoaV4SetZ_V( VmathSoaVector4 *result, vec_float4 z ); + +/* + * Set the w element of a 4-D vector + */ +static inline void vmathSoaV4SetW_V( VmathSoaVector4 *result, vec_float4 w ); + +/* + * Get the x element of a 4-D vector + */ +static inline vec_float4 vmathSoaV4GetX_V( VmathSoaVector4 vec ); + +/* + * Get the y element of a 4-D vector + */ +static inline vec_float4 vmathSoaV4GetY_V( VmathSoaVector4 vec ); + +/* + * Get the z element of a 4-D vector + */ +static inline vec_float4 vmathSoaV4GetZ_V( VmathSoaVector4 vec ); + +/* + * Get the w element of a 4-D vector + */ +static inline vec_float4 vmathSoaV4GetW_V( VmathSoaVector4 vec ); + +/* + * Set an x, y, z, or w element of a 4-D vector by index + */ +static inline void vmathSoaV4SetElem_V( VmathSoaVector4 *result, int idx, vec_float4 value ); + +/* + * Get an x, y, z, or w element of a 4-D vector by index + */ +static inline vec_float4 vmathSoaV4GetElem_V( VmathSoaVector4 vec, int idx ); + +/* + * Add two 4-D vectors + */ +static inline VmathSoaVector4 vmathSoaV4Add_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); + +/* + * Subtract a 4-D vector from another 4-D vector + */ +static inline VmathSoaVector4 vmathSoaV4Sub_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); + +/* + * Multiply a 4-D vector by a scalar + */ +static inline VmathSoaVector4 vmathSoaV4ScalarMul_V( VmathSoaVector4 vec, vec_float4 scalar ); + +/* + * Divide a 4-D vector by a scalar + */ +static inline VmathSoaVector4 vmathSoaV4ScalarDiv_V( VmathSoaVector4 vec, vec_float4 scalar ); + +/* + * Negate all elements of a 4-D vector + */ +static inline VmathSoaVector4 vmathSoaV4Neg_V( VmathSoaVector4 vec ); + +/* + * Construct x axis + */ +static inline VmathSoaVector4 vmathSoaV4MakeXAxis_V( ); + +/* + * Construct y axis + */ +static inline VmathSoaVector4 vmathSoaV4MakeYAxis_V( ); + +/* + * Construct z axis + */ +static inline VmathSoaVector4 vmathSoaV4MakeZAxis_V( ); + +/* + * Construct w axis + */ +static inline VmathSoaVector4 vmathSoaV4MakeWAxis_V( ); + +/* + * Multiply two 4-D vectors per element + */ +static inline VmathSoaVector4 vmathSoaV4MulPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); + +/* + * Divide two 4-D vectors per element + * NOTE: + * Floating-point behavior matches standard library function divf4. + */ +static inline VmathSoaVector4 vmathSoaV4DivPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); + +/* + * Compute the reciprocal of a 4-D vector per element + * NOTE: + * Floating-point behavior matches standard library function recipf4. + */ +static inline VmathSoaVector4 vmathSoaV4RecipPerElem_V( VmathSoaVector4 vec ); + +/* + * Compute the square root of a 4-D vector per element + * NOTE: + * Floating-point behavior matches standard library function sqrtf4. + */ +static inline VmathSoaVector4 vmathSoaV4SqrtPerElem_V( VmathSoaVector4 vec ); + +/* + * Compute the reciprocal square root of a 4-D vector per element + * NOTE: + * Floating-point behavior matches standard library function rsqrtf4. + */ +static inline VmathSoaVector4 vmathSoaV4RsqrtPerElem_V( VmathSoaVector4 vec ); + +/* + * Compute the absolute value of a 4-D vector per element + */ +static inline VmathSoaVector4 vmathSoaV4AbsPerElem_V( VmathSoaVector4 vec ); + +/* + * Copy sign from one 4-D vector to another, per element + */ +static inline VmathSoaVector4 vmathSoaV4CopySignPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); + +/* + * Maximum of two 4-D vectors per element + */ +static inline VmathSoaVector4 vmathSoaV4MaxPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); + +/* + * Minimum of two 4-D vectors per element + */ +static inline VmathSoaVector4 vmathSoaV4MinPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); + +/* + * Maximum element of a 4-D vector + */ +static inline vec_float4 vmathSoaV4MaxElem_V( VmathSoaVector4 vec ); + +/* + * Minimum element of a 4-D vector + */ +static inline vec_float4 vmathSoaV4MinElem_V( VmathSoaVector4 vec ); + +/* + * Compute the sum of all elements of a 4-D vector + */ +static inline vec_float4 vmathSoaV4Sum_V( VmathSoaVector4 vec ); + +/* + * Compute the dot product of two 4-D vectors + */ +static inline vec_float4 vmathSoaV4Dot_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); + +/* + * Compute the square of the length of a 4-D vector + */ +static inline vec_float4 vmathSoaV4LengthSqr_V( VmathSoaVector4 vec ); + +/* + * Compute the length of a 4-D vector + */ +static inline vec_float4 vmathSoaV4Length_V( VmathSoaVector4 vec ); + +/* + * Normalize a 4-D vector + * NOTE: + * The result is unpredictable when all elements of vec are at or near zero. + */ +static inline VmathSoaVector4 vmathSoaV4Normalize_V( VmathSoaVector4 vec ); + +/* + * Outer product of two 4-D vectors + */ +static inline VmathSoaMatrix4 vmathSoaV4Outer_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); + +/* + * Linear interpolation between two 4-D vectors + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline VmathSoaVector4 vmathSoaV4Lerp_V( vec_float4 t, VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); + +/* + * Spherical linear interpolation between two 4-D vectors + * NOTE: + * The result is unpredictable if the vectors point in opposite directions. + * Does not clamp t between 0 and 1. + */ +static inline VmathSoaVector4 vmathSoaV4Slerp_V( vec_float4 t, VmathSoaVector4 unitVec0, VmathSoaVector4 unitVec1 ); + +/* + * Conditionally select between two 4-D vectors + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline VmathSoaVector4 vmathSoaV4Select_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1, vec_uint4 select1 ); + +/* + * Store four slots of an SoA 4-D vector as half-floats + */ +static inline void vmathSoaV4StoreHalfFloats_V( VmathSoaVector4 vec, vec_ushort8 *twoQuads ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 4-D vector + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaV4Print_V( VmathSoaVector4 vec ); + +/* + * Print a 4-D vector and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaV4Prints_V( VmathSoaVector4 vec, const char *name ); + +#endif + +/* + * Construct a 3-D point from x, y, and z elements + */ +static inline VmathSoaPoint3 vmathSoaP3MakeFromElems_V( vec_float4 x, vec_float4 y, vec_float4 z ); + +/* + * Copy elements from a 3-D vector into a 3-D point + */ +static inline VmathSoaPoint3 vmathSoaP3MakeFromV3_V( VmathSoaVector3 vec ); + +/* + * Set all elements of a 3-D point to the same scalar value + */ +static inline VmathSoaPoint3 vmathSoaP3MakeFromScalar_V( vec_float4 scalar ); + +/* + * Replicate an AoS 3-D point + */ +static inline VmathSoaPoint3 vmathSoaP3MakeFromAos_V( VmathPoint3 pnt ); + +/* + * Insert four AoS 3-D points + */ +static inline VmathSoaPoint3 vmathSoaP3MakeFrom4Aos_V( VmathPoint3 pnt0, VmathPoint3 pnt1, VmathPoint3 pnt2, VmathPoint3 pnt3 ); + +/* + * Extract four AoS 3-D points + */ +static inline void vmathSoaP3Get4Aos_V( VmathSoaPoint3 pnt, VmathPoint3 *result0, VmathPoint3 *result1, VmathPoint3 *result2, VmathPoint3 *result3 ); + +/* + * Set the x element of a 3-D point + */ +static inline void vmathSoaP3SetX_V( VmathSoaPoint3 *result, vec_float4 x ); + +/* + * Set the y element of a 3-D point + */ +static inline void vmathSoaP3SetY_V( VmathSoaPoint3 *result, vec_float4 y ); + +/* + * Set the z element of a 3-D point + */ +static inline void vmathSoaP3SetZ_V( VmathSoaPoint3 *result, vec_float4 z ); + +/* + * Get the x element of a 3-D point + */ +static inline vec_float4 vmathSoaP3GetX_V( VmathSoaPoint3 pnt ); + +/* + * Get the y element of a 3-D point + */ +static inline vec_float4 vmathSoaP3GetY_V( VmathSoaPoint3 pnt ); + +/* + * Get the z element of a 3-D point + */ +static inline vec_float4 vmathSoaP3GetZ_V( VmathSoaPoint3 pnt ); + +/* + * Set an x, y, or z element of a 3-D point by index + */ +static inline void vmathSoaP3SetElem_V( VmathSoaPoint3 *result, int idx, vec_float4 value ); + +/* + * Get an x, y, or z element of a 3-D point by index + */ +static inline vec_float4 vmathSoaP3GetElem_V( VmathSoaPoint3 pnt, int idx ); + +/* + * Subtract a 3-D point from another 3-D point + */ +static inline VmathSoaVector3 vmathSoaP3Sub_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ); + +/* + * Add a 3-D point to a 3-D vector + */ +static inline VmathSoaPoint3 vmathSoaP3AddV3_V( VmathSoaPoint3 pnt, VmathSoaVector3 vec ); + +/* + * Subtract a 3-D vector from a 3-D point + */ +static inline VmathSoaPoint3 vmathSoaP3SubV3_V( VmathSoaPoint3 pnt, VmathSoaVector3 vec ); + +/* + * Multiply two 3-D points per element + */ +static inline VmathSoaPoint3 vmathSoaP3MulPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ); + +/* + * Divide two 3-D points per element + * NOTE: + * Floating-point behavior matches standard library function divf4. + */ +static inline VmathSoaPoint3 vmathSoaP3DivPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ); + +/* + * Compute the reciprocal of a 3-D point per element + * NOTE: + * Floating-point behavior matches standard library function recipf4. + */ +static inline VmathSoaPoint3 vmathSoaP3RecipPerElem_V( VmathSoaPoint3 pnt ); + +/* + * Compute the square root of a 3-D point per element + * NOTE: + * Floating-point behavior matches standard library function sqrtf4. + */ +static inline VmathSoaPoint3 vmathSoaP3SqrtPerElem_V( VmathSoaPoint3 pnt ); + +/* + * Compute the reciprocal square root of a 3-D point per element + * NOTE: + * Floating-point behavior matches standard library function rsqrtf4. + */ +static inline VmathSoaPoint3 vmathSoaP3RsqrtPerElem_V( VmathSoaPoint3 pnt ); + +/* + * Compute the absolute value of a 3-D point per element + */ +static inline VmathSoaPoint3 vmathSoaP3AbsPerElem_V( VmathSoaPoint3 pnt ); + +/* + * Copy sign from one 3-D point to another, per element + */ +static inline VmathSoaPoint3 vmathSoaP3CopySignPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ); + +/* + * Maximum of two 3-D points per element + */ +static inline VmathSoaPoint3 vmathSoaP3MaxPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ); + +/* + * Minimum of two 3-D points per element + */ +static inline VmathSoaPoint3 vmathSoaP3MinPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ); + +/* + * Maximum element of a 3-D point + */ +static inline vec_float4 vmathSoaP3MaxElem_V( VmathSoaPoint3 pnt ); + +/* + * Minimum element of a 3-D point + */ +static inline vec_float4 vmathSoaP3MinElem_V( VmathSoaPoint3 pnt ); + +/* + * Compute the sum of all elements of a 3-D point + */ +static inline vec_float4 vmathSoaP3Sum_V( VmathSoaPoint3 pnt ); + +/* + * Apply uniform scale to a 3-D point + */ +static inline VmathSoaPoint3 vmathSoaP3Scale_V( VmathSoaPoint3 pnt, vec_float4 scaleVal ); + +/* + * Apply non-uniform scale to a 3-D point + */ +static inline VmathSoaPoint3 vmathSoaP3NonUniformScale_V( VmathSoaPoint3 pnt, VmathSoaVector3 scaleVec ); + +/* + * Scalar projection of a 3-D point on a unit-length 3-D vector + */ +static inline vec_float4 vmathSoaP3Projection_V( VmathSoaPoint3 pnt, VmathSoaVector3 unitVec ); + +/* + * Compute the square of the distance of a 3-D point from the coordinate-system origin + */ +static inline vec_float4 vmathSoaP3DistSqrFromOrigin_V( VmathSoaPoint3 pnt ); + +/* + * Compute the distance of a 3-D point from the coordinate-system origin + */ +static inline vec_float4 vmathSoaP3DistFromOrigin_V( VmathSoaPoint3 pnt ); + +/* + * Compute the square of the distance between two 3-D points + */ +static inline vec_float4 vmathSoaP3DistSqr_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ); + +/* + * Compute the distance between two 3-D points + */ +static inline vec_float4 vmathSoaP3Dist_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ); + +/* + * Linear interpolation between two 3-D points + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline VmathSoaPoint3 vmathSoaP3Lerp_V( vec_float4 t, VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ); + +/* + * Conditionally select between two 3-D points + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline VmathSoaPoint3 vmathSoaP3Select_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1, vec_uint4 select1 ); + +/* + * Load four three-float 3-D points, stored in three quadwords + */ +static inline void vmathSoaP3LoadXYZArray_V( VmathSoaPoint3 *pnt, const vec_float4 *threeQuads ); + +/* + * Store four slots of an SoA 3-D point in three quadwords + */ +static inline void vmathSoaP3StoreXYZArray_V( VmathSoaPoint3 pnt, vec_float4 *threeQuads ); + +/* + * Store eight slots of two SoA 3-D points as half-floats + */ +static inline void vmathSoaP3StoreHalfFloats_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1, vec_ushort8 *threeQuads ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3-D point + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaP3Print_V( VmathSoaPoint3 pnt ); + +/* + * Print a 3-D point and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaP3Prints_V( VmathSoaPoint3 pnt, const char *name ); + +#endif + +/* + * Construct a quaternion from x, y, z, and w elements + */ +static inline VmathSoaQuat vmathSoaQMakeFromElems_V( vec_float4 x, vec_float4 y, vec_float4 z, vec_float4 w ); + +/* + * Construct a quaternion from a 3-D vector and a scalar + */ +static inline VmathSoaQuat vmathSoaQMakeFromV3Scalar_V( VmathSoaVector3 xyz, vec_float4 w ); + +/* + * Copy elements from a 4-D vector into a quaternion + */ +static inline VmathSoaQuat vmathSoaQMakeFromV4_V( VmathSoaVector4 vec ); + +/* + * Convert a rotation matrix to a unit-length quaternion + */ +static inline VmathSoaQuat vmathSoaQMakeFromM3_V( VmathSoaMatrix3 rotMat ); + +/* + * Set all elements of a quaternion to the same scalar value + */ +static inline VmathSoaQuat vmathSoaQMakeFromScalar_V( vec_float4 scalar ); + +/* + * Replicate an AoS quaternion + */ +static inline VmathSoaQuat vmathSoaQMakeFromAos_V( VmathQuat quat ); + +/* + * Insert four AoS quaternions + */ +static inline VmathSoaQuat vmathSoaQMakeFrom4Aos_V( VmathQuat quat0, VmathQuat quat1, VmathQuat quat2, VmathQuat quat3 ); + +/* + * Extract four AoS quaternions + */ +static inline void vmathSoaQGet4Aos_V( VmathSoaQuat quat, VmathQuat *result0, VmathQuat *result1, VmathQuat *result2, VmathQuat *result3 ); + +/* + * Set the x, y, and z elements of a quaternion + * NOTE: + * This function does not change the w element. + */ +static inline void vmathSoaQSetXYZ_V( VmathSoaQuat *result, VmathSoaVector3 vec ); + +/* + * Get the x, y, and z elements of a quaternion + */ +static inline VmathSoaVector3 vmathSoaQGetXYZ_V( VmathSoaQuat quat ); + +/* + * Set the x element of a quaternion + */ +static inline void vmathSoaQSetX_V( VmathSoaQuat *result, vec_float4 x ); + +/* + * Set the y element of a quaternion + */ +static inline void vmathSoaQSetY_V( VmathSoaQuat *result, vec_float4 y ); + +/* + * Set the z element of a quaternion + */ +static inline void vmathSoaQSetZ_V( VmathSoaQuat *result, vec_float4 z ); + +/* + * Set the w element of a quaternion + */ +static inline void vmathSoaQSetW_V( VmathSoaQuat *result, vec_float4 w ); + +/* + * Get the x element of a quaternion + */ +static inline vec_float4 vmathSoaQGetX_V( VmathSoaQuat quat ); + +/* + * Get the y element of a quaternion + */ +static inline vec_float4 vmathSoaQGetY_V( VmathSoaQuat quat ); + +/* + * Get the z element of a quaternion + */ +static inline vec_float4 vmathSoaQGetZ_V( VmathSoaQuat quat ); + +/* + * Get the w element of a quaternion + */ +static inline vec_float4 vmathSoaQGetW_V( VmathSoaQuat quat ); + +/* + * Set an x, y, z, or w element of a quaternion by index + */ +static inline void vmathSoaQSetElem_V( VmathSoaQuat *result, int idx, vec_float4 value ); + +/* + * Get an x, y, z, or w element of a quaternion by index + */ +static inline vec_float4 vmathSoaQGetElem_V( VmathSoaQuat quat, int idx ); + +/* + * Add two quaternions + */ +static inline VmathSoaQuat vmathSoaQAdd_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ); + +/* + * Subtract a quaternion from another quaternion + */ +static inline VmathSoaQuat vmathSoaQSub_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ); + +/* + * Multiply two quaternions + */ +static inline VmathSoaQuat vmathSoaQMul_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ); + +/* + * Multiply a quaternion by a scalar + */ +static inline VmathSoaQuat vmathSoaQScalarMul_V( VmathSoaQuat quat, vec_float4 scalar ); + +/* + * Divide a quaternion by a scalar + */ +static inline VmathSoaQuat vmathSoaQScalarDiv_V( VmathSoaQuat quat, vec_float4 scalar ); + +/* + * Negate all elements of a quaternion + */ +static inline VmathSoaQuat vmathSoaQNeg_V( VmathSoaQuat quat ); + +/* + * Construct an identity quaternion + */ +static inline VmathSoaQuat vmathSoaQMakeIdentity_V( ); + +/* + * Construct a quaternion to rotate between two unit-length 3-D vectors + * NOTE: + * The result is unpredictable if unitVec0 and unitVec1 point in opposite directions. + */ +static inline VmathSoaQuat vmathSoaQMakeRotationArc_V( VmathSoaVector3 unitVec0, VmathSoaVector3 unitVec1 ); + +/* + * Construct a quaternion to rotate around a unit-length 3-D vector + */ +static inline VmathSoaQuat vmathSoaQMakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec ); + +/* + * Construct a quaternion to rotate around the x axis + */ +static inline VmathSoaQuat vmathSoaQMakeRotationX_V( vec_float4 radians ); + +/* + * Construct a quaternion to rotate around the y axis + */ +static inline VmathSoaQuat vmathSoaQMakeRotationY_V( vec_float4 radians ); + +/* + * Construct a quaternion to rotate around the z axis + */ +static inline VmathSoaQuat vmathSoaQMakeRotationZ_V( vec_float4 radians ); + +/* + * Compute the conjugate of a quaternion + */ +static inline VmathSoaQuat vmathSoaQConj_V( VmathSoaQuat quat ); + +/* + * Use a unit-length quaternion to rotate a 3-D vector + */ +static inline VmathSoaVector3 vmathSoaQRotate_V( VmathSoaQuat unitQuat, VmathSoaVector3 vec ); + +/* + * Compute the dot product of two quaternions + */ +static inline vec_float4 vmathSoaQDot_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ); + +/* + * Compute the norm of a quaternion + */ +static inline vec_float4 vmathSoaQNorm_V( VmathSoaQuat quat ); + +/* + * Compute the length of a quaternion + */ +static inline vec_float4 vmathSoaQLength_V( VmathSoaQuat quat ); + +/* + * Normalize a quaternion + * NOTE: + * The result is unpredictable when all elements of quat are at or near zero. + */ +static inline VmathSoaQuat vmathSoaQNormalize_V( VmathSoaQuat quat ); + +/* + * Linear interpolation between two quaternions + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline VmathSoaQuat vmathSoaQLerp_V( vec_float4 t, VmathSoaQuat quat0, VmathSoaQuat quat1 ); + +/* + * Spherical linear interpolation between two quaternions + * NOTE: + * Interpolates along the shortest path between orientations. + * Does not clamp t between 0 and 1. + */ +static inline VmathSoaQuat vmathSoaQSlerp_V( vec_float4 t, VmathSoaQuat unitQuat0, VmathSoaQuat unitQuat1 ); + +/* + * Spherical quadrangle interpolation + */ +static inline VmathSoaQuat vmathSoaQSquad_V( vec_float4 t, VmathSoaQuat unitQuat0, VmathSoaQuat unitQuat1, VmathSoaQuat unitQuat2, VmathSoaQuat unitQuat3 ); + +/* + * Conditionally select between two quaternions + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline VmathSoaQuat vmathSoaQSelect_V( VmathSoaQuat quat0, VmathSoaQuat quat1, vec_uint4 select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a quaternion + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaQPrint_V( VmathSoaQuat quat ); + +/* + * Print a quaternion and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaQPrints_V( VmathSoaQuat quat, const char *name ); + +#endif + +/* + * Construct a 3x3 matrix containing the specified columns + */ +static inline VmathSoaMatrix3 vmathSoaM3MakeFromCols_V( VmathSoaVector3 col0, VmathSoaVector3 col1, VmathSoaVector3 col2 ); + +/* + * Construct a 3x3 rotation matrix from a unit-length quaternion + */ +static inline VmathSoaMatrix3 vmathSoaM3MakeFromQ_V( VmathSoaQuat unitQuat ); + +/* + * Set all elements of a 3x3 matrix to the same scalar value + */ +static inline VmathSoaMatrix3 vmathSoaM3MakeFromScalar_V( vec_float4 scalar ); + +/* + * Replicate an AoS 3x3 matrix + */ +static inline VmathSoaMatrix3 vmathSoaM3MakeFromAos_V( VmathMatrix3 mat ); + +/* + * Insert four AoS 3x3 matrices + */ +static inline VmathSoaMatrix3 vmathSoaM3MakeFrom4Aos_V( VmathMatrix3 mat0, VmathMatrix3 mat1, VmathMatrix3 mat2, VmathMatrix3 mat3 ); + +/* + * Extract four AoS 3x3 matrices + */ +static inline void vmathSoaM3Get4Aos_V( VmathSoaMatrix3 mat, VmathMatrix3 *result0, VmathMatrix3 *result1, VmathMatrix3 *result2, VmathMatrix3 *result3 ); + +/* + * Set column 0 of a 3x3 matrix + */ +static inline void vmathSoaM3SetCol0_V( VmathSoaMatrix3 *result, VmathSoaVector3 col0 ); + +/* + * Set column 1 of a 3x3 matrix + */ +static inline void vmathSoaM3SetCol1_V( VmathSoaMatrix3 *result, VmathSoaVector3 col1 ); + +/* + * Set column 2 of a 3x3 matrix + */ +static inline void vmathSoaM3SetCol2_V( VmathSoaMatrix3 *result, VmathSoaVector3 col2 ); + +/* + * Get column 0 of a 3x3 matrix + */ +static inline VmathSoaVector3 vmathSoaM3GetCol0_V( VmathSoaMatrix3 mat ); + +/* + * Get column 1 of a 3x3 matrix + */ +static inline VmathSoaVector3 vmathSoaM3GetCol1_V( VmathSoaMatrix3 mat ); + +/* + * Get column 2 of a 3x3 matrix + */ +static inline VmathSoaVector3 vmathSoaM3GetCol2_V( VmathSoaMatrix3 mat ); + +/* + * Set the column of a 3x3 matrix referred to by the specified index + */ +static inline void vmathSoaM3SetCol_V( VmathSoaMatrix3 *result, int col, VmathSoaVector3 vec ); + +/* + * Set the row of a 3x3 matrix referred to by the specified index + */ +static inline void vmathSoaM3SetRow_V( VmathSoaMatrix3 *result, int row, VmathSoaVector3 vec ); + +/* + * Get the column of a 3x3 matrix referred to by the specified index + */ +static inline VmathSoaVector3 vmathSoaM3GetCol_V( VmathSoaMatrix3 mat, int col ); + +/* + * Get the row of a 3x3 matrix referred to by the specified index + */ +static inline VmathSoaVector3 vmathSoaM3GetRow_V( VmathSoaMatrix3 mat, int row ); + +/* + * Set the element of a 3x3 matrix referred to by column and row indices + */ +static inline void vmathSoaM3SetElem_V( VmathSoaMatrix3 *result, int col, int row, vec_float4 val ); + +/* + * Get the element of a 3x3 matrix referred to by column and row indices + */ +static inline vec_float4 vmathSoaM3GetElem_V( VmathSoaMatrix3 mat, int col, int row ); + +/* + * Add two 3x3 matrices + */ +static inline VmathSoaMatrix3 vmathSoaM3Add_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1 ); + +/* + * Subtract a 3x3 matrix from another 3x3 matrix + */ +static inline VmathSoaMatrix3 vmathSoaM3Sub_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1 ); + +/* + * Negate all elements of a 3x3 matrix + */ +static inline VmathSoaMatrix3 vmathSoaM3Neg_V( VmathSoaMatrix3 mat ); + +/* + * Multiply a 3x3 matrix by a scalar + */ +static inline VmathSoaMatrix3 vmathSoaM3ScalarMul_V( VmathSoaMatrix3 mat, vec_float4 scalar ); + +/* + * Multiply a 3x3 matrix by a 3-D vector + */ +static inline VmathSoaVector3 vmathSoaM3MulV3_V( VmathSoaMatrix3 mat, VmathSoaVector3 vec ); + +/* + * Multiply two 3x3 matrices + */ +static inline VmathSoaMatrix3 vmathSoaM3Mul_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1 ); + +/* + * Construct an identity 3x3 matrix + */ +static inline VmathSoaMatrix3 vmathSoaM3MakeIdentity_V( ); + +/* + * Construct a 3x3 matrix to rotate around the x axis + */ +static inline VmathSoaMatrix3 vmathSoaM3MakeRotationX_V( vec_float4 radians ); + +/* + * Construct a 3x3 matrix to rotate around the y axis + */ +static inline VmathSoaMatrix3 vmathSoaM3MakeRotationY_V( vec_float4 radians ); + +/* + * Construct a 3x3 matrix to rotate around the z axis + */ +static inline VmathSoaMatrix3 vmathSoaM3MakeRotationZ_V( vec_float4 radians ); + +/* + * Construct a 3x3 matrix to rotate around the x, y, and z axes + */ +static inline VmathSoaMatrix3 vmathSoaM3MakeRotationZYX_V( VmathSoaVector3 radiansXYZ ); + +/* + * Construct a 3x3 matrix to rotate around a unit-length 3-D vector + */ +static inline VmathSoaMatrix3 vmathSoaM3MakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec ); + +/* + * Construct a rotation matrix from a unit-length quaternion + */ +static inline VmathSoaMatrix3 vmathSoaM3MakeRotationQ_V( VmathSoaQuat unitQuat ); + +/* + * Construct a 3x3 matrix to perform scaling + */ +static inline VmathSoaMatrix3 vmathSoaM3MakeScale_V( VmathSoaVector3 scaleVec ); + +/* + * Append (post-multiply) a scale transformation to a 3x3 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline VmathSoaMatrix3 vmathSoaM3AppendScale_V( VmathSoaMatrix3 mat, VmathSoaVector3 scaleVec ); + +/* + * Prepend (pre-multiply) a scale transformation to a 3x3 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline VmathSoaMatrix3 vmathSoaM3PrependScale_V( VmathSoaVector3 scaleVec, VmathSoaMatrix3 mat ); + +/* + * Multiply two 3x3 matrices per element + */ +static inline VmathSoaMatrix3 vmathSoaM3MulPerElem_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1 ); + +/* + * Compute the absolute value of a 3x3 matrix per element + */ +static inline VmathSoaMatrix3 vmathSoaM3AbsPerElem_V( VmathSoaMatrix3 mat ); + +/* + * Transpose of a 3x3 matrix + */ +static inline VmathSoaMatrix3 vmathSoaM3Transpose_V( VmathSoaMatrix3 mat ); + +/* + * Compute the inverse of a 3x3 matrix + * NOTE: + * Result is unpredictable when the determinant of mat is equal to or near 0. + */ +static inline VmathSoaMatrix3 vmathSoaM3Inverse_V( VmathSoaMatrix3 mat ); + +/* + * Determinant of a 3x3 matrix + */ +static inline vec_float4 vmathSoaM3Determinant_V( VmathSoaMatrix3 mat ); + +/* + * Conditionally select between two 3x3 matrices + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline VmathSoaMatrix3 vmathSoaM3Select_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1, vec_uint4 select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3x3 matrix + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaM3Print_V( VmathSoaMatrix3 mat ); + +/* + * Print a 3x3 matrix and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaM3Prints_V( VmathSoaMatrix3 mat, const char *name ); + +#endif + +/* + * Construct a 4x4 matrix containing the specified columns + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeFromCols_V( VmathSoaVector4 col0, VmathSoaVector4 col1, VmathSoaVector4 col2, VmathSoaVector4 col3 ); + +/* + * Construct a 4x4 matrix from a 3x4 transformation matrix + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeFromT3_V( VmathSoaTransform3 mat ); + +/* + * Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeFromM3V3_V( VmathSoaMatrix3 mat, VmathSoaVector3 translateVec ); + +/* + * Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeFromQV3_V( VmathSoaQuat unitQuat, VmathSoaVector3 translateVec ); + +/* + * Set all elements of a 4x4 matrix to the same scalar value + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeFromScalar_V( vec_float4 scalar ); + +/* + * Replicate an AoS 4x4 matrix + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeFromAos_V( VmathMatrix4 mat ); + +/* + * Insert four AoS 4x4 matrices + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeFrom4Aos_V( VmathMatrix4 mat0, VmathMatrix4 mat1, VmathMatrix4 mat2, VmathMatrix4 mat3 ); + +/* + * Extract four AoS 4x4 matrices + */ +static inline void vmathSoaM4Get4Aos_V( VmathSoaMatrix4 mat, VmathMatrix4 *result0, VmathMatrix4 *result1, VmathMatrix4 *result2, VmathMatrix4 *result3 ); + +/* + * Set the upper-left 3x3 submatrix + * NOTE: + * This function does not change the bottom row elements. + */ +static inline void vmathSoaM4SetUpper3x3_V( VmathSoaMatrix4 *result, VmathSoaMatrix3 mat3 ); + +/* + * Get the upper-left 3x3 submatrix of a 4x4 matrix + */ +static inline VmathSoaMatrix3 vmathSoaM4GetUpper3x3_V( VmathSoaMatrix4 mat ); + +/* + * Set translation component + * NOTE: + * This function does not change the bottom row elements. + */ +static inline void vmathSoaM4SetTranslation_V( VmathSoaMatrix4 *result, VmathSoaVector3 translateVec ); + +/* + * Get the translation component of a 4x4 matrix + */ +static inline VmathSoaVector3 vmathSoaM4GetTranslation_V( VmathSoaMatrix4 mat ); + +/* + * Set column 0 of a 4x4 matrix + */ +static inline void vmathSoaM4SetCol0_V( VmathSoaMatrix4 *result, VmathSoaVector4 col0 ); + +/* + * Set column 1 of a 4x4 matrix + */ +static inline void vmathSoaM4SetCol1_V( VmathSoaMatrix4 *result, VmathSoaVector4 col1 ); + +/* + * Set column 2 of a 4x4 matrix + */ +static inline void vmathSoaM4SetCol2_V( VmathSoaMatrix4 *result, VmathSoaVector4 col2 ); + +/* + * Set column 3 of a 4x4 matrix + */ +static inline void vmathSoaM4SetCol3_V( VmathSoaMatrix4 *result, VmathSoaVector4 col3 ); + +/* + * Get column 0 of a 4x4 matrix + */ +static inline VmathSoaVector4 vmathSoaM4GetCol0_V( VmathSoaMatrix4 mat ); + +/* + * Get column 1 of a 4x4 matrix + */ +static inline VmathSoaVector4 vmathSoaM4GetCol1_V( VmathSoaMatrix4 mat ); + +/* + * Get column 2 of a 4x4 matrix + */ +static inline VmathSoaVector4 vmathSoaM4GetCol2_V( VmathSoaMatrix4 mat ); + +/* + * Get column 3 of a 4x4 matrix + */ +static inline VmathSoaVector4 vmathSoaM4GetCol3_V( VmathSoaMatrix4 mat ); + +/* + * Set the column of a 4x4 matrix referred to by the specified index + */ +static inline void vmathSoaM4SetCol_V( VmathSoaMatrix4 *result, int col, VmathSoaVector4 vec ); + +/* + * Set the row of a 4x4 matrix referred to by the specified index + */ +static inline void vmathSoaM4SetRow_V( VmathSoaMatrix4 *result, int row, VmathSoaVector4 vec ); + +/* + * Get the column of a 4x4 matrix referred to by the specified index + */ +static inline VmathSoaVector4 vmathSoaM4GetCol_V( VmathSoaMatrix4 mat, int col ); + +/* + * Get the row of a 4x4 matrix referred to by the specified index + */ +static inline VmathSoaVector4 vmathSoaM4GetRow_V( VmathSoaMatrix4 mat, int row ); + +/* + * Set the element of a 4x4 matrix referred to by column and row indices + */ +static inline void vmathSoaM4SetElem_V( VmathSoaMatrix4 *result, int col, int row, vec_float4 val ); + +/* + * Get the element of a 4x4 matrix referred to by column and row indices + */ +static inline vec_float4 vmathSoaM4GetElem_V( VmathSoaMatrix4 mat, int col, int row ); + +/* + * Add two 4x4 matrices + */ +static inline VmathSoaMatrix4 vmathSoaM4Add_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1 ); + +/* + * Subtract a 4x4 matrix from another 4x4 matrix + */ +static inline VmathSoaMatrix4 vmathSoaM4Sub_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1 ); + +/* + * Negate all elements of a 4x4 matrix + */ +static inline VmathSoaMatrix4 vmathSoaM4Neg_V( VmathSoaMatrix4 mat ); + +/* + * Multiply a 4x4 matrix by a scalar + */ +static inline VmathSoaMatrix4 vmathSoaM4ScalarMul_V( VmathSoaMatrix4 mat, vec_float4 scalar ); + +/* + * Multiply a 4x4 matrix by a 4-D vector + */ +static inline VmathSoaVector4 vmathSoaM4MulV4_V( VmathSoaMatrix4 mat, VmathSoaVector4 vec ); + +/* + * Multiply a 4x4 matrix by a 3-D vector + */ +static inline VmathSoaVector4 vmathSoaM4MulV3_V( VmathSoaMatrix4 mat, VmathSoaVector3 vec ); + +/* + * Multiply a 4x4 matrix by a 3-D point + */ +static inline VmathSoaVector4 vmathSoaM4MulP3_V( VmathSoaMatrix4 mat, VmathSoaPoint3 pnt ); + +/* + * Multiply two 4x4 matrices + */ +static inline VmathSoaMatrix4 vmathSoaM4Mul_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1 ); + +/* + * Multiply a 4x4 matrix by a 3x4 transformation matrix + */ +static inline VmathSoaMatrix4 vmathSoaM4MulT3_V( VmathSoaMatrix4 mat, VmathSoaTransform3 tfrm ); + +/* + * Construct an identity 4x4 matrix + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeIdentity_V( ); + +/* + * Construct a 4x4 matrix to rotate around the x axis + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeRotationX_V( vec_float4 radians ); + +/* + * Construct a 4x4 matrix to rotate around the y axis + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeRotationY_V( vec_float4 radians ); + +/* + * Construct a 4x4 matrix to rotate around the z axis + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeRotationZ_V( vec_float4 radians ); + +/* + * Construct a 4x4 matrix to rotate around the x, y, and z axes + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeRotationZYX_V( VmathSoaVector3 radiansXYZ ); + +/* + * Construct a 4x4 matrix to rotate around a unit-length 3-D vector + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec ); + +/* + * Construct a rotation matrix from a unit-length quaternion + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeRotationQ_V( VmathSoaQuat unitQuat ); + +/* + * Construct a 4x4 matrix to perform scaling + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeScale_V( VmathSoaVector3 scaleVec ); + +/* + * Construct a 4x4 matrix to perform translation + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeTranslation_V( VmathSoaVector3 translateVec ); + +/* + * Construct viewing matrix based on eye position, position looked at, and up direction + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeLookAt_V( VmathSoaPoint3 eyePos, VmathSoaPoint3 lookAtPos, VmathSoaVector3 upVec ); + +/* + * Construct a perspective projection matrix + */ +static inline VmathSoaMatrix4 vmathSoaM4MakePerspective_V( vec_float4 fovyRadians, vec_float4 aspect, vec_float4 zNear, vec_float4 zFar ); + +/* + * Construct a perspective projection matrix based on frustum + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeFrustum_V( vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ); + +/* + * Construct an orthographic projection matrix + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeOrthographic_V( vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ); + +/* + * Append (post-multiply) a scale transformation to a 4x4 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline VmathSoaMatrix4 vmathSoaM4AppendScale_V( VmathSoaMatrix4 mat, VmathSoaVector3 scaleVec ); + +/* + * Prepend (pre-multiply) a scale transformation to a 4x4 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline VmathSoaMatrix4 vmathSoaM4PrependScale_V( VmathSoaVector3 scaleVec, VmathSoaMatrix4 mat ); + +/* + * Multiply two 4x4 matrices per element + */ +static inline VmathSoaMatrix4 vmathSoaM4MulPerElem_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1 ); + +/* + * Compute the absolute value of a 4x4 matrix per element + */ +static inline VmathSoaMatrix4 vmathSoaM4AbsPerElem_V( VmathSoaMatrix4 mat ); + +/* + * Transpose of a 4x4 matrix + */ +static inline VmathSoaMatrix4 vmathSoaM4Transpose_V( VmathSoaMatrix4 mat ); + +/* + * Compute the inverse of a 4x4 matrix + * NOTE: + * Result is unpredictable when the determinant of mat is equal to or near 0. + */ +static inline VmathSoaMatrix4 vmathSoaM4Inverse_V( VmathSoaMatrix4 mat ); + +/* + * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix + * NOTE: + * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. The result is unpredictable when the determinant of mat is equal to or near 0. + */ +static inline VmathSoaMatrix4 vmathSoaM4AffineInverse_V( VmathSoaMatrix4 mat ); + +/* + * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix + * NOTE: + * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. + */ +static inline VmathSoaMatrix4 vmathSoaM4OrthoInverse_V( VmathSoaMatrix4 mat ); + +/* + * Determinant of a 4x4 matrix + */ +static inline vec_float4 vmathSoaM4Determinant_V( VmathSoaMatrix4 mat ); + +/* + * Conditionally select between two 4x4 matrices + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline VmathSoaMatrix4 vmathSoaM4Select_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1, vec_uint4 select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 4x4 matrix + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaM4Print_V( VmathSoaMatrix4 mat ); + +/* + * Print a 4x4 matrix and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaM4Prints_V( VmathSoaMatrix4 mat, const char *name ); + +#endif + +/* + * Construct a 3x4 transformation matrix containing the specified columns + */ +static inline VmathSoaTransform3 vmathSoaT3MakeFromCols_V( VmathSoaVector3 col0, VmathSoaVector3 col1, VmathSoaVector3 col2, VmathSoaVector3 col3 ); + +/* + * Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector + */ +static inline VmathSoaTransform3 vmathSoaT3MakeFromM3V3_V( VmathSoaMatrix3 tfrm, VmathSoaVector3 translateVec ); + +/* + * Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector + */ +static inline VmathSoaTransform3 vmathSoaT3MakeFromQV3_V( VmathSoaQuat unitQuat, VmathSoaVector3 translateVec ); + +/* + * Set all elements of a 3x4 transformation matrix to the same scalar value + */ +static inline VmathSoaTransform3 vmathSoaT3MakeFromScalar_V( vec_float4 scalar ); + +/* + * Replicate an AoS 3x4 transformation matrix + */ +static inline VmathSoaTransform3 vmathSoaT3MakeFromAos_V( VmathTransform3 tfrm ); + +/* + * Insert four AoS 3x4 transformation matrices + */ +static inline VmathSoaTransform3 vmathSoaT3MakeFrom4Aos_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1, VmathTransform3 tfrm2, VmathTransform3 tfrm3 ); + +/* + * Extract four AoS 3x4 transformation matrices + */ +static inline void vmathSoaT3Get4Aos_V( VmathSoaTransform3 tfrm, VmathTransform3 *result0, VmathTransform3 *result1, VmathTransform3 *result2, VmathTransform3 *result3 ); + +/* + * Set the upper-left 3x3 submatrix + */ +static inline void vmathSoaT3SetUpper3x3_V( VmathSoaTransform3 *result, VmathSoaMatrix3 mat3 ); + +/* + * Get the upper-left 3x3 submatrix of a 3x4 transformation matrix + */ +static inline VmathSoaMatrix3 vmathSoaT3GetUpper3x3_V( VmathSoaTransform3 tfrm ); + +/* + * Set translation component + */ +static inline void vmathSoaT3SetTranslation_V( VmathSoaTransform3 *result, VmathSoaVector3 translateVec ); + +/* + * Get the translation component of a 3x4 transformation matrix + */ +static inline VmathSoaVector3 vmathSoaT3GetTranslation_V( VmathSoaTransform3 tfrm ); + +/* + * Set column 0 of a 3x4 transformation matrix + */ +static inline void vmathSoaT3SetCol0_V( VmathSoaTransform3 *result, VmathSoaVector3 col0 ); + +/* + * Set column 1 of a 3x4 transformation matrix + */ +static inline void vmathSoaT3SetCol1_V( VmathSoaTransform3 *result, VmathSoaVector3 col1 ); + +/* + * Set column 2 of a 3x4 transformation matrix + */ +static inline void vmathSoaT3SetCol2_V( VmathSoaTransform3 *result, VmathSoaVector3 col2 ); + +/* + * Set column 3 of a 3x4 transformation matrix + */ +static inline void vmathSoaT3SetCol3_V( VmathSoaTransform3 *result, VmathSoaVector3 col3 ); + +/* + * Get column 0 of a 3x4 transformation matrix + */ +static inline VmathSoaVector3 vmathSoaT3GetCol0_V( VmathSoaTransform3 tfrm ); + +/* + * Get column 1 of a 3x4 transformation matrix + */ +static inline VmathSoaVector3 vmathSoaT3GetCol1_V( VmathSoaTransform3 tfrm ); + +/* + * Get column 2 of a 3x4 transformation matrix + */ +static inline VmathSoaVector3 vmathSoaT3GetCol2_V( VmathSoaTransform3 tfrm ); + +/* + * Get column 3 of a 3x4 transformation matrix + */ +static inline VmathSoaVector3 vmathSoaT3GetCol3_V( VmathSoaTransform3 tfrm ); + +/* + * Set the column of a 3x4 transformation matrix referred to by the specified index + */ +static inline void vmathSoaT3SetCol_V( VmathSoaTransform3 *result, int col, VmathSoaVector3 vec ); + +/* + * Set the row of a 3x4 transformation matrix referred to by the specified index + */ +static inline void vmathSoaT3SetRow_V( VmathSoaTransform3 *result, int row, VmathSoaVector4 vec ); + +/* + * Get the column of a 3x4 transformation matrix referred to by the specified index + */ +static inline VmathSoaVector3 vmathSoaT3GetCol_V( VmathSoaTransform3 tfrm, int col ); + +/* + * Get the row of a 3x4 transformation matrix referred to by the specified index + */ +static inline VmathSoaVector4 vmathSoaT3GetRow_V( VmathSoaTransform3 tfrm, int row ); + +/* + * Set the element of a 3x4 transformation matrix referred to by column and row indices + */ +static inline void vmathSoaT3SetElem_V( VmathSoaTransform3 *result, int col, int row, vec_float4 val ); + +/* + * Get the element of a 3x4 transformation matrix referred to by column and row indices + */ +static inline vec_float4 vmathSoaT3GetElem_V( VmathSoaTransform3 tfrm, int col, int row ); + +/* + * Multiply a 3x4 transformation matrix by a 3-D vector + */ +static inline VmathSoaVector3 vmathSoaT3MulV3_V( VmathSoaTransform3 tfrm, VmathSoaVector3 vec ); + +/* + * Multiply a 3x4 transformation matrix by a 3-D point + */ +static inline VmathSoaPoint3 vmathSoaT3MulP3_V( VmathSoaTransform3 tfrm, VmathSoaPoint3 pnt ); + +/* + * Multiply two 3x4 transformation matrices + */ +static inline VmathSoaTransform3 vmathSoaT3Mul_V( VmathSoaTransform3 tfrm0, VmathSoaTransform3 tfrm1 ); + +/* + * Construct an identity 3x4 transformation matrix + */ +static inline VmathSoaTransform3 vmathSoaT3MakeIdentity_V( ); + +/* + * Construct a 3x4 transformation matrix to rotate around the x axis + */ +static inline VmathSoaTransform3 vmathSoaT3MakeRotationX_V( vec_float4 radians ); + +/* + * Construct a 3x4 transformation matrix to rotate around the y axis + */ +static inline VmathSoaTransform3 vmathSoaT3MakeRotationY_V( vec_float4 radians ); + +/* + * Construct a 3x4 transformation matrix to rotate around the z axis + */ +static inline VmathSoaTransform3 vmathSoaT3MakeRotationZ_V( vec_float4 radians ); + +/* + * Construct a 3x4 transformation matrix to rotate around the x, y, and z axes + */ +static inline VmathSoaTransform3 vmathSoaT3MakeRotationZYX_V( VmathSoaVector3 radiansXYZ ); + +/* + * Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector + */ +static inline VmathSoaTransform3 vmathSoaT3MakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec ); + +/* + * Construct a rotation matrix from a unit-length quaternion + */ +static inline VmathSoaTransform3 vmathSoaT3MakeRotationQ_V( VmathSoaQuat unitQuat ); + +/* + * Construct a 3x4 transformation matrix to perform scaling + */ +static inline VmathSoaTransform3 vmathSoaT3MakeScale_V( VmathSoaVector3 scaleVec ); + +/* + * Construct a 3x4 transformation matrix to perform translation + */ +static inline VmathSoaTransform3 vmathSoaT3MakeTranslation_V( VmathSoaVector3 translateVec ); + +/* + * Append (post-multiply) a scale transformation to a 3x4 transformation matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline VmathSoaTransform3 vmathSoaT3AppendScale_V( VmathSoaTransform3 tfrm, VmathSoaVector3 scaleVec ); + +/* + * Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline VmathSoaTransform3 vmathSoaT3PrependScale_V( VmathSoaVector3 scaleVec, VmathSoaTransform3 tfrm ); + +/* + * Multiply two 3x4 transformation matrices per element + */ +static inline VmathSoaTransform3 vmathSoaT3MulPerElem_V( VmathSoaTransform3 tfrm0, VmathSoaTransform3 tfrm1 ); + +/* + * Compute the absolute value of a 3x4 transformation matrix per element + */ +static inline VmathSoaTransform3 vmathSoaT3AbsPerElem_V( VmathSoaTransform3 tfrm ); + +/* + * Inverse of a 3x4 transformation matrix + * NOTE: + * Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0. + */ +static inline VmathSoaTransform3 vmathSoaT3Inverse_V( VmathSoaTransform3 tfrm ); + +/* + * Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix + * NOTE: + * This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions. + */ +static inline VmathSoaTransform3 vmathSoaT3OrthoInverse_V( VmathSoaTransform3 tfrm ); + +/* + * Conditionally select between two 3x4 transformation matrices + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline VmathSoaTransform3 vmathSoaT3Select_V( VmathSoaTransform3 tfrm0, VmathSoaTransform3 tfrm1, vec_uint4 select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3x4 transformation matrix + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaT3Print_V( VmathSoaTransform3 tfrm ); + +/* + * Print a 3x4 transformation matrix and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaT3Prints_V( VmathSoaTransform3 tfrm, const char *name ); + +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include "vectormath_soa.h" +#include "vec_soa_v.h" +#include "quat_soa_v.h" +#include "mat_soa_v.h" + +#endif diff --git a/vectormathlibrary/include/vectormath/ppu/cpp/boolInVec.h b/vectormathlibrary/include/vectormath/ppu/cpp/boolInVec.h new file mode 100644 index 000000000..351a6f67c --- /dev/null +++ b/vectormathlibrary/include/vectormath/ppu/cpp/boolInVec.h @@ -0,0 +1,261 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _BOOLINVEC_H +#define _BOOLINVEC_H + +#include <math.h> +#include <altivec.h> +#include "../c/vec_types.h" +#undef bool + +namespace Vectormath { + +class floatInVec; + +//-------------------------------------------------------------------------------------------------- +// boolInVec class +// + +class boolInVec +{ + private: + vec_uint4 mData; + + inline boolInVec(vec_uint4 vec); + public: + inline boolInVec() {} + + // matches standard type conversions + // + inline boolInVec(floatInVec vec); + + // explicit cast from bool + // + explicit inline boolInVec(bool scalar); + +#ifdef _VECTORMATH_NO_SCALAR_CAST + // explicit cast to bool + // + inline bool getAsBool() const; +#else + // implicit cast to bool + // + inline operator bool() const; +#endif + + // get vector data + // bool value is splatted across all word slots of vector as 0 (false) or -1 (true) + // + inline vec_uint4 get128() const; + + // operators + // + inline const boolInVec operator ! () const; + inline boolInVec& operator = (boolInVec vec); + inline boolInVec& operator &= (boolInVec vec); + inline boolInVec& operator ^= (boolInVec vec); + inline boolInVec& operator |= (boolInVec vec); + + // friend functions + // + friend inline const boolInVec operator == (boolInVec vec0, boolInVec vec1); + friend inline const boolInVec operator != (boolInVec vec0, boolInVec vec1); + friend inline const boolInVec operator < (floatInVec vec0, floatInVec vec1); + friend inline const boolInVec operator <= (floatInVec vec0, floatInVec vec1); + friend inline const boolInVec operator > (floatInVec vec0, floatInVec vec1); + friend inline const boolInVec operator >= (floatInVec vec0, floatInVec vec1); + friend inline const boolInVec operator == (floatInVec vec0, floatInVec vec1); + friend inline const boolInVec operator != (floatInVec vec0, floatInVec vec1); + friend inline const boolInVec operator & (boolInVec vec0, boolInVec vec1); + friend inline const boolInVec operator ^ (boolInVec vec0, boolInVec vec1); + friend inline const boolInVec operator | (boolInVec vec0, boolInVec vec1); + friend inline const boolInVec select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1); +}; + +//-------------------------------------------------------------------------------------------------- +// boolInVec functions +// + +// operators +// +inline const boolInVec operator == (boolInVec vec0, boolInVec vec1); +inline const boolInVec operator != (boolInVec vec0, boolInVec vec1); +inline const boolInVec operator & (boolInVec vec0, boolInVec vec1); +inline const boolInVec operator ^ (boolInVec vec0, boolInVec vec1); +inline const boolInVec operator | (boolInVec vec0, boolInVec vec1); + +// select between vec0 and vec1 using boolInVec. +// false selects vec0, true selects vec1 +// +inline const boolInVec select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1); + +} // namespace Vectormath + +//-------------------------------------------------------------------------------------------------- +// boolInVec implementation +// + +#include "floatInVec.h" + +namespace Vectormath { + +inline +boolInVec::boolInVec(vec_uint4 vec) +{ + mData = vec; +} + +inline +boolInVec::boolInVec(floatInVec vec) +{ + *this = (vec != floatInVec(0.0f)); +} + +inline +boolInVec::boolInVec(bool scalar) +{ +#ifdef __GNUC__ + if (__builtin_constant_p(scalar)) + { + const unsigned int mask = -(int)scalar; + mData = (vec_uint4){mask, mask, mask, mask}; + } + else +#endif + { + unsigned int mask = -(int)scalar; + vec_uint4 vec = vec_ld(0, &mask); + mData = vec_splat(vec_perm(vec, vec, vec_lvsl(0, &mask)), 0); + } +} + +#ifdef _VECTORMATH_NO_SCALAR_CAST +inline +bool +boolInVec::getAsBool() const +#else +inline +boolInVec::operator bool() const +#endif +{ + return vec_all_gt(mData, ((vec_uint4){0,0,0,0})); +} + +inline +vec_uint4 +boolInVec::get128() const +{ + return mData; +} + +inline +const boolInVec +boolInVec::operator ! () const +{ + return boolInVec(vec_nor(mData, mData)); +} + +inline +boolInVec& +boolInVec::operator = (boolInVec vec) +{ + mData = vec.mData; + return *this; +} + +inline +boolInVec& +boolInVec::operator &= (boolInVec vec) +{ + *this = *this & vec; + return *this; +} + +inline +boolInVec& +boolInVec::operator ^= (boolInVec vec) +{ + *this = *this ^ vec; + return *this; +} + +inline +boolInVec& +boolInVec::operator |= (boolInVec vec) +{ + *this = *this | vec; + return *this; +} + +inline +const boolInVec +operator == (boolInVec vec0, boolInVec vec1) +{ + return boolInVec((vec_uint4)vec_cmpeq(vec0.get128(), vec1.get128())); +} + +inline +const boolInVec +operator != (boolInVec vec0, boolInVec vec1) +{ + return !(vec0 == vec1); +} + +inline +const boolInVec +operator & (boolInVec vec0, boolInVec vec1) +{ + return boolInVec(vec_and(vec0.get128(), vec1.get128())); +} + +inline +const boolInVec +operator | (boolInVec vec0, boolInVec vec1) +{ + return boolInVec(vec_or(vec0.get128(), vec1.get128())); +} + +inline +const boolInVec +operator ^ (boolInVec vec0, boolInVec vec1) +{ + return boolInVec(vec_xor(vec0.get128(), vec1.get128())); +} + +inline +const boolInVec +select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1) +{ + return boolInVec(vec_sel(vec0.get128(), vec1.get128(), select_vec1.get128())); +} + +} // namespace Vectormath + +#endif // boolInVec_h diff --git a/vectormathlibrary/include/vectormath/ppu/cpp/floatInVec.h b/vectormathlibrary/include/vectormath/ppu/cpp/floatInVec.h new file mode 100644 index 000000000..957971900 --- /dev/null +++ b/vectormathlibrary/include/vectormath/ppu/cpp/floatInVec.h @@ -0,0 +1,361 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _FLOATINVEC_H +#define _FLOATINVEC_H + +#include <math.h> +#include <altivec.h> +#include <stddef.h> +#include <simdmath.h> +#include "../c/vec_types.h" +#undef bool + +namespace Vectormath { + +class boolInVec; + +//-------------------------------------------------------------------------------------------------- +// floatInVec class +// + +class floatInVec +{ + private: + vec_float4 mData; + + inline floatInVec(vec_float4 vec); + public: + inline floatInVec() {} + + // matches standard type conversions + // + inline floatInVec(boolInVec vec); + + // construct from a slot of vec_float4 + // + inline floatInVec(vec_float4 vec, int slot); + + // explicit cast from float + // + explicit inline floatInVec(float scalar); + +#ifdef _VECTORMATH_NO_SCALAR_CAST + // explicit cast to float + // + inline float getAsFloat() const; +#else + // implicit cast to float + // + inline operator float() const; +#endif + + // get vector data + // float value is splatted across all word slots of vector + // + inline vec_float4 get128() const; + + // operators + // + inline const floatInVec operator ++ (int); + inline const floatInVec operator -- (int); + inline floatInVec& operator ++ (); + inline floatInVec& operator -- (); + inline const floatInVec operator - () const; + inline floatInVec& operator = (floatInVec vec); + inline floatInVec& operator *= (floatInVec vec); + inline floatInVec& operator /= (floatInVec vec); + inline floatInVec& operator += (floatInVec vec); + inline floatInVec& operator -= (floatInVec vec); + + // friend functions + // + friend inline const floatInVec operator * (floatInVec vec0, floatInVec vec1); + friend inline const floatInVec operator / (floatInVec vec0, floatInVec vec1); + friend inline const floatInVec operator + (floatInVec vec0, floatInVec vec1); + friend inline const floatInVec operator - (floatInVec vec0, floatInVec vec1); + friend inline const floatInVec select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1); +}; + +//-------------------------------------------------------------------------------------------------- +// floatInVec functions +// + +// operators +// +inline const floatInVec operator * (floatInVec vec0, floatInVec vec1); +inline const floatInVec operator / (floatInVec vec0, floatInVec vec1); +inline const floatInVec operator + (floatInVec vec0, floatInVec vec1); +inline const floatInVec operator - (floatInVec vec0, floatInVec vec1); +inline const boolInVec operator < (floatInVec vec0, floatInVec vec1); +inline const boolInVec operator <= (floatInVec vec0, floatInVec vec1); +inline const boolInVec operator > (floatInVec vec0, floatInVec vec1); +inline const boolInVec operator >= (floatInVec vec0, floatInVec vec1); +inline const boolInVec operator == (floatInVec vec0, floatInVec vec1); +inline const boolInVec operator != (floatInVec vec0, floatInVec vec1); + +// select between vec0 and vec1 using boolInVec. +// false selects vec0, true selects vec1 +// +inline const floatInVec select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1); + +} // namespace Vectormath + +//-------------------------------------------------------------------------------------------------- +// floatInVec implementation +// + +#include "boolInVec.h" + +namespace Vectormath { + +inline +floatInVec::floatInVec(vec_float4 vec) +{ + mData = vec; +} + +inline +floatInVec::floatInVec(boolInVec vec) +{ + mData = vec_ctf(vec_sub((vec_uint4){0,0,0,0}, vec.get128()), 0); +} + +inline +floatInVec::floatInVec(vec_float4 vec, int slot) +{ +#ifdef __GNUC__ + if (__builtin_constant_p(slot)) + { + mData = vec_splat(vec, slot); + } + else +#endif + { + const vec_uchar16 shiftpattern = vec_lvsl(0, (float *)(size_t)(slot << 2)); + mData = vec_splat(vec_perm(vec, vec, shiftpattern), 0); + } +} + +inline +floatInVec::floatInVec(float scalar) +{ +#ifdef __GNUC__ + if (__builtin_constant_p(scalar)) + { + mData = (vec_float4){scalar, scalar, scalar, scalar}; + } + else +#endif + { + vec_float4 vec = vec_ld(0, &scalar); + mData = vec_splat(vec_perm(vec, vec, vec_lvsl(0, &scalar)), 0); + } +} + +#ifdef _VECTORMATH_NO_SCALAR_CAST +inline +float +floatInVec::getAsFloat() const +#else +inline +floatInVec::operator float() const +#endif +{ + return *((float *)&mData); +} + +inline +vec_float4 +floatInVec::get128() const +{ + return mData; +} + +inline +const floatInVec +floatInVec::operator ++ (int) +{ + vec_float4 olddata = mData; + operator ++(); + return floatInVec(olddata); +} + +inline +const floatInVec +floatInVec::operator -- (int) +{ + vec_float4 olddata = mData; + operator --(); + return floatInVec(olddata); +} + +inline +floatInVec& +floatInVec::operator ++ () +{ + *this += floatInVec((vec_float4){1.0f,1.0f,1.0f,1.0f}); + return *this; +} + +inline +floatInVec& +floatInVec::operator -- () +{ + *this -= floatInVec((vec_float4){1.0f,1.0f,1.0f,1.0f}); + return *this; +} + +inline +const floatInVec +floatInVec::operator - () const +{ + return floatInVec((vec_float4)vec_xor((vec_uint4)mData, (vec_uint4){0x80000000,0x80000000,0x80000000,0x80000000})); +} + +inline +floatInVec& +floatInVec::operator = (floatInVec vec) +{ + mData = vec.mData; + return *this; +} + +inline +floatInVec& +floatInVec::operator *= (floatInVec vec) +{ + *this = *this * vec; + return *this; +} + +inline +floatInVec& +floatInVec::operator /= (floatInVec vec) +{ + *this = *this / vec; + return *this; +} + +inline +floatInVec& +floatInVec::operator += (floatInVec vec) +{ + *this = *this + vec; + return *this; +} + +inline +floatInVec& +floatInVec::operator -= (floatInVec vec) +{ + *this = *this - vec; + return *this; +} + +inline +const floatInVec +operator * (floatInVec vec0, floatInVec vec1) +{ + return floatInVec(vec_madd(vec0.get128(), vec1.get128(), (vec_float4){0,0,0,0})); +} + +inline +const floatInVec +operator / (floatInVec num, floatInVec den) +{ + return floatInVec(divf4(num.get128(), den.get128())); +} + +inline +const floatInVec +operator + (floatInVec vec0, floatInVec vec1) +{ + return floatInVec(vec_add(vec0.get128(), vec1.get128())); +} + +inline +const floatInVec +operator - (floatInVec vec0, floatInVec vec1) +{ + return floatInVec(vec_sub(vec0.get128(), vec1.get128())); +} + +inline +const boolInVec +operator < (floatInVec vec0, floatInVec vec1) +{ + return boolInVec((vec_uint4)vec_cmpgt(vec1.get128(), vec0.get128())); +} + +inline +const boolInVec +operator <= (floatInVec vec0, floatInVec vec1) +{ + return !(vec0 > vec1); +} + +inline +const boolInVec +operator > (floatInVec vec0, floatInVec vec1) +{ + return boolInVec((vec_uint4)vec_cmpgt(vec0.get128(), vec1.get128())); +} + +inline +const boolInVec +operator >= (floatInVec vec0, floatInVec vec1) +{ + return !(vec0 < vec1); +} + +inline +const boolInVec +operator == (floatInVec vec0, floatInVec vec1) +{ + return boolInVec((vec_uint4)vec_cmpeq(vec0.get128(), vec1.get128())); +} + +inline +const boolInVec +operator != (floatInVec vec0, floatInVec vec1) +{ + return !(vec0 == vec1); +} + +inline +const floatInVec +select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1) +{ + return floatInVec(vec_sel(vec0.get128(), vec1.get128(), select_vec1.get128())); +} + +} // namespace Vectormath + +#endif // floatInVec_h diff --git a/vectormathlibrary/include/vectormath/ppu/cpp/mat_aos.h b/vectormathlibrary/include/vectormath/ppu/cpp/mat_aos.h new file mode 100644 index 000000000..77a184725 --- /dev/null +++ b/vectormathlibrary/include/vectormath/ppu/cpp/mat_aos.h @@ -0,0 +1,2188 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_MAT_AOS_CPP_H +#define _VECTORMATH_MAT_AOS_CPP_H + +namespace Vectormath { +namespace Aos { + +//----------------------------------------------------------------------------- +// Constants +// for shuffles, words are labeled [x,y,z,w] [a,b,c,d] + +#define _VECTORMATH_PERM_ZBWX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B, _VECTORMATH_PERM_W, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_XCYX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_C, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_XYAB ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A, _VECTORMATH_PERM_B }) +#define _VECTORMATH_PERM_ZWCD ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_W, _VECTORMATH_PERM_C, _VECTORMATH_PERM_D }) +#define _VECTORMATH_PERM_XZBX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_CXXX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_C, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_YAXX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_XAZC ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_A, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_C }) +#define _VECTORMATH_PERM_YXWZ ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X, _VECTORMATH_PERM_W, _VECTORMATH_PERM_Z }) +#define _VECTORMATH_PERM_YBWD ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_B, _VECTORMATH_PERM_W, _VECTORMATH_PERM_D }) +#define _VECTORMATH_PERM_XYCX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_C, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_YCXY ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_C, _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y }) +#define _VECTORMATH_PERM_CXYC ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_C, _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_C }) +#define _VECTORMATH_PERM_ZAYX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_BZXX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_B, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_XZYA ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A }) +#define _VECTORMATH_PERM_ZXXB ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X, _VECTORMATH_PERM_B }) +#define _VECTORMATH_PERM_YXXC ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X, _VECTORMATH_PERM_C }) +#define _VECTORMATH_PERM_BBYX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_B, _VECTORMATH_PERM_B, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PI_OVER_2 1.570796327f + +//----------------------------------------------------------------------------- +// Definitions + +inline Matrix3::Matrix3( const Matrix3 & mat ) +{ + mCol0 = mat.mCol0; + mCol1 = mat.mCol1; + mCol2 = mat.mCol2; +} + +inline Matrix3::Matrix3( float scalar ) +{ + mCol0 = Vector3( scalar ); + mCol1 = Vector3( scalar ); + mCol2 = Vector3( scalar ); +} + +inline Matrix3::Matrix3( floatInVec scalar ) +{ + mCol0 = Vector3( scalar ); + mCol1 = Vector3( scalar ); + mCol2 = Vector3( scalar ); +} + +inline Matrix3::Matrix3( Quat unitQuat ) +{ + vec_float4 xyzw_2, wwww, yzxw, zxyw, yzxw_2, zxyw_2; + vec_float4 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; + vec_uint4 select_x = _VECTORMATH_MASK_0xF000; + vec_uint4 select_z = _VECTORMATH_MASK_0x00F0; + xyzw_2 = vec_add( unitQuat.get128(), unitQuat.get128() ); + wwww = vec_splat( unitQuat.get128(), 3 ); + yzxw = vec_perm( unitQuat.get128(), unitQuat.get128(), _VECTORMATH_PERM_YZXW ); + zxyw = vec_perm( unitQuat.get128(), unitQuat.get128(), _VECTORMATH_PERM_ZXYW ); + yzxw_2 = vec_perm( xyzw_2, xyzw_2, _VECTORMATH_PERM_YZXW ); + zxyw_2 = vec_perm( xyzw_2, xyzw_2, _VECTORMATH_PERM_ZXYW ); + tmp0 = vec_madd( yzxw_2, wwww, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + tmp1 = vec_nmsub( yzxw, yzxw_2, ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); + tmp2 = vec_madd( yzxw, xyzw_2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + tmp0 = vec_madd( zxyw, xyzw_2, tmp0 ); + tmp1 = vec_nmsub( zxyw, zxyw_2, tmp1 ); + tmp2 = vec_nmsub( zxyw_2, wwww, tmp2 ); + tmp3 = vec_sel( tmp0, tmp1, select_x ); + tmp4 = vec_sel( tmp1, tmp2, select_x ); + tmp5 = vec_sel( tmp2, tmp0, select_x ); + mCol0 = Vector3( vec_sel( tmp3, tmp2, select_z ) ); + mCol1 = Vector3( vec_sel( tmp4, tmp0, select_z ) ); + mCol2 = Vector3( vec_sel( tmp5, tmp1, select_z ) ); +} + +inline Matrix3::Matrix3( Vector3 _col0, Vector3 _col1, Vector3 _col2 ) +{ + mCol0 = _col0; + mCol1 = _col1; + mCol2 = _col2; +} + +inline Matrix3 & Matrix3::setCol0( Vector3 _col0 ) +{ + mCol0 = _col0; + return *this; +} + +inline Matrix3 & Matrix3::setCol1( Vector3 _col1 ) +{ + mCol1 = _col1; + return *this; +} + +inline Matrix3 & Matrix3::setCol2( Vector3 _col2 ) +{ + mCol2 = _col2; + return *this; +} + +inline Matrix3 & Matrix3::setCol( int col, Vector3 vec ) +{ + *(&mCol0 + col) = vec; + return *this; +} + +inline Matrix3 & Matrix3::setRow( int row, Vector3 vec ) +{ + mCol0.setElem( row, vec.getElem( 0 ) ); + mCol1.setElem( row, vec.getElem( 1 ) ); + mCol2.setElem( row, vec.getElem( 2 ) ); + return *this; +} + +inline Matrix3 & Matrix3::setElem( int col, int row, float val ) +{ + (*this)[col].setElem(row, val); + return *this; +} + +inline Matrix3 & Matrix3::setElem( int col, int row, floatInVec val ) +{ + Vector3 tmpV3_0; + tmpV3_0 = this->getCol( col ); + tmpV3_0.setElem( row, val ); + this->setCol( col, tmpV3_0 ); + return *this; +} + +inline const floatInVec Matrix3::getElem( int col, int row ) const +{ + return this->getCol( col ).getElem( row ); +} + +inline const Vector3 Matrix3::getCol0( ) const +{ + return mCol0; +} + +inline const Vector3 Matrix3::getCol1( ) const +{ + return mCol1; +} + +inline const Vector3 Matrix3::getCol2( ) const +{ + return mCol2; +} + +inline const Vector3 Matrix3::getCol( int col ) const +{ + return *(&mCol0 + col); +} + +inline const Vector3 Matrix3::getRow( int row ) const +{ + return Vector3( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ) ); +} + +inline Vector3 & Matrix3::operator []( int col ) +{ + return *(&mCol0 + col); +} + +inline const Vector3 Matrix3::operator []( int col ) const +{ + return *(&mCol0 + col); +} + +inline Matrix3 & Matrix3::operator =( const Matrix3 & mat ) +{ + mCol0 = mat.mCol0; + mCol1 = mat.mCol1; + mCol2 = mat.mCol2; + return *this; +} + +inline const Matrix3 transpose( const Matrix3 & mat ) +{ + vec_float4 tmp0, tmp1, res0, res1, res2; + tmp0 = vec_mergeh( mat.getCol0().get128(), mat.getCol2().get128() ); + tmp1 = vec_mergel( mat.getCol0().get128(), mat.getCol2().get128() ); + res0 = vec_mergeh( tmp0, mat.getCol1().get128() ); + res1 = vec_perm( tmp0, mat.getCol1().get128(), _VECTORMATH_PERM_ZBWX ); + res2 = vec_perm( tmp1, mat.getCol1().get128(), _VECTORMATH_PERM_XCYX ); + return Matrix3( + Vector3( res0 ), + Vector3( res1 ), + Vector3( res2 ) + ); +} + +inline const Matrix3 inverse( const Matrix3 & mat ) +{ + vec_float4 tmp0, tmp1, tmp2, tmp3, tmp4, dot, invdet, inv0, inv1, inv2; + vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + tmp2 = _vmathVfCross( mat.getCol0().get128(), mat.getCol1().get128() ); + tmp0 = _vmathVfCross( mat.getCol1().get128(), mat.getCol2().get128() ); + tmp1 = _vmathVfCross( mat.getCol2().get128(), mat.getCol0().get128() ); + dot = _vmathVfDot3( tmp2, mat.getCol2().get128() ); + dot = vec_splat( dot, 0 ); + invdet = recipf4( dot ); + tmp3 = vec_mergeh( tmp0, tmp2 ); + tmp4 = vec_mergel( tmp0, tmp2 ); + inv0 = vec_mergeh( tmp3, tmp1 ); + inv1 = vec_perm( tmp3, tmp1, _VECTORMATH_PERM_ZBWX ); + inv2 = vec_perm( tmp4, tmp1, _VECTORMATH_PERM_XCYX ); + inv0 = vec_madd( inv0, invdet, zero ); + inv1 = vec_madd( inv1, invdet, zero ); + inv2 = vec_madd( inv2, invdet, zero ); + return Matrix3( + Vector3( inv0 ), + Vector3( inv1 ), + Vector3( inv2 ) + ); +} + +inline const floatInVec determinant( const Matrix3 & mat ) +{ + return dot( mat.getCol2(), cross( mat.getCol0(), mat.getCol1() ) ); +} + +inline const Matrix3 Matrix3::operator +( const Matrix3 & mat ) const +{ + return Matrix3( + ( mCol0 + mat.mCol0 ), + ( mCol1 + mat.mCol1 ), + ( mCol2 + mat.mCol2 ) + ); +} + +inline const Matrix3 Matrix3::operator -( const Matrix3 & mat ) const +{ + return Matrix3( + ( mCol0 - mat.mCol0 ), + ( mCol1 - mat.mCol1 ), + ( mCol2 - mat.mCol2 ) + ); +} + +inline Matrix3 & Matrix3::operator +=( const Matrix3 & mat ) +{ + *this = *this + mat; + return *this; +} + +inline Matrix3 & Matrix3::operator -=( const Matrix3 & mat ) +{ + *this = *this - mat; + return *this; +} + +inline const Matrix3 Matrix3::operator -( ) const +{ + return Matrix3( + ( -mCol0 ), + ( -mCol1 ), + ( -mCol2 ) + ); +} + +inline const Matrix3 absPerElem( const Matrix3 & mat ) +{ + return Matrix3( + absPerElem( mat.getCol0() ), + absPerElem( mat.getCol1() ), + absPerElem( mat.getCol2() ) + ); +} + +inline const Matrix3 Matrix3::operator *( float scalar ) const +{ + return *this * floatInVec(scalar); +} + +inline const Matrix3 Matrix3::operator *( floatInVec scalar ) const +{ + return Matrix3( + ( mCol0 * scalar ), + ( mCol1 * scalar ), + ( mCol2 * scalar ) + ); +} + +inline Matrix3 & Matrix3::operator *=( float scalar ) +{ + return *this *= floatInVec(scalar); +} + +inline Matrix3 & Matrix3::operator *=( floatInVec scalar ) +{ + *this = *this * scalar; + return *this; +} + +inline const Matrix3 operator *( float scalar, const Matrix3 & mat ) +{ + return floatInVec(scalar) * mat; +} + +inline const Matrix3 operator *( floatInVec scalar, const Matrix3 & mat ) +{ + return mat * scalar; +} + +inline const Vector3 Matrix3::operator *( Vector3 vec ) const +{ + vec_float4 res; + vec_float4 xxxx, yyyy, zzzz; + xxxx = vec_splat( vec.get128(), 0 ); + yyyy = vec_splat( vec.get128(), 1 ); + zzzz = vec_splat( vec.get128(), 2 ); + res = vec_madd( mCol0.get128(), xxxx, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + res = vec_madd( mCol1.get128(), yyyy, res ); + res = vec_madd( mCol2.get128(), zzzz, res ); + return Vector3( res ); +} + +inline const Matrix3 Matrix3::operator *( const Matrix3 & mat ) const +{ + return Matrix3( + ( *this * mat.mCol0 ), + ( *this * mat.mCol1 ), + ( *this * mat.mCol2 ) + ); +} + +inline Matrix3 & Matrix3::operator *=( const Matrix3 & mat ) +{ + *this = *this * mat; + return *this; +} + +inline const Matrix3 mulPerElem( const Matrix3 & mat0, const Matrix3 & mat1 ) +{ + return Matrix3( + mulPerElem( mat0.getCol0(), mat1.getCol0() ), + mulPerElem( mat0.getCol1(), mat1.getCol1() ), + mulPerElem( mat0.getCol2(), mat1.getCol2() ) + ); +} + +inline const Matrix3 Matrix3::identity( ) +{ + return Matrix3( + Vector3::xAxis( ), + Vector3::yAxis( ), + Vector3::zAxis( ) + ); +} + +inline const Matrix3 Matrix3::rotationX( float radians ) +{ + return rotationX( floatInVec(radians) ); +} + +inline const Matrix3 Matrix3::rotationX( floatInVec radians ) +{ + vec_float4 s, c, res1, res2; + vec_uint4 select_y, select_z; + vec_float4 zero; + select_y = _VECTORMATH_MASK_0x0F00; + select_z = _VECTORMATH_MASK_0x00F0; + zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + sincosf4( radians.get128(), &s, &c ); + res1 = vec_sel( zero, c, select_y ); + res1 = vec_sel( res1, s, select_z ); + res2 = vec_sel( zero, negatef4(s), select_y ); + res2 = vec_sel( res2, c, select_z ); + return Matrix3( + Vector3::xAxis( ), + Vector3( res1 ), + Vector3( res2 ) + ); +} + +inline const Matrix3 Matrix3::rotationY( float radians ) +{ + return rotationY( floatInVec(radians) ); +} + +inline const Matrix3 Matrix3::rotationY( floatInVec radians ) +{ + vec_float4 s, c, res0, res2; + vec_uint4 select_x, select_z; + vec_float4 zero; + select_x = _VECTORMATH_MASK_0xF000; + select_z = _VECTORMATH_MASK_0x00F0; + zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + sincosf4( radians.get128(), &s, &c ); + res0 = vec_sel( zero, c, select_x ); + res0 = vec_sel( res0, negatef4(s), select_z ); + res2 = vec_sel( zero, s, select_x ); + res2 = vec_sel( res2, c, select_z ); + return Matrix3( + Vector3( res0 ), + Vector3::yAxis( ), + Vector3( res2 ) + ); +} + +inline const Matrix3 Matrix3::rotationZ( float radians ) +{ + return rotationZ( floatInVec(radians) ); +} + +inline const Matrix3 Matrix3::rotationZ( floatInVec radians ) +{ + vec_float4 s, c, res0, res1; + vec_uint4 select_x, select_y; + vec_float4 zero; + select_x = _VECTORMATH_MASK_0xF000; + select_y = _VECTORMATH_MASK_0x0F00; + zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + sincosf4( radians.get128(), &s, &c ); + res0 = vec_sel( zero, c, select_x ); + res0 = vec_sel( res0, s, select_y ); + res1 = vec_sel( zero, negatef4(s), select_x ); + res1 = vec_sel( res1, c, select_y ); + return Matrix3( + Vector3( res0 ), + Vector3( res1 ), + Vector3::zAxis( ) + ); +} + +inline const Matrix3 Matrix3::rotationZYX( Vector3 radiansXYZ ) +{ + vec_float4 angles, s, negS, c, X0, X1, Y0, Y1, Z0, Z1, tmp; + vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + angles = Vector4( radiansXYZ, 0.0f ).get128(); + sincosf4( angles, &s, &c ); + negS = negatef4( s ); + Z0 = vec_mergel( c, s ); + Z1 = vec_mergel( negS, c ); + Z1 = vec_andc( Z1, (vec_float4)_VECTORMATH_MASK_0x000F ); + Y0 = vec_perm( negS, c, _VECTORMATH_PERM_BBYX ); + Y1 = vec_perm( c, s, _VECTORMATH_PERM_BBYX ); + X0 = vec_splat( s, 0 ); + X1 = vec_splat( c, 0 ); + tmp = vec_madd( Z0, Y1, zero ); + return Matrix3( + Vector3( vec_madd( Z0, Y0, zero ) ), + Vector3( vec_madd( Z1, X1, vec_madd( tmp, X0, zero ) ) ), + Vector3( vec_nmsub( Z1, X0, vec_madd( tmp, X1, zero ) ) ) + ); +} + +inline const Matrix3 Matrix3::rotation( float radians, Vector3 unitVec ) +{ + return rotation( floatInVec(radians), unitVec ); +} + +inline const Matrix3 Matrix3::rotation( floatInVec radians, Vector3 unitVec ) +{ + vec_float4 axis, s, c, oneMinusC, axisS, negAxisS, xxxx, yyyy, zzzz, tmp0, tmp1, tmp2; + vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + axis = unitVec.get128(); + sincosf4( radians.get128(), &s, &c ); + xxxx = vec_splat( axis, 0 ); + yyyy = vec_splat( axis, 1 ); + zzzz = vec_splat( axis, 2 ); + oneMinusC = vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), c ); + axisS = vec_madd( axis, s, zero ); + negAxisS = negatef4( axisS ); + tmp0 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_XZBX ); + tmp1 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_CXXX ); + tmp2 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_YAXX ); + tmp0 = vec_sel( tmp0, c, _VECTORMATH_MASK_0xF000 ); + tmp1 = vec_sel( tmp1, c, _VECTORMATH_MASK_0x0F00 ); + tmp2 = vec_sel( tmp2, c, _VECTORMATH_MASK_0x00F0 ); + return Matrix3( + Vector3( vec_madd( vec_madd( axis, xxxx, zero ), oneMinusC, tmp0 ) ), + Vector3( vec_madd( vec_madd( axis, yyyy, zero ), oneMinusC, tmp1 ) ), + Vector3( vec_madd( vec_madd( axis, zzzz, zero ), oneMinusC, tmp2 ) ) + ); +} + +inline const Matrix3 Matrix3::rotation( Quat unitQuat ) +{ + return Matrix3( unitQuat ); +} + +inline const Matrix3 Matrix3::scale( Vector3 scaleVec ) +{ + vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + return Matrix3( + Vector3( vec_sel( zero, scaleVec.get128(), _VECTORMATH_MASK_0xF000 ) ), + Vector3( vec_sel( zero, scaleVec.get128(), _VECTORMATH_MASK_0x0F00 ) ), + Vector3( vec_sel( zero, scaleVec.get128(), _VECTORMATH_MASK_0x00F0 ) ) + ); +} + +inline const Matrix3 appendScale( const Matrix3 & mat, Vector3 scaleVec ) +{ + return Matrix3( + ( mat.getCol0() * scaleVec.getX( ) ), + ( mat.getCol1() * scaleVec.getY( ) ), + ( mat.getCol2() * scaleVec.getZ( ) ) + ); +} + +inline const Matrix3 prependScale( Vector3 scaleVec, const Matrix3 & mat ) +{ + return Matrix3( + mulPerElem( mat.getCol0(), scaleVec ), + mulPerElem( mat.getCol1(), scaleVec ), + mulPerElem( mat.getCol2(), scaleVec ) + ); +} + +inline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, bool select1 ) +{ + return Matrix3( + select( mat0.getCol0(), mat1.getCol0(), select1 ), + select( mat0.getCol1(), mat1.getCol1(), select1 ), + select( mat0.getCol2(), mat1.getCol2(), select1 ) + ); +} + +inline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, boolInVec select1 ) +{ + return Matrix3( + select( mat0.getCol0(), mat1.getCol0(), select1 ), + select( mat0.getCol1(), mat1.getCol1(), select1 ), + select( mat0.getCol2(), mat1.getCol2(), select1 ) + ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( const Matrix3 & mat ) +{ + print( mat.getRow( 0 ) ); + print( mat.getRow( 1 ) ); + print( mat.getRow( 2 ) ); +} + +inline void print( const Matrix3 & mat, const char * name ) +{ + printf("%s:\n", name); + print( mat ); +} + +#endif + +inline Matrix4::Matrix4( const Matrix4 & mat ) +{ + mCol0 = mat.mCol0; + mCol1 = mat.mCol1; + mCol2 = mat.mCol2; + mCol3 = mat.mCol3; +} + +inline Matrix4::Matrix4( float scalar ) +{ + mCol0 = Vector4( scalar ); + mCol1 = Vector4( scalar ); + mCol2 = Vector4( scalar ); + mCol3 = Vector4( scalar ); +} + +inline Matrix4::Matrix4( floatInVec scalar ) +{ + mCol0 = Vector4( scalar ); + mCol1 = Vector4( scalar ); + mCol2 = Vector4( scalar ); + mCol3 = Vector4( scalar ); +} + +inline Matrix4::Matrix4( const Transform3 & mat ) +{ + mCol0 = Vector4( mat.getCol0(), 0.0f ); + mCol1 = Vector4( mat.getCol1(), 0.0f ); + mCol2 = Vector4( mat.getCol2(), 0.0f ); + mCol3 = Vector4( mat.getCol3(), 1.0f ); +} + +inline Matrix4::Matrix4( Vector4 _col0, Vector4 _col1, Vector4 _col2, Vector4 _col3 ) +{ + mCol0 = _col0; + mCol1 = _col1; + mCol2 = _col2; + mCol3 = _col3; +} + +inline Matrix4::Matrix4( const Matrix3 & mat, Vector3 translateVec ) +{ + mCol0 = Vector4( mat.getCol0(), 0.0f ); + mCol1 = Vector4( mat.getCol1(), 0.0f ); + mCol2 = Vector4( mat.getCol2(), 0.0f ); + mCol3 = Vector4( translateVec, 1.0f ); +} + +inline Matrix4::Matrix4( Quat unitQuat, Vector3 translateVec ) +{ + Matrix3 mat; + mat = Matrix3( unitQuat ); + mCol0 = Vector4( mat.getCol0(), 0.0f ); + mCol1 = Vector4( mat.getCol1(), 0.0f ); + mCol2 = Vector4( mat.getCol2(), 0.0f ); + mCol3 = Vector4( translateVec, 1.0f ); +} + +inline Matrix4 & Matrix4::setCol0( Vector4 _col0 ) +{ + mCol0 = _col0; + return *this; +} + +inline Matrix4 & Matrix4::setCol1( Vector4 _col1 ) +{ + mCol1 = _col1; + return *this; +} + +inline Matrix4 & Matrix4::setCol2( Vector4 _col2 ) +{ + mCol2 = _col2; + return *this; +} + +inline Matrix4 & Matrix4::setCol3( Vector4 _col3 ) +{ + mCol3 = _col3; + return *this; +} + +inline Matrix4 & Matrix4::setCol( int col, Vector4 vec ) +{ + *(&mCol0 + col) = vec; + return *this; +} + +inline Matrix4 & Matrix4::setRow( int row, Vector4 vec ) +{ + mCol0.setElem( row, vec.getElem( 0 ) ); + mCol1.setElem( row, vec.getElem( 1 ) ); + mCol2.setElem( row, vec.getElem( 2 ) ); + mCol3.setElem( row, vec.getElem( 3 ) ); + return *this; +} + +inline Matrix4 & Matrix4::setElem( int col, int row, float val ) +{ + (*this)[col].setElem(row, val); + return *this; +} + +inline Matrix4 & Matrix4::setElem( int col, int row, floatInVec val ) +{ + Vector4 tmpV3_0; + tmpV3_0 = this->getCol( col ); + tmpV3_0.setElem( row, val ); + this->setCol( col, tmpV3_0 ); + return *this; +} + +inline const floatInVec Matrix4::getElem( int col, int row ) const +{ + return this->getCol( col ).getElem( row ); +} + +inline const Vector4 Matrix4::getCol0( ) const +{ + return mCol0; +} + +inline const Vector4 Matrix4::getCol1( ) const +{ + return mCol1; +} + +inline const Vector4 Matrix4::getCol2( ) const +{ + return mCol2; +} + +inline const Vector4 Matrix4::getCol3( ) const +{ + return mCol3; +} + +inline const Vector4 Matrix4::getCol( int col ) const +{ + return *(&mCol0 + col); +} + +inline const Vector4 Matrix4::getRow( int row ) const +{ + return Vector4( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ), mCol3.getElem( row ) ); +} + +inline Vector4 & Matrix4::operator []( int col ) +{ + return *(&mCol0 + col); +} + +inline const Vector4 Matrix4::operator []( int col ) const +{ + return *(&mCol0 + col); +} + +inline Matrix4 & Matrix4::operator =( const Matrix4 & mat ) +{ + mCol0 = mat.mCol0; + mCol1 = mat.mCol1; + mCol2 = mat.mCol2; + mCol3 = mat.mCol3; + return *this; +} + +inline const Matrix4 transpose( const Matrix4 & mat ) +{ + vec_float4 tmp0, tmp1, tmp2, tmp3, res0, res1, res2, res3; + tmp0 = vec_mergeh( mat.getCol0().get128(), mat.getCol2().get128() ); + tmp1 = vec_mergeh( mat.getCol1().get128(), mat.getCol3().get128() ); + tmp2 = vec_mergel( mat.getCol0().get128(), mat.getCol2().get128() ); + tmp3 = vec_mergel( mat.getCol1().get128(), mat.getCol3().get128() ); + res0 = vec_mergeh( tmp0, tmp1 ); + res1 = vec_mergel( tmp0, tmp1 ); + res2 = vec_mergeh( tmp2, tmp3 ); + res3 = vec_mergel( tmp2, tmp3 ); + return Matrix4( + Vector4( res0 ), + Vector4( res1 ), + Vector4( res2 ), + Vector4( res3 ) + ); +} + +inline const Matrix4 inverse( const Matrix4 & mat ) +{ + /* function implementation based on code from STIDC SDK: */ + /* -------------------------------------------------------------- */ + /* PLEASE DO NOT MODIFY THIS SECTION */ + /* This prolog section is automatically generated. */ + /* */ + /* (C)Copyright */ + /* Sony Computer Entertainment, Inc., */ + /* Toshiba Corporation, */ + /* International Business Machines Corporation, */ + /* 2001,2002. */ + /* S/T/I Confidential Information */ + /* -------------------------------------------------------------- */ + vector float in0, in1, in2, in3; + vector float tmp0, tmp1, tmp2, tmp3; + vector float cof0, cof1, cof2, cof3; + vector float t0, t1, t2, t3; + vector float t01, t02, t03, t12, t23; + vector float t1r, t2r; + vector float t01r, t02r, t03r, t12r, t23r; + vector float t1r3, t1r3r; + vector float det, det0, det1, det2, det3, invdet; + vector float vzero = (vector float){0.0}; + in0 = mat.getCol0().get128(); + in1 = mat.getCol1().get128(); + in2 = mat.getCol2().get128(); + in3 = mat.getCol3().get128(); + /* Perform transform of the input matrix of the form: + * A B C D + * E F G H + * I J K L + * M N O P + * + * The pseudo transpose of the input matrix is trans: + * A E I M + * J N B F + * C G K O + * L P D H + */ + tmp0 = vec_perm(in0, in1, _VECTORMATH_PERM_XAZC); /* A E C G */ + tmp1 = vec_perm(in2, in3, _VECTORMATH_PERM_XAZC); /* I M K O */ + tmp2 = vec_perm(in0, in1, _VECTORMATH_PERM_YBWD); /* B F D H */ + tmp3 = vec_perm(in2, in3, _VECTORMATH_PERM_YBWD); /* J N L P */ + t0 = vec_perm(tmp0, tmp1, _VECTORMATH_PERM_XYAB); /* A E I M */ + t1 = vec_perm(tmp3, tmp2, _VECTORMATH_PERM_XYAB); /* J N B F */ + t2 = vec_perm(tmp0, tmp1, _VECTORMATH_PERM_ZWCD); /* C G K O */ + t3 = vec_perm(tmp3, tmp2, _VECTORMATH_PERM_ZWCD); /* L P D H */ + /* Generate a cofactor matrix. The computed cofactors reside in + * cof0, cof1, cof2, cof3. + */ + t23 = vec_madd(t2, t3, vzero); /* CL GP KD OH */ + t23 = vec_perm(t23, t23, _VECTORMATH_PERM_YXWZ); /* GP CL OH KD */ + cof0 = vec_nmsub(t1, t23, vzero); /* -(JGP NCL FOH BKD) */ + cof1 = vec_nmsub(t0, t23, vzero); /* -(AGP ECL IOH MKD) */ + t23r = vec_sld(t23, t23, 8); /* OH KD GP CL */ + cof0 = vec_madd(t1, t23r, cof0); /* JOH NKD BGP FCL + cof0 */ + cof1 = vec_madd(t0, t23r, cof1); /* AOH EKD IGP MCL + cof1 */ + cof1 = vec_sld(cof1, cof1, 8); /* IGP MCL AOH EKD - IOH MKD AGP ECL */ + t12 = vec_madd(t1, t2, vzero); /* JC NG BK FO */ + t12 = vec_perm(t12, t12, _VECTORMATH_PERM_YXWZ); /* NG JC FO BK */ + cof0 = vec_madd(t3, t12, cof0); /* LNG PJC DFO HBK + cof0 */ + cof3 = vec_madd(t0, t12, vzero); /* ANG EJC IFO MBK */ + t12r = vec_sld(t12, t12, 8); /* FO BK NG JC */ + cof0 = vec_nmsub(t3, t12r, cof0); /* cof0 - LFO PBK DNG HJC */ + cof3 = vec_nmsub(t0, t12r, cof3); /* cof3 - AFO EBK ING MJC */ + cof3 = vec_sld(cof3, cof3, 8); /* ING MJC AFO EBK - IFO MBK ANG EJC */ + t1r = vec_sld(t1, t1, 8); /* B F J N */ + t2r = vec_sld(t2, t2, 8); /* K O C G */ + t1r3 = vec_madd(t1r, t3, vzero); /* BL FP JD NH */ + t1r3 = vec_perm(t1r3, t1r3, _VECTORMATH_PERM_YXWZ); /* FP BL NH JD */ + cof0 = vec_madd(t2r, t1r3, cof0); /* KFP OBL CNH GJD + cof0 */ + cof2 = vec_madd(t0, t1r3, vzero); /* AFP EBL INH MJD */ + t1r3r = vec_sld(t1r3, t1r3, 8); /* NH JD FP BL */ + cof0 = vec_nmsub(t2r, t1r3r, cof0); /* cof0 - KNH OJD CFP GBL */ + cof2 = vec_nmsub(t0, t1r3r, cof2); /* cof2 - ANH EJD IFP MBL */ + cof2 = vec_sld(cof2, cof2, 8); /* IFP MBL ANH EJD - INH MJD AFP EBL */ + t01 = vec_madd(t0, t1, vzero); /* AJ EN IB MF */ + t01 = vec_perm(t01, t01, _VECTORMATH_PERM_YXWZ); /* EN AJ MF IB */ + cof2 = vec_nmsub(t3, t01, cof2); /* cof2 - LEN PAJ DMF HIB */ + cof3 = vec_madd(t2r, t01, cof3); /* KEN OAJ CMF GIB + cof3 */ + t01r = vec_sld(t01, t01, 8); /* MF IB EN AJ */ + cof2 = vec_madd(t3, t01r, cof2); /* LMF PIB DEN HAJ + cof2 */ + cof3 = vec_nmsub(t2r, t01r, cof3); /* cof3 - KMF OIB CEN GAJ */ + t03 = vec_madd(t0, t3, vzero); /* AL EP ID MH */ + t03 = vec_perm(t03, t03, _VECTORMATH_PERM_YXWZ); /* EP AL MH ID */ + cof1 = vec_nmsub(t2r, t03, cof1); /* cof1 - KEP OAL CMH GID */ + cof2 = vec_madd(t1, t03, cof2); /* JEP NAL BMH FID + cof2 */ + t03r = vec_sld(t03, t03, 8); /* MH ID EP AL */ + cof1 = vec_madd(t2r, t03r, cof1); /* KMH OID CEP GAL + cof1 */ + cof2 = vec_nmsub(t1, t03r, cof2); /* cof2 - JMH NID BEP FAL */ + t02 = vec_madd(t0, t2r, vzero); /* AK EO IC MG */ + t02 = vec_perm(t02, t02, _VECTORMATH_PERM_YXWZ); /* E0 AK MG IC */ + cof1 = vec_madd(t3, t02, cof1); /* LEO PAK DMG HIC + cof1 */ + cof3 = vec_nmsub(t1, t02, cof3); /* cof3 - JEO NAK BMG FIC */ + t02r = vec_sld(t02, t02, 8); /* MG IC EO AK */ + cof1 = vec_nmsub(t3, t02r, cof1); /* cof1 - LMG PIC DEO HAK */ + cof3 = vec_madd(t1, t02r, cof3); /* JMG NIC BEO FAK + cof3 */ + /* Compute the determinant of the matrix + * + * det = sum_across(t0 * cof0); + * + * We perform a sum across the entire vector so that + * we don't have to splat the result when multiplying the + * cofactors by the inverse of the determinant. + */ + det = vec_madd(t0, cof0, vzero); + det0 = vec_splat(det, 0); + det1 = vec_splat(det, 1); + det2 = vec_splat(det, 2); + det3 = vec_splat(det, 3); + det = vec_add(det0, det1); + det2 = vec_add(det2, det3); + det = vec_add(det, det2); + /* Compute the reciprocal of the determinant. + */ + invdet = recipf4(det); + /* Multiply the cofactors by the reciprocal of the determinant. + */ + return Matrix4( + Vector4( vec_madd(cof0, invdet, vzero) ), + Vector4( vec_madd(cof1, invdet, vzero) ), + Vector4( vec_madd(cof2, invdet, vzero) ), + Vector4( vec_madd(cof3, invdet, vzero) ) + ); +} + +inline const Matrix4 affineInverse( const Matrix4 & mat ) +{ + Transform3 affineMat; + affineMat.setCol0( mat.getCol0().getXYZ( ) ); + affineMat.setCol1( mat.getCol1().getXYZ( ) ); + affineMat.setCol2( mat.getCol2().getXYZ( ) ); + affineMat.setCol3( mat.getCol3().getXYZ( ) ); + return Matrix4( inverse( affineMat ) ); +} + +inline const Matrix4 orthoInverse( const Matrix4 & mat ) +{ + Transform3 affineMat; + affineMat.setCol0( mat.getCol0().getXYZ( ) ); + affineMat.setCol1( mat.getCol1().getXYZ( ) ); + affineMat.setCol2( mat.getCol2().getXYZ( ) ); + affineMat.setCol3( mat.getCol3().getXYZ( ) ); + return Matrix4( orthoInverse( affineMat ) ); +} + +inline const floatInVec determinant( const Matrix4 & mat ) +{ + /* function implementation based on code from STIDC SDK: */ + /* -------------------------------------------------------------- */ + /* PLEASE DO NOT MODIFY THIS SECTION */ + /* This prolog section is automatically generated. */ + /* */ + /* (C)Copyright */ + /* Sony Computer Entertainment, Inc., */ + /* Toshiba Corporation, */ + /* International Business Machines Corporation, */ + /* 2001,2002. */ + /* S/T/I Confidential Information */ + /* -------------------------------------------------------------- */ + vector float in0, in1, in2, in3; + vector float tmp0, tmp1, tmp2, tmp3; + vector float cof0; + vector float t0, t1, t2, t3; + vector float t12, t23; + vector float t1r, t2r; + vector float t12r, t23r; + vector float t1r3, t1r3r; + vector float vzero = (vector float){0.0}; + in0 = mat.getCol0().get128(); + in1 = mat.getCol1().get128(); + in2 = mat.getCol2().get128(); + in3 = mat.getCol3().get128(); + /* Perform transform of the input matrix of the form: + * A B C D + * E F G H + * I J K L + * M N O P + * + * The pseudo transpose of the input matrix is trans: + * A E I M + * J N B F + * C G K O + * L P D H + */ + tmp0 = vec_perm(in0, in1, _VECTORMATH_PERM_XAZC); /* A E C G */ + tmp1 = vec_perm(in2, in3, _VECTORMATH_PERM_XAZC); /* I M K O */ + tmp2 = vec_perm(in0, in1, _VECTORMATH_PERM_YBWD); /* B F D H */ + tmp3 = vec_perm(in2, in3, _VECTORMATH_PERM_YBWD); /* J N L P */ + t0 = vec_perm(tmp0, tmp1, _VECTORMATH_PERM_XYAB); /* A E I M */ + t1 = vec_perm(tmp3, tmp2, _VECTORMATH_PERM_XYAB); /* J N B F */ + t2 = vec_perm(tmp0, tmp1, _VECTORMATH_PERM_ZWCD); /* C G K O */ + t3 = vec_perm(tmp3, tmp2, _VECTORMATH_PERM_ZWCD); /* L P D H */ + /* Generate a cofactor matrix. The computed cofactors reside in + * cof0, cof1, cof2, cof3. + */ + t23 = vec_madd(t2, t3, vzero); /* CL GP KD OH */ + t23 = vec_perm(t23, t23, _VECTORMATH_PERM_YXWZ); /* GP CL OH KD */ + cof0 = vec_nmsub(t1, t23, vzero); /* -(JGP NCL FOH BKD) */ + t23r = vec_sld(t23, t23, 8); /* OH KD GP CL */ + cof0 = vec_madd(t1, t23r, cof0); /* JOH NKD BGP FCL + cof0 */ + t12 = vec_madd(t1, t2, vzero); /* JC NG BK FO */ + t12 = vec_perm(t12, t12, _VECTORMATH_PERM_YXWZ); /* NG JC FO BK */ + cof0 = vec_madd(t3, t12, cof0); /* LNG PJC DFO HBK + cof0 */ + t12r = vec_sld(t12, t12, 8); /* FO BK NG JC */ + cof0 = vec_nmsub(t3, t12r, cof0); /* cof0 - LFO PBK DNG HJC */ + t1r = vec_sld(t1, t1, 8); /* B F J N */ + t2r = vec_sld(t2, t2, 8); /* K O C G */ + t1r3 = vec_madd(t1r, t3, vzero); /* BL FP JD NH */ + t1r3 = vec_perm(t1r3, t1r3, _VECTORMATH_PERM_YXWZ); /* FP BL NH JD */ + cof0 = vec_madd(t2r, t1r3, cof0); /* KFP OBL CNH GJD + cof0 */ + t1r3r = vec_sld(t1r3, t1r3, 8); /* NH JD FP BL */ + cof0 = vec_nmsub(t2r, t1r3r, cof0); /* cof0 - KNH OJD CFP GBL */ + return floatInVec( _vmathVfDot4(t0,cof0), 0 ); +} + +inline const Matrix4 Matrix4::operator +( const Matrix4 & mat ) const +{ + return Matrix4( + ( mCol0 + mat.mCol0 ), + ( mCol1 + mat.mCol1 ), + ( mCol2 + mat.mCol2 ), + ( mCol3 + mat.mCol3 ) + ); +} + +inline const Matrix4 Matrix4::operator -( const Matrix4 & mat ) const +{ + return Matrix4( + ( mCol0 - mat.mCol0 ), + ( mCol1 - mat.mCol1 ), + ( mCol2 - mat.mCol2 ), + ( mCol3 - mat.mCol3 ) + ); +} + +inline Matrix4 & Matrix4::operator +=( const Matrix4 & mat ) +{ + *this = *this + mat; + return *this; +} + +inline Matrix4 & Matrix4::operator -=( const Matrix4 & mat ) +{ + *this = *this - mat; + return *this; +} + +inline const Matrix4 Matrix4::operator -( ) const +{ + return Matrix4( + ( -mCol0 ), + ( -mCol1 ), + ( -mCol2 ), + ( -mCol3 ) + ); +} + +inline const Matrix4 absPerElem( const Matrix4 & mat ) +{ + return Matrix4( + absPerElem( mat.getCol0() ), + absPerElem( mat.getCol1() ), + absPerElem( mat.getCol2() ), + absPerElem( mat.getCol3() ) + ); +} + +inline const Matrix4 Matrix4::operator *( float scalar ) const +{ + return *this * floatInVec(scalar); +} + +inline const Matrix4 Matrix4::operator *( floatInVec scalar ) const +{ + return Matrix4( + ( mCol0 * scalar ), + ( mCol1 * scalar ), + ( mCol2 * scalar ), + ( mCol3 * scalar ) + ); +} + +inline Matrix4 & Matrix4::operator *=( float scalar ) +{ + return *this *= floatInVec(scalar); +} + +inline Matrix4 & Matrix4::operator *=( floatInVec scalar ) +{ + *this = *this * scalar; + return *this; +} + +inline const Matrix4 operator *( float scalar, const Matrix4 & mat ) +{ + return floatInVec(scalar) * mat; +} + +inline const Matrix4 operator *( floatInVec scalar, const Matrix4 & mat ) +{ + return mat * scalar; +} + +inline const Vector4 Matrix4::operator *( Vector4 vec ) const +{ + vec_float4 tmp0, tmp1, res; + vec_float4 xxxx, yyyy, zzzz, wwww; + vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + xxxx = vec_splat( vec.get128(), 0 ); + yyyy = vec_splat( vec.get128(), 1 ); + zzzz = vec_splat( vec.get128(), 2 ); + wwww = vec_splat( vec.get128(), 3 ); + tmp0 = vec_madd( mCol0.get128(), xxxx, zero ); + tmp1 = vec_madd( mCol1.get128(), yyyy, zero ); + tmp0 = vec_madd( mCol2.get128(), zzzz, tmp0 ); + tmp1 = vec_madd( mCol3.get128(), wwww, tmp1 ); + res = vec_add( tmp0, tmp1 ); + return Vector4( res ); +} + +inline const Vector4 Matrix4::operator *( Vector3 vec ) const +{ + vec_float4 res; + vec_float4 xxxx, yyyy, zzzz; + xxxx = vec_splat( vec.get128(), 0 ); + yyyy = vec_splat( vec.get128(), 1 ); + zzzz = vec_splat( vec.get128(), 2 ); + res = vec_madd( mCol0.get128(), xxxx, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + res = vec_madd( mCol1.get128(), yyyy, res ); + res = vec_madd( mCol2.get128(), zzzz, res ); + return Vector4( res ); +} + +inline const Vector4 Matrix4::operator *( Point3 pnt ) const +{ + vec_float4 tmp0, tmp1, res; + vec_float4 xxxx, yyyy, zzzz; + vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + xxxx = vec_splat( pnt.get128(), 0 ); + yyyy = vec_splat( pnt.get128(), 1 ); + zzzz = vec_splat( pnt.get128(), 2 ); + tmp0 = vec_madd( mCol0.get128(), xxxx, zero ); + tmp1 = vec_madd( mCol1.get128(), yyyy, zero ); + tmp0 = vec_madd( mCol2.get128(), zzzz, tmp0 ); + tmp1 = vec_add( mCol3.get128(), tmp1 ); + res = vec_add( tmp0, tmp1 ); + return Vector4( res ); +} + +inline const Matrix4 Matrix4::operator *( const Matrix4 & mat ) const +{ + return Matrix4( + ( *this * mat.mCol0 ), + ( *this * mat.mCol1 ), + ( *this * mat.mCol2 ), + ( *this * mat.mCol3 ) + ); +} + +inline Matrix4 & Matrix4::operator *=( const Matrix4 & mat ) +{ + *this = *this * mat; + return *this; +} + +inline const Matrix4 Matrix4::operator *( const Transform3 & tfrm ) const +{ + return Matrix4( + ( *this * tfrm.getCol0() ), + ( *this * tfrm.getCol1() ), + ( *this * tfrm.getCol2() ), + ( *this * Point3( tfrm.getCol3() ) ) + ); +} + +inline Matrix4 & Matrix4::operator *=( const Transform3 & tfrm ) +{ + *this = *this * tfrm; + return *this; +} + +inline const Matrix4 mulPerElem( const Matrix4 & mat0, const Matrix4 & mat1 ) +{ + return Matrix4( + mulPerElem( mat0.getCol0(), mat1.getCol0() ), + mulPerElem( mat0.getCol1(), mat1.getCol1() ), + mulPerElem( mat0.getCol2(), mat1.getCol2() ), + mulPerElem( mat0.getCol3(), mat1.getCol3() ) + ); +} + +inline const Matrix4 Matrix4::identity( ) +{ + return Matrix4( + Vector4::xAxis( ), + Vector4::yAxis( ), + Vector4::zAxis( ), + Vector4::wAxis( ) + ); +} + +inline Matrix4 & Matrix4::setUpper3x3( const Matrix3 & mat3 ) +{ + mCol0.setXYZ( mat3.getCol0() ); + mCol1.setXYZ( mat3.getCol1() ); + mCol2.setXYZ( mat3.getCol2() ); + return *this; +} + +inline const Matrix3 Matrix4::getUpper3x3( ) const +{ + return Matrix3( + mCol0.getXYZ( ), + mCol1.getXYZ( ), + mCol2.getXYZ( ) + ); +} + +inline Matrix4 & Matrix4::setTranslation( Vector3 translateVec ) +{ + mCol3.setXYZ( translateVec ); + return *this; +} + +inline const Vector3 Matrix4::getTranslation( ) const +{ + return mCol3.getXYZ( ); +} + +inline const Matrix4 Matrix4::rotationX( float radians ) +{ + return rotationX( floatInVec(radians) ); +} + +inline const Matrix4 Matrix4::rotationX( floatInVec radians ) +{ + vec_float4 s, c, res1, res2; + vec_uint4 select_y, select_z; + vec_float4 zero; + select_y = _VECTORMATH_MASK_0x0F00; + select_z = _VECTORMATH_MASK_0x00F0; + zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + sincosf4( radians.get128(), &s, &c ); + res1 = vec_sel( zero, c, select_y ); + res1 = vec_sel( res1, s, select_z ); + res2 = vec_sel( zero, negatef4(s), select_y ); + res2 = vec_sel( res2, c, select_z ); + return Matrix4( + Vector4::xAxis( ), + Vector4( res1 ), + Vector4( res2 ), + Vector4::wAxis( ) + ); +} + +inline const Matrix4 Matrix4::rotationY( float radians ) +{ + return rotationY( floatInVec(radians) ); +} + +inline const Matrix4 Matrix4::rotationY( floatInVec radians ) +{ + vec_float4 s, c, res0, res2; + vec_uint4 select_x, select_z; + vec_float4 zero; + select_x = _VECTORMATH_MASK_0xF000; + select_z = _VECTORMATH_MASK_0x00F0; + zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + sincosf4( radians.get128(), &s, &c ); + res0 = vec_sel( zero, c, select_x ); + res0 = vec_sel( res0, negatef4(s), select_z ); + res2 = vec_sel( zero, s, select_x ); + res2 = vec_sel( res2, c, select_z ); + return Matrix4( + Vector4( res0 ), + Vector4::yAxis( ), + Vector4( res2 ), + Vector4::wAxis( ) + ); +} + +inline const Matrix4 Matrix4::rotationZ( float radians ) +{ + return rotationZ( floatInVec(radians) ); +} + +inline const Matrix4 Matrix4::rotationZ( floatInVec radians ) +{ + vec_float4 s, c, res0, res1; + vec_uint4 select_x, select_y; + vec_float4 zero; + select_x = _VECTORMATH_MASK_0xF000; + select_y = _VECTORMATH_MASK_0x0F00; + zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + sincosf4( radians.get128(), &s, &c ); + res0 = vec_sel( zero, c, select_x ); + res0 = vec_sel( res0, s, select_y ); + res1 = vec_sel( zero, negatef4(s), select_x ); + res1 = vec_sel( res1, c, select_y ); + return Matrix4( + Vector4( res0 ), + Vector4( res1 ), + Vector4::zAxis( ), + Vector4::wAxis( ) + ); +} + +inline const Matrix4 Matrix4::rotationZYX( Vector3 radiansXYZ ) +{ + vec_float4 angles, s, negS, c, X0, X1, Y0, Y1, Z0, Z1, tmp; + vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + angles = Vector4( radiansXYZ, 0.0f ).get128(); + sincosf4( angles, &s, &c ); + negS = negatef4( s ); + Z0 = vec_mergel( c, s ); + Z1 = vec_mergel( negS, c ); + Z1 = vec_andc( Z1, (vec_float4)_VECTORMATH_MASK_0x000F ); + Y0 = vec_perm( negS, c, _VECTORMATH_PERM_BBYX ); + Y1 = vec_perm( c, s, _VECTORMATH_PERM_BBYX ); + X0 = vec_splat( s, 0 ); + X1 = vec_splat( c, 0 ); + tmp = vec_madd( Z0, Y1, zero ); + return Matrix4( + Vector4( vec_madd( Z0, Y0, zero ) ), + Vector4( vec_madd( Z1, X1, vec_madd( tmp, X0, zero ) ) ), + Vector4( vec_nmsub( Z1, X0, vec_madd( tmp, X1, zero ) ) ), + Vector4::wAxis( ) + ); +} + +inline const Matrix4 Matrix4::rotation( float radians, Vector3 unitVec ) +{ + return rotation( floatInVec(radians), unitVec ); +} + +inline const Matrix4 Matrix4::rotation( floatInVec radians, Vector3 unitVec ) +{ + vec_float4 axis, s, c, oneMinusC, axisS, negAxisS, xxxx, yyyy, zzzz, tmp0, tmp1, tmp2, zeroW; + vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + axis = unitVec.get128(); + sincosf4( radians.get128(), &s, &c ); + xxxx = vec_splat( axis, 0 ); + yyyy = vec_splat( axis, 1 ); + zzzz = vec_splat( axis, 2 ); + oneMinusC = vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), c ); + axisS = vec_madd( axis, s, zero ); + negAxisS = negatef4( axisS ); + tmp0 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_XZBX ); + tmp1 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_CXXX ); + tmp2 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_YAXX ); + tmp0 = vec_sel( tmp0, c, _VECTORMATH_MASK_0xF000 ); + tmp1 = vec_sel( tmp1, c, _VECTORMATH_MASK_0x0F00 ); + tmp2 = vec_sel( tmp2, c, _VECTORMATH_MASK_0x00F0 ); + zeroW = (vec_float4)_VECTORMATH_MASK_0x000F; + axis = vec_andc( axis, zeroW ); + tmp0 = vec_andc( tmp0, zeroW ); + tmp1 = vec_andc( tmp1, zeroW ); + tmp2 = vec_andc( tmp2, zeroW ); + return Matrix4( + Vector4( vec_madd( vec_madd( axis, xxxx, zero ), oneMinusC, tmp0 ) ), + Vector4( vec_madd( vec_madd( axis, yyyy, zero ), oneMinusC, tmp1 ) ), + Vector4( vec_madd( vec_madd( axis, zzzz, zero ), oneMinusC, tmp2 ) ), + Vector4::wAxis( ) + ); +} + +inline const Matrix4 Matrix4::rotation( Quat unitQuat ) +{ + return Matrix4( Transform3::rotation( unitQuat ) ); +} + +inline const Matrix4 Matrix4::scale( Vector3 scaleVec ) +{ + vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + return Matrix4( + Vector4( vec_sel( zero, scaleVec.get128(), _VECTORMATH_MASK_0xF000 ) ), + Vector4( vec_sel( zero, scaleVec.get128(), _VECTORMATH_MASK_0x0F00 ) ), + Vector4( vec_sel( zero, scaleVec.get128(), _VECTORMATH_MASK_0x00F0 ) ), + Vector4::wAxis( ) + ); +} + +inline const Matrix4 appendScale( const Matrix4 & mat, Vector3 scaleVec ) +{ + return Matrix4( + ( mat.getCol0() * scaleVec.getX( ) ), + ( mat.getCol1() * scaleVec.getY( ) ), + ( mat.getCol2() * scaleVec.getZ( ) ), + mat.getCol3() + ); +} + +inline const Matrix4 prependScale( Vector3 scaleVec, const Matrix4 & mat ) +{ + Vector4 scale4; + scale4 = Vector4( scaleVec, 1.0f ); + return Matrix4( + mulPerElem( mat.getCol0(), scale4 ), + mulPerElem( mat.getCol1(), scale4 ), + mulPerElem( mat.getCol2(), scale4 ), + mulPerElem( mat.getCol3(), scale4 ) + ); +} + +inline const Matrix4 Matrix4::translation( Vector3 translateVec ) +{ + return Matrix4( + Vector4::xAxis( ), + Vector4::yAxis( ), + Vector4::zAxis( ), + Vector4( translateVec, 1.0f ) + ); +} + +inline const Matrix4 Matrix4::lookAt( Point3 eyePos, Point3 lookAtPos, Vector3 upVec ) +{ + Matrix4 m4EyeFrame; + Vector3 v3X, v3Y, v3Z; + v3Y = normalize( upVec ); + v3Z = normalize( ( eyePos - lookAtPos ) ); + v3X = normalize( cross( v3Y, v3Z ) ); + v3Y = cross( v3Z, v3X ); + m4EyeFrame = Matrix4( Vector4( v3X ), Vector4( v3Y ), Vector4( v3Z ), Vector4( eyePos ) ); + return orthoInverse( m4EyeFrame ); +} + +inline const Matrix4 Matrix4::perspective( float fovyRadians, float aspect, float zNear, float zFar ) +{ + float f, rangeInv; + vec_float4 zero, col0, col1, col2, col3; + union { vec_float4 v; float s[4]; } tmp; + f = tanf( _VECTORMATH_PI_OVER_2 - fovyRadians * 0.5f ); + rangeInv = 1.0f / ( zNear - zFar ); + zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + tmp.v = zero; + tmp.s[0] = f / aspect; + col0 = tmp.v; + tmp.v = zero; + tmp.s[1] = f; + col1 = tmp.v; + tmp.v = zero; + tmp.s[2] = ( zNear + zFar ) * rangeInv; + tmp.s[3] = -1.0f; + col2 = tmp.v; + tmp.v = zero; + tmp.s[2] = zNear * zFar * rangeInv * 2.0f; + col3 = tmp.v; + return Matrix4( + Vector4( col0 ), + Vector4( col1 ), + Vector4( col2 ), + Vector4( col3 ) + ); +} + +inline const Matrix4 Matrix4::frustum( float left, float right, float bottom, float top, float zNear, float zFar ) +{ + /* function implementation based on code from STIDC SDK: */ + /* -------------------------------------------------------------- */ + /* PLEASE DO NOT MODIFY THIS SECTION */ + /* This prolog section is automatically generated. */ + /* */ + /* (C)Copyright */ + /* Sony Computer Entertainment, Inc., */ + /* Toshiba Corporation, */ + /* International Business Machines Corporation, */ + /* 2001,2002. */ + /* S/T/I Confidential Information */ + /* -------------------------------------------------------------- */ + vec_float4 lbf, rtn; + vec_float4 diff, sum, inv_diff; + vec_float4 diagonal, column, near2; + vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + union { vec_float4 v; float s[4]; } l, f, r, n, b, t; + l.s[0] = left; + f.s[0] = zFar; + r.s[0] = right; + n.s[0] = zNear; + b.s[0] = bottom; + t.s[0] = top; + lbf = vec_mergeh( l.v, f.v ); + rtn = vec_mergeh( r.v, n.v ); + lbf = vec_mergeh( lbf, b.v ); + rtn = vec_mergeh( rtn, t.v ); + diff = vec_sub( rtn, lbf ); + sum = vec_add( rtn, lbf ); + inv_diff = recipf4( diff ); + near2 = vec_splat( n.v, 0 ); + near2 = vec_add( near2, near2 ); + diagonal = vec_madd( near2, inv_diff, zero ); + column = vec_madd( sum, inv_diff, zero ); + return Matrix4( + Vector4( vec_sel( zero, diagonal, _VECTORMATH_MASK_0xF000 ) ), + Vector4( vec_sel( zero, diagonal, _VECTORMATH_MASK_0x0F00 ) ), + Vector4( vec_sel( column, ((vec_float4){-1.0f,-1.0f,-1.0f,-1.0f}), _VECTORMATH_MASK_0x000F ) ), + Vector4( vec_sel( zero, vec_madd( diagonal, vec_splat( f.v, 0 ), zero ), _VECTORMATH_MASK_0x00F0 ) ) + ); +} + +inline const Matrix4 Matrix4::orthographic( float left, float right, float bottom, float top, float zNear, float zFar ) +{ + /* function implementation based on code from STIDC SDK: */ + /* -------------------------------------------------------------- */ + /* PLEASE DO NOT MODIFY THIS SECTION */ + /* This prolog section is automatically generated. */ + /* */ + /* (C)Copyright */ + /* Sony Computer Entertainment, Inc., */ + /* Toshiba Corporation, */ + /* International Business Machines Corporation, */ + /* 2001,2002. */ + /* S/T/I Confidential Information */ + /* -------------------------------------------------------------- */ + vec_float4 lbf, rtn; + vec_float4 diff, sum, inv_diff, neg_inv_diff; + vec_float4 diagonal, column; + vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + union { vec_float4 v; float s[4]; } l, f, r, n, b, t; + l.s[0] = left; + f.s[0] = zFar; + r.s[0] = right; + n.s[0] = zNear; + b.s[0] = bottom; + t.s[0] = top; + lbf = vec_mergeh( l.v, f.v ); + rtn = vec_mergeh( r.v, n.v ); + lbf = vec_mergeh( lbf, b.v ); + rtn = vec_mergeh( rtn, t.v ); + diff = vec_sub( rtn, lbf ); + sum = vec_add( rtn, lbf ); + inv_diff = recipf4( diff ); + neg_inv_diff = negatef4( inv_diff ); + diagonal = vec_add( inv_diff, inv_diff ); + column = vec_madd( sum, vec_sel( neg_inv_diff, inv_diff, _VECTORMATH_MASK_0x00F0 ), zero ); + return Matrix4( + Vector4( vec_sel( zero, diagonal, _VECTORMATH_MASK_0xF000 ) ), + Vector4( vec_sel( zero, diagonal, _VECTORMATH_MASK_0x0F00 ) ), + Vector4( vec_sel( zero, diagonal, _VECTORMATH_MASK_0x00F0 ) ), + Vector4( vec_sel( column, ((vec_float4){1.0f,1.0f,1.0f,1.0f}), _VECTORMATH_MASK_0x000F ) ) + ); +} + +inline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, bool select1 ) +{ + return Matrix4( + select( mat0.getCol0(), mat1.getCol0(), select1 ), + select( mat0.getCol1(), mat1.getCol1(), select1 ), + select( mat0.getCol2(), mat1.getCol2(), select1 ), + select( mat0.getCol3(), mat1.getCol3(), select1 ) + ); +} + +inline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, boolInVec select1 ) +{ + return Matrix4( + select( mat0.getCol0(), mat1.getCol0(), select1 ), + select( mat0.getCol1(), mat1.getCol1(), select1 ), + select( mat0.getCol2(), mat1.getCol2(), select1 ), + select( mat0.getCol3(), mat1.getCol3(), select1 ) + ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( const Matrix4 & mat ) +{ + print( mat.getRow( 0 ) ); + print( mat.getRow( 1 ) ); + print( mat.getRow( 2 ) ); + print( mat.getRow( 3 ) ); +} + +inline void print( const Matrix4 & mat, const char * name ) +{ + printf("%s:\n", name); + print( mat ); +} + +#endif + +inline Transform3::Transform3( const Transform3 & tfrm ) +{ + mCol0 = tfrm.mCol0; + mCol1 = tfrm.mCol1; + mCol2 = tfrm.mCol2; + mCol3 = tfrm.mCol3; +} + +inline Transform3::Transform3( float scalar ) +{ + mCol0 = Vector3( scalar ); + mCol1 = Vector3( scalar ); + mCol2 = Vector3( scalar ); + mCol3 = Vector3( scalar ); +} + +inline Transform3::Transform3( floatInVec scalar ) +{ + mCol0 = Vector3( scalar ); + mCol1 = Vector3( scalar ); + mCol2 = Vector3( scalar ); + mCol3 = Vector3( scalar ); +} + +inline Transform3::Transform3( Vector3 _col0, Vector3 _col1, Vector3 _col2, Vector3 _col3 ) +{ + mCol0 = _col0; + mCol1 = _col1; + mCol2 = _col2; + mCol3 = _col3; +} + +inline Transform3::Transform3( const Matrix3 & tfrm, Vector3 translateVec ) +{ + this->setUpper3x3( tfrm ); + this->setTranslation( translateVec ); +} + +inline Transform3::Transform3( Quat unitQuat, Vector3 translateVec ) +{ + this->setUpper3x3( Matrix3( unitQuat ) ); + this->setTranslation( translateVec ); +} + +inline Transform3 & Transform3::setCol0( Vector3 _col0 ) +{ + mCol0 = _col0; + return *this; +} + +inline Transform3 & Transform3::setCol1( Vector3 _col1 ) +{ + mCol1 = _col1; + return *this; +} + +inline Transform3 & Transform3::setCol2( Vector3 _col2 ) +{ + mCol2 = _col2; + return *this; +} + +inline Transform3 & Transform3::setCol3( Vector3 _col3 ) +{ + mCol3 = _col3; + return *this; +} + +inline Transform3 & Transform3::setCol( int col, Vector3 vec ) +{ + *(&mCol0 + col) = vec; + return *this; +} + +inline Transform3 & Transform3::setRow( int row, Vector4 vec ) +{ + mCol0.setElem( row, vec.getElem( 0 ) ); + mCol1.setElem( row, vec.getElem( 1 ) ); + mCol2.setElem( row, vec.getElem( 2 ) ); + mCol3.setElem( row, vec.getElem( 3 ) ); + return *this; +} + +inline Transform3 & Transform3::setElem( int col, int row, float val ) +{ + (*this)[col].setElem(row, val); + return *this; +} + +inline Transform3 & Transform3::setElem( int col, int row, floatInVec val ) +{ + Vector3 tmpV3_0; + tmpV3_0 = this->getCol( col ); + tmpV3_0.setElem( row, val ); + this->setCol( col, tmpV3_0 ); + return *this; +} + +inline const floatInVec Transform3::getElem( int col, int row ) const +{ + return this->getCol( col ).getElem( row ); +} + +inline const Vector3 Transform3::getCol0( ) const +{ + return mCol0; +} + +inline const Vector3 Transform3::getCol1( ) const +{ + return mCol1; +} + +inline const Vector3 Transform3::getCol2( ) const +{ + return mCol2; +} + +inline const Vector3 Transform3::getCol3( ) const +{ + return mCol3; +} + +inline const Vector3 Transform3::getCol( int col ) const +{ + return *(&mCol0 + col); +} + +inline const Vector4 Transform3::getRow( int row ) const +{ + return Vector4( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ), mCol3.getElem( row ) ); +} + +inline Vector3 & Transform3::operator []( int col ) +{ + return *(&mCol0 + col); +} + +inline const Vector3 Transform3::operator []( int col ) const +{ + return *(&mCol0 + col); +} + +inline Transform3 & Transform3::operator =( const Transform3 & tfrm ) +{ + mCol0 = tfrm.mCol0; + mCol1 = tfrm.mCol1; + mCol2 = tfrm.mCol2; + mCol3 = tfrm.mCol3; + return *this; +} + +inline const Transform3 inverse( const Transform3 & tfrm ) +{ + vec_float4 inv0, inv1, inv2, inv3; + vec_float4 tmp0, tmp1, tmp2, tmp3, tmp4, dot, invdet; + vec_float4 xxxx, yyyy, zzzz; + vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + tmp2 = _vmathVfCross( tfrm.getCol0().get128(), tfrm.getCol1().get128() ); + tmp0 = _vmathVfCross( tfrm.getCol1().get128(), tfrm.getCol2().get128() ); + tmp1 = _vmathVfCross( tfrm.getCol2().get128(), tfrm.getCol0().get128() ); + inv3 = negatef4( tfrm.getCol3().get128() ); + dot = _vmathVfDot3( tmp2, tfrm.getCol2().get128() ); + dot = vec_splat( dot, 0 ); + invdet = recipf4( dot ); + tmp3 = vec_mergeh( tmp0, tmp2 ); + tmp4 = vec_mergel( tmp0, tmp2 ); + inv0 = vec_mergeh( tmp3, tmp1 ); + xxxx = vec_splat( inv3, 0 ); + inv1 = vec_perm( tmp3, tmp1, _VECTORMATH_PERM_ZBWX ); + inv2 = vec_perm( tmp4, tmp1, _VECTORMATH_PERM_XCYX ); + yyyy = vec_splat( inv3, 1 ); + zzzz = vec_splat( inv3, 2 ); + inv3 = vec_madd( inv0, xxxx, zero ); + inv3 = vec_madd( inv1, yyyy, inv3 ); + inv3 = vec_madd( inv2, zzzz, inv3 ); + inv0 = vec_madd( inv0, invdet, zero ); + inv1 = vec_madd( inv1, invdet, zero ); + inv2 = vec_madd( inv2, invdet, zero ); + inv3 = vec_madd( inv3, invdet, zero ); + return Transform3( + Vector3( inv0 ), + Vector3( inv1 ), + Vector3( inv2 ), + Vector3( inv3 ) + ); +} + +inline const Transform3 orthoInverse( const Transform3 & tfrm ) +{ + vec_float4 inv0, inv1, inv2, inv3; + vec_float4 tmp0, tmp1; + vec_float4 xxxx, yyyy, zzzz; + tmp0 = vec_mergeh( tfrm.getCol0().get128(), tfrm.getCol2().get128() ); + tmp1 = vec_mergel( tfrm.getCol0().get128(), tfrm.getCol2().get128() ); + inv3 = negatef4( tfrm.getCol3().get128() ); + inv0 = vec_mergeh( tmp0, tfrm.getCol1().get128() ); + xxxx = vec_splat( inv3, 0 ); + inv1 = vec_perm( tmp0, tfrm.getCol1().get128(), _VECTORMATH_PERM_ZBWX ); + inv2 = vec_perm( tmp1, tfrm.getCol1().get128(), _VECTORMATH_PERM_XCYX ); + yyyy = vec_splat( inv3, 1 ); + zzzz = vec_splat( inv3, 2 ); + inv3 = vec_madd( inv0, xxxx, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + inv3 = vec_madd( inv1, yyyy, inv3 ); + inv3 = vec_madd( inv2, zzzz, inv3 ); + return Transform3( + Vector3( inv0 ), + Vector3( inv1 ), + Vector3( inv2 ), + Vector3( inv3 ) + ); +} + +inline const Transform3 absPerElem( const Transform3 & tfrm ) +{ + return Transform3( + absPerElem( tfrm.getCol0() ), + absPerElem( tfrm.getCol1() ), + absPerElem( tfrm.getCol2() ), + absPerElem( tfrm.getCol3() ) + ); +} + +inline const Vector3 Transform3::operator *( Vector3 vec ) const +{ + vec_float4 res; + vec_float4 xxxx, yyyy, zzzz; + xxxx = vec_splat( vec.get128(), 0 ); + yyyy = vec_splat( vec.get128(), 1 ); + zzzz = vec_splat( vec.get128(), 2 ); + res = vec_madd( mCol0.get128(), xxxx, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + res = vec_madd( mCol1.get128(), yyyy, res ); + res = vec_madd( mCol2.get128(), zzzz, res ); + return Vector3( res ); +} + +inline const Point3 Transform3::operator *( Point3 pnt ) const +{ + vec_float4 tmp0, tmp1, res; + vec_float4 xxxx, yyyy, zzzz; + vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + xxxx = vec_splat( pnt.get128(), 0 ); + yyyy = vec_splat( pnt.get128(), 1 ); + zzzz = vec_splat( pnt.get128(), 2 ); + tmp0 = vec_madd( mCol0.get128(), xxxx, zero ); + tmp1 = vec_madd( mCol1.get128(), yyyy, zero ); + tmp0 = vec_madd( mCol2.get128(), zzzz, tmp0 ); + tmp1 = vec_add( mCol3.get128(), tmp1 ); + res = vec_add( tmp0, tmp1 ); + return Point3( res ); +} + +inline const Transform3 Transform3::operator *( const Transform3 & tfrm ) const +{ + return Transform3( + ( *this * tfrm.mCol0 ), + ( *this * tfrm.mCol1 ), + ( *this * tfrm.mCol2 ), + Vector3( ( *this * Point3( tfrm.mCol3 ) ) ) + ); +} + +inline Transform3 & Transform3::operator *=( const Transform3 & tfrm ) +{ + *this = *this * tfrm; + return *this; +} + +inline const Transform3 mulPerElem( const Transform3 & tfrm0, const Transform3 & tfrm1 ) +{ + return Transform3( + mulPerElem( tfrm0.getCol0(), tfrm1.getCol0() ), + mulPerElem( tfrm0.getCol1(), tfrm1.getCol1() ), + mulPerElem( tfrm0.getCol2(), tfrm1.getCol2() ), + mulPerElem( tfrm0.getCol3(), tfrm1.getCol3() ) + ); +} + +inline const Transform3 Transform3::identity( ) +{ + return Transform3( + Vector3::xAxis( ), + Vector3::yAxis( ), + Vector3::zAxis( ), + Vector3( 0.0f ) + ); +} + +inline Transform3 & Transform3::setUpper3x3( const Matrix3 & tfrm ) +{ + mCol0 = tfrm.getCol0(); + mCol1 = tfrm.getCol1(); + mCol2 = tfrm.getCol2(); + return *this; +} + +inline const Matrix3 Transform3::getUpper3x3( ) const +{ + return Matrix3( mCol0, mCol1, mCol2 ); +} + +inline Transform3 & Transform3::setTranslation( Vector3 translateVec ) +{ + mCol3 = translateVec; + return *this; +} + +inline const Vector3 Transform3::getTranslation( ) const +{ + return mCol3; +} + +inline const Transform3 Transform3::rotationX( float radians ) +{ + return rotationX( floatInVec(radians) ); +} + +inline const Transform3 Transform3::rotationX( floatInVec radians ) +{ + vec_float4 s, c, res1, res2; + vec_uint4 select_y, select_z; + vec_float4 zero; + select_y = _VECTORMATH_MASK_0x0F00; + select_z = _VECTORMATH_MASK_0x00F0; + zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + sincosf4( radians.get128(), &s, &c ); + res1 = vec_sel( zero, c, select_y ); + res1 = vec_sel( res1, s, select_z ); + res2 = vec_sel( zero, negatef4(s), select_y ); + res2 = vec_sel( res2, c, select_z ); + return Transform3( + Vector3::xAxis( ), + Vector3( res1 ), + Vector3( res2 ), + Vector3( 0.0f ) + ); +} + +inline const Transform3 Transform3::rotationY( float radians ) +{ + return rotationY( floatInVec(radians) ); +} + +inline const Transform3 Transform3::rotationY( floatInVec radians ) +{ + vec_float4 s, c, res0, res2; + vec_uint4 select_x, select_z; + vec_float4 zero; + select_x = _VECTORMATH_MASK_0xF000; + select_z = _VECTORMATH_MASK_0x00F0; + zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + sincosf4( radians.get128(), &s, &c ); + res0 = vec_sel( zero, c, select_x ); + res0 = vec_sel( res0, negatef4(s), select_z ); + res2 = vec_sel( zero, s, select_x ); + res2 = vec_sel( res2, c, select_z ); + return Transform3( + Vector3( res0 ), + Vector3::yAxis( ), + Vector3( res2 ), + Vector3( 0.0f ) + ); +} + +inline const Transform3 Transform3::rotationZ( float radians ) +{ + return rotationZ( floatInVec(radians) ); +} + +inline const Transform3 Transform3::rotationZ( floatInVec radians ) +{ + vec_float4 s, c, res0, res1; + vec_uint4 select_x, select_y; + vec_float4 zero; + select_x = _VECTORMATH_MASK_0xF000; + select_y = _VECTORMATH_MASK_0x0F00; + zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + sincosf4( radians.get128(), &s, &c ); + res0 = vec_sel( zero, c, select_x ); + res0 = vec_sel( res0, s, select_y ); + res1 = vec_sel( zero, negatef4(s), select_x ); + res1 = vec_sel( res1, c, select_y ); + return Transform3( + Vector3( res0 ), + Vector3( res1 ), + Vector3::zAxis( ), + Vector3( 0.0f ) + ); +} + +inline const Transform3 Transform3::rotationZYX( Vector3 radiansXYZ ) +{ + vec_float4 angles, s, negS, c, X0, X1, Y0, Y1, Z0, Z1, tmp; + vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + angles = Vector4( radiansXYZ, 0.0f ).get128(); + sincosf4( angles, &s, &c ); + negS = negatef4( s ); + Z0 = vec_mergel( c, s ); + Z1 = vec_mergel( negS, c ); + Z1 = vec_andc( Z1, (vec_float4)_VECTORMATH_MASK_0x000F ); + Y0 = vec_perm( negS, c, _VECTORMATH_PERM_BBYX ); + Y1 = vec_perm( c, s, _VECTORMATH_PERM_BBYX ); + X0 = vec_splat( s, 0 ); + X1 = vec_splat( c, 0 ); + tmp = vec_madd( Z0, Y1, zero ); + return Transform3( + Vector3( vec_madd( Z0, Y0, zero ) ), + Vector3( vec_madd( Z1, X1, vec_madd( tmp, X0, zero ) ) ), + Vector3( vec_nmsub( Z1, X0, vec_madd( tmp, X1, zero ) ) ), + Vector3( 0.0f ) + ); +} + +inline const Transform3 Transform3::rotation( float radians, Vector3 unitVec ) +{ + return rotation( floatInVec(radians), unitVec ); +} + +inline const Transform3 Transform3::rotation( floatInVec radians, Vector3 unitVec ) +{ + return Transform3( Matrix3::rotation( radians, unitVec ), Vector3( 0.0f ) ); +} + +inline const Transform3 Transform3::rotation( Quat unitQuat ) +{ + return Transform3( Matrix3( unitQuat ), Vector3( 0.0f ) ); +} + +inline const Transform3 Transform3::scale( Vector3 scaleVec ) +{ + vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + return Transform3( + Vector3( vec_sel( zero, scaleVec.get128(), _VECTORMATH_MASK_0xF000 ) ), + Vector3( vec_sel( zero, scaleVec.get128(), _VECTORMATH_MASK_0x0F00 ) ), + Vector3( vec_sel( zero, scaleVec.get128(), _VECTORMATH_MASK_0x00F0 ) ), + Vector3( 0.0f ) + ); +} + +inline const Transform3 appendScale( const Transform3 & tfrm, Vector3 scaleVec ) +{ + return Transform3( + ( tfrm.getCol0() * scaleVec.getX( ) ), + ( tfrm.getCol1() * scaleVec.getY( ) ), + ( tfrm.getCol2() * scaleVec.getZ( ) ), + tfrm.getCol3() + ); +} + +inline const Transform3 prependScale( Vector3 scaleVec, const Transform3 & tfrm ) +{ + return Transform3( + mulPerElem( tfrm.getCol0(), scaleVec ), + mulPerElem( tfrm.getCol1(), scaleVec ), + mulPerElem( tfrm.getCol2(), scaleVec ), + mulPerElem( tfrm.getCol3(), scaleVec ) + ); +} + +inline const Transform3 Transform3::translation( Vector3 translateVec ) +{ + return Transform3( + Vector3::xAxis( ), + Vector3::yAxis( ), + Vector3::zAxis( ), + translateVec + ); +} + +inline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, bool select1 ) +{ + return Transform3( + select( tfrm0.getCol0(), tfrm1.getCol0(), select1 ), + select( tfrm0.getCol1(), tfrm1.getCol1(), select1 ), + select( tfrm0.getCol2(), tfrm1.getCol2(), select1 ), + select( tfrm0.getCol3(), tfrm1.getCol3(), select1 ) + ); +} + +inline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, boolInVec select1 ) +{ + return Transform3( + select( tfrm0.getCol0(), tfrm1.getCol0(), select1 ), + select( tfrm0.getCol1(), tfrm1.getCol1(), select1 ), + select( tfrm0.getCol2(), tfrm1.getCol2(), select1 ), + select( tfrm0.getCol3(), tfrm1.getCol3(), select1 ) + ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( const Transform3 & tfrm ) +{ + print( tfrm.getRow( 0 ) ); + print( tfrm.getRow( 1 ) ); + print( tfrm.getRow( 2 ) ); +} + +inline void print( const Transform3 & tfrm, const char * name ) +{ + printf("%s:\n", name); + print( tfrm ); +} + +#endif + +inline Quat::Quat( const Matrix3 & tfrm ) +{ + vec_float4 res; + vec_float4 col0, col1, col2; + vec_float4 xx_yy, xx_yy_zz_xx, yy_zz_xx_yy, zz_xx_yy_zz, diagSum, diagDiff; + vec_float4 zy_xz_yx, yz_zx_xy, sum, diff; + vec_float4 radicand, invSqrt, scale; + vec_float4 res0, res1, res2, res3; + vec_float4 xx, yy, zz; + vec_uint4 select_x = _VECTORMATH_MASK_0xF000; + vec_uint4 select_y = _VECTORMATH_MASK_0x0F00; + vec_uint4 select_z = _VECTORMATH_MASK_0x00F0; + vec_uint4 select_w = _VECTORMATH_MASK_0x000F; + vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); + + col0 = tfrm.getCol0().get128(); + col1 = tfrm.getCol1().get128(); + col2 = tfrm.getCol2().get128(); + + /* four cases: */ + /* trace > 0 */ + /* else */ + /* xx largest diagonal element */ + /* yy largest diagonal element */ + /* zz largest diagonal element */ + + /* compute quaternion for each case */ + + xx_yy = vec_sel( col0, col1, select_y ); + xx_yy_zz_xx = vec_perm( xx_yy, col2, _VECTORMATH_PERM_XYCX ); + yy_zz_xx_yy = vec_perm( xx_yy, col2, _VECTORMATH_PERM_YCXY ); + zz_xx_yy_zz = vec_perm( xx_yy, col2, _VECTORMATH_PERM_CXYC ); + + diagSum = vec_add( vec_add( xx_yy_zz_xx, yy_zz_xx_yy ), zz_xx_yy_zz ); + diagDiff = vec_sub( vec_sub( xx_yy_zz_xx, yy_zz_xx_yy ), zz_xx_yy_zz ); + radicand = vec_add( vec_sel( diagDiff, diagSum, select_w ), ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); + invSqrt = rsqrtf4( radicand ); + + zy_xz_yx = vec_sel( col0, col1, select_z ); + zy_xz_yx = vec_perm( zy_xz_yx, col2, _VECTORMATH_PERM_ZAYX ); + yz_zx_xy = vec_sel( col0, col1, select_x ); + yz_zx_xy = vec_perm( yz_zx_xy, col2, _VECTORMATH_PERM_BZXX ); + + sum = vec_add( zy_xz_yx, yz_zx_xy ); + diff = vec_sub( zy_xz_yx, yz_zx_xy ); + + scale = vec_madd( invSqrt, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), zero ); + res0 = vec_perm( sum, diff, _VECTORMATH_PERM_XZYA ); + res1 = vec_perm( sum, diff, _VECTORMATH_PERM_ZXXB ); + res2 = vec_perm( sum, diff, _VECTORMATH_PERM_YXXC ); + res3 = diff; + res0 = vec_sel( res0, radicand, select_x ); + res1 = vec_sel( res1, radicand, select_y ); + res2 = vec_sel( res2, radicand, select_z ); + res3 = vec_sel( res3, radicand, select_w ); + res0 = vec_madd( res0, vec_splat( scale, 0 ), zero ); + res1 = vec_madd( res1, vec_splat( scale, 1 ), zero ); + res2 = vec_madd( res2, vec_splat( scale, 2 ), zero ); + res3 = vec_madd( res3, vec_splat( scale, 3 ), zero ); + + /* determine case and select answer */ + + xx = vec_splat( col0, 0 ); + yy = vec_splat( col1, 1 ); + zz = vec_splat( col2, 2 ); + res = vec_sel( res0, res1, vec_cmpgt( yy, xx ) ); + res = vec_sel( res, res2, vec_and( vec_cmpgt( zz, xx ), vec_cmpgt( zz, yy ) ) ); + res = vec_sel( res, res3, vec_cmpgt( vec_splat( diagSum, 0 ), zero ) ); + mVec128 = res; +} + +inline const Matrix3 outer( Vector3 tfrm0, Vector3 tfrm1 ) +{ + return Matrix3( + ( tfrm0 * tfrm1.getX( ) ), + ( tfrm0 * tfrm1.getY( ) ), + ( tfrm0 * tfrm1.getZ( ) ) + ); +} + +inline const Matrix4 outer( Vector4 tfrm0, Vector4 tfrm1 ) +{ + return Matrix4( + ( tfrm0 * tfrm1.getX( ) ), + ( tfrm0 * tfrm1.getY( ) ), + ( tfrm0 * tfrm1.getZ( ) ), + ( tfrm0 * tfrm1.getW( ) ) + ); +} + +inline const Vector3 rowMul( Vector3 vec, const Matrix3 & mat ) +{ + vec_float4 tmp0, tmp1, mcol0, mcol1, mcol2, res; + vec_float4 xxxx, yyyy, zzzz; + tmp0 = vec_mergeh( mat.getCol0().get128(), mat.getCol2().get128() ); + tmp1 = vec_mergel( mat.getCol0().get128(), mat.getCol2().get128() ); + xxxx = vec_splat( vec.get128(), 0 ); + mcol0 = vec_mergeh( tmp0, mat.getCol1().get128() ); + mcol1 = vec_perm( tmp0, mat.getCol1().get128(), _VECTORMATH_PERM_ZBWX ); + mcol2 = vec_perm( tmp1, mat.getCol1().get128(), _VECTORMATH_PERM_XCYX ); + yyyy = vec_splat( vec.get128(), 1 ); + res = vec_madd( mcol0, xxxx, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + zzzz = vec_splat( vec.get128(), 2 ); + res = vec_madd( mcol1, yyyy, res ); + res = vec_madd( mcol2, zzzz, res ); + return Vector3( res ); +} + +inline const Matrix3 crossMatrix( Vector3 vec ) +{ + vec_float4 neg, res0, res1, res2; + neg = negatef4( vec.get128() ); + res0 = vec_perm( vec.get128(), neg, _VECTORMATH_PERM_XZBX ); + res1 = vec_perm( vec.get128(), neg, _VECTORMATH_PERM_CXXX ); + res2 = vec_perm( vec.get128(), neg, _VECTORMATH_PERM_YAXX ); + res0 = vec_andc( res0, (vec_float4)_VECTORMATH_MASK_0xF000 ); + res1 = vec_andc( res1, (vec_float4)_VECTORMATH_MASK_0x0F00 ); + res2 = vec_andc( res2, (vec_float4)_VECTORMATH_MASK_0x00F0 ); + return Matrix3( + Vector3( res0 ), + Vector3( res1 ), + Vector3( res2 ) + ); +} + +inline const Matrix3 crossMatrixMul( Vector3 vec, const Matrix3 & mat ) +{ + return Matrix3( cross( vec, mat.getCol0() ), cross( vec, mat.getCol1() ), cross( vec, mat.getCol2() ) ); +} + +} // namespace Aos +} // namespace Vectormath + +#endif diff --git a/vectormathlibrary/include/vectormath/ppu/cpp/mat_soa.h b/vectormathlibrary/include/vectormath/ppu/cpp/mat_soa.h new file mode 100644 index 000000000..7868cfd4b --- /dev/null +++ b/vectormathlibrary/include/vectormath/ppu/cpp/mat_soa.h @@ -0,0 +1,1744 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_MAT_SOA_CPP_H +#define _VECTORMATH_MAT_SOA_CPP_H + +namespace Vectormath { +namespace Soa { + +//----------------------------------------------------------------------------- +// Constants + +#define _VECTORMATH_PI_OVER_2 1.570796327f + +//----------------------------------------------------------------------------- +// Definitions + +inline Matrix3::Matrix3( const Matrix3 & mat ) +{ + mCol0 = mat.mCol0; + mCol1 = mat.mCol1; + mCol2 = mat.mCol2; +} + +inline Matrix3::Matrix3( vec_float4 scalar ) +{ + mCol0 = Vector3( scalar ); + mCol1 = Vector3( scalar ); + mCol2 = Vector3( scalar ); +} + +inline Matrix3::Matrix3( const Quat & unitQuat ) +{ + vec_float4 qx, qy, qz, qw, qx2, qy2, qz2, qxqx2, qyqy2, qzqz2, qxqy2, qyqz2, qzqw2, qxqz2, qyqw2, qxqw2; + qx = unitQuat.getX(); + qy = unitQuat.getY(); + qz = unitQuat.getZ(); + qw = unitQuat.getW(); + qx2 = vec_add( qx, qx ); + qy2 = vec_add( qy, qy ); + qz2 = vec_add( qz, qz ); + qxqx2 = vec_madd( qx, qx2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + qxqy2 = vec_madd( qx, qy2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + qxqz2 = vec_madd( qx, qz2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + qxqw2 = vec_madd( qw, qx2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + qyqy2 = vec_madd( qy, qy2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + qyqz2 = vec_madd( qy, qz2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + qyqw2 = vec_madd( qw, qy2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + qzqz2 = vec_madd( qz, qz2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + qzqw2 = vec_madd( qw, qz2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + mCol0 = Vector3( vec_sub( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), qyqy2 ), qzqz2 ), vec_add( qxqy2, qzqw2 ), vec_sub( qxqz2, qyqw2 ) ); + mCol1 = Vector3( vec_sub( qxqy2, qzqw2 ), vec_sub( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), qxqx2 ), qzqz2 ), vec_add( qyqz2, qxqw2 ) ); + mCol2 = Vector3( vec_add( qxqz2, qyqw2 ), vec_sub( qyqz2, qxqw2 ), vec_sub( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), qxqx2 ), qyqy2 ) ); +} + +inline Matrix3::Matrix3( const Vector3 & _col0, const Vector3 & _col1, const Vector3 & _col2 ) +{ + mCol0 = _col0; + mCol1 = _col1; + mCol2 = _col2; +} + +inline Matrix3::Matrix3( const Aos::Matrix3 & mat ) +{ + mCol0 = Vector3( mat.getCol0() ); + mCol1 = Vector3( mat.getCol1() ); + mCol2 = Vector3( mat.getCol2() ); +} + +inline Matrix3::Matrix3( const Aos::Matrix3 & mat0, const Aos::Matrix3 & mat1, const Aos::Matrix3 & mat2, const Aos::Matrix3 & mat3 ) +{ + mCol0 = Vector3( mat0.getCol0(), mat1.getCol0(), mat2.getCol0(), mat3.getCol0() ); + mCol1 = Vector3( mat0.getCol1(), mat1.getCol1(), mat2.getCol1(), mat3.getCol1() ); + mCol2 = Vector3( mat0.getCol2(), mat1.getCol2(), mat2.getCol2(), mat3.getCol2() ); +} + +inline void Matrix3::get4Aos( Aos::Matrix3 & result0, Aos::Matrix3 & result1, Aos::Matrix3 & result2, Aos::Matrix3 & result3 ) const +{ + Aos::Vector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3; + mCol0.get4Aos( tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3 ); + result0.setCol0( tmpV3_0 ); + result1.setCol0( tmpV3_1 ); + result2.setCol0( tmpV3_2 ); + result3.setCol0( tmpV3_3 ); + mCol1.get4Aos( tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3 ); + result0.setCol1( tmpV3_0 ); + result1.setCol1( tmpV3_1 ); + result2.setCol1( tmpV3_2 ); + result3.setCol1( tmpV3_3 ); + mCol2.get4Aos( tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3 ); + result0.setCol2( tmpV3_0 ); + result1.setCol2( tmpV3_1 ); + result2.setCol2( tmpV3_2 ); + result3.setCol2( tmpV3_3 ); +} + +inline Matrix3 & Matrix3::setCol0( const Vector3 & _col0 ) +{ + mCol0 = _col0; + return *this; +} + +inline Matrix3 & Matrix3::setCol1( const Vector3 & _col1 ) +{ + mCol1 = _col1; + return *this; +} + +inline Matrix3 & Matrix3::setCol2( const Vector3 & _col2 ) +{ + mCol2 = _col2; + return *this; +} + +inline Matrix3 & Matrix3::setCol( int col, const Vector3 & vec ) +{ + *(&mCol0 + col) = vec; + return *this; +} + +inline Matrix3 & Matrix3::setRow( int row, const Vector3 & vec ) +{ + mCol0.setElem( row, vec.getElem( 0 ) ); + mCol1.setElem( row, vec.getElem( 1 ) ); + mCol2.setElem( row, vec.getElem( 2 ) ); + return *this; +} + +inline Matrix3 & Matrix3::setElem( int col, int row, vec_float4 val ) +{ + Vector3 tmpV3_0; + tmpV3_0 = this->getCol( col ); + tmpV3_0.setElem( row, val ); + this->setCol( col, tmpV3_0 ); + return *this; +} + +inline vec_float4 Matrix3::getElem( int col, int row ) const +{ + return this->getCol( col ).getElem( row ); +} + +inline const Vector3 Matrix3::getCol0( ) const +{ + return mCol0; +} + +inline const Vector3 Matrix3::getCol1( ) const +{ + return mCol1; +} + +inline const Vector3 Matrix3::getCol2( ) const +{ + return mCol2; +} + +inline const Vector3 Matrix3::getCol( int col ) const +{ + return *(&mCol0 + col); +} + +inline const Vector3 Matrix3::getRow( int row ) const +{ + return Vector3( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ) ); +} + +inline Vector3 & Matrix3::operator []( int col ) +{ + return *(&mCol0 + col); +} + +inline const Vector3 Matrix3::operator []( int col ) const +{ + return *(&mCol0 + col); +} + +inline Matrix3 & Matrix3::operator =( const Matrix3 & mat ) +{ + mCol0 = mat.mCol0; + mCol1 = mat.mCol1; + mCol2 = mat.mCol2; + return *this; +} + +inline const Matrix3 transpose( const Matrix3 & mat ) +{ + return Matrix3( + Vector3( mat.getCol0().getX(), mat.getCol1().getX(), mat.getCol2().getX() ), + Vector3( mat.getCol0().getY(), mat.getCol1().getY(), mat.getCol2().getY() ), + Vector3( mat.getCol0().getZ(), mat.getCol1().getZ(), mat.getCol2().getZ() ) + ); +} + +inline const Matrix3 inverse( const Matrix3 & mat ) +{ + Vector3 tmp0, tmp1, tmp2; + vec_float4 detinv; + tmp0 = cross( mat.getCol1(), mat.getCol2() ); + tmp1 = cross( mat.getCol2(), mat.getCol0() ); + tmp2 = cross( mat.getCol0(), mat.getCol1() ); + detinv = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), dot( mat.getCol2(), tmp2 ) ); + return Matrix3( + Vector3( vec_madd( tmp0.getX(), detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp1.getX(), detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp2.getX(), detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), + Vector3( vec_madd( tmp0.getY(), detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp1.getY(), detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp2.getY(), detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), + Vector3( vec_madd( tmp0.getZ(), detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp1.getZ(), detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp2.getZ(), detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) + ); +} + +inline vec_float4 determinant( const Matrix3 & mat ) +{ + return dot( mat.getCol2(), cross( mat.getCol0(), mat.getCol1() ) ); +} + +inline const Matrix3 Matrix3::operator +( const Matrix3 & mat ) const +{ + return Matrix3( + ( mCol0 + mat.mCol0 ), + ( mCol1 + mat.mCol1 ), + ( mCol2 + mat.mCol2 ) + ); +} + +inline const Matrix3 Matrix3::operator -( const Matrix3 & mat ) const +{ + return Matrix3( + ( mCol0 - mat.mCol0 ), + ( mCol1 - mat.mCol1 ), + ( mCol2 - mat.mCol2 ) + ); +} + +inline Matrix3 & Matrix3::operator +=( const Matrix3 & mat ) +{ + *this = *this + mat; + return *this; +} + +inline Matrix3 & Matrix3::operator -=( const Matrix3 & mat ) +{ + *this = *this - mat; + return *this; +} + +inline const Matrix3 Matrix3::operator -( ) const +{ + return Matrix3( + ( -mCol0 ), + ( -mCol1 ), + ( -mCol2 ) + ); +} + +inline const Matrix3 absPerElem( const Matrix3 & mat ) +{ + return Matrix3( + absPerElem( mat.getCol0() ), + absPerElem( mat.getCol1() ), + absPerElem( mat.getCol2() ) + ); +} + +inline const Matrix3 Matrix3::operator *( vec_float4 scalar ) const +{ + return Matrix3( + ( mCol0 * scalar ), + ( mCol1 * scalar ), + ( mCol2 * scalar ) + ); +} + +inline Matrix3 & Matrix3::operator *=( vec_float4 scalar ) +{ + *this = *this * scalar; + return *this; +} + +inline const Matrix3 operator *( vec_float4 scalar, const Matrix3 & mat ) +{ + return mat * scalar; +} + +inline const Vector3 Matrix3::operator *( const Vector3 & vec ) const +{ + return Vector3( + vec_add( vec_add( vec_madd( mCol0.getX(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getX(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getX(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), + vec_add( vec_add( vec_madd( mCol0.getY(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getY(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getY(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), + vec_add( vec_add( vec_madd( mCol0.getZ(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getZ(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getZ(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) + ); +} + +inline const Matrix3 Matrix3::operator *( const Matrix3 & mat ) const +{ + return Matrix3( + ( *this * mat.mCol0 ), + ( *this * mat.mCol1 ), + ( *this * mat.mCol2 ) + ); +} + +inline Matrix3 & Matrix3::operator *=( const Matrix3 & mat ) +{ + *this = *this * mat; + return *this; +} + +inline const Matrix3 mulPerElem( const Matrix3 & mat0, const Matrix3 & mat1 ) +{ + return Matrix3( + mulPerElem( mat0.getCol0(), mat1.getCol0() ), + mulPerElem( mat0.getCol1(), mat1.getCol1() ), + mulPerElem( mat0.getCol2(), mat1.getCol2() ) + ); +} + +inline const Matrix3 Matrix3::identity( ) +{ + return Matrix3( + Vector3::xAxis( ), + Vector3::yAxis( ), + Vector3::zAxis( ) + ); +} + +inline const Matrix3 Matrix3::rotationX( vec_float4 radians ) +{ + vec_float4 s, c; + sincosf4( radians, &s, &c ); + return Matrix3( + Vector3::xAxis( ), + Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c, s ), + Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), negatef4( s ), c ) + ); +} + +inline const Matrix3 Matrix3::rotationY( vec_float4 radians ) +{ + vec_float4 s, c; + sincosf4( radians, &s, &c ); + return Matrix3( + Vector3( c, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), negatef4( s ) ), + Vector3::yAxis( ), + Vector3( s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c ) + ); +} + +inline const Matrix3 Matrix3::rotationZ( vec_float4 radians ) +{ + vec_float4 s, c; + sincosf4( radians, &s, &c ); + return Matrix3( + Vector3( c, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + Vector3( negatef4( s ), c, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + Vector3::zAxis( ) + ); +} + +inline const Matrix3 Matrix3::rotationZYX( const Vector3 & radiansXYZ ) +{ + vec_float4 sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; + sincosf4( radiansXYZ.getX(), &sX, &cX ); + sincosf4( radiansXYZ.getY(), &sY, &cY ); + sincosf4( radiansXYZ.getZ(), &sZ, &cZ ); + tmp0 = vec_madd( cZ, sY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + tmp1 = vec_madd( sZ, sY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + return Matrix3( + Vector3( vec_madd( cZ, cY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sZ, cY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), negatef4( sY ) ), + Vector3( vec_sub( vec_madd( tmp0, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sZ, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_add( vec_madd( tmp1, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( cZ, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( cY, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), + Vector3( vec_add( vec_madd( tmp0, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sZ, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_sub( vec_madd( tmp1, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( cZ, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( cY, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) + ); +} + +inline const Matrix3 Matrix3::rotation( vec_float4 radians, const Vector3 & unitVec ) +{ + vec_float4 x, y, z, s, c, oneMinusC, xy, yz, zx; + sincosf4( radians, &s, &c ); + x = unitVec.getX(); + y = unitVec.getY(); + z = unitVec.getZ(); + xy = vec_madd( x, y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + yz = vec_madd( y, z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + zx = vec_madd( z, x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + oneMinusC = vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), c ); + return Matrix3( + Vector3( vec_add( vec_madd( vec_madd( x, x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), c ), vec_add( vec_madd( xy, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( z, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_sub( vec_madd( zx, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( y, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ), + Vector3( vec_sub( vec_madd( xy, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( z, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_add( vec_madd( vec_madd( y, y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), c ), vec_add( vec_madd( yz, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( x, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ), + Vector3( vec_add( vec_madd( zx, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( y, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_sub( vec_madd( yz, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( x, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_add( vec_madd( vec_madd( z, z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), c ) ) + ); +} + +inline const Matrix3 Matrix3::rotation( const Quat & unitQuat ) +{ + return Matrix3( unitQuat ); +} + +inline const Matrix3 Matrix3::scale( const Vector3 & scaleVec ) +{ + return Matrix3( + Vector3( scaleVec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), scaleVec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), scaleVec.getZ() ) + ); +} + +inline const Matrix3 appendScale( const Matrix3 & mat, const Vector3 & scaleVec ) +{ + return Matrix3( + ( mat.getCol0() * scaleVec.getX( ) ), + ( mat.getCol1() * scaleVec.getY( ) ), + ( mat.getCol2() * scaleVec.getZ( ) ) + ); +} + +inline const Matrix3 prependScale( const Vector3 & scaleVec, const Matrix3 & mat ) +{ + return Matrix3( + mulPerElem( mat.getCol0(), scaleVec ), + mulPerElem( mat.getCol1(), scaleVec ), + mulPerElem( mat.getCol2(), scaleVec ) + ); +} + +inline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, vec_uint4 select1 ) +{ + return Matrix3( + select( mat0.getCol0(), mat1.getCol0(), select1 ), + select( mat0.getCol1(), mat1.getCol1(), select1 ), + select( mat0.getCol2(), mat1.getCol2(), select1 ) + ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( const Matrix3 & mat ) +{ + Aos::Matrix3 mat0, mat1, mat2, mat3; + mat.get4Aos( mat0, mat1, mat2, mat3 ); + printf("slot 0:\n"); + print( mat0 ); + printf("slot 1:\n"); + print( mat1 ); + printf("slot 2:\n"); + print( mat2 ); + printf("slot 3:\n"); + print( mat3 ); +} + +inline void print( const Matrix3 & mat, const char * name ) +{ + printf("%s:\n", name); + print( mat ); +} + +#endif + +inline Matrix4::Matrix4( const Matrix4 & mat ) +{ + mCol0 = mat.mCol0; + mCol1 = mat.mCol1; + mCol2 = mat.mCol2; + mCol3 = mat.mCol3; +} + +inline Matrix4::Matrix4( vec_float4 scalar ) +{ + mCol0 = Vector4( scalar ); + mCol1 = Vector4( scalar ); + mCol2 = Vector4( scalar ); + mCol3 = Vector4( scalar ); +} + +inline Matrix4::Matrix4( const Transform3 & mat ) +{ + mCol0 = Vector4( mat.getCol0(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + mCol1 = Vector4( mat.getCol1(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + mCol2 = Vector4( mat.getCol2(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + mCol3 = Vector4( mat.getCol3(), ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); +} + +inline Matrix4::Matrix4( const Vector4 & _col0, const Vector4 & _col1, const Vector4 & _col2, const Vector4 & _col3 ) +{ + mCol0 = _col0; + mCol1 = _col1; + mCol2 = _col2; + mCol3 = _col3; +} + +inline Matrix4::Matrix4( const Matrix3 & mat, const Vector3 & translateVec ) +{ + mCol0 = Vector4( mat.getCol0(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + mCol1 = Vector4( mat.getCol1(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + mCol2 = Vector4( mat.getCol2(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + mCol3 = Vector4( translateVec, ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); +} + +inline Matrix4::Matrix4( const Quat & unitQuat, const Vector3 & translateVec ) +{ + Matrix3 mat; + mat = Matrix3( unitQuat ); + mCol0 = Vector4( mat.getCol0(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + mCol1 = Vector4( mat.getCol1(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + mCol2 = Vector4( mat.getCol2(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + mCol3 = Vector4( translateVec, ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); +} + +inline Matrix4::Matrix4( const Aos::Matrix4 & mat ) +{ + mCol0 = Vector4( mat.getCol0() ); + mCol1 = Vector4( mat.getCol1() ); + mCol2 = Vector4( mat.getCol2() ); + mCol3 = Vector4( mat.getCol3() ); +} + +inline Matrix4::Matrix4( const Aos::Matrix4 & mat0, const Aos::Matrix4 & mat1, const Aos::Matrix4 & mat2, const Aos::Matrix4 & mat3 ) +{ + mCol0 = Vector4( mat0.getCol0(), mat1.getCol0(), mat2.getCol0(), mat3.getCol0() ); + mCol1 = Vector4( mat0.getCol1(), mat1.getCol1(), mat2.getCol1(), mat3.getCol1() ); + mCol2 = Vector4( mat0.getCol2(), mat1.getCol2(), mat2.getCol2(), mat3.getCol2() ); + mCol3 = Vector4( mat0.getCol3(), mat1.getCol3(), mat2.getCol3(), mat3.getCol3() ); +} + +inline void Matrix4::get4Aos( Aos::Matrix4 & result0, Aos::Matrix4 & result1, Aos::Matrix4 & result2, Aos::Matrix4 & result3 ) const +{ + Aos::Vector4 tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3; + mCol0.get4Aos( tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3 ); + result0.setCol0( tmpV4_0 ); + result1.setCol0( tmpV4_1 ); + result2.setCol0( tmpV4_2 ); + result3.setCol0( tmpV4_3 ); + mCol1.get4Aos( tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3 ); + result0.setCol1( tmpV4_0 ); + result1.setCol1( tmpV4_1 ); + result2.setCol1( tmpV4_2 ); + result3.setCol1( tmpV4_3 ); + mCol2.get4Aos( tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3 ); + result0.setCol2( tmpV4_0 ); + result1.setCol2( tmpV4_1 ); + result2.setCol2( tmpV4_2 ); + result3.setCol2( tmpV4_3 ); + mCol3.get4Aos( tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3 ); + result0.setCol3( tmpV4_0 ); + result1.setCol3( tmpV4_1 ); + result2.setCol3( tmpV4_2 ); + result3.setCol3( tmpV4_3 ); +} + +inline Matrix4 & Matrix4::setCol0( const Vector4 & _col0 ) +{ + mCol0 = _col0; + return *this; +} + +inline Matrix4 & Matrix4::setCol1( const Vector4 & _col1 ) +{ + mCol1 = _col1; + return *this; +} + +inline Matrix4 & Matrix4::setCol2( const Vector4 & _col2 ) +{ + mCol2 = _col2; + return *this; +} + +inline Matrix4 & Matrix4::setCol3( const Vector4 & _col3 ) +{ + mCol3 = _col3; + return *this; +} + +inline Matrix4 & Matrix4::setCol( int col, const Vector4 & vec ) +{ + *(&mCol0 + col) = vec; + return *this; +} + +inline Matrix4 & Matrix4::setRow( int row, const Vector4 & vec ) +{ + mCol0.setElem( row, vec.getElem( 0 ) ); + mCol1.setElem( row, vec.getElem( 1 ) ); + mCol2.setElem( row, vec.getElem( 2 ) ); + mCol3.setElem( row, vec.getElem( 3 ) ); + return *this; +} + +inline Matrix4 & Matrix4::setElem( int col, int row, vec_float4 val ) +{ + Vector4 tmpV3_0; + tmpV3_0 = this->getCol( col ); + tmpV3_0.setElem( row, val ); + this->setCol( col, tmpV3_0 ); + return *this; +} + +inline vec_float4 Matrix4::getElem( int col, int row ) const +{ + return this->getCol( col ).getElem( row ); +} + +inline const Vector4 Matrix4::getCol0( ) const +{ + return mCol0; +} + +inline const Vector4 Matrix4::getCol1( ) const +{ + return mCol1; +} + +inline const Vector4 Matrix4::getCol2( ) const +{ + return mCol2; +} + +inline const Vector4 Matrix4::getCol3( ) const +{ + return mCol3; +} + +inline const Vector4 Matrix4::getCol( int col ) const +{ + return *(&mCol0 + col); +} + +inline const Vector4 Matrix4::getRow( int row ) const +{ + return Vector4( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ), mCol3.getElem( row ) ); +} + +inline Vector4 & Matrix4::operator []( int col ) +{ + return *(&mCol0 + col); +} + +inline const Vector4 Matrix4::operator []( int col ) const +{ + return *(&mCol0 + col); +} + +inline Matrix4 & Matrix4::operator =( const Matrix4 & mat ) +{ + mCol0 = mat.mCol0; + mCol1 = mat.mCol1; + mCol2 = mat.mCol2; + mCol3 = mat.mCol3; + return *this; +} + +inline const Matrix4 transpose( const Matrix4 & mat ) +{ + return Matrix4( + Vector4( mat.getCol0().getX(), mat.getCol1().getX(), mat.getCol2().getX(), mat.getCol3().getX() ), + Vector4( mat.getCol0().getY(), mat.getCol1().getY(), mat.getCol2().getY(), mat.getCol3().getY() ), + Vector4( mat.getCol0().getZ(), mat.getCol1().getZ(), mat.getCol2().getZ(), mat.getCol3().getZ() ), + Vector4( mat.getCol0().getW(), mat.getCol1().getW(), mat.getCol2().getW(), mat.getCol3().getW() ) + ); +} + +inline const Matrix4 inverse( const Matrix4 & mat ) +{ + Vector4 res0, res1, res2, res3; + vec_float4 mA, mB, mC, mD, mE, mF, mG, mH, mI, mJ, mK, mL, mM, mN, mO, mP, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, detInv; + mA = mat.getCol0().getX(); + mB = mat.getCol0().getY(); + mC = mat.getCol0().getZ(); + mD = mat.getCol0().getW(); + mE = mat.getCol1().getX(); + mF = mat.getCol1().getY(); + mG = mat.getCol1().getZ(); + mH = mat.getCol1().getW(); + mI = mat.getCol2().getX(); + mJ = mat.getCol2().getY(); + mK = mat.getCol2().getZ(); + mL = mat.getCol2().getW(); + mM = mat.getCol3().getX(); + mN = mat.getCol3().getY(); + mO = mat.getCol3().getZ(); + mP = mat.getCol3().getW(); + tmp0 = vec_sub( vec_madd( mK, mD, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mC, mL, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmp1 = vec_sub( vec_madd( mO, mH, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mG, mP, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmp2 = vec_sub( vec_madd( mB, mK, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mJ, mC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmp3 = vec_sub( vec_madd( mF, mO, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mN, mG, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmp4 = vec_sub( vec_madd( mJ, mD, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mB, mL, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmp5 = vec_sub( vec_madd( mN, mH, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mF, mP, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + res0.setX( vec_sub( vec_sub( vec_madd( mJ, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mL, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mK, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ); + res0.setY( vec_sub( vec_sub( vec_madd( mN, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mP, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mO, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ); + res0.setZ( vec_sub( vec_add( vec_madd( mD, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mC, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mB, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ); + res0.setW( vec_sub( vec_add( vec_madd( mH, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mG, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mF, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ); + detInv = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec_add( vec_add( vec_add( vec_madd( mA, res0.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mE, res0.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mI, res0.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mM, res0.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ); + res1.setX( vec_madd( mI, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + res1.setY( vec_madd( mM, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + res1.setZ( vec_madd( mA, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + res1.setW( vec_madd( mE, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + res3.setX( vec_madd( mI, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + res3.setY( vec_madd( mM, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + res3.setZ( vec_madd( mA, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + res3.setW( vec_madd( mE, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + res2.setX( vec_madd( mI, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + res2.setY( vec_madd( mM, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + res2.setZ( vec_madd( mA, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + res2.setW( vec_madd( mE, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmp0 = vec_sub( vec_madd( mI, mB, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mA, mJ, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmp1 = vec_sub( vec_madd( mM, mF, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mE, mN, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmp2 = vec_sub( vec_madd( mI, mD, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mA, mL, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmp3 = vec_sub( vec_madd( mM, mH, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mE, mP, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmp4 = vec_sub( vec_madd( mI, mC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mA, mK, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmp5 = vec_sub( vec_madd( mM, mG, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mE, mO, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + res2.setX( vec_add( vec_sub( vec_madd( mL, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mJ, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res2.getX() ) ); + res2.setY( vec_add( vec_sub( vec_madd( mP, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mN, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res2.getY() ) ); + res2.setZ( vec_sub( vec_sub( vec_madd( mB, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mD, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res2.getZ() ) ); + res2.setW( vec_sub( vec_sub( vec_madd( mF, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mH, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res2.getW() ) ); + res3.setX( vec_add( vec_sub( vec_madd( mJ, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mK, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res3.getX() ) ); + res3.setY( vec_add( vec_sub( vec_madd( mN, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mO, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res3.getY() ) ); + res3.setZ( vec_sub( vec_sub( vec_madd( mC, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mB, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res3.getZ() ) ); + res3.setW( vec_sub( vec_sub( vec_madd( mG, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mF, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res3.getW() ) ); + res1.setX( vec_sub( vec_sub( vec_madd( mK, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mL, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res1.getX() ) ); + res1.setY( vec_sub( vec_sub( vec_madd( mO, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mP, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res1.getY() ) ); + res1.setZ( vec_add( vec_sub( vec_madd( mD, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mC, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res1.getZ() ) ); + res1.setW( vec_add( vec_sub( vec_madd( mH, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mG, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res1.getW() ) ); + return Matrix4( + ( res0 * detInv ), + ( res1 * detInv ), + ( res2 * detInv ), + ( res3 * detInv ) + ); +} + +inline const Matrix4 affineInverse( const Matrix4 & mat ) +{ + Transform3 affineMat; + affineMat.setCol0( mat.getCol0().getXYZ( ) ); + affineMat.setCol1( mat.getCol1().getXYZ( ) ); + affineMat.setCol2( mat.getCol2().getXYZ( ) ); + affineMat.setCol3( mat.getCol3().getXYZ( ) ); + return Matrix4( inverse( affineMat ) ); +} + +inline const Matrix4 orthoInverse( const Matrix4 & mat ) +{ + Transform3 affineMat; + affineMat.setCol0( mat.getCol0().getXYZ( ) ); + affineMat.setCol1( mat.getCol1().getXYZ( ) ); + affineMat.setCol2( mat.getCol2().getXYZ( ) ); + affineMat.setCol3( mat.getCol3().getXYZ( ) ); + return Matrix4( orthoInverse( affineMat ) ); +} + +inline vec_float4 determinant( const Matrix4 & mat ) +{ + vec_float4 dx, dy, dz, dw, mA, mB, mC, mD, mE, mF, mG, mH, mI, mJ, mK, mL, mM, mN, mO, mP, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; + mA = mat.getCol0().getX(); + mB = mat.getCol0().getY(); + mC = mat.getCol0().getZ(); + mD = mat.getCol0().getW(); + mE = mat.getCol1().getX(); + mF = mat.getCol1().getY(); + mG = mat.getCol1().getZ(); + mH = mat.getCol1().getW(); + mI = mat.getCol2().getX(); + mJ = mat.getCol2().getY(); + mK = mat.getCol2().getZ(); + mL = mat.getCol2().getW(); + mM = mat.getCol3().getX(); + mN = mat.getCol3().getY(); + mO = mat.getCol3().getZ(); + mP = mat.getCol3().getW(); + tmp0 = vec_sub( vec_madd( mK, mD, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mC, mL, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmp1 = vec_sub( vec_madd( mO, mH, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mG, mP, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmp2 = vec_sub( vec_madd( mB, mK, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mJ, mC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmp3 = vec_sub( vec_madd( mF, mO, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mN, mG, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmp4 = vec_sub( vec_madd( mJ, mD, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mB, mL, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmp5 = vec_sub( vec_madd( mN, mH, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mF, mP, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + dx = vec_sub( vec_sub( vec_madd( mJ, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mL, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mK, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + dy = vec_sub( vec_sub( vec_madd( mN, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mP, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mO, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + dz = vec_sub( vec_add( vec_madd( mD, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mC, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mB, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + dw = vec_sub( vec_add( vec_madd( mH, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mG, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mF, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + return vec_add( vec_add( vec_add( vec_madd( mA, dx, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mE, dy, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mI, dz, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mM, dw, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); +} + +inline const Matrix4 Matrix4::operator +( const Matrix4 & mat ) const +{ + return Matrix4( + ( mCol0 + mat.mCol0 ), + ( mCol1 + mat.mCol1 ), + ( mCol2 + mat.mCol2 ), + ( mCol3 + mat.mCol3 ) + ); +} + +inline const Matrix4 Matrix4::operator -( const Matrix4 & mat ) const +{ + return Matrix4( + ( mCol0 - mat.mCol0 ), + ( mCol1 - mat.mCol1 ), + ( mCol2 - mat.mCol2 ), + ( mCol3 - mat.mCol3 ) + ); +} + +inline Matrix4 & Matrix4::operator +=( const Matrix4 & mat ) +{ + *this = *this + mat; + return *this; +} + +inline Matrix4 & Matrix4::operator -=( const Matrix4 & mat ) +{ + *this = *this - mat; + return *this; +} + +inline const Matrix4 Matrix4::operator -( ) const +{ + return Matrix4( + ( -mCol0 ), + ( -mCol1 ), + ( -mCol2 ), + ( -mCol3 ) + ); +} + +inline const Matrix4 absPerElem( const Matrix4 & mat ) +{ + return Matrix4( + absPerElem( mat.getCol0() ), + absPerElem( mat.getCol1() ), + absPerElem( mat.getCol2() ), + absPerElem( mat.getCol3() ) + ); +} + +inline const Matrix4 Matrix4::operator *( vec_float4 scalar ) const +{ + return Matrix4( + ( mCol0 * scalar ), + ( mCol1 * scalar ), + ( mCol2 * scalar ), + ( mCol3 * scalar ) + ); +} + +inline Matrix4 & Matrix4::operator *=( vec_float4 scalar ) +{ + *this = *this * scalar; + return *this; +} + +inline const Matrix4 operator *( vec_float4 scalar, const Matrix4 & mat ) +{ + return mat * scalar; +} + +inline const Vector4 Matrix4::operator *( const Vector4 & vec ) const +{ + return Vector4( + vec_add( vec_add( vec_add( vec_madd( mCol0.getX(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getX(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getX(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol3.getX(), vec.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), + vec_add( vec_add( vec_add( vec_madd( mCol0.getY(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getY(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getY(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol3.getY(), vec.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), + vec_add( vec_add( vec_add( vec_madd( mCol0.getZ(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getZ(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getZ(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol3.getZ(), vec.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), + vec_add( vec_add( vec_add( vec_madd( mCol0.getW(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getW(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getW(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol3.getW(), vec.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) + ); +} + +inline const Vector4 Matrix4::operator *( const Vector3 & vec ) const +{ + return Vector4( + vec_add( vec_add( vec_madd( mCol0.getX(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getX(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getX(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), + vec_add( vec_add( vec_madd( mCol0.getY(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getY(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getY(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), + vec_add( vec_add( vec_madd( mCol0.getZ(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getZ(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getZ(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), + vec_add( vec_add( vec_madd( mCol0.getW(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getW(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getW(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) + ); +} + +inline const Vector4 Matrix4::operator *( const Point3 & pnt ) const +{ + return Vector4( + vec_add( vec_add( vec_add( vec_madd( mCol0.getX(), pnt.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getX(), pnt.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getX(), pnt.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), mCol3.getX() ), + vec_add( vec_add( vec_add( vec_madd( mCol0.getY(), pnt.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getY(), pnt.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getY(), pnt.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), mCol3.getY() ), + vec_add( vec_add( vec_add( vec_madd( mCol0.getZ(), pnt.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getZ(), pnt.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getZ(), pnt.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), mCol3.getZ() ), + vec_add( vec_add( vec_add( vec_madd( mCol0.getW(), pnt.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getW(), pnt.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getW(), pnt.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), mCol3.getW() ) + ); +} + +inline const Matrix4 Matrix4::operator *( const Matrix4 & mat ) const +{ + return Matrix4( + ( *this * mat.mCol0 ), + ( *this * mat.mCol1 ), + ( *this * mat.mCol2 ), + ( *this * mat.mCol3 ) + ); +} + +inline Matrix4 & Matrix4::operator *=( const Matrix4 & mat ) +{ + *this = *this * mat; + return *this; +} + +inline const Matrix4 Matrix4::operator *( const Transform3 & tfrm ) const +{ + return Matrix4( + ( *this * tfrm.getCol0() ), + ( *this * tfrm.getCol1() ), + ( *this * tfrm.getCol2() ), + ( *this * Point3( tfrm.getCol3() ) ) + ); +} + +inline Matrix4 & Matrix4::operator *=( const Transform3 & tfrm ) +{ + *this = *this * tfrm; + return *this; +} + +inline const Matrix4 mulPerElem( const Matrix4 & mat0, const Matrix4 & mat1 ) +{ + return Matrix4( + mulPerElem( mat0.getCol0(), mat1.getCol0() ), + mulPerElem( mat0.getCol1(), mat1.getCol1() ), + mulPerElem( mat0.getCol2(), mat1.getCol2() ), + mulPerElem( mat0.getCol3(), mat1.getCol3() ) + ); +} + +inline const Matrix4 Matrix4::identity( ) +{ + return Matrix4( + Vector4::xAxis( ), + Vector4::yAxis( ), + Vector4::zAxis( ), + Vector4::wAxis( ) + ); +} + +inline Matrix4 & Matrix4::setUpper3x3( const Matrix3 & mat3 ) +{ + mCol0.setXYZ( mat3.getCol0() ); + mCol1.setXYZ( mat3.getCol1() ); + mCol2.setXYZ( mat3.getCol2() ); + return *this; +} + +inline const Matrix3 Matrix4::getUpper3x3( ) const +{ + return Matrix3( + mCol0.getXYZ( ), + mCol1.getXYZ( ), + mCol2.getXYZ( ) + ); +} + +inline Matrix4 & Matrix4::setTranslation( const Vector3 & translateVec ) +{ + mCol3.setXYZ( translateVec ); + return *this; +} + +inline const Vector3 Matrix4::getTranslation( ) const +{ + return mCol3.getXYZ( ); +} + +inline const Matrix4 Matrix4::rotationX( vec_float4 radians ) +{ + vec_float4 s, c; + sincosf4( radians, &s, &c ); + return Matrix4( + Vector4::xAxis( ), + Vector4( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + Vector4( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), negatef4( s ), c, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + Vector4::wAxis( ) + ); +} + +inline const Matrix4 Matrix4::rotationY( vec_float4 radians ) +{ + vec_float4 s, c; + sincosf4( radians, &s, &c ); + return Matrix4( + Vector4( c, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), negatef4( s ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + Vector4::yAxis( ), + Vector4( s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + Vector4::wAxis( ) + ); +} + +inline const Matrix4 Matrix4::rotationZ( vec_float4 radians ) +{ + vec_float4 s, c; + sincosf4( radians, &s, &c ); + return Matrix4( + Vector4( c, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + Vector4( negatef4( s ), c, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + Vector4::zAxis( ), + Vector4::wAxis( ) + ); +} + +inline const Matrix4 Matrix4::rotationZYX( const Vector3 & radiansXYZ ) +{ + vec_float4 sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; + sincosf4( radiansXYZ.getX(), &sX, &cX ); + sincosf4( radiansXYZ.getY(), &sY, &cY ); + sincosf4( radiansXYZ.getZ(), &sZ, &cZ ); + tmp0 = vec_madd( cZ, sY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + tmp1 = vec_madd( sZ, sY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + return Matrix4( + Vector4( vec_madd( cZ, cY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sZ, cY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), negatef4( sY ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + Vector4( vec_sub( vec_madd( tmp0, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sZ, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_add( vec_madd( tmp1, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( cZ, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( cY, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + Vector4( vec_add( vec_madd( tmp0, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sZ, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_sub( vec_madd( tmp1, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( cZ, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( cY, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + Vector4::wAxis( ) + ); +} + +inline const Matrix4 Matrix4::rotation( vec_float4 radians, const Vector3 & unitVec ) +{ + vec_float4 x, y, z, s, c, oneMinusC, xy, yz, zx; + sincosf4( radians, &s, &c ); + x = unitVec.getX(); + y = unitVec.getY(); + z = unitVec.getZ(); + xy = vec_madd( x, y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + yz = vec_madd( y, z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + zx = vec_madd( z, x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + oneMinusC = vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), c ); + return Matrix4( + Vector4( vec_add( vec_madd( vec_madd( x, x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), c ), vec_add( vec_madd( xy, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( z, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_sub( vec_madd( zx, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( y, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + Vector4( vec_sub( vec_madd( xy, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( z, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_add( vec_madd( vec_madd( y, y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), c ), vec_add( vec_madd( yz, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( x, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + Vector4( vec_add( vec_madd( zx, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( y, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_sub( vec_madd( yz, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( x, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_add( vec_madd( vec_madd( z, z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), c ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + Vector4::wAxis( ) + ); +} + +inline const Matrix4 Matrix4::rotation( const Quat & unitQuat ) +{ + return Matrix4( Transform3::rotation( unitQuat ) ); +} + +inline const Matrix4 Matrix4::scale( const Vector3 & scaleVec ) +{ + return Matrix4( + Vector4( scaleVec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + Vector4( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), scaleVec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + Vector4( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), scaleVec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + Vector4::wAxis( ) + ); +} + +inline const Matrix4 appendScale( const Matrix4 & mat, const Vector3 & scaleVec ) +{ + return Matrix4( + ( mat.getCol0() * scaleVec.getX( ) ), + ( mat.getCol1() * scaleVec.getY( ) ), + ( mat.getCol2() * scaleVec.getZ( ) ), + mat.getCol3() + ); +} + +inline const Matrix4 prependScale( const Vector3 & scaleVec, const Matrix4 & mat ) +{ + Vector4 scale4; + scale4 = Vector4( scaleVec, ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); + return Matrix4( + mulPerElem( mat.getCol0(), scale4 ), + mulPerElem( mat.getCol1(), scale4 ), + mulPerElem( mat.getCol2(), scale4 ), + mulPerElem( mat.getCol3(), scale4 ) + ); +} + +inline const Matrix4 Matrix4::translation( const Vector3 & translateVec ) +{ + return Matrix4( + Vector4::xAxis( ), + Vector4::yAxis( ), + Vector4::zAxis( ), + Vector4( translateVec, ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ) + ); +} + +inline const Matrix4 Matrix4::lookAt( const Point3 & eyePos, const Point3 & lookAtPos, const Vector3 & upVec ) +{ + Matrix4 m4EyeFrame; + Vector3 v3X, v3Y, v3Z; + v3Y = normalize( upVec ); + v3Z = normalize( ( eyePos - lookAtPos ) ); + v3X = normalize( cross( v3Y, v3Z ) ); + v3Y = cross( v3Z, v3X ); + m4EyeFrame = Matrix4( Vector4( v3X ), Vector4( v3Y ), Vector4( v3Z ), Vector4( eyePos ) ); + return orthoInverse( m4EyeFrame ); +} + +inline const Matrix4 Matrix4::perspective( vec_float4 fovyRadians, vec_float4 aspect, vec_float4 zNear, vec_float4 zFar ) +{ + vec_float4 f, rangeInv; + f = tanf4( vec_sub( ((vec_float4){_VECTORMATH_PI_OVER_2,_VECTORMATH_PI_OVER_2,_VECTORMATH_PI_OVER_2,_VECTORMATH_PI_OVER_2}), vec_madd( ((vec_float4){0.5f,0.5f,0.5f,0.5f}), fovyRadians, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ); + rangeInv = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec_sub( zNear, zFar ) ); + return Matrix4( + Vector4( divf4( f, aspect ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + Vector4( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), f, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + Vector4( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), vec_madd( vec_add( zNear, zFar ), rangeInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){-1.0f,-1.0f,-1.0f,-1.0f}) ), + Vector4( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), vec_madd( vec_madd( vec_madd( zNear, zFar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), rangeInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){2.0f,2.0f,2.0f,2.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) + ); +} + +inline const Matrix4 Matrix4::frustum( vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ) +{ + vec_float4 sum_rl, sum_tb, sum_nf, inv_rl, inv_tb, inv_nf, n2; + sum_rl = vec_add( right, left ); + sum_tb = vec_add( top, bottom ); + sum_nf = vec_add( zNear, zFar ); + inv_rl = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec_sub( right, left ) ); + inv_tb = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec_sub( top, bottom ) ); + inv_nf = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec_sub( zNear, zFar ) ); + n2 = vec_add( zNear, zNear ); + return Matrix4( + Vector4( vec_madd( n2, inv_rl, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + Vector4( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), vec_madd( n2, inv_tb, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + Vector4( vec_madd( sum_rl, inv_rl, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sum_tb, inv_tb, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sum_nf, inv_nf, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){-1.0f,-1.0f,-1.0f,-1.0f}) ), + Vector4( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), vec_madd( vec_madd( n2, inv_nf, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), zFar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) + ); +} + +inline const Matrix4 Matrix4::orthographic( vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ) +{ + vec_float4 sum_rl, sum_tb, sum_nf, inv_rl, inv_tb, inv_nf; + sum_rl = vec_add( right, left ); + sum_tb = vec_add( top, bottom ); + sum_nf = vec_add( zNear, zFar ); + inv_rl = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec_sub( right, left ) ); + inv_tb = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec_sub( top, bottom ) ); + inv_nf = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec_sub( zNear, zFar ) ); + return Matrix4( + Vector4( vec_add( inv_rl, inv_rl ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + Vector4( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), vec_add( inv_tb, inv_tb ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + Vector4( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), vec_add( inv_nf, inv_nf ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + Vector4( vec_madd( negatef4( sum_rl ), inv_rl, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( negatef4( sum_tb ), inv_tb, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sum_nf, inv_nf, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ) + ); +} + +inline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, vec_uint4 select1 ) +{ + return Matrix4( + select( mat0.getCol0(), mat1.getCol0(), select1 ), + select( mat0.getCol1(), mat1.getCol1(), select1 ), + select( mat0.getCol2(), mat1.getCol2(), select1 ), + select( mat0.getCol3(), mat1.getCol3(), select1 ) + ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( const Matrix4 & mat ) +{ + Aos::Matrix4 mat0, mat1, mat2, mat3; + mat.get4Aos( mat0, mat1, mat2, mat3 ); + printf("slot 0:\n"); + print( mat0 ); + printf("slot 1:\n"); + print( mat1 ); + printf("slot 2:\n"); + print( mat2 ); + printf("slot 3:\n"); + print( mat3 ); +} + +inline void print( const Matrix4 & mat, const char * name ) +{ + printf("%s:\n", name); + print( mat ); +} + +#endif + +inline Transform3::Transform3( const Transform3 & tfrm ) +{ + mCol0 = tfrm.mCol0; + mCol1 = tfrm.mCol1; + mCol2 = tfrm.mCol2; + mCol3 = tfrm.mCol3; +} + +inline Transform3::Transform3( vec_float4 scalar ) +{ + mCol0 = Vector3( scalar ); + mCol1 = Vector3( scalar ); + mCol2 = Vector3( scalar ); + mCol3 = Vector3( scalar ); +} + +inline Transform3::Transform3( const Vector3 & _col0, const Vector3 & _col1, const Vector3 & _col2, const Vector3 & _col3 ) +{ + mCol0 = _col0; + mCol1 = _col1; + mCol2 = _col2; + mCol3 = _col3; +} + +inline Transform3::Transform3( const Matrix3 & tfrm, const Vector3 & translateVec ) +{ + this->setUpper3x3( tfrm ); + this->setTranslation( translateVec ); +} + +inline Transform3::Transform3( const Quat & unitQuat, const Vector3 & translateVec ) +{ + this->setUpper3x3( Matrix3( unitQuat ) ); + this->setTranslation( translateVec ); +} + +inline Transform3::Transform3( const Aos::Transform3 & tfrm ) +{ + mCol0 = Vector3( tfrm.getCol0() ); + mCol1 = Vector3( tfrm.getCol1() ); + mCol2 = Vector3( tfrm.getCol2() ); + mCol3 = Vector3( tfrm.getCol3() ); +} + +inline Transform3::Transform3( const Aos::Transform3 & tfrm0, const Aos::Transform3 & tfrm1, const Aos::Transform3 & tfrm2, const Aos::Transform3 & tfrm3 ) +{ + mCol0 = Vector3( tfrm0.getCol0(), tfrm1.getCol0(), tfrm2.getCol0(), tfrm3.getCol0() ); + mCol1 = Vector3( tfrm0.getCol1(), tfrm1.getCol1(), tfrm2.getCol1(), tfrm3.getCol1() ); + mCol2 = Vector3( tfrm0.getCol2(), tfrm1.getCol2(), tfrm2.getCol2(), tfrm3.getCol2() ); + mCol3 = Vector3( tfrm0.getCol3(), tfrm1.getCol3(), tfrm2.getCol3(), tfrm3.getCol3() ); +} + +inline void Transform3::get4Aos( Aos::Transform3 & result0, Aos::Transform3 & result1, Aos::Transform3 & result2, Aos::Transform3 & result3 ) const +{ + Aos::Vector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3; + mCol0.get4Aos( tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3 ); + result0.setCol0( tmpV3_0 ); + result1.setCol0( tmpV3_1 ); + result2.setCol0( tmpV3_2 ); + result3.setCol0( tmpV3_3 ); + mCol1.get4Aos( tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3 ); + result0.setCol1( tmpV3_0 ); + result1.setCol1( tmpV3_1 ); + result2.setCol1( tmpV3_2 ); + result3.setCol1( tmpV3_3 ); + mCol2.get4Aos( tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3 ); + result0.setCol2( tmpV3_0 ); + result1.setCol2( tmpV3_1 ); + result2.setCol2( tmpV3_2 ); + result3.setCol2( tmpV3_3 ); + mCol3.get4Aos( tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3 ); + result0.setCol3( tmpV3_0 ); + result1.setCol3( tmpV3_1 ); + result2.setCol3( tmpV3_2 ); + result3.setCol3( tmpV3_3 ); +} + +inline Transform3 & Transform3::setCol0( const Vector3 & _col0 ) +{ + mCol0 = _col0; + return *this; +} + +inline Transform3 & Transform3::setCol1( const Vector3 & _col1 ) +{ + mCol1 = _col1; + return *this; +} + +inline Transform3 & Transform3::setCol2( const Vector3 & _col2 ) +{ + mCol2 = _col2; + return *this; +} + +inline Transform3 & Transform3::setCol3( const Vector3 & _col3 ) +{ + mCol3 = _col3; + return *this; +} + +inline Transform3 & Transform3::setCol( int col, const Vector3 & vec ) +{ + *(&mCol0 + col) = vec; + return *this; +} + +inline Transform3 & Transform3::setRow( int row, const Vector4 & vec ) +{ + mCol0.setElem( row, vec.getElem( 0 ) ); + mCol1.setElem( row, vec.getElem( 1 ) ); + mCol2.setElem( row, vec.getElem( 2 ) ); + mCol3.setElem( row, vec.getElem( 3 ) ); + return *this; +} + +inline Transform3 & Transform3::setElem( int col, int row, vec_float4 val ) +{ + Vector3 tmpV3_0; + tmpV3_0 = this->getCol( col ); + tmpV3_0.setElem( row, val ); + this->setCol( col, tmpV3_0 ); + return *this; +} + +inline vec_float4 Transform3::getElem( int col, int row ) const +{ + return this->getCol( col ).getElem( row ); +} + +inline const Vector3 Transform3::getCol0( ) const +{ + return mCol0; +} + +inline const Vector3 Transform3::getCol1( ) const +{ + return mCol1; +} + +inline const Vector3 Transform3::getCol2( ) const +{ + return mCol2; +} + +inline const Vector3 Transform3::getCol3( ) const +{ + return mCol3; +} + +inline const Vector3 Transform3::getCol( int col ) const +{ + return *(&mCol0 + col); +} + +inline const Vector4 Transform3::getRow( int row ) const +{ + return Vector4( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ), mCol3.getElem( row ) ); +} + +inline Vector3 & Transform3::operator []( int col ) +{ + return *(&mCol0 + col); +} + +inline const Vector3 Transform3::operator []( int col ) const +{ + return *(&mCol0 + col); +} + +inline Transform3 & Transform3::operator =( const Transform3 & tfrm ) +{ + mCol0 = tfrm.mCol0; + mCol1 = tfrm.mCol1; + mCol2 = tfrm.mCol2; + mCol3 = tfrm.mCol3; + return *this; +} + +inline const Transform3 inverse( const Transform3 & tfrm ) +{ + Vector3 tmp0, tmp1, tmp2, inv0, inv1, inv2; + vec_float4 detinv; + tmp0 = cross( tfrm.getCol1(), tfrm.getCol2() ); + tmp1 = cross( tfrm.getCol2(), tfrm.getCol0() ); + tmp2 = cross( tfrm.getCol0(), tfrm.getCol1() ); + detinv = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), dot( tfrm.getCol2(), tmp2 ) ); + inv0 = Vector3( vec_madd( tmp0.getX(), detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp1.getX(), detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp2.getX(), detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + inv1 = Vector3( vec_madd( tmp0.getY(), detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp1.getY(), detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp2.getY(), detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + inv2 = Vector3( vec_madd( tmp0.getZ(), detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp1.getZ(), detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp2.getZ(), detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + return Transform3( + inv0, + inv1, + inv2, + Vector3( ( -( ( inv0 * tfrm.getCol3().getX() ) + ( ( inv1 * tfrm.getCol3().getY() ) + ( inv2 * tfrm.getCol3().getZ() ) ) ) ) ) + ); +} + +inline const Transform3 orthoInverse( const Transform3 & tfrm ) +{ + Vector3 inv0, inv1, inv2; + inv0 = Vector3( tfrm.getCol0().getX(), tfrm.getCol1().getX(), tfrm.getCol2().getX() ); + inv1 = Vector3( tfrm.getCol0().getY(), tfrm.getCol1().getY(), tfrm.getCol2().getY() ); + inv2 = Vector3( tfrm.getCol0().getZ(), tfrm.getCol1().getZ(), tfrm.getCol2().getZ() ); + return Transform3( + inv0, + inv1, + inv2, + Vector3( ( -( ( inv0 * tfrm.getCol3().getX() ) + ( ( inv1 * tfrm.getCol3().getY() ) + ( inv2 * tfrm.getCol3().getZ() ) ) ) ) ) + ); +} + +inline const Transform3 absPerElem( const Transform3 & tfrm ) +{ + return Transform3( + absPerElem( tfrm.getCol0() ), + absPerElem( tfrm.getCol1() ), + absPerElem( tfrm.getCol2() ), + absPerElem( tfrm.getCol3() ) + ); +} + +inline const Vector3 Transform3::operator *( const Vector3 & vec ) const +{ + return Vector3( + vec_add( vec_add( vec_madd( mCol0.getX(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getX(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getX(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), + vec_add( vec_add( vec_madd( mCol0.getY(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getY(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getY(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), + vec_add( vec_add( vec_madd( mCol0.getZ(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getZ(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getZ(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) + ); +} + +inline const Point3 Transform3::operator *( const Point3 & pnt ) const +{ + return Point3( + vec_add( vec_add( vec_add( vec_madd( mCol0.getX(), pnt.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getX(), pnt.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getX(), pnt.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), mCol3.getX() ), + vec_add( vec_add( vec_add( vec_madd( mCol0.getY(), pnt.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getY(), pnt.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getY(), pnt.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), mCol3.getY() ), + vec_add( vec_add( vec_add( vec_madd( mCol0.getZ(), pnt.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getZ(), pnt.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getZ(), pnt.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), mCol3.getZ() ) + ); +} + +inline const Transform3 Transform3::operator *( const Transform3 & tfrm ) const +{ + return Transform3( + ( *this * tfrm.mCol0 ), + ( *this * tfrm.mCol1 ), + ( *this * tfrm.mCol2 ), + Vector3( ( *this * Point3( tfrm.mCol3 ) ) ) + ); +} + +inline Transform3 & Transform3::operator *=( const Transform3 & tfrm ) +{ + *this = *this * tfrm; + return *this; +} + +inline const Transform3 mulPerElem( const Transform3 & tfrm0, const Transform3 & tfrm1 ) +{ + return Transform3( + mulPerElem( tfrm0.getCol0(), tfrm1.getCol0() ), + mulPerElem( tfrm0.getCol1(), tfrm1.getCol1() ), + mulPerElem( tfrm0.getCol2(), tfrm1.getCol2() ), + mulPerElem( tfrm0.getCol3(), tfrm1.getCol3() ) + ); +} + +inline const Transform3 Transform3::identity( ) +{ + return Transform3( + Vector3::xAxis( ), + Vector3::yAxis( ), + Vector3::zAxis( ), + Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) + ); +} + +inline Transform3 & Transform3::setUpper3x3( const Matrix3 & tfrm ) +{ + mCol0 = tfrm.getCol0(); + mCol1 = tfrm.getCol1(); + mCol2 = tfrm.getCol2(); + return *this; +} + +inline const Matrix3 Transform3::getUpper3x3( ) const +{ + return Matrix3( mCol0, mCol1, mCol2 ); +} + +inline Transform3 & Transform3::setTranslation( const Vector3 & translateVec ) +{ + mCol3 = translateVec; + return *this; +} + +inline const Vector3 Transform3::getTranslation( ) const +{ + return mCol3; +} + +inline const Transform3 Transform3::rotationX( vec_float4 radians ) +{ + vec_float4 s, c; + sincosf4( radians, &s, &c ); + return Transform3( + Vector3::xAxis( ), + Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c, s ), + Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), negatef4( s ), c ), + Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) + ); +} + +inline const Transform3 Transform3::rotationY( vec_float4 radians ) +{ + vec_float4 s, c; + sincosf4( radians, &s, &c ); + return Transform3( + Vector3( c, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), negatef4( s ) ), + Vector3::yAxis( ), + Vector3( s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c ), + Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) + ); +} + +inline const Transform3 Transform3::rotationZ( vec_float4 radians ) +{ + vec_float4 s, c; + sincosf4( radians, &s, &c ); + return Transform3( + Vector3( c, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + Vector3( negatef4( s ), c, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + Vector3::zAxis( ), + Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) + ); +} + +inline const Transform3 Transform3::rotationZYX( const Vector3 & radiansXYZ ) +{ + vec_float4 sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; + sincosf4( radiansXYZ.getX(), &sX, &cX ); + sincosf4( radiansXYZ.getY(), &sY, &cY ); + sincosf4( radiansXYZ.getZ(), &sZ, &cZ ); + tmp0 = vec_madd( cZ, sY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + tmp1 = vec_madd( sZ, sY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + return Transform3( + Vector3( vec_madd( cZ, cY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sZ, cY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), negatef4( sY ) ), + Vector3( vec_sub( vec_madd( tmp0, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sZ, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_add( vec_madd( tmp1, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( cZ, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( cY, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), + Vector3( vec_add( vec_madd( tmp0, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sZ, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_sub( vec_madd( tmp1, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( cZ, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( cY, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), + Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) + ); +} + +inline const Transform3 Transform3::rotation( vec_float4 radians, const Vector3 & unitVec ) +{ + return Transform3( Matrix3::rotation( radians, unitVec ), Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); +} + +inline const Transform3 Transform3::rotation( const Quat & unitQuat ) +{ + return Transform3( Matrix3( unitQuat ), Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); +} + +inline const Transform3 Transform3::scale( const Vector3 & scaleVec ) +{ + return Transform3( + Vector3( scaleVec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), scaleVec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), scaleVec.getZ() ), + Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) + ); +} + +inline const Transform3 appendScale( const Transform3 & tfrm, const Vector3 & scaleVec ) +{ + return Transform3( + ( tfrm.getCol0() * scaleVec.getX( ) ), + ( tfrm.getCol1() * scaleVec.getY( ) ), + ( tfrm.getCol2() * scaleVec.getZ( ) ), + tfrm.getCol3() + ); +} + +inline const Transform3 prependScale( const Vector3 & scaleVec, const Transform3 & tfrm ) +{ + return Transform3( + mulPerElem( tfrm.getCol0(), scaleVec ), + mulPerElem( tfrm.getCol1(), scaleVec ), + mulPerElem( tfrm.getCol2(), scaleVec ), + mulPerElem( tfrm.getCol3(), scaleVec ) + ); +} + +inline const Transform3 Transform3::translation( const Vector3 & translateVec ) +{ + return Transform3( + Vector3::xAxis( ), + Vector3::yAxis( ), + Vector3::zAxis( ), + translateVec + ); +} + +inline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, vec_uint4 select1 ) +{ + return Transform3( + select( tfrm0.getCol0(), tfrm1.getCol0(), select1 ), + select( tfrm0.getCol1(), tfrm1.getCol1(), select1 ), + select( tfrm0.getCol2(), tfrm1.getCol2(), select1 ), + select( tfrm0.getCol3(), tfrm1.getCol3(), select1 ) + ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( const Transform3 & tfrm ) +{ + Aos::Transform3 mat0, mat1, mat2, mat3; + tfrm.get4Aos( mat0, mat1, mat2, mat3 ); + printf("slot 0:\n"); + print( mat0 ); + printf("slot 1:\n"); + print( mat1 ); + printf("slot 2:\n"); + print( mat2 ); + printf("slot 3:\n"); + print( mat3 ); +} + +inline void print( const Transform3 & tfrm, const char * name ) +{ + printf("%s:\n", name); + print( tfrm ); +} + +#endif + +inline Quat::Quat( const Matrix3 & tfrm ) +{ + vec_float4 trace, radicand, scale, xx, yx, zx, xy, yy, zy, xz, yz, zz, tmpx, tmpy, tmpz, tmpw, qx, qy, qz, qw; + vec_uint4 negTrace, ZgtX, ZgtY, YgtX; + vec_uint4 largestXorY, largestYorZ, largestZorX; + + xx = tfrm.getCol0().getX(); + yx = tfrm.getCol0().getY(); + zx = tfrm.getCol0().getZ(); + xy = tfrm.getCol1().getX(); + yy = tfrm.getCol1().getY(); + zy = tfrm.getCol1().getZ(); + xz = tfrm.getCol2().getX(); + yz = tfrm.getCol2().getY(); + zz = tfrm.getCol2().getZ(); + + trace = vec_add( vec_add( xx, yy ), zz ); + + negTrace = (vec_uint4)vec_cmpgt( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), trace ); + ZgtX = (vec_uint4)vec_cmpgt( zz, xx ); + ZgtY = (vec_uint4)vec_cmpgt( zz, yy ); + YgtX = (vec_uint4)vec_cmpgt( yy, xx ); + largestXorY = vec_andc( negTrace, vec_and( ZgtX, ZgtY ) ); + largestYorZ = vec_and( negTrace, vec_or( YgtX, ZgtX ) ); + largestZorX = vec_andc( negTrace, vec_andc( YgtX, ZgtY ) ); + + zz = vec_sel( zz, negatef4(zz), largestXorY ); + xy = vec_sel( xy, negatef4(xy), largestXorY ); + xx = vec_sel( xx, negatef4(xx), largestYorZ ); + yz = vec_sel( yz, negatef4(yz), largestYorZ ); + yy = vec_sel( yy, negatef4(yy), largestZorX ); + zx = vec_sel( zx, negatef4(zx), largestZorX ); + + radicand = vec_add( vec_add( vec_add( xx, yy ), zz ), ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); + scale = vec_madd( ((vec_float4){0.5f,0.5f,0.5f,0.5f}), divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( radicand ) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + + tmpx = vec_madd( vec_sub( zy, yz ), scale, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + tmpy = vec_madd( vec_sub( xz, zx ), scale, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + tmpz = vec_madd( vec_sub( yx, xy ), scale, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + tmpw = vec_madd( radicand, scale, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + qx = tmpx; + qy = tmpy; + qz = tmpz; + qw = tmpw; + + qx = vec_sel( qx, tmpw, largestXorY ); + qy = vec_sel( qy, tmpz, largestXorY ); + qz = vec_sel( qz, tmpy, largestXorY ); + qw = vec_sel( qw, tmpx, largestXorY ); + tmpx = qx; + tmpz = qz; + qx = vec_sel( qx, qy, largestYorZ ); + qy = vec_sel( qy, tmpx, largestYorZ ); + qz = vec_sel( qz, qw, largestYorZ ); + qw = vec_sel( qw, tmpz, largestYorZ ); + + mX = qx; + mY = qy; + mZ = qz; + mW = qw; +} + +inline const Matrix3 outer( const Vector3 & tfrm0, const Vector3 & tfrm1 ) +{ + return Matrix3( + ( tfrm0 * tfrm1.getX( ) ), + ( tfrm0 * tfrm1.getY( ) ), + ( tfrm0 * tfrm1.getZ( ) ) + ); +} + +inline const Matrix4 outer( const Vector4 & tfrm0, const Vector4 & tfrm1 ) +{ + return Matrix4( + ( tfrm0 * tfrm1.getX( ) ), + ( tfrm0 * tfrm1.getY( ) ), + ( tfrm0 * tfrm1.getZ( ) ), + ( tfrm0 * tfrm1.getW( ) ) + ); +} + +inline const Vector3 rowMul( const Vector3 & vec, const Matrix3 & mat ) +{ + return Vector3( + vec_add( vec_add( vec_madd( vec.getX(), mat.getCol0().getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( vec.getY(), mat.getCol0().getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( vec.getZ(), mat.getCol0().getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), + vec_add( vec_add( vec_madd( vec.getX(), mat.getCol1().getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( vec.getY(), mat.getCol1().getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( vec.getZ(), mat.getCol1().getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), + vec_add( vec_add( vec_madd( vec.getX(), mat.getCol2().getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( vec.getY(), mat.getCol2().getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( vec.getZ(), mat.getCol2().getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) + ); +} + +inline const Matrix3 crossMatrix( const Vector3 & vec ) +{ + return Matrix3( + Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), vec.getZ(), negatef4( vec.getY() ) ), + Vector3( negatef4( vec.getZ() ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), vec.getX() ), + Vector3( vec.getY(), negatef4( vec.getX() ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) + ); +} + +inline const Matrix3 crossMatrixMul( const Vector3 & vec, const Matrix3 & mat ) +{ + return Matrix3( cross( vec, mat.getCol0() ), cross( vec, mat.getCol1() ), cross( vec, mat.getCol2() ) ); +} + +} // namespace Soa +} // namespace Vectormath + +#endif diff --git a/vectormathlibrary/include/vectormath/ppu/cpp/quat_aos.h b/vectormathlibrary/include/vectormath/ppu/cpp/quat_aos.h new file mode 100644 index 000000000..196a48d98 --- /dev/null +++ b/vectormathlibrary/include/vectormath/ppu/cpp/quat_aos.h @@ -0,0 +1,536 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_QUAT_AOS_CPP_H +#define _VECTORMATH_QUAT_AOS_CPP_H +//----------------------------------------------------------------------------- +// Definitions + +#ifndef _VECTORMATH_INTERNAL_FUNCTIONS +#define _VECTORMATH_INTERNAL_FUNCTIONS + +#endif + +namespace Vectormath { +namespace Aos { + +inline Quat::Quat( float _x, float _y, float _z, float _w ) +{ + if (__builtin_constant_p(_x) & __builtin_constant_p(_y) & + __builtin_constant_p(_z) & __builtin_constant_p(_w)) { + mVec128 = (vec_float4){_x, _y, _z, _w}; + } else { + float *pf = (float *)&mVec128; + pf[0] = _x; + pf[1] = _y; + pf[2] = _z; + pf[3] = _w; + } +} + +inline Quat::Quat( floatInVec _x, floatInVec _y, floatInVec _z, floatInVec _w ) +{ + vec_float4 xz = vec_mergeh( _x.get128(), _z.get128() ); + vec_float4 yw = vec_mergeh( _y.get128(), _w.get128() ); + mVec128 = vec_mergeh( xz, yw ); +} + +inline Quat::Quat( Vector3 xyz, float _w ) +{ + mVec128 = xyz.get128(); + _vmathVfSetElement(mVec128, _w, 3); +} + +inline Quat::Quat( Vector3 xyz, floatInVec _w ) +{ + mVec128 = xyz.get128(); + mVec128 = _vmathVfInsert(mVec128, _w.get128(), 3); +} + +inline Quat::Quat( Vector4 vec ) +{ + mVec128 = vec.get128(); +} + +inline Quat::Quat( float scalar ) +{ + mVec128 = floatInVec(scalar).get128(); +} + +inline Quat::Quat( floatInVec scalar ) +{ + mVec128 = scalar.get128(); +} + +inline Quat::Quat( vec_float4 vf4 ) +{ + mVec128 = vf4; +} + +inline const Quat Quat::identity( ) +{ + return Quat( _VECTORMATH_UNIT_0001 ); +} + +inline const Quat lerp( float t, Quat quat0, Quat quat1 ) +{ + return lerp( floatInVec(t), quat0, quat1 ); +} + +inline const Quat lerp( floatInVec t, Quat quat0, Quat quat1 ) +{ + return ( quat0 + ( ( quat1 - quat0 ) * t ) ); +} + +inline const Quat slerp( float t, Quat unitQuat0, Quat unitQuat1 ) +{ + return slerp( floatInVec(t), unitQuat0, unitQuat1 ); +} + +inline const Quat slerp( floatInVec t, Quat unitQuat0, Quat unitQuat1 ) +{ + Quat start; + vec_float4 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines; + vec_uint4 selectMask; + cosAngle = _vmathVfDot4( unitQuat0.get128(), unitQuat1.get128() ); + cosAngle = vec_splat( cosAngle, 0 ); + selectMask = (vec_uint4)vec_cmpgt( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), cosAngle ); + cosAngle = vec_sel( cosAngle, negatef4( cosAngle ), selectMask ); + start = Quat( vec_sel( unitQuat0.get128(), negatef4( unitQuat0.get128() ), selectMask ) ); + selectMask = (vec_uint4)vec_cmpgt( ((vec_float4){_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL}), cosAngle ); + angle = acosf4( cosAngle ); + tttt = t.get128(); + oneMinusT = vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), tttt ); + angles = vec_mergeh( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), tttt ); + angles = vec_mergeh( angles, oneMinusT ); + angles = vec_madd( angles, angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + sines = sinf4( angles ); + scales = divf4( sines, vec_splat( sines, 0 ) ); + scale0 = vec_sel( oneMinusT, vec_splat( scales, 1 ), selectMask ); + scale1 = vec_sel( tttt, vec_splat( scales, 2 ), selectMask ); + return Quat( vec_madd( start.get128(), scale0, vec_madd( unitQuat1.get128(), scale1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ); +} + +inline const Quat squad( float t, Quat unitQuat0, Quat unitQuat1, Quat unitQuat2, Quat unitQuat3 ) +{ + return squad( floatInVec(t), unitQuat0, unitQuat1, unitQuat2, unitQuat3 ); +} + +inline const Quat squad( floatInVec t, Quat unitQuat0, Quat unitQuat1, Quat unitQuat2, Quat unitQuat3 ) +{ + Quat tmp0, tmp1; + tmp0 = slerp( t, unitQuat0, unitQuat3 ); + tmp1 = slerp( t, unitQuat1, unitQuat2 ); + return slerp( ( ( floatInVec(2.0f) * t ) * ( floatInVec(1.0f) - t ) ), tmp0, tmp1 ); +} + +inline vec_float4 Quat::get128( ) const +{ + return mVec128; +} + +inline Quat & Quat::operator =( Quat quat ) +{ + mVec128 = quat.mVec128; + return *this; +} + +inline Quat & Quat::setXYZ( Vector3 vec ) +{ + mVec128 = vec_sel( vec.get128(), mVec128, _VECTORMATH_MASK_0x000F ); + return *this; +} + +inline const Vector3 Quat::getXYZ( ) const +{ + return Vector3( mVec128 ); +} + +inline Quat & Quat::setX( float _x ) +{ + _vmathVfSetElement(mVec128, _x, 0); + return *this; +} + +inline Quat & Quat::setX( floatInVec _x ) +{ + mVec128 = _vmathVfInsert(mVec128, _x.get128(), 0); + return *this; +} + +inline const floatInVec Quat::getX( ) const +{ + return floatInVec( mVec128, 0 ); +} + +inline Quat & Quat::setY( float _y ) +{ + _vmathVfSetElement(mVec128, _y, 1); + return *this; +} + +inline Quat & Quat::setY( floatInVec _y ) +{ + mVec128 = _vmathVfInsert(mVec128, _y.get128(), 1); + return *this; +} + +inline const floatInVec Quat::getY( ) const +{ + return floatInVec( mVec128, 1 ); +} + +inline Quat & Quat::setZ( float _z ) +{ + _vmathVfSetElement(mVec128, _z, 2); + return *this; +} + +inline Quat & Quat::setZ( floatInVec _z ) +{ + mVec128 = _vmathVfInsert(mVec128, _z.get128(), 2); + return *this; +} + +inline const floatInVec Quat::getZ( ) const +{ + return floatInVec( mVec128, 2 ); +} + +inline Quat & Quat::setW( float _w ) +{ + _vmathVfSetElement(mVec128, _w, 3); + return *this; +} + +inline Quat & Quat::setW( floatInVec _w ) +{ + mVec128 = _vmathVfInsert(mVec128, _w.get128(), 3); + return *this; +} + +inline const floatInVec Quat::getW( ) const +{ + return floatInVec( mVec128, 3 ); +} + +inline Quat & Quat::setElem( int idx, float value ) +{ + _vmathVfSetElement(mVec128, value, idx); + return *this; +} + +inline Quat & Quat::setElem( int idx, floatInVec value ) +{ + mVec128 = _vmathVfInsert(mVec128, value.get128(), idx); + return *this; +} + +inline const floatInVec Quat::getElem( int idx ) const +{ + return floatInVec( mVec128, idx ); +} + +inline VecIdx Quat::operator []( int idx ) +{ + return VecIdx( mVec128, idx ); +} + +inline const floatInVec Quat::operator []( int idx ) const +{ + return floatInVec( mVec128, idx ); +} + +inline const Quat Quat::operator +( Quat quat ) const +{ + return Quat( vec_add( mVec128, quat.mVec128 ) ); +} + +inline const Quat Quat::operator -( Quat quat ) const +{ + return Quat( vec_sub( mVec128, quat.mVec128 ) ); +} + +inline const Quat Quat::operator *( float scalar ) const +{ + return *this * floatInVec(scalar); +} + +inline const Quat Quat::operator *( floatInVec scalar ) const +{ + return Quat( vec_madd( mVec128, scalar.get128(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); +} + +inline Quat & Quat::operator +=( Quat quat ) +{ + *this = *this + quat; + return *this; +} + +inline Quat & Quat::operator -=( Quat quat ) +{ + *this = *this - quat; + return *this; +} + +inline Quat & Quat::operator *=( float scalar ) +{ + *this = *this * scalar; + return *this; +} + +inline Quat & Quat::operator *=( floatInVec scalar ) +{ + *this = *this * scalar; + return *this; +} + +inline const Quat Quat::operator /( float scalar ) const +{ + return *this / floatInVec(scalar); +} + +inline const Quat Quat::operator /( floatInVec scalar ) const +{ + return Quat( divf4( mVec128, scalar.get128() ) ); +} + +inline Quat & Quat::operator /=( float scalar ) +{ + *this = *this / scalar; + return *this; +} + +inline Quat & Quat::operator /=( floatInVec scalar ) +{ + *this = *this / scalar; + return *this; +} + +inline const Quat Quat::operator -( ) const +{ + return Quat( negatef4( mVec128 ) ); +} + +inline const Quat operator *( float scalar, Quat quat ) +{ + return floatInVec(scalar) * quat; +} + +inline const Quat operator *( floatInVec scalar, Quat quat ) +{ + return quat * scalar; +} + +inline const floatInVec dot( Quat quat0, Quat quat1 ) +{ + return floatInVec( _vmathVfDot4( quat0.get128(), quat1.get128() ), 0 ); +} + +inline const floatInVec norm( Quat quat ) +{ + return floatInVec( _vmathVfDot4( quat.get128(), quat.get128() ), 0 ); +} + +inline const floatInVec length( Quat quat ) +{ + return floatInVec( sqrtf4(_vmathVfDot4( quat.get128(), quat.get128() )), 0 ); +} + +inline const Quat normalize( Quat quat ) +{ + vec_float4 dot = _vmathVfDot4( quat.get128(), quat.get128() ); + return Quat( vec_madd( quat.get128(), rsqrtf4( dot ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); +} + +inline const Quat Quat::rotation( Vector3 unitVec0, Vector3 unitVec1 ) +{ + Vector3 crossVec; + vec_float4 cosAngle, cosAngleX2Plus2, recipCosHalfAngleX2, cosHalfAngleX2, res; + cosAngle = _vmathVfDot3( unitVec0.get128(), unitVec1.get128() ); + cosAngle = vec_splat( cosAngle, 0 ); + cosAngleX2Plus2 = vec_madd( cosAngle, ((vec_float4){2.0f,2.0f,2.0f,2.0f}), ((vec_float4){2.0f,2.0f,2.0f,2.0f}) ); + recipCosHalfAngleX2 = rsqrtf4( cosAngleX2Plus2 ); + cosHalfAngleX2 = vec_madd( recipCosHalfAngleX2, cosAngleX2Plus2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + crossVec = cross( unitVec0, unitVec1 ); + res = vec_madd( crossVec.get128(), recipCosHalfAngleX2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + res = vec_sel( res, vec_madd( cosHalfAngleX2, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), _VECTORMATH_MASK_0x000F ); + return Quat( res ); +} + +inline const Quat Quat::rotation( float radians, Vector3 unitVec ) +{ + return rotation( floatInVec(radians), unitVec ); +} + +inline const Quat Quat::rotation( floatInVec radians, Vector3 unitVec ) +{ + vec_float4 s, c, angle, res; + angle = vec_madd( radians.get128(), ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + sincosf4( angle, &s, &c ); + res = vec_sel( vec_madd( unitVec.get128(), s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), c, _VECTORMATH_MASK_0x000F ); + return Quat( res ); +} + +inline const Quat Quat::rotationX( float radians ) +{ + return rotationX( floatInVec(radians) ); +} + +inline const Quat Quat::rotationX( floatInVec radians ) +{ + vec_float4 s, c, angle, res; + angle = vec_madd( radians.get128(), ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + sincosf4( angle, &s, &c ); + res = vec_sel( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, _VECTORMATH_MASK_0xF000 ); + res = vec_sel( res, c, _VECTORMATH_MASK_0x000F ); + return Quat( res ); +} + +inline const Quat Quat::rotationY( float radians ) +{ + return rotationY( floatInVec(radians) ); +} + +inline const Quat Quat::rotationY( floatInVec radians ) +{ + vec_float4 s, c, angle, res; + angle = vec_madd( radians.get128(), ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + sincosf4( angle, &s, &c ); + res = vec_sel( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, _VECTORMATH_MASK_0x0F00 ); + res = vec_sel( res, c, _VECTORMATH_MASK_0x000F ); + return Quat( res ); +} + +inline const Quat Quat::rotationZ( float radians ) +{ + return rotationZ( floatInVec(radians) ); +} + +inline const Quat Quat::rotationZ( floatInVec radians ) +{ + vec_float4 s, c, angle, res; + angle = vec_madd( radians.get128(), ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + sincosf4( angle, &s, &c ); + res = vec_sel( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, _VECTORMATH_MASK_0x00F0 ); + res = vec_sel( res, c, _VECTORMATH_MASK_0x000F ); + return Quat( res ); +} + +inline const Quat Quat::operator *( Quat quat ) const +{ + vec_float4 ldata, rdata, qv, tmp0, tmp1, tmp2, tmp3; + vec_float4 product, l_wxyz, r_wxyz, xy, qw; + ldata = mVec128; + rdata = quat.mVec128; + tmp0 = vec_perm( ldata, ldata, _VECTORMATH_PERM_YZXW ); + tmp1 = vec_perm( rdata, rdata, _VECTORMATH_PERM_ZXYW ); + tmp2 = vec_perm( ldata, ldata, _VECTORMATH_PERM_ZXYW ); + tmp3 = vec_perm( rdata, rdata, _VECTORMATH_PERM_YZXW ); + qv = vec_madd( vec_splat( ldata, 3 ), rdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + qv = vec_madd( vec_splat( rdata, 3 ), ldata, qv ); + qv = vec_madd( tmp0, tmp1, qv ); + qv = vec_nmsub( tmp2, tmp3, qv ); + product = vec_madd( ldata, rdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + l_wxyz = vec_sld( ldata, ldata, 12 ); + r_wxyz = vec_sld( rdata, rdata, 12 ); + qw = vec_nmsub( l_wxyz, r_wxyz, product ); + xy = vec_madd( l_wxyz, r_wxyz, product ); + qw = vec_sub( qw, vec_sld( xy, xy, 8 ) ); + return Quat( vec_sel( qv, qw, _VECTORMATH_MASK_0x000F ) ); +} + +inline Quat & Quat::operator *=( Quat quat ) +{ + *this = *this * quat; + return *this; +} + +inline const Vector3 rotate( Quat quat, Vector3 vec ) +{ + vec_float4 qdata, vdata, product, tmp0, tmp1, tmp2, tmp3, wwww, qv, qw, res; + qdata = quat.get128(); + vdata = vec.get128(); + tmp0 = vec_perm( qdata, qdata, _VECTORMATH_PERM_YZXW ); + tmp1 = vec_perm( vdata, vdata, _VECTORMATH_PERM_ZXYW ); + tmp2 = vec_perm( qdata, qdata, _VECTORMATH_PERM_ZXYW ); + tmp3 = vec_perm( vdata, vdata, _VECTORMATH_PERM_YZXW ); + wwww = vec_splat( qdata, 3 ); + qv = vec_madd( wwww, vdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + qv = vec_madd( tmp0, tmp1, qv ); + qv = vec_nmsub( tmp2, tmp3, qv ); + product = vec_madd( qdata, vdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + qw = vec_madd( vec_sld( qdata, qdata, 4 ), vec_sld( vdata, vdata, 4 ), product ); + qw = vec_add( vec_sld( product, product, 8 ), qw ); + tmp1 = vec_perm( qv, qv, _VECTORMATH_PERM_ZXYW ); + tmp3 = vec_perm( qv, qv, _VECTORMATH_PERM_YZXW ); + res = vec_madd( vec_splat( qw, 0 ), qdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + res = vec_madd( wwww, qv, res ); + res = vec_madd( tmp0, tmp1, res ); + res = vec_nmsub( tmp2, tmp3, res ); + return Vector3( res ); +} + +inline const Quat conj( Quat quat ) +{ + return Quat( vec_xor( quat.get128(), ((vec_float4)(vec_int4){0x80000000,0x80000000,0x80000000,0}) ) ); +} + +inline const Quat select( Quat quat0, Quat quat1, bool select1 ) +{ + return select( quat0, quat1, boolInVec(select1) ); +} + +inline const Quat select( Quat quat0, Quat quat1, boolInVec select1 ) +{ + return Quat( vec_sel( quat0.get128(), quat1.get128(), select1.get128() ) ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( Quat quat ) +{ + union { vec_float4 v; float s[4]; } tmp; + tmp.v = quat.get128(); + printf( "( %f %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] ); +} + +inline void print( Quat quat, const char * name ) +{ + union { vec_float4 v; float s[4]; } tmp; + tmp.v = quat.get128(); + printf( "%s: ( %f %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] ); +} + +#endif + +} // namespace Aos +} // namespace Vectormath + +#endif diff --git a/vectormathlibrary/include/vectormath/ppu/cpp/quat_soa.h b/vectormathlibrary/include/vectormath/ppu/cpp/quat_soa.h new file mode 100644 index 000000000..fb83e8121 --- /dev/null +++ b/vectormathlibrary/include/vectormath/ppu/cpp/quat_soa.h @@ -0,0 +1,479 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_QUAT_SOA_CPP_H +#define _VECTORMATH_QUAT_SOA_CPP_H +//----------------------------------------------------------------------------- +// Definitions + +#ifndef _VECTORMATH_INTERNAL_FUNCTIONS +#define _VECTORMATH_INTERNAL_FUNCTIONS + +#endif + +namespace Vectormath { +namespace Soa { + +inline Quat::Quat( const Quat & quat ) +{ + mX = quat.mX; + mY = quat.mY; + mZ = quat.mZ; + mW = quat.mW; +} + +inline Quat::Quat( vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w ) +{ + mX = _x; + mY = _y; + mZ = _z; + mW = _w; +} + +inline Quat::Quat( const Vector3 & xyz, vec_float4 _w ) +{ + this->setXYZ( xyz ); + this->setW( _w ); +} + +inline Quat::Quat( const Vector4 & vec ) +{ + mX = vec.getX(); + mY = vec.getY(); + mZ = vec.getZ(); + mW = vec.getW(); +} + +inline Quat::Quat( vec_float4 scalar ) +{ + mX = scalar; + mY = scalar; + mZ = scalar; + mW = scalar; +} + +inline Quat::Quat( Aos::Quat quat ) +{ + vec_float4 vec128 = quat.get128(); + mX = vec_splat( vec128, 0 ); + mY = vec_splat( vec128, 1 ); + mZ = vec_splat( vec128, 2 ); + mW = vec_splat( vec128, 3 ); +} + +inline Quat::Quat( Aos::Quat quat0, Aos::Quat quat1, Aos::Quat quat2, Aos::Quat quat3 ) +{ + vec_float4 tmp0, tmp1, tmp2, tmp3; + tmp0 = vec_mergeh( quat0.get128(), quat2.get128() ); + tmp1 = vec_mergeh( quat1.get128(), quat3.get128() ); + tmp2 = vec_mergel( quat0.get128(), quat2.get128() ); + tmp3 = vec_mergel( quat1.get128(), quat3.get128() ); + mX = vec_mergeh( tmp0, tmp1 ); + mY = vec_mergel( tmp0, tmp1 ); + mZ = vec_mergeh( tmp2, tmp3 ); + mW = vec_mergel( tmp2, tmp3 ); +} + +inline const Quat Quat::identity( ) +{ + return Quat( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); +} + +inline const Quat lerp( vec_float4 t, const Quat & quat0, const Quat & quat1 ) +{ + return ( quat0 + ( ( quat1 - quat0 ) * t ) ); +} + +inline const Quat slerp( vec_float4 t, const Quat & unitQuat0, const Quat & unitQuat1 ) +{ + Quat start; + vec_float4 recipSinAngle, scale0, scale1, cosAngle, angle; + vec_uint4 selectMask; + cosAngle = dot( unitQuat0, unitQuat1 ); + selectMask = (vec_uint4)vec_cmpgt( (vec_float4){0.0f,0.0f,0.0f,0.0f}, cosAngle ); + cosAngle = vec_sel( cosAngle, negatef4( cosAngle ), selectMask ); + start.setX( vec_sel( unitQuat0.getX(), negatef4( unitQuat0.getX() ), selectMask ) ); + start.setY( vec_sel( unitQuat0.getY(), negatef4( unitQuat0.getY() ), selectMask ) ); + start.setZ( vec_sel( unitQuat0.getZ(), negatef4( unitQuat0.getZ() ), selectMask ) ); + start.setW( vec_sel( unitQuat0.getW(), negatef4( unitQuat0.getW() ), selectMask ) ); + selectMask = (vec_uint4)vec_cmpgt( (vec_float4){_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL}, cosAngle ); + angle = acosf4( cosAngle ); + recipSinAngle = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sinf4( angle ) ); + scale0 = vec_sel( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), vec_madd( sinf4( vec_madd( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), recipSinAngle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), selectMask ); + scale1 = vec_sel( t, vec_madd( sinf4( vec_madd( t, angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), recipSinAngle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), selectMask ); + return ( ( start * scale0 ) + ( unitQuat1 * scale1 ) ); +} + +inline const Quat squad( vec_float4 t, const Quat & unitQuat0, const Quat & unitQuat1, const Quat & unitQuat2, const Quat & unitQuat3 ) +{ + Quat tmp0, tmp1; + tmp0 = slerp( t, unitQuat0, unitQuat3 ); + tmp1 = slerp( t, unitQuat1, unitQuat2 ); + return slerp( vec_madd( vec_madd( ((vec_float4){2.0f,2.0f,2.0f,2.0f}), t, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), tmp0, tmp1 ); +} + +inline void Quat::get4Aos( Aos::Quat & result0, Aos::Quat & result1, Aos::Quat & result2, Aos::Quat & result3 ) const +{ + vec_float4 tmp0, tmp1, tmp2, tmp3; + tmp0 = vec_mergeh( mX, mZ ); + tmp1 = vec_mergeh( mY, mW ); + tmp2 = vec_mergel( mX, mZ ); + tmp3 = vec_mergel( mY, mW ); + result0 = Aos::Quat( vec_mergeh( tmp0, tmp1 ) ); + result1 = Aos::Quat( vec_mergel( tmp0, tmp1 ) ); + result2 = Aos::Quat( vec_mergeh( tmp2, tmp3 ) ); + result3 = Aos::Quat( vec_mergel( tmp2, tmp3 ) ); +} + +inline Quat & Quat::operator =( const Quat & quat ) +{ + mX = quat.mX; + mY = quat.mY; + mZ = quat.mZ; + mW = quat.mW; + return *this; +} + +inline Quat & Quat::setXYZ( const Vector3 & vec ) +{ + mX = vec.getX(); + mY = vec.getY(); + mZ = vec.getZ(); + return *this; +} + +inline const Vector3 Quat::getXYZ( ) const +{ + return Vector3( mX, mY, mZ ); +} + +inline Quat & Quat::setX( vec_float4 _x ) +{ + mX = _x; + return *this; +} + +inline vec_float4 Quat::getX( ) const +{ + return mX; +} + +inline Quat & Quat::setY( vec_float4 _y ) +{ + mY = _y; + return *this; +} + +inline vec_float4 Quat::getY( ) const +{ + return mY; +} + +inline Quat & Quat::setZ( vec_float4 _z ) +{ + mZ = _z; + return *this; +} + +inline vec_float4 Quat::getZ( ) const +{ + return mZ; +} + +inline Quat & Quat::setW( vec_float4 _w ) +{ + mW = _w; + return *this; +} + +inline vec_float4 Quat::getW( ) const +{ + return mW; +} + +inline Quat & Quat::setElem( int idx, vec_float4 value ) +{ + *(&mX + idx) = value; + return *this; +} + +inline vec_float4 Quat::getElem( int idx ) const +{ + return *(&mX + idx); +} + +inline Quat::vec_float4_t & Quat::operator []( int idx ) +{ + return *(&mX + idx); +} + +inline vec_float4 Quat::operator []( int idx ) const +{ + return *(&mX + idx); +} + +inline const Quat Quat::operator +( const Quat & quat ) const +{ + return Quat( + vec_add( mX, quat.mX ), + vec_add( mY, quat.mY ), + vec_add( mZ, quat.mZ ), + vec_add( mW, quat.mW ) + ); +} + +inline const Quat Quat::operator -( const Quat & quat ) const +{ + return Quat( + vec_sub( mX, quat.mX ), + vec_sub( mY, quat.mY ), + vec_sub( mZ, quat.mZ ), + vec_sub( mW, quat.mW ) + ); +} + +inline const Quat Quat::operator *( vec_float4 scalar ) const +{ + return Quat( + vec_madd( mX, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + vec_madd( mY, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + vec_madd( mZ, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + vec_madd( mW, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) + ); +} + +inline Quat & Quat::operator +=( const Quat & quat ) +{ + *this = *this + quat; + return *this; +} + +inline Quat & Quat::operator -=( const Quat & quat ) +{ + *this = *this - quat; + return *this; +} + +inline Quat & Quat::operator *=( vec_float4 scalar ) +{ + *this = *this * scalar; + return *this; +} + +inline const Quat Quat::operator /( vec_float4 scalar ) const +{ + return Quat( + divf4( mX, scalar ), + divf4( mY, scalar ), + divf4( mZ, scalar ), + divf4( mW, scalar ) + ); +} + +inline Quat & Quat::operator /=( vec_float4 scalar ) +{ + *this = *this / scalar; + return *this; +} + +inline const Quat Quat::operator -( ) const +{ + return Quat( + negatef4( mX ), + negatef4( mY ), + negatef4( mZ ), + negatef4( mW ) + ); +} + +inline const Quat operator *( vec_float4 scalar, const Quat & quat ) +{ + return quat * scalar; +} + +inline vec_float4 dot( const Quat & quat0, const Quat & quat1 ) +{ + vec_float4 result; + result = vec_madd( quat0.getX(), quat1.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + result = vec_add( result, vec_madd( quat0.getY(), quat1.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + result = vec_add( result, vec_madd( quat0.getZ(), quat1.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + result = vec_add( result, vec_madd( quat0.getW(), quat1.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + return result; +} + +inline vec_float4 norm( const Quat & quat ) +{ + vec_float4 result; + result = vec_madd( quat.getX(), quat.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + result = vec_add( result, vec_madd( quat.getY(), quat.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + result = vec_add( result, vec_madd( quat.getZ(), quat.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + result = vec_add( result, vec_madd( quat.getW(), quat.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + return result; +} + +inline vec_float4 length( const Quat & quat ) +{ + return sqrtf4( norm( quat ) ); +} + +inline const Quat normalize( const Quat & quat ) +{ + vec_float4 lenSqr, lenInv; + lenSqr = norm( quat ); + lenInv = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( lenSqr ) ); + return Quat( + vec_madd( quat.getX(), lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + vec_madd( quat.getY(), lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + vec_madd( quat.getZ(), lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + vec_madd( quat.getW(), lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) + ); +} + +inline const Quat Quat::rotation( const Vector3 & unitVec0, const Vector3 & unitVec1 ) +{ + vec_float4 cosHalfAngleX2, recipCosHalfAngleX2; + cosHalfAngleX2 = sqrtf4( vec_madd( ((vec_float4){2.0f,2.0f,2.0f,2.0f}), vec_add( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), dot( unitVec0, unitVec1 ) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + recipCosHalfAngleX2 = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), cosHalfAngleX2 ); + return Quat( ( cross( unitVec0, unitVec1 ) * recipCosHalfAngleX2 ), vec_madd( cosHalfAngleX2, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); +} + +inline const Quat Quat::rotation( vec_float4 radians, const Vector3 & unitVec ) +{ + vec_float4 s, c, angle; + angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + sincosf4( angle, &s, &c ); + return Quat( ( unitVec * s ), c ); +} + +inline const Quat Quat::rotationX( vec_float4 radians ) +{ + vec_float4 s, c, angle; + angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + sincosf4( angle, &s, &c ); + return Quat( s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c ); +} + +inline const Quat Quat::rotationY( vec_float4 radians ) +{ + vec_float4 s, c, angle; + angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + sincosf4( angle, &s, &c ); + return Quat( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c ); +} + +inline const Quat Quat::rotationZ( vec_float4 radians ) +{ + vec_float4 s, c, angle; + angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + sincosf4( angle, &s, &c ); + return Quat( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, c ); +} + +inline const Quat Quat::operator *( const Quat & quat ) const +{ + return Quat( + vec_sub( vec_add( vec_add( vec_madd( mW, quat.mX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mX, quat.mW, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mY, quat.mZ, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mZ, quat.mY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), + vec_sub( vec_add( vec_add( vec_madd( mW, quat.mY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mY, quat.mW, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mZ, quat.mX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mX, quat.mZ, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), + vec_sub( vec_add( vec_add( vec_madd( mW, quat.mZ, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mZ, quat.mW, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mX, quat.mY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mY, quat.mX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), + vec_sub( vec_sub( vec_sub( vec_madd( mW, quat.mW, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mX, quat.mX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mY, quat.mY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mZ, quat.mZ, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) + ); +} + +inline Quat & Quat::operator *=( const Quat & quat ) +{ + *this = *this * quat; + return *this; +} + +inline const Vector3 rotate( const Quat & quat, const Vector3 & vec ) +{ + vec_float4 tmpX, tmpY, tmpZ, tmpW; + tmpX = vec_sub( vec_add( vec_madd( quat.getW(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat.getY(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat.getZ(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmpY = vec_sub( vec_add( vec_madd( quat.getW(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat.getZ(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat.getX(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmpZ = vec_sub( vec_add( vec_madd( quat.getW(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat.getX(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat.getY(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + tmpW = vec_add( vec_add( vec_madd( quat.getX(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat.getY(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat.getZ(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + return Vector3( + vec_add( vec_sub( vec_add( vec_madd( tmpW, quat.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmpX, quat.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpY, quat.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpZ, quat.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), + vec_add( vec_sub( vec_add( vec_madd( tmpW, quat.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmpY, quat.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpZ, quat.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpX, quat.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), + vec_add( vec_sub( vec_add( vec_madd( tmpW, quat.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmpZ, quat.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpX, quat.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpY, quat.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) + ); +} + +inline const Quat conj( const Quat & quat ) +{ + return Quat( negatef4( quat.getX() ), negatef4( quat.getY() ), negatef4( quat.getZ() ), quat.getW() ); +} + +inline const Quat select( const Quat & quat0, const Quat & quat1, vec_uint4 select1 ) +{ + return Quat( + vec_sel( quat0.getX(), quat1.getX(), select1 ), + vec_sel( quat0.getY(), quat1.getY(), select1 ), + vec_sel( quat0.getZ(), quat1.getZ(), select1 ), + vec_sel( quat0.getW(), quat1.getW(), select1 ) + ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( const Quat & quat ) +{ + Aos::Quat vec0, vec1, vec2, vec3; + quat.get4Aos( vec0, vec1, vec2, vec3 ); + printf("slot 0:\n"); + print( vec0 ); + printf("slot 1:\n"); + print( vec1 ); + printf("slot 2:\n"); + print( vec2 ); + printf("slot 3:\n"); + print( vec3 ); +} + +inline void print( const Quat & quat, const char * name ) +{ + Aos::Quat vec0, vec1, vec2, vec3; + printf( "%s:\n", name ); + quat.get4Aos( vec0, vec1, vec2, vec3 ); + printf("slot 0:\n"); + print( vec0 ); + printf("slot 1:\n"); + print( vec1 ); + printf("slot 2:\n"); + print( vec2 ); + printf("slot 3:\n"); + print( vec3 ); +} + +#endif + +} // namespace Soa +} // namespace Vectormath + +#endif diff --git a/vectormathlibrary/include/vectormath/ppu/cpp/vec_aos.h b/vectormathlibrary/include/vectormath/ppu/cpp/vec_aos.h new file mode 100644 index 000000000..dc1f9849b --- /dev/null +++ b/vectormathlibrary/include/vectormath/ppu/cpp/vec_aos.h @@ -0,0 +1,1492 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_VEC_AOS_CPP_H +#define _VECTORMATH_VEC_AOS_CPP_H +//----------------------------------------------------------------------------- +// Constants +// for permutes words are labeled [x,y,z,w] [a,b,c,d] + +#define _VECTORMATH_PERM_X 0x00010203 +#define _VECTORMATH_PERM_Y 0x04050607 +#define _VECTORMATH_PERM_Z 0x08090a0b +#define _VECTORMATH_PERM_W 0x0c0d0e0f +#define _VECTORMATH_PERM_A 0x10111213 +#define _VECTORMATH_PERM_B 0x14151617 +#define _VECTORMATH_PERM_C 0x18191a1b +#define _VECTORMATH_PERM_D 0x1c1d1e1f +#define _VECTORMATH_PERM_XYZA (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A } +#define _VECTORMATH_PERM_ZXYW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_W } +#define _VECTORMATH_PERM_YZXW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_W } +#define _VECTORMATH_PERM_YZAB (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A, _VECTORMATH_PERM_B } +#define _VECTORMATH_PERM_ZABC (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A, _VECTORMATH_PERM_B, _VECTORMATH_PERM_C } +#define _VECTORMATH_PERM_XYAW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A, _VECTORMATH_PERM_W } +#define _VECTORMATH_PERM_XAZW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_A, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_W } +#define _VECTORMATH_MASK_0xF000 (vec_uint4){ 0xffffffff, 0, 0, 0 } +#define _VECTORMATH_MASK_0x0F00 (vec_uint4){ 0, 0xffffffff, 0, 0 } +#define _VECTORMATH_MASK_0x00F0 (vec_uint4){ 0, 0, 0xffffffff, 0 } +#define _VECTORMATH_MASK_0x000F (vec_uint4){ 0, 0, 0, 0xffffffff } +#define _VECTORMATH_UNIT_1000 (vec_float4){ 1.0f, 0.0f, 0.0f, 0.0f } +#define _VECTORMATH_UNIT_0100 (vec_float4){ 0.0f, 1.0f, 0.0f, 0.0f } +#define _VECTORMATH_UNIT_0010 (vec_float4){ 0.0f, 0.0f, 1.0f, 0.0f } +#define _VECTORMATH_UNIT_0001 (vec_float4){ 0.0f, 0.0f, 0.0f, 1.0f } +#define _VECTORMATH_SLERP_TOL 0.999f + +//----------------------------------------------------------------------------- +// Definitions + +#ifndef _VECTORMATH_INTERNAL_FUNCTIONS +#define _VECTORMATH_INTERNAL_FUNCTIONS + +static inline vec_float4 _vmathVfDot3( vec_float4 vec0, vec_float4 vec1 ) +{ + vec_float4 result; + result = vec_madd( vec0, vec1, (vec_float4){0.0f,0.0f,0.0f,0.0f} ); + result = vec_madd( vec_sld( vec0, vec0, 4 ), vec_sld( vec1, vec1, 4 ), result ); + return vec_madd( vec_sld( vec0, vec0, 8 ), vec_sld( vec1, vec1, 8 ), result ); +} + +static inline vec_float4 _vmathVfDot4( vec_float4 vec0, vec_float4 vec1 ) +{ + vec_float4 result; + result = vec_madd( vec0, vec1, (vec_float4){0.0f,0.0f,0.0f,0.0f} ); + result = vec_madd( vec_sld( vec0, vec0, 4 ), vec_sld( vec1, vec1, 4 ), result ); + return vec_add( vec_sld( result, result, 8 ), result ); +} + +static inline vec_float4 _vmathVfCross( vec_float4 vec0, vec_float4 vec1 ) +{ + vec_float4 tmp0, tmp1, tmp2, tmp3, result; + tmp0 = vec_perm( vec0, vec0, _VECTORMATH_PERM_YZXW ); + tmp1 = vec_perm( vec1, vec1, _VECTORMATH_PERM_ZXYW ); + tmp2 = vec_perm( vec0, vec0, _VECTORMATH_PERM_ZXYW ); + tmp3 = vec_perm( vec1, vec1, _VECTORMATH_PERM_YZXW ); + result = vec_madd( tmp0, tmp1, (vec_float4){0.0f,0.0f,0.0f,0.0f} ); + result = vec_nmsub( tmp2, tmp3, result ); + return result; +} + +static inline vec_uint4 _vmathVfToHalfFloatsUnpacked(vec_float4 v) +{ + vec_int4 bexp; + vec_uint4 mant, sign, hfloat; + vec_uint4 notZero, isInf; + const vec_uint4 hfloatInf = (vec_uint4){0x00007c00u,0x00007c00u,0x00007c00u,0x00007c00u}; + const vec_uint4 mergeMant = (vec_uint4){0x000003ffu,0x000003ffu,0x000003ffu,0x000003ffu}; + const vec_uint4 mergeSign = (vec_uint4){0x00008000u,0x00008000u,0x00008000u,0x00008000u}; + + sign = vec_sr((vec_uint4)v, (vec_uint4){16,16,16,16}); + mant = vec_sr((vec_uint4)v, (vec_uint4){13,13,13,13}); + bexp = vec_and(vec_sr((vec_int4)v, (vec_uint4){23,23,23,23}), (vec_int4){0xff,0xff,0xff,0xff}); + + notZero = (vec_uint4)vec_cmpgt(bexp, (vec_int4){112,112,112,112}); + isInf = (vec_uint4)vec_cmpgt(bexp, (vec_int4){142,142,142,142}); + + bexp = vec_add(bexp, (vec_int4){-112,-112,-112,-112}); + bexp = vec_sl(bexp, (vec_uint4){10,10,10,10}); + + hfloat = vec_sel((vec_uint4)bexp, mant, mergeMant); + hfloat = vec_sel((vec_uint4){0,0,0,0}, hfloat, notZero); + hfloat = vec_sel(hfloat, hfloatInf, isInf); + hfloat = vec_sel(hfloat, sign, mergeSign); + + return hfloat; +} + +static inline vec_ushort8 _vmath2VfToHalfFloats(vec_float4 u, vec_float4 v) +{ + vec_uint4 hfloat_u, hfloat_v; + const vec_uchar16 pack = (vec_uchar16){2,3,6,7,10,11,14,15,18,19,22,23,26,27,30,31}; + hfloat_u = _vmathVfToHalfFloatsUnpacked(u); + hfloat_v = _vmathVfToHalfFloatsUnpacked(v); + return (vec_ushort8)vec_perm(hfloat_u, hfloat_v, pack); +} + +#ifndef __GNUC__ +#define __builtin_constant_p(x) 0 +#endif + +static inline vec_float4 _vmathVfInsert(vec_float4 dst, vec_float4 src, int slot) +{ +#ifdef __GNUC__ + if (__builtin_constant_p(slot)) { + dst = vec_sld(dst, dst, slot<<2); + dst = vec_sld(dst, src, 4); + if (slot != 3) dst = vec_sld(dst, dst, (3-slot)<<2); + return dst; + } else +#endif + { + vec_uchar16 shiftpattern = vec_lvsr( 0, (float *)(size_t)(slot<<2) ); + vec_uint4 selectmask = (vec_uint4)vec_perm( (vec_uint4){0,0,0,0}, _VECTORMATH_MASK_0xF000, shiftpattern ); + return vec_sel( dst, src, selectmask ); + } +} + +#define _vmathVfGetElement(vec, slot) ((float *)&(vec))[slot] +#ifdef _VECTORMATH_SET_CONSTS_IN_MEM +#define _vmathVfSetElement(vec, scalar, slot) ((float *)&(vec))[slot] = scalar +#else +#define _vmathVfSetElement(vec, scalar, slot) \ +{ \ + if (__builtin_constant_p(scalar)) { \ + (vec) = _vmathVfInsert(vec, (vec_float4){scalar, scalar, scalar, scalar}, slot); \ + } else { \ + ((float *)&(vec))[slot] = scalar; \ + } \ +} +#endif + +static inline vec_float4 _vmathVfSplatScalar(float scalar) +{ + vec_float4 result; + if (__builtin_constant_p(scalar)) { + result = (vec_float4){scalar, scalar, scalar, scalar}; + } else { + result = vec_ld(0, &scalar); + result = vec_splat(vec_perm(result, result, vec_lvsl(0, &scalar)), 0); + } + return result; +} + +static inline vec_uint4 _vmathVuiSplatScalar(unsigned int scalar) +{ + vec_uint4 result; + if (__builtin_constant_p(scalar)) { + result = (vec_uint4){scalar, scalar, scalar, scalar}; + } else { + result = vec_ld(0, &scalar); + result = vec_splat(vec_perm(result, result, vec_lvsl(0, &scalar)), 0); + } + return result; +} + +#endif + +namespace Vectormath { +namespace Aos { + +#ifdef _VECTORMATH_NO_SCALAR_CAST +inline VecIdx::operator floatInVec() const +{ + return floatInVec(ref, i); +} + +inline float VecIdx::getAsFloat() const +#else +inline VecIdx::operator float() const +#endif +{ + return _vmathVfGetElement(ref, i); +} + +inline float VecIdx::operator =( float scalar ) +{ + _vmathVfSetElement(ref, scalar, i); + return scalar; +} + +inline floatInVec VecIdx::operator =( floatInVec scalar ) +{ + ref = _vmathVfInsert(ref, scalar.get128(), i); + return scalar; +} + +inline floatInVec VecIdx::operator =( const VecIdx& scalar ) +{ + return *this = floatInVec(scalar.ref, scalar.i); +} + +inline floatInVec VecIdx::operator *=( float scalar ) +{ + return *this *= floatInVec(scalar); +} + +inline floatInVec VecIdx::operator *=( floatInVec scalar ) +{ + return *this = floatInVec(ref, i) * scalar; +} + +inline floatInVec VecIdx::operator /=( float scalar ) +{ + return *this /= floatInVec(scalar); +} + +inline floatInVec VecIdx::operator /=( floatInVec scalar ) +{ + return *this = floatInVec(ref, i) / scalar; +} + +inline floatInVec VecIdx::operator +=( float scalar ) +{ + return *this += floatInVec(scalar); +} + +inline floatInVec VecIdx::operator +=( floatInVec scalar ) +{ + return *this = floatInVec(ref, i) + scalar; +} + +inline floatInVec VecIdx::operator -=( float scalar ) +{ + return *this -= floatInVec(scalar); +} + +inline floatInVec VecIdx::operator -=( floatInVec scalar ) +{ + return *this = floatInVec(ref, i) - scalar; +} + +inline Vector3::Vector3( float _x, float _y, float _z ) +{ + if (__builtin_constant_p(_x) & __builtin_constant_p(_y) & __builtin_constant_p(_z)) { + mVec128 = (vec_float4){_x, _y, _z, 0.0f}; + } else { + float *pf = (float *)&mVec128; + pf[0] = _x; + pf[1] = _y; + pf[2] = _z; + } +} + +inline Vector3::Vector3( floatInVec _x, floatInVec _y, floatInVec _z ) +{ + vec_float4 xz = vec_mergeh( _x.get128(), _z.get128() ); + mVec128 = vec_mergeh( xz, _y.get128() ); +} + +inline Vector3::Vector3( Point3 pnt ) +{ + mVec128 = pnt.get128(); +} + +inline Vector3::Vector3( float scalar ) +{ + mVec128 = floatInVec(scalar).get128(); +} + +inline Vector3::Vector3( floatInVec scalar ) +{ + mVec128 = scalar.get128(); +} + +inline Vector3::Vector3( vec_float4 vf4 ) +{ + mVec128 = vf4; +} + +inline const Vector3 Vector3::xAxis( ) +{ + return Vector3( _VECTORMATH_UNIT_1000 ); +} + +inline const Vector3 Vector3::yAxis( ) +{ + return Vector3( _VECTORMATH_UNIT_0100 ); +} + +inline const Vector3 Vector3::zAxis( ) +{ + return Vector3( _VECTORMATH_UNIT_0010 ); +} + +inline const Vector3 lerp( float t, Vector3 vec0, Vector3 vec1 ) +{ + return lerp( floatInVec(t), vec0, vec1 ); +} + +inline const Vector3 lerp( floatInVec t, Vector3 vec0, Vector3 vec1 ) +{ + return ( vec0 + ( ( vec1 - vec0 ) * t ) ); +} + +inline const Vector3 slerp( float t, Vector3 unitVec0, Vector3 unitVec1 ) +{ + return slerp( floatInVec(t), unitVec0, unitVec1 ); +} + +inline const Vector3 slerp( floatInVec t, Vector3 unitVec0, Vector3 unitVec1 ) +{ + vec_float4 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines; + vec_uint4 selectMask; + cosAngle = _vmathVfDot3( unitVec0.get128(), unitVec1.get128() ); + cosAngle = vec_splat( cosAngle, 0 ); + selectMask = (vec_uint4)vec_cmpgt( ((vec_float4){_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL}), cosAngle ); + angle = acosf4( cosAngle ); + tttt = t.get128(); + oneMinusT = vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), tttt ); + angles = vec_mergeh( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), tttt ); + angles = vec_mergeh( angles, oneMinusT ); + angles = vec_madd( angles, angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + sines = sinf4( angles ); + scales = divf4( sines, vec_splat( sines, 0 ) ); + scale0 = vec_sel( oneMinusT, vec_splat( scales, 1 ), selectMask ); + scale1 = vec_sel( tttt, vec_splat( scales, 2 ), selectMask ); + return Vector3( vec_madd( unitVec0.get128(), scale0, vec_madd( unitVec1.get128(), scale1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ); +} + +inline vec_float4 Vector3::get128( ) const +{ + return mVec128; +} + +inline void storeXYZ( Vector3 vec, vec_float4 * quad ) +{ + vec_float4 dstVec = *quad; + vec_uint4 mask = _VECTORMATH_MASK_0x000F; + dstVec = vec_sel(vec.get128(), dstVec, mask); + *quad = dstVec; +} + +inline void loadXYZArray( Vector3 & vec0, Vector3 & vec1, Vector3 & vec2, Vector3 & vec3, const vec_float4 * threeQuads ) +{ + vec_float4 xyzx, yzxy, zxyz, xyz1, xyz2, xyz3; + xyzx = threeQuads[0]; + yzxy = threeQuads[1]; + zxyz = threeQuads[2]; + xyz1 = vec_sld( xyzx, yzxy, 12 ); + xyz2 = vec_sld( yzxy, zxyz, 8 ); + xyz3 = vec_sld( zxyz, zxyz, 4 ); + vec0 = Vector3( xyzx ); + vec1 = Vector3( xyz1 ); + vec2 = Vector3( xyz2 ); + vec3 = Vector3( xyz3 ); +} + +inline void storeXYZArray( Vector3 vec0, Vector3 vec1, Vector3 vec2, Vector3 vec3, vec_float4 * threeQuads ) +{ + vec_float4 xyzx, yzxy, zxyz; + xyzx = vec_perm( vec0.get128(), vec1.get128(), _VECTORMATH_PERM_XYZA ); + yzxy = vec_perm( vec1.get128(), vec2.get128(), _VECTORMATH_PERM_YZAB ); + zxyz = vec_perm( vec2.get128(), vec3.get128(), _VECTORMATH_PERM_ZABC ); + threeQuads[0] = xyzx; + threeQuads[1] = yzxy; + threeQuads[2] = zxyz; +} + +inline void storeHalfFloats( Vector3 vec0, Vector3 vec1, Vector3 vec2, Vector3 vec3, Vector3 vec4, Vector3 vec5, Vector3 vec6, Vector3 vec7, vec_ushort8 * threeQuads ) +{ + vec_float4 xyz0[3]; + vec_float4 xyz1[3]; + storeXYZArray( vec0, vec1, vec2, vec3, xyz0 ); + storeXYZArray( vec4, vec5, vec6, vec7, xyz1 ); + threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); + threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); + threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); +} + +inline Vector3 & Vector3::operator =( Vector3 vec ) +{ + mVec128 = vec.mVec128; + return *this; +} + +inline Vector3 & Vector3::setX( float _x ) +{ + _vmathVfSetElement(mVec128, _x, 0); + return *this; +} + +inline Vector3 & Vector3::setX( floatInVec _x ) +{ + mVec128 = _vmathVfInsert(mVec128, _x.get128(), 0); + return *this; +} + +inline const floatInVec Vector3::getX( ) const +{ + return floatInVec( mVec128, 0 ); +} + +inline Vector3 & Vector3::setY( float _y ) +{ + _vmathVfSetElement(mVec128, _y, 1); + return *this; +} + +inline Vector3 & Vector3::setY( floatInVec _y ) +{ + mVec128 = _vmathVfInsert(mVec128, _y.get128(), 1); + return *this; +} + +inline const floatInVec Vector3::getY( ) const +{ + return floatInVec( mVec128, 1 ); +} + +inline Vector3 & Vector3::setZ( float _z ) +{ + _vmathVfSetElement(mVec128, _z, 2); + return *this; +} + +inline Vector3 & Vector3::setZ( floatInVec _z ) +{ + mVec128 = _vmathVfInsert(mVec128, _z.get128(), 2); + return *this; +} + +inline const floatInVec Vector3::getZ( ) const +{ + return floatInVec( mVec128, 2 ); +} + +inline Vector3 & Vector3::setElem( int idx, float value ) +{ + _vmathVfSetElement(mVec128, value, idx); + return *this; +} + +inline Vector3 & Vector3::setElem( int idx, floatInVec value ) +{ + mVec128 = _vmathVfInsert(mVec128, value.get128(), idx); + return *this; +} + +inline const floatInVec Vector3::getElem( int idx ) const +{ + return floatInVec( mVec128, idx ); +} + +inline VecIdx Vector3::operator []( int idx ) +{ + return VecIdx( mVec128, idx ); +} + +inline const floatInVec Vector3::operator []( int idx ) const +{ + return floatInVec( mVec128, idx ); +} + +inline const Vector3 Vector3::operator +( Vector3 vec ) const +{ + return Vector3( vec_add( mVec128, vec.mVec128 ) ); +} + +inline const Vector3 Vector3::operator -( Vector3 vec ) const +{ + return Vector3( vec_sub( mVec128, vec.mVec128 ) ); +} + +inline const Point3 Vector3::operator +( Point3 pnt ) const +{ + return Point3( vec_add( mVec128, pnt.get128() ) ); +} + +inline const Vector3 Vector3::operator *( float scalar ) const +{ + return *this * floatInVec(scalar); +} + +inline const Vector3 Vector3::operator *( floatInVec scalar ) const +{ + return Vector3( vec_madd( mVec128, scalar.get128(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); +} + +inline Vector3 & Vector3::operator +=( Vector3 vec ) +{ + *this = *this + vec; + return *this; +} + +inline Vector3 & Vector3::operator -=( Vector3 vec ) +{ + *this = *this - vec; + return *this; +} + +inline Vector3 & Vector3::operator *=( float scalar ) +{ + *this = *this * scalar; + return *this; +} + +inline Vector3 & Vector3::operator *=( floatInVec scalar ) +{ + *this = *this * scalar; + return *this; +} + +inline const Vector3 Vector3::operator /( float scalar ) const +{ + return *this / floatInVec(scalar); +} + +inline const Vector3 Vector3::operator /( floatInVec scalar ) const +{ + return Vector3( divf4( mVec128, scalar.get128() ) ); +} + +inline Vector3 & Vector3::operator /=( float scalar ) +{ + *this = *this / scalar; + return *this; +} + +inline Vector3 & Vector3::operator /=( floatInVec scalar ) +{ + *this = *this / scalar; + return *this; +} + +inline const Vector3 Vector3::operator -( ) const +{ + return Vector3( negatef4( mVec128 ) ); +} + +inline const Vector3 operator *( float scalar, Vector3 vec ) +{ + return floatInVec(scalar) * vec; +} + +inline const Vector3 operator *( floatInVec scalar, Vector3 vec ) +{ + return vec * scalar; +} + +inline const Vector3 mulPerElem( Vector3 vec0, Vector3 vec1 ) +{ + return Vector3( vec_madd( vec0.get128(), vec1.get128(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); +} + +inline const Vector3 divPerElem( Vector3 vec0, Vector3 vec1 ) +{ + return Vector3( divf4( vec0.get128(), vec1.get128() ) ); +} + +inline const Vector3 recipPerElem( Vector3 vec ) +{ + return Vector3( recipf4( vec.get128() ) ); +} + +inline const Vector3 sqrtPerElem( Vector3 vec ) +{ + return Vector3( sqrtf4( vec.get128() ) ); +} + +inline const Vector3 rsqrtPerElem( Vector3 vec ) +{ + return Vector3( rsqrtf4( vec.get128() ) ); +} + +inline const Vector3 absPerElem( Vector3 vec ) +{ + return Vector3( fabsf4( vec.get128() ) ); +} + +inline const Vector3 copySignPerElem( Vector3 vec0, Vector3 vec1 ) +{ + return Vector3( copysignf4( vec0.get128(), vec1.get128() ) ); +} + +inline const Vector3 maxPerElem( Vector3 vec0, Vector3 vec1 ) +{ + return Vector3( fmaxf4( vec0.get128(), vec1.get128() ) ); +} + +inline const floatInVec maxElem( Vector3 vec ) +{ + vec_float4 result; + result = fmaxf4( vec_splat( vec.get128(), 1 ), vec.get128() ); + result = fmaxf4( vec_splat( vec.get128(), 2 ), result ); + return floatInVec( result, 0 ); +} + +inline const Vector3 minPerElem( Vector3 vec0, Vector3 vec1 ) +{ + return Vector3( fminf4( vec0.get128(), vec1.get128() ) ); +} + +inline const floatInVec minElem( Vector3 vec ) +{ + vec_float4 result; + result = fminf4( vec_splat( vec.get128(), 1 ), vec.get128() ); + result = fminf4( vec_splat( vec.get128(), 2 ), result ); + return floatInVec( result, 0 ); +} + +inline const floatInVec sum( Vector3 vec ) +{ + vec_float4 result; + result = vec_add( vec_splat( vec.get128(), 1 ), vec.get128() ); + result = vec_add( vec_splat( vec.get128(), 2 ), result ); + return floatInVec( result, 0 ); +} + +inline const floatInVec dot( Vector3 vec0, Vector3 vec1 ) +{ + return floatInVec( _vmathVfDot3( vec0.get128(), vec1.get128() ), 0 ); +} + +inline const floatInVec lengthSqr( Vector3 vec ) +{ + return floatInVec( _vmathVfDot3( vec.get128(), vec.get128() ), 0 ); +} + +inline const floatInVec length( Vector3 vec ) +{ + return floatInVec( sqrtf4(_vmathVfDot3( vec.get128(), vec.get128() )), 0 ); +} + +inline const Vector3 normalize( Vector3 vec ) +{ + vec_float4 dot = _vmathVfDot3( vec.get128(), vec.get128() ); + dot = vec_splat( dot, 0 ); + return Vector3( vec_madd( vec.get128(), rsqrtf4( dot ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); +} + +inline const Vector3 cross( Vector3 vec0, Vector3 vec1 ) +{ + return Vector3( _vmathVfCross( vec0.get128(), vec1.get128() ) ); +} + +inline const Vector3 select( Vector3 vec0, Vector3 vec1, bool select1 ) +{ + return select( vec0, vec1, boolInVec(select1) ); +} + +inline const Vector3 select( Vector3 vec0, Vector3 vec1, boolInVec select1 ) +{ + return Vector3( vec_sel( vec0.get128(), vec1.get128(), select1.get128() ) ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( Vector3 vec ) +{ + union { vec_float4 v; float s[4]; } tmp; + tmp.v = vec.get128(); + printf( "( %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2] ); +} + +inline void print( Vector3 vec, const char * name ) +{ + union { vec_float4 v; float s[4]; } tmp; + tmp.v = vec.get128(); + printf( "%s: ( %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2] ); +} + +#endif + +inline Vector4::Vector4( float _x, float _y, float _z, float _w ) +{ + if (__builtin_constant_p(_x) & __builtin_constant_p(_y) & + __builtin_constant_p(_z) & __builtin_constant_p(_w)) { + mVec128 = (vec_float4){_x, _y, _z, _w}; + } else { + float *pf = (float *)&mVec128; + pf[0] = _x; + pf[1] = _y; + pf[2] = _z; + pf[3] = _w; + } +} + +inline Vector4::Vector4( floatInVec _x, floatInVec _y, floatInVec _z, floatInVec _w ) +{ + vec_float4 xz = vec_mergeh( _x.get128(), _z.get128() ); + vec_float4 yw = vec_mergeh( _y.get128(), _w.get128() ); + mVec128 = vec_mergeh( xz, yw ); +} + +inline Vector4::Vector4( Vector3 xyz, float _w ) +{ + mVec128 = xyz.get128(); + _vmathVfSetElement(mVec128, _w, 3); +} + +inline Vector4::Vector4( Vector3 xyz, floatInVec _w ) +{ + mVec128 = xyz.get128(); + mVec128 = _vmathVfInsert(mVec128, _w.get128(), 3); +} + +inline Vector4::Vector4( Vector3 vec ) +{ + mVec128 = vec.get128(); + mVec128 = _vmathVfInsert(mVec128, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), 3); +} + +inline Vector4::Vector4( Point3 pnt ) +{ + mVec128 = pnt.get128(); + mVec128 = _vmathVfInsert(mVec128, ((vec_float4){1.0f,1.0f,1.0f,1.0f}), 3); +} + +inline Vector4::Vector4( Quat quat ) +{ + mVec128 = quat.get128(); +} + +inline Vector4::Vector4( float scalar ) +{ + mVec128 = floatInVec(scalar).get128(); +} + +inline Vector4::Vector4( floatInVec scalar ) +{ + mVec128 = scalar.get128(); +} + +inline Vector4::Vector4( vec_float4 vf4 ) +{ + mVec128 = vf4; +} + +inline const Vector4 Vector4::xAxis( ) +{ + return Vector4( _VECTORMATH_UNIT_1000 ); +} + +inline const Vector4 Vector4::yAxis( ) +{ + return Vector4( _VECTORMATH_UNIT_0100 ); +} + +inline const Vector4 Vector4::zAxis( ) +{ + return Vector4( _VECTORMATH_UNIT_0010 ); +} + +inline const Vector4 Vector4::wAxis( ) +{ + return Vector4( _VECTORMATH_UNIT_0001 ); +} + +inline const Vector4 lerp( float t, Vector4 vec0, Vector4 vec1 ) +{ + return lerp( floatInVec(t), vec0, vec1 ); +} + +inline const Vector4 lerp( floatInVec t, Vector4 vec0, Vector4 vec1 ) +{ + return ( vec0 + ( ( vec1 - vec0 ) * t ) ); +} + +inline const Vector4 slerp( float t, Vector4 unitVec0, Vector4 unitVec1 ) +{ + return slerp( floatInVec(t), unitVec0, unitVec1 ); +} + +inline const Vector4 slerp( floatInVec t, Vector4 unitVec0, Vector4 unitVec1 ) +{ + vec_float4 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines; + vec_uint4 selectMask; + cosAngle = _vmathVfDot4( unitVec0.get128(), unitVec1.get128() ); + cosAngle = vec_splat( cosAngle, 0 ); + selectMask = (vec_uint4)vec_cmpgt( ((vec_float4){_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL}), cosAngle ); + angle = acosf4( cosAngle ); + tttt = t.get128(); + oneMinusT = vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), tttt ); + angles = vec_mergeh( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), tttt ); + angles = vec_mergeh( angles, oneMinusT ); + angles = vec_madd( angles, angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + sines = sinf4( angles ); + scales = divf4( sines, vec_splat( sines, 0 ) ); + scale0 = vec_sel( oneMinusT, vec_splat( scales, 1 ), selectMask ); + scale1 = vec_sel( tttt, vec_splat( scales, 2 ), selectMask ); + return Vector4( vec_madd( unitVec0.get128(), scale0, vec_madd( unitVec1.get128(), scale1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ); +} + +inline vec_float4 Vector4::get128( ) const +{ + return mVec128; +} + +inline void storeHalfFloats( Vector4 vec0, Vector4 vec1, Vector4 vec2, Vector4 vec3, vec_ushort8 * twoQuads ) +{ + twoQuads[0] = _vmath2VfToHalfFloats(vec0.get128(), vec1.get128()); + twoQuads[1] = _vmath2VfToHalfFloats(vec2.get128(), vec3.get128()); +} + +inline Vector4 & Vector4::operator =( Vector4 vec ) +{ + mVec128 = vec.mVec128; + return *this; +} + +inline Vector4 & Vector4::setXYZ( Vector3 vec ) +{ + mVec128 = vec_sel( vec.get128(), mVec128, _VECTORMATH_MASK_0x000F ); + return *this; +} + +inline const Vector3 Vector4::getXYZ( ) const +{ + return Vector3( mVec128 ); +} + +inline Vector4 & Vector4::setX( float _x ) +{ + _vmathVfSetElement(mVec128, _x, 0); + return *this; +} + +inline Vector4 & Vector4::setX( floatInVec _x ) +{ + mVec128 = _vmathVfInsert(mVec128, _x.get128(), 0); + return *this; +} + +inline const floatInVec Vector4::getX( ) const +{ + return floatInVec( mVec128, 0 ); +} + +inline Vector4 & Vector4::setY( float _y ) +{ + _vmathVfSetElement(mVec128, _y, 1); + return *this; +} + +inline Vector4 & Vector4::setY( floatInVec _y ) +{ + mVec128 = _vmathVfInsert(mVec128, _y.get128(), 1); + return *this; +} + +inline const floatInVec Vector4::getY( ) const +{ + return floatInVec( mVec128, 1 ); +} + +inline Vector4 & Vector4::setZ( float _z ) +{ + _vmathVfSetElement(mVec128, _z, 2); + return *this; +} + +inline Vector4 & Vector4::setZ( floatInVec _z ) +{ + mVec128 = _vmathVfInsert(mVec128, _z.get128(), 2); + return *this; +} + +inline const floatInVec Vector4::getZ( ) const +{ + return floatInVec( mVec128, 2 ); +} + +inline Vector4 & Vector4::setW( float _w ) +{ + _vmathVfSetElement(mVec128, _w, 3); + return *this; +} + +inline Vector4 & Vector4::setW( floatInVec _w ) +{ + mVec128 = _vmathVfInsert(mVec128, _w.get128(), 3); + return *this; +} + +inline const floatInVec Vector4::getW( ) const +{ + return floatInVec( mVec128, 3 ); +} + +inline Vector4 & Vector4::setElem( int idx, float value ) +{ + _vmathVfSetElement(mVec128, value, idx); + return *this; +} + +inline Vector4 & Vector4::setElem( int idx, floatInVec value ) +{ + mVec128 = _vmathVfInsert(mVec128, value.get128(), idx); + return *this; +} + +inline const floatInVec Vector4::getElem( int idx ) const +{ + return floatInVec( mVec128, idx ); +} + +inline VecIdx Vector4::operator []( int idx ) +{ + return VecIdx( mVec128, idx ); +} + +inline const floatInVec Vector4::operator []( int idx ) const +{ + return floatInVec( mVec128, idx ); +} + +inline const Vector4 Vector4::operator +( Vector4 vec ) const +{ + return Vector4( vec_add( mVec128, vec.mVec128 ) ); +} + +inline const Vector4 Vector4::operator -( Vector4 vec ) const +{ + return Vector4( vec_sub( mVec128, vec.mVec128 ) ); +} + +inline const Vector4 Vector4::operator *( float scalar ) const +{ + return *this * floatInVec(scalar); +} + +inline const Vector4 Vector4::operator *( floatInVec scalar ) const +{ + return Vector4( vec_madd( mVec128, scalar.get128(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); +} + +inline Vector4 & Vector4::operator +=( Vector4 vec ) +{ + *this = *this + vec; + return *this; +} + +inline Vector4 & Vector4::operator -=( Vector4 vec ) +{ + *this = *this - vec; + return *this; +} + +inline Vector4 & Vector4::operator *=( float scalar ) +{ + *this = *this * scalar; + return *this; +} + +inline Vector4 & Vector4::operator *=( floatInVec scalar ) +{ + *this = *this * scalar; + return *this; +} + +inline const Vector4 Vector4::operator /( float scalar ) const +{ + return *this / floatInVec(scalar); +} + +inline const Vector4 Vector4::operator /( floatInVec scalar ) const +{ + return Vector4( divf4( mVec128, scalar.get128() ) ); +} + +inline Vector4 & Vector4::operator /=( float scalar ) +{ + *this = *this / scalar; + return *this; +} + +inline Vector4 & Vector4::operator /=( floatInVec scalar ) +{ + *this = *this / scalar; + return *this; +} + +inline const Vector4 Vector4::operator -( ) const +{ + return Vector4( negatef4( mVec128 ) ); +} + +inline const Vector4 operator *( float scalar, Vector4 vec ) +{ + return floatInVec(scalar) * vec; +} + +inline const Vector4 operator *( floatInVec scalar, Vector4 vec ) +{ + return vec * scalar; +} + +inline const Vector4 mulPerElem( Vector4 vec0, Vector4 vec1 ) +{ + return Vector4( vec_madd( vec0.get128(), vec1.get128(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); +} + +inline const Vector4 divPerElem( Vector4 vec0, Vector4 vec1 ) +{ + return Vector4( divf4( vec0.get128(), vec1.get128() ) ); +} + +inline const Vector4 recipPerElem( Vector4 vec ) +{ + return Vector4( recipf4( vec.get128() ) ); +} + +inline const Vector4 sqrtPerElem( Vector4 vec ) +{ + return Vector4( sqrtf4( vec.get128() ) ); +} + +inline const Vector4 rsqrtPerElem( Vector4 vec ) +{ + return Vector4( rsqrtf4( vec.get128() ) ); +} + +inline const Vector4 absPerElem( Vector4 vec ) +{ + return Vector4( fabsf4( vec.get128() ) ); +} + +inline const Vector4 copySignPerElem( Vector4 vec0, Vector4 vec1 ) +{ + return Vector4( copysignf4( vec0.get128(), vec1.get128() ) ); +} + +inline const Vector4 maxPerElem( Vector4 vec0, Vector4 vec1 ) +{ + return Vector4( fmaxf4( vec0.get128(), vec1.get128() ) ); +} + +inline const floatInVec maxElem( Vector4 vec ) +{ + vec_float4 result; + result = fmaxf4( vec_splat( vec.get128(), 1 ), vec.get128() ); + result = fmaxf4( vec_splat( vec.get128(), 2 ), result ); + result = fmaxf4( vec_splat( vec.get128(), 3 ), result ); + return floatInVec( result, 0 ); +} + +inline const Vector4 minPerElem( Vector4 vec0, Vector4 vec1 ) +{ + return Vector4( fminf4( vec0.get128(), vec1.get128() ) ); +} + +inline const floatInVec minElem( Vector4 vec ) +{ + vec_float4 result; + result = fminf4( vec_splat( vec.get128(), 1 ), vec.get128() ); + result = fminf4( vec_splat( vec.get128(), 2 ), result ); + result = fminf4( vec_splat( vec.get128(), 3 ), result ); + return floatInVec( result, 0 ); +} + +inline const floatInVec sum( Vector4 vec ) +{ + vec_float4 result; + result = vec_add( vec_splat( vec.get128(), 1 ), vec.get128() ); + result = vec_add( vec_splat( vec.get128(), 2 ), result ); + result = vec_add( vec_splat( vec.get128(), 3 ), result ); + return floatInVec( result, 0 ); +} + +inline const floatInVec dot( Vector4 vec0, Vector4 vec1 ) +{ + return floatInVec( _vmathVfDot4( vec0.get128(), vec1.get128() ), 0 ); +} + +inline const floatInVec lengthSqr( Vector4 vec ) +{ + return floatInVec( _vmathVfDot4( vec.get128(), vec.get128() ), 0 ); +} + +inline const floatInVec length( Vector4 vec ) +{ + return floatInVec( sqrtf4(_vmathVfDot4( vec.get128(), vec.get128() )), 0 ); +} + +inline const Vector4 normalize( Vector4 vec ) +{ + vec_float4 dot = _vmathVfDot4( vec.get128(), vec.get128() ); + return Vector4( vec_madd( vec.get128(), rsqrtf4( dot ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); +} + +inline const Vector4 select( Vector4 vec0, Vector4 vec1, bool select1 ) +{ + return select( vec0, vec1, boolInVec(select1) ); +} + +inline const Vector4 select( Vector4 vec0, Vector4 vec1, boolInVec select1 ) +{ + return Vector4( vec_sel( vec0.get128(), vec1.get128(), select1.get128() ) ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( Vector4 vec ) +{ + union { vec_float4 v; float s[4]; } tmp; + tmp.v = vec.get128(); + printf( "( %f %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] ); +} + +inline void print( Vector4 vec, const char * name ) +{ + union { vec_float4 v; float s[4]; } tmp; + tmp.v = vec.get128(); + printf( "%s: ( %f %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] ); +} + +#endif + +inline Point3::Point3( float _x, float _y, float _z ) +{ + if (__builtin_constant_p(_x) & __builtin_constant_p(_y) & __builtin_constant_p(_z)) { + mVec128 = (vec_float4){_x, _y, _z, 0.0f}; + } else { + float *pf = (float *)&mVec128; + pf[0] = _x; + pf[1] = _y; + pf[2] = _z; + } +} + +inline Point3::Point3( floatInVec _x, floatInVec _y, floatInVec _z ) +{ + vec_float4 xz = vec_mergeh( _x.get128(), _z.get128() ); + mVec128 = vec_mergeh( xz, _y.get128() ); +} + +inline Point3::Point3( Vector3 vec ) +{ + mVec128 = vec.get128(); +} + +inline Point3::Point3( float scalar ) +{ + mVec128 = floatInVec(scalar).get128(); +} + +inline Point3::Point3( floatInVec scalar ) +{ + mVec128 = scalar.get128(); +} + +inline Point3::Point3( vec_float4 vf4 ) +{ + mVec128 = vf4; +} + +inline const Point3 lerp( float t, Point3 pnt0, Point3 pnt1 ) +{ + return lerp( floatInVec(t), pnt0, pnt1 ); +} + +inline const Point3 lerp( floatInVec t, Point3 pnt0, Point3 pnt1 ) +{ + return ( pnt0 + ( ( pnt1 - pnt0 ) * t ) ); +} + +inline vec_float4 Point3::get128( ) const +{ + return mVec128; +} + +inline void storeXYZ( Point3 pnt, vec_float4 * quad ) +{ + vec_float4 dstVec = *quad; + vec_uint4 mask = _VECTORMATH_MASK_0x000F; + dstVec = vec_sel(pnt.get128(), dstVec, mask); + *quad = dstVec; +} + +inline void loadXYZArray( Point3 & pnt0, Point3 & pnt1, Point3 & pnt2, Point3 & pnt3, const vec_float4 * threeQuads ) +{ + vec_float4 xyzx, yzxy, zxyz, xyz1, xyz2, xyz3; + xyzx = threeQuads[0]; + yzxy = threeQuads[1]; + zxyz = threeQuads[2]; + xyz1 = vec_sld( xyzx, yzxy, 12 ); + xyz2 = vec_sld( yzxy, zxyz, 8 ); + xyz3 = vec_sld( zxyz, zxyz, 4 ); + pnt0 = Point3( xyzx ); + pnt1 = Point3( xyz1 ); + pnt2 = Point3( xyz2 ); + pnt3 = Point3( xyz3 ); +} + +inline void storeXYZArray( Point3 pnt0, Point3 pnt1, Point3 pnt2, Point3 pnt3, vec_float4 * threeQuads ) +{ + vec_float4 xyzx, yzxy, zxyz; + xyzx = vec_perm( pnt0.get128(), pnt1.get128(), _VECTORMATH_PERM_XYZA ); + yzxy = vec_perm( pnt1.get128(), pnt2.get128(), _VECTORMATH_PERM_YZAB ); + zxyz = vec_perm( pnt2.get128(), pnt3.get128(), _VECTORMATH_PERM_ZABC ); + threeQuads[0] = xyzx; + threeQuads[1] = yzxy; + threeQuads[2] = zxyz; +} + +inline void storeHalfFloats( Point3 pnt0, Point3 pnt1, Point3 pnt2, Point3 pnt3, Point3 pnt4, Point3 pnt5, Point3 pnt6, Point3 pnt7, vec_ushort8 * threeQuads ) +{ + vec_float4 xyz0[3]; + vec_float4 xyz1[3]; + storeXYZArray( pnt0, pnt1, pnt2, pnt3, xyz0 ); + storeXYZArray( pnt4, pnt5, pnt6, pnt7, xyz1 ); + threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); + threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); + threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); +} + +inline Point3 & Point3::operator =( Point3 pnt ) +{ + mVec128 = pnt.mVec128; + return *this; +} + +inline Point3 & Point3::setX( float _x ) +{ + _vmathVfSetElement(mVec128, _x, 0); + return *this; +} + +inline Point3 & Point3::setX( floatInVec _x ) +{ + mVec128 = _vmathVfInsert(mVec128, _x.get128(), 0); + return *this; +} + +inline const floatInVec Point3::getX( ) const +{ + return floatInVec( mVec128, 0 ); +} + +inline Point3 & Point3::setY( float _y ) +{ + _vmathVfSetElement(mVec128, _y, 1); + return *this; +} + +inline Point3 & Point3::setY( floatInVec _y ) +{ + mVec128 = _vmathVfInsert(mVec128, _y.get128(), 1); + return *this; +} + +inline const floatInVec Point3::getY( ) const +{ + return floatInVec( mVec128, 1 ); +} + +inline Point3 & Point3::setZ( float _z ) +{ + _vmathVfSetElement(mVec128, _z, 2); + return *this; +} + +inline Point3 & Point3::setZ( floatInVec _z ) +{ + mVec128 = _vmathVfInsert(mVec128, _z.get128(), 2); + return *this; +} + +inline const floatInVec Point3::getZ( ) const +{ + return floatInVec( mVec128, 2 ); +} + +inline Point3 & Point3::setElem( int idx, float value ) +{ + _vmathVfSetElement(mVec128, value, idx); + return *this; +} + +inline Point3 & Point3::setElem( int idx, floatInVec value ) +{ + mVec128 = _vmathVfInsert(mVec128, value.get128(), idx); + return *this; +} + +inline const floatInVec Point3::getElem( int idx ) const +{ + return floatInVec( mVec128, idx ); +} + +inline VecIdx Point3::operator []( int idx ) +{ + return VecIdx( mVec128, idx ); +} + +inline const floatInVec Point3::operator []( int idx ) const +{ + return floatInVec( mVec128, idx ); +} + +inline const Vector3 Point3::operator -( Point3 pnt ) const +{ + return Vector3( vec_sub( mVec128, pnt.mVec128 ) ); +} + +inline const Point3 Point3::operator +( Vector3 vec ) const +{ + return Point3( vec_add( mVec128, vec.get128() ) ); +} + +inline const Point3 Point3::operator -( Vector3 vec ) const +{ + return Point3( vec_sub( mVec128, vec.get128() ) ); +} + +inline Point3 & Point3::operator +=( Vector3 vec ) +{ + *this = *this + vec; + return *this; +} + +inline Point3 & Point3::operator -=( Vector3 vec ) +{ + *this = *this - vec; + return *this; +} + +inline const Point3 mulPerElem( Point3 pnt0, Point3 pnt1 ) +{ + return Point3( vec_madd( pnt0.get128(), pnt1.get128(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); +} + +inline const Point3 divPerElem( Point3 pnt0, Point3 pnt1 ) +{ + return Point3( divf4( pnt0.get128(), pnt1.get128() ) ); +} + +inline const Point3 recipPerElem( Point3 pnt ) +{ + return Point3( recipf4( pnt.get128() ) ); +} + +inline const Point3 sqrtPerElem( Point3 pnt ) +{ + return Point3( sqrtf4( pnt.get128() ) ); +} + +inline const Point3 rsqrtPerElem( Point3 pnt ) +{ + return Point3( rsqrtf4( pnt.get128() ) ); +} + +inline const Point3 absPerElem( Point3 pnt ) +{ + return Point3( fabsf4( pnt.get128() ) ); +} + +inline const Point3 copySignPerElem( Point3 pnt0, Point3 pnt1 ) +{ + return Point3( copysignf4( pnt0.get128(), pnt1.get128() ) ); +} + +inline const Point3 maxPerElem( Point3 pnt0, Point3 pnt1 ) +{ + return Point3( fmaxf4( pnt0.get128(), pnt1.get128() ) ); +} + +inline const floatInVec maxElem( Point3 pnt ) +{ + vec_float4 result; + result = fmaxf4( vec_splat( pnt.get128(), 1 ), pnt.get128() ); + result = fmaxf4( vec_splat( pnt.get128(), 2 ), result ); + return floatInVec( result, 0 ); +} + +inline const Point3 minPerElem( Point3 pnt0, Point3 pnt1 ) +{ + return Point3( fminf4( pnt0.get128(), pnt1.get128() ) ); +} + +inline const floatInVec minElem( Point3 pnt ) +{ + vec_float4 result; + result = fminf4( vec_splat( pnt.get128(), 1 ), pnt.get128() ); + result = fminf4( vec_splat( pnt.get128(), 2 ), result ); + return floatInVec( result, 0 ); +} + +inline const floatInVec sum( Point3 pnt ) +{ + vec_float4 result; + result = vec_add( vec_splat( pnt.get128(), 1 ), pnt.get128() ); + result = vec_add( vec_splat( pnt.get128(), 2 ), result ); + return floatInVec( result, 0 ); +} + +inline const Point3 scale( Point3 pnt, float scaleVal ) +{ + return scale( pnt, floatInVec( scaleVal ) ); +} + +inline const Point3 scale( Point3 pnt, floatInVec scaleVal ) +{ + return mulPerElem( pnt, Point3( scaleVal ) ); +} + +inline const Point3 scale( Point3 pnt, Vector3 scaleVec ) +{ + return mulPerElem( pnt, Point3( scaleVec ) ); +} + +inline const floatInVec projection( Point3 pnt, Vector3 unitVec ) +{ + return floatInVec( _vmathVfDot3( pnt.get128(), unitVec.get128() ), 0 ); +} + +inline const floatInVec distSqrFromOrigin( Point3 pnt ) +{ + return lengthSqr( Vector3( pnt ) ); +} + +inline const floatInVec distFromOrigin( Point3 pnt ) +{ + return length( Vector3( pnt ) ); +} + +inline const floatInVec distSqr( Point3 pnt0, Point3 pnt1 ) +{ + return lengthSqr( ( pnt1 - pnt0 ) ); +} + +inline const floatInVec dist( Point3 pnt0, Point3 pnt1 ) +{ + return length( ( pnt1 - pnt0 ) ); +} + +inline const Point3 select( Point3 pnt0, Point3 pnt1, bool select1 ) +{ + return select( pnt0, pnt1, boolInVec(select1) ); +} + +inline const Point3 select( Point3 pnt0, Point3 pnt1, boolInVec select1 ) +{ + return Point3( vec_sel( pnt0.get128(), pnt1.get128(), select1.get128() ) ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( Point3 pnt ) +{ + union { vec_float4 v; float s[4]; } tmp; + tmp.v = pnt.get128(); + printf( "( %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2] ); +} + +inline void print( Point3 pnt, const char * name ) +{ + union { vec_float4 v; float s[4]; } tmp; + tmp.v = pnt.get128(); + printf( "%s: ( %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2] ); +} + +#endif + +} // namespace Aos +} // namespace Vectormath + +#endif diff --git a/vectormathlibrary/include/vectormath/ppu/cpp/vec_soa.h b/vectormathlibrary/include/vectormath/ppu/cpp/vec_soa.h new file mode 100644 index 000000000..89fdfcf7f --- /dev/null +++ b/vectormathlibrary/include/vectormath/ppu/cpp/vec_soa.h @@ -0,0 +1,1425 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_VEC_SOA_CPP_H +#define _VECTORMATH_VEC_SOA_CPP_H +//----------------------------------------------------------------------------- +// Constants +// for permutes, words are labeled [x,y,z,w] [a,b,c,d] + +#define _VECTORMATH_PERM_X 0x00010203 +#define _VECTORMATH_PERM_Y 0x04050607 +#define _VECTORMATH_PERM_Z 0x08090a0b +#define _VECTORMATH_PERM_W 0x0c0d0e0f +#define _VECTORMATH_PERM_A 0x10111213 +#define _VECTORMATH_PERM_B 0x14151617 +#define _VECTORMATH_PERM_C 0x18191a1b +#define _VECTORMATH_PERM_D 0x1c1d1e1f +#define _VECTORMATH_PERM_ZBWX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B, _VECTORMATH_PERM_W, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_XCYX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_C, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_ZDWX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_D, _VECTORMATH_PERM_W, _VECTORMATH_PERM_X }) +#define _VECTORMATH_PERM_ZCXA ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_C, _VECTORMATH_PERM_X, _VECTORMATH_PERM_A }) +#define _VECTORMATH_PERM_XBZD ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_B, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_D }) +#define _VECTORMATH_PERM_WDYB ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_W, _VECTORMATH_PERM_D, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_B }) +#define _VECTORMATH_PERM_ZBXD ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B, _VECTORMATH_PERM_X, _VECTORMATH_PERM_D }) +#define _VECTORMATH_PERM_WCYA ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_W, _VECTORMATH_PERM_C, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A }) +#define _VECTORMATH_PERM_XDZB ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_D, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B }) +#define _VECTORMATH_SLERP_TOL 0.999f + +//----------------------------------------------------------------------------- +// Definitions + +#ifndef _VECTORMATH_INTERNAL_FUNCTIONS +#define _VECTORMATH_INTERNAL_FUNCTIONS + +#endif + +namespace Vectormath { +namespace Soa { + +inline Vector3::Vector3( const Vector3 & vec ) +{ + mX = vec.mX; + mY = vec.mY; + mZ = vec.mZ; +} + +inline Vector3::Vector3( vec_float4 _x, vec_float4 _y, vec_float4 _z ) +{ + mX = _x; + mY = _y; + mZ = _z; +} + +inline Vector3::Vector3( const Point3 & pnt ) +{ + mX = pnt.getX(); + mY = pnt.getY(); + mZ = pnt.getZ(); +} + +inline Vector3::Vector3( vec_float4 scalar ) +{ + mX = scalar; + mY = scalar; + mZ = scalar; +} + +inline Vector3::Vector3( Aos::Vector3 vec ) +{ + vec_float4 vec128 = vec.get128(); + mX = vec_splat( vec128, 0 ); + mY = vec_splat( vec128, 1 ); + mZ = vec_splat( vec128, 2 ); +} + +inline Vector3::Vector3( Aos::Vector3 vec0, Aos::Vector3 vec1, Aos::Vector3 vec2, Aos::Vector3 vec3 ) +{ + vec_float4 tmp0, tmp1, tmp2, tmp3; + tmp0 = vec_mergeh( vec0.get128(), vec2.get128() ); + tmp1 = vec_mergeh( vec1.get128(), vec3.get128() ); + tmp2 = vec_mergel( vec0.get128(), vec2.get128() ); + tmp3 = vec_mergel( vec1.get128(), vec3.get128() ); + mX = vec_mergeh( tmp0, tmp1 ); + mY = vec_mergel( tmp0, tmp1 ); + mZ = vec_mergeh( tmp2, tmp3 ); +} + +inline const Vector3 Vector3::xAxis( ) +{ + return Vector3( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); +} + +inline const Vector3 Vector3::yAxis( ) +{ + return Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){1.0f,1.0f,1.0f,1.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); +} + +inline const Vector3 Vector3::zAxis( ) +{ + return Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); +} + +inline const Vector3 lerp( vec_float4 t, const Vector3 & vec0, const Vector3 & vec1 ) +{ + return ( vec0 + ( ( vec1 - vec0 ) * t ) ); +} + +inline const Vector3 slerp( vec_float4 t, const Vector3 & unitVec0, const Vector3 & unitVec1 ) +{ + vec_float4 recipSinAngle, scale0, scale1, cosAngle, angle; + vec_uint4 selectMask; + cosAngle = dot( unitVec0, unitVec1 ); + selectMask = (vec_uint4)vec_cmpgt( (vec_float4){_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL}, cosAngle ); + angle = acosf4( cosAngle ); + recipSinAngle = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sinf4( angle ) ); + scale0 = vec_sel( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), vec_madd( sinf4( vec_madd( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), recipSinAngle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), selectMask ); + scale1 = vec_sel( t, vec_madd( sinf4( vec_madd( t, angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), recipSinAngle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), selectMask ); + return ( ( unitVec0 * scale0 ) + ( unitVec1 * scale1 ) ); +} + +inline void Vector3::get4Aos( Aos::Vector3 & result0, Aos::Vector3 & result1, Aos::Vector3 & result2, Aos::Vector3 & result3 ) const +{ + vec_float4 tmp0, tmp1; + tmp0 = vec_mergeh( mX, mZ ); + tmp1 = vec_mergel( mX, mZ ); + result0 = Aos::Vector3( vec_mergeh( tmp0, mY ) ); + result1 = Aos::Vector3( vec_perm( tmp0, mY, _VECTORMATH_PERM_ZBWX ) ); + result2 = Aos::Vector3( vec_perm( tmp1, mY, _VECTORMATH_PERM_XCYX ) ); + result3 = Aos::Vector3( vec_perm( tmp1, mY, _VECTORMATH_PERM_ZDWX ) ); +} + +inline void loadXYZArray( Vector3 & vec, const vec_float4 * threeQuads ) +{ + vec_float4 xyxy, yzyz, zxzx, xyzx, yzxy, zxyz; + xyzx = threeQuads[0]; + yzxy = threeQuads[1]; + zxyz = threeQuads[2]; + xyxy = vec_sld( yzxy, xyzx, 8 ); + zxzx = vec_sld( xyzx, zxyz, 8 ); + yzyz = vec_sld( zxyz, yzxy, 8 ); + vec.setX( vec_perm( xyxy, zxzx, _VECTORMATH_PERM_ZBXD ) ); + vec.setY( vec_perm( xyxy, yzyz, _VECTORMATH_PERM_WCYA ) ); + vec.setZ( vec_perm( zxzx, yzyz, _VECTORMATH_PERM_XDZB ) ); +} + +inline void storeXYZArray( const Vector3 & vec, vec_float4 * threeQuads ) +{ + vec_float4 xyzx, yzxy, zxyz, xyxy, zxzx, yzyz; + xyxy = vec_perm( vec.getX(), vec.getY(), _VECTORMATH_PERM_ZCXA ); + zxzx = vec_perm( vec.getZ(), vec.getX(), _VECTORMATH_PERM_XBZD ); + yzyz = vec_perm( vec.getY(), vec.getZ(), _VECTORMATH_PERM_WDYB ); + xyzx = vec_sld( xyxy, zxzx, 8 ); + yzxy = vec_sld( yzyz, xyxy, 8 ); + zxyz = vec_sld( zxzx, yzyz, 8 ); + threeQuads[0] = xyzx; + threeQuads[1] = yzxy; + threeQuads[2] = zxyz; +} + +inline void storeHalfFloats( const Vector3 & vec0, const Vector3 & vec1, vec_ushort8 * threeQuads ) +{ + vec_float4 xyz0[3]; + vec_float4 xyz1[3]; + storeXYZArray( vec0, xyz0 ); + storeXYZArray( vec1, xyz1 ); + threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); + threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); + threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); +} + +inline Vector3 & Vector3::operator =( const Vector3 & vec ) +{ + mX = vec.mX; + mY = vec.mY; + mZ = vec.mZ; + return *this; +} + +inline Vector3 & Vector3::setX( vec_float4 _x ) +{ + mX = _x; + return *this; +} + +inline vec_float4 Vector3::getX( ) const +{ + return mX; +} + +inline Vector3 & Vector3::setY( vec_float4 _y ) +{ + mY = _y; + return *this; +} + +inline vec_float4 Vector3::getY( ) const +{ + return mY; +} + +inline Vector3 & Vector3::setZ( vec_float4 _z ) +{ + mZ = _z; + return *this; +} + +inline vec_float4 Vector3::getZ( ) const +{ + return mZ; +} + +inline Vector3 & Vector3::setElem( int idx, vec_float4 value ) +{ + *(&mX + idx) = value; + return *this; +} + +inline vec_float4 Vector3::getElem( int idx ) const +{ + return *(&mX + idx); +} + +inline Vector3::vec_float4_t & Vector3::operator []( int idx ) +{ + return *(&mX + idx); +} + +inline vec_float4 Vector3::operator []( int idx ) const +{ + return *(&mX + idx); +} + +inline const Vector3 Vector3::operator +( const Vector3 & vec ) const +{ + return Vector3( + vec_add( mX, vec.mX ), + vec_add( mY, vec.mY ), + vec_add( mZ, vec.mZ ) + ); +} + +inline const Vector3 Vector3::operator -( const Vector3 & vec ) const +{ + return Vector3( + vec_sub( mX, vec.mX ), + vec_sub( mY, vec.mY ), + vec_sub( mZ, vec.mZ ) + ); +} + +inline const Point3 Vector3::operator +( const Point3 & pnt ) const +{ + return Point3( + vec_add( mX, pnt.getX() ), + vec_add( mY, pnt.getY() ), + vec_add( mZ, pnt.getZ() ) + ); +} + +inline const Vector3 Vector3::operator *( vec_float4 scalar ) const +{ + return Vector3( + vec_madd( mX, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + vec_madd( mY, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + vec_madd( mZ, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) + ); +} + +inline Vector3 & Vector3::operator +=( const Vector3 & vec ) +{ + *this = *this + vec; + return *this; +} + +inline Vector3 & Vector3::operator -=( const Vector3 & vec ) +{ + *this = *this - vec; + return *this; +} + +inline Vector3 & Vector3::operator *=( vec_float4 scalar ) +{ + *this = *this * scalar; + return *this; +} + +inline const Vector3 Vector3::operator /( vec_float4 scalar ) const +{ + return Vector3( + divf4( mX, scalar ), + divf4( mY, scalar ), + divf4( mZ, scalar ) + ); +} + +inline Vector3 & Vector3::operator /=( vec_float4 scalar ) +{ + *this = *this / scalar; + return *this; +} + +inline const Vector3 Vector3::operator -( ) const +{ + return Vector3( + negatef4( mX ), + negatef4( mY ), + negatef4( mZ ) + ); +} + +inline const Vector3 operator *( vec_float4 scalar, const Vector3 & vec ) +{ + return vec * scalar; +} + +inline const Vector3 mulPerElem( const Vector3 & vec0, const Vector3 & vec1 ) +{ + return Vector3( + vec_madd( vec0.getX(), vec1.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + vec_madd( vec0.getY(), vec1.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + vec_madd( vec0.getZ(), vec1.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) + ); +} + +inline const Vector3 divPerElem( const Vector3 & vec0, const Vector3 & vec1 ) +{ + return Vector3( + divf4( vec0.getX(), vec1.getX() ), + divf4( vec0.getY(), vec1.getY() ), + divf4( vec0.getZ(), vec1.getZ() ) + ); +} + +inline const Vector3 recipPerElem( const Vector3 & vec ) +{ + return Vector3( + divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec.getX() ), + divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec.getY() ), + divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec.getZ() ) + ); +} + +inline const Vector3 sqrtPerElem( const Vector3 & vec ) +{ + return Vector3( + sqrtf4( vec.getX() ), + sqrtf4( vec.getY() ), + sqrtf4( vec.getZ() ) + ); +} + +inline const Vector3 rsqrtPerElem( const Vector3 & vec ) +{ + return Vector3( + divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( vec.getX() ) ), + divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( vec.getY() ) ), + divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( vec.getZ() ) ) + ); +} + +inline const Vector3 absPerElem( const Vector3 & vec ) +{ + return Vector3( + fabsf4( vec.getX() ), + fabsf4( vec.getY() ), + fabsf4( vec.getZ() ) + ); +} + +inline const Vector3 copySignPerElem( const Vector3 & vec0, const Vector3 & vec1 ) +{ + return Vector3( + copysignf4( vec0.getX(), vec1.getX() ), + copysignf4( vec0.getY(), vec1.getY() ), + copysignf4( vec0.getZ(), vec1.getZ() ) + ); +} + +inline const Vector3 maxPerElem( const Vector3 & vec0, const Vector3 & vec1 ) +{ + return Vector3( + fmaxf4( vec0.getX(), vec1.getX() ), + fmaxf4( vec0.getY(), vec1.getY() ), + fmaxf4( vec0.getZ(), vec1.getZ() ) + ); +} + +inline vec_float4 maxElem( const Vector3 & vec ) +{ + vec_float4 result; + result = fmaxf4( vec.getX(), vec.getY() ); + result = fmaxf4( vec.getZ(), result ); + return result; +} + +inline const Vector3 minPerElem( const Vector3 & vec0, const Vector3 & vec1 ) +{ + return Vector3( + fminf4( vec0.getX(), vec1.getX() ), + fminf4( vec0.getY(), vec1.getY() ), + fminf4( vec0.getZ(), vec1.getZ() ) + ); +} + +inline vec_float4 minElem( const Vector3 & vec ) +{ + vec_float4 result; + result = fminf4( vec.getX(), vec.getY() ); + result = fminf4( vec.getZ(), result ); + return result; +} + +inline vec_float4 sum( const Vector3 & vec ) +{ + vec_float4 result; + result = vec_add( vec.getX(), vec.getY() ); + result = vec_add( result, vec.getZ() ); + return result; +} + +inline vec_float4 dot( const Vector3 & vec0, const Vector3 & vec1 ) +{ + vec_float4 result; + result = vec_madd( vec0.getX(), vec1.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + result = vec_add( result, vec_madd( vec0.getY(), vec1.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + result = vec_add( result, vec_madd( vec0.getZ(), vec1.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + return result; +} + +inline vec_float4 lengthSqr( const Vector3 & vec ) +{ + vec_float4 result; + result = vec_madd( vec.getX(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + result = vec_add( result, vec_madd( vec.getY(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + result = vec_add( result, vec_madd( vec.getZ(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + return result; +} + +inline vec_float4 length( const Vector3 & vec ) +{ + return sqrtf4( lengthSqr( vec ) ); +} + +inline const Vector3 normalize( const Vector3 & vec ) +{ + vec_float4 lenSqr, lenInv; + lenSqr = lengthSqr( vec ); + lenInv = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( lenSqr ) ); + return Vector3( + vec_madd( vec.getX(), lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + vec_madd( vec.getY(), lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + vec_madd( vec.getZ(), lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) + ); +} + +inline const Vector3 cross( const Vector3 & vec0, const Vector3 & vec1 ) +{ + return Vector3( + vec_sub( vec_madd( vec0.getY(), vec1.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( vec0.getZ(), vec1.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), + vec_sub( vec_madd( vec0.getZ(), vec1.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( vec0.getX(), vec1.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), + vec_sub( vec_madd( vec0.getX(), vec1.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( vec0.getY(), vec1.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) + ); +} + +inline const Vector3 select( const Vector3 & vec0, const Vector3 & vec1, vec_uint4 select1 ) +{ + return Vector3( + vec_sel( vec0.getX(), vec1.getX(), select1 ), + vec_sel( vec0.getY(), vec1.getY(), select1 ), + vec_sel( vec0.getZ(), vec1.getZ(), select1 ) + ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( const Vector3 & vec ) +{ + Aos::Vector3 vec0, vec1, vec2, vec3; + vec.get4Aos( vec0, vec1, vec2, vec3 ); + printf("slot 0:\n"); + print( vec0 ); + printf("slot 1:\n"); + print( vec1 ); + printf("slot 2:\n"); + print( vec2 ); + printf("slot 3:\n"); + print( vec3 ); +} + +inline void print( const Vector3 & vec, const char * name ) +{ + Aos::Vector3 vec0, vec1, vec2, vec3; + printf( "%s:\n", name ); + vec.get4Aos( vec0, vec1, vec2, vec3 ); + printf("slot 0:\n"); + print( vec0 ); + printf("slot 1:\n"); + print( vec1 ); + printf("slot 2:\n"); + print( vec2 ); + printf("slot 3:\n"); + print( vec3 ); +} + +#endif + +inline Vector4::Vector4( const Vector4 & vec ) +{ + mX = vec.mX; + mY = vec.mY; + mZ = vec.mZ; + mW = vec.mW; +} + +inline Vector4::Vector4( vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w ) +{ + mX = _x; + mY = _y; + mZ = _z; + mW = _w; +} + +inline Vector4::Vector4( const Vector3 & xyz, vec_float4 _w ) +{ + this->setXYZ( xyz ); + this->setW( _w ); +} + +inline Vector4::Vector4( const Vector3 & vec ) +{ + mX = vec.getX(); + mY = vec.getY(); + mZ = vec.getZ(); + mW = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); +} + +inline Vector4::Vector4( const Point3 & pnt ) +{ + mX = pnt.getX(); + mY = pnt.getY(); + mZ = pnt.getZ(); + mW = ((vec_float4){1.0f,1.0f,1.0f,1.0f}); +} + +inline Vector4::Vector4( const Quat & quat ) +{ + mX = quat.getX(); + mY = quat.getY(); + mZ = quat.getZ(); + mW = quat.getW(); +} + +inline Vector4::Vector4( vec_float4 scalar ) +{ + mX = scalar; + mY = scalar; + mZ = scalar; + mW = scalar; +} + +inline Vector4::Vector4( Aos::Vector4 vec ) +{ + vec_float4 vec128 = vec.get128(); + mX = vec_splat( vec128, 0 ); + mY = vec_splat( vec128, 1 ); + mZ = vec_splat( vec128, 2 ); + mW = vec_splat( vec128, 3 ); +} + +inline Vector4::Vector4( Aos::Vector4 vec0, Aos::Vector4 vec1, Aos::Vector4 vec2, Aos::Vector4 vec3 ) +{ + vec_float4 tmp0, tmp1, tmp2, tmp3; + tmp0 = vec_mergeh( vec0.get128(), vec2.get128() ); + tmp1 = vec_mergeh( vec1.get128(), vec3.get128() ); + tmp2 = vec_mergel( vec0.get128(), vec2.get128() ); + tmp3 = vec_mergel( vec1.get128(), vec3.get128() ); + mX = vec_mergeh( tmp0, tmp1 ); + mY = vec_mergel( tmp0, tmp1 ); + mZ = vec_mergeh( tmp2, tmp3 ); + mW = vec_mergel( tmp2, tmp3 ); +} + +inline const Vector4 Vector4::xAxis( ) +{ + return Vector4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); +} + +inline const Vector4 Vector4::yAxis( ) +{ + return Vector4( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){1.0f,1.0f,1.0f,1.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); +} + +inline const Vector4 Vector4::zAxis( ) +{ + return Vector4( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){1.0f,1.0f,1.0f,1.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); +} + +inline const Vector4 Vector4::wAxis( ) +{ + return Vector4( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); +} + +inline const Vector4 lerp( vec_float4 t, const Vector4 & vec0, const Vector4 & vec1 ) +{ + return ( vec0 + ( ( vec1 - vec0 ) * t ) ); +} + +inline const Vector4 slerp( vec_float4 t, const Vector4 & unitVec0, const Vector4 & unitVec1 ) +{ + vec_float4 recipSinAngle, scale0, scale1, cosAngle, angle; + vec_uint4 selectMask; + cosAngle = dot( unitVec0, unitVec1 ); + selectMask = (vec_uint4)vec_cmpgt( (vec_float4){_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL}, cosAngle ); + angle = acosf4( cosAngle ); + recipSinAngle = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sinf4( angle ) ); + scale0 = vec_sel( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), vec_madd( sinf4( vec_madd( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), recipSinAngle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), selectMask ); + scale1 = vec_sel( t, vec_madd( sinf4( vec_madd( t, angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), recipSinAngle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), selectMask ); + return ( ( unitVec0 * scale0 ) + ( unitVec1 * scale1 ) ); +} + +inline void Vector4::get4Aos( Aos::Vector4 & result0, Aos::Vector4 & result1, Aos::Vector4 & result2, Aos::Vector4 & result3 ) const +{ + vec_float4 tmp0, tmp1, tmp2, tmp3; + tmp0 = vec_mergeh( mX, mZ ); + tmp1 = vec_mergeh( mY, mW ); + tmp2 = vec_mergel( mX, mZ ); + tmp3 = vec_mergel( mY, mW ); + result0 = Aos::Vector4( vec_mergeh( tmp0, tmp1 ) ); + result1 = Aos::Vector4( vec_mergel( tmp0, tmp1 ) ); + result2 = Aos::Vector4( vec_mergeh( tmp2, tmp3 ) ); + result3 = Aos::Vector4( vec_mergel( tmp2, tmp3 ) ); +} + +inline void storeHalfFloats( const Vector4 & vec, vec_ushort8 * twoQuads ) +{ + Aos::Vector4 v0, v1, v2, v3; + vec.get4Aos( v0, v1, v2, v3 ); + twoQuads[0] = _vmath2VfToHalfFloats(v0.get128(), v1.get128()); + twoQuads[1] = _vmath2VfToHalfFloats(v2.get128(), v3.get128()); +} + +inline Vector4 & Vector4::operator =( const Vector4 & vec ) +{ + mX = vec.mX; + mY = vec.mY; + mZ = vec.mZ; + mW = vec.mW; + return *this; +} + +inline Vector4 & Vector4::setXYZ( const Vector3 & vec ) +{ + mX = vec.getX(); + mY = vec.getY(); + mZ = vec.getZ(); + return *this; +} + +inline const Vector3 Vector4::getXYZ( ) const +{ + return Vector3( mX, mY, mZ ); +} + +inline Vector4 & Vector4::setX( vec_float4 _x ) +{ + mX = _x; + return *this; +} + +inline vec_float4 Vector4::getX( ) const +{ + return mX; +} + +inline Vector4 & Vector4::setY( vec_float4 _y ) +{ + mY = _y; + return *this; +} + +inline vec_float4 Vector4::getY( ) const +{ + return mY; +} + +inline Vector4 & Vector4::setZ( vec_float4 _z ) +{ + mZ = _z; + return *this; +} + +inline vec_float4 Vector4::getZ( ) const +{ + return mZ; +} + +inline Vector4 & Vector4::setW( vec_float4 _w ) +{ + mW = _w; + return *this; +} + +inline vec_float4 Vector4::getW( ) const +{ + return mW; +} + +inline Vector4 & Vector4::setElem( int idx, vec_float4 value ) +{ + *(&mX + idx) = value; + return *this; +} + +inline vec_float4 Vector4::getElem( int idx ) const +{ + return *(&mX + idx); +} + +inline Vector4::vec_float4_t & Vector4::operator []( int idx ) +{ + return *(&mX + idx); +} + +inline vec_float4 Vector4::operator []( int idx ) const +{ + return *(&mX + idx); +} + +inline const Vector4 Vector4::operator +( const Vector4 & vec ) const +{ + return Vector4( + vec_add( mX, vec.mX ), + vec_add( mY, vec.mY ), + vec_add( mZ, vec.mZ ), + vec_add( mW, vec.mW ) + ); +} + +inline const Vector4 Vector4::operator -( const Vector4 & vec ) const +{ + return Vector4( + vec_sub( mX, vec.mX ), + vec_sub( mY, vec.mY ), + vec_sub( mZ, vec.mZ ), + vec_sub( mW, vec.mW ) + ); +} + +inline const Vector4 Vector4::operator *( vec_float4 scalar ) const +{ + return Vector4( + vec_madd( mX, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + vec_madd( mY, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + vec_madd( mZ, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + vec_madd( mW, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) + ); +} + +inline Vector4 & Vector4::operator +=( const Vector4 & vec ) +{ + *this = *this + vec; + return *this; +} + +inline Vector4 & Vector4::operator -=( const Vector4 & vec ) +{ + *this = *this - vec; + return *this; +} + +inline Vector4 & Vector4::operator *=( vec_float4 scalar ) +{ + *this = *this * scalar; + return *this; +} + +inline const Vector4 Vector4::operator /( vec_float4 scalar ) const +{ + return Vector4( + divf4( mX, scalar ), + divf4( mY, scalar ), + divf4( mZ, scalar ), + divf4( mW, scalar ) + ); +} + +inline Vector4 & Vector4::operator /=( vec_float4 scalar ) +{ + *this = *this / scalar; + return *this; +} + +inline const Vector4 Vector4::operator -( ) const +{ + return Vector4( + negatef4( mX ), + negatef4( mY ), + negatef4( mZ ), + negatef4( mW ) + ); +} + +inline const Vector4 operator *( vec_float4 scalar, const Vector4 & vec ) +{ + return vec * scalar; +} + +inline const Vector4 mulPerElem( const Vector4 & vec0, const Vector4 & vec1 ) +{ + return Vector4( + vec_madd( vec0.getX(), vec1.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + vec_madd( vec0.getY(), vec1.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + vec_madd( vec0.getZ(), vec1.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + vec_madd( vec0.getW(), vec1.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) + ); +} + +inline const Vector4 divPerElem( const Vector4 & vec0, const Vector4 & vec1 ) +{ + return Vector4( + divf4( vec0.getX(), vec1.getX() ), + divf4( vec0.getY(), vec1.getY() ), + divf4( vec0.getZ(), vec1.getZ() ), + divf4( vec0.getW(), vec1.getW() ) + ); +} + +inline const Vector4 recipPerElem( const Vector4 & vec ) +{ + return Vector4( + divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec.getX() ), + divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec.getY() ), + divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec.getZ() ), + divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec.getW() ) + ); +} + +inline const Vector4 sqrtPerElem( const Vector4 & vec ) +{ + return Vector4( + sqrtf4( vec.getX() ), + sqrtf4( vec.getY() ), + sqrtf4( vec.getZ() ), + sqrtf4( vec.getW() ) + ); +} + +inline const Vector4 rsqrtPerElem( const Vector4 & vec ) +{ + return Vector4( + divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( vec.getX() ) ), + divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( vec.getY() ) ), + divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( vec.getZ() ) ), + divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( vec.getW() ) ) + ); +} + +inline const Vector4 absPerElem( const Vector4 & vec ) +{ + return Vector4( + fabsf4( vec.getX() ), + fabsf4( vec.getY() ), + fabsf4( vec.getZ() ), + fabsf4( vec.getW() ) + ); +} + +inline const Vector4 copySignPerElem( const Vector4 & vec0, const Vector4 & vec1 ) +{ + return Vector4( + copysignf4( vec0.getX(), vec1.getX() ), + copysignf4( vec0.getY(), vec1.getY() ), + copysignf4( vec0.getZ(), vec1.getZ() ), + copysignf4( vec0.getW(), vec1.getW() ) + ); +} + +inline const Vector4 maxPerElem( const Vector4 & vec0, const Vector4 & vec1 ) +{ + return Vector4( + fmaxf4( vec0.getX(), vec1.getX() ), + fmaxf4( vec0.getY(), vec1.getY() ), + fmaxf4( vec0.getZ(), vec1.getZ() ), + fmaxf4( vec0.getW(), vec1.getW() ) + ); +} + +inline vec_float4 maxElem( const Vector4 & vec ) +{ + vec_float4 result; + result = fmaxf4( vec.getX(), vec.getY() ); + result = fmaxf4( vec.getZ(), result ); + result = fmaxf4( vec.getW(), result ); + return result; +} + +inline const Vector4 minPerElem( const Vector4 & vec0, const Vector4 & vec1 ) +{ + return Vector4( + fminf4( vec0.getX(), vec1.getX() ), + fminf4( vec0.getY(), vec1.getY() ), + fminf4( vec0.getZ(), vec1.getZ() ), + fminf4( vec0.getW(), vec1.getW() ) + ); +} + +inline vec_float4 minElem( const Vector4 & vec ) +{ + vec_float4 result; + result = fminf4( vec.getX(), vec.getY() ); + result = fminf4( vec.getZ(), result ); + result = fminf4( vec.getW(), result ); + return result; +} + +inline vec_float4 sum( const Vector4 & vec ) +{ + vec_float4 result; + result = vec_add( vec.getX(), vec.getY() ); + result = vec_add( result, vec.getZ() ); + result = vec_add( result, vec.getW() ); + return result; +} + +inline vec_float4 dot( const Vector4 & vec0, const Vector4 & vec1 ) +{ + vec_float4 result; + result = vec_madd( vec0.getX(), vec1.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + result = vec_add( result, vec_madd( vec0.getY(), vec1.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + result = vec_add( result, vec_madd( vec0.getZ(), vec1.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + result = vec_add( result, vec_madd( vec0.getW(), vec1.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + return result; +} + +inline vec_float4 lengthSqr( const Vector4 & vec ) +{ + vec_float4 result; + result = vec_madd( vec.getX(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + result = vec_add( result, vec_madd( vec.getY(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + result = vec_add( result, vec_madd( vec.getZ(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + result = vec_add( result, vec_madd( vec.getW(), vec.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + return result; +} + +inline vec_float4 length( const Vector4 & vec ) +{ + return sqrtf4( lengthSqr( vec ) ); +} + +inline const Vector4 normalize( const Vector4 & vec ) +{ + vec_float4 lenSqr, lenInv; + lenSqr = lengthSqr( vec ); + lenInv = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( lenSqr ) ); + return Vector4( + vec_madd( vec.getX(), lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + vec_madd( vec.getY(), lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + vec_madd( vec.getZ(), lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + vec_madd( vec.getW(), lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) + ); +} + +inline const Vector4 select( const Vector4 & vec0, const Vector4 & vec1, vec_uint4 select1 ) +{ + return Vector4( + vec_sel( vec0.getX(), vec1.getX(), select1 ), + vec_sel( vec0.getY(), vec1.getY(), select1 ), + vec_sel( vec0.getZ(), vec1.getZ(), select1 ), + vec_sel( vec0.getW(), vec1.getW(), select1 ) + ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( const Vector4 & vec ) +{ + Aos::Vector4 vec0, vec1, vec2, vec3; + vec.get4Aos( vec0, vec1, vec2, vec3 ); + printf("slot 0:\n"); + print( vec0 ); + printf("slot 1:\n"); + print( vec1 ); + printf("slot 2:\n"); + print( vec2 ); + printf("slot 3:\n"); + print( vec3 ); +} + +inline void print( const Vector4 & vec, const char * name ) +{ + Aos::Vector4 vec0, vec1, vec2, vec3; + printf( "%s:\n", name ); + vec.get4Aos( vec0, vec1, vec2, vec3 ); + printf("slot 0:\n"); + print( vec0 ); + printf("slot 1:\n"); + print( vec1 ); + printf("slot 2:\n"); + print( vec2 ); + printf("slot 3:\n"); + print( vec3 ); +} + +#endif + +inline Point3::Point3( const Point3 & pnt ) +{ + mX = pnt.mX; + mY = pnt.mY; + mZ = pnt.mZ; +} + +inline Point3::Point3( vec_float4 _x, vec_float4 _y, vec_float4 _z ) +{ + mX = _x; + mY = _y; + mZ = _z; +} + +inline Point3::Point3( const Vector3 & vec ) +{ + mX = vec.getX(); + mY = vec.getY(); + mZ = vec.getZ(); +} + +inline Point3::Point3( vec_float4 scalar ) +{ + mX = scalar; + mY = scalar; + mZ = scalar; +} + +inline Point3::Point3( Aos::Point3 pnt ) +{ + vec_float4 vec128 = pnt.get128(); + mX = vec_splat( vec128, 0 ); + mY = vec_splat( vec128, 1 ); + mZ = vec_splat( vec128, 2 ); +} + +inline Point3::Point3( Aos::Point3 pnt0, Aos::Point3 pnt1, Aos::Point3 pnt2, Aos::Point3 pnt3 ) +{ + vec_float4 tmp0, tmp1, tmp2, tmp3; + tmp0 = vec_mergeh( pnt0.get128(), pnt2.get128() ); + tmp1 = vec_mergeh( pnt1.get128(), pnt3.get128() ); + tmp2 = vec_mergel( pnt0.get128(), pnt2.get128() ); + tmp3 = vec_mergel( pnt1.get128(), pnt3.get128() ); + mX = vec_mergeh( tmp0, tmp1 ); + mY = vec_mergel( tmp0, tmp1 ); + mZ = vec_mergeh( tmp2, tmp3 ); +} + +inline const Point3 lerp( vec_float4 t, const Point3 & pnt0, const Point3 & pnt1 ) +{ + return ( pnt0 + ( ( pnt1 - pnt0 ) * t ) ); +} + +inline void Point3::get4Aos( Aos::Point3 & result0, Aos::Point3 & result1, Aos::Point3 & result2, Aos::Point3 & result3 ) const +{ + vec_float4 tmp0, tmp1; + tmp0 = vec_mergeh( mX, mZ ); + tmp1 = vec_mergel( mX, mZ ); + result0 = Aos::Point3( vec_mergeh( tmp0, mY ) ); + result1 = Aos::Point3( vec_perm( tmp0, mY, _VECTORMATH_PERM_ZBWX ) ); + result2 = Aos::Point3( vec_perm( tmp1, mY, _VECTORMATH_PERM_XCYX ) ); + result3 = Aos::Point3( vec_perm( tmp1, mY, _VECTORMATH_PERM_ZDWX ) ); +} + +inline void loadXYZArray( Point3 & vec, const vec_float4 * threeQuads ) +{ + vec_float4 xyxy, yzyz, zxzx, xyzx, yzxy, zxyz; + xyzx = threeQuads[0]; + yzxy = threeQuads[1]; + zxyz = threeQuads[2]; + xyxy = vec_sld( yzxy, xyzx, 8 ); + zxzx = vec_sld( xyzx, zxyz, 8 ); + yzyz = vec_sld( zxyz, yzxy, 8 ); + vec.setX( vec_perm( xyxy, zxzx, _VECTORMATH_PERM_ZBXD ) ); + vec.setY( vec_perm( xyxy, yzyz, _VECTORMATH_PERM_WCYA ) ); + vec.setZ( vec_perm( zxzx, yzyz, _VECTORMATH_PERM_XDZB ) ); +} + +inline void storeXYZArray( const Point3 & vec, vec_float4 * threeQuads ) +{ + vec_float4 xyzx, yzxy, zxyz, xyxy, zxzx, yzyz; + xyxy = vec_perm( vec.getX(), vec.getY(), _VECTORMATH_PERM_ZCXA ); + zxzx = vec_perm( vec.getZ(), vec.getX(), _VECTORMATH_PERM_XBZD ); + yzyz = vec_perm( vec.getY(), vec.getZ(), _VECTORMATH_PERM_WDYB ); + xyzx = vec_sld( xyxy, zxzx, 8 ); + yzxy = vec_sld( yzyz, xyxy, 8 ); + zxyz = vec_sld( zxzx, yzyz, 8 ); + threeQuads[0] = xyzx; + threeQuads[1] = yzxy; + threeQuads[2] = zxyz; +} + +inline void storeHalfFloats( const Point3 & pnt0, const Point3 & pnt1, vec_ushort8 * threeQuads ) +{ + vec_float4 xyz0[3]; + vec_float4 xyz1[3]; + storeXYZArray( pnt0, xyz0 ); + storeXYZArray( pnt1, xyz1 ); + threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); + threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); + threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); +} + +inline Point3 & Point3::operator =( const Point3 & pnt ) +{ + mX = pnt.mX; + mY = pnt.mY; + mZ = pnt.mZ; + return *this; +} + +inline Point3 & Point3::setX( vec_float4 _x ) +{ + mX = _x; + return *this; +} + +inline vec_float4 Point3::getX( ) const +{ + return mX; +} + +inline Point3 & Point3::setY( vec_float4 _y ) +{ + mY = _y; + return *this; +} + +inline vec_float4 Point3::getY( ) const +{ + return mY; +} + +inline Point3 & Point3::setZ( vec_float4 _z ) +{ + mZ = _z; + return *this; +} + +inline vec_float4 Point3::getZ( ) const +{ + return mZ; +} + +inline Point3 & Point3::setElem( int idx, vec_float4 value ) +{ + *(&mX + idx) = value; + return *this; +} + +inline vec_float4 Point3::getElem( int idx ) const +{ + return *(&mX + idx); +} + +inline Point3::vec_float4_t & Point3::operator []( int idx ) +{ + return *(&mX + idx); +} + +inline vec_float4 Point3::operator []( int idx ) const +{ + return *(&mX + idx); +} + +inline const Vector3 Point3::operator -( const Point3 & pnt ) const +{ + return Vector3( + vec_sub( mX, pnt.mX ), + vec_sub( mY, pnt.mY ), + vec_sub( mZ, pnt.mZ ) + ); +} + +inline const Point3 Point3::operator +( const Vector3 & vec ) const +{ + return Point3( + vec_add( mX, vec.getX() ), + vec_add( mY, vec.getY() ), + vec_add( mZ, vec.getZ() ) + ); +} + +inline const Point3 Point3::operator -( const Vector3 & vec ) const +{ + return Point3( + vec_sub( mX, vec.getX() ), + vec_sub( mY, vec.getY() ), + vec_sub( mZ, vec.getZ() ) + ); +} + +inline Point3 & Point3::operator +=( const Vector3 & vec ) +{ + *this = *this + vec; + return *this; +} + +inline Point3 & Point3::operator -=( const Vector3 & vec ) +{ + *this = *this - vec; + return *this; +} + +inline const Point3 mulPerElem( const Point3 & pnt0, const Point3 & pnt1 ) +{ + return Point3( + vec_madd( pnt0.getX(), pnt1.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + vec_madd( pnt0.getY(), pnt1.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), + vec_madd( pnt0.getZ(), pnt1.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) + ); +} + +inline const Point3 divPerElem( const Point3 & pnt0, const Point3 & pnt1 ) +{ + return Point3( + divf4( pnt0.getX(), pnt1.getX() ), + divf4( pnt0.getY(), pnt1.getY() ), + divf4( pnt0.getZ(), pnt1.getZ() ) + ); +} + +inline const Point3 recipPerElem( const Point3 & pnt ) +{ + return Point3( + divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), pnt.getX() ), + divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), pnt.getY() ), + divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), pnt.getZ() ) + ); +} + +inline const Point3 sqrtPerElem( const Point3 & pnt ) +{ + return Point3( + sqrtf4( pnt.getX() ), + sqrtf4( pnt.getY() ), + sqrtf4( pnt.getZ() ) + ); +} + +inline const Point3 rsqrtPerElem( const Point3 & pnt ) +{ + return Point3( + divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( pnt.getX() ) ), + divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( pnt.getY() ) ), + divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( pnt.getZ() ) ) + ); +} + +inline const Point3 absPerElem( const Point3 & pnt ) +{ + return Point3( + fabsf4( pnt.getX() ), + fabsf4( pnt.getY() ), + fabsf4( pnt.getZ() ) + ); +} + +inline const Point3 copySignPerElem( const Point3 & pnt0, const Point3 & pnt1 ) +{ + return Point3( + copysignf4( pnt0.getX(), pnt1.getX() ), + copysignf4( pnt0.getY(), pnt1.getY() ), + copysignf4( pnt0.getZ(), pnt1.getZ() ) + ); +} + +inline const Point3 maxPerElem( const Point3 & pnt0, const Point3 & pnt1 ) +{ + return Point3( + fmaxf4( pnt0.getX(), pnt1.getX() ), + fmaxf4( pnt0.getY(), pnt1.getY() ), + fmaxf4( pnt0.getZ(), pnt1.getZ() ) + ); +} + +inline vec_float4 maxElem( const Point3 & pnt ) +{ + vec_float4 result; + result = fmaxf4( pnt.getX(), pnt.getY() ); + result = fmaxf4( pnt.getZ(), result ); + return result; +} + +inline const Point3 minPerElem( const Point3 & pnt0, const Point3 & pnt1 ) +{ + return Point3( + fminf4( pnt0.getX(), pnt1.getX() ), + fminf4( pnt0.getY(), pnt1.getY() ), + fminf4( pnt0.getZ(), pnt1.getZ() ) + ); +} + +inline vec_float4 minElem( const Point3 & pnt ) +{ + vec_float4 result; + result = fminf4( pnt.getX(), pnt.getY() ); + result = fminf4( pnt.getZ(), result ); + return result; +} + +inline vec_float4 sum( const Point3 & pnt ) +{ + vec_float4 result; + result = vec_add( pnt.getX(), pnt.getY() ); + result = vec_add( result, pnt.getZ() ); + return result; +} + +inline const Point3 scale( const Point3 & pnt, vec_float4 scaleVal ) +{ + return mulPerElem( pnt, Point3( scaleVal ) ); +} + +inline const Point3 scale( const Point3 & pnt, const Vector3 & scaleVec ) +{ + return mulPerElem( pnt, Point3( scaleVec ) ); +} + +inline vec_float4 projection( const Point3 & pnt, const Vector3 & unitVec ) +{ + vec_float4 result; + result = vec_madd( pnt.getX(), unitVec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); + result = vec_add( result, vec_madd( pnt.getY(), unitVec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + result = vec_add( result, vec_madd( pnt.getZ(), unitVec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); + return result; +} + +inline vec_float4 distSqrFromOrigin( const Point3 & pnt ) +{ + return lengthSqr( Vector3( pnt ) ); +} + +inline vec_float4 distFromOrigin( const Point3 & pnt ) +{ + return length( Vector3( pnt ) ); +} + +inline vec_float4 distSqr( const Point3 & pnt0, const Point3 & pnt1 ) +{ + return lengthSqr( ( pnt1 - pnt0 ) ); +} + +inline vec_float4 dist( const Point3 & pnt0, const Point3 & pnt1 ) +{ + return length( ( pnt1 - pnt0 ) ); +} + +inline const Point3 select( const Point3 & pnt0, const Point3 & pnt1, vec_uint4 select1 ) +{ + return Point3( + vec_sel( pnt0.getX(), pnt1.getX(), select1 ), + vec_sel( pnt0.getY(), pnt1.getY(), select1 ), + vec_sel( pnt0.getZ(), pnt1.getZ(), select1 ) + ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( const Point3 & pnt ) +{ + Aos::Point3 vec0, vec1, vec2, vec3; + pnt.get4Aos( vec0, vec1, vec2, vec3 ); + printf("slot 0:\n"); + print( vec0 ); + printf("slot 1:\n"); + print( vec1 ); + printf("slot 2:\n"); + print( vec2 ); + printf("slot 3:\n"); + print( vec3 ); +} + +inline void print( const Point3 & pnt, const char * name ) +{ + Aos::Point3 vec0, vec1, vec2, vec3; + printf( "%s:\n", name ); + pnt.get4Aos( vec0, vec1, vec2, vec3 ); + printf("slot 0:\n"); + print( vec0 ); + printf("slot 1:\n"); + print( vec1 ); + printf("slot 2:\n"); + print( vec2 ); + printf("slot 3:\n"); + print( vec3 ); +} + +#endif + +} // namespace Soa +} // namespace Vectormath + +#endif diff --git a/vectormathlibrary/include/vectormath/ppu/cpp/vecidx_aos.h b/vectormathlibrary/include/vectormath/ppu/cpp/vecidx_aos.h new file mode 100644 index 000000000..df3357570 --- /dev/null +++ b/vectormathlibrary/include/vectormath/ppu/cpp/vecidx_aos.h @@ -0,0 +1,80 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_VECIDX_AOS_H +#define _VECTORMATH_VECIDX_AOS_H + +#include "floatInVec.h" + +namespace Vectormath { +namespace Aos { + +//----------------------------------------------------------------------------- +// VecIdx +// Used in setting elements of Vector3, Vector4, Point3, or Quat with the +// subscripting operator. +// + +class VecIdx +{ +private: + typedef vec_float4 vec_float4_t; + vec_float4_t &ref __attribute__ ((aligned(16))); + int i __attribute__ ((aligned(16))); +public: + inline VecIdx( vec_float4_t& vec, int idx ): ref(vec) { i = idx; } + + // implicitly casts to float unless _VECTORMATH_NO_SCALAR_CAST defined + // in which case, implicitly casts to floatInVec, and one must call + // getAsFloat to convert to float. + // +#ifdef _VECTORMATH_NO_SCALAR_CAST + inline operator floatInVec() const; + inline float getAsFloat() const; +#else + inline operator float() const; +#endif + + inline float operator =( float scalar ); + inline floatInVec operator =( floatInVec scalar ); + inline floatInVec operator =( const VecIdx& scalar ); + inline floatInVec operator *=( float scalar ); + inline floatInVec operator *=( floatInVec scalar ); + inline floatInVec operator /=( float scalar ); + inline floatInVec operator /=( floatInVec scalar ); + inline floatInVec operator +=( float scalar ); + inline floatInVec operator +=( floatInVec scalar ); + inline floatInVec operator -=( float scalar ); + inline floatInVec operator -=( floatInVec scalar ); +}; + +} // namespace Aos +} // namespace Vectormath + +#endif diff --git a/vectormathlibrary/include/vectormath/ppu/cpp/vectormath_aos.h b/vectormathlibrary/include/vectormath/ppu/cpp/vectormath_aos.h new file mode 100644 index 000000000..0a7fa1738 --- /dev/null +++ b/vectormathlibrary/include/vectormath/ppu/cpp/vectormath_aos.h @@ -0,0 +1,2244 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_AOS_CPP_PPU_H +#define _VECTORMATH_AOS_CPP_PPU_H + +#include <math.h> +#include <altivec.h> +#include "vecidx_aos.h" +#include "floatInVec.h" +#include "boolInVec.h" + +#ifdef _VECTORMATH_DEBUG +#include <stdio.h> +#endif + +namespace Vectormath { + +namespace Aos { + +//----------------------------------------------------------------------------- +// Forward Declarations +// + +class Vector3; +class Vector4; +class Point3; +class Quat; +class Matrix3; +class Matrix4; +class Transform3; + +// A 3-D vector in array-of-structures format +// +class Vector3 +{ + vec_float4 mVec128; + +public: + // Default constructor; does no initialization + // + inline Vector3( ) { }; + + // Construct a 3-D vector from x, y, and z elements + // + inline Vector3( float x, float y, float z ); + + // Construct a 3-D vector from x, y, and z elements (scalar data contained in vector data type) + // + inline Vector3( floatInVec x, floatInVec y, floatInVec z ); + + // Copy elements from a 3-D point into a 3-D vector + // + explicit inline Vector3( Point3 pnt ); + + // Set all elements of a 3-D vector to the same scalar value + // + explicit inline Vector3( float scalar ); + + // Set all elements of a 3-D vector to the same scalar value (scalar data contained in vector data type) + // + explicit inline Vector3( floatInVec scalar ); + + // Set vector float data in a 3-D vector + // + explicit inline Vector3( vec_float4 vf4 ); + + // Get vector float data from a 3-D vector + // + inline vec_float4 get128( ) const; + + // Assign one 3-D vector to another + // + inline Vector3 & operator =( Vector3 vec ); + + // Set the x element of a 3-D vector + // + inline Vector3 & setX( float x ); + + // Set the y element of a 3-D vector + // + inline Vector3 & setY( float y ); + + // Set the z element of a 3-D vector + // + inline Vector3 & setZ( float z ); + + // Set the x element of a 3-D vector (scalar data contained in vector data type) + // + inline Vector3 & setX( floatInVec x ); + + // Set the y element of a 3-D vector (scalar data contained in vector data type) + // + inline Vector3 & setY( floatInVec y ); + + // Set the z element of a 3-D vector (scalar data contained in vector data type) + // + inline Vector3 & setZ( floatInVec z ); + + // Get the x element of a 3-D vector + // + inline const floatInVec getX( ) const; + + // Get the y element of a 3-D vector + // + inline const floatInVec getY( ) const; + + // Get the z element of a 3-D vector + // + inline const floatInVec getZ( ) const; + + // Set an x, y, or z element of a 3-D vector by index + // + inline Vector3 & setElem( int idx, float value ); + + // Set an x, y, or z element of a 3-D vector by index (scalar data contained in vector data type) + // + inline Vector3 & setElem( int idx, floatInVec value ); + + // Get an x, y, or z element of a 3-D vector by index + // + inline const floatInVec getElem( int idx ) const; + + // Subscripting operator to set or get an element + // + inline VecIdx operator []( int idx ); + + // Subscripting operator to get an element + // + inline const floatInVec operator []( int idx ) const; + + // Add two 3-D vectors + // + inline const Vector3 operator +( Vector3 vec ) const; + + // Subtract a 3-D vector from another 3-D vector + // + inline const Vector3 operator -( Vector3 vec ) const; + + // Add a 3-D vector to a 3-D point + // + inline const Point3 operator +( Point3 pnt ) const; + + // Multiply a 3-D vector by a scalar + // + inline const Vector3 operator *( float scalar ) const; + + // Divide a 3-D vector by a scalar + // + inline const Vector3 operator /( float scalar ) const; + + // Multiply a 3-D vector by a scalar (scalar data contained in vector data type) + // + inline const Vector3 operator *( floatInVec scalar ) const; + + // Divide a 3-D vector by a scalar (scalar data contained in vector data type) + // + inline const Vector3 operator /( floatInVec scalar ) const; + + // Perform compound assignment and addition with a 3-D vector + // + inline Vector3 & operator +=( Vector3 vec ); + + // Perform compound assignment and subtraction by a 3-D vector + // + inline Vector3 & operator -=( Vector3 vec ); + + // Perform compound assignment and multiplication by a scalar + // + inline Vector3 & operator *=( float scalar ); + + // Perform compound assignment and division by a scalar + // + inline Vector3 & operator /=( float scalar ); + + // Perform compound assignment and multiplication by a scalar (scalar data contained in vector data type) + // + inline Vector3 & operator *=( floatInVec scalar ); + + // Perform compound assignment and division by a scalar (scalar data contained in vector data type) + // + inline Vector3 & operator /=( floatInVec scalar ); + + // Negate all elements of a 3-D vector + // + inline const Vector3 operator -( ) const; + + // Construct x axis + // + static inline const Vector3 xAxis( ); + + // Construct y axis + // + static inline const Vector3 yAxis( ); + + // Construct z axis + // + static inline const Vector3 zAxis( ); + +}; + +// Multiply a 3-D vector by a scalar +// +inline const Vector3 operator *( float scalar, Vector3 vec ); + +// Multiply a 3-D vector by a scalar (scalar data contained in vector data type) +// +inline const Vector3 operator *( floatInVec scalar, Vector3 vec ); + +// Multiply two 3-D vectors per element +// +inline const Vector3 mulPerElem( Vector3 vec0, Vector3 vec1 ); + +// Divide two 3-D vectors per element +// NOTE: +// Floating-point behavior matches standard library function divf4. +// +inline const Vector3 divPerElem( Vector3 vec0, Vector3 vec1 ); + +// Compute the reciprocal of a 3-D vector per element +// NOTE: +// Floating-point behavior matches standard library function recipf4. +// +inline const Vector3 recipPerElem( Vector3 vec ); + +// Compute the square root of a 3-D vector per element +// NOTE: +// Floating-point behavior matches standard library function sqrtf4. +// +inline const Vector3 sqrtPerElem( Vector3 vec ); + +// Compute the reciprocal square root of a 3-D vector per element +// NOTE: +// Floating-point behavior matches standard library function rsqrtf4. +// +inline const Vector3 rsqrtPerElem( Vector3 vec ); + +// Compute the absolute value of a 3-D vector per element +// +inline const Vector3 absPerElem( Vector3 vec ); + +// Copy sign from one 3-D vector to another, per element +// +inline const Vector3 copySignPerElem( Vector3 vec0, Vector3 vec1 ); + +// Maximum of two 3-D vectors per element +// +inline const Vector3 maxPerElem( Vector3 vec0, Vector3 vec1 ); + +// Minimum of two 3-D vectors per element +// +inline const Vector3 minPerElem( Vector3 vec0, Vector3 vec1 ); + +// Maximum element of a 3-D vector +// +inline const floatInVec maxElem( Vector3 vec ); + +// Minimum element of a 3-D vector +// +inline const floatInVec minElem( Vector3 vec ); + +// Compute the sum of all elements of a 3-D vector +// +inline const floatInVec sum( Vector3 vec ); + +// Compute the dot product of two 3-D vectors +// +inline const floatInVec dot( Vector3 vec0, Vector3 vec1 ); + +// Compute the square of the length of a 3-D vector +// +inline const floatInVec lengthSqr( Vector3 vec ); + +// Compute the length of a 3-D vector +// +inline const floatInVec length( Vector3 vec ); + +// Normalize a 3-D vector +// NOTE: +// The result is unpredictable when all elements of vec are at or near zero. +// +inline const Vector3 normalize( Vector3 vec ); + +// Compute cross product of two 3-D vectors +// +inline const Vector3 cross( Vector3 vec0, Vector3 vec1 ); + +// Outer product of two 3-D vectors +// +inline const Matrix3 outer( Vector3 vec0, Vector3 vec1 ); + +// Pre-multiply a row vector by a 3x3 matrix +// NOTE: +// Slower than column post-multiply. +// +inline const Vector3 rowMul( Vector3 vec, const Matrix3 & mat ); + +// Cross-product matrix of a 3-D vector +// +inline const Matrix3 crossMatrix( Vector3 vec ); + +// Create cross-product matrix and multiply +// NOTE: +// Faster than separately creating a cross-product matrix and multiplying. +// +inline const Matrix3 crossMatrixMul( Vector3 vec, const Matrix3 & mat ); + +// Linear interpolation between two 3-D vectors +// NOTE: +// Does not clamp t between 0 and 1. +// +inline const Vector3 lerp( float t, Vector3 vec0, Vector3 vec1 ); + +// Linear interpolation between two 3-D vectors (scalar data contained in vector data type) +// NOTE: +// Does not clamp t between 0 and 1. +// +inline const Vector3 lerp( floatInVec t, Vector3 vec0, Vector3 vec1 ); + +// Spherical linear interpolation between two 3-D vectors +// NOTE: +// The result is unpredictable if the vectors point in opposite directions. +// Does not clamp t between 0 and 1. +// +inline const Vector3 slerp( float t, Vector3 unitVec0, Vector3 unitVec1 ); + +// Spherical linear interpolation between two 3-D vectors (scalar data contained in vector data type) +// NOTE: +// The result is unpredictable if the vectors point in opposite directions. +// Does not clamp t between 0 and 1. +// +inline const Vector3 slerp( floatInVec t, Vector3 unitVec0, Vector3 unitVec1 ); + +// Conditionally select between two 3-D vectors +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// However, the transfer of select1 to a VMX register may use more processing time than a branch. +// Use the boolInVec version for better performance. +// +inline const Vector3 select( Vector3 vec0, Vector3 vec1, bool select1 ); + +// Conditionally select between two 3-D vectors (scalar data contained in vector data type) +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// +inline const Vector3 select( Vector3 vec0, Vector3 vec1, boolInVec select1 ); + +// Store x, y, and z elements of a 3-D vector in the first three words of a quadword. +// The value of the fourth word (the word with the highest address) remains unchanged +// +inline void storeXYZ( Vector3 vec, vec_float4 * quad ); + +// Load four three-float 3-D vectors, stored in three quadwords +// +inline void loadXYZArray( Vector3 & vec0, Vector3 & vec1, Vector3 & vec2, Vector3 & vec3, const vec_float4 * threeQuads ); + +// Store four 3-D vectors in three quadwords +// +inline void storeXYZArray( Vector3 vec0, Vector3 vec1, Vector3 vec2, Vector3 vec3, vec_float4 * threeQuads ); + +// Store eight 3-D vectors as half-floats +// +inline void storeHalfFloats( Vector3 vec0, Vector3 vec1, Vector3 vec2, Vector3 vec3, Vector3 vec4, Vector3 vec5, Vector3 vec6, Vector3 vec7, vec_ushort8 * threeQuads ); + +#ifdef _VECTORMATH_DEBUG + +// Print a 3-D vector +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( Vector3 vec ); + +// Print a 3-D vector and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( Vector3 vec, const char * name ); + +#endif + +// A 4-D vector in array-of-structures format +// +class Vector4 +{ + vec_float4 mVec128; + +public: + // Default constructor; does no initialization + // + inline Vector4( ) { }; + + // Construct a 4-D vector from x, y, z, and w elements + // + inline Vector4( float x, float y, float z, float w ); + + // Construct a 4-D vector from x, y, z, and w elements (scalar data contained in vector data type) + // + inline Vector4( floatInVec x, floatInVec y, floatInVec z, floatInVec w ); + + // Construct a 4-D vector from a 3-D vector and a scalar + // + inline Vector4( Vector3 xyz, float w ); + + // Construct a 4-D vector from a 3-D vector and a scalar (scalar data contained in vector data type) + // + inline Vector4( Vector3 xyz, floatInVec w ); + + // Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0 + // + explicit inline Vector4( Vector3 vec ); + + // Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1 + // + explicit inline Vector4( Point3 pnt ); + + // Copy elements from a quaternion into a 4-D vector + // + explicit inline Vector4( Quat quat ); + + // Set all elements of a 4-D vector to the same scalar value + // + explicit inline Vector4( float scalar ); + + // Set all elements of a 4-D vector to the same scalar value (scalar data contained in vector data type) + // + explicit inline Vector4( floatInVec scalar ); + + // Set vector float data in a 4-D vector + // + explicit inline Vector4( vec_float4 vf4 ); + + // Get vector float data from a 4-D vector + // + inline vec_float4 get128( ) const; + + // Assign one 4-D vector to another + // + inline Vector4 & operator =( Vector4 vec ); + + // Set the x, y, and z elements of a 4-D vector + // NOTE: + // This function does not change the w element. + // + inline Vector4 & setXYZ( Vector3 vec ); + + // Get the x, y, and z elements of a 4-D vector + // + inline const Vector3 getXYZ( ) const; + + // Set the x element of a 4-D vector + // + inline Vector4 & setX( float x ); + + // Set the y element of a 4-D vector + // + inline Vector4 & setY( float y ); + + // Set the z element of a 4-D vector + // + inline Vector4 & setZ( float z ); + + // Set the w element of a 4-D vector + // + inline Vector4 & setW( float w ); + + // Set the x element of a 4-D vector (scalar data contained in vector data type) + // + inline Vector4 & setX( floatInVec x ); + + // Set the y element of a 4-D vector (scalar data contained in vector data type) + // + inline Vector4 & setY( floatInVec y ); + + // Set the z element of a 4-D vector (scalar data contained in vector data type) + // + inline Vector4 & setZ( floatInVec z ); + + // Set the w element of a 4-D vector (scalar data contained in vector data type) + // + inline Vector4 & setW( floatInVec w ); + + // Get the x element of a 4-D vector + // + inline const floatInVec getX( ) const; + + // Get the y element of a 4-D vector + // + inline const floatInVec getY( ) const; + + // Get the z element of a 4-D vector + // + inline const floatInVec getZ( ) const; + + // Get the w element of a 4-D vector + // + inline const floatInVec getW( ) const; + + // Set an x, y, z, or w element of a 4-D vector by index + // + inline Vector4 & setElem( int idx, float value ); + + // Set an x, y, z, or w element of a 4-D vector by index (scalar data contained in vector data type) + // + inline Vector4 & setElem( int idx, floatInVec value ); + + // Get an x, y, z, or w element of a 4-D vector by index + // + inline const floatInVec getElem( int idx ) const; + + // Subscripting operator to set or get an element + // + inline VecIdx operator []( int idx ); + + // Subscripting operator to get an element + // + inline const floatInVec operator []( int idx ) const; + + // Add two 4-D vectors + // + inline const Vector4 operator +( Vector4 vec ) const; + + // Subtract a 4-D vector from another 4-D vector + // + inline const Vector4 operator -( Vector4 vec ) const; + + // Multiply a 4-D vector by a scalar + // + inline const Vector4 operator *( float scalar ) const; + + // Divide a 4-D vector by a scalar + // + inline const Vector4 operator /( float scalar ) const; + + // Multiply a 4-D vector by a scalar (scalar data contained in vector data type) + // + inline const Vector4 operator *( floatInVec scalar ) const; + + // Divide a 4-D vector by a scalar (scalar data contained in vector data type) + // + inline const Vector4 operator /( floatInVec scalar ) const; + + // Perform compound assignment and addition with a 4-D vector + // + inline Vector4 & operator +=( Vector4 vec ); + + // Perform compound assignment and subtraction by a 4-D vector + // + inline Vector4 & operator -=( Vector4 vec ); + + // Perform compound assignment and multiplication by a scalar + // + inline Vector4 & operator *=( float scalar ); + + // Perform compound assignment and division by a scalar + // + inline Vector4 & operator /=( float scalar ); + + // Perform compound assignment and multiplication by a scalar (scalar data contained in vector data type) + // + inline Vector4 & operator *=( floatInVec scalar ); + + // Perform compound assignment and division by a scalar (scalar data contained in vector data type) + // + inline Vector4 & operator /=( floatInVec scalar ); + + // Negate all elements of a 4-D vector + // + inline const Vector4 operator -( ) const; + + // Construct x axis + // + static inline const Vector4 xAxis( ); + + // Construct y axis + // + static inline const Vector4 yAxis( ); + + // Construct z axis + // + static inline const Vector4 zAxis( ); + + // Construct w axis + // + static inline const Vector4 wAxis( ); + +}; + +// Multiply a 4-D vector by a scalar +// +inline const Vector4 operator *( float scalar, Vector4 vec ); + +// Multiply a 4-D vector by a scalar (scalar data contained in vector data type) +// +inline const Vector4 operator *( floatInVec scalar, Vector4 vec ); + +// Multiply two 4-D vectors per element +// +inline const Vector4 mulPerElem( Vector4 vec0, Vector4 vec1 ); + +// Divide two 4-D vectors per element +// NOTE: +// Floating-point behavior matches standard library function divf4. +// +inline const Vector4 divPerElem( Vector4 vec0, Vector4 vec1 ); + +// Compute the reciprocal of a 4-D vector per element +// NOTE: +// Floating-point behavior matches standard library function recipf4. +// +inline const Vector4 recipPerElem( Vector4 vec ); + +// Compute the square root of a 4-D vector per element +// NOTE: +// Floating-point behavior matches standard library function sqrtf4. +// +inline const Vector4 sqrtPerElem( Vector4 vec ); + +// Compute the reciprocal square root of a 4-D vector per element +// NOTE: +// Floating-point behavior matches standard library function rsqrtf4. +// +inline const Vector4 rsqrtPerElem( Vector4 vec ); + +// Compute the absolute value of a 4-D vector per element +// +inline const Vector4 absPerElem( Vector4 vec ); + +// Copy sign from one 4-D vector to another, per element +// +inline const Vector4 copySignPerElem( Vector4 vec0, Vector4 vec1 ); + +// Maximum of two 4-D vectors per element +// +inline const Vector4 maxPerElem( Vector4 vec0, Vector4 vec1 ); + +// Minimum of two 4-D vectors per element +// +inline const Vector4 minPerElem( Vector4 vec0, Vector4 vec1 ); + +// Maximum element of a 4-D vector +// +inline const floatInVec maxElem( Vector4 vec ); + +// Minimum element of a 4-D vector +// +inline const floatInVec minElem( Vector4 vec ); + +// Compute the sum of all elements of a 4-D vector +// +inline const floatInVec sum( Vector4 vec ); + +// Compute the dot product of two 4-D vectors +// +inline const floatInVec dot( Vector4 vec0, Vector4 vec1 ); + +// Compute the square of the length of a 4-D vector +// +inline const floatInVec lengthSqr( Vector4 vec ); + +// Compute the length of a 4-D vector +// +inline const floatInVec length( Vector4 vec ); + +// Normalize a 4-D vector +// NOTE: +// The result is unpredictable when all elements of vec are at or near zero. +// +inline const Vector4 normalize( Vector4 vec ); + +// Outer product of two 4-D vectors +// +inline const Matrix4 outer( Vector4 vec0, Vector4 vec1 ); + +// Linear interpolation between two 4-D vectors +// NOTE: +// Does not clamp t between 0 and 1. +// +inline const Vector4 lerp( float t, Vector4 vec0, Vector4 vec1 ); + +// Linear interpolation between two 4-D vectors (scalar data contained in vector data type) +// NOTE: +// Does not clamp t between 0 and 1. +// +inline const Vector4 lerp( floatInVec t, Vector4 vec0, Vector4 vec1 ); + +// Spherical linear interpolation between two 4-D vectors +// NOTE: +// The result is unpredictable if the vectors point in opposite directions. +// Does not clamp t between 0 and 1. +// +inline const Vector4 slerp( float t, Vector4 unitVec0, Vector4 unitVec1 ); + +// Spherical linear interpolation between two 4-D vectors (scalar data contained in vector data type) +// NOTE: +// The result is unpredictable if the vectors point in opposite directions. +// Does not clamp t between 0 and 1. +// +inline const Vector4 slerp( floatInVec t, Vector4 unitVec0, Vector4 unitVec1 ); + +// Conditionally select between two 4-D vectors +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// However, the transfer of select1 to a VMX register may use more processing time than a branch. +// Use the boolInVec version for better performance. +// +inline const Vector4 select( Vector4 vec0, Vector4 vec1, bool select1 ); + +// Conditionally select between two 4-D vectors (scalar data contained in vector data type) +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// +inline const Vector4 select( Vector4 vec0, Vector4 vec1, boolInVec select1 ); + +// Store four 4-D vectors as half-floats +// +inline void storeHalfFloats( Vector4 vec0, Vector4 vec1, Vector4 vec2, Vector4 vec3, vec_ushort8 * twoQuads ); + +#ifdef _VECTORMATH_DEBUG + +// Print a 4-D vector +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( Vector4 vec ); + +// Print a 4-D vector and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( Vector4 vec, const char * name ); + +#endif + +// A 3-D point in array-of-structures format +// +class Point3 +{ + vec_float4 mVec128; + +public: + // Default constructor; does no initialization + // + inline Point3( ) { }; + + // Construct a 3-D point from x, y, and z elements + // + inline Point3( float x, float y, float z ); + + // Construct a 3-D point from x, y, and z elements (scalar data contained in vector data type) + // + inline Point3( floatInVec x, floatInVec y, floatInVec z ); + + // Copy elements from a 3-D vector into a 3-D point + // + explicit inline Point3( Vector3 vec ); + + // Set all elements of a 3-D point to the same scalar value + // + explicit inline Point3( float scalar ); + + // Set all elements of a 3-D point to the same scalar value (scalar data contained in vector data type) + // + explicit inline Point3( floatInVec scalar ); + + // Set vector float data in a 3-D point + // + explicit inline Point3( vec_float4 vf4 ); + + // Get vector float data from a 3-D point + // + inline vec_float4 get128( ) const; + + // Assign one 3-D point to another + // + inline Point3 & operator =( Point3 pnt ); + + // Set the x element of a 3-D point + // + inline Point3 & setX( float x ); + + // Set the y element of a 3-D point + // + inline Point3 & setY( float y ); + + // Set the z element of a 3-D point + // + inline Point3 & setZ( float z ); + + // Set the x element of a 3-D point (scalar data contained in vector data type) + // + inline Point3 & setX( floatInVec x ); + + // Set the y element of a 3-D point (scalar data contained in vector data type) + // + inline Point3 & setY( floatInVec y ); + + // Set the z element of a 3-D point (scalar data contained in vector data type) + // + inline Point3 & setZ( floatInVec z ); + + // Get the x element of a 3-D point + // + inline const floatInVec getX( ) const; + + // Get the y element of a 3-D point + // + inline const floatInVec getY( ) const; + + // Get the z element of a 3-D point + // + inline const floatInVec getZ( ) const; + + // Set an x, y, or z element of a 3-D point by index + // + inline Point3 & setElem( int idx, float value ); + + // Set an x, y, or z element of a 3-D point by index (scalar data contained in vector data type) + // + inline Point3 & setElem( int idx, floatInVec value ); + + // Get an x, y, or z element of a 3-D point by index + // + inline const floatInVec getElem( int idx ) const; + + // Subscripting operator to set or get an element + // + inline VecIdx operator []( int idx ); + + // Subscripting operator to get an element + // + inline const floatInVec operator []( int idx ) const; + + // Subtract a 3-D point from another 3-D point + // + inline const Vector3 operator -( Point3 pnt ) const; + + // Add a 3-D point to a 3-D vector + // + inline const Point3 operator +( Vector3 vec ) const; + + // Subtract a 3-D vector from a 3-D point + // + inline const Point3 operator -( Vector3 vec ) const; + + // Perform compound assignment and addition with a 3-D vector + // + inline Point3 & operator +=( Vector3 vec ); + + // Perform compound assignment and subtraction by a 3-D vector + // + inline Point3 & operator -=( Vector3 vec ); + +}; + +// Multiply two 3-D points per element +// +inline const Point3 mulPerElem( Point3 pnt0, Point3 pnt1 ); + +// Divide two 3-D points per element +// NOTE: +// Floating-point behavior matches standard library function divf4. +// +inline const Point3 divPerElem( Point3 pnt0, Point3 pnt1 ); + +// Compute the reciprocal of a 3-D point per element +// NOTE: +// Floating-point behavior matches standard library function recipf4. +// +inline const Point3 recipPerElem( Point3 pnt ); + +// Compute the square root of a 3-D point per element +// NOTE: +// Floating-point behavior matches standard library function sqrtf4. +// +inline const Point3 sqrtPerElem( Point3 pnt ); + +// Compute the reciprocal square root of a 3-D point per element +// NOTE: +// Floating-point behavior matches standard library function rsqrtf4. +// +inline const Point3 rsqrtPerElem( Point3 pnt ); + +// Compute the absolute value of a 3-D point per element +// +inline const Point3 absPerElem( Point3 pnt ); + +// Copy sign from one 3-D point to another, per element +// +inline const Point3 copySignPerElem( Point3 pnt0, Point3 pnt1 ); + +// Maximum of two 3-D points per element +// +inline const Point3 maxPerElem( Point3 pnt0, Point3 pnt1 ); + +// Minimum of two 3-D points per element +// +inline const Point3 minPerElem( Point3 pnt0, Point3 pnt1 ); + +// Maximum element of a 3-D point +// +inline const floatInVec maxElem( Point3 pnt ); + +// Minimum element of a 3-D point +// +inline const floatInVec minElem( Point3 pnt ); + +// Compute the sum of all elements of a 3-D point +// +inline const floatInVec sum( Point3 pnt ); + +// Apply uniform scale to a 3-D point +// +inline const Point3 scale( Point3 pnt, float scaleVal ); + +// Apply uniform scale to a 3-D point (scalar data contained in vector data type) +// +inline const Point3 scale( Point3 pnt, floatInVec scaleVal ); + +// Apply non-uniform scale to a 3-D point +// +inline const Point3 scale( Point3 pnt, Vector3 scaleVec ); + +// Scalar projection of a 3-D point on a unit-length 3-D vector +// +inline const floatInVec projection( Point3 pnt, Vector3 unitVec ); + +// Compute the square of the distance of a 3-D point from the coordinate-system origin +// +inline const floatInVec distSqrFromOrigin( Point3 pnt ); + +// Compute the distance of a 3-D point from the coordinate-system origin +// +inline const floatInVec distFromOrigin( Point3 pnt ); + +// Compute the square of the distance between two 3-D points +// +inline const floatInVec distSqr( Point3 pnt0, Point3 pnt1 ); + +// Compute the distance between two 3-D points +// +inline const floatInVec dist( Point3 pnt0, Point3 pnt1 ); + +// Linear interpolation between two 3-D points +// NOTE: +// Does not clamp t between 0 and 1. +// +inline const Point3 lerp( float t, Point3 pnt0, Point3 pnt1 ); + +// Linear interpolation between two 3-D points (scalar data contained in vector data type) +// NOTE: +// Does not clamp t between 0 and 1. +// +inline const Point3 lerp( floatInVec t, Point3 pnt0, Point3 pnt1 ); + +// Conditionally select between two 3-D points +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// However, the transfer of select1 to a VMX register may use more processing time than a branch. +// Use the boolInVec version for better performance. +// +inline const Point3 select( Point3 pnt0, Point3 pnt1, bool select1 ); + +// Conditionally select between two 3-D points (scalar data contained in vector data type) +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// +inline const Point3 select( Point3 pnt0, Point3 pnt1, boolInVec select1 ); + +// Store x, y, and z elements of a 3-D point in the first three words of a quadword. +// The value of the fourth word (the word with the highest address) remains unchanged +// +inline void storeXYZ( Point3 pnt, vec_float4 * quad ); + +// Load four three-float 3-D points, stored in three quadwords +// +inline void loadXYZArray( Point3 & pnt0, Point3 & pnt1, Point3 & pnt2, Point3 & pnt3, const vec_float4 * threeQuads ); + +// Store four 3-D points in three quadwords +// +inline void storeXYZArray( Point3 pnt0, Point3 pnt1, Point3 pnt2, Point3 pnt3, vec_float4 * threeQuads ); + +// Store eight 3-D points as half-floats +// +inline void storeHalfFloats( Point3 pnt0, Point3 pnt1, Point3 pnt2, Point3 pnt3, Point3 pnt4, Point3 pnt5, Point3 pnt6, Point3 pnt7, vec_ushort8 * threeQuads ); + +#ifdef _VECTORMATH_DEBUG + +// Print a 3-D point +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( Point3 pnt ); + +// Print a 3-D point and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( Point3 pnt, const char * name ); + +#endif + +// A quaternion in array-of-structures format +// +class Quat +{ + vec_float4 mVec128; + +public: + // Default constructor; does no initialization + // + inline Quat( ) { }; + + // Construct a quaternion from x, y, z, and w elements + // + inline Quat( float x, float y, float z, float w ); + + // Construct a quaternion from x, y, z, and w elements (scalar data contained in vector data type) + // + inline Quat( floatInVec x, floatInVec y, floatInVec z, floatInVec w ); + + // Construct a quaternion from a 3-D vector and a scalar + // + inline Quat( Vector3 xyz, float w ); + + // Construct a quaternion from a 3-D vector and a scalar (scalar data contained in vector data type) + // + inline Quat( Vector3 xyz, floatInVec w ); + + // Copy elements from a 4-D vector into a quaternion + // + explicit inline Quat( Vector4 vec ); + + // Convert a rotation matrix to a unit-length quaternion + // + explicit inline Quat( const Matrix3 & rotMat ); + + // Set all elements of a quaternion to the same scalar value + // + explicit inline Quat( float scalar ); + + // Set all elements of a quaternion to the same scalar value (scalar data contained in vector data type) + // + explicit inline Quat( floatInVec scalar ); + + // Set vector float data in a quaternion + // + explicit inline Quat( vec_float4 vf4 ); + + // Get vector float data from a quaternion + // + inline vec_float4 get128( ) const; + + // Assign one quaternion to another + // + inline Quat & operator =( Quat quat ); + + // Set the x, y, and z elements of a quaternion + // NOTE: + // This function does not change the w element. + // + inline Quat & setXYZ( Vector3 vec ); + + // Get the x, y, and z elements of a quaternion + // + inline const Vector3 getXYZ( ) const; + + // Set the x element of a quaternion + // + inline Quat & setX( float x ); + + // Set the y element of a quaternion + // + inline Quat & setY( float y ); + + // Set the z element of a quaternion + // + inline Quat & setZ( float z ); + + // Set the w element of a quaternion + // + inline Quat & setW( float w ); + + // Set the x element of a quaternion (scalar data contained in vector data type) + // + inline Quat & setX( floatInVec x ); + + // Set the y element of a quaternion (scalar data contained in vector data type) + // + inline Quat & setY( floatInVec y ); + + // Set the z element of a quaternion (scalar data contained in vector data type) + // + inline Quat & setZ( floatInVec z ); + + // Set the w element of a quaternion (scalar data contained in vector data type) + // + inline Quat & setW( floatInVec w ); + + // Get the x element of a quaternion + // + inline const floatInVec getX( ) const; + + // Get the y element of a quaternion + // + inline const floatInVec getY( ) const; + + // Get the z element of a quaternion + // + inline const floatInVec getZ( ) const; + + // Get the w element of a quaternion + // + inline const floatInVec getW( ) const; + + // Set an x, y, z, or w element of a quaternion by index + // + inline Quat & setElem( int idx, float value ); + + // Set an x, y, z, or w element of a quaternion by index (scalar data contained in vector data type) + // + inline Quat & setElem( int idx, floatInVec value ); + + // Get an x, y, z, or w element of a quaternion by index + // + inline const floatInVec getElem( int idx ) const; + + // Subscripting operator to set or get an element + // + inline VecIdx operator []( int idx ); + + // Subscripting operator to get an element + // + inline const floatInVec operator []( int idx ) const; + + // Add two quaternions + // + inline const Quat operator +( Quat quat ) const; + + // Subtract a quaternion from another quaternion + // + inline const Quat operator -( Quat quat ) const; + + // Multiply two quaternions + // + inline const Quat operator *( Quat quat ) const; + + // Multiply a quaternion by a scalar + // + inline const Quat operator *( float scalar ) const; + + // Divide a quaternion by a scalar + // + inline const Quat operator /( float scalar ) const; + + // Multiply a quaternion by a scalar (scalar data contained in vector data type) + // + inline const Quat operator *( floatInVec scalar ) const; + + // Divide a quaternion by a scalar (scalar data contained in vector data type) + // + inline const Quat operator /( floatInVec scalar ) const; + + // Perform compound assignment and addition with a quaternion + // + inline Quat & operator +=( Quat quat ); + + // Perform compound assignment and subtraction by a quaternion + // + inline Quat & operator -=( Quat quat ); + + // Perform compound assignment and multiplication by a quaternion + // + inline Quat & operator *=( Quat quat ); + + // Perform compound assignment and multiplication by a scalar + // + inline Quat & operator *=( float scalar ); + + // Perform compound assignment and division by a scalar + // + inline Quat & operator /=( float scalar ); + + // Perform compound assignment and multiplication by a scalar (scalar data contained in vector data type) + // + inline Quat & operator *=( floatInVec scalar ); + + // Perform compound assignment and division by a scalar (scalar data contained in vector data type) + // + inline Quat & operator /=( floatInVec scalar ); + + // Negate all elements of a quaternion + // + inline const Quat operator -( ) const; + + // Construct an identity quaternion + // + static inline const Quat identity( ); + + // Construct a quaternion to rotate between two unit-length 3-D vectors + // NOTE: + // The result is unpredictable if unitVec0 and unitVec1 point in opposite directions. + // + static inline const Quat rotation( Vector3 unitVec0, Vector3 unitVec1 ); + + // Construct a quaternion to rotate around a unit-length 3-D vector + // + static inline const Quat rotation( float radians, Vector3 unitVec ); + + // Construct a quaternion to rotate around a unit-length 3-D vector (scalar data contained in vector data type) + // + static inline const Quat rotation( floatInVec radians, Vector3 unitVec ); + + // Construct a quaternion to rotate around the x axis + // + static inline const Quat rotationX( float radians ); + + // Construct a quaternion to rotate around the y axis + // + static inline const Quat rotationY( float radians ); + + // Construct a quaternion to rotate around the z axis + // + static inline const Quat rotationZ( float radians ); + + // Construct a quaternion to rotate around the x axis (scalar data contained in vector data type) + // + static inline const Quat rotationX( floatInVec radians ); + + // Construct a quaternion to rotate around the y axis (scalar data contained in vector data type) + // + static inline const Quat rotationY( floatInVec radians ); + + // Construct a quaternion to rotate around the z axis (scalar data contained in vector data type) + // + static inline const Quat rotationZ( floatInVec radians ); + +}; + +// Multiply a quaternion by a scalar +// +inline const Quat operator *( float scalar, Quat quat ); + +// Multiply a quaternion by a scalar (scalar data contained in vector data type) +// +inline const Quat operator *( floatInVec scalar, Quat quat ); + +// Compute the conjugate of a quaternion +// +inline const Quat conj( Quat quat ); + +// Use a unit-length quaternion to rotate a 3-D vector +// +inline const Vector3 rotate( Quat unitQuat, Vector3 vec ); + +// Compute the dot product of two quaternions +// +inline const floatInVec dot( Quat quat0, Quat quat1 ); + +// Compute the norm of a quaternion +// +inline const floatInVec norm( Quat quat ); + +// Compute the length of a quaternion +// +inline const floatInVec length( Quat quat ); + +// Normalize a quaternion +// NOTE: +// The result is unpredictable when all elements of quat are at or near zero. +// +inline const Quat normalize( Quat quat ); + +// Linear interpolation between two quaternions +// NOTE: +// Does not clamp t between 0 and 1. +// +inline const Quat lerp( float t, Quat quat0, Quat quat1 ); + +// Linear interpolation between two quaternions (scalar data contained in vector data type) +// NOTE: +// Does not clamp t between 0 and 1. +// +inline const Quat lerp( floatInVec t, Quat quat0, Quat quat1 ); + +// Spherical linear interpolation between two quaternions +// NOTE: +// Interpolates along the shortest path between orientations. +// Does not clamp t between 0 and 1. +// +inline const Quat slerp( float t, Quat unitQuat0, Quat unitQuat1 ); + +// Spherical linear interpolation between two quaternions (scalar data contained in vector data type) +// NOTE: +// Interpolates along the shortest path between orientations. +// Does not clamp t between 0 and 1. +// +inline const Quat slerp( floatInVec t, Quat unitQuat0, Quat unitQuat1 ); + +// Spherical quadrangle interpolation +// +inline const Quat squad( float t, Quat unitQuat0, Quat unitQuat1, Quat unitQuat2, Quat unitQuat3 ); + +// Spherical quadrangle interpolation (scalar data contained in vector data type) +// +inline const Quat squad( floatInVec t, Quat unitQuat0, Quat unitQuat1, Quat unitQuat2, Quat unitQuat3 ); + +// Conditionally select between two quaternions +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// However, the transfer of select1 to a VMX register may use more processing time than a branch. +// Use the boolInVec version for better performance. +// +inline const Quat select( Quat quat0, Quat quat1, bool select1 ); + +// Conditionally select between two quaternions (scalar data contained in vector data type) +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// +inline const Quat select( Quat quat0, Quat quat1, boolInVec select1 ); + +#ifdef _VECTORMATH_DEBUG + +// Print a quaternion +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( Quat quat ); + +// Print a quaternion and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( Quat quat, const char * name ); + +#endif + +// A 3x3 matrix in array-of-structures format +// +class Matrix3 +{ + Vector3 mCol0; + Vector3 mCol1; + Vector3 mCol2; + +public: + // Default constructor; does no initialization + // + inline Matrix3( ) { }; + + // Copy a 3x3 matrix + // + inline Matrix3( const Matrix3 & mat ); + + // Construct a 3x3 matrix containing the specified columns + // + inline Matrix3( Vector3 col0, Vector3 col1, Vector3 col2 ); + + // Construct a 3x3 rotation matrix from a unit-length quaternion + // + explicit inline Matrix3( Quat unitQuat ); + + // Set all elements of a 3x3 matrix to the same scalar value + // + explicit inline Matrix3( float scalar ); + + // Set all elements of a 3x3 matrix to the same scalar value (scalar data contained in vector data type) + // + explicit inline Matrix3( floatInVec scalar ); + + // Assign one 3x3 matrix to another + // + inline Matrix3 & operator =( const Matrix3 & mat ); + + // Set column 0 of a 3x3 matrix + // + inline Matrix3 & setCol0( Vector3 col0 ); + + // Set column 1 of a 3x3 matrix + // + inline Matrix3 & setCol1( Vector3 col1 ); + + // Set column 2 of a 3x3 matrix + // + inline Matrix3 & setCol2( Vector3 col2 ); + + // Get column 0 of a 3x3 matrix + // + inline const Vector3 getCol0( ) const; + + // Get column 1 of a 3x3 matrix + // + inline const Vector3 getCol1( ) const; + + // Get column 2 of a 3x3 matrix + // + inline const Vector3 getCol2( ) const; + + // Set the column of a 3x3 matrix referred to by the specified index + // + inline Matrix3 & setCol( int col, Vector3 vec ); + + // Set the row of a 3x3 matrix referred to by the specified index + // + inline Matrix3 & setRow( int row, Vector3 vec ); + + // Get the column of a 3x3 matrix referred to by the specified index + // + inline const Vector3 getCol( int col ) const; + + // Get the row of a 3x3 matrix referred to by the specified index + // + inline const Vector3 getRow( int row ) const; + + // Subscripting operator to set or get a column + // + inline Vector3 & operator []( int col ); + + // Subscripting operator to get a column + // + inline const Vector3 operator []( int col ) const; + + // Set the element of a 3x3 matrix referred to by column and row indices + // + inline Matrix3 & setElem( int col, int row, float val ); + + // Set the element of a 3x3 matrix referred to by column and row indices (scalar data contained in vector data type) + // + inline Matrix3 & setElem( int col, int row, floatInVec val ); + + // Get the element of a 3x3 matrix referred to by column and row indices + // + inline const floatInVec getElem( int col, int row ) const; + + // Add two 3x3 matrices + // + inline const Matrix3 operator +( const Matrix3 & mat ) const; + + // Subtract a 3x3 matrix from another 3x3 matrix + // + inline const Matrix3 operator -( const Matrix3 & mat ) const; + + // Negate all elements of a 3x3 matrix + // + inline const Matrix3 operator -( ) const; + + // Multiply a 3x3 matrix by a scalar + // + inline const Matrix3 operator *( float scalar ) const; + + // Multiply a 3x3 matrix by a scalar (scalar data contained in vector data type) + // + inline const Matrix3 operator *( floatInVec scalar ) const; + + // Multiply a 3x3 matrix by a 3-D vector + // + inline const Vector3 operator *( Vector3 vec ) const; + + // Multiply two 3x3 matrices + // + inline const Matrix3 operator *( const Matrix3 & mat ) const; + + // Perform compound assignment and addition with a 3x3 matrix + // + inline Matrix3 & operator +=( const Matrix3 & mat ); + + // Perform compound assignment and subtraction by a 3x3 matrix + // + inline Matrix3 & operator -=( const Matrix3 & mat ); + + // Perform compound assignment and multiplication by a scalar + // + inline Matrix3 & operator *=( float scalar ); + + // Perform compound assignment and multiplication by a scalar (scalar data contained in vector data type) + // + inline Matrix3 & operator *=( floatInVec scalar ); + + // Perform compound assignment and multiplication by a 3x3 matrix + // + inline Matrix3 & operator *=( const Matrix3 & mat ); + + // Construct an identity 3x3 matrix + // + static inline const Matrix3 identity( ); + + // Construct a 3x3 matrix to rotate around the x axis + // + static inline const Matrix3 rotationX( float radians ); + + // Construct a 3x3 matrix to rotate around the y axis + // + static inline const Matrix3 rotationY( float radians ); + + // Construct a 3x3 matrix to rotate around the z axis + // + static inline const Matrix3 rotationZ( float radians ); + + // Construct a 3x3 matrix to rotate around the x axis (scalar data contained in vector data type) + // + static inline const Matrix3 rotationX( floatInVec radians ); + + // Construct a 3x3 matrix to rotate around the y axis (scalar data contained in vector data type) + // + static inline const Matrix3 rotationY( floatInVec radians ); + + // Construct a 3x3 matrix to rotate around the z axis (scalar data contained in vector data type) + // + static inline const Matrix3 rotationZ( floatInVec radians ); + + // Construct a 3x3 matrix to rotate around the x, y, and z axes + // + static inline const Matrix3 rotationZYX( Vector3 radiansXYZ ); + + // Construct a 3x3 matrix to rotate around a unit-length 3-D vector + // + static inline const Matrix3 rotation( float radians, Vector3 unitVec ); + + // Construct a 3x3 matrix to rotate around a unit-length 3-D vector (scalar data contained in vector data type) + // + static inline const Matrix3 rotation( floatInVec radians, Vector3 unitVec ); + + // Construct a rotation matrix from a unit-length quaternion + // + static inline const Matrix3 rotation( Quat unitQuat ); + + // Construct a 3x3 matrix to perform scaling + // + static inline const Matrix3 scale( Vector3 scaleVec ); + +}; +// Multiply a 3x3 matrix by a scalar +// +inline const Matrix3 operator *( float scalar, const Matrix3 & mat ); + +// Multiply a 3x3 matrix by a scalar (scalar data contained in vector data type) +// +inline const Matrix3 operator *( floatInVec scalar, const Matrix3 & mat ); + +// Append (post-multiply) a scale transformation to a 3x3 matrix +// NOTE: +// Faster than creating and multiplying a scale transformation matrix. +// +inline const Matrix3 appendScale( const Matrix3 & mat, Vector3 scaleVec ); + +// Prepend (pre-multiply) a scale transformation to a 3x3 matrix +// NOTE: +// Faster than creating and multiplying a scale transformation matrix. +// +inline const Matrix3 prependScale( Vector3 scaleVec, const Matrix3 & mat ); + +// Multiply two 3x3 matrices per element +// +inline const Matrix3 mulPerElem( const Matrix3 & mat0, const Matrix3 & mat1 ); + +// Compute the absolute value of a 3x3 matrix per element +// +inline const Matrix3 absPerElem( const Matrix3 & mat ); + +// Transpose of a 3x3 matrix +// +inline const Matrix3 transpose( const Matrix3 & mat ); + +// Compute the inverse of a 3x3 matrix +// NOTE: +// Result is unpredictable when the determinant of mat is equal to or near 0. +// +inline const Matrix3 inverse( const Matrix3 & mat ); + +// Determinant of a 3x3 matrix +// +inline const floatInVec determinant( const Matrix3 & mat ); + +// Conditionally select between two 3x3 matrices +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// However, the transfer of select1 to a VMX register may use more processing time than a branch. +// Use the boolInVec version for better performance. +// +inline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, bool select1 ); + +// Conditionally select between two 3x3 matrices (scalar data contained in vector data type) +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// +inline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, boolInVec select1 ); + +#ifdef _VECTORMATH_DEBUG + +// Print a 3x3 matrix +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Matrix3 & mat ); + +// Print a 3x3 matrix and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Matrix3 & mat, const char * name ); + +#endif + +// A 4x4 matrix in array-of-structures format +// +class Matrix4 +{ + Vector4 mCol0; + Vector4 mCol1; + Vector4 mCol2; + Vector4 mCol3; + +public: + // Default constructor; does no initialization + // + inline Matrix4( ) { }; + + // Copy a 4x4 matrix + // + inline Matrix4( const Matrix4 & mat ); + + // Construct a 4x4 matrix containing the specified columns + // + inline Matrix4( Vector4 col0, Vector4 col1, Vector4 col2, Vector4 col3 ); + + // Construct a 4x4 matrix from a 3x4 transformation matrix + // + explicit inline Matrix4( const Transform3 & mat ); + + // Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector + // + inline Matrix4( const Matrix3 & mat, Vector3 translateVec ); + + // Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector + // + inline Matrix4( Quat unitQuat, Vector3 translateVec ); + + // Set all elements of a 4x4 matrix to the same scalar value + // + explicit inline Matrix4( float scalar ); + + // Set all elements of a 4x4 matrix to the same scalar value (scalar data contained in vector data type) + // + explicit inline Matrix4( floatInVec scalar ); + + // Assign one 4x4 matrix to another + // + inline Matrix4 & operator =( const Matrix4 & mat ); + + // Set the upper-left 3x3 submatrix + // NOTE: + // This function does not change the bottom row elements. + // + inline Matrix4 & setUpper3x3( const Matrix3 & mat3 ); + + // Get the upper-left 3x3 submatrix of a 4x4 matrix + // + inline const Matrix3 getUpper3x3( ) const; + + // Set translation component + // NOTE: + // This function does not change the bottom row elements. + // + inline Matrix4 & setTranslation( Vector3 translateVec ); + + // Get the translation component of a 4x4 matrix + // + inline const Vector3 getTranslation( ) const; + + // Set column 0 of a 4x4 matrix + // + inline Matrix4 & setCol0( Vector4 col0 ); + + // Set column 1 of a 4x4 matrix + // + inline Matrix4 & setCol1( Vector4 col1 ); + + // Set column 2 of a 4x4 matrix + // + inline Matrix4 & setCol2( Vector4 col2 ); + + // Set column 3 of a 4x4 matrix + // + inline Matrix4 & setCol3( Vector4 col3 ); + + // Get column 0 of a 4x4 matrix + // + inline const Vector4 getCol0( ) const; + + // Get column 1 of a 4x4 matrix + // + inline const Vector4 getCol1( ) const; + + // Get column 2 of a 4x4 matrix + // + inline const Vector4 getCol2( ) const; + + // Get column 3 of a 4x4 matrix + // + inline const Vector4 getCol3( ) const; + + // Set the column of a 4x4 matrix referred to by the specified index + // + inline Matrix4 & setCol( int col, Vector4 vec ); + + // Set the row of a 4x4 matrix referred to by the specified index + // + inline Matrix4 & setRow( int row, Vector4 vec ); + + // Get the column of a 4x4 matrix referred to by the specified index + // + inline const Vector4 getCol( int col ) const; + + // Get the row of a 4x4 matrix referred to by the specified index + // + inline const Vector4 getRow( int row ) const; + + // Subscripting operator to set or get a column + // + inline Vector4 & operator []( int col ); + + // Subscripting operator to get a column + // + inline const Vector4 operator []( int col ) const; + + // Set the element of a 4x4 matrix referred to by column and row indices + // + inline Matrix4 & setElem( int col, int row, float val ); + + // Set the element of a 4x4 matrix referred to by column and row indices (scalar data contained in vector data type) + // + inline Matrix4 & setElem( int col, int row, floatInVec val ); + + // Get the element of a 4x4 matrix referred to by column and row indices + // + inline const floatInVec getElem( int col, int row ) const; + + // Add two 4x4 matrices + // + inline const Matrix4 operator +( const Matrix4 & mat ) const; + + // Subtract a 4x4 matrix from another 4x4 matrix + // + inline const Matrix4 operator -( const Matrix4 & mat ) const; + + // Negate all elements of a 4x4 matrix + // + inline const Matrix4 operator -( ) const; + + // Multiply a 4x4 matrix by a scalar + // + inline const Matrix4 operator *( float scalar ) const; + + // Multiply a 4x4 matrix by a scalar (scalar data contained in vector data type) + // + inline const Matrix4 operator *( floatInVec scalar ) const; + + // Multiply a 4x4 matrix by a 4-D vector + // + inline const Vector4 operator *( Vector4 vec ) const; + + // Multiply a 4x4 matrix by a 3-D vector + // + inline const Vector4 operator *( Vector3 vec ) const; + + // Multiply a 4x4 matrix by a 3-D point + // + inline const Vector4 operator *( Point3 pnt ) const; + + // Multiply two 4x4 matrices + // + inline const Matrix4 operator *( const Matrix4 & mat ) const; + + // Multiply a 4x4 matrix by a 3x4 transformation matrix + // + inline const Matrix4 operator *( const Transform3 & tfrm ) const; + + // Perform compound assignment and addition with a 4x4 matrix + // + inline Matrix4 & operator +=( const Matrix4 & mat ); + + // Perform compound assignment and subtraction by a 4x4 matrix + // + inline Matrix4 & operator -=( const Matrix4 & mat ); + + // Perform compound assignment and multiplication by a scalar + // + inline Matrix4 & operator *=( float scalar ); + + // Perform compound assignment and multiplication by a scalar (scalar data contained in vector data type) + // + inline Matrix4 & operator *=( floatInVec scalar ); + + // Perform compound assignment and multiplication by a 4x4 matrix + // + inline Matrix4 & operator *=( const Matrix4 & mat ); + + // Perform compound assignment and multiplication by a 3x4 transformation matrix + // + inline Matrix4 & operator *=( const Transform3 & tfrm ); + + // Construct an identity 4x4 matrix + // + static inline const Matrix4 identity( ); + + // Construct a 4x4 matrix to rotate around the x axis + // + static inline const Matrix4 rotationX( float radians ); + + // Construct a 4x4 matrix to rotate around the y axis + // + static inline const Matrix4 rotationY( float radians ); + + // Construct a 4x4 matrix to rotate around the z axis + // + static inline const Matrix4 rotationZ( float radians ); + + // Construct a 4x4 matrix to rotate around the x axis (scalar data contained in vector data type) + // + static inline const Matrix4 rotationX( floatInVec radians ); + + // Construct a 4x4 matrix to rotate around the y axis (scalar data contained in vector data type) + // + static inline const Matrix4 rotationY( floatInVec radians ); + + // Construct a 4x4 matrix to rotate around the z axis (scalar data contained in vector data type) + // + static inline const Matrix4 rotationZ( floatInVec radians ); + + // Construct a 4x4 matrix to rotate around the x, y, and z axes + // + static inline const Matrix4 rotationZYX( Vector3 radiansXYZ ); + + // Construct a 4x4 matrix to rotate around a unit-length 3-D vector + // + static inline const Matrix4 rotation( float radians, Vector3 unitVec ); + + // Construct a 4x4 matrix to rotate around a unit-length 3-D vector (scalar data contained in vector data type) + // + static inline const Matrix4 rotation( floatInVec radians, Vector3 unitVec ); + + // Construct a rotation matrix from a unit-length quaternion + // + static inline const Matrix4 rotation( Quat unitQuat ); + + // Construct a 4x4 matrix to perform scaling + // + static inline const Matrix4 scale( Vector3 scaleVec ); + + // Construct a 4x4 matrix to perform translation + // + static inline const Matrix4 translation( Vector3 translateVec ); + + // Construct viewing matrix based on eye position, position looked at, and up direction + // + static inline const Matrix4 lookAt( Point3 eyePos, Point3 lookAtPos, Vector3 upVec ); + + // Construct a perspective projection matrix + // + static inline const Matrix4 perspective( float fovyRadians, float aspect, float zNear, float zFar ); + + // Construct a perspective projection matrix based on frustum + // + static inline const Matrix4 frustum( float left, float right, float bottom, float top, float zNear, float zFar ); + + // Construct an orthographic projection matrix + // + static inline const Matrix4 orthographic( float left, float right, float bottom, float top, float zNear, float zFar ); + +}; +// Multiply a 4x4 matrix by a scalar +// +inline const Matrix4 operator *( float scalar, const Matrix4 & mat ); + +// Multiply a 4x4 matrix by a scalar (scalar data contained in vector data type) +// +inline const Matrix4 operator *( floatInVec scalar, const Matrix4 & mat ); + +// Append (post-multiply) a scale transformation to a 4x4 matrix +// NOTE: +// Faster than creating and multiplying a scale transformation matrix. +// +inline const Matrix4 appendScale( const Matrix4 & mat, Vector3 scaleVec ); + +// Prepend (pre-multiply) a scale transformation to a 4x4 matrix +// NOTE: +// Faster than creating and multiplying a scale transformation matrix. +// +inline const Matrix4 prependScale( Vector3 scaleVec, const Matrix4 & mat ); + +// Multiply two 4x4 matrices per element +// +inline const Matrix4 mulPerElem( const Matrix4 & mat0, const Matrix4 & mat1 ); + +// Compute the absolute value of a 4x4 matrix per element +// +inline const Matrix4 absPerElem( const Matrix4 & mat ); + +// Transpose of a 4x4 matrix +// +inline const Matrix4 transpose( const Matrix4 & mat ); + +// Compute the inverse of a 4x4 matrix +// NOTE: +// Result is unpredictable when the determinant of mat is equal to or near 0. +// +inline const Matrix4 inverse( const Matrix4 & mat ); + +// Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix +// NOTE: +// This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. The result is unpredictable when the determinant of mat is equal to or near 0. +// +inline const Matrix4 affineInverse( const Matrix4 & mat ); + +// Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix +// NOTE: +// This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. +// +inline const Matrix4 orthoInverse( const Matrix4 & mat ); + +// Determinant of a 4x4 matrix +// +inline const floatInVec determinant( const Matrix4 & mat ); + +// Conditionally select between two 4x4 matrices +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// However, the transfer of select1 to a VMX register may use more processing time than a branch. +// Use the boolInVec version for better performance. +// +inline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, bool select1 ); + +// Conditionally select between two 4x4 matrices (scalar data contained in vector data type) +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// +inline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, boolInVec select1 ); + +#ifdef _VECTORMATH_DEBUG + +// Print a 4x4 matrix +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Matrix4 & mat ); + +// Print a 4x4 matrix and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Matrix4 & mat, const char * name ); + +#endif + +// A 3x4 transformation matrix in array-of-structures format +// +class Transform3 +{ + Vector3 mCol0; + Vector3 mCol1; + Vector3 mCol2; + Vector3 mCol3; + +public: + // Default constructor; does no initialization + // + inline Transform3( ) { }; + + // Copy a 3x4 transformation matrix + // + inline Transform3( const Transform3 & tfrm ); + + // Construct a 3x4 transformation matrix containing the specified columns + // + inline Transform3( Vector3 col0, Vector3 col1, Vector3 col2, Vector3 col3 ); + + // Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector + // + inline Transform3( const Matrix3 & tfrm, Vector3 translateVec ); + + // Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector + // + inline Transform3( Quat unitQuat, Vector3 translateVec ); + + // Set all elements of a 3x4 transformation matrix to the same scalar value + // + explicit inline Transform3( float scalar ); + + // Set all elements of a 3x4 transformation matrix to the same scalar value (scalar data contained in vector data type) + // + explicit inline Transform3( floatInVec scalar ); + + // Assign one 3x4 transformation matrix to another + // + inline Transform3 & operator =( const Transform3 & tfrm ); + + // Set the upper-left 3x3 submatrix + // + inline Transform3 & setUpper3x3( const Matrix3 & mat3 ); + + // Get the upper-left 3x3 submatrix of a 3x4 transformation matrix + // + inline const Matrix3 getUpper3x3( ) const; + + // Set translation component + // + inline Transform3 & setTranslation( Vector3 translateVec ); + + // Get the translation component of a 3x4 transformation matrix + // + inline const Vector3 getTranslation( ) const; + + // Set column 0 of a 3x4 transformation matrix + // + inline Transform3 & setCol0( Vector3 col0 ); + + // Set column 1 of a 3x4 transformation matrix + // + inline Transform3 & setCol1( Vector3 col1 ); + + // Set column 2 of a 3x4 transformation matrix + // + inline Transform3 & setCol2( Vector3 col2 ); + + // Set column 3 of a 3x4 transformation matrix + // + inline Transform3 & setCol3( Vector3 col3 ); + + // Get column 0 of a 3x4 transformation matrix + // + inline const Vector3 getCol0( ) const; + + // Get column 1 of a 3x4 transformation matrix + // + inline const Vector3 getCol1( ) const; + + // Get column 2 of a 3x4 transformation matrix + // + inline const Vector3 getCol2( ) const; + + // Get column 3 of a 3x4 transformation matrix + // + inline const Vector3 getCol3( ) const; + + // Set the column of a 3x4 transformation matrix referred to by the specified index + // + inline Transform3 & setCol( int col, Vector3 vec ); + + // Set the row of a 3x4 transformation matrix referred to by the specified index + // + inline Transform3 & setRow( int row, Vector4 vec ); + + // Get the column of a 3x4 transformation matrix referred to by the specified index + // + inline const Vector3 getCol( int col ) const; + + // Get the row of a 3x4 transformation matrix referred to by the specified index + // + inline const Vector4 getRow( int row ) const; + + // Subscripting operator to set or get a column + // + inline Vector3 & operator []( int col ); + + // Subscripting operator to get a column + // + inline const Vector3 operator []( int col ) const; + + // Set the element of a 3x4 transformation matrix referred to by column and row indices + // + inline Transform3 & setElem( int col, int row, float val ); + + // Set the element of a 3x4 transformation matrix referred to by column and row indices (scalar data contained in vector data type) + // + inline Transform3 & setElem( int col, int row, floatInVec val ); + + // Get the element of a 3x4 transformation matrix referred to by column and row indices + // + inline const floatInVec getElem( int col, int row ) const; + + // Multiply a 3x4 transformation matrix by a 3-D vector + // + inline const Vector3 operator *( Vector3 vec ) const; + + // Multiply a 3x4 transformation matrix by a 3-D point + // + inline const Point3 operator *( Point3 pnt ) const; + + // Multiply two 3x4 transformation matrices + // + inline const Transform3 operator *( const Transform3 & tfrm ) const; + + // Perform compound assignment and multiplication by a 3x4 transformation matrix + // + inline Transform3 & operator *=( const Transform3 & tfrm ); + + // Construct an identity 3x4 transformation matrix + // + static inline const Transform3 identity( ); + + // Construct a 3x4 transformation matrix to rotate around the x axis + // + static inline const Transform3 rotationX( float radians ); + + // Construct a 3x4 transformation matrix to rotate around the y axis + // + static inline const Transform3 rotationY( float radians ); + + // Construct a 3x4 transformation matrix to rotate around the z axis + // + static inline const Transform3 rotationZ( float radians ); + + // Construct a 3x4 transformation matrix to rotate around the x axis (scalar data contained in vector data type) + // + static inline const Transform3 rotationX( floatInVec radians ); + + // Construct a 3x4 transformation matrix to rotate around the y axis (scalar data contained in vector data type) + // + static inline const Transform3 rotationY( floatInVec radians ); + + // Construct a 3x4 transformation matrix to rotate around the z axis (scalar data contained in vector data type) + // + static inline const Transform3 rotationZ( floatInVec radians ); + + // Construct a 3x4 transformation matrix to rotate around the x, y, and z axes + // + static inline const Transform3 rotationZYX( Vector3 radiansXYZ ); + + // Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector + // + static inline const Transform3 rotation( float radians, Vector3 unitVec ); + + // Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector (scalar data contained in vector data type) + // + static inline const Transform3 rotation( floatInVec radians, Vector3 unitVec ); + + // Construct a rotation matrix from a unit-length quaternion + // + static inline const Transform3 rotation( Quat unitQuat ); + + // Construct a 3x4 transformation matrix to perform scaling + // + static inline const Transform3 scale( Vector3 scaleVec ); + + // Construct a 3x4 transformation matrix to perform translation + // + static inline const Transform3 translation( Vector3 translateVec ); + +}; +// Append (post-multiply) a scale transformation to a 3x4 transformation matrix +// NOTE: +// Faster than creating and multiplying a scale transformation matrix. +// +inline const Transform3 appendScale( const Transform3 & tfrm, Vector3 scaleVec ); + +// Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix +// NOTE: +// Faster than creating and multiplying a scale transformation matrix. +// +inline const Transform3 prependScale( Vector3 scaleVec, const Transform3 & tfrm ); + +// Multiply two 3x4 transformation matrices per element +// +inline const Transform3 mulPerElem( const Transform3 & tfrm0, const Transform3 & tfrm1 ); + +// Compute the absolute value of a 3x4 transformation matrix per element +// +inline const Transform3 absPerElem( const Transform3 & tfrm ); + +// Inverse of a 3x4 transformation matrix +// NOTE: +// Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0. +// +inline const Transform3 inverse( const Transform3 & tfrm ); + +// Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix +// NOTE: +// This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions. +// +inline const Transform3 orthoInverse( const Transform3 & tfrm ); + +// Conditionally select between two 3x4 transformation matrices +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// However, the transfer of select1 to a VMX register may use more processing time than a branch. +// Use the boolInVec version for better performance. +// +inline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, bool select1 ); + +// Conditionally select between two 3x4 transformation matrices (scalar data contained in vector data type) +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// +inline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, boolInVec select1 ); + +#ifdef _VECTORMATH_DEBUG + +// Print a 3x4 transformation matrix +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Transform3 & tfrm ); + +// Print a 3x4 transformation matrix and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Transform3 & tfrm, const char * name ); + +#endif + +} // namespace Aos +} // namespace Vectormath + +#include "vec_aos.h" +#include "quat_aos.h" +#include "mat_aos.h" + +#endif diff --git a/vectormathlibrary/include/vectormath/ppu/cpp/vectormath_soa.h b/vectormathlibrary/include/vectormath/ppu/cpp/vectormath_soa.h new file mode 100644 index 000000000..65932d803 --- /dev/null +++ b/vectormathlibrary/include/vectormath/ppu/cpp/vectormath_soa.h @@ -0,0 +1,1919 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_SOA_CPP_PPU_H +#define _VECTORMATH_SOA_CPP_PPU_H + +#include <math.h> +#include <altivec.h> +#include "vectormath_aos.h" + +#ifdef _VECTORMATH_DEBUG +#include <stdio.h> +#endif + +namespace Vectormath { + +namespace Soa { + +//----------------------------------------------------------------------------- +// Forward Declarations +// + +class Vector3; +class Vector4; +class Point3; +class Quat; +class Matrix3; +class Matrix4; +class Transform3; + +// A set of four 3-D vectors in structure-of-arrays format +// +class Vector3 +{ + typedef vec_float4 vec_float4_t; + vec_float4 mX; + vec_float4 mY; + vec_float4 mZ; + +public: + // Default constructor; does no initialization + // + inline Vector3( ) { }; + + // Copy a 3-D vector + // + inline Vector3( const Vector3 & vec ); + + // Construct a 3-D vector from x, y, and z elements + // + inline Vector3( vec_float4 x, vec_float4 y, vec_float4 z ); + + // Copy elements from a 3-D point into a 3-D vector + // + explicit inline Vector3( const Point3 & pnt ); + + // Set all elements of a 3-D vector to the same scalar value + // + explicit inline Vector3( vec_float4 scalar ); + + // Replicate an AoS 3-D vector + // + inline Vector3( Aos::Vector3 vec ); + + // Insert four AoS 3-D vectors + // + inline Vector3( Aos::Vector3 vec0, Aos::Vector3 vec1, Aos::Vector3 vec2, Aos::Vector3 vec3 ); + + // Extract four AoS 3-D vectors + // + inline void get4Aos( Aos::Vector3 & result0, Aos::Vector3 & result1, Aos::Vector3 & result2, Aos::Vector3 & result3 ) const; + + // Assign one 3-D vector to another + // + inline Vector3 & operator =( const Vector3 & vec ); + + // Set the x element of a 3-D vector + // + inline Vector3 & setX( vec_float4 x ); + + // Set the y element of a 3-D vector + // + inline Vector3 & setY( vec_float4 y ); + + // Set the z element of a 3-D vector + // + inline Vector3 & setZ( vec_float4 z ); + + // Get the x element of a 3-D vector + // + inline vec_float4 getX( ) const; + + // Get the y element of a 3-D vector + // + inline vec_float4 getY( ) const; + + // Get the z element of a 3-D vector + // + inline vec_float4 getZ( ) const; + + // Set an x, y, or z element of a 3-D vector by index + // + inline Vector3 & setElem( int idx, vec_float4 value ); + + // Get an x, y, or z element of a 3-D vector by index + // + inline vec_float4 getElem( int idx ) const; + + // Subscripting operator to set or get an element + // + inline vec_float4_t & operator []( int idx ); + + // Subscripting operator to get an element + // + inline vec_float4 operator []( int idx ) const; + + // Add two 3-D vectors + // + inline const Vector3 operator +( const Vector3 & vec ) const; + + // Subtract a 3-D vector from another 3-D vector + // + inline const Vector3 operator -( const Vector3 & vec ) const; + + // Add a 3-D vector to a 3-D point + // + inline const Point3 operator +( const Point3 & pnt ) const; + + // Multiply a 3-D vector by a scalar + // + inline const Vector3 operator *( vec_float4 scalar ) const; + + // Divide a 3-D vector by a scalar + // + inline const Vector3 operator /( vec_float4 scalar ) const; + + // Perform compound assignment and addition with a 3-D vector + // + inline Vector3 & operator +=( const Vector3 & vec ); + + // Perform compound assignment and subtraction by a 3-D vector + // + inline Vector3 & operator -=( const Vector3 & vec ); + + // Perform compound assignment and multiplication by a scalar + // + inline Vector3 & operator *=( vec_float4 scalar ); + + // Perform compound assignment and division by a scalar + // + inline Vector3 & operator /=( vec_float4 scalar ); + + // Negate all elements of a 3-D vector + // + inline const Vector3 operator -( ) const; + + // Construct x axis + // + static inline const Vector3 xAxis( ); + + // Construct y axis + // + static inline const Vector3 yAxis( ); + + // Construct z axis + // + static inline const Vector3 zAxis( ); + +}; + +// Multiply a 3-D vector by a scalar +// +inline const Vector3 operator *( vec_float4 scalar, const Vector3 & vec ); + +// Multiply two 3-D vectors per element +// +inline const Vector3 mulPerElem( const Vector3 & vec0, const Vector3 & vec1 ); + +// Divide two 3-D vectors per element +// NOTE: +// Floating-point behavior matches standard library function divf4. +// +inline const Vector3 divPerElem( const Vector3 & vec0, const Vector3 & vec1 ); + +// Compute the reciprocal of a 3-D vector per element +// NOTE: +// Floating-point behavior matches standard library function recipf4. +// +inline const Vector3 recipPerElem( const Vector3 & vec ); + +// Compute the square root of a 3-D vector per element +// NOTE: +// Floating-point behavior matches standard library function sqrtf4. +// +inline const Vector3 sqrtPerElem( const Vector3 & vec ); + +// Compute the reciprocal square root of a 3-D vector per element +// NOTE: +// Floating-point behavior matches standard library function rsqrtf4. +// +inline const Vector3 rsqrtPerElem( const Vector3 & vec ); + +// Compute the absolute value of a 3-D vector per element +// +inline const Vector3 absPerElem( const Vector3 & vec ); + +// Copy sign from one 3-D vector to another, per element +// +inline const Vector3 copySignPerElem( const Vector3 & vec0, const Vector3 & vec1 ); + +// Maximum of two 3-D vectors per element +// +inline const Vector3 maxPerElem( const Vector3 & vec0, const Vector3 & vec1 ); + +// Minimum of two 3-D vectors per element +// +inline const Vector3 minPerElem( const Vector3 & vec0, const Vector3 & vec1 ); + +// Maximum element of a 3-D vector +// +inline vec_float4 maxElem( const Vector3 & vec ); + +// Minimum element of a 3-D vector +// +inline vec_float4 minElem( const Vector3 & vec ); + +// Compute the sum of all elements of a 3-D vector +// +inline vec_float4 sum( const Vector3 & vec ); + +// Compute the dot product of two 3-D vectors +// +inline vec_float4 dot( const Vector3 & vec0, const Vector3 & vec1 ); + +// Compute the square of the length of a 3-D vector +// +inline vec_float4 lengthSqr( const Vector3 & vec ); + +// Compute the length of a 3-D vector +// +inline vec_float4 length( const Vector3 & vec ); + +// Normalize a 3-D vector +// NOTE: +// The result is unpredictable when all elements of vec are at or near zero. +// +inline const Vector3 normalize( const Vector3 & vec ); + +// Compute cross product of two 3-D vectors +// +inline const Vector3 cross( const Vector3 & vec0, const Vector3 & vec1 ); + +// Outer product of two 3-D vectors +// +inline const Matrix3 outer( const Vector3 & vec0, const Vector3 & vec1 ); + +// Pre-multiply a row vector by a 3x3 matrix +// +inline const Vector3 rowMul( const Vector3 & vec, const Matrix3 & mat ); + +// Cross-product matrix of a 3-D vector +// +inline const Matrix3 crossMatrix( const Vector3 & vec ); + +// Create cross-product matrix and multiply +// NOTE: +// Faster than separately creating a cross-product matrix and multiplying. +// +inline const Matrix3 crossMatrixMul( const Vector3 & vec, const Matrix3 & mat ); + +// Linear interpolation between two 3-D vectors +// NOTE: +// Does not clamp t between 0 and 1. +// +inline const Vector3 lerp( vec_float4 t, const Vector3 & vec0, const Vector3 & vec1 ); + +// Spherical linear interpolation between two 3-D vectors +// NOTE: +// The result is unpredictable if the vectors point in opposite directions. +// Does not clamp t between 0 and 1. +// +inline const Vector3 slerp( vec_float4 t, const Vector3 & unitVec0, const Vector3 & unitVec1 ); + +// Conditionally select between two 3-D vectors +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// +inline const Vector3 select( const Vector3 & vec0, const Vector3 & vec1, vec_uint4 select1 ); + +// Load four three-float 3-D vectors, stored in three quadwords +// +inline void loadXYZArray( Vector3 & vec, const vec_float4 * threeQuads ); + +// Store four slots of an SoA 3-D vector in three quadwords +// +inline void storeXYZArray( const Vector3 & vec, vec_float4 * threeQuads ); + +// Store eight slots of two SoA 3-D vectors as half-floats +// +inline void storeHalfFloats( const Vector3 & vec0, const Vector3 & vec1, vec_ushort8 * threeQuads ); + +#ifdef _VECTORMATH_DEBUG + +// Print a 3-D vector +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Vector3 & vec ); + +// Print a 3-D vector and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Vector3 & vec, const char * name ); + +#endif + +// A set of four 4-D vectors in structure-of-arrays format +// +class Vector4 +{ + typedef vec_float4 vec_float4_t; + vec_float4 mX; + vec_float4 mY; + vec_float4 mZ; + vec_float4 mW; + +public: + // Default constructor; does no initialization + // + inline Vector4( ) { }; + + // Copy a 4-D vector + // + inline Vector4( const Vector4 & vec ); + + // Construct a 4-D vector from x, y, z, and w elements + // + inline Vector4( vec_float4 x, vec_float4 y, vec_float4 z, vec_float4 w ); + + // Construct a 4-D vector from a 3-D vector and a scalar + // + inline Vector4( const Vector3 & xyz, vec_float4 w ); + + // Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0 + // + explicit inline Vector4( const Vector3 & vec ); + + // Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1 + // + explicit inline Vector4( const Point3 & pnt ); + + // Copy elements from a quaternion into a 4-D vector + // + explicit inline Vector4( const Quat & quat ); + + // Set all elements of a 4-D vector to the same scalar value + // + explicit inline Vector4( vec_float4 scalar ); + + // Replicate an AoS 4-D vector + // + inline Vector4( Aos::Vector4 vec ); + + // Insert four AoS 4-D vectors + // + inline Vector4( Aos::Vector4 vec0, Aos::Vector4 vec1, Aos::Vector4 vec2, Aos::Vector4 vec3 ); + + // Extract four AoS 4-D vectors + // + inline void get4Aos( Aos::Vector4 & result0, Aos::Vector4 & result1, Aos::Vector4 & result2, Aos::Vector4 & result3 ) const; + + // Assign one 4-D vector to another + // + inline Vector4 & operator =( const Vector4 & vec ); + + // Set the x, y, and z elements of a 4-D vector + // NOTE: + // This function does not change the w element. + // + inline Vector4 & setXYZ( const Vector3 & vec ); + + // Get the x, y, and z elements of a 4-D vector + // + inline const Vector3 getXYZ( ) const; + + // Set the x element of a 4-D vector + // + inline Vector4 & setX( vec_float4 x ); + + // Set the y element of a 4-D vector + // + inline Vector4 & setY( vec_float4 y ); + + // Set the z element of a 4-D vector + // + inline Vector4 & setZ( vec_float4 z ); + + // Set the w element of a 4-D vector + // + inline Vector4 & setW( vec_float4 w ); + + // Get the x element of a 4-D vector + // + inline vec_float4 getX( ) const; + + // Get the y element of a 4-D vector + // + inline vec_float4 getY( ) const; + + // Get the z element of a 4-D vector + // + inline vec_float4 getZ( ) const; + + // Get the w element of a 4-D vector + // + inline vec_float4 getW( ) const; + + // Set an x, y, z, or w element of a 4-D vector by index + // + inline Vector4 & setElem( int idx, vec_float4 value ); + + // Get an x, y, z, or w element of a 4-D vector by index + // + inline vec_float4 getElem( int idx ) const; + + // Subscripting operator to set or get an element + // + inline vec_float4_t & operator []( int idx ); + + // Subscripting operator to get an element + // + inline vec_float4 operator []( int idx ) const; + + // Add two 4-D vectors + // + inline const Vector4 operator +( const Vector4 & vec ) const; + + // Subtract a 4-D vector from another 4-D vector + // + inline const Vector4 operator -( const Vector4 & vec ) const; + + // Multiply a 4-D vector by a scalar + // + inline const Vector4 operator *( vec_float4 scalar ) const; + + // Divide a 4-D vector by a scalar + // + inline const Vector4 operator /( vec_float4 scalar ) const; + + // Perform compound assignment and addition with a 4-D vector + // + inline Vector4 & operator +=( const Vector4 & vec ); + + // Perform compound assignment and subtraction by a 4-D vector + // + inline Vector4 & operator -=( const Vector4 & vec ); + + // Perform compound assignment and multiplication by a scalar + // + inline Vector4 & operator *=( vec_float4 scalar ); + + // Perform compound assignment and division by a scalar + // + inline Vector4 & operator /=( vec_float4 scalar ); + + // Negate all elements of a 4-D vector + // + inline const Vector4 operator -( ) const; + + // Construct x axis + // + static inline const Vector4 xAxis( ); + + // Construct y axis + // + static inline const Vector4 yAxis( ); + + // Construct z axis + // + static inline const Vector4 zAxis( ); + + // Construct w axis + // + static inline const Vector4 wAxis( ); + +}; + +// Multiply a 4-D vector by a scalar +// +inline const Vector4 operator *( vec_float4 scalar, const Vector4 & vec ); + +// Multiply two 4-D vectors per element +// +inline const Vector4 mulPerElem( const Vector4 & vec0, const Vector4 & vec1 ); + +// Divide two 4-D vectors per element +// NOTE: +// Floating-point behavior matches standard library function divf4. +// +inline const Vector4 divPerElem( const Vector4 & vec0, const Vector4 & vec1 ); + +// Compute the reciprocal of a 4-D vector per element +// NOTE: +// Floating-point behavior matches standard library function recipf4. +// +inline const Vector4 recipPerElem( const Vector4 & vec ); + +// Compute the square root of a 4-D vector per element +// NOTE: +// Floating-point behavior matches standard library function sqrtf4. +// +inline const Vector4 sqrtPerElem( const Vector4 & vec ); + +// Compute the reciprocal square root of a 4-D vector per element +// NOTE: +// Floating-point behavior matches standard library function rsqrtf4. +// +inline const Vector4 rsqrtPerElem( const Vector4 & vec ); + +// Compute the absolute value of a 4-D vector per element +// +inline const Vector4 absPerElem( const Vector4 & vec ); + +// Copy sign from one 4-D vector to another, per element +// +inline const Vector4 copySignPerElem( const Vector4 & vec0, const Vector4 & vec1 ); + +// Maximum of two 4-D vectors per element +// +inline const Vector4 maxPerElem( const Vector4 & vec0, const Vector4 & vec1 ); + +// Minimum of two 4-D vectors per element +// +inline const Vector4 minPerElem( const Vector4 & vec0, const Vector4 & vec1 ); + +// Maximum element of a 4-D vector +// +inline vec_float4 maxElem( const Vector4 & vec ); + +// Minimum element of a 4-D vector +// +inline vec_float4 minElem( const Vector4 & vec ); + +// Compute the sum of all elements of a 4-D vector +// +inline vec_float4 sum( const Vector4 & vec ); + +// Compute the dot product of two 4-D vectors +// +inline vec_float4 dot( const Vector4 & vec0, const Vector4 & vec1 ); + +// Compute the square of the length of a 4-D vector +// +inline vec_float4 lengthSqr( const Vector4 & vec ); + +// Compute the length of a 4-D vector +// +inline vec_float4 length( const Vector4 & vec ); + +// Normalize a 4-D vector +// NOTE: +// The result is unpredictable when all elements of vec are at or near zero. +// +inline const Vector4 normalize( const Vector4 & vec ); + +// Outer product of two 4-D vectors +// +inline const Matrix4 outer( const Vector4 & vec0, const Vector4 & vec1 ); + +// Linear interpolation between two 4-D vectors +// NOTE: +// Does not clamp t between 0 and 1. +// +inline const Vector4 lerp( vec_float4 t, const Vector4 & vec0, const Vector4 & vec1 ); + +// Spherical linear interpolation between two 4-D vectors +// NOTE: +// The result is unpredictable if the vectors point in opposite directions. +// Does not clamp t between 0 and 1. +// +inline const Vector4 slerp( vec_float4 t, const Vector4 & unitVec0, const Vector4 & unitVec1 ); + +// Conditionally select between two 4-D vectors +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// +inline const Vector4 select( const Vector4 & vec0, const Vector4 & vec1, vec_uint4 select1 ); + +// Store four slots of an SoA 4-D vector as half-floats +// +inline void storeHalfFloats( const Vector4 & vec, vec_ushort8 * twoQuads ); + +#ifdef _VECTORMATH_DEBUG + +// Print a 4-D vector +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Vector4 & vec ); + +// Print a 4-D vector and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Vector4 & vec, const char * name ); + +#endif + +// A set of four 3-D points in structure-of-arrays format +// +class Point3 +{ + typedef vec_float4 vec_float4_t; + vec_float4 mX; + vec_float4 mY; + vec_float4 mZ; + +public: + // Default constructor; does no initialization + // + inline Point3( ) { }; + + // Copy a 3-D point + // + inline Point3( const Point3 & pnt ); + + // Construct a 3-D point from x, y, and z elements + // + inline Point3( vec_float4 x, vec_float4 y, vec_float4 z ); + + // Copy elements from a 3-D vector into a 3-D point + // + explicit inline Point3( const Vector3 & vec ); + + // Set all elements of a 3-D point to the same scalar value + // + explicit inline Point3( vec_float4 scalar ); + + // Replicate an AoS 3-D point + // + inline Point3( Aos::Point3 pnt ); + + // Insert four AoS 3-D points + // + inline Point3( Aos::Point3 pnt0, Aos::Point3 pnt1, Aos::Point3 pnt2, Aos::Point3 pnt3 ); + + // Extract four AoS 3-D points + // + inline void get4Aos( Aos::Point3 & result0, Aos::Point3 & result1, Aos::Point3 & result2, Aos::Point3 & result3 ) const; + + // Assign one 3-D point to another + // + inline Point3 & operator =( const Point3 & pnt ); + + // Set the x element of a 3-D point + // + inline Point3 & setX( vec_float4 x ); + + // Set the y element of a 3-D point + // + inline Point3 & setY( vec_float4 y ); + + // Set the z element of a 3-D point + // + inline Point3 & setZ( vec_float4 z ); + + // Get the x element of a 3-D point + // + inline vec_float4 getX( ) const; + + // Get the y element of a 3-D point + // + inline vec_float4 getY( ) const; + + // Get the z element of a 3-D point + // + inline vec_float4 getZ( ) const; + + // Set an x, y, or z element of a 3-D point by index + // + inline Point3 & setElem( int idx, vec_float4 value ); + + // Get an x, y, or z element of a 3-D point by index + // + inline vec_float4 getElem( int idx ) const; + + // Subscripting operator to set or get an element + // + inline vec_float4_t & operator []( int idx ); + + // Subscripting operator to get an element + // + inline vec_float4 operator []( int idx ) const; + + // Subtract a 3-D point from another 3-D point + // + inline const Vector3 operator -( const Point3 & pnt ) const; + + // Add a 3-D point to a 3-D vector + // + inline const Point3 operator +( const Vector3 & vec ) const; + + // Subtract a 3-D vector from a 3-D point + // + inline const Point3 operator -( const Vector3 & vec ) const; + + // Perform compound assignment and addition with a 3-D vector + // + inline Point3 & operator +=( const Vector3 & vec ); + + // Perform compound assignment and subtraction by a 3-D vector + // + inline Point3 & operator -=( const Vector3 & vec ); + +}; + +// Multiply two 3-D points per element +// +inline const Point3 mulPerElem( const Point3 & pnt0, const Point3 & pnt1 ); + +// Divide two 3-D points per element +// NOTE: +// Floating-point behavior matches standard library function divf4. +// +inline const Point3 divPerElem( const Point3 & pnt0, const Point3 & pnt1 ); + +// Compute the reciprocal of a 3-D point per element +// NOTE: +// Floating-point behavior matches standard library function recipf4. +// +inline const Point3 recipPerElem( const Point3 & pnt ); + +// Compute the square root of a 3-D point per element +// NOTE: +// Floating-point behavior matches standard library function sqrtf4. +// +inline const Point3 sqrtPerElem( const Point3 & pnt ); + +// Compute the reciprocal square root of a 3-D point per element +// NOTE: +// Floating-point behavior matches standard library function rsqrtf4. +// +inline const Point3 rsqrtPerElem( const Point3 & pnt ); + +// Compute the absolute value of a 3-D point per element +// +inline const Point3 absPerElem( const Point3 & pnt ); + +// Copy sign from one 3-D point to another, per element +// +inline const Point3 copySignPerElem( const Point3 & pnt0, const Point3 & pnt1 ); + +// Maximum of two 3-D points per element +// +inline const Point3 maxPerElem( const Point3 & pnt0, const Point3 & pnt1 ); + +// Minimum of two 3-D points per element +// +inline const Point3 minPerElem( const Point3 & pnt0, const Point3 & pnt1 ); + +// Maximum element of a 3-D point +// +inline vec_float4 maxElem( const Point3 & pnt ); + +// Minimum element of a 3-D point +// +inline vec_float4 minElem( const Point3 & pnt ); + +// Compute the sum of all elements of a 3-D point +// +inline vec_float4 sum( const Point3 & pnt ); + +// Apply uniform scale to a 3-D point +// +inline const Point3 scale( const Point3 & pnt, vec_float4 scaleVal ); + +// Apply non-uniform scale to a 3-D point +// +inline const Point3 scale( const Point3 & pnt, const Vector3 & scaleVec ); + +// Scalar projection of a 3-D point on a unit-length 3-D vector +// +inline vec_float4 projection( const Point3 & pnt, const Vector3 & unitVec ); + +// Compute the square of the distance of a 3-D point from the coordinate-system origin +// +inline vec_float4 distSqrFromOrigin( const Point3 & pnt ); + +// Compute the distance of a 3-D point from the coordinate-system origin +// +inline vec_float4 distFromOrigin( const Point3 & pnt ); + +// Compute the square of the distance between two 3-D points +// +inline vec_float4 distSqr( const Point3 & pnt0, const Point3 & pnt1 ); + +// Compute the distance between two 3-D points +// +inline vec_float4 dist( const Point3 & pnt0, const Point3 & pnt1 ); + +// Linear interpolation between two 3-D points +// NOTE: +// Does not clamp t between 0 and 1. +// +inline const Point3 lerp( vec_float4 t, const Point3 & pnt0, const Point3 & pnt1 ); + +// Conditionally select between two 3-D points +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// +inline const Point3 select( const Point3 & pnt0, const Point3 & pnt1, vec_uint4 select1 ); + +// Load four three-float 3-D points, stored in three quadwords +// +inline void loadXYZArray( Point3 & pnt, const vec_float4 * threeQuads ); + +// Store four slots of an SoA 3-D point in three quadwords +// +inline void storeXYZArray( const Point3 & pnt, vec_float4 * threeQuads ); + +// Store eight slots of two SoA 3-D points as half-floats +// +inline void storeHalfFloats( const Point3 & pnt0, const Point3 & pnt1, vec_ushort8 * threeQuads ); + +#ifdef _VECTORMATH_DEBUG + +// Print a 3-D point +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Point3 & pnt ); + +// Print a 3-D point and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Point3 & pnt, const char * name ); + +#endif + +// A set of four quaternions in structure-of-arrays format +// +class Quat +{ + typedef vec_float4 vec_float4_t; + vec_float4 mX; + vec_float4 mY; + vec_float4 mZ; + vec_float4 mW; + +public: + // Default constructor; does no initialization + // + inline Quat( ) { }; + + // Copy a quaternion + // + inline Quat( const Quat & quat ); + + // Construct a quaternion from x, y, z, and w elements + // + inline Quat( vec_float4 x, vec_float4 y, vec_float4 z, vec_float4 w ); + + // Construct a quaternion from a 3-D vector and a scalar + // + inline Quat( const Vector3 & xyz, vec_float4 w ); + + // Copy elements from a 4-D vector into a quaternion + // + explicit inline Quat( const Vector4 & vec ); + + // Convert a rotation matrix to a unit-length quaternion + // + explicit inline Quat( const Matrix3 & rotMat ); + + // Set all elements of a quaternion to the same scalar value + // + explicit inline Quat( vec_float4 scalar ); + + // Replicate an AoS quaternion + // + inline Quat( Aos::Quat quat ); + + // Insert four AoS quaternions + // + inline Quat( Aos::Quat quat0, Aos::Quat quat1, Aos::Quat quat2, Aos::Quat quat3 ); + + // Extract four AoS quaternions + // + inline void get4Aos( Aos::Quat & result0, Aos::Quat & result1, Aos::Quat & result2, Aos::Quat & result3 ) const; + + // Assign one quaternion to another + // + inline Quat & operator =( const Quat & quat ); + + // Set the x, y, and z elements of a quaternion + // NOTE: + // This function does not change the w element. + // + inline Quat & setXYZ( const Vector3 & vec ); + + // Get the x, y, and z elements of a quaternion + // + inline const Vector3 getXYZ( ) const; + + // Set the x element of a quaternion + // + inline Quat & setX( vec_float4 x ); + + // Set the y element of a quaternion + // + inline Quat & setY( vec_float4 y ); + + // Set the z element of a quaternion + // + inline Quat & setZ( vec_float4 z ); + + // Set the w element of a quaternion + // + inline Quat & setW( vec_float4 w ); + + // Get the x element of a quaternion + // + inline vec_float4 getX( ) const; + + // Get the y element of a quaternion + // + inline vec_float4 getY( ) const; + + // Get the z element of a quaternion + // + inline vec_float4 getZ( ) const; + + // Get the w element of a quaternion + // + inline vec_float4 getW( ) const; + + // Set an x, y, z, or w element of a quaternion by index + // + inline Quat & setElem( int idx, vec_float4 value ); + + // Get an x, y, z, or w element of a quaternion by index + // + inline vec_float4 getElem( int idx ) const; + + // Subscripting operator to set or get an element + // + inline vec_float4_t & operator []( int idx ); + + // Subscripting operator to get an element + // + inline vec_float4 operator []( int idx ) const; + + // Add two quaternions + // + inline const Quat operator +( const Quat & quat ) const; + + // Subtract a quaternion from another quaternion + // + inline const Quat operator -( const Quat & quat ) const; + + // Multiply two quaternions + // + inline const Quat operator *( const Quat & quat ) const; + + // Multiply a quaternion by a scalar + // + inline const Quat operator *( vec_float4 scalar ) const; + + // Divide a quaternion by a scalar + // + inline const Quat operator /( vec_float4 scalar ) const; + + // Perform compound assignment and addition with a quaternion + // + inline Quat & operator +=( const Quat & quat ); + + // Perform compound assignment and subtraction by a quaternion + // + inline Quat & operator -=( const Quat & quat ); + + // Perform compound assignment and multiplication by a quaternion + // + inline Quat & operator *=( const Quat & quat ); + + // Perform compound assignment and multiplication by a scalar + // + inline Quat & operator *=( vec_float4 scalar ); + + // Perform compound assignment and division by a scalar + // + inline Quat & operator /=( vec_float4 scalar ); + + // Negate all elements of a quaternion + // + inline const Quat operator -( ) const; + + // Construct an identity quaternion + // + static inline const Quat identity( ); + + // Construct a quaternion to rotate between two unit-length 3-D vectors + // NOTE: + // The result is unpredictable if unitVec0 and unitVec1 point in opposite directions. + // + static inline const Quat rotation( const Vector3 & unitVec0, const Vector3 & unitVec1 ); + + // Construct a quaternion to rotate around a unit-length 3-D vector + // + static inline const Quat rotation( vec_float4 radians, const Vector3 & unitVec ); + + // Construct a quaternion to rotate around the x axis + // + static inline const Quat rotationX( vec_float4 radians ); + + // Construct a quaternion to rotate around the y axis + // + static inline const Quat rotationY( vec_float4 radians ); + + // Construct a quaternion to rotate around the z axis + // + static inline const Quat rotationZ( vec_float4 radians ); + +}; + +// Multiply a quaternion by a scalar +// +inline const Quat operator *( vec_float4 scalar, const Quat & quat ); + +// Compute the conjugate of a quaternion +// +inline const Quat conj( const Quat & quat ); + +// Use a unit-length quaternion to rotate a 3-D vector +// +inline const Vector3 rotate( const Quat & unitQuat, const Vector3 & vec ); + +// Compute the dot product of two quaternions +// +inline vec_float4 dot( const Quat & quat0, const Quat & quat1 ); + +// Compute the norm of a quaternion +// +inline vec_float4 norm( const Quat & quat ); + +// Compute the length of a quaternion +// +inline vec_float4 length( const Quat & quat ); + +// Normalize a quaternion +// NOTE: +// The result is unpredictable when all elements of quat are at or near zero. +// +inline const Quat normalize( const Quat & quat ); + +// Linear interpolation between two quaternions +// NOTE: +// Does not clamp t between 0 and 1. +// +inline const Quat lerp( vec_float4 t, const Quat & quat0, const Quat & quat1 ); + +// Spherical linear interpolation between two quaternions +// NOTE: +// Interpolates along the shortest path between orientations. +// Does not clamp t between 0 and 1. +// +inline const Quat slerp( vec_float4 t, const Quat & unitQuat0, const Quat & unitQuat1 ); + +// Spherical quadrangle interpolation +// +inline const Quat squad( vec_float4 t, const Quat & unitQuat0, const Quat & unitQuat1, const Quat & unitQuat2, const Quat & unitQuat3 ); + +// Conditionally select between two quaternions +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// +inline const Quat select( const Quat & quat0, const Quat & quat1, vec_uint4 select1 ); + +#ifdef _VECTORMATH_DEBUG + +// Print a quaternion +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Quat & quat ); + +// Print a quaternion and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Quat & quat, const char * name ); + +#endif + +// A set of four 3x3 matrices in structure-of-arrays format +// +class Matrix3 +{ + Vector3 mCol0; + Vector3 mCol1; + Vector3 mCol2; + +public: + // Default constructor; does no initialization + // + inline Matrix3( ) { }; + + // Copy a 3x3 matrix + // + inline Matrix3( const Matrix3 & mat ); + + // Construct a 3x3 matrix containing the specified columns + // + inline Matrix3( const Vector3 & col0, const Vector3 & col1, const Vector3 & col2 ); + + // Construct a 3x3 rotation matrix from a unit-length quaternion + // + explicit inline Matrix3( const Quat & unitQuat ); + + // Set all elements of a 3x3 matrix to the same scalar value + // + explicit inline Matrix3( vec_float4 scalar ); + + // Replicate an AoS 3x3 matrix + // + inline Matrix3( const Aos::Matrix3 & mat ); + + // Insert four AoS 3x3 matrices + // + inline Matrix3( const Aos::Matrix3 & mat0, const Aos::Matrix3 & mat1, const Aos::Matrix3 & mat2, const Aos::Matrix3 & mat3 ); + + // Extract four AoS 3x3 matrices + // + inline void get4Aos( Aos::Matrix3 & result0, Aos::Matrix3 & result1, Aos::Matrix3 & result2, Aos::Matrix3 & result3 ) const; + + // Assign one 3x3 matrix to another + // + inline Matrix3 & operator =( const Matrix3 & mat ); + + // Set column 0 of a 3x3 matrix + // + inline Matrix3 & setCol0( const Vector3 & col0 ); + + // Set column 1 of a 3x3 matrix + // + inline Matrix3 & setCol1( const Vector3 & col1 ); + + // Set column 2 of a 3x3 matrix + // + inline Matrix3 & setCol2( const Vector3 & col2 ); + + // Get column 0 of a 3x3 matrix + // + inline const Vector3 getCol0( ) const; + + // Get column 1 of a 3x3 matrix + // + inline const Vector3 getCol1( ) const; + + // Get column 2 of a 3x3 matrix + // + inline const Vector3 getCol2( ) const; + + // Set the column of a 3x3 matrix referred to by the specified index + // + inline Matrix3 & setCol( int col, const Vector3 & vec ); + + // Set the row of a 3x3 matrix referred to by the specified index + // + inline Matrix3 & setRow( int row, const Vector3 & vec ); + + // Get the column of a 3x3 matrix referred to by the specified index + // + inline const Vector3 getCol( int col ) const; + + // Get the row of a 3x3 matrix referred to by the specified index + // + inline const Vector3 getRow( int row ) const; + + // Subscripting operator to set or get a column + // + inline Vector3 & operator []( int col ); + + // Subscripting operator to get a column + // + inline const Vector3 operator []( int col ) const; + + // Set the element of a 3x3 matrix referred to by column and row indices + // + inline Matrix3 & setElem( int col, int row, vec_float4 val ); + + // Get the element of a 3x3 matrix referred to by column and row indices + // + inline vec_float4 getElem( int col, int row ) const; + + // Add two 3x3 matrices + // + inline const Matrix3 operator +( const Matrix3 & mat ) const; + + // Subtract a 3x3 matrix from another 3x3 matrix + // + inline const Matrix3 operator -( const Matrix3 & mat ) const; + + // Negate all elements of a 3x3 matrix + // + inline const Matrix3 operator -( ) const; + + // Multiply a 3x3 matrix by a scalar + // + inline const Matrix3 operator *( vec_float4 scalar ) const; + + // Multiply a 3x3 matrix by a 3-D vector + // + inline const Vector3 operator *( const Vector3 & vec ) const; + + // Multiply two 3x3 matrices + // + inline const Matrix3 operator *( const Matrix3 & mat ) const; + + // Perform compound assignment and addition with a 3x3 matrix + // + inline Matrix3 & operator +=( const Matrix3 & mat ); + + // Perform compound assignment and subtraction by a 3x3 matrix + // + inline Matrix3 & operator -=( const Matrix3 & mat ); + + // Perform compound assignment and multiplication by a scalar + // + inline Matrix3 & operator *=( vec_float4 scalar ); + + // Perform compound assignment and multiplication by a 3x3 matrix + // + inline Matrix3 & operator *=( const Matrix3 & mat ); + + // Construct an identity 3x3 matrix + // + static inline const Matrix3 identity( ); + + // Construct a 3x3 matrix to rotate around the x axis + // + static inline const Matrix3 rotationX( vec_float4 radians ); + + // Construct a 3x3 matrix to rotate around the y axis + // + static inline const Matrix3 rotationY( vec_float4 radians ); + + // Construct a 3x3 matrix to rotate around the z axis + // + static inline const Matrix3 rotationZ( vec_float4 radians ); + + // Construct a 3x3 matrix to rotate around the x, y, and z axes + // + static inline const Matrix3 rotationZYX( const Vector3 & radiansXYZ ); + + // Construct a 3x3 matrix to rotate around a unit-length 3-D vector + // + static inline const Matrix3 rotation( vec_float4 radians, const Vector3 & unitVec ); + + // Construct a rotation matrix from a unit-length quaternion + // + static inline const Matrix3 rotation( const Quat & unitQuat ); + + // Construct a 3x3 matrix to perform scaling + // + static inline const Matrix3 scale( const Vector3 & scaleVec ); + +}; +// Multiply a 3x3 matrix by a scalar +// +inline const Matrix3 operator *( vec_float4 scalar, const Matrix3 & mat ); + +// Append (post-multiply) a scale transformation to a 3x3 matrix +// NOTE: +// Faster than creating and multiplying a scale transformation matrix. +// +inline const Matrix3 appendScale( const Matrix3 & mat, const Vector3 & scaleVec ); + +// Prepend (pre-multiply) a scale transformation to a 3x3 matrix +// NOTE: +// Faster than creating and multiplying a scale transformation matrix. +// +inline const Matrix3 prependScale( const Vector3 & scaleVec, const Matrix3 & mat ); + +// Multiply two 3x3 matrices per element +// +inline const Matrix3 mulPerElem( const Matrix3 & mat0, const Matrix3 & mat1 ); + +// Compute the absolute value of a 3x3 matrix per element +// +inline const Matrix3 absPerElem( const Matrix3 & mat ); + +// Transpose of a 3x3 matrix +// +inline const Matrix3 transpose( const Matrix3 & mat ); + +// Compute the inverse of a 3x3 matrix +// NOTE: +// Result is unpredictable when the determinant of mat is equal to or near 0. +// +inline const Matrix3 inverse( const Matrix3 & mat ); + +// Determinant of a 3x3 matrix +// +inline vec_float4 determinant( const Matrix3 & mat ); + +// Conditionally select between two 3x3 matrices +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// +inline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, vec_uint4 select1 ); + +#ifdef _VECTORMATH_DEBUG + +// Print a 3x3 matrix +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Matrix3 & mat ); + +// Print a 3x3 matrix and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Matrix3 & mat, const char * name ); + +#endif + +// A set of four 4x4 matrices in structure-of-arrays format +// +class Matrix4 +{ + Vector4 mCol0; + Vector4 mCol1; + Vector4 mCol2; + Vector4 mCol3; + +public: + // Default constructor; does no initialization + // + inline Matrix4( ) { }; + + // Copy a 4x4 matrix + // + inline Matrix4( const Matrix4 & mat ); + + // Construct a 4x4 matrix containing the specified columns + // + inline Matrix4( const Vector4 & col0, const Vector4 & col1, const Vector4 & col2, const Vector4 & col3 ); + + // Construct a 4x4 matrix from a 3x4 transformation matrix + // + explicit inline Matrix4( const Transform3 & mat ); + + // Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector + // + inline Matrix4( const Matrix3 & mat, const Vector3 & translateVec ); + + // Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector + // + inline Matrix4( const Quat & unitQuat, const Vector3 & translateVec ); + + // Set all elements of a 4x4 matrix to the same scalar value + // + explicit inline Matrix4( vec_float4 scalar ); + + // Replicate an AoS 4x4 matrix + // + inline Matrix4( const Aos::Matrix4 & mat ); + + // Insert four AoS 4x4 matrices + // + inline Matrix4( const Aos::Matrix4 & mat0, const Aos::Matrix4 & mat1, const Aos::Matrix4 & mat2, const Aos::Matrix4 & mat3 ); + + // Extract four AoS 4x4 matrices + // + inline void get4Aos( Aos::Matrix4 & result0, Aos::Matrix4 & result1, Aos::Matrix4 & result2, Aos::Matrix4 & result3 ) const; + + // Assign one 4x4 matrix to another + // + inline Matrix4 & operator =( const Matrix4 & mat ); + + // Set the upper-left 3x3 submatrix + // NOTE: + // This function does not change the bottom row elements. + // + inline Matrix4 & setUpper3x3( const Matrix3 & mat3 ); + + // Get the upper-left 3x3 submatrix of a 4x4 matrix + // + inline const Matrix3 getUpper3x3( ) const; + + // Set translation component + // NOTE: + // This function does not change the bottom row elements. + // + inline Matrix4 & setTranslation( const Vector3 & translateVec ); + + // Get the translation component of a 4x4 matrix + // + inline const Vector3 getTranslation( ) const; + + // Set column 0 of a 4x4 matrix + // + inline Matrix4 & setCol0( const Vector4 & col0 ); + + // Set column 1 of a 4x4 matrix + // + inline Matrix4 & setCol1( const Vector4 & col1 ); + + // Set column 2 of a 4x4 matrix + // + inline Matrix4 & setCol2( const Vector4 & col2 ); + + // Set column 3 of a 4x4 matrix + // + inline Matrix4 & setCol3( const Vector4 & col3 ); + + // Get column 0 of a 4x4 matrix + // + inline const Vector4 getCol0( ) const; + + // Get column 1 of a 4x4 matrix + // + inline const Vector4 getCol1( ) const; + + // Get column 2 of a 4x4 matrix + // + inline const Vector4 getCol2( ) const; + + // Get column 3 of a 4x4 matrix + // + inline const Vector4 getCol3( ) const; + + // Set the column of a 4x4 matrix referred to by the specified index + // + inline Matrix4 & setCol( int col, const Vector4 & vec ); + + // Set the row of a 4x4 matrix referred to by the specified index + // + inline Matrix4 & setRow( int row, const Vector4 & vec ); + + // Get the column of a 4x4 matrix referred to by the specified index + // + inline const Vector4 getCol( int col ) const; + + // Get the row of a 4x4 matrix referred to by the specified index + // + inline const Vector4 getRow( int row ) const; + + // Subscripting operator to set or get a column + // + inline Vector4 & operator []( int col ); + + // Subscripting operator to get a column + // + inline const Vector4 operator []( int col ) const; + + // Set the element of a 4x4 matrix referred to by column and row indices + // + inline Matrix4 & setElem( int col, int row, vec_float4 val ); + + // Get the element of a 4x4 matrix referred to by column and row indices + // + inline vec_float4 getElem( int col, int row ) const; + + // Add two 4x4 matrices + // + inline const Matrix4 operator +( const Matrix4 & mat ) const; + + // Subtract a 4x4 matrix from another 4x4 matrix + // + inline const Matrix4 operator -( const Matrix4 & mat ) const; + + // Negate all elements of a 4x4 matrix + // + inline const Matrix4 operator -( ) const; + + // Multiply a 4x4 matrix by a scalar + // + inline const Matrix4 operator *( vec_float4 scalar ) const; + + // Multiply a 4x4 matrix by a 4-D vector + // + inline const Vector4 operator *( const Vector4 & vec ) const; + + // Multiply a 4x4 matrix by a 3-D vector + // + inline const Vector4 operator *( const Vector3 & vec ) const; + + // Multiply a 4x4 matrix by a 3-D point + // + inline const Vector4 operator *( const Point3 & pnt ) const; + + // Multiply two 4x4 matrices + // + inline const Matrix4 operator *( const Matrix4 & mat ) const; + + // Multiply a 4x4 matrix by a 3x4 transformation matrix + // + inline const Matrix4 operator *( const Transform3 & tfrm ) const; + + // Perform compound assignment and addition with a 4x4 matrix + // + inline Matrix4 & operator +=( const Matrix4 & mat ); + + // Perform compound assignment and subtraction by a 4x4 matrix + // + inline Matrix4 & operator -=( const Matrix4 & mat ); + + // Perform compound assignment and multiplication by a scalar + // + inline Matrix4 & operator *=( vec_float4 scalar ); + + // Perform compound assignment and multiplication by a 4x4 matrix + // + inline Matrix4 & operator *=( const Matrix4 & mat ); + + // Perform compound assignment and multiplication by a 3x4 transformation matrix + // + inline Matrix4 & operator *=( const Transform3 & tfrm ); + + // Construct an identity 4x4 matrix + // + static inline const Matrix4 identity( ); + + // Construct a 4x4 matrix to rotate around the x axis + // + static inline const Matrix4 rotationX( vec_float4 radians ); + + // Construct a 4x4 matrix to rotate around the y axis + // + static inline const Matrix4 rotationY( vec_float4 radians ); + + // Construct a 4x4 matrix to rotate around the z axis + // + static inline const Matrix4 rotationZ( vec_float4 radians ); + + // Construct a 4x4 matrix to rotate around the x, y, and z axes + // + static inline const Matrix4 rotationZYX( const Vector3 & radiansXYZ ); + + // Construct a 4x4 matrix to rotate around a unit-length 3-D vector + // + static inline const Matrix4 rotation( vec_float4 radians, const Vector3 & unitVec ); + + // Construct a rotation matrix from a unit-length quaternion + // + static inline const Matrix4 rotation( const Quat & unitQuat ); + + // Construct a 4x4 matrix to perform scaling + // + static inline const Matrix4 scale( const Vector3 & scaleVec ); + + // Construct a 4x4 matrix to perform translation + // + static inline const Matrix4 translation( const Vector3 & translateVec ); + + // Construct viewing matrix based on eye position, position looked at, and up direction + // + static inline const Matrix4 lookAt( const Point3 & eyePos, const Point3 & lookAtPos, const Vector3 & upVec ); + + // Construct a perspective projection matrix + // + static inline const Matrix4 perspective( vec_float4 fovyRadians, vec_float4 aspect, vec_float4 zNear, vec_float4 zFar ); + + // Construct a perspective projection matrix based on frustum + // + static inline const Matrix4 frustum( vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ); + + // Construct an orthographic projection matrix + // + static inline const Matrix4 orthographic( vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ); + +}; +// Multiply a 4x4 matrix by a scalar +// +inline const Matrix4 operator *( vec_float4 scalar, const Matrix4 & mat ); + +// Append (post-multiply) a scale transformation to a 4x4 matrix +// NOTE: +// Faster than creating and multiplying a scale transformation matrix. +// +inline const Matrix4 appendScale( const Matrix4 & mat, const Vector3 & scaleVec ); + +// Prepend (pre-multiply) a scale transformation to a 4x4 matrix +// NOTE: +// Faster than creating and multiplying a scale transformation matrix. +// +inline const Matrix4 prependScale( const Vector3 & scaleVec, const Matrix4 & mat ); + +// Multiply two 4x4 matrices per element +// +inline const Matrix4 mulPerElem( const Matrix4 & mat0, const Matrix4 & mat1 ); + +// Compute the absolute value of a 4x4 matrix per element +// +inline const Matrix4 absPerElem( const Matrix4 & mat ); + +// Transpose of a 4x4 matrix +// +inline const Matrix4 transpose( const Matrix4 & mat ); + +// Compute the inverse of a 4x4 matrix +// NOTE: +// Result is unpredictable when the determinant of mat is equal to or near 0. +// +inline const Matrix4 inverse( const Matrix4 & mat ); + +// Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix +// NOTE: +// This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. The result is unpredictable when the determinant of mat is equal to or near 0. +// +inline const Matrix4 affineInverse( const Matrix4 & mat ); + +// Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix +// NOTE: +// This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. +// +inline const Matrix4 orthoInverse( const Matrix4 & mat ); + +// Determinant of a 4x4 matrix +// +inline vec_float4 determinant( const Matrix4 & mat ); + +// Conditionally select between two 4x4 matrices +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// +inline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, vec_uint4 select1 ); + +#ifdef _VECTORMATH_DEBUG + +// Print a 4x4 matrix +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Matrix4 & mat ); + +// Print a 4x4 matrix and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Matrix4 & mat, const char * name ); + +#endif + +// A set of four 3x4 transformation matrices in structure-of-arrays format +// +class Transform3 +{ + Vector3 mCol0; + Vector3 mCol1; + Vector3 mCol2; + Vector3 mCol3; + +public: + // Default constructor; does no initialization + // + inline Transform3( ) { }; + + // Copy a 3x4 transformation matrix + // + inline Transform3( const Transform3 & tfrm ); + + // Construct a 3x4 transformation matrix containing the specified columns + // + inline Transform3( const Vector3 & col0, const Vector3 & col1, const Vector3 & col2, const Vector3 & col3 ); + + // Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector + // + inline Transform3( const Matrix3 & tfrm, const Vector3 & translateVec ); + + // Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector + // + inline Transform3( const Quat & unitQuat, const Vector3 & translateVec ); + + // Set all elements of a 3x4 transformation matrix to the same scalar value + // + explicit inline Transform3( vec_float4 scalar ); + + // Replicate an AoS 3x4 transformation matrix + // + inline Transform3( const Aos::Transform3 & tfrm ); + + // Insert four AoS 3x4 transformation matrices + // + inline Transform3( const Aos::Transform3 & tfrm0, const Aos::Transform3 & tfrm1, const Aos::Transform3 & tfrm2, const Aos::Transform3 & tfrm3 ); + + // Extract four AoS 3x4 transformation matrices + // + inline void get4Aos( Aos::Transform3 & result0, Aos::Transform3 & result1, Aos::Transform3 & result2, Aos::Transform3 & result3 ) const; + + // Assign one 3x4 transformation matrix to another + // + inline Transform3 & operator =( const Transform3 & tfrm ); + + // Set the upper-left 3x3 submatrix + // + inline Transform3 & setUpper3x3( const Matrix3 & mat3 ); + + // Get the upper-left 3x3 submatrix of a 3x4 transformation matrix + // + inline const Matrix3 getUpper3x3( ) const; + + // Set translation component + // + inline Transform3 & setTranslation( const Vector3 & translateVec ); + + // Get the translation component of a 3x4 transformation matrix + // + inline const Vector3 getTranslation( ) const; + + // Set column 0 of a 3x4 transformation matrix + // + inline Transform3 & setCol0( const Vector3 & col0 ); + + // Set column 1 of a 3x4 transformation matrix + // + inline Transform3 & setCol1( const Vector3 & col1 ); + + // Set column 2 of a 3x4 transformation matrix + // + inline Transform3 & setCol2( const Vector3 & col2 ); + + // Set column 3 of a 3x4 transformation matrix + // + inline Transform3 & setCol3( const Vector3 & col3 ); + + // Get column 0 of a 3x4 transformation matrix + // + inline const Vector3 getCol0( ) const; + + // Get column 1 of a 3x4 transformation matrix + // + inline const Vector3 getCol1( ) const; + + // Get column 2 of a 3x4 transformation matrix + // + inline const Vector3 getCol2( ) const; + + // Get column 3 of a 3x4 transformation matrix + // + inline const Vector3 getCol3( ) const; + + // Set the column of a 3x4 transformation matrix referred to by the specified index + // + inline Transform3 & setCol( int col, const Vector3 & vec ); + + // Set the row of a 3x4 transformation matrix referred to by the specified index + // + inline Transform3 & setRow( int row, const Vector4 & vec ); + + // Get the column of a 3x4 transformation matrix referred to by the specified index + // + inline const Vector3 getCol( int col ) const; + + // Get the row of a 3x4 transformation matrix referred to by the specified index + // + inline const Vector4 getRow( int row ) const; + + // Subscripting operator to set or get a column + // + inline Vector3 & operator []( int col ); + + // Subscripting operator to get a column + // + inline const Vector3 operator []( int col ) const; + + // Set the element of a 3x4 transformation matrix referred to by column and row indices + // + inline Transform3 & setElem( int col, int row, vec_float4 val ); + + // Get the element of a 3x4 transformation matrix referred to by column and row indices + // + inline vec_float4 getElem( int col, int row ) const; + + // Multiply a 3x4 transformation matrix by a 3-D vector + // + inline const Vector3 operator *( const Vector3 & vec ) const; + + // Multiply a 3x4 transformation matrix by a 3-D point + // + inline const Point3 operator *( const Point3 & pnt ) const; + + // Multiply two 3x4 transformation matrices + // + inline const Transform3 operator *( const Transform3 & tfrm ) const; + + // Perform compound assignment and multiplication by a 3x4 transformation matrix + // + inline Transform3 & operator *=( const Transform3 & tfrm ); + + // Construct an identity 3x4 transformation matrix + // + static inline const Transform3 identity( ); + + // Construct a 3x4 transformation matrix to rotate around the x axis + // + static inline const Transform3 rotationX( vec_float4 radians ); + + // Construct a 3x4 transformation matrix to rotate around the y axis + // + static inline const Transform3 rotationY( vec_float4 radians ); + + // Construct a 3x4 transformation matrix to rotate around the z axis + // + static inline const Transform3 rotationZ( vec_float4 radians ); + + // Construct a 3x4 transformation matrix to rotate around the x, y, and z axes + // + static inline const Transform3 rotationZYX( const Vector3 & radiansXYZ ); + + // Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector + // + static inline const Transform3 rotation( vec_float4 radians, const Vector3 & unitVec ); + + // Construct a rotation matrix from a unit-length quaternion + // + static inline const Transform3 rotation( const Quat & unitQuat ); + + // Construct a 3x4 transformation matrix to perform scaling + // + static inline const Transform3 scale( const Vector3 & scaleVec ); + + // Construct a 3x4 transformation matrix to perform translation + // + static inline const Transform3 translation( const Vector3 & translateVec ); + +}; +// Append (post-multiply) a scale transformation to a 3x4 transformation matrix +// NOTE: +// Faster than creating and multiplying a scale transformation matrix. +// +inline const Transform3 appendScale( const Transform3 & tfrm, const Vector3 & scaleVec ); + +// Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix +// NOTE: +// Faster than creating and multiplying a scale transformation matrix. +// +inline const Transform3 prependScale( const Vector3 & scaleVec, const Transform3 & tfrm ); + +// Multiply two 3x4 transformation matrices per element +// +inline const Transform3 mulPerElem( const Transform3 & tfrm0, const Transform3 & tfrm1 ); + +// Compute the absolute value of a 3x4 transformation matrix per element +// +inline const Transform3 absPerElem( const Transform3 & tfrm ); + +// Inverse of a 3x4 transformation matrix +// NOTE: +// Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0. +// +inline const Transform3 inverse( const Transform3 & tfrm ); + +// Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix +// NOTE: +// This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions. +// +inline const Transform3 orthoInverse( const Transform3 & tfrm ); + +// Conditionally select between two 3x4 transformation matrices +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// +inline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, vec_uint4 select1 ); + +#ifdef _VECTORMATH_DEBUG + +// Print a 3x4 transformation matrix +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Transform3 & tfrm ); + +// Print a 3x4 transformation matrix and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Transform3 & tfrm, const char * name ); + +#endif + +} // namespace Soa +} // namespace Vectormath + +#include "vec_soa.h" +#include "quat_soa.h" +#include "mat_soa.h" + +#endif diff --git a/vectormathlibrary/include/vectormath/scalar/c/mat_aos.h b/vectormathlibrary/include/vectormath/scalar/c/mat_aos.h new file mode 100644 index 000000000..4e0d6ee5c --- /dev/null +++ b/vectormathlibrary/include/vectormath/scalar/c/mat_aos.h @@ -0,0 +1,1452 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_MAT_AOS_C_H +#define _VECTORMATH_MAT_AOS_C_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/*----------------------------------------------------------------------------- + * Constants + */ +#define _VECTORMATH_PI_OVER_2 1.570796327f + +/*----------------------------------------------------------------------------- + * Definitions + */ +static inline void vmathM3Copy( VmathMatrix3 *result, const VmathMatrix3 *mat ) +{ + vmathV3Copy( &result->col0, &mat->col0 ); + vmathV3Copy( &result->col1, &mat->col1 ); + vmathV3Copy( &result->col2, &mat->col2 ); +} + +static inline void vmathM3MakeFromScalar( VmathMatrix3 *result, float scalar ) +{ + vmathV3MakeFromScalar( &result->col0, scalar ); + vmathV3MakeFromScalar( &result->col1, scalar ); + vmathV3MakeFromScalar( &result->col2, scalar ); +} + +static inline void vmathM3MakeFromQ( VmathMatrix3 *result, const VmathQuat *unitQuat ) +{ + float qx, qy, qz, qw, qx2, qy2, qz2, qxqx2, qyqy2, qzqz2, qxqy2, qyqz2, qzqw2, qxqz2, qyqw2, qxqw2; + qx = unitQuat->x; + qy = unitQuat->y; + qz = unitQuat->z; + qw = unitQuat->w; + qx2 = ( qx + qx ); + qy2 = ( qy + qy ); + qz2 = ( qz + qz ); + qxqx2 = ( qx * qx2 ); + qxqy2 = ( qx * qy2 ); + qxqz2 = ( qx * qz2 ); + qxqw2 = ( qw * qx2 ); + qyqy2 = ( qy * qy2 ); + qyqz2 = ( qy * qz2 ); + qyqw2 = ( qw * qy2 ); + qzqz2 = ( qz * qz2 ); + qzqw2 = ( qw * qz2 ); + vmathV3MakeFromElems( &result->col0, ( ( 1.0f - qyqy2 ) - qzqz2 ), ( qxqy2 + qzqw2 ), ( qxqz2 - qyqw2 ) ); + vmathV3MakeFromElems( &result->col1, ( qxqy2 - qzqw2 ), ( ( 1.0f - qxqx2 ) - qzqz2 ), ( qyqz2 + qxqw2 ) ); + vmathV3MakeFromElems( &result->col2, ( qxqz2 + qyqw2 ), ( qyqz2 - qxqw2 ), ( ( 1.0f - qxqx2 ) - qyqy2 ) ); +} + +static inline void vmathM3MakeFromCols( VmathMatrix3 *result, const VmathVector3 *_col0, const VmathVector3 *_col1, const VmathVector3 *_col2 ) +{ + vmathV3Copy( &result->col0, _col0 ); + vmathV3Copy( &result->col1, _col1 ); + vmathV3Copy( &result->col2, _col2 ); +} + +static inline void vmathM3SetCol0( VmathMatrix3 *result, const VmathVector3 *_col0 ) +{ + vmathV3Copy( &result->col0, _col0 ); +} + +static inline void vmathM3SetCol1( VmathMatrix3 *result, const VmathVector3 *_col1 ) +{ + vmathV3Copy( &result->col1, _col1 ); +} + +static inline void vmathM3SetCol2( VmathMatrix3 *result, const VmathVector3 *_col2 ) +{ + vmathV3Copy( &result->col2, _col2 ); +} + +static inline void vmathM3SetCol( VmathMatrix3 *result, int col, const VmathVector3 *vec ) +{ + vmathV3Copy( (&result->col0 + col), vec ); +} + +static inline void vmathM3SetRow( VmathMatrix3 *result, int row, const VmathVector3 *vec ) +{ + vmathV3SetElem( &result->col0, row, vmathV3GetElem( vec, 0 ) ); + vmathV3SetElem( &result->col1, row, vmathV3GetElem( vec, 1 ) ); + vmathV3SetElem( &result->col2, row, vmathV3GetElem( vec, 2 ) ); +} + +static inline void vmathM3SetElem( VmathMatrix3 *result, int col, int row, float val ) +{ + VmathVector3 tmpV3_0; + vmathM3GetCol( &tmpV3_0, result, col ); + vmathV3SetElem( &tmpV3_0, row, val ); + vmathM3SetCol( result, col, &tmpV3_0 ); +} + +static inline float vmathM3GetElem( const VmathMatrix3 *mat, int col, int row ) +{ + VmathVector3 tmpV3_0; + vmathM3GetCol( &tmpV3_0, mat, col ); + return vmathV3GetElem( &tmpV3_0, row ); +} + +static inline void vmathM3GetCol0( VmathVector3 *result, const VmathMatrix3 *mat ) +{ + vmathV3Copy( result, &mat->col0 ); +} + +static inline void vmathM3GetCol1( VmathVector3 *result, const VmathMatrix3 *mat ) +{ + vmathV3Copy( result, &mat->col1 ); +} + +static inline void vmathM3GetCol2( VmathVector3 *result, const VmathMatrix3 *mat ) +{ + vmathV3Copy( result, &mat->col2 ); +} + +static inline void vmathM3GetCol( VmathVector3 *result, const VmathMatrix3 *mat, int col ) +{ + vmathV3Copy( result, (&mat->col0 + col) ); +} + +static inline void vmathM3GetRow( VmathVector3 *result, const VmathMatrix3 *mat, int row ) +{ + vmathV3MakeFromElems( result, vmathV3GetElem( &mat->col0, row ), vmathV3GetElem( &mat->col1, row ), vmathV3GetElem( &mat->col2, row ) ); +} + +static inline void vmathM3Transpose( VmathMatrix3 *result, const VmathMatrix3 *mat ) +{ + VmathMatrix3 tmpResult; + vmathV3MakeFromElems( &tmpResult.col0, mat->col0.x, mat->col1.x, mat->col2.x ); + vmathV3MakeFromElems( &tmpResult.col1, mat->col0.y, mat->col1.y, mat->col2.y ); + vmathV3MakeFromElems( &tmpResult.col2, mat->col0.z, mat->col1.z, mat->col2.z ); + vmathM3Copy( result, &tmpResult ); +} + +static inline void vmathM3Inverse( VmathMatrix3 *result, const VmathMatrix3 *mat ) +{ + VmathVector3 tmp0, tmp1, tmp2; + float detinv; + vmathV3Cross( &tmp0, &mat->col1, &mat->col2 ); + vmathV3Cross( &tmp1, &mat->col2, &mat->col0 ); + vmathV3Cross( &tmp2, &mat->col0, &mat->col1 ); + detinv = ( 1.0f / vmathV3Dot( &mat->col2, &tmp2 ) ); + vmathV3MakeFromElems( &result->col0, ( tmp0.x * detinv ), ( tmp1.x * detinv ), ( tmp2.x * detinv ) ); + vmathV3MakeFromElems( &result->col1, ( tmp0.y * detinv ), ( tmp1.y * detinv ), ( tmp2.y * detinv ) ); + vmathV3MakeFromElems( &result->col2, ( tmp0.z * detinv ), ( tmp1.z * detinv ), ( tmp2.z * detinv ) ); +} + +static inline float vmathM3Determinant( const VmathMatrix3 *mat ) +{ + VmathVector3 tmpV3_0; + vmathV3Cross( &tmpV3_0, &mat->col0, &mat->col1 ); + return vmathV3Dot( &mat->col2, &tmpV3_0 ); +} + +static inline void vmathM3Add( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ) +{ + vmathV3Add( &result->col0, &mat0->col0, &mat1->col0 ); + vmathV3Add( &result->col1, &mat0->col1, &mat1->col1 ); + vmathV3Add( &result->col2, &mat0->col2, &mat1->col2 ); +} + +static inline void vmathM3Sub( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ) +{ + vmathV3Sub( &result->col0, &mat0->col0, &mat1->col0 ); + vmathV3Sub( &result->col1, &mat0->col1, &mat1->col1 ); + vmathV3Sub( &result->col2, &mat0->col2, &mat1->col2 ); +} + +static inline void vmathM3Neg( VmathMatrix3 *result, const VmathMatrix3 *mat ) +{ + vmathV3Neg( &result->col0, &mat->col0 ); + vmathV3Neg( &result->col1, &mat->col1 ); + vmathV3Neg( &result->col2, &mat->col2 ); +} + +static inline void vmathM3AbsPerElem( VmathMatrix3 *result, const VmathMatrix3 *mat ) +{ + vmathV3AbsPerElem( &result->col0, &mat->col0 ); + vmathV3AbsPerElem( &result->col1, &mat->col1 ); + vmathV3AbsPerElem( &result->col2, &mat->col2 ); +} + +static inline void vmathM3ScalarMul( VmathMatrix3 *result, const VmathMatrix3 *mat, float scalar ) +{ + vmathV3ScalarMul( &result->col0, &mat->col0, scalar ); + vmathV3ScalarMul( &result->col1, &mat->col1, scalar ); + vmathV3ScalarMul( &result->col2, &mat->col2, scalar ); +} + +static inline void vmathM3MulV3( VmathVector3 *result, const VmathMatrix3 *mat, const VmathVector3 *vec ) +{ + float tmpX, tmpY, tmpZ; + tmpX = ( ( ( mat->col0.x * vec->x ) + ( mat->col1.x * vec->y ) ) + ( mat->col2.x * vec->z ) ); + tmpY = ( ( ( mat->col0.y * vec->x ) + ( mat->col1.y * vec->y ) ) + ( mat->col2.y * vec->z ) ); + tmpZ = ( ( ( mat->col0.z * vec->x ) + ( mat->col1.z * vec->y ) ) + ( mat->col2.z * vec->z ) ); + vmathV3MakeFromElems( result, tmpX, tmpY, tmpZ ); +} + +static inline void vmathM3Mul( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ) +{ + VmathMatrix3 tmpResult; + vmathM3MulV3( &tmpResult.col0, mat0, &mat1->col0 ); + vmathM3MulV3( &tmpResult.col1, mat0, &mat1->col1 ); + vmathM3MulV3( &tmpResult.col2, mat0, &mat1->col2 ); + vmathM3Copy( result, &tmpResult ); +} + +static inline void vmathM3MulPerElem( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ) +{ + vmathV3MulPerElem( &result->col0, &mat0->col0, &mat1->col0 ); + vmathV3MulPerElem( &result->col1, &mat0->col1, &mat1->col1 ); + vmathV3MulPerElem( &result->col2, &mat0->col2, &mat1->col2 ); +} + +static inline void vmathM3MakeIdentity( VmathMatrix3 *result ) +{ + vmathV3MakeXAxis( &result->col0 ); + vmathV3MakeYAxis( &result->col1 ); + vmathV3MakeZAxis( &result->col2 ); +} + +static inline void vmathM3MakeRotationX( VmathMatrix3 *result, float radians ) +{ + float s, c; + s = sinf( radians ); + c = cosf( radians ); + vmathV3MakeXAxis( &result->col0 ); + vmathV3MakeFromElems( &result->col1, 0.0f, c, s ); + vmathV3MakeFromElems( &result->col2, 0.0f, -s, c ); +} + +static inline void vmathM3MakeRotationY( VmathMatrix3 *result, float radians ) +{ + float s, c; + s = sinf( radians ); + c = cosf( radians ); + vmathV3MakeFromElems( &result->col0, c, 0.0f, -s ); + vmathV3MakeYAxis( &result->col1 ); + vmathV3MakeFromElems( &result->col2, s, 0.0f, c ); +} + +static inline void vmathM3MakeRotationZ( VmathMatrix3 *result, float radians ) +{ + float s, c; + s = sinf( radians ); + c = cosf( radians ); + vmathV3MakeFromElems( &result->col0, c, s, 0.0f ); + vmathV3MakeFromElems( &result->col1, -s, c, 0.0f ); + vmathV3MakeZAxis( &result->col2 ); +} + +static inline void vmathM3MakeRotationZYX( VmathMatrix3 *result, const VmathVector3 *radiansXYZ ) +{ + float sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; + sX = sinf( radiansXYZ->x ); + cX = cosf( radiansXYZ->x ); + sY = sinf( radiansXYZ->y ); + cY = cosf( radiansXYZ->y ); + sZ = sinf( radiansXYZ->z ); + cZ = cosf( radiansXYZ->z ); + tmp0 = ( cZ * sY ); + tmp1 = ( sZ * sY ); + vmathV3MakeFromElems( &result->col0, ( cZ * cY ), ( sZ * cY ), -sY ); + vmathV3MakeFromElems( &result->col1, ( ( tmp0 * sX ) - ( sZ * cX ) ), ( ( tmp1 * sX ) + ( cZ * cX ) ), ( cY * sX ) ); + vmathV3MakeFromElems( &result->col2, ( ( tmp0 * cX ) + ( sZ * sX ) ), ( ( tmp1 * cX ) - ( cZ * sX ) ), ( cY * cX ) ); +} + +static inline void vmathM3MakeRotationAxis( VmathMatrix3 *result, float radians, const VmathVector3 *unitVec ) +{ + float x, y, z, s, c, oneMinusC, xy, yz, zx; + s = sinf( radians ); + c = cosf( radians ); + x = unitVec->x; + y = unitVec->y; + z = unitVec->z; + xy = ( x * y ); + yz = ( y * z ); + zx = ( z * x ); + oneMinusC = ( 1.0f - c ); + vmathV3MakeFromElems( &result->col0, ( ( ( x * x ) * oneMinusC ) + c ), ( ( xy * oneMinusC ) + ( z * s ) ), ( ( zx * oneMinusC ) - ( y * s ) ) ); + vmathV3MakeFromElems( &result->col1, ( ( xy * oneMinusC ) - ( z * s ) ), ( ( ( y * y ) * oneMinusC ) + c ), ( ( yz * oneMinusC ) + ( x * s ) ) ); + vmathV3MakeFromElems( &result->col2, ( ( zx * oneMinusC ) + ( y * s ) ), ( ( yz * oneMinusC ) - ( x * s ) ), ( ( ( z * z ) * oneMinusC ) + c ) ); +} + +static inline void vmathM3MakeRotationQ( VmathMatrix3 *result, const VmathQuat *unitQuat ) +{ + vmathM3MakeFromQ( result, unitQuat ); +} + +static inline void vmathM3MakeScale( VmathMatrix3 *result, const VmathVector3 *scaleVec ) +{ + vmathV3MakeFromElems( &result->col0, scaleVec->x, 0.0f, 0.0f ); + vmathV3MakeFromElems( &result->col1, 0.0f, scaleVec->y, 0.0f ); + vmathV3MakeFromElems( &result->col2, 0.0f, 0.0f, scaleVec->z ); +} + +static inline void vmathM3AppendScale( VmathMatrix3 *result, const VmathMatrix3 *mat, const VmathVector3 *scaleVec ) +{ + vmathV3ScalarMul( &result->col0, &mat->col0, vmathV3GetX( scaleVec ) ); + vmathV3ScalarMul( &result->col1, &mat->col1, vmathV3GetY( scaleVec ) ); + vmathV3ScalarMul( &result->col2, &mat->col2, vmathV3GetZ( scaleVec ) ); +} + +static inline void vmathM3PrependScale( VmathMatrix3 *result, const VmathVector3 *scaleVec, const VmathMatrix3 *mat ) +{ + vmathV3MulPerElem( &result->col0, &mat->col0, scaleVec ); + vmathV3MulPerElem( &result->col1, &mat->col1, scaleVec ); + vmathV3MulPerElem( &result->col2, &mat->col2, scaleVec ); +} + +static inline void vmathM3Select( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1, unsigned int select1 ) +{ + vmathV3Select( &result->col0, &mat0->col0, &mat1->col0, select1 ); + vmathV3Select( &result->col1, &mat0->col1, &mat1->col1, select1 ); + vmathV3Select( &result->col2, &mat0->col2, &mat1->col2, select1 ); +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathM3Print( const VmathMatrix3 *mat ) +{ + VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2; + vmathM3GetRow( &tmpV3_0, mat, 0 ); + vmathV3Print( &tmpV3_0 ); + vmathM3GetRow( &tmpV3_1, mat, 1 ); + vmathV3Print( &tmpV3_1 ); + vmathM3GetRow( &tmpV3_2, mat, 2 ); + vmathV3Print( &tmpV3_2 ); +} + +static inline void vmathM3Prints( const VmathMatrix3 *mat, const char *name ) +{ + printf("%s:\n", name); + vmathM3Print( mat ); +} + +#endif + +static inline void vmathM4Copy( VmathMatrix4 *result, const VmathMatrix4 *mat ) +{ + vmathV4Copy( &result->col0, &mat->col0 ); + vmathV4Copy( &result->col1, &mat->col1 ); + vmathV4Copy( &result->col2, &mat->col2 ); + vmathV4Copy( &result->col3, &mat->col3 ); +} + +static inline void vmathM4MakeFromScalar( VmathMatrix4 *result, float scalar ) +{ + vmathV4MakeFromScalar( &result->col0, scalar ); + vmathV4MakeFromScalar( &result->col1, scalar ); + vmathV4MakeFromScalar( &result->col2, scalar ); + vmathV4MakeFromScalar( &result->col3, scalar ); +} + +static inline void vmathM4MakeFromT3( VmathMatrix4 *result, const VmathTransform3 *mat ) +{ + vmathV4MakeFromV3Scalar( &result->col0, &mat->col0, 0.0f ); + vmathV4MakeFromV3Scalar( &result->col1, &mat->col1, 0.0f ); + vmathV4MakeFromV3Scalar( &result->col2, &mat->col2, 0.0f ); + vmathV4MakeFromV3Scalar( &result->col3, &mat->col3, 1.0f ); +} + +static inline void vmathM4MakeFromCols( VmathMatrix4 *result, const VmathVector4 *_col0, const VmathVector4 *_col1, const VmathVector4 *_col2, const VmathVector4 *_col3 ) +{ + vmathV4Copy( &result->col0, _col0 ); + vmathV4Copy( &result->col1, _col1 ); + vmathV4Copy( &result->col2, _col2 ); + vmathV4Copy( &result->col3, _col3 ); +} + +static inline void vmathM4MakeFromM3V3( VmathMatrix4 *result, const VmathMatrix3 *mat, const VmathVector3 *translateVec ) +{ + vmathV4MakeFromV3Scalar( &result->col0, &mat->col0, 0.0f ); + vmathV4MakeFromV3Scalar( &result->col1, &mat->col1, 0.0f ); + vmathV4MakeFromV3Scalar( &result->col2, &mat->col2, 0.0f ); + vmathV4MakeFromV3Scalar( &result->col3, translateVec, 1.0f ); +} + +static inline void vmathM4MakeFromQV3( VmathMatrix4 *result, const VmathQuat *unitQuat, const VmathVector3 *translateVec ) +{ + VmathMatrix3 mat; + vmathM3MakeFromQ( &mat, unitQuat ); + vmathV4MakeFromV3Scalar( &result->col0, &mat.col0, 0.0f ); + vmathV4MakeFromV3Scalar( &result->col1, &mat.col1, 0.0f ); + vmathV4MakeFromV3Scalar( &result->col2, &mat.col2, 0.0f ); + vmathV4MakeFromV3Scalar( &result->col3, translateVec, 1.0f ); +} + +static inline void vmathM4SetCol0( VmathMatrix4 *result, const VmathVector4 *_col0 ) +{ + vmathV4Copy( &result->col0, _col0 ); +} + +static inline void vmathM4SetCol1( VmathMatrix4 *result, const VmathVector4 *_col1 ) +{ + vmathV4Copy( &result->col1, _col1 ); +} + +static inline void vmathM4SetCol2( VmathMatrix4 *result, const VmathVector4 *_col2 ) +{ + vmathV4Copy( &result->col2, _col2 ); +} + +static inline void vmathM4SetCol3( VmathMatrix4 *result, const VmathVector4 *_col3 ) +{ + vmathV4Copy( &result->col3, _col3 ); +} + +static inline void vmathM4SetCol( VmathMatrix4 *result, int col, const VmathVector4 *vec ) +{ + vmathV4Copy( (&result->col0 + col), vec ); +} + +static inline void vmathM4SetRow( VmathMatrix4 *result, int row, const VmathVector4 *vec ) +{ + vmathV4SetElem( &result->col0, row, vmathV4GetElem( vec, 0 ) ); + vmathV4SetElem( &result->col1, row, vmathV4GetElem( vec, 1 ) ); + vmathV4SetElem( &result->col2, row, vmathV4GetElem( vec, 2 ) ); + vmathV4SetElem( &result->col3, row, vmathV4GetElem( vec, 3 ) ); +} + +static inline void vmathM4SetElem( VmathMatrix4 *result, int col, int row, float val ) +{ + VmathVector4 tmpV3_0; + vmathM4GetCol( &tmpV3_0, result, col ); + vmathV4SetElem( &tmpV3_0, row, val ); + vmathM4SetCol( result, col, &tmpV3_0 ); +} + +static inline float vmathM4GetElem( const VmathMatrix4 *mat, int col, int row ) +{ + VmathVector4 tmpV4_0; + vmathM4GetCol( &tmpV4_0, mat, col ); + return vmathV4GetElem( &tmpV4_0, row ); +} + +static inline void vmathM4GetCol0( VmathVector4 *result, const VmathMatrix4 *mat ) +{ + vmathV4Copy( result, &mat->col0 ); +} + +static inline void vmathM4GetCol1( VmathVector4 *result, const VmathMatrix4 *mat ) +{ + vmathV4Copy( result, &mat->col1 ); +} + +static inline void vmathM4GetCol2( VmathVector4 *result, const VmathMatrix4 *mat ) +{ + vmathV4Copy( result, &mat->col2 ); +} + +static inline void vmathM4GetCol3( VmathVector4 *result, const VmathMatrix4 *mat ) +{ + vmathV4Copy( result, &mat->col3 ); +} + +static inline void vmathM4GetCol( VmathVector4 *result, const VmathMatrix4 *mat, int col ) +{ + vmathV4Copy( result, (&mat->col0 + col) ); +} + +static inline void vmathM4GetRow( VmathVector4 *result, const VmathMatrix4 *mat, int row ) +{ + vmathV4MakeFromElems( result, vmathV4GetElem( &mat->col0, row ), vmathV4GetElem( &mat->col1, row ), vmathV4GetElem( &mat->col2, row ), vmathV4GetElem( &mat->col3, row ) ); +} + +static inline void vmathM4Transpose( VmathMatrix4 *result, const VmathMatrix4 *mat ) +{ + VmathMatrix4 tmpResult; + vmathV4MakeFromElems( &tmpResult.col0, mat->col0.x, mat->col1.x, mat->col2.x, mat->col3.x ); + vmathV4MakeFromElems( &tmpResult.col1, mat->col0.y, mat->col1.y, mat->col2.y, mat->col3.y ); + vmathV4MakeFromElems( &tmpResult.col2, mat->col0.z, mat->col1.z, mat->col2.z, mat->col3.z ); + vmathV4MakeFromElems( &tmpResult.col3, mat->col0.w, mat->col1.w, mat->col2.w, mat->col3.w ); + vmathM4Copy( result, &tmpResult ); +} + +static inline void vmathM4Inverse( VmathMatrix4 *result, const VmathMatrix4 *mat ) +{ + VmathVector4 res0, res1, res2, res3; + float mA, mB, mC, mD, mE, mF, mG, mH, mI, mJ, mK, mL, mM, mN, mO, mP, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, detInv; + mA = mat->col0.x; + mB = mat->col0.y; + mC = mat->col0.z; + mD = mat->col0.w; + mE = mat->col1.x; + mF = mat->col1.y; + mG = mat->col1.z; + mH = mat->col1.w; + mI = mat->col2.x; + mJ = mat->col2.y; + mK = mat->col2.z; + mL = mat->col2.w; + mM = mat->col3.x; + mN = mat->col3.y; + mO = mat->col3.z; + mP = mat->col3.w; + tmp0 = ( ( mK * mD ) - ( mC * mL ) ); + tmp1 = ( ( mO * mH ) - ( mG * mP ) ); + tmp2 = ( ( mB * mK ) - ( mJ * mC ) ); + tmp3 = ( ( mF * mO ) - ( mN * mG ) ); + tmp4 = ( ( mJ * mD ) - ( mB * mL ) ); + tmp5 = ( ( mN * mH ) - ( mF * mP ) ); + vmathV4SetX( &res0, ( ( ( mJ * tmp1 ) - ( mL * tmp3 ) ) - ( mK * tmp5 ) ) ); + vmathV4SetY( &res0, ( ( ( mN * tmp0 ) - ( mP * tmp2 ) ) - ( mO * tmp4 ) ) ); + vmathV4SetZ( &res0, ( ( ( mD * tmp3 ) + ( mC * tmp5 ) ) - ( mB * tmp1 ) ) ); + vmathV4SetW( &res0, ( ( ( mH * tmp2 ) + ( mG * tmp4 ) ) - ( mF * tmp0 ) ) ); + detInv = ( 1.0f / ( ( ( ( mA * res0.x ) + ( mE * res0.y ) ) + ( mI * res0.z ) ) + ( mM * res0.w ) ) ); + vmathV4SetX( &res1, ( mI * tmp1 ) ); + vmathV4SetY( &res1, ( mM * tmp0 ) ); + vmathV4SetZ( &res1, ( mA * tmp1 ) ); + vmathV4SetW( &res1, ( mE * tmp0 ) ); + vmathV4SetX( &res3, ( mI * tmp3 ) ); + vmathV4SetY( &res3, ( mM * tmp2 ) ); + vmathV4SetZ( &res3, ( mA * tmp3 ) ); + vmathV4SetW( &res3, ( mE * tmp2 ) ); + vmathV4SetX( &res2, ( mI * tmp5 ) ); + vmathV4SetY( &res2, ( mM * tmp4 ) ); + vmathV4SetZ( &res2, ( mA * tmp5 ) ); + vmathV4SetW( &res2, ( mE * tmp4 ) ); + tmp0 = ( ( mI * mB ) - ( mA * mJ ) ); + tmp1 = ( ( mM * mF ) - ( mE * mN ) ); + tmp2 = ( ( mI * mD ) - ( mA * mL ) ); + tmp3 = ( ( mM * mH ) - ( mE * mP ) ); + tmp4 = ( ( mI * mC ) - ( mA * mK ) ); + tmp5 = ( ( mM * mG ) - ( mE * mO ) ); + vmathV4SetX( &res2, ( ( ( mL * tmp1 ) - ( mJ * tmp3 ) ) + res2.x ) ); + vmathV4SetY( &res2, ( ( ( mP * tmp0 ) - ( mN * tmp2 ) ) + res2.y ) ); + vmathV4SetZ( &res2, ( ( ( mB * tmp3 ) - ( mD * tmp1 ) ) - res2.z ) ); + vmathV4SetW( &res2, ( ( ( mF * tmp2 ) - ( mH * tmp0 ) ) - res2.w ) ); + vmathV4SetX( &res3, ( ( ( mJ * tmp5 ) - ( mK * tmp1 ) ) + res3.x ) ); + vmathV4SetY( &res3, ( ( ( mN * tmp4 ) - ( mO * tmp0 ) ) + res3.y ) ); + vmathV4SetZ( &res3, ( ( ( mC * tmp1 ) - ( mB * tmp5 ) ) - res3.z ) ); + vmathV4SetW( &res3, ( ( ( mG * tmp0 ) - ( mF * tmp4 ) ) - res3.w ) ); + vmathV4SetX( &res1, ( ( ( mK * tmp3 ) - ( mL * tmp5 ) ) - res1.x ) ); + vmathV4SetY( &res1, ( ( ( mO * tmp2 ) - ( mP * tmp4 ) ) - res1.y ) ); + vmathV4SetZ( &res1, ( ( ( mD * tmp5 ) - ( mC * tmp3 ) ) + res1.z ) ); + vmathV4SetW( &res1, ( ( ( mH * tmp4 ) - ( mG * tmp2 ) ) + res1.w ) ); + vmathV4ScalarMul( &result->col0, &res0, detInv ); + vmathV4ScalarMul( &result->col1, &res1, detInv ); + vmathV4ScalarMul( &result->col2, &res2, detInv ); + vmathV4ScalarMul( &result->col3, &res3, detInv ); +} + +static inline void vmathM4AffineInverse( VmathMatrix4 *result, const VmathMatrix4 *mat ) +{ + VmathTransform3 affineMat, tmpT3_0; + VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3; + vmathV4GetXYZ( &tmpV3_0, &mat->col0 ); + vmathT3SetCol0( &affineMat, &tmpV3_0 ); + vmathV4GetXYZ( &tmpV3_1, &mat->col1 ); + vmathT3SetCol1( &affineMat, &tmpV3_1 ); + vmathV4GetXYZ( &tmpV3_2, &mat->col2 ); + vmathT3SetCol2( &affineMat, &tmpV3_2 ); + vmathV4GetXYZ( &tmpV3_3, &mat->col3 ); + vmathT3SetCol3( &affineMat, &tmpV3_3 ); + vmathT3Inverse( &tmpT3_0, &affineMat ); + vmathM4MakeFromT3( result, &tmpT3_0 ); +} + +static inline void vmathM4OrthoInverse( VmathMatrix4 *result, const VmathMatrix4 *mat ) +{ + VmathTransform3 affineMat, tmpT3_0; + VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3; + vmathV4GetXYZ( &tmpV3_0, &mat->col0 ); + vmathT3SetCol0( &affineMat, &tmpV3_0 ); + vmathV4GetXYZ( &tmpV3_1, &mat->col1 ); + vmathT3SetCol1( &affineMat, &tmpV3_1 ); + vmathV4GetXYZ( &tmpV3_2, &mat->col2 ); + vmathT3SetCol2( &affineMat, &tmpV3_2 ); + vmathV4GetXYZ( &tmpV3_3, &mat->col3 ); + vmathT3SetCol3( &affineMat, &tmpV3_3 ); + vmathT3OrthoInverse( &tmpT3_0, &affineMat ); + vmathM4MakeFromT3( result, &tmpT3_0 ); +} + +static inline float vmathM4Determinant( const VmathMatrix4 *mat ) +{ + float dx, dy, dz, dw, mA, mB, mC, mD, mE, mF, mG, mH, mI, mJ, mK, mL, mM, mN, mO, mP, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; + mA = mat->col0.x; + mB = mat->col0.y; + mC = mat->col0.z; + mD = mat->col0.w; + mE = mat->col1.x; + mF = mat->col1.y; + mG = mat->col1.z; + mH = mat->col1.w; + mI = mat->col2.x; + mJ = mat->col2.y; + mK = mat->col2.z; + mL = mat->col2.w; + mM = mat->col3.x; + mN = mat->col3.y; + mO = mat->col3.z; + mP = mat->col3.w; + tmp0 = ( ( mK * mD ) - ( mC * mL ) ); + tmp1 = ( ( mO * mH ) - ( mG * mP ) ); + tmp2 = ( ( mB * mK ) - ( mJ * mC ) ); + tmp3 = ( ( mF * mO ) - ( mN * mG ) ); + tmp4 = ( ( mJ * mD ) - ( mB * mL ) ); + tmp5 = ( ( mN * mH ) - ( mF * mP ) ); + dx = ( ( ( mJ * tmp1 ) - ( mL * tmp3 ) ) - ( mK * tmp5 ) ); + dy = ( ( ( mN * tmp0 ) - ( mP * tmp2 ) ) - ( mO * tmp4 ) ); + dz = ( ( ( mD * tmp3 ) + ( mC * tmp5 ) ) - ( mB * tmp1 ) ); + dw = ( ( ( mH * tmp2 ) + ( mG * tmp4 ) ) - ( mF * tmp0 ) ); + return ( ( ( ( mA * dx ) + ( mE * dy ) ) + ( mI * dz ) ) + ( mM * dw ) ); +} + +static inline void vmathM4Add( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ) +{ + vmathV4Add( &result->col0, &mat0->col0, &mat1->col0 ); + vmathV4Add( &result->col1, &mat0->col1, &mat1->col1 ); + vmathV4Add( &result->col2, &mat0->col2, &mat1->col2 ); + vmathV4Add( &result->col3, &mat0->col3, &mat1->col3 ); +} + +static inline void vmathM4Sub( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ) +{ + vmathV4Sub( &result->col0, &mat0->col0, &mat1->col0 ); + vmathV4Sub( &result->col1, &mat0->col1, &mat1->col1 ); + vmathV4Sub( &result->col2, &mat0->col2, &mat1->col2 ); + vmathV4Sub( &result->col3, &mat0->col3, &mat1->col3 ); +} + +static inline void vmathM4Neg( VmathMatrix4 *result, const VmathMatrix4 *mat ) +{ + vmathV4Neg( &result->col0, &mat->col0 ); + vmathV4Neg( &result->col1, &mat->col1 ); + vmathV4Neg( &result->col2, &mat->col2 ); + vmathV4Neg( &result->col3, &mat->col3 ); +} + +static inline void vmathM4AbsPerElem( VmathMatrix4 *result, const VmathMatrix4 *mat ) +{ + vmathV4AbsPerElem( &result->col0, &mat->col0 ); + vmathV4AbsPerElem( &result->col1, &mat->col1 ); + vmathV4AbsPerElem( &result->col2, &mat->col2 ); + vmathV4AbsPerElem( &result->col3, &mat->col3 ); +} + +static inline void vmathM4ScalarMul( VmathMatrix4 *result, const VmathMatrix4 *mat, float scalar ) +{ + vmathV4ScalarMul( &result->col0, &mat->col0, scalar ); + vmathV4ScalarMul( &result->col1, &mat->col1, scalar ); + vmathV4ScalarMul( &result->col2, &mat->col2, scalar ); + vmathV4ScalarMul( &result->col3, &mat->col3, scalar ); +} + +static inline void vmathM4MulV4( VmathVector4 *result, const VmathMatrix4 *mat, const VmathVector4 *vec ) +{ + float tmpX, tmpY, tmpZ, tmpW; + tmpX = ( ( ( ( mat->col0.x * vec->x ) + ( mat->col1.x * vec->y ) ) + ( mat->col2.x * vec->z ) ) + ( mat->col3.x * vec->w ) ); + tmpY = ( ( ( ( mat->col0.y * vec->x ) + ( mat->col1.y * vec->y ) ) + ( mat->col2.y * vec->z ) ) + ( mat->col3.y * vec->w ) ); + tmpZ = ( ( ( ( mat->col0.z * vec->x ) + ( mat->col1.z * vec->y ) ) + ( mat->col2.z * vec->z ) ) + ( mat->col3.z * vec->w ) ); + tmpW = ( ( ( ( mat->col0.w * vec->x ) + ( mat->col1.w * vec->y ) ) + ( mat->col2.w * vec->z ) ) + ( mat->col3.w * vec->w ) ); + vmathV4MakeFromElems( result, tmpX, tmpY, tmpZ, tmpW ); +} + +static inline void vmathM4MulV3( VmathVector4 *result, const VmathMatrix4 *mat, const VmathVector3 *vec ) +{ + result->x = ( ( ( mat->col0.x * vec->x ) + ( mat->col1.x * vec->y ) ) + ( mat->col2.x * vec->z ) ); + result->y = ( ( ( mat->col0.y * vec->x ) + ( mat->col1.y * vec->y ) ) + ( mat->col2.y * vec->z ) ); + result->z = ( ( ( mat->col0.z * vec->x ) + ( mat->col1.z * vec->y ) ) + ( mat->col2.z * vec->z ) ); + result->w = ( ( ( mat->col0.w * vec->x ) + ( mat->col1.w * vec->y ) ) + ( mat->col2.w * vec->z ) ); +} + +static inline void vmathM4MulP3( VmathVector4 *result, const VmathMatrix4 *mat, const VmathPoint3 *pnt ) +{ + result->x = ( ( ( ( mat->col0.x * pnt->x ) + ( mat->col1.x * pnt->y ) ) + ( mat->col2.x * pnt->z ) ) + mat->col3.x ); + result->y = ( ( ( ( mat->col0.y * pnt->x ) + ( mat->col1.y * pnt->y ) ) + ( mat->col2.y * pnt->z ) ) + mat->col3.y ); + result->z = ( ( ( ( mat->col0.z * pnt->x ) + ( mat->col1.z * pnt->y ) ) + ( mat->col2.z * pnt->z ) ) + mat->col3.z ); + result->w = ( ( ( ( mat->col0.w * pnt->x ) + ( mat->col1.w * pnt->y ) ) + ( mat->col2.w * pnt->z ) ) + mat->col3.w ); +} + +static inline void vmathM4Mul( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ) +{ + VmathMatrix4 tmpResult; + vmathM4MulV4( &tmpResult.col0, mat0, &mat1->col0 ); + vmathM4MulV4( &tmpResult.col1, mat0, &mat1->col1 ); + vmathM4MulV4( &tmpResult.col2, mat0, &mat1->col2 ); + vmathM4MulV4( &tmpResult.col3, mat0, &mat1->col3 ); + vmathM4Copy( result, &tmpResult ); +} + +static inline void vmathM4MulT3( VmathMatrix4 *result, const VmathMatrix4 *mat, const VmathTransform3 *tfrm1 ) +{ + VmathMatrix4 tmpResult; + VmathPoint3 tmpP3_0; + vmathM4MulV3( &tmpResult.col0, mat, &tfrm1->col0 ); + vmathM4MulV3( &tmpResult.col1, mat, &tfrm1->col1 ); + vmathM4MulV3( &tmpResult.col2, mat, &tfrm1->col2 ); + vmathP3MakeFromV3( &tmpP3_0, &tfrm1->col3 ); + vmathM4MulP3( &tmpResult.col3, mat, &tmpP3_0 ); + vmathM4Copy( result, &tmpResult ); +} + +static inline void vmathM4MulPerElem( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ) +{ + vmathV4MulPerElem( &result->col0, &mat0->col0, &mat1->col0 ); + vmathV4MulPerElem( &result->col1, &mat0->col1, &mat1->col1 ); + vmathV4MulPerElem( &result->col2, &mat0->col2, &mat1->col2 ); + vmathV4MulPerElem( &result->col3, &mat0->col3, &mat1->col3 ); +} + +static inline void vmathM4MakeIdentity( VmathMatrix4 *result ) +{ + vmathV4MakeXAxis( &result->col0 ); + vmathV4MakeYAxis( &result->col1 ); + vmathV4MakeZAxis( &result->col2 ); + vmathV4MakeWAxis( &result->col3 ); +} + +static inline void vmathM4SetUpper3x3( VmathMatrix4 *result, const VmathMatrix3 *mat3 ) +{ + vmathV4SetXYZ( &result->col0, &mat3->col0 ); + vmathV4SetXYZ( &result->col1, &mat3->col1 ); + vmathV4SetXYZ( &result->col2, &mat3->col2 ); +} + +static inline void vmathM4GetUpper3x3( VmathMatrix3 *result, const VmathMatrix4 *mat ) +{ + vmathV4GetXYZ( &result->col0, &mat->col0 ); + vmathV4GetXYZ( &result->col1, &mat->col1 ); + vmathV4GetXYZ( &result->col2, &mat->col2 ); +} + +static inline void vmathM4SetTranslation( VmathMatrix4 *result, const VmathVector3 *translateVec ) +{ + vmathV4SetXYZ( &result->col3, translateVec ); +} + +static inline void vmathM4GetTranslation( VmathVector3 *result, const VmathMatrix4 *mat ) +{ + vmathV4GetXYZ( result, &mat->col3 ); +} + +static inline void vmathM4MakeRotationX( VmathMatrix4 *result, float radians ) +{ + float s, c; + s = sinf( radians ); + c = cosf( radians ); + vmathV4MakeXAxis( &result->col0 ); + vmathV4MakeFromElems( &result->col1, 0.0f, c, s, 0.0f ); + vmathV4MakeFromElems( &result->col2, 0.0f, -s, c, 0.0f ); + vmathV4MakeWAxis( &result->col3 ); +} + +static inline void vmathM4MakeRotationY( VmathMatrix4 *result, float radians ) +{ + float s, c; + s = sinf( radians ); + c = cosf( radians ); + vmathV4MakeFromElems( &result->col0, c, 0.0f, -s, 0.0f ); + vmathV4MakeYAxis( &result->col1 ); + vmathV4MakeFromElems( &result->col2, s, 0.0f, c, 0.0f ); + vmathV4MakeWAxis( &result->col3 ); +} + +static inline void vmathM4MakeRotationZ( VmathMatrix4 *result, float radians ) +{ + float s, c; + s = sinf( radians ); + c = cosf( radians ); + vmathV4MakeFromElems( &result->col0, c, s, 0.0f, 0.0f ); + vmathV4MakeFromElems( &result->col1, -s, c, 0.0f, 0.0f ); + vmathV4MakeZAxis( &result->col2 ); + vmathV4MakeWAxis( &result->col3 ); +} + +static inline void vmathM4MakeRotationZYX( VmathMatrix4 *result, const VmathVector3 *radiansXYZ ) +{ + float sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; + sX = sinf( radiansXYZ->x ); + cX = cosf( radiansXYZ->x ); + sY = sinf( radiansXYZ->y ); + cY = cosf( radiansXYZ->y ); + sZ = sinf( radiansXYZ->z ); + cZ = cosf( radiansXYZ->z ); + tmp0 = ( cZ * sY ); + tmp1 = ( sZ * sY ); + vmathV4MakeFromElems( &result->col0, ( cZ * cY ), ( sZ * cY ), -sY, 0.0f ); + vmathV4MakeFromElems( &result->col1, ( ( tmp0 * sX ) - ( sZ * cX ) ), ( ( tmp1 * sX ) + ( cZ * cX ) ), ( cY * sX ), 0.0f ); + vmathV4MakeFromElems( &result->col2, ( ( tmp0 * cX ) + ( sZ * sX ) ), ( ( tmp1 * cX ) - ( cZ * sX ) ), ( cY * cX ), 0.0f ); + vmathV4MakeWAxis( &result->col3 ); +} + +static inline void vmathM4MakeRotationAxis( VmathMatrix4 *result, float radians, const VmathVector3 *unitVec ) +{ + float x, y, z, s, c, oneMinusC, xy, yz, zx; + s = sinf( radians ); + c = cosf( radians ); + x = unitVec->x; + y = unitVec->y; + z = unitVec->z; + xy = ( x * y ); + yz = ( y * z ); + zx = ( z * x ); + oneMinusC = ( 1.0f - c ); + vmathV4MakeFromElems( &result->col0, ( ( ( x * x ) * oneMinusC ) + c ), ( ( xy * oneMinusC ) + ( z * s ) ), ( ( zx * oneMinusC ) - ( y * s ) ), 0.0f ); + vmathV4MakeFromElems( &result->col1, ( ( xy * oneMinusC ) - ( z * s ) ), ( ( ( y * y ) * oneMinusC ) + c ), ( ( yz * oneMinusC ) + ( x * s ) ), 0.0f ); + vmathV4MakeFromElems( &result->col2, ( ( zx * oneMinusC ) + ( y * s ) ), ( ( yz * oneMinusC ) - ( x * s ) ), ( ( ( z * z ) * oneMinusC ) + c ), 0.0f ); + vmathV4MakeWAxis( &result->col3 ); +} + +static inline void vmathM4MakeRotationQ( VmathMatrix4 *result, const VmathQuat *unitQuat ) +{ + VmathTransform3 tmpT3_0; + vmathT3MakeRotationQ( &tmpT3_0, unitQuat ); + vmathM4MakeFromT3( result, &tmpT3_0 ); +} + +static inline void vmathM4MakeScale( VmathMatrix4 *result, const VmathVector3 *scaleVec ) +{ + vmathV4MakeFromElems( &result->col0, scaleVec->x, 0.0f, 0.0f, 0.0f ); + vmathV4MakeFromElems( &result->col1, 0.0f, scaleVec->y, 0.0f, 0.0f ); + vmathV4MakeFromElems( &result->col2, 0.0f, 0.0f, scaleVec->z, 0.0f ); + vmathV4MakeWAxis( &result->col3 ); +} + +static inline void vmathM4AppendScale( VmathMatrix4 *result, const VmathMatrix4 *mat, const VmathVector3 *scaleVec ) +{ + vmathV4ScalarMul( &result->col0, &mat->col0, vmathV3GetX( scaleVec ) ); + vmathV4ScalarMul( &result->col1, &mat->col1, vmathV3GetY( scaleVec ) ); + vmathV4ScalarMul( &result->col2, &mat->col2, vmathV3GetZ( scaleVec ) ); + vmathV4Copy( &result->col3, &mat->col3 ); +} + +static inline void vmathM4PrependScale( VmathMatrix4 *result, const VmathVector3 *scaleVec, const VmathMatrix4 *mat ) +{ + VmathVector4 scale4; + vmathV4MakeFromV3Scalar( &scale4, scaleVec, 1.0f ); + vmathV4MulPerElem( &result->col0, &mat->col0, &scale4 ); + vmathV4MulPerElem( &result->col1, &mat->col1, &scale4 ); + vmathV4MulPerElem( &result->col2, &mat->col2, &scale4 ); + vmathV4MulPerElem( &result->col3, &mat->col3, &scale4 ); +} + +static inline void vmathM4MakeTranslation( VmathMatrix4 *result, const VmathVector3 *translateVec ) +{ + vmathV4MakeXAxis( &result->col0 ); + vmathV4MakeYAxis( &result->col1 ); + vmathV4MakeZAxis( &result->col2 ); + vmathV4MakeFromV3Scalar( &result->col3, translateVec, 1.0f ); +} + +static inline void vmathM4MakeLookAt( VmathMatrix4 *result, const VmathPoint3 *eyePos, const VmathPoint3 *lookAtPos, const VmathVector3 *upVec ) +{ + VmathMatrix4 m4EyeFrame; + VmathVector3 v3X, v3Y, v3Z, tmpV3_0, tmpV3_1; + VmathVector4 tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3; + vmathV3Normalize( &v3Y, upVec ); + vmathP3Sub( &tmpV3_0, eyePos, lookAtPos ); + vmathV3Normalize( &v3Z, &tmpV3_0 ); + vmathV3Cross( &tmpV3_1, &v3Y, &v3Z ); + vmathV3Normalize( &v3X, &tmpV3_1 ); + vmathV3Cross( &v3Y, &v3Z, &v3X ); + vmathV4MakeFromV3( &tmpV4_0, &v3X ); + vmathV4MakeFromV3( &tmpV4_1, &v3Y ); + vmathV4MakeFromV3( &tmpV4_2, &v3Z ); + vmathV4MakeFromP3( &tmpV4_3, eyePos ); + vmathM4MakeFromCols( &m4EyeFrame, &tmpV4_0, &tmpV4_1, &tmpV4_2, &tmpV4_3 ); + vmathM4OrthoInverse( result, &m4EyeFrame ); +} + +static inline void vmathM4MakePerspective( VmathMatrix4 *result, float fovyRadians, float aspect, float zNear, float zFar ) +{ + float f, rangeInv; + f = tanf( ( (float)( _VECTORMATH_PI_OVER_2 ) - ( 0.5f * fovyRadians ) ) ); + rangeInv = ( 1.0f / ( zNear - zFar ) ); + vmathV4MakeFromElems( &result->col0, ( f / aspect ), 0.0f, 0.0f, 0.0f ); + vmathV4MakeFromElems( &result->col1, 0.0f, f, 0.0f, 0.0f ); + vmathV4MakeFromElems( &result->col2, 0.0f, 0.0f, ( ( zNear + zFar ) * rangeInv ), -1.0f ); + vmathV4MakeFromElems( &result->col3, 0.0f, 0.0f, ( ( ( zNear * zFar ) * rangeInv ) * 2.0f ), 0.0f ); +} + +static inline void vmathM4MakeFrustum( VmathMatrix4 *result, float left, float right, float bottom, float top, float zNear, float zFar ) +{ + float sum_rl, sum_tb, sum_nf, inv_rl, inv_tb, inv_nf, n2; + sum_rl = ( right + left ); + sum_tb = ( top + bottom ); + sum_nf = ( zNear + zFar ); + inv_rl = ( 1.0f / ( right - left ) ); + inv_tb = ( 1.0f / ( top - bottom ) ); + inv_nf = ( 1.0f / ( zNear - zFar ) ); + n2 = ( zNear + zNear ); + vmathV4MakeFromElems( &result->col0, ( n2 * inv_rl ), 0.0f, 0.0f, 0.0f ); + vmathV4MakeFromElems( &result->col1, 0.0f, ( n2 * inv_tb ), 0.0f, 0.0f ); + vmathV4MakeFromElems( &result->col2, ( sum_rl * inv_rl ), ( sum_tb * inv_tb ), ( sum_nf * inv_nf ), -1.0f ); + vmathV4MakeFromElems( &result->col3, 0.0f, 0.0f, ( ( n2 * inv_nf ) * zFar ), 0.0f ); +} + +static inline void vmathM4MakeOrthographic( VmathMatrix4 *result, float left, float right, float bottom, float top, float zNear, float zFar ) +{ + float sum_rl, sum_tb, sum_nf, inv_rl, inv_tb, inv_nf; + sum_rl = ( right + left ); + sum_tb = ( top + bottom ); + sum_nf = ( zNear + zFar ); + inv_rl = ( 1.0f / ( right - left ) ); + inv_tb = ( 1.0f / ( top - bottom ) ); + inv_nf = ( 1.0f / ( zNear - zFar ) ); + vmathV4MakeFromElems( &result->col0, ( inv_rl + inv_rl ), 0.0f, 0.0f, 0.0f ); + vmathV4MakeFromElems( &result->col1, 0.0f, ( inv_tb + inv_tb ), 0.0f, 0.0f ); + vmathV4MakeFromElems( &result->col2, 0.0f, 0.0f, ( inv_nf + inv_nf ), 0.0f ); + vmathV4MakeFromElems( &result->col3, ( -sum_rl * inv_rl ), ( -sum_tb * inv_tb ), ( sum_nf * inv_nf ), 1.0f ); +} + +static inline void vmathM4Select( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1, unsigned int select1 ) +{ + vmathV4Select( &result->col0, &mat0->col0, &mat1->col0, select1 ); + vmathV4Select( &result->col1, &mat0->col1, &mat1->col1, select1 ); + vmathV4Select( &result->col2, &mat0->col2, &mat1->col2, select1 ); + vmathV4Select( &result->col3, &mat0->col3, &mat1->col3, select1 ); +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathM4Print( const VmathMatrix4 *mat ) +{ + VmathVector4 tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3; + vmathM4GetRow( &tmpV4_0, mat, 0 ); + vmathV4Print( &tmpV4_0 ); + vmathM4GetRow( &tmpV4_1, mat, 1 ); + vmathV4Print( &tmpV4_1 ); + vmathM4GetRow( &tmpV4_2, mat, 2 ); + vmathV4Print( &tmpV4_2 ); + vmathM4GetRow( &tmpV4_3, mat, 3 ); + vmathV4Print( &tmpV4_3 ); +} + +static inline void vmathM4Prints( const VmathMatrix4 *mat, const char *name ) +{ + printf("%s:\n", name); + vmathM4Print( mat ); +} + +#endif + +static inline void vmathT3Copy( VmathTransform3 *result, const VmathTransform3 *tfrm ) +{ + vmathV3Copy( &result->col0, &tfrm->col0 ); + vmathV3Copy( &result->col1, &tfrm->col1 ); + vmathV3Copy( &result->col2, &tfrm->col2 ); + vmathV3Copy( &result->col3, &tfrm->col3 ); +} + +static inline void vmathT3MakeFromScalar( VmathTransform3 *result, float scalar ) +{ + vmathV3MakeFromScalar( &result->col0, scalar ); + vmathV3MakeFromScalar( &result->col1, scalar ); + vmathV3MakeFromScalar( &result->col2, scalar ); + vmathV3MakeFromScalar( &result->col3, scalar ); +} + +static inline void vmathT3MakeFromCols( VmathTransform3 *result, const VmathVector3 *_col0, const VmathVector3 *_col1, const VmathVector3 *_col2, const VmathVector3 *_col3 ) +{ + vmathV3Copy( &result->col0, _col0 ); + vmathV3Copy( &result->col1, _col1 ); + vmathV3Copy( &result->col2, _col2 ); + vmathV3Copy( &result->col3, _col3 ); +} + +static inline void vmathT3MakeFromM3V3( VmathTransform3 *result, const VmathMatrix3 *tfrm, const VmathVector3 *translateVec ) +{ + vmathT3SetUpper3x3( result, tfrm ); + vmathT3SetTranslation( result, translateVec ); +} + +static inline void vmathT3MakeFromQV3( VmathTransform3 *result, const VmathQuat *unitQuat, const VmathVector3 *translateVec ) +{ + VmathMatrix3 tmpM3_0; + vmathM3MakeFromQ( &tmpM3_0, unitQuat ); + vmathT3SetUpper3x3( result, &tmpM3_0 ); + vmathT3SetTranslation( result, translateVec ); +} + +static inline void vmathT3SetCol0( VmathTransform3 *result, const VmathVector3 *_col0 ) +{ + vmathV3Copy( &result->col0, _col0 ); +} + +static inline void vmathT3SetCol1( VmathTransform3 *result, const VmathVector3 *_col1 ) +{ + vmathV3Copy( &result->col1, _col1 ); +} + +static inline void vmathT3SetCol2( VmathTransform3 *result, const VmathVector3 *_col2 ) +{ + vmathV3Copy( &result->col2, _col2 ); +} + +static inline void vmathT3SetCol3( VmathTransform3 *result, const VmathVector3 *_col3 ) +{ + vmathV3Copy( &result->col3, _col3 ); +} + +static inline void vmathT3SetCol( VmathTransform3 *result, int col, const VmathVector3 *vec ) +{ + vmathV3Copy( (&result->col0 + col), vec ); +} + +static inline void vmathT3SetRow( VmathTransform3 *result, int row, const VmathVector4 *vec ) +{ + vmathV3SetElem( &result->col0, row, vmathV4GetElem( vec, 0 ) ); + vmathV3SetElem( &result->col1, row, vmathV4GetElem( vec, 1 ) ); + vmathV3SetElem( &result->col2, row, vmathV4GetElem( vec, 2 ) ); + vmathV3SetElem( &result->col3, row, vmathV4GetElem( vec, 3 ) ); +} + +static inline void vmathT3SetElem( VmathTransform3 *result, int col, int row, float val ) +{ + VmathVector3 tmpV3_0; + vmathT3GetCol( &tmpV3_0, result, col ); + vmathV3SetElem( &tmpV3_0, row, val ); + vmathT3SetCol( result, col, &tmpV3_0 ); +} + +static inline float vmathT3GetElem( const VmathTransform3 *tfrm, int col, int row ) +{ + VmathVector3 tmpV3_0; + vmathT3GetCol( &tmpV3_0, tfrm, col ); + return vmathV3GetElem( &tmpV3_0, row ); +} + +static inline void vmathT3GetCol0( VmathVector3 *result, const VmathTransform3 *tfrm ) +{ + vmathV3Copy( result, &tfrm->col0 ); +} + +static inline void vmathT3GetCol1( VmathVector3 *result, const VmathTransform3 *tfrm ) +{ + vmathV3Copy( result, &tfrm->col1 ); +} + +static inline void vmathT3GetCol2( VmathVector3 *result, const VmathTransform3 *tfrm ) +{ + vmathV3Copy( result, &tfrm->col2 ); +} + +static inline void vmathT3GetCol3( VmathVector3 *result, const VmathTransform3 *tfrm ) +{ + vmathV3Copy( result, &tfrm->col3 ); +} + +static inline void vmathT3GetCol( VmathVector3 *result, const VmathTransform3 *tfrm, int col ) +{ + vmathV3Copy( result, (&tfrm->col0 + col) ); +} + +static inline void vmathT3GetRow( VmathVector4 *result, const VmathTransform3 *tfrm, int row ) +{ + vmathV4MakeFromElems( result, vmathV3GetElem( &tfrm->col0, row ), vmathV3GetElem( &tfrm->col1, row ), vmathV3GetElem( &tfrm->col2, row ), vmathV3GetElem( &tfrm->col3, row ) ); +} + +static inline void vmathT3Inverse( VmathTransform3 *result, const VmathTransform3 *tfrm ) +{ + VmathVector3 tmp0, tmp1, tmp2, inv0, inv1, inv2, tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5; + float detinv; + vmathV3Cross( &tmp0, &tfrm->col1, &tfrm->col2 ); + vmathV3Cross( &tmp1, &tfrm->col2, &tfrm->col0 ); + vmathV3Cross( &tmp2, &tfrm->col0, &tfrm->col1 ); + detinv = ( 1.0f / vmathV3Dot( &tfrm->col2, &tmp2 ) ); + vmathV3MakeFromElems( &inv0, ( tmp0.x * detinv ), ( tmp1.x * detinv ), ( tmp2.x * detinv ) ); + vmathV3MakeFromElems( &inv1, ( tmp0.y * detinv ), ( tmp1.y * detinv ), ( tmp2.y * detinv ) ); + vmathV3MakeFromElems( &inv2, ( tmp0.z * detinv ), ( tmp1.z * detinv ), ( tmp2.z * detinv ) ); + vmathV3Copy( &result->col0, &inv0 ); + vmathV3Copy( &result->col1, &inv1 ); + vmathV3Copy( &result->col2, &inv2 ); + vmathV3ScalarMul( &tmpV3_0, &inv0, tfrm->col3.x ); + vmathV3ScalarMul( &tmpV3_1, &inv1, tfrm->col3.y ); + vmathV3ScalarMul( &tmpV3_2, &inv2, tfrm->col3.z ); + vmathV3Add( &tmpV3_3, &tmpV3_1, &tmpV3_2 ); + vmathV3Add( &tmpV3_4, &tmpV3_0, &tmpV3_3 ); + vmathV3Neg( &tmpV3_5, &tmpV3_4 ); + vmathV3Copy( &result->col3, &tmpV3_5 ); +} + +static inline void vmathT3OrthoInverse( VmathTransform3 *result, const VmathTransform3 *tfrm ) +{ + VmathVector3 inv0, inv1, inv2, tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5; + vmathV3MakeFromElems( &inv0, tfrm->col0.x, tfrm->col1.x, tfrm->col2.x ); + vmathV3MakeFromElems( &inv1, tfrm->col0.y, tfrm->col1.y, tfrm->col2.y ); + vmathV3MakeFromElems( &inv2, tfrm->col0.z, tfrm->col1.z, tfrm->col2.z ); + vmathV3Copy( &result->col0, &inv0 ); + vmathV3Copy( &result->col1, &inv1 ); + vmathV3Copy( &result->col2, &inv2 ); + vmathV3ScalarMul( &tmpV3_0, &inv0, tfrm->col3.x ); + vmathV3ScalarMul( &tmpV3_1, &inv1, tfrm->col3.y ); + vmathV3ScalarMul( &tmpV3_2, &inv2, tfrm->col3.z ); + vmathV3Add( &tmpV3_3, &tmpV3_1, &tmpV3_2 ); + vmathV3Add( &tmpV3_4, &tmpV3_0, &tmpV3_3 ); + vmathV3Neg( &tmpV3_5, &tmpV3_4 ); + vmathV3Copy( &result->col3, &tmpV3_5 ); +} + +static inline void vmathT3AbsPerElem( VmathTransform3 *result, const VmathTransform3 *tfrm ) +{ + vmathV3AbsPerElem( &result->col0, &tfrm->col0 ); + vmathV3AbsPerElem( &result->col1, &tfrm->col1 ); + vmathV3AbsPerElem( &result->col2, &tfrm->col2 ); + vmathV3AbsPerElem( &result->col3, &tfrm->col3 ); +} + +static inline void vmathT3MulV3( VmathVector3 *result, const VmathTransform3 *tfrm, const VmathVector3 *vec ) +{ + float tmpX, tmpY, tmpZ; + tmpX = ( ( ( tfrm->col0.x * vec->x ) + ( tfrm->col1.x * vec->y ) ) + ( tfrm->col2.x * vec->z ) ); + tmpY = ( ( ( tfrm->col0.y * vec->x ) + ( tfrm->col1.y * vec->y ) ) + ( tfrm->col2.y * vec->z ) ); + tmpZ = ( ( ( tfrm->col0.z * vec->x ) + ( tfrm->col1.z * vec->y ) ) + ( tfrm->col2.z * vec->z ) ); + vmathV3MakeFromElems( result, tmpX, tmpY, tmpZ ); +} + +static inline void vmathT3MulP3( VmathPoint3 *result, const VmathTransform3 *tfrm, const VmathPoint3 *pnt ) +{ + float tmpX, tmpY, tmpZ; + tmpX = ( ( ( ( tfrm->col0.x * pnt->x ) + ( tfrm->col1.x * pnt->y ) ) + ( tfrm->col2.x * pnt->z ) ) + tfrm->col3.x ); + tmpY = ( ( ( ( tfrm->col0.y * pnt->x ) + ( tfrm->col1.y * pnt->y ) ) + ( tfrm->col2.y * pnt->z ) ) + tfrm->col3.y ); + tmpZ = ( ( ( ( tfrm->col0.z * pnt->x ) + ( tfrm->col1.z * pnt->y ) ) + ( tfrm->col2.z * pnt->z ) ) + tfrm->col3.z ); + vmathP3MakeFromElems( result, tmpX, tmpY, tmpZ ); +} + +static inline void vmathT3Mul( VmathTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1 ) +{ + VmathTransform3 tmpResult; + VmathPoint3 tmpP3_0, tmpP3_1; + vmathT3MulV3( &tmpResult.col0, tfrm0, &tfrm1->col0 ); + vmathT3MulV3( &tmpResult.col1, tfrm0, &tfrm1->col1 ); + vmathT3MulV3( &tmpResult.col2, tfrm0, &tfrm1->col2 ); + vmathP3MakeFromV3( &tmpP3_0, &tfrm1->col3 ); + vmathT3MulP3( &tmpP3_1, tfrm0, &tmpP3_0 ); + vmathV3MakeFromP3( &tmpResult.col3, &tmpP3_1 ); + vmathT3Copy( result, &tmpResult ); +} + +static inline void vmathT3MulPerElem( VmathTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1 ) +{ + vmathV3MulPerElem( &result->col0, &tfrm0->col0, &tfrm1->col0 ); + vmathV3MulPerElem( &result->col1, &tfrm0->col1, &tfrm1->col1 ); + vmathV3MulPerElem( &result->col2, &tfrm0->col2, &tfrm1->col2 ); + vmathV3MulPerElem( &result->col3, &tfrm0->col3, &tfrm1->col3 ); +} + +static inline void vmathT3MakeIdentity( VmathTransform3 *result ) +{ + vmathV3MakeXAxis( &result->col0 ); + vmathV3MakeYAxis( &result->col1 ); + vmathV3MakeZAxis( &result->col2 ); + vmathV3MakeFromScalar( &result->col3, 0.0f ); +} + +static inline void vmathT3SetUpper3x3( VmathTransform3 *result, const VmathMatrix3 *tfrm ) +{ + vmathV3Copy( &result->col0, &tfrm->col0 ); + vmathV3Copy( &result->col1, &tfrm->col1 ); + vmathV3Copy( &result->col2, &tfrm->col2 ); +} + +static inline void vmathT3GetUpper3x3( VmathMatrix3 *result, const VmathTransform3 *tfrm ) +{ + vmathM3MakeFromCols( result, &tfrm->col0, &tfrm->col1, &tfrm->col2 ); +} + +static inline void vmathT3SetTranslation( VmathTransform3 *result, const VmathVector3 *translateVec ) +{ + vmathV3Copy( &result->col3, translateVec ); +} + +static inline void vmathT3GetTranslation( VmathVector3 *result, const VmathTransform3 *tfrm ) +{ + vmathV3Copy( result, &tfrm->col3 ); +} + +static inline void vmathT3MakeRotationX( VmathTransform3 *result, float radians ) +{ + float s, c; + s = sinf( radians ); + c = cosf( radians ); + vmathV3MakeXAxis( &result->col0 ); + vmathV3MakeFromElems( &result->col1, 0.0f, c, s ); + vmathV3MakeFromElems( &result->col2, 0.0f, -s, c ); + vmathV3MakeFromScalar( &result->col3, 0.0f ); +} + +static inline void vmathT3MakeRotationY( VmathTransform3 *result, float radians ) +{ + float s, c; + s = sinf( radians ); + c = cosf( radians ); + vmathV3MakeFromElems( &result->col0, c, 0.0f, -s ); + vmathV3MakeYAxis( &result->col1 ); + vmathV3MakeFromElems( &result->col2, s, 0.0f, c ); + vmathV3MakeFromScalar( &result->col3, 0.0f ); +} + +static inline void vmathT3MakeRotationZ( VmathTransform3 *result, float radians ) +{ + float s, c; + s = sinf( radians ); + c = cosf( radians ); + vmathV3MakeFromElems( &result->col0, c, s, 0.0f ); + vmathV3MakeFromElems( &result->col1, -s, c, 0.0f ); + vmathV3MakeZAxis( &result->col2 ); + vmathV3MakeFromScalar( &result->col3, 0.0f ); +} + +static inline void vmathT3MakeRotationZYX( VmathTransform3 *result, const VmathVector3 *radiansXYZ ) +{ + float sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; + sX = sinf( radiansXYZ->x ); + cX = cosf( radiansXYZ->x ); + sY = sinf( radiansXYZ->y ); + cY = cosf( radiansXYZ->y ); + sZ = sinf( radiansXYZ->z ); + cZ = cosf( radiansXYZ->z ); + tmp0 = ( cZ * sY ); + tmp1 = ( sZ * sY ); + vmathV3MakeFromElems( &result->col0, ( cZ * cY ), ( sZ * cY ), -sY ); + vmathV3MakeFromElems( &result->col1, ( ( tmp0 * sX ) - ( sZ * cX ) ), ( ( tmp1 * sX ) + ( cZ * cX ) ), ( cY * sX ) ); + vmathV3MakeFromElems( &result->col2, ( ( tmp0 * cX ) + ( sZ * sX ) ), ( ( tmp1 * cX ) - ( cZ * sX ) ), ( cY * cX ) ); + vmathV3MakeFromScalar( &result->col3, 0.0f ); +} + +static inline void vmathT3MakeRotationAxis( VmathTransform3 *result, float radians, const VmathVector3 *unitVec ) +{ + VmathMatrix3 tmpM3_0; + VmathVector3 tmpV3_0; + vmathM3MakeRotationAxis( &tmpM3_0, radians, unitVec ); + vmathV3MakeFromScalar( &tmpV3_0, 0.0f ); + vmathT3MakeFromM3V3( result, &tmpM3_0, &tmpV3_0 ); +} + +static inline void vmathT3MakeRotationQ( VmathTransform3 *result, const VmathQuat *unitQuat ) +{ + VmathMatrix3 tmpM3_0; + VmathVector3 tmpV3_0; + vmathM3MakeFromQ( &tmpM3_0, unitQuat ); + vmathV3MakeFromScalar( &tmpV3_0, 0.0f ); + vmathT3MakeFromM3V3( result, &tmpM3_0, &tmpV3_0 ); +} + +static inline void vmathT3MakeScale( VmathTransform3 *result, const VmathVector3 *scaleVec ) +{ + vmathV3MakeFromElems( &result->col0, scaleVec->x, 0.0f, 0.0f ); + vmathV3MakeFromElems( &result->col1, 0.0f, scaleVec->y, 0.0f ); + vmathV3MakeFromElems( &result->col2, 0.0f, 0.0f, scaleVec->z ); + vmathV3MakeFromScalar( &result->col3, 0.0f ); +} + +static inline void vmathT3AppendScale( VmathTransform3 *result, const VmathTransform3 *tfrm, const VmathVector3 *scaleVec ) +{ + vmathV3ScalarMul( &result->col0, &tfrm->col0, vmathV3GetX( scaleVec ) ); + vmathV3ScalarMul( &result->col1, &tfrm->col1, vmathV3GetY( scaleVec ) ); + vmathV3ScalarMul( &result->col2, &tfrm->col2, vmathV3GetZ( scaleVec ) ); + vmathV3Copy( &result->col3, &tfrm->col3 ); +} + +static inline void vmathT3PrependScale( VmathTransform3 *result, const VmathVector3 *scaleVec, const VmathTransform3 *tfrm ) +{ + vmathV3MulPerElem( &result->col0, &tfrm->col0, scaleVec ); + vmathV3MulPerElem( &result->col1, &tfrm->col1, scaleVec ); + vmathV3MulPerElem( &result->col2, &tfrm->col2, scaleVec ); + vmathV3MulPerElem( &result->col3, &tfrm->col3, scaleVec ); +} + +static inline void vmathT3MakeTranslation( VmathTransform3 *result, const VmathVector3 *translateVec ) +{ + vmathV3MakeXAxis( &result->col0 ); + vmathV3MakeYAxis( &result->col1 ); + vmathV3MakeZAxis( &result->col2 ); + vmathV3Copy( &result->col3, translateVec ); +} + +static inline void vmathT3Select( VmathTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1, unsigned int select1 ) +{ + vmathV3Select( &result->col0, &tfrm0->col0, &tfrm1->col0, select1 ); + vmathV3Select( &result->col1, &tfrm0->col1, &tfrm1->col1, select1 ); + vmathV3Select( &result->col2, &tfrm0->col2, &tfrm1->col2, select1 ); + vmathV3Select( &result->col3, &tfrm0->col3, &tfrm1->col3, select1 ); +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathT3Print( const VmathTransform3 *tfrm ) +{ + VmathVector4 tmpV4_0, tmpV4_1, tmpV4_2; + vmathT3GetRow( &tmpV4_0, tfrm, 0 ); + vmathV4Print( &tmpV4_0 ); + vmathT3GetRow( &tmpV4_1, tfrm, 1 ); + vmathV4Print( &tmpV4_1 ); + vmathT3GetRow( &tmpV4_2, tfrm, 2 ); + vmathV4Print( &tmpV4_2 ); +} + +static inline void vmathT3Prints( const VmathTransform3 *tfrm, const char *name ) +{ + printf("%s:\n", name); + vmathT3Print( tfrm ); +} + +#endif + +static inline void vmathQMakeFromM3( VmathQuat *result, const VmathMatrix3 *tfrm ) +{ + float trace, radicand, scale, xx, yx, zx, xy, yy, zy, xz, yz, zz, tmpx, tmpy, tmpz, tmpw, qx, qy, qz, qw; + int negTrace, ZgtX, ZgtY, YgtX; + int largestXorY, largestYorZ, largestZorX; + + xx = tfrm->col0.x; + yx = tfrm->col0.y; + zx = tfrm->col0.z; + xy = tfrm->col1.x; + yy = tfrm->col1.y; + zy = tfrm->col1.z; + xz = tfrm->col2.x; + yz = tfrm->col2.y; + zz = tfrm->col2.z; + + trace = ( ( xx + yy ) + zz ); + + negTrace = ( trace < 0.0f ); + ZgtX = zz > xx; + ZgtY = zz > yy; + YgtX = yy > xx; + largestXorY = ( !ZgtX || !ZgtY ) && negTrace; + largestYorZ = ( YgtX || ZgtX ) && negTrace; + largestZorX = ( ZgtY || !YgtX ) && negTrace; + + if ( largestXorY ) + { + zz = -zz; + xy = -xy; + } + if ( largestYorZ ) + { + xx = -xx; + yz = -yz; + } + if ( largestZorX ) + { + yy = -yy; + zx = -zx; + } + + radicand = ( ( ( xx + yy ) + zz ) + 1.0f ); + scale = ( 0.5f * ( 1.0f / sqrtf( radicand ) ) ); + + tmpx = ( ( zy - yz ) * scale ); + tmpy = ( ( xz - zx ) * scale ); + tmpz = ( ( yx - xy ) * scale ); + tmpw = ( radicand * scale ); + qx = tmpx; + qy = tmpy; + qz = tmpz; + qw = tmpw; + + if ( largestXorY ) + { + qx = tmpw; + qy = tmpz; + qz = tmpy; + qw = tmpx; + } + if ( largestYorZ ) + { + tmpx = qx; + tmpz = qz; + qx = qy; + qy = tmpx; + qz = qw; + qw = tmpz; + } + + result->x = qx; + result->y = qy; + result->z = qz; + result->w = qw; +} + +static inline void vmathV3Outer( VmathMatrix3 *result, const VmathVector3 *tfrm0, const VmathVector3 *tfrm1 ) +{ + vmathV3ScalarMul( &result->col0, tfrm0, vmathV3GetX( tfrm1 ) ); + vmathV3ScalarMul( &result->col1, tfrm0, vmathV3GetY( tfrm1 ) ); + vmathV3ScalarMul( &result->col2, tfrm0, vmathV3GetZ( tfrm1 ) ); +} + +static inline void vmathV4Outer( VmathMatrix4 *result, const VmathVector4 *tfrm0, const VmathVector4 *tfrm1 ) +{ + vmathV4ScalarMul( &result->col0, tfrm0, vmathV4GetX( tfrm1 ) ); + vmathV4ScalarMul( &result->col1, tfrm0, vmathV4GetY( tfrm1 ) ); + vmathV4ScalarMul( &result->col2, tfrm0, vmathV4GetZ( tfrm1 ) ); + vmathV4ScalarMul( &result->col3, tfrm0, vmathV4GetW( tfrm1 ) ); +} + +static inline void vmathV3RowMul( VmathVector3 *result, const VmathVector3 *vec, const VmathMatrix3 *mat ) +{ + float tmpX, tmpY, tmpZ; + tmpX = ( ( ( vec->x * mat->col0.x ) + ( vec->y * mat->col0.y ) ) + ( vec->z * mat->col0.z ) ); + tmpY = ( ( ( vec->x * mat->col1.x ) + ( vec->y * mat->col1.y ) ) + ( vec->z * mat->col1.z ) ); + tmpZ = ( ( ( vec->x * mat->col2.x ) + ( vec->y * mat->col2.y ) ) + ( vec->z * mat->col2.z ) ); + vmathV3MakeFromElems( result, tmpX, tmpY, tmpZ ); +} + +static inline void vmathV3CrossMatrix( VmathMatrix3 *result, const VmathVector3 *vec ) +{ + vmathV3MakeFromElems( &result->col0, 0.0f, vec->z, -vec->y ); + vmathV3MakeFromElems( &result->col1, -vec->z, 0.0f, vec->x ); + vmathV3MakeFromElems( &result->col2, vec->y, -vec->x, 0.0f ); +} + +static inline void vmathV3CrossMatrixMul( VmathMatrix3 *result, const VmathVector3 *vec, const VmathMatrix3 *mat ) +{ + VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2; + vmathV3Cross( &tmpV3_0, vec, &mat->col0 ); + vmathV3Cross( &tmpV3_1, vec, &mat->col1 ); + vmathV3Cross( &tmpV3_2, vec, &mat->col2 ); + vmathM3MakeFromCols( result, &tmpV3_0, &tmpV3_1, &tmpV3_2 ); +} + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/vectormathlibrary/include/vectormath/scalar/c/mat_aos_v.h b/vectormathlibrary/include/vectormath/scalar/c/mat_aos_v.h new file mode 100644 index 000000000..270ffcb50 --- /dev/null +++ b/vectormathlibrary/include/vectormath/scalar/c/mat_aos_v.h @@ -0,0 +1,1006 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_MAT_AOS_V_C_H +#define _VECTORMATH_MAT_AOS_V_C_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/*----------------------------------------------------------------------------- + * Constants + */ +#define _VECTORMATH_PI_OVER_2 1.570796327f + +/*----------------------------------------------------------------------------- + * Definitions + */ +static inline VmathMatrix3 vmathM3MakeFromScalar_V( float scalar ) +{ + VmathMatrix3 result; + vmathM3MakeFromScalar(&result, scalar); + return result; +} + +static inline VmathMatrix3 vmathM3MakeFromQ_V( VmathQuat unitQuat ) +{ + VmathMatrix3 result; + vmathM3MakeFromQ(&result, &unitQuat); + return result; +} + +static inline VmathMatrix3 vmathM3MakeFromCols_V( VmathVector3 _col0, VmathVector3 _col1, VmathVector3 _col2 ) +{ + VmathMatrix3 result; + vmathM3MakeFromCols(&result, &_col0, &_col1, &_col2); + return result; +} + +static inline void vmathM3SetCol0_V( VmathMatrix3 *result, VmathVector3 _col0 ) +{ + vmathM3SetCol0(result, &_col0); +} + +static inline void vmathM3SetCol1_V( VmathMatrix3 *result, VmathVector3 _col1 ) +{ + vmathM3SetCol1(result, &_col1); +} + +static inline void vmathM3SetCol2_V( VmathMatrix3 *result, VmathVector3 _col2 ) +{ + vmathM3SetCol2(result, &_col2); +} + +static inline void vmathM3SetCol_V( VmathMatrix3 *result, int col, VmathVector3 vec ) +{ + vmathM3SetCol(result, col, &vec); +} + +static inline void vmathM3SetRow_V( VmathMatrix3 *result, int row, VmathVector3 vec ) +{ + vmathM3SetRow(result, row, &vec); +} + +static inline void vmathM3SetElem_V( VmathMatrix3 *result, int col, int row, float val ) +{ + vmathM3SetElem(result, col, row, val); +} + +static inline float vmathM3GetElem_V( VmathMatrix3 mat, int col, int row ) +{ + return vmathM3GetElem(&mat, col, row); +} + +static inline VmathVector3 vmathM3GetCol0_V( VmathMatrix3 mat ) +{ + VmathVector3 result; + vmathM3GetCol0(&result, &mat); + return result; +} + +static inline VmathVector3 vmathM3GetCol1_V( VmathMatrix3 mat ) +{ + VmathVector3 result; + vmathM3GetCol1(&result, &mat); + return result; +} + +static inline VmathVector3 vmathM3GetCol2_V( VmathMatrix3 mat ) +{ + VmathVector3 result; + vmathM3GetCol2(&result, &mat); + return result; +} + +static inline VmathVector3 vmathM3GetCol_V( VmathMatrix3 mat, int col ) +{ + VmathVector3 result; + vmathM3GetCol(&result, &mat, col); + return result; +} + +static inline VmathVector3 vmathM3GetRow_V( VmathMatrix3 mat, int row ) +{ + VmathVector3 result; + vmathM3GetRow(&result, &mat, row); + return result; +} + +static inline VmathMatrix3 vmathM3Transpose_V( VmathMatrix3 mat ) +{ + VmathMatrix3 result; + vmathM3Transpose(&result, &mat); + return result; +} + +static inline VmathMatrix3 vmathM3Inverse_V( VmathMatrix3 mat ) +{ + VmathMatrix3 result; + vmathM3Inverse(&result, &mat); + return result; +} + +static inline float vmathM3Determinant_V( VmathMatrix3 mat ) +{ + return vmathM3Determinant(&mat); +} + +static inline VmathMatrix3 vmathM3Add_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ) +{ + VmathMatrix3 result; + vmathM3Add(&result, &mat0, &mat1); + return result; +} + +static inline VmathMatrix3 vmathM3Sub_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ) +{ + VmathMatrix3 result; + vmathM3Sub(&result, &mat0, &mat1); + return result; +} + +static inline VmathMatrix3 vmathM3Neg_V( VmathMatrix3 mat ) +{ + VmathMatrix3 result; + vmathM3Neg(&result, &mat); + return result; +} + +static inline VmathMatrix3 vmathM3AbsPerElem_V( VmathMatrix3 mat ) +{ + VmathMatrix3 result; + vmathM3AbsPerElem(&result, &mat); + return result; +} + +static inline VmathMatrix3 vmathM3ScalarMul_V( VmathMatrix3 mat, float scalar ) +{ + VmathMatrix3 result; + vmathM3ScalarMul(&result, &mat, scalar); + return result; +} + +static inline VmathVector3 vmathM3MulV3_V( VmathMatrix3 mat, VmathVector3 vec ) +{ + VmathVector3 result; + vmathM3MulV3(&result, &mat, &vec); + return result; +} + +static inline VmathMatrix3 vmathM3Mul_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ) +{ + VmathMatrix3 result; + vmathM3Mul(&result, &mat0, &mat1); + return result; +} + +static inline VmathMatrix3 vmathM3MulPerElem_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ) +{ + VmathMatrix3 result; + vmathM3MulPerElem(&result, &mat0, &mat1); + return result; +} + +static inline VmathMatrix3 vmathM3MakeIdentity_V( ) +{ + VmathMatrix3 result; + vmathM3MakeIdentity(&result); + return result; +} + +static inline VmathMatrix3 vmathM3MakeRotationX_V( float radians ) +{ + VmathMatrix3 result; + vmathM3MakeRotationX(&result, radians); + return result; +} + +static inline VmathMatrix3 vmathM3MakeRotationY_V( float radians ) +{ + VmathMatrix3 result; + vmathM3MakeRotationY(&result, radians); + return result; +} + +static inline VmathMatrix3 vmathM3MakeRotationZ_V( float radians ) +{ + VmathMatrix3 result; + vmathM3MakeRotationZ(&result, radians); + return result; +} + +static inline VmathMatrix3 vmathM3MakeRotationZYX_V( VmathVector3 radiansXYZ ) +{ + VmathMatrix3 result; + vmathM3MakeRotationZYX(&result, &radiansXYZ); + return result; +} + +static inline VmathMatrix3 vmathM3MakeRotationAxis_V( float radians, VmathVector3 unitVec ) +{ + VmathMatrix3 result; + vmathM3MakeRotationAxis(&result, radians, &unitVec); + return result; +} + +static inline VmathMatrix3 vmathM3MakeRotationQ_V( VmathQuat unitQuat ) +{ + VmathMatrix3 result; + vmathM3MakeRotationQ(&result, &unitQuat); + return result; +} + +static inline VmathMatrix3 vmathM3MakeScale_V( VmathVector3 scaleVec ) +{ + VmathMatrix3 result; + vmathM3MakeScale(&result, &scaleVec); + return result; +} + +static inline VmathMatrix3 vmathM3AppendScale_V( VmathMatrix3 mat, VmathVector3 scaleVec ) +{ + VmathMatrix3 result; + vmathM3AppendScale(&result, &mat, &scaleVec); + return result; +} + +static inline VmathMatrix3 vmathM3PrependScale_V( VmathVector3 scaleVec, VmathMatrix3 mat ) +{ + VmathMatrix3 result; + vmathM3PrependScale(&result, &scaleVec, &mat); + return result; +} + +static inline VmathMatrix3 vmathM3Select_V( VmathMatrix3 mat0, VmathMatrix3 mat1, unsigned int select1 ) +{ + VmathMatrix3 result; + vmathM3Select(&result, &mat0, &mat1, select1); + return result; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathM3Print_V( VmathMatrix3 mat ) +{ + vmathM3Print(&mat); +} + +static inline void vmathM3Prints_V( VmathMatrix3 mat, const char *name ) +{ + vmathM3Prints(&mat, name); +} + +#endif + +static inline VmathMatrix4 vmathM4MakeFromScalar_V( float scalar ) +{ + VmathMatrix4 result; + vmathM4MakeFromScalar(&result, scalar); + return result; +} + +static inline VmathMatrix4 vmathM4MakeFromT3_V( VmathTransform3 mat ) +{ + VmathMatrix4 result; + vmathM4MakeFromT3(&result, &mat); + return result; +} + +static inline VmathMatrix4 vmathM4MakeFromCols_V( VmathVector4 _col0, VmathVector4 _col1, VmathVector4 _col2, VmathVector4 _col3 ) +{ + VmathMatrix4 result; + vmathM4MakeFromCols(&result, &_col0, &_col1, &_col2, &_col3); + return result; +} + +static inline VmathMatrix4 vmathM4MakeFromM3V3_V( VmathMatrix3 mat, VmathVector3 translateVec ) +{ + VmathMatrix4 result; + vmathM4MakeFromM3V3(&result, &mat, &translateVec); + return result; +} + +static inline VmathMatrix4 vmathM4MakeFromQV3_V( VmathQuat unitQuat, VmathVector3 translateVec ) +{ + VmathMatrix4 result; + vmathM4MakeFromQV3(&result, &unitQuat, &translateVec); + return result; +} + +static inline void vmathM4SetCol0_V( VmathMatrix4 *result, VmathVector4 _col0 ) +{ + vmathM4SetCol0(result, &_col0); +} + +static inline void vmathM4SetCol1_V( VmathMatrix4 *result, VmathVector4 _col1 ) +{ + vmathM4SetCol1(result, &_col1); +} + +static inline void vmathM4SetCol2_V( VmathMatrix4 *result, VmathVector4 _col2 ) +{ + vmathM4SetCol2(result, &_col2); +} + +static inline void vmathM4SetCol3_V( VmathMatrix4 *result, VmathVector4 _col3 ) +{ + vmathM4SetCol3(result, &_col3); +} + +static inline void vmathM4SetCol_V( VmathMatrix4 *result, int col, VmathVector4 vec ) +{ + vmathM4SetCol(result, col, &vec); +} + +static inline void vmathM4SetRow_V( VmathMatrix4 *result, int row, VmathVector4 vec ) +{ + vmathM4SetRow(result, row, &vec); +} + +static inline void vmathM4SetElem_V( VmathMatrix4 *result, int col, int row, float val ) +{ + vmathM4SetElem(result, col, row, val); +} + +static inline float vmathM4GetElem_V( VmathMatrix4 mat, int col, int row ) +{ + return vmathM4GetElem(&mat, col, row); +} + +static inline VmathVector4 vmathM4GetCol0_V( VmathMatrix4 mat ) +{ + VmathVector4 result; + vmathM4GetCol0(&result, &mat); + return result; +} + +static inline VmathVector4 vmathM4GetCol1_V( VmathMatrix4 mat ) +{ + VmathVector4 result; + vmathM4GetCol1(&result, &mat); + return result; +} + +static inline VmathVector4 vmathM4GetCol2_V( VmathMatrix4 mat ) +{ + VmathVector4 result; + vmathM4GetCol2(&result, &mat); + return result; +} + +static inline VmathVector4 vmathM4GetCol3_V( VmathMatrix4 mat ) +{ + VmathVector4 result; + vmathM4GetCol3(&result, &mat); + return result; +} + +static inline VmathVector4 vmathM4GetCol_V( VmathMatrix4 mat, int col ) +{ + VmathVector4 result; + vmathM4GetCol(&result, &mat, col); + return result; +} + +static inline VmathVector4 vmathM4GetRow_V( VmathMatrix4 mat, int row ) +{ + VmathVector4 result; + vmathM4GetRow(&result, &mat, row); + return result; +} + +static inline VmathMatrix4 vmathM4Transpose_V( VmathMatrix4 mat ) +{ + VmathMatrix4 result; + vmathM4Transpose(&result, &mat); + return result; +} + +static inline VmathMatrix4 vmathM4Inverse_V( VmathMatrix4 mat ) +{ + VmathMatrix4 result; + vmathM4Inverse(&result, &mat); + return result; +} + +static inline VmathMatrix4 vmathM4AffineInverse_V( VmathMatrix4 mat ) +{ + VmathMatrix4 result; + vmathM4AffineInverse(&result, &mat); + return result; +} + +static inline VmathMatrix4 vmathM4OrthoInverse_V( VmathMatrix4 mat ) +{ + VmathMatrix4 result; + vmathM4OrthoInverse(&result, &mat); + return result; +} + +static inline float vmathM4Determinant_V( VmathMatrix4 mat ) +{ + return vmathM4Determinant(&mat); +} + +static inline VmathMatrix4 vmathM4Add_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ) +{ + VmathMatrix4 result; + vmathM4Add(&result, &mat0, &mat1); + return result; +} + +static inline VmathMatrix4 vmathM4Sub_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ) +{ + VmathMatrix4 result; + vmathM4Sub(&result, &mat0, &mat1); + return result; +} + +static inline VmathMatrix4 vmathM4Neg_V( VmathMatrix4 mat ) +{ + VmathMatrix4 result; + vmathM4Neg(&result, &mat); + return result; +} + +static inline VmathMatrix4 vmathM4AbsPerElem_V( VmathMatrix4 mat ) +{ + VmathMatrix4 result; + vmathM4AbsPerElem(&result, &mat); + return result; +} + +static inline VmathMatrix4 vmathM4ScalarMul_V( VmathMatrix4 mat, float scalar ) +{ + VmathMatrix4 result; + vmathM4ScalarMul(&result, &mat, scalar); + return result; +} + +static inline VmathVector4 vmathM4MulV4_V( VmathMatrix4 mat, VmathVector4 vec ) +{ + VmathVector4 result; + vmathM4MulV4(&result, &mat, &vec); + return result; +} + +static inline VmathVector4 vmathM4MulV3_V( VmathMatrix4 mat, VmathVector3 vec ) +{ + VmathVector4 result; + vmathM4MulV3(&result, &mat, &vec); + return result; +} + +static inline VmathVector4 vmathM4MulP3_V( VmathMatrix4 mat, VmathPoint3 pnt ) +{ + VmathVector4 result; + vmathM4MulP3(&result, &mat, &pnt); + return result; +} + +static inline VmathMatrix4 vmathM4Mul_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ) +{ + VmathMatrix4 result; + vmathM4Mul(&result, &mat0, &mat1); + return result; +} + +static inline VmathMatrix4 vmathM4MulT3_V( VmathMatrix4 mat, VmathTransform3 tfrm1 ) +{ + VmathMatrix4 result; + vmathM4MulT3(&result, &mat, &tfrm1); + return result; +} + +static inline VmathMatrix4 vmathM4MulPerElem_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ) +{ + VmathMatrix4 result; + vmathM4MulPerElem(&result, &mat0, &mat1); + return result; +} + +static inline VmathMatrix4 vmathM4MakeIdentity_V( ) +{ + VmathMatrix4 result; + vmathM4MakeIdentity(&result); + return result; +} + +static inline void vmathM4SetUpper3x3_V( VmathMatrix4 *result, VmathMatrix3 mat3 ) +{ + vmathM4SetUpper3x3(result, &mat3); +} + +static inline VmathMatrix3 vmathM4GetUpper3x3_V( VmathMatrix4 mat ) +{ + VmathMatrix3 result; + vmathM4GetUpper3x3(&result, &mat); + return result; +} + +static inline void vmathM4SetTranslation_V( VmathMatrix4 *result, VmathVector3 translateVec ) +{ + vmathM4SetTranslation(result, &translateVec); +} + +static inline VmathVector3 vmathM4GetTranslation_V( VmathMatrix4 mat ) +{ + VmathVector3 result; + vmathM4GetTranslation(&result, &mat); + return result; +} + +static inline VmathMatrix4 vmathM4MakeRotationX_V( float radians ) +{ + VmathMatrix4 result; + vmathM4MakeRotationX(&result, radians); + return result; +} + +static inline VmathMatrix4 vmathM4MakeRotationY_V( float radians ) +{ + VmathMatrix4 result; + vmathM4MakeRotationY(&result, radians); + return result; +} + +static inline VmathMatrix4 vmathM4MakeRotationZ_V( float radians ) +{ + VmathMatrix4 result; + vmathM4MakeRotationZ(&result, radians); + return result; +} + +static inline VmathMatrix4 vmathM4MakeRotationZYX_V( VmathVector3 radiansXYZ ) +{ + VmathMatrix4 result; + vmathM4MakeRotationZYX(&result, &radiansXYZ); + return result; +} + +static inline VmathMatrix4 vmathM4MakeRotationAxis_V( float radians, VmathVector3 unitVec ) +{ + VmathMatrix4 result; + vmathM4MakeRotationAxis(&result, radians, &unitVec); + return result; +} + +static inline VmathMatrix4 vmathM4MakeRotationQ_V( VmathQuat unitQuat ) +{ + VmathMatrix4 result; + vmathM4MakeRotationQ(&result, &unitQuat); + return result; +} + +static inline VmathMatrix4 vmathM4MakeScale_V( VmathVector3 scaleVec ) +{ + VmathMatrix4 result; + vmathM4MakeScale(&result, &scaleVec); + return result; +} + +static inline VmathMatrix4 vmathM4AppendScale_V( VmathMatrix4 mat, VmathVector3 scaleVec ) +{ + VmathMatrix4 result; + vmathM4AppendScale(&result, &mat, &scaleVec); + return result; +} + +static inline VmathMatrix4 vmathM4PrependScale_V( VmathVector3 scaleVec, VmathMatrix4 mat ) +{ + VmathMatrix4 result; + vmathM4PrependScale(&result, &scaleVec, &mat); + return result; +} + +static inline VmathMatrix4 vmathM4MakeTranslation_V( VmathVector3 translateVec ) +{ + VmathMatrix4 result; + vmathM4MakeTranslation(&result, &translateVec); + return result; +} + +static inline VmathMatrix4 vmathM4MakeLookAt_V( VmathPoint3 eyePos, VmathPoint3 lookAtPos, VmathVector3 upVec ) +{ + VmathMatrix4 result; + vmathM4MakeLookAt(&result, &eyePos, &lookAtPos, &upVec); + return result; +} + +static inline VmathMatrix4 vmathM4MakePerspective_V( float fovyRadians, float aspect, float zNear, float zFar ) +{ + VmathMatrix4 result; + vmathM4MakePerspective(&result, fovyRadians, aspect, zNear, zFar); + return result; +} + +static inline VmathMatrix4 vmathM4MakeFrustum_V( float left, float right, float bottom, float top, float zNear, float zFar ) +{ + VmathMatrix4 result; + vmathM4MakeFrustum(&result, left, right, bottom, top, zNear, zFar); + return result; +} + +static inline VmathMatrix4 vmathM4MakeOrthographic_V( float left, float right, float bottom, float top, float zNear, float zFar ) +{ + VmathMatrix4 result; + vmathM4MakeOrthographic(&result, left, right, bottom, top, zNear, zFar); + return result; +} + +static inline VmathMatrix4 vmathM4Select_V( VmathMatrix4 mat0, VmathMatrix4 mat1, unsigned int select1 ) +{ + VmathMatrix4 result; + vmathM4Select(&result, &mat0, &mat1, select1); + return result; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathM4Print_V( VmathMatrix4 mat ) +{ + vmathM4Print(&mat); +} + +static inline void vmathM4Prints_V( VmathMatrix4 mat, const char *name ) +{ + vmathM4Prints(&mat, name); +} + +#endif + +static inline VmathTransform3 vmathT3MakeFromScalar_V( float scalar ) +{ + VmathTransform3 result; + vmathT3MakeFromScalar(&result, scalar); + return result; +} + +static inline VmathTransform3 vmathT3MakeFromCols_V( VmathVector3 _col0, VmathVector3 _col1, VmathVector3 _col2, VmathVector3 _col3 ) +{ + VmathTransform3 result; + vmathT3MakeFromCols(&result, &_col0, &_col1, &_col2, &_col3); + return result; +} + +static inline VmathTransform3 vmathT3MakeFromM3V3_V( VmathMatrix3 tfrm, VmathVector3 translateVec ) +{ + VmathTransform3 result; + vmathT3MakeFromM3V3(&result, &tfrm, &translateVec); + return result; +} + +static inline VmathTransform3 vmathT3MakeFromQV3_V( VmathQuat unitQuat, VmathVector3 translateVec ) +{ + VmathTransform3 result; + vmathT3MakeFromQV3(&result, &unitQuat, &translateVec); + return result; +} + +static inline void vmathT3SetCol0_V( VmathTransform3 *result, VmathVector3 _col0 ) +{ + vmathT3SetCol0(result, &_col0); +} + +static inline void vmathT3SetCol1_V( VmathTransform3 *result, VmathVector3 _col1 ) +{ + vmathT3SetCol1(result, &_col1); +} + +static inline void vmathT3SetCol2_V( VmathTransform3 *result, VmathVector3 _col2 ) +{ + vmathT3SetCol2(result, &_col2); +} + +static inline void vmathT3SetCol3_V( VmathTransform3 *result, VmathVector3 _col3 ) +{ + vmathT3SetCol3(result, &_col3); +} + +static inline void vmathT3SetCol_V( VmathTransform3 *result, int col, VmathVector3 vec ) +{ + vmathT3SetCol(result, col, &vec); +} + +static inline void vmathT3SetRow_V( VmathTransform3 *result, int row, VmathVector4 vec ) +{ + vmathT3SetRow(result, row, &vec); +} + +static inline void vmathT3SetElem_V( VmathTransform3 *result, int col, int row, float val ) +{ + vmathT3SetElem(result, col, row, val); +} + +static inline float vmathT3GetElem_V( VmathTransform3 tfrm, int col, int row ) +{ + return vmathT3GetElem(&tfrm, col, row); +} + +static inline VmathVector3 vmathT3GetCol0_V( VmathTransform3 tfrm ) +{ + VmathVector3 result; + vmathT3GetCol0(&result, &tfrm); + return result; +} + +static inline VmathVector3 vmathT3GetCol1_V( VmathTransform3 tfrm ) +{ + VmathVector3 result; + vmathT3GetCol1(&result, &tfrm); + return result; +} + +static inline VmathVector3 vmathT3GetCol2_V( VmathTransform3 tfrm ) +{ + VmathVector3 result; + vmathT3GetCol2(&result, &tfrm); + return result; +} + +static inline VmathVector3 vmathT3GetCol3_V( VmathTransform3 tfrm ) +{ + VmathVector3 result; + vmathT3GetCol3(&result, &tfrm); + return result; +} + +static inline VmathVector3 vmathT3GetCol_V( VmathTransform3 tfrm, int col ) +{ + VmathVector3 result; + vmathT3GetCol(&result, &tfrm, col); + return result; +} + +static inline VmathVector4 vmathT3GetRow_V( VmathTransform3 tfrm, int row ) +{ + VmathVector4 result; + vmathT3GetRow(&result, &tfrm, row); + return result; +} + +static inline VmathTransform3 vmathT3Inverse_V( VmathTransform3 tfrm ) +{ + VmathTransform3 result; + vmathT3Inverse(&result, &tfrm); + return result; +} + +static inline VmathTransform3 vmathT3OrthoInverse_V( VmathTransform3 tfrm ) +{ + VmathTransform3 result; + vmathT3OrthoInverse(&result, &tfrm); + return result; +} + +static inline VmathTransform3 vmathT3AbsPerElem_V( VmathTransform3 tfrm ) +{ + VmathTransform3 result; + vmathT3AbsPerElem(&result, &tfrm); + return result; +} + +static inline VmathVector3 vmathT3MulV3_V( VmathTransform3 tfrm, VmathVector3 vec ) +{ + VmathVector3 result; + vmathT3MulV3(&result, &tfrm, &vec); + return result; +} + +static inline VmathPoint3 vmathT3MulP3_V( VmathTransform3 tfrm, VmathPoint3 pnt ) +{ + VmathPoint3 result; + vmathT3MulP3(&result, &tfrm, &pnt); + return result; +} + +static inline VmathTransform3 vmathT3Mul_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1 ) +{ + VmathTransform3 result; + vmathT3Mul(&result, &tfrm0, &tfrm1); + return result; +} + +static inline VmathTransform3 vmathT3MulPerElem_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1 ) +{ + VmathTransform3 result; + vmathT3MulPerElem(&result, &tfrm0, &tfrm1); + return result; +} + +static inline VmathTransform3 vmathT3MakeIdentity_V( ) +{ + VmathTransform3 result; + vmathT3MakeIdentity(&result); + return result; +} + +static inline void vmathT3SetUpper3x3_V( VmathTransform3 *result, VmathMatrix3 tfrm ) +{ + vmathT3SetUpper3x3(result, &tfrm); +} + +static inline VmathMatrix3 vmathT3GetUpper3x3_V( VmathTransform3 tfrm ) +{ + VmathMatrix3 result; + vmathT3GetUpper3x3(&result, &tfrm); + return result; +} + +static inline void vmathT3SetTranslation_V( VmathTransform3 *result, VmathVector3 translateVec ) +{ + vmathT3SetTranslation(result, &translateVec); +} + +static inline VmathVector3 vmathT3GetTranslation_V( VmathTransform3 tfrm ) +{ + VmathVector3 result; + vmathT3GetTranslation(&result, &tfrm); + return result; +} + +static inline VmathTransform3 vmathT3MakeRotationX_V( float radians ) +{ + VmathTransform3 result; + vmathT3MakeRotationX(&result, radians); + return result; +} + +static inline VmathTransform3 vmathT3MakeRotationY_V( float radians ) +{ + VmathTransform3 result; + vmathT3MakeRotationY(&result, radians); + return result; +} + +static inline VmathTransform3 vmathT3MakeRotationZ_V( float radians ) +{ + VmathTransform3 result; + vmathT3MakeRotationZ(&result, radians); + return result; +} + +static inline VmathTransform3 vmathT3MakeRotationZYX_V( VmathVector3 radiansXYZ ) +{ + VmathTransform3 result; + vmathT3MakeRotationZYX(&result, &radiansXYZ); + return result; +} + +static inline VmathTransform3 vmathT3MakeRotationAxis_V( float radians, VmathVector3 unitVec ) +{ + VmathTransform3 result; + vmathT3MakeRotationAxis(&result, radians, &unitVec); + return result; +} + +static inline VmathTransform3 vmathT3MakeRotationQ_V( VmathQuat unitQuat ) +{ + VmathTransform3 result; + vmathT3MakeRotationQ(&result, &unitQuat); + return result; +} + +static inline VmathTransform3 vmathT3MakeScale_V( VmathVector3 scaleVec ) +{ + VmathTransform3 result; + vmathT3MakeScale(&result, &scaleVec); + return result; +} + +static inline VmathTransform3 vmathT3AppendScale_V( VmathTransform3 tfrm, VmathVector3 scaleVec ) +{ + VmathTransform3 result; + vmathT3AppendScale(&result, &tfrm, &scaleVec); + return result; +} + +static inline VmathTransform3 vmathT3PrependScale_V( VmathVector3 scaleVec, VmathTransform3 tfrm ) +{ + VmathTransform3 result; + vmathT3PrependScale(&result, &scaleVec, &tfrm); + return result; +} + +static inline VmathTransform3 vmathT3MakeTranslation_V( VmathVector3 translateVec ) +{ + VmathTransform3 result; + vmathT3MakeTranslation(&result, &translateVec); + return result; +} + +static inline VmathTransform3 vmathT3Select_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1, unsigned int select1 ) +{ + VmathTransform3 result; + vmathT3Select(&result, &tfrm0, &tfrm1, select1); + return result; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathT3Print_V( VmathTransform3 tfrm ) +{ + vmathT3Print(&tfrm); +} + +static inline void vmathT3Prints_V( VmathTransform3 tfrm, const char *name ) +{ + vmathT3Prints(&tfrm, name); +} + +#endif + +static inline VmathQuat vmathQMakeFromM3_V( VmathMatrix3 tfrm ) +{ + VmathQuat result; + vmathQMakeFromM3(&result, &tfrm); + return result; +} + +static inline VmathMatrix3 vmathV3Outer_V( VmathVector3 tfrm0, VmathVector3 tfrm1 ) +{ + VmathMatrix3 result; + vmathV3Outer(&result, &tfrm0, &tfrm1); + return result; +} + +static inline VmathMatrix4 vmathV4Outer_V( VmathVector4 tfrm0, VmathVector4 tfrm1 ) +{ + VmathMatrix4 result; + vmathV4Outer(&result, &tfrm0, &tfrm1); + return result; +} + +static inline VmathVector3 vmathV3RowMul_V( VmathVector3 vec, VmathMatrix3 mat ) +{ + VmathVector3 result; + vmathV3RowMul(&result, &vec, &mat); + return result; +} + +static inline VmathMatrix3 vmathV3CrossMatrix_V( VmathVector3 vec ) +{ + VmathMatrix3 result; + vmathV3CrossMatrix(&result, &vec); + return result; +} + +static inline VmathMatrix3 vmathV3CrossMatrixMul_V( VmathVector3 vec, VmathMatrix3 mat ) +{ + VmathMatrix3 result; + vmathV3CrossMatrixMul(&result, &vec, &mat); + return result; +} + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/vectormathlibrary/include/vectormath/scalar/c/quat_aos.h b/vectormathlibrary/include/vectormath/scalar/c/quat_aos.h new file mode 100644 index 000000000..c886ab669 --- /dev/null +++ b/vectormathlibrary/include/vectormath/scalar/c/quat_aos.h @@ -0,0 +1,368 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_QUAT_AOS_C_H +#define _VECTORMATH_QUAT_AOS_C_H +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/*----------------------------------------------------------------------------- + * Definitions + */ +#ifndef _VECTORMATH_INTERNAL_FUNCTIONS +#define _VECTORMATH_INTERNAL_FUNCTIONS + +#endif + +static inline void vmathQCopy( VmathQuat *result, const VmathQuat *quat ) +{ + result->x = quat->x; + result->y = quat->y; + result->z = quat->z; + result->w = quat->w; +} + +static inline void vmathQMakeFromElems( VmathQuat *result, float _x, float _y, float _z, float _w ) +{ + result->x = _x; + result->y = _y; + result->z = _z; + result->w = _w; +} + +static inline void vmathQMakeFromV3Scalar( VmathQuat *result, const VmathVector3 *xyz, float _w ) +{ + vmathQSetXYZ( result, xyz ); + vmathQSetW( result, _w ); +} + +static inline void vmathQMakeFromV4( VmathQuat *result, const VmathVector4 *vec ) +{ + result->x = vec->x; + result->y = vec->y; + result->z = vec->z; + result->w = vec->w; +} + +static inline void vmathQMakeFromScalar( VmathQuat *result, float scalar ) +{ + result->x = scalar; + result->y = scalar; + result->z = scalar; + result->w = scalar; +} + +static inline void vmathQMakeIdentity( VmathQuat *result ) +{ + vmathQMakeFromElems( result, 0.0f, 0.0f, 0.0f, 1.0f ); +} + +static inline void vmathQLerp( VmathQuat *result, float t, const VmathQuat *quat0, const VmathQuat *quat1 ) +{ + VmathQuat tmpQ_0, tmpQ_1; + vmathQSub( &tmpQ_0, quat1, quat0 ); + vmathQScalarMul( &tmpQ_1, &tmpQ_0, t ); + vmathQAdd( result, quat0, &tmpQ_1 ); +} + +static inline void vmathQSlerp( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1 ) +{ + VmathQuat start, tmpQ_0, tmpQ_1; + float recipSinAngle, scale0, scale1, cosAngle, angle; + cosAngle = vmathQDot( unitQuat0, unitQuat1 ); + if ( cosAngle < 0.0f ) { + cosAngle = -cosAngle; + vmathQNeg( &start, unitQuat0 ); + } else { + vmathQCopy( &start, unitQuat0 ); + } + if ( cosAngle < _VECTORMATH_SLERP_TOL ) { + angle = acosf( cosAngle ); + recipSinAngle = ( 1.0f / sinf( angle ) ); + scale0 = ( sinf( ( ( 1.0f - t ) * angle ) ) * recipSinAngle ); + scale1 = ( sinf( ( t * angle ) ) * recipSinAngle ); + } else { + scale0 = ( 1.0f - t ); + scale1 = t; + } + vmathQScalarMul( &tmpQ_0, &start, scale0 ); + vmathQScalarMul( &tmpQ_1, unitQuat1, scale1 ); + vmathQAdd( result, &tmpQ_0, &tmpQ_1 ); +} + +static inline void vmathQSquad( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1, const VmathQuat *unitQuat2, const VmathQuat *unitQuat3 ) +{ + VmathQuat tmp0, tmp1; + vmathQSlerp( &tmp0, t, unitQuat0, unitQuat3 ); + vmathQSlerp( &tmp1, t, unitQuat1, unitQuat2 ); + vmathQSlerp( result, ( ( 2.0f * t ) * ( 1.0f - t ) ), &tmp0, &tmp1 ); +} + +static inline void vmathQSetXYZ( VmathQuat *result, const VmathVector3 *vec ) +{ + result->x = vec->x; + result->y = vec->y; + result->z = vec->z; +} + +static inline void vmathQGetXYZ( VmathVector3 *result, const VmathQuat *quat ) +{ + vmathV3MakeFromElems( result, quat->x, quat->y, quat->z ); +} + +static inline void vmathQSetX( VmathQuat *result, float _x ) +{ + result->x = _x; +} + +static inline float vmathQGetX( const VmathQuat *quat ) +{ + return quat->x; +} + +static inline void vmathQSetY( VmathQuat *result, float _y ) +{ + result->y = _y; +} + +static inline float vmathQGetY( const VmathQuat *quat ) +{ + return quat->y; +} + +static inline void vmathQSetZ( VmathQuat *result, float _z ) +{ + result->z = _z; +} + +static inline float vmathQGetZ( const VmathQuat *quat ) +{ + return quat->z; +} + +static inline void vmathQSetW( VmathQuat *result, float _w ) +{ + result->w = _w; +} + +static inline float vmathQGetW( const VmathQuat *quat ) +{ + return quat->w; +} + +static inline void vmathQSetElem( VmathQuat *result, int idx, float value ) +{ + *(&result->x + idx) = value; +} + +static inline float vmathQGetElem( const VmathQuat *quat, int idx ) +{ + return *(&quat->x + idx); +} + +static inline void vmathQAdd( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ) +{ + result->x = ( quat0->x + quat1->x ); + result->y = ( quat0->y + quat1->y ); + result->z = ( quat0->z + quat1->z ); + result->w = ( quat0->w + quat1->w ); +} + +static inline void vmathQSub( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ) +{ + result->x = ( quat0->x - quat1->x ); + result->y = ( quat0->y - quat1->y ); + result->z = ( quat0->z - quat1->z ); + result->w = ( quat0->w - quat1->w ); +} + +static inline void vmathQScalarMul( VmathQuat *result, const VmathQuat *quat, float scalar ) +{ + result->x = ( quat->x * scalar ); + result->y = ( quat->y * scalar ); + result->z = ( quat->z * scalar ); + result->w = ( quat->w * scalar ); +} + +static inline void vmathQScalarDiv( VmathQuat *result, const VmathQuat *quat, float scalar ) +{ + result->x = ( quat->x / scalar ); + result->y = ( quat->y / scalar ); + result->z = ( quat->z / scalar ); + result->w = ( quat->w / scalar ); +} + +static inline void vmathQNeg( VmathQuat *result, const VmathQuat *quat ) +{ + result->x = -quat->x; + result->y = -quat->y; + result->z = -quat->z; + result->w = -quat->w; +} + +static inline float vmathQDot( const VmathQuat *quat0, const VmathQuat *quat1 ) +{ + float result; + result = ( quat0->x * quat1->x ); + result = ( result + ( quat0->y * quat1->y ) ); + result = ( result + ( quat0->z * quat1->z ) ); + result = ( result + ( quat0->w * quat1->w ) ); + return result; +} + +static inline float vmathQNorm( const VmathQuat *quat ) +{ + float result; + result = ( quat->x * quat->x ); + result = ( result + ( quat->y * quat->y ) ); + result = ( result + ( quat->z * quat->z ) ); + result = ( result + ( quat->w * quat->w ) ); + return result; +} + +static inline float vmathQLength( const VmathQuat *quat ) +{ + return sqrtf( vmathQNorm( quat ) ); +} + +static inline void vmathQNormalize( VmathQuat *result, const VmathQuat *quat ) +{ + float lenSqr, lenInv; + lenSqr = vmathQNorm( quat ); + lenInv = ( 1.0f / sqrtf( lenSqr ) ); + result->x = ( quat->x * lenInv ); + result->y = ( quat->y * lenInv ); + result->z = ( quat->z * lenInv ); + result->w = ( quat->w * lenInv ); +} + +static inline void vmathQMakeRotationArc( VmathQuat *result, const VmathVector3 *unitVec0, const VmathVector3 *unitVec1 ) +{ + VmathVector3 tmpV3_0, tmpV3_1; + float cosHalfAngleX2, recipCosHalfAngleX2; + cosHalfAngleX2 = sqrtf( ( 2.0f * ( 1.0f + vmathV3Dot( unitVec0, unitVec1 ) ) ) ); + recipCosHalfAngleX2 = ( 1.0f / cosHalfAngleX2 ); + vmathV3Cross( &tmpV3_0, unitVec0, unitVec1 ); + vmathV3ScalarMul( &tmpV3_1, &tmpV3_0, recipCosHalfAngleX2 ); + vmathQMakeFromV3Scalar( result, &tmpV3_1, ( cosHalfAngleX2 * 0.5f ) ); +} + +static inline void vmathQMakeRotationAxis( VmathQuat *result, float radians, const VmathVector3 *unitVec ) +{ + VmathVector3 tmpV3_0; + float s, c, angle; + angle = ( radians * 0.5f ); + s = sinf( angle ); + c = cosf( angle ); + vmathV3ScalarMul( &tmpV3_0, unitVec, s ); + vmathQMakeFromV3Scalar( result, &tmpV3_0, c ); +} + +static inline void vmathQMakeRotationX( VmathQuat *result, float radians ) +{ + float s, c, angle; + angle = ( radians * 0.5f ); + s = sinf( angle ); + c = cosf( angle ); + vmathQMakeFromElems( result, s, 0.0f, 0.0f, c ); +} + +static inline void vmathQMakeRotationY( VmathQuat *result, float radians ) +{ + float s, c, angle; + angle = ( radians * 0.5f ); + s = sinf( angle ); + c = cosf( angle ); + vmathQMakeFromElems( result, 0.0f, s, 0.0f, c ); +} + +static inline void vmathQMakeRotationZ( VmathQuat *result, float radians ) +{ + float s, c, angle; + angle = ( radians * 0.5f ); + s = sinf( angle ); + c = cosf( angle ); + vmathQMakeFromElems( result, 0.0f, 0.0f, s, c ); +} + +static inline void vmathQMul( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ) +{ + float tmpX, tmpY, tmpZ, tmpW; + tmpX = ( ( ( ( quat0->w * quat1->x ) + ( quat0->x * quat1->w ) ) + ( quat0->y * quat1->z ) ) - ( quat0->z * quat1->y ) ); + tmpY = ( ( ( ( quat0->w * quat1->y ) + ( quat0->y * quat1->w ) ) + ( quat0->z * quat1->x ) ) - ( quat0->x * quat1->z ) ); + tmpZ = ( ( ( ( quat0->w * quat1->z ) + ( quat0->z * quat1->w ) ) + ( quat0->x * quat1->y ) ) - ( quat0->y * quat1->x ) ); + tmpW = ( ( ( ( quat0->w * quat1->w ) - ( quat0->x * quat1->x ) ) - ( quat0->y * quat1->y ) ) - ( quat0->z * quat1->z ) ); + vmathQMakeFromElems( result, tmpX, tmpY, tmpZ, tmpW ); +} + +static inline void vmathQRotate( VmathVector3 *result, const VmathQuat *quat, const VmathVector3 *vec ) +{ + float tmpX, tmpY, tmpZ, tmpW; + tmpX = ( ( ( quat->w * vec->x ) + ( quat->y * vec->z ) ) - ( quat->z * vec->y ) ); + tmpY = ( ( ( quat->w * vec->y ) + ( quat->z * vec->x ) ) - ( quat->x * vec->z ) ); + tmpZ = ( ( ( quat->w * vec->z ) + ( quat->x * vec->y ) ) - ( quat->y * vec->x ) ); + tmpW = ( ( ( quat->x * vec->x ) + ( quat->y * vec->y ) ) + ( quat->z * vec->z ) ); + result->x = ( ( ( ( tmpW * quat->x ) + ( tmpX * quat->w ) ) - ( tmpY * quat->z ) ) + ( tmpZ * quat->y ) ); + result->y = ( ( ( ( tmpW * quat->y ) + ( tmpY * quat->w ) ) - ( tmpZ * quat->x ) ) + ( tmpX * quat->z ) ); + result->z = ( ( ( ( tmpW * quat->z ) + ( tmpZ * quat->w ) ) - ( tmpX * quat->y ) ) + ( tmpY * quat->x ) ); +} + +static inline void vmathQConj( VmathQuat *result, const VmathQuat *quat ) +{ + vmathQMakeFromElems( result, -quat->x, -quat->y, -quat->z, quat->w ); +} + +static inline void vmathQSelect( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1, unsigned int select1 ) +{ + result->x = ( select1 )? quat1->x : quat0->x; + result->y = ( select1 )? quat1->y : quat0->y; + result->z = ( select1 )? quat1->z : quat0->z; + result->w = ( select1 )? quat1->w : quat0->w; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathQPrint( const VmathQuat *quat ) +{ + printf( "( %f %f %f %f )\n", quat->x, quat->y, quat->z, quat->w ); +} + +static inline void vmathQPrints( const VmathQuat *quat, const char *name ) +{ + printf( "%s: ( %f %f %f %f )\n", name, quat->x, quat->y, quat->z, quat->w ); +} + +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/vectormathlibrary/include/vectormath/scalar/c/quat_aos_v.h b/vectormathlibrary/include/vectormath/scalar/c/quat_aos_v.h new file mode 100644 index 000000000..b5a9e248d --- /dev/null +++ b/vectormathlibrary/include/vectormath/scalar/c/quat_aos_v.h @@ -0,0 +1,300 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_QUAT_AOS_V_C_H +#define _VECTORMATH_QUAT_AOS_V_C_H +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/*----------------------------------------------------------------------------- + * Definitions + */ +#ifndef _VECTORMATH_INTERNAL_FUNCTIONS +#define _VECTORMATH_INTERNAL_FUNCTIONS + +#endif + +static inline VmathQuat vmathQMakeFromElems_V( float _x, float _y, float _z, float _w ) +{ + VmathQuat result; + vmathQMakeFromElems(&result, _x, _y, _z, _w); + return result; +} + +static inline VmathQuat vmathQMakeFromV3Scalar_V( VmathVector3 xyz, float _w ) +{ + VmathQuat result; + vmathQMakeFromV3Scalar(&result, &xyz, _w); + return result; +} + +static inline VmathQuat vmathQMakeFromV4_V( VmathVector4 vec ) +{ + VmathQuat result; + vmathQMakeFromV4(&result, &vec); + return result; +} + +static inline VmathQuat vmathQMakeFromScalar_V( float scalar ) +{ + VmathQuat result; + vmathQMakeFromScalar(&result, scalar); + return result; +} + +static inline VmathQuat vmathQMakeIdentity_V( ) +{ + VmathQuat result; + vmathQMakeIdentity(&result); + return result; +} + +static inline VmathQuat vmathQLerp_V( float t, VmathQuat quat0, VmathQuat quat1 ) +{ + VmathQuat result; + vmathQLerp(&result, t, &quat0, &quat1); + return result; +} + +static inline VmathQuat vmathQSlerp_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1 ) +{ + VmathQuat result; + vmathQSlerp(&result, t, &unitQuat0, &unitQuat1); + return result; +} + +static inline VmathQuat vmathQSquad_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1, VmathQuat unitQuat2, VmathQuat unitQuat3 ) +{ + VmathQuat result; + vmathQSquad(&result, t, &unitQuat0, &unitQuat1, &unitQuat2, &unitQuat3); + return result; +} + +static inline void vmathQSetXYZ_V( VmathQuat *result, VmathVector3 vec ) +{ + vmathQSetXYZ(result, &vec); +} + +static inline VmathVector3 vmathQGetXYZ_V( VmathQuat quat ) +{ + VmathVector3 result; + vmathQGetXYZ(&result, &quat); + return result; +} + +static inline void vmathQSetX_V( VmathQuat *result, float _x ) +{ + vmathQSetX(result, _x); +} + +static inline float vmathQGetX_V( VmathQuat quat ) +{ + return vmathQGetX(&quat); +} + +static inline void vmathQSetY_V( VmathQuat *result, float _y ) +{ + vmathQSetY(result, _y); +} + +static inline float vmathQGetY_V( VmathQuat quat ) +{ + return vmathQGetY(&quat); +} + +static inline void vmathQSetZ_V( VmathQuat *result, float _z ) +{ + vmathQSetZ(result, _z); +} + +static inline float vmathQGetZ_V( VmathQuat quat ) +{ + return vmathQGetZ(&quat); +} + +static inline void vmathQSetW_V( VmathQuat *result, float _w ) +{ + vmathQSetW(result, _w); +} + +static inline float vmathQGetW_V( VmathQuat quat ) +{ + return vmathQGetW(&quat); +} + +static inline void vmathQSetElem_V( VmathQuat *result, int idx, float value ) +{ + vmathQSetElem(result, idx, value); +} + +static inline float vmathQGetElem_V( VmathQuat quat, int idx ) +{ + return vmathQGetElem(&quat, idx); +} + +static inline VmathQuat vmathQAdd_V( VmathQuat quat0, VmathQuat quat1 ) +{ + VmathQuat result; + vmathQAdd(&result, &quat0, &quat1); + return result; +} + +static inline VmathQuat vmathQSub_V( VmathQuat quat0, VmathQuat quat1 ) +{ + VmathQuat result; + vmathQSub(&result, &quat0, &quat1); + return result; +} + +static inline VmathQuat vmathQScalarMul_V( VmathQuat quat, float scalar ) +{ + VmathQuat result; + vmathQScalarMul(&result, &quat, scalar); + return result; +} + +static inline VmathQuat vmathQScalarDiv_V( VmathQuat quat, float scalar ) +{ + VmathQuat result; + vmathQScalarDiv(&result, &quat, scalar); + return result; +} + +static inline VmathQuat vmathQNeg_V( VmathQuat quat ) +{ + VmathQuat result; + vmathQNeg(&result, &quat); + return result; +} + +static inline float vmathQDot_V( VmathQuat quat0, VmathQuat quat1 ) +{ + return vmathQDot(&quat0, &quat1); +} + +static inline float vmathQNorm_V( VmathQuat quat ) +{ + return vmathQNorm(&quat); +} + +static inline float vmathQLength_V( VmathQuat quat ) +{ + return vmathQLength(&quat); +} + +static inline VmathQuat vmathQNormalize_V( VmathQuat quat ) +{ + VmathQuat result; + vmathQNormalize(&result, &quat); + return result; +} + +static inline VmathQuat vmathQMakeRotationArc_V( VmathVector3 unitVec0, VmathVector3 unitVec1 ) +{ + VmathQuat result; + vmathQMakeRotationArc(&result, &unitVec0, &unitVec1); + return result; +} + +static inline VmathQuat vmathQMakeRotationAxis_V( float radians, VmathVector3 unitVec ) +{ + VmathQuat result; + vmathQMakeRotationAxis(&result, radians, &unitVec); + return result; +} + +static inline VmathQuat vmathQMakeRotationX_V( float radians ) +{ + VmathQuat result; + vmathQMakeRotationX(&result, radians); + return result; +} + +static inline VmathQuat vmathQMakeRotationY_V( float radians ) +{ + VmathQuat result; + vmathQMakeRotationY(&result, radians); + return result; +} + +static inline VmathQuat vmathQMakeRotationZ_V( float radians ) +{ + VmathQuat result; + vmathQMakeRotationZ(&result, radians); + return result; +} + +static inline VmathQuat vmathQMul_V( VmathQuat quat0, VmathQuat quat1 ) +{ + VmathQuat result; + vmathQMul(&result, &quat0, &quat1); + return result; +} + +static inline VmathVector3 vmathQRotate_V( VmathQuat quat, VmathVector3 vec ) +{ + VmathVector3 result; + vmathQRotate(&result, &quat, &vec); + return result; +} + +static inline VmathQuat vmathQConj_V( VmathQuat quat ) +{ + VmathQuat result; + vmathQConj(&result, &quat); + return result; +} + +static inline VmathQuat vmathQSelect_V( VmathQuat quat0, VmathQuat quat1, unsigned int select1 ) +{ + VmathQuat result; + vmathQSelect(&result, &quat0, &quat1, select1); + return result; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathQPrint_V( VmathQuat quat ) +{ + vmathQPrint(&quat); +} + +static inline void vmathQPrints_V( VmathQuat quat, const char *name ) +{ + vmathQPrints(&quat, name); +} + +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/vectormathlibrary/include/vectormath/scalar/c/vec_aos.h b/vectormathlibrary/include/vectormath/scalar/c/vec_aos.h new file mode 100644 index 000000000..f0b0f437d --- /dev/null +++ b/vectormathlibrary/include/vectormath/scalar/c/vec_aos.h @@ -0,0 +1,971 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_VEC_AOS_C_H +#define _VECTORMATH_VEC_AOS_C_H +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/*----------------------------------------------------------------------------- + * Constants + */ +#define _VECTORMATH_SLERP_TOL 0.999f + +/*----------------------------------------------------------------------------- + * Definitions + */ +#ifndef _VECTORMATH_INTERNAL_FUNCTIONS +#define _VECTORMATH_INTERNAL_FUNCTIONS + +#endif + +static inline void vmathV3Copy( VmathVector3 *result, const VmathVector3 *vec ) +{ + result->x = vec->x; + result->y = vec->y; + result->z = vec->z; +} + +static inline void vmathV3MakeFromElems( VmathVector3 *result, float _x, float _y, float _z ) +{ + result->x = _x; + result->y = _y; + result->z = _z; +} + +static inline void vmathV3MakeFromP3( VmathVector3 *result, const VmathPoint3 *pnt ) +{ + result->x = pnt->x; + result->y = pnt->y; + result->z = pnt->z; +} + +static inline void vmathV3MakeFromScalar( VmathVector3 *result, float scalar ) +{ + result->x = scalar; + result->y = scalar; + result->z = scalar; +} + +static inline void vmathV3MakeXAxis( VmathVector3 *result ) +{ + vmathV3MakeFromElems( result, 1.0f, 0.0f, 0.0f ); +} + +static inline void vmathV3MakeYAxis( VmathVector3 *result ) +{ + vmathV3MakeFromElems( result, 0.0f, 1.0f, 0.0f ); +} + +static inline void vmathV3MakeZAxis( VmathVector3 *result ) +{ + vmathV3MakeFromElems( result, 0.0f, 0.0f, 1.0f ); +} + +static inline void vmathV3Lerp( VmathVector3 *result, float t, const VmathVector3 *vec0, const VmathVector3 *vec1 ) +{ + VmathVector3 tmpV3_0, tmpV3_1; + vmathV3Sub( &tmpV3_0, vec1, vec0 ); + vmathV3ScalarMul( &tmpV3_1, &tmpV3_0, t ); + vmathV3Add( result, vec0, &tmpV3_1 ); +} + +static inline void vmathV3Slerp( VmathVector3 *result, float t, const VmathVector3 *unitVec0, const VmathVector3 *unitVec1 ) +{ + VmathVector3 tmpV3_0, tmpV3_1; + float recipSinAngle, scale0, scale1, cosAngle, angle; + cosAngle = vmathV3Dot( unitVec0, unitVec1 ); + if ( cosAngle < _VECTORMATH_SLERP_TOL ) { + angle = acosf( cosAngle ); + recipSinAngle = ( 1.0f / sinf( angle ) ); + scale0 = ( sinf( ( ( 1.0f - t ) * angle ) ) * recipSinAngle ); + scale1 = ( sinf( ( t * angle ) ) * recipSinAngle ); + } else { + scale0 = ( 1.0f - t ); + scale1 = t; + } + vmathV3ScalarMul( &tmpV3_0, unitVec0, scale0 ); + vmathV3ScalarMul( &tmpV3_1, unitVec1, scale1 ); + vmathV3Add( result, &tmpV3_0, &tmpV3_1 ); +} + +static inline void vmathV3SetX( VmathVector3 *result, float _x ) +{ + result->x = _x; +} + +static inline float vmathV3GetX( const VmathVector3 *vec ) +{ + return vec->x; +} + +static inline void vmathV3SetY( VmathVector3 *result, float _y ) +{ + result->y = _y; +} + +static inline float vmathV3GetY( const VmathVector3 *vec ) +{ + return vec->y; +} + +static inline void vmathV3SetZ( VmathVector3 *result, float _z ) +{ + result->z = _z; +} + +static inline float vmathV3GetZ( const VmathVector3 *vec ) +{ + return vec->z; +} + +static inline void vmathV3SetElem( VmathVector3 *result, int idx, float value ) +{ + *(&result->x + idx) = value; +} + +static inline float vmathV3GetElem( const VmathVector3 *vec, int idx ) +{ + return *(&vec->x + idx); +} + +static inline void vmathV3Add( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) +{ + result->x = ( vec0->x + vec1->x ); + result->y = ( vec0->y + vec1->y ); + result->z = ( vec0->z + vec1->z ); +} + +static inline void vmathV3Sub( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) +{ + result->x = ( vec0->x - vec1->x ); + result->y = ( vec0->y - vec1->y ); + result->z = ( vec0->z - vec1->z ); +} + +static inline void vmathV3AddP3( VmathPoint3 *result, const VmathVector3 *vec, const VmathPoint3 *pnt1 ) +{ + result->x = ( vec->x + pnt1->x ); + result->y = ( vec->y + pnt1->y ); + result->z = ( vec->z + pnt1->z ); +} + +static inline void vmathV3ScalarMul( VmathVector3 *result, const VmathVector3 *vec, float scalar ) +{ + result->x = ( vec->x * scalar ); + result->y = ( vec->y * scalar ); + result->z = ( vec->z * scalar ); +} + +static inline void vmathV3ScalarDiv( VmathVector3 *result, const VmathVector3 *vec, float scalar ) +{ + result->x = ( vec->x / scalar ); + result->y = ( vec->y / scalar ); + result->z = ( vec->z / scalar ); +} + +static inline void vmathV3Neg( VmathVector3 *result, const VmathVector3 *vec ) +{ + result->x = -vec->x; + result->y = -vec->y; + result->z = -vec->z; +} + +static inline void vmathV3MulPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) +{ + result->x = ( vec0->x * vec1->x ); + result->y = ( vec0->y * vec1->y ); + result->z = ( vec0->z * vec1->z ); +} + +static inline void vmathV3DivPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) +{ + result->x = ( vec0->x / vec1->x ); + result->y = ( vec0->y / vec1->y ); + result->z = ( vec0->z / vec1->z ); +} + +static inline void vmathV3RecipPerElem( VmathVector3 *result, const VmathVector3 *vec ) +{ + result->x = ( 1.0f / vec->x ); + result->y = ( 1.0f / vec->y ); + result->z = ( 1.0f / vec->z ); +} + +static inline void vmathV3SqrtPerElem( VmathVector3 *result, const VmathVector3 *vec ) +{ + result->x = sqrtf( vec->x ); + result->y = sqrtf( vec->y ); + result->z = sqrtf( vec->z ); +} + +static inline void vmathV3RsqrtPerElem( VmathVector3 *result, const VmathVector3 *vec ) +{ + result->x = ( 1.0f / sqrtf( vec->x ) ); + result->y = ( 1.0f / sqrtf( vec->y ) ); + result->z = ( 1.0f / sqrtf( vec->z ) ); +} + +static inline void vmathV3AbsPerElem( VmathVector3 *result, const VmathVector3 *vec ) +{ + result->x = fabsf( vec->x ); + result->y = fabsf( vec->y ); + result->z = fabsf( vec->z ); +} + +static inline void vmathV3CopySignPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) +{ + result->x = ( vec1->x < 0.0f )? -fabsf( vec0->x ) : fabsf( vec0->x ); + result->y = ( vec1->y < 0.0f )? -fabsf( vec0->y ) : fabsf( vec0->y ); + result->z = ( vec1->z < 0.0f )? -fabsf( vec0->z ) : fabsf( vec0->z ); +} + +static inline void vmathV3MaxPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) +{ + result->x = (vec0->x > vec1->x)? vec0->x : vec1->x; + result->y = (vec0->y > vec1->y)? vec0->y : vec1->y; + result->z = (vec0->z > vec1->z)? vec0->z : vec1->z; +} + +static inline float vmathV3MaxElem( const VmathVector3 *vec ) +{ + float result; + result = (vec->x > vec->y)? vec->x : vec->y; + result = (vec->z > result)? vec->z : result; + return result; +} + +static inline void vmathV3MinPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) +{ + result->x = (vec0->x < vec1->x)? vec0->x : vec1->x; + result->y = (vec0->y < vec1->y)? vec0->y : vec1->y; + result->z = (vec0->z < vec1->z)? vec0->z : vec1->z; +} + +static inline float vmathV3MinElem( const VmathVector3 *vec ) +{ + float result; + result = (vec->x < vec->y)? vec->x : vec->y; + result = (vec->z < result)? vec->z : result; + return result; +} + +static inline float vmathV3Sum( const VmathVector3 *vec ) +{ + float result; + result = ( vec->x + vec->y ); + result = ( result + vec->z ); + return result; +} + +static inline float vmathV3Dot( const VmathVector3 *vec0, const VmathVector3 *vec1 ) +{ + float result; + result = ( vec0->x * vec1->x ); + result = ( result + ( vec0->y * vec1->y ) ); + result = ( result + ( vec0->z * vec1->z ) ); + return result; +} + +static inline float vmathV3LengthSqr( const VmathVector3 *vec ) +{ + float result; + result = ( vec->x * vec->x ); + result = ( result + ( vec->y * vec->y ) ); + result = ( result + ( vec->z * vec->z ) ); + return result; +} + +static inline float vmathV3Length( const VmathVector3 *vec ) +{ + return sqrtf( vmathV3LengthSqr( vec ) ); +} + +static inline void vmathV3Normalize( VmathVector3 *result, const VmathVector3 *vec ) +{ + float lenSqr, lenInv; + lenSqr = vmathV3LengthSqr( vec ); + lenInv = ( 1.0f / sqrtf( lenSqr ) ); + result->x = ( vec->x * lenInv ); + result->y = ( vec->y * lenInv ); + result->z = ( vec->z * lenInv ); +} + +static inline void vmathV3Cross( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) +{ + float tmpX, tmpY, tmpZ; + tmpX = ( ( vec0->y * vec1->z ) - ( vec0->z * vec1->y ) ); + tmpY = ( ( vec0->z * vec1->x ) - ( vec0->x * vec1->z ) ); + tmpZ = ( ( vec0->x * vec1->y ) - ( vec0->y * vec1->x ) ); + vmathV3MakeFromElems( result, tmpX, tmpY, tmpZ ); +} + +static inline void vmathV3Select( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1, unsigned int select1 ) +{ + result->x = ( select1 )? vec1->x : vec0->x; + result->y = ( select1 )? vec1->y : vec0->y; + result->z = ( select1 )? vec1->z : vec0->z; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathV3Print( const VmathVector3 *vec ) +{ + printf( "( %f %f %f )\n", vec->x, vec->y, vec->z ); +} + +static inline void vmathV3Prints( const VmathVector3 *vec, const char *name ) +{ + printf( "%s: ( %f %f %f )\n", name, vec->x, vec->y, vec->z ); +} + +#endif + +static inline void vmathV4Copy( VmathVector4 *result, const VmathVector4 *vec ) +{ + result->x = vec->x; + result->y = vec->y; + result->z = vec->z; + result->w = vec->w; +} + +static inline void vmathV4MakeFromElems( VmathVector4 *result, float _x, float _y, float _z, float _w ) +{ + result->x = _x; + result->y = _y; + result->z = _z; + result->w = _w; +} + +static inline void vmathV4MakeFromV3Scalar( VmathVector4 *result, const VmathVector3 *xyz, float _w ) +{ + vmathV4SetXYZ( result, xyz ); + vmathV4SetW( result, _w ); +} + +static inline void vmathV4MakeFromV3( VmathVector4 *result, const VmathVector3 *vec ) +{ + result->x = vec->x; + result->y = vec->y; + result->z = vec->z; + result->w = 0.0f; +} + +static inline void vmathV4MakeFromP3( VmathVector4 *result, const VmathPoint3 *pnt ) +{ + result->x = pnt->x; + result->y = pnt->y; + result->z = pnt->z; + result->w = 1.0f; +} + +static inline void vmathV4MakeFromQ( VmathVector4 *result, const VmathQuat *quat ) +{ + result->x = quat->x; + result->y = quat->y; + result->z = quat->z; + result->w = quat->w; +} + +static inline void vmathV4MakeFromScalar( VmathVector4 *result, float scalar ) +{ + result->x = scalar; + result->y = scalar; + result->z = scalar; + result->w = scalar; +} + +static inline void vmathV4MakeXAxis( VmathVector4 *result ) +{ + vmathV4MakeFromElems( result, 1.0f, 0.0f, 0.0f, 0.0f ); +} + +static inline void vmathV4MakeYAxis( VmathVector4 *result ) +{ + vmathV4MakeFromElems( result, 0.0f, 1.0f, 0.0f, 0.0f ); +} + +static inline void vmathV4MakeZAxis( VmathVector4 *result ) +{ + vmathV4MakeFromElems( result, 0.0f, 0.0f, 1.0f, 0.0f ); +} + +static inline void vmathV4MakeWAxis( VmathVector4 *result ) +{ + vmathV4MakeFromElems( result, 0.0f, 0.0f, 0.0f, 1.0f ); +} + +static inline void vmathV4Lerp( VmathVector4 *result, float t, const VmathVector4 *vec0, const VmathVector4 *vec1 ) +{ + VmathVector4 tmpV4_0, tmpV4_1; + vmathV4Sub( &tmpV4_0, vec1, vec0 ); + vmathV4ScalarMul( &tmpV4_1, &tmpV4_0, t ); + vmathV4Add( result, vec0, &tmpV4_1 ); +} + +static inline void vmathV4Slerp( VmathVector4 *result, float t, const VmathVector4 *unitVec0, const VmathVector4 *unitVec1 ) +{ + VmathVector4 tmpV4_0, tmpV4_1; + float recipSinAngle, scale0, scale1, cosAngle, angle; + cosAngle = vmathV4Dot( unitVec0, unitVec1 ); + if ( cosAngle < _VECTORMATH_SLERP_TOL ) { + angle = acosf( cosAngle ); + recipSinAngle = ( 1.0f / sinf( angle ) ); + scale0 = ( sinf( ( ( 1.0f - t ) * angle ) ) * recipSinAngle ); + scale1 = ( sinf( ( t * angle ) ) * recipSinAngle ); + } else { + scale0 = ( 1.0f - t ); + scale1 = t; + } + vmathV4ScalarMul( &tmpV4_0, unitVec0, scale0 ); + vmathV4ScalarMul( &tmpV4_1, unitVec1, scale1 ); + vmathV4Add( result, &tmpV4_0, &tmpV4_1 ); +} + +static inline void vmathV4SetXYZ( VmathVector4 *result, const VmathVector3 *vec ) +{ + result->x = vec->x; + result->y = vec->y; + result->z = vec->z; +} + +static inline void vmathV4GetXYZ( VmathVector3 *result, const VmathVector4 *vec ) +{ + vmathV3MakeFromElems( result, vec->x, vec->y, vec->z ); +} + +static inline void vmathV4SetX( VmathVector4 *result, float _x ) +{ + result->x = _x; +} + +static inline float vmathV4GetX( const VmathVector4 *vec ) +{ + return vec->x; +} + +static inline void vmathV4SetY( VmathVector4 *result, float _y ) +{ + result->y = _y; +} + +static inline float vmathV4GetY( const VmathVector4 *vec ) +{ + return vec->y; +} + +static inline void vmathV4SetZ( VmathVector4 *result, float _z ) +{ + result->z = _z; +} + +static inline float vmathV4GetZ( const VmathVector4 *vec ) +{ + return vec->z; +} + +static inline void vmathV4SetW( VmathVector4 *result, float _w ) +{ + result->w = _w; +} + +static inline float vmathV4GetW( const VmathVector4 *vec ) +{ + return vec->w; +} + +static inline void vmathV4SetElem( VmathVector4 *result, int idx, float value ) +{ + *(&result->x + idx) = value; +} + +static inline float vmathV4GetElem( const VmathVector4 *vec, int idx ) +{ + return *(&vec->x + idx); +} + +static inline void vmathV4Add( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) +{ + result->x = ( vec0->x + vec1->x ); + result->y = ( vec0->y + vec1->y ); + result->z = ( vec0->z + vec1->z ); + result->w = ( vec0->w + vec1->w ); +} + +static inline void vmathV4Sub( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) +{ + result->x = ( vec0->x - vec1->x ); + result->y = ( vec0->y - vec1->y ); + result->z = ( vec0->z - vec1->z ); + result->w = ( vec0->w - vec1->w ); +} + +static inline void vmathV4ScalarMul( VmathVector4 *result, const VmathVector4 *vec, float scalar ) +{ + result->x = ( vec->x * scalar ); + result->y = ( vec->y * scalar ); + result->z = ( vec->z * scalar ); + result->w = ( vec->w * scalar ); +} + +static inline void vmathV4ScalarDiv( VmathVector4 *result, const VmathVector4 *vec, float scalar ) +{ + result->x = ( vec->x / scalar ); + result->y = ( vec->y / scalar ); + result->z = ( vec->z / scalar ); + result->w = ( vec->w / scalar ); +} + +static inline void vmathV4Neg( VmathVector4 *result, const VmathVector4 *vec ) +{ + result->x = -vec->x; + result->y = -vec->y; + result->z = -vec->z; + result->w = -vec->w; +} + +static inline void vmathV4MulPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) +{ + result->x = ( vec0->x * vec1->x ); + result->y = ( vec0->y * vec1->y ); + result->z = ( vec0->z * vec1->z ); + result->w = ( vec0->w * vec1->w ); +} + +static inline void vmathV4DivPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) +{ + result->x = ( vec0->x / vec1->x ); + result->y = ( vec0->y / vec1->y ); + result->z = ( vec0->z / vec1->z ); + result->w = ( vec0->w / vec1->w ); +} + +static inline void vmathV4RecipPerElem( VmathVector4 *result, const VmathVector4 *vec ) +{ + result->x = ( 1.0f / vec->x ); + result->y = ( 1.0f / vec->y ); + result->z = ( 1.0f / vec->z ); + result->w = ( 1.0f / vec->w ); +} + +static inline void vmathV4SqrtPerElem( VmathVector4 *result, const VmathVector4 *vec ) +{ + result->x = sqrtf( vec->x ); + result->y = sqrtf( vec->y ); + result->z = sqrtf( vec->z ); + result->w = sqrtf( vec->w ); +} + +static inline void vmathV4RsqrtPerElem( VmathVector4 *result, const VmathVector4 *vec ) +{ + result->x = ( 1.0f / sqrtf( vec->x ) ); + result->y = ( 1.0f / sqrtf( vec->y ) ); + result->z = ( 1.0f / sqrtf( vec->z ) ); + result->w = ( 1.0f / sqrtf( vec->w ) ); +} + +static inline void vmathV4AbsPerElem( VmathVector4 *result, const VmathVector4 *vec ) +{ + result->x = fabsf( vec->x ); + result->y = fabsf( vec->y ); + result->z = fabsf( vec->z ); + result->w = fabsf( vec->w ); +} + +static inline void vmathV4CopySignPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) +{ + result->x = ( vec1->x < 0.0f )? -fabsf( vec0->x ) : fabsf( vec0->x ); + result->y = ( vec1->y < 0.0f )? -fabsf( vec0->y ) : fabsf( vec0->y ); + result->z = ( vec1->z < 0.0f )? -fabsf( vec0->z ) : fabsf( vec0->z ); + result->w = ( vec1->w < 0.0f )? -fabsf( vec0->w ) : fabsf( vec0->w ); +} + +static inline void vmathV4MaxPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) +{ + result->x = (vec0->x > vec1->x)? vec0->x : vec1->x; + result->y = (vec0->y > vec1->y)? vec0->y : vec1->y; + result->z = (vec0->z > vec1->z)? vec0->z : vec1->z; + result->w = (vec0->w > vec1->w)? vec0->w : vec1->w; +} + +static inline float vmathV4MaxElem( const VmathVector4 *vec ) +{ + float result; + result = (vec->x > vec->y)? vec->x : vec->y; + result = (vec->z > result)? vec->z : result; + result = (vec->w > result)? vec->w : result; + return result; +} + +static inline void vmathV4MinPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) +{ + result->x = (vec0->x < vec1->x)? vec0->x : vec1->x; + result->y = (vec0->y < vec1->y)? vec0->y : vec1->y; + result->z = (vec0->z < vec1->z)? vec0->z : vec1->z; + result->w = (vec0->w < vec1->w)? vec0->w : vec1->w; +} + +static inline float vmathV4MinElem( const VmathVector4 *vec ) +{ + float result; + result = (vec->x < vec->y)? vec->x : vec->y; + result = (vec->z < result)? vec->z : result; + result = (vec->w < result)? vec->w : result; + return result; +} + +static inline float vmathV4Sum( const VmathVector4 *vec ) +{ + float result; + result = ( vec->x + vec->y ); + result = ( result + vec->z ); + result = ( result + vec->w ); + return result; +} + +static inline float vmathV4Dot( const VmathVector4 *vec0, const VmathVector4 *vec1 ) +{ + float result; + result = ( vec0->x * vec1->x ); + result = ( result + ( vec0->y * vec1->y ) ); + result = ( result + ( vec0->z * vec1->z ) ); + result = ( result + ( vec0->w * vec1->w ) ); + return result; +} + +static inline float vmathV4LengthSqr( const VmathVector4 *vec ) +{ + float result; + result = ( vec->x * vec->x ); + result = ( result + ( vec->y * vec->y ) ); + result = ( result + ( vec->z * vec->z ) ); + result = ( result + ( vec->w * vec->w ) ); + return result; +} + +static inline float vmathV4Length( const VmathVector4 *vec ) +{ + return sqrtf( vmathV4LengthSqr( vec ) ); +} + +static inline void vmathV4Normalize( VmathVector4 *result, const VmathVector4 *vec ) +{ + float lenSqr, lenInv; + lenSqr = vmathV4LengthSqr( vec ); + lenInv = ( 1.0f / sqrtf( lenSqr ) ); + result->x = ( vec->x * lenInv ); + result->y = ( vec->y * lenInv ); + result->z = ( vec->z * lenInv ); + result->w = ( vec->w * lenInv ); +} + +static inline void vmathV4Select( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1, unsigned int select1 ) +{ + result->x = ( select1 )? vec1->x : vec0->x; + result->y = ( select1 )? vec1->y : vec0->y; + result->z = ( select1 )? vec1->z : vec0->z; + result->w = ( select1 )? vec1->w : vec0->w; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathV4Print( const VmathVector4 *vec ) +{ + printf( "( %f %f %f %f )\n", vec->x, vec->y, vec->z, vec->w ); +} + +static inline void vmathV4Prints( const VmathVector4 *vec, const char *name ) +{ + printf( "%s: ( %f %f %f %f )\n", name, vec->x, vec->y, vec->z, vec->w ); +} + +#endif + +static inline void vmathP3Copy( VmathPoint3 *result, const VmathPoint3 *pnt ) +{ + result->x = pnt->x; + result->y = pnt->y; + result->z = pnt->z; +} + +static inline void vmathP3MakeFromElems( VmathPoint3 *result, float _x, float _y, float _z ) +{ + result->x = _x; + result->y = _y; + result->z = _z; +} + +static inline void vmathP3MakeFromV3( VmathPoint3 *result, const VmathVector3 *vec ) +{ + result->x = vec->x; + result->y = vec->y; + result->z = vec->z; +} + +static inline void vmathP3MakeFromScalar( VmathPoint3 *result, float scalar ) +{ + result->x = scalar; + result->y = scalar; + result->z = scalar; +} + +static inline void vmathP3Lerp( VmathPoint3 *result, float t, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) +{ + VmathVector3 tmpV3_0, tmpV3_1; + vmathP3Sub( &tmpV3_0, pnt1, pnt0 ); + vmathV3ScalarMul( &tmpV3_1, &tmpV3_0, t ); + vmathP3AddV3( result, pnt0, &tmpV3_1 ); +} + +static inline void vmathP3SetX( VmathPoint3 *result, float _x ) +{ + result->x = _x; +} + +static inline float vmathP3GetX( const VmathPoint3 *pnt ) +{ + return pnt->x; +} + +static inline void vmathP3SetY( VmathPoint3 *result, float _y ) +{ + result->y = _y; +} + +static inline float vmathP3GetY( const VmathPoint3 *pnt ) +{ + return pnt->y; +} + +static inline void vmathP3SetZ( VmathPoint3 *result, float _z ) +{ + result->z = _z; +} + +static inline float vmathP3GetZ( const VmathPoint3 *pnt ) +{ + return pnt->z; +} + +static inline void vmathP3SetElem( VmathPoint3 *result, int idx, float value ) +{ + *(&result->x + idx) = value; +} + +static inline float vmathP3GetElem( const VmathPoint3 *pnt, int idx ) +{ + return *(&pnt->x + idx); +} + +static inline void vmathP3Sub( VmathVector3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) +{ + result->x = ( pnt0->x - pnt1->x ); + result->y = ( pnt0->y - pnt1->y ); + result->z = ( pnt0->z - pnt1->z ); +} + +static inline void vmathP3AddV3( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *vec1 ) +{ + result->x = ( pnt->x + vec1->x ); + result->y = ( pnt->y + vec1->y ); + result->z = ( pnt->z + vec1->z ); +} + +static inline void vmathP3SubV3( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *vec1 ) +{ + result->x = ( pnt->x - vec1->x ); + result->y = ( pnt->y - vec1->y ); + result->z = ( pnt->z - vec1->z ); +} + +static inline void vmathP3MulPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) +{ + result->x = ( pnt0->x * pnt1->x ); + result->y = ( pnt0->y * pnt1->y ); + result->z = ( pnt0->z * pnt1->z ); +} + +static inline void vmathP3DivPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) +{ + result->x = ( pnt0->x / pnt1->x ); + result->y = ( pnt0->y / pnt1->y ); + result->z = ( pnt0->z / pnt1->z ); +} + +static inline void vmathP3RecipPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ) +{ + result->x = ( 1.0f / pnt->x ); + result->y = ( 1.0f / pnt->y ); + result->z = ( 1.0f / pnt->z ); +} + +static inline void vmathP3SqrtPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ) +{ + result->x = sqrtf( pnt->x ); + result->y = sqrtf( pnt->y ); + result->z = sqrtf( pnt->z ); +} + +static inline void vmathP3RsqrtPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ) +{ + result->x = ( 1.0f / sqrtf( pnt->x ) ); + result->y = ( 1.0f / sqrtf( pnt->y ) ); + result->z = ( 1.0f / sqrtf( pnt->z ) ); +} + +static inline void vmathP3AbsPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ) +{ + result->x = fabsf( pnt->x ); + result->y = fabsf( pnt->y ); + result->z = fabsf( pnt->z ); +} + +static inline void vmathP3CopySignPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) +{ + result->x = ( pnt1->x < 0.0f )? -fabsf( pnt0->x ) : fabsf( pnt0->x ); + result->y = ( pnt1->y < 0.0f )? -fabsf( pnt0->y ) : fabsf( pnt0->y ); + result->z = ( pnt1->z < 0.0f )? -fabsf( pnt0->z ) : fabsf( pnt0->z ); +} + +static inline void vmathP3MaxPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) +{ + result->x = (pnt0->x > pnt1->x)? pnt0->x : pnt1->x; + result->y = (pnt0->y > pnt1->y)? pnt0->y : pnt1->y; + result->z = (pnt0->z > pnt1->z)? pnt0->z : pnt1->z; +} + +static inline float vmathP3MaxElem( const VmathPoint3 *pnt ) +{ + float result; + result = (pnt->x > pnt->y)? pnt->x : pnt->y; + result = (pnt->z > result)? pnt->z : result; + return result; +} + +static inline void vmathP3MinPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) +{ + result->x = (pnt0->x < pnt1->x)? pnt0->x : pnt1->x; + result->y = (pnt0->y < pnt1->y)? pnt0->y : pnt1->y; + result->z = (pnt0->z < pnt1->z)? pnt0->z : pnt1->z; +} + +static inline float vmathP3MinElem( const VmathPoint3 *pnt ) +{ + float result; + result = (pnt->x < pnt->y)? pnt->x : pnt->y; + result = (pnt->z < result)? pnt->z : result; + return result; +} + +static inline float vmathP3Sum( const VmathPoint3 *pnt ) +{ + float result; + result = ( pnt->x + pnt->y ); + result = ( result + pnt->z ); + return result; +} + +static inline void vmathP3Scale( VmathPoint3 *result, const VmathPoint3 *pnt, float scaleVal ) +{ + VmathPoint3 tmpP3_0; + vmathP3MakeFromScalar( &tmpP3_0, scaleVal ); + vmathP3MulPerElem( result, pnt, &tmpP3_0 ); +} + +static inline void vmathP3NonUniformScale( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *scaleVec ) +{ + VmathPoint3 tmpP3_0; + vmathP3MakeFromV3( &tmpP3_0, scaleVec ); + vmathP3MulPerElem( result, pnt, &tmpP3_0 ); +} + +static inline float vmathP3Projection( const VmathPoint3 *pnt, const VmathVector3 *unitVec ) +{ + float result; + result = ( pnt->x * unitVec->x ); + result = ( result + ( pnt->y * unitVec->y ) ); + result = ( result + ( pnt->z * unitVec->z ) ); + return result; +} + +static inline float vmathP3DistSqrFromOrigin( const VmathPoint3 *pnt ) +{ + VmathVector3 tmpV3_0; + vmathV3MakeFromP3( &tmpV3_0, pnt ); + return vmathV3LengthSqr( &tmpV3_0 ); +} + +static inline float vmathP3DistFromOrigin( const VmathPoint3 *pnt ) +{ + VmathVector3 tmpV3_0; + vmathV3MakeFromP3( &tmpV3_0, pnt ); + return vmathV3Length( &tmpV3_0 ); +} + +static inline float vmathP3DistSqr( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) +{ + VmathVector3 tmpV3_0; + vmathP3Sub( &tmpV3_0, pnt1, pnt0 ); + return vmathV3LengthSqr( &tmpV3_0 ); +} + +static inline float vmathP3Dist( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) +{ + VmathVector3 tmpV3_0; + vmathP3Sub( &tmpV3_0, pnt1, pnt0 ); + return vmathV3Length( &tmpV3_0 ); +} + +static inline void vmathP3Select( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, unsigned int select1 ) +{ + result->x = ( select1 )? pnt1->x : pnt0->x; + result->y = ( select1 )? pnt1->y : pnt0->y; + result->z = ( select1 )? pnt1->z : pnt0->z; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathP3Print( const VmathPoint3 *pnt ) +{ + printf( "( %f %f %f )\n", pnt->x, pnt->y, pnt->z ); +} + +static inline void vmathP3Prints( const VmathPoint3 *pnt, const char *name ) +{ + printf( "%s: ( %f %f %f )\n", name, pnt->x, pnt->y, pnt->z ); +} + +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/vectormathlibrary/include/vectormath/scalar/c/vec_aos_v.h b/vectormathlibrary/include/vectormath/scalar/c/vec_aos_v.h new file mode 100644 index 000000000..75c49370d --- /dev/null +++ b/vectormathlibrary/include/vectormath/scalar/c/vec_aos_v.h @@ -0,0 +1,848 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_VEC_AOS_V_C_H +#define _VECTORMATH_VEC_AOS_V_C_H +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/*----------------------------------------------------------------------------- + * Constants + */ +#define _VECTORMATH_SLERP_TOL 0.999f + +/*----------------------------------------------------------------------------- + * Definitions + */ +#ifndef _VECTORMATH_INTERNAL_FUNCTIONS +#define _VECTORMATH_INTERNAL_FUNCTIONS + +#endif + +static inline VmathVector3 vmathV3MakeFromElems_V( float _x, float _y, float _z ) +{ + VmathVector3 result; + vmathV3MakeFromElems(&result, _x, _y, _z); + return result; +} + +static inline VmathVector3 vmathV3MakeFromP3_V( VmathPoint3 pnt ) +{ + VmathVector3 result; + vmathV3MakeFromP3(&result, &pnt); + return result; +} + +static inline VmathVector3 vmathV3MakeFromScalar_V( float scalar ) +{ + VmathVector3 result; + vmathV3MakeFromScalar(&result, scalar); + return result; +} + +static inline VmathVector3 vmathV3MakeXAxis_V( ) +{ + VmathVector3 result; + vmathV3MakeXAxis(&result); + return result; +} + +static inline VmathVector3 vmathV3MakeYAxis_V( ) +{ + VmathVector3 result; + vmathV3MakeYAxis(&result); + return result; +} + +static inline VmathVector3 vmathV3MakeZAxis_V( ) +{ + VmathVector3 result; + vmathV3MakeZAxis(&result); + return result; +} + +static inline VmathVector3 vmathV3Lerp_V( float t, VmathVector3 vec0, VmathVector3 vec1 ) +{ + VmathVector3 result; + vmathV3Lerp(&result, t, &vec0, &vec1); + return result; +} + +static inline VmathVector3 vmathV3Slerp_V( float t, VmathVector3 unitVec0, VmathVector3 unitVec1 ) +{ + VmathVector3 result; + vmathV3Slerp(&result, t, &unitVec0, &unitVec1); + return result; +} + +static inline void vmathV3SetX_V( VmathVector3 *result, float _x ) +{ + vmathV3SetX(result, _x); +} + +static inline float vmathV3GetX_V( VmathVector3 vec ) +{ + return vmathV3GetX(&vec); +} + +static inline void vmathV3SetY_V( VmathVector3 *result, float _y ) +{ + vmathV3SetY(result, _y); +} + +static inline float vmathV3GetY_V( VmathVector3 vec ) +{ + return vmathV3GetY(&vec); +} + +static inline void vmathV3SetZ_V( VmathVector3 *result, float _z ) +{ + vmathV3SetZ(result, _z); +} + +static inline float vmathV3GetZ_V( VmathVector3 vec ) +{ + return vmathV3GetZ(&vec); +} + +static inline void vmathV3SetElem_V( VmathVector3 *result, int idx, float value ) +{ + vmathV3SetElem(result, idx, value); +} + +static inline float vmathV3GetElem_V( VmathVector3 vec, int idx ) +{ + return vmathV3GetElem(&vec, idx); +} + +static inline VmathVector3 vmathV3Add_V( VmathVector3 vec0, VmathVector3 vec1 ) +{ + VmathVector3 result; + vmathV3Add(&result, &vec0, &vec1); + return result; +} + +static inline VmathVector3 vmathV3Sub_V( VmathVector3 vec0, VmathVector3 vec1 ) +{ + VmathVector3 result; + vmathV3Sub(&result, &vec0, &vec1); + return result; +} + +static inline VmathPoint3 vmathV3AddP3_V( VmathVector3 vec, VmathPoint3 pnt1 ) +{ + VmathPoint3 result; + vmathV3AddP3(&result, &vec, &pnt1); + return result; +} + +static inline VmathVector3 vmathV3ScalarMul_V( VmathVector3 vec, float scalar ) +{ + VmathVector3 result; + vmathV3ScalarMul(&result, &vec, scalar); + return result; +} + +static inline VmathVector3 vmathV3ScalarDiv_V( VmathVector3 vec, float scalar ) +{ + VmathVector3 result; + vmathV3ScalarDiv(&result, &vec, scalar); + return result; +} + +static inline VmathVector3 vmathV3Neg_V( VmathVector3 vec ) +{ + VmathVector3 result; + vmathV3Neg(&result, &vec); + return result; +} + +static inline VmathVector3 vmathV3MulPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ) +{ + VmathVector3 result; + vmathV3MulPerElem(&result, &vec0, &vec1); + return result; +} + +static inline VmathVector3 vmathV3DivPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ) +{ + VmathVector3 result; + vmathV3DivPerElem(&result, &vec0, &vec1); + return result; +} + +static inline VmathVector3 vmathV3RecipPerElem_V( VmathVector3 vec ) +{ + VmathVector3 result; + vmathV3RecipPerElem(&result, &vec); + return result; +} + +static inline VmathVector3 vmathV3SqrtPerElem_V( VmathVector3 vec ) +{ + VmathVector3 result; + vmathV3SqrtPerElem(&result, &vec); + return result; +} + +static inline VmathVector3 vmathV3RsqrtPerElem_V( VmathVector3 vec ) +{ + VmathVector3 result; + vmathV3RsqrtPerElem(&result, &vec); + return result; +} + +static inline VmathVector3 vmathV3AbsPerElem_V( VmathVector3 vec ) +{ + VmathVector3 result; + vmathV3AbsPerElem(&result, &vec); + return result; +} + +static inline VmathVector3 vmathV3CopySignPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ) +{ + VmathVector3 result; + vmathV3CopySignPerElem(&result, &vec0, &vec1); + return result; +} + +static inline VmathVector3 vmathV3MaxPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ) +{ + VmathVector3 result; + vmathV3MaxPerElem(&result, &vec0, &vec1); + return result; +} + +static inline float vmathV3MaxElem_V( VmathVector3 vec ) +{ + return vmathV3MaxElem(&vec); +} + +static inline VmathVector3 vmathV3MinPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ) +{ + VmathVector3 result; + vmathV3MinPerElem(&result, &vec0, &vec1); + return result; +} + +static inline float vmathV3MinElem_V( VmathVector3 vec ) +{ + return vmathV3MinElem(&vec); +} + +static inline float vmathV3Sum_V( VmathVector3 vec ) +{ + return vmathV3Sum(&vec); +} + +static inline float vmathV3Dot_V( VmathVector3 vec0, VmathVector3 vec1 ) +{ + return vmathV3Dot(&vec0, &vec1); +} + +static inline float vmathV3LengthSqr_V( VmathVector3 vec ) +{ + return vmathV3LengthSqr(&vec); +} + +static inline float vmathV3Length_V( VmathVector3 vec ) +{ + return vmathV3Length(&vec); +} + +static inline VmathVector3 vmathV3Normalize_V( VmathVector3 vec ) +{ + VmathVector3 result; + vmathV3Normalize(&result, &vec); + return result; +} + +static inline VmathVector3 vmathV3Cross_V( VmathVector3 vec0, VmathVector3 vec1 ) +{ + VmathVector3 result; + vmathV3Cross(&result, &vec0, &vec1); + return result; +} + +static inline VmathVector3 vmathV3Select_V( VmathVector3 vec0, VmathVector3 vec1, unsigned int select1 ) +{ + VmathVector3 result; + vmathV3Select(&result, &vec0, &vec1, select1); + return result; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathV3Print_V( VmathVector3 vec ) +{ + vmathV3Print(&vec); +} + +static inline void vmathV3Prints_V( VmathVector3 vec, const char *name ) +{ + vmathV3Prints(&vec, name); +} + +#endif + +static inline VmathVector4 vmathV4MakeFromElems_V( float _x, float _y, float _z, float _w ) +{ + VmathVector4 result; + vmathV4MakeFromElems(&result, _x, _y, _z, _w); + return result; +} + +static inline VmathVector4 vmathV4MakeFromV3Scalar_V( VmathVector3 xyz, float _w ) +{ + VmathVector4 result; + vmathV4MakeFromV3Scalar(&result, &xyz, _w); + return result; +} + +static inline VmathVector4 vmathV4MakeFromV3_V( VmathVector3 vec ) +{ + VmathVector4 result; + vmathV4MakeFromV3(&result, &vec); + return result; +} + +static inline VmathVector4 vmathV4MakeFromP3_V( VmathPoint3 pnt ) +{ + VmathVector4 result; + vmathV4MakeFromP3(&result, &pnt); + return result; +} + +static inline VmathVector4 vmathV4MakeFromQ_V( VmathQuat quat ) +{ + VmathVector4 result; + vmathV4MakeFromQ(&result, &quat); + return result; +} + +static inline VmathVector4 vmathV4MakeFromScalar_V( float scalar ) +{ + VmathVector4 result; + vmathV4MakeFromScalar(&result, scalar); + return result; +} + +static inline VmathVector4 vmathV4MakeXAxis_V( ) +{ + VmathVector4 result; + vmathV4MakeXAxis(&result); + return result; +} + +static inline VmathVector4 vmathV4MakeYAxis_V( ) +{ + VmathVector4 result; + vmathV4MakeYAxis(&result); + return result; +} + +static inline VmathVector4 vmathV4MakeZAxis_V( ) +{ + VmathVector4 result; + vmathV4MakeZAxis(&result); + return result; +} + +static inline VmathVector4 vmathV4MakeWAxis_V( ) +{ + VmathVector4 result; + vmathV4MakeWAxis(&result); + return result; +} + +static inline VmathVector4 vmathV4Lerp_V( float t, VmathVector4 vec0, VmathVector4 vec1 ) +{ + VmathVector4 result; + vmathV4Lerp(&result, t, &vec0, &vec1); + return result; +} + +static inline VmathVector4 vmathV4Slerp_V( float t, VmathVector4 unitVec0, VmathVector4 unitVec1 ) +{ + VmathVector4 result; + vmathV4Slerp(&result, t, &unitVec0, &unitVec1); + return result; +} + +static inline void vmathV4SetXYZ_V( VmathVector4 *result, VmathVector3 vec ) +{ + vmathV4SetXYZ(result, &vec); +} + +static inline VmathVector3 vmathV4GetXYZ_V( VmathVector4 vec ) +{ + VmathVector3 result; + vmathV4GetXYZ(&result, &vec); + return result; +} + +static inline void vmathV4SetX_V( VmathVector4 *result, float _x ) +{ + vmathV4SetX(result, _x); +} + +static inline float vmathV4GetX_V( VmathVector4 vec ) +{ + return vmathV4GetX(&vec); +} + +static inline void vmathV4SetY_V( VmathVector4 *result, float _y ) +{ + vmathV4SetY(result, _y); +} + +static inline float vmathV4GetY_V( VmathVector4 vec ) +{ + return vmathV4GetY(&vec); +} + +static inline void vmathV4SetZ_V( VmathVector4 *result, float _z ) +{ + vmathV4SetZ(result, _z); +} + +static inline float vmathV4GetZ_V( VmathVector4 vec ) +{ + return vmathV4GetZ(&vec); +} + +static inline void vmathV4SetW_V( VmathVector4 *result, float _w ) +{ + vmathV4SetW(result, _w); +} + +static inline float vmathV4GetW_V( VmathVector4 vec ) +{ + return vmathV4GetW(&vec); +} + +static inline void vmathV4SetElem_V( VmathVector4 *result, int idx, float value ) +{ + vmathV4SetElem(result, idx, value); +} + +static inline float vmathV4GetElem_V( VmathVector4 vec, int idx ) +{ + return vmathV4GetElem(&vec, idx); +} + +static inline VmathVector4 vmathV4Add_V( VmathVector4 vec0, VmathVector4 vec1 ) +{ + VmathVector4 result; + vmathV4Add(&result, &vec0, &vec1); + return result; +} + +static inline VmathVector4 vmathV4Sub_V( VmathVector4 vec0, VmathVector4 vec1 ) +{ + VmathVector4 result; + vmathV4Sub(&result, &vec0, &vec1); + return result; +} + +static inline VmathVector4 vmathV4ScalarMul_V( VmathVector4 vec, float scalar ) +{ + VmathVector4 result; + vmathV4ScalarMul(&result, &vec, scalar); + return result; +} + +static inline VmathVector4 vmathV4ScalarDiv_V( VmathVector4 vec, float scalar ) +{ + VmathVector4 result; + vmathV4ScalarDiv(&result, &vec, scalar); + return result; +} + +static inline VmathVector4 vmathV4Neg_V( VmathVector4 vec ) +{ + VmathVector4 result; + vmathV4Neg(&result, &vec); + return result; +} + +static inline VmathVector4 vmathV4MulPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ) +{ + VmathVector4 result; + vmathV4MulPerElem(&result, &vec0, &vec1); + return result; +} + +static inline VmathVector4 vmathV4DivPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ) +{ + VmathVector4 result; + vmathV4DivPerElem(&result, &vec0, &vec1); + return result; +} + +static inline VmathVector4 vmathV4RecipPerElem_V( VmathVector4 vec ) +{ + VmathVector4 result; + vmathV4RecipPerElem(&result, &vec); + return result; +} + +static inline VmathVector4 vmathV4SqrtPerElem_V( VmathVector4 vec ) +{ + VmathVector4 result; + vmathV4SqrtPerElem(&result, &vec); + return result; +} + +static inline VmathVector4 vmathV4RsqrtPerElem_V( VmathVector4 vec ) +{ + VmathVector4 result; + vmathV4RsqrtPerElem(&result, &vec); + return result; +} + +static inline VmathVector4 vmathV4AbsPerElem_V( VmathVector4 vec ) +{ + VmathVector4 result; + vmathV4AbsPerElem(&result, &vec); + return result; +} + +static inline VmathVector4 vmathV4CopySignPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ) +{ + VmathVector4 result; + vmathV4CopySignPerElem(&result, &vec0, &vec1); + return result; +} + +static inline VmathVector4 vmathV4MaxPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ) +{ + VmathVector4 result; + vmathV4MaxPerElem(&result, &vec0, &vec1); + return result; +} + +static inline float vmathV4MaxElem_V( VmathVector4 vec ) +{ + return vmathV4MaxElem(&vec); +} + +static inline VmathVector4 vmathV4MinPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ) +{ + VmathVector4 result; + vmathV4MinPerElem(&result, &vec0, &vec1); + return result; +} + +static inline float vmathV4MinElem_V( VmathVector4 vec ) +{ + return vmathV4MinElem(&vec); +} + +static inline float vmathV4Sum_V( VmathVector4 vec ) +{ + return vmathV4Sum(&vec); +} + +static inline float vmathV4Dot_V( VmathVector4 vec0, VmathVector4 vec1 ) +{ + return vmathV4Dot(&vec0, &vec1); +} + +static inline float vmathV4LengthSqr_V( VmathVector4 vec ) +{ + return vmathV4LengthSqr(&vec); +} + +static inline float vmathV4Length_V( VmathVector4 vec ) +{ + return vmathV4Length(&vec); +} + +static inline VmathVector4 vmathV4Normalize_V( VmathVector4 vec ) +{ + VmathVector4 result; + vmathV4Normalize(&result, &vec); + return result; +} + +static inline VmathVector4 vmathV4Select_V( VmathVector4 vec0, VmathVector4 vec1, unsigned int select1 ) +{ + VmathVector4 result; + vmathV4Select(&result, &vec0, &vec1, select1); + return result; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathV4Print_V( VmathVector4 vec ) +{ + vmathV4Print(&vec); +} + +static inline void vmathV4Prints_V( VmathVector4 vec, const char *name ) +{ + vmathV4Prints(&vec, name); +} + +#endif + +static inline VmathPoint3 vmathP3MakeFromElems_V( float _x, float _y, float _z ) +{ + VmathPoint3 result; + vmathP3MakeFromElems(&result, _x, _y, _z); + return result; +} + +static inline VmathPoint3 vmathP3MakeFromV3_V( VmathVector3 vec ) +{ + VmathPoint3 result; + vmathP3MakeFromV3(&result, &vec); + return result; +} + +static inline VmathPoint3 vmathP3MakeFromScalar_V( float scalar ) +{ + VmathPoint3 result; + vmathP3MakeFromScalar(&result, scalar); + return result; +} + +static inline VmathPoint3 vmathP3Lerp_V( float t, VmathPoint3 pnt0, VmathPoint3 pnt1 ) +{ + VmathPoint3 result; + vmathP3Lerp(&result, t, &pnt0, &pnt1); + return result; +} + +static inline void vmathP3SetX_V( VmathPoint3 *result, float _x ) +{ + vmathP3SetX(result, _x); +} + +static inline float vmathP3GetX_V( VmathPoint3 pnt ) +{ + return vmathP3GetX(&pnt); +} + +static inline void vmathP3SetY_V( VmathPoint3 *result, float _y ) +{ + vmathP3SetY(result, _y); +} + +static inline float vmathP3GetY_V( VmathPoint3 pnt ) +{ + return vmathP3GetY(&pnt); +} + +static inline void vmathP3SetZ_V( VmathPoint3 *result, float _z ) +{ + vmathP3SetZ(result, _z); +} + +static inline float vmathP3GetZ_V( VmathPoint3 pnt ) +{ + return vmathP3GetZ(&pnt); +} + +static inline void vmathP3SetElem_V( VmathPoint3 *result, int idx, float value ) +{ + vmathP3SetElem(result, idx, value); +} + +static inline float vmathP3GetElem_V( VmathPoint3 pnt, int idx ) +{ + return vmathP3GetElem(&pnt, idx); +} + +static inline VmathVector3 vmathP3Sub_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) +{ + VmathVector3 result; + vmathP3Sub(&result, &pnt0, &pnt1); + return result; +} + +static inline VmathPoint3 vmathP3AddV3_V( VmathPoint3 pnt, VmathVector3 vec1 ) +{ + VmathPoint3 result; + vmathP3AddV3(&result, &pnt, &vec1); + return result; +} + +static inline VmathPoint3 vmathP3SubV3_V( VmathPoint3 pnt, VmathVector3 vec1 ) +{ + VmathPoint3 result; + vmathP3SubV3(&result, &pnt, &vec1); + return result; +} + +static inline VmathPoint3 vmathP3MulPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) +{ + VmathPoint3 result; + vmathP3MulPerElem(&result, &pnt0, &pnt1); + return result; +} + +static inline VmathPoint3 vmathP3DivPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) +{ + VmathPoint3 result; + vmathP3DivPerElem(&result, &pnt0, &pnt1); + return result; +} + +static inline VmathPoint3 vmathP3RecipPerElem_V( VmathPoint3 pnt ) +{ + VmathPoint3 result; + vmathP3RecipPerElem(&result, &pnt); + return result; +} + +static inline VmathPoint3 vmathP3SqrtPerElem_V( VmathPoint3 pnt ) +{ + VmathPoint3 result; + vmathP3SqrtPerElem(&result, &pnt); + return result; +} + +static inline VmathPoint3 vmathP3RsqrtPerElem_V( VmathPoint3 pnt ) +{ + VmathPoint3 result; + vmathP3RsqrtPerElem(&result, &pnt); + return result; +} + +static inline VmathPoint3 vmathP3AbsPerElem_V( VmathPoint3 pnt ) +{ + VmathPoint3 result; + vmathP3AbsPerElem(&result, &pnt); + return result; +} + +static inline VmathPoint3 vmathP3CopySignPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) +{ + VmathPoint3 result; + vmathP3CopySignPerElem(&result, &pnt0, &pnt1); + return result; +} + +static inline VmathPoint3 vmathP3MaxPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) +{ + VmathPoint3 result; + vmathP3MaxPerElem(&result, &pnt0, &pnt1); + return result; +} + +static inline float vmathP3MaxElem_V( VmathPoint3 pnt ) +{ + return vmathP3MaxElem(&pnt); +} + +static inline VmathPoint3 vmathP3MinPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) +{ + VmathPoint3 result; + vmathP3MinPerElem(&result, &pnt0, &pnt1); + return result; +} + +static inline float vmathP3MinElem_V( VmathPoint3 pnt ) +{ + return vmathP3MinElem(&pnt); +} + +static inline float vmathP3Sum_V( VmathPoint3 pnt ) +{ + return vmathP3Sum(&pnt); +} + +static inline VmathPoint3 vmathP3Scale_V( VmathPoint3 pnt, float scaleVal ) +{ + VmathPoint3 result; + vmathP3Scale(&result, &pnt, scaleVal); + return result; +} + +static inline VmathPoint3 vmathP3NonUniformScale_V( VmathPoint3 pnt, VmathVector3 scaleVec ) +{ + VmathPoint3 result; + vmathP3NonUniformScale(&result, &pnt, &scaleVec); + return result; +} + +static inline float vmathP3Projection_V( VmathPoint3 pnt, VmathVector3 unitVec ) +{ + return vmathP3Projection(&pnt, &unitVec); +} + +static inline float vmathP3DistSqrFromOrigin_V( VmathPoint3 pnt ) +{ + return vmathP3DistSqrFromOrigin(&pnt); +} + +static inline float vmathP3DistFromOrigin_V( VmathPoint3 pnt ) +{ + return vmathP3DistFromOrigin(&pnt); +} + +static inline float vmathP3DistSqr_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) +{ + return vmathP3DistSqr(&pnt0, &pnt1); +} + +static inline float vmathP3Dist_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) +{ + return vmathP3Dist(&pnt0, &pnt1); +} + +static inline VmathPoint3 vmathP3Select_V( VmathPoint3 pnt0, VmathPoint3 pnt1, unsigned int select1 ) +{ + VmathPoint3 result; + vmathP3Select(&result, &pnt0, &pnt1, select1); + return result; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathP3Print_V( VmathPoint3 pnt ) +{ + vmathP3Print(&pnt); +} + +static inline void vmathP3Prints_V( VmathPoint3 pnt, const char *name ) +{ + vmathP3Prints(&pnt, name); +} + +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/vectormathlibrary/include/vectormath/scalar/c/vectormath_aos.h b/vectormathlibrary/include/vectormath/scalar/c/vectormath_aos.h new file mode 100644 index 000000000..26bee0b81 --- /dev/null +++ b/vectormathlibrary/include/vectormath/scalar/c/vectormath_aos.h @@ -0,0 +1,1879 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_AOS_C_SCALAR_H +#define _VECTORMATH_AOS_C_SCALAR_H + +#include <math.h> + +#ifdef _VECTORMATH_DEBUG +#include <stdio.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#ifndef _VECTORMATH_AOS_C_TYPES_H +#define _VECTORMATH_AOS_C_TYPES_H + +/* A 3-D vector in array-of-structures format + */ +typedef struct _VmathVector3 +{ + float x; + float y; + float z; +#ifndef __GNUC__ + float d; +#endif +} +#ifdef __GNUC__ +__attribute__ ((aligned(16))) +#endif +VmathVector3; + +/* A 4-D vector in array-of-structures format + */ +typedef struct _VmathVector4 +{ + float x; + float y; + float z; + float w; +} +#ifdef __GNUC__ +__attribute__ ((aligned(16))) +#endif +VmathVector4; + +/* A 3-D point in array-of-structures format + */ +typedef struct _VmathPoint3 +{ + float x; + float y; + float z; +#ifndef __GNUC__ + float d; +#endif +} +#ifdef __GNUC__ +__attribute__ ((aligned(16))) +#endif +VmathPoint3; + +/* A quaternion in array-of-structures format + */ +typedef struct _VmathQuat +{ + float x; + float y; + float z; + float w; +} +#ifdef __GNUC__ +__attribute__ ((aligned(16))) +#endif +VmathQuat; + +/* A 3x3 matrix in array-of-structures format + */ +typedef struct _VmathMatrix3 +{ + VmathVector3 col0; + VmathVector3 col1; + VmathVector3 col2; +} VmathMatrix3; + +/* A 4x4 matrix in array-of-structures format + */ +typedef struct _VmathMatrix4 +{ + VmathVector4 col0; + VmathVector4 col1; + VmathVector4 col2; + VmathVector4 col3; +} VmathMatrix4; + +/* A 3x4 transformation matrix in array-of-structures format + */ +typedef struct _VmathTransform3 +{ + VmathVector3 col0; + VmathVector3 col1; + VmathVector3 col2; + VmathVector3 col3; +} VmathTransform3; + +#endif + +/* + * Copy a 3-D vector + */ +static inline void vmathV3Copy( VmathVector3 *result, const VmathVector3 *vec ); + +/* + * Construct a 3-D vector from x, y, and z elements + */ +static inline void vmathV3MakeFromElems( VmathVector3 *result, float x, float y, float z ); + +/* + * Copy elements from a 3-D point into a 3-D vector + */ +static inline void vmathV3MakeFromP3( VmathVector3 *result, const VmathPoint3 *pnt ); + +/* + * Set all elements of a 3-D vector to the same scalar value + */ +static inline void vmathV3MakeFromScalar( VmathVector3 *result, float scalar ); + +/* + * Set the x element of a 3-D vector + */ +static inline void vmathV3SetX( VmathVector3 *result, float x ); + +/* + * Set the y element of a 3-D vector + */ +static inline void vmathV3SetY( VmathVector3 *result, float y ); + +/* + * Set the z element of a 3-D vector + */ +static inline void vmathV3SetZ( VmathVector3 *result, float z ); + +/* + * Get the x element of a 3-D vector + */ +static inline float vmathV3GetX( const VmathVector3 *vec ); + +/* + * Get the y element of a 3-D vector + */ +static inline float vmathV3GetY( const VmathVector3 *vec ); + +/* + * Get the z element of a 3-D vector + */ +static inline float vmathV3GetZ( const VmathVector3 *vec ); + +/* + * Set an x, y, or z element of a 3-D vector by index + */ +static inline void vmathV3SetElem( VmathVector3 *result, int idx, float value ); + +/* + * Get an x, y, or z element of a 3-D vector by index + */ +static inline float vmathV3GetElem( const VmathVector3 *vec, int idx ); + +/* + * Add two 3-D vectors + */ +static inline void vmathV3Add( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); + +/* + * Subtract a 3-D vector from another 3-D vector + */ +static inline void vmathV3Sub( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); + +/* + * Add a 3-D vector to a 3-D point + */ +static inline void vmathV3AddP3( VmathPoint3 *result, const VmathVector3 *vec, const VmathPoint3 *pnt ); + +/* + * Multiply a 3-D vector by a scalar + */ +static inline void vmathV3ScalarMul( VmathVector3 *result, const VmathVector3 *vec, float scalar ); + +/* + * Divide a 3-D vector by a scalar + */ +static inline void vmathV3ScalarDiv( VmathVector3 *result, const VmathVector3 *vec, float scalar ); + +/* + * Negate all elements of a 3-D vector + */ +static inline void vmathV3Neg( VmathVector3 *result, const VmathVector3 *vec ); + +/* + * Construct x axis + */ +static inline void vmathV3MakeXAxis( VmathVector3 *result ); + +/* + * Construct y axis + */ +static inline void vmathV3MakeYAxis( VmathVector3 *result ); + +/* + * Construct z axis + */ +static inline void vmathV3MakeZAxis( VmathVector3 *result ); + +/* + * Multiply two 3-D vectors per element + */ +static inline void vmathV3MulPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); + +/* + * Divide two 3-D vectors per element + * NOTE: + * Floating-point behavior matches standard library function divf4. + */ +static inline void vmathV3DivPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); + +/* + * Compute the reciprocal of a 3-D vector per element + * NOTE: + * Floating-point behavior matches standard library function recipf4. + */ +static inline void vmathV3RecipPerElem( VmathVector3 *result, const VmathVector3 *vec ); + +/* + * Compute the square root of a 3-D vector per element + * NOTE: + * Floating-point behavior matches standard library function sqrtf4. + */ +static inline void vmathV3SqrtPerElem( VmathVector3 *result, const VmathVector3 *vec ); + +/* + * Compute the reciprocal square root of a 3-D vector per element + * NOTE: + * Floating-point behavior matches standard library function rsqrtf4. + */ +static inline void vmathV3RsqrtPerElem( VmathVector3 *result, const VmathVector3 *vec ); + +/* + * Compute the absolute value of a 3-D vector per element + */ +static inline void vmathV3AbsPerElem( VmathVector3 *result, const VmathVector3 *vec ); + +/* + * Copy sign from one 3-D vector to another, per element + */ +static inline void vmathV3CopySignPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); + +/* + * Maximum of two 3-D vectors per element + */ +static inline void vmathV3MaxPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); + +/* + * Minimum of two 3-D vectors per element + */ +static inline void vmathV3MinPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); + +/* + * Maximum element of a 3-D vector + */ +static inline float vmathV3MaxElem( const VmathVector3 *vec ); + +/* + * Minimum element of a 3-D vector + */ +static inline float vmathV3MinElem( const VmathVector3 *vec ); + +/* + * Compute the sum of all elements of a 3-D vector + */ +static inline float vmathV3Sum( const VmathVector3 *vec ); + +/* + * Compute the dot product of two 3-D vectors + */ +static inline float vmathV3Dot( const VmathVector3 *vec0, const VmathVector3 *vec1 ); + +/* + * Compute the square of the length of a 3-D vector + */ +static inline float vmathV3LengthSqr( const VmathVector3 *vec ); + +/* + * Compute the length of a 3-D vector + */ +static inline float vmathV3Length( const VmathVector3 *vec ); + +/* + * Normalize a 3-D vector + * NOTE: + * The result is unpredictable when all elements of vec are at or near zero. + */ +static inline void vmathV3Normalize( VmathVector3 *result, const VmathVector3 *vec ); + +/* + * Compute cross product of two 3-D vectors + */ +static inline void vmathV3Cross( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); + +/* + * Outer product of two 3-D vectors + */ +static inline void vmathV3Outer( VmathMatrix3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); + +/* + * Pre-multiply a row vector by a 3x3 matrix + */ +static inline void vmathV3RowMul( VmathVector3 *result, const VmathVector3 *vec, const VmathMatrix3 *mat ); + +/* + * Cross-product matrix of a 3-D vector + */ +static inline void vmathV3CrossMatrix( VmathMatrix3 *result, const VmathVector3 *vec ); + +/* + * Create cross-product matrix and multiply + * NOTE: + * Faster than separately creating a cross-product matrix and multiplying. + */ +static inline void vmathV3CrossMatrixMul( VmathMatrix3 *result, const VmathVector3 *vec, const VmathMatrix3 *mat ); + +/* + * Linear interpolation between two 3-D vectors + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline void vmathV3Lerp( VmathVector3 *result, float t, const VmathVector3 *vec0, const VmathVector3 *vec1 ); + +/* + * Spherical linear interpolation between two 3-D vectors + * NOTE: + * The result is unpredictable if the vectors point in opposite directions. + * Does not clamp t between 0 and 1. + */ +static inline void vmathV3Slerp( VmathVector3 *result, float t, const VmathVector3 *unitVec0, const VmathVector3 *unitVec1 ); + +/* + * Conditionally select between two 3-D vectors + */ +static inline void vmathV3Select( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1, unsigned int select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3-D vector + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathV3Print( const VmathVector3 *vec ); + +/* + * Print a 3-D vector and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathV3Prints( const VmathVector3 *vec, const char *name ); + +#endif + +/* + * Copy a 4-D vector + */ +static inline void vmathV4Copy( VmathVector4 *result, const VmathVector4 *vec ); + +/* + * Construct a 4-D vector from x, y, z, and w elements + */ +static inline void vmathV4MakeFromElems( VmathVector4 *result, float x, float y, float z, float w ); + +/* + * Construct a 4-D vector from a 3-D vector and a scalar + */ +static inline void vmathV4MakeFromV3Scalar( VmathVector4 *result, const VmathVector3 *xyz, float w ); + +/* + * Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0 + */ +static inline void vmathV4MakeFromV3( VmathVector4 *result, const VmathVector3 *vec ); + +/* + * Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1 + */ +static inline void vmathV4MakeFromP3( VmathVector4 *result, const VmathPoint3 *pnt ); + +/* + * Copy elements from a quaternion into a 4-D vector + */ +static inline void vmathV4MakeFromQ( VmathVector4 *result, const VmathQuat *quat ); + +/* + * Set all elements of a 4-D vector to the same scalar value + */ +static inline void vmathV4MakeFromScalar( VmathVector4 *result, float scalar ); + +/* + * Set the x, y, and z elements of a 4-D vector + * NOTE: + * This function does not change the w element. + */ +static inline void vmathV4SetXYZ( VmathVector4 *result, const VmathVector3 *vec ); + +/* + * Get the x, y, and z elements of a 4-D vector + */ +static inline void vmathV4GetXYZ( VmathVector3 *result, const VmathVector4 *vec ); + +/* + * Set the x element of a 4-D vector + */ +static inline void vmathV4SetX( VmathVector4 *result, float x ); + +/* + * Set the y element of a 4-D vector + */ +static inline void vmathV4SetY( VmathVector4 *result, float y ); + +/* + * Set the z element of a 4-D vector + */ +static inline void vmathV4SetZ( VmathVector4 *result, float z ); + +/* + * Set the w element of a 4-D vector + */ +static inline void vmathV4SetW( VmathVector4 *result, float w ); + +/* + * Get the x element of a 4-D vector + */ +static inline float vmathV4GetX( const VmathVector4 *vec ); + +/* + * Get the y element of a 4-D vector + */ +static inline float vmathV4GetY( const VmathVector4 *vec ); + +/* + * Get the z element of a 4-D vector + */ +static inline float vmathV4GetZ( const VmathVector4 *vec ); + +/* + * Get the w element of a 4-D vector + */ +static inline float vmathV4GetW( const VmathVector4 *vec ); + +/* + * Set an x, y, z, or w element of a 4-D vector by index + */ +static inline void vmathV4SetElem( VmathVector4 *result, int idx, float value ); + +/* + * Get an x, y, z, or w element of a 4-D vector by index + */ +static inline float vmathV4GetElem( const VmathVector4 *vec, int idx ); + +/* + * Add two 4-D vectors + */ +static inline void vmathV4Add( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); + +/* + * Subtract a 4-D vector from another 4-D vector + */ +static inline void vmathV4Sub( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); + +/* + * Multiply a 4-D vector by a scalar + */ +static inline void vmathV4ScalarMul( VmathVector4 *result, const VmathVector4 *vec, float scalar ); + +/* + * Divide a 4-D vector by a scalar + */ +static inline void vmathV4ScalarDiv( VmathVector4 *result, const VmathVector4 *vec, float scalar ); + +/* + * Negate all elements of a 4-D vector + */ +static inline void vmathV4Neg( VmathVector4 *result, const VmathVector4 *vec ); + +/* + * Construct x axis + */ +static inline void vmathV4MakeXAxis( VmathVector4 *result ); + +/* + * Construct y axis + */ +static inline void vmathV4MakeYAxis( VmathVector4 *result ); + +/* + * Construct z axis + */ +static inline void vmathV4MakeZAxis( VmathVector4 *result ); + +/* + * Construct w axis + */ +static inline void vmathV4MakeWAxis( VmathVector4 *result ); + +/* + * Multiply two 4-D vectors per element + */ +static inline void vmathV4MulPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); + +/* + * Divide two 4-D vectors per element + * NOTE: + * Floating-point behavior matches standard library function divf4. + */ +static inline void vmathV4DivPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); + +/* + * Compute the reciprocal of a 4-D vector per element + * NOTE: + * Floating-point behavior matches standard library function recipf4. + */ +static inline void vmathV4RecipPerElem( VmathVector4 *result, const VmathVector4 *vec ); + +/* + * Compute the square root of a 4-D vector per element + * NOTE: + * Floating-point behavior matches standard library function sqrtf4. + */ +static inline void vmathV4SqrtPerElem( VmathVector4 *result, const VmathVector4 *vec ); + +/* + * Compute the reciprocal square root of a 4-D vector per element + * NOTE: + * Floating-point behavior matches standard library function rsqrtf4. + */ +static inline void vmathV4RsqrtPerElem( VmathVector4 *result, const VmathVector4 *vec ); + +/* + * Compute the absolute value of a 4-D vector per element + */ +static inline void vmathV4AbsPerElem( VmathVector4 *result, const VmathVector4 *vec ); + +/* + * Copy sign from one 4-D vector to another, per element + */ +static inline void vmathV4CopySignPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); + +/* + * Maximum of two 4-D vectors per element + */ +static inline void vmathV4MaxPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); + +/* + * Minimum of two 4-D vectors per element + */ +static inline void vmathV4MinPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); + +/* + * Maximum element of a 4-D vector + */ +static inline float vmathV4MaxElem( const VmathVector4 *vec ); + +/* + * Minimum element of a 4-D vector + */ +static inline float vmathV4MinElem( const VmathVector4 *vec ); + +/* + * Compute the sum of all elements of a 4-D vector + */ +static inline float vmathV4Sum( const VmathVector4 *vec ); + +/* + * Compute the dot product of two 4-D vectors + */ +static inline float vmathV4Dot( const VmathVector4 *vec0, const VmathVector4 *vec1 ); + +/* + * Compute the square of the length of a 4-D vector + */ +static inline float vmathV4LengthSqr( const VmathVector4 *vec ); + +/* + * Compute the length of a 4-D vector + */ +static inline float vmathV4Length( const VmathVector4 *vec ); + +/* + * Normalize a 4-D vector + * NOTE: + * The result is unpredictable when all elements of vec are at or near zero. + */ +static inline void vmathV4Normalize( VmathVector4 *result, const VmathVector4 *vec ); + +/* + * Outer product of two 4-D vectors + */ +static inline void vmathV4Outer( VmathMatrix4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); + +/* + * Linear interpolation between two 4-D vectors + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline void vmathV4Lerp( VmathVector4 *result, float t, const VmathVector4 *vec0, const VmathVector4 *vec1 ); + +/* + * Spherical linear interpolation between two 4-D vectors + * NOTE: + * The result is unpredictable if the vectors point in opposite directions. + * Does not clamp t between 0 and 1. + */ +static inline void vmathV4Slerp( VmathVector4 *result, float t, const VmathVector4 *unitVec0, const VmathVector4 *unitVec1 ); + +/* + * Conditionally select between two 4-D vectors + */ +static inline void vmathV4Select( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1, unsigned int select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 4-D vector + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathV4Print( const VmathVector4 *vec ); + +/* + * Print a 4-D vector and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathV4Prints( const VmathVector4 *vec, const char *name ); + +#endif + +/* + * Copy a 3-D point + */ +static inline void vmathP3Copy( VmathPoint3 *result, const VmathPoint3 *pnt ); + +/* + * Construct a 3-D point from x, y, and z elements + */ +static inline void vmathP3MakeFromElems( VmathPoint3 *result, float x, float y, float z ); + +/* + * Copy elements from a 3-D vector into a 3-D point + */ +static inline void vmathP3MakeFromV3( VmathPoint3 *result, const VmathVector3 *vec ); + +/* + * Set all elements of a 3-D point to the same scalar value + */ +static inline void vmathP3MakeFromScalar( VmathPoint3 *result, float scalar ); + +/* + * Set the x element of a 3-D point + */ +static inline void vmathP3SetX( VmathPoint3 *result, float x ); + +/* + * Set the y element of a 3-D point + */ +static inline void vmathP3SetY( VmathPoint3 *result, float y ); + +/* + * Set the z element of a 3-D point + */ +static inline void vmathP3SetZ( VmathPoint3 *result, float z ); + +/* + * Get the x element of a 3-D point + */ +static inline float vmathP3GetX( const VmathPoint3 *pnt ); + +/* + * Get the y element of a 3-D point + */ +static inline float vmathP3GetY( const VmathPoint3 *pnt ); + +/* + * Get the z element of a 3-D point + */ +static inline float vmathP3GetZ( const VmathPoint3 *pnt ); + +/* + * Set an x, y, or z element of a 3-D point by index + */ +static inline void vmathP3SetElem( VmathPoint3 *result, int idx, float value ); + +/* + * Get an x, y, or z element of a 3-D point by index + */ +static inline float vmathP3GetElem( const VmathPoint3 *pnt, int idx ); + +/* + * Subtract a 3-D point from another 3-D point + */ +static inline void vmathP3Sub( VmathVector3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); + +/* + * Add a 3-D point to a 3-D vector + */ +static inline void vmathP3AddV3( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *vec ); + +/* + * Subtract a 3-D vector from a 3-D point + */ +static inline void vmathP3SubV3( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *vec ); + +/* + * Multiply two 3-D points per element + */ +static inline void vmathP3MulPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); + +/* + * Divide two 3-D points per element + * NOTE: + * Floating-point behavior matches standard library function divf4. + */ +static inline void vmathP3DivPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); + +/* + * Compute the reciprocal of a 3-D point per element + * NOTE: + * Floating-point behavior matches standard library function recipf4. + */ +static inline void vmathP3RecipPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ); + +/* + * Compute the square root of a 3-D point per element + * NOTE: + * Floating-point behavior matches standard library function sqrtf4. + */ +static inline void vmathP3SqrtPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ); + +/* + * Compute the reciprocal square root of a 3-D point per element + * NOTE: + * Floating-point behavior matches standard library function rsqrtf4. + */ +static inline void vmathP3RsqrtPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ); + +/* + * Compute the absolute value of a 3-D point per element + */ +static inline void vmathP3AbsPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ); + +/* + * Copy sign from one 3-D point to another, per element + */ +static inline void vmathP3CopySignPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); + +/* + * Maximum of two 3-D points per element + */ +static inline void vmathP3MaxPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); + +/* + * Minimum of two 3-D points per element + */ +static inline void vmathP3MinPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); + +/* + * Maximum element of a 3-D point + */ +static inline float vmathP3MaxElem( const VmathPoint3 *pnt ); + +/* + * Minimum element of a 3-D point + */ +static inline float vmathP3MinElem( const VmathPoint3 *pnt ); + +/* + * Compute the sum of all elements of a 3-D point + */ +static inline float vmathP3Sum( const VmathPoint3 *pnt ); + +/* + * Apply uniform scale to a 3-D point + */ +static inline void vmathP3Scale( VmathPoint3 *result, const VmathPoint3 *pnt, float scaleVal ); + +/* + * Apply non-uniform scale to a 3-D point + */ +static inline void vmathP3NonUniformScale( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *scaleVec ); + +/* + * Scalar projection of a 3-D point on a unit-length 3-D vector + */ +static inline float vmathP3Projection( const VmathPoint3 *pnt, const VmathVector3 *unitVec ); + +/* + * Compute the square of the distance of a 3-D point from the coordinate-system origin + */ +static inline float vmathP3DistSqrFromOrigin( const VmathPoint3 *pnt ); + +/* + * Compute the distance of a 3-D point from the coordinate-system origin + */ +static inline float vmathP3DistFromOrigin( const VmathPoint3 *pnt ); + +/* + * Compute the square of the distance between two 3-D points + */ +static inline float vmathP3DistSqr( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); + +/* + * Compute the distance between two 3-D points + */ +static inline float vmathP3Dist( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); + +/* + * Linear interpolation between two 3-D points + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline void vmathP3Lerp( VmathPoint3 *result, float t, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); + +/* + * Conditionally select between two 3-D points + */ +static inline void vmathP3Select( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, unsigned int select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3-D point + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathP3Print( const VmathPoint3 *pnt ); + +/* + * Print a 3-D point and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathP3Prints( const VmathPoint3 *pnt, const char *name ); + +#endif + +/* + * Copy a quaternion + */ +static inline void vmathQCopy( VmathQuat *result, const VmathQuat *quat ); + +/* + * Construct a quaternion from x, y, z, and w elements + */ +static inline void vmathQMakeFromElems( VmathQuat *result, float x, float y, float z, float w ); + +/* + * Construct a quaternion from a 3-D vector and a scalar + */ +static inline void vmathQMakeFromV3Scalar( VmathQuat *result, const VmathVector3 *xyz, float w ); + +/* + * Copy elements from a 4-D vector into a quaternion + */ +static inline void vmathQMakeFromV4( VmathQuat *result, const VmathVector4 *vec ); + +/* + * Convert a rotation matrix to a unit-length quaternion + */ +static inline void vmathQMakeFromM3( VmathQuat *result, const VmathMatrix3 *rotMat ); + +/* + * Set all elements of a quaternion to the same scalar value + */ +static inline void vmathQMakeFromScalar( VmathQuat *result, float scalar ); + +/* + * Set the x, y, and z elements of a quaternion + * NOTE: + * This function does not change the w element. + */ +static inline void vmathQSetXYZ( VmathQuat *result, const VmathVector3 *vec ); + +/* + * Get the x, y, and z elements of a quaternion + */ +static inline void vmathQGetXYZ( VmathVector3 *result, const VmathQuat *quat ); + +/* + * Set the x element of a quaternion + */ +static inline void vmathQSetX( VmathQuat *result, float x ); + +/* + * Set the y element of a quaternion + */ +static inline void vmathQSetY( VmathQuat *result, float y ); + +/* + * Set the z element of a quaternion + */ +static inline void vmathQSetZ( VmathQuat *result, float z ); + +/* + * Set the w element of a quaternion + */ +static inline void vmathQSetW( VmathQuat *result, float w ); + +/* + * Get the x element of a quaternion + */ +static inline float vmathQGetX( const VmathQuat *quat ); + +/* + * Get the y element of a quaternion + */ +static inline float vmathQGetY( const VmathQuat *quat ); + +/* + * Get the z element of a quaternion + */ +static inline float vmathQGetZ( const VmathQuat *quat ); + +/* + * Get the w element of a quaternion + */ +static inline float vmathQGetW( const VmathQuat *quat ); + +/* + * Set an x, y, z, or w element of a quaternion by index + */ +static inline void vmathQSetElem( VmathQuat *result, int idx, float value ); + +/* + * Get an x, y, z, or w element of a quaternion by index + */ +static inline float vmathQGetElem( const VmathQuat *quat, int idx ); + +/* + * Add two quaternions + */ +static inline void vmathQAdd( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ); + +/* + * Subtract a quaternion from another quaternion + */ +static inline void vmathQSub( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ); + +/* + * Multiply two quaternions + */ +static inline void vmathQMul( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ); + +/* + * Multiply a quaternion by a scalar + */ +static inline void vmathQScalarMul( VmathQuat *result, const VmathQuat *quat, float scalar ); + +/* + * Divide a quaternion by a scalar + */ +static inline void vmathQScalarDiv( VmathQuat *result, const VmathQuat *quat, float scalar ); + +/* + * Negate all elements of a quaternion + */ +static inline void vmathQNeg( VmathQuat *result, const VmathQuat *quat ); + +/* + * Construct an identity quaternion + */ +static inline void vmathQMakeIdentity( VmathQuat *result ); + +/* + * Construct a quaternion to rotate between two unit-length 3-D vectors + * NOTE: + * The result is unpredictable if unitVec0 and unitVec1 point in opposite directions. + */ +static inline void vmathQMakeRotationArc( VmathQuat *result, const VmathVector3 *unitVec0, const VmathVector3 *unitVec1 ); + +/* + * Construct a quaternion to rotate around a unit-length 3-D vector + */ +static inline void vmathQMakeRotationAxis( VmathQuat *result, float radians, const VmathVector3 *unitVec ); + +/* + * Construct a quaternion to rotate around the x axis + */ +static inline void vmathQMakeRotationX( VmathQuat *result, float radians ); + +/* + * Construct a quaternion to rotate around the y axis + */ +static inline void vmathQMakeRotationY( VmathQuat *result, float radians ); + +/* + * Construct a quaternion to rotate around the z axis + */ +static inline void vmathQMakeRotationZ( VmathQuat *result, float radians ); + +/* + * Compute the conjugate of a quaternion + */ +static inline void vmathQConj( VmathQuat *result, const VmathQuat *quat ); + +/* + * Use a unit-length quaternion to rotate a 3-D vector + */ +static inline void vmathQRotate( VmathVector3 *result, const VmathQuat *unitQuat, const VmathVector3 *vec ); + +/* + * Compute the dot product of two quaternions + */ +static inline float vmathQDot( const VmathQuat *quat0, const VmathQuat *quat1 ); + +/* + * Compute the norm of a quaternion + */ +static inline float vmathQNorm( const VmathQuat *quat ); + +/* + * Compute the length of a quaternion + */ +static inline float vmathQLength( const VmathQuat *quat ); + +/* + * Normalize a quaternion + * NOTE: + * The result is unpredictable when all elements of quat are at or near zero. + */ +static inline void vmathQNormalize( VmathQuat *result, const VmathQuat *quat ); + +/* + * Linear interpolation between two quaternions + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline void vmathQLerp( VmathQuat *result, float t, const VmathQuat *quat0, const VmathQuat *quat1 ); + +/* + * Spherical linear interpolation between two quaternions + * NOTE: + * Interpolates along the shortest path between orientations. + * Does not clamp t between 0 and 1. + */ +static inline void vmathQSlerp( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1 ); + +/* + * Spherical quadrangle interpolation + */ +static inline void vmathQSquad( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1, const VmathQuat *unitQuat2, const VmathQuat *unitQuat3 ); + +/* + * Conditionally select between two quaternions + */ +static inline void vmathQSelect( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1, unsigned int select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a quaternion + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathQPrint( const VmathQuat *quat ); + +/* + * Print a quaternion and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathQPrints( const VmathQuat *quat, const char *name ); + +#endif + +/* + * Copy a 3x3 matrix + */ +static inline void vmathM3Copy( VmathMatrix3 *result, const VmathMatrix3 *mat ); + +/* + * Construct a 3x3 matrix containing the specified columns + */ +static inline void vmathM3MakeFromCols( VmathMatrix3 *result, const VmathVector3 *col0, const VmathVector3 *col1, const VmathVector3 *col2 ); + +/* + * Construct a 3x3 rotation matrix from a unit-length quaternion + */ +static inline void vmathM3MakeFromQ( VmathMatrix3 *result, const VmathQuat *unitQuat ); + +/* + * Set all elements of a 3x3 matrix to the same scalar value + */ +static inline void vmathM3MakeFromScalar( VmathMatrix3 *result, float scalar ); + +/* + * Set column 0 of a 3x3 matrix + */ +static inline void vmathM3SetCol0( VmathMatrix3 *result, const VmathVector3 *col0 ); + +/* + * Set column 1 of a 3x3 matrix + */ +static inline void vmathM3SetCol1( VmathMatrix3 *result, const VmathVector3 *col1 ); + +/* + * Set column 2 of a 3x3 matrix + */ +static inline void vmathM3SetCol2( VmathMatrix3 *result, const VmathVector3 *col2 ); + +/* + * Get column 0 of a 3x3 matrix + */ +static inline void vmathM3GetCol0( VmathVector3 *result, const VmathMatrix3 *mat ); + +/* + * Get column 1 of a 3x3 matrix + */ +static inline void vmathM3GetCol1( VmathVector3 *result, const VmathMatrix3 *mat ); + +/* + * Get column 2 of a 3x3 matrix + */ +static inline void vmathM3GetCol2( VmathVector3 *result, const VmathMatrix3 *mat ); + +/* + * Set the column of a 3x3 matrix referred to by the specified index + */ +static inline void vmathM3SetCol( VmathMatrix3 *result, int col, const VmathVector3 *vec ); + +/* + * Set the row of a 3x3 matrix referred to by the specified index + */ +static inline void vmathM3SetRow( VmathMatrix3 *result, int row, const VmathVector3 *vec ); + +/* + * Get the column of a 3x3 matrix referred to by the specified index + */ +static inline void vmathM3GetCol( VmathVector3 *result, const VmathMatrix3 *mat, int col ); + +/* + * Get the row of a 3x3 matrix referred to by the specified index + */ +static inline void vmathM3GetRow( VmathVector3 *result, const VmathMatrix3 *mat, int row ); + +/* + * Set the element of a 3x3 matrix referred to by column and row indices + */ +static inline void vmathM3SetElem( VmathMatrix3 *result, int col, int row, float val ); + +/* + * Get the element of a 3x3 matrix referred to by column and row indices + */ +static inline float vmathM3GetElem( const VmathMatrix3 *mat, int col, int row ); + +/* + * Add two 3x3 matrices + */ +static inline void vmathM3Add( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ); + +/* + * Subtract a 3x3 matrix from another 3x3 matrix + */ +static inline void vmathM3Sub( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ); + +/* + * Negate all elements of a 3x3 matrix + */ +static inline void vmathM3Neg( VmathMatrix3 *result, const VmathMatrix3 *mat ); + +/* + * Multiply a 3x3 matrix by a scalar + */ +static inline void vmathM3ScalarMul( VmathMatrix3 *result, const VmathMatrix3 *mat, float scalar ); + +/* + * Multiply a 3x3 matrix by a 3-D vector + */ +static inline void vmathM3MulV3( VmathVector3 *result, const VmathMatrix3 *mat, const VmathVector3 *vec ); + +/* + * Multiply two 3x3 matrices + */ +static inline void vmathM3Mul( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ); + +/* + * Construct an identity 3x3 matrix + */ +static inline void vmathM3MakeIdentity( VmathMatrix3 *result ); + +/* + * Construct a 3x3 matrix to rotate around the x axis + */ +static inline void vmathM3MakeRotationX( VmathMatrix3 *result, float radians ); + +/* + * Construct a 3x3 matrix to rotate around the y axis + */ +static inline void vmathM3MakeRotationY( VmathMatrix3 *result, float radians ); + +/* + * Construct a 3x3 matrix to rotate around the z axis + */ +static inline void vmathM3MakeRotationZ( VmathMatrix3 *result, float radians ); + +/* + * Construct a 3x3 matrix to rotate around the x, y, and z axes + */ +static inline void vmathM3MakeRotationZYX( VmathMatrix3 *result, const VmathVector3 *radiansXYZ ); + +/* + * Construct a 3x3 matrix to rotate around a unit-length 3-D vector + */ +static inline void vmathM3MakeRotationAxis( VmathMatrix3 *result, float radians, const VmathVector3 *unitVec ); + +/* + * Construct a rotation matrix from a unit-length quaternion + */ +static inline void vmathM3MakeRotationQ( VmathMatrix3 *result, const VmathQuat *unitQuat ); + +/* + * Construct a 3x3 matrix to perform scaling + */ +static inline void vmathM3MakeScale( VmathMatrix3 *result, const VmathVector3 *scaleVec ); + +/* + * Append (post-multiply) a scale transformation to a 3x3 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline void vmathM3AppendScale( VmathMatrix3 *result, const VmathMatrix3 *mat, const VmathVector3 *scaleVec ); + +/* + * Prepend (pre-multiply) a scale transformation to a 3x3 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline void vmathM3PrependScale( VmathMatrix3 *result, const VmathVector3 *scaleVec, const VmathMatrix3 *mat ); + +/* + * Multiply two 3x3 matrices per element + */ +static inline void vmathM3MulPerElem( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ); + +/* + * Compute the absolute value of a 3x3 matrix per element + */ +static inline void vmathM3AbsPerElem( VmathMatrix3 *result, const VmathMatrix3 *mat ); + +/* + * Transpose of a 3x3 matrix + */ +static inline void vmathM3Transpose( VmathMatrix3 *result, const VmathMatrix3 *mat ); + +/* + * Compute the inverse of a 3x3 matrix + * NOTE: + * Result is unpredictable when the determinant of mat is equal to or near 0. + */ +static inline void vmathM3Inverse( VmathMatrix3 *result, const VmathMatrix3 *mat ); + +/* + * Determinant of a 3x3 matrix + */ +static inline float vmathM3Determinant( const VmathMatrix3 *mat ); + +/* + * Conditionally select between two 3x3 matrices + */ +static inline void vmathM3Select( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1, unsigned int select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3x3 matrix + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathM3Print( const VmathMatrix3 *mat ); + +/* + * Print a 3x3 matrix and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathM3Prints( const VmathMatrix3 *mat, const char *name ); + +#endif + +/* + * Copy a 4x4 matrix + */ +static inline void vmathM4Copy( VmathMatrix4 *result, const VmathMatrix4 *mat ); + +/* + * Construct a 4x4 matrix containing the specified columns + */ +static inline void vmathM4MakeFromCols( VmathMatrix4 *result, const VmathVector4 *col0, const VmathVector4 *col1, const VmathVector4 *col2, const VmathVector4 *col3 ); + +/* + * Construct a 4x4 matrix from a 3x4 transformation matrix + */ +static inline void vmathM4MakeFromT3( VmathMatrix4 *result, const VmathTransform3 *mat ); + +/* + * Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector + */ +static inline void vmathM4MakeFromM3V3( VmathMatrix4 *result, const VmathMatrix3 *mat, const VmathVector3 *translateVec ); + +/* + * Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector + */ +static inline void vmathM4MakeFromQV3( VmathMatrix4 *result, const VmathQuat *unitQuat, const VmathVector3 *translateVec ); + +/* + * Set all elements of a 4x4 matrix to the same scalar value + */ +static inline void vmathM4MakeFromScalar( VmathMatrix4 *result, float scalar ); + +/* + * Set the upper-left 3x3 submatrix + * NOTE: + * This function does not change the bottom row elements. + */ +static inline void vmathM4SetUpper3x3( VmathMatrix4 *result, const VmathMatrix3 *mat3 ); + +/* + * Get the upper-left 3x3 submatrix of a 4x4 matrix + */ +static inline void vmathM4GetUpper3x3( VmathMatrix3 *result, const VmathMatrix4 *mat ); + +/* + * Set translation component + * NOTE: + * This function does not change the bottom row elements. + */ +static inline void vmathM4SetTranslation( VmathMatrix4 *result, const VmathVector3 *translateVec ); + +/* + * Get the translation component of a 4x4 matrix + */ +static inline void vmathM4GetTranslation( VmathVector3 *result, const VmathMatrix4 *mat ); + +/* + * Set column 0 of a 4x4 matrix + */ +static inline void vmathM4SetCol0( VmathMatrix4 *result, const VmathVector4 *col0 ); + +/* + * Set column 1 of a 4x4 matrix + */ +static inline void vmathM4SetCol1( VmathMatrix4 *result, const VmathVector4 *col1 ); + +/* + * Set column 2 of a 4x4 matrix + */ +static inline void vmathM4SetCol2( VmathMatrix4 *result, const VmathVector4 *col2 ); + +/* + * Set column 3 of a 4x4 matrix + */ +static inline void vmathM4SetCol3( VmathMatrix4 *result, const VmathVector4 *col3 ); + +/* + * Get column 0 of a 4x4 matrix + */ +static inline void vmathM4GetCol0( VmathVector4 *result, const VmathMatrix4 *mat ); + +/* + * Get column 1 of a 4x4 matrix + */ +static inline void vmathM4GetCol1( VmathVector4 *result, const VmathMatrix4 *mat ); + +/* + * Get column 2 of a 4x4 matrix + */ +static inline void vmathM4GetCol2( VmathVector4 *result, const VmathMatrix4 *mat ); + +/* + * Get column 3 of a 4x4 matrix + */ +static inline void vmathM4GetCol3( VmathVector4 *result, const VmathMatrix4 *mat ); + +/* + * Set the column of a 4x4 matrix referred to by the specified index + */ +static inline void vmathM4SetCol( VmathMatrix4 *result, int col, const VmathVector4 *vec ); + +/* + * Set the row of a 4x4 matrix referred to by the specified index + */ +static inline void vmathM4SetRow( VmathMatrix4 *result, int row, const VmathVector4 *vec ); + +/* + * Get the column of a 4x4 matrix referred to by the specified index + */ +static inline void vmathM4GetCol( VmathVector4 *result, const VmathMatrix4 *mat, int col ); + +/* + * Get the row of a 4x4 matrix referred to by the specified index + */ +static inline void vmathM4GetRow( VmathVector4 *result, const VmathMatrix4 *mat, int row ); + +/* + * Set the element of a 4x4 matrix referred to by column and row indices + */ +static inline void vmathM4SetElem( VmathMatrix4 *result, int col, int row, float val ); + +/* + * Get the element of a 4x4 matrix referred to by column and row indices + */ +static inline float vmathM4GetElem( const VmathMatrix4 *mat, int col, int row ); + +/* + * Add two 4x4 matrices + */ +static inline void vmathM4Add( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ); + +/* + * Subtract a 4x4 matrix from another 4x4 matrix + */ +static inline void vmathM4Sub( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ); + +/* + * Negate all elements of a 4x4 matrix + */ +static inline void vmathM4Neg( VmathMatrix4 *result, const VmathMatrix4 *mat ); + +/* + * Multiply a 4x4 matrix by a scalar + */ +static inline void vmathM4ScalarMul( VmathMatrix4 *result, const VmathMatrix4 *mat, float scalar ); + +/* + * Multiply a 4x4 matrix by a 4-D vector + */ +static inline void vmathM4MulV4( VmathVector4 *result, const VmathMatrix4 *mat, const VmathVector4 *vec ); + +/* + * Multiply a 4x4 matrix by a 3-D vector + */ +static inline void vmathM4MulV3( VmathVector4 *result, const VmathMatrix4 *mat, const VmathVector3 *vec ); + +/* + * Multiply a 4x4 matrix by a 3-D point + */ +static inline void vmathM4MulP3( VmathVector4 *result, const VmathMatrix4 *mat, const VmathPoint3 *pnt ); + +/* + * Multiply two 4x4 matrices + */ +static inline void vmathM4Mul( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ); + +/* + * Multiply a 4x4 matrix by a 3x4 transformation matrix + */ +static inline void vmathM4MulT3( VmathMatrix4 *result, const VmathMatrix4 *mat, const VmathTransform3 *tfrm ); + +/* + * Construct an identity 4x4 matrix + */ +static inline void vmathM4MakeIdentity( VmathMatrix4 *result ); + +/* + * Construct a 4x4 matrix to rotate around the x axis + */ +static inline void vmathM4MakeRotationX( VmathMatrix4 *result, float radians ); + +/* + * Construct a 4x4 matrix to rotate around the y axis + */ +static inline void vmathM4MakeRotationY( VmathMatrix4 *result, float radians ); + +/* + * Construct a 4x4 matrix to rotate around the z axis + */ +static inline void vmathM4MakeRotationZ( VmathMatrix4 *result, float radians ); + +/* + * Construct a 4x4 matrix to rotate around the x, y, and z axes + */ +static inline void vmathM4MakeRotationZYX( VmathMatrix4 *result, const VmathVector3 *radiansXYZ ); + +/* + * Construct a 4x4 matrix to rotate around a unit-length 3-D vector + */ +static inline void vmathM4MakeRotationAxis( VmathMatrix4 *result, float radians, const VmathVector3 *unitVec ); + +/* + * Construct a rotation matrix from a unit-length quaternion + */ +static inline void vmathM4MakeRotationQ( VmathMatrix4 *result, const VmathQuat *unitQuat ); + +/* + * Construct a 4x4 matrix to perform scaling + */ +static inline void vmathM4MakeScale( VmathMatrix4 *result, const VmathVector3 *scaleVec ); + +/* + * Construct a 4x4 matrix to perform translation + */ +static inline void vmathM4MakeTranslation( VmathMatrix4 *result, const VmathVector3 *translateVec ); + +/* + * Construct viewing matrix based on eye position, position looked at, and up direction + */ +static inline void vmathM4MakeLookAt( VmathMatrix4 *result, const VmathPoint3 *eyePos, const VmathPoint3 *lookAtPos, const VmathVector3 *upVec ); + +/* + * Construct a perspective projection matrix + */ +static inline void vmathM4MakePerspective( VmathMatrix4 *result, float fovyRadians, float aspect, float zNear, float zFar ); + +/* + * Construct a perspective projection matrix based on frustum + */ +static inline void vmathM4MakeFrustum( VmathMatrix4 *result, float left, float right, float bottom, float top, float zNear, float zFar ); + +/* + * Construct an orthographic projection matrix + */ +static inline void vmathM4MakeOrthographic( VmathMatrix4 *result, float left, float right, float bottom, float top, float zNear, float zFar ); + +/* + * Append (post-multiply) a scale transformation to a 4x4 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline void vmathM4AppendScale( VmathMatrix4 *result, const VmathMatrix4 *mat, const VmathVector3 *scaleVec ); + +/* + * Prepend (pre-multiply) a scale transformation to a 4x4 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline void vmathM4PrependScale( VmathMatrix4 *result, const VmathVector3 *scaleVec, const VmathMatrix4 *mat ); + +/* + * Multiply two 4x4 matrices per element + */ +static inline void vmathM4MulPerElem( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ); + +/* + * Compute the absolute value of a 4x4 matrix per element + */ +static inline void vmathM4AbsPerElem( VmathMatrix4 *result, const VmathMatrix4 *mat ); + +/* + * Transpose of a 4x4 matrix + */ +static inline void vmathM4Transpose( VmathMatrix4 *result, const VmathMatrix4 *mat ); + +/* + * Compute the inverse of a 4x4 matrix + * NOTE: + * Result is unpredictable when the determinant of mat is equal to or near 0. + */ +static inline void vmathM4Inverse( VmathMatrix4 *result, const VmathMatrix4 *mat ); + +/* + * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix + * NOTE: + * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. The result is unpredictable when the determinant of mat is equal to or near 0. + */ +static inline void vmathM4AffineInverse( VmathMatrix4 *result, const VmathMatrix4 *mat ); + +/* + * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix + * NOTE: + * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. + */ +static inline void vmathM4OrthoInverse( VmathMatrix4 *result, const VmathMatrix4 *mat ); + +/* + * Determinant of a 4x4 matrix + */ +static inline float vmathM4Determinant( const VmathMatrix4 *mat ); + +/* + * Conditionally select between two 4x4 matrices + */ +static inline void vmathM4Select( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1, unsigned int select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 4x4 matrix + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathM4Print( const VmathMatrix4 *mat ); + +/* + * Print a 4x4 matrix and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathM4Prints( const VmathMatrix4 *mat, const char *name ); + +#endif + +/* + * Copy a 3x4 transformation matrix + */ +static inline void vmathT3Copy( VmathTransform3 *result, const VmathTransform3 *tfrm ); + +/* + * Construct a 3x4 transformation matrix containing the specified columns + */ +static inline void vmathT3MakeFromCols( VmathTransform3 *result, const VmathVector3 *col0, const VmathVector3 *col1, const VmathVector3 *col2, const VmathVector3 *col3 ); + +/* + * Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector + */ +static inline void vmathT3MakeFromM3V3( VmathTransform3 *result, const VmathMatrix3 *tfrm, const VmathVector3 *translateVec ); + +/* + * Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector + */ +static inline void vmathT3MakeFromQV3( VmathTransform3 *result, const VmathQuat *unitQuat, const VmathVector3 *translateVec ); + +/* + * Set all elements of a 3x4 transformation matrix to the same scalar value + */ +static inline void vmathT3MakeFromScalar( VmathTransform3 *result, float scalar ); + +/* + * Set the upper-left 3x3 submatrix + */ +static inline void vmathT3SetUpper3x3( VmathTransform3 *result, const VmathMatrix3 *mat3 ); + +/* + * Get the upper-left 3x3 submatrix of a 3x4 transformation matrix + */ +static inline void vmathT3GetUpper3x3( VmathMatrix3 *result, const VmathTransform3 *tfrm ); + +/* + * Set translation component + */ +static inline void vmathT3SetTranslation( VmathTransform3 *result, const VmathVector3 *translateVec ); + +/* + * Get the translation component of a 3x4 transformation matrix + */ +static inline void vmathT3GetTranslation( VmathVector3 *result, const VmathTransform3 *tfrm ); + +/* + * Set column 0 of a 3x4 transformation matrix + */ +static inline void vmathT3SetCol0( VmathTransform3 *result, const VmathVector3 *col0 ); + +/* + * Set column 1 of a 3x4 transformation matrix + */ +static inline void vmathT3SetCol1( VmathTransform3 *result, const VmathVector3 *col1 ); + +/* + * Set column 2 of a 3x4 transformation matrix + */ +static inline void vmathT3SetCol2( VmathTransform3 *result, const VmathVector3 *col2 ); + +/* + * Set column 3 of a 3x4 transformation matrix + */ +static inline void vmathT3SetCol3( VmathTransform3 *result, const VmathVector3 *col3 ); + +/* + * Get column 0 of a 3x4 transformation matrix + */ +static inline void vmathT3GetCol0( VmathVector3 *result, const VmathTransform3 *tfrm ); + +/* + * Get column 1 of a 3x4 transformation matrix + */ +static inline void vmathT3GetCol1( VmathVector3 *result, const VmathTransform3 *tfrm ); + +/* + * Get column 2 of a 3x4 transformation matrix + */ +static inline void vmathT3GetCol2( VmathVector3 *result, const VmathTransform3 *tfrm ); + +/* + * Get column 3 of a 3x4 transformation matrix + */ +static inline void vmathT3GetCol3( VmathVector3 *result, const VmathTransform3 *tfrm ); + +/* + * Set the column of a 3x4 transformation matrix referred to by the specified index + */ +static inline void vmathT3SetCol( VmathTransform3 *result, int col, const VmathVector3 *vec ); + +/* + * Set the row of a 3x4 transformation matrix referred to by the specified index + */ +static inline void vmathT3SetRow( VmathTransform3 *result, int row, const VmathVector4 *vec ); + +/* + * Get the column of a 3x4 transformation matrix referred to by the specified index + */ +static inline void vmathT3GetCol( VmathVector3 *result, const VmathTransform3 *tfrm, int col ); + +/* + * Get the row of a 3x4 transformation matrix referred to by the specified index + */ +static inline void vmathT3GetRow( VmathVector4 *result, const VmathTransform3 *tfrm, int row ); + +/* + * Set the element of a 3x4 transformation matrix referred to by column and row indices + */ +static inline void vmathT3SetElem( VmathTransform3 *result, int col, int row, float val ); + +/* + * Get the element of a 3x4 transformation matrix referred to by column and row indices + */ +static inline float vmathT3GetElem( const VmathTransform3 *tfrm, int col, int row ); + +/* + * Multiply a 3x4 transformation matrix by a 3-D vector + */ +static inline void vmathT3MulV3( VmathVector3 *result, const VmathTransform3 *tfrm, const VmathVector3 *vec ); + +/* + * Multiply a 3x4 transformation matrix by a 3-D point + */ +static inline void vmathT3MulP3( VmathPoint3 *result, const VmathTransform3 *tfrm, const VmathPoint3 *pnt ); + +/* + * Multiply two 3x4 transformation matrices + */ +static inline void vmathT3Mul( VmathTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1 ); + +/* + * Construct an identity 3x4 transformation matrix + */ +static inline void vmathT3MakeIdentity( VmathTransform3 *result ); + +/* + * Construct a 3x4 transformation matrix to rotate around the x axis + */ +static inline void vmathT3MakeRotationX( VmathTransform3 *result, float radians ); + +/* + * Construct a 3x4 transformation matrix to rotate around the y axis + */ +static inline void vmathT3MakeRotationY( VmathTransform3 *result, float radians ); + +/* + * Construct a 3x4 transformation matrix to rotate around the z axis + */ +static inline void vmathT3MakeRotationZ( VmathTransform3 *result, float radians ); + +/* + * Construct a 3x4 transformation matrix to rotate around the x, y, and z axes + */ +static inline void vmathT3MakeRotationZYX( VmathTransform3 *result, const VmathVector3 *radiansXYZ ); + +/* + * Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector + */ +static inline void vmathT3MakeRotationAxis( VmathTransform3 *result, float radians, const VmathVector3 *unitVec ); + +/* + * Construct a rotation matrix from a unit-length quaternion + */ +static inline void vmathT3MakeRotationQ( VmathTransform3 *result, const VmathQuat *unitQuat ); + +/* + * Construct a 3x4 transformation matrix to perform scaling + */ +static inline void vmathT3MakeScale( VmathTransform3 *result, const VmathVector3 *scaleVec ); + +/* + * Construct a 3x4 transformation matrix to perform translation + */ +static inline void vmathT3MakeTranslation( VmathTransform3 *result, const VmathVector3 *translateVec ); + +/* + * Append (post-multiply) a scale transformation to a 3x4 transformation matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline void vmathT3AppendScale( VmathTransform3 *result, const VmathTransform3 *tfrm, const VmathVector3 *scaleVec ); + +/* + * Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline void vmathT3PrependScale( VmathTransform3 *result, const VmathVector3 *scaleVec, const VmathTransform3 *tfrm ); + +/* + * Multiply two 3x4 transformation matrices per element + */ +static inline void vmathT3MulPerElem( VmathTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1 ); + +/* + * Compute the absolute value of a 3x4 transformation matrix per element + */ +static inline void vmathT3AbsPerElem( VmathTransform3 *result, const VmathTransform3 *tfrm ); + +/* + * Inverse of a 3x4 transformation matrix + * NOTE: + * Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0. + */ +static inline void vmathT3Inverse( VmathTransform3 *result, const VmathTransform3 *tfrm ); + +/* + * Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix + * NOTE: + * This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions. + */ +static inline void vmathT3OrthoInverse( VmathTransform3 *result, const VmathTransform3 *tfrm ); + +/* + * Conditionally select between two 3x4 transformation matrices + */ +static inline void vmathT3Select( VmathTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1, unsigned int select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3x4 transformation matrix + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathT3Print( const VmathTransform3 *tfrm ); + +/* + * Print a 3x4 transformation matrix and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathT3Prints( const VmathTransform3 *tfrm, const char *name ); + +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include "vec_aos.h" +#include "quat_aos.h" +#include "mat_aos.h" + +#endif diff --git a/vectormathlibrary/include/vectormath/scalar/c/vectormath_aos_v.h b/vectormathlibrary/include/vectormath/scalar/c/vectormath_aos_v.h new file mode 100644 index 000000000..f766bb148 --- /dev/null +++ b/vectormathlibrary/include/vectormath/scalar/c/vectormath_aos_v.h @@ -0,0 +1,1845 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_AOS_C_V_SCALAR_H +#define _VECTORMATH_AOS_C_V_SCALAR_H + +#include <math.h> + +#ifdef _VECTORMATH_DEBUG +#include <stdio.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#ifndef _VECTORMATH_AOS_C_TYPES_H +#define _VECTORMATH_AOS_C_TYPES_H + +/* A 3-D vector in array-of-structures format + */ +typedef struct _VmathVector3 +{ + float x; + float y; + float z; +#ifndef __GNUC__ + float d; +#endif +} +#ifdef __GNUC__ +__attribute__ ((aligned(16))) +#endif +VmathVector3; + +/* A 4-D vector in array-of-structures format + */ +typedef struct _VmathVector4 +{ + float x; + float y; + float z; + float w; +} +#ifdef __GNUC__ +__attribute__ ((aligned(16))) +#endif +VmathVector4; + +/* A 3-D point in array-of-structures format + */ +typedef struct _VmathPoint3 +{ + float x; + float y; + float z; +#ifndef __GNUC__ + float d; +#endif +} +#ifdef __GNUC__ +__attribute__ ((aligned(16))) +#endif +VmathPoint3; + +/* A quaternion in array-of-structures format + */ +typedef struct _VmathQuat +{ + float x; + float y; + float z; + float w; +} +#ifdef __GNUC__ +__attribute__ ((aligned(16))) +#endif +VmathQuat; + +/* A 3x3 matrix in array-of-structures format + */ +typedef struct _VmathMatrix3 +{ + VmathVector3 col0; + VmathVector3 col1; + VmathVector3 col2; +} VmathMatrix3; + +/* A 4x4 matrix in array-of-structures format + */ +typedef struct _VmathMatrix4 +{ + VmathVector4 col0; + VmathVector4 col1; + VmathVector4 col2; + VmathVector4 col3; +} VmathMatrix4; + +/* A 3x4 transformation matrix in array-of-structures format + */ +typedef struct _VmathTransform3 +{ + VmathVector3 col0; + VmathVector3 col1; + VmathVector3 col2; + VmathVector3 col3; +} VmathTransform3; + +#endif + +/* + * Construct a 3-D vector from x, y, and z elements + */ +static inline VmathVector3 vmathV3MakeFromElems_V( float x, float y, float z ); + +/* + * Copy elements from a 3-D point into a 3-D vector + */ +static inline VmathVector3 vmathV3MakeFromP3_V( VmathPoint3 pnt ); + +/* + * Set all elements of a 3-D vector to the same scalar value + */ +static inline VmathVector3 vmathV3MakeFromScalar_V( float scalar ); + +/* + * Set the x element of a 3-D vector + */ +static inline void vmathV3SetX_V( VmathVector3 *result, float x ); + +/* + * Set the y element of a 3-D vector + */ +static inline void vmathV3SetY_V( VmathVector3 *result, float y ); + +/* + * Set the z element of a 3-D vector + */ +static inline void vmathV3SetZ_V( VmathVector3 *result, float z ); + +/* + * Get the x element of a 3-D vector + */ +static inline float vmathV3GetX_V( VmathVector3 vec ); + +/* + * Get the y element of a 3-D vector + */ +static inline float vmathV3GetY_V( VmathVector3 vec ); + +/* + * Get the z element of a 3-D vector + */ +static inline float vmathV3GetZ_V( VmathVector3 vec ); + +/* + * Set an x, y, or z element of a 3-D vector by index + */ +static inline void vmathV3SetElem_V( VmathVector3 *result, int idx, float value ); + +/* + * Get an x, y, or z element of a 3-D vector by index + */ +static inline float vmathV3GetElem_V( VmathVector3 vec, int idx ); + +/* + * Add two 3-D vectors + */ +static inline VmathVector3 vmathV3Add_V( VmathVector3 vec0, VmathVector3 vec1 ); + +/* + * Subtract a 3-D vector from another 3-D vector + */ +static inline VmathVector3 vmathV3Sub_V( VmathVector3 vec0, VmathVector3 vec1 ); + +/* + * Add a 3-D vector to a 3-D point + */ +static inline VmathPoint3 vmathV3AddP3_V( VmathVector3 vec, VmathPoint3 pnt ); + +/* + * Multiply a 3-D vector by a scalar + */ +static inline VmathVector3 vmathV3ScalarMul_V( VmathVector3 vec, float scalar ); + +/* + * Divide a 3-D vector by a scalar + */ +static inline VmathVector3 vmathV3ScalarDiv_V( VmathVector3 vec, float scalar ); + +/* + * Negate all elements of a 3-D vector + */ +static inline VmathVector3 vmathV3Neg_V( VmathVector3 vec ); + +/* + * Construct x axis + */ +static inline VmathVector3 vmathV3MakeXAxis_V( ); + +/* + * Construct y axis + */ +static inline VmathVector3 vmathV3MakeYAxis_V( ); + +/* + * Construct z axis + */ +static inline VmathVector3 vmathV3MakeZAxis_V( ); + +/* + * Multiply two 3-D vectors per element + */ +static inline VmathVector3 vmathV3MulPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ); + +/* + * Divide two 3-D vectors per element + * NOTE: + * Floating-point behavior matches standard library function divf4. + */ +static inline VmathVector3 vmathV3DivPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ); + +/* + * Compute the reciprocal of a 3-D vector per element + * NOTE: + * Floating-point behavior matches standard library function recipf4. + */ +static inline VmathVector3 vmathV3RecipPerElem_V( VmathVector3 vec ); + +/* + * Compute the square root of a 3-D vector per element + * NOTE: + * Floating-point behavior matches standard library function sqrtf4. + */ +static inline VmathVector3 vmathV3SqrtPerElem_V( VmathVector3 vec ); + +/* + * Compute the reciprocal square root of a 3-D vector per element + * NOTE: + * Floating-point behavior matches standard library function rsqrtf4. + */ +static inline VmathVector3 vmathV3RsqrtPerElem_V( VmathVector3 vec ); + +/* + * Compute the absolute value of a 3-D vector per element + */ +static inline VmathVector3 vmathV3AbsPerElem_V( VmathVector3 vec ); + +/* + * Copy sign from one 3-D vector to another, per element + */ +static inline VmathVector3 vmathV3CopySignPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ); + +/* + * Maximum of two 3-D vectors per element + */ +static inline VmathVector3 vmathV3MaxPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ); + +/* + * Minimum of two 3-D vectors per element + */ +static inline VmathVector3 vmathV3MinPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ); + +/* + * Maximum element of a 3-D vector + */ +static inline float vmathV3MaxElem_V( VmathVector3 vec ); + +/* + * Minimum element of a 3-D vector + */ +static inline float vmathV3MinElem_V( VmathVector3 vec ); + +/* + * Compute the sum of all elements of a 3-D vector + */ +static inline float vmathV3Sum_V( VmathVector3 vec ); + +/* + * Compute the dot product of two 3-D vectors + */ +static inline float vmathV3Dot_V( VmathVector3 vec0, VmathVector3 vec1 ); + +/* + * Compute the square of the length of a 3-D vector + */ +static inline float vmathV3LengthSqr_V( VmathVector3 vec ); + +/* + * Compute the length of a 3-D vector + */ +static inline float vmathV3Length_V( VmathVector3 vec ); + +/* + * Normalize a 3-D vector + * NOTE: + * The result is unpredictable when all elements of vec are at or near zero. + */ +static inline VmathVector3 vmathV3Normalize_V( VmathVector3 vec ); + +/* + * Compute cross product of two 3-D vectors + */ +static inline VmathVector3 vmathV3Cross_V( VmathVector3 vec0, VmathVector3 vec1 ); + +/* + * Outer product of two 3-D vectors + */ +static inline VmathMatrix3 vmathV3Outer_V( VmathVector3 vec0, VmathVector3 vec1 ); + +/* + * Pre-multiply a row vector by a 3x3 matrix + */ +static inline VmathVector3 vmathV3RowMul_V( VmathVector3 vec, VmathMatrix3 mat ); + +/* + * Cross-product matrix of a 3-D vector + */ +static inline VmathMatrix3 vmathV3CrossMatrix_V( VmathVector3 vec ); + +/* + * Create cross-product matrix and multiply + * NOTE: + * Faster than separately creating a cross-product matrix and multiplying. + */ +static inline VmathMatrix3 vmathV3CrossMatrixMul_V( VmathVector3 vec, VmathMatrix3 mat ); + +/* + * Linear interpolation between two 3-D vectors + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline VmathVector3 vmathV3Lerp_V( float t, VmathVector3 vec0, VmathVector3 vec1 ); + +/* + * Spherical linear interpolation between two 3-D vectors + * NOTE: + * The result is unpredictable if the vectors point in opposite directions. + * Does not clamp t between 0 and 1. + */ +static inline VmathVector3 vmathV3Slerp_V( float t, VmathVector3 unitVec0, VmathVector3 unitVec1 ); + +/* + * Conditionally select between two 3-D vectors + */ +static inline VmathVector3 vmathV3Select_V( VmathVector3 vec0, VmathVector3 vec1, unsigned int select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3-D vector + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathV3Print_V( VmathVector3 vec ); + +/* + * Print a 3-D vector and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathV3Prints_V( VmathVector3 vec, const char *name ); + +#endif + +/* + * Construct a 4-D vector from x, y, z, and w elements + */ +static inline VmathVector4 vmathV4MakeFromElems_V( float x, float y, float z, float w ); + +/* + * Construct a 4-D vector from a 3-D vector and a scalar + */ +static inline VmathVector4 vmathV4MakeFromV3Scalar_V( VmathVector3 xyz, float w ); + +/* + * Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0 + */ +static inline VmathVector4 vmathV4MakeFromV3_V( VmathVector3 vec ); + +/* + * Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1 + */ +static inline VmathVector4 vmathV4MakeFromP3_V( VmathPoint3 pnt ); + +/* + * Copy elements from a quaternion into a 4-D vector + */ +static inline VmathVector4 vmathV4MakeFromQ_V( VmathQuat quat ); + +/* + * Set all elements of a 4-D vector to the same scalar value + */ +static inline VmathVector4 vmathV4MakeFromScalar_V( float scalar ); + +/* + * Set the x, y, and z elements of a 4-D vector + * NOTE: + * This function does not change the w element. + */ +static inline void vmathV4SetXYZ_V( VmathVector4 *result, VmathVector3 vec ); + +/* + * Get the x, y, and z elements of a 4-D vector + */ +static inline VmathVector3 vmathV4GetXYZ_V( VmathVector4 vec ); + +/* + * Set the x element of a 4-D vector + */ +static inline void vmathV4SetX_V( VmathVector4 *result, float x ); + +/* + * Set the y element of a 4-D vector + */ +static inline void vmathV4SetY_V( VmathVector4 *result, float y ); + +/* + * Set the z element of a 4-D vector + */ +static inline void vmathV4SetZ_V( VmathVector4 *result, float z ); + +/* + * Set the w element of a 4-D vector + */ +static inline void vmathV4SetW_V( VmathVector4 *result, float w ); + +/* + * Get the x element of a 4-D vector + */ +static inline float vmathV4GetX_V( VmathVector4 vec ); + +/* + * Get the y element of a 4-D vector + */ +static inline float vmathV4GetY_V( VmathVector4 vec ); + +/* + * Get the z element of a 4-D vector + */ +static inline float vmathV4GetZ_V( VmathVector4 vec ); + +/* + * Get the w element of a 4-D vector + */ +static inline float vmathV4GetW_V( VmathVector4 vec ); + +/* + * Set an x, y, z, or w element of a 4-D vector by index + */ +static inline void vmathV4SetElem_V( VmathVector4 *result, int idx, float value ); + +/* + * Get an x, y, z, or w element of a 4-D vector by index + */ +static inline float vmathV4GetElem_V( VmathVector4 vec, int idx ); + +/* + * Add two 4-D vectors + */ +static inline VmathVector4 vmathV4Add_V( VmathVector4 vec0, VmathVector4 vec1 ); + +/* + * Subtract a 4-D vector from another 4-D vector + */ +static inline VmathVector4 vmathV4Sub_V( VmathVector4 vec0, VmathVector4 vec1 ); + +/* + * Multiply a 4-D vector by a scalar + */ +static inline VmathVector4 vmathV4ScalarMul_V( VmathVector4 vec, float scalar ); + +/* + * Divide a 4-D vector by a scalar + */ +static inline VmathVector4 vmathV4ScalarDiv_V( VmathVector4 vec, float scalar ); + +/* + * Negate all elements of a 4-D vector + */ +static inline VmathVector4 vmathV4Neg_V( VmathVector4 vec ); + +/* + * Construct x axis + */ +static inline VmathVector4 vmathV4MakeXAxis_V( ); + +/* + * Construct y axis + */ +static inline VmathVector4 vmathV4MakeYAxis_V( ); + +/* + * Construct z axis + */ +static inline VmathVector4 vmathV4MakeZAxis_V( ); + +/* + * Construct w axis + */ +static inline VmathVector4 vmathV4MakeWAxis_V( ); + +/* + * Multiply two 4-D vectors per element + */ +static inline VmathVector4 vmathV4MulPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ); + +/* + * Divide two 4-D vectors per element + * NOTE: + * Floating-point behavior matches standard library function divf4. + */ +static inline VmathVector4 vmathV4DivPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ); + +/* + * Compute the reciprocal of a 4-D vector per element + * NOTE: + * Floating-point behavior matches standard library function recipf4. + */ +static inline VmathVector4 vmathV4RecipPerElem_V( VmathVector4 vec ); + +/* + * Compute the square root of a 4-D vector per element + * NOTE: + * Floating-point behavior matches standard library function sqrtf4. + */ +static inline VmathVector4 vmathV4SqrtPerElem_V( VmathVector4 vec ); + +/* + * Compute the reciprocal square root of a 4-D vector per element + * NOTE: + * Floating-point behavior matches standard library function rsqrtf4. + */ +static inline VmathVector4 vmathV4RsqrtPerElem_V( VmathVector4 vec ); + +/* + * Compute the absolute value of a 4-D vector per element + */ +static inline VmathVector4 vmathV4AbsPerElem_V( VmathVector4 vec ); + +/* + * Copy sign from one 4-D vector to another, per element + */ +static inline VmathVector4 vmathV4CopySignPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ); + +/* + * Maximum of two 4-D vectors per element + */ +static inline VmathVector4 vmathV4MaxPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ); + +/* + * Minimum of two 4-D vectors per element + */ +static inline VmathVector4 vmathV4MinPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ); + +/* + * Maximum element of a 4-D vector + */ +static inline float vmathV4MaxElem_V( VmathVector4 vec ); + +/* + * Minimum element of a 4-D vector + */ +static inline float vmathV4MinElem_V( VmathVector4 vec ); + +/* + * Compute the sum of all elements of a 4-D vector + */ +static inline float vmathV4Sum_V( VmathVector4 vec ); + +/* + * Compute the dot product of two 4-D vectors + */ +static inline float vmathV4Dot_V( VmathVector4 vec0, VmathVector4 vec1 ); + +/* + * Compute the square of the length of a 4-D vector + */ +static inline float vmathV4LengthSqr_V( VmathVector4 vec ); + +/* + * Compute the length of a 4-D vector + */ +static inline float vmathV4Length_V( VmathVector4 vec ); + +/* + * Normalize a 4-D vector + * NOTE: + * The result is unpredictable when all elements of vec are at or near zero. + */ +static inline VmathVector4 vmathV4Normalize_V( VmathVector4 vec ); + +/* + * Outer product of two 4-D vectors + */ +static inline VmathMatrix4 vmathV4Outer_V( VmathVector4 vec0, VmathVector4 vec1 ); + +/* + * Linear interpolation between two 4-D vectors + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline VmathVector4 vmathV4Lerp_V( float t, VmathVector4 vec0, VmathVector4 vec1 ); + +/* + * Spherical linear interpolation between two 4-D vectors + * NOTE: + * The result is unpredictable if the vectors point in opposite directions. + * Does not clamp t between 0 and 1. + */ +static inline VmathVector4 vmathV4Slerp_V( float t, VmathVector4 unitVec0, VmathVector4 unitVec1 ); + +/* + * Conditionally select between two 4-D vectors + */ +static inline VmathVector4 vmathV4Select_V( VmathVector4 vec0, VmathVector4 vec1, unsigned int select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 4-D vector + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathV4Print_V( VmathVector4 vec ); + +/* + * Print a 4-D vector and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathV4Prints_V( VmathVector4 vec, const char *name ); + +#endif + +/* + * Construct a 3-D point from x, y, and z elements + */ +static inline VmathPoint3 vmathP3MakeFromElems_V( float x, float y, float z ); + +/* + * Copy elements from a 3-D vector into a 3-D point + */ +static inline VmathPoint3 vmathP3MakeFromV3_V( VmathVector3 vec ); + +/* + * Set all elements of a 3-D point to the same scalar value + */ +static inline VmathPoint3 vmathP3MakeFromScalar_V( float scalar ); + +/* + * Set the x element of a 3-D point + */ +static inline void vmathP3SetX_V( VmathPoint3 *result, float x ); + +/* + * Set the y element of a 3-D point + */ +static inline void vmathP3SetY_V( VmathPoint3 *result, float y ); + +/* + * Set the z element of a 3-D point + */ +static inline void vmathP3SetZ_V( VmathPoint3 *result, float z ); + +/* + * Get the x element of a 3-D point + */ +static inline float vmathP3GetX_V( VmathPoint3 pnt ); + +/* + * Get the y element of a 3-D point + */ +static inline float vmathP3GetY_V( VmathPoint3 pnt ); + +/* + * Get the z element of a 3-D point + */ +static inline float vmathP3GetZ_V( VmathPoint3 pnt ); + +/* + * Set an x, y, or z element of a 3-D point by index + */ +static inline void vmathP3SetElem_V( VmathPoint3 *result, int idx, float value ); + +/* + * Get an x, y, or z element of a 3-D point by index + */ +static inline float vmathP3GetElem_V( VmathPoint3 pnt, int idx ); + +/* + * Subtract a 3-D point from another 3-D point + */ +static inline VmathVector3 vmathP3Sub_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); + +/* + * Add a 3-D point to a 3-D vector + */ +static inline VmathPoint3 vmathP3AddV3_V( VmathPoint3 pnt, VmathVector3 vec ); + +/* + * Subtract a 3-D vector from a 3-D point + */ +static inline VmathPoint3 vmathP3SubV3_V( VmathPoint3 pnt, VmathVector3 vec ); + +/* + * Multiply two 3-D points per element + */ +static inline VmathPoint3 vmathP3MulPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); + +/* + * Divide two 3-D points per element + * NOTE: + * Floating-point behavior matches standard library function divf4. + */ +static inline VmathPoint3 vmathP3DivPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); + +/* + * Compute the reciprocal of a 3-D point per element + * NOTE: + * Floating-point behavior matches standard library function recipf4. + */ +static inline VmathPoint3 vmathP3RecipPerElem_V( VmathPoint3 pnt ); + +/* + * Compute the square root of a 3-D point per element + * NOTE: + * Floating-point behavior matches standard library function sqrtf4. + */ +static inline VmathPoint3 vmathP3SqrtPerElem_V( VmathPoint3 pnt ); + +/* + * Compute the reciprocal square root of a 3-D point per element + * NOTE: + * Floating-point behavior matches standard library function rsqrtf4. + */ +static inline VmathPoint3 vmathP3RsqrtPerElem_V( VmathPoint3 pnt ); + +/* + * Compute the absolute value of a 3-D point per element + */ +static inline VmathPoint3 vmathP3AbsPerElem_V( VmathPoint3 pnt ); + +/* + * Copy sign from one 3-D point to another, per element + */ +static inline VmathPoint3 vmathP3CopySignPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); + +/* + * Maximum of two 3-D points per element + */ +static inline VmathPoint3 vmathP3MaxPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); + +/* + * Minimum of two 3-D points per element + */ +static inline VmathPoint3 vmathP3MinPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); + +/* + * Maximum element of a 3-D point + */ +static inline float vmathP3MaxElem_V( VmathPoint3 pnt ); + +/* + * Minimum element of a 3-D point + */ +static inline float vmathP3MinElem_V( VmathPoint3 pnt ); + +/* + * Compute the sum of all elements of a 3-D point + */ +static inline float vmathP3Sum_V( VmathPoint3 pnt ); + +/* + * Apply uniform scale to a 3-D point + */ +static inline VmathPoint3 vmathP3Scale_V( VmathPoint3 pnt, float scaleVal ); + +/* + * Apply non-uniform scale to a 3-D point + */ +static inline VmathPoint3 vmathP3NonUniformScale_V( VmathPoint3 pnt, VmathVector3 scaleVec ); + +/* + * Scalar projection of a 3-D point on a unit-length 3-D vector + */ +static inline float vmathP3Projection_V( VmathPoint3 pnt, VmathVector3 unitVec ); + +/* + * Compute the square of the distance of a 3-D point from the coordinate-system origin + */ +static inline float vmathP3DistSqrFromOrigin_V( VmathPoint3 pnt ); + +/* + * Compute the distance of a 3-D point from the coordinate-system origin + */ +static inline float vmathP3DistFromOrigin_V( VmathPoint3 pnt ); + +/* + * Compute the square of the distance between two 3-D points + */ +static inline float vmathP3DistSqr_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); + +/* + * Compute the distance between two 3-D points + */ +static inline float vmathP3Dist_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); + +/* + * Linear interpolation between two 3-D points + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline VmathPoint3 vmathP3Lerp_V( float t, VmathPoint3 pnt0, VmathPoint3 pnt1 ); + +/* + * Conditionally select between two 3-D points + */ +static inline VmathPoint3 vmathP3Select_V( VmathPoint3 pnt0, VmathPoint3 pnt1, unsigned int select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3-D point + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathP3Print_V( VmathPoint3 pnt ); + +/* + * Print a 3-D point and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathP3Prints_V( VmathPoint3 pnt, const char *name ); + +#endif + +/* + * Construct a quaternion from x, y, z, and w elements + */ +static inline VmathQuat vmathQMakeFromElems_V( float x, float y, float z, float w ); + +/* + * Construct a quaternion from a 3-D vector and a scalar + */ +static inline VmathQuat vmathQMakeFromV3Scalar_V( VmathVector3 xyz, float w ); + +/* + * Copy elements from a 4-D vector into a quaternion + */ +static inline VmathQuat vmathQMakeFromV4_V( VmathVector4 vec ); + +/* + * Convert a rotation matrix to a unit-length quaternion + */ +static inline VmathQuat vmathQMakeFromM3_V( VmathMatrix3 rotMat ); + +/* + * Set all elements of a quaternion to the same scalar value + */ +static inline VmathQuat vmathQMakeFromScalar_V( float scalar ); + +/* + * Set the x, y, and z elements of a quaternion + * NOTE: + * This function does not change the w element. + */ +static inline void vmathQSetXYZ_V( VmathQuat *result, VmathVector3 vec ); + +/* + * Get the x, y, and z elements of a quaternion + */ +static inline VmathVector3 vmathQGetXYZ_V( VmathQuat quat ); + +/* + * Set the x element of a quaternion + */ +static inline void vmathQSetX_V( VmathQuat *result, float x ); + +/* + * Set the y element of a quaternion + */ +static inline void vmathQSetY_V( VmathQuat *result, float y ); + +/* + * Set the z element of a quaternion + */ +static inline void vmathQSetZ_V( VmathQuat *result, float z ); + +/* + * Set the w element of a quaternion + */ +static inline void vmathQSetW_V( VmathQuat *result, float w ); + +/* + * Get the x element of a quaternion + */ +static inline float vmathQGetX_V( VmathQuat quat ); + +/* + * Get the y element of a quaternion + */ +static inline float vmathQGetY_V( VmathQuat quat ); + +/* + * Get the z element of a quaternion + */ +static inline float vmathQGetZ_V( VmathQuat quat ); + +/* + * Get the w element of a quaternion + */ +static inline float vmathQGetW_V( VmathQuat quat ); + +/* + * Set an x, y, z, or w element of a quaternion by index + */ +static inline void vmathQSetElem_V( VmathQuat *result, int idx, float value ); + +/* + * Get an x, y, z, or w element of a quaternion by index + */ +static inline float vmathQGetElem_V( VmathQuat quat, int idx ); + +/* + * Add two quaternions + */ +static inline VmathQuat vmathQAdd_V( VmathQuat quat0, VmathQuat quat1 ); + +/* + * Subtract a quaternion from another quaternion + */ +static inline VmathQuat vmathQSub_V( VmathQuat quat0, VmathQuat quat1 ); + +/* + * Multiply two quaternions + */ +static inline VmathQuat vmathQMul_V( VmathQuat quat0, VmathQuat quat1 ); + +/* + * Multiply a quaternion by a scalar + */ +static inline VmathQuat vmathQScalarMul_V( VmathQuat quat, float scalar ); + +/* + * Divide a quaternion by a scalar + */ +static inline VmathQuat vmathQScalarDiv_V( VmathQuat quat, float scalar ); + +/* + * Negate all elements of a quaternion + */ +static inline VmathQuat vmathQNeg_V( VmathQuat quat ); + +/* + * Construct an identity quaternion + */ +static inline VmathQuat vmathQMakeIdentity_V( ); + +/* + * Construct a quaternion to rotate between two unit-length 3-D vectors + * NOTE: + * The result is unpredictable if unitVec0 and unitVec1 point in opposite directions. + */ +static inline VmathQuat vmathQMakeRotationArc_V( VmathVector3 unitVec0, VmathVector3 unitVec1 ); + +/* + * Construct a quaternion to rotate around a unit-length 3-D vector + */ +static inline VmathQuat vmathQMakeRotationAxis_V( float radians, VmathVector3 unitVec ); + +/* + * Construct a quaternion to rotate around the x axis + */ +static inline VmathQuat vmathQMakeRotationX_V( float radians ); + +/* + * Construct a quaternion to rotate around the y axis + */ +static inline VmathQuat vmathQMakeRotationY_V( float radians ); + +/* + * Construct a quaternion to rotate around the z axis + */ +static inline VmathQuat vmathQMakeRotationZ_V( float radians ); + +/* + * Compute the conjugate of a quaternion + */ +static inline VmathQuat vmathQConj_V( VmathQuat quat ); + +/* + * Use a unit-length quaternion to rotate a 3-D vector + */ +static inline VmathVector3 vmathQRotate_V( VmathQuat unitQuat, VmathVector3 vec ); + +/* + * Compute the dot product of two quaternions + */ +static inline float vmathQDot_V( VmathQuat quat0, VmathQuat quat1 ); + +/* + * Compute the norm of a quaternion + */ +static inline float vmathQNorm_V( VmathQuat quat ); + +/* + * Compute the length of a quaternion + */ +static inline float vmathQLength_V( VmathQuat quat ); + +/* + * Normalize a quaternion + * NOTE: + * The result is unpredictable when all elements of quat are at or near zero. + */ +static inline VmathQuat vmathQNormalize_V( VmathQuat quat ); + +/* + * Linear interpolation between two quaternions + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline VmathQuat vmathQLerp_V( float t, VmathQuat quat0, VmathQuat quat1 ); + +/* + * Spherical linear interpolation between two quaternions + * NOTE: + * Interpolates along the shortest path between orientations. + * Does not clamp t between 0 and 1. + */ +static inline VmathQuat vmathQSlerp_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1 ); + +/* + * Spherical quadrangle interpolation + */ +static inline VmathQuat vmathQSquad_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1, VmathQuat unitQuat2, VmathQuat unitQuat3 ); + +/* + * Conditionally select between two quaternions + */ +static inline VmathQuat vmathQSelect_V( VmathQuat quat0, VmathQuat quat1, unsigned int select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a quaternion + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathQPrint_V( VmathQuat quat ); + +/* + * Print a quaternion and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathQPrints_V( VmathQuat quat, const char *name ); + +#endif + +/* + * Construct a 3x3 matrix containing the specified columns + */ +static inline VmathMatrix3 vmathM3MakeFromCols_V( VmathVector3 col0, VmathVector3 col1, VmathVector3 col2 ); + +/* + * Construct a 3x3 rotation matrix from a unit-length quaternion + */ +static inline VmathMatrix3 vmathM3MakeFromQ_V( VmathQuat unitQuat ); + +/* + * Set all elements of a 3x3 matrix to the same scalar value + */ +static inline VmathMatrix3 vmathM3MakeFromScalar_V( float scalar ); + +/* + * Set column 0 of a 3x3 matrix + */ +static inline void vmathM3SetCol0_V( VmathMatrix3 *result, VmathVector3 col0 ); + +/* + * Set column 1 of a 3x3 matrix + */ +static inline void vmathM3SetCol1_V( VmathMatrix3 *result, VmathVector3 col1 ); + +/* + * Set column 2 of a 3x3 matrix + */ +static inline void vmathM3SetCol2_V( VmathMatrix3 *result, VmathVector3 col2 ); + +/* + * Get column 0 of a 3x3 matrix + */ +static inline VmathVector3 vmathM3GetCol0_V( VmathMatrix3 mat ); + +/* + * Get column 1 of a 3x3 matrix + */ +static inline VmathVector3 vmathM3GetCol1_V( VmathMatrix3 mat ); + +/* + * Get column 2 of a 3x3 matrix + */ +static inline VmathVector3 vmathM3GetCol2_V( VmathMatrix3 mat ); + +/* + * Set the column of a 3x3 matrix referred to by the specified index + */ +static inline void vmathM3SetCol_V( VmathMatrix3 *result, int col, VmathVector3 vec ); + +/* + * Set the row of a 3x3 matrix referred to by the specified index + */ +static inline void vmathM3SetRow_V( VmathMatrix3 *result, int row, VmathVector3 vec ); + +/* + * Get the column of a 3x3 matrix referred to by the specified index + */ +static inline VmathVector3 vmathM3GetCol_V( VmathMatrix3 mat, int col ); + +/* + * Get the row of a 3x3 matrix referred to by the specified index + */ +static inline VmathVector3 vmathM3GetRow_V( VmathMatrix3 mat, int row ); + +/* + * Set the element of a 3x3 matrix referred to by column and row indices + */ +static inline void vmathM3SetElem_V( VmathMatrix3 *result, int col, int row, float val ); + +/* + * Get the element of a 3x3 matrix referred to by column and row indices + */ +static inline float vmathM3GetElem_V( VmathMatrix3 mat, int col, int row ); + +/* + * Add two 3x3 matrices + */ +static inline VmathMatrix3 vmathM3Add_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ); + +/* + * Subtract a 3x3 matrix from another 3x3 matrix + */ +static inline VmathMatrix3 vmathM3Sub_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ); + +/* + * Negate all elements of a 3x3 matrix + */ +static inline VmathMatrix3 vmathM3Neg_V( VmathMatrix3 mat ); + +/* + * Multiply a 3x3 matrix by a scalar + */ +static inline VmathMatrix3 vmathM3ScalarMul_V( VmathMatrix3 mat, float scalar ); + +/* + * Multiply a 3x3 matrix by a 3-D vector + */ +static inline VmathVector3 vmathM3MulV3_V( VmathMatrix3 mat, VmathVector3 vec ); + +/* + * Multiply two 3x3 matrices + */ +static inline VmathMatrix3 vmathM3Mul_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ); + +/* + * Construct an identity 3x3 matrix + */ +static inline VmathMatrix3 vmathM3MakeIdentity_V( ); + +/* + * Construct a 3x3 matrix to rotate around the x axis + */ +static inline VmathMatrix3 vmathM3MakeRotationX_V( float radians ); + +/* + * Construct a 3x3 matrix to rotate around the y axis + */ +static inline VmathMatrix3 vmathM3MakeRotationY_V( float radians ); + +/* + * Construct a 3x3 matrix to rotate around the z axis + */ +static inline VmathMatrix3 vmathM3MakeRotationZ_V( float radians ); + +/* + * Construct a 3x3 matrix to rotate around the x, y, and z axes + */ +static inline VmathMatrix3 vmathM3MakeRotationZYX_V( VmathVector3 radiansXYZ ); + +/* + * Construct a 3x3 matrix to rotate around a unit-length 3-D vector + */ +static inline VmathMatrix3 vmathM3MakeRotationAxis_V( float radians, VmathVector3 unitVec ); + +/* + * Construct a rotation matrix from a unit-length quaternion + */ +static inline VmathMatrix3 vmathM3MakeRotationQ_V( VmathQuat unitQuat ); + +/* + * Construct a 3x3 matrix to perform scaling + */ +static inline VmathMatrix3 vmathM3MakeScale_V( VmathVector3 scaleVec ); + +/* + * Append (post-multiply) a scale transformation to a 3x3 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline VmathMatrix3 vmathM3AppendScale_V( VmathMatrix3 mat, VmathVector3 scaleVec ); + +/* + * Prepend (pre-multiply) a scale transformation to a 3x3 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline VmathMatrix3 vmathM3PrependScale_V( VmathVector3 scaleVec, VmathMatrix3 mat ); + +/* + * Multiply two 3x3 matrices per element + */ +static inline VmathMatrix3 vmathM3MulPerElem_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ); + +/* + * Compute the absolute value of a 3x3 matrix per element + */ +static inline VmathMatrix3 vmathM3AbsPerElem_V( VmathMatrix3 mat ); + +/* + * Transpose of a 3x3 matrix + */ +static inline VmathMatrix3 vmathM3Transpose_V( VmathMatrix3 mat ); + +/* + * Compute the inverse of a 3x3 matrix + * NOTE: + * Result is unpredictable when the determinant of mat is equal to or near 0. + */ +static inline VmathMatrix3 vmathM3Inverse_V( VmathMatrix3 mat ); + +/* + * Determinant of a 3x3 matrix + */ +static inline float vmathM3Determinant_V( VmathMatrix3 mat ); + +/* + * Conditionally select between two 3x3 matrices + */ +static inline VmathMatrix3 vmathM3Select_V( VmathMatrix3 mat0, VmathMatrix3 mat1, unsigned int select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3x3 matrix + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathM3Print_V( VmathMatrix3 mat ); + +/* + * Print a 3x3 matrix and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathM3Prints_V( VmathMatrix3 mat, const char *name ); + +#endif + +/* + * Construct a 4x4 matrix containing the specified columns + */ +static inline VmathMatrix4 vmathM4MakeFromCols_V( VmathVector4 col0, VmathVector4 col1, VmathVector4 col2, VmathVector4 col3 ); + +/* + * Construct a 4x4 matrix from a 3x4 transformation matrix + */ +static inline VmathMatrix4 vmathM4MakeFromT3_V( VmathTransform3 mat ); + +/* + * Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector + */ +static inline VmathMatrix4 vmathM4MakeFromM3V3_V( VmathMatrix3 mat, VmathVector3 translateVec ); + +/* + * Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector + */ +static inline VmathMatrix4 vmathM4MakeFromQV3_V( VmathQuat unitQuat, VmathVector3 translateVec ); + +/* + * Set all elements of a 4x4 matrix to the same scalar value + */ +static inline VmathMatrix4 vmathM4MakeFromScalar_V( float scalar ); + +/* + * Set the upper-left 3x3 submatrix + * NOTE: + * This function does not change the bottom row elements. + */ +static inline void vmathM4SetUpper3x3_V( VmathMatrix4 *result, VmathMatrix3 mat3 ); + +/* + * Get the upper-left 3x3 submatrix of a 4x4 matrix + */ +static inline VmathMatrix3 vmathM4GetUpper3x3_V( VmathMatrix4 mat ); + +/* + * Set translation component + * NOTE: + * This function does not change the bottom row elements. + */ +static inline void vmathM4SetTranslation_V( VmathMatrix4 *result, VmathVector3 translateVec ); + +/* + * Get the translation component of a 4x4 matrix + */ +static inline VmathVector3 vmathM4GetTranslation_V( VmathMatrix4 mat ); + +/* + * Set column 0 of a 4x4 matrix + */ +static inline void vmathM4SetCol0_V( VmathMatrix4 *result, VmathVector4 col0 ); + +/* + * Set column 1 of a 4x4 matrix + */ +static inline void vmathM4SetCol1_V( VmathMatrix4 *result, VmathVector4 col1 ); + +/* + * Set column 2 of a 4x4 matrix + */ +static inline void vmathM4SetCol2_V( VmathMatrix4 *result, VmathVector4 col2 ); + +/* + * Set column 3 of a 4x4 matrix + */ +static inline void vmathM4SetCol3_V( VmathMatrix4 *result, VmathVector4 col3 ); + +/* + * Get column 0 of a 4x4 matrix + */ +static inline VmathVector4 vmathM4GetCol0_V( VmathMatrix4 mat ); + +/* + * Get column 1 of a 4x4 matrix + */ +static inline VmathVector4 vmathM4GetCol1_V( VmathMatrix4 mat ); + +/* + * Get column 2 of a 4x4 matrix + */ +static inline VmathVector4 vmathM4GetCol2_V( VmathMatrix4 mat ); + +/* + * Get column 3 of a 4x4 matrix + */ +static inline VmathVector4 vmathM4GetCol3_V( VmathMatrix4 mat ); + +/* + * Set the column of a 4x4 matrix referred to by the specified index + */ +static inline void vmathM4SetCol_V( VmathMatrix4 *result, int col, VmathVector4 vec ); + +/* + * Set the row of a 4x4 matrix referred to by the specified index + */ +static inline void vmathM4SetRow_V( VmathMatrix4 *result, int row, VmathVector4 vec ); + +/* + * Get the column of a 4x4 matrix referred to by the specified index + */ +static inline VmathVector4 vmathM4GetCol_V( VmathMatrix4 mat, int col ); + +/* + * Get the row of a 4x4 matrix referred to by the specified index + */ +static inline VmathVector4 vmathM4GetRow_V( VmathMatrix4 mat, int row ); + +/* + * Set the element of a 4x4 matrix referred to by column and row indices + */ +static inline void vmathM4SetElem_V( VmathMatrix4 *result, int col, int row, float val ); + +/* + * Get the element of a 4x4 matrix referred to by column and row indices + */ +static inline float vmathM4GetElem_V( VmathMatrix4 mat, int col, int row ); + +/* + * Add two 4x4 matrices + */ +static inline VmathMatrix4 vmathM4Add_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ); + +/* + * Subtract a 4x4 matrix from another 4x4 matrix + */ +static inline VmathMatrix4 vmathM4Sub_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ); + +/* + * Negate all elements of a 4x4 matrix + */ +static inline VmathMatrix4 vmathM4Neg_V( VmathMatrix4 mat ); + +/* + * Multiply a 4x4 matrix by a scalar + */ +static inline VmathMatrix4 vmathM4ScalarMul_V( VmathMatrix4 mat, float scalar ); + +/* + * Multiply a 4x4 matrix by a 4-D vector + */ +static inline VmathVector4 vmathM4MulV4_V( VmathMatrix4 mat, VmathVector4 vec ); + +/* + * Multiply a 4x4 matrix by a 3-D vector + */ +static inline VmathVector4 vmathM4MulV3_V( VmathMatrix4 mat, VmathVector3 vec ); + +/* + * Multiply a 4x4 matrix by a 3-D point + */ +static inline VmathVector4 vmathM4MulP3_V( VmathMatrix4 mat, VmathPoint3 pnt ); + +/* + * Multiply two 4x4 matrices + */ +static inline VmathMatrix4 vmathM4Mul_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ); + +/* + * Multiply a 4x4 matrix by a 3x4 transformation matrix + */ +static inline VmathMatrix4 vmathM4MulT3_V( VmathMatrix4 mat, VmathTransform3 tfrm ); + +/* + * Construct an identity 4x4 matrix + */ +static inline VmathMatrix4 vmathM4MakeIdentity_V( ); + +/* + * Construct a 4x4 matrix to rotate around the x axis + */ +static inline VmathMatrix4 vmathM4MakeRotationX_V( float radians ); + +/* + * Construct a 4x4 matrix to rotate around the y axis + */ +static inline VmathMatrix4 vmathM4MakeRotationY_V( float radians ); + +/* + * Construct a 4x4 matrix to rotate around the z axis + */ +static inline VmathMatrix4 vmathM4MakeRotationZ_V( float radians ); + +/* + * Construct a 4x4 matrix to rotate around the x, y, and z axes + */ +static inline VmathMatrix4 vmathM4MakeRotationZYX_V( VmathVector3 radiansXYZ ); + +/* + * Construct a 4x4 matrix to rotate around a unit-length 3-D vector + */ +static inline VmathMatrix4 vmathM4MakeRotationAxis_V( float radians, VmathVector3 unitVec ); + +/* + * Construct a rotation matrix from a unit-length quaternion + */ +static inline VmathMatrix4 vmathM4MakeRotationQ_V( VmathQuat unitQuat ); + +/* + * Construct a 4x4 matrix to perform scaling + */ +static inline VmathMatrix4 vmathM4MakeScale_V( VmathVector3 scaleVec ); + +/* + * Construct a 4x4 matrix to perform translation + */ +static inline VmathMatrix4 vmathM4MakeTranslation_V( VmathVector3 translateVec ); + +/* + * Construct viewing matrix based on eye position, position looked at, and up direction + */ +static inline VmathMatrix4 vmathM4MakeLookAt_V( VmathPoint3 eyePos, VmathPoint3 lookAtPos, VmathVector3 upVec ); + +/* + * Construct a perspective projection matrix + */ +static inline VmathMatrix4 vmathM4MakePerspective_V( float fovyRadians, float aspect, float zNear, float zFar ); + +/* + * Construct a perspective projection matrix based on frustum + */ +static inline VmathMatrix4 vmathM4MakeFrustum_V( float left, float right, float bottom, float top, float zNear, float zFar ); + +/* + * Construct an orthographic projection matrix + */ +static inline VmathMatrix4 vmathM4MakeOrthographic_V( float left, float right, float bottom, float top, float zNear, float zFar ); + +/* + * Append (post-multiply) a scale transformation to a 4x4 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline VmathMatrix4 vmathM4AppendScale_V( VmathMatrix4 mat, VmathVector3 scaleVec ); + +/* + * Prepend (pre-multiply) a scale transformation to a 4x4 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline VmathMatrix4 vmathM4PrependScale_V( VmathVector3 scaleVec, VmathMatrix4 mat ); + +/* + * Multiply two 4x4 matrices per element + */ +static inline VmathMatrix4 vmathM4MulPerElem_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ); + +/* + * Compute the absolute value of a 4x4 matrix per element + */ +static inline VmathMatrix4 vmathM4AbsPerElem_V( VmathMatrix4 mat ); + +/* + * Transpose of a 4x4 matrix + */ +static inline VmathMatrix4 vmathM4Transpose_V( VmathMatrix4 mat ); + +/* + * Compute the inverse of a 4x4 matrix + * NOTE: + * Result is unpredictable when the determinant of mat is equal to or near 0. + */ +static inline VmathMatrix4 vmathM4Inverse_V( VmathMatrix4 mat ); + +/* + * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix + * NOTE: + * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. The result is unpredictable when the determinant of mat is equal to or near 0. + */ +static inline VmathMatrix4 vmathM4AffineInverse_V( VmathMatrix4 mat ); + +/* + * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix + * NOTE: + * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. + */ +static inline VmathMatrix4 vmathM4OrthoInverse_V( VmathMatrix4 mat ); + +/* + * Determinant of a 4x4 matrix + */ +static inline float vmathM4Determinant_V( VmathMatrix4 mat ); + +/* + * Conditionally select between two 4x4 matrices + */ +static inline VmathMatrix4 vmathM4Select_V( VmathMatrix4 mat0, VmathMatrix4 mat1, unsigned int select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 4x4 matrix + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathM4Print_V( VmathMatrix4 mat ); + +/* + * Print a 4x4 matrix and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathM4Prints_V( VmathMatrix4 mat, const char *name ); + +#endif + +/* + * Construct a 3x4 transformation matrix containing the specified columns + */ +static inline VmathTransform3 vmathT3MakeFromCols_V( VmathVector3 col0, VmathVector3 col1, VmathVector3 col2, VmathVector3 col3 ); + +/* + * Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector + */ +static inline VmathTransform3 vmathT3MakeFromM3V3_V( VmathMatrix3 tfrm, VmathVector3 translateVec ); + +/* + * Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector + */ +static inline VmathTransform3 vmathT3MakeFromQV3_V( VmathQuat unitQuat, VmathVector3 translateVec ); + +/* + * Set all elements of a 3x4 transformation matrix to the same scalar value + */ +static inline VmathTransform3 vmathT3MakeFromScalar_V( float scalar ); + +/* + * Set the upper-left 3x3 submatrix + */ +static inline void vmathT3SetUpper3x3_V( VmathTransform3 *result, VmathMatrix3 mat3 ); + +/* + * Get the upper-left 3x3 submatrix of a 3x4 transformation matrix + */ +static inline VmathMatrix3 vmathT3GetUpper3x3_V( VmathTransform3 tfrm ); + +/* + * Set translation component + */ +static inline void vmathT3SetTranslation_V( VmathTransform3 *result, VmathVector3 translateVec ); + +/* + * Get the translation component of a 3x4 transformation matrix + */ +static inline VmathVector3 vmathT3GetTranslation_V( VmathTransform3 tfrm ); + +/* + * Set column 0 of a 3x4 transformation matrix + */ +static inline void vmathT3SetCol0_V( VmathTransform3 *result, VmathVector3 col0 ); + +/* + * Set column 1 of a 3x4 transformation matrix + */ +static inline void vmathT3SetCol1_V( VmathTransform3 *result, VmathVector3 col1 ); + +/* + * Set column 2 of a 3x4 transformation matrix + */ +static inline void vmathT3SetCol2_V( VmathTransform3 *result, VmathVector3 col2 ); + +/* + * Set column 3 of a 3x4 transformation matrix + */ +static inline void vmathT3SetCol3_V( VmathTransform3 *result, VmathVector3 col3 ); + +/* + * Get column 0 of a 3x4 transformation matrix + */ +static inline VmathVector3 vmathT3GetCol0_V( VmathTransform3 tfrm ); + +/* + * Get column 1 of a 3x4 transformation matrix + */ +static inline VmathVector3 vmathT3GetCol1_V( VmathTransform3 tfrm ); + +/* + * Get column 2 of a 3x4 transformation matrix + */ +static inline VmathVector3 vmathT3GetCol2_V( VmathTransform3 tfrm ); + +/* + * Get column 3 of a 3x4 transformation matrix + */ +static inline VmathVector3 vmathT3GetCol3_V( VmathTransform3 tfrm ); + +/* + * Set the column of a 3x4 transformation matrix referred to by the specified index + */ +static inline void vmathT3SetCol_V( VmathTransform3 *result, int col, VmathVector3 vec ); + +/* + * Set the row of a 3x4 transformation matrix referred to by the specified index + */ +static inline void vmathT3SetRow_V( VmathTransform3 *result, int row, VmathVector4 vec ); + +/* + * Get the column of a 3x4 transformation matrix referred to by the specified index + */ +static inline VmathVector3 vmathT3GetCol_V( VmathTransform3 tfrm, int col ); + +/* + * Get the row of a 3x4 transformation matrix referred to by the specified index + */ +static inline VmathVector4 vmathT3GetRow_V( VmathTransform3 tfrm, int row ); + +/* + * Set the element of a 3x4 transformation matrix referred to by column and row indices + */ +static inline void vmathT3SetElem_V( VmathTransform3 *result, int col, int row, float val ); + +/* + * Get the element of a 3x4 transformation matrix referred to by column and row indices + */ +static inline float vmathT3GetElem_V( VmathTransform3 tfrm, int col, int row ); + +/* + * Multiply a 3x4 transformation matrix by a 3-D vector + */ +static inline VmathVector3 vmathT3MulV3_V( VmathTransform3 tfrm, VmathVector3 vec ); + +/* + * Multiply a 3x4 transformation matrix by a 3-D point + */ +static inline VmathPoint3 vmathT3MulP3_V( VmathTransform3 tfrm, VmathPoint3 pnt ); + +/* + * Multiply two 3x4 transformation matrices + */ +static inline VmathTransform3 vmathT3Mul_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1 ); + +/* + * Construct an identity 3x4 transformation matrix + */ +static inline VmathTransform3 vmathT3MakeIdentity_V( ); + +/* + * Construct a 3x4 transformation matrix to rotate around the x axis + */ +static inline VmathTransform3 vmathT3MakeRotationX_V( float radians ); + +/* + * Construct a 3x4 transformation matrix to rotate around the y axis + */ +static inline VmathTransform3 vmathT3MakeRotationY_V( float radians ); + +/* + * Construct a 3x4 transformation matrix to rotate around the z axis + */ +static inline VmathTransform3 vmathT3MakeRotationZ_V( float radians ); + +/* + * Construct a 3x4 transformation matrix to rotate around the x, y, and z axes + */ +static inline VmathTransform3 vmathT3MakeRotationZYX_V( VmathVector3 radiansXYZ ); + +/* + * Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector + */ +static inline VmathTransform3 vmathT3MakeRotationAxis_V( float radians, VmathVector3 unitVec ); + +/* + * Construct a rotation matrix from a unit-length quaternion + */ +static inline VmathTransform3 vmathT3MakeRotationQ_V( VmathQuat unitQuat ); + +/* + * Construct a 3x4 transformation matrix to perform scaling + */ +static inline VmathTransform3 vmathT3MakeScale_V( VmathVector3 scaleVec ); + +/* + * Construct a 3x4 transformation matrix to perform translation + */ +static inline VmathTransform3 vmathT3MakeTranslation_V( VmathVector3 translateVec ); + +/* + * Append (post-multiply) a scale transformation to a 3x4 transformation matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline VmathTransform3 vmathT3AppendScale_V( VmathTransform3 tfrm, VmathVector3 scaleVec ); + +/* + * Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline VmathTransform3 vmathT3PrependScale_V( VmathVector3 scaleVec, VmathTransform3 tfrm ); + +/* + * Multiply two 3x4 transformation matrices per element + */ +static inline VmathTransform3 vmathT3MulPerElem_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1 ); + +/* + * Compute the absolute value of a 3x4 transformation matrix per element + */ +static inline VmathTransform3 vmathT3AbsPerElem_V( VmathTransform3 tfrm ); + +/* + * Inverse of a 3x4 transformation matrix + * NOTE: + * Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0. + */ +static inline VmathTransform3 vmathT3Inverse_V( VmathTransform3 tfrm ); + +/* + * Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix + * NOTE: + * This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions. + */ +static inline VmathTransform3 vmathT3OrthoInverse_V( VmathTransform3 tfrm ); + +/* + * Conditionally select between two 3x4 transformation matrices + */ +static inline VmathTransform3 vmathT3Select_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1, unsigned int select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3x4 transformation matrix + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathT3Print_V( VmathTransform3 tfrm ); + +/* + * Print a 3x4 transformation matrix and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathT3Prints_V( VmathTransform3 tfrm, const char *name ); + +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include "vectormath_aos.h" +#include "vec_aos_v.h" +#include "quat_aos_v.h" +#include "mat_aos_v.h" + +#endif diff --git a/vectormathlibrary/include/vectormath/scalar/cpp/mat_aos.h b/vectormathlibrary/include/vectormath/scalar/cpp/mat_aos.h new file mode 100644 index 000000000..5d5d012d9 --- /dev/null +++ b/vectormathlibrary/include/vectormath/scalar/cpp/mat_aos.h @@ -0,0 +1,1643 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_MAT_AOS_CPP_H +#define _VECTORMATH_MAT_AOS_CPP_H + +namespace Vectormath { +namespace Aos { + +//----------------------------------------------------------------------------- +// Constants + +#define _VECTORMATH_PI_OVER_2 1.570796327f + +//----------------------------------------------------------------------------- +// Definitions + +inline Matrix3::Matrix3( const Matrix3 & mat ) +{ + mCol0 = mat.mCol0; + mCol1 = mat.mCol1; + mCol2 = mat.mCol2; +} + +inline Matrix3::Matrix3( float scalar ) +{ + mCol0 = Vector3( scalar ); + mCol1 = Vector3( scalar ); + mCol2 = Vector3( scalar ); +} + +inline Matrix3::Matrix3( const Quat & unitQuat ) +{ + float qx, qy, qz, qw, qx2, qy2, qz2, qxqx2, qyqy2, qzqz2, qxqy2, qyqz2, qzqw2, qxqz2, qyqw2, qxqw2; + qx = unitQuat.getX(); + qy = unitQuat.getY(); + qz = unitQuat.getZ(); + qw = unitQuat.getW(); + qx2 = ( qx + qx ); + qy2 = ( qy + qy ); + qz2 = ( qz + qz ); + qxqx2 = ( qx * qx2 ); + qxqy2 = ( qx * qy2 ); + qxqz2 = ( qx * qz2 ); + qxqw2 = ( qw * qx2 ); + qyqy2 = ( qy * qy2 ); + qyqz2 = ( qy * qz2 ); + qyqw2 = ( qw * qy2 ); + qzqz2 = ( qz * qz2 ); + qzqw2 = ( qw * qz2 ); + mCol0 = Vector3( ( ( 1.0f - qyqy2 ) - qzqz2 ), ( qxqy2 + qzqw2 ), ( qxqz2 - qyqw2 ) ); + mCol1 = Vector3( ( qxqy2 - qzqw2 ), ( ( 1.0f - qxqx2 ) - qzqz2 ), ( qyqz2 + qxqw2 ) ); + mCol2 = Vector3( ( qxqz2 + qyqw2 ), ( qyqz2 - qxqw2 ), ( ( 1.0f - qxqx2 ) - qyqy2 ) ); +} + +inline Matrix3::Matrix3( const Vector3 & _col0, const Vector3 & _col1, const Vector3 & _col2 ) +{ + mCol0 = _col0; + mCol1 = _col1; + mCol2 = _col2; +} + +inline Matrix3 & Matrix3::setCol0( const Vector3 & _col0 ) +{ + mCol0 = _col0; + return *this; +} + +inline Matrix3 & Matrix3::setCol1( const Vector3 & _col1 ) +{ + mCol1 = _col1; + return *this; +} + +inline Matrix3 & Matrix3::setCol2( const Vector3 & _col2 ) +{ + mCol2 = _col2; + return *this; +} + +inline Matrix3 & Matrix3::setCol( int col, const Vector3 & vec ) +{ + *(&mCol0 + col) = vec; + return *this; +} + +inline Matrix3 & Matrix3::setRow( int row, const Vector3 & vec ) +{ + mCol0.setElem( row, vec.getElem( 0 ) ); + mCol1.setElem( row, vec.getElem( 1 ) ); + mCol2.setElem( row, vec.getElem( 2 ) ); + return *this; +} + +inline Matrix3 & Matrix3::setElem( int col, int row, float val ) +{ + Vector3 tmpV3_0; + tmpV3_0 = this->getCol( col ); + tmpV3_0.setElem( row, val ); + this->setCol( col, tmpV3_0 ); + return *this; +} + +inline float Matrix3::getElem( int col, int row ) const +{ + return this->getCol( col ).getElem( row ); +} + +inline const Vector3 Matrix3::getCol0( ) const +{ + return mCol0; +} + +inline const Vector3 Matrix3::getCol1( ) const +{ + return mCol1; +} + +inline const Vector3 Matrix3::getCol2( ) const +{ + return mCol2; +} + +inline const Vector3 Matrix3::getCol( int col ) const +{ + return *(&mCol0 + col); +} + +inline const Vector3 Matrix3::getRow( int row ) const +{ + return Vector3( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ) ); +} + +inline Vector3 & Matrix3::operator []( int col ) +{ + return *(&mCol0 + col); +} + +inline const Vector3 Matrix3::operator []( int col ) const +{ + return *(&mCol0 + col); +} + +inline Matrix3 & Matrix3::operator =( const Matrix3 & mat ) +{ + mCol0 = mat.mCol0; + mCol1 = mat.mCol1; + mCol2 = mat.mCol2; + return *this; +} + +inline const Matrix3 transpose( const Matrix3 & mat ) +{ + return Matrix3( + Vector3( mat.getCol0().getX(), mat.getCol1().getX(), mat.getCol2().getX() ), + Vector3( mat.getCol0().getY(), mat.getCol1().getY(), mat.getCol2().getY() ), + Vector3( mat.getCol0().getZ(), mat.getCol1().getZ(), mat.getCol2().getZ() ) + ); +} + +inline const Matrix3 inverse( const Matrix3 & mat ) +{ + Vector3 tmp0, tmp1, tmp2; + float detinv; + tmp0 = cross( mat.getCol1(), mat.getCol2() ); + tmp1 = cross( mat.getCol2(), mat.getCol0() ); + tmp2 = cross( mat.getCol0(), mat.getCol1() ); + detinv = ( 1.0f / dot( mat.getCol2(), tmp2 ) ); + return Matrix3( + Vector3( ( tmp0.getX() * detinv ), ( tmp1.getX() * detinv ), ( tmp2.getX() * detinv ) ), + Vector3( ( tmp0.getY() * detinv ), ( tmp1.getY() * detinv ), ( tmp2.getY() * detinv ) ), + Vector3( ( tmp0.getZ() * detinv ), ( tmp1.getZ() * detinv ), ( tmp2.getZ() * detinv ) ) + ); +} + +inline float determinant( const Matrix3 & mat ) +{ + return dot( mat.getCol2(), cross( mat.getCol0(), mat.getCol1() ) ); +} + +inline const Matrix3 Matrix3::operator +( const Matrix3 & mat ) const +{ + return Matrix3( + ( mCol0 + mat.mCol0 ), + ( mCol1 + mat.mCol1 ), + ( mCol2 + mat.mCol2 ) + ); +} + +inline const Matrix3 Matrix3::operator -( const Matrix3 & mat ) const +{ + return Matrix3( + ( mCol0 - mat.mCol0 ), + ( mCol1 - mat.mCol1 ), + ( mCol2 - mat.mCol2 ) + ); +} + +inline Matrix3 & Matrix3::operator +=( const Matrix3 & mat ) +{ + *this = *this + mat; + return *this; +} + +inline Matrix3 & Matrix3::operator -=( const Matrix3 & mat ) +{ + *this = *this - mat; + return *this; +} + +inline const Matrix3 Matrix3::operator -( ) const +{ + return Matrix3( + ( -mCol0 ), + ( -mCol1 ), + ( -mCol2 ) + ); +} + +inline const Matrix3 absPerElem( const Matrix3 & mat ) +{ + return Matrix3( + absPerElem( mat.getCol0() ), + absPerElem( mat.getCol1() ), + absPerElem( mat.getCol2() ) + ); +} + +inline const Matrix3 Matrix3::operator *( float scalar ) const +{ + return Matrix3( + ( mCol0 * scalar ), + ( mCol1 * scalar ), + ( mCol2 * scalar ) + ); +} + +inline Matrix3 & Matrix3::operator *=( float scalar ) +{ + *this = *this * scalar; + return *this; +} + +inline const Matrix3 operator *( float scalar, const Matrix3 & mat ) +{ + return mat * scalar; +} + +inline const Vector3 Matrix3::operator *( const Vector3 & vec ) const +{ + return Vector3( + ( ( ( mCol0.getX() * vec.getX() ) + ( mCol1.getX() * vec.getY() ) ) + ( mCol2.getX() * vec.getZ() ) ), + ( ( ( mCol0.getY() * vec.getX() ) + ( mCol1.getY() * vec.getY() ) ) + ( mCol2.getY() * vec.getZ() ) ), + ( ( ( mCol0.getZ() * vec.getX() ) + ( mCol1.getZ() * vec.getY() ) ) + ( mCol2.getZ() * vec.getZ() ) ) + ); +} + +inline const Matrix3 Matrix3::operator *( const Matrix3 & mat ) const +{ + return Matrix3( + ( *this * mat.mCol0 ), + ( *this * mat.mCol1 ), + ( *this * mat.mCol2 ) + ); +} + +inline Matrix3 & Matrix3::operator *=( const Matrix3 & mat ) +{ + *this = *this * mat; + return *this; +} + +inline const Matrix3 mulPerElem( const Matrix3 & mat0, const Matrix3 & mat1 ) +{ + return Matrix3( + mulPerElem( mat0.getCol0(), mat1.getCol0() ), + mulPerElem( mat0.getCol1(), mat1.getCol1() ), + mulPerElem( mat0.getCol2(), mat1.getCol2() ) + ); +} + +inline const Matrix3 Matrix3::identity( ) +{ + return Matrix3( + Vector3::xAxis( ), + Vector3::yAxis( ), + Vector3::zAxis( ) + ); +} + +inline const Matrix3 Matrix3::rotationX( float radians ) +{ + float s, c; + s = sinf( radians ); + c = cosf( radians ); + return Matrix3( + Vector3::xAxis( ), + Vector3( 0.0f, c, s ), + Vector3( 0.0f, -s, c ) + ); +} + +inline const Matrix3 Matrix3::rotationY( float radians ) +{ + float s, c; + s = sinf( radians ); + c = cosf( radians ); + return Matrix3( + Vector3( c, 0.0f, -s ), + Vector3::yAxis( ), + Vector3( s, 0.0f, c ) + ); +} + +inline const Matrix3 Matrix3::rotationZ( float radians ) +{ + float s, c; + s = sinf( radians ); + c = cosf( radians ); + return Matrix3( + Vector3( c, s, 0.0f ), + Vector3( -s, c, 0.0f ), + Vector3::zAxis( ) + ); +} + +inline const Matrix3 Matrix3::rotationZYX( const Vector3 & radiansXYZ ) +{ + float sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; + sX = sinf( radiansXYZ.getX() ); + cX = cosf( radiansXYZ.getX() ); + sY = sinf( radiansXYZ.getY() ); + cY = cosf( radiansXYZ.getY() ); + sZ = sinf( radiansXYZ.getZ() ); + cZ = cosf( radiansXYZ.getZ() ); + tmp0 = ( cZ * sY ); + tmp1 = ( sZ * sY ); + return Matrix3( + Vector3( ( cZ * cY ), ( sZ * cY ), -sY ), + Vector3( ( ( tmp0 * sX ) - ( sZ * cX ) ), ( ( tmp1 * sX ) + ( cZ * cX ) ), ( cY * sX ) ), + Vector3( ( ( tmp0 * cX ) + ( sZ * sX ) ), ( ( tmp1 * cX ) - ( cZ * sX ) ), ( cY * cX ) ) + ); +} + +inline const Matrix3 Matrix3::rotation( float radians, const Vector3 & unitVec ) +{ + float x, y, z, s, c, oneMinusC, xy, yz, zx; + s = sinf( radians ); + c = cosf( radians ); + x = unitVec.getX(); + y = unitVec.getY(); + z = unitVec.getZ(); + xy = ( x * y ); + yz = ( y * z ); + zx = ( z * x ); + oneMinusC = ( 1.0f - c ); + return Matrix3( + Vector3( ( ( ( x * x ) * oneMinusC ) + c ), ( ( xy * oneMinusC ) + ( z * s ) ), ( ( zx * oneMinusC ) - ( y * s ) ) ), + Vector3( ( ( xy * oneMinusC ) - ( z * s ) ), ( ( ( y * y ) * oneMinusC ) + c ), ( ( yz * oneMinusC ) + ( x * s ) ) ), + Vector3( ( ( zx * oneMinusC ) + ( y * s ) ), ( ( yz * oneMinusC ) - ( x * s ) ), ( ( ( z * z ) * oneMinusC ) + c ) ) + ); +} + +inline const Matrix3 Matrix3::rotation( const Quat & unitQuat ) +{ + return Matrix3( unitQuat ); +} + +inline const Matrix3 Matrix3::scale( const Vector3 & scaleVec ) +{ + return Matrix3( + Vector3( scaleVec.getX(), 0.0f, 0.0f ), + Vector3( 0.0f, scaleVec.getY(), 0.0f ), + Vector3( 0.0f, 0.0f, scaleVec.getZ() ) + ); +} + +inline const Matrix3 appendScale( const Matrix3 & mat, const Vector3 & scaleVec ) +{ + return Matrix3( + ( mat.getCol0() * scaleVec.getX( ) ), + ( mat.getCol1() * scaleVec.getY( ) ), + ( mat.getCol2() * scaleVec.getZ( ) ) + ); +} + +inline const Matrix3 prependScale( const Vector3 & scaleVec, const Matrix3 & mat ) +{ + return Matrix3( + mulPerElem( mat.getCol0(), scaleVec ), + mulPerElem( mat.getCol1(), scaleVec ), + mulPerElem( mat.getCol2(), scaleVec ) + ); +} + +inline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, bool select1 ) +{ + return Matrix3( + select( mat0.getCol0(), mat1.getCol0(), select1 ), + select( mat0.getCol1(), mat1.getCol1(), select1 ), + select( mat0.getCol2(), mat1.getCol2(), select1 ) + ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( const Matrix3 & mat ) +{ + print( mat.getRow( 0 ) ); + print( mat.getRow( 1 ) ); + print( mat.getRow( 2 ) ); +} + +inline void print( const Matrix3 & mat, const char * name ) +{ + printf("%s:\n", name); + print( mat ); +} + +#endif + +inline Matrix4::Matrix4( const Matrix4 & mat ) +{ + mCol0 = mat.mCol0; + mCol1 = mat.mCol1; + mCol2 = mat.mCol2; + mCol3 = mat.mCol3; +} + +inline Matrix4::Matrix4( float scalar ) +{ + mCol0 = Vector4( scalar ); + mCol1 = Vector4( scalar ); + mCol2 = Vector4( scalar ); + mCol3 = Vector4( scalar ); +} + +inline Matrix4::Matrix4( const Transform3 & mat ) +{ + mCol0 = Vector4( mat.getCol0(), 0.0f ); + mCol1 = Vector4( mat.getCol1(), 0.0f ); + mCol2 = Vector4( mat.getCol2(), 0.0f ); + mCol3 = Vector4( mat.getCol3(), 1.0f ); +} + +inline Matrix4::Matrix4( const Vector4 & _col0, const Vector4 & _col1, const Vector4 & _col2, const Vector4 & _col3 ) +{ + mCol0 = _col0; + mCol1 = _col1; + mCol2 = _col2; + mCol3 = _col3; +} + +inline Matrix4::Matrix4( const Matrix3 & mat, const Vector3 & translateVec ) +{ + mCol0 = Vector4( mat.getCol0(), 0.0f ); + mCol1 = Vector4( mat.getCol1(), 0.0f ); + mCol2 = Vector4( mat.getCol2(), 0.0f ); + mCol3 = Vector4( translateVec, 1.0f ); +} + +inline Matrix4::Matrix4( const Quat & unitQuat, const Vector3 & translateVec ) +{ + Matrix3 mat; + mat = Matrix3( unitQuat ); + mCol0 = Vector4( mat.getCol0(), 0.0f ); + mCol1 = Vector4( mat.getCol1(), 0.0f ); + mCol2 = Vector4( mat.getCol2(), 0.0f ); + mCol3 = Vector4( translateVec, 1.0f ); +} + +inline Matrix4 & Matrix4::setCol0( const Vector4 & _col0 ) +{ + mCol0 = _col0; + return *this; +} + +inline Matrix4 & Matrix4::setCol1( const Vector4 & _col1 ) +{ + mCol1 = _col1; + return *this; +} + +inline Matrix4 & Matrix4::setCol2( const Vector4 & _col2 ) +{ + mCol2 = _col2; + return *this; +} + +inline Matrix4 & Matrix4::setCol3( const Vector4 & _col3 ) +{ + mCol3 = _col3; + return *this; +} + +inline Matrix4 & Matrix4::setCol( int col, const Vector4 & vec ) +{ + *(&mCol0 + col) = vec; + return *this; +} + +inline Matrix4 & Matrix4::setRow( int row, const Vector4 & vec ) +{ + mCol0.setElem( row, vec.getElem( 0 ) ); + mCol1.setElem( row, vec.getElem( 1 ) ); + mCol2.setElem( row, vec.getElem( 2 ) ); + mCol3.setElem( row, vec.getElem( 3 ) ); + return *this; +} + +inline Matrix4 & Matrix4::setElem( int col, int row, float val ) +{ + Vector4 tmpV3_0; + tmpV3_0 = this->getCol( col ); + tmpV3_0.setElem( row, val ); + this->setCol( col, tmpV3_0 ); + return *this; +} + +inline float Matrix4::getElem( int col, int row ) const +{ + return this->getCol( col ).getElem( row ); +} + +inline const Vector4 Matrix4::getCol0( ) const +{ + return mCol0; +} + +inline const Vector4 Matrix4::getCol1( ) const +{ + return mCol1; +} + +inline const Vector4 Matrix4::getCol2( ) const +{ + return mCol2; +} + +inline const Vector4 Matrix4::getCol3( ) const +{ + return mCol3; +} + +inline const Vector4 Matrix4::getCol( int col ) const +{ + return *(&mCol0 + col); +} + +inline const Vector4 Matrix4::getRow( int row ) const +{ + return Vector4( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ), mCol3.getElem( row ) ); +} + +inline Vector4 & Matrix4::operator []( int col ) +{ + return *(&mCol0 + col); +} + +inline const Vector4 Matrix4::operator []( int col ) const +{ + return *(&mCol0 + col); +} + +inline Matrix4 & Matrix4::operator =( const Matrix4 & mat ) +{ + mCol0 = mat.mCol0; + mCol1 = mat.mCol1; + mCol2 = mat.mCol2; + mCol3 = mat.mCol3; + return *this; +} + +inline const Matrix4 transpose( const Matrix4 & mat ) +{ + return Matrix4( + Vector4( mat.getCol0().getX(), mat.getCol1().getX(), mat.getCol2().getX(), mat.getCol3().getX() ), + Vector4( mat.getCol0().getY(), mat.getCol1().getY(), mat.getCol2().getY(), mat.getCol3().getY() ), + Vector4( mat.getCol0().getZ(), mat.getCol1().getZ(), mat.getCol2().getZ(), mat.getCol3().getZ() ), + Vector4( mat.getCol0().getW(), mat.getCol1().getW(), mat.getCol2().getW(), mat.getCol3().getW() ) + ); +} + +inline const Matrix4 inverse( const Matrix4 & mat ) +{ + Vector4 res0, res1, res2, res3; + float mA, mB, mC, mD, mE, mF, mG, mH, mI, mJ, mK, mL, mM, mN, mO, mP, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, detInv; + mA = mat.getCol0().getX(); + mB = mat.getCol0().getY(); + mC = mat.getCol0().getZ(); + mD = mat.getCol0().getW(); + mE = mat.getCol1().getX(); + mF = mat.getCol1().getY(); + mG = mat.getCol1().getZ(); + mH = mat.getCol1().getW(); + mI = mat.getCol2().getX(); + mJ = mat.getCol2().getY(); + mK = mat.getCol2().getZ(); + mL = mat.getCol2().getW(); + mM = mat.getCol3().getX(); + mN = mat.getCol3().getY(); + mO = mat.getCol3().getZ(); + mP = mat.getCol3().getW(); + tmp0 = ( ( mK * mD ) - ( mC * mL ) ); + tmp1 = ( ( mO * mH ) - ( mG * mP ) ); + tmp2 = ( ( mB * mK ) - ( mJ * mC ) ); + tmp3 = ( ( mF * mO ) - ( mN * mG ) ); + tmp4 = ( ( mJ * mD ) - ( mB * mL ) ); + tmp5 = ( ( mN * mH ) - ( mF * mP ) ); + res0.setX( ( ( ( mJ * tmp1 ) - ( mL * tmp3 ) ) - ( mK * tmp5 ) ) ); + res0.setY( ( ( ( mN * tmp0 ) - ( mP * tmp2 ) ) - ( mO * tmp4 ) ) ); + res0.setZ( ( ( ( mD * tmp3 ) + ( mC * tmp5 ) ) - ( mB * tmp1 ) ) ); + res0.setW( ( ( ( mH * tmp2 ) + ( mG * tmp4 ) ) - ( mF * tmp0 ) ) ); + detInv = ( 1.0f / ( ( ( ( mA * res0.getX() ) + ( mE * res0.getY() ) ) + ( mI * res0.getZ() ) ) + ( mM * res0.getW() ) ) ); + res1.setX( ( mI * tmp1 ) ); + res1.setY( ( mM * tmp0 ) ); + res1.setZ( ( mA * tmp1 ) ); + res1.setW( ( mE * tmp0 ) ); + res3.setX( ( mI * tmp3 ) ); + res3.setY( ( mM * tmp2 ) ); + res3.setZ( ( mA * tmp3 ) ); + res3.setW( ( mE * tmp2 ) ); + res2.setX( ( mI * tmp5 ) ); + res2.setY( ( mM * tmp4 ) ); + res2.setZ( ( mA * tmp5 ) ); + res2.setW( ( mE * tmp4 ) ); + tmp0 = ( ( mI * mB ) - ( mA * mJ ) ); + tmp1 = ( ( mM * mF ) - ( mE * mN ) ); + tmp2 = ( ( mI * mD ) - ( mA * mL ) ); + tmp3 = ( ( mM * mH ) - ( mE * mP ) ); + tmp4 = ( ( mI * mC ) - ( mA * mK ) ); + tmp5 = ( ( mM * mG ) - ( mE * mO ) ); + res2.setX( ( ( ( mL * tmp1 ) - ( mJ * tmp3 ) ) + res2.getX() ) ); + res2.setY( ( ( ( mP * tmp0 ) - ( mN * tmp2 ) ) + res2.getY() ) ); + res2.setZ( ( ( ( mB * tmp3 ) - ( mD * tmp1 ) ) - res2.getZ() ) ); + res2.setW( ( ( ( mF * tmp2 ) - ( mH * tmp0 ) ) - res2.getW() ) ); + res3.setX( ( ( ( mJ * tmp5 ) - ( mK * tmp1 ) ) + res3.getX() ) ); + res3.setY( ( ( ( mN * tmp4 ) - ( mO * tmp0 ) ) + res3.getY() ) ); + res3.setZ( ( ( ( mC * tmp1 ) - ( mB * tmp5 ) ) - res3.getZ() ) ); + res3.setW( ( ( ( mG * tmp0 ) - ( mF * tmp4 ) ) - res3.getW() ) ); + res1.setX( ( ( ( mK * tmp3 ) - ( mL * tmp5 ) ) - res1.getX() ) ); + res1.setY( ( ( ( mO * tmp2 ) - ( mP * tmp4 ) ) - res1.getY() ) ); + res1.setZ( ( ( ( mD * tmp5 ) - ( mC * tmp3 ) ) + res1.getZ() ) ); + res1.setW( ( ( ( mH * tmp4 ) - ( mG * tmp2 ) ) + res1.getW() ) ); + return Matrix4( + ( res0 * detInv ), + ( res1 * detInv ), + ( res2 * detInv ), + ( res3 * detInv ) + ); +} + +inline const Matrix4 affineInverse( const Matrix4 & mat ) +{ + Transform3 affineMat; + affineMat.setCol0( mat.getCol0().getXYZ( ) ); + affineMat.setCol1( mat.getCol1().getXYZ( ) ); + affineMat.setCol2( mat.getCol2().getXYZ( ) ); + affineMat.setCol3( mat.getCol3().getXYZ( ) ); + return Matrix4( inverse( affineMat ) ); +} + +inline const Matrix4 orthoInverse( const Matrix4 & mat ) +{ + Transform3 affineMat; + affineMat.setCol0( mat.getCol0().getXYZ( ) ); + affineMat.setCol1( mat.getCol1().getXYZ( ) ); + affineMat.setCol2( mat.getCol2().getXYZ( ) ); + affineMat.setCol3( mat.getCol3().getXYZ( ) ); + return Matrix4( orthoInverse( affineMat ) ); +} + +inline float determinant( const Matrix4 & mat ) +{ + float dx, dy, dz, dw, mA, mB, mC, mD, mE, mF, mG, mH, mI, mJ, mK, mL, mM, mN, mO, mP, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; + mA = mat.getCol0().getX(); + mB = mat.getCol0().getY(); + mC = mat.getCol0().getZ(); + mD = mat.getCol0().getW(); + mE = mat.getCol1().getX(); + mF = mat.getCol1().getY(); + mG = mat.getCol1().getZ(); + mH = mat.getCol1().getW(); + mI = mat.getCol2().getX(); + mJ = mat.getCol2().getY(); + mK = mat.getCol2().getZ(); + mL = mat.getCol2().getW(); + mM = mat.getCol3().getX(); + mN = mat.getCol3().getY(); + mO = mat.getCol3().getZ(); + mP = mat.getCol3().getW(); + tmp0 = ( ( mK * mD ) - ( mC * mL ) ); + tmp1 = ( ( mO * mH ) - ( mG * mP ) ); + tmp2 = ( ( mB * mK ) - ( mJ * mC ) ); + tmp3 = ( ( mF * mO ) - ( mN * mG ) ); + tmp4 = ( ( mJ * mD ) - ( mB * mL ) ); + tmp5 = ( ( mN * mH ) - ( mF * mP ) ); + dx = ( ( ( mJ * tmp1 ) - ( mL * tmp3 ) ) - ( mK * tmp5 ) ); + dy = ( ( ( mN * tmp0 ) - ( mP * tmp2 ) ) - ( mO * tmp4 ) ); + dz = ( ( ( mD * tmp3 ) + ( mC * tmp5 ) ) - ( mB * tmp1 ) ); + dw = ( ( ( mH * tmp2 ) + ( mG * tmp4 ) ) - ( mF * tmp0 ) ); + return ( ( ( ( mA * dx ) + ( mE * dy ) ) + ( mI * dz ) ) + ( mM * dw ) ); +} + +inline const Matrix4 Matrix4::operator +( const Matrix4 & mat ) const +{ + return Matrix4( + ( mCol0 + mat.mCol0 ), + ( mCol1 + mat.mCol1 ), + ( mCol2 + mat.mCol2 ), + ( mCol3 + mat.mCol3 ) + ); +} + +inline const Matrix4 Matrix4::operator -( const Matrix4 & mat ) const +{ + return Matrix4( + ( mCol0 - mat.mCol0 ), + ( mCol1 - mat.mCol1 ), + ( mCol2 - mat.mCol2 ), + ( mCol3 - mat.mCol3 ) + ); +} + +inline Matrix4 & Matrix4::operator +=( const Matrix4 & mat ) +{ + *this = *this + mat; + return *this; +} + +inline Matrix4 & Matrix4::operator -=( const Matrix4 & mat ) +{ + *this = *this - mat; + return *this; +} + +inline const Matrix4 Matrix4::operator -( ) const +{ + return Matrix4( + ( -mCol0 ), + ( -mCol1 ), + ( -mCol2 ), + ( -mCol3 ) + ); +} + +inline const Matrix4 absPerElem( const Matrix4 & mat ) +{ + return Matrix4( + absPerElem( mat.getCol0() ), + absPerElem( mat.getCol1() ), + absPerElem( mat.getCol2() ), + absPerElem( mat.getCol3() ) + ); +} + +inline const Matrix4 Matrix4::operator *( float scalar ) const +{ + return Matrix4( + ( mCol0 * scalar ), + ( mCol1 * scalar ), + ( mCol2 * scalar ), + ( mCol3 * scalar ) + ); +} + +inline Matrix4 & Matrix4::operator *=( float scalar ) +{ + *this = *this * scalar; + return *this; +} + +inline const Matrix4 operator *( float scalar, const Matrix4 & mat ) +{ + return mat * scalar; +} + +inline const Vector4 Matrix4::operator *( const Vector4 & vec ) const +{ + return Vector4( + ( ( ( ( mCol0.getX() * vec.getX() ) + ( mCol1.getX() * vec.getY() ) ) + ( mCol2.getX() * vec.getZ() ) ) + ( mCol3.getX() * vec.getW() ) ), + ( ( ( ( mCol0.getY() * vec.getX() ) + ( mCol1.getY() * vec.getY() ) ) + ( mCol2.getY() * vec.getZ() ) ) + ( mCol3.getY() * vec.getW() ) ), + ( ( ( ( mCol0.getZ() * vec.getX() ) + ( mCol1.getZ() * vec.getY() ) ) + ( mCol2.getZ() * vec.getZ() ) ) + ( mCol3.getZ() * vec.getW() ) ), + ( ( ( ( mCol0.getW() * vec.getX() ) + ( mCol1.getW() * vec.getY() ) ) + ( mCol2.getW() * vec.getZ() ) ) + ( mCol3.getW() * vec.getW() ) ) + ); +} + +inline const Vector4 Matrix4::operator *( const Vector3 & vec ) const +{ + return Vector4( + ( ( ( mCol0.getX() * vec.getX() ) + ( mCol1.getX() * vec.getY() ) ) + ( mCol2.getX() * vec.getZ() ) ), + ( ( ( mCol0.getY() * vec.getX() ) + ( mCol1.getY() * vec.getY() ) ) + ( mCol2.getY() * vec.getZ() ) ), + ( ( ( mCol0.getZ() * vec.getX() ) + ( mCol1.getZ() * vec.getY() ) ) + ( mCol2.getZ() * vec.getZ() ) ), + ( ( ( mCol0.getW() * vec.getX() ) + ( mCol1.getW() * vec.getY() ) ) + ( mCol2.getW() * vec.getZ() ) ) + ); +} + +inline const Vector4 Matrix4::operator *( const Point3 & pnt ) const +{ + return Vector4( + ( ( ( ( mCol0.getX() * pnt.getX() ) + ( mCol1.getX() * pnt.getY() ) ) + ( mCol2.getX() * pnt.getZ() ) ) + mCol3.getX() ), + ( ( ( ( mCol0.getY() * pnt.getX() ) + ( mCol1.getY() * pnt.getY() ) ) + ( mCol2.getY() * pnt.getZ() ) ) + mCol3.getY() ), + ( ( ( ( mCol0.getZ() * pnt.getX() ) + ( mCol1.getZ() * pnt.getY() ) ) + ( mCol2.getZ() * pnt.getZ() ) ) + mCol3.getZ() ), + ( ( ( ( mCol0.getW() * pnt.getX() ) + ( mCol1.getW() * pnt.getY() ) ) + ( mCol2.getW() * pnt.getZ() ) ) + mCol3.getW() ) + ); +} + +inline const Matrix4 Matrix4::operator *( const Matrix4 & mat ) const +{ + return Matrix4( + ( *this * mat.mCol0 ), + ( *this * mat.mCol1 ), + ( *this * mat.mCol2 ), + ( *this * mat.mCol3 ) + ); +} + +inline Matrix4 & Matrix4::operator *=( const Matrix4 & mat ) +{ + *this = *this * mat; + return *this; +} + +inline const Matrix4 Matrix4::operator *( const Transform3 & tfrm ) const +{ + return Matrix4( + ( *this * tfrm.getCol0() ), + ( *this * tfrm.getCol1() ), + ( *this * tfrm.getCol2() ), + ( *this * Point3( tfrm.getCol3() ) ) + ); +} + +inline Matrix4 & Matrix4::operator *=( const Transform3 & tfrm ) +{ + *this = *this * tfrm; + return *this; +} + +inline const Matrix4 mulPerElem( const Matrix4 & mat0, const Matrix4 & mat1 ) +{ + return Matrix4( + mulPerElem( mat0.getCol0(), mat1.getCol0() ), + mulPerElem( mat0.getCol1(), mat1.getCol1() ), + mulPerElem( mat0.getCol2(), mat1.getCol2() ), + mulPerElem( mat0.getCol3(), mat1.getCol3() ) + ); +} + +inline const Matrix4 Matrix4::identity( ) +{ + return Matrix4( + Vector4::xAxis( ), + Vector4::yAxis( ), + Vector4::zAxis( ), + Vector4::wAxis( ) + ); +} + +inline Matrix4 & Matrix4::setUpper3x3( const Matrix3 & mat3 ) +{ + mCol0.setXYZ( mat3.getCol0() ); + mCol1.setXYZ( mat3.getCol1() ); + mCol2.setXYZ( mat3.getCol2() ); + return *this; +} + +inline const Matrix3 Matrix4::getUpper3x3( ) const +{ + return Matrix3( + mCol0.getXYZ( ), + mCol1.getXYZ( ), + mCol2.getXYZ( ) + ); +} + +inline Matrix4 & Matrix4::setTranslation( const Vector3 & translateVec ) +{ + mCol3.setXYZ( translateVec ); + return *this; +} + +inline const Vector3 Matrix4::getTranslation( ) const +{ + return mCol3.getXYZ( ); +} + +inline const Matrix4 Matrix4::rotationX( float radians ) +{ + float s, c; + s = sinf( radians ); + c = cosf( radians ); + return Matrix4( + Vector4::xAxis( ), + Vector4( 0.0f, c, s, 0.0f ), + Vector4( 0.0f, -s, c, 0.0f ), + Vector4::wAxis( ) + ); +} + +inline const Matrix4 Matrix4::rotationY( float radians ) +{ + float s, c; + s = sinf( radians ); + c = cosf( radians ); + return Matrix4( + Vector4( c, 0.0f, -s, 0.0f ), + Vector4::yAxis( ), + Vector4( s, 0.0f, c, 0.0f ), + Vector4::wAxis( ) + ); +} + +inline const Matrix4 Matrix4::rotationZ( float radians ) +{ + float s, c; + s = sinf( radians ); + c = cosf( radians ); + return Matrix4( + Vector4( c, s, 0.0f, 0.0f ), + Vector4( -s, c, 0.0f, 0.0f ), + Vector4::zAxis( ), + Vector4::wAxis( ) + ); +} + +inline const Matrix4 Matrix4::rotationZYX( const Vector3 & radiansXYZ ) +{ + float sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; + sX = sinf( radiansXYZ.getX() ); + cX = cosf( radiansXYZ.getX() ); + sY = sinf( radiansXYZ.getY() ); + cY = cosf( radiansXYZ.getY() ); + sZ = sinf( radiansXYZ.getZ() ); + cZ = cosf( radiansXYZ.getZ() ); + tmp0 = ( cZ * sY ); + tmp1 = ( sZ * sY ); + return Matrix4( + Vector4( ( cZ * cY ), ( sZ * cY ), -sY, 0.0f ), + Vector4( ( ( tmp0 * sX ) - ( sZ * cX ) ), ( ( tmp1 * sX ) + ( cZ * cX ) ), ( cY * sX ), 0.0f ), + Vector4( ( ( tmp0 * cX ) + ( sZ * sX ) ), ( ( tmp1 * cX ) - ( cZ * sX ) ), ( cY * cX ), 0.0f ), + Vector4::wAxis( ) + ); +} + +inline const Matrix4 Matrix4::rotation( float radians, const Vector3 & unitVec ) +{ + float x, y, z, s, c, oneMinusC, xy, yz, zx; + s = sinf( radians ); + c = cosf( radians ); + x = unitVec.getX(); + y = unitVec.getY(); + z = unitVec.getZ(); + xy = ( x * y ); + yz = ( y * z ); + zx = ( z * x ); + oneMinusC = ( 1.0f - c ); + return Matrix4( + Vector4( ( ( ( x * x ) * oneMinusC ) + c ), ( ( xy * oneMinusC ) + ( z * s ) ), ( ( zx * oneMinusC ) - ( y * s ) ), 0.0f ), + Vector4( ( ( xy * oneMinusC ) - ( z * s ) ), ( ( ( y * y ) * oneMinusC ) + c ), ( ( yz * oneMinusC ) + ( x * s ) ), 0.0f ), + Vector4( ( ( zx * oneMinusC ) + ( y * s ) ), ( ( yz * oneMinusC ) - ( x * s ) ), ( ( ( z * z ) * oneMinusC ) + c ), 0.0f ), + Vector4::wAxis( ) + ); +} + +inline const Matrix4 Matrix4::rotation( const Quat & unitQuat ) +{ + return Matrix4( Transform3::rotation( unitQuat ) ); +} + +inline const Matrix4 Matrix4::scale( const Vector3 & scaleVec ) +{ + return Matrix4( + Vector4( scaleVec.getX(), 0.0f, 0.0f, 0.0f ), + Vector4( 0.0f, scaleVec.getY(), 0.0f, 0.0f ), + Vector4( 0.0f, 0.0f, scaleVec.getZ(), 0.0f ), + Vector4::wAxis( ) + ); +} + +inline const Matrix4 appendScale( const Matrix4 & mat, const Vector3 & scaleVec ) +{ + return Matrix4( + ( mat.getCol0() * scaleVec.getX( ) ), + ( mat.getCol1() * scaleVec.getY( ) ), + ( mat.getCol2() * scaleVec.getZ( ) ), + mat.getCol3() + ); +} + +inline const Matrix4 prependScale( const Vector3 & scaleVec, const Matrix4 & mat ) +{ + Vector4 scale4; + scale4 = Vector4( scaleVec, 1.0f ); + return Matrix4( + mulPerElem( mat.getCol0(), scale4 ), + mulPerElem( mat.getCol1(), scale4 ), + mulPerElem( mat.getCol2(), scale4 ), + mulPerElem( mat.getCol3(), scale4 ) + ); +} + +inline const Matrix4 Matrix4::translation( const Vector3 & translateVec ) +{ + return Matrix4( + Vector4::xAxis( ), + Vector4::yAxis( ), + Vector4::zAxis( ), + Vector4( translateVec, 1.0f ) + ); +} + +inline const Matrix4 Matrix4::lookAt( const Point3 & eyePos, const Point3 & lookAtPos, const Vector3 & upVec ) +{ + Matrix4 m4EyeFrame; + Vector3 v3X, v3Y, v3Z; + v3Y = normalize( upVec ); + v3Z = normalize( ( eyePos - lookAtPos ) ); + v3X = normalize( cross( v3Y, v3Z ) ); + v3Y = cross( v3Z, v3X ); + m4EyeFrame = Matrix4( Vector4( v3X ), Vector4( v3Y ), Vector4( v3Z ), Vector4( eyePos ) ); + return orthoInverse( m4EyeFrame ); +} + +inline const Matrix4 Matrix4::perspective( float fovyRadians, float aspect, float zNear, float zFar ) +{ + float f, rangeInv; + f = tanf( ( (float)( _VECTORMATH_PI_OVER_2 ) - ( 0.5f * fovyRadians ) ) ); + rangeInv = ( 1.0f / ( zNear - zFar ) ); + return Matrix4( + Vector4( ( f / aspect ), 0.0f, 0.0f, 0.0f ), + Vector4( 0.0f, f, 0.0f, 0.0f ), + Vector4( 0.0f, 0.0f, ( ( zNear + zFar ) * rangeInv ), -1.0f ), + Vector4( 0.0f, 0.0f, ( ( ( zNear * zFar ) * rangeInv ) * 2.0f ), 0.0f ) + ); +} + +inline const Matrix4 Matrix4::frustum( float left, float right, float bottom, float top, float zNear, float zFar ) +{ + float sum_rl, sum_tb, sum_nf, inv_rl, inv_tb, inv_nf, n2; + sum_rl = ( right + left ); + sum_tb = ( top + bottom ); + sum_nf = ( zNear + zFar ); + inv_rl = ( 1.0f / ( right - left ) ); + inv_tb = ( 1.0f / ( top - bottom ) ); + inv_nf = ( 1.0f / ( zNear - zFar ) ); + n2 = ( zNear + zNear ); + return Matrix4( + Vector4( ( n2 * inv_rl ), 0.0f, 0.0f, 0.0f ), + Vector4( 0.0f, ( n2 * inv_tb ), 0.0f, 0.0f ), + Vector4( ( sum_rl * inv_rl ), ( sum_tb * inv_tb ), ( sum_nf * inv_nf ), -1.0f ), + Vector4( 0.0f, 0.0f, ( ( n2 * inv_nf ) * zFar ), 0.0f ) + ); +} + +inline const Matrix4 Matrix4::orthographic( float left, float right, float bottom, float top, float zNear, float zFar ) +{ + float sum_rl, sum_tb, sum_nf, inv_rl, inv_tb, inv_nf; + sum_rl = ( right + left ); + sum_tb = ( top + bottom ); + sum_nf = ( zNear + zFar ); + inv_rl = ( 1.0f / ( right - left ) ); + inv_tb = ( 1.0f / ( top - bottom ) ); + inv_nf = ( 1.0f / ( zNear - zFar ) ); + return Matrix4( + Vector4( ( inv_rl + inv_rl ), 0.0f, 0.0f, 0.0f ), + Vector4( 0.0f, ( inv_tb + inv_tb ), 0.0f, 0.0f ), + Vector4( 0.0f, 0.0f, ( inv_nf + inv_nf ), 0.0f ), + Vector4( ( -sum_rl * inv_rl ), ( -sum_tb * inv_tb ), ( sum_nf * inv_nf ), 1.0f ) + ); +} + +inline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, bool select1 ) +{ + return Matrix4( + select( mat0.getCol0(), mat1.getCol0(), select1 ), + select( mat0.getCol1(), mat1.getCol1(), select1 ), + select( mat0.getCol2(), mat1.getCol2(), select1 ), + select( mat0.getCol3(), mat1.getCol3(), select1 ) + ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( const Matrix4 & mat ) +{ + print( mat.getRow( 0 ) ); + print( mat.getRow( 1 ) ); + print( mat.getRow( 2 ) ); + print( mat.getRow( 3 ) ); +} + +inline void print( const Matrix4 & mat, const char * name ) +{ + printf("%s:\n", name); + print( mat ); +} + +#endif + +inline Transform3::Transform3( const Transform3 & tfrm ) +{ + mCol0 = tfrm.mCol0; + mCol1 = tfrm.mCol1; + mCol2 = tfrm.mCol2; + mCol3 = tfrm.mCol3; +} + +inline Transform3::Transform3( float scalar ) +{ + mCol0 = Vector3( scalar ); + mCol1 = Vector3( scalar ); + mCol2 = Vector3( scalar ); + mCol3 = Vector3( scalar ); +} + +inline Transform3::Transform3( const Vector3 & _col0, const Vector3 & _col1, const Vector3 & _col2, const Vector3 & _col3 ) +{ + mCol0 = _col0; + mCol1 = _col1; + mCol2 = _col2; + mCol3 = _col3; +} + +inline Transform3::Transform3( const Matrix3 & tfrm, const Vector3 & translateVec ) +{ + this->setUpper3x3( tfrm ); + this->setTranslation( translateVec ); +} + +inline Transform3::Transform3( const Quat & unitQuat, const Vector3 & translateVec ) +{ + this->setUpper3x3( Matrix3( unitQuat ) ); + this->setTranslation( translateVec ); +} + +inline Transform3 & Transform3::setCol0( const Vector3 & _col0 ) +{ + mCol0 = _col0; + return *this; +} + +inline Transform3 & Transform3::setCol1( const Vector3 & _col1 ) +{ + mCol1 = _col1; + return *this; +} + +inline Transform3 & Transform3::setCol2( const Vector3 & _col2 ) +{ + mCol2 = _col2; + return *this; +} + +inline Transform3 & Transform3::setCol3( const Vector3 & _col3 ) +{ + mCol3 = _col3; + return *this; +} + +inline Transform3 & Transform3::setCol( int col, const Vector3 & vec ) +{ + *(&mCol0 + col) = vec; + return *this; +} + +inline Transform3 & Transform3::setRow( int row, const Vector4 & vec ) +{ + mCol0.setElem( row, vec.getElem( 0 ) ); + mCol1.setElem( row, vec.getElem( 1 ) ); + mCol2.setElem( row, vec.getElem( 2 ) ); + mCol3.setElem( row, vec.getElem( 3 ) ); + return *this; +} + +inline Transform3 & Transform3::setElem( int col, int row, float val ) +{ + Vector3 tmpV3_0; + tmpV3_0 = this->getCol( col ); + tmpV3_0.setElem( row, val ); + this->setCol( col, tmpV3_0 ); + return *this; +} + +inline float Transform3::getElem( int col, int row ) const +{ + return this->getCol( col ).getElem( row ); +} + +inline const Vector3 Transform3::getCol0( ) const +{ + return mCol0; +} + +inline const Vector3 Transform3::getCol1( ) const +{ + return mCol1; +} + +inline const Vector3 Transform3::getCol2( ) const +{ + return mCol2; +} + +inline const Vector3 Transform3::getCol3( ) const +{ + return mCol3; +} + +inline const Vector3 Transform3::getCol( int col ) const +{ + return *(&mCol0 + col); +} + +inline const Vector4 Transform3::getRow( int row ) const +{ + return Vector4( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ), mCol3.getElem( row ) ); +} + +inline Vector3 & Transform3::operator []( int col ) +{ + return *(&mCol0 + col); +} + +inline const Vector3 Transform3::operator []( int col ) const +{ + return *(&mCol0 + col); +} + +inline Transform3 & Transform3::operator =( const Transform3 & tfrm ) +{ + mCol0 = tfrm.mCol0; + mCol1 = tfrm.mCol1; + mCol2 = tfrm.mCol2; + mCol3 = tfrm.mCol3; + return *this; +} + +inline const Transform3 inverse( const Transform3 & tfrm ) +{ + Vector3 tmp0, tmp1, tmp2, inv0, inv1, inv2; + float detinv; + tmp0 = cross( tfrm.getCol1(), tfrm.getCol2() ); + tmp1 = cross( tfrm.getCol2(), tfrm.getCol0() ); + tmp2 = cross( tfrm.getCol0(), tfrm.getCol1() ); + detinv = ( 1.0f / dot( tfrm.getCol2(), tmp2 ) ); + inv0 = Vector3( ( tmp0.getX() * detinv ), ( tmp1.getX() * detinv ), ( tmp2.getX() * detinv ) ); + inv1 = Vector3( ( tmp0.getY() * detinv ), ( tmp1.getY() * detinv ), ( tmp2.getY() * detinv ) ); + inv2 = Vector3( ( tmp0.getZ() * detinv ), ( tmp1.getZ() * detinv ), ( tmp2.getZ() * detinv ) ); + return Transform3( + inv0, + inv1, + inv2, + Vector3( ( -( ( inv0 * tfrm.getCol3().getX() ) + ( ( inv1 * tfrm.getCol3().getY() ) + ( inv2 * tfrm.getCol3().getZ() ) ) ) ) ) + ); +} + +inline const Transform3 orthoInverse( const Transform3 & tfrm ) +{ + Vector3 inv0, inv1, inv2; + inv0 = Vector3( tfrm.getCol0().getX(), tfrm.getCol1().getX(), tfrm.getCol2().getX() ); + inv1 = Vector3( tfrm.getCol0().getY(), tfrm.getCol1().getY(), tfrm.getCol2().getY() ); + inv2 = Vector3( tfrm.getCol0().getZ(), tfrm.getCol1().getZ(), tfrm.getCol2().getZ() ); + return Transform3( + inv0, + inv1, + inv2, + Vector3( ( -( ( inv0 * tfrm.getCol3().getX() ) + ( ( inv1 * tfrm.getCol3().getY() ) + ( inv2 * tfrm.getCol3().getZ() ) ) ) ) ) + ); +} + +inline const Transform3 absPerElem( const Transform3 & tfrm ) +{ + return Transform3( + absPerElem( tfrm.getCol0() ), + absPerElem( tfrm.getCol1() ), + absPerElem( tfrm.getCol2() ), + absPerElem( tfrm.getCol3() ) + ); +} + +inline const Vector3 Transform3::operator *( const Vector3 & vec ) const +{ + return Vector3( + ( ( ( mCol0.getX() * vec.getX() ) + ( mCol1.getX() * vec.getY() ) ) + ( mCol2.getX() * vec.getZ() ) ), + ( ( ( mCol0.getY() * vec.getX() ) + ( mCol1.getY() * vec.getY() ) ) + ( mCol2.getY() * vec.getZ() ) ), + ( ( ( mCol0.getZ() * vec.getX() ) + ( mCol1.getZ() * vec.getY() ) ) + ( mCol2.getZ() * vec.getZ() ) ) + ); +} + +inline const Point3 Transform3::operator *( const Point3 & pnt ) const +{ + return Point3( + ( ( ( ( mCol0.getX() * pnt.getX() ) + ( mCol1.getX() * pnt.getY() ) ) + ( mCol2.getX() * pnt.getZ() ) ) + mCol3.getX() ), + ( ( ( ( mCol0.getY() * pnt.getX() ) + ( mCol1.getY() * pnt.getY() ) ) + ( mCol2.getY() * pnt.getZ() ) ) + mCol3.getY() ), + ( ( ( ( mCol0.getZ() * pnt.getX() ) + ( mCol1.getZ() * pnt.getY() ) ) + ( mCol2.getZ() * pnt.getZ() ) ) + mCol3.getZ() ) + ); +} + +inline const Transform3 Transform3::operator *( const Transform3 & tfrm ) const +{ + return Transform3( + ( *this * tfrm.mCol0 ), + ( *this * tfrm.mCol1 ), + ( *this * tfrm.mCol2 ), + Vector3( ( *this * Point3( tfrm.mCol3 ) ) ) + ); +} + +inline Transform3 & Transform3::operator *=( const Transform3 & tfrm ) +{ + *this = *this * tfrm; + return *this; +} + +inline const Transform3 mulPerElem( const Transform3 & tfrm0, const Transform3 & tfrm1 ) +{ + return Transform3( + mulPerElem( tfrm0.getCol0(), tfrm1.getCol0() ), + mulPerElem( tfrm0.getCol1(), tfrm1.getCol1() ), + mulPerElem( tfrm0.getCol2(), tfrm1.getCol2() ), + mulPerElem( tfrm0.getCol3(), tfrm1.getCol3() ) + ); +} + +inline const Transform3 Transform3::identity( ) +{ + return Transform3( + Vector3::xAxis( ), + Vector3::yAxis( ), + Vector3::zAxis( ), + Vector3( 0.0f ) + ); +} + +inline Transform3 & Transform3::setUpper3x3( const Matrix3 & tfrm ) +{ + mCol0 = tfrm.getCol0(); + mCol1 = tfrm.getCol1(); + mCol2 = tfrm.getCol2(); + return *this; +} + +inline const Matrix3 Transform3::getUpper3x3( ) const +{ + return Matrix3( mCol0, mCol1, mCol2 ); +} + +inline Transform3 & Transform3::setTranslation( const Vector3 & translateVec ) +{ + mCol3 = translateVec; + return *this; +} + +inline const Vector3 Transform3::getTranslation( ) const +{ + return mCol3; +} + +inline const Transform3 Transform3::rotationX( float radians ) +{ + float s, c; + s = sinf( radians ); + c = cosf( radians ); + return Transform3( + Vector3::xAxis( ), + Vector3( 0.0f, c, s ), + Vector3( 0.0f, -s, c ), + Vector3( 0.0f ) + ); +} + +inline const Transform3 Transform3::rotationY( float radians ) +{ + float s, c; + s = sinf( radians ); + c = cosf( radians ); + return Transform3( + Vector3( c, 0.0f, -s ), + Vector3::yAxis( ), + Vector3( s, 0.0f, c ), + Vector3( 0.0f ) + ); +} + +inline const Transform3 Transform3::rotationZ( float radians ) +{ + float s, c; + s = sinf( radians ); + c = cosf( radians ); + return Transform3( + Vector3( c, s, 0.0f ), + Vector3( -s, c, 0.0f ), + Vector3::zAxis( ), + Vector3( 0.0f ) + ); +} + +inline const Transform3 Transform3::rotationZYX( const Vector3 & radiansXYZ ) +{ + float sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; + sX = sinf( radiansXYZ.getX() ); + cX = cosf( radiansXYZ.getX() ); + sY = sinf( radiansXYZ.getY() ); + cY = cosf( radiansXYZ.getY() ); + sZ = sinf( radiansXYZ.getZ() ); + cZ = cosf( radiansXYZ.getZ() ); + tmp0 = ( cZ * sY ); + tmp1 = ( sZ * sY ); + return Transform3( + Vector3( ( cZ * cY ), ( sZ * cY ), -sY ), + Vector3( ( ( tmp0 * sX ) - ( sZ * cX ) ), ( ( tmp1 * sX ) + ( cZ * cX ) ), ( cY * sX ) ), + Vector3( ( ( tmp0 * cX ) + ( sZ * sX ) ), ( ( tmp1 * cX ) - ( cZ * sX ) ), ( cY * cX ) ), + Vector3( 0.0f ) + ); +} + +inline const Transform3 Transform3::rotation( float radians, const Vector3 & unitVec ) +{ + return Transform3( Matrix3::rotation( radians, unitVec ), Vector3( 0.0f ) ); +} + +inline const Transform3 Transform3::rotation( const Quat & unitQuat ) +{ + return Transform3( Matrix3( unitQuat ), Vector3( 0.0f ) ); +} + +inline const Transform3 Transform3::scale( const Vector3 & scaleVec ) +{ + return Transform3( + Vector3( scaleVec.getX(), 0.0f, 0.0f ), + Vector3( 0.0f, scaleVec.getY(), 0.0f ), + Vector3( 0.0f, 0.0f, scaleVec.getZ() ), + Vector3( 0.0f ) + ); +} + +inline const Transform3 appendScale( const Transform3 & tfrm, const Vector3 & scaleVec ) +{ + return Transform3( + ( tfrm.getCol0() * scaleVec.getX( ) ), + ( tfrm.getCol1() * scaleVec.getY( ) ), + ( tfrm.getCol2() * scaleVec.getZ( ) ), + tfrm.getCol3() + ); +} + +inline const Transform3 prependScale( const Vector3 & scaleVec, const Transform3 & tfrm ) +{ + return Transform3( + mulPerElem( tfrm.getCol0(), scaleVec ), + mulPerElem( tfrm.getCol1(), scaleVec ), + mulPerElem( tfrm.getCol2(), scaleVec ), + mulPerElem( tfrm.getCol3(), scaleVec ) + ); +} + +inline const Transform3 Transform3::translation( const Vector3 & translateVec ) +{ + return Transform3( + Vector3::xAxis( ), + Vector3::yAxis( ), + Vector3::zAxis( ), + translateVec + ); +} + +inline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, bool select1 ) +{ + return Transform3( + select( tfrm0.getCol0(), tfrm1.getCol0(), select1 ), + select( tfrm0.getCol1(), tfrm1.getCol1(), select1 ), + select( tfrm0.getCol2(), tfrm1.getCol2(), select1 ), + select( tfrm0.getCol3(), tfrm1.getCol3(), select1 ) + ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( const Transform3 & tfrm ) +{ + print( tfrm.getRow( 0 ) ); + print( tfrm.getRow( 1 ) ); + print( tfrm.getRow( 2 ) ); +} + +inline void print( const Transform3 & tfrm, const char * name ) +{ + printf("%s:\n", name); + print( tfrm ); +} + +#endif + +inline Quat::Quat( const Matrix3 & tfrm ) +{ + float trace, radicand, scale, xx, yx, zx, xy, yy, zy, xz, yz, zz, tmpx, tmpy, tmpz, tmpw, qx, qy, qz, qw; + int negTrace, ZgtX, ZgtY, YgtX; + int largestXorY, largestYorZ, largestZorX; + + xx = tfrm.getCol0().getX(); + yx = tfrm.getCol0().getY(); + zx = tfrm.getCol0().getZ(); + xy = tfrm.getCol1().getX(); + yy = tfrm.getCol1().getY(); + zy = tfrm.getCol1().getZ(); + xz = tfrm.getCol2().getX(); + yz = tfrm.getCol2().getY(); + zz = tfrm.getCol2().getZ(); + + trace = ( ( xx + yy ) + zz ); + + negTrace = ( trace < 0.0f ); + ZgtX = zz > xx; + ZgtY = zz > yy; + YgtX = yy > xx; + largestXorY = ( !ZgtX || !ZgtY ) && negTrace; + largestYorZ = ( YgtX || ZgtX ) && negTrace; + largestZorX = ( ZgtY || !YgtX ) && negTrace; + + if ( largestXorY ) + { + zz = -zz; + xy = -xy; + } + if ( largestYorZ ) + { + xx = -xx; + yz = -yz; + } + if ( largestZorX ) + { + yy = -yy; + zx = -zx; + } + + radicand = ( ( ( xx + yy ) + zz ) + 1.0f ); + scale = ( 0.5f * ( 1.0f / sqrtf( radicand ) ) ); + + tmpx = ( ( zy - yz ) * scale ); + tmpy = ( ( xz - zx ) * scale ); + tmpz = ( ( yx - xy ) * scale ); + tmpw = ( radicand * scale ); + qx = tmpx; + qy = tmpy; + qz = tmpz; + qw = tmpw; + + if ( largestXorY ) + { + qx = tmpw; + qy = tmpz; + qz = tmpy; + qw = tmpx; + } + if ( largestYorZ ) + { + tmpx = qx; + tmpz = qz; + qx = qy; + qy = tmpx; + qz = qw; + qw = tmpz; + } + + mX = qx; + mY = qy; + mZ = qz; + mW = qw; +} + +inline const Matrix3 outer( const Vector3 & tfrm0, const Vector3 & tfrm1 ) +{ + return Matrix3( + ( tfrm0 * tfrm1.getX( ) ), + ( tfrm0 * tfrm1.getY( ) ), + ( tfrm0 * tfrm1.getZ( ) ) + ); +} + +inline const Matrix4 outer( const Vector4 & tfrm0, const Vector4 & tfrm1 ) +{ + return Matrix4( + ( tfrm0 * tfrm1.getX( ) ), + ( tfrm0 * tfrm1.getY( ) ), + ( tfrm0 * tfrm1.getZ( ) ), + ( tfrm0 * tfrm1.getW( ) ) + ); +} + +inline const Vector3 rowMul( const Vector3 & vec, const Matrix3 & mat ) +{ + return Vector3( + ( ( ( vec.getX() * mat.getCol0().getX() ) + ( vec.getY() * mat.getCol0().getY() ) ) + ( vec.getZ() * mat.getCol0().getZ() ) ), + ( ( ( vec.getX() * mat.getCol1().getX() ) + ( vec.getY() * mat.getCol1().getY() ) ) + ( vec.getZ() * mat.getCol1().getZ() ) ), + ( ( ( vec.getX() * mat.getCol2().getX() ) + ( vec.getY() * mat.getCol2().getY() ) ) + ( vec.getZ() * mat.getCol2().getZ() ) ) + ); +} + +inline const Matrix3 crossMatrix( const Vector3 & vec ) +{ + return Matrix3( + Vector3( 0.0f, vec.getZ(), -vec.getY() ), + Vector3( -vec.getZ(), 0.0f, vec.getX() ), + Vector3( vec.getY(), -vec.getX(), 0.0f ) + ); +} + +inline const Matrix3 crossMatrixMul( const Vector3 & vec, const Matrix3 & mat ) +{ + return Matrix3( cross( vec, mat.getCol0() ), cross( vec, mat.getCol1() ), cross( vec, mat.getCol2() ) ); +} + +} // namespace Aos +} // namespace Vectormath + +#endif diff --git a/vectormathlibrary/include/vectormath/scalar/cpp/quat_aos.h b/vectormathlibrary/include/vectormath/scalar/cpp/quat_aos.h new file mode 100644 index 000000000..7f1e8822b --- /dev/null +++ b/vectormathlibrary/include/vectormath/scalar/cpp/quat_aos.h @@ -0,0 +1,432 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_QUAT_AOS_CPP_H +#define _VECTORMATH_QUAT_AOS_CPP_H +//----------------------------------------------------------------------------- +// Definitions + +#ifndef _VECTORMATH_INTERNAL_FUNCTIONS +#define _VECTORMATH_INTERNAL_FUNCTIONS + +#endif + +namespace Vectormath { +namespace Aos { + +inline Quat::Quat( const Quat & quat ) +{ + mX = quat.mX; + mY = quat.mY; + mZ = quat.mZ; + mW = quat.mW; +} + +inline Quat::Quat( float _x, float _y, float _z, float _w ) +{ + mX = _x; + mY = _y; + mZ = _z; + mW = _w; +} + +inline Quat::Quat( const Vector3 & xyz, float _w ) +{ + this->setXYZ( xyz ); + this->setW( _w ); +} + +inline Quat::Quat( const Vector4 & vec ) +{ + mX = vec.getX(); + mY = vec.getY(); + mZ = vec.getZ(); + mW = vec.getW(); +} + +inline Quat::Quat( float scalar ) +{ + mX = scalar; + mY = scalar; + mZ = scalar; + mW = scalar; +} + +inline const Quat Quat::identity( ) +{ + return Quat( 0.0f, 0.0f, 0.0f, 1.0f ); +} + +inline const Quat lerp( float t, const Quat & quat0, const Quat & quat1 ) +{ + return ( quat0 + ( ( quat1 - quat0 ) * t ) ); +} + +inline const Quat slerp( float t, const Quat & unitQuat0, const Quat & unitQuat1 ) +{ + Quat start; + float recipSinAngle, scale0, scale1, cosAngle, angle; + cosAngle = dot( unitQuat0, unitQuat1 ); + if ( cosAngle < 0.0f ) { + cosAngle = -cosAngle; + start = ( -unitQuat0 ); + } else { + start = unitQuat0; + } + if ( cosAngle < _VECTORMATH_SLERP_TOL ) { + angle = acosf( cosAngle ); + recipSinAngle = ( 1.0f / sinf( angle ) ); + scale0 = ( sinf( ( ( 1.0f - t ) * angle ) ) * recipSinAngle ); + scale1 = ( sinf( ( t * angle ) ) * recipSinAngle ); + } else { + scale0 = ( 1.0f - t ); + scale1 = t; + } + return ( ( start * scale0 ) + ( unitQuat1 * scale1 ) ); +} + +inline const Quat squad( float t, const Quat & unitQuat0, const Quat & unitQuat1, const Quat & unitQuat2, const Quat & unitQuat3 ) +{ + Quat tmp0, tmp1; + tmp0 = slerp( t, unitQuat0, unitQuat3 ); + tmp1 = slerp( t, unitQuat1, unitQuat2 ); + return slerp( ( ( 2.0f * t ) * ( 1.0f - t ) ), tmp0, tmp1 ); +} + +inline Quat & Quat::operator =( const Quat & quat ) +{ + mX = quat.mX; + mY = quat.mY; + mZ = quat.mZ; + mW = quat.mW; + return *this; +} + +inline Quat & Quat::setXYZ( const Vector3 & vec ) +{ + mX = vec.getX(); + mY = vec.getY(); + mZ = vec.getZ(); + return *this; +} + +inline const Vector3 Quat::getXYZ( ) const +{ + return Vector3( mX, mY, mZ ); +} + +inline Quat & Quat::setX( float _x ) +{ + mX = _x; + return *this; +} + +inline float Quat::getX( ) const +{ + return mX; +} + +inline Quat & Quat::setY( float _y ) +{ + mY = _y; + return *this; +} + +inline float Quat::getY( ) const +{ + return mY; +} + +inline Quat & Quat::setZ( float _z ) +{ + mZ = _z; + return *this; +} + +inline float Quat::getZ( ) const +{ + return mZ; +} + +inline Quat & Quat::setW( float _w ) +{ + mW = _w; + return *this; +} + +inline float Quat::getW( ) const +{ + return mW; +} + +inline Quat & Quat::setElem( int idx, float value ) +{ + *(&mX + idx) = value; + return *this; +} + +inline float Quat::getElem( int idx ) const +{ + return *(&mX + idx); +} + +inline float & Quat::operator []( int idx ) +{ + return *(&mX + idx); +} + +inline float Quat::operator []( int idx ) const +{ + return *(&mX + idx); +} + +inline const Quat Quat::operator +( const Quat & quat ) const +{ + return Quat( + ( mX + quat.mX ), + ( mY + quat.mY ), + ( mZ + quat.mZ ), + ( mW + quat.mW ) + ); +} + +inline const Quat Quat::operator -( const Quat & quat ) const +{ + return Quat( + ( mX - quat.mX ), + ( mY - quat.mY ), + ( mZ - quat.mZ ), + ( mW - quat.mW ) + ); +} + +inline const Quat Quat::operator *( float scalar ) const +{ + return Quat( + ( mX * scalar ), + ( mY * scalar ), + ( mZ * scalar ), + ( mW * scalar ) + ); +} + +inline Quat & Quat::operator +=( const Quat & quat ) +{ + *this = *this + quat; + return *this; +} + +inline Quat & Quat::operator -=( const Quat & quat ) +{ + *this = *this - quat; + return *this; +} + +inline Quat & Quat::operator *=( float scalar ) +{ + *this = *this * scalar; + return *this; +} + +inline const Quat Quat::operator /( float scalar ) const +{ + return Quat( + ( mX / scalar ), + ( mY / scalar ), + ( mZ / scalar ), + ( mW / scalar ) + ); +} + +inline Quat & Quat::operator /=( float scalar ) +{ + *this = *this / scalar; + return *this; +} + +inline const Quat Quat::operator -( ) const +{ + return Quat( + -mX, + -mY, + -mZ, + -mW + ); +} + +inline const Quat operator *( float scalar, const Quat & quat ) +{ + return quat * scalar; +} + +inline float dot( const Quat & quat0, const Quat & quat1 ) +{ + float result; + result = ( quat0.getX() * quat1.getX() ); + result = ( result + ( quat0.getY() * quat1.getY() ) ); + result = ( result + ( quat0.getZ() * quat1.getZ() ) ); + result = ( result + ( quat0.getW() * quat1.getW() ) ); + return result; +} + +inline float norm( const Quat & quat ) +{ + float result; + result = ( quat.getX() * quat.getX() ); + result = ( result + ( quat.getY() * quat.getY() ) ); + result = ( result + ( quat.getZ() * quat.getZ() ) ); + result = ( result + ( quat.getW() * quat.getW() ) ); + return result; +} + +inline float length( const Quat & quat ) +{ + return sqrtf( norm( quat ) ); +} + +inline const Quat normalize( const Quat & quat ) +{ + float lenSqr, lenInv; + lenSqr = norm( quat ); + lenInv = ( 1.0f / sqrtf( lenSqr ) ); + return Quat( + ( quat.getX() * lenInv ), + ( quat.getY() * lenInv ), + ( quat.getZ() * lenInv ), + ( quat.getW() * lenInv ) + ); +} + +inline const Quat Quat::rotation( const Vector3 & unitVec0, const Vector3 & unitVec1 ) +{ + float cosHalfAngleX2, recipCosHalfAngleX2; + cosHalfAngleX2 = sqrtf( ( 2.0f * ( 1.0f + dot( unitVec0, unitVec1 ) ) ) ); + recipCosHalfAngleX2 = ( 1.0f / cosHalfAngleX2 ); + return Quat( ( cross( unitVec0, unitVec1 ) * recipCosHalfAngleX2 ), ( cosHalfAngleX2 * 0.5f ) ); +} + +inline const Quat Quat::rotation( float radians, const Vector3 & unitVec ) +{ + float s, c, angle; + angle = ( radians * 0.5f ); + s = sinf( angle ); + c = cosf( angle ); + return Quat( ( unitVec * s ), c ); +} + +inline const Quat Quat::rotationX( float radians ) +{ + float s, c, angle; + angle = ( radians * 0.5f ); + s = sinf( angle ); + c = cosf( angle ); + return Quat( s, 0.0f, 0.0f, c ); +} + +inline const Quat Quat::rotationY( float radians ) +{ + float s, c, angle; + angle = ( radians * 0.5f ); + s = sinf( angle ); + c = cosf( angle ); + return Quat( 0.0f, s, 0.0f, c ); +} + +inline const Quat Quat::rotationZ( float radians ) +{ + float s, c, angle; + angle = ( radians * 0.5f ); + s = sinf( angle ); + c = cosf( angle ); + return Quat( 0.0f, 0.0f, s, c ); +} + +inline const Quat Quat::operator *( const Quat & quat ) const +{ + return Quat( + ( ( ( ( mW * quat.mX ) + ( mX * quat.mW ) ) + ( mY * quat.mZ ) ) - ( mZ * quat.mY ) ), + ( ( ( ( mW * quat.mY ) + ( mY * quat.mW ) ) + ( mZ * quat.mX ) ) - ( mX * quat.mZ ) ), + ( ( ( ( mW * quat.mZ ) + ( mZ * quat.mW ) ) + ( mX * quat.mY ) ) - ( mY * quat.mX ) ), + ( ( ( ( mW * quat.mW ) - ( mX * quat.mX ) ) - ( mY * quat.mY ) ) - ( mZ * quat.mZ ) ) + ); +} + +inline Quat & Quat::operator *=( const Quat & quat ) +{ + *this = *this * quat; + return *this; +} + +inline const Vector3 rotate( const Quat & quat, const Vector3 & vec ) +{ + float tmpX, tmpY, tmpZ, tmpW; + tmpX = ( ( ( quat.getW() * vec.getX() ) + ( quat.getY() * vec.getZ() ) ) - ( quat.getZ() * vec.getY() ) ); + tmpY = ( ( ( quat.getW() * vec.getY() ) + ( quat.getZ() * vec.getX() ) ) - ( quat.getX() * vec.getZ() ) ); + tmpZ = ( ( ( quat.getW() * vec.getZ() ) + ( quat.getX() * vec.getY() ) ) - ( quat.getY() * vec.getX() ) ); + tmpW = ( ( ( quat.getX() * vec.getX() ) + ( quat.getY() * vec.getY() ) ) + ( quat.getZ() * vec.getZ() ) ); + return Vector3( + ( ( ( ( tmpW * quat.getX() ) + ( tmpX * quat.getW() ) ) - ( tmpY * quat.getZ() ) ) + ( tmpZ * quat.getY() ) ), + ( ( ( ( tmpW * quat.getY() ) + ( tmpY * quat.getW() ) ) - ( tmpZ * quat.getX() ) ) + ( tmpX * quat.getZ() ) ), + ( ( ( ( tmpW * quat.getZ() ) + ( tmpZ * quat.getW() ) ) - ( tmpX * quat.getY() ) ) + ( tmpY * quat.getX() ) ) + ); +} + +inline const Quat conj( const Quat & quat ) +{ + return Quat( -quat.getX(), -quat.getY(), -quat.getZ(), quat.getW() ); +} + +inline const Quat select( const Quat & quat0, const Quat & quat1, bool select1 ) +{ + return Quat( + ( select1 )? quat1.getX() : quat0.getX(), + ( select1 )? quat1.getY() : quat0.getY(), + ( select1 )? quat1.getZ() : quat0.getZ(), + ( select1 )? quat1.getW() : quat0.getW() + ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( const Quat & quat ) +{ + printf( "( %f %f %f %f )\n", quat.getX(), quat.getY(), quat.getZ(), quat.getW() ); +} + +inline void print( const Quat & quat, const char * name ) +{ + printf( "%s: ( %f %f %f %f )\n", name, quat.getX(), quat.getY(), quat.getZ(), quat.getW() ); +} + +#endif + +} // namespace Aos +} // namespace Vectormath + +#endif diff --git a/vectormathlibrary/include/vectormath/scalar/cpp/vec_aos.h b/vectormathlibrary/include/vectormath/scalar/cpp/vec_aos.h new file mode 100644 index 000000000..a1a75333a --- /dev/null +++ b/vectormathlibrary/include/vectormath/scalar/cpp/vec_aos.h @@ -0,0 +1,1173 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_VEC_AOS_CPP_H +#define _VECTORMATH_VEC_AOS_CPP_H +//----------------------------------------------------------------------------- +// Constants + +#define _VECTORMATH_SLERP_TOL 0.999f + +//----------------------------------------------------------------------------- +// Definitions + +#ifndef _VECTORMATH_INTERNAL_FUNCTIONS +#define _VECTORMATH_INTERNAL_FUNCTIONS + +#endif + +namespace Vectormath { +namespace Aos { + +inline Vector3::Vector3( const Vector3 & vec ) +{ + mX = vec.mX; + mY = vec.mY; + mZ = vec.mZ; +} + +inline Vector3::Vector3( float _x, float _y, float _z ) +{ + mX = _x; + mY = _y; + mZ = _z; +} + +inline Vector3::Vector3( const Point3 & pnt ) +{ + mX = pnt.getX(); + mY = pnt.getY(); + mZ = pnt.getZ(); +} + +inline Vector3::Vector3( float scalar ) +{ + mX = scalar; + mY = scalar; + mZ = scalar; +} + +inline const Vector3 Vector3::xAxis( ) +{ + return Vector3( 1.0f, 0.0f, 0.0f ); +} + +inline const Vector3 Vector3::yAxis( ) +{ + return Vector3( 0.0f, 1.0f, 0.0f ); +} + +inline const Vector3 Vector3::zAxis( ) +{ + return Vector3( 0.0f, 0.0f, 1.0f ); +} + +inline const Vector3 lerp( float t, const Vector3 & vec0, const Vector3 & vec1 ) +{ + return ( vec0 + ( ( vec1 - vec0 ) * t ) ); +} + +inline const Vector3 slerp( float t, const Vector3 & unitVec0, const Vector3 & unitVec1 ) +{ + float recipSinAngle, scale0, scale1, cosAngle, angle; + cosAngle = dot( unitVec0, unitVec1 ); + if ( cosAngle < _VECTORMATH_SLERP_TOL ) { + angle = acosf( cosAngle ); + recipSinAngle = ( 1.0f / sinf( angle ) ); + scale0 = ( sinf( ( ( 1.0f - t ) * angle ) ) * recipSinAngle ); + scale1 = ( sinf( ( t * angle ) ) * recipSinAngle ); + } else { + scale0 = ( 1.0f - t ); + scale1 = t; + } + return ( ( unitVec0 * scale0 ) + ( unitVec1 * scale1 ) ); +} + +inline Vector3 & Vector3::operator =( const Vector3 & vec ) +{ + mX = vec.mX; + mY = vec.mY; + mZ = vec.mZ; + return *this; +} + +inline Vector3 & Vector3::setX( float _x ) +{ + mX = _x; + return *this; +} + +inline float Vector3::getX( ) const +{ + return mX; +} + +inline Vector3 & Vector3::setY( float _y ) +{ + mY = _y; + return *this; +} + +inline float Vector3::getY( ) const +{ + return mY; +} + +inline Vector3 & Vector3::setZ( float _z ) +{ + mZ = _z; + return *this; +} + +inline float Vector3::getZ( ) const +{ + return mZ; +} + +inline Vector3 & Vector3::setElem( int idx, float value ) +{ + *(&mX + idx) = value; + return *this; +} + +inline float Vector3::getElem( int idx ) const +{ + return *(&mX + idx); +} + +inline float & Vector3::operator []( int idx ) +{ + return *(&mX + idx); +} + +inline float Vector3::operator []( int idx ) const +{ + return *(&mX + idx); +} + +inline const Vector3 Vector3::operator +( const Vector3 & vec ) const +{ + return Vector3( + ( mX + vec.mX ), + ( mY + vec.mY ), + ( mZ + vec.mZ ) + ); +} + +inline const Vector3 Vector3::operator -( const Vector3 & vec ) const +{ + return Vector3( + ( mX - vec.mX ), + ( mY - vec.mY ), + ( mZ - vec.mZ ) + ); +} + +inline const Point3 Vector3::operator +( const Point3 & pnt ) const +{ + return Point3( + ( mX + pnt.getX() ), + ( mY + pnt.getY() ), + ( mZ + pnt.getZ() ) + ); +} + +inline const Vector3 Vector3::operator *( float scalar ) const +{ + return Vector3( + ( mX * scalar ), + ( mY * scalar ), + ( mZ * scalar ) + ); +} + +inline Vector3 & Vector3::operator +=( const Vector3 & vec ) +{ + *this = *this + vec; + return *this; +} + +inline Vector3 & Vector3::operator -=( const Vector3 & vec ) +{ + *this = *this - vec; + return *this; +} + +inline Vector3 & Vector3::operator *=( float scalar ) +{ + *this = *this * scalar; + return *this; +} + +inline const Vector3 Vector3::operator /( float scalar ) const +{ + return Vector3( + ( mX / scalar ), + ( mY / scalar ), + ( mZ / scalar ) + ); +} + +inline Vector3 & Vector3::operator /=( float scalar ) +{ + *this = *this / scalar; + return *this; +} + +inline const Vector3 Vector3::operator -( ) const +{ + return Vector3( + -mX, + -mY, + -mZ + ); +} + +inline const Vector3 operator *( float scalar, const Vector3 & vec ) +{ + return vec * scalar; +} + +inline const Vector3 mulPerElem( const Vector3 & vec0, const Vector3 & vec1 ) +{ + return Vector3( + ( vec0.getX() * vec1.getX() ), + ( vec0.getY() * vec1.getY() ), + ( vec0.getZ() * vec1.getZ() ) + ); +} + +inline const Vector3 divPerElem( const Vector3 & vec0, const Vector3 & vec1 ) +{ + return Vector3( + ( vec0.getX() / vec1.getX() ), + ( vec0.getY() / vec1.getY() ), + ( vec0.getZ() / vec1.getZ() ) + ); +} + +inline const Vector3 recipPerElem( const Vector3 & vec ) +{ + return Vector3( + ( 1.0f / vec.getX() ), + ( 1.0f / vec.getY() ), + ( 1.0f / vec.getZ() ) + ); +} + +inline const Vector3 sqrtPerElem( const Vector3 & vec ) +{ + return Vector3( + sqrtf( vec.getX() ), + sqrtf( vec.getY() ), + sqrtf( vec.getZ() ) + ); +} + +inline const Vector3 rsqrtPerElem( const Vector3 & vec ) +{ + return Vector3( + ( 1.0f / sqrtf( vec.getX() ) ), + ( 1.0f / sqrtf( vec.getY() ) ), + ( 1.0f / sqrtf( vec.getZ() ) ) + ); +} + +inline const Vector3 absPerElem( const Vector3 & vec ) +{ + return Vector3( + fabsf( vec.getX() ), + fabsf( vec.getY() ), + fabsf( vec.getZ() ) + ); +} + +inline const Vector3 copySignPerElem( const Vector3 & vec0, const Vector3 & vec1 ) +{ + return Vector3( + ( vec1.getX() < 0.0f )? -fabsf( vec0.getX() ) : fabsf( vec0.getX() ), + ( vec1.getY() < 0.0f )? -fabsf( vec0.getY() ) : fabsf( vec0.getY() ), + ( vec1.getZ() < 0.0f )? -fabsf( vec0.getZ() ) : fabsf( vec0.getZ() ) + ); +} + +inline const Vector3 maxPerElem( const Vector3 & vec0, const Vector3 & vec1 ) +{ + return Vector3( + (vec0.getX() > vec1.getX())? vec0.getX() : vec1.getX(), + (vec0.getY() > vec1.getY())? vec0.getY() : vec1.getY(), + (vec0.getZ() > vec1.getZ())? vec0.getZ() : vec1.getZ() + ); +} + +inline float maxElem( const Vector3 & vec ) +{ + float result; + result = (vec.getX() > vec.getY())? vec.getX() : vec.getY(); + result = (vec.getZ() > result)? vec.getZ() : result; + return result; +} + +inline const Vector3 minPerElem( const Vector3 & vec0, const Vector3 & vec1 ) +{ + return Vector3( + (vec0.getX() < vec1.getX())? vec0.getX() : vec1.getX(), + (vec0.getY() < vec1.getY())? vec0.getY() : vec1.getY(), + (vec0.getZ() < vec1.getZ())? vec0.getZ() : vec1.getZ() + ); +} + +inline float minElem( const Vector3 & vec ) +{ + float result; + result = (vec.getX() < vec.getY())? vec.getX() : vec.getY(); + result = (vec.getZ() < result)? vec.getZ() : result; + return result; +} + +inline float sum( const Vector3 & vec ) +{ + float result; + result = ( vec.getX() + vec.getY() ); + result = ( result + vec.getZ() ); + return result; +} + +inline float dot( const Vector3 & vec0, const Vector3 & vec1 ) +{ + float result; + result = ( vec0.getX() * vec1.getX() ); + result = ( result + ( vec0.getY() * vec1.getY() ) ); + result = ( result + ( vec0.getZ() * vec1.getZ() ) ); + return result; +} + +inline float lengthSqr( const Vector3 & vec ) +{ + float result; + result = ( vec.getX() * vec.getX() ); + result = ( result + ( vec.getY() * vec.getY() ) ); + result = ( result + ( vec.getZ() * vec.getZ() ) ); + return result; +} + +inline float length( const Vector3 & vec ) +{ + return sqrtf( lengthSqr( vec ) ); +} + +inline const Vector3 normalize( const Vector3 & vec ) +{ + float lenSqr, lenInv; + lenSqr = lengthSqr( vec ); + lenInv = ( 1.0f / sqrtf( lenSqr ) ); + return Vector3( + ( vec.getX() * lenInv ), + ( vec.getY() * lenInv ), + ( vec.getZ() * lenInv ) + ); +} + +inline const Vector3 cross( const Vector3 & vec0, const Vector3 & vec1 ) +{ + return Vector3( + ( ( vec0.getY() * vec1.getZ() ) - ( vec0.getZ() * vec1.getY() ) ), + ( ( vec0.getZ() * vec1.getX() ) - ( vec0.getX() * vec1.getZ() ) ), + ( ( vec0.getX() * vec1.getY() ) - ( vec0.getY() * vec1.getX() ) ) + ); +} + +inline const Vector3 select( const Vector3 & vec0, const Vector3 & vec1, bool select1 ) +{ + return Vector3( + ( select1 )? vec1.getX() : vec0.getX(), + ( select1 )? vec1.getY() : vec0.getY(), + ( select1 )? vec1.getZ() : vec0.getZ() + ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( const Vector3 & vec ) +{ + printf( "( %f %f %f )\n", vec.getX(), vec.getY(), vec.getZ() ); +} + +inline void print( const Vector3 & vec, const char * name ) +{ + printf( "%s: ( %f %f %f )\n", name, vec.getX(), vec.getY(), vec.getZ() ); +} + +#endif + +inline Vector4::Vector4( const Vector4 & vec ) +{ + mX = vec.mX; + mY = vec.mY; + mZ = vec.mZ; + mW = vec.mW; +} + +inline Vector4::Vector4( float _x, float _y, float _z, float _w ) +{ + mX = _x; + mY = _y; + mZ = _z; + mW = _w; +} + +inline Vector4::Vector4( const Vector3 & xyz, float _w ) +{ + this->setXYZ( xyz ); + this->setW( _w ); +} + +inline Vector4::Vector4( const Vector3 & vec ) +{ + mX = vec.getX(); + mY = vec.getY(); + mZ = vec.getZ(); + mW = 0.0f; +} + +inline Vector4::Vector4( const Point3 & pnt ) +{ + mX = pnt.getX(); + mY = pnt.getY(); + mZ = pnt.getZ(); + mW = 1.0f; +} + +inline Vector4::Vector4( const Quat & quat ) +{ + mX = quat.getX(); + mY = quat.getY(); + mZ = quat.getZ(); + mW = quat.getW(); +} + +inline Vector4::Vector4( float scalar ) +{ + mX = scalar; + mY = scalar; + mZ = scalar; + mW = scalar; +} + +inline const Vector4 Vector4::xAxis( ) +{ + return Vector4( 1.0f, 0.0f, 0.0f, 0.0f ); +} + +inline const Vector4 Vector4::yAxis( ) +{ + return Vector4( 0.0f, 1.0f, 0.0f, 0.0f ); +} + +inline const Vector4 Vector4::zAxis( ) +{ + return Vector4( 0.0f, 0.0f, 1.0f, 0.0f ); +} + +inline const Vector4 Vector4::wAxis( ) +{ + return Vector4( 0.0f, 0.0f, 0.0f, 1.0f ); +} + +inline const Vector4 lerp( float t, const Vector4 & vec0, const Vector4 & vec1 ) +{ + return ( vec0 + ( ( vec1 - vec0 ) * t ) ); +} + +inline const Vector4 slerp( float t, const Vector4 & unitVec0, const Vector4 & unitVec1 ) +{ + float recipSinAngle, scale0, scale1, cosAngle, angle; + cosAngle = dot( unitVec0, unitVec1 ); + if ( cosAngle < _VECTORMATH_SLERP_TOL ) { + angle = acosf( cosAngle ); + recipSinAngle = ( 1.0f / sinf( angle ) ); + scale0 = ( sinf( ( ( 1.0f - t ) * angle ) ) * recipSinAngle ); + scale1 = ( sinf( ( t * angle ) ) * recipSinAngle ); + } else { + scale0 = ( 1.0f - t ); + scale1 = t; + } + return ( ( unitVec0 * scale0 ) + ( unitVec1 * scale1 ) ); +} + +inline Vector4 & Vector4::operator =( const Vector4 & vec ) +{ + mX = vec.mX; + mY = vec.mY; + mZ = vec.mZ; + mW = vec.mW; + return *this; +} + +inline Vector4 & Vector4::setXYZ( const Vector3 & vec ) +{ + mX = vec.getX(); + mY = vec.getY(); + mZ = vec.getZ(); + return *this; +} + +inline const Vector3 Vector4::getXYZ( ) const +{ + return Vector3( mX, mY, mZ ); +} + +inline Vector4 & Vector4::setX( float _x ) +{ + mX = _x; + return *this; +} + +inline float Vector4::getX( ) const +{ + return mX; +} + +inline Vector4 & Vector4::setY( float _y ) +{ + mY = _y; + return *this; +} + +inline float Vector4::getY( ) const +{ + return mY; +} + +inline Vector4 & Vector4::setZ( float _z ) +{ + mZ = _z; + return *this; +} + +inline float Vector4::getZ( ) const +{ + return mZ; +} + +inline Vector4 & Vector4::setW( float _w ) +{ + mW = _w; + return *this; +} + +inline float Vector4::getW( ) const +{ + return mW; +} + +inline Vector4 & Vector4::setElem( int idx, float value ) +{ + *(&mX + idx) = value; + return *this; +} + +inline float Vector4::getElem( int idx ) const +{ + return *(&mX + idx); +} + +inline float & Vector4::operator []( int idx ) +{ + return *(&mX + idx); +} + +inline float Vector4::operator []( int idx ) const +{ + return *(&mX + idx); +} + +inline const Vector4 Vector4::operator +( const Vector4 & vec ) const +{ + return Vector4( + ( mX + vec.mX ), + ( mY + vec.mY ), + ( mZ + vec.mZ ), + ( mW + vec.mW ) + ); +} + +inline const Vector4 Vector4::operator -( const Vector4 & vec ) const +{ + return Vector4( + ( mX - vec.mX ), + ( mY - vec.mY ), + ( mZ - vec.mZ ), + ( mW - vec.mW ) + ); +} + +inline const Vector4 Vector4::operator *( float scalar ) const +{ + return Vector4( + ( mX * scalar ), + ( mY * scalar ), + ( mZ * scalar ), + ( mW * scalar ) + ); +} + +inline Vector4 & Vector4::operator +=( const Vector4 & vec ) +{ + *this = *this + vec; + return *this; +} + +inline Vector4 & Vector4::operator -=( const Vector4 & vec ) +{ + *this = *this - vec; + return *this; +} + +inline Vector4 & Vector4::operator *=( float scalar ) +{ + *this = *this * scalar; + return *this; +} + +inline const Vector4 Vector4::operator /( float scalar ) const +{ + return Vector4( + ( mX / scalar ), + ( mY / scalar ), + ( mZ / scalar ), + ( mW / scalar ) + ); +} + +inline Vector4 & Vector4::operator /=( float scalar ) +{ + *this = *this / scalar; + return *this; +} + +inline const Vector4 Vector4::operator -( ) const +{ + return Vector4( + -mX, + -mY, + -mZ, + -mW + ); +} + +inline const Vector4 operator *( float scalar, const Vector4 & vec ) +{ + return vec * scalar; +} + +inline const Vector4 mulPerElem( const Vector4 & vec0, const Vector4 & vec1 ) +{ + return Vector4( + ( vec0.getX() * vec1.getX() ), + ( vec0.getY() * vec1.getY() ), + ( vec0.getZ() * vec1.getZ() ), + ( vec0.getW() * vec1.getW() ) + ); +} + +inline const Vector4 divPerElem( const Vector4 & vec0, const Vector4 & vec1 ) +{ + return Vector4( + ( vec0.getX() / vec1.getX() ), + ( vec0.getY() / vec1.getY() ), + ( vec0.getZ() / vec1.getZ() ), + ( vec0.getW() / vec1.getW() ) + ); +} + +inline const Vector4 recipPerElem( const Vector4 & vec ) +{ + return Vector4( + ( 1.0f / vec.getX() ), + ( 1.0f / vec.getY() ), + ( 1.0f / vec.getZ() ), + ( 1.0f / vec.getW() ) + ); +} + +inline const Vector4 sqrtPerElem( const Vector4 & vec ) +{ + return Vector4( + sqrtf( vec.getX() ), + sqrtf( vec.getY() ), + sqrtf( vec.getZ() ), + sqrtf( vec.getW() ) + ); +} + +inline const Vector4 rsqrtPerElem( const Vector4 & vec ) +{ + return Vector4( + ( 1.0f / sqrtf( vec.getX() ) ), + ( 1.0f / sqrtf( vec.getY() ) ), + ( 1.0f / sqrtf( vec.getZ() ) ), + ( 1.0f / sqrtf( vec.getW() ) ) + ); +} + +inline const Vector4 absPerElem( const Vector4 & vec ) +{ + return Vector4( + fabsf( vec.getX() ), + fabsf( vec.getY() ), + fabsf( vec.getZ() ), + fabsf( vec.getW() ) + ); +} + +inline const Vector4 copySignPerElem( const Vector4 & vec0, const Vector4 & vec1 ) +{ + return Vector4( + ( vec1.getX() < 0.0f )? -fabsf( vec0.getX() ) : fabsf( vec0.getX() ), + ( vec1.getY() < 0.0f )? -fabsf( vec0.getY() ) : fabsf( vec0.getY() ), + ( vec1.getZ() < 0.0f )? -fabsf( vec0.getZ() ) : fabsf( vec0.getZ() ), + ( vec1.getW() < 0.0f )? -fabsf( vec0.getW() ) : fabsf( vec0.getW() ) + ); +} + +inline const Vector4 maxPerElem( const Vector4 & vec0, const Vector4 & vec1 ) +{ + return Vector4( + (vec0.getX() > vec1.getX())? vec0.getX() : vec1.getX(), + (vec0.getY() > vec1.getY())? vec0.getY() : vec1.getY(), + (vec0.getZ() > vec1.getZ())? vec0.getZ() : vec1.getZ(), + (vec0.getW() > vec1.getW())? vec0.getW() : vec1.getW() + ); +} + +inline float maxElem( const Vector4 & vec ) +{ + float result; + result = (vec.getX() > vec.getY())? vec.getX() : vec.getY(); + result = (vec.getZ() > result)? vec.getZ() : result; + result = (vec.getW() > result)? vec.getW() : result; + return result; +} + +inline const Vector4 minPerElem( const Vector4 & vec0, const Vector4 & vec1 ) +{ + return Vector4( + (vec0.getX() < vec1.getX())? vec0.getX() : vec1.getX(), + (vec0.getY() < vec1.getY())? vec0.getY() : vec1.getY(), + (vec0.getZ() < vec1.getZ())? vec0.getZ() : vec1.getZ(), + (vec0.getW() < vec1.getW())? vec0.getW() : vec1.getW() + ); +} + +inline float minElem( const Vector4 & vec ) +{ + float result; + result = (vec.getX() < vec.getY())? vec.getX() : vec.getY(); + result = (vec.getZ() < result)? vec.getZ() : result; + result = (vec.getW() < result)? vec.getW() : result; + return result; +} + +inline float sum( const Vector4 & vec ) +{ + float result; + result = ( vec.getX() + vec.getY() ); + result = ( result + vec.getZ() ); + result = ( result + vec.getW() ); + return result; +} + +inline float dot( const Vector4 & vec0, const Vector4 & vec1 ) +{ + float result; + result = ( vec0.getX() * vec1.getX() ); + result = ( result + ( vec0.getY() * vec1.getY() ) ); + result = ( result + ( vec0.getZ() * vec1.getZ() ) ); + result = ( result + ( vec0.getW() * vec1.getW() ) ); + return result; +} + +inline float lengthSqr( const Vector4 & vec ) +{ + float result; + result = ( vec.getX() * vec.getX() ); + result = ( result + ( vec.getY() * vec.getY() ) ); + result = ( result + ( vec.getZ() * vec.getZ() ) ); + result = ( result + ( vec.getW() * vec.getW() ) ); + return result; +} + +inline float length( const Vector4 & vec ) +{ + return sqrtf( lengthSqr( vec ) ); +} + +inline const Vector4 normalize( const Vector4 & vec ) +{ + float lenSqr, lenInv; + lenSqr = lengthSqr( vec ); + lenInv = ( 1.0f / sqrtf( lenSqr ) ); + return Vector4( + ( vec.getX() * lenInv ), + ( vec.getY() * lenInv ), + ( vec.getZ() * lenInv ), + ( vec.getW() * lenInv ) + ); +} + +inline const Vector4 select( const Vector4 & vec0, const Vector4 & vec1, bool select1 ) +{ + return Vector4( + ( select1 )? vec1.getX() : vec0.getX(), + ( select1 )? vec1.getY() : vec0.getY(), + ( select1 )? vec1.getZ() : vec0.getZ(), + ( select1 )? vec1.getW() : vec0.getW() + ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( const Vector4 & vec ) +{ + printf( "( %f %f %f %f )\n", vec.getX(), vec.getY(), vec.getZ(), vec.getW() ); +} + +inline void print( const Vector4 & vec, const char * name ) +{ + printf( "%s: ( %f %f %f %f )\n", name, vec.getX(), vec.getY(), vec.getZ(), vec.getW() ); +} + +#endif + +inline Point3::Point3( const Point3 & pnt ) +{ + mX = pnt.mX; + mY = pnt.mY; + mZ = pnt.mZ; +} + +inline Point3::Point3( float _x, float _y, float _z ) +{ + mX = _x; + mY = _y; + mZ = _z; +} + +inline Point3::Point3( const Vector3 & vec ) +{ + mX = vec.getX(); + mY = vec.getY(); + mZ = vec.getZ(); +} + +inline Point3::Point3( float scalar ) +{ + mX = scalar; + mY = scalar; + mZ = scalar; +} + +inline const Point3 lerp( float t, const Point3 & pnt0, const Point3 & pnt1 ) +{ + return ( pnt0 + ( ( pnt1 - pnt0 ) * t ) ); +} + +inline Point3 & Point3::operator =( const Point3 & pnt ) +{ + mX = pnt.mX; + mY = pnt.mY; + mZ = pnt.mZ; + return *this; +} + +inline Point3 & Point3::setX( float _x ) +{ + mX = _x; + return *this; +} + +inline float Point3::getX( ) const +{ + return mX; +} + +inline Point3 & Point3::setY( float _y ) +{ + mY = _y; + return *this; +} + +inline float Point3::getY( ) const +{ + return mY; +} + +inline Point3 & Point3::setZ( float _z ) +{ + mZ = _z; + return *this; +} + +inline float Point3::getZ( ) const +{ + return mZ; +} + +inline Point3 & Point3::setElem( int idx, float value ) +{ + *(&mX + idx) = value; + return *this; +} + +inline float Point3::getElem( int idx ) const +{ + return *(&mX + idx); +} + +inline float & Point3::operator []( int idx ) +{ + return *(&mX + idx); +} + +inline float Point3::operator []( int idx ) const +{ + return *(&mX + idx); +} + +inline const Vector3 Point3::operator -( const Point3 & pnt ) const +{ + return Vector3( + ( mX - pnt.mX ), + ( mY - pnt.mY ), + ( mZ - pnt.mZ ) + ); +} + +inline const Point3 Point3::operator +( const Vector3 & vec ) const +{ + return Point3( + ( mX + vec.getX() ), + ( mY + vec.getY() ), + ( mZ + vec.getZ() ) + ); +} + +inline const Point3 Point3::operator -( const Vector3 & vec ) const +{ + return Point3( + ( mX - vec.getX() ), + ( mY - vec.getY() ), + ( mZ - vec.getZ() ) + ); +} + +inline Point3 & Point3::operator +=( const Vector3 & vec ) +{ + *this = *this + vec; + return *this; +} + +inline Point3 & Point3::operator -=( const Vector3 & vec ) +{ + *this = *this - vec; + return *this; +} + +inline const Point3 mulPerElem( const Point3 & pnt0, const Point3 & pnt1 ) +{ + return Point3( + ( pnt0.getX() * pnt1.getX() ), + ( pnt0.getY() * pnt1.getY() ), + ( pnt0.getZ() * pnt1.getZ() ) + ); +} + +inline const Point3 divPerElem( const Point3 & pnt0, const Point3 & pnt1 ) +{ + return Point3( + ( pnt0.getX() / pnt1.getX() ), + ( pnt0.getY() / pnt1.getY() ), + ( pnt0.getZ() / pnt1.getZ() ) + ); +} + +inline const Point3 recipPerElem( const Point3 & pnt ) +{ + return Point3( + ( 1.0f / pnt.getX() ), + ( 1.0f / pnt.getY() ), + ( 1.0f / pnt.getZ() ) + ); +} + +inline const Point3 sqrtPerElem( const Point3 & pnt ) +{ + return Point3( + sqrtf( pnt.getX() ), + sqrtf( pnt.getY() ), + sqrtf( pnt.getZ() ) + ); +} + +inline const Point3 rsqrtPerElem( const Point3 & pnt ) +{ + return Point3( + ( 1.0f / sqrtf( pnt.getX() ) ), + ( 1.0f / sqrtf( pnt.getY() ) ), + ( 1.0f / sqrtf( pnt.getZ() ) ) + ); +} + +inline const Point3 absPerElem( const Point3 & pnt ) +{ + return Point3( + fabsf( pnt.getX() ), + fabsf( pnt.getY() ), + fabsf( pnt.getZ() ) + ); +} + +inline const Point3 copySignPerElem( const Point3 & pnt0, const Point3 & pnt1 ) +{ + return Point3( + ( pnt1.getX() < 0.0f )? -fabsf( pnt0.getX() ) : fabsf( pnt0.getX() ), + ( pnt1.getY() < 0.0f )? -fabsf( pnt0.getY() ) : fabsf( pnt0.getY() ), + ( pnt1.getZ() < 0.0f )? -fabsf( pnt0.getZ() ) : fabsf( pnt0.getZ() ) + ); +} + +inline const Point3 maxPerElem( const Point3 & pnt0, const Point3 & pnt1 ) +{ + return Point3( + (pnt0.getX() > pnt1.getX())? pnt0.getX() : pnt1.getX(), + (pnt0.getY() > pnt1.getY())? pnt0.getY() : pnt1.getY(), + (pnt0.getZ() > pnt1.getZ())? pnt0.getZ() : pnt1.getZ() + ); +} + +inline float maxElem( const Point3 & pnt ) +{ + float result; + result = (pnt.getX() > pnt.getY())? pnt.getX() : pnt.getY(); + result = (pnt.getZ() > result)? pnt.getZ() : result; + return result; +} + +inline const Point3 minPerElem( const Point3 & pnt0, const Point3 & pnt1 ) +{ + return Point3( + (pnt0.getX() < pnt1.getX())? pnt0.getX() : pnt1.getX(), + (pnt0.getY() < pnt1.getY())? pnt0.getY() : pnt1.getY(), + (pnt0.getZ() < pnt1.getZ())? pnt0.getZ() : pnt1.getZ() + ); +} + +inline float minElem( const Point3 & pnt ) +{ + float result; + result = (pnt.getX() < pnt.getY())? pnt.getX() : pnt.getY(); + result = (pnt.getZ() < result)? pnt.getZ() : result; + return result; +} + +inline float sum( const Point3 & pnt ) +{ + float result; + result = ( pnt.getX() + pnt.getY() ); + result = ( result + pnt.getZ() ); + return result; +} + +inline const Point3 scale( const Point3 & pnt, float scaleVal ) +{ + return mulPerElem( pnt, Point3( scaleVal ) ); +} + +inline const Point3 scale( const Point3 & pnt, const Vector3 & scaleVec ) +{ + return mulPerElem( pnt, Point3( scaleVec ) ); +} + +inline float projection( const Point3 & pnt, const Vector3 & unitVec ) +{ + float result; + result = ( pnt.getX() * unitVec.getX() ); + result = ( result + ( pnt.getY() * unitVec.getY() ) ); + result = ( result + ( pnt.getZ() * unitVec.getZ() ) ); + return result; +} + +inline float distSqrFromOrigin( const Point3 & pnt ) +{ + return lengthSqr( Vector3( pnt ) ); +} + +inline float distFromOrigin( const Point3 & pnt ) +{ + return length( Vector3( pnt ) ); +} + +inline float distSqr( const Point3 & pnt0, const Point3 & pnt1 ) +{ + return lengthSqr( ( pnt1 - pnt0 ) ); +} + +inline float dist( const Point3 & pnt0, const Point3 & pnt1 ) +{ + return length( ( pnt1 - pnt0 ) ); +} + +inline const Point3 select( const Point3 & pnt0, const Point3 & pnt1, bool select1 ) +{ + return Point3( + ( select1 )? pnt1.getX() : pnt0.getX(), + ( select1 )? pnt1.getY() : pnt0.getY(), + ( select1 )? pnt1.getZ() : pnt0.getZ() + ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( const Point3 & pnt ) +{ + printf( "( %f %f %f )\n", pnt.getX(), pnt.getY(), pnt.getZ() ); +} + +inline void print( const Point3 & pnt, const char * name ) +{ + printf( "%s: ( %f %f %f )\n", name, pnt.getX(), pnt.getY(), pnt.getZ() ); +} + +#endif + +} // namespace Aos +} // namespace Vectormath + +#endif diff --git a/vectormathlibrary/include/vectormath/scalar/cpp/vectormath_aos.h b/vectormathlibrary/include/vectormath/scalar/cpp/vectormath_aos.h new file mode 100644 index 000000000..7913c11ea --- /dev/null +++ b/vectormathlibrary/include/vectormath/scalar/cpp/vectormath_aos.h @@ -0,0 +1,1809 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_AOS_CPP_SCALAR_H +#define _VECTORMATH_AOS_CPP_SCALAR_H + +#include <math.h> + +#ifdef _VECTORMATH_DEBUG +#include <stdio.h> +#endif + +namespace Vectormath { + +namespace Aos { + +//----------------------------------------------------------------------------- +// Forward Declarations +// + +class Vector3; +class Vector4; +class Point3; +class Quat; +class Matrix3; +class Matrix4; +class Transform3; + +// A 3-D vector in array-of-structures format +// +class Vector3 +{ + float mX; + float mY; + float mZ; +#ifndef __GNUC__ + float d; +#endif + +public: + // Default constructor; does no initialization + // + inline Vector3( ) { }; + + // Copy a 3-D vector + // + inline Vector3( const Vector3 & vec ); + + // Construct a 3-D vector from x, y, and z elements + // + inline Vector3( float x, float y, float z ); + + // Copy elements from a 3-D point into a 3-D vector + // + explicit inline Vector3( const Point3 & pnt ); + + // Set all elements of a 3-D vector to the same scalar value + // + explicit inline Vector3( float scalar ); + + // Assign one 3-D vector to another + // + inline Vector3 & operator =( const Vector3 & vec ); + + // Set the x element of a 3-D vector + // + inline Vector3 & setX( float x ); + + // Set the y element of a 3-D vector + // + inline Vector3 & setY( float y ); + + // Set the z element of a 3-D vector + // + inline Vector3 & setZ( float z ); + + // Get the x element of a 3-D vector + // + inline float getX( ) const; + + // Get the y element of a 3-D vector + // + inline float getY( ) const; + + // Get the z element of a 3-D vector + // + inline float getZ( ) const; + + // Set an x, y, or z element of a 3-D vector by index + // + inline Vector3 & setElem( int idx, float value ); + + // Get an x, y, or z element of a 3-D vector by index + // + inline float getElem( int idx ) const; + + // Subscripting operator to set or get an element + // + inline float & operator []( int idx ); + + // Subscripting operator to get an element + // + inline float operator []( int idx ) const; + + // Add two 3-D vectors + // + inline const Vector3 operator +( const Vector3 & vec ) const; + + // Subtract a 3-D vector from another 3-D vector + // + inline const Vector3 operator -( const Vector3 & vec ) const; + + // Add a 3-D vector to a 3-D point + // + inline const Point3 operator +( const Point3 & pnt ) const; + + // Multiply a 3-D vector by a scalar + // + inline const Vector3 operator *( float scalar ) const; + + // Divide a 3-D vector by a scalar + // + inline const Vector3 operator /( float scalar ) const; + + // Perform compound assignment and addition with a 3-D vector + // + inline Vector3 & operator +=( const Vector3 & vec ); + + // Perform compound assignment and subtraction by a 3-D vector + // + inline Vector3 & operator -=( const Vector3 & vec ); + + // Perform compound assignment and multiplication by a scalar + // + inline Vector3 & operator *=( float scalar ); + + // Perform compound assignment and division by a scalar + // + inline Vector3 & operator /=( float scalar ); + + // Negate all elements of a 3-D vector + // + inline const Vector3 operator -( ) const; + + // Construct x axis + // + static inline const Vector3 xAxis( ); + + // Construct y axis + // + static inline const Vector3 yAxis( ); + + // Construct z axis + // + static inline const Vector3 zAxis( ); + +} +#ifdef __GNUC__ +__attribute__ ((aligned(16))) +#endif +; + +// Multiply a 3-D vector by a scalar +// +inline const Vector3 operator *( float scalar, const Vector3 & vec ); + +// Multiply two 3-D vectors per element +// +inline const Vector3 mulPerElem( const Vector3 & vec0, const Vector3 & vec1 ); + +// Divide two 3-D vectors per element +// NOTE: +// Floating-point behavior matches standard library function divf4. +// +inline const Vector3 divPerElem( const Vector3 & vec0, const Vector3 & vec1 ); + +// Compute the reciprocal of a 3-D vector per element +// NOTE: +// Floating-point behavior matches standard library function recipf4. +// +inline const Vector3 recipPerElem( const Vector3 & vec ); + +// Compute the square root of a 3-D vector per element +// NOTE: +// Floating-point behavior matches standard library function sqrtf4. +// +inline const Vector3 sqrtPerElem( const Vector3 & vec ); + +// Compute the reciprocal square root of a 3-D vector per element +// NOTE: +// Floating-point behavior matches standard library function rsqrtf4. +// +inline const Vector3 rsqrtPerElem( const Vector3 & vec ); + +// Compute the absolute value of a 3-D vector per element +// +inline const Vector3 absPerElem( const Vector3 & vec ); + +// Copy sign from one 3-D vector to another, per element +// +inline const Vector3 copySignPerElem( const Vector3 & vec0, const Vector3 & vec1 ); + +// Maximum of two 3-D vectors per element +// +inline const Vector3 maxPerElem( const Vector3 & vec0, const Vector3 & vec1 ); + +// Minimum of two 3-D vectors per element +// +inline const Vector3 minPerElem( const Vector3 & vec0, const Vector3 & vec1 ); + +// Maximum element of a 3-D vector +// +inline float maxElem( const Vector3 & vec ); + +// Minimum element of a 3-D vector +// +inline float minElem( const Vector3 & vec ); + +// Compute the sum of all elements of a 3-D vector +// +inline float sum( const Vector3 & vec ); + +// Compute the dot product of two 3-D vectors +// +inline float dot( const Vector3 & vec0, const Vector3 & vec1 ); + +// Compute the square of the length of a 3-D vector +// +inline float lengthSqr( const Vector3 & vec ); + +// Compute the length of a 3-D vector +// +inline float length( const Vector3 & vec ); + +// Normalize a 3-D vector +// NOTE: +// The result is unpredictable when all elements of vec are at or near zero. +// +inline const Vector3 normalize( const Vector3 & vec ); + +// Compute cross product of two 3-D vectors +// +inline const Vector3 cross( const Vector3 & vec0, const Vector3 & vec1 ); + +// Outer product of two 3-D vectors +// +inline const Matrix3 outer( const Vector3 & vec0, const Vector3 & vec1 ); + +// Pre-multiply a row vector by a 3x3 matrix +// +inline const Vector3 rowMul( const Vector3 & vec, const Matrix3 & mat ); + +// Cross-product matrix of a 3-D vector +// +inline const Matrix3 crossMatrix( const Vector3 & vec ); + +// Create cross-product matrix and multiply +// NOTE: +// Faster than separately creating a cross-product matrix and multiplying. +// +inline const Matrix3 crossMatrixMul( const Vector3 & vec, const Matrix3 & mat ); + +// Linear interpolation between two 3-D vectors +// NOTE: +// Does not clamp t between 0 and 1. +// +inline const Vector3 lerp( float t, const Vector3 & vec0, const Vector3 & vec1 ); + +// Spherical linear interpolation between two 3-D vectors +// NOTE: +// The result is unpredictable if the vectors point in opposite directions. +// Does not clamp t between 0 and 1. +// +inline const Vector3 slerp( float t, const Vector3 & unitVec0, const Vector3 & unitVec1 ); + +// Conditionally select between two 3-D vectors +// +inline const Vector3 select( const Vector3 & vec0, const Vector3 & vec1, bool select1 ); + +#ifdef _VECTORMATH_DEBUG + +// Print a 3-D vector +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Vector3 & vec ); + +// Print a 3-D vector and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Vector3 & vec, const char * name ); + +#endif + +// A 4-D vector in array-of-structures format +// +class Vector4 +{ + float mX; + float mY; + float mZ; + float mW; + +public: + // Default constructor; does no initialization + // + inline Vector4( ) { }; + + // Copy a 4-D vector + // + inline Vector4( const Vector4 & vec ); + + // Construct a 4-D vector from x, y, z, and w elements + // + inline Vector4( float x, float y, float z, float w ); + + // Construct a 4-D vector from a 3-D vector and a scalar + // + inline Vector4( const Vector3 & xyz, float w ); + + // Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0 + // + explicit inline Vector4( const Vector3 & vec ); + + // Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1 + // + explicit inline Vector4( const Point3 & pnt ); + + // Copy elements from a quaternion into a 4-D vector + // + explicit inline Vector4( const Quat & quat ); + + // Set all elements of a 4-D vector to the same scalar value + // + explicit inline Vector4( float scalar ); + + // Assign one 4-D vector to another + // + inline Vector4 & operator =( const Vector4 & vec ); + + // Set the x, y, and z elements of a 4-D vector + // NOTE: + // This function does not change the w element. + // + inline Vector4 & setXYZ( const Vector3 & vec ); + + // Get the x, y, and z elements of a 4-D vector + // + inline const Vector3 getXYZ( ) const; + + // Set the x element of a 4-D vector + // + inline Vector4 & setX( float x ); + + // Set the y element of a 4-D vector + // + inline Vector4 & setY( float y ); + + // Set the z element of a 4-D vector + // + inline Vector4 & setZ( float z ); + + // Set the w element of a 4-D vector + // + inline Vector4 & setW( float w ); + + // Get the x element of a 4-D vector + // + inline float getX( ) const; + + // Get the y element of a 4-D vector + // + inline float getY( ) const; + + // Get the z element of a 4-D vector + // + inline float getZ( ) const; + + // Get the w element of a 4-D vector + // + inline float getW( ) const; + + // Set an x, y, z, or w element of a 4-D vector by index + // + inline Vector4 & setElem( int idx, float value ); + + // Get an x, y, z, or w element of a 4-D vector by index + // + inline float getElem( int idx ) const; + + // Subscripting operator to set or get an element + // + inline float & operator []( int idx ); + + // Subscripting operator to get an element + // + inline float operator []( int idx ) const; + + // Add two 4-D vectors + // + inline const Vector4 operator +( const Vector4 & vec ) const; + + // Subtract a 4-D vector from another 4-D vector + // + inline const Vector4 operator -( const Vector4 & vec ) const; + + // Multiply a 4-D vector by a scalar + // + inline const Vector4 operator *( float scalar ) const; + + // Divide a 4-D vector by a scalar + // + inline const Vector4 operator /( float scalar ) const; + + // Perform compound assignment and addition with a 4-D vector + // + inline Vector4 & operator +=( const Vector4 & vec ); + + // Perform compound assignment and subtraction by a 4-D vector + // + inline Vector4 & operator -=( const Vector4 & vec ); + + // Perform compound assignment and multiplication by a scalar + // + inline Vector4 & operator *=( float scalar ); + + // Perform compound assignment and division by a scalar + // + inline Vector4 & operator /=( float scalar ); + + // Negate all elements of a 4-D vector + // + inline const Vector4 operator -( ) const; + + // Construct x axis + // + static inline const Vector4 xAxis( ); + + // Construct y axis + // + static inline const Vector4 yAxis( ); + + // Construct z axis + // + static inline const Vector4 zAxis( ); + + // Construct w axis + // + static inline const Vector4 wAxis( ); + +} +#ifdef __GNUC__ +__attribute__ ((aligned(16))) +#endif +; + +// Multiply a 4-D vector by a scalar +// +inline const Vector4 operator *( float scalar, const Vector4 & vec ); + +// Multiply two 4-D vectors per element +// +inline const Vector4 mulPerElem( const Vector4 & vec0, const Vector4 & vec1 ); + +// Divide two 4-D vectors per element +// NOTE: +// Floating-point behavior matches standard library function divf4. +// +inline const Vector4 divPerElem( const Vector4 & vec0, const Vector4 & vec1 ); + +// Compute the reciprocal of a 4-D vector per element +// NOTE: +// Floating-point behavior matches standard library function recipf4. +// +inline const Vector4 recipPerElem( const Vector4 & vec ); + +// Compute the square root of a 4-D vector per element +// NOTE: +// Floating-point behavior matches standard library function sqrtf4. +// +inline const Vector4 sqrtPerElem( const Vector4 & vec ); + +// Compute the reciprocal square root of a 4-D vector per element +// NOTE: +// Floating-point behavior matches standard library function rsqrtf4. +// +inline const Vector4 rsqrtPerElem( const Vector4 & vec ); + +// Compute the absolute value of a 4-D vector per element +// +inline const Vector4 absPerElem( const Vector4 & vec ); + +// Copy sign from one 4-D vector to another, per element +// +inline const Vector4 copySignPerElem( const Vector4 & vec0, const Vector4 & vec1 ); + +// Maximum of two 4-D vectors per element +// +inline const Vector4 maxPerElem( const Vector4 & vec0, const Vector4 & vec1 ); + +// Minimum of two 4-D vectors per element +// +inline const Vector4 minPerElem( const Vector4 & vec0, const Vector4 & vec1 ); + +// Maximum element of a 4-D vector +// +inline float maxElem( const Vector4 & vec ); + +// Minimum element of a 4-D vector +// +inline float minElem( const Vector4 & vec ); + +// Compute the sum of all elements of a 4-D vector +// +inline float sum( const Vector4 & vec ); + +// Compute the dot product of two 4-D vectors +// +inline float dot( const Vector4 & vec0, const Vector4 & vec1 ); + +// Compute the square of the length of a 4-D vector +// +inline float lengthSqr( const Vector4 & vec ); + +// Compute the length of a 4-D vector +// +inline float length( const Vector4 & vec ); + +// Normalize a 4-D vector +// NOTE: +// The result is unpredictable when all elements of vec are at or near zero. +// +inline const Vector4 normalize( const Vector4 & vec ); + +// Outer product of two 4-D vectors +// +inline const Matrix4 outer( const Vector4 & vec0, const Vector4 & vec1 ); + +// Linear interpolation between two 4-D vectors +// NOTE: +// Does not clamp t between 0 and 1. +// +inline const Vector4 lerp( float t, const Vector4 & vec0, const Vector4 & vec1 ); + +// Spherical linear interpolation between two 4-D vectors +// NOTE: +// The result is unpredictable if the vectors point in opposite directions. +// Does not clamp t between 0 and 1. +// +inline const Vector4 slerp( float t, const Vector4 & unitVec0, const Vector4 & unitVec1 ); + +// Conditionally select between two 4-D vectors +// +inline const Vector4 select( const Vector4 & vec0, const Vector4 & vec1, bool select1 ); + +#ifdef _VECTORMATH_DEBUG + +// Print a 4-D vector +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Vector4 & vec ); + +// Print a 4-D vector and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Vector4 & vec, const char * name ); + +#endif + +// A 3-D point in array-of-structures format +// +class Point3 +{ + float mX; + float mY; + float mZ; +#ifndef __GNUC__ + float d; +#endif + +public: + // Default constructor; does no initialization + // + inline Point3( ) { }; + + // Copy a 3-D point + // + inline Point3( const Point3 & pnt ); + + // Construct a 3-D point from x, y, and z elements + // + inline Point3( float x, float y, float z ); + + // Copy elements from a 3-D vector into a 3-D point + // + explicit inline Point3( const Vector3 & vec ); + + // Set all elements of a 3-D point to the same scalar value + // + explicit inline Point3( float scalar ); + + // Assign one 3-D point to another + // + inline Point3 & operator =( const Point3 & pnt ); + + // Set the x element of a 3-D point + // + inline Point3 & setX( float x ); + + // Set the y element of a 3-D point + // + inline Point3 & setY( float y ); + + // Set the z element of a 3-D point + // + inline Point3 & setZ( float z ); + + // Get the x element of a 3-D point + // + inline float getX( ) const; + + // Get the y element of a 3-D point + // + inline float getY( ) const; + + // Get the z element of a 3-D point + // + inline float getZ( ) const; + + // Set an x, y, or z element of a 3-D point by index + // + inline Point3 & setElem( int idx, float value ); + + // Get an x, y, or z element of a 3-D point by index + // + inline float getElem( int idx ) const; + + // Subscripting operator to set or get an element + // + inline float & operator []( int idx ); + + // Subscripting operator to get an element + // + inline float operator []( int idx ) const; + + // Subtract a 3-D point from another 3-D point + // + inline const Vector3 operator -( const Point3 & pnt ) const; + + // Add a 3-D point to a 3-D vector + // + inline const Point3 operator +( const Vector3 & vec ) const; + + // Subtract a 3-D vector from a 3-D point + // + inline const Point3 operator -( const Vector3 & vec ) const; + + // Perform compound assignment and addition with a 3-D vector + // + inline Point3 & operator +=( const Vector3 & vec ); + + // Perform compound assignment and subtraction by a 3-D vector + // + inline Point3 & operator -=( const Vector3 & vec ); + +} +#ifdef __GNUC__ +__attribute__ ((aligned(16))) +#endif +; + +// Multiply two 3-D points per element +// +inline const Point3 mulPerElem( const Point3 & pnt0, const Point3 & pnt1 ); + +// Divide two 3-D points per element +// NOTE: +// Floating-point behavior matches standard library function divf4. +// +inline const Point3 divPerElem( const Point3 & pnt0, const Point3 & pnt1 ); + +// Compute the reciprocal of a 3-D point per element +// NOTE: +// Floating-point behavior matches standard library function recipf4. +// +inline const Point3 recipPerElem( const Point3 & pnt ); + +// Compute the square root of a 3-D point per element +// NOTE: +// Floating-point behavior matches standard library function sqrtf4. +// +inline const Point3 sqrtPerElem( const Point3 & pnt ); + +// Compute the reciprocal square root of a 3-D point per element +// NOTE: +// Floating-point behavior matches standard library function rsqrtf4. +// +inline const Point3 rsqrtPerElem( const Point3 & pnt ); + +// Compute the absolute value of a 3-D point per element +// +inline const Point3 absPerElem( const Point3 & pnt ); + +// Copy sign from one 3-D point to another, per element +// +inline const Point3 copySignPerElem( const Point3 & pnt0, const Point3 & pnt1 ); + +// Maximum of two 3-D points per element +// +inline const Point3 maxPerElem( const Point3 & pnt0, const Point3 & pnt1 ); + +// Minimum of two 3-D points per element +// +inline const Point3 minPerElem( const Point3 & pnt0, const Point3 & pnt1 ); + +// Maximum element of a 3-D point +// +inline float maxElem( const Point3 & pnt ); + +// Minimum element of a 3-D point +// +inline float minElem( const Point3 & pnt ); + +// Compute the sum of all elements of a 3-D point +// +inline float sum( const Point3 & pnt ); + +// Apply uniform scale to a 3-D point +// +inline const Point3 scale( const Point3 & pnt, float scaleVal ); + +// Apply non-uniform scale to a 3-D point +// +inline const Point3 scale( const Point3 & pnt, const Vector3 & scaleVec ); + +// Scalar projection of a 3-D point on a unit-length 3-D vector +// +inline float projection( const Point3 & pnt, const Vector3 & unitVec ); + +// Compute the square of the distance of a 3-D point from the coordinate-system origin +// +inline float distSqrFromOrigin( const Point3 & pnt ); + +// Compute the distance of a 3-D point from the coordinate-system origin +// +inline float distFromOrigin( const Point3 & pnt ); + +// Compute the square of the distance between two 3-D points +// +inline float distSqr( const Point3 & pnt0, const Point3 & pnt1 ); + +// Compute the distance between two 3-D points +// +inline float dist( const Point3 & pnt0, const Point3 & pnt1 ); + +// Linear interpolation between two 3-D points +// NOTE: +// Does not clamp t between 0 and 1. +// +inline const Point3 lerp( float t, const Point3 & pnt0, const Point3 & pnt1 ); + +// Conditionally select between two 3-D points +// +inline const Point3 select( const Point3 & pnt0, const Point3 & pnt1, bool select1 ); + +#ifdef _VECTORMATH_DEBUG + +// Print a 3-D point +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Point3 & pnt ); + +// Print a 3-D point and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Point3 & pnt, const char * name ); + +#endif + +// A quaternion in array-of-structures format +// +class Quat +{ + float mX; + float mY; + float mZ; + float mW; + +public: + // Default constructor; does no initialization + // + inline Quat( ) { }; + + // Copy a quaternion + // + inline Quat( const Quat & quat ); + + // Construct a quaternion from x, y, z, and w elements + // + inline Quat( float x, float y, float z, float w ); + + // Construct a quaternion from a 3-D vector and a scalar + // + inline Quat( const Vector3 & xyz, float w ); + + // Copy elements from a 4-D vector into a quaternion + // + explicit inline Quat( const Vector4 & vec ); + + // Convert a rotation matrix to a unit-length quaternion + // + explicit inline Quat( const Matrix3 & rotMat ); + + // Set all elements of a quaternion to the same scalar value + // + explicit inline Quat( float scalar ); + + // Assign one quaternion to another + // + inline Quat & operator =( const Quat & quat ); + + // Set the x, y, and z elements of a quaternion + // NOTE: + // This function does not change the w element. + // + inline Quat & setXYZ( const Vector3 & vec ); + + // Get the x, y, and z elements of a quaternion + // + inline const Vector3 getXYZ( ) const; + + // Set the x element of a quaternion + // + inline Quat & setX( float x ); + + // Set the y element of a quaternion + // + inline Quat & setY( float y ); + + // Set the z element of a quaternion + // + inline Quat & setZ( float z ); + + // Set the w element of a quaternion + // + inline Quat & setW( float w ); + + // Get the x element of a quaternion + // + inline float getX( ) const; + + // Get the y element of a quaternion + // + inline float getY( ) const; + + // Get the z element of a quaternion + // + inline float getZ( ) const; + + // Get the w element of a quaternion + // + inline float getW( ) const; + + // Set an x, y, z, or w element of a quaternion by index + // + inline Quat & setElem( int idx, float value ); + + // Get an x, y, z, or w element of a quaternion by index + // + inline float getElem( int idx ) const; + + // Subscripting operator to set or get an element + // + inline float & operator []( int idx ); + + // Subscripting operator to get an element + // + inline float operator []( int idx ) const; + + // Add two quaternions + // + inline const Quat operator +( const Quat & quat ) const; + + // Subtract a quaternion from another quaternion + // + inline const Quat operator -( const Quat & quat ) const; + + // Multiply two quaternions + // + inline const Quat operator *( const Quat & quat ) const; + + // Multiply a quaternion by a scalar + // + inline const Quat operator *( float scalar ) const; + + // Divide a quaternion by a scalar + // + inline const Quat operator /( float scalar ) const; + + // Perform compound assignment and addition with a quaternion + // + inline Quat & operator +=( const Quat & quat ); + + // Perform compound assignment and subtraction by a quaternion + // + inline Quat & operator -=( const Quat & quat ); + + // Perform compound assignment and multiplication by a quaternion + // + inline Quat & operator *=( const Quat & quat ); + + // Perform compound assignment and multiplication by a scalar + // + inline Quat & operator *=( float scalar ); + + // Perform compound assignment and division by a scalar + // + inline Quat & operator /=( float scalar ); + + // Negate all elements of a quaternion + // + inline const Quat operator -( ) const; + + // Construct an identity quaternion + // + static inline const Quat identity( ); + + // Construct a quaternion to rotate between two unit-length 3-D vectors + // NOTE: + // The result is unpredictable if unitVec0 and unitVec1 point in opposite directions. + // + static inline const Quat rotation( const Vector3 & unitVec0, const Vector3 & unitVec1 ); + + // Construct a quaternion to rotate around a unit-length 3-D vector + // + static inline const Quat rotation( float radians, const Vector3 & unitVec ); + + // Construct a quaternion to rotate around the x axis + // + static inline const Quat rotationX( float radians ); + + // Construct a quaternion to rotate around the y axis + // + static inline const Quat rotationY( float radians ); + + // Construct a quaternion to rotate around the z axis + // + static inline const Quat rotationZ( float radians ); + +} +#ifdef __GNUC__ +__attribute__ ((aligned(16))) +#endif +; + +// Multiply a quaternion by a scalar +// +inline const Quat operator *( float scalar, const Quat & quat ); + +// Compute the conjugate of a quaternion +// +inline const Quat conj( const Quat & quat ); + +// Use a unit-length quaternion to rotate a 3-D vector +// +inline const Vector3 rotate( const Quat & unitQuat, const Vector3 & vec ); + +// Compute the dot product of two quaternions +// +inline float dot( const Quat & quat0, const Quat & quat1 ); + +// Compute the norm of a quaternion +// +inline float norm( const Quat & quat ); + +// Compute the length of a quaternion +// +inline float length( const Quat & quat ); + +// Normalize a quaternion +// NOTE: +// The result is unpredictable when all elements of quat are at or near zero. +// +inline const Quat normalize( const Quat & quat ); + +// Linear interpolation between two quaternions +// NOTE: +// Does not clamp t between 0 and 1. +// +inline const Quat lerp( float t, const Quat & quat0, const Quat & quat1 ); + +// Spherical linear interpolation between two quaternions +// NOTE: +// Interpolates along the shortest path between orientations. +// Does not clamp t between 0 and 1. +// +inline const Quat slerp( float t, const Quat & unitQuat0, const Quat & unitQuat1 ); + +// Spherical quadrangle interpolation +// +inline const Quat squad( float t, const Quat & unitQuat0, const Quat & unitQuat1, const Quat & unitQuat2, const Quat & unitQuat3 ); + +// Conditionally select between two quaternions +// +inline const Quat select( const Quat & quat0, const Quat & quat1, bool select1 ); + +#ifdef _VECTORMATH_DEBUG + +// Print a quaternion +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Quat & quat ); + +// Print a quaternion and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Quat & quat, const char * name ); + +#endif + +// A 3x3 matrix in array-of-structures format +// +class Matrix3 +{ + Vector3 mCol0; + Vector3 mCol1; + Vector3 mCol2; + +public: + // Default constructor; does no initialization + // + inline Matrix3( ) { }; + + // Copy a 3x3 matrix + // + inline Matrix3( const Matrix3 & mat ); + + // Construct a 3x3 matrix containing the specified columns + // + inline Matrix3( const Vector3 & col0, const Vector3 & col1, const Vector3 & col2 ); + + // Construct a 3x3 rotation matrix from a unit-length quaternion + // + explicit inline Matrix3( const Quat & unitQuat ); + + // Set all elements of a 3x3 matrix to the same scalar value + // + explicit inline Matrix3( float scalar ); + + // Assign one 3x3 matrix to another + // + inline Matrix3 & operator =( const Matrix3 & mat ); + + // Set column 0 of a 3x3 matrix + // + inline Matrix3 & setCol0( const Vector3 & col0 ); + + // Set column 1 of a 3x3 matrix + // + inline Matrix3 & setCol1( const Vector3 & col1 ); + + // Set column 2 of a 3x3 matrix + // + inline Matrix3 & setCol2( const Vector3 & col2 ); + + // Get column 0 of a 3x3 matrix + // + inline const Vector3 getCol0( ) const; + + // Get column 1 of a 3x3 matrix + // + inline const Vector3 getCol1( ) const; + + // Get column 2 of a 3x3 matrix + // + inline const Vector3 getCol2( ) const; + + // Set the column of a 3x3 matrix referred to by the specified index + // + inline Matrix3 & setCol( int col, const Vector3 & vec ); + + // Set the row of a 3x3 matrix referred to by the specified index + // + inline Matrix3 & setRow( int row, const Vector3 & vec ); + + // Get the column of a 3x3 matrix referred to by the specified index + // + inline const Vector3 getCol( int col ) const; + + // Get the row of a 3x3 matrix referred to by the specified index + // + inline const Vector3 getRow( int row ) const; + + // Subscripting operator to set or get a column + // + inline Vector3 & operator []( int col ); + + // Subscripting operator to get a column + // + inline const Vector3 operator []( int col ) const; + + // Set the element of a 3x3 matrix referred to by column and row indices + // + inline Matrix3 & setElem( int col, int row, float val ); + + // Get the element of a 3x3 matrix referred to by column and row indices + // + inline float getElem( int col, int row ) const; + + // Add two 3x3 matrices + // + inline const Matrix3 operator +( const Matrix3 & mat ) const; + + // Subtract a 3x3 matrix from another 3x3 matrix + // + inline const Matrix3 operator -( const Matrix3 & mat ) const; + + // Negate all elements of a 3x3 matrix + // + inline const Matrix3 operator -( ) const; + + // Multiply a 3x3 matrix by a scalar + // + inline const Matrix3 operator *( float scalar ) const; + + // Multiply a 3x3 matrix by a 3-D vector + // + inline const Vector3 operator *( const Vector3 & vec ) const; + + // Multiply two 3x3 matrices + // + inline const Matrix3 operator *( const Matrix3 & mat ) const; + + // Perform compound assignment and addition with a 3x3 matrix + // + inline Matrix3 & operator +=( const Matrix3 & mat ); + + // Perform compound assignment and subtraction by a 3x3 matrix + // + inline Matrix3 & operator -=( const Matrix3 & mat ); + + // Perform compound assignment and multiplication by a scalar + // + inline Matrix3 & operator *=( float scalar ); + + // Perform compound assignment and multiplication by a 3x3 matrix + // + inline Matrix3 & operator *=( const Matrix3 & mat ); + + // Construct an identity 3x3 matrix + // + static inline const Matrix3 identity( ); + + // Construct a 3x3 matrix to rotate around the x axis + // + static inline const Matrix3 rotationX( float radians ); + + // Construct a 3x3 matrix to rotate around the y axis + // + static inline const Matrix3 rotationY( float radians ); + + // Construct a 3x3 matrix to rotate around the z axis + // + static inline const Matrix3 rotationZ( float radians ); + + // Construct a 3x3 matrix to rotate around the x, y, and z axes + // + static inline const Matrix3 rotationZYX( const Vector3 & radiansXYZ ); + + // Construct a 3x3 matrix to rotate around a unit-length 3-D vector + // + static inline const Matrix3 rotation( float radians, const Vector3 & unitVec ); + + // Construct a rotation matrix from a unit-length quaternion + // + static inline const Matrix3 rotation( const Quat & unitQuat ); + + // Construct a 3x3 matrix to perform scaling + // + static inline const Matrix3 scale( const Vector3 & scaleVec ); + +}; +// Multiply a 3x3 matrix by a scalar +// +inline const Matrix3 operator *( float scalar, const Matrix3 & mat ); + +// Append (post-multiply) a scale transformation to a 3x3 matrix +// NOTE: +// Faster than creating and multiplying a scale transformation matrix. +// +inline const Matrix3 appendScale( const Matrix3 & mat, const Vector3 & scaleVec ); + +// Prepend (pre-multiply) a scale transformation to a 3x3 matrix +// NOTE: +// Faster than creating and multiplying a scale transformation matrix. +// +inline const Matrix3 prependScale( const Vector3 & scaleVec, const Matrix3 & mat ); + +// Multiply two 3x3 matrices per element +// +inline const Matrix3 mulPerElem( const Matrix3 & mat0, const Matrix3 & mat1 ); + +// Compute the absolute value of a 3x3 matrix per element +// +inline const Matrix3 absPerElem( const Matrix3 & mat ); + +// Transpose of a 3x3 matrix +// +inline const Matrix3 transpose( const Matrix3 & mat ); + +// Compute the inverse of a 3x3 matrix +// NOTE: +// Result is unpredictable when the determinant of mat is equal to or near 0. +// +inline const Matrix3 inverse( const Matrix3 & mat ); + +// Determinant of a 3x3 matrix +// +inline float determinant( const Matrix3 & mat ); + +// Conditionally select between two 3x3 matrices +// +inline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, bool select1 ); + +#ifdef _VECTORMATH_DEBUG + +// Print a 3x3 matrix +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Matrix3 & mat ); + +// Print a 3x3 matrix and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Matrix3 & mat, const char * name ); + +#endif + +// A 4x4 matrix in array-of-structures format +// +class Matrix4 +{ + Vector4 mCol0; + Vector4 mCol1; + Vector4 mCol2; + Vector4 mCol3; + +public: + // Default constructor; does no initialization + // + inline Matrix4( ) { }; + + // Copy a 4x4 matrix + // + inline Matrix4( const Matrix4 & mat ); + + // Construct a 4x4 matrix containing the specified columns + // + inline Matrix4( const Vector4 & col0, const Vector4 & col1, const Vector4 & col2, const Vector4 & col3 ); + + // Construct a 4x4 matrix from a 3x4 transformation matrix + // + explicit inline Matrix4( const Transform3 & mat ); + + // Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector + // + inline Matrix4( const Matrix3 & mat, const Vector3 & translateVec ); + + // Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector + // + inline Matrix4( const Quat & unitQuat, const Vector3 & translateVec ); + + // Set all elements of a 4x4 matrix to the same scalar value + // + explicit inline Matrix4( float scalar ); + + // Assign one 4x4 matrix to another + // + inline Matrix4 & operator =( const Matrix4 & mat ); + + // Set the upper-left 3x3 submatrix + // NOTE: + // This function does not change the bottom row elements. + // + inline Matrix4 & setUpper3x3( const Matrix3 & mat3 ); + + // Get the upper-left 3x3 submatrix of a 4x4 matrix + // + inline const Matrix3 getUpper3x3( ) const; + + // Set translation component + // NOTE: + // This function does not change the bottom row elements. + // + inline Matrix4 & setTranslation( const Vector3 & translateVec ); + + // Get the translation component of a 4x4 matrix + // + inline const Vector3 getTranslation( ) const; + + // Set column 0 of a 4x4 matrix + // + inline Matrix4 & setCol0( const Vector4 & col0 ); + + // Set column 1 of a 4x4 matrix + // + inline Matrix4 & setCol1( const Vector4 & col1 ); + + // Set column 2 of a 4x4 matrix + // + inline Matrix4 & setCol2( const Vector4 & col2 ); + + // Set column 3 of a 4x4 matrix + // + inline Matrix4 & setCol3( const Vector4 & col3 ); + + // Get column 0 of a 4x4 matrix + // + inline const Vector4 getCol0( ) const; + + // Get column 1 of a 4x4 matrix + // + inline const Vector4 getCol1( ) const; + + // Get column 2 of a 4x4 matrix + // + inline const Vector4 getCol2( ) const; + + // Get column 3 of a 4x4 matrix + // + inline const Vector4 getCol3( ) const; + + // Set the column of a 4x4 matrix referred to by the specified index + // + inline Matrix4 & setCol( int col, const Vector4 & vec ); + + // Set the row of a 4x4 matrix referred to by the specified index + // + inline Matrix4 & setRow( int row, const Vector4 & vec ); + + // Get the column of a 4x4 matrix referred to by the specified index + // + inline const Vector4 getCol( int col ) const; + + // Get the row of a 4x4 matrix referred to by the specified index + // + inline const Vector4 getRow( int row ) const; + + // Subscripting operator to set or get a column + // + inline Vector4 & operator []( int col ); + + // Subscripting operator to get a column + // + inline const Vector4 operator []( int col ) const; + + // Set the element of a 4x4 matrix referred to by column and row indices + // + inline Matrix4 & setElem( int col, int row, float val ); + + // Get the element of a 4x4 matrix referred to by column and row indices + // + inline float getElem( int col, int row ) const; + + // Add two 4x4 matrices + // + inline const Matrix4 operator +( const Matrix4 & mat ) const; + + // Subtract a 4x4 matrix from another 4x4 matrix + // + inline const Matrix4 operator -( const Matrix4 & mat ) const; + + // Negate all elements of a 4x4 matrix + // + inline const Matrix4 operator -( ) const; + + // Multiply a 4x4 matrix by a scalar + // + inline const Matrix4 operator *( float scalar ) const; + + // Multiply a 4x4 matrix by a 4-D vector + // + inline const Vector4 operator *( const Vector4 & vec ) const; + + // Multiply a 4x4 matrix by a 3-D vector + // + inline const Vector4 operator *( const Vector3 & vec ) const; + + // Multiply a 4x4 matrix by a 3-D point + // + inline const Vector4 operator *( const Point3 & pnt ) const; + + // Multiply two 4x4 matrices + // + inline const Matrix4 operator *( const Matrix4 & mat ) const; + + // Multiply a 4x4 matrix by a 3x4 transformation matrix + // + inline const Matrix4 operator *( const Transform3 & tfrm ) const; + + // Perform compound assignment and addition with a 4x4 matrix + // + inline Matrix4 & operator +=( const Matrix4 & mat ); + + // Perform compound assignment and subtraction by a 4x4 matrix + // + inline Matrix4 & operator -=( const Matrix4 & mat ); + + // Perform compound assignment and multiplication by a scalar + // + inline Matrix4 & operator *=( float scalar ); + + // Perform compound assignment and multiplication by a 4x4 matrix + // + inline Matrix4 & operator *=( const Matrix4 & mat ); + + // Perform compound assignment and multiplication by a 3x4 transformation matrix + // + inline Matrix4 & operator *=( const Transform3 & tfrm ); + + // Construct an identity 4x4 matrix + // + static inline const Matrix4 identity( ); + + // Construct a 4x4 matrix to rotate around the x axis + // + static inline const Matrix4 rotationX( float radians ); + + // Construct a 4x4 matrix to rotate around the y axis + // + static inline const Matrix4 rotationY( float radians ); + + // Construct a 4x4 matrix to rotate around the z axis + // + static inline const Matrix4 rotationZ( float radians ); + + // Construct a 4x4 matrix to rotate around the x, y, and z axes + // + static inline const Matrix4 rotationZYX( const Vector3 & radiansXYZ ); + + // Construct a 4x4 matrix to rotate around a unit-length 3-D vector + // + static inline const Matrix4 rotation( float radians, const Vector3 & unitVec ); + + // Construct a rotation matrix from a unit-length quaternion + // + static inline const Matrix4 rotation( const Quat & unitQuat ); + + // Construct a 4x4 matrix to perform scaling + // + static inline const Matrix4 scale( const Vector3 & scaleVec ); + + // Construct a 4x4 matrix to perform translation + // + static inline const Matrix4 translation( const Vector3 & translateVec ); + + // Construct viewing matrix based on eye position, position looked at, and up direction + // + static inline const Matrix4 lookAt( const Point3 & eyePos, const Point3 & lookAtPos, const Vector3 & upVec ); + + // Construct a perspective projection matrix + // + static inline const Matrix4 perspective( float fovyRadians, float aspect, float zNear, float zFar ); + + // Construct a perspective projection matrix based on frustum + // + static inline const Matrix4 frustum( float left, float right, float bottom, float top, float zNear, float zFar ); + + // Construct an orthographic projection matrix + // + static inline const Matrix4 orthographic( float left, float right, float bottom, float top, float zNear, float zFar ); + +}; +// Multiply a 4x4 matrix by a scalar +// +inline const Matrix4 operator *( float scalar, const Matrix4 & mat ); + +// Append (post-multiply) a scale transformation to a 4x4 matrix +// NOTE: +// Faster than creating and multiplying a scale transformation matrix. +// +inline const Matrix4 appendScale( const Matrix4 & mat, const Vector3 & scaleVec ); + +// Prepend (pre-multiply) a scale transformation to a 4x4 matrix +// NOTE: +// Faster than creating and multiplying a scale transformation matrix. +// +inline const Matrix4 prependScale( const Vector3 & scaleVec, const Matrix4 & mat ); + +// Multiply two 4x4 matrices per element +// +inline const Matrix4 mulPerElem( const Matrix4 & mat0, const Matrix4 & mat1 ); + +// Compute the absolute value of a 4x4 matrix per element +// +inline const Matrix4 absPerElem( const Matrix4 & mat ); + +// Transpose of a 4x4 matrix +// +inline const Matrix4 transpose( const Matrix4 & mat ); + +// Compute the inverse of a 4x4 matrix +// NOTE: +// Result is unpredictable when the determinant of mat is equal to or near 0. +// +inline const Matrix4 inverse( const Matrix4 & mat ); + +// Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix +// NOTE: +// This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. The result is unpredictable when the determinant of mat is equal to or near 0. +// +inline const Matrix4 affineInverse( const Matrix4 & mat ); + +// Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix +// NOTE: +// This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. +// +inline const Matrix4 orthoInverse( const Matrix4 & mat ); + +// Determinant of a 4x4 matrix +// +inline float determinant( const Matrix4 & mat ); + +// Conditionally select between two 4x4 matrices +// +inline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, bool select1 ); + +#ifdef _VECTORMATH_DEBUG + +// Print a 4x4 matrix +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Matrix4 & mat ); + +// Print a 4x4 matrix and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Matrix4 & mat, const char * name ); + +#endif + +// A 3x4 transformation matrix in array-of-structures format +// +class Transform3 +{ + Vector3 mCol0; + Vector3 mCol1; + Vector3 mCol2; + Vector3 mCol3; + +public: + // Default constructor; does no initialization + // + inline Transform3( ) { }; + + // Copy a 3x4 transformation matrix + // + inline Transform3( const Transform3 & tfrm ); + + // Construct a 3x4 transformation matrix containing the specified columns + // + inline Transform3( const Vector3 & col0, const Vector3 & col1, const Vector3 & col2, const Vector3 & col3 ); + + // Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector + // + inline Transform3( const Matrix3 & tfrm, const Vector3 & translateVec ); + + // Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector + // + inline Transform3( const Quat & unitQuat, const Vector3 & translateVec ); + + // Set all elements of a 3x4 transformation matrix to the same scalar value + // + explicit inline Transform3( float scalar ); + + // Assign one 3x4 transformation matrix to another + // + inline Transform3 & operator =( const Transform3 & tfrm ); + + // Set the upper-left 3x3 submatrix + // + inline Transform3 & setUpper3x3( const Matrix3 & mat3 ); + + // Get the upper-left 3x3 submatrix of a 3x4 transformation matrix + // + inline const Matrix3 getUpper3x3( ) const; + + // Set translation component + // + inline Transform3 & setTranslation( const Vector3 & translateVec ); + + // Get the translation component of a 3x4 transformation matrix + // + inline const Vector3 getTranslation( ) const; + + // Set column 0 of a 3x4 transformation matrix + // + inline Transform3 & setCol0( const Vector3 & col0 ); + + // Set column 1 of a 3x4 transformation matrix + // + inline Transform3 & setCol1( const Vector3 & col1 ); + + // Set column 2 of a 3x4 transformation matrix + // + inline Transform3 & setCol2( const Vector3 & col2 ); + + // Set column 3 of a 3x4 transformation matrix + // + inline Transform3 & setCol3( const Vector3 & col3 ); + + // Get column 0 of a 3x4 transformation matrix + // + inline const Vector3 getCol0( ) const; + + // Get column 1 of a 3x4 transformation matrix + // + inline const Vector3 getCol1( ) const; + + // Get column 2 of a 3x4 transformation matrix + // + inline const Vector3 getCol2( ) const; + + // Get column 3 of a 3x4 transformation matrix + // + inline const Vector3 getCol3( ) const; + + // Set the column of a 3x4 transformation matrix referred to by the specified index + // + inline Transform3 & setCol( int col, const Vector3 & vec ); + + // Set the row of a 3x4 transformation matrix referred to by the specified index + // + inline Transform3 & setRow( int row, const Vector4 & vec ); + + // Get the column of a 3x4 transformation matrix referred to by the specified index + // + inline const Vector3 getCol( int col ) const; + + // Get the row of a 3x4 transformation matrix referred to by the specified index + // + inline const Vector4 getRow( int row ) const; + + // Subscripting operator to set or get a column + // + inline Vector3 & operator []( int col ); + + // Subscripting operator to get a column + // + inline const Vector3 operator []( int col ) const; + + // Set the element of a 3x4 transformation matrix referred to by column and row indices + // + inline Transform3 & setElem( int col, int row, float val ); + + // Get the element of a 3x4 transformation matrix referred to by column and row indices + // + inline float getElem( int col, int row ) const; + + // Multiply a 3x4 transformation matrix by a 3-D vector + // + inline const Vector3 operator *( const Vector3 & vec ) const; + + // Multiply a 3x4 transformation matrix by a 3-D point + // + inline const Point3 operator *( const Point3 & pnt ) const; + + // Multiply two 3x4 transformation matrices + // + inline const Transform3 operator *( const Transform3 & tfrm ) const; + + // Perform compound assignment and multiplication by a 3x4 transformation matrix + // + inline Transform3 & operator *=( const Transform3 & tfrm ); + + // Construct an identity 3x4 transformation matrix + // + static inline const Transform3 identity( ); + + // Construct a 3x4 transformation matrix to rotate around the x axis + // + static inline const Transform3 rotationX( float radians ); + + // Construct a 3x4 transformation matrix to rotate around the y axis + // + static inline const Transform3 rotationY( float radians ); + + // Construct a 3x4 transformation matrix to rotate around the z axis + // + static inline const Transform3 rotationZ( float radians ); + + // Construct a 3x4 transformation matrix to rotate around the x, y, and z axes + // + static inline const Transform3 rotationZYX( const Vector3 & radiansXYZ ); + + // Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector + // + static inline const Transform3 rotation( float radians, const Vector3 & unitVec ); + + // Construct a rotation matrix from a unit-length quaternion + // + static inline const Transform3 rotation( const Quat & unitQuat ); + + // Construct a 3x4 transformation matrix to perform scaling + // + static inline const Transform3 scale( const Vector3 & scaleVec ); + + // Construct a 3x4 transformation matrix to perform translation + // + static inline const Transform3 translation( const Vector3 & translateVec ); + +}; +// Append (post-multiply) a scale transformation to a 3x4 transformation matrix +// NOTE: +// Faster than creating and multiplying a scale transformation matrix. +// +inline const Transform3 appendScale( const Transform3 & tfrm, const Vector3 & scaleVec ); + +// Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix +// NOTE: +// Faster than creating and multiplying a scale transformation matrix. +// +inline const Transform3 prependScale( const Vector3 & scaleVec, const Transform3 & tfrm ); + +// Multiply two 3x4 transformation matrices per element +// +inline const Transform3 mulPerElem( const Transform3 & tfrm0, const Transform3 & tfrm1 ); + +// Compute the absolute value of a 3x4 transformation matrix per element +// +inline const Transform3 absPerElem( const Transform3 & tfrm ); + +// Inverse of a 3x4 transformation matrix +// NOTE: +// Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0. +// +inline const Transform3 inverse( const Transform3 & tfrm ); + +// Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix +// NOTE: +// This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions. +// +inline const Transform3 orthoInverse( const Transform3 & tfrm ); + +// Conditionally select between two 3x4 transformation matrices +// +inline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, bool select1 ); + +#ifdef _VECTORMATH_DEBUG + +// Print a 3x4 transformation matrix +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Transform3 & tfrm ); + +// Print a 3x4 transformation matrix and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Transform3 & tfrm, const char * name ); + +#endif + +} // namespace Aos +} // namespace Vectormath + +#include "vec_aos.h" +#include "quat_aos.h" +#include "mat_aos.h" + +#endif diff --git a/vectormathlibrary/include/vectormath/spu/c/mat_aos.h b/vectormathlibrary/include/vectormath/spu/c/mat_aos.h new file mode 100644 index 000000000..d6b4cb0ba --- /dev/null +++ b/vectormathlibrary/include/vectormath/spu/c/mat_aos.h @@ -0,0 +1,1833 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_MAT_AOS_C_H +#define _VECTORMATH_MAT_AOS_C_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/*----------------------------------------------------------------------------- + * Constants + * for shuffles, words are labeled [x,y,z,w] [a,b,c,d] + */ +#define _VECTORMATH_SHUF_XAYB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_B }) +#define _VECTORMATH_SHUF_ZCWD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_D }) +#define _VECTORMATH_SHUF_ZBW0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_0 }) +#define _VECTORMATH_SHUF_XCY0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_0 }) +#define _VECTORMATH_SHUF_XYAB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_B }) +#define _VECTORMATH_SHUF_ZWCD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_D }) +#define _VECTORMATH_SHUF_0ZB0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_0, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_0 }) +#define _VECTORMATH_SHUF_C0X0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_0, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_0 }) +#define _VECTORMATH_SHUF_YA00 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_0, _VECTORMATH_SHUF_0 }) +#define _VECTORMATH_SHUF_XAZC ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_C }) +#define _VECTORMATH_SHUF_YXWZ ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_Z }) +#define _VECTORMATH_SHUF_YBWD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_D }) +#define _VECTORMATH_SHUF_XYCX ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_X }) +#define _VECTORMATH_SHUF_YCXY ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y }) +#define _VECTORMATH_SHUF_CXYC ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_C }) +#define _VECTORMATH_SHUF_ZAY0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_0 }) +#define _VECTORMATH_SHUF_BZX0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_0 }) +#define _VECTORMATH_SHUF_0ZYA ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_0, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_A }) +#define _VECTORMATH_SHUF_Z0XB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_0, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_B }) +#define _VECTORMATH_SHUF_YX0C ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_0, _VECTORMATH_SHUF_C }) +#define _VECTORMATH_SHUF_CZD0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_D, _VECTORMATH_SHUF_0 }) +#define _VECTORMATH_SHUF_BBY0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_0 }) +#define _VECTORMATH_PI_OVER_2 1.570796327f + +/*----------------------------------------------------------------------------- + * Definitions + */ +static inline void vmathM3Copy( VmathMatrix3 *result, const VmathMatrix3 *mat ) +{ + vmathV3Copy( &result->col0, &mat->col0 ); + vmathV3Copy( &result->col1, &mat->col1 ); + vmathV3Copy( &result->col2, &mat->col2 ); +} + +static inline void vmathM3MakeFromScalar( VmathMatrix3 *result, float scalar ) +{ + vmathV3MakeFromScalar( &result->col0, scalar ); + vmathV3MakeFromScalar( &result->col1, scalar ); + vmathV3MakeFromScalar( &result->col2, scalar ); +} + +static inline void vmathM3MakeFromQ( VmathMatrix3 *result, const VmathQuat *unitQuat ) +{ + vec_float4 xyzw_2, wwww, yzxw, zxyw, yzxw_2, zxyw_2; + vec_float4 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; + vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f); + vec_uint4 select_x = (vec_uint4)spu_maskb(0xf000); + vec_uint4 select_z = (vec_uint4)spu_maskb(0x00f0); + xyzw_2 = spu_add( unitQuat->vec128, unitQuat->vec128 ); + wwww = spu_shuffle( unitQuat->vec128, unitQuat->vec128, shuffle_wwww ); + yzxw = spu_shuffle( unitQuat->vec128, unitQuat->vec128, _VECTORMATH_SHUF_YZXW ); + zxyw = spu_shuffle( unitQuat->vec128, unitQuat->vec128, _VECTORMATH_SHUF_ZXYW ); + yzxw_2 = spu_shuffle( xyzw_2, xyzw_2, _VECTORMATH_SHUF_YZXW ); + zxyw_2 = spu_shuffle( xyzw_2, xyzw_2, _VECTORMATH_SHUF_ZXYW ); + tmp0 = spu_mul( yzxw_2, wwww ); + tmp1 = spu_nmsub( yzxw, yzxw_2, spu_splats(1.0f) ); + tmp2 = spu_mul( yzxw, xyzw_2 ); + tmp0 = spu_madd( zxyw, xyzw_2, tmp0 ); + tmp1 = spu_nmsub( zxyw, zxyw_2, tmp1 ); + tmp2 = spu_nmsub( zxyw_2, wwww, tmp2 ); + tmp3 = spu_sel( tmp0, tmp1, select_x ); + tmp4 = spu_sel( tmp1, tmp2, select_x ); + tmp5 = spu_sel( tmp2, tmp0, select_x ); + result->col0.vec128 = spu_sel( tmp3, tmp2, select_z ); + result->col1.vec128 = spu_sel( tmp4, tmp0, select_z ); + result->col2.vec128 = spu_sel( tmp5, tmp1, select_z ); +} + +static inline void vmathM3MakeFromCols( VmathMatrix3 *result, const VmathVector3 *_col0, const VmathVector3 *_col1, const VmathVector3 *_col2 ) +{ + vmathV3Copy( &result->col0, _col0 ); + vmathV3Copy( &result->col1, _col1 ); + vmathV3Copy( &result->col2, _col2 ); +} + +static inline void vmathM3SetCol0( VmathMatrix3 *result, const VmathVector3 *_col0 ) +{ + vmathV3Copy( &result->col0, _col0 ); +} + +static inline void vmathM3SetCol1( VmathMatrix3 *result, const VmathVector3 *_col1 ) +{ + vmathV3Copy( &result->col1, _col1 ); +} + +static inline void vmathM3SetCol2( VmathMatrix3 *result, const VmathVector3 *_col2 ) +{ + vmathV3Copy( &result->col2, _col2 ); +} + +static inline void vmathM3SetCol( VmathMatrix3 *result, int col, const VmathVector3 *vec ) +{ + vmathV3Copy( (&result->col0 + col), vec ); +} + +static inline void vmathM3SetRow( VmathMatrix3 *result, int row, const VmathVector3 *vec ) +{ + vmathV3SetElem( &result->col0, row, vmathV3GetElem( vec, 0 ) ); + vmathV3SetElem( &result->col1, row, vmathV3GetElem( vec, 1 ) ); + vmathV3SetElem( &result->col2, row, vmathV3GetElem( vec, 2 ) ); +} + +static inline void vmathM3SetElem( VmathMatrix3 *result, int col, int row, float val ) +{ + VmathVector3 tmpV3_0; + vmathM3GetCol( &tmpV3_0, result, col ); + vmathV3SetElem( &tmpV3_0, row, val ); + vmathM3SetCol( result, col, &tmpV3_0 ); +} + +static inline float vmathM3GetElem( const VmathMatrix3 *mat, int col, int row ) +{ + VmathVector3 tmpV3_0; + vmathM3GetCol( &tmpV3_0, mat, col ); + return vmathV3GetElem( &tmpV3_0, row ); +} + +static inline void vmathM3GetCol0( VmathVector3 *result, const VmathMatrix3 *mat ) +{ + vmathV3Copy( result, &mat->col0 ); +} + +static inline void vmathM3GetCol1( VmathVector3 *result, const VmathMatrix3 *mat ) +{ + vmathV3Copy( result, &mat->col1 ); +} + +static inline void vmathM3GetCol2( VmathVector3 *result, const VmathMatrix3 *mat ) +{ + vmathV3Copy( result, &mat->col2 ); +} + +static inline void vmathM3GetCol( VmathVector3 *result, const VmathMatrix3 *mat, int col ) +{ + vmathV3Copy( result, (&mat->col0 + col) ); +} + +static inline void vmathM3GetRow( VmathVector3 *result, const VmathMatrix3 *mat, int row ) +{ + vmathV3MakeFromElems( result, vmathV3GetElem( &mat->col0, row ), vmathV3GetElem( &mat->col1, row ), vmathV3GetElem( &mat->col2, row ) ); +} + +static inline void vmathM3Transpose( VmathMatrix3 *result, const VmathMatrix3 *mat ) +{ + vec_float4 tmp0, tmp1, res0, res1, res2; + tmp0 = spu_shuffle( mat->col0.vec128, mat->col2.vec128, _VECTORMATH_SHUF_XAYB ); + tmp1 = spu_shuffle( mat->col0.vec128, mat->col2.vec128, _VECTORMATH_SHUF_ZCWD ); + res0 = spu_shuffle( tmp0, mat->col1.vec128, _VECTORMATH_SHUF_XAYB ); + res1 = spu_shuffle( tmp0, mat->col1.vec128, _VECTORMATH_SHUF_ZBW0 ); + res2 = spu_shuffle( tmp1, mat->col1.vec128, _VECTORMATH_SHUF_XCY0 ); + result->col0.vec128 = res0; + result->col1.vec128 = res1; + result->col2.vec128 = res2; +} + +static inline void vmathM3Inverse( VmathMatrix3 *result, const VmathMatrix3 *mat ) +{ + vec_float4 tmp0, tmp1, tmp2, tmp3, tmp4, dot, invdet, inv0, inv1, inv2; + tmp2 = _vmathVfCross( mat->col0.vec128, mat->col1.vec128 ); + tmp0 = _vmathVfCross( mat->col1.vec128, mat->col2.vec128 ); + tmp1 = _vmathVfCross( mat->col2.vec128, mat->col0.vec128 ); + dot = _vmathVfDot3( tmp2, mat->col2.vec128 ); + dot = spu_shuffle( dot, dot, (vec_uchar16)spu_splats(0x00010203) ); + invdet = recipf4( dot ); + tmp3 = spu_shuffle( tmp0, tmp2, _VECTORMATH_SHUF_XAYB ); + tmp4 = spu_shuffle( tmp0, tmp2, _VECTORMATH_SHUF_ZCWD ); + inv0 = spu_shuffle( tmp3, tmp1, _VECTORMATH_SHUF_XAYB ); + inv1 = spu_shuffle( tmp3, tmp1, _VECTORMATH_SHUF_ZBW0 ); + inv2 = spu_shuffle( tmp4, tmp1, _VECTORMATH_SHUF_XCY0 ); + inv0 = spu_mul( inv0, invdet ); + inv1 = spu_mul( inv1, invdet ); + inv2 = spu_mul( inv2, invdet ); + result->col0.vec128 = inv0; + result->col1.vec128 = inv1; + result->col2.vec128 = inv2; +} + +static inline float vmathM3Determinant( const VmathMatrix3 *mat ) +{ + VmathVector3 tmpV3_0; + vmathV3Cross( &tmpV3_0, &mat->col0, &mat->col1 ); + return vmathV3Dot( &mat->col2, &tmpV3_0 ); +} + +static inline void vmathM3Add( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ) +{ + vmathV3Add( &result->col0, &mat0->col0, &mat1->col0 ); + vmathV3Add( &result->col1, &mat0->col1, &mat1->col1 ); + vmathV3Add( &result->col2, &mat0->col2, &mat1->col2 ); +} + +static inline void vmathM3Sub( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ) +{ + vmathV3Sub( &result->col0, &mat0->col0, &mat1->col0 ); + vmathV3Sub( &result->col1, &mat0->col1, &mat1->col1 ); + vmathV3Sub( &result->col2, &mat0->col2, &mat1->col2 ); +} + +static inline void vmathM3Neg( VmathMatrix3 *result, const VmathMatrix3 *mat ) +{ + vmathV3Neg( &result->col0, &mat->col0 ); + vmathV3Neg( &result->col1, &mat->col1 ); + vmathV3Neg( &result->col2, &mat->col2 ); +} + +static inline void vmathM3AbsPerElem( VmathMatrix3 *result, const VmathMatrix3 *mat ) +{ + vmathV3AbsPerElem( &result->col0, &mat->col0 ); + vmathV3AbsPerElem( &result->col1, &mat->col1 ); + vmathV3AbsPerElem( &result->col2, &mat->col2 ); +} + +static inline void vmathM3ScalarMul( VmathMatrix3 *result, const VmathMatrix3 *mat, float scalar ) +{ + vmathV3ScalarMul( &result->col0, &mat->col0, scalar ); + vmathV3ScalarMul( &result->col1, &mat->col1, scalar ); + vmathV3ScalarMul( &result->col2, &mat->col2, scalar ); +} + +static inline void vmathM3MulV3( VmathVector3 *result, const VmathMatrix3 *mat, const VmathVector3 *vec ) +{ + vec_float4 res; + vec_float4 xxxx, yyyy, zzzz; + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); + xxxx = spu_shuffle( vec->vec128, vec->vec128, shuffle_xxxx ); + yyyy = spu_shuffle( vec->vec128, vec->vec128, shuffle_yyyy ); + zzzz = spu_shuffle( vec->vec128, vec->vec128, shuffle_zzzz ); + res = spu_mul( mat->col0.vec128, xxxx ); + res = spu_madd( mat->col1.vec128, yyyy, res ); + res = spu_madd( mat->col2.vec128, zzzz, res ); + result->vec128 = res; +} + +static inline void vmathM3Mul( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ) +{ + VmathMatrix3 tmpResult; + vmathM3MulV3( &tmpResult.col0, mat0, &mat1->col0 ); + vmathM3MulV3( &tmpResult.col1, mat0, &mat1->col1 ); + vmathM3MulV3( &tmpResult.col2, mat0, &mat1->col2 ); + vmathM3Copy( result, &tmpResult ); +} + +static inline void vmathM3MulPerElem( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ) +{ + vmathV3MulPerElem( &result->col0, &mat0->col0, &mat1->col0 ); + vmathV3MulPerElem( &result->col1, &mat0->col1, &mat1->col1 ); + vmathV3MulPerElem( &result->col2, &mat0->col2, &mat1->col2 ); +} + +static inline void vmathM3MakeIdentity( VmathMatrix3 *result ) +{ + vmathV3MakeXAxis( &result->col0 ); + vmathV3MakeYAxis( &result->col1 ); + vmathV3MakeZAxis( &result->col2 ); +} + +static inline void vmathM3MakeRotationX( VmathMatrix3 *result, float radians ) +{ + vec_float4 s, c, res1, res2; + vec_uint4 select_y, select_z; + vec_float4 zero; + select_y = (vec_uint4)spu_maskb(0x0f00); + select_z = (vec_uint4)spu_maskb(0x00f0); + zero = spu_splats(0.0f); + sincosf4( spu_splats(radians), &s, &c ); + res1 = spu_sel( zero, c, select_y ); + res1 = spu_sel( res1, s, select_z ); + res2 = spu_sel( zero, negatef4(s), select_y ); + res2 = spu_sel( res2, c, select_z ); + vmathV3MakeXAxis( &result->col0 ); + result->col1.vec128 = res1; + result->col2.vec128 = res2; +} + +static inline void vmathM3MakeRotationY( VmathMatrix3 *result, float radians ) +{ + vec_float4 s, c, res0, res2; + vec_uint4 select_x, select_z; + vec_float4 zero; + select_x = (vec_uint4)spu_maskb(0xf000); + select_z = (vec_uint4)spu_maskb(0x00f0); + zero = spu_splats(0.0f); + sincosf4( spu_splats(radians), &s, &c ); + res0 = spu_sel( zero, c, select_x ); + res0 = spu_sel( res0, negatef4(s), select_z ); + res2 = spu_sel( zero, s, select_x ); + res2 = spu_sel( res2, c, select_z ); + result->col0.vec128 = res0; + vmathV3MakeYAxis( &result->col1 ); + result->col2.vec128 = res2; +} + +static inline void vmathM3MakeRotationZ( VmathMatrix3 *result, float radians ) +{ + vec_float4 s, c, res0, res1; + vec_uint4 select_x, select_y; + vec_float4 zero; + select_x = (vec_uint4)spu_maskb(0xf000); + select_y = (vec_uint4)spu_maskb(0x0f00); + zero = spu_splats(0.0f); + sincosf4( spu_splats(radians), &s, &c ); + res0 = spu_sel( zero, c, select_x ); + res0 = spu_sel( res0, s, select_y ); + res1 = spu_sel( zero, negatef4(s), select_x ); + res1 = spu_sel( res1, c, select_y ); + result->col0.vec128 = res0; + result->col1.vec128 = res1; + vmathV3MakeZAxis( &result->col2 ); +} + +static inline void vmathM3MakeRotationZYX( VmathMatrix3 *result, const VmathVector3 *radiansXYZ ) +{ + vec_float4 angles, s, negS, c, X0, X1, Y0, Y1, Z0, Z1, tmp; + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + angles = radiansXYZ->vec128; + angles = spu_insert( 0.0f, angles, 3 ); + sincosf4( angles, &s, &c ); + negS = negatef4( s ); + Z0 = spu_shuffle( s, c, _VECTORMATH_SHUF_CZD0 ); + Z1 = spu_shuffle( c, negS, _VECTORMATH_SHUF_CZD0 ); + Y0 = spu_shuffle( negS, c, _VECTORMATH_SHUF_BBY0 ); + Y1 = spu_shuffle( c, s, _VECTORMATH_SHUF_BBY0 ); + X0 = spu_shuffle( s, s, shuffle_xxxx ); + X1 = spu_shuffle( c, c, shuffle_xxxx ); + tmp = spu_mul( Z0, Y1 ); + result->col0.vec128 = spu_mul( Z0, Y0 ); + result->col1.vec128 = spu_madd( Z1, X1, spu_mul( tmp, X0 ) ); + result->col2.vec128 = spu_nmsub( Z1, X0, spu_mul( tmp, X1 ) ); +} + +static inline void vmathM3MakeRotationAxis( VmathMatrix3 *result, float radians, const VmathVector3 *unitVec ) +{ + vec_float4 axis, s, c, oneMinusC, axisS, negAxisS, xxxx, yyyy, zzzz, tmp0, tmp1, tmp2; + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); + axis = unitVec->vec128; + sincosf4( spu_splats( radians ), &s, &c ); + xxxx = spu_shuffle( axis, axis, shuffle_xxxx ); + yyyy = spu_shuffle( axis, axis, shuffle_yyyy ); + zzzz = spu_shuffle( axis, axis, shuffle_zzzz ); + oneMinusC = spu_sub( spu_splats(1.0f), c ); + axisS = spu_mul( axis, s ); + negAxisS = negatef4( axisS ); + tmp0 = spu_shuffle( axisS, negAxisS, _VECTORMATH_SHUF_0ZB0 ); + tmp1 = spu_shuffle( axisS, negAxisS, _VECTORMATH_SHUF_C0X0 ); + tmp2 = spu_shuffle( axisS, negAxisS, _VECTORMATH_SHUF_YA00 ); + tmp0 = spu_sel( tmp0, c, (vec_uint4)spu_maskb(0xf000) ); + tmp1 = spu_sel( tmp1, c, (vec_uint4)spu_maskb(0x0f00) ); + tmp2 = spu_sel( tmp2, c, (vec_uint4)spu_maskb(0x00f0) ); + result->col0.vec128 = spu_madd( spu_mul( axis, xxxx ), oneMinusC, tmp0 ); + result->col1.vec128 = spu_madd( spu_mul( axis, yyyy ), oneMinusC, tmp1 ); + result->col2.vec128 = spu_madd( spu_mul( axis, zzzz ), oneMinusC, tmp2 ); +} + +static inline void vmathM3MakeRotationQ( VmathMatrix3 *result, const VmathQuat *unitQuat ) +{ + vmathM3MakeFromQ( result, unitQuat ); +} + +static inline void vmathM3MakeScale( VmathMatrix3 *result, const VmathVector3 *scaleVec ) +{ + vec_float4 zero = spu_splats(0.0f); + result->col0.vec128 = spu_sel( zero, scaleVec->vec128, (vec_uint4)spu_maskb(0xf000) ); + result->col1.vec128 = spu_sel( zero, scaleVec->vec128, (vec_uint4)spu_maskb(0x0f00) ); + result->col2.vec128 = spu_sel( zero, scaleVec->vec128, (vec_uint4)spu_maskb(0x00f0) ); +} + +static inline void vmathM3AppendScale( VmathMatrix3 *result, const VmathMatrix3 *mat, const VmathVector3 *scaleVec ) +{ + vmathV3ScalarMul( &result->col0, &mat->col0, vmathV3GetX( scaleVec ) ); + vmathV3ScalarMul( &result->col1, &mat->col1, vmathV3GetY( scaleVec ) ); + vmathV3ScalarMul( &result->col2, &mat->col2, vmathV3GetZ( scaleVec ) ); +} + +static inline void vmathM3PrependScale( VmathMatrix3 *result, const VmathVector3 *scaleVec, const VmathMatrix3 *mat ) +{ + vmathV3MulPerElem( &result->col0, &mat->col0, scaleVec ); + vmathV3MulPerElem( &result->col1, &mat->col1, scaleVec ); + vmathV3MulPerElem( &result->col2, &mat->col2, scaleVec ); +} + +static inline void vmathM3Select( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1, unsigned int select1 ) +{ + vmathV3Select( &result->col0, &mat0->col0, &mat1->col0, select1 ); + vmathV3Select( &result->col1, &mat0->col1, &mat1->col1, select1 ); + vmathV3Select( &result->col2, &mat0->col2, &mat1->col2, select1 ); +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathM3Print( const VmathMatrix3 *mat ) +{ + VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2; + vmathM3GetRow( &tmpV3_0, mat, 0 ); + vmathV3Print( &tmpV3_0 ); + vmathM3GetRow( &tmpV3_1, mat, 1 ); + vmathV3Print( &tmpV3_1 ); + vmathM3GetRow( &tmpV3_2, mat, 2 ); + vmathV3Print( &tmpV3_2 ); +} + +static inline void vmathM3Prints( const VmathMatrix3 *mat, const char *name ) +{ + printf("%s:\n", name); + vmathM3Print( mat ); +} + +#endif + +static inline void vmathM4Copy( VmathMatrix4 *result, const VmathMatrix4 *mat ) +{ + vmathV4Copy( &result->col0, &mat->col0 ); + vmathV4Copy( &result->col1, &mat->col1 ); + vmathV4Copy( &result->col2, &mat->col2 ); + vmathV4Copy( &result->col3, &mat->col3 ); +} + +static inline void vmathM4MakeFromScalar( VmathMatrix4 *result, float scalar ) +{ + vmathV4MakeFromScalar( &result->col0, scalar ); + vmathV4MakeFromScalar( &result->col1, scalar ); + vmathV4MakeFromScalar( &result->col2, scalar ); + vmathV4MakeFromScalar( &result->col3, scalar ); +} + +static inline void vmathM4MakeFromT3( VmathMatrix4 *result, const VmathTransform3 *mat ) +{ + vmathV4MakeFromV3Scalar( &result->col0, &mat->col0, 0.0f ); + vmathV4MakeFromV3Scalar( &result->col1, &mat->col1, 0.0f ); + vmathV4MakeFromV3Scalar( &result->col2, &mat->col2, 0.0f ); + vmathV4MakeFromV3Scalar( &result->col3, &mat->col3, 1.0f ); +} + +static inline void vmathM4MakeFromCols( VmathMatrix4 *result, const VmathVector4 *_col0, const VmathVector4 *_col1, const VmathVector4 *_col2, const VmathVector4 *_col3 ) +{ + vmathV4Copy( &result->col0, _col0 ); + vmathV4Copy( &result->col1, _col1 ); + vmathV4Copy( &result->col2, _col2 ); + vmathV4Copy( &result->col3, _col3 ); +} + +static inline void vmathM4MakeFromM3V3( VmathMatrix4 *result, const VmathMatrix3 *mat, const VmathVector3 *translateVec ) +{ + vmathV4MakeFromV3Scalar( &result->col0, &mat->col0, 0.0f ); + vmathV4MakeFromV3Scalar( &result->col1, &mat->col1, 0.0f ); + vmathV4MakeFromV3Scalar( &result->col2, &mat->col2, 0.0f ); + vmathV4MakeFromV3Scalar( &result->col3, translateVec, 1.0f ); +} + +static inline void vmathM4MakeFromQV3( VmathMatrix4 *result, const VmathQuat *unitQuat, const VmathVector3 *translateVec ) +{ + VmathMatrix3 mat; + vmathM3MakeFromQ( &mat, unitQuat ); + vmathV4MakeFromV3Scalar( &result->col0, &mat.col0, 0.0f ); + vmathV4MakeFromV3Scalar( &result->col1, &mat.col1, 0.0f ); + vmathV4MakeFromV3Scalar( &result->col2, &mat.col2, 0.0f ); + vmathV4MakeFromV3Scalar( &result->col3, translateVec, 1.0f ); +} + +static inline void vmathM4SetCol0( VmathMatrix4 *result, const VmathVector4 *_col0 ) +{ + vmathV4Copy( &result->col0, _col0 ); +} + +static inline void vmathM4SetCol1( VmathMatrix4 *result, const VmathVector4 *_col1 ) +{ + vmathV4Copy( &result->col1, _col1 ); +} + +static inline void vmathM4SetCol2( VmathMatrix4 *result, const VmathVector4 *_col2 ) +{ + vmathV4Copy( &result->col2, _col2 ); +} + +static inline void vmathM4SetCol3( VmathMatrix4 *result, const VmathVector4 *_col3 ) +{ + vmathV4Copy( &result->col3, _col3 ); +} + +static inline void vmathM4SetCol( VmathMatrix4 *result, int col, const VmathVector4 *vec ) +{ + vmathV4Copy( (&result->col0 + col), vec ); +} + +static inline void vmathM4SetRow( VmathMatrix4 *result, int row, const VmathVector4 *vec ) +{ + vmathV4SetElem( &result->col0, row, vmathV4GetElem( vec, 0 ) ); + vmathV4SetElem( &result->col1, row, vmathV4GetElem( vec, 1 ) ); + vmathV4SetElem( &result->col2, row, vmathV4GetElem( vec, 2 ) ); + vmathV4SetElem( &result->col3, row, vmathV4GetElem( vec, 3 ) ); +} + +static inline void vmathM4SetElem( VmathMatrix4 *result, int col, int row, float val ) +{ + VmathVector4 tmpV3_0; + vmathM4GetCol( &tmpV3_0, result, col ); + vmathV4SetElem( &tmpV3_0, row, val ); + vmathM4SetCol( result, col, &tmpV3_0 ); +} + +static inline float vmathM4GetElem( const VmathMatrix4 *mat, int col, int row ) +{ + VmathVector4 tmpV4_0; + vmathM4GetCol( &tmpV4_0, mat, col ); + return vmathV4GetElem( &tmpV4_0, row ); +} + +static inline void vmathM4GetCol0( VmathVector4 *result, const VmathMatrix4 *mat ) +{ + vmathV4Copy( result, &mat->col0 ); +} + +static inline void vmathM4GetCol1( VmathVector4 *result, const VmathMatrix4 *mat ) +{ + vmathV4Copy( result, &mat->col1 ); +} + +static inline void vmathM4GetCol2( VmathVector4 *result, const VmathMatrix4 *mat ) +{ + vmathV4Copy( result, &mat->col2 ); +} + +static inline void vmathM4GetCol3( VmathVector4 *result, const VmathMatrix4 *mat ) +{ + vmathV4Copy( result, &mat->col3 ); +} + +static inline void vmathM4GetCol( VmathVector4 *result, const VmathMatrix4 *mat, int col ) +{ + vmathV4Copy( result, (&mat->col0 + col) ); +} + +static inline void vmathM4GetRow( VmathVector4 *result, const VmathMatrix4 *mat, int row ) +{ + vmathV4MakeFromElems( result, vmathV4GetElem( &mat->col0, row ), vmathV4GetElem( &mat->col1, row ), vmathV4GetElem( &mat->col2, row ), vmathV4GetElem( &mat->col3, row ) ); +} + +static inline void vmathM4Transpose( VmathMatrix4 *result, const VmathMatrix4 *mat ) +{ + vec_float4 tmp0, tmp1, tmp2, tmp3, res0, res1, res2, res3; + tmp0 = spu_shuffle( mat->col0.vec128, mat->col2.vec128, _VECTORMATH_SHUF_XAYB ); + tmp1 = spu_shuffle( mat->col1.vec128, mat->col3.vec128, _VECTORMATH_SHUF_XAYB ); + tmp2 = spu_shuffle( mat->col0.vec128, mat->col2.vec128, _VECTORMATH_SHUF_ZCWD ); + tmp3 = spu_shuffle( mat->col1.vec128, mat->col3.vec128, _VECTORMATH_SHUF_ZCWD ); + res0 = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB ); + res1 = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD ); + res2 = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB ); + res3 = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_ZCWD ); + result->col0.vec128 = res0; + result->col1.vec128 = res1; + result->col2.vec128 = res2; + result->col3.vec128 = res3; +} + +static inline void vmathM4Inverse( VmathMatrix4 *result, const VmathMatrix4 *mat ) +{ + /* function implementation based on code from STIDC SDK: */ + /* -------------------------------------------------------------- */ + /* PLEASE DO NOT MODIFY THIS SECTION */ + /* This prolog section is automatically generated. */ + /* */ + /* (C)Copyright */ + /* Sony Computer Entertainment, Inc., */ + /* Toshiba Corporation, */ + /* International Business Machines Corporation, */ + /* 2001,2002. */ + /* S/T/I Confidential Information */ + /* -------------------------------------------------------------- */ + vec_float4 in0, in1, in2, in3; + vec_float4 tmp0, tmp1, tmp2, tmp3; + vec_float4 cof0, cof1, cof2, cof3; + vec_float4 t0, t1, t2, t3; + vec_float4 t01, t02, t03, t12, t23; + vec_float4 t1r, t2r; + vec_float4 t01r, t02r, t03r, t12r, t23r; + vec_float4 t1r3, t1r3r; + vec_float4 det, det1, det2, det3, invdet; + in0 = mat->col0.vec128; + in1 = mat->col1.vec128; + in2 = mat->col2.vec128; + in3 = mat->col3.vec128; + /* Perform transform of the input matrix of the form: + * A B C D + * E F G H + * I J K L + * M N O P + * + * The pseudo transpose of the input matrix is trans: + * A E I M + * J N B F + * C G K O + * L P D H + */ + tmp0 = spu_shuffle(in0, in1, _VECTORMATH_SHUF_XAZC); /* A E C G */ + tmp1 = spu_shuffle(in2, in3, _VECTORMATH_SHUF_XAZC); /* I M K O */ + tmp2 = spu_shuffle(in0, in1, _VECTORMATH_SHUF_YBWD); /* B F D H */ + tmp3 = spu_shuffle(in2, in3, _VECTORMATH_SHUF_YBWD); /* J N L P */ + t0 = spu_shuffle(tmp0, tmp1, _VECTORMATH_SHUF_XYAB); /* A E I M */ + t1 = spu_shuffle(tmp3, tmp2, _VECTORMATH_SHUF_XYAB); /* J N B F */ + t2 = spu_shuffle(tmp0, tmp1, _VECTORMATH_SHUF_ZWCD); /* C G K O */ + t3 = spu_shuffle(tmp3, tmp2, _VECTORMATH_SHUF_ZWCD); /* L P D H */ + /* Generate a cofactor matrix. The computed cofactors reside in + * cof0, cof1, cof2, cof3. + */ + t23 = spu_mul(t2, t3); /* CL GP KD OH */ + t23 = spu_shuffle(t23, t23, _VECTORMATH_SHUF_YXWZ); /* GP CL OH KD */ + cof0 = spu_mul(t1, t23); /* JGP NCL BOH FKD */ + cof1 = spu_mul(t0, t23); /* AGP ECL IOH MKD */ + t23r = spu_rlqwbyte(t23, 8); /* OH KD GP CL */ + cof0 = spu_msub(t1, t23r, cof0); /* JOH NKD BGP FCL - cof0 */ + cof1 = spu_msub(t0, t23r, cof1); /* AOH EKD IGP MCL - cof1 */ + cof1 = spu_rlqwbyte(cof1, 8); /* IGP MCL AOH EKD - IOH MKD AGP ECL */ + + t12 = spu_mul(t1, t2); /* JC NG BK FO */ + t12 = spu_shuffle(t12, t12, _VECTORMATH_SHUF_YXWZ); /* NG JC FO BK */ + cof0 = spu_madd(t3, t12, cof0); /* LNG PJC DFO HBK + cof0 */ + cof3 = spu_mul(t0, t12); /* ANG EJC IFO MBK */ + t12r = spu_rlqwbyte(t12, 8); /* FO BK NG JC */ + cof0 = spu_nmsub(t3, t12r, cof0); /* cof0 - LFO PBK DNG HJC */ + cof3 = spu_msub(t0, t12r, cof3); /* AFO EBK ING MJC - cof3 */ + cof3 = spu_rlqwbyte(cof3, 8); /* ING MJC AFO EBK - IFO MBK ANG EJC */ + t1r = spu_rlqwbyte(t1, 8); /* B F J N */ + t2r = spu_rlqwbyte(t2, 8); /* K O C G */ + t1r3 = spu_mul(t1r, t3); /* BL FP JD NH */ + t1r3 = spu_shuffle(t1r3, t1r3, _VECTORMATH_SHUF_YXWZ); /* FP BL NH JD */ + cof0 = spu_madd(t2r, t1r3, cof0); /* KFP OBL CNH GJD + cof0 */ + cof2 = spu_mul(t0, t1r3); /* AFP EBL INH MJD */ + t1r3r = spu_rlqwbyte(t1r3, 8); /* NH JD FP BL */ + cof0 = spu_nmsub(t2r, t1r3r, cof0); /* cof0 - KNH OJD CFP GBL */ + cof2 = spu_msub(t0, t1r3r, cof2); /* ANH EJD IFP MBL - cof2 */ + cof2 = spu_rlqwbyte(cof2, 8); /* IFP MBL ANH EJD - INH MJD AFP EBL */ + t01 = spu_mul(t0, t1); /* AJ EN IB MF */ + t01 = spu_shuffle(t01, t01, _VECTORMATH_SHUF_YXWZ); /* EN AJ MF IB */ + cof2 = spu_madd(t3, t01, cof2); /* LEN PAJ DMF HIB + cof2 */ + cof3 = spu_msub(t2r, t01, cof3); /* KEN OAJ CMF GIB - cof3 */ + t01r = spu_rlqwbyte(t01, 8); /* MF IB EN AJ */ + cof2 = spu_msub(t3, t01r, cof2); /* LMF PIB DEN HAJ - cof2 */ + cof3 = spu_nmsub(t2r, t01r, cof3); /* cof3 - KMF OIB CEN GAJ */ + t03 = spu_mul(t0, t3); /* AL EP ID MH */ + t03 = spu_shuffle(t03, t03, _VECTORMATH_SHUF_YXWZ); /* EP AL MH ID */ + cof1 = spu_nmsub(t2r, t03, cof1); /* cof1 - KEP OAL CMH GID */ + cof2 = spu_madd(t1, t03, cof2); /* JEP NAL BMH FID + cof2 */ + t03r = spu_rlqwbyte(t03, 8); /* MH ID EP AL */ + cof1 = spu_madd(t2r, t03r, cof1); /* KMH OID CEP GAL + cof1 */ + cof2 = spu_nmsub(t1, t03r, cof2); /* cof2 - JMH NID BEP FAL */ + t02 = spu_mul(t0, t2r); /* AK EO IC MG */ + t02 = spu_shuffle(t02, t02, _VECTORMATH_SHUF_YXWZ); /* E0 AK MG IC */ + cof1 = spu_madd(t3, t02, cof1); /* LEO PAK DMG HIC + cof1 */ + cof3 = spu_nmsub(t1, t02, cof3); /* cof3 - JEO NAK BMG FIC */ + t02r = spu_rlqwbyte(t02, 8); /* MG IC EO AK */ + cof1 = spu_nmsub(t3, t02r, cof1); /* cof1 - LMG PIC DEO HAK */ + cof3 = spu_madd(t1, t02r, cof3); /* JMG NIC BEO FAK + cof3 */ + /* Compute the determinant of the matrix + * + * det = sum_across(t0 * cof0); + * + * We perform a sum across the entire vector so that + * we don't have to splat the result when multiplying the + * cofactors by the inverse of the determinant. + */ + det = spu_mul(t0, cof0); + det1 = spu_rlqwbyte(det, 4); + det2 = spu_rlqwbyte(det, 8); + det3 = spu_rlqwbyte(det, 12); + det = spu_add(det, det1); + det2 = spu_add(det2, det3); + det = spu_add(det, det2); + /* Compute the reciprocal of the determinant. + */ + invdet = recipf4(det); + /* Multiply the cofactors by the reciprocal of the determinant. + */ + result->col0.vec128 = spu_mul(cof0, invdet); + result->col1.vec128 = spu_mul(cof1, invdet); + result->col2.vec128 = spu_mul(cof2, invdet); + result->col3.vec128 = spu_mul(cof3, invdet); +} + +static inline void vmathM4AffineInverse( VmathMatrix4 *result, const VmathMatrix4 *mat ) +{ + VmathTransform3 affineMat, tmpT3_0; + VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3; + vmathV4GetXYZ( &tmpV3_0, &mat->col0 ); + vmathT3SetCol0( &affineMat, &tmpV3_0 ); + vmathV4GetXYZ( &tmpV3_1, &mat->col1 ); + vmathT3SetCol1( &affineMat, &tmpV3_1 ); + vmathV4GetXYZ( &tmpV3_2, &mat->col2 ); + vmathT3SetCol2( &affineMat, &tmpV3_2 ); + vmathV4GetXYZ( &tmpV3_3, &mat->col3 ); + vmathT3SetCol3( &affineMat, &tmpV3_3 ); + vmathT3Inverse( &tmpT3_0, &affineMat ); + vmathM4MakeFromT3( result, &tmpT3_0 ); +} + +static inline void vmathM4OrthoInverse( VmathMatrix4 *result, const VmathMatrix4 *mat ) +{ + VmathTransform3 affineMat, tmpT3_0; + VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3; + vmathV4GetXYZ( &tmpV3_0, &mat->col0 ); + vmathT3SetCol0( &affineMat, &tmpV3_0 ); + vmathV4GetXYZ( &tmpV3_1, &mat->col1 ); + vmathT3SetCol1( &affineMat, &tmpV3_1 ); + vmathV4GetXYZ( &tmpV3_2, &mat->col2 ); + vmathT3SetCol2( &affineMat, &tmpV3_2 ); + vmathV4GetXYZ( &tmpV3_3, &mat->col3 ); + vmathT3SetCol3( &affineMat, &tmpV3_3 ); + vmathT3OrthoInverse( &tmpT3_0, &affineMat ); + vmathM4MakeFromT3( result, &tmpT3_0 ); +} + +static inline float vmathM4Determinant( const VmathMatrix4 *mat ) +{ + /* function implementation based on code from STIDC SDK: */ + /* -------------------------------------------------------------- */ + /* PLEASE DO NOT MODIFY THIS SECTION */ + /* This prolog section is automatically generated. */ + /* */ + /* (C)Copyright */ + /* Sony Computer Entertainment, Inc., */ + /* Toshiba Corporation, */ + /* International Business Machines Corporation, */ + /* 2001,2002. */ + /* S/T/I Confidential Information */ + /* -------------------------------------------------------------- */ + vec_float4 in0, in1, in2, in3; + vec_float4 tmp0, tmp1, tmp2, tmp3; + vec_float4 cof0; + vec_float4 t0, t1, t2, t3; + vec_float4 t12, t23; + vec_float4 t1r, t2r; + vec_float4 t12r, t23r; + vec_float4 t1r3, t1r3r; + in0 = mat->col0.vec128; + in1 = mat->col1.vec128; + in2 = mat->col2.vec128; + in3 = mat->col3.vec128; + /* Perform transform of the input matrix of the form: + * A B C D + * E F G H + * I J K L + * M N O P + * + * The pseudo transpose of the input matrix is trans: + * A E I M + * J N B F + * C G K O + * L P D H + */ + tmp0 = spu_shuffle(in0, in1, _VECTORMATH_SHUF_XAZC); /* A E C G */ + tmp1 = spu_shuffle(in2, in3, _VECTORMATH_SHUF_XAZC); /* I M K O */ + tmp2 = spu_shuffle(in0, in1, _VECTORMATH_SHUF_YBWD); /* B F D H */ + tmp3 = spu_shuffle(in2, in3, _VECTORMATH_SHUF_YBWD); /* J N L P */ + t0 = spu_shuffle(tmp0, tmp1, _VECTORMATH_SHUF_XYAB); /* A E I M */ + t1 = spu_shuffle(tmp3, tmp2, _VECTORMATH_SHUF_XYAB); /* J N B F */ + t2 = spu_shuffle(tmp0, tmp1, _VECTORMATH_SHUF_ZWCD); /* C G K O */ + t3 = spu_shuffle(tmp3, tmp2, _VECTORMATH_SHUF_ZWCD); /* L P D H */ + /* Generate a cofactor matrix. The computed cofactors reside in + * cof0, cof1, cof2, cof3. + */ + t23 = spu_mul(t2, t3); /* CL GP KD OH */ + t23 = spu_shuffle(t23, t23, _VECTORMATH_SHUF_YXWZ); /* GP CL OH KD */ + cof0 = spu_mul(t1, t23); /* JGP NCL BOH FKD */ + t23r = spu_rlqwbyte(t23, 8); /* OH KD GP CL */ + cof0 = spu_msub(t1, t23r, cof0); /* JOH NKD BGP FCL - cof0 */ + + t12 = spu_mul(t1, t2); /* JC NG BK FO */ + t12 = spu_shuffle(t12, t12, _VECTORMATH_SHUF_YXWZ); /* NG JC FO BK */ + cof0 = spu_madd(t3, t12, cof0); /* LNG PJC DFO HBK + cof0 */ + t12r = spu_rlqwbyte(t12, 8); /* FO BK NG JC */ + cof0 = spu_nmsub(t3, t12r, cof0); /* cof0 - LFO PBK DNG HJC */ + t1r = spu_rlqwbyte(t1, 8); /* B F J N */ + t2r = spu_rlqwbyte(t2, 8); /* K O C G */ + t1r3 = spu_mul(t1r, t3); /* BL FP JD NH */ + t1r3 = spu_shuffle(t1r3, t1r3, _VECTORMATH_SHUF_YXWZ); /* FP BL NH JD */ + cof0 = spu_madd(t2r, t1r3, cof0); /* KFP OBL CNH GJD + cof0 */ + t1r3r = spu_rlqwbyte(t1r3, 8); /* NH JD FP BL */ + cof0 = spu_nmsub(t2r, t1r3r, cof0); /* cof0 - KNH OJD CFP GBL */ + return spu_extract( _vmathVfDot4(t0,cof0), 0 ); +} + +static inline void vmathM4Add( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ) +{ + vmathV4Add( &result->col0, &mat0->col0, &mat1->col0 ); + vmathV4Add( &result->col1, &mat0->col1, &mat1->col1 ); + vmathV4Add( &result->col2, &mat0->col2, &mat1->col2 ); + vmathV4Add( &result->col3, &mat0->col3, &mat1->col3 ); +} + +static inline void vmathM4Sub( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ) +{ + vmathV4Sub( &result->col0, &mat0->col0, &mat1->col0 ); + vmathV4Sub( &result->col1, &mat0->col1, &mat1->col1 ); + vmathV4Sub( &result->col2, &mat0->col2, &mat1->col2 ); + vmathV4Sub( &result->col3, &mat0->col3, &mat1->col3 ); +} + +static inline void vmathM4Neg( VmathMatrix4 *result, const VmathMatrix4 *mat ) +{ + vmathV4Neg( &result->col0, &mat->col0 ); + vmathV4Neg( &result->col1, &mat->col1 ); + vmathV4Neg( &result->col2, &mat->col2 ); + vmathV4Neg( &result->col3, &mat->col3 ); +} + +static inline void vmathM4AbsPerElem( VmathMatrix4 *result, const VmathMatrix4 *mat ) +{ + vmathV4AbsPerElem( &result->col0, &mat->col0 ); + vmathV4AbsPerElem( &result->col1, &mat->col1 ); + vmathV4AbsPerElem( &result->col2, &mat->col2 ); + vmathV4AbsPerElem( &result->col3, &mat->col3 ); +} + +static inline void vmathM4ScalarMul( VmathMatrix4 *result, const VmathMatrix4 *mat, float scalar ) +{ + vmathV4ScalarMul( &result->col0, &mat->col0, scalar ); + vmathV4ScalarMul( &result->col1, &mat->col1, scalar ); + vmathV4ScalarMul( &result->col2, &mat->col2, scalar ); + vmathV4ScalarMul( &result->col3, &mat->col3, scalar ); +} + +static inline void vmathM4MulV4( VmathVector4 *result, const VmathMatrix4 *mat, const VmathVector4 *vec ) +{ + vec_float4 tmp0, tmp1, res; + vec_float4 xxxx, yyyy, zzzz, wwww; + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); + vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f); + xxxx = spu_shuffle( vec->vec128, vec->vec128, shuffle_xxxx ); + yyyy = spu_shuffle( vec->vec128, vec->vec128, shuffle_yyyy ); + zzzz = spu_shuffle( vec->vec128, vec->vec128, shuffle_zzzz ); + wwww = spu_shuffle( vec->vec128, vec->vec128, shuffle_wwww ); + tmp0 = spu_mul( mat->col0.vec128, xxxx ); + tmp1 = spu_mul( mat->col1.vec128, yyyy ); + tmp0 = spu_madd( mat->col2.vec128, zzzz, tmp0 ); + tmp1 = spu_madd( mat->col3.vec128, wwww, tmp1 ); + res = spu_add( tmp0, tmp1 ); + result->vec128 = res; +} + +static inline void vmathM4MulV3( VmathVector4 *result, const VmathMatrix4 *mat, const VmathVector3 *vec ) +{ + vec_float4 res; + vec_float4 xxxx, yyyy, zzzz; + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); + xxxx = spu_shuffle( vec->vec128, vec->vec128, shuffle_xxxx ); + yyyy = spu_shuffle( vec->vec128, vec->vec128, shuffle_yyyy ); + zzzz = spu_shuffle( vec->vec128, vec->vec128, shuffle_zzzz ); + res = spu_mul( mat->col0.vec128, xxxx ); + res = spu_madd( mat->col1.vec128, yyyy, res ); + res = spu_madd( mat->col2.vec128, zzzz, res ); + result->vec128 = res; +} + +static inline void vmathM4MulP3( VmathVector4 *result, const VmathMatrix4 *mat, const VmathPoint3 *pnt ) +{ + vec_float4 tmp0, tmp1, res; + vec_float4 xxxx, yyyy, zzzz; + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); + xxxx = spu_shuffle( pnt->vec128, pnt->vec128, shuffle_xxxx ); + yyyy = spu_shuffle( pnt->vec128, pnt->vec128, shuffle_yyyy ); + zzzz = spu_shuffle( pnt->vec128, pnt->vec128, shuffle_zzzz ); + tmp0 = spu_mul( mat->col0.vec128, xxxx ); + tmp1 = spu_mul( mat->col1.vec128, yyyy ); + tmp0 = spu_madd( mat->col2.vec128, zzzz, tmp0 ); + tmp1 = spu_add( mat->col3.vec128, tmp1 ); + res = spu_add( tmp0, tmp1 ); + result->vec128 = res; +} + +static inline void vmathM4Mul( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ) +{ + VmathMatrix4 tmpResult; + vmathM4MulV4( &tmpResult.col0, mat0, &mat1->col0 ); + vmathM4MulV4( &tmpResult.col1, mat0, &mat1->col1 ); + vmathM4MulV4( &tmpResult.col2, mat0, &mat1->col2 ); + vmathM4MulV4( &tmpResult.col3, mat0, &mat1->col3 ); + vmathM4Copy( result, &tmpResult ); +} + +static inline void vmathM4MulT3( VmathMatrix4 *result, const VmathMatrix4 *mat, const VmathTransform3 *tfrm1 ) +{ + VmathMatrix4 tmpResult; + VmathPoint3 tmpP3_0; + vmathM4MulV3( &tmpResult.col0, mat, &tfrm1->col0 ); + vmathM4MulV3( &tmpResult.col1, mat, &tfrm1->col1 ); + vmathM4MulV3( &tmpResult.col2, mat, &tfrm1->col2 ); + vmathP3MakeFromV3( &tmpP3_0, &tfrm1->col3 ); + vmathM4MulP3( &tmpResult.col3, mat, &tmpP3_0 ); + vmathM4Copy( result, &tmpResult ); +} + +static inline void vmathM4MulPerElem( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ) +{ + vmathV4MulPerElem( &result->col0, &mat0->col0, &mat1->col0 ); + vmathV4MulPerElem( &result->col1, &mat0->col1, &mat1->col1 ); + vmathV4MulPerElem( &result->col2, &mat0->col2, &mat1->col2 ); + vmathV4MulPerElem( &result->col3, &mat0->col3, &mat1->col3 ); +} + +static inline void vmathM4MakeIdentity( VmathMatrix4 *result ) +{ + vmathV4MakeXAxis( &result->col0 ); + vmathV4MakeYAxis( &result->col1 ); + vmathV4MakeZAxis( &result->col2 ); + vmathV4MakeWAxis( &result->col3 ); +} + +static inline void vmathM4SetUpper3x3( VmathMatrix4 *result, const VmathMatrix3 *mat3 ) +{ + vmathV4SetXYZ( &result->col0, &mat3->col0 ); + vmathV4SetXYZ( &result->col1, &mat3->col1 ); + vmathV4SetXYZ( &result->col2, &mat3->col2 ); +} + +static inline void vmathM4GetUpper3x3( VmathMatrix3 *result, const VmathMatrix4 *mat ) +{ + vmathV4GetXYZ( &result->col0, &mat->col0 ); + vmathV4GetXYZ( &result->col1, &mat->col1 ); + vmathV4GetXYZ( &result->col2, &mat->col2 ); +} + +static inline void vmathM4SetTranslation( VmathMatrix4 *result, const VmathVector3 *translateVec ) +{ + vmathV4SetXYZ( &result->col3, translateVec ); +} + +static inline void vmathM4GetTranslation( VmathVector3 *result, const VmathMatrix4 *mat ) +{ + vmathV4GetXYZ( result, &mat->col3 ); +} + +static inline void vmathM4MakeRotationX( VmathMatrix4 *result, float radians ) +{ + vec_float4 s, c, res1, res2; + vec_uint4 select_y, select_z; + vec_float4 zero; + select_y = (vec_uint4)spu_maskb(0x0f00); + select_z = (vec_uint4)spu_maskb(0x00f0); + zero = spu_splats(0.0f); + sincosf4( spu_splats(radians), &s, &c ); + res1 = spu_sel( zero, c, select_y ); + res1 = spu_sel( res1, s, select_z ); + res2 = spu_sel( zero, negatef4(s), select_y ); + res2 = spu_sel( res2, c, select_z ); + vmathV4MakeXAxis( &result->col0 ); + result->col1.vec128 = res1; + result->col2.vec128 = res2; + vmathV4MakeWAxis( &result->col3 ); +} + +static inline void vmathM4MakeRotationY( VmathMatrix4 *result, float radians ) +{ + vec_float4 s, c, res0, res2; + vec_uint4 select_x, select_z; + vec_float4 zero; + select_x = (vec_uint4)spu_maskb(0xf000); + select_z = (vec_uint4)spu_maskb(0x00f0); + zero = spu_splats(0.0f); + sincosf4( spu_splats(radians), &s, &c ); + res0 = spu_sel( zero, c, select_x ); + res0 = spu_sel( res0, negatef4(s), select_z ); + res2 = spu_sel( zero, s, select_x ); + res2 = spu_sel( res2, c, select_z ); + result->col0.vec128 = res0; + vmathV4MakeYAxis( &result->col1 ); + result->col2.vec128 = res2; + vmathV4MakeWAxis( &result->col3 ); +} + +static inline void vmathM4MakeRotationZ( VmathMatrix4 *result, float radians ) +{ + vec_float4 s, c, res0, res1; + vec_uint4 select_x, select_y; + vec_float4 zero; + select_x = (vec_uint4)spu_maskb(0xf000); + select_y = (vec_uint4)spu_maskb(0x0f00); + zero = spu_splats(0.0f); + sincosf4( spu_splats(radians), &s, &c ); + res0 = spu_sel( zero, c, select_x ); + res0 = spu_sel( res0, s, select_y ); + res1 = spu_sel( zero, negatef4(s), select_x ); + res1 = spu_sel( res1, c, select_y ); + result->col0.vec128 = res0; + result->col1.vec128 = res1; + vmathV4MakeZAxis( &result->col2 ); + vmathV4MakeWAxis( &result->col3 ); +} + +static inline void vmathM4MakeRotationZYX( VmathMatrix4 *result, const VmathVector3 *radiansXYZ ) +{ + vec_float4 angles, s, negS, c, X0, X1, Y0, Y1, Z0, Z1, tmp; + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + angles = radiansXYZ->vec128; + angles = spu_insert( 0.0f, angles, 3 ); + sincosf4( angles, &s, &c ); + negS = negatef4( s ); + Z0 = spu_shuffle( s, c, _VECTORMATH_SHUF_CZD0 ); + Z1 = spu_shuffle( c, negS, _VECTORMATH_SHUF_CZD0 ); + Y0 = spu_shuffle( negS, c, _VECTORMATH_SHUF_BBY0 ); + Y1 = spu_shuffle( c, s, _VECTORMATH_SHUF_BBY0 ); + X0 = spu_shuffle( s, s, shuffle_xxxx ); + X1 = spu_shuffle( c, c, shuffle_xxxx ); + tmp = spu_mul( Z0, Y1 ); + result->col0.vec128 = spu_mul( Z0, Y0 ); + result->col1.vec128 = spu_madd( Z1, X1, spu_mul( tmp, X0 ) ); + result->col2.vec128 = spu_nmsub( Z1, X0, spu_mul( tmp, X1 ) ); + vmathV4MakeWAxis( &result->col3 ); +} + +static inline void vmathM4MakeRotationAxis( VmathMatrix4 *result, float radians, const VmathVector3 *unitVec ) +{ + vec_float4 axis, s, c, oneMinusC, axisS, negAxisS, xxxx, yyyy, zzzz, tmp0, tmp1, tmp2, zeroW; + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); + axis = unitVec->vec128; + sincosf4( spu_splats( radians ), &s, &c ); + xxxx = spu_shuffle( axis, axis, shuffle_xxxx ); + yyyy = spu_shuffle( axis, axis, shuffle_yyyy ); + zzzz = spu_shuffle( axis, axis, shuffle_zzzz ); + oneMinusC = spu_sub( spu_splats(1.0f), c ); + axisS = spu_mul( axis, s ); + negAxisS = negatef4( axisS ); + tmp0 = spu_shuffle( axisS, negAxisS, _VECTORMATH_SHUF_0ZB0 ); + tmp1 = spu_shuffle( axisS, negAxisS, _VECTORMATH_SHUF_C0X0 ); + tmp2 = spu_shuffle( axisS, negAxisS, _VECTORMATH_SHUF_YA00 ); + tmp0 = spu_sel( tmp0, c, (vec_uint4)spu_maskb(0xf000) ); + tmp1 = spu_sel( tmp1, c, (vec_uint4)spu_maskb(0x0f00) ); + tmp2 = spu_sel( tmp2, c, (vec_uint4)spu_maskb(0x00f0) ); + zeroW = (vec_float4)spu_maskb(0x000f); + axis = spu_andc( axis, zeroW ); + result->col0.vec128 = spu_madd( spu_mul( axis, xxxx ), oneMinusC, tmp0 ); + result->col1.vec128 = spu_madd( spu_mul( axis, yyyy ), oneMinusC, tmp1 ); + result->col2.vec128 = spu_madd( spu_mul( axis, zzzz ), oneMinusC, tmp2 ); + vmathV4MakeWAxis( &result->col3 ); +} + +static inline void vmathM4MakeRotationQ( VmathMatrix4 *result, const VmathQuat *unitQuat ) +{ + VmathTransform3 tmpT3_0; + vmathT3MakeRotationQ( &tmpT3_0, unitQuat ); + vmathM4MakeFromT3( result, &tmpT3_0 ); +} + +static inline void vmathM4MakeScale( VmathMatrix4 *result, const VmathVector3 *scaleVec ) +{ + vec_float4 zero = spu_splats(0.0f); + result->col0.vec128 = spu_sel( zero, scaleVec->vec128, (vec_uint4)spu_maskb(0xf000) ); + result->col1.vec128 = spu_sel( zero, scaleVec->vec128, (vec_uint4)spu_maskb(0x0f00) ); + result->col2.vec128 = spu_sel( zero, scaleVec->vec128, (vec_uint4)spu_maskb(0x00f0) ); + vmathV4MakeWAxis( &result->col3 ); +} + +static inline void vmathM4AppendScale( VmathMatrix4 *result, const VmathMatrix4 *mat, const VmathVector3 *scaleVec ) +{ + vmathV4ScalarMul( &result->col0, &mat->col0, vmathV3GetX( scaleVec ) ); + vmathV4ScalarMul( &result->col1, &mat->col1, vmathV3GetY( scaleVec ) ); + vmathV4ScalarMul( &result->col2, &mat->col2, vmathV3GetZ( scaleVec ) ); + vmathV4Copy( &result->col3, &mat->col3 ); +} + +static inline void vmathM4PrependScale( VmathMatrix4 *result, const VmathVector3 *scaleVec, const VmathMatrix4 *mat ) +{ + VmathVector4 scale4; + vmathV4MakeFromV3Scalar( &scale4, scaleVec, 1.0f ); + vmathV4MulPerElem( &result->col0, &mat->col0, &scale4 ); + vmathV4MulPerElem( &result->col1, &mat->col1, &scale4 ); + vmathV4MulPerElem( &result->col2, &mat->col2, &scale4 ); + vmathV4MulPerElem( &result->col3, &mat->col3, &scale4 ); +} + +static inline void vmathM4MakeTranslation( VmathMatrix4 *result, const VmathVector3 *translateVec ) +{ + vmathV4MakeXAxis( &result->col0 ); + vmathV4MakeYAxis( &result->col1 ); + vmathV4MakeZAxis( &result->col2 ); + vmathV4MakeFromV3Scalar( &result->col3, translateVec, 1.0f ); +} + +static inline void vmathM4MakeLookAt( VmathMatrix4 *result, const VmathPoint3 *eyePos, const VmathPoint3 *lookAtPos, const VmathVector3 *upVec ) +{ + VmathMatrix4 m4EyeFrame; + VmathVector3 v3X, v3Y, v3Z, tmpV3_0, tmpV3_1; + VmathVector4 tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3; + vmathV3Normalize( &v3Y, upVec ); + vmathP3Sub( &tmpV3_0, eyePos, lookAtPos ); + vmathV3Normalize( &v3Z, &tmpV3_0 ); + vmathV3Cross( &tmpV3_1, &v3Y, &v3Z ); + vmathV3Normalize( &v3X, &tmpV3_1 ); + vmathV3Cross( &v3Y, &v3Z, &v3X ); + vmathV4MakeFromV3( &tmpV4_0, &v3X ); + vmathV4MakeFromV3( &tmpV4_1, &v3Y ); + vmathV4MakeFromV3( &tmpV4_2, &v3Z ); + vmathV4MakeFromP3( &tmpV4_3, eyePos ); + vmathM4MakeFromCols( &m4EyeFrame, &tmpV4_0, &tmpV4_1, &tmpV4_2, &tmpV4_3 ); + vmathM4OrthoInverse( result, &m4EyeFrame ); +} + +static inline void vmathM4MakePerspective( VmathMatrix4 *result, float fovyRadians, float aspect, float zNear, float zFar ) +{ + float f, rangeInv; + vec_float4 zero, col0, col1, col2, col3; + f = tanf( _VECTORMATH_PI_OVER_2 - fovyRadians * 0.5f ); + rangeInv = 1.0f / ( zNear - zFar ); + zero = spu_splats(0.0f); + col0 = zero; + col1 = zero; + col2 = zero; + col3 = zero; + col0 = spu_insert( f / aspect, col0, 0 ); + col1 = spu_insert( f, col1, 1 ); + col2 = spu_insert( ( zNear + zFar ) * rangeInv, col2, 2 ); + col2 = spu_insert( -1.0f, col2, 3 ); + col3 = spu_insert( zNear * zFar * rangeInv * 2.0f, col3, 2 ); + result->col0.vec128 = col0; + result->col1.vec128 = col1; + result->col2.vec128 = col2; + result->col3.vec128 = col3; +} + +static inline void vmathM4MakeFrustum( VmathMatrix4 *result, float left, float right, float bottom, float top, float zNear, float zFar ) +{ + /* function implementation based on code from STIDC SDK: */ + /* -------------------------------------------------------------- */ + /* PLEASE DO NOT MODIFY THIS SECTION */ + /* This prolog section is automatically generated. */ + /* */ + /* (C)Copyright */ + /* Sony Computer Entertainment, Inc., */ + /* Toshiba Corporation, */ + /* International Business Machines Corporation, */ + /* 2001,2002. */ + /* S/T/I Confidential Information */ + /* -------------------------------------------------------------- */ + vec_float4 lbf, rtn; + vec_float4 diff, sum, inv_diff; + vec_float4 diagonal, column, near2; + vec_float4 zero = spu_splats(0.0f); + lbf = spu_shuffle( spu_promote(left,0), spu_promote(zFar,0), _VECTORMATH_SHUF_XAYB ); + rtn = spu_shuffle( spu_promote(right,0), spu_promote(zNear,0), _VECTORMATH_SHUF_XAYB ); + lbf = spu_shuffle( lbf, spu_promote(bottom,0), _VECTORMATH_SHUF_XAYB ); + rtn = spu_shuffle( rtn, spu_promote(top,0), _VECTORMATH_SHUF_XAYB ); + diff = spu_sub( rtn, lbf ); + sum = spu_add( rtn, lbf ); + inv_diff = recipf4( diff ); + near2 = spu_splats( zNear ); + near2 = spu_add( near2, near2 ); + diagonal = spu_mul( near2, inv_diff ); + column = spu_mul( sum, inv_diff ); + result->col0.vec128 = spu_sel( zero, diagonal, (vec_uint4)spu_maskb(0xf000) ); + result->col1.vec128 = spu_sel( zero, diagonal, (vec_uint4)spu_maskb(0x0f00) ); + result->col2.vec128 = spu_sel( column, spu_splats(-1.0f), (vec_uint4)spu_maskb(0x000f) ); + result->col3.vec128 = spu_sel( zero, spu_mul( diagonal, spu_splats(zFar) ), (vec_uint4)spu_maskb(0x00f0) ); +} + +static inline void vmathM4MakeOrthographic( VmathMatrix4 *result, float left, float right, float bottom, float top, float zNear, float zFar ) +{ + /* function implementation based on code from STIDC SDK: */ + /* -------------------------------------------------------------- */ + /* PLEASE DO NOT MODIFY THIS SECTION */ + /* This prolog section is automatically generated. */ + /* */ + /* (C)Copyright */ + /* Sony Computer Entertainment, Inc., */ + /* Toshiba Corporation, */ + /* International Business Machines Corporation, */ + /* 2001,2002. */ + /* S/T/I Confidential Information */ + /* -------------------------------------------------------------- */ + vec_float4 lbf, rtn; + vec_float4 diff, sum, inv_diff, neg_inv_diff; + vec_float4 diagonal, column; + vec_float4 zero = spu_splats(0.0f); + lbf = spu_shuffle( spu_promote(left,0), spu_promote(zFar,0), _VECTORMATH_SHUF_XAYB ); + rtn = spu_shuffle( spu_promote(right,0), spu_promote(zNear,0), _VECTORMATH_SHUF_XAYB ); + lbf = spu_shuffle( lbf, spu_promote(bottom,0), _VECTORMATH_SHUF_XAYB ); + rtn = spu_shuffle( rtn, spu_promote(top,0), _VECTORMATH_SHUF_XAYB ); + diff = spu_sub( rtn, lbf ); + sum = spu_add( rtn, lbf ); + inv_diff = recipf4( diff ); + neg_inv_diff = negatef4( inv_diff ); + diagonal = spu_add( inv_diff, inv_diff ); + column = spu_mul( sum, spu_sel( neg_inv_diff, inv_diff, (vec_uint4)spu_maskb(0x00f0) ) ); + result->col0.vec128 = spu_sel( zero, diagonal, (vec_uint4)spu_maskb(0xf000) ); + result->col1.vec128 = spu_sel( zero, diagonal, (vec_uint4)spu_maskb(0x0f00) ); + result->col2.vec128 = spu_sel( zero, diagonal, (vec_uint4)spu_maskb(0x00f0) ); + result->col3.vec128 = spu_sel( column, spu_splats(1.0f), (vec_uint4)spu_maskb(0x000f) ); +} + +static inline void vmathM4Select( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1, unsigned int select1 ) +{ + vmathV4Select( &result->col0, &mat0->col0, &mat1->col0, select1 ); + vmathV4Select( &result->col1, &mat0->col1, &mat1->col1, select1 ); + vmathV4Select( &result->col2, &mat0->col2, &mat1->col2, select1 ); + vmathV4Select( &result->col3, &mat0->col3, &mat1->col3, select1 ); +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathM4Print( const VmathMatrix4 *mat ) +{ + VmathVector4 tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3; + vmathM4GetRow( &tmpV4_0, mat, 0 ); + vmathV4Print( &tmpV4_0 ); + vmathM4GetRow( &tmpV4_1, mat, 1 ); + vmathV4Print( &tmpV4_1 ); + vmathM4GetRow( &tmpV4_2, mat, 2 ); + vmathV4Print( &tmpV4_2 ); + vmathM4GetRow( &tmpV4_3, mat, 3 ); + vmathV4Print( &tmpV4_3 ); +} + +static inline void vmathM4Prints( const VmathMatrix4 *mat, const char *name ) +{ + printf("%s:\n", name); + vmathM4Print( mat ); +} + +#endif + +static inline void vmathT3Copy( VmathTransform3 *result, const VmathTransform3 *tfrm ) +{ + vmathV3Copy( &result->col0, &tfrm->col0 ); + vmathV3Copy( &result->col1, &tfrm->col1 ); + vmathV3Copy( &result->col2, &tfrm->col2 ); + vmathV3Copy( &result->col3, &tfrm->col3 ); +} + +static inline void vmathT3MakeFromScalar( VmathTransform3 *result, float scalar ) +{ + vmathV3MakeFromScalar( &result->col0, scalar ); + vmathV3MakeFromScalar( &result->col1, scalar ); + vmathV3MakeFromScalar( &result->col2, scalar ); + vmathV3MakeFromScalar( &result->col3, scalar ); +} + +static inline void vmathT3MakeFromCols( VmathTransform3 *result, const VmathVector3 *_col0, const VmathVector3 *_col1, const VmathVector3 *_col2, const VmathVector3 *_col3 ) +{ + vmathV3Copy( &result->col0, _col0 ); + vmathV3Copy( &result->col1, _col1 ); + vmathV3Copy( &result->col2, _col2 ); + vmathV3Copy( &result->col3, _col3 ); +} + +static inline void vmathT3MakeFromM3V3( VmathTransform3 *result, const VmathMatrix3 *tfrm, const VmathVector3 *translateVec ) +{ + vmathT3SetUpper3x3( result, tfrm ); + vmathT3SetTranslation( result, translateVec ); +} + +static inline void vmathT3MakeFromQV3( VmathTransform3 *result, const VmathQuat *unitQuat, const VmathVector3 *translateVec ) +{ + VmathMatrix3 tmpM3_0; + vmathM3MakeFromQ( &tmpM3_0, unitQuat ); + vmathT3SetUpper3x3( result, &tmpM3_0 ); + vmathT3SetTranslation( result, translateVec ); +} + +static inline void vmathT3SetCol0( VmathTransform3 *result, const VmathVector3 *_col0 ) +{ + vmathV3Copy( &result->col0, _col0 ); +} + +static inline void vmathT3SetCol1( VmathTransform3 *result, const VmathVector3 *_col1 ) +{ + vmathV3Copy( &result->col1, _col1 ); +} + +static inline void vmathT3SetCol2( VmathTransform3 *result, const VmathVector3 *_col2 ) +{ + vmathV3Copy( &result->col2, _col2 ); +} + +static inline void vmathT3SetCol3( VmathTransform3 *result, const VmathVector3 *_col3 ) +{ + vmathV3Copy( &result->col3, _col3 ); +} + +static inline void vmathT3SetCol( VmathTransform3 *result, int col, const VmathVector3 *vec ) +{ + vmathV3Copy( (&result->col0 + col), vec ); +} + +static inline void vmathT3SetRow( VmathTransform3 *result, int row, const VmathVector4 *vec ) +{ + vmathV3SetElem( &result->col0, row, vmathV4GetElem( vec, 0 ) ); + vmathV3SetElem( &result->col1, row, vmathV4GetElem( vec, 1 ) ); + vmathV3SetElem( &result->col2, row, vmathV4GetElem( vec, 2 ) ); + vmathV3SetElem( &result->col3, row, vmathV4GetElem( vec, 3 ) ); +} + +static inline void vmathT3SetElem( VmathTransform3 *result, int col, int row, float val ) +{ + VmathVector3 tmpV3_0; + vmathT3GetCol( &tmpV3_0, result, col ); + vmathV3SetElem( &tmpV3_0, row, val ); + vmathT3SetCol( result, col, &tmpV3_0 ); +} + +static inline float vmathT3GetElem( const VmathTransform3 *tfrm, int col, int row ) +{ + VmathVector3 tmpV3_0; + vmathT3GetCol( &tmpV3_0, tfrm, col ); + return vmathV3GetElem( &tmpV3_0, row ); +} + +static inline void vmathT3GetCol0( VmathVector3 *result, const VmathTransform3 *tfrm ) +{ + vmathV3Copy( result, &tfrm->col0 ); +} + +static inline void vmathT3GetCol1( VmathVector3 *result, const VmathTransform3 *tfrm ) +{ + vmathV3Copy( result, &tfrm->col1 ); +} + +static inline void vmathT3GetCol2( VmathVector3 *result, const VmathTransform3 *tfrm ) +{ + vmathV3Copy( result, &tfrm->col2 ); +} + +static inline void vmathT3GetCol3( VmathVector3 *result, const VmathTransform3 *tfrm ) +{ + vmathV3Copy( result, &tfrm->col3 ); +} + +static inline void vmathT3GetCol( VmathVector3 *result, const VmathTransform3 *tfrm, int col ) +{ + vmathV3Copy( result, (&tfrm->col0 + col) ); +} + +static inline void vmathT3GetRow( VmathVector4 *result, const VmathTransform3 *tfrm, int row ) +{ + vmathV4MakeFromElems( result, vmathV3GetElem( &tfrm->col0, row ), vmathV3GetElem( &tfrm->col1, row ), vmathV3GetElem( &tfrm->col2, row ), vmathV3GetElem( &tfrm->col3, row ) ); +} + +static inline void vmathT3Inverse( VmathTransform3 *result, const VmathTransform3 *tfrm ) +{ + vec_float4 inv0, inv1, inv2, inv3; + vec_float4 tmp0, tmp1, tmp2, tmp3, tmp4, dot, invdet; + vec_float4 xxxx, yyyy, zzzz; + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); + tmp2 = _vmathVfCross( tfrm->col0.vec128, tfrm->col1.vec128 ); + tmp0 = _vmathVfCross( tfrm->col1.vec128, tfrm->col2.vec128 ); + tmp1 = _vmathVfCross( tfrm->col2.vec128, tfrm->col0.vec128 ); + inv3 = negatef4( tfrm->col3.vec128 ); + dot = _vmathVfDot3( tmp2, tfrm->col2.vec128 ); + dot = spu_shuffle( dot, dot, shuffle_xxxx ); + invdet = recipf4( dot ); + tmp3 = spu_shuffle( tmp0, tmp2, _VECTORMATH_SHUF_XAYB ); + tmp4 = spu_shuffle( tmp0, tmp2, _VECTORMATH_SHUF_ZCWD ); + inv0 = spu_shuffle( tmp3, tmp1, _VECTORMATH_SHUF_XAYB ); + xxxx = spu_shuffle( inv3, inv3, shuffle_xxxx ); + inv1 = spu_shuffle( tmp3, tmp1, _VECTORMATH_SHUF_ZBW0 ); + inv2 = spu_shuffle( tmp4, tmp1, _VECTORMATH_SHUF_XCY0 ); + yyyy = spu_shuffle( inv3, inv3, shuffle_yyyy ); + zzzz = spu_shuffle( inv3, inv3, shuffle_zzzz ); + inv3 = spu_mul( inv0, xxxx ); + inv3 = spu_madd( inv1, yyyy, inv3 ); + inv3 = spu_madd( inv2, zzzz, inv3 ); + inv0 = spu_mul( inv0, invdet ); + inv1 = spu_mul( inv1, invdet ); + inv2 = spu_mul( inv2, invdet ); + inv3 = spu_mul( inv3, invdet ); + result->col0.vec128 = inv0; + result->col1.vec128 = inv1; + result->col2.vec128 = inv2; + result->col3.vec128 = inv3; +} + +static inline void vmathT3OrthoInverse( VmathTransform3 *result, const VmathTransform3 *tfrm ) +{ + vec_float4 inv0, inv1, inv2, inv3; + vec_float4 tmp0, tmp1; + vec_float4 xxxx, yyyy, zzzz; + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); + tmp0 = spu_shuffle( tfrm->col0.vec128, tfrm->col2.vec128, _VECTORMATH_SHUF_XAYB ); + tmp1 = spu_shuffle( tfrm->col0.vec128, tfrm->col2.vec128, _VECTORMATH_SHUF_ZCWD ); + inv3 = negatef4( tfrm->col3.vec128 ); + inv0 = spu_shuffle( tmp0, tfrm->col1.vec128, _VECTORMATH_SHUF_XAYB ); + xxxx = spu_shuffle( inv3, inv3, shuffle_xxxx ); + inv1 = spu_shuffle( tmp0, tfrm->col1.vec128, _VECTORMATH_SHUF_ZBW0 ); + inv2 = spu_shuffle( tmp1, tfrm->col1.vec128, _VECTORMATH_SHUF_XCY0 ); + yyyy = spu_shuffle( inv3, inv3, shuffle_yyyy ); + zzzz = spu_shuffle( inv3, inv3, shuffle_zzzz ); + inv3 = spu_mul( inv0, xxxx ); + inv3 = spu_madd( inv1, yyyy, inv3 ); + inv3 = spu_madd( inv2, zzzz, inv3 ); + result->col0.vec128 = inv0; + result->col1.vec128 = inv1; + result->col2.vec128 = inv2; + result->col3.vec128 = inv3; +} + +static inline void vmathT3AbsPerElem( VmathTransform3 *result, const VmathTransform3 *tfrm ) +{ + vmathV3AbsPerElem( &result->col0, &tfrm->col0 ); + vmathV3AbsPerElem( &result->col1, &tfrm->col1 ); + vmathV3AbsPerElem( &result->col2, &tfrm->col2 ); + vmathV3AbsPerElem( &result->col3, &tfrm->col3 ); +} + +static inline void vmathT3MulV3( VmathVector3 *result, const VmathTransform3 *tfrm, const VmathVector3 *vec ) +{ + vec_float4 res; + vec_float4 xxxx, yyyy, zzzz; + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); + xxxx = spu_shuffle( vec->vec128, vec->vec128, shuffle_xxxx ); + yyyy = spu_shuffle( vec->vec128, vec->vec128, shuffle_yyyy ); + zzzz = spu_shuffle( vec->vec128, vec->vec128, shuffle_zzzz ); + res = spu_mul( tfrm->col0.vec128, xxxx ); + res = spu_madd( tfrm->col1.vec128, yyyy, res ); + res = spu_madd( tfrm->col2.vec128, zzzz, res ); + result->vec128 = res; +} + +static inline void vmathT3MulP3( VmathPoint3 *result, const VmathTransform3 *tfrm, const VmathPoint3 *pnt ) +{ + vec_float4 tmp0, tmp1, res; + vec_float4 xxxx, yyyy, zzzz; + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); + xxxx = spu_shuffle( pnt->vec128, pnt->vec128, shuffle_xxxx ); + yyyy = spu_shuffle( pnt->vec128, pnt->vec128, shuffle_yyyy ); + zzzz = spu_shuffle( pnt->vec128, pnt->vec128, shuffle_zzzz ); + tmp0 = spu_mul( tfrm->col0.vec128, xxxx ); + tmp1 = spu_mul( tfrm->col1.vec128, yyyy ); + tmp0 = spu_madd( tfrm->col2.vec128, zzzz, tmp0 ); + tmp1 = spu_add( tfrm->col3.vec128, tmp1 ); + res = spu_add( tmp0, tmp1 ); + result->vec128 = res; +} + +static inline void vmathT3Mul( VmathTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1 ) +{ + VmathTransform3 tmpResult; + VmathPoint3 tmpP3_0, tmpP3_1; + vmathT3MulV3( &tmpResult.col0, tfrm0, &tfrm1->col0 ); + vmathT3MulV3( &tmpResult.col1, tfrm0, &tfrm1->col1 ); + vmathT3MulV3( &tmpResult.col2, tfrm0, &tfrm1->col2 ); + vmathP3MakeFromV3( &tmpP3_0, &tfrm1->col3 ); + vmathT3MulP3( &tmpP3_1, tfrm0, &tmpP3_0 ); + vmathV3MakeFromP3( &tmpResult.col3, &tmpP3_1 ); + vmathT3Copy( result, &tmpResult ); +} + +static inline void vmathT3MulPerElem( VmathTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1 ) +{ + vmathV3MulPerElem( &result->col0, &tfrm0->col0, &tfrm1->col0 ); + vmathV3MulPerElem( &result->col1, &tfrm0->col1, &tfrm1->col1 ); + vmathV3MulPerElem( &result->col2, &tfrm0->col2, &tfrm1->col2 ); + vmathV3MulPerElem( &result->col3, &tfrm0->col3, &tfrm1->col3 ); +} + +static inline void vmathT3MakeIdentity( VmathTransform3 *result ) +{ + vmathV3MakeXAxis( &result->col0 ); + vmathV3MakeYAxis( &result->col1 ); + vmathV3MakeZAxis( &result->col2 ); + vmathV3MakeFromScalar( &result->col3, 0.0f ); +} + +static inline void vmathT3SetUpper3x3( VmathTransform3 *result, const VmathMatrix3 *tfrm ) +{ + vmathV3Copy( &result->col0, &tfrm->col0 ); + vmathV3Copy( &result->col1, &tfrm->col1 ); + vmathV3Copy( &result->col2, &tfrm->col2 ); +} + +static inline void vmathT3GetUpper3x3( VmathMatrix3 *result, const VmathTransform3 *tfrm ) +{ + vmathM3MakeFromCols( result, &tfrm->col0, &tfrm->col1, &tfrm->col2 ); +} + +static inline void vmathT3SetTranslation( VmathTransform3 *result, const VmathVector3 *translateVec ) +{ + vmathV3Copy( &result->col3, translateVec ); +} + +static inline void vmathT3GetTranslation( VmathVector3 *result, const VmathTransform3 *tfrm ) +{ + vmathV3Copy( result, &tfrm->col3 ); +} + +static inline void vmathT3MakeRotationX( VmathTransform3 *result, float radians ) +{ + vec_float4 s, c, res1, res2; + vec_uint4 select_y, select_z; + vec_float4 zero; + select_y = (vec_uint4)spu_maskb(0x0f00); + select_z = (vec_uint4)spu_maskb(0x00f0); + zero = spu_splats(0.0f); + sincosf4( spu_splats(radians), &s, &c ); + res1 = spu_sel( zero, c, select_y ); + res1 = spu_sel( res1, s, select_z ); + res2 = spu_sel( zero, negatef4(s), select_y ); + res2 = spu_sel( res2, c, select_z ); + vmathV3MakeXAxis( &result->col0 ); + result->col1.vec128 = res1; + result->col2.vec128 = res2; + vmathV3MakeFromScalar( &result->col3, 0.0f ); +} + +static inline void vmathT3MakeRotationY( VmathTransform3 *result, float radians ) +{ + vec_float4 s, c, res0, res2; + vec_uint4 select_x, select_z; + vec_float4 zero; + select_x = (vec_uint4)spu_maskb(0xf000); + select_z = (vec_uint4)spu_maskb(0x00f0); + zero = spu_splats(0.0f); + sincosf4( spu_splats(radians), &s, &c ); + res0 = spu_sel( zero, c, select_x ); + res0 = spu_sel( res0, negatef4(s), select_z ); + res2 = spu_sel( zero, s, select_x ); + res2 = spu_sel( res2, c, select_z ); + result->col0.vec128 = res0; + vmathV3MakeYAxis( &result->col1 ); + result->col2.vec128 = res2; + vmathV3MakeFromScalar( &result->col3, 0.0f ); +} + +static inline void vmathT3MakeRotationZ( VmathTransform3 *result, float radians ) +{ + vec_float4 s, c, res0, res1; + vec_uint4 select_x, select_y; + vec_float4 zero; + select_x = (vec_uint4)spu_maskb(0xf000); + select_y = (vec_uint4)spu_maskb(0x0f00); + zero = spu_splats(0.0f); + sincosf4( spu_splats(radians), &s, &c ); + res0 = spu_sel( zero, c, select_x ); + res0 = spu_sel( res0, s, select_y ); + res1 = spu_sel( zero, negatef4(s), select_x ); + res1 = spu_sel( res1, c, select_y ); + result->col0.vec128 = res0; + result->col1.vec128 = res1; + vmathV3MakeZAxis( &result->col2 ); + vmathV3MakeFromScalar( &result->col3, 0.0f ); +} + +static inline void vmathT3MakeRotationZYX( VmathTransform3 *result, const VmathVector3 *radiansXYZ ) +{ + vec_float4 angles, s, negS, c, X0, X1, Y0, Y1, Z0, Z1, tmp; + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + angles = radiansXYZ->vec128; + angles = spu_insert( 0.0f, angles, 3 ); + sincosf4( angles, &s, &c ); + negS = negatef4( s ); + Z0 = spu_shuffle( s, c, _VECTORMATH_SHUF_CZD0 ); + Z1 = spu_shuffle( c, negS, _VECTORMATH_SHUF_CZD0 ); + Y0 = spu_shuffle( negS, c, _VECTORMATH_SHUF_BBY0 ); + Y1 = spu_shuffle( c, s, _VECTORMATH_SHUF_BBY0 ); + X0 = spu_shuffle( s, s, shuffle_xxxx ); + X1 = spu_shuffle( c, c, shuffle_xxxx ); + tmp = spu_mul( Z0, Y1 ); + result->col0.vec128 = spu_mul( Z0, Y0 ); + result->col1.vec128 = spu_madd( Z1, X1, spu_mul( tmp, X0 ) ); + result->col2.vec128 = spu_nmsub( Z1, X0, spu_mul( tmp, X1 ) ); + vmathV3MakeFromScalar( &result->col3, 0.0f ); +} + +static inline void vmathT3MakeRotationAxis( VmathTransform3 *result, float radians, const VmathVector3 *unitVec ) +{ + VmathMatrix3 tmpM3_0; + VmathVector3 tmpV3_0; + vmathM3MakeRotationAxis( &tmpM3_0, radians, unitVec ); + vmathV3MakeFromScalar( &tmpV3_0, 0.0f ); + vmathT3MakeFromM3V3( result, &tmpM3_0, &tmpV3_0 ); +} + +static inline void vmathT3MakeRotationQ( VmathTransform3 *result, const VmathQuat *unitQuat ) +{ + VmathMatrix3 tmpM3_0; + VmathVector3 tmpV3_0; + vmathM3MakeFromQ( &tmpM3_0, unitQuat ); + vmathV3MakeFromScalar( &tmpV3_0, 0.0f ); + vmathT3MakeFromM3V3( result, &tmpM3_0, &tmpV3_0 ); +} + +static inline void vmathT3MakeScale( VmathTransform3 *result, const VmathVector3 *scaleVec ) +{ + vec_float4 zero = spu_splats(0.0f); + result->col0.vec128 = spu_sel( zero, scaleVec->vec128, (vec_uint4)spu_maskb(0xf000) ); + result->col1.vec128 = spu_sel( zero, scaleVec->vec128, (vec_uint4)spu_maskb(0x0f00) ); + result->col2.vec128 = spu_sel( zero, scaleVec->vec128, (vec_uint4)spu_maskb(0x00f0) ); + vmathV3MakeFromScalar( &result->col3, 0.0f ); +} + +static inline void vmathT3AppendScale( VmathTransform3 *result, const VmathTransform3 *tfrm, const VmathVector3 *scaleVec ) +{ + vmathV3ScalarMul( &result->col0, &tfrm->col0, vmathV3GetX( scaleVec ) ); + vmathV3ScalarMul( &result->col1, &tfrm->col1, vmathV3GetY( scaleVec ) ); + vmathV3ScalarMul( &result->col2, &tfrm->col2, vmathV3GetZ( scaleVec ) ); + vmathV3Copy( &result->col3, &tfrm->col3 ); +} + +static inline void vmathT3PrependScale( VmathTransform3 *result, const VmathVector3 *scaleVec, const VmathTransform3 *tfrm ) +{ + vmathV3MulPerElem( &result->col0, &tfrm->col0, scaleVec ); + vmathV3MulPerElem( &result->col1, &tfrm->col1, scaleVec ); + vmathV3MulPerElem( &result->col2, &tfrm->col2, scaleVec ); + vmathV3MulPerElem( &result->col3, &tfrm->col3, scaleVec ); +} + +static inline void vmathT3MakeTranslation( VmathTransform3 *result, const VmathVector3 *translateVec ) +{ + vmathV3MakeXAxis( &result->col0 ); + vmathV3MakeYAxis( &result->col1 ); + vmathV3MakeZAxis( &result->col2 ); + vmathV3Copy( &result->col3, translateVec ); +} + +static inline void vmathT3Select( VmathTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1, unsigned int select1 ) +{ + vmathV3Select( &result->col0, &tfrm0->col0, &tfrm1->col0, select1 ); + vmathV3Select( &result->col1, &tfrm0->col1, &tfrm1->col1, select1 ); + vmathV3Select( &result->col2, &tfrm0->col2, &tfrm1->col2, select1 ); + vmathV3Select( &result->col3, &tfrm0->col3, &tfrm1->col3, select1 ); +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathT3Print( const VmathTransform3 *tfrm ) +{ + VmathVector4 tmpV4_0, tmpV4_1, tmpV4_2; + vmathT3GetRow( &tmpV4_0, tfrm, 0 ); + vmathV4Print( &tmpV4_0 ); + vmathT3GetRow( &tmpV4_1, tfrm, 1 ); + vmathV4Print( &tmpV4_1 ); + vmathT3GetRow( &tmpV4_2, tfrm, 2 ); + vmathV4Print( &tmpV4_2 ); +} + +static inline void vmathT3Prints( const VmathTransform3 *tfrm, const char *name ) +{ + printf("%s:\n", name); + vmathT3Print( tfrm ); +} + +#endif + +static inline void vmathQMakeFromM3( VmathQuat *result, const VmathMatrix3 *tfrm ) +{ + vec_float4 res; + vec_float4 col0, col1, col2; + vec_float4 xx_yy, xx_yy_zz_xx, yy_zz_xx_yy, zz_xx_yy_zz, diagSum, diagDiff; + vec_float4 zy_xz_yx, yz_zx_xy, sum, diff; + vec_float4 radicand, invSqrt, scale; + vec_float4 res0, res1, res2, res3; + vec_float4 xx, yy, zz; + vec_uint4 select_x = (vec_uint4)spu_maskb( 0xf000 ); + vec_uint4 select_y = (vec_uint4)spu_maskb( 0x0f00 ); + vec_uint4 select_z = (vec_uint4)spu_maskb( 0x00f0 ); + vec_uint4 select_w = (vec_uint4)spu_maskb( 0x000f ); + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((unsigned int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((unsigned int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((unsigned int)0x08090a0b); + vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((unsigned int)0x0c0d0e0f); + + col0 = tfrm->col0.vec128; + col1 = tfrm->col1.vec128; + col2 = tfrm->col2.vec128; + + /* four cases: */ + /* trace > 0 */ + /* else */ + /* xx largest diagonal element */ + /* yy largest diagonal element */ + /* zz largest diagonal element */ + + /* compute quaternion for each case */ + + xx_yy = spu_sel( col0, col1, select_y ); + xx_yy_zz_xx = spu_shuffle( xx_yy, col2, _VECTORMATH_SHUF_XYCX ); + yy_zz_xx_yy = spu_shuffle( xx_yy, col2, _VECTORMATH_SHUF_YCXY ); + zz_xx_yy_zz = spu_shuffle( xx_yy, col2, _VECTORMATH_SHUF_CXYC ); + + diagSum = spu_add( spu_add( xx_yy_zz_xx, yy_zz_xx_yy ), zz_xx_yy_zz ); + diagDiff = spu_sub( spu_sub( xx_yy_zz_xx, yy_zz_xx_yy ), zz_xx_yy_zz ); + radicand = spu_add( spu_sel( diagDiff, diagSum, select_w ), spu_splats(1.0f) ); + invSqrt = rsqrtf4( radicand ); + + zy_xz_yx = spu_sel( col0, col1, select_z ); + zy_xz_yx = spu_shuffle( zy_xz_yx, col2, _VECTORMATH_SHUF_ZAY0 ); + yz_zx_xy = spu_sel( col0, col1, select_x ); + yz_zx_xy = spu_shuffle( yz_zx_xy, col2, _VECTORMATH_SHUF_BZX0 ); + + sum = spu_add( zy_xz_yx, yz_zx_xy ); + diff = spu_sub( zy_xz_yx, yz_zx_xy ); + + scale = spu_mul( invSqrt, spu_splats(0.5f) ); + res0 = spu_shuffle( sum, diff, _VECTORMATH_SHUF_0ZYA ); + res1 = spu_shuffle( sum, diff, _VECTORMATH_SHUF_Z0XB ); + res2 = spu_shuffle( sum, diff, _VECTORMATH_SHUF_YX0C ); + res3 = diff; + res0 = spu_sel( res0, radicand, select_x ); + res1 = spu_sel( res1, radicand, select_y ); + res2 = spu_sel( res2, radicand, select_z ); + res3 = spu_sel( res3, radicand, select_w ); + res0 = spu_mul( res0, spu_shuffle( scale, scale, shuffle_xxxx ) ); + res1 = spu_mul( res1, spu_shuffle( scale, scale, shuffle_yyyy ) ); + res2 = spu_mul( res2, spu_shuffle( scale, scale, shuffle_zzzz ) ); + res3 = spu_mul( res3, spu_shuffle( scale, scale, shuffle_wwww ) ); + + /* determine case and select answer */ + + xx = spu_shuffle( col0, col0, shuffle_xxxx ); + yy = spu_shuffle( col1, col1, shuffle_yyyy ); + zz = spu_shuffle( col2, col2, shuffle_zzzz ); + res = spu_sel( res0, res1, spu_cmpgt( yy, xx ) ); + res = spu_sel( res, res2, spu_and( spu_cmpgt( zz, xx ), spu_cmpgt( zz, yy ) ) ); + res = spu_sel( res, res3, spu_cmpgt( spu_shuffle( diagSum, diagSum, shuffle_xxxx ), spu_splats(0.0f) ) ); + result->vec128 = res; +} + +static inline void vmathV3Outer( VmathMatrix3 *result, const VmathVector3 *tfrm0, const VmathVector3 *tfrm1 ) +{ + vmathV3ScalarMul( &result->col0, tfrm0, vmathV3GetX( tfrm1 ) ); + vmathV3ScalarMul( &result->col1, tfrm0, vmathV3GetY( tfrm1 ) ); + vmathV3ScalarMul( &result->col2, tfrm0, vmathV3GetZ( tfrm1 ) ); +} + +static inline void vmathV4Outer( VmathMatrix4 *result, const VmathVector4 *tfrm0, const VmathVector4 *tfrm1 ) +{ + vmathV4ScalarMul( &result->col0, tfrm0, vmathV4GetX( tfrm1 ) ); + vmathV4ScalarMul( &result->col1, tfrm0, vmathV4GetY( tfrm1 ) ); + vmathV4ScalarMul( &result->col2, tfrm0, vmathV4GetZ( tfrm1 ) ); + vmathV4ScalarMul( &result->col3, tfrm0, vmathV4GetW( tfrm1 ) ); +} + +static inline void vmathV3RowMul( VmathVector3 *result, const VmathVector3 *vec, const VmathMatrix3 *mat ) +{ + vec_float4 tmp0, tmp1, mcol0, mcol1, mcol2, res; + vec_float4 xxxx, yyyy, zzzz; + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); + tmp0 = spu_shuffle( mat->col0.vec128, mat->col2.vec128, _VECTORMATH_SHUF_XAYB ); + tmp1 = spu_shuffle( mat->col0.vec128, mat->col2.vec128, _VECTORMATH_SHUF_ZCWD ); + xxxx = spu_shuffle( vec->vec128, vec->vec128, shuffle_xxxx ); + mcol0 = spu_shuffle( tmp0, mat->col1.vec128, _VECTORMATH_SHUF_XAYB ); + mcol1 = spu_shuffle( tmp0, mat->col1.vec128, _VECTORMATH_SHUF_ZBW0 ); + mcol2 = spu_shuffle( tmp1, mat->col1.vec128, _VECTORMATH_SHUF_XCY0 ); + yyyy = spu_shuffle( vec->vec128, vec->vec128, shuffle_yyyy ); + res = spu_mul( mcol0, xxxx ); + zzzz = spu_shuffle( vec->vec128, vec->vec128, shuffle_zzzz ); + res = spu_madd( mcol1, yyyy, res ); + res = spu_madd( mcol2, zzzz, res ); + result->vec128 = res; +} + +static inline void vmathV3CrossMatrix( VmathMatrix3 *result, const VmathVector3 *vec ) +{ + vec_float4 neg, res0, res1, res2; + neg = negatef4( vec->vec128 ); + res0 = spu_shuffle( vec->vec128, neg, _VECTORMATH_SHUF_0ZB0 ); + res1 = spu_shuffle( vec->vec128, neg, _VECTORMATH_SHUF_C0X0 ); + res2 = spu_shuffle( vec->vec128, neg, _VECTORMATH_SHUF_YA00 ); + result->col0.vec128 = res0; + result->col1.vec128 = res1; + result->col2.vec128 = res2; +} + +static inline void vmathV3CrossMatrixMul( VmathMatrix3 *result, const VmathVector3 *vec, const VmathMatrix3 *mat ) +{ + VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2; + vmathV3Cross( &tmpV3_0, vec, &mat->col0 ); + vmathV3Cross( &tmpV3_1, vec, &mat->col1 ); + vmathV3Cross( &tmpV3_2, vec, &mat->col2 ); + vmathM3MakeFromCols( result, &tmpV3_0, &tmpV3_1, &tmpV3_2 ); +} + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/vectormathlibrary/include/vectormath/spu/c/mat_aos_v.h b/vectormathlibrary/include/vectormath/spu/c/mat_aos_v.h new file mode 100644 index 000000000..986612ebe --- /dev/null +++ b/vectormathlibrary/include/vectormath/spu/c/mat_aos_v.h @@ -0,0 +1,1029 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_MAT_AOS_V_C_H +#define _VECTORMATH_MAT_AOS_V_C_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/*----------------------------------------------------------------------------- + * Constants + * for shuffles, words are labeled [x,y,z,w] [a,b,c,d] + */ +#define _VECTORMATH_SHUF_XAYB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_B }) +#define _VECTORMATH_SHUF_ZCWD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_D }) +#define _VECTORMATH_SHUF_ZBW0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_0 }) +#define _VECTORMATH_SHUF_XCY0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_0 }) +#define _VECTORMATH_SHUF_XYAB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_B }) +#define _VECTORMATH_SHUF_ZWCD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_D }) +#define _VECTORMATH_SHUF_0ZB0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_0, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_0 }) +#define _VECTORMATH_SHUF_C0X0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_0, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_0 }) +#define _VECTORMATH_SHUF_YA00 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_0, _VECTORMATH_SHUF_0 }) +#define _VECTORMATH_SHUF_XAZC ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_C }) +#define _VECTORMATH_SHUF_YXWZ ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_Z }) +#define _VECTORMATH_SHUF_YBWD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_D }) +#define _VECTORMATH_SHUF_XYCX ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_X }) +#define _VECTORMATH_SHUF_YCXY ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y }) +#define _VECTORMATH_SHUF_CXYC ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_C }) +#define _VECTORMATH_SHUF_ZAY0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_0 }) +#define _VECTORMATH_SHUF_BZX0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_0 }) +#define _VECTORMATH_SHUF_0ZYA ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_0, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_A }) +#define _VECTORMATH_SHUF_Z0XB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_0, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_B }) +#define _VECTORMATH_SHUF_YX0C ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_0, _VECTORMATH_SHUF_C }) +#define _VECTORMATH_SHUF_CZD0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_D, _VECTORMATH_SHUF_0 }) +#define _VECTORMATH_SHUF_BBY0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_0 }) +#define _VECTORMATH_PI_OVER_2 1.570796327f + +/*----------------------------------------------------------------------------- + * Definitions + */ +static inline VmathMatrix3 vmathM3MakeFromScalar_V( float scalar ) +{ + VmathMatrix3 result; + vmathM3MakeFromScalar(&result, scalar); + return result; +} + +static inline VmathMatrix3 vmathM3MakeFromQ_V( VmathQuat unitQuat ) +{ + VmathMatrix3 result; + vmathM3MakeFromQ(&result, &unitQuat); + return result; +} + +static inline VmathMatrix3 vmathM3MakeFromCols_V( VmathVector3 _col0, VmathVector3 _col1, VmathVector3 _col2 ) +{ + VmathMatrix3 result; + vmathM3MakeFromCols(&result, &_col0, &_col1, &_col2); + return result; +} + +static inline void vmathM3SetCol0_V( VmathMatrix3 *result, VmathVector3 _col0 ) +{ + vmathM3SetCol0(result, &_col0); +} + +static inline void vmathM3SetCol1_V( VmathMatrix3 *result, VmathVector3 _col1 ) +{ + vmathM3SetCol1(result, &_col1); +} + +static inline void vmathM3SetCol2_V( VmathMatrix3 *result, VmathVector3 _col2 ) +{ + vmathM3SetCol2(result, &_col2); +} + +static inline void vmathM3SetCol_V( VmathMatrix3 *result, int col, VmathVector3 vec ) +{ + vmathM3SetCol(result, col, &vec); +} + +static inline void vmathM3SetRow_V( VmathMatrix3 *result, int row, VmathVector3 vec ) +{ + vmathM3SetRow(result, row, &vec); +} + +static inline void vmathM3SetElem_V( VmathMatrix3 *result, int col, int row, float val ) +{ + vmathM3SetElem(result, col, row, val); +} + +static inline float vmathM3GetElem_V( VmathMatrix3 mat, int col, int row ) +{ + return vmathM3GetElem(&mat, col, row); +} + +static inline VmathVector3 vmathM3GetCol0_V( VmathMatrix3 mat ) +{ + VmathVector3 result; + vmathM3GetCol0(&result, &mat); + return result; +} + +static inline VmathVector3 vmathM3GetCol1_V( VmathMatrix3 mat ) +{ + VmathVector3 result; + vmathM3GetCol1(&result, &mat); + return result; +} + +static inline VmathVector3 vmathM3GetCol2_V( VmathMatrix3 mat ) +{ + VmathVector3 result; + vmathM3GetCol2(&result, &mat); + return result; +} + +static inline VmathVector3 vmathM3GetCol_V( VmathMatrix3 mat, int col ) +{ + VmathVector3 result; + vmathM3GetCol(&result, &mat, col); + return result; +} + +static inline VmathVector3 vmathM3GetRow_V( VmathMatrix3 mat, int row ) +{ + VmathVector3 result; + vmathM3GetRow(&result, &mat, row); + return result; +} + +static inline VmathMatrix3 vmathM3Transpose_V( VmathMatrix3 mat ) +{ + VmathMatrix3 result; + vmathM3Transpose(&result, &mat); + return result; +} + +static inline VmathMatrix3 vmathM3Inverse_V( VmathMatrix3 mat ) +{ + VmathMatrix3 result; + vmathM3Inverse(&result, &mat); + return result; +} + +static inline float vmathM3Determinant_V( VmathMatrix3 mat ) +{ + return vmathM3Determinant(&mat); +} + +static inline VmathMatrix3 vmathM3Add_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ) +{ + VmathMatrix3 result; + vmathM3Add(&result, &mat0, &mat1); + return result; +} + +static inline VmathMatrix3 vmathM3Sub_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ) +{ + VmathMatrix3 result; + vmathM3Sub(&result, &mat0, &mat1); + return result; +} + +static inline VmathMatrix3 vmathM3Neg_V( VmathMatrix3 mat ) +{ + VmathMatrix3 result; + vmathM3Neg(&result, &mat); + return result; +} + +static inline VmathMatrix3 vmathM3AbsPerElem_V( VmathMatrix3 mat ) +{ + VmathMatrix3 result; + vmathM3AbsPerElem(&result, &mat); + return result; +} + +static inline VmathMatrix3 vmathM3ScalarMul_V( VmathMatrix3 mat, float scalar ) +{ + VmathMatrix3 result; + vmathM3ScalarMul(&result, &mat, scalar); + return result; +} + +static inline VmathVector3 vmathM3MulV3_V( VmathMatrix3 mat, VmathVector3 vec ) +{ + VmathVector3 result; + vmathM3MulV3(&result, &mat, &vec); + return result; +} + +static inline VmathMatrix3 vmathM3Mul_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ) +{ + VmathMatrix3 result; + vmathM3Mul(&result, &mat0, &mat1); + return result; +} + +static inline VmathMatrix3 vmathM3MulPerElem_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ) +{ + VmathMatrix3 result; + vmathM3MulPerElem(&result, &mat0, &mat1); + return result; +} + +static inline VmathMatrix3 vmathM3MakeIdentity_V( ) +{ + VmathMatrix3 result; + vmathM3MakeIdentity(&result); + return result; +} + +static inline VmathMatrix3 vmathM3MakeRotationX_V( float radians ) +{ + VmathMatrix3 result; + vmathM3MakeRotationX(&result, radians); + return result; +} + +static inline VmathMatrix3 vmathM3MakeRotationY_V( float radians ) +{ + VmathMatrix3 result; + vmathM3MakeRotationY(&result, radians); + return result; +} + +static inline VmathMatrix3 vmathM3MakeRotationZ_V( float radians ) +{ + VmathMatrix3 result; + vmathM3MakeRotationZ(&result, radians); + return result; +} + +static inline VmathMatrix3 vmathM3MakeRotationZYX_V( VmathVector3 radiansXYZ ) +{ + VmathMatrix3 result; + vmathM3MakeRotationZYX(&result, &radiansXYZ); + return result; +} + +static inline VmathMatrix3 vmathM3MakeRotationAxis_V( float radians, VmathVector3 unitVec ) +{ + VmathMatrix3 result; + vmathM3MakeRotationAxis(&result, radians, &unitVec); + return result; +} + +static inline VmathMatrix3 vmathM3MakeRotationQ_V( VmathQuat unitQuat ) +{ + VmathMatrix3 result; + vmathM3MakeRotationQ(&result, &unitQuat); + return result; +} + +static inline VmathMatrix3 vmathM3MakeScale_V( VmathVector3 scaleVec ) +{ + VmathMatrix3 result; + vmathM3MakeScale(&result, &scaleVec); + return result; +} + +static inline VmathMatrix3 vmathM3AppendScale_V( VmathMatrix3 mat, VmathVector3 scaleVec ) +{ + VmathMatrix3 result; + vmathM3AppendScale(&result, &mat, &scaleVec); + return result; +} + +static inline VmathMatrix3 vmathM3PrependScale_V( VmathVector3 scaleVec, VmathMatrix3 mat ) +{ + VmathMatrix3 result; + vmathM3PrependScale(&result, &scaleVec, &mat); + return result; +} + +static inline VmathMatrix3 vmathM3Select_V( VmathMatrix3 mat0, VmathMatrix3 mat1, unsigned int select1 ) +{ + VmathMatrix3 result; + vmathM3Select(&result, &mat0, &mat1, select1); + return result; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathM3Print_V( VmathMatrix3 mat ) +{ + vmathM3Print(&mat); +} + +static inline void vmathM3Prints_V( VmathMatrix3 mat, const char *name ) +{ + vmathM3Prints(&mat, name); +} + +#endif + +static inline VmathMatrix4 vmathM4MakeFromScalar_V( float scalar ) +{ + VmathMatrix4 result; + vmathM4MakeFromScalar(&result, scalar); + return result; +} + +static inline VmathMatrix4 vmathM4MakeFromT3_V( VmathTransform3 mat ) +{ + VmathMatrix4 result; + vmathM4MakeFromT3(&result, &mat); + return result; +} + +static inline VmathMatrix4 vmathM4MakeFromCols_V( VmathVector4 _col0, VmathVector4 _col1, VmathVector4 _col2, VmathVector4 _col3 ) +{ + VmathMatrix4 result; + vmathM4MakeFromCols(&result, &_col0, &_col1, &_col2, &_col3); + return result; +} + +static inline VmathMatrix4 vmathM4MakeFromM3V3_V( VmathMatrix3 mat, VmathVector3 translateVec ) +{ + VmathMatrix4 result; + vmathM4MakeFromM3V3(&result, &mat, &translateVec); + return result; +} + +static inline VmathMatrix4 vmathM4MakeFromQV3_V( VmathQuat unitQuat, VmathVector3 translateVec ) +{ + VmathMatrix4 result; + vmathM4MakeFromQV3(&result, &unitQuat, &translateVec); + return result; +} + +static inline void vmathM4SetCol0_V( VmathMatrix4 *result, VmathVector4 _col0 ) +{ + vmathM4SetCol0(result, &_col0); +} + +static inline void vmathM4SetCol1_V( VmathMatrix4 *result, VmathVector4 _col1 ) +{ + vmathM4SetCol1(result, &_col1); +} + +static inline void vmathM4SetCol2_V( VmathMatrix4 *result, VmathVector4 _col2 ) +{ + vmathM4SetCol2(result, &_col2); +} + +static inline void vmathM4SetCol3_V( VmathMatrix4 *result, VmathVector4 _col3 ) +{ + vmathM4SetCol3(result, &_col3); +} + +static inline void vmathM4SetCol_V( VmathMatrix4 *result, int col, VmathVector4 vec ) +{ + vmathM4SetCol(result, col, &vec); +} + +static inline void vmathM4SetRow_V( VmathMatrix4 *result, int row, VmathVector4 vec ) +{ + vmathM4SetRow(result, row, &vec); +} + +static inline void vmathM4SetElem_V( VmathMatrix4 *result, int col, int row, float val ) +{ + vmathM4SetElem(result, col, row, val); +} + +static inline float vmathM4GetElem_V( VmathMatrix4 mat, int col, int row ) +{ + return vmathM4GetElem(&mat, col, row); +} + +static inline VmathVector4 vmathM4GetCol0_V( VmathMatrix4 mat ) +{ + VmathVector4 result; + vmathM4GetCol0(&result, &mat); + return result; +} + +static inline VmathVector4 vmathM4GetCol1_V( VmathMatrix4 mat ) +{ + VmathVector4 result; + vmathM4GetCol1(&result, &mat); + return result; +} + +static inline VmathVector4 vmathM4GetCol2_V( VmathMatrix4 mat ) +{ + VmathVector4 result; + vmathM4GetCol2(&result, &mat); + return result; +} + +static inline VmathVector4 vmathM4GetCol3_V( VmathMatrix4 mat ) +{ + VmathVector4 result; + vmathM4GetCol3(&result, &mat); + return result; +} + +static inline VmathVector4 vmathM4GetCol_V( VmathMatrix4 mat, int col ) +{ + VmathVector4 result; + vmathM4GetCol(&result, &mat, col); + return result; +} + +static inline VmathVector4 vmathM4GetRow_V( VmathMatrix4 mat, int row ) +{ + VmathVector4 result; + vmathM4GetRow(&result, &mat, row); + return result; +} + +static inline VmathMatrix4 vmathM4Transpose_V( VmathMatrix4 mat ) +{ + VmathMatrix4 result; + vmathM4Transpose(&result, &mat); + return result; +} + +static inline VmathMatrix4 vmathM4Inverse_V( VmathMatrix4 mat ) +{ + VmathMatrix4 result; + vmathM4Inverse(&result, &mat); + return result; +} + +static inline VmathMatrix4 vmathM4AffineInverse_V( VmathMatrix4 mat ) +{ + VmathMatrix4 result; + vmathM4AffineInverse(&result, &mat); + return result; +} + +static inline VmathMatrix4 vmathM4OrthoInverse_V( VmathMatrix4 mat ) +{ + VmathMatrix4 result; + vmathM4OrthoInverse(&result, &mat); + return result; +} + +static inline float vmathM4Determinant_V( VmathMatrix4 mat ) +{ + return vmathM4Determinant(&mat); +} + +static inline VmathMatrix4 vmathM4Add_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ) +{ + VmathMatrix4 result; + vmathM4Add(&result, &mat0, &mat1); + return result; +} + +static inline VmathMatrix4 vmathM4Sub_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ) +{ + VmathMatrix4 result; + vmathM4Sub(&result, &mat0, &mat1); + return result; +} + +static inline VmathMatrix4 vmathM4Neg_V( VmathMatrix4 mat ) +{ + VmathMatrix4 result; + vmathM4Neg(&result, &mat); + return result; +} + +static inline VmathMatrix4 vmathM4AbsPerElem_V( VmathMatrix4 mat ) +{ + VmathMatrix4 result; + vmathM4AbsPerElem(&result, &mat); + return result; +} + +static inline VmathMatrix4 vmathM4ScalarMul_V( VmathMatrix4 mat, float scalar ) +{ + VmathMatrix4 result; + vmathM4ScalarMul(&result, &mat, scalar); + return result; +} + +static inline VmathVector4 vmathM4MulV4_V( VmathMatrix4 mat, VmathVector4 vec ) +{ + VmathVector4 result; + vmathM4MulV4(&result, &mat, &vec); + return result; +} + +static inline VmathVector4 vmathM4MulV3_V( VmathMatrix4 mat, VmathVector3 vec ) +{ + VmathVector4 result; + vmathM4MulV3(&result, &mat, &vec); + return result; +} + +static inline VmathVector4 vmathM4MulP3_V( VmathMatrix4 mat, VmathPoint3 pnt ) +{ + VmathVector4 result; + vmathM4MulP3(&result, &mat, &pnt); + return result; +} + +static inline VmathMatrix4 vmathM4Mul_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ) +{ + VmathMatrix4 result; + vmathM4Mul(&result, &mat0, &mat1); + return result; +} + +static inline VmathMatrix4 vmathM4MulT3_V( VmathMatrix4 mat, VmathTransform3 tfrm1 ) +{ + VmathMatrix4 result; + vmathM4MulT3(&result, &mat, &tfrm1); + return result; +} + +static inline VmathMatrix4 vmathM4MulPerElem_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ) +{ + VmathMatrix4 result; + vmathM4MulPerElem(&result, &mat0, &mat1); + return result; +} + +static inline VmathMatrix4 vmathM4MakeIdentity_V( ) +{ + VmathMatrix4 result; + vmathM4MakeIdentity(&result); + return result; +} + +static inline void vmathM4SetUpper3x3_V( VmathMatrix4 *result, VmathMatrix3 mat3 ) +{ + vmathM4SetUpper3x3(result, &mat3); +} + +static inline VmathMatrix3 vmathM4GetUpper3x3_V( VmathMatrix4 mat ) +{ + VmathMatrix3 result; + vmathM4GetUpper3x3(&result, &mat); + return result; +} + +static inline void vmathM4SetTranslation_V( VmathMatrix4 *result, VmathVector3 translateVec ) +{ + vmathM4SetTranslation(result, &translateVec); +} + +static inline VmathVector3 vmathM4GetTranslation_V( VmathMatrix4 mat ) +{ + VmathVector3 result; + vmathM4GetTranslation(&result, &mat); + return result; +} + +static inline VmathMatrix4 vmathM4MakeRotationX_V( float radians ) +{ + VmathMatrix4 result; + vmathM4MakeRotationX(&result, radians); + return result; +} + +static inline VmathMatrix4 vmathM4MakeRotationY_V( float radians ) +{ + VmathMatrix4 result; + vmathM4MakeRotationY(&result, radians); + return result; +} + +static inline VmathMatrix4 vmathM4MakeRotationZ_V( float radians ) +{ + VmathMatrix4 result; + vmathM4MakeRotationZ(&result, radians); + return result; +} + +static inline VmathMatrix4 vmathM4MakeRotationZYX_V( VmathVector3 radiansXYZ ) +{ + VmathMatrix4 result; + vmathM4MakeRotationZYX(&result, &radiansXYZ); + return result; +} + +static inline VmathMatrix4 vmathM4MakeRotationAxis_V( float radians, VmathVector3 unitVec ) +{ + VmathMatrix4 result; + vmathM4MakeRotationAxis(&result, radians, &unitVec); + return result; +} + +static inline VmathMatrix4 vmathM4MakeRotationQ_V( VmathQuat unitQuat ) +{ + VmathMatrix4 result; + vmathM4MakeRotationQ(&result, &unitQuat); + return result; +} + +static inline VmathMatrix4 vmathM4MakeScale_V( VmathVector3 scaleVec ) +{ + VmathMatrix4 result; + vmathM4MakeScale(&result, &scaleVec); + return result; +} + +static inline VmathMatrix4 vmathM4AppendScale_V( VmathMatrix4 mat, VmathVector3 scaleVec ) +{ + VmathMatrix4 result; + vmathM4AppendScale(&result, &mat, &scaleVec); + return result; +} + +static inline VmathMatrix4 vmathM4PrependScale_V( VmathVector3 scaleVec, VmathMatrix4 mat ) +{ + VmathMatrix4 result; + vmathM4PrependScale(&result, &scaleVec, &mat); + return result; +} + +static inline VmathMatrix4 vmathM4MakeTranslation_V( VmathVector3 translateVec ) +{ + VmathMatrix4 result; + vmathM4MakeTranslation(&result, &translateVec); + return result; +} + +static inline VmathMatrix4 vmathM4MakeLookAt_V( VmathPoint3 eyePos, VmathPoint3 lookAtPos, VmathVector3 upVec ) +{ + VmathMatrix4 result; + vmathM4MakeLookAt(&result, &eyePos, &lookAtPos, &upVec); + return result; +} + +static inline VmathMatrix4 vmathM4MakePerspective_V( float fovyRadians, float aspect, float zNear, float zFar ) +{ + VmathMatrix4 result; + vmathM4MakePerspective(&result, fovyRadians, aspect, zNear, zFar); + return result; +} + +static inline VmathMatrix4 vmathM4MakeFrustum_V( float left, float right, float bottom, float top, float zNear, float zFar ) +{ + VmathMatrix4 result; + vmathM4MakeFrustum(&result, left, right, bottom, top, zNear, zFar); + return result; +} + +static inline VmathMatrix4 vmathM4MakeOrthographic_V( float left, float right, float bottom, float top, float zNear, float zFar ) +{ + VmathMatrix4 result; + vmathM4MakeOrthographic(&result, left, right, bottom, top, zNear, zFar); + return result; +} + +static inline VmathMatrix4 vmathM4Select_V( VmathMatrix4 mat0, VmathMatrix4 mat1, unsigned int select1 ) +{ + VmathMatrix4 result; + vmathM4Select(&result, &mat0, &mat1, select1); + return result; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathM4Print_V( VmathMatrix4 mat ) +{ + vmathM4Print(&mat); +} + +static inline void vmathM4Prints_V( VmathMatrix4 mat, const char *name ) +{ + vmathM4Prints(&mat, name); +} + +#endif + +static inline VmathTransform3 vmathT3MakeFromScalar_V( float scalar ) +{ + VmathTransform3 result; + vmathT3MakeFromScalar(&result, scalar); + return result; +} + +static inline VmathTransform3 vmathT3MakeFromCols_V( VmathVector3 _col0, VmathVector3 _col1, VmathVector3 _col2, VmathVector3 _col3 ) +{ + VmathTransform3 result; + vmathT3MakeFromCols(&result, &_col0, &_col1, &_col2, &_col3); + return result; +} + +static inline VmathTransform3 vmathT3MakeFromM3V3_V( VmathMatrix3 tfrm, VmathVector3 translateVec ) +{ + VmathTransform3 result; + vmathT3MakeFromM3V3(&result, &tfrm, &translateVec); + return result; +} + +static inline VmathTransform3 vmathT3MakeFromQV3_V( VmathQuat unitQuat, VmathVector3 translateVec ) +{ + VmathTransform3 result; + vmathT3MakeFromQV3(&result, &unitQuat, &translateVec); + return result; +} + +static inline void vmathT3SetCol0_V( VmathTransform3 *result, VmathVector3 _col0 ) +{ + vmathT3SetCol0(result, &_col0); +} + +static inline void vmathT3SetCol1_V( VmathTransform3 *result, VmathVector3 _col1 ) +{ + vmathT3SetCol1(result, &_col1); +} + +static inline void vmathT3SetCol2_V( VmathTransform3 *result, VmathVector3 _col2 ) +{ + vmathT3SetCol2(result, &_col2); +} + +static inline void vmathT3SetCol3_V( VmathTransform3 *result, VmathVector3 _col3 ) +{ + vmathT3SetCol3(result, &_col3); +} + +static inline void vmathT3SetCol_V( VmathTransform3 *result, int col, VmathVector3 vec ) +{ + vmathT3SetCol(result, col, &vec); +} + +static inline void vmathT3SetRow_V( VmathTransform3 *result, int row, VmathVector4 vec ) +{ + vmathT3SetRow(result, row, &vec); +} + +static inline void vmathT3SetElem_V( VmathTransform3 *result, int col, int row, float val ) +{ + vmathT3SetElem(result, col, row, val); +} + +static inline float vmathT3GetElem_V( VmathTransform3 tfrm, int col, int row ) +{ + return vmathT3GetElem(&tfrm, col, row); +} + +static inline VmathVector3 vmathT3GetCol0_V( VmathTransform3 tfrm ) +{ + VmathVector3 result; + vmathT3GetCol0(&result, &tfrm); + return result; +} + +static inline VmathVector3 vmathT3GetCol1_V( VmathTransform3 tfrm ) +{ + VmathVector3 result; + vmathT3GetCol1(&result, &tfrm); + return result; +} + +static inline VmathVector3 vmathT3GetCol2_V( VmathTransform3 tfrm ) +{ + VmathVector3 result; + vmathT3GetCol2(&result, &tfrm); + return result; +} + +static inline VmathVector3 vmathT3GetCol3_V( VmathTransform3 tfrm ) +{ + VmathVector3 result; + vmathT3GetCol3(&result, &tfrm); + return result; +} + +static inline VmathVector3 vmathT3GetCol_V( VmathTransform3 tfrm, int col ) +{ + VmathVector3 result; + vmathT3GetCol(&result, &tfrm, col); + return result; +} + +static inline VmathVector4 vmathT3GetRow_V( VmathTransform3 tfrm, int row ) +{ + VmathVector4 result; + vmathT3GetRow(&result, &tfrm, row); + return result; +} + +static inline VmathTransform3 vmathT3Inverse_V( VmathTransform3 tfrm ) +{ + VmathTransform3 result; + vmathT3Inverse(&result, &tfrm); + return result; +} + +static inline VmathTransform3 vmathT3OrthoInverse_V( VmathTransform3 tfrm ) +{ + VmathTransform3 result; + vmathT3OrthoInverse(&result, &tfrm); + return result; +} + +static inline VmathTransform3 vmathT3AbsPerElem_V( VmathTransform3 tfrm ) +{ + VmathTransform3 result; + vmathT3AbsPerElem(&result, &tfrm); + return result; +} + +static inline VmathVector3 vmathT3MulV3_V( VmathTransform3 tfrm, VmathVector3 vec ) +{ + VmathVector3 result; + vmathT3MulV3(&result, &tfrm, &vec); + return result; +} + +static inline VmathPoint3 vmathT3MulP3_V( VmathTransform3 tfrm, VmathPoint3 pnt ) +{ + VmathPoint3 result; + vmathT3MulP3(&result, &tfrm, &pnt); + return result; +} + +static inline VmathTransform3 vmathT3Mul_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1 ) +{ + VmathTransform3 result; + vmathT3Mul(&result, &tfrm0, &tfrm1); + return result; +} + +static inline VmathTransform3 vmathT3MulPerElem_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1 ) +{ + VmathTransform3 result; + vmathT3MulPerElem(&result, &tfrm0, &tfrm1); + return result; +} + +static inline VmathTransform3 vmathT3MakeIdentity_V( ) +{ + VmathTransform3 result; + vmathT3MakeIdentity(&result); + return result; +} + +static inline void vmathT3SetUpper3x3_V( VmathTransform3 *result, VmathMatrix3 tfrm ) +{ + vmathT3SetUpper3x3(result, &tfrm); +} + +static inline VmathMatrix3 vmathT3GetUpper3x3_V( VmathTransform3 tfrm ) +{ + VmathMatrix3 result; + vmathT3GetUpper3x3(&result, &tfrm); + return result; +} + +static inline void vmathT3SetTranslation_V( VmathTransform3 *result, VmathVector3 translateVec ) +{ + vmathT3SetTranslation(result, &translateVec); +} + +static inline VmathVector3 vmathT3GetTranslation_V( VmathTransform3 tfrm ) +{ + VmathVector3 result; + vmathT3GetTranslation(&result, &tfrm); + return result; +} + +static inline VmathTransform3 vmathT3MakeRotationX_V( float radians ) +{ + VmathTransform3 result; + vmathT3MakeRotationX(&result, radians); + return result; +} + +static inline VmathTransform3 vmathT3MakeRotationY_V( float radians ) +{ + VmathTransform3 result; + vmathT3MakeRotationY(&result, radians); + return result; +} + +static inline VmathTransform3 vmathT3MakeRotationZ_V( float radians ) +{ + VmathTransform3 result; + vmathT3MakeRotationZ(&result, radians); + return result; +} + +static inline VmathTransform3 vmathT3MakeRotationZYX_V( VmathVector3 radiansXYZ ) +{ + VmathTransform3 result; + vmathT3MakeRotationZYX(&result, &radiansXYZ); + return result; +} + +static inline VmathTransform3 vmathT3MakeRotationAxis_V( float radians, VmathVector3 unitVec ) +{ + VmathTransform3 result; + vmathT3MakeRotationAxis(&result, radians, &unitVec); + return result; +} + +static inline VmathTransform3 vmathT3MakeRotationQ_V( VmathQuat unitQuat ) +{ + VmathTransform3 result; + vmathT3MakeRotationQ(&result, &unitQuat); + return result; +} + +static inline VmathTransform3 vmathT3MakeScale_V( VmathVector3 scaleVec ) +{ + VmathTransform3 result; + vmathT3MakeScale(&result, &scaleVec); + return result; +} + +static inline VmathTransform3 vmathT3AppendScale_V( VmathTransform3 tfrm, VmathVector3 scaleVec ) +{ + VmathTransform3 result; + vmathT3AppendScale(&result, &tfrm, &scaleVec); + return result; +} + +static inline VmathTransform3 vmathT3PrependScale_V( VmathVector3 scaleVec, VmathTransform3 tfrm ) +{ + VmathTransform3 result; + vmathT3PrependScale(&result, &scaleVec, &tfrm); + return result; +} + +static inline VmathTransform3 vmathT3MakeTranslation_V( VmathVector3 translateVec ) +{ + VmathTransform3 result; + vmathT3MakeTranslation(&result, &translateVec); + return result; +} + +static inline VmathTransform3 vmathT3Select_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1, unsigned int select1 ) +{ + VmathTransform3 result; + vmathT3Select(&result, &tfrm0, &tfrm1, select1); + return result; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathT3Print_V( VmathTransform3 tfrm ) +{ + vmathT3Print(&tfrm); +} + +static inline void vmathT3Prints_V( VmathTransform3 tfrm, const char *name ) +{ + vmathT3Prints(&tfrm, name); +} + +#endif + +static inline VmathQuat vmathQMakeFromM3_V( VmathMatrix3 tfrm ) +{ + VmathQuat result; + vmathQMakeFromM3(&result, &tfrm); + return result; +} + +static inline VmathMatrix3 vmathV3Outer_V( VmathVector3 tfrm0, VmathVector3 tfrm1 ) +{ + VmathMatrix3 result; + vmathV3Outer(&result, &tfrm0, &tfrm1); + return result; +} + +static inline VmathMatrix4 vmathV4Outer_V( VmathVector4 tfrm0, VmathVector4 tfrm1 ) +{ + VmathMatrix4 result; + vmathV4Outer(&result, &tfrm0, &tfrm1); + return result; +} + +static inline VmathVector3 vmathV3RowMul_V( VmathVector3 vec, VmathMatrix3 mat ) +{ + VmathVector3 result; + vmathV3RowMul(&result, &vec, &mat); + return result; +} + +static inline VmathMatrix3 vmathV3CrossMatrix_V( VmathVector3 vec ) +{ + VmathMatrix3 result; + vmathV3CrossMatrix(&result, &vec); + return result; +} + +static inline VmathMatrix3 vmathV3CrossMatrixMul_V( VmathVector3 vec, VmathMatrix3 mat ) +{ + VmathMatrix3 result; + vmathV3CrossMatrixMul(&result, &vec, &mat); + return result; +} + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/vectormathlibrary/include/vectormath/spu/c/mat_soa.h b/vectormathlibrary/include/vectormath/spu/c/mat_soa.h new file mode 100644 index 000000000..c2c3734e0 --- /dev/null +++ b/vectormathlibrary/include/vectormath/spu/c/mat_soa.h @@ -0,0 +1,1493 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_MAT_SOA_C_H +#define _VECTORMATH_MAT_SOA_C_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/*----------------------------------------------------------------------------- + * Constants + */ +#define _VECTORMATH_PI_OVER_2 1.570796327f + +/*----------------------------------------------------------------------------- + * Definitions + */ +static inline void vmathSoaM3Copy( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ) +{ + vmathSoaV3Copy( &result->col0, &mat->col0 ); + vmathSoaV3Copy( &result->col1, &mat->col1 ); + vmathSoaV3Copy( &result->col2, &mat->col2 ); +} + +static inline void vmathSoaM3MakeFromScalar( VmathSoaMatrix3 *result, vec_float4 scalar ) +{ + vmathSoaV3MakeFromScalar( &result->col0, scalar ); + vmathSoaV3MakeFromScalar( &result->col1, scalar ); + vmathSoaV3MakeFromScalar( &result->col2, scalar ); +} + +static inline void vmathSoaM3MakeFromQ( VmathSoaMatrix3 *result, const VmathSoaQuat *unitQuat ) +{ + vec_float4 qx, qy, qz, qw, qx2, qy2, qz2, qxqx2, qyqy2, qzqz2, qxqy2, qyqz2, qzqw2, qxqz2, qyqw2, qxqw2; + qx = unitQuat->x; + qy = unitQuat->y; + qz = unitQuat->z; + qw = unitQuat->w; + qx2 = spu_add( qx, qx ); + qy2 = spu_add( qy, qy ); + qz2 = spu_add( qz, qz ); + qxqx2 = spu_mul( qx, qx2 ); + qxqy2 = spu_mul( qx, qy2 ); + qxqz2 = spu_mul( qx, qz2 ); + qxqw2 = spu_mul( qw, qx2 ); + qyqy2 = spu_mul( qy, qy2 ); + qyqz2 = spu_mul( qy, qz2 ); + qyqw2 = spu_mul( qw, qy2 ); + qzqz2 = spu_mul( qz, qz2 ); + qzqw2 = spu_mul( qw, qz2 ); + vmathSoaV3MakeFromElems( &result->col0, spu_sub( spu_sub( spu_splats(1.0f), qyqy2 ), qzqz2 ), spu_add( qxqy2, qzqw2 ), spu_sub( qxqz2, qyqw2 ) ); + vmathSoaV3MakeFromElems( &result->col1, spu_sub( qxqy2, qzqw2 ), spu_sub( spu_sub( spu_splats(1.0f), qxqx2 ), qzqz2 ), spu_add( qyqz2, qxqw2 ) ); + vmathSoaV3MakeFromElems( &result->col2, spu_add( qxqz2, qyqw2 ), spu_sub( qyqz2, qxqw2 ), spu_sub( spu_sub( spu_splats(1.0f), qxqx2 ), qyqy2 ) ); +} + +static inline void vmathSoaM3MakeFromCols( VmathSoaMatrix3 *result, const VmathSoaVector3 *_col0, const VmathSoaVector3 *_col1, const VmathSoaVector3 *_col2 ) +{ + vmathSoaV3Copy( &result->col0, _col0 ); + vmathSoaV3Copy( &result->col1, _col1 ); + vmathSoaV3Copy( &result->col2, _col2 ); +} + +static inline void vmathSoaM3MakeFromAos( VmathSoaMatrix3 *result, const VmathMatrix3 *mat ) +{ + vmathSoaV3MakeFromAos( &result->col0, &mat->col0 ); + vmathSoaV3MakeFromAos( &result->col1, &mat->col1 ); + vmathSoaV3MakeFromAos( &result->col2, &mat->col2 ); +} + +static inline void vmathSoaM3MakeFrom4Aos( VmathSoaMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1, const VmathMatrix3 *mat2, const VmathMatrix3 *mat3 ) +{ + vmathSoaV3MakeFrom4Aos( &result->col0, &mat0->col0, &mat1->col0, &mat2->col0, &mat3->col0 ); + vmathSoaV3MakeFrom4Aos( &result->col1, &mat0->col1, &mat1->col1, &mat2->col1, &mat3->col1 ); + vmathSoaV3MakeFrom4Aos( &result->col2, &mat0->col2, &mat1->col2, &mat2->col2, &mat3->col2 ); +} + +static inline void vmathSoaM3Get4Aos( const VmathSoaMatrix3 *mat, VmathMatrix3 *result0, VmathMatrix3 *result1, VmathMatrix3 *result2, VmathMatrix3 *result3 ) +{ + vmathSoaV3Get4Aos( &mat->col0, &result0->col0, &result1->col0, &result2->col0, &result3->col0 ); + vmathSoaV3Get4Aos( &mat->col1, &result0->col1, &result1->col1, &result2->col1, &result3->col1 ); + vmathSoaV3Get4Aos( &mat->col2, &result0->col2, &result1->col2, &result2->col2, &result3->col2 ); +} + +static inline void vmathSoaM3SetCol0( VmathSoaMatrix3 *result, const VmathSoaVector3 *_col0 ) +{ + vmathSoaV3Copy( &result->col0, _col0 ); +} + +static inline void vmathSoaM3SetCol1( VmathSoaMatrix3 *result, const VmathSoaVector3 *_col1 ) +{ + vmathSoaV3Copy( &result->col1, _col1 ); +} + +static inline void vmathSoaM3SetCol2( VmathSoaMatrix3 *result, const VmathSoaVector3 *_col2 ) +{ + vmathSoaV3Copy( &result->col2, _col2 ); +} + +static inline void vmathSoaM3SetCol( VmathSoaMatrix3 *result, int col, const VmathSoaVector3 *vec ) +{ + vmathSoaV3Copy( (&result->col0 + col), vec ); +} + +static inline void vmathSoaM3SetRow( VmathSoaMatrix3 *result, int row, const VmathSoaVector3 *vec ) +{ + vmathSoaV3SetElem( &result->col0, row, vmathSoaV3GetElem( vec, 0 ) ); + vmathSoaV3SetElem( &result->col1, row, vmathSoaV3GetElem( vec, 1 ) ); + vmathSoaV3SetElem( &result->col2, row, vmathSoaV3GetElem( vec, 2 ) ); +} + +static inline void vmathSoaM3SetElem( VmathSoaMatrix3 *result, int col, int row, vec_float4 val ) +{ + VmathSoaVector3 tmpV3_0; + vmathSoaM3GetCol( &tmpV3_0, result, col ); + vmathSoaV3SetElem( &tmpV3_0, row, val ); + vmathSoaM3SetCol( result, col, &tmpV3_0 ); +} + +static inline vec_float4 vmathSoaM3GetElem( const VmathSoaMatrix3 *mat, int col, int row ) +{ + VmathSoaVector3 tmpV3_0; + vmathSoaM3GetCol( &tmpV3_0, mat, col ); + return vmathSoaV3GetElem( &tmpV3_0, row ); +} + +static inline void vmathSoaM3GetCol0( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat ) +{ + vmathSoaV3Copy( result, &mat->col0 ); +} + +static inline void vmathSoaM3GetCol1( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat ) +{ + vmathSoaV3Copy( result, &mat->col1 ); +} + +static inline void vmathSoaM3GetCol2( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat ) +{ + vmathSoaV3Copy( result, &mat->col2 ); +} + +static inline void vmathSoaM3GetCol( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat, int col ) +{ + vmathSoaV3Copy( result, (&mat->col0 + col) ); +} + +static inline void vmathSoaM3GetRow( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat, int row ) +{ + vmathSoaV3MakeFromElems( result, vmathSoaV3GetElem( &mat->col0, row ), vmathSoaV3GetElem( &mat->col1, row ), vmathSoaV3GetElem( &mat->col2, row ) ); +} + +static inline void vmathSoaM3Transpose( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ) +{ + VmathSoaMatrix3 tmpResult; + vmathSoaV3MakeFromElems( &tmpResult.col0, mat->col0.x, mat->col1.x, mat->col2.x ); + vmathSoaV3MakeFromElems( &tmpResult.col1, mat->col0.y, mat->col1.y, mat->col2.y ); + vmathSoaV3MakeFromElems( &tmpResult.col2, mat->col0.z, mat->col1.z, mat->col2.z ); + vmathSoaM3Copy( result, &tmpResult ); +} + +static inline void vmathSoaM3Inverse( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ) +{ + VmathSoaVector3 tmp0, tmp1, tmp2; + vec_float4 detinv; + vmathSoaV3Cross( &tmp0, &mat->col1, &mat->col2 ); + vmathSoaV3Cross( &tmp1, &mat->col2, &mat->col0 ); + vmathSoaV3Cross( &tmp2, &mat->col0, &mat->col1 ); + detinv = recipf4( vmathSoaV3Dot( &mat->col2, &tmp2 ) ); + vmathSoaV3MakeFromElems( &result->col0, spu_mul( tmp0.x, detinv ), spu_mul( tmp1.x, detinv ), spu_mul( tmp2.x, detinv ) ); + vmathSoaV3MakeFromElems( &result->col1, spu_mul( tmp0.y, detinv ), spu_mul( tmp1.y, detinv ), spu_mul( tmp2.y, detinv ) ); + vmathSoaV3MakeFromElems( &result->col2, spu_mul( tmp0.z, detinv ), spu_mul( tmp1.z, detinv ), spu_mul( tmp2.z, detinv ) ); +} + +static inline vec_float4 vmathSoaM3Determinant( const VmathSoaMatrix3 *mat ) +{ + VmathSoaVector3 tmpV3_0; + vmathSoaV3Cross( &tmpV3_0, &mat->col0, &mat->col1 ); + return vmathSoaV3Dot( &mat->col2, &tmpV3_0 ); +} + +static inline void vmathSoaM3Add( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1 ) +{ + vmathSoaV3Add( &result->col0, &mat0->col0, &mat1->col0 ); + vmathSoaV3Add( &result->col1, &mat0->col1, &mat1->col1 ); + vmathSoaV3Add( &result->col2, &mat0->col2, &mat1->col2 ); +} + +static inline void vmathSoaM3Sub( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1 ) +{ + vmathSoaV3Sub( &result->col0, &mat0->col0, &mat1->col0 ); + vmathSoaV3Sub( &result->col1, &mat0->col1, &mat1->col1 ); + vmathSoaV3Sub( &result->col2, &mat0->col2, &mat1->col2 ); +} + +static inline void vmathSoaM3Neg( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ) +{ + vmathSoaV3Neg( &result->col0, &mat->col0 ); + vmathSoaV3Neg( &result->col1, &mat->col1 ); + vmathSoaV3Neg( &result->col2, &mat->col2 ); +} + +static inline void vmathSoaM3AbsPerElem( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ) +{ + vmathSoaV3AbsPerElem( &result->col0, &mat->col0 ); + vmathSoaV3AbsPerElem( &result->col1, &mat->col1 ); + vmathSoaV3AbsPerElem( &result->col2, &mat->col2 ); +} + +static inline void vmathSoaM3ScalarMul( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat, vec_float4 scalar ) +{ + vmathSoaV3ScalarMul( &result->col0, &mat->col0, scalar ); + vmathSoaV3ScalarMul( &result->col1, &mat->col1, scalar ); + vmathSoaV3ScalarMul( &result->col2, &mat->col2, scalar ); +} + +static inline void vmathSoaM3MulV3( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat, const VmathSoaVector3 *vec ) +{ + vec_float4 tmpX, tmpY, tmpZ; + tmpX = spu_add( spu_add( spu_mul( mat->col0.x, vec->x ), spu_mul( mat->col1.x, vec->y ) ), spu_mul( mat->col2.x, vec->z ) ); + tmpY = spu_add( spu_add( spu_mul( mat->col0.y, vec->x ), spu_mul( mat->col1.y, vec->y ) ), spu_mul( mat->col2.y, vec->z ) ); + tmpZ = spu_add( spu_add( spu_mul( mat->col0.z, vec->x ), spu_mul( mat->col1.z, vec->y ) ), spu_mul( mat->col2.z, vec->z ) ); + vmathSoaV3MakeFromElems( result, tmpX, tmpY, tmpZ ); +} + +static inline void vmathSoaM3Mul( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1 ) +{ + VmathSoaMatrix3 tmpResult; + vmathSoaM3MulV3( &tmpResult.col0, mat0, &mat1->col0 ); + vmathSoaM3MulV3( &tmpResult.col1, mat0, &mat1->col1 ); + vmathSoaM3MulV3( &tmpResult.col2, mat0, &mat1->col2 ); + vmathSoaM3Copy( result, &tmpResult ); +} + +static inline void vmathSoaM3MulPerElem( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1 ) +{ + vmathSoaV3MulPerElem( &result->col0, &mat0->col0, &mat1->col0 ); + vmathSoaV3MulPerElem( &result->col1, &mat0->col1, &mat1->col1 ); + vmathSoaV3MulPerElem( &result->col2, &mat0->col2, &mat1->col2 ); +} + +static inline void vmathSoaM3MakeIdentity( VmathSoaMatrix3 *result ) +{ + vmathSoaV3MakeXAxis( &result->col0 ); + vmathSoaV3MakeYAxis( &result->col1 ); + vmathSoaV3MakeZAxis( &result->col2 ); +} + +static inline void vmathSoaM3MakeRotationX( VmathSoaMatrix3 *result, vec_float4 radians ) +{ + vec_float4 s, c; + sincosf4( radians, &s, &c ); + vmathSoaV3MakeXAxis( &result->col0 ); + vmathSoaV3MakeFromElems( &result->col1, spu_splats(0.0f), c, s ); + vmathSoaV3MakeFromElems( &result->col2, spu_splats(0.0f), negatef4( s ), c ); +} + +static inline void vmathSoaM3MakeRotationY( VmathSoaMatrix3 *result, vec_float4 radians ) +{ + vec_float4 s, c; + sincosf4( radians, &s, &c ); + vmathSoaV3MakeFromElems( &result->col0, c, spu_splats(0.0f), negatef4( s ) ); + vmathSoaV3MakeYAxis( &result->col1 ); + vmathSoaV3MakeFromElems( &result->col2, s, spu_splats(0.0f), c ); +} + +static inline void vmathSoaM3MakeRotationZ( VmathSoaMatrix3 *result, vec_float4 radians ) +{ + vec_float4 s, c; + sincosf4( radians, &s, &c ); + vmathSoaV3MakeFromElems( &result->col0, c, s, spu_splats(0.0f) ); + vmathSoaV3MakeFromElems( &result->col1, negatef4( s ), c, spu_splats(0.0f) ); + vmathSoaV3MakeZAxis( &result->col2 ); +} + +static inline void vmathSoaM3MakeRotationZYX( VmathSoaMatrix3 *result, const VmathSoaVector3 *radiansXYZ ) +{ + vec_float4 sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; + sincosf4( radiansXYZ->x, &sX, &cX ); + sincosf4( radiansXYZ->y, &sY, &cY ); + sincosf4( radiansXYZ->z, &sZ, &cZ ); + tmp0 = spu_mul( cZ, sY ); + tmp1 = spu_mul( sZ, sY ); + vmathSoaV3MakeFromElems( &result->col0, spu_mul( cZ, cY ), spu_mul( sZ, cY ), negatef4( sY ) ); + vmathSoaV3MakeFromElems( &result->col1, spu_sub( spu_mul( tmp0, sX ), spu_mul( sZ, cX ) ), spu_add( spu_mul( tmp1, sX ), spu_mul( cZ, cX ) ), spu_mul( cY, sX ) ); + vmathSoaV3MakeFromElems( &result->col2, spu_add( spu_mul( tmp0, cX ), spu_mul( sZ, sX ) ), spu_sub( spu_mul( tmp1, cX ), spu_mul( cZ, sX ) ), spu_mul( cY, cX ) ); +} + +static inline void vmathSoaM3MakeRotationAxis( VmathSoaMatrix3 *result, vec_float4 radians, const VmathSoaVector3 *unitVec ) +{ + vec_float4 x, y, z, s, c, oneMinusC, xy, yz, zx; + sincosf4( radians, &s, &c ); + x = unitVec->x; + y = unitVec->y; + z = unitVec->z; + xy = spu_mul( x, y ); + yz = spu_mul( y, z ); + zx = spu_mul( z, x ); + oneMinusC = spu_sub( spu_splats(1.0f), c ); + vmathSoaV3MakeFromElems( &result->col0, spu_add( spu_mul( spu_mul( x, x ), oneMinusC ), c ), spu_add( spu_mul( xy, oneMinusC ), spu_mul( z, s ) ), spu_sub( spu_mul( zx, oneMinusC ), spu_mul( y, s ) ) ); + vmathSoaV3MakeFromElems( &result->col1, spu_sub( spu_mul( xy, oneMinusC ), spu_mul( z, s ) ), spu_add( spu_mul( spu_mul( y, y ), oneMinusC ), c ), spu_add( spu_mul( yz, oneMinusC ), spu_mul( x, s ) ) ); + vmathSoaV3MakeFromElems( &result->col2, spu_add( spu_mul( zx, oneMinusC ), spu_mul( y, s ) ), spu_sub( spu_mul( yz, oneMinusC ), spu_mul( x, s ) ), spu_add( spu_mul( spu_mul( z, z ), oneMinusC ), c ) ); +} + +static inline void vmathSoaM3MakeRotationQ( VmathSoaMatrix3 *result, const VmathSoaQuat *unitQuat ) +{ + vmathSoaM3MakeFromQ( result, unitQuat ); +} + +static inline void vmathSoaM3MakeScale( VmathSoaMatrix3 *result, const VmathSoaVector3 *scaleVec ) +{ + vmathSoaV3MakeFromElems( &result->col0, scaleVec->x, spu_splats(0.0f), spu_splats(0.0f) ); + vmathSoaV3MakeFromElems( &result->col1, spu_splats(0.0f), scaleVec->y, spu_splats(0.0f) ); + vmathSoaV3MakeFromElems( &result->col2, spu_splats(0.0f), spu_splats(0.0f), scaleVec->z ); +} + +static inline void vmathSoaM3AppendScale( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat, const VmathSoaVector3 *scaleVec ) +{ + vmathSoaV3ScalarMul( &result->col0, &mat->col0, vmathSoaV3GetX( scaleVec ) ); + vmathSoaV3ScalarMul( &result->col1, &mat->col1, vmathSoaV3GetY( scaleVec ) ); + vmathSoaV3ScalarMul( &result->col2, &mat->col2, vmathSoaV3GetZ( scaleVec ) ); +} + +static inline void vmathSoaM3PrependScale( VmathSoaMatrix3 *result, const VmathSoaVector3 *scaleVec, const VmathSoaMatrix3 *mat ) +{ + vmathSoaV3MulPerElem( &result->col0, &mat->col0, scaleVec ); + vmathSoaV3MulPerElem( &result->col1, &mat->col1, scaleVec ); + vmathSoaV3MulPerElem( &result->col2, &mat->col2, scaleVec ); +} + +static inline void vmathSoaM3Select( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1, vec_uint4 select1 ) +{ + vmathSoaV3Select( &result->col0, &mat0->col0, &mat1->col0, select1 ); + vmathSoaV3Select( &result->col1, &mat0->col1, &mat1->col1, select1 ); + vmathSoaV3Select( &result->col2, &mat0->col2, &mat1->col2, select1 ); +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathSoaM3Print( const VmathSoaMatrix3 *mat ) +{ + VmathMatrix3 mat0, mat1, mat2, mat3; + vmathSoaM3Get4Aos( mat, &mat0, &mat1, &mat2, &mat3 ); + printf("slot 0:\n"); + vmathM3Print( &mat0 ); + printf("slot 1:\n"); + vmathM3Print( &mat1 ); + printf("slot 2:\n"); + vmathM3Print( &mat2 ); + printf("slot 3:\n"); + vmathM3Print( &mat3 ); +} + +static inline void vmathSoaM3Prints( const VmathSoaMatrix3 *mat, const char *name ) +{ + printf("%s:\n", name); + vmathSoaM3Print( mat ); +} + +#endif + +static inline void vmathSoaM4Copy( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ) +{ + vmathSoaV4Copy( &result->col0, &mat->col0 ); + vmathSoaV4Copy( &result->col1, &mat->col1 ); + vmathSoaV4Copy( &result->col2, &mat->col2 ); + vmathSoaV4Copy( &result->col3, &mat->col3 ); +} + +static inline void vmathSoaM4MakeFromScalar( VmathSoaMatrix4 *result, vec_float4 scalar ) +{ + vmathSoaV4MakeFromScalar( &result->col0, scalar ); + vmathSoaV4MakeFromScalar( &result->col1, scalar ); + vmathSoaV4MakeFromScalar( &result->col2, scalar ); + vmathSoaV4MakeFromScalar( &result->col3, scalar ); +} + +static inline void vmathSoaM4MakeFromT3( VmathSoaMatrix4 *result, const VmathSoaTransform3 *mat ) +{ + vmathSoaV4MakeFromV3Scalar( &result->col0, &mat->col0, spu_splats(0.0f) ); + vmathSoaV4MakeFromV3Scalar( &result->col1, &mat->col1, spu_splats(0.0f) ); + vmathSoaV4MakeFromV3Scalar( &result->col2, &mat->col2, spu_splats(0.0f) ); + vmathSoaV4MakeFromV3Scalar( &result->col3, &mat->col3, spu_splats(1.0f) ); +} + +static inline void vmathSoaM4MakeFromCols( VmathSoaMatrix4 *result, const VmathSoaVector4 *_col0, const VmathSoaVector4 *_col1, const VmathSoaVector4 *_col2, const VmathSoaVector4 *_col3 ) +{ + vmathSoaV4Copy( &result->col0, _col0 ); + vmathSoaV4Copy( &result->col1, _col1 ); + vmathSoaV4Copy( &result->col2, _col2 ); + vmathSoaV4Copy( &result->col3, _col3 ); +} + +static inline void vmathSoaM4MakeFromM3V3( VmathSoaMatrix4 *result, const VmathSoaMatrix3 *mat, const VmathSoaVector3 *translateVec ) +{ + vmathSoaV4MakeFromV3Scalar( &result->col0, &mat->col0, spu_splats(0.0f) ); + vmathSoaV4MakeFromV3Scalar( &result->col1, &mat->col1, spu_splats(0.0f) ); + vmathSoaV4MakeFromV3Scalar( &result->col2, &mat->col2, spu_splats(0.0f) ); + vmathSoaV4MakeFromV3Scalar( &result->col3, translateVec, spu_splats(1.0f) ); +} + +static inline void vmathSoaM4MakeFromQV3( VmathSoaMatrix4 *result, const VmathSoaQuat *unitQuat, const VmathSoaVector3 *translateVec ) +{ + VmathSoaMatrix3 mat; + vmathSoaM3MakeFromQ( &mat, unitQuat ); + vmathSoaV4MakeFromV3Scalar( &result->col0, &mat.col0, spu_splats(0.0f) ); + vmathSoaV4MakeFromV3Scalar( &result->col1, &mat.col1, spu_splats(0.0f) ); + vmathSoaV4MakeFromV3Scalar( &result->col2, &mat.col2, spu_splats(0.0f) ); + vmathSoaV4MakeFromV3Scalar( &result->col3, translateVec, spu_splats(1.0f) ); +} + +static inline void vmathSoaM4MakeFromAos( VmathSoaMatrix4 *result, const VmathMatrix4 *mat ) +{ + vmathSoaV4MakeFromAos( &result->col0, &mat->col0 ); + vmathSoaV4MakeFromAos( &result->col1, &mat->col1 ); + vmathSoaV4MakeFromAos( &result->col2, &mat->col2 ); + vmathSoaV4MakeFromAos( &result->col3, &mat->col3 ); +} + +static inline void vmathSoaM4MakeFrom4Aos( VmathSoaMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1, const VmathMatrix4 *mat2, const VmathMatrix4 *mat3 ) +{ + vmathSoaV4MakeFrom4Aos( &result->col0, &mat0->col0, &mat1->col0, &mat2->col0, &mat3->col0 ); + vmathSoaV4MakeFrom4Aos( &result->col1, &mat0->col1, &mat1->col1, &mat2->col1, &mat3->col1 ); + vmathSoaV4MakeFrom4Aos( &result->col2, &mat0->col2, &mat1->col2, &mat2->col2, &mat3->col2 ); + vmathSoaV4MakeFrom4Aos( &result->col3, &mat0->col3, &mat1->col3, &mat2->col3, &mat3->col3 ); +} + +static inline void vmathSoaM4Get4Aos( const VmathSoaMatrix4 *mat, VmathMatrix4 *result0, VmathMatrix4 *result1, VmathMatrix4 *result2, VmathMatrix4 *result3 ) +{ + vmathSoaV4Get4Aos( &mat->col0, &result0->col0, &result1->col0, &result2->col0, &result3->col0 ); + vmathSoaV4Get4Aos( &mat->col1, &result0->col1, &result1->col1, &result2->col1, &result3->col1 ); + vmathSoaV4Get4Aos( &mat->col2, &result0->col2, &result1->col2, &result2->col2, &result3->col2 ); + vmathSoaV4Get4Aos( &mat->col3, &result0->col3, &result1->col3, &result2->col3, &result3->col3 ); +} + +static inline void vmathSoaM4SetCol0( VmathSoaMatrix4 *result, const VmathSoaVector4 *_col0 ) +{ + vmathSoaV4Copy( &result->col0, _col0 ); +} + +static inline void vmathSoaM4SetCol1( VmathSoaMatrix4 *result, const VmathSoaVector4 *_col1 ) +{ + vmathSoaV4Copy( &result->col1, _col1 ); +} + +static inline void vmathSoaM4SetCol2( VmathSoaMatrix4 *result, const VmathSoaVector4 *_col2 ) +{ + vmathSoaV4Copy( &result->col2, _col2 ); +} + +static inline void vmathSoaM4SetCol3( VmathSoaMatrix4 *result, const VmathSoaVector4 *_col3 ) +{ + vmathSoaV4Copy( &result->col3, _col3 ); +} + +static inline void vmathSoaM4SetCol( VmathSoaMatrix4 *result, int col, const VmathSoaVector4 *vec ) +{ + vmathSoaV4Copy( (&result->col0 + col), vec ); +} + +static inline void vmathSoaM4SetRow( VmathSoaMatrix4 *result, int row, const VmathSoaVector4 *vec ) +{ + vmathSoaV4SetElem( &result->col0, row, vmathSoaV4GetElem( vec, 0 ) ); + vmathSoaV4SetElem( &result->col1, row, vmathSoaV4GetElem( vec, 1 ) ); + vmathSoaV4SetElem( &result->col2, row, vmathSoaV4GetElem( vec, 2 ) ); + vmathSoaV4SetElem( &result->col3, row, vmathSoaV4GetElem( vec, 3 ) ); +} + +static inline void vmathSoaM4SetElem( VmathSoaMatrix4 *result, int col, int row, vec_float4 val ) +{ + VmathSoaVector4 tmpV3_0; + vmathSoaM4GetCol( &tmpV3_0, result, col ); + vmathSoaV4SetElem( &tmpV3_0, row, val ); + vmathSoaM4SetCol( result, col, &tmpV3_0 ); +} + +static inline vec_float4 vmathSoaM4GetElem( const VmathSoaMatrix4 *mat, int col, int row ) +{ + VmathSoaVector4 tmpV4_0; + vmathSoaM4GetCol( &tmpV4_0, mat, col ); + return vmathSoaV4GetElem( &tmpV4_0, row ); +} + +static inline void vmathSoaM4GetCol0( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat ) +{ + vmathSoaV4Copy( result, &mat->col0 ); +} + +static inline void vmathSoaM4GetCol1( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat ) +{ + vmathSoaV4Copy( result, &mat->col1 ); +} + +static inline void vmathSoaM4GetCol2( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat ) +{ + vmathSoaV4Copy( result, &mat->col2 ); +} + +static inline void vmathSoaM4GetCol3( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat ) +{ + vmathSoaV4Copy( result, &mat->col3 ); +} + +static inline void vmathSoaM4GetCol( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, int col ) +{ + vmathSoaV4Copy( result, (&mat->col0 + col) ); +} + +static inline void vmathSoaM4GetRow( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, int row ) +{ + vmathSoaV4MakeFromElems( result, vmathSoaV4GetElem( &mat->col0, row ), vmathSoaV4GetElem( &mat->col1, row ), vmathSoaV4GetElem( &mat->col2, row ), vmathSoaV4GetElem( &mat->col3, row ) ); +} + +static inline void vmathSoaM4Transpose( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ) +{ + VmathSoaMatrix4 tmpResult; + vmathSoaV4MakeFromElems( &tmpResult.col0, mat->col0.x, mat->col1.x, mat->col2.x, mat->col3.x ); + vmathSoaV4MakeFromElems( &tmpResult.col1, mat->col0.y, mat->col1.y, mat->col2.y, mat->col3.y ); + vmathSoaV4MakeFromElems( &tmpResult.col2, mat->col0.z, mat->col1.z, mat->col2.z, mat->col3.z ); + vmathSoaV4MakeFromElems( &tmpResult.col3, mat->col0.w, mat->col1.w, mat->col2.w, mat->col3.w ); + vmathSoaM4Copy( result, &tmpResult ); +} + +static inline void vmathSoaM4Inverse( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ) +{ + VmathSoaVector4 res0, res1, res2, res3; + vec_float4 mA, mB, mC, mD, mE, mF, mG, mH, mI, mJ, mK, mL, mM, mN, mO, mP, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, detInv; + mA = mat->col0.x; + mB = mat->col0.y; + mC = mat->col0.z; + mD = mat->col0.w; + mE = mat->col1.x; + mF = mat->col1.y; + mG = mat->col1.z; + mH = mat->col1.w; + mI = mat->col2.x; + mJ = mat->col2.y; + mK = mat->col2.z; + mL = mat->col2.w; + mM = mat->col3.x; + mN = mat->col3.y; + mO = mat->col3.z; + mP = mat->col3.w; + tmp0 = spu_sub( spu_mul( mK, mD ), spu_mul( mC, mL ) ); + tmp1 = spu_sub( spu_mul( mO, mH ), spu_mul( mG, mP ) ); + tmp2 = spu_sub( spu_mul( mB, mK ), spu_mul( mJ, mC ) ); + tmp3 = spu_sub( spu_mul( mF, mO ), spu_mul( mN, mG ) ); + tmp4 = spu_sub( spu_mul( mJ, mD ), spu_mul( mB, mL ) ); + tmp5 = spu_sub( spu_mul( mN, mH ), spu_mul( mF, mP ) ); + vmathSoaV4SetX( &res0, spu_sub( spu_sub( spu_mul( mJ, tmp1 ), spu_mul( mL, tmp3 ) ), spu_mul( mK, tmp5 ) ) ); + vmathSoaV4SetY( &res0, spu_sub( spu_sub( spu_mul( mN, tmp0 ), spu_mul( mP, tmp2 ) ), spu_mul( mO, tmp4 ) ) ); + vmathSoaV4SetZ( &res0, spu_sub( spu_add( spu_mul( mD, tmp3 ), spu_mul( mC, tmp5 ) ), spu_mul( mB, tmp1 ) ) ); + vmathSoaV4SetW( &res0, spu_sub( spu_add( spu_mul( mH, tmp2 ), spu_mul( mG, tmp4 ) ), spu_mul( mF, tmp0 ) ) ); + detInv = recipf4( spu_add( spu_add( spu_add( spu_mul( mA, res0.x ), spu_mul( mE, res0.y ) ), spu_mul( mI, res0.z ) ), spu_mul( mM, res0.w ) ) ); + vmathSoaV4SetX( &res1, spu_mul( mI, tmp1 ) ); + vmathSoaV4SetY( &res1, spu_mul( mM, tmp0 ) ); + vmathSoaV4SetZ( &res1, spu_mul( mA, tmp1 ) ); + vmathSoaV4SetW( &res1, spu_mul( mE, tmp0 ) ); + vmathSoaV4SetX( &res3, spu_mul( mI, tmp3 ) ); + vmathSoaV4SetY( &res3, spu_mul( mM, tmp2 ) ); + vmathSoaV4SetZ( &res3, spu_mul( mA, tmp3 ) ); + vmathSoaV4SetW( &res3, spu_mul( mE, tmp2 ) ); + vmathSoaV4SetX( &res2, spu_mul( mI, tmp5 ) ); + vmathSoaV4SetY( &res2, spu_mul( mM, tmp4 ) ); + vmathSoaV4SetZ( &res2, spu_mul( mA, tmp5 ) ); + vmathSoaV4SetW( &res2, spu_mul( mE, tmp4 ) ); + tmp0 = spu_sub( spu_mul( mI, mB ), spu_mul( mA, mJ ) ); + tmp1 = spu_sub( spu_mul( mM, mF ), spu_mul( mE, mN ) ); + tmp2 = spu_sub( spu_mul( mI, mD ), spu_mul( mA, mL ) ); + tmp3 = spu_sub( spu_mul( mM, mH ), spu_mul( mE, mP ) ); + tmp4 = spu_sub( spu_mul( mI, mC ), spu_mul( mA, mK ) ); + tmp5 = spu_sub( spu_mul( mM, mG ), spu_mul( mE, mO ) ); + vmathSoaV4SetX( &res2, spu_add( spu_sub( spu_mul( mL, tmp1 ), spu_mul( mJ, tmp3 ) ), res2.x ) ); + vmathSoaV4SetY( &res2, spu_add( spu_sub( spu_mul( mP, tmp0 ), spu_mul( mN, tmp2 ) ), res2.y ) ); + vmathSoaV4SetZ( &res2, spu_sub( spu_sub( spu_mul( mB, tmp3 ), spu_mul( mD, tmp1 ) ), res2.z ) ); + vmathSoaV4SetW( &res2, spu_sub( spu_sub( spu_mul( mF, tmp2 ), spu_mul( mH, tmp0 ) ), res2.w ) ); + vmathSoaV4SetX( &res3, spu_add( spu_sub( spu_mul( mJ, tmp5 ), spu_mul( mK, tmp1 ) ), res3.x ) ); + vmathSoaV4SetY( &res3, spu_add( spu_sub( spu_mul( mN, tmp4 ), spu_mul( mO, tmp0 ) ), res3.y ) ); + vmathSoaV4SetZ( &res3, spu_sub( spu_sub( spu_mul( mC, tmp1 ), spu_mul( mB, tmp5 ) ), res3.z ) ); + vmathSoaV4SetW( &res3, spu_sub( spu_sub( spu_mul( mG, tmp0 ), spu_mul( mF, tmp4 ) ), res3.w ) ); + vmathSoaV4SetX( &res1, spu_sub( spu_sub( spu_mul( mK, tmp3 ), spu_mul( mL, tmp5 ) ), res1.x ) ); + vmathSoaV4SetY( &res1, spu_sub( spu_sub( spu_mul( mO, tmp2 ), spu_mul( mP, tmp4 ) ), res1.y ) ); + vmathSoaV4SetZ( &res1, spu_add( spu_sub( spu_mul( mD, tmp5 ), spu_mul( mC, tmp3 ) ), res1.z ) ); + vmathSoaV4SetW( &res1, spu_add( spu_sub( spu_mul( mH, tmp4 ), spu_mul( mG, tmp2 ) ), res1.w ) ); + vmathSoaV4ScalarMul( &result->col0, &res0, detInv ); + vmathSoaV4ScalarMul( &result->col1, &res1, detInv ); + vmathSoaV4ScalarMul( &result->col2, &res2, detInv ); + vmathSoaV4ScalarMul( &result->col3, &res3, detInv ); +} + +static inline void vmathSoaM4AffineInverse( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ) +{ + VmathSoaTransform3 affineMat, tmpT3_0; + VmathSoaVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3; + vmathSoaV4GetXYZ( &tmpV3_0, &mat->col0 ); + vmathSoaT3SetCol0( &affineMat, &tmpV3_0 ); + vmathSoaV4GetXYZ( &tmpV3_1, &mat->col1 ); + vmathSoaT3SetCol1( &affineMat, &tmpV3_1 ); + vmathSoaV4GetXYZ( &tmpV3_2, &mat->col2 ); + vmathSoaT3SetCol2( &affineMat, &tmpV3_2 ); + vmathSoaV4GetXYZ( &tmpV3_3, &mat->col3 ); + vmathSoaT3SetCol3( &affineMat, &tmpV3_3 ); + vmathSoaT3Inverse( &tmpT3_0, &affineMat ); + vmathSoaM4MakeFromT3( result, &tmpT3_0 ); +} + +static inline void vmathSoaM4OrthoInverse( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ) +{ + VmathSoaTransform3 affineMat, tmpT3_0; + VmathSoaVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3; + vmathSoaV4GetXYZ( &tmpV3_0, &mat->col0 ); + vmathSoaT3SetCol0( &affineMat, &tmpV3_0 ); + vmathSoaV4GetXYZ( &tmpV3_1, &mat->col1 ); + vmathSoaT3SetCol1( &affineMat, &tmpV3_1 ); + vmathSoaV4GetXYZ( &tmpV3_2, &mat->col2 ); + vmathSoaT3SetCol2( &affineMat, &tmpV3_2 ); + vmathSoaV4GetXYZ( &tmpV3_3, &mat->col3 ); + vmathSoaT3SetCol3( &affineMat, &tmpV3_3 ); + vmathSoaT3OrthoInverse( &tmpT3_0, &affineMat ); + vmathSoaM4MakeFromT3( result, &tmpT3_0 ); +} + +static inline vec_float4 vmathSoaM4Determinant( const VmathSoaMatrix4 *mat ) +{ + vec_float4 dx, dy, dz, dw, mA, mB, mC, mD, mE, mF, mG, mH, mI, mJ, mK, mL, mM, mN, mO, mP, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; + mA = mat->col0.x; + mB = mat->col0.y; + mC = mat->col0.z; + mD = mat->col0.w; + mE = mat->col1.x; + mF = mat->col1.y; + mG = mat->col1.z; + mH = mat->col1.w; + mI = mat->col2.x; + mJ = mat->col2.y; + mK = mat->col2.z; + mL = mat->col2.w; + mM = mat->col3.x; + mN = mat->col3.y; + mO = mat->col3.z; + mP = mat->col3.w; + tmp0 = spu_sub( spu_mul( mK, mD ), spu_mul( mC, mL ) ); + tmp1 = spu_sub( spu_mul( mO, mH ), spu_mul( mG, mP ) ); + tmp2 = spu_sub( spu_mul( mB, mK ), spu_mul( mJ, mC ) ); + tmp3 = spu_sub( spu_mul( mF, mO ), spu_mul( mN, mG ) ); + tmp4 = spu_sub( spu_mul( mJ, mD ), spu_mul( mB, mL ) ); + tmp5 = spu_sub( spu_mul( mN, mH ), spu_mul( mF, mP ) ); + dx = spu_sub( spu_sub( spu_mul( mJ, tmp1 ), spu_mul( mL, tmp3 ) ), spu_mul( mK, tmp5 ) ); + dy = spu_sub( spu_sub( spu_mul( mN, tmp0 ), spu_mul( mP, tmp2 ) ), spu_mul( mO, tmp4 ) ); + dz = spu_sub( spu_add( spu_mul( mD, tmp3 ), spu_mul( mC, tmp5 ) ), spu_mul( mB, tmp1 ) ); + dw = spu_sub( spu_add( spu_mul( mH, tmp2 ), spu_mul( mG, tmp4 ) ), spu_mul( mF, tmp0 ) ); + return spu_add( spu_add( spu_add( spu_mul( mA, dx ), spu_mul( mE, dy ) ), spu_mul( mI, dz ) ), spu_mul( mM, dw ) ); +} + +static inline void vmathSoaM4Add( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1 ) +{ + vmathSoaV4Add( &result->col0, &mat0->col0, &mat1->col0 ); + vmathSoaV4Add( &result->col1, &mat0->col1, &mat1->col1 ); + vmathSoaV4Add( &result->col2, &mat0->col2, &mat1->col2 ); + vmathSoaV4Add( &result->col3, &mat0->col3, &mat1->col3 ); +} + +static inline void vmathSoaM4Sub( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1 ) +{ + vmathSoaV4Sub( &result->col0, &mat0->col0, &mat1->col0 ); + vmathSoaV4Sub( &result->col1, &mat0->col1, &mat1->col1 ); + vmathSoaV4Sub( &result->col2, &mat0->col2, &mat1->col2 ); + vmathSoaV4Sub( &result->col3, &mat0->col3, &mat1->col3 ); +} + +static inline void vmathSoaM4Neg( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ) +{ + vmathSoaV4Neg( &result->col0, &mat->col0 ); + vmathSoaV4Neg( &result->col1, &mat->col1 ); + vmathSoaV4Neg( &result->col2, &mat->col2 ); + vmathSoaV4Neg( &result->col3, &mat->col3 ); +} + +static inline void vmathSoaM4AbsPerElem( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ) +{ + vmathSoaV4AbsPerElem( &result->col0, &mat->col0 ); + vmathSoaV4AbsPerElem( &result->col1, &mat->col1 ); + vmathSoaV4AbsPerElem( &result->col2, &mat->col2 ); + vmathSoaV4AbsPerElem( &result->col3, &mat->col3 ); +} + +static inline void vmathSoaM4ScalarMul( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat, vec_float4 scalar ) +{ + vmathSoaV4ScalarMul( &result->col0, &mat->col0, scalar ); + vmathSoaV4ScalarMul( &result->col1, &mat->col1, scalar ); + vmathSoaV4ScalarMul( &result->col2, &mat->col2, scalar ); + vmathSoaV4ScalarMul( &result->col3, &mat->col3, scalar ); +} + +static inline void vmathSoaM4MulV4( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, const VmathSoaVector4 *vec ) +{ + vec_float4 tmpX, tmpY, tmpZ, tmpW; + tmpX = spu_add( spu_add( spu_add( spu_mul( mat->col0.x, vec->x ), spu_mul( mat->col1.x, vec->y ) ), spu_mul( mat->col2.x, vec->z ) ), spu_mul( mat->col3.x, vec->w ) ); + tmpY = spu_add( spu_add( spu_add( spu_mul( mat->col0.y, vec->x ), spu_mul( mat->col1.y, vec->y ) ), spu_mul( mat->col2.y, vec->z ) ), spu_mul( mat->col3.y, vec->w ) ); + tmpZ = spu_add( spu_add( spu_add( spu_mul( mat->col0.z, vec->x ), spu_mul( mat->col1.z, vec->y ) ), spu_mul( mat->col2.z, vec->z ) ), spu_mul( mat->col3.z, vec->w ) ); + tmpW = spu_add( spu_add( spu_add( spu_mul( mat->col0.w, vec->x ), spu_mul( mat->col1.w, vec->y ) ), spu_mul( mat->col2.w, vec->z ) ), spu_mul( mat->col3.w, vec->w ) ); + vmathSoaV4MakeFromElems( result, tmpX, tmpY, tmpZ, tmpW ); +} + +static inline void vmathSoaM4MulV3( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, const VmathSoaVector3 *vec ) +{ + result->x = spu_add( spu_add( spu_mul( mat->col0.x, vec->x ), spu_mul( mat->col1.x, vec->y ) ), spu_mul( mat->col2.x, vec->z ) ); + result->y = spu_add( spu_add( spu_mul( mat->col0.y, vec->x ), spu_mul( mat->col1.y, vec->y ) ), spu_mul( mat->col2.y, vec->z ) ); + result->z = spu_add( spu_add( spu_mul( mat->col0.z, vec->x ), spu_mul( mat->col1.z, vec->y ) ), spu_mul( mat->col2.z, vec->z ) ); + result->w = spu_add( spu_add( spu_mul( mat->col0.w, vec->x ), spu_mul( mat->col1.w, vec->y ) ), spu_mul( mat->col2.w, vec->z ) ); +} + +static inline void vmathSoaM4MulP3( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, const VmathSoaPoint3 *pnt ) +{ + result->x = spu_add( spu_add( spu_add( spu_mul( mat->col0.x, pnt->x ), spu_mul( mat->col1.x, pnt->y ) ), spu_mul( mat->col2.x, pnt->z ) ), mat->col3.x ); + result->y = spu_add( spu_add( spu_add( spu_mul( mat->col0.y, pnt->x ), spu_mul( mat->col1.y, pnt->y ) ), spu_mul( mat->col2.y, pnt->z ) ), mat->col3.y ); + result->z = spu_add( spu_add( spu_add( spu_mul( mat->col0.z, pnt->x ), spu_mul( mat->col1.z, pnt->y ) ), spu_mul( mat->col2.z, pnt->z ) ), mat->col3.z ); + result->w = spu_add( spu_add( spu_add( spu_mul( mat->col0.w, pnt->x ), spu_mul( mat->col1.w, pnt->y ) ), spu_mul( mat->col2.w, pnt->z ) ), mat->col3.w ); +} + +static inline void vmathSoaM4Mul( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1 ) +{ + VmathSoaMatrix4 tmpResult; + vmathSoaM4MulV4( &tmpResult.col0, mat0, &mat1->col0 ); + vmathSoaM4MulV4( &tmpResult.col1, mat0, &mat1->col1 ); + vmathSoaM4MulV4( &tmpResult.col2, mat0, &mat1->col2 ); + vmathSoaM4MulV4( &tmpResult.col3, mat0, &mat1->col3 ); + vmathSoaM4Copy( result, &tmpResult ); +} + +static inline void vmathSoaM4MulT3( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat, const VmathSoaTransform3 *tfrm1 ) +{ + VmathSoaMatrix4 tmpResult; + VmathSoaPoint3 tmpP3_0; + vmathSoaM4MulV3( &tmpResult.col0, mat, &tfrm1->col0 ); + vmathSoaM4MulV3( &tmpResult.col1, mat, &tfrm1->col1 ); + vmathSoaM4MulV3( &tmpResult.col2, mat, &tfrm1->col2 ); + vmathSoaP3MakeFromV3( &tmpP3_0, &tfrm1->col3 ); + vmathSoaM4MulP3( &tmpResult.col3, mat, &tmpP3_0 ); + vmathSoaM4Copy( result, &tmpResult ); +} + +static inline void vmathSoaM4MulPerElem( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1 ) +{ + vmathSoaV4MulPerElem( &result->col0, &mat0->col0, &mat1->col0 ); + vmathSoaV4MulPerElem( &result->col1, &mat0->col1, &mat1->col1 ); + vmathSoaV4MulPerElem( &result->col2, &mat0->col2, &mat1->col2 ); + vmathSoaV4MulPerElem( &result->col3, &mat0->col3, &mat1->col3 ); +} + +static inline void vmathSoaM4MakeIdentity( VmathSoaMatrix4 *result ) +{ + vmathSoaV4MakeXAxis( &result->col0 ); + vmathSoaV4MakeYAxis( &result->col1 ); + vmathSoaV4MakeZAxis( &result->col2 ); + vmathSoaV4MakeWAxis( &result->col3 ); +} + +static inline void vmathSoaM4SetUpper3x3( VmathSoaMatrix4 *result, const VmathSoaMatrix3 *mat3 ) +{ + vmathSoaV4SetXYZ( &result->col0, &mat3->col0 ); + vmathSoaV4SetXYZ( &result->col1, &mat3->col1 ); + vmathSoaV4SetXYZ( &result->col2, &mat3->col2 ); +} + +static inline void vmathSoaM4GetUpper3x3( VmathSoaMatrix3 *result, const VmathSoaMatrix4 *mat ) +{ + vmathSoaV4GetXYZ( &result->col0, &mat->col0 ); + vmathSoaV4GetXYZ( &result->col1, &mat->col1 ); + vmathSoaV4GetXYZ( &result->col2, &mat->col2 ); +} + +static inline void vmathSoaM4SetTranslation( VmathSoaMatrix4 *result, const VmathSoaVector3 *translateVec ) +{ + vmathSoaV4SetXYZ( &result->col3, translateVec ); +} + +static inline void vmathSoaM4GetTranslation( VmathSoaVector3 *result, const VmathSoaMatrix4 *mat ) +{ + vmathSoaV4GetXYZ( result, &mat->col3 ); +} + +static inline void vmathSoaM4MakeRotationX( VmathSoaMatrix4 *result, vec_float4 radians ) +{ + vec_float4 s, c; + sincosf4( radians, &s, &c ); + vmathSoaV4MakeXAxis( &result->col0 ); + vmathSoaV4MakeFromElems( &result->col1, spu_splats(0.0f), c, s, spu_splats(0.0f) ); + vmathSoaV4MakeFromElems( &result->col2, spu_splats(0.0f), negatef4( s ), c, spu_splats(0.0f) ); + vmathSoaV4MakeWAxis( &result->col3 ); +} + +static inline void vmathSoaM4MakeRotationY( VmathSoaMatrix4 *result, vec_float4 radians ) +{ + vec_float4 s, c; + sincosf4( radians, &s, &c ); + vmathSoaV4MakeFromElems( &result->col0, c, spu_splats(0.0f), negatef4( s ), spu_splats(0.0f) ); + vmathSoaV4MakeYAxis( &result->col1 ); + vmathSoaV4MakeFromElems( &result->col2, s, spu_splats(0.0f), c, spu_splats(0.0f) ); + vmathSoaV4MakeWAxis( &result->col3 ); +} + +static inline void vmathSoaM4MakeRotationZ( VmathSoaMatrix4 *result, vec_float4 radians ) +{ + vec_float4 s, c; + sincosf4( radians, &s, &c ); + vmathSoaV4MakeFromElems( &result->col0, c, s, spu_splats(0.0f), spu_splats(0.0f) ); + vmathSoaV4MakeFromElems( &result->col1, negatef4( s ), c, spu_splats(0.0f), spu_splats(0.0f) ); + vmathSoaV4MakeZAxis( &result->col2 ); + vmathSoaV4MakeWAxis( &result->col3 ); +} + +static inline void vmathSoaM4MakeRotationZYX( VmathSoaMatrix4 *result, const VmathSoaVector3 *radiansXYZ ) +{ + vec_float4 sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; + sincosf4( radiansXYZ->x, &sX, &cX ); + sincosf4( radiansXYZ->y, &sY, &cY ); + sincosf4( radiansXYZ->z, &sZ, &cZ ); + tmp0 = spu_mul( cZ, sY ); + tmp1 = spu_mul( sZ, sY ); + vmathSoaV4MakeFromElems( &result->col0, spu_mul( cZ, cY ), spu_mul( sZ, cY ), negatef4( sY ), spu_splats(0.0f) ); + vmathSoaV4MakeFromElems( &result->col1, spu_sub( spu_mul( tmp0, sX ), spu_mul( sZ, cX ) ), spu_add( spu_mul( tmp1, sX ), spu_mul( cZ, cX ) ), spu_mul( cY, sX ), spu_splats(0.0f) ); + vmathSoaV4MakeFromElems( &result->col2, spu_add( spu_mul( tmp0, cX ), spu_mul( sZ, sX ) ), spu_sub( spu_mul( tmp1, cX ), spu_mul( cZ, sX ) ), spu_mul( cY, cX ), spu_splats(0.0f) ); + vmathSoaV4MakeWAxis( &result->col3 ); +} + +static inline void vmathSoaM4MakeRotationAxis( VmathSoaMatrix4 *result, vec_float4 radians, const VmathSoaVector3 *unitVec ) +{ + vec_float4 x, y, z, s, c, oneMinusC, xy, yz, zx; + sincosf4( radians, &s, &c ); + x = unitVec->x; + y = unitVec->y; + z = unitVec->z; + xy = spu_mul( x, y ); + yz = spu_mul( y, z ); + zx = spu_mul( z, x ); + oneMinusC = spu_sub( spu_splats(1.0f), c ); + vmathSoaV4MakeFromElems( &result->col0, spu_add( spu_mul( spu_mul( x, x ), oneMinusC ), c ), spu_add( spu_mul( xy, oneMinusC ), spu_mul( z, s ) ), spu_sub( spu_mul( zx, oneMinusC ), spu_mul( y, s ) ), spu_splats(0.0f) ); + vmathSoaV4MakeFromElems( &result->col1, spu_sub( spu_mul( xy, oneMinusC ), spu_mul( z, s ) ), spu_add( spu_mul( spu_mul( y, y ), oneMinusC ), c ), spu_add( spu_mul( yz, oneMinusC ), spu_mul( x, s ) ), spu_splats(0.0f) ); + vmathSoaV4MakeFromElems( &result->col2, spu_add( spu_mul( zx, oneMinusC ), spu_mul( y, s ) ), spu_sub( spu_mul( yz, oneMinusC ), spu_mul( x, s ) ), spu_add( spu_mul( spu_mul( z, z ), oneMinusC ), c ), spu_splats(0.0f) ); + vmathSoaV4MakeWAxis( &result->col3 ); +} + +static inline void vmathSoaM4MakeRotationQ( VmathSoaMatrix4 *result, const VmathSoaQuat *unitQuat ) +{ + VmathSoaTransform3 tmpT3_0; + vmathSoaT3MakeRotationQ( &tmpT3_0, unitQuat ); + vmathSoaM4MakeFromT3( result, &tmpT3_0 ); +} + +static inline void vmathSoaM4MakeScale( VmathSoaMatrix4 *result, const VmathSoaVector3 *scaleVec ) +{ + vmathSoaV4MakeFromElems( &result->col0, scaleVec->x, spu_splats(0.0f), spu_splats(0.0f), spu_splats(0.0f) ); + vmathSoaV4MakeFromElems( &result->col1, spu_splats(0.0f), scaleVec->y, spu_splats(0.0f), spu_splats(0.0f) ); + vmathSoaV4MakeFromElems( &result->col2, spu_splats(0.0f), spu_splats(0.0f), scaleVec->z, spu_splats(0.0f) ); + vmathSoaV4MakeWAxis( &result->col3 ); +} + +static inline void vmathSoaM4AppendScale( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat, const VmathSoaVector3 *scaleVec ) +{ + vmathSoaV4ScalarMul( &result->col0, &mat->col0, vmathSoaV3GetX( scaleVec ) ); + vmathSoaV4ScalarMul( &result->col1, &mat->col1, vmathSoaV3GetY( scaleVec ) ); + vmathSoaV4ScalarMul( &result->col2, &mat->col2, vmathSoaV3GetZ( scaleVec ) ); + vmathSoaV4Copy( &result->col3, &mat->col3 ); +} + +static inline void vmathSoaM4PrependScale( VmathSoaMatrix4 *result, const VmathSoaVector3 *scaleVec, const VmathSoaMatrix4 *mat ) +{ + VmathSoaVector4 scale4; + vmathSoaV4MakeFromV3Scalar( &scale4, scaleVec, spu_splats(1.0f) ); + vmathSoaV4MulPerElem( &result->col0, &mat->col0, &scale4 ); + vmathSoaV4MulPerElem( &result->col1, &mat->col1, &scale4 ); + vmathSoaV4MulPerElem( &result->col2, &mat->col2, &scale4 ); + vmathSoaV4MulPerElem( &result->col3, &mat->col3, &scale4 ); +} + +static inline void vmathSoaM4MakeTranslation( VmathSoaMatrix4 *result, const VmathSoaVector3 *translateVec ) +{ + vmathSoaV4MakeXAxis( &result->col0 ); + vmathSoaV4MakeYAxis( &result->col1 ); + vmathSoaV4MakeZAxis( &result->col2 ); + vmathSoaV4MakeFromV3Scalar( &result->col3, translateVec, spu_splats(1.0f) ); +} + +static inline void vmathSoaM4MakeLookAt( VmathSoaMatrix4 *result, const VmathSoaPoint3 *eyePos, const VmathSoaPoint3 *lookAtPos, const VmathSoaVector3 *upVec ) +{ + VmathSoaMatrix4 m4EyeFrame; + VmathSoaVector3 v3X, v3Y, v3Z, tmpV3_0, tmpV3_1; + VmathSoaVector4 tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3; + vmathSoaV3Normalize( &v3Y, upVec ); + vmathSoaP3Sub( &tmpV3_0, eyePos, lookAtPos ); + vmathSoaV3Normalize( &v3Z, &tmpV3_0 ); + vmathSoaV3Cross( &tmpV3_1, &v3Y, &v3Z ); + vmathSoaV3Normalize( &v3X, &tmpV3_1 ); + vmathSoaV3Cross( &v3Y, &v3Z, &v3X ); + vmathSoaV4MakeFromV3( &tmpV4_0, &v3X ); + vmathSoaV4MakeFromV3( &tmpV4_1, &v3Y ); + vmathSoaV4MakeFromV3( &tmpV4_2, &v3Z ); + vmathSoaV4MakeFromP3( &tmpV4_3, eyePos ); + vmathSoaM4MakeFromCols( &m4EyeFrame, &tmpV4_0, &tmpV4_1, &tmpV4_2, &tmpV4_3 ); + vmathSoaM4OrthoInverse( result, &m4EyeFrame ); +} + +static inline void vmathSoaM4MakePerspective( VmathSoaMatrix4 *result, vec_float4 fovyRadians, vec_float4 aspect, vec_float4 zNear, vec_float4 zFar ) +{ + vec_float4 f, rangeInv; + f = tanf4( spu_sub( spu_splats( _VECTORMATH_PI_OVER_2 ), spu_mul( spu_splats(0.5f), fovyRadians ) ) ); + rangeInv = recipf4( spu_sub( zNear, zFar ) ); + vmathSoaV4MakeFromElems( &result->col0, divf4( f, aspect ), spu_splats(0.0f), spu_splats(0.0f), spu_splats(0.0f) ); + vmathSoaV4MakeFromElems( &result->col1, spu_splats(0.0f), f, spu_splats(0.0f), spu_splats(0.0f) ); + vmathSoaV4MakeFromElems( &result->col2, spu_splats(0.0f), spu_splats(0.0f), spu_mul( spu_add( zNear, zFar ), rangeInv ), spu_splats(-1.0f) ); + vmathSoaV4MakeFromElems( &result->col3, spu_splats(0.0f), spu_splats(0.0f), spu_mul( spu_mul( spu_mul( zNear, zFar ), rangeInv ), spu_splats(2.0f) ), spu_splats(0.0f) ); +} + +static inline void vmathSoaM4MakeFrustum( VmathSoaMatrix4 *result, vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ) +{ + vec_float4 sum_rl, sum_tb, sum_nf, inv_rl, inv_tb, inv_nf, n2; + sum_rl = spu_add( right, left ); + sum_tb = spu_add( top, bottom ); + sum_nf = spu_add( zNear, zFar ); + inv_rl = recipf4( spu_sub( right, left ) ); + inv_tb = recipf4( spu_sub( top, bottom ) ); + inv_nf = recipf4( spu_sub( zNear, zFar ) ); + n2 = spu_add( zNear, zNear ); + vmathSoaV4MakeFromElems( &result->col0, spu_mul( n2, inv_rl ), spu_splats(0.0f), spu_splats(0.0f), spu_splats(0.0f) ); + vmathSoaV4MakeFromElems( &result->col1, spu_splats(0.0f), spu_mul( n2, inv_tb ), spu_splats(0.0f), spu_splats(0.0f) ); + vmathSoaV4MakeFromElems( &result->col2, spu_mul( sum_rl, inv_rl ), spu_mul( sum_tb, inv_tb ), spu_mul( sum_nf, inv_nf ), spu_splats(-1.0f) ); + vmathSoaV4MakeFromElems( &result->col3, spu_splats(0.0f), spu_splats(0.0f), spu_mul( spu_mul( n2, inv_nf ), zFar ), spu_splats(0.0f) ); +} + +static inline void vmathSoaM4MakeOrthographic( VmathSoaMatrix4 *result, vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ) +{ + vec_float4 sum_rl, sum_tb, sum_nf, inv_rl, inv_tb, inv_nf; + sum_rl = spu_add( right, left ); + sum_tb = spu_add( top, bottom ); + sum_nf = spu_add( zNear, zFar ); + inv_rl = recipf4( spu_sub( right, left ) ); + inv_tb = recipf4( spu_sub( top, bottom ) ); + inv_nf = recipf4( spu_sub( zNear, zFar ) ); + vmathSoaV4MakeFromElems( &result->col0, spu_add( inv_rl, inv_rl ), spu_splats(0.0f), spu_splats(0.0f), spu_splats(0.0f) ); + vmathSoaV4MakeFromElems( &result->col1, spu_splats(0.0f), spu_add( inv_tb, inv_tb ), spu_splats(0.0f), spu_splats(0.0f) ); + vmathSoaV4MakeFromElems( &result->col2, spu_splats(0.0f), spu_splats(0.0f), spu_add( inv_nf, inv_nf ), spu_splats(0.0f) ); + vmathSoaV4MakeFromElems( &result->col3, spu_mul( negatef4( sum_rl ), inv_rl ), spu_mul( negatef4( sum_tb ), inv_tb ), spu_mul( sum_nf, inv_nf ), spu_splats(1.0f) ); +} + +static inline void vmathSoaM4Select( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1, vec_uint4 select1 ) +{ + vmathSoaV4Select( &result->col0, &mat0->col0, &mat1->col0, select1 ); + vmathSoaV4Select( &result->col1, &mat0->col1, &mat1->col1, select1 ); + vmathSoaV4Select( &result->col2, &mat0->col2, &mat1->col2, select1 ); + vmathSoaV4Select( &result->col3, &mat0->col3, &mat1->col3, select1 ); +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathSoaM4Print( const VmathSoaMatrix4 *mat ) +{ + VmathMatrix4 mat0, mat1, mat2, mat3; + vmathSoaM4Get4Aos( mat, &mat0, &mat1, &mat2, &mat3 ); + printf("slot 0:\n"); + vmathM4Print( &mat0 ); + printf("slot 1:\n"); + vmathM4Print( &mat1 ); + printf("slot 2:\n"); + vmathM4Print( &mat2 ); + printf("slot 3:\n"); + vmathM4Print( &mat3 ); +} + +static inline void vmathSoaM4Prints( const VmathSoaMatrix4 *mat, const char *name ) +{ + printf("%s:\n", name); + vmathSoaM4Print( mat ); +} + +#endif + +static inline void vmathSoaT3Copy( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm ) +{ + vmathSoaV3Copy( &result->col0, &tfrm->col0 ); + vmathSoaV3Copy( &result->col1, &tfrm->col1 ); + vmathSoaV3Copy( &result->col2, &tfrm->col2 ); + vmathSoaV3Copy( &result->col3, &tfrm->col3 ); +} + +static inline void vmathSoaT3MakeFromScalar( VmathSoaTransform3 *result, vec_float4 scalar ) +{ + vmathSoaV3MakeFromScalar( &result->col0, scalar ); + vmathSoaV3MakeFromScalar( &result->col1, scalar ); + vmathSoaV3MakeFromScalar( &result->col2, scalar ); + vmathSoaV3MakeFromScalar( &result->col3, scalar ); +} + +static inline void vmathSoaT3MakeFromCols( VmathSoaTransform3 *result, const VmathSoaVector3 *_col0, const VmathSoaVector3 *_col1, const VmathSoaVector3 *_col2, const VmathSoaVector3 *_col3 ) +{ + vmathSoaV3Copy( &result->col0, _col0 ); + vmathSoaV3Copy( &result->col1, _col1 ); + vmathSoaV3Copy( &result->col2, _col2 ); + vmathSoaV3Copy( &result->col3, _col3 ); +} + +static inline void vmathSoaT3MakeFromM3V3( VmathSoaTransform3 *result, const VmathSoaMatrix3 *tfrm, const VmathSoaVector3 *translateVec ) +{ + vmathSoaT3SetUpper3x3( result, tfrm ); + vmathSoaT3SetTranslation( result, translateVec ); +} + +static inline void vmathSoaT3MakeFromQV3( VmathSoaTransform3 *result, const VmathSoaQuat *unitQuat, const VmathSoaVector3 *translateVec ) +{ + VmathSoaMatrix3 tmpM3_0; + vmathSoaM3MakeFromQ( &tmpM3_0, unitQuat ); + vmathSoaT3SetUpper3x3( result, &tmpM3_0 ); + vmathSoaT3SetTranslation( result, translateVec ); +} + +static inline void vmathSoaT3MakeFromAos( VmathSoaTransform3 *result, const VmathTransform3 *tfrm ) +{ + vmathSoaV3MakeFromAos( &result->col0, &tfrm->col0 ); + vmathSoaV3MakeFromAos( &result->col1, &tfrm->col1 ); + vmathSoaV3MakeFromAos( &result->col2, &tfrm->col2 ); + vmathSoaV3MakeFromAos( &result->col3, &tfrm->col3 ); +} + +static inline void vmathSoaT3MakeFrom4Aos( VmathSoaTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1, const VmathTransform3 *tfrm2, const VmathTransform3 *tfrm3 ) +{ + vmathSoaV3MakeFrom4Aos( &result->col0, &tfrm0->col0, &tfrm1->col0, &tfrm2->col0, &tfrm3->col0 ); + vmathSoaV3MakeFrom4Aos( &result->col1, &tfrm0->col1, &tfrm1->col1, &tfrm2->col1, &tfrm3->col1 ); + vmathSoaV3MakeFrom4Aos( &result->col2, &tfrm0->col2, &tfrm1->col2, &tfrm2->col2, &tfrm3->col2 ); + vmathSoaV3MakeFrom4Aos( &result->col3, &tfrm0->col3, &tfrm1->col3, &tfrm2->col3, &tfrm3->col3 ); +} + +static inline void vmathSoaT3Get4Aos( const VmathSoaTransform3 *tfrm, VmathTransform3 *result0, VmathTransform3 *result1, VmathTransform3 *result2, VmathTransform3 *result3 ) +{ + vmathSoaV3Get4Aos( &tfrm->col0, &result0->col0, &result1->col0, &result2->col0, &result3->col0 ); + vmathSoaV3Get4Aos( &tfrm->col1, &result0->col1, &result1->col1, &result2->col1, &result3->col1 ); + vmathSoaV3Get4Aos( &tfrm->col2, &result0->col2, &result1->col2, &result2->col2, &result3->col2 ); + vmathSoaV3Get4Aos( &tfrm->col3, &result0->col3, &result1->col3, &result2->col3, &result3->col3 ); +} + +static inline void vmathSoaT3SetCol0( VmathSoaTransform3 *result, const VmathSoaVector3 *_col0 ) +{ + vmathSoaV3Copy( &result->col0, _col0 ); +} + +static inline void vmathSoaT3SetCol1( VmathSoaTransform3 *result, const VmathSoaVector3 *_col1 ) +{ + vmathSoaV3Copy( &result->col1, _col1 ); +} + +static inline void vmathSoaT3SetCol2( VmathSoaTransform3 *result, const VmathSoaVector3 *_col2 ) +{ + vmathSoaV3Copy( &result->col2, _col2 ); +} + +static inline void vmathSoaT3SetCol3( VmathSoaTransform3 *result, const VmathSoaVector3 *_col3 ) +{ + vmathSoaV3Copy( &result->col3, _col3 ); +} + +static inline void vmathSoaT3SetCol( VmathSoaTransform3 *result, int col, const VmathSoaVector3 *vec ) +{ + vmathSoaV3Copy( (&result->col0 + col), vec ); +} + +static inline void vmathSoaT3SetRow( VmathSoaTransform3 *result, int row, const VmathSoaVector4 *vec ) +{ + vmathSoaV3SetElem( &result->col0, row, vmathSoaV4GetElem( vec, 0 ) ); + vmathSoaV3SetElem( &result->col1, row, vmathSoaV4GetElem( vec, 1 ) ); + vmathSoaV3SetElem( &result->col2, row, vmathSoaV4GetElem( vec, 2 ) ); + vmathSoaV3SetElem( &result->col3, row, vmathSoaV4GetElem( vec, 3 ) ); +} + +static inline void vmathSoaT3SetElem( VmathSoaTransform3 *result, int col, int row, vec_float4 val ) +{ + VmathSoaVector3 tmpV3_0; + vmathSoaT3GetCol( &tmpV3_0, result, col ); + vmathSoaV3SetElem( &tmpV3_0, row, val ); + vmathSoaT3SetCol( result, col, &tmpV3_0 ); +} + +static inline vec_float4 vmathSoaT3GetElem( const VmathSoaTransform3 *tfrm, int col, int row ) +{ + VmathSoaVector3 tmpV3_0; + vmathSoaT3GetCol( &tmpV3_0, tfrm, col ); + return vmathSoaV3GetElem( &tmpV3_0, row ); +} + +static inline void vmathSoaT3GetCol0( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ) +{ + vmathSoaV3Copy( result, &tfrm->col0 ); +} + +static inline void vmathSoaT3GetCol1( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ) +{ + vmathSoaV3Copy( result, &tfrm->col1 ); +} + +static inline void vmathSoaT3GetCol2( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ) +{ + vmathSoaV3Copy( result, &tfrm->col2 ); +} + +static inline void vmathSoaT3GetCol3( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ) +{ + vmathSoaV3Copy( result, &tfrm->col3 ); +} + +static inline void vmathSoaT3GetCol( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm, int col ) +{ + vmathSoaV3Copy( result, (&tfrm->col0 + col) ); +} + +static inline void vmathSoaT3GetRow( VmathSoaVector4 *result, const VmathSoaTransform3 *tfrm, int row ) +{ + vmathSoaV4MakeFromElems( result, vmathSoaV3GetElem( &tfrm->col0, row ), vmathSoaV3GetElem( &tfrm->col1, row ), vmathSoaV3GetElem( &tfrm->col2, row ), vmathSoaV3GetElem( &tfrm->col3, row ) ); +} + +static inline void vmathSoaT3Inverse( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm ) +{ + VmathSoaVector3 tmp0, tmp1, tmp2, inv0, inv1, inv2, tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5; + vec_float4 detinv; + vmathSoaV3Cross( &tmp0, &tfrm->col1, &tfrm->col2 ); + vmathSoaV3Cross( &tmp1, &tfrm->col2, &tfrm->col0 ); + vmathSoaV3Cross( &tmp2, &tfrm->col0, &tfrm->col1 ); + detinv = recipf4( vmathSoaV3Dot( &tfrm->col2, &tmp2 ) ); + vmathSoaV3MakeFromElems( &inv0, spu_mul( tmp0.x, detinv ), spu_mul( tmp1.x, detinv ), spu_mul( tmp2.x, detinv ) ); + vmathSoaV3MakeFromElems( &inv1, spu_mul( tmp0.y, detinv ), spu_mul( tmp1.y, detinv ), spu_mul( tmp2.y, detinv ) ); + vmathSoaV3MakeFromElems( &inv2, spu_mul( tmp0.z, detinv ), spu_mul( tmp1.z, detinv ), spu_mul( tmp2.z, detinv ) ); + vmathSoaV3Copy( &result->col0, &inv0 ); + vmathSoaV3Copy( &result->col1, &inv1 ); + vmathSoaV3Copy( &result->col2, &inv2 ); + vmathSoaV3ScalarMul( &tmpV3_0, &inv0, tfrm->col3.x ); + vmathSoaV3ScalarMul( &tmpV3_1, &inv1, tfrm->col3.y ); + vmathSoaV3ScalarMul( &tmpV3_2, &inv2, tfrm->col3.z ); + vmathSoaV3Add( &tmpV3_3, &tmpV3_1, &tmpV3_2 ); + vmathSoaV3Add( &tmpV3_4, &tmpV3_0, &tmpV3_3 ); + vmathSoaV3Neg( &tmpV3_5, &tmpV3_4 ); + vmathSoaV3Copy( &result->col3, &tmpV3_5 ); +} + +static inline void vmathSoaT3OrthoInverse( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm ) +{ + VmathSoaVector3 inv0, inv1, inv2, tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5; + vmathSoaV3MakeFromElems( &inv0, tfrm->col0.x, tfrm->col1.x, tfrm->col2.x ); + vmathSoaV3MakeFromElems( &inv1, tfrm->col0.y, tfrm->col1.y, tfrm->col2.y ); + vmathSoaV3MakeFromElems( &inv2, tfrm->col0.z, tfrm->col1.z, tfrm->col2.z ); + vmathSoaV3Copy( &result->col0, &inv0 ); + vmathSoaV3Copy( &result->col1, &inv1 ); + vmathSoaV3Copy( &result->col2, &inv2 ); + vmathSoaV3ScalarMul( &tmpV3_0, &inv0, tfrm->col3.x ); + vmathSoaV3ScalarMul( &tmpV3_1, &inv1, tfrm->col3.y ); + vmathSoaV3ScalarMul( &tmpV3_2, &inv2, tfrm->col3.z ); + vmathSoaV3Add( &tmpV3_3, &tmpV3_1, &tmpV3_2 ); + vmathSoaV3Add( &tmpV3_4, &tmpV3_0, &tmpV3_3 ); + vmathSoaV3Neg( &tmpV3_5, &tmpV3_4 ); + vmathSoaV3Copy( &result->col3, &tmpV3_5 ); +} + +static inline void vmathSoaT3AbsPerElem( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm ) +{ + vmathSoaV3AbsPerElem( &result->col0, &tfrm->col0 ); + vmathSoaV3AbsPerElem( &result->col1, &tfrm->col1 ); + vmathSoaV3AbsPerElem( &result->col2, &tfrm->col2 ); + vmathSoaV3AbsPerElem( &result->col3, &tfrm->col3 ); +} + +static inline void vmathSoaT3MulV3( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm, const VmathSoaVector3 *vec ) +{ + vec_float4 tmpX, tmpY, tmpZ; + tmpX = spu_add( spu_add( spu_mul( tfrm->col0.x, vec->x ), spu_mul( tfrm->col1.x, vec->y ) ), spu_mul( tfrm->col2.x, vec->z ) ); + tmpY = spu_add( spu_add( spu_mul( tfrm->col0.y, vec->x ), spu_mul( tfrm->col1.y, vec->y ) ), spu_mul( tfrm->col2.y, vec->z ) ); + tmpZ = spu_add( spu_add( spu_mul( tfrm->col0.z, vec->x ), spu_mul( tfrm->col1.z, vec->y ) ), spu_mul( tfrm->col2.z, vec->z ) ); + vmathSoaV3MakeFromElems( result, tmpX, tmpY, tmpZ ); +} + +static inline void vmathSoaT3MulP3( VmathSoaPoint3 *result, const VmathSoaTransform3 *tfrm, const VmathSoaPoint3 *pnt ) +{ + vec_float4 tmpX, tmpY, tmpZ; + tmpX = spu_add( spu_add( spu_add( spu_mul( tfrm->col0.x, pnt->x ), spu_mul( tfrm->col1.x, pnt->y ) ), spu_mul( tfrm->col2.x, pnt->z ) ), tfrm->col3.x ); + tmpY = spu_add( spu_add( spu_add( spu_mul( tfrm->col0.y, pnt->x ), spu_mul( tfrm->col1.y, pnt->y ) ), spu_mul( tfrm->col2.y, pnt->z ) ), tfrm->col3.y ); + tmpZ = spu_add( spu_add( spu_add( spu_mul( tfrm->col0.z, pnt->x ), spu_mul( tfrm->col1.z, pnt->y ) ), spu_mul( tfrm->col2.z, pnt->z ) ), tfrm->col3.z ); + vmathSoaP3MakeFromElems( result, tmpX, tmpY, tmpZ ); +} + +static inline void vmathSoaT3Mul( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm0, const VmathSoaTransform3 *tfrm1 ) +{ + VmathSoaTransform3 tmpResult; + VmathSoaPoint3 tmpP3_0, tmpP3_1; + vmathSoaT3MulV3( &tmpResult.col0, tfrm0, &tfrm1->col0 ); + vmathSoaT3MulV3( &tmpResult.col1, tfrm0, &tfrm1->col1 ); + vmathSoaT3MulV3( &tmpResult.col2, tfrm0, &tfrm1->col2 ); + vmathSoaP3MakeFromV3( &tmpP3_0, &tfrm1->col3 ); + vmathSoaT3MulP3( &tmpP3_1, tfrm0, &tmpP3_0 ); + vmathSoaV3MakeFromP3( &tmpResult.col3, &tmpP3_1 ); + vmathSoaT3Copy( result, &tmpResult ); +} + +static inline void vmathSoaT3MulPerElem( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm0, const VmathSoaTransform3 *tfrm1 ) +{ + vmathSoaV3MulPerElem( &result->col0, &tfrm0->col0, &tfrm1->col0 ); + vmathSoaV3MulPerElem( &result->col1, &tfrm0->col1, &tfrm1->col1 ); + vmathSoaV3MulPerElem( &result->col2, &tfrm0->col2, &tfrm1->col2 ); + vmathSoaV3MulPerElem( &result->col3, &tfrm0->col3, &tfrm1->col3 ); +} + +static inline void vmathSoaT3MakeIdentity( VmathSoaTransform3 *result ) +{ + vmathSoaV3MakeXAxis( &result->col0 ); + vmathSoaV3MakeYAxis( &result->col1 ); + vmathSoaV3MakeZAxis( &result->col2 ); + vmathSoaV3MakeFromScalar( &result->col3, spu_splats(0.0f) ); +} + +static inline void vmathSoaT3SetUpper3x3( VmathSoaTransform3 *result, const VmathSoaMatrix3 *tfrm ) +{ + vmathSoaV3Copy( &result->col0, &tfrm->col0 ); + vmathSoaV3Copy( &result->col1, &tfrm->col1 ); + vmathSoaV3Copy( &result->col2, &tfrm->col2 ); +} + +static inline void vmathSoaT3GetUpper3x3( VmathSoaMatrix3 *result, const VmathSoaTransform3 *tfrm ) +{ + vmathSoaM3MakeFromCols( result, &tfrm->col0, &tfrm->col1, &tfrm->col2 ); +} + +static inline void vmathSoaT3SetTranslation( VmathSoaTransform3 *result, const VmathSoaVector3 *translateVec ) +{ + vmathSoaV3Copy( &result->col3, translateVec ); +} + +static inline void vmathSoaT3GetTranslation( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ) +{ + vmathSoaV3Copy( result, &tfrm->col3 ); +} + +static inline void vmathSoaT3MakeRotationX( VmathSoaTransform3 *result, vec_float4 radians ) +{ + vec_float4 s, c; + sincosf4( radians, &s, &c ); + vmathSoaV3MakeXAxis( &result->col0 ); + vmathSoaV3MakeFromElems( &result->col1, spu_splats(0.0f), c, s ); + vmathSoaV3MakeFromElems( &result->col2, spu_splats(0.0f), negatef4( s ), c ); + vmathSoaV3MakeFromScalar( &result->col3, spu_splats(0.0f) ); +} + +static inline void vmathSoaT3MakeRotationY( VmathSoaTransform3 *result, vec_float4 radians ) +{ + vec_float4 s, c; + sincosf4( radians, &s, &c ); + vmathSoaV3MakeFromElems( &result->col0, c, spu_splats(0.0f), negatef4( s ) ); + vmathSoaV3MakeYAxis( &result->col1 ); + vmathSoaV3MakeFromElems( &result->col2, s, spu_splats(0.0f), c ); + vmathSoaV3MakeFromScalar( &result->col3, spu_splats(0.0f) ); +} + +static inline void vmathSoaT3MakeRotationZ( VmathSoaTransform3 *result, vec_float4 radians ) +{ + vec_float4 s, c; + sincosf4( radians, &s, &c ); + vmathSoaV3MakeFromElems( &result->col0, c, s, spu_splats(0.0f) ); + vmathSoaV3MakeFromElems( &result->col1, negatef4( s ), c, spu_splats(0.0f) ); + vmathSoaV3MakeZAxis( &result->col2 ); + vmathSoaV3MakeFromScalar( &result->col3, spu_splats(0.0f) ); +} + +static inline void vmathSoaT3MakeRotationZYX( VmathSoaTransform3 *result, const VmathSoaVector3 *radiansXYZ ) +{ + vec_float4 sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; + sincosf4( radiansXYZ->x, &sX, &cX ); + sincosf4( radiansXYZ->y, &sY, &cY ); + sincosf4( radiansXYZ->z, &sZ, &cZ ); + tmp0 = spu_mul( cZ, sY ); + tmp1 = spu_mul( sZ, sY ); + vmathSoaV3MakeFromElems( &result->col0, spu_mul( cZ, cY ), spu_mul( sZ, cY ), negatef4( sY ) ); + vmathSoaV3MakeFromElems( &result->col1, spu_sub( spu_mul( tmp0, sX ), spu_mul( sZ, cX ) ), spu_add( spu_mul( tmp1, sX ), spu_mul( cZ, cX ) ), spu_mul( cY, sX ) ); + vmathSoaV3MakeFromElems( &result->col2, spu_add( spu_mul( tmp0, cX ), spu_mul( sZ, sX ) ), spu_sub( spu_mul( tmp1, cX ), spu_mul( cZ, sX ) ), spu_mul( cY, cX ) ); + vmathSoaV3MakeFromScalar( &result->col3, spu_splats(0.0f) ); +} + +static inline void vmathSoaT3MakeRotationAxis( VmathSoaTransform3 *result, vec_float4 radians, const VmathSoaVector3 *unitVec ) +{ + VmathSoaMatrix3 tmpM3_0; + VmathSoaVector3 tmpV3_0; + vmathSoaM3MakeRotationAxis( &tmpM3_0, radians, unitVec ); + vmathSoaV3MakeFromScalar( &tmpV3_0, spu_splats(0.0f) ); + vmathSoaT3MakeFromM3V3( result, &tmpM3_0, &tmpV3_0 ); +} + +static inline void vmathSoaT3MakeRotationQ( VmathSoaTransform3 *result, const VmathSoaQuat *unitQuat ) +{ + VmathSoaMatrix3 tmpM3_0; + VmathSoaVector3 tmpV3_0; + vmathSoaM3MakeFromQ( &tmpM3_0, unitQuat ); + vmathSoaV3MakeFromScalar( &tmpV3_0, spu_splats(0.0f) ); + vmathSoaT3MakeFromM3V3( result, &tmpM3_0, &tmpV3_0 ); +} + +static inline void vmathSoaT3MakeScale( VmathSoaTransform3 *result, const VmathSoaVector3 *scaleVec ) +{ + vmathSoaV3MakeFromElems( &result->col0, scaleVec->x, spu_splats(0.0f), spu_splats(0.0f) ); + vmathSoaV3MakeFromElems( &result->col1, spu_splats(0.0f), scaleVec->y, spu_splats(0.0f) ); + vmathSoaV3MakeFromElems( &result->col2, spu_splats(0.0f), spu_splats(0.0f), scaleVec->z ); + vmathSoaV3MakeFromScalar( &result->col3, spu_splats(0.0f) ); +} + +static inline void vmathSoaT3AppendScale( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm, const VmathSoaVector3 *scaleVec ) +{ + vmathSoaV3ScalarMul( &result->col0, &tfrm->col0, vmathSoaV3GetX( scaleVec ) ); + vmathSoaV3ScalarMul( &result->col1, &tfrm->col1, vmathSoaV3GetY( scaleVec ) ); + vmathSoaV3ScalarMul( &result->col2, &tfrm->col2, vmathSoaV3GetZ( scaleVec ) ); + vmathSoaV3Copy( &result->col3, &tfrm->col3 ); +} + +static inline void vmathSoaT3PrependScale( VmathSoaTransform3 *result, const VmathSoaVector3 *scaleVec, const VmathSoaTransform3 *tfrm ) +{ + vmathSoaV3MulPerElem( &result->col0, &tfrm->col0, scaleVec ); + vmathSoaV3MulPerElem( &result->col1, &tfrm->col1, scaleVec ); + vmathSoaV3MulPerElem( &result->col2, &tfrm->col2, scaleVec ); + vmathSoaV3MulPerElem( &result->col3, &tfrm->col3, scaleVec ); +} + +static inline void vmathSoaT3MakeTranslation( VmathSoaTransform3 *result, const VmathSoaVector3 *translateVec ) +{ + vmathSoaV3MakeXAxis( &result->col0 ); + vmathSoaV3MakeYAxis( &result->col1 ); + vmathSoaV3MakeZAxis( &result->col2 ); + vmathSoaV3Copy( &result->col3, translateVec ); +} + +static inline void vmathSoaT3Select( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm0, const VmathSoaTransform3 *tfrm1, vec_uint4 select1 ) +{ + vmathSoaV3Select( &result->col0, &tfrm0->col0, &tfrm1->col0, select1 ); + vmathSoaV3Select( &result->col1, &tfrm0->col1, &tfrm1->col1, select1 ); + vmathSoaV3Select( &result->col2, &tfrm0->col2, &tfrm1->col2, select1 ); + vmathSoaV3Select( &result->col3, &tfrm0->col3, &tfrm1->col3, select1 ); +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathSoaT3Print( const VmathSoaTransform3 *tfrm ) +{ + VmathTransform3 mat0, mat1, mat2, mat3; + vmathSoaT3Get4Aos( tfrm, &mat0, &mat1, &mat2, &mat3 ); + printf("slot 0:\n"); + vmathT3Print( &mat0 ); + printf("slot 1:\n"); + vmathT3Print( &mat1 ); + printf("slot 2:\n"); + vmathT3Print( &mat2 ); + printf("slot 3:\n"); + vmathT3Print( &mat3 ); +} + +static inline void vmathSoaT3Prints( const VmathSoaTransform3 *tfrm, const char *name ) +{ + printf("%s:\n", name); + vmathSoaT3Print( tfrm ); +} + +#endif + +static inline void vmathSoaQMakeFromM3( VmathSoaQuat *result, const VmathSoaMatrix3 *tfrm ) +{ + vec_float4 trace, radicand, scale, xx, yx, zx, xy, yy, zy, xz, yz, zz, tmpx, tmpy, tmpz, tmpw, qx, qy, qz, qw; + vec_uint4 negTrace, ZgtX, ZgtY, YgtX; + vec_uint4 largestXorY, largestYorZ, largestZorX; + + xx = tfrm->col0.x; + yx = tfrm->col0.y; + zx = tfrm->col0.z; + xy = tfrm->col1.x; + yy = tfrm->col1.y; + zy = tfrm->col1.z; + xz = tfrm->col2.x; + yz = tfrm->col2.y; + zz = tfrm->col2.z; + + trace = spu_add( spu_add( xx, yy ), zz ); + + negTrace = spu_cmpgt( spu_splats(0.0f), trace ); + ZgtX = spu_cmpgt( zz, xx ); + ZgtY = spu_cmpgt( zz, yy ); + YgtX = spu_cmpgt( yy, xx ); + largestXorY = spu_and( negTrace, spu_nand( ZgtX, ZgtY ) ); + largestYorZ = spu_and( negTrace, spu_or( YgtX, ZgtX ) ); + largestZorX = spu_and( negTrace, spu_orc( ZgtY, YgtX ) ); + + zz = spu_sel( zz, negatef4(zz), largestXorY ); + xy = spu_sel( xy, negatef4(xy), largestXorY ); + xx = spu_sel( xx, negatef4(xx), largestYorZ ); + yz = spu_sel( yz, negatef4(yz), largestYorZ ); + yy = spu_sel( yy, negatef4(yy), largestZorX ); + zx = spu_sel( zx, negatef4(zx), largestZorX ); + + radicand = spu_add( spu_add( spu_add( xx, yy ), zz ), spu_splats(1.0f) ); + scale = spu_mul( spu_splats(0.5f), rsqrtf4( radicand ) ); + + tmpx = spu_mul( spu_sub( zy, yz ), scale ); + tmpy = spu_mul( spu_sub( xz, zx ), scale ); + tmpz = spu_mul( spu_sub( yx, xy ), scale ); + tmpw = spu_mul( radicand, scale ); + qx = tmpx; + qy = tmpy; + qz = tmpz; + qw = tmpw; + + qx = spu_sel( qx, tmpw, largestXorY ); + qy = spu_sel( qy, tmpz, largestXorY ); + qz = spu_sel( qz, tmpy, largestXorY ); + qw = spu_sel( qw, tmpx, largestXorY ); + tmpx = qx; + tmpz = qz; + qx = spu_sel( qx, qy, largestYorZ ); + qy = spu_sel( qy, tmpx, largestYorZ ); + qz = spu_sel( qz, qw, largestYorZ ); + qw = spu_sel( qw, tmpz, largestYorZ ); + + result->x = qx; + result->y = qy; + result->z = qz; + result->w = qw; +} + +static inline void vmathSoaV3Outer( VmathSoaMatrix3 *result, const VmathSoaVector3 *tfrm0, const VmathSoaVector3 *tfrm1 ) +{ + vmathSoaV3ScalarMul( &result->col0, tfrm0, vmathSoaV3GetX( tfrm1 ) ); + vmathSoaV3ScalarMul( &result->col1, tfrm0, vmathSoaV3GetY( tfrm1 ) ); + vmathSoaV3ScalarMul( &result->col2, tfrm0, vmathSoaV3GetZ( tfrm1 ) ); +} + +static inline void vmathSoaV4Outer( VmathSoaMatrix4 *result, const VmathSoaVector4 *tfrm0, const VmathSoaVector4 *tfrm1 ) +{ + vmathSoaV4ScalarMul( &result->col0, tfrm0, vmathSoaV4GetX( tfrm1 ) ); + vmathSoaV4ScalarMul( &result->col1, tfrm0, vmathSoaV4GetY( tfrm1 ) ); + vmathSoaV4ScalarMul( &result->col2, tfrm0, vmathSoaV4GetZ( tfrm1 ) ); + vmathSoaV4ScalarMul( &result->col3, tfrm0, vmathSoaV4GetW( tfrm1 ) ); +} + +static inline void vmathSoaV3RowMul( VmathSoaVector3 *result, const VmathSoaVector3 *vec, const VmathSoaMatrix3 *mat ) +{ + vec_float4 tmpX, tmpY, tmpZ; + tmpX = spu_add( spu_add( spu_mul( vec->x, mat->col0.x ), spu_mul( vec->y, mat->col0.y ) ), spu_mul( vec->z, mat->col0.z ) ); + tmpY = spu_add( spu_add( spu_mul( vec->x, mat->col1.x ), spu_mul( vec->y, mat->col1.y ) ), spu_mul( vec->z, mat->col1.z ) ); + tmpZ = spu_add( spu_add( spu_mul( vec->x, mat->col2.x ), spu_mul( vec->y, mat->col2.y ) ), spu_mul( vec->z, mat->col2.z ) ); + vmathSoaV3MakeFromElems( result, tmpX, tmpY, tmpZ ); +} + +static inline void vmathSoaV3CrossMatrix( VmathSoaMatrix3 *result, const VmathSoaVector3 *vec ) +{ + vmathSoaV3MakeFromElems( &result->col0, spu_splats(0.0f), vec->z, negatef4( vec->y ) ); + vmathSoaV3MakeFromElems( &result->col1, negatef4( vec->z ), spu_splats(0.0f), vec->x ); + vmathSoaV3MakeFromElems( &result->col2, vec->y, negatef4( vec->x ), spu_splats(0.0f) ); +} + +static inline void vmathSoaV3CrossMatrixMul( VmathSoaMatrix3 *result, const VmathSoaVector3 *vec, const VmathSoaMatrix3 *mat ) +{ + VmathSoaVector3 tmpV3_0, tmpV3_1, tmpV3_2; + vmathSoaV3Cross( &tmpV3_0, vec, &mat->col0 ); + vmathSoaV3Cross( &tmpV3_1, vec, &mat->col1 ); + vmathSoaV3Cross( &tmpV3_2, vec, &mat->col2 ); + vmathSoaM3MakeFromCols( result, &tmpV3_0, &tmpV3_1, &tmpV3_2 ); +} + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/vectormathlibrary/include/vectormath/spu/c/mat_soa_v.h b/vectormathlibrary/include/vectormath/spu/c/mat_soa_v.h new file mode 100644 index 000000000..c8401e3d0 --- /dev/null +++ b/vectormathlibrary/include/vectormath/spu/c/mat_soa_v.h @@ -0,0 +1,1063 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_MAT_SOA_V_C_H +#define _VECTORMATH_MAT_SOA_V_C_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/*----------------------------------------------------------------------------- + * Constants + */ +#define _VECTORMATH_PI_OVER_2 1.570796327f + +/*----------------------------------------------------------------------------- + * Definitions + */ +static inline VmathSoaMatrix3 vmathSoaM3MakeFromScalar_V( vec_float4 scalar ) +{ + VmathSoaMatrix3 result; + vmathSoaM3MakeFromScalar(&result, scalar); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3MakeFromQ_V( VmathSoaQuat unitQuat ) +{ + VmathSoaMatrix3 result; + vmathSoaM3MakeFromQ(&result, &unitQuat); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3MakeFromCols_V( VmathSoaVector3 _col0, VmathSoaVector3 _col1, VmathSoaVector3 _col2 ) +{ + VmathSoaMatrix3 result; + vmathSoaM3MakeFromCols(&result, &_col0, &_col1, &_col2); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3MakeFromAos_V( VmathMatrix3 mat ) +{ + VmathSoaMatrix3 result; + vmathSoaM3MakeFromAos(&result, &mat); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3MakeFrom4Aos_V( VmathMatrix3 mat0, VmathMatrix3 mat1, VmathMatrix3 mat2, VmathMatrix3 mat3 ) +{ + VmathSoaMatrix3 result; + vmathSoaM3MakeFrom4Aos(&result, &mat0, &mat1, &mat2, &mat3); + return result; +} + +static inline void vmathSoaM3Get4Aos_V( VmathSoaMatrix3 mat, VmathMatrix3 *result0, VmathMatrix3 *result1, VmathMatrix3 *result2, VmathMatrix3 *result3 ) +{ + vmathSoaM3Get4Aos(&mat, result0, result1, result2, result3); +} + +static inline void vmathSoaM3SetCol0_V( VmathSoaMatrix3 *result, VmathSoaVector3 _col0 ) +{ + vmathSoaM3SetCol0(result, &_col0); +} + +static inline void vmathSoaM3SetCol1_V( VmathSoaMatrix3 *result, VmathSoaVector3 _col1 ) +{ + vmathSoaM3SetCol1(result, &_col1); +} + +static inline void vmathSoaM3SetCol2_V( VmathSoaMatrix3 *result, VmathSoaVector3 _col2 ) +{ + vmathSoaM3SetCol2(result, &_col2); +} + +static inline void vmathSoaM3SetCol_V( VmathSoaMatrix3 *result, int col, VmathSoaVector3 vec ) +{ + vmathSoaM3SetCol(result, col, &vec); +} + +static inline void vmathSoaM3SetRow_V( VmathSoaMatrix3 *result, int row, VmathSoaVector3 vec ) +{ + vmathSoaM3SetRow(result, row, &vec); +} + +static inline void vmathSoaM3SetElem_V( VmathSoaMatrix3 *result, int col, int row, vec_float4 val ) +{ + vmathSoaM3SetElem(result, col, row, val); +} + +static inline vec_float4 vmathSoaM3GetElem_V( VmathSoaMatrix3 mat, int col, int row ) +{ + return vmathSoaM3GetElem(&mat, col, row); +} + +static inline VmathSoaVector3 vmathSoaM3GetCol0_V( VmathSoaMatrix3 mat ) +{ + VmathSoaVector3 result; + vmathSoaM3GetCol0(&result, &mat); + return result; +} + +static inline VmathSoaVector3 vmathSoaM3GetCol1_V( VmathSoaMatrix3 mat ) +{ + VmathSoaVector3 result; + vmathSoaM3GetCol1(&result, &mat); + return result; +} + +static inline VmathSoaVector3 vmathSoaM3GetCol2_V( VmathSoaMatrix3 mat ) +{ + VmathSoaVector3 result; + vmathSoaM3GetCol2(&result, &mat); + return result; +} + +static inline VmathSoaVector3 vmathSoaM3GetCol_V( VmathSoaMatrix3 mat, int col ) +{ + VmathSoaVector3 result; + vmathSoaM3GetCol(&result, &mat, col); + return result; +} + +static inline VmathSoaVector3 vmathSoaM3GetRow_V( VmathSoaMatrix3 mat, int row ) +{ + VmathSoaVector3 result; + vmathSoaM3GetRow(&result, &mat, row); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3Transpose_V( VmathSoaMatrix3 mat ) +{ + VmathSoaMatrix3 result; + vmathSoaM3Transpose(&result, &mat); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3Inverse_V( VmathSoaMatrix3 mat ) +{ + VmathSoaMatrix3 result; + vmathSoaM3Inverse(&result, &mat); + return result; +} + +static inline vec_float4 vmathSoaM3Determinant_V( VmathSoaMatrix3 mat ) +{ + return vmathSoaM3Determinant(&mat); +} + +static inline VmathSoaMatrix3 vmathSoaM3Add_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1 ) +{ + VmathSoaMatrix3 result; + vmathSoaM3Add(&result, &mat0, &mat1); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3Sub_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1 ) +{ + VmathSoaMatrix3 result; + vmathSoaM3Sub(&result, &mat0, &mat1); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3Neg_V( VmathSoaMatrix3 mat ) +{ + VmathSoaMatrix3 result; + vmathSoaM3Neg(&result, &mat); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3AbsPerElem_V( VmathSoaMatrix3 mat ) +{ + VmathSoaMatrix3 result; + vmathSoaM3AbsPerElem(&result, &mat); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3ScalarMul_V( VmathSoaMatrix3 mat, vec_float4 scalar ) +{ + VmathSoaMatrix3 result; + vmathSoaM3ScalarMul(&result, &mat, scalar); + return result; +} + +static inline VmathSoaVector3 vmathSoaM3MulV3_V( VmathSoaMatrix3 mat, VmathSoaVector3 vec ) +{ + VmathSoaVector3 result; + vmathSoaM3MulV3(&result, &mat, &vec); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3Mul_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1 ) +{ + VmathSoaMatrix3 result; + vmathSoaM3Mul(&result, &mat0, &mat1); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3MulPerElem_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1 ) +{ + VmathSoaMatrix3 result; + vmathSoaM3MulPerElem(&result, &mat0, &mat1); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3MakeIdentity_V( ) +{ + VmathSoaMatrix3 result; + vmathSoaM3MakeIdentity(&result); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3MakeRotationX_V( vec_float4 radians ) +{ + VmathSoaMatrix3 result; + vmathSoaM3MakeRotationX(&result, radians); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3MakeRotationY_V( vec_float4 radians ) +{ + VmathSoaMatrix3 result; + vmathSoaM3MakeRotationY(&result, radians); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3MakeRotationZ_V( vec_float4 radians ) +{ + VmathSoaMatrix3 result; + vmathSoaM3MakeRotationZ(&result, radians); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3MakeRotationZYX_V( VmathSoaVector3 radiansXYZ ) +{ + VmathSoaMatrix3 result; + vmathSoaM3MakeRotationZYX(&result, &radiansXYZ); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3MakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec ) +{ + VmathSoaMatrix3 result; + vmathSoaM3MakeRotationAxis(&result, radians, &unitVec); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3MakeRotationQ_V( VmathSoaQuat unitQuat ) +{ + VmathSoaMatrix3 result; + vmathSoaM3MakeRotationQ(&result, &unitQuat); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3MakeScale_V( VmathSoaVector3 scaleVec ) +{ + VmathSoaMatrix3 result; + vmathSoaM3MakeScale(&result, &scaleVec); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3AppendScale_V( VmathSoaMatrix3 mat, VmathSoaVector3 scaleVec ) +{ + VmathSoaMatrix3 result; + vmathSoaM3AppendScale(&result, &mat, &scaleVec); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3PrependScale_V( VmathSoaVector3 scaleVec, VmathSoaMatrix3 mat ) +{ + VmathSoaMatrix3 result; + vmathSoaM3PrependScale(&result, &scaleVec, &mat); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaM3Select_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1, vec_uint4 select1 ) +{ + VmathSoaMatrix3 result; + vmathSoaM3Select(&result, &mat0, &mat1, select1); + return result; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathSoaM3Print_V( VmathSoaMatrix3 mat ) +{ + vmathSoaM3Print(&mat); +} + +static inline void vmathSoaM3Prints_V( VmathSoaMatrix3 mat, const char *name ) +{ + vmathSoaM3Prints(&mat, name); +} + +#endif + +static inline VmathSoaMatrix4 vmathSoaM4MakeFromScalar_V( vec_float4 scalar ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeFromScalar(&result, scalar); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakeFromT3_V( VmathSoaTransform3 mat ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeFromT3(&result, &mat); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakeFromCols_V( VmathSoaVector4 _col0, VmathSoaVector4 _col1, VmathSoaVector4 _col2, VmathSoaVector4 _col3 ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeFromCols(&result, &_col0, &_col1, &_col2, &_col3); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakeFromM3V3_V( VmathSoaMatrix3 mat, VmathSoaVector3 translateVec ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeFromM3V3(&result, &mat, &translateVec); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakeFromQV3_V( VmathSoaQuat unitQuat, VmathSoaVector3 translateVec ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeFromQV3(&result, &unitQuat, &translateVec); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakeFromAos_V( VmathMatrix4 mat ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeFromAos(&result, &mat); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakeFrom4Aos_V( VmathMatrix4 mat0, VmathMatrix4 mat1, VmathMatrix4 mat2, VmathMatrix4 mat3 ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeFrom4Aos(&result, &mat0, &mat1, &mat2, &mat3); + return result; +} + +static inline void vmathSoaM4Get4Aos_V( VmathSoaMatrix4 mat, VmathMatrix4 *result0, VmathMatrix4 *result1, VmathMatrix4 *result2, VmathMatrix4 *result3 ) +{ + vmathSoaM4Get4Aos(&mat, result0, result1, result2, result3); +} + +static inline void vmathSoaM4SetCol0_V( VmathSoaMatrix4 *result, VmathSoaVector4 _col0 ) +{ + vmathSoaM4SetCol0(result, &_col0); +} + +static inline void vmathSoaM4SetCol1_V( VmathSoaMatrix4 *result, VmathSoaVector4 _col1 ) +{ + vmathSoaM4SetCol1(result, &_col1); +} + +static inline void vmathSoaM4SetCol2_V( VmathSoaMatrix4 *result, VmathSoaVector4 _col2 ) +{ + vmathSoaM4SetCol2(result, &_col2); +} + +static inline void vmathSoaM4SetCol3_V( VmathSoaMatrix4 *result, VmathSoaVector4 _col3 ) +{ + vmathSoaM4SetCol3(result, &_col3); +} + +static inline void vmathSoaM4SetCol_V( VmathSoaMatrix4 *result, int col, VmathSoaVector4 vec ) +{ + vmathSoaM4SetCol(result, col, &vec); +} + +static inline void vmathSoaM4SetRow_V( VmathSoaMatrix4 *result, int row, VmathSoaVector4 vec ) +{ + vmathSoaM4SetRow(result, row, &vec); +} + +static inline void vmathSoaM4SetElem_V( VmathSoaMatrix4 *result, int col, int row, vec_float4 val ) +{ + vmathSoaM4SetElem(result, col, row, val); +} + +static inline vec_float4 vmathSoaM4GetElem_V( VmathSoaMatrix4 mat, int col, int row ) +{ + return vmathSoaM4GetElem(&mat, col, row); +} + +static inline VmathSoaVector4 vmathSoaM4GetCol0_V( VmathSoaMatrix4 mat ) +{ + VmathSoaVector4 result; + vmathSoaM4GetCol0(&result, &mat); + return result; +} + +static inline VmathSoaVector4 vmathSoaM4GetCol1_V( VmathSoaMatrix4 mat ) +{ + VmathSoaVector4 result; + vmathSoaM4GetCol1(&result, &mat); + return result; +} + +static inline VmathSoaVector4 vmathSoaM4GetCol2_V( VmathSoaMatrix4 mat ) +{ + VmathSoaVector4 result; + vmathSoaM4GetCol2(&result, &mat); + return result; +} + +static inline VmathSoaVector4 vmathSoaM4GetCol3_V( VmathSoaMatrix4 mat ) +{ + VmathSoaVector4 result; + vmathSoaM4GetCol3(&result, &mat); + return result; +} + +static inline VmathSoaVector4 vmathSoaM4GetCol_V( VmathSoaMatrix4 mat, int col ) +{ + VmathSoaVector4 result; + vmathSoaM4GetCol(&result, &mat, col); + return result; +} + +static inline VmathSoaVector4 vmathSoaM4GetRow_V( VmathSoaMatrix4 mat, int row ) +{ + VmathSoaVector4 result; + vmathSoaM4GetRow(&result, &mat, row); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4Transpose_V( VmathSoaMatrix4 mat ) +{ + VmathSoaMatrix4 result; + vmathSoaM4Transpose(&result, &mat); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4Inverse_V( VmathSoaMatrix4 mat ) +{ + VmathSoaMatrix4 result; + vmathSoaM4Inverse(&result, &mat); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4AffineInverse_V( VmathSoaMatrix4 mat ) +{ + VmathSoaMatrix4 result; + vmathSoaM4AffineInverse(&result, &mat); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4OrthoInverse_V( VmathSoaMatrix4 mat ) +{ + VmathSoaMatrix4 result; + vmathSoaM4OrthoInverse(&result, &mat); + return result; +} + +static inline vec_float4 vmathSoaM4Determinant_V( VmathSoaMatrix4 mat ) +{ + return vmathSoaM4Determinant(&mat); +} + +static inline VmathSoaMatrix4 vmathSoaM4Add_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1 ) +{ + VmathSoaMatrix4 result; + vmathSoaM4Add(&result, &mat0, &mat1); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4Sub_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1 ) +{ + VmathSoaMatrix4 result; + vmathSoaM4Sub(&result, &mat0, &mat1); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4Neg_V( VmathSoaMatrix4 mat ) +{ + VmathSoaMatrix4 result; + vmathSoaM4Neg(&result, &mat); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4AbsPerElem_V( VmathSoaMatrix4 mat ) +{ + VmathSoaMatrix4 result; + vmathSoaM4AbsPerElem(&result, &mat); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4ScalarMul_V( VmathSoaMatrix4 mat, vec_float4 scalar ) +{ + VmathSoaMatrix4 result; + vmathSoaM4ScalarMul(&result, &mat, scalar); + return result; +} + +static inline VmathSoaVector4 vmathSoaM4MulV4_V( VmathSoaMatrix4 mat, VmathSoaVector4 vec ) +{ + VmathSoaVector4 result; + vmathSoaM4MulV4(&result, &mat, &vec); + return result; +} + +static inline VmathSoaVector4 vmathSoaM4MulV3_V( VmathSoaMatrix4 mat, VmathSoaVector3 vec ) +{ + VmathSoaVector4 result; + vmathSoaM4MulV3(&result, &mat, &vec); + return result; +} + +static inline VmathSoaVector4 vmathSoaM4MulP3_V( VmathSoaMatrix4 mat, VmathSoaPoint3 pnt ) +{ + VmathSoaVector4 result; + vmathSoaM4MulP3(&result, &mat, &pnt); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4Mul_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1 ) +{ + VmathSoaMatrix4 result; + vmathSoaM4Mul(&result, &mat0, &mat1); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MulT3_V( VmathSoaMatrix4 mat, VmathSoaTransform3 tfrm1 ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MulT3(&result, &mat, &tfrm1); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MulPerElem_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1 ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MulPerElem(&result, &mat0, &mat1); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakeIdentity_V( ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeIdentity(&result); + return result; +} + +static inline void vmathSoaM4SetUpper3x3_V( VmathSoaMatrix4 *result, VmathSoaMatrix3 mat3 ) +{ + vmathSoaM4SetUpper3x3(result, &mat3); +} + +static inline VmathSoaMatrix3 vmathSoaM4GetUpper3x3_V( VmathSoaMatrix4 mat ) +{ + VmathSoaMatrix3 result; + vmathSoaM4GetUpper3x3(&result, &mat); + return result; +} + +static inline void vmathSoaM4SetTranslation_V( VmathSoaMatrix4 *result, VmathSoaVector3 translateVec ) +{ + vmathSoaM4SetTranslation(result, &translateVec); +} + +static inline VmathSoaVector3 vmathSoaM4GetTranslation_V( VmathSoaMatrix4 mat ) +{ + VmathSoaVector3 result; + vmathSoaM4GetTranslation(&result, &mat); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakeRotationX_V( vec_float4 radians ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeRotationX(&result, radians); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakeRotationY_V( vec_float4 radians ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeRotationY(&result, radians); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakeRotationZ_V( vec_float4 radians ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeRotationZ(&result, radians); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakeRotationZYX_V( VmathSoaVector3 radiansXYZ ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeRotationZYX(&result, &radiansXYZ); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeRotationAxis(&result, radians, &unitVec); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakeRotationQ_V( VmathSoaQuat unitQuat ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeRotationQ(&result, &unitQuat); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakeScale_V( VmathSoaVector3 scaleVec ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeScale(&result, &scaleVec); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4AppendScale_V( VmathSoaMatrix4 mat, VmathSoaVector3 scaleVec ) +{ + VmathSoaMatrix4 result; + vmathSoaM4AppendScale(&result, &mat, &scaleVec); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4PrependScale_V( VmathSoaVector3 scaleVec, VmathSoaMatrix4 mat ) +{ + VmathSoaMatrix4 result; + vmathSoaM4PrependScale(&result, &scaleVec, &mat); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakeTranslation_V( VmathSoaVector3 translateVec ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeTranslation(&result, &translateVec); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakeLookAt_V( VmathSoaPoint3 eyePos, VmathSoaPoint3 lookAtPos, VmathSoaVector3 upVec ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeLookAt(&result, &eyePos, &lookAtPos, &upVec); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakePerspective_V( vec_float4 fovyRadians, vec_float4 aspect, vec_float4 zNear, vec_float4 zFar ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakePerspective(&result, fovyRadians, aspect, zNear, zFar); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakeFrustum_V( vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeFrustum(&result, left, right, bottom, top, zNear, zFar); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4MakeOrthographic_V( vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ) +{ + VmathSoaMatrix4 result; + vmathSoaM4MakeOrthographic(&result, left, right, bottom, top, zNear, zFar); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaM4Select_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1, vec_uint4 select1 ) +{ + VmathSoaMatrix4 result; + vmathSoaM4Select(&result, &mat0, &mat1, select1); + return result; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathSoaM4Print_V( VmathSoaMatrix4 mat ) +{ + vmathSoaM4Print(&mat); +} + +static inline void vmathSoaM4Prints_V( VmathSoaMatrix4 mat, const char *name ) +{ + vmathSoaM4Prints(&mat, name); +} + +#endif + +static inline VmathSoaTransform3 vmathSoaT3MakeFromScalar_V( vec_float4 scalar ) +{ + VmathSoaTransform3 result; + vmathSoaT3MakeFromScalar(&result, scalar); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3MakeFromCols_V( VmathSoaVector3 _col0, VmathSoaVector3 _col1, VmathSoaVector3 _col2, VmathSoaVector3 _col3 ) +{ + VmathSoaTransform3 result; + vmathSoaT3MakeFromCols(&result, &_col0, &_col1, &_col2, &_col3); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3MakeFromM3V3_V( VmathSoaMatrix3 tfrm, VmathSoaVector3 translateVec ) +{ + VmathSoaTransform3 result; + vmathSoaT3MakeFromM3V3(&result, &tfrm, &translateVec); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3MakeFromQV3_V( VmathSoaQuat unitQuat, VmathSoaVector3 translateVec ) +{ + VmathSoaTransform3 result; + vmathSoaT3MakeFromQV3(&result, &unitQuat, &translateVec); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3MakeFromAos_V( VmathTransform3 tfrm ) +{ + VmathSoaTransform3 result; + vmathSoaT3MakeFromAos(&result, &tfrm); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3MakeFrom4Aos_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1, VmathTransform3 tfrm2, VmathTransform3 tfrm3 ) +{ + VmathSoaTransform3 result; + vmathSoaT3MakeFrom4Aos(&result, &tfrm0, &tfrm1, &tfrm2, &tfrm3); + return result; +} + +static inline void vmathSoaT3Get4Aos_V( VmathSoaTransform3 tfrm, VmathTransform3 *result0, VmathTransform3 *result1, VmathTransform3 *result2, VmathTransform3 *result3 ) +{ + vmathSoaT3Get4Aos(&tfrm, result0, result1, result2, result3); +} + +static inline void vmathSoaT3SetCol0_V( VmathSoaTransform3 *result, VmathSoaVector3 _col0 ) +{ + vmathSoaT3SetCol0(result, &_col0); +} + +static inline void vmathSoaT3SetCol1_V( VmathSoaTransform3 *result, VmathSoaVector3 _col1 ) +{ + vmathSoaT3SetCol1(result, &_col1); +} + +static inline void vmathSoaT3SetCol2_V( VmathSoaTransform3 *result, VmathSoaVector3 _col2 ) +{ + vmathSoaT3SetCol2(result, &_col2); +} + +static inline void vmathSoaT3SetCol3_V( VmathSoaTransform3 *result, VmathSoaVector3 _col3 ) +{ + vmathSoaT3SetCol3(result, &_col3); +} + +static inline void vmathSoaT3SetCol_V( VmathSoaTransform3 *result, int col, VmathSoaVector3 vec ) +{ + vmathSoaT3SetCol(result, col, &vec); +} + +static inline void vmathSoaT3SetRow_V( VmathSoaTransform3 *result, int row, VmathSoaVector4 vec ) +{ + vmathSoaT3SetRow(result, row, &vec); +} + +static inline void vmathSoaT3SetElem_V( VmathSoaTransform3 *result, int col, int row, vec_float4 val ) +{ + vmathSoaT3SetElem(result, col, row, val); +} + +static inline vec_float4 vmathSoaT3GetElem_V( VmathSoaTransform3 tfrm, int col, int row ) +{ + return vmathSoaT3GetElem(&tfrm, col, row); +} + +static inline VmathSoaVector3 vmathSoaT3GetCol0_V( VmathSoaTransform3 tfrm ) +{ + VmathSoaVector3 result; + vmathSoaT3GetCol0(&result, &tfrm); + return result; +} + +static inline VmathSoaVector3 vmathSoaT3GetCol1_V( VmathSoaTransform3 tfrm ) +{ + VmathSoaVector3 result; + vmathSoaT3GetCol1(&result, &tfrm); + return result; +} + +static inline VmathSoaVector3 vmathSoaT3GetCol2_V( VmathSoaTransform3 tfrm ) +{ + VmathSoaVector3 result; + vmathSoaT3GetCol2(&result, &tfrm); + return result; +} + +static inline VmathSoaVector3 vmathSoaT3GetCol3_V( VmathSoaTransform3 tfrm ) +{ + VmathSoaVector3 result; + vmathSoaT3GetCol3(&result, &tfrm); + return result; +} + +static inline VmathSoaVector3 vmathSoaT3GetCol_V( VmathSoaTransform3 tfrm, int col ) +{ + VmathSoaVector3 result; + vmathSoaT3GetCol(&result, &tfrm, col); + return result; +} + +static inline VmathSoaVector4 vmathSoaT3GetRow_V( VmathSoaTransform3 tfrm, int row ) +{ + VmathSoaVector4 result; + vmathSoaT3GetRow(&result, &tfrm, row); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3Inverse_V( VmathSoaTransform3 tfrm ) +{ + VmathSoaTransform3 result; + vmathSoaT3Inverse(&result, &tfrm); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3OrthoInverse_V( VmathSoaTransform3 tfrm ) +{ + VmathSoaTransform3 result; + vmathSoaT3OrthoInverse(&result, &tfrm); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3AbsPerElem_V( VmathSoaTransform3 tfrm ) +{ + VmathSoaTransform3 result; + vmathSoaT3AbsPerElem(&result, &tfrm); + return result; +} + +static inline VmathSoaVector3 vmathSoaT3MulV3_V( VmathSoaTransform3 tfrm, VmathSoaVector3 vec ) +{ + VmathSoaVector3 result; + vmathSoaT3MulV3(&result, &tfrm, &vec); + return result; +} + +static inline VmathSoaPoint3 vmathSoaT3MulP3_V( VmathSoaTransform3 tfrm, VmathSoaPoint3 pnt ) +{ + VmathSoaPoint3 result; + vmathSoaT3MulP3(&result, &tfrm, &pnt); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3Mul_V( VmathSoaTransform3 tfrm0, VmathSoaTransform3 tfrm1 ) +{ + VmathSoaTransform3 result; + vmathSoaT3Mul(&result, &tfrm0, &tfrm1); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3MulPerElem_V( VmathSoaTransform3 tfrm0, VmathSoaTransform3 tfrm1 ) +{ + VmathSoaTransform3 result; + vmathSoaT3MulPerElem(&result, &tfrm0, &tfrm1); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3MakeIdentity_V( ) +{ + VmathSoaTransform3 result; + vmathSoaT3MakeIdentity(&result); + return result; +} + +static inline void vmathSoaT3SetUpper3x3_V( VmathSoaTransform3 *result, VmathSoaMatrix3 tfrm ) +{ + vmathSoaT3SetUpper3x3(result, &tfrm); +} + +static inline VmathSoaMatrix3 vmathSoaT3GetUpper3x3_V( VmathSoaTransform3 tfrm ) +{ + VmathSoaMatrix3 result; + vmathSoaT3GetUpper3x3(&result, &tfrm); + return result; +} + +static inline void vmathSoaT3SetTranslation_V( VmathSoaTransform3 *result, VmathSoaVector3 translateVec ) +{ + vmathSoaT3SetTranslation(result, &translateVec); +} + +static inline VmathSoaVector3 vmathSoaT3GetTranslation_V( VmathSoaTransform3 tfrm ) +{ + VmathSoaVector3 result; + vmathSoaT3GetTranslation(&result, &tfrm); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3MakeRotationX_V( vec_float4 radians ) +{ + VmathSoaTransform3 result; + vmathSoaT3MakeRotationX(&result, radians); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3MakeRotationY_V( vec_float4 radians ) +{ + VmathSoaTransform3 result; + vmathSoaT3MakeRotationY(&result, radians); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3MakeRotationZ_V( vec_float4 radians ) +{ + VmathSoaTransform3 result; + vmathSoaT3MakeRotationZ(&result, radians); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3MakeRotationZYX_V( VmathSoaVector3 radiansXYZ ) +{ + VmathSoaTransform3 result; + vmathSoaT3MakeRotationZYX(&result, &radiansXYZ); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3MakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec ) +{ + VmathSoaTransform3 result; + vmathSoaT3MakeRotationAxis(&result, radians, &unitVec); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3MakeRotationQ_V( VmathSoaQuat unitQuat ) +{ + VmathSoaTransform3 result; + vmathSoaT3MakeRotationQ(&result, &unitQuat); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3MakeScale_V( VmathSoaVector3 scaleVec ) +{ + VmathSoaTransform3 result; + vmathSoaT3MakeScale(&result, &scaleVec); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3AppendScale_V( VmathSoaTransform3 tfrm, VmathSoaVector3 scaleVec ) +{ + VmathSoaTransform3 result; + vmathSoaT3AppendScale(&result, &tfrm, &scaleVec); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3PrependScale_V( VmathSoaVector3 scaleVec, VmathSoaTransform3 tfrm ) +{ + VmathSoaTransform3 result; + vmathSoaT3PrependScale(&result, &scaleVec, &tfrm); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3MakeTranslation_V( VmathSoaVector3 translateVec ) +{ + VmathSoaTransform3 result; + vmathSoaT3MakeTranslation(&result, &translateVec); + return result; +} + +static inline VmathSoaTransform3 vmathSoaT3Select_V( VmathSoaTransform3 tfrm0, VmathSoaTransform3 tfrm1, vec_uint4 select1 ) +{ + VmathSoaTransform3 result; + vmathSoaT3Select(&result, &tfrm0, &tfrm1, select1); + return result; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathSoaT3Print_V( VmathSoaTransform3 tfrm ) +{ + vmathSoaT3Print(&tfrm); +} + +static inline void vmathSoaT3Prints_V( VmathSoaTransform3 tfrm, const char *name ) +{ + vmathSoaT3Prints(&tfrm, name); +} + +#endif + +static inline VmathSoaQuat vmathSoaQMakeFromM3_V( VmathSoaMatrix3 tfrm ) +{ + VmathSoaQuat result; + vmathSoaQMakeFromM3(&result, &tfrm); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaV3Outer_V( VmathSoaVector3 tfrm0, VmathSoaVector3 tfrm1 ) +{ + VmathSoaMatrix3 result; + vmathSoaV3Outer(&result, &tfrm0, &tfrm1); + return result; +} + +static inline VmathSoaMatrix4 vmathSoaV4Outer_V( VmathSoaVector4 tfrm0, VmathSoaVector4 tfrm1 ) +{ + VmathSoaMatrix4 result; + vmathSoaV4Outer(&result, &tfrm0, &tfrm1); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3RowMul_V( VmathSoaVector3 vec, VmathSoaMatrix3 mat ) +{ + VmathSoaVector3 result; + vmathSoaV3RowMul(&result, &vec, &mat); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaV3CrossMatrix_V( VmathSoaVector3 vec ) +{ + VmathSoaMatrix3 result; + vmathSoaV3CrossMatrix(&result, &vec); + return result; +} + +static inline VmathSoaMatrix3 vmathSoaV3CrossMatrixMul_V( VmathSoaVector3 vec, VmathSoaMatrix3 mat ) +{ + VmathSoaMatrix3 result; + vmathSoaV3CrossMatrixMul(&result, &vec, &mat); + return result; +} + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/vectormathlibrary/include/vectormath/spu/c/quat_aos.h b/vectormathlibrary/include/vectormath/spu/c/quat_aos.h new file mode 100644 index 000000000..0f25d654b --- /dev/null +++ b/vectormathlibrary/include/vectormath/spu/c/quat_aos.h @@ -0,0 +1,371 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_QUAT_AOS_C_H +#define _VECTORMATH_QUAT_AOS_C_H +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/*----------------------------------------------------------------------------- + * Definitions + */ +#ifndef _VECTORMATH_INTERNAL_FUNCTIONS +#define _VECTORMATH_INTERNAL_FUNCTIONS + +#endif + +static inline void vmathQCopy( VmathQuat *result, const VmathQuat *quat ) +{ + result->vec128 = quat->vec128; +} + +static inline void vmathQMakeFromElems( VmathQuat *result, float _x, float _y, float _z, float _w ) +{ + result->vec128 = (vec_float4){ _x, _y, _z, _w }; +} + +static inline void vmathQMakeFromV3Scalar( VmathQuat *result, const VmathVector3 *xyz, float _w ) +{ + result->vec128 = spu_shuffle( xyz->vec128, spu_promote( _w, 0 ), _VECTORMATH_SHUF_XYZA ); +} + +static inline void vmathQMakeFromV4( VmathQuat *result, const VmathVector4 *vec ) +{ + result->vec128 = vec->vec128; +} + +static inline void vmathQMakeFromScalar( VmathQuat *result, float scalar ) +{ + result->vec128 = spu_splats( scalar ); +} + +static inline void vmathQMakeFrom128( VmathQuat *result, vec_float4 vf4 ) +{ + result->vec128 = vf4; +} + +static inline void vmathQMakeIdentity( VmathQuat *result ) +{ + result->vec128 = _VECTORMATH_UNIT_0001; +} + +static inline void vmathQLerp( VmathQuat *result, float t, const VmathQuat *quat0, const VmathQuat *quat1 ) +{ + VmathQuat tmpQ_0, tmpQ_1; + vmathQSub( &tmpQ_0, quat1, quat0 ); + vmathQScalarMul( &tmpQ_1, &tmpQ_0, t ); + vmathQAdd( result, quat0, &tmpQ_1 ); +} + +static inline void vmathQSlerp( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1 ) +{ + VmathQuat start; + vec_float4 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines; + vec_uint4 selectMask; + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); + cosAngle = _vmathVfDot4( unitQuat0->vec128, unitQuat1->vec128 ); + cosAngle = spu_shuffle( cosAngle, cosAngle, shuffle_xxxx ); + selectMask = (vec_uint4)spu_cmpgt( spu_splats(0.0f), cosAngle ); + cosAngle = spu_sel( cosAngle, negatef4( cosAngle ), selectMask ); + start.vec128 = spu_sel( unitQuat0->vec128, negatef4( unitQuat0->vec128 ), selectMask ); + selectMask = (vec_uint4)spu_cmpgt( spu_splats(_VECTORMATH_SLERP_TOL), cosAngle ); + angle = acosf4( cosAngle ); + tttt = spu_splats(t); + oneMinusT = spu_sub( spu_splats(1.0f), tttt ); + angles = spu_sel( spu_splats(1.0f), oneMinusT, (vec_uint4)spu_maskb(0x0f00) ); + angles = spu_sel( angles, tttt, (vec_uint4)spu_maskb(0x00f0) ); + angles = spu_mul( angles, angle ); + sines = sinf4( angles ); + scales = divf4( sines, spu_shuffle( sines, sines, shuffle_xxxx ) ); + scale0 = spu_sel( oneMinusT, spu_shuffle( scales, scales, shuffle_yyyy ), selectMask ); + scale1 = spu_sel( tttt, spu_shuffle( scales, scales, shuffle_zzzz ), selectMask ); + result->vec128 = spu_madd( start.vec128, scale0, spu_mul( unitQuat1->vec128, scale1 ) ); +} + +static inline void vmathQSquad( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1, const VmathQuat *unitQuat2, const VmathQuat *unitQuat3 ) +{ + VmathQuat tmp0, tmp1; + vmathQSlerp( &tmp0, t, unitQuat0, unitQuat3 ); + vmathQSlerp( &tmp1, t, unitQuat1, unitQuat2 ); + vmathQSlerp( result, ( ( 2.0f * t ) * ( 1.0f - t ) ), &tmp0, &tmp1 ); +} + +static inline vec_float4 vmathQGet128( const VmathQuat *quat ) +{ + return quat->vec128; +} + +static inline void vmathQSetXYZ( VmathQuat *result, const VmathVector3 *vec ) +{ + result->vec128 = spu_sel( vec->vec128, result->vec128, (vec_uint4)spu_maskb(0x000f) ); +} + +static inline void vmathQGetXYZ( VmathVector3 *result, const VmathQuat *quat ) +{ + result->vec128 = quat->vec128; +} + +static inline void vmathQSetX( VmathQuat *result, float _x ) +{ + result->vec128 = spu_insert( _x, result->vec128, 0 ); +} + +static inline float vmathQGetX( const VmathQuat *quat ) +{ + return spu_extract( quat->vec128, 0 ); +} + +static inline void vmathQSetY( VmathQuat *result, float _y ) +{ + result->vec128 = spu_insert( _y, result->vec128, 1 ); +} + +static inline float vmathQGetY( const VmathQuat *quat ) +{ + return spu_extract( quat->vec128, 1 ); +} + +static inline void vmathQSetZ( VmathQuat *result, float _z ) +{ + result->vec128 = spu_insert( _z, result->vec128, 2 ); +} + +static inline float vmathQGetZ( const VmathQuat *quat ) +{ + return spu_extract( quat->vec128, 2 ); +} + +static inline void vmathQSetW( VmathQuat *result, float _w ) +{ + result->vec128 = spu_insert( _w, result->vec128, 3 ); +} + +static inline float vmathQGetW( const VmathQuat *quat ) +{ + return spu_extract( quat->vec128, 3 ); +} + +static inline void vmathQSetElem( VmathQuat *result, int idx, float value ) +{ + result->vec128 = spu_insert( value, result->vec128, idx ); +} + +static inline float vmathQGetElem( const VmathQuat *quat, int idx ) +{ + return spu_extract( quat->vec128, idx ); +} + +static inline void vmathQAdd( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ) +{ + result->vec128 = spu_add( quat0->vec128, quat1->vec128 ); +} + +static inline void vmathQSub( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ) +{ + result->vec128 = spu_sub( quat0->vec128, quat1->vec128 ); +} + +static inline void vmathQScalarMul( VmathQuat *result, const VmathQuat *quat, float scalar ) +{ + result->vec128 = spu_mul( quat->vec128, spu_splats(scalar) ); +} + +static inline void vmathQScalarDiv( VmathQuat *result, const VmathQuat *quat, float scalar ) +{ + result->vec128 = divf4( quat->vec128, spu_splats(scalar) ); +} + +static inline void vmathQNeg( VmathQuat *result, const VmathQuat *quat ) +{ + result->vec128 = negatef4( quat->vec128 ); +} + +static inline float vmathQDot( const VmathQuat *quat0, const VmathQuat *quat1 ) +{ + return spu_extract( _vmathVfDot4( quat0->vec128, quat1->vec128 ), 0 ); +} + +static inline float vmathQNorm( const VmathQuat *quat ) +{ + return spu_extract( _vmathVfDot4( quat->vec128, quat->vec128 ), 0 ); +} + +static inline float vmathQLength( const VmathQuat *quat ) +{ + return sqrtf( vmathQNorm( quat ) ); +} + +static inline void vmathQNormalize( VmathQuat *result, const VmathQuat *quat ) +{ + vec_float4 dot = _vmathVfDot4( quat->vec128, quat->vec128 ); + result->vec128 = spu_mul( quat->vec128, rsqrtf4( dot ) ); +} + +static inline void vmathQMakeRotationArc( VmathQuat *result, const VmathVector3 *unitVec0, const VmathVector3 *unitVec1 ) +{ + VmathVector3 crossVec, tmpV3_0; + vec_float4 cosAngle, cosAngleX2Plus2, recipCosHalfAngleX2, cosHalfAngleX2, res; + cosAngle = _vmathVfDot3( unitVec0->vec128, unitVec1->vec128 ); + cosAngle = spu_shuffle( cosAngle, cosAngle, (vec_uchar16)spu_splats(0x00010203) ); + cosAngleX2Plus2 = spu_madd( cosAngle, spu_splats(2.0f), spu_splats(2.0f) ); + recipCosHalfAngleX2 = rsqrtf4( cosAngleX2Plus2 ); + cosHalfAngleX2 = spu_mul( recipCosHalfAngleX2, cosAngleX2Plus2 ); + vmathV3Cross( &tmpV3_0, unitVec0, unitVec1 ); + crossVec = tmpV3_0; + res = spu_mul( crossVec.vec128, recipCosHalfAngleX2 ); + res = spu_sel( res, spu_mul( cosHalfAngleX2, spu_splats(0.5f) ), (vec_uint4)spu_maskb(0x000f) ); + result->vec128 = res; +} + +static inline void vmathQMakeRotationAxis( VmathQuat *result, float radians, const VmathVector3 *unitVec ) +{ + vec_float4 s, c, angle, res; + angle = spu_mul( spu_splats(radians), spu_splats(0.5f) ); + sincosf4( angle, &s, &c ); + res = spu_sel( spu_mul( unitVec->vec128, s ), c, (vec_uint4)spu_maskb(0x000f) ); + result->vec128 = res; +} + +static inline void vmathQMakeRotationX( VmathQuat *result, float radians ) +{ + vec_float4 s, c, angle, res; + angle = spu_mul( spu_splats(radians), spu_splats(0.5f) ); + sincosf4( angle, &s, &c ); + res = spu_sel( spu_splats(0.0f), s, (vec_uint4)spu_maskb(0xf000) ); + res = spu_sel( res, c, (vec_uint4)spu_maskb(0x000f) ); + result->vec128 = res; +} + +static inline void vmathQMakeRotationY( VmathQuat *result, float radians ) +{ + vec_float4 s, c, angle, res; + angle = spu_mul( spu_splats(radians), spu_splats(0.5f) ); + sincosf4( angle, &s, &c ); + res = spu_sel( spu_splats(0.0f), s, (vec_uint4)spu_maskb(0x0f00) ); + res = spu_sel( res, c, (vec_uint4)spu_maskb(0x000f) ); + result->vec128 = res; +} + +static inline void vmathQMakeRotationZ( VmathQuat *result, float radians ) +{ + vec_float4 s, c, angle, res; + angle = spu_mul( spu_splats(radians), spu_splats(0.5f) ); + sincosf4( angle, &s, &c ); + res = spu_sel( spu_splats(0.0f), s, (vec_uint4)spu_maskb(0x00f0) ); + res = spu_sel( res, c, (vec_uint4)spu_maskb(0x000f) ); + result->vec128 = res; +} + +static inline void vmathQMul( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ) +{ + vec_float4 ldata, rdata, qv, tmp0, tmp1, tmp2, tmp3; + vec_float4 product, l_wxyz, r_wxyz, xy, qw; + ldata = quat0->vec128; + rdata = quat1->vec128; + vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f); + tmp0 = spu_shuffle( ldata, ldata, _VECTORMATH_SHUF_YZXW ); + tmp1 = spu_shuffle( rdata, rdata, _VECTORMATH_SHUF_ZXYW ); + tmp2 = spu_shuffle( ldata, ldata, _VECTORMATH_SHUF_ZXYW ); + tmp3 = spu_shuffle( rdata, rdata, _VECTORMATH_SHUF_YZXW ); + qv = spu_mul( spu_shuffle( ldata, ldata, shuffle_wwww ), rdata ); + qv = spu_madd( spu_shuffle( rdata, rdata, shuffle_wwww ), ldata, qv ); + qv = spu_madd( tmp0, tmp1, qv ); + qv = spu_nmsub( tmp2, tmp3, qv ); + product = spu_mul( ldata, rdata ); + l_wxyz = spu_rlqwbyte( ldata, 12 ); + r_wxyz = spu_rlqwbyte( rdata, 12 ); + qw = spu_nmsub( l_wxyz, r_wxyz, product ); + xy = spu_madd( l_wxyz, r_wxyz, product ); + qw = spu_sub( qw, spu_rlqwbyte( xy, 8 ) ); + result->vec128 = spu_sel( qv, qw, (vec_uint4)spu_maskb( 0x000f ) ); +} + +static inline void vmathQRotate( VmathVector3 *result, const VmathQuat *quat, const VmathVector3 *vec ) +{ + vec_float4 qdata, vdata, product, tmp0, tmp1, tmp2, tmp3, wwww, qv, qw, res; + qdata = quat->vec128; + vdata = vec->vec128; + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f); + tmp0 = spu_shuffle( qdata, qdata, _VECTORMATH_SHUF_YZXW ); + tmp1 = spu_shuffle( vdata, vdata, _VECTORMATH_SHUF_ZXYW ); + tmp2 = spu_shuffle( qdata, qdata, _VECTORMATH_SHUF_ZXYW ); + tmp3 = spu_shuffle( vdata, vdata, _VECTORMATH_SHUF_YZXW ); + wwww = spu_shuffle( qdata, qdata, shuffle_wwww ); + qv = spu_mul( wwww, vdata ); + qv = spu_madd( tmp0, tmp1, qv ); + qv = spu_nmsub( tmp2, tmp3, qv ); + product = spu_mul( qdata, vdata ); + qw = spu_madd( spu_rlqwbyte( qdata, 4 ), spu_rlqwbyte( vdata, 4 ), product ); + qw = spu_add( spu_rlqwbyte( product, 8 ), qw ); + tmp1 = spu_shuffle( qv, qv, _VECTORMATH_SHUF_ZXYW ); + tmp3 = spu_shuffle( qv, qv, _VECTORMATH_SHUF_YZXW ); + res = spu_mul( spu_shuffle( qw, qw, shuffle_xxxx ), qdata ); + res = spu_madd( wwww, qv, res ); + res = spu_madd( tmp0, tmp1, res ); + res = spu_nmsub( tmp2, tmp3, res ); + result->vec128 = res; +} + +static inline void vmathQConj( VmathQuat *result, const VmathQuat *quat ) +{ + result->vec128 = spu_xor( quat->vec128, ((vec_float4)(vec_int4){0x80000000,0x80000000,0x80000000,0}) ); +} + +static inline void vmathQSelect( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1, unsigned int select1 ) +{ + result->vec128 = spu_sel( quat0->vec128, quat1->vec128, spu_splats( (unsigned int)-(select1 > 0) ) ); +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathQPrint( const VmathQuat *quat ) +{ + union { vec_float4 v; float s[4]; } tmp; + tmp.v = quat->vec128; + printf( "( %f %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] ); +} + +static inline void vmathQPrints( const VmathQuat *quat, const char *name ) +{ + union { vec_float4 v; float s[4]; } tmp; + tmp.v = quat->vec128; + printf( "%s: ( %f %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] ); +} + +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/vectormathlibrary/include/vectormath/spu/c/quat_aos_v.h b/vectormathlibrary/include/vectormath/spu/c/quat_aos_v.h new file mode 100644 index 000000000..04cf6ccf9 --- /dev/null +++ b/vectormathlibrary/include/vectormath/spu/c/quat_aos_v.h @@ -0,0 +1,312 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_QUAT_AOS_V_C_H +#define _VECTORMATH_QUAT_AOS_V_C_H +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/*----------------------------------------------------------------------------- + * Definitions + */ +#ifndef _VECTORMATH_INTERNAL_FUNCTIONS +#define _VECTORMATH_INTERNAL_FUNCTIONS + +#endif + +static inline VmathQuat vmathQMakeFromElems_V( float _x, float _y, float _z, float _w ) +{ + VmathQuat result; + vmathQMakeFromElems(&result, _x, _y, _z, _w); + return result; +} + +static inline VmathQuat vmathQMakeFromV3Scalar_V( VmathVector3 xyz, float _w ) +{ + VmathQuat result; + vmathQMakeFromV3Scalar(&result, &xyz, _w); + return result; +} + +static inline VmathQuat vmathQMakeFromV4_V( VmathVector4 vec ) +{ + VmathQuat result; + vmathQMakeFromV4(&result, &vec); + return result; +} + +static inline VmathQuat vmathQMakeFromScalar_V( float scalar ) +{ + VmathQuat result; + vmathQMakeFromScalar(&result, scalar); + return result; +} + +static inline VmathQuat vmathQMakeFrom128_V( vec_float4 vf4 ) +{ + VmathQuat result; + vmathQMakeFrom128(&result, vf4); + return result; +} + +static inline VmathQuat vmathQMakeIdentity_V( ) +{ + VmathQuat result; + vmathQMakeIdentity(&result); + return result; +} + +static inline VmathQuat vmathQLerp_V( float t, VmathQuat quat0, VmathQuat quat1 ) +{ + VmathQuat result; + vmathQLerp(&result, t, &quat0, &quat1); + return result; +} + +static inline VmathQuat vmathQSlerp_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1 ) +{ + VmathQuat result; + vmathQSlerp(&result, t, &unitQuat0, &unitQuat1); + return result; +} + +static inline VmathQuat vmathQSquad_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1, VmathQuat unitQuat2, VmathQuat unitQuat3 ) +{ + VmathQuat result; + vmathQSquad(&result, t, &unitQuat0, &unitQuat1, &unitQuat2, &unitQuat3); + return result; +} + +static inline vec_float4 vmathQGet128_V( VmathQuat quat ) +{ + return vmathQGet128(&quat); +} + +static inline void vmathQSetXYZ_V( VmathQuat *result, VmathVector3 vec ) +{ + vmathQSetXYZ(result, &vec); +} + +static inline VmathVector3 vmathQGetXYZ_V( VmathQuat quat ) +{ + VmathVector3 result; + vmathQGetXYZ(&result, &quat); + return result; +} + +static inline void vmathQSetX_V( VmathQuat *result, float _x ) +{ + vmathQSetX(result, _x); +} + +static inline float vmathQGetX_V( VmathQuat quat ) +{ + return vmathQGetX(&quat); +} + +static inline void vmathQSetY_V( VmathQuat *result, float _y ) +{ + vmathQSetY(result, _y); +} + +static inline float vmathQGetY_V( VmathQuat quat ) +{ + return vmathQGetY(&quat); +} + +static inline void vmathQSetZ_V( VmathQuat *result, float _z ) +{ + vmathQSetZ(result, _z); +} + +static inline float vmathQGetZ_V( VmathQuat quat ) +{ + return vmathQGetZ(&quat); +} + +static inline void vmathQSetW_V( VmathQuat *result, float _w ) +{ + vmathQSetW(result, _w); +} + +static inline float vmathQGetW_V( VmathQuat quat ) +{ + return vmathQGetW(&quat); +} + +static inline void vmathQSetElem_V( VmathQuat *result, int idx, float value ) +{ + vmathQSetElem(result, idx, value); +} + +static inline float vmathQGetElem_V( VmathQuat quat, int idx ) +{ + return vmathQGetElem(&quat, idx); +} + +static inline VmathQuat vmathQAdd_V( VmathQuat quat0, VmathQuat quat1 ) +{ + VmathQuat result; + vmathQAdd(&result, &quat0, &quat1); + return result; +} + +static inline VmathQuat vmathQSub_V( VmathQuat quat0, VmathQuat quat1 ) +{ + VmathQuat result; + vmathQSub(&result, &quat0, &quat1); + return result; +} + +static inline VmathQuat vmathQScalarMul_V( VmathQuat quat, float scalar ) +{ + VmathQuat result; + vmathQScalarMul(&result, &quat, scalar); + return result; +} + +static inline VmathQuat vmathQScalarDiv_V( VmathQuat quat, float scalar ) +{ + VmathQuat result; + vmathQScalarDiv(&result, &quat, scalar); + return result; +} + +static inline VmathQuat vmathQNeg_V( VmathQuat quat ) +{ + VmathQuat result; + vmathQNeg(&result, &quat); + return result; +} + +static inline float vmathQDot_V( VmathQuat quat0, VmathQuat quat1 ) +{ + return vmathQDot(&quat0, &quat1); +} + +static inline float vmathQNorm_V( VmathQuat quat ) +{ + return vmathQNorm(&quat); +} + +static inline float vmathQLength_V( VmathQuat quat ) +{ + return vmathQLength(&quat); +} + +static inline VmathQuat vmathQNormalize_V( VmathQuat quat ) +{ + VmathQuat result; + vmathQNormalize(&result, &quat); + return result; +} + +static inline VmathQuat vmathQMakeRotationArc_V( VmathVector3 unitVec0, VmathVector3 unitVec1 ) +{ + VmathQuat result; + vmathQMakeRotationArc(&result, &unitVec0, &unitVec1); + return result; +} + +static inline VmathQuat vmathQMakeRotationAxis_V( float radians, VmathVector3 unitVec ) +{ + VmathQuat result; + vmathQMakeRotationAxis(&result, radians, &unitVec); + return result; +} + +static inline VmathQuat vmathQMakeRotationX_V( float radians ) +{ + VmathQuat result; + vmathQMakeRotationX(&result, radians); + return result; +} + +static inline VmathQuat vmathQMakeRotationY_V( float radians ) +{ + VmathQuat result; + vmathQMakeRotationY(&result, radians); + return result; +} + +static inline VmathQuat vmathQMakeRotationZ_V( float radians ) +{ + VmathQuat result; + vmathQMakeRotationZ(&result, radians); + return result; +} + +static inline VmathQuat vmathQMul_V( VmathQuat quat0, VmathQuat quat1 ) +{ + VmathQuat result; + vmathQMul(&result, &quat0, &quat1); + return result; +} + +static inline VmathVector3 vmathQRotate_V( VmathQuat quat, VmathVector3 vec ) +{ + VmathVector3 result; + vmathQRotate(&result, &quat, &vec); + return result; +} + +static inline VmathQuat vmathQConj_V( VmathQuat quat ) +{ + VmathQuat result; + vmathQConj(&result, &quat); + return result; +} + +static inline VmathQuat vmathQSelect_V( VmathQuat quat0, VmathQuat quat1, unsigned int select1 ) +{ + VmathQuat result; + vmathQSelect(&result, &quat0, &quat1, select1); + return result; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathQPrint_V( VmathQuat quat ) +{ + vmathQPrint(&quat); +} + +static inline void vmathQPrints_V( VmathQuat quat, const char *name ) +{ + vmathQPrints(&quat, name); +} + +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/vectormathlibrary/include/vectormath/spu/c/quat_soa.h b/vectormathlibrary/include/vectormath/spu/c/quat_soa.h new file mode 100644 index 000000000..cd79e9d8d --- /dev/null +++ b/vectormathlibrary/include/vectormath/spu/c/quat_soa.h @@ -0,0 +1,419 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_QUAT_SOA_C_H +#define _VECTORMATH_QUAT_SOA_C_H +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/*----------------------------------------------------------------------------- + * Definitions + */ +#ifndef _VECTORMATH_INTERNAL_FUNCTIONS +#define _VECTORMATH_INTERNAL_FUNCTIONS + +#endif + +static inline void vmathSoaQCopy( VmathSoaQuat *result, const VmathSoaQuat *quat ) +{ + result->x = quat->x; + result->y = quat->y; + result->z = quat->z; + result->w = quat->w; +} + +static inline void vmathSoaQMakeFromElems( VmathSoaQuat *result, vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w ) +{ + result->x = _x; + result->y = _y; + result->z = _z; + result->w = _w; +} + +static inline void vmathSoaQMakeFromV3Scalar( VmathSoaQuat *result, const VmathSoaVector3 *xyz, vec_float4 _w ) +{ + vmathSoaQSetXYZ( result, xyz ); + vmathSoaQSetW( result, _w ); +} + +static inline void vmathSoaQMakeFromV4( VmathSoaQuat *result, const VmathSoaVector4 *vec ) +{ + result->x = vec->x; + result->y = vec->y; + result->z = vec->z; + result->w = vec->w; +} + +static inline void vmathSoaQMakeFromScalar( VmathSoaQuat *result, vec_float4 scalar ) +{ + result->x = scalar; + result->y = scalar; + result->z = scalar; + result->w = scalar; +} + +static inline void vmathSoaQMakeFromAos( VmathSoaQuat *result, const VmathQuat *quat ) +{ + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); + vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f); + vec_float4 vec128 = quat->vec128; + result->x = spu_shuffle( vec128, vec128, shuffle_xxxx ); + result->y = spu_shuffle( vec128, vec128, shuffle_yyyy ); + result->z = spu_shuffle( vec128, vec128, shuffle_zzzz ); + result->w = spu_shuffle( vec128, vec128, shuffle_wwww ); +} + +static inline void vmathSoaQMakeFrom4Aos( VmathSoaQuat *result, const VmathQuat *quat0, const VmathQuat *quat1, const VmathQuat *quat2, const VmathQuat *quat3 ) +{ + vec_float4 tmp0, tmp1, tmp2, tmp3; + tmp0 = spu_shuffle( quat0->vec128, quat2->vec128, _VECTORMATH_SHUF_XAYB ); + tmp1 = spu_shuffle( quat1->vec128, quat3->vec128, _VECTORMATH_SHUF_XAYB ); + tmp2 = spu_shuffle( quat0->vec128, quat2->vec128, _VECTORMATH_SHUF_ZCWD ); + tmp3 = spu_shuffle( quat1->vec128, quat3->vec128, _VECTORMATH_SHUF_ZCWD ); + result->x = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB ); + result->y = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD ); + result->z = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB ); + result->w = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_ZCWD ); +} + +static inline void vmathSoaQMakeIdentity( VmathSoaQuat *result ) +{ + vmathSoaQMakeFromElems( result, spu_splats(0.0f), spu_splats(0.0f), spu_splats(0.0f), spu_splats(1.0f) ); +} + +static inline void vmathSoaQLerp( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ) +{ + VmathSoaQuat tmpQ_0, tmpQ_1; + vmathSoaQSub( &tmpQ_0, quat1, quat0 ); + vmathSoaQScalarMul( &tmpQ_1, &tmpQ_0, t ); + vmathSoaQAdd( result, quat0, &tmpQ_1 ); +} + +static inline void vmathSoaQSlerp( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *unitQuat0, const VmathSoaQuat *unitQuat1 ) +{ + VmathSoaQuat start, tmpQ_0, tmpQ_1; + vec_float4 recipSinAngle, scale0, scale1, cosAngle, angle; + vec_uint4 selectMask; + cosAngle = vmathSoaQDot( unitQuat0, unitQuat1 ); + selectMask = (vec_uint4)spu_cmpgt( spu_splats(0.0f), cosAngle ); + cosAngle = spu_sel( cosAngle, negatef4( cosAngle ), selectMask ); + vmathSoaQSetX( &start, spu_sel( unitQuat0->x, negatef4( unitQuat0->x ), selectMask ) ); + vmathSoaQSetY( &start, spu_sel( unitQuat0->y, negatef4( unitQuat0->y ), selectMask ) ); + vmathSoaQSetZ( &start, spu_sel( unitQuat0->z, negatef4( unitQuat0->z ), selectMask ) ); + vmathSoaQSetW( &start, spu_sel( unitQuat0->w, negatef4( unitQuat0->w ), selectMask ) ); + selectMask = (vec_uint4)spu_cmpgt( spu_splats(_VECTORMATH_SLERP_TOL), cosAngle ); + angle = acosf4( cosAngle ); + recipSinAngle = recipf4( sinf4( angle ) ); + scale0 = spu_sel( spu_sub( spu_splats(1.0f), t ), spu_mul( sinf4( spu_mul( spu_sub( spu_splats(1.0f), t ), angle ) ), recipSinAngle ), selectMask ); + scale1 = spu_sel( t, spu_mul( sinf4( spu_mul( t, angle ) ), recipSinAngle ), selectMask ); + vmathSoaQScalarMul( &tmpQ_0, &start, scale0 ); + vmathSoaQScalarMul( &tmpQ_1, unitQuat1, scale1 ); + vmathSoaQAdd( result, &tmpQ_0, &tmpQ_1 ); +} + +static inline void vmathSoaQSquad( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *unitQuat0, const VmathSoaQuat *unitQuat1, const VmathSoaQuat *unitQuat2, const VmathSoaQuat *unitQuat3 ) +{ + VmathSoaQuat tmp0, tmp1; + vmathSoaQSlerp( &tmp0, t, unitQuat0, unitQuat3 ); + vmathSoaQSlerp( &tmp1, t, unitQuat1, unitQuat2 ); + vmathSoaQSlerp( result, spu_mul( spu_mul( spu_splats(2.0f), t ), spu_sub( spu_splats(1.0f), t ) ), &tmp0, &tmp1 ); +} + +static inline void vmathSoaQGet4Aos( const VmathSoaQuat *quat, VmathQuat *result0, VmathQuat *result1, VmathQuat *result2, VmathQuat *result3 ) +{ + vec_float4 tmp0, tmp1, tmp2, tmp3; + tmp0 = spu_shuffle( quat->x, quat->z, _VECTORMATH_SHUF_XAYB ); + tmp1 = spu_shuffle( quat->y, quat->w, _VECTORMATH_SHUF_XAYB ); + tmp2 = spu_shuffle( quat->x, quat->z, _VECTORMATH_SHUF_ZCWD ); + tmp3 = spu_shuffle( quat->y, quat->w, _VECTORMATH_SHUF_ZCWD ); + vmathQMakeFrom128( result0, spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB ) ); + vmathQMakeFrom128( result1, spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD ) ); + vmathQMakeFrom128( result2, spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB ) ); + vmathQMakeFrom128( result3, spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_ZCWD ) ); +} + +static inline void vmathSoaQSetXYZ( VmathSoaQuat *result, const VmathSoaVector3 *vec ) +{ + result->x = vec->x; + result->y = vec->y; + result->z = vec->z; +} + +static inline void vmathSoaQGetXYZ( VmathSoaVector3 *result, const VmathSoaQuat *quat ) +{ + vmathSoaV3MakeFromElems( result, quat->x, quat->y, quat->z ); +} + +static inline void vmathSoaQSetX( VmathSoaQuat *result, vec_float4 _x ) +{ + result->x = _x; +} + +static inline vec_float4 vmathSoaQGetX( const VmathSoaQuat *quat ) +{ + return quat->x; +} + +static inline void vmathSoaQSetY( VmathSoaQuat *result, vec_float4 _y ) +{ + result->y = _y; +} + +static inline vec_float4 vmathSoaQGetY( const VmathSoaQuat *quat ) +{ + return quat->y; +} + +static inline void vmathSoaQSetZ( VmathSoaQuat *result, vec_float4 _z ) +{ + result->z = _z; +} + +static inline vec_float4 vmathSoaQGetZ( const VmathSoaQuat *quat ) +{ + return quat->z; +} + +static inline void vmathSoaQSetW( VmathSoaQuat *result, vec_float4 _w ) +{ + result->w = _w; +} + +static inline vec_float4 vmathSoaQGetW( const VmathSoaQuat *quat ) +{ + return quat->w; +} + +static inline void vmathSoaQSetElem( VmathSoaQuat *result, int idx, vec_float4 value ) +{ + *(&result->x + idx) = value; +} + +static inline vec_float4 vmathSoaQGetElem( const VmathSoaQuat *quat, int idx ) +{ + return *(&quat->x + idx); +} + +static inline void vmathSoaQAdd( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ) +{ + result->x = spu_add( quat0->x, quat1->x ); + result->y = spu_add( quat0->y, quat1->y ); + result->z = spu_add( quat0->z, quat1->z ); + result->w = spu_add( quat0->w, quat1->w ); +} + +static inline void vmathSoaQSub( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ) +{ + result->x = spu_sub( quat0->x, quat1->x ); + result->y = spu_sub( quat0->y, quat1->y ); + result->z = spu_sub( quat0->z, quat1->z ); + result->w = spu_sub( quat0->w, quat1->w ); +} + +static inline void vmathSoaQScalarMul( VmathSoaQuat *result, const VmathSoaQuat *quat, vec_float4 scalar ) +{ + result->x = spu_mul( quat->x, scalar ); + result->y = spu_mul( quat->y, scalar ); + result->z = spu_mul( quat->z, scalar ); + result->w = spu_mul( quat->w, scalar ); +} + +static inline void vmathSoaQScalarDiv( VmathSoaQuat *result, const VmathSoaQuat *quat, vec_float4 scalar ) +{ + result->x = divf4( quat->x, scalar ); + result->y = divf4( quat->y, scalar ); + result->z = divf4( quat->z, scalar ); + result->w = divf4( quat->w, scalar ); +} + +static inline void vmathSoaQNeg( VmathSoaQuat *result, const VmathSoaQuat *quat ) +{ + result->x = negatef4( quat->x ); + result->y = negatef4( quat->y ); + result->z = negatef4( quat->z ); + result->w = negatef4( quat->w ); +} + +static inline vec_float4 vmathSoaQDot( const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ) +{ + vec_float4 result; + result = spu_mul( quat0->x, quat1->x ); + result = spu_add( result, spu_mul( quat0->y, quat1->y ) ); + result = spu_add( result, spu_mul( quat0->z, quat1->z ) ); + result = spu_add( result, spu_mul( quat0->w, quat1->w ) ); + return result; +} + +static inline vec_float4 vmathSoaQNorm( const VmathSoaQuat *quat ) +{ + vec_float4 result; + result = spu_mul( quat->x, quat->x ); + result = spu_add( result, spu_mul( quat->y, quat->y ) ); + result = spu_add( result, spu_mul( quat->z, quat->z ) ); + result = spu_add( result, spu_mul( quat->w, quat->w ) ); + return result; +} + +static inline vec_float4 vmathSoaQLength( const VmathSoaQuat *quat ) +{ + return sqrtf4( vmathSoaQNorm( quat ) ); +} + +static inline void vmathSoaQNormalize( VmathSoaQuat *result, const VmathSoaQuat *quat ) +{ + vec_float4 lenSqr, lenInv; + lenSqr = vmathSoaQNorm( quat ); + lenInv = rsqrtf4( lenSqr ); + result->x = spu_mul( quat->x, lenInv ); + result->y = spu_mul( quat->y, lenInv ); + result->z = spu_mul( quat->z, lenInv ); + result->w = spu_mul( quat->w, lenInv ); +} + +static inline void vmathSoaQMakeRotationArc( VmathSoaQuat *result, const VmathSoaVector3 *unitVec0, const VmathSoaVector3 *unitVec1 ) +{ + VmathSoaVector3 tmpV3_0, tmpV3_1; + vec_float4 cosHalfAngleX2, recipCosHalfAngleX2; + cosHalfAngleX2 = sqrtf4( spu_mul( spu_splats(2.0f), spu_add( spu_splats(1.0f), vmathSoaV3Dot( unitVec0, unitVec1 ) ) ) ); + recipCosHalfAngleX2 = recipf4( cosHalfAngleX2 ); + vmathSoaV3Cross( &tmpV3_0, unitVec0, unitVec1 ); + vmathSoaV3ScalarMul( &tmpV3_1, &tmpV3_0, recipCosHalfAngleX2 ); + vmathSoaQMakeFromV3Scalar( result, &tmpV3_1, spu_mul( cosHalfAngleX2, spu_splats(0.5f) ) ); +} + +static inline void vmathSoaQMakeRotationAxis( VmathSoaQuat *result, vec_float4 radians, const VmathSoaVector3 *unitVec ) +{ + VmathSoaVector3 tmpV3_0; + vec_float4 s, c, angle; + angle = spu_mul( radians, spu_splats(0.5f) ); + sincosf4( angle, &s, &c ); + vmathSoaV3ScalarMul( &tmpV3_0, unitVec, s ); + vmathSoaQMakeFromV3Scalar( result, &tmpV3_0, c ); +} + +static inline void vmathSoaQMakeRotationX( VmathSoaQuat *result, vec_float4 radians ) +{ + vec_float4 s, c, angle; + angle = spu_mul( radians, spu_splats(0.5f) ); + sincosf4( angle, &s, &c ); + vmathSoaQMakeFromElems( result, s, spu_splats(0.0f), spu_splats(0.0f), c ); +} + +static inline void vmathSoaQMakeRotationY( VmathSoaQuat *result, vec_float4 radians ) +{ + vec_float4 s, c, angle; + angle = spu_mul( radians, spu_splats(0.5f) ); + sincosf4( angle, &s, &c ); + vmathSoaQMakeFromElems( result, spu_splats(0.0f), s, spu_splats(0.0f), c ); +} + +static inline void vmathSoaQMakeRotationZ( VmathSoaQuat *result, vec_float4 radians ) +{ + vec_float4 s, c, angle; + angle = spu_mul( radians, spu_splats(0.5f) ); + sincosf4( angle, &s, &c ); + vmathSoaQMakeFromElems( result, spu_splats(0.0f), spu_splats(0.0f), s, c ); +} + +static inline void vmathSoaQMul( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ) +{ + vec_float4 tmpX, tmpY, tmpZ, tmpW; + tmpX = spu_sub( spu_add( spu_add( spu_mul( quat0->w, quat1->x ), spu_mul( quat0->x, quat1->w ) ), spu_mul( quat0->y, quat1->z ) ), spu_mul( quat0->z, quat1->y ) ); + tmpY = spu_sub( spu_add( spu_add( spu_mul( quat0->w, quat1->y ), spu_mul( quat0->y, quat1->w ) ), spu_mul( quat0->z, quat1->x ) ), spu_mul( quat0->x, quat1->z ) ); + tmpZ = spu_sub( spu_add( spu_add( spu_mul( quat0->w, quat1->z ), spu_mul( quat0->z, quat1->w ) ), spu_mul( quat0->x, quat1->y ) ), spu_mul( quat0->y, quat1->x ) ); + tmpW = spu_sub( spu_sub( spu_sub( spu_mul( quat0->w, quat1->w ), spu_mul( quat0->x, quat1->x ) ), spu_mul( quat0->y, quat1->y ) ), spu_mul( quat0->z, quat1->z ) ); + vmathSoaQMakeFromElems( result, tmpX, tmpY, tmpZ, tmpW ); +} + +static inline void vmathSoaQRotate( VmathSoaVector3 *result, const VmathSoaQuat *quat, const VmathSoaVector3 *vec ) +{ + vec_float4 tmpX, tmpY, tmpZ, tmpW; + tmpX = spu_sub( spu_add( spu_mul( quat->w, vec->x ), spu_mul( quat->y, vec->z ) ), spu_mul( quat->z, vec->y ) ); + tmpY = spu_sub( spu_add( spu_mul( quat->w, vec->y ), spu_mul( quat->z, vec->x ) ), spu_mul( quat->x, vec->z ) ); + tmpZ = spu_sub( spu_add( spu_mul( quat->w, vec->z ), spu_mul( quat->x, vec->y ) ), spu_mul( quat->y, vec->x ) ); + tmpW = spu_add( spu_add( spu_mul( quat->x, vec->x ), spu_mul( quat->y, vec->y ) ), spu_mul( quat->z, vec->z ) ); + result->x = spu_add( spu_sub( spu_add( spu_mul( tmpW, quat->x ), spu_mul( tmpX, quat->w ) ), spu_mul( tmpY, quat->z ) ), spu_mul( tmpZ, quat->y ) ); + result->y = spu_add( spu_sub( spu_add( spu_mul( tmpW, quat->y ), spu_mul( tmpY, quat->w ) ), spu_mul( tmpZ, quat->x ) ), spu_mul( tmpX, quat->z ) ); + result->z = spu_add( spu_sub( spu_add( spu_mul( tmpW, quat->z ), spu_mul( tmpZ, quat->w ) ), spu_mul( tmpX, quat->y ) ), spu_mul( tmpY, quat->x ) ); +} + +static inline void vmathSoaQConj( VmathSoaQuat *result, const VmathSoaQuat *quat ) +{ + vmathSoaQMakeFromElems( result, negatef4( quat->x ), negatef4( quat->y ), negatef4( quat->z ), quat->w ); +} + +static inline void vmathSoaQSelect( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1, vec_uint4 select1 ) +{ + result->x = spu_sel( quat0->x, quat1->x, select1 ); + result->y = spu_sel( quat0->y, quat1->y, select1 ); + result->z = spu_sel( quat0->z, quat1->z, select1 ); + result->w = spu_sel( quat0->w, quat1->w, select1 ); +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathSoaQPrint( const VmathSoaQuat *quat ) +{ + VmathQuat vec0, vec1, vec2, vec3; + vmathSoaQGet4Aos( quat, &vec0, &vec1, &vec2, &vec3 ); + printf("slot 0:\n"); + vmathQPrint( &vec0 ); + printf("slot 1:\n"); + vmathQPrint( &vec1 ); + printf("slot 2:\n"); + vmathQPrint( &vec2 ); + printf("slot 3:\n"); + vmathQPrint( &vec3 ); +} + +static inline void vmathSoaQPrints( const VmathSoaQuat *quat, const char *name ) +{ + VmathQuat vec0, vec1, vec2, vec3; + printf( "%s:\n", name ); + vmathSoaQGet4Aos( quat, &vec0, &vec1, &vec2, &vec3 ); + printf("slot 0:\n"); + vmathQPrint( &vec0 ); + printf("slot 1:\n"); + vmathQPrint( &vec1 ); + printf("slot 2:\n"); + vmathQPrint( &vec2 ); + printf("slot 3:\n"); + vmathQPrint( &vec3 ); +} + +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/vectormathlibrary/include/vectormath/spu/c/quat_soa_v.h b/vectormathlibrary/include/vectormath/spu/c/quat_soa_v.h new file mode 100644 index 000000000..601d9da92 --- /dev/null +++ b/vectormathlibrary/include/vectormath/spu/c/quat_soa_v.h @@ -0,0 +1,319 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_QUAT_SOA_V_C_H +#define _VECTORMATH_QUAT_SOA_V_C_H +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/*----------------------------------------------------------------------------- + * Definitions + */ +#ifndef _VECTORMATH_INTERNAL_FUNCTIONS +#define _VECTORMATH_INTERNAL_FUNCTIONS + +#endif + +static inline VmathSoaQuat vmathSoaQMakeFromElems_V( vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w ) +{ + VmathSoaQuat result; + vmathSoaQMakeFromElems(&result, _x, _y, _z, _w); + return result; +} + +static inline VmathSoaQuat vmathSoaQMakeFromV3Scalar_V( VmathSoaVector3 xyz, vec_float4 _w ) +{ + VmathSoaQuat result; + vmathSoaQMakeFromV3Scalar(&result, &xyz, _w); + return result; +} + +static inline VmathSoaQuat vmathSoaQMakeFromV4_V( VmathSoaVector4 vec ) +{ + VmathSoaQuat result; + vmathSoaQMakeFromV4(&result, &vec); + return result; +} + +static inline VmathSoaQuat vmathSoaQMakeFromScalar_V( vec_float4 scalar ) +{ + VmathSoaQuat result; + vmathSoaQMakeFromScalar(&result, scalar); + return result; +} + +static inline VmathSoaQuat vmathSoaQMakeFromAos_V( VmathQuat quat ) +{ + VmathSoaQuat result; + vmathSoaQMakeFromAos(&result, &quat); + return result; +} + +static inline VmathSoaQuat vmathSoaQMakeFrom4Aos_V( VmathQuat quat0, VmathQuat quat1, VmathQuat quat2, VmathQuat quat3 ) +{ + VmathSoaQuat result; + vmathSoaQMakeFrom4Aos(&result, &quat0, &quat1, &quat2, &quat3); + return result; +} + +static inline VmathSoaQuat vmathSoaQMakeIdentity_V( ) +{ + VmathSoaQuat result; + vmathSoaQMakeIdentity(&result); + return result; +} + +static inline VmathSoaQuat vmathSoaQLerp_V( vec_float4 t, VmathSoaQuat quat0, VmathSoaQuat quat1 ) +{ + VmathSoaQuat result; + vmathSoaQLerp(&result, t, &quat0, &quat1); + return result; +} + +static inline VmathSoaQuat vmathSoaQSlerp_V( vec_float4 t, VmathSoaQuat unitQuat0, VmathSoaQuat unitQuat1 ) +{ + VmathSoaQuat result; + vmathSoaQSlerp(&result, t, &unitQuat0, &unitQuat1); + return result; +} + +static inline VmathSoaQuat vmathSoaQSquad_V( vec_float4 t, VmathSoaQuat unitQuat0, VmathSoaQuat unitQuat1, VmathSoaQuat unitQuat2, VmathSoaQuat unitQuat3 ) +{ + VmathSoaQuat result; + vmathSoaQSquad(&result, t, &unitQuat0, &unitQuat1, &unitQuat2, &unitQuat3); + return result; +} + +static inline void vmathSoaQGet4Aos_V( VmathSoaQuat quat, VmathQuat *result0, VmathQuat *result1, VmathQuat *result2, VmathQuat *result3 ) +{ + vmathSoaQGet4Aos(&quat, result0, result1, result2, result3); +} + +static inline void vmathSoaQSetXYZ_V( VmathSoaQuat *result, VmathSoaVector3 vec ) +{ + vmathSoaQSetXYZ(result, &vec); +} + +static inline VmathSoaVector3 vmathSoaQGetXYZ_V( VmathSoaQuat quat ) +{ + VmathSoaVector3 result; + vmathSoaQGetXYZ(&result, &quat); + return result; +} + +static inline void vmathSoaQSetX_V( VmathSoaQuat *result, vec_float4 _x ) +{ + vmathSoaQSetX(result, _x); +} + +static inline vec_float4 vmathSoaQGetX_V( VmathSoaQuat quat ) +{ + return vmathSoaQGetX(&quat); +} + +static inline void vmathSoaQSetY_V( VmathSoaQuat *result, vec_float4 _y ) +{ + vmathSoaQSetY(result, _y); +} + +static inline vec_float4 vmathSoaQGetY_V( VmathSoaQuat quat ) +{ + return vmathSoaQGetY(&quat); +} + +static inline void vmathSoaQSetZ_V( VmathSoaQuat *result, vec_float4 _z ) +{ + vmathSoaQSetZ(result, _z); +} + +static inline vec_float4 vmathSoaQGetZ_V( VmathSoaQuat quat ) +{ + return vmathSoaQGetZ(&quat); +} + +static inline void vmathSoaQSetW_V( VmathSoaQuat *result, vec_float4 _w ) +{ + vmathSoaQSetW(result, _w); +} + +static inline vec_float4 vmathSoaQGetW_V( VmathSoaQuat quat ) +{ + return vmathSoaQGetW(&quat); +} + +static inline void vmathSoaQSetElem_V( VmathSoaQuat *result, int idx, vec_float4 value ) +{ + vmathSoaQSetElem(result, idx, value); +} + +static inline vec_float4 vmathSoaQGetElem_V( VmathSoaQuat quat, int idx ) +{ + return vmathSoaQGetElem(&quat, idx); +} + +static inline VmathSoaQuat vmathSoaQAdd_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ) +{ + VmathSoaQuat result; + vmathSoaQAdd(&result, &quat0, &quat1); + return result; +} + +static inline VmathSoaQuat vmathSoaQSub_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ) +{ + VmathSoaQuat result; + vmathSoaQSub(&result, &quat0, &quat1); + return result; +} + +static inline VmathSoaQuat vmathSoaQScalarMul_V( VmathSoaQuat quat, vec_float4 scalar ) +{ + VmathSoaQuat result; + vmathSoaQScalarMul(&result, &quat, scalar); + return result; +} + +static inline VmathSoaQuat vmathSoaQScalarDiv_V( VmathSoaQuat quat, vec_float4 scalar ) +{ + VmathSoaQuat result; + vmathSoaQScalarDiv(&result, &quat, scalar); + return result; +} + +static inline VmathSoaQuat vmathSoaQNeg_V( VmathSoaQuat quat ) +{ + VmathSoaQuat result; + vmathSoaQNeg(&result, &quat); + return result; +} + +static inline vec_float4 vmathSoaQDot_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ) +{ + return vmathSoaQDot(&quat0, &quat1); +} + +static inline vec_float4 vmathSoaQNorm_V( VmathSoaQuat quat ) +{ + return vmathSoaQNorm(&quat); +} + +static inline vec_float4 vmathSoaQLength_V( VmathSoaQuat quat ) +{ + return vmathSoaQLength(&quat); +} + +static inline VmathSoaQuat vmathSoaQNormalize_V( VmathSoaQuat quat ) +{ + VmathSoaQuat result; + vmathSoaQNormalize(&result, &quat); + return result; +} + +static inline VmathSoaQuat vmathSoaQMakeRotationArc_V( VmathSoaVector3 unitVec0, VmathSoaVector3 unitVec1 ) +{ + VmathSoaQuat result; + vmathSoaQMakeRotationArc(&result, &unitVec0, &unitVec1); + return result; +} + +static inline VmathSoaQuat vmathSoaQMakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec ) +{ + VmathSoaQuat result; + vmathSoaQMakeRotationAxis(&result, radians, &unitVec); + return result; +} + +static inline VmathSoaQuat vmathSoaQMakeRotationX_V( vec_float4 radians ) +{ + VmathSoaQuat result; + vmathSoaQMakeRotationX(&result, radians); + return result; +} + +static inline VmathSoaQuat vmathSoaQMakeRotationY_V( vec_float4 radians ) +{ + VmathSoaQuat result; + vmathSoaQMakeRotationY(&result, radians); + return result; +} + +static inline VmathSoaQuat vmathSoaQMakeRotationZ_V( vec_float4 radians ) +{ + VmathSoaQuat result; + vmathSoaQMakeRotationZ(&result, radians); + return result; +} + +static inline VmathSoaQuat vmathSoaQMul_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ) +{ + VmathSoaQuat result; + vmathSoaQMul(&result, &quat0, &quat1); + return result; +} + +static inline VmathSoaVector3 vmathSoaQRotate_V( VmathSoaQuat quat, VmathSoaVector3 vec ) +{ + VmathSoaVector3 result; + vmathSoaQRotate(&result, &quat, &vec); + return result; +} + +static inline VmathSoaQuat vmathSoaQConj_V( VmathSoaQuat quat ) +{ + VmathSoaQuat result; + vmathSoaQConj(&result, &quat); + return result; +} + +static inline VmathSoaQuat vmathSoaQSelect_V( VmathSoaQuat quat0, VmathSoaQuat quat1, vec_uint4 select1 ) +{ + VmathSoaQuat result; + vmathSoaQSelect(&result, &quat0, &quat1, select1); + return result; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathSoaQPrint_V( VmathSoaQuat quat ) +{ + vmathSoaQPrint(&quat); +} + +static inline void vmathSoaQPrints_V( VmathSoaQuat quat, const char *name ) +{ + vmathSoaQPrints(&quat, name); +} + +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/vectormathlibrary/include/vectormath/spu/c/vec_aos.h b/vectormathlibrary/include/vectormath/spu/c/vec_aos.h new file mode 100644 index 000000000..715f27df7 --- /dev/null +++ b/vectormathlibrary/include/vectormath/spu/c/vec_aos.h @@ -0,0 +1,1029 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_VEC_AOS_C_H +#define _VECTORMATH_VEC_AOS_C_H +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/*----------------------------------------------------------------------------- + * Constants + * for shuffles, words are labeled [x,y,z,w] [a,b,c,d] + */ +#define _VECTORMATH_SHUF_X 0x00010203 +#define _VECTORMATH_SHUF_Y 0x04050607 +#define _VECTORMATH_SHUF_Z 0x08090a0b +#define _VECTORMATH_SHUF_W 0x0c0d0e0f +#define _VECTORMATH_SHUF_A 0x10111213 +#define _VECTORMATH_SHUF_B 0x14151617 +#define _VECTORMATH_SHUF_C 0x18191a1b +#define _VECTORMATH_SHUF_D 0x1c1d1e1f +#define _VECTORMATH_SHUF_0 0x80808080 +#define _VECTORMATH_SHUF_XYZA (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_A } +#define _VECTORMATH_SHUF_ZXYW (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_W } +#define _VECTORMATH_SHUF_YZXW (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_W } +#define _VECTORMATH_SHUF_WABC (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_C } +#define _VECTORMATH_SHUF_ZWAB (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_B } +#define _VECTORMATH_SHUF_XYZA (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_A } +#define _VECTORMATH_SHUF_YZAB (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_B } +#define _VECTORMATH_SHUF_ZABC (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_C } +#define _VECTORMATH_UNIT_1000 (vec_float4){ 1.0f, 0.0f, 0.0f, 0.0f } +#define _VECTORMATH_UNIT_0100 (vec_float4){ 0.0f, 1.0f, 0.0f, 0.0f } +#define _VECTORMATH_UNIT_0010 (vec_float4){ 0.0f, 0.0f, 1.0f, 0.0f } +#define _VECTORMATH_UNIT_0001 (vec_float4){ 0.0f, 0.0f, 0.0f, 1.0f } +#define _VECTORMATH_SLERP_TOL 0.999f + +/*----------------------------------------------------------------------------- + * Definitions + */ +#ifndef _VECTORMATH_INTERNAL_FUNCTIONS +#define _VECTORMATH_INTERNAL_FUNCTIONS + +static inline vec_float4 _vmathVfDot3( vec_float4 vec0, vec_float4 vec1 ) +{ + vec_float4 result; + result = spu_mul( vec0, vec1 ); + result = spu_madd( spu_rlqwbyte( vec0, 4 ), spu_rlqwbyte( vec1, 4 ), result ); + return spu_madd( spu_rlqwbyte( vec0, 8 ), spu_rlqwbyte( vec1, 8 ), result ); +} + +static inline vec_float4 _vmathVfDot4( vec_float4 vec0, vec_float4 vec1 ) +{ + vec_float4 result; + result = spu_mul( vec0, vec1 ); + result = spu_madd( spu_rlqwbyte( vec0, 4 ), spu_rlqwbyte( vec1, 4 ), result ); + return spu_add( spu_rlqwbyte( result, 8 ), result ); +} + +static inline vec_float4 _vmathVfCross( vec_float4 vec0, vec_float4 vec1 ) +{ + vec_float4 tmp0, tmp1, tmp2, tmp3, result; + tmp0 = spu_shuffle( vec0, vec0, _VECTORMATH_SHUF_YZXW ); + tmp1 = spu_shuffle( vec1, vec1, _VECTORMATH_SHUF_ZXYW ); + tmp2 = spu_shuffle( vec0, vec0, _VECTORMATH_SHUF_ZXYW ); + tmp3 = spu_shuffle( vec1, vec1, _VECTORMATH_SHUF_YZXW ); + result = spu_mul( tmp0, tmp1 ); + result = spu_nmsub( tmp2, tmp3, result ); + return result; +} + +static inline vec_uint4 _vmathVfToHalfFloatsUnpacked(vec_float4 v) +{ + vec_int4 bexp; + vec_uint4 mant, sign, hfloat; + vec_uint4 notZero, isInf; + const vec_uint4 hfloatInf = spu_splats(0x00007c00u); + const vec_uint4 mergeMant = spu_splats(0x000003ffu); + const vec_uint4 mergeSign = spu_splats(0x00008000u); + + sign = spu_rlmask((vec_uint4)v, -16); + mant = spu_rlmask((vec_uint4)v, -13); + bexp = spu_and(spu_rlmask((vec_int4)v, -23), 0xff); + + notZero = spu_cmpgt(bexp, 112); + isInf = spu_cmpgt(bexp, 142); + + bexp = spu_add(bexp, -112); + bexp = spu_sl(bexp, 10); + + hfloat = spu_sel((vec_uint4)bexp, mant, mergeMant); + hfloat = spu_sel(spu_splats(0u), hfloat, notZero); + hfloat = spu_sel(hfloat, hfloatInf, isInf); + hfloat = spu_sel(hfloat, sign, mergeSign); + + return hfloat; +} + +static inline vec_ushort8 _vmath2VfToHalfFloats(vec_float4 u, vec_float4 v) +{ + vec_uint4 hfloat_u, hfloat_v; + const vec_uchar16 pack = (vec_uchar16){2,3,6,7,10,11,14,15,18,19,22,23,26,27,30,31}; + hfloat_u = _vmathVfToHalfFloatsUnpacked(u); + hfloat_v = _vmathVfToHalfFloatsUnpacked(v); + return (vec_ushort8)spu_shuffle(hfloat_u, hfloat_v, pack); +} + +#endif + +static inline void vmathV3Copy( VmathVector3 *result, const VmathVector3 *vec ) +{ + result->vec128 = vec->vec128; +} + +static inline void vmathV3MakeFromElems( VmathVector3 *result, float _x, float _y, float _z ) +{ + result->vec128 = (vec_float4){ _x, _y, _z, 0.0f }; +} + +static inline void vmathV3MakeFromP3( VmathVector3 *result, const VmathPoint3 *pnt ) +{ + result->vec128 = pnt->vec128; +} + +static inline void vmathV3MakeFromScalar( VmathVector3 *result, float scalar ) +{ + result->vec128 = spu_splats( scalar ); +} + +static inline void vmathV3MakeFrom128( VmathVector3 *result, vec_float4 vf4 ) +{ + result->vec128 = vf4; +} + +static inline void vmathV3MakeXAxis( VmathVector3 *result ) +{ + result->vec128 = _VECTORMATH_UNIT_1000; +} + +static inline void vmathV3MakeYAxis( VmathVector3 *result ) +{ + result->vec128 = _VECTORMATH_UNIT_0100; +} + +static inline void vmathV3MakeZAxis( VmathVector3 *result ) +{ + result->vec128 = _VECTORMATH_UNIT_0010; +} + +static inline void vmathV3Lerp( VmathVector3 *result, float t, const VmathVector3 *vec0, const VmathVector3 *vec1 ) +{ + VmathVector3 tmpV3_0, tmpV3_1; + vmathV3Sub( &tmpV3_0, vec1, vec0 ); + vmathV3ScalarMul( &tmpV3_1, &tmpV3_0, t ); + vmathV3Add( result, vec0, &tmpV3_1 ); +} + +static inline void vmathV3Slerp( VmathVector3 *result, float t, const VmathVector3 *unitVec0, const VmathVector3 *unitVec1 ) +{ + vec_float4 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines; + vec_uint4 selectMask; + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); + cosAngle = _vmathVfDot3( unitVec0->vec128, unitVec1->vec128 ); + cosAngle = spu_shuffle( cosAngle, cosAngle, shuffle_xxxx ); + selectMask = (vec_uint4)spu_cmpgt( spu_splats(_VECTORMATH_SLERP_TOL), cosAngle ); + angle = acosf4( cosAngle ); + tttt = spu_splats(t); + oneMinusT = spu_sub( spu_splats(1.0f), tttt ); + angles = spu_sel( spu_splats(1.0f), oneMinusT, (vec_uint4)spu_maskb(0x0f00) ); + angles = spu_sel( angles, tttt, (vec_uint4)spu_maskb(0x00f0) ); + angles = spu_mul( angles, angle ); + sines = sinf4( angles ); + scales = divf4( sines, spu_shuffle( sines, sines, shuffle_xxxx ) ); + scale0 = spu_sel( oneMinusT, spu_shuffle( scales, scales, shuffle_yyyy ), selectMask ); + scale1 = spu_sel( tttt, spu_shuffle( scales, scales, shuffle_zzzz ), selectMask ); + result->vec128 = spu_madd( unitVec0->vec128, scale0, spu_mul( unitVec1->vec128, scale1 ) ); +} + +static inline vec_float4 vmathV3Get128( const VmathVector3 *vec ) +{ + return vec->vec128; +} + +static inline void vmathV3StoreXYZ( const VmathVector3 *vec, vec_float4 *quad ) +{ + vec_float4 dstVec = *quad; + vec_uint4 mask = (vec_uint4)spu_maskb(0x000f); + dstVec = spu_sel(vec->vec128, dstVec, mask); + *quad = dstVec; +} + +static inline void vmathV3LoadXYZArray( VmathVector3 *vec0, VmathVector3 *vec1, VmathVector3 *vec2, VmathVector3 *vec3, const vec_float4 *threeQuads ) +{ + vec_float4 xyzx, yzxy, zxyz, xyz1, xyz2, xyz3; + xyzx = threeQuads[0]; + yzxy = threeQuads[1]; + zxyz = threeQuads[2]; + xyz1 = spu_shuffle( xyzx, yzxy, _VECTORMATH_SHUF_WABC ); + xyz2 = spu_shuffle( yzxy, zxyz, _VECTORMATH_SHUF_ZWAB ); + xyz3 = spu_rlqwbyte( zxyz, 4 ); + vec0->vec128 = xyzx; + vec1->vec128 = xyz1; + vec2->vec128 = xyz2; + vec3->vec128 = xyz3; +} + +static inline void vmathV3StoreXYZArray( const VmathVector3 *vec0, const VmathVector3 *vec1, const VmathVector3 *vec2, const VmathVector3 *vec3, vec_float4 *threeQuads ) +{ + vec_float4 xyzx, yzxy, zxyz; + xyzx = spu_shuffle( vec0->vec128, vec1->vec128, _VECTORMATH_SHUF_XYZA ); + yzxy = spu_shuffle( vec1->vec128, vec2->vec128, _VECTORMATH_SHUF_YZAB ); + zxyz = spu_shuffle( vec2->vec128, vec3->vec128, _VECTORMATH_SHUF_ZABC ); + threeQuads[0] = xyzx; + threeQuads[1] = yzxy; + threeQuads[2] = zxyz; +} + +static inline void vmathV3StoreHalfFloats( const VmathVector3 *vec0, const VmathVector3 *vec1, const VmathVector3 *vec2, const VmathVector3 *vec3, const VmathVector3 *vec4, const VmathVector3 *vec5, const VmathVector3 *vec6, const VmathVector3 *vec7, vec_ushort8 *threeQuads ) +{ + vec_float4 xyz0[3]; + vec_float4 xyz1[3]; + vmathV3StoreXYZArray( vec0, vec1, vec2, vec3, xyz0 ); + vmathV3StoreXYZArray( vec4, vec5, vec6, vec7, xyz1 ); + threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); + threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); + threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); +} + +static inline void vmathV3SetX( VmathVector3 *result, float _x ) +{ + result->vec128 = spu_insert( _x, result->vec128, 0 ); +} + +static inline float vmathV3GetX( const VmathVector3 *vec ) +{ + return spu_extract( vec->vec128, 0 ); +} + +static inline void vmathV3SetY( VmathVector3 *result, float _y ) +{ + result->vec128 = spu_insert( _y, result->vec128, 1 ); +} + +static inline float vmathV3GetY( const VmathVector3 *vec ) +{ + return spu_extract( vec->vec128, 1 ); +} + +static inline void vmathV3SetZ( VmathVector3 *result, float _z ) +{ + result->vec128 = spu_insert( _z, result->vec128, 2 ); +} + +static inline float vmathV3GetZ( const VmathVector3 *vec ) +{ + return spu_extract( vec->vec128, 2 ); +} + +static inline void vmathV3SetElem( VmathVector3 *result, int idx, float value ) +{ + result->vec128 = spu_insert( value, result->vec128, idx ); +} + +static inline float vmathV3GetElem( const VmathVector3 *vec, int idx ) +{ + return spu_extract( vec->vec128, idx ); +} + +static inline void vmathV3Add( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) +{ + result->vec128 = spu_add( vec0->vec128, vec1->vec128 ); +} + +static inline void vmathV3Sub( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) +{ + result->vec128 = spu_sub( vec0->vec128, vec1->vec128 ); +} + +static inline void vmathV3AddP3( VmathPoint3 *result, const VmathVector3 *vec, const VmathPoint3 *pnt1 ) +{ + result->vec128 = spu_add( vec->vec128, pnt1->vec128 ); +} + +static inline void vmathV3ScalarMul( VmathVector3 *result, const VmathVector3 *vec, float scalar ) +{ + result->vec128 = spu_mul( vec->vec128, spu_splats(scalar) ); +} + +static inline void vmathV3ScalarDiv( VmathVector3 *result, const VmathVector3 *vec, float scalar ) +{ + result->vec128 = divf4( vec->vec128, spu_splats(scalar) ); +} + +static inline void vmathV3Neg( VmathVector3 *result, const VmathVector3 *vec ) +{ + result->vec128 = negatef4( vec->vec128 ); +} + +static inline void vmathV3MulPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) +{ + result->vec128 = spu_mul( vec0->vec128, vec1->vec128 ); +} + +static inline void vmathV3DivPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) +{ + result->vec128 = divf4( vec0->vec128, vec1->vec128 ); +} + +static inline void vmathV3RecipPerElem( VmathVector3 *result, const VmathVector3 *vec ) +{ + result->vec128 = recipf4( vec->vec128 ); +} + +static inline void vmathV3SqrtPerElem( VmathVector3 *result, const VmathVector3 *vec ) +{ + result->vec128 = sqrtf4( vec->vec128 ); +} + +static inline void vmathV3RsqrtPerElem( VmathVector3 *result, const VmathVector3 *vec ) +{ + result->vec128 = rsqrtf4( vec->vec128 ); +} + +static inline void vmathV3AbsPerElem( VmathVector3 *result, const VmathVector3 *vec ) +{ + result->vec128 = fabsf4( vec->vec128 ); +} + +static inline void vmathV3CopySignPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) +{ + result->vec128 = copysignf4( vec0->vec128, vec1->vec128 ); +} + +static inline void vmathV3MaxPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) +{ + result->vec128 = fmaxf4( vec0->vec128, vec1->vec128 ); +} + +static inline float vmathV3MaxElem( const VmathVector3 *vec ) +{ + vec_float4 result; + result = fmaxf4( spu_promote( spu_extract( vec->vec128, 1 ), 0 ), vec->vec128 ); + result = fmaxf4( spu_promote( spu_extract( vec->vec128, 2 ), 0 ), result ); + return spu_extract( result, 0 ); +} + +static inline void vmathV3MinPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) +{ + result->vec128 = fminf4( vec0->vec128, vec1->vec128 ); +} + +static inline float vmathV3MinElem( const VmathVector3 *vec ) +{ + vec_float4 result; + result = fminf4( spu_promote( spu_extract( vec->vec128, 1 ), 0 ), vec->vec128 ); + result = fminf4( spu_promote( spu_extract( vec->vec128, 2 ), 0 ), result ); + return spu_extract( result, 0 ); +} + +static inline float vmathV3Sum( const VmathVector3 *vec ) +{ + return + spu_extract( vec->vec128, 0 ) + + spu_extract( vec->vec128, 1 ) + + spu_extract( vec->vec128, 2 ); +} + +static inline float vmathV3Dot( const VmathVector3 *vec0, const VmathVector3 *vec1 ) +{ + return spu_extract( _vmathVfDot3( vec0->vec128, vec1->vec128 ), 0 ); +} + +static inline float vmathV3LengthSqr( const VmathVector3 *vec ) +{ + return spu_extract( _vmathVfDot3( vec->vec128, vec->vec128 ), 0 ); +} + +static inline float vmathV3Length( const VmathVector3 *vec ) +{ + return sqrtf( vmathV3LengthSqr( vec ) ); +} + +static inline void vmathV3Normalize( VmathVector3 *result, const VmathVector3 *vec ) +{ + vec_float4 dot = _vmathVfDot3( vec->vec128, vec->vec128 ); + dot = spu_shuffle( dot, dot, (vec_uchar16)spu_splats(0x00010203) ); + result->vec128 = spu_mul( vec->vec128, rsqrtf4( dot ) ); +} + +static inline void vmathV3Cross( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) +{ + result->vec128 = _vmathVfCross( vec0->vec128, vec1->vec128 ); +} + +static inline void vmathV3Select( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1, unsigned int select1 ) +{ + result->vec128 = spu_sel( vec0->vec128, vec1->vec128, spu_splats( (unsigned int)-(select1 > 0) ) ); +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathV3Print( const VmathVector3 *vec ) +{ + union { vec_float4 v; float s[4]; } tmp; + tmp.v = vec->vec128; + printf( "( %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2] ); +} + +static inline void vmathV3Prints( const VmathVector3 *vec, const char *name ) +{ + union { vec_float4 v; float s[4]; } tmp; + tmp.v = vec->vec128; + printf( "%s: ( %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2] ); +} + +#endif + +static inline void vmathV4Copy( VmathVector4 *result, const VmathVector4 *vec ) +{ + result->vec128 = vec->vec128; +} + +static inline void vmathV4MakeFromElems( VmathVector4 *result, float _x, float _y, float _z, float _w ) +{ + result->vec128 = (vec_float4){ _x, _y, _z, _w }; +} + +static inline void vmathV4MakeFromV3Scalar( VmathVector4 *result, const VmathVector3 *xyz, float _w ) +{ + result->vec128 = spu_shuffle( xyz->vec128, spu_promote( _w, 0 ), _VECTORMATH_SHUF_XYZA ); +} + +static inline void vmathV4MakeFromV3( VmathVector4 *result, const VmathVector3 *vec ) +{ + result->vec128 = spu_sel( vec->vec128, spu_splats(0.0f), (vec_uint4)spu_maskb(0x000f) ); +} + +static inline void vmathV4MakeFromP3( VmathVector4 *result, const VmathPoint3 *pnt ) +{ + result->vec128 = spu_sel( pnt->vec128, spu_splats(1.0f), (vec_uint4)spu_maskb(0x000f) ); +} + +static inline void vmathV4MakeFromQ( VmathVector4 *result, const VmathQuat *quat ) +{ + result->vec128 = quat->vec128; +} + +static inline void vmathV4MakeFromScalar( VmathVector4 *result, float scalar ) +{ + result->vec128 = spu_splats( scalar ); +} + +static inline void vmathV4MakeFrom128( VmathVector4 *result, vec_float4 vf4 ) +{ + result->vec128 = vf4; +} + +static inline void vmathV4MakeXAxis( VmathVector4 *result ) +{ + result->vec128 = _VECTORMATH_UNIT_1000; +} + +static inline void vmathV4MakeYAxis( VmathVector4 *result ) +{ + result->vec128 = _VECTORMATH_UNIT_0100; +} + +static inline void vmathV4MakeZAxis( VmathVector4 *result ) +{ + result->vec128 = _VECTORMATH_UNIT_0010; +} + +static inline void vmathV4MakeWAxis( VmathVector4 *result ) +{ + result->vec128 = _VECTORMATH_UNIT_0001; +} + +static inline void vmathV4Lerp( VmathVector4 *result, float t, const VmathVector4 *vec0, const VmathVector4 *vec1 ) +{ + VmathVector4 tmpV4_0, tmpV4_1; + vmathV4Sub( &tmpV4_0, vec1, vec0 ); + vmathV4ScalarMul( &tmpV4_1, &tmpV4_0, t ); + vmathV4Add( result, vec0, &tmpV4_1 ); +} + +static inline void vmathV4Slerp( VmathVector4 *result, float t, const VmathVector4 *unitVec0, const VmathVector4 *unitVec1 ) +{ + vec_float4 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines; + vec_uint4 selectMask; + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); + cosAngle = _vmathVfDot4( unitVec0->vec128, unitVec1->vec128 ); + cosAngle = spu_shuffle( cosAngle, cosAngle, shuffle_xxxx ); + selectMask = (vec_uint4)spu_cmpgt( spu_splats(_VECTORMATH_SLERP_TOL), cosAngle ); + angle = acosf4( cosAngle ); + tttt = spu_splats(t); + oneMinusT = spu_sub( spu_splats(1.0f), tttt ); + angles = spu_sel( spu_splats(1.0f), oneMinusT, (vec_uint4)spu_maskb(0x0f00) ); + angles = spu_sel( angles, tttt, (vec_uint4)spu_maskb(0x00f0) ); + angles = spu_mul( angles, angle ); + sines = sinf4( angles ); + scales = divf4( sines, spu_shuffle( sines, sines, shuffle_xxxx ) ); + scale0 = spu_sel( oneMinusT, spu_shuffle( scales, scales, shuffle_yyyy ), selectMask ); + scale1 = spu_sel( tttt, spu_shuffle( scales, scales, shuffle_zzzz ), selectMask ); + result->vec128 = spu_madd( unitVec0->vec128, scale0, spu_mul( unitVec1->vec128, scale1 ) ); +} + +static inline vec_float4 vmathV4Get128( const VmathVector4 *vec ) +{ + return vec->vec128; +} + +static inline void vmathV4StoreHalfFloats( const VmathVector4 *vec0, const VmathVector4 *vec1, const VmathVector4 *vec2, const VmathVector4 *vec3, vec_ushort8 *twoQuads ) +{ + twoQuads[0] = _vmath2VfToHalfFloats(vec0->vec128, vec1->vec128); + twoQuads[1] = _vmath2VfToHalfFloats(vec2->vec128, vec3->vec128); +} + +static inline void vmathV4SetXYZ( VmathVector4 *result, const VmathVector3 *vec ) +{ + result->vec128 = spu_sel( vec->vec128, result->vec128, (vec_uint4)spu_maskb(0x000f) ); +} + +static inline void vmathV4GetXYZ( VmathVector3 *result, const VmathVector4 *vec ) +{ + result->vec128 = vec->vec128; +} + +static inline void vmathV4SetX( VmathVector4 *result, float _x ) +{ + result->vec128 = spu_insert( _x, result->vec128, 0 ); +} + +static inline float vmathV4GetX( const VmathVector4 *vec ) +{ + return spu_extract( vec->vec128, 0 ); +} + +static inline void vmathV4SetY( VmathVector4 *result, float _y ) +{ + result->vec128 = spu_insert( _y, result->vec128, 1 ); +} + +static inline float vmathV4GetY( const VmathVector4 *vec ) +{ + return spu_extract( vec->vec128, 1 ); +} + +static inline void vmathV4SetZ( VmathVector4 *result, float _z ) +{ + result->vec128 = spu_insert( _z, result->vec128, 2 ); +} + +static inline float vmathV4GetZ( const VmathVector4 *vec ) +{ + return spu_extract( vec->vec128, 2 ); +} + +static inline void vmathV4SetW( VmathVector4 *result, float _w ) +{ + result->vec128 = spu_insert( _w, result->vec128, 3 ); +} + +static inline float vmathV4GetW( const VmathVector4 *vec ) +{ + return spu_extract( vec->vec128, 3 ); +} + +static inline void vmathV4SetElem( VmathVector4 *result, int idx, float value ) +{ + result->vec128 = spu_insert( value, result->vec128, idx ); +} + +static inline float vmathV4GetElem( const VmathVector4 *vec, int idx ) +{ + return spu_extract( vec->vec128, idx ); +} + +static inline void vmathV4Add( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) +{ + result->vec128 = spu_add( vec0->vec128, vec1->vec128 ); +} + +static inline void vmathV4Sub( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) +{ + result->vec128 = spu_sub( vec0->vec128, vec1->vec128 ); +} + +static inline void vmathV4ScalarMul( VmathVector4 *result, const VmathVector4 *vec, float scalar ) +{ + result->vec128 = spu_mul( vec->vec128, spu_splats(scalar) ); +} + +static inline void vmathV4ScalarDiv( VmathVector4 *result, const VmathVector4 *vec, float scalar ) +{ + result->vec128 = divf4( vec->vec128, spu_splats(scalar) ); +} + +static inline void vmathV4Neg( VmathVector4 *result, const VmathVector4 *vec ) +{ + result->vec128 = negatef4( vec->vec128 ); +} + +static inline void vmathV4MulPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) +{ + result->vec128 = spu_mul( vec0->vec128, vec1->vec128 ); +} + +static inline void vmathV4DivPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) +{ + result->vec128 = divf4( vec0->vec128, vec1->vec128 ); +} + +static inline void vmathV4RecipPerElem( VmathVector4 *result, const VmathVector4 *vec ) +{ + result->vec128 = recipf4( vec->vec128 ); +} + +static inline void vmathV4SqrtPerElem( VmathVector4 *result, const VmathVector4 *vec ) +{ + result->vec128 = sqrtf4( vec->vec128 ); +} + +static inline void vmathV4RsqrtPerElem( VmathVector4 *result, const VmathVector4 *vec ) +{ + result->vec128 = rsqrtf4( vec->vec128 ); +} + +static inline void vmathV4AbsPerElem( VmathVector4 *result, const VmathVector4 *vec ) +{ + result->vec128 = fabsf4( vec->vec128 ); +} + +static inline void vmathV4CopySignPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) +{ + result->vec128 = copysignf4( vec0->vec128, vec1->vec128 ); +} + +static inline void vmathV4MaxPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) +{ + result->vec128 = fmaxf4( vec0->vec128, vec1->vec128 ); +} + +static inline float vmathV4MaxElem( const VmathVector4 *vec ) +{ + vec_float4 result; + result = fmaxf4( spu_promote( spu_extract( vec->vec128, 1 ), 0 ), vec->vec128 ); + result = fmaxf4( spu_promote( spu_extract( vec->vec128, 2 ), 0 ), result ); + result = fmaxf4( spu_promote( spu_extract( vec->vec128, 3 ), 0 ), result ); + return spu_extract( result, 0 ); +} + +static inline void vmathV4MinPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) +{ + result->vec128 = fminf4( vec0->vec128, vec1->vec128 ); +} + +static inline float vmathV4MinElem( const VmathVector4 *vec ) +{ + vec_float4 result; + result = fminf4( spu_promote( spu_extract( vec->vec128, 1 ), 0 ), vec->vec128 ); + result = fminf4( spu_promote( spu_extract( vec->vec128, 2 ), 0 ), result ); + result = fminf4( spu_promote( spu_extract( vec->vec128, 3 ), 0 ), result ); + return spu_extract( result, 0 ); +} + +static inline float vmathV4Sum( const VmathVector4 *vec ) +{ + return + spu_extract( vec->vec128, 0 ) + + spu_extract( vec->vec128, 1 ) + + spu_extract( vec->vec128, 2 ) + + spu_extract( vec->vec128, 3 ); +} + +static inline float vmathV4Dot( const VmathVector4 *vec0, const VmathVector4 *vec1 ) +{ + return spu_extract( _vmathVfDot4( vec0->vec128, vec1->vec128 ), 0 ); +} + +static inline float vmathV4LengthSqr( const VmathVector4 *vec ) +{ + return spu_extract( _vmathVfDot4( vec->vec128, vec->vec128 ), 0 ); +} + +static inline float vmathV4Length( const VmathVector4 *vec ) +{ + return sqrtf( vmathV4LengthSqr( vec ) ); +} + +static inline void vmathV4Normalize( VmathVector4 *result, const VmathVector4 *vec ) +{ + vec_float4 dot = _vmathVfDot4( vec->vec128, vec->vec128 ); + result->vec128 = spu_mul( vec->vec128, rsqrtf4( dot ) ); +} + +static inline void vmathV4Select( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1, unsigned int select1 ) +{ + result->vec128 = spu_sel( vec0->vec128, vec1->vec128, spu_splats( (unsigned int)-(select1 > 0) ) ); +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathV4Print( const VmathVector4 *vec ) +{ + union { vec_float4 v; float s[4]; } tmp; + tmp.v = vec->vec128; + printf( "( %f %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] ); +} + +static inline void vmathV4Prints( const VmathVector4 *vec, const char *name ) +{ + union { vec_float4 v; float s[4]; } tmp; + tmp.v = vec->vec128; + printf( "%s: ( %f %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] ); +} + +#endif + +static inline void vmathP3Copy( VmathPoint3 *result, const VmathPoint3 *pnt ) +{ + result->vec128 = pnt->vec128; +} + +static inline void vmathP3MakeFromElems( VmathPoint3 *result, float _x, float _y, float _z ) +{ + result->vec128 = (vec_float4){ _x, _y, _z, 0.0f }; +} + +static inline void vmathP3MakeFromV3( VmathPoint3 *result, const VmathVector3 *vec ) +{ + result->vec128 = vec->vec128; +} + +static inline void vmathP3MakeFromScalar( VmathPoint3 *result, float scalar ) +{ + result->vec128 = spu_splats( scalar ); +} + +static inline void vmathP3MakeFrom128( VmathPoint3 *result, vec_float4 vf4 ) +{ + result->vec128 = vf4; +} + +static inline void vmathP3Lerp( VmathPoint3 *result, float t, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) +{ + VmathVector3 tmpV3_0, tmpV3_1; + vmathP3Sub( &tmpV3_0, pnt1, pnt0 ); + vmathV3ScalarMul( &tmpV3_1, &tmpV3_0, t ); + vmathP3AddV3( result, pnt0, &tmpV3_1 ); +} + +static inline vec_float4 vmathP3Get128( const VmathPoint3 *pnt ) +{ + return pnt->vec128; +} + +static inline void vmathP3StoreXYZ( const VmathPoint3 *pnt, vec_float4 *quad ) +{ + vec_float4 dstVec = *quad; + vec_uint4 mask = (vec_uint4)spu_maskb(0x000f); + dstVec = spu_sel(pnt->vec128, dstVec, mask); + *quad = dstVec; +} + +static inline void vmathP3LoadXYZArray( VmathPoint3 *pnt0, VmathPoint3 *pnt1, VmathPoint3 *pnt2, VmathPoint3 *pnt3, const vec_float4 *threeQuads ) +{ + vec_float4 xyzx, yzxy, zxyz, xyz1, xyz2, xyz3; + xyzx = threeQuads[0]; + yzxy = threeQuads[1]; + zxyz = threeQuads[2]; + xyz1 = spu_shuffle( xyzx, yzxy, _VECTORMATH_SHUF_WABC ); + xyz2 = spu_shuffle( yzxy, zxyz, _VECTORMATH_SHUF_ZWAB ); + xyz3 = spu_rlqwbyte( zxyz, 4 ); + pnt0->vec128 = xyzx; + pnt1->vec128 = xyz1; + pnt2->vec128 = xyz2; + pnt3->vec128 = xyz3; +} + +static inline void vmathP3StoreXYZArray( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, const VmathPoint3 *pnt2, const VmathPoint3 *pnt3, vec_float4 *threeQuads ) +{ + vec_float4 xyzx, yzxy, zxyz; + xyzx = spu_shuffle( pnt0->vec128, pnt1->vec128, _VECTORMATH_SHUF_XYZA ); + yzxy = spu_shuffle( pnt1->vec128, pnt2->vec128, _VECTORMATH_SHUF_YZAB ); + zxyz = spu_shuffle( pnt2->vec128, pnt3->vec128, _VECTORMATH_SHUF_ZABC ); + threeQuads[0] = xyzx; + threeQuads[1] = yzxy; + threeQuads[2] = zxyz; +} + +static inline void vmathP3StoreHalfFloats( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, const VmathPoint3 *pnt2, const VmathPoint3 *pnt3, const VmathPoint3 *pnt4, const VmathPoint3 *pnt5, const VmathPoint3 *pnt6, const VmathPoint3 *pnt7, vec_ushort8 *threeQuads ) +{ + vec_float4 xyz0[3]; + vec_float4 xyz1[3]; + vmathP3StoreXYZArray( pnt0, pnt1, pnt2, pnt3, xyz0 ); + vmathP3StoreXYZArray( pnt4, pnt5, pnt6, pnt7, xyz1 ); + threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); + threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); + threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); +} + +static inline void vmathP3SetX( VmathPoint3 *result, float _x ) +{ + result->vec128 = spu_insert( _x, result->vec128, 0 ); +} + +static inline float vmathP3GetX( const VmathPoint3 *pnt ) +{ + return spu_extract( pnt->vec128, 0 ); +} + +static inline void vmathP3SetY( VmathPoint3 *result, float _y ) +{ + result->vec128 = spu_insert( _y, result->vec128, 1 ); +} + +static inline float vmathP3GetY( const VmathPoint3 *pnt ) +{ + return spu_extract( pnt->vec128, 1 ); +} + +static inline void vmathP3SetZ( VmathPoint3 *result, float _z ) +{ + result->vec128 = spu_insert( _z, result->vec128, 2 ); +} + +static inline float vmathP3GetZ( const VmathPoint3 *pnt ) +{ + return spu_extract( pnt->vec128, 2 ); +} + +static inline void vmathP3SetElem( VmathPoint3 *result, int idx, float value ) +{ + result->vec128 = spu_insert( value, result->vec128, idx ); +} + +static inline float vmathP3GetElem( const VmathPoint3 *pnt, int idx ) +{ + return spu_extract( pnt->vec128, idx ); +} + +static inline void vmathP3Sub( VmathVector3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) +{ + result->vec128 = spu_sub( pnt0->vec128, pnt1->vec128 ); +} + +static inline void vmathP3AddV3( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *vec1 ) +{ + result->vec128 = spu_add( pnt->vec128, vec1->vec128 ); +} + +static inline void vmathP3SubV3( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *vec1 ) +{ + result->vec128 = spu_sub( pnt->vec128, vec1->vec128 ); +} + +static inline void vmathP3MulPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) +{ + result->vec128 = spu_mul( pnt0->vec128, pnt1->vec128 ); +} + +static inline void vmathP3DivPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) +{ + result->vec128 = divf4( pnt0->vec128, pnt1->vec128 ); +} + +static inline void vmathP3RecipPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ) +{ + result->vec128 = recipf4( pnt->vec128 ); +} + +static inline void vmathP3SqrtPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ) +{ + result->vec128 = sqrtf4( pnt->vec128 ); +} + +static inline void vmathP3RsqrtPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ) +{ + result->vec128 = rsqrtf4( pnt->vec128 ); +} + +static inline void vmathP3AbsPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ) +{ + result->vec128 = fabsf4( pnt->vec128 ); +} + +static inline void vmathP3CopySignPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) +{ + result->vec128 = copysignf4( pnt0->vec128, pnt1->vec128 ); +} + +static inline void vmathP3MaxPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) +{ + result->vec128 = fmaxf4( pnt0->vec128, pnt1->vec128 ); +} + +static inline float vmathP3MaxElem( const VmathPoint3 *pnt ) +{ + vec_float4 result; + result = fmaxf4( spu_promote( spu_extract( pnt->vec128, 1 ), 0 ), pnt->vec128 ); + result = fmaxf4( spu_promote( spu_extract( pnt->vec128, 2 ), 0 ), result ); + return spu_extract( result, 0 ); +} + +static inline void vmathP3MinPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) +{ + result->vec128 = fminf4( pnt0->vec128, pnt1->vec128 ); +} + +static inline float vmathP3MinElem( const VmathPoint3 *pnt ) +{ + vec_float4 result; + result = fminf4( spu_promote( spu_extract( pnt->vec128, 1 ), 0 ), pnt->vec128 ); + result = fminf4( spu_promote( spu_extract( pnt->vec128, 2 ), 0 ), result ); + return spu_extract( result, 0 ); +} + +static inline float vmathP3Sum( const VmathPoint3 *pnt ) +{ + return + spu_extract( pnt->vec128, 0 ) + + spu_extract( pnt->vec128, 1 ) + + spu_extract( pnt->vec128, 2 ); +} + +static inline void vmathP3Scale( VmathPoint3 *result, const VmathPoint3 *pnt, float scaleVal ) +{ + VmathPoint3 tmpP3_0; + vmathP3MakeFromScalar( &tmpP3_0, scaleVal ); + vmathP3MulPerElem( result, pnt, &tmpP3_0 ); +} + +static inline void vmathP3NonUniformScale( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *scaleVec ) +{ + VmathPoint3 tmpP3_0; + vmathP3MakeFromV3( &tmpP3_0, scaleVec ); + vmathP3MulPerElem( result, pnt, &tmpP3_0 ); +} + +static inline float vmathP3Projection( const VmathPoint3 *pnt, const VmathVector3 *unitVec ) +{ + return spu_extract( _vmathVfDot3( pnt->vec128, unitVec->vec128 ), 0 ); +} + +static inline float vmathP3DistSqrFromOrigin( const VmathPoint3 *pnt ) +{ + VmathVector3 tmpV3_0; + vmathV3MakeFromP3( &tmpV3_0, pnt ); + return vmathV3LengthSqr( &tmpV3_0 ); +} + +static inline float vmathP3DistFromOrigin( const VmathPoint3 *pnt ) +{ + VmathVector3 tmpV3_0; + vmathV3MakeFromP3( &tmpV3_0, pnt ); + return vmathV3Length( &tmpV3_0 ); +} + +static inline float vmathP3DistSqr( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) +{ + VmathVector3 tmpV3_0; + vmathP3Sub( &tmpV3_0, pnt1, pnt0 ); + return vmathV3LengthSqr( &tmpV3_0 ); +} + +static inline float vmathP3Dist( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) +{ + VmathVector3 tmpV3_0; + vmathP3Sub( &tmpV3_0, pnt1, pnt0 ); + return vmathV3Length( &tmpV3_0 ); +} + +static inline void vmathP3Select( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, unsigned int select1 ) +{ + result->vec128 = spu_sel( pnt0->vec128, pnt1->vec128, spu_splats( (unsigned int)-(select1 > 0) ) ); +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathP3Print( const VmathPoint3 *pnt ) +{ + union { vec_float4 v; float s[4]; } tmp; + tmp.v = pnt->vec128; + printf( "( %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2] ); +} + +static inline void vmathP3Prints( const VmathPoint3 *pnt, const char *name ) +{ + union { vec_float4 v; float s[4]; } tmp; + tmp.v = pnt->vec128; + printf( "%s: ( %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2] ); +} + +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/vectormathlibrary/include/vectormath/spu/c/vec_aos_v.h b/vectormathlibrary/include/vectormath/spu/c/vec_aos_v.h new file mode 100644 index 000000000..7cf0fa9cc --- /dev/null +++ b/vectormathlibrary/include/vectormath/spu/c/vec_aos_v.h @@ -0,0 +1,951 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_VEC_AOS_V_C_H +#define _VECTORMATH_VEC_AOS_V_C_H +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/*----------------------------------------------------------------------------- + * Constants + * for shuffles, words are labeled [x,y,z,w] [a,b,c,d] + */ +#define _VECTORMATH_SHUF_X 0x00010203 +#define _VECTORMATH_SHUF_Y 0x04050607 +#define _VECTORMATH_SHUF_Z 0x08090a0b +#define _VECTORMATH_SHUF_W 0x0c0d0e0f +#define _VECTORMATH_SHUF_A 0x10111213 +#define _VECTORMATH_SHUF_B 0x14151617 +#define _VECTORMATH_SHUF_C 0x18191a1b +#define _VECTORMATH_SHUF_D 0x1c1d1e1f +#define _VECTORMATH_SHUF_0 0x80808080 +#define _VECTORMATH_SHUF_XYZA (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_A } +#define _VECTORMATH_SHUF_ZXYW (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_W } +#define _VECTORMATH_SHUF_YZXW (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_W } +#define _VECTORMATH_SHUF_WABC (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_C } +#define _VECTORMATH_SHUF_ZWAB (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_B } +#define _VECTORMATH_SHUF_XYZA (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_A } +#define _VECTORMATH_SHUF_YZAB (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_B } +#define _VECTORMATH_SHUF_ZABC (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_C } +#define _VECTORMATH_UNIT_1000 (vec_float4){ 1.0f, 0.0f, 0.0f, 0.0f } +#define _VECTORMATH_UNIT_0100 (vec_float4){ 0.0f, 1.0f, 0.0f, 0.0f } +#define _VECTORMATH_UNIT_0010 (vec_float4){ 0.0f, 0.0f, 1.0f, 0.0f } +#define _VECTORMATH_UNIT_0001 (vec_float4){ 0.0f, 0.0f, 0.0f, 1.0f } +#define _VECTORMATH_SLERP_TOL 0.999f + +/*----------------------------------------------------------------------------- + * Definitions + */ +#ifndef _VECTORMATH_INTERNAL_FUNCTIONS +#define _VECTORMATH_INTERNAL_FUNCTIONS + +#endif + +static inline VmathVector3 vmathV3MakeFromElems_V( float _x, float _y, float _z ) +{ + VmathVector3 result; + vmathV3MakeFromElems(&result, _x, _y, _z); + return result; +} + +static inline VmathVector3 vmathV3MakeFromP3_V( VmathPoint3 pnt ) +{ + VmathVector3 result; + vmathV3MakeFromP3(&result, &pnt); + return result; +} + +static inline VmathVector3 vmathV3MakeFromScalar_V( float scalar ) +{ + VmathVector3 result; + vmathV3MakeFromScalar(&result, scalar); + return result; +} + +static inline VmathVector3 vmathV3MakeFrom128_V( vec_float4 vf4 ) +{ + VmathVector3 result; + vmathV3MakeFrom128(&result, vf4); + return result; +} + +static inline VmathVector3 vmathV3MakeXAxis_V( ) +{ + VmathVector3 result; + vmathV3MakeXAxis(&result); + return result; +} + +static inline VmathVector3 vmathV3MakeYAxis_V( ) +{ + VmathVector3 result; + vmathV3MakeYAxis(&result); + return result; +} + +static inline VmathVector3 vmathV3MakeZAxis_V( ) +{ + VmathVector3 result; + vmathV3MakeZAxis(&result); + return result; +} + +static inline VmathVector3 vmathV3Lerp_V( float t, VmathVector3 vec0, VmathVector3 vec1 ) +{ + VmathVector3 result; + vmathV3Lerp(&result, t, &vec0, &vec1); + return result; +} + +static inline VmathVector3 vmathV3Slerp_V( float t, VmathVector3 unitVec0, VmathVector3 unitVec1 ) +{ + VmathVector3 result; + vmathV3Slerp(&result, t, &unitVec0, &unitVec1); + return result; +} + +static inline vec_float4 vmathV3Get128_V( VmathVector3 vec ) +{ + return vmathV3Get128(&vec); +} + +static inline void vmathV3StoreXYZ_V( VmathVector3 vec, vec_float4 *quad ) +{ + vmathV3StoreXYZ(&vec, quad); +} + +static inline void vmathV3LoadXYZArray_V( VmathVector3 *vec0, VmathVector3 *vec1, VmathVector3 *vec2, VmathVector3 *vec3, const vec_float4 *threeQuads ) +{ + vmathV3LoadXYZArray(vec0, vec1, vec2, vec3, threeQuads); +} + +static inline void vmathV3StoreXYZArray_V( VmathVector3 vec0, VmathVector3 vec1, VmathVector3 vec2, VmathVector3 vec3, vec_float4 *threeQuads ) +{ + vmathV3StoreXYZArray(&vec0, &vec1, &vec2, &vec3, threeQuads); +} + +static inline void vmathV3StoreHalfFloats_V( VmathVector3 vec0, VmathVector3 vec1, VmathVector3 vec2, VmathVector3 vec3, VmathVector3 vec4, VmathVector3 vec5, VmathVector3 vec6, VmathVector3 vec7, vec_ushort8 *threeQuads ) +{ + vmathV3StoreHalfFloats(&vec0, &vec1, &vec2, &vec3, &vec4, &vec5, &vec6, &vec7, threeQuads); +} + +static inline void vmathV3SetX_V( VmathVector3 *result, float _x ) +{ + vmathV3SetX(result, _x); +} + +static inline float vmathV3GetX_V( VmathVector3 vec ) +{ + return vmathV3GetX(&vec); +} + +static inline void vmathV3SetY_V( VmathVector3 *result, float _y ) +{ + vmathV3SetY(result, _y); +} + +static inline float vmathV3GetY_V( VmathVector3 vec ) +{ + return vmathV3GetY(&vec); +} + +static inline void vmathV3SetZ_V( VmathVector3 *result, float _z ) +{ + vmathV3SetZ(result, _z); +} + +static inline float vmathV3GetZ_V( VmathVector3 vec ) +{ + return vmathV3GetZ(&vec); +} + +static inline void vmathV3SetElem_V( VmathVector3 *result, int idx, float value ) +{ + vmathV3SetElem(result, idx, value); +} + +static inline float vmathV3GetElem_V( VmathVector3 vec, int idx ) +{ + return vmathV3GetElem(&vec, idx); +} + +static inline VmathVector3 vmathV3Add_V( VmathVector3 vec0, VmathVector3 vec1 ) +{ + VmathVector3 result; + vmathV3Add(&result, &vec0, &vec1); + return result; +} + +static inline VmathVector3 vmathV3Sub_V( VmathVector3 vec0, VmathVector3 vec1 ) +{ + VmathVector3 result; + vmathV3Sub(&result, &vec0, &vec1); + return result; +} + +static inline VmathPoint3 vmathV3AddP3_V( VmathVector3 vec, VmathPoint3 pnt1 ) +{ + VmathPoint3 result; + vmathV3AddP3(&result, &vec, &pnt1); + return result; +} + +static inline VmathVector3 vmathV3ScalarMul_V( VmathVector3 vec, float scalar ) +{ + VmathVector3 result; + vmathV3ScalarMul(&result, &vec, scalar); + return result; +} + +static inline VmathVector3 vmathV3ScalarDiv_V( VmathVector3 vec, float scalar ) +{ + VmathVector3 result; + vmathV3ScalarDiv(&result, &vec, scalar); + return result; +} + +static inline VmathVector3 vmathV3Neg_V( VmathVector3 vec ) +{ + VmathVector3 result; + vmathV3Neg(&result, &vec); + return result; +} + +static inline VmathVector3 vmathV3MulPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ) +{ + VmathVector3 result; + vmathV3MulPerElem(&result, &vec0, &vec1); + return result; +} + +static inline VmathVector3 vmathV3DivPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ) +{ + VmathVector3 result; + vmathV3DivPerElem(&result, &vec0, &vec1); + return result; +} + +static inline VmathVector3 vmathV3RecipPerElem_V( VmathVector3 vec ) +{ + VmathVector3 result; + vmathV3RecipPerElem(&result, &vec); + return result; +} + +static inline VmathVector3 vmathV3SqrtPerElem_V( VmathVector3 vec ) +{ + VmathVector3 result; + vmathV3SqrtPerElem(&result, &vec); + return result; +} + +static inline VmathVector3 vmathV3RsqrtPerElem_V( VmathVector3 vec ) +{ + VmathVector3 result; + vmathV3RsqrtPerElem(&result, &vec); + return result; +} + +static inline VmathVector3 vmathV3AbsPerElem_V( VmathVector3 vec ) +{ + VmathVector3 result; + vmathV3AbsPerElem(&result, &vec); + return result; +} + +static inline VmathVector3 vmathV3CopySignPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ) +{ + VmathVector3 result; + vmathV3CopySignPerElem(&result, &vec0, &vec1); + return result; +} + +static inline VmathVector3 vmathV3MaxPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ) +{ + VmathVector3 result; + vmathV3MaxPerElem(&result, &vec0, &vec1); + return result; +} + +static inline float vmathV3MaxElem_V( VmathVector3 vec ) +{ + return vmathV3MaxElem(&vec); +} + +static inline VmathVector3 vmathV3MinPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ) +{ + VmathVector3 result; + vmathV3MinPerElem(&result, &vec0, &vec1); + return result; +} + +static inline float vmathV3MinElem_V( VmathVector3 vec ) +{ + return vmathV3MinElem(&vec); +} + +static inline float vmathV3Sum_V( VmathVector3 vec ) +{ + return vmathV3Sum(&vec); +} + +static inline float vmathV3Dot_V( VmathVector3 vec0, VmathVector3 vec1 ) +{ + return vmathV3Dot(&vec0, &vec1); +} + +static inline float vmathV3LengthSqr_V( VmathVector3 vec ) +{ + return vmathV3LengthSqr(&vec); +} + +static inline float vmathV3Length_V( VmathVector3 vec ) +{ + return vmathV3Length(&vec); +} + +static inline VmathVector3 vmathV3Normalize_V( VmathVector3 vec ) +{ + VmathVector3 result; + vmathV3Normalize(&result, &vec); + return result; +} + +static inline VmathVector3 vmathV3Cross_V( VmathVector3 vec0, VmathVector3 vec1 ) +{ + VmathVector3 result; + vmathV3Cross(&result, &vec0, &vec1); + return result; +} + +static inline VmathVector3 vmathV3Select_V( VmathVector3 vec0, VmathVector3 vec1, unsigned int select1 ) +{ + VmathVector3 result; + vmathV3Select(&result, &vec0, &vec1, select1); + return result; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathV3Print_V( VmathVector3 vec ) +{ + vmathV3Print(&vec); +} + +static inline void vmathV3Prints_V( VmathVector3 vec, const char *name ) +{ + vmathV3Prints(&vec, name); +} + +#endif + +static inline VmathVector4 vmathV4MakeFromElems_V( float _x, float _y, float _z, float _w ) +{ + VmathVector4 result; + vmathV4MakeFromElems(&result, _x, _y, _z, _w); + return result; +} + +static inline VmathVector4 vmathV4MakeFromV3Scalar_V( VmathVector3 xyz, float _w ) +{ + VmathVector4 result; + vmathV4MakeFromV3Scalar(&result, &xyz, _w); + return result; +} + +static inline VmathVector4 vmathV4MakeFromV3_V( VmathVector3 vec ) +{ + VmathVector4 result; + vmathV4MakeFromV3(&result, &vec); + return result; +} + +static inline VmathVector4 vmathV4MakeFromP3_V( VmathPoint3 pnt ) +{ + VmathVector4 result; + vmathV4MakeFromP3(&result, &pnt); + return result; +} + +static inline VmathVector4 vmathV4MakeFromQ_V( VmathQuat quat ) +{ + VmathVector4 result; + vmathV4MakeFromQ(&result, &quat); + return result; +} + +static inline VmathVector4 vmathV4MakeFromScalar_V( float scalar ) +{ + VmathVector4 result; + vmathV4MakeFromScalar(&result, scalar); + return result; +} + +static inline VmathVector4 vmathV4MakeFrom128_V( vec_float4 vf4 ) +{ + VmathVector4 result; + vmathV4MakeFrom128(&result, vf4); + return result; +} + +static inline VmathVector4 vmathV4MakeXAxis_V( ) +{ + VmathVector4 result; + vmathV4MakeXAxis(&result); + return result; +} + +static inline VmathVector4 vmathV4MakeYAxis_V( ) +{ + VmathVector4 result; + vmathV4MakeYAxis(&result); + return result; +} + +static inline VmathVector4 vmathV4MakeZAxis_V( ) +{ + VmathVector4 result; + vmathV4MakeZAxis(&result); + return result; +} + +static inline VmathVector4 vmathV4MakeWAxis_V( ) +{ + VmathVector4 result; + vmathV4MakeWAxis(&result); + return result; +} + +static inline VmathVector4 vmathV4Lerp_V( float t, VmathVector4 vec0, VmathVector4 vec1 ) +{ + VmathVector4 result; + vmathV4Lerp(&result, t, &vec0, &vec1); + return result; +} + +static inline VmathVector4 vmathV4Slerp_V( float t, VmathVector4 unitVec0, VmathVector4 unitVec1 ) +{ + VmathVector4 result; + vmathV4Slerp(&result, t, &unitVec0, &unitVec1); + return result; +} + +static inline vec_float4 vmathV4Get128_V( VmathVector4 vec ) +{ + return vmathV4Get128(&vec); +} + +static inline void vmathV4StoreHalfFloats_V( VmathVector4 vec0, VmathVector4 vec1, VmathVector4 vec2, VmathVector4 vec3, vec_ushort8 *twoQuads ) +{ + vmathV4StoreHalfFloats(&vec0, &vec1, &vec2, &vec3, twoQuads); +} + +static inline void vmathV4SetXYZ_V( VmathVector4 *result, VmathVector3 vec ) +{ + vmathV4SetXYZ(result, &vec); +} + +static inline VmathVector3 vmathV4GetXYZ_V( VmathVector4 vec ) +{ + VmathVector3 result; + vmathV4GetXYZ(&result, &vec); + return result; +} + +static inline void vmathV4SetX_V( VmathVector4 *result, float _x ) +{ + vmathV4SetX(result, _x); +} + +static inline float vmathV4GetX_V( VmathVector4 vec ) +{ + return vmathV4GetX(&vec); +} + +static inline void vmathV4SetY_V( VmathVector4 *result, float _y ) +{ + vmathV4SetY(result, _y); +} + +static inline float vmathV4GetY_V( VmathVector4 vec ) +{ + return vmathV4GetY(&vec); +} + +static inline void vmathV4SetZ_V( VmathVector4 *result, float _z ) +{ + vmathV4SetZ(result, _z); +} + +static inline float vmathV4GetZ_V( VmathVector4 vec ) +{ + return vmathV4GetZ(&vec); +} + +static inline void vmathV4SetW_V( VmathVector4 *result, float _w ) +{ + vmathV4SetW(result, _w); +} + +static inline float vmathV4GetW_V( VmathVector4 vec ) +{ + return vmathV4GetW(&vec); +} + +static inline void vmathV4SetElem_V( VmathVector4 *result, int idx, float value ) +{ + vmathV4SetElem(result, idx, value); +} + +static inline float vmathV4GetElem_V( VmathVector4 vec, int idx ) +{ + return vmathV4GetElem(&vec, idx); +} + +static inline VmathVector4 vmathV4Add_V( VmathVector4 vec0, VmathVector4 vec1 ) +{ + VmathVector4 result; + vmathV4Add(&result, &vec0, &vec1); + return result; +} + +static inline VmathVector4 vmathV4Sub_V( VmathVector4 vec0, VmathVector4 vec1 ) +{ + VmathVector4 result; + vmathV4Sub(&result, &vec0, &vec1); + return result; +} + +static inline VmathVector4 vmathV4ScalarMul_V( VmathVector4 vec, float scalar ) +{ + VmathVector4 result; + vmathV4ScalarMul(&result, &vec, scalar); + return result; +} + +static inline VmathVector4 vmathV4ScalarDiv_V( VmathVector4 vec, float scalar ) +{ + VmathVector4 result; + vmathV4ScalarDiv(&result, &vec, scalar); + return result; +} + +static inline VmathVector4 vmathV4Neg_V( VmathVector4 vec ) +{ + VmathVector4 result; + vmathV4Neg(&result, &vec); + return result; +} + +static inline VmathVector4 vmathV4MulPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ) +{ + VmathVector4 result; + vmathV4MulPerElem(&result, &vec0, &vec1); + return result; +} + +static inline VmathVector4 vmathV4DivPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ) +{ + VmathVector4 result; + vmathV4DivPerElem(&result, &vec0, &vec1); + return result; +} + +static inline VmathVector4 vmathV4RecipPerElem_V( VmathVector4 vec ) +{ + VmathVector4 result; + vmathV4RecipPerElem(&result, &vec); + return result; +} + +static inline VmathVector4 vmathV4SqrtPerElem_V( VmathVector4 vec ) +{ + VmathVector4 result; + vmathV4SqrtPerElem(&result, &vec); + return result; +} + +static inline VmathVector4 vmathV4RsqrtPerElem_V( VmathVector4 vec ) +{ + VmathVector4 result; + vmathV4RsqrtPerElem(&result, &vec); + return result; +} + +static inline VmathVector4 vmathV4AbsPerElem_V( VmathVector4 vec ) +{ + VmathVector4 result; + vmathV4AbsPerElem(&result, &vec); + return result; +} + +static inline VmathVector4 vmathV4CopySignPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ) +{ + VmathVector4 result; + vmathV4CopySignPerElem(&result, &vec0, &vec1); + return result; +} + +static inline VmathVector4 vmathV4MaxPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ) +{ + VmathVector4 result; + vmathV4MaxPerElem(&result, &vec0, &vec1); + return result; +} + +static inline float vmathV4MaxElem_V( VmathVector4 vec ) +{ + return vmathV4MaxElem(&vec); +} + +static inline VmathVector4 vmathV4MinPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ) +{ + VmathVector4 result; + vmathV4MinPerElem(&result, &vec0, &vec1); + return result; +} + +static inline float vmathV4MinElem_V( VmathVector4 vec ) +{ + return vmathV4MinElem(&vec); +} + +static inline float vmathV4Sum_V( VmathVector4 vec ) +{ + return vmathV4Sum(&vec); +} + +static inline float vmathV4Dot_V( VmathVector4 vec0, VmathVector4 vec1 ) +{ + return vmathV4Dot(&vec0, &vec1); +} + +static inline float vmathV4LengthSqr_V( VmathVector4 vec ) +{ + return vmathV4LengthSqr(&vec); +} + +static inline float vmathV4Length_V( VmathVector4 vec ) +{ + return vmathV4Length(&vec); +} + +static inline VmathVector4 vmathV4Normalize_V( VmathVector4 vec ) +{ + VmathVector4 result; + vmathV4Normalize(&result, &vec); + return result; +} + +static inline VmathVector4 vmathV4Select_V( VmathVector4 vec0, VmathVector4 vec1, unsigned int select1 ) +{ + VmathVector4 result; + vmathV4Select(&result, &vec0, &vec1, select1); + return result; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathV4Print_V( VmathVector4 vec ) +{ + vmathV4Print(&vec); +} + +static inline void vmathV4Prints_V( VmathVector4 vec, const char *name ) +{ + vmathV4Prints(&vec, name); +} + +#endif + +static inline VmathPoint3 vmathP3MakeFromElems_V( float _x, float _y, float _z ) +{ + VmathPoint3 result; + vmathP3MakeFromElems(&result, _x, _y, _z); + return result; +} + +static inline VmathPoint3 vmathP3MakeFromV3_V( VmathVector3 vec ) +{ + VmathPoint3 result; + vmathP3MakeFromV3(&result, &vec); + return result; +} + +static inline VmathPoint3 vmathP3MakeFromScalar_V( float scalar ) +{ + VmathPoint3 result; + vmathP3MakeFromScalar(&result, scalar); + return result; +} + +static inline VmathPoint3 vmathP3MakeFrom128_V( vec_float4 vf4 ) +{ + VmathPoint3 result; + vmathP3MakeFrom128(&result, vf4); + return result; +} + +static inline VmathPoint3 vmathP3Lerp_V( float t, VmathPoint3 pnt0, VmathPoint3 pnt1 ) +{ + VmathPoint3 result; + vmathP3Lerp(&result, t, &pnt0, &pnt1); + return result; +} + +static inline vec_float4 vmathP3Get128_V( VmathPoint3 pnt ) +{ + return vmathP3Get128(&pnt); +} + +static inline void vmathP3StoreXYZ_V( VmathPoint3 pnt, vec_float4 *quad ) +{ + vmathP3StoreXYZ(&pnt, quad); +} + +static inline void vmathP3LoadXYZArray_V( VmathPoint3 *pnt0, VmathPoint3 *pnt1, VmathPoint3 *pnt2, VmathPoint3 *pnt3, const vec_float4 *threeQuads ) +{ + vmathP3LoadXYZArray(pnt0, pnt1, pnt2, pnt3, threeQuads); +} + +static inline void vmathP3StoreXYZArray_V( VmathPoint3 pnt0, VmathPoint3 pnt1, VmathPoint3 pnt2, VmathPoint3 pnt3, vec_float4 *threeQuads ) +{ + vmathP3StoreXYZArray(&pnt0, &pnt1, &pnt2, &pnt3, threeQuads); +} + +static inline void vmathP3StoreHalfFloats_V( VmathPoint3 pnt0, VmathPoint3 pnt1, VmathPoint3 pnt2, VmathPoint3 pnt3, VmathPoint3 pnt4, VmathPoint3 pnt5, VmathPoint3 pnt6, VmathPoint3 pnt7, vec_ushort8 *threeQuads ) +{ + vmathP3StoreHalfFloats(&pnt0, &pnt1, &pnt2, &pnt3, &pnt4, &pnt5, &pnt6, &pnt7, threeQuads); +} + +static inline void vmathP3SetX_V( VmathPoint3 *result, float _x ) +{ + vmathP3SetX(result, _x); +} + +static inline float vmathP3GetX_V( VmathPoint3 pnt ) +{ + return vmathP3GetX(&pnt); +} + +static inline void vmathP3SetY_V( VmathPoint3 *result, float _y ) +{ + vmathP3SetY(result, _y); +} + +static inline float vmathP3GetY_V( VmathPoint3 pnt ) +{ + return vmathP3GetY(&pnt); +} + +static inline void vmathP3SetZ_V( VmathPoint3 *result, float _z ) +{ + vmathP3SetZ(result, _z); +} + +static inline float vmathP3GetZ_V( VmathPoint3 pnt ) +{ + return vmathP3GetZ(&pnt); +} + +static inline void vmathP3SetElem_V( VmathPoint3 *result, int idx, float value ) +{ + vmathP3SetElem(result, idx, value); +} + +static inline float vmathP3GetElem_V( VmathPoint3 pnt, int idx ) +{ + return vmathP3GetElem(&pnt, idx); +} + +static inline VmathVector3 vmathP3Sub_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) +{ + VmathVector3 result; + vmathP3Sub(&result, &pnt0, &pnt1); + return result; +} + +static inline VmathPoint3 vmathP3AddV3_V( VmathPoint3 pnt, VmathVector3 vec1 ) +{ + VmathPoint3 result; + vmathP3AddV3(&result, &pnt, &vec1); + return result; +} + +static inline VmathPoint3 vmathP3SubV3_V( VmathPoint3 pnt, VmathVector3 vec1 ) +{ + VmathPoint3 result; + vmathP3SubV3(&result, &pnt, &vec1); + return result; +} + +static inline VmathPoint3 vmathP3MulPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) +{ + VmathPoint3 result; + vmathP3MulPerElem(&result, &pnt0, &pnt1); + return result; +} + +static inline VmathPoint3 vmathP3DivPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) +{ + VmathPoint3 result; + vmathP3DivPerElem(&result, &pnt0, &pnt1); + return result; +} + +static inline VmathPoint3 vmathP3RecipPerElem_V( VmathPoint3 pnt ) +{ + VmathPoint3 result; + vmathP3RecipPerElem(&result, &pnt); + return result; +} + +static inline VmathPoint3 vmathP3SqrtPerElem_V( VmathPoint3 pnt ) +{ + VmathPoint3 result; + vmathP3SqrtPerElem(&result, &pnt); + return result; +} + +static inline VmathPoint3 vmathP3RsqrtPerElem_V( VmathPoint3 pnt ) +{ + VmathPoint3 result; + vmathP3RsqrtPerElem(&result, &pnt); + return result; +} + +static inline VmathPoint3 vmathP3AbsPerElem_V( VmathPoint3 pnt ) +{ + VmathPoint3 result; + vmathP3AbsPerElem(&result, &pnt); + return result; +} + +static inline VmathPoint3 vmathP3CopySignPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) +{ + VmathPoint3 result; + vmathP3CopySignPerElem(&result, &pnt0, &pnt1); + return result; +} + +static inline VmathPoint3 vmathP3MaxPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) +{ + VmathPoint3 result; + vmathP3MaxPerElem(&result, &pnt0, &pnt1); + return result; +} + +static inline float vmathP3MaxElem_V( VmathPoint3 pnt ) +{ + return vmathP3MaxElem(&pnt); +} + +static inline VmathPoint3 vmathP3MinPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) +{ + VmathPoint3 result; + vmathP3MinPerElem(&result, &pnt0, &pnt1); + return result; +} + +static inline float vmathP3MinElem_V( VmathPoint3 pnt ) +{ + return vmathP3MinElem(&pnt); +} + +static inline float vmathP3Sum_V( VmathPoint3 pnt ) +{ + return vmathP3Sum(&pnt); +} + +static inline VmathPoint3 vmathP3Scale_V( VmathPoint3 pnt, float scaleVal ) +{ + VmathPoint3 result; + vmathP3Scale(&result, &pnt, scaleVal); + return result; +} + +static inline VmathPoint3 vmathP3NonUniformScale_V( VmathPoint3 pnt, VmathVector3 scaleVec ) +{ + VmathPoint3 result; + vmathP3NonUniformScale(&result, &pnt, &scaleVec); + return result; +} + +static inline float vmathP3Projection_V( VmathPoint3 pnt, VmathVector3 unitVec ) +{ + return vmathP3Projection(&pnt, &unitVec); +} + +static inline float vmathP3DistSqrFromOrigin_V( VmathPoint3 pnt ) +{ + return vmathP3DistSqrFromOrigin(&pnt); +} + +static inline float vmathP3DistFromOrigin_V( VmathPoint3 pnt ) +{ + return vmathP3DistFromOrigin(&pnt); +} + +static inline float vmathP3DistSqr_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) +{ + return vmathP3DistSqr(&pnt0, &pnt1); +} + +static inline float vmathP3Dist_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) +{ + return vmathP3Dist(&pnt0, &pnt1); +} + +static inline VmathPoint3 vmathP3Select_V( VmathPoint3 pnt0, VmathPoint3 pnt1, unsigned int select1 ) +{ + VmathPoint3 result; + vmathP3Select(&result, &pnt0, &pnt1, select1); + return result; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathP3Print_V( VmathPoint3 pnt ) +{ + vmathP3Print(&pnt); +} + +static inline void vmathP3Prints_V( VmathPoint3 pnt, const char *name ) +{ + vmathP3Prints(&pnt, name); +} + +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/vectormathlibrary/include/vectormath/spu/c/vec_soa.h b/vectormathlibrary/include/vectormath/spu/c/vec_soa.h new file mode 100644 index 000000000..608b38562 --- /dev/null +++ b/vectormathlibrary/include/vectormath/spu/c/vec_soa.h @@ -0,0 +1,1237 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_VEC_SOA_C_H +#define _VECTORMATH_VEC_SOA_C_H +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/*----------------------------------------------------------------------------- + * Constants + * for shuffles, words are labeled [x,y,z,w] [a,b,c,d] + */ +#define _VECTORMATH_SHUF_X 0x00010203 +#define _VECTORMATH_SHUF_Y 0x04050607 +#define _VECTORMATH_SHUF_Z 0x08090a0b +#define _VECTORMATH_SHUF_W 0x0c0d0e0f +#define _VECTORMATH_SHUF_A 0x10111213 +#define _VECTORMATH_SHUF_B 0x14151617 +#define _VECTORMATH_SHUF_C 0x18191a1b +#define _VECTORMATH_SHUF_D 0x1c1d1e1f +#define _VECTORMATH_SHUF_0 0x80808080 +#define _VECTORMATH_SHUF_XAYB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_B }) +#define _VECTORMATH_SHUF_ZCWD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_D }) +#define _VECTORMATH_SHUF_ZBW0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_0 }) +#define _VECTORMATH_SHUF_XCY0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_0 }) +#define _VECTORMATH_SHUF_ZDW0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_D, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_0 }) +#define _VECTORMATH_SHUF_XAZC ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_C }) +#define _VECTORMATH_SHUF_ZDXB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_D, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_B }) +#define _VECTORMATH_SHUF_YBWD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_D }) +#define _VECTORMATH_SHUF_XDZB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_D, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_B }) +#define _VECTORMATH_SHUF_YAWC ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_C }) +#define _VECTORMATH_SHUF_ZBXD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_D }) +#define _VECTORMATH_SHUF_XYCD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_D }) +#define _VECTORMATH_SLERP_TOL 0.999f + +/*----------------------------------------------------------------------------- + * Definitions + */ +#ifndef _VECTORMATH_INTERNAL_FUNCTIONS +#define _VECTORMATH_INTERNAL_FUNCTIONS + +#endif + +static inline void vmathSoaV3Copy( VmathSoaVector3 *result, const VmathSoaVector3 *vec ) +{ + result->x = vec->x; + result->y = vec->y; + result->z = vec->z; +} + +static inline void vmathSoaV3MakeFromElems( VmathSoaVector3 *result, vec_float4 _x, vec_float4 _y, vec_float4 _z ) +{ + result->x = _x; + result->y = _y; + result->z = _z; +} + +static inline void vmathSoaV3MakeFromP3( VmathSoaVector3 *result, const VmathSoaPoint3 *pnt ) +{ + result->x = pnt->x; + result->y = pnt->y; + result->z = pnt->z; +} + +static inline void vmathSoaV3MakeFromScalar( VmathSoaVector3 *result, vec_float4 scalar ) +{ + result->x = scalar; + result->y = scalar; + result->z = scalar; +} + +static inline void vmathSoaV3MakeFromAos( VmathSoaVector3 *result, const VmathVector3 *vec ) +{ + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); + vec_float4 vec128 = vec->vec128; + result->x = spu_shuffle( vec128, vec128, shuffle_xxxx ); + result->y = spu_shuffle( vec128, vec128, shuffle_yyyy ); + result->z = spu_shuffle( vec128, vec128, shuffle_zzzz ); +} + +static inline void vmathSoaV3MakeFrom4Aos( VmathSoaVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1, const VmathVector3 *vec2, const VmathVector3 *vec3 ) +{ + vec_float4 tmp0, tmp1, tmp2, tmp3; + tmp0 = spu_shuffle( vec0->vec128, vec2->vec128, _VECTORMATH_SHUF_XAYB ); + tmp1 = spu_shuffle( vec1->vec128, vec3->vec128, _VECTORMATH_SHUF_XAYB ); + tmp2 = spu_shuffle( vec0->vec128, vec2->vec128, _VECTORMATH_SHUF_ZCWD ); + tmp3 = spu_shuffle( vec1->vec128, vec3->vec128, _VECTORMATH_SHUF_ZCWD ); + result->x = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB ); + result->y = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD ); + result->z = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB ); +} + +static inline void vmathSoaV3MakeXAxis( VmathSoaVector3 *result ) +{ + vmathSoaV3MakeFromElems( result, spu_splats(1.0f), spu_splats(0.0f), spu_splats(0.0f) ); +} + +static inline void vmathSoaV3MakeYAxis( VmathSoaVector3 *result ) +{ + vmathSoaV3MakeFromElems( result, spu_splats(0.0f), spu_splats(1.0f), spu_splats(0.0f) ); +} + +static inline void vmathSoaV3MakeZAxis( VmathSoaVector3 *result ) +{ + vmathSoaV3MakeFromElems( result, spu_splats(0.0f), spu_splats(0.0f), spu_splats(1.0f) ); +} + +static inline void vmathSoaV3Lerp( VmathSoaVector3 *result, vec_float4 t, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) +{ + VmathSoaVector3 tmpV3_0, tmpV3_1; + vmathSoaV3Sub( &tmpV3_0, vec1, vec0 ); + vmathSoaV3ScalarMul( &tmpV3_1, &tmpV3_0, t ); + vmathSoaV3Add( result, vec0, &tmpV3_1 ); +} + +static inline void vmathSoaV3Slerp( VmathSoaVector3 *result, vec_float4 t, const VmathSoaVector3 *unitVec0, const VmathSoaVector3 *unitVec1 ) +{ + VmathSoaVector3 tmpV3_0, tmpV3_1; + vec_float4 recipSinAngle, scale0, scale1, cosAngle, angle; + vec_uint4 selectMask; + cosAngle = vmathSoaV3Dot( unitVec0, unitVec1 ); + selectMask = (vec_uint4)spu_cmpgt( spu_splats(_VECTORMATH_SLERP_TOL), cosAngle ); + angle = acosf4( cosAngle ); + recipSinAngle = recipf4( sinf4( angle ) ); + scale0 = spu_sel( spu_sub( spu_splats(1.0f), t ), spu_mul( sinf4( spu_mul( spu_sub( spu_splats(1.0f), t ), angle ) ), recipSinAngle ), selectMask ); + scale1 = spu_sel( t, spu_mul( sinf4( spu_mul( t, angle ) ), recipSinAngle ), selectMask ); + vmathSoaV3ScalarMul( &tmpV3_0, unitVec0, scale0 ); + vmathSoaV3ScalarMul( &tmpV3_1, unitVec1, scale1 ); + vmathSoaV3Add( result, &tmpV3_0, &tmpV3_1 ); +} + +static inline void vmathSoaV3Get4Aos( const VmathSoaVector3 *vec, VmathVector3 *result0, VmathVector3 *result1, VmathVector3 *result2, VmathVector3 *result3 ) +{ + vec_float4 tmp0, tmp1; + tmp0 = spu_shuffle( vec->x, vec->z, _VECTORMATH_SHUF_XAYB ); + tmp1 = spu_shuffle( vec->x, vec->z, _VECTORMATH_SHUF_ZCWD ); + vmathV3MakeFrom128( result0, spu_shuffle( tmp0, vec->y, _VECTORMATH_SHUF_XAYB ) ); + vmathV3MakeFrom128( result1, spu_shuffle( tmp0, vec->y, _VECTORMATH_SHUF_ZBW0 ) ); + vmathV3MakeFrom128( result2, spu_shuffle( tmp1, vec->y, _VECTORMATH_SHUF_XCY0 ) ); + vmathV3MakeFrom128( result3, spu_shuffle( tmp1, vec->y, _VECTORMATH_SHUF_ZDW0 ) ); +} + +static inline void vmathSoaV3LoadXYZArray( VmathSoaVector3 *vec, const vec_float4 *threeQuads ) +{ + vec_float4 xyxy, yzyz, zxzx, xyzx, yzxy, zxyz; + xyzx = threeQuads[0]; + yzxy = threeQuads[1]; + zxyz = threeQuads[2]; + xyxy = spu_shuffle( xyzx, yzxy, _VECTORMATH_SHUF_XYCD ); + zxzx = spu_shuffle( zxyz, xyzx, _VECTORMATH_SHUF_XYCD ); + yzyz = spu_shuffle( yzxy, zxyz, _VECTORMATH_SHUF_XYCD ); + vmathSoaV3SetX( vec, spu_shuffle( xyxy, zxzx, _VECTORMATH_SHUF_XDZB ) ); + vmathSoaV3SetY( vec, spu_shuffle( xyxy, yzyz, _VECTORMATH_SHUF_YAWC ) ); + vmathSoaV3SetZ( vec, spu_shuffle( zxzx, yzyz, _VECTORMATH_SHUF_ZBXD ) ); +} + +static inline void vmathSoaV3StoreXYZArray( const VmathSoaVector3 *vec, vec_float4 *threeQuads ) +{ + vec_float4 xyzx, yzxy, zxyz, xyxy, zxzx, yzyz; + xyxy = spu_shuffle( vec->x, vec->y, _VECTORMATH_SHUF_XAZC ); + zxzx = spu_shuffle( vec->z, vec->x, _VECTORMATH_SHUF_ZDXB ); + yzyz = spu_shuffle( vec->y, vec->z, _VECTORMATH_SHUF_YBWD ); + xyzx = spu_shuffle( xyxy, zxzx, _VECTORMATH_SHUF_XYCD ); + yzxy = spu_shuffle( yzyz, xyxy, _VECTORMATH_SHUF_XYCD ); + zxyz = spu_shuffle( zxzx, yzyz, _VECTORMATH_SHUF_XYCD ); + threeQuads[0] = xyzx; + threeQuads[1] = yzxy; + threeQuads[2] = zxyz; +} + +static inline void vmathSoaV3StoreHalfFloats( const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1, vec_ushort8 *threeQuads ) +{ + vec_float4 xyz0[3]; + vec_float4 xyz1[3]; + vmathSoaV3StoreXYZArray( vec0, xyz0 ); + vmathSoaV3StoreXYZArray( vec1, xyz1 ); + threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); + threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); + threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); +} + +static inline void vmathSoaV3SetX( VmathSoaVector3 *result, vec_float4 _x ) +{ + result->x = _x; +} + +static inline vec_float4 vmathSoaV3GetX( const VmathSoaVector3 *vec ) +{ + return vec->x; +} + +static inline void vmathSoaV3SetY( VmathSoaVector3 *result, vec_float4 _y ) +{ + result->y = _y; +} + +static inline vec_float4 vmathSoaV3GetY( const VmathSoaVector3 *vec ) +{ + return vec->y; +} + +static inline void vmathSoaV3SetZ( VmathSoaVector3 *result, vec_float4 _z ) +{ + result->z = _z; +} + +static inline vec_float4 vmathSoaV3GetZ( const VmathSoaVector3 *vec ) +{ + return vec->z; +} + +static inline void vmathSoaV3SetElem( VmathSoaVector3 *result, int idx, vec_float4 value ) +{ + *(&result->x + idx) = value; +} + +static inline vec_float4 vmathSoaV3GetElem( const VmathSoaVector3 *vec, int idx ) +{ + return *(&vec->x + idx); +} + +static inline void vmathSoaV3Add( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) +{ + result->x = spu_add( vec0->x, vec1->x ); + result->y = spu_add( vec0->y, vec1->y ); + result->z = spu_add( vec0->z, vec1->z ); +} + +static inline void vmathSoaV3Sub( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) +{ + result->x = spu_sub( vec0->x, vec1->x ); + result->y = spu_sub( vec0->y, vec1->y ); + result->z = spu_sub( vec0->z, vec1->z ); +} + +static inline void vmathSoaV3AddP3( VmathSoaPoint3 *result, const VmathSoaVector3 *vec, const VmathSoaPoint3 *pnt1 ) +{ + result->x = spu_add( vec->x, pnt1->x ); + result->y = spu_add( vec->y, pnt1->y ); + result->z = spu_add( vec->z, pnt1->z ); +} + +static inline void vmathSoaV3ScalarMul( VmathSoaVector3 *result, const VmathSoaVector3 *vec, vec_float4 scalar ) +{ + result->x = spu_mul( vec->x, scalar ); + result->y = spu_mul( vec->y, scalar ); + result->z = spu_mul( vec->z, scalar ); +} + +static inline void vmathSoaV3ScalarDiv( VmathSoaVector3 *result, const VmathSoaVector3 *vec, vec_float4 scalar ) +{ + result->x = divf4( vec->x, scalar ); + result->y = divf4( vec->y, scalar ); + result->z = divf4( vec->z, scalar ); +} + +static inline void vmathSoaV3Neg( VmathSoaVector3 *result, const VmathSoaVector3 *vec ) +{ + result->x = negatef4( vec->x ); + result->y = negatef4( vec->y ); + result->z = negatef4( vec->z ); +} + +static inline void vmathSoaV3MulPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) +{ + result->x = spu_mul( vec0->x, vec1->x ); + result->y = spu_mul( vec0->y, vec1->y ); + result->z = spu_mul( vec0->z, vec1->z ); +} + +static inline void vmathSoaV3DivPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) +{ + result->x = divf4( vec0->x, vec1->x ); + result->y = divf4( vec0->y, vec1->y ); + result->z = divf4( vec0->z, vec1->z ); +} + +static inline void vmathSoaV3RecipPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec ) +{ + result->x = recipf4( vec->x ); + result->y = recipf4( vec->y ); + result->z = recipf4( vec->z ); +} + +static inline void vmathSoaV3SqrtPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec ) +{ + result->x = sqrtf4( vec->x ); + result->y = sqrtf4( vec->y ); + result->z = sqrtf4( vec->z ); +} + +static inline void vmathSoaV3RsqrtPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec ) +{ + result->x = rsqrtf4( vec->x ); + result->y = rsqrtf4( vec->y ); + result->z = rsqrtf4( vec->z ); +} + +static inline void vmathSoaV3AbsPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec ) +{ + result->x = fabsf4( vec->x ); + result->y = fabsf4( vec->y ); + result->z = fabsf4( vec->z ); +} + +static inline void vmathSoaV3CopySignPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) +{ + result->x = copysignf4( vec0->x, vec1->x ); + result->y = copysignf4( vec0->y, vec1->y ); + result->z = copysignf4( vec0->z, vec1->z ); +} + +static inline void vmathSoaV3MaxPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) +{ + result->x = fmaxf4( vec0->x, vec1->x ); + result->y = fmaxf4( vec0->y, vec1->y ); + result->z = fmaxf4( vec0->z, vec1->z ); +} + +static inline vec_float4 vmathSoaV3MaxElem( const VmathSoaVector3 *vec ) +{ + vec_float4 result; + result = fmaxf4( vec->x, vec->y ); + result = fmaxf4( vec->z, result ); + return result; +} + +static inline void vmathSoaV3MinPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) +{ + result->x = fminf4( vec0->x, vec1->x ); + result->y = fminf4( vec0->y, vec1->y ); + result->z = fminf4( vec0->z, vec1->z ); +} + +static inline vec_float4 vmathSoaV3MinElem( const VmathSoaVector3 *vec ) +{ + vec_float4 result; + result = fminf4( vec->x, vec->y ); + result = fminf4( vec->z, result ); + return result; +} + +static inline vec_float4 vmathSoaV3Sum( const VmathSoaVector3 *vec ) +{ + vec_float4 result; + result = spu_add( vec->x, vec->y ); + result = spu_add( result, vec->z ); + return result; +} + +static inline vec_float4 vmathSoaV3Dot( const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) +{ + vec_float4 result; + result = spu_mul( vec0->x, vec1->x ); + result = spu_add( result, spu_mul( vec0->y, vec1->y ) ); + result = spu_add( result, spu_mul( vec0->z, vec1->z ) ); + return result; +} + +static inline vec_float4 vmathSoaV3LengthSqr( const VmathSoaVector3 *vec ) +{ + vec_float4 result; + result = spu_mul( vec->x, vec->x ); + result = spu_add( result, spu_mul( vec->y, vec->y ) ); + result = spu_add( result, spu_mul( vec->z, vec->z ) ); + return result; +} + +static inline vec_float4 vmathSoaV3Length( const VmathSoaVector3 *vec ) +{ + return sqrtf4( vmathSoaV3LengthSqr( vec ) ); +} + +static inline void vmathSoaV3Normalize( VmathSoaVector3 *result, const VmathSoaVector3 *vec ) +{ + vec_float4 lenSqr, lenInv; + lenSqr = vmathSoaV3LengthSqr( vec ); + lenInv = rsqrtf4( lenSqr ); + result->x = spu_mul( vec->x, lenInv ); + result->y = spu_mul( vec->y, lenInv ); + result->z = spu_mul( vec->z, lenInv ); +} + +static inline void vmathSoaV3Cross( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) +{ + vec_float4 tmpX, tmpY, tmpZ; + tmpX = spu_sub( spu_mul( vec0->y, vec1->z ), spu_mul( vec0->z, vec1->y ) ); + tmpY = spu_sub( spu_mul( vec0->z, vec1->x ), spu_mul( vec0->x, vec1->z ) ); + tmpZ = spu_sub( spu_mul( vec0->x, vec1->y ), spu_mul( vec0->y, vec1->x ) ); + vmathSoaV3MakeFromElems( result, tmpX, tmpY, tmpZ ); +} + +static inline void vmathSoaV3Select( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1, vec_uint4 select1 ) +{ + result->x = spu_sel( vec0->x, vec1->x, select1 ); + result->y = spu_sel( vec0->y, vec1->y, select1 ); + result->z = spu_sel( vec0->z, vec1->z, select1 ); +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathSoaV3Print( const VmathSoaVector3 *vec ) +{ + VmathVector3 vec0, vec1, vec2, vec3; + vmathSoaV3Get4Aos( vec, &vec0, &vec1, &vec2, &vec3 ); + printf("slot 0:\n"); + vmathV3Print( &vec0 ); + printf("slot 1:\n"); + vmathV3Print( &vec1 ); + printf("slot 2:\n"); + vmathV3Print( &vec2 ); + printf("slot 3:\n"); + vmathV3Print( &vec3 ); +} + +static inline void vmathSoaV3Prints( const VmathSoaVector3 *vec, const char *name ) +{ + VmathVector3 vec0, vec1, vec2, vec3; + printf( "%s:\n", name ); + vmathSoaV3Get4Aos( vec, &vec0, &vec1, &vec2, &vec3 ); + printf("slot 0:\n"); + vmathV3Print( &vec0 ); + printf("slot 1:\n"); + vmathV3Print( &vec1 ); + printf("slot 2:\n"); + vmathV3Print( &vec2 ); + printf("slot 3:\n"); + vmathV3Print( &vec3 ); +} + +#endif + +static inline void vmathSoaV4Copy( VmathSoaVector4 *result, const VmathSoaVector4 *vec ) +{ + result->x = vec->x; + result->y = vec->y; + result->z = vec->z; + result->w = vec->w; +} + +static inline void vmathSoaV4MakeFromElems( VmathSoaVector4 *result, vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w ) +{ + result->x = _x; + result->y = _y; + result->z = _z; + result->w = _w; +} + +static inline void vmathSoaV4MakeFromV3Scalar( VmathSoaVector4 *result, const VmathSoaVector3 *xyz, vec_float4 _w ) +{ + vmathSoaV4SetXYZ( result, xyz ); + vmathSoaV4SetW( result, _w ); +} + +static inline void vmathSoaV4MakeFromV3( VmathSoaVector4 *result, const VmathSoaVector3 *vec ) +{ + result->x = vec->x; + result->y = vec->y; + result->z = vec->z; + result->w = spu_splats(0.0f); +} + +static inline void vmathSoaV4MakeFromP3( VmathSoaVector4 *result, const VmathSoaPoint3 *pnt ) +{ + result->x = pnt->x; + result->y = pnt->y; + result->z = pnt->z; + result->w = spu_splats(1.0f); +} + +static inline void vmathSoaV4MakeFromQ( VmathSoaVector4 *result, const VmathSoaQuat *quat ) +{ + result->x = quat->x; + result->y = quat->y; + result->z = quat->z; + result->w = quat->w; +} + +static inline void vmathSoaV4MakeFromScalar( VmathSoaVector4 *result, vec_float4 scalar ) +{ + result->x = scalar; + result->y = scalar; + result->z = scalar; + result->w = scalar; +} + +static inline void vmathSoaV4MakeFromAos( VmathSoaVector4 *result, const VmathVector4 *vec ) +{ + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); + vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f); + vec_float4 vec128 = vec->vec128; + result->x = spu_shuffle( vec128, vec128, shuffle_xxxx ); + result->y = spu_shuffle( vec128, vec128, shuffle_yyyy ); + result->z = spu_shuffle( vec128, vec128, shuffle_zzzz ); + result->w = spu_shuffle( vec128, vec128, shuffle_wwww ); +} + +static inline void vmathSoaV4MakeFrom4Aos( VmathSoaVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1, const VmathVector4 *vec2, const VmathVector4 *vec3 ) +{ + vec_float4 tmp0, tmp1, tmp2, tmp3; + tmp0 = spu_shuffle( vec0->vec128, vec2->vec128, _VECTORMATH_SHUF_XAYB ); + tmp1 = spu_shuffle( vec1->vec128, vec3->vec128, _VECTORMATH_SHUF_XAYB ); + tmp2 = spu_shuffle( vec0->vec128, vec2->vec128, _VECTORMATH_SHUF_ZCWD ); + tmp3 = spu_shuffle( vec1->vec128, vec3->vec128, _VECTORMATH_SHUF_ZCWD ); + result->x = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB ); + result->y = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD ); + result->z = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB ); + result->w = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_ZCWD ); +} + +static inline void vmathSoaV4MakeXAxis( VmathSoaVector4 *result ) +{ + vmathSoaV4MakeFromElems( result, spu_splats(1.0f), spu_splats(0.0f), spu_splats(0.0f), spu_splats(0.0f) ); +} + +static inline void vmathSoaV4MakeYAxis( VmathSoaVector4 *result ) +{ + vmathSoaV4MakeFromElems( result, spu_splats(0.0f), spu_splats(1.0f), spu_splats(0.0f), spu_splats(0.0f) ); +} + +static inline void vmathSoaV4MakeZAxis( VmathSoaVector4 *result ) +{ + vmathSoaV4MakeFromElems( result, spu_splats(0.0f), spu_splats(0.0f), spu_splats(1.0f), spu_splats(0.0f) ); +} + +static inline void vmathSoaV4MakeWAxis( VmathSoaVector4 *result ) +{ + vmathSoaV4MakeFromElems( result, spu_splats(0.0f), spu_splats(0.0f), spu_splats(0.0f), spu_splats(1.0f) ); +} + +static inline void vmathSoaV4Lerp( VmathSoaVector4 *result, vec_float4 t, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ) +{ + VmathSoaVector4 tmpV4_0, tmpV4_1; + vmathSoaV4Sub( &tmpV4_0, vec1, vec0 ); + vmathSoaV4ScalarMul( &tmpV4_1, &tmpV4_0, t ); + vmathSoaV4Add( result, vec0, &tmpV4_1 ); +} + +static inline void vmathSoaV4Slerp( VmathSoaVector4 *result, vec_float4 t, const VmathSoaVector4 *unitVec0, const VmathSoaVector4 *unitVec1 ) +{ + VmathSoaVector4 tmpV4_0, tmpV4_1; + vec_float4 recipSinAngle, scale0, scale1, cosAngle, angle; + vec_uint4 selectMask; + cosAngle = vmathSoaV4Dot( unitVec0, unitVec1 ); + selectMask = (vec_uint4)spu_cmpgt( spu_splats(_VECTORMATH_SLERP_TOL), cosAngle ); + angle = acosf4( cosAngle ); + recipSinAngle = recipf4( sinf4( angle ) ); + scale0 = spu_sel( spu_sub( spu_splats(1.0f), t ), spu_mul( sinf4( spu_mul( spu_sub( spu_splats(1.0f), t ), angle ) ), recipSinAngle ), selectMask ); + scale1 = spu_sel( t, spu_mul( sinf4( spu_mul( t, angle ) ), recipSinAngle ), selectMask ); + vmathSoaV4ScalarMul( &tmpV4_0, unitVec0, scale0 ); + vmathSoaV4ScalarMul( &tmpV4_1, unitVec1, scale1 ); + vmathSoaV4Add( result, &tmpV4_0, &tmpV4_1 ); +} + +static inline void vmathSoaV4Get4Aos( const VmathSoaVector4 *vec, VmathVector4 *result0, VmathVector4 *result1, VmathVector4 *result2, VmathVector4 *result3 ) +{ + vec_float4 tmp0, tmp1, tmp2, tmp3; + tmp0 = spu_shuffle( vec->x, vec->z, _VECTORMATH_SHUF_XAYB ); + tmp1 = spu_shuffle( vec->y, vec->w, _VECTORMATH_SHUF_XAYB ); + tmp2 = spu_shuffle( vec->x, vec->z, _VECTORMATH_SHUF_ZCWD ); + tmp3 = spu_shuffle( vec->y, vec->w, _VECTORMATH_SHUF_ZCWD ); + vmathV4MakeFrom128( result0, spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB ) ); + vmathV4MakeFrom128( result1, spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD ) ); + vmathV4MakeFrom128( result2, spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB ) ); + vmathV4MakeFrom128( result3, spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_ZCWD ) ); +} + +static inline void vmathSoaV4StoreHalfFloats( const VmathSoaVector4 *vec, vec_ushort8 *twoQuads ) +{ + VmathVector4 v0, v1, v2, v3; + vmathSoaV4Get4Aos( vec, &v0, &v1, &v2, &v3 ); + twoQuads[0] = _vmath2VfToHalfFloats(v0.vec128, v1.vec128); + twoQuads[1] = _vmath2VfToHalfFloats(v2.vec128, v3.vec128); +} + +static inline void vmathSoaV4SetXYZ( VmathSoaVector4 *result, const VmathSoaVector3 *vec ) +{ + result->x = vec->x; + result->y = vec->y; + result->z = vec->z; +} + +static inline void vmathSoaV4GetXYZ( VmathSoaVector3 *result, const VmathSoaVector4 *vec ) +{ + vmathSoaV3MakeFromElems( result, vec->x, vec->y, vec->z ); +} + +static inline void vmathSoaV4SetX( VmathSoaVector4 *result, vec_float4 _x ) +{ + result->x = _x; +} + +static inline vec_float4 vmathSoaV4GetX( const VmathSoaVector4 *vec ) +{ + return vec->x; +} + +static inline void vmathSoaV4SetY( VmathSoaVector4 *result, vec_float4 _y ) +{ + result->y = _y; +} + +static inline vec_float4 vmathSoaV4GetY( const VmathSoaVector4 *vec ) +{ + return vec->y; +} + +static inline void vmathSoaV4SetZ( VmathSoaVector4 *result, vec_float4 _z ) +{ + result->z = _z; +} + +static inline vec_float4 vmathSoaV4GetZ( const VmathSoaVector4 *vec ) +{ + return vec->z; +} + +static inline void vmathSoaV4SetW( VmathSoaVector4 *result, vec_float4 _w ) +{ + result->w = _w; +} + +static inline vec_float4 vmathSoaV4GetW( const VmathSoaVector4 *vec ) +{ + return vec->w; +} + +static inline void vmathSoaV4SetElem( VmathSoaVector4 *result, int idx, vec_float4 value ) +{ + *(&result->x + idx) = value; +} + +static inline vec_float4 vmathSoaV4GetElem( const VmathSoaVector4 *vec, int idx ) +{ + return *(&vec->x + idx); +} + +static inline void vmathSoaV4Add( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ) +{ + result->x = spu_add( vec0->x, vec1->x ); + result->y = spu_add( vec0->y, vec1->y ); + result->z = spu_add( vec0->z, vec1->z ); + result->w = spu_add( vec0->w, vec1->w ); +} + +static inline void vmathSoaV4Sub( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ) +{ + result->x = spu_sub( vec0->x, vec1->x ); + result->y = spu_sub( vec0->y, vec1->y ); + result->z = spu_sub( vec0->z, vec1->z ); + result->w = spu_sub( vec0->w, vec1->w ); +} + +static inline void vmathSoaV4ScalarMul( VmathSoaVector4 *result, const VmathSoaVector4 *vec, vec_float4 scalar ) +{ + result->x = spu_mul( vec->x, scalar ); + result->y = spu_mul( vec->y, scalar ); + result->z = spu_mul( vec->z, scalar ); + result->w = spu_mul( vec->w, scalar ); +} + +static inline void vmathSoaV4ScalarDiv( VmathSoaVector4 *result, const VmathSoaVector4 *vec, vec_float4 scalar ) +{ + result->x = divf4( vec->x, scalar ); + result->y = divf4( vec->y, scalar ); + result->z = divf4( vec->z, scalar ); + result->w = divf4( vec->w, scalar ); +} + +static inline void vmathSoaV4Neg( VmathSoaVector4 *result, const VmathSoaVector4 *vec ) +{ + result->x = negatef4( vec->x ); + result->y = negatef4( vec->y ); + result->z = negatef4( vec->z ); + result->w = negatef4( vec->w ); +} + +static inline void vmathSoaV4MulPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ) +{ + result->x = spu_mul( vec0->x, vec1->x ); + result->y = spu_mul( vec0->y, vec1->y ); + result->z = spu_mul( vec0->z, vec1->z ); + result->w = spu_mul( vec0->w, vec1->w ); +} + +static inline void vmathSoaV4DivPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ) +{ + result->x = divf4( vec0->x, vec1->x ); + result->y = divf4( vec0->y, vec1->y ); + result->z = divf4( vec0->z, vec1->z ); + result->w = divf4( vec0->w, vec1->w ); +} + +static inline void vmathSoaV4RecipPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec ) +{ + result->x = recipf4( vec->x ); + result->y = recipf4( vec->y ); + result->z = recipf4( vec->z ); + result->w = recipf4( vec->w ); +} + +static inline void vmathSoaV4SqrtPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec ) +{ + result->x = sqrtf4( vec->x ); + result->y = sqrtf4( vec->y ); + result->z = sqrtf4( vec->z ); + result->w = sqrtf4( vec->w ); +} + +static inline void vmathSoaV4RsqrtPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec ) +{ + result->x = rsqrtf4( vec->x ); + result->y = rsqrtf4( vec->y ); + result->z = rsqrtf4( vec->z ); + result->w = rsqrtf4( vec->w ); +} + +static inline void vmathSoaV4AbsPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec ) +{ + result->x = fabsf4( vec->x ); + result->y = fabsf4( vec->y ); + result->z = fabsf4( vec->z ); + result->w = fabsf4( vec->w ); +} + +static inline void vmathSoaV4CopySignPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ) +{ + result->x = copysignf4( vec0->x, vec1->x ); + result->y = copysignf4( vec0->y, vec1->y ); + result->z = copysignf4( vec0->z, vec1->z ); + result->w = copysignf4( vec0->w, vec1->w ); +} + +static inline void vmathSoaV4MaxPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ) +{ + result->x = fmaxf4( vec0->x, vec1->x ); + result->y = fmaxf4( vec0->y, vec1->y ); + result->z = fmaxf4( vec0->z, vec1->z ); + result->w = fmaxf4( vec0->w, vec1->w ); +} + +static inline vec_float4 vmathSoaV4MaxElem( const VmathSoaVector4 *vec ) +{ + vec_float4 result; + result = fmaxf4( vec->x, vec->y ); + result = fmaxf4( vec->z, result ); + result = fmaxf4( vec->w, result ); + return result; +} + +static inline void vmathSoaV4MinPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ) +{ + result->x = fminf4( vec0->x, vec1->x ); + result->y = fminf4( vec0->y, vec1->y ); + result->z = fminf4( vec0->z, vec1->z ); + result->w = fminf4( vec0->w, vec1->w ); +} + +static inline vec_float4 vmathSoaV4MinElem( const VmathSoaVector4 *vec ) +{ + vec_float4 result; + result = fminf4( vec->x, vec->y ); + result = fminf4( vec->z, result ); + result = fminf4( vec->w, result ); + return result; +} + +static inline vec_float4 vmathSoaV4Sum( const VmathSoaVector4 *vec ) +{ + vec_float4 result; + result = spu_add( vec->x, vec->y ); + result = spu_add( result, vec->z ); + result = spu_add( result, vec->w ); + return result; +} + +static inline vec_float4 vmathSoaV4Dot( const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ) +{ + vec_float4 result; + result = spu_mul( vec0->x, vec1->x ); + result = spu_add( result, spu_mul( vec0->y, vec1->y ) ); + result = spu_add( result, spu_mul( vec0->z, vec1->z ) ); + result = spu_add( result, spu_mul( vec0->w, vec1->w ) ); + return result; +} + +static inline vec_float4 vmathSoaV4LengthSqr( const VmathSoaVector4 *vec ) +{ + vec_float4 result; + result = spu_mul( vec->x, vec->x ); + result = spu_add( result, spu_mul( vec->y, vec->y ) ); + result = spu_add( result, spu_mul( vec->z, vec->z ) ); + result = spu_add( result, spu_mul( vec->w, vec->w ) ); + return result; +} + +static inline vec_float4 vmathSoaV4Length( const VmathSoaVector4 *vec ) +{ + return sqrtf4( vmathSoaV4LengthSqr( vec ) ); +} + +static inline void vmathSoaV4Normalize( VmathSoaVector4 *result, const VmathSoaVector4 *vec ) +{ + vec_float4 lenSqr, lenInv; + lenSqr = vmathSoaV4LengthSqr( vec ); + lenInv = rsqrtf4( lenSqr ); + result->x = spu_mul( vec->x, lenInv ); + result->y = spu_mul( vec->y, lenInv ); + result->z = spu_mul( vec->z, lenInv ); + result->w = spu_mul( vec->w, lenInv ); +} + +static inline void vmathSoaV4Select( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1, vec_uint4 select1 ) +{ + result->x = spu_sel( vec0->x, vec1->x, select1 ); + result->y = spu_sel( vec0->y, vec1->y, select1 ); + result->z = spu_sel( vec0->z, vec1->z, select1 ); + result->w = spu_sel( vec0->w, vec1->w, select1 ); +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathSoaV4Print( const VmathSoaVector4 *vec ) +{ + VmathVector4 vec0, vec1, vec2, vec3; + vmathSoaV4Get4Aos( vec, &vec0, &vec1, &vec2, &vec3 ); + printf("slot 0:\n"); + vmathV4Print( &vec0 ); + printf("slot 1:\n"); + vmathV4Print( &vec1 ); + printf("slot 2:\n"); + vmathV4Print( &vec2 ); + printf("slot 3:\n"); + vmathV4Print( &vec3 ); +} + +static inline void vmathSoaV4Prints( const VmathSoaVector4 *vec, const char *name ) +{ + VmathVector4 vec0, vec1, vec2, vec3; + printf( "%s:\n", name ); + vmathSoaV4Get4Aos( vec, &vec0, &vec1, &vec2, &vec3 ); + printf("slot 0:\n"); + vmathV4Print( &vec0 ); + printf("slot 1:\n"); + vmathV4Print( &vec1 ); + printf("slot 2:\n"); + vmathV4Print( &vec2 ); + printf("slot 3:\n"); + vmathV4Print( &vec3 ); +} + +#endif + +static inline void vmathSoaP3Copy( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ) +{ + result->x = pnt->x; + result->y = pnt->y; + result->z = pnt->z; +} + +static inline void vmathSoaP3MakeFromElems( VmathSoaPoint3 *result, vec_float4 _x, vec_float4 _y, vec_float4 _z ) +{ + result->x = _x; + result->y = _y; + result->z = _z; +} + +static inline void vmathSoaP3MakeFromV3( VmathSoaPoint3 *result, const VmathSoaVector3 *vec ) +{ + result->x = vec->x; + result->y = vec->y; + result->z = vec->z; +} + +static inline void vmathSoaP3MakeFromScalar( VmathSoaPoint3 *result, vec_float4 scalar ) +{ + result->x = scalar; + result->y = scalar; + result->z = scalar; +} + +static inline void vmathSoaP3MakeFromAos( VmathSoaPoint3 *result, const VmathPoint3 *pnt ) +{ + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); + vec_float4 vec128 = pnt->vec128; + result->x = spu_shuffle( vec128, vec128, shuffle_xxxx ); + result->y = spu_shuffle( vec128, vec128, shuffle_yyyy ); + result->z = spu_shuffle( vec128, vec128, shuffle_zzzz ); +} + +static inline void vmathSoaP3MakeFrom4Aos( VmathSoaPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, const VmathPoint3 *pnt2, const VmathPoint3 *pnt3 ) +{ + vec_float4 tmp0, tmp1, tmp2, tmp3; + tmp0 = spu_shuffle( pnt0->vec128, pnt2->vec128, _VECTORMATH_SHUF_XAYB ); + tmp1 = spu_shuffle( pnt1->vec128, pnt3->vec128, _VECTORMATH_SHUF_XAYB ); + tmp2 = spu_shuffle( pnt0->vec128, pnt2->vec128, _VECTORMATH_SHUF_ZCWD ); + tmp3 = spu_shuffle( pnt1->vec128, pnt3->vec128, _VECTORMATH_SHUF_ZCWD ); + result->x = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB ); + result->y = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD ); + result->z = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB ); +} + +static inline void vmathSoaP3Lerp( VmathSoaPoint3 *result, vec_float4 t, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ) +{ + VmathSoaVector3 tmpV3_0, tmpV3_1; + vmathSoaP3Sub( &tmpV3_0, pnt1, pnt0 ); + vmathSoaV3ScalarMul( &tmpV3_1, &tmpV3_0, t ); + vmathSoaP3AddV3( result, pnt0, &tmpV3_1 ); +} + +static inline void vmathSoaP3Get4Aos( const VmathSoaPoint3 *pnt, VmathPoint3 *result0, VmathPoint3 *result1, VmathPoint3 *result2, VmathPoint3 *result3 ) +{ + vec_float4 tmp0, tmp1; + tmp0 = spu_shuffle( pnt->x, pnt->z, _VECTORMATH_SHUF_XAYB ); + tmp1 = spu_shuffle( pnt->x, pnt->z, _VECTORMATH_SHUF_ZCWD ); + vmathP3MakeFrom128( result0, spu_shuffle( tmp0, pnt->y, _VECTORMATH_SHUF_XAYB ) ); + vmathP3MakeFrom128( result1, spu_shuffle( tmp0, pnt->y, _VECTORMATH_SHUF_ZBW0 ) ); + vmathP3MakeFrom128( result2, spu_shuffle( tmp1, pnt->y, _VECTORMATH_SHUF_XCY0 ) ); + vmathP3MakeFrom128( result3, spu_shuffle( tmp1, pnt->y, _VECTORMATH_SHUF_ZDW0 ) ); +} + +static inline void vmathSoaP3LoadXYZArray( VmathSoaPoint3 *vec, const vec_float4 *threeQuads ) +{ + vec_float4 xyxy, yzyz, zxzx, xyzx, yzxy, zxyz; + xyzx = threeQuads[0]; + yzxy = threeQuads[1]; + zxyz = threeQuads[2]; + xyxy = spu_shuffle( xyzx, yzxy, _VECTORMATH_SHUF_XYCD ); + zxzx = spu_shuffle( zxyz, xyzx, _VECTORMATH_SHUF_XYCD ); + yzyz = spu_shuffle( yzxy, zxyz, _VECTORMATH_SHUF_XYCD ); + vmathSoaP3SetX( vec, spu_shuffle( xyxy, zxzx, _VECTORMATH_SHUF_XDZB ) ); + vmathSoaP3SetY( vec, spu_shuffle( xyxy, yzyz, _VECTORMATH_SHUF_YAWC ) ); + vmathSoaP3SetZ( vec, spu_shuffle( zxzx, yzyz, _VECTORMATH_SHUF_ZBXD ) ); +} + +static inline void vmathSoaP3StoreXYZArray( const VmathSoaPoint3 *vec, vec_float4 *threeQuads ) +{ + vec_float4 xyzx, yzxy, zxyz, xyxy, zxzx, yzyz; + xyxy = spu_shuffle( vec->x, vec->y, _VECTORMATH_SHUF_XAZC ); + zxzx = spu_shuffle( vec->z, vec->x, _VECTORMATH_SHUF_ZDXB ); + yzyz = spu_shuffle( vec->y, vec->z, _VECTORMATH_SHUF_YBWD ); + xyzx = spu_shuffle( xyxy, zxzx, _VECTORMATH_SHUF_XYCD ); + yzxy = spu_shuffle( yzyz, xyxy, _VECTORMATH_SHUF_XYCD ); + zxyz = spu_shuffle( zxzx, yzyz, _VECTORMATH_SHUF_XYCD ); + threeQuads[0] = xyzx; + threeQuads[1] = yzxy; + threeQuads[2] = zxyz; +} + +static inline void vmathSoaP3StoreHalfFloats( const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1, vec_ushort8 *threeQuads ) +{ + vec_float4 xyz0[3]; + vec_float4 xyz1[3]; + vmathSoaP3StoreXYZArray( pnt0, xyz0 ); + vmathSoaP3StoreXYZArray( pnt1, xyz1 ); + threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); + threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); + threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); +} + +static inline void vmathSoaP3SetX( VmathSoaPoint3 *result, vec_float4 _x ) +{ + result->x = _x; +} + +static inline vec_float4 vmathSoaP3GetX( const VmathSoaPoint3 *pnt ) +{ + return pnt->x; +} + +static inline void vmathSoaP3SetY( VmathSoaPoint3 *result, vec_float4 _y ) +{ + result->y = _y; +} + +static inline vec_float4 vmathSoaP3GetY( const VmathSoaPoint3 *pnt ) +{ + return pnt->y; +} + +static inline void vmathSoaP3SetZ( VmathSoaPoint3 *result, vec_float4 _z ) +{ + result->z = _z; +} + +static inline vec_float4 vmathSoaP3GetZ( const VmathSoaPoint3 *pnt ) +{ + return pnt->z; +} + +static inline void vmathSoaP3SetElem( VmathSoaPoint3 *result, int idx, vec_float4 value ) +{ + *(&result->x + idx) = value; +} + +static inline vec_float4 vmathSoaP3GetElem( const VmathSoaPoint3 *pnt, int idx ) +{ + return *(&pnt->x + idx); +} + +static inline void vmathSoaP3Sub( VmathSoaVector3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ) +{ + result->x = spu_sub( pnt0->x, pnt1->x ); + result->y = spu_sub( pnt0->y, pnt1->y ); + result->z = spu_sub( pnt0->z, pnt1->z ); +} + +static inline void vmathSoaP3AddV3( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt, const VmathSoaVector3 *vec1 ) +{ + result->x = spu_add( pnt->x, vec1->x ); + result->y = spu_add( pnt->y, vec1->y ); + result->z = spu_add( pnt->z, vec1->z ); +} + +static inline void vmathSoaP3SubV3( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt, const VmathSoaVector3 *vec1 ) +{ + result->x = spu_sub( pnt->x, vec1->x ); + result->y = spu_sub( pnt->y, vec1->y ); + result->z = spu_sub( pnt->z, vec1->z ); +} + +static inline void vmathSoaP3MulPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ) +{ + result->x = spu_mul( pnt0->x, pnt1->x ); + result->y = spu_mul( pnt0->y, pnt1->y ); + result->z = spu_mul( pnt0->z, pnt1->z ); +} + +static inline void vmathSoaP3DivPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ) +{ + result->x = divf4( pnt0->x, pnt1->x ); + result->y = divf4( pnt0->y, pnt1->y ); + result->z = divf4( pnt0->z, pnt1->z ); +} + +static inline void vmathSoaP3RecipPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ) +{ + result->x = recipf4( pnt->x ); + result->y = recipf4( pnt->y ); + result->z = recipf4( pnt->z ); +} + +static inline void vmathSoaP3SqrtPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ) +{ + result->x = sqrtf4( pnt->x ); + result->y = sqrtf4( pnt->y ); + result->z = sqrtf4( pnt->z ); +} + +static inline void vmathSoaP3RsqrtPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ) +{ + result->x = rsqrtf4( pnt->x ); + result->y = rsqrtf4( pnt->y ); + result->z = rsqrtf4( pnt->z ); +} + +static inline void vmathSoaP3AbsPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ) +{ + result->x = fabsf4( pnt->x ); + result->y = fabsf4( pnt->y ); + result->z = fabsf4( pnt->z ); +} + +static inline void vmathSoaP3CopySignPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ) +{ + result->x = copysignf4( pnt0->x, pnt1->x ); + result->y = copysignf4( pnt0->y, pnt1->y ); + result->z = copysignf4( pnt0->z, pnt1->z ); +} + +static inline void vmathSoaP3MaxPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ) +{ + result->x = fmaxf4( pnt0->x, pnt1->x ); + result->y = fmaxf4( pnt0->y, pnt1->y ); + result->z = fmaxf4( pnt0->z, pnt1->z ); +} + +static inline vec_float4 vmathSoaP3MaxElem( const VmathSoaPoint3 *pnt ) +{ + vec_float4 result; + result = fmaxf4( pnt->x, pnt->y ); + result = fmaxf4( pnt->z, result ); + return result; +} + +static inline void vmathSoaP3MinPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ) +{ + result->x = fminf4( pnt0->x, pnt1->x ); + result->y = fminf4( pnt0->y, pnt1->y ); + result->z = fminf4( pnt0->z, pnt1->z ); +} + +static inline vec_float4 vmathSoaP3MinElem( const VmathSoaPoint3 *pnt ) +{ + vec_float4 result; + result = fminf4( pnt->x, pnt->y ); + result = fminf4( pnt->z, result ); + return result; +} + +static inline vec_float4 vmathSoaP3Sum( const VmathSoaPoint3 *pnt ) +{ + vec_float4 result; + result = spu_add( pnt->x, pnt->y ); + result = spu_add( result, pnt->z ); + return result; +} + +static inline void vmathSoaP3Scale( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt, vec_float4 scaleVal ) +{ + VmathSoaPoint3 tmpP3_0; + vmathSoaP3MakeFromScalar( &tmpP3_0, scaleVal ); + vmathSoaP3MulPerElem( result, pnt, &tmpP3_0 ); +} + +static inline void vmathSoaP3NonUniformScale( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt, const VmathSoaVector3 *scaleVec ) +{ + VmathSoaPoint3 tmpP3_0; + vmathSoaP3MakeFromV3( &tmpP3_0, scaleVec ); + vmathSoaP3MulPerElem( result, pnt, &tmpP3_0 ); +} + +static inline vec_float4 vmathSoaP3Projection( const VmathSoaPoint3 *pnt, const VmathSoaVector3 *unitVec ) +{ + vec_float4 result; + result = spu_mul( pnt->x, unitVec->x ); + result = spu_add( result, spu_mul( pnt->y, unitVec->y ) ); + result = spu_add( result, spu_mul( pnt->z, unitVec->z ) ); + return result; +} + +static inline vec_float4 vmathSoaP3DistSqrFromOrigin( const VmathSoaPoint3 *pnt ) +{ + VmathSoaVector3 tmpV3_0; + vmathSoaV3MakeFromP3( &tmpV3_0, pnt ); + return vmathSoaV3LengthSqr( &tmpV3_0 ); +} + +static inline vec_float4 vmathSoaP3DistFromOrigin( const VmathSoaPoint3 *pnt ) +{ + VmathSoaVector3 tmpV3_0; + vmathSoaV3MakeFromP3( &tmpV3_0, pnt ); + return vmathSoaV3Length( &tmpV3_0 ); +} + +static inline vec_float4 vmathSoaP3DistSqr( const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ) +{ + VmathSoaVector3 tmpV3_0; + vmathSoaP3Sub( &tmpV3_0, pnt1, pnt0 ); + return vmathSoaV3LengthSqr( &tmpV3_0 ); +} + +static inline vec_float4 vmathSoaP3Dist( const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ) +{ + VmathSoaVector3 tmpV3_0; + vmathSoaP3Sub( &tmpV3_0, pnt1, pnt0 ); + return vmathSoaV3Length( &tmpV3_0 ); +} + +static inline void vmathSoaP3Select( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1, vec_uint4 select1 ) +{ + result->x = spu_sel( pnt0->x, pnt1->x, select1 ); + result->y = spu_sel( pnt0->y, pnt1->y, select1 ); + result->z = spu_sel( pnt0->z, pnt1->z, select1 ); +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathSoaP3Print( const VmathSoaPoint3 *pnt ) +{ + VmathPoint3 vec0, vec1, vec2, vec3; + vmathSoaP3Get4Aos( pnt, &vec0, &vec1, &vec2, &vec3 ); + printf("slot 0:\n"); + vmathP3Print( &vec0 ); + printf("slot 1:\n"); + vmathP3Print( &vec1 ); + printf("slot 2:\n"); + vmathP3Print( &vec2 ); + printf("slot 3:\n"); + vmathP3Print( &vec3 ); +} + +static inline void vmathSoaP3Prints( const VmathSoaPoint3 *pnt, const char *name ) +{ + VmathPoint3 vec0, vec1, vec2, vec3; + printf( "%s:\n", name ); + vmathSoaP3Get4Aos( pnt, &vec0, &vec1, &vec2, &vec3 ); + printf("slot 0:\n"); + vmathP3Print( &vec0 ); + printf("slot 1:\n"); + vmathP3Print( &vec1 ); + printf("slot 2:\n"); + vmathP3Print( &vec2 ); + printf("slot 3:\n"); + vmathP3Print( &vec3 ); +} + +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/vectormathlibrary/include/vectormath/spu/c/vec_soa_v.h b/vectormathlibrary/include/vectormath/spu/c/vec_soa_v.h new file mode 100644 index 000000000..560356a77 --- /dev/null +++ b/vectormathlibrary/include/vectormath/spu/c/vec_soa_v.h @@ -0,0 +1,962 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_VEC_SOA_V_C_H +#define _VECTORMATH_VEC_SOA_V_C_H +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/*----------------------------------------------------------------------------- + * Constants + * for shuffles, words are labeled [x,y,z,w] [a,b,c,d] + */ +#define _VECTORMATH_SHUF_X 0x00010203 +#define _VECTORMATH_SHUF_Y 0x04050607 +#define _VECTORMATH_SHUF_Z 0x08090a0b +#define _VECTORMATH_SHUF_W 0x0c0d0e0f +#define _VECTORMATH_SHUF_A 0x10111213 +#define _VECTORMATH_SHUF_B 0x14151617 +#define _VECTORMATH_SHUF_C 0x18191a1b +#define _VECTORMATH_SHUF_D 0x1c1d1e1f +#define _VECTORMATH_SHUF_0 0x80808080 +#define _VECTORMATH_SHUF_XAYB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_B }) +#define _VECTORMATH_SHUF_ZCWD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_D }) +#define _VECTORMATH_SHUF_ZBW0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_0 }) +#define _VECTORMATH_SHUF_XCY0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_0 }) +#define _VECTORMATH_SHUF_ZDW0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_D, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_0 }) +#define _VECTORMATH_SHUF_XAZC ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_C }) +#define _VECTORMATH_SHUF_ZDXB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_D, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_B }) +#define _VECTORMATH_SHUF_YBWD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_D }) +#define _VECTORMATH_SHUF_XDZB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_D, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_B }) +#define _VECTORMATH_SHUF_YAWC ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_C }) +#define _VECTORMATH_SHUF_ZBXD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_D }) +#define _VECTORMATH_SHUF_XYCD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_D }) +#define _VECTORMATH_SLERP_TOL 0.999f + +/*----------------------------------------------------------------------------- + * Definitions + */ +#ifndef _VECTORMATH_INTERNAL_FUNCTIONS +#define _VECTORMATH_INTERNAL_FUNCTIONS + +#endif + +static inline VmathSoaVector3 vmathSoaV3MakeFromElems_V( vec_float4 _x, vec_float4 _y, vec_float4 _z ) +{ + VmathSoaVector3 result; + vmathSoaV3MakeFromElems(&result, _x, _y, _z); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3MakeFromP3_V( VmathSoaPoint3 pnt ) +{ + VmathSoaVector3 result; + vmathSoaV3MakeFromP3(&result, &pnt); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3MakeFromScalar_V( vec_float4 scalar ) +{ + VmathSoaVector3 result; + vmathSoaV3MakeFromScalar(&result, scalar); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3MakeFromAos_V( VmathVector3 vec ) +{ + VmathSoaVector3 result; + vmathSoaV3MakeFromAos(&result, &vec); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3MakeFrom4Aos_V( VmathVector3 vec0, VmathVector3 vec1, VmathVector3 vec2, VmathVector3 vec3 ) +{ + VmathSoaVector3 result; + vmathSoaV3MakeFrom4Aos(&result, &vec0, &vec1, &vec2, &vec3); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3MakeXAxis_V( ) +{ + VmathSoaVector3 result; + vmathSoaV3MakeXAxis(&result); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3MakeYAxis_V( ) +{ + VmathSoaVector3 result; + vmathSoaV3MakeYAxis(&result); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3MakeZAxis_V( ) +{ + VmathSoaVector3 result; + vmathSoaV3MakeZAxis(&result); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3Lerp_V( vec_float4 t, VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) +{ + VmathSoaVector3 result; + vmathSoaV3Lerp(&result, t, &vec0, &vec1); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3Slerp_V( vec_float4 t, VmathSoaVector3 unitVec0, VmathSoaVector3 unitVec1 ) +{ + VmathSoaVector3 result; + vmathSoaV3Slerp(&result, t, &unitVec0, &unitVec1); + return result; +} + +static inline void vmathSoaV3Get4Aos_V( VmathSoaVector3 vec, VmathVector3 *result0, VmathVector3 *result1, VmathVector3 *result2, VmathVector3 *result3 ) +{ + vmathSoaV3Get4Aos(&vec, result0, result1, result2, result3); +} + +static inline void vmathSoaV3LoadXYZArray_V( VmathSoaVector3 *vec, const vec_float4 *threeQuads ) +{ + vmathSoaV3LoadXYZArray(vec, threeQuads); +} + +static inline void vmathSoaV3StoreXYZArray_V( VmathSoaVector3 vec, vec_float4 *threeQuads ) +{ + vmathSoaV3StoreXYZArray(&vec, threeQuads); +} + +static inline void vmathSoaV3StoreHalfFloats_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1, vec_ushort8 *threeQuads ) +{ + vmathSoaV3StoreHalfFloats(&vec0, &vec1, threeQuads); +} + +static inline void vmathSoaV3SetX_V( VmathSoaVector3 *result, vec_float4 _x ) +{ + vmathSoaV3SetX(result, _x); +} + +static inline vec_float4 vmathSoaV3GetX_V( VmathSoaVector3 vec ) +{ + return vmathSoaV3GetX(&vec); +} + +static inline void vmathSoaV3SetY_V( VmathSoaVector3 *result, vec_float4 _y ) +{ + vmathSoaV3SetY(result, _y); +} + +static inline vec_float4 vmathSoaV3GetY_V( VmathSoaVector3 vec ) +{ + return vmathSoaV3GetY(&vec); +} + +static inline void vmathSoaV3SetZ_V( VmathSoaVector3 *result, vec_float4 _z ) +{ + vmathSoaV3SetZ(result, _z); +} + +static inline vec_float4 vmathSoaV3GetZ_V( VmathSoaVector3 vec ) +{ + return vmathSoaV3GetZ(&vec); +} + +static inline void vmathSoaV3SetElem_V( VmathSoaVector3 *result, int idx, vec_float4 value ) +{ + vmathSoaV3SetElem(result, idx, value); +} + +static inline vec_float4 vmathSoaV3GetElem_V( VmathSoaVector3 vec, int idx ) +{ + return vmathSoaV3GetElem(&vec, idx); +} + +static inline VmathSoaVector3 vmathSoaV3Add_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) +{ + VmathSoaVector3 result; + vmathSoaV3Add(&result, &vec0, &vec1); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3Sub_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) +{ + VmathSoaVector3 result; + vmathSoaV3Sub(&result, &vec0, &vec1); + return result; +} + +static inline VmathSoaPoint3 vmathSoaV3AddP3_V( VmathSoaVector3 vec, VmathSoaPoint3 pnt1 ) +{ + VmathSoaPoint3 result; + vmathSoaV3AddP3(&result, &vec, &pnt1); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3ScalarMul_V( VmathSoaVector3 vec, vec_float4 scalar ) +{ + VmathSoaVector3 result; + vmathSoaV3ScalarMul(&result, &vec, scalar); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3ScalarDiv_V( VmathSoaVector3 vec, vec_float4 scalar ) +{ + VmathSoaVector3 result; + vmathSoaV3ScalarDiv(&result, &vec, scalar); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3Neg_V( VmathSoaVector3 vec ) +{ + VmathSoaVector3 result; + vmathSoaV3Neg(&result, &vec); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3MulPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) +{ + VmathSoaVector3 result; + vmathSoaV3MulPerElem(&result, &vec0, &vec1); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3DivPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) +{ + VmathSoaVector3 result; + vmathSoaV3DivPerElem(&result, &vec0, &vec1); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3RecipPerElem_V( VmathSoaVector3 vec ) +{ + VmathSoaVector3 result; + vmathSoaV3RecipPerElem(&result, &vec); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3SqrtPerElem_V( VmathSoaVector3 vec ) +{ + VmathSoaVector3 result; + vmathSoaV3SqrtPerElem(&result, &vec); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3RsqrtPerElem_V( VmathSoaVector3 vec ) +{ + VmathSoaVector3 result; + vmathSoaV3RsqrtPerElem(&result, &vec); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3AbsPerElem_V( VmathSoaVector3 vec ) +{ + VmathSoaVector3 result; + vmathSoaV3AbsPerElem(&result, &vec); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3CopySignPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) +{ + VmathSoaVector3 result; + vmathSoaV3CopySignPerElem(&result, &vec0, &vec1); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3MaxPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) +{ + VmathSoaVector3 result; + vmathSoaV3MaxPerElem(&result, &vec0, &vec1); + return result; +} + +static inline vec_float4 vmathSoaV3MaxElem_V( VmathSoaVector3 vec ) +{ + return vmathSoaV3MaxElem(&vec); +} + +static inline VmathSoaVector3 vmathSoaV3MinPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) +{ + VmathSoaVector3 result; + vmathSoaV3MinPerElem(&result, &vec0, &vec1); + return result; +} + +static inline vec_float4 vmathSoaV3MinElem_V( VmathSoaVector3 vec ) +{ + return vmathSoaV3MinElem(&vec); +} + +static inline vec_float4 vmathSoaV3Sum_V( VmathSoaVector3 vec ) +{ + return vmathSoaV3Sum(&vec); +} + +static inline vec_float4 vmathSoaV3Dot_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) +{ + return vmathSoaV3Dot(&vec0, &vec1); +} + +static inline vec_float4 vmathSoaV3LengthSqr_V( VmathSoaVector3 vec ) +{ + return vmathSoaV3LengthSqr(&vec); +} + +static inline vec_float4 vmathSoaV3Length_V( VmathSoaVector3 vec ) +{ + return vmathSoaV3Length(&vec); +} + +static inline VmathSoaVector3 vmathSoaV3Normalize_V( VmathSoaVector3 vec ) +{ + VmathSoaVector3 result; + vmathSoaV3Normalize(&result, &vec); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3Cross_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) +{ + VmathSoaVector3 result; + vmathSoaV3Cross(&result, &vec0, &vec1); + return result; +} + +static inline VmathSoaVector3 vmathSoaV3Select_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1, vec_uint4 select1 ) +{ + VmathSoaVector3 result; + vmathSoaV3Select(&result, &vec0, &vec1, select1); + return result; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathSoaV3Print_V( VmathSoaVector3 vec ) +{ + vmathSoaV3Print(&vec); +} + +static inline void vmathSoaV3Prints_V( VmathSoaVector3 vec, const char *name ) +{ + vmathSoaV3Prints(&vec, name); +} + +#endif + +static inline VmathSoaVector4 vmathSoaV4MakeFromElems_V( vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w ) +{ + VmathSoaVector4 result; + vmathSoaV4MakeFromElems(&result, _x, _y, _z, _w); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4MakeFromV3Scalar_V( VmathSoaVector3 xyz, vec_float4 _w ) +{ + VmathSoaVector4 result; + vmathSoaV4MakeFromV3Scalar(&result, &xyz, _w); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4MakeFromV3_V( VmathSoaVector3 vec ) +{ + VmathSoaVector4 result; + vmathSoaV4MakeFromV3(&result, &vec); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4MakeFromP3_V( VmathSoaPoint3 pnt ) +{ + VmathSoaVector4 result; + vmathSoaV4MakeFromP3(&result, &pnt); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4MakeFromQ_V( VmathSoaQuat quat ) +{ + VmathSoaVector4 result; + vmathSoaV4MakeFromQ(&result, &quat); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4MakeFromScalar_V( vec_float4 scalar ) +{ + VmathSoaVector4 result; + vmathSoaV4MakeFromScalar(&result, scalar); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4MakeFromAos_V( VmathVector4 vec ) +{ + VmathSoaVector4 result; + vmathSoaV4MakeFromAos(&result, &vec); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4MakeFrom4Aos_V( VmathVector4 vec0, VmathVector4 vec1, VmathVector4 vec2, VmathVector4 vec3 ) +{ + VmathSoaVector4 result; + vmathSoaV4MakeFrom4Aos(&result, &vec0, &vec1, &vec2, &vec3); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4MakeXAxis_V( ) +{ + VmathSoaVector4 result; + vmathSoaV4MakeXAxis(&result); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4MakeYAxis_V( ) +{ + VmathSoaVector4 result; + vmathSoaV4MakeYAxis(&result); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4MakeZAxis_V( ) +{ + VmathSoaVector4 result; + vmathSoaV4MakeZAxis(&result); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4MakeWAxis_V( ) +{ + VmathSoaVector4 result; + vmathSoaV4MakeWAxis(&result); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4Lerp_V( vec_float4 t, VmathSoaVector4 vec0, VmathSoaVector4 vec1 ) +{ + VmathSoaVector4 result; + vmathSoaV4Lerp(&result, t, &vec0, &vec1); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4Slerp_V( vec_float4 t, VmathSoaVector4 unitVec0, VmathSoaVector4 unitVec1 ) +{ + VmathSoaVector4 result; + vmathSoaV4Slerp(&result, t, &unitVec0, &unitVec1); + return result; +} + +static inline void vmathSoaV4Get4Aos_V( VmathSoaVector4 vec, VmathVector4 *result0, VmathVector4 *result1, VmathVector4 *result2, VmathVector4 *result3 ) +{ + vmathSoaV4Get4Aos(&vec, result0, result1, result2, result3); +} + +static inline void vmathSoaV4StoreHalfFloats_V( VmathSoaVector4 vec, vec_ushort8 *twoQuads ) +{ + vmathSoaV4StoreHalfFloats(&vec, twoQuads); +} + +static inline void vmathSoaV4SetXYZ_V( VmathSoaVector4 *result, VmathSoaVector3 vec ) +{ + vmathSoaV4SetXYZ(result, &vec); +} + +static inline VmathSoaVector3 vmathSoaV4GetXYZ_V( VmathSoaVector4 vec ) +{ + VmathSoaVector3 result; + vmathSoaV4GetXYZ(&result, &vec); + return result; +} + +static inline void vmathSoaV4SetX_V( VmathSoaVector4 *result, vec_float4 _x ) +{ + vmathSoaV4SetX(result, _x); +} + +static inline vec_float4 vmathSoaV4GetX_V( VmathSoaVector4 vec ) +{ + return vmathSoaV4GetX(&vec); +} + +static inline void vmathSoaV4SetY_V( VmathSoaVector4 *result, vec_float4 _y ) +{ + vmathSoaV4SetY(result, _y); +} + +static inline vec_float4 vmathSoaV4GetY_V( VmathSoaVector4 vec ) +{ + return vmathSoaV4GetY(&vec); +} + +static inline void vmathSoaV4SetZ_V( VmathSoaVector4 *result, vec_float4 _z ) +{ + vmathSoaV4SetZ(result, _z); +} + +static inline vec_float4 vmathSoaV4GetZ_V( VmathSoaVector4 vec ) +{ + return vmathSoaV4GetZ(&vec); +} + +static inline void vmathSoaV4SetW_V( VmathSoaVector4 *result, vec_float4 _w ) +{ + vmathSoaV4SetW(result, _w); +} + +static inline vec_float4 vmathSoaV4GetW_V( VmathSoaVector4 vec ) +{ + return vmathSoaV4GetW(&vec); +} + +static inline void vmathSoaV4SetElem_V( VmathSoaVector4 *result, int idx, vec_float4 value ) +{ + vmathSoaV4SetElem(result, idx, value); +} + +static inline vec_float4 vmathSoaV4GetElem_V( VmathSoaVector4 vec, int idx ) +{ + return vmathSoaV4GetElem(&vec, idx); +} + +static inline VmathSoaVector4 vmathSoaV4Add_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ) +{ + VmathSoaVector4 result; + vmathSoaV4Add(&result, &vec0, &vec1); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4Sub_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ) +{ + VmathSoaVector4 result; + vmathSoaV4Sub(&result, &vec0, &vec1); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4ScalarMul_V( VmathSoaVector4 vec, vec_float4 scalar ) +{ + VmathSoaVector4 result; + vmathSoaV4ScalarMul(&result, &vec, scalar); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4ScalarDiv_V( VmathSoaVector4 vec, vec_float4 scalar ) +{ + VmathSoaVector4 result; + vmathSoaV4ScalarDiv(&result, &vec, scalar); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4Neg_V( VmathSoaVector4 vec ) +{ + VmathSoaVector4 result; + vmathSoaV4Neg(&result, &vec); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4MulPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ) +{ + VmathSoaVector4 result; + vmathSoaV4MulPerElem(&result, &vec0, &vec1); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4DivPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ) +{ + VmathSoaVector4 result; + vmathSoaV4DivPerElem(&result, &vec0, &vec1); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4RecipPerElem_V( VmathSoaVector4 vec ) +{ + VmathSoaVector4 result; + vmathSoaV4RecipPerElem(&result, &vec); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4SqrtPerElem_V( VmathSoaVector4 vec ) +{ + VmathSoaVector4 result; + vmathSoaV4SqrtPerElem(&result, &vec); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4RsqrtPerElem_V( VmathSoaVector4 vec ) +{ + VmathSoaVector4 result; + vmathSoaV4RsqrtPerElem(&result, &vec); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4AbsPerElem_V( VmathSoaVector4 vec ) +{ + VmathSoaVector4 result; + vmathSoaV4AbsPerElem(&result, &vec); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4CopySignPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ) +{ + VmathSoaVector4 result; + vmathSoaV4CopySignPerElem(&result, &vec0, &vec1); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4MaxPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ) +{ + VmathSoaVector4 result; + vmathSoaV4MaxPerElem(&result, &vec0, &vec1); + return result; +} + +static inline vec_float4 vmathSoaV4MaxElem_V( VmathSoaVector4 vec ) +{ + return vmathSoaV4MaxElem(&vec); +} + +static inline VmathSoaVector4 vmathSoaV4MinPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ) +{ + VmathSoaVector4 result; + vmathSoaV4MinPerElem(&result, &vec0, &vec1); + return result; +} + +static inline vec_float4 vmathSoaV4MinElem_V( VmathSoaVector4 vec ) +{ + return vmathSoaV4MinElem(&vec); +} + +static inline vec_float4 vmathSoaV4Sum_V( VmathSoaVector4 vec ) +{ + return vmathSoaV4Sum(&vec); +} + +static inline vec_float4 vmathSoaV4Dot_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ) +{ + return vmathSoaV4Dot(&vec0, &vec1); +} + +static inline vec_float4 vmathSoaV4LengthSqr_V( VmathSoaVector4 vec ) +{ + return vmathSoaV4LengthSqr(&vec); +} + +static inline vec_float4 vmathSoaV4Length_V( VmathSoaVector4 vec ) +{ + return vmathSoaV4Length(&vec); +} + +static inline VmathSoaVector4 vmathSoaV4Normalize_V( VmathSoaVector4 vec ) +{ + VmathSoaVector4 result; + vmathSoaV4Normalize(&result, &vec); + return result; +} + +static inline VmathSoaVector4 vmathSoaV4Select_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1, vec_uint4 select1 ) +{ + VmathSoaVector4 result; + vmathSoaV4Select(&result, &vec0, &vec1, select1); + return result; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathSoaV4Print_V( VmathSoaVector4 vec ) +{ + vmathSoaV4Print(&vec); +} + +static inline void vmathSoaV4Prints_V( VmathSoaVector4 vec, const char *name ) +{ + vmathSoaV4Prints(&vec, name); +} + +#endif + +static inline VmathSoaPoint3 vmathSoaP3MakeFromElems_V( vec_float4 _x, vec_float4 _y, vec_float4 _z ) +{ + VmathSoaPoint3 result; + vmathSoaP3MakeFromElems(&result, _x, _y, _z); + return result; +} + +static inline VmathSoaPoint3 vmathSoaP3MakeFromV3_V( VmathSoaVector3 vec ) +{ + VmathSoaPoint3 result; + vmathSoaP3MakeFromV3(&result, &vec); + return result; +} + +static inline VmathSoaPoint3 vmathSoaP3MakeFromScalar_V( vec_float4 scalar ) +{ + VmathSoaPoint3 result; + vmathSoaP3MakeFromScalar(&result, scalar); + return result; +} + +static inline VmathSoaPoint3 vmathSoaP3MakeFromAos_V( VmathPoint3 pnt ) +{ + VmathSoaPoint3 result; + vmathSoaP3MakeFromAos(&result, &pnt); + return result; +} + +static inline VmathSoaPoint3 vmathSoaP3MakeFrom4Aos_V( VmathPoint3 pnt0, VmathPoint3 pnt1, VmathPoint3 pnt2, VmathPoint3 pnt3 ) +{ + VmathSoaPoint3 result; + vmathSoaP3MakeFrom4Aos(&result, &pnt0, &pnt1, &pnt2, &pnt3); + return result; +} + +static inline VmathSoaPoint3 vmathSoaP3Lerp_V( vec_float4 t, VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ) +{ + VmathSoaPoint3 result; + vmathSoaP3Lerp(&result, t, &pnt0, &pnt1); + return result; +} + +static inline void vmathSoaP3Get4Aos_V( VmathSoaPoint3 pnt, VmathPoint3 *result0, VmathPoint3 *result1, VmathPoint3 *result2, VmathPoint3 *result3 ) +{ + vmathSoaP3Get4Aos(&pnt, result0, result1, result2, result3); +} + +static inline void vmathSoaP3LoadXYZArray_V( VmathSoaPoint3 *vec, const vec_float4 *threeQuads ) +{ + vmathSoaP3LoadXYZArray(vec, threeQuads); +} + +static inline void vmathSoaP3StoreXYZArray_V( VmathSoaPoint3 vec, vec_float4 *threeQuads ) +{ + vmathSoaP3StoreXYZArray(&vec, threeQuads); +} + +static inline void vmathSoaP3StoreHalfFloats_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1, vec_ushort8 *threeQuads ) +{ + vmathSoaP3StoreHalfFloats(&pnt0, &pnt1, threeQuads); +} + +static inline void vmathSoaP3SetX_V( VmathSoaPoint3 *result, vec_float4 _x ) +{ + vmathSoaP3SetX(result, _x); +} + +static inline vec_float4 vmathSoaP3GetX_V( VmathSoaPoint3 pnt ) +{ + return vmathSoaP3GetX(&pnt); +} + +static inline void vmathSoaP3SetY_V( VmathSoaPoint3 *result, vec_float4 _y ) +{ + vmathSoaP3SetY(result, _y); +} + +static inline vec_float4 vmathSoaP3GetY_V( VmathSoaPoint3 pnt ) +{ + return vmathSoaP3GetY(&pnt); +} + +static inline void vmathSoaP3SetZ_V( VmathSoaPoint3 *result, vec_float4 _z ) +{ + vmathSoaP3SetZ(result, _z); +} + +static inline vec_float4 vmathSoaP3GetZ_V( VmathSoaPoint3 pnt ) +{ + return vmathSoaP3GetZ(&pnt); +} + +static inline void vmathSoaP3SetElem_V( VmathSoaPoint3 *result, int idx, vec_float4 value ) +{ + vmathSoaP3SetElem(result, idx, value); +} + +static inline vec_float4 vmathSoaP3GetElem_V( VmathSoaPoint3 pnt, int idx ) +{ + return vmathSoaP3GetElem(&pnt, idx); +} + +static inline VmathSoaVector3 vmathSoaP3Sub_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ) +{ + VmathSoaVector3 result; + vmathSoaP3Sub(&result, &pnt0, &pnt1); + return result; +} + +static inline VmathSoaPoint3 vmathSoaP3AddV3_V( VmathSoaPoint3 pnt, VmathSoaVector3 vec1 ) +{ + VmathSoaPoint3 result; + vmathSoaP3AddV3(&result, &pnt, &vec1); + return result; +} + +static inline VmathSoaPoint3 vmathSoaP3SubV3_V( VmathSoaPoint3 pnt, VmathSoaVector3 vec1 ) +{ + VmathSoaPoint3 result; + vmathSoaP3SubV3(&result, &pnt, &vec1); + return result; +} + +static inline VmathSoaPoint3 vmathSoaP3MulPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ) +{ + VmathSoaPoint3 result; + vmathSoaP3MulPerElem(&result, &pnt0, &pnt1); + return result; +} + +static inline VmathSoaPoint3 vmathSoaP3DivPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ) +{ + VmathSoaPoint3 result; + vmathSoaP3DivPerElem(&result, &pnt0, &pnt1); + return result; +} + +static inline VmathSoaPoint3 vmathSoaP3RecipPerElem_V( VmathSoaPoint3 pnt ) +{ + VmathSoaPoint3 result; + vmathSoaP3RecipPerElem(&result, &pnt); + return result; +} + +static inline VmathSoaPoint3 vmathSoaP3SqrtPerElem_V( VmathSoaPoint3 pnt ) +{ + VmathSoaPoint3 result; + vmathSoaP3SqrtPerElem(&result, &pnt); + return result; +} + +static inline VmathSoaPoint3 vmathSoaP3RsqrtPerElem_V( VmathSoaPoint3 pnt ) +{ + VmathSoaPoint3 result; + vmathSoaP3RsqrtPerElem(&result, &pnt); + return result; +} + +static inline VmathSoaPoint3 vmathSoaP3AbsPerElem_V( VmathSoaPoint3 pnt ) +{ + VmathSoaPoint3 result; + vmathSoaP3AbsPerElem(&result, &pnt); + return result; +} + +static inline VmathSoaPoint3 vmathSoaP3CopySignPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ) +{ + VmathSoaPoint3 result; + vmathSoaP3CopySignPerElem(&result, &pnt0, &pnt1); + return result; +} + +static inline VmathSoaPoint3 vmathSoaP3MaxPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ) +{ + VmathSoaPoint3 result; + vmathSoaP3MaxPerElem(&result, &pnt0, &pnt1); + return result; +} + +static inline vec_float4 vmathSoaP3MaxElem_V( VmathSoaPoint3 pnt ) +{ + return vmathSoaP3MaxElem(&pnt); +} + +static inline VmathSoaPoint3 vmathSoaP3MinPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ) +{ + VmathSoaPoint3 result; + vmathSoaP3MinPerElem(&result, &pnt0, &pnt1); + return result; +} + +static inline vec_float4 vmathSoaP3MinElem_V( VmathSoaPoint3 pnt ) +{ + return vmathSoaP3MinElem(&pnt); +} + +static inline vec_float4 vmathSoaP3Sum_V( VmathSoaPoint3 pnt ) +{ + return vmathSoaP3Sum(&pnt); +} + +static inline VmathSoaPoint3 vmathSoaP3Scale_V( VmathSoaPoint3 pnt, vec_float4 scaleVal ) +{ + VmathSoaPoint3 result; + vmathSoaP3Scale(&result, &pnt, scaleVal); + return result; +} + +static inline VmathSoaPoint3 vmathSoaP3NonUniformScale_V( VmathSoaPoint3 pnt, VmathSoaVector3 scaleVec ) +{ + VmathSoaPoint3 result; + vmathSoaP3NonUniformScale(&result, &pnt, &scaleVec); + return result; +} + +static inline vec_float4 vmathSoaP3Projection_V( VmathSoaPoint3 pnt, VmathSoaVector3 unitVec ) +{ + return vmathSoaP3Projection(&pnt, &unitVec); +} + +static inline vec_float4 vmathSoaP3DistSqrFromOrigin_V( VmathSoaPoint3 pnt ) +{ + return vmathSoaP3DistSqrFromOrigin(&pnt); +} + +static inline vec_float4 vmathSoaP3DistFromOrigin_V( VmathSoaPoint3 pnt ) +{ + return vmathSoaP3DistFromOrigin(&pnt); +} + +static inline vec_float4 vmathSoaP3DistSqr_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ) +{ + return vmathSoaP3DistSqr(&pnt0, &pnt1); +} + +static inline vec_float4 vmathSoaP3Dist_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ) +{ + return vmathSoaP3Dist(&pnt0, &pnt1); +} + +static inline VmathSoaPoint3 vmathSoaP3Select_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1, vec_uint4 select1 ) +{ + VmathSoaPoint3 result; + vmathSoaP3Select(&result, &pnt0, &pnt1, select1); + return result; +} + +#ifdef _VECTORMATH_DEBUG + +static inline void vmathSoaP3Print_V( VmathSoaPoint3 pnt ) +{ + vmathSoaP3Print(&pnt); +} + +static inline void vmathSoaP3Prints_V( VmathSoaPoint3 pnt, const char *name ) +{ + vmathSoaP3Prints(&pnt, name); +} + +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/vectormathlibrary/include/vectormath/spu/c/vectormath_aos.h b/vectormathlibrary/include/vectormath/spu/c/vectormath_aos.h new file mode 100644 index 000000000..3bd4e0fe2 --- /dev/null +++ b/vectormathlibrary/include/vectormath/spu/c/vectormath_aos.h @@ -0,0 +1,1951 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_AOS_C_SPU_H +#define _VECTORMATH_AOS_C_SPU_H + +#include <math.h> +#include <simdmath.h> +#include <stdio.h> + +#ifdef _VECTORMATH_DEBUG +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#ifndef _VECTORMATH_AOS_C_TYPES_H +#define _VECTORMATH_AOS_C_TYPES_H + +/* A 3-D vector in array-of-structures format + */ +typedef struct _VmathVector3 +{ + vec_float4 vec128; +} VmathVector3; + +/* A 4-D vector in array-of-structures format + */ +typedef struct _VmathVector4 +{ + vec_float4 vec128; +} VmathVector4; + +/* A 3-D point in array-of-structures format + */ +typedef struct _VmathPoint3 +{ + vec_float4 vec128; +} VmathPoint3; + +/* A quaternion in array-of-structures format + */ +typedef struct _VmathQuat +{ + vec_float4 vec128; +} VmathQuat; + +/* A 3x3 matrix in array-of-structures format + */ +typedef struct _VmathMatrix3 +{ + VmathVector3 col0; + VmathVector3 col1; + VmathVector3 col2; +} VmathMatrix3; + +/* A 4x4 matrix in array-of-structures format + */ +typedef struct _VmathMatrix4 +{ + VmathVector4 col0; + VmathVector4 col1; + VmathVector4 col2; + VmathVector4 col3; +} VmathMatrix4; + +/* A 3x4 transformation matrix in array-of-structures format + */ +typedef struct _VmathTransform3 +{ + VmathVector3 col0; + VmathVector3 col1; + VmathVector3 col2; + VmathVector3 col3; +} VmathTransform3; + +#endif + +/* + * Copy a 3-D vector + */ +static inline void vmathV3Copy( VmathVector3 *result, const VmathVector3 *vec ); + +/* + * Construct a 3-D vector from x, y, and z elements + */ +static inline void vmathV3MakeFromElems( VmathVector3 *result, float x, float y, float z ); + +/* + * Copy elements from a 3-D point into a 3-D vector + */ +static inline void vmathV3MakeFromP3( VmathVector3 *result, const VmathPoint3 *pnt ); + +/* + * Set all elements of a 3-D vector to the same scalar value + */ +static inline void vmathV3MakeFromScalar( VmathVector3 *result, float scalar ); + +/* + * Set vector float data in a 3-D vector + */ +static inline void vmathV3MakeFrom128( VmathVector3 *result, vec_float4 vf4 ); + +/* + * Get vector float data from a 3-D vector + */ +static inline vec_float4 vmathV3Get128( const VmathVector3 *vec ); + +/* + * Set the x element of a 3-D vector + */ +static inline void vmathV3SetX( VmathVector3 *result, float x ); + +/* + * Set the y element of a 3-D vector + */ +static inline void vmathV3SetY( VmathVector3 *result, float y ); + +/* + * Set the z element of a 3-D vector + */ +static inline void vmathV3SetZ( VmathVector3 *result, float z ); + +/* + * Get the x element of a 3-D vector + */ +static inline float vmathV3GetX( const VmathVector3 *vec ); + +/* + * Get the y element of a 3-D vector + */ +static inline float vmathV3GetY( const VmathVector3 *vec ); + +/* + * Get the z element of a 3-D vector + */ +static inline float vmathV3GetZ( const VmathVector3 *vec ); + +/* + * Set an x, y, or z element of a 3-D vector by index + */ +static inline void vmathV3SetElem( VmathVector3 *result, int idx, float value ); + +/* + * Get an x, y, or z element of a 3-D vector by index + */ +static inline float vmathV3GetElem( const VmathVector3 *vec, int idx ); + +/* + * Add two 3-D vectors + */ +static inline void vmathV3Add( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); + +/* + * Subtract a 3-D vector from another 3-D vector + */ +static inline void vmathV3Sub( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); + +/* + * Add a 3-D vector to a 3-D point + */ +static inline void vmathV3AddP3( VmathPoint3 *result, const VmathVector3 *vec, const VmathPoint3 *pnt ); + +/* + * Multiply a 3-D vector by a scalar + */ +static inline void vmathV3ScalarMul( VmathVector3 *result, const VmathVector3 *vec, float scalar ); + +/* + * Divide a 3-D vector by a scalar + */ +static inline void vmathV3ScalarDiv( VmathVector3 *result, const VmathVector3 *vec, float scalar ); + +/* + * Negate all elements of a 3-D vector + */ +static inline void vmathV3Neg( VmathVector3 *result, const VmathVector3 *vec ); + +/* + * Construct x axis + */ +static inline void vmathV3MakeXAxis( VmathVector3 *result ); + +/* + * Construct y axis + */ +static inline void vmathV3MakeYAxis( VmathVector3 *result ); + +/* + * Construct z axis + */ +static inline void vmathV3MakeZAxis( VmathVector3 *result ); + +/* + * Multiply two 3-D vectors per element + */ +static inline void vmathV3MulPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); + +/* + * Divide two 3-D vectors per element + * NOTE: + * Floating-point behavior matches standard library function divf4. + */ +static inline void vmathV3DivPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); + +/* + * Compute the reciprocal of a 3-D vector per element + * NOTE: + * Floating-point behavior matches standard library function recipf4. + */ +static inline void vmathV3RecipPerElem( VmathVector3 *result, const VmathVector3 *vec ); + +/* + * Compute the square root of a 3-D vector per element + * NOTE: + * Floating-point behavior matches standard library function sqrtf4. + */ +static inline void vmathV3SqrtPerElem( VmathVector3 *result, const VmathVector3 *vec ); + +/* + * Compute the reciprocal square root of a 3-D vector per element + * NOTE: + * Floating-point behavior matches standard library function rsqrtf4. + */ +static inline void vmathV3RsqrtPerElem( VmathVector3 *result, const VmathVector3 *vec ); + +/* + * Compute the absolute value of a 3-D vector per element + */ +static inline void vmathV3AbsPerElem( VmathVector3 *result, const VmathVector3 *vec ); + +/* + * Copy sign from one 3-D vector to another, per element + */ +static inline void vmathV3CopySignPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); + +/* + * Maximum of two 3-D vectors per element + */ +static inline void vmathV3MaxPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); + +/* + * Minimum of two 3-D vectors per element + */ +static inline void vmathV3MinPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); + +/* + * Maximum element of a 3-D vector + */ +static inline float vmathV3MaxElem( const VmathVector3 *vec ); + +/* + * Minimum element of a 3-D vector + */ +static inline float vmathV3MinElem( const VmathVector3 *vec ); + +/* + * Compute the sum of all elements of a 3-D vector + */ +static inline float vmathV3Sum( const VmathVector3 *vec ); + +/* + * Compute the dot product of two 3-D vectors + */ +static inline float vmathV3Dot( const VmathVector3 *vec0, const VmathVector3 *vec1 ); + +/* + * Compute the square of the length of a 3-D vector + */ +static inline float vmathV3LengthSqr( const VmathVector3 *vec ); + +/* + * Compute the length of a 3-D vector + */ +static inline float vmathV3Length( const VmathVector3 *vec ); + +/* + * Normalize a 3-D vector + * NOTE: + * The result is unpredictable when all elements of vec are at or near zero. + */ +static inline void vmathV3Normalize( VmathVector3 *result, const VmathVector3 *vec ); + +/* + * Compute cross product of two 3-D vectors + */ +static inline void vmathV3Cross( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); + +/* + * Outer product of two 3-D vectors + */ +static inline void vmathV3Outer( VmathMatrix3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); + +/* + * Pre-multiply a row vector by a 3x3 matrix + * NOTE: + * Slower than column post-multiply. + */ +static inline void vmathV3RowMul( VmathVector3 *result, const VmathVector3 *vec, const VmathMatrix3 *mat ); + +/* + * Cross-product matrix of a 3-D vector + */ +static inline void vmathV3CrossMatrix( VmathMatrix3 *result, const VmathVector3 *vec ); + +/* + * Create cross-product matrix and multiply + * NOTE: + * Faster than separately creating a cross-product matrix and multiplying. + */ +static inline void vmathV3CrossMatrixMul( VmathMatrix3 *result, const VmathVector3 *vec, const VmathMatrix3 *mat ); + +/* + * Linear interpolation between two 3-D vectors + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline void vmathV3Lerp( VmathVector3 *result, float t, const VmathVector3 *vec0, const VmathVector3 *vec1 ); + +/* + * Spherical linear interpolation between two 3-D vectors + * NOTE: + * The result is unpredictable if the vectors point in opposite directions. + * Does not clamp t between 0 and 1. + */ +static inline void vmathV3Slerp( VmathVector3 *result, float t, const VmathVector3 *unitVec0, const VmathVector3 *unitVec1 ); + +/* + * Conditionally select between two 3-D vectors + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline void vmathV3Select( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1, unsigned int select1 ); + +/* + * Store x, y, and z elements of a 3-D vector in the first three words of a quadword. + * The value of the fourth word (the word with the highest address) remains unchanged + */ +static inline void vmathV3StoreXYZ( const VmathVector3 *vec, vec_float4 *quad ); + +/* + * Load four three-float 3-D vectors, stored in three quadwords + */ +static inline void vmathV3LoadXYZArray( VmathVector3 *vec0, VmathVector3 *vec1, VmathVector3 *vec2, VmathVector3 *vec3, const vec_float4 *threeQuads ); + +/* + * Store four 3-D vectors in three quadwords + */ +static inline void vmathV3StoreXYZArray( const VmathVector3 *vec0, const VmathVector3 *vec1, const VmathVector3 *vec2, const VmathVector3 *vec3, vec_float4 *threeQuads ); + +/* + * Store eight 3-D vectors as half-floats + */ +static inline void vmathV3StoreHalfFloats( const VmathVector3 *vec0, const VmathVector3 *vec1, const VmathVector3 *vec2, const VmathVector3 *vec3, const VmathVector3 *vec4, const VmathVector3 *vec5, const VmathVector3 *vec6, const VmathVector3 *vec7, vec_ushort8 *threeQuads ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3-D vector + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathV3Print( const VmathVector3 *vec ); + +/* + * Print a 3-D vector and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathV3Prints( const VmathVector3 *vec, const char *name ); + +#endif + +/* + * Copy a 4-D vector + */ +static inline void vmathV4Copy( VmathVector4 *result, const VmathVector4 *vec ); + +/* + * Construct a 4-D vector from x, y, z, and w elements + */ +static inline void vmathV4MakeFromElems( VmathVector4 *result, float x, float y, float z, float w ); + +/* + * Construct a 4-D vector from a 3-D vector and a scalar + */ +static inline void vmathV4MakeFromV3Scalar( VmathVector4 *result, const VmathVector3 *xyz, float w ); + +/* + * Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0 + */ +static inline void vmathV4MakeFromV3( VmathVector4 *result, const VmathVector3 *vec ); + +/* + * Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1 + */ +static inline void vmathV4MakeFromP3( VmathVector4 *result, const VmathPoint3 *pnt ); + +/* + * Copy elements from a quaternion into a 4-D vector + */ +static inline void vmathV4MakeFromQ( VmathVector4 *result, const VmathQuat *quat ); + +/* + * Set all elements of a 4-D vector to the same scalar value + */ +static inline void vmathV4MakeFromScalar( VmathVector4 *result, float scalar ); + +/* + * Set vector float data in a 4-D vector + */ +static inline void vmathV4MakeFrom128( VmathVector4 *result, vec_float4 vf4 ); + +/* + * Get vector float data from a 4-D vector + */ +static inline vec_float4 vmathV4Get128( const VmathVector4 *vec ); + +/* + * Set the x, y, and z elements of a 4-D vector + * NOTE: + * This function does not change the w element. + */ +static inline void vmathV4SetXYZ( VmathVector4 *result, const VmathVector3 *vec ); + +/* + * Get the x, y, and z elements of a 4-D vector + */ +static inline void vmathV4GetXYZ( VmathVector3 *result, const VmathVector4 *vec ); + +/* + * Set the x element of a 4-D vector + */ +static inline void vmathV4SetX( VmathVector4 *result, float x ); + +/* + * Set the y element of a 4-D vector + */ +static inline void vmathV4SetY( VmathVector4 *result, float y ); + +/* + * Set the z element of a 4-D vector + */ +static inline void vmathV4SetZ( VmathVector4 *result, float z ); + +/* + * Set the w element of a 4-D vector + */ +static inline void vmathV4SetW( VmathVector4 *result, float w ); + +/* + * Get the x element of a 4-D vector + */ +static inline float vmathV4GetX( const VmathVector4 *vec ); + +/* + * Get the y element of a 4-D vector + */ +static inline float vmathV4GetY( const VmathVector4 *vec ); + +/* + * Get the z element of a 4-D vector + */ +static inline float vmathV4GetZ( const VmathVector4 *vec ); + +/* + * Get the w element of a 4-D vector + */ +static inline float vmathV4GetW( const VmathVector4 *vec ); + +/* + * Set an x, y, z, or w element of a 4-D vector by index + */ +static inline void vmathV4SetElem( VmathVector4 *result, int idx, float value ); + +/* + * Get an x, y, z, or w element of a 4-D vector by index + */ +static inline float vmathV4GetElem( const VmathVector4 *vec, int idx ); + +/* + * Add two 4-D vectors + */ +static inline void vmathV4Add( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); + +/* + * Subtract a 4-D vector from another 4-D vector + */ +static inline void vmathV4Sub( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); + +/* + * Multiply a 4-D vector by a scalar + */ +static inline void vmathV4ScalarMul( VmathVector4 *result, const VmathVector4 *vec, float scalar ); + +/* + * Divide a 4-D vector by a scalar + */ +static inline void vmathV4ScalarDiv( VmathVector4 *result, const VmathVector4 *vec, float scalar ); + +/* + * Negate all elements of a 4-D vector + */ +static inline void vmathV4Neg( VmathVector4 *result, const VmathVector4 *vec ); + +/* + * Construct x axis + */ +static inline void vmathV4MakeXAxis( VmathVector4 *result ); + +/* + * Construct y axis + */ +static inline void vmathV4MakeYAxis( VmathVector4 *result ); + +/* + * Construct z axis + */ +static inline void vmathV4MakeZAxis( VmathVector4 *result ); + +/* + * Construct w axis + */ +static inline void vmathV4MakeWAxis( VmathVector4 *result ); + +/* + * Multiply two 4-D vectors per element + */ +static inline void vmathV4MulPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); + +/* + * Divide two 4-D vectors per element + * NOTE: + * Floating-point behavior matches standard library function divf4. + */ +static inline void vmathV4DivPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); + +/* + * Compute the reciprocal of a 4-D vector per element + * NOTE: + * Floating-point behavior matches standard library function recipf4. + */ +static inline void vmathV4RecipPerElem( VmathVector4 *result, const VmathVector4 *vec ); + +/* + * Compute the square root of a 4-D vector per element + * NOTE: + * Floating-point behavior matches standard library function sqrtf4. + */ +static inline void vmathV4SqrtPerElem( VmathVector4 *result, const VmathVector4 *vec ); + +/* + * Compute the reciprocal square root of a 4-D vector per element + * NOTE: + * Floating-point behavior matches standard library function rsqrtf4. + */ +static inline void vmathV4RsqrtPerElem( VmathVector4 *result, const VmathVector4 *vec ); + +/* + * Compute the absolute value of a 4-D vector per element + */ +static inline void vmathV4AbsPerElem( VmathVector4 *result, const VmathVector4 *vec ); + +/* + * Copy sign from one 4-D vector to another, per element + */ +static inline void vmathV4CopySignPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); + +/* + * Maximum of two 4-D vectors per element + */ +static inline void vmathV4MaxPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); + +/* + * Minimum of two 4-D vectors per element + */ +static inline void vmathV4MinPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); + +/* + * Maximum element of a 4-D vector + */ +static inline float vmathV4MaxElem( const VmathVector4 *vec ); + +/* + * Minimum element of a 4-D vector + */ +static inline float vmathV4MinElem( const VmathVector4 *vec ); + +/* + * Compute the sum of all elements of a 4-D vector + */ +static inline float vmathV4Sum( const VmathVector4 *vec ); + +/* + * Compute the dot product of two 4-D vectors + */ +static inline float vmathV4Dot( const VmathVector4 *vec0, const VmathVector4 *vec1 ); + +/* + * Compute the square of the length of a 4-D vector + */ +static inline float vmathV4LengthSqr( const VmathVector4 *vec ); + +/* + * Compute the length of a 4-D vector + */ +static inline float vmathV4Length( const VmathVector4 *vec ); + +/* + * Normalize a 4-D vector + * NOTE: + * The result is unpredictable when all elements of vec are at or near zero. + */ +static inline void vmathV4Normalize( VmathVector4 *result, const VmathVector4 *vec ); + +/* + * Outer product of two 4-D vectors + */ +static inline void vmathV4Outer( VmathMatrix4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); + +/* + * Linear interpolation between two 4-D vectors + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline void vmathV4Lerp( VmathVector4 *result, float t, const VmathVector4 *vec0, const VmathVector4 *vec1 ); + +/* + * Spherical linear interpolation between two 4-D vectors + * NOTE: + * The result is unpredictable if the vectors point in opposite directions. + * Does not clamp t between 0 and 1. + */ +static inline void vmathV4Slerp( VmathVector4 *result, float t, const VmathVector4 *unitVec0, const VmathVector4 *unitVec1 ); + +/* + * Conditionally select between two 4-D vectors + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline void vmathV4Select( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1, unsigned int select1 ); + +/* + * Store four 4-D vectors as half-floats + */ +static inline void vmathV4StoreHalfFloats( const VmathVector4 *vec0, const VmathVector4 *vec1, const VmathVector4 *vec2, const VmathVector4 *vec3, vec_ushort8 *twoQuads ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 4-D vector + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathV4Print( const VmathVector4 *vec ); + +/* + * Print a 4-D vector and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathV4Prints( const VmathVector4 *vec, const char *name ); + +#endif + +/* + * Copy a 3-D point + */ +static inline void vmathP3Copy( VmathPoint3 *result, const VmathPoint3 *pnt ); + +/* + * Construct a 3-D point from x, y, and z elements + */ +static inline void vmathP3MakeFromElems( VmathPoint3 *result, float x, float y, float z ); + +/* + * Copy elements from a 3-D vector into a 3-D point + */ +static inline void vmathP3MakeFromV3( VmathPoint3 *result, const VmathVector3 *vec ); + +/* + * Set all elements of a 3-D point to the same scalar value + */ +static inline void vmathP3MakeFromScalar( VmathPoint3 *result, float scalar ); + +/* + * Set vector float data in a 3-D point + */ +static inline void vmathP3MakeFrom128( VmathPoint3 *result, vec_float4 vf4 ); + +/* + * Get vector float data from a 3-D point + */ +static inline vec_float4 vmathP3Get128( const VmathPoint3 *pnt ); + +/* + * Set the x element of a 3-D point + */ +static inline void vmathP3SetX( VmathPoint3 *result, float x ); + +/* + * Set the y element of a 3-D point + */ +static inline void vmathP3SetY( VmathPoint3 *result, float y ); + +/* + * Set the z element of a 3-D point + */ +static inline void vmathP3SetZ( VmathPoint3 *result, float z ); + +/* + * Get the x element of a 3-D point + */ +static inline float vmathP3GetX( const VmathPoint3 *pnt ); + +/* + * Get the y element of a 3-D point + */ +static inline float vmathP3GetY( const VmathPoint3 *pnt ); + +/* + * Get the z element of a 3-D point + */ +static inline float vmathP3GetZ( const VmathPoint3 *pnt ); + +/* + * Set an x, y, or z element of a 3-D point by index + */ +static inline void vmathP3SetElem( VmathPoint3 *result, int idx, float value ); + +/* + * Get an x, y, or z element of a 3-D point by index + */ +static inline float vmathP3GetElem( const VmathPoint3 *pnt, int idx ); + +/* + * Subtract a 3-D point from another 3-D point + */ +static inline void vmathP3Sub( VmathVector3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); + +/* + * Add a 3-D point to a 3-D vector + */ +static inline void vmathP3AddV3( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *vec ); + +/* + * Subtract a 3-D vector from a 3-D point + */ +static inline void vmathP3SubV3( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *vec ); + +/* + * Multiply two 3-D points per element + */ +static inline void vmathP3MulPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); + +/* + * Divide two 3-D points per element + * NOTE: + * Floating-point behavior matches standard library function divf4. + */ +static inline void vmathP3DivPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); + +/* + * Compute the reciprocal of a 3-D point per element + * NOTE: + * Floating-point behavior matches standard library function recipf4. + */ +static inline void vmathP3RecipPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ); + +/* + * Compute the square root of a 3-D point per element + * NOTE: + * Floating-point behavior matches standard library function sqrtf4. + */ +static inline void vmathP3SqrtPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ); + +/* + * Compute the reciprocal square root of a 3-D point per element + * NOTE: + * Floating-point behavior matches standard library function rsqrtf4. + */ +static inline void vmathP3RsqrtPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ); + +/* + * Compute the absolute value of a 3-D point per element + */ +static inline void vmathP3AbsPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ); + +/* + * Copy sign from one 3-D point to another, per element + */ +static inline void vmathP3CopySignPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); + +/* + * Maximum of two 3-D points per element + */ +static inline void vmathP3MaxPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); + +/* + * Minimum of two 3-D points per element + */ +static inline void vmathP3MinPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); + +/* + * Maximum element of a 3-D point + */ +static inline float vmathP3MaxElem( const VmathPoint3 *pnt ); + +/* + * Minimum element of a 3-D point + */ +static inline float vmathP3MinElem( const VmathPoint3 *pnt ); + +/* + * Compute the sum of all elements of a 3-D point + */ +static inline float vmathP3Sum( const VmathPoint3 *pnt ); + +/* + * Apply uniform scale to a 3-D point + */ +static inline void vmathP3Scale( VmathPoint3 *result, const VmathPoint3 *pnt, float scaleVal ); + +/* + * Apply non-uniform scale to a 3-D point + */ +static inline void vmathP3NonUniformScale( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *scaleVec ); + +/* + * Scalar projection of a 3-D point on a unit-length 3-D vector + */ +static inline float vmathP3Projection( const VmathPoint3 *pnt, const VmathVector3 *unitVec ); + +/* + * Compute the square of the distance of a 3-D point from the coordinate-system origin + */ +static inline float vmathP3DistSqrFromOrigin( const VmathPoint3 *pnt ); + +/* + * Compute the distance of a 3-D point from the coordinate-system origin + */ +static inline float vmathP3DistFromOrigin( const VmathPoint3 *pnt ); + +/* + * Compute the square of the distance between two 3-D points + */ +static inline float vmathP3DistSqr( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); + +/* + * Compute the distance between two 3-D points + */ +static inline float vmathP3Dist( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); + +/* + * Linear interpolation between two 3-D points + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline void vmathP3Lerp( VmathPoint3 *result, float t, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); + +/* + * Conditionally select between two 3-D points + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline void vmathP3Select( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, unsigned int select1 ); + +/* + * Store x, y, and z elements of a 3-D point in the first three words of a quadword. + * The value of the fourth word (the word with the highest address) remains unchanged + */ +static inline void vmathP3StoreXYZ( const VmathPoint3 *pnt, vec_float4 *quad ); + +/* + * Load four three-float 3-D points, stored in three quadwords + */ +static inline void vmathP3LoadXYZArray( VmathPoint3 *pnt0, VmathPoint3 *pnt1, VmathPoint3 *pnt2, VmathPoint3 *pnt3, const vec_float4 *threeQuads ); + +/* + * Store four 3-D points in three quadwords + */ +static inline void vmathP3StoreXYZArray( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, const VmathPoint3 *pnt2, const VmathPoint3 *pnt3, vec_float4 *threeQuads ); + +/* + * Store eight 3-D points as half-floats + */ +static inline void vmathP3StoreHalfFloats( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, const VmathPoint3 *pnt2, const VmathPoint3 *pnt3, const VmathPoint3 *pnt4, const VmathPoint3 *pnt5, const VmathPoint3 *pnt6, const VmathPoint3 *pnt7, vec_ushort8 *threeQuads ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3-D point + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathP3Print( const VmathPoint3 *pnt ); + +/* + * Print a 3-D point and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathP3Prints( const VmathPoint3 *pnt, const char *name ); + +#endif + +/* + * Copy a quaternion + */ +static inline void vmathQCopy( VmathQuat *result, const VmathQuat *quat ); + +/* + * Construct a quaternion from x, y, z, and w elements + */ +static inline void vmathQMakeFromElems( VmathQuat *result, float x, float y, float z, float w ); + +/* + * Construct a quaternion from a 3-D vector and a scalar + */ +static inline void vmathQMakeFromV3Scalar( VmathQuat *result, const VmathVector3 *xyz, float w ); + +/* + * Copy elements from a 4-D vector into a quaternion + */ +static inline void vmathQMakeFromV4( VmathQuat *result, const VmathVector4 *vec ); + +/* + * Convert a rotation matrix to a unit-length quaternion + */ +static inline void vmathQMakeFromM3( VmathQuat *result, const VmathMatrix3 *rotMat ); + +/* + * Set all elements of a quaternion to the same scalar value + */ +static inline void vmathQMakeFromScalar( VmathQuat *result, float scalar ); + +/* + * Set vector float data in a quaternion + */ +static inline void vmathQMakeFrom128( VmathQuat *result, vec_float4 vf4 ); + +/* + * Get vector float data from a quaternion + */ +static inline vec_float4 vmathQGet128( const VmathQuat *quat ); + +/* + * Set the x, y, and z elements of a quaternion + * NOTE: + * This function does not change the w element. + */ +static inline void vmathQSetXYZ( VmathQuat *result, const VmathVector3 *vec ); + +/* + * Get the x, y, and z elements of a quaternion + */ +static inline void vmathQGetXYZ( VmathVector3 *result, const VmathQuat *quat ); + +/* + * Set the x element of a quaternion + */ +static inline void vmathQSetX( VmathQuat *result, float x ); + +/* + * Set the y element of a quaternion + */ +static inline void vmathQSetY( VmathQuat *result, float y ); + +/* + * Set the z element of a quaternion + */ +static inline void vmathQSetZ( VmathQuat *result, float z ); + +/* + * Set the w element of a quaternion + */ +static inline void vmathQSetW( VmathQuat *result, float w ); + +/* + * Get the x element of a quaternion + */ +static inline float vmathQGetX( const VmathQuat *quat ); + +/* + * Get the y element of a quaternion + */ +static inline float vmathQGetY( const VmathQuat *quat ); + +/* + * Get the z element of a quaternion + */ +static inline float vmathQGetZ( const VmathQuat *quat ); + +/* + * Get the w element of a quaternion + */ +static inline float vmathQGetW( const VmathQuat *quat ); + +/* + * Set an x, y, z, or w element of a quaternion by index + */ +static inline void vmathQSetElem( VmathQuat *result, int idx, float value ); + +/* + * Get an x, y, z, or w element of a quaternion by index + */ +static inline float vmathQGetElem( const VmathQuat *quat, int idx ); + +/* + * Add two quaternions + */ +static inline void vmathQAdd( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ); + +/* + * Subtract a quaternion from another quaternion + */ +static inline void vmathQSub( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ); + +/* + * Multiply two quaternions + */ +static inline void vmathQMul( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ); + +/* + * Multiply a quaternion by a scalar + */ +static inline void vmathQScalarMul( VmathQuat *result, const VmathQuat *quat, float scalar ); + +/* + * Divide a quaternion by a scalar + */ +static inline void vmathQScalarDiv( VmathQuat *result, const VmathQuat *quat, float scalar ); + +/* + * Negate all elements of a quaternion + */ +static inline void vmathQNeg( VmathQuat *result, const VmathQuat *quat ); + +/* + * Construct an identity quaternion + */ +static inline void vmathQMakeIdentity( VmathQuat *result ); + +/* + * Construct a quaternion to rotate between two unit-length 3-D vectors + * NOTE: + * The result is unpredictable if unitVec0 and unitVec1 point in opposite directions. + */ +static inline void vmathQMakeRotationArc( VmathQuat *result, const VmathVector3 *unitVec0, const VmathVector3 *unitVec1 ); + +/* + * Construct a quaternion to rotate around a unit-length 3-D vector + */ +static inline void vmathQMakeRotationAxis( VmathQuat *result, float radians, const VmathVector3 *unitVec ); + +/* + * Construct a quaternion to rotate around the x axis + */ +static inline void vmathQMakeRotationX( VmathQuat *result, float radians ); + +/* + * Construct a quaternion to rotate around the y axis + */ +static inline void vmathQMakeRotationY( VmathQuat *result, float radians ); + +/* + * Construct a quaternion to rotate around the z axis + */ +static inline void vmathQMakeRotationZ( VmathQuat *result, float radians ); + +/* + * Compute the conjugate of a quaternion + */ +static inline void vmathQConj( VmathQuat *result, const VmathQuat *quat ); + +/* + * Use a unit-length quaternion to rotate a 3-D vector + */ +static inline void vmathQRotate( VmathVector3 *result, const VmathQuat *unitQuat, const VmathVector3 *vec ); + +/* + * Compute the dot product of two quaternions + */ +static inline float vmathQDot( const VmathQuat *quat0, const VmathQuat *quat1 ); + +/* + * Compute the norm of a quaternion + */ +static inline float vmathQNorm( const VmathQuat *quat ); + +/* + * Compute the length of a quaternion + */ +static inline float vmathQLength( const VmathQuat *quat ); + +/* + * Normalize a quaternion + * NOTE: + * The result is unpredictable when all elements of quat are at or near zero. + */ +static inline void vmathQNormalize( VmathQuat *result, const VmathQuat *quat ); + +/* + * Linear interpolation between two quaternions + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline void vmathQLerp( VmathQuat *result, float t, const VmathQuat *quat0, const VmathQuat *quat1 ); + +/* + * Spherical linear interpolation between two quaternions + * NOTE: + * Interpolates along the shortest path between orientations. + * Does not clamp t between 0 and 1. + */ +static inline void vmathQSlerp( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1 ); + +/* + * Spherical quadrangle interpolation + */ +static inline void vmathQSquad( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1, const VmathQuat *unitQuat2, const VmathQuat *unitQuat3 ); + +/* + * Conditionally select between two quaternions + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline void vmathQSelect( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1, unsigned int select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a quaternion + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathQPrint( const VmathQuat *quat ); + +/* + * Print a quaternion and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathQPrints( const VmathQuat *quat, const char *name ); + +#endif + +/* + * Copy a 3x3 matrix + */ +static inline void vmathM3Copy( VmathMatrix3 *result, const VmathMatrix3 *mat ); + +/* + * Construct a 3x3 matrix containing the specified columns + */ +static inline void vmathM3MakeFromCols( VmathMatrix3 *result, const VmathVector3 *col0, const VmathVector3 *col1, const VmathVector3 *col2 ); + +/* + * Construct a 3x3 rotation matrix from a unit-length quaternion + */ +static inline void vmathM3MakeFromQ( VmathMatrix3 *result, const VmathQuat *unitQuat ); + +/* + * Set all elements of a 3x3 matrix to the same scalar value + */ +static inline void vmathM3MakeFromScalar( VmathMatrix3 *result, float scalar ); + +/* + * Set column 0 of a 3x3 matrix + */ +static inline void vmathM3SetCol0( VmathMatrix3 *result, const VmathVector3 *col0 ); + +/* + * Set column 1 of a 3x3 matrix + */ +static inline void vmathM3SetCol1( VmathMatrix3 *result, const VmathVector3 *col1 ); + +/* + * Set column 2 of a 3x3 matrix + */ +static inline void vmathM3SetCol2( VmathMatrix3 *result, const VmathVector3 *col2 ); + +/* + * Get column 0 of a 3x3 matrix + */ +static inline void vmathM3GetCol0( VmathVector3 *result, const VmathMatrix3 *mat ); + +/* + * Get column 1 of a 3x3 matrix + */ +static inline void vmathM3GetCol1( VmathVector3 *result, const VmathMatrix3 *mat ); + +/* + * Get column 2 of a 3x3 matrix + */ +static inline void vmathM3GetCol2( VmathVector3 *result, const VmathMatrix3 *mat ); + +/* + * Set the column of a 3x3 matrix referred to by the specified index + */ +static inline void vmathM3SetCol( VmathMatrix3 *result, int col, const VmathVector3 *vec ); + +/* + * Set the row of a 3x3 matrix referred to by the specified index + */ +static inline void vmathM3SetRow( VmathMatrix3 *result, int row, const VmathVector3 *vec ); + +/* + * Get the column of a 3x3 matrix referred to by the specified index + */ +static inline void vmathM3GetCol( VmathVector3 *result, const VmathMatrix3 *mat, int col ); + +/* + * Get the row of a 3x3 matrix referred to by the specified index + */ +static inline void vmathM3GetRow( VmathVector3 *result, const VmathMatrix3 *mat, int row ); + +/* + * Set the element of a 3x3 matrix referred to by column and row indices + */ +static inline void vmathM3SetElem( VmathMatrix3 *result, int col, int row, float val ); + +/* + * Get the element of a 3x3 matrix referred to by column and row indices + */ +static inline float vmathM3GetElem( const VmathMatrix3 *mat, int col, int row ); + +/* + * Add two 3x3 matrices + */ +static inline void vmathM3Add( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ); + +/* + * Subtract a 3x3 matrix from another 3x3 matrix + */ +static inline void vmathM3Sub( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ); + +/* + * Negate all elements of a 3x3 matrix + */ +static inline void vmathM3Neg( VmathMatrix3 *result, const VmathMatrix3 *mat ); + +/* + * Multiply a 3x3 matrix by a scalar + */ +static inline void vmathM3ScalarMul( VmathMatrix3 *result, const VmathMatrix3 *mat, float scalar ); + +/* + * Multiply a 3x3 matrix by a 3-D vector + */ +static inline void vmathM3MulV3( VmathVector3 *result, const VmathMatrix3 *mat, const VmathVector3 *vec ); + +/* + * Multiply two 3x3 matrices + */ +static inline void vmathM3Mul( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ); + +/* + * Construct an identity 3x3 matrix + */ +static inline void vmathM3MakeIdentity( VmathMatrix3 *result ); + +/* + * Construct a 3x3 matrix to rotate around the x axis + */ +static inline void vmathM3MakeRotationX( VmathMatrix3 *result, float radians ); + +/* + * Construct a 3x3 matrix to rotate around the y axis + */ +static inline void vmathM3MakeRotationY( VmathMatrix3 *result, float radians ); + +/* + * Construct a 3x3 matrix to rotate around the z axis + */ +static inline void vmathM3MakeRotationZ( VmathMatrix3 *result, float radians ); + +/* + * Construct a 3x3 matrix to rotate around the x, y, and z axes + */ +static inline void vmathM3MakeRotationZYX( VmathMatrix3 *result, const VmathVector3 *radiansXYZ ); + +/* + * Construct a 3x3 matrix to rotate around a unit-length 3-D vector + */ +static inline void vmathM3MakeRotationAxis( VmathMatrix3 *result, float radians, const VmathVector3 *unitVec ); + +/* + * Construct a rotation matrix from a unit-length quaternion + */ +static inline void vmathM3MakeRotationQ( VmathMatrix3 *result, const VmathQuat *unitQuat ); + +/* + * Construct a 3x3 matrix to perform scaling + */ +static inline void vmathM3MakeScale( VmathMatrix3 *result, const VmathVector3 *scaleVec ); + +/* + * Append (post-multiply) a scale transformation to a 3x3 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline void vmathM3AppendScale( VmathMatrix3 *result, const VmathMatrix3 *mat, const VmathVector3 *scaleVec ); + +/* + * Prepend (pre-multiply) a scale transformation to a 3x3 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline void vmathM3PrependScale( VmathMatrix3 *result, const VmathVector3 *scaleVec, const VmathMatrix3 *mat ); + +/* + * Multiply two 3x3 matrices per element + */ +static inline void vmathM3MulPerElem( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ); + +/* + * Compute the absolute value of a 3x3 matrix per element + */ +static inline void vmathM3AbsPerElem( VmathMatrix3 *result, const VmathMatrix3 *mat ); + +/* + * Transpose of a 3x3 matrix + */ +static inline void vmathM3Transpose( VmathMatrix3 *result, const VmathMatrix3 *mat ); + +/* + * Compute the inverse of a 3x3 matrix + * NOTE: + * Result is unpredictable when the determinant of mat is equal to or near 0. + */ +static inline void vmathM3Inverse( VmathMatrix3 *result, const VmathMatrix3 *mat ); + +/* + * Determinant of a 3x3 matrix + */ +static inline float vmathM3Determinant( const VmathMatrix3 *mat ); + +/* + * Conditionally select between two 3x3 matrices + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline void vmathM3Select( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1, unsigned int select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3x3 matrix + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathM3Print( const VmathMatrix3 *mat ); + +/* + * Print a 3x3 matrix and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathM3Prints( const VmathMatrix3 *mat, const char *name ); + +#endif + +/* + * Copy a 4x4 matrix + */ +static inline void vmathM4Copy( VmathMatrix4 *result, const VmathMatrix4 *mat ); + +/* + * Construct a 4x4 matrix containing the specified columns + */ +static inline void vmathM4MakeFromCols( VmathMatrix4 *result, const VmathVector4 *col0, const VmathVector4 *col1, const VmathVector4 *col2, const VmathVector4 *col3 ); + +/* + * Construct a 4x4 matrix from a 3x4 transformation matrix + */ +static inline void vmathM4MakeFromT3( VmathMatrix4 *result, const VmathTransform3 *mat ); + +/* + * Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector + */ +static inline void vmathM4MakeFromM3V3( VmathMatrix4 *result, const VmathMatrix3 *mat, const VmathVector3 *translateVec ); + +/* + * Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector + */ +static inline void vmathM4MakeFromQV3( VmathMatrix4 *result, const VmathQuat *unitQuat, const VmathVector3 *translateVec ); + +/* + * Set all elements of a 4x4 matrix to the same scalar value + */ +static inline void vmathM4MakeFromScalar( VmathMatrix4 *result, float scalar ); + +/* + * Set the upper-left 3x3 submatrix + * NOTE: + * This function does not change the bottom row elements. + */ +static inline void vmathM4SetUpper3x3( VmathMatrix4 *result, const VmathMatrix3 *mat3 ); + +/* + * Get the upper-left 3x3 submatrix of a 4x4 matrix + */ +static inline void vmathM4GetUpper3x3( VmathMatrix3 *result, const VmathMatrix4 *mat ); + +/* + * Set translation component + * NOTE: + * This function does not change the bottom row elements. + */ +static inline void vmathM4SetTranslation( VmathMatrix4 *result, const VmathVector3 *translateVec ); + +/* + * Get the translation component of a 4x4 matrix + */ +static inline void vmathM4GetTranslation( VmathVector3 *result, const VmathMatrix4 *mat ); + +/* + * Set column 0 of a 4x4 matrix + */ +static inline void vmathM4SetCol0( VmathMatrix4 *result, const VmathVector4 *col0 ); + +/* + * Set column 1 of a 4x4 matrix + */ +static inline void vmathM4SetCol1( VmathMatrix4 *result, const VmathVector4 *col1 ); + +/* + * Set column 2 of a 4x4 matrix + */ +static inline void vmathM4SetCol2( VmathMatrix4 *result, const VmathVector4 *col2 ); + +/* + * Set column 3 of a 4x4 matrix + */ +static inline void vmathM4SetCol3( VmathMatrix4 *result, const VmathVector4 *col3 ); + +/* + * Get column 0 of a 4x4 matrix + */ +static inline void vmathM4GetCol0( VmathVector4 *result, const VmathMatrix4 *mat ); + +/* + * Get column 1 of a 4x4 matrix + */ +static inline void vmathM4GetCol1( VmathVector4 *result, const VmathMatrix4 *mat ); + +/* + * Get column 2 of a 4x4 matrix + */ +static inline void vmathM4GetCol2( VmathVector4 *result, const VmathMatrix4 *mat ); + +/* + * Get column 3 of a 4x4 matrix + */ +static inline void vmathM4GetCol3( VmathVector4 *result, const VmathMatrix4 *mat ); + +/* + * Set the column of a 4x4 matrix referred to by the specified index + */ +static inline void vmathM4SetCol( VmathMatrix4 *result, int col, const VmathVector4 *vec ); + +/* + * Set the row of a 4x4 matrix referred to by the specified index + */ +static inline void vmathM4SetRow( VmathMatrix4 *result, int row, const VmathVector4 *vec ); + +/* + * Get the column of a 4x4 matrix referred to by the specified index + */ +static inline void vmathM4GetCol( VmathVector4 *result, const VmathMatrix4 *mat, int col ); + +/* + * Get the row of a 4x4 matrix referred to by the specified index + */ +static inline void vmathM4GetRow( VmathVector4 *result, const VmathMatrix4 *mat, int row ); + +/* + * Set the element of a 4x4 matrix referred to by column and row indices + */ +static inline void vmathM4SetElem( VmathMatrix4 *result, int col, int row, float val ); + +/* + * Get the element of a 4x4 matrix referred to by column and row indices + */ +static inline float vmathM4GetElem( const VmathMatrix4 *mat, int col, int row ); + +/* + * Add two 4x4 matrices + */ +static inline void vmathM4Add( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ); + +/* + * Subtract a 4x4 matrix from another 4x4 matrix + */ +static inline void vmathM4Sub( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ); + +/* + * Negate all elements of a 4x4 matrix + */ +static inline void vmathM4Neg( VmathMatrix4 *result, const VmathMatrix4 *mat ); + +/* + * Multiply a 4x4 matrix by a scalar + */ +static inline void vmathM4ScalarMul( VmathMatrix4 *result, const VmathMatrix4 *mat, float scalar ); + +/* + * Multiply a 4x4 matrix by a 4-D vector + */ +static inline void vmathM4MulV4( VmathVector4 *result, const VmathMatrix4 *mat, const VmathVector4 *vec ); + +/* + * Multiply a 4x4 matrix by a 3-D vector + */ +static inline void vmathM4MulV3( VmathVector4 *result, const VmathMatrix4 *mat, const VmathVector3 *vec ); + +/* + * Multiply a 4x4 matrix by a 3-D point + */ +static inline void vmathM4MulP3( VmathVector4 *result, const VmathMatrix4 *mat, const VmathPoint3 *pnt ); + +/* + * Multiply two 4x4 matrices + */ +static inline void vmathM4Mul( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ); + +/* + * Multiply a 4x4 matrix by a 3x4 transformation matrix + */ +static inline void vmathM4MulT3( VmathMatrix4 *result, const VmathMatrix4 *mat, const VmathTransform3 *tfrm ); + +/* + * Construct an identity 4x4 matrix + */ +static inline void vmathM4MakeIdentity( VmathMatrix4 *result ); + +/* + * Construct a 4x4 matrix to rotate around the x axis + */ +static inline void vmathM4MakeRotationX( VmathMatrix4 *result, float radians ); + +/* + * Construct a 4x4 matrix to rotate around the y axis + */ +static inline void vmathM4MakeRotationY( VmathMatrix4 *result, float radians ); + +/* + * Construct a 4x4 matrix to rotate around the z axis + */ +static inline void vmathM4MakeRotationZ( VmathMatrix4 *result, float radians ); + +/* + * Construct a 4x4 matrix to rotate around the x, y, and z axes + */ +static inline void vmathM4MakeRotationZYX( VmathMatrix4 *result, const VmathVector3 *radiansXYZ ); + +/* + * Construct a 4x4 matrix to rotate around a unit-length 3-D vector + */ +static inline void vmathM4MakeRotationAxis( VmathMatrix4 *result, float radians, const VmathVector3 *unitVec ); + +/* + * Construct a rotation matrix from a unit-length quaternion + */ +static inline void vmathM4MakeRotationQ( VmathMatrix4 *result, const VmathQuat *unitQuat ); + +/* + * Construct a 4x4 matrix to perform scaling + */ +static inline void vmathM4MakeScale( VmathMatrix4 *result, const VmathVector3 *scaleVec ); + +/* + * Construct a 4x4 matrix to perform translation + */ +static inline void vmathM4MakeTranslation( VmathMatrix4 *result, const VmathVector3 *translateVec ); + +/* + * Construct viewing matrix based on eye position, position looked at, and up direction + */ +static inline void vmathM4MakeLookAt( VmathMatrix4 *result, const VmathPoint3 *eyePos, const VmathPoint3 *lookAtPos, const VmathVector3 *upVec ); + +/* + * Construct a perspective projection matrix + */ +static inline void vmathM4MakePerspective( VmathMatrix4 *result, float fovyRadians, float aspect, float zNear, float zFar ); + +/* + * Construct a perspective projection matrix based on frustum + */ +static inline void vmathM4MakeFrustum( VmathMatrix4 *result, float left, float right, float bottom, float top, float zNear, float zFar ); + +/* + * Construct an orthographic projection matrix + */ +static inline void vmathM4MakeOrthographic( VmathMatrix4 *result, float left, float right, float bottom, float top, float zNear, float zFar ); + +/* + * Append (post-multiply) a scale transformation to a 4x4 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline void vmathM4AppendScale( VmathMatrix4 *result, const VmathMatrix4 *mat, const VmathVector3 *scaleVec ); + +/* + * Prepend (pre-multiply) a scale transformation to a 4x4 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline void vmathM4PrependScale( VmathMatrix4 *result, const VmathVector3 *scaleVec, const VmathMatrix4 *mat ); + +/* + * Multiply two 4x4 matrices per element + */ +static inline void vmathM4MulPerElem( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ); + +/* + * Compute the absolute value of a 4x4 matrix per element + */ +static inline void vmathM4AbsPerElem( VmathMatrix4 *result, const VmathMatrix4 *mat ); + +/* + * Transpose of a 4x4 matrix + */ +static inline void vmathM4Transpose( VmathMatrix4 *result, const VmathMatrix4 *mat ); + +/* + * Compute the inverse of a 4x4 matrix + * NOTE: + * Result is unpredictable when the determinant of mat is equal to or near 0. + */ +static inline void vmathM4Inverse( VmathMatrix4 *result, const VmathMatrix4 *mat ); + +/* + * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix + * NOTE: + * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. The result is unpredictable when the determinant of mat is equal to or near 0. + */ +static inline void vmathM4AffineInverse( VmathMatrix4 *result, const VmathMatrix4 *mat ); + +/* + * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix + * NOTE: + * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. + */ +static inline void vmathM4OrthoInverse( VmathMatrix4 *result, const VmathMatrix4 *mat ); + +/* + * Determinant of a 4x4 matrix + */ +static inline float vmathM4Determinant( const VmathMatrix4 *mat ); + +/* + * Conditionally select between two 4x4 matrices + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline void vmathM4Select( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1, unsigned int select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 4x4 matrix + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathM4Print( const VmathMatrix4 *mat ); + +/* + * Print a 4x4 matrix and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathM4Prints( const VmathMatrix4 *mat, const char *name ); + +#endif + +/* + * Copy a 3x4 transformation matrix + */ +static inline void vmathT3Copy( VmathTransform3 *result, const VmathTransform3 *tfrm ); + +/* + * Construct a 3x4 transformation matrix containing the specified columns + */ +static inline void vmathT3MakeFromCols( VmathTransform3 *result, const VmathVector3 *col0, const VmathVector3 *col1, const VmathVector3 *col2, const VmathVector3 *col3 ); + +/* + * Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector + */ +static inline void vmathT3MakeFromM3V3( VmathTransform3 *result, const VmathMatrix3 *tfrm, const VmathVector3 *translateVec ); + +/* + * Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector + */ +static inline void vmathT3MakeFromQV3( VmathTransform3 *result, const VmathQuat *unitQuat, const VmathVector3 *translateVec ); + +/* + * Set all elements of a 3x4 transformation matrix to the same scalar value + */ +static inline void vmathT3MakeFromScalar( VmathTransform3 *result, float scalar ); + +/* + * Set the upper-left 3x3 submatrix + */ +static inline void vmathT3SetUpper3x3( VmathTransform3 *result, const VmathMatrix3 *mat3 ); + +/* + * Get the upper-left 3x3 submatrix of a 3x4 transformation matrix + */ +static inline void vmathT3GetUpper3x3( VmathMatrix3 *result, const VmathTransform3 *tfrm ); + +/* + * Set translation component + */ +static inline void vmathT3SetTranslation( VmathTransform3 *result, const VmathVector3 *translateVec ); + +/* + * Get the translation component of a 3x4 transformation matrix + */ +static inline void vmathT3GetTranslation( VmathVector3 *result, const VmathTransform3 *tfrm ); + +/* + * Set column 0 of a 3x4 transformation matrix + */ +static inline void vmathT3SetCol0( VmathTransform3 *result, const VmathVector3 *col0 ); + +/* + * Set column 1 of a 3x4 transformation matrix + */ +static inline void vmathT3SetCol1( VmathTransform3 *result, const VmathVector3 *col1 ); + +/* + * Set column 2 of a 3x4 transformation matrix + */ +static inline void vmathT3SetCol2( VmathTransform3 *result, const VmathVector3 *col2 ); + +/* + * Set column 3 of a 3x4 transformation matrix + */ +static inline void vmathT3SetCol3( VmathTransform3 *result, const VmathVector3 *col3 ); + +/* + * Get column 0 of a 3x4 transformation matrix + */ +static inline void vmathT3GetCol0( VmathVector3 *result, const VmathTransform3 *tfrm ); + +/* + * Get column 1 of a 3x4 transformation matrix + */ +static inline void vmathT3GetCol1( VmathVector3 *result, const VmathTransform3 *tfrm ); + +/* + * Get column 2 of a 3x4 transformation matrix + */ +static inline void vmathT3GetCol2( VmathVector3 *result, const VmathTransform3 *tfrm ); + +/* + * Get column 3 of a 3x4 transformation matrix + */ +static inline void vmathT3GetCol3( VmathVector3 *result, const VmathTransform3 *tfrm ); + +/* + * Set the column of a 3x4 transformation matrix referred to by the specified index + */ +static inline void vmathT3SetCol( VmathTransform3 *result, int col, const VmathVector3 *vec ); + +/* + * Set the row of a 3x4 transformation matrix referred to by the specified index + */ +static inline void vmathT3SetRow( VmathTransform3 *result, int row, const VmathVector4 *vec ); + +/* + * Get the column of a 3x4 transformation matrix referred to by the specified index + */ +static inline void vmathT3GetCol( VmathVector3 *result, const VmathTransform3 *tfrm, int col ); + +/* + * Get the row of a 3x4 transformation matrix referred to by the specified index + */ +static inline void vmathT3GetRow( VmathVector4 *result, const VmathTransform3 *tfrm, int row ); + +/* + * Set the element of a 3x4 transformation matrix referred to by column and row indices + */ +static inline void vmathT3SetElem( VmathTransform3 *result, int col, int row, float val ); + +/* + * Get the element of a 3x4 transformation matrix referred to by column and row indices + */ +static inline float vmathT3GetElem( const VmathTransform3 *tfrm, int col, int row ); + +/* + * Multiply a 3x4 transformation matrix by a 3-D vector + */ +static inline void vmathT3MulV3( VmathVector3 *result, const VmathTransform3 *tfrm, const VmathVector3 *vec ); + +/* + * Multiply a 3x4 transformation matrix by a 3-D point + */ +static inline void vmathT3MulP3( VmathPoint3 *result, const VmathTransform3 *tfrm, const VmathPoint3 *pnt ); + +/* + * Multiply two 3x4 transformation matrices + */ +static inline void vmathT3Mul( VmathTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1 ); + +/* + * Construct an identity 3x4 transformation matrix + */ +static inline void vmathT3MakeIdentity( VmathTransform3 *result ); + +/* + * Construct a 3x4 transformation matrix to rotate around the x axis + */ +static inline void vmathT3MakeRotationX( VmathTransform3 *result, float radians ); + +/* + * Construct a 3x4 transformation matrix to rotate around the y axis + */ +static inline void vmathT3MakeRotationY( VmathTransform3 *result, float radians ); + +/* + * Construct a 3x4 transformation matrix to rotate around the z axis + */ +static inline void vmathT3MakeRotationZ( VmathTransform3 *result, float radians ); + +/* + * Construct a 3x4 transformation matrix to rotate around the x, y, and z axes + */ +static inline void vmathT3MakeRotationZYX( VmathTransform3 *result, const VmathVector3 *radiansXYZ ); + +/* + * Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector + */ +static inline void vmathT3MakeRotationAxis( VmathTransform3 *result, float radians, const VmathVector3 *unitVec ); + +/* + * Construct a rotation matrix from a unit-length quaternion + */ +static inline void vmathT3MakeRotationQ( VmathTransform3 *result, const VmathQuat *unitQuat ); + +/* + * Construct a 3x4 transformation matrix to perform scaling + */ +static inline void vmathT3MakeScale( VmathTransform3 *result, const VmathVector3 *scaleVec ); + +/* + * Construct a 3x4 transformation matrix to perform translation + */ +static inline void vmathT3MakeTranslation( VmathTransform3 *result, const VmathVector3 *translateVec ); + +/* + * Append (post-multiply) a scale transformation to a 3x4 transformation matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline void vmathT3AppendScale( VmathTransform3 *result, const VmathTransform3 *tfrm, const VmathVector3 *scaleVec ); + +/* + * Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline void vmathT3PrependScale( VmathTransform3 *result, const VmathVector3 *scaleVec, const VmathTransform3 *tfrm ); + +/* + * Multiply two 3x4 transformation matrices per element + */ +static inline void vmathT3MulPerElem( VmathTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1 ); + +/* + * Compute the absolute value of a 3x4 transformation matrix per element + */ +static inline void vmathT3AbsPerElem( VmathTransform3 *result, const VmathTransform3 *tfrm ); + +/* + * Inverse of a 3x4 transformation matrix + * NOTE: + * Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0. + */ +static inline void vmathT3Inverse( VmathTransform3 *result, const VmathTransform3 *tfrm ); + +/* + * Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix + * NOTE: + * This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions. + */ +static inline void vmathT3OrthoInverse( VmathTransform3 *result, const VmathTransform3 *tfrm ); + +/* + * Conditionally select between two 3x4 transformation matrices + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline void vmathT3Select( VmathTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1, unsigned int select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3x4 transformation matrix + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathT3Print( const VmathTransform3 *tfrm ); + +/* + * Print a 3x4 transformation matrix and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathT3Prints( const VmathTransform3 *tfrm, const char *name ); + +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include "vec_aos.h" +#include "quat_aos.h" +#include "mat_aos.h" + +#endif diff --git a/vectormathlibrary/include/vectormath/spu/c/vectormath_aos_v.h b/vectormathlibrary/include/vectormath/spu/c/vectormath_aos_v.h new file mode 100644 index 000000000..cca0872f0 --- /dev/null +++ b/vectormathlibrary/include/vectormath/spu/c/vectormath_aos_v.h @@ -0,0 +1,1916 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_AOS_C_V_SPU_H +#define _VECTORMATH_AOS_C_V_SPU_H + +#include <math.h> +#include <spu_intrinsics.h> + +#ifdef _VECTORMATH_DEBUG +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#ifndef _VECTORMATH_AOS_C_TYPES_H +#define _VECTORMATH_AOS_C_TYPES_H + +/* A 3-D vector in array-of-structures format + */ +typedef struct _VmathVector3 +{ + vec_float4 vec128; +} VmathVector3; + +/* A 4-D vector in array-of-structures format + */ +typedef struct _VmathVector4 +{ + vec_float4 vec128; +} VmathVector4; + +/* A 3-D point in array-of-structures format + */ +typedef struct _VmathPoint3 +{ + vec_float4 vec128; +} VmathPoint3; + +/* A quaternion in array-of-structures format + */ +typedef struct _VmathQuat +{ + vec_float4 vec128; +} VmathQuat; + +/* A 3x3 matrix in array-of-structures format + */ +typedef struct _VmathMatrix3 +{ + VmathVector3 col0; + VmathVector3 col1; + VmathVector3 col2; +} VmathMatrix3; + +/* A 4x4 matrix in array-of-structures format + */ +typedef struct _VmathMatrix4 +{ + VmathVector4 col0; + VmathVector4 col1; + VmathVector4 col2; + VmathVector4 col3; +} VmathMatrix4; + +/* A 3x4 transformation matrix in array-of-structures format + */ +typedef struct _VmathTransform3 +{ + VmathVector3 col0; + VmathVector3 col1; + VmathVector3 col2; + VmathVector3 col3; +} VmathTransform3; + +#endif + +/* + * Construct a 3-D vector from x, y, and z elements + */ +static inline VmathVector3 vmathV3MakeFromElems_V( float x, float y, float z ); + +/* + * Copy elements from a 3-D point into a 3-D vector + */ +static inline VmathVector3 vmathV3MakeFromP3_V( VmathPoint3 pnt ); + +/* + * Set all elements of a 3-D vector to the same scalar value + */ +static inline VmathVector3 vmathV3MakeFromScalar_V( float scalar ); + +/* + * Set vector float data in a 3-D vector + */ +static inline VmathVector3 vmathV3MakeFrom128_V( vec_float4 vf4 ); + +/* + * Get vector float data from a 3-D vector + */ +static inline vec_float4 vmathV3Get128_V( VmathVector3 vec ); + +/* + * Set the x element of a 3-D vector + */ +static inline void vmathV3SetX_V( VmathVector3 *result, float x ); + +/* + * Set the y element of a 3-D vector + */ +static inline void vmathV3SetY_V( VmathVector3 *result, float y ); + +/* + * Set the z element of a 3-D vector + */ +static inline void vmathV3SetZ_V( VmathVector3 *result, float z ); + +/* + * Get the x element of a 3-D vector + */ +static inline float vmathV3GetX_V( VmathVector3 vec ); + +/* + * Get the y element of a 3-D vector + */ +static inline float vmathV3GetY_V( VmathVector3 vec ); + +/* + * Get the z element of a 3-D vector + */ +static inline float vmathV3GetZ_V( VmathVector3 vec ); + +/* + * Set an x, y, or z element of a 3-D vector by index + */ +static inline void vmathV3SetElem_V( VmathVector3 *result, int idx, float value ); + +/* + * Get an x, y, or z element of a 3-D vector by index + */ +static inline float vmathV3GetElem_V( VmathVector3 vec, int idx ); + +/* + * Add two 3-D vectors + */ +static inline VmathVector3 vmathV3Add_V( VmathVector3 vec0, VmathVector3 vec1 ); + +/* + * Subtract a 3-D vector from another 3-D vector + */ +static inline VmathVector3 vmathV3Sub_V( VmathVector3 vec0, VmathVector3 vec1 ); + +/* + * Add a 3-D vector to a 3-D point + */ +static inline VmathPoint3 vmathV3AddP3_V( VmathVector3 vec, VmathPoint3 pnt ); + +/* + * Multiply a 3-D vector by a scalar + */ +static inline VmathVector3 vmathV3ScalarMul_V( VmathVector3 vec, float scalar ); + +/* + * Divide a 3-D vector by a scalar + */ +static inline VmathVector3 vmathV3ScalarDiv_V( VmathVector3 vec, float scalar ); + +/* + * Negate all elements of a 3-D vector + */ +static inline VmathVector3 vmathV3Neg_V( VmathVector3 vec ); + +/* + * Construct x axis + */ +static inline VmathVector3 vmathV3MakeXAxis_V( ); + +/* + * Construct y axis + */ +static inline VmathVector3 vmathV3MakeYAxis_V( ); + +/* + * Construct z axis + */ +static inline VmathVector3 vmathV3MakeZAxis_V( ); + +/* + * Multiply two 3-D vectors per element + */ +static inline VmathVector3 vmathV3MulPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ); + +/* + * Divide two 3-D vectors per element + * NOTE: + * Floating-point behavior matches standard library function divf4. + */ +static inline VmathVector3 vmathV3DivPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ); + +/* + * Compute the reciprocal of a 3-D vector per element + * NOTE: + * Floating-point behavior matches standard library function recipf4. + */ +static inline VmathVector3 vmathV3RecipPerElem_V( VmathVector3 vec ); + +/* + * Compute the square root of a 3-D vector per element + * NOTE: + * Floating-point behavior matches standard library function sqrtf4. + */ +static inline VmathVector3 vmathV3SqrtPerElem_V( VmathVector3 vec ); + +/* + * Compute the reciprocal square root of a 3-D vector per element + * NOTE: + * Floating-point behavior matches standard library function rsqrtf4. + */ +static inline VmathVector3 vmathV3RsqrtPerElem_V( VmathVector3 vec ); + +/* + * Compute the absolute value of a 3-D vector per element + */ +static inline VmathVector3 vmathV3AbsPerElem_V( VmathVector3 vec ); + +/* + * Copy sign from one 3-D vector to another, per element + */ +static inline VmathVector3 vmathV3CopySignPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ); + +/* + * Maximum of two 3-D vectors per element + */ +static inline VmathVector3 vmathV3MaxPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ); + +/* + * Minimum of two 3-D vectors per element + */ +static inline VmathVector3 vmathV3MinPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ); + +/* + * Maximum element of a 3-D vector + */ +static inline float vmathV3MaxElem_V( VmathVector3 vec ); + +/* + * Minimum element of a 3-D vector + */ +static inline float vmathV3MinElem_V( VmathVector3 vec ); + +/* + * Compute the sum of all elements of a 3-D vector + */ +static inline float vmathV3Sum_V( VmathVector3 vec ); + +/* + * Compute the dot product of two 3-D vectors + */ +static inline float vmathV3Dot_V( VmathVector3 vec0, VmathVector3 vec1 ); + +/* + * Compute the square of the length of a 3-D vector + */ +static inline float vmathV3LengthSqr_V( VmathVector3 vec ); + +/* + * Compute the length of a 3-D vector + */ +static inline float vmathV3Length_V( VmathVector3 vec ); + +/* + * Normalize a 3-D vector + * NOTE: + * The result is unpredictable when all elements of vec are at or near zero. + */ +static inline VmathVector3 vmathV3Normalize_V( VmathVector3 vec ); + +/* + * Compute cross product of two 3-D vectors + */ +static inline VmathVector3 vmathV3Cross_V( VmathVector3 vec0, VmathVector3 vec1 ); + +/* + * Outer product of two 3-D vectors + */ +static inline VmathMatrix3 vmathV3Outer_V( VmathVector3 vec0, VmathVector3 vec1 ); + +/* + * Pre-multiply a row vector by a 3x3 matrix + * NOTE: + * Slower than column post-multiply. + */ +static inline VmathVector3 vmathV3RowMul_V( VmathVector3 vec, VmathMatrix3 mat ); + +/* + * Cross-product matrix of a 3-D vector + */ +static inline VmathMatrix3 vmathV3CrossMatrix_V( VmathVector3 vec ); + +/* + * Create cross-product matrix and multiply + * NOTE: + * Faster than separately creating a cross-product matrix and multiplying. + */ +static inline VmathMatrix3 vmathV3CrossMatrixMul_V( VmathVector3 vec, VmathMatrix3 mat ); + +/* + * Linear interpolation between two 3-D vectors + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline VmathVector3 vmathV3Lerp_V( float t, VmathVector3 vec0, VmathVector3 vec1 ); + +/* + * Spherical linear interpolation between two 3-D vectors + * NOTE: + * The result is unpredictable if the vectors point in opposite directions. + * Does not clamp t between 0 and 1. + */ +static inline VmathVector3 vmathV3Slerp_V( float t, VmathVector3 unitVec0, VmathVector3 unitVec1 ); + +/* + * Conditionally select between two 3-D vectors + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline VmathVector3 vmathV3Select_V( VmathVector3 vec0, VmathVector3 vec1, unsigned int select1 ); + +/* + * Store x, y, and z elements of a 3-D vector in the first three words of a quadword. + * The value of the fourth word (the word with the highest address) remains unchanged + */ +static inline void vmathV3StoreXYZ_V( VmathVector3 vec, vec_float4 *quad ); + +/* + * Load four three-float 3-D vectors, stored in three quadwords + */ +static inline void vmathV3LoadXYZArray_V( VmathVector3 *vec0, VmathVector3 *vec1, VmathVector3 *vec2, VmathVector3 *vec3, const vec_float4 *threeQuads ); + +/* + * Store four 3-D vectors in three quadwords + */ +static inline void vmathV3StoreXYZArray_V( VmathVector3 vec0, VmathVector3 vec1, VmathVector3 vec2, VmathVector3 vec3, vec_float4 *threeQuads ); + +/* + * Store eight 3-D vectors as half-floats + */ +static inline void vmathV3StoreHalfFloats_V( VmathVector3 vec0, VmathVector3 vec1, VmathVector3 vec2, VmathVector3 vec3, VmathVector3 vec4, VmathVector3 vec5, VmathVector3 vec6, VmathVector3 vec7, vec_ushort8 *threeQuads ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3-D vector + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathV3Print_V( VmathVector3 vec ); + +/* + * Print a 3-D vector and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathV3Prints_V( VmathVector3 vec, const char *name ); + +#endif + +/* + * Construct a 4-D vector from x, y, z, and w elements + */ +static inline VmathVector4 vmathV4MakeFromElems_V( float x, float y, float z, float w ); + +/* + * Construct a 4-D vector from a 3-D vector and a scalar + */ +static inline VmathVector4 vmathV4MakeFromV3Scalar_V( VmathVector3 xyz, float w ); + +/* + * Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0 + */ +static inline VmathVector4 vmathV4MakeFromV3_V( VmathVector3 vec ); + +/* + * Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1 + */ +static inline VmathVector4 vmathV4MakeFromP3_V( VmathPoint3 pnt ); + +/* + * Copy elements from a quaternion into a 4-D vector + */ +static inline VmathVector4 vmathV4MakeFromQ_V( VmathQuat quat ); + +/* + * Set all elements of a 4-D vector to the same scalar value + */ +static inline VmathVector4 vmathV4MakeFromScalar_V( float scalar ); + +/* + * Set vector float data in a 4-D vector + */ +static inline VmathVector4 vmathV4MakeFrom128_V( vec_float4 vf4 ); + +/* + * Get vector float data from a 4-D vector + */ +static inline vec_float4 vmathV4Get128_V( VmathVector4 vec ); + +/* + * Set the x, y, and z elements of a 4-D vector + * NOTE: + * This function does not change the w element. + */ +static inline void vmathV4SetXYZ_V( VmathVector4 *result, VmathVector3 vec ); + +/* + * Get the x, y, and z elements of a 4-D vector + */ +static inline VmathVector3 vmathV4GetXYZ_V( VmathVector4 vec ); + +/* + * Set the x element of a 4-D vector + */ +static inline void vmathV4SetX_V( VmathVector4 *result, float x ); + +/* + * Set the y element of a 4-D vector + */ +static inline void vmathV4SetY_V( VmathVector4 *result, float y ); + +/* + * Set the z element of a 4-D vector + */ +static inline void vmathV4SetZ_V( VmathVector4 *result, float z ); + +/* + * Set the w element of a 4-D vector + */ +static inline void vmathV4SetW_V( VmathVector4 *result, float w ); + +/* + * Get the x element of a 4-D vector + */ +static inline float vmathV4GetX_V( VmathVector4 vec ); + +/* + * Get the y element of a 4-D vector + */ +static inline float vmathV4GetY_V( VmathVector4 vec ); + +/* + * Get the z element of a 4-D vector + */ +static inline float vmathV4GetZ_V( VmathVector4 vec ); + +/* + * Get the w element of a 4-D vector + */ +static inline float vmathV4GetW_V( VmathVector4 vec ); + +/* + * Set an x, y, z, or w element of a 4-D vector by index + */ +static inline void vmathV4SetElem_V( VmathVector4 *result, int idx, float value ); + +/* + * Get an x, y, z, or w element of a 4-D vector by index + */ +static inline float vmathV4GetElem_V( VmathVector4 vec, int idx ); + +/* + * Add two 4-D vectors + */ +static inline VmathVector4 vmathV4Add_V( VmathVector4 vec0, VmathVector4 vec1 ); + +/* + * Subtract a 4-D vector from another 4-D vector + */ +static inline VmathVector4 vmathV4Sub_V( VmathVector4 vec0, VmathVector4 vec1 ); + +/* + * Multiply a 4-D vector by a scalar + */ +static inline VmathVector4 vmathV4ScalarMul_V( VmathVector4 vec, float scalar ); + +/* + * Divide a 4-D vector by a scalar + */ +static inline VmathVector4 vmathV4ScalarDiv_V( VmathVector4 vec, float scalar ); + +/* + * Negate all elements of a 4-D vector + */ +static inline VmathVector4 vmathV4Neg_V( VmathVector4 vec ); + +/* + * Construct x axis + */ +static inline VmathVector4 vmathV4MakeXAxis_V( ); + +/* + * Construct y axis + */ +static inline VmathVector4 vmathV4MakeYAxis_V( ); + +/* + * Construct z axis + */ +static inline VmathVector4 vmathV4MakeZAxis_V( ); + +/* + * Construct w axis + */ +static inline VmathVector4 vmathV4MakeWAxis_V( ); + +/* + * Multiply two 4-D vectors per element + */ +static inline VmathVector4 vmathV4MulPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ); + +/* + * Divide two 4-D vectors per element + * NOTE: + * Floating-point behavior matches standard library function divf4. + */ +static inline VmathVector4 vmathV4DivPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ); + +/* + * Compute the reciprocal of a 4-D vector per element + * NOTE: + * Floating-point behavior matches standard library function recipf4. + */ +static inline VmathVector4 vmathV4RecipPerElem_V( VmathVector4 vec ); + +/* + * Compute the square root of a 4-D vector per element + * NOTE: + * Floating-point behavior matches standard library function sqrtf4. + */ +static inline VmathVector4 vmathV4SqrtPerElem_V( VmathVector4 vec ); + +/* + * Compute the reciprocal square root of a 4-D vector per element + * NOTE: + * Floating-point behavior matches standard library function rsqrtf4. + */ +static inline VmathVector4 vmathV4RsqrtPerElem_V( VmathVector4 vec ); + +/* + * Compute the absolute value of a 4-D vector per element + */ +static inline VmathVector4 vmathV4AbsPerElem_V( VmathVector4 vec ); + +/* + * Copy sign from one 4-D vector to another, per element + */ +static inline VmathVector4 vmathV4CopySignPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ); + +/* + * Maximum of two 4-D vectors per element + */ +static inline VmathVector4 vmathV4MaxPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ); + +/* + * Minimum of two 4-D vectors per element + */ +static inline VmathVector4 vmathV4MinPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ); + +/* + * Maximum element of a 4-D vector + */ +static inline float vmathV4MaxElem_V( VmathVector4 vec ); + +/* + * Minimum element of a 4-D vector + */ +static inline float vmathV4MinElem_V( VmathVector4 vec ); + +/* + * Compute the sum of all elements of a 4-D vector + */ +static inline float vmathV4Sum_V( VmathVector4 vec ); + +/* + * Compute the dot product of two 4-D vectors + */ +static inline float vmathV4Dot_V( VmathVector4 vec0, VmathVector4 vec1 ); + +/* + * Compute the square of the length of a 4-D vector + */ +static inline float vmathV4LengthSqr_V( VmathVector4 vec ); + +/* + * Compute the length of a 4-D vector + */ +static inline float vmathV4Length_V( VmathVector4 vec ); + +/* + * Normalize a 4-D vector + * NOTE: + * The result is unpredictable when all elements of vec are at or near zero. + */ +static inline VmathVector4 vmathV4Normalize_V( VmathVector4 vec ); + +/* + * Outer product of two 4-D vectors + */ +static inline VmathMatrix4 vmathV4Outer_V( VmathVector4 vec0, VmathVector4 vec1 ); + +/* + * Linear interpolation between two 4-D vectors + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline VmathVector4 vmathV4Lerp_V( float t, VmathVector4 vec0, VmathVector4 vec1 ); + +/* + * Spherical linear interpolation between two 4-D vectors + * NOTE: + * The result is unpredictable if the vectors point in opposite directions. + * Does not clamp t between 0 and 1. + */ +static inline VmathVector4 vmathV4Slerp_V( float t, VmathVector4 unitVec0, VmathVector4 unitVec1 ); + +/* + * Conditionally select between two 4-D vectors + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline VmathVector4 vmathV4Select_V( VmathVector4 vec0, VmathVector4 vec1, unsigned int select1 ); + +/* + * Store four 4-D vectors as half-floats + */ +static inline void vmathV4StoreHalfFloats_V( VmathVector4 vec0, VmathVector4 vec1, VmathVector4 vec2, VmathVector4 vec3, vec_ushort8 *twoQuads ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 4-D vector + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathV4Print_V( VmathVector4 vec ); + +/* + * Print a 4-D vector and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathV4Prints_V( VmathVector4 vec, const char *name ); + +#endif + +/* + * Construct a 3-D point from x, y, and z elements + */ +static inline VmathPoint3 vmathP3MakeFromElems_V( float x, float y, float z ); + +/* + * Copy elements from a 3-D vector into a 3-D point + */ +static inline VmathPoint3 vmathP3MakeFromV3_V( VmathVector3 vec ); + +/* + * Set all elements of a 3-D point to the same scalar value + */ +static inline VmathPoint3 vmathP3MakeFromScalar_V( float scalar ); + +/* + * Set vector float data in a 3-D point + */ +static inline VmathPoint3 vmathP3MakeFrom128_V( vec_float4 vf4 ); + +/* + * Get vector float data from a 3-D point + */ +static inline vec_float4 vmathP3Get128_V( VmathPoint3 pnt ); + +/* + * Set the x element of a 3-D point + */ +static inline void vmathP3SetX_V( VmathPoint3 *result, float x ); + +/* + * Set the y element of a 3-D point + */ +static inline void vmathP3SetY_V( VmathPoint3 *result, float y ); + +/* + * Set the z element of a 3-D point + */ +static inline void vmathP3SetZ_V( VmathPoint3 *result, float z ); + +/* + * Get the x element of a 3-D point + */ +static inline float vmathP3GetX_V( VmathPoint3 pnt ); + +/* + * Get the y element of a 3-D point + */ +static inline float vmathP3GetY_V( VmathPoint3 pnt ); + +/* + * Get the z element of a 3-D point + */ +static inline float vmathP3GetZ_V( VmathPoint3 pnt ); + +/* + * Set an x, y, or z element of a 3-D point by index + */ +static inline void vmathP3SetElem_V( VmathPoint3 *result, int idx, float value ); + +/* + * Get an x, y, or z element of a 3-D point by index + */ +static inline float vmathP3GetElem_V( VmathPoint3 pnt, int idx ); + +/* + * Subtract a 3-D point from another 3-D point + */ +static inline VmathVector3 vmathP3Sub_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); + +/* + * Add a 3-D point to a 3-D vector + */ +static inline VmathPoint3 vmathP3AddV3_V( VmathPoint3 pnt, VmathVector3 vec ); + +/* + * Subtract a 3-D vector from a 3-D point + */ +static inline VmathPoint3 vmathP3SubV3_V( VmathPoint3 pnt, VmathVector3 vec ); + +/* + * Multiply two 3-D points per element + */ +static inline VmathPoint3 vmathP3MulPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); + +/* + * Divide two 3-D points per element + * NOTE: + * Floating-point behavior matches standard library function divf4. + */ +static inline VmathPoint3 vmathP3DivPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); + +/* + * Compute the reciprocal of a 3-D point per element + * NOTE: + * Floating-point behavior matches standard library function recipf4. + */ +static inline VmathPoint3 vmathP3RecipPerElem_V( VmathPoint3 pnt ); + +/* + * Compute the square root of a 3-D point per element + * NOTE: + * Floating-point behavior matches standard library function sqrtf4. + */ +static inline VmathPoint3 vmathP3SqrtPerElem_V( VmathPoint3 pnt ); + +/* + * Compute the reciprocal square root of a 3-D point per element + * NOTE: + * Floating-point behavior matches standard library function rsqrtf4. + */ +static inline VmathPoint3 vmathP3RsqrtPerElem_V( VmathPoint3 pnt ); + +/* + * Compute the absolute value of a 3-D point per element + */ +static inline VmathPoint3 vmathP3AbsPerElem_V( VmathPoint3 pnt ); + +/* + * Copy sign from one 3-D point to another, per element + */ +static inline VmathPoint3 vmathP3CopySignPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); + +/* + * Maximum of two 3-D points per element + */ +static inline VmathPoint3 vmathP3MaxPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); + +/* + * Minimum of two 3-D points per element + */ +static inline VmathPoint3 vmathP3MinPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); + +/* + * Maximum element of a 3-D point + */ +static inline float vmathP3MaxElem_V( VmathPoint3 pnt ); + +/* + * Minimum element of a 3-D point + */ +static inline float vmathP3MinElem_V( VmathPoint3 pnt ); + +/* + * Compute the sum of all elements of a 3-D point + */ +static inline float vmathP3Sum_V( VmathPoint3 pnt ); + +/* + * Apply uniform scale to a 3-D point + */ +static inline VmathPoint3 vmathP3Scale_V( VmathPoint3 pnt, float scaleVal ); + +/* + * Apply non-uniform scale to a 3-D point + */ +static inline VmathPoint3 vmathP3NonUniformScale_V( VmathPoint3 pnt, VmathVector3 scaleVec ); + +/* + * Scalar projection of a 3-D point on a unit-length 3-D vector + */ +static inline float vmathP3Projection_V( VmathPoint3 pnt, VmathVector3 unitVec ); + +/* + * Compute the square of the distance of a 3-D point from the coordinate-system origin + */ +static inline float vmathP3DistSqrFromOrigin_V( VmathPoint3 pnt ); + +/* + * Compute the distance of a 3-D point from the coordinate-system origin + */ +static inline float vmathP3DistFromOrigin_V( VmathPoint3 pnt ); + +/* + * Compute the square of the distance between two 3-D points + */ +static inline float vmathP3DistSqr_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); + +/* + * Compute the distance between two 3-D points + */ +static inline float vmathP3Dist_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); + +/* + * Linear interpolation between two 3-D points + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline VmathPoint3 vmathP3Lerp_V( float t, VmathPoint3 pnt0, VmathPoint3 pnt1 ); + +/* + * Conditionally select between two 3-D points + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline VmathPoint3 vmathP3Select_V( VmathPoint3 pnt0, VmathPoint3 pnt1, unsigned int select1 ); + +/* + * Store x, y, and z elements of a 3-D point in the first three words of a quadword. + * The value of the fourth word (the word with the highest address) remains unchanged + */ +static inline void vmathP3StoreXYZ_V( VmathPoint3 pnt, vec_float4 *quad ); + +/* + * Load four three-float 3-D points, stored in three quadwords + */ +static inline void vmathP3LoadXYZArray_V( VmathPoint3 *pnt0, VmathPoint3 *pnt1, VmathPoint3 *pnt2, VmathPoint3 *pnt3, const vec_float4 *threeQuads ); + +/* + * Store four 3-D points in three quadwords + */ +static inline void vmathP3StoreXYZArray_V( VmathPoint3 pnt0, VmathPoint3 pnt1, VmathPoint3 pnt2, VmathPoint3 pnt3, vec_float4 *threeQuads ); + +/* + * Store eight 3-D points as half-floats + */ +static inline void vmathP3StoreHalfFloats_V( VmathPoint3 pnt0, VmathPoint3 pnt1, VmathPoint3 pnt2, VmathPoint3 pnt3, VmathPoint3 pnt4, VmathPoint3 pnt5, VmathPoint3 pnt6, VmathPoint3 pnt7, vec_ushort8 *threeQuads ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3-D point + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathP3Print_V( VmathPoint3 pnt ); + +/* + * Print a 3-D point and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathP3Prints_V( VmathPoint3 pnt, const char *name ); + +#endif + +/* + * Construct a quaternion from x, y, z, and w elements + */ +static inline VmathQuat vmathQMakeFromElems_V( float x, float y, float z, float w ); + +/* + * Construct a quaternion from a 3-D vector and a scalar + */ +static inline VmathQuat vmathQMakeFromV3Scalar_V( VmathVector3 xyz, float w ); + +/* + * Copy elements from a 4-D vector into a quaternion + */ +static inline VmathQuat vmathQMakeFromV4_V( VmathVector4 vec ); + +/* + * Convert a rotation matrix to a unit-length quaternion + */ +static inline VmathQuat vmathQMakeFromM3_V( VmathMatrix3 rotMat ); + +/* + * Set all elements of a quaternion to the same scalar value + */ +static inline VmathQuat vmathQMakeFromScalar_V( float scalar ); + +/* + * Set vector float data in a quaternion + */ +static inline VmathQuat vmathQMakeFrom128_V( vec_float4 vf4 ); + +/* + * Get vector float data from a quaternion + */ +static inline vec_float4 vmathQGet128_V( VmathQuat quat ); + +/* + * Set the x, y, and z elements of a quaternion + * NOTE: + * This function does not change the w element. + */ +static inline void vmathQSetXYZ_V( VmathQuat *result, VmathVector3 vec ); + +/* + * Get the x, y, and z elements of a quaternion + */ +static inline VmathVector3 vmathQGetXYZ_V( VmathQuat quat ); + +/* + * Set the x element of a quaternion + */ +static inline void vmathQSetX_V( VmathQuat *result, float x ); + +/* + * Set the y element of a quaternion + */ +static inline void vmathQSetY_V( VmathQuat *result, float y ); + +/* + * Set the z element of a quaternion + */ +static inline void vmathQSetZ_V( VmathQuat *result, float z ); + +/* + * Set the w element of a quaternion + */ +static inline void vmathQSetW_V( VmathQuat *result, float w ); + +/* + * Get the x element of a quaternion + */ +static inline float vmathQGetX_V( VmathQuat quat ); + +/* + * Get the y element of a quaternion + */ +static inline float vmathQGetY_V( VmathQuat quat ); + +/* + * Get the z element of a quaternion + */ +static inline float vmathQGetZ_V( VmathQuat quat ); + +/* + * Get the w element of a quaternion + */ +static inline float vmathQGetW_V( VmathQuat quat ); + +/* + * Set an x, y, z, or w element of a quaternion by index + */ +static inline void vmathQSetElem_V( VmathQuat *result, int idx, float value ); + +/* + * Get an x, y, z, or w element of a quaternion by index + */ +static inline float vmathQGetElem_V( VmathQuat quat, int idx ); + +/* + * Add two quaternions + */ +static inline VmathQuat vmathQAdd_V( VmathQuat quat0, VmathQuat quat1 ); + +/* + * Subtract a quaternion from another quaternion + */ +static inline VmathQuat vmathQSub_V( VmathQuat quat0, VmathQuat quat1 ); + +/* + * Multiply two quaternions + */ +static inline VmathQuat vmathQMul_V( VmathQuat quat0, VmathQuat quat1 ); + +/* + * Multiply a quaternion by a scalar + */ +static inline VmathQuat vmathQScalarMul_V( VmathQuat quat, float scalar ); + +/* + * Divide a quaternion by a scalar + */ +static inline VmathQuat vmathQScalarDiv_V( VmathQuat quat, float scalar ); + +/* + * Negate all elements of a quaternion + */ +static inline VmathQuat vmathQNeg_V( VmathQuat quat ); + +/* + * Construct an identity quaternion + */ +static inline VmathQuat vmathQMakeIdentity_V( ); + +/* + * Construct a quaternion to rotate between two unit-length 3-D vectors + * NOTE: + * The result is unpredictable if unitVec0 and unitVec1 point in opposite directions. + */ +static inline VmathQuat vmathQMakeRotationArc_V( VmathVector3 unitVec0, VmathVector3 unitVec1 ); + +/* + * Construct a quaternion to rotate around a unit-length 3-D vector + */ +static inline VmathQuat vmathQMakeRotationAxis_V( float radians, VmathVector3 unitVec ); + +/* + * Construct a quaternion to rotate around the x axis + */ +static inline VmathQuat vmathQMakeRotationX_V( float radians ); + +/* + * Construct a quaternion to rotate around the y axis + */ +static inline VmathQuat vmathQMakeRotationY_V( float radians ); + +/* + * Construct a quaternion to rotate around the z axis + */ +static inline VmathQuat vmathQMakeRotationZ_V( float radians ); + +/* + * Compute the conjugate of a quaternion + */ +static inline VmathQuat vmathQConj_V( VmathQuat quat ); + +/* + * Use a unit-length quaternion to rotate a 3-D vector + */ +static inline VmathVector3 vmathQRotate_V( VmathQuat unitQuat, VmathVector3 vec ); + +/* + * Compute the dot product of two quaternions + */ +static inline float vmathQDot_V( VmathQuat quat0, VmathQuat quat1 ); + +/* + * Compute the norm of a quaternion + */ +static inline float vmathQNorm_V( VmathQuat quat ); + +/* + * Compute the length of a quaternion + */ +static inline float vmathQLength_V( VmathQuat quat ); + +/* + * Normalize a quaternion + * NOTE: + * The result is unpredictable when all elements of quat are at or near zero. + */ +static inline VmathQuat vmathQNormalize_V( VmathQuat quat ); + +/* + * Linear interpolation between two quaternions + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline VmathQuat vmathQLerp_V( float t, VmathQuat quat0, VmathQuat quat1 ); + +/* + * Spherical linear interpolation between two quaternions + * NOTE: + * Interpolates along the shortest path between orientations. + * Does not clamp t between 0 and 1. + */ +static inline VmathQuat vmathQSlerp_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1 ); + +/* + * Spherical quadrangle interpolation + */ +static inline VmathQuat vmathQSquad_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1, VmathQuat unitQuat2, VmathQuat unitQuat3 ); + +/* + * Conditionally select between two quaternions + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline VmathQuat vmathQSelect_V( VmathQuat quat0, VmathQuat quat1, unsigned int select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a quaternion + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathQPrint_V( VmathQuat quat ); + +/* + * Print a quaternion and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathQPrints_V( VmathQuat quat, const char *name ); + +#endif + +/* + * Construct a 3x3 matrix containing the specified columns + */ +static inline VmathMatrix3 vmathM3MakeFromCols_V( VmathVector3 col0, VmathVector3 col1, VmathVector3 col2 ); + +/* + * Construct a 3x3 rotation matrix from a unit-length quaternion + */ +static inline VmathMatrix3 vmathM3MakeFromQ_V( VmathQuat unitQuat ); + +/* + * Set all elements of a 3x3 matrix to the same scalar value + */ +static inline VmathMatrix3 vmathM3MakeFromScalar_V( float scalar ); + +/* + * Set column 0 of a 3x3 matrix + */ +static inline void vmathM3SetCol0_V( VmathMatrix3 *result, VmathVector3 col0 ); + +/* + * Set column 1 of a 3x3 matrix + */ +static inline void vmathM3SetCol1_V( VmathMatrix3 *result, VmathVector3 col1 ); + +/* + * Set column 2 of a 3x3 matrix + */ +static inline void vmathM3SetCol2_V( VmathMatrix3 *result, VmathVector3 col2 ); + +/* + * Get column 0 of a 3x3 matrix + */ +static inline VmathVector3 vmathM3GetCol0_V( VmathMatrix3 mat ); + +/* + * Get column 1 of a 3x3 matrix + */ +static inline VmathVector3 vmathM3GetCol1_V( VmathMatrix3 mat ); + +/* + * Get column 2 of a 3x3 matrix + */ +static inline VmathVector3 vmathM3GetCol2_V( VmathMatrix3 mat ); + +/* + * Set the column of a 3x3 matrix referred to by the specified index + */ +static inline void vmathM3SetCol_V( VmathMatrix3 *result, int col, VmathVector3 vec ); + +/* + * Set the row of a 3x3 matrix referred to by the specified index + */ +static inline void vmathM3SetRow_V( VmathMatrix3 *result, int row, VmathVector3 vec ); + +/* + * Get the column of a 3x3 matrix referred to by the specified index + */ +static inline VmathVector3 vmathM3GetCol_V( VmathMatrix3 mat, int col ); + +/* + * Get the row of a 3x3 matrix referred to by the specified index + */ +static inline VmathVector3 vmathM3GetRow_V( VmathMatrix3 mat, int row ); + +/* + * Set the element of a 3x3 matrix referred to by column and row indices + */ +static inline void vmathM3SetElem_V( VmathMatrix3 *result, int col, int row, float val ); + +/* + * Get the element of a 3x3 matrix referred to by column and row indices + */ +static inline float vmathM3GetElem_V( VmathMatrix3 mat, int col, int row ); + +/* + * Add two 3x3 matrices + */ +static inline VmathMatrix3 vmathM3Add_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ); + +/* + * Subtract a 3x3 matrix from another 3x3 matrix + */ +static inline VmathMatrix3 vmathM3Sub_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ); + +/* + * Negate all elements of a 3x3 matrix + */ +static inline VmathMatrix3 vmathM3Neg_V( VmathMatrix3 mat ); + +/* + * Multiply a 3x3 matrix by a scalar + */ +static inline VmathMatrix3 vmathM3ScalarMul_V( VmathMatrix3 mat, float scalar ); + +/* + * Multiply a 3x3 matrix by a 3-D vector + */ +static inline VmathVector3 vmathM3MulV3_V( VmathMatrix3 mat, VmathVector3 vec ); + +/* + * Multiply two 3x3 matrices + */ +static inline VmathMatrix3 vmathM3Mul_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ); + +/* + * Construct an identity 3x3 matrix + */ +static inline VmathMatrix3 vmathM3MakeIdentity_V( ); + +/* + * Construct a 3x3 matrix to rotate around the x axis + */ +static inline VmathMatrix3 vmathM3MakeRotationX_V( float radians ); + +/* + * Construct a 3x3 matrix to rotate around the y axis + */ +static inline VmathMatrix3 vmathM3MakeRotationY_V( float radians ); + +/* + * Construct a 3x3 matrix to rotate around the z axis + */ +static inline VmathMatrix3 vmathM3MakeRotationZ_V( float radians ); + +/* + * Construct a 3x3 matrix to rotate around the x, y, and z axes + */ +static inline VmathMatrix3 vmathM3MakeRotationZYX_V( VmathVector3 radiansXYZ ); + +/* + * Construct a 3x3 matrix to rotate around a unit-length 3-D vector + */ +static inline VmathMatrix3 vmathM3MakeRotationAxis_V( float radians, VmathVector3 unitVec ); + +/* + * Construct a rotation matrix from a unit-length quaternion + */ +static inline VmathMatrix3 vmathM3MakeRotationQ_V( VmathQuat unitQuat ); + +/* + * Construct a 3x3 matrix to perform scaling + */ +static inline VmathMatrix3 vmathM3MakeScale_V( VmathVector3 scaleVec ); + +/* + * Append (post-multiply) a scale transformation to a 3x3 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline VmathMatrix3 vmathM3AppendScale_V( VmathMatrix3 mat, VmathVector3 scaleVec ); + +/* + * Prepend (pre-multiply) a scale transformation to a 3x3 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline VmathMatrix3 vmathM3PrependScale_V( VmathVector3 scaleVec, VmathMatrix3 mat ); + +/* + * Multiply two 3x3 matrices per element + */ +static inline VmathMatrix3 vmathM3MulPerElem_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ); + +/* + * Compute the absolute value of a 3x3 matrix per element + */ +static inline VmathMatrix3 vmathM3AbsPerElem_V( VmathMatrix3 mat ); + +/* + * Transpose of a 3x3 matrix + */ +static inline VmathMatrix3 vmathM3Transpose_V( VmathMatrix3 mat ); + +/* + * Compute the inverse of a 3x3 matrix + * NOTE: + * Result is unpredictable when the determinant of mat is equal to or near 0. + */ +static inline VmathMatrix3 vmathM3Inverse_V( VmathMatrix3 mat ); + +/* + * Determinant of a 3x3 matrix + */ +static inline float vmathM3Determinant_V( VmathMatrix3 mat ); + +/* + * Conditionally select between two 3x3 matrices + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline VmathMatrix3 vmathM3Select_V( VmathMatrix3 mat0, VmathMatrix3 mat1, unsigned int select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3x3 matrix + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathM3Print_V( VmathMatrix3 mat ); + +/* + * Print a 3x3 matrix and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathM3Prints_V( VmathMatrix3 mat, const char *name ); + +#endif + +/* + * Construct a 4x4 matrix containing the specified columns + */ +static inline VmathMatrix4 vmathM4MakeFromCols_V( VmathVector4 col0, VmathVector4 col1, VmathVector4 col2, VmathVector4 col3 ); + +/* + * Construct a 4x4 matrix from a 3x4 transformation matrix + */ +static inline VmathMatrix4 vmathM4MakeFromT3_V( VmathTransform3 mat ); + +/* + * Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector + */ +static inline VmathMatrix4 vmathM4MakeFromM3V3_V( VmathMatrix3 mat, VmathVector3 translateVec ); + +/* + * Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector + */ +static inline VmathMatrix4 vmathM4MakeFromQV3_V( VmathQuat unitQuat, VmathVector3 translateVec ); + +/* + * Set all elements of a 4x4 matrix to the same scalar value + */ +static inline VmathMatrix4 vmathM4MakeFromScalar_V( float scalar ); + +/* + * Set the upper-left 3x3 submatrix + * NOTE: + * This function does not change the bottom row elements. + */ +static inline void vmathM4SetUpper3x3_V( VmathMatrix4 *result, VmathMatrix3 mat3 ); + +/* + * Get the upper-left 3x3 submatrix of a 4x4 matrix + */ +static inline VmathMatrix3 vmathM4GetUpper3x3_V( VmathMatrix4 mat ); + +/* + * Set translation component + * NOTE: + * This function does not change the bottom row elements. + */ +static inline void vmathM4SetTranslation_V( VmathMatrix4 *result, VmathVector3 translateVec ); + +/* + * Get the translation component of a 4x4 matrix + */ +static inline VmathVector3 vmathM4GetTranslation_V( VmathMatrix4 mat ); + +/* + * Set column 0 of a 4x4 matrix + */ +static inline void vmathM4SetCol0_V( VmathMatrix4 *result, VmathVector4 col0 ); + +/* + * Set column 1 of a 4x4 matrix + */ +static inline void vmathM4SetCol1_V( VmathMatrix4 *result, VmathVector4 col1 ); + +/* + * Set column 2 of a 4x4 matrix + */ +static inline void vmathM4SetCol2_V( VmathMatrix4 *result, VmathVector4 col2 ); + +/* + * Set column 3 of a 4x4 matrix + */ +static inline void vmathM4SetCol3_V( VmathMatrix4 *result, VmathVector4 col3 ); + +/* + * Get column 0 of a 4x4 matrix + */ +static inline VmathVector4 vmathM4GetCol0_V( VmathMatrix4 mat ); + +/* + * Get column 1 of a 4x4 matrix + */ +static inline VmathVector4 vmathM4GetCol1_V( VmathMatrix4 mat ); + +/* + * Get column 2 of a 4x4 matrix + */ +static inline VmathVector4 vmathM4GetCol2_V( VmathMatrix4 mat ); + +/* + * Get column 3 of a 4x4 matrix + */ +static inline VmathVector4 vmathM4GetCol3_V( VmathMatrix4 mat ); + +/* + * Set the column of a 4x4 matrix referred to by the specified index + */ +static inline void vmathM4SetCol_V( VmathMatrix4 *result, int col, VmathVector4 vec ); + +/* + * Set the row of a 4x4 matrix referred to by the specified index + */ +static inline void vmathM4SetRow_V( VmathMatrix4 *result, int row, VmathVector4 vec ); + +/* + * Get the column of a 4x4 matrix referred to by the specified index + */ +static inline VmathVector4 vmathM4GetCol_V( VmathMatrix4 mat, int col ); + +/* + * Get the row of a 4x4 matrix referred to by the specified index + */ +static inline VmathVector4 vmathM4GetRow_V( VmathMatrix4 mat, int row ); + +/* + * Set the element of a 4x4 matrix referred to by column and row indices + */ +static inline void vmathM4SetElem_V( VmathMatrix4 *result, int col, int row, float val ); + +/* + * Get the element of a 4x4 matrix referred to by column and row indices + */ +static inline float vmathM4GetElem_V( VmathMatrix4 mat, int col, int row ); + +/* + * Add two 4x4 matrices + */ +static inline VmathMatrix4 vmathM4Add_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ); + +/* + * Subtract a 4x4 matrix from another 4x4 matrix + */ +static inline VmathMatrix4 vmathM4Sub_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ); + +/* + * Negate all elements of a 4x4 matrix + */ +static inline VmathMatrix4 vmathM4Neg_V( VmathMatrix4 mat ); + +/* + * Multiply a 4x4 matrix by a scalar + */ +static inline VmathMatrix4 vmathM4ScalarMul_V( VmathMatrix4 mat, float scalar ); + +/* + * Multiply a 4x4 matrix by a 4-D vector + */ +static inline VmathVector4 vmathM4MulV4_V( VmathMatrix4 mat, VmathVector4 vec ); + +/* + * Multiply a 4x4 matrix by a 3-D vector + */ +static inline VmathVector4 vmathM4MulV3_V( VmathMatrix4 mat, VmathVector3 vec ); + +/* + * Multiply a 4x4 matrix by a 3-D point + */ +static inline VmathVector4 vmathM4MulP3_V( VmathMatrix4 mat, VmathPoint3 pnt ); + +/* + * Multiply two 4x4 matrices + */ +static inline VmathMatrix4 vmathM4Mul_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ); + +/* + * Multiply a 4x4 matrix by a 3x4 transformation matrix + */ +static inline VmathMatrix4 vmathM4MulT3_V( VmathMatrix4 mat, VmathTransform3 tfrm ); + +/* + * Construct an identity 4x4 matrix + */ +static inline VmathMatrix4 vmathM4MakeIdentity_V( ); + +/* + * Construct a 4x4 matrix to rotate around the x axis + */ +static inline VmathMatrix4 vmathM4MakeRotationX_V( float radians ); + +/* + * Construct a 4x4 matrix to rotate around the y axis + */ +static inline VmathMatrix4 vmathM4MakeRotationY_V( float radians ); + +/* + * Construct a 4x4 matrix to rotate around the z axis + */ +static inline VmathMatrix4 vmathM4MakeRotationZ_V( float radians ); + +/* + * Construct a 4x4 matrix to rotate around the x, y, and z axes + */ +static inline VmathMatrix4 vmathM4MakeRotationZYX_V( VmathVector3 radiansXYZ ); + +/* + * Construct a 4x4 matrix to rotate around a unit-length 3-D vector + */ +static inline VmathMatrix4 vmathM4MakeRotationAxis_V( float radians, VmathVector3 unitVec ); + +/* + * Construct a rotation matrix from a unit-length quaternion + */ +static inline VmathMatrix4 vmathM4MakeRotationQ_V( VmathQuat unitQuat ); + +/* + * Construct a 4x4 matrix to perform scaling + */ +static inline VmathMatrix4 vmathM4MakeScale_V( VmathVector3 scaleVec ); + +/* + * Construct a 4x4 matrix to perform translation + */ +static inline VmathMatrix4 vmathM4MakeTranslation_V( VmathVector3 translateVec ); + +/* + * Construct viewing matrix based on eye position, position looked at, and up direction + */ +static inline VmathMatrix4 vmathM4MakeLookAt_V( VmathPoint3 eyePos, VmathPoint3 lookAtPos, VmathVector3 upVec ); + +/* + * Construct a perspective projection matrix + */ +static inline VmathMatrix4 vmathM4MakePerspective_V( float fovyRadians, float aspect, float zNear, float zFar ); + +/* + * Construct a perspective projection matrix based on frustum + */ +static inline VmathMatrix4 vmathM4MakeFrustum_V( float left, float right, float bottom, float top, float zNear, float zFar ); + +/* + * Construct an orthographic projection matrix + */ +static inline VmathMatrix4 vmathM4MakeOrthographic_V( float left, float right, float bottom, float top, float zNear, float zFar ); + +/* + * Append (post-multiply) a scale transformation to a 4x4 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline VmathMatrix4 vmathM4AppendScale_V( VmathMatrix4 mat, VmathVector3 scaleVec ); + +/* + * Prepend (pre-multiply) a scale transformation to a 4x4 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline VmathMatrix4 vmathM4PrependScale_V( VmathVector3 scaleVec, VmathMatrix4 mat ); + +/* + * Multiply two 4x4 matrices per element + */ +static inline VmathMatrix4 vmathM4MulPerElem_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ); + +/* + * Compute the absolute value of a 4x4 matrix per element + */ +static inline VmathMatrix4 vmathM4AbsPerElem_V( VmathMatrix4 mat ); + +/* + * Transpose of a 4x4 matrix + */ +static inline VmathMatrix4 vmathM4Transpose_V( VmathMatrix4 mat ); + +/* + * Compute the inverse of a 4x4 matrix + * NOTE: + * Result is unpredictable when the determinant of mat is equal to or near 0. + */ +static inline VmathMatrix4 vmathM4Inverse_V( VmathMatrix4 mat ); + +/* + * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix + * NOTE: + * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. The result is unpredictable when the determinant of mat is equal to or near 0. + */ +static inline VmathMatrix4 vmathM4AffineInverse_V( VmathMatrix4 mat ); + +/* + * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix + * NOTE: + * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. + */ +static inline VmathMatrix4 vmathM4OrthoInverse_V( VmathMatrix4 mat ); + +/* + * Determinant of a 4x4 matrix + */ +static inline float vmathM4Determinant_V( VmathMatrix4 mat ); + +/* + * Conditionally select between two 4x4 matrices + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline VmathMatrix4 vmathM4Select_V( VmathMatrix4 mat0, VmathMatrix4 mat1, unsigned int select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 4x4 matrix + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathM4Print_V( VmathMatrix4 mat ); + +/* + * Print a 4x4 matrix and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathM4Prints_V( VmathMatrix4 mat, const char *name ); + +#endif + +/* + * Construct a 3x4 transformation matrix containing the specified columns + */ +static inline VmathTransform3 vmathT3MakeFromCols_V( VmathVector3 col0, VmathVector3 col1, VmathVector3 col2, VmathVector3 col3 ); + +/* + * Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector + */ +static inline VmathTransform3 vmathT3MakeFromM3V3_V( VmathMatrix3 tfrm, VmathVector3 translateVec ); + +/* + * Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector + */ +static inline VmathTransform3 vmathT3MakeFromQV3_V( VmathQuat unitQuat, VmathVector3 translateVec ); + +/* + * Set all elements of a 3x4 transformation matrix to the same scalar value + */ +static inline VmathTransform3 vmathT3MakeFromScalar_V( float scalar ); + +/* + * Set the upper-left 3x3 submatrix + */ +static inline void vmathT3SetUpper3x3_V( VmathTransform3 *result, VmathMatrix3 mat3 ); + +/* + * Get the upper-left 3x3 submatrix of a 3x4 transformation matrix + */ +static inline VmathMatrix3 vmathT3GetUpper3x3_V( VmathTransform3 tfrm ); + +/* + * Set translation component + */ +static inline void vmathT3SetTranslation_V( VmathTransform3 *result, VmathVector3 translateVec ); + +/* + * Get the translation component of a 3x4 transformation matrix + */ +static inline VmathVector3 vmathT3GetTranslation_V( VmathTransform3 tfrm ); + +/* + * Set column 0 of a 3x4 transformation matrix + */ +static inline void vmathT3SetCol0_V( VmathTransform3 *result, VmathVector3 col0 ); + +/* + * Set column 1 of a 3x4 transformation matrix + */ +static inline void vmathT3SetCol1_V( VmathTransform3 *result, VmathVector3 col1 ); + +/* + * Set column 2 of a 3x4 transformation matrix + */ +static inline void vmathT3SetCol2_V( VmathTransform3 *result, VmathVector3 col2 ); + +/* + * Set column 3 of a 3x4 transformation matrix + */ +static inline void vmathT3SetCol3_V( VmathTransform3 *result, VmathVector3 col3 ); + +/* + * Get column 0 of a 3x4 transformation matrix + */ +static inline VmathVector3 vmathT3GetCol0_V( VmathTransform3 tfrm ); + +/* + * Get column 1 of a 3x4 transformation matrix + */ +static inline VmathVector3 vmathT3GetCol1_V( VmathTransform3 tfrm ); + +/* + * Get column 2 of a 3x4 transformation matrix + */ +static inline VmathVector3 vmathT3GetCol2_V( VmathTransform3 tfrm ); + +/* + * Get column 3 of a 3x4 transformation matrix + */ +static inline VmathVector3 vmathT3GetCol3_V( VmathTransform3 tfrm ); + +/* + * Set the column of a 3x4 transformation matrix referred to by the specified index + */ +static inline void vmathT3SetCol_V( VmathTransform3 *result, int col, VmathVector3 vec ); + +/* + * Set the row of a 3x4 transformation matrix referred to by the specified index + */ +static inline void vmathT3SetRow_V( VmathTransform3 *result, int row, VmathVector4 vec ); + +/* + * Get the column of a 3x4 transformation matrix referred to by the specified index + */ +static inline VmathVector3 vmathT3GetCol_V( VmathTransform3 tfrm, int col ); + +/* + * Get the row of a 3x4 transformation matrix referred to by the specified index + */ +static inline VmathVector4 vmathT3GetRow_V( VmathTransform3 tfrm, int row ); + +/* + * Set the element of a 3x4 transformation matrix referred to by column and row indices + */ +static inline void vmathT3SetElem_V( VmathTransform3 *result, int col, int row, float val ); + +/* + * Get the element of a 3x4 transformation matrix referred to by column and row indices + */ +static inline float vmathT3GetElem_V( VmathTransform3 tfrm, int col, int row ); + +/* + * Multiply a 3x4 transformation matrix by a 3-D vector + */ +static inline VmathVector3 vmathT3MulV3_V( VmathTransform3 tfrm, VmathVector3 vec ); + +/* + * Multiply a 3x4 transformation matrix by a 3-D point + */ +static inline VmathPoint3 vmathT3MulP3_V( VmathTransform3 tfrm, VmathPoint3 pnt ); + +/* + * Multiply two 3x4 transformation matrices + */ +static inline VmathTransform3 vmathT3Mul_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1 ); + +/* + * Construct an identity 3x4 transformation matrix + */ +static inline VmathTransform3 vmathT3MakeIdentity_V( ); + +/* + * Construct a 3x4 transformation matrix to rotate around the x axis + */ +static inline VmathTransform3 vmathT3MakeRotationX_V( float radians ); + +/* + * Construct a 3x4 transformation matrix to rotate around the y axis + */ +static inline VmathTransform3 vmathT3MakeRotationY_V( float radians ); + +/* + * Construct a 3x4 transformation matrix to rotate around the z axis + */ +static inline VmathTransform3 vmathT3MakeRotationZ_V( float radians ); + +/* + * Construct a 3x4 transformation matrix to rotate around the x, y, and z axes + */ +static inline VmathTransform3 vmathT3MakeRotationZYX_V( VmathVector3 radiansXYZ ); + +/* + * Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector + */ +static inline VmathTransform3 vmathT3MakeRotationAxis_V( float radians, VmathVector3 unitVec ); + +/* + * Construct a rotation matrix from a unit-length quaternion + */ +static inline VmathTransform3 vmathT3MakeRotationQ_V( VmathQuat unitQuat ); + +/* + * Construct a 3x4 transformation matrix to perform scaling + */ +static inline VmathTransform3 vmathT3MakeScale_V( VmathVector3 scaleVec ); + +/* + * Construct a 3x4 transformation matrix to perform translation + */ +static inline VmathTransform3 vmathT3MakeTranslation_V( VmathVector3 translateVec ); + +/* + * Append (post-multiply) a scale transformation to a 3x4 transformation matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline VmathTransform3 vmathT3AppendScale_V( VmathTransform3 tfrm, VmathVector3 scaleVec ); + +/* + * Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline VmathTransform3 vmathT3PrependScale_V( VmathVector3 scaleVec, VmathTransform3 tfrm ); + +/* + * Multiply two 3x4 transformation matrices per element + */ +static inline VmathTransform3 vmathT3MulPerElem_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1 ); + +/* + * Compute the absolute value of a 3x4 transformation matrix per element + */ +static inline VmathTransform3 vmathT3AbsPerElem_V( VmathTransform3 tfrm ); + +/* + * Inverse of a 3x4 transformation matrix + * NOTE: + * Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0. + */ +static inline VmathTransform3 vmathT3Inverse_V( VmathTransform3 tfrm ); + +/* + * Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix + * NOTE: + * This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions. + */ +static inline VmathTransform3 vmathT3OrthoInverse_V( VmathTransform3 tfrm ); + +/* + * Conditionally select between two 3x4 transformation matrices + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline VmathTransform3 vmathT3Select_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1, unsigned int select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3x4 transformation matrix + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathT3Print_V( VmathTransform3 tfrm ); + +/* + * Print a 3x4 transformation matrix and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathT3Prints_V( VmathTransform3 tfrm, const char *name ); + +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include "vectormath_aos.h" +#include "vec_aos_v.h" +#include "quat_aos_v.h" +#include "mat_aos_v.h" + +#endif diff --git a/vectormathlibrary/include/vectormath/spu/c/vectormath_soa.h b/vectormathlibrary/include/vectormath/spu/c/vectormath_soa.h new file mode 100644 index 000000000..6aa9b6ae7 --- /dev/null +++ b/vectormathlibrary/include/vectormath/spu/c/vectormath_soa.h @@ -0,0 +1,2012 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_SOA_C_SPU_H +#define _VECTORMATH_SOA_C_SPU_H + +#include <math.h> +#include <spu_intrinsics.h> +#include "vectormath_aos.h" + +#ifdef _VECTORMATH_DEBUG +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#ifndef _VECTORMATH_SOA_C_TYPES_H +#define _VECTORMATH_SOA_C_TYPES_H + +/* A set of four 3-D vectors in structure-of-arrays format + */ +typedef struct _VmathSoaVector3 +{ + vec_float4 x; + vec_float4 y; + vec_float4 z; +} VmathSoaVector3; + +/* A set of four 4-D vectors in structure-of-arrays format + */ +typedef struct _VmathSoaVector4 +{ + vec_float4 x; + vec_float4 y; + vec_float4 z; + vec_float4 w; +} VmathSoaVector4; + +/* A set of four 3-D points in structure-of-arrays format + */ +typedef struct _VmathSoaPoint3 +{ + vec_float4 x; + vec_float4 y; + vec_float4 z; +} VmathSoaPoint3; + +/* A set of four quaternions in structure-of-arrays format + */ +typedef struct _VmathSoaQuat +{ + vec_float4 x; + vec_float4 y; + vec_float4 z; + vec_float4 w; +} VmathSoaQuat; + +/* A set of four 3x3 matrices in structure-of-arrays format + */ +typedef struct _VmathSoaMatrix3 +{ + VmathSoaVector3 col0; + VmathSoaVector3 col1; + VmathSoaVector3 col2; +} VmathSoaMatrix3; + +/* A set of four 4x4 matrices in structure-of-arrays format + */ +typedef struct _VmathSoaMatrix4 +{ + VmathSoaVector4 col0; + VmathSoaVector4 col1; + VmathSoaVector4 col2; + VmathSoaVector4 col3; +} VmathSoaMatrix4; + +/* A set of four 3x4 transformation matrices in structure-of-arrays format + */ +typedef struct _VmathSoaTransform3 +{ + VmathSoaVector3 col0; + VmathSoaVector3 col1; + VmathSoaVector3 col2; + VmathSoaVector3 col3; +} VmathSoaTransform3; + +#endif + +/* + * Copy a 3-D vector + */ +static inline void vmathSoaV3Copy( VmathSoaVector3 *result, const VmathSoaVector3 *vec ); + +/* + * Construct a 3-D vector from x, y, and z elements + */ +static inline void vmathSoaV3MakeFromElems( VmathSoaVector3 *result, vec_float4 x, vec_float4 y, vec_float4 z ); + +/* + * Copy elements from a 3-D point into a 3-D vector + */ +static inline void vmathSoaV3MakeFromP3( VmathSoaVector3 *result, const VmathSoaPoint3 *pnt ); + +/* + * Set all elements of a 3-D vector to the same scalar value + */ +static inline void vmathSoaV3MakeFromScalar( VmathSoaVector3 *result, vec_float4 scalar ); + +/* + * Replicate an AoS 3-D vector + */ +static inline void vmathSoaV3MakeFromAos( VmathSoaVector3 *result, const VmathVector3 *vec ); + +/* + * Insert four AoS 3-D vectors + */ +static inline void vmathSoaV3MakeFrom4Aos( VmathSoaVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1, const VmathVector3 *vec2, const VmathVector3 *vec3 ); + +/* + * Extract four AoS 3-D vectors + */ +static inline void vmathSoaV3Get4Aos( const VmathSoaVector3 *vec, VmathVector3 *result0, VmathVector3 *result1, VmathVector3 *result2, VmathVector3 *result3 ); + +/* + * Set the x element of a 3-D vector + */ +static inline void vmathSoaV3SetX( VmathSoaVector3 *result, vec_float4 x ); + +/* + * Set the y element of a 3-D vector + */ +static inline void vmathSoaV3SetY( VmathSoaVector3 *result, vec_float4 y ); + +/* + * Set the z element of a 3-D vector + */ +static inline void vmathSoaV3SetZ( VmathSoaVector3 *result, vec_float4 z ); + +/* + * Get the x element of a 3-D vector + */ +static inline vec_float4 vmathSoaV3GetX( const VmathSoaVector3 *vec ); + +/* + * Get the y element of a 3-D vector + */ +static inline vec_float4 vmathSoaV3GetY( const VmathSoaVector3 *vec ); + +/* + * Get the z element of a 3-D vector + */ +static inline vec_float4 vmathSoaV3GetZ( const VmathSoaVector3 *vec ); + +/* + * Set an x, y, or z element of a 3-D vector by index + */ +static inline void vmathSoaV3SetElem( VmathSoaVector3 *result, int idx, vec_float4 value ); + +/* + * Get an x, y, or z element of a 3-D vector by index + */ +static inline vec_float4 vmathSoaV3GetElem( const VmathSoaVector3 *vec, int idx ); + +/* + * Add two 3-D vectors + */ +static inline void vmathSoaV3Add( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); + +/* + * Subtract a 3-D vector from another 3-D vector + */ +static inline void vmathSoaV3Sub( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); + +/* + * Add a 3-D vector to a 3-D point + */ +static inline void vmathSoaV3AddP3( VmathSoaPoint3 *result, const VmathSoaVector3 *vec, const VmathSoaPoint3 *pnt ); + +/* + * Multiply a 3-D vector by a scalar + */ +static inline void vmathSoaV3ScalarMul( VmathSoaVector3 *result, const VmathSoaVector3 *vec, vec_float4 scalar ); + +/* + * Divide a 3-D vector by a scalar + */ +static inline void vmathSoaV3ScalarDiv( VmathSoaVector3 *result, const VmathSoaVector3 *vec, vec_float4 scalar ); + +/* + * Negate all elements of a 3-D vector + */ +static inline void vmathSoaV3Neg( VmathSoaVector3 *result, const VmathSoaVector3 *vec ); + +/* + * Construct x axis + */ +static inline void vmathSoaV3MakeXAxis( VmathSoaVector3 *result ); + +/* + * Construct y axis + */ +static inline void vmathSoaV3MakeYAxis( VmathSoaVector3 *result ); + +/* + * Construct z axis + */ +static inline void vmathSoaV3MakeZAxis( VmathSoaVector3 *result ); + +/* + * Multiply two 3-D vectors per element + */ +static inline void vmathSoaV3MulPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); + +/* + * Divide two 3-D vectors per element + * NOTE: + * Floating-point behavior matches standard library function divf4. + */ +static inline void vmathSoaV3DivPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); + +/* + * Compute the reciprocal of a 3-D vector per element + * NOTE: + * Floating-point behavior matches standard library function recipf4. + */ +static inline void vmathSoaV3RecipPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec ); + +/* + * Compute the square root of a 3-D vector per element + * NOTE: + * Floating-point behavior matches standard library function sqrtf4. + */ +static inline void vmathSoaV3SqrtPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec ); + +/* + * Compute the reciprocal square root of a 3-D vector per element + * NOTE: + * Floating-point behavior matches standard library function rsqrtf4. + */ +static inline void vmathSoaV3RsqrtPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec ); + +/* + * Compute the absolute value of a 3-D vector per element + */ +static inline void vmathSoaV3AbsPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec ); + +/* + * Copy sign from one 3-D vector to another, per element + */ +static inline void vmathSoaV3CopySignPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); + +/* + * Maximum of two 3-D vectors per element + */ +static inline void vmathSoaV3MaxPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); + +/* + * Minimum of two 3-D vectors per element + */ +static inline void vmathSoaV3MinPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); + +/* + * Maximum element of a 3-D vector + */ +static inline vec_float4 vmathSoaV3MaxElem( const VmathSoaVector3 *vec ); + +/* + * Minimum element of a 3-D vector + */ +static inline vec_float4 vmathSoaV3MinElem( const VmathSoaVector3 *vec ); + +/* + * Compute the sum of all elements of a 3-D vector + */ +static inline vec_float4 vmathSoaV3Sum( const VmathSoaVector3 *vec ); + +/* + * Compute the dot product of two 3-D vectors + */ +static inline vec_float4 vmathSoaV3Dot( const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); + +/* + * Compute the square of the length of a 3-D vector + */ +static inline vec_float4 vmathSoaV3LengthSqr( const VmathSoaVector3 *vec ); + +/* + * Compute the length of a 3-D vector + */ +static inline vec_float4 vmathSoaV3Length( const VmathSoaVector3 *vec ); + +/* + * Normalize a 3-D vector + * NOTE: + * The result is unpredictable when all elements of vec are at or near zero. + */ +static inline void vmathSoaV3Normalize( VmathSoaVector3 *result, const VmathSoaVector3 *vec ); + +/* + * Compute cross product of two 3-D vectors + */ +static inline void vmathSoaV3Cross( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); + +/* + * Outer product of two 3-D vectors + */ +static inline void vmathSoaV3Outer( VmathSoaMatrix3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); + +/* + * Pre-multiply a row vector by a 3x3 matrix + */ +static inline void vmathSoaV3RowMul( VmathSoaVector3 *result, const VmathSoaVector3 *vec, const VmathSoaMatrix3 *mat ); + +/* + * Cross-product matrix of a 3-D vector + */ +static inline void vmathSoaV3CrossMatrix( VmathSoaMatrix3 *result, const VmathSoaVector3 *vec ); + +/* + * Create cross-product matrix and multiply + * NOTE: + * Faster than separately creating a cross-product matrix and multiplying. + */ +static inline void vmathSoaV3CrossMatrixMul( VmathSoaMatrix3 *result, const VmathSoaVector3 *vec, const VmathSoaMatrix3 *mat ); + +/* + * Linear interpolation between two 3-D vectors + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline void vmathSoaV3Lerp( VmathSoaVector3 *result, vec_float4 t, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); + +/* + * Spherical linear interpolation between two 3-D vectors + * NOTE: + * The result is unpredictable if the vectors point in opposite directions. + * Does not clamp t between 0 and 1. + */ +static inline void vmathSoaV3Slerp( VmathSoaVector3 *result, vec_float4 t, const VmathSoaVector3 *unitVec0, const VmathSoaVector3 *unitVec1 ); + +/* + * Conditionally select between two 3-D vectors + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline void vmathSoaV3Select( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1, vec_uint4 select1 ); + +/* + * Load four three-float 3-D vectors, stored in three quadwords + */ +static inline void vmathSoaV3LoadXYZArray( VmathSoaVector3 *vec, const vec_float4 *threeQuads ); + +/* + * Store four slots of an SoA 3-D vector in three quadwords + */ +static inline void vmathSoaV3StoreXYZArray( const VmathSoaVector3 *vec, vec_float4 *threeQuads ); + +/* + * Store eight slots of two SoA 3-D vectors as half-floats + */ +static inline void vmathSoaV3StoreHalfFloats( const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1, vec_ushort8 *threeQuads ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3-D vector + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaV3Print( const VmathSoaVector3 *vec ); + +/* + * Print a 3-D vector and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaV3Prints( const VmathSoaVector3 *vec, const char *name ); + +#endif + +/* + * Copy a 4-D vector + */ +static inline void vmathSoaV4Copy( VmathSoaVector4 *result, const VmathSoaVector4 *vec ); + +/* + * Construct a 4-D vector from x, y, z, and w elements + */ +static inline void vmathSoaV4MakeFromElems( VmathSoaVector4 *result, vec_float4 x, vec_float4 y, vec_float4 z, vec_float4 w ); + +/* + * Construct a 4-D vector from a 3-D vector and a scalar + */ +static inline void vmathSoaV4MakeFromV3Scalar( VmathSoaVector4 *result, const VmathSoaVector3 *xyz, vec_float4 w ); + +/* + * Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0 + */ +static inline void vmathSoaV4MakeFromV3( VmathSoaVector4 *result, const VmathSoaVector3 *vec ); + +/* + * Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1 + */ +static inline void vmathSoaV4MakeFromP3( VmathSoaVector4 *result, const VmathSoaPoint3 *pnt ); + +/* + * Copy elements from a quaternion into a 4-D vector + */ +static inline void vmathSoaV4MakeFromQ( VmathSoaVector4 *result, const VmathSoaQuat *quat ); + +/* + * Set all elements of a 4-D vector to the same scalar value + */ +static inline void vmathSoaV4MakeFromScalar( VmathSoaVector4 *result, vec_float4 scalar ); + +/* + * Replicate an AoS 4-D vector + */ +static inline void vmathSoaV4MakeFromAos( VmathSoaVector4 *result, const VmathVector4 *vec ); + +/* + * Insert four AoS 4-D vectors + */ +static inline void vmathSoaV4MakeFrom4Aos( VmathSoaVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1, const VmathVector4 *vec2, const VmathVector4 *vec3 ); + +/* + * Extract four AoS 4-D vectors + */ +static inline void vmathSoaV4Get4Aos( const VmathSoaVector4 *vec, VmathVector4 *result0, VmathVector4 *result1, VmathVector4 *result2, VmathVector4 *result3 ); + +/* + * Set the x, y, and z elements of a 4-D vector + * NOTE: + * This function does not change the w element. + */ +static inline void vmathSoaV4SetXYZ( VmathSoaVector4 *result, const VmathSoaVector3 *vec ); + +/* + * Get the x, y, and z elements of a 4-D vector + */ +static inline void vmathSoaV4GetXYZ( VmathSoaVector3 *result, const VmathSoaVector4 *vec ); + +/* + * Set the x element of a 4-D vector + */ +static inline void vmathSoaV4SetX( VmathSoaVector4 *result, vec_float4 x ); + +/* + * Set the y element of a 4-D vector + */ +static inline void vmathSoaV4SetY( VmathSoaVector4 *result, vec_float4 y ); + +/* + * Set the z element of a 4-D vector + */ +static inline void vmathSoaV4SetZ( VmathSoaVector4 *result, vec_float4 z ); + +/* + * Set the w element of a 4-D vector + */ +static inline void vmathSoaV4SetW( VmathSoaVector4 *result, vec_float4 w ); + +/* + * Get the x element of a 4-D vector + */ +static inline vec_float4 vmathSoaV4GetX( const VmathSoaVector4 *vec ); + +/* + * Get the y element of a 4-D vector + */ +static inline vec_float4 vmathSoaV4GetY( const VmathSoaVector4 *vec ); + +/* + * Get the z element of a 4-D vector + */ +static inline vec_float4 vmathSoaV4GetZ( const VmathSoaVector4 *vec ); + +/* + * Get the w element of a 4-D vector + */ +static inline vec_float4 vmathSoaV4GetW( const VmathSoaVector4 *vec ); + +/* + * Set an x, y, z, or w element of a 4-D vector by index + */ +static inline void vmathSoaV4SetElem( VmathSoaVector4 *result, int idx, vec_float4 value ); + +/* + * Get an x, y, z, or w element of a 4-D vector by index + */ +static inline vec_float4 vmathSoaV4GetElem( const VmathSoaVector4 *vec, int idx ); + +/* + * Add two 4-D vectors + */ +static inline void vmathSoaV4Add( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); + +/* + * Subtract a 4-D vector from another 4-D vector + */ +static inline void vmathSoaV4Sub( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); + +/* + * Multiply a 4-D vector by a scalar + */ +static inline void vmathSoaV4ScalarMul( VmathSoaVector4 *result, const VmathSoaVector4 *vec, vec_float4 scalar ); + +/* + * Divide a 4-D vector by a scalar + */ +static inline void vmathSoaV4ScalarDiv( VmathSoaVector4 *result, const VmathSoaVector4 *vec, vec_float4 scalar ); + +/* + * Negate all elements of a 4-D vector + */ +static inline void vmathSoaV4Neg( VmathSoaVector4 *result, const VmathSoaVector4 *vec ); + +/* + * Construct x axis + */ +static inline void vmathSoaV4MakeXAxis( VmathSoaVector4 *result ); + +/* + * Construct y axis + */ +static inline void vmathSoaV4MakeYAxis( VmathSoaVector4 *result ); + +/* + * Construct z axis + */ +static inline void vmathSoaV4MakeZAxis( VmathSoaVector4 *result ); + +/* + * Construct w axis + */ +static inline void vmathSoaV4MakeWAxis( VmathSoaVector4 *result ); + +/* + * Multiply two 4-D vectors per element + */ +static inline void vmathSoaV4MulPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); + +/* + * Divide two 4-D vectors per element + * NOTE: + * Floating-point behavior matches standard library function divf4. + */ +static inline void vmathSoaV4DivPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); + +/* + * Compute the reciprocal of a 4-D vector per element + * NOTE: + * Floating-point behavior matches standard library function recipf4. + */ +static inline void vmathSoaV4RecipPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec ); + +/* + * Compute the square root of a 4-D vector per element + * NOTE: + * Floating-point behavior matches standard library function sqrtf4. + */ +static inline void vmathSoaV4SqrtPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec ); + +/* + * Compute the reciprocal square root of a 4-D vector per element + * NOTE: + * Floating-point behavior matches standard library function rsqrtf4. + */ +static inline void vmathSoaV4RsqrtPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec ); + +/* + * Compute the absolute value of a 4-D vector per element + */ +static inline void vmathSoaV4AbsPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec ); + +/* + * Copy sign from one 4-D vector to another, per element + */ +static inline void vmathSoaV4CopySignPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); + +/* + * Maximum of two 4-D vectors per element + */ +static inline void vmathSoaV4MaxPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); + +/* + * Minimum of two 4-D vectors per element + */ +static inline void vmathSoaV4MinPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); + +/* + * Maximum element of a 4-D vector + */ +static inline vec_float4 vmathSoaV4MaxElem( const VmathSoaVector4 *vec ); + +/* + * Minimum element of a 4-D vector + */ +static inline vec_float4 vmathSoaV4MinElem( const VmathSoaVector4 *vec ); + +/* + * Compute the sum of all elements of a 4-D vector + */ +static inline vec_float4 vmathSoaV4Sum( const VmathSoaVector4 *vec ); + +/* + * Compute the dot product of two 4-D vectors + */ +static inline vec_float4 vmathSoaV4Dot( const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); + +/* + * Compute the square of the length of a 4-D vector + */ +static inline vec_float4 vmathSoaV4LengthSqr( const VmathSoaVector4 *vec ); + +/* + * Compute the length of a 4-D vector + */ +static inline vec_float4 vmathSoaV4Length( const VmathSoaVector4 *vec ); + +/* + * Normalize a 4-D vector + * NOTE: + * The result is unpredictable when all elements of vec are at or near zero. + */ +static inline void vmathSoaV4Normalize( VmathSoaVector4 *result, const VmathSoaVector4 *vec ); + +/* + * Outer product of two 4-D vectors + */ +static inline void vmathSoaV4Outer( VmathSoaMatrix4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); + +/* + * Linear interpolation between two 4-D vectors + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline void vmathSoaV4Lerp( VmathSoaVector4 *result, vec_float4 t, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); + +/* + * Spherical linear interpolation between two 4-D vectors + * NOTE: + * The result is unpredictable if the vectors point in opposite directions. + * Does not clamp t between 0 and 1. + */ +static inline void vmathSoaV4Slerp( VmathSoaVector4 *result, vec_float4 t, const VmathSoaVector4 *unitVec0, const VmathSoaVector4 *unitVec1 ); + +/* + * Conditionally select between two 4-D vectors + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline void vmathSoaV4Select( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1, vec_uint4 select1 ); + +/* + * Store four slots of an SoA 4-D vector as half-floats + */ +static inline void vmathSoaV4StoreHalfFloats( const VmathSoaVector4 *vec, vec_ushort8 *twoQuads ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 4-D vector + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaV4Print( const VmathSoaVector4 *vec ); + +/* + * Print a 4-D vector and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaV4Prints( const VmathSoaVector4 *vec, const char *name ); + +#endif + +/* + * Copy a 3-D point + */ +static inline void vmathSoaP3Copy( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ); + +/* + * Construct a 3-D point from x, y, and z elements + */ +static inline void vmathSoaP3MakeFromElems( VmathSoaPoint3 *result, vec_float4 x, vec_float4 y, vec_float4 z ); + +/* + * Copy elements from a 3-D vector into a 3-D point + */ +static inline void vmathSoaP3MakeFromV3( VmathSoaPoint3 *result, const VmathSoaVector3 *vec ); + +/* + * Set all elements of a 3-D point to the same scalar value + */ +static inline void vmathSoaP3MakeFromScalar( VmathSoaPoint3 *result, vec_float4 scalar ); + +/* + * Replicate an AoS 3-D point + */ +static inline void vmathSoaP3MakeFromAos( VmathSoaPoint3 *result, const VmathPoint3 *pnt ); + +/* + * Insert four AoS 3-D points + */ +static inline void vmathSoaP3MakeFrom4Aos( VmathSoaPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, const VmathPoint3 *pnt2, const VmathPoint3 *pnt3 ); + +/* + * Extract four AoS 3-D points + */ +static inline void vmathSoaP3Get4Aos( const VmathSoaPoint3 *pnt, VmathPoint3 *result0, VmathPoint3 *result1, VmathPoint3 *result2, VmathPoint3 *result3 ); + +/* + * Set the x element of a 3-D point + */ +static inline void vmathSoaP3SetX( VmathSoaPoint3 *result, vec_float4 x ); + +/* + * Set the y element of a 3-D point + */ +static inline void vmathSoaP3SetY( VmathSoaPoint3 *result, vec_float4 y ); + +/* + * Set the z element of a 3-D point + */ +static inline void vmathSoaP3SetZ( VmathSoaPoint3 *result, vec_float4 z ); + +/* + * Get the x element of a 3-D point + */ +static inline vec_float4 vmathSoaP3GetX( const VmathSoaPoint3 *pnt ); + +/* + * Get the y element of a 3-D point + */ +static inline vec_float4 vmathSoaP3GetY( const VmathSoaPoint3 *pnt ); + +/* + * Get the z element of a 3-D point + */ +static inline vec_float4 vmathSoaP3GetZ( const VmathSoaPoint3 *pnt ); + +/* + * Set an x, y, or z element of a 3-D point by index + */ +static inline void vmathSoaP3SetElem( VmathSoaPoint3 *result, int idx, vec_float4 value ); + +/* + * Get an x, y, or z element of a 3-D point by index + */ +static inline vec_float4 vmathSoaP3GetElem( const VmathSoaPoint3 *pnt, int idx ); + +/* + * Subtract a 3-D point from another 3-D point + */ +static inline void vmathSoaP3Sub( VmathSoaVector3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ); + +/* + * Add a 3-D point to a 3-D vector + */ +static inline void vmathSoaP3AddV3( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt, const VmathSoaVector3 *vec ); + +/* + * Subtract a 3-D vector from a 3-D point + */ +static inline void vmathSoaP3SubV3( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt, const VmathSoaVector3 *vec ); + +/* + * Multiply two 3-D points per element + */ +static inline void vmathSoaP3MulPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ); + +/* + * Divide two 3-D points per element + * NOTE: + * Floating-point behavior matches standard library function divf4. + */ +static inline void vmathSoaP3DivPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ); + +/* + * Compute the reciprocal of a 3-D point per element + * NOTE: + * Floating-point behavior matches standard library function recipf4. + */ +static inline void vmathSoaP3RecipPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ); + +/* + * Compute the square root of a 3-D point per element + * NOTE: + * Floating-point behavior matches standard library function sqrtf4. + */ +static inline void vmathSoaP3SqrtPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ); + +/* + * Compute the reciprocal square root of a 3-D point per element + * NOTE: + * Floating-point behavior matches standard library function rsqrtf4. + */ +static inline void vmathSoaP3RsqrtPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ); + +/* + * Compute the absolute value of a 3-D point per element + */ +static inline void vmathSoaP3AbsPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ); + +/* + * Copy sign from one 3-D point to another, per element + */ +static inline void vmathSoaP3CopySignPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ); + +/* + * Maximum of two 3-D points per element + */ +static inline void vmathSoaP3MaxPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ); + +/* + * Minimum of two 3-D points per element + */ +static inline void vmathSoaP3MinPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ); + +/* + * Maximum element of a 3-D point + */ +static inline vec_float4 vmathSoaP3MaxElem( const VmathSoaPoint3 *pnt ); + +/* + * Minimum element of a 3-D point + */ +static inline vec_float4 vmathSoaP3MinElem( const VmathSoaPoint3 *pnt ); + +/* + * Compute the sum of all elements of a 3-D point + */ +static inline vec_float4 vmathSoaP3Sum( const VmathSoaPoint3 *pnt ); + +/* + * Apply uniform scale to a 3-D point + */ +static inline void vmathSoaP3Scale( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt, vec_float4 scaleVal ); + +/* + * Apply non-uniform scale to a 3-D point + */ +static inline void vmathSoaP3NonUniformScale( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt, const VmathSoaVector3 *scaleVec ); + +/* + * Scalar projection of a 3-D point on a unit-length 3-D vector + */ +static inline vec_float4 vmathSoaP3Projection( const VmathSoaPoint3 *pnt, const VmathSoaVector3 *unitVec ); + +/* + * Compute the square of the distance of a 3-D point from the coordinate-system origin + */ +static inline vec_float4 vmathSoaP3DistSqrFromOrigin( const VmathSoaPoint3 *pnt ); + +/* + * Compute the distance of a 3-D point from the coordinate-system origin + */ +static inline vec_float4 vmathSoaP3DistFromOrigin( const VmathSoaPoint3 *pnt ); + +/* + * Compute the square of the distance between two 3-D points + */ +static inline vec_float4 vmathSoaP3DistSqr( const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ); + +/* + * Compute the distance between two 3-D points + */ +static inline vec_float4 vmathSoaP3Dist( const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ); + +/* + * Linear interpolation between two 3-D points + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline void vmathSoaP3Lerp( VmathSoaPoint3 *result, vec_float4 t, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ); + +/* + * Conditionally select between two 3-D points + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline void vmathSoaP3Select( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1, vec_uint4 select1 ); + +/* + * Load four three-float 3-D points, stored in three quadwords + */ +static inline void vmathSoaP3LoadXYZArray( VmathSoaPoint3 *pnt, const vec_float4 *threeQuads ); + +/* + * Store four slots of an SoA 3-D point in three quadwords + */ +static inline void vmathSoaP3StoreXYZArray( const VmathSoaPoint3 *pnt, vec_float4 *threeQuads ); + +/* + * Store eight slots of two SoA 3-D points as half-floats + */ +static inline void vmathSoaP3StoreHalfFloats( const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1, vec_ushort8 *threeQuads ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3-D point + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaP3Print( const VmathSoaPoint3 *pnt ); + +/* + * Print a 3-D point and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaP3Prints( const VmathSoaPoint3 *pnt, const char *name ); + +#endif + +/* + * Copy a quaternion + */ +static inline void vmathSoaQCopy( VmathSoaQuat *result, const VmathSoaQuat *quat ); + +/* + * Construct a quaternion from x, y, z, and w elements + */ +static inline void vmathSoaQMakeFromElems( VmathSoaQuat *result, vec_float4 x, vec_float4 y, vec_float4 z, vec_float4 w ); + +/* + * Construct a quaternion from a 3-D vector and a scalar + */ +static inline void vmathSoaQMakeFromV3Scalar( VmathSoaQuat *result, const VmathSoaVector3 *xyz, vec_float4 w ); + +/* + * Copy elements from a 4-D vector into a quaternion + */ +static inline void vmathSoaQMakeFromV4( VmathSoaQuat *result, const VmathSoaVector4 *vec ); + +/* + * Convert a rotation matrix to a unit-length quaternion + */ +static inline void vmathSoaQMakeFromM3( VmathSoaQuat *result, const VmathSoaMatrix3 *rotMat ); + +/* + * Set all elements of a quaternion to the same scalar value + */ +static inline void vmathSoaQMakeFromScalar( VmathSoaQuat *result, vec_float4 scalar ); + +/* + * Replicate an AoS quaternion + */ +static inline void vmathSoaQMakeFromAos( VmathSoaQuat *result, const VmathQuat *quat ); + +/* + * Insert four AoS quaternions + */ +static inline void vmathSoaQMakeFrom4Aos( VmathSoaQuat *result, const VmathQuat *quat0, const VmathQuat *quat1, const VmathQuat *quat2, const VmathQuat *quat3 ); + +/* + * Extract four AoS quaternions + */ +static inline void vmathSoaQGet4Aos( const VmathSoaQuat *quat, VmathQuat *result0, VmathQuat *result1, VmathQuat *result2, VmathQuat *result3 ); + +/* + * Set the x, y, and z elements of a quaternion + * NOTE: + * This function does not change the w element. + */ +static inline void vmathSoaQSetXYZ( VmathSoaQuat *result, const VmathSoaVector3 *vec ); + +/* + * Get the x, y, and z elements of a quaternion + */ +static inline void vmathSoaQGetXYZ( VmathSoaVector3 *result, const VmathSoaQuat *quat ); + +/* + * Set the x element of a quaternion + */ +static inline void vmathSoaQSetX( VmathSoaQuat *result, vec_float4 x ); + +/* + * Set the y element of a quaternion + */ +static inline void vmathSoaQSetY( VmathSoaQuat *result, vec_float4 y ); + +/* + * Set the z element of a quaternion + */ +static inline void vmathSoaQSetZ( VmathSoaQuat *result, vec_float4 z ); + +/* + * Set the w element of a quaternion + */ +static inline void vmathSoaQSetW( VmathSoaQuat *result, vec_float4 w ); + +/* + * Get the x element of a quaternion + */ +static inline vec_float4 vmathSoaQGetX( const VmathSoaQuat *quat ); + +/* + * Get the y element of a quaternion + */ +static inline vec_float4 vmathSoaQGetY( const VmathSoaQuat *quat ); + +/* + * Get the z element of a quaternion + */ +static inline vec_float4 vmathSoaQGetZ( const VmathSoaQuat *quat ); + +/* + * Get the w element of a quaternion + */ +static inline vec_float4 vmathSoaQGetW( const VmathSoaQuat *quat ); + +/* + * Set an x, y, z, or w element of a quaternion by index + */ +static inline void vmathSoaQSetElem( VmathSoaQuat *result, int idx, vec_float4 value ); + +/* + * Get an x, y, z, or w element of a quaternion by index + */ +static inline vec_float4 vmathSoaQGetElem( const VmathSoaQuat *quat, int idx ); + +/* + * Add two quaternions + */ +static inline void vmathSoaQAdd( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ); + +/* + * Subtract a quaternion from another quaternion + */ +static inline void vmathSoaQSub( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ); + +/* + * Multiply two quaternions + */ +static inline void vmathSoaQMul( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ); + +/* + * Multiply a quaternion by a scalar + */ +static inline void vmathSoaQScalarMul( VmathSoaQuat *result, const VmathSoaQuat *quat, vec_float4 scalar ); + +/* + * Divide a quaternion by a scalar + */ +static inline void vmathSoaQScalarDiv( VmathSoaQuat *result, const VmathSoaQuat *quat, vec_float4 scalar ); + +/* + * Negate all elements of a quaternion + */ +static inline void vmathSoaQNeg( VmathSoaQuat *result, const VmathSoaQuat *quat ); + +/* + * Construct an identity quaternion + */ +static inline void vmathSoaQMakeIdentity( VmathSoaQuat *result ); + +/* + * Construct a quaternion to rotate between two unit-length 3-D vectors + * NOTE: + * The result is unpredictable if unitVec0 and unitVec1 point in opposite directions. + */ +static inline void vmathSoaQMakeRotationArc( VmathSoaQuat *result, const VmathSoaVector3 *unitVec0, const VmathSoaVector3 *unitVec1 ); + +/* + * Construct a quaternion to rotate around a unit-length 3-D vector + */ +static inline void vmathSoaQMakeRotationAxis( VmathSoaQuat *result, vec_float4 radians, const VmathSoaVector3 *unitVec ); + +/* + * Construct a quaternion to rotate around the x axis + */ +static inline void vmathSoaQMakeRotationX( VmathSoaQuat *result, vec_float4 radians ); + +/* + * Construct a quaternion to rotate around the y axis + */ +static inline void vmathSoaQMakeRotationY( VmathSoaQuat *result, vec_float4 radians ); + +/* + * Construct a quaternion to rotate around the z axis + */ +static inline void vmathSoaQMakeRotationZ( VmathSoaQuat *result, vec_float4 radians ); + +/* + * Compute the conjugate of a quaternion + */ +static inline void vmathSoaQConj( VmathSoaQuat *result, const VmathSoaQuat *quat ); + +/* + * Use a unit-length quaternion to rotate a 3-D vector + */ +static inline void vmathSoaQRotate( VmathSoaVector3 *result, const VmathSoaQuat *unitQuat, const VmathSoaVector3 *vec ); + +/* + * Compute the dot product of two quaternions + */ +static inline vec_float4 vmathSoaQDot( const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ); + +/* + * Compute the norm of a quaternion + */ +static inline vec_float4 vmathSoaQNorm( const VmathSoaQuat *quat ); + +/* + * Compute the length of a quaternion + */ +static inline vec_float4 vmathSoaQLength( const VmathSoaQuat *quat ); + +/* + * Normalize a quaternion + * NOTE: + * The result is unpredictable when all elements of quat are at or near zero. + */ +static inline void vmathSoaQNormalize( VmathSoaQuat *result, const VmathSoaQuat *quat ); + +/* + * Linear interpolation between two quaternions + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline void vmathSoaQLerp( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ); + +/* + * Spherical linear interpolation between two quaternions + * NOTE: + * Interpolates along the shortest path between orientations. + * Does not clamp t between 0 and 1. + */ +static inline void vmathSoaQSlerp( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *unitQuat0, const VmathSoaQuat *unitQuat1 ); + +/* + * Spherical quadrangle interpolation + */ +static inline void vmathSoaQSquad( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *unitQuat0, const VmathSoaQuat *unitQuat1, const VmathSoaQuat *unitQuat2, const VmathSoaQuat *unitQuat3 ); + +/* + * Conditionally select between two quaternions + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline void vmathSoaQSelect( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1, vec_uint4 select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a quaternion + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaQPrint( const VmathSoaQuat *quat ); + +/* + * Print a quaternion and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaQPrints( const VmathSoaQuat *quat, const char *name ); + +#endif + +/* + * Copy a 3x3 matrix + */ +static inline void vmathSoaM3Copy( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ); + +/* + * Construct a 3x3 matrix containing the specified columns + */ +static inline void vmathSoaM3MakeFromCols( VmathSoaMatrix3 *result, const VmathSoaVector3 *col0, const VmathSoaVector3 *col1, const VmathSoaVector3 *col2 ); + +/* + * Construct a 3x3 rotation matrix from a unit-length quaternion + */ +static inline void vmathSoaM3MakeFromQ( VmathSoaMatrix3 *result, const VmathSoaQuat *unitQuat ); + +/* + * Set all elements of a 3x3 matrix to the same scalar value + */ +static inline void vmathSoaM3MakeFromScalar( VmathSoaMatrix3 *result, vec_float4 scalar ); + +/* + * Replicate an AoS 3x3 matrix + */ +static inline void vmathSoaM3MakeFromAos( VmathSoaMatrix3 *result, const VmathMatrix3 *mat ); + +/* + * Insert four AoS 3x3 matrices + */ +static inline void vmathSoaM3MakeFrom4Aos( VmathSoaMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1, const VmathMatrix3 *mat2, const VmathMatrix3 *mat3 ); + +/* + * Extract four AoS 3x3 matrices + */ +static inline void vmathSoaM3Get4Aos( const VmathSoaMatrix3 *mat, VmathMatrix3 *result0, VmathMatrix3 *result1, VmathMatrix3 *result2, VmathMatrix3 *result3 ); + +/* + * Set column 0 of a 3x3 matrix + */ +static inline void vmathSoaM3SetCol0( VmathSoaMatrix3 *result, const VmathSoaVector3 *col0 ); + +/* + * Set column 1 of a 3x3 matrix + */ +static inline void vmathSoaM3SetCol1( VmathSoaMatrix3 *result, const VmathSoaVector3 *col1 ); + +/* + * Set column 2 of a 3x3 matrix + */ +static inline void vmathSoaM3SetCol2( VmathSoaMatrix3 *result, const VmathSoaVector3 *col2 ); + +/* + * Get column 0 of a 3x3 matrix + */ +static inline void vmathSoaM3GetCol0( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat ); + +/* + * Get column 1 of a 3x3 matrix + */ +static inline void vmathSoaM3GetCol1( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat ); + +/* + * Get column 2 of a 3x3 matrix + */ +static inline void vmathSoaM3GetCol2( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat ); + +/* + * Set the column of a 3x3 matrix referred to by the specified index + */ +static inline void vmathSoaM3SetCol( VmathSoaMatrix3 *result, int col, const VmathSoaVector3 *vec ); + +/* + * Set the row of a 3x3 matrix referred to by the specified index + */ +static inline void vmathSoaM3SetRow( VmathSoaMatrix3 *result, int row, const VmathSoaVector3 *vec ); + +/* + * Get the column of a 3x3 matrix referred to by the specified index + */ +static inline void vmathSoaM3GetCol( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat, int col ); + +/* + * Get the row of a 3x3 matrix referred to by the specified index + */ +static inline void vmathSoaM3GetRow( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat, int row ); + +/* + * Set the element of a 3x3 matrix referred to by column and row indices + */ +static inline void vmathSoaM3SetElem( VmathSoaMatrix3 *result, int col, int row, vec_float4 val ); + +/* + * Get the element of a 3x3 matrix referred to by column and row indices + */ +static inline vec_float4 vmathSoaM3GetElem( const VmathSoaMatrix3 *mat, int col, int row ); + +/* + * Add two 3x3 matrices + */ +static inline void vmathSoaM3Add( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1 ); + +/* + * Subtract a 3x3 matrix from another 3x3 matrix + */ +static inline void vmathSoaM3Sub( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1 ); + +/* + * Negate all elements of a 3x3 matrix + */ +static inline void vmathSoaM3Neg( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ); + +/* + * Multiply a 3x3 matrix by a scalar + */ +static inline void vmathSoaM3ScalarMul( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat, vec_float4 scalar ); + +/* + * Multiply a 3x3 matrix by a 3-D vector + */ +static inline void vmathSoaM3MulV3( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat, const VmathSoaVector3 *vec ); + +/* + * Multiply two 3x3 matrices + */ +static inline void vmathSoaM3Mul( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1 ); + +/* + * Construct an identity 3x3 matrix + */ +static inline void vmathSoaM3MakeIdentity( VmathSoaMatrix3 *result ); + +/* + * Construct a 3x3 matrix to rotate around the x axis + */ +static inline void vmathSoaM3MakeRotationX( VmathSoaMatrix3 *result, vec_float4 radians ); + +/* + * Construct a 3x3 matrix to rotate around the y axis + */ +static inline void vmathSoaM3MakeRotationY( VmathSoaMatrix3 *result, vec_float4 radians ); + +/* + * Construct a 3x3 matrix to rotate around the z axis + */ +static inline void vmathSoaM3MakeRotationZ( VmathSoaMatrix3 *result, vec_float4 radians ); + +/* + * Construct a 3x3 matrix to rotate around the x, y, and z axes + */ +static inline void vmathSoaM3MakeRotationZYX( VmathSoaMatrix3 *result, const VmathSoaVector3 *radiansXYZ ); + +/* + * Construct a 3x3 matrix to rotate around a unit-length 3-D vector + */ +static inline void vmathSoaM3MakeRotationAxis( VmathSoaMatrix3 *result, vec_float4 radians, const VmathSoaVector3 *unitVec ); + +/* + * Construct a rotation matrix from a unit-length quaternion + */ +static inline void vmathSoaM3MakeRotationQ( VmathSoaMatrix3 *result, const VmathSoaQuat *unitQuat ); + +/* + * Construct a 3x3 matrix to perform scaling + */ +static inline void vmathSoaM3MakeScale( VmathSoaMatrix3 *result, const VmathSoaVector3 *scaleVec ); + +/* + * Append (post-multiply) a scale transformation to a 3x3 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline void vmathSoaM3AppendScale( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat, const VmathSoaVector3 *scaleVec ); + +/* + * Prepend (pre-multiply) a scale transformation to a 3x3 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline void vmathSoaM3PrependScale( VmathSoaMatrix3 *result, const VmathSoaVector3 *scaleVec, const VmathSoaMatrix3 *mat ); + +/* + * Multiply two 3x3 matrices per element + */ +static inline void vmathSoaM3MulPerElem( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1 ); + +/* + * Compute the absolute value of a 3x3 matrix per element + */ +static inline void vmathSoaM3AbsPerElem( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ); + +/* + * Transpose of a 3x3 matrix + */ +static inline void vmathSoaM3Transpose( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ); + +/* + * Compute the inverse of a 3x3 matrix + * NOTE: + * Result is unpredictable when the determinant of mat is equal to or near 0. + */ +static inline void vmathSoaM3Inverse( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ); + +/* + * Determinant of a 3x3 matrix + */ +static inline vec_float4 vmathSoaM3Determinant( const VmathSoaMatrix3 *mat ); + +/* + * Conditionally select between two 3x3 matrices + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline void vmathSoaM3Select( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1, vec_uint4 select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3x3 matrix + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaM3Print( const VmathSoaMatrix3 *mat ); + +/* + * Print a 3x3 matrix and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaM3Prints( const VmathSoaMatrix3 *mat, const char *name ); + +#endif + +/* + * Copy a 4x4 matrix + */ +static inline void vmathSoaM4Copy( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ); + +/* + * Construct a 4x4 matrix containing the specified columns + */ +static inline void vmathSoaM4MakeFromCols( VmathSoaMatrix4 *result, const VmathSoaVector4 *col0, const VmathSoaVector4 *col1, const VmathSoaVector4 *col2, const VmathSoaVector4 *col3 ); + +/* + * Construct a 4x4 matrix from a 3x4 transformation matrix + */ +static inline void vmathSoaM4MakeFromT3( VmathSoaMatrix4 *result, const VmathSoaTransform3 *mat ); + +/* + * Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector + */ +static inline void vmathSoaM4MakeFromM3V3( VmathSoaMatrix4 *result, const VmathSoaMatrix3 *mat, const VmathSoaVector3 *translateVec ); + +/* + * Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector + */ +static inline void vmathSoaM4MakeFromQV3( VmathSoaMatrix4 *result, const VmathSoaQuat *unitQuat, const VmathSoaVector3 *translateVec ); + +/* + * Set all elements of a 4x4 matrix to the same scalar value + */ +static inline void vmathSoaM4MakeFromScalar( VmathSoaMatrix4 *result, vec_float4 scalar ); + +/* + * Replicate an AoS 4x4 matrix + */ +static inline void vmathSoaM4MakeFromAos( VmathSoaMatrix4 *result, const VmathMatrix4 *mat ); + +/* + * Insert four AoS 4x4 matrices + */ +static inline void vmathSoaM4MakeFrom4Aos( VmathSoaMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1, const VmathMatrix4 *mat2, const VmathMatrix4 *mat3 ); + +/* + * Extract four AoS 4x4 matrices + */ +static inline void vmathSoaM4Get4Aos( const VmathSoaMatrix4 *mat, VmathMatrix4 *result0, VmathMatrix4 *result1, VmathMatrix4 *result2, VmathMatrix4 *result3 ); + +/* + * Set the upper-left 3x3 submatrix + * NOTE: + * This function does not change the bottom row elements. + */ +static inline void vmathSoaM4SetUpper3x3( VmathSoaMatrix4 *result, const VmathSoaMatrix3 *mat3 ); + +/* + * Get the upper-left 3x3 submatrix of a 4x4 matrix + */ +static inline void vmathSoaM4GetUpper3x3( VmathSoaMatrix3 *result, const VmathSoaMatrix4 *mat ); + +/* + * Set translation component + * NOTE: + * This function does not change the bottom row elements. + */ +static inline void vmathSoaM4SetTranslation( VmathSoaMatrix4 *result, const VmathSoaVector3 *translateVec ); + +/* + * Get the translation component of a 4x4 matrix + */ +static inline void vmathSoaM4GetTranslation( VmathSoaVector3 *result, const VmathSoaMatrix4 *mat ); + +/* + * Set column 0 of a 4x4 matrix + */ +static inline void vmathSoaM4SetCol0( VmathSoaMatrix4 *result, const VmathSoaVector4 *col0 ); + +/* + * Set column 1 of a 4x4 matrix + */ +static inline void vmathSoaM4SetCol1( VmathSoaMatrix4 *result, const VmathSoaVector4 *col1 ); + +/* + * Set column 2 of a 4x4 matrix + */ +static inline void vmathSoaM4SetCol2( VmathSoaMatrix4 *result, const VmathSoaVector4 *col2 ); + +/* + * Set column 3 of a 4x4 matrix + */ +static inline void vmathSoaM4SetCol3( VmathSoaMatrix4 *result, const VmathSoaVector4 *col3 ); + +/* + * Get column 0 of a 4x4 matrix + */ +static inline void vmathSoaM4GetCol0( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat ); + +/* + * Get column 1 of a 4x4 matrix + */ +static inline void vmathSoaM4GetCol1( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat ); + +/* + * Get column 2 of a 4x4 matrix + */ +static inline void vmathSoaM4GetCol2( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat ); + +/* + * Get column 3 of a 4x4 matrix + */ +static inline void vmathSoaM4GetCol3( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat ); + +/* + * Set the column of a 4x4 matrix referred to by the specified index + */ +static inline void vmathSoaM4SetCol( VmathSoaMatrix4 *result, int col, const VmathSoaVector4 *vec ); + +/* + * Set the row of a 4x4 matrix referred to by the specified index + */ +static inline void vmathSoaM4SetRow( VmathSoaMatrix4 *result, int row, const VmathSoaVector4 *vec ); + +/* + * Get the column of a 4x4 matrix referred to by the specified index + */ +static inline void vmathSoaM4GetCol( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, int col ); + +/* + * Get the row of a 4x4 matrix referred to by the specified index + */ +static inline void vmathSoaM4GetRow( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, int row ); + +/* + * Set the element of a 4x4 matrix referred to by column and row indices + */ +static inline void vmathSoaM4SetElem( VmathSoaMatrix4 *result, int col, int row, vec_float4 val ); + +/* + * Get the element of a 4x4 matrix referred to by column and row indices + */ +static inline vec_float4 vmathSoaM4GetElem( const VmathSoaMatrix4 *mat, int col, int row ); + +/* + * Add two 4x4 matrices + */ +static inline void vmathSoaM4Add( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1 ); + +/* + * Subtract a 4x4 matrix from another 4x4 matrix + */ +static inline void vmathSoaM4Sub( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1 ); + +/* + * Negate all elements of a 4x4 matrix + */ +static inline void vmathSoaM4Neg( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ); + +/* + * Multiply a 4x4 matrix by a scalar + */ +static inline void vmathSoaM4ScalarMul( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat, vec_float4 scalar ); + +/* + * Multiply a 4x4 matrix by a 4-D vector + */ +static inline void vmathSoaM4MulV4( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, const VmathSoaVector4 *vec ); + +/* + * Multiply a 4x4 matrix by a 3-D vector + */ +static inline void vmathSoaM4MulV3( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, const VmathSoaVector3 *vec ); + +/* + * Multiply a 4x4 matrix by a 3-D point + */ +static inline void vmathSoaM4MulP3( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, const VmathSoaPoint3 *pnt ); + +/* + * Multiply two 4x4 matrices + */ +static inline void vmathSoaM4Mul( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1 ); + +/* + * Multiply a 4x4 matrix by a 3x4 transformation matrix + */ +static inline void vmathSoaM4MulT3( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat, const VmathSoaTransform3 *tfrm ); + +/* + * Construct an identity 4x4 matrix + */ +static inline void vmathSoaM4MakeIdentity( VmathSoaMatrix4 *result ); + +/* + * Construct a 4x4 matrix to rotate around the x axis + */ +static inline void vmathSoaM4MakeRotationX( VmathSoaMatrix4 *result, vec_float4 radians ); + +/* + * Construct a 4x4 matrix to rotate around the y axis + */ +static inline void vmathSoaM4MakeRotationY( VmathSoaMatrix4 *result, vec_float4 radians ); + +/* + * Construct a 4x4 matrix to rotate around the z axis + */ +static inline void vmathSoaM4MakeRotationZ( VmathSoaMatrix4 *result, vec_float4 radians ); + +/* + * Construct a 4x4 matrix to rotate around the x, y, and z axes + */ +static inline void vmathSoaM4MakeRotationZYX( VmathSoaMatrix4 *result, const VmathSoaVector3 *radiansXYZ ); + +/* + * Construct a 4x4 matrix to rotate around a unit-length 3-D vector + */ +static inline void vmathSoaM4MakeRotationAxis( VmathSoaMatrix4 *result, vec_float4 radians, const VmathSoaVector3 *unitVec ); + +/* + * Construct a rotation matrix from a unit-length quaternion + */ +static inline void vmathSoaM4MakeRotationQ( VmathSoaMatrix4 *result, const VmathSoaQuat *unitQuat ); + +/* + * Construct a 4x4 matrix to perform scaling + */ +static inline void vmathSoaM4MakeScale( VmathSoaMatrix4 *result, const VmathSoaVector3 *scaleVec ); + +/* + * Construct a 4x4 matrix to perform translation + */ +static inline void vmathSoaM4MakeTranslation( VmathSoaMatrix4 *result, const VmathSoaVector3 *translateVec ); + +/* + * Construct viewing matrix based on eye position, position looked at, and up direction + */ +static inline void vmathSoaM4MakeLookAt( VmathSoaMatrix4 *result, const VmathSoaPoint3 *eyePos, const VmathSoaPoint3 *lookAtPos, const VmathSoaVector3 *upVec ); + +/* + * Construct a perspective projection matrix + */ +static inline void vmathSoaM4MakePerspective( VmathSoaMatrix4 *result, vec_float4 fovyRadians, vec_float4 aspect, vec_float4 zNear, vec_float4 zFar ); + +/* + * Construct a perspective projection matrix based on frustum + */ +static inline void vmathSoaM4MakeFrustum( VmathSoaMatrix4 *result, vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ); + +/* + * Construct an orthographic projection matrix + */ +static inline void vmathSoaM4MakeOrthographic( VmathSoaMatrix4 *result, vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ); + +/* + * Append (post-multiply) a scale transformation to a 4x4 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline void vmathSoaM4AppendScale( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat, const VmathSoaVector3 *scaleVec ); + +/* + * Prepend (pre-multiply) a scale transformation to a 4x4 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline void vmathSoaM4PrependScale( VmathSoaMatrix4 *result, const VmathSoaVector3 *scaleVec, const VmathSoaMatrix4 *mat ); + +/* + * Multiply two 4x4 matrices per element + */ +static inline void vmathSoaM4MulPerElem( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1 ); + +/* + * Compute the absolute value of a 4x4 matrix per element + */ +static inline void vmathSoaM4AbsPerElem( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ); + +/* + * Transpose of a 4x4 matrix + */ +static inline void vmathSoaM4Transpose( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ); + +/* + * Compute the inverse of a 4x4 matrix + * NOTE: + * Result is unpredictable when the determinant of mat is equal to or near 0. + */ +static inline void vmathSoaM4Inverse( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ); + +/* + * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix + * NOTE: + * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. The result is unpredictable when the determinant of mat is equal to or near 0. + */ +static inline void vmathSoaM4AffineInverse( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ); + +/* + * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix + * NOTE: + * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. + */ +static inline void vmathSoaM4OrthoInverse( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ); + +/* + * Determinant of a 4x4 matrix + */ +static inline vec_float4 vmathSoaM4Determinant( const VmathSoaMatrix4 *mat ); + +/* + * Conditionally select between two 4x4 matrices + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline void vmathSoaM4Select( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1, vec_uint4 select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 4x4 matrix + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaM4Print( const VmathSoaMatrix4 *mat ); + +/* + * Print a 4x4 matrix and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaM4Prints( const VmathSoaMatrix4 *mat, const char *name ); + +#endif + +/* + * Copy a 3x4 transformation matrix + */ +static inline void vmathSoaT3Copy( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm ); + +/* + * Construct a 3x4 transformation matrix containing the specified columns + */ +static inline void vmathSoaT3MakeFromCols( VmathSoaTransform3 *result, const VmathSoaVector3 *col0, const VmathSoaVector3 *col1, const VmathSoaVector3 *col2, const VmathSoaVector3 *col3 ); + +/* + * Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector + */ +static inline void vmathSoaT3MakeFromM3V3( VmathSoaTransform3 *result, const VmathSoaMatrix3 *tfrm, const VmathSoaVector3 *translateVec ); + +/* + * Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector + */ +static inline void vmathSoaT3MakeFromQV3( VmathSoaTransform3 *result, const VmathSoaQuat *unitQuat, const VmathSoaVector3 *translateVec ); + +/* + * Set all elements of a 3x4 transformation matrix to the same scalar value + */ +static inline void vmathSoaT3MakeFromScalar( VmathSoaTransform3 *result, vec_float4 scalar ); + +/* + * Replicate an AoS 3x4 transformation matrix + */ +static inline void vmathSoaT3MakeFromAos( VmathSoaTransform3 *result, const VmathTransform3 *tfrm ); + +/* + * Insert four AoS 3x4 transformation matrices + */ +static inline void vmathSoaT3MakeFrom4Aos( VmathSoaTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1, const VmathTransform3 *tfrm2, const VmathTransform3 *tfrm3 ); + +/* + * Extract four AoS 3x4 transformation matrices + */ +static inline void vmathSoaT3Get4Aos( const VmathSoaTransform3 *tfrm, VmathTransform3 *result0, VmathTransform3 *result1, VmathTransform3 *result2, VmathTransform3 *result3 ); + +/* + * Set the upper-left 3x3 submatrix + */ +static inline void vmathSoaT3SetUpper3x3( VmathSoaTransform3 *result, const VmathSoaMatrix3 *mat3 ); + +/* + * Get the upper-left 3x3 submatrix of a 3x4 transformation matrix + */ +static inline void vmathSoaT3GetUpper3x3( VmathSoaMatrix3 *result, const VmathSoaTransform3 *tfrm ); + +/* + * Set translation component + */ +static inline void vmathSoaT3SetTranslation( VmathSoaTransform3 *result, const VmathSoaVector3 *translateVec ); + +/* + * Get the translation component of a 3x4 transformation matrix + */ +static inline void vmathSoaT3GetTranslation( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ); + +/* + * Set column 0 of a 3x4 transformation matrix + */ +static inline void vmathSoaT3SetCol0( VmathSoaTransform3 *result, const VmathSoaVector3 *col0 ); + +/* + * Set column 1 of a 3x4 transformation matrix + */ +static inline void vmathSoaT3SetCol1( VmathSoaTransform3 *result, const VmathSoaVector3 *col1 ); + +/* + * Set column 2 of a 3x4 transformation matrix + */ +static inline void vmathSoaT3SetCol2( VmathSoaTransform3 *result, const VmathSoaVector3 *col2 ); + +/* + * Set column 3 of a 3x4 transformation matrix + */ +static inline void vmathSoaT3SetCol3( VmathSoaTransform3 *result, const VmathSoaVector3 *col3 ); + +/* + * Get column 0 of a 3x4 transformation matrix + */ +static inline void vmathSoaT3GetCol0( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ); + +/* + * Get column 1 of a 3x4 transformation matrix + */ +static inline void vmathSoaT3GetCol1( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ); + +/* + * Get column 2 of a 3x4 transformation matrix + */ +static inline void vmathSoaT3GetCol2( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ); + +/* + * Get column 3 of a 3x4 transformation matrix + */ +static inline void vmathSoaT3GetCol3( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ); + +/* + * Set the column of a 3x4 transformation matrix referred to by the specified index + */ +static inline void vmathSoaT3SetCol( VmathSoaTransform3 *result, int col, const VmathSoaVector3 *vec ); + +/* + * Set the row of a 3x4 transformation matrix referred to by the specified index + */ +static inline void vmathSoaT3SetRow( VmathSoaTransform3 *result, int row, const VmathSoaVector4 *vec ); + +/* + * Get the column of a 3x4 transformation matrix referred to by the specified index + */ +static inline void vmathSoaT3GetCol( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm, int col ); + +/* + * Get the row of a 3x4 transformation matrix referred to by the specified index + */ +static inline void vmathSoaT3GetRow( VmathSoaVector4 *result, const VmathSoaTransform3 *tfrm, int row ); + +/* + * Set the element of a 3x4 transformation matrix referred to by column and row indices + */ +static inline void vmathSoaT3SetElem( VmathSoaTransform3 *result, int col, int row, vec_float4 val ); + +/* + * Get the element of a 3x4 transformation matrix referred to by column and row indices + */ +static inline vec_float4 vmathSoaT3GetElem( const VmathSoaTransform3 *tfrm, int col, int row ); + +/* + * Multiply a 3x4 transformation matrix by a 3-D vector + */ +static inline void vmathSoaT3MulV3( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm, const VmathSoaVector3 *vec ); + +/* + * Multiply a 3x4 transformation matrix by a 3-D point + */ +static inline void vmathSoaT3MulP3( VmathSoaPoint3 *result, const VmathSoaTransform3 *tfrm, const VmathSoaPoint3 *pnt ); + +/* + * Multiply two 3x4 transformation matrices + */ +static inline void vmathSoaT3Mul( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm0, const VmathSoaTransform3 *tfrm1 ); + +/* + * Construct an identity 3x4 transformation matrix + */ +static inline void vmathSoaT3MakeIdentity( VmathSoaTransform3 *result ); + +/* + * Construct a 3x4 transformation matrix to rotate around the x axis + */ +static inline void vmathSoaT3MakeRotationX( VmathSoaTransform3 *result, vec_float4 radians ); + +/* + * Construct a 3x4 transformation matrix to rotate around the y axis + */ +static inline void vmathSoaT3MakeRotationY( VmathSoaTransform3 *result, vec_float4 radians ); + +/* + * Construct a 3x4 transformation matrix to rotate around the z axis + */ +static inline void vmathSoaT3MakeRotationZ( VmathSoaTransform3 *result, vec_float4 radians ); + +/* + * Construct a 3x4 transformation matrix to rotate around the x, y, and z axes + */ +static inline void vmathSoaT3MakeRotationZYX( VmathSoaTransform3 *result, const VmathSoaVector3 *radiansXYZ ); + +/* + * Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector + */ +static inline void vmathSoaT3MakeRotationAxis( VmathSoaTransform3 *result, vec_float4 radians, const VmathSoaVector3 *unitVec ); + +/* + * Construct a rotation matrix from a unit-length quaternion + */ +static inline void vmathSoaT3MakeRotationQ( VmathSoaTransform3 *result, const VmathSoaQuat *unitQuat ); + +/* + * Construct a 3x4 transformation matrix to perform scaling + */ +static inline void vmathSoaT3MakeScale( VmathSoaTransform3 *result, const VmathSoaVector3 *scaleVec ); + +/* + * Construct a 3x4 transformation matrix to perform translation + */ +static inline void vmathSoaT3MakeTranslation( VmathSoaTransform3 *result, const VmathSoaVector3 *translateVec ); + +/* + * Append (post-multiply) a scale transformation to a 3x4 transformation matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline void vmathSoaT3AppendScale( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm, const VmathSoaVector3 *scaleVec ); + +/* + * Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline void vmathSoaT3PrependScale( VmathSoaTransform3 *result, const VmathSoaVector3 *scaleVec, const VmathSoaTransform3 *tfrm ); + +/* + * Multiply two 3x4 transformation matrices per element + */ +static inline void vmathSoaT3MulPerElem( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm0, const VmathSoaTransform3 *tfrm1 ); + +/* + * Compute the absolute value of a 3x4 transformation matrix per element + */ +static inline void vmathSoaT3AbsPerElem( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm ); + +/* + * Inverse of a 3x4 transformation matrix + * NOTE: + * Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0. + */ +static inline void vmathSoaT3Inverse( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm ); + +/* + * Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix + * NOTE: + * This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions. + */ +static inline void vmathSoaT3OrthoInverse( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm ); + +/* + * Conditionally select between two 3x4 transformation matrices + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline void vmathSoaT3Select( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm0, const VmathSoaTransform3 *tfrm1, vec_uint4 select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3x4 transformation matrix + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaT3Print( const VmathSoaTransform3 *tfrm ); + +/* + * Print a 3x4 transformation matrix and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaT3Prints( const VmathSoaTransform3 *tfrm, const char *name ); + +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include "vec_soa.h" +#include "quat_soa.h" +#include "mat_soa.h" + +#endif diff --git a/vectormathlibrary/include/vectormath/spu/c/vectormath_soa_v.h b/vectormathlibrary/include/vectormath/spu/c/vectormath_soa_v.h new file mode 100644 index 000000000..85ebed3ac --- /dev/null +++ b/vectormathlibrary/include/vectormath/spu/c/vectormath_soa_v.h @@ -0,0 +1,1978 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_SOA_C_V_SPU_H +#define _VECTORMATH_SOA_C_V_SPU_H + +#include <math.h> +#include <spu_intrinsics.h> +#include "vectormath_aos_v.h" + +#ifdef _VECTORMATH_DEBUG +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#ifndef _VECTORMATH_SOA_C_TYPES_H +#define _VECTORMATH_SOA_C_TYPES_H + +/* A set of four 3-D vectors in structure-of-arrays format + */ +typedef struct _VmathSoaVector3 +{ + vec_float4 x; + vec_float4 y; + vec_float4 z; +} VmathSoaVector3; + +/* A set of four 4-D vectors in structure-of-arrays format + */ +typedef struct _VmathSoaVector4 +{ + vec_float4 x; + vec_float4 y; + vec_float4 z; + vec_float4 w; +} VmathSoaVector4; + +/* A set of four 3-D points in structure-of-arrays format + */ +typedef struct _VmathSoaPoint3 +{ + vec_float4 x; + vec_float4 y; + vec_float4 z; +} VmathSoaPoint3; + +/* A set of four quaternions in structure-of-arrays format + */ +typedef struct _VmathSoaQuat +{ + vec_float4 x; + vec_float4 y; + vec_float4 z; + vec_float4 w; +} VmathSoaQuat; + +/* A set of four 3x3 matrices in structure-of-arrays format + */ +typedef struct _VmathSoaMatrix3 +{ + VmathSoaVector3 col0; + VmathSoaVector3 col1; + VmathSoaVector3 col2; +} VmathSoaMatrix3; + +/* A set of four 4x4 matrices in structure-of-arrays format + */ +typedef struct _VmathSoaMatrix4 +{ + VmathSoaVector4 col0; + VmathSoaVector4 col1; + VmathSoaVector4 col2; + VmathSoaVector4 col3; +} VmathSoaMatrix4; + +/* A set of four 3x4 transformation matrices in structure-of-arrays format + */ +typedef struct _VmathSoaTransform3 +{ + VmathSoaVector3 col0; + VmathSoaVector3 col1; + VmathSoaVector3 col2; + VmathSoaVector3 col3; +} VmathSoaTransform3; + +#endif + +/* + * Construct a 3-D vector from x, y, and z elements + */ +static inline VmathSoaVector3 vmathSoaV3MakeFromElems_V( vec_float4 x, vec_float4 y, vec_float4 z ); + +/* + * Copy elements from a 3-D point into a 3-D vector + */ +static inline VmathSoaVector3 vmathSoaV3MakeFromP3_V( VmathSoaPoint3 pnt ); + +/* + * Set all elements of a 3-D vector to the same scalar value + */ +static inline VmathSoaVector3 vmathSoaV3MakeFromScalar_V( vec_float4 scalar ); + +/* + * Replicate an AoS 3-D vector + */ +static inline VmathSoaVector3 vmathSoaV3MakeFromAos_V( VmathVector3 vec ); + +/* + * Insert four AoS 3-D vectors + */ +static inline VmathSoaVector3 vmathSoaV3MakeFrom4Aos_V( VmathVector3 vec0, VmathVector3 vec1, VmathVector3 vec2, VmathVector3 vec3 ); + +/* + * Extract four AoS 3-D vectors + */ +static inline void vmathSoaV3Get4Aos_V( VmathSoaVector3 vec, VmathVector3 *result0, VmathVector3 *result1, VmathVector3 *result2, VmathVector3 *result3 ); + +/* + * Set the x element of a 3-D vector + */ +static inline void vmathSoaV3SetX_V( VmathSoaVector3 *result, vec_float4 x ); + +/* + * Set the y element of a 3-D vector + */ +static inline void vmathSoaV3SetY_V( VmathSoaVector3 *result, vec_float4 y ); + +/* + * Set the z element of a 3-D vector + */ +static inline void vmathSoaV3SetZ_V( VmathSoaVector3 *result, vec_float4 z ); + +/* + * Get the x element of a 3-D vector + */ +static inline vec_float4 vmathSoaV3GetX_V( VmathSoaVector3 vec ); + +/* + * Get the y element of a 3-D vector + */ +static inline vec_float4 vmathSoaV3GetY_V( VmathSoaVector3 vec ); + +/* + * Get the z element of a 3-D vector + */ +static inline vec_float4 vmathSoaV3GetZ_V( VmathSoaVector3 vec ); + +/* + * Set an x, y, or z element of a 3-D vector by index + */ +static inline void vmathSoaV3SetElem_V( VmathSoaVector3 *result, int idx, vec_float4 value ); + +/* + * Get an x, y, or z element of a 3-D vector by index + */ +static inline vec_float4 vmathSoaV3GetElem_V( VmathSoaVector3 vec, int idx ); + +/* + * Add two 3-D vectors + */ +static inline VmathSoaVector3 vmathSoaV3Add_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); + +/* + * Subtract a 3-D vector from another 3-D vector + */ +static inline VmathSoaVector3 vmathSoaV3Sub_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); + +/* + * Add a 3-D vector to a 3-D point + */ +static inline VmathSoaPoint3 vmathSoaV3AddP3_V( VmathSoaVector3 vec, VmathSoaPoint3 pnt ); + +/* + * Multiply a 3-D vector by a scalar + */ +static inline VmathSoaVector3 vmathSoaV3ScalarMul_V( VmathSoaVector3 vec, vec_float4 scalar ); + +/* + * Divide a 3-D vector by a scalar + */ +static inline VmathSoaVector3 vmathSoaV3ScalarDiv_V( VmathSoaVector3 vec, vec_float4 scalar ); + +/* + * Negate all elements of a 3-D vector + */ +static inline VmathSoaVector3 vmathSoaV3Neg_V( VmathSoaVector3 vec ); + +/* + * Construct x axis + */ +static inline VmathSoaVector3 vmathSoaV3MakeXAxis_V( ); + +/* + * Construct y axis + */ +static inline VmathSoaVector3 vmathSoaV3MakeYAxis_V( ); + +/* + * Construct z axis + */ +static inline VmathSoaVector3 vmathSoaV3MakeZAxis_V( ); + +/* + * Multiply two 3-D vectors per element + */ +static inline VmathSoaVector3 vmathSoaV3MulPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); + +/* + * Divide two 3-D vectors per element + * NOTE: + * Floating-point behavior matches standard library function divf4. + */ +static inline VmathSoaVector3 vmathSoaV3DivPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); + +/* + * Compute the reciprocal of a 3-D vector per element + * NOTE: + * Floating-point behavior matches standard library function recipf4. + */ +static inline VmathSoaVector3 vmathSoaV3RecipPerElem_V( VmathSoaVector3 vec ); + +/* + * Compute the square root of a 3-D vector per element + * NOTE: + * Floating-point behavior matches standard library function sqrtf4. + */ +static inline VmathSoaVector3 vmathSoaV3SqrtPerElem_V( VmathSoaVector3 vec ); + +/* + * Compute the reciprocal square root of a 3-D vector per element + * NOTE: + * Floating-point behavior matches standard library function rsqrtf4. + */ +static inline VmathSoaVector3 vmathSoaV3RsqrtPerElem_V( VmathSoaVector3 vec ); + +/* + * Compute the absolute value of a 3-D vector per element + */ +static inline VmathSoaVector3 vmathSoaV3AbsPerElem_V( VmathSoaVector3 vec ); + +/* + * Copy sign from one 3-D vector to another, per element + */ +static inline VmathSoaVector3 vmathSoaV3CopySignPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); + +/* + * Maximum of two 3-D vectors per element + */ +static inline VmathSoaVector3 vmathSoaV3MaxPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); + +/* + * Minimum of two 3-D vectors per element + */ +static inline VmathSoaVector3 vmathSoaV3MinPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); + +/* + * Maximum element of a 3-D vector + */ +static inline vec_float4 vmathSoaV3MaxElem_V( VmathSoaVector3 vec ); + +/* + * Minimum element of a 3-D vector + */ +static inline vec_float4 vmathSoaV3MinElem_V( VmathSoaVector3 vec ); + +/* + * Compute the sum of all elements of a 3-D vector + */ +static inline vec_float4 vmathSoaV3Sum_V( VmathSoaVector3 vec ); + +/* + * Compute the dot product of two 3-D vectors + */ +static inline vec_float4 vmathSoaV3Dot_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); + +/* + * Compute the square of the length of a 3-D vector + */ +static inline vec_float4 vmathSoaV3LengthSqr_V( VmathSoaVector3 vec ); + +/* + * Compute the length of a 3-D vector + */ +static inline vec_float4 vmathSoaV3Length_V( VmathSoaVector3 vec ); + +/* + * Normalize a 3-D vector + * NOTE: + * The result is unpredictable when all elements of vec are at or near zero. + */ +static inline VmathSoaVector3 vmathSoaV3Normalize_V( VmathSoaVector3 vec ); + +/* + * Compute cross product of two 3-D vectors + */ +static inline VmathSoaVector3 vmathSoaV3Cross_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); + +/* + * Outer product of two 3-D vectors + */ +static inline VmathSoaMatrix3 vmathSoaV3Outer_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); + +/* + * Pre-multiply a row vector by a 3x3 matrix + */ +static inline VmathSoaVector3 vmathSoaV3RowMul_V( VmathSoaVector3 vec, VmathSoaMatrix3 mat ); + +/* + * Cross-product matrix of a 3-D vector + */ +static inline VmathSoaMatrix3 vmathSoaV3CrossMatrix_V( VmathSoaVector3 vec ); + +/* + * Create cross-product matrix and multiply + * NOTE: + * Faster than separately creating a cross-product matrix and multiplying. + */ +static inline VmathSoaMatrix3 vmathSoaV3CrossMatrixMul_V( VmathSoaVector3 vec, VmathSoaMatrix3 mat ); + +/* + * Linear interpolation between two 3-D vectors + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline VmathSoaVector3 vmathSoaV3Lerp_V( vec_float4 t, VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); + +/* + * Spherical linear interpolation between two 3-D vectors + * NOTE: + * The result is unpredictable if the vectors point in opposite directions. + * Does not clamp t between 0 and 1. + */ +static inline VmathSoaVector3 vmathSoaV3Slerp_V( vec_float4 t, VmathSoaVector3 unitVec0, VmathSoaVector3 unitVec1 ); + +/* + * Conditionally select between two 3-D vectors + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline VmathSoaVector3 vmathSoaV3Select_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1, vec_uint4 select1 ); + +/* + * Load four three-float 3-D vectors, stored in three quadwords + */ +static inline void vmathSoaV3LoadXYZArray_V( VmathSoaVector3 *vec, const vec_float4 *threeQuads ); + +/* + * Store four slots of an SoA 3-D vector in three quadwords + */ +static inline void vmathSoaV3StoreXYZArray_V( VmathSoaVector3 vec, vec_float4 *threeQuads ); + +/* + * Store eight slots of two SoA 3-D vectors as half-floats + */ +static inline void vmathSoaV3StoreHalfFloats_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1, vec_ushort8 *threeQuads ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3-D vector + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaV3Print_V( VmathSoaVector3 vec ); + +/* + * Print a 3-D vector and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaV3Prints_V( VmathSoaVector3 vec, const char *name ); + +#endif + +/* + * Construct a 4-D vector from x, y, z, and w elements + */ +static inline VmathSoaVector4 vmathSoaV4MakeFromElems_V( vec_float4 x, vec_float4 y, vec_float4 z, vec_float4 w ); + +/* + * Construct a 4-D vector from a 3-D vector and a scalar + */ +static inline VmathSoaVector4 vmathSoaV4MakeFromV3Scalar_V( VmathSoaVector3 xyz, vec_float4 w ); + +/* + * Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0 + */ +static inline VmathSoaVector4 vmathSoaV4MakeFromV3_V( VmathSoaVector3 vec ); + +/* + * Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1 + */ +static inline VmathSoaVector4 vmathSoaV4MakeFromP3_V( VmathSoaPoint3 pnt ); + +/* + * Copy elements from a quaternion into a 4-D vector + */ +static inline VmathSoaVector4 vmathSoaV4MakeFromQ_V( VmathSoaQuat quat ); + +/* + * Set all elements of a 4-D vector to the same scalar value + */ +static inline VmathSoaVector4 vmathSoaV4MakeFromScalar_V( vec_float4 scalar ); + +/* + * Replicate an AoS 4-D vector + */ +static inline VmathSoaVector4 vmathSoaV4MakeFromAos_V( VmathVector4 vec ); + +/* + * Insert four AoS 4-D vectors + */ +static inline VmathSoaVector4 vmathSoaV4MakeFrom4Aos_V( VmathVector4 vec0, VmathVector4 vec1, VmathVector4 vec2, VmathVector4 vec3 ); + +/* + * Extract four AoS 4-D vectors + */ +static inline void vmathSoaV4Get4Aos_V( VmathSoaVector4 vec, VmathVector4 *result0, VmathVector4 *result1, VmathVector4 *result2, VmathVector4 *result3 ); + +/* + * Set the x, y, and z elements of a 4-D vector + * NOTE: + * This function does not change the w element. + */ +static inline void vmathSoaV4SetXYZ_V( VmathSoaVector4 *result, VmathSoaVector3 vec ); + +/* + * Get the x, y, and z elements of a 4-D vector + */ +static inline VmathSoaVector3 vmathSoaV4GetXYZ_V( VmathSoaVector4 vec ); + +/* + * Set the x element of a 4-D vector + */ +static inline void vmathSoaV4SetX_V( VmathSoaVector4 *result, vec_float4 x ); + +/* + * Set the y element of a 4-D vector + */ +static inline void vmathSoaV4SetY_V( VmathSoaVector4 *result, vec_float4 y ); + +/* + * Set the z element of a 4-D vector + */ +static inline void vmathSoaV4SetZ_V( VmathSoaVector4 *result, vec_float4 z ); + +/* + * Set the w element of a 4-D vector + */ +static inline void vmathSoaV4SetW_V( VmathSoaVector4 *result, vec_float4 w ); + +/* + * Get the x element of a 4-D vector + */ +static inline vec_float4 vmathSoaV4GetX_V( VmathSoaVector4 vec ); + +/* + * Get the y element of a 4-D vector + */ +static inline vec_float4 vmathSoaV4GetY_V( VmathSoaVector4 vec ); + +/* + * Get the z element of a 4-D vector + */ +static inline vec_float4 vmathSoaV4GetZ_V( VmathSoaVector4 vec ); + +/* + * Get the w element of a 4-D vector + */ +static inline vec_float4 vmathSoaV4GetW_V( VmathSoaVector4 vec ); + +/* + * Set an x, y, z, or w element of a 4-D vector by index + */ +static inline void vmathSoaV4SetElem_V( VmathSoaVector4 *result, int idx, vec_float4 value ); + +/* + * Get an x, y, z, or w element of a 4-D vector by index + */ +static inline vec_float4 vmathSoaV4GetElem_V( VmathSoaVector4 vec, int idx ); + +/* + * Add two 4-D vectors + */ +static inline VmathSoaVector4 vmathSoaV4Add_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); + +/* + * Subtract a 4-D vector from another 4-D vector + */ +static inline VmathSoaVector4 vmathSoaV4Sub_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); + +/* + * Multiply a 4-D vector by a scalar + */ +static inline VmathSoaVector4 vmathSoaV4ScalarMul_V( VmathSoaVector4 vec, vec_float4 scalar ); + +/* + * Divide a 4-D vector by a scalar + */ +static inline VmathSoaVector4 vmathSoaV4ScalarDiv_V( VmathSoaVector4 vec, vec_float4 scalar ); + +/* + * Negate all elements of a 4-D vector + */ +static inline VmathSoaVector4 vmathSoaV4Neg_V( VmathSoaVector4 vec ); + +/* + * Construct x axis + */ +static inline VmathSoaVector4 vmathSoaV4MakeXAxis_V( ); + +/* + * Construct y axis + */ +static inline VmathSoaVector4 vmathSoaV4MakeYAxis_V( ); + +/* + * Construct z axis + */ +static inline VmathSoaVector4 vmathSoaV4MakeZAxis_V( ); + +/* + * Construct w axis + */ +static inline VmathSoaVector4 vmathSoaV4MakeWAxis_V( ); + +/* + * Multiply two 4-D vectors per element + */ +static inline VmathSoaVector4 vmathSoaV4MulPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); + +/* + * Divide two 4-D vectors per element + * NOTE: + * Floating-point behavior matches standard library function divf4. + */ +static inline VmathSoaVector4 vmathSoaV4DivPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); + +/* + * Compute the reciprocal of a 4-D vector per element + * NOTE: + * Floating-point behavior matches standard library function recipf4. + */ +static inline VmathSoaVector4 vmathSoaV4RecipPerElem_V( VmathSoaVector4 vec ); + +/* + * Compute the square root of a 4-D vector per element + * NOTE: + * Floating-point behavior matches standard library function sqrtf4. + */ +static inline VmathSoaVector4 vmathSoaV4SqrtPerElem_V( VmathSoaVector4 vec ); + +/* + * Compute the reciprocal square root of a 4-D vector per element + * NOTE: + * Floating-point behavior matches standard library function rsqrtf4. + */ +static inline VmathSoaVector4 vmathSoaV4RsqrtPerElem_V( VmathSoaVector4 vec ); + +/* + * Compute the absolute value of a 4-D vector per element + */ +static inline VmathSoaVector4 vmathSoaV4AbsPerElem_V( VmathSoaVector4 vec ); + +/* + * Copy sign from one 4-D vector to another, per element + */ +static inline VmathSoaVector4 vmathSoaV4CopySignPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); + +/* + * Maximum of two 4-D vectors per element + */ +static inline VmathSoaVector4 vmathSoaV4MaxPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); + +/* + * Minimum of two 4-D vectors per element + */ +static inline VmathSoaVector4 vmathSoaV4MinPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); + +/* + * Maximum element of a 4-D vector + */ +static inline vec_float4 vmathSoaV4MaxElem_V( VmathSoaVector4 vec ); + +/* + * Minimum element of a 4-D vector + */ +static inline vec_float4 vmathSoaV4MinElem_V( VmathSoaVector4 vec ); + +/* + * Compute the sum of all elements of a 4-D vector + */ +static inline vec_float4 vmathSoaV4Sum_V( VmathSoaVector4 vec ); + +/* + * Compute the dot product of two 4-D vectors + */ +static inline vec_float4 vmathSoaV4Dot_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); + +/* + * Compute the square of the length of a 4-D vector + */ +static inline vec_float4 vmathSoaV4LengthSqr_V( VmathSoaVector4 vec ); + +/* + * Compute the length of a 4-D vector + */ +static inline vec_float4 vmathSoaV4Length_V( VmathSoaVector4 vec ); + +/* + * Normalize a 4-D vector + * NOTE: + * The result is unpredictable when all elements of vec are at or near zero. + */ +static inline VmathSoaVector4 vmathSoaV4Normalize_V( VmathSoaVector4 vec ); + +/* + * Outer product of two 4-D vectors + */ +static inline VmathSoaMatrix4 vmathSoaV4Outer_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); + +/* + * Linear interpolation between two 4-D vectors + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline VmathSoaVector4 vmathSoaV4Lerp_V( vec_float4 t, VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); + +/* + * Spherical linear interpolation between two 4-D vectors + * NOTE: + * The result is unpredictable if the vectors point in opposite directions. + * Does not clamp t between 0 and 1. + */ +static inline VmathSoaVector4 vmathSoaV4Slerp_V( vec_float4 t, VmathSoaVector4 unitVec0, VmathSoaVector4 unitVec1 ); + +/* + * Conditionally select between two 4-D vectors + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline VmathSoaVector4 vmathSoaV4Select_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1, vec_uint4 select1 ); + +/* + * Store four slots of an SoA 4-D vector as half-floats + */ +static inline void vmathSoaV4StoreHalfFloats_V( VmathSoaVector4 vec, vec_ushort8 *twoQuads ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 4-D vector + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaV4Print_V( VmathSoaVector4 vec ); + +/* + * Print a 4-D vector and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaV4Prints_V( VmathSoaVector4 vec, const char *name ); + +#endif + +/* + * Construct a 3-D point from x, y, and z elements + */ +static inline VmathSoaPoint3 vmathSoaP3MakeFromElems_V( vec_float4 x, vec_float4 y, vec_float4 z ); + +/* + * Copy elements from a 3-D vector into a 3-D point + */ +static inline VmathSoaPoint3 vmathSoaP3MakeFromV3_V( VmathSoaVector3 vec ); + +/* + * Set all elements of a 3-D point to the same scalar value + */ +static inline VmathSoaPoint3 vmathSoaP3MakeFromScalar_V( vec_float4 scalar ); + +/* + * Replicate an AoS 3-D point + */ +static inline VmathSoaPoint3 vmathSoaP3MakeFromAos_V( VmathPoint3 pnt ); + +/* + * Insert four AoS 3-D points + */ +static inline VmathSoaPoint3 vmathSoaP3MakeFrom4Aos_V( VmathPoint3 pnt0, VmathPoint3 pnt1, VmathPoint3 pnt2, VmathPoint3 pnt3 ); + +/* + * Extract four AoS 3-D points + */ +static inline void vmathSoaP3Get4Aos_V( VmathSoaPoint3 pnt, VmathPoint3 *result0, VmathPoint3 *result1, VmathPoint3 *result2, VmathPoint3 *result3 ); + +/* + * Set the x element of a 3-D point + */ +static inline void vmathSoaP3SetX_V( VmathSoaPoint3 *result, vec_float4 x ); + +/* + * Set the y element of a 3-D point + */ +static inline void vmathSoaP3SetY_V( VmathSoaPoint3 *result, vec_float4 y ); + +/* + * Set the z element of a 3-D point + */ +static inline void vmathSoaP3SetZ_V( VmathSoaPoint3 *result, vec_float4 z ); + +/* + * Get the x element of a 3-D point + */ +static inline vec_float4 vmathSoaP3GetX_V( VmathSoaPoint3 pnt ); + +/* + * Get the y element of a 3-D point + */ +static inline vec_float4 vmathSoaP3GetY_V( VmathSoaPoint3 pnt ); + +/* + * Get the z element of a 3-D point + */ +static inline vec_float4 vmathSoaP3GetZ_V( VmathSoaPoint3 pnt ); + +/* + * Set an x, y, or z element of a 3-D point by index + */ +static inline void vmathSoaP3SetElem_V( VmathSoaPoint3 *result, int idx, vec_float4 value ); + +/* + * Get an x, y, or z element of a 3-D point by index + */ +static inline vec_float4 vmathSoaP3GetElem_V( VmathSoaPoint3 pnt, int idx ); + +/* + * Subtract a 3-D point from another 3-D point + */ +static inline VmathSoaVector3 vmathSoaP3Sub_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ); + +/* + * Add a 3-D point to a 3-D vector + */ +static inline VmathSoaPoint3 vmathSoaP3AddV3_V( VmathSoaPoint3 pnt, VmathSoaVector3 vec ); + +/* + * Subtract a 3-D vector from a 3-D point + */ +static inline VmathSoaPoint3 vmathSoaP3SubV3_V( VmathSoaPoint3 pnt, VmathSoaVector3 vec ); + +/* + * Multiply two 3-D points per element + */ +static inline VmathSoaPoint3 vmathSoaP3MulPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ); + +/* + * Divide two 3-D points per element + * NOTE: + * Floating-point behavior matches standard library function divf4. + */ +static inline VmathSoaPoint3 vmathSoaP3DivPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ); + +/* + * Compute the reciprocal of a 3-D point per element + * NOTE: + * Floating-point behavior matches standard library function recipf4. + */ +static inline VmathSoaPoint3 vmathSoaP3RecipPerElem_V( VmathSoaPoint3 pnt ); + +/* + * Compute the square root of a 3-D point per element + * NOTE: + * Floating-point behavior matches standard library function sqrtf4. + */ +static inline VmathSoaPoint3 vmathSoaP3SqrtPerElem_V( VmathSoaPoint3 pnt ); + +/* + * Compute the reciprocal square root of a 3-D point per element + * NOTE: + * Floating-point behavior matches standard library function rsqrtf4. + */ +static inline VmathSoaPoint3 vmathSoaP3RsqrtPerElem_V( VmathSoaPoint3 pnt ); + +/* + * Compute the absolute value of a 3-D point per element + */ +static inline VmathSoaPoint3 vmathSoaP3AbsPerElem_V( VmathSoaPoint3 pnt ); + +/* + * Copy sign from one 3-D point to another, per element + */ +static inline VmathSoaPoint3 vmathSoaP3CopySignPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ); + +/* + * Maximum of two 3-D points per element + */ +static inline VmathSoaPoint3 vmathSoaP3MaxPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ); + +/* + * Minimum of two 3-D points per element + */ +static inline VmathSoaPoint3 vmathSoaP3MinPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ); + +/* + * Maximum element of a 3-D point + */ +static inline vec_float4 vmathSoaP3MaxElem_V( VmathSoaPoint3 pnt ); + +/* + * Minimum element of a 3-D point + */ +static inline vec_float4 vmathSoaP3MinElem_V( VmathSoaPoint3 pnt ); + +/* + * Compute the sum of all elements of a 3-D point + */ +static inline vec_float4 vmathSoaP3Sum_V( VmathSoaPoint3 pnt ); + +/* + * Apply uniform scale to a 3-D point + */ +static inline VmathSoaPoint3 vmathSoaP3Scale_V( VmathSoaPoint3 pnt, vec_float4 scaleVal ); + +/* + * Apply non-uniform scale to a 3-D point + */ +static inline VmathSoaPoint3 vmathSoaP3NonUniformScale_V( VmathSoaPoint3 pnt, VmathSoaVector3 scaleVec ); + +/* + * Scalar projection of a 3-D point on a unit-length 3-D vector + */ +static inline vec_float4 vmathSoaP3Projection_V( VmathSoaPoint3 pnt, VmathSoaVector3 unitVec ); + +/* + * Compute the square of the distance of a 3-D point from the coordinate-system origin + */ +static inline vec_float4 vmathSoaP3DistSqrFromOrigin_V( VmathSoaPoint3 pnt ); + +/* + * Compute the distance of a 3-D point from the coordinate-system origin + */ +static inline vec_float4 vmathSoaP3DistFromOrigin_V( VmathSoaPoint3 pnt ); + +/* + * Compute the square of the distance between two 3-D points + */ +static inline vec_float4 vmathSoaP3DistSqr_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ); + +/* + * Compute the distance between two 3-D points + */ +static inline vec_float4 vmathSoaP3Dist_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ); + +/* + * Linear interpolation between two 3-D points + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline VmathSoaPoint3 vmathSoaP3Lerp_V( vec_float4 t, VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ); + +/* + * Conditionally select between two 3-D points + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline VmathSoaPoint3 vmathSoaP3Select_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1, vec_uint4 select1 ); + +/* + * Load four three-float 3-D points, stored in three quadwords + */ +static inline void vmathSoaP3LoadXYZArray_V( VmathSoaPoint3 *pnt, const vec_float4 *threeQuads ); + +/* + * Store four slots of an SoA 3-D point in three quadwords + */ +static inline void vmathSoaP3StoreXYZArray_V( VmathSoaPoint3 pnt, vec_float4 *threeQuads ); + +/* + * Store eight slots of two SoA 3-D points as half-floats + */ +static inline void vmathSoaP3StoreHalfFloats_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1, vec_ushort8 *threeQuads ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3-D point + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaP3Print_V( VmathSoaPoint3 pnt ); + +/* + * Print a 3-D point and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaP3Prints_V( VmathSoaPoint3 pnt, const char *name ); + +#endif + +/* + * Construct a quaternion from x, y, z, and w elements + */ +static inline VmathSoaQuat vmathSoaQMakeFromElems_V( vec_float4 x, vec_float4 y, vec_float4 z, vec_float4 w ); + +/* + * Construct a quaternion from a 3-D vector and a scalar + */ +static inline VmathSoaQuat vmathSoaQMakeFromV3Scalar_V( VmathSoaVector3 xyz, vec_float4 w ); + +/* + * Copy elements from a 4-D vector into a quaternion + */ +static inline VmathSoaQuat vmathSoaQMakeFromV4_V( VmathSoaVector4 vec ); + +/* + * Convert a rotation matrix to a unit-length quaternion + */ +static inline VmathSoaQuat vmathSoaQMakeFromM3_V( VmathSoaMatrix3 rotMat ); + +/* + * Set all elements of a quaternion to the same scalar value + */ +static inline VmathSoaQuat vmathSoaQMakeFromScalar_V( vec_float4 scalar ); + +/* + * Replicate an AoS quaternion + */ +static inline VmathSoaQuat vmathSoaQMakeFromAos_V( VmathQuat quat ); + +/* + * Insert four AoS quaternions + */ +static inline VmathSoaQuat vmathSoaQMakeFrom4Aos_V( VmathQuat quat0, VmathQuat quat1, VmathQuat quat2, VmathQuat quat3 ); + +/* + * Extract four AoS quaternions + */ +static inline void vmathSoaQGet4Aos_V( VmathSoaQuat quat, VmathQuat *result0, VmathQuat *result1, VmathQuat *result2, VmathQuat *result3 ); + +/* + * Set the x, y, and z elements of a quaternion + * NOTE: + * This function does not change the w element. + */ +static inline void vmathSoaQSetXYZ_V( VmathSoaQuat *result, VmathSoaVector3 vec ); + +/* + * Get the x, y, and z elements of a quaternion + */ +static inline VmathSoaVector3 vmathSoaQGetXYZ_V( VmathSoaQuat quat ); + +/* + * Set the x element of a quaternion + */ +static inline void vmathSoaQSetX_V( VmathSoaQuat *result, vec_float4 x ); + +/* + * Set the y element of a quaternion + */ +static inline void vmathSoaQSetY_V( VmathSoaQuat *result, vec_float4 y ); + +/* + * Set the z element of a quaternion + */ +static inline void vmathSoaQSetZ_V( VmathSoaQuat *result, vec_float4 z ); + +/* + * Set the w element of a quaternion + */ +static inline void vmathSoaQSetW_V( VmathSoaQuat *result, vec_float4 w ); + +/* + * Get the x element of a quaternion + */ +static inline vec_float4 vmathSoaQGetX_V( VmathSoaQuat quat ); + +/* + * Get the y element of a quaternion + */ +static inline vec_float4 vmathSoaQGetY_V( VmathSoaQuat quat ); + +/* + * Get the z element of a quaternion + */ +static inline vec_float4 vmathSoaQGetZ_V( VmathSoaQuat quat ); + +/* + * Get the w element of a quaternion + */ +static inline vec_float4 vmathSoaQGetW_V( VmathSoaQuat quat ); + +/* + * Set an x, y, z, or w element of a quaternion by index + */ +static inline void vmathSoaQSetElem_V( VmathSoaQuat *result, int idx, vec_float4 value ); + +/* + * Get an x, y, z, or w element of a quaternion by index + */ +static inline vec_float4 vmathSoaQGetElem_V( VmathSoaQuat quat, int idx ); + +/* + * Add two quaternions + */ +static inline VmathSoaQuat vmathSoaQAdd_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ); + +/* + * Subtract a quaternion from another quaternion + */ +static inline VmathSoaQuat vmathSoaQSub_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ); + +/* + * Multiply two quaternions + */ +static inline VmathSoaQuat vmathSoaQMul_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ); + +/* + * Multiply a quaternion by a scalar + */ +static inline VmathSoaQuat vmathSoaQScalarMul_V( VmathSoaQuat quat, vec_float4 scalar ); + +/* + * Divide a quaternion by a scalar + */ +static inline VmathSoaQuat vmathSoaQScalarDiv_V( VmathSoaQuat quat, vec_float4 scalar ); + +/* + * Negate all elements of a quaternion + */ +static inline VmathSoaQuat vmathSoaQNeg_V( VmathSoaQuat quat ); + +/* + * Construct an identity quaternion + */ +static inline VmathSoaQuat vmathSoaQMakeIdentity_V( ); + +/* + * Construct a quaternion to rotate between two unit-length 3-D vectors + * NOTE: + * The result is unpredictable if unitVec0 and unitVec1 point in opposite directions. + */ +static inline VmathSoaQuat vmathSoaQMakeRotationArc_V( VmathSoaVector3 unitVec0, VmathSoaVector3 unitVec1 ); + +/* + * Construct a quaternion to rotate around a unit-length 3-D vector + */ +static inline VmathSoaQuat vmathSoaQMakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec ); + +/* + * Construct a quaternion to rotate around the x axis + */ +static inline VmathSoaQuat vmathSoaQMakeRotationX_V( vec_float4 radians ); + +/* + * Construct a quaternion to rotate around the y axis + */ +static inline VmathSoaQuat vmathSoaQMakeRotationY_V( vec_float4 radians ); + +/* + * Construct a quaternion to rotate around the z axis + */ +static inline VmathSoaQuat vmathSoaQMakeRotationZ_V( vec_float4 radians ); + +/* + * Compute the conjugate of a quaternion + */ +static inline VmathSoaQuat vmathSoaQConj_V( VmathSoaQuat quat ); + +/* + * Use a unit-length quaternion to rotate a 3-D vector + */ +static inline VmathSoaVector3 vmathSoaQRotate_V( VmathSoaQuat unitQuat, VmathSoaVector3 vec ); + +/* + * Compute the dot product of two quaternions + */ +static inline vec_float4 vmathSoaQDot_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ); + +/* + * Compute the norm of a quaternion + */ +static inline vec_float4 vmathSoaQNorm_V( VmathSoaQuat quat ); + +/* + * Compute the length of a quaternion + */ +static inline vec_float4 vmathSoaQLength_V( VmathSoaQuat quat ); + +/* + * Normalize a quaternion + * NOTE: + * The result is unpredictable when all elements of quat are at or near zero. + */ +static inline VmathSoaQuat vmathSoaQNormalize_V( VmathSoaQuat quat ); + +/* + * Linear interpolation between two quaternions + * NOTE: + * Does not clamp t between 0 and 1. + */ +static inline VmathSoaQuat vmathSoaQLerp_V( vec_float4 t, VmathSoaQuat quat0, VmathSoaQuat quat1 ); + +/* + * Spherical linear interpolation between two quaternions + * NOTE: + * Interpolates along the shortest path between orientations. + * Does not clamp t between 0 and 1. + */ +static inline VmathSoaQuat vmathSoaQSlerp_V( vec_float4 t, VmathSoaQuat unitQuat0, VmathSoaQuat unitQuat1 ); + +/* + * Spherical quadrangle interpolation + */ +static inline VmathSoaQuat vmathSoaQSquad_V( vec_float4 t, VmathSoaQuat unitQuat0, VmathSoaQuat unitQuat1, VmathSoaQuat unitQuat2, VmathSoaQuat unitQuat3 ); + +/* + * Conditionally select between two quaternions + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline VmathSoaQuat vmathSoaQSelect_V( VmathSoaQuat quat0, VmathSoaQuat quat1, vec_uint4 select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a quaternion + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaQPrint_V( VmathSoaQuat quat ); + +/* + * Print a quaternion and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaQPrints_V( VmathSoaQuat quat, const char *name ); + +#endif + +/* + * Construct a 3x3 matrix containing the specified columns + */ +static inline VmathSoaMatrix3 vmathSoaM3MakeFromCols_V( VmathSoaVector3 col0, VmathSoaVector3 col1, VmathSoaVector3 col2 ); + +/* + * Construct a 3x3 rotation matrix from a unit-length quaternion + */ +static inline VmathSoaMatrix3 vmathSoaM3MakeFromQ_V( VmathSoaQuat unitQuat ); + +/* + * Set all elements of a 3x3 matrix to the same scalar value + */ +static inline VmathSoaMatrix3 vmathSoaM3MakeFromScalar_V( vec_float4 scalar ); + +/* + * Replicate an AoS 3x3 matrix + */ +static inline VmathSoaMatrix3 vmathSoaM3MakeFromAos_V( VmathMatrix3 mat ); + +/* + * Insert four AoS 3x3 matrices + */ +static inline VmathSoaMatrix3 vmathSoaM3MakeFrom4Aos_V( VmathMatrix3 mat0, VmathMatrix3 mat1, VmathMatrix3 mat2, VmathMatrix3 mat3 ); + +/* + * Extract four AoS 3x3 matrices + */ +static inline void vmathSoaM3Get4Aos_V( VmathSoaMatrix3 mat, VmathMatrix3 *result0, VmathMatrix3 *result1, VmathMatrix3 *result2, VmathMatrix3 *result3 ); + +/* + * Set column 0 of a 3x3 matrix + */ +static inline void vmathSoaM3SetCol0_V( VmathSoaMatrix3 *result, VmathSoaVector3 col0 ); + +/* + * Set column 1 of a 3x3 matrix + */ +static inline void vmathSoaM3SetCol1_V( VmathSoaMatrix3 *result, VmathSoaVector3 col1 ); + +/* + * Set column 2 of a 3x3 matrix + */ +static inline void vmathSoaM3SetCol2_V( VmathSoaMatrix3 *result, VmathSoaVector3 col2 ); + +/* + * Get column 0 of a 3x3 matrix + */ +static inline VmathSoaVector3 vmathSoaM3GetCol0_V( VmathSoaMatrix3 mat ); + +/* + * Get column 1 of a 3x3 matrix + */ +static inline VmathSoaVector3 vmathSoaM3GetCol1_V( VmathSoaMatrix3 mat ); + +/* + * Get column 2 of a 3x3 matrix + */ +static inline VmathSoaVector3 vmathSoaM3GetCol2_V( VmathSoaMatrix3 mat ); + +/* + * Set the column of a 3x3 matrix referred to by the specified index + */ +static inline void vmathSoaM3SetCol_V( VmathSoaMatrix3 *result, int col, VmathSoaVector3 vec ); + +/* + * Set the row of a 3x3 matrix referred to by the specified index + */ +static inline void vmathSoaM3SetRow_V( VmathSoaMatrix3 *result, int row, VmathSoaVector3 vec ); + +/* + * Get the column of a 3x3 matrix referred to by the specified index + */ +static inline VmathSoaVector3 vmathSoaM3GetCol_V( VmathSoaMatrix3 mat, int col ); + +/* + * Get the row of a 3x3 matrix referred to by the specified index + */ +static inline VmathSoaVector3 vmathSoaM3GetRow_V( VmathSoaMatrix3 mat, int row ); + +/* + * Set the element of a 3x3 matrix referred to by column and row indices + */ +static inline void vmathSoaM3SetElem_V( VmathSoaMatrix3 *result, int col, int row, vec_float4 val ); + +/* + * Get the element of a 3x3 matrix referred to by column and row indices + */ +static inline vec_float4 vmathSoaM3GetElem_V( VmathSoaMatrix3 mat, int col, int row ); + +/* + * Add two 3x3 matrices + */ +static inline VmathSoaMatrix3 vmathSoaM3Add_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1 ); + +/* + * Subtract a 3x3 matrix from another 3x3 matrix + */ +static inline VmathSoaMatrix3 vmathSoaM3Sub_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1 ); + +/* + * Negate all elements of a 3x3 matrix + */ +static inline VmathSoaMatrix3 vmathSoaM3Neg_V( VmathSoaMatrix3 mat ); + +/* + * Multiply a 3x3 matrix by a scalar + */ +static inline VmathSoaMatrix3 vmathSoaM3ScalarMul_V( VmathSoaMatrix3 mat, vec_float4 scalar ); + +/* + * Multiply a 3x3 matrix by a 3-D vector + */ +static inline VmathSoaVector3 vmathSoaM3MulV3_V( VmathSoaMatrix3 mat, VmathSoaVector3 vec ); + +/* + * Multiply two 3x3 matrices + */ +static inline VmathSoaMatrix3 vmathSoaM3Mul_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1 ); + +/* + * Construct an identity 3x3 matrix + */ +static inline VmathSoaMatrix3 vmathSoaM3MakeIdentity_V( ); + +/* + * Construct a 3x3 matrix to rotate around the x axis + */ +static inline VmathSoaMatrix3 vmathSoaM3MakeRotationX_V( vec_float4 radians ); + +/* + * Construct a 3x3 matrix to rotate around the y axis + */ +static inline VmathSoaMatrix3 vmathSoaM3MakeRotationY_V( vec_float4 radians ); + +/* + * Construct a 3x3 matrix to rotate around the z axis + */ +static inline VmathSoaMatrix3 vmathSoaM3MakeRotationZ_V( vec_float4 radians ); + +/* + * Construct a 3x3 matrix to rotate around the x, y, and z axes + */ +static inline VmathSoaMatrix3 vmathSoaM3MakeRotationZYX_V( VmathSoaVector3 radiansXYZ ); + +/* + * Construct a 3x3 matrix to rotate around a unit-length 3-D vector + */ +static inline VmathSoaMatrix3 vmathSoaM3MakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec ); + +/* + * Construct a rotation matrix from a unit-length quaternion + */ +static inline VmathSoaMatrix3 vmathSoaM3MakeRotationQ_V( VmathSoaQuat unitQuat ); + +/* + * Construct a 3x3 matrix to perform scaling + */ +static inline VmathSoaMatrix3 vmathSoaM3MakeScale_V( VmathSoaVector3 scaleVec ); + +/* + * Append (post-multiply) a scale transformation to a 3x3 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline VmathSoaMatrix3 vmathSoaM3AppendScale_V( VmathSoaMatrix3 mat, VmathSoaVector3 scaleVec ); + +/* + * Prepend (pre-multiply) a scale transformation to a 3x3 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline VmathSoaMatrix3 vmathSoaM3PrependScale_V( VmathSoaVector3 scaleVec, VmathSoaMatrix3 mat ); + +/* + * Multiply two 3x3 matrices per element + */ +static inline VmathSoaMatrix3 vmathSoaM3MulPerElem_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1 ); + +/* + * Compute the absolute value of a 3x3 matrix per element + */ +static inline VmathSoaMatrix3 vmathSoaM3AbsPerElem_V( VmathSoaMatrix3 mat ); + +/* + * Transpose of a 3x3 matrix + */ +static inline VmathSoaMatrix3 vmathSoaM3Transpose_V( VmathSoaMatrix3 mat ); + +/* + * Compute the inverse of a 3x3 matrix + * NOTE: + * Result is unpredictable when the determinant of mat is equal to or near 0. + */ +static inline VmathSoaMatrix3 vmathSoaM3Inverse_V( VmathSoaMatrix3 mat ); + +/* + * Determinant of a 3x3 matrix + */ +static inline vec_float4 vmathSoaM3Determinant_V( VmathSoaMatrix3 mat ); + +/* + * Conditionally select between two 3x3 matrices + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline VmathSoaMatrix3 vmathSoaM3Select_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1, vec_uint4 select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3x3 matrix + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaM3Print_V( VmathSoaMatrix3 mat ); + +/* + * Print a 3x3 matrix and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaM3Prints_V( VmathSoaMatrix3 mat, const char *name ); + +#endif + +/* + * Construct a 4x4 matrix containing the specified columns + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeFromCols_V( VmathSoaVector4 col0, VmathSoaVector4 col1, VmathSoaVector4 col2, VmathSoaVector4 col3 ); + +/* + * Construct a 4x4 matrix from a 3x4 transformation matrix + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeFromT3_V( VmathSoaTransform3 mat ); + +/* + * Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeFromM3V3_V( VmathSoaMatrix3 mat, VmathSoaVector3 translateVec ); + +/* + * Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeFromQV3_V( VmathSoaQuat unitQuat, VmathSoaVector3 translateVec ); + +/* + * Set all elements of a 4x4 matrix to the same scalar value + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeFromScalar_V( vec_float4 scalar ); + +/* + * Replicate an AoS 4x4 matrix + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeFromAos_V( VmathMatrix4 mat ); + +/* + * Insert four AoS 4x4 matrices + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeFrom4Aos_V( VmathMatrix4 mat0, VmathMatrix4 mat1, VmathMatrix4 mat2, VmathMatrix4 mat3 ); + +/* + * Extract four AoS 4x4 matrices + */ +static inline void vmathSoaM4Get4Aos_V( VmathSoaMatrix4 mat, VmathMatrix4 *result0, VmathMatrix4 *result1, VmathMatrix4 *result2, VmathMatrix4 *result3 ); + +/* + * Set the upper-left 3x3 submatrix + * NOTE: + * This function does not change the bottom row elements. + */ +static inline void vmathSoaM4SetUpper3x3_V( VmathSoaMatrix4 *result, VmathSoaMatrix3 mat3 ); + +/* + * Get the upper-left 3x3 submatrix of a 4x4 matrix + */ +static inline VmathSoaMatrix3 vmathSoaM4GetUpper3x3_V( VmathSoaMatrix4 mat ); + +/* + * Set translation component + * NOTE: + * This function does not change the bottom row elements. + */ +static inline void vmathSoaM4SetTranslation_V( VmathSoaMatrix4 *result, VmathSoaVector3 translateVec ); + +/* + * Get the translation component of a 4x4 matrix + */ +static inline VmathSoaVector3 vmathSoaM4GetTranslation_V( VmathSoaMatrix4 mat ); + +/* + * Set column 0 of a 4x4 matrix + */ +static inline void vmathSoaM4SetCol0_V( VmathSoaMatrix4 *result, VmathSoaVector4 col0 ); + +/* + * Set column 1 of a 4x4 matrix + */ +static inline void vmathSoaM4SetCol1_V( VmathSoaMatrix4 *result, VmathSoaVector4 col1 ); + +/* + * Set column 2 of a 4x4 matrix + */ +static inline void vmathSoaM4SetCol2_V( VmathSoaMatrix4 *result, VmathSoaVector4 col2 ); + +/* + * Set column 3 of a 4x4 matrix + */ +static inline void vmathSoaM4SetCol3_V( VmathSoaMatrix4 *result, VmathSoaVector4 col3 ); + +/* + * Get column 0 of a 4x4 matrix + */ +static inline VmathSoaVector4 vmathSoaM4GetCol0_V( VmathSoaMatrix4 mat ); + +/* + * Get column 1 of a 4x4 matrix + */ +static inline VmathSoaVector4 vmathSoaM4GetCol1_V( VmathSoaMatrix4 mat ); + +/* + * Get column 2 of a 4x4 matrix + */ +static inline VmathSoaVector4 vmathSoaM4GetCol2_V( VmathSoaMatrix4 mat ); + +/* + * Get column 3 of a 4x4 matrix + */ +static inline VmathSoaVector4 vmathSoaM4GetCol3_V( VmathSoaMatrix4 mat ); + +/* + * Set the column of a 4x4 matrix referred to by the specified index + */ +static inline void vmathSoaM4SetCol_V( VmathSoaMatrix4 *result, int col, VmathSoaVector4 vec ); + +/* + * Set the row of a 4x4 matrix referred to by the specified index + */ +static inline void vmathSoaM4SetRow_V( VmathSoaMatrix4 *result, int row, VmathSoaVector4 vec ); + +/* + * Get the column of a 4x4 matrix referred to by the specified index + */ +static inline VmathSoaVector4 vmathSoaM4GetCol_V( VmathSoaMatrix4 mat, int col ); + +/* + * Get the row of a 4x4 matrix referred to by the specified index + */ +static inline VmathSoaVector4 vmathSoaM4GetRow_V( VmathSoaMatrix4 mat, int row ); + +/* + * Set the element of a 4x4 matrix referred to by column and row indices + */ +static inline void vmathSoaM4SetElem_V( VmathSoaMatrix4 *result, int col, int row, vec_float4 val ); + +/* + * Get the element of a 4x4 matrix referred to by column and row indices + */ +static inline vec_float4 vmathSoaM4GetElem_V( VmathSoaMatrix4 mat, int col, int row ); + +/* + * Add two 4x4 matrices + */ +static inline VmathSoaMatrix4 vmathSoaM4Add_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1 ); + +/* + * Subtract a 4x4 matrix from another 4x4 matrix + */ +static inline VmathSoaMatrix4 vmathSoaM4Sub_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1 ); + +/* + * Negate all elements of a 4x4 matrix + */ +static inline VmathSoaMatrix4 vmathSoaM4Neg_V( VmathSoaMatrix4 mat ); + +/* + * Multiply a 4x4 matrix by a scalar + */ +static inline VmathSoaMatrix4 vmathSoaM4ScalarMul_V( VmathSoaMatrix4 mat, vec_float4 scalar ); + +/* + * Multiply a 4x4 matrix by a 4-D vector + */ +static inline VmathSoaVector4 vmathSoaM4MulV4_V( VmathSoaMatrix4 mat, VmathSoaVector4 vec ); + +/* + * Multiply a 4x4 matrix by a 3-D vector + */ +static inline VmathSoaVector4 vmathSoaM4MulV3_V( VmathSoaMatrix4 mat, VmathSoaVector3 vec ); + +/* + * Multiply a 4x4 matrix by a 3-D point + */ +static inline VmathSoaVector4 vmathSoaM4MulP3_V( VmathSoaMatrix4 mat, VmathSoaPoint3 pnt ); + +/* + * Multiply two 4x4 matrices + */ +static inline VmathSoaMatrix4 vmathSoaM4Mul_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1 ); + +/* + * Multiply a 4x4 matrix by a 3x4 transformation matrix + */ +static inline VmathSoaMatrix4 vmathSoaM4MulT3_V( VmathSoaMatrix4 mat, VmathSoaTransform3 tfrm ); + +/* + * Construct an identity 4x4 matrix + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeIdentity_V( ); + +/* + * Construct a 4x4 matrix to rotate around the x axis + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeRotationX_V( vec_float4 radians ); + +/* + * Construct a 4x4 matrix to rotate around the y axis + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeRotationY_V( vec_float4 radians ); + +/* + * Construct a 4x4 matrix to rotate around the z axis + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeRotationZ_V( vec_float4 radians ); + +/* + * Construct a 4x4 matrix to rotate around the x, y, and z axes + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeRotationZYX_V( VmathSoaVector3 radiansXYZ ); + +/* + * Construct a 4x4 matrix to rotate around a unit-length 3-D vector + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec ); + +/* + * Construct a rotation matrix from a unit-length quaternion + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeRotationQ_V( VmathSoaQuat unitQuat ); + +/* + * Construct a 4x4 matrix to perform scaling + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeScale_V( VmathSoaVector3 scaleVec ); + +/* + * Construct a 4x4 matrix to perform translation + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeTranslation_V( VmathSoaVector3 translateVec ); + +/* + * Construct viewing matrix based on eye position, position looked at, and up direction + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeLookAt_V( VmathSoaPoint3 eyePos, VmathSoaPoint3 lookAtPos, VmathSoaVector3 upVec ); + +/* + * Construct a perspective projection matrix + */ +static inline VmathSoaMatrix4 vmathSoaM4MakePerspective_V( vec_float4 fovyRadians, vec_float4 aspect, vec_float4 zNear, vec_float4 zFar ); + +/* + * Construct a perspective projection matrix based on frustum + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeFrustum_V( vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ); + +/* + * Construct an orthographic projection matrix + */ +static inline VmathSoaMatrix4 vmathSoaM4MakeOrthographic_V( vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ); + +/* + * Append (post-multiply) a scale transformation to a 4x4 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline VmathSoaMatrix4 vmathSoaM4AppendScale_V( VmathSoaMatrix4 mat, VmathSoaVector3 scaleVec ); + +/* + * Prepend (pre-multiply) a scale transformation to a 4x4 matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline VmathSoaMatrix4 vmathSoaM4PrependScale_V( VmathSoaVector3 scaleVec, VmathSoaMatrix4 mat ); + +/* + * Multiply two 4x4 matrices per element + */ +static inline VmathSoaMatrix4 vmathSoaM4MulPerElem_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1 ); + +/* + * Compute the absolute value of a 4x4 matrix per element + */ +static inline VmathSoaMatrix4 vmathSoaM4AbsPerElem_V( VmathSoaMatrix4 mat ); + +/* + * Transpose of a 4x4 matrix + */ +static inline VmathSoaMatrix4 vmathSoaM4Transpose_V( VmathSoaMatrix4 mat ); + +/* + * Compute the inverse of a 4x4 matrix + * NOTE: + * Result is unpredictable when the determinant of mat is equal to or near 0. + */ +static inline VmathSoaMatrix4 vmathSoaM4Inverse_V( VmathSoaMatrix4 mat ); + +/* + * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix + * NOTE: + * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. The result is unpredictable when the determinant of mat is equal to or near 0. + */ +static inline VmathSoaMatrix4 vmathSoaM4AffineInverse_V( VmathSoaMatrix4 mat ); + +/* + * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix + * NOTE: + * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. + */ +static inline VmathSoaMatrix4 vmathSoaM4OrthoInverse_V( VmathSoaMatrix4 mat ); + +/* + * Determinant of a 4x4 matrix + */ +static inline vec_float4 vmathSoaM4Determinant_V( VmathSoaMatrix4 mat ); + +/* + * Conditionally select between two 4x4 matrices + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline VmathSoaMatrix4 vmathSoaM4Select_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1, vec_uint4 select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 4x4 matrix + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaM4Print_V( VmathSoaMatrix4 mat ); + +/* + * Print a 4x4 matrix and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaM4Prints_V( VmathSoaMatrix4 mat, const char *name ); + +#endif + +/* + * Construct a 3x4 transformation matrix containing the specified columns + */ +static inline VmathSoaTransform3 vmathSoaT3MakeFromCols_V( VmathSoaVector3 col0, VmathSoaVector3 col1, VmathSoaVector3 col2, VmathSoaVector3 col3 ); + +/* + * Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector + */ +static inline VmathSoaTransform3 vmathSoaT3MakeFromM3V3_V( VmathSoaMatrix3 tfrm, VmathSoaVector3 translateVec ); + +/* + * Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector + */ +static inline VmathSoaTransform3 vmathSoaT3MakeFromQV3_V( VmathSoaQuat unitQuat, VmathSoaVector3 translateVec ); + +/* + * Set all elements of a 3x4 transformation matrix to the same scalar value + */ +static inline VmathSoaTransform3 vmathSoaT3MakeFromScalar_V( vec_float4 scalar ); + +/* + * Replicate an AoS 3x4 transformation matrix + */ +static inline VmathSoaTransform3 vmathSoaT3MakeFromAos_V( VmathTransform3 tfrm ); + +/* + * Insert four AoS 3x4 transformation matrices + */ +static inline VmathSoaTransform3 vmathSoaT3MakeFrom4Aos_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1, VmathTransform3 tfrm2, VmathTransform3 tfrm3 ); + +/* + * Extract four AoS 3x4 transformation matrices + */ +static inline void vmathSoaT3Get4Aos_V( VmathSoaTransform3 tfrm, VmathTransform3 *result0, VmathTransform3 *result1, VmathTransform3 *result2, VmathTransform3 *result3 ); + +/* + * Set the upper-left 3x3 submatrix + */ +static inline void vmathSoaT3SetUpper3x3_V( VmathSoaTransform3 *result, VmathSoaMatrix3 mat3 ); + +/* + * Get the upper-left 3x3 submatrix of a 3x4 transformation matrix + */ +static inline VmathSoaMatrix3 vmathSoaT3GetUpper3x3_V( VmathSoaTransform3 tfrm ); + +/* + * Set translation component + */ +static inline void vmathSoaT3SetTranslation_V( VmathSoaTransform3 *result, VmathSoaVector3 translateVec ); + +/* + * Get the translation component of a 3x4 transformation matrix + */ +static inline VmathSoaVector3 vmathSoaT3GetTranslation_V( VmathSoaTransform3 tfrm ); + +/* + * Set column 0 of a 3x4 transformation matrix + */ +static inline void vmathSoaT3SetCol0_V( VmathSoaTransform3 *result, VmathSoaVector3 col0 ); + +/* + * Set column 1 of a 3x4 transformation matrix + */ +static inline void vmathSoaT3SetCol1_V( VmathSoaTransform3 *result, VmathSoaVector3 col1 ); + +/* + * Set column 2 of a 3x4 transformation matrix + */ +static inline void vmathSoaT3SetCol2_V( VmathSoaTransform3 *result, VmathSoaVector3 col2 ); + +/* + * Set column 3 of a 3x4 transformation matrix + */ +static inline void vmathSoaT3SetCol3_V( VmathSoaTransform3 *result, VmathSoaVector3 col3 ); + +/* + * Get column 0 of a 3x4 transformation matrix + */ +static inline VmathSoaVector3 vmathSoaT3GetCol0_V( VmathSoaTransform3 tfrm ); + +/* + * Get column 1 of a 3x4 transformation matrix + */ +static inline VmathSoaVector3 vmathSoaT3GetCol1_V( VmathSoaTransform3 tfrm ); + +/* + * Get column 2 of a 3x4 transformation matrix + */ +static inline VmathSoaVector3 vmathSoaT3GetCol2_V( VmathSoaTransform3 tfrm ); + +/* + * Get column 3 of a 3x4 transformation matrix + */ +static inline VmathSoaVector3 vmathSoaT3GetCol3_V( VmathSoaTransform3 tfrm ); + +/* + * Set the column of a 3x4 transformation matrix referred to by the specified index + */ +static inline void vmathSoaT3SetCol_V( VmathSoaTransform3 *result, int col, VmathSoaVector3 vec ); + +/* + * Set the row of a 3x4 transformation matrix referred to by the specified index + */ +static inline void vmathSoaT3SetRow_V( VmathSoaTransform3 *result, int row, VmathSoaVector4 vec ); + +/* + * Get the column of a 3x4 transformation matrix referred to by the specified index + */ +static inline VmathSoaVector3 vmathSoaT3GetCol_V( VmathSoaTransform3 tfrm, int col ); + +/* + * Get the row of a 3x4 transformation matrix referred to by the specified index + */ +static inline VmathSoaVector4 vmathSoaT3GetRow_V( VmathSoaTransform3 tfrm, int row ); + +/* + * Set the element of a 3x4 transformation matrix referred to by column and row indices + */ +static inline void vmathSoaT3SetElem_V( VmathSoaTransform3 *result, int col, int row, vec_float4 val ); + +/* + * Get the element of a 3x4 transformation matrix referred to by column and row indices + */ +static inline vec_float4 vmathSoaT3GetElem_V( VmathSoaTransform3 tfrm, int col, int row ); + +/* + * Multiply a 3x4 transformation matrix by a 3-D vector + */ +static inline VmathSoaVector3 vmathSoaT3MulV3_V( VmathSoaTransform3 tfrm, VmathSoaVector3 vec ); + +/* + * Multiply a 3x4 transformation matrix by a 3-D point + */ +static inline VmathSoaPoint3 vmathSoaT3MulP3_V( VmathSoaTransform3 tfrm, VmathSoaPoint3 pnt ); + +/* + * Multiply two 3x4 transformation matrices + */ +static inline VmathSoaTransform3 vmathSoaT3Mul_V( VmathSoaTransform3 tfrm0, VmathSoaTransform3 tfrm1 ); + +/* + * Construct an identity 3x4 transformation matrix + */ +static inline VmathSoaTransform3 vmathSoaT3MakeIdentity_V( ); + +/* + * Construct a 3x4 transformation matrix to rotate around the x axis + */ +static inline VmathSoaTransform3 vmathSoaT3MakeRotationX_V( vec_float4 radians ); + +/* + * Construct a 3x4 transformation matrix to rotate around the y axis + */ +static inline VmathSoaTransform3 vmathSoaT3MakeRotationY_V( vec_float4 radians ); + +/* + * Construct a 3x4 transformation matrix to rotate around the z axis + */ +static inline VmathSoaTransform3 vmathSoaT3MakeRotationZ_V( vec_float4 radians ); + +/* + * Construct a 3x4 transformation matrix to rotate around the x, y, and z axes + */ +static inline VmathSoaTransform3 vmathSoaT3MakeRotationZYX_V( VmathSoaVector3 radiansXYZ ); + +/* + * Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector + */ +static inline VmathSoaTransform3 vmathSoaT3MakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec ); + +/* + * Construct a rotation matrix from a unit-length quaternion + */ +static inline VmathSoaTransform3 vmathSoaT3MakeRotationQ_V( VmathSoaQuat unitQuat ); + +/* + * Construct a 3x4 transformation matrix to perform scaling + */ +static inline VmathSoaTransform3 vmathSoaT3MakeScale_V( VmathSoaVector3 scaleVec ); + +/* + * Construct a 3x4 transformation matrix to perform translation + */ +static inline VmathSoaTransform3 vmathSoaT3MakeTranslation_V( VmathSoaVector3 translateVec ); + +/* + * Append (post-multiply) a scale transformation to a 3x4 transformation matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline VmathSoaTransform3 vmathSoaT3AppendScale_V( VmathSoaTransform3 tfrm, VmathSoaVector3 scaleVec ); + +/* + * Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix + * NOTE: + * Faster than creating and multiplying a scale transformation matrix. + */ +static inline VmathSoaTransform3 vmathSoaT3PrependScale_V( VmathSoaVector3 scaleVec, VmathSoaTransform3 tfrm ); + +/* + * Multiply two 3x4 transformation matrices per element + */ +static inline VmathSoaTransform3 vmathSoaT3MulPerElem_V( VmathSoaTransform3 tfrm0, VmathSoaTransform3 tfrm1 ); + +/* + * Compute the absolute value of a 3x4 transformation matrix per element + */ +static inline VmathSoaTransform3 vmathSoaT3AbsPerElem_V( VmathSoaTransform3 tfrm ); + +/* + * Inverse of a 3x4 transformation matrix + * NOTE: + * Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0. + */ +static inline VmathSoaTransform3 vmathSoaT3Inverse_V( VmathSoaTransform3 tfrm ); + +/* + * Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix + * NOTE: + * This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions. + */ +static inline VmathSoaTransform3 vmathSoaT3OrthoInverse_V( VmathSoaTransform3 tfrm ); + +/* + * Conditionally select between two 3x4 transformation matrices + * NOTE: + * This function uses a conditional select instruction to avoid a branch. + */ +static inline VmathSoaTransform3 vmathSoaT3Select_V( VmathSoaTransform3 tfrm0, VmathSoaTransform3 tfrm1, vec_uint4 select1 ); + +#ifdef _VECTORMATH_DEBUG + +/* + * Print a 3x4 transformation matrix + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaT3Print_V( VmathSoaTransform3 tfrm ); + +/* + * Print a 3x4 transformation matrix and an associated string identifier + * NOTE: + * Function is only defined when _VECTORMATH_DEBUG is defined. + */ +static inline void vmathSoaT3Prints_V( VmathSoaTransform3 tfrm, const char *name ); + +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include "vectormath_soa.h" +#include "vec_soa_v.h" +#include "quat_soa_v.h" +#include "mat_soa_v.h" + +#endif diff --git a/vectormathlibrary/include/vectormath/spu/cpp/boolInVec.h b/vectormathlibrary/include/vectormath/spu/cpp/boolInVec.h new file mode 100644 index 000000000..93a3ad29d --- /dev/null +++ b/vectormathlibrary/include/vectormath/spu/cpp/boolInVec.h @@ -0,0 +1,246 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _BOOLINVEC_H +#define _BOOLINVEC_H + +#include <spu_intrinsics.h> + +namespace Vectormath { + +class floatInVec; + +//-------------------------------------------------------------------------------------------------- +// boolInVec class +// + +class boolInVec +{ + private: + vec_uint4 mData; + + inline boolInVec(vec_uint4 vec); + public: + inline boolInVec() {} + + // matches standard type conversions + // + inline boolInVec(floatInVec vec); + + // explicit cast from bool + // + explicit inline boolInVec(bool scalar); + +#ifdef _VECTORMATH_NO_SCALAR_CAST + // explicit cast to bool + // + inline bool getAsBool() const; +#else + // implicit cast to bool + // + inline operator bool() const; +#endif + + // get vector data + // bool value is in the 0 word slot of vector as 0 (false) or -1 (true) + // + inline vec_uint4 get128() const; + + // operators + // + inline const boolInVec operator ! () const; + inline boolInVec& operator = (boolInVec vec); + inline boolInVec& operator &= (boolInVec vec); + inline boolInVec& operator ^= (boolInVec vec); + inline boolInVec& operator |= (boolInVec vec); + + // friend functions + // + friend inline const boolInVec operator == (boolInVec vec0, boolInVec vec1); + friend inline const boolInVec operator != (boolInVec vec0, boolInVec vec1); + friend inline const boolInVec operator < (floatInVec vec0, floatInVec vec1); + friend inline const boolInVec operator <= (floatInVec vec0, floatInVec vec1); + friend inline const boolInVec operator > (floatInVec vec0, floatInVec vec1); + friend inline const boolInVec operator >= (floatInVec vec0, floatInVec vec1); + friend inline const boolInVec operator == (floatInVec vec0, floatInVec vec1); + friend inline const boolInVec operator != (floatInVec vec0, floatInVec vec1); + friend inline const boolInVec operator & (boolInVec vec0, boolInVec vec1); + friend inline const boolInVec operator ^ (boolInVec vec0, boolInVec vec1); + friend inline const boolInVec operator | (boolInVec vec0, boolInVec vec1); + friend inline const boolInVec select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1); +}; + +//-------------------------------------------------------------------------------------------------- +// boolInVec functions +// + +// operators +// +inline const boolInVec operator == (boolInVec vec0, boolInVec vec1); +inline const boolInVec operator != (boolInVec vec0, boolInVec vec1); +inline const boolInVec operator & (boolInVec vec0, boolInVec vec1); +inline const boolInVec operator ^ (boolInVec vec0, boolInVec vec1); +inline const boolInVec operator | (boolInVec vec0, boolInVec vec1); + +// select between vec0 and vec1 using boolInVec. +// false selects vec0, true selects vec1 +// +inline const boolInVec select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1); + +} // namespace Vectormath + +//-------------------------------------------------------------------------------------------------- +// boolInVec implementation +// + +#include "floatInVec.h" + +namespace Vectormath { + +inline +boolInVec::boolInVec(vec_uint4 vec) +{ + mData = vec; +} + +inline +boolInVec::boolInVec(floatInVec vec) +{ + *this = (vec != floatInVec(0.0f)); +} + +inline +boolInVec::boolInVec(bool scalar) +{ + mData = spu_promote((unsigned int)-scalar, 0); +} + +#ifdef _VECTORMATH_NO_SCALAR_CAST +inline +bool +boolInVec::getAsBool() const +#else +inline +boolInVec::operator bool() const +#endif +{ + return (bool)spu_extract(mData, 0); +} + +inline +vec_uint4 +boolInVec::get128() const +{ + return mData; +} + +inline +const boolInVec +boolInVec::operator ! () const +{ + return boolInVec(spu_nor(mData, mData)); +} + +inline +boolInVec& +boolInVec::operator = (boolInVec vec) +{ + mData = vec.mData; + return *this; +} + +inline +boolInVec& +boolInVec::operator &= (boolInVec vec) +{ + *this = *this & vec; + return *this; +} + +inline +boolInVec& +boolInVec::operator ^= (boolInVec vec) +{ + *this = *this ^ vec; + return *this; +} + +inline +boolInVec& +boolInVec::operator |= (boolInVec vec) +{ + *this = *this | vec; + return *this; +} + +inline +const boolInVec +operator == (boolInVec vec0, boolInVec vec1) +{ + return boolInVec(spu_cmpeq(vec0.get128(), vec1.get128())); +} + +inline +const boolInVec +operator != (boolInVec vec0, boolInVec vec1) +{ + return !(vec0 == vec1); +} + +inline +const boolInVec +operator & (boolInVec vec0, boolInVec vec1) +{ + return boolInVec(spu_and(vec0.get128(), vec1.get128())); +} + +inline +const boolInVec +operator | (boolInVec vec0, boolInVec vec1) +{ + return boolInVec(spu_or(vec0.get128(), vec1.get128())); +} + +inline +const boolInVec +operator ^ (boolInVec vec0, boolInVec vec1) +{ + return boolInVec(spu_xor(vec0.get128(), vec1.get128())); +} + +inline +const boolInVec +select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1) +{ + return boolInVec(spu_sel(vec0.get128(), vec1.get128(), select_vec1.get128())); +} + +} // namespace Vectormath + +#endif // boolInVec_h diff --git a/vectormathlibrary/include/vectormath/spu/cpp/floatInVec.h b/vectormathlibrary/include/vectormath/spu/cpp/floatInVec.h new file mode 100644 index 000000000..7521c0c40 --- /dev/null +++ b/vectormathlibrary/include/vectormath/spu/cpp/floatInVec.h @@ -0,0 +1,339 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _FLOATINVEC_H +#define _FLOATINVEC_H + +#include <math.h> +#include <spu_intrinsics.h> +#include <simdmath.h> +#undef bool + +namespace Vectormath { + +class boolInVec; + +//-------------------------------------------------------------------------------------------------- +// floatInVec class +// + +class floatInVec +{ + private: + vec_float4 mData; + + inline floatInVec(vec_float4 vec); + public: + inline floatInVec() {} + + // matches standard type conversions + // + inline floatInVec(boolInVec vec); + + // construct from a slot of vec_float4 + // + inline floatInVec(vec_float4 vec, int slot); + + // explicit cast from float + // + explicit inline floatInVec(float scalar); + +#ifdef _VECTORMATH_NO_SCALAR_CAST + // explicit cast to float + // + inline float getAsFloat() const; +#else + // implicit cast to float + // + inline operator float() const; +#endif + + // get vector data + // float value is in 0 word slot of vector + // + inline vec_float4 get128() const; + + // operators + // + inline const floatInVec operator ++ (int); + inline const floatInVec operator -- (int); + inline floatInVec& operator ++ (); + inline floatInVec& operator -- (); + inline const floatInVec operator - () const; + inline floatInVec& operator = (floatInVec vec); + inline floatInVec& operator *= (floatInVec vec); + inline floatInVec& operator /= (floatInVec vec); + inline floatInVec& operator += (floatInVec vec); + inline floatInVec& operator -= (floatInVec vec); + + // friend functions + // + friend inline const floatInVec operator * (floatInVec vec0, floatInVec vec1); + friend inline const floatInVec operator / (floatInVec vec0, floatInVec vec1); + friend inline const floatInVec operator + (floatInVec vec0, floatInVec vec1); + friend inline const floatInVec operator - (floatInVec vec0, floatInVec vec1); + friend inline const floatInVec select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1); +}; + +//-------------------------------------------------------------------------------------------------- +// floatInVec functions +// + +// operators +// +inline const floatInVec operator * (floatInVec vec0, floatInVec vec1); +inline const floatInVec operator / (floatInVec vec0, floatInVec vec1); +inline const floatInVec operator + (floatInVec vec0, floatInVec vec1); +inline const floatInVec operator - (floatInVec vec0, floatInVec vec1); +inline const boolInVec operator < (floatInVec vec0, floatInVec vec1); +inline const boolInVec operator <= (floatInVec vec0, floatInVec vec1); +inline const boolInVec operator > (floatInVec vec0, floatInVec vec1); +inline const boolInVec operator >= (floatInVec vec0, floatInVec vec1); +inline const boolInVec operator == (floatInVec vec0, floatInVec vec1); +inline const boolInVec operator != (floatInVec vec0, floatInVec vec1); + +// select between vec0 and vec1 using boolInVec. +// false selects vec0, true selects vec1 +// +inline const floatInVec select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1); + +} // namespace Vectormath + +//-------------------------------------------------------------------------------------------------- +// floatInVec implementation +// + +#include "boolInVec.h" + +namespace Vectormath { + +inline +floatInVec::floatInVec(vec_float4 vec) +{ + mData = vec; +} + +inline +floatInVec::floatInVec(boolInVec vec) +{ + mData = spu_sel(spu_splats(0.0f), spu_splats(1.0f), vec.get128()); +} + +inline +floatInVec::floatInVec(vec_float4 vec, int slot) +{ + mData = spu_promote(spu_extract(vec, slot), 0); +} + +inline +floatInVec::floatInVec(float scalar) +{ + mData = spu_promote(scalar, 0); +} + +#ifdef _VECTORMATH_NO_SCALAR_CAST +inline +float +floatInVec::getAsFloat() const +#else +inline +floatInVec::operator float() const +#endif +{ + return spu_extract(mData,0); +} + +inline +vec_float4 +floatInVec::get128() const +{ + return mData; +} + +inline +const floatInVec +floatInVec::operator ++ (int) +{ + vec_float4 olddata = mData; + operator ++(); + return floatInVec(olddata); +} + +inline +const floatInVec +floatInVec::operator -- (int) +{ + vec_float4 olddata = mData; + operator --(); + return floatInVec(olddata); +} + +inline +floatInVec& +floatInVec::operator ++ () +{ + *this += floatInVec(1.0f); + return *this; +} + +inline +floatInVec& +floatInVec::operator -- () +{ + *this -= floatInVec(1.0f); + return *this; +} + +inline +const floatInVec +floatInVec::operator - () const +{ + return floatInVec((vec_float4)spu_xor((vec_uint4)mData, spu_splats(0x80000000))); +} + +inline +floatInVec& +floatInVec::operator = (floatInVec vec) +{ + mData = vec.mData; + return *this; +} + +inline +floatInVec& +floatInVec::operator *= (floatInVec vec) +{ + *this = *this * vec; + return *this; +} + +inline +floatInVec& +floatInVec::operator /= (floatInVec vec) +{ + *this = *this / vec; + return *this; +} + +inline +floatInVec& +floatInVec::operator += (floatInVec vec) +{ + *this = *this + vec; + return *this; +} + +inline +floatInVec& +floatInVec::operator -= (floatInVec vec) +{ + *this = *this - vec; + return *this; +} + +inline +const floatInVec +operator * (floatInVec vec0, floatInVec vec1) +{ + return floatInVec(spu_mul(vec0.get128(), vec1.get128())); +} + +inline +const floatInVec +operator / (floatInVec num, floatInVec den) +{ + return floatInVec(divf4(num.get128(), den.get128())); +} + +inline +const floatInVec +operator + (floatInVec vec0, floatInVec vec1) +{ + return floatInVec(spu_add(vec0.get128(), vec1.get128())); +} + +inline +const floatInVec +operator - (floatInVec vec0, floatInVec vec1) +{ + return floatInVec(spu_sub(vec0.get128(), vec1.get128())); +} + +inline +const boolInVec +operator < (floatInVec vec0, floatInVec vec1) +{ + return boolInVec(spu_cmpgt(vec1.get128(), vec0.get128())); +} + +inline +const boolInVec +operator <= (floatInVec vec0, floatInVec vec1) +{ + return !(vec0 > vec1); +} + +inline +const boolInVec +operator > (floatInVec vec0, floatInVec vec1) +{ + return boolInVec(spu_cmpgt(vec0.get128(), vec1.get128())); +} + +inline +const boolInVec +operator >= (floatInVec vec0, floatInVec vec1) +{ + return !(vec0 < vec1); +} + +inline +const boolInVec +operator == (floatInVec vec0, floatInVec vec1) +{ + return boolInVec(spu_cmpeq(vec0.get128(), vec1.get128())); +} + +inline +const boolInVec +operator != (floatInVec vec0, floatInVec vec1) +{ + return !(vec0 == vec1); +} + +inline +const floatInVec +select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1) +{ + return floatInVec(spu_sel(vec0.get128(), vec1.get128(), select_vec1.get128())); +} + +} // namespace Vectormath + +#endif // floatInVec_h diff --git a/vectormathlibrary/include/vectormath/spu/cpp/mat_aos.h b/vectormathlibrary/include/vectormath/spu/cpp/mat_aos.h new file mode 100644 index 000000000..a2fd611ec --- /dev/null +++ b/vectormathlibrary/include/vectormath/spu/cpp/mat_aos.h @@ -0,0 +1,2027 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_MAT_AOS_CPP_H +#define _VECTORMATH_MAT_AOS_CPP_H + +namespace Vectormath { +namespace Aos { + +//----------------------------------------------------------------------------- +// Constants +// for shuffles, words are labeled [x,y,z,w] [a,b,c,d] + +#define _VECTORMATH_SHUF_XAYB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_B }) +#define _VECTORMATH_SHUF_ZCWD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_D }) +#define _VECTORMATH_SHUF_ZBW0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_0 }) +#define _VECTORMATH_SHUF_XCY0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_0 }) +#define _VECTORMATH_SHUF_XYAB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_B }) +#define _VECTORMATH_SHUF_ZWCD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_D }) +#define _VECTORMATH_SHUF_0ZB0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_0, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_0 }) +#define _VECTORMATH_SHUF_C0X0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_0, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_0 }) +#define _VECTORMATH_SHUF_YA00 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_0, _VECTORMATH_SHUF_0 }) +#define _VECTORMATH_SHUF_XAZC ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_C }) +#define _VECTORMATH_SHUF_YXWZ ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_Z }) +#define _VECTORMATH_SHUF_YBWD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_D }) +#define _VECTORMATH_SHUF_XYCX ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_X }) +#define _VECTORMATH_SHUF_YCXY ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y }) +#define _VECTORMATH_SHUF_CXYC ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_C }) +#define _VECTORMATH_SHUF_ZAY0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_0 }) +#define _VECTORMATH_SHUF_BZX0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_0 }) +#define _VECTORMATH_SHUF_0ZYA ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_0, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_A }) +#define _VECTORMATH_SHUF_Z0XB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_0, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_B }) +#define _VECTORMATH_SHUF_YX0C ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_0, _VECTORMATH_SHUF_C }) +#define _VECTORMATH_SHUF_CZD0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_D, _VECTORMATH_SHUF_0 }) +#define _VECTORMATH_SHUF_BBY0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_0 }) +#define _VECTORMATH_PI_OVER_2 1.570796327f + +//----------------------------------------------------------------------------- +// Definitions + +inline Matrix3::Matrix3( const Matrix3 & mat ) +{ + mCol0 = mat.mCol0; + mCol1 = mat.mCol1; + mCol2 = mat.mCol2; +} + +inline Matrix3::Matrix3( float scalar ) +{ + mCol0 = Vector3( scalar ); + mCol1 = Vector3( scalar ); + mCol2 = Vector3( scalar ); +} + +inline Matrix3::Matrix3( Quat unitQuat ) +{ + vec_float4 xyzw_2, wwww, yzxw, zxyw, yzxw_2, zxyw_2; + vec_float4 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; + vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f); + vec_uint4 select_x = (vec_uint4)spu_maskb(0xf000); + vec_uint4 select_z = (vec_uint4)spu_maskb(0x00f0); + xyzw_2 = spu_add( unitQuat.get128(), unitQuat.get128() ); + wwww = spu_shuffle( unitQuat.get128(), unitQuat.get128(), shuffle_wwww ); + yzxw = spu_shuffle( unitQuat.get128(), unitQuat.get128(), _VECTORMATH_SHUF_YZXW ); + zxyw = spu_shuffle( unitQuat.get128(), unitQuat.get128(), _VECTORMATH_SHUF_ZXYW ); + yzxw_2 = spu_shuffle( xyzw_2, xyzw_2, _VECTORMATH_SHUF_YZXW ); + zxyw_2 = spu_shuffle( xyzw_2, xyzw_2, _VECTORMATH_SHUF_ZXYW ); + tmp0 = spu_mul( yzxw_2, wwww ); + tmp1 = spu_nmsub( yzxw, yzxw_2, spu_splats(1.0f) ); + tmp2 = spu_mul( yzxw, xyzw_2 ); + tmp0 = spu_madd( zxyw, xyzw_2, tmp0 ); + tmp1 = spu_nmsub( zxyw, zxyw_2, tmp1 ); + tmp2 = spu_nmsub( zxyw_2, wwww, tmp2 ); + tmp3 = spu_sel( tmp0, tmp1, select_x ); + tmp4 = spu_sel( tmp1, tmp2, select_x ); + tmp5 = spu_sel( tmp2, tmp0, select_x ); + mCol0 = Vector3( spu_sel( tmp3, tmp2, select_z ) ); + mCol1 = Vector3( spu_sel( tmp4, tmp0, select_z ) ); + mCol2 = Vector3( spu_sel( tmp5, tmp1, select_z ) ); +} + +inline Matrix3::Matrix3( Vector3 _col0, Vector3 _col1, Vector3 _col2 ) +{ + mCol0 = _col0; + mCol1 = _col1; + mCol2 = _col2; +} + +inline Matrix3 & Matrix3::setCol0( Vector3 _col0 ) +{ + mCol0 = _col0; + return *this; +} + +inline Matrix3 & Matrix3::setCol1( Vector3 _col1 ) +{ + mCol1 = _col1; + return *this; +} + +inline Matrix3 & Matrix3::setCol2( Vector3 _col2 ) +{ + mCol2 = _col2; + return *this; +} + +inline Matrix3 & Matrix3::setCol( int col, Vector3 vec ) +{ + *(&mCol0 + col) = vec; + return *this; +} + +inline Matrix3 & Matrix3::setRow( int row, Vector3 vec ) +{ + mCol0.setElem( row, vec.getElem( 0 ) ); + mCol1.setElem( row, vec.getElem( 1 ) ); + mCol2.setElem( row, vec.getElem( 2 ) ); + return *this; +} + +inline Matrix3 & Matrix3::setElem( int col, int row, float val ) +{ + (*this)[col].setElem(row, val); + return *this; +} + +inline float Matrix3::getElem( int col, int row ) const +{ + return this->getCol( col ).getElem( row ); +} + +inline const Vector3 Matrix3::getCol0( ) const +{ + return mCol0; +} + +inline const Vector3 Matrix3::getCol1( ) const +{ + return mCol1; +} + +inline const Vector3 Matrix3::getCol2( ) const +{ + return mCol2; +} + +inline const Vector3 Matrix3::getCol( int col ) const +{ + return *(&mCol0 + col); +} + +inline const Vector3 Matrix3::getRow( int row ) const +{ + return Vector3( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ) ); +} + +inline Vector3 & Matrix3::operator []( int col ) +{ + return *(&mCol0 + col); +} + +inline const Vector3 Matrix3::operator []( int col ) const +{ + return *(&mCol0 + col); +} + +inline Matrix3 & Matrix3::operator =( const Matrix3 & mat ) +{ + mCol0 = mat.mCol0; + mCol1 = mat.mCol1; + mCol2 = mat.mCol2; + return *this; +} + +inline const Matrix3 transpose( const Matrix3 & mat ) +{ + vec_float4 tmp0, tmp1, res0, res1, res2; + tmp0 = spu_shuffle( mat.getCol0().get128(), mat.getCol2().get128(), _VECTORMATH_SHUF_XAYB ); + tmp1 = spu_shuffle( mat.getCol0().get128(), mat.getCol2().get128(), _VECTORMATH_SHUF_ZCWD ); + res0 = spu_shuffle( tmp0, mat.getCol1().get128(), _VECTORMATH_SHUF_XAYB ); + res1 = spu_shuffle( tmp0, mat.getCol1().get128(), _VECTORMATH_SHUF_ZBW0 ); + res2 = spu_shuffle( tmp1, mat.getCol1().get128(), _VECTORMATH_SHUF_XCY0 ); + return Matrix3( + Vector3( res0 ), + Vector3( res1 ), + Vector3( res2 ) + ); +} + +inline const Matrix3 inverse( const Matrix3 & mat ) +{ + vec_float4 tmp0, tmp1, tmp2, tmp3, tmp4, dot, invdet, inv0, inv1, inv2; + tmp2 = _vmathVfCross( mat.getCol0().get128(), mat.getCol1().get128() ); + tmp0 = _vmathVfCross( mat.getCol1().get128(), mat.getCol2().get128() ); + tmp1 = _vmathVfCross( mat.getCol2().get128(), mat.getCol0().get128() ); + dot = _vmathVfDot3( tmp2, mat.getCol2().get128() ); + dot = spu_shuffle( dot, dot, (vec_uchar16)spu_splats(0x00010203) ); + invdet = recipf4( dot ); + tmp3 = spu_shuffle( tmp0, tmp2, _VECTORMATH_SHUF_XAYB ); + tmp4 = spu_shuffle( tmp0, tmp2, _VECTORMATH_SHUF_ZCWD ); + inv0 = spu_shuffle( tmp3, tmp1, _VECTORMATH_SHUF_XAYB ); + inv1 = spu_shuffle( tmp3, tmp1, _VECTORMATH_SHUF_ZBW0 ); + inv2 = spu_shuffle( tmp4, tmp1, _VECTORMATH_SHUF_XCY0 ); + inv0 = spu_mul( inv0, invdet ); + inv1 = spu_mul( inv1, invdet ); + inv2 = spu_mul( inv2, invdet ); + return Matrix3( + Vector3( inv0 ), + Vector3( inv1 ), + Vector3( inv2 ) + ); +} + +inline float determinant( const Matrix3 & mat ) +{ + return dot( mat.getCol2(), cross( mat.getCol0(), mat.getCol1() ) ); +} + +inline const Matrix3 Matrix3::operator +( const Matrix3 & mat ) const +{ + return Matrix3( + ( mCol0 + mat.mCol0 ), + ( mCol1 + mat.mCol1 ), + ( mCol2 + mat.mCol2 ) + ); +} + +inline const Matrix3 Matrix3::operator -( const Matrix3 & mat ) const +{ + return Matrix3( + ( mCol0 - mat.mCol0 ), + ( mCol1 - mat.mCol1 ), + ( mCol2 - mat.mCol2 ) + ); +} + +inline Matrix3 & Matrix3::operator +=( const Matrix3 & mat ) +{ + *this = *this + mat; + return *this; +} + +inline Matrix3 & Matrix3::operator -=( const Matrix3 & mat ) +{ + *this = *this - mat; + return *this; +} + +inline const Matrix3 Matrix3::operator -( ) const +{ + return Matrix3( + ( -mCol0 ), + ( -mCol1 ), + ( -mCol2 ) + ); +} + +inline const Matrix3 absPerElem( const Matrix3 & mat ) +{ + return Matrix3( + absPerElem( mat.getCol0() ), + absPerElem( mat.getCol1() ), + absPerElem( mat.getCol2() ) + ); +} + +inline const Matrix3 Matrix3::operator *( float scalar ) const +{ + return Matrix3( + ( mCol0 * scalar ), + ( mCol1 * scalar ), + ( mCol2 * scalar ) + ); +} + +inline Matrix3 & Matrix3::operator *=( float scalar ) +{ + *this = *this * scalar; + return *this; +} + +inline const Matrix3 operator *( float scalar, const Matrix3 & mat ) +{ + return mat * scalar; +} + +inline const Vector3 Matrix3::operator *( Vector3 vec ) const +{ + vec_float4 res; + vec_float4 xxxx, yyyy, zzzz; + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); + xxxx = spu_shuffle( vec.get128(), vec.get128(), shuffle_xxxx ); + yyyy = spu_shuffle( vec.get128(), vec.get128(), shuffle_yyyy ); + zzzz = spu_shuffle( vec.get128(), vec.get128(), shuffle_zzzz ); + res = spu_mul( mCol0.get128(), xxxx ); + res = spu_madd( mCol1.get128(), yyyy, res ); + res = spu_madd( mCol2.get128(), zzzz, res ); + return Vector3( res ); +} + +inline const Matrix3 Matrix3::operator *( const Matrix3 & mat ) const +{ + return Matrix3( + ( *this * mat.mCol0 ), + ( *this * mat.mCol1 ), + ( *this * mat.mCol2 ) + ); +} + +inline Matrix3 & Matrix3::operator *=( const Matrix3 & mat ) +{ + *this = *this * mat; + return *this; +} + +inline const Matrix3 mulPerElem( const Matrix3 & mat0, const Matrix3 & mat1 ) +{ + return Matrix3( + mulPerElem( mat0.getCol0(), mat1.getCol0() ), + mulPerElem( mat0.getCol1(), mat1.getCol1() ), + mulPerElem( mat0.getCol2(), mat1.getCol2() ) + ); +} + +inline const Matrix3 Matrix3::identity( ) +{ + return Matrix3( + Vector3::xAxis( ), + Vector3::yAxis( ), + Vector3::zAxis( ) + ); +} + +inline const Matrix3 Matrix3::rotationX( float radians ) +{ + vec_float4 s, c, res1, res2; + vec_uint4 select_y, select_z; + vec_float4 zero; + select_y = (vec_uint4)spu_maskb(0x0f00); + select_z = (vec_uint4)spu_maskb(0x00f0); + zero = spu_splats(0.0f); + sincosf4( spu_splats(radians), &s, &c ); + res1 = spu_sel( zero, c, select_y ); + res1 = spu_sel( res1, s, select_z ); + res2 = spu_sel( zero, negatef4(s), select_y ); + res2 = spu_sel( res2, c, select_z ); + return Matrix3( + Vector3::xAxis( ), + Vector3( res1 ), + Vector3( res2 ) + ); +} + +inline const Matrix3 Matrix3::rotationY( float radians ) +{ + vec_float4 s, c, res0, res2; + vec_uint4 select_x, select_z; + vec_float4 zero; + select_x = (vec_uint4)spu_maskb(0xf000); + select_z = (vec_uint4)spu_maskb(0x00f0); + zero = spu_splats(0.0f); + sincosf4( spu_splats(radians), &s, &c ); + res0 = spu_sel( zero, c, select_x ); + res0 = spu_sel( res0, negatef4(s), select_z ); + res2 = spu_sel( zero, s, select_x ); + res2 = spu_sel( res2, c, select_z ); + return Matrix3( + Vector3( res0 ), + Vector3::yAxis( ), + Vector3( res2 ) + ); +} + +inline const Matrix3 Matrix3::rotationZ( float radians ) +{ + vec_float4 s, c, res0, res1; + vec_uint4 select_x, select_y; + vec_float4 zero; + select_x = (vec_uint4)spu_maskb(0xf000); + select_y = (vec_uint4)spu_maskb(0x0f00); + zero = spu_splats(0.0f); + sincosf4( spu_splats(radians), &s, &c ); + res0 = spu_sel( zero, c, select_x ); + res0 = spu_sel( res0, s, select_y ); + res1 = spu_sel( zero, negatef4(s), select_x ); + res1 = spu_sel( res1, c, select_y ); + return Matrix3( + Vector3( res0 ), + Vector3( res1 ), + Vector3::zAxis( ) + ); +} + +inline const Matrix3 Matrix3::rotationZYX( Vector3 radiansXYZ ) +{ + vec_float4 angles, s, negS, c, X0, X1, Y0, Y1, Z0, Z1, tmp; + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + angles = radiansXYZ.get128(); + angles = spu_insert( 0.0f, angles, 3 ); + sincosf4( angles, &s, &c ); + negS = negatef4( s ); + Z0 = spu_shuffle( s, c, _VECTORMATH_SHUF_CZD0 ); + Z1 = spu_shuffle( c, negS, _VECTORMATH_SHUF_CZD0 ); + Y0 = spu_shuffle( negS, c, _VECTORMATH_SHUF_BBY0 ); + Y1 = spu_shuffle( c, s, _VECTORMATH_SHUF_BBY0 ); + X0 = spu_shuffle( s, s, shuffle_xxxx ); + X1 = spu_shuffle( c, c, shuffle_xxxx ); + tmp = spu_mul( Z0, Y1 ); + return Matrix3( + Vector3( spu_mul( Z0, Y0 ) ), + Vector3( spu_madd( Z1, X1, spu_mul( tmp, X0 ) ) ), + Vector3( spu_nmsub( Z1, X0, spu_mul( tmp, X1 ) ) ) + ); +} + +inline const Matrix3 Matrix3::rotation( float radians, Vector3 unitVec ) +{ + vec_float4 axis, s, c, oneMinusC, axisS, negAxisS, xxxx, yyyy, zzzz, tmp0, tmp1, tmp2; + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); + axis = unitVec.get128(); + sincosf4( spu_splats( radians ), &s, &c ); + xxxx = spu_shuffle( axis, axis, shuffle_xxxx ); + yyyy = spu_shuffle( axis, axis, shuffle_yyyy ); + zzzz = spu_shuffle( axis, axis, shuffle_zzzz ); + oneMinusC = spu_sub( spu_splats(1.0f), c ); + axisS = spu_mul( axis, s ); + negAxisS = negatef4( axisS ); + tmp0 = spu_shuffle( axisS, negAxisS, _VECTORMATH_SHUF_0ZB0 ); + tmp1 = spu_shuffle( axisS, negAxisS, _VECTORMATH_SHUF_C0X0 ); + tmp2 = spu_shuffle( axisS, negAxisS, _VECTORMATH_SHUF_YA00 ); + tmp0 = spu_sel( tmp0, c, (vec_uint4)spu_maskb(0xf000) ); + tmp1 = spu_sel( tmp1, c, (vec_uint4)spu_maskb(0x0f00) ); + tmp2 = spu_sel( tmp2, c, (vec_uint4)spu_maskb(0x00f0) ); + return Matrix3( + Vector3( spu_madd( spu_mul( axis, xxxx ), oneMinusC, tmp0 ) ), + Vector3( spu_madd( spu_mul( axis, yyyy ), oneMinusC, tmp1 ) ), + Vector3( spu_madd( spu_mul( axis, zzzz ), oneMinusC, tmp2 ) ) + ); +} + +inline const Matrix3 Matrix3::rotation( Quat unitQuat ) +{ + return Matrix3( unitQuat ); +} + +inline const Matrix3 Matrix3::scale( Vector3 scaleVec ) +{ + vec_float4 zero = spu_splats(0.0f); + return Matrix3( + Vector3( spu_sel( zero, scaleVec.get128(), (vec_uint4)spu_maskb(0xf000) ) ), + Vector3( spu_sel( zero, scaleVec.get128(), (vec_uint4)spu_maskb(0x0f00) ) ), + Vector3( spu_sel( zero, scaleVec.get128(), (vec_uint4)spu_maskb(0x00f0) ) ) + ); +} + +inline const Matrix3 appendScale( const Matrix3 & mat, Vector3 scaleVec ) +{ + return Matrix3( + ( mat.getCol0() * scaleVec.getX( ) ), + ( mat.getCol1() * scaleVec.getY( ) ), + ( mat.getCol2() * scaleVec.getZ( ) ) + ); +} + +inline const Matrix3 prependScale( Vector3 scaleVec, const Matrix3 & mat ) +{ + return Matrix3( + mulPerElem( mat.getCol0(), scaleVec ), + mulPerElem( mat.getCol1(), scaleVec ), + mulPerElem( mat.getCol2(), scaleVec ) + ); +} + +inline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, bool select1 ) +{ + return Matrix3( + select( mat0.getCol0(), mat1.getCol0(), select1 ), + select( mat0.getCol1(), mat1.getCol1(), select1 ), + select( mat0.getCol2(), mat1.getCol2(), select1 ) + ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( const Matrix3 & mat ) +{ + print( mat.getRow( 0 ) ); + print( mat.getRow( 1 ) ); + print( mat.getRow( 2 ) ); +} + +inline void print( const Matrix3 & mat, const char * name ) +{ + printf("%s:\n", name); + print( mat ); +} + +#endif + +inline Matrix4::Matrix4( const Matrix4 & mat ) +{ + mCol0 = mat.mCol0; + mCol1 = mat.mCol1; + mCol2 = mat.mCol2; + mCol3 = mat.mCol3; +} + +inline Matrix4::Matrix4( float scalar ) +{ + mCol0 = Vector4( scalar ); + mCol1 = Vector4( scalar ); + mCol2 = Vector4( scalar ); + mCol3 = Vector4( scalar ); +} + +inline Matrix4::Matrix4( const Transform3 & mat ) +{ + mCol0 = Vector4( mat.getCol0(), 0.0f ); + mCol1 = Vector4( mat.getCol1(), 0.0f ); + mCol2 = Vector4( mat.getCol2(), 0.0f ); + mCol3 = Vector4( mat.getCol3(), 1.0f ); +} + +inline Matrix4::Matrix4( Vector4 _col0, Vector4 _col1, Vector4 _col2, Vector4 _col3 ) +{ + mCol0 = _col0; + mCol1 = _col1; + mCol2 = _col2; + mCol3 = _col3; +} + +inline Matrix4::Matrix4( const Matrix3 & mat, Vector3 translateVec ) +{ + mCol0 = Vector4( mat.getCol0(), 0.0f ); + mCol1 = Vector4( mat.getCol1(), 0.0f ); + mCol2 = Vector4( mat.getCol2(), 0.0f ); + mCol3 = Vector4( translateVec, 1.0f ); +} + +inline Matrix4::Matrix4( Quat unitQuat, Vector3 translateVec ) +{ + Matrix3 mat; + mat = Matrix3( unitQuat ); + mCol0 = Vector4( mat.getCol0(), 0.0f ); + mCol1 = Vector4( mat.getCol1(), 0.0f ); + mCol2 = Vector4( mat.getCol2(), 0.0f ); + mCol3 = Vector4( translateVec, 1.0f ); +} + +inline Matrix4 & Matrix4::setCol0( Vector4 _col0 ) +{ + mCol0 = _col0; + return *this; +} + +inline Matrix4 & Matrix4::setCol1( Vector4 _col1 ) +{ + mCol1 = _col1; + return *this; +} + +inline Matrix4 & Matrix4::setCol2( Vector4 _col2 ) +{ + mCol2 = _col2; + return *this; +} + +inline Matrix4 & Matrix4::setCol3( Vector4 _col3 ) +{ + mCol3 = _col3; + return *this; +} + +inline Matrix4 & Matrix4::setCol( int col, Vector4 vec ) +{ + *(&mCol0 + col) = vec; + return *this; +} + +inline Matrix4 & Matrix4::setRow( int row, Vector4 vec ) +{ + mCol0.setElem( row, vec.getElem( 0 ) ); + mCol1.setElem( row, vec.getElem( 1 ) ); + mCol2.setElem( row, vec.getElem( 2 ) ); + mCol3.setElem( row, vec.getElem( 3 ) ); + return *this; +} + +inline Matrix4 & Matrix4::setElem( int col, int row, float val ) +{ + (*this)[col].setElem(row, val); + return *this; +} + +inline float Matrix4::getElem( int col, int row ) const +{ + return this->getCol( col ).getElem( row ); +} + +inline const Vector4 Matrix4::getCol0( ) const +{ + return mCol0; +} + +inline const Vector4 Matrix4::getCol1( ) const +{ + return mCol1; +} + +inline const Vector4 Matrix4::getCol2( ) const +{ + return mCol2; +} + +inline const Vector4 Matrix4::getCol3( ) const +{ + return mCol3; +} + +inline const Vector4 Matrix4::getCol( int col ) const +{ + return *(&mCol0 + col); +} + +inline const Vector4 Matrix4::getRow( int row ) const +{ + return Vector4( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ), mCol3.getElem( row ) ); +} + +inline Vector4 & Matrix4::operator []( int col ) +{ + return *(&mCol0 + col); +} + +inline const Vector4 Matrix4::operator []( int col ) const +{ + return *(&mCol0 + col); +} + +inline Matrix4 & Matrix4::operator =( const Matrix4 & mat ) +{ + mCol0 = mat.mCol0; + mCol1 = mat.mCol1; + mCol2 = mat.mCol2; + mCol3 = mat.mCol3; + return *this; +} + +inline const Matrix4 transpose( const Matrix4 & mat ) +{ + vec_float4 tmp0, tmp1, tmp2, tmp3, res0, res1, res2, res3; + tmp0 = spu_shuffle( mat.getCol0().get128(), mat.getCol2().get128(), _VECTORMATH_SHUF_XAYB ); + tmp1 = spu_shuffle( mat.getCol1().get128(), mat.getCol3().get128(), _VECTORMATH_SHUF_XAYB ); + tmp2 = spu_shuffle( mat.getCol0().get128(), mat.getCol2().get128(), _VECTORMATH_SHUF_ZCWD ); + tmp3 = spu_shuffle( mat.getCol1().get128(), mat.getCol3().get128(), _VECTORMATH_SHUF_ZCWD ); + res0 = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB ); + res1 = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD ); + res2 = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB ); + res3 = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_ZCWD ); + return Matrix4( + Vector4( res0 ), + Vector4( res1 ), + Vector4( res2 ), + Vector4( res3 ) + ); +} + +inline const Matrix4 inverse( const Matrix4 & mat ) +{ + /* function implementation based on code from STIDC SDK: */ + /* -------------------------------------------------------------- */ + /* PLEASE DO NOT MODIFY THIS SECTION */ + /* This prolog section is automatically generated. */ + /* */ + /* (C)Copyright */ + /* Sony Computer Entertainment, Inc., */ + /* Toshiba Corporation, */ + /* International Business Machines Corporation, */ + /* 2001,2002. */ + /* S/T/I Confidential Information */ + /* -------------------------------------------------------------- */ + vec_float4 in0, in1, in2, in3; + vec_float4 tmp0, tmp1, tmp2, tmp3; + vec_float4 cof0, cof1, cof2, cof3; + vec_float4 t0, t1, t2, t3; + vec_float4 t01, t02, t03, t12, t23; + vec_float4 t1r, t2r; + vec_float4 t01r, t02r, t03r, t12r, t23r; + vec_float4 t1r3, t1r3r; + vec_float4 det, det1, det2, det3, invdet; + in0 = mat.getCol0().get128(); + in1 = mat.getCol1().get128(); + in2 = mat.getCol2().get128(); + in3 = mat.getCol3().get128(); + /* Perform transform of the input matrix of the form: + * A B C D + * E F G H + * I J K L + * M N O P + * + * The pseudo transpose of the input matrix is trans: + * A E I M + * J N B F + * C G K O + * L P D H + */ + tmp0 = spu_shuffle(in0, in1, _VECTORMATH_SHUF_XAZC); /* A E C G */ + tmp1 = spu_shuffle(in2, in3, _VECTORMATH_SHUF_XAZC); /* I M K O */ + tmp2 = spu_shuffle(in0, in1, _VECTORMATH_SHUF_YBWD); /* B F D H */ + tmp3 = spu_shuffle(in2, in3, _VECTORMATH_SHUF_YBWD); /* J N L P */ + t0 = spu_shuffle(tmp0, tmp1, _VECTORMATH_SHUF_XYAB); /* A E I M */ + t1 = spu_shuffle(tmp3, tmp2, _VECTORMATH_SHUF_XYAB); /* J N B F */ + t2 = spu_shuffle(tmp0, tmp1, _VECTORMATH_SHUF_ZWCD); /* C G K O */ + t3 = spu_shuffle(tmp3, tmp2, _VECTORMATH_SHUF_ZWCD); /* L P D H */ + /* Generate a cofactor matrix. The computed cofactors reside in + * cof0, cof1, cof2, cof3. + */ + t23 = spu_mul(t2, t3); /* CL GP KD OH */ + t23 = spu_shuffle(t23, t23, _VECTORMATH_SHUF_YXWZ); /* GP CL OH KD */ + cof0 = spu_mul(t1, t23); /* JGP NCL BOH FKD */ + cof1 = spu_mul(t0, t23); /* AGP ECL IOH MKD */ + t23r = spu_rlqwbyte(t23, 8); /* OH KD GP CL */ + cof0 = spu_msub(t1, t23r, cof0); /* JOH NKD BGP FCL - cof0 */ + cof1 = spu_msub(t0, t23r, cof1); /* AOH EKD IGP MCL - cof1 */ + cof1 = spu_rlqwbyte(cof1, 8); /* IGP MCL AOH EKD - IOH MKD AGP ECL */ + + t12 = spu_mul(t1, t2); /* JC NG BK FO */ + t12 = spu_shuffle(t12, t12, _VECTORMATH_SHUF_YXWZ); /* NG JC FO BK */ + cof0 = spu_madd(t3, t12, cof0); /* LNG PJC DFO HBK + cof0 */ + cof3 = spu_mul(t0, t12); /* ANG EJC IFO MBK */ + t12r = spu_rlqwbyte(t12, 8); /* FO BK NG JC */ + cof0 = spu_nmsub(t3, t12r, cof0); /* cof0 - LFO PBK DNG HJC */ + cof3 = spu_msub(t0, t12r, cof3); /* AFO EBK ING MJC - cof3 */ + cof3 = spu_rlqwbyte(cof3, 8); /* ING MJC AFO EBK - IFO MBK ANG EJC */ + t1r = spu_rlqwbyte(t1, 8); /* B F J N */ + t2r = spu_rlqwbyte(t2, 8); /* K O C G */ + t1r3 = spu_mul(t1r, t3); /* BL FP JD NH */ + t1r3 = spu_shuffle(t1r3, t1r3, _VECTORMATH_SHUF_YXWZ); /* FP BL NH JD */ + cof0 = spu_madd(t2r, t1r3, cof0); /* KFP OBL CNH GJD + cof0 */ + cof2 = spu_mul(t0, t1r3); /* AFP EBL INH MJD */ + t1r3r = spu_rlqwbyte(t1r3, 8); /* NH JD FP BL */ + cof0 = spu_nmsub(t2r, t1r3r, cof0); /* cof0 - KNH OJD CFP GBL */ + cof2 = spu_msub(t0, t1r3r, cof2); /* ANH EJD IFP MBL - cof2 */ + cof2 = spu_rlqwbyte(cof2, 8); /* IFP MBL ANH EJD - INH MJD AFP EBL */ + t01 = spu_mul(t0, t1); /* AJ EN IB MF */ + t01 = spu_shuffle(t01, t01, _VECTORMATH_SHUF_YXWZ); /* EN AJ MF IB */ + cof2 = spu_madd(t3, t01, cof2); /* LEN PAJ DMF HIB + cof2 */ + cof3 = spu_msub(t2r, t01, cof3); /* KEN OAJ CMF GIB - cof3 */ + t01r = spu_rlqwbyte(t01, 8); /* MF IB EN AJ */ + cof2 = spu_msub(t3, t01r, cof2); /* LMF PIB DEN HAJ - cof2 */ + cof3 = spu_nmsub(t2r, t01r, cof3); /* cof3 - KMF OIB CEN GAJ */ + t03 = spu_mul(t0, t3); /* AL EP ID MH */ + t03 = spu_shuffle(t03, t03, _VECTORMATH_SHUF_YXWZ); /* EP AL MH ID */ + cof1 = spu_nmsub(t2r, t03, cof1); /* cof1 - KEP OAL CMH GID */ + cof2 = spu_madd(t1, t03, cof2); /* JEP NAL BMH FID + cof2 */ + t03r = spu_rlqwbyte(t03, 8); /* MH ID EP AL */ + cof1 = spu_madd(t2r, t03r, cof1); /* KMH OID CEP GAL + cof1 */ + cof2 = spu_nmsub(t1, t03r, cof2); /* cof2 - JMH NID BEP FAL */ + t02 = spu_mul(t0, t2r); /* AK EO IC MG */ + t02 = spu_shuffle(t02, t02, _VECTORMATH_SHUF_YXWZ); /* E0 AK MG IC */ + cof1 = spu_madd(t3, t02, cof1); /* LEO PAK DMG HIC + cof1 */ + cof3 = spu_nmsub(t1, t02, cof3); /* cof3 - JEO NAK BMG FIC */ + t02r = spu_rlqwbyte(t02, 8); /* MG IC EO AK */ + cof1 = spu_nmsub(t3, t02r, cof1); /* cof1 - LMG PIC DEO HAK */ + cof3 = spu_madd(t1, t02r, cof3); /* JMG NIC BEO FAK + cof3 */ + /* Compute the determinant of the matrix + * + * det = sum_across(t0 * cof0); + * + * We perform a sum across the entire vector so that + * we don't have to splat the result when multiplying the + * cofactors by the inverse of the determinant. + */ + det = spu_mul(t0, cof0); + det1 = spu_rlqwbyte(det, 4); + det2 = spu_rlqwbyte(det, 8); + det3 = spu_rlqwbyte(det, 12); + det = spu_add(det, det1); + det2 = spu_add(det2, det3); + det = spu_add(det, det2); + /* Compute the reciprocal of the determinant. + */ + invdet = recipf4(det); + /* Multiply the cofactors by the reciprocal of the determinant. + */ + return Matrix4( + Vector4( spu_mul(cof0, invdet) ), + Vector4( spu_mul(cof1, invdet) ), + Vector4( spu_mul(cof2, invdet) ), + Vector4( spu_mul(cof3, invdet) ) + ); +} + +inline const Matrix4 affineInverse( const Matrix4 & mat ) +{ + Transform3 affineMat; + affineMat.setCol0( mat.getCol0().getXYZ( ) ); + affineMat.setCol1( mat.getCol1().getXYZ( ) ); + affineMat.setCol2( mat.getCol2().getXYZ( ) ); + affineMat.setCol3( mat.getCol3().getXYZ( ) ); + return Matrix4( inverse( affineMat ) ); +} + +inline const Matrix4 orthoInverse( const Matrix4 & mat ) +{ + Transform3 affineMat; + affineMat.setCol0( mat.getCol0().getXYZ( ) ); + affineMat.setCol1( mat.getCol1().getXYZ( ) ); + affineMat.setCol2( mat.getCol2().getXYZ( ) ); + affineMat.setCol3( mat.getCol3().getXYZ( ) ); + return Matrix4( orthoInverse( affineMat ) ); +} + +inline float determinant( const Matrix4 & mat ) +{ + /* function implementation based on code from STIDC SDK: */ + /* -------------------------------------------------------------- */ + /* PLEASE DO NOT MODIFY THIS SECTION */ + /* This prolog section is automatically generated. */ + /* */ + /* (C)Copyright */ + /* Sony Computer Entertainment, Inc., */ + /* Toshiba Corporation, */ + /* International Business Machines Corporation, */ + /* 2001,2002. */ + /* S/T/I Confidential Information */ + /* -------------------------------------------------------------- */ + vec_float4 in0, in1, in2, in3; + vec_float4 tmp0, tmp1, tmp2, tmp3; + vec_float4 cof0; + vec_float4 t0, t1, t2, t3; + vec_float4 t12, t23; + vec_float4 t1r, t2r; + vec_float4 t12r, t23r; + vec_float4 t1r3, t1r3r; + in0 = mat.getCol0().get128(); + in1 = mat.getCol1().get128(); + in2 = mat.getCol2().get128(); + in3 = mat.getCol3().get128(); + /* Perform transform of the input matrix of the form: + * A B C D + * E F G H + * I J K L + * M N O P + * + * The pseudo transpose of the input matrix is trans: + * A E I M + * J N B F + * C G K O + * L P D H + */ + tmp0 = spu_shuffle(in0, in1, _VECTORMATH_SHUF_XAZC); /* A E C G */ + tmp1 = spu_shuffle(in2, in3, _VECTORMATH_SHUF_XAZC); /* I M K O */ + tmp2 = spu_shuffle(in0, in1, _VECTORMATH_SHUF_YBWD); /* B F D H */ + tmp3 = spu_shuffle(in2, in3, _VECTORMATH_SHUF_YBWD); /* J N L P */ + t0 = spu_shuffle(tmp0, tmp1, _VECTORMATH_SHUF_XYAB); /* A E I M */ + t1 = spu_shuffle(tmp3, tmp2, _VECTORMATH_SHUF_XYAB); /* J N B F */ + t2 = spu_shuffle(tmp0, tmp1, _VECTORMATH_SHUF_ZWCD); /* C G K O */ + t3 = spu_shuffle(tmp3, tmp2, _VECTORMATH_SHUF_ZWCD); /* L P D H */ + /* Generate a cofactor matrix. The computed cofactors reside in + * cof0, cof1, cof2, cof3. + */ + t23 = spu_mul(t2, t3); /* CL GP KD OH */ + t23 = spu_shuffle(t23, t23, _VECTORMATH_SHUF_YXWZ); /* GP CL OH KD */ + cof0 = spu_mul(t1, t23); /* JGP NCL BOH FKD */ + t23r = spu_rlqwbyte(t23, 8); /* OH KD GP CL */ + cof0 = spu_msub(t1, t23r, cof0); /* JOH NKD BGP FCL - cof0 */ + + t12 = spu_mul(t1, t2); /* JC NG BK FO */ + t12 = spu_shuffle(t12, t12, _VECTORMATH_SHUF_YXWZ); /* NG JC FO BK */ + cof0 = spu_madd(t3, t12, cof0); /* LNG PJC DFO HBK + cof0 */ + t12r = spu_rlqwbyte(t12, 8); /* FO BK NG JC */ + cof0 = spu_nmsub(t3, t12r, cof0); /* cof0 - LFO PBK DNG HJC */ + t1r = spu_rlqwbyte(t1, 8); /* B F J N */ + t2r = spu_rlqwbyte(t2, 8); /* K O C G */ + t1r3 = spu_mul(t1r, t3); /* BL FP JD NH */ + t1r3 = spu_shuffle(t1r3, t1r3, _VECTORMATH_SHUF_YXWZ); /* FP BL NH JD */ + cof0 = spu_madd(t2r, t1r3, cof0); /* KFP OBL CNH GJD + cof0 */ + t1r3r = spu_rlqwbyte(t1r3, 8); /* NH JD FP BL */ + cof0 = spu_nmsub(t2r, t1r3r, cof0); /* cof0 - KNH OJD CFP GBL */ + return spu_extract( _vmathVfDot4(t0,cof0), 0 ); +} + +inline const Matrix4 Matrix4::operator +( const Matrix4 & mat ) const +{ + return Matrix4( + ( mCol0 + mat.mCol0 ), + ( mCol1 + mat.mCol1 ), + ( mCol2 + mat.mCol2 ), + ( mCol3 + mat.mCol3 ) + ); +} + +inline const Matrix4 Matrix4::operator -( const Matrix4 & mat ) const +{ + return Matrix4( + ( mCol0 - mat.mCol0 ), + ( mCol1 - mat.mCol1 ), + ( mCol2 - mat.mCol2 ), + ( mCol3 - mat.mCol3 ) + ); +} + +inline Matrix4 & Matrix4::operator +=( const Matrix4 & mat ) +{ + *this = *this + mat; + return *this; +} + +inline Matrix4 & Matrix4::operator -=( const Matrix4 & mat ) +{ + *this = *this - mat; + return *this; +} + +inline const Matrix4 Matrix4::operator -( ) const +{ + return Matrix4( + ( -mCol0 ), + ( -mCol1 ), + ( -mCol2 ), + ( -mCol3 ) + ); +} + +inline const Matrix4 absPerElem( const Matrix4 & mat ) +{ + return Matrix4( + absPerElem( mat.getCol0() ), + absPerElem( mat.getCol1() ), + absPerElem( mat.getCol2() ), + absPerElem( mat.getCol3() ) + ); +} + +inline const Matrix4 Matrix4::operator *( float scalar ) const +{ + return Matrix4( + ( mCol0 * scalar ), + ( mCol1 * scalar ), + ( mCol2 * scalar ), + ( mCol3 * scalar ) + ); +} + +inline Matrix4 & Matrix4::operator *=( float scalar ) +{ + *this = *this * scalar; + return *this; +} + +inline const Matrix4 operator *( float scalar, const Matrix4 & mat ) +{ + return mat * scalar; +} + +inline const Vector4 Matrix4::operator *( Vector4 vec ) const +{ + vec_float4 tmp0, tmp1, res; + vec_float4 xxxx, yyyy, zzzz, wwww; + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); + vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f); + xxxx = spu_shuffle( vec.get128(), vec.get128(), shuffle_xxxx ); + yyyy = spu_shuffle( vec.get128(), vec.get128(), shuffle_yyyy ); + zzzz = spu_shuffle( vec.get128(), vec.get128(), shuffle_zzzz ); + wwww = spu_shuffle( vec.get128(), vec.get128(), shuffle_wwww ); + tmp0 = spu_mul( mCol0.get128(), xxxx ); + tmp1 = spu_mul( mCol1.get128(), yyyy ); + tmp0 = spu_madd( mCol2.get128(), zzzz, tmp0 ); + tmp1 = spu_madd( mCol3.get128(), wwww, tmp1 ); + res = spu_add( tmp0, tmp1 ); + return Vector4( res ); +} + +inline const Vector4 Matrix4::operator *( Vector3 vec ) const +{ + vec_float4 res; + vec_float4 xxxx, yyyy, zzzz; + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); + xxxx = spu_shuffle( vec.get128(), vec.get128(), shuffle_xxxx ); + yyyy = spu_shuffle( vec.get128(), vec.get128(), shuffle_yyyy ); + zzzz = spu_shuffle( vec.get128(), vec.get128(), shuffle_zzzz ); + res = spu_mul( mCol0.get128(), xxxx ); + res = spu_madd( mCol1.get128(), yyyy, res ); + res = spu_madd( mCol2.get128(), zzzz, res ); + return Vector4( res ); +} + +inline const Vector4 Matrix4::operator *( Point3 pnt ) const +{ + vec_float4 tmp0, tmp1, res; + vec_float4 xxxx, yyyy, zzzz; + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); + xxxx = spu_shuffle( pnt.get128(), pnt.get128(), shuffle_xxxx ); + yyyy = spu_shuffle( pnt.get128(), pnt.get128(), shuffle_yyyy ); + zzzz = spu_shuffle( pnt.get128(), pnt.get128(), shuffle_zzzz ); + tmp0 = spu_mul( mCol0.get128(), xxxx ); + tmp1 = spu_mul( mCol1.get128(), yyyy ); + tmp0 = spu_madd( mCol2.get128(), zzzz, tmp0 ); + tmp1 = spu_add( mCol3.get128(), tmp1 ); + res = spu_add( tmp0, tmp1 ); + return Vector4( res ); +} + +inline const Matrix4 Matrix4::operator *( const Matrix4 & mat ) const +{ + return Matrix4( + ( *this * mat.mCol0 ), + ( *this * mat.mCol1 ), + ( *this * mat.mCol2 ), + ( *this * mat.mCol3 ) + ); +} + +inline Matrix4 & Matrix4::operator *=( const Matrix4 & mat ) +{ + *this = *this * mat; + return *this; +} + +inline const Matrix4 Matrix4::operator *( const Transform3 & tfrm ) const +{ + return Matrix4( + ( *this * tfrm.getCol0() ), + ( *this * tfrm.getCol1() ), + ( *this * tfrm.getCol2() ), + ( *this * Point3( tfrm.getCol3() ) ) + ); +} + +inline Matrix4 & Matrix4::operator *=( const Transform3 & tfrm ) +{ + *this = *this * tfrm; + return *this; +} + +inline const Matrix4 mulPerElem( const Matrix4 & mat0, const Matrix4 & mat1 ) +{ + return Matrix4( + mulPerElem( mat0.getCol0(), mat1.getCol0() ), + mulPerElem( mat0.getCol1(), mat1.getCol1() ), + mulPerElem( mat0.getCol2(), mat1.getCol2() ), + mulPerElem( mat0.getCol3(), mat1.getCol3() ) + ); +} + +inline const Matrix4 Matrix4::identity( ) +{ + return Matrix4( + Vector4::xAxis( ), + Vector4::yAxis( ), + Vector4::zAxis( ), + Vector4::wAxis( ) + ); +} + +inline Matrix4 & Matrix4::setUpper3x3( const Matrix3 & mat3 ) +{ + mCol0.setXYZ( mat3.getCol0() ); + mCol1.setXYZ( mat3.getCol1() ); + mCol2.setXYZ( mat3.getCol2() ); + return *this; +} + +inline const Matrix3 Matrix4::getUpper3x3( ) const +{ + return Matrix3( + mCol0.getXYZ( ), + mCol1.getXYZ( ), + mCol2.getXYZ( ) + ); +} + +inline Matrix4 & Matrix4::setTranslation( Vector3 translateVec ) +{ + mCol3.setXYZ( translateVec ); + return *this; +} + +inline const Vector3 Matrix4::getTranslation( ) const +{ + return mCol3.getXYZ( ); +} + +inline const Matrix4 Matrix4::rotationX( float radians ) +{ + vec_float4 s, c, res1, res2; + vec_uint4 select_y, select_z; + vec_float4 zero; + select_y = (vec_uint4)spu_maskb(0x0f00); + select_z = (vec_uint4)spu_maskb(0x00f0); + zero = spu_splats(0.0f); + sincosf4( spu_splats(radians), &s, &c ); + res1 = spu_sel( zero, c, select_y ); + res1 = spu_sel( res1, s, select_z ); + res2 = spu_sel( zero, negatef4(s), select_y ); + res2 = spu_sel( res2, c, select_z ); + return Matrix4( + Vector4::xAxis( ), + Vector4( res1 ), + Vector4( res2 ), + Vector4::wAxis( ) + ); +} + +inline const Matrix4 Matrix4::rotationY( float radians ) +{ + vec_float4 s, c, res0, res2; + vec_uint4 select_x, select_z; + vec_float4 zero; + select_x = (vec_uint4)spu_maskb(0xf000); + select_z = (vec_uint4)spu_maskb(0x00f0); + zero = spu_splats(0.0f); + sincosf4( spu_splats(radians), &s, &c ); + res0 = spu_sel( zero, c, select_x ); + res0 = spu_sel( res0, negatef4(s), select_z ); + res2 = spu_sel( zero, s, select_x ); + res2 = spu_sel( res2, c, select_z ); + return Matrix4( + Vector4( res0 ), + Vector4::yAxis( ), + Vector4( res2 ), + Vector4::wAxis( ) + ); +} + +inline const Matrix4 Matrix4::rotationZ( float radians ) +{ + vec_float4 s, c, res0, res1; + vec_uint4 select_x, select_y; + vec_float4 zero; + select_x = (vec_uint4)spu_maskb(0xf000); + select_y = (vec_uint4)spu_maskb(0x0f00); + zero = spu_splats(0.0f); + sincosf4( spu_splats(radians), &s, &c ); + res0 = spu_sel( zero, c, select_x ); + res0 = spu_sel( res0, s, select_y ); + res1 = spu_sel( zero, negatef4(s), select_x ); + res1 = spu_sel( res1, c, select_y ); + return Matrix4( + Vector4( res0 ), + Vector4( res1 ), + Vector4::zAxis( ), + Vector4::wAxis( ) + ); +} + +inline const Matrix4 Matrix4::rotationZYX( Vector3 radiansXYZ ) +{ + vec_float4 angles, s, negS, c, X0, X1, Y0, Y1, Z0, Z1, tmp; + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + angles = radiansXYZ.get128(); + angles = spu_insert( 0.0f, angles, 3 ); + sincosf4( angles, &s, &c ); + negS = negatef4( s ); + Z0 = spu_shuffle( s, c, _VECTORMATH_SHUF_CZD0 ); + Z1 = spu_shuffle( c, negS, _VECTORMATH_SHUF_CZD0 ); + Y0 = spu_shuffle( negS, c, _VECTORMATH_SHUF_BBY0 ); + Y1 = spu_shuffle( c, s, _VECTORMATH_SHUF_BBY0 ); + X0 = spu_shuffle( s, s, shuffle_xxxx ); + X1 = spu_shuffle( c, c, shuffle_xxxx ); + tmp = spu_mul( Z0, Y1 ); + return Matrix4( + Vector4( spu_mul( Z0, Y0 ) ), + Vector4( spu_madd( Z1, X1, spu_mul( tmp, X0 ) ) ), + Vector4( spu_nmsub( Z1, X0, spu_mul( tmp, X1 ) ) ), + Vector4::wAxis( ) + ); +} + +inline const Matrix4 Matrix4::rotation( float radians, Vector3 unitVec ) +{ + vec_float4 axis, s, c, oneMinusC, axisS, negAxisS, xxxx, yyyy, zzzz, tmp0, tmp1, tmp2, zeroW; + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); + axis = unitVec.get128(); + sincosf4( spu_splats( radians ), &s, &c ); + xxxx = spu_shuffle( axis, axis, shuffle_xxxx ); + yyyy = spu_shuffle( axis, axis, shuffle_yyyy ); + zzzz = spu_shuffle( axis, axis, shuffle_zzzz ); + oneMinusC = spu_sub( spu_splats(1.0f), c ); + axisS = spu_mul( axis, s ); + negAxisS = negatef4( axisS ); + tmp0 = spu_shuffle( axisS, negAxisS, _VECTORMATH_SHUF_0ZB0 ); + tmp1 = spu_shuffle( axisS, negAxisS, _VECTORMATH_SHUF_C0X0 ); + tmp2 = spu_shuffle( axisS, negAxisS, _VECTORMATH_SHUF_YA00 ); + tmp0 = spu_sel( tmp0, c, (vec_uint4)spu_maskb(0xf000) ); + tmp1 = spu_sel( tmp1, c, (vec_uint4)spu_maskb(0x0f00) ); + tmp2 = spu_sel( tmp2, c, (vec_uint4)spu_maskb(0x00f0) ); + zeroW = (vec_float4)spu_maskb(0x000f); + axis = spu_andc( axis, zeroW ); + return Matrix4( + Vector4( spu_madd( spu_mul( axis, xxxx ), oneMinusC, tmp0 ) ), + Vector4( spu_madd( spu_mul( axis, yyyy ), oneMinusC, tmp1 ) ), + Vector4( spu_madd( spu_mul( axis, zzzz ), oneMinusC, tmp2 ) ), + Vector4::wAxis( ) + ); +} + +inline const Matrix4 Matrix4::rotation( Quat unitQuat ) +{ + return Matrix4( Transform3::rotation( unitQuat ) ); +} + +inline const Matrix4 Matrix4::scale( Vector3 scaleVec ) +{ + vec_float4 zero = spu_splats(0.0f); + return Matrix4( + Vector4( spu_sel( zero, scaleVec.get128(), (vec_uint4)spu_maskb(0xf000) ) ), + Vector4( spu_sel( zero, scaleVec.get128(), (vec_uint4)spu_maskb(0x0f00) ) ), + Vector4( spu_sel( zero, scaleVec.get128(), (vec_uint4)spu_maskb(0x00f0) ) ), + Vector4::wAxis( ) + ); +} + +inline const Matrix4 appendScale( const Matrix4 & mat, Vector3 scaleVec ) +{ + return Matrix4( + ( mat.getCol0() * scaleVec.getX( ) ), + ( mat.getCol1() * scaleVec.getY( ) ), + ( mat.getCol2() * scaleVec.getZ( ) ), + mat.getCol3() + ); +} + +inline const Matrix4 prependScale( Vector3 scaleVec, const Matrix4 & mat ) +{ + Vector4 scale4; + scale4 = Vector4( scaleVec, 1.0f ); + return Matrix4( + mulPerElem( mat.getCol0(), scale4 ), + mulPerElem( mat.getCol1(), scale4 ), + mulPerElem( mat.getCol2(), scale4 ), + mulPerElem( mat.getCol3(), scale4 ) + ); +} + +inline const Matrix4 Matrix4::translation( Vector3 translateVec ) +{ + return Matrix4( + Vector4::xAxis( ), + Vector4::yAxis( ), + Vector4::zAxis( ), + Vector4( translateVec, 1.0f ) + ); +} + +inline const Matrix4 Matrix4::lookAt( Point3 eyePos, Point3 lookAtPos, Vector3 upVec ) +{ + Matrix4 m4EyeFrame; + Vector3 v3X, v3Y, v3Z; + v3Y = normalize( upVec ); + v3Z = normalize( ( eyePos - lookAtPos ) ); + v3X = normalize( cross( v3Y, v3Z ) ); + v3Y = cross( v3Z, v3X ); + m4EyeFrame = Matrix4( Vector4( v3X ), Vector4( v3Y ), Vector4( v3Z ), Vector4( eyePos ) ); + return orthoInverse( m4EyeFrame ); +} + +inline const Matrix4 Matrix4::perspective( float fovyRadians, float aspect, float zNear, float zFar ) +{ + float f, rangeInv; + vec_float4 zero, col0, col1, col2, col3; + f = tanf( _VECTORMATH_PI_OVER_2 - fovyRadians * 0.5f ); + rangeInv = 1.0f / ( zNear - zFar ); + zero = spu_splats(0.0f); + col0 = zero; + col1 = zero; + col2 = zero; + col3 = zero; + col0 = spu_insert( f / aspect, col0, 0 ); + col1 = spu_insert( f, col1, 1 ); + col2 = spu_insert( ( zNear + zFar ) * rangeInv, col2, 2 ); + col2 = spu_insert( -1.0f, col2, 3 ); + col3 = spu_insert( zNear * zFar * rangeInv * 2.0f, col3, 2 ); + return Matrix4( + Vector4( col0 ), + Vector4( col1 ), + Vector4( col2 ), + Vector4( col3 ) + ); +} + +inline const Matrix4 Matrix4::frustum( float left, float right, float bottom, float top, float zNear, float zFar ) +{ + /* function implementation based on code from STIDC SDK: */ + /* -------------------------------------------------------------- */ + /* PLEASE DO NOT MODIFY THIS SECTION */ + /* This prolog section is automatically generated. */ + /* */ + /* (C)Copyright */ + /* Sony Computer Entertainment, Inc., */ + /* Toshiba Corporation, */ + /* International Business Machines Corporation, */ + /* 2001,2002. */ + /* S/T/I Confidential Information */ + /* -------------------------------------------------------------- */ + vec_float4 lbf, rtn; + vec_float4 diff, sum, inv_diff; + vec_float4 diagonal, column, near2; + vec_float4 zero = spu_splats(0.0f); + lbf = spu_shuffle( spu_promote(left,0), spu_promote(zFar,0), _VECTORMATH_SHUF_XAYB ); + rtn = spu_shuffle( spu_promote(right,0), spu_promote(zNear,0), _VECTORMATH_SHUF_XAYB ); + lbf = spu_shuffle( lbf, spu_promote(bottom,0), _VECTORMATH_SHUF_XAYB ); + rtn = spu_shuffle( rtn, spu_promote(top,0), _VECTORMATH_SHUF_XAYB ); + diff = spu_sub( rtn, lbf ); + sum = spu_add( rtn, lbf ); + inv_diff = recipf4( diff ); + near2 = spu_splats( zNear ); + near2 = spu_add( near2, near2 ); + diagonal = spu_mul( near2, inv_diff ); + column = spu_mul( sum, inv_diff ); + return Matrix4( + Vector4( spu_sel( zero, diagonal, (vec_uint4)spu_maskb(0xf000) ) ), + Vector4( spu_sel( zero, diagonal, (vec_uint4)spu_maskb(0x0f00) ) ), + Vector4( spu_sel( column, spu_splats(-1.0f), (vec_uint4)spu_maskb(0x000f) ) ), + Vector4( spu_sel( zero, spu_mul( diagonal, spu_splats(zFar) ), (vec_uint4)spu_maskb(0x00f0) ) ) + ); +} + +inline const Matrix4 Matrix4::orthographic( float left, float right, float bottom, float top, float zNear, float zFar ) +{ + /* function implementation based on code from STIDC SDK: */ + /* -------------------------------------------------------------- */ + /* PLEASE DO NOT MODIFY THIS SECTION */ + /* This prolog section is automatically generated. */ + /* */ + /* (C)Copyright */ + /* Sony Computer Entertainment, Inc., */ + /* Toshiba Corporation, */ + /* International Business Machines Corporation, */ + /* 2001,2002. */ + /* S/T/I Confidential Information */ + /* -------------------------------------------------------------- */ + vec_float4 lbf, rtn; + vec_float4 diff, sum, inv_diff, neg_inv_diff; + vec_float4 diagonal, column; + vec_float4 zero = spu_splats(0.0f); + lbf = spu_shuffle( spu_promote(left,0), spu_promote(zFar,0), _VECTORMATH_SHUF_XAYB ); + rtn = spu_shuffle( spu_promote(right,0), spu_promote(zNear,0), _VECTORMATH_SHUF_XAYB ); + lbf = spu_shuffle( lbf, spu_promote(bottom,0), _VECTORMATH_SHUF_XAYB ); + rtn = spu_shuffle( rtn, spu_promote(top,0), _VECTORMATH_SHUF_XAYB ); + diff = spu_sub( rtn, lbf ); + sum = spu_add( rtn, lbf ); + inv_diff = recipf4( diff ); + neg_inv_diff = negatef4( inv_diff ); + diagonal = spu_add( inv_diff, inv_diff ); + column = spu_mul( sum, spu_sel( neg_inv_diff, inv_diff, (vec_uint4)spu_maskb(0x00f0) ) ); + return Matrix4( + Vector4( spu_sel( zero, diagonal, (vec_uint4)spu_maskb(0xf000) ) ), + Vector4( spu_sel( zero, diagonal, (vec_uint4)spu_maskb(0x0f00) ) ), + Vector4( spu_sel( zero, diagonal, (vec_uint4)spu_maskb(0x00f0) ) ), + Vector4( spu_sel( column, spu_splats(1.0f), (vec_uint4)spu_maskb(0x000f) ) ) + ); +} + +inline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, bool select1 ) +{ + return Matrix4( + select( mat0.getCol0(), mat1.getCol0(), select1 ), + select( mat0.getCol1(), mat1.getCol1(), select1 ), + select( mat0.getCol2(), mat1.getCol2(), select1 ), + select( mat0.getCol3(), mat1.getCol3(), select1 ) + ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( const Matrix4 & mat ) +{ + print( mat.getRow( 0 ) ); + print( mat.getRow( 1 ) ); + print( mat.getRow( 2 ) ); + print( mat.getRow( 3 ) ); +} + +inline void print( const Matrix4 & mat, const char * name ) +{ + printf("%s:\n", name); + print( mat ); +} + +#endif + +inline Transform3::Transform3( const Transform3 & tfrm ) +{ + mCol0 = tfrm.mCol0; + mCol1 = tfrm.mCol1; + mCol2 = tfrm.mCol2; + mCol3 = tfrm.mCol3; +} + +inline Transform3::Transform3( float scalar ) +{ + mCol0 = Vector3( scalar ); + mCol1 = Vector3( scalar ); + mCol2 = Vector3( scalar ); + mCol3 = Vector3( scalar ); +} + +inline Transform3::Transform3( Vector3 _col0, Vector3 _col1, Vector3 _col2, Vector3 _col3 ) +{ + mCol0 = _col0; + mCol1 = _col1; + mCol2 = _col2; + mCol3 = _col3; +} + +inline Transform3::Transform3( const Matrix3 & tfrm, Vector3 translateVec ) +{ + this->setUpper3x3( tfrm ); + this->setTranslation( translateVec ); +} + +inline Transform3::Transform3( Quat unitQuat, Vector3 translateVec ) +{ + this->setUpper3x3( Matrix3( unitQuat ) ); + this->setTranslation( translateVec ); +} + +inline Transform3 & Transform3::setCol0( Vector3 _col0 ) +{ + mCol0 = _col0; + return *this; +} + +inline Transform3 & Transform3::setCol1( Vector3 _col1 ) +{ + mCol1 = _col1; + return *this; +} + +inline Transform3 & Transform3::setCol2( Vector3 _col2 ) +{ + mCol2 = _col2; + return *this; +} + +inline Transform3 & Transform3::setCol3( Vector3 _col3 ) +{ + mCol3 = _col3; + return *this; +} + +inline Transform3 & Transform3::setCol( int col, Vector3 vec ) +{ + *(&mCol0 + col) = vec; + return *this; +} + +inline Transform3 & Transform3::setRow( int row, Vector4 vec ) +{ + mCol0.setElem( row, vec.getElem( 0 ) ); + mCol1.setElem( row, vec.getElem( 1 ) ); + mCol2.setElem( row, vec.getElem( 2 ) ); + mCol3.setElem( row, vec.getElem( 3 ) ); + return *this; +} + +inline Transform3 & Transform3::setElem( int col, int row, float val ) +{ + (*this)[col].setElem(row, val); + return *this; +} + +inline float Transform3::getElem( int col, int row ) const +{ + return this->getCol( col ).getElem( row ); +} + +inline const Vector3 Transform3::getCol0( ) const +{ + return mCol0; +} + +inline const Vector3 Transform3::getCol1( ) const +{ + return mCol1; +} + +inline const Vector3 Transform3::getCol2( ) const +{ + return mCol2; +} + +inline const Vector3 Transform3::getCol3( ) const +{ + return mCol3; +} + +inline const Vector3 Transform3::getCol( int col ) const +{ + return *(&mCol0 + col); +} + +inline const Vector4 Transform3::getRow( int row ) const +{ + return Vector4( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ), mCol3.getElem( row ) ); +} + +inline Vector3 & Transform3::operator []( int col ) +{ + return *(&mCol0 + col); +} + +inline const Vector3 Transform3::operator []( int col ) const +{ + return *(&mCol0 + col); +} + +inline Transform3 & Transform3::operator =( const Transform3 & tfrm ) +{ + mCol0 = tfrm.mCol0; + mCol1 = tfrm.mCol1; + mCol2 = tfrm.mCol2; + mCol3 = tfrm.mCol3; + return *this; +} + +inline const Transform3 inverse( const Transform3 & tfrm ) +{ + vec_float4 inv0, inv1, inv2, inv3; + vec_float4 tmp0, tmp1, tmp2, tmp3, tmp4, dot, invdet; + vec_float4 xxxx, yyyy, zzzz; + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); + tmp2 = _vmathVfCross( tfrm.getCol0().get128(), tfrm.getCol1().get128() ); + tmp0 = _vmathVfCross( tfrm.getCol1().get128(), tfrm.getCol2().get128() ); + tmp1 = _vmathVfCross( tfrm.getCol2().get128(), tfrm.getCol0().get128() ); + inv3 = negatef4( tfrm.getCol3().get128() ); + dot = _vmathVfDot3( tmp2, tfrm.getCol2().get128() ); + dot = spu_shuffle( dot, dot, shuffle_xxxx ); + invdet = recipf4( dot ); + tmp3 = spu_shuffle( tmp0, tmp2, _VECTORMATH_SHUF_XAYB ); + tmp4 = spu_shuffle( tmp0, tmp2, _VECTORMATH_SHUF_ZCWD ); + inv0 = spu_shuffle( tmp3, tmp1, _VECTORMATH_SHUF_XAYB ); + xxxx = spu_shuffle( inv3, inv3, shuffle_xxxx ); + inv1 = spu_shuffle( tmp3, tmp1, _VECTORMATH_SHUF_ZBW0 ); + inv2 = spu_shuffle( tmp4, tmp1, _VECTORMATH_SHUF_XCY0 ); + yyyy = spu_shuffle( inv3, inv3, shuffle_yyyy ); + zzzz = spu_shuffle( inv3, inv3, shuffle_zzzz ); + inv3 = spu_mul( inv0, xxxx ); + inv3 = spu_madd( inv1, yyyy, inv3 ); + inv3 = spu_madd( inv2, zzzz, inv3 ); + inv0 = spu_mul( inv0, invdet ); + inv1 = spu_mul( inv1, invdet ); + inv2 = spu_mul( inv2, invdet ); + inv3 = spu_mul( inv3, invdet ); + return Transform3( + Vector3( inv0 ), + Vector3( inv1 ), + Vector3( inv2 ), + Vector3( inv3 ) + ); +} + +inline const Transform3 orthoInverse( const Transform3 & tfrm ) +{ + vec_float4 inv0, inv1, inv2, inv3; + vec_float4 tmp0, tmp1; + vec_float4 xxxx, yyyy, zzzz; + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); + tmp0 = spu_shuffle( tfrm.getCol0().get128(), tfrm.getCol2().get128(), _VECTORMATH_SHUF_XAYB ); + tmp1 = spu_shuffle( tfrm.getCol0().get128(), tfrm.getCol2().get128(), _VECTORMATH_SHUF_ZCWD ); + inv3 = negatef4( tfrm.getCol3().get128() ); + inv0 = spu_shuffle( tmp0, tfrm.getCol1().get128(), _VECTORMATH_SHUF_XAYB ); + xxxx = spu_shuffle( inv3, inv3, shuffle_xxxx ); + inv1 = spu_shuffle( tmp0, tfrm.getCol1().get128(), _VECTORMATH_SHUF_ZBW0 ); + inv2 = spu_shuffle( tmp1, tfrm.getCol1().get128(), _VECTORMATH_SHUF_XCY0 ); + yyyy = spu_shuffle( inv3, inv3, shuffle_yyyy ); + zzzz = spu_shuffle( inv3, inv3, shuffle_zzzz ); + inv3 = spu_mul( inv0, xxxx ); + inv3 = spu_madd( inv1, yyyy, inv3 ); + inv3 = spu_madd( inv2, zzzz, inv3 ); + return Transform3( + Vector3( inv0 ), + Vector3( inv1 ), + Vector3( inv2 ), + Vector3( inv3 ) + ); +} + +inline const Transform3 absPerElem( const Transform3 & tfrm ) +{ + return Transform3( + absPerElem( tfrm.getCol0() ), + absPerElem( tfrm.getCol1() ), + absPerElem( tfrm.getCol2() ), + absPerElem( tfrm.getCol3() ) + ); +} + +inline const Vector3 Transform3::operator *( Vector3 vec ) const +{ + vec_float4 res; + vec_float4 xxxx, yyyy, zzzz; + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); + xxxx = spu_shuffle( vec.get128(), vec.get128(), shuffle_xxxx ); + yyyy = spu_shuffle( vec.get128(), vec.get128(), shuffle_yyyy ); + zzzz = spu_shuffle( vec.get128(), vec.get128(), shuffle_zzzz ); + res = spu_mul( mCol0.get128(), xxxx ); + res = spu_madd( mCol1.get128(), yyyy, res ); + res = spu_madd( mCol2.get128(), zzzz, res ); + return Vector3( res ); +} + +inline const Point3 Transform3::operator *( Point3 pnt ) const +{ + vec_float4 tmp0, tmp1, res; + vec_float4 xxxx, yyyy, zzzz; + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); + xxxx = spu_shuffle( pnt.get128(), pnt.get128(), shuffle_xxxx ); + yyyy = spu_shuffle( pnt.get128(), pnt.get128(), shuffle_yyyy ); + zzzz = spu_shuffle( pnt.get128(), pnt.get128(), shuffle_zzzz ); + tmp0 = spu_mul( mCol0.get128(), xxxx ); + tmp1 = spu_mul( mCol1.get128(), yyyy ); + tmp0 = spu_madd( mCol2.get128(), zzzz, tmp0 ); + tmp1 = spu_add( mCol3.get128(), tmp1 ); + res = spu_add( tmp0, tmp1 ); + return Point3( res ); +} + +inline const Transform3 Transform3::operator *( const Transform3 & tfrm ) const +{ + return Transform3( + ( *this * tfrm.mCol0 ), + ( *this * tfrm.mCol1 ), + ( *this * tfrm.mCol2 ), + Vector3( ( *this * Point3( tfrm.mCol3 ) ) ) + ); +} + +inline Transform3 & Transform3::operator *=( const Transform3 & tfrm ) +{ + *this = *this * tfrm; + return *this; +} + +inline const Transform3 mulPerElem( const Transform3 & tfrm0, const Transform3 & tfrm1 ) +{ + return Transform3( + mulPerElem( tfrm0.getCol0(), tfrm1.getCol0() ), + mulPerElem( tfrm0.getCol1(), tfrm1.getCol1() ), + mulPerElem( tfrm0.getCol2(), tfrm1.getCol2() ), + mulPerElem( tfrm0.getCol3(), tfrm1.getCol3() ) + ); +} + +inline const Transform3 Transform3::identity( ) +{ + return Transform3( + Vector3::xAxis( ), + Vector3::yAxis( ), + Vector3::zAxis( ), + Vector3( 0.0f ) + ); +} + +inline Transform3 & Transform3::setUpper3x3( const Matrix3 & tfrm ) +{ + mCol0 = tfrm.getCol0(); + mCol1 = tfrm.getCol1(); + mCol2 = tfrm.getCol2(); + return *this; +} + +inline const Matrix3 Transform3::getUpper3x3( ) const +{ + return Matrix3( mCol0, mCol1, mCol2 ); +} + +inline Transform3 & Transform3::setTranslation( Vector3 translateVec ) +{ + mCol3 = translateVec; + return *this; +} + +inline const Vector3 Transform3::getTranslation( ) const +{ + return mCol3; +} + +inline const Transform3 Transform3::rotationX( float radians ) +{ + vec_float4 s, c, res1, res2; + vec_uint4 select_y, select_z; + vec_float4 zero; + select_y = (vec_uint4)spu_maskb(0x0f00); + select_z = (vec_uint4)spu_maskb(0x00f0); + zero = spu_splats(0.0f); + sincosf4( spu_splats(radians), &s, &c ); + res1 = spu_sel( zero, c, select_y ); + res1 = spu_sel( res1, s, select_z ); + res2 = spu_sel( zero, negatef4(s), select_y ); + res2 = spu_sel( res2, c, select_z ); + return Transform3( + Vector3::xAxis( ), + Vector3( res1 ), + Vector3( res2 ), + Vector3( 0.0f ) + ); +} + +inline const Transform3 Transform3::rotationY( float radians ) +{ + vec_float4 s, c, res0, res2; + vec_uint4 select_x, select_z; + vec_float4 zero; + select_x = (vec_uint4)spu_maskb(0xf000); + select_z = (vec_uint4)spu_maskb(0x00f0); + zero = spu_splats(0.0f); + sincosf4( spu_splats(radians), &s, &c ); + res0 = spu_sel( zero, c, select_x ); + res0 = spu_sel( res0, negatef4(s), select_z ); + res2 = spu_sel( zero, s, select_x ); + res2 = spu_sel( res2, c, select_z ); + return Transform3( + Vector3( res0 ), + Vector3::yAxis( ), + Vector3( res2 ), + Vector3( 0.0f ) + ); +} + +inline const Transform3 Transform3::rotationZ( float radians ) +{ + vec_float4 s, c, res0, res1; + vec_uint4 select_x, select_y; + vec_float4 zero; + select_x = (vec_uint4)spu_maskb(0xf000); + select_y = (vec_uint4)spu_maskb(0x0f00); + zero = spu_splats(0.0f); + sincosf4( spu_splats(radians), &s, &c ); + res0 = spu_sel( zero, c, select_x ); + res0 = spu_sel( res0, s, select_y ); + res1 = spu_sel( zero, negatef4(s), select_x ); + res1 = spu_sel( res1, c, select_y ); + return Transform3( + Vector3( res0 ), + Vector3( res1 ), + Vector3::zAxis( ), + Vector3( 0.0f ) + ); +} + +inline const Transform3 Transform3::rotationZYX( Vector3 radiansXYZ ) +{ + vec_float4 angles, s, negS, c, X0, X1, Y0, Y1, Z0, Z1, tmp; + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + angles = radiansXYZ.get128(); + angles = spu_insert( 0.0f, angles, 3 ); + sincosf4( angles, &s, &c ); + negS = negatef4( s ); + Z0 = spu_shuffle( s, c, _VECTORMATH_SHUF_CZD0 ); + Z1 = spu_shuffle( c, negS, _VECTORMATH_SHUF_CZD0 ); + Y0 = spu_shuffle( negS, c, _VECTORMATH_SHUF_BBY0 ); + Y1 = spu_shuffle( c, s, _VECTORMATH_SHUF_BBY0 ); + X0 = spu_shuffle( s, s, shuffle_xxxx ); + X1 = spu_shuffle( c, c, shuffle_xxxx ); + tmp = spu_mul( Z0, Y1 ); + return Transform3( + Vector3( spu_mul( Z0, Y0 ) ), + Vector3( spu_madd( Z1, X1, spu_mul( tmp, X0 ) ) ), + Vector3( spu_nmsub( Z1, X0, spu_mul( tmp, X1 ) ) ), + Vector3( 0.0f ) + ); +} + +inline const Transform3 Transform3::rotation( float radians, Vector3 unitVec ) +{ + return Transform3( Matrix3::rotation( radians, unitVec ), Vector3( 0.0f ) ); +} + +inline const Transform3 Transform3::rotation( Quat unitQuat ) +{ + return Transform3( Matrix3( unitQuat ), Vector3( 0.0f ) ); +} + +inline const Transform3 Transform3::scale( Vector3 scaleVec ) +{ + vec_float4 zero = spu_splats(0.0f); + return Transform3( + Vector3( spu_sel( zero, scaleVec.get128(), (vec_uint4)spu_maskb(0xf000) ) ), + Vector3( spu_sel( zero, scaleVec.get128(), (vec_uint4)spu_maskb(0x0f00) ) ), + Vector3( spu_sel( zero, scaleVec.get128(), (vec_uint4)spu_maskb(0x00f0) ) ), + Vector3( 0.0f ) + ); +} + +inline const Transform3 appendScale( const Transform3 & tfrm, Vector3 scaleVec ) +{ + return Transform3( + ( tfrm.getCol0() * scaleVec.getX( ) ), + ( tfrm.getCol1() * scaleVec.getY( ) ), + ( tfrm.getCol2() * scaleVec.getZ( ) ), + tfrm.getCol3() + ); +} + +inline const Transform3 prependScale( Vector3 scaleVec, const Transform3 & tfrm ) +{ + return Transform3( + mulPerElem( tfrm.getCol0(), scaleVec ), + mulPerElem( tfrm.getCol1(), scaleVec ), + mulPerElem( tfrm.getCol2(), scaleVec ), + mulPerElem( tfrm.getCol3(), scaleVec ) + ); +} + +inline const Transform3 Transform3::translation( Vector3 translateVec ) +{ + return Transform3( + Vector3::xAxis( ), + Vector3::yAxis( ), + Vector3::zAxis( ), + translateVec + ); +} + +inline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, bool select1 ) +{ + return Transform3( + select( tfrm0.getCol0(), tfrm1.getCol0(), select1 ), + select( tfrm0.getCol1(), tfrm1.getCol1(), select1 ), + select( tfrm0.getCol2(), tfrm1.getCol2(), select1 ), + select( tfrm0.getCol3(), tfrm1.getCol3(), select1 ) + ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( const Transform3 & tfrm ) +{ + print( tfrm.getRow( 0 ) ); + print( tfrm.getRow( 1 ) ); + print( tfrm.getRow( 2 ) ); +} + +inline void print( const Transform3 & tfrm, const char * name ) +{ + printf("%s:\n", name); + print( tfrm ); +} + +#endif + +inline Quat::Quat( const Matrix3 & tfrm ) +{ + vec_float4 res; + vec_float4 col0, col1, col2; + vec_float4 xx_yy, xx_yy_zz_xx, yy_zz_xx_yy, zz_xx_yy_zz, diagSum, diagDiff; + vec_float4 zy_xz_yx, yz_zx_xy, sum, diff; + vec_float4 radicand, invSqrt, scale; + vec_float4 res0, res1, res2, res3; + vec_float4 xx, yy, zz; + vec_uint4 select_x = (vec_uint4)spu_maskb( 0xf000 ); + vec_uint4 select_y = (vec_uint4)spu_maskb( 0x0f00 ); + vec_uint4 select_z = (vec_uint4)spu_maskb( 0x00f0 ); + vec_uint4 select_w = (vec_uint4)spu_maskb( 0x000f ); + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((unsigned int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((unsigned int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((unsigned int)0x08090a0b); + vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((unsigned int)0x0c0d0e0f); + + col0 = tfrm.getCol0().get128(); + col1 = tfrm.getCol1().get128(); + col2 = tfrm.getCol2().get128(); + + /* four cases: */ + /* trace > 0 */ + /* else */ + /* xx largest diagonal element */ + /* yy largest diagonal element */ + /* zz largest diagonal element */ + + /* compute quaternion for each case */ + + xx_yy = spu_sel( col0, col1, select_y ); + xx_yy_zz_xx = spu_shuffle( xx_yy, col2, _VECTORMATH_SHUF_XYCX ); + yy_zz_xx_yy = spu_shuffle( xx_yy, col2, _VECTORMATH_SHUF_YCXY ); + zz_xx_yy_zz = spu_shuffle( xx_yy, col2, _VECTORMATH_SHUF_CXYC ); + + diagSum = spu_add( spu_add( xx_yy_zz_xx, yy_zz_xx_yy ), zz_xx_yy_zz ); + diagDiff = spu_sub( spu_sub( xx_yy_zz_xx, yy_zz_xx_yy ), zz_xx_yy_zz ); + radicand = spu_add( spu_sel( diagDiff, diagSum, select_w ), spu_splats(1.0f) ); + invSqrt = rsqrtf4( radicand ); + + zy_xz_yx = spu_sel( col0, col1, select_z ); + zy_xz_yx = spu_shuffle( zy_xz_yx, col2, _VECTORMATH_SHUF_ZAY0 ); + yz_zx_xy = spu_sel( col0, col1, select_x ); + yz_zx_xy = spu_shuffle( yz_zx_xy, col2, _VECTORMATH_SHUF_BZX0 ); + + sum = spu_add( zy_xz_yx, yz_zx_xy ); + diff = spu_sub( zy_xz_yx, yz_zx_xy ); + + scale = spu_mul( invSqrt, spu_splats(0.5f) ); + res0 = spu_shuffle( sum, diff, _VECTORMATH_SHUF_0ZYA ); + res1 = spu_shuffle( sum, diff, _VECTORMATH_SHUF_Z0XB ); + res2 = spu_shuffle( sum, diff, _VECTORMATH_SHUF_YX0C ); + res3 = diff; + res0 = spu_sel( res0, radicand, select_x ); + res1 = spu_sel( res1, radicand, select_y ); + res2 = spu_sel( res2, radicand, select_z ); + res3 = spu_sel( res3, radicand, select_w ); + res0 = spu_mul( res0, spu_shuffle( scale, scale, shuffle_xxxx ) ); + res1 = spu_mul( res1, spu_shuffle( scale, scale, shuffle_yyyy ) ); + res2 = spu_mul( res2, spu_shuffle( scale, scale, shuffle_zzzz ) ); + res3 = spu_mul( res3, spu_shuffle( scale, scale, shuffle_wwww ) ); + + /* determine case and select answer */ + + xx = spu_shuffle( col0, col0, shuffle_xxxx ); + yy = spu_shuffle( col1, col1, shuffle_yyyy ); + zz = spu_shuffle( col2, col2, shuffle_zzzz ); + res = spu_sel( res0, res1, spu_cmpgt( yy, xx ) ); + res = spu_sel( res, res2, spu_and( spu_cmpgt( zz, xx ), spu_cmpgt( zz, yy ) ) ); + res = spu_sel( res, res3, spu_cmpgt( spu_shuffle( diagSum, diagSum, shuffle_xxxx ), spu_splats(0.0f) ) ); + mVec128 = res; +} + +inline const Matrix3 outer( Vector3 tfrm0, Vector3 tfrm1 ) +{ + return Matrix3( + ( tfrm0 * tfrm1.getX( ) ), + ( tfrm0 * tfrm1.getY( ) ), + ( tfrm0 * tfrm1.getZ( ) ) + ); +} + +inline const Matrix4 outer( Vector4 tfrm0, Vector4 tfrm1 ) +{ + return Matrix4( + ( tfrm0 * tfrm1.getX( ) ), + ( tfrm0 * tfrm1.getY( ) ), + ( tfrm0 * tfrm1.getZ( ) ), + ( tfrm0 * tfrm1.getW( ) ) + ); +} + +inline const Vector3 rowMul( Vector3 vec, const Matrix3 & mat ) +{ + vec_float4 tmp0, tmp1, mcol0, mcol1, mcol2, res; + vec_float4 xxxx, yyyy, zzzz; + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); + tmp0 = spu_shuffle( mat.getCol0().get128(), mat.getCol2().get128(), _VECTORMATH_SHUF_XAYB ); + tmp1 = spu_shuffle( mat.getCol0().get128(), mat.getCol2().get128(), _VECTORMATH_SHUF_ZCWD ); + xxxx = spu_shuffle( vec.get128(), vec.get128(), shuffle_xxxx ); + mcol0 = spu_shuffle( tmp0, mat.getCol1().get128(), _VECTORMATH_SHUF_XAYB ); + mcol1 = spu_shuffle( tmp0, mat.getCol1().get128(), _VECTORMATH_SHUF_ZBW0 ); + mcol2 = spu_shuffle( tmp1, mat.getCol1().get128(), _VECTORMATH_SHUF_XCY0 ); + yyyy = spu_shuffle( vec.get128(), vec.get128(), shuffle_yyyy ); + res = spu_mul( mcol0, xxxx ); + zzzz = spu_shuffle( vec.get128(), vec.get128(), shuffle_zzzz ); + res = spu_madd( mcol1, yyyy, res ); + res = spu_madd( mcol2, zzzz, res ); + return Vector3( res ); +} + +inline const Matrix3 crossMatrix( Vector3 vec ) +{ + vec_float4 neg, res0, res1, res2; + neg = negatef4( vec.get128() ); + res0 = spu_shuffle( vec.get128(), neg, _VECTORMATH_SHUF_0ZB0 ); + res1 = spu_shuffle( vec.get128(), neg, _VECTORMATH_SHUF_C0X0 ); + res2 = spu_shuffle( vec.get128(), neg, _VECTORMATH_SHUF_YA00 ); + return Matrix3( + Vector3( res0 ), + Vector3( res1 ), + Vector3( res2 ) + ); +} + +inline const Matrix3 crossMatrixMul( Vector3 vec, const Matrix3 & mat ) +{ + return Matrix3( cross( vec, mat.getCol0() ), cross( vec, mat.getCol1() ), cross( vec, mat.getCol2() ) ); +} + +} // namespace Aos +} // namespace Vectormath + +#endif diff --git a/vectormathlibrary/include/vectormath/spu/cpp/mat_soa.h b/vectormathlibrary/include/vectormath/spu/cpp/mat_soa.h new file mode 100644 index 000000000..8c884d593 --- /dev/null +++ b/vectormathlibrary/include/vectormath/spu/cpp/mat_soa.h @@ -0,0 +1,1744 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_MAT_SOA_CPP_H +#define _VECTORMATH_MAT_SOA_CPP_H + +namespace Vectormath { +namespace Soa { + +//----------------------------------------------------------------------------- +// Constants + +#define _VECTORMATH_PI_OVER_2 1.570796327f + +//----------------------------------------------------------------------------- +// Definitions + +inline Matrix3::Matrix3( const Matrix3 & mat ) +{ + mCol0 = mat.mCol0; + mCol1 = mat.mCol1; + mCol2 = mat.mCol2; +} + +inline Matrix3::Matrix3( vec_float4 scalar ) +{ + mCol0 = Vector3( scalar ); + mCol1 = Vector3( scalar ); + mCol2 = Vector3( scalar ); +} + +inline Matrix3::Matrix3( const Quat & unitQuat ) +{ + vec_float4 qx, qy, qz, qw, qx2, qy2, qz2, qxqx2, qyqy2, qzqz2, qxqy2, qyqz2, qzqw2, qxqz2, qyqw2, qxqw2; + qx = unitQuat.getX(); + qy = unitQuat.getY(); + qz = unitQuat.getZ(); + qw = unitQuat.getW(); + qx2 = spu_add( qx, qx ); + qy2 = spu_add( qy, qy ); + qz2 = spu_add( qz, qz ); + qxqx2 = spu_mul( qx, qx2 ); + qxqy2 = spu_mul( qx, qy2 ); + qxqz2 = spu_mul( qx, qz2 ); + qxqw2 = spu_mul( qw, qx2 ); + qyqy2 = spu_mul( qy, qy2 ); + qyqz2 = spu_mul( qy, qz2 ); + qyqw2 = spu_mul( qw, qy2 ); + qzqz2 = spu_mul( qz, qz2 ); + qzqw2 = spu_mul( qw, qz2 ); + mCol0 = Vector3( spu_sub( spu_sub( spu_splats(1.0f), qyqy2 ), qzqz2 ), spu_add( qxqy2, qzqw2 ), spu_sub( qxqz2, qyqw2 ) ); + mCol1 = Vector3( spu_sub( qxqy2, qzqw2 ), spu_sub( spu_sub( spu_splats(1.0f), qxqx2 ), qzqz2 ), spu_add( qyqz2, qxqw2 ) ); + mCol2 = Vector3( spu_add( qxqz2, qyqw2 ), spu_sub( qyqz2, qxqw2 ), spu_sub( spu_sub( spu_splats(1.0f), qxqx2 ), qyqy2 ) ); +} + +inline Matrix3::Matrix3( const Vector3 & _col0, const Vector3 & _col1, const Vector3 & _col2 ) +{ + mCol0 = _col0; + mCol1 = _col1; + mCol2 = _col2; +} + +inline Matrix3::Matrix3( const Aos::Matrix3 & mat ) +{ + mCol0 = Vector3( mat.getCol0() ); + mCol1 = Vector3( mat.getCol1() ); + mCol2 = Vector3( mat.getCol2() ); +} + +inline Matrix3::Matrix3( const Aos::Matrix3 & mat0, const Aos::Matrix3 & mat1, const Aos::Matrix3 & mat2, const Aos::Matrix3 & mat3 ) +{ + mCol0 = Vector3( mat0.getCol0(), mat1.getCol0(), mat2.getCol0(), mat3.getCol0() ); + mCol1 = Vector3( mat0.getCol1(), mat1.getCol1(), mat2.getCol1(), mat3.getCol1() ); + mCol2 = Vector3( mat0.getCol2(), mat1.getCol2(), mat2.getCol2(), mat3.getCol2() ); +} + +inline void Matrix3::get4Aos( Aos::Matrix3 & result0, Aos::Matrix3 & result1, Aos::Matrix3 & result2, Aos::Matrix3 & result3 ) const +{ + Aos::Vector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3; + mCol0.get4Aos( tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3 ); + result0.setCol0( tmpV3_0 ); + result1.setCol0( tmpV3_1 ); + result2.setCol0( tmpV3_2 ); + result3.setCol0( tmpV3_3 ); + mCol1.get4Aos( tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3 ); + result0.setCol1( tmpV3_0 ); + result1.setCol1( tmpV3_1 ); + result2.setCol1( tmpV3_2 ); + result3.setCol1( tmpV3_3 ); + mCol2.get4Aos( tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3 ); + result0.setCol2( tmpV3_0 ); + result1.setCol2( tmpV3_1 ); + result2.setCol2( tmpV3_2 ); + result3.setCol2( tmpV3_3 ); +} + +inline Matrix3 & Matrix3::setCol0( const Vector3 & _col0 ) +{ + mCol0 = _col0; + return *this; +} + +inline Matrix3 & Matrix3::setCol1( const Vector3 & _col1 ) +{ + mCol1 = _col1; + return *this; +} + +inline Matrix3 & Matrix3::setCol2( const Vector3 & _col2 ) +{ + mCol2 = _col2; + return *this; +} + +inline Matrix3 & Matrix3::setCol( int col, const Vector3 & vec ) +{ + *(&mCol0 + col) = vec; + return *this; +} + +inline Matrix3 & Matrix3::setRow( int row, const Vector3 & vec ) +{ + mCol0.setElem( row, vec.getElem( 0 ) ); + mCol1.setElem( row, vec.getElem( 1 ) ); + mCol2.setElem( row, vec.getElem( 2 ) ); + return *this; +} + +inline Matrix3 & Matrix3::setElem( int col, int row, vec_float4 val ) +{ + Vector3 tmpV3_0; + tmpV3_0 = this->getCol( col ); + tmpV3_0.setElem( row, val ); + this->setCol( col, tmpV3_0 ); + return *this; +} + +inline vec_float4 Matrix3::getElem( int col, int row ) const +{ + return this->getCol( col ).getElem( row ); +} + +inline const Vector3 Matrix3::getCol0( ) const +{ + return mCol0; +} + +inline const Vector3 Matrix3::getCol1( ) const +{ + return mCol1; +} + +inline const Vector3 Matrix3::getCol2( ) const +{ + return mCol2; +} + +inline const Vector3 Matrix3::getCol( int col ) const +{ + return *(&mCol0 + col); +} + +inline const Vector3 Matrix3::getRow( int row ) const +{ + return Vector3( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ) ); +} + +inline Vector3 & Matrix3::operator []( int col ) +{ + return *(&mCol0 + col); +} + +inline const Vector3 Matrix3::operator []( int col ) const +{ + return *(&mCol0 + col); +} + +inline Matrix3 & Matrix3::operator =( const Matrix3 & mat ) +{ + mCol0 = mat.mCol0; + mCol1 = mat.mCol1; + mCol2 = mat.mCol2; + return *this; +} + +inline const Matrix3 transpose( const Matrix3 & mat ) +{ + return Matrix3( + Vector3( mat.getCol0().getX(), mat.getCol1().getX(), mat.getCol2().getX() ), + Vector3( mat.getCol0().getY(), mat.getCol1().getY(), mat.getCol2().getY() ), + Vector3( mat.getCol0().getZ(), mat.getCol1().getZ(), mat.getCol2().getZ() ) + ); +} + +inline const Matrix3 inverse( const Matrix3 & mat ) +{ + Vector3 tmp0, tmp1, tmp2; + vec_float4 detinv; + tmp0 = cross( mat.getCol1(), mat.getCol2() ); + tmp1 = cross( mat.getCol2(), mat.getCol0() ); + tmp2 = cross( mat.getCol0(), mat.getCol1() ); + detinv = recipf4( dot( mat.getCol2(), tmp2 ) ); + return Matrix3( + Vector3( spu_mul( tmp0.getX(), detinv ), spu_mul( tmp1.getX(), detinv ), spu_mul( tmp2.getX(), detinv ) ), + Vector3( spu_mul( tmp0.getY(), detinv ), spu_mul( tmp1.getY(), detinv ), spu_mul( tmp2.getY(), detinv ) ), + Vector3( spu_mul( tmp0.getZ(), detinv ), spu_mul( tmp1.getZ(), detinv ), spu_mul( tmp2.getZ(), detinv ) ) + ); +} + +inline vec_float4 determinant( const Matrix3 & mat ) +{ + return dot( mat.getCol2(), cross( mat.getCol0(), mat.getCol1() ) ); +} + +inline const Matrix3 Matrix3::operator +( const Matrix3 & mat ) const +{ + return Matrix3( + ( mCol0 + mat.mCol0 ), + ( mCol1 + mat.mCol1 ), + ( mCol2 + mat.mCol2 ) + ); +} + +inline const Matrix3 Matrix3::operator -( const Matrix3 & mat ) const +{ + return Matrix3( + ( mCol0 - mat.mCol0 ), + ( mCol1 - mat.mCol1 ), + ( mCol2 - mat.mCol2 ) + ); +} + +inline Matrix3 & Matrix3::operator +=( const Matrix3 & mat ) +{ + *this = *this + mat; + return *this; +} + +inline Matrix3 & Matrix3::operator -=( const Matrix3 & mat ) +{ + *this = *this - mat; + return *this; +} + +inline const Matrix3 Matrix3::operator -( ) const +{ + return Matrix3( + ( -mCol0 ), + ( -mCol1 ), + ( -mCol2 ) + ); +} + +inline const Matrix3 absPerElem( const Matrix3 & mat ) +{ + return Matrix3( + absPerElem( mat.getCol0() ), + absPerElem( mat.getCol1() ), + absPerElem( mat.getCol2() ) + ); +} + +inline const Matrix3 Matrix3::operator *( vec_float4 scalar ) const +{ + return Matrix3( + ( mCol0 * scalar ), + ( mCol1 * scalar ), + ( mCol2 * scalar ) + ); +} + +inline Matrix3 & Matrix3::operator *=( vec_float4 scalar ) +{ + *this = *this * scalar; + return *this; +} + +inline const Matrix3 operator *( vec_float4 scalar, const Matrix3 & mat ) +{ + return mat * scalar; +} + +inline const Vector3 Matrix3::operator *( const Vector3 & vec ) const +{ + return Vector3( + spu_add( spu_add( spu_mul( mCol0.getX(), vec.getX() ), spu_mul( mCol1.getX(), vec.getY() ) ), spu_mul( mCol2.getX(), vec.getZ() ) ), + spu_add( spu_add( spu_mul( mCol0.getY(), vec.getX() ), spu_mul( mCol1.getY(), vec.getY() ) ), spu_mul( mCol2.getY(), vec.getZ() ) ), + spu_add( spu_add( spu_mul( mCol0.getZ(), vec.getX() ), spu_mul( mCol1.getZ(), vec.getY() ) ), spu_mul( mCol2.getZ(), vec.getZ() ) ) + ); +} + +inline const Matrix3 Matrix3::operator *( const Matrix3 & mat ) const +{ + return Matrix3( + ( *this * mat.mCol0 ), + ( *this * mat.mCol1 ), + ( *this * mat.mCol2 ) + ); +} + +inline Matrix3 & Matrix3::operator *=( const Matrix3 & mat ) +{ + *this = *this * mat; + return *this; +} + +inline const Matrix3 mulPerElem( const Matrix3 & mat0, const Matrix3 & mat1 ) +{ + return Matrix3( + mulPerElem( mat0.getCol0(), mat1.getCol0() ), + mulPerElem( mat0.getCol1(), mat1.getCol1() ), + mulPerElem( mat0.getCol2(), mat1.getCol2() ) + ); +} + +inline const Matrix3 Matrix3::identity( ) +{ + return Matrix3( + Vector3::xAxis( ), + Vector3::yAxis( ), + Vector3::zAxis( ) + ); +} + +inline const Matrix3 Matrix3::rotationX( vec_float4 radians ) +{ + vec_float4 s, c; + sincosf4( radians, &s, &c ); + return Matrix3( + Vector3::xAxis( ), + Vector3( spu_splats(0.0f), c, s ), + Vector3( spu_splats(0.0f), negatef4( s ), c ) + ); +} + +inline const Matrix3 Matrix3::rotationY( vec_float4 radians ) +{ + vec_float4 s, c; + sincosf4( radians, &s, &c ); + return Matrix3( + Vector3( c, spu_splats(0.0f), negatef4( s ) ), + Vector3::yAxis( ), + Vector3( s, spu_splats(0.0f), c ) + ); +} + +inline const Matrix3 Matrix3::rotationZ( vec_float4 radians ) +{ + vec_float4 s, c; + sincosf4( radians, &s, &c ); + return Matrix3( + Vector3( c, s, spu_splats(0.0f) ), + Vector3( negatef4( s ), c, spu_splats(0.0f) ), + Vector3::zAxis( ) + ); +} + +inline const Matrix3 Matrix3::rotationZYX( const Vector3 & radiansXYZ ) +{ + vec_float4 sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; + sincosf4( radiansXYZ.getX(), &sX, &cX ); + sincosf4( radiansXYZ.getY(), &sY, &cY ); + sincosf4( radiansXYZ.getZ(), &sZ, &cZ ); + tmp0 = spu_mul( cZ, sY ); + tmp1 = spu_mul( sZ, sY ); + return Matrix3( + Vector3( spu_mul( cZ, cY ), spu_mul( sZ, cY ), negatef4( sY ) ), + Vector3( spu_sub( spu_mul( tmp0, sX ), spu_mul( sZ, cX ) ), spu_add( spu_mul( tmp1, sX ), spu_mul( cZ, cX ) ), spu_mul( cY, sX ) ), + Vector3( spu_add( spu_mul( tmp0, cX ), spu_mul( sZ, sX ) ), spu_sub( spu_mul( tmp1, cX ), spu_mul( cZ, sX ) ), spu_mul( cY, cX ) ) + ); +} + +inline const Matrix3 Matrix3::rotation( vec_float4 radians, const Vector3 & unitVec ) +{ + vec_float4 x, y, z, s, c, oneMinusC, xy, yz, zx; + sincosf4( radians, &s, &c ); + x = unitVec.getX(); + y = unitVec.getY(); + z = unitVec.getZ(); + xy = spu_mul( x, y ); + yz = spu_mul( y, z ); + zx = spu_mul( z, x ); + oneMinusC = spu_sub( spu_splats(1.0f), c ); + return Matrix3( + Vector3( spu_add( spu_mul( spu_mul( x, x ), oneMinusC ), c ), spu_add( spu_mul( xy, oneMinusC ), spu_mul( z, s ) ), spu_sub( spu_mul( zx, oneMinusC ), spu_mul( y, s ) ) ), + Vector3( spu_sub( spu_mul( xy, oneMinusC ), spu_mul( z, s ) ), spu_add( spu_mul( spu_mul( y, y ), oneMinusC ), c ), spu_add( spu_mul( yz, oneMinusC ), spu_mul( x, s ) ) ), + Vector3( spu_add( spu_mul( zx, oneMinusC ), spu_mul( y, s ) ), spu_sub( spu_mul( yz, oneMinusC ), spu_mul( x, s ) ), spu_add( spu_mul( spu_mul( z, z ), oneMinusC ), c ) ) + ); +} + +inline const Matrix3 Matrix3::rotation( const Quat & unitQuat ) +{ + return Matrix3( unitQuat ); +} + +inline const Matrix3 Matrix3::scale( const Vector3 & scaleVec ) +{ + return Matrix3( + Vector3( scaleVec.getX(), spu_splats(0.0f), spu_splats(0.0f) ), + Vector3( spu_splats(0.0f), scaleVec.getY(), spu_splats(0.0f) ), + Vector3( spu_splats(0.0f), spu_splats(0.0f), scaleVec.getZ() ) + ); +} + +inline const Matrix3 appendScale( const Matrix3 & mat, const Vector3 & scaleVec ) +{ + return Matrix3( + ( mat.getCol0() * scaleVec.getX( ) ), + ( mat.getCol1() * scaleVec.getY( ) ), + ( mat.getCol2() * scaleVec.getZ( ) ) + ); +} + +inline const Matrix3 prependScale( const Vector3 & scaleVec, const Matrix3 & mat ) +{ + return Matrix3( + mulPerElem( mat.getCol0(), scaleVec ), + mulPerElem( mat.getCol1(), scaleVec ), + mulPerElem( mat.getCol2(), scaleVec ) + ); +} + +inline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, vec_uint4 select1 ) +{ + return Matrix3( + select( mat0.getCol0(), mat1.getCol0(), select1 ), + select( mat0.getCol1(), mat1.getCol1(), select1 ), + select( mat0.getCol2(), mat1.getCol2(), select1 ) + ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( const Matrix3 & mat ) +{ + Aos::Matrix3 mat0, mat1, mat2, mat3; + mat.get4Aos( mat0, mat1, mat2, mat3 ); + printf("slot 0:\n"); + print( mat0 ); + printf("slot 1:\n"); + print( mat1 ); + printf("slot 2:\n"); + print( mat2 ); + printf("slot 3:\n"); + print( mat3 ); +} + +inline void print( const Matrix3 & mat, const char * name ) +{ + printf("%s:\n", name); + print( mat ); +} + +#endif + +inline Matrix4::Matrix4( const Matrix4 & mat ) +{ + mCol0 = mat.mCol0; + mCol1 = mat.mCol1; + mCol2 = mat.mCol2; + mCol3 = mat.mCol3; +} + +inline Matrix4::Matrix4( vec_float4 scalar ) +{ + mCol0 = Vector4( scalar ); + mCol1 = Vector4( scalar ); + mCol2 = Vector4( scalar ); + mCol3 = Vector4( scalar ); +} + +inline Matrix4::Matrix4( const Transform3 & mat ) +{ + mCol0 = Vector4( mat.getCol0(), spu_splats(0.0f) ); + mCol1 = Vector4( mat.getCol1(), spu_splats(0.0f) ); + mCol2 = Vector4( mat.getCol2(), spu_splats(0.0f) ); + mCol3 = Vector4( mat.getCol3(), spu_splats(1.0f) ); +} + +inline Matrix4::Matrix4( const Vector4 & _col0, const Vector4 & _col1, const Vector4 & _col2, const Vector4 & _col3 ) +{ + mCol0 = _col0; + mCol1 = _col1; + mCol2 = _col2; + mCol3 = _col3; +} + +inline Matrix4::Matrix4( const Matrix3 & mat, const Vector3 & translateVec ) +{ + mCol0 = Vector4( mat.getCol0(), spu_splats(0.0f) ); + mCol1 = Vector4( mat.getCol1(), spu_splats(0.0f) ); + mCol2 = Vector4( mat.getCol2(), spu_splats(0.0f) ); + mCol3 = Vector4( translateVec, spu_splats(1.0f) ); +} + +inline Matrix4::Matrix4( const Quat & unitQuat, const Vector3 & translateVec ) +{ + Matrix3 mat; + mat = Matrix3( unitQuat ); + mCol0 = Vector4( mat.getCol0(), spu_splats(0.0f) ); + mCol1 = Vector4( mat.getCol1(), spu_splats(0.0f) ); + mCol2 = Vector4( mat.getCol2(), spu_splats(0.0f) ); + mCol3 = Vector4( translateVec, spu_splats(1.0f) ); +} + +inline Matrix4::Matrix4( const Aos::Matrix4 & mat ) +{ + mCol0 = Vector4( mat.getCol0() ); + mCol1 = Vector4( mat.getCol1() ); + mCol2 = Vector4( mat.getCol2() ); + mCol3 = Vector4( mat.getCol3() ); +} + +inline Matrix4::Matrix4( const Aos::Matrix4 & mat0, const Aos::Matrix4 & mat1, const Aos::Matrix4 & mat2, const Aos::Matrix4 & mat3 ) +{ + mCol0 = Vector4( mat0.getCol0(), mat1.getCol0(), mat2.getCol0(), mat3.getCol0() ); + mCol1 = Vector4( mat0.getCol1(), mat1.getCol1(), mat2.getCol1(), mat3.getCol1() ); + mCol2 = Vector4( mat0.getCol2(), mat1.getCol2(), mat2.getCol2(), mat3.getCol2() ); + mCol3 = Vector4( mat0.getCol3(), mat1.getCol3(), mat2.getCol3(), mat3.getCol3() ); +} + +inline void Matrix4::get4Aos( Aos::Matrix4 & result0, Aos::Matrix4 & result1, Aos::Matrix4 & result2, Aos::Matrix4 & result3 ) const +{ + Aos::Vector4 tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3; + mCol0.get4Aos( tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3 ); + result0.setCol0( tmpV4_0 ); + result1.setCol0( tmpV4_1 ); + result2.setCol0( tmpV4_2 ); + result3.setCol0( tmpV4_3 ); + mCol1.get4Aos( tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3 ); + result0.setCol1( tmpV4_0 ); + result1.setCol1( tmpV4_1 ); + result2.setCol1( tmpV4_2 ); + result3.setCol1( tmpV4_3 ); + mCol2.get4Aos( tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3 ); + result0.setCol2( tmpV4_0 ); + result1.setCol2( tmpV4_1 ); + result2.setCol2( tmpV4_2 ); + result3.setCol2( tmpV4_3 ); + mCol3.get4Aos( tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3 ); + result0.setCol3( tmpV4_0 ); + result1.setCol3( tmpV4_1 ); + result2.setCol3( tmpV4_2 ); + result3.setCol3( tmpV4_3 ); +} + +inline Matrix4 & Matrix4::setCol0( const Vector4 & _col0 ) +{ + mCol0 = _col0; + return *this; +} + +inline Matrix4 & Matrix4::setCol1( const Vector4 & _col1 ) +{ + mCol1 = _col1; + return *this; +} + +inline Matrix4 & Matrix4::setCol2( const Vector4 & _col2 ) +{ + mCol2 = _col2; + return *this; +} + +inline Matrix4 & Matrix4::setCol3( const Vector4 & _col3 ) +{ + mCol3 = _col3; + return *this; +} + +inline Matrix4 & Matrix4::setCol( int col, const Vector4 & vec ) +{ + *(&mCol0 + col) = vec; + return *this; +} + +inline Matrix4 & Matrix4::setRow( int row, const Vector4 & vec ) +{ + mCol0.setElem( row, vec.getElem( 0 ) ); + mCol1.setElem( row, vec.getElem( 1 ) ); + mCol2.setElem( row, vec.getElem( 2 ) ); + mCol3.setElem( row, vec.getElem( 3 ) ); + return *this; +} + +inline Matrix4 & Matrix4::setElem( int col, int row, vec_float4 val ) +{ + Vector4 tmpV3_0; + tmpV3_0 = this->getCol( col ); + tmpV3_0.setElem( row, val ); + this->setCol( col, tmpV3_0 ); + return *this; +} + +inline vec_float4 Matrix4::getElem( int col, int row ) const +{ + return this->getCol( col ).getElem( row ); +} + +inline const Vector4 Matrix4::getCol0( ) const +{ + return mCol0; +} + +inline const Vector4 Matrix4::getCol1( ) const +{ + return mCol1; +} + +inline const Vector4 Matrix4::getCol2( ) const +{ + return mCol2; +} + +inline const Vector4 Matrix4::getCol3( ) const +{ + return mCol3; +} + +inline const Vector4 Matrix4::getCol( int col ) const +{ + return *(&mCol0 + col); +} + +inline const Vector4 Matrix4::getRow( int row ) const +{ + return Vector4( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ), mCol3.getElem( row ) ); +} + +inline Vector4 & Matrix4::operator []( int col ) +{ + return *(&mCol0 + col); +} + +inline const Vector4 Matrix4::operator []( int col ) const +{ + return *(&mCol0 + col); +} + +inline Matrix4 & Matrix4::operator =( const Matrix4 & mat ) +{ + mCol0 = mat.mCol0; + mCol1 = mat.mCol1; + mCol2 = mat.mCol2; + mCol3 = mat.mCol3; + return *this; +} + +inline const Matrix4 transpose( const Matrix4 & mat ) +{ + return Matrix4( + Vector4( mat.getCol0().getX(), mat.getCol1().getX(), mat.getCol2().getX(), mat.getCol3().getX() ), + Vector4( mat.getCol0().getY(), mat.getCol1().getY(), mat.getCol2().getY(), mat.getCol3().getY() ), + Vector4( mat.getCol0().getZ(), mat.getCol1().getZ(), mat.getCol2().getZ(), mat.getCol3().getZ() ), + Vector4( mat.getCol0().getW(), mat.getCol1().getW(), mat.getCol2().getW(), mat.getCol3().getW() ) + ); +} + +inline const Matrix4 inverse( const Matrix4 & mat ) +{ + Vector4 res0, res1, res2, res3; + vec_float4 mA, mB, mC, mD, mE, mF, mG, mH, mI, mJ, mK, mL, mM, mN, mO, mP, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, detInv; + mA = mat.getCol0().getX(); + mB = mat.getCol0().getY(); + mC = mat.getCol0().getZ(); + mD = mat.getCol0().getW(); + mE = mat.getCol1().getX(); + mF = mat.getCol1().getY(); + mG = mat.getCol1().getZ(); + mH = mat.getCol1().getW(); + mI = mat.getCol2().getX(); + mJ = mat.getCol2().getY(); + mK = mat.getCol2().getZ(); + mL = mat.getCol2().getW(); + mM = mat.getCol3().getX(); + mN = mat.getCol3().getY(); + mO = mat.getCol3().getZ(); + mP = mat.getCol3().getW(); + tmp0 = spu_sub( spu_mul( mK, mD ), spu_mul( mC, mL ) ); + tmp1 = spu_sub( spu_mul( mO, mH ), spu_mul( mG, mP ) ); + tmp2 = spu_sub( spu_mul( mB, mK ), spu_mul( mJ, mC ) ); + tmp3 = spu_sub( spu_mul( mF, mO ), spu_mul( mN, mG ) ); + tmp4 = spu_sub( spu_mul( mJ, mD ), spu_mul( mB, mL ) ); + tmp5 = spu_sub( spu_mul( mN, mH ), spu_mul( mF, mP ) ); + res0.setX( spu_sub( spu_sub( spu_mul( mJ, tmp1 ), spu_mul( mL, tmp3 ) ), spu_mul( mK, tmp5 ) ) ); + res0.setY( spu_sub( spu_sub( spu_mul( mN, tmp0 ), spu_mul( mP, tmp2 ) ), spu_mul( mO, tmp4 ) ) ); + res0.setZ( spu_sub( spu_add( spu_mul( mD, tmp3 ), spu_mul( mC, tmp5 ) ), spu_mul( mB, tmp1 ) ) ); + res0.setW( spu_sub( spu_add( spu_mul( mH, tmp2 ), spu_mul( mG, tmp4 ) ), spu_mul( mF, tmp0 ) ) ); + detInv = recipf4( spu_add( spu_add( spu_add( spu_mul( mA, res0.getX() ), spu_mul( mE, res0.getY() ) ), spu_mul( mI, res0.getZ() ) ), spu_mul( mM, res0.getW() ) ) ); + res1.setX( spu_mul( mI, tmp1 ) ); + res1.setY( spu_mul( mM, tmp0 ) ); + res1.setZ( spu_mul( mA, tmp1 ) ); + res1.setW( spu_mul( mE, tmp0 ) ); + res3.setX( spu_mul( mI, tmp3 ) ); + res3.setY( spu_mul( mM, tmp2 ) ); + res3.setZ( spu_mul( mA, tmp3 ) ); + res3.setW( spu_mul( mE, tmp2 ) ); + res2.setX( spu_mul( mI, tmp5 ) ); + res2.setY( spu_mul( mM, tmp4 ) ); + res2.setZ( spu_mul( mA, tmp5 ) ); + res2.setW( spu_mul( mE, tmp4 ) ); + tmp0 = spu_sub( spu_mul( mI, mB ), spu_mul( mA, mJ ) ); + tmp1 = spu_sub( spu_mul( mM, mF ), spu_mul( mE, mN ) ); + tmp2 = spu_sub( spu_mul( mI, mD ), spu_mul( mA, mL ) ); + tmp3 = spu_sub( spu_mul( mM, mH ), spu_mul( mE, mP ) ); + tmp4 = spu_sub( spu_mul( mI, mC ), spu_mul( mA, mK ) ); + tmp5 = spu_sub( spu_mul( mM, mG ), spu_mul( mE, mO ) ); + res2.setX( spu_add( spu_sub( spu_mul( mL, tmp1 ), spu_mul( mJ, tmp3 ) ), res2.getX() ) ); + res2.setY( spu_add( spu_sub( spu_mul( mP, tmp0 ), spu_mul( mN, tmp2 ) ), res2.getY() ) ); + res2.setZ( spu_sub( spu_sub( spu_mul( mB, tmp3 ), spu_mul( mD, tmp1 ) ), res2.getZ() ) ); + res2.setW( spu_sub( spu_sub( spu_mul( mF, tmp2 ), spu_mul( mH, tmp0 ) ), res2.getW() ) ); + res3.setX( spu_add( spu_sub( spu_mul( mJ, tmp5 ), spu_mul( mK, tmp1 ) ), res3.getX() ) ); + res3.setY( spu_add( spu_sub( spu_mul( mN, tmp4 ), spu_mul( mO, tmp0 ) ), res3.getY() ) ); + res3.setZ( spu_sub( spu_sub( spu_mul( mC, tmp1 ), spu_mul( mB, tmp5 ) ), res3.getZ() ) ); + res3.setW( spu_sub( spu_sub( spu_mul( mG, tmp0 ), spu_mul( mF, tmp4 ) ), res3.getW() ) ); + res1.setX( spu_sub( spu_sub( spu_mul( mK, tmp3 ), spu_mul( mL, tmp5 ) ), res1.getX() ) ); + res1.setY( spu_sub( spu_sub( spu_mul( mO, tmp2 ), spu_mul( mP, tmp4 ) ), res1.getY() ) ); + res1.setZ( spu_add( spu_sub( spu_mul( mD, tmp5 ), spu_mul( mC, tmp3 ) ), res1.getZ() ) ); + res1.setW( spu_add( spu_sub( spu_mul( mH, tmp4 ), spu_mul( mG, tmp2 ) ), res1.getW() ) ); + return Matrix4( + ( res0 * detInv ), + ( res1 * detInv ), + ( res2 * detInv ), + ( res3 * detInv ) + ); +} + +inline const Matrix4 affineInverse( const Matrix4 & mat ) +{ + Transform3 affineMat; + affineMat.setCol0( mat.getCol0().getXYZ( ) ); + affineMat.setCol1( mat.getCol1().getXYZ( ) ); + affineMat.setCol2( mat.getCol2().getXYZ( ) ); + affineMat.setCol3( mat.getCol3().getXYZ( ) ); + return Matrix4( inverse( affineMat ) ); +} + +inline const Matrix4 orthoInverse( const Matrix4 & mat ) +{ + Transform3 affineMat; + affineMat.setCol0( mat.getCol0().getXYZ( ) ); + affineMat.setCol1( mat.getCol1().getXYZ( ) ); + affineMat.setCol2( mat.getCol2().getXYZ( ) ); + affineMat.setCol3( mat.getCol3().getXYZ( ) ); + return Matrix4( orthoInverse( affineMat ) ); +} + +inline vec_float4 determinant( const Matrix4 & mat ) +{ + vec_float4 dx, dy, dz, dw, mA, mB, mC, mD, mE, mF, mG, mH, mI, mJ, mK, mL, mM, mN, mO, mP, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; + mA = mat.getCol0().getX(); + mB = mat.getCol0().getY(); + mC = mat.getCol0().getZ(); + mD = mat.getCol0().getW(); + mE = mat.getCol1().getX(); + mF = mat.getCol1().getY(); + mG = mat.getCol1().getZ(); + mH = mat.getCol1().getW(); + mI = mat.getCol2().getX(); + mJ = mat.getCol2().getY(); + mK = mat.getCol2().getZ(); + mL = mat.getCol2().getW(); + mM = mat.getCol3().getX(); + mN = mat.getCol3().getY(); + mO = mat.getCol3().getZ(); + mP = mat.getCol3().getW(); + tmp0 = spu_sub( spu_mul( mK, mD ), spu_mul( mC, mL ) ); + tmp1 = spu_sub( spu_mul( mO, mH ), spu_mul( mG, mP ) ); + tmp2 = spu_sub( spu_mul( mB, mK ), spu_mul( mJ, mC ) ); + tmp3 = spu_sub( spu_mul( mF, mO ), spu_mul( mN, mG ) ); + tmp4 = spu_sub( spu_mul( mJ, mD ), spu_mul( mB, mL ) ); + tmp5 = spu_sub( spu_mul( mN, mH ), spu_mul( mF, mP ) ); + dx = spu_sub( spu_sub( spu_mul( mJ, tmp1 ), spu_mul( mL, tmp3 ) ), spu_mul( mK, tmp5 ) ); + dy = spu_sub( spu_sub( spu_mul( mN, tmp0 ), spu_mul( mP, tmp2 ) ), spu_mul( mO, tmp4 ) ); + dz = spu_sub( spu_add( spu_mul( mD, tmp3 ), spu_mul( mC, tmp5 ) ), spu_mul( mB, tmp1 ) ); + dw = spu_sub( spu_add( spu_mul( mH, tmp2 ), spu_mul( mG, tmp4 ) ), spu_mul( mF, tmp0 ) ); + return spu_add( spu_add( spu_add( spu_mul( mA, dx ), spu_mul( mE, dy ) ), spu_mul( mI, dz ) ), spu_mul( mM, dw ) ); +} + +inline const Matrix4 Matrix4::operator +( const Matrix4 & mat ) const +{ + return Matrix4( + ( mCol0 + mat.mCol0 ), + ( mCol1 + mat.mCol1 ), + ( mCol2 + mat.mCol2 ), + ( mCol3 + mat.mCol3 ) + ); +} + +inline const Matrix4 Matrix4::operator -( const Matrix4 & mat ) const +{ + return Matrix4( + ( mCol0 - mat.mCol0 ), + ( mCol1 - mat.mCol1 ), + ( mCol2 - mat.mCol2 ), + ( mCol3 - mat.mCol3 ) + ); +} + +inline Matrix4 & Matrix4::operator +=( const Matrix4 & mat ) +{ + *this = *this + mat; + return *this; +} + +inline Matrix4 & Matrix4::operator -=( const Matrix4 & mat ) +{ + *this = *this - mat; + return *this; +} + +inline const Matrix4 Matrix4::operator -( ) const +{ + return Matrix4( + ( -mCol0 ), + ( -mCol1 ), + ( -mCol2 ), + ( -mCol3 ) + ); +} + +inline const Matrix4 absPerElem( const Matrix4 & mat ) +{ + return Matrix4( + absPerElem( mat.getCol0() ), + absPerElem( mat.getCol1() ), + absPerElem( mat.getCol2() ), + absPerElem( mat.getCol3() ) + ); +} + +inline const Matrix4 Matrix4::operator *( vec_float4 scalar ) const +{ + return Matrix4( + ( mCol0 * scalar ), + ( mCol1 * scalar ), + ( mCol2 * scalar ), + ( mCol3 * scalar ) + ); +} + +inline Matrix4 & Matrix4::operator *=( vec_float4 scalar ) +{ + *this = *this * scalar; + return *this; +} + +inline const Matrix4 operator *( vec_float4 scalar, const Matrix4 & mat ) +{ + return mat * scalar; +} + +inline const Vector4 Matrix4::operator *( const Vector4 & vec ) const +{ + return Vector4( + spu_add( spu_add( spu_add( spu_mul( mCol0.getX(), vec.getX() ), spu_mul( mCol1.getX(), vec.getY() ) ), spu_mul( mCol2.getX(), vec.getZ() ) ), spu_mul( mCol3.getX(), vec.getW() ) ), + spu_add( spu_add( spu_add( spu_mul( mCol0.getY(), vec.getX() ), spu_mul( mCol1.getY(), vec.getY() ) ), spu_mul( mCol2.getY(), vec.getZ() ) ), spu_mul( mCol3.getY(), vec.getW() ) ), + spu_add( spu_add( spu_add( spu_mul( mCol0.getZ(), vec.getX() ), spu_mul( mCol1.getZ(), vec.getY() ) ), spu_mul( mCol2.getZ(), vec.getZ() ) ), spu_mul( mCol3.getZ(), vec.getW() ) ), + spu_add( spu_add( spu_add( spu_mul( mCol0.getW(), vec.getX() ), spu_mul( mCol1.getW(), vec.getY() ) ), spu_mul( mCol2.getW(), vec.getZ() ) ), spu_mul( mCol3.getW(), vec.getW() ) ) + ); +} + +inline const Vector4 Matrix4::operator *( const Vector3 & vec ) const +{ + return Vector4( + spu_add( spu_add( spu_mul( mCol0.getX(), vec.getX() ), spu_mul( mCol1.getX(), vec.getY() ) ), spu_mul( mCol2.getX(), vec.getZ() ) ), + spu_add( spu_add( spu_mul( mCol0.getY(), vec.getX() ), spu_mul( mCol1.getY(), vec.getY() ) ), spu_mul( mCol2.getY(), vec.getZ() ) ), + spu_add( spu_add( spu_mul( mCol0.getZ(), vec.getX() ), spu_mul( mCol1.getZ(), vec.getY() ) ), spu_mul( mCol2.getZ(), vec.getZ() ) ), + spu_add( spu_add( spu_mul( mCol0.getW(), vec.getX() ), spu_mul( mCol1.getW(), vec.getY() ) ), spu_mul( mCol2.getW(), vec.getZ() ) ) + ); +} + +inline const Vector4 Matrix4::operator *( const Point3 & pnt ) const +{ + return Vector4( + spu_add( spu_add( spu_add( spu_mul( mCol0.getX(), pnt.getX() ), spu_mul( mCol1.getX(), pnt.getY() ) ), spu_mul( mCol2.getX(), pnt.getZ() ) ), mCol3.getX() ), + spu_add( spu_add( spu_add( spu_mul( mCol0.getY(), pnt.getX() ), spu_mul( mCol1.getY(), pnt.getY() ) ), spu_mul( mCol2.getY(), pnt.getZ() ) ), mCol3.getY() ), + spu_add( spu_add( spu_add( spu_mul( mCol0.getZ(), pnt.getX() ), spu_mul( mCol1.getZ(), pnt.getY() ) ), spu_mul( mCol2.getZ(), pnt.getZ() ) ), mCol3.getZ() ), + spu_add( spu_add( spu_add( spu_mul( mCol0.getW(), pnt.getX() ), spu_mul( mCol1.getW(), pnt.getY() ) ), spu_mul( mCol2.getW(), pnt.getZ() ) ), mCol3.getW() ) + ); +} + +inline const Matrix4 Matrix4::operator *( const Matrix4 & mat ) const +{ + return Matrix4( + ( *this * mat.mCol0 ), + ( *this * mat.mCol1 ), + ( *this * mat.mCol2 ), + ( *this * mat.mCol3 ) + ); +} + +inline Matrix4 & Matrix4::operator *=( const Matrix4 & mat ) +{ + *this = *this * mat; + return *this; +} + +inline const Matrix4 Matrix4::operator *( const Transform3 & tfrm ) const +{ + return Matrix4( + ( *this * tfrm.getCol0() ), + ( *this * tfrm.getCol1() ), + ( *this * tfrm.getCol2() ), + ( *this * Point3( tfrm.getCol3() ) ) + ); +} + +inline Matrix4 & Matrix4::operator *=( const Transform3 & tfrm ) +{ + *this = *this * tfrm; + return *this; +} + +inline const Matrix4 mulPerElem( const Matrix4 & mat0, const Matrix4 & mat1 ) +{ + return Matrix4( + mulPerElem( mat0.getCol0(), mat1.getCol0() ), + mulPerElem( mat0.getCol1(), mat1.getCol1() ), + mulPerElem( mat0.getCol2(), mat1.getCol2() ), + mulPerElem( mat0.getCol3(), mat1.getCol3() ) + ); +} + +inline const Matrix4 Matrix4::identity( ) +{ + return Matrix4( + Vector4::xAxis( ), + Vector4::yAxis( ), + Vector4::zAxis( ), + Vector4::wAxis( ) + ); +} + +inline Matrix4 & Matrix4::setUpper3x3( const Matrix3 & mat3 ) +{ + mCol0.setXYZ( mat3.getCol0() ); + mCol1.setXYZ( mat3.getCol1() ); + mCol2.setXYZ( mat3.getCol2() ); + return *this; +} + +inline const Matrix3 Matrix4::getUpper3x3( ) const +{ + return Matrix3( + mCol0.getXYZ( ), + mCol1.getXYZ( ), + mCol2.getXYZ( ) + ); +} + +inline Matrix4 & Matrix4::setTranslation( const Vector3 & translateVec ) +{ + mCol3.setXYZ( translateVec ); + return *this; +} + +inline const Vector3 Matrix4::getTranslation( ) const +{ + return mCol3.getXYZ( ); +} + +inline const Matrix4 Matrix4::rotationX( vec_float4 radians ) +{ + vec_float4 s, c; + sincosf4( radians, &s, &c ); + return Matrix4( + Vector4::xAxis( ), + Vector4( spu_splats(0.0f), c, s, spu_splats(0.0f) ), + Vector4( spu_splats(0.0f), negatef4( s ), c, spu_splats(0.0f) ), + Vector4::wAxis( ) + ); +} + +inline const Matrix4 Matrix4::rotationY( vec_float4 radians ) +{ + vec_float4 s, c; + sincosf4( radians, &s, &c ); + return Matrix4( + Vector4( c, spu_splats(0.0f), negatef4( s ), spu_splats(0.0f) ), + Vector4::yAxis( ), + Vector4( s, spu_splats(0.0f), c, spu_splats(0.0f) ), + Vector4::wAxis( ) + ); +} + +inline const Matrix4 Matrix4::rotationZ( vec_float4 radians ) +{ + vec_float4 s, c; + sincosf4( radians, &s, &c ); + return Matrix4( + Vector4( c, s, spu_splats(0.0f), spu_splats(0.0f) ), + Vector4( negatef4( s ), c, spu_splats(0.0f), spu_splats(0.0f) ), + Vector4::zAxis( ), + Vector4::wAxis( ) + ); +} + +inline const Matrix4 Matrix4::rotationZYX( const Vector3 & radiansXYZ ) +{ + vec_float4 sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; + sincosf4( radiansXYZ.getX(), &sX, &cX ); + sincosf4( radiansXYZ.getY(), &sY, &cY ); + sincosf4( radiansXYZ.getZ(), &sZ, &cZ ); + tmp0 = spu_mul( cZ, sY ); + tmp1 = spu_mul( sZ, sY ); + return Matrix4( + Vector4( spu_mul( cZ, cY ), spu_mul( sZ, cY ), negatef4( sY ), spu_splats(0.0f) ), + Vector4( spu_sub( spu_mul( tmp0, sX ), spu_mul( sZ, cX ) ), spu_add( spu_mul( tmp1, sX ), spu_mul( cZ, cX ) ), spu_mul( cY, sX ), spu_splats(0.0f) ), + Vector4( spu_add( spu_mul( tmp0, cX ), spu_mul( sZ, sX ) ), spu_sub( spu_mul( tmp1, cX ), spu_mul( cZ, sX ) ), spu_mul( cY, cX ), spu_splats(0.0f) ), + Vector4::wAxis( ) + ); +} + +inline const Matrix4 Matrix4::rotation( vec_float4 radians, const Vector3 & unitVec ) +{ + vec_float4 x, y, z, s, c, oneMinusC, xy, yz, zx; + sincosf4( radians, &s, &c ); + x = unitVec.getX(); + y = unitVec.getY(); + z = unitVec.getZ(); + xy = spu_mul( x, y ); + yz = spu_mul( y, z ); + zx = spu_mul( z, x ); + oneMinusC = spu_sub( spu_splats(1.0f), c ); + return Matrix4( + Vector4( spu_add( spu_mul( spu_mul( x, x ), oneMinusC ), c ), spu_add( spu_mul( xy, oneMinusC ), spu_mul( z, s ) ), spu_sub( spu_mul( zx, oneMinusC ), spu_mul( y, s ) ), spu_splats(0.0f) ), + Vector4( spu_sub( spu_mul( xy, oneMinusC ), spu_mul( z, s ) ), spu_add( spu_mul( spu_mul( y, y ), oneMinusC ), c ), spu_add( spu_mul( yz, oneMinusC ), spu_mul( x, s ) ), spu_splats(0.0f) ), + Vector4( spu_add( spu_mul( zx, oneMinusC ), spu_mul( y, s ) ), spu_sub( spu_mul( yz, oneMinusC ), spu_mul( x, s ) ), spu_add( spu_mul( spu_mul( z, z ), oneMinusC ), c ), spu_splats(0.0f) ), + Vector4::wAxis( ) + ); +} + +inline const Matrix4 Matrix4::rotation( const Quat & unitQuat ) +{ + return Matrix4( Transform3::rotation( unitQuat ) ); +} + +inline const Matrix4 Matrix4::scale( const Vector3 & scaleVec ) +{ + return Matrix4( + Vector4( scaleVec.getX(), spu_splats(0.0f), spu_splats(0.0f), spu_splats(0.0f) ), + Vector4( spu_splats(0.0f), scaleVec.getY(), spu_splats(0.0f), spu_splats(0.0f) ), + Vector4( spu_splats(0.0f), spu_splats(0.0f), scaleVec.getZ(), spu_splats(0.0f) ), + Vector4::wAxis( ) + ); +} + +inline const Matrix4 appendScale( const Matrix4 & mat, const Vector3 & scaleVec ) +{ + return Matrix4( + ( mat.getCol0() * scaleVec.getX( ) ), + ( mat.getCol1() * scaleVec.getY( ) ), + ( mat.getCol2() * scaleVec.getZ( ) ), + mat.getCol3() + ); +} + +inline const Matrix4 prependScale( const Vector3 & scaleVec, const Matrix4 & mat ) +{ + Vector4 scale4; + scale4 = Vector4( scaleVec, spu_splats(1.0f) ); + return Matrix4( + mulPerElem( mat.getCol0(), scale4 ), + mulPerElem( mat.getCol1(), scale4 ), + mulPerElem( mat.getCol2(), scale4 ), + mulPerElem( mat.getCol3(), scale4 ) + ); +} + +inline const Matrix4 Matrix4::translation( const Vector3 & translateVec ) +{ + return Matrix4( + Vector4::xAxis( ), + Vector4::yAxis( ), + Vector4::zAxis( ), + Vector4( translateVec, spu_splats(1.0f) ) + ); +} + +inline const Matrix4 Matrix4::lookAt( const Point3 & eyePos, const Point3 & lookAtPos, const Vector3 & upVec ) +{ + Matrix4 m4EyeFrame; + Vector3 v3X, v3Y, v3Z; + v3Y = normalize( upVec ); + v3Z = normalize( ( eyePos - lookAtPos ) ); + v3X = normalize( cross( v3Y, v3Z ) ); + v3Y = cross( v3Z, v3X ); + m4EyeFrame = Matrix4( Vector4( v3X ), Vector4( v3Y ), Vector4( v3Z ), Vector4( eyePos ) ); + return orthoInverse( m4EyeFrame ); +} + +inline const Matrix4 Matrix4::perspective( vec_float4 fovyRadians, vec_float4 aspect, vec_float4 zNear, vec_float4 zFar ) +{ + vec_float4 f, rangeInv; + f = tanf4( spu_sub( spu_splats( _VECTORMATH_PI_OVER_2 ), spu_mul( spu_splats(0.5f), fovyRadians ) ) ); + rangeInv = recipf4( spu_sub( zNear, zFar ) ); + return Matrix4( + Vector4( divf4( f, aspect ), spu_splats(0.0f), spu_splats(0.0f), spu_splats(0.0f) ), + Vector4( spu_splats(0.0f), f, spu_splats(0.0f), spu_splats(0.0f) ), + Vector4( spu_splats(0.0f), spu_splats(0.0f), spu_mul( spu_add( zNear, zFar ), rangeInv ), spu_splats(-1.0f) ), + Vector4( spu_splats(0.0f), spu_splats(0.0f), spu_mul( spu_mul( spu_mul( zNear, zFar ), rangeInv ), spu_splats(2.0f) ), spu_splats(0.0f) ) + ); +} + +inline const Matrix4 Matrix4::frustum( vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ) +{ + vec_float4 sum_rl, sum_tb, sum_nf, inv_rl, inv_tb, inv_nf, n2; + sum_rl = spu_add( right, left ); + sum_tb = spu_add( top, bottom ); + sum_nf = spu_add( zNear, zFar ); + inv_rl = recipf4( spu_sub( right, left ) ); + inv_tb = recipf4( spu_sub( top, bottom ) ); + inv_nf = recipf4( spu_sub( zNear, zFar ) ); + n2 = spu_add( zNear, zNear ); + return Matrix4( + Vector4( spu_mul( n2, inv_rl ), spu_splats(0.0f), spu_splats(0.0f), spu_splats(0.0f) ), + Vector4( spu_splats(0.0f), spu_mul( n2, inv_tb ), spu_splats(0.0f), spu_splats(0.0f) ), + Vector4( spu_mul( sum_rl, inv_rl ), spu_mul( sum_tb, inv_tb ), spu_mul( sum_nf, inv_nf ), spu_splats(-1.0f) ), + Vector4( spu_splats(0.0f), spu_splats(0.0f), spu_mul( spu_mul( n2, inv_nf ), zFar ), spu_splats(0.0f) ) + ); +} + +inline const Matrix4 Matrix4::orthographic( vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ) +{ + vec_float4 sum_rl, sum_tb, sum_nf, inv_rl, inv_tb, inv_nf; + sum_rl = spu_add( right, left ); + sum_tb = spu_add( top, bottom ); + sum_nf = spu_add( zNear, zFar ); + inv_rl = recipf4( spu_sub( right, left ) ); + inv_tb = recipf4( spu_sub( top, bottom ) ); + inv_nf = recipf4( spu_sub( zNear, zFar ) ); + return Matrix4( + Vector4( spu_add( inv_rl, inv_rl ), spu_splats(0.0f), spu_splats(0.0f), spu_splats(0.0f) ), + Vector4( spu_splats(0.0f), spu_add( inv_tb, inv_tb ), spu_splats(0.0f), spu_splats(0.0f) ), + Vector4( spu_splats(0.0f), spu_splats(0.0f), spu_add( inv_nf, inv_nf ), spu_splats(0.0f) ), + Vector4( spu_mul( negatef4( sum_rl ), inv_rl ), spu_mul( negatef4( sum_tb ), inv_tb ), spu_mul( sum_nf, inv_nf ), spu_splats(1.0f) ) + ); +} + +inline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, vec_uint4 select1 ) +{ + return Matrix4( + select( mat0.getCol0(), mat1.getCol0(), select1 ), + select( mat0.getCol1(), mat1.getCol1(), select1 ), + select( mat0.getCol2(), mat1.getCol2(), select1 ), + select( mat0.getCol3(), mat1.getCol3(), select1 ) + ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( const Matrix4 & mat ) +{ + Aos::Matrix4 mat0, mat1, mat2, mat3; + mat.get4Aos( mat0, mat1, mat2, mat3 ); + printf("slot 0:\n"); + print( mat0 ); + printf("slot 1:\n"); + print( mat1 ); + printf("slot 2:\n"); + print( mat2 ); + printf("slot 3:\n"); + print( mat3 ); +} + +inline void print( const Matrix4 & mat, const char * name ) +{ + printf("%s:\n", name); + print( mat ); +} + +#endif + +inline Transform3::Transform3( const Transform3 & tfrm ) +{ + mCol0 = tfrm.mCol0; + mCol1 = tfrm.mCol1; + mCol2 = tfrm.mCol2; + mCol3 = tfrm.mCol3; +} + +inline Transform3::Transform3( vec_float4 scalar ) +{ + mCol0 = Vector3( scalar ); + mCol1 = Vector3( scalar ); + mCol2 = Vector3( scalar ); + mCol3 = Vector3( scalar ); +} + +inline Transform3::Transform3( const Vector3 & _col0, const Vector3 & _col1, const Vector3 & _col2, const Vector3 & _col3 ) +{ + mCol0 = _col0; + mCol1 = _col1; + mCol2 = _col2; + mCol3 = _col3; +} + +inline Transform3::Transform3( const Matrix3 & tfrm, const Vector3 & translateVec ) +{ + this->setUpper3x3( tfrm ); + this->setTranslation( translateVec ); +} + +inline Transform3::Transform3( const Quat & unitQuat, const Vector3 & translateVec ) +{ + this->setUpper3x3( Matrix3( unitQuat ) ); + this->setTranslation( translateVec ); +} + +inline Transform3::Transform3( const Aos::Transform3 & tfrm ) +{ + mCol0 = Vector3( tfrm.getCol0() ); + mCol1 = Vector3( tfrm.getCol1() ); + mCol2 = Vector3( tfrm.getCol2() ); + mCol3 = Vector3( tfrm.getCol3() ); +} + +inline Transform3::Transform3( const Aos::Transform3 & tfrm0, const Aos::Transform3 & tfrm1, const Aos::Transform3 & tfrm2, const Aos::Transform3 & tfrm3 ) +{ + mCol0 = Vector3( tfrm0.getCol0(), tfrm1.getCol0(), tfrm2.getCol0(), tfrm3.getCol0() ); + mCol1 = Vector3( tfrm0.getCol1(), tfrm1.getCol1(), tfrm2.getCol1(), tfrm3.getCol1() ); + mCol2 = Vector3( tfrm0.getCol2(), tfrm1.getCol2(), tfrm2.getCol2(), tfrm3.getCol2() ); + mCol3 = Vector3( tfrm0.getCol3(), tfrm1.getCol3(), tfrm2.getCol3(), tfrm3.getCol3() ); +} + +inline void Transform3::get4Aos( Aos::Transform3 & result0, Aos::Transform3 & result1, Aos::Transform3 & result2, Aos::Transform3 & result3 ) const +{ + Aos::Vector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3; + mCol0.get4Aos( tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3 ); + result0.setCol0( tmpV3_0 ); + result1.setCol0( tmpV3_1 ); + result2.setCol0( tmpV3_2 ); + result3.setCol0( tmpV3_3 ); + mCol1.get4Aos( tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3 ); + result0.setCol1( tmpV3_0 ); + result1.setCol1( tmpV3_1 ); + result2.setCol1( tmpV3_2 ); + result3.setCol1( tmpV3_3 ); + mCol2.get4Aos( tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3 ); + result0.setCol2( tmpV3_0 ); + result1.setCol2( tmpV3_1 ); + result2.setCol2( tmpV3_2 ); + result3.setCol2( tmpV3_3 ); + mCol3.get4Aos( tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3 ); + result0.setCol3( tmpV3_0 ); + result1.setCol3( tmpV3_1 ); + result2.setCol3( tmpV3_2 ); + result3.setCol3( tmpV3_3 ); +} + +inline Transform3 & Transform3::setCol0( const Vector3 & _col0 ) +{ + mCol0 = _col0; + return *this; +} + +inline Transform3 & Transform3::setCol1( const Vector3 & _col1 ) +{ + mCol1 = _col1; + return *this; +} + +inline Transform3 & Transform3::setCol2( const Vector3 & _col2 ) +{ + mCol2 = _col2; + return *this; +} + +inline Transform3 & Transform3::setCol3( const Vector3 & _col3 ) +{ + mCol3 = _col3; + return *this; +} + +inline Transform3 & Transform3::setCol( int col, const Vector3 & vec ) +{ + *(&mCol0 + col) = vec; + return *this; +} + +inline Transform3 & Transform3::setRow( int row, const Vector4 & vec ) +{ + mCol0.setElem( row, vec.getElem( 0 ) ); + mCol1.setElem( row, vec.getElem( 1 ) ); + mCol2.setElem( row, vec.getElem( 2 ) ); + mCol3.setElem( row, vec.getElem( 3 ) ); + return *this; +} + +inline Transform3 & Transform3::setElem( int col, int row, vec_float4 val ) +{ + Vector3 tmpV3_0; + tmpV3_0 = this->getCol( col ); + tmpV3_0.setElem( row, val ); + this->setCol( col, tmpV3_0 ); + return *this; +} + +inline vec_float4 Transform3::getElem( int col, int row ) const +{ + return this->getCol( col ).getElem( row ); +} + +inline const Vector3 Transform3::getCol0( ) const +{ + return mCol0; +} + +inline const Vector3 Transform3::getCol1( ) const +{ + return mCol1; +} + +inline const Vector3 Transform3::getCol2( ) const +{ + return mCol2; +} + +inline const Vector3 Transform3::getCol3( ) const +{ + return mCol3; +} + +inline const Vector3 Transform3::getCol( int col ) const +{ + return *(&mCol0 + col); +} + +inline const Vector4 Transform3::getRow( int row ) const +{ + return Vector4( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ), mCol3.getElem( row ) ); +} + +inline Vector3 & Transform3::operator []( int col ) +{ + return *(&mCol0 + col); +} + +inline const Vector3 Transform3::operator []( int col ) const +{ + return *(&mCol0 + col); +} + +inline Transform3 & Transform3::operator =( const Transform3 & tfrm ) +{ + mCol0 = tfrm.mCol0; + mCol1 = tfrm.mCol1; + mCol2 = tfrm.mCol2; + mCol3 = tfrm.mCol3; + return *this; +} + +inline const Transform3 inverse( const Transform3 & tfrm ) +{ + Vector3 tmp0, tmp1, tmp2, inv0, inv1, inv2; + vec_float4 detinv; + tmp0 = cross( tfrm.getCol1(), tfrm.getCol2() ); + tmp1 = cross( tfrm.getCol2(), tfrm.getCol0() ); + tmp2 = cross( tfrm.getCol0(), tfrm.getCol1() ); + detinv = recipf4( dot( tfrm.getCol2(), tmp2 ) ); + inv0 = Vector3( spu_mul( tmp0.getX(), detinv ), spu_mul( tmp1.getX(), detinv ), spu_mul( tmp2.getX(), detinv ) ); + inv1 = Vector3( spu_mul( tmp0.getY(), detinv ), spu_mul( tmp1.getY(), detinv ), spu_mul( tmp2.getY(), detinv ) ); + inv2 = Vector3( spu_mul( tmp0.getZ(), detinv ), spu_mul( tmp1.getZ(), detinv ), spu_mul( tmp2.getZ(), detinv ) ); + return Transform3( + inv0, + inv1, + inv2, + Vector3( ( -( ( inv0 * tfrm.getCol3().getX() ) + ( ( inv1 * tfrm.getCol3().getY() ) + ( inv2 * tfrm.getCol3().getZ() ) ) ) ) ) + ); +} + +inline const Transform3 orthoInverse( const Transform3 & tfrm ) +{ + Vector3 inv0, inv1, inv2; + inv0 = Vector3( tfrm.getCol0().getX(), tfrm.getCol1().getX(), tfrm.getCol2().getX() ); + inv1 = Vector3( tfrm.getCol0().getY(), tfrm.getCol1().getY(), tfrm.getCol2().getY() ); + inv2 = Vector3( tfrm.getCol0().getZ(), tfrm.getCol1().getZ(), tfrm.getCol2().getZ() ); + return Transform3( + inv0, + inv1, + inv2, + Vector3( ( -( ( inv0 * tfrm.getCol3().getX() ) + ( ( inv1 * tfrm.getCol3().getY() ) + ( inv2 * tfrm.getCol3().getZ() ) ) ) ) ) + ); +} + +inline const Transform3 absPerElem( const Transform3 & tfrm ) +{ + return Transform3( + absPerElem( tfrm.getCol0() ), + absPerElem( tfrm.getCol1() ), + absPerElem( tfrm.getCol2() ), + absPerElem( tfrm.getCol3() ) + ); +} + +inline const Vector3 Transform3::operator *( const Vector3 & vec ) const +{ + return Vector3( + spu_add( spu_add( spu_mul( mCol0.getX(), vec.getX() ), spu_mul( mCol1.getX(), vec.getY() ) ), spu_mul( mCol2.getX(), vec.getZ() ) ), + spu_add( spu_add( spu_mul( mCol0.getY(), vec.getX() ), spu_mul( mCol1.getY(), vec.getY() ) ), spu_mul( mCol2.getY(), vec.getZ() ) ), + spu_add( spu_add( spu_mul( mCol0.getZ(), vec.getX() ), spu_mul( mCol1.getZ(), vec.getY() ) ), spu_mul( mCol2.getZ(), vec.getZ() ) ) + ); +} + +inline const Point3 Transform3::operator *( const Point3 & pnt ) const +{ + return Point3( + spu_add( spu_add( spu_add( spu_mul( mCol0.getX(), pnt.getX() ), spu_mul( mCol1.getX(), pnt.getY() ) ), spu_mul( mCol2.getX(), pnt.getZ() ) ), mCol3.getX() ), + spu_add( spu_add( spu_add( spu_mul( mCol0.getY(), pnt.getX() ), spu_mul( mCol1.getY(), pnt.getY() ) ), spu_mul( mCol2.getY(), pnt.getZ() ) ), mCol3.getY() ), + spu_add( spu_add( spu_add( spu_mul( mCol0.getZ(), pnt.getX() ), spu_mul( mCol1.getZ(), pnt.getY() ) ), spu_mul( mCol2.getZ(), pnt.getZ() ) ), mCol3.getZ() ) + ); +} + +inline const Transform3 Transform3::operator *( const Transform3 & tfrm ) const +{ + return Transform3( + ( *this * tfrm.mCol0 ), + ( *this * tfrm.mCol1 ), + ( *this * tfrm.mCol2 ), + Vector3( ( *this * Point3( tfrm.mCol3 ) ) ) + ); +} + +inline Transform3 & Transform3::operator *=( const Transform3 & tfrm ) +{ + *this = *this * tfrm; + return *this; +} + +inline const Transform3 mulPerElem( const Transform3 & tfrm0, const Transform3 & tfrm1 ) +{ + return Transform3( + mulPerElem( tfrm0.getCol0(), tfrm1.getCol0() ), + mulPerElem( tfrm0.getCol1(), tfrm1.getCol1() ), + mulPerElem( tfrm0.getCol2(), tfrm1.getCol2() ), + mulPerElem( tfrm0.getCol3(), tfrm1.getCol3() ) + ); +} + +inline const Transform3 Transform3::identity( ) +{ + return Transform3( + Vector3::xAxis( ), + Vector3::yAxis( ), + Vector3::zAxis( ), + Vector3( spu_splats(0.0f) ) + ); +} + +inline Transform3 & Transform3::setUpper3x3( const Matrix3 & tfrm ) +{ + mCol0 = tfrm.getCol0(); + mCol1 = tfrm.getCol1(); + mCol2 = tfrm.getCol2(); + return *this; +} + +inline const Matrix3 Transform3::getUpper3x3( ) const +{ + return Matrix3( mCol0, mCol1, mCol2 ); +} + +inline Transform3 & Transform3::setTranslation( const Vector3 & translateVec ) +{ + mCol3 = translateVec; + return *this; +} + +inline const Vector3 Transform3::getTranslation( ) const +{ + return mCol3; +} + +inline const Transform3 Transform3::rotationX( vec_float4 radians ) +{ + vec_float4 s, c; + sincosf4( radians, &s, &c ); + return Transform3( + Vector3::xAxis( ), + Vector3( spu_splats(0.0f), c, s ), + Vector3( spu_splats(0.0f), negatef4( s ), c ), + Vector3( spu_splats(0.0f) ) + ); +} + +inline const Transform3 Transform3::rotationY( vec_float4 radians ) +{ + vec_float4 s, c; + sincosf4( radians, &s, &c ); + return Transform3( + Vector3( c, spu_splats(0.0f), negatef4( s ) ), + Vector3::yAxis( ), + Vector3( s, spu_splats(0.0f), c ), + Vector3( spu_splats(0.0f) ) + ); +} + +inline const Transform3 Transform3::rotationZ( vec_float4 radians ) +{ + vec_float4 s, c; + sincosf4( radians, &s, &c ); + return Transform3( + Vector3( c, s, spu_splats(0.0f) ), + Vector3( negatef4( s ), c, spu_splats(0.0f) ), + Vector3::zAxis( ), + Vector3( spu_splats(0.0f) ) + ); +} + +inline const Transform3 Transform3::rotationZYX( const Vector3 & radiansXYZ ) +{ + vec_float4 sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; + sincosf4( radiansXYZ.getX(), &sX, &cX ); + sincosf4( radiansXYZ.getY(), &sY, &cY ); + sincosf4( radiansXYZ.getZ(), &sZ, &cZ ); + tmp0 = spu_mul( cZ, sY ); + tmp1 = spu_mul( sZ, sY ); + return Transform3( + Vector3( spu_mul( cZ, cY ), spu_mul( sZ, cY ), negatef4( sY ) ), + Vector3( spu_sub( spu_mul( tmp0, sX ), spu_mul( sZ, cX ) ), spu_add( spu_mul( tmp1, sX ), spu_mul( cZ, cX ) ), spu_mul( cY, sX ) ), + Vector3( spu_add( spu_mul( tmp0, cX ), spu_mul( sZ, sX ) ), spu_sub( spu_mul( tmp1, cX ), spu_mul( cZ, sX ) ), spu_mul( cY, cX ) ), + Vector3( spu_splats(0.0f) ) + ); +} + +inline const Transform3 Transform3::rotation( vec_float4 radians, const Vector3 & unitVec ) +{ + return Transform3( Matrix3::rotation( radians, unitVec ), Vector3( spu_splats(0.0f) ) ); +} + +inline const Transform3 Transform3::rotation( const Quat & unitQuat ) +{ + return Transform3( Matrix3( unitQuat ), Vector3( spu_splats(0.0f) ) ); +} + +inline const Transform3 Transform3::scale( const Vector3 & scaleVec ) +{ + return Transform3( + Vector3( scaleVec.getX(), spu_splats(0.0f), spu_splats(0.0f) ), + Vector3( spu_splats(0.0f), scaleVec.getY(), spu_splats(0.0f) ), + Vector3( spu_splats(0.0f), spu_splats(0.0f), scaleVec.getZ() ), + Vector3( spu_splats(0.0f) ) + ); +} + +inline const Transform3 appendScale( const Transform3 & tfrm, const Vector3 & scaleVec ) +{ + return Transform3( + ( tfrm.getCol0() * scaleVec.getX( ) ), + ( tfrm.getCol1() * scaleVec.getY( ) ), + ( tfrm.getCol2() * scaleVec.getZ( ) ), + tfrm.getCol3() + ); +} + +inline const Transform3 prependScale( const Vector3 & scaleVec, const Transform3 & tfrm ) +{ + return Transform3( + mulPerElem( tfrm.getCol0(), scaleVec ), + mulPerElem( tfrm.getCol1(), scaleVec ), + mulPerElem( tfrm.getCol2(), scaleVec ), + mulPerElem( tfrm.getCol3(), scaleVec ) + ); +} + +inline const Transform3 Transform3::translation( const Vector3 & translateVec ) +{ + return Transform3( + Vector3::xAxis( ), + Vector3::yAxis( ), + Vector3::zAxis( ), + translateVec + ); +} + +inline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, vec_uint4 select1 ) +{ + return Transform3( + select( tfrm0.getCol0(), tfrm1.getCol0(), select1 ), + select( tfrm0.getCol1(), tfrm1.getCol1(), select1 ), + select( tfrm0.getCol2(), tfrm1.getCol2(), select1 ), + select( tfrm0.getCol3(), tfrm1.getCol3(), select1 ) + ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( const Transform3 & tfrm ) +{ + Aos::Transform3 mat0, mat1, mat2, mat3; + tfrm.get4Aos( mat0, mat1, mat2, mat3 ); + printf("slot 0:\n"); + print( mat0 ); + printf("slot 1:\n"); + print( mat1 ); + printf("slot 2:\n"); + print( mat2 ); + printf("slot 3:\n"); + print( mat3 ); +} + +inline void print( const Transform3 & tfrm, const char * name ) +{ + printf("%s:\n", name); + print( tfrm ); +} + +#endif + +inline Quat::Quat( const Matrix3 & tfrm ) +{ + vec_float4 trace, radicand, scale, xx, yx, zx, xy, yy, zy, xz, yz, zz, tmpx, tmpy, tmpz, tmpw, qx, qy, qz, qw; + vec_uint4 negTrace, ZgtX, ZgtY, YgtX; + vec_uint4 largestXorY, largestYorZ, largestZorX; + + xx = tfrm.getCol0().getX(); + yx = tfrm.getCol0().getY(); + zx = tfrm.getCol0().getZ(); + xy = tfrm.getCol1().getX(); + yy = tfrm.getCol1().getY(); + zy = tfrm.getCol1().getZ(); + xz = tfrm.getCol2().getX(); + yz = tfrm.getCol2().getY(); + zz = tfrm.getCol2().getZ(); + + trace = spu_add( spu_add( xx, yy ), zz ); + + negTrace = spu_cmpgt( spu_splats(0.0f), trace ); + ZgtX = spu_cmpgt( zz, xx ); + ZgtY = spu_cmpgt( zz, yy ); + YgtX = spu_cmpgt( yy, xx ); + largestXorY = spu_and( negTrace, spu_nand( ZgtX, ZgtY ) ); + largestYorZ = spu_and( negTrace, spu_or( YgtX, ZgtX ) ); + largestZorX = spu_and( negTrace, spu_orc( ZgtY, YgtX ) ); + + zz = spu_sel( zz, negatef4(zz), largestXorY ); + xy = spu_sel( xy, negatef4(xy), largestXorY ); + xx = spu_sel( xx, negatef4(xx), largestYorZ ); + yz = spu_sel( yz, negatef4(yz), largestYorZ ); + yy = spu_sel( yy, negatef4(yy), largestZorX ); + zx = spu_sel( zx, negatef4(zx), largestZorX ); + + radicand = spu_add( spu_add( spu_add( xx, yy ), zz ), spu_splats(1.0f) ); + scale = spu_mul( spu_splats(0.5f), rsqrtf4( radicand ) ); + + tmpx = spu_mul( spu_sub( zy, yz ), scale ); + tmpy = spu_mul( spu_sub( xz, zx ), scale ); + tmpz = spu_mul( spu_sub( yx, xy ), scale ); + tmpw = spu_mul( radicand, scale ); + qx = tmpx; + qy = tmpy; + qz = tmpz; + qw = tmpw; + + qx = spu_sel( qx, tmpw, largestXorY ); + qy = spu_sel( qy, tmpz, largestXorY ); + qz = spu_sel( qz, tmpy, largestXorY ); + qw = spu_sel( qw, tmpx, largestXorY ); + tmpx = qx; + tmpz = qz; + qx = spu_sel( qx, qy, largestYorZ ); + qy = spu_sel( qy, tmpx, largestYorZ ); + qz = spu_sel( qz, qw, largestYorZ ); + qw = spu_sel( qw, tmpz, largestYorZ ); + + mX = qx; + mY = qy; + mZ = qz; + mW = qw; +} + +inline const Matrix3 outer( const Vector3 & tfrm0, const Vector3 & tfrm1 ) +{ + return Matrix3( + ( tfrm0 * tfrm1.getX( ) ), + ( tfrm0 * tfrm1.getY( ) ), + ( tfrm0 * tfrm1.getZ( ) ) + ); +} + +inline const Matrix4 outer( const Vector4 & tfrm0, const Vector4 & tfrm1 ) +{ + return Matrix4( + ( tfrm0 * tfrm1.getX( ) ), + ( tfrm0 * tfrm1.getY( ) ), + ( tfrm0 * tfrm1.getZ( ) ), + ( tfrm0 * tfrm1.getW( ) ) + ); +} + +inline const Vector3 rowMul( const Vector3 & vec, const Matrix3 & mat ) +{ + return Vector3( + spu_add( spu_add( spu_mul( vec.getX(), mat.getCol0().getX() ), spu_mul( vec.getY(), mat.getCol0().getY() ) ), spu_mul( vec.getZ(), mat.getCol0().getZ() ) ), + spu_add( spu_add( spu_mul( vec.getX(), mat.getCol1().getX() ), spu_mul( vec.getY(), mat.getCol1().getY() ) ), spu_mul( vec.getZ(), mat.getCol1().getZ() ) ), + spu_add( spu_add( spu_mul( vec.getX(), mat.getCol2().getX() ), spu_mul( vec.getY(), mat.getCol2().getY() ) ), spu_mul( vec.getZ(), mat.getCol2().getZ() ) ) + ); +} + +inline const Matrix3 crossMatrix( const Vector3 & vec ) +{ + return Matrix3( + Vector3( spu_splats(0.0f), vec.getZ(), negatef4( vec.getY() ) ), + Vector3( negatef4( vec.getZ() ), spu_splats(0.0f), vec.getX() ), + Vector3( vec.getY(), negatef4( vec.getX() ), spu_splats(0.0f) ) + ); +} + +inline const Matrix3 crossMatrixMul( const Vector3 & vec, const Matrix3 & mat ) +{ + return Matrix3( cross( vec, mat.getCol0() ), cross( vec, mat.getCol1() ), cross( vec, mat.getCol2() ) ); +} + +} // namespace Soa +} // namespace Vectormath + +#endif diff --git a/vectormathlibrary/include/vectormath/spu/cpp/quat_aos.h b/vectormathlibrary/include/vectormath/spu/cpp/quat_aos.h new file mode 100644 index 000000000..a41bc69aa --- /dev/null +++ b/vectormathlibrary/include/vectormath/spu/cpp/quat_aos.h @@ -0,0 +1,417 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_QUAT_AOS_CPP_H +#define _VECTORMATH_QUAT_AOS_CPP_H +//----------------------------------------------------------------------------- +// Definitions + +#ifndef _VECTORMATH_INTERNAL_FUNCTIONS +#define _VECTORMATH_INTERNAL_FUNCTIONS + +#endif + +namespace Vectormath { +namespace Aos { + +inline Quat::Quat( float _x, float _y, float _z, float _w ) +{ + mVec128 = (vec_float4){ _x, _y, _z, _w }; +} + +inline Quat::Quat( Vector3 xyz, float _w ) +{ + mVec128 = spu_shuffle( xyz.get128(), spu_promote( _w, 0 ), _VECTORMATH_SHUF_XYZA ); +} + +inline Quat::Quat( Vector4 vec ) +{ + mVec128 = vec.get128(); +} + +inline Quat::Quat( float scalar ) +{ + mVec128 = spu_splats( scalar ); +} + +inline Quat::Quat( vec_float4 vf4 ) +{ + mVec128 = vf4; +} + +inline const Quat Quat::identity( ) +{ + return Quat( _VECTORMATH_UNIT_0001 ); +} + +inline const Quat lerp( float t, Quat quat0, Quat quat1 ) +{ + return ( quat0 + ( ( quat1 - quat0 ) * t ) ); +} + +inline const Quat slerp( float t, Quat unitQuat0, Quat unitQuat1 ) +{ + Quat start; + vec_float4 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines; + vec_uint4 selectMask; + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); + cosAngle = _vmathVfDot4( unitQuat0.get128(), unitQuat1.get128() ); + cosAngle = spu_shuffle( cosAngle, cosAngle, shuffle_xxxx ); + selectMask = (vec_uint4)spu_cmpgt( spu_splats(0.0f), cosAngle ); + cosAngle = spu_sel( cosAngle, negatef4( cosAngle ), selectMask ); + start = Quat( spu_sel( unitQuat0.get128(), negatef4( unitQuat0.get128() ), selectMask ) ); + selectMask = (vec_uint4)spu_cmpgt( spu_splats(_VECTORMATH_SLERP_TOL), cosAngle ); + angle = acosf4( cosAngle ); + tttt = spu_splats(t); + oneMinusT = spu_sub( spu_splats(1.0f), tttt ); + angles = spu_sel( spu_splats(1.0f), oneMinusT, (vec_uint4)spu_maskb(0x0f00) ); + angles = spu_sel( angles, tttt, (vec_uint4)spu_maskb(0x00f0) ); + angles = spu_mul( angles, angle ); + sines = sinf4( angles ); + scales = divf4( sines, spu_shuffle( sines, sines, shuffle_xxxx ) ); + scale0 = spu_sel( oneMinusT, spu_shuffle( scales, scales, shuffle_yyyy ), selectMask ); + scale1 = spu_sel( tttt, spu_shuffle( scales, scales, shuffle_zzzz ), selectMask ); + return Quat( spu_madd( start.get128(), scale0, spu_mul( unitQuat1.get128(), scale1 ) ) ); +} + +inline const Quat squad( float t, Quat unitQuat0, Quat unitQuat1, Quat unitQuat2, Quat unitQuat3 ) +{ + Quat tmp0, tmp1; + tmp0 = slerp( t, unitQuat0, unitQuat3 ); + tmp1 = slerp( t, unitQuat1, unitQuat2 ); + return slerp( ( ( 2.0f * t ) * ( 1.0f - t ) ), tmp0, tmp1 ); +} + +inline vec_float4 Quat::get128( ) const +{ + return mVec128; +} + +inline Quat & Quat::operator =( Quat quat ) +{ + mVec128 = quat.mVec128; + return *this; +} + +inline Quat & Quat::setXYZ( Vector3 vec ) +{ + mVec128 = spu_sel( vec.get128(), mVec128, (vec_uint4)spu_maskb(0x000f) ); + return *this; +} + +inline const Vector3 Quat::getXYZ( ) const +{ + return Vector3( mVec128 ); +} + +inline Quat & Quat::setX( float _x ) +{ + mVec128 = spu_insert( _x, mVec128, 0 ); + return *this; +} + +inline float Quat::getX( ) const +{ + return spu_extract( mVec128, 0 ); +} + +inline Quat & Quat::setY( float _y ) +{ + mVec128 = spu_insert( _y, mVec128, 1 ); + return *this; +} + +inline float Quat::getY( ) const +{ + return spu_extract( mVec128, 1 ); +} + +inline Quat & Quat::setZ( float _z ) +{ + mVec128 = spu_insert( _z, mVec128, 2 ); + return *this; +} + +inline float Quat::getZ( ) const +{ + return spu_extract( mVec128, 2 ); +} + +inline Quat & Quat::setW( float _w ) +{ + mVec128 = spu_insert( _w, mVec128, 3 ); + return *this; +} + +inline float Quat::getW( ) const +{ + return spu_extract( mVec128, 3 ); +} + +inline Quat & Quat::setElem( int idx, float value ) +{ + mVec128 = spu_insert( value, mVec128, idx ); + return *this; +} + +inline float Quat::getElem( int idx ) const +{ + return spu_extract( mVec128, idx ); +} + +inline VecIdx Quat::operator []( int idx ) +{ + return VecIdx( mVec128, idx ); +} + +inline float Quat::operator []( int idx ) const +{ + return spu_extract( mVec128, idx ); +} + +inline const Quat Quat::operator +( Quat quat ) const +{ + return Quat( spu_add( mVec128, quat.mVec128 ) ); +} + +inline const Quat Quat::operator -( Quat quat ) const +{ + return Quat( spu_sub( mVec128, quat.mVec128 ) ); +} + +inline const Quat Quat::operator *( float scalar ) const +{ + return Quat( spu_mul( mVec128, spu_splats(scalar) ) ); +} + +inline Quat & Quat::operator +=( Quat quat ) +{ + *this = *this + quat; + return *this; +} + +inline Quat & Quat::operator -=( Quat quat ) +{ + *this = *this - quat; + return *this; +} + +inline Quat & Quat::operator *=( float scalar ) +{ + *this = *this * scalar; + return *this; +} + +inline const Quat Quat::operator /( float scalar ) const +{ + return Quat( divf4( mVec128, spu_splats(scalar) ) ); +} + +inline Quat & Quat::operator /=( float scalar ) +{ + *this = *this / scalar; + return *this; +} + +inline const Quat Quat::operator -( ) const +{ + return Quat( negatef4( mVec128 ) ); +} + +inline const Quat operator *( float scalar, Quat quat ) +{ + return quat * scalar; +} + +inline float dot( Quat quat0, Quat quat1 ) +{ + return spu_extract( _vmathVfDot4( quat0.get128(), quat1.get128() ), 0 ); +} + +inline float norm( Quat quat ) +{ + return spu_extract( _vmathVfDot4( quat.get128(), quat.get128() ), 0 ); +} + +inline float length( Quat quat ) +{ + return sqrtf( norm( quat ) ); +} + +inline const Quat normalize( Quat quat ) +{ + vec_float4 dot = _vmathVfDot4( quat.get128(), quat.get128() ); + return Quat( spu_mul( quat.get128(), rsqrtf4( dot ) ) ); +} + +inline const Quat Quat::rotation( Vector3 unitVec0, Vector3 unitVec1 ) +{ + Vector3 crossVec; + vec_float4 cosAngle, cosAngleX2Plus2, recipCosHalfAngleX2, cosHalfAngleX2, res; + cosAngle = _vmathVfDot3( unitVec0.get128(), unitVec1.get128() ); + cosAngle = spu_shuffle( cosAngle, cosAngle, (vec_uchar16)spu_splats(0x00010203) ); + cosAngleX2Plus2 = spu_madd( cosAngle, spu_splats(2.0f), spu_splats(2.0f) ); + recipCosHalfAngleX2 = rsqrtf4( cosAngleX2Plus2 ); + cosHalfAngleX2 = spu_mul( recipCosHalfAngleX2, cosAngleX2Plus2 ); + crossVec = cross( unitVec0, unitVec1 ); + res = spu_mul( crossVec.get128(), recipCosHalfAngleX2 ); + res = spu_sel( res, spu_mul( cosHalfAngleX2, spu_splats(0.5f) ), (vec_uint4)spu_maskb(0x000f) ); + return Quat( res ); +} + +inline const Quat Quat::rotation( float radians, Vector3 unitVec ) +{ + vec_float4 s, c, angle, res; + angle = spu_mul( spu_splats(radians), spu_splats(0.5f) ); + sincosf4( angle, &s, &c ); + res = spu_sel( spu_mul( unitVec.get128(), s ), c, (vec_uint4)spu_maskb(0x000f) ); + return Quat( res ); +} + +inline const Quat Quat::rotationX( float radians ) +{ + vec_float4 s, c, angle, res; + angle = spu_mul( spu_splats(radians), spu_splats(0.5f) ); + sincosf4( angle, &s, &c ); + res = spu_sel( spu_splats(0.0f), s, (vec_uint4)spu_maskb(0xf000) ); + res = spu_sel( res, c, (vec_uint4)spu_maskb(0x000f) ); + return Quat( res ); +} + +inline const Quat Quat::rotationY( float radians ) +{ + vec_float4 s, c, angle, res; + angle = spu_mul( spu_splats(radians), spu_splats(0.5f) ); + sincosf4( angle, &s, &c ); + res = spu_sel( spu_splats(0.0f), s, (vec_uint4)spu_maskb(0x0f00) ); + res = spu_sel( res, c, (vec_uint4)spu_maskb(0x000f) ); + return Quat( res ); +} + +inline const Quat Quat::rotationZ( float radians ) +{ + vec_float4 s, c, angle, res; + angle = spu_mul( spu_splats(radians), spu_splats(0.5f) ); + sincosf4( angle, &s, &c ); + res = spu_sel( spu_splats(0.0f), s, (vec_uint4)spu_maskb(0x00f0) ); + res = spu_sel( res, c, (vec_uint4)spu_maskb(0x000f) ); + return Quat( res ); +} + +inline const Quat Quat::operator *( Quat quat ) const +{ + vec_float4 ldata, rdata, qv, tmp0, tmp1, tmp2, tmp3; + vec_float4 product, l_wxyz, r_wxyz, xy, qw; + ldata = mVec128; + rdata = quat.mVec128; + vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f); + tmp0 = spu_shuffle( ldata, ldata, _VECTORMATH_SHUF_YZXW ); + tmp1 = spu_shuffle( rdata, rdata, _VECTORMATH_SHUF_ZXYW ); + tmp2 = spu_shuffle( ldata, ldata, _VECTORMATH_SHUF_ZXYW ); + tmp3 = spu_shuffle( rdata, rdata, _VECTORMATH_SHUF_YZXW ); + qv = spu_mul( spu_shuffle( ldata, ldata, shuffle_wwww ), rdata ); + qv = spu_madd( spu_shuffle( rdata, rdata, shuffle_wwww ), ldata, qv ); + qv = spu_madd( tmp0, tmp1, qv ); + qv = spu_nmsub( tmp2, tmp3, qv ); + product = spu_mul( ldata, rdata ); + l_wxyz = spu_rlqwbyte( ldata, 12 ); + r_wxyz = spu_rlqwbyte( rdata, 12 ); + qw = spu_nmsub( l_wxyz, r_wxyz, product ); + xy = spu_madd( l_wxyz, r_wxyz, product ); + qw = spu_sub( qw, spu_rlqwbyte( xy, 8 ) ); + return Quat( spu_sel( qv, qw, (vec_uint4)spu_maskb( 0x000f ) ) ); +} + +inline Quat & Quat::operator *=( Quat quat ) +{ + *this = *this * quat; + return *this; +} + +inline const Vector3 rotate( Quat quat, Vector3 vec ) +{ + vec_float4 qdata, vdata, product, tmp0, tmp1, tmp2, tmp3, wwww, qv, qw, res; + qdata = quat.get128(); + vdata = vec.get128(); + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f); + tmp0 = spu_shuffle( qdata, qdata, _VECTORMATH_SHUF_YZXW ); + tmp1 = spu_shuffle( vdata, vdata, _VECTORMATH_SHUF_ZXYW ); + tmp2 = spu_shuffle( qdata, qdata, _VECTORMATH_SHUF_ZXYW ); + tmp3 = spu_shuffle( vdata, vdata, _VECTORMATH_SHUF_YZXW ); + wwww = spu_shuffle( qdata, qdata, shuffle_wwww ); + qv = spu_mul( wwww, vdata ); + qv = spu_madd( tmp0, tmp1, qv ); + qv = spu_nmsub( tmp2, tmp3, qv ); + product = spu_mul( qdata, vdata ); + qw = spu_madd( spu_rlqwbyte( qdata, 4 ), spu_rlqwbyte( vdata, 4 ), product ); + qw = spu_add( spu_rlqwbyte( product, 8 ), qw ); + tmp1 = spu_shuffle( qv, qv, _VECTORMATH_SHUF_ZXYW ); + tmp3 = spu_shuffle( qv, qv, _VECTORMATH_SHUF_YZXW ); + res = spu_mul( spu_shuffle( qw, qw, shuffle_xxxx ), qdata ); + res = spu_madd( wwww, qv, res ); + res = spu_madd( tmp0, tmp1, res ); + res = spu_nmsub( tmp2, tmp3, res ); + return Vector3( res ); +} + +inline const Quat conj( Quat quat ) +{ + return Quat( spu_xor( quat.get128(), ((vec_float4)(vec_int4){0x80000000,0x80000000,0x80000000,0}) ) ); +} + +inline const Quat select( Quat quat0, Quat quat1, bool select1 ) +{ + return Quat( spu_sel( quat0.get128(), quat1.get128(), spu_splats( (unsigned int)-(select1 > 0) ) ) ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( Quat quat ) +{ + union { vec_float4 v; float s[4]; } tmp; + tmp.v = quat.get128(); + printf( "( %f %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] ); +} + +inline void print( Quat quat, const char * name ) +{ + union { vec_float4 v; float s[4]; } tmp; + tmp.v = quat.get128(); + printf( "%s: ( %f %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] ); +} + +#endif + +} // namespace Aos +} // namespace Vectormath + +#endif diff --git a/vectormathlibrary/include/vectormath/spu/cpp/quat_soa.h b/vectormathlibrary/include/vectormath/spu/cpp/quat_soa.h new file mode 100644 index 000000000..88c2884fa --- /dev/null +++ b/vectormathlibrary/include/vectormath/spu/cpp/quat_soa.h @@ -0,0 +1,483 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_QUAT_SOA_CPP_H +#define _VECTORMATH_QUAT_SOA_CPP_H +//----------------------------------------------------------------------------- +// Definitions + +#ifndef _VECTORMATH_INTERNAL_FUNCTIONS +#define _VECTORMATH_INTERNAL_FUNCTIONS + +#endif + +namespace Vectormath { +namespace Soa { + +inline Quat::Quat( const Quat & quat ) +{ + mX = quat.mX; + mY = quat.mY; + mZ = quat.mZ; + mW = quat.mW; +} + +inline Quat::Quat( vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w ) +{ + mX = _x; + mY = _y; + mZ = _z; + mW = _w; +} + +inline Quat::Quat( const Vector3 & xyz, vec_float4 _w ) +{ + this->setXYZ( xyz ); + this->setW( _w ); +} + +inline Quat::Quat( const Vector4 & vec ) +{ + mX = vec.getX(); + mY = vec.getY(); + mZ = vec.getZ(); + mW = vec.getW(); +} + +inline Quat::Quat( vec_float4 scalar ) +{ + mX = scalar; + mY = scalar; + mZ = scalar; + mW = scalar; +} + +inline Quat::Quat( Aos::Quat quat ) +{ + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); + vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f); + vec_float4 vec128 = quat.get128(); + mX = spu_shuffle( vec128, vec128, shuffle_xxxx ); + mY = spu_shuffle( vec128, vec128, shuffle_yyyy ); + mZ = spu_shuffle( vec128, vec128, shuffle_zzzz ); + mW = spu_shuffle( vec128, vec128, shuffle_wwww ); +} + +inline Quat::Quat( Aos::Quat quat0, Aos::Quat quat1, Aos::Quat quat2, Aos::Quat quat3 ) +{ + vec_float4 tmp0, tmp1, tmp2, tmp3; + tmp0 = spu_shuffle( quat0.get128(), quat2.get128(), _VECTORMATH_SHUF_XAYB ); + tmp1 = spu_shuffle( quat1.get128(), quat3.get128(), _VECTORMATH_SHUF_XAYB ); + tmp2 = spu_shuffle( quat0.get128(), quat2.get128(), _VECTORMATH_SHUF_ZCWD ); + tmp3 = spu_shuffle( quat1.get128(), quat3.get128(), _VECTORMATH_SHUF_ZCWD ); + mX = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB ); + mY = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD ); + mZ = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB ); + mW = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_ZCWD ); +} + +inline const Quat Quat::identity( ) +{ + return Quat( spu_splats(0.0f), spu_splats(0.0f), spu_splats(0.0f), spu_splats(1.0f) ); +} + +inline const Quat lerp( vec_float4 t, const Quat & quat0, const Quat & quat1 ) +{ + return ( quat0 + ( ( quat1 - quat0 ) * t ) ); +} + +inline const Quat slerp( vec_float4 t, const Quat & unitQuat0, const Quat & unitQuat1 ) +{ + Quat start; + vec_float4 recipSinAngle, scale0, scale1, cosAngle, angle; + vec_uint4 selectMask; + cosAngle = dot( unitQuat0, unitQuat1 ); + selectMask = (vec_uint4)spu_cmpgt( spu_splats(0.0f), cosAngle ); + cosAngle = spu_sel( cosAngle, negatef4( cosAngle ), selectMask ); + start.setX( spu_sel( unitQuat0.getX(), negatef4( unitQuat0.getX() ), selectMask ) ); + start.setY( spu_sel( unitQuat0.getY(), negatef4( unitQuat0.getY() ), selectMask ) ); + start.setZ( spu_sel( unitQuat0.getZ(), negatef4( unitQuat0.getZ() ), selectMask ) ); + start.setW( spu_sel( unitQuat0.getW(), negatef4( unitQuat0.getW() ), selectMask ) ); + selectMask = (vec_uint4)spu_cmpgt( spu_splats(_VECTORMATH_SLERP_TOL), cosAngle ); + angle = acosf4( cosAngle ); + recipSinAngle = recipf4( sinf4( angle ) ); + scale0 = spu_sel( spu_sub( spu_splats(1.0f), t ), spu_mul( sinf4( spu_mul( spu_sub( spu_splats(1.0f), t ), angle ) ), recipSinAngle ), selectMask ); + scale1 = spu_sel( t, spu_mul( sinf4( spu_mul( t, angle ) ), recipSinAngle ), selectMask ); + return ( ( start * scale0 ) + ( unitQuat1 * scale1 ) ); +} + +inline const Quat squad( vec_float4 t, const Quat & unitQuat0, const Quat & unitQuat1, const Quat & unitQuat2, const Quat & unitQuat3 ) +{ + Quat tmp0, tmp1; + tmp0 = slerp( t, unitQuat0, unitQuat3 ); + tmp1 = slerp( t, unitQuat1, unitQuat2 ); + return slerp( spu_mul( spu_mul( spu_splats(2.0f), t ), spu_sub( spu_splats(1.0f), t ) ), tmp0, tmp1 ); +} + +inline void Quat::get4Aos( Aos::Quat & result0, Aos::Quat & result1, Aos::Quat & result2, Aos::Quat & result3 ) const +{ + vec_float4 tmp0, tmp1, tmp2, tmp3; + tmp0 = spu_shuffle( mX, mZ, _VECTORMATH_SHUF_XAYB ); + tmp1 = spu_shuffle( mY, mW, _VECTORMATH_SHUF_XAYB ); + tmp2 = spu_shuffle( mX, mZ, _VECTORMATH_SHUF_ZCWD ); + tmp3 = spu_shuffle( mY, mW, _VECTORMATH_SHUF_ZCWD ); + result0 = Aos::Quat( spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB ) ); + result1 = Aos::Quat( spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD ) ); + result2 = Aos::Quat( spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB ) ); + result3 = Aos::Quat( spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_ZCWD ) ); +} + +inline Quat & Quat::operator =( const Quat & quat ) +{ + mX = quat.mX; + mY = quat.mY; + mZ = quat.mZ; + mW = quat.mW; + return *this; +} + +inline Quat & Quat::setXYZ( const Vector3 & vec ) +{ + mX = vec.getX(); + mY = vec.getY(); + mZ = vec.getZ(); + return *this; +} + +inline const Vector3 Quat::getXYZ( ) const +{ + return Vector3( mX, mY, mZ ); +} + +inline Quat & Quat::setX( vec_float4 _x ) +{ + mX = _x; + return *this; +} + +inline vec_float4 Quat::getX( ) const +{ + return mX; +} + +inline Quat & Quat::setY( vec_float4 _y ) +{ + mY = _y; + return *this; +} + +inline vec_float4 Quat::getY( ) const +{ + return mY; +} + +inline Quat & Quat::setZ( vec_float4 _z ) +{ + mZ = _z; + return *this; +} + +inline vec_float4 Quat::getZ( ) const +{ + return mZ; +} + +inline Quat & Quat::setW( vec_float4 _w ) +{ + mW = _w; + return *this; +} + +inline vec_float4 Quat::getW( ) const +{ + return mW; +} + +inline Quat & Quat::setElem( int idx, vec_float4 value ) +{ + *(&mX + idx) = value; + return *this; +} + +inline vec_float4 Quat::getElem( int idx ) const +{ + return *(&mX + idx); +} + +inline Quat::vec_float4_t & Quat::operator []( int idx ) +{ + return *(&mX + idx); +} + +inline vec_float4 Quat::operator []( int idx ) const +{ + return *(&mX + idx); +} + +inline const Quat Quat::operator +( const Quat & quat ) const +{ + return Quat( + spu_add( mX, quat.mX ), + spu_add( mY, quat.mY ), + spu_add( mZ, quat.mZ ), + spu_add( mW, quat.mW ) + ); +} + +inline const Quat Quat::operator -( const Quat & quat ) const +{ + return Quat( + spu_sub( mX, quat.mX ), + spu_sub( mY, quat.mY ), + spu_sub( mZ, quat.mZ ), + spu_sub( mW, quat.mW ) + ); +} + +inline const Quat Quat::operator *( vec_float4 scalar ) const +{ + return Quat( + spu_mul( mX, scalar ), + spu_mul( mY, scalar ), + spu_mul( mZ, scalar ), + spu_mul( mW, scalar ) + ); +} + +inline Quat & Quat::operator +=( const Quat & quat ) +{ + *this = *this + quat; + return *this; +} + +inline Quat & Quat::operator -=( const Quat & quat ) +{ + *this = *this - quat; + return *this; +} + +inline Quat & Quat::operator *=( vec_float4 scalar ) +{ + *this = *this * scalar; + return *this; +} + +inline const Quat Quat::operator /( vec_float4 scalar ) const +{ + return Quat( + divf4( mX, scalar ), + divf4( mY, scalar ), + divf4( mZ, scalar ), + divf4( mW, scalar ) + ); +} + +inline Quat & Quat::operator /=( vec_float4 scalar ) +{ + *this = *this / scalar; + return *this; +} + +inline const Quat Quat::operator -( ) const +{ + return Quat( + negatef4( mX ), + negatef4( mY ), + negatef4( mZ ), + negatef4( mW ) + ); +} + +inline const Quat operator *( vec_float4 scalar, const Quat & quat ) +{ + return quat * scalar; +} + +inline vec_float4 dot( const Quat & quat0, const Quat & quat1 ) +{ + vec_float4 result; + result = spu_mul( quat0.getX(), quat1.getX() ); + result = spu_add( result, spu_mul( quat0.getY(), quat1.getY() ) ); + result = spu_add( result, spu_mul( quat0.getZ(), quat1.getZ() ) ); + result = spu_add( result, spu_mul( quat0.getW(), quat1.getW() ) ); + return result; +} + +inline vec_float4 norm( const Quat & quat ) +{ + vec_float4 result; + result = spu_mul( quat.getX(), quat.getX() ); + result = spu_add( result, spu_mul( quat.getY(), quat.getY() ) ); + result = spu_add( result, spu_mul( quat.getZ(), quat.getZ() ) ); + result = spu_add( result, spu_mul( quat.getW(), quat.getW() ) ); + return result; +} + +inline vec_float4 length( const Quat & quat ) +{ + return sqrtf4( norm( quat ) ); +} + +inline const Quat normalize( const Quat & quat ) +{ + vec_float4 lenSqr, lenInv; + lenSqr = norm( quat ); + lenInv = rsqrtf4( lenSqr ); + return Quat( + spu_mul( quat.getX(), lenInv ), + spu_mul( quat.getY(), lenInv ), + spu_mul( quat.getZ(), lenInv ), + spu_mul( quat.getW(), lenInv ) + ); +} + +inline const Quat Quat::rotation( const Vector3 & unitVec0, const Vector3 & unitVec1 ) +{ + vec_float4 cosHalfAngleX2, recipCosHalfAngleX2; + cosHalfAngleX2 = sqrtf4( spu_mul( spu_splats(2.0f), spu_add( spu_splats(1.0f), dot( unitVec0, unitVec1 ) ) ) ); + recipCosHalfAngleX2 = recipf4( cosHalfAngleX2 ); + return Quat( ( cross( unitVec0, unitVec1 ) * recipCosHalfAngleX2 ), spu_mul( cosHalfAngleX2, spu_splats(0.5f) ) ); +} + +inline const Quat Quat::rotation( vec_float4 radians, const Vector3 & unitVec ) +{ + vec_float4 s, c, angle; + angle = spu_mul( radians, spu_splats(0.5f) ); + sincosf4( angle, &s, &c ); + return Quat( ( unitVec * s ), c ); +} + +inline const Quat Quat::rotationX( vec_float4 radians ) +{ + vec_float4 s, c, angle; + angle = spu_mul( radians, spu_splats(0.5f) ); + sincosf4( angle, &s, &c ); + return Quat( s, spu_splats(0.0f), spu_splats(0.0f), c ); +} + +inline const Quat Quat::rotationY( vec_float4 radians ) +{ + vec_float4 s, c, angle; + angle = spu_mul( radians, spu_splats(0.5f) ); + sincosf4( angle, &s, &c ); + return Quat( spu_splats(0.0f), s, spu_splats(0.0f), c ); +} + +inline const Quat Quat::rotationZ( vec_float4 radians ) +{ + vec_float4 s, c, angle; + angle = spu_mul( radians, spu_splats(0.5f) ); + sincosf4( angle, &s, &c ); + return Quat( spu_splats(0.0f), spu_splats(0.0f), s, c ); +} + +inline const Quat Quat::operator *( const Quat & quat ) const +{ + return Quat( + spu_sub( spu_add( spu_add( spu_mul( mW, quat.mX ), spu_mul( mX, quat.mW ) ), spu_mul( mY, quat.mZ ) ), spu_mul( mZ, quat.mY ) ), + spu_sub( spu_add( spu_add( spu_mul( mW, quat.mY ), spu_mul( mY, quat.mW ) ), spu_mul( mZ, quat.mX ) ), spu_mul( mX, quat.mZ ) ), + spu_sub( spu_add( spu_add( spu_mul( mW, quat.mZ ), spu_mul( mZ, quat.mW ) ), spu_mul( mX, quat.mY ) ), spu_mul( mY, quat.mX ) ), + spu_sub( spu_sub( spu_sub( spu_mul( mW, quat.mW ), spu_mul( mX, quat.mX ) ), spu_mul( mY, quat.mY ) ), spu_mul( mZ, quat.mZ ) ) + ); +} + +inline Quat & Quat::operator *=( const Quat & quat ) +{ + *this = *this * quat; + return *this; +} + +inline const Vector3 rotate( const Quat & quat, const Vector3 & vec ) +{ + vec_float4 tmpX, tmpY, tmpZ, tmpW; + tmpX = spu_sub( spu_add( spu_mul( quat.getW(), vec.getX() ), spu_mul( quat.getY(), vec.getZ() ) ), spu_mul( quat.getZ(), vec.getY() ) ); + tmpY = spu_sub( spu_add( spu_mul( quat.getW(), vec.getY() ), spu_mul( quat.getZ(), vec.getX() ) ), spu_mul( quat.getX(), vec.getZ() ) ); + tmpZ = spu_sub( spu_add( spu_mul( quat.getW(), vec.getZ() ), spu_mul( quat.getX(), vec.getY() ) ), spu_mul( quat.getY(), vec.getX() ) ); + tmpW = spu_add( spu_add( spu_mul( quat.getX(), vec.getX() ), spu_mul( quat.getY(), vec.getY() ) ), spu_mul( quat.getZ(), vec.getZ() ) ); + return Vector3( + spu_add( spu_sub( spu_add( spu_mul( tmpW, quat.getX() ), spu_mul( tmpX, quat.getW() ) ), spu_mul( tmpY, quat.getZ() ) ), spu_mul( tmpZ, quat.getY() ) ), + spu_add( spu_sub( spu_add( spu_mul( tmpW, quat.getY() ), spu_mul( tmpY, quat.getW() ) ), spu_mul( tmpZ, quat.getX() ) ), spu_mul( tmpX, quat.getZ() ) ), + spu_add( spu_sub( spu_add( spu_mul( tmpW, quat.getZ() ), spu_mul( tmpZ, quat.getW() ) ), spu_mul( tmpX, quat.getY() ) ), spu_mul( tmpY, quat.getX() ) ) + ); +} + +inline const Quat conj( const Quat & quat ) +{ + return Quat( negatef4( quat.getX() ), negatef4( quat.getY() ), negatef4( quat.getZ() ), quat.getW() ); +} + +inline const Quat select( const Quat & quat0, const Quat & quat1, vec_uint4 select1 ) +{ + return Quat( + spu_sel( quat0.getX(), quat1.getX(), select1 ), + spu_sel( quat0.getY(), quat1.getY(), select1 ), + spu_sel( quat0.getZ(), quat1.getZ(), select1 ), + spu_sel( quat0.getW(), quat1.getW(), select1 ) + ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( const Quat & quat ) +{ + Aos::Quat vec0, vec1, vec2, vec3; + quat.get4Aos( vec0, vec1, vec2, vec3 ); + printf("slot 0:\n"); + print( vec0 ); + printf("slot 1:\n"); + print( vec1 ); + printf("slot 2:\n"); + print( vec2 ); + printf("slot 3:\n"); + print( vec3 ); +} + +inline void print( const Quat & quat, const char * name ) +{ + Aos::Quat vec0, vec1, vec2, vec3; + printf( "%s:\n", name ); + quat.get4Aos( vec0, vec1, vec2, vec3 ); + printf("slot 0:\n"); + print( vec0 ); + printf("slot 1:\n"); + print( vec1 ); + printf("slot 2:\n"); + print( vec2 ); + printf("slot 3:\n"); + print( vec3 ); +} + +#endif + +} // namespace Soa +} // namespace Vectormath + +#endif diff --git a/vectormathlibrary/include/vectormath/spu/cpp/vec_aos.h b/vectormathlibrary/include/vectormath/spu/cpp/vec_aos.h new file mode 100644 index 000000000..c983f1817 --- /dev/null +++ b/vectormathlibrary/include/vectormath/spu/cpp/vec_aos.h @@ -0,0 +1,1167 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_VEC_AOS_CPP_H +#define _VECTORMATH_VEC_AOS_CPP_H +//----------------------------------------------------------------------------- +// Constants +// for shuffles, words are labeled [x,y,z,w] [a,b,c,d] + +#define _VECTORMATH_SHUF_X 0x00010203 +#define _VECTORMATH_SHUF_Y 0x04050607 +#define _VECTORMATH_SHUF_Z 0x08090a0b +#define _VECTORMATH_SHUF_W 0x0c0d0e0f +#define _VECTORMATH_SHUF_A 0x10111213 +#define _VECTORMATH_SHUF_B 0x14151617 +#define _VECTORMATH_SHUF_C 0x18191a1b +#define _VECTORMATH_SHUF_D 0x1c1d1e1f +#define _VECTORMATH_SHUF_0 0x80808080 +#define _VECTORMATH_SHUF_XYZA (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_A } +#define _VECTORMATH_SHUF_ZXYW (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_W } +#define _VECTORMATH_SHUF_YZXW (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_W } +#define _VECTORMATH_SHUF_WABC (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_C } +#define _VECTORMATH_SHUF_ZWAB (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_B } +#define _VECTORMATH_SHUF_XYZA (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_A } +#define _VECTORMATH_SHUF_YZAB (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_B } +#define _VECTORMATH_SHUF_ZABC (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_C } +#define _VECTORMATH_UNIT_1000 (vec_float4){ 1.0f, 0.0f, 0.0f, 0.0f } +#define _VECTORMATH_UNIT_0100 (vec_float4){ 0.0f, 1.0f, 0.0f, 0.0f } +#define _VECTORMATH_UNIT_0010 (vec_float4){ 0.0f, 0.0f, 1.0f, 0.0f } +#define _VECTORMATH_UNIT_0001 (vec_float4){ 0.0f, 0.0f, 0.0f, 1.0f } +#define _VECTORMATH_SLERP_TOL 0.999f + +//----------------------------------------------------------------------------- +// Definitions + +#ifndef _VECTORMATH_INTERNAL_FUNCTIONS +#define _VECTORMATH_INTERNAL_FUNCTIONS + +static inline vec_float4 _vmathVfDot3( vec_float4 vec0, vec_float4 vec1 ) +{ + vec_float4 result; + result = spu_mul( vec0, vec1 ); + result = spu_madd( spu_rlqwbyte( vec0, 4 ), spu_rlqwbyte( vec1, 4 ), result ); + return spu_madd( spu_rlqwbyte( vec0, 8 ), spu_rlqwbyte( vec1, 8 ), result ); +} + +static inline vec_float4 _vmathVfDot4( vec_float4 vec0, vec_float4 vec1 ) +{ + vec_float4 result; + result = spu_mul( vec0, vec1 ); + result = spu_madd( spu_rlqwbyte( vec0, 4 ), spu_rlqwbyte( vec1, 4 ), result ); + return spu_add( spu_rlqwbyte( result, 8 ), result ); +} + +static inline vec_float4 _vmathVfCross( vec_float4 vec0, vec_float4 vec1 ) +{ + vec_float4 tmp0, tmp1, tmp2, tmp3, result; + tmp0 = spu_shuffle( vec0, vec0, _VECTORMATH_SHUF_YZXW ); + tmp1 = spu_shuffle( vec1, vec1, _VECTORMATH_SHUF_ZXYW ); + tmp2 = spu_shuffle( vec0, vec0, _VECTORMATH_SHUF_ZXYW ); + tmp3 = spu_shuffle( vec1, vec1, _VECTORMATH_SHUF_YZXW ); + result = spu_mul( tmp0, tmp1 ); + result = spu_nmsub( tmp2, tmp3, result ); + return result; +} + +static inline vec_uint4 _vmathVfToHalfFloatsUnpacked(vec_float4 v) +{ + vec_int4 bexp; + vec_uint4 mant, sign, hfloat; + vec_uint4 notZero, isInf; + const vec_uint4 hfloatInf = spu_splats(0x00007c00u); + const vec_uint4 mergeMant = spu_splats(0x000003ffu); + const vec_uint4 mergeSign = spu_splats(0x00008000u); + + sign = spu_rlmask((vec_uint4)v, -16); + mant = spu_rlmask((vec_uint4)v, -13); + bexp = spu_and(spu_rlmask((vec_int4)v, -23), 0xff); + + notZero = spu_cmpgt(bexp, 112); + isInf = spu_cmpgt(bexp, 142); + + bexp = spu_add(bexp, -112); + bexp = spu_sl(bexp, 10); + + hfloat = spu_sel((vec_uint4)bexp, mant, mergeMant); + hfloat = spu_sel(spu_splats(0u), hfloat, notZero); + hfloat = spu_sel(hfloat, hfloatInf, isInf); + hfloat = spu_sel(hfloat, sign, mergeSign); + + return hfloat; +} + +static inline vec_ushort8 _vmath2VfToHalfFloats(vec_float4 u, vec_float4 v) +{ + vec_uint4 hfloat_u, hfloat_v; + const vec_uchar16 pack = (vec_uchar16){2,3,6,7,10,11,14,15,18,19,22,23,26,27,30,31}; + hfloat_u = _vmathVfToHalfFloatsUnpacked(u); + hfloat_v = _vmathVfToHalfFloatsUnpacked(v); + return (vec_ushort8)spu_shuffle(hfloat_u, hfloat_v, pack); +} + +#endif + +namespace Vectormath { +namespace Aos { + +inline VecIdx::operator float() const +{ + return spu_extract( ref, i ); +} + +inline float VecIdx::operator =( float scalar ) +{ + ref = spu_insert( scalar, ref, i ); + return scalar; +} + +inline float VecIdx::operator =( const VecIdx& scalar ) +{ + return *this = float(scalar); +} + +inline float VecIdx::operator *=( float scalar ) +{ + float tmp = spu_extract( ref, i ) * scalar; + ref = spu_insert( tmp, ref, i ); + return tmp; +} + +inline float VecIdx::operator /=( float scalar ) +{ + float tmp = spu_extract( ref, i ) / scalar; + ref = spu_insert( tmp, ref, i ); + return tmp; +} + +inline float VecIdx::operator +=( float scalar ) +{ + float tmp = spu_extract( ref, i ) + scalar; + ref = spu_insert( tmp, ref, i ); + return tmp; +} + +inline float VecIdx::operator -=( float scalar ) +{ + float tmp = spu_extract( ref, i ) - scalar; + ref = spu_insert( tmp, ref, i ); + return tmp; +} + +inline Vector3::Vector3( float _x, float _y, float _z ) +{ + mVec128 = (vec_float4){ _x, _y, _z, 0.0f }; +} + +inline Vector3::Vector3( Point3 pnt ) +{ + mVec128 = pnt.get128(); +} + +inline Vector3::Vector3( float scalar ) +{ + mVec128 = spu_splats( scalar ); +} + +inline Vector3::Vector3( vec_float4 vf4 ) +{ + mVec128 = vf4; +} + +inline const Vector3 Vector3::xAxis( ) +{ + return Vector3( _VECTORMATH_UNIT_1000 ); +} + +inline const Vector3 Vector3::yAxis( ) +{ + return Vector3( _VECTORMATH_UNIT_0100 ); +} + +inline const Vector3 Vector3::zAxis( ) +{ + return Vector3( _VECTORMATH_UNIT_0010 ); +} + +inline const Vector3 lerp( float t, Vector3 vec0, Vector3 vec1 ) +{ + return ( vec0 + ( ( vec1 - vec0 ) * t ) ); +} + +inline const Vector3 slerp( float t, Vector3 unitVec0, Vector3 unitVec1 ) +{ + vec_float4 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines; + vec_uint4 selectMask; + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); + cosAngle = _vmathVfDot3( unitVec0.get128(), unitVec1.get128() ); + cosAngle = spu_shuffle( cosAngle, cosAngle, shuffle_xxxx ); + selectMask = (vec_uint4)spu_cmpgt( spu_splats(_VECTORMATH_SLERP_TOL), cosAngle ); + angle = acosf4( cosAngle ); + tttt = spu_splats(t); + oneMinusT = spu_sub( spu_splats(1.0f), tttt ); + angles = spu_sel( spu_splats(1.0f), oneMinusT, (vec_uint4)spu_maskb(0x0f00) ); + angles = spu_sel( angles, tttt, (vec_uint4)spu_maskb(0x00f0) ); + angles = spu_mul( angles, angle ); + sines = sinf4( angles ); + scales = divf4( sines, spu_shuffle( sines, sines, shuffle_xxxx ) ); + scale0 = spu_sel( oneMinusT, spu_shuffle( scales, scales, shuffle_yyyy ), selectMask ); + scale1 = spu_sel( tttt, spu_shuffle( scales, scales, shuffle_zzzz ), selectMask ); + return Vector3( spu_madd( unitVec0.get128(), scale0, spu_mul( unitVec1.get128(), scale1 ) ) ); +} + +inline vec_float4 Vector3::get128( ) const +{ + return mVec128; +} + +inline void storeXYZ( Vector3 vec, vec_float4 * quad ) +{ + vec_float4 dstVec = *quad; + vec_uint4 mask = (vec_uint4)spu_maskb(0x000f); + dstVec = spu_sel(vec.get128(), dstVec, mask); + *quad = dstVec; +} + +inline void loadXYZArray( Vector3 & vec0, Vector3 & vec1, Vector3 & vec2, Vector3 & vec3, const vec_float4 * threeQuads ) +{ + vec_float4 xyzx, yzxy, zxyz, xyz1, xyz2, xyz3; + xyzx = threeQuads[0]; + yzxy = threeQuads[1]; + zxyz = threeQuads[2]; + xyz1 = spu_shuffle( xyzx, yzxy, _VECTORMATH_SHUF_WABC ); + xyz2 = spu_shuffle( yzxy, zxyz, _VECTORMATH_SHUF_ZWAB ); + xyz3 = spu_rlqwbyte( zxyz, 4 ); + vec0 = Vector3( xyzx ); + vec1 = Vector3( xyz1 ); + vec2 = Vector3( xyz2 ); + vec3 = Vector3( xyz3 ); +} + +inline void storeXYZArray( Vector3 vec0, Vector3 vec1, Vector3 vec2, Vector3 vec3, vec_float4 * threeQuads ) +{ + vec_float4 xyzx, yzxy, zxyz; + xyzx = spu_shuffle( vec0.get128(), vec1.get128(), _VECTORMATH_SHUF_XYZA ); + yzxy = spu_shuffle( vec1.get128(), vec2.get128(), _VECTORMATH_SHUF_YZAB ); + zxyz = spu_shuffle( vec2.get128(), vec3.get128(), _VECTORMATH_SHUF_ZABC ); + threeQuads[0] = xyzx; + threeQuads[1] = yzxy; + threeQuads[2] = zxyz; +} + +inline void storeHalfFloats( Vector3 vec0, Vector3 vec1, Vector3 vec2, Vector3 vec3, Vector3 vec4, Vector3 vec5, Vector3 vec6, Vector3 vec7, vec_ushort8 * threeQuads ) +{ + vec_float4 xyz0[3]; + vec_float4 xyz1[3]; + storeXYZArray( vec0, vec1, vec2, vec3, xyz0 ); + storeXYZArray( vec4, vec5, vec6, vec7, xyz1 ); + threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); + threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); + threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); +} + +inline Vector3 & Vector3::operator =( Vector3 vec ) +{ + mVec128 = vec.mVec128; + return *this; +} + +inline Vector3 & Vector3::setX( float _x ) +{ + mVec128 = spu_insert( _x, mVec128, 0 ); + return *this; +} + +inline float Vector3::getX( ) const +{ + return spu_extract( mVec128, 0 ); +} + +inline Vector3 & Vector3::setY( float _y ) +{ + mVec128 = spu_insert( _y, mVec128, 1 ); + return *this; +} + +inline float Vector3::getY( ) const +{ + return spu_extract( mVec128, 1 ); +} + +inline Vector3 & Vector3::setZ( float _z ) +{ + mVec128 = spu_insert( _z, mVec128, 2 ); + return *this; +} + +inline float Vector3::getZ( ) const +{ + return spu_extract( mVec128, 2 ); +} + +inline Vector3 & Vector3::setElem( int idx, float value ) +{ + mVec128 = spu_insert( value, mVec128, idx ); + return *this; +} + +inline float Vector3::getElem( int idx ) const +{ + return spu_extract( mVec128, idx ); +} + +inline VecIdx Vector3::operator []( int idx ) +{ + return VecIdx( mVec128, idx ); +} + +inline float Vector3::operator []( int idx ) const +{ + return spu_extract( mVec128, idx ); +} + +inline const Vector3 Vector3::operator +( Vector3 vec ) const +{ + return Vector3( spu_add( mVec128, vec.mVec128 ) ); +} + +inline const Vector3 Vector3::operator -( Vector3 vec ) const +{ + return Vector3( spu_sub( mVec128, vec.mVec128 ) ); +} + +inline const Point3 Vector3::operator +( Point3 pnt ) const +{ + return Point3( spu_add( mVec128, pnt.get128() ) ); +} + +inline const Vector3 Vector3::operator *( float scalar ) const +{ + return Vector3( spu_mul( mVec128, spu_splats(scalar) ) ); +} + +inline Vector3 & Vector3::operator +=( Vector3 vec ) +{ + *this = *this + vec; + return *this; +} + +inline Vector3 & Vector3::operator -=( Vector3 vec ) +{ + *this = *this - vec; + return *this; +} + +inline Vector3 & Vector3::operator *=( float scalar ) +{ + *this = *this * scalar; + return *this; +} + +inline const Vector3 Vector3::operator /( float scalar ) const +{ + return Vector3( divf4( mVec128, spu_splats(scalar) ) ); +} + +inline Vector3 & Vector3::operator /=( float scalar ) +{ + *this = *this / scalar; + return *this; +} + +inline const Vector3 Vector3::operator -( ) const +{ + return Vector3( negatef4( mVec128 ) ); +} + +inline const Vector3 operator *( float scalar, Vector3 vec ) +{ + return vec * scalar; +} + +inline const Vector3 mulPerElem( Vector3 vec0, Vector3 vec1 ) +{ + return Vector3( spu_mul( vec0.get128(), vec1.get128() ) ); +} + +inline const Vector3 divPerElem( Vector3 vec0, Vector3 vec1 ) +{ + return Vector3( divf4( vec0.get128(), vec1.get128() ) ); +} + +inline const Vector3 recipPerElem( Vector3 vec ) +{ + return Vector3( recipf4( vec.get128() ) ); +} + +inline const Vector3 sqrtPerElem( Vector3 vec ) +{ + return Vector3( sqrtf4( vec.get128() ) ); +} + +inline const Vector3 rsqrtPerElem( Vector3 vec ) +{ + return Vector3( rsqrtf4( vec.get128() ) ); +} + +inline const Vector3 absPerElem( Vector3 vec ) +{ + return Vector3( fabsf4( vec.get128() ) ); +} + +inline const Vector3 copySignPerElem( Vector3 vec0, Vector3 vec1 ) +{ + return Vector3( copysignf4( vec0.get128(), vec1.get128() ) ); +} + +inline const Vector3 maxPerElem( Vector3 vec0, Vector3 vec1 ) +{ + return Vector3( fmaxf4( vec0.get128(), vec1.get128() ) ); +} + +inline float maxElem( Vector3 vec ) +{ + vec_float4 result; + result = fmaxf4( spu_promote( spu_extract( vec.get128(), 1 ), 0 ), vec.get128() ); + result = fmaxf4( spu_promote( spu_extract( vec.get128(), 2 ), 0 ), result ); + return spu_extract( result, 0 ); +} + +inline const Vector3 minPerElem( Vector3 vec0, Vector3 vec1 ) +{ + return Vector3( fminf4( vec0.get128(), vec1.get128() ) ); +} + +inline float minElem( Vector3 vec ) +{ + vec_float4 result; + result = fminf4( spu_promote( spu_extract( vec.get128(), 1 ), 0 ), vec.get128() ); + result = fminf4( spu_promote( spu_extract( vec.get128(), 2 ), 0 ), result ); + return spu_extract( result, 0 ); +} + +inline float sum( Vector3 vec ) +{ + return + spu_extract( vec.get128(), 0 ) + + spu_extract( vec.get128(), 1 ) + + spu_extract( vec.get128(), 2 ); +} + +inline float dot( Vector3 vec0, Vector3 vec1 ) +{ + return spu_extract( _vmathVfDot3( vec0.get128(), vec1.get128() ), 0 ); +} + +inline float lengthSqr( Vector3 vec ) +{ + return spu_extract( _vmathVfDot3( vec.get128(), vec.get128() ), 0 ); +} + +inline float length( Vector3 vec ) +{ + return sqrtf( lengthSqr( vec ) ); +} + +inline const Vector3 normalize( Vector3 vec ) +{ + vec_float4 dot = _vmathVfDot3( vec.get128(), vec.get128() ); + dot = spu_shuffle( dot, dot, (vec_uchar16)spu_splats(0x00010203) ); + return Vector3( spu_mul( vec.get128(), rsqrtf4( dot ) ) ); +} + +inline const Vector3 cross( Vector3 vec0, Vector3 vec1 ) +{ + return Vector3( _vmathVfCross( vec0.get128(), vec1.get128() ) ); +} + +inline const Vector3 select( Vector3 vec0, Vector3 vec1, bool select1 ) +{ + return Vector3( spu_sel( vec0.get128(), vec1.get128(), spu_splats( (unsigned int)-(select1 > 0) ) ) ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( Vector3 vec ) +{ + union { vec_float4 v; float s[4]; } tmp; + tmp.v = vec.get128(); + printf( "( %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2] ); +} + +inline void print( Vector3 vec, const char * name ) +{ + union { vec_float4 v; float s[4]; } tmp; + tmp.v = vec.get128(); + printf( "%s: ( %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2] ); +} + +#endif + +inline Vector4::Vector4( float _x, float _y, float _z, float _w ) +{ + mVec128 = (vec_float4){ _x, _y, _z, _w }; +} + +inline Vector4::Vector4( Vector3 xyz, float _w ) +{ + mVec128 = spu_shuffle( xyz.get128(), spu_promote( _w, 0 ), _VECTORMATH_SHUF_XYZA ); +} + +inline Vector4::Vector4( Vector3 vec ) +{ + mVec128 = spu_sel( vec.get128(), spu_splats(0.0f), (vec_uint4)spu_maskb(0x000f) ); +} + +inline Vector4::Vector4( Point3 pnt ) +{ + mVec128 = spu_sel( pnt.get128(), spu_splats(1.0f), (vec_uint4)spu_maskb(0x000f) ); +} + +inline Vector4::Vector4( Quat quat ) +{ + mVec128 = quat.get128(); +} + +inline Vector4::Vector4( float scalar ) +{ + mVec128 = spu_splats( scalar ); +} + +inline Vector4::Vector4( vec_float4 vf4 ) +{ + mVec128 = vf4; +} + +inline const Vector4 Vector4::xAxis( ) +{ + return Vector4( _VECTORMATH_UNIT_1000 ); +} + +inline const Vector4 Vector4::yAxis( ) +{ + return Vector4( _VECTORMATH_UNIT_0100 ); +} + +inline const Vector4 Vector4::zAxis( ) +{ + return Vector4( _VECTORMATH_UNIT_0010 ); +} + +inline const Vector4 Vector4::wAxis( ) +{ + return Vector4( _VECTORMATH_UNIT_0001 ); +} + +inline const Vector4 lerp( float t, Vector4 vec0, Vector4 vec1 ) +{ + return ( vec0 + ( ( vec1 - vec0 ) * t ) ); +} + +inline const Vector4 slerp( float t, Vector4 unitVec0, Vector4 unitVec1 ) +{ + vec_float4 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines; + vec_uint4 selectMask; + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); + cosAngle = _vmathVfDot4( unitVec0.get128(), unitVec1.get128() ); + cosAngle = spu_shuffle( cosAngle, cosAngle, shuffle_xxxx ); + selectMask = (vec_uint4)spu_cmpgt( spu_splats(_VECTORMATH_SLERP_TOL), cosAngle ); + angle = acosf4( cosAngle ); + tttt = spu_splats(t); + oneMinusT = spu_sub( spu_splats(1.0f), tttt ); + angles = spu_sel( spu_splats(1.0f), oneMinusT, (vec_uint4)spu_maskb(0x0f00) ); + angles = spu_sel( angles, tttt, (vec_uint4)spu_maskb(0x00f0) ); + angles = spu_mul( angles, angle ); + sines = sinf4( angles ); + scales = divf4( sines, spu_shuffle( sines, sines, shuffle_xxxx ) ); + scale0 = spu_sel( oneMinusT, spu_shuffle( scales, scales, shuffle_yyyy ), selectMask ); + scale1 = spu_sel( tttt, spu_shuffle( scales, scales, shuffle_zzzz ), selectMask ); + return Vector4( spu_madd( unitVec0.get128(), scale0, spu_mul( unitVec1.get128(), scale1 ) ) ); +} + +inline vec_float4 Vector4::get128( ) const +{ + return mVec128; +} + +inline void storeHalfFloats( Vector4 vec0, Vector4 vec1, Vector4 vec2, Vector4 vec3, vec_ushort8 * twoQuads ) +{ + twoQuads[0] = _vmath2VfToHalfFloats(vec0.get128(), vec1.get128()); + twoQuads[1] = _vmath2VfToHalfFloats(vec2.get128(), vec3.get128()); +} + +inline Vector4 & Vector4::operator =( Vector4 vec ) +{ + mVec128 = vec.mVec128; + return *this; +} + +inline Vector4 & Vector4::setXYZ( Vector3 vec ) +{ + mVec128 = spu_sel( vec.get128(), mVec128, (vec_uint4)spu_maskb(0x000f) ); + return *this; +} + +inline const Vector3 Vector4::getXYZ( ) const +{ + return Vector3( mVec128 ); +} + +inline Vector4 & Vector4::setX( float _x ) +{ + mVec128 = spu_insert( _x, mVec128, 0 ); + return *this; +} + +inline float Vector4::getX( ) const +{ + return spu_extract( mVec128, 0 ); +} + +inline Vector4 & Vector4::setY( float _y ) +{ + mVec128 = spu_insert( _y, mVec128, 1 ); + return *this; +} + +inline float Vector4::getY( ) const +{ + return spu_extract( mVec128, 1 ); +} + +inline Vector4 & Vector4::setZ( float _z ) +{ + mVec128 = spu_insert( _z, mVec128, 2 ); + return *this; +} + +inline float Vector4::getZ( ) const +{ + return spu_extract( mVec128, 2 ); +} + +inline Vector4 & Vector4::setW( float _w ) +{ + mVec128 = spu_insert( _w, mVec128, 3 ); + return *this; +} + +inline float Vector4::getW( ) const +{ + return spu_extract( mVec128, 3 ); +} + +inline Vector4 & Vector4::setElem( int idx, float value ) +{ + mVec128 = spu_insert( value, mVec128, idx ); + return *this; +} + +inline float Vector4::getElem( int idx ) const +{ + return spu_extract( mVec128, idx ); +} + +inline VecIdx Vector4::operator []( int idx ) +{ + return VecIdx( mVec128, idx ); +} + +inline float Vector4::operator []( int idx ) const +{ + return spu_extract( mVec128, idx ); +} + +inline const Vector4 Vector4::operator +( Vector4 vec ) const +{ + return Vector4( spu_add( mVec128, vec.mVec128 ) ); +} + +inline const Vector4 Vector4::operator -( Vector4 vec ) const +{ + return Vector4( spu_sub( mVec128, vec.mVec128 ) ); +} + +inline const Vector4 Vector4::operator *( float scalar ) const +{ + return Vector4( spu_mul( mVec128, spu_splats(scalar) ) ); +} + +inline Vector4 & Vector4::operator +=( Vector4 vec ) +{ + *this = *this + vec; + return *this; +} + +inline Vector4 & Vector4::operator -=( Vector4 vec ) +{ + *this = *this - vec; + return *this; +} + +inline Vector4 & Vector4::operator *=( float scalar ) +{ + *this = *this * scalar; + return *this; +} + +inline const Vector4 Vector4::operator /( float scalar ) const +{ + return Vector4( divf4( mVec128, spu_splats(scalar) ) ); +} + +inline Vector4 & Vector4::operator /=( float scalar ) +{ + *this = *this / scalar; + return *this; +} + +inline const Vector4 Vector4::operator -( ) const +{ + return Vector4( negatef4( mVec128 ) ); +} + +inline const Vector4 operator *( float scalar, Vector4 vec ) +{ + return vec * scalar; +} + +inline const Vector4 mulPerElem( Vector4 vec0, Vector4 vec1 ) +{ + return Vector4( spu_mul( vec0.get128(), vec1.get128() ) ); +} + +inline const Vector4 divPerElem( Vector4 vec0, Vector4 vec1 ) +{ + return Vector4( divf4( vec0.get128(), vec1.get128() ) ); +} + +inline const Vector4 recipPerElem( Vector4 vec ) +{ + return Vector4( recipf4( vec.get128() ) ); +} + +inline const Vector4 sqrtPerElem( Vector4 vec ) +{ + return Vector4( sqrtf4( vec.get128() ) ); +} + +inline const Vector4 rsqrtPerElem( Vector4 vec ) +{ + return Vector4( rsqrtf4( vec.get128() ) ); +} + +inline const Vector4 absPerElem( Vector4 vec ) +{ + return Vector4( fabsf4( vec.get128() ) ); +} + +inline const Vector4 copySignPerElem( Vector4 vec0, Vector4 vec1 ) +{ + return Vector4( copysignf4( vec0.get128(), vec1.get128() ) ); +} + +inline const Vector4 maxPerElem( Vector4 vec0, Vector4 vec1 ) +{ + return Vector4( fmaxf4( vec0.get128(), vec1.get128() ) ); +} + +inline float maxElem( Vector4 vec ) +{ + vec_float4 result; + result = fmaxf4( spu_promote( spu_extract( vec.get128(), 1 ), 0 ), vec.get128() ); + result = fmaxf4( spu_promote( spu_extract( vec.get128(), 2 ), 0 ), result ); + result = fmaxf4( spu_promote( spu_extract( vec.get128(), 3 ), 0 ), result ); + return spu_extract( result, 0 ); +} + +inline const Vector4 minPerElem( Vector4 vec0, Vector4 vec1 ) +{ + return Vector4( fminf4( vec0.get128(), vec1.get128() ) ); +} + +inline float minElem( Vector4 vec ) +{ + vec_float4 result; + result = fminf4( spu_promote( spu_extract( vec.get128(), 1 ), 0 ), vec.get128() ); + result = fminf4( spu_promote( spu_extract( vec.get128(), 2 ), 0 ), result ); + result = fminf4( spu_promote( spu_extract( vec.get128(), 3 ), 0 ), result ); + return spu_extract( result, 0 ); +} + +inline float sum( Vector4 vec ) +{ + return + spu_extract( vec.get128(), 0 ) + + spu_extract( vec.get128(), 1 ) + + spu_extract( vec.get128(), 2 ) + + spu_extract( vec.get128(), 3 ); +} + +inline float dot( Vector4 vec0, Vector4 vec1 ) +{ + return spu_extract( _vmathVfDot4( vec0.get128(), vec1.get128() ), 0 ); +} + +inline float lengthSqr( Vector4 vec ) +{ + return spu_extract( _vmathVfDot4( vec.get128(), vec.get128() ), 0 ); +} + +inline float length( Vector4 vec ) +{ + return sqrtf( lengthSqr( vec ) ); +} + +inline const Vector4 normalize( Vector4 vec ) +{ + vec_float4 dot = _vmathVfDot4( vec.get128(), vec.get128() ); + return Vector4( spu_mul( vec.get128(), rsqrtf4( dot ) ) ); +} + +inline const Vector4 select( Vector4 vec0, Vector4 vec1, bool select1 ) +{ + return Vector4( spu_sel( vec0.get128(), vec1.get128(), spu_splats( (unsigned int)-(select1 > 0) ) ) ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( Vector4 vec ) +{ + union { vec_float4 v; float s[4]; } tmp; + tmp.v = vec.get128(); + printf( "( %f %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] ); +} + +inline void print( Vector4 vec, const char * name ) +{ + union { vec_float4 v; float s[4]; } tmp; + tmp.v = vec.get128(); + printf( "%s: ( %f %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] ); +} + +#endif + +inline Point3::Point3( float _x, float _y, float _z ) +{ + mVec128 = (vec_float4){ _x, _y, _z, 0.0f }; +} + +inline Point3::Point3( Vector3 vec ) +{ + mVec128 = vec.get128(); +} + +inline Point3::Point3( float scalar ) +{ + mVec128 = spu_splats( scalar ); +} + +inline Point3::Point3( vec_float4 vf4 ) +{ + mVec128 = vf4; +} + +inline const Point3 lerp( float t, Point3 pnt0, Point3 pnt1 ) +{ + return ( pnt0 + ( ( pnt1 - pnt0 ) * t ) ); +} + +inline vec_float4 Point3::get128( ) const +{ + return mVec128; +} + +inline void storeXYZ( Point3 pnt, vec_float4 * quad ) +{ + vec_float4 dstVec = *quad; + vec_uint4 mask = (vec_uint4)spu_maskb(0x000f); + dstVec = spu_sel(pnt.get128(), dstVec, mask); + *quad = dstVec; +} + +inline void loadXYZArray( Point3 & pnt0, Point3 & pnt1, Point3 & pnt2, Point3 & pnt3, const vec_float4 * threeQuads ) +{ + vec_float4 xyzx, yzxy, zxyz, xyz1, xyz2, xyz3; + xyzx = threeQuads[0]; + yzxy = threeQuads[1]; + zxyz = threeQuads[2]; + xyz1 = spu_shuffle( xyzx, yzxy, _VECTORMATH_SHUF_WABC ); + xyz2 = spu_shuffle( yzxy, zxyz, _VECTORMATH_SHUF_ZWAB ); + xyz3 = spu_rlqwbyte( zxyz, 4 ); + pnt0 = Point3( xyzx ); + pnt1 = Point3( xyz1 ); + pnt2 = Point3( xyz2 ); + pnt3 = Point3( xyz3 ); +} + +inline void storeXYZArray( Point3 pnt0, Point3 pnt1, Point3 pnt2, Point3 pnt3, vec_float4 * threeQuads ) +{ + vec_float4 xyzx, yzxy, zxyz; + xyzx = spu_shuffle( pnt0.get128(), pnt1.get128(), _VECTORMATH_SHUF_XYZA ); + yzxy = spu_shuffle( pnt1.get128(), pnt2.get128(), _VECTORMATH_SHUF_YZAB ); + zxyz = spu_shuffle( pnt2.get128(), pnt3.get128(), _VECTORMATH_SHUF_ZABC ); + threeQuads[0] = xyzx; + threeQuads[1] = yzxy; + threeQuads[2] = zxyz; +} + +inline void storeHalfFloats( Point3 pnt0, Point3 pnt1, Point3 pnt2, Point3 pnt3, Point3 pnt4, Point3 pnt5, Point3 pnt6, Point3 pnt7, vec_ushort8 * threeQuads ) +{ + vec_float4 xyz0[3]; + vec_float4 xyz1[3]; + storeXYZArray( pnt0, pnt1, pnt2, pnt3, xyz0 ); + storeXYZArray( pnt4, pnt5, pnt6, pnt7, xyz1 ); + threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); + threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); + threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); +} + +inline Point3 & Point3::operator =( Point3 pnt ) +{ + mVec128 = pnt.mVec128; + return *this; +} + +inline Point3 & Point3::setX( float _x ) +{ + mVec128 = spu_insert( _x, mVec128, 0 ); + return *this; +} + +inline float Point3::getX( ) const +{ + return spu_extract( mVec128, 0 ); +} + +inline Point3 & Point3::setY( float _y ) +{ + mVec128 = spu_insert( _y, mVec128, 1 ); + return *this; +} + +inline float Point3::getY( ) const +{ + return spu_extract( mVec128, 1 ); +} + +inline Point3 & Point3::setZ( float _z ) +{ + mVec128 = spu_insert( _z, mVec128, 2 ); + return *this; +} + +inline float Point3::getZ( ) const +{ + return spu_extract( mVec128, 2 ); +} + +inline Point3 & Point3::setElem( int idx, float value ) +{ + mVec128 = spu_insert( value, mVec128, idx ); + return *this; +} + +inline float Point3::getElem( int idx ) const +{ + return spu_extract( mVec128, idx ); +} + +inline VecIdx Point3::operator []( int idx ) +{ + return VecIdx( mVec128, idx ); +} + +inline float Point3::operator []( int idx ) const +{ + return spu_extract( mVec128, idx ); +} + +inline const Vector3 Point3::operator -( Point3 pnt ) const +{ + return Vector3( spu_sub( mVec128, pnt.mVec128 ) ); +} + +inline const Point3 Point3::operator +( Vector3 vec ) const +{ + return Point3( spu_add( mVec128, vec.get128() ) ); +} + +inline const Point3 Point3::operator -( Vector3 vec ) const +{ + return Point3( spu_sub( mVec128, vec.get128() ) ); +} + +inline Point3 & Point3::operator +=( Vector3 vec ) +{ + *this = *this + vec; + return *this; +} + +inline Point3 & Point3::operator -=( Vector3 vec ) +{ + *this = *this - vec; + return *this; +} + +inline const Point3 mulPerElem( Point3 pnt0, Point3 pnt1 ) +{ + return Point3( spu_mul( pnt0.get128(), pnt1.get128() ) ); +} + +inline const Point3 divPerElem( Point3 pnt0, Point3 pnt1 ) +{ + return Point3( divf4( pnt0.get128(), pnt1.get128() ) ); +} + +inline const Point3 recipPerElem( Point3 pnt ) +{ + return Point3( recipf4( pnt.get128() ) ); +} + +inline const Point3 sqrtPerElem( Point3 pnt ) +{ + return Point3( sqrtf4( pnt.get128() ) ); +} + +inline const Point3 rsqrtPerElem( Point3 pnt ) +{ + return Point3( rsqrtf4( pnt.get128() ) ); +} + +inline const Point3 absPerElem( Point3 pnt ) +{ + return Point3( fabsf4( pnt.get128() ) ); +} + +inline const Point3 copySignPerElem( Point3 pnt0, Point3 pnt1 ) +{ + return Point3( copysignf4( pnt0.get128(), pnt1.get128() ) ); +} + +inline const Point3 maxPerElem( Point3 pnt0, Point3 pnt1 ) +{ + return Point3( fmaxf4( pnt0.get128(), pnt1.get128() ) ); +} + +inline float maxElem( Point3 pnt ) +{ + vec_float4 result; + result = fmaxf4( spu_promote( spu_extract( pnt.get128(), 1 ), 0 ), pnt.get128() ); + result = fmaxf4( spu_promote( spu_extract( pnt.get128(), 2 ), 0 ), result ); + return spu_extract( result, 0 ); +} + +inline const Point3 minPerElem( Point3 pnt0, Point3 pnt1 ) +{ + return Point3( fminf4( pnt0.get128(), pnt1.get128() ) ); +} + +inline float minElem( Point3 pnt ) +{ + vec_float4 result; + result = fminf4( spu_promote( spu_extract( pnt.get128(), 1 ), 0 ), pnt.get128() ); + result = fminf4( spu_promote( spu_extract( pnt.get128(), 2 ), 0 ), result ); + return spu_extract( result, 0 ); +} + +inline float sum( Point3 pnt ) +{ + return + spu_extract( pnt.get128(), 0 ) + + spu_extract( pnt.get128(), 1 ) + + spu_extract( pnt.get128(), 2 ); +} + +inline const Point3 scale( Point3 pnt, float scaleVal ) +{ + return mulPerElem( pnt, Point3( scaleVal ) ); +} + +inline const Point3 scale( Point3 pnt, Vector3 scaleVec ) +{ + return mulPerElem( pnt, Point3( scaleVec ) ); +} + +inline float projection( Point3 pnt, Vector3 unitVec ) +{ + return spu_extract( _vmathVfDot3( pnt.get128(), unitVec.get128() ), 0 ); +} + +inline float distSqrFromOrigin( Point3 pnt ) +{ + return lengthSqr( Vector3( pnt ) ); +} + +inline float distFromOrigin( Point3 pnt ) +{ + return length( Vector3( pnt ) ); +} + +inline float distSqr( Point3 pnt0, Point3 pnt1 ) +{ + return lengthSqr( ( pnt1 - pnt0 ) ); +} + +inline float dist( Point3 pnt0, Point3 pnt1 ) +{ + return length( ( pnt1 - pnt0 ) ); +} + +inline const Point3 select( Point3 pnt0, Point3 pnt1, bool select1 ) +{ + return Point3( spu_sel( pnt0.get128(), pnt1.get128(), spu_splats( (unsigned int)-(select1 > 0) ) ) ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( Point3 pnt ) +{ + union { vec_float4 v; float s[4]; } tmp; + tmp.v = pnt.get128(); + printf( "( %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2] ); +} + +inline void print( Point3 pnt, const char * name ) +{ + union { vec_float4 v; float s[4]; } tmp; + tmp.v = pnt.get128(); + printf( "%s: ( %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2] ); +} + +#endif + +} // namespace Aos +} // namespace Vectormath + +#endif diff --git a/vectormathlibrary/include/vectormath/spu/cpp/vec_soa.h b/vectormathlibrary/include/vectormath/spu/cpp/vec_soa.h new file mode 100644 index 000000000..1ac657732 --- /dev/null +++ b/vectormathlibrary/include/vectormath/spu/cpp/vec_soa.h @@ -0,0 +1,1439 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_VEC_SOA_CPP_H +#define _VECTORMATH_VEC_SOA_CPP_H +//----------------------------------------------------------------------------- +// Constants +// for shuffles, words are labeled [x,y,z,w] [a,b,c,d] + +#define _VECTORMATH_SHUF_X 0x00010203 +#define _VECTORMATH_SHUF_Y 0x04050607 +#define _VECTORMATH_SHUF_Z 0x08090a0b +#define _VECTORMATH_SHUF_W 0x0c0d0e0f +#define _VECTORMATH_SHUF_A 0x10111213 +#define _VECTORMATH_SHUF_B 0x14151617 +#define _VECTORMATH_SHUF_C 0x18191a1b +#define _VECTORMATH_SHUF_D 0x1c1d1e1f +#define _VECTORMATH_SHUF_0 0x80808080 +#define _VECTORMATH_SHUF_XAYB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_B }) +#define _VECTORMATH_SHUF_ZCWD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_D }) +#define _VECTORMATH_SHUF_ZBW0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_0 }) +#define _VECTORMATH_SHUF_XCY0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_0 }) +#define _VECTORMATH_SHUF_ZDW0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_D, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_0 }) +#define _VECTORMATH_SHUF_XAZC ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_C }) +#define _VECTORMATH_SHUF_ZDXB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_D, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_B }) +#define _VECTORMATH_SHUF_YBWD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_D }) +#define _VECTORMATH_SHUF_XDZB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_D, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_B }) +#define _VECTORMATH_SHUF_YAWC ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_C }) +#define _VECTORMATH_SHUF_ZBXD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_D }) +#define _VECTORMATH_SHUF_XYCD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_D }) +#define _VECTORMATH_SLERP_TOL 0.999f + +//----------------------------------------------------------------------------- +// Definitions + +#ifndef _VECTORMATH_INTERNAL_FUNCTIONS +#define _VECTORMATH_INTERNAL_FUNCTIONS + +#endif + +namespace Vectormath { +namespace Soa { + +inline Vector3::Vector3( const Vector3 & vec ) +{ + mX = vec.mX; + mY = vec.mY; + mZ = vec.mZ; +} + +inline Vector3::Vector3( vec_float4 _x, vec_float4 _y, vec_float4 _z ) +{ + mX = _x; + mY = _y; + mZ = _z; +} + +inline Vector3::Vector3( const Point3 & pnt ) +{ + mX = pnt.getX(); + mY = pnt.getY(); + mZ = pnt.getZ(); +} + +inline Vector3::Vector3( vec_float4 scalar ) +{ + mX = scalar; + mY = scalar; + mZ = scalar; +} + +inline Vector3::Vector3( Aos::Vector3 vec ) +{ + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); + vec_float4 vec128 = vec.get128(); + mX = spu_shuffle( vec128, vec128, shuffle_xxxx ); + mY = spu_shuffle( vec128, vec128, shuffle_yyyy ); + mZ = spu_shuffle( vec128, vec128, shuffle_zzzz ); +} + +inline Vector3::Vector3( Aos::Vector3 vec0, Aos::Vector3 vec1, Aos::Vector3 vec2, Aos::Vector3 vec3 ) +{ + vec_float4 tmp0, tmp1, tmp2, tmp3; + tmp0 = spu_shuffle( vec0.get128(), vec2.get128(), _VECTORMATH_SHUF_XAYB ); + tmp1 = spu_shuffle( vec1.get128(), vec3.get128(), _VECTORMATH_SHUF_XAYB ); + tmp2 = spu_shuffle( vec0.get128(), vec2.get128(), _VECTORMATH_SHUF_ZCWD ); + tmp3 = spu_shuffle( vec1.get128(), vec3.get128(), _VECTORMATH_SHUF_ZCWD ); + mX = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB ); + mY = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD ); + mZ = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB ); +} + +inline const Vector3 Vector3::xAxis( ) +{ + return Vector3( spu_splats(1.0f), spu_splats(0.0f), spu_splats(0.0f) ); +} + +inline const Vector3 Vector3::yAxis( ) +{ + return Vector3( spu_splats(0.0f), spu_splats(1.0f), spu_splats(0.0f) ); +} + +inline const Vector3 Vector3::zAxis( ) +{ + return Vector3( spu_splats(0.0f), spu_splats(0.0f), spu_splats(1.0f) ); +} + +inline const Vector3 lerp( vec_float4 t, const Vector3 & vec0, const Vector3 & vec1 ) +{ + return ( vec0 + ( ( vec1 - vec0 ) * t ) ); +} + +inline const Vector3 slerp( vec_float4 t, const Vector3 & unitVec0, const Vector3 & unitVec1 ) +{ + vec_float4 recipSinAngle, scale0, scale1, cosAngle, angle; + vec_uint4 selectMask; + cosAngle = dot( unitVec0, unitVec1 ); + selectMask = (vec_uint4)spu_cmpgt( spu_splats(_VECTORMATH_SLERP_TOL), cosAngle ); + angle = acosf4( cosAngle ); + recipSinAngle = recipf4( sinf4( angle ) ); + scale0 = spu_sel( spu_sub( spu_splats(1.0f), t ), spu_mul( sinf4( spu_mul( spu_sub( spu_splats(1.0f), t ), angle ) ), recipSinAngle ), selectMask ); + scale1 = spu_sel( t, spu_mul( sinf4( spu_mul( t, angle ) ), recipSinAngle ), selectMask ); + return ( ( unitVec0 * scale0 ) + ( unitVec1 * scale1 ) ); +} + +inline void Vector3::get4Aos( Aos::Vector3 & result0, Aos::Vector3 & result1, Aos::Vector3 & result2, Aos::Vector3 & result3 ) const +{ + vec_float4 tmp0, tmp1; + tmp0 = spu_shuffle( mX, mZ, _VECTORMATH_SHUF_XAYB ); + tmp1 = spu_shuffle( mX, mZ, _VECTORMATH_SHUF_ZCWD ); + result0 = Aos::Vector3( spu_shuffle( tmp0, mY, _VECTORMATH_SHUF_XAYB ) ); + result1 = Aos::Vector3( spu_shuffle( tmp0, mY, _VECTORMATH_SHUF_ZBW0 ) ); + result2 = Aos::Vector3( spu_shuffle( tmp1, mY, _VECTORMATH_SHUF_XCY0 ) ); + result3 = Aos::Vector3( spu_shuffle( tmp1, mY, _VECTORMATH_SHUF_ZDW0 ) ); +} + +inline void loadXYZArray( Vector3 & vec, const vec_float4 * threeQuads ) +{ + vec_float4 xyxy, yzyz, zxzx, xyzx, yzxy, zxyz; + xyzx = threeQuads[0]; + yzxy = threeQuads[1]; + zxyz = threeQuads[2]; + xyxy = spu_shuffle( xyzx, yzxy, _VECTORMATH_SHUF_XYCD ); + zxzx = spu_shuffle( zxyz, xyzx, _VECTORMATH_SHUF_XYCD ); + yzyz = spu_shuffle( yzxy, zxyz, _VECTORMATH_SHUF_XYCD ); + vec.setX( spu_shuffle( xyxy, zxzx, _VECTORMATH_SHUF_XDZB ) ); + vec.setY( spu_shuffle( xyxy, yzyz, _VECTORMATH_SHUF_YAWC ) ); + vec.setZ( spu_shuffle( zxzx, yzyz, _VECTORMATH_SHUF_ZBXD ) ); +} + +inline void storeXYZArray( const Vector3 & vec, vec_float4 * threeQuads ) +{ + vec_float4 xyzx, yzxy, zxyz, xyxy, zxzx, yzyz; + xyxy = spu_shuffle( vec.getX(), vec.getY(), _VECTORMATH_SHUF_XAZC ); + zxzx = spu_shuffle( vec.getZ(), vec.getX(), _VECTORMATH_SHUF_ZDXB ); + yzyz = spu_shuffle( vec.getY(), vec.getZ(), _VECTORMATH_SHUF_YBWD ); + xyzx = spu_shuffle( xyxy, zxzx, _VECTORMATH_SHUF_XYCD ); + yzxy = spu_shuffle( yzyz, xyxy, _VECTORMATH_SHUF_XYCD ); + zxyz = spu_shuffle( zxzx, yzyz, _VECTORMATH_SHUF_XYCD ); + threeQuads[0] = xyzx; + threeQuads[1] = yzxy; + threeQuads[2] = zxyz; +} + +inline void storeHalfFloats( const Vector3 & vec0, const Vector3 & vec1, vec_ushort8 * threeQuads ) +{ + vec_float4 xyz0[3]; + vec_float4 xyz1[3]; + storeXYZArray( vec0, xyz0 ); + storeXYZArray( vec1, xyz1 ); + threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); + threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); + threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); +} + +inline Vector3 & Vector3::operator =( const Vector3 & vec ) +{ + mX = vec.mX; + mY = vec.mY; + mZ = vec.mZ; + return *this; +} + +inline Vector3 & Vector3::setX( vec_float4 _x ) +{ + mX = _x; + return *this; +} + +inline vec_float4 Vector3::getX( ) const +{ + return mX; +} + +inline Vector3 & Vector3::setY( vec_float4 _y ) +{ + mY = _y; + return *this; +} + +inline vec_float4 Vector3::getY( ) const +{ + return mY; +} + +inline Vector3 & Vector3::setZ( vec_float4 _z ) +{ + mZ = _z; + return *this; +} + +inline vec_float4 Vector3::getZ( ) const +{ + return mZ; +} + +inline Vector3 & Vector3::setElem( int idx, vec_float4 value ) +{ + *(&mX + idx) = value; + return *this; +} + +inline vec_float4 Vector3::getElem( int idx ) const +{ + return *(&mX + idx); +} + +inline Vector3::vec_float4_t & Vector3::operator []( int idx ) +{ + return *(&mX + idx); +} + +inline vec_float4 Vector3::operator []( int idx ) const +{ + return *(&mX + idx); +} + +inline const Vector3 Vector3::operator +( const Vector3 & vec ) const +{ + return Vector3( + spu_add( mX, vec.mX ), + spu_add( mY, vec.mY ), + spu_add( mZ, vec.mZ ) + ); +} + +inline const Vector3 Vector3::operator -( const Vector3 & vec ) const +{ + return Vector3( + spu_sub( mX, vec.mX ), + spu_sub( mY, vec.mY ), + spu_sub( mZ, vec.mZ ) + ); +} + +inline const Point3 Vector3::operator +( const Point3 & pnt ) const +{ + return Point3( + spu_add( mX, pnt.getX() ), + spu_add( mY, pnt.getY() ), + spu_add( mZ, pnt.getZ() ) + ); +} + +inline const Vector3 Vector3::operator *( vec_float4 scalar ) const +{ + return Vector3( + spu_mul( mX, scalar ), + spu_mul( mY, scalar ), + spu_mul( mZ, scalar ) + ); +} + +inline Vector3 & Vector3::operator +=( const Vector3 & vec ) +{ + *this = *this + vec; + return *this; +} + +inline Vector3 & Vector3::operator -=( const Vector3 & vec ) +{ + *this = *this - vec; + return *this; +} + +inline Vector3 & Vector3::operator *=( vec_float4 scalar ) +{ + *this = *this * scalar; + return *this; +} + +inline const Vector3 Vector3::operator /( vec_float4 scalar ) const +{ + return Vector3( + divf4( mX, scalar ), + divf4( mY, scalar ), + divf4( mZ, scalar ) + ); +} + +inline Vector3 & Vector3::operator /=( vec_float4 scalar ) +{ + *this = *this / scalar; + return *this; +} + +inline const Vector3 Vector3::operator -( ) const +{ + return Vector3( + negatef4( mX ), + negatef4( mY ), + negatef4( mZ ) + ); +} + +inline const Vector3 operator *( vec_float4 scalar, const Vector3 & vec ) +{ + return vec * scalar; +} + +inline const Vector3 mulPerElem( const Vector3 & vec0, const Vector3 & vec1 ) +{ + return Vector3( + spu_mul( vec0.getX(), vec1.getX() ), + spu_mul( vec0.getY(), vec1.getY() ), + spu_mul( vec0.getZ(), vec1.getZ() ) + ); +} + +inline const Vector3 divPerElem( const Vector3 & vec0, const Vector3 & vec1 ) +{ + return Vector3( + divf4( vec0.getX(), vec1.getX() ), + divf4( vec0.getY(), vec1.getY() ), + divf4( vec0.getZ(), vec1.getZ() ) + ); +} + +inline const Vector3 recipPerElem( const Vector3 & vec ) +{ + return Vector3( + recipf4( vec.getX() ), + recipf4( vec.getY() ), + recipf4( vec.getZ() ) + ); +} + +inline const Vector3 sqrtPerElem( const Vector3 & vec ) +{ + return Vector3( + sqrtf4( vec.getX() ), + sqrtf4( vec.getY() ), + sqrtf4( vec.getZ() ) + ); +} + +inline const Vector3 rsqrtPerElem( const Vector3 & vec ) +{ + return Vector3( + rsqrtf4( vec.getX() ), + rsqrtf4( vec.getY() ), + rsqrtf4( vec.getZ() ) + ); +} + +inline const Vector3 absPerElem( const Vector3 & vec ) +{ + return Vector3( + fabsf4( vec.getX() ), + fabsf4( vec.getY() ), + fabsf4( vec.getZ() ) + ); +} + +inline const Vector3 copySignPerElem( const Vector3 & vec0, const Vector3 & vec1 ) +{ + return Vector3( + copysignf4( vec0.getX(), vec1.getX() ), + copysignf4( vec0.getY(), vec1.getY() ), + copysignf4( vec0.getZ(), vec1.getZ() ) + ); +} + +inline const Vector3 maxPerElem( const Vector3 & vec0, const Vector3 & vec1 ) +{ + return Vector3( + fmaxf4( vec0.getX(), vec1.getX() ), + fmaxf4( vec0.getY(), vec1.getY() ), + fmaxf4( vec0.getZ(), vec1.getZ() ) + ); +} + +inline vec_float4 maxElem( const Vector3 & vec ) +{ + vec_float4 result; + result = fmaxf4( vec.getX(), vec.getY() ); + result = fmaxf4( vec.getZ(), result ); + return result; +} + +inline const Vector3 minPerElem( const Vector3 & vec0, const Vector3 & vec1 ) +{ + return Vector3( + fminf4( vec0.getX(), vec1.getX() ), + fminf4( vec0.getY(), vec1.getY() ), + fminf4( vec0.getZ(), vec1.getZ() ) + ); +} + +inline vec_float4 minElem( const Vector3 & vec ) +{ + vec_float4 result; + result = fminf4( vec.getX(), vec.getY() ); + result = fminf4( vec.getZ(), result ); + return result; +} + +inline vec_float4 sum( const Vector3 & vec ) +{ + vec_float4 result; + result = spu_add( vec.getX(), vec.getY() ); + result = spu_add( result, vec.getZ() ); + return result; +} + +inline vec_float4 dot( const Vector3 & vec0, const Vector3 & vec1 ) +{ + vec_float4 result; + result = spu_mul( vec0.getX(), vec1.getX() ); + result = spu_add( result, spu_mul( vec0.getY(), vec1.getY() ) ); + result = spu_add( result, spu_mul( vec0.getZ(), vec1.getZ() ) ); + return result; +} + +inline vec_float4 lengthSqr( const Vector3 & vec ) +{ + vec_float4 result; + result = spu_mul( vec.getX(), vec.getX() ); + result = spu_add( result, spu_mul( vec.getY(), vec.getY() ) ); + result = spu_add( result, spu_mul( vec.getZ(), vec.getZ() ) ); + return result; +} + +inline vec_float4 length( const Vector3 & vec ) +{ + return sqrtf4( lengthSqr( vec ) ); +} + +inline const Vector3 normalize( const Vector3 & vec ) +{ + vec_float4 lenSqr, lenInv; + lenSqr = lengthSqr( vec ); + lenInv = rsqrtf4( lenSqr ); + return Vector3( + spu_mul( vec.getX(), lenInv ), + spu_mul( vec.getY(), lenInv ), + spu_mul( vec.getZ(), lenInv ) + ); +} + +inline const Vector3 cross( const Vector3 & vec0, const Vector3 & vec1 ) +{ + return Vector3( + spu_sub( spu_mul( vec0.getY(), vec1.getZ() ), spu_mul( vec0.getZ(), vec1.getY() ) ), + spu_sub( spu_mul( vec0.getZ(), vec1.getX() ), spu_mul( vec0.getX(), vec1.getZ() ) ), + spu_sub( spu_mul( vec0.getX(), vec1.getY() ), spu_mul( vec0.getY(), vec1.getX() ) ) + ); +} + +inline const Vector3 select( const Vector3 & vec0, const Vector3 & vec1, vec_uint4 select1 ) +{ + return Vector3( + spu_sel( vec0.getX(), vec1.getX(), select1 ), + spu_sel( vec0.getY(), vec1.getY(), select1 ), + spu_sel( vec0.getZ(), vec1.getZ(), select1 ) + ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( const Vector3 & vec ) +{ + Aos::Vector3 vec0, vec1, vec2, vec3; + vec.get4Aos( vec0, vec1, vec2, vec3 ); + printf("slot 0:\n"); + print( vec0 ); + printf("slot 1:\n"); + print( vec1 ); + printf("slot 2:\n"); + print( vec2 ); + printf("slot 3:\n"); + print( vec3 ); +} + +inline void print( const Vector3 & vec, const char * name ) +{ + Aos::Vector3 vec0, vec1, vec2, vec3; + printf( "%s:\n", name ); + vec.get4Aos( vec0, vec1, vec2, vec3 ); + printf("slot 0:\n"); + print( vec0 ); + printf("slot 1:\n"); + print( vec1 ); + printf("slot 2:\n"); + print( vec2 ); + printf("slot 3:\n"); + print( vec3 ); +} + +#endif + +inline Vector4::Vector4( const Vector4 & vec ) +{ + mX = vec.mX; + mY = vec.mY; + mZ = vec.mZ; + mW = vec.mW; +} + +inline Vector4::Vector4( vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w ) +{ + mX = _x; + mY = _y; + mZ = _z; + mW = _w; +} + +inline Vector4::Vector4( const Vector3 & xyz, vec_float4 _w ) +{ + this->setXYZ( xyz ); + this->setW( _w ); +} + +inline Vector4::Vector4( const Vector3 & vec ) +{ + mX = vec.getX(); + mY = vec.getY(); + mZ = vec.getZ(); + mW = spu_splats(0.0f); +} + +inline Vector4::Vector4( const Point3 & pnt ) +{ + mX = pnt.getX(); + mY = pnt.getY(); + mZ = pnt.getZ(); + mW = spu_splats(1.0f); +} + +inline Vector4::Vector4( const Quat & quat ) +{ + mX = quat.getX(); + mY = quat.getY(); + mZ = quat.getZ(); + mW = quat.getW(); +} + +inline Vector4::Vector4( vec_float4 scalar ) +{ + mX = scalar; + mY = scalar; + mZ = scalar; + mW = scalar; +} + +inline Vector4::Vector4( Aos::Vector4 vec ) +{ + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); + vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f); + vec_float4 vec128 = vec.get128(); + mX = spu_shuffle( vec128, vec128, shuffle_xxxx ); + mY = spu_shuffle( vec128, vec128, shuffle_yyyy ); + mZ = spu_shuffle( vec128, vec128, shuffle_zzzz ); + mW = spu_shuffle( vec128, vec128, shuffle_wwww ); +} + +inline Vector4::Vector4( Aos::Vector4 vec0, Aos::Vector4 vec1, Aos::Vector4 vec2, Aos::Vector4 vec3 ) +{ + vec_float4 tmp0, tmp1, tmp2, tmp3; + tmp0 = spu_shuffle( vec0.get128(), vec2.get128(), _VECTORMATH_SHUF_XAYB ); + tmp1 = spu_shuffle( vec1.get128(), vec3.get128(), _VECTORMATH_SHUF_XAYB ); + tmp2 = spu_shuffle( vec0.get128(), vec2.get128(), _VECTORMATH_SHUF_ZCWD ); + tmp3 = spu_shuffle( vec1.get128(), vec3.get128(), _VECTORMATH_SHUF_ZCWD ); + mX = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB ); + mY = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD ); + mZ = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB ); + mW = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_ZCWD ); +} + +inline const Vector4 Vector4::xAxis( ) +{ + return Vector4( spu_splats(1.0f), spu_splats(0.0f), spu_splats(0.0f), spu_splats(0.0f) ); +} + +inline const Vector4 Vector4::yAxis( ) +{ + return Vector4( spu_splats(0.0f), spu_splats(1.0f), spu_splats(0.0f), spu_splats(0.0f) ); +} + +inline const Vector4 Vector4::zAxis( ) +{ + return Vector4( spu_splats(0.0f), spu_splats(0.0f), spu_splats(1.0f), spu_splats(0.0f) ); +} + +inline const Vector4 Vector4::wAxis( ) +{ + return Vector4( spu_splats(0.0f), spu_splats(0.0f), spu_splats(0.0f), spu_splats(1.0f) ); +} + +inline const Vector4 lerp( vec_float4 t, const Vector4 & vec0, const Vector4 & vec1 ) +{ + return ( vec0 + ( ( vec1 - vec0 ) * t ) ); +} + +inline const Vector4 slerp( vec_float4 t, const Vector4 & unitVec0, const Vector4 & unitVec1 ) +{ + vec_float4 recipSinAngle, scale0, scale1, cosAngle, angle; + vec_uint4 selectMask; + cosAngle = dot( unitVec0, unitVec1 ); + selectMask = (vec_uint4)spu_cmpgt( spu_splats(_VECTORMATH_SLERP_TOL), cosAngle ); + angle = acosf4( cosAngle ); + recipSinAngle = recipf4( sinf4( angle ) ); + scale0 = spu_sel( spu_sub( spu_splats(1.0f), t ), spu_mul( sinf4( spu_mul( spu_sub( spu_splats(1.0f), t ), angle ) ), recipSinAngle ), selectMask ); + scale1 = spu_sel( t, spu_mul( sinf4( spu_mul( t, angle ) ), recipSinAngle ), selectMask ); + return ( ( unitVec0 * scale0 ) + ( unitVec1 * scale1 ) ); +} + +inline void Vector4::get4Aos( Aos::Vector4 & result0, Aos::Vector4 & result1, Aos::Vector4 & result2, Aos::Vector4 & result3 ) const +{ + vec_float4 tmp0, tmp1, tmp2, tmp3; + tmp0 = spu_shuffle( mX, mZ, _VECTORMATH_SHUF_XAYB ); + tmp1 = spu_shuffle( mY, mW, _VECTORMATH_SHUF_XAYB ); + tmp2 = spu_shuffle( mX, mZ, _VECTORMATH_SHUF_ZCWD ); + tmp3 = spu_shuffle( mY, mW, _VECTORMATH_SHUF_ZCWD ); + result0 = Aos::Vector4( spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB ) ); + result1 = Aos::Vector4( spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD ) ); + result2 = Aos::Vector4( spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB ) ); + result3 = Aos::Vector4( spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_ZCWD ) ); +} + +inline void storeHalfFloats( const Vector4 & vec, vec_ushort8 * twoQuads ) +{ + Aos::Vector4 v0, v1, v2, v3; + vec.get4Aos( v0, v1, v2, v3 ); + twoQuads[0] = _vmath2VfToHalfFloats(v0.get128(), v1.get128()); + twoQuads[1] = _vmath2VfToHalfFloats(v2.get128(), v3.get128()); +} + +inline Vector4 & Vector4::operator =( const Vector4 & vec ) +{ + mX = vec.mX; + mY = vec.mY; + mZ = vec.mZ; + mW = vec.mW; + return *this; +} + +inline Vector4 & Vector4::setXYZ( const Vector3 & vec ) +{ + mX = vec.getX(); + mY = vec.getY(); + mZ = vec.getZ(); + return *this; +} + +inline const Vector3 Vector4::getXYZ( ) const +{ + return Vector3( mX, mY, mZ ); +} + +inline Vector4 & Vector4::setX( vec_float4 _x ) +{ + mX = _x; + return *this; +} + +inline vec_float4 Vector4::getX( ) const +{ + return mX; +} + +inline Vector4 & Vector4::setY( vec_float4 _y ) +{ + mY = _y; + return *this; +} + +inline vec_float4 Vector4::getY( ) const +{ + return mY; +} + +inline Vector4 & Vector4::setZ( vec_float4 _z ) +{ + mZ = _z; + return *this; +} + +inline vec_float4 Vector4::getZ( ) const +{ + return mZ; +} + +inline Vector4 & Vector4::setW( vec_float4 _w ) +{ + mW = _w; + return *this; +} + +inline vec_float4 Vector4::getW( ) const +{ + return mW; +} + +inline Vector4 & Vector4::setElem( int idx, vec_float4 value ) +{ + *(&mX + idx) = value; + return *this; +} + +inline vec_float4 Vector4::getElem( int idx ) const +{ + return *(&mX + idx); +} + +inline Vector4::vec_float4_t & Vector4::operator []( int idx ) +{ + return *(&mX + idx); +} + +inline vec_float4 Vector4::operator []( int idx ) const +{ + return *(&mX + idx); +} + +inline const Vector4 Vector4::operator +( const Vector4 & vec ) const +{ + return Vector4( + spu_add( mX, vec.mX ), + spu_add( mY, vec.mY ), + spu_add( mZ, vec.mZ ), + spu_add( mW, vec.mW ) + ); +} + +inline const Vector4 Vector4::operator -( const Vector4 & vec ) const +{ + return Vector4( + spu_sub( mX, vec.mX ), + spu_sub( mY, vec.mY ), + spu_sub( mZ, vec.mZ ), + spu_sub( mW, vec.mW ) + ); +} + +inline const Vector4 Vector4::operator *( vec_float4 scalar ) const +{ + return Vector4( + spu_mul( mX, scalar ), + spu_mul( mY, scalar ), + spu_mul( mZ, scalar ), + spu_mul( mW, scalar ) + ); +} + +inline Vector4 & Vector4::operator +=( const Vector4 & vec ) +{ + *this = *this + vec; + return *this; +} + +inline Vector4 & Vector4::operator -=( const Vector4 & vec ) +{ + *this = *this - vec; + return *this; +} + +inline Vector4 & Vector4::operator *=( vec_float4 scalar ) +{ + *this = *this * scalar; + return *this; +} + +inline const Vector4 Vector4::operator /( vec_float4 scalar ) const +{ + return Vector4( + divf4( mX, scalar ), + divf4( mY, scalar ), + divf4( mZ, scalar ), + divf4( mW, scalar ) + ); +} + +inline Vector4 & Vector4::operator /=( vec_float4 scalar ) +{ + *this = *this / scalar; + return *this; +} + +inline const Vector4 Vector4::operator -( ) const +{ + return Vector4( + negatef4( mX ), + negatef4( mY ), + negatef4( mZ ), + negatef4( mW ) + ); +} + +inline const Vector4 operator *( vec_float4 scalar, const Vector4 & vec ) +{ + return vec * scalar; +} + +inline const Vector4 mulPerElem( const Vector4 & vec0, const Vector4 & vec1 ) +{ + return Vector4( + spu_mul( vec0.getX(), vec1.getX() ), + spu_mul( vec0.getY(), vec1.getY() ), + spu_mul( vec0.getZ(), vec1.getZ() ), + spu_mul( vec0.getW(), vec1.getW() ) + ); +} + +inline const Vector4 divPerElem( const Vector4 & vec0, const Vector4 & vec1 ) +{ + return Vector4( + divf4( vec0.getX(), vec1.getX() ), + divf4( vec0.getY(), vec1.getY() ), + divf4( vec0.getZ(), vec1.getZ() ), + divf4( vec0.getW(), vec1.getW() ) + ); +} + +inline const Vector4 recipPerElem( const Vector4 & vec ) +{ + return Vector4( + recipf4( vec.getX() ), + recipf4( vec.getY() ), + recipf4( vec.getZ() ), + recipf4( vec.getW() ) + ); +} + +inline const Vector4 sqrtPerElem( const Vector4 & vec ) +{ + return Vector4( + sqrtf4( vec.getX() ), + sqrtf4( vec.getY() ), + sqrtf4( vec.getZ() ), + sqrtf4( vec.getW() ) + ); +} + +inline const Vector4 rsqrtPerElem( const Vector4 & vec ) +{ + return Vector4( + rsqrtf4( vec.getX() ), + rsqrtf4( vec.getY() ), + rsqrtf4( vec.getZ() ), + rsqrtf4( vec.getW() ) + ); +} + +inline const Vector4 absPerElem( const Vector4 & vec ) +{ + return Vector4( + fabsf4( vec.getX() ), + fabsf4( vec.getY() ), + fabsf4( vec.getZ() ), + fabsf4( vec.getW() ) + ); +} + +inline const Vector4 copySignPerElem( const Vector4 & vec0, const Vector4 & vec1 ) +{ + return Vector4( + copysignf4( vec0.getX(), vec1.getX() ), + copysignf4( vec0.getY(), vec1.getY() ), + copysignf4( vec0.getZ(), vec1.getZ() ), + copysignf4( vec0.getW(), vec1.getW() ) + ); +} + +inline const Vector4 maxPerElem( const Vector4 & vec0, const Vector4 & vec1 ) +{ + return Vector4( + fmaxf4( vec0.getX(), vec1.getX() ), + fmaxf4( vec0.getY(), vec1.getY() ), + fmaxf4( vec0.getZ(), vec1.getZ() ), + fmaxf4( vec0.getW(), vec1.getW() ) + ); +} + +inline vec_float4 maxElem( const Vector4 & vec ) +{ + vec_float4 result; + result = fmaxf4( vec.getX(), vec.getY() ); + result = fmaxf4( vec.getZ(), result ); + result = fmaxf4( vec.getW(), result ); + return result; +} + +inline const Vector4 minPerElem( const Vector4 & vec0, const Vector4 & vec1 ) +{ + return Vector4( + fminf4( vec0.getX(), vec1.getX() ), + fminf4( vec0.getY(), vec1.getY() ), + fminf4( vec0.getZ(), vec1.getZ() ), + fminf4( vec0.getW(), vec1.getW() ) + ); +} + +inline vec_float4 minElem( const Vector4 & vec ) +{ + vec_float4 result; + result = fminf4( vec.getX(), vec.getY() ); + result = fminf4( vec.getZ(), result ); + result = fminf4( vec.getW(), result ); + return result; +} + +inline vec_float4 sum( const Vector4 & vec ) +{ + vec_float4 result; + result = spu_add( vec.getX(), vec.getY() ); + result = spu_add( result, vec.getZ() ); + result = spu_add( result, vec.getW() ); + return result; +} + +inline vec_float4 dot( const Vector4 & vec0, const Vector4 & vec1 ) +{ + vec_float4 result; + result = spu_mul( vec0.getX(), vec1.getX() ); + result = spu_add( result, spu_mul( vec0.getY(), vec1.getY() ) ); + result = spu_add( result, spu_mul( vec0.getZ(), vec1.getZ() ) ); + result = spu_add( result, spu_mul( vec0.getW(), vec1.getW() ) ); + return result; +} + +inline vec_float4 lengthSqr( const Vector4 & vec ) +{ + vec_float4 result; + result = spu_mul( vec.getX(), vec.getX() ); + result = spu_add( result, spu_mul( vec.getY(), vec.getY() ) ); + result = spu_add( result, spu_mul( vec.getZ(), vec.getZ() ) ); + result = spu_add( result, spu_mul( vec.getW(), vec.getW() ) ); + return result; +} + +inline vec_float4 length( const Vector4 & vec ) +{ + return sqrtf4( lengthSqr( vec ) ); +} + +inline const Vector4 normalize( const Vector4 & vec ) +{ + vec_float4 lenSqr, lenInv; + lenSqr = lengthSqr( vec ); + lenInv = rsqrtf4( lenSqr ); + return Vector4( + spu_mul( vec.getX(), lenInv ), + spu_mul( vec.getY(), lenInv ), + spu_mul( vec.getZ(), lenInv ), + spu_mul( vec.getW(), lenInv ) + ); +} + +inline const Vector4 select( const Vector4 & vec0, const Vector4 & vec1, vec_uint4 select1 ) +{ + return Vector4( + spu_sel( vec0.getX(), vec1.getX(), select1 ), + spu_sel( vec0.getY(), vec1.getY(), select1 ), + spu_sel( vec0.getZ(), vec1.getZ(), select1 ), + spu_sel( vec0.getW(), vec1.getW(), select1 ) + ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( const Vector4 & vec ) +{ + Aos::Vector4 vec0, vec1, vec2, vec3; + vec.get4Aos( vec0, vec1, vec2, vec3 ); + printf("slot 0:\n"); + print( vec0 ); + printf("slot 1:\n"); + print( vec1 ); + printf("slot 2:\n"); + print( vec2 ); + printf("slot 3:\n"); + print( vec3 ); +} + +inline void print( const Vector4 & vec, const char * name ) +{ + Aos::Vector4 vec0, vec1, vec2, vec3; + printf( "%s:\n", name ); + vec.get4Aos( vec0, vec1, vec2, vec3 ); + printf("slot 0:\n"); + print( vec0 ); + printf("slot 1:\n"); + print( vec1 ); + printf("slot 2:\n"); + print( vec2 ); + printf("slot 3:\n"); + print( vec3 ); +} + +#endif + +inline Point3::Point3( const Point3 & pnt ) +{ + mX = pnt.mX; + mY = pnt.mY; + mZ = pnt.mZ; +} + +inline Point3::Point3( vec_float4 _x, vec_float4 _y, vec_float4 _z ) +{ + mX = _x; + mY = _y; + mZ = _z; +} + +inline Point3::Point3( const Vector3 & vec ) +{ + mX = vec.getX(); + mY = vec.getY(); + mZ = vec.getZ(); +} + +inline Point3::Point3( vec_float4 scalar ) +{ + mX = scalar; + mY = scalar; + mZ = scalar; +} + +inline Point3::Point3( Aos::Point3 pnt ) +{ + vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); + vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); + vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); + vec_float4 vec128 = pnt.get128(); + mX = spu_shuffle( vec128, vec128, shuffle_xxxx ); + mY = spu_shuffle( vec128, vec128, shuffle_yyyy ); + mZ = spu_shuffle( vec128, vec128, shuffle_zzzz ); +} + +inline Point3::Point3( Aos::Point3 pnt0, Aos::Point3 pnt1, Aos::Point3 pnt2, Aos::Point3 pnt3 ) +{ + vec_float4 tmp0, tmp1, tmp2, tmp3; + tmp0 = spu_shuffle( pnt0.get128(), pnt2.get128(), _VECTORMATH_SHUF_XAYB ); + tmp1 = spu_shuffle( pnt1.get128(), pnt3.get128(), _VECTORMATH_SHUF_XAYB ); + tmp2 = spu_shuffle( pnt0.get128(), pnt2.get128(), _VECTORMATH_SHUF_ZCWD ); + tmp3 = spu_shuffle( pnt1.get128(), pnt3.get128(), _VECTORMATH_SHUF_ZCWD ); + mX = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB ); + mY = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD ); + mZ = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB ); +} + +inline const Point3 lerp( vec_float4 t, const Point3 & pnt0, const Point3 & pnt1 ) +{ + return ( pnt0 + ( ( pnt1 - pnt0 ) * t ) ); +} + +inline void Point3::get4Aos( Aos::Point3 & result0, Aos::Point3 & result1, Aos::Point3 & result2, Aos::Point3 & result3 ) const +{ + vec_float4 tmp0, tmp1; + tmp0 = spu_shuffle( mX, mZ, _VECTORMATH_SHUF_XAYB ); + tmp1 = spu_shuffle( mX, mZ, _VECTORMATH_SHUF_ZCWD ); + result0 = Aos::Point3( spu_shuffle( tmp0, mY, _VECTORMATH_SHUF_XAYB ) ); + result1 = Aos::Point3( spu_shuffle( tmp0, mY, _VECTORMATH_SHUF_ZBW0 ) ); + result2 = Aos::Point3( spu_shuffle( tmp1, mY, _VECTORMATH_SHUF_XCY0 ) ); + result3 = Aos::Point3( spu_shuffle( tmp1, mY, _VECTORMATH_SHUF_ZDW0 ) ); +} + +inline void loadXYZArray( Point3 & vec, const vec_float4 * threeQuads ) +{ + vec_float4 xyxy, yzyz, zxzx, xyzx, yzxy, zxyz; + xyzx = threeQuads[0]; + yzxy = threeQuads[1]; + zxyz = threeQuads[2]; + xyxy = spu_shuffle( xyzx, yzxy, _VECTORMATH_SHUF_XYCD ); + zxzx = spu_shuffle( zxyz, xyzx, _VECTORMATH_SHUF_XYCD ); + yzyz = spu_shuffle( yzxy, zxyz, _VECTORMATH_SHUF_XYCD ); + vec.setX( spu_shuffle( xyxy, zxzx, _VECTORMATH_SHUF_XDZB ) ); + vec.setY( spu_shuffle( xyxy, yzyz, _VECTORMATH_SHUF_YAWC ) ); + vec.setZ( spu_shuffle( zxzx, yzyz, _VECTORMATH_SHUF_ZBXD ) ); +} + +inline void storeXYZArray( const Point3 & vec, vec_float4 * threeQuads ) +{ + vec_float4 xyzx, yzxy, zxyz, xyxy, zxzx, yzyz; + xyxy = spu_shuffle( vec.getX(), vec.getY(), _VECTORMATH_SHUF_XAZC ); + zxzx = spu_shuffle( vec.getZ(), vec.getX(), _VECTORMATH_SHUF_ZDXB ); + yzyz = spu_shuffle( vec.getY(), vec.getZ(), _VECTORMATH_SHUF_YBWD ); + xyzx = spu_shuffle( xyxy, zxzx, _VECTORMATH_SHUF_XYCD ); + yzxy = spu_shuffle( yzyz, xyxy, _VECTORMATH_SHUF_XYCD ); + zxyz = spu_shuffle( zxzx, yzyz, _VECTORMATH_SHUF_XYCD ); + threeQuads[0] = xyzx; + threeQuads[1] = yzxy; + threeQuads[2] = zxyz; +} + +inline void storeHalfFloats( const Point3 & pnt0, const Point3 & pnt1, vec_ushort8 * threeQuads ) +{ + vec_float4 xyz0[3]; + vec_float4 xyz1[3]; + storeXYZArray( pnt0, xyz0 ); + storeXYZArray( pnt1, xyz1 ); + threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); + threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); + threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); +} + +inline Point3 & Point3::operator =( const Point3 & pnt ) +{ + mX = pnt.mX; + mY = pnt.mY; + mZ = pnt.mZ; + return *this; +} + +inline Point3 & Point3::setX( vec_float4 _x ) +{ + mX = _x; + return *this; +} + +inline vec_float4 Point3::getX( ) const +{ + return mX; +} + +inline Point3 & Point3::setY( vec_float4 _y ) +{ + mY = _y; + return *this; +} + +inline vec_float4 Point3::getY( ) const +{ + return mY; +} + +inline Point3 & Point3::setZ( vec_float4 _z ) +{ + mZ = _z; + return *this; +} + +inline vec_float4 Point3::getZ( ) const +{ + return mZ; +} + +inline Point3 & Point3::setElem( int idx, vec_float4 value ) +{ + *(&mX + idx) = value; + return *this; +} + +inline vec_float4 Point3::getElem( int idx ) const +{ + return *(&mX + idx); +} + +inline Point3::vec_float4_t & Point3::operator []( int idx ) +{ + return *(&mX + idx); +} + +inline vec_float4 Point3::operator []( int idx ) const +{ + return *(&mX + idx); +} + +inline const Vector3 Point3::operator -( const Point3 & pnt ) const +{ + return Vector3( + spu_sub( mX, pnt.mX ), + spu_sub( mY, pnt.mY ), + spu_sub( mZ, pnt.mZ ) + ); +} + +inline const Point3 Point3::operator +( const Vector3 & vec ) const +{ + return Point3( + spu_add( mX, vec.getX() ), + spu_add( mY, vec.getY() ), + spu_add( mZ, vec.getZ() ) + ); +} + +inline const Point3 Point3::operator -( const Vector3 & vec ) const +{ + return Point3( + spu_sub( mX, vec.getX() ), + spu_sub( mY, vec.getY() ), + spu_sub( mZ, vec.getZ() ) + ); +} + +inline Point3 & Point3::operator +=( const Vector3 & vec ) +{ + *this = *this + vec; + return *this; +} + +inline Point3 & Point3::operator -=( const Vector3 & vec ) +{ + *this = *this - vec; + return *this; +} + +inline const Point3 mulPerElem( const Point3 & pnt0, const Point3 & pnt1 ) +{ + return Point3( + spu_mul( pnt0.getX(), pnt1.getX() ), + spu_mul( pnt0.getY(), pnt1.getY() ), + spu_mul( pnt0.getZ(), pnt1.getZ() ) + ); +} + +inline const Point3 divPerElem( const Point3 & pnt0, const Point3 & pnt1 ) +{ + return Point3( + divf4( pnt0.getX(), pnt1.getX() ), + divf4( pnt0.getY(), pnt1.getY() ), + divf4( pnt0.getZ(), pnt1.getZ() ) + ); +} + +inline const Point3 recipPerElem( const Point3 & pnt ) +{ + return Point3( + recipf4( pnt.getX() ), + recipf4( pnt.getY() ), + recipf4( pnt.getZ() ) + ); +} + +inline const Point3 sqrtPerElem( const Point3 & pnt ) +{ + return Point3( + sqrtf4( pnt.getX() ), + sqrtf4( pnt.getY() ), + sqrtf4( pnt.getZ() ) + ); +} + +inline const Point3 rsqrtPerElem( const Point3 & pnt ) +{ + return Point3( + rsqrtf4( pnt.getX() ), + rsqrtf4( pnt.getY() ), + rsqrtf4( pnt.getZ() ) + ); +} + +inline const Point3 absPerElem( const Point3 & pnt ) +{ + return Point3( + fabsf4( pnt.getX() ), + fabsf4( pnt.getY() ), + fabsf4( pnt.getZ() ) + ); +} + +inline const Point3 copySignPerElem( const Point3 & pnt0, const Point3 & pnt1 ) +{ + return Point3( + copysignf4( pnt0.getX(), pnt1.getX() ), + copysignf4( pnt0.getY(), pnt1.getY() ), + copysignf4( pnt0.getZ(), pnt1.getZ() ) + ); +} + +inline const Point3 maxPerElem( const Point3 & pnt0, const Point3 & pnt1 ) +{ + return Point3( + fmaxf4( pnt0.getX(), pnt1.getX() ), + fmaxf4( pnt0.getY(), pnt1.getY() ), + fmaxf4( pnt0.getZ(), pnt1.getZ() ) + ); +} + +inline vec_float4 maxElem( const Point3 & pnt ) +{ + vec_float4 result; + result = fmaxf4( pnt.getX(), pnt.getY() ); + result = fmaxf4( pnt.getZ(), result ); + return result; +} + +inline const Point3 minPerElem( const Point3 & pnt0, const Point3 & pnt1 ) +{ + return Point3( + fminf4( pnt0.getX(), pnt1.getX() ), + fminf4( pnt0.getY(), pnt1.getY() ), + fminf4( pnt0.getZ(), pnt1.getZ() ) + ); +} + +inline vec_float4 minElem( const Point3 & pnt ) +{ + vec_float4 result; + result = fminf4( pnt.getX(), pnt.getY() ); + result = fminf4( pnt.getZ(), result ); + return result; +} + +inline vec_float4 sum( const Point3 & pnt ) +{ + vec_float4 result; + result = spu_add( pnt.getX(), pnt.getY() ); + result = spu_add( result, pnt.getZ() ); + return result; +} + +inline const Point3 scale( const Point3 & pnt, vec_float4 scaleVal ) +{ + return mulPerElem( pnt, Point3( scaleVal ) ); +} + +inline const Point3 scale( const Point3 & pnt, const Vector3 & scaleVec ) +{ + return mulPerElem( pnt, Point3( scaleVec ) ); +} + +inline vec_float4 projection( const Point3 & pnt, const Vector3 & unitVec ) +{ + vec_float4 result; + result = spu_mul( pnt.getX(), unitVec.getX() ); + result = spu_add( result, spu_mul( pnt.getY(), unitVec.getY() ) ); + result = spu_add( result, spu_mul( pnt.getZ(), unitVec.getZ() ) ); + return result; +} + +inline vec_float4 distSqrFromOrigin( const Point3 & pnt ) +{ + return lengthSqr( Vector3( pnt ) ); +} + +inline vec_float4 distFromOrigin( const Point3 & pnt ) +{ + return length( Vector3( pnt ) ); +} + +inline vec_float4 distSqr( const Point3 & pnt0, const Point3 & pnt1 ) +{ + return lengthSqr( ( pnt1 - pnt0 ) ); +} + +inline vec_float4 dist( const Point3 & pnt0, const Point3 & pnt1 ) +{ + return length( ( pnt1 - pnt0 ) ); +} + +inline const Point3 select( const Point3 & pnt0, const Point3 & pnt1, vec_uint4 select1 ) +{ + return Point3( + spu_sel( pnt0.getX(), pnt1.getX(), select1 ), + spu_sel( pnt0.getY(), pnt1.getY(), select1 ), + spu_sel( pnt0.getZ(), pnt1.getZ(), select1 ) + ); +} + +#ifdef _VECTORMATH_DEBUG + +inline void print( const Point3 & pnt ) +{ + Aos::Point3 vec0, vec1, vec2, vec3; + pnt.get4Aos( vec0, vec1, vec2, vec3 ); + printf("slot 0:\n"); + print( vec0 ); + printf("slot 1:\n"); + print( vec1 ); + printf("slot 2:\n"); + print( vec2 ); + printf("slot 3:\n"); + print( vec3 ); +} + +inline void print( const Point3 & pnt, const char * name ) +{ + Aos::Point3 vec0, vec1, vec2, vec3; + printf( "%s:\n", name ); + pnt.get4Aos( vec0, vec1, vec2, vec3 ); + printf("slot 0:\n"); + print( vec0 ); + printf("slot 1:\n"); + print( vec1 ); + printf("slot 2:\n"); + print( vec2 ); + printf("slot 3:\n"); + print( vec3 ); +} + +#endif + +} // namespace Soa +} // namespace Vectormath + +#endif diff --git a/vectormathlibrary/include/vectormath/spu/cpp/vecidx_aos.h b/vectormathlibrary/include/vectormath/spu/cpp/vecidx_aos.h new file mode 100644 index 000000000..f5309153d --- /dev/null +++ b/vectormathlibrary/include/vectormath/spu/cpp/vecidx_aos.h @@ -0,0 +1,64 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_VECIDX_AOS_H +#define _VECTORMATH_VECIDX_AOS_H + +#include <spu_intrinsics.h> + +namespace Vectormath { +namespace Aos { + +//----------------------------------------------------------------------------- +// VecIdx +// Used in setting elements of Vector3, Vector4, Point3, or Quat with the +// subscripting operator. +// + +class VecIdx +{ +private: + typedef vec_float4 vec_float4_t; + vec_float4_t &ref __attribute__ ((aligned(16))); + int i __attribute__ ((aligned(16))); +public: + inline VecIdx( vec_float4& vec, int idx ): ref(vec) { i = idx; } + inline operator float() const; + inline float operator =( float scalar ); + inline float operator =( const VecIdx& scalar ); + inline float operator *=( float scalar ); + inline float operator /=( float scalar ); + inline float operator +=( float scalar ); + inline float operator -=( float scalar ); +}; + +} // namespace Aos +} // namespace Vectormath + +#endif diff --git a/vectormathlibrary/include/vectormath/spu/cpp/vectormath_aos.h b/vectormathlibrary/include/vectormath/spu/cpp/vectormath_aos.h new file mode 100644 index 000000000..f876c5382 --- /dev/null +++ b/vectormathlibrary/include/vectormath/spu/cpp/vectormath_aos.h @@ -0,0 +1,1851 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_AOS_CPP_SPU_H +#define _VECTORMATH_AOS_CPP_SPU_H + +#include <math.h> +#include <spu_intrinsics.h> +#include "floatInVec.h" +#include "boolInVec.h" +#include "vecidx_aos.h" +#include <stdio.h> + +#ifdef _VECTORMATH_DEBUG +#endif + +namespace Vectormath { + +namespace Aos { + +//----------------------------------------------------------------------------- +// Forward Declarations +// + +class Vector3; +class Vector4; +class Point3; +class Quat; +class Matrix3; +class Matrix4; +class Transform3; + +// A 3-D vector in array-of-structures format +// +class Vector3 +{ + vec_float4 mVec128; + +public: + // Default constructor; does no initialization + // + inline Vector3( ) { }; + + // Construct a 3-D vector from x, y, and z elements + // + inline Vector3( float x, float y, float z ); + + // Copy elements from a 3-D point into a 3-D vector + // + explicit inline Vector3( Point3 pnt ); + + // Set all elements of a 3-D vector to the same scalar value + // + explicit inline Vector3( float scalar ); + + // Set vector float data in a 3-D vector + // + explicit inline Vector3( vec_float4 vf4 ); + + // Get vector float data from a 3-D vector + // + inline vec_float4 get128( ) const; + + // Assign one 3-D vector to another + // + inline Vector3 & operator =( Vector3 vec ); + + // Set the x element of a 3-D vector + // + inline Vector3 & setX( float x ); + + // Set the y element of a 3-D vector + // + inline Vector3 & setY( float y ); + + // Set the z element of a 3-D vector + // + inline Vector3 & setZ( float z ); + + // Get the x element of a 3-D vector + // + inline float getX( ) const; + + // Get the y element of a 3-D vector + // + inline float getY( ) const; + + // Get the z element of a 3-D vector + // + inline float getZ( ) const; + + // Set an x, y, or z element of a 3-D vector by index + // + inline Vector3 & setElem( int idx, float value ); + + // Get an x, y, or z element of a 3-D vector by index + // + inline float getElem( int idx ) const; + + // Subscripting operator to set or get an element + // + inline VecIdx operator []( int idx ); + + // Subscripting operator to get an element + // + inline float operator []( int idx ) const; + + // Add two 3-D vectors + // + inline const Vector3 operator +( Vector3 vec ) const; + + // Subtract a 3-D vector from another 3-D vector + // + inline const Vector3 operator -( Vector3 vec ) const; + + // Add a 3-D vector to a 3-D point + // + inline const Point3 operator +( Point3 pnt ) const; + + // Multiply a 3-D vector by a scalar + // + inline const Vector3 operator *( float scalar ) const; + + // Divide a 3-D vector by a scalar + // + inline const Vector3 operator /( float scalar ) const; + + // Perform compound assignment and addition with a 3-D vector + // + inline Vector3 & operator +=( Vector3 vec ); + + // Perform compound assignment and subtraction by a 3-D vector + // + inline Vector3 & operator -=( Vector3 vec ); + + // Perform compound assignment and multiplication by a scalar + // + inline Vector3 & operator *=( float scalar ); + + // Perform compound assignment and division by a scalar + // + inline Vector3 & operator /=( float scalar ); + + // Negate all elements of a 3-D vector + // + inline const Vector3 operator -( ) const; + + // Construct x axis + // + static inline const Vector3 xAxis( ); + + // Construct y axis + // + static inline const Vector3 yAxis( ); + + // Construct z axis + // + static inline const Vector3 zAxis( ); + +}; + +// Multiply a 3-D vector by a scalar +// +inline const Vector3 operator *( float scalar, Vector3 vec ); + +// Multiply two 3-D vectors per element +// +inline const Vector3 mulPerElem( Vector3 vec0, Vector3 vec1 ); + +// Divide two 3-D vectors per element +// NOTE: +// Floating-point behavior matches standard library function divf4. +// +inline const Vector3 divPerElem( Vector3 vec0, Vector3 vec1 ); + +// Compute the reciprocal of a 3-D vector per element +// NOTE: +// Floating-point behavior matches standard library function recipf4. +// +inline const Vector3 recipPerElem( Vector3 vec ); + +// Compute the square root of a 3-D vector per element +// NOTE: +// Floating-point behavior matches standard library function sqrtf4. +// +inline const Vector3 sqrtPerElem( Vector3 vec ); + +// Compute the reciprocal square root of a 3-D vector per element +// NOTE: +// Floating-point behavior matches standard library function rsqrtf4. +// +inline const Vector3 rsqrtPerElem( Vector3 vec ); + +// Compute the absolute value of a 3-D vector per element +// +inline const Vector3 absPerElem( Vector3 vec ); + +// Copy sign from one 3-D vector to another, per element +// +inline const Vector3 copySignPerElem( Vector3 vec0, Vector3 vec1 ); + +// Maximum of two 3-D vectors per element +// +inline const Vector3 maxPerElem( Vector3 vec0, Vector3 vec1 ); + +// Minimum of two 3-D vectors per element +// +inline const Vector3 minPerElem( Vector3 vec0, Vector3 vec1 ); + +// Maximum element of a 3-D vector +// +inline float maxElem( Vector3 vec ); + +// Minimum element of a 3-D vector +// +inline float minElem( Vector3 vec ); + +// Compute the sum of all elements of a 3-D vector +// +inline float sum( Vector3 vec ); + +// Compute the dot product of two 3-D vectors +// +inline float dot( Vector3 vec0, Vector3 vec1 ); + +// Compute the square of the length of a 3-D vector +// +inline float lengthSqr( Vector3 vec ); + +// Compute the length of a 3-D vector +// +inline float length( Vector3 vec ); + +// Normalize a 3-D vector +// NOTE: +// The result is unpredictable when all elements of vec are at or near zero. +// +inline const Vector3 normalize( Vector3 vec ); + +// Compute cross product of two 3-D vectors +// +inline const Vector3 cross( Vector3 vec0, Vector3 vec1 ); + +// Outer product of two 3-D vectors +// +inline const Matrix3 outer( Vector3 vec0, Vector3 vec1 ); + +// Pre-multiply a row vector by a 3x3 matrix +// NOTE: +// Slower than column post-multiply. +// +inline const Vector3 rowMul( Vector3 vec, const Matrix3 & mat ); + +// Cross-product matrix of a 3-D vector +// +inline const Matrix3 crossMatrix( Vector3 vec ); + +// Create cross-product matrix and multiply +// NOTE: +// Faster than separately creating a cross-product matrix and multiplying. +// +inline const Matrix3 crossMatrixMul( Vector3 vec, const Matrix3 & mat ); + +// Linear interpolation between two 3-D vectors +// NOTE: +// Does not clamp t between 0 and 1. +// +inline const Vector3 lerp( float t, Vector3 vec0, Vector3 vec1 ); + +// Spherical linear interpolation between two 3-D vectors +// NOTE: +// The result is unpredictable if the vectors point in opposite directions. +// Does not clamp t between 0 and 1. +// +inline const Vector3 slerp( float t, Vector3 unitVec0, Vector3 unitVec1 ); + +// Conditionally select between two 3-D vectors +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// +inline const Vector3 select( Vector3 vec0, Vector3 vec1, bool select1 ); + +// Store x, y, and z elements of a 3-D vector in the first three words of a quadword. +// The value of the fourth word (the word with the highest address) remains unchanged +// +inline void storeXYZ( Vector3 vec, vec_float4 * quad ); + +// Load four three-float 3-D vectors, stored in three quadwords +// +inline void loadXYZArray( Vector3 & vec0, Vector3 & vec1, Vector3 & vec2, Vector3 & vec3, const vec_float4 * threeQuads ); + +// Store four 3-D vectors in three quadwords +// +inline void storeXYZArray( Vector3 vec0, Vector3 vec1, Vector3 vec2, Vector3 vec3, vec_float4 * threeQuads ); + +// Store eight 3-D vectors as half-floats +// +inline void storeHalfFloats( Vector3 vec0, Vector3 vec1, Vector3 vec2, Vector3 vec3, Vector3 vec4, Vector3 vec5, Vector3 vec6, Vector3 vec7, vec_ushort8 * threeQuads ); + +#ifdef _VECTORMATH_DEBUG + +// Print a 3-D vector +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( Vector3 vec ); + +// Print a 3-D vector and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( Vector3 vec, const char * name ); + +#endif + +// A 4-D vector in array-of-structures format +// +class Vector4 +{ + vec_float4 mVec128; + +public: + // Default constructor; does no initialization + // + inline Vector4( ) { }; + + // Construct a 4-D vector from x, y, z, and w elements + // + inline Vector4( float x, float y, float z, float w ); + + // Construct a 4-D vector from a 3-D vector and a scalar + // + inline Vector4( Vector3 xyz, float w ); + + // Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0 + // + explicit inline Vector4( Vector3 vec ); + + // Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1 + // + explicit inline Vector4( Point3 pnt ); + + // Copy elements from a quaternion into a 4-D vector + // + explicit inline Vector4( Quat quat ); + + // Set all elements of a 4-D vector to the same scalar value + // + explicit inline Vector4( float scalar ); + + // Set vector float data in a 4-D vector + // + explicit inline Vector4( vec_float4 vf4 ); + + // Get vector float data from a 4-D vector + // + inline vec_float4 get128( ) const; + + // Assign one 4-D vector to another + // + inline Vector4 & operator =( Vector4 vec ); + + // Set the x, y, and z elements of a 4-D vector + // NOTE: + // This function does not change the w element. + // + inline Vector4 & setXYZ( Vector3 vec ); + + // Get the x, y, and z elements of a 4-D vector + // + inline const Vector3 getXYZ( ) const; + + // Set the x element of a 4-D vector + // + inline Vector4 & setX( float x ); + + // Set the y element of a 4-D vector + // + inline Vector4 & setY( float y ); + + // Set the z element of a 4-D vector + // + inline Vector4 & setZ( float z ); + + // Set the w element of a 4-D vector + // + inline Vector4 & setW( float w ); + + // Get the x element of a 4-D vector + // + inline float getX( ) const; + + // Get the y element of a 4-D vector + // + inline float getY( ) const; + + // Get the z element of a 4-D vector + // + inline float getZ( ) const; + + // Get the w element of a 4-D vector + // + inline float getW( ) const; + + // Set an x, y, z, or w element of a 4-D vector by index + // + inline Vector4 & setElem( int idx, float value ); + + // Get an x, y, z, or w element of a 4-D vector by index + // + inline float getElem( int idx ) const; + + // Subscripting operator to set or get an element + // + inline VecIdx operator []( int idx ); + + // Subscripting operator to get an element + // + inline float operator []( int idx ) const; + + // Add two 4-D vectors + // + inline const Vector4 operator +( Vector4 vec ) const; + + // Subtract a 4-D vector from another 4-D vector + // + inline const Vector4 operator -( Vector4 vec ) const; + + // Multiply a 4-D vector by a scalar + // + inline const Vector4 operator *( float scalar ) const; + + // Divide a 4-D vector by a scalar + // + inline const Vector4 operator /( float scalar ) const; + + // Perform compound assignment and addition with a 4-D vector + // + inline Vector4 & operator +=( Vector4 vec ); + + // Perform compound assignment and subtraction by a 4-D vector + // + inline Vector4 & operator -=( Vector4 vec ); + + // Perform compound assignment and multiplication by a scalar + // + inline Vector4 & operator *=( float scalar ); + + // Perform compound assignment and division by a scalar + // + inline Vector4 & operator /=( float scalar ); + + // Negate all elements of a 4-D vector + // + inline const Vector4 operator -( ) const; + + // Construct x axis + // + static inline const Vector4 xAxis( ); + + // Construct y axis + // + static inline const Vector4 yAxis( ); + + // Construct z axis + // + static inline const Vector4 zAxis( ); + + // Construct w axis + // + static inline const Vector4 wAxis( ); + +}; + +// Multiply a 4-D vector by a scalar +// +inline const Vector4 operator *( float scalar, Vector4 vec ); + +// Multiply two 4-D vectors per element +// +inline const Vector4 mulPerElem( Vector4 vec0, Vector4 vec1 ); + +// Divide two 4-D vectors per element +// NOTE: +// Floating-point behavior matches standard library function divf4. +// +inline const Vector4 divPerElem( Vector4 vec0, Vector4 vec1 ); + +// Compute the reciprocal of a 4-D vector per element +// NOTE: +// Floating-point behavior matches standard library function recipf4. +// +inline const Vector4 recipPerElem( Vector4 vec ); + +// Compute the square root of a 4-D vector per element +// NOTE: +// Floating-point behavior matches standard library function sqrtf4. +// +inline const Vector4 sqrtPerElem( Vector4 vec ); + +// Compute the reciprocal square root of a 4-D vector per element +// NOTE: +// Floating-point behavior matches standard library function rsqrtf4. +// +inline const Vector4 rsqrtPerElem( Vector4 vec ); + +// Compute the absolute value of a 4-D vector per element +// +inline const Vector4 absPerElem( Vector4 vec ); + +// Copy sign from one 4-D vector to another, per element +// +inline const Vector4 copySignPerElem( Vector4 vec0, Vector4 vec1 ); + +// Maximum of two 4-D vectors per element +// +inline const Vector4 maxPerElem( Vector4 vec0, Vector4 vec1 ); + +// Minimum of two 4-D vectors per element +// +inline const Vector4 minPerElem( Vector4 vec0, Vector4 vec1 ); + +// Maximum element of a 4-D vector +// +inline float maxElem( Vector4 vec ); + +// Minimum element of a 4-D vector +// +inline float minElem( Vector4 vec ); + +// Compute the sum of all elements of a 4-D vector +// +inline float sum( Vector4 vec ); + +// Compute the dot product of two 4-D vectors +// +inline float dot( Vector4 vec0, Vector4 vec1 ); + +// Compute the square of the length of a 4-D vector +// +inline float lengthSqr( Vector4 vec ); + +// Compute the length of a 4-D vector +// +inline float length( Vector4 vec ); + +// Normalize a 4-D vector +// NOTE: +// The result is unpredictable when all elements of vec are at or near zero. +// +inline const Vector4 normalize( Vector4 vec ); + +// Outer product of two 4-D vectors +// +inline const Matrix4 outer( Vector4 vec0, Vector4 vec1 ); + +// Linear interpolation between two 4-D vectors +// NOTE: +// Does not clamp t between 0 and 1. +// +inline const Vector4 lerp( float t, Vector4 vec0, Vector4 vec1 ); + +// Spherical linear interpolation between two 4-D vectors +// NOTE: +// The result is unpredictable if the vectors point in opposite directions. +// Does not clamp t between 0 and 1. +// +inline const Vector4 slerp( float t, Vector4 unitVec0, Vector4 unitVec1 ); + +// Conditionally select between two 4-D vectors +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// +inline const Vector4 select( Vector4 vec0, Vector4 vec1, bool select1 ); + +// Store four 4-D vectors as half-floats +// +inline void storeHalfFloats( Vector4 vec0, Vector4 vec1, Vector4 vec2, Vector4 vec3, vec_ushort8 * twoQuads ); + +#ifdef _VECTORMATH_DEBUG + +// Print a 4-D vector +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( Vector4 vec ); + +// Print a 4-D vector and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( Vector4 vec, const char * name ); + +#endif + +// A 3-D point in array-of-structures format +// +class Point3 +{ + vec_float4 mVec128; + +public: + // Default constructor; does no initialization + // + inline Point3( ) { }; + + // Construct a 3-D point from x, y, and z elements + // + inline Point3( float x, float y, float z ); + + // Copy elements from a 3-D vector into a 3-D point + // + explicit inline Point3( Vector3 vec ); + + // Set all elements of a 3-D point to the same scalar value + // + explicit inline Point3( float scalar ); + + // Set vector float data in a 3-D point + // + explicit inline Point3( vec_float4 vf4 ); + + // Get vector float data from a 3-D point + // + inline vec_float4 get128( ) const; + + // Assign one 3-D point to another + // + inline Point3 & operator =( Point3 pnt ); + + // Set the x element of a 3-D point + // + inline Point3 & setX( float x ); + + // Set the y element of a 3-D point + // + inline Point3 & setY( float y ); + + // Set the z element of a 3-D point + // + inline Point3 & setZ( float z ); + + // Get the x element of a 3-D point + // + inline float getX( ) const; + + // Get the y element of a 3-D point + // + inline float getY( ) const; + + // Get the z element of a 3-D point + // + inline float getZ( ) const; + + // Set an x, y, or z element of a 3-D point by index + // + inline Point3 & setElem( int idx, float value ); + + // Get an x, y, or z element of a 3-D point by index + // + inline float getElem( int idx ) const; + + // Subscripting operator to set or get an element + // + inline VecIdx operator []( int idx ); + + // Subscripting operator to get an element + // + inline float operator []( int idx ) const; + + // Subtract a 3-D point from another 3-D point + // + inline const Vector3 operator -( Point3 pnt ) const; + + // Add a 3-D point to a 3-D vector + // + inline const Point3 operator +( Vector3 vec ) const; + + // Subtract a 3-D vector from a 3-D point + // + inline const Point3 operator -( Vector3 vec ) const; + + // Perform compound assignment and addition with a 3-D vector + // + inline Point3 & operator +=( Vector3 vec ); + + // Perform compound assignment and subtraction by a 3-D vector + // + inline Point3 & operator -=( Vector3 vec ); + +}; + +// Multiply two 3-D points per element +// +inline const Point3 mulPerElem( Point3 pnt0, Point3 pnt1 ); + +// Divide two 3-D points per element +// NOTE: +// Floating-point behavior matches standard library function divf4. +// +inline const Point3 divPerElem( Point3 pnt0, Point3 pnt1 ); + +// Compute the reciprocal of a 3-D point per element +// NOTE: +// Floating-point behavior matches standard library function recipf4. +// +inline const Point3 recipPerElem( Point3 pnt ); + +// Compute the square root of a 3-D point per element +// NOTE: +// Floating-point behavior matches standard library function sqrtf4. +// +inline const Point3 sqrtPerElem( Point3 pnt ); + +// Compute the reciprocal square root of a 3-D point per element +// NOTE: +// Floating-point behavior matches standard library function rsqrtf4. +// +inline const Point3 rsqrtPerElem( Point3 pnt ); + +// Compute the absolute value of a 3-D point per element +// +inline const Point3 absPerElem( Point3 pnt ); + +// Copy sign from one 3-D point to another, per element +// +inline const Point3 copySignPerElem( Point3 pnt0, Point3 pnt1 ); + +// Maximum of two 3-D points per element +// +inline const Point3 maxPerElem( Point3 pnt0, Point3 pnt1 ); + +// Minimum of two 3-D points per element +// +inline const Point3 minPerElem( Point3 pnt0, Point3 pnt1 ); + +// Maximum element of a 3-D point +// +inline float maxElem( Point3 pnt ); + +// Minimum element of a 3-D point +// +inline float minElem( Point3 pnt ); + +// Compute the sum of all elements of a 3-D point +// +inline float sum( Point3 pnt ); + +// Apply uniform scale to a 3-D point +// +inline const Point3 scale( Point3 pnt, float scaleVal ); + +// Apply non-uniform scale to a 3-D point +// +inline const Point3 scale( Point3 pnt, Vector3 scaleVec ); + +// Scalar projection of a 3-D point on a unit-length 3-D vector +// +inline float projection( Point3 pnt, Vector3 unitVec ); + +// Compute the square of the distance of a 3-D point from the coordinate-system origin +// +inline float distSqrFromOrigin( Point3 pnt ); + +// Compute the distance of a 3-D point from the coordinate-system origin +// +inline float distFromOrigin( Point3 pnt ); + +// Compute the square of the distance between two 3-D points +// +inline float distSqr( Point3 pnt0, Point3 pnt1 ); + +// Compute the distance between two 3-D points +// +inline float dist( Point3 pnt0, Point3 pnt1 ); + +// Linear interpolation between two 3-D points +// NOTE: +// Does not clamp t between 0 and 1. +// +inline const Point3 lerp( float t, Point3 pnt0, Point3 pnt1 ); + +// Conditionally select between two 3-D points +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// +inline const Point3 select( Point3 pnt0, Point3 pnt1, bool select1 ); + +// Store x, y, and z elements of a 3-D point in the first three words of a quadword. +// The value of the fourth word (the word with the highest address) remains unchanged +// +inline void storeXYZ( Point3 pnt, vec_float4 * quad ); + +// Load four three-float 3-D points, stored in three quadwords +// +inline void loadXYZArray( Point3 & pnt0, Point3 & pnt1, Point3 & pnt2, Point3 & pnt3, const vec_float4 * threeQuads ); + +// Store four 3-D points in three quadwords +// +inline void storeXYZArray( Point3 pnt0, Point3 pnt1, Point3 pnt2, Point3 pnt3, vec_float4 * threeQuads ); + +// Store eight 3-D points as half-floats +// +inline void storeHalfFloats( Point3 pnt0, Point3 pnt1, Point3 pnt2, Point3 pnt3, Point3 pnt4, Point3 pnt5, Point3 pnt6, Point3 pnt7, vec_ushort8 * threeQuads ); + +#ifdef _VECTORMATH_DEBUG + +// Print a 3-D point +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( Point3 pnt ); + +// Print a 3-D point and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( Point3 pnt, const char * name ); + +#endif + +// A quaternion in array-of-structures format +// +class Quat +{ + vec_float4 mVec128; + +public: + // Default constructor; does no initialization + // + inline Quat( ) { }; + + // Construct a quaternion from x, y, z, and w elements + // + inline Quat( float x, float y, float z, float w ); + + // Construct a quaternion from a 3-D vector and a scalar + // + inline Quat( Vector3 xyz, float w ); + + // Copy elements from a 4-D vector into a quaternion + // + explicit inline Quat( Vector4 vec ); + + // Convert a rotation matrix to a unit-length quaternion + // + explicit inline Quat( const Matrix3 & rotMat ); + + // Set all elements of a quaternion to the same scalar value + // + explicit inline Quat( float scalar ); + + // Set vector float data in a quaternion + // + explicit inline Quat( vec_float4 vf4 ); + + // Get vector float data from a quaternion + // + inline vec_float4 get128( ) const; + + // Assign one quaternion to another + // + inline Quat & operator =( Quat quat ); + + // Set the x, y, and z elements of a quaternion + // NOTE: + // This function does not change the w element. + // + inline Quat & setXYZ( Vector3 vec ); + + // Get the x, y, and z elements of a quaternion + // + inline const Vector3 getXYZ( ) const; + + // Set the x element of a quaternion + // + inline Quat & setX( float x ); + + // Set the y element of a quaternion + // + inline Quat & setY( float y ); + + // Set the z element of a quaternion + // + inline Quat & setZ( float z ); + + // Set the w element of a quaternion + // + inline Quat & setW( float w ); + + // Get the x element of a quaternion + // + inline float getX( ) const; + + // Get the y element of a quaternion + // + inline float getY( ) const; + + // Get the z element of a quaternion + // + inline float getZ( ) const; + + // Get the w element of a quaternion + // + inline float getW( ) const; + + // Set an x, y, z, or w element of a quaternion by index + // + inline Quat & setElem( int idx, float value ); + + // Get an x, y, z, or w element of a quaternion by index + // + inline float getElem( int idx ) const; + + // Subscripting operator to set or get an element + // + inline VecIdx operator []( int idx ); + + // Subscripting operator to get an element + // + inline float operator []( int idx ) const; + + // Add two quaternions + // + inline const Quat operator +( Quat quat ) const; + + // Subtract a quaternion from another quaternion + // + inline const Quat operator -( Quat quat ) const; + + // Multiply two quaternions + // + inline const Quat operator *( Quat quat ) const; + + // Multiply a quaternion by a scalar + // + inline const Quat operator *( float scalar ) const; + + // Divide a quaternion by a scalar + // + inline const Quat operator /( float scalar ) const; + + // Perform compound assignment and addition with a quaternion + // + inline Quat & operator +=( Quat quat ); + + // Perform compound assignment and subtraction by a quaternion + // + inline Quat & operator -=( Quat quat ); + + // Perform compound assignment and multiplication by a quaternion + // + inline Quat & operator *=( Quat quat ); + + // Perform compound assignment and multiplication by a scalar + // + inline Quat & operator *=( float scalar ); + + // Perform compound assignment and division by a scalar + // + inline Quat & operator /=( float scalar ); + + // Negate all elements of a quaternion + // + inline const Quat operator -( ) const; + + // Construct an identity quaternion + // + static inline const Quat identity( ); + + // Construct a quaternion to rotate between two unit-length 3-D vectors + // NOTE: + // The result is unpredictable if unitVec0 and unitVec1 point in opposite directions. + // + static inline const Quat rotation( Vector3 unitVec0, Vector3 unitVec1 ); + + // Construct a quaternion to rotate around a unit-length 3-D vector + // + static inline const Quat rotation( float radians, Vector3 unitVec ); + + // Construct a quaternion to rotate around the x axis + // + static inline const Quat rotationX( float radians ); + + // Construct a quaternion to rotate around the y axis + // + static inline const Quat rotationY( float radians ); + + // Construct a quaternion to rotate around the z axis + // + static inline const Quat rotationZ( float radians ); + +}; + +// Multiply a quaternion by a scalar +// +inline const Quat operator *( float scalar, Quat quat ); + +// Compute the conjugate of a quaternion +// +inline const Quat conj( Quat quat ); + +// Use a unit-length quaternion to rotate a 3-D vector +// +inline const Vector3 rotate( Quat unitQuat, Vector3 vec ); + +// Compute the dot product of two quaternions +// +inline float dot( Quat quat0, Quat quat1 ); + +// Compute the norm of a quaternion +// +inline float norm( Quat quat ); + +// Compute the length of a quaternion +// +inline float length( Quat quat ); + +// Normalize a quaternion +// NOTE: +// The result is unpredictable when all elements of quat are at or near zero. +// +inline const Quat normalize( Quat quat ); + +// Linear interpolation between two quaternions +// NOTE: +// Does not clamp t between 0 and 1. +// +inline const Quat lerp( float t, Quat quat0, Quat quat1 ); + +// Spherical linear interpolation between two quaternions +// NOTE: +// Interpolates along the shortest path between orientations. +// Does not clamp t between 0 and 1. +// +inline const Quat slerp( float t, Quat unitQuat0, Quat unitQuat1 ); + +// Spherical quadrangle interpolation +// +inline const Quat squad( float t, Quat unitQuat0, Quat unitQuat1, Quat unitQuat2, Quat unitQuat3 ); + +// Conditionally select between two quaternions +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// +inline const Quat select( Quat quat0, Quat quat1, bool select1 ); + +#ifdef _VECTORMATH_DEBUG + +// Print a quaternion +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( Quat quat ); + +// Print a quaternion and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( Quat quat, const char * name ); + +#endif + +// A 3x3 matrix in array-of-structures format +// +class Matrix3 +{ + Vector3 mCol0; + Vector3 mCol1; + Vector3 mCol2; + +public: + // Default constructor; does no initialization + // + inline Matrix3( ) { }; + + // Copy a 3x3 matrix + // + inline Matrix3( const Matrix3 & mat ); + + // Construct a 3x3 matrix containing the specified columns + // + inline Matrix3( Vector3 col0, Vector3 col1, Vector3 col2 ); + + // Construct a 3x3 rotation matrix from a unit-length quaternion + // + explicit inline Matrix3( Quat unitQuat ); + + // Set all elements of a 3x3 matrix to the same scalar value + // + explicit inline Matrix3( float scalar ); + + // Assign one 3x3 matrix to another + // + inline Matrix3 & operator =( const Matrix3 & mat ); + + // Set column 0 of a 3x3 matrix + // + inline Matrix3 & setCol0( Vector3 col0 ); + + // Set column 1 of a 3x3 matrix + // + inline Matrix3 & setCol1( Vector3 col1 ); + + // Set column 2 of a 3x3 matrix + // + inline Matrix3 & setCol2( Vector3 col2 ); + + // Get column 0 of a 3x3 matrix + // + inline const Vector3 getCol0( ) const; + + // Get column 1 of a 3x3 matrix + // + inline const Vector3 getCol1( ) const; + + // Get column 2 of a 3x3 matrix + // + inline const Vector3 getCol2( ) const; + + // Set the column of a 3x3 matrix referred to by the specified index + // + inline Matrix3 & setCol( int col, Vector3 vec ); + + // Set the row of a 3x3 matrix referred to by the specified index + // + inline Matrix3 & setRow( int row, Vector3 vec ); + + // Get the column of a 3x3 matrix referred to by the specified index + // + inline const Vector3 getCol( int col ) const; + + // Get the row of a 3x3 matrix referred to by the specified index + // + inline const Vector3 getRow( int row ) const; + + // Subscripting operator to set or get a column + // + inline Vector3 & operator []( int col ); + + // Subscripting operator to get a column + // + inline const Vector3 operator []( int col ) const; + + // Set the element of a 3x3 matrix referred to by column and row indices + // + inline Matrix3 & setElem( int col, int row, float val ); + + // Get the element of a 3x3 matrix referred to by column and row indices + // + inline float getElem( int col, int row ) const; + + // Add two 3x3 matrices + // + inline const Matrix3 operator +( const Matrix3 & mat ) const; + + // Subtract a 3x3 matrix from another 3x3 matrix + // + inline const Matrix3 operator -( const Matrix3 & mat ) const; + + // Negate all elements of a 3x3 matrix + // + inline const Matrix3 operator -( ) const; + + // Multiply a 3x3 matrix by a scalar + // + inline const Matrix3 operator *( float scalar ) const; + + // Multiply a 3x3 matrix by a 3-D vector + // + inline const Vector3 operator *( Vector3 vec ) const; + + // Multiply two 3x3 matrices + // + inline const Matrix3 operator *( const Matrix3 & mat ) const; + + // Perform compound assignment and addition with a 3x3 matrix + // + inline Matrix3 & operator +=( const Matrix3 & mat ); + + // Perform compound assignment and subtraction by a 3x3 matrix + // + inline Matrix3 & operator -=( const Matrix3 & mat ); + + // Perform compound assignment and multiplication by a scalar + // + inline Matrix3 & operator *=( float scalar ); + + // Perform compound assignment and multiplication by a 3x3 matrix + // + inline Matrix3 & operator *=( const Matrix3 & mat ); + + // Construct an identity 3x3 matrix + // + static inline const Matrix3 identity( ); + + // Construct a 3x3 matrix to rotate around the x axis + // + static inline const Matrix3 rotationX( float radians ); + + // Construct a 3x3 matrix to rotate around the y axis + // + static inline const Matrix3 rotationY( float radians ); + + // Construct a 3x3 matrix to rotate around the z axis + // + static inline const Matrix3 rotationZ( float radians ); + + // Construct a 3x3 matrix to rotate around the x, y, and z axes + // + static inline const Matrix3 rotationZYX( Vector3 radiansXYZ ); + + // Construct a 3x3 matrix to rotate around a unit-length 3-D vector + // + static inline const Matrix3 rotation( float radians, Vector3 unitVec ); + + // Construct a rotation matrix from a unit-length quaternion + // + static inline const Matrix3 rotation( Quat unitQuat ); + + // Construct a 3x3 matrix to perform scaling + // + static inline const Matrix3 scale( Vector3 scaleVec ); + +}; +// Multiply a 3x3 matrix by a scalar +// +inline const Matrix3 operator *( float scalar, const Matrix3 & mat ); + +// Append (post-multiply) a scale transformation to a 3x3 matrix +// NOTE: +// Faster than creating and multiplying a scale transformation matrix. +// +inline const Matrix3 appendScale( const Matrix3 & mat, Vector3 scaleVec ); + +// Prepend (pre-multiply) a scale transformation to a 3x3 matrix +// NOTE: +// Faster than creating and multiplying a scale transformation matrix. +// +inline const Matrix3 prependScale( Vector3 scaleVec, const Matrix3 & mat ); + +// Multiply two 3x3 matrices per element +// +inline const Matrix3 mulPerElem( const Matrix3 & mat0, const Matrix3 & mat1 ); + +// Compute the absolute value of a 3x3 matrix per element +// +inline const Matrix3 absPerElem( const Matrix3 & mat ); + +// Transpose of a 3x3 matrix +// +inline const Matrix3 transpose( const Matrix3 & mat ); + +// Compute the inverse of a 3x3 matrix +// NOTE: +// Result is unpredictable when the determinant of mat is equal to or near 0. +// +inline const Matrix3 inverse( const Matrix3 & mat ); + +// Determinant of a 3x3 matrix +// +inline float determinant( const Matrix3 & mat ); + +// Conditionally select between two 3x3 matrices +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// +inline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, bool select1 ); + +#ifdef _VECTORMATH_DEBUG + +// Print a 3x3 matrix +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Matrix3 & mat ); + +// Print a 3x3 matrix and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Matrix3 & mat, const char * name ); + +#endif + +// A 4x4 matrix in array-of-structures format +// +class Matrix4 +{ + Vector4 mCol0; + Vector4 mCol1; + Vector4 mCol2; + Vector4 mCol3; + +public: + // Default constructor; does no initialization + // + inline Matrix4( ) { }; + + // Copy a 4x4 matrix + // + inline Matrix4( const Matrix4 & mat ); + + // Construct a 4x4 matrix containing the specified columns + // + inline Matrix4( Vector4 col0, Vector4 col1, Vector4 col2, Vector4 col3 ); + + // Construct a 4x4 matrix from a 3x4 transformation matrix + // + explicit inline Matrix4( const Transform3 & mat ); + + // Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector + // + inline Matrix4( const Matrix3 & mat, Vector3 translateVec ); + + // Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector + // + inline Matrix4( Quat unitQuat, Vector3 translateVec ); + + // Set all elements of a 4x4 matrix to the same scalar value + // + explicit inline Matrix4( float scalar ); + + // Assign one 4x4 matrix to another + // + inline Matrix4 & operator =( const Matrix4 & mat ); + + // Set the upper-left 3x3 submatrix + // NOTE: + // This function does not change the bottom row elements. + // + inline Matrix4 & setUpper3x3( const Matrix3 & mat3 ); + + // Get the upper-left 3x3 submatrix of a 4x4 matrix + // + inline const Matrix3 getUpper3x3( ) const; + + // Set translation component + // NOTE: + // This function does not change the bottom row elements. + // + inline Matrix4 & setTranslation( Vector3 translateVec ); + + // Get the translation component of a 4x4 matrix + // + inline const Vector3 getTranslation( ) const; + + // Set column 0 of a 4x4 matrix + // + inline Matrix4 & setCol0( Vector4 col0 ); + + // Set column 1 of a 4x4 matrix + // + inline Matrix4 & setCol1( Vector4 col1 ); + + // Set column 2 of a 4x4 matrix + // + inline Matrix4 & setCol2( Vector4 col2 ); + + // Set column 3 of a 4x4 matrix + // + inline Matrix4 & setCol3( Vector4 col3 ); + + // Get column 0 of a 4x4 matrix + // + inline const Vector4 getCol0( ) const; + + // Get column 1 of a 4x4 matrix + // + inline const Vector4 getCol1( ) const; + + // Get column 2 of a 4x4 matrix + // + inline const Vector4 getCol2( ) const; + + // Get column 3 of a 4x4 matrix + // + inline const Vector4 getCol3( ) const; + + // Set the column of a 4x4 matrix referred to by the specified index + // + inline Matrix4 & setCol( int col, Vector4 vec ); + + // Set the row of a 4x4 matrix referred to by the specified index + // + inline Matrix4 & setRow( int row, Vector4 vec ); + + // Get the column of a 4x4 matrix referred to by the specified index + // + inline const Vector4 getCol( int col ) const; + + // Get the row of a 4x4 matrix referred to by the specified index + // + inline const Vector4 getRow( int row ) const; + + // Subscripting operator to set or get a column + // + inline Vector4 & operator []( int col ); + + // Subscripting operator to get a column + // + inline const Vector4 operator []( int col ) const; + + // Set the element of a 4x4 matrix referred to by column and row indices + // + inline Matrix4 & setElem( int col, int row, float val ); + + // Get the element of a 4x4 matrix referred to by column and row indices + // + inline float getElem( int col, int row ) const; + + // Add two 4x4 matrices + // + inline const Matrix4 operator +( const Matrix4 & mat ) const; + + // Subtract a 4x4 matrix from another 4x4 matrix + // + inline const Matrix4 operator -( const Matrix4 & mat ) const; + + // Negate all elements of a 4x4 matrix + // + inline const Matrix4 operator -( ) const; + + // Multiply a 4x4 matrix by a scalar + // + inline const Matrix4 operator *( float scalar ) const; + + // Multiply a 4x4 matrix by a 4-D vector + // + inline const Vector4 operator *( Vector4 vec ) const; + + // Multiply a 4x4 matrix by a 3-D vector + // + inline const Vector4 operator *( Vector3 vec ) const; + + // Multiply a 4x4 matrix by a 3-D point + // + inline const Vector4 operator *( Point3 pnt ) const; + + // Multiply two 4x4 matrices + // + inline const Matrix4 operator *( const Matrix4 & mat ) const; + + // Multiply a 4x4 matrix by a 3x4 transformation matrix + // + inline const Matrix4 operator *( const Transform3 & tfrm ) const; + + // Perform compound assignment and addition with a 4x4 matrix + // + inline Matrix4 & operator +=( const Matrix4 & mat ); + + // Perform compound assignment and subtraction by a 4x4 matrix + // + inline Matrix4 & operator -=( const Matrix4 & mat ); + + // Perform compound assignment and multiplication by a scalar + // + inline Matrix4 & operator *=( float scalar ); + + // Perform compound assignment and multiplication by a 4x4 matrix + // + inline Matrix4 & operator *=( const Matrix4 & mat ); + + // Perform compound assignment and multiplication by a 3x4 transformation matrix + // + inline Matrix4 & operator *=( const Transform3 & tfrm ); + + // Construct an identity 4x4 matrix + // + static inline const Matrix4 identity( ); + + // Construct a 4x4 matrix to rotate around the x axis + // + static inline const Matrix4 rotationX( float radians ); + + // Construct a 4x4 matrix to rotate around the y axis + // + static inline const Matrix4 rotationY( float radians ); + + // Construct a 4x4 matrix to rotate around the z axis + // + static inline const Matrix4 rotationZ( float radians ); + + // Construct a 4x4 matrix to rotate around the x, y, and z axes + // + static inline const Matrix4 rotationZYX( Vector3 radiansXYZ ); + + // Construct a 4x4 matrix to rotate around a unit-length 3-D vector + // + static inline const Matrix4 rotation( float radians, Vector3 unitVec ); + + // Construct a rotation matrix from a unit-length quaternion + // + static inline const Matrix4 rotation( Quat unitQuat ); + + // Construct a 4x4 matrix to perform scaling + // + static inline const Matrix4 scale( Vector3 scaleVec ); + + // Construct a 4x4 matrix to perform translation + // + static inline const Matrix4 translation( Vector3 translateVec ); + + // Construct viewing matrix based on eye position, position looked at, and up direction + // + static inline const Matrix4 lookAt( Point3 eyePos, Point3 lookAtPos, Vector3 upVec ); + + // Construct a perspective projection matrix + // + static inline const Matrix4 perspective( float fovyRadians, float aspect, float zNear, float zFar ); + + // Construct a perspective projection matrix based on frustum + // + static inline const Matrix4 frustum( float left, float right, float bottom, float top, float zNear, float zFar ); + + // Construct an orthographic projection matrix + // + static inline const Matrix4 orthographic( float left, float right, float bottom, float top, float zNear, float zFar ); + +}; +// Multiply a 4x4 matrix by a scalar +// +inline const Matrix4 operator *( float scalar, const Matrix4 & mat ); + +// Append (post-multiply) a scale transformation to a 4x4 matrix +// NOTE: +// Faster than creating and multiplying a scale transformation matrix. +// +inline const Matrix4 appendScale( const Matrix4 & mat, Vector3 scaleVec ); + +// Prepend (pre-multiply) a scale transformation to a 4x4 matrix +// NOTE: +// Faster than creating and multiplying a scale transformation matrix. +// +inline const Matrix4 prependScale( Vector3 scaleVec, const Matrix4 & mat ); + +// Multiply two 4x4 matrices per element +// +inline const Matrix4 mulPerElem( const Matrix4 & mat0, const Matrix4 & mat1 ); + +// Compute the absolute value of a 4x4 matrix per element +// +inline const Matrix4 absPerElem( const Matrix4 & mat ); + +// Transpose of a 4x4 matrix +// +inline const Matrix4 transpose( const Matrix4 & mat ); + +// Compute the inverse of a 4x4 matrix +// NOTE: +// Result is unpredictable when the determinant of mat is equal to or near 0. +// +inline const Matrix4 inverse( const Matrix4 & mat ); + +// Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix +// NOTE: +// This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. The result is unpredictable when the determinant of mat is equal to or near 0. +// +inline const Matrix4 affineInverse( const Matrix4 & mat ); + +// Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix +// NOTE: +// This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. +// +inline const Matrix4 orthoInverse( const Matrix4 & mat ); + +// Determinant of a 4x4 matrix +// +inline float determinant( const Matrix4 & mat ); + +// Conditionally select between two 4x4 matrices +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// +inline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, bool select1 ); + +#ifdef _VECTORMATH_DEBUG + +// Print a 4x4 matrix +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Matrix4 & mat ); + +// Print a 4x4 matrix and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Matrix4 & mat, const char * name ); + +#endif + +// A 3x4 transformation matrix in array-of-structures format +// +class Transform3 +{ + Vector3 mCol0; + Vector3 mCol1; + Vector3 mCol2; + Vector3 mCol3; + +public: + // Default constructor; does no initialization + // + inline Transform3( ) { }; + + // Copy a 3x4 transformation matrix + // + inline Transform3( const Transform3 & tfrm ); + + // Construct a 3x4 transformation matrix containing the specified columns + // + inline Transform3( Vector3 col0, Vector3 col1, Vector3 col2, Vector3 col3 ); + + // Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector + // + inline Transform3( const Matrix3 & tfrm, Vector3 translateVec ); + + // Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector + // + inline Transform3( Quat unitQuat, Vector3 translateVec ); + + // Set all elements of a 3x4 transformation matrix to the same scalar value + // + explicit inline Transform3( float scalar ); + + // Assign one 3x4 transformation matrix to another + // + inline Transform3 & operator =( const Transform3 & tfrm ); + + // Set the upper-left 3x3 submatrix + // + inline Transform3 & setUpper3x3( const Matrix3 & mat3 ); + + // Get the upper-left 3x3 submatrix of a 3x4 transformation matrix + // + inline const Matrix3 getUpper3x3( ) const; + + // Set translation component + // + inline Transform3 & setTranslation( Vector3 translateVec ); + + // Get the translation component of a 3x4 transformation matrix + // + inline const Vector3 getTranslation( ) const; + + // Set column 0 of a 3x4 transformation matrix + // + inline Transform3 & setCol0( Vector3 col0 ); + + // Set column 1 of a 3x4 transformation matrix + // + inline Transform3 & setCol1( Vector3 col1 ); + + // Set column 2 of a 3x4 transformation matrix + // + inline Transform3 & setCol2( Vector3 col2 ); + + // Set column 3 of a 3x4 transformation matrix + // + inline Transform3 & setCol3( Vector3 col3 ); + + // Get column 0 of a 3x4 transformation matrix + // + inline const Vector3 getCol0( ) const; + + // Get column 1 of a 3x4 transformation matrix + // + inline const Vector3 getCol1( ) const; + + // Get column 2 of a 3x4 transformation matrix + // + inline const Vector3 getCol2( ) const; + + // Get column 3 of a 3x4 transformation matrix + // + inline const Vector3 getCol3( ) const; + + // Set the column of a 3x4 transformation matrix referred to by the specified index + // + inline Transform3 & setCol( int col, Vector3 vec ); + + // Set the row of a 3x4 transformation matrix referred to by the specified index + // + inline Transform3 & setRow( int row, Vector4 vec ); + + // Get the column of a 3x4 transformation matrix referred to by the specified index + // + inline const Vector3 getCol( int col ) const; + + // Get the row of a 3x4 transformation matrix referred to by the specified index + // + inline const Vector4 getRow( int row ) const; + + // Subscripting operator to set or get a column + // + inline Vector3 & operator []( int col ); + + // Subscripting operator to get a column + // + inline const Vector3 operator []( int col ) const; + + // Set the element of a 3x4 transformation matrix referred to by column and row indices + // + inline Transform3 & setElem( int col, int row, float val ); + + // Get the element of a 3x4 transformation matrix referred to by column and row indices + // + inline float getElem( int col, int row ) const; + + // Multiply a 3x4 transformation matrix by a 3-D vector + // + inline const Vector3 operator *( Vector3 vec ) const; + + // Multiply a 3x4 transformation matrix by a 3-D point + // + inline const Point3 operator *( Point3 pnt ) const; + + // Multiply two 3x4 transformation matrices + // + inline const Transform3 operator *( const Transform3 & tfrm ) const; + + // Perform compound assignment and multiplication by a 3x4 transformation matrix + // + inline Transform3 & operator *=( const Transform3 & tfrm ); + + // Construct an identity 3x4 transformation matrix + // + static inline const Transform3 identity( ); + + // Construct a 3x4 transformation matrix to rotate around the x axis + // + static inline const Transform3 rotationX( float radians ); + + // Construct a 3x4 transformation matrix to rotate around the y axis + // + static inline const Transform3 rotationY( float radians ); + + // Construct a 3x4 transformation matrix to rotate around the z axis + // + static inline const Transform3 rotationZ( float radians ); + + // Construct a 3x4 transformation matrix to rotate around the x, y, and z axes + // + static inline const Transform3 rotationZYX( Vector3 radiansXYZ ); + + // Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector + // + static inline const Transform3 rotation( float radians, Vector3 unitVec ); + + // Construct a rotation matrix from a unit-length quaternion + // + static inline const Transform3 rotation( Quat unitQuat ); + + // Construct a 3x4 transformation matrix to perform scaling + // + static inline const Transform3 scale( Vector3 scaleVec ); + + // Construct a 3x4 transformation matrix to perform translation + // + static inline const Transform3 translation( Vector3 translateVec ); + +}; +// Append (post-multiply) a scale transformation to a 3x4 transformation matrix +// NOTE: +// Faster than creating and multiplying a scale transformation matrix. +// +inline const Transform3 appendScale( const Transform3 & tfrm, Vector3 scaleVec ); + +// Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix +// NOTE: +// Faster than creating and multiplying a scale transformation matrix. +// +inline const Transform3 prependScale( Vector3 scaleVec, const Transform3 & tfrm ); + +// Multiply two 3x4 transformation matrices per element +// +inline const Transform3 mulPerElem( const Transform3 & tfrm0, const Transform3 & tfrm1 ); + +// Compute the absolute value of a 3x4 transformation matrix per element +// +inline const Transform3 absPerElem( const Transform3 & tfrm ); + +// Inverse of a 3x4 transformation matrix +// NOTE: +// Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0. +// +inline const Transform3 inverse( const Transform3 & tfrm ); + +// Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix +// NOTE: +// This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions. +// +inline const Transform3 orthoInverse( const Transform3 & tfrm ); + +// Conditionally select between two 3x4 transformation matrices +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// +inline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, bool select1 ); + +#ifdef _VECTORMATH_DEBUG + +// Print a 3x4 transformation matrix +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Transform3 & tfrm ); + +// Print a 3x4 transformation matrix and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Transform3 & tfrm, const char * name ); + +#endif + +} // namespace Aos +} // namespace Vectormath + +#include "vec_aos.h" +#include "quat_aos.h" +#include "mat_aos.h" + +#endif diff --git a/vectormathlibrary/include/vectormath/spu/cpp/vectormath_soa.h b/vectormathlibrary/include/vectormath/spu/cpp/vectormath_soa.h new file mode 100644 index 000000000..c37927b38 --- /dev/null +++ b/vectormathlibrary/include/vectormath/spu/cpp/vectormath_soa.h @@ -0,0 +1,1921 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_SOA_CPP_SPU_H +#define _VECTORMATH_SOA_CPP_SPU_H + +#include <math.h> +#include <spu_intrinsics.h> +#include "floatInVec.h" +#include "boolInVec.h" +#include "vectormath_aos.h" +#include <stdio.h> + +#ifdef _VECTORMATH_DEBUG +#endif + +namespace Vectormath { + +namespace Soa { + +//----------------------------------------------------------------------------- +// Forward Declarations +// + +class Vector3; +class Vector4; +class Point3; +class Quat; +class Matrix3; +class Matrix4; +class Transform3; + +// A set of four 3-D vectors in structure-of-arrays format +// +class Vector3 +{ + typedef vec_float4 vec_float4_t; + vec_float4 mX; + vec_float4 mY; + vec_float4 mZ; + +public: + // Default constructor; does no initialization + // + inline Vector3( ) { }; + + // Copy a 3-D vector + // + inline Vector3( const Vector3 & vec ); + + // Construct a 3-D vector from x, y, and z elements + // + inline Vector3( vec_float4 x, vec_float4 y, vec_float4 z ); + + // Copy elements from a 3-D point into a 3-D vector + // + explicit inline Vector3( const Point3 & pnt ); + + // Set all elements of a 3-D vector to the same scalar value + // + explicit inline Vector3( vec_float4 scalar ); + + // Replicate an AoS 3-D vector + // + inline Vector3( Aos::Vector3 vec ); + + // Insert four AoS 3-D vectors + // + inline Vector3( Aos::Vector3 vec0, Aos::Vector3 vec1, Aos::Vector3 vec2, Aos::Vector3 vec3 ); + + // Extract four AoS 3-D vectors + // + inline void get4Aos( Aos::Vector3 & result0, Aos::Vector3 & result1, Aos::Vector3 & result2, Aos::Vector3 & result3 ) const; + + // Assign one 3-D vector to another + // + inline Vector3 & operator =( const Vector3 & vec ); + + // Set the x element of a 3-D vector + // + inline Vector3 & setX( vec_float4 x ); + + // Set the y element of a 3-D vector + // + inline Vector3 & setY( vec_float4 y ); + + // Set the z element of a 3-D vector + // + inline Vector3 & setZ( vec_float4 z ); + + // Get the x element of a 3-D vector + // + inline vec_float4 getX( ) const; + + // Get the y element of a 3-D vector + // + inline vec_float4 getY( ) const; + + // Get the z element of a 3-D vector + // + inline vec_float4 getZ( ) const; + + // Set an x, y, or z element of a 3-D vector by index + // + inline Vector3 & setElem( int idx, vec_float4 value ); + + // Get an x, y, or z element of a 3-D vector by index + // + inline vec_float4 getElem( int idx ) const; + + // Subscripting operator to set or get an element + // + inline vec_float4_t & operator []( int idx ); + + // Subscripting operator to get an element + // + inline vec_float4 operator []( int idx ) const; + + // Add two 3-D vectors + // + inline const Vector3 operator +( const Vector3 & vec ) const; + + // Subtract a 3-D vector from another 3-D vector + // + inline const Vector3 operator -( const Vector3 & vec ) const; + + // Add a 3-D vector to a 3-D point + // + inline const Point3 operator +( const Point3 & pnt ) const; + + // Multiply a 3-D vector by a scalar + // + inline const Vector3 operator *( vec_float4 scalar ) const; + + // Divide a 3-D vector by a scalar + // + inline const Vector3 operator /( vec_float4 scalar ) const; + + // Perform compound assignment and addition with a 3-D vector + // + inline Vector3 & operator +=( const Vector3 & vec ); + + // Perform compound assignment and subtraction by a 3-D vector + // + inline Vector3 & operator -=( const Vector3 & vec ); + + // Perform compound assignment and multiplication by a scalar + // + inline Vector3 & operator *=( vec_float4 scalar ); + + // Perform compound assignment and division by a scalar + // + inline Vector3 & operator /=( vec_float4 scalar ); + + // Negate all elements of a 3-D vector + // + inline const Vector3 operator -( ) const; + + // Construct x axis + // + static inline const Vector3 xAxis( ); + + // Construct y axis + // + static inline const Vector3 yAxis( ); + + // Construct z axis + // + static inline const Vector3 zAxis( ); + +}; + +// Multiply a 3-D vector by a scalar +// +inline const Vector3 operator *( vec_float4 scalar, const Vector3 & vec ); + +// Multiply two 3-D vectors per element +// +inline const Vector3 mulPerElem( const Vector3 & vec0, const Vector3 & vec1 ); + +// Divide two 3-D vectors per element +// NOTE: +// Floating-point behavior matches standard library function divf4. +// +inline const Vector3 divPerElem( const Vector3 & vec0, const Vector3 & vec1 ); + +// Compute the reciprocal of a 3-D vector per element +// NOTE: +// Floating-point behavior matches standard library function recipf4. +// +inline const Vector3 recipPerElem( const Vector3 & vec ); + +// Compute the square root of a 3-D vector per element +// NOTE: +// Floating-point behavior matches standard library function sqrtf4. +// +inline const Vector3 sqrtPerElem( const Vector3 & vec ); + +// Compute the reciprocal square root of a 3-D vector per element +// NOTE: +// Floating-point behavior matches standard library function rsqrtf4. +// +inline const Vector3 rsqrtPerElem( const Vector3 & vec ); + +// Compute the absolute value of a 3-D vector per element +// +inline const Vector3 absPerElem( const Vector3 & vec ); + +// Copy sign from one 3-D vector to another, per element +// +inline const Vector3 copySignPerElem( const Vector3 & vec0, const Vector3 & vec1 ); + +// Maximum of two 3-D vectors per element +// +inline const Vector3 maxPerElem( const Vector3 & vec0, const Vector3 & vec1 ); + +// Minimum of two 3-D vectors per element +// +inline const Vector3 minPerElem( const Vector3 & vec0, const Vector3 & vec1 ); + +// Maximum element of a 3-D vector +// +inline vec_float4 maxElem( const Vector3 & vec ); + +// Minimum element of a 3-D vector +// +inline vec_float4 minElem( const Vector3 & vec ); + +// Compute the sum of all elements of a 3-D vector +// +inline vec_float4 sum( const Vector3 & vec ); + +// Compute the dot product of two 3-D vectors +// +inline vec_float4 dot( const Vector3 & vec0, const Vector3 & vec1 ); + +// Compute the square of the length of a 3-D vector +// +inline vec_float4 lengthSqr( const Vector3 & vec ); + +// Compute the length of a 3-D vector +// +inline vec_float4 length( const Vector3 & vec ); + +// Normalize a 3-D vector +// NOTE: +// The result is unpredictable when all elements of vec are at or near zero. +// +inline const Vector3 normalize( const Vector3 & vec ); + +// Compute cross product of two 3-D vectors +// +inline const Vector3 cross( const Vector3 & vec0, const Vector3 & vec1 ); + +// Outer product of two 3-D vectors +// +inline const Matrix3 outer( const Vector3 & vec0, const Vector3 & vec1 ); + +// Pre-multiply a row vector by a 3x3 matrix +// +inline const Vector3 rowMul( const Vector3 & vec, const Matrix3 & mat ); + +// Cross-product matrix of a 3-D vector +// +inline const Matrix3 crossMatrix( const Vector3 & vec ); + +// Create cross-product matrix and multiply +// NOTE: +// Faster than separately creating a cross-product matrix and multiplying. +// +inline const Matrix3 crossMatrixMul( const Vector3 & vec, const Matrix3 & mat ); + +// Linear interpolation between two 3-D vectors +// NOTE: +// Does not clamp t between 0 and 1. +// +inline const Vector3 lerp( vec_float4 t, const Vector3 & vec0, const Vector3 & vec1 ); + +// Spherical linear interpolation between two 3-D vectors +// NOTE: +// The result is unpredictable if the vectors point in opposite directions. +// Does not clamp t between 0 and 1. +// +inline const Vector3 slerp( vec_float4 t, const Vector3 & unitVec0, const Vector3 & unitVec1 ); + +// Conditionally select between two 3-D vectors +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// +inline const Vector3 select( const Vector3 & vec0, const Vector3 & vec1, vec_uint4 select1 ); + +// Load four three-float 3-D vectors, stored in three quadwords +// +inline void loadXYZArray( Vector3 & vec, const vec_float4 * threeQuads ); + +// Store four slots of an SoA 3-D vector in three quadwords +// +inline void storeXYZArray( const Vector3 & vec, vec_float4 * threeQuads ); + +// Store eight slots of two SoA 3-D vectors as half-floats +// +inline void storeHalfFloats( const Vector3 & vec0, const Vector3 & vec1, vec_ushort8 * threeQuads ); + +#ifdef _VECTORMATH_DEBUG + +// Print a 3-D vector +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Vector3 & vec ); + +// Print a 3-D vector and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Vector3 & vec, const char * name ); + +#endif + +// A set of four 4-D vectors in structure-of-arrays format +// +class Vector4 +{ + typedef vec_float4 vec_float4_t; + vec_float4 mX; + vec_float4 mY; + vec_float4 mZ; + vec_float4 mW; + +public: + // Default constructor; does no initialization + // + inline Vector4( ) { }; + + // Copy a 4-D vector + // + inline Vector4( const Vector4 & vec ); + + // Construct a 4-D vector from x, y, z, and w elements + // + inline Vector4( vec_float4 x, vec_float4 y, vec_float4 z, vec_float4 w ); + + // Construct a 4-D vector from a 3-D vector and a scalar + // + inline Vector4( const Vector3 & xyz, vec_float4 w ); + + // Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0 + // + explicit inline Vector4( const Vector3 & vec ); + + // Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1 + // + explicit inline Vector4( const Point3 & pnt ); + + // Copy elements from a quaternion into a 4-D vector + // + explicit inline Vector4( const Quat & quat ); + + // Set all elements of a 4-D vector to the same scalar value + // + explicit inline Vector4( vec_float4 scalar ); + + // Replicate an AoS 4-D vector + // + inline Vector4( Aos::Vector4 vec ); + + // Insert four AoS 4-D vectors + // + inline Vector4( Aos::Vector4 vec0, Aos::Vector4 vec1, Aos::Vector4 vec2, Aos::Vector4 vec3 ); + + // Extract four AoS 4-D vectors + // + inline void get4Aos( Aos::Vector4 & result0, Aos::Vector4 & result1, Aos::Vector4 & result2, Aos::Vector4 & result3 ) const; + + // Assign one 4-D vector to another + // + inline Vector4 & operator =( const Vector4 & vec ); + + // Set the x, y, and z elements of a 4-D vector + // NOTE: + // This function does not change the w element. + // + inline Vector4 & setXYZ( const Vector3 & vec ); + + // Get the x, y, and z elements of a 4-D vector + // + inline const Vector3 getXYZ( ) const; + + // Set the x element of a 4-D vector + // + inline Vector4 & setX( vec_float4 x ); + + // Set the y element of a 4-D vector + // + inline Vector4 & setY( vec_float4 y ); + + // Set the z element of a 4-D vector + // + inline Vector4 & setZ( vec_float4 z ); + + // Set the w element of a 4-D vector + // + inline Vector4 & setW( vec_float4 w ); + + // Get the x element of a 4-D vector + // + inline vec_float4 getX( ) const; + + // Get the y element of a 4-D vector + // + inline vec_float4 getY( ) const; + + // Get the z element of a 4-D vector + // + inline vec_float4 getZ( ) const; + + // Get the w element of a 4-D vector + // + inline vec_float4 getW( ) const; + + // Set an x, y, z, or w element of a 4-D vector by index + // + inline Vector4 & setElem( int idx, vec_float4 value ); + + // Get an x, y, z, or w element of a 4-D vector by index + // + inline vec_float4 getElem( int idx ) const; + + // Subscripting operator to set or get an element + // + inline vec_float4_t & operator []( int idx ); + + // Subscripting operator to get an element + // + inline vec_float4 operator []( int idx ) const; + + // Add two 4-D vectors + // + inline const Vector4 operator +( const Vector4 & vec ) const; + + // Subtract a 4-D vector from another 4-D vector + // + inline const Vector4 operator -( const Vector4 & vec ) const; + + // Multiply a 4-D vector by a scalar + // + inline const Vector4 operator *( vec_float4 scalar ) const; + + // Divide a 4-D vector by a scalar + // + inline const Vector4 operator /( vec_float4 scalar ) const; + + // Perform compound assignment and addition with a 4-D vector + // + inline Vector4 & operator +=( const Vector4 & vec ); + + // Perform compound assignment and subtraction by a 4-D vector + // + inline Vector4 & operator -=( const Vector4 & vec ); + + // Perform compound assignment and multiplication by a scalar + // + inline Vector4 & operator *=( vec_float4 scalar ); + + // Perform compound assignment and division by a scalar + // + inline Vector4 & operator /=( vec_float4 scalar ); + + // Negate all elements of a 4-D vector + // + inline const Vector4 operator -( ) const; + + // Construct x axis + // + static inline const Vector4 xAxis( ); + + // Construct y axis + // + static inline const Vector4 yAxis( ); + + // Construct z axis + // + static inline const Vector4 zAxis( ); + + // Construct w axis + // + static inline const Vector4 wAxis( ); + +}; + +// Multiply a 4-D vector by a scalar +// +inline const Vector4 operator *( vec_float4 scalar, const Vector4 & vec ); + +// Multiply two 4-D vectors per element +// +inline const Vector4 mulPerElem( const Vector4 & vec0, const Vector4 & vec1 ); + +// Divide two 4-D vectors per element +// NOTE: +// Floating-point behavior matches standard library function divf4. +// +inline const Vector4 divPerElem( const Vector4 & vec0, const Vector4 & vec1 ); + +// Compute the reciprocal of a 4-D vector per element +// NOTE: +// Floating-point behavior matches standard library function recipf4. +// +inline const Vector4 recipPerElem( const Vector4 & vec ); + +// Compute the square root of a 4-D vector per element +// NOTE: +// Floating-point behavior matches standard library function sqrtf4. +// +inline const Vector4 sqrtPerElem( const Vector4 & vec ); + +// Compute the reciprocal square root of a 4-D vector per element +// NOTE: +// Floating-point behavior matches standard library function rsqrtf4. +// +inline const Vector4 rsqrtPerElem( const Vector4 & vec ); + +// Compute the absolute value of a 4-D vector per element +// +inline const Vector4 absPerElem( const Vector4 & vec ); + +// Copy sign from one 4-D vector to another, per element +// +inline const Vector4 copySignPerElem( const Vector4 & vec0, const Vector4 & vec1 ); + +// Maximum of two 4-D vectors per element +// +inline const Vector4 maxPerElem( const Vector4 & vec0, const Vector4 & vec1 ); + +// Minimum of two 4-D vectors per element +// +inline const Vector4 minPerElem( const Vector4 & vec0, const Vector4 & vec1 ); + +// Maximum element of a 4-D vector +// +inline vec_float4 maxElem( const Vector4 & vec ); + +// Minimum element of a 4-D vector +// +inline vec_float4 minElem( const Vector4 & vec ); + +// Compute the sum of all elements of a 4-D vector +// +inline vec_float4 sum( const Vector4 & vec ); + +// Compute the dot product of two 4-D vectors +// +inline vec_float4 dot( const Vector4 & vec0, const Vector4 & vec1 ); + +// Compute the square of the length of a 4-D vector +// +inline vec_float4 lengthSqr( const Vector4 & vec ); + +// Compute the length of a 4-D vector +// +inline vec_float4 length( const Vector4 & vec ); + +// Normalize a 4-D vector +// NOTE: +// The result is unpredictable when all elements of vec are at or near zero. +// +inline const Vector4 normalize( const Vector4 & vec ); + +// Outer product of two 4-D vectors +// +inline const Matrix4 outer( const Vector4 & vec0, const Vector4 & vec1 ); + +// Linear interpolation between two 4-D vectors +// NOTE: +// Does not clamp t between 0 and 1. +// +inline const Vector4 lerp( vec_float4 t, const Vector4 & vec0, const Vector4 & vec1 ); + +// Spherical linear interpolation between two 4-D vectors +// NOTE: +// The result is unpredictable if the vectors point in opposite directions. +// Does not clamp t between 0 and 1. +// +inline const Vector4 slerp( vec_float4 t, const Vector4 & unitVec0, const Vector4 & unitVec1 ); + +// Conditionally select between two 4-D vectors +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// +inline const Vector4 select( const Vector4 & vec0, const Vector4 & vec1, vec_uint4 select1 ); + +// Store four slots of an SoA 4-D vector as half-floats +// +inline void storeHalfFloats( const Vector4 & vec, vec_ushort8 * twoQuads ); + +#ifdef _VECTORMATH_DEBUG + +// Print a 4-D vector +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Vector4 & vec ); + +// Print a 4-D vector and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Vector4 & vec, const char * name ); + +#endif + +// A set of four 3-D points in structure-of-arrays format +// +class Point3 +{ + typedef vec_float4 vec_float4_t; + vec_float4 mX; + vec_float4 mY; + vec_float4 mZ; + +public: + // Default constructor; does no initialization + // + inline Point3( ) { }; + + // Copy a 3-D point + // + inline Point3( const Point3 & pnt ); + + // Construct a 3-D point from x, y, and z elements + // + inline Point3( vec_float4 x, vec_float4 y, vec_float4 z ); + + // Copy elements from a 3-D vector into a 3-D point + // + explicit inline Point3( const Vector3 & vec ); + + // Set all elements of a 3-D point to the same scalar value + // + explicit inline Point3( vec_float4 scalar ); + + // Replicate an AoS 3-D point + // + inline Point3( Aos::Point3 pnt ); + + // Insert four AoS 3-D points + // + inline Point3( Aos::Point3 pnt0, Aos::Point3 pnt1, Aos::Point3 pnt2, Aos::Point3 pnt3 ); + + // Extract four AoS 3-D points + // + inline void get4Aos( Aos::Point3 & result0, Aos::Point3 & result1, Aos::Point3 & result2, Aos::Point3 & result3 ) const; + + // Assign one 3-D point to another + // + inline Point3 & operator =( const Point3 & pnt ); + + // Set the x element of a 3-D point + // + inline Point3 & setX( vec_float4 x ); + + // Set the y element of a 3-D point + // + inline Point3 & setY( vec_float4 y ); + + // Set the z element of a 3-D point + // + inline Point3 & setZ( vec_float4 z ); + + // Get the x element of a 3-D point + // + inline vec_float4 getX( ) const; + + // Get the y element of a 3-D point + // + inline vec_float4 getY( ) const; + + // Get the z element of a 3-D point + // + inline vec_float4 getZ( ) const; + + // Set an x, y, or z element of a 3-D point by index + // + inline Point3 & setElem( int idx, vec_float4 value ); + + // Get an x, y, or z element of a 3-D point by index + // + inline vec_float4 getElem( int idx ) const; + + // Subscripting operator to set or get an element + // + inline vec_float4_t & operator []( int idx ); + + // Subscripting operator to get an element + // + inline vec_float4 operator []( int idx ) const; + + // Subtract a 3-D point from another 3-D point + // + inline const Vector3 operator -( const Point3 & pnt ) const; + + // Add a 3-D point to a 3-D vector + // + inline const Point3 operator +( const Vector3 & vec ) const; + + // Subtract a 3-D vector from a 3-D point + // + inline const Point3 operator -( const Vector3 & vec ) const; + + // Perform compound assignment and addition with a 3-D vector + // + inline Point3 & operator +=( const Vector3 & vec ); + + // Perform compound assignment and subtraction by a 3-D vector + // + inline Point3 & operator -=( const Vector3 & vec ); + +}; + +// Multiply two 3-D points per element +// +inline const Point3 mulPerElem( const Point3 & pnt0, const Point3 & pnt1 ); + +// Divide two 3-D points per element +// NOTE: +// Floating-point behavior matches standard library function divf4. +// +inline const Point3 divPerElem( const Point3 & pnt0, const Point3 & pnt1 ); + +// Compute the reciprocal of a 3-D point per element +// NOTE: +// Floating-point behavior matches standard library function recipf4. +// +inline const Point3 recipPerElem( const Point3 & pnt ); + +// Compute the square root of a 3-D point per element +// NOTE: +// Floating-point behavior matches standard library function sqrtf4. +// +inline const Point3 sqrtPerElem( const Point3 & pnt ); + +// Compute the reciprocal square root of a 3-D point per element +// NOTE: +// Floating-point behavior matches standard library function rsqrtf4. +// +inline const Point3 rsqrtPerElem( const Point3 & pnt ); + +// Compute the absolute value of a 3-D point per element +// +inline const Point3 absPerElem( const Point3 & pnt ); + +// Copy sign from one 3-D point to another, per element +// +inline const Point3 copySignPerElem( const Point3 & pnt0, const Point3 & pnt1 ); + +// Maximum of two 3-D points per element +// +inline const Point3 maxPerElem( const Point3 & pnt0, const Point3 & pnt1 ); + +// Minimum of two 3-D points per element +// +inline const Point3 minPerElem( const Point3 & pnt0, const Point3 & pnt1 ); + +// Maximum element of a 3-D point +// +inline vec_float4 maxElem( const Point3 & pnt ); + +// Minimum element of a 3-D point +// +inline vec_float4 minElem( const Point3 & pnt ); + +// Compute the sum of all elements of a 3-D point +// +inline vec_float4 sum( const Point3 & pnt ); + +// Apply uniform scale to a 3-D point +// +inline const Point3 scale( const Point3 & pnt, vec_float4 scaleVal ); + +// Apply non-uniform scale to a 3-D point +// +inline const Point3 scale( const Point3 & pnt, const Vector3 & scaleVec ); + +// Scalar projection of a 3-D point on a unit-length 3-D vector +// +inline vec_float4 projection( const Point3 & pnt, const Vector3 & unitVec ); + +// Compute the square of the distance of a 3-D point from the coordinate-system origin +// +inline vec_float4 distSqrFromOrigin( const Point3 & pnt ); + +// Compute the distance of a 3-D point from the coordinate-system origin +// +inline vec_float4 distFromOrigin( const Point3 & pnt ); + +// Compute the square of the distance between two 3-D points +// +inline vec_float4 distSqr( const Point3 & pnt0, const Point3 & pnt1 ); + +// Compute the distance between two 3-D points +// +inline vec_float4 dist( const Point3 & pnt0, const Point3 & pnt1 ); + +// Linear interpolation between two 3-D points +// NOTE: +// Does not clamp t between 0 and 1. +// +inline const Point3 lerp( vec_float4 t, const Point3 & pnt0, const Point3 & pnt1 ); + +// Conditionally select between two 3-D points +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// +inline const Point3 select( const Point3 & pnt0, const Point3 & pnt1, vec_uint4 select1 ); + +// Load four three-float 3-D points, stored in three quadwords +// +inline void loadXYZArray( Point3 & pnt, const vec_float4 * threeQuads ); + +// Store four slots of an SoA 3-D point in three quadwords +// +inline void storeXYZArray( const Point3 & pnt, vec_float4 * threeQuads ); + +// Store eight slots of two SoA 3-D points as half-floats +// +inline void storeHalfFloats( const Point3 & pnt0, const Point3 & pnt1, vec_ushort8 * threeQuads ); + +#ifdef _VECTORMATH_DEBUG + +// Print a 3-D point +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Point3 & pnt ); + +// Print a 3-D point and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Point3 & pnt, const char * name ); + +#endif + +// A set of four quaternions in structure-of-arrays format +// +class Quat +{ + typedef vec_float4 vec_float4_t; + vec_float4 mX; + vec_float4 mY; + vec_float4 mZ; + vec_float4 mW; + +public: + // Default constructor; does no initialization + // + inline Quat( ) { }; + + // Copy a quaternion + // + inline Quat( const Quat & quat ); + + // Construct a quaternion from x, y, z, and w elements + // + inline Quat( vec_float4 x, vec_float4 y, vec_float4 z, vec_float4 w ); + + // Construct a quaternion from a 3-D vector and a scalar + // + inline Quat( const Vector3 & xyz, vec_float4 w ); + + // Copy elements from a 4-D vector into a quaternion + // + explicit inline Quat( const Vector4 & vec ); + + // Convert a rotation matrix to a unit-length quaternion + // + explicit inline Quat( const Matrix3 & rotMat ); + + // Set all elements of a quaternion to the same scalar value + // + explicit inline Quat( vec_float4 scalar ); + + // Replicate an AoS quaternion + // + inline Quat( Aos::Quat quat ); + + // Insert four AoS quaternions + // + inline Quat( Aos::Quat quat0, Aos::Quat quat1, Aos::Quat quat2, Aos::Quat quat3 ); + + // Extract four AoS quaternions + // + inline void get4Aos( Aos::Quat & result0, Aos::Quat & result1, Aos::Quat & result2, Aos::Quat & result3 ) const; + + // Assign one quaternion to another + // + inline Quat & operator =( const Quat & quat ); + + // Set the x, y, and z elements of a quaternion + // NOTE: + // This function does not change the w element. + // + inline Quat & setXYZ( const Vector3 & vec ); + + // Get the x, y, and z elements of a quaternion + // + inline const Vector3 getXYZ( ) const; + + // Set the x element of a quaternion + // + inline Quat & setX( vec_float4 x ); + + // Set the y element of a quaternion + // + inline Quat & setY( vec_float4 y ); + + // Set the z element of a quaternion + // + inline Quat & setZ( vec_float4 z ); + + // Set the w element of a quaternion + // + inline Quat & setW( vec_float4 w ); + + // Get the x element of a quaternion + // + inline vec_float4 getX( ) const; + + // Get the y element of a quaternion + // + inline vec_float4 getY( ) const; + + // Get the z element of a quaternion + // + inline vec_float4 getZ( ) const; + + // Get the w element of a quaternion + // + inline vec_float4 getW( ) const; + + // Set an x, y, z, or w element of a quaternion by index + // + inline Quat & setElem( int idx, vec_float4 value ); + + // Get an x, y, z, or w element of a quaternion by index + // + inline vec_float4 getElem( int idx ) const; + + // Subscripting operator to set or get an element + // + inline vec_float4_t & operator []( int idx ); + + // Subscripting operator to get an element + // + inline vec_float4 operator []( int idx ) const; + + // Add two quaternions + // + inline const Quat operator +( const Quat & quat ) const; + + // Subtract a quaternion from another quaternion + // + inline const Quat operator -( const Quat & quat ) const; + + // Multiply two quaternions + // + inline const Quat operator *( const Quat & quat ) const; + + // Multiply a quaternion by a scalar + // + inline const Quat operator *( vec_float4 scalar ) const; + + // Divide a quaternion by a scalar + // + inline const Quat operator /( vec_float4 scalar ) const; + + // Perform compound assignment and addition with a quaternion + // + inline Quat & operator +=( const Quat & quat ); + + // Perform compound assignment and subtraction by a quaternion + // + inline Quat & operator -=( const Quat & quat ); + + // Perform compound assignment and multiplication by a quaternion + // + inline Quat & operator *=( const Quat & quat ); + + // Perform compound assignment and multiplication by a scalar + // + inline Quat & operator *=( vec_float4 scalar ); + + // Perform compound assignment and division by a scalar + // + inline Quat & operator /=( vec_float4 scalar ); + + // Negate all elements of a quaternion + // + inline const Quat operator -( ) const; + + // Construct an identity quaternion + // + static inline const Quat identity( ); + + // Construct a quaternion to rotate between two unit-length 3-D vectors + // NOTE: + // The result is unpredictable if unitVec0 and unitVec1 point in opposite directions. + // + static inline const Quat rotation( const Vector3 & unitVec0, const Vector3 & unitVec1 ); + + // Construct a quaternion to rotate around a unit-length 3-D vector + // + static inline const Quat rotation( vec_float4 radians, const Vector3 & unitVec ); + + // Construct a quaternion to rotate around the x axis + // + static inline const Quat rotationX( vec_float4 radians ); + + // Construct a quaternion to rotate around the y axis + // + static inline const Quat rotationY( vec_float4 radians ); + + // Construct a quaternion to rotate around the z axis + // + static inline const Quat rotationZ( vec_float4 radians ); + +}; + +// Multiply a quaternion by a scalar +// +inline const Quat operator *( vec_float4 scalar, const Quat & quat ); + +// Compute the conjugate of a quaternion +// +inline const Quat conj( const Quat & quat ); + +// Use a unit-length quaternion to rotate a 3-D vector +// +inline const Vector3 rotate( const Quat & unitQuat, const Vector3 & vec ); + +// Compute the dot product of two quaternions +// +inline vec_float4 dot( const Quat & quat0, const Quat & quat1 ); + +// Compute the norm of a quaternion +// +inline vec_float4 norm( const Quat & quat ); + +// Compute the length of a quaternion +// +inline vec_float4 length( const Quat & quat ); + +// Normalize a quaternion +// NOTE: +// The result is unpredictable when all elements of quat are at or near zero. +// +inline const Quat normalize( const Quat & quat ); + +// Linear interpolation between two quaternions +// NOTE: +// Does not clamp t between 0 and 1. +// +inline const Quat lerp( vec_float4 t, const Quat & quat0, const Quat & quat1 ); + +// Spherical linear interpolation between two quaternions +// NOTE: +// Interpolates along the shortest path between orientations. +// Does not clamp t between 0 and 1. +// +inline const Quat slerp( vec_float4 t, const Quat & unitQuat0, const Quat & unitQuat1 ); + +// Spherical quadrangle interpolation +// +inline const Quat squad( vec_float4 t, const Quat & unitQuat0, const Quat & unitQuat1, const Quat & unitQuat2, const Quat & unitQuat3 ); + +// Conditionally select between two quaternions +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// +inline const Quat select( const Quat & quat0, const Quat & quat1, vec_uint4 select1 ); + +#ifdef _VECTORMATH_DEBUG + +// Print a quaternion +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Quat & quat ); + +// Print a quaternion and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Quat & quat, const char * name ); + +#endif + +// A set of four 3x3 matrices in structure-of-arrays format +// +class Matrix3 +{ + Vector3 mCol0; + Vector3 mCol1; + Vector3 mCol2; + +public: + // Default constructor; does no initialization + // + inline Matrix3( ) { }; + + // Copy a 3x3 matrix + // + inline Matrix3( const Matrix3 & mat ); + + // Construct a 3x3 matrix containing the specified columns + // + inline Matrix3( const Vector3 & col0, const Vector3 & col1, const Vector3 & col2 ); + + // Construct a 3x3 rotation matrix from a unit-length quaternion + // + explicit inline Matrix3( const Quat & unitQuat ); + + // Set all elements of a 3x3 matrix to the same scalar value + // + explicit inline Matrix3( vec_float4 scalar ); + + // Replicate an AoS 3x3 matrix + // + inline Matrix3( const Aos::Matrix3 & mat ); + + // Insert four AoS 3x3 matrices + // + inline Matrix3( const Aos::Matrix3 & mat0, const Aos::Matrix3 & mat1, const Aos::Matrix3 & mat2, const Aos::Matrix3 & mat3 ); + + // Extract four AoS 3x3 matrices + // + inline void get4Aos( Aos::Matrix3 & result0, Aos::Matrix3 & result1, Aos::Matrix3 & result2, Aos::Matrix3 & result3 ) const; + + // Assign one 3x3 matrix to another + // + inline Matrix3 & operator =( const Matrix3 & mat ); + + // Set column 0 of a 3x3 matrix + // + inline Matrix3 & setCol0( const Vector3 & col0 ); + + // Set column 1 of a 3x3 matrix + // + inline Matrix3 & setCol1( const Vector3 & col1 ); + + // Set column 2 of a 3x3 matrix + // + inline Matrix3 & setCol2( const Vector3 & col2 ); + + // Get column 0 of a 3x3 matrix + // + inline const Vector3 getCol0( ) const; + + // Get column 1 of a 3x3 matrix + // + inline const Vector3 getCol1( ) const; + + // Get column 2 of a 3x3 matrix + // + inline const Vector3 getCol2( ) const; + + // Set the column of a 3x3 matrix referred to by the specified index + // + inline Matrix3 & setCol( int col, const Vector3 & vec ); + + // Set the row of a 3x3 matrix referred to by the specified index + // + inline Matrix3 & setRow( int row, const Vector3 & vec ); + + // Get the column of a 3x3 matrix referred to by the specified index + // + inline const Vector3 getCol( int col ) const; + + // Get the row of a 3x3 matrix referred to by the specified index + // + inline const Vector3 getRow( int row ) const; + + // Subscripting operator to set or get a column + // + inline Vector3 & operator []( int col ); + + // Subscripting operator to get a column + // + inline const Vector3 operator []( int col ) const; + + // Set the element of a 3x3 matrix referred to by column and row indices + // + inline Matrix3 & setElem( int col, int row, vec_float4 val ); + + // Get the element of a 3x3 matrix referred to by column and row indices + // + inline vec_float4 getElem( int col, int row ) const; + + // Add two 3x3 matrices + // + inline const Matrix3 operator +( const Matrix3 & mat ) const; + + // Subtract a 3x3 matrix from another 3x3 matrix + // + inline const Matrix3 operator -( const Matrix3 & mat ) const; + + // Negate all elements of a 3x3 matrix + // + inline const Matrix3 operator -( ) const; + + // Multiply a 3x3 matrix by a scalar + // + inline const Matrix3 operator *( vec_float4 scalar ) const; + + // Multiply a 3x3 matrix by a 3-D vector + // + inline const Vector3 operator *( const Vector3 & vec ) const; + + // Multiply two 3x3 matrices + // + inline const Matrix3 operator *( const Matrix3 & mat ) const; + + // Perform compound assignment and addition with a 3x3 matrix + // + inline Matrix3 & operator +=( const Matrix3 & mat ); + + // Perform compound assignment and subtraction by a 3x3 matrix + // + inline Matrix3 & operator -=( const Matrix3 & mat ); + + // Perform compound assignment and multiplication by a scalar + // + inline Matrix3 & operator *=( vec_float4 scalar ); + + // Perform compound assignment and multiplication by a 3x3 matrix + // + inline Matrix3 & operator *=( const Matrix3 & mat ); + + // Construct an identity 3x3 matrix + // + static inline const Matrix3 identity( ); + + // Construct a 3x3 matrix to rotate around the x axis + // + static inline const Matrix3 rotationX( vec_float4 radians ); + + // Construct a 3x3 matrix to rotate around the y axis + // + static inline const Matrix3 rotationY( vec_float4 radians ); + + // Construct a 3x3 matrix to rotate around the z axis + // + static inline const Matrix3 rotationZ( vec_float4 radians ); + + // Construct a 3x3 matrix to rotate around the x, y, and z axes + // + static inline const Matrix3 rotationZYX( const Vector3 & radiansXYZ ); + + // Construct a 3x3 matrix to rotate around a unit-length 3-D vector + // + static inline const Matrix3 rotation( vec_float4 radians, const Vector3 & unitVec ); + + // Construct a rotation matrix from a unit-length quaternion + // + static inline const Matrix3 rotation( const Quat & unitQuat ); + + // Construct a 3x3 matrix to perform scaling + // + static inline const Matrix3 scale( const Vector3 & scaleVec ); + +}; +// Multiply a 3x3 matrix by a scalar +// +inline const Matrix3 operator *( vec_float4 scalar, const Matrix3 & mat ); + +// Append (post-multiply) a scale transformation to a 3x3 matrix +// NOTE: +// Faster than creating and multiplying a scale transformation matrix. +// +inline const Matrix3 appendScale( const Matrix3 & mat, const Vector3 & scaleVec ); + +// Prepend (pre-multiply) a scale transformation to a 3x3 matrix +// NOTE: +// Faster than creating and multiplying a scale transformation matrix. +// +inline const Matrix3 prependScale( const Vector3 & scaleVec, const Matrix3 & mat ); + +// Multiply two 3x3 matrices per element +// +inline const Matrix3 mulPerElem( const Matrix3 & mat0, const Matrix3 & mat1 ); + +// Compute the absolute value of a 3x3 matrix per element +// +inline const Matrix3 absPerElem( const Matrix3 & mat ); + +// Transpose of a 3x3 matrix +// +inline const Matrix3 transpose( const Matrix3 & mat ); + +// Compute the inverse of a 3x3 matrix +// NOTE: +// Result is unpredictable when the determinant of mat is equal to or near 0. +// +inline const Matrix3 inverse( const Matrix3 & mat ); + +// Determinant of a 3x3 matrix +// +inline vec_float4 determinant( const Matrix3 & mat ); + +// Conditionally select between two 3x3 matrices +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// +inline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, vec_uint4 select1 ); + +#ifdef _VECTORMATH_DEBUG + +// Print a 3x3 matrix +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Matrix3 & mat ); + +// Print a 3x3 matrix and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Matrix3 & mat, const char * name ); + +#endif + +// A set of four 4x4 matrices in structure-of-arrays format +// +class Matrix4 +{ + Vector4 mCol0; + Vector4 mCol1; + Vector4 mCol2; + Vector4 mCol3; + +public: + // Default constructor; does no initialization + // + inline Matrix4( ) { }; + + // Copy a 4x4 matrix + // + inline Matrix4( const Matrix4 & mat ); + + // Construct a 4x4 matrix containing the specified columns + // + inline Matrix4( const Vector4 & col0, const Vector4 & col1, const Vector4 & col2, const Vector4 & col3 ); + + // Construct a 4x4 matrix from a 3x4 transformation matrix + // + explicit inline Matrix4( const Transform3 & mat ); + + // Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector + // + inline Matrix4( const Matrix3 & mat, const Vector3 & translateVec ); + + // Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector + // + inline Matrix4( const Quat & unitQuat, const Vector3 & translateVec ); + + // Set all elements of a 4x4 matrix to the same scalar value + // + explicit inline Matrix4( vec_float4 scalar ); + + // Replicate an AoS 4x4 matrix + // + inline Matrix4( const Aos::Matrix4 & mat ); + + // Insert four AoS 4x4 matrices + // + inline Matrix4( const Aos::Matrix4 & mat0, const Aos::Matrix4 & mat1, const Aos::Matrix4 & mat2, const Aos::Matrix4 & mat3 ); + + // Extract four AoS 4x4 matrices + // + inline void get4Aos( Aos::Matrix4 & result0, Aos::Matrix4 & result1, Aos::Matrix4 & result2, Aos::Matrix4 & result3 ) const; + + // Assign one 4x4 matrix to another + // + inline Matrix4 & operator =( const Matrix4 & mat ); + + // Set the upper-left 3x3 submatrix + // NOTE: + // This function does not change the bottom row elements. + // + inline Matrix4 & setUpper3x3( const Matrix3 & mat3 ); + + // Get the upper-left 3x3 submatrix of a 4x4 matrix + // + inline const Matrix3 getUpper3x3( ) const; + + // Set translation component + // NOTE: + // This function does not change the bottom row elements. + // + inline Matrix4 & setTranslation( const Vector3 & translateVec ); + + // Get the translation component of a 4x4 matrix + // + inline const Vector3 getTranslation( ) const; + + // Set column 0 of a 4x4 matrix + // + inline Matrix4 & setCol0( const Vector4 & col0 ); + + // Set column 1 of a 4x4 matrix + // + inline Matrix4 & setCol1( const Vector4 & col1 ); + + // Set column 2 of a 4x4 matrix + // + inline Matrix4 & setCol2( const Vector4 & col2 ); + + // Set column 3 of a 4x4 matrix + // + inline Matrix4 & setCol3( const Vector4 & col3 ); + + // Get column 0 of a 4x4 matrix + // + inline const Vector4 getCol0( ) const; + + // Get column 1 of a 4x4 matrix + // + inline const Vector4 getCol1( ) const; + + // Get column 2 of a 4x4 matrix + // + inline const Vector4 getCol2( ) const; + + // Get column 3 of a 4x4 matrix + // + inline const Vector4 getCol3( ) const; + + // Set the column of a 4x4 matrix referred to by the specified index + // + inline Matrix4 & setCol( int col, const Vector4 & vec ); + + // Set the row of a 4x4 matrix referred to by the specified index + // + inline Matrix4 & setRow( int row, const Vector4 & vec ); + + // Get the column of a 4x4 matrix referred to by the specified index + // + inline const Vector4 getCol( int col ) const; + + // Get the row of a 4x4 matrix referred to by the specified index + // + inline const Vector4 getRow( int row ) const; + + // Subscripting operator to set or get a column + // + inline Vector4 & operator []( int col ); + + // Subscripting operator to get a column + // + inline const Vector4 operator []( int col ) const; + + // Set the element of a 4x4 matrix referred to by column and row indices + // + inline Matrix4 & setElem( int col, int row, vec_float4 val ); + + // Get the element of a 4x4 matrix referred to by column and row indices + // + inline vec_float4 getElem( int col, int row ) const; + + // Add two 4x4 matrices + // + inline const Matrix4 operator +( const Matrix4 & mat ) const; + + // Subtract a 4x4 matrix from another 4x4 matrix + // + inline const Matrix4 operator -( const Matrix4 & mat ) const; + + // Negate all elements of a 4x4 matrix + // + inline const Matrix4 operator -( ) const; + + // Multiply a 4x4 matrix by a scalar + // + inline const Matrix4 operator *( vec_float4 scalar ) const; + + // Multiply a 4x4 matrix by a 4-D vector + // + inline const Vector4 operator *( const Vector4 & vec ) const; + + // Multiply a 4x4 matrix by a 3-D vector + // + inline const Vector4 operator *( const Vector3 & vec ) const; + + // Multiply a 4x4 matrix by a 3-D point + // + inline const Vector4 operator *( const Point3 & pnt ) const; + + // Multiply two 4x4 matrices + // + inline const Matrix4 operator *( const Matrix4 & mat ) const; + + // Multiply a 4x4 matrix by a 3x4 transformation matrix + // + inline const Matrix4 operator *( const Transform3 & tfrm ) const; + + // Perform compound assignment and addition with a 4x4 matrix + // + inline Matrix4 & operator +=( const Matrix4 & mat ); + + // Perform compound assignment and subtraction by a 4x4 matrix + // + inline Matrix4 & operator -=( const Matrix4 & mat ); + + // Perform compound assignment and multiplication by a scalar + // + inline Matrix4 & operator *=( vec_float4 scalar ); + + // Perform compound assignment and multiplication by a 4x4 matrix + // + inline Matrix4 & operator *=( const Matrix4 & mat ); + + // Perform compound assignment and multiplication by a 3x4 transformation matrix + // + inline Matrix4 & operator *=( const Transform3 & tfrm ); + + // Construct an identity 4x4 matrix + // + static inline const Matrix4 identity( ); + + // Construct a 4x4 matrix to rotate around the x axis + // + static inline const Matrix4 rotationX( vec_float4 radians ); + + // Construct a 4x4 matrix to rotate around the y axis + // + static inline const Matrix4 rotationY( vec_float4 radians ); + + // Construct a 4x4 matrix to rotate around the z axis + // + static inline const Matrix4 rotationZ( vec_float4 radians ); + + // Construct a 4x4 matrix to rotate around the x, y, and z axes + // + static inline const Matrix4 rotationZYX( const Vector3 & radiansXYZ ); + + // Construct a 4x4 matrix to rotate around a unit-length 3-D vector + // + static inline const Matrix4 rotation( vec_float4 radians, const Vector3 & unitVec ); + + // Construct a rotation matrix from a unit-length quaternion + // + static inline const Matrix4 rotation( const Quat & unitQuat ); + + // Construct a 4x4 matrix to perform scaling + // + static inline const Matrix4 scale( const Vector3 & scaleVec ); + + // Construct a 4x4 matrix to perform translation + // + static inline const Matrix4 translation( const Vector3 & translateVec ); + + // Construct viewing matrix based on eye position, position looked at, and up direction + // + static inline const Matrix4 lookAt( const Point3 & eyePos, const Point3 & lookAtPos, const Vector3 & upVec ); + + // Construct a perspective projection matrix + // + static inline const Matrix4 perspective( vec_float4 fovyRadians, vec_float4 aspect, vec_float4 zNear, vec_float4 zFar ); + + // Construct a perspective projection matrix based on frustum + // + static inline const Matrix4 frustum( vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ); + + // Construct an orthographic projection matrix + // + static inline const Matrix4 orthographic( vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ); + +}; +// Multiply a 4x4 matrix by a scalar +// +inline const Matrix4 operator *( vec_float4 scalar, const Matrix4 & mat ); + +// Append (post-multiply) a scale transformation to a 4x4 matrix +// NOTE: +// Faster than creating and multiplying a scale transformation matrix. +// +inline const Matrix4 appendScale( const Matrix4 & mat, const Vector3 & scaleVec ); + +// Prepend (pre-multiply) a scale transformation to a 4x4 matrix +// NOTE: +// Faster than creating and multiplying a scale transformation matrix. +// +inline const Matrix4 prependScale( const Vector3 & scaleVec, const Matrix4 & mat ); + +// Multiply two 4x4 matrices per element +// +inline const Matrix4 mulPerElem( const Matrix4 & mat0, const Matrix4 & mat1 ); + +// Compute the absolute value of a 4x4 matrix per element +// +inline const Matrix4 absPerElem( const Matrix4 & mat ); + +// Transpose of a 4x4 matrix +// +inline const Matrix4 transpose( const Matrix4 & mat ); + +// Compute the inverse of a 4x4 matrix +// NOTE: +// Result is unpredictable when the determinant of mat is equal to or near 0. +// +inline const Matrix4 inverse( const Matrix4 & mat ); + +// Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix +// NOTE: +// This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. The result is unpredictable when the determinant of mat is equal to or near 0. +// +inline const Matrix4 affineInverse( const Matrix4 & mat ); + +// Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix +// NOTE: +// This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. +// +inline const Matrix4 orthoInverse( const Matrix4 & mat ); + +// Determinant of a 4x4 matrix +// +inline vec_float4 determinant( const Matrix4 & mat ); + +// Conditionally select between two 4x4 matrices +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// +inline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, vec_uint4 select1 ); + +#ifdef _VECTORMATH_DEBUG + +// Print a 4x4 matrix +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Matrix4 & mat ); + +// Print a 4x4 matrix and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Matrix4 & mat, const char * name ); + +#endif + +// A set of four 3x4 transformation matrices in structure-of-arrays format +// +class Transform3 +{ + Vector3 mCol0; + Vector3 mCol1; + Vector3 mCol2; + Vector3 mCol3; + +public: + // Default constructor; does no initialization + // + inline Transform3( ) { }; + + // Copy a 3x4 transformation matrix + // + inline Transform3( const Transform3 & tfrm ); + + // Construct a 3x4 transformation matrix containing the specified columns + // + inline Transform3( const Vector3 & col0, const Vector3 & col1, const Vector3 & col2, const Vector3 & col3 ); + + // Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector + // + inline Transform3( const Matrix3 & tfrm, const Vector3 & translateVec ); + + // Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector + // + inline Transform3( const Quat & unitQuat, const Vector3 & translateVec ); + + // Set all elements of a 3x4 transformation matrix to the same scalar value + // + explicit inline Transform3( vec_float4 scalar ); + + // Replicate an AoS 3x4 transformation matrix + // + inline Transform3( const Aos::Transform3 & tfrm ); + + // Insert four AoS 3x4 transformation matrices + // + inline Transform3( const Aos::Transform3 & tfrm0, const Aos::Transform3 & tfrm1, const Aos::Transform3 & tfrm2, const Aos::Transform3 & tfrm3 ); + + // Extract four AoS 3x4 transformation matrices + // + inline void get4Aos( Aos::Transform3 & result0, Aos::Transform3 & result1, Aos::Transform3 & result2, Aos::Transform3 & result3 ) const; + + // Assign one 3x4 transformation matrix to another + // + inline Transform3 & operator =( const Transform3 & tfrm ); + + // Set the upper-left 3x3 submatrix + // + inline Transform3 & setUpper3x3( const Matrix3 & mat3 ); + + // Get the upper-left 3x3 submatrix of a 3x4 transformation matrix + // + inline const Matrix3 getUpper3x3( ) const; + + // Set translation component + // + inline Transform3 & setTranslation( const Vector3 & translateVec ); + + // Get the translation component of a 3x4 transformation matrix + // + inline const Vector3 getTranslation( ) const; + + // Set column 0 of a 3x4 transformation matrix + // + inline Transform3 & setCol0( const Vector3 & col0 ); + + // Set column 1 of a 3x4 transformation matrix + // + inline Transform3 & setCol1( const Vector3 & col1 ); + + // Set column 2 of a 3x4 transformation matrix + // + inline Transform3 & setCol2( const Vector3 & col2 ); + + // Set column 3 of a 3x4 transformation matrix + // + inline Transform3 & setCol3( const Vector3 & col3 ); + + // Get column 0 of a 3x4 transformation matrix + // + inline const Vector3 getCol0( ) const; + + // Get column 1 of a 3x4 transformation matrix + // + inline const Vector3 getCol1( ) const; + + // Get column 2 of a 3x4 transformation matrix + // + inline const Vector3 getCol2( ) const; + + // Get column 3 of a 3x4 transformation matrix + // + inline const Vector3 getCol3( ) const; + + // Set the column of a 3x4 transformation matrix referred to by the specified index + // + inline Transform3 & setCol( int col, const Vector3 & vec ); + + // Set the row of a 3x4 transformation matrix referred to by the specified index + // + inline Transform3 & setRow( int row, const Vector4 & vec ); + + // Get the column of a 3x4 transformation matrix referred to by the specified index + // + inline const Vector3 getCol( int col ) const; + + // Get the row of a 3x4 transformation matrix referred to by the specified index + // + inline const Vector4 getRow( int row ) const; + + // Subscripting operator to set or get a column + // + inline Vector3 & operator []( int col ); + + // Subscripting operator to get a column + // + inline const Vector3 operator []( int col ) const; + + // Set the element of a 3x4 transformation matrix referred to by column and row indices + // + inline Transform3 & setElem( int col, int row, vec_float4 val ); + + // Get the element of a 3x4 transformation matrix referred to by column and row indices + // + inline vec_float4 getElem( int col, int row ) const; + + // Multiply a 3x4 transformation matrix by a 3-D vector + // + inline const Vector3 operator *( const Vector3 & vec ) const; + + // Multiply a 3x4 transformation matrix by a 3-D point + // + inline const Point3 operator *( const Point3 & pnt ) const; + + // Multiply two 3x4 transformation matrices + // + inline const Transform3 operator *( const Transform3 & tfrm ) const; + + // Perform compound assignment and multiplication by a 3x4 transformation matrix + // + inline Transform3 & operator *=( const Transform3 & tfrm ); + + // Construct an identity 3x4 transformation matrix + // + static inline const Transform3 identity( ); + + // Construct a 3x4 transformation matrix to rotate around the x axis + // + static inline const Transform3 rotationX( vec_float4 radians ); + + // Construct a 3x4 transformation matrix to rotate around the y axis + // + static inline const Transform3 rotationY( vec_float4 radians ); + + // Construct a 3x4 transformation matrix to rotate around the z axis + // + static inline const Transform3 rotationZ( vec_float4 radians ); + + // Construct a 3x4 transformation matrix to rotate around the x, y, and z axes + // + static inline const Transform3 rotationZYX( const Vector3 & radiansXYZ ); + + // Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector + // + static inline const Transform3 rotation( vec_float4 radians, const Vector3 & unitVec ); + + // Construct a rotation matrix from a unit-length quaternion + // + static inline const Transform3 rotation( const Quat & unitQuat ); + + // Construct a 3x4 transformation matrix to perform scaling + // + static inline const Transform3 scale( const Vector3 & scaleVec ); + + // Construct a 3x4 transformation matrix to perform translation + // + static inline const Transform3 translation( const Vector3 & translateVec ); + +}; +// Append (post-multiply) a scale transformation to a 3x4 transformation matrix +// NOTE: +// Faster than creating and multiplying a scale transformation matrix. +// +inline const Transform3 appendScale( const Transform3 & tfrm, const Vector3 & scaleVec ); + +// Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix +// NOTE: +// Faster than creating and multiplying a scale transformation matrix. +// +inline const Transform3 prependScale( const Vector3 & scaleVec, const Transform3 & tfrm ); + +// Multiply two 3x4 transformation matrices per element +// +inline const Transform3 mulPerElem( const Transform3 & tfrm0, const Transform3 & tfrm1 ); + +// Compute the absolute value of a 3x4 transformation matrix per element +// +inline const Transform3 absPerElem( const Transform3 & tfrm ); + +// Inverse of a 3x4 transformation matrix +// NOTE: +// Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0. +// +inline const Transform3 inverse( const Transform3 & tfrm ); + +// Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix +// NOTE: +// This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions. +// +inline const Transform3 orthoInverse( const Transform3 & tfrm ); + +// Conditionally select between two 3x4 transformation matrices +// NOTE: +// This function uses a conditional select instruction to avoid a branch. +// +inline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, vec_uint4 select1 ); + +#ifdef _VECTORMATH_DEBUG + +// Print a 3x4 transformation matrix +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Transform3 & tfrm ); + +// Print a 3x4 transformation matrix and an associated string identifier +// NOTE: +// Function is only defined when _VECTORMATH_DEBUG is defined. +// +inline void print( const Transform3 & tfrm, const char * name ); + +#endif + +} // namespace Soa +} // namespace Vectormath + +#include "vec_soa.h" +#include "quat_soa.h" +#include "mat_soa.h" + +#endif diff --git a/vectormathlibrary/tests/main_vmtest.cpp b/vectormathlibrary/tests/main_vmtest.cpp new file mode 100644 index 000000000..7aa66e5aa --- /dev/null +++ b/vectormathlibrary/tests/main_vmtest.cpp @@ -0,0 +1,163 @@ + +///Testfile to test differences between vectormath and Bullet LinearMath + +#ifdef __PPU__ +#include "include/vectormath/ppu/cpp/vectormath_aos.h" +#elif defined __SPU__ +#include "include/vectormath/spu/cpp/vectormath_aos.h" +#else +#include "include/vectormath/SSE/cpp/vectormath_aos.h" +//#include "include/vectormath/scalar/cpp/vectormath_aos.h" +#endif + +#include "../../src/LinearMath/btTransform.h" +#include <stdio.h> + +//Bullet, a btVector can be used for both points and vectors. +//it is up to the user/developer to use the right multiplication: btTransform for points, and btQuaternion or btMatrix3x3 for vectors. +void BulletTest() +{ + + printf("Bullet Linearmath\n"); + + btTransform tr; + tr.setIdentity(); + + tr.setOrigin(btVector3(10,0,0)); + //initialization + btVector3 pointA(0,0,0); + btVector3 pointB,pointC,pointD,pointE; + //assignment + pointB = pointA; + //in-place initialization + pointB.setValue(1,2,3); + //transform over tr + pointB = tr * pointA; + printf("pointB = tr * pointA = (%f,%f,%f)\n",pointB.getX(),pointB.getY(),pointB.getZ()); + //transform over tr + pointE = tr(pointA); + //inverse transform + pointC = tr.inverse() * pointA; + printf("pointC = tr.inverse() * pointA = (%f,%f,%f)\n",pointC.getX(),pointC.getY(),pointC.getZ()); + //inverse transform + pointD = tr.invXform( pointA ); + btScalar x; + //dot product + x = pointD.dot(pointE); + //square length + x = pointD.length2(); + //length + x = pointD.length(); + + const btVector3& constPointD = pointD; + + //get a normalized vector from constPointD, without changing constPointD + btVector3 norm = constPointD.normalized(); + + //in-place normalize pointD + pointD.normalize(); + + //quaternions & matrices + btQuaternion quat(0,0,0,1); + btQuaternion quat1(btVector3(0,1,0),90.f * SIMD_RADS_PER_DEG); + btMatrix3x3 mat0(quat1); + btMatrix3x3 mat1 = mat0.inverse(); + btMatrix3x3 mat2 = mat0.transpose(); + btTransform tr1(mat2,btVector3(0,10,0)); + btTransform tr2 =tr1.inverse(); + btVector3 pt0(1,1,1); + btVector3 pt1 = tr2 * pt0; + + printf("btVector3 pt1 = tr2 * pt0 = (%f,%f,%f)\n",pt1.getX(),pt1.getY(),pt1.getZ()); + + + btVector3 pt2 = tr2.getBasis() * pt0; + btVector3 pt3 = pt0 * tr2.getBasis(); + btVector3 pt4 = tr2.getBasis().inverse() * pt0; + btTransform tr3 = tr2.inverseTimes(tr2); + + + +} + +//vectormath makes a difference between point and vector. +void VectormathTest() +{ + + printf("Vectormath\n"); + + Vectormath::Aos::Transform3 tr; + tr = Vectormath::Aos::Transform3::identity(); + + tr.setTranslation(Vectormath::Aos::Vector3(10,0,0)); + //initialization + Vectormath::Aos::Point3 pointA(0,0,0); + Vectormath::Aos::Point3 pointB,pointC,pointE; + Vectormath::Aos::Vector3 pointD; + //assignment + pointB = pointA; + //in-place initialization + pointB = Vectormath::Aos::Point3(1,2,3); //or + pointB.setElem(0,1); //or + pointB.setX(1); + + //transform over tr + pointB = tr * pointA; + + printf("pointB = tr * pointA = (%f,%f,%f)\n",(float)pointB.getX(),(float)pointB.getY(),(float)pointB.getZ()); + //transform over tr + //pointE = tr(pointA); + //inverse transform + pointC = Vectormath::Aos::inverse(tr) * pointA; + printf("Vectormath::Aos::inverse(tr) * pointA = (%f,%f,%f)\n",(float)pointC.getX(),(float)pointC.getY(),(float)pointC.getZ()); + + + + btScalar x; + //dot product + x = Vectormath::Aos::dot(Vectormath::Aos::Vector3(pointD),Vectormath::Aos::Vector3(pointE)); + //square length + x = Vectormath::Aos::lengthSqr(Vectormath::Aos::Vector3(pointD)); + //length + x = Vectormath::Aos::length(Vectormath::Aos::Vector3(pointD)); + + const Vectormath::Aos::Vector3& constPointD = (Vectormath::Aos::Vector3&)pointD; + + //get a normalized vector from constPointD, without changing constPointD + Vectormath::Aos::Vector3 norm = Vectormath::Aos::normalize(constPointD); + + //in-place normalize pointD + pointD = Vectormath::Aos::normalize(Vectormath::Aos::Vector3(pointD)); + + //quaternions & matrices + Vectormath::Aos::Quat quat(0,0,0,1); + Vectormath::Aos::Quat quat1; + quat1 = Vectormath::Aos::Quat::rotationY(90.f * SIMD_RADS_PER_DEG); + + Vectormath::Aos::Matrix3 mat0(quat1); + + Vectormath::Aos::Matrix3 mat1 = Vectormath::Aos::inverse(mat0); + Vectormath::Aos::Matrix3 mat2 = Vectormath::Aos::transpose(mat0); + Vectormath::Aos::Transform3 tr1(mat2,Vectormath::Aos::Vector3(0,10,0)); + Vectormath::Aos::Transform3 tr2 = Vectormath::Aos::inverse(tr1); + Vectormath::Aos::Point3 pt0(1,1,1); + Vectormath::Aos::Point3 pt1 = tr2 * pt0; + printf("Vectormath::Aos::Vector3 pt1 = tr2 * pt0; = (%f,%f,%f)\n",(float)pt1.getX(),(float)pt1.getY(),(float)pt1.getZ()); + + Vectormath::Aos::Vector3 pt2 = tr2.getUpper3x3() * Vectormath::Aos::Vector3(pt0); + //Vectormath::Aos::Vector3 pt3 = pt0 * tr2.getUpper3x3(); + Vectormath::Aos::Vector3 pt3 = Vectormath::Aos::inverse(tr2.getUpper3x3()) * Vectormath::Aos::Vector3(pt0); + Vectormath::Aos::Vector3 pt4 = Vectormath::Aos::inverse(tr2.getUpper3x3()) * Vectormath::Aos::Vector3(pt0); + Vectormath::Aos::Transform3 tr3 = Vectormath::Aos::inverse(tr2) * tr2; + +} + +int main() +{ + + BulletTest(); + + VectormathTest(); + + return 0; +} diff --git a/vectormathlibrary/tests/test.h b/vectormathlibrary/tests/test.h new file mode 100644 index 000000000..acb65436d --- /dev/null +++ b/vectormathlibrary/tests/test.h @@ -0,0 +1,346 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _VECTORMATH_TEST_H +#define _VECTORMATH_TEST_H + +#if defined(__SPU__) +# define vec_splats_float(v) spu_splats(v) +# define vec_mul_float(a, b) spu_mul(a, b) +# define vec_add_float(a, b) spu_add(a, b) +# define vec_sub_float(a, b) spu_sub(a, b) +#elif defined(__ALTIVEC__) +# define vec_splats_float(v) ((vec_float4){(float)(v),(float)(v),(float)(v),(float)(v)}) +# define vec_mul_float(a, b) vec_madd(a, b, vec_splats_float(0.0f)) +# define vec_add_float(a, b) vec_add(a, b) +# define vec_sub_float(a, b) vec_sub(a, b) +#elif defined(__SSE__) +# error "Not implemented." +#else +# define _VECTORMATH_SCALAR_TEST +#endif + +float randfloats[1024] = { + -0.658343927787421f,0.499803960969928f,-0.807256688752865f,0.740930454054151f, + 0.154607013590216f,0.571598517679348f,0.38438830691728f,-0.262467460159158f, + 0.747808153723618f,0.49019019690013f,-0.107908181813777f,-0.292543593813249f, + 0.465039264005078f,-0.47955599783424f,-0.211412450152245f,0.553579902451233f, + 0.690070275160572f,0.151576400965553f,0.431077190337326f,-0.833991507852247f, + -0.0883497426804851f,-0.780106371638709f,0.0904560476331469f,-0.218626858702649f, + 0.137170846428894f,0.918132898976751f,0.735438192918274f,-0.673620979495283f, + -0.448982146263369f,-0.479277810255866f,0.848189483738331f,-0.12815472579463f, + 0.578921731104181f,-0.744765966376519f,-0.83558862791913f,0.881284032895692f, + -0.948850147493964f,-0.691578137344351f,-0.235635149443688f,-0.690526600666615f, + 0.0586668362339609f,0.753696982166502f,-0.138777123323202f,-0.472187547315841f, + -0.372811001953572f,0.540183371709446f,-0.78521823389179f,0.542084510391291f, + 0.410391117788897f,-0.562720682584484f,0.523587985711991f,-0.176573908842087f, + 0.297653645858226f,0.859912509814734f,0.00483713119734119f,0.374881358857735f, + -0.127818103705344f,0.21660181589948f,0.153117267270737f,0.265243421428139f, + -0.0731487047425148f,0.264487579220173f,-0.723410134701346f,0.921522835850382f, + -0.711249997824318f,-0.106633857864438f,-0.350831080309241f,0.905168155184938f, + -0.283632179037646f,-0.203583555015513f,-0.797436915535236f,0.910171471305759f, + 0.96923389534215f,0.151940162902974f,0.731827470770519f,-0.700248217534451f, + 0.818300860563319f,0.302505017280083f,-0.872278290470156f,0.909998773124912f, + 0.932525528551317f,0.571086770427939f,0.610329635790002f,0.142507359591505f, + -0.43482856009151f,0.925102103935927f,0.158954117892613f,-0.126282746058862f, + -0.249127650925452f,0.846815218386041f,-0.942601239873774f,0.537719955431001f, + 0.446213543435171f,0.181938699625931f,-0.148222922840326f,0.284286118166037f, + 0.493525458201255f,-0.861962900371793f,-0.893410102755276f,0.548627291142694f, + 0.407006961478977f,-0.757467096890906f,-0.393126176069536f,-0.850984293029867f, + 0.375719573110992f,-0.270087780463427f,0.45888819784826f,-0.610827766442796f, + -0.690815628408266f,-0.676415221072347f,0.664465776005038f,0.101873923854313f, + -0.365713939355025f,0.0554727439164822f,-0.133556089035984f,-0.572643072647438f, + 0.459209235899415f,-0.997261395030506f,0.172408991295974f,-0.0451240115316551f, + 0.879715937508259f,0.524317125330867f,-0.744532077249495f,-0.970443523820151f, + -1.32784686215359e-05f,0.689543072301063f,0.704297111725616f,-0.817983008667298f, + 0.71550535643383f,0.577868436783262f,0.156952383805468f,-0.80102179210472f, + 0.65633547615213f,0.494393128677046f,0.816743155389922f,0.0242848471199721f, + 0.769131722839866f,0.923894866655701f,0.133021600755988f,-0.0522193159450097f, + -0.164886284373118f,0.300690282133047f,0.760403145270168f,0.171869369152077f, + -0.554975788488598f,0.998693253807744f,-0.681641007087912f,0.391194738828759f, + 0.403058705852153f,0.972411306067528f,0.297195187773745f,0.309761312769567f, + 0.688408077837671f,0.363539666742895f,0.94029653976505f,-0.336683042511069f, + 0.600164345782652f,-0.681271587780742f,0.726558239385319f,0.205513360229233f, + -0.16008221686365f,0.962714155748642f,0.737793770111715f,-0.0719258703692134f, + -0.506312816314299f,0.689277082946518f,0.686485424709581f,0.473013144786293f, + -0.735610421404026f,-0.0463900680836105f,0.568673968586005f,-0.00481466271939723f, + 0.137636823654454f,-0.111879120785687f,-0.929542605813147f,-0.336303463382606f, + -0.146740182632236f,0.165140351947514f,-0.823874099621072f,0.349776463047661f, + 0.174872304411146f,-0.528584334304156f,0.489291834762803f,0.916707538240686f, + 0.728510889338118f,-0.851139787348188f,0.0796199799283031f,-0.234369971523549f, + -0.996308342568362f,0.433228819394486f,-0.892684128206504f,-0.95791073791078f, + 0.517122298113016f,0.257920984044574f,0.862028434359466f,0.0958813977553206f, + -0.171932523577503f,-0.214077886807473f,-0.604841274532937f,-0.38383141210609f, + -0.58149997525441f,0.222182734948547f,-0.2561203625418f,-0.678699493062183f, + -0.0795530448181339f,0.605960090732907f,-0.633147389976791f,0.435875222532317f, + -0.0466270522618899f,-0.71649136999298f,0.267317414957141f,-0.514873596167021f, + -0.751699524124625f,0.742958874040227f,-0.793179510948171f,0.508814009999512f, + -0.238839286150373f,0.113471002014307f,-0.843523253083085f,-0.245249991279181f, + 0.250368454758338f,0.579243470287253f,-0.157280074848025f,0.648487464157242f, + 0.103833079240538f,0.456401128469849f,-0.0223720820167514f,-0.475631368950744f, + -0.0041782226245104f,-0.0208652308868125f,-0.0169971127675765f,0.699143621917685f, + 0.83779636548531f,-0.276082033737794f,0.0915817913013015f,0.209063902268738f, + 0.219316780269516f,-0.118359453100055f,0.413442003735092f,-0.567697560481989f, + 0.531358299984625f,-0.387225776610819f,0.572489506868486f,-0.820417090039186f, + 0.797191361229615f,0.867177919412683f,0.934764375062564f,0.237092079542023f, + -0.866161864691826f,-0.773938728379676f,0.261310530107004f,-0.851569556583101f, + 0.114814425111355f,-0.531592190789155f,0.223924683490957f,0.869104561345111f, + 0.143404566999386f,0.148517529008075f,-0.0711363985626363f,-0.758291614176514f, + -0.527633502740933f,0.99721511923596f,0.114439963849399f,0.72755837253878f, + -0.425760405626697f,0.459888066153781f,0.642515762634126f,-0.0225335867899474f, + 0.186094961562027f,-0.775678571017551f,-0.683400976752644f,0.398133764191002f, + 0.189642093838877f,0.765986315134853f,-0.137794739254879f,-0.579843714684088f, + -0.63564699482432f,0.374970154657689f,-0.563749876868947f,-0.471075422601373f, + -0.553799500723066f,-0.0146881150006948f,-0.464365244644604f,-0.10788986146774f, + -0.527503023060852f,-0.406422760262416f,0.301261161950258f,0.499528573888128f, + 0.385179609005043f,-0.150218387266079f,0.519111879977139f,-0.203208683924331f, + -0.252017508479717f,0.282193567323901f,0.0676372217166588f,0.798376368300907f, + 0.310782163860559f,0.861334103612307f,-0.980345166653173f,-0.655105604450725f, + 0.286765236319503f,0.532078410709602f,0.352670966735097f,0.540977184819425f, + 0.510961465933072f,0.791871139829084f,-0.564378698589145f,0.273199199047909f, + 0.194378063163676f,0.244636363558442f,-0.2696079922111f,-0.858162214209599f, + -0.495023067522474f,-0.277797538673553f,-0.0327403642191157f,0.00741169596342672f, + -0.420178428178723f,-0.522576683894926f,0.324971970060567f,0.795389045001329f, + 0.342900104539247f,-0.913636452280628f,0.675221839440177f,0.144052833646484f, + -0.632328982629893f,-0.947119831218089f,-0.0493673719309484f,0.126332763266575f, + -0.66420574517786f,0.220879155225703f,0.284218535482147f,-0.387215543918998f, + 0.913567998448777f,0.531906099678991f,0.271995095904906f,-0.862600551020719f, + -0.738693635668703f,0.514248487507359f,-0.0393632803376036f,0.429389595727585f, + -0.769468991576751f,0.28133632724311f,-0.203301313955485f,0.412585911285348f, + 0.567925862321268f,0.410131004328946f,-0.462918277454527f,0.560952548692129f, + -0.731715443500342f,-0.446157565377547f,-0.837491324975311f,-0.573480361464263f, + -0.607819850918752f,0.23841499693998f,0.213445432027605f,0.0986122683758737f, + 0.135072190814675f,-0.749273552937012f,-0.855977160741141f,0.765675059673342f, + -0.693447453911567f,0.131554184087008f,-0.366756547983336f,-0.330409262236842f, + -0.588815619465343f,0.352532978762866f,-0.920522750723883f,-0.915255088789323f, + 0.631923943060777f,-0.870739292438145f,0.415604498050605f,-0.180973894496887f, + 0.775697838994837f,0.879356890591083f,-0.993957564335638f,-0.298451942545356f, + 0.876855036440425f,0.982846031192253f,-0.282564044364371f,0.95346849594155f, + -0.947311505090191f,-0.317822974923359f,0.692391664998802f,-0.123566763365389f, + 0.407041678839057f,0.141204372181107f,-0.793069847914673f,-0.638275471740698f, + -0.51955405631346f,0.368499710074474f,0.970213689037045f,0.0272163305900648f, + 0.801791483976395f,-0.0663635812993562f,-0.0512834823579524f,-0.184935295126749f, + 0.516982835871183f,-0.769951152485618f,-0.708267044537941f,0.398266880674086f, + -0.479614543356881f,0.0604142126476859f,-0.867394563338259f,-0.702364045743693f, + -0.18260171523908f,-0.83280747136078f,0.278190893454216f,-0.967562302471109f, + -0.52029595778054f,0.160191201466318f,-0.677989785356466f,-0.470750261667419f, + -0.846579999787899f,-0.705750757861409f,-0.825367487626302f,-0.712890462610304f, + -0.0644873847193068f,0.444064587944183f,-0.0452257881147275f,0.116544259603998f, + -0.00728451932408092f,-0.838230133415692f,-0.410766823165496f,-0.40929905742685f, + -0.336682948179195f,-0.830699768111344f,-0.801729180453698f,-0.595152571835385f, + -0.784671779507129f,-0.653655236426147f,0.670791046451306f,0.653571468806589f, + 0.850715654625567f,0.0714334825891569f,-0.0577154211012854f,0.401895373758876f, + 0.0168605144772656f,0.5354384129881f,0.965901293540405f,-0.0726753529456374f, + 0.341689326326282f,0.781662445971847f,0.707322369548329f,0.505889413040066f, + 0.43279006682301f,-0.82579284323046f,0.597718837056043f,-0.250904847502525f, + -0.085712490334565f,-0.27284668464705f,0.552644217406645f,0.19420250718521f, + -0.884426763638054f,-0.756791257372726f,0.121106956043313f,0.312482778322803f, + -0.873316960494485f,0.0450805196969668f,0.687443898195021f,-0.684625629977333f, + -0.994046624794031f,0.800365484075002f,-0.565640229111075f,-0.625626063021869f, + 0.932584676112249f,0.636927568286012f,0.420250137262336f,0.175862511828669f, + 0.362158342804186f,0.547495978208275f,-0.534422794348934f,-0.563030463450744f, + -0.254488285756501f,0.647777595706543f,-0.674240168502628f,0.224344628949055f, + -0.754563097553635f,-0.12881655237274f,-0.997838330250381f,0.0369162049154141f, + -0.077549312424928f,0.376025736059717f,-0.935044655882827f,-0.189804125597547f, + 0.00764933224392195f,-0.440298102088747f,0.994796322297979f,-0.271484040660724f, + -0.2590701870053f,0.902148580301628f,-0.836501451887365f,0.229092669621153f, + 0.5863932076197f,-0.287825592948792f,0.942655407357726f,-0.634432455852235f, + -0.140437555704573f,0.570869095619685f,-0.764965080867434f,0.0675228424859284f, + -0.514589062662218f,0.233090988246516f,0.554487773397391f,-0.633529215840056f, + -0.0193735702003366f,0.869258510751365f,-0.369818396412519f,-0.280689998188947f, + -0.797208739895403f,-0.255233407527697f,0.780605315236578f,0.789803426518219f, + 0.974261893445153f,-0.785980203848396f,-0.701385987245636f,0.871088183435759f, + 0.566742533772562f,0.75227294222347f,-0.476301298243307f,-0.747341931420877f, + 0.0773855838641069f,-0.305599507084935f,-0.229193881336336f,-0.260009071921601f, + -0.0515187258224827f,0.459831012841761f,0.861793377659517f,-0.00839510548009059f, + -0.0535644390132504f,0.912885769359548f,-0.402379747450233f,-0.10435292389046f, + 0.644045025641198f,-0.235395897167933f,0.454549452554879f,-0.303775931682779f, + 0.321575614700528f,0.724025709176772f,0.330082831646187f,0.609903689400269f, + 0.851604270169993f,-0.356715440425745f,-0.0455002843413084f,0.13772975575408f, + -0.148995564903764f,0.892453960056798f,-0.821676934893254f,-0.14847536459807f, + -0.381886292618752f,0.398820351836747f,-0.292289360617424f,0.0702858731114446f, + -0.772469821167697f,0.474357996692333f,0.857792314833965f,-0.720558506386439f, + 0.888908862188352f,-0.950919194501893f,-0.196258139903655f,-0.59980821479941f, + -0.794413298851502f,-0.927635622930836f,-0.18747758800405f,-0.113038430406718f, + 0.366119602275866f,-0.483786056117111f,0.622670249344587f,-0.801805699607442f, + 0.295383348060291f,0.0220054959489744f,-0.000678144987013241f,-0.68933407333013f, + 0.266537772395942f,-0.785099000882013f,-0.572664686201399f,0.772760435300924f, + 0.97189582826514f,-0.961362535549199f,0.723449439795125f,-0.758441529489218f, + -0.733158222482722f,0.13966678591575f,-0.73814671277507f,0.727223546774141f, + 0.0899213092919311f,-0.113118130362636f,-0.364554501988017f,-0.137644753297124f, + 0.933846571857863f,0.615857754190102f,0.442837902751755f,0.691293553853697f, + 0.862436507424839f,-0.769632706987466f,-0.069558455823973f,-0.216368763497925f, + -0.240286864167238f,-0.494147338088084f,-0.732343541285623f,0.247500097354347f, + 0.238013165932848f,-0.0222504081638135f,0.0354097573205863f,0.562870060908224f, + -0.443182852051812f,-0.148476065390099f,-0.785559583638936f,-0.534284390277335f, + 0.804060941136193f,0.161693072162677f,0.626454348053834f,0.564290128221401f, + 0.414242183673117f,-0.314079097076757f,0.871460392700492f,-0.586016607169839f, + 0.446183340840953f,0.670697807509214f,-0.31261251323f,-0.34635111476409f, + -0.32237160168031f,0.0615992346122596f,0.108866036772035f,-0.96854607364277f, + -0.0900520153269255f,-0.000638517939648864f,-0.497526906200939f,0.0210549572282304f, + -0.513626724036349f,0.219974002433304f,-0.406318097379831f,0.829310754424156f, + 0.139888080843043f,-0.409132737685127f,-0.0296375827238435f,-0.713853913104842f, + 0.286946651436075f,-0.734473045715816f,0.649341057254212f,0.0281454231254514f, + -0.188432361127518f,-0.683807673918693f,0.432885949511977f,-0.0361810926016091f, + 0.438347837417645f,0.710651677026334f,0.673928786874676f,-0.0546809333762468f, + 0.826058562813905f,-0.832265197271681f,-0.668493142354613f,0.35502470967181f, + 0.5354983136667f,0.82137347039f,-0.143300610352533f,0.713426364459551f, + -0.297806605505109f,0.340760003596245f,-0.564118270640485f,-0.0240265108522948f, + -0.60137093958766f,-0.178866127631323f,-0.229680331692812f,0.741055717732976f, + -0.219526898682084f,0.534269946476002f,0.133115059442581f,-0.249583317941799f, + 0.811487242943805f,0.699282902509054f,-0.43331663912921f,0.71961761681392f, + 0.943524928147106f,0.523603303061634f,-0.677065472025312f,-0.636492873531878f, + 0.0384525794274069f,-0.377124785497273f,0.967031372742831f,0.435091298236713f, + 0.161520957813146f,-0.15972397671726f,-0.166845254078147f,-0.587937091804449f, + 0.910419348982238f,0.764819474485904f,-0.987496701506423f,-0.838882086564368f, + -0.41301635023239f,0.740276015423035f,0.951437768918503f,0.284889876776347f, + -0.158434377954073f,0.73838340645338f,-0.370863653408783f,0.989946556977472f, + -0.848079748582045f,-0.449771614068709f,0.663499305019705f,-0.93185425837116f, + 0.523896920061681f,-0.232489928806984f,-0.538281594630583f,-0.899682373052556f, + -0.338756398325579f,0.951550867830917f,0.494550167204373f,0.194556783574981f, + 0.243717136517866f,0.224354070146973f,0.143792613511486f,-0.333553884855363f, + 0.229952471240104f,-0.204077808365582f,0.469903146410694f,-0.958373658125808f, + -0.226054823628623f,0.229899490605959f,0.196501423332386f,0.879845549743308f, + 0.577560209175438f,0.641089277668982f,0.642316105885037f,0.232802361926147f, + -0.381538604113949f,0.640474533642731f,-0.913151229860155f,-0.614188561923768f, + 0.171776090268345f,-0.645757746280538f,-0.122217277374411f,0.00689941379876302f, + 0.019433549917359f,-0.0675691088088968f,-0.373650414044171f,-0.67103881780362f, + 0.504459382741295f,-0.14911057310502f,0.148122926701966f,0.694898716737626f, + 0.585837578674649f,-0.750790936323284f,0.853926520879604f,0.15730556487317f, + -0.113618219173468f,0.320367463625416f,-0.552134285767956f,-0.920422170186882f, + -0.338845809007829f,-0.810536065394189f,-0.177695639626343f,0.351905028679525f, + 0.0633494717407146f,-0.865174843305965f,0.634557634797282f,-0.787750206138512f, + -0.379512173859858f,0.791878043518267f,-0.704956748246282f,-0.670757904173982f, + 0.684751731590218f,-0.953277716787511f,0.985770879077755f,0.122219634876117f, + 0.1721202012071f,-0.388256876288864f,-0.73825752183587f,0.906019401398325f, + -0.803381430261645f,-0.74941181755554f,0.0727255174881734f,-0.221605735994771f, + -0.564223723915198f,-0.213656403861052f,-0.608162856680174f,0.921170937654253f, + 0.0847855661657562f,0.417987807384179f,-0.330418934403873f,0.648809934312297f, + 0.0796460930869003f,0.550628835897015f,-0.92719924470385f,0.877452232036589f, + 0.559779671355166f,-0.0896538710039181f,0.849093177103803f,-0.747330460544603f, + -0.87952842676733f,0.791614152693995f,-0.483542677352212f,0.795053306558017f, + -0.246444636768096f,-0.967515102978155f,0.159471890174437f,0.210810164441753f, + -0.874227023772981f,-0.0805964482800334f,0.567497201138046f,-0.137743608785641f, + -0.710773819308763f,-0.589571113738941f,0.83391847788473f,0.474349423613731f, + -0.495444643831966f,-0.415319533683743f,-0.688818445640273f,0.923238489082379f, + 0.688452278243922f,-0.639758117768224f,0.353458578584501f,-0.352412753977475f, + -0.667399029986676f,0.586965778853283f,0.352610916528867f,0.360697015758419f, + -0.502839728688848f,-0.539644214882799f,0.365329906944815f,-0.379932106654209f, + -0.269280779163601f,0.694895571222645f,0.727823970732565f,0.51105486079409f, + -0.761212733299821f,-0.551940664095241f,0.953323471475834f,-0.915964879494524f, + 0.199091342904332f,0.0392241713497299f,-0.19261671908783f,-0.6074206562147f, + 0.345256597791838f,0.031516093623793f,0.563117849295644f,-0.0626584858579093f, + -0.491887339392029f,-0.758788812866925f,0.265995340863064f,0.23182766277084f, + 0.069408408971249f,-0.758115582411847f,-0.495213306068685f,-0.941798830898321f, + -0.244099121724069f,-0.496495655783264f,0.217102928532306f,-0.958590442403207f, + -0.951376141167081f,-0.454184666450089f,0.886300276933433f,0.487002988091731f, + 0.0249044829036293f,-0.482416930998085f,0.949278378895364f,0.332136035903019f, + 0.667897336691517f,-0.903192712329542f,0.0759824890853551f,-0.338269985337703f, + -0.29518903317139f,-0.768719116695905f,-0.648362986306786f,0.935201134387952f, + 0.661626711929564f,0.224599917215244f,0.348525351988449f,-0.972641665331466f, + 0.996220202383405f,-0.72814219793807f,-0.921619408688976f,-0.134878186992026f, + 0.496907260713279f,0.544992091878385f,0.238303715804555f,-0.924062793629034f, + -0.630686074442814f,-0.865452949495847f,-0.222028734920293f,0.171739204767604f, + 0.997130539607845f,0.918172604643416f,-0.694626556063078f,0.672880204329672f, + -0.175982089302543f,-0.876546457819273f,-0.699672836718442f,0.809662568756764f, + 0.393205100623341f,-0.108144983913576f,-0.486322989569125f,-0.613674712751319f, + -0.317080956716971f,0.471134684264513f,-0.30417867085874f,0.696115419091356f, + -0.469268432777419f,0.236211281027806f,-0.772378939124543f,0.460249824926805f, + -0.654534877200454f,-0.934852798470303f,0.032756384083477f,-0.66677857258658f, + 0.314980215822125f,-0.289198088561079f,-0.0476688874127049f,0.0583547444711741f, + 0.941740852748786f,0.774296795413221f,-0.414622097461695f,0.638345821607103f, + -0.358465167682304f,-0.700596445490135f,0.374529194857949f,0.45456008092971f, + -0.853620900176985f,0.494280579565469f,-0.217619888424174f,0.956186128386705f, + 0.0389822381652678f,-0.19316201021536f,0.00512085504598048f,-0.0427176575011998f, + 0.547932129275615f,0.721865358296469f,0.456248153651011f,0.618884232413038f, + 0.0410425055490649f,-0.0673903257300594f,-0.218781418704999f,0.528492225462415f, + -0.0837068514807342f,0.718697939323846f,-0.603328224259776f,0.875509849594366f, + -0.0909494938322766f,-0.280637910576161f,-0.645530682341054f,-0.705120660981081f, + -0.529475884017096f,0.140296797228785f,-0.0133440668494202f,0.529843637228154f, + -0.25828493683013f,0.619866268930593f,0.47419437241583f,0.447278725151833f, + 0.821711397258731f,-0.617272470973745f,-0.212155578716597f,-0.794533711360103f, + -0.762402399229636f,-0.66554198883216f,0.86799064535122f,-0.61415791629922f, + 0.650236475570502f,0.838917668255732f,-0.658036726366966f,0.79973808497526f, + -0.583232188921549f,-0.958456594727579f,-0.670917275207309f,-0.607735262211108f, + 0.374114548594356f,0.758519548998692f,-0.831818710697753f,-0.606668498198204f, + 0.461609482669083f,0.676995424711095f,0.338856030176508f,0.5967074997629f, + -0.925180531336558f,0.4696830362291f,-0.0384243216844951f,0.649557593176482f, + 0.502765260428653f,0.513967467262376f,-0.515358199072217f,-0.444119277197828f, + -0.230720891612428f,0.348053063903166f,0.335781438011331f,0.567805000835321f, + -0.345275268793607f,0.452852845315761f,-0.823034642564643f,-0.629914051647049f, + -0.248509141280827f,0.107760047194603f,0.103293698795021f,0.347988561161273f, + -0.103424145197316f,0.151822355394586f,-0.272890315097335f,0.940838684544033f, + 0.174472591496773f,0.741124360281646f,-0.950217097467039f,-0.922017392413252f, + 0.496955384825533f,-0.588424819191232f,-0.285012984144181f,-0.292976024259858f, + 0.30303004349728f,0.748249196092075f,-0.565826698130202f,0.973592191086922f, + 0.598249548946463f,-0.926358493656323f,-0.241048287909827f,0.996364548389252f, + -0.0599127959717052f,0.174629249412504f,-0.96587410625029f,0.980693566420129f, + -0.696388116912935f,-0.900221651108609f,-0.706671628163384f,0.990309443320101f, + -0.585908086908283,0.414355789768166f,0.456957525423029f,-0.308246583228438f, +}; + +#ifdef _VECTORMATH_SOA_TEST +inline float getfloat( vec_float4 val ) +{ + union { vec_float4 v; float s[4]; } tmp; + tmp.v = val; + return tmp.s[0]; +} + +vec_float4 randfloat() +{ + static int randfloat_count = 0; + int idx = randfloat_count; + vec_float4 tmp = (vec_float4){randfloats[idx],randfloats[idx],randfloats[idx],randfloats[idx]}; + randfloat_count = (randfloat_count+1) % 1024; + return tmp; +} + +#else +inline float getfloat( float val ) +{ + return val; +} + +float randfloat() +{ + static int randfloat_count = 0; + float tmp = randfloats[randfloat_count]; + randfloat_count = (randfloat_count+1) % 1024; + return tmp; +} +#endif + +#ifdef _VECTORMATH_SCALAR_TEST +# define scalar_float(v) (v) +#else +# define scalar_float(v) floatInVec(v) +#endif + +#endif diff --git a/vectormathlibrary/tests/test1_aos_c.c b/vectormathlibrary/tests/test1_aos_c.c new file mode 100644 index 000000000..c5e7a7a1b --- /dev/null +++ b/vectormathlibrary/tests/test1_aos_c.c @@ -0,0 +1,1153 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _VECTORMATH_AOS_TEST + +#include "vectormath_aos.h" +#include "test.h" + +int iteration = 0; + +void +Vector3_methods_test() +{ + VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3, e_Vector3; + VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4, e_Vector4; + VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3, e_Point3; + VmathQuat a_Quat, b_Quat, c_Quat, d_Quat, e_Quat; + VmathVector4 tmpV4; + VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, aos_Vector3_0, aos_Vector3_1, aos_Vector3_2, aos_Vector3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7; + VmathVector4 aos_Vector4_0, aos_Vector4_1, aos_Vector4_2; + VmathVector3 tmpV3_8, tmpV3_9; + VmathPoint3 tmpP3_0; + VmathVector3 tmpV3_10, tmpV3_11, tmpV3_12, tmpV3_13, tmpV3_14, tmpV3_15, tmpV3_16, tmpV3_17, tmpV3_18, tmpV3_19, tmpV3_20, tmpV3_21, tmpV3_22, tmpV3_23, tmpV3_24, tmpV3_25; + float rndflt1, rndflt2, rndflt3, rndflt4, pad; + float xyz4[12] __attribute__ ((aligned(16))); +#ifndef _VECTORMATH_SCALAR_TEST + vec_float4 quad; +#endif + xyz4[0] = randfloat(); + xyz4[1] = randfloat(); + xyz4[2] = randfloat(); + xyz4[3] = randfloat(); + xyz4[4] = randfloat(); + xyz4[5] = randfloat(); + xyz4[6] = randfloat(); + xyz4[7] = randfloat(); + xyz4[8] = randfloat(); + xyz4[9] = randfloat(); + xyz4[10] = randfloat(); + xyz4[11] = randfloat(); + // set a pad value to detect invalid use of padding. + // this will be nan for scalar/ppu implementations, max. float for spu + union { float f; unsigned int u; } tmp; + tmp.u = 0x7fffffff; + pad = tmp.f; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &b_Vector3, rndflt1, rndflt2, rndflt3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad ); + vmathV4GetXYZ( &a_Vector3, &tmpV4 ); + vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad ); + vmathV4GetXYZ( &b_Vector3, &tmpV4 ); + vmathV3Prints( &a_Vector3, "set Vector3 with floats" ); + vmathV3Prints( &b_Vector3, "set Vector3 with floats" ); + vmathV3MakeFromScalar( &c_Vector3, 0.0f ); + vmathV3MakeFromScalar( &d_Vector3, 0.0f ); + vmathV3MakeFromScalar( &e_Vector3, 0.0f ); + vmathV3Prints( &c_Vector3, "set Vector3 elements to zero" ); + vmathV3Prints( &d_Vector3, "set Vector3 elements to zero" ); + vmathV3Prints( &e_Vector3, "set Vector3 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &b_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathV4Prints( &a_Vector4, "set Vector4 with floats" ); + vmathV4Prints( &b_Vector4, "set Vector4 with floats" ); + vmathV4MakeFromScalar( &c_Vector4, 0.0f ); + vmathV4MakeFromScalar( &d_Vector4, 0.0f ); + vmathV4MakeFromScalar( &e_Vector4, 0.0f ); + vmathV4Prints( &c_Vector4, "set Vector4 elements to zero" ); + vmathV4Prints( &d_Vector4, "set Vector4 elements to zero" ); + vmathV4Prints( &e_Vector4, "set Vector4 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &b_Point3, rndflt1, rndflt2, rndflt3 ); + vmathV3MakeFromP3( &tmpV3_0, &a_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad ); + vmathV4GetXYZ( &tmpV3_1, &tmpV4 ); + vmathP3MakeFromV3( &a_Point3, &tmpV3_1 ); + vmathV3MakeFromP3( &tmpV3_2, &b_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad ); + vmathV4GetXYZ( &tmpV3_3, &tmpV4 ); + vmathP3MakeFromV3( &b_Point3, &tmpV3_3 ); + vmathP3Prints( &a_Point3, "set Point3 with floats" ); + vmathP3Prints( &b_Point3, "set Point3 with floats" ); + vmathP3MakeFromScalar( &c_Point3, 0.0f ); + vmathP3MakeFromScalar( &d_Point3, 0.0f ); + vmathP3MakeFromScalar( &e_Point3, 0.0f ); + vmathP3Prints( &c_Point3, "set Point3 elements to zero" ); + vmathP3Prints( &d_Point3, "set Point3 elements to zero" ); + vmathP3Prints( &e_Point3, "set Point3 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &b_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathQPrints( &a_Quat, "set Quat with floats" ); + vmathQPrints( &b_Quat, "set Quat with floats" ); + vmathQMakeFromScalar( &c_Quat, 0.0f ); + vmathQMakeFromScalar( &d_Quat, 0.0f ); + vmathQMakeFromScalar( &e_Quat, 0.0f ); + vmathQPrints( &c_Quat, "set Quat elements to zero" ); + vmathQPrints( &d_Quat, "set Quat elements to zero" ); + vmathQPrints( &e_Quat, "set Quat elements to zero" ); + vmathV3MakeFromP3( &a_Vector3, &a_Point3 ); + vmathV3Prints( &a_Vector3, "construct Vector3 with Point3" ); + vmathV3MakeFromScalar( &a_Vector3, randfloat() ); + vmathV3Prints( &a_Vector3, "set Vector3 with float" ); + vmathV3MakeFromScalar( &a_Vector3, randfloat() ); + vmathV3Prints( &a_Vector3, "set Vector3 with float" ); + vmathV3MakeFromElems( &aos_Vector3_0, 0.0f, 1.0f, 2.0f ); + vmathV3MakeFromElems( &aos_Vector3_1, 3.0f, 4.0f, 5.0f ); + vmathV3MakeFromElems( &aos_Vector3_2, 6.0f, 7.0f, 8.0f ); + vmathV3MakeFromElems( &aos_Vector3_3, 9.0f, 10.0f, 11.0f ); + vmathV3Prints( &aos_Vector3_3, "aos type 0" ); + vmathV3Prints( &aos_Vector3_2, "aos type 1" ); + vmathV3Prints( &aos_Vector3_1, "aos type 2" ); + vmathV3Prints( &aos_Vector3_0, "aos type 3" ); + vmathV3Select( &tmpV3_4, &a_Vector3, &b_Vector3, 0 ); + vmathV3Prints( &tmpV3_4, "select 0" ); + vmathV3Select( &tmpV3_5, &a_Vector3, &b_Vector3, 1 ); + vmathV3Prints( &tmpV3_5, "select 1" ); + vmathV3Select( &tmpV3_6, &a_Vector3, &b_Vector3, 0 ); + vmathV3Prints( &tmpV3_6, "select 2" ); + vmathV3Select( &tmpV3_7, &a_Vector3, &b_Vector3, (unsigned int)-1 ); + vmathV3Prints( &tmpV3_7, "select 3" ); + vmathV3MakeFromElems( &a_Vector3, xyz4[0], xyz4[1], xyz4[2] ); + vmathV3Prints( &a_Vector3, "load XYZ array" ); + xyz4[0] = -xyz4[0]; + xyz4[1] = -xyz4[1]; + xyz4[2] = -xyz4[2]; + xyz4[3] = -xyz4[3]; + xyz4[4] = -xyz4[4]; + xyz4[5] = -xyz4[5]; + xyz4[6] = -xyz4[6]; + xyz4[7] = -xyz4[7]; + xyz4[8] = -xyz4[8]; + xyz4[9] = -xyz4[9]; + xyz4[10] = -xyz4[10]; + xyz4[11] = -xyz4[11]; + vmathV4MakeFromElems( &aos_Vector4_0, xyz4[0], xyz4[1], xyz4[2], xyz4[3] ); + vmathV4MakeFromElems( &aos_Vector4_1, xyz4[4], xyz4[5], xyz4[6], xyz4[7] ); + vmathV4MakeFromElems( &aos_Vector4_2, xyz4[8], xyz4[9], xyz4[10], xyz4[11] ); + vmathV4Prints( &aos_Vector4_0, "xyzx" ); + vmathV4Prints( &aos_Vector4_1, "yzxy" ); + vmathV4Prints( &aos_Vector4_2, "zxyz" ); +#ifndef _VECTORMATH_SCALAR_TEST + vmathV3LoadXYZArray( &aos_Vector3_0, &aos_Vector3_1, &aos_Vector3_2, &aos_Vector3_3, (const vec_float4 *)xyz4 ); + xyz4[0] = 0; + xyz4[1] = 1; + xyz4[2] = 2; + xyz4[3] = 3; + xyz4[4] = 4; + xyz4[5] = 5; + xyz4[6] = 6; + xyz4[7] = 7; + xyz4[8] = 8; + xyz4[9] = 9; + xyz4[10] = 10; + xyz4[11] = 11; + vmathV3StoreXYZArray( &aos_Vector3_0, &aos_Vector3_1, &aos_Vector3_2, &aos_Vector3_3, (vec_float4 *)xyz4 ); +#endif + vmathV4MakeFromElems( &aos_Vector4_0, xyz4[0], xyz4[1], xyz4[2], xyz4[3] ); + vmathV4MakeFromElems( &aos_Vector4_1, xyz4[4], xyz4[5], xyz4[6], xyz4[7] ); + vmathV4MakeFromElems( &aos_Vector4_2, xyz4[8], xyz4[9], xyz4[10], xyz4[11] ); + vmathV4Prints( &aos_Vector4_0, "xyzx" ); + vmathV4Prints( &aos_Vector4_1, "yzxy" ); + vmathV4Prints( &aos_Vector4_2, "zxyz" ); +#ifdef _VECTORMATH_SCALAR_TEST + printf("storeXYZ:-1.0 -2.0 -3.0 0.4\n"); +#else + quad = (vec_float4){-1.0f, -2.0f, -3.0f, -4.0f}; + a_Vector3.vec128 = quad; + quad = (vec_float4){0.1f, 0.2f, 0.3f, 0.4f}; + vmathV3StoreXYZ( &a_Vector3, &quad ); + printf("storeXYZ:%f %f %f %f\n", ((float *)&quad)[0], ((float *)&quad)[1], ((float *)&quad)[2], ((float *)&quad)[3]); +#endif + vmathV3Copy( &a_Vector3, &b_Vector3 ); + vmathV3Prints( &a_Vector3, "assign to Vector3 from Vector3" ); + vmathV3MakeFromScalar( &a_Vector3, 0.0f ); + vmathV3Prints( &a_Vector3, "set Vector3 elements to zero" ); + vmathV3MakeXAxis( &a_Vector3 ); + vmathV3Prints( &a_Vector3, "set to x axis" ); + vmathV3MakeYAxis( &a_Vector3 ); + vmathV3Prints( &a_Vector3, "set to y axis" ); + vmathV3MakeZAxis( &a_Vector3 ); + vmathV3Prints( &a_Vector3, "set to z axis" ); + vmathV3SetElem( &a_Vector3, 0, randfloat() ); + vmathV3Prints( &a_Vector3, "Vector3::set( 0, float )" ); + vmathV3SetElem( &a_Vector3, 0, randfloat() ); + vmathV3SetElem( &a_Vector3, 0, ( vmathV3GetElem( &a_Vector3, 0 ) * randfloat() ) ); + vmathV3SetElem( &a_Vector3, 0, ( vmathV3GetElem( &a_Vector3, 0 ) / randfloat() ) ); + vmathV3SetElem( &a_Vector3, 0, ( vmathV3GetElem( &a_Vector3, 0 ) + randfloat() ) ); + vmathV3SetElem( &a_Vector3, 0, ( vmathV3GetElem( &a_Vector3, 0 ) - randfloat() ) ); + vmathV3Prints( &a_Vector3, "Vector3::operator [](0)" ); + vmathV3SetX( &a_Vector3, randfloat() ); + vmathV3Prints( &a_Vector3, "Vector3::setX()" ); + vmathV3SetElem( &a_Vector3, 1, randfloat() ); + vmathV3Prints( &a_Vector3, "Vector3::set( 1, float )" ); + vmathV3SetElem( &a_Vector3, 1, randfloat() ); + vmathV3SetElem( &a_Vector3, 1, ( vmathV3GetElem( &a_Vector3, 1 ) * randfloat() ) ); + vmathV3SetElem( &a_Vector3, 1, ( vmathV3GetElem( &a_Vector3, 1 ) / randfloat() ) ); + vmathV3SetElem( &a_Vector3, 1, ( vmathV3GetElem( &a_Vector3, 1 ) + randfloat() ) ); + vmathV3SetElem( &a_Vector3, 1, ( vmathV3GetElem( &a_Vector3, 1 ) - randfloat() ) ); + vmathV3Prints( &a_Vector3, "Vector3::operator [](1)" ); + vmathV3SetY( &a_Vector3, randfloat() ); + vmathV3Prints( &a_Vector3, "Vector3::setY()" ); + vmathV3SetElem( &a_Vector3, 2, randfloat() ); + vmathV3Prints( &a_Vector3, "Vector3::set( 2, float )" ); + vmathV3SetElem( &a_Vector3, 2, randfloat() ); + vmathV3SetElem( &a_Vector3, 2, ( vmathV3GetElem( &a_Vector3, 2 ) * randfloat() ) ); + vmathV3SetElem( &a_Vector3, 2, ( vmathV3GetElem( &a_Vector3, 2 ) / randfloat() ) ); + vmathV3SetElem( &a_Vector3, 2, ( vmathV3GetElem( &a_Vector3, 2 ) + randfloat() ) ); + vmathV3SetElem( &a_Vector3, 2, ( vmathV3GetElem( &a_Vector3, 2 ) - randfloat() ) ); + vmathV3Prints( &a_Vector3, "Vector3::operator [](2)" ); + vmathV3SetZ( &a_Vector3, randfloat() ); + vmathV3Prints( &a_Vector3, "Vector3::setZ()" ); + printf("Vector3::get( 0 ): %f\n", getfloat(vmathV3GetElem( &a_Vector3, 0 )) ); + printf("Vector3::operator []( 0 ): %f\n", getfloat(vmathV3GetElem( &a_Vector3, 0 )) ); + printf("Vector3::getX(): %f\n", getfloat(vmathV3GetX( &a_Vector3 )) ); + printf("Vector3::get( 1 ): %f\n", getfloat(vmathV3GetElem( &a_Vector3, 1 )) ); + printf("Vector3::operator []( 1 ): %f\n", getfloat(vmathV3GetElem( &a_Vector3, 1 )) ); + printf("Vector3::getY(): %f\n", getfloat(vmathV3GetY( &a_Vector3 )) ); + printf("Vector3::get( 2 ): %f\n", getfloat(vmathV3GetElem( &a_Vector3, 2 )) ); + printf("Vector3::operator []( 2 ): %f\n", getfloat(vmathV3GetElem( &a_Vector3, 2 )) ); + printf("Vector3::getZ(): %f\n", getfloat(vmathV3GetZ( &a_Vector3 )) ); + vmathV3Add( &tmpV3_8, &a_Vector3, &b_Vector3 ); + vmathV3Prints( &tmpV3_8, "Vector3 + Vector3" ); + vmathV3Sub( &tmpV3_9, &a_Vector3, &b_Vector3 ); + vmathV3Prints( &tmpV3_9, "Vector3 - Vector3" ); + vmathV3AddP3( &tmpP3_0, &a_Vector3, &b_Point3 ); + vmathP3Prints( &tmpP3_0, "Vector3 + Point3" ); + vmathV3ScalarMul( &tmpV3_10, &a_Vector3, randfloat() ); + vmathV3Prints( &tmpV3_10, "Vector3 * float" ); + vmathV3ScalarDiv( &tmpV3_11, &a_Vector3, randfloat() ); + vmathV3Prints( &tmpV3_11, "Vector3 / float" ); + vmathV3ScalarMul( &tmpV3_12, &a_Vector3, randfloat() ); + vmathV3Prints( &tmpV3_12, "float * Vector3" ); + vmathV3Neg( &tmpV3_13, &a_Vector3 ); + vmathV3Prints( &tmpV3_13, "Vector3 negate" ); + vmathV3MulPerElem( &tmpV3_14, &a_Vector3, &b_Vector3 ); + vmathV3Prints( &tmpV3_14, "mulPerElem( Vector3, Vector3 )" ); + vmathV3DivPerElem( &tmpV3_15, &a_Vector3, &b_Vector3 ); + vmathV3Prints( &tmpV3_15, "divPerElem( Vector3, Vector3 )" ); + vmathV3RecipPerElem( &tmpV3_16, &a_Vector3 ); + vmathV3Prints( &tmpV3_16, "Vector3 recip" ); + vmathV3AbsPerElem( &tmpV3_17, &a_Vector3 ); + vmathV3SqrtPerElem( &tmpV3_18, &tmpV3_17 ); + vmathV3Prints( &tmpV3_18, "Vector3 sqrt" ); + vmathV3AbsPerElem( &tmpV3_19, &a_Vector3 ); + vmathV3RsqrtPerElem( &tmpV3_20, &tmpV3_19 ); + vmathV3Prints( &tmpV3_20, "Vector3 rsqrt" ); + vmathV3AbsPerElem( &tmpV3_21, &a_Vector3 ); + vmathV3Prints( &tmpV3_21, "Vector3 abs" ); + vmathV3CopySignPerElem( &tmpV3_22, &a_Vector3, &b_Vector3 ); + vmathV3Prints( &tmpV3_22, "Vector3 copySign" ); + vmathV3MaxPerElem( &tmpV3_23, &a_Vector3, &b_Vector3 ); + vmathV3Prints( &tmpV3_23, "Vector3 maximum Vector3" ); + vmathV3MinPerElem( &tmpV3_24, &a_Vector3, &b_Vector3 ); + vmathV3Prints( &tmpV3_24, "Vector3 minimum Vector3" ); + printf("Vector3 maximum of elements: %f\n", getfloat(vmathV3MaxElem( &a_Vector3 ))); + printf("Vector3 minimum of elements: %f\n", getfloat(vmathV3MinElem( &a_Vector3 ))); + printf("Vector3 sum of elements: %f\n", getfloat(vmathV3Sum( &a_Vector3 ))); + printf("Vector3 dot Vector3: %f\n", getfloat(vmathV3Dot( &a_Vector3, &b_Vector3 ))); + printf("Vector3 lengthSqr: %f\n", getfloat(vmathV3LengthSqr( &a_Vector3 ))); + printf("Vector3 length: %f\n", getfloat(vmathV3Length( &a_Vector3 ))); + vmathV3Normalize( &tmpV3_25, &a_Vector3 ); + vmathV3Prints( &tmpV3_25, "Vector3 normalized" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &b_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &e_Vector3, rndflt1, rndflt2, rndflt3 ); + vmathV3Normalize( &b_Vector3, &b_Vector3 ); + vmathV3Normalize( &c_Vector3, &c_Vector3 ); + vmathV3Normalize( &d_Vector3, &d_Vector3 ); + vmathV3Normalize( &e_Vector3, &e_Vector3 ); + vmathV3Lerp( &a_Vector3, randfloat(), &b_Vector3, &c_Vector3 ); + vmathV3Prints( &a_Vector3, "Vector3 lerp" ); + vmathV3Slerp( &a_Vector3, randfloat(), &b_Vector3, &c_Vector3 ); + vmathV3Prints( &a_Vector3, "Vector3 slerp" ); +} + +void +Vector4_methods_test() +{ + VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3, e_Vector3; + VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4, e_Vector4; + VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3, e_Point3; + VmathQuat a_Quat, b_Quat, c_Quat, d_Quat, e_Quat; + VmathVector4 tmpV4; + VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3; + VmathVector4 aos_Vector4_0, aos_Vector4_1, aos_Vector4_2, aos_Vector4_3, tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3; + VmathVector3 tmpV3_4; + VmathVector4 tmpV4_4, tmpV4_5, tmpV4_6, tmpV4_7, tmpV4_8, tmpV4_9, tmpV4_10, tmpV4_11, tmpV4_12, tmpV4_13, tmpV4_14, tmpV4_15, tmpV4_16, tmpV4_17, tmpV4_18, tmpV4_19, tmpV4_20, tmpV4_21; + float rndflt1, rndflt2, rndflt3, rndflt4, pad; + // set a pad value to detect invalid use of padding. + // this will be nan for scalar/ppu implementations, max. float for spu + union { float f; unsigned int u; } tmp; + tmp.u = 0x7fffffff; + pad = tmp.f; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &b_Vector3, rndflt1, rndflt2, rndflt3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad ); + vmathV4GetXYZ( &a_Vector3, &tmpV4 ); + vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad ); + vmathV4GetXYZ( &b_Vector3, &tmpV4 ); + vmathV3Prints( &a_Vector3, "set Vector3 with floats" ); + vmathV3Prints( &b_Vector3, "set Vector3 with floats" ); + vmathV3MakeFromScalar( &c_Vector3, 0.0f ); + vmathV3MakeFromScalar( &d_Vector3, 0.0f ); + vmathV3MakeFromScalar( &e_Vector3, 0.0f ); + vmathV3Prints( &c_Vector3, "set Vector3 elements to zero" ); + vmathV3Prints( &d_Vector3, "set Vector3 elements to zero" ); + vmathV3Prints( &e_Vector3, "set Vector3 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &b_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathV4Prints( &a_Vector4, "set Vector4 with floats" ); + vmathV4Prints( &b_Vector4, "set Vector4 with floats" ); + vmathV4MakeFromScalar( &c_Vector4, 0.0f ); + vmathV4MakeFromScalar( &d_Vector4, 0.0f ); + vmathV4MakeFromScalar( &e_Vector4, 0.0f ); + vmathV4Prints( &c_Vector4, "set Vector4 elements to zero" ); + vmathV4Prints( &d_Vector4, "set Vector4 elements to zero" ); + vmathV4Prints( &e_Vector4, "set Vector4 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &b_Point3, rndflt1, rndflt2, rndflt3 ); + vmathV3MakeFromP3( &tmpV3_0, &a_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad ); + vmathV4GetXYZ( &tmpV3_1, &tmpV4 ); + vmathP3MakeFromV3( &a_Point3, &tmpV3_1 ); + vmathV3MakeFromP3( &tmpV3_2, &b_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad ); + vmathV4GetXYZ( &tmpV3_3, &tmpV4 ); + vmathP3MakeFromV3( &b_Point3, &tmpV3_3 ); + vmathP3Prints( &a_Point3, "set Point3 with floats" ); + vmathP3Prints( &b_Point3, "set Point3 with floats" ); + vmathP3MakeFromScalar( &c_Point3, 0.0f ); + vmathP3MakeFromScalar( &d_Point3, 0.0f ); + vmathP3MakeFromScalar( &e_Point3, 0.0f ); + vmathP3Prints( &c_Point3, "set Point3 elements to zero" ); + vmathP3Prints( &d_Point3, "set Point3 elements to zero" ); + vmathP3Prints( &e_Point3, "set Point3 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &b_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathQPrints( &a_Quat, "set Quat with floats" ); + vmathQPrints( &b_Quat, "set Quat with floats" ); + vmathQMakeFromScalar( &c_Quat, 0.0f ); + vmathQMakeFromScalar( &d_Quat, 0.0f ); + vmathQMakeFromScalar( &e_Quat, 0.0f ); + vmathQPrints( &c_Quat, "set Quat elements to zero" ); + vmathQPrints( &d_Quat, "set Quat elements to zero" ); + vmathQPrints( &e_Quat, "set Quat elements to zero" ); + vmathV4MakeFromV3Scalar( &a_Vector4, &a_Vector3, randfloat() ); + vmathV4Prints( &a_Vector4, "set Vector4 with Vector3, float" ); + vmathV4MakeFromV3( &a_Vector4, &a_Vector3 ); + vmathV4Prints( &a_Vector4, "set Vector4 with Vector3" ); + vmathV4MakeFromP3( &a_Vector4, &a_Point3 ); + vmathV4Prints( &a_Vector4, "set Vector4 with Point3" ); + vmathV4MakeFromQ( &a_Vector4, &a_Quat ); + vmathV4Prints( &a_Vector4, "construct Vector4 with Quat" ); + vmathV4MakeFromScalar( &a_Vector4, randfloat() ); + vmathV4Prints( &a_Vector4, "set Vector4 with float" ); + vmathV4MakeFromScalar( &a_Vector4, randfloat() ); + vmathV4Prints( &a_Vector4, "set Vector4 with float" ); + vmathV4MakeFromElems( &aos_Vector4_0, 0.0f, 1.0f, 2.0f, 3.0f ); + vmathV4MakeFromElems( &aos_Vector4_1, 4.0f, 5.0f, 6.0f, 7.0f ); + vmathV4MakeFromElems( &aos_Vector4_2, 8.0f, 9.0f, 10.0f, 11.0f ); + vmathV4MakeFromElems( &aos_Vector4_3, 12.0f, 13.0f, 14.0f, 15.0f ); + vmathV4Prints( &aos_Vector4_3, "aos type 0" ); + vmathV4Prints( &aos_Vector4_2, "aos type 1" ); + vmathV4Prints( &aos_Vector4_1, "aos type 2" ); + vmathV4Prints( &aos_Vector4_0, "aos type 3" ); + vmathV4Select( &tmpV4_0, &a_Vector4, &b_Vector4, 0 ); + vmathV4Prints( &tmpV4_0, "select 0" ); + vmathV4Select( &tmpV4_1, &a_Vector4, &b_Vector4, 1 ); + vmathV4Prints( &tmpV4_1, "select 1" ); + vmathV4Select( &tmpV4_2, &a_Vector4, &b_Vector4, 0 ); + vmathV4Prints( &tmpV4_2, "select 2" ); + vmathV4Select( &tmpV4_3, &a_Vector4, &b_Vector4, (unsigned int)-1 ); + vmathV4Prints( &tmpV4_3, "select 3" ); + vmathV4Copy( &a_Vector4, &b_Vector4 ); + vmathV4Prints( &a_Vector4, "assign to Vector4 from Vector4" ); + vmathV4SetXYZ( &a_Vector4, &a_Vector3 ); + vmathV4Prints( &a_Vector4, "set Vector4 xyz" ); + vmathV4GetXYZ( &tmpV3_4, &a_Vector4 ); + vmathV3Prints( &tmpV3_4, "get Vector4 xyz" ); + vmathV4MakeFromScalar( &a_Vector4, 0.0f ); + vmathV4Prints( &a_Vector4, "set Vector4 elements to zero" ); + vmathV4MakeXAxis( &a_Vector4 ); + vmathV4Prints( &a_Vector4, "set to x axis" ); + vmathV4MakeYAxis( &a_Vector4 ); + vmathV4Prints( &a_Vector4, "set to y axis" ); + vmathV4MakeZAxis( &a_Vector4 ); + vmathV4Prints( &a_Vector4, "set to z axis" ); + vmathV4MakeWAxis( &a_Vector4 ); + vmathV4Prints( &a_Vector4, "set to w axis" ); + vmathV4SetElem( &a_Vector4, 0, randfloat() ); + vmathV4Prints( &a_Vector4, "Vector4::set( 0, float )" ); + vmathV4SetElem( &a_Vector4, 0, randfloat() ); + vmathV4SetElem( &a_Vector4, 0, ( vmathV4GetElem( &a_Vector4, 0 ) * randfloat() ) ); + vmathV4SetElem( &a_Vector4, 0, ( vmathV4GetElem( &a_Vector4, 0 ) / randfloat() ) ); + vmathV4SetElem( &a_Vector4, 0, ( vmathV4GetElem( &a_Vector4, 0 ) + randfloat() ) ); + vmathV4SetElem( &a_Vector4, 0, ( vmathV4GetElem( &a_Vector4, 0 ) - randfloat() ) ); + vmathV4Prints( &a_Vector4, "Vector4::operator [](0)" ); + vmathV4SetX( &a_Vector4, randfloat() ); + vmathV4Prints( &a_Vector4, "Vector4::setX()" ); + vmathV4SetElem( &a_Vector4, 1, randfloat() ); + vmathV4Prints( &a_Vector4, "Vector4::set( 1, float )" ); + vmathV4SetElem( &a_Vector4, 1, randfloat() ); + vmathV4SetElem( &a_Vector4, 1, ( vmathV4GetElem( &a_Vector4, 1 ) * randfloat() ) ); + vmathV4SetElem( &a_Vector4, 1, ( vmathV4GetElem( &a_Vector4, 1 ) / randfloat() ) ); + vmathV4SetElem( &a_Vector4, 1, ( vmathV4GetElem( &a_Vector4, 1 ) + randfloat() ) ); + vmathV4SetElem( &a_Vector4, 1, ( vmathV4GetElem( &a_Vector4, 1 ) - randfloat() ) ); + vmathV4Prints( &a_Vector4, "Vector4::operator [](1)" ); + vmathV4SetY( &a_Vector4, randfloat() ); + vmathV4Prints( &a_Vector4, "Vector4::setY()" ); + vmathV4SetElem( &a_Vector4, 2, randfloat() ); + vmathV4Prints( &a_Vector4, "Vector4::set( 2, float )" ); + vmathV4SetElem( &a_Vector4, 2, randfloat() ); + vmathV4SetElem( &a_Vector4, 2, ( vmathV4GetElem( &a_Vector4, 2 ) * randfloat() ) ); + vmathV4SetElem( &a_Vector4, 2, ( vmathV4GetElem( &a_Vector4, 2 ) / randfloat() ) ); + vmathV4SetElem( &a_Vector4, 2, ( vmathV4GetElem( &a_Vector4, 2 ) + randfloat() ) ); + vmathV4SetElem( &a_Vector4, 2, ( vmathV4GetElem( &a_Vector4, 2 ) - randfloat() ) ); + vmathV4Prints( &a_Vector4, "Vector4::operator [](2)" ); + vmathV4SetZ( &a_Vector4, randfloat() ); + vmathV4Prints( &a_Vector4, "Vector4::setZ()" ); + vmathV4SetElem( &a_Vector4, 3, randfloat() ); + vmathV4Prints( &a_Vector4, "Vector4::set( 3, float )" ); + vmathV4SetElem( &a_Vector4, 3, randfloat() ); + vmathV4SetElem( &a_Vector4, 3, ( vmathV4GetElem( &a_Vector4, 3 ) * randfloat() ) ); + vmathV4SetElem( &a_Vector4, 3, ( vmathV4GetElem( &a_Vector4, 3 ) / randfloat() ) ); + vmathV4SetElem( &a_Vector4, 3, ( vmathV4GetElem( &a_Vector4, 3 ) + randfloat() ) ); + vmathV4SetElem( &a_Vector4, 3, ( vmathV4GetElem( &a_Vector4, 3 ) - randfloat() ) ); + vmathV4Prints( &a_Vector4, "Vector4::operator [](3)" ); + vmathV4SetW( &a_Vector4, randfloat() ); + vmathV4Prints( &a_Vector4, "Vector4::setW()" ); + printf("Vector4::get( 0 ): %f\n", getfloat(vmathV4GetElem( &a_Vector4, 0 )) ); + printf("Vector4::operator []( 0 ): %f\n", getfloat(vmathV4GetElem( &a_Vector4, 0 )) ); + printf("Vector4::getX(): %f\n", getfloat(vmathV4GetX( &a_Vector4 )) ); + printf("Vector4::get( 1 ): %f\n", getfloat(vmathV4GetElem( &a_Vector4, 1 )) ); + printf("Vector4::operator []( 1 ): %f\n", getfloat(vmathV4GetElem( &a_Vector4, 1 )) ); + printf("Vector4::getY(): %f\n", getfloat(vmathV4GetY( &a_Vector4 )) ); + printf("Vector4::get( 2 ): %f\n", getfloat(vmathV4GetElem( &a_Vector4, 2 )) ); + printf("Vector4::operator []( 2 ): %f\n", getfloat(vmathV4GetElem( &a_Vector4, 2 )) ); + printf("Vector4::getZ(): %f\n", getfloat(vmathV4GetZ( &a_Vector4 )) ); + printf("Vector4::get( 3 ): %f\n", getfloat(vmathV4GetElem( &a_Vector4, 3 )) ); + printf("Vector4::operator []( 3 ): %f\n", getfloat(vmathV4GetElem( &a_Vector4, 3 )) ); + printf("Vector4::getW(): %f\n", getfloat(vmathV4GetW( &a_Vector4 )) ); + vmathV4Add( &tmpV4_4, &a_Vector4, &b_Vector4 ); + vmathV4Prints( &tmpV4_4, "Vector4 + Vector4" ); + vmathV4Sub( &tmpV4_5, &a_Vector4, &b_Vector4 ); + vmathV4Prints( &tmpV4_5, "Vector4 - Vector4" ); + vmathV4ScalarMul( &tmpV4_6, &a_Vector4, randfloat() ); + vmathV4Prints( &tmpV4_6, "Vector4 * float" ); + vmathV4ScalarDiv( &tmpV4_7, &a_Vector4, randfloat() ); + vmathV4Prints( &tmpV4_7, "Vector4 / float" ); + vmathV4ScalarMul( &tmpV4_8, &a_Vector4, randfloat() ); + vmathV4Prints( &tmpV4_8, "float * Vector4" ); + vmathV4Neg( &tmpV4_9, &a_Vector4 ); + vmathV4Prints( &tmpV4_9, "Vector4 negate" ); + vmathV4MulPerElem( &tmpV4_10, &a_Vector4, &b_Vector4 ); + vmathV4Prints( &tmpV4_10, "mulPerElem( Vector4, Vector4 )" ); + vmathV4DivPerElem( &tmpV4_11, &a_Vector4, &b_Vector4 ); + vmathV4Prints( &tmpV4_11, "divPerElem( Vector4, Vector4 )" ); + vmathV4RecipPerElem( &tmpV4_12, &a_Vector4 ); + vmathV4Prints( &tmpV4_12, "Vector4 recip" ); + vmathV4AbsPerElem( &tmpV4_13, &a_Vector4 ); + vmathV4SqrtPerElem( &tmpV4_14, &tmpV4_13 ); + vmathV4Prints( &tmpV4_14, "Vector4 sqrt" ); + vmathV4AbsPerElem( &tmpV4_15, &a_Vector4 ); + vmathV4RsqrtPerElem( &tmpV4_16, &tmpV4_15 ); + vmathV4Prints( &tmpV4_16, "Vector4 rsqrt" ); + vmathV4AbsPerElem( &tmpV4_17, &a_Vector4 ); + vmathV4Prints( &tmpV4_17, "Vector4 abs" ); + vmathV4CopySignPerElem( &tmpV4_18, &a_Vector4, &b_Vector4 ); + vmathV4Prints( &tmpV4_18, "Vector4 copySign" ); + vmathV4MaxPerElem( &tmpV4_19, &a_Vector4, &b_Vector4 ); + vmathV4Prints( &tmpV4_19, "Vector4 maximum Vector4" ); + vmathV4MinPerElem( &tmpV4_20, &a_Vector4, &b_Vector4 ); + vmathV4Prints( &tmpV4_20, "Vector4 minimum Vector4" ); + printf("Vector4 maximum of elements: %f\n", getfloat(vmathV4MaxElem( &a_Vector4 ))); + printf("Vector4 minimum of elements: %f\n", getfloat(vmathV4MinElem( &a_Vector4 ))); + printf("Vector4 sum of elements: %f\n", getfloat(vmathV4Sum( &a_Vector4 ))); + printf("Vector4 dot Vector4: %f\n", getfloat(vmathV4Dot( &a_Vector4, &b_Vector4 ))); + printf("Vector4 lengthSqr: %f\n", getfloat(vmathV4LengthSqr( &a_Vector4 ))); + printf("Vector4 length: %f\n", getfloat(vmathV4Length( &a_Vector4 ))); + vmathV4Normalize( &tmpV4_21, &a_Vector4 ); + vmathV4Prints( &tmpV4_21, "Vector4 normalized" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &b_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &e_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathV4Normalize( &b_Vector4, &b_Vector4 ); + vmathV4Normalize( &c_Vector4, &c_Vector4 ); + vmathV4Normalize( &d_Vector4, &d_Vector4 ); + vmathV4Normalize( &e_Vector4, &e_Vector4 ); + vmathV4Lerp( &a_Vector4, randfloat(), &b_Vector4, &c_Vector4 ); + vmathV4Prints( &a_Vector4, "Vector4 lerp" ); + vmathV4Slerp( &a_Vector4, randfloat(), &b_Vector4, &c_Vector4 ); + vmathV4Prints( &a_Vector4, "Vector4 slerp" ); +} + +void +Point3_methods_test() +{ + VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3, e_Vector3; + VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4, e_Vector4; + VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3, e_Point3; + VmathQuat a_Quat, b_Quat, c_Quat, d_Quat, e_Quat; + VmathVector4 tmpV4; + VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3; + VmathPoint3 aos_Point3_0, aos_Point3_1, aos_Point3_2, aos_Point3_3, tmpP3_0, tmpP3_1, tmpP3_2, tmpP3_3; + VmathVector4 aos_Vector4_0, aos_Vector4_1, aos_Vector4_2; + VmathVector3 tmpV3_4; + VmathPoint3 tmpP3_4, tmpP3_5, tmpP3_6, tmpP3_7, tmpP3_8, tmpP3_9, tmpP3_10, tmpP3_11, tmpP3_12, tmpP3_13, tmpP3_14, tmpP3_15, tmpP3_16; + float rndflt1, rndflt2, rndflt3, rndflt4, pad; + float xyz4[12] __attribute__ ((aligned(16))); +#ifndef _VECTORMATH_SCALAR_TEST + vec_float4 quad; +#endif + xyz4[0] = randfloat(); + xyz4[1] = randfloat(); + xyz4[2] = randfloat(); + xyz4[3] = randfloat(); + xyz4[4] = randfloat(); + xyz4[5] = randfloat(); + xyz4[6] = randfloat(); + xyz4[7] = randfloat(); + xyz4[8] = randfloat(); + xyz4[9] = randfloat(); + xyz4[10] = randfloat(); + xyz4[11] = randfloat(); + // set a pad value to detect invalid use of padding. + // this will be nan for scalar/ppu implementations, max. float for spu + union { float f; unsigned int u; } tmp; + tmp.u = 0x7fffffff; + pad = tmp.f; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &b_Vector3, rndflt1, rndflt2, rndflt3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad ); + vmathV4GetXYZ( &a_Vector3, &tmpV4 ); + vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad ); + vmathV4GetXYZ( &b_Vector3, &tmpV4 ); + vmathV3Prints( &a_Vector3, "set Vector3 with floats" ); + vmathV3Prints( &b_Vector3, "set Vector3 with floats" ); + vmathV3MakeFromScalar( &c_Vector3, 0.0f ); + vmathV3MakeFromScalar( &d_Vector3, 0.0f ); + vmathV3MakeFromScalar( &e_Vector3, 0.0f ); + vmathV3Prints( &c_Vector3, "set Vector3 elements to zero" ); + vmathV3Prints( &d_Vector3, "set Vector3 elements to zero" ); + vmathV3Prints( &e_Vector3, "set Vector3 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &b_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathV4Prints( &a_Vector4, "set Vector4 with floats" ); + vmathV4Prints( &b_Vector4, "set Vector4 with floats" ); + vmathV4MakeFromScalar( &c_Vector4, 0.0f ); + vmathV4MakeFromScalar( &d_Vector4, 0.0f ); + vmathV4MakeFromScalar( &e_Vector4, 0.0f ); + vmathV4Prints( &c_Vector4, "set Vector4 elements to zero" ); + vmathV4Prints( &d_Vector4, "set Vector4 elements to zero" ); + vmathV4Prints( &e_Vector4, "set Vector4 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &b_Point3, rndflt1, rndflt2, rndflt3 ); + vmathV3MakeFromP3( &tmpV3_0, &a_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad ); + vmathV4GetXYZ( &tmpV3_1, &tmpV4 ); + vmathP3MakeFromV3( &a_Point3, &tmpV3_1 ); + vmathV3MakeFromP3( &tmpV3_2, &b_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad ); + vmathV4GetXYZ( &tmpV3_3, &tmpV4 ); + vmathP3MakeFromV3( &b_Point3, &tmpV3_3 ); + vmathP3Prints( &a_Point3, "set Point3 with floats" ); + vmathP3Prints( &b_Point3, "set Point3 with floats" ); + vmathP3MakeFromScalar( &c_Point3, 0.0f ); + vmathP3MakeFromScalar( &d_Point3, 0.0f ); + vmathP3MakeFromScalar( &e_Point3, 0.0f ); + vmathP3Prints( &c_Point3, "set Point3 elements to zero" ); + vmathP3Prints( &d_Point3, "set Point3 elements to zero" ); + vmathP3Prints( &e_Point3, "set Point3 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &b_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathQPrints( &a_Quat, "set Quat with floats" ); + vmathQPrints( &b_Quat, "set Quat with floats" ); + vmathQMakeFromScalar( &c_Quat, 0.0f ); + vmathQMakeFromScalar( &d_Quat, 0.0f ); + vmathQMakeFromScalar( &e_Quat, 0.0f ); + vmathQPrints( &c_Quat, "set Quat elements to zero" ); + vmathQPrints( &d_Quat, "set Quat elements to zero" ); + vmathQPrints( &e_Quat, "set Quat elements to zero" ); + vmathP3MakeFromV3( &a_Point3, &a_Vector3 ); + vmathP3Prints( &a_Point3, "construct Point3 with Vector3" ); + vmathP3MakeFromScalar( &a_Point3, randfloat() ); + vmathP3Prints( &a_Point3, "set Point3 with float" ); + vmathP3MakeFromScalar( &a_Point3, randfloat() ); + vmathP3Prints( &a_Point3, "set Point3 with float" ); + vmathP3MakeFromElems( &aos_Point3_0, 0.0f, 1.0f, 2.0f ); + vmathP3MakeFromElems( &aos_Point3_1, 3.0f, 4.0f, 5.0f ); + vmathP3MakeFromElems( &aos_Point3_2, 6.0f, 7.0f, 8.0f ); + vmathP3MakeFromElems( &aos_Point3_3, 9.0f, 10.0f, 11.0f ); + vmathP3Prints( &aos_Point3_3, "aos type 0" ); + vmathP3Prints( &aos_Point3_2, "aos type 1" ); + vmathP3Prints( &aos_Point3_1, "aos type 2" ); + vmathP3Prints( &aos_Point3_0, "aos type 3" ); + vmathP3Select( &tmpP3_0, &a_Point3, &b_Point3, 0 ); + vmathP3Prints( &tmpP3_0, "select 0" ); + vmathP3Select( &tmpP3_1, &a_Point3, &b_Point3, 1 ); + vmathP3Prints( &tmpP3_1, "select 1" ); + vmathP3Select( &tmpP3_2, &a_Point3, &b_Point3, 0 ); + vmathP3Prints( &tmpP3_2, "select 2" ); + vmathP3Select( &tmpP3_3, &a_Point3, &b_Point3, (unsigned int)-1 ); + vmathP3Prints( &tmpP3_3, "select 3" ); + vmathP3MakeFromElems( &a_Point3, xyz4[0], xyz4[1], xyz4[2] ); + vmathP3Prints( &a_Point3, "load XYZ array" ); + xyz4[0] = -xyz4[0]; + xyz4[1] = -xyz4[1]; + xyz4[2] = -xyz4[2]; + xyz4[3] = -xyz4[3]; + xyz4[4] = -xyz4[4]; + xyz4[5] = -xyz4[5]; + xyz4[6] = -xyz4[6]; + xyz4[7] = -xyz4[7]; + xyz4[8] = -xyz4[8]; + xyz4[9] = -xyz4[9]; + xyz4[10] = -xyz4[10]; + xyz4[11] = -xyz4[11]; + vmathV4MakeFromElems( &aos_Vector4_0, xyz4[0], xyz4[1], xyz4[2], xyz4[3] ); + vmathV4MakeFromElems( &aos_Vector4_1, xyz4[4], xyz4[5], xyz4[6], xyz4[7] ); + vmathV4MakeFromElems( &aos_Vector4_2, xyz4[8], xyz4[9], xyz4[10], xyz4[11] ); + vmathV4Prints( &aos_Vector4_0, "xyzx" ); + vmathV4Prints( &aos_Vector4_1, "yzxy" ); + vmathV4Prints( &aos_Vector4_2, "zxyz" ); +#ifndef _VECTORMATH_SCALAR_TEST + vmathP3LoadXYZArray( &aos_Point3_0, &aos_Point3_1, &aos_Point3_2, &aos_Point3_3, (const vec_float4 *)xyz4 ); + xyz4[0] = 0; + xyz4[1] = 1; + xyz4[2] = 2; + xyz4[3] = 3; + xyz4[4] = 4; + xyz4[5] = 5; + xyz4[6] = 6; + xyz4[7] = 7; + xyz4[8] = 8; + xyz4[9] = 9; + xyz4[10] = 10; + xyz4[11] = 11; + vmathP3StoreXYZArray( &aos_Point3_0, &aos_Point3_1, &aos_Point3_2, &aos_Point3_3, (vec_float4 *)xyz4 ); +#endif + vmathV4MakeFromElems( &aos_Vector4_0, xyz4[0], xyz4[1], xyz4[2], xyz4[3] ); + vmathV4MakeFromElems( &aos_Vector4_1, xyz4[4], xyz4[5], xyz4[6], xyz4[7] ); + vmathV4MakeFromElems( &aos_Vector4_2, xyz4[8], xyz4[9], xyz4[10], xyz4[11] ); + vmathV4Prints( &aos_Vector4_0, "xyzx" ); + vmathV4Prints( &aos_Vector4_1, "yzxy" ); + vmathV4Prints( &aos_Vector4_2, "zxyz" ); +#ifdef _VECTORMATH_SCALAR_TEST + printf("storeXYZ:-1.0 -2.0 -3.0 0.4\n"); +#else + quad = (vec_float4){-1.0f, -2.0f, -3.0f, -4.0f}; + a_Point3.vec128 = quad; + quad = (vec_float4){0.1f, 0.2f, 0.3f, 0.4f}; + vmathP3StoreXYZ( &a_Point3, &quad ); + printf("storeXYZ:%f %f %f %f\n", ((float *)&quad)[0], ((float *)&quad)[1], ((float *)&quad)[2], ((float *)&quad)[3]); +#endif + vmathP3Copy( &a_Point3, &b_Point3 ); + vmathP3Prints( &a_Point3, "assign to Point3 from Point3" ); + vmathP3MakeFromScalar( &a_Point3, 0.0f ); + vmathP3Prints( &a_Point3, "set Point3 elements to zero" ); + vmathP3SetElem( &a_Point3, 0, randfloat() ); + vmathP3Prints( &a_Point3, "Point3::set( 0, float )" ); + vmathP3SetElem( &a_Point3, 0, randfloat() ); + vmathP3SetElem( &a_Point3, 0, ( vmathP3GetElem( &a_Point3, 0 ) * randfloat() ) ); + vmathP3SetElem( &a_Point3, 0, ( vmathP3GetElem( &a_Point3, 0 ) / randfloat() ) ); + vmathP3SetElem( &a_Point3, 0, ( vmathP3GetElem( &a_Point3, 0 ) + randfloat() ) ); + vmathP3SetElem( &a_Point3, 0, ( vmathP3GetElem( &a_Point3, 0 ) - randfloat() ) ); + vmathP3Prints( &a_Point3, "Point3::operator [](0)" ); + vmathP3SetX( &a_Point3, randfloat() ); + vmathP3Prints( &a_Point3, "Point3::setX()" ); + vmathP3SetElem( &a_Point3, 1, randfloat() ); + vmathP3Prints( &a_Point3, "Point3::set( 1, float )" ); + vmathP3SetElem( &a_Point3, 1, randfloat() ); + vmathP3SetElem( &a_Point3, 1, ( vmathP3GetElem( &a_Point3, 1 ) * randfloat() ) ); + vmathP3SetElem( &a_Point3, 1, ( vmathP3GetElem( &a_Point3, 1 ) / randfloat() ) ); + vmathP3SetElem( &a_Point3, 1, ( vmathP3GetElem( &a_Point3, 1 ) + randfloat() ) ); + vmathP3SetElem( &a_Point3, 1, ( vmathP3GetElem( &a_Point3, 1 ) - randfloat() ) ); + vmathP3Prints( &a_Point3, "Point3::operator [](1)" ); + vmathP3SetY( &a_Point3, randfloat() ); + vmathP3Prints( &a_Point3, "Point3::setY()" ); + vmathP3SetElem( &a_Point3, 2, randfloat() ); + vmathP3Prints( &a_Point3, "Point3::set( 2, float )" ); + vmathP3SetElem( &a_Point3, 2, randfloat() ); + vmathP3SetElem( &a_Point3, 2, ( vmathP3GetElem( &a_Point3, 2 ) * randfloat() ) ); + vmathP3SetElem( &a_Point3, 2, ( vmathP3GetElem( &a_Point3, 2 ) / randfloat() ) ); + vmathP3SetElem( &a_Point3, 2, ( vmathP3GetElem( &a_Point3, 2 ) + randfloat() ) ); + vmathP3SetElem( &a_Point3, 2, ( vmathP3GetElem( &a_Point3, 2 ) - randfloat() ) ); + vmathP3Prints( &a_Point3, "Point3::operator [](2)" ); + vmathP3SetZ( &a_Point3, randfloat() ); + vmathP3Prints( &a_Point3, "Point3::setZ()" ); + printf("Point3::get( 0 ): %f\n", getfloat(vmathP3GetElem( &a_Point3, 0 )) ); + printf("Point3::operator []( 0 ): %f\n", getfloat(vmathP3GetElem( &a_Point3, 0 )) ); + printf("Point3::getX(): %f\n", getfloat(vmathP3GetX( &a_Point3 )) ); + printf("Point3::get( 1 ): %f\n", getfloat(vmathP3GetElem( &a_Point3, 1 )) ); + printf("Point3::operator []( 1 ): %f\n", getfloat(vmathP3GetElem( &a_Point3, 1 )) ); + printf("Point3::getY(): %f\n", getfloat(vmathP3GetY( &a_Point3 )) ); + printf("Point3::get( 2 ): %f\n", getfloat(vmathP3GetElem( &a_Point3, 2 )) ); + printf("Point3::operator []( 2 ): %f\n", getfloat(vmathP3GetElem( &a_Point3, 2 )) ); + printf("Point3::getZ(): %f\n", getfloat(vmathP3GetZ( &a_Point3 )) ); + vmathP3Sub( &tmpV3_4, &a_Point3, &b_Point3 ); + vmathV3Prints( &tmpV3_4, "Point3 - Point3" ); + vmathP3AddV3( &tmpP3_4, &a_Point3, &b_Vector3 ); + vmathP3Prints( &tmpP3_4, "Point3 + Vector3" ); + vmathP3SubV3( &tmpP3_5, &a_Point3, &b_Vector3 ); + vmathP3Prints( &tmpP3_5, "Point3 - Vector3" ); + vmathP3MulPerElem( &tmpP3_6, &a_Point3, &b_Point3 ); + vmathP3Prints( &tmpP3_6, "mulPerElem( Point3, Point3 )" ); + vmathP3DivPerElem( &tmpP3_7, &a_Point3, &b_Point3 ); + vmathP3Prints( &tmpP3_7, "divPerElem( Point3, Point3 )" ); + vmathP3RecipPerElem( &tmpP3_8, &a_Point3 ); + vmathP3Prints( &tmpP3_8, "Point3 recip" ); + vmathP3AbsPerElem( &tmpP3_9, &a_Point3 ); + vmathP3SqrtPerElem( &tmpP3_10, &tmpP3_9 ); + vmathP3Prints( &tmpP3_10, "Point3 sqrt" ); + vmathP3AbsPerElem( &tmpP3_11, &a_Point3 ); + vmathP3RsqrtPerElem( &tmpP3_12, &tmpP3_11 ); + vmathP3Prints( &tmpP3_12, "Point3 rsqrt" ); + vmathP3AbsPerElem( &tmpP3_13, &a_Point3 ); + vmathP3Prints( &tmpP3_13, "Point3 abs" ); + vmathP3CopySignPerElem( &tmpP3_14, &a_Point3, &b_Point3 ); + vmathP3Prints( &tmpP3_14, "Point3 copySign" ); + vmathP3MaxPerElem( &tmpP3_15, &a_Point3, &b_Point3 ); + vmathP3Prints( &tmpP3_15, "Point3 maximum Point3" ); + vmathP3MinPerElem( &tmpP3_16, &a_Point3, &b_Point3 ); + vmathP3Prints( &tmpP3_16, "Point3 minimum Point3" ); + printf("Point3 maximum of elements: %f\n", getfloat(vmathP3MaxElem( &a_Point3 ))); + printf("Point3 minimum of elements: %f\n", getfloat(vmathP3MinElem( &a_Point3 ))); + printf("Point3 sum of elements: %f\n", getfloat(vmathP3Sum( &a_Point3 ))); + printf("Point projection: %f\n", getfloat(vmathP3Projection( &a_Point3, &b_Vector3 ))); + printf("Point distSqrFromOrigin: %f\n", getfloat(vmathP3DistSqrFromOrigin( &a_Point3 )) ); + printf("Point distFromOrigin: %f\n", getfloat(vmathP3DistFromOrigin( &a_Point3 )) ); + printf("Point distSqr: %f\n", getfloat(vmathP3DistSqr( &a_Point3, &b_Point3 )) ); + printf("Point dist: %f\n", getfloat(vmathP3Dist( &a_Point3, &b_Point3 )) ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &b_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &e_Point3, rndflt1, rndflt2, rndflt3 ); + vmathP3Lerp( &a_Point3, randfloat(), &b_Point3, &c_Point3 ); + vmathP3Prints( &a_Point3, "Point3 lerp" ); +} + +void +Quat_methods_test() +{ + VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3, e_Vector3; + VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4, e_Vector4; + VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3, e_Point3; + VmathQuat a_Quat, b_Quat, c_Quat, d_Quat, e_Quat; + VmathVector4 tmpV4; + VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3; + VmathQuat aos_Quat_0, aos_Quat_1, aos_Quat_2, aos_Quat_3, tmpQ_0, tmpQ_1, tmpQ_2, tmpQ_3; + VmathVector3 tmpV3_4; + VmathQuat tmpQ_4, tmpQ_5, tmpQ_6, tmpQ_7, tmpQ_8, tmpQ_9, tmpQ_10, tmpQ_11; + VmathVector3 tmpV3_5; + VmathQuat tmpQ_12; + float rndflt1, rndflt2, rndflt3, rndflt4, pad; + // set a pad value to detect invalid use of padding. + // this will be nan for scalar/ppu implementations, max. float for spu + union { float f; unsigned int u; } tmp; + tmp.u = 0x7fffffff; + pad = tmp.f; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &b_Vector3, rndflt1, rndflt2, rndflt3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad ); + vmathV4GetXYZ( &a_Vector3, &tmpV4 ); + vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad ); + vmathV4GetXYZ( &b_Vector3, &tmpV4 ); + vmathV3Prints( &a_Vector3, "set Vector3 with floats" ); + vmathV3Prints( &b_Vector3, "set Vector3 with floats" ); + vmathV3MakeFromScalar( &c_Vector3, 0.0f ); + vmathV3MakeFromScalar( &d_Vector3, 0.0f ); + vmathV3MakeFromScalar( &e_Vector3, 0.0f ); + vmathV3Prints( &c_Vector3, "set Vector3 elements to zero" ); + vmathV3Prints( &d_Vector3, "set Vector3 elements to zero" ); + vmathV3Prints( &e_Vector3, "set Vector3 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &b_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathV4Prints( &a_Vector4, "set Vector4 with floats" ); + vmathV4Prints( &b_Vector4, "set Vector4 with floats" ); + vmathV4MakeFromScalar( &c_Vector4, 0.0f ); + vmathV4MakeFromScalar( &d_Vector4, 0.0f ); + vmathV4MakeFromScalar( &e_Vector4, 0.0f ); + vmathV4Prints( &c_Vector4, "set Vector4 elements to zero" ); + vmathV4Prints( &d_Vector4, "set Vector4 elements to zero" ); + vmathV4Prints( &e_Vector4, "set Vector4 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &b_Point3, rndflt1, rndflt2, rndflt3 ); + vmathV3MakeFromP3( &tmpV3_0, &a_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad ); + vmathV4GetXYZ( &tmpV3_1, &tmpV4 ); + vmathP3MakeFromV3( &a_Point3, &tmpV3_1 ); + vmathV3MakeFromP3( &tmpV3_2, &b_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad ); + vmathV4GetXYZ( &tmpV3_3, &tmpV4 ); + vmathP3MakeFromV3( &b_Point3, &tmpV3_3 ); + vmathP3Prints( &a_Point3, "set Point3 with floats" ); + vmathP3Prints( &b_Point3, "set Point3 with floats" ); + vmathP3MakeFromScalar( &c_Point3, 0.0f ); + vmathP3MakeFromScalar( &d_Point3, 0.0f ); + vmathP3MakeFromScalar( &e_Point3, 0.0f ); + vmathP3Prints( &c_Point3, "set Point3 elements to zero" ); + vmathP3Prints( &d_Point3, "set Point3 elements to zero" ); + vmathP3Prints( &e_Point3, "set Point3 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &b_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathQPrints( &a_Quat, "set Quat with floats" ); + vmathQPrints( &b_Quat, "set Quat with floats" ); + vmathQMakeFromScalar( &c_Quat, 0.0f ); + vmathQMakeFromScalar( &d_Quat, 0.0f ); + vmathQMakeFromScalar( &e_Quat, 0.0f ); + vmathQPrints( &c_Quat, "set Quat elements to zero" ); + vmathQPrints( &d_Quat, "set Quat elements to zero" ); + vmathQPrints( &e_Quat, "set Quat elements to zero" ); + vmathQMakeFromV3Scalar( &a_Quat, &a_Vector3, randfloat() ); + vmathQPrints( &a_Quat, "set Quat with Vector3, float" ); + vmathQMakeFromV4( &a_Quat, &a_Vector4 ); + vmathQPrints( &a_Quat, "construct Quat with Vector4" ); + vmathQMakeFromScalar( &a_Quat, randfloat() ); + vmathQPrints( &a_Quat, "set Quat with float" ); + vmathQMakeFromScalar( &a_Quat, randfloat() ); + vmathQPrints( &a_Quat, "set Quat with float" ); + vmathQMakeFromElems( &aos_Quat_0, 0.0f, 1.0f, 2.0f, 3.0f ); + vmathQMakeFromElems( &aos_Quat_1, 4.0f, 5.0f, 6.0f, 7.0f ); + vmathQMakeFromElems( &aos_Quat_2, 8.0f, 9.0f, 10.0f, 11.0f ); + vmathQMakeFromElems( &aos_Quat_3, 12.0f, 13.0f, 14.0f, 15.0f ); + vmathQPrints( &aos_Quat_3, "aos type 0" ); + vmathQPrints( &aos_Quat_2, "aos type 1" ); + vmathQPrints( &aos_Quat_1, "aos type 2" ); + vmathQPrints( &aos_Quat_0, "aos type 3" ); + vmathQSelect( &tmpQ_0, &a_Quat, &b_Quat, 0 ); + vmathQPrints( &tmpQ_0, "select 0" ); + vmathQSelect( &tmpQ_1, &a_Quat, &b_Quat, 1 ); + vmathQPrints( &tmpQ_1, "select 1" ); + vmathQSelect( &tmpQ_2, &a_Quat, &b_Quat, 0 ); + vmathQPrints( &tmpQ_2, "select 2" ); + vmathQSelect( &tmpQ_3, &a_Quat, &b_Quat, (unsigned int)-1 ); + vmathQPrints( &tmpQ_3, "select 3" ); + vmathQCopy( &a_Quat, &b_Quat ); + vmathQPrints( &a_Quat, "assign to Quat from Quat" ); + vmathQSetXYZ( &a_Quat, &a_Vector3 ); + vmathQPrints( &a_Quat, "set Quat xyz" ); + vmathQGetXYZ( &tmpV3_4, &a_Quat ); + vmathV3Prints( &tmpV3_4, "get Quat xyz" ); + vmathQMakeFromScalar( &a_Quat, 0.0f ); + vmathQPrints( &a_Quat, "set Quat elements to zero" ); + vmathQSetElem( &a_Quat, 0, randfloat() ); + vmathQPrints( &a_Quat, "Quat::set( 0, float )" ); + vmathQSetElem( &a_Quat, 0, randfloat() ); + vmathQSetElem( &a_Quat, 0, ( vmathQGetElem( &a_Quat, 0 ) * randfloat() ) ); + vmathQSetElem( &a_Quat, 0, ( vmathQGetElem( &a_Quat, 0 ) / randfloat() ) ); + vmathQSetElem( &a_Quat, 0, ( vmathQGetElem( &a_Quat, 0 ) + randfloat() ) ); + vmathQSetElem( &a_Quat, 0, ( vmathQGetElem( &a_Quat, 0 ) - randfloat() ) ); + vmathQPrints( &a_Quat, "Quat::operator [](0)" ); + vmathQSetX( &a_Quat, randfloat() ); + vmathQPrints( &a_Quat, "Quat::setX()" ); + vmathQSetElem( &a_Quat, 1, randfloat() ); + vmathQPrints( &a_Quat, "Quat::set( 1, float )" ); + vmathQSetElem( &a_Quat, 1, randfloat() ); + vmathQSetElem( &a_Quat, 1, ( vmathQGetElem( &a_Quat, 1 ) * randfloat() ) ); + vmathQSetElem( &a_Quat, 1, ( vmathQGetElem( &a_Quat, 1 ) / randfloat() ) ); + vmathQSetElem( &a_Quat, 1, ( vmathQGetElem( &a_Quat, 1 ) + randfloat() ) ); + vmathQSetElem( &a_Quat, 1, ( vmathQGetElem( &a_Quat, 1 ) - randfloat() ) ); + vmathQPrints( &a_Quat, "Quat::operator [](1)" ); + vmathQSetY( &a_Quat, randfloat() ); + vmathQPrints( &a_Quat, "Quat::setY()" ); + vmathQSetElem( &a_Quat, 2, randfloat() ); + vmathQPrints( &a_Quat, "Quat::set( 2, float )" ); + vmathQSetElem( &a_Quat, 2, randfloat() ); + vmathQSetElem( &a_Quat, 2, ( vmathQGetElem( &a_Quat, 2 ) * randfloat() ) ); + vmathQSetElem( &a_Quat, 2, ( vmathQGetElem( &a_Quat, 2 ) / randfloat() ) ); + vmathQSetElem( &a_Quat, 2, ( vmathQGetElem( &a_Quat, 2 ) + randfloat() ) ); + vmathQSetElem( &a_Quat, 2, ( vmathQGetElem( &a_Quat, 2 ) - randfloat() ) ); + vmathQPrints( &a_Quat, "Quat::operator [](2)" ); + vmathQSetZ( &a_Quat, randfloat() ); + vmathQPrints( &a_Quat, "Quat::setZ()" ); + vmathQSetElem( &a_Quat, 3, randfloat() ); + vmathQPrints( &a_Quat, "Quat::set( 3, float )" ); + vmathQSetElem( &a_Quat, 3, randfloat() ); + vmathQSetElem( &a_Quat, 3, ( vmathQGetElem( &a_Quat, 3 ) * randfloat() ) ); + vmathQSetElem( &a_Quat, 3, ( vmathQGetElem( &a_Quat, 3 ) / randfloat() ) ); + vmathQSetElem( &a_Quat, 3, ( vmathQGetElem( &a_Quat, 3 ) + randfloat() ) ); + vmathQSetElem( &a_Quat, 3, ( vmathQGetElem( &a_Quat, 3 ) - randfloat() ) ); + vmathQPrints( &a_Quat, "Quat::operator [](3)" ); + vmathQSetW( &a_Quat, randfloat() ); + vmathQPrints( &a_Quat, "Quat::setW()" ); + printf("Quat::get( 0 ): %f\n", getfloat(vmathQGetElem( &a_Quat, 0 )) ); + printf("Quat::operator []( 0 ): %f\n", getfloat(vmathQGetElem( &a_Quat, 0 )) ); + printf("Quat::getX(): %f\n", getfloat(vmathQGetX( &a_Quat )) ); + printf("Quat::get( 1 ): %f\n", getfloat(vmathQGetElem( &a_Quat, 1 )) ); + printf("Quat::operator []( 1 ): %f\n", getfloat(vmathQGetElem( &a_Quat, 1 )) ); + printf("Quat::getY(): %f\n", getfloat(vmathQGetY( &a_Quat )) ); + printf("Quat::get( 2 ): %f\n", getfloat(vmathQGetElem( &a_Quat, 2 )) ); + printf("Quat::operator []( 2 ): %f\n", getfloat(vmathQGetElem( &a_Quat, 2 )) ); + printf("Quat::getZ(): %f\n", getfloat(vmathQGetZ( &a_Quat )) ); + printf("Quat::get( 3 ): %f\n", getfloat(vmathQGetElem( &a_Quat, 3 )) ); + printf("Quat::operator []( 3 ): %f\n", getfloat(vmathQGetElem( &a_Quat, 3 )) ); + printf("Quat::getW(): %f\n", getfloat(vmathQGetW( &a_Quat )) ); + vmathQAdd( &tmpQ_4, &a_Quat, &b_Quat ); + vmathQPrints( &tmpQ_4, "Quat + Quat" ); + vmathQSub( &tmpQ_5, &a_Quat, &b_Quat ); + vmathQPrints( &tmpQ_5, "Quat - Quat" ); + vmathQMul( &tmpQ_6, &a_Quat, &b_Quat ); + vmathQPrints( &tmpQ_6, "Quat * Quat" ); + vmathQScalarMul( &tmpQ_7, &a_Quat, randfloat() ); + vmathQPrints( &tmpQ_7, "Quat * float" ); + vmathQScalarDiv( &tmpQ_8, &a_Quat, randfloat() ); + vmathQPrints( &tmpQ_8, "Quat / float" ); + vmathQScalarMul( &tmpQ_9, &a_Quat, randfloat() ); + vmathQPrints( &tmpQ_9, "float * Quat" ); + vmathQNeg( &tmpQ_10, &a_Quat ); + vmathQPrints( &tmpQ_10, "Quat negate" ); + printf("Quat dot Quat: %f\n", getfloat(vmathQDot( &a_Quat, &b_Quat ))); + printf("Quat lengthSqr: %f\n", getfloat(vmathQNorm( &a_Quat ))); + printf("Quat length: %f\n", getfloat(vmathQLength( &a_Quat ))); + vmathQNormalize( &tmpQ_11, &a_Quat ); + vmathQPrints( &tmpQ_11, "Quat normalized" ); + vmathQMakeIdentity( &a_Quat ); + vmathQPrints( &a_Quat, "set to identity" ); + vmathQMakeRotationArc( &a_Quat, &a_Vector3, &b_Vector3 ); + vmathQPrints( &a_Quat, "Quat rotation between vectors" ); + vmathQMakeRotationAxis( &a_Quat, randfloat(), &a_Vector3 ); + vmathQPrints( &a_Quat, "Quat rotation axis angle" ); + vmathQMakeRotationX( &a_Quat, randfloat() ); + vmathQPrints( &a_Quat, "Quat rotationX" ); + vmathQMakeRotationY( &a_Quat, randfloat() ); + vmathQPrints( &a_Quat, "Quat rotationY" ); + vmathQMakeRotationZ( &a_Quat, randfloat() ); + vmathQPrints( &a_Quat, "Quat rotationZ" ); + vmathQRotate( &tmpV3_5, &a_Quat, &a_Vector3 ); + vmathV3Prints( &tmpV3_5, "Quat rotate Vector3" ); + vmathQConj( &tmpQ_12, &a_Quat ); + vmathQPrints( &tmpQ_12, "Quat conj" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &b_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &e_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathQNormalize( &b_Quat, &b_Quat ); + vmathQNormalize( &c_Quat, &c_Quat ); + vmathQNormalize( &d_Quat, &d_Quat ); + vmathQNormalize( &e_Quat, &e_Quat ); + vmathQLerp( &a_Quat, randfloat(), &b_Quat, &c_Quat ); + vmathQPrints( &a_Quat, "Quat lerp" ); + vmathQSlerp( &a_Quat, randfloat(), &b_Quat, &c_Quat ); + vmathQPrints( &a_Quat, "Quat slerp" ); + vmathQSquad( &a_Quat, randfloat(), &b_Quat, &c_Quat, &d_Quat, &e_Quat ); + vmathQPrints( &a_Quat, "Quat squad" ); +} + +int main() +{ + printf("\n __begin__ \n"); + for ( iteration = 0; iteration < 2; iteration++ ) { + Vector3_methods_test(); + Vector4_methods_test(); + Point3_methods_test(); + Quat_methods_test(); + } + printf("\n __end__ \n"); + return 0; +} diff --git a/vectormathlibrary/tests/test1_aos_cpp.cpp b/vectormathlibrary/tests/test1_aos_cpp.cpp new file mode 100644 index 000000000..eec4d4d6b --- /dev/null +++ b/vectormathlibrary/tests/test1_aos_cpp.cpp @@ -0,0 +1,1102 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _VECTORMATH_AOS_TEST + +#include "vectormath_aos.h" +#include "test.h" + +int iteration = 0; + +using namespace Vectormath; +using namespace Vectormath::Aos; + +void +Vector3_methods_test() +{ + Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3, e_Vector3; + Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4, e_Vector4; + Point3 a_Point3, b_Point3, c_Point3, d_Point3, e_Point3; + Quat a_Quat, b_Quat, c_Quat, d_Quat, e_Quat; + Vector4 tmpV4; + Vector3 aos_Vector3_0, aos_Vector3_1, aos_Vector3_2, aos_Vector3_3; + Vector4 aos_Vector4_0, aos_Vector4_1, aos_Vector4_2; + float rndflt1, rndflt2, rndflt3, rndflt4, pad; + float xyz4[12] __attribute__ ((aligned(16))); +#ifndef _VECTORMATH_SCALAR_TEST + vec_float4 quad; +#endif + xyz4[0] = randfloat(); + xyz4[1] = randfloat(); + xyz4[2] = randfloat(); + xyz4[3] = randfloat(); + xyz4[4] = randfloat(); + xyz4[5] = randfloat(); + xyz4[6] = randfloat(); + xyz4[7] = randfloat(); + xyz4[8] = randfloat(); + xyz4[9] = randfloat(); + xyz4[10] = randfloat(); + xyz4[11] = randfloat(); + // set a pad value to detect invalid use of padding. + // this will be nan for scalar/ppu implementations, max. float for spu + union { float f; unsigned int u; } tmp; + tmp.u = 0x7fffffff; + pad = tmp.f; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + b_Vector3 = Vector3( scalar_float(rndflt1), scalar_float(rndflt2), scalar_float(rndflt3) ); + tmpV4 = Vector4( a_Vector3, pad ); + a_Vector3 = tmpV4.getXYZ( ); + tmpV4 = Vector4( b_Vector3, pad ); + b_Vector3 = tmpV4.getXYZ( ); + print( a_Vector3, "set Vector3 with floats" ); + print( b_Vector3, "set Vector3 with floats" ); + c_Vector3 = Vector3( 0.0f ); + d_Vector3 = Vector3( 0.0f ); + e_Vector3 = Vector3( 0.0f ); + print( c_Vector3, "set Vector3 elements to zero" ); + print( d_Vector3, "set Vector3 elements to zero" ); + print( e_Vector3, "set Vector3 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + b_Vector4 = Vector4( scalar_float(rndflt1), scalar_float(rndflt2), scalar_float(rndflt3), scalar_float(rndflt4) ); + print( a_Vector4, "set Vector4 with floats" ); + print( b_Vector4, "set Vector4 with floats" ); + c_Vector4 = Vector4( 0.0f ); + d_Vector4 = Vector4( 0.0f ); + e_Vector4 = Vector4( 0.0f ); + print( c_Vector4, "set Vector4 elements to zero" ); + print( d_Vector4, "set Vector4 elements to zero" ); + print( e_Vector4, "set Vector4 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + b_Point3 = Point3( scalar_float(rndflt1), scalar_float(rndflt2), scalar_float(rndflt3) ); + tmpV4 = Vector4( Vector3( a_Point3 ), pad ); + a_Point3 = Point3( tmpV4.getXYZ( ) ); + tmpV4 = Vector4( Vector3( b_Point3 ), pad ); + b_Point3 = Point3( tmpV4.getXYZ( ) ); + print( a_Point3, "set Point3 with floats" ); + print( b_Point3, "set Point3 with floats" ); + c_Point3 = Point3( 0.0f ); + d_Point3 = Point3( 0.0f ); + e_Point3 = Point3( 0.0f ); + print( c_Point3, "set Point3 elements to zero" ); + print( d_Point3, "set Point3 elements to zero" ); + print( e_Point3, "set Point3 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + b_Quat = Quat( scalar_float(rndflt1), scalar_float(rndflt2), scalar_float(rndflt3), scalar_float(rndflt4) ); + print( a_Quat, "set Quat with floats" ); + print( b_Quat, "set Quat with floats" ); + c_Quat = Quat( 0.0f ); + d_Quat = Quat( 0.0f ); + e_Quat = Quat( 0.0f ); + print( c_Quat, "set Quat elements to zero" ); + print( d_Quat, "set Quat elements to zero" ); + print( e_Quat, "set Quat elements to zero" ); + a_Vector3 = Vector3( a_Point3 ); + print( a_Vector3, "construct Vector3 with Point3" ); + a_Vector3 = Vector3( randfloat() ); + print( a_Vector3, "set Vector3 with float" ); + a_Vector3 = Vector3( scalar_float(randfloat()) ); + print( a_Vector3, "set Vector3 with float" ); + aos_Vector3_0 = Vector3( 0.0f, 1.0f, 2.0f ); + aos_Vector3_1 = Vector3( 3.0f, 4.0f, 5.0f ); + aos_Vector3_2 = Vector3( 6.0f, 7.0f, 8.0f ); + aos_Vector3_3 = Vector3( 9.0f, 10.0f, 11.0f ); + print( aos_Vector3_3, "aos type 0" ); + print( aos_Vector3_2, "aos type 1" ); + print( aos_Vector3_1, "aos type 2" ); + print( aos_Vector3_0, "aos type 3" ); + print( select( a_Vector3, b_Vector3, 0 ), "select 0" ); + print( select( a_Vector3, b_Vector3, 1 ), "select 1" ); + print( select( a_Vector3, b_Vector3, 0 ), "select 2" ); + print( select( a_Vector3, b_Vector3, (unsigned int)-1 ), "select 3" ); + a_Vector3 = Vector3( xyz4[0], xyz4[1], xyz4[2] ); + print( a_Vector3, "load XYZ array" ); + xyz4[0] = -xyz4[0]; + xyz4[1] = -xyz4[1]; + xyz4[2] = -xyz4[2]; + xyz4[3] = -xyz4[3]; + xyz4[4] = -xyz4[4]; + xyz4[5] = -xyz4[5]; + xyz4[6] = -xyz4[6]; + xyz4[7] = -xyz4[7]; + xyz4[8] = -xyz4[8]; + xyz4[9] = -xyz4[9]; + xyz4[10] = -xyz4[10]; + xyz4[11] = -xyz4[11]; + aos_Vector4_0 = Vector4( xyz4[0], xyz4[1], xyz4[2], xyz4[3] ); + aos_Vector4_1 = Vector4( xyz4[4], xyz4[5], xyz4[6], xyz4[7] ); + aos_Vector4_2 = Vector4( xyz4[8], xyz4[9], xyz4[10], xyz4[11] ); + print( aos_Vector4_0, "xyzx" ); + print( aos_Vector4_1, "yzxy" ); + print( aos_Vector4_2, "zxyz" ); +#ifndef _VECTORMATH_SCALAR_TEST + loadXYZArray( aos_Vector3_0, aos_Vector3_1, aos_Vector3_2, aos_Vector3_3, (const vec_float4 *)xyz4 ); + xyz4[0] = 0; + xyz4[1] = 1; + xyz4[2] = 2; + xyz4[3] = 3; + xyz4[4] = 4; + xyz4[5] = 5; + xyz4[6] = 6; + xyz4[7] = 7; + xyz4[8] = 8; + xyz4[9] = 9; + xyz4[10] = 10; + xyz4[11] = 11; + storeXYZArray( aos_Vector3_0, aos_Vector3_1, aos_Vector3_2, aos_Vector3_3, (vec_float4 *)xyz4 ); +#endif + aos_Vector4_0 = Vector4( xyz4[0], xyz4[1], xyz4[2], xyz4[3] ); + aos_Vector4_1 = Vector4( xyz4[4], xyz4[5], xyz4[6], xyz4[7] ); + aos_Vector4_2 = Vector4( xyz4[8], xyz4[9], xyz4[10], xyz4[11] ); + print( aos_Vector4_0, "xyzx" ); + print( aos_Vector4_1, "yzxy" ); + print( aos_Vector4_2, "zxyz" ); +#ifdef _VECTORMATH_SCALAR_TEST + printf("storeXYZ:-1.0 -2.0 -3.0 0.4\n"); +#else + quad = (vec_float4){-1.0f, -2.0f, -3.0f, -4.0f}; + a_Vector3 = Vector3( quad ); + quad = (vec_float4){0.1f, 0.2f, 0.3f, 0.4f}; + storeXYZ( a_Vector3, &quad ); + printf("storeXYZ:%f %f %f %f\n", ((float *)&quad)[0], ((float *)&quad)[1], ((float *)&quad)[2], ((float *)&quad)[3]); +#endif + a_Vector3 = b_Vector3; + print( a_Vector3, "assign to Vector3 from Vector3" ); + a_Vector3 = Vector3( 0.0f ); + print( a_Vector3, "set Vector3 elements to zero" ); + a_Vector3 = Vector3::xAxis( ); + print( a_Vector3, "set to x axis" ); + a_Vector3 = Vector3::yAxis( ); + print( a_Vector3, "set to y axis" ); + a_Vector3 = Vector3::zAxis( ); + print( a_Vector3, "set to z axis" ); + if (iteration % 2) { + a_Vector3.setElem( 0, randfloat() ); + } else { + a_Vector3.setElem( 0, scalar_float(randfloat()) ); + } + print( a_Vector3, "Vector3::set( 0, float )" ); + a_Vector3[0] = randfloat(); + a_Vector3[0] *= randfloat(); + a_Vector3[0] /= randfloat(); + a_Vector3[0] += randfloat(); + a_Vector3[0] -= randfloat(); + print( a_Vector3, "Vector3::operator [](0)" ); + a_Vector3.setX( randfloat() ); + print( a_Vector3, "Vector3::setX()" ); + if (iteration % 2) { + a_Vector3.setElem( 1, randfloat() ); + } else { + a_Vector3.setElem( 1, scalar_float(randfloat()) ); + } + print( a_Vector3, "Vector3::set( 1, float )" ); + a_Vector3[1] = randfloat(); + a_Vector3[1] *= randfloat(); + a_Vector3[1] /= randfloat(); + a_Vector3[1] += randfloat(); + a_Vector3[1] -= randfloat(); + print( a_Vector3, "Vector3::operator [](1)" ); + a_Vector3.setY( randfloat() ); + print( a_Vector3, "Vector3::setY()" ); + if (iteration % 2) { + a_Vector3.setElem( 2, randfloat() ); + } else { + a_Vector3.setElem( 2, scalar_float(randfloat()) ); + } + print( a_Vector3, "Vector3::set( 2, float )" ); + a_Vector3[2] = randfloat(); + a_Vector3[2] *= randfloat(); + a_Vector3[2] /= randfloat(); + a_Vector3[2] += randfloat(); + a_Vector3[2] -= randfloat(); + print( a_Vector3, "Vector3::operator [](2)" ); + a_Vector3.setZ( randfloat() ); + print( a_Vector3, "Vector3::setZ()" ); + printf("Vector3::get( 0 ): %f\n", getfloat(a_Vector3.getElem( 0 )) ); + printf("Vector3::operator []( 0 ): %f\n", getfloat((float)a_Vector3[0]) ); + printf("Vector3::getX(): %f\n", getfloat(a_Vector3.getX( )) ); + printf("Vector3::get( 1 ): %f\n", getfloat(a_Vector3.getElem( 1 )) ); + printf("Vector3::operator []( 1 ): %f\n", getfloat((float)a_Vector3[1]) ); + printf("Vector3::getY(): %f\n", getfloat(a_Vector3.getY( )) ); + printf("Vector3::get( 2 ): %f\n", getfloat(a_Vector3.getElem( 2 )) ); + printf("Vector3::operator []( 2 ): %f\n", getfloat((float)a_Vector3[2]) ); + printf("Vector3::getZ(): %f\n", getfloat(a_Vector3.getZ( )) ); + print( ( a_Vector3 + b_Vector3 ), "Vector3 + Vector3" ); + print( ( a_Vector3 - b_Vector3 ), "Vector3 - Vector3" ); + print( ( a_Vector3 + b_Point3 ), "Vector3 + Point3" ); + print( ( a_Vector3 * randfloat() ), "Vector3 * float" ); + print( ( a_Vector3 / randfloat() ), "Vector3 / float" ); + print( ( randfloat() * a_Vector3 ), "float * Vector3" ); + print( ( -a_Vector3 ), "Vector3 negate" ); + print( mulPerElem( a_Vector3, b_Vector3 ), "mulPerElem( Vector3, Vector3 )" ); + print( divPerElem( a_Vector3, b_Vector3 ), "divPerElem( Vector3, Vector3 )" ); + print( recipPerElem( a_Vector3 ), "Vector3 recip" ); + print( sqrtPerElem( absPerElem( a_Vector3 ) ), "Vector3 sqrt" ); + print( rsqrtPerElem( absPerElem( a_Vector3 ) ), "Vector3 rsqrt" ); + print( absPerElem( a_Vector3 ), "Vector3 abs" ); + print( copySignPerElem( a_Vector3, b_Vector3 ), "Vector3 copySign" ); + print( maxPerElem( a_Vector3, b_Vector3 ), "Vector3 maximum Vector3" ); + print( minPerElem( a_Vector3, b_Vector3 ), "Vector3 minimum Vector3" ); + printf("Vector3 maximum of elements: %f\n", getfloat(maxElem( a_Vector3 ))); + printf("Vector3 minimum of elements: %f\n", getfloat(minElem( a_Vector3 ))); + printf("Vector3 sum of elements: %f\n", getfloat(sum( a_Vector3 ))); + printf("Vector3 dot Vector3: %f\n", getfloat(dot( a_Vector3, b_Vector3 ))); + printf("Vector3 lengthSqr: %f\n", getfloat(lengthSqr( a_Vector3 ))); + printf("Vector3 length: %f\n", getfloat(length( a_Vector3 ))); + print( normalize( a_Vector3 ), "Vector3 normalized" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + b_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + e_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + b_Vector3 = normalize( b_Vector3 ); + c_Vector3 = normalize( c_Vector3 ); + d_Vector3 = normalize( d_Vector3 ); + e_Vector3 = normalize( e_Vector3 ); + a_Vector3 = lerp( randfloat(), b_Vector3, c_Vector3 ); + print( a_Vector3, "Vector3 lerp" ); + a_Vector3 = slerp( randfloat(), b_Vector3, c_Vector3 ); + print( a_Vector3, "Vector3 slerp" ); +} + +void +Vector4_methods_test() +{ + Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3, e_Vector3; + Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4, e_Vector4; + Point3 a_Point3, b_Point3, c_Point3, d_Point3, e_Point3; + Quat a_Quat, b_Quat, c_Quat, d_Quat, e_Quat; + Vector4 tmpV4, aos_Vector4_0, aos_Vector4_1, aos_Vector4_2, aos_Vector4_3; + float rndflt1, rndflt2, rndflt3, rndflt4, pad; + // set a pad value to detect invalid use of padding. + // this will be nan for scalar/ppu implementations, max. float for spu + union { float f; unsigned int u; } tmp; + tmp.u = 0x7fffffff; + pad = tmp.f; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + b_Vector3 = Vector3( scalar_float(rndflt1), scalar_float(rndflt2), scalar_float(rndflt3) ); + tmpV4 = Vector4( a_Vector3, pad ); + a_Vector3 = tmpV4.getXYZ( ); + tmpV4 = Vector4( b_Vector3, pad ); + b_Vector3 = tmpV4.getXYZ( ); + print( a_Vector3, "set Vector3 with floats" ); + print( b_Vector3, "set Vector3 with floats" ); + c_Vector3 = Vector3( 0.0f ); + d_Vector3 = Vector3( 0.0f ); + e_Vector3 = Vector3( 0.0f ); + print( c_Vector3, "set Vector3 elements to zero" ); + print( d_Vector3, "set Vector3 elements to zero" ); + print( e_Vector3, "set Vector3 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + b_Vector4 = Vector4( scalar_float(rndflt1), scalar_float(rndflt2), scalar_float(rndflt3), scalar_float(rndflt4) ); + print( a_Vector4, "set Vector4 with floats" ); + print( b_Vector4, "set Vector4 with floats" ); + c_Vector4 = Vector4( 0.0f ); + d_Vector4 = Vector4( 0.0f ); + e_Vector4 = Vector4( 0.0f ); + print( c_Vector4, "set Vector4 elements to zero" ); + print( d_Vector4, "set Vector4 elements to zero" ); + print( e_Vector4, "set Vector4 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + b_Point3 = Point3( scalar_float(rndflt1), scalar_float(rndflt2), scalar_float(rndflt3) ); + tmpV4 = Vector4( Vector3( a_Point3 ), pad ); + a_Point3 = Point3( tmpV4.getXYZ( ) ); + tmpV4 = Vector4( Vector3( b_Point3 ), pad ); + b_Point3 = Point3( tmpV4.getXYZ( ) ); + print( a_Point3, "set Point3 with floats" ); + print( b_Point3, "set Point3 with floats" ); + c_Point3 = Point3( 0.0f ); + d_Point3 = Point3( 0.0f ); + e_Point3 = Point3( 0.0f ); + print( c_Point3, "set Point3 elements to zero" ); + print( d_Point3, "set Point3 elements to zero" ); + print( e_Point3, "set Point3 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + b_Quat = Quat( scalar_float(rndflt1), scalar_float(rndflt2), scalar_float(rndflt3), scalar_float(rndflt4) ); + print( a_Quat, "set Quat with floats" ); + print( b_Quat, "set Quat with floats" ); + c_Quat = Quat( 0.0f ); + d_Quat = Quat( 0.0f ); + e_Quat = Quat( 0.0f ); + print( c_Quat, "set Quat elements to zero" ); + print( d_Quat, "set Quat elements to zero" ); + print( e_Quat, "set Quat elements to zero" ); + a_Vector4 = Vector4( a_Vector3, randfloat() ); + print( a_Vector4, "set Vector4 with Vector3, float" ); + a_Vector4 = Vector4( a_Vector3 ); + print( a_Vector4, "set Vector4 with Vector3" ); + a_Vector4 = Vector4( a_Point3 ); + print( a_Vector4, "set Vector4 with Point3" ); + a_Vector4 = Vector4( a_Quat ); + print( a_Vector4, "construct Vector4 with Quat" ); + a_Vector4 = Vector4( randfloat() ); + print( a_Vector4, "set Vector4 with float" ); + a_Vector4 = Vector4( scalar_float(randfloat()) ); + print( a_Vector4, "set Vector4 with float" ); + aos_Vector4_0 = Vector4( 0.0f, 1.0f, 2.0f, 3.0f ); + aos_Vector4_1 = Vector4( 4.0f, 5.0f, 6.0f, 7.0f ); + aos_Vector4_2 = Vector4( 8.0f, 9.0f, 10.0f, 11.0f ); + aos_Vector4_3 = Vector4( 12.0f, 13.0f, 14.0f, 15.0f ); + print( aos_Vector4_3, "aos type 0" ); + print( aos_Vector4_2, "aos type 1" ); + print( aos_Vector4_1, "aos type 2" ); + print( aos_Vector4_0, "aos type 3" ); + print( select( a_Vector4, b_Vector4, 0 ), "select 0" ); + print( select( a_Vector4, b_Vector4, 1 ), "select 1" ); + print( select( a_Vector4, b_Vector4, 0 ), "select 2" ); + print( select( a_Vector4, b_Vector4, (unsigned int)-1 ), "select 3" ); + a_Vector4 = b_Vector4; + print( a_Vector4, "assign to Vector4 from Vector4" ); + a_Vector4.setXYZ( a_Vector3 ); + print( a_Vector4, "set Vector4 xyz" ); + print( a_Vector4.getXYZ( ), "get Vector4 xyz" ); + a_Vector4 = Vector4( 0.0f ); + print( a_Vector4, "set Vector4 elements to zero" ); + a_Vector4 = Vector4::xAxis( ); + print( a_Vector4, "set to x axis" ); + a_Vector4 = Vector4::yAxis( ); + print( a_Vector4, "set to y axis" ); + a_Vector4 = Vector4::zAxis( ); + print( a_Vector4, "set to z axis" ); + a_Vector4 = Vector4::wAxis( ); + print( a_Vector4, "set to w axis" ); + if (iteration % 2) { + a_Vector4.setElem( 0, randfloat() ); + } else { + a_Vector4.setElem( 0, scalar_float(randfloat()) ); + } + print( a_Vector4, "Vector4::set( 0, float )" ); + a_Vector4[0] = randfloat(); + a_Vector4[0] *= randfloat(); + a_Vector4[0] /= randfloat(); + a_Vector4[0] += randfloat(); + a_Vector4[0] -= randfloat(); + print( a_Vector4, "Vector4::operator [](0)" ); + a_Vector4.setX( randfloat() ); + print( a_Vector4, "Vector4::setX()" ); + if (iteration % 2) { + a_Vector4.setElem( 1, randfloat() ); + } else { + a_Vector4.setElem( 1, scalar_float(randfloat()) ); + } + print( a_Vector4, "Vector4::set( 1, float )" ); + a_Vector4[1] = randfloat(); + a_Vector4[1] *= randfloat(); + a_Vector4[1] /= randfloat(); + a_Vector4[1] += randfloat(); + a_Vector4[1] -= randfloat(); + print( a_Vector4, "Vector4::operator [](1)" ); + a_Vector4.setY( randfloat() ); + print( a_Vector4, "Vector4::setY()" ); + if (iteration % 2) { + a_Vector4.setElem( 2, randfloat() ); + } else { + a_Vector4.setElem( 2, scalar_float(randfloat()) ); + } + print( a_Vector4, "Vector4::set( 2, float )" ); + a_Vector4[2] = randfloat(); + a_Vector4[2] *= randfloat(); + a_Vector4[2] /= randfloat(); + a_Vector4[2] += randfloat(); + a_Vector4[2] -= randfloat(); + print( a_Vector4, "Vector4::operator [](2)" ); + a_Vector4.setZ( randfloat() ); + print( a_Vector4, "Vector4::setZ()" ); + if (iteration % 2) { + a_Vector4.setElem( 3, randfloat() ); + } else { + a_Vector4.setElem( 3, scalar_float(randfloat()) ); + } + print( a_Vector4, "Vector4::set( 3, float )" ); + a_Vector4[3] = randfloat(); + a_Vector4[3] *= randfloat(); + a_Vector4[3] /= randfloat(); + a_Vector4[3] += randfloat(); + a_Vector4[3] -= randfloat(); + print( a_Vector4, "Vector4::operator [](3)" ); + a_Vector4.setW( randfloat() ); + print( a_Vector4, "Vector4::setW()" ); + printf("Vector4::get( 0 ): %f\n", getfloat(a_Vector4.getElem( 0 )) ); + printf("Vector4::operator []( 0 ): %f\n", getfloat((float)a_Vector4[0]) ); + printf("Vector4::getX(): %f\n", getfloat(a_Vector4.getX( )) ); + printf("Vector4::get( 1 ): %f\n", getfloat(a_Vector4.getElem( 1 )) ); + printf("Vector4::operator []( 1 ): %f\n", getfloat((float)a_Vector4[1]) ); + printf("Vector4::getY(): %f\n", getfloat(a_Vector4.getY( )) ); + printf("Vector4::get( 2 ): %f\n", getfloat(a_Vector4.getElem( 2 )) ); + printf("Vector4::operator []( 2 ): %f\n", getfloat((float)a_Vector4[2]) ); + printf("Vector4::getZ(): %f\n", getfloat(a_Vector4.getZ( )) ); + printf("Vector4::get( 3 ): %f\n", getfloat(a_Vector4.getElem( 3 )) ); + printf("Vector4::operator []( 3 ): %f\n", getfloat((float)a_Vector4[3]) ); + printf("Vector4::getW(): %f\n", getfloat(a_Vector4.getW( )) ); + print( ( a_Vector4 + b_Vector4 ), "Vector4 + Vector4" ); + print( ( a_Vector4 - b_Vector4 ), "Vector4 - Vector4" ); + print( ( a_Vector4 * randfloat() ), "Vector4 * float" ); + print( ( a_Vector4 / randfloat() ), "Vector4 / float" ); + print( ( randfloat() * a_Vector4 ), "float * Vector4" ); + print( ( -a_Vector4 ), "Vector4 negate" ); + print( mulPerElem( a_Vector4, b_Vector4 ), "mulPerElem( Vector4, Vector4 )" ); + print( divPerElem( a_Vector4, b_Vector4 ), "divPerElem( Vector4, Vector4 )" ); + print( recipPerElem( a_Vector4 ), "Vector4 recip" ); + print( sqrtPerElem( absPerElem( a_Vector4 ) ), "Vector4 sqrt" ); + print( rsqrtPerElem( absPerElem( a_Vector4 ) ), "Vector4 rsqrt" ); + print( absPerElem( a_Vector4 ), "Vector4 abs" ); + print( copySignPerElem( a_Vector4, b_Vector4 ), "Vector4 copySign" ); + print( maxPerElem( a_Vector4, b_Vector4 ), "Vector4 maximum Vector4" ); + print( minPerElem( a_Vector4, b_Vector4 ), "Vector4 minimum Vector4" ); + printf("Vector4 maximum of elements: %f\n", getfloat(maxElem( a_Vector4 ))); + printf("Vector4 minimum of elements: %f\n", getfloat(minElem( a_Vector4 ))); + printf("Vector4 sum of elements: %f\n", getfloat(sum( a_Vector4 ))); + printf("Vector4 dot Vector4: %f\n", getfloat(dot( a_Vector4, b_Vector4 ))); + printf("Vector4 lengthSqr: %f\n", getfloat(lengthSqr( a_Vector4 ))); + printf("Vector4 length: %f\n", getfloat(length( a_Vector4 ))); + print( normalize( a_Vector4 ), "Vector4 normalized" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + b_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + e_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + b_Vector4 = normalize( b_Vector4 ); + c_Vector4 = normalize( c_Vector4 ); + d_Vector4 = normalize( d_Vector4 ); + e_Vector4 = normalize( e_Vector4 ); + a_Vector4 = lerp( randfloat(), b_Vector4, c_Vector4 ); + print( a_Vector4, "Vector4 lerp" ); + a_Vector4 = slerp( randfloat(), b_Vector4, c_Vector4 ); + print( a_Vector4, "Vector4 slerp" ); +} + +void +Point3_methods_test() +{ + Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3, e_Vector3; + Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4, e_Vector4; + Point3 a_Point3, b_Point3, c_Point3, d_Point3, e_Point3; + Quat a_Quat, b_Quat, c_Quat, d_Quat, e_Quat; + Vector4 tmpV4; + Point3 aos_Point3_0, aos_Point3_1, aos_Point3_2, aos_Point3_3; + Vector4 aos_Vector4_0, aos_Vector4_1, aos_Vector4_2; + float rndflt1, rndflt2, rndflt3, rndflt4, pad; + float xyz4[12] __attribute__ ((aligned(16))); +#ifndef _VECTORMATH_SCALAR_TEST + vec_float4 quad; +#endif + xyz4[0] = randfloat(); + xyz4[1] = randfloat(); + xyz4[2] = randfloat(); + xyz4[3] = randfloat(); + xyz4[4] = randfloat(); + xyz4[5] = randfloat(); + xyz4[6] = randfloat(); + xyz4[7] = randfloat(); + xyz4[8] = randfloat(); + xyz4[9] = randfloat(); + xyz4[10] = randfloat(); + xyz4[11] = randfloat(); + // set a pad value to detect invalid use of padding. + // this will be nan for scalar/ppu implementations, max. float for spu + union { float f; unsigned int u; } tmp; + tmp.u = 0x7fffffff; + pad = tmp.f; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + b_Vector3 = Vector3( scalar_float(rndflt1), scalar_float(rndflt2), scalar_float(rndflt3) ); + tmpV4 = Vector4( a_Vector3, pad ); + a_Vector3 = tmpV4.getXYZ( ); + tmpV4 = Vector4( b_Vector3, pad ); + b_Vector3 = tmpV4.getXYZ( ); + print( a_Vector3, "set Vector3 with floats" ); + print( b_Vector3, "set Vector3 with floats" ); + c_Vector3 = Vector3( 0.0f ); + d_Vector3 = Vector3( 0.0f ); + e_Vector3 = Vector3( 0.0f ); + print( c_Vector3, "set Vector3 elements to zero" ); + print( d_Vector3, "set Vector3 elements to zero" ); + print( e_Vector3, "set Vector3 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + b_Vector4 = Vector4( scalar_float(rndflt1), scalar_float(rndflt2), scalar_float(rndflt3), scalar_float(rndflt4) ); + print( a_Vector4, "set Vector4 with floats" ); + print( b_Vector4, "set Vector4 with floats" ); + c_Vector4 = Vector4( 0.0f ); + d_Vector4 = Vector4( 0.0f ); + e_Vector4 = Vector4( 0.0f ); + print( c_Vector4, "set Vector4 elements to zero" ); + print( d_Vector4, "set Vector4 elements to zero" ); + print( e_Vector4, "set Vector4 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + b_Point3 = Point3( scalar_float(rndflt1), scalar_float(rndflt2), scalar_float(rndflt3) ); + tmpV4 = Vector4( Vector3( a_Point3 ), pad ); + a_Point3 = Point3( tmpV4.getXYZ( ) ); + tmpV4 = Vector4( Vector3( b_Point3 ), pad ); + b_Point3 = Point3( tmpV4.getXYZ( ) ); + print( a_Point3, "set Point3 with floats" ); + print( b_Point3, "set Point3 with floats" ); + c_Point3 = Point3( 0.0f ); + d_Point3 = Point3( 0.0f ); + e_Point3 = Point3( 0.0f ); + print( c_Point3, "set Point3 elements to zero" ); + print( d_Point3, "set Point3 elements to zero" ); + print( e_Point3, "set Point3 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + b_Quat = Quat( scalar_float(rndflt1), scalar_float(rndflt2), scalar_float(rndflt3), scalar_float(rndflt4) ); + print( a_Quat, "set Quat with floats" ); + print( b_Quat, "set Quat with floats" ); + c_Quat = Quat( 0.0f ); + d_Quat = Quat( 0.0f ); + e_Quat = Quat( 0.0f ); + print( c_Quat, "set Quat elements to zero" ); + print( d_Quat, "set Quat elements to zero" ); + print( e_Quat, "set Quat elements to zero" ); + a_Point3 = Point3( a_Vector3 ); + print( a_Point3, "construct Point3 with Vector3" ); + a_Point3 = Point3( randfloat() ); + print( a_Point3, "set Point3 with float" ); + a_Point3 = Point3( scalar_float(randfloat()) ); + print( a_Point3, "set Point3 with float" ); + aos_Point3_0 = Point3( 0.0f, 1.0f, 2.0f ); + aos_Point3_1 = Point3( 3.0f, 4.0f, 5.0f ); + aos_Point3_2 = Point3( 6.0f, 7.0f, 8.0f ); + aos_Point3_3 = Point3( 9.0f, 10.0f, 11.0f ); + print( aos_Point3_3, "aos type 0" ); + print( aos_Point3_2, "aos type 1" ); + print( aos_Point3_1, "aos type 2" ); + print( aos_Point3_0, "aos type 3" ); + print( select( a_Point3, b_Point3, 0 ), "select 0" ); + print( select( a_Point3, b_Point3, 1 ), "select 1" ); + print( select( a_Point3, b_Point3, 0 ), "select 2" ); + print( select( a_Point3, b_Point3, (unsigned int)-1 ), "select 3" ); + a_Point3 = Point3( xyz4[0], xyz4[1], xyz4[2] ); + print( a_Point3, "load XYZ array" ); + xyz4[0] = -xyz4[0]; + xyz4[1] = -xyz4[1]; + xyz4[2] = -xyz4[2]; + xyz4[3] = -xyz4[3]; + xyz4[4] = -xyz4[4]; + xyz4[5] = -xyz4[5]; + xyz4[6] = -xyz4[6]; + xyz4[7] = -xyz4[7]; + xyz4[8] = -xyz4[8]; + xyz4[9] = -xyz4[9]; + xyz4[10] = -xyz4[10]; + xyz4[11] = -xyz4[11]; + aos_Vector4_0 = Vector4( xyz4[0], xyz4[1], xyz4[2], xyz4[3] ); + aos_Vector4_1 = Vector4( xyz4[4], xyz4[5], xyz4[6], xyz4[7] ); + aos_Vector4_2 = Vector4( xyz4[8], xyz4[9], xyz4[10], xyz4[11] ); + print( aos_Vector4_0, "xyzx" ); + print( aos_Vector4_1, "yzxy" ); + print( aos_Vector4_2, "zxyz" ); +#ifndef _VECTORMATH_SCALAR_TEST + loadXYZArray( aos_Point3_0, aos_Point3_1, aos_Point3_2, aos_Point3_3, (const vec_float4 *)xyz4 ); + xyz4[0] = 0; + xyz4[1] = 1; + xyz4[2] = 2; + xyz4[3] = 3; + xyz4[4] = 4; + xyz4[5] = 5; + xyz4[6] = 6; + xyz4[7] = 7; + xyz4[8] = 8; + xyz4[9] = 9; + xyz4[10] = 10; + xyz4[11] = 11; + storeXYZArray( aos_Point3_0, aos_Point3_1, aos_Point3_2, aos_Point3_3, (vec_float4 *)xyz4 ); +#endif + aos_Vector4_0 = Vector4( xyz4[0], xyz4[1], xyz4[2], xyz4[3] ); + aos_Vector4_1 = Vector4( xyz4[4], xyz4[5], xyz4[6], xyz4[7] ); + aos_Vector4_2 = Vector4( xyz4[8], xyz4[9], xyz4[10], xyz4[11] ); + print( aos_Vector4_0, "xyzx" ); + print( aos_Vector4_1, "yzxy" ); + print( aos_Vector4_2, "zxyz" ); +#ifdef _VECTORMATH_SCALAR_TEST + printf("storeXYZ:-1.0 -2.0 -3.0 0.4\n"); +#else + quad = (vec_float4){-1.0f, -2.0f, -3.0f, -4.0f}; + a_Point3 = Point3( quad ); + quad = (vec_float4){0.1f, 0.2f, 0.3f, 0.4f}; + storeXYZ( a_Point3, &quad ); + printf("storeXYZ:%f %f %f %f\n", ((float *)&quad)[0], ((float *)&quad)[1], ((float *)&quad)[2], ((float *)&quad)[3]); +#endif + a_Point3 = b_Point3; + print( a_Point3, "assign to Point3 from Point3" ); + a_Point3 = Point3( 0.0f ); + print( a_Point3, "set Point3 elements to zero" ); + if (iteration % 2) { + a_Point3.setElem( 0, randfloat() ); + } else { + a_Point3.setElem( 0, scalar_float(randfloat()) ); + } + print( a_Point3, "Point3::set( 0, float )" ); + a_Point3[0] = randfloat(); + a_Point3[0] *= randfloat(); + a_Point3[0] /= randfloat(); + a_Point3[0] += randfloat(); + a_Point3[0] -= randfloat(); + print( a_Point3, "Point3::operator [](0)" ); + a_Point3.setX( randfloat() ); + print( a_Point3, "Point3::setX()" ); + if (iteration % 2) { + a_Point3.setElem( 1, randfloat() ); + } else { + a_Point3.setElem( 1, scalar_float(randfloat()) ); + } + print( a_Point3, "Point3::set( 1, float )" ); + a_Point3[1] = randfloat(); + a_Point3[1] *= randfloat(); + a_Point3[1] /= randfloat(); + a_Point3[1] += randfloat(); + a_Point3[1] -= randfloat(); + print( a_Point3, "Point3::operator [](1)" ); + a_Point3.setY( randfloat() ); + print( a_Point3, "Point3::setY()" ); + if (iteration % 2) { + a_Point3.setElem( 2, randfloat() ); + } else { + a_Point3.setElem( 2, scalar_float(randfloat()) ); + } + print( a_Point3, "Point3::set( 2, float )" ); + a_Point3[2] = randfloat(); + a_Point3[2] *= randfloat(); + a_Point3[2] /= randfloat(); + a_Point3[2] += randfloat(); + a_Point3[2] -= randfloat(); + print( a_Point3, "Point3::operator [](2)" ); + a_Point3.setZ( randfloat() ); + print( a_Point3, "Point3::setZ()" ); + printf("Point3::get( 0 ): %f\n", getfloat(a_Point3.getElem( 0 )) ); + printf("Point3::operator []( 0 ): %f\n", getfloat((float)a_Point3[0]) ); + printf("Point3::getX(): %f\n", getfloat(a_Point3.getX( )) ); + printf("Point3::get( 1 ): %f\n", getfloat(a_Point3.getElem( 1 )) ); + printf("Point3::operator []( 1 ): %f\n", getfloat((float)a_Point3[1]) ); + printf("Point3::getY(): %f\n", getfloat(a_Point3.getY( )) ); + printf("Point3::get( 2 ): %f\n", getfloat(a_Point3.getElem( 2 )) ); + printf("Point3::operator []( 2 ): %f\n", getfloat((float)a_Point3[2]) ); + printf("Point3::getZ(): %f\n", getfloat(a_Point3.getZ( )) ); + print( ( a_Point3 - b_Point3 ), "Point3 - Point3" ); + print( ( a_Point3 + b_Vector3 ), "Point3 + Vector3" ); + print( ( a_Point3 - b_Vector3 ), "Point3 - Vector3" ); + print( mulPerElem( a_Point3, b_Point3 ), "mulPerElem( Point3, Point3 )" ); + print( divPerElem( a_Point3, b_Point3 ), "divPerElem( Point3, Point3 )" ); + print( recipPerElem( a_Point3 ), "Point3 recip" ); + print( sqrtPerElem( absPerElem( a_Point3 ) ), "Point3 sqrt" ); + print( rsqrtPerElem( absPerElem( a_Point3 ) ), "Point3 rsqrt" ); + print( absPerElem( a_Point3 ), "Point3 abs" ); + print( copySignPerElem( a_Point3, b_Point3 ), "Point3 copySign" ); + print( maxPerElem( a_Point3, b_Point3 ), "Point3 maximum Point3" ); + print( minPerElem( a_Point3, b_Point3 ), "Point3 minimum Point3" ); + printf("Point3 maximum of elements: %f\n", getfloat(maxElem( a_Point3 ))); + printf("Point3 minimum of elements: %f\n", getfloat(minElem( a_Point3 ))); + printf("Point3 sum of elements: %f\n", getfloat(sum( a_Point3 ))); + printf("Point projection: %f\n", getfloat(projection( a_Point3, b_Vector3 ))); + printf("Point distSqrFromOrigin: %f\n", getfloat(distSqrFromOrigin( a_Point3 )) ); + printf("Point distFromOrigin: %f\n", getfloat(distFromOrigin( a_Point3 )) ); + printf("Point distSqr: %f\n", getfloat(distSqr( a_Point3, b_Point3 )) ); + printf("Point dist: %f\n", getfloat(dist( a_Point3, b_Point3 )) ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + b_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + e_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + a_Point3 = lerp( randfloat(), b_Point3, c_Point3 ); + print( a_Point3, "Point3 lerp" ); +} + +void +Quat_methods_test() +{ + Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3, e_Vector3; + Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4, e_Vector4; + Point3 a_Point3, b_Point3, c_Point3, d_Point3, e_Point3; + Quat a_Quat, b_Quat, c_Quat, d_Quat, e_Quat; + Vector4 tmpV4; + Quat aos_Quat_0, aos_Quat_1, aos_Quat_2, aos_Quat_3; + float rndflt1, rndflt2, rndflt3, rndflt4, pad; + // set a pad value to detect invalid use of padding. + // this will be nan for scalar/ppu implementations, max. float for spu + union { float f; unsigned int u; } tmp; + tmp.u = 0x7fffffff; + pad = tmp.f; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + b_Vector3 = Vector3( scalar_float(rndflt1), scalar_float(rndflt2), scalar_float(rndflt3) ); + tmpV4 = Vector4( a_Vector3, pad ); + a_Vector3 = tmpV4.getXYZ( ); + tmpV4 = Vector4( b_Vector3, pad ); + b_Vector3 = tmpV4.getXYZ( ); + print( a_Vector3, "set Vector3 with floats" ); + print( b_Vector3, "set Vector3 with floats" ); + c_Vector3 = Vector3( 0.0f ); + d_Vector3 = Vector3( 0.0f ); + e_Vector3 = Vector3( 0.0f ); + print( c_Vector3, "set Vector3 elements to zero" ); + print( d_Vector3, "set Vector3 elements to zero" ); + print( e_Vector3, "set Vector3 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + b_Vector4 = Vector4( scalar_float(rndflt1), scalar_float(rndflt2), scalar_float(rndflt3), scalar_float(rndflt4) ); + print( a_Vector4, "set Vector4 with floats" ); + print( b_Vector4, "set Vector4 with floats" ); + c_Vector4 = Vector4( 0.0f ); + d_Vector4 = Vector4( 0.0f ); + e_Vector4 = Vector4( 0.0f ); + print( c_Vector4, "set Vector4 elements to zero" ); + print( d_Vector4, "set Vector4 elements to zero" ); + print( e_Vector4, "set Vector4 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + b_Point3 = Point3( scalar_float(rndflt1), scalar_float(rndflt2), scalar_float(rndflt3) ); + tmpV4 = Vector4( Vector3( a_Point3 ), pad ); + a_Point3 = Point3( tmpV4.getXYZ( ) ); + tmpV4 = Vector4( Vector3( b_Point3 ), pad ); + b_Point3 = Point3( tmpV4.getXYZ( ) ); + print( a_Point3, "set Point3 with floats" ); + print( b_Point3, "set Point3 with floats" ); + c_Point3 = Point3( 0.0f ); + d_Point3 = Point3( 0.0f ); + e_Point3 = Point3( 0.0f ); + print( c_Point3, "set Point3 elements to zero" ); + print( d_Point3, "set Point3 elements to zero" ); + print( e_Point3, "set Point3 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + b_Quat = Quat( scalar_float(rndflt1), scalar_float(rndflt2), scalar_float(rndflt3), scalar_float(rndflt4) ); + print( a_Quat, "set Quat with floats" ); + print( b_Quat, "set Quat with floats" ); + c_Quat = Quat( 0.0f ); + d_Quat = Quat( 0.0f ); + e_Quat = Quat( 0.0f ); + print( c_Quat, "set Quat elements to zero" ); + print( d_Quat, "set Quat elements to zero" ); + print( e_Quat, "set Quat elements to zero" ); + a_Quat = Quat( a_Vector3, randfloat() ); + print( a_Quat, "set Quat with Vector3, float" ); + a_Quat = Quat( a_Vector4 ); + print( a_Quat, "construct Quat with Vector4" ); + a_Quat = Quat( randfloat() ); + print( a_Quat, "set Quat with float" ); + a_Quat = Quat( scalar_float(randfloat()) ); + print( a_Quat, "set Quat with float" ); + aos_Quat_0 = Quat( 0.0f, 1.0f, 2.0f, 3.0f ); + aos_Quat_1 = Quat( 4.0f, 5.0f, 6.0f, 7.0f ); + aos_Quat_2 = Quat( 8.0f, 9.0f, 10.0f, 11.0f ); + aos_Quat_3 = Quat( 12.0f, 13.0f, 14.0f, 15.0f ); + print( aos_Quat_3, "aos type 0" ); + print( aos_Quat_2, "aos type 1" ); + print( aos_Quat_1, "aos type 2" ); + print( aos_Quat_0, "aos type 3" ); + print( select( a_Quat, b_Quat, 0 ), "select 0" ); + print( select( a_Quat, b_Quat, 1 ), "select 1" ); + print( select( a_Quat, b_Quat, 0 ), "select 2" ); + print( select( a_Quat, b_Quat, (unsigned int)-1 ), "select 3" ); + a_Quat = b_Quat; + print( a_Quat, "assign to Quat from Quat" ); + a_Quat.setXYZ( a_Vector3 ); + print( a_Quat, "set Quat xyz" ); + print( a_Quat.getXYZ( ), "get Quat xyz" ); + a_Quat = Quat( 0.0f ); + print( a_Quat, "set Quat elements to zero" ); + if (iteration % 2) { + a_Quat.setElem( 0, randfloat() ); + } else { + a_Quat.setElem( 0, scalar_float(randfloat()) ); + } + print( a_Quat, "Quat::set( 0, float )" ); + a_Quat[0] = randfloat(); + a_Quat[0] *= randfloat(); + a_Quat[0] /= randfloat(); + a_Quat[0] += randfloat(); + a_Quat[0] -= randfloat(); + print( a_Quat, "Quat::operator [](0)" ); + a_Quat.setX( randfloat() ); + print( a_Quat, "Quat::setX()" ); + if (iteration % 2) { + a_Quat.setElem( 1, randfloat() ); + } else { + a_Quat.setElem( 1, scalar_float(randfloat()) ); + } + print( a_Quat, "Quat::set( 1, float )" ); + a_Quat[1] = randfloat(); + a_Quat[1] *= randfloat(); + a_Quat[1] /= randfloat(); + a_Quat[1] += randfloat(); + a_Quat[1] -= randfloat(); + print( a_Quat, "Quat::operator [](1)" ); + a_Quat.setY( randfloat() ); + print( a_Quat, "Quat::setY()" ); + if (iteration % 2) { + a_Quat.setElem( 2, randfloat() ); + } else { + a_Quat.setElem( 2, scalar_float(randfloat()) ); + } + print( a_Quat, "Quat::set( 2, float )" ); + a_Quat[2] = randfloat(); + a_Quat[2] *= randfloat(); + a_Quat[2] /= randfloat(); + a_Quat[2] += randfloat(); + a_Quat[2] -= randfloat(); + print( a_Quat, "Quat::operator [](2)" ); + a_Quat.setZ( randfloat() ); + print( a_Quat, "Quat::setZ()" ); + if (iteration % 2) { + a_Quat.setElem( 3, randfloat() ); + } else { + a_Quat.setElem( 3, scalar_float(randfloat()) ); + } + print( a_Quat, "Quat::set( 3, float )" ); + a_Quat[3] = randfloat(); + a_Quat[3] *= randfloat(); + a_Quat[3] /= randfloat(); + a_Quat[3] += randfloat(); + a_Quat[3] -= randfloat(); + print( a_Quat, "Quat::operator [](3)" ); + a_Quat.setW( randfloat() ); + print( a_Quat, "Quat::setW()" ); + printf("Quat::get( 0 ): %f\n", getfloat(a_Quat.getElem( 0 )) ); + printf("Quat::operator []( 0 ): %f\n", getfloat((float)a_Quat[0]) ); + printf("Quat::getX(): %f\n", getfloat(a_Quat.getX( )) ); + printf("Quat::get( 1 ): %f\n", getfloat(a_Quat.getElem( 1 )) ); + printf("Quat::operator []( 1 ): %f\n", getfloat((float)a_Quat[1]) ); + printf("Quat::getY(): %f\n", getfloat(a_Quat.getY( )) ); + printf("Quat::get( 2 ): %f\n", getfloat(a_Quat.getElem( 2 )) ); + printf("Quat::operator []( 2 ): %f\n", getfloat((float)a_Quat[2]) ); + printf("Quat::getZ(): %f\n", getfloat(a_Quat.getZ( )) ); + printf("Quat::get( 3 ): %f\n", getfloat(a_Quat.getElem( 3 )) ); + printf("Quat::operator []( 3 ): %f\n", getfloat((float)a_Quat[3]) ); + printf("Quat::getW(): %f\n", getfloat(a_Quat.getW( )) ); + print( ( a_Quat + b_Quat ), "Quat + Quat" ); + print( ( a_Quat - b_Quat ), "Quat - Quat" ); + print( ( a_Quat * b_Quat ), "Quat * Quat" ); + print( ( a_Quat * randfloat() ), "Quat * float" ); + print( ( a_Quat / randfloat() ), "Quat / float" ); + print( ( randfloat() * a_Quat ), "float * Quat" ); + print( ( -a_Quat ), "Quat negate" ); + printf("Quat dot Quat: %f\n", getfloat(dot( a_Quat, b_Quat ))); + printf("Quat lengthSqr: %f\n", getfloat(norm( a_Quat ))); + printf("Quat length: %f\n", getfloat(length( a_Quat ))); + print( normalize( a_Quat ), "Quat normalized" ); + a_Quat = Quat::identity( ); + print( a_Quat, "set to identity" ); + a_Quat = Quat::rotation( a_Vector3, b_Vector3 ); + print( a_Quat, "Quat rotation between vectors" ); + a_Quat = Quat::rotation( randfloat(), a_Vector3 ); + print( a_Quat, "Quat rotation axis angle" ); + a_Quat = Quat::rotationX( randfloat() ); + print( a_Quat, "Quat rotationX" ); + a_Quat = Quat::rotationY( randfloat() ); + print( a_Quat, "Quat rotationY" ); + a_Quat = Quat::rotationZ( randfloat() ); + print( a_Quat, "Quat rotationZ" ); + print( rotate( a_Quat, a_Vector3 ), "Quat rotate Vector3" ); + print( conj( a_Quat ), "Quat conj" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + b_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + e_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + b_Quat = normalize( b_Quat ); + c_Quat = normalize( c_Quat ); + d_Quat = normalize( d_Quat ); + e_Quat = normalize( e_Quat ); + a_Quat = lerp( randfloat(), b_Quat, c_Quat ); + print( a_Quat, "Quat lerp" ); + a_Quat = slerp( randfloat(), b_Quat, c_Quat ); + print( a_Quat, "Quat slerp" ); + a_Quat = squad( randfloat(), b_Quat, c_Quat, d_Quat, e_Quat ); + print( a_Quat, "Quat squad" ); +} + +int main() +{ + printf("\n __begin__ \n"); + for ( iteration = 0; iteration < 2; iteration++ ) { + Vector3_methods_test(); + Vector4_methods_test(); + Point3_methods_test(); + Quat_methods_test(); + } + printf("\n __end__ \n"); + return 0; +} diff --git a/vectormathlibrary/tests/test1_soa_c.c b/vectormathlibrary/tests/test1_soa_c.c new file mode 100644 index 000000000..26dc33771 --- /dev/null +++ b/vectormathlibrary/tests/test1_soa_c.c @@ -0,0 +1,1006 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _VECTORMATH_SOA_TEST + +#include "vectormath_soa.h" +#include "test.h" + +int iteration = 0; + +void +Vector3_methods_test() +{ + VmathSoaVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3, e_Vector3; + VmathSoaVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4, e_Vector4; + VmathSoaPoint3 a_Point3, b_Point3, c_Point3, d_Point3, e_Point3; + VmathSoaQuat a_Quat, b_Quat, c_Quat, d_Quat, e_Quat; + VmathVector3 aos_Vector3_0, aos_Vector3_1, aos_Vector3_2, aos_Vector3_3; + VmathSoaVector3 soa_Vector3; + VmathVector4 aos_Vector4_0, aos_Vector4_1, aos_Vector4_2; + VmathSoaVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3; + VmathSoaPoint3 tmpP3_0; + VmathSoaVector3 tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7, tmpV3_8, tmpV3_9, tmpV3_10, tmpV3_11, tmpV3_12, tmpV3_13, tmpV3_14, tmpV3_15, tmpV3_16, tmpV3_17, tmpV3_18, tmpV3_19; + vec_float4 rndflt1, rndflt2, rndflt3, rndflt4; + float xyz4[12] __attribute__ ((aligned(16))); + xyz4[0] = getfloat(randfloat()); + xyz4[1] = getfloat(randfloat()); + xyz4[2] = getfloat(randfloat()); + xyz4[3] = getfloat(randfloat()); + xyz4[4] = getfloat(randfloat()); + xyz4[5] = getfloat(randfloat()); + xyz4[6] = getfloat(randfloat()); + xyz4[7] = getfloat(randfloat()); + xyz4[8] = getfloat(randfloat()); + xyz4[9] = getfloat(randfloat()); + xyz4[10] = getfloat(randfloat()); + xyz4[11] = getfloat(randfloat()); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &b_Vector3, rndflt1, rndflt2, rndflt3 ); + vmathSoaV3Prints( &a_Vector3, "set Vector3 with floats" ); + vmathSoaV3Prints( &b_Vector3, "set Vector3 with floats" ); + vmathSoaV3MakeFromScalar( &c_Vector3, (vec_float4){0.0f} ); + vmathSoaV3MakeFromScalar( &d_Vector3, (vec_float4){0.0f} ); + vmathSoaV3MakeFromScalar( &e_Vector3, (vec_float4){0.0f} ); + vmathSoaV3Prints( &c_Vector3, "set Vector3 elements to zero" ); + vmathSoaV3Prints( &d_Vector3, "set Vector3 elements to zero" ); + vmathSoaV3Prints( &e_Vector3, "set Vector3 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &b_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathSoaV4Prints( &a_Vector4, "set Vector4 with floats" ); + vmathSoaV4Prints( &b_Vector4, "set Vector4 with floats" ); + vmathSoaV4MakeFromScalar( &c_Vector4, (vec_float4){0.0f} ); + vmathSoaV4MakeFromScalar( &d_Vector4, (vec_float4){0.0f} ); + vmathSoaV4MakeFromScalar( &e_Vector4, (vec_float4){0.0f} ); + vmathSoaV4Prints( &c_Vector4, "set Vector4 elements to zero" ); + vmathSoaV4Prints( &d_Vector4, "set Vector4 elements to zero" ); + vmathSoaV4Prints( &e_Vector4, "set Vector4 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &b_Point3, rndflt1, rndflt2, rndflt3 ); + vmathSoaP3Prints( &a_Point3, "set Point3 with floats" ); + vmathSoaP3Prints( &b_Point3, "set Point3 with floats" ); + vmathSoaP3MakeFromScalar( &c_Point3, (vec_float4){0.0f} ); + vmathSoaP3MakeFromScalar( &d_Point3, (vec_float4){0.0f} ); + vmathSoaP3MakeFromScalar( &e_Point3, (vec_float4){0.0f} ); + vmathSoaP3Prints( &c_Point3, "set Point3 elements to zero" ); + vmathSoaP3Prints( &d_Point3, "set Point3 elements to zero" ); + vmathSoaP3Prints( &e_Point3, "set Point3 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &b_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathSoaQPrints( &a_Quat, "set Quat with floats" ); + vmathSoaQPrints( &b_Quat, "set Quat with floats" ); + vmathSoaQMakeFromScalar( &c_Quat, (vec_float4){0.0f} ); + vmathSoaQMakeFromScalar( &d_Quat, (vec_float4){0.0f} ); + vmathSoaQMakeFromScalar( &e_Quat, (vec_float4){0.0f} ); + vmathSoaQPrints( &c_Quat, "set Quat elements to zero" ); + vmathSoaQPrints( &d_Quat, "set Quat elements to zero" ); + vmathSoaQPrints( &e_Quat, "set Quat elements to zero" ); + vmathSoaV3MakeFromP3( &a_Vector3, &a_Point3 ); + vmathSoaV3Prints( &a_Vector3, "construct Vector3 with Point3" ); + vmathSoaV3MakeFromScalar( &a_Vector3, randfloat() ); + vmathSoaV3Prints( &a_Vector3, "set Vector3 with float" ); + vmathSoaV3MakeFromScalar( &a_Vector3, randfloat() ); + vmathSoaV3Prints( &a_Vector3, "set Vector3 with float" ); + vmathV3MakeFromElems( &aos_Vector3_0, 0.0f, 1.0f, 2.0f ); + vmathV3MakeFromElems( &aos_Vector3_1, 3.0f, 4.0f, 5.0f ); + vmathV3MakeFromElems( &aos_Vector3_2, 6.0f, 7.0f, 8.0f ); + vmathV3MakeFromElems( &aos_Vector3_3, 9.0f, 10.0f, 11.0f ); + vmathSoaV3MakeFrom4Aos( &soa_Vector3, &aos_Vector3_0, &aos_Vector3_1, &aos_Vector3_2, &aos_Vector3_3 ); + vmathSoaV3Get4Aos( &soa_Vector3, &aos_Vector3_3, &aos_Vector3_2, &aos_Vector3_1, &aos_Vector3_0 ); + vmathV3Prints( &aos_Vector3_0, "aos type 0" ); + vmathV3Prints( &aos_Vector3_1, "aos type 1" ); + vmathV3Prints( &aos_Vector3_2, "aos type 2" ); + vmathV3Prints( &aos_Vector3_3, "aos type 3" ); + vmathSoaV3Select( &a_Vector3, &a_Vector3, &b_Vector3, ((vec_uint4){0,0xffffffff,0,0xffffffff}) ); + vmathSoaV3Get4Aos( &a_Vector3, &aos_Vector3_0, &aos_Vector3_1, &aos_Vector3_2, &aos_Vector3_3 ); + vmathV3Prints( &aos_Vector3_0, "select 0" ); + vmathV3Prints( &aos_Vector3_1, "select 1" ); + vmathV3Prints( &aos_Vector3_2, "select 2" ); + vmathV3Prints( &aos_Vector3_3, "select 3" ); + vmathSoaV3LoadXYZArray( &a_Vector3, (const vec_float4 *)xyz4 ); + vmathSoaV3Prints( &a_Vector3, "load XYZ array" ); + vmathSoaV3Copy( &tmpV3_0, &a_Vector3 ); + vmathSoaV3Neg( &tmpV3_1, &tmpV3_0 ); + vmathSoaV3Copy( &a_Vector3, &tmpV3_1 ); + vmathSoaV3StoreXYZArray( &a_Vector3, (vec_float4 *)xyz4 ); + vmathV4MakeFromElems( &aos_Vector4_0, xyz4[0], xyz4[1], xyz4[2], xyz4[3] ); + vmathV4MakeFromElems( &aos_Vector4_1, xyz4[4], xyz4[5], xyz4[6], xyz4[7] ); + vmathV4MakeFromElems( &aos_Vector4_2, xyz4[8], xyz4[9], xyz4[10], xyz4[11] ); + vmathV4Prints( &aos_Vector4_0, "xyzx" ); + vmathV4Prints( &aos_Vector4_1, "yzxy" ); + vmathV4Prints( &aos_Vector4_2, "zxyz" ); + vmathV4Prints( &aos_Vector4_0, "xyzx" ); + vmathV4Prints( &aos_Vector4_1, "yzxy" ); + vmathV4Prints( &aos_Vector4_2, "zxyz" ); + printf("storeXYZ:-1.0 -2.0 -3.0 0.4\n"); + vmathSoaV3Copy( &a_Vector3, &b_Vector3 ); + vmathSoaV3Prints( &a_Vector3, "assign to Vector3 from Vector3" ); + vmathSoaV3MakeFromScalar( &a_Vector3, (vec_float4){0.0f} ); + vmathSoaV3Prints( &a_Vector3, "set Vector3 elements to zero" ); + vmathSoaV3MakeXAxis( &a_Vector3 ); + vmathSoaV3Prints( &a_Vector3, "set to x axis" ); + vmathSoaV3MakeYAxis( &a_Vector3 ); + vmathSoaV3Prints( &a_Vector3, "set to y axis" ); + vmathSoaV3MakeZAxis( &a_Vector3 ); + vmathSoaV3Prints( &a_Vector3, "set to z axis" ); + vmathSoaV3SetElem( &a_Vector3, 0, randfloat() ); + vmathSoaV3Prints( &a_Vector3, "Vector3::set( 0, float )" ); + vmathSoaV3SetElem( &a_Vector3, 0, randfloat() ); + vmathSoaV3SetElem( &a_Vector3, 0, vec_mul_float( vmathSoaV3GetElem( &a_Vector3, 0 ), randfloat() ) ); + vmathSoaV3SetElem( &a_Vector3, 0, divf4( vmathSoaV3GetElem( &a_Vector3, 0 ), randfloat() ) ); + vmathSoaV3SetElem( &a_Vector3, 0, vec_add_float( vmathSoaV3GetElem( &a_Vector3, 0 ), randfloat() ) ); + vmathSoaV3SetElem( &a_Vector3, 0, vec_sub_float( vmathSoaV3GetElem( &a_Vector3, 0 ), randfloat() ) ); + vmathSoaV3Prints( &a_Vector3, "Vector3::operator [](0)" ); + vmathSoaV3SetX( &a_Vector3, randfloat() ); + vmathSoaV3Prints( &a_Vector3, "Vector3::setX()" ); + vmathSoaV3SetElem( &a_Vector3, 1, randfloat() ); + vmathSoaV3Prints( &a_Vector3, "Vector3::set( 1, float )" ); + vmathSoaV3SetElem( &a_Vector3, 1, randfloat() ); + vmathSoaV3SetElem( &a_Vector3, 1, vec_mul_float( vmathSoaV3GetElem( &a_Vector3, 1 ), randfloat() ) ); + vmathSoaV3SetElem( &a_Vector3, 1, divf4( vmathSoaV3GetElem( &a_Vector3, 1 ), randfloat() ) ); + vmathSoaV3SetElem( &a_Vector3, 1, vec_add_float( vmathSoaV3GetElem( &a_Vector3, 1 ), randfloat() ) ); + vmathSoaV3SetElem( &a_Vector3, 1, vec_sub_float( vmathSoaV3GetElem( &a_Vector3, 1 ), randfloat() ) ); + vmathSoaV3Prints( &a_Vector3, "Vector3::operator [](1)" ); + vmathSoaV3SetY( &a_Vector3, randfloat() ); + vmathSoaV3Prints( &a_Vector3, "Vector3::setY()" ); + vmathSoaV3SetElem( &a_Vector3, 2, randfloat() ); + vmathSoaV3Prints( &a_Vector3, "Vector3::set( 2, float )" ); + vmathSoaV3SetElem( &a_Vector3, 2, randfloat() ); + vmathSoaV3SetElem( &a_Vector3, 2, vec_mul_float( vmathSoaV3GetElem( &a_Vector3, 2 ), randfloat() ) ); + vmathSoaV3SetElem( &a_Vector3, 2, divf4( vmathSoaV3GetElem( &a_Vector3, 2 ), randfloat() ) ); + vmathSoaV3SetElem( &a_Vector3, 2, vec_add_float( vmathSoaV3GetElem( &a_Vector3, 2 ), randfloat() ) ); + vmathSoaV3SetElem( &a_Vector3, 2, vec_sub_float( vmathSoaV3GetElem( &a_Vector3, 2 ), randfloat() ) ); + vmathSoaV3Prints( &a_Vector3, "Vector3::operator [](2)" ); + vmathSoaV3SetZ( &a_Vector3, randfloat() ); + vmathSoaV3Prints( &a_Vector3, "Vector3::setZ()" ); + printf("Vector3::get( 0 ): %f\n", getfloat(vmathSoaV3GetElem( &a_Vector3, 0 )) ); + printf("Vector3::operator []( 0 ): %f\n", getfloat(vmathSoaV3GetElem( &a_Vector3, 0 )) ); + printf("Vector3::getX(): %f\n", getfloat(vmathSoaV3GetX( &a_Vector3 )) ); + printf("Vector3::get( 1 ): %f\n", getfloat(vmathSoaV3GetElem( &a_Vector3, 1 )) ); + printf("Vector3::operator []( 1 ): %f\n", getfloat(vmathSoaV3GetElem( &a_Vector3, 1 )) ); + printf("Vector3::getY(): %f\n", getfloat(vmathSoaV3GetY( &a_Vector3 )) ); + printf("Vector3::get( 2 ): %f\n", getfloat(vmathSoaV3GetElem( &a_Vector3, 2 )) ); + printf("Vector3::operator []( 2 ): %f\n", getfloat(vmathSoaV3GetElem( &a_Vector3, 2 )) ); + printf("Vector3::getZ(): %f\n", getfloat(vmathSoaV3GetZ( &a_Vector3 )) ); + vmathSoaV3Add( &tmpV3_2, &a_Vector3, &b_Vector3 ); + vmathSoaV3Prints( &tmpV3_2, "Vector3 + Vector3" ); + vmathSoaV3Sub( &tmpV3_3, &a_Vector3, &b_Vector3 ); + vmathSoaV3Prints( &tmpV3_3, "Vector3 - Vector3" ); + vmathSoaV3AddP3( &tmpP3_0, &a_Vector3, &b_Point3 ); + vmathSoaP3Prints( &tmpP3_0, "Vector3 + Point3" ); + vmathSoaV3ScalarMul( &tmpV3_4, &a_Vector3, randfloat() ); + vmathSoaV3Prints( &tmpV3_4, "Vector3 * float" ); + vmathSoaV3ScalarDiv( &tmpV3_5, &a_Vector3, randfloat() ); + vmathSoaV3Prints( &tmpV3_5, "Vector3 / float" ); + vmathSoaV3ScalarMul( &tmpV3_6, &a_Vector3, randfloat() ); + vmathSoaV3Prints( &tmpV3_6, "float * Vector3" ); + vmathSoaV3Neg( &tmpV3_7, &a_Vector3 ); + vmathSoaV3Prints( &tmpV3_7, "Vector3 negate" ); + vmathSoaV3MulPerElem( &tmpV3_8, &a_Vector3, &b_Vector3 ); + vmathSoaV3Prints( &tmpV3_8, "mulPerElem( Vector3, Vector3 )" ); + vmathSoaV3DivPerElem( &tmpV3_9, &a_Vector3, &b_Vector3 ); + vmathSoaV3Prints( &tmpV3_9, "divPerElem( Vector3, Vector3 )" ); + vmathSoaV3RecipPerElem( &tmpV3_10, &a_Vector3 ); + vmathSoaV3Prints( &tmpV3_10, "Vector3 recip" ); + vmathSoaV3AbsPerElem( &tmpV3_11, &a_Vector3 ); + vmathSoaV3SqrtPerElem( &tmpV3_12, &tmpV3_11 ); + vmathSoaV3Prints( &tmpV3_12, "Vector3 sqrt" ); + vmathSoaV3AbsPerElem( &tmpV3_13, &a_Vector3 ); + vmathSoaV3RsqrtPerElem( &tmpV3_14, &tmpV3_13 ); + vmathSoaV3Prints( &tmpV3_14, "Vector3 rsqrt" ); + vmathSoaV3AbsPerElem( &tmpV3_15, &a_Vector3 ); + vmathSoaV3Prints( &tmpV3_15, "Vector3 abs" ); + vmathSoaV3CopySignPerElem( &tmpV3_16, &a_Vector3, &b_Vector3 ); + vmathSoaV3Prints( &tmpV3_16, "Vector3 copySign" ); + vmathSoaV3MaxPerElem( &tmpV3_17, &a_Vector3, &b_Vector3 ); + vmathSoaV3Prints( &tmpV3_17, "Vector3 maximum Vector3" ); + vmathSoaV3MinPerElem( &tmpV3_18, &a_Vector3, &b_Vector3 ); + vmathSoaV3Prints( &tmpV3_18, "Vector3 minimum Vector3" ); + printf("Vector3 maximum of elements: %f\n", getfloat(vmathSoaV3MaxElem( &a_Vector3 ))); + printf("Vector3 minimum of elements: %f\n", getfloat(vmathSoaV3MinElem( &a_Vector3 ))); + printf("Vector3 sum of elements: %f\n", getfloat(vmathSoaV3Sum( &a_Vector3 ))); + printf("Vector3 dot Vector3: %f\n", getfloat(vmathSoaV3Dot( &a_Vector3, &b_Vector3 ))); + printf("Vector3 lengthSqr: %f\n", getfloat(vmathSoaV3LengthSqr( &a_Vector3 ))); + printf("Vector3 length: %f\n", getfloat(vmathSoaV3Length( &a_Vector3 ))); + vmathSoaV3Normalize( &tmpV3_19, &a_Vector3 ); + vmathSoaV3Prints( &tmpV3_19, "Vector3 normalized" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &b_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &e_Vector3, rndflt1, rndflt2, rndflt3 ); + vmathSoaV3Normalize( &b_Vector3, &b_Vector3 ); + vmathSoaV3Normalize( &c_Vector3, &c_Vector3 ); + vmathSoaV3Normalize( &d_Vector3, &d_Vector3 ); + vmathSoaV3Normalize( &e_Vector3, &e_Vector3 ); + vmathSoaV3Lerp( &a_Vector3, randfloat(), &b_Vector3, &c_Vector3 ); + vmathSoaV3Prints( &a_Vector3, "Vector3 lerp" ); + vmathSoaV3Slerp( &a_Vector3, randfloat(), &b_Vector3, &c_Vector3 ); + vmathSoaV3Prints( &a_Vector3, "Vector3 slerp" ); +} + +void +Vector4_methods_test() +{ + VmathSoaVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3, e_Vector3; + VmathSoaVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4, e_Vector4; + VmathSoaPoint3 a_Point3, b_Point3, c_Point3, d_Point3, e_Point3; + VmathSoaQuat a_Quat, b_Quat, c_Quat, d_Quat, e_Quat; + VmathVector4 aos_Vector4_0, aos_Vector4_1, aos_Vector4_2, aos_Vector4_3; + VmathSoaVector4 soa_Vector4; + VmathSoaVector3 tmpV3_0; + VmathSoaVector4 tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3, tmpV4_4, tmpV4_5, tmpV4_6, tmpV4_7, tmpV4_8, tmpV4_9, tmpV4_10, tmpV4_11, tmpV4_12, tmpV4_13, tmpV4_14, tmpV4_15, tmpV4_16, tmpV4_17; + vec_float4 rndflt1, rndflt2, rndflt3, rndflt4; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &b_Vector3, rndflt1, rndflt2, rndflt3 ); + vmathSoaV3Prints( &a_Vector3, "set Vector3 with floats" ); + vmathSoaV3Prints( &b_Vector3, "set Vector3 with floats" ); + vmathSoaV3MakeFromScalar( &c_Vector3, (vec_float4){0.0f} ); + vmathSoaV3MakeFromScalar( &d_Vector3, (vec_float4){0.0f} ); + vmathSoaV3MakeFromScalar( &e_Vector3, (vec_float4){0.0f} ); + vmathSoaV3Prints( &c_Vector3, "set Vector3 elements to zero" ); + vmathSoaV3Prints( &d_Vector3, "set Vector3 elements to zero" ); + vmathSoaV3Prints( &e_Vector3, "set Vector3 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &b_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathSoaV4Prints( &a_Vector4, "set Vector4 with floats" ); + vmathSoaV4Prints( &b_Vector4, "set Vector4 with floats" ); + vmathSoaV4MakeFromScalar( &c_Vector4, (vec_float4){0.0f} ); + vmathSoaV4MakeFromScalar( &d_Vector4, (vec_float4){0.0f} ); + vmathSoaV4MakeFromScalar( &e_Vector4, (vec_float4){0.0f} ); + vmathSoaV4Prints( &c_Vector4, "set Vector4 elements to zero" ); + vmathSoaV4Prints( &d_Vector4, "set Vector4 elements to zero" ); + vmathSoaV4Prints( &e_Vector4, "set Vector4 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &b_Point3, rndflt1, rndflt2, rndflt3 ); + vmathSoaP3Prints( &a_Point3, "set Point3 with floats" ); + vmathSoaP3Prints( &b_Point3, "set Point3 with floats" ); + vmathSoaP3MakeFromScalar( &c_Point3, (vec_float4){0.0f} ); + vmathSoaP3MakeFromScalar( &d_Point3, (vec_float4){0.0f} ); + vmathSoaP3MakeFromScalar( &e_Point3, (vec_float4){0.0f} ); + vmathSoaP3Prints( &c_Point3, "set Point3 elements to zero" ); + vmathSoaP3Prints( &d_Point3, "set Point3 elements to zero" ); + vmathSoaP3Prints( &e_Point3, "set Point3 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &b_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathSoaQPrints( &a_Quat, "set Quat with floats" ); + vmathSoaQPrints( &b_Quat, "set Quat with floats" ); + vmathSoaQMakeFromScalar( &c_Quat, (vec_float4){0.0f} ); + vmathSoaQMakeFromScalar( &d_Quat, (vec_float4){0.0f} ); + vmathSoaQMakeFromScalar( &e_Quat, (vec_float4){0.0f} ); + vmathSoaQPrints( &c_Quat, "set Quat elements to zero" ); + vmathSoaQPrints( &d_Quat, "set Quat elements to zero" ); + vmathSoaQPrints( &e_Quat, "set Quat elements to zero" ); + vmathSoaV4MakeFromV3Scalar( &a_Vector4, &a_Vector3, randfloat() ); + vmathSoaV4Prints( &a_Vector4, "set Vector4 with Vector3, float" ); + vmathSoaV4MakeFromV3( &a_Vector4, &a_Vector3 ); + vmathSoaV4Prints( &a_Vector4, "set Vector4 with Vector3" ); + vmathSoaV4MakeFromP3( &a_Vector4, &a_Point3 ); + vmathSoaV4Prints( &a_Vector4, "set Vector4 with Point3" ); + vmathSoaV4MakeFromQ( &a_Vector4, &a_Quat ); + vmathSoaV4Prints( &a_Vector4, "construct Vector4 with Quat" ); + vmathSoaV4MakeFromScalar( &a_Vector4, randfloat() ); + vmathSoaV4Prints( &a_Vector4, "set Vector4 with float" ); + vmathSoaV4MakeFromScalar( &a_Vector4, randfloat() ); + vmathSoaV4Prints( &a_Vector4, "set Vector4 with float" ); + vmathV4MakeFromElems( &aos_Vector4_0, 0.0f, 1.0f, 2.0f, 3.0f ); + vmathV4MakeFromElems( &aos_Vector4_1, 4.0f, 5.0f, 6.0f, 7.0f ); + vmathV4MakeFromElems( &aos_Vector4_2, 8.0f, 9.0f, 10.0f, 11.0f ); + vmathV4MakeFromElems( &aos_Vector4_3, 12.0f, 13.0f, 14.0f, 15.0f ); + vmathSoaV4MakeFrom4Aos( &soa_Vector4, &aos_Vector4_0, &aos_Vector4_1, &aos_Vector4_2, &aos_Vector4_3 ); + vmathSoaV4Get4Aos( &soa_Vector4, &aos_Vector4_3, &aos_Vector4_2, &aos_Vector4_1, &aos_Vector4_0 ); + vmathV4Prints( &aos_Vector4_0, "aos type 0" ); + vmathV4Prints( &aos_Vector4_1, "aos type 1" ); + vmathV4Prints( &aos_Vector4_2, "aos type 2" ); + vmathV4Prints( &aos_Vector4_3, "aos type 3" ); + vmathSoaV4Select( &a_Vector4, &a_Vector4, &b_Vector4, ((vec_uint4){0,0xffffffff,0,0xffffffff}) ); + vmathSoaV4Get4Aos( &a_Vector4, &aos_Vector4_0, &aos_Vector4_1, &aos_Vector4_2, &aos_Vector4_3 ); + vmathV4Prints( &aos_Vector4_0, "select 0" ); + vmathV4Prints( &aos_Vector4_1, "select 1" ); + vmathV4Prints( &aos_Vector4_2, "select 2" ); + vmathV4Prints( &aos_Vector4_3, "select 3" ); + vmathSoaV4Copy( &a_Vector4, &b_Vector4 ); + vmathSoaV4Prints( &a_Vector4, "assign to Vector4 from Vector4" ); + vmathSoaV4SetXYZ( &a_Vector4, &a_Vector3 ); + vmathSoaV4Prints( &a_Vector4, "set Vector4 xyz" ); + vmathSoaV4GetXYZ( &tmpV3_0, &a_Vector4 ); + vmathSoaV3Prints( &tmpV3_0, "get Vector4 xyz" ); + vmathSoaV4MakeFromScalar( &a_Vector4, (vec_float4){0.0f} ); + vmathSoaV4Prints( &a_Vector4, "set Vector4 elements to zero" ); + vmathSoaV4MakeXAxis( &a_Vector4 ); + vmathSoaV4Prints( &a_Vector4, "set to x axis" ); + vmathSoaV4MakeYAxis( &a_Vector4 ); + vmathSoaV4Prints( &a_Vector4, "set to y axis" ); + vmathSoaV4MakeZAxis( &a_Vector4 ); + vmathSoaV4Prints( &a_Vector4, "set to z axis" ); + vmathSoaV4MakeWAxis( &a_Vector4 ); + vmathSoaV4Prints( &a_Vector4, "set to w axis" ); + vmathSoaV4SetElem( &a_Vector4, 0, randfloat() ); + vmathSoaV4Prints( &a_Vector4, "Vector4::set( 0, float )" ); + vmathSoaV4SetElem( &a_Vector4, 0, randfloat() ); + vmathSoaV4SetElem( &a_Vector4, 0, vec_mul_float( vmathSoaV4GetElem( &a_Vector4, 0 ), randfloat() ) ); + vmathSoaV4SetElem( &a_Vector4, 0, divf4( vmathSoaV4GetElem( &a_Vector4, 0 ), randfloat() ) ); + vmathSoaV4SetElem( &a_Vector4, 0, vec_add_float( vmathSoaV4GetElem( &a_Vector4, 0 ), randfloat() ) ); + vmathSoaV4SetElem( &a_Vector4, 0, vec_sub_float( vmathSoaV4GetElem( &a_Vector4, 0 ), randfloat() ) ); + vmathSoaV4Prints( &a_Vector4, "Vector4::operator [](0)" ); + vmathSoaV4SetX( &a_Vector4, randfloat() ); + vmathSoaV4Prints( &a_Vector4, "Vector4::setX()" ); + vmathSoaV4SetElem( &a_Vector4, 1, randfloat() ); + vmathSoaV4Prints( &a_Vector4, "Vector4::set( 1, float )" ); + vmathSoaV4SetElem( &a_Vector4, 1, randfloat() ); + vmathSoaV4SetElem( &a_Vector4, 1, vec_mul_float( vmathSoaV4GetElem( &a_Vector4, 1 ), randfloat() ) ); + vmathSoaV4SetElem( &a_Vector4, 1, divf4( vmathSoaV4GetElem( &a_Vector4, 1 ), randfloat() ) ); + vmathSoaV4SetElem( &a_Vector4, 1, vec_add_float( vmathSoaV4GetElem( &a_Vector4, 1 ), randfloat() ) ); + vmathSoaV4SetElem( &a_Vector4, 1, vec_sub_float( vmathSoaV4GetElem( &a_Vector4, 1 ), randfloat() ) ); + vmathSoaV4Prints( &a_Vector4, "Vector4::operator [](1)" ); + vmathSoaV4SetY( &a_Vector4, randfloat() ); + vmathSoaV4Prints( &a_Vector4, "Vector4::setY()" ); + vmathSoaV4SetElem( &a_Vector4, 2, randfloat() ); + vmathSoaV4Prints( &a_Vector4, "Vector4::set( 2, float )" ); + vmathSoaV4SetElem( &a_Vector4, 2, randfloat() ); + vmathSoaV4SetElem( &a_Vector4, 2, vec_mul_float( vmathSoaV4GetElem( &a_Vector4, 2 ), randfloat() ) ); + vmathSoaV4SetElem( &a_Vector4, 2, divf4( vmathSoaV4GetElem( &a_Vector4, 2 ), randfloat() ) ); + vmathSoaV4SetElem( &a_Vector4, 2, vec_add_float( vmathSoaV4GetElem( &a_Vector4, 2 ), randfloat() ) ); + vmathSoaV4SetElem( &a_Vector4, 2, vec_sub_float( vmathSoaV4GetElem( &a_Vector4, 2 ), randfloat() ) ); + vmathSoaV4Prints( &a_Vector4, "Vector4::operator [](2)" ); + vmathSoaV4SetZ( &a_Vector4, randfloat() ); + vmathSoaV4Prints( &a_Vector4, "Vector4::setZ()" ); + vmathSoaV4SetElem( &a_Vector4, 3, randfloat() ); + vmathSoaV4Prints( &a_Vector4, "Vector4::set( 3, float )" ); + vmathSoaV4SetElem( &a_Vector4, 3, randfloat() ); + vmathSoaV4SetElem( &a_Vector4, 3, vec_mul_float( vmathSoaV4GetElem( &a_Vector4, 3 ), randfloat() ) ); + vmathSoaV4SetElem( &a_Vector4, 3, divf4( vmathSoaV4GetElem( &a_Vector4, 3 ), randfloat() ) ); + vmathSoaV4SetElem( &a_Vector4, 3, vec_add_float( vmathSoaV4GetElem( &a_Vector4, 3 ), randfloat() ) ); + vmathSoaV4SetElem( &a_Vector4, 3, vec_sub_float( vmathSoaV4GetElem( &a_Vector4, 3 ), randfloat() ) ); + vmathSoaV4Prints( &a_Vector4, "Vector4::operator [](3)" ); + vmathSoaV4SetW( &a_Vector4, randfloat() ); + vmathSoaV4Prints( &a_Vector4, "Vector4::setW()" ); + printf("Vector4::get( 0 ): %f\n", getfloat(vmathSoaV4GetElem( &a_Vector4, 0 )) ); + printf("Vector4::operator []( 0 ): %f\n", getfloat(vmathSoaV4GetElem( &a_Vector4, 0 )) ); + printf("Vector4::getX(): %f\n", getfloat(vmathSoaV4GetX( &a_Vector4 )) ); + printf("Vector4::get( 1 ): %f\n", getfloat(vmathSoaV4GetElem( &a_Vector4, 1 )) ); + printf("Vector4::operator []( 1 ): %f\n", getfloat(vmathSoaV4GetElem( &a_Vector4, 1 )) ); + printf("Vector4::getY(): %f\n", getfloat(vmathSoaV4GetY( &a_Vector4 )) ); + printf("Vector4::get( 2 ): %f\n", getfloat(vmathSoaV4GetElem( &a_Vector4, 2 )) ); + printf("Vector4::operator []( 2 ): %f\n", getfloat(vmathSoaV4GetElem( &a_Vector4, 2 )) ); + printf("Vector4::getZ(): %f\n", getfloat(vmathSoaV4GetZ( &a_Vector4 )) ); + printf("Vector4::get( 3 ): %f\n", getfloat(vmathSoaV4GetElem( &a_Vector4, 3 )) ); + printf("Vector4::operator []( 3 ): %f\n", getfloat(vmathSoaV4GetElem( &a_Vector4, 3 )) ); + printf("Vector4::getW(): %f\n", getfloat(vmathSoaV4GetW( &a_Vector4 )) ); + vmathSoaV4Add( &tmpV4_0, &a_Vector4, &b_Vector4 ); + vmathSoaV4Prints( &tmpV4_0, "Vector4 + Vector4" ); + vmathSoaV4Sub( &tmpV4_1, &a_Vector4, &b_Vector4 ); + vmathSoaV4Prints( &tmpV4_1, "Vector4 - Vector4" ); + vmathSoaV4ScalarMul( &tmpV4_2, &a_Vector4, randfloat() ); + vmathSoaV4Prints( &tmpV4_2, "Vector4 * float" ); + vmathSoaV4ScalarDiv( &tmpV4_3, &a_Vector4, randfloat() ); + vmathSoaV4Prints( &tmpV4_3, "Vector4 / float" ); + vmathSoaV4ScalarMul( &tmpV4_4, &a_Vector4, randfloat() ); + vmathSoaV4Prints( &tmpV4_4, "float * Vector4" ); + vmathSoaV4Neg( &tmpV4_5, &a_Vector4 ); + vmathSoaV4Prints( &tmpV4_5, "Vector4 negate" ); + vmathSoaV4MulPerElem( &tmpV4_6, &a_Vector4, &b_Vector4 ); + vmathSoaV4Prints( &tmpV4_6, "mulPerElem( Vector4, Vector4 )" ); + vmathSoaV4DivPerElem( &tmpV4_7, &a_Vector4, &b_Vector4 ); + vmathSoaV4Prints( &tmpV4_7, "divPerElem( Vector4, Vector4 )" ); + vmathSoaV4RecipPerElem( &tmpV4_8, &a_Vector4 ); + vmathSoaV4Prints( &tmpV4_8, "Vector4 recip" ); + vmathSoaV4AbsPerElem( &tmpV4_9, &a_Vector4 ); + vmathSoaV4SqrtPerElem( &tmpV4_10, &tmpV4_9 ); + vmathSoaV4Prints( &tmpV4_10, "Vector4 sqrt" ); + vmathSoaV4AbsPerElem( &tmpV4_11, &a_Vector4 ); + vmathSoaV4RsqrtPerElem( &tmpV4_12, &tmpV4_11 ); + vmathSoaV4Prints( &tmpV4_12, "Vector4 rsqrt" ); + vmathSoaV4AbsPerElem( &tmpV4_13, &a_Vector4 ); + vmathSoaV4Prints( &tmpV4_13, "Vector4 abs" ); + vmathSoaV4CopySignPerElem( &tmpV4_14, &a_Vector4, &b_Vector4 ); + vmathSoaV4Prints( &tmpV4_14, "Vector4 copySign" ); + vmathSoaV4MaxPerElem( &tmpV4_15, &a_Vector4, &b_Vector4 ); + vmathSoaV4Prints( &tmpV4_15, "Vector4 maximum Vector4" ); + vmathSoaV4MinPerElem( &tmpV4_16, &a_Vector4, &b_Vector4 ); + vmathSoaV4Prints( &tmpV4_16, "Vector4 minimum Vector4" ); + printf("Vector4 maximum of elements: %f\n", getfloat(vmathSoaV4MaxElem( &a_Vector4 ))); + printf("Vector4 minimum of elements: %f\n", getfloat(vmathSoaV4MinElem( &a_Vector4 ))); + printf("Vector4 sum of elements: %f\n", getfloat(vmathSoaV4Sum( &a_Vector4 ))); + printf("Vector4 dot Vector4: %f\n", getfloat(vmathSoaV4Dot( &a_Vector4, &b_Vector4 ))); + printf("Vector4 lengthSqr: %f\n", getfloat(vmathSoaV4LengthSqr( &a_Vector4 ))); + printf("Vector4 length: %f\n", getfloat(vmathSoaV4Length( &a_Vector4 ))); + vmathSoaV4Normalize( &tmpV4_17, &a_Vector4 ); + vmathSoaV4Prints( &tmpV4_17, "Vector4 normalized" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &b_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &e_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathSoaV4Normalize( &b_Vector4, &b_Vector4 ); + vmathSoaV4Normalize( &c_Vector4, &c_Vector4 ); + vmathSoaV4Normalize( &d_Vector4, &d_Vector4 ); + vmathSoaV4Normalize( &e_Vector4, &e_Vector4 ); + vmathSoaV4Lerp( &a_Vector4, randfloat(), &b_Vector4, &c_Vector4 ); + vmathSoaV4Prints( &a_Vector4, "Vector4 lerp" ); + vmathSoaV4Slerp( &a_Vector4, randfloat(), &b_Vector4, &c_Vector4 ); + vmathSoaV4Prints( &a_Vector4, "Vector4 slerp" ); +} + +void +Point3_methods_test() +{ + VmathSoaVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3, e_Vector3; + VmathSoaVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4, e_Vector4; + VmathSoaPoint3 a_Point3, b_Point3, c_Point3, d_Point3, e_Point3; + VmathSoaQuat a_Quat, b_Quat, c_Quat, d_Quat, e_Quat; + VmathPoint3 aos_Point3_0, aos_Point3_1, aos_Point3_2, aos_Point3_3; + VmathSoaPoint3 soa_Point3; + VmathVector4 aos_Vector4_0, aos_Vector4_1, aos_Vector4_2; + VmathSoaVector3 tmpV3_0, tmpV3_1, tmpV3_2; + VmathSoaPoint3 tmpP3_0, tmpP3_1, tmpP3_2, tmpP3_3, tmpP3_4, tmpP3_5, tmpP3_6, tmpP3_7, tmpP3_8, tmpP3_9, tmpP3_10, tmpP3_11, tmpP3_12; + vec_float4 rndflt1, rndflt2, rndflt3, rndflt4; + float xyz4[12] __attribute__ ((aligned(16))); + xyz4[0] = getfloat(randfloat()); + xyz4[1] = getfloat(randfloat()); + xyz4[2] = getfloat(randfloat()); + xyz4[3] = getfloat(randfloat()); + xyz4[4] = getfloat(randfloat()); + xyz4[5] = getfloat(randfloat()); + xyz4[6] = getfloat(randfloat()); + xyz4[7] = getfloat(randfloat()); + xyz4[8] = getfloat(randfloat()); + xyz4[9] = getfloat(randfloat()); + xyz4[10] = getfloat(randfloat()); + xyz4[11] = getfloat(randfloat()); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &b_Vector3, rndflt1, rndflt2, rndflt3 ); + vmathSoaV3Prints( &a_Vector3, "set Vector3 with floats" ); + vmathSoaV3Prints( &b_Vector3, "set Vector3 with floats" ); + vmathSoaV3MakeFromScalar( &c_Vector3, (vec_float4){0.0f} ); + vmathSoaV3MakeFromScalar( &d_Vector3, (vec_float4){0.0f} ); + vmathSoaV3MakeFromScalar( &e_Vector3, (vec_float4){0.0f} ); + vmathSoaV3Prints( &c_Vector3, "set Vector3 elements to zero" ); + vmathSoaV3Prints( &d_Vector3, "set Vector3 elements to zero" ); + vmathSoaV3Prints( &e_Vector3, "set Vector3 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &b_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathSoaV4Prints( &a_Vector4, "set Vector4 with floats" ); + vmathSoaV4Prints( &b_Vector4, "set Vector4 with floats" ); + vmathSoaV4MakeFromScalar( &c_Vector4, (vec_float4){0.0f} ); + vmathSoaV4MakeFromScalar( &d_Vector4, (vec_float4){0.0f} ); + vmathSoaV4MakeFromScalar( &e_Vector4, (vec_float4){0.0f} ); + vmathSoaV4Prints( &c_Vector4, "set Vector4 elements to zero" ); + vmathSoaV4Prints( &d_Vector4, "set Vector4 elements to zero" ); + vmathSoaV4Prints( &e_Vector4, "set Vector4 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &b_Point3, rndflt1, rndflt2, rndflt3 ); + vmathSoaP3Prints( &a_Point3, "set Point3 with floats" ); + vmathSoaP3Prints( &b_Point3, "set Point3 with floats" ); + vmathSoaP3MakeFromScalar( &c_Point3, (vec_float4){0.0f} ); + vmathSoaP3MakeFromScalar( &d_Point3, (vec_float4){0.0f} ); + vmathSoaP3MakeFromScalar( &e_Point3, (vec_float4){0.0f} ); + vmathSoaP3Prints( &c_Point3, "set Point3 elements to zero" ); + vmathSoaP3Prints( &d_Point3, "set Point3 elements to zero" ); + vmathSoaP3Prints( &e_Point3, "set Point3 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &b_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathSoaQPrints( &a_Quat, "set Quat with floats" ); + vmathSoaQPrints( &b_Quat, "set Quat with floats" ); + vmathSoaQMakeFromScalar( &c_Quat, (vec_float4){0.0f} ); + vmathSoaQMakeFromScalar( &d_Quat, (vec_float4){0.0f} ); + vmathSoaQMakeFromScalar( &e_Quat, (vec_float4){0.0f} ); + vmathSoaQPrints( &c_Quat, "set Quat elements to zero" ); + vmathSoaQPrints( &d_Quat, "set Quat elements to zero" ); + vmathSoaQPrints( &e_Quat, "set Quat elements to zero" ); + vmathSoaP3MakeFromV3( &a_Point3, &a_Vector3 ); + vmathSoaP3Prints( &a_Point3, "construct Point3 with Vector3" ); + vmathSoaP3MakeFromScalar( &a_Point3, randfloat() ); + vmathSoaP3Prints( &a_Point3, "set Point3 with float" ); + vmathSoaP3MakeFromScalar( &a_Point3, randfloat() ); + vmathSoaP3Prints( &a_Point3, "set Point3 with float" ); + vmathP3MakeFromElems( &aos_Point3_0, 0.0f, 1.0f, 2.0f ); + vmathP3MakeFromElems( &aos_Point3_1, 3.0f, 4.0f, 5.0f ); + vmathP3MakeFromElems( &aos_Point3_2, 6.0f, 7.0f, 8.0f ); + vmathP3MakeFromElems( &aos_Point3_3, 9.0f, 10.0f, 11.0f ); + vmathSoaP3MakeFrom4Aos( &soa_Point3, &aos_Point3_0, &aos_Point3_1, &aos_Point3_2, &aos_Point3_3 ); + vmathSoaP3Get4Aos( &soa_Point3, &aos_Point3_3, &aos_Point3_2, &aos_Point3_1, &aos_Point3_0 ); + vmathP3Prints( &aos_Point3_0, "aos type 0" ); + vmathP3Prints( &aos_Point3_1, "aos type 1" ); + vmathP3Prints( &aos_Point3_2, "aos type 2" ); + vmathP3Prints( &aos_Point3_3, "aos type 3" ); + vmathSoaP3Select( &a_Point3, &a_Point3, &b_Point3, ((vec_uint4){0,0xffffffff,0,0xffffffff}) ); + vmathSoaP3Get4Aos( &a_Point3, &aos_Point3_0, &aos_Point3_1, &aos_Point3_2, &aos_Point3_3 ); + vmathP3Prints( &aos_Point3_0, "select 0" ); + vmathP3Prints( &aos_Point3_1, "select 1" ); + vmathP3Prints( &aos_Point3_2, "select 2" ); + vmathP3Prints( &aos_Point3_3, "select 3" ); + vmathSoaP3LoadXYZArray( &a_Point3, (const vec_float4 *)xyz4 ); + vmathSoaP3Prints( &a_Point3, "load XYZ array" ); + vmathSoaV3MakeFromP3( &tmpV3_0, &a_Point3 ); + vmathSoaV3Neg( &tmpV3_1, &tmpV3_0 ); + vmathSoaP3MakeFromV3( &a_Point3, &tmpV3_1 ); + vmathSoaP3StoreXYZArray( &a_Point3, (vec_float4 *)xyz4 ); + vmathV4MakeFromElems( &aos_Vector4_0, xyz4[0], xyz4[1], xyz4[2], xyz4[3] ); + vmathV4MakeFromElems( &aos_Vector4_1, xyz4[4], xyz4[5], xyz4[6], xyz4[7] ); + vmathV4MakeFromElems( &aos_Vector4_2, xyz4[8], xyz4[9], xyz4[10], xyz4[11] ); + vmathV4Prints( &aos_Vector4_0, "xyzx" ); + vmathV4Prints( &aos_Vector4_1, "yzxy" ); + vmathV4Prints( &aos_Vector4_2, "zxyz" ); + vmathV4Prints( &aos_Vector4_0, "xyzx" ); + vmathV4Prints( &aos_Vector4_1, "yzxy" ); + vmathV4Prints( &aos_Vector4_2, "zxyz" ); + printf("storeXYZ:-1.0 -2.0 -3.0 0.4\n"); + vmathSoaP3Copy( &a_Point3, &b_Point3 ); + vmathSoaP3Prints( &a_Point3, "assign to Point3 from Point3" ); + vmathSoaP3MakeFromScalar( &a_Point3, (vec_float4){0.0f} ); + vmathSoaP3Prints( &a_Point3, "set Point3 elements to zero" ); + vmathSoaP3SetElem( &a_Point3, 0, randfloat() ); + vmathSoaP3Prints( &a_Point3, "Point3::set( 0, float )" ); + vmathSoaP3SetElem( &a_Point3, 0, randfloat() ); + vmathSoaP3SetElem( &a_Point3, 0, vec_mul_float( vmathSoaP3GetElem( &a_Point3, 0 ), randfloat() ) ); + vmathSoaP3SetElem( &a_Point3, 0, divf4( vmathSoaP3GetElem( &a_Point3, 0 ), randfloat() ) ); + vmathSoaP3SetElem( &a_Point3, 0, vec_add_float( vmathSoaP3GetElem( &a_Point3, 0 ), randfloat() ) ); + vmathSoaP3SetElem( &a_Point3, 0, vec_sub_float( vmathSoaP3GetElem( &a_Point3, 0 ), randfloat() ) ); + vmathSoaP3Prints( &a_Point3, "Point3::operator [](0)" ); + vmathSoaP3SetX( &a_Point3, randfloat() ); + vmathSoaP3Prints( &a_Point3, "Point3::setX()" ); + vmathSoaP3SetElem( &a_Point3, 1, randfloat() ); + vmathSoaP3Prints( &a_Point3, "Point3::set( 1, float )" ); + vmathSoaP3SetElem( &a_Point3, 1, randfloat() ); + vmathSoaP3SetElem( &a_Point3, 1, vec_mul_float( vmathSoaP3GetElem( &a_Point3, 1 ), randfloat() ) ); + vmathSoaP3SetElem( &a_Point3, 1, divf4( vmathSoaP3GetElem( &a_Point3, 1 ), randfloat() ) ); + vmathSoaP3SetElem( &a_Point3, 1, vec_add_float( vmathSoaP3GetElem( &a_Point3, 1 ), randfloat() ) ); + vmathSoaP3SetElem( &a_Point3, 1, vec_sub_float( vmathSoaP3GetElem( &a_Point3, 1 ), randfloat() ) ); + vmathSoaP3Prints( &a_Point3, "Point3::operator [](1)" ); + vmathSoaP3SetY( &a_Point3, randfloat() ); + vmathSoaP3Prints( &a_Point3, "Point3::setY()" ); + vmathSoaP3SetElem( &a_Point3, 2, randfloat() ); + vmathSoaP3Prints( &a_Point3, "Point3::set( 2, float )" ); + vmathSoaP3SetElem( &a_Point3, 2, randfloat() ); + vmathSoaP3SetElem( &a_Point3, 2, vec_mul_float( vmathSoaP3GetElem( &a_Point3, 2 ), randfloat() ) ); + vmathSoaP3SetElem( &a_Point3, 2, divf4( vmathSoaP3GetElem( &a_Point3, 2 ), randfloat() ) ); + vmathSoaP3SetElem( &a_Point3, 2, vec_add_float( vmathSoaP3GetElem( &a_Point3, 2 ), randfloat() ) ); + vmathSoaP3SetElem( &a_Point3, 2, vec_sub_float( vmathSoaP3GetElem( &a_Point3, 2 ), randfloat() ) ); + vmathSoaP3Prints( &a_Point3, "Point3::operator [](2)" ); + vmathSoaP3SetZ( &a_Point3, randfloat() ); + vmathSoaP3Prints( &a_Point3, "Point3::setZ()" ); + printf("Point3::get( 0 ): %f\n", getfloat(vmathSoaP3GetElem( &a_Point3, 0 )) ); + printf("Point3::operator []( 0 ): %f\n", getfloat(vmathSoaP3GetElem( &a_Point3, 0 )) ); + printf("Point3::getX(): %f\n", getfloat(vmathSoaP3GetX( &a_Point3 )) ); + printf("Point3::get( 1 ): %f\n", getfloat(vmathSoaP3GetElem( &a_Point3, 1 )) ); + printf("Point3::operator []( 1 ): %f\n", getfloat(vmathSoaP3GetElem( &a_Point3, 1 )) ); + printf("Point3::getY(): %f\n", getfloat(vmathSoaP3GetY( &a_Point3 )) ); + printf("Point3::get( 2 ): %f\n", getfloat(vmathSoaP3GetElem( &a_Point3, 2 )) ); + printf("Point3::operator []( 2 ): %f\n", getfloat(vmathSoaP3GetElem( &a_Point3, 2 )) ); + printf("Point3::getZ(): %f\n", getfloat(vmathSoaP3GetZ( &a_Point3 )) ); + vmathSoaP3Sub( &tmpV3_2, &a_Point3, &b_Point3 ); + vmathSoaV3Prints( &tmpV3_2, "Point3 - Point3" ); + vmathSoaP3AddV3( &tmpP3_0, &a_Point3, &b_Vector3 ); + vmathSoaP3Prints( &tmpP3_0, "Point3 + Vector3" ); + vmathSoaP3SubV3( &tmpP3_1, &a_Point3, &b_Vector3 ); + vmathSoaP3Prints( &tmpP3_1, "Point3 - Vector3" ); + vmathSoaP3MulPerElem( &tmpP3_2, &a_Point3, &b_Point3 ); + vmathSoaP3Prints( &tmpP3_2, "mulPerElem( Point3, Point3 )" ); + vmathSoaP3DivPerElem( &tmpP3_3, &a_Point3, &b_Point3 ); + vmathSoaP3Prints( &tmpP3_3, "divPerElem( Point3, Point3 )" ); + vmathSoaP3RecipPerElem( &tmpP3_4, &a_Point3 ); + vmathSoaP3Prints( &tmpP3_4, "Point3 recip" ); + vmathSoaP3AbsPerElem( &tmpP3_5, &a_Point3 ); + vmathSoaP3SqrtPerElem( &tmpP3_6, &tmpP3_5 ); + vmathSoaP3Prints( &tmpP3_6, "Point3 sqrt" ); + vmathSoaP3AbsPerElem( &tmpP3_7, &a_Point3 ); + vmathSoaP3RsqrtPerElem( &tmpP3_8, &tmpP3_7 ); + vmathSoaP3Prints( &tmpP3_8, "Point3 rsqrt" ); + vmathSoaP3AbsPerElem( &tmpP3_9, &a_Point3 ); + vmathSoaP3Prints( &tmpP3_9, "Point3 abs" ); + vmathSoaP3CopySignPerElem( &tmpP3_10, &a_Point3, &b_Point3 ); + vmathSoaP3Prints( &tmpP3_10, "Point3 copySign" ); + vmathSoaP3MaxPerElem( &tmpP3_11, &a_Point3, &b_Point3 ); + vmathSoaP3Prints( &tmpP3_11, "Point3 maximum Point3" ); + vmathSoaP3MinPerElem( &tmpP3_12, &a_Point3, &b_Point3 ); + vmathSoaP3Prints( &tmpP3_12, "Point3 minimum Point3" ); + printf("Point3 maximum of elements: %f\n", getfloat(vmathSoaP3MaxElem( &a_Point3 ))); + printf("Point3 minimum of elements: %f\n", getfloat(vmathSoaP3MinElem( &a_Point3 ))); + printf("Point3 sum of elements: %f\n", getfloat(vmathSoaP3Sum( &a_Point3 ))); + printf("Point projection: %f\n", getfloat(vmathSoaP3Projection( &a_Point3, &b_Vector3 ))); + printf("Point distSqrFromOrigin: %f\n", getfloat(vmathSoaP3DistSqrFromOrigin( &a_Point3 )) ); + printf("Point distFromOrigin: %f\n", getfloat(vmathSoaP3DistFromOrigin( &a_Point3 )) ); + printf("Point distSqr: %f\n", getfloat(vmathSoaP3DistSqr( &a_Point3, &b_Point3 )) ); + printf("Point dist: %f\n", getfloat(vmathSoaP3Dist( &a_Point3, &b_Point3 )) ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &b_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &e_Point3, rndflt1, rndflt2, rndflt3 ); + vmathSoaP3Lerp( &a_Point3, randfloat(), &b_Point3, &c_Point3 ); + vmathSoaP3Prints( &a_Point3, "Point3 lerp" ); +} + +void +Quat_methods_test() +{ + VmathSoaVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3, e_Vector3; + VmathSoaVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4, e_Vector4; + VmathSoaPoint3 a_Point3, b_Point3, c_Point3, d_Point3, e_Point3; + VmathSoaQuat a_Quat, b_Quat, c_Quat, d_Quat, e_Quat; + VmathQuat aos_Quat_0, aos_Quat_1, aos_Quat_2, aos_Quat_3; + VmathSoaQuat soa_Quat; + VmathSoaVector3 tmpV3_0; + VmathSoaQuat tmpQ_0, tmpQ_1, tmpQ_2, tmpQ_3, tmpQ_4, tmpQ_5, tmpQ_6, tmpQ_7; + VmathSoaVector3 tmpV3_1; + VmathSoaQuat tmpQ_8; + vec_float4 rndflt1, rndflt2, rndflt3, rndflt4; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &b_Vector3, rndflt1, rndflt2, rndflt3 ); + vmathSoaV3Prints( &a_Vector3, "set Vector3 with floats" ); + vmathSoaV3Prints( &b_Vector3, "set Vector3 with floats" ); + vmathSoaV3MakeFromScalar( &c_Vector3, (vec_float4){0.0f} ); + vmathSoaV3MakeFromScalar( &d_Vector3, (vec_float4){0.0f} ); + vmathSoaV3MakeFromScalar( &e_Vector3, (vec_float4){0.0f} ); + vmathSoaV3Prints( &c_Vector3, "set Vector3 elements to zero" ); + vmathSoaV3Prints( &d_Vector3, "set Vector3 elements to zero" ); + vmathSoaV3Prints( &e_Vector3, "set Vector3 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &b_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathSoaV4Prints( &a_Vector4, "set Vector4 with floats" ); + vmathSoaV4Prints( &b_Vector4, "set Vector4 with floats" ); + vmathSoaV4MakeFromScalar( &c_Vector4, (vec_float4){0.0f} ); + vmathSoaV4MakeFromScalar( &d_Vector4, (vec_float4){0.0f} ); + vmathSoaV4MakeFromScalar( &e_Vector4, (vec_float4){0.0f} ); + vmathSoaV4Prints( &c_Vector4, "set Vector4 elements to zero" ); + vmathSoaV4Prints( &d_Vector4, "set Vector4 elements to zero" ); + vmathSoaV4Prints( &e_Vector4, "set Vector4 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &b_Point3, rndflt1, rndflt2, rndflt3 ); + vmathSoaP3Prints( &a_Point3, "set Point3 with floats" ); + vmathSoaP3Prints( &b_Point3, "set Point3 with floats" ); + vmathSoaP3MakeFromScalar( &c_Point3, (vec_float4){0.0f} ); + vmathSoaP3MakeFromScalar( &d_Point3, (vec_float4){0.0f} ); + vmathSoaP3MakeFromScalar( &e_Point3, (vec_float4){0.0f} ); + vmathSoaP3Prints( &c_Point3, "set Point3 elements to zero" ); + vmathSoaP3Prints( &d_Point3, "set Point3 elements to zero" ); + vmathSoaP3Prints( &e_Point3, "set Point3 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &b_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathSoaQPrints( &a_Quat, "set Quat with floats" ); + vmathSoaQPrints( &b_Quat, "set Quat with floats" ); + vmathSoaQMakeFromScalar( &c_Quat, (vec_float4){0.0f} ); + vmathSoaQMakeFromScalar( &d_Quat, (vec_float4){0.0f} ); + vmathSoaQMakeFromScalar( &e_Quat, (vec_float4){0.0f} ); + vmathSoaQPrints( &c_Quat, "set Quat elements to zero" ); + vmathSoaQPrints( &d_Quat, "set Quat elements to zero" ); + vmathSoaQPrints( &e_Quat, "set Quat elements to zero" ); + vmathSoaQMakeFromV3Scalar( &a_Quat, &a_Vector3, randfloat() ); + vmathSoaQPrints( &a_Quat, "set Quat with Vector3, float" ); + vmathSoaQMakeFromV4( &a_Quat, &a_Vector4 ); + vmathSoaQPrints( &a_Quat, "construct Quat with Vector4" ); + vmathSoaQMakeFromScalar( &a_Quat, randfloat() ); + vmathSoaQPrints( &a_Quat, "set Quat with float" ); + vmathSoaQMakeFromScalar( &a_Quat, randfloat() ); + vmathSoaQPrints( &a_Quat, "set Quat with float" ); + vmathQMakeFromElems( &aos_Quat_0, 0.0f, 1.0f, 2.0f, 3.0f ); + vmathQMakeFromElems( &aos_Quat_1, 4.0f, 5.0f, 6.0f, 7.0f ); + vmathQMakeFromElems( &aos_Quat_2, 8.0f, 9.0f, 10.0f, 11.0f ); + vmathQMakeFromElems( &aos_Quat_3, 12.0f, 13.0f, 14.0f, 15.0f ); + vmathSoaQMakeFrom4Aos( &soa_Quat, &aos_Quat_0, &aos_Quat_1, &aos_Quat_2, &aos_Quat_3 ); + vmathSoaQGet4Aos( &soa_Quat, &aos_Quat_3, &aos_Quat_2, &aos_Quat_1, &aos_Quat_0 ); + vmathQPrints( &aos_Quat_0, "aos type 0" ); + vmathQPrints( &aos_Quat_1, "aos type 1" ); + vmathQPrints( &aos_Quat_2, "aos type 2" ); + vmathQPrints( &aos_Quat_3, "aos type 3" ); + vmathSoaQSelect( &a_Quat, &a_Quat, &b_Quat, ((vec_uint4){0,0xffffffff,0,0xffffffff}) ); + vmathSoaQGet4Aos( &a_Quat, &aos_Quat_0, &aos_Quat_1, &aos_Quat_2, &aos_Quat_3 ); + vmathQPrints( &aos_Quat_0, "select 0" ); + vmathQPrints( &aos_Quat_1, "select 1" ); + vmathQPrints( &aos_Quat_2, "select 2" ); + vmathQPrints( &aos_Quat_3, "select 3" ); + vmathSoaQCopy( &a_Quat, &b_Quat ); + vmathSoaQPrints( &a_Quat, "assign to Quat from Quat" ); + vmathSoaQSetXYZ( &a_Quat, &a_Vector3 ); + vmathSoaQPrints( &a_Quat, "set Quat xyz" ); + vmathSoaQGetXYZ( &tmpV3_0, &a_Quat ); + vmathSoaV3Prints( &tmpV3_0, "get Quat xyz" ); + vmathSoaQMakeFromScalar( &a_Quat, (vec_float4){0.0f} ); + vmathSoaQPrints( &a_Quat, "set Quat elements to zero" ); + vmathSoaQSetElem( &a_Quat, 0, randfloat() ); + vmathSoaQPrints( &a_Quat, "Quat::set( 0, float )" ); + vmathSoaQSetElem( &a_Quat, 0, randfloat() ); + vmathSoaQSetElem( &a_Quat, 0, vec_mul_float( vmathSoaQGetElem( &a_Quat, 0 ), randfloat() ) ); + vmathSoaQSetElem( &a_Quat, 0, divf4( vmathSoaQGetElem( &a_Quat, 0 ), randfloat() ) ); + vmathSoaQSetElem( &a_Quat, 0, vec_add_float( vmathSoaQGetElem( &a_Quat, 0 ), randfloat() ) ); + vmathSoaQSetElem( &a_Quat, 0, vec_sub_float( vmathSoaQGetElem( &a_Quat, 0 ), randfloat() ) ); + vmathSoaQPrints( &a_Quat, "Quat::operator [](0)" ); + vmathSoaQSetX( &a_Quat, randfloat() ); + vmathSoaQPrints( &a_Quat, "Quat::setX()" ); + vmathSoaQSetElem( &a_Quat, 1, randfloat() ); + vmathSoaQPrints( &a_Quat, "Quat::set( 1, float )" ); + vmathSoaQSetElem( &a_Quat, 1, randfloat() ); + vmathSoaQSetElem( &a_Quat, 1, vec_mul_float( vmathSoaQGetElem( &a_Quat, 1 ), randfloat() ) ); + vmathSoaQSetElem( &a_Quat, 1, divf4( vmathSoaQGetElem( &a_Quat, 1 ), randfloat() ) ); + vmathSoaQSetElem( &a_Quat, 1, vec_add_float( vmathSoaQGetElem( &a_Quat, 1 ), randfloat() ) ); + vmathSoaQSetElem( &a_Quat, 1, vec_sub_float( vmathSoaQGetElem( &a_Quat, 1 ), randfloat() ) ); + vmathSoaQPrints( &a_Quat, "Quat::operator [](1)" ); + vmathSoaQSetY( &a_Quat, randfloat() ); + vmathSoaQPrints( &a_Quat, "Quat::setY()" ); + vmathSoaQSetElem( &a_Quat, 2, randfloat() ); + vmathSoaQPrints( &a_Quat, "Quat::set( 2, float )" ); + vmathSoaQSetElem( &a_Quat, 2, randfloat() ); + vmathSoaQSetElem( &a_Quat, 2, vec_mul_float( vmathSoaQGetElem( &a_Quat, 2 ), randfloat() ) ); + vmathSoaQSetElem( &a_Quat, 2, divf4( vmathSoaQGetElem( &a_Quat, 2 ), randfloat() ) ); + vmathSoaQSetElem( &a_Quat, 2, vec_add_float( vmathSoaQGetElem( &a_Quat, 2 ), randfloat() ) ); + vmathSoaQSetElem( &a_Quat, 2, vec_sub_float( vmathSoaQGetElem( &a_Quat, 2 ), randfloat() ) ); + vmathSoaQPrints( &a_Quat, "Quat::operator [](2)" ); + vmathSoaQSetZ( &a_Quat, randfloat() ); + vmathSoaQPrints( &a_Quat, "Quat::setZ()" ); + vmathSoaQSetElem( &a_Quat, 3, randfloat() ); + vmathSoaQPrints( &a_Quat, "Quat::set( 3, float )" ); + vmathSoaQSetElem( &a_Quat, 3, randfloat() ); + vmathSoaQSetElem( &a_Quat, 3, vec_mul_float( vmathSoaQGetElem( &a_Quat, 3 ), randfloat() ) ); + vmathSoaQSetElem( &a_Quat, 3, divf4( vmathSoaQGetElem( &a_Quat, 3 ), randfloat() ) ); + vmathSoaQSetElem( &a_Quat, 3, vec_add_float( vmathSoaQGetElem( &a_Quat, 3 ), randfloat() ) ); + vmathSoaQSetElem( &a_Quat, 3, vec_sub_float( vmathSoaQGetElem( &a_Quat, 3 ), randfloat() ) ); + vmathSoaQPrints( &a_Quat, "Quat::operator [](3)" ); + vmathSoaQSetW( &a_Quat, randfloat() ); + vmathSoaQPrints( &a_Quat, "Quat::setW()" ); + printf("Quat::get( 0 ): %f\n", getfloat(vmathSoaQGetElem( &a_Quat, 0 )) ); + printf("Quat::operator []( 0 ): %f\n", getfloat(vmathSoaQGetElem( &a_Quat, 0 )) ); + printf("Quat::getX(): %f\n", getfloat(vmathSoaQGetX( &a_Quat )) ); + printf("Quat::get( 1 ): %f\n", getfloat(vmathSoaQGetElem( &a_Quat, 1 )) ); + printf("Quat::operator []( 1 ): %f\n", getfloat(vmathSoaQGetElem( &a_Quat, 1 )) ); + printf("Quat::getY(): %f\n", getfloat(vmathSoaQGetY( &a_Quat )) ); + printf("Quat::get( 2 ): %f\n", getfloat(vmathSoaQGetElem( &a_Quat, 2 )) ); + printf("Quat::operator []( 2 ): %f\n", getfloat(vmathSoaQGetElem( &a_Quat, 2 )) ); + printf("Quat::getZ(): %f\n", getfloat(vmathSoaQGetZ( &a_Quat )) ); + printf("Quat::get( 3 ): %f\n", getfloat(vmathSoaQGetElem( &a_Quat, 3 )) ); + printf("Quat::operator []( 3 ): %f\n", getfloat(vmathSoaQGetElem( &a_Quat, 3 )) ); + printf("Quat::getW(): %f\n", getfloat(vmathSoaQGetW( &a_Quat )) ); + vmathSoaQAdd( &tmpQ_0, &a_Quat, &b_Quat ); + vmathSoaQPrints( &tmpQ_0, "Quat + Quat" ); + vmathSoaQSub( &tmpQ_1, &a_Quat, &b_Quat ); + vmathSoaQPrints( &tmpQ_1, "Quat - Quat" ); + vmathSoaQMul( &tmpQ_2, &a_Quat, &b_Quat ); + vmathSoaQPrints( &tmpQ_2, "Quat * Quat" ); + vmathSoaQScalarMul( &tmpQ_3, &a_Quat, randfloat() ); + vmathSoaQPrints( &tmpQ_3, "Quat * float" ); + vmathSoaQScalarDiv( &tmpQ_4, &a_Quat, randfloat() ); + vmathSoaQPrints( &tmpQ_4, "Quat / float" ); + vmathSoaQScalarMul( &tmpQ_5, &a_Quat, randfloat() ); + vmathSoaQPrints( &tmpQ_5, "float * Quat" ); + vmathSoaQNeg( &tmpQ_6, &a_Quat ); + vmathSoaQPrints( &tmpQ_6, "Quat negate" ); + printf("Quat dot Quat: %f\n", getfloat(vmathSoaQDot( &a_Quat, &b_Quat ))); + printf("Quat lengthSqr: %f\n", getfloat(vmathSoaQNorm( &a_Quat ))); + printf("Quat length: %f\n", getfloat(vmathSoaQLength( &a_Quat ))); + vmathSoaQNormalize( &tmpQ_7, &a_Quat ); + vmathSoaQPrints( &tmpQ_7, "Quat normalized" ); + vmathSoaQMakeIdentity( &a_Quat ); + vmathSoaQPrints( &a_Quat, "set to identity" ); + vmathSoaQMakeRotationArc( &a_Quat, &a_Vector3, &b_Vector3 ); + vmathSoaQPrints( &a_Quat, "Quat rotation between vectors" ); + vmathSoaQMakeRotationAxis( &a_Quat, randfloat(), &a_Vector3 ); + vmathSoaQPrints( &a_Quat, "Quat rotation axis angle" ); + vmathSoaQMakeRotationX( &a_Quat, randfloat() ); + vmathSoaQPrints( &a_Quat, "Quat rotationX" ); + vmathSoaQMakeRotationY( &a_Quat, randfloat() ); + vmathSoaQPrints( &a_Quat, "Quat rotationY" ); + vmathSoaQMakeRotationZ( &a_Quat, randfloat() ); + vmathSoaQPrints( &a_Quat, "Quat rotationZ" ); + vmathSoaQRotate( &tmpV3_1, &a_Quat, &a_Vector3 ); + vmathSoaV3Prints( &tmpV3_1, "Quat rotate Vector3" ); + vmathSoaQConj( &tmpQ_8, &a_Quat ); + vmathSoaQPrints( &tmpQ_8, "Quat conj" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &b_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &e_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathSoaQNormalize( &b_Quat, &b_Quat ); + vmathSoaQNormalize( &c_Quat, &c_Quat ); + vmathSoaQNormalize( &d_Quat, &d_Quat ); + vmathSoaQNormalize( &e_Quat, &e_Quat ); + vmathSoaQLerp( &a_Quat, randfloat(), &b_Quat, &c_Quat ); + vmathSoaQPrints( &a_Quat, "Quat lerp" ); + vmathSoaQSlerp( &a_Quat, randfloat(), &b_Quat, &c_Quat ); + vmathSoaQPrints( &a_Quat, "Quat slerp" ); + vmathSoaQSquad( &a_Quat, randfloat(), &b_Quat, &c_Quat, &d_Quat, &e_Quat ); + vmathSoaQPrints( &a_Quat, "Quat squad" ); +} + +int main() +{ + printf("\n __begin__ \n"); + for ( iteration = 0; iteration < 2; iteration++ ) { + Vector3_methods_test(); + Vector4_methods_test(); + Point3_methods_test(); + Quat_methods_test(); + } + printf("\n __end__ \n"); + return 0; +} diff --git a/vectormathlibrary/tests/test1_soa_cpp.cpp b/vectormathlibrary/tests/test1_soa_cpp.cpp new file mode 100644 index 000000000..8c62a1e3c --- /dev/null +++ b/vectormathlibrary/tests/test1_soa_cpp.cpp @@ -0,0 +1,931 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _VECTORMATH_SOA_TEST + +#include "vectormath_soa.h" +#include "test.h" + +int iteration = 0; + +using namespace Vectormath; +using namespace Vectormath::Soa; + +void +Vector3_methods_test() +{ + Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3, e_Vector3; + Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4, e_Vector4; + Point3 a_Point3, b_Point3, c_Point3, d_Point3, e_Point3; + Quat a_Quat, b_Quat, c_Quat, d_Quat, e_Quat; + Aos::Vector3 aos_Vector3_0, aos_Vector3_1, aos_Vector3_2, aos_Vector3_3; + Vector3 soa_Vector3; + Aos::Vector4 aos_Vector4_0, aos_Vector4_1, aos_Vector4_2; + vec_float4 rndflt1, rndflt2, rndflt3, rndflt4; + float xyz4[12] __attribute__ ((aligned(16))); + xyz4[0] = getfloat(randfloat()); + xyz4[1] = getfloat(randfloat()); + xyz4[2] = getfloat(randfloat()); + xyz4[3] = getfloat(randfloat()); + xyz4[4] = getfloat(randfloat()); + xyz4[5] = getfloat(randfloat()); + xyz4[6] = getfloat(randfloat()); + xyz4[7] = getfloat(randfloat()); + xyz4[8] = getfloat(randfloat()); + xyz4[9] = getfloat(randfloat()); + xyz4[10] = getfloat(randfloat()); + xyz4[11] = getfloat(randfloat()); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + b_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + print( a_Vector3, "set Vector3 with floats" ); + print( b_Vector3, "set Vector3 with floats" ); + c_Vector3 = Vector3( (vec_float4){0.0f} ); + d_Vector3 = Vector3( (vec_float4){0.0f} ); + e_Vector3 = Vector3( (vec_float4){0.0f} ); + print( c_Vector3, "set Vector3 elements to zero" ); + print( d_Vector3, "set Vector3 elements to zero" ); + print( e_Vector3, "set Vector3 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + b_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Vector4, "set Vector4 with floats" ); + print( b_Vector4, "set Vector4 with floats" ); + c_Vector4 = Vector4( (vec_float4){0.0f} ); + d_Vector4 = Vector4( (vec_float4){0.0f} ); + e_Vector4 = Vector4( (vec_float4){0.0f} ); + print( c_Vector4, "set Vector4 elements to zero" ); + print( d_Vector4, "set Vector4 elements to zero" ); + print( e_Vector4, "set Vector4 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + b_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + print( a_Point3, "set Point3 with floats" ); + print( b_Point3, "set Point3 with floats" ); + c_Point3 = Point3( (vec_float4){0.0f} ); + d_Point3 = Point3( (vec_float4){0.0f} ); + e_Point3 = Point3( (vec_float4){0.0f} ); + print( c_Point3, "set Point3 elements to zero" ); + print( d_Point3, "set Point3 elements to zero" ); + print( e_Point3, "set Point3 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + b_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Quat, "set Quat with floats" ); + print( b_Quat, "set Quat with floats" ); + c_Quat = Quat( (vec_float4){0.0f} ); + d_Quat = Quat( (vec_float4){0.0f} ); + e_Quat = Quat( (vec_float4){0.0f} ); + print( c_Quat, "set Quat elements to zero" ); + print( d_Quat, "set Quat elements to zero" ); + print( e_Quat, "set Quat elements to zero" ); + a_Vector3 = Vector3( a_Point3 ); + print( a_Vector3, "construct Vector3 with Point3" ); + a_Vector3 = Vector3( randfloat() ); + print( a_Vector3, "set Vector3 with float" ); + a_Vector3 = Vector3( randfloat() ); + print( a_Vector3, "set Vector3 with float" ); + aos_Vector3_0 = Aos::Vector3( 0.0f, 1.0f, 2.0f ); + aos_Vector3_1 = Aos::Vector3( 3.0f, 4.0f, 5.0f ); + aos_Vector3_2 = Aos::Vector3( 6.0f, 7.0f, 8.0f ); + aos_Vector3_3 = Aos::Vector3( 9.0f, 10.0f, 11.0f ); + soa_Vector3 = Vector3( aos_Vector3_0, aos_Vector3_1, aos_Vector3_2, aos_Vector3_3 ); + soa_Vector3.get4Aos( aos_Vector3_3, aos_Vector3_2, aos_Vector3_1, aos_Vector3_0 ); + Aos::print( aos_Vector3_0, "aos type 0" ); + Aos::print( aos_Vector3_1, "aos type 1" ); + Aos::print( aos_Vector3_2, "aos type 2" ); + Aos::print( aos_Vector3_3, "aos type 3" ); + a_Vector3 = select( a_Vector3, b_Vector3, ((vec_uint4){0,0xffffffff,0,0xffffffff}) ); + a_Vector3.get4Aos( aos_Vector3_0, aos_Vector3_1, aos_Vector3_2, aos_Vector3_3 ); + Aos::print( aos_Vector3_0, "select 0" ); + Aos::print( aos_Vector3_1, "select 1" ); + Aos::print( aos_Vector3_2, "select 2" ); + Aos::print( aos_Vector3_3, "select 3" ); + loadXYZArray( a_Vector3, (const vec_float4 *)xyz4 ); + print( a_Vector3, "load XYZ array" ); + a_Vector3 = Vector3( ( -Vector3( a_Vector3 ) ) ); + storeXYZArray( a_Vector3, (vec_float4 *)xyz4 ); + aos_Vector4_0 = Aos::Vector4( xyz4[0], xyz4[1], xyz4[2], xyz4[3] ); + aos_Vector4_1 = Aos::Vector4( xyz4[4], xyz4[5], xyz4[6], xyz4[7] ); + aos_Vector4_2 = Aos::Vector4( xyz4[8], xyz4[9], xyz4[10], xyz4[11] ); + Aos::print( aos_Vector4_0, "xyzx" ); + Aos::print( aos_Vector4_1, "yzxy" ); + Aos::print( aos_Vector4_2, "zxyz" ); + Aos::print( aos_Vector4_0, "xyzx" ); + Aos::print( aos_Vector4_1, "yzxy" ); + Aos::print( aos_Vector4_2, "zxyz" ); + printf("storeXYZ:-1.0 -2.0 -3.0 0.4\n"); + a_Vector3 = b_Vector3; + print( a_Vector3, "assign to Vector3 from Vector3" ); + a_Vector3 = Vector3( (vec_float4){0.0f} ); + print( a_Vector3, "set Vector3 elements to zero" ); + a_Vector3 = Vector3::xAxis( ); + print( a_Vector3, "set to x axis" ); + a_Vector3 = Vector3::yAxis( ); + print( a_Vector3, "set to y axis" ); + a_Vector3 = Vector3::zAxis( ); + print( a_Vector3, "set to z axis" ); + a_Vector3.setElem( 0, randfloat() ); + print( a_Vector3, "Vector3::set( 0, float )" ); + a_Vector3[0] = randfloat(); + a_Vector3[0] = vec_mul_float( a_Vector3[0], randfloat() ); + a_Vector3[0] = divf4( a_Vector3[0], randfloat() ); + a_Vector3[0] = vec_add_float( a_Vector3[0], randfloat() ); + a_Vector3[0] = vec_sub_float( a_Vector3[0], randfloat() ); + print( a_Vector3, "Vector3::operator [](0)" ); + a_Vector3.setX( randfloat() ); + print( a_Vector3, "Vector3::setX()" ); + a_Vector3.setElem( 1, randfloat() ); + print( a_Vector3, "Vector3::set( 1, float )" ); + a_Vector3[1] = randfloat(); + a_Vector3[1] = vec_mul_float( a_Vector3[1], randfloat() ); + a_Vector3[1] = divf4( a_Vector3[1], randfloat() ); + a_Vector3[1] = vec_add_float( a_Vector3[1], randfloat() ); + a_Vector3[1] = vec_sub_float( a_Vector3[1], randfloat() ); + print( a_Vector3, "Vector3::operator [](1)" ); + a_Vector3.setY( randfloat() ); + print( a_Vector3, "Vector3::setY()" ); + a_Vector3.setElem( 2, randfloat() ); + print( a_Vector3, "Vector3::set( 2, float )" ); + a_Vector3[2] = randfloat(); + a_Vector3[2] = vec_mul_float( a_Vector3[2], randfloat() ); + a_Vector3[2] = divf4( a_Vector3[2], randfloat() ); + a_Vector3[2] = vec_add_float( a_Vector3[2], randfloat() ); + a_Vector3[2] = vec_sub_float( a_Vector3[2], randfloat() ); + print( a_Vector3, "Vector3::operator [](2)" ); + a_Vector3.setZ( randfloat() ); + print( a_Vector3, "Vector3::setZ()" ); + printf("Vector3::get( 0 ): %f\n", getfloat(a_Vector3.getElem( 0 )) ); + printf("Vector3::operator []( 0 ): %f\n", getfloat((vec_float4)a_Vector3[0]) ); + printf("Vector3::getX(): %f\n", getfloat(a_Vector3.getX( )) ); + printf("Vector3::get( 1 ): %f\n", getfloat(a_Vector3.getElem( 1 )) ); + printf("Vector3::operator []( 1 ): %f\n", getfloat((vec_float4)a_Vector3[1]) ); + printf("Vector3::getY(): %f\n", getfloat(a_Vector3.getY( )) ); + printf("Vector3::get( 2 ): %f\n", getfloat(a_Vector3.getElem( 2 )) ); + printf("Vector3::operator []( 2 ): %f\n", getfloat((vec_float4)a_Vector3[2]) ); + printf("Vector3::getZ(): %f\n", getfloat(a_Vector3.getZ( )) ); + print( ( a_Vector3 + b_Vector3 ), "Vector3 + Vector3" ); + print( ( a_Vector3 - b_Vector3 ), "Vector3 - Vector3" ); + print( ( a_Vector3 + b_Point3 ), "Vector3 + Point3" ); + print( ( a_Vector3 * randfloat() ), "Vector3 * float" ); + print( ( a_Vector3 / randfloat() ), "Vector3 / float" ); + print( ( randfloat() * a_Vector3 ), "float * Vector3" ); + print( ( -a_Vector3 ), "Vector3 negate" ); + print( mulPerElem( a_Vector3, b_Vector3 ), "mulPerElem( Vector3, Vector3 )" ); + print( divPerElem( a_Vector3, b_Vector3 ), "divPerElem( Vector3, Vector3 )" ); + print( recipPerElem( a_Vector3 ), "Vector3 recip" ); + print( sqrtPerElem( absPerElem( a_Vector3 ) ), "Vector3 sqrt" ); + print( rsqrtPerElem( absPerElem( a_Vector3 ) ), "Vector3 rsqrt" ); + print( absPerElem( a_Vector3 ), "Vector3 abs" ); + print( copySignPerElem( a_Vector3, b_Vector3 ), "Vector3 copySign" ); + print( maxPerElem( a_Vector3, b_Vector3 ), "Vector3 maximum Vector3" ); + print( minPerElem( a_Vector3, b_Vector3 ), "Vector3 minimum Vector3" ); + printf("Vector3 maximum of elements: %f\n", getfloat(maxElem( a_Vector3 ))); + printf("Vector3 minimum of elements: %f\n", getfloat(minElem( a_Vector3 ))); + printf("Vector3 sum of elements: %f\n", getfloat(sum( a_Vector3 ))); + printf("Vector3 dot Vector3: %f\n", getfloat(dot( a_Vector3, b_Vector3 ))); + printf("Vector3 lengthSqr: %f\n", getfloat(lengthSqr( a_Vector3 ))); + printf("Vector3 length: %f\n", getfloat(length( a_Vector3 ))); + print( normalize( a_Vector3 ), "Vector3 normalized" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + b_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + e_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + b_Vector3 = normalize( b_Vector3 ); + c_Vector3 = normalize( c_Vector3 ); + d_Vector3 = normalize( d_Vector3 ); + e_Vector3 = normalize( e_Vector3 ); + a_Vector3 = lerp( randfloat(), b_Vector3, c_Vector3 ); + print( a_Vector3, "Vector3 lerp" ); + a_Vector3 = slerp( randfloat(), b_Vector3, c_Vector3 ); + print( a_Vector3, "Vector3 slerp" ); +} + +void +Vector4_methods_test() +{ + Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3, e_Vector3; + Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4, e_Vector4; + Point3 a_Point3, b_Point3, c_Point3, d_Point3, e_Point3; + Quat a_Quat, b_Quat, c_Quat, d_Quat, e_Quat; + Aos::Vector4 aos_Vector4_0, aos_Vector4_1, aos_Vector4_2, aos_Vector4_3; + Vector4 soa_Vector4; + vec_float4 rndflt1, rndflt2, rndflt3, rndflt4; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + b_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + print( a_Vector3, "set Vector3 with floats" ); + print( b_Vector3, "set Vector3 with floats" ); + c_Vector3 = Vector3( (vec_float4){0.0f} ); + d_Vector3 = Vector3( (vec_float4){0.0f} ); + e_Vector3 = Vector3( (vec_float4){0.0f} ); + print( c_Vector3, "set Vector3 elements to zero" ); + print( d_Vector3, "set Vector3 elements to zero" ); + print( e_Vector3, "set Vector3 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + b_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Vector4, "set Vector4 with floats" ); + print( b_Vector4, "set Vector4 with floats" ); + c_Vector4 = Vector4( (vec_float4){0.0f} ); + d_Vector4 = Vector4( (vec_float4){0.0f} ); + e_Vector4 = Vector4( (vec_float4){0.0f} ); + print( c_Vector4, "set Vector4 elements to zero" ); + print( d_Vector4, "set Vector4 elements to zero" ); + print( e_Vector4, "set Vector4 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + b_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + print( a_Point3, "set Point3 with floats" ); + print( b_Point3, "set Point3 with floats" ); + c_Point3 = Point3( (vec_float4){0.0f} ); + d_Point3 = Point3( (vec_float4){0.0f} ); + e_Point3 = Point3( (vec_float4){0.0f} ); + print( c_Point3, "set Point3 elements to zero" ); + print( d_Point3, "set Point3 elements to zero" ); + print( e_Point3, "set Point3 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + b_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Quat, "set Quat with floats" ); + print( b_Quat, "set Quat with floats" ); + c_Quat = Quat( (vec_float4){0.0f} ); + d_Quat = Quat( (vec_float4){0.0f} ); + e_Quat = Quat( (vec_float4){0.0f} ); + print( c_Quat, "set Quat elements to zero" ); + print( d_Quat, "set Quat elements to zero" ); + print( e_Quat, "set Quat elements to zero" ); + a_Vector4 = Vector4( a_Vector3, randfloat() ); + print( a_Vector4, "set Vector4 with Vector3, float" ); + a_Vector4 = Vector4( a_Vector3 ); + print( a_Vector4, "set Vector4 with Vector3" ); + a_Vector4 = Vector4( a_Point3 ); + print( a_Vector4, "set Vector4 with Point3" ); + a_Vector4 = Vector4( a_Quat ); + print( a_Vector4, "construct Vector4 with Quat" ); + a_Vector4 = Vector4( randfloat() ); + print( a_Vector4, "set Vector4 with float" ); + a_Vector4 = Vector4( randfloat() ); + print( a_Vector4, "set Vector4 with float" ); + aos_Vector4_0 = Aos::Vector4( 0.0f, 1.0f, 2.0f, 3.0f ); + aos_Vector4_1 = Aos::Vector4( 4.0f, 5.0f, 6.0f, 7.0f ); + aos_Vector4_2 = Aos::Vector4( 8.0f, 9.0f, 10.0f, 11.0f ); + aos_Vector4_3 = Aos::Vector4( 12.0f, 13.0f, 14.0f, 15.0f ); + soa_Vector4 = Vector4( aos_Vector4_0, aos_Vector4_1, aos_Vector4_2, aos_Vector4_3 ); + soa_Vector4.get4Aos( aos_Vector4_3, aos_Vector4_2, aos_Vector4_1, aos_Vector4_0 ); + Aos::print( aos_Vector4_0, "aos type 0" ); + Aos::print( aos_Vector4_1, "aos type 1" ); + Aos::print( aos_Vector4_2, "aos type 2" ); + Aos::print( aos_Vector4_3, "aos type 3" ); + a_Vector4 = select( a_Vector4, b_Vector4, ((vec_uint4){0,0xffffffff,0,0xffffffff}) ); + a_Vector4.get4Aos( aos_Vector4_0, aos_Vector4_1, aos_Vector4_2, aos_Vector4_3 ); + Aos::print( aos_Vector4_0, "select 0" ); + Aos::print( aos_Vector4_1, "select 1" ); + Aos::print( aos_Vector4_2, "select 2" ); + Aos::print( aos_Vector4_3, "select 3" ); + a_Vector4 = b_Vector4; + print( a_Vector4, "assign to Vector4 from Vector4" ); + a_Vector4.setXYZ( a_Vector3 ); + print( a_Vector4, "set Vector4 xyz" ); + print( a_Vector4.getXYZ( ), "get Vector4 xyz" ); + a_Vector4 = Vector4( (vec_float4){0.0f} ); + print( a_Vector4, "set Vector4 elements to zero" ); + a_Vector4 = Vector4::xAxis( ); + print( a_Vector4, "set to x axis" ); + a_Vector4 = Vector4::yAxis( ); + print( a_Vector4, "set to y axis" ); + a_Vector4 = Vector4::zAxis( ); + print( a_Vector4, "set to z axis" ); + a_Vector4 = Vector4::wAxis( ); + print( a_Vector4, "set to w axis" ); + a_Vector4.setElem( 0, randfloat() ); + print( a_Vector4, "Vector4::set( 0, float )" ); + a_Vector4[0] = randfloat(); + a_Vector4[0] = vec_mul_float( a_Vector4[0], randfloat() ); + a_Vector4[0] = divf4( a_Vector4[0], randfloat() ); + a_Vector4[0] = vec_add_float( a_Vector4[0], randfloat() ); + a_Vector4[0] = vec_sub_float( a_Vector4[0], randfloat() ); + print( a_Vector4, "Vector4::operator [](0)" ); + a_Vector4.setX( randfloat() ); + print( a_Vector4, "Vector4::setX()" ); + a_Vector4.setElem( 1, randfloat() ); + print( a_Vector4, "Vector4::set( 1, float )" ); + a_Vector4[1] = randfloat(); + a_Vector4[1] = vec_mul_float( a_Vector4[1], randfloat() ); + a_Vector4[1] = divf4( a_Vector4[1], randfloat() ); + a_Vector4[1] = vec_add_float( a_Vector4[1], randfloat() ); + a_Vector4[1] = vec_sub_float( a_Vector4[1], randfloat() ); + print( a_Vector4, "Vector4::operator [](1)" ); + a_Vector4.setY( randfloat() ); + print( a_Vector4, "Vector4::setY()" ); + a_Vector4.setElem( 2, randfloat() ); + print( a_Vector4, "Vector4::set( 2, float )" ); + a_Vector4[2] = randfloat(); + a_Vector4[2] = vec_mul_float( a_Vector4[2], randfloat() ); + a_Vector4[2] = divf4( a_Vector4[2], randfloat() ); + a_Vector4[2] = vec_add_float( a_Vector4[2], randfloat() ); + a_Vector4[2] = vec_sub_float( a_Vector4[2], randfloat() ); + print( a_Vector4, "Vector4::operator [](2)" ); + a_Vector4.setZ( randfloat() ); + print( a_Vector4, "Vector4::setZ()" ); + a_Vector4.setElem( 3, randfloat() ); + print( a_Vector4, "Vector4::set( 3, float )" ); + a_Vector4[3] = randfloat(); + a_Vector4[3] = vec_mul_float( a_Vector4[3], randfloat() ); + a_Vector4[3] = divf4( a_Vector4[3], randfloat() ); + a_Vector4[3] = vec_add_float( a_Vector4[3], randfloat() ); + a_Vector4[3] = vec_sub_float( a_Vector4[3], randfloat() ); + print( a_Vector4, "Vector4::operator [](3)" ); + a_Vector4.setW( randfloat() ); + print( a_Vector4, "Vector4::setW()" ); + printf("Vector4::get( 0 ): %f\n", getfloat(a_Vector4.getElem( 0 )) ); + printf("Vector4::operator []( 0 ): %f\n", getfloat((vec_float4)a_Vector4[0]) ); + printf("Vector4::getX(): %f\n", getfloat(a_Vector4.getX( )) ); + printf("Vector4::get( 1 ): %f\n", getfloat(a_Vector4.getElem( 1 )) ); + printf("Vector4::operator []( 1 ): %f\n", getfloat((vec_float4)a_Vector4[1]) ); + printf("Vector4::getY(): %f\n", getfloat(a_Vector4.getY( )) ); + printf("Vector4::get( 2 ): %f\n", getfloat(a_Vector4.getElem( 2 )) ); + printf("Vector4::operator []( 2 ): %f\n", getfloat((vec_float4)a_Vector4[2]) ); + printf("Vector4::getZ(): %f\n", getfloat(a_Vector4.getZ( )) ); + printf("Vector4::get( 3 ): %f\n", getfloat(a_Vector4.getElem( 3 )) ); + printf("Vector4::operator []( 3 ): %f\n", getfloat((vec_float4)a_Vector4[3]) ); + printf("Vector4::getW(): %f\n", getfloat(a_Vector4.getW( )) ); + print( ( a_Vector4 + b_Vector4 ), "Vector4 + Vector4" ); + print( ( a_Vector4 - b_Vector4 ), "Vector4 - Vector4" ); + print( ( a_Vector4 * randfloat() ), "Vector4 * float" ); + print( ( a_Vector4 / randfloat() ), "Vector4 / float" ); + print( ( randfloat() * a_Vector4 ), "float * Vector4" ); + print( ( -a_Vector4 ), "Vector4 negate" ); + print( mulPerElem( a_Vector4, b_Vector4 ), "mulPerElem( Vector4, Vector4 )" ); + print( divPerElem( a_Vector4, b_Vector4 ), "divPerElem( Vector4, Vector4 )" ); + print( recipPerElem( a_Vector4 ), "Vector4 recip" ); + print( sqrtPerElem( absPerElem( a_Vector4 ) ), "Vector4 sqrt" ); + print( rsqrtPerElem( absPerElem( a_Vector4 ) ), "Vector4 rsqrt" ); + print( absPerElem( a_Vector4 ), "Vector4 abs" ); + print( copySignPerElem( a_Vector4, b_Vector4 ), "Vector4 copySign" ); + print( maxPerElem( a_Vector4, b_Vector4 ), "Vector4 maximum Vector4" ); + print( minPerElem( a_Vector4, b_Vector4 ), "Vector4 minimum Vector4" ); + printf("Vector4 maximum of elements: %f\n", getfloat(maxElem( a_Vector4 ))); + printf("Vector4 minimum of elements: %f\n", getfloat(minElem( a_Vector4 ))); + printf("Vector4 sum of elements: %f\n", getfloat(sum( a_Vector4 ))); + printf("Vector4 dot Vector4: %f\n", getfloat(dot( a_Vector4, b_Vector4 ))); + printf("Vector4 lengthSqr: %f\n", getfloat(lengthSqr( a_Vector4 ))); + printf("Vector4 length: %f\n", getfloat(length( a_Vector4 ))); + print( normalize( a_Vector4 ), "Vector4 normalized" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + b_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + e_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + b_Vector4 = normalize( b_Vector4 ); + c_Vector4 = normalize( c_Vector4 ); + d_Vector4 = normalize( d_Vector4 ); + e_Vector4 = normalize( e_Vector4 ); + a_Vector4 = lerp( randfloat(), b_Vector4, c_Vector4 ); + print( a_Vector4, "Vector4 lerp" ); + a_Vector4 = slerp( randfloat(), b_Vector4, c_Vector4 ); + print( a_Vector4, "Vector4 slerp" ); +} + +void +Point3_methods_test() +{ + Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3, e_Vector3; + Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4, e_Vector4; + Point3 a_Point3, b_Point3, c_Point3, d_Point3, e_Point3; + Quat a_Quat, b_Quat, c_Quat, d_Quat, e_Quat; + Aos::Point3 aos_Point3_0, aos_Point3_1, aos_Point3_2, aos_Point3_3; + Point3 soa_Point3; + Aos::Vector4 aos_Vector4_0, aos_Vector4_1, aos_Vector4_2; + vec_float4 rndflt1, rndflt2, rndflt3, rndflt4; + float xyz4[12] __attribute__ ((aligned(16))); + xyz4[0] = getfloat(randfloat()); + xyz4[1] = getfloat(randfloat()); + xyz4[2] = getfloat(randfloat()); + xyz4[3] = getfloat(randfloat()); + xyz4[4] = getfloat(randfloat()); + xyz4[5] = getfloat(randfloat()); + xyz4[6] = getfloat(randfloat()); + xyz4[7] = getfloat(randfloat()); + xyz4[8] = getfloat(randfloat()); + xyz4[9] = getfloat(randfloat()); + xyz4[10] = getfloat(randfloat()); + xyz4[11] = getfloat(randfloat()); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + b_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + print( a_Vector3, "set Vector3 with floats" ); + print( b_Vector3, "set Vector3 with floats" ); + c_Vector3 = Vector3( (vec_float4){0.0f} ); + d_Vector3 = Vector3( (vec_float4){0.0f} ); + e_Vector3 = Vector3( (vec_float4){0.0f} ); + print( c_Vector3, "set Vector3 elements to zero" ); + print( d_Vector3, "set Vector3 elements to zero" ); + print( e_Vector3, "set Vector3 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + b_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Vector4, "set Vector4 with floats" ); + print( b_Vector4, "set Vector4 with floats" ); + c_Vector4 = Vector4( (vec_float4){0.0f} ); + d_Vector4 = Vector4( (vec_float4){0.0f} ); + e_Vector4 = Vector4( (vec_float4){0.0f} ); + print( c_Vector4, "set Vector4 elements to zero" ); + print( d_Vector4, "set Vector4 elements to zero" ); + print( e_Vector4, "set Vector4 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + b_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + print( a_Point3, "set Point3 with floats" ); + print( b_Point3, "set Point3 with floats" ); + c_Point3 = Point3( (vec_float4){0.0f} ); + d_Point3 = Point3( (vec_float4){0.0f} ); + e_Point3 = Point3( (vec_float4){0.0f} ); + print( c_Point3, "set Point3 elements to zero" ); + print( d_Point3, "set Point3 elements to zero" ); + print( e_Point3, "set Point3 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + b_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Quat, "set Quat with floats" ); + print( b_Quat, "set Quat with floats" ); + c_Quat = Quat( (vec_float4){0.0f} ); + d_Quat = Quat( (vec_float4){0.0f} ); + e_Quat = Quat( (vec_float4){0.0f} ); + print( c_Quat, "set Quat elements to zero" ); + print( d_Quat, "set Quat elements to zero" ); + print( e_Quat, "set Quat elements to zero" ); + a_Point3 = Point3( a_Vector3 ); + print( a_Point3, "construct Point3 with Vector3" ); + a_Point3 = Point3( randfloat() ); + print( a_Point3, "set Point3 with float" ); + a_Point3 = Point3( randfloat() ); + print( a_Point3, "set Point3 with float" ); + aos_Point3_0 = Aos::Point3( 0.0f, 1.0f, 2.0f ); + aos_Point3_1 = Aos::Point3( 3.0f, 4.0f, 5.0f ); + aos_Point3_2 = Aos::Point3( 6.0f, 7.0f, 8.0f ); + aos_Point3_3 = Aos::Point3( 9.0f, 10.0f, 11.0f ); + soa_Point3 = Point3( aos_Point3_0, aos_Point3_1, aos_Point3_2, aos_Point3_3 ); + soa_Point3.get4Aos( aos_Point3_3, aos_Point3_2, aos_Point3_1, aos_Point3_0 ); + Aos::print( aos_Point3_0, "aos type 0" ); + Aos::print( aos_Point3_1, "aos type 1" ); + Aos::print( aos_Point3_2, "aos type 2" ); + Aos::print( aos_Point3_3, "aos type 3" ); + a_Point3 = select( a_Point3, b_Point3, ((vec_uint4){0,0xffffffff,0,0xffffffff}) ); + a_Point3.get4Aos( aos_Point3_0, aos_Point3_1, aos_Point3_2, aos_Point3_3 ); + Aos::print( aos_Point3_0, "select 0" ); + Aos::print( aos_Point3_1, "select 1" ); + Aos::print( aos_Point3_2, "select 2" ); + Aos::print( aos_Point3_3, "select 3" ); + loadXYZArray( a_Point3, (const vec_float4 *)xyz4 ); + print( a_Point3, "load XYZ array" ); + a_Point3 = Point3( ( -Vector3( a_Point3 ) ) ); + storeXYZArray( a_Point3, (vec_float4 *)xyz4 ); + aos_Vector4_0 = Aos::Vector4( xyz4[0], xyz4[1], xyz4[2], xyz4[3] ); + aos_Vector4_1 = Aos::Vector4( xyz4[4], xyz4[5], xyz4[6], xyz4[7] ); + aos_Vector4_2 = Aos::Vector4( xyz4[8], xyz4[9], xyz4[10], xyz4[11] ); + Aos::print( aos_Vector4_0, "xyzx" ); + Aos::print( aos_Vector4_1, "yzxy" ); + Aos::print( aos_Vector4_2, "zxyz" ); + Aos::print( aos_Vector4_0, "xyzx" ); + Aos::print( aos_Vector4_1, "yzxy" ); + Aos::print( aos_Vector4_2, "zxyz" ); + printf("storeXYZ:-1.0 -2.0 -3.0 0.4\n"); + a_Point3 = b_Point3; + print( a_Point3, "assign to Point3 from Point3" ); + a_Point3 = Point3( (vec_float4){0.0f} ); + print( a_Point3, "set Point3 elements to zero" ); + a_Point3.setElem( 0, randfloat() ); + print( a_Point3, "Point3::set( 0, float )" ); + a_Point3[0] = randfloat(); + a_Point3[0] = vec_mul_float( a_Point3[0], randfloat() ); + a_Point3[0] = divf4( a_Point3[0], randfloat() ); + a_Point3[0] = vec_add_float( a_Point3[0], randfloat() ); + a_Point3[0] = vec_sub_float( a_Point3[0], randfloat() ); + print( a_Point3, "Point3::operator [](0)" ); + a_Point3.setX( randfloat() ); + print( a_Point3, "Point3::setX()" ); + a_Point3.setElem( 1, randfloat() ); + print( a_Point3, "Point3::set( 1, float )" ); + a_Point3[1] = randfloat(); + a_Point3[1] = vec_mul_float( a_Point3[1], randfloat() ); + a_Point3[1] = divf4( a_Point3[1], randfloat() ); + a_Point3[1] = vec_add_float( a_Point3[1], randfloat() ); + a_Point3[1] = vec_sub_float( a_Point3[1], randfloat() ); + print( a_Point3, "Point3::operator [](1)" ); + a_Point3.setY( randfloat() ); + print( a_Point3, "Point3::setY()" ); + a_Point3.setElem( 2, randfloat() ); + print( a_Point3, "Point3::set( 2, float )" ); + a_Point3[2] = randfloat(); + a_Point3[2] = vec_mul_float( a_Point3[2], randfloat() ); + a_Point3[2] = divf4( a_Point3[2], randfloat() ); + a_Point3[2] = vec_add_float( a_Point3[2], randfloat() ); + a_Point3[2] = vec_sub_float( a_Point3[2], randfloat() ); + print( a_Point3, "Point3::operator [](2)" ); + a_Point3.setZ( randfloat() ); + print( a_Point3, "Point3::setZ()" ); + printf("Point3::get( 0 ): %f\n", getfloat(a_Point3.getElem( 0 )) ); + printf("Point3::operator []( 0 ): %f\n", getfloat((vec_float4)a_Point3[0]) ); + printf("Point3::getX(): %f\n", getfloat(a_Point3.getX( )) ); + printf("Point3::get( 1 ): %f\n", getfloat(a_Point3.getElem( 1 )) ); + printf("Point3::operator []( 1 ): %f\n", getfloat((vec_float4)a_Point3[1]) ); + printf("Point3::getY(): %f\n", getfloat(a_Point3.getY( )) ); + printf("Point3::get( 2 ): %f\n", getfloat(a_Point3.getElem( 2 )) ); + printf("Point3::operator []( 2 ): %f\n", getfloat((vec_float4)a_Point3[2]) ); + printf("Point3::getZ(): %f\n", getfloat(a_Point3.getZ( )) ); + print( ( a_Point3 - b_Point3 ), "Point3 - Point3" ); + print( ( a_Point3 + b_Vector3 ), "Point3 + Vector3" ); + print( ( a_Point3 - b_Vector3 ), "Point3 - Vector3" ); + print( mulPerElem( a_Point3, b_Point3 ), "mulPerElem( Point3, Point3 )" ); + print( divPerElem( a_Point3, b_Point3 ), "divPerElem( Point3, Point3 )" ); + print( recipPerElem( a_Point3 ), "Point3 recip" ); + print( sqrtPerElem( absPerElem( a_Point3 ) ), "Point3 sqrt" ); + print( rsqrtPerElem( absPerElem( a_Point3 ) ), "Point3 rsqrt" ); + print( absPerElem( a_Point3 ), "Point3 abs" ); + print( copySignPerElem( a_Point3, b_Point3 ), "Point3 copySign" ); + print( maxPerElem( a_Point3, b_Point3 ), "Point3 maximum Point3" ); + print( minPerElem( a_Point3, b_Point3 ), "Point3 minimum Point3" ); + printf("Point3 maximum of elements: %f\n", getfloat(maxElem( a_Point3 ))); + printf("Point3 minimum of elements: %f\n", getfloat(minElem( a_Point3 ))); + printf("Point3 sum of elements: %f\n", getfloat(sum( a_Point3 ))); + printf("Point projection: %f\n", getfloat(projection( a_Point3, b_Vector3 ))); + printf("Point distSqrFromOrigin: %f\n", getfloat(distSqrFromOrigin( a_Point3 )) ); + printf("Point distFromOrigin: %f\n", getfloat(distFromOrigin( a_Point3 )) ); + printf("Point distSqr: %f\n", getfloat(distSqr( a_Point3, b_Point3 )) ); + printf("Point dist: %f\n", getfloat(dist( a_Point3, b_Point3 )) ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + b_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + e_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + a_Point3 = lerp( randfloat(), b_Point3, c_Point3 ); + print( a_Point3, "Point3 lerp" ); +} + +void +Quat_methods_test() +{ + Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3, e_Vector3; + Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4, e_Vector4; + Point3 a_Point3, b_Point3, c_Point3, d_Point3, e_Point3; + Quat a_Quat, b_Quat, c_Quat, d_Quat, e_Quat; + Aos::Quat aos_Quat_0, aos_Quat_1, aos_Quat_2, aos_Quat_3; + Quat soa_Quat; + vec_float4 rndflt1, rndflt2, rndflt3, rndflt4; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + b_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + print( a_Vector3, "set Vector3 with floats" ); + print( b_Vector3, "set Vector3 with floats" ); + c_Vector3 = Vector3( (vec_float4){0.0f} ); + d_Vector3 = Vector3( (vec_float4){0.0f} ); + e_Vector3 = Vector3( (vec_float4){0.0f} ); + print( c_Vector3, "set Vector3 elements to zero" ); + print( d_Vector3, "set Vector3 elements to zero" ); + print( e_Vector3, "set Vector3 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + b_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Vector4, "set Vector4 with floats" ); + print( b_Vector4, "set Vector4 with floats" ); + c_Vector4 = Vector4( (vec_float4){0.0f} ); + d_Vector4 = Vector4( (vec_float4){0.0f} ); + e_Vector4 = Vector4( (vec_float4){0.0f} ); + print( c_Vector4, "set Vector4 elements to zero" ); + print( d_Vector4, "set Vector4 elements to zero" ); + print( e_Vector4, "set Vector4 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + b_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + print( a_Point3, "set Point3 with floats" ); + print( b_Point3, "set Point3 with floats" ); + c_Point3 = Point3( (vec_float4){0.0f} ); + d_Point3 = Point3( (vec_float4){0.0f} ); + e_Point3 = Point3( (vec_float4){0.0f} ); + print( c_Point3, "set Point3 elements to zero" ); + print( d_Point3, "set Point3 elements to zero" ); + print( e_Point3, "set Point3 elements to zero" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + b_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Quat, "set Quat with floats" ); + print( b_Quat, "set Quat with floats" ); + c_Quat = Quat( (vec_float4){0.0f} ); + d_Quat = Quat( (vec_float4){0.0f} ); + e_Quat = Quat( (vec_float4){0.0f} ); + print( c_Quat, "set Quat elements to zero" ); + print( d_Quat, "set Quat elements to zero" ); + print( e_Quat, "set Quat elements to zero" ); + a_Quat = Quat( a_Vector3, randfloat() ); + print( a_Quat, "set Quat with Vector3, float" ); + a_Quat = Quat( a_Vector4 ); + print( a_Quat, "construct Quat with Vector4" ); + a_Quat = Quat( randfloat() ); + print( a_Quat, "set Quat with float" ); + a_Quat = Quat( randfloat() ); + print( a_Quat, "set Quat with float" ); + aos_Quat_0 = Aos::Quat( 0.0f, 1.0f, 2.0f, 3.0f ); + aos_Quat_1 = Aos::Quat( 4.0f, 5.0f, 6.0f, 7.0f ); + aos_Quat_2 = Aos::Quat( 8.0f, 9.0f, 10.0f, 11.0f ); + aos_Quat_3 = Aos::Quat( 12.0f, 13.0f, 14.0f, 15.0f ); + soa_Quat = Quat( aos_Quat_0, aos_Quat_1, aos_Quat_2, aos_Quat_3 ); + soa_Quat.get4Aos( aos_Quat_3, aos_Quat_2, aos_Quat_1, aos_Quat_0 ); + Aos::print( aos_Quat_0, "aos type 0" ); + Aos::print( aos_Quat_1, "aos type 1" ); + Aos::print( aos_Quat_2, "aos type 2" ); + Aos::print( aos_Quat_3, "aos type 3" ); + a_Quat = select( a_Quat, b_Quat, ((vec_uint4){0,0xffffffff,0,0xffffffff}) ); + a_Quat.get4Aos( aos_Quat_0, aos_Quat_1, aos_Quat_2, aos_Quat_3 ); + Aos::print( aos_Quat_0, "select 0" ); + Aos::print( aos_Quat_1, "select 1" ); + Aos::print( aos_Quat_2, "select 2" ); + Aos::print( aos_Quat_3, "select 3" ); + a_Quat = b_Quat; + print( a_Quat, "assign to Quat from Quat" ); + a_Quat.setXYZ( a_Vector3 ); + print( a_Quat, "set Quat xyz" ); + print( a_Quat.getXYZ( ), "get Quat xyz" ); + a_Quat = Quat( (vec_float4){0.0f} ); + print( a_Quat, "set Quat elements to zero" ); + a_Quat.setElem( 0, randfloat() ); + print( a_Quat, "Quat::set( 0, float )" ); + a_Quat[0] = randfloat(); + a_Quat[0] = vec_mul_float( a_Quat[0], randfloat() ); + a_Quat[0] = divf4( a_Quat[0], randfloat() ); + a_Quat[0] = vec_add_float( a_Quat[0], randfloat() ); + a_Quat[0] = vec_sub_float( a_Quat[0], randfloat() ); + print( a_Quat, "Quat::operator [](0)" ); + a_Quat.setX( randfloat() ); + print( a_Quat, "Quat::setX()" ); + a_Quat.setElem( 1, randfloat() ); + print( a_Quat, "Quat::set( 1, float )" ); + a_Quat[1] = randfloat(); + a_Quat[1] = vec_mul_float( a_Quat[1], randfloat() ); + a_Quat[1] = divf4( a_Quat[1], randfloat() ); + a_Quat[1] = vec_add_float( a_Quat[1], randfloat() ); + a_Quat[1] = vec_sub_float( a_Quat[1], randfloat() ); + print( a_Quat, "Quat::operator [](1)" ); + a_Quat.setY( randfloat() ); + print( a_Quat, "Quat::setY()" ); + a_Quat.setElem( 2, randfloat() ); + print( a_Quat, "Quat::set( 2, float )" ); + a_Quat[2] = randfloat(); + a_Quat[2] = vec_mul_float( a_Quat[2], randfloat() ); + a_Quat[2] = divf4( a_Quat[2], randfloat() ); + a_Quat[2] = vec_add_float( a_Quat[2], randfloat() ); + a_Quat[2] = vec_sub_float( a_Quat[2], randfloat() ); + print( a_Quat, "Quat::operator [](2)" ); + a_Quat.setZ( randfloat() ); + print( a_Quat, "Quat::setZ()" ); + a_Quat.setElem( 3, randfloat() ); + print( a_Quat, "Quat::set( 3, float )" ); + a_Quat[3] = randfloat(); + a_Quat[3] = vec_mul_float( a_Quat[3], randfloat() ); + a_Quat[3] = divf4( a_Quat[3], randfloat() ); + a_Quat[3] = vec_add_float( a_Quat[3], randfloat() ); + a_Quat[3] = vec_sub_float( a_Quat[3], randfloat() ); + print( a_Quat, "Quat::operator [](3)" ); + a_Quat.setW( randfloat() ); + print( a_Quat, "Quat::setW()" ); + printf("Quat::get( 0 ): %f\n", getfloat(a_Quat.getElem( 0 )) ); + printf("Quat::operator []( 0 ): %f\n", getfloat((vec_float4)a_Quat[0]) ); + printf("Quat::getX(): %f\n", getfloat(a_Quat.getX( )) ); + printf("Quat::get( 1 ): %f\n", getfloat(a_Quat.getElem( 1 )) ); + printf("Quat::operator []( 1 ): %f\n", getfloat((vec_float4)a_Quat[1]) ); + printf("Quat::getY(): %f\n", getfloat(a_Quat.getY( )) ); + printf("Quat::get( 2 ): %f\n", getfloat(a_Quat.getElem( 2 )) ); + printf("Quat::operator []( 2 ): %f\n", getfloat((vec_float4)a_Quat[2]) ); + printf("Quat::getZ(): %f\n", getfloat(a_Quat.getZ( )) ); + printf("Quat::get( 3 ): %f\n", getfloat(a_Quat.getElem( 3 )) ); + printf("Quat::operator []( 3 ): %f\n", getfloat((vec_float4)a_Quat[3]) ); + printf("Quat::getW(): %f\n", getfloat(a_Quat.getW( )) ); + print( ( a_Quat + b_Quat ), "Quat + Quat" ); + print( ( a_Quat - b_Quat ), "Quat - Quat" ); + print( ( a_Quat * b_Quat ), "Quat * Quat" ); + print( ( a_Quat * randfloat() ), "Quat * float" ); + print( ( a_Quat / randfloat() ), "Quat / float" ); + print( ( randfloat() * a_Quat ), "float * Quat" ); + print( ( -a_Quat ), "Quat negate" ); + printf("Quat dot Quat: %f\n", getfloat(dot( a_Quat, b_Quat ))); + printf("Quat lengthSqr: %f\n", getfloat(norm( a_Quat ))); + printf("Quat length: %f\n", getfloat(length( a_Quat ))); + print( normalize( a_Quat ), "Quat normalized" ); + a_Quat = Quat::identity( ); + print( a_Quat, "set to identity" ); + a_Quat = Quat::rotation( a_Vector3, b_Vector3 ); + print( a_Quat, "Quat rotation between vectors" ); + a_Quat = Quat::rotation( randfloat(), a_Vector3 ); + print( a_Quat, "Quat rotation axis angle" ); + a_Quat = Quat::rotationX( randfloat() ); + print( a_Quat, "Quat rotationX" ); + a_Quat = Quat::rotationY( randfloat() ); + print( a_Quat, "Quat rotationY" ); + a_Quat = Quat::rotationZ( randfloat() ); + print( a_Quat, "Quat rotationZ" ); + print( rotate( a_Quat, a_Vector3 ), "Quat rotate Vector3" ); + print( conj( a_Quat ), "Quat conj" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + b_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + e_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + b_Quat = normalize( b_Quat ); + c_Quat = normalize( c_Quat ); + d_Quat = normalize( d_Quat ); + e_Quat = normalize( e_Quat ); + a_Quat = lerp( randfloat(), b_Quat, c_Quat ); + print( a_Quat, "Quat lerp" ); + a_Quat = slerp( randfloat(), b_Quat, c_Quat ); + print( a_Quat, "Quat slerp" ); + a_Quat = squad( randfloat(), b_Quat, c_Quat, d_Quat, e_Quat ); + print( a_Quat, "Quat squad" ); +} + +int main() +{ + printf("\n __begin__ \n"); + for ( iteration = 0; iteration < 2; iteration++ ) { + Vector3_methods_test(); + Vector4_methods_test(); + Point3_methods_test(); + Quat_methods_test(); + } + printf("\n __end__ \n"); + return 0; +} diff --git a/vectormathlibrary/tests/test2_aos_c.c b/vectormathlibrary/tests/test2_aos_c.c new file mode 100644 index 000000000..290d6a34d --- /dev/null +++ b/vectormathlibrary/tests/test2_aos_c.c @@ -0,0 +1,852 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _VECTORMATH_AOS_TEST + +#include "vectormath_aos.h" +#include "test.h" + +int iteration = 0; + +void +Matrix3_methods_test() +{ + VmathMatrix3 a_Matrix3, b_Matrix3; + VmathMatrix4 a_Matrix4, b_Matrix4; + VmathTransform3 a_Transform3, b_Transform3; + VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; + VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; + VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3; + VmathQuat a_Quat, b_Quat, c_Quat, d_Quat; + VmathVector4 tmpV4; + VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7; + VmathQuat tmpQ_0; + VmathVector3 tmpV3_8, tmpV3_9, tmpV3_10, tmpV3_11, tmpV3_12, tmpV3_13, tmpV3_14, tmpV3_15, tmpV3_16, tmpV3_17, tmpV3_18, tmpV3_19, tmpV3_20, tmpV3_21; + float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad; + // set a pad value to detect invalid use of padding. + // this will be nan for scalar/ppu implementations, max. float for spu + union { float f; unsigned int u; } tmp; + tmp.u = 0x7fffffff; + pad = tmp.f; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad ); + vmathV4GetXYZ( &a_Vector3, &tmpV4 ); + vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad ); + vmathV4GetXYZ( &b_Vector3, &tmpV4 ); + vmathV4MakeFromV3Scalar( &tmpV4, &c_Vector3, pad ); + vmathV4GetXYZ( &c_Vector3, &tmpV4 ); + vmathV4MakeFromV3Scalar( &tmpV4, &d_Vector3, pad ); + vmathV4GetXYZ( &d_Vector3, &tmpV4 ); + vmathV3Prints( &a_Vector3, "set Vector3 with floats" ); + vmathV3Prints( &b_Vector3, "set Vector3 with floats" ); + vmathV3Prints( &c_Vector3, "set Vector3 with floats" ); + vmathV3Prints( &d_Vector3, "set Vector3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathV4Prints( &a_Vector4, "set Vector4 with floats" ); + vmathV4Prints( &b_Vector4, "set Vector4 with floats" ); + vmathV4Prints( &c_Vector4, "set Vector4 with floats" ); + vmathV4Prints( &d_Vector4, "set Vector4 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); + vmathV3MakeFromP3( &tmpV3_0, &a_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad ); + vmathV4GetXYZ( &tmpV3_1, &tmpV4 ); + vmathP3MakeFromV3( &a_Point3, &tmpV3_1 ); + vmathV3MakeFromP3( &tmpV3_2, &b_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad ); + vmathV4GetXYZ( &tmpV3_3, &tmpV4 ); + vmathP3MakeFromV3( &b_Point3, &tmpV3_3 ); + vmathV3MakeFromP3( &tmpV3_4, &c_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_4, pad ); + vmathV4GetXYZ( &tmpV3_5, &tmpV4 ); + vmathP3MakeFromV3( &c_Point3, &tmpV3_5 ); + vmathV3MakeFromP3( &tmpV3_6, &d_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_6, pad ); + vmathV4GetXYZ( &tmpV3_7, &tmpV4 ); + vmathP3MakeFromV3( &d_Point3, &tmpV3_7 ); + vmathP3Prints( &a_Point3, "set Point3 with floats" ); + vmathP3Prints( &b_Point3, "set Point3 with floats" ); + vmathP3Prints( &c_Point3, "set Point3 with floats" ); + vmathP3Prints( &d_Point3, "set Point3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathQPrints( &a_Quat, "set Quat with floats" ); + vmathQPrints( &b_Quat, "set Quat with floats" ); + vmathQPrints( &c_Quat, "set Quat with floats" ); + vmathQPrints( &d_Quat, "set Quat with floats" ); + vmathM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 ); + vmathM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 ); + vmathM3Prints( &a_Matrix3, "set Matrix3 columns" ); + vmathM3Prints( &b_Matrix3, "set Matrix3 columns" ); + vmathM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 ); + vmathM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 ); + vmathM4Prints( &a_Matrix4, "set Matrix4 columns" ); + vmathM4Prints( &b_Matrix4, "set Matrix4 columns" ); + vmathT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 ); + vmathT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 ); + vmathT3Prints( &a_Transform3, "set Transform3 columns" ); + vmathT3Prints( &b_Transform3, "set Transform3 columns" ); + vmathQNormalize( &tmpQ_0, &a_Quat ); + vmathM3MakeFromQ( &a_Matrix3, &tmpQ_0 ); + vmathM3Prints( &a_Matrix3, "construct Matrix3 with Quat" ); + vmathQMakeFromM3( &a_Quat, &a_Matrix3 ); + vmathQPrints( &a_Quat, "construct Quat with Matrix3" ); + vmathM3Copy( &a_Matrix3, &b_Matrix3 ); + vmathM3Prints( &a_Matrix3, "assign to Matrix3 from Matrix3" ); + vmathM3MakeFromScalar( &a_Matrix3, randfloat() ); + vmathM3Prints( &a_Matrix3, "set Matrix3 with float" ); + vmathM3MakeFromScalar( &a_Matrix3, randfloat() ); + vmathM3Prints( &a_Matrix3, "set Matrix3 with float" ); + vmathM3MakeFromScalar( &a_Matrix3, 0.0f ); + vmathM3Prints( &a_Matrix3, "set elements to zero" ); + vmathM3MakeIdentity( &a_Matrix3 ); + vmathM3Prints( &a_Matrix3, "set to identity" ); + vmathM3MakeRotationX( &a_Matrix3, randfloat() ); + vmathM3Prints( &a_Matrix3, "set to rotationX" ); + vmathM3MakeRotationY( &a_Matrix3, randfloat() ); + vmathM3Prints( &a_Matrix3, "set to rotationY" ); + vmathM3MakeRotationZ( &a_Matrix3, randfloat() ); + vmathM3Prints( &a_Matrix3, "set to rotationZ" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &tmpV3_8, rndflt3, rndflt2, rndflt1 ); + vmathM3MakeRotationZYX( &a_Matrix3, &tmpV3_8 ); + vmathM3Prints( &a_Matrix3, "set to rotation from Z,Y,X angles" ); + vmathV3Normalize( &tmpV3_9, &a_Vector3 ); + vmathM3MakeRotationAxis( &a_Matrix3, randfloat(), &tmpV3_9 ); + vmathM3Prints( &a_Matrix3, "set to rotation from axis angle" ); + vmathM3SetCol0( &a_Matrix3, &a_Vector3 ); + vmathM3Prints( &a_Matrix3, "Matrix3 set col 0" ); + vmathM3SetCol1( &a_Matrix3, &a_Vector3 ); + vmathM3Prints( &a_Matrix3, "Matrix3 set col 1" ); + vmathM3SetCol2( &a_Matrix3, &a_Vector3 ); + vmathM3Prints( &a_Matrix3, "Matrix3 set col 2" ); + vmathM3GetCol0( &tmpV3_10, &a_Matrix3 ); + vmathV3Prints( &tmpV3_10, "Matrix3 get col 0" ); + vmathM3GetCol1( &tmpV3_11, &a_Matrix3 ); + vmathV3Prints( &tmpV3_11, "Matrix3 get col 1" ); + vmathM3GetCol2( &tmpV3_12, &a_Matrix3 ); + vmathV3Prints( &tmpV3_12, "Matrix3 get col 2" ); + vmathM3SetCol( &a_Matrix3, 0, &b_Vector3 ); + vmathM3Prints( &a_Matrix3, "Matrix3 set col 0" ); + vmathM3SetCol( &a_Matrix3, 1, &b_Vector3 ); + vmathM3Prints( &a_Matrix3, "Matrix3 set col 1" ); + vmathM3SetCol( &a_Matrix3, 2, &b_Vector3 ); + vmathM3Prints( &a_Matrix3, "Matrix3 set col 2" ); + vmathM3GetCol( &tmpV3_13, &a_Matrix3, 0 ); + vmathV3Prints( &tmpV3_13, "Matrix3 get col 0" ); + vmathM3GetCol( &tmpV3_14, &a_Matrix3, 1 ); + vmathV3Prints( &tmpV3_14, "Matrix3 get col 1" ); + vmathM3GetCol( &tmpV3_15, &a_Matrix3, 2 ); + vmathV3Prints( &tmpV3_15, "Matrix3 get col 2" ); + vmathM3SetRow( &a_Matrix3, 0, &a_Vector3 ); + vmathM3Prints( &a_Matrix3, "Matrix3 set row 0" ); + vmathM3SetRow( &a_Matrix3, 1, &a_Vector3 ); + vmathM3Prints( &a_Matrix3, "Matrix3 set row 1" ); + vmathM3SetRow( &a_Matrix3, 2, &a_Vector3 ); + vmathM3Prints( &a_Matrix3, "Matrix3 set row 2" ); + vmathM3GetRow( &tmpV3_16, &a_Matrix3, 0 ); + vmathV3Prints( &tmpV3_16, "Matrix3 get row 0" ); + vmathM3GetRow( &tmpV3_17, &a_Matrix3, 1 ); + vmathV3Prints( &tmpV3_17, "Matrix3 get row 1" ); + vmathM3GetRow( &tmpV3_18, &a_Matrix3, 2 ); + vmathV3Prints( &tmpV3_18, "Matrix3 get row 2" ); + vmathM3SetCol( &a_Matrix3, 0, &a_Vector3 ); + vmathM3Prints( &a_Matrix3, "set " ); + vmathM3SetCol( &a_Matrix3, 1, &a_Vector3 ); + vmathM3Prints( &a_Matrix3, "set " ); + vmathM3SetCol( &a_Matrix3, 2, &a_Vector3 ); + vmathM3Prints( &a_Matrix3, "set " ); + vmathM3GetCol( &tmpV3_19, &a_Matrix3, 0 ); + vmathV3Prints( &tmpV3_19, "get " ); + vmathM3GetCol( &tmpV3_20, &a_Matrix3, 1 ); + vmathV3Prints( &tmpV3_20, "get " ); + vmathM3GetCol( &tmpV3_21, &a_Matrix3, 2 ); + vmathV3Prints( &tmpV3_21, "get " ); + vmathM3SetElem( &a_Matrix3, 0, 0, randfloat() ); + vmathM3SetElem( &a_Matrix3, 0, 1, randfloat() ); + vmathM3SetElem( &a_Matrix3, 0, 2, randfloat() ); + vmathM3SetElem( &a_Matrix3, 1, 0, randfloat() ); + vmathM3SetElem( &a_Matrix3, 1, 1, randfloat() ); + vmathM3SetElem( &a_Matrix3, 1, 2, randfloat() ); + vmathM3SetElem( &a_Matrix3, 2, 0, randfloat() ); + vmathM3SetElem( &a_Matrix3, 2, 1, randfloat() ); + vmathM3SetElem( &a_Matrix3, 2, 2, randfloat() ); + vmathM3Prints( &a_Matrix3, "Matrix3 set elements" ); + printf("%f\n", getfloat(vmathM3GetElem( &a_Matrix3, 0, 0 )) ); + printf("%f\n", getfloat(vmathM3GetElem( &a_Matrix3, 0, 1 )) ); + printf("%f\n", getfloat(vmathM3GetElem( &a_Matrix3, 0, 2 )) ); + printf("%f\n", getfloat(vmathM3GetElem( &a_Matrix3, 1, 0 )) ); + printf("%f\n", getfloat(vmathM3GetElem( &a_Matrix3, 1, 1 )) ); + printf("%f\n", getfloat(vmathM3GetElem( &a_Matrix3, 1, 2 )) ); + printf("%f\n", getfloat(vmathM3GetElem( &a_Matrix3, 2, 0 )) ); + printf("%f\n", getfloat(vmathM3GetElem( &a_Matrix3, 2, 1 )) ); + printf("%f\n", getfloat(vmathM3GetElem( &a_Matrix3, 2, 2 )) ); +} + +void +Matrix4_methods_test() +{ + VmathMatrix3 a_Matrix3, b_Matrix3; + VmathMatrix4 a_Matrix4, b_Matrix4; + VmathTransform3 a_Transform3, b_Transform3; + VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; + VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; + VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3; + VmathQuat a_Quat, b_Quat, c_Quat, d_Quat; + VmathVector4 tmpV4; + VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7, tmpV3_8, tmpV3_9; + VmathVector4 tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3, tmpV4_4, tmpV4_5, tmpV4_6, tmpV4_7, tmpV4_8, tmpV4_9, tmpV4_10, tmpV4_11, tmpV4_12, tmpV4_13, tmpV4_14, tmpV4_15; + float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad; + // set a pad value to detect invalid use of padding. + // this will be nan for scalar/ppu implementations, max. float for spu + union { float f; unsigned int u; } tmp; + tmp.u = 0x7fffffff; + pad = tmp.f; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad ); + vmathV4GetXYZ( &a_Vector3, &tmpV4 ); + vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad ); + vmathV4GetXYZ( &b_Vector3, &tmpV4 ); + vmathV4MakeFromV3Scalar( &tmpV4, &c_Vector3, pad ); + vmathV4GetXYZ( &c_Vector3, &tmpV4 ); + vmathV4MakeFromV3Scalar( &tmpV4, &d_Vector3, pad ); + vmathV4GetXYZ( &d_Vector3, &tmpV4 ); + vmathV3Prints( &a_Vector3, "set Vector3 with floats" ); + vmathV3Prints( &b_Vector3, "set Vector3 with floats" ); + vmathV3Prints( &c_Vector3, "set Vector3 with floats" ); + vmathV3Prints( &d_Vector3, "set Vector3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathV4Prints( &a_Vector4, "set Vector4 with floats" ); + vmathV4Prints( &b_Vector4, "set Vector4 with floats" ); + vmathV4Prints( &c_Vector4, "set Vector4 with floats" ); + vmathV4Prints( &d_Vector4, "set Vector4 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); + vmathV3MakeFromP3( &tmpV3_0, &a_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad ); + vmathV4GetXYZ( &tmpV3_1, &tmpV4 ); + vmathP3MakeFromV3( &a_Point3, &tmpV3_1 ); + vmathV3MakeFromP3( &tmpV3_2, &b_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad ); + vmathV4GetXYZ( &tmpV3_3, &tmpV4 ); + vmathP3MakeFromV3( &b_Point3, &tmpV3_3 ); + vmathV3MakeFromP3( &tmpV3_4, &c_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_4, pad ); + vmathV4GetXYZ( &tmpV3_5, &tmpV4 ); + vmathP3MakeFromV3( &c_Point3, &tmpV3_5 ); + vmathV3MakeFromP3( &tmpV3_6, &d_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_6, pad ); + vmathV4GetXYZ( &tmpV3_7, &tmpV4 ); + vmathP3MakeFromV3( &d_Point3, &tmpV3_7 ); + vmathP3Prints( &a_Point3, "set Point3 with floats" ); + vmathP3Prints( &b_Point3, "set Point3 with floats" ); + vmathP3Prints( &c_Point3, "set Point3 with floats" ); + vmathP3Prints( &d_Point3, "set Point3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathQPrints( &a_Quat, "set Quat with floats" ); + vmathQPrints( &b_Quat, "set Quat with floats" ); + vmathQPrints( &c_Quat, "set Quat with floats" ); + vmathQPrints( &d_Quat, "set Quat with floats" ); + vmathM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 ); + vmathM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 ); + vmathM3Prints( &a_Matrix3, "set Matrix3 columns" ); + vmathM3Prints( &b_Matrix3, "set Matrix3 columns" ); + vmathM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 ); + vmathM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 ); + vmathM4Prints( &a_Matrix4, "set Matrix4 columns" ); + vmathM4Prints( &b_Matrix4, "set Matrix4 columns" ); + vmathT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 ); + vmathT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 ); + vmathT3Prints( &a_Transform3, "set Transform3 columns" ); + vmathT3Prints( &b_Transform3, "set Transform3 columns" ); + vmathM4MakeFromT3( &a_Matrix4, &a_Transform3 ); + vmathM4Prints( &a_Matrix4, "construct Matrix4 with Transform3" ); + vmathM4MakeFromM3V3( &a_Matrix4, &a_Matrix3, &a_Vector3 ); + vmathM4Prints( &a_Matrix4, "construct Matrix4 with Matrix3 and Vector3" ); + vmathM4MakeFromQV3( &a_Matrix4, &a_Quat, &a_Vector3 ); + vmathM4Prints( &a_Matrix4, "construct Matrix4 with Quat and Vector3" ); + vmathM4Copy( &a_Matrix4, &b_Matrix4 ); + vmathM4Prints( &a_Matrix4, "assign to Matrix4 from Matrix4" ); + vmathM4MakeFromScalar( &a_Matrix4, randfloat() ); + vmathM4Prints( &a_Matrix4, "set Matrix4 with float" ); + vmathM4MakeFromScalar( &a_Matrix4, randfloat() ); + vmathM4Prints( &a_Matrix4, "set Matrix4 with float" ); + vmathM4MakeFromScalar( &a_Matrix4, 0.0f ); + vmathM4Prints( &a_Matrix4, "set elements to zero" ); + vmathM4MakeIdentity( &a_Matrix4 ); + vmathM4Prints( &a_Matrix4, "set to identity" ); + vmathM4MakeRotationX( &a_Matrix4, randfloat() ); + vmathM4Prints( &a_Matrix4, "set to rotationX" ); + vmathM4MakeRotationY( &a_Matrix4, randfloat() ); + vmathM4Prints( &a_Matrix4, "set to rotationY" ); + vmathM4MakeRotationZ( &a_Matrix4, randfloat() ); + vmathM4Prints( &a_Matrix4, "set to rotationZ" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &tmpV3_8, rndflt3, rndflt2, rndflt1 ); + vmathM4MakeRotationZYX( &a_Matrix4, &tmpV3_8 ); + vmathM4Prints( &a_Matrix4, "set to rotation from Z,Y,X angles" ); + vmathV3Normalize( &tmpV3_9, &a_Vector3 ); + vmathM4MakeRotationAxis( &a_Matrix4, randfloat(), &tmpV3_9 ); + vmathM4Prints( &a_Matrix4, "set to rotation from axis angle" ); + vmathM4MakeTranslation( &a_Matrix4, &a_Vector3 ); + vmathM4Prints( &a_Matrix4, "set to translation" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathM4MakePerspective( &a_Matrix4, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathM4Prints( &a_Matrix4, "set to perspective matrix" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathM4MakeFrustum( &a_Matrix4, rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6 ); + vmathM4Prints( &a_Matrix4, "set to frustum matrix" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathM4MakeOrthographic( &a_Matrix4, rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6 ); + vmathM4Prints( &a_Matrix4, "set to orthographic matrix" ); + vmathM4MakeLookAt( &a_Matrix4, &a_Point3, &b_Point3, &a_Vector3 ); + vmathM4Prints( &a_Matrix4, "set to look-at matrix" ); + vmathM4SetCol0( &a_Matrix4, &a_Vector4 ); + vmathM4Prints( &a_Matrix4, "Matrix4 set col 0" ); + vmathM4SetCol1( &a_Matrix4, &a_Vector4 ); + vmathM4Prints( &a_Matrix4, "Matrix4 set col 1" ); + vmathM4SetCol2( &a_Matrix4, &a_Vector4 ); + vmathM4Prints( &a_Matrix4, "Matrix4 set col 2" ); + vmathM4SetCol3( &a_Matrix4, &a_Vector4 ); + vmathM4Prints( &a_Matrix4, "Matrix4 set col 3" ); + vmathM4GetCol0( &tmpV4_0, &a_Matrix4 ); + vmathV4Prints( &tmpV4_0, "Matrix4 get col 0" ); + vmathM4GetCol1( &tmpV4_1, &a_Matrix4 ); + vmathV4Prints( &tmpV4_1, "Matrix4 get col 1" ); + vmathM4GetCol2( &tmpV4_2, &a_Matrix4 ); + vmathV4Prints( &tmpV4_2, "Matrix4 get col 2" ); + vmathM4GetCol3( &tmpV4_3, &a_Matrix4 ); + vmathV4Prints( &tmpV4_3, "Matrix4 get col 3" ); + vmathM4SetCol( &a_Matrix4, 0, &b_Vector4 ); + vmathM4Prints( &a_Matrix4, "Matrix4 set col 0" ); + vmathM4SetCol( &a_Matrix4, 1, &b_Vector4 ); + vmathM4Prints( &a_Matrix4, "Matrix4 set col 1" ); + vmathM4SetCol( &a_Matrix4, 2, &b_Vector4 ); + vmathM4Prints( &a_Matrix4, "Matrix4 set col 2" ); + vmathM4SetCol( &a_Matrix4, 3, &b_Vector4 ); + vmathM4Prints( &a_Matrix4, "Matrix4 set col 3" ); + vmathM4GetCol( &tmpV4_4, &a_Matrix4, 0 ); + vmathV4Prints( &tmpV4_4, "Matrix4 get col 0" ); + vmathM4GetCol( &tmpV4_5, &a_Matrix4, 1 ); + vmathV4Prints( &tmpV4_5, "Matrix4 get col 1" ); + vmathM4GetCol( &tmpV4_6, &a_Matrix4, 2 ); + vmathV4Prints( &tmpV4_6, "Matrix4 get col 2" ); + vmathM4GetCol( &tmpV4_7, &a_Matrix4, 3 ); + vmathV4Prints( &tmpV4_7, "Matrix4 get col 3" ); + vmathM4SetRow( &a_Matrix4, 0, &a_Vector4 ); + vmathM4Prints( &a_Matrix4, "Matrix4 set row 0" ); + vmathM4SetRow( &a_Matrix4, 1, &a_Vector4 ); + vmathM4Prints( &a_Matrix4, "Matrix4 set row 1" ); + vmathM4SetRow( &a_Matrix4, 2, &a_Vector4 ); + vmathM4Prints( &a_Matrix4, "Matrix4 set row 2" ); + vmathM4SetRow( &a_Matrix4, 3, &a_Vector4 ); + vmathM4Prints( &a_Matrix4, "Matrix4 set row 3" ); + vmathM4GetRow( &tmpV4_8, &a_Matrix4, 0 ); + vmathV4Prints( &tmpV4_8, "Matrix4 get row 0" ); + vmathM4GetRow( &tmpV4_9, &a_Matrix4, 1 ); + vmathV4Prints( &tmpV4_9, "Matrix4 get row 1" ); + vmathM4GetRow( &tmpV4_10, &a_Matrix4, 2 ); + vmathV4Prints( &tmpV4_10, "Matrix4 get row 2" ); + vmathM4GetRow( &tmpV4_11, &a_Matrix4, 3 ); + vmathV4Prints( &tmpV4_11, "Matrix4 get row 3" ); + vmathM4SetCol( &a_Matrix4, 0, &a_Vector4 ); + vmathM4Prints( &a_Matrix4, "set " ); + vmathM4SetCol( &a_Matrix4, 1, &a_Vector4 ); + vmathM4Prints( &a_Matrix4, "set " ); + vmathM4SetCol( &a_Matrix4, 2, &a_Vector4 ); + vmathM4Prints( &a_Matrix4, "set " ); + vmathM4SetCol( &a_Matrix4, 3, &a_Vector4 ); + vmathM4Prints( &a_Matrix4, "set " ); + vmathM4GetCol( &tmpV4_12, &a_Matrix4, 0 ); + vmathV4Prints( &tmpV4_12, "get " ); + vmathM4GetCol( &tmpV4_13, &a_Matrix4, 1 ); + vmathV4Prints( &tmpV4_13, "get " ); + vmathM4GetCol( &tmpV4_14, &a_Matrix4, 2 ); + vmathV4Prints( &tmpV4_14, "get " ); + vmathM4GetCol( &tmpV4_15, &a_Matrix4, 3 ); + vmathV4Prints( &tmpV4_15, "get " ); + vmathM4SetElem( &a_Matrix4, 0, 0, randfloat() ); + vmathM4SetElem( &a_Matrix4, 0, 1, randfloat() ); + vmathM4SetElem( &a_Matrix4, 0, 2, randfloat() ); + vmathM4SetElem( &a_Matrix4, 0, 3, randfloat() ); + vmathM4SetElem( &a_Matrix4, 1, 0, randfloat() ); + vmathM4SetElem( &a_Matrix4, 1, 1, randfloat() ); + vmathM4SetElem( &a_Matrix4, 1, 2, randfloat() ); + vmathM4SetElem( &a_Matrix4, 1, 3, randfloat() ); + vmathM4SetElem( &a_Matrix4, 2, 0, randfloat() ); + vmathM4SetElem( &a_Matrix4, 2, 1, randfloat() ); + vmathM4SetElem( &a_Matrix4, 2, 2, randfloat() ); + vmathM4SetElem( &a_Matrix4, 2, 3, randfloat() ); + vmathM4SetElem( &a_Matrix4, 3, 0, randfloat() ); + vmathM4SetElem( &a_Matrix4, 3, 1, randfloat() ); + vmathM4SetElem( &a_Matrix4, 3, 2, randfloat() ); + vmathM4SetElem( &a_Matrix4, 3, 3, randfloat() ); + vmathM4Prints( &a_Matrix4, "Matrix4 set elements" ); + printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 0, 0 )) ); + printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 0, 1 )) ); + printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 0, 2 )) ); + printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 0, 3 )) ); + printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 1, 0 )) ); + printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 1, 1 )) ); + printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 1, 2 )) ); + printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 1, 3 )) ); + printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 2, 0 )) ); + printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 2, 1 )) ); + printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 2, 2 )) ); + printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 2, 3 )) ); + printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 3, 0 )) ); + printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 3, 1 )) ); + printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 3, 2 )) ); + printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 3, 3 )) ); +} + +void +Transform3_methods_test() +{ + VmathMatrix3 a_Matrix3, b_Matrix3; + VmathMatrix4 a_Matrix4, b_Matrix4; + VmathTransform3 a_Transform3, b_Transform3; + VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; + VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; + VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3; + VmathQuat a_Quat, b_Quat, c_Quat, d_Quat; + VmathVector4 tmpV4; + VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7, tmpV3_8, tmpV3_9, tmpV3_10, tmpV3_11, tmpV3_12, tmpV3_13, tmpV3_14, tmpV3_15, tmpV3_16, tmpV3_17; + VmathVector4 tmpV4_0, tmpV4_1, tmpV4_2; + VmathVector3 tmpV3_18, tmpV3_19, tmpV3_20, tmpV3_21; + float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad; + // set a pad value to detect invalid use of padding. + // this will be nan for scalar/ppu implementations, max. float for spu + union { float f; unsigned int u; } tmp; + tmp.u = 0x7fffffff; + pad = tmp.f; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad ); + vmathV4GetXYZ( &a_Vector3, &tmpV4 ); + vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad ); + vmathV4GetXYZ( &b_Vector3, &tmpV4 ); + vmathV4MakeFromV3Scalar( &tmpV4, &c_Vector3, pad ); + vmathV4GetXYZ( &c_Vector3, &tmpV4 ); + vmathV4MakeFromV3Scalar( &tmpV4, &d_Vector3, pad ); + vmathV4GetXYZ( &d_Vector3, &tmpV4 ); + vmathV3Prints( &a_Vector3, "set Vector3 with floats" ); + vmathV3Prints( &b_Vector3, "set Vector3 with floats" ); + vmathV3Prints( &c_Vector3, "set Vector3 with floats" ); + vmathV3Prints( &d_Vector3, "set Vector3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathV4Prints( &a_Vector4, "set Vector4 with floats" ); + vmathV4Prints( &b_Vector4, "set Vector4 with floats" ); + vmathV4Prints( &c_Vector4, "set Vector4 with floats" ); + vmathV4Prints( &d_Vector4, "set Vector4 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); + vmathV3MakeFromP3( &tmpV3_0, &a_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad ); + vmathV4GetXYZ( &tmpV3_1, &tmpV4 ); + vmathP3MakeFromV3( &a_Point3, &tmpV3_1 ); + vmathV3MakeFromP3( &tmpV3_2, &b_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad ); + vmathV4GetXYZ( &tmpV3_3, &tmpV4 ); + vmathP3MakeFromV3( &b_Point3, &tmpV3_3 ); + vmathV3MakeFromP3( &tmpV3_4, &c_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_4, pad ); + vmathV4GetXYZ( &tmpV3_5, &tmpV4 ); + vmathP3MakeFromV3( &c_Point3, &tmpV3_5 ); + vmathV3MakeFromP3( &tmpV3_6, &d_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_6, pad ); + vmathV4GetXYZ( &tmpV3_7, &tmpV4 ); + vmathP3MakeFromV3( &d_Point3, &tmpV3_7 ); + vmathP3Prints( &a_Point3, "set Point3 with floats" ); + vmathP3Prints( &b_Point3, "set Point3 with floats" ); + vmathP3Prints( &c_Point3, "set Point3 with floats" ); + vmathP3Prints( &d_Point3, "set Point3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathQPrints( &a_Quat, "set Quat with floats" ); + vmathQPrints( &b_Quat, "set Quat with floats" ); + vmathQPrints( &c_Quat, "set Quat with floats" ); + vmathQPrints( &d_Quat, "set Quat with floats" ); + vmathM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 ); + vmathM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 ); + vmathM3Prints( &a_Matrix3, "set Matrix3 columns" ); + vmathM3Prints( &b_Matrix3, "set Matrix3 columns" ); + vmathM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 ); + vmathM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 ); + vmathM4Prints( &a_Matrix4, "set Matrix4 columns" ); + vmathM4Prints( &b_Matrix4, "set Matrix4 columns" ); + vmathT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 ); + vmathT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 ); + vmathT3Prints( &a_Transform3, "set Transform3 columns" ); + vmathT3Prints( &b_Transform3, "set Transform3 columns" ); + vmathT3MakeFromM3V3( &a_Transform3, &a_Matrix3, &a_Vector3 ); + vmathT3Prints( &a_Transform3, "construct Transform3 with Matrix3 and Vector3" ); + vmathT3MakeFromQV3( &a_Transform3, &a_Quat, &a_Vector3 ); + vmathT3Prints( &a_Transform3, "construct Transform3 with Quat and Vector3" ); + vmathT3Copy( &a_Transform3, &b_Transform3 ); + vmathT3Prints( &a_Transform3, "assign to Transform3 from Transform3" ); + vmathT3MakeFromScalar( &a_Transform3, randfloat() ); + vmathT3Prints( &a_Transform3, "set Transform3 with float" ); + vmathT3MakeFromScalar( &a_Transform3, randfloat() ); + vmathT3Prints( &a_Transform3, "set Transform3 with float" ); + vmathT3MakeFromScalar( &a_Transform3, 0.0f ); + vmathT3Prints( &a_Transform3, "set elements to zero" ); + vmathT3MakeIdentity( &a_Transform3 ); + vmathT3Prints( &a_Transform3, "set to identity" ); + vmathT3MakeRotationX( &a_Transform3, randfloat() ); + vmathT3Prints( &a_Transform3, "set to rotationX" ); + vmathT3MakeRotationY( &a_Transform3, randfloat() ); + vmathT3Prints( &a_Transform3, "set to rotationY" ); + vmathT3MakeRotationZ( &a_Transform3, randfloat() ); + vmathT3Prints( &a_Transform3, "set to rotationZ" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &tmpV3_8, rndflt3, rndflt2, rndflt1 ); + vmathT3MakeRotationZYX( &a_Transform3, &tmpV3_8 ); + vmathT3Prints( &a_Transform3, "set to rotation from Z,Y,X angles" ); + vmathV3Normalize( &tmpV3_9, &a_Vector3 ); + vmathT3MakeRotationAxis( &a_Transform3, randfloat(), &tmpV3_9 ); + vmathT3Prints( &a_Transform3, "set to rotation from axis angle" ); + vmathT3MakeTranslation( &a_Transform3, &a_Vector3 ); + vmathT3Prints( &a_Transform3, "set to translation" ); + vmathT3SetCol0( &a_Transform3, &a_Vector3 ); + vmathT3Prints( &a_Transform3, "Transform3 set col 0" ); + vmathT3SetCol1( &a_Transform3, &a_Vector3 ); + vmathT3Prints( &a_Transform3, "Transform3 set col 1" ); + vmathT3SetCol2( &a_Transform3, &a_Vector3 ); + vmathT3Prints( &a_Transform3, "Transform3 set col 2" ); + vmathT3SetCol3( &a_Transform3, &a_Vector3 ); + vmathT3Prints( &a_Transform3, "Transform3 set col 3" ); + vmathT3GetCol0( &tmpV3_10, &a_Transform3 ); + vmathV3Prints( &tmpV3_10, "Transform3 get col 0" ); + vmathT3GetCol1( &tmpV3_11, &a_Transform3 ); + vmathV3Prints( &tmpV3_11, "Transform3 get col 1" ); + vmathT3GetCol2( &tmpV3_12, &a_Transform3 ); + vmathV3Prints( &tmpV3_12, "Transform3 get col 2" ); + vmathT3GetCol3( &tmpV3_13, &a_Transform3 ); + vmathV3Prints( &tmpV3_13, "Transform3 get col 3" ); + vmathT3SetCol( &a_Transform3, 0, &b_Vector3 ); + vmathT3Prints( &a_Transform3, "Transform3 set col 0" ); + vmathT3SetCol( &a_Transform3, 1, &b_Vector3 ); + vmathT3Prints( &a_Transform3, "Transform3 set col 1" ); + vmathT3SetCol( &a_Transform3, 2, &b_Vector3 ); + vmathT3Prints( &a_Transform3, "Transform3 set col 2" ); + vmathT3SetCol( &a_Transform3, 3, &b_Vector3 ); + vmathT3Prints( &a_Transform3, "Transform3 set col 3" ); + vmathT3GetCol( &tmpV3_14, &a_Transform3, 0 ); + vmathV3Prints( &tmpV3_14, "Transform3 get col 0" ); + vmathT3GetCol( &tmpV3_15, &a_Transform3, 1 ); + vmathV3Prints( &tmpV3_15, "Transform3 get col 1" ); + vmathT3GetCol( &tmpV3_16, &a_Transform3, 2 ); + vmathV3Prints( &tmpV3_16, "Transform3 get col 2" ); + vmathT3GetCol( &tmpV3_17, &a_Transform3, 3 ); + vmathV3Prints( &tmpV3_17, "Transform3 get col 3" ); + vmathT3SetRow( &a_Transform3, 0, &a_Vector4 ); + vmathT3Prints( &a_Transform3, "Transform3 set row 0" ); + vmathT3SetRow( &a_Transform3, 1, &a_Vector4 ); + vmathT3Prints( &a_Transform3, "Transform3 set row 1" ); + vmathT3SetRow( &a_Transform3, 2, &a_Vector4 ); + vmathT3Prints( &a_Transform3, "Transform3 set row 2" ); + vmathT3GetRow( &tmpV4_0, &a_Transform3, 0 ); + vmathV4Prints( &tmpV4_0, "Transform3 get row 0" ); + vmathT3GetRow( &tmpV4_1, &a_Transform3, 1 ); + vmathV4Prints( &tmpV4_1, "Transform3 get row 1" ); + vmathT3GetRow( &tmpV4_2, &a_Transform3, 2 ); + vmathV4Prints( &tmpV4_2, "Transform3 get row 2" ); + vmathT3SetCol( &a_Transform3, 0, &a_Vector3 ); + vmathT3Prints( &a_Transform3, "set " ); + vmathT3SetCol( &a_Transform3, 1, &a_Vector3 ); + vmathT3Prints( &a_Transform3, "set " ); + vmathT3SetCol( &a_Transform3, 2, &a_Vector3 ); + vmathT3Prints( &a_Transform3, "set " ); + vmathT3SetCol( &a_Transform3, 3, &a_Vector3 ); + vmathT3Prints( &a_Transform3, "set " ); + vmathT3GetCol( &tmpV3_18, &a_Transform3, 0 ); + vmathV3Prints( &tmpV3_18, "get " ); + vmathT3GetCol( &tmpV3_19, &a_Transform3, 1 ); + vmathV3Prints( &tmpV3_19, "get " ); + vmathT3GetCol( &tmpV3_20, &a_Transform3, 2 ); + vmathV3Prints( &tmpV3_20, "get " ); + vmathT3GetCol( &tmpV3_21, &a_Transform3, 3 ); + vmathV3Prints( &tmpV3_21, "get " ); + vmathT3SetElem( &a_Transform3, 0, 0, randfloat() ); + vmathT3SetElem( &a_Transform3, 0, 1, randfloat() ); + vmathT3SetElem( &a_Transform3, 0, 2, randfloat() ); + vmathT3SetElem( &a_Transform3, 1, 0, randfloat() ); + vmathT3SetElem( &a_Transform3, 1, 1, randfloat() ); + vmathT3SetElem( &a_Transform3, 1, 2, randfloat() ); + vmathT3SetElem( &a_Transform3, 2, 0, randfloat() ); + vmathT3SetElem( &a_Transform3, 2, 1, randfloat() ); + vmathT3SetElem( &a_Transform3, 2, 2, randfloat() ); + vmathT3SetElem( &a_Transform3, 3, 0, randfloat() ); + vmathT3SetElem( &a_Transform3, 3, 1, randfloat() ); + vmathT3SetElem( &a_Transform3, 3, 2, randfloat() ); + vmathT3Prints( &a_Transform3, "Transform3 set elements" ); + printf("%f\n", getfloat(vmathT3GetElem( &a_Transform3, 0, 0 )) ); + printf("%f\n", getfloat(vmathT3GetElem( &a_Transform3, 0, 1 )) ); + printf("%f\n", getfloat(vmathT3GetElem( &a_Transform3, 0, 2 )) ); + printf("%f\n", getfloat(vmathT3GetElem( &a_Transform3, 1, 0 )) ); + printf("%f\n", getfloat(vmathT3GetElem( &a_Transform3, 1, 1 )) ); + printf("%f\n", getfloat(vmathT3GetElem( &a_Transform3, 1, 2 )) ); + printf("%f\n", getfloat(vmathT3GetElem( &a_Transform3, 2, 0 )) ); + printf("%f\n", getfloat(vmathT3GetElem( &a_Transform3, 2, 1 )) ); + printf("%f\n", getfloat(vmathT3GetElem( &a_Transform3, 2, 2 )) ); + printf("%f\n", getfloat(vmathT3GetElem( &a_Transform3, 3, 0 )) ); + printf("%f\n", getfloat(vmathT3GetElem( &a_Transform3, 3, 1 )) ); + printf("%f\n", getfloat(vmathT3GetElem( &a_Transform3, 3, 2 )) ); +} + +int main() +{ + int i; + printf("\n __begin__ \n"); + for ( i = 0; i < 2; i++ ) { + Matrix3_methods_test(); + Matrix4_methods_test(); + Transform3_methods_test(); + } + printf("\n __end__ \n"); + return 0; +} diff --git a/vectormathlibrary/tests/test2_aos_cpp.cpp b/vectormathlibrary/tests/test2_aos_cpp.cpp new file mode 100644 index 000000000..55567c8a9 --- /dev/null +++ b/vectormathlibrary/tests/test2_aos_cpp.cpp @@ -0,0 +1,784 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _VECTORMATH_AOS_TEST + +#include "vectormath_aos.h" +#include "test.h" + +int iteration = 0; + +using namespace Vectormath; +using namespace Vectormath::Aos; + +void +Matrix3_methods_test() +{ + Matrix3 a_Matrix3, b_Matrix3; + Matrix4 a_Matrix4, b_Matrix4; + Transform3 a_Transform3, b_Transform3; + Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; + Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; + Point3 a_Point3, b_Point3, c_Point3, d_Point3; + Quat a_Quat, b_Quat, c_Quat, d_Quat; + Vector4 tmpV4; + float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad; + // set a pad value to detect invalid use of padding. + // this will be nan for scalar/ppu implementations, max. float for spu + union { float f; unsigned int u; } tmp; + tmp.u = 0x7fffffff; + pad = tmp.f; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + tmpV4 = Vector4( a_Vector3, pad ); + a_Vector3 = tmpV4.getXYZ( ); + tmpV4 = Vector4( b_Vector3, pad ); + b_Vector3 = tmpV4.getXYZ( ); + tmpV4 = Vector4( c_Vector3, pad ); + c_Vector3 = tmpV4.getXYZ( ); + tmpV4 = Vector4( d_Vector3, pad ); + d_Vector3 = tmpV4.getXYZ( ); + print( a_Vector3, "set Vector3 with floats" ); + print( b_Vector3, "set Vector3 with floats" ); + print( c_Vector3, "set Vector3 with floats" ); + print( d_Vector3, "set Vector3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Vector4, "set Vector4 with floats" ); + print( b_Vector4, "set Vector4 with floats" ); + print( c_Vector4, "set Vector4 with floats" ); + print( d_Vector4, "set Vector4 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Point3 = Point3( rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + tmpV4 = Vector4( Vector3( a_Point3 ), pad ); + a_Point3 = Point3( tmpV4.getXYZ( ) ); + tmpV4 = Vector4( Vector3( b_Point3 ), pad ); + b_Point3 = Point3( tmpV4.getXYZ( ) ); + tmpV4 = Vector4( Vector3( c_Point3 ), pad ); + c_Point3 = Point3( tmpV4.getXYZ( ) ); + tmpV4 = Vector4( Vector3( d_Point3 ), pad ); + d_Point3 = Point3( tmpV4.getXYZ( ) ); + print( a_Point3, "set Point3 with floats" ); + print( b_Point3, "set Point3 with floats" ); + print( c_Point3, "set Point3 with floats" ); + print( d_Point3, "set Point3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Quat, "set Quat with floats" ); + print( b_Quat, "set Quat with floats" ); + print( c_Quat, "set Quat with floats" ); + print( d_Quat, "set Quat with floats" ); + a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 ); + b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 ); + print( a_Matrix3, "set Matrix3 columns" ); + print( b_Matrix3, "set Matrix3 columns" ); + a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 ); + b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 ); + print( a_Matrix4, "set Matrix4 columns" ); + print( b_Matrix4, "set Matrix4 columns" ); + a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 ); + b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 ); + print( a_Transform3, "set Transform3 columns" ); + print( b_Transform3, "set Transform3 columns" ); + a_Matrix3 = Matrix3( normalize( a_Quat ) ); + print( a_Matrix3, "construct Matrix3 with Quat" ); + a_Quat = Quat( a_Matrix3 ); + print( a_Quat, "construct Quat with Matrix3" ); + a_Matrix3 = b_Matrix3; + print( a_Matrix3, "assign to Matrix3 from Matrix3" ); + a_Matrix3 = Matrix3( randfloat() ); + print( a_Matrix3, "set Matrix3 with float" ); + a_Matrix3 = Matrix3( scalar_float(randfloat()) ); + print( a_Matrix3, "set Matrix3 with float" ); + a_Matrix3 = Matrix3( 0.0f ); + print( a_Matrix3, "set elements to zero" ); + a_Matrix3 = Matrix3::identity( ); + print( a_Matrix3, "set to identity" ); + a_Matrix3 = Matrix3::rotationX( randfloat() ); + print( a_Matrix3, "set to rotationX" ); + a_Matrix3 = Matrix3::rotationY( randfloat() ); + print( a_Matrix3, "set to rotationY" ); + a_Matrix3 = Matrix3::rotationZ( randfloat() ); + print( a_Matrix3, "set to rotationZ" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Matrix3 = Matrix3::rotationZYX( Vector3( rndflt3, rndflt2, rndflt1 ) ); + print( a_Matrix3, "set to rotation from Z,Y,X angles" ); + a_Matrix3 = Matrix3::rotation( randfloat(), normalize( a_Vector3 ) ); + print( a_Matrix3, "set to rotation from axis angle" ); + a_Matrix3.setCol0( a_Vector3 ); + print( a_Matrix3, "Matrix3 set col 0" ); + a_Matrix3.setCol1( a_Vector3 ); + print( a_Matrix3, "Matrix3 set col 1" ); + a_Matrix3.setCol2( a_Vector3 ); + print( a_Matrix3, "Matrix3 set col 2" ); + print( a_Matrix3.getCol0( ), "Matrix3 get col 0" ); + print( a_Matrix3.getCol1( ), "Matrix3 get col 1" ); + print( a_Matrix3.getCol2( ), "Matrix3 get col 2" ); + a_Matrix3.setCol( 0, b_Vector3 ); + print( a_Matrix3, "Matrix3 set col 0" ); + a_Matrix3.setCol( 1, b_Vector3 ); + print( a_Matrix3, "Matrix3 set col 1" ); + a_Matrix3.setCol( 2, b_Vector3 ); + print( a_Matrix3, "Matrix3 set col 2" ); + print( a_Matrix3.getCol( 0 ), "Matrix3 get col 0" ); + print( a_Matrix3.getCol( 1 ), "Matrix3 get col 1" ); + print( a_Matrix3.getCol( 2 ), "Matrix3 get col 2" ); + a_Matrix3.setRow( 0, a_Vector3 ); + print( a_Matrix3, "Matrix3 set row 0" ); + a_Matrix3.setRow( 1, a_Vector3 ); + print( a_Matrix3, "Matrix3 set row 1" ); + a_Matrix3.setRow( 2, a_Vector3 ); + print( a_Matrix3, "Matrix3 set row 2" ); + print( a_Matrix3.getRow( 0 ), "Matrix3 get row 0" ); + print( a_Matrix3.getRow( 1 ), "Matrix3 get row 1" ); + print( a_Matrix3.getRow( 2 ), "Matrix3 get row 2" ); + a_Matrix3[0] = a_Vector3; + print( a_Matrix3, "set Matrix3[0]" ); + a_Matrix3[1] = a_Vector3; + print( a_Matrix3, "set Matrix3[1]" ); + a_Matrix3[2] = a_Vector3; + print( a_Matrix3, "set Matrix3[2]" ); + a_Matrix3[0] = a_Vector3; + print( a_Matrix3[0], "get Matrix3[0]" ); + a_Matrix3[1] = a_Vector3; + print( a_Matrix3[1], "get Matrix3[1]" ); + a_Matrix3[2] = a_Vector3; + print( a_Matrix3[2], "get Matrix3[2]" ); + a_Matrix3.setElem( 0, 0, randfloat() ); + a_Matrix3.setElem( 0, 1, randfloat() ); + a_Matrix3.setElem( 0, 2, randfloat() ); + a_Matrix3.setElem( 1, 0, randfloat() ); + a_Matrix3.setElem( 1, 1, randfloat() ); + a_Matrix3.setElem( 1, 2, randfloat() ); + a_Matrix3.setElem( 2, 0, randfloat() ); + a_Matrix3.setElem( 2, 1, randfloat() ); + a_Matrix3.setElem( 2, 2, randfloat() ); + print( a_Matrix3, "Matrix3 set elements" ); + printf("%f\n", getfloat(a_Matrix3.getElem( 0, 0 )) ); + printf("%f\n", getfloat(a_Matrix3.getElem( 0, 1 )) ); + printf("%f\n", getfloat(a_Matrix3.getElem( 0, 2 )) ); + printf("%f\n", getfloat(a_Matrix3.getElem( 1, 0 )) ); + printf("%f\n", getfloat(a_Matrix3.getElem( 1, 1 )) ); + printf("%f\n", getfloat(a_Matrix3.getElem( 1, 2 )) ); + printf("%f\n", getfloat(a_Matrix3.getElem( 2, 0 )) ); + printf("%f\n", getfloat(a_Matrix3.getElem( 2, 1 )) ); + printf("%f\n", getfloat(a_Matrix3.getElem( 2, 2 )) ); +} + +void +Matrix4_methods_test() +{ + Matrix3 a_Matrix3, b_Matrix3; + Matrix4 a_Matrix4, b_Matrix4; + Transform3 a_Transform3, b_Transform3; + Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; + Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; + Point3 a_Point3, b_Point3, c_Point3, d_Point3; + Quat a_Quat, b_Quat, c_Quat, d_Quat; + Vector4 tmpV4; + float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad; + // set a pad value to detect invalid use of padding. + // this will be nan for scalar/ppu implementations, max. float for spu + union { float f; unsigned int u; } tmp; + tmp.u = 0x7fffffff; + pad = tmp.f; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + tmpV4 = Vector4( a_Vector3, pad ); + a_Vector3 = tmpV4.getXYZ( ); + tmpV4 = Vector4( b_Vector3, pad ); + b_Vector3 = tmpV4.getXYZ( ); + tmpV4 = Vector4( c_Vector3, pad ); + c_Vector3 = tmpV4.getXYZ( ); + tmpV4 = Vector4( d_Vector3, pad ); + d_Vector3 = tmpV4.getXYZ( ); + print( a_Vector3, "set Vector3 with floats" ); + print( b_Vector3, "set Vector3 with floats" ); + print( c_Vector3, "set Vector3 with floats" ); + print( d_Vector3, "set Vector3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Vector4, "set Vector4 with floats" ); + print( b_Vector4, "set Vector4 with floats" ); + print( c_Vector4, "set Vector4 with floats" ); + print( d_Vector4, "set Vector4 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Point3 = Point3( rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + tmpV4 = Vector4( Vector3( a_Point3 ), pad ); + a_Point3 = Point3( tmpV4.getXYZ( ) ); + tmpV4 = Vector4( Vector3( b_Point3 ), pad ); + b_Point3 = Point3( tmpV4.getXYZ( ) ); + tmpV4 = Vector4( Vector3( c_Point3 ), pad ); + c_Point3 = Point3( tmpV4.getXYZ( ) ); + tmpV4 = Vector4( Vector3( d_Point3 ), pad ); + d_Point3 = Point3( tmpV4.getXYZ( ) ); + print( a_Point3, "set Point3 with floats" ); + print( b_Point3, "set Point3 with floats" ); + print( c_Point3, "set Point3 with floats" ); + print( d_Point3, "set Point3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Quat, "set Quat with floats" ); + print( b_Quat, "set Quat with floats" ); + print( c_Quat, "set Quat with floats" ); + print( d_Quat, "set Quat with floats" ); + a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 ); + b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 ); + print( a_Matrix3, "set Matrix3 columns" ); + print( b_Matrix3, "set Matrix3 columns" ); + a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 ); + b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 ); + print( a_Matrix4, "set Matrix4 columns" ); + print( b_Matrix4, "set Matrix4 columns" ); + a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 ); + b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 ); + print( a_Transform3, "set Transform3 columns" ); + print( b_Transform3, "set Transform3 columns" ); + a_Matrix4 = Matrix4( a_Transform3 ); + print( a_Matrix4, "construct Matrix4 with Transform3" ); + a_Matrix4 = Matrix4( a_Matrix3, a_Vector3 ); + print( a_Matrix4, "construct Matrix4 with Matrix3 and Vector3" ); + a_Matrix4 = Matrix4( a_Quat, a_Vector3 ); + print( a_Matrix4, "construct Matrix4 with Quat and Vector3" ); + a_Matrix4 = b_Matrix4; + print( a_Matrix4, "assign to Matrix4 from Matrix4" ); + a_Matrix4 = Matrix4( randfloat() ); + print( a_Matrix4, "set Matrix4 with float" ); + a_Matrix4 = Matrix4( scalar_float(randfloat()) ); + print( a_Matrix4, "set Matrix4 with float" ); + a_Matrix4 = Matrix4( 0.0f ); + print( a_Matrix4, "set elements to zero" ); + a_Matrix4 = Matrix4::identity( ); + print( a_Matrix4, "set to identity" ); + a_Matrix4 = Matrix4::rotationX( randfloat() ); + print( a_Matrix4, "set to rotationX" ); + a_Matrix4 = Matrix4::rotationY( randfloat() ); + print( a_Matrix4, "set to rotationY" ); + a_Matrix4 = Matrix4::rotationZ( randfloat() ); + print( a_Matrix4, "set to rotationZ" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Matrix4 = Matrix4::rotationZYX( Vector3( rndflt3, rndflt2, rndflt1 ) ); + print( a_Matrix4, "set to rotation from Z,Y,X angles" ); + a_Matrix4 = Matrix4::rotation( randfloat(), normalize( a_Vector3 ) ); + print( a_Matrix4, "set to rotation from axis angle" ); + a_Matrix4 = Matrix4::translation( a_Vector3 ); + print( a_Matrix4, "set to translation" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Matrix4 = Matrix4::perspective( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Matrix4, "set to perspective matrix" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + a_Matrix4 = Matrix4::frustum( rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6 ); + print( a_Matrix4, "set to frustum matrix" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + a_Matrix4 = Matrix4::orthographic( rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6 ); + print( a_Matrix4, "set to orthographic matrix" ); + a_Matrix4 = Matrix4::lookAt( a_Point3, b_Point3, a_Vector3 ); + print( a_Matrix4, "set to look-at matrix" ); + a_Matrix4.setCol0( a_Vector4 ); + print( a_Matrix4, "Matrix4 set col 0" ); + a_Matrix4.setCol1( a_Vector4 ); + print( a_Matrix4, "Matrix4 set col 1" ); + a_Matrix4.setCol2( a_Vector4 ); + print( a_Matrix4, "Matrix4 set col 2" ); + a_Matrix4.setCol3( a_Vector4 ); + print( a_Matrix4, "Matrix4 set col 3" ); + print( a_Matrix4.getCol0( ), "Matrix4 get col 0" ); + print( a_Matrix4.getCol1( ), "Matrix4 get col 1" ); + print( a_Matrix4.getCol2( ), "Matrix4 get col 2" ); + print( a_Matrix4.getCol3( ), "Matrix4 get col 3" ); + a_Matrix4.setCol( 0, b_Vector4 ); + print( a_Matrix4, "Matrix4 set col 0" ); + a_Matrix4.setCol( 1, b_Vector4 ); + print( a_Matrix4, "Matrix4 set col 1" ); + a_Matrix4.setCol( 2, b_Vector4 ); + print( a_Matrix4, "Matrix4 set col 2" ); + a_Matrix4.setCol( 3, b_Vector4 ); + print( a_Matrix4, "Matrix4 set col 3" ); + print( a_Matrix4.getCol( 0 ), "Matrix4 get col 0" ); + print( a_Matrix4.getCol( 1 ), "Matrix4 get col 1" ); + print( a_Matrix4.getCol( 2 ), "Matrix4 get col 2" ); + print( a_Matrix4.getCol( 3 ), "Matrix4 get col 3" ); + a_Matrix4.setRow( 0, a_Vector4 ); + print( a_Matrix4, "Matrix4 set row 0" ); + a_Matrix4.setRow( 1, a_Vector4 ); + print( a_Matrix4, "Matrix4 set row 1" ); + a_Matrix4.setRow( 2, a_Vector4 ); + print( a_Matrix4, "Matrix4 set row 2" ); + a_Matrix4.setRow( 3, a_Vector4 ); + print( a_Matrix4, "Matrix4 set row 3" ); + print( a_Matrix4.getRow( 0 ), "Matrix4 get row 0" ); + print( a_Matrix4.getRow( 1 ), "Matrix4 get row 1" ); + print( a_Matrix4.getRow( 2 ), "Matrix4 get row 2" ); + print( a_Matrix4.getRow( 3 ), "Matrix4 get row 3" ); + a_Matrix4[0] = a_Vector4; + print( a_Matrix4, "set Matrix4[0]" ); + a_Matrix4[1] = a_Vector4; + print( a_Matrix4, "set Matrix4[1]" ); + a_Matrix4[2] = a_Vector4; + print( a_Matrix4, "set Matrix4[2]" ); + a_Matrix4[3] = a_Vector4; + print( a_Matrix4, "set Matrix4[3]" ); + a_Matrix4[0] = a_Vector4; + print( a_Matrix4[0], "get Matrix4[0]" ); + a_Matrix4[1] = a_Vector4; + print( a_Matrix4[1], "get Matrix4[1]" ); + a_Matrix4[2] = a_Vector4; + print( a_Matrix4[2], "get Matrix4[2]" ); + a_Matrix4[3] = a_Vector4; + print( a_Matrix4[3], "get Matrix4[3]" ); + a_Matrix4.setElem( 0, 0, randfloat() ); + a_Matrix4.setElem( 0, 1, randfloat() ); + a_Matrix4.setElem( 0, 2, randfloat() ); + a_Matrix4.setElem( 0, 3, randfloat() ); + a_Matrix4.setElem( 1, 0, randfloat() ); + a_Matrix4.setElem( 1, 1, randfloat() ); + a_Matrix4.setElem( 1, 2, randfloat() ); + a_Matrix4.setElem( 1, 3, randfloat() ); + a_Matrix4.setElem( 2, 0, randfloat() ); + a_Matrix4.setElem( 2, 1, randfloat() ); + a_Matrix4.setElem( 2, 2, randfloat() ); + a_Matrix4.setElem( 2, 3, randfloat() ); + a_Matrix4.setElem( 3, 0, randfloat() ); + a_Matrix4.setElem( 3, 1, randfloat() ); + a_Matrix4.setElem( 3, 2, randfloat() ); + a_Matrix4.setElem( 3, 3, randfloat() ); + print( a_Matrix4, "Matrix4 set elements" ); + printf("%f\n", getfloat(a_Matrix4.getElem( 0, 0 )) ); + printf("%f\n", getfloat(a_Matrix4.getElem( 0, 1 )) ); + printf("%f\n", getfloat(a_Matrix4.getElem( 0, 2 )) ); + printf("%f\n", getfloat(a_Matrix4.getElem( 0, 3 )) ); + printf("%f\n", getfloat(a_Matrix4.getElem( 1, 0 )) ); + printf("%f\n", getfloat(a_Matrix4.getElem( 1, 1 )) ); + printf("%f\n", getfloat(a_Matrix4.getElem( 1, 2 )) ); + printf("%f\n", getfloat(a_Matrix4.getElem( 1, 3 )) ); + printf("%f\n", getfloat(a_Matrix4.getElem( 2, 0 )) ); + printf("%f\n", getfloat(a_Matrix4.getElem( 2, 1 )) ); + printf("%f\n", getfloat(a_Matrix4.getElem( 2, 2 )) ); + printf("%f\n", getfloat(a_Matrix4.getElem( 2, 3 )) ); + printf("%f\n", getfloat(a_Matrix4.getElem( 3, 0 )) ); + printf("%f\n", getfloat(a_Matrix4.getElem( 3, 1 )) ); + printf("%f\n", getfloat(a_Matrix4.getElem( 3, 2 )) ); + printf("%f\n", getfloat(a_Matrix4.getElem( 3, 3 )) ); +} + +void +Transform3_methods_test() +{ + Matrix3 a_Matrix3, b_Matrix3; + Matrix4 a_Matrix4, b_Matrix4; + Transform3 a_Transform3, b_Transform3; + Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; + Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; + Point3 a_Point3, b_Point3, c_Point3, d_Point3; + Quat a_Quat, b_Quat, c_Quat, d_Quat; + Vector4 tmpV4; + float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad; + // set a pad value to detect invalid use of padding. + // this will be nan for scalar/ppu implementations, max. float for spu + union { float f; unsigned int u; } tmp; + tmp.u = 0x7fffffff; + pad = tmp.f; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + tmpV4 = Vector4( a_Vector3, pad ); + a_Vector3 = tmpV4.getXYZ( ); + tmpV4 = Vector4( b_Vector3, pad ); + b_Vector3 = tmpV4.getXYZ( ); + tmpV4 = Vector4( c_Vector3, pad ); + c_Vector3 = tmpV4.getXYZ( ); + tmpV4 = Vector4( d_Vector3, pad ); + d_Vector3 = tmpV4.getXYZ( ); + print( a_Vector3, "set Vector3 with floats" ); + print( b_Vector3, "set Vector3 with floats" ); + print( c_Vector3, "set Vector3 with floats" ); + print( d_Vector3, "set Vector3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Vector4, "set Vector4 with floats" ); + print( b_Vector4, "set Vector4 with floats" ); + print( c_Vector4, "set Vector4 with floats" ); + print( d_Vector4, "set Vector4 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Point3 = Point3( rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + tmpV4 = Vector4( Vector3( a_Point3 ), pad ); + a_Point3 = Point3( tmpV4.getXYZ( ) ); + tmpV4 = Vector4( Vector3( b_Point3 ), pad ); + b_Point3 = Point3( tmpV4.getXYZ( ) ); + tmpV4 = Vector4( Vector3( c_Point3 ), pad ); + c_Point3 = Point3( tmpV4.getXYZ( ) ); + tmpV4 = Vector4( Vector3( d_Point3 ), pad ); + d_Point3 = Point3( tmpV4.getXYZ( ) ); + print( a_Point3, "set Point3 with floats" ); + print( b_Point3, "set Point3 with floats" ); + print( c_Point3, "set Point3 with floats" ); + print( d_Point3, "set Point3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Quat, "set Quat with floats" ); + print( b_Quat, "set Quat with floats" ); + print( c_Quat, "set Quat with floats" ); + print( d_Quat, "set Quat with floats" ); + a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 ); + b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 ); + print( a_Matrix3, "set Matrix3 columns" ); + print( b_Matrix3, "set Matrix3 columns" ); + a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 ); + b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 ); + print( a_Matrix4, "set Matrix4 columns" ); + print( b_Matrix4, "set Matrix4 columns" ); + a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 ); + b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 ); + print( a_Transform3, "set Transform3 columns" ); + print( b_Transform3, "set Transform3 columns" ); + a_Transform3 = Transform3( a_Matrix3, a_Vector3 ); + print( a_Transform3, "construct Transform3 with Matrix3 and Vector3" ); + a_Transform3 = Transform3( a_Quat, a_Vector3 ); + print( a_Transform3, "construct Transform3 with Quat and Vector3" ); + a_Transform3 = b_Transform3; + print( a_Transform3, "assign to Transform3 from Transform3" ); + a_Transform3 = Transform3( randfloat() ); + print( a_Transform3, "set Transform3 with float" ); + a_Transform3 = Transform3( scalar_float(randfloat()) ); + print( a_Transform3, "set Transform3 with float" ); + a_Transform3 = Transform3( 0.0f ); + print( a_Transform3, "set elements to zero" ); + a_Transform3 = Transform3::identity( ); + print( a_Transform3, "set to identity" ); + a_Transform3 = Transform3::rotationX( randfloat() ); + print( a_Transform3, "set to rotationX" ); + a_Transform3 = Transform3::rotationY( randfloat() ); + print( a_Transform3, "set to rotationY" ); + a_Transform3 = Transform3::rotationZ( randfloat() ); + print( a_Transform3, "set to rotationZ" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Transform3 = Transform3::rotationZYX( Vector3( rndflt3, rndflt2, rndflt1 ) ); + print( a_Transform3, "set to rotation from Z,Y,X angles" ); + a_Transform3 = Transform3::rotation( randfloat(), normalize( a_Vector3 ) ); + print( a_Transform3, "set to rotation from axis angle" ); + a_Transform3 = Transform3::translation( a_Vector3 ); + print( a_Transform3, "set to translation" ); + a_Transform3.setCol0( a_Vector3 ); + print( a_Transform3, "Transform3 set col 0" ); + a_Transform3.setCol1( a_Vector3 ); + print( a_Transform3, "Transform3 set col 1" ); + a_Transform3.setCol2( a_Vector3 ); + print( a_Transform3, "Transform3 set col 2" ); + a_Transform3.setCol3( a_Vector3 ); + print( a_Transform3, "Transform3 set col 3" ); + print( a_Transform3.getCol0( ), "Transform3 get col 0" ); + print( a_Transform3.getCol1( ), "Transform3 get col 1" ); + print( a_Transform3.getCol2( ), "Transform3 get col 2" ); + print( a_Transform3.getCol3( ), "Transform3 get col 3" ); + a_Transform3.setCol( 0, b_Vector3 ); + print( a_Transform3, "Transform3 set col 0" ); + a_Transform3.setCol( 1, b_Vector3 ); + print( a_Transform3, "Transform3 set col 1" ); + a_Transform3.setCol( 2, b_Vector3 ); + print( a_Transform3, "Transform3 set col 2" ); + a_Transform3.setCol( 3, b_Vector3 ); + print( a_Transform3, "Transform3 set col 3" ); + print( a_Transform3.getCol( 0 ), "Transform3 get col 0" ); + print( a_Transform3.getCol( 1 ), "Transform3 get col 1" ); + print( a_Transform3.getCol( 2 ), "Transform3 get col 2" ); + print( a_Transform3.getCol( 3 ), "Transform3 get col 3" ); + a_Transform3.setRow( 0, a_Vector4 ); + print( a_Transform3, "Transform3 set row 0" ); + a_Transform3.setRow( 1, a_Vector4 ); + print( a_Transform3, "Transform3 set row 1" ); + a_Transform3.setRow( 2, a_Vector4 ); + print( a_Transform3, "Transform3 set row 2" ); + print( a_Transform3.getRow( 0 ), "Transform3 get row 0" ); + print( a_Transform3.getRow( 1 ), "Transform3 get row 1" ); + print( a_Transform3.getRow( 2 ), "Transform3 get row 2" ); + a_Transform3[0] = a_Vector3; + print( a_Transform3, "set Transform3[0]" ); + a_Transform3[1] = a_Vector3; + print( a_Transform3, "set Transform3[1]" ); + a_Transform3[2] = a_Vector3; + print( a_Transform3, "set Transform3[2]" ); + a_Transform3[3] = a_Vector3; + print( a_Transform3, "set Transform3[3]" ); + a_Transform3[0] = a_Vector3; + print( a_Transform3[0], "get Transform3[0]" ); + a_Transform3[1] = a_Vector3; + print( a_Transform3[1], "get Transform3[1]" ); + a_Transform3[2] = a_Vector3; + print( a_Transform3[2], "get Transform3[2]" ); + a_Transform3[3] = a_Vector3; + print( a_Transform3[3], "get Transform3[3]" ); + a_Transform3.setElem( 0, 0, randfloat() ); + a_Transform3.setElem( 0, 1, randfloat() ); + a_Transform3.setElem( 0, 2, randfloat() ); + a_Transform3.setElem( 1, 0, randfloat() ); + a_Transform3.setElem( 1, 1, randfloat() ); + a_Transform3.setElem( 1, 2, randfloat() ); + a_Transform3.setElem( 2, 0, randfloat() ); + a_Transform3.setElem( 2, 1, randfloat() ); + a_Transform3.setElem( 2, 2, randfloat() ); + a_Transform3.setElem( 3, 0, randfloat() ); + a_Transform3.setElem( 3, 1, randfloat() ); + a_Transform3.setElem( 3, 2, randfloat() ); + print( a_Transform3, "Transform3 set elements" ); + printf("%f\n", getfloat(a_Transform3.getElem( 0, 0 )) ); + printf("%f\n", getfloat(a_Transform3.getElem( 0, 1 )) ); + printf("%f\n", getfloat(a_Transform3.getElem( 0, 2 )) ); + printf("%f\n", getfloat(a_Transform3.getElem( 1, 0 )) ); + printf("%f\n", getfloat(a_Transform3.getElem( 1, 1 )) ); + printf("%f\n", getfloat(a_Transform3.getElem( 1, 2 )) ); + printf("%f\n", getfloat(a_Transform3.getElem( 2, 0 )) ); + printf("%f\n", getfloat(a_Transform3.getElem( 2, 1 )) ); + printf("%f\n", getfloat(a_Transform3.getElem( 2, 2 )) ); + printf("%f\n", getfloat(a_Transform3.getElem( 3, 0 )) ); + printf("%f\n", getfloat(a_Transform3.getElem( 3, 1 )) ); + printf("%f\n", getfloat(a_Transform3.getElem( 3, 2 )) ); +} + +int main() +{ + int i; + printf("\n __begin__ \n"); + for ( i = 0; i < 2; i++ ) { + Matrix3_methods_test(); + Matrix4_methods_test(); + Transform3_methods_test(); + } + printf("\n __end__ \n"); + return 0; +} diff --git a/vectormathlibrary/tests/test2_soa_c.c b/vectormathlibrary/tests/test2_soa_c.c new file mode 100644 index 000000000..c012f990f --- /dev/null +++ b/vectormathlibrary/tests/test2_soa_c.c @@ -0,0 +1,760 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _VECTORMATH_SOA_TEST + +#include "vectormath_soa.h" +#include "test.h" + +int iteration = 0; + +void +Matrix3_methods_test() +{ + VmathSoaMatrix3 a_Matrix3, b_Matrix3; + VmathSoaMatrix4 a_Matrix4, b_Matrix4; + VmathSoaTransform3 a_Transform3, b_Transform3; + VmathSoaVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; + VmathSoaVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; + VmathSoaPoint3 a_Point3, b_Point3, c_Point3, d_Point3; + VmathSoaQuat a_Quat, b_Quat, c_Quat, d_Quat, tmpQ_0; + VmathSoaVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7, tmpV3_8, tmpV3_9, tmpV3_10, tmpV3_11, tmpV3_12, tmpV3_13; + vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); + vmathSoaV3Prints( &a_Vector3, "set Vector3 with floats" ); + vmathSoaV3Prints( &b_Vector3, "set Vector3 with floats" ); + vmathSoaV3Prints( &c_Vector3, "set Vector3 with floats" ); + vmathSoaV3Prints( &d_Vector3, "set Vector3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathSoaV4Prints( &a_Vector4, "set Vector4 with floats" ); + vmathSoaV4Prints( &b_Vector4, "set Vector4 with floats" ); + vmathSoaV4Prints( &c_Vector4, "set Vector4 with floats" ); + vmathSoaV4Prints( &d_Vector4, "set Vector4 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); + vmathSoaP3Prints( &a_Point3, "set Point3 with floats" ); + vmathSoaP3Prints( &b_Point3, "set Point3 with floats" ); + vmathSoaP3Prints( &c_Point3, "set Point3 with floats" ); + vmathSoaP3Prints( &d_Point3, "set Point3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathSoaQPrints( &a_Quat, "set Quat with floats" ); + vmathSoaQPrints( &b_Quat, "set Quat with floats" ); + vmathSoaQPrints( &c_Quat, "set Quat with floats" ); + vmathSoaQPrints( &d_Quat, "set Quat with floats" ); + vmathSoaM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 ); + vmathSoaM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 ); + vmathSoaM3Prints( &a_Matrix3, "set Matrix3 columns" ); + vmathSoaM3Prints( &b_Matrix3, "set Matrix3 columns" ); + vmathSoaM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 ); + vmathSoaM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 ); + vmathSoaM4Prints( &a_Matrix4, "set Matrix4 columns" ); + vmathSoaM4Prints( &b_Matrix4, "set Matrix4 columns" ); + vmathSoaT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 ); + vmathSoaT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 ); + vmathSoaT3Prints( &a_Transform3, "set Transform3 columns" ); + vmathSoaT3Prints( &b_Transform3, "set Transform3 columns" ); + vmathSoaQNormalize( &tmpQ_0, &a_Quat ); + vmathSoaM3MakeFromQ( &a_Matrix3, &tmpQ_0 ); + vmathSoaM3Prints( &a_Matrix3, "construct Matrix3 with Quat" ); + vmathSoaQMakeFromM3( &a_Quat, &a_Matrix3 ); + vmathSoaQPrints( &a_Quat, "construct Quat with Matrix3" ); + vmathSoaM3Copy( &a_Matrix3, &b_Matrix3 ); + vmathSoaM3Prints( &a_Matrix3, "assign to Matrix3 from Matrix3" ); + vmathSoaM3MakeFromScalar( &a_Matrix3, randfloat() ); + vmathSoaM3Prints( &a_Matrix3, "set Matrix3 with float" ); + vmathSoaM3MakeFromScalar( &a_Matrix3, randfloat() ); + vmathSoaM3Prints( &a_Matrix3, "set Matrix3 with float" ); + vmathSoaM3MakeFromScalar( &a_Matrix3, (vec_float4){0.0f} ); + vmathSoaM3Prints( &a_Matrix3, "set elements to zero" ); + vmathSoaM3MakeIdentity( &a_Matrix3 ); + vmathSoaM3Prints( &a_Matrix3, "set to identity" ); + vmathSoaM3MakeRotationX( &a_Matrix3, randfloat() ); + vmathSoaM3Prints( &a_Matrix3, "set to rotationX" ); + vmathSoaM3MakeRotationY( &a_Matrix3, randfloat() ); + vmathSoaM3Prints( &a_Matrix3, "set to rotationY" ); + vmathSoaM3MakeRotationZ( &a_Matrix3, randfloat() ); + vmathSoaM3Prints( &a_Matrix3, "set to rotationZ" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &tmpV3_0, rndflt3, rndflt2, rndflt1 ); + vmathSoaM3MakeRotationZYX( &a_Matrix3, &tmpV3_0 ); + vmathSoaM3Prints( &a_Matrix3, "set to rotation from Z,Y,X angles" ); + vmathSoaV3Normalize( &tmpV3_1, &a_Vector3 ); + vmathSoaM3MakeRotationAxis( &a_Matrix3, randfloat(), &tmpV3_1 ); + vmathSoaM3Prints( &a_Matrix3, "set to rotation from axis angle" ); + vmathSoaM3SetCol0( &a_Matrix3, &a_Vector3 ); + vmathSoaM3Prints( &a_Matrix3, "Matrix3 set col 0" ); + vmathSoaM3SetCol1( &a_Matrix3, &a_Vector3 ); + vmathSoaM3Prints( &a_Matrix3, "Matrix3 set col 1" ); + vmathSoaM3SetCol2( &a_Matrix3, &a_Vector3 ); + vmathSoaM3Prints( &a_Matrix3, "Matrix3 set col 2" ); + vmathSoaM3GetCol0( &tmpV3_2, &a_Matrix3 ); + vmathSoaV3Prints( &tmpV3_2, "Matrix3 get col 0" ); + vmathSoaM3GetCol1( &tmpV3_3, &a_Matrix3 ); + vmathSoaV3Prints( &tmpV3_3, "Matrix3 get col 1" ); + vmathSoaM3GetCol2( &tmpV3_4, &a_Matrix3 ); + vmathSoaV3Prints( &tmpV3_4, "Matrix3 get col 2" ); + vmathSoaM3SetCol( &a_Matrix3, 0, &b_Vector3 ); + vmathSoaM3Prints( &a_Matrix3, "Matrix3 set col 0" ); + vmathSoaM3SetCol( &a_Matrix3, 1, &b_Vector3 ); + vmathSoaM3Prints( &a_Matrix3, "Matrix3 set col 1" ); + vmathSoaM3SetCol( &a_Matrix3, 2, &b_Vector3 ); + vmathSoaM3Prints( &a_Matrix3, "Matrix3 set col 2" ); + vmathSoaM3GetCol( &tmpV3_5, &a_Matrix3, 0 ); + vmathSoaV3Prints( &tmpV3_5, "Matrix3 get col 0" ); + vmathSoaM3GetCol( &tmpV3_6, &a_Matrix3, 1 ); + vmathSoaV3Prints( &tmpV3_6, "Matrix3 get col 1" ); + vmathSoaM3GetCol( &tmpV3_7, &a_Matrix3, 2 ); + vmathSoaV3Prints( &tmpV3_7, "Matrix3 get col 2" ); + vmathSoaM3SetRow( &a_Matrix3, 0, &a_Vector3 ); + vmathSoaM3Prints( &a_Matrix3, "Matrix3 set row 0" ); + vmathSoaM3SetRow( &a_Matrix3, 1, &a_Vector3 ); + vmathSoaM3Prints( &a_Matrix3, "Matrix3 set row 1" ); + vmathSoaM3SetRow( &a_Matrix3, 2, &a_Vector3 ); + vmathSoaM3Prints( &a_Matrix3, "Matrix3 set row 2" ); + vmathSoaM3GetRow( &tmpV3_8, &a_Matrix3, 0 ); + vmathSoaV3Prints( &tmpV3_8, "Matrix3 get row 0" ); + vmathSoaM3GetRow( &tmpV3_9, &a_Matrix3, 1 ); + vmathSoaV3Prints( &tmpV3_9, "Matrix3 get row 1" ); + vmathSoaM3GetRow( &tmpV3_10, &a_Matrix3, 2 ); + vmathSoaV3Prints( &tmpV3_10, "Matrix3 get row 2" ); + vmathSoaM3SetCol( &a_Matrix3, 0, &a_Vector3 ); + vmathSoaM3Prints( &a_Matrix3, "set " ); + vmathSoaM3SetCol( &a_Matrix3, 1, &a_Vector3 ); + vmathSoaM3Prints( &a_Matrix3, "set " ); + vmathSoaM3SetCol( &a_Matrix3, 2, &a_Vector3 ); + vmathSoaM3Prints( &a_Matrix3, "set " ); + vmathSoaM3GetCol( &tmpV3_11, &a_Matrix3, 0 ); + vmathSoaV3Prints( &tmpV3_11, "get " ); + vmathSoaM3GetCol( &tmpV3_12, &a_Matrix3, 1 ); + vmathSoaV3Prints( &tmpV3_12, "get " ); + vmathSoaM3GetCol( &tmpV3_13, &a_Matrix3, 2 ); + vmathSoaV3Prints( &tmpV3_13, "get " ); + vmathSoaM3SetElem( &a_Matrix3, 0, 0, randfloat() ); + vmathSoaM3SetElem( &a_Matrix3, 0, 1, randfloat() ); + vmathSoaM3SetElem( &a_Matrix3, 0, 2, randfloat() ); + vmathSoaM3SetElem( &a_Matrix3, 1, 0, randfloat() ); + vmathSoaM3SetElem( &a_Matrix3, 1, 1, randfloat() ); + vmathSoaM3SetElem( &a_Matrix3, 1, 2, randfloat() ); + vmathSoaM3SetElem( &a_Matrix3, 2, 0, randfloat() ); + vmathSoaM3SetElem( &a_Matrix3, 2, 1, randfloat() ); + vmathSoaM3SetElem( &a_Matrix3, 2, 2, randfloat() ); + vmathSoaM3Prints( &a_Matrix3, "Matrix3 set elements" ); + printf("%f\n", getfloat(vmathSoaM3GetElem( &a_Matrix3, 0, 0 )) ); + printf("%f\n", getfloat(vmathSoaM3GetElem( &a_Matrix3, 0, 1 )) ); + printf("%f\n", getfloat(vmathSoaM3GetElem( &a_Matrix3, 0, 2 )) ); + printf("%f\n", getfloat(vmathSoaM3GetElem( &a_Matrix3, 1, 0 )) ); + printf("%f\n", getfloat(vmathSoaM3GetElem( &a_Matrix3, 1, 1 )) ); + printf("%f\n", getfloat(vmathSoaM3GetElem( &a_Matrix3, 1, 2 )) ); + printf("%f\n", getfloat(vmathSoaM3GetElem( &a_Matrix3, 2, 0 )) ); + printf("%f\n", getfloat(vmathSoaM3GetElem( &a_Matrix3, 2, 1 )) ); + printf("%f\n", getfloat(vmathSoaM3GetElem( &a_Matrix3, 2, 2 )) ); +} + +void +Matrix4_methods_test() +{ + VmathSoaMatrix3 a_Matrix3, b_Matrix3; + VmathSoaMatrix4 a_Matrix4, b_Matrix4; + VmathSoaTransform3 a_Transform3, b_Transform3; + VmathSoaVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; + VmathSoaVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; + VmathSoaPoint3 a_Point3, b_Point3, c_Point3, d_Point3; + VmathSoaQuat a_Quat, b_Quat, c_Quat, d_Quat; + VmathSoaVector3 tmpV3_0, tmpV3_1; + VmathSoaVector4 tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3, tmpV4_4, tmpV4_5, tmpV4_6, tmpV4_7, tmpV4_8, tmpV4_9, tmpV4_10, tmpV4_11, tmpV4_12, tmpV4_13, tmpV4_14, tmpV4_15; + vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); + vmathSoaV3Prints( &a_Vector3, "set Vector3 with floats" ); + vmathSoaV3Prints( &b_Vector3, "set Vector3 with floats" ); + vmathSoaV3Prints( &c_Vector3, "set Vector3 with floats" ); + vmathSoaV3Prints( &d_Vector3, "set Vector3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathSoaV4Prints( &a_Vector4, "set Vector4 with floats" ); + vmathSoaV4Prints( &b_Vector4, "set Vector4 with floats" ); + vmathSoaV4Prints( &c_Vector4, "set Vector4 with floats" ); + vmathSoaV4Prints( &d_Vector4, "set Vector4 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); + vmathSoaP3Prints( &a_Point3, "set Point3 with floats" ); + vmathSoaP3Prints( &b_Point3, "set Point3 with floats" ); + vmathSoaP3Prints( &c_Point3, "set Point3 with floats" ); + vmathSoaP3Prints( &d_Point3, "set Point3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathSoaQPrints( &a_Quat, "set Quat with floats" ); + vmathSoaQPrints( &b_Quat, "set Quat with floats" ); + vmathSoaQPrints( &c_Quat, "set Quat with floats" ); + vmathSoaQPrints( &d_Quat, "set Quat with floats" ); + vmathSoaM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 ); + vmathSoaM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 ); + vmathSoaM3Prints( &a_Matrix3, "set Matrix3 columns" ); + vmathSoaM3Prints( &b_Matrix3, "set Matrix3 columns" ); + vmathSoaM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 ); + vmathSoaM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 ); + vmathSoaM4Prints( &a_Matrix4, "set Matrix4 columns" ); + vmathSoaM4Prints( &b_Matrix4, "set Matrix4 columns" ); + vmathSoaT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 ); + vmathSoaT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 ); + vmathSoaT3Prints( &a_Transform3, "set Transform3 columns" ); + vmathSoaT3Prints( &b_Transform3, "set Transform3 columns" ); + vmathSoaM4MakeFromT3( &a_Matrix4, &a_Transform3 ); + vmathSoaM4Prints( &a_Matrix4, "construct Matrix4 with Transform3" ); + vmathSoaM4MakeFromM3V3( &a_Matrix4, &a_Matrix3, &a_Vector3 ); + vmathSoaM4Prints( &a_Matrix4, "construct Matrix4 with Matrix3 and Vector3" ); + vmathSoaM4MakeFromQV3( &a_Matrix4, &a_Quat, &a_Vector3 ); + vmathSoaM4Prints( &a_Matrix4, "construct Matrix4 with Quat and Vector3" ); + vmathSoaM4Copy( &a_Matrix4, &b_Matrix4 ); + vmathSoaM4Prints( &a_Matrix4, "assign to Matrix4 from Matrix4" ); + vmathSoaM4MakeFromScalar( &a_Matrix4, randfloat() ); + vmathSoaM4Prints( &a_Matrix4, "set Matrix4 with float" ); + vmathSoaM4MakeFromScalar( &a_Matrix4, randfloat() ); + vmathSoaM4Prints( &a_Matrix4, "set Matrix4 with float" ); + vmathSoaM4MakeFromScalar( &a_Matrix4, (vec_float4){0.0f} ); + vmathSoaM4Prints( &a_Matrix4, "set elements to zero" ); + vmathSoaM4MakeIdentity( &a_Matrix4 ); + vmathSoaM4Prints( &a_Matrix4, "set to identity" ); + vmathSoaM4MakeRotationX( &a_Matrix4, randfloat() ); + vmathSoaM4Prints( &a_Matrix4, "set to rotationX" ); + vmathSoaM4MakeRotationY( &a_Matrix4, randfloat() ); + vmathSoaM4Prints( &a_Matrix4, "set to rotationY" ); + vmathSoaM4MakeRotationZ( &a_Matrix4, randfloat() ); + vmathSoaM4Prints( &a_Matrix4, "set to rotationZ" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &tmpV3_0, rndflt3, rndflt2, rndflt1 ); + vmathSoaM4MakeRotationZYX( &a_Matrix4, &tmpV3_0 ); + vmathSoaM4Prints( &a_Matrix4, "set to rotation from Z,Y,X angles" ); + vmathSoaV3Normalize( &tmpV3_1, &a_Vector3 ); + vmathSoaM4MakeRotationAxis( &a_Matrix4, randfloat(), &tmpV3_1 ); + vmathSoaM4Prints( &a_Matrix4, "set to rotation from axis angle" ); + vmathSoaM4MakeTranslation( &a_Matrix4, &a_Vector3 ); + vmathSoaM4Prints( &a_Matrix4, "set to translation" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaM4MakePerspective( &a_Matrix4, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathSoaM4Prints( &a_Matrix4, "set to perspective matrix" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaM4MakeFrustum( &a_Matrix4, rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6 ); + vmathSoaM4Prints( &a_Matrix4, "set to frustum matrix" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaM4MakeOrthographic( &a_Matrix4, rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6 ); + vmathSoaM4Prints( &a_Matrix4, "set to orthographic matrix" ); + vmathSoaM4MakeLookAt( &a_Matrix4, &a_Point3, &b_Point3, &a_Vector3 ); + vmathSoaM4Prints( &a_Matrix4, "set to look-at matrix" ); + vmathSoaM4SetCol0( &a_Matrix4, &a_Vector4 ); + vmathSoaM4Prints( &a_Matrix4, "Matrix4 set col 0" ); + vmathSoaM4SetCol1( &a_Matrix4, &a_Vector4 ); + vmathSoaM4Prints( &a_Matrix4, "Matrix4 set col 1" ); + vmathSoaM4SetCol2( &a_Matrix4, &a_Vector4 ); + vmathSoaM4Prints( &a_Matrix4, "Matrix4 set col 2" ); + vmathSoaM4SetCol3( &a_Matrix4, &a_Vector4 ); + vmathSoaM4Prints( &a_Matrix4, "Matrix4 set col 3" ); + vmathSoaM4GetCol0( &tmpV4_0, &a_Matrix4 ); + vmathSoaV4Prints( &tmpV4_0, "Matrix4 get col 0" ); + vmathSoaM4GetCol1( &tmpV4_1, &a_Matrix4 ); + vmathSoaV4Prints( &tmpV4_1, "Matrix4 get col 1" ); + vmathSoaM4GetCol2( &tmpV4_2, &a_Matrix4 ); + vmathSoaV4Prints( &tmpV4_2, "Matrix4 get col 2" ); + vmathSoaM4GetCol3( &tmpV4_3, &a_Matrix4 ); + vmathSoaV4Prints( &tmpV4_3, "Matrix4 get col 3" ); + vmathSoaM4SetCol( &a_Matrix4, 0, &b_Vector4 ); + vmathSoaM4Prints( &a_Matrix4, "Matrix4 set col 0" ); + vmathSoaM4SetCol( &a_Matrix4, 1, &b_Vector4 ); + vmathSoaM4Prints( &a_Matrix4, "Matrix4 set col 1" ); + vmathSoaM4SetCol( &a_Matrix4, 2, &b_Vector4 ); + vmathSoaM4Prints( &a_Matrix4, "Matrix4 set col 2" ); + vmathSoaM4SetCol( &a_Matrix4, 3, &b_Vector4 ); + vmathSoaM4Prints( &a_Matrix4, "Matrix4 set col 3" ); + vmathSoaM4GetCol( &tmpV4_4, &a_Matrix4, 0 ); + vmathSoaV4Prints( &tmpV4_4, "Matrix4 get col 0" ); + vmathSoaM4GetCol( &tmpV4_5, &a_Matrix4, 1 ); + vmathSoaV4Prints( &tmpV4_5, "Matrix4 get col 1" ); + vmathSoaM4GetCol( &tmpV4_6, &a_Matrix4, 2 ); + vmathSoaV4Prints( &tmpV4_6, "Matrix4 get col 2" ); + vmathSoaM4GetCol( &tmpV4_7, &a_Matrix4, 3 ); + vmathSoaV4Prints( &tmpV4_7, "Matrix4 get col 3" ); + vmathSoaM4SetRow( &a_Matrix4, 0, &a_Vector4 ); + vmathSoaM4Prints( &a_Matrix4, "Matrix4 set row 0" ); + vmathSoaM4SetRow( &a_Matrix4, 1, &a_Vector4 ); + vmathSoaM4Prints( &a_Matrix4, "Matrix4 set row 1" ); + vmathSoaM4SetRow( &a_Matrix4, 2, &a_Vector4 ); + vmathSoaM4Prints( &a_Matrix4, "Matrix4 set row 2" ); + vmathSoaM4SetRow( &a_Matrix4, 3, &a_Vector4 ); + vmathSoaM4Prints( &a_Matrix4, "Matrix4 set row 3" ); + vmathSoaM4GetRow( &tmpV4_8, &a_Matrix4, 0 ); + vmathSoaV4Prints( &tmpV4_8, "Matrix4 get row 0" ); + vmathSoaM4GetRow( &tmpV4_9, &a_Matrix4, 1 ); + vmathSoaV4Prints( &tmpV4_9, "Matrix4 get row 1" ); + vmathSoaM4GetRow( &tmpV4_10, &a_Matrix4, 2 ); + vmathSoaV4Prints( &tmpV4_10, "Matrix4 get row 2" ); + vmathSoaM4GetRow( &tmpV4_11, &a_Matrix4, 3 ); + vmathSoaV4Prints( &tmpV4_11, "Matrix4 get row 3" ); + vmathSoaM4SetCol( &a_Matrix4, 0, &a_Vector4 ); + vmathSoaM4Prints( &a_Matrix4, "set " ); + vmathSoaM4SetCol( &a_Matrix4, 1, &a_Vector4 ); + vmathSoaM4Prints( &a_Matrix4, "set " ); + vmathSoaM4SetCol( &a_Matrix4, 2, &a_Vector4 ); + vmathSoaM4Prints( &a_Matrix4, "set " ); + vmathSoaM4SetCol( &a_Matrix4, 3, &a_Vector4 ); + vmathSoaM4Prints( &a_Matrix4, "set " ); + vmathSoaM4GetCol( &tmpV4_12, &a_Matrix4, 0 ); + vmathSoaV4Prints( &tmpV4_12, "get " ); + vmathSoaM4GetCol( &tmpV4_13, &a_Matrix4, 1 ); + vmathSoaV4Prints( &tmpV4_13, "get " ); + vmathSoaM4GetCol( &tmpV4_14, &a_Matrix4, 2 ); + vmathSoaV4Prints( &tmpV4_14, "get " ); + vmathSoaM4GetCol( &tmpV4_15, &a_Matrix4, 3 ); + vmathSoaV4Prints( &tmpV4_15, "get " ); + vmathSoaM4SetElem( &a_Matrix4, 0, 0, randfloat() ); + vmathSoaM4SetElem( &a_Matrix4, 0, 1, randfloat() ); + vmathSoaM4SetElem( &a_Matrix4, 0, 2, randfloat() ); + vmathSoaM4SetElem( &a_Matrix4, 0, 3, randfloat() ); + vmathSoaM4SetElem( &a_Matrix4, 1, 0, randfloat() ); + vmathSoaM4SetElem( &a_Matrix4, 1, 1, randfloat() ); + vmathSoaM4SetElem( &a_Matrix4, 1, 2, randfloat() ); + vmathSoaM4SetElem( &a_Matrix4, 1, 3, randfloat() ); + vmathSoaM4SetElem( &a_Matrix4, 2, 0, randfloat() ); + vmathSoaM4SetElem( &a_Matrix4, 2, 1, randfloat() ); + vmathSoaM4SetElem( &a_Matrix4, 2, 2, randfloat() ); + vmathSoaM4SetElem( &a_Matrix4, 2, 3, randfloat() ); + vmathSoaM4SetElem( &a_Matrix4, 3, 0, randfloat() ); + vmathSoaM4SetElem( &a_Matrix4, 3, 1, randfloat() ); + vmathSoaM4SetElem( &a_Matrix4, 3, 2, randfloat() ); + vmathSoaM4SetElem( &a_Matrix4, 3, 3, randfloat() ); + vmathSoaM4Prints( &a_Matrix4, "Matrix4 set elements" ); + printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 0, 0 )) ); + printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 0, 1 )) ); + printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 0, 2 )) ); + printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 0, 3 )) ); + printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 1, 0 )) ); + printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 1, 1 )) ); + printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 1, 2 )) ); + printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 1, 3 )) ); + printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 2, 0 )) ); + printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 2, 1 )) ); + printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 2, 2 )) ); + printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 2, 3 )) ); + printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 3, 0 )) ); + printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 3, 1 )) ); + printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 3, 2 )) ); + printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 3, 3 )) ); +} + +void +Transform3_methods_test() +{ + VmathSoaMatrix3 a_Matrix3, b_Matrix3; + VmathSoaMatrix4 a_Matrix4, b_Matrix4; + VmathSoaTransform3 a_Transform3, b_Transform3; + VmathSoaVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; + VmathSoaVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; + VmathSoaPoint3 a_Point3, b_Point3, c_Point3, d_Point3; + VmathSoaQuat a_Quat, b_Quat, c_Quat, d_Quat; + VmathSoaVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7, tmpV3_8, tmpV3_9; + VmathSoaVector4 tmpV4_0, tmpV4_1, tmpV4_2; + VmathSoaVector3 tmpV3_10, tmpV3_11, tmpV3_12, tmpV3_13; + vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); + vmathSoaV3Prints( &a_Vector3, "set Vector3 with floats" ); + vmathSoaV3Prints( &b_Vector3, "set Vector3 with floats" ); + vmathSoaV3Prints( &c_Vector3, "set Vector3 with floats" ); + vmathSoaV3Prints( &d_Vector3, "set Vector3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathSoaV4Prints( &a_Vector4, "set Vector4 with floats" ); + vmathSoaV4Prints( &b_Vector4, "set Vector4 with floats" ); + vmathSoaV4Prints( &c_Vector4, "set Vector4 with floats" ); + vmathSoaV4Prints( &d_Vector4, "set Vector4 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); + vmathSoaP3Prints( &a_Point3, "set Point3 with floats" ); + vmathSoaP3Prints( &b_Point3, "set Point3 with floats" ); + vmathSoaP3Prints( &c_Point3, "set Point3 with floats" ); + vmathSoaP3Prints( &d_Point3, "set Point3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathSoaQPrints( &a_Quat, "set Quat with floats" ); + vmathSoaQPrints( &b_Quat, "set Quat with floats" ); + vmathSoaQPrints( &c_Quat, "set Quat with floats" ); + vmathSoaQPrints( &d_Quat, "set Quat with floats" ); + vmathSoaM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 ); + vmathSoaM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 ); + vmathSoaM3Prints( &a_Matrix3, "set Matrix3 columns" ); + vmathSoaM3Prints( &b_Matrix3, "set Matrix3 columns" ); + vmathSoaM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 ); + vmathSoaM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 ); + vmathSoaM4Prints( &a_Matrix4, "set Matrix4 columns" ); + vmathSoaM4Prints( &b_Matrix4, "set Matrix4 columns" ); + vmathSoaT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 ); + vmathSoaT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 ); + vmathSoaT3Prints( &a_Transform3, "set Transform3 columns" ); + vmathSoaT3Prints( &b_Transform3, "set Transform3 columns" ); + vmathSoaT3MakeFromM3V3( &a_Transform3, &a_Matrix3, &a_Vector3 ); + vmathSoaT3Prints( &a_Transform3, "construct Transform3 with Matrix3 and Vector3" ); + vmathSoaT3MakeFromQV3( &a_Transform3, &a_Quat, &a_Vector3 ); + vmathSoaT3Prints( &a_Transform3, "construct Transform3 with Quat and Vector3" ); + vmathSoaT3Copy( &a_Transform3, &b_Transform3 ); + vmathSoaT3Prints( &a_Transform3, "assign to Transform3 from Transform3" ); + vmathSoaT3MakeFromScalar( &a_Transform3, randfloat() ); + vmathSoaT3Prints( &a_Transform3, "set Transform3 with float" ); + vmathSoaT3MakeFromScalar( &a_Transform3, randfloat() ); + vmathSoaT3Prints( &a_Transform3, "set Transform3 with float" ); + vmathSoaT3MakeFromScalar( &a_Transform3, (vec_float4){0.0f} ); + vmathSoaT3Prints( &a_Transform3, "set elements to zero" ); + vmathSoaT3MakeIdentity( &a_Transform3 ); + vmathSoaT3Prints( &a_Transform3, "set to identity" ); + vmathSoaT3MakeRotationX( &a_Transform3, randfloat() ); + vmathSoaT3Prints( &a_Transform3, "set to rotationX" ); + vmathSoaT3MakeRotationY( &a_Transform3, randfloat() ); + vmathSoaT3Prints( &a_Transform3, "set to rotationY" ); + vmathSoaT3MakeRotationZ( &a_Transform3, randfloat() ); + vmathSoaT3Prints( &a_Transform3, "set to rotationZ" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &tmpV3_0, rndflt3, rndflt2, rndflt1 ); + vmathSoaT3MakeRotationZYX( &a_Transform3, &tmpV3_0 ); + vmathSoaT3Prints( &a_Transform3, "set to rotation from Z,Y,X angles" ); + vmathSoaV3Normalize( &tmpV3_1, &a_Vector3 ); + vmathSoaT3MakeRotationAxis( &a_Transform3, randfloat(), &tmpV3_1 ); + vmathSoaT3Prints( &a_Transform3, "set to rotation from axis angle" ); + vmathSoaT3MakeTranslation( &a_Transform3, &a_Vector3 ); + vmathSoaT3Prints( &a_Transform3, "set to translation" ); + vmathSoaT3SetCol0( &a_Transform3, &a_Vector3 ); + vmathSoaT3Prints( &a_Transform3, "Transform3 set col 0" ); + vmathSoaT3SetCol1( &a_Transform3, &a_Vector3 ); + vmathSoaT3Prints( &a_Transform3, "Transform3 set col 1" ); + vmathSoaT3SetCol2( &a_Transform3, &a_Vector3 ); + vmathSoaT3Prints( &a_Transform3, "Transform3 set col 2" ); + vmathSoaT3SetCol3( &a_Transform3, &a_Vector3 ); + vmathSoaT3Prints( &a_Transform3, "Transform3 set col 3" ); + vmathSoaT3GetCol0( &tmpV3_2, &a_Transform3 ); + vmathSoaV3Prints( &tmpV3_2, "Transform3 get col 0" ); + vmathSoaT3GetCol1( &tmpV3_3, &a_Transform3 ); + vmathSoaV3Prints( &tmpV3_3, "Transform3 get col 1" ); + vmathSoaT3GetCol2( &tmpV3_4, &a_Transform3 ); + vmathSoaV3Prints( &tmpV3_4, "Transform3 get col 2" ); + vmathSoaT3GetCol3( &tmpV3_5, &a_Transform3 ); + vmathSoaV3Prints( &tmpV3_5, "Transform3 get col 3" ); + vmathSoaT3SetCol( &a_Transform3, 0, &b_Vector3 ); + vmathSoaT3Prints( &a_Transform3, "Transform3 set col 0" ); + vmathSoaT3SetCol( &a_Transform3, 1, &b_Vector3 ); + vmathSoaT3Prints( &a_Transform3, "Transform3 set col 1" ); + vmathSoaT3SetCol( &a_Transform3, 2, &b_Vector3 ); + vmathSoaT3Prints( &a_Transform3, "Transform3 set col 2" ); + vmathSoaT3SetCol( &a_Transform3, 3, &b_Vector3 ); + vmathSoaT3Prints( &a_Transform3, "Transform3 set col 3" ); + vmathSoaT3GetCol( &tmpV3_6, &a_Transform3, 0 ); + vmathSoaV3Prints( &tmpV3_6, "Transform3 get col 0" ); + vmathSoaT3GetCol( &tmpV3_7, &a_Transform3, 1 ); + vmathSoaV3Prints( &tmpV3_7, "Transform3 get col 1" ); + vmathSoaT3GetCol( &tmpV3_8, &a_Transform3, 2 ); + vmathSoaV3Prints( &tmpV3_8, "Transform3 get col 2" ); + vmathSoaT3GetCol( &tmpV3_9, &a_Transform3, 3 ); + vmathSoaV3Prints( &tmpV3_9, "Transform3 get col 3" ); + vmathSoaT3SetRow( &a_Transform3, 0, &a_Vector4 ); + vmathSoaT3Prints( &a_Transform3, "Transform3 set row 0" ); + vmathSoaT3SetRow( &a_Transform3, 1, &a_Vector4 ); + vmathSoaT3Prints( &a_Transform3, "Transform3 set row 1" ); + vmathSoaT3SetRow( &a_Transform3, 2, &a_Vector4 ); + vmathSoaT3Prints( &a_Transform3, "Transform3 set row 2" ); + vmathSoaT3GetRow( &tmpV4_0, &a_Transform3, 0 ); + vmathSoaV4Prints( &tmpV4_0, "Transform3 get row 0" ); + vmathSoaT3GetRow( &tmpV4_1, &a_Transform3, 1 ); + vmathSoaV4Prints( &tmpV4_1, "Transform3 get row 1" ); + vmathSoaT3GetRow( &tmpV4_2, &a_Transform3, 2 ); + vmathSoaV4Prints( &tmpV4_2, "Transform3 get row 2" ); + vmathSoaT3SetCol( &a_Transform3, 0, &a_Vector3 ); + vmathSoaT3Prints( &a_Transform3, "set " ); + vmathSoaT3SetCol( &a_Transform3, 1, &a_Vector3 ); + vmathSoaT3Prints( &a_Transform3, "set " ); + vmathSoaT3SetCol( &a_Transform3, 2, &a_Vector3 ); + vmathSoaT3Prints( &a_Transform3, "set " ); + vmathSoaT3SetCol( &a_Transform3, 3, &a_Vector3 ); + vmathSoaT3Prints( &a_Transform3, "set " ); + vmathSoaT3GetCol( &tmpV3_10, &a_Transform3, 0 ); + vmathSoaV3Prints( &tmpV3_10, "get " ); + vmathSoaT3GetCol( &tmpV3_11, &a_Transform3, 1 ); + vmathSoaV3Prints( &tmpV3_11, "get " ); + vmathSoaT3GetCol( &tmpV3_12, &a_Transform3, 2 ); + vmathSoaV3Prints( &tmpV3_12, "get " ); + vmathSoaT3GetCol( &tmpV3_13, &a_Transform3, 3 ); + vmathSoaV3Prints( &tmpV3_13, "get " ); + vmathSoaT3SetElem( &a_Transform3, 0, 0, randfloat() ); + vmathSoaT3SetElem( &a_Transform3, 0, 1, randfloat() ); + vmathSoaT3SetElem( &a_Transform3, 0, 2, randfloat() ); + vmathSoaT3SetElem( &a_Transform3, 1, 0, randfloat() ); + vmathSoaT3SetElem( &a_Transform3, 1, 1, randfloat() ); + vmathSoaT3SetElem( &a_Transform3, 1, 2, randfloat() ); + vmathSoaT3SetElem( &a_Transform3, 2, 0, randfloat() ); + vmathSoaT3SetElem( &a_Transform3, 2, 1, randfloat() ); + vmathSoaT3SetElem( &a_Transform3, 2, 2, randfloat() ); + vmathSoaT3SetElem( &a_Transform3, 3, 0, randfloat() ); + vmathSoaT3SetElem( &a_Transform3, 3, 1, randfloat() ); + vmathSoaT3SetElem( &a_Transform3, 3, 2, randfloat() ); + vmathSoaT3Prints( &a_Transform3, "Transform3 set elements" ); + printf("%f\n", getfloat(vmathSoaT3GetElem( &a_Transform3, 0, 0 )) ); + printf("%f\n", getfloat(vmathSoaT3GetElem( &a_Transform3, 0, 1 )) ); + printf("%f\n", getfloat(vmathSoaT3GetElem( &a_Transform3, 0, 2 )) ); + printf("%f\n", getfloat(vmathSoaT3GetElem( &a_Transform3, 1, 0 )) ); + printf("%f\n", getfloat(vmathSoaT3GetElem( &a_Transform3, 1, 1 )) ); + printf("%f\n", getfloat(vmathSoaT3GetElem( &a_Transform3, 1, 2 )) ); + printf("%f\n", getfloat(vmathSoaT3GetElem( &a_Transform3, 2, 0 )) ); + printf("%f\n", getfloat(vmathSoaT3GetElem( &a_Transform3, 2, 1 )) ); + printf("%f\n", getfloat(vmathSoaT3GetElem( &a_Transform3, 2, 2 )) ); + printf("%f\n", getfloat(vmathSoaT3GetElem( &a_Transform3, 3, 0 )) ); + printf("%f\n", getfloat(vmathSoaT3GetElem( &a_Transform3, 3, 1 )) ); + printf("%f\n", getfloat(vmathSoaT3GetElem( &a_Transform3, 3, 2 )) ); +} + +int main() +{ + int i; + printf("\n __begin__ \n"); + for ( i = 0; i < 2; i++ ) { + Matrix3_methods_test(); + Matrix4_methods_test(); + Transform3_methods_test(); + } + printf("\n __end__ \n"); + return 0; +} diff --git a/vectormathlibrary/tests/test2_soa_cpp.cpp b/vectormathlibrary/tests/test2_soa_cpp.cpp new file mode 100644 index 000000000..c0f08a907 --- /dev/null +++ b/vectormathlibrary/tests/test2_soa_cpp.cpp @@ -0,0 +1,718 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _VECTORMATH_SOA_TEST + +#include "vectormath_soa.h" +#include "test.h" + +int iteration = 0; + +using namespace Vectormath; +using namespace Vectormath::Soa; + +void +Matrix3_methods_test() +{ + Matrix3 a_Matrix3, b_Matrix3; + Matrix4 a_Matrix4, b_Matrix4; + Transform3 a_Transform3, b_Transform3; + Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; + Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; + Point3 a_Point3, b_Point3, c_Point3, d_Point3; + Quat a_Quat, b_Quat, c_Quat, d_Quat; + vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + print( a_Vector3, "set Vector3 with floats" ); + print( b_Vector3, "set Vector3 with floats" ); + print( c_Vector3, "set Vector3 with floats" ); + print( d_Vector3, "set Vector3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Vector4, "set Vector4 with floats" ); + print( b_Vector4, "set Vector4 with floats" ); + print( c_Vector4, "set Vector4 with floats" ); + print( d_Vector4, "set Vector4 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Point3 = Point3( rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + print( a_Point3, "set Point3 with floats" ); + print( b_Point3, "set Point3 with floats" ); + print( c_Point3, "set Point3 with floats" ); + print( d_Point3, "set Point3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Quat, "set Quat with floats" ); + print( b_Quat, "set Quat with floats" ); + print( c_Quat, "set Quat with floats" ); + print( d_Quat, "set Quat with floats" ); + a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 ); + b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 ); + print( a_Matrix3, "set Matrix3 columns" ); + print( b_Matrix3, "set Matrix3 columns" ); + a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 ); + b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 ); + print( a_Matrix4, "set Matrix4 columns" ); + print( b_Matrix4, "set Matrix4 columns" ); + a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 ); + b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 ); + print( a_Transform3, "set Transform3 columns" ); + print( b_Transform3, "set Transform3 columns" ); + a_Matrix3 = Matrix3( normalize( a_Quat ) ); + print( a_Matrix3, "construct Matrix3 with Quat" ); + a_Quat = Quat( a_Matrix3 ); + print( a_Quat, "construct Quat with Matrix3" ); + a_Matrix3 = b_Matrix3; + print( a_Matrix3, "assign to Matrix3 from Matrix3" ); + a_Matrix3 = Matrix3( randfloat() ); + print( a_Matrix3, "set Matrix3 with float" ); + a_Matrix3 = Matrix3( randfloat() ); + print( a_Matrix3, "set Matrix3 with float" ); + a_Matrix3 = Matrix3( (vec_float4){0.0f} ); + print( a_Matrix3, "set elements to zero" ); + a_Matrix3 = Matrix3::identity( ); + print( a_Matrix3, "set to identity" ); + a_Matrix3 = Matrix3::rotationX( randfloat() ); + print( a_Matrix3, "set to rotationX" ); + a_Matrix3 = Matrix3::rotationY( randfloat() ); + print( a_Matrix3, "set to rotationY" ); + a_Matrix3 = Matrix3::rotationZ( randfloat() ); + print( a_Matrix3, "set to rotationZ" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Matrix3 = Matrix3::rotationZYX( Vector3( rndflt3, rndflt2, rndflt1 ) ); + print( a_Matrix3, "set to rotation from Z,Y,X angles" ); + a_Matrix3 = Matrix3::rotation( randfloat(), normalize( a_Vector3 ) ); + print( a_Matrix3, "set to rotation from axis angle" ); + a_Matrix3.setCol0( a_Vector3 ); + print( a_Matrix3, "Matrix3 set col 0" ); + a_Matrix3.setCol1( a_Vector3 ); + print( a_Matrix3, "Matrix3 set col 1" ); + a_Matrix3.setCol2( a_Vector3 ); + print( a_Matrix3, "Matrix3 set col 2" ); + print( a_Matrix3.getCol0( ), "Matrix3 get col 0" ); + print( a_Matrix3.getCol1( ), "Matrix3 get col 1" ); + print( a_Matrix3.getCol2( ), "Matrix3 get col 2" ); + a_Matrix3.setCol( 0, b_Vector3 ); + print( a_Matrix3, "Matrix3 set col 0" ); + a_Matrix3.setCol( 1, b_Vector3 ); + print( a_Matrix3, "Matrix3 set col 1" ); + a_Matrix3.setCol( 2, b_Vector3 ); + print( a_Matrix3, "Matrix3 set col 2" ); + print( a_Matrix3.getCol( 0 ), "Matrix3 get col 0" ); + print( a_Matrix3.getCol( 1 ), "Matrix3 get col 1" ); + print( a_Matrix3.getCol( 2 ), "Matrix3 get col 2" ); + a_Matrix3.setRow( 0, a_Vector3 ); + print( a_Matrix3, "Matrix3 set row 0" ); + a_Matrix3.setRow( 1, a_Vector3 ); + print( a_Matrix3, "Matrix3 set row 1" ); + a_Matrix3.setRow( 2, a_Vector3 ); + print( a_Matrix3, "Matrix3 set row 2" ); + print( a_Matrix3.getRow( 0 ), "Matrix3 get row 0" ); + print( a_Matrix3.getRow( 1 ), "Matrix3 get row 1" ); + print( a_Matrix3.getRow( 2 ), "Matrix3 get row 2" ); + a_Matrix3[0] = a_Vector3; + print( a_Matrix3, "set Matrix3[0]" ); + a_Matrix3[1] = a_Vector3; + print( a_Matrix3, "set Matrix3[1]" ); + a_Matrix3[2] = a_Vector3; + print( a_Matrix3, "set Matrix3[2]" ); + a_Matrix3[0] = a_Vector3; + print( a_Matrix3[0], "get Matrix3[0]" ); + a_Matrix3[1] = a_Vector3; + print( a_Matrix3[1], "get Matrix3[1]" ); + a_Matrix3[2] = a_Vector3; + print( a_Matrix3[2], "get Matrix3[2]" ); + a_Matrix3.setElem( 0, 0, randfloat() ); + a_Matrix3.setElem( 0, 1, randfloat() ); + a_Matrix3.setElem( 0, 2, randfloat() ); + a_Matrix3.setElem( 1, 0, randfloat() ); + a_Matrix3.setElem( 1, 1, randfloat() ); + a_Matrix3.setElem( 1, 2, randfloat() ); + a_Matrix3.setElem( 2, 0, randfloat() ); + a_Matrix3.setElem( 2, 1, randfloat() ); + a_Matrix3.setElem( 2, 2, randfloat() ); + print( a_Matrix3, "Matrix3 set elements" ); + printf("%f\n", getfloat(a_Matrix3.getElem( 0, 0 )) ); + printf("%f\n", getfloat(a_Matrix3.getElem( 0, 1 )) ); + printf("%f\n", getfloat(a_Matrix3.getElem( 0, 2 )) ); + printf("%f\n", getfloat(a_Matrix3.getElem( 1, 0 )) ); + printf("%f\n", getfloat(a_Matrix3.getElem( 1, 1 )) ); + printf("%f\n", getfloat(a_Matrix3.getElem( 1, 2 )) ); + printf("%f\n", getfloat(a_Matrix3.getElem( 2, 0 )) ); + printf("%f\n", getfloat(a_Matrix3.getElem( 2, 1 )) ); + printf("%f\n", getfloat(a_Matrix3.getElem( 2, 2 )) ); +} + +void +Matrix4_methods_test() +{ + Matrix3 a_Matrix3, b_Matrix3; + Matrix4 a_Matrix4, b_Matrix4; + Transform3 a_Transform3, b_Transform3; + Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; + Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; + Point3 a_Point3, b_Point3, c_Point3, d_Point3; + Quat a_Quat, b_Quat, c_Quat, d_Quat; + vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + print( a_Vector3, "set Vector3 with floats" ); + print( b_Vector3, "set Vector3 with floats" ); + print( c_Vector3, "set Vector3 with floats" ); + print( d_Vector3, "set Vector3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Vector4, "set Vector4 with floats" ); + print( b_Vector4, "set Vector4 with floats" ); + print( c_Vector4, "set Vector4 with floats" ); + print( d_Vector4, "set Vector4 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Point3 = Point3( rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + print( a_Point3, "set Point3 with floats" ); + print( b_Point3, "set Point3 with floats" ); + print( c_Point3, "set Point3 with floats" ); + print( d_Point3, "set Point3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Quat, "set Quat with floats" ); + print( b_Quat, "set Quat with floats" ); + print( c_Quat, "set Quat with floats" ); + print( d_Quat, "set Quat with floats" ); + a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 ); + b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 ); + print( a_Matrix3, "set Matrix3 columns" ); + print( b_Matrix3, "set Matrix3 columns" ); + a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 ); + b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 ); + print( a_Matrix4, "set Matrix4 columns" ); + print( b_Matrix4, "set Matrix4 columns" ); + a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 ); + b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 ); + print( a_Transform3, "set Transform3 columns" ); + print( b_Transform3, "set Transform3 columns" ); + a_Matrix4 = Matrix4( a_Transform3 ); + print( a_Matrix4, "construct Matrix4 with Transform3" ); + a_Matrix4 = Matrix4( a_Matrix3, a_Vector3 ); + print( a_Matrix4, "construct Matrix4 with Matrix3 and Vector3" ); + a_Matrix4 = Matrix4( a_Quat, a_Vector3 ); + print( a_Matrix4, "construct Matrix4 with Quat and Vector3" ); + a_Matrix4 = b_Matrix4; + print( a_Matrix4, "assign to Matrix4 from Matrix4" ); + a_Matrix4 = Matrix4( randfloat() ); + print( a_Matrix4, "set Matrix4 with float" ); + a_Matrix4 = Matrix4( randfloat() ); + print( a_Matrix4, "set Matrix4 with float" ); + a_Matrix4 = Matrix4( (vec_float4){0.0f} ); + print( a_Matrix4, "set elements to zero" ); + a_Matrix4 = Matrix4::identity( ); + print( a_Matrix4, "set to identity" ); + a_Matrix4 = Matrix4::rotationX( randfloat() ); + print( a_Matrix4, "set to rotationX" ); + a_Matrix4 = Matrix4::rotationY( randfloat() ); + print( a_Matrix4, "set to rotationY" ); + a_Matrix4 = Matrix4::rotationZ( randfloat() ); + print( a_Matrix4, "set to rotationZ" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Matrix4 = Matrix4::rotationZYX( Vector3( rndflt3, rndflt2, rndflt1 ) ); + print( a_Matrix4, "set to rotation from Z,Y,X angles" ); + a_Matrix4 = Matrix4::rotation( randfloat(), normalize( a_Vector3 ) ); + print( a_Matrix4, "set to rotation from axis angle" ); + a_Matrix4 = Matrix4::translation( a_Vector3 ); + print( a_Matrix4, "set to translation" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Matrix4 = Matrix4::perspective( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Matrix4, "set to perspective matrix" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + a_Matrix4 = Matrix4::frustum( rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6 ); + print( a_Matrix4, "set to frustum matrix" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + a_Matrix4 = Matrix4::orthographic( rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6 ); + print( a_Matrix4, "set to orthographic matrix" ); + a_Matrix4 = Matrix4::lookAt( a_Point3, b_Point3, a_Vector3 ); + print( a_Matrix4, "set to look-at matrix" ); + a_Matrix4.setCol0( a_Vector4 ); + print( a_Matrix4, "Matrix4 set col 0" ); + a_Matrix4.setCol1( a_Vector4 ); + print( a_Matrix4, "Matrix4 set col 1" ); + a_Matrix4.setCol2( a_Vector4 ); + print( a_Matrix4, "Matrix4 set col 2" ); + a_Matrix4.setCol3( a_Vector4 ); + print( a_Matrix4, "Matrix4 set col 3" ); + print( a_Matrix4.getCol0( ), "Matrix4 get col 0" ); + print( a_Matrix4.getCol1( ), "Matrix4 get col 1" ); + print( a_Matrix4.getCol2( ), "Matrix4 get col 2" ); + print( a_Matrix4.getCol3( ), "Matrix4 get col 3" ); + a_Matrix4.setCol( 0, b_Vector4 ); + print( a_Matrix4, "Matrix4 set col 0" ); + a_Matrix4.setCol( 1, b_Vector4 ); + print( a_Matrix4, "Matrix4 set col 1" ); + a_Matrix4.setCol( 2, b_Vector4 ); + print( a_Matrix4, "Matrix4 set col 2" ); + a_Matrix4.setCol( 3, b_Vector4 ); + print( a_Matrix4, "Matrix4 set col 3" ); + print( a_Matrix4.getCol( 0 ), "Matrix4 get col 0" ); + print( a_Matrix4.getCol( 1 ), "Matrix4 get col 1" ); + print( a_Matrix4.getCol( 2 ), "Matrix4 get col 2" ); + print( a_Matrix4.getCol( 3 ), "Matrix4 get col 3" ); + a_Matrix4.setRow( 0, a_Vector4 ); + print( a_Matrix4, "Matrix4 set row 0" ); + a_Matrix4.setRow( 1, a_Vector4 ); + print( a_Matrix4, "Matrix4 set row 1" ); + a_Matrix4.setRow( 2, a_Vector4 ); + print( a_Matrix4, "Matrix4 set row 2" ); + a_Matrix4.setRow( 3, a_Vector4 ); + print( a_Matrix4, "Matrix4 set row 3" ); + print( a_Matrix4.getRow( 0 ), "Matrix4 get row 0" ); + print( a_Matrix4.getRow( 1 ), "Matrix4 get row 1" ); + print( a_Matrix4.getRow( 2 ), "Matrix4 get row 2" ); + print( a_Matrix4.getRow( 3 ), "Matrix4 get row 3" ); + a_Matrix4[0] = a_Vector4; + print( a_Matrix4, "set Matrix4[0]" ); + a_Matrix4[1] = a_Vector4; + print( a_Matrix4, "set Matrix4[1]" ); + a_Matrix4[2] = a_Vector4; + print( a_Matrix4, "set Matrix4[2]" ); + a_Matrix4[3] = a_Vector4; + print( a_Matrix4, "set Matrix4[3]" ); + a_Matrix4[0] = a_Vector4; + print( a_Matrix4[0], "get Matrix4[0]" ); + a_Matrix4[1] = a_Vector4; + print( a_Matrix4[1], "get Matrix4[1]" ); + a_Matrix4[2] = a_Vector4; + print( a_Matrix4[2], "get Matrix4[2]" ); + a_Matrix4[3] = a_Vector4; + print( a_Matrix4[3], "get Matrix4[3]" ); + a_Matrix4.setElem( 0, 0, randfloat() ); + a_Matrix4.setElem( 0, 1, randfloat() ); + a_Matrix4.setElem( 0, 2, randfloat() ); + a_Matrix4.setElem( 0, 3, randfloat() ); + a_Matrix4.setElem( 1, 0, randfloat() ); + a_Matrix4.setElem( 1, 1, randfloat() ); + a_Matrix4.setElem( 1, 2, randfloat() ); + a_Matrix4.setElem( 1, 3, randfloat() ); + a_Matrix4.setElem( 2, 0, randfloat() ); + a_Matrix4.setElem( 2, 1, randfloat() ); + a_Matrix4.setElem( 2, 2, randfloat() ); + a_Matrix4.setElem( 2, 3, randfloat() ); + a_Matrix4.setElem( 3, 0, randfloat() ); + a_Matrix4.setElem( 3, 1, randfloat() ); + a_Matrix4.setElem( 3, 2, randfloat() ); + a_Matrix4.setElem( 3, 3, randfloat() ); + print( a_Matrix4, "Matrix4 set elements" ); + printf("%f\n", getfloat(a_Matrix4.getElem( 0, 0 )) ); + printf("%f\n", getfloat(a_Matrix4.getElem( 0, 1 )) ); + printf("%f\n", getfloat(a_Matrix4.getElem( 0, 2 )) ); + printf("%f\n", getfloat(a_Matrix4.getElem( 0, 3 )) ); + printf("%f\n", getfloat(a_Matrix4.getElem( 1, 0 )) ); + printf("%f\n", getfloat(a_Matrix4.getElem( 1, 1 )) ); + printf("%f\n", getfloat(a_Matrix4.getElem( 1, 2 )) ); + printf("%f\n", getfloat(a_Matrix4.getElem( 1, 3 )) ); + printf("%f\n", getfloat(a_Matrix4.getElem( 2, 0 )) ); + printf("%f\n", getfloat(a_Matrix4.getElem( 2, 1 )) ); + printf("%f\n", getfloat(a_Matrix4.getElem( 2, 2 )) ); + printf("%f\n", getfloat(a_Matrix4.getElem( 2, 3 )) ); + printf("%f\n", getfloat(a_Matrix4.getElem( 3, 0 )) ); + printf("%f\n", getfloat(a_Matrix4.getElem( 3, 1 )) ); + printf("%f\n", getfloat(a_Matrix4.getElem( 3, 2 )) ); + printf("%f\n", getfloat(a_Matrix4.getElem( 3, 3 )) ); +} + +void +Transform3_methods_test() +{ + Matrix3 a_Matrix3, b_Matrix3; + Matrix4 a_Matrix4, b_Matrix4; + Transform3 a_Transform3, b_Transform3; + Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; + Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; + Point3 a_Point3, b_Point3, c_Point3, d_Point3; + Quat a_Quat, b_Quat, c_Quat, d_Quat; + vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + print( a_Vector3, "set Vector3 with floats" ); + print( b_Vector3, "set Vector3 with floats" ); + print( c_Vector3, "set Vector3 with floats" ); + print( d_Vector3, "set Vector3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Vector4, "set Vector4 with floats" ); + print( b_Vector4, "set Vector4 with floats" ); + print( c_Vector4, "set Vector4 with floats" ); + print( d_Vector4, "set Vector4 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Point3 = Point3( rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + print( a_Point3, "set Point3 with floats" ); + print( b_Point3, "set Point3 with floats" ); + print( c_Point3, "set Point3 with floats" ); + print( d_Point3, "set Point3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Quat, "set Quat with floats" ); + print( b_Quat, "set Quat with floats" ); + print( c_Quat, "set Quat with floats" ); + print( d_Quat, "set Quat with floats" ); + a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 ); + b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 ); + print( a_Matrix3, "set Matrix3 columns" ); + print( b_Matrix3, "set Matrix3 columns" ); + a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 ); + b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 ); + print( a_Matrix4, "set Matrix4 columns" ); + print( b_Matrix4, "set Matrix4 columns" ); + a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 ); + b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 ); + print( a_Transform3, "set Transform3 columns" ); + print( b_Transform3, "set Transform3 columns" ); + a_Transform3 = Transform3( a_Matrix3, a_Vector3 ); + print( a_Transform3, "construct Transform3 with Matrix3 and Vector3" ); + a_Transform3 = Transform3( a_Quat, a_Vector3 ); + print( a_Transform3, "construct Transform3 with Quat and Vector3" ); + a_Transform3 = b_Transform3; + print( a_Transform3, "assign to Transform3 from Transform3" ); + a_Transform3 = Transform3( randfloat() ); + print( a_Transform3, "set Transform3 with float" ); + a_Transform3 = Transform3( randfloat() ); + print( a_Transform3, "set Transform3 with float" ); + a_Transform3 = Transform3( (vec_float4){0.0f} ); + print( a_Transform3, "set elements to zero" ); + a_Transform3 = Transform3::identity( ); + print( a_Transform3, "set to identity" ); + a_Transform3 = Transform3::rotationX( randfloat() ); + print( a_Transform3, "set to rotationX" ); + a_Transform3 = Transform3::rotationY( randfloat() ); + print( a_Transform3, "set to rotationY" ); + a_Transform3 = Transform3::rotationZ( randfloat() ); + print( a_Transform3, "set to rotationZ" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Transform3 = Transform3::rotationZYX( Vector3( rndflt3, rndflt2, rndflt1 ) ); + print( a_Transform3, "set to rotation from Z,Y,X angles" ); + a_Transform3 = Transform3::rotation( randfloat(), normalize( a_Vector3 ) ); + print( a_Transform3, "set to rotation from axis angle" ); + a_Transform3 = Transform3::translation( a_Vector3 ); + print( a_Transform3, "set to translation" ); + a_Transform3.setCol0( a_Vector3 ); + print( a_Transform3, "Transform3 set col 0" ); + a_Transform3.setCol1( a_Vector3 ); + print( a_Transform3, "Transform3 set col 1" ); + a_Transform3.setCol2( a_Vector3 ); + print( a_Transform3, "Transform3 set col 2" ); + a_Transform3.setCol3( a_Vector3 ); + print( a_Transform3, "Transform3 set col 3" ); + print( a_Transform3.getCol0( ), "Transform3 get col 0" ); + print( a_Transform3.getCol1( ), "Transform3 get col 1" ); + print( a_Transform3.getCol2( ), "Transform3 get col 2" ); + print( a_Transform3.getCol3( ), "Transform3 get col 3" ); + a_Transform3.setCol( 0, b_Vector3 ); + print( a_Transform3, "Transform3 set col 0" ); + a_Transform3.setCol( 1, b_Vector3 ); + print( a_Transform3, "Transform3 set col 1" ); + a_Transform3.setCol( 2, b_Vector3 ); + print( a_Transform3, "Transform3 set col 2" ); + a_Transform3.setCol( 3, b_Vector3 ); + print( a_Transform3, "Transform3 set col 3" ); + print( a_Transform3.getCol( 0 ), "Transform3 get col 0" ); + print( a_Transform3.getCol( 1 ), "Transform3 get col 1" ); + print( a_Transform3.getCol( 2 ), "Transform3 get col 2" ); + print( a_Transform3.getCol( 3 ), "Transform3 get col 3" ); + a_Transform3.setRow( 0, a_Vector4 ); + print( a_Transform3, "Transform3 set row 0" ); + a_Transform3.setRow( 1, a_Vector4 ); + print( a_Transform3, "Transform3 set row 1" ); + a_Transform3.setRow( 2, a_Vector4 ); + print( a_Transform3, "Transform3 set row 2" ); + print( a_Transform3.getRow( 0 ), "Transform3 get row 0" ); + print( a_Transform3.getRow( 1 ), "Transform3 get row 1" ); + print( a_Transform3.getRow( 2 ), "Transform3 get row 2" ); + a_Transform3[0] = a_Vector3; + print( a_Transform3, "set Transform3[0]" ); + a_Transform3[1] = a_Vector3; + print( a_Transform3, "set Transform3[1]" ); + a_Transform3[2] = a_Vector3; + print( a_Transform3, "set Transform3[2]" ); + a_Transform3[3] = a_Vector3; + print( a_Transform3, "set Transform3[3]" ); + a_Transform3[0] = a_Vector3; + print( a_Transform3[0], "get Transform3[0]" ); + a_Transform3[1] = a_Vector3; + print( a_Transform3[1], "get Transform3[1]" ); + a_Transform3[2] = a_Vector3; + print( a_Transform3[2], "get Transform3[2]" ); + a_Transform3[3] = a_Vector3; + print( a_Transform3[3], "get Transform3[3]" ); + a_Transform3.setElem( 0, 0, randfloat() ); + a_Transform3.setElem( 0, 1, randfloat() ); + a_Transform3.setElem( 0, 2, randfloat() ); + a_Transform3.setElem( 1, 0, randfloat() ); + a_Transform3.setElem( 1, 1, randfloat() ); + a_Transform3.setElem( 1, 2, randfloat() ); + a_Transform3.setElem( 2, 0, randfloat() ); + a_Transform3.setElem( 2, 1, randfloat() ); + a_Transform3.setElem( 2, 2, randfloat() ); + a_Transform3.setElem( 3, 0, randfloat() ); + a_Transform3.setElem( 3, 1, randfloat() ); + a_Transform3.setElem( 3, 2, randfloat() ); + print( a_Transform3, "Transform3 set elements" ); + printf("%f\n", getfloat(a_Transform3.getElem( 0, 0 )) ); + printf("%f\n", getfloat(a_Transform3.getElem( 0, 1 )) ); + printf("%f\n", getfloat(a_Transform3.getElem( 0, 2 )) ); + printf("%f\n", getfloat(a_Transform3.getElem( 1, 0 )) ); + printf("%f\n", getfloat(a_Transform3.getElem( 1, 1 )) ); + printf("%f\n", getfloat(a_Transform3.getElem( 1, 2 )) ); + printf("%f\n", getfloat(a_Transform3.getElem( 2, 0 )) ); + printf("%f\n", getfloat(a_Transform3.getElem( 2, 1 )) ); + printf("%f\n", getfloat(a_Transform3.getElem( 2, 2 )) ); + printf("%f\n", getfloat(a_Transform3.getElem( 3, 0 )) ); + printf("%f\n", getfloat(a_Transform3.getElem( 3, 1 )) ); + printf("%f\n", getfloat(a_Transform3.getElem( 3, 2 )) ); +} + +int main() +{ + int i; + printf("\n __begin__ \n"); + for ( i = 0; i < 2; i++ ) { + Matrix3_methods_test(); + Matrix4_methods_test(); + Transform3_methods_test(); + } + printf("\n __end__ \n"); + return 0; +} diff --git a/vectormathlibrary/tests/test3_aos_c.c b/vectormathlibrary/tests/test3_aos_c.c new file mode 100644 index 000000000..6e5aab4c5 --- /dev/null +++ b/vectormathlibrary/tests/test3_aos_c.c @@ -0,0 +1,524 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _VECTORMATH_AOS_TEST + +#include "vectormath_aos.h" +#include "test.h" + +int iteration = 0; + +void +Matrix3_methods_test() +{ + VmathMatrix3 a_Matrix3, b_Matrix3; + VmathMatrix4 a_Matrix4, b_Matrix4; + VmathTransform3 a_Transform3, b_Transform3; + VmathMatrix3 tmpM3_0, tmpM3_1, tmpM3_2, tmpM3_3, tmpM3_4, tmpM3_5; + VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; + VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; + VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3; + VmathQuat a_Quat, b_Quat, c_Quat, d_Quat; + VmathVector4 tmpV4; + VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7, tmpV3_8; + float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad; + // set a pad value to detect invalid use of padding. + // this will be nan for scalar/ppu implementations, max. float for spu + union { float f; unsigned int u; } tmp; + tmp.u = 0x7fffffff; + pad = tmp.f; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad ); + vmathV4GetXYZ( &a_Vector3, &tmpV4 ); + vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad ); + vmathV4GetXYZ( &b_Vector3, &tmpV4 ); + vmathV4MakeFromV3Scalar( &tmpV4, &c_Vector3, pad ); + vmathV4GetXYZ( &c_Vector3, &tmpV4 ); + vmathV4MakeFromV3Scalar( &tmpV4, &d_Vector3, pad ); + vmathV4GetXYZ( &d_Vector3, &tmpV4 ); + vmathV3Prints( &a_Vector3, "set Vector3 with floats" ); + vmathV3Prints( &b_Vector3, "set Vector3 with floats" ); + vmathV3Prints( &c_Vector3, "set Vector3 with floats" ); + vmathV3Prints( &d_Vector3, "set Vector3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathV4Prints( &a_Vector4, "set Vector4 with floats" ); + vmathV4Prints( &b_Vector4, "set Vector4 with floats" ); + vmathV4Prints( &c_Vector4, "set Vector4 with floats" ); + vmathV4Prints( &d_Vector4, "set Vector4 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); + vmathV3MakeFromP3( &tmpV3_0, &a_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad ); + vmathV4GetXYZ( &tmpV3_1, &tmpV4 ); + vmathP3MakeFromV3( &a_Point3, &tmpV3_1 ); + vmathV3MakeFromP3( &tmpV3_2, &b_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad ); + vmathV4GetXYZ( &tmpV3_3, &tmpV4 ); + vmathP3MakeFromV3( &b_Point3, &tmpV3_3 ); + vmathV3MakeFromP3( &tmpV3_4, &c_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_4, pad ); + vmathV4GetXYZ( &tmpV3_5, &tmpV4 ); + vmathP3MakeFromV3( &c_Point3, &tmpV3_5 ); + vmathV3MakeFromP3( &tmpV3_6, &d_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_6, pad ); + vmathV4GetXYZ( &tmpV3_7, &tmpV4 ); + vmathP3MakeFromV3( &d_Point3, &tmpV3_7 ); + vmathP3Prints( &a_Point3, "set Point3 with floats" ); + vmathP3Prints( &b_Point3, "set Point3 with floats" ); + vmathP3Prints( &c_Point3, "set Point3 with floats" ); + vmathP3Prints( &d_Point3, "set Point3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathQPrints( &a_Quat, "set Quat with floats" ); + vmathQPrints( &b_Quat, "set Quat with floats" ); + vmathQPrints( &c_Quat, "set Quat with floats" ); + vmathQPrints( &d_Quat, "set Quat with floats" ); + vmathM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 ); + vmathM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 ); + vmathM3Prints( &a_Matrix3, "set Matrix3 columns" ); + vmathM3Prints( &b_Matrix3, "set Matrix3 columns" ); + vmathM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 ); + vmathM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 ); + vmathM4Prints( &a_Matrix4, "set Matrix4 columns" ); + vmathM4Prints( &b_Matrix4, "set Matrix4 columns" ); + vmathT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 ); + vmathT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 ); + vmathT3Prints( &a_Transform3, "set Transform3 columns" ); + vmathT3Prints( &b_Transform3, "set Transform3 columns" ); + vmathM3Add( &tmpM3_0, &a_Matrix3, &b_Matrix3 ); + vmathM3Prints( &tmpM3_0, "Matrix3 + Matrix3" ); + vmathM3Sub( &tmpM3_1, &a_Matrix3, &b_Matrix3 ); + vmathM3Prints( &tmpM3_1, "Matrix3 - Matrix3" ); + vmathM3Neg( &tmpM3_2, &a_Matrix3 ); + vmathM3Prints( &tmpM3_2, "-Matrix3" ); + vmathM3ScalarMul( &tmpM3_3, &a_Matrix3, randfloat() ); + vmathM3Prints( &tmpM3_3, "Matrix3 * float" ); + vmathM3ScalarMul( &tmpM3_4, &a_Matrix3, randfloat() ); + vmathM3Prints( &tmpM3_4, "float * Matrix3" ); + vmathM3MulV3( &tmpV3_8, &a_Matrix3, &a_Vector3 ); + vmathV3Prints( &tmpV3_8, "Matrix3 * Vector3" ); + vmathM3Mul( &tmpM3_5, &a_Matrix3, &b_Matrix3 ); + vmathM3Prints( &tmpM3_5, "Matrix3 * Matrix3" ); +} + +void +Matrix4_methods_test() +{ + VmathMatrix3 a_Matrix3, b_Matrix3; + VmathMatrix4 a_Matrix4, b_Matrix4; + VmathTransform3 a_Transform3, b_Transform3; + VmathMatrix4 tmpM4_0, tmpM4_1, tmpM4_2, tmpM4_3, tmpM4_4, tmpM4_5, tmpM4_6; + VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; + VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; + VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3; + VmathQuat a_Quat, b_Quat, c_Quat, d_Quat; + VmathVector4 tmpV4; + VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7; + VmathVector4 tmpV4_0, tmpV4_1, tmpV4_2; + float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad; + // set a pad value to detect invalid use of padding. + // this will be nan for scalar/ppu implementations, max. float for spu + union { float f; unsigned int u; } tmp; + tmp.u = 0x7fffffff; + pad = tmp.f; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad ); + vmathV4GetXYZ( &a_Vector3, &tmpV4 ); + vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad ); + vmathV4GetXYZ( &b_Vector3, &tmpV4 ); + vmathV4MakeFromV3Scalar( &tmpV4, &c_Vector3, pad ); + vmathV4GetXYZ( &c_Vector3, &tmpV4 ); + vmathV4MakeFromV3Scalar( &tmpV4, &d_Vector3, pad ); + vmathV4GetXYZ( &d_Vector3, &tmpV4 ); + vmathV3Prints( &a_Vector3, "set Vector3 with floats" ); + vmathV3Prints( &b_Vector3, "set Vector3 with floats" ); + vmathV3Prints( &c_Vector3, "set Vector3 with floats" ); + vmathV3Prints( &d_Vector3, "set Vector3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathV4Prints( &a_Vector4, "set Vector4 with floats" ); + vmathV4Prints( &b_Vector4, "set Vector4 with floats" ); + vmathV4Prints( &c_Vector4, "set Vector4 with floats" ); + vmathV4Prints( &d_Vector4, "set Vector4 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); + vmathV3MakeFromP3( &tmpV3_0, &a_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad ); + vmathV4GetXYZ( &tmpV3_1, &tmpV4 ); + vmathP3MakeFromV3( &a_Point3, &tmpV3_1 ); + vmathV3MakeFromP3( &tmpV3_2, &b_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad ); + vmathV4GetXYZ( &tmpV3_3, &tmpV4 ); + vmathP3MakeFromV3( &b_Point3, &tmpV3_3 ); + vmathV3MakeFromP3( &tmpV3_4, &c_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_4, pad ); + vmathV4GetXYZ( &tmpV3_5, &tmpV4 ); + vmathP3MakeFromV3( &c_Point3, &tmpV3_5 ); + vmathV3MakeFromP3( &tmpV3_6, &d_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_6, pad ); + vmathV4GetXYZ( &tmpV3_7, &tmpV4 ); + vmathP3MakeFromV3( &d_Point3, &tmpV3_7 ); + vmathP3Prints( &a_Point3, "set Point3 with floats" ); + vmathP3Prints( &b_Point3, "set Point3 with floats" ); + vmathP3Prints( &c_Point3, "set Point3 with floats" ); + vmathP3Prints( &d_Point3, "set Point3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathQPrints( &a_Quat, "set Quat with floats" ); + vmathQPrints( &b_Quat, "set Quat with floats" ); + vmathQPrints( &c_Quat, "set Quat with floats" ); + vmathQPrints( &d_Quat, "set Quat with floats" ); + vmathM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 ); + vmathM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 ); + vmathM3Prints( &a_Matrix3, "set Matrix3 columns" ); + vmathM3Prints( &b_Matrix3, "set Matrix3 columns" ); + vmathM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 ); + vmathM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 ); + vmathM4Prints( &a_Matrix4, "set Matrix4 columns" ); + vmathM4Prints( &b_Matrix4, "set Matrix4 columns" ); + vmathT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 ); + vmathT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 ); + vmathT3Prints( &a_Transform3, "set Transform3 columns" ); + vmathT3Prints( &b_Transform3, "set Transform3 columns" ); + vmathM4Add( &tmpM4_0, &a_Matrix4, &b_Matrix4 ); + vmathM4Prints( &tmpM4_0, "Matrix4 + Matrix4" ); + vmathM4Sub( &tmpM4_1, &a_Matrix4, &b_Matrix4 ); + vmathM4Prints( &tmpM4_1, "Matrix4 - Matrix4" ); + vmathM4Neg( &tmpM4_2, &a_Matrix4 ); + vmathM4Prints( &tmpM4_2, "-Matrix4" ); + vmathM4ScalarMul( &tmpM4_3, &a_Matrix4, randfloat() ); + vmathM4Prints( &tmpM4_3, "Matrix4 * float" ); + vmathM4ScalarMul( &tmpM4_4, &a_Matrix4, randfloat() ); + vmathM4Prints( &tmpM4_4, "float * Matrix4" ); + vmathM4MulV4( &tmpV4_0, &a_Matrix4, &a_Vector4 ); + vmathV4Prints( &tmpV4_0, "Matrix4 * Vector4" ); + vmathM4MulV3( &tmpV4_1, &a_Matrix4, &a_Vector3 ); + vmathV4Prints( &tmpV4_1, "Matrix4 * Vector3" ); + vmathM4MulP3( &tmpV4_2, &a_Matrix4, &a_Point3 ); + vmathV4Prints( &tmpV4_2, "Matrix4 * Point3" ); + vmathM4Mul( &tmpM4_5, &a_Matrix4, &b_Matrix4 ); + vmathM4Prints( &tmpM4_5, "Matrix4 * Matrix4" ); + vmathM4MulT3( &tmpM4_6, &a_Matrix4, &b_Transform3 ); + vmathM4Prints( &tmpM4_6, "Matrix4 * Transform3" ); +} + +void +Transform3_methods_test() +{ + VmathMatrix3 a_Matrix3, b_Matrix3; + VmathMatrix4 a_Matrix4, b_Matrix4; + VmathTransform3 a_Transform3, b_Transform3, tmpT3_0; + VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; + VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; + VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3; + VmathQuat a_Quat, b_Quat, c_Quat, d_Quat; + VmathVector4 tmpV4; + VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7, tmpV3_8; + VmathPoint3 tmpP3_0; + float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad; + // set a pad value to detect invalid use of padding. + // this will be nan for scalar/ppu implementations, max. float for spu + union { float f; unsigned int u; } tmp; + tmp.u = 0x7fffffff; + pad = tmp.f; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad ); + vmathV4GetXYZ( &a_Vector3, &tmpV4 ); + vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad ); + vmathV4GetXYZ( &b_Vector3, &tmpV4 ); + vmathV4MakeFromV3Scalar( &tmpV4, &c_Vector3, pad ); + vmathV4GetXYZ( &c_Vector3, &tmpV4 ); + vmathV4MakeFromV3Scalar( &tmpV4, &d_Vector3, pad ); + vmathV4GetXYZ( &d_Vector3, &tmpV4 ); + vmathV3Prints( &a_Vector3, "set Vector3 with floats" ); + vmathV3Prints( &b_Vector3, "set Vector3 with floats" ); + vmathV3Prints( &c_Vector3, "set Vector3 with floats" ); + vmathV3Prints( &d_Vector3, "set Vector3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathV4Prints( &a_Vector4, "set Vector4 with floats" ); + vmathV4Prints( &b_Vector4, "set Vector4 with floats" ); + vmathV4Prints( &c_Vector4, "set Vector4 with floats" ); + vmathV4Prints( &d_Vector4, "set Vector4 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); + vmathV3MakeFromP3( &tmpV3_0, &a_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad ); + vmathV4GetXYZ( &tmpV3_1, &tmpV4 ); + vmathP3MakeFromV3( &a_Point3, &tmpV3_1 ); + vmathV3MakeFromP3( &tmpV3_2, &b_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad ); + vmathV4GetXYZ( &tmpV3_3, &tmpV4 ); + vmathP3MakeFromV3( &b_Point3, &tmpV3_3 ); + vmathV3MakeFromP3( &tmpV3_4, &c_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_4, pad ); + vmathV4GetXYZ( &tmpV3_5, &tmpV4 ); + vmathP3MakeFromV3( &c_Point3, &tmpV3_5 ); + vmathV3MakeFromP3( &tmpV3_6, &d_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_6, pad ); + vmathV4GetXYZ( &tmpV3_7, &tmpV4 ); + vmathP3MakeFromV3( &d_Point3, &tmpV3_7 ); + vmathP3Prints( &a_Point3, "set Point3 with floats" ); + vmathP3Prints( &b_Point3, "set Point3 with floats" ); + vmathP3Prints( &c_Point3, "set Point3 with floats" ); + vmathP3Prints( &d_Point3, "set Point3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathQPrints( &a_Quat, "set Quat with floats" ); + vmathQPrints( &b_Quat, "set Quat with floats" ); + vmathQPrints( &c_Quat, "set Quat with floats" ); + vmathQPrints( &d_Quat, "set Quat with floats" ); + vmathM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 ); + vmathM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 ); + vmathM3Prints( &a_Matrix3, "set Matrix3 columns" ); + vmathM3Prints( &b_Matrix3, "set Matrix3 columns" ); + vmathM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 ); + vmathM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 ); + vmathM4Prints( &a_Matrix4, "set Matrix4 columns" ); + vmathM4Prints( &b_Matrix4, "set Matrix4 columns" ); + vmathT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 ); + vmathT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 ); + vmathT3Prints( &a_Transform3, "set Transform3 columns" ); + vmathT3Prints( &b_Transform3, "set Transform3 columns" ); + vmathT3MulV3( &tmpV3_8, &a_Transform3, &a_Vector3 ); + vmathV3Prints( &tmpV3_8, "Transform3 * Vector3" ); + vmathT3MulP3( &tmpP3_0, &a_Transform3, &a_Point3 ); + vmathP3Prints( &tmpP3_0, "Transform3 * Point3" ); + vmathT3Mul( &tmpT3_0, &a_Transform3, &b_Transform3 ); + vmathT3Prints( &tmpT3_0, "Transform3 * Transform3" ); +} + +int main() +{ + int i; + printf("\n __begin__ \n"); + for ( i = 0; i < 2; i++ ) { + Matrix3_methods_test(); + Matrix4_methods_test(); + Transform3_methods_test(); + } + printf("\n __end__ \n"); + return 0; +} diff --git a/vectormathlibrary/tests/test3_aos_cpp.cpp b/vectormathlibrary/tests/test3_aos_cpp.cpp new file mode 100644 index 000000000..6bf1019e4 --- /dev/null +++ b/vectormathlibrary/tests/test3_aos_cpp.cpp @@ -0,0 +1,476 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _VECTORMATH_AOS_TEST + +#include "vectormath_aos.h" +#include "test.h" + +int iteration = 0; + +using namespace Vectormath; +using namespace Vectormath::Aos; + +void +Matrix3_methods_test() +{ + Matrix3 a_Matrix3, b_Matrix3; + Matrix4 a_Matrix4, b_Matrix4; + Transform3 a_Transform3, b_Transform3; + Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; + Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; + Point3 a_Point3, b_Point3, c_Point3, d_Point3; + Quat a_Quat, b_Quat, c_Quat, d_Quat; + Vector4 tmpV4; + float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad; + // set a pad value to detect invalid use of padding. + // this will be nan for scalar/ppu implementations, max. float for spu + union { float f; unsigned int u; } tmp; + tmp.u = 0x7fffffff; + pad = tmp.f; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + tmpV4 = Vector4( a_Vector3, pad ); + a_Vector3 = tmpV4.getXYZ( ); + tmpV4 = Vector4( b_Vector3, pad ); + b_Vector3 = tmpV4.getXYZ( ); + tmpV4 = Vector4( c_Vector3, pad ); + c_Vector3 = tmpV4.getXYZ( ); + tmpV4 = Vector4( d_Vector3, pad ); + d_Vector3 = tmpV4.getXYZ( ); + print( a_Vector3, "set Vector3 with floats" ); + print( b_Vector3, "set Vector3 with floats" ); + print( c_Vector3, "set Vector3 with floats" ); + print( d_Vector3, "set Vector3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Vector4, "set Vector4 with floats" ); + print( b_Vector4, "set Vector4 with floats" ); + print( c_Vector4, "set Vector4 with floats" ); + print( d_Vector4, "set Vector4 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Point3 = Point3( rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + tmpV4 = Vector4( Vector3( a_Point3 ), pad ); + a_Point3 = Point3( tmpV4.getXYZ( ) ); + tmpV4 = Vector4( Vector3( b_Point3 ), pad ); + b_Point3 = Point3( tmpV4.getXYZ( ) ); + tmpV4 = Vector4( Vector3( c_Point3 ), pad ); + c_Point3 = Point3( tmpV4.getXYZ( ) ); + tmpV4 = Vector4( Vector3( d_Point3 ), pad ); + d_Point3 = Point3( tmpV4.getXYZ( ) ); + print( a_Point3, "set Point3 with floats" ); + print( b_Point3, "set Point3 with floats" ); + print( c_Point3, "set Point3 with floats" ); + print( d_Point3, "set Point3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Quat, "set Quat with floats" ); + print( b_Quat, "set Quat with floats" ); + print( c_Quat, "set Quat with floats" ); + print( d_Quat, "set Quat with floats" ); + a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 ); + b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 ); + print( a_Matrix3, "set Matrix3 columns" ); + print( b_Matrix3, "set Matrix3 columns" ); + a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 ); + b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 ); + print( a_Matrix4, "set Matrix4 columns" ); + print( b_Matrix4, "set Matrix4 columns" ); + a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 ); + b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 ); + print( a_Transform3, "set Transform3 columns" ); + print( b_Transform3, "set Transform3 columns" ); + print( ( a_Matrix3 + b_Matrix3 ), "Matrix3 + Matrix3" ); + print( ( a_Matrix3 - b_Matrix3 ), "Matrix3 - Matrix3" ); + print( ( -a_Matrix3 ), "-Matrix3" ); + print( ( a_Matrix3 * randfloat() ), "Matrix3 * float" ); + print( ( randfloat() * a_Matrix3 ), "float * Matrix3" ); + print( ( a_Matrix3 * a_Vector3 ), "Matrix3 * Vector3" ); + print( ( a_Matrix3 * b_Matrix3 ), "Matrix3 * Matrix3" ); +} + +void +Matrix4_methods_test() +{ + Matrix3 a_Matrix3, b_Matrix3; + Matrix4 a_Matrix4, b_Matrix4; + Transform3 a_Transform3, b_Transform3; + Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; + Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; + Point3 a_Point3, b_Point3, c_Point3, d_Point3; + Quat a_Quat, b_Quat, c_Quat, d_Quat; + Vector4 tmpV4; + float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad; + // set a pad value to detect invalid use of padding. + // this will be nan for scalar/ppu implementations, max. float for spu + union { float f; unsigned int u; } tmp; + tmp.u = 0x7fffffff; + pad = tmp.f; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + tmpV4 = Vector4( a_Vector3, pad ); + a_Vector3 = tmpV4.getXYZ( ); + tmpV4 = Vector4( b_Vector3, pad ); + b_Vector3 = tmpV4.getXYZ( ); + tmpV4 = Vector4( c_Vector3, pad ); + c_Vector3 = tmpV4.getXYZ( ); + tmpV4 = Vector4( d_Vector3, pad ); + d_Vector3 = tmpV4.getXYZ( ); + print( a_Vector3, "set Vector3 with floats" ); + print( b_Vector3, "set Vector3 with floats" ); + print( c_Vector3, "set Vector3 with floats" ); + print( d_Vector3, "set Vector3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Vector4, "set Vector4 with floats" ); + print( b_Vector4, "set Vector4 with floats" ); + print( c_Vector4, "set Vector4 with floats" ); + print( d_Vector4, "set Vector4 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Point3 = Point3( rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + tmpV4 = Vector4( Vector3( a_Point3 ), pad ); + a_Point3 = Point3( tmpV4.getXYZ( ) ); + tmpV4 = Vector4( Vector3( b_Point3 ), pad ); + b_Point3 = Point3( tmpV4.getXYZ( ) ); + tmpV4 = Vector4( Vector3( c_Point3 ), pad ); + c_Point3 = Point3( tmpV4.getXYZ( ) ); + tmpV4 = Vector4( Vector3( d_Point3 ), pad ); + d_Point3 = Point3( tmpV4.getXYZ( ) ); + print( a_Point3, "set Point3 with floats" ); + print( b_Point3, "set Point3 with floats" ); + print( c_Point3, "set Point3 with floats" ); + print( d_Point3, "set Point3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Quat, "set Quat with floats" ); + print( b_Quat, "set Quat with floats" ); + print( c_Quat, "set Quat with floats" ); + print( d_Quat, "set Quat with floats" ); + a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 ); + b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 ); + print( a_Matrix3, "set Matrix3 columns" ); + print( b_Matrix3, "set Matrix3 columns" ); + a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 ); + b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 ); + print( a_Matrix4, "set Matrix4 columns" ); + print( b_Matrix4, "set Matrix4 columns" ); + a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 ); + b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 ); + print( a_Transform3, "set Transform3 columns" ); + print( b_Transform3, "set Transform3 columns" ); + print( ( a_Matrix4 + b_Matrix4 ), "Matrix4 + Matrix4" ); + print( ( a_Matrix4 - b_Matrix4 ), "Matrix4 - Matrix4" ); + print( ( -a_Matrix4 ), "-Matrix4" ); + print( ( a_Matrix4 * randfloat() ), "Matrix4 * float" ); + print( ( randfloat() * a_Matrix4 ), "float * Matrix4" ); + print( ( a_Matrix4 * a_Vector4 ), "Matrix4 * Vector4" ); + print( ( a_Matrix4 * a_Vector3 ), "Matrix4 * Vector3" ); + print( ( a_Matrix4 * a_Point3 ), "Matrix4 * Point3" ); + print( ( a_Matrix4 * b_Matrix4 ), "Matrix4 * Matrix4" ); + print( ( a_Matrix4 * b_Transform3 ), "Matrix4 * Transform3" ); +} + +void +Transform3_methods_test() +{ + Matrix3 a_Matrix3, b_Matrix3; + Matrix4 a_Matrix4, b_Matrix4; + Transform3 a_Transform3, b_Transform3; + Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; + Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; + Point3 a_Point3, b_Point3, c_Point3, d_Point3; + Quat a_Quat, b_Quat, c_Quat, d_Quat; + Vector4 tmpV4; + float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad; + // set a pad value to detect invalid use of padding. + // this will be nan for scalar/ppu implementations, max. float for spu + union { float f; unsigned int u; } tmp; + tmp.u = 0x7fffffff; + pad = tmp.f; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + tmpV4 = Vector4( a_Vector3, pad ); + a_Vector3 = tmpV4.getXYZ( ); + tmpV4 = Vector4( b_Vector3, pad ); + b_Vector3 = tmpV4.getXYZ( ); + tmpV4 = Vector4( c_Vector3, pad ); + c_Vector3 = tmpV4.getXYZ( ); + tmpV4 = Vector4( d_Vector3, pad ); + d_Vector3 = tmpV4.getXYZ( ); + print( a_Vector3, "set Vector3 with floats" ); + print( b_Vector3, "set Vector3 with floats" ); + print( c_Vector3, "set Vector3 with floats" ); + print( d_Vector3, "set Vector3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Vector4, "set Vector4 with floats" ); + print( b_Vector4, "set Vector4 with floats" ); + print( c_Vector4, "set Vector4 with floats" ); + print( d_Vector4, "set Vector4 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Point3 = Point3( rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + tmpV4 = Vector4( Vector3( a_Point3 ), pad ); + a_Point3 = Point3( tmpV4.getXYZ( ) ); + tmpV4 = Vector4( Vector3( b_Point3 ), pad ); + b_Point3 = Point3( tmpV4.getXYZ( ) ); + tmpV4 = Vector4( Vector3( c_Point3 ), pad ); + c_Point3 = Point3( tmpV4.getXYZ( ) ); + tmpV4 = Vector4( Vector3( d_Point3 ), pad ); + d_Point3 = Point3( tmpV4.getXYZ( ) ); + print( a_Point3, "set Point3 with floats" ); + print( b_Point3, "set Point3 with floats" ); + print( c_Point3, "set Point3 with floats" ); + print( d_Point3, "set Point3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Quat, "set Quat with floats" ); + print( b_Quat, "set Quat with floats" ); + print( c_Quat, "set Quat with floats" ); + print( d_Quat, "set Quat with floats" ); + a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 ); + b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 ); + print( a_Matrix3, "set Matrix3 columns" ); + print( b_Matrix3, "set Matrix3 columns" ); + a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 ); + b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 ); + print( a_Matrix4, "set Matrix4 columns" ); + print( b_Matrix4, "set Matrix4 columns" ); + a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 ); + b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 ); + print( a_Transform3, "set Transform3 columns" ); + print( b_Transform3, "set Transform3 columns" ); + print( ( a_Transform3 * a_Vector3 ), "Transform3 * Vector3" ); + print( ( a_Transform3 * a_Point3 ), "Transform3 * Point3" ); + print( ( a_Transform3 * b_Transform3 ), "Transform3 * Transform3" ); +} + +int main() +{ + int i; + printf("\n __begin__ \n"); + for ( i = 0; i < 2; i++ ) { + Matrix3_methods_test(); + Matrix4_methods_test(); + Transform3_methods_test(); + } + printf("\n __end__ \n"); + return 0; +} diff --git a/vectormathlibrary/tests/test3_soa_c.c b/vectormathlibrary/tests/test3_soa_c.c new file mode 100644 index 000000000..94660487f --- /dev/null +++ b/vectormathlibrary/tests/test3_soa_c.c @@ -0,0 +1,433 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _VECTORMATH_SOA_TEST + +#include "vectormath_soa.h" +#include "test.h" + +int iteration = 0; + +void +Matrix3_methods_test() +{ + VmathSoaMatrix3 a_Matrix3, b_Matrix3; + VmathSoaMatrix4 a_Matrix4, b_Matrix4; + VmathSoaTransform3 a_Transform3, b_Transform3; + VmathSoaMatrix3 tmpM3_0, tmpM3_1, tmpM3_2, tmpM3_3, tmpM3_4, tmpM3_5; + VmathSoaVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; + VmathSoaVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; + VmathSoaPoint3 a_Point3, b_Point3, c_Point3, d_Point3; + VmathSoaQuat a_Quat, b_Quat, c_Quat, d_Quat; + VmathSoaVector3 tmpV3_0; + vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); + vmathSoaV3Prints( &a_Vector3, "set Vector3 with floats" ); + vmathSoaV3Prints( &b_Vector3, "set Vector3 with floats" ); + vmathSoaV3Prints( &c_Vector3, "set Vector3 with floats" ); + vmathSoaV3Prints( &d_Vector3, "set Vector3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathSoaV4Prints( &a_Vector4, "set Vector4 with floats" ); + vmathSoaV4Prints( &b_Vector4, "set Vector4 with floats" ); + vmathSoaV4Prints( &c_Vector4, "set Vector4 with floats" ); + vmathSoaV4Prints( &d_Vector4, "set Vector4 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); + vmathSoaP3Prints( &a_Point3, "set Point3 with floats" ); + vmathSoaP3Prints( &b_Point3, "set Point3 with floats" ); + vmathSoaP3Prints( &c_Point3, "set Point3 with floats" ); + vmathSoaP3Prints( &d_Point3, "set Point3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathSoaQPrints( &a_Quat, "set Quat with floats" ); + vmathSoaQPrints( &b_Quat, "set Quat with floats" ); + vmathSoaQPrints( &c_Quat, "set Quat with floats" ); + vmathSoaQPrints( &d_Quat, "set Quat with floats" ); + vmathSoaM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 ); + vmathSoaM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 ); + vmathSoaM3Prints( &a_Matrix3, "set Matrix3 columns" ); + vmathSoaM3Prints( &b_Matrix3, "set Matrix3 columns" ); + vmathSoaM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 ); + vmathSoaM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 ); + vmathSoaM4Prints( &a_Matrix4, "set Matrix4 columns" ); + vmathSoaM4Prints( &b_Matrix4, "set Matrix4 columns" ); + vmathSoaT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 ); + vmathSoaT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 ); + vmathSoaT3Prints( &a_Transform3, "set Transform3 columns" ); + vmathSoaT3Prints( &b_Transform3, "set Transform3 columns" ); + vmathSoaM3Add( &tmpM3_0, &a_Matrix3, &b_Matrix3 ); + vmathSoaM3Prints( &tmpM3_0, "Matrix3 + Matrix3" ); + vmathSoaM3Sub( &tmpM3_1, &a_Matrix3, &b_Matrix3 ); + vmathSoaM3Prints( &tmpM3_1, "Matrix3 - Matrix3" ); + vmathSoaM3Neg( &tmpM3_2, &a_Matrix3 ); + vmathSoaM3Prints( &tmpM3_2, "-Matrix3" ); + vmathSoaM3ScalarMul( &tmpM3_3, &a_Matrix3, randfloat() ); + vmathSoaM3Prints( &tmpM3_3, "Matrix3 * float" ); + vmathSoaM3ScalarMul( &tmpM3_4, &a_Matrix3, randfloat() ); + vmathSoaM3Prints( &tmpM3_4, "float * Matrix3" ); + vmathSoaM3MulV3( &tmpV3_0, &a_Matrix3, &a_Vector3 ); + vmathSoaV3Prints( &tmpV3_0, "Matrix3 * Vector3" ); + vmathSoaM3Mul( &tmpM3_5, &a_Matrix3, &b_Matrix3 ); + vmathSoaM3Prints( &tmpM3_5, "Matrix3 * Matrix3" ); +} + +void +Matrix4_methods_test() +{ + VmathSoaMatrix3 a_Matrix3, b_Matrix3; + VmathSoaMatrix4 a_Matrix4, b_Matrix4; + VmathSoaTransform3 a_Transform3, b_Transform3; + VmathSoaMatrix4 tmpM4_0, tmpM4_1, tmpM4_2, tmpM4_3, tmpM4_4, tmpM4_5, tmpM4_6; + VmathSoaVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; + VmathSoaVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; + VmathSoaPoint3 a_Point3, b_Point3, c_Point3, d_Point3; + VmathSoaQuat a_Quat, b_Quat, c_Quat, d_Quat; + VmathSoaVector4 tmpV4_0, tmpV4_1, tmpV4_2; + vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); + vmathSoaV3Prints( &a_Vector3, "set Vector3 with floats" ); + vmathSoaV3Prints( &b_Vector3, "set Vector3 with floats" ); + vmathSoaV3Prints( &c_Vector3, "set Vector3 with floats" ); + vmathSoaV3Prints( &d_Vector3, "set Vector3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathSoaV4Prints( &a_Vector4, "set Vector4 with floats" ); + vmathSoaV4Prints( &b_Vector4, "set Vector4 with floats" ); + vmathSoaV4Prints( &c_Vector4, "set Vector4 with floats" ); + vmathSoaV4Prints( &d_Vector4, "set Vector4 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); + vmathSoaP3Prints( &a_Point3, "set Point3 with floats" ); + vmathSoaP3Prints( &b_Point3, "set Point3 with floats" ); + vmathSoaP3Prints( &c_Point3, "set Point3 with floats" ); + vmathSoaP3Prints( &d_Point3, "set Point3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathSoaQPrints( &a_Quat, "set Quat with floats" ); + vmathSoaQPrints( &b_Quat, "set Quat with floats" ); + vmathSoaQPrints( &c_Quat, "set Quat with floats" ); + vmathSoaQPrints( &d_Quat, "set Quat with floats" ); + vmathSoaM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 ); + vmathSoaM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 ); + vmathSoaM3Prints( &a_Matrix3, "set Matrix3 columns" ); + vmathSoaM3Prints( &b_Matrix3, "set Matrix3 columns" ); + vmathSoaM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 ); + vmathSoaM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 ); + vmathSoaM4Prints( &a_Matrix4, "set Matrix4 columns" ); + vmathSoaM4Prints( &b_Matrix4, "set Matrix4 columns" ); + vmathSoaT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 ); + vmathSoaT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 ); + vmathSoaT3Prints( &a_Transform3, "set Transform3 columns" ); + vmathSoaT3Prints( &b_Transform3, "set Transform3 columns" ); + vmathSoaM4Add( &tmpM4_0, &a_Matrix4, &b_Matrix4 ); + vmathSoaM4Prints( &tmpM4_0, "Matrix4 + Matrix4" ); + vmathSoaM4Sub( &tmpM4_1, &a_Matrix4, &b_Matrix4 ); + vmathSoaM4Prints( &tmpM4_1, "Matrix4 - Matrix4" ); + vmathSoaM4Neg( &tmpM4_2, &a_Matrix4 ); + vmathSoaM4Prints( &tmpM4_2, "-Matrix4" ); + vmathSoaM4ScalarMul( &tmpM4_3, &a_Matrix4, randfloat() ); + vmathSoaM4Prints( &tmpM4_3, "Matrix4 * float" ); + vmathSoaM4ScalarMul( &tmpM4_4, &a_Matrix4, randfloat() ); + vmathSoaM4Prints( &tmpM4_4, "float * Matrix4" ); + vmathSoaM4MulV4( &tmpV4_0, &a_Matrix4, &a_Vector4 ); + vmathSoaV4Prints( &tmpV4_0, "Matrix4 * Vector4" ); + vmathSoaM4MulV3( &tmpV4_1, &a_Matrix4, &a_Vector3 ); + vmathSoaV4Prints( &tmpV4_1, "Matrix4 * Vector3" ); + vmathSoaM4MulP3( &tmpV4_2, &a_Matrix4, &a_Point3 ); + vmathSoaV4Prints( &tmpV4_2, "Matrix4 * Point3" ); + vmathSoaM4Mul( &tmpM4_5, &a_Matrix4, &b_Matrix4 ); + vmathSoaM4Prints( &tmpM4_5, "Matrix4 * Matrix4" ); + vmathSoaM4MulT3( &tmpM4_6, &a_Matrix4, &b_Transform3 ); + vmathSoaM4Prints( &tmpM4_6, "Matrix4 * Transform3" ); +} + +void +Transform3_methods_test() +{ + VmathSoaMatrix3 a_Matrix3, b_Matrix3; + VmathSoaMatrix4 a_Matrix4, b_Matrix4; + VmathSoaTransform3 a_Transform3, b_Transform3, tmpT3_0; + VmathSoaVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; + VmathSoaVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; + VmathSoaPoint3 a_Point3, b_Point3, c_Point3, d_Point3; + VmathSoaQuat a_Quat, b_Quat, c_Quat, d_Quat; + VmathSoaVector3 tmpV3_0; + VmathSoaPoint3 tmpP3_0; + vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); + vmathSoaV3Prints( &a_Vector3, "set Vector3 with floats" ); + vmathSoaV3Prints( &b_Vector3, "set Vector3 with floats" ); + vmathSoaV3Prints( &c_Vector3, "set Vector3 with floats" ); + vmathSoaV3Prints( &d_Vector3, "set Vector3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathSoaV4Prints( &a_Vector4, "set Vector4 with floats" ); + vmathSoaV4Prints( &b_Vector4, "set Vector4 with floats" ); + vmathSoaV4Prints( &c_Vector4, "set Vector4 with floats" ); + vmathSoaV4Prints( &d_Vector4, "set Vector4 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); + vmathSoaP3Prints( &a_Point3, "set Point3 with floats" ); + vmathSoaP3Prints( &b_Point3, "set Point3 with floats" ); + vmathSoaP3Prints( &c_Point3, "set Point3 with floats" ); + vmathSoaP3Prints( &d_Point3, "set Point3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathSoaQPrints( &a_Quat, "set Quat with floats" ); + vmathSoaQPrints( &b_Quat, "set Quat with floats" ); + vmathSoaQPrints( &c_Quat, "set Quat with floats" ); + vmathSoaQPrints( &d_Quat, "set Quat with floats" ); + vmathSoaM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 ); + vmathSoaM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 ); + vmathSoaM3Prints( &a_Matrix3, "set Matrix3 columns" ); + vmathSoaM3Prints( &b_Matrix3, "set Matrix3 columns" ); + vmathSoaM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 ); + vmathSoaM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 ); + vmathSoaM4Prints( &a_Matrix4, "set Matrix4 columns" ); + vmathSoaM4Prints( &b_Matrix4, "set Matrix4 columns" ); + vmathSoaT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 ); + vmathSoaT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 ); + vmathSoaT3Prints( &a_Transform3, "set Transform3 columns" ); + vmathSoaT3Prints( &b_Transform3, "set Transform3 columns" ); + vmathSoaT3MulV3( &tmpV3_0, &a_Transform3, &a_Vector3 ); + vmathSoaV3Prints( &tmpV3_0, "Transform3 * Vector3" ); + vmathSoaT3MulP3( &tmpP3_0, &a_Transform3, &a_Point3 ); + vmathSoaP3Prints( &tmpP3_0, "Transform3 * Point3" ); + vmathSoaT3Mul( &tmpT3_0, &a_Transform3, &b_Transform3 ); + vmathSoaT3Prints( &tmpT3_0, "Transform3 * Transform3" ); +} + +int main() +{ + int i; + printf("\n __begin__ \n"); + for ( i = 0; i < 2; i++ ) { + Matrix3_methods_test(); + Matrix4_methods_test(); + Transform3_methods_test(); + } + printf("\n __end__ \n"); + return 0; +} diff --git a/vectormathlibrary/tests/test3_soa_cpp.cpp b/vectormathlibrary/tests/test3_soa_cpp.cpp new file mode 100644 index 000000000..85f0bf190 --- /dev/null +++ b/vectormathlibrary/tests/test3_soa_cpp.cpp @@ -0,0 +1,410 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _VECTORMATH_SOA_TEST + +#include "vectormath_soa.h" +#include "test.h" + +int iteration = 0; + +using namespace Vectormath; +using namespace Vectormath::Soa; + +void +Matrix3_methods_test() +{ + Matrix3 a_Matrix3, b_Matrix3; + Matrix4 a_Matrix4, b_Matrix4; + Transform3 a_Transform3, b_Transform3; + Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; + Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; + Point3 a_Point3, b_Point3, c_Point3, d_Point3; + Quat a_Quat, b_Quat, c_Quat, d_Quat; + vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + print( a_Vector3, "set Vector3 with floats" ); + print( b_Vector3, "set Vector3 with floats" ); + print( c_Vector3, "set Vector3 with floats" ); + print( d_Vector3, "set Vector3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Vector4, "set Vector4 with floats" ); + print( b_Vector4, "set Vector4 with floats" ); + print( c_Vector4, "set Vector4 with floats" ); + print( d_Vector4, "set Vector4 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Point3 = Point3( rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + print( a_Point3, "set Point3 with floats" ); + print( b_Point3, "set Point3 with floats" ); + print( c_Point3, "set Point3 with floats" ); + print( d_Point3, "set Point3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Quat, "set Quat with floats" ); + print( b_Quat, "set Quat with floats" ); + print( c_Quat, "set Quat with floats" ); + print( d_Quat, "set Quat with floats" ); + a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 ); + b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 ); + print( a_Matrix3, "set Matrix3 columns" ); + print( b_Matrix3, "set Matrix3 columns" ); + a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 ); + b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 ); + print( a_Matrix4, "set Matrix4 columns" ); + print( b_Matrix4, "set Matrix4 columns" ); + a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 ); + b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 ); + print( a_Transform3, "set Transform3 columns" ); + print( b_Transform3, "set Transform3 columns" ); + print( ( a_Matrix3 + b_Matrix3 ), "Matrix3 + Matrix3" ); + print( ( a_Matrix3 - b_Matrix3 ), "Matrix3 - Matrix3" ); + print( ( -a_Matrix3 ), "-Matrix3" ); + print( ( a_Matrix3 * randfloat() ), "Matrix3 * float" ); + print( ( randfloat() * a_Matrix3 ), "float * Matrix3" ); + print( ( a_Matrix3 * a_Vector3 ), "Matrix3 * Vector3" ); + print( ( a_Matrix3 * b_Matrix3 ), "Matrix3 * Matrix3" ); +} + +void +Matrix4_methods_test() +{ + Matrix3 a_Matrix3, b_Matrix3; + Matrix4 a_Matrix4, b_Matrix4; + Transform3 a_Transform3, b_Transform3; + Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; + Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; + Point3 a_Point3, b_Point3, c_Point3, d_Point3; + Quat a_Quat, b_Quat, c_Quat, d_Quat; + vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + print( a_Vector3, "set Vector3 with floats" ); + print( b_Vector3, "set Vector3 with floats" ); + print( c_Vector3, "set Vector3 with floats" ); + print( d_Vector3, "set Vector3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Vector4, "set Vector4 with floats" ); + print( b_Vector4, "set Vector4 with floats" ); + print( c_Vector4, "set Vector4 with floats" ); + print( d_Vector4, "set Vector4 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Point3 = Point3( rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + print( a_Point3, "set Point3 with floats" ); + print( b_Point3, "set Point3 with floats" ); + print( c_Point3, "set Point3 with floats" ); + print( d_Point3, "set Point3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Quat, "set Quat with floats" ); + print( b_Quat, "set Quat with floats" ); + print( c_Quat, "set Quat with floats" ); + print( d_Quat, "set Quat with floats" ); + a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 ); + b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 ); + print( a_Matrix3, "set Matrix3 columns" ); + print( b_Matrix3, "set Matrix3 columns" ); + a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 ); + b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 ); + print( a_Matrix4, "set Matrix4 columns" ); + print( b_Matrix4, "set Matrix4 columns" ); + a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 ); + b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 ); + print( a_Transform3, "set Transform3 columns" ); + print( b_Transform3, "set Transform3 columns" ); + print( ( a_Matrix4 + b_Matrix4 ), "Matrix4 + Matrix4" ); + print( ( a_Matrix4 - b_Matrix4 ), "Matrix4 - Matrix4" ); + print( ( -a_Matrix4 ), "-Matrix4" ); + print( ( a_Matrix4 * randfloat() ), "Matrix4 * float" ); + print( ( randfloat() * a_Matrix4 ), "float * Matrix4" ); + print( ( a_Matrix4 * a_Vector4 ), "Matrix4 * Vector4" ); + print( ( a_Matrix4 * a_Vector3 ), "Matrix4 * Vector3" ); + print( ( a_Matrix4 * a_Point3 ), "Matrix4 * Point3" ); + print( ( a_Matrix4 * b_Matrix4 ), "Matrix4 * Matrix4" ); + print( ( a_Matrix4 * b_Transform3 ), "Matrix4 * Transform3" ); +} + +void +Transform3_methods_test() +{ + Matrix3 a_Matrix3, b_Matrix3; + Matrix4 a_Matrix4, b_Matrix4; + Transform3 a_Transform3, b_Transform3; + Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; + Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; + Point3 a_Point3, b_Point3, c_Point3, d_Point3; + Quat a_Quat, b_Quat, c_Quat, d_Quat; + vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + print( a_Vector3, "set Vector3 with floats" ); + print( b_Vector3, "set Vector3 with floats" ); + print( c_Vector3, "set Vector3 with floats" ); + print( d_Vector3, "set Vector3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Vector4, "set Vector4 with floats" ); + print( b_Vector4, "set Vector4 with floats" ); + print( c_Vector4, "set Vector4 with floats" ); + print( d_Vector4, "set Vector4 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Point3 = Point3( rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + print( a_Point3, "set Point3 with floats" ); + print( b_Point3, "set Point3 with floats" ); + print( c_Point3, "set Point3 with floats" ); + print( d_Point3, "set Point3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Quat, "set Quat with floats" ); + print( b_Quat, "set Quat with floats" ); + print( c_Quat, "set Quat with floats" ); + print( d_Quat, "set Quat with floats" ); + a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 ); + b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 ); + print( a_Matrix3, "set Matrix3 columns" ); + print( b_Matrix3, "set Matrix3 columns" ); + a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 ); + b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 ); + print( a_Matrix4, "set Matrix4 columns" ); + print( b_Matrix4, "set Matrix4 columns" ); + a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 ); + b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 ); + print( a_Transform3, "set Transform3 columns" ); + print( b_Transform3, "set Transform3 columns" ); + print( ( a_Transform3 * a_Vector3 ), "Transform3 * Vector3" ); + print( ( a_Transform3 * a_Point3 ), "Transform3 * Point3" ); + print( ( a_Transform3 * b_Transform3 ), "Transform3 * Transform3" ); +} + +int main() +{ + int i; + printf("\n __begin__ \n"); + for ( i = 0; i < 2; i++ ) { + Matrix3_methods_test(); + Matrix4_methods_test(); + Transform3_methods_test(); + } + printf("\n __end__ \n"); + return 0; +} diff --git a/vectormathlibrary/tests/test4_aos_c.c b/vectormathlibrary/tests/test4_aos_c.c new file mode 100644 index 000000000..c43051633 --- /dev/null +++ b/vectormathlibrary/tests/test4_aos_c.c @@ -0,0 +1,567 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _VECTORMATH_AOS_TEST + +#include "vectormath_aos.h" +#include "test.h" + +int iteration = 0; + +void +Matrix3_methods_test() +{ + VmathMatrix3 a_Matrix3, b_Matrix3; + VmathMatrix4 a_Matrix4, b_Matrix4; + VmathTransform3 a_Transform3, b_Transform3; + VmathMatrix3 tmpM3_0, tmpM3_1, tmpM3_2, tmpM3_3, tmpM3_4, tmpM3_5, tmpM3_6, tmpM3_7, tmpM3_8, tmpM3_9, tmpM3_10; + VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; + VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; + VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3; + VmathQuat a_Quat, b_Quat, c_Quat, d_Quat; + VmathVector4 tmpV4; + VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7, tmpV3_8; + float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad; + // set a pad value to detect invalid use of padding. + // this will be nan for scalar/ppu implementations, max. float for spu + union { float f; unsigned int u; } tmp; + tmp.u = 0x7fffffff; + pad = tmp.f; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad ); + vmathV4GetXYZ( &a_Vector3, &tmpV4 ); + vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad ); + vmathV4GetXYZ( &b_Vector3, &tmpV4 ); + vmathV4MakeFromV3Scalar( &tmpV4, &c_Vector3, pad ); + vmathV4GetXYZ( &c_Vector3, &tmpV4 ); + vmathV4MakeFromV3Scalar( &tmpV4, &d_Vector3, pad ); + vmathV4GetXYZ( &d_Vector3, &tmpV4 ); + vmathV3Prints( &a_Vector3, "set Vector3 with floats" ); + vmathV3Prints( &b_Vector3, "set Vector3 with floats" ); + vmathV3Prints( &c_Vector3, "set Vector3 with floats" ); + vmathV3Prints( &d_Vector3, "set Vector3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathV4Prints( &a_Vector4, "set Vector4 with floats" ); + vmathV4Prints( &b_Vector4, "set Vector4 with floats" ); + vmathV4Prints( &c_Vector4, "set Vector4 with floats" ); + vmathV4Prints( &d_Vector4, "set Vector4 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); + vmathV3MakeFromP3( &tmpV3_0, &a_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad ); + vmathV4GetXYZ( &tmpV3_1, &tmpV4 ); + vmathP3MakeFromV3( &a_Point3, &tmpV3_1 ); + vmathV3MakeFromP3( &tmpV3_2, &b_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad ); + vmathV4GetXYZ( &tmpV3_3, &tmpV4 ); + vmathP3MakeFromV3( &b_Point3, &tmpV3_3 ); + vmathV3MakeFromP3( &tmpV3_4, &c_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_4, pad ); + vmathV4GetXYZ( &tmpV3_5, &tmpV4 ); + vmathP3MakeFromV3( &c_Point3, &tmpV3_5 ); + vmathV3MakeFromP3( &tmpV3_6, &d_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_6, pad ); + vmathV4GetXYZ( &tmpV3_7, &tmpV4 ); + vmathP3MakeFromV3( &d_Point3, &tmpV3_7 ); + vmathP3Prints( &a_Point3, "set Point3 with floats" ); + vmathP3Prints( &b_Point3, "set Point3 with floats" ); + vmathP3Prints( &c_Point3, "set Point3 with floats" ); + vmathP3Prints( &d_Point3, "set Point3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathQPrints( &a_Quat, "set Quat with floats" ); + vmathQPrints( &b_Quat, "set Quat with floats" ); + vmathQPrints( &c_Quat, "set Quat with floats" ); + vmathQPrints( &d_Quat, "set Quat with floats" ); + vmathM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 ); + vmathM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 ); + vmathM3Prints( &a_Matrix3, "set Matrix3 columns" ); + vmathM3Prints( &b_Matrix3, "set Matrix3 columns" ); + vmathM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 ); + vmathM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 ); + vmathM4Prints( &a_Matrix4, "set Matrix4 columns" ); + vmathM4Prints( &b_Matrix4, "set Matrix4 columns" ); + vmathT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 ); + vmathT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 ); + vmathT3Prints( &a_Transform3, "set Transform3 columns" ); + vmathT3Prints( &b_Transform3, "set Transform3 columns" ); + vmathM3AppendScale( &tmpM3_0, &a_Matrix3, &a_Vector3 ); + vmathM3Prints( &tmpM3_0, "appendScale Matrix3 Vector3" ); + vmathM3PrependScale( &tmpM3_1, &a_Vector3, &a_Matrix3 ); + vmathM3Prints( &tmpM3_1, "prependScale Vector3 Matrix3" ); + vmathM3MulPerElem( &tmpM3_2, &a_Matrix3, &b_Matrix3 ); + vmathM3Prints( &tmpM3_2, "mulPerElem Matrix3" ); + vmathM3AbsPerElem( &tmpM3_3, &a_Matrix3 ); + vmathM3Prints( &tmpM3_3, "absPerElem Matrix3" ); + vmathM3Transpose( &tmpM3_4, &a_Matrix3 ); + vmathM3Prints( &tmpM3_4, "transpose Matrix3" ); + vmathM3Inverse( &tmpM3_5, &a_Matrix3 ); + vmathM3Prints( &tmpM3_5, "inverse Matrix3" ); + vmathM3Inverse( &tmpM3_6, &a_Matrix3 ); + vmathM3Mul( &tmpM3_7, &tmpM3_6, &a_Matrix3 ); + vmathM3Prints( &tmpM3_7, "inverse(Matrix3) * Matrix3" ); + printf("%f\n", getfloat(vmathM3Determinant( &a_Matrix3 )) ); + vmathV3Outer( &tmpM3_8, &a_Vector3, &b_Vector3 ); + vmathM3Prints( &tmpM3_8, "outer Vector3" ); + vmathV3RowMul( &tmpV3_8, &a_Vector3, &a_Matrix3 ); + vmathV3Prints( &tmpV3_8, "rowMul Vector3" ); + vmathV3CrossMatrix( &tmpM3_9, &a_Vector3 ); + vmathM3Prints( &tmpM3_9, "crossMatrix" ); + vmathV3CrossMatrixMul( &tmpM3_10, &a_Vector3, &a_Matrix3 ); + vmathM3Prints( &tmpM3_10, "crossMatrixMul" ); +} + +void +Matrix4_methods_test() +{ + VmathMatrix3 a_Matrix3, b_Matrix3; + VmathMatrix4 a_Matrix4, b_Matrix4; + VmathTransform3 a_Transform3, b_Transform3; + VmathMatrix4 tmpM4_0, tmpM4_1, tmpM4_2, tmpM4_3, tmpM4_4, tmpM4_5, tmpM4_6, tmpM4_7; + VmathMatrix3 tmpM3_0; + VmathMatrix4 tmpM4_8, tmpM4_9, tmpM4_10, tmpM4_11, tmpM4_12, tmpM4_13, tmpM4_14; + VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; + VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; + VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3; + VmathQuat a_Quat, b_Quat, c_Quat, d_Quat; + VmathVector4 tmpV4; + VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7; + VmathVector4 tmpV4_0; + VmathQuat tmpQ_0; + float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad; + // set a pad value to detect invalid use of padding. + // this will be nan for scalar/ppu implementations, max. float for spu + union { float f; unsigned int u; } tmp; + tmp.u = 0x7fffffff; + pad = tmp.f; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad ); + vmathV4GetXYZ( &a_Vector3, &tmpV4 ); + vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad ); + vmathV4GetXYZ( &b_Vector3, &tmpV4 ); + vmathV4MakeFromV3Scalar( &tmpV4, &c_Vector3, pad ); + vmathV4GetXYZ( &c_Vector3, &tmpV4 ); + vmathV4MakeFromV3Scalar( &tmpV4, &d_Vector3, pad ); + vmathV4GetXYZ( &d_Vector3, &tmpV4 ); + vmathV3Prints( &a_Vector3, "set Vector3 with floats" ); + vmathV3Prints( &b_Vector3, "set Vector3 with floats" ); + vmathV3Prints( &c_Vector3, "set Vector3 with floats" ); + vmathV3Prints( &d_Vector3, "set Vector3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathV4Prints( &a_Vector4, "set Vector4 with floats" ); + vmathV4Prints( &b_Vector4, "set Vector4 with floats" ); + vmathV4Prints( &c_Vector4, "set Vector4 with floats" ); + vmathV4Prints( &d_Vector4, "set Vector4 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); + vmathV3MakeFromP3( &tmpV3_0, &a_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad ); + vmathV4GetXYZ( &tmpV3_1, &tmpV4 ); + vmathP3MakeFromV3( &a_Point3, &tmpV3_1 ); + vmathV3MakeFromP3( &tmpV3_2, &b_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad ); + vmathV4GetXYZ( &tmpV3_3, &tmpV4 ); + vmathP3MakeFromV3( &b_Point3, &tmpV3_3 ); + vmathV3MakeFromP3( &tmpV3_4, &c_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_4, pad ); + vmathV4GetXYZ( &tmpV3_5, &tmpV4 ); + vmathP3MakeFromV3( &c_Point3, &tmpV3_5 ); + vmathV3MakeFromP3( &tmpV3_6, &d_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_6, pad ); + vmathV4GetXYZ( &tmpV3_7, &tmpV4 ); + vmathP3MakeFromV3( &d_Point3, &tmpV3_7 ); + vmathP3Prints( &a_Point3, "set Point3 with floats" ); + vmathP3Prints( &b_Point3, "set Point3 with floats" ); + vmathP3Prints( &c_Point3, "set Point3 with floats" ); + vmathP3Prints( &d_Point3, "set Point3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathQPrints( &a_Quat, "set Quat with floats" ); + vmathQPrints( &b_Quat, "set Quat with floats" ); + vmathQPrints( &c_Quat, "set Quat with floats" ); + vmathQPrints( &d_Quat, "set Quat with floats" ); + vmathM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 ); + vmathM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 ); + vmathM3Prints( &a_Matrix3, "set Matrix3 columns" ); + vmathM3Prints( &b_Matrix3, "set Matrix3 columns" ); + vmathM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 ); + vmathM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 ); + vmathM4Prints( &a_Matrix4, "set Matrix4 columns" ); + vmathM4Prints( &b_Matrix4, "set Matrix4 columns" ); + vmathT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 ); + vmathT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 ); + vmathT3Prints( &a_Transform3, "set Transform3 columns" ); + vmathT3Prints( &b_Transform3, "set Transform3 columns" ); + vmathM4AppendScale( &tmpM4_0, &a_Matrix4, &a_Vector3 ); + vmathM4Prints( &tmpM4_0, "appendScale Matrix4 Vector3" ); + vmathM4PrependScale( &tmpM4_1, &a_Vector3, &a_Matrix4 ); + vmathM4Prints( &tmpM4_1, "prependScale Vector3 Matrix4" ); + vmathM4MulPerElem( &tmpM4_2, &a_Matrix4, &b_Matrix4 ); + vmathM4Prints( &tmpM4_2, "mulPerElem Matrix4" ); + vmathM4AbsPerElem( &tmpM4_3, &a_Matrix4 ); + vmathM4Prints( &tmpM4_3, "absPerElem Matrix4" ); + vmathM4Transpose( &tmpM4_4, &a_Matrix4 ); + vmathM4Prints( &tmpM4_4, "transpose Matrix4" ); + vmathM4Inverse( &tmpM4_5, &a_Matrix4 ); + vmathM4Prints( &tmpM4_5, "inverse Matrix4" ); + vmathM4Inverse( &tmpM4_6, &a_Matrix4 ); + vmathM4Mul( &tmpM4_7, &tmpM4_6, &a_Matrix4 ); + vmathM4Prints( &tmpM4_7, "inverse(Matrix4) * Matrix4" ); + vmathV4MakeFromElems( &tmpV4_0, 0.0f, 0.0f, 0.0f, 1.0f ); + vmathM4SetRow( &a_Matrix4, 3, &tmpV4_0 ); + vmathQNormalize( &tmpQ_0, &a_Quat ); + vmathM3MakeFromQ( &tmpM3_0, &tmpQ_0 ); + vmathM4SetUpper3x3( &a_Matrix4, &tmpM3_0 ); + vmathM4AffineInverse( &tmpM4_8, &a_Matrix4 ); + vmathM4Prints( &tmpM4_8, "affineInverse Matrix4" ); + vmathM4AffineInverse( &tmpM4_9, &a_Matrix4 ); + vmathM4Mul( &tmpM4_10, &tmpM4_9, &a_Matrix4 ); + vmathM4Prints( &tmpM4_10, "affineInverse(Matrix4) * Matrix4" ); + vmathM4OrthoInverse( &tmpM4_11, &a_Matrix4 ); + vmathM4Prints( &tmpM4_11, "orthoInverse Matrix4" ); + vmathM4OrthoInverse( &tmpM4_12, &a_Matrix4 ); + vmathM4Mul( &tmpM4_13, &tmpM4_12, &a_Matrix4 ); + vmathM4Prints( &tmpM4_13, "orthoInverse(Matrix4) * Matrix4" ); + printf("%f\n", getfloat(vmathM4Determinant( &a_Matrix4 )) ); + vmathV4Outer( &tmpM4_14, &a_Vector4, &b_Vector4 ); + vmathM4Prints( &tmpM4_14, "outer Vector4" ); +} + +void +Transform3_methods_test() +{ + VmathMatrix3 a_Matrix3, b_Matrix3; + VmathMatrix4 a_Matrix4, b_Matrix4; + VmathTransform3 a_Transform3, b_Transform3, tmpT3_0, tmpT3_1, tmpT3_2, tmpT3_3, tmpT3_4, tmpT3_5, tmpT3_6; + VmathMatrix3 tmpM3_0; + VmathTransform3 tmpT3_7, tmpT3_8, tmpT3_9; + VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; + VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; + VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3; + VmathQuat a_Quat, b_Quat, c_Quat, d_Quat; + VmathVector4 tmpV4; + VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7; + VmathQuat tmpQ_0; + float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad; + // set a pad value to detect invalid use of padding. + // this will be nan for scalar/ppu implementations, max. float for spu + union { float f; unsigned int u; } tmp; + tmp.u = 0x7fffffff; + pad = tmp.f; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad ); + vmathV4GetXYZ( &a_Vector3, &tmpV4 ); + vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad ); + vmathV4GetXYZ( &b_Vector3, &tmpV4 ); + vmathV4MakeFromV3Scalar( &tmpV4, &c_Vector3, pad ); + vmathV4GetXYZ( &c_Vector3, &tmpV4 ); + vmathV4MakeFromV3Scalar( &tmpV4, &d_Vector3, pad ); + vmathV4GetXYZ( &d_Vector3, &tmpV4 ); + vmathV3Prints( &a_Vector3, "set Vector3 with floats" ); + vmathV3Prints( &b_Vector3, "set Vector3 with floats" ); + vmathV3Prints( &c_Vector3, "set Vector3 with floats" ); + vmathV3Prints( &d_Vector3, "set Vector3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathV4Prints( &a_Vector4, "set Vector4 with floats" ); + vmathV4Prints( &b_Vector4, "set Vector4 with floats" ); + vmathV4Prints( &c_Vector4, "set Vector4 with floats" ); + vmathV4Prints( &d_Vector4, "set Vector4 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); + vmathV3MakeFromP3( &tmpV3_0, &a_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad ); + vmathV4GetXYZ( &tmpV3_1, &tmpV4 ); + vmathP3MakeFromV3( &a_Point3, &tmpV3_1 ); + vmathV3MakeFromP3( &tmpV3_2, &b_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad ); + vmathV4GetXYZ( &tmpV3_3, &tmpV4 ); + vmathP3MakeFromV3( &b_Point3, &tmpV3_3 ); + vmathV3MakeFromP3( &tmpV3_4, &c_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_4, pad ); + vmathV4GetXYZ( &tmpV3_5, &tmpV4 ); + vmathP3MakeFromV3( &c_Point3, &tmpV3_5 ); + vmathV3MakeFromP3( &tmpV3_6, &d_Point3 ); + vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_6, pad ); + vmathV4GetXYZ( &tmpV3_7, &tmpV4 ); + vmathP3MakeFromV3( &d_Point3, &tmpV3_7 ); + vmathP3Prints( &a_Point3, "set Point3 with floats" ); + vmathP3Prints( &b_Point3, "set Point3 with floats" ); + vmathP3Prints( &c_Point3, "set Point3 with floats" ); + vmathP3Prints( &d_Point3, "set Point3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathQPrints( &a_Quat, "set Quat with floats" ); + vmathQPrints( &b_Quat, "set Quat with floats" ); + vmathQPrints( &c_Quat, "set Quat with floats" ); + vmathQPrints( &d_Quat, "set Quat with floats" ); + vmathM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 ); + vmathM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 ); + vmathM3Prints( &a_Matrix3, "set Matrix3 columns" ); + vmathM3Prints( &b_Matrix3, "set Matrix3 columns" ); + vmathM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 ); + vmathM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 ); + vmathM4Prints( &a_Matrix4, "set Matrix4 columns" ); + vmathM4Prints( &b_Matrix4, "set Matrix4 columns" ); + vmathT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 ); + vmathT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 ); + vmathT3Prints( &a_Transform3, "set Transform3 columns" ); + vmathT3Prints( &b_Transform3, "set Transform3 columns" ); + vmathT3AppendScale( &tmpT3_0, &a_Transform3, &a_Vector3 ); + vmathT3Prints( &tmpT3_0, "appendScale Transform3 Vector3" ); + vmathT3PrependScale( &tmpT3_1, &a_Vector3, &a_Transform3 ); + vmathT3Prints( &tmpT3_1, "prependScale Vector3 Transform3" ); + vmathT3MulPerElem( &tmpT3_2, &a_Transform3, &b_Transform3 ); + vmathT3Prints( &tmpT3_2, "mulPerElem Transform3" ); + vmathT3AbsPerElem( &tmpT3_3, &a_Transform3 ); + vmathT3Prints( &tmpT3_3, "absPerElem Transform3" ); + vmathT3Inverse( &tmpT3_4, &a_Transform3 ); + vmathT3Prints( &tmpT3_4, "inverse Transform3" ); + vmathT3Inverse( &tmpT3_5, &a_Transform3 ); + vmathT3Mul( &tmpT3_6, &tmpT3_5, &a_Transform3 ); + vmathT3Prints( &tmpT3_6, "inverse(Transform3) * Transform3" ); + vmathQNormalize( &tmpQ_0, &a_Quat ); + vmathM3MakeFromQ( &tmpM3_0, &tmpQ_0 ); + vmathT3SetUpper3x3( &a_Transform3, &tmpM3_0 ); + vmathT3OrthoInverse( &tmpT3_7, &a_Transform3 ); + vmathT3Prints( &tmpT3_7, "orthoInverse Transform3" ); + vmathT3OrthoInverse( &tmpT3_8, &a_Transform3 ); + vmathT3Mul( &tmpT3_9, &tmpT3_8, &a_Transform3 ); + vmathT3Prints( &tmpT3_9, "orthoInverse(Transform3) * Transform3" ); +} + +int main() +{ + int i; + printf("\n __begin__ \n"); + for ( i = 0; i < 2; i++ ) { + Matrix3_methods_test(); + Matrix4_methods_test(); + Transform3_methods_test(); + } + printf("\n __end__ \n"); + return 0; +} diff --git a/vectormathlibrary/tests/test4_aos_cpp.cpp b/vectormathlibrary/tests/test4_aos_cpp.cpp new file mode 100644 index 000000000..602df6321 --- /dev/null +++ b/vectormathlibrary/tests/test4_aos_cpp.cpp @@ -0,0 +1,492 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _VECTORMATH_AOS_TEST + +#include "vectormath_aos.h" +#include "test.h" + +int iteration = 0; + +using namespace Vectormath; +using namespace Vectormath::Aos; + +void +Matrix3_methods_test() +{ + Matrix3 a_Matrix3, b_Matrix3; + Matrix4 a_Matrix4, b_Matrix4; + Transform3 a_Transform3, b_Transform3; + Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; + Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; + Point3 a_Point3, b_Point3, c_Point3, d_Point3; + Quat a_Quat, b_Quat, c_Quat, d_Quat; + Vector4 tmpV4; + float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad; + // set a pad value to detect invalid use of padding. + // this will be nan for scalar/ppu implementations, max. float for spu + union { float f; unsigned int u; } tmp; + tmp.u = 0x7fffffff; + pad = tmp.f; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + tmpV4 = Vector4( a_Vector3, pad ); + a_Vector3 = tmpV4.getXYZ( ); + tmpV4 = Vector4( b_Vector3, pad ); + b_Vector3 = tmpV4.getXYZ( ); + tmpV4 = Vector4( c_Vector3, pad ); + c_Vector3 = tmpV4.getXYZ( ); + tmpV4 = Vector4( d_Vector3, pad ); + d_Vector3 = tmpV4.getXYZ( ); + print( a_Vector3, "set Vector3 with floats" ); + print( b_Vector3, "set Vector3 with floats" ); + print( c_Vector3, "set Vector3 with floats" ); + print( d_Vector3, "set Vector3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Vector4, "set Vector4 with floats" ); + print( b_Vector4, "set Vector4 with floats" ); + print( c_Vector4, "set Vector4 with floats" ); + print( d_Vector4, "set Vector4 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Point3 = Point3( rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + tmpV4 = Vector4( Vector3( a_Point3 ), pad ); + a_Point3 = Point3( tmpV4.getXYZ( ) ); + tmpV4 = Vector4( Vector3( b_Point3 ), pad ); + b_Point3 = Point3( tmpV4.getXYZ( ) ); + tmpV4 = Vector4( Vector3( c_Point3 ), pad ); + c_Point3 = Point3( tmpV4.getXYZ( ) ); + tmpV4 = Vector4( Vector3( d_Point3 ), pad ); + d_Point3 = Point3( tmpV4.getXYZ( ) ); + print( a_Point3, "set Point3 with floats" ); + print( b_Point3, "set Point3 with floats" ); + print( c_Point3, "set Point3 with floats" ); + print( d_Point3, "set Point3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Quat, "set Quat with floats" ); + print( b_Quat, "set Quat with floats" ); + print( c_Quat, "set Quat with floats" ); + print( d_Quat, "set Quat with floats" ); + a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 ); + b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 ); + print( a_Matrix3, "set Matrix3 columns" ); + print( b_Matrix3, "set Matrix3 columns" ); + a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 ); + b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 ); + print( a_Matrix4, "set Matrix4 columns" ); + print( b_Matrix4, "set Matrix4 columns" ); + a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 ); + b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 ); + print( a_Transform3, "set Transform3 columns" ); + print( b_Transform3, "set Transform3 columns" ); + print( appendScale( a_Matrix3, a_Vector3 ), "appendScale Matrix3 Vector3" ); + print( prependScale( a_Vector3, a_Matrix3 ), "prependScale Vector3 Matrix3" ); + print( mulPerElem( a_Matrix3, b_Matrix3 ), "mulPerElem Matrix3" ); + print( absPerElem( a_Matrix3 ), "absPerElem Matrix3" ); + print( transpose( a_Matrix3 ), "transpose Matrix3" ); + print( inverse( a_Matrix3 ), "inverse Matrix3" ); + print( ( inverse( a_Matrix3 ) * a_Matrix3 ), "inverse(Matrix3) * Matrix3" ); + printf("%f\n", getfloat(determinant( a_Matrix3 )) ); + print( outer( a_Vector3, b_Vector3 ), "outer Vector3" ); + print( rowMul( a_Vector3, a_Matrix3 ), "rowMul Vector3" ); + print( crossMatrix( a_Vector3 ), "crossMatrix" ); + print( crossMatrixMul( a_Vector3, a_Matrix3 ), "crossMatrixMul" ); +} + +void +Matrix4_methods_test() +{ + Matrix3 a_Matrix3, b_Matrix3; + Matrix4 a_Matrix4, b_Matrix4; + Transform3 a_Transform3, b_Transform3; + Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; + Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; + Point3 a_Point3, b_Point3, c_Point3, d_Point3; + Quat a_Quat, b_Quat, c_Quat, d_Quat; + Vector4 tmpV4; + float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad; + // set a pad value to detect invalid use of padding. + // this will be nan for scalar/ppu implementations, max. float for spu + union { float f; unsigned int u; } tmp; + tmp.u = 0x7fffffff; + pad = tmp.f; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + tmpV4 = Vector4( a_Vector3, pad ); + a_Vector3 = tmpV4.getXYZ( ); + tmpV4 = Vector4( b_Vector3, pad ); + b_Vector3 = tmpV4.getXYZ( ); + tmpV4 = Vector4( c_Vector3, pad ); + c_Vector3 = tmpV4.getXYZ( ); + tmpV4 = Vector4( d_Vector3, pad ); + d_Vector3 = tmpV4.getXYZ( ); + print( a_Vector3, "set Vector3 with floats" ); + print( b_Vector3, "set Vector3 with floats" ); + print( c_Vector3, "set Vector3 with floats" ); + print( d_Vector3, "set Vector3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Vector4, "set Vector4 with floats" ); + print( b_Vector4, "set Vector4 with floats" ); + print( c_Vector4, "set Vector4 with floats" ); + print( d_Vector4, "set Vector4 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Point3 = Point3( rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + tmpV4 = Vector4( Vector3( a_Point3 ), pad ); + a_Point3 = Point3( tmpV4.getXYZ( ) ); + tmpV4 = Vector4( Vector3( b_Point3 ), pad ); + b_Point3 = Point3( tmpV4.getXYZ( ) ); + tmpV4 = Vector4( Vector3( c_Point3 ), pad ); + c_Point3 = Point3( tmpV4.getXYZ( ) ); + tmpV4 = Vector4( Vector3( d_Point3 ), pad ); + d_Point3 = Point3( tmpV4.getXYZ( ) ); + print( a_Point3, "set Point3 with floats" ); + print( b_Point3, "set Point3 with floats" ); + print( c_Point3, "set Point3 with floats" ); + print( d_Point3, "set Point3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Quat, "set Quat with floats" ); + print( b_Quat, "set Quat with floats" ); + print( c_Quat, "set Quat with floats" ); + print( d_Quat, "set Quat with floats" ); + a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 ); + b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 ); + print( a_Matrix3, "set Matrix3 columns" ); + print( b_Matrix3, "set Matrix3 columns" ); + a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 ); + b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 ); + print( a_Matrix4, "set Matrix4 columns" ); + print( b_Matrix4, "set Matrix4 columns" ); + a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 ); + b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 ); + print( a_Transform3, "set Transform3 columns" ); + print( b_Transform3, "set Transform3 columns" ); + print( appendScale( a_Matrix4, a_Vector3 ), "appendScale Matrix4 Vector3" ); + print( prependScale( a_Vector3, a_Matrix4 ), "prependScale Vector3 Matrix4" ); + print( mulPerElem( a_Matrix4, b_Matrix4 ), "mulPerElem Matrix4" ); + print( absPerElem( a_Matrix4 ), "absPerElem Matrix4" ); + print( transpose( a_Matrix4 ), "transpose Matrix4" ); + print( inverse( a_Matrix4 ), "inverse Matrix4" ); + print( ( inverse( a_Matrix4 ) * a_Matrix4 ), "inverse(Matrix4) * Matrix4" ); + a_Matrix4.setRow( 3, Vector4( 0.0f, 0.0f, 0.0f, 1.0f ) ); + a_Matrix4.setUpper3x3( Matrix3( normalize( a_Quat ) ) ); + print( affineInverse( a_Matrix4 ), "affineInverse Matrix4" ); + print( ( affineInverse( a_Matrix4 ) * a_Matrix4 ), "affineInverse(Matrix4) * Matrix4" ); + print( orthoInverse( a_Matrix4 ), "orthoInverse Matrix4" ); + print( ( orthoInverse( a_Matrix4 ) * a_Matrix4 ), "orthoInverse(Matrix4) * Matrix4" ); + printf("%f\n", getfloat(determinant( a_Matrix4 )) ); + print( outer( a_Vector4, b_Vector4 ), "outer Vector4" ); +} + +void +Transform3_methods_test() +{ + Matrix3 a_Matrix3, b_Matrix3; + Matrix4 a_Matrix4, b_Matrix4; + Transform3 a_Transform3, b_Transform3; + Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; + Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; + Point3 a_Point3, b_Point3, c_Point3, d_Point3; + Quat a_Quat, b_Quat, c_Quat, d_Quat; + Vector4 tmpV4; + float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad; + // set a pad value to detect invalid use of padding. + // this will be nan for scalar/ppu implementations, max. float for spu + union { float f; unsigned int u; } tmp; + tmp.u = 0x7fffffff; + pad = tmp.f; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + tmpV4 = Vector4( a_Vector3, pad ); + a_Vector3 = tmpV4.getXYZ( ); + tmpV4 = Vector4( b_Vector3, pad ); + b_Vector3 = tmpV4.getXYZ( ); + tmpV4 = Vector4( c_Vector3, pad ); + c_Vector3 = tmpV4.getXYZ( ); + tmpV4 = Vector4( d_Vector3, pad ); + d_Vector3 = tmpV4.getXYZ( ); + print( a_Vector3, "set Vector3 with floats" ); + print( b_Vector3, "set Vector3 with floats" ); + print( c_Vector3, "set Vector3 with floats" ); + print( d_Vector3, "set Vector3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Vector4, "set Vector4 with floats" ); + print( b_Vector4, "set Vector4 with floats" ); + print( c_Vector4, "set Vector4 with floats" ); + print( d_Vector4, "set Vector4 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Point3 = Point3( rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + tmpV4 = Vector4( Vector3( a_Point3 ), pad ); + a_Point3 = Point3( tmpV4.getXYZ( ) ); + tmpV4 = Vector4( Vector3( b_Point3 ), pad ); + b_Point3 = Point3( tmpV4.getXYZ( ) ); + tmpV4 = Vector4( Vector3( c_Point3 ), pad ); + c_Point3 = Point3( tmpV4.getXYZ( ) ); + tmpV4 = Vector4( Vector3( d_Point3 ), pad ); + d_Point3 = Point3( tmpV4.getXYZ( ) ); + print( a_Point3, "set Point3 with floats" ); + print( b_Point3, "set Point3 with floats" ); + print( c_Point3, "set Point3 with floats" ); + print( d_Point3, "set Point3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Quat, "set Quat with floats" ); + print( b_Quat, "set Quat with floats" ); + print( c_Quat, "set Quat with floats" ); + print( d_Quat, "set Quat with floats" ); + a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 ); + b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 ); + print( a_Matrix3, "set Matrix3 columns" ); + print( b_Matrix3, "set Matrix3 columns" ); + a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 ); + b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 ); + print( a_Matrix4, "set Matrix4 columns" ); + print( b_Matrix4, "set Matrix4 columns" ); + a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 ); + b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 ); + print( a_Transform3, "set Transform3 columns" ); + print( b_Transform3, "set Transform3 columns" ); + print( appendScale( a_Transform3, a_Vector3 ), "appendScale Transform3 Vector3" ); + print( prependScale( a_Vector3, a_Transform3 ), "prependScale Vector3 Transform3" ); + print( mulPerElem( a_Transform3, b_Transform3 ), "mulPerElem Transform3" ); + print( absPerElem( a_Transform3 ), "absPerElem Transform3" ); + print( inverse( a_Transform3 ), "inverse Transform3" ); + print( ( inverse( a_Transform3 ) * a_Transform3 ), "inverse(Transform3) * Transform3" ); + a_Transform3.setUpper3x3( Matrix3( normalize( a_Quat ) ) ); + print( orthoInverse( a_Transform3 ), "orthoInverse Transform3" ); + print( ( orthoInverse( a_Transform3 ) * a_Transform3 ), "orthoInverse(Transform3) * Transform3" ); +} + +int main() +{ + int i; + printf("\n __begin__ \n"); + for ( i = 0; i < 2; i++ ) { + Matrix3_methods_test(); + Matrix4_methods_test(); + Transform3_methods_test(); + } + printf("\n __end__ \n"); + return 0; +} diff --git a/vectormathlibrary/tests/test4_soa_c.c b/vectormathlibrary/tests/test4_soa_c.c new file mode 100644 index 000000000..40ad3e63c --- /dev/null +++ b/vectormathlibrary/tests/test4_soa_c.c @@ -0,0 +1,474 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _VECTORMATH_SOA_TEST + +#include "vectormath_soa.h" +#include "test.h" + +int iteration = 0; + +void +Matrix3_methods_test() +{ + VmathSoaMatrix3 a_Matrix3, b_Matrix3; + VmathSoaMatrix4 a_Matrix4, b_Matrix4; + VmathSoaTransform3 a_Transform3, b_Transform3; + VmathSoaMatrix3 tmpM3_0, tmpM3_1, tmpM3_2, tmpM3_3, tmpM3_4, tmpM3_5, tmpM3_6, tmpM3_7, tmpM3_8, tmpM3_9, tmpM3_10; + VmathSoaVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; + VmathSoaVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; + VmathSoaPoint3 a_Point3, b_Point3, c_Point3, d_Point3; + VmathSoaQuat a_Quat, b_Quat, c_Quat, d_Quat; + VmathSoaVector3 tmpV3_0; + vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); + vmathSoaV3Prints( &a_Vector3, "set Vector3 with floats" ); + vmathSoaV3Prints( &b_Vector3, "set Vector3 with floats" ); + vmathSoaV3Prints( &c_Vector3, "set Vector3 with floats" ); + vmathSoaV3Prints( &d_Vector3, "set Vector3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathSoaV4Prints( &a_Vector4, "set Vector4 with floats" ); + vmathSoaV4Prints( &b_Vector4, "set Vector4 with floats" ); + vmathSoaV4Prints( &c_Vector4, "set Vector4 with floats" ); + vmathSoaV4Prints( &d_Vector4, "set Vector4 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); + vmathSoaP3Prints( &a_Point3, "set Point3 with floats" ); + vmathSoaP3Prints( &b_Point3, "set Point3 with floats" ); + vmathSoaP3Prints( &c_Point3, "set Point3 with floats" ); + vmathSoaP3Prints( &d_Point3, "set Point3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathSoaQPrints( &a_Quat, "set Quat with floats" ); + vmathSoaQPrints( &b_Quat, "set Quat with floats" ); + vmathSoaQPrints( &c_Quat, "set Quat with floats" ); + vmathSoaQPrints( &d_Quat, "set Quat with floats" ); + vmathSoaM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 ); + vmathSoaM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 ); + vmathSoaM3Prints( &a_Matrix3, "set Matrix3 columns" ); + vmathSoaM3Prints( &b_Matrix3, "set Matrix3 columns" ); + vmathSoaM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 ); + vmathSoaM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 ); + vmathSoaM4Prints( &a_Matrix4, "set Matrix4 columns" ); + vmathSoaM4Prints( &b_Matrix4, "set Matrix4 columns" ); + vmathSoaT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 ); + vmathSoaT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 ); + vmathSoaT3Prints( &a_Transform3, "set Transform3 columns" ); + vmathSoaT3Prints( &b_Transform3, "set Transform3 columns" ); + vmathSoaM3AppendScale( &tmpM3_0, &a_Matrix3, &a_Vector3 ); + vmathSoaM3Prints( &tmpM3_0, "appendScale Matrix3 Vector3" ); + vmathSoaM3PrependScale( &tmpM3_1, &a_Vector3, &a_Matrix3 ); + vmathSoaM3Prints( &tmpM3_1, "prependScale Vector3 Matrix3" ); + vmathSoaM3MulPerElem( &tmpM3_2, &a_Matrix3, &b_Matrix3 ); + vmathSoaM3Prints( &tmpM3_2, "mulPerElem Matrix3" ); + vmathSoaM3AbsPerElem( &tmpM3_3, &a_Matrix3 ); + vmathSoaM3Prints( &tmpM3_3, "absPerElem Matrix3" ); + vmathSoaM3Transpose( &tmpM3_4, &a_Matrix3 ); + vmathSoaM3Prints( &tmpM3_4, "transpose Matrix3" ); + vmathSoaM3Inverse( &tmpM3_5, &a_Matrix3 ); + vmathSoaM3Prints( &tmpM3_5, "inverse Matrix3" ); + vmathSoaM3Inverse( &tmpM3_6, &a_Matrix3 ); + vmathSoaM3Mul( &tmpM3_7, &tmpM3_6, &a_Matrix3 ); + vmathSoaM3Prints( &tmpM3_7, "inverse(Matrix3) * Matrix3" ); + printf("%f\n", getfloat(vmathSoaM3Determinant( &a_Matrix3 )) ); + vmathSoaV3Outer( &tmpM3_8, &a_Vector3, &b_Vector3 ); + vmathSoaM3Prints( &tmpM3_8, "outer Vector3" ); + vmathSoaV3RowMul( &tmpV3_0, &a_Vector3, &a_Matrix3 ); + vmathSoaV3Prints( &tmpV3_0, "rowMul Vector3" ); + vmathSoaV3CrossMatrix( &tmpM3_9, &a_Vector3 ); + vmathSoaM3Prints( &tmpM3_9, "crossMatrix" ); + vmathSoaV3CrossMatrixMul( &tmpM3_10, &a_Vector3, &a_Matrix3 ); + vmathSoaM3Prints( &tmpM3_10, "crossMatrixMul" ); +} + +void +Matrix4_methods_test() +{ + VmathSoaMatrix3 a_Matrix3, b_Matrix3; + VmathSoaMatrix4 a_Matrix4, b_Matrix4; + VmathSoaTransform3 a_Transform3, b_Transform3; + VmathSoaMatrix4 tmpM4_0, tmpM4_1, tmpM4_2, tmpM4_3, tmpM4_4, tmpM4_5, tmpM4_6, tmpM4_7; + VmathSoaMatrix3 tmpM3_0; + VmathSoaMatrix4 tmpM4_8, tmpM4_9, tmpM4_10, tmpM4_11, tmpM4_12, tmpM4_13, tmpM4_14; + VmathSoaVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; + VmathSoaVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; + VmathSoaPoint3 a_Point3, b_Point3, c_Point3, d_Point3; + VmathSoaQuat a_Quat, b_Quat, c_Quat, d_Quat; + VmathSoaVector4 tmpV4_0; + VmathSoaQuat tmpQ_0; + vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); + vmathSoaV3Prints( &a_Vector3, "set Vector3 with floats" ); + vmathSoaV3Prints( &b_Vector3, "set Vector3 with floats" ); + vmathSoaV3Prints( &c_Vector3, "set Vector3 with floats" ); + vmathSoaV3Prints( &d_Vector3, "set Vector3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathSoaV4Prints( &a_Vector4, "set Vector4 with floats" ); + vmathSoaV4Prints( &b_Vector4, "set Vector4 with floats" ); + vmathSoaV4Prints( &c_Vector4, "set Vector4 with floats" ); + vmathSoaV4Prints( &d_Vector4, "set Vector4 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); + vmathSoaP3Prints( &a_Point3, "set Point3 with floats" ); + vmathSoaP3Prints( &b_Point3, "set Point3 with floats" ); + vmathSoaP3Prints( &c_Point3, "set Point3 with floats" ); + vmathSoaP3Prints( &d_Point3, "set Point3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathSoaQPrints( &a_Quat, "set Quat with floats" ); + vmathSoaQPrints( &b_Quat, "set Quat with floats" ); + vmathSoaQPrints( &c_Quat, "set Quat with floats" ); + vmathSoaQPrints( &d_Quat, "set Quat with floats" ); + vmathSoaM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 ); + vmathSoaM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 ); + vmathSoaM3Prints( &a_Matrix3, "set Matrix3 columns" ); + vmathSoaM3Prints( &b_Matrix3, "set Matrix3 columns" ); + vmathSoaM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 ); + vmathSoaM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 ); + vmathSoaM4Prints( &a_Matrix4, "set Matrix4 columns" ); + vmathSoaM4Prints( &b_Matrix4, "set Matrix4 columns" ); + vmathSoaT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 ); + vmathSoaT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 ); + vmathSoaT3Prints( &a_Transform3, "set Transform3 columns" ); + vmathSoaT3Prints( &b_Transform3, "set Transform3 columns" ); + vmathSoaM4AppendScale( &tmpM4_0, &a_Matrix4, &a_Vector3 ); + vmathSoaM4Prints( &tmpM4_0, "appendScale Matrix4 Vector3" ); + vmathSoaM4PrependScale( &tmpM4_1, &a_Vector3, &a_Matrix4 ); + vmathSoaM4Prints( &tmpM4_1, "prependScale Vector3 Matrix4" ); + vmathSoaM4MulPerElem( &tmpM4_2, &a_Matrix4, &b_Matrix4 ); + vmathSoaM4Prints( &tmpM4_2, "mulPerElem Matrix4" ); + vmathSoaM4AbsPerElem( &tmpM4_3, &a_Matrix4 ); + vmathSoaM4Prints( &tmpM4_3, "absPerElem Matrix4" ); + vmathSoaM4Transpose( &tmpM4_4, &a_Matrix4 ); + vmathSoaM4Prints( &tmpM4_4, "transpose Matrix4" ); + vmathSoaM4Inverse( &tmpM4_5, &a_Matrix4 ); + vmathSoaM4Prints( &tmpM4_5, "inverse Matrix4" ); + vmathSoaM4Inverse( &tmpM4_6, &a_Matrix4 ); + vmathSoaM4Mul( &tmpM4_7, &tmpM4_6, &a_Matrix4 ); + vmathSoaM4Prints( &tmpM4_7, "inverse(Matrix4) * Matrix4" ); + vmathSoaV4MakeFromElems( &tmpV4_0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); + vmathSoaM4SetRow( &a_Matrix4, 3, &tmpV4_0 ); + vmathSoaQNormalize( &tmpQ_0, &a_Quat ); + vmathSoaM3MakeFromQ( &tmpM3_0, &tmpQ_0 ); + vmathSoaM4SetUpper3x3( &a_Matrix4, &tmpM3_0 ); + vmathSoaM4AffineInverse( &tmpM4_8, &a_Matrix4 ); + vmathSoaM4Prints( &tmpM4_8, "affineInverse Matrix4" ); + vmathSoaM4AffineInverse( &tmpM4_9, &a_Matrix4 ); + vmathSoaM4Mul( &tmpM4_10, &tmpM4_9, &a_Matrix4 ); + vmathSoaM4Prints( &tmpM4_10, "affineInverse(Matrix4) * Matrix4" ); + vmathSoaM4OrthoInverse( &tmpM4_11, &a_Matrix4 ); + vmathSoaM4Prints( &tmpM4_11, "orthoInverse Matrix4" ); + vmathSoaM4OrthoInverse( &tmpM4_12, &a_Matrix4 ); + vmathSoaM4Mul( &tmpM4_13, &tmpM4_12, &a_Matrix4 ); + vmathSoaM4Prints( &tmpM4_13, "orthoInverse(Matrix4) * Matrix4" ); + printf("%f\n", getfloat(vmathSoaM4Determinant( &a_Matrix4 )) ); + vmathSoaV4Outer( &tmpM4_14, &a_Vector4, &b_Vector4 ); + vmathSoaM4Prints( &tmpM4_14, "outer Vector4" ); +} + +void +Transform3_methods_test() +{ + VmathSoaMatrix3 a_Matrix3, b_Matrix3; + VmathSoaMatrix4 a_Matrix4, b_Matrix4; + VmathSoaTransform3 a_Transform3, b_Transform3, tmpT3_0, tmpT3_1, tmpT3_2, tmpT3_3, tmpT3_4, tmpT3_5, tmpT3_6; + VmathSoaMatrix3 tmpM3_0; + VmathSoaTransform3 tmpT3_7, tmpT3_8, tmpT3_9; + VmathSoaVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; + VmathSoaVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; + VmathSoaPoint3 a_Point3, b_Point3, c_Point3, d_Point3; + VmathSoaQuat a_Quat, b_Quat, c_Quat, d_Quat, tmpQ_0; + vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); + vmathSoaV3Prints( &a_Vector3, "set Vector3 with floats" ); + vmathSoaV3Prints( &b_Vector3, "set Vector3 with floats" ); + vmathSoaV3Prints( &c_Vector3, "set Vector3 with floats" ); + vmathSoaV3Prints( &d_Vector3, "set Vector3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathSoaV4Prints( &a_Vector4, "set Vector4 with floats" ); + vmathSoaV4Prints( &b_Vector4, "set Vector4 with floats" ); + vmathSoaV4Prints( &c_Vector4, "set Vector4 with floats" ); + vmathSoaV4Prints( &d_Vector4, "set Vector4 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + vmathSoaP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); + vmathSoaP3Prints( &a_Point3, "set Point3 with floats" ); + vmathSoaP3Prints( &b_Point3, "set Point3 with floats" ); + vmathSoaP3Prints( &c_Point3, "set Point3 with floats" ); + vmathSoaP3Prints( &d_Point3, "set Point3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + vmathSoaQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + vmathSoaQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); + vmathSoaQPrints( &a_Quat, "set Quat with floats" ); + vmathSoaQPrints( &b_Quat, "set Quat with floats" ); + vmathSoaQPrints( &c_Quat, "set Quat with floats" ); + vmathSoaQPrints( &d_Quat, "set Quat with floats" ); + vmathSoaM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 ); + vmathSoaM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 ); + vmathSoaM3Prints( &a_Matrix3, "set Matrix3 columns" ); + vmathSoaM3Prints( &b_Matrix3, "set Matrix3 columns" ); + vmathSoaM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 ); + vmathSoaM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 ); + vmathSoaM4Prints( &a_Matrix4, "set Matrix4 columns" ); + vmathSoaM4Prints( &b_Matrix4, "set Matrix4 columns" ); + vmathSoaT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 ); + vmathSoaT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 ); + vmathSoaT3Prints( &a_Transform3, "set Transform3 columns" ); + vmathSoaT3Prints( &b_Transform3, "set Transform3 columns" ); + vmathSoaT3AppendScale( &tmpT3_0, &a_Transform3, &a_Vector3 ); + vmathSoaT3Prints( &tmpT3_0, "appendScale Transform3 Vector3" ); + vmathSoaT3PrependScale( &tmpT3_1, &a_Vector3, &a_Transform3 ); + vmathSoaT3Prints( &tmpT3_1, "prependScale Vector3 Transform3" ); + vmathSoaT3MulPerElem( &tmpT3_2, &a_Transform3, &b_Transform3 ); + vmathSoaT3Prints( &tmpT3_2, "mulPerElem Transform3" ); + vmathSoaT3AbsPerElem( &tmpT3_3, &a_Transform3 ); + vmathSoaT3Prints( &tmpT3_3, "absPerElem Transform3" ); + vmathSoaT3Inverse( &tmpT3_4, &a_Transform3 ); + vmathSoaT3Prints( &tmpT3_4, "inverse Transform3" ); + vmathSoaT3Inverse( &tmpT3_5, &a_Transform3 ); + vmathSoaT3Mul( &tmpT3_6, &tmpT3_5, &a_Transform3 ); + vmathSoaT3Prints( &tmpT3_6, "inverse(Transform3) * Transform3" ); + vmathSoaQNormalize( &tmpQ_0, &a_Quat ); + vmathSoaM3MakeFromQ( &tmpM3_0, &tmpQ_0 ); + vmathSoaT3SetUpper3x3( &a_Transform3, &tmpM3_0 ); + vmathSoaT3OrthoInverse( &tmpT3_7, &a_Transform3 ); + vmathSoaT3Prints( &tmpT3_7, "orthoInverse Transform3" ); + vmathSoaT3OrthoInverse( &tmpT3_8, &a_Transform3 ); + vmathSoaT3Mul( &tmpT3_9, &tmpT3_8, &a_Transform3 ); + vmathSoaT3Prints( &tmpT3_9, "orthoInverse(Transform3) * Transform3" ); +} + +int main() +{ + int i; + printf("\n __begin__ \n"); + for ( i = 0; i < 2; i++ ) { + Matrix3_methods_test(); + Matrix4_methods_test(); + Transform3_methods_test(); + } + printf("\n __end__ \n"); + return 0; +} diff --git a/vectormathlibrary/tests/test4_soa_cpp.cpp b/vectormathlibrary/tests/test4_soa_cpp.cpp new file mode 100644 index 000000000..6b0f95e02 --- /dev/null +++ b/vectormathlibrary/tests/test4_soa_cpp.cpp @@ -0,0 +1,426 @@ +/* + Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. + All rights reserved. + + Redistribution and use in source and binary forms, + with or without modification, are permitted provided that the + following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Sony Computer Entertainment Inc nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _VECTORMATH_SOA_TEST + +#include "vectormath_soa.h" +#include "test.h" + +int iteration = 0; + +using namespace Vectormath; +using namespace Vectormath::Soa; + +void +Matrix3_methods_test() +{ + Matrix3 a_Matrix3, b_Matrix3; + Matrix4 a_Matrix4, b_Matrix4; + Transform3 a_Transform3, b_Transform3; + Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; + Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; + Point3 a_Point3, b_Point3, c_Point3, d_Point3; + Quat a_Quat, b_Quat, c_Quat, d_Quat; + vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + print( a_Vector3, "set Vector3 with floats" ); + print( b_Vector3, "set Vector3 with floats" ); + print( c_Vector3, "set Vector3 with floats" ); + print( d_Vector3, "set Vector3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Vector4, "set Vector4 with floats" ); + print( b_Vector4, "set Vector4 with floats" ); + print( c_Vector4, "set Vector4 with floats" ); + print( d_Vector4, "set Vector4 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Point3 = Point3( rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + print( a_Point3, "set Point3 with floats" ); + print( b_Point3, "set Point3 with floats" ); + print( c_Point3, "set Point3 with floats" ); + print( d_Point3, "set Point3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Quat, "set Quat with floats" ); + print( b_Quat, "set Quat with floats" ); + print( c_Quat, "set Quat with floats" ); + print( d_Quat, "set Quat with floats" ); + a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 ); + b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 ); + print( a_Matrix3, "set Matrix3 columns" ); + print( b_Matrix3, "set Matrix3 columns" ); + a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 ); + b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 ); + print( a_Matrix4, "set Matrix4 columns" ); + print( b_Matrix4, "set Matrix4 columns" ); + a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 ); + b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 ); + print( a_Transform3, "set Transform3 columns" ); + print( b_Transform3, "set Transform3 columns" ); + print( appendScale( a_Matrix3, a_Vector3 ), "appendScale Matrix3 Vector3" ); + print( prependScale( a_Vector3, a_Matrix3 ), "prependScale Vector3 Matrix3" ); + print( mulPerElem( a_Matrix3, b_Matrix3 ), "mulPerElem Matrix3" ); + print( absPerElem( a_Matrix3 ), "absPerElem Matrix3" ); + print( transpose( a_Matrix3 ), "transpose Matrix3" ); + print( inverse( a_Matrix3 ), "inverse Matrix3" ); + print( ( inverse( a_Matrix3 ) * a_Matrix3 ), "inverse(Matrix3) * Matrix3" ); + printf("%f\n", getfloat(determinant( a_Matrix3 )) ); + print( outer( a_Vector3, b_Vector3 ), "outer Vector3" ); + print( rowMul( a_Vector3, a_Matrix3 ), "rowMul Vector3" ); + print( crossMatrix( a_Vector3 ), "crossMatrix" ); + print( crossMatrixMul( a_Vector3, a_Matrix3 ), "crossMatrixMul" ); +} + +void +Matrix4_methods_test() +{ + Matrix3 a_Matrix3, b_Matrix3; + Matrix4 a_Matrix4, b_Matrix4; + Transform3 a_Transform3, b_Transform3; + Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; + Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; + Point3 a_Point3, b_Point3, c_Point3, d_Point3; + Quat a_Quat, b_Quat, c_Quat, d_Quat; + vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + print( a_Vector3, "set Vector3 with floats" ); + print( b_Vector3, "set Vector3 with floats" ); + print( c_Vector3, "set Vector3 with floats" ); + print( d_Vector3, "set Vector3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Vector4, "set Vector4 with floats" ); + print( b_Vector4, "set Vector4 with floats" ); + print( c_Vector4, "set Vector4 with floats" ); + print( d_Vector4, "set Vector4 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Point3 = Point3( rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + print( a_Point3, "set Point3 with floats" ); + print( b_Point3, "set Point3 with floats" ); + print( c_Point3, "set Point3 with floats" ); + print( d_Point3, "set Point3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Quat, "set Quat with floats" ); + print( b_Quat, "set Quat with floats" ); + print( c_Quat, "set Quat with floats" ); + print( d_Quat, "set Quat with floats" ); + a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 ); + b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 ); + print( a_Matrix3, "set Matrix3 columns" ); + print( b_Matrix3, "set Matrix3 columns" ); + a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 ); + b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 ); + print( a_Matrix4, "set Matrix4 columns" ); + print( b_Matrix4, "set Matrix4 columns" ); + a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 ); + b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 ); + print( a_Transform3, "set Transform3 columns" ); + print( b_Transform3, "set Transform3 columns" ); + print( appendScale( a_Matrix4, a_Vector3 ), "appendScale Matrix4 Vector3" ); + print( prependScale( a_Vector3, a_Matrix4 ), "prependScale Vector3 Matrix4" ); + print( mulPerElem( a_Matrix4, b_Matrix4 ), "mulPerElem Matrix4" ); + print( absPerElem( a_Matrix4 ), "absPerElem Matrix4" ); + print( transpose( a_Matrix4 ), "transpose Matrix4" ); + print( inverse( a_Matrix4 ), "inverse Matrix4" ); + print( ( inverse( a_Matrix4 ) * a_Matrix4 ), "inverse(Matrix4) * Matrix4" ); + a_Matrix4.setRow( 3, Vector4( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ) ); + a_Matrix4.setUpper3x3( Matrix3( normalize( a_Quat ) ) ); + print( affineInverse( a_Matrix4 ), "affineInverse Matrix4" ); + print( ( affineInverse( a_Matrix4 ) * a_Matrix4 ), "affineInverse(Matrix4) * Matrix4" ); + print( orthoInverse( a_Matrix4 ), "orthoInverse Matrix4" ); + print( ( orthoInverse( a_Matrix4 ) * a_Matrix4 ), "orthoInverse(Matrix4) * Matrix4" ); + printf("%f\n", getfloat(determinant( a_Matrix4 )) ); + print( outer( a_Vector4, b_Vector4 ), "outer Vector4" ); +} + +void +Transform3_methods_test() +{ + Matrix3 a_Matrix3, b_Matrix3; + Matrix4 a_Matrix4, b_Matrix4; + Transform3 a_Transform3, b_Transform3; + Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; + Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; + Point3 a_Point3, b_Point3, c_Point3, d_Point3; + Quat a_Quat, b_Quat, c_Quat, d_Quat; + vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6; + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); + print( a_Vector3, "set Vector3 with floats" ); + print( b_Vector3, "set Vector3 with floats" ); + print( c_Vector3, "set Vector3 with floats" ); + print( d_Vector3, "set Vector3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Vector4, "set Vector4 with floats" ); + print( b_Vector4, "set Vector4 with floats" ); + print( c_Vector4, "set Vector4 with floats" ); + print( d_Vector4, "set Vector4 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Point3 = Point3( rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); + print( a_Point3, "set Point3 with floats" ); + print( b_Point3, "set Point3 with floats" ); + print( c_Point3, "set Point3 with floats" ); + print( d_Point3, "set Point3 with floats" ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + rndflt5 = randfloat(); + rndflt6 = randfloat(); + b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + rndflt1 = randfloat(); + rndflt2 = randfloat(); + rndflt3 = randfloat(); + rndflt4 = randfloat(); + d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); + print( a_Quat, "set Quat with floats" ); + print( b_Quat, "set Quat with floats" ); + print( c_Quat, "set Quat with floats" ); + print( d_Quat, "set Quat with floats" ); + a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 ); + b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 ); + print( a_Matrix3, "set Matrix3 columns" ); + print( b_Matrix3, "set Matrix3 columns" ); + a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 ); + b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 ); + print( a_Matrix4, "set Matrix4 columns" ); + print( b_Matrix4, "set Matrix4 columns" ); + a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 ); + b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 ); + print( a_Transform3, "set Transform3 columns" ); + print( b_Transform3, "set Transform3 columns" ); + print( appendScale( a_Transform3, a_Vector3 ), "appendScale Transform3 Vector3" ); + print( prependScale( a_Vector3, a_Transform3 ), "prependScale Vector3 Transform3" ); + print( mulPerElem( a_Transform3, b_Transform3 ), "mulPerElem Transform3" ); + print( absPerElem( a_Transform3 ), "absPerElem Transform3" ); + print( inverse( a_Transform3 ), "inverse Transform3" ); + print( ( inverse( a_Transform3 ) * a_Transform3 ), "inverse(Transform3) * Transform3" ); + a_Transform3.setUpper3x3( Matrix3( normalize( a_Quat ) ) ); + print( orthoInverse( a_Transform3 ), "orthoInverse Transform3" ); + print( ( orthoInverse( a_Transform3 ) * a_Transform3 ), "orthoInverse(Transform3) * Transform3" ); +} + +int main() +{ + int i; + printf("\n __begin__ \n"); + for ( i = 0; i < 2; i++ ) { + Matrix3_methods_test(); + Matrix4_methods_test(); + Transform3_methods_test(); + } + printf("\n __end__ \n"); + return 0; +}